diff --git a/go/src/cmd/compile/internal/abi/abiutils.go b/go/src/cmd/compile/internal/abi/abiutils.go new file mode 100644 index 0000000000000000000000000000000000000000..7acab36e8df3e2e709922b74d21cde5ef1a52b5a --- /dev/null +++ b/go/src/cmd/compile/internal/abi/abiutils.go @@ -0,0 +1,688 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package abi + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" + "fmt" + "math" + "sync" +) + +//...................................................................... +// +// Public/exported bits of the ABI utilities. +// + +// ABIParamResultInfo stores the results of processing a given +// function type to compute stack layout and register assignments. For +// each input and output parameter we capture whether the param was +// register-assigned (and to which register(s)) or the stack offset +// for the param if is not going to be passed in registers according +// to the rules in the Go internal ABI specification (1.17). +type ABIParamResultInfo struct { + inparams []ABIParamAssignment // Includes receiver for method calls. Does NOT include hidden closure pointer. + outparams []ABIParamAssignment + offsetToSpillArea int64 + spillAreaSize int64 + inRegistersUsed int + outRegistersUsed int + config *ABIConfig // to enable String() method +} + +func (a *ABIParamResultInfo) Config() *ABIConfig { + return a.config +} + +func (a *ABIParamResultInfo) InParams() []ABIParamAssignment { + return a.inparams +} + +func (a *ABIParamResultInfo) OutParams() []ABIParamAssignment { + return a.outparams +} + +func (a *ABIParamResultInfo) InRegistersUsed() int { + return a.inRegistersUsed +} + +func (a *ABIParamResultInfo) OutRegistersUsed() int { + return a.outRegistersUsed +} + +func (a *ABIParamResultInfo) InParam(i int) *ABIParamAssignment { + return &a.inparams[i] +} + +func (a *ABIParamResultInfo) OutParam(i int) *ABIParamAssignment { + return &a.outparams[i] +} + +func (a *ABIParamResultInfo) SpillAreaOffset() int64 { + return a.offsetToSpillArea +} + +func (a *ABIParamResultInfo) SpillAreaSize() int64 { + return a.spillAreaSize +} + +// ArgWidth returns the amount of stack needed for all the inputs +// and outputs of a function or method, including ABI-defined parameter +// slots and ABI-defined spill slots for register-resident parameters. +// The name is inherited from (*Type).ArgWidth(), which it replaces. +func (a *ABIParamResultInfo) ArgWidth() int64 { + return a.spillAreaSize + a.offsetToSpillArea - a.config.LocalsOffset() +} + +// RegIndex stores the index into the set of machine registers used by +// the ABI on a specific architecture for parameter passing. RegIndex +// values 0 through N-1 (where N is the number of integer registers +// used for param passing according to the ABI rules) describe integer +// registers; values N through M (where M is the number of floating +// point registers used). Thus if the ABI says there are 5 integer +// registers and 7 floating point registers, then RegIndex value of 4 +// indicates the 5th integer register, and a RegIndex value of 11 +// indicates the 7th floating point register. +type RegIndex uint8 + +// ABIParamAssignment holds information about how a specific param or +// result will be passed: in registers (in which case 'Registers' is +// populated) or on the stack (in which case 'Offset' is set to a +// non-negative stack offset). The values in 'Registers' are indices +// (as described above), not architected registers. +type ABIParamAssignment struct { + Type *types.Type + Name *ir.Name + Registers []RegIndex + offset int32 +} + +// Offset returns the stack offset for addressing the parameter that "a" describes. +// This will panic if "a" describes a register-allocated parameter. +func (a *ABIParamAssignment) Offset() int32 { + if len(a.Registers) > 0 { + base.Fatalf("register allocated parameters have no offset") + } + return a.offset +} + +// RegisterTypes returns a slice of the types of the registers +// corresponding to a slice of parameters. The returned slice +// has capacity for one more, likely a memory type. +func RegisterTypes(apa []ABIParamAssignment) []*types.Type { + rcount := 0 + for _, pa := range apa { + rcount += len(pa.Registers) + } + if rcount == 0 { + // Note that this catches top-level struct{} and [0]Foo, which are stack allocated. + return make([]*types.Type, 0, 1) + } + rts := make([]*types.Type, 0, rcount+1) + for _, pa := range apa { + if len(pa.Registers) == 0 { + continue + } + rts = appendParamTypes(rts, pa.Type) + } + return rts +} + +func (pa *ABIParamAssignment) RegisterTypesAndOffsets() ([]*types.Type, []int64) { + l := len(pa.Registers) + if l == 0 { + return nil, nil + } + typs := make([]*types.Type, 0, l) + offs := make([]int64, 0, l) + offs, _ = appendParamOffsets(offs, 0, pa.Type) // 0 is aligned for everything. + return appendParamTypes(typs, pa.Type), offs +} + +func appendParamTypes(rts []*types.Type, t *types.Type) []*types.Type { + w := t.Size() + if w == 0 { + return rts + } + if t.IsScalar() || t.IsPtrShaped() || t.IsSIMD() { + if t.IsComplex() { + c := types.FloatForComplex(t) + return append(rts, c, c) + } else { + if int(t.Size()) <= types.RegSize || t.IsSIMD() { + return append(rts, t) + } + // assume 64bit int on 32-bit machine + // TODO endianness? Should high-order (sign bits) word come first? + if t.IsSigned() { + rts = append(rts, types.Types[types.TINT32]) + } else { + rts = append(rts, types.Types[types.TUINT32]) + } + return append(rts, types.Types[types.TUINT32]) + } + } else { + typ := t.Kind() + switch typ { + case types.TARRAY: + for i := int64(0); i < t.NumElem(); i++ { // 0 gets no registers, plus future-proofing. + rts = appendParamTypes(rts, t.Elem()) + } + case types.TSTRUCT: + for _, f := range t.Fields() { + if f.Type.Size() > 0 { // embedded zero-width types receive no registers + rts = appendParamTypes(rts, f.Type) + } + } + case types.TSLICE: + return appendParamTypes(rts, synthSlice) + case types.TSTRING: + return appendParamTypes(rts, synthString) + case types.TINTER: + return appendParamTypes(rts, synthIface) + } + } + return rts +} + +// appendParamOffsets appends the offset(s) of type t, starting from "at", +// to input offsets, and returns the longer slice and the next unused offset. +// at should already be aligned for t. +func appendParamOffsets(offsets []int64, at int64, t *types.Type) ([]int64, int64) { + w := t.Size() + if w == 0 { + return offsets, at + } + if t.IsSIMD() { + return append(offsets, at), at + w + } + if t.IsScalar() || t.IsPtrShaped() { + if t.IsComplex() || int(t.Size()) > types.RegSize { // complex and *int64 on 32-bit + s := w / 2 + return append(offsets, at, at+s), at + w + } else { + return append(offsets, at), at + w + } + } else { + typ := t.Kind() + switch typ { + case types.TARRAY: + te := t.Elem() + for i := int64(0); i < t.NumElem(); i++ { + at = align(at, te) + offsets, at = appendParamOffsets(offsets, at, te) + } + case types.TSTRUCT: + at0 := at + for i, f := range t.Fields() { + at = at0 + f.Offset // Fields may be over-aligned, see wasm32. + offsets, at = appendParamOffsets(offsets, at, f.Type) + if f.Type.Size() == 0 && i == t.NumFields()-1 { + at++ // last field has zero width + } + } + at = align(at, t) // type size is rounded up to its alignment + case types.TSLICE: + return appendParamOffsets(offsets, at, synthSlice) + case types.TSTRING: + return appendParamOffsets(offsets, at, synthString) + case types.TINTER: + return appendParamOffsets(offsets, at, synthIface) + } + } + return offsets, at +} + +// FrameOffset returns the frame-pointer-relative location that a function +// would spill its input or output parameter to, if such a spill slot exists. +// If there is none defined (e.g., register-allocated outputs) it panics. +// For register-allocated inputs that is their spill offset reserved for morestack; +// for stack-allocated inputs and outputs, that is their location on the stack. +// (In a future version of the ABI, register-resident inputs may lose their defined +// spill area to help reduce stack sizes.) +func (a *ABIParamAssignment) FrameOffset(i *ABIParamResultInfo) int64 { + if a.offset == -1 { + base.Fatalf("function parameter has no ABI-defined frame-pointer offset") + } + if len(a.Registers) == 0 { // passed on stack + return int64(a.offset) - i.config.LocalsOffset() + } + // spill area for registers + return int64(a.offset) + i.SpillAreaOffset() - i.config.LocalsOffset() +} + +// RegAmounts holds a specified number of integer/float registers. +type RegAmounts struct { + intRegs int + floatRegs int +} + +// ABIConfig captures the number of registers made available +// by the ABI rules for parameter passing and result returning. +type ABIConfig struct { + // Do we need anything more than this? + offsetForLocals int64 // e.g., obj.(*Link).Arch.FixedFrameSize -- extra linkage information on some architectures. + regAmounts RegAmounts + which obj.ABI +} + +// NewABIConfig returns a new ABI configuration for an architecture with +// iRegsCount integer/pointer registers and fRegsCount floating point registers. +func NewABIConfig(iRegsCount, fRegsCount int, offsetForLocals int64, which uint8) *ABIConfig { + return &ABIConfig{offsetForLocals: offsetForLocals, regAmounts: RegAmounts{iRegsCount, fRegsCount}, which: obj.ABI(which)} +} + +// Copy returns config. +// +// TODO(mdempsky): Remove. +func (config *ABIConfig) Copy() *ABIConfig { + return config +} + +// Which returns the ABI number +func (config *ABIConfig) Which() obj.ABI { + return config.which +} + +// LocalsOffset returns the architecture-dependent offset from SP for args and results. +// In theory this is only used for debugging; it ought to already be incorporated into +// results from the ABI-related methods +func (config *ABIConfig) LocalsOffset() int64 { + return config.offsetForLocals +} + +// FloatIndexFor translates r into an index in the floating point parameter +// registers. If the result is negative, the input index was actually for the +// integer parameter registers. +func (config *ABIConfig) FloatIndexFor(r RegIndex) int64 { + return int64(r) - int64(config.regAmounts.intRegs) +} + +// NumParamRegs returns the total number of registers used to +// represent a parameter of the given type, which must be register +// assignable. +func (config *ABIConfig) NumParamRegs(typ *types.Type) int { + intRegs, floatRegs := typ.Registers() + if intRegs == math.MaxUint8 && floatRegs == math.MaxUint8 { + base.Fatalf("cannot represent parameters of type %v in registers", typ) + } + return int(intRegs) + int(floatRegs) +} + +// ABIAnalyzeTypes takes slices of parameter and result types, and returns an ABIParamResultInfo, +// based on the given configuration. This is the same result computed by config.ABIAnalyze applied to the +// corresponding method/function type, except that all the embedded parameter names are nil. +// This is intended for use by ssagen/ssa.go:(*state).rtcall, for runtime functions that lack a parsed function type. +func (config *ABIConfig) ABIAnalyzeTypes(params, results []*types.Type) *ABIParamResultInfo { + setup() + s := assignState{ + stackOffset: config.offsetForLocals, + rTotal: config.regAmounts, + } + + assignParams := func(params []*types.Type, isResult bool) []ABIParamAssignment { + res := make([]ABIParamAssignment, len(params)) + for i, param := range params { + res[i] = s.assignParam(param, nil, isResult) + } + return res + } + + info := &ABIParamResultInfo{config: config} + + // Inputs + info.inparams = assignParams(params, false) + s.stackOffset = types.RoundUp(s.stackOffset, int64(types.RegSize)) + info.inRegistersUsed = s.rUsed.intRegs + s.rUsed.floatRegs + + // Outputs + s.rUsed = RegAmounts{} + info.outparams = assignParams(results, true) + // The spill area is at a register-aligned offset and its size is rounded up to a register alignment. + // TODO in theory could align offset only to minimum required by spilled data types. + info.offsetToSpillArea = alignTo(s.stackOffset, types.RegSize) + info.spillAreaSize = alignTo(s.spillOffset, types.RegSize) + info.outRegistersUsed = s.rUsed.intRegs + s.rUsed.floatRegs + + return info +} + +// ABIAnalyzeFuncType takes a function type 'ft' and an ABI rules description +// 'config' and analyzes the function to determine how its parameters +// and results will be passed (in registers or on the stack), returning +// an ABIParamResultInfo object that holds the results of the analysis. +func (config *ABIConfig) ABIAnalyzeFuncType(ft *types.Type) *ABIParamResultInfo { + setup() + s := assignState{ + stackOffset: config.offsetForLocals, + rTotal: config.regAmounts, + } + + assignParams := func(params []*types.Field, isResult bool) []ABIParamAssignment { + res := make([]ABIParamAssignment, len(params)) + for i, param := range params { + var name *ir.Name + if param.Nname != nil { + name = param.Nname.(*ir.Name) + } + res[i] = s.assignParam(param.Type, name, isResult) + } + return res + } + + info := &ABIParamResultInfo{config: config} + + // Inputs + info.inparams = assignParams(ft.RecvParams(), false) + s.stackOffset = types.RoundUp(s.stackOffset, int64(types.RegSize)) + info.inRegistersUsed = s.rUsed.intRegs + s.rUsed.floatRegs + + // Outputs + s.rUsed = RegAmounts{} + info.outparams = assignParams(ft.Results(), true) + // The spill area is at a register-aligned offset and its size is rounded up to a register alignment. + // TODO in theory could align offset only to minimum required by spilled data types. + info.offsetToSpillArea = alignTo(s.stackOffset, types.RegSize) + info.spillAreaSize = alignTo(s.spillOffset, types.RegSize) + info.outRegistersUsed = s.rUsed.intRegs + s.rUsed.floatRegs + return info +} + +// ABIAnalyze returns the same result as ABIAnalyzeFuncType, but also +// updates the offsets of all the receiver, input, and output fields. +// If setNname is true, it also sets the FrameOffset of the Nname for +// the field(s); this is for use when compiling a function and figuring out +// spill locations. Doing this for callers can cause races for register +// outputs because their frame location transitions from BOGUS_FUNARG_OFFSET +// to zero to an as-if-AUTO offset that has no use for callers. +func (config *ABIConfig) ABIAnalyze(t *types.Type, setNname bool) *ABIParamResultInfo { + result := config.ABIAnalyzeFuncType(t) + + // Fill in the frame offsets for receiver, inputs, results + for i, f := range t.RecvParams() { + config.updateOffset(result, f, result.inparams[i], false, setNname) + } + for i, f := range t.Results() { + config.updateOffset(result, f, result.outparams[i], true, setNname) + } + return result +} + +func (config *ABIConfig) updateOffset(result *ABIParamResultInfo, f *types.Field, a ABIParamAssignment, isResult, setNname bool) { + if f.Offset != types.BADWIDTH { + base.Fatalf("field offset for %s at %s has been set to %d", f.Sym, base.FmtPos(f.Pos), f.Offset) + } + + // Everything except return values in registers has either a frame home (if not in a register) or a frame spill location. + if !isResult || len(a.Registers) == 0 { + // The type frame offset DOES NOT show effects of minimum frame size. + // Getting this wrong breaks stackmaps, see liveness/plive.go:WriteFuncMap and typebits/typebits.go:Set + off := a.FrameOffset(result) + if setNname && f.Nname != nil { + f.Nname.(*ir.Name).SetFrameOffset(off) + f.Nname.(*ir.Name).SetIsOutputParamInRegisters(false) + } + } else { + if setNname && f.Nname != nil { + fname := f.Nname.(*ir.Name) + fname.SetIsOutputParamInRegisters(true) + fname.SetFrameOffset(0) + } + } +} + +//...................................................................... +// +// Non-public portions. + +// regString produces a human-readable version of a RegIndex. +func (c *RegAmounts) regString(r RegIndex) string { + if int(r) < c.intRegs { + return fmt.Sprintf("I%d", int(r)) + } else if int(r) < c.intRegs+c.floatRegs { + return fmt.Sprintf("F%d", int(r)-c.intRegs) + } + return fmt.Sprintf("%d", r) +} + +// ToString method renders an ABIParamAssignment in human-readable +// form, suitable for debugging or unit testing. +func (ri *ABIParamAssignment) ToString(config *ABIConfig, extra bool) string { + regs := "R{" + offname := "spilloffset" // offset is for spill for register(s) + if len(ri.Registers) == 0 { + offname = "offset" // offset is for memory arg + } + for _, r := range ri.Registers { + regs += " " + config.regAmounts.regString(r) + if extra { + regs += fmt.Sprintf("(%d)", r) + } + } + if extra { + regs += fmt.Sprintf(" | #I=%d, #F=%d", config.regAmounts.intRegs, config.regAmounts.floatRegs) + } + return fmt.Sprintf("%s } %s: %d typ: %v", regs, offname, ri.offset, ri.Type) +} + +// String method renders an ABIParamResultInfo in human-readable +// form, suitable for debugging or unit testing. +func (ri *ABIParamResultInfo) String() string { + res := "" + for k, p := range ri.inparams { + res += fmt.Sprintf("IN %d: %s\n", k, p.ToString(ri.config, false)) + } + for k, r := range ri.outparams { + res += fmt.Sprintf("OUT %d: %s\n", k, r.ToString(ri.config, false)) + } + res += fmt.Sprintf("offsetToSpillArea: %d spillAreaSize: %d", + ri.offsetToSpillArea, ri.spillAreaSize) + return res +} + +// assignState holds intermediate state during the register assigning process +// for a given function signature. +type assignState struct { + rTotal RegAmounts // total reg amounts from ABI rules + rUsed RegAmounts // regs used by params completely assigned so far + stackOffset int64 // current stack offset + spillOffset int64 // current spill offset +} + +// align returns a rounded up to t's alignment. +func align(a int64, t *types.Type) int64 { + return alignTo(a, int(uint8(t.Alignment()))) +} + +// alignTo returns a rounded up to t, where t must be 0 or a power of 2. +func alignTo(a int64, t int) int64 { + if t == 0 { + return a + } + return types.RoundUp(a, int64(t)) +} + +// nextSlot allocates the next available slot for typ. +func nextSlot(offsetp *int64, typ *types.Type) int64 { + offset := align(*offsetp, typ) + *offsetp = offset + typ.Size() + return offset +} + +// allocateRegs returns an ordered list of register indices for a parameter or result +// that we've just determined to be register-assignable. The number of registers +// needed is assumed to be stored in state.pUsed. +func (state *assignState) allocateRegs(regs []RegIndex, t *types.Type) []RegIndex { + if t.Size() == 0 { + return regs + } + ri := state.rUsed.intRegs + rf := state.rUsed.floatRegs + if t.IsScalar() || t.IsPtrShaped() || t.IsSIMD() { + if t.IsComplex() { + regs = append(regs, RegIndex(rf+state.rTotal.intRegs), RegIndex(rf+1+state.rTotal.intRegs)) + rf += 2 + } else if t.IsFloat() || t.IsSIMD() { + regs = append(regs, RegIndex(rf+state.rTotal.intRegs)) + rf += 1 + } else { + n := (int(t.Size()) + types.RegSize - 1) / types.RegSize + for i := 0; i < n; i++ { // looking ahead to really big integers + regs = append(regs, RegIndex(ri)) + ri += 1 + } + } + state.rUsed.intRegs = ri + state.rUsed.floatRegs = rf + return regs + } else { + typ := t.Kind() + switch typ { + case types.TARRAY: + for i := int64(0); i < t.NumElem(); i++ { + regs = state.allocateRegs(regs, t.Elem()) + } + return regs + case types.TSTRUCT: + for _, f := range t.Fields() { + regs = state.allocateRegs(regs, f.Type) + } + return regs + case types.TSLICE: + return state.allocateRegs(regs, synthSlice) + case types.TSTRING: + return state.allocateRegs(regs, synthString) + case types.TINTER: + return state.allocateRegs(regs, synthIface) + } + } + base.Fatalf("was not expecting type %s", t) + panic("unreachable") +} + +// synthOnce ensures that we only create the synth* fake types once. +var synthOnce sync.Once + +// synthSlice, synthString, and syncIface are synthesized struct types +// meant to capture the underlying implementations of string/slice/interface. +var synthSlice *types.Type +var synthString *types.Type +var synthIface *types.Type + +// setup performs setup for the register assignment utilities, manufacturing +// a small set of synthesized types that we'll need along the way. +func setup() { + synthOnce.Do(func() { + fname := types.BuiltinPkg.Lookup + nxp := src.NoXPos + bp := types.NewPtr(types.Types[types.TUINT8]) + it := types.Types[types.TINT] + synthSlice = types.NewStruct([]*types.Field{ + types.NewField(nxp, fname("ptr"), bp), + types.NewField(nxp, fname("len"), it), + types.NewField(nxp, fname("cap"), it), + }) + types.CalcStructSize(synthSlice) + synthString = types.NewStruct([]*types.Field{ + types.NewField(nxp, fname("data"), bp), + types.NewField(nxp, fname("len"), it), + }) + types.CalcStructSize(synthString) + unsp := types.Types[types.TUNSAFEPTR] + synthIface = types.NewStruct([]*types.Field{ + types.NewField(nxp, fname("f1"), unsp), + types.NewField(nxp, fname("f2"), unsp), + }) + types.CalcStructSize(synthIface) + }) +} + +// assignParam processes a given receiver, param, or result +// of field f to determine whether it can be register assigned. +// The result of the analysis is recorded in the result +// ABIParamResultInfo held in 'state'. +func (state *assignState) assignParam(typ *types.Type, name *ir.Name, isResult bool) ABIParamAssignment { + registers := state.tryAllocRegs(typ) + + var offset int64 = -1 + if registers == nil { // stack allocated; needs stack slot + offset = nextSlot(&state.stackOffset, typ) + } else if !isResult { // register-allocated param; needs spill slot + offset = nextSlot(&state.spillOffset, typ) + } + + return ABIParamAssignment{ + Type: typ, + Name: name, + Registers: registers, + offset: int32(offset), + } +} + +// tryAllocRegs attempts to allocate registers to represent a +// parameter of the given type. If unsuccessful, it returns nil. +func (state *assignState) tryAllocRegs(typ *types.Type) []RegIndex { + if typ.Size() == 0 { + return nil // zero-size parameters are defined as being stack allocated + } + + intRegs, floatRegs := typ.Registers() + if int(intRegs) > state.rTotal.intRegs-state.rUsed.intRegs || int(floatRegs) > state.rTotal.floatRegs-state.rUsed.floatRegs { + return nil // too few available registers + } + + regs := make([]RegIndex, 0, int(intRegs)+int(floatRegs)) + return state.allocateRegs(regs, typ) +} + +// ComputePadding returns a list of "post element" padding values in +// the case where we have a structure being passed in registers. Given +// a param assignment corresponding to a struct, it returns a list +// containing padding values for each field, e.g. the Kth element in +// the list is the amount of padding between field K and the following +// field. For things that are not structs (or structs without padding) +// it returns a list of zeros. Example: +// +// type small struct { +// x uint16 +// y uint8 +// z int32 +// w int32 +// } +// +// For this struct we would return a list [0, 1, 0, 0], meaning that +// we have one byte of padding after the second field, and no bytes of +// padding after any of the other fields. Input parameter "storage" is +// a slice with enough capacity to accommodate padding elements for +// the architected register set in question. +func (pa *ABIParamAssignment) ComputePadding(storage []uint64) []uint64 { + nr := len(pa.Registers) + padding := storage[:nr] + clear(padding) + if pa.Type.Kind() != types.TSTRUCT || nr == 0 { + return padding + } + types := make([]*types.Type, 0, nr) + types = appendParamTypes(types, pa.Type) + if len(types) != nr { + panic("internal error") + } + offsets, _ := appendParamOffsets([]int64{}, 0, pa.Type) + for idx, t := range types { + ts := t.Size() + off := offsets[idx] + ts + if idx < len(types)-1 { + noff := offsets[idx+1] + if noff != off { + padding[idx] = uint64(noff - off) + } + } + } + return padding +} diff --git a/go/src/cmd/compile/internal/abt/avlint32.go b/go/src/cmd/compile/internal/abt/avlint32.go new file mode 100644 index 0000000000000000000000000000000000000000..e41a6c0ca40bd87477bc2a2c01065f98b6e836a1 --- /dev/null +++ b/go/src/cmd/compile/internal/abt/avlint32.go @@ -0,0 +1,825 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package abt + +import ( + "fmt" + "strconv" + "strings" +) + +const ( + LEAF_HEIGHT = 1 + ZERO_HEIGHT = 0 + NOT_KEY32 = int32(-0x80000000) +) + +// T is the exported applicative balanced tree data type. +// A T can be used as a value; updates to one copy of the value +// do not change other copies. +type T struct { + root *node32 + size int +} + +// node32 is the internal tree node data type +type node32 struct { + // Standard conventions hold for left = smaller, right = larger + left, right *node32 + data any + key int32 + height_ int8 +} + +func makeNode(key int32) *node32 { + return &node32{key: key, height_: LEAF_HEIGHT} +} + +// IsEmpty returns true iff t is empty. +func (t *T) IsEmpty() bool { + return t.root == nil +} + +// IsSingle returns true iff t is a singleton (leaf). +func (t *T) IsSingle() bool { + return t.root != nil && t.root.isLeaf() +} + +// VisitInOrder applies f to the key and data pairs in t, +// with keys ordered from smallest to largest. +func (t *T) VisitInOrder(f func(int32, any)) { + if t.root == nil { + return + } + t.root.visitInOrder(f) +} + +func (n *node32) nilOrData() any { + if n == nil { + return nil + } + return n.data +} + +func (n *node32) nilOrKeyAndData() (k int32, d any) { + if n == nil { + k = NOT_KEY32 + d = nil + } else { + k = n.key + d = n.data + } + return +} + +func (n *node32) height() int8 { + if n == nil { + return 0 + } + return n.height_ +} + +// Find returns the data associated with x in the tree, or +// nil if x is not in the tree. +func (t *T) Find(x int32) any { + return t.root.find(x).nilOrData() +} + +// Insert either adds x to the tree if x was not previously +// a key in the tree, or updates the data for x in the tree if +// x was already a key in the tree. The previous data associated +// with x is returned, and is nil if x was not previously a +// key in the tree. +func (t *T) Insert(x int32, data any) any { + if x == NOT_KEY32 { + panic("Cannot use sentinel value -0x80000000 as key") + } + n := t.root + var newroot *node32 + var o *node32 + if n == nil { + n = makeNode(x) + newroot = n + } else { + newroot, n, o = n.aInsert(x) + } + var r any + if o != nil { + r = o.data + } else { + t.size++ + } + n.data = data + t.root = newroot + return r +} + +func (t *T) Copy() *T { + u := *t + return &u +} + +func (t *T) Delete(x int32) any { + n := t.root + if n == nil { + return nil + } + d, s := n.aDelete(x) + if d == nil { + return nil + } + t.root = s + t.size-- + return d.data +} + +func (t *T) DeleteMin() (int32, any) { + n := t.root + if n == nil { + return NOT_KEY32, nil + } + d, s := n.aDeleteMin() + if d == nil { + return NOT_KEY32, nil + } + t.root = s + t.size-- + return d.key, d.data +} + +func (t *T) DeleteMax() (int32, any) { + n := t.root + if n == nil { + return NOT_KEY32, nil + } + d, s := n.aDeleteMax() + if d == nil { + return NOT_KEY32, nil + } + t.root = s + t.size-- + return d.key, d.data +} + +func (t *T) Size() int { + return t.size +} + +// Intersection returns the intersection of t and u, where the result +// data for any common keys is given by f(t's data, u's data) -- f need +// not be symmetric. If f returns nil, then the key and data are not +// added to the result. If f itself is nil, then whatever value was +// already present in the smaller set is used. +func (t *T) Intersection(u *T, f func(x, y any) any) *T { + if t.Size() == 0 || u.Size() == 0 { + return &T{} + } + + // For faster execution and less allocation, prefer t smaller, iterate over t. + if t.Size() <= u.Size() { + v := t.Copy() + for it := t.Iterator(); !it.Done(); { + k, d := it.Next() + e := u.Find(k) + if e == nil { + v.Delete(k) + continue + } + if f == nil { + continue + } + if c := f(d, e); c != d { + if c == nil { + v.Delete(k) + } else { + v.Insert(k, c) + } + } + } + return v + } + v := u.Copy() + for it := u.Iterator(); !it.Done(); { + k, e := it.Next() + d := t.Find(k) + if d == nil { + v.Delete(k) + continue + } + if f == nil { + continue + } + if c := f(d, e); c != d { + if c == nil { + v.Delete(k) + } else { + v.Insert(k, c) + } + } + } + + return v +} + +// Union returns the union of t and u, where the result data for any common keys +// is given by f(t's data, u's data) -- f need not be symmetric. If f returns nil, +// then the key and data are not added to the result. If f itself is nil, then +// whatever value was already present in the larger set is used. +func (t *T) Union(u *T, f func(x, y any) any) *T { + if t.Size() == 0 { + return u + } + if u.Size() == 0 { + return t + } + + if t.Size() >= u.Size() { + v := t.Copy() + for it := u.Iterator(); !it.Done(); { + k, e := it.Next() + d := t.Find(k) + if d == nil { + v.Insert(k, e) + continue + } + if f == nil { + continue + } + if c := f(d, e); c != d { + if c == nil { + v.Delete(k) + } else { + v.Insert(k, c) + } + } + } + return v + } + + v := u.Copy() + for it := t.Iterator(); !it.Done(); { + k, d := it.Next() + e := u.Find(k) + if e == nil { + v.Insert(k, d) + continue + } + if f == nil { + continue + } + if c := f(d, e); c != d { + if c == nil { + v.Delete(k) + } else { + v.Insert(k, c) + } + } + } + return v +} + +// Difference returns the difference of t and u, subject to the result +// of f applied to data corresponding to equal keys. If f returns nil +// (or if f is nil) then the key+data are excluded, as usual. If f +// returns not-nil, then that key+data pair is inserted. instead. +func (t *T) Difference(u *T, f func(x, y any) any) *T { + if t.Size() == 0 { + return &T{} + } + if u.Size() == 0 { + return t + } + v := t.Copy() + for it := t.Iterator(); !it.Done(); { + k, d := it.Next() + e := u.Find(k) + if e != nil { + if f == nil { + v.Delete(k) + continue + } + c := f(d, e) + if c == nil { + v.Delete(k) + continue + } + if c != d { + v.Insert(k, c) + } + } + } + return v +} + +func (t *T) Iterator() Iterator { + return Iterator{it: t.root.iterator()} +} + +func (t *T) Equals(u *T) bool { + if t == u { + return true + } + if t.Size() != u.Size() { + return false + } + return t.root.equals(u.root) +} + +func (t *T) String() string { + var b strings.Builder + first := true + for it := t.Iterator(); !it.Done(); { + k, v := it.Next() + if first { + first = false + } else { + b.WriteString("; ") + } + b.WriteString(strconv.FormatInt(int64(k), 10)) + b.WriteString(":") + fmt.Fprint(&b, v) + } + return b.String() +} + +func (t *node32) equals(u *node32) bool { + if t == u { + return true + } + it, iu := t.iterator(), u.iterator() + for !it.done() && !iu.done() { + nt := it.next() + nu := iu.next() + if nt == nu { + continue + } + if nt.key != nu.key { + return false + } + if nt.data != nu.data { + return false + } + } + return it.done() == iu.done() +} + +func (t *T) Equiv(u *T, eqv func(x, y any) bool) bool { + if t == u { + return true + } + if t.Size() != u.Size() { + return false + } + return t.root.equiv(u.root, eqv) +} + +func (t *node32) equiv(u *node32, eqv func(x, y any) bool) bool { + if t == u { + return true + } + it, iu := t.iterator(), u.iterator() + for !it.done() && !iu.done() { + nt := it.next() + nu := iu.next() + if nt == nu { + continue + } + if nt.key != nu.key { + return false + } + if !eqv(nt.data, nu.data) { + return false + } + } + return it.done() == iu.done() +} + +type iterator struct { + parents []*node32 +} + +type Iterator struct { + it iterator +} + +func (it *Iterator) Next() (int32, any) { + x := it.it.next() + if x == nil { + return NOT_KEY32, nil + } + return x.key, x.data +} + +func (it *Iterator) Done() bool { + return len(it.it.parents) == 0 +} + +func (t *node32) iterator() iterator { + if t == nil { + return iterator{} + } + it := iterator{parents: make([]*node32, 0, int(t.height()))} + it.leftmost(t) + return it +} + +func (it *iterator) leftmost(t *node32) { + for t != nil { + it.parents = append(it.parents, t) + t = t.left + } +} + +func (it *iterator) done() bool { + return len(it.parents) == 0 +} + +func (it *iterator) next() *node32 { + l := len(it.parents) + if l == 0 { + return nil + } + x := it.parents[l-1] // return value + if x.right != nil { + it.leftmost(x.right) + return x + } + // discard visited top of parents + l-- + it.parents = it.parents[:l] + y := x // y is known visited/returned + for l > 0 && y == it.parents[l-1].right { + y = it.parents[l-1] + l-- + it.parents = it.parents[:l] + } + + return x +} + +// Min returns the minimum element of t. +// If t is empty, then (NOT_KEY32, nil) is returned. +func (t *T) Min() (k int32, d any) { + return t.root.min().nilOrKeyAndData() +} + +// Max returns the maximum element of t. +// If t is empty, then (NOT_KEY32, nil) is returned. +func (t *T) Max() (k int32, d any) { + return t.root.max().nilOrKeyAndData() +} + +// Glb returns the greatest-lower-bound-exclusive of x and the associated +// data. If x has no glb in the tree, then (NOT_KEY32, nil) is returned. +func (t *T) Glb(x int32) (k int32, d any) { + return t.root.glb(x, false).nilOrKeyAndData() +} + +// GlbEq returns the greatest-lower-bound-inclusive of x and the associated +// data. If x has no glbEQ in the tree, then (NOT_KEY32, nil) is returned. +func (t *T) GlbEq(x int32) (k int32, d any) { + return t.root.glb(x, true).nilOrKeyAndData() +} + +// Lub returns the least-upper-bound-exclusive of x and the associated +// data. If x has no lub in the tree, then (NOT_KEY32, nil) is returned. +func (t *T) Lub(x int32) (k int32, d any) { + return t.root.lub(x, false).nilOrKeyAndData() +} + +// LubEq returns the least-upper-bound-inclusive of x and the associated +// data. If x has no lubEq in the tree, then (NOT_KEY32, nil) is returned. +func (t *T) LubEq(x int32) (k int32, d any) { + return t.root.lub(x, true).nilOrKeyAndData() +} + +func (t *node32) isLeaf() bool { + return t.left == nil && t.right == nil && t.height_ == LEAF_HEIGHT +} + +func (t *node32) visitInOrder(f func(int32, any)) { + if t.left != nil { + t.left.visitInOrder(f) + } + f(t.key, t.data) + if t.right != nil { + t.right.visitInOrder(f) + } +} + +func (t *node32) find(key int32) *node32 { + for t != nil { + if key < t.key { + t = t.left + } else if key > t.key { + t = t.right + } else { + return t + } + } + return nil +} + +func (t *node32) min() *node32 { + if t == nil { + return t + } + for t.left != nil { + t = t.left + } + return t +} + +func (t *node32) max() *node32 { + if t == nil { + return t + } + for t.right != nil { + t = t.right + } + return t +} + +func (t *node32) glb(key int32, allow_eq bool) *node32 { + var best *node32 = nil + for t != nil { + if key <= t.key { + if allow_eq && key == t.key { + return t + } + // t is too big, glb is to left. + t = t.left + } else { + // t is a lower bound, record it and seek a better one. + best = t + t = t.right + } + } + return best +} + +func (t *node32) lub(key int32, allow_eq bool) *node32 { + var best *node32 = nil + for t != nil { + if key >= t.key { + if allow_eq && key == t.key { + return t + } + // t is too small, lub is to right. + t = t.right + } else { + // t is an upper bound, record it and seek a better one. + best = t + t = t.left + } + } + return best +} + +func (t *node32) aInsert(x int32) (newroot, newnode, oldnode *node32) { + // oldnode default of nil is good, others should be assigned. + if x == t.key { + oldnode = t + newt := *t + newnode = &newt + newroot = newnode + return + } + if x < t.key { + if t.left == nil { + t = t.copy() + n := makeNode(x) + t.left = n + newnode = n + newroot = t + t.height_ = 2 // was balanced w/ 0, sibling is height 0 or 1 + return + } + var new_l *node32 + new_l, newnode, oldnode = t.left.aInsert(x) + t = t.copy() + t.left = new_l + if new_l.height() > 1+t.right.height() { + newroot = t.aLeftIsHigh(newnode) + } else { + t.height_ = 1 + max(t.left.height(), t.right.height()) + newroot = t + } + } else { // x > t.key + if t.right == nil { + t = t.copy() + n := makeNode(x) + t.right = n + newnode = n + newroot = t + t.height_ = 2 // was balanced w/ 0, sibling is height 0 or 1 + return + } + var new_r *node32 + new_r, newnode, oldnode = t.right.aInsert(x) + t = t.copy() + t.right = new_r + if new_r.height() > 1+t.left.height() { + newroot = t.aRightIsHigh(newnode) + } else { + t.height_ = 1 + max(t.left.height(), t.right.height()) + newroot = t + } + } + return +} + +func (t *node32) aDelete(key int32) (deleted, newSubTree *node32) { + if t == nil { + return nil, nil + } + + if key < t.key { + oh := t.left.height() + d, tleft := t.left.aDelete(key) + if tleft == t.left { + return d, t + } + return d, t.copy().aRebalanceAfterLeftDeletion(oh, tleft) + } else if key > t.key { + oh := t.right.height() + d, tright := t.right.aDelete(key) + if tright == t.right { + return d, t + } + return d, t.copy().aRebalanceAfterRightDeletion(oh, tright) + } + + if t.height() == LEAF_HEIGHT { + return t, nil + } + + // Interior delete by removing left.Max or right.Min, + // then swapping contents + if t.left.height() > t.right.height() { + oh := t.left.height() + d, tleft := t.left.aDeleteMax() + r := t + t = t.copy() + t.data, t.key = d.data, d.key + return r, t.aRebalanceAfterLeftDeletion(oh, tleft) + } + + oh := t.right.height() + d, tright := t.right.aDeleteMin() + r := t + t = t.copy() + t.data, t.key = d.data, d.key + return r, t.aRebalanceAfterRightDeletion(oh, tright) +} + +func (t *node32) aDeleteMin() (deleted, newSubTree *node32) { + if t == nil { + return nil, nil + } + if t.left == nil { // leaf or left-most + return t, t.right + } + oh := t.left.height() + d, tleft := t.left.aDeleteMin() + if tleft == t.left { + return d, t + } + return d, t.copy().aRebalanceAfterLeftDeletion(oh, tleft) +} + +func (t *node32) aDeleteMax() (deleted, newSubTree *node32) { + if t == nil { + return nil, nil + } + + if t.right == nil { // leaf or right-most + return t, t.left + } + + oh := t.right.height() + d, tright := t.right.aDeleteMax() + if tright == t.right { + return d, t + } + return d, t.copy().aRebalanceAfterRightDeletion(oh, tright) +} + +func (t *node32) aRebalanceAfterLeftDeletion(oldLeftHeight int8, tleft *node32) *node32 { + t.left = tleft + + if oldLeftHeight == tleft.height() || oldLeftHeight == t.right.height() { + // this node is still balanced and its height is unchanged + return t + } + + if oldLeftHeight > t.right.height() { + // left was larger + t.height_-- + return t + } + + // left height fell by 1 and it was already less than right height + t.right = t.right.copy() + return t.aRightIsHigh(nil) +} + +func (t *node32) aRebalanceAfterRightDeletion(oldRightHeight int8, tright *node32) *node32 { + t.right = tright + + if oldRightHeight == tright.height() || oldRightHeight == t.left.height() { + // this node is still balanced and its height is unchanged + return t + } + + if oldRightHeight > t.left.height() { + // left was larger + t.height_-- + return t + } + + // right height fell by 1 and it was already less than left height + t.left = t.left.copy() + return t.aLeftIsHigh(nil) +} + +// aRightIsHigh does rotations necessary to fix a high right child +// assume that t and t.right are already fresh copies. +func (t *node32) aRightIsHigh(newnode *node32) *node32 { + right := t.right + if right.right.height() < right.left.height() { + // double rotation + if newnode != right.left { + right.left = right.left.copy() + } + t.right = right.leftToRoot() + } + t = t.rightToRoot() + return t +} + +// aLeftIsHigh does rotations necessary to fix a high left child +// assume that t and t.left are already fresh copies. +func (t *node32) aLeftIsHigh(newnode *node32) *node32 { + left := t.left + if left.left.height() < left.right.height() { + // double rotation + if newnode != left.right { + left.right = left.right.copy() + } + t.left = left.rightToRoot() + } + t = t.leftToRoot() + return t +} + +// rightToRoot does that rotation, modifying t and t.right in the process. +func (t *node32) rightToRoot() *node32 { + // this + // left right + // rl rr + // + // becomes + // + // right + // this rr + // left rl + // + right := t.right + rl := right.left + right.left = t + // parent's child ptr fixed in caller + t.right = rl + t.height_ = 1 + max(rl.height(), t.left.height()) + right.height_ = 1 + max(t.height(), right.right.height()) + return right +} + +// leftToRoot does that rotation, modifying t and t.left in the process. +func (t *node32) leftToRoot() *node32 { + // this + // left right + // ll lr + // + // becomes + // + // left + // ll this + // lr right + // + left := t.left + lr := left.right + left.right = t + // parent's child ptr fixed in caller + t.left = lr + t.height_ = 1 + max(lr.height(), t.right.height()) + left.height_ = 1 + max(t.height(), left.left.height()) + return left +} + +func (t *node32) copy() *node32 { + u := *t + return &u +} diff --git a/go/src/cmd/compile/internal/abt/avlint32_test.go b/go/src/cmd/compile/internal/abt/avlint32_test.go new file mode 100644 index 0000000000000000000000000000000000000000..71962445f2b1d810564046290b7dada0b9899258 --- /dev/null +++ b/go/src/cmd/compile/internal/abt/avlint32_test.go @@ -0,0 +1,700 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package abt + +import ( + "fmt" + "strconv" + "testing" +) + +func makeTree(te *testing.T, x []int32, check bool) (t *T, k int, min, max int32) { + t = &T{} + k = 0 + min = int32(0x7fffffff) + max = int32(-0x80000000) + history := []*T{} + + for _, d := range x { + d = d + d // double everything for Glb/Lub testing. + + if check { + history = append(history, t.Copy()) + } + + t.Insert(d, stringer(fmt.Sprintf("%v", d))) + + k++ + if d < min { + min = d + } + if d > max { + max = d + } + + if !check { + continue + } + + for j, old := range history { + s, i := old.wellFormed() + if s != "" { + te.Errorf("Old tree consistency problem %v at k=%d, j=%d, old=\n%v, t=\n%v", s, k, j, old.DebugString(), t.DebugString()) + return + } + if i != j { + te.Errorf("Wrong tree size %v, expected %v for old %v", i, j, old.DebugString()) + } + } + s, i := t.wellFormed() + if s != "" { + te.Errorf("Tree consistency problem at %v", s) + return + } + if i != k { + te.Errorf("Wrong tree size %v, expected %v for %v", i, k, t.DebugString()) + return + } + if t.Size() != k { + te.Errorf("Wrong t.Size() %v, expected %v for %v", t.Size(), k, t.DebugString()) + return + } + } + return +} + +func applicInsert(te *testing.T, x []int32) { + makeTree(te, x, true) +} + +func applicFind(te *testing.T, x []int32) { + t, _, _, _ := makeTree(te, x, false) + + for _, d := range x { + d = d + d // double everything for Glb/Lub testing. + s := fmt.Sprintf("%v", d) + f := t.Find(d) + + // data + if s != fmt.Sprint(f) { + te.Errorf("s(%v) != f(%v)", s, f) + } + } +} + +func applicBounds(te *testing.T, x []int32) { + t, _, min, max := makeTree(te, x, false) + for _, d := range x { + d = d + d // double everything for Glb/Lub testing. + s := fmt.Sprintf("%v", d) + + kg, g := t.Glb(d + 1) + kge, ge := t.GlbEq(d) + kl, l := t.Lub(d - 1) + kle, le := t.LubEq(d) + + // keys + if d != kg { + te.Errorf("d(%v) != kg(%v)", d, kg) + } + if d != kl { + te.Errorf("d(%v) != kl(%v)", d, kl) + } + if d != kge { + te.Errorf("d(%v) != kge(%v)", d, kge) + } + if d != kle { + te.Errorf("d(%v) != kle(%v)", d, kle) + } + // data + if s != fmt.Sprint(g) { + te.Errorf("s(%v) != g(%v)", s, g) + } + if s != fmt.Sprint(l) { + te.Errorf("s(%v) != l(%v)", s, l) + } + if s != fmt.Sprint(ge) { + te.Errorf("s(%v) != ge(%v)", s, ge) + } + if s != fmt.Sprint(le) { + te.Errorf("s(%v) != le(%v)", s, le) + } + } + + for _, d := range x { + d = d + d // double everything for Glb/Lub testing. + s := fmt.Sprintf("%v", d) + kge, ge := t.GlbEq(d + 1) + kle, le := t.LubEq(d - 1) + if d != kge { + te.Errorf("d(%v) != kge(%v)", d, kge) + } + if d != kle { + te.Errorf("d(%v) != kle(%v)", d, kle) + } + if s != fmt.Sprint(ge) { + te.Errorf("s(%v) != ge(%v)", s, ge) + } + if s != fmt.Sprint(le) { + te.Errorf("s(%v) != le(%v)", s, le) + } + } + + kg, g := t.Glb(min) + kge, ge := t.GlbEq(min - 1) + kl, l := t.Lub(max) + kle, le := t.LubEq(max + 1) + fmin := t.Find(min - 1) + fmax := t.Find(max + 1) + + if kg != NOT_KEY32 || kge != NOT_KEY32 || kl != NOT_KEY32 || kle != NOT_KEY32 { + te.Errorf("Got non-error-key for missing query") + } + + if g != nil || ge != nil || l != nil || le != nil || fmin != nil || fmax != nil { + te.Errorf("Got non-error-data for missing query") + } +} + +func applicDeleteMin(te *testing.T, x []int32) { + t, _, _, _ := makeTree(te, x, false) + _, size := t.wellFormed() + history := []*T{} + for !t.IsEmpty() { + k, _ := t.Min() + history = append(history, t.Copy()) + kd, _ := t.DeleteMin() + if kd != k { + te.Errorf("Deleted minimum key %v not equal to minimum %v", kd, k) + } + for j, old := range history { + s, i := old.wellFormed() + if s != "" { + te.Errorf("Tree consistency problem %s at old after DeleteMin, old=\n%stree=\n%v", s, old.DebugString(), t.DebugString()) + return + } + if i != len(x)-j { + te.Errorf("Wrong old tree size %v, expected %v after DeleteMin, old=\n%vtree\n%v", i, len(x)-j, old.DebugString(), t.DebugString()) + return + } + } + size-- + s, i := t.wellFormed() + if s != "" { + te.Errorf("Tree consistency problem at %v after DeleteMin, tree=\n%v", s, t.DebugString()) + return + } + if i != size { + te.Errorf("Wrong tree size %v, expected %v after DeleteMin", i, size) + return + } + if t.Size() != size { + te.Errorf("Wrong t.Size() %v, expected %v for %v", t.Size(), i, t.DebugString()) + return + } + } +} + +func applicDeleteMax(te *testing.T, x []int32) { + t, _, _, _ := makeTree(te, x, false) + _, size := t.wellFormed() + history := []*T{} + + for !t.IsEmpty() { + k, _ := t.Max() + history = append(history, t.Copy()) + kd, _ := t.DeleteMax() + if kd != k { + te.Errorf("Deleted maximum key %v not equal to maximum %v", kd, k) + } + + for j, old := range history { + s, i := old.wellFormed() + if s != "" { + te.Errorf("Tree consistency problem %s at old after DeleteMin, old=\n%stree=\n%v", s, old.DebugString(), t.DebugString()) + return + } + if i != len(x)-j { + te.Errorf("Wrong old tree size %v, expected %v after DeleteMin, old=\n%vtree\n%v", i, len(x)-j, old.DebugString(), t.DebugString()) + return + } + } + + size-- + s, i := t.wellFormed() + if s != "" { + te.Errorf("Tree consistency problem at %v after DeleteMax, tree=\n%v", s, t.DebugString()) + return + } + if i != size { + te.Errorf("Wrong tree size %v, expected %v after DeleteMax", i, size) + return + } + if t.Size() != size { + te.Errorf("Wrong t.Size() %v, expected %v for %v", t.Size(), i, t.DebugString()) + return + } + } +} + +func applicDelete(te *testing.T, x []int32) { + t, _, _, _ := makeTree(te, x, false) + _, size := t.wellFormed() + history := []*T{} + + missing := t.Delete(11) + if missing != nil { + te.Errorf("Returned a value when there should have been none, %v", missing) + return + } + + s, i := t.wellFormed() + if s != "" { + te.Errorf("Tree consistency problem at %v after delete of missing value, tree=\n%v", s, t.DebugString()) + return + } + if size != i { + te.Errorf("Delete of missing data should not change tree size, expected %d, got %d", size, i) + return + } + + for _, d := range x { + d += d // double + vWant := fmt.Sprintf("%v", d) + history = append(history, t.Copy()) + v := t.Delete(d) + + for j, old := range history { + s, i := old.wellFormed() + if s != "" { + te.Errorf("Tree consistency problem %s at old after DeleteMin, old=\n%stree=\n%v", s, old.DebugString(), t.DebugString()) + return + } + if i != len(x)-j { + te.Errorf("Wrong old tree size %v, expected %v after DeleteMin, old=\n%vtree\n%v", i, len(x)-j, old.DebugString(), t.DebugString()) + return + } + } + + if v.(*sstring).s != vWant { + te.Errorf("Deleted %v expected %v but got %v", d, vWant, v) + return + } + size-- + s, i := t.wellFormed() + if s != "" { + te.Errorf("Tree consistency problem at %v after Delete %d, tree=\n%v", s, d, t.DebugString()) + return + } + if i != size { + te.Errorf("Wrong tree size %v, expected %v after Delete", i, size) + return + } + if t.Size() != size { + te.Errorf("Wrong t.Size() %v, expected %v for %v", t.Size(), i, t.DebugString()) + return + } + } + +} + +func applicIterator(te *testing.T, x []int32) { + t, _, _, _ := makeTree(te, x, false) + it := t.Iterator() + for !it.Done() { + k0, d0 := it.Next() + k1, d1 := t.DeleteMin() + if k0 != k1 || d0 != d1 { + te.Errorf("Iterator and deleteMin mismatch, k0, k1, d0, d1 = %v, %v, %v, %v", k0, k1, d0, d1) + return + } + } + if t.Size() != 0 { + te.Errorf("Iterator ended early, remaining tree = \n%s", t.DebugString()) + return + } +} + +func equiv(a, b any) bool { + sa, sb := a.(*sstring), b.(*sstring) + return *sa == *sb +} + +func applicEquals(te *testing.T, x, y []int32) { + t, _, _, _ := makeTree(te, x, false) + u, _, _, _ := makeTree(te, y, false) + if !t.Equiv(t, equiv) { + te.Errorf("Equiv failure, t == t, =\n%v", t.DebugString()) + return + } + if !t.Equiv(t.Copy(), equiv) { + te.Errorf("Equiv failure, t == t.Copy(), =\n%v", t.DebugString()) + return + } + if !t.Equiv(u, equiv) { + te.Errorf("Equiv failure, t == u, =\n%v", t.DebugString()) + return + } + v := t.Copy() + + v.DeleteMax() + if t.Equiv(v, equiv) { + te.Errorf("!Equiv failure, t != v, =\n%v\nand%v\n", t.DebugString(), v.DebugString()) + return + } + + if v.Equiv(u, equiv) { + te.Errorf("!Equiv failure, v != u, =\n%v\nand%v\n", v.DebugString(), u.DebugString()) + return + } + +} + +func tree(x []int32) *T { + t := &T{} + for _, d := range x { + t.Insert(d, stringer(fmt.Sprintf("%v", d))) + } + return t +} + +func treePlus1(x []int32) *T { + t := &T{} + for _, d := range x { + t.Insert(d, stringer(fmt.Sprintf("%v", d+1))) + } + return t +} +func TestApplicInsert(t *testing.T) { + applicInsert(t, []int32{24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}) + applicInsert(t, []int32{1, 2, 3, 4}) + applicInsert(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9}) + applicInsert(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}) + applicInsert(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicInsert(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicInsert(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24}) + applicInsert(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2}) +} + +func TestApplicFind(t *testing.T) { + applicFind(t, []int32{24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}) + applicFind(t, []int32{1, 2, 3, 4}) + applicFind(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9}) + applicFind(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}) + applicFind(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicFind(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicFind(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24}) + applicFind(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2}) +} + +func TestBounds(t *testing.T) { + applicBounds(t, []int32{24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}) + applicBounds(t, []int32{1, 2, 3, 4}) + applicBounds(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9}) + applicBounds(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}) + applicBounds(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicBounds(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicBounds(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24}) + applicBounds(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2}) +} +func TestDeleteMin(t *testing.T) { + applicDeleteMin(t, []int32{1, 2, 3, 4}) + applicDeleteMin(t, []int32{24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}) + applicDeleteMin(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9}) + applicDeleteMin(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}) + applicDeleteMin(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicDeleteMin(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicDeleteMin(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24}) + applicDeleteMin(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2}) +} +func TestDeleteMax(t *testing.T) { + applicDeleteMax(t, []int32{24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}) + applicDeleteMax(t, []int32{1, 2, 3, 4}) + applicDeleteMax(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9}) + applicDeleteMax(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}) + applicDeleteMax(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicDeleteMax(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicDeleteMax(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24}) + applicDeleteMax(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2}) +} +func TestDelete(t *testing.T) { + applicDelete(t, []int32{24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}) + applicDelete(t, []int32{1, 2, 3, 4}) + applicDelete(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9}) + applicDelete(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}) + applicDelete(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicDelete(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicDelete(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24}) + applicDelete(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2}) +} +func TestIterator(t *testing.T) { + applicIterator(t, []int32{1, 2, 3, 4}) + applicIterator(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9}) + applicIterator(t, []int32{24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}) + applicIterator(t, []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}) + applicIterator(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicIterator(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicIterator(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24}) + applicIterator(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2}) +} +func TestEquals(t *testing.T) { + applicEquals(t, []int32{1, 2, 3, 4}, []int32{4, 3, 2, 1}) + + applicEquals(t, []int32{24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}, + []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}) + applicEquals(t, []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, + []int32{25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + applicEquals(t, []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24}, + []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2}) +} + +func first(x, y any) any { + return x +} +func second(x, y any) any { + return y +} +func alwaysNil(x, y any) any { + return nil +} +func smaller(x, y any) any { + xi, _ := strconv.Atoi(fmt.Sprint(x)) + yi, _ := strconv.Atoi(fmt.Sprint(y)) + if xi < yi { + return x + } + return y +} +func assert(t *testing.T, expected, got *T, what string) { + s, _ := got.wellFormed() + if s != "" { + t.Errorf("Tree consistency problem %v for 'got' in assert for %s, tree=\n%v", s, what, got.DebugString()) + return + } + + if !expected.Equiv(got, equiv) { + t.Errorf("%s fail, expected\n%vgot\n%v\n", what, expected.DebugString(), got.DebugString()) + } +} + +func TestSetOps(t *testing.T) { + A := tree([]int32{1, 2, 3, 4}) + B := tree([]int32{3, 4, 5, 6, 7}) + + AIB := tree([]int32{3, 4}) + ADB := tree([]int32{1, 2}) + BDA := tree([]int32{5, 6, 7}) + AUB := tree([]int32{1, 2, 3, 4, 5, 6, 7}) + AXB := tree([]int32{1, 2, 5, 6, 7}) + + aib1 := A.Intersection(B, first) + assert(t, AIB, aib1, "aib1") + if A.Find(3) != aib1.Find(3) { + t.Errorf("Failed aliasing/reuse check, A/aib1") + } + aib2 := A.Intersection(B, second) + assert(t, AIB, aib2, "aib2") + if B.Find(3) != aib2.Find(3) { + t.Errorf("Failed aliasing/reuse check, B/aib2") + } + aib3 := B.Intersection(A, first) + assert(t, AIB, aib3, "aib3") + if A.Find(3) != aib3.Find(3) { + // A is smaller, intersection favors reuse from smaller when function is "first" + t.Errorf("Failed aliasing/reuse check, A/aib3") + } + aib4 := B.Intersection(A, second) + assert(t, AIB, aib4, "aib4") + if A.Find(3) != aib4.Find(3) { + t.Errorf("Failed aliasing/reuse check, A/aib4") + } + + aub1 := A.Union(B, first) + assert(t, AUB, aub1, "aub1") + if B.Find(3) != aub1.Find(3) { + // B is larger, union favors reuse from larger when function is "first" + t.Errorf("Failed aliasing/reuse check, A/aub1") + } + aub2 := A.Union(B, second) + assert(t, AUB, aub2, "aub2") + if B.Find(3) != aub2.Find(3) { + t.Errorf("Failed aliasing/reuse check, B/aub2") + } + aub3 := B.Union(A, first) + assert(t, AUB, aub3, "aub3") + if B.Find(3) != aub3.Find(3) { + t.Errorf("Failed aliasing/reuse check, B/aub3") + } + aub4 := B.Union(A, second) + assert(t, AUB, aub4, "aub4") + if A.Find(3) != aub4.Find(3) { + t.Errorf("Failed aliasing/reuse check, A/aub4") + } + + axb1 := A.Union(B, alwaysNil) + assert(t, AXB, axb1, "axb1") + axb2 := B.Union(A, alwaysNil) + assert(t, AXB, axb2, "axb2") + + adb := A.Difference(B, alwaysNil) + assert(t, ADB, adb, "adb") + bda := B.Difference(A, nil) + assert(t, BDA, bda, "bda") + + Ap1 := treePlus1([]int32{1, 2, 3, 4}) + + ada1_1 := A.Difference(Ap1, smaller) + assert(t, A, ada1_1, "ada1_1") + ada1_2 := Ap1.Difference(A, smaller) + assert(t, A, ada1_2, "ada1_2") + +} + +type sstring struct { + s string +} + +func (s *sstring) String() string { + return s.s +} + +func stringer(s string) any { + return &sstring{s} +} + +// wellFormed ensures that a red-black tree meets +// all of its invariants and returns a string identifying +// the first problem encountered. If there is no problem +// then the returned string is empty. The size is also +// returned to allow comparison of calculated tree size +// with expected. +func (t *T) wellFormed() (s string, i int) { + if t.root == nil { + s = "" + i = 0 + return + } + return t.root.wellFormedSubtree(nil, -0x80000000, 0x7fffffff) +} + +// wellFormedSubtree ensures that a red-black subtree meets +// all of its invariants and returns a string identifying +// the first problem encountered. If there is no problem +// then the returned string is empty. The size is also +// returned to allow comparison of calculated tree size +// with expected. +func (t *node32) wellFormedSubtree(parent *node32, keyMin, keyMax int32) (s string, i int) { + i = -1 // initialize to a failing value + s = "" // s is the reason for failure; empty means okay. + + if keyMin >= t.key { + s = " min >= t.key" + return + } + + if keyMax <= t.key { + s = " max <= t.key" + return + } + + l := t.left + r := t.right + + lh := l.height() + rh := r.height() + mh := max(lh, rh) + th := t.height() + dh := lh - rh + if dh < 0 { + dh = -dh + } + if dh > 1 { + s = fmt.Sprintf(" dh > 1, t=%d", t.key) + return + } + + if l == nil && r == nil { + if th != LEAF_HEIGHT { + s = " leaf height wrong" + return + } + } + + if th != mh+1 { + s = " th != mh + 1" + return + } + + if l != nil { + if th <= lh { + s = " t.height <= l.height" + } else if th > 2+lh { + s = " t.height > 2+l.height" + } else if t.key <= l.key { + s = " t.key <= l.key" + } + if s != "" { + return + } + + } + + if r != nil { + if th <= rh { + s = " t.height <= r.height" + } else if th > 2+rh { + s = " t.height > 2+r.height" + } else if t.key >= r.key { + s = " t.key >= r.key" + } + if s != "" { + return + } + } + + ii := 1 + if l != nil { + res, il := l.wellFormedSubtree(t, keyMin, t.key) + if res != "" { + s = ".L" + res + return + } + ii += il + } + if r != nil { + res, ir := r.wellFormedSubtree(t, t.key, keyMax) + if res != "" { + s = ".R" + res + return + } + ii += ir + } + i = ii + return +} + +func (t *T) DebugString() string { + if t.root == nil { + return "" + } + return t.root.DebugString(0) +} + +// DebugString prints the tree with nested information +// to allow an eyeball check on the tree balance. +func (t *node32) DebugString(indent int) string { + s := "" + if t.left != nil { + s = s + t.left.DebugString(indent+1) + } + for i := 0; i < indent; i++ { + s = s + " " + } + s = s + fmt.Sprintf("%v=%v:%d\n", t.key, t.data, t.height_) + if t.right != nil { + s = s + t.right.DebugString(indent+1) + } + return s +} diff --git a/go/src/cmd/compile/internal/amd64/galign.go b/go/src/cmd/compile/internal/amd64/galign.go new file mode 100644 index 0000000000000000000000000000000000000000..ca44263afc476c4eef177df64562920b13e7afdc --- /dev/null +++ b/go/src/cmd/compile/internal/amd64/galign.go @@ -0,0 +1,27 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package amd64 + +import ( + "cmd/compile/internal/ssagen" + "cmd/internal/obj/x86" +) + +var leaptr = x86.ALEAQ + +func Init(arch *ssagen.ArchInfo) { + arch.LinkArch = &x86.Linkamd64 + arch.REGSP = x86.REGSP + arch.MAXWIDTH = 1 << 50 + + arch.ZeroRange = zerorange + arch.Ginsnop = ginsnop + + arch.SSAMarkMoves = ssaMarkMoves + arch.SSAGenValue = ssaGenValue + arch.SSAGenBlock = ssaGenBlock + arch.LoadRegResult = loadRegResult + arch.SpillArgReg = spillArgReg +} diff --git a/go/src/cmd/compile/internal/amd64/ggen.go b/go/src/cmd/compile/internal/amd64/ggen.go new file mode 100644 index 0000000000000000000000000000000000000000..853a10cb9a396aff8a3fabb7e438589ec15e876a --- /dev/null +++ b/go/src/cmd/compile/internal/amd64/ggen.go @@ -0,0 +1,41 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package amd64 + +import ( + "cmd/compile/internal/objw" + "cmd/internal/obj" + "cmd/internal/obj/x86" +) + +func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, state *uint32) *obj.Prog { + if cnt%8 != 0 { + panic("zeroed region not aligned") + } + for cnt >= 16 { + p = pp.Append(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X15, 0, obj.TYPE_MEM, x86.REG_SP, off) + off += 16 + cnt -= 16 + } + if cnt != 0 { + p = pp.Append(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_X15, 0, obj.TYPE_MEM, x86.REG_SP, off) + } + return p +} + +func ginsnop(pp *objw.Progs) *obj.Prog { + // This is a hardware nop (1-byte 0x90) instruction, + // even though we describe it as an explicit XCHGL here. + // Particularly, this does not zero the high 32 bits + // like typical *L opcodes. + // (gas assembles "xchg %eax,%eax" to 0x87 0xc0, which + // does zero the high 32 bits.) + p := pp.Prog(x86.AXCHGL) + p.From.Type = obj.TYPE_REG + p.From.Reg = x86.REG_AX + p.To.Type = obj.TYPE_REG + p.To.Reg = x86.REG_AX + return p +} diff --git a/go/src/cmd/compile/internal/amd64/simdssa.go b/go/src/cmd/compile/internal/amd64/simdssa.go new file mode 100644 index 0000000000000000000000000000000000000000..ea33808a1cf4b5e8816ea2c9abbe3d3dff1dfcdd --- /dev/null +++ b/go/src/cmd/compile/internal/amd64/simdssa.go @@ -0,0 +1,3738 @@ +// Code generated by 'simdgen -o godefs -goroot $GOROOT -xedPath $XED_PATH go.yaml types.yaml categories.yaml'; DO NOT EDIT. + +package amd64 + +import ( + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/internal/obj" + "cmd/internal/obj/x86" +) + +func ssaGenSIMDValue(s *ssagen.State, v *ssa.Value) bool { + var p *obj.Prog + switch v.Op { + case ssa.OpAMD64VAESIMC128, + ssa.OpAMD64VPABSB128, + ssa.OpAMD64VPABSB256, + ssa.OpAMD64VPABSB512, + ssa.OpAMD64VPABSW128, + ssa.OpAMD64VPABSW256, + ssa.OpAMD64VPABSW512, + ssa.OpAMD64VPABSD128, + ssa.OpAMD64VPABSD256, + ssa.OpAMD64VPABSD512, + ssa.OpAMD64VPABSQ128, + ssa.OpAMD64VPABSQ256, + ssa.OpAMD64VPABSQ512, + ssa.OpAMD64VPBROADCASTQ128, + ssa.OpAMD64VBROADCASTSS128, + ssa.OpAMD64VBROADCASTSD256, + ssa.OpAMD64VPBROADCASTD128, + ssa.OpAMD64VPBROADCASTQ256, + ssa.OpAMD64VBROADCASTSS256, + ssa.OpAMD64VBROADCASTSD512, + ssa.OpAMD64VPBROADCASTW128, + ssa.OpAMD64VPBROADCASTD256, + ssa.OpAMD64VPBROADCASTQ512, + ssa.OpAMD64VBROADCASTSS512, + ssa.OpAMD64VPBROADCASTB128, + ssa.OpAMD64VPBROADCASTW256, + ssa.OpAMD64VPBROADCASTD512, + ssa.OpAMD64VPBROADCASTB256, + ssa.OpAMD64VPBROADCASTW512, + ssa.OpAMD64VPBROADCASTB512, + ssa.OpAMD64VCVTPD2PSX128, + ssa.OpAMD64VCVTPD2PSY128, + ssa.OpAMD64VCVTPD2PS256, + ssa.OpAMD64VCVTDQ2PS128, + ssa.OpAMD64VCVTDQ2PS256, + ssa.OpAMD64VCVTDQ2PS512, + ssa.OpAMD64VCVTQQ2PSX128, + ssa.OpAMD64VCVTQQ2PSY128, + ssa.OpAMD64VCVTQQ2PS256, + ssa.OpAMD64VCVTUDQ2PS128, + ssa.OpAMD64VCVTUDQ2PS256, + ssa.OpAMD64VCVTUDQ2PS512, + ssa.OpAMD64VCVTUQQ2PSX128, + ssa.OpAMD64VCVTUQQ2PSY128, + ssa.OpAMD64VCVTUQQ2PS256, + ssa.OpAMD64VCVTPS2PD256, + ssa.OpAMD64VCVTPS2PD512, + ssa.OpAMD64VCVTDQ2PD256, + ssa.OpAMD64VCVTDQ2PD512, + ssa.OpAMD64VCVTQQ2PD128, + ssa.OpAMD64VCVTQQ2PD256, + ssa.OpAMD64VCVTQQ2PD512, + ssa.OpAMD64VCVTUDQ2PD256, + ssa.OpAMD64VCVTUDQ2PD512, + ssa.OpAMD64VCVTUQQ2PD128, + ssa.OpAMD64VCVTUQQ2PD256, + ssa.OpAMD64VCVTUQQ2PD512, + ssa.OpAMD64VCVTTPS2DQ128, + ssa.OpAMD64VCVTTPS2DQ256, + ssa.OpAMD64VCVTTPS2DQ512, + ssa.OpAMD64VCVTTPD2DQX128, + ssa.OpAMD64VCVTTPD2DQY128, + ssa.OpAMD64VCVTTPD2DQ256, + ssa.OpAMD64VCVTTPS2QQ256, + ssa.OpAMD64VCVTTPS2QQ512, + ssa.OpAMD64VCVTTPD2QQ128, + ssa.OpAMD64VCVTTPD2QQ256, + ssa.OpAMD64VCVTTPD2QQ512, + ssa.OpAMD64VCVTTPS2UDQ128, + ssa.OpAMD64VCVTTPS2UDQ256, + ssa.OpAMD64VCVTTPS2UDQ512, + ssa.OpAMD64VCVTTPD2UDQX128, + ssa.OpAMD64VCVTTPD2UDQY128, + ssa.OpAMD64VCVTTPD2UDQ256, + ssa.OpAMD64VCVTTPS2UQQ256, + ssa.OpAMD64VCVTTPS2UQQ512, + ssa.OpAMD64VCVTTPD2UQQ128, + ssa.OpAMD64VCVTTPD2UQQ256, + ssa.OpAMD64VCVTTPD2UQQ512, + ssa.OpAMD64VPMOVSXBQ128, + ssa.OpAMD64VPMOVSXWQ128, + ssa.OpAMD64VPMOVSXDQ128, + ssa.OpAMD64VPMOVZXBQ128, + ssa.OpAMD64VPMOVZXWQ128, + ssa.OpAMD64VPMOVZXDQ128, + ssa.OpAMD64VPMOVSXBD128, + ssa.OpAMD64VPMOVSXWD128, + ssa.OpAMD64VPMOVSXBQ256, + ssa.OpAMD64VPMOVSXWQ256, + ssa.OpAMD64VPMOVZXBD128, + ssa.OpAMD64VPMOVZXWD128, + ssa.OpAMD64VPMOVZXBQ256, + ssa.OpAMD64VPMOVZXWQ256, + ssa.OpAMD64VPMOVSXBW128, + ssa.OpAMD64VPMOVSXBD256, + ssa.OpAMD64VPMOVSXBQ512, + ssa.OpAMD64VPMOVZXBW128, + ssa.OpAMD64VPMOVZXBD256, + ssa.OpAMD64VPMOVZXBQ512, + ssa.OpAMD64VPMOVSXBW256, + ssa.OpAMD64VPMOVSXBW512, + ssa.OpAMD64VPMOVSXBD512, + ssa.OpAMD64VPMOVSXWD256, + ssa.OpAMD64VPMOVSXWD512, + ssa.OpAMD64VPMOVSXWQ512, + ssa.OpAMD64VPMOVSXDQ256, + ssa.OpAMD64VPMOVSXDQ512, + ssa.OpAMD64VPMOVZXBW256, + ssa.OpAMD64VPMOVZXBW512, + ssa.OpAMD64VPMOVZXBD512, + ssa.OpAMD64VPMOVZXWD256, + ssa.OpAMD64VPMOVZXWD512, + ssa.OpAMD64VPMOVZXWQ512, + ssa.OpAMD64VPMOVZXDQ256, + ssa.OpAMD64VPMOVZXDQ512, + ssa.OpAMD64VPLZCNTD128, + ssa.OpAMD64VPLZCNTD256, + ssa.OpAMD64VPLZCNTD512, + ssa.OpAMD64VPLZCNTQ128, + ssa.OpAMD64VPLZCNTQ256, + ssa.OpAMD64VPLZCNTQ512, + ssa.OpAMD64VPOPCNTB128, + ssa.OpAMD64VPOPCNTB256, + ssa.OpAMD64VPOPCNTB512, + ssa.OpAMD64VPOPCNTW128, + ssa.OpAMD64VPOPCNTW256, + ssa.OpAMD64VPOPCNTW512, + ssa.OpAMD64VPOPCNTD128, + ssa.OpAMD64VPOPCNTD256, + ssa.OpAMD64VPOPCNTD512, + ssa.OpAMD64VPOPCNTQ128, + ssa.OpAMD64VPOPCNTQ256, + ssa.OpAMD64VPOPCNTQ512, + ssa.OpAMD64VRCPPS128, + ssa.OpAMD64VRCPPS256, + ssa.OpAMD64VRCP14PS512, + ssa.OpAMD64VRCP14PD128, + ssa.OpAMD64VRCP14PD256, + ssa.OpAMD64VRCP14PD512, + ssa.OpAMD64VRSQRTPS128, + ssa.OpAMD64VRSQRTPS256, + ssa.OpAMD64VRSQRT14PS512, + ssa.OpAMD64VRSQRT14PD128, + ssa.OpAMD64VRSQRT14PD256, + ssa.OpAMD64VRSQRT14PD512, + ssa.OpAMD64VPMOVSWB128_128, + ssa.OpAMD64VPMOVSWB128_256, + ssa.OpAMD64VPMOVSWB256, + ssa.OpAMD64VPMOVSDB128_128, + ssa.OpAMD64VPMOVSDB128_256, + ssa.OpAMD64VPMOVSDB128_512, + ssa.OpAMD64VPMOVSQB128_128, + ssa.OpAMD64VPMOVSQB128_256, + ssa.OpAMD64VPMOVSQB128_512, + ssa.OpAMD64VPMOVSDW128_128, + ssa.OpAMD64VPMOVSDW128_256, + ssa.OpAMD64VPMOVSDW256, + ssa.OpAMD64VPMOVSQW128_128, + ssa.OpAMD64VPMOVSQW128_256, + ssa.OpAMD64VPMOVSQW128_512, + ssa.OpAMD64VPMOVSQD128_128, + ssa.OpAMD64VPMOVSQD128_256, + ssa.OpAMD64VPMOVSQD256, + ssa.OpAMD64VPMOVUSWB128_128, + ssa.OpAMD64VPMOVUSWB128_256, + ssa.OpAMD64VPMOVUSWB256, + ssa.OpAMD64VPMOVUSDB128_128, + ssa.OpAMD64VPMOVUSDB128_256, + ssa.OpAMD64VPMOVUSDB128_512, + ssa.OpAMD64VPMOVUSQB128_128, + ssa.OpAMD64VPMOVUSQB128_256, + ssa.OpAMD64VPMOVUSQB128_512, + ssa.OpAMD64VPMOVUSDW128_128, + ssa.OpAMD64VPMOVUSDW128_256, + ssa.OpAMD64VPMOVUSDW256, + ssa.OpAMD64VPMOVUSQW128_128, + ssa.OpAMD64VPMOVUSQW128_256, + ssa.OpAMD64VPMOVUSQW128_512, + ssa.OpAMD64VPMOVUSQD128_128, + ssa.OpAMD64VPMOVUSQD128_256, + ssa.OpAMD64VPMOVUSQD256, + ssa.OpAMD64VSQRTPS128, + ssa.OpAMD64VSQRTPS256, + ssa.OpAMD64VSQRTPS512, + ssa.OpAMD64VSQRTPD128, + ssa.OpAMD64VSQRTPD256, + ssa.OpAMD64VSQRTPD512, + ssa.OpAMD64VPMOVWB128_128, + ssa.OpAMD64VPMOVWB128_256, + ssa.OpAMD64VPMOVWB256, + ssa.OpAMD64VPMOVDB128_128, + ssa.OpAMD64VPMOVDB128_256, + ssa.OpAMD64VPMOVDB128_512, + ssa.OpAMD64VPMOVQB128_128, + ssa.OpAMD64VPMOVQB128_256, + ssa.OpAMD64VPMOVQB128_512, + ssa.OpAMD64VPMOVDW128_128, + ssa.OpAMD64VPMOVDW128_256, + ssa.OpAMD64VPMOVDW256, + ssa.OpAMD64VPMOVQW128_128, + ssa.OpAMD64VPMOVQW128_256, + ssa.OpAMD64VPMOVQW128_512, + ssa.OpAMD64VPMOVQD128_128, + ssa.OpAMD64VPMOVQD128_256, + ssa.OpAMD64VPMOVQD256: + p = simdV11(s, v) + + case ssa.OpAMD64VAESDECLAST128, + ssa.OpAMD64VAESDECLAST256, + ssa.OpAMD64VAESDECLAST512, + ssa.OpAMD64VAESDEC128, + ssa.OpAMD64VAESDEC256, + ssa.OpAMD64VAESDEC512, + ssa.OpAMD64VAESENCLAST128, + ssa.OpAMD64VAESENCLAST256, + ssa.OpAMD64VAESENCLAST512, + ssa.OpAMD64VAESENC128, + ssa.OpAMD64VAESENC256, + ssa.OpAMD64VAESENC512, + ssa.OpAMD64VADDPS128, + ssa.OpAMD64VADDPS256, + ssa.OpAMD64VADDPS512, + ssa.OpAMD64VADDPD128, + ssa.OpAMD64VADDPD256, + ssa.OpAMD64VADDPD512, + ssa.OpAMD64VPADDB128, + ssa.OpAMD64VPADDB256, + ssa.OpAMD64VPADDB512, + ssa.OpAMD64VPADDW128, + ssa.OpAMD64VPADDW256, + ssa.OpAMD64VPADDW512, + ssa.OpAMD64VPADDD128, + ssa.OpAMD64VPADDD256, + ssa.OpAMD64VPADDD512, + ssa.OpAMD64VPADDQ128, + ssa.OpAMD64VPADDQ256, + ssa.OpAMD64VPADDQ512, + ssa.OpAMD64VHADDPS128, + ssa.OpAMD64VHADDPD128, + ssa.OpAMD64VPHADDW128, + ssa.OpAMD64VPHADDD128, + ssa.OpAMD64VHADDPS256, + ssa.OpAMD64VHADDPD256, + ssa.OpAMD64VPHADDW256, + ssa.OpAMD64VPHADDD256, + ssa.OpAMD64VPHADDSW128, + ssa.OpAMD64VPHADDSW256, + ssa.OpAMD64VPADDSB128, + ssa.OpAMD64VPADDSB256, + ssa.OpAMD64VPADDSB512, + ssa.OpAMD64VPADDSW128, + ssa.OpAMD64VPADDSW256, + ssa.OpAMD64VPADDSW512, + ssa.OpAMD64VPADDUSB128, + ssa.OpAMD64VPADDUSB256, + ssa.OpAMD64VPADDUSB512, + ssa.OpAMD64VPADDUSW128, + ssa.OpAMD64VPADDUSW256, + ssa.OpAMD64VPADDUSW512, + ssa.OpAMD64VADDSUBPS128, + ssa.OpAMD64VADDSUBPS256, + ssa.OpAMD64VADDSUBPD128, + ssa.OpAMD64VADDSUBPD256, + ssa.OpAMD64VPAND128, + ssa.OpAMD64VPAND256, + ssa.OpAMD64VPANDD512, + ssa.OpAMD64VPANDQ512, + ssa.OpAMD64VPANDN128, + ssa.OpAMD64VPANDN256, + ssa.OpAMD64VPANDND512, + ssa.OpAMD64VPANDNQ512, + ssa.OpAMD64VPAVGB128, + ssa.OpAMD64VPAVGB256, + ssa.OpAMD64VPAVGB512, + ssa.OpAMD64VPAVGW128, + ssa.OpAMD64VPAVGW256, + ssa.OpAMD64VPAVGW512, + ssa.OpAMD64VPSIGNB128, + ssa.OpAMD64VPSIGNB256, + ssa.OpAMD64VPSIGNW128, + ssa.OpAMD64VPSIGNW256, + ssa.OpAMD64VPSIGND128, + ssa.OpAMD64VPSIGND256, + ssa.OpAMD64VDIVPS128, + ssa.OpAMD64VDIVPS256, + ssa.OpAMD64VDIVPS512, + ssa.OpAMD64VDIVPD128, + ssa.OpAMD64VDIVPD256, + ssa.OpAMD64VDIVPD512, + ssa.OpAMD64VPMADDWD128, + ssa.OpAMD64VPMADDWD256, + ssa.OpAMD64VPMADDWD512, + ssa.OpAMD64VPMADDUBSW128, + ssa.OpAMD64VPMADDUBSW256, + ssa.OpAMD64VPMADDUBSW512, + ssa.OpAMD64VPCMPEQB128, + ssa.OpAMD64VPCMPEQB256, + ssa.OpAMD64VPCMPEQW128, + ssa.OpAMD64VPCMPEQW256, + ssa.OpAMD64VPCMPEQD128, + ssa.OpAMD64VPCMPEQD256, + ssa.OpAMD64VPCMPEQQ128, + ssa.OpAMD64VPCMPEQQ256, + ssa.OpAMD64VGF2P8MULB128, + ssa.OpAMD64VGF2P8MULB256, + ssa.OpAMD64VGF2P8MULB512, + ssa.OpAMD64VPCMPGTB128, + ssa.OpAMD64VPCMPGTB256, + ssa.OpAMD64VPCMPGTW128, + ssa.OpAMD64VPCMPGTW256, + ssa.OpAMD64VPCMPGTD128, + ssa.OpAMD64VPCMPGTD256, + ssa.OpAMD64VPCMPGTQ128, + ssa.OpAMD64VPCMPGTQ256, + ssa.OpAMD64VPUNPCKHWD128, + ssa.OpAMD64VPUNPCKHDQ128, + ssa.OpAMD64VPUNPCKHQDQ128, + ssa.OpAMD64VPUNPCKHWD256, + ssa.OpAMD64VPUNPCKHWD512, + ssa.OpAMD64VPUNPCKHDQ256, + ssa.OpAMD64VPUNPCKHDQ512, + ssa.OpAMD64VPUNPCKHQDQ256, + ssa.OpAMD64VPUNPCKHQDQ512, + ssa.OpAMD64VPUNPCKLWD128, + ssa.OpAMD64VPUNPCKLDQ128, + ssa.OpAMD64VPUNPCKLQDQ128, + ssa.OpAMD64VPUNPCKLWD256, + ssa.OpAMD64VPUNPCKLWD512, + ssa.OpAMD64VPUNPCKLDQ256, + ssa.OpAMD64VPUNPCKLDQ512, + ssa.OpAMD64VPUNPCKLQDQ256, + ssa.OpAMD64VPUNPCKLQDQ512, + ssa.OpAMD64VMAXPS128, + ssa.OpAMD64VMAXPS256, + ssa.OpAMD64VMAXPS512, + ssa.OpAMD64VMAXPD128, + ssa.OpAMD64VMAXPD256, + ssa.OpAMD64VMAXPD512, + ssa.OpAMD64VPMAXSB128, + ssa.OpAMD64VPMAXSB256, + ssa.OpAMD64VPMAXSB512, + ssa.OpAMD64VPMAXSW128, + ssa.OpAMD64VPMAXSW256, + ssa.OpAMD64VPMAXSW512, + ssa.OpAMD64VPMAXSD128, + ssa.OpAMD64VPMAXSD256, + ssa.OpAMD64VPMAXSD512, + ssa.OpAMD64VPMAXSQ128, + ssa.OpAMD64VPMAXSQ256, + ssa.OpAMD64VPMAXSQ512, + ssa.OpAMD64VPMAXUB128, + ssa.OpAMD64VPMAXUB256, + ssa.OpAMD64VPMAXUB512, + ssa.OpAMD64VPMAXUW128, + ssa.OpAMD64VPMAXUW256, + ssa.OpAMD64VPMAXUW512, + ssa.OpAMD64VPMAXUD128, + ssa.OpAMD64VPMAXUD256, + ssa.OpAMD64VPMAXUD512, + ssa.OpAMD64VPMAXUQ128, + ssa.OpAMD64VPMAXUQ256, + ssa.OpAMD64VPMAXUQ512, + ssa.OpAMD64VMINPS128, + ssa.OpAMD64VMINPS256, + ssa.OpAMD64VMINPS512, + ssa.OpAMD64VMINPD128, + ssa.OpAMD64VMINPD256, + ssa.OpAMD64VMINPD512, + ssa.OpAMD64VPMINSB128, + ssa.OpAMD64VPMINSB256, + ssa.OpAMD64VPMINSB512, + ssa.OpAMD64VPMINSW128, + ssa.OpAMD64VPMINSW256, + ssa.OpAMD64VPMINSW512, + ssa.OpAMD64VPMINSD128, + ssa.OpAMD64VPMINSD256, + ssa.OpAMD64VPMINSD512, + ssa.OpAMD64VPMINSQ128, + ssa.OpAMD64VPMINSQ256, + ssa.OpAMD64VPMINSQ512, + ssa.OpAMD64VPMINUB128, + ssa.OpAMD64VPMINUB256, + ssa.OpAMD64VPMINUB512, + ssa.OpAMD64VPMINUW128, + ssa.OpAMD64VPMINUW256, + ssa.OpAMD64VPMINUW512, + ssa.OpAMD64VPMINUD128, + ssa.OpAMD64VPMINUD256, + ssa.OpAMD64VPMINUD512, + ssa.OpAMD64VPMINUQ128, + ssa.OpAMD64VPMINUQ256, + ssa.OpAMD64VPMINUQ512, + ssa.OpAMD64VMULPS128, + ssa.OpAMD64VMULPS256, + ssa.OpAMD64VMULPS512, + ssa.OpAMD64VMULPD128, + ssa.OpAMD64VMULPD256, + ssa.OpAMD64VMULPD512, + ssa.OpAMD64VPMULLW128, + ssa.OpAMD64VPMULLW256, + ssa.OpAMD64VPMULLW512, + ssa.OpAMD64VPMULLD128, + ssa.OpAMD64VPMULLD256, + ssa.OpAMD64VPMULLD512, + ssa.OpAMD64VPMULLQ128, + ssa.OpAMD64VPMULLQ256, + ssa.OpAMD64VPMULLQ512, + ssa.OpAMD64VPMULDQ128, + ssa.OpAMD64VPMULDQ256, + ssa.OpAMD64VPMULUDQ128, + ssa.OpAMD64VPMULUDQ256, + ssa.OpAMD64VPMULHW128, + ssa.OpAMD64VPMULHW256, + ssa.OpAMD64VPMULHW512, + ssa.OpAMD64VPMULHUW128, + ssa.OpAMD64VPMULHUW256, + ssa.OpAMD64VPMULHUW512, + ssa.OpAMD64VPOR128, + ssa.OpAMD64VPOR256, + ssa.OpAMD64VPORD512, + ssa.OpAMD64VPORQ512, + ssa.OpAMD64VPERMB128, + ssa.OpAMD64VPERMB256, + ssa.OpAMD64VPERMB512, + ssa.OpAMD64VPERMW128, + ssa.OpAMD64VPERMW256, + ssa.OpAMD64VPERMW512, + ssa.OpAMD64VPERMPS256, + ssa.OpAMD64VPERMD256, + ssa.OpAMD64VPERMPS512, + ssa.OpAMD64VPERMD512, + ssa.OpAMD64VPERMPD256, + ssa.OpAMD64VPERMQ256, + ssa.OpAMD64VPERMPD512, + ssa.OpAMD64VPERMQ512, + ssa.OpAMD64VPSHUFB128, + ssa.OpAMD64VPSHUFB256, + ssa.OpAMD64VPSHUFB512, + ssa.OpAMD64VPROLVD128, + ssa.OpAMD64VPROLVD256, + ssa.OpAMD64VPROLVD512, + ssa.OpAMD64VPROLVQ128, + ssa.OpAMD64VPROLVQ256, + ssa.OpAMD64VPROLVQ512, + ssa.OpAMD64VPRORVD128, + ssa.OpAMD64VPRORVD256, + ssa.OpAMD64VPRORVD512, + ssa.OpAMD64VPRORVQ128, + ssa.OpAMD64VPRORVQ256, + ssa.OpAMD64VPRORVQ512, + ssa.OpAMD64VPACKSSDW128, + ssa.OpAMD64VPACKSSDW256, + ssa.OpAMD64VPACKSSDW512, + ssa.OpAMD64VPACKUSDW128, + ssa.OpAMD64VPACKUSDW256, + ssa.OpAMD64VPACKUSDW512, + ssa.OpAMD64VSCALEFPS128, + ssa.OpAMD64VSCALEFPS256, + ssa.OpAMD64VSCALEFPS512, + ssa.OpAMD64VSCALEFPD128, + ssa.OpAMD64VSCALEFPD256, + ssa.OpAMD64VSCALEFPD512, + ssa.OpAMD64VPSLLVW128, + ssa.OpAMD64VPSLLVW256, + ssa.OpAMD64VPSLLVW512, + ssa.OpAMD64VPSLLVD128, + ssa.OpAMD64VPSLLVD256, + ssa.OpAMD64VPSLLVD512, + ssa.OpAMD64VPSLLVQ128, + ssa.OpAMD64VPSLLVQ256, + ssa.OpAMD64VPSLLVQ512, + ssa.OpAMD64VPSRAVW128, + ssa.OpAMD64VPSRAVW256, + ssa.OpAMD64VPSRAVW512, + ssa.OpAMD64VPSRAVD128, + ssa.OpAMD64VPSRAVD256, + ssa.OpAMD64VPSRAVD512, + ssa.OpAMD64VPSRAVQ128, + ssa.OpAMD64VPSRAVQ256, + ssa.OpAMD64VPSRAVQ512, + ssa.OpAMD64VPSRLVW128, + ssa.OpAMD64VPSRLVW256, + ssa.OpAMD64VPSRLVW512, + ssa.OpAMD64VPSRLVD128, + ssa.OpAMD64VPSRLVD256, + ssa.OpAMD64VPSRLVD512, + ssa.OpAMD64VPSRLVQ128, + ssa.OpAMD64VPSRLVQ256, + ssa.OpAMD64VPSRLVQ512, + ssa.OpAMD64VSUBPS128, + ssa.OpAMD64VSUBPS256, + ssa.OpAMD64VSUBPS512, + ssa.OpAMD64VSUBPD128, + ssa.OpAMD64VSUBPD256, + ssa.OpAMD64VSUBPD512, + ssa.OpAMD64VPSUBB128, + ssa.OpAMD64VPSUBB256, + ssa.OpAMD64VPSUBB512, + ssa.OpAMD64VPSUBW128, + ssa.OpAMD64VPSUBW256, + ssa.OpAMD64VPSUBW512, + ssa.OpAMD64VPSUBD128, + ssa.OpAMD64VPSUBD256, + ssa.OpAMD64VPSUBD512, + ssa.OpAMD64VPSUBQ128, + ssa.OpAMD64VPSUBQ256, + ssa.OpAMD64VPSUBQ512, + ssa.OpAMD64VHSUBPS128, + ssa.OpAMD64VHSUBPD128, + ssa.OpAMD64VPHSUBW128, + ssa.OpAMD64VPHSUBD128, + ssa.OpAMD64VHSUBPS256, + ssa.OpAMD64VHSUBPD256, + ssa.OpAMD64VPHSUBW256, + ssa.OpAMD64VPHSUBD256, + ssa.OpAMD64VPHSUBSW128, + ssa.OpAMD64VPHSUBSW256, + ssa.OpAMD64VPSUBSB128, + ssa.OpAMD64VPSUBSB256, + ssa.OpAMD64VPSUBSB512, + ssa.OpAMD64VPSUBSW128, + ssa.OpAMD64VPSUBSW256, + ssa.OpAMD64VPSUBSW512, + ssa.OpAMD64VPSUBUSB128, + ssa.OpAMD64VPSUBUSB256, + ssa.OpAMD64VPSUBUSB512, + ssa.OpAMD64VPSUBUSW128, + ssa.OpAMD64VPSUBUSW256, + ssa.OpAMD64VPSUBUSW512, + ssa.OpAMD64VPSADBW128, + ssa.OpAMD64VPSADBW256, + ssa.OpAMD64VPSADBW512, + ssa.OpAMD64VPXOR128, + ssa.OpAMD64VPXOR256, + ssa.OpAMD64VPXORD512, + ssa.OpAMD64VPXORQ512: + p = simdV21(s, v) + + case ssa.OpAMD64VPCMPEQB512, + ssa.OpAMD64VPCMPEQW512, + ssa.OpAMD64VPCMPEQD512, + ssa.OpAMD64VPCMPEQQ512, + ssa.OpAMD64VPCMPGTB512, + ssa.OpAMD64VPCMPGTW512, + ssa.OpAMD64VPCMPGTD512, + ssa.OpAMD64VPCMPGTQ512: + p = simdV2k(s, v) + + case ssa.OpAMD64VADDPSMasked128, + ssa.OpAMD64VADDPSMasked256, + ssa.OpAMD64VADDPSMasked512, + ssa.OpAMD64VADDPDMasked128, + ssa.OpAMD64VADDPDMasked256, + ssa.OpAMD64VADDPDMasked512, + ssa.OpAMD64VPADDBMasked128, + ssa.OpAMD64VPADDBMasked256, + ssa.OpAMD64VPADDBMasked512, + ssa.OpAMD64VPADDWMasked128, + ssa.OpAMD64VPADDWMasked256, + ssa.OpAMD64VPADDWMasked512, + ssa.OpAMD64VPADDDMasked128, + ssa.OpAMD64VPADDDMasked256, + ssa.OpAMD64VPADDDMasked512, + ssa.OpAMD64VPADDQMasked128, + ssa.OpAMD64VPADDQMasked256, + ssa.OpAMD64VPADDQMasked512, + ssa.OpAMD64VPADDSBMasked128, + ssa.OpAMD64VPADDSBMasked256, + ssa.OpAMD64VPADDSBMasked512, + ssa.OpAMD64VPADDSWMasked128, + ssa.OpAMD64VPADDSWMasked256, + ssa.OpAMD64VPADDSWMasked512, + ssa.OpAMD64VPADDUSBMasked128, + ssa.OpAMD64VPADDUSBMasked256, + ssa.OpAMD64VPADDUSBMasked512, + ssa.OpAMD64VPADDUSWMasked128, + ssa.OpAMD64VPADDUSWMasked256, + ssa.OpAMD64VPADDUSWMasked512, + ssa.OpAMD64VPANDDMasked128, + ssa.OpAMD64VPANDDMasked256, + ssa.OpAMD64VPANDDMasked512, + ssa.OpAMD64VPANDQMasked128, + ssa.OpAMD64VPANDQMasked256, + ssa.OpAMD64VPANDQMasked512, + ssa.OpAMD64VPANDNDMasked128, + ssa.OpAMD64VPANDNDMasked256, + ssa.OpAMD64VPANDNDMasked512, + ssa.OpAMD64VPANDNQMasked128, + ssa.OpAMD64VPANDNQMasked256, + ssa.OpAMD64VPANDNQMasked512, + ssa.OpAMD64VPAVGBMasked128, + ssa.OpAMD64VPAVGBMasked256, + ssa.OpAMD64VPAVGBMasked512, + ssa.OpAMD64VPAVGWMasked128, + ssa.OpAMD64VPAVGWMasked256, + ssa.OpAMD64VPAVGWMasked512, + ssa.OpAMD64VDIVPSMasked128, + ssa.OpAMD64VDIVPSMasked256, + ssa.OpAMD64VDIVPSMasked512, + ssa.OpAMD64VDIVPDMasked128, + ssa.OpAMD64VDIVPDMasked256, + ssa.OpAMD64VDIVPDMasked512, + ssa.OpAMD64VPMADDWDMasked128, + ssa.OpAMD64VPMADDWDMasked256, + ssa.OpAMD64VPMADDWDMasked512, + ssa.OpAMD64VPMADDUBSWMasked128, + ssa.OpAMD64VPMADDUBSWMasked256, + ssa.OpAMD64VPMADDUBSWMasked512, + ssa.OpAMD64VGF2P8MULBMasked128, + ssa.OpAMD64VGF2P8MULBMasked256, + ssa.OpAMD64VGF2P8MULBMasked512, + ssa.OpAMD64VMAXPSMasked128, + ssa.OpAMD64VMAXPSMasked256, + ssa.OpAMD64VMAXPSMasked512, + ssa.OpAMD64VMAXPDMasked128, + ssa.OpAMD64VMAXPDMasked256, + ssa.OpAMD64VMAXPDMasked512, + ssa.OpAMD64VPMAXSBMasked128, + ssa.OpAMD64VPMAXSBMasked256, + ssa.OpAMD64VPMAXSBMasked512, + ssa.OpAMD64VPMAXSWMasked128, + ssa.OpAMD64VPMAXSWMasked256, + ssa.OpAMD64VPMAXSWMasked512, + ssa.OpAMD64VPMAXSDMasked128, + ssa.OpAMD64VPMAXSDMasked256, + ssa.OpAMD64VPMAXSDMasked512, + ssa.OpAMD64VPMAXSQMasked128, + ssa.OpAMD64VPMAXSQMasked256, + ssa.OpAMD64VPMAXSQMasked512, + ssa.OpAMD64VPMAXUBMasked128, + ssa.OpAMD64VPMAXUBMasked256, + ssa.OpAMD64VPMAXUBMasked512, + ssa.OpAMD64VPMAXUWMasked128, + ssa.OpAMD64VPMAXUWMasked256, + ssa.OpAMD64VPMAXUWMasked512, + ssa.OpAMD64VPMAXUDMasked128, + ssa.OpAMD64VPMAXUDMasked256, + ssa.OpAMD64VPMAXUDMasked512, + ssa.OpAMD64VPMAXUQMasked128, + ssa.OpAMD64VPMAXUQMasked256, + ssa.OpAMD64VPMAXUQMasked512, + ssa.OpAMD64VMINPSMasked128, + ssa.OpAMD64VMINPSMasked256, + ssa.OpAMD64VMINPSMasked512, + ssa.OpAMD64VMINPDMasked128, + ssa.OpAMD64VMINPDMasked256, + ssa.OpAMD64VMINPDMasked512, + ssa.OpAMD64VPMINSBMasked128, + ssa.OpAMD64VPMINSBMasked256, + ssa.OpAMD64VPMINSBMasked512, + ssa.OpAMD64VPMINSWMasked128, + ssa.OpAMD64VPMINSWMasked256, + ssa.OpAMD64VPMINSWMasked512, + ssa.OpAMD64VPMINSDMasked128, + ssa.OpAMD64VPMINSDMasked256, + ssa.OpAMD64VPMINSDMasked512, + ssa.OpAMD64VPMINSQMasked128, + ssa.OpAMD64VPMINSQMasked256, + ssa.OpAMD64VPMINSQMasked512, + ssa.OpAMD64VPMINUBMasked128, + ssa.OpAMD64VPMINUBMasked256, + ssa.OpAMD64VPMINUBMasked512, + ssa.OpAMD64VPMINUWMasked128, + ssa.OpAMD64VPMINUWMasked256, + ssa.OpAMD64VPMINUWMasked512, + ssa.OpAMD64VPMINUDMasked128, + ssa.OpAMD64VPMINUDMasked256, + ssa.OpAMD64VPMINUDMasked512, + ssa.OpAMD64VPMINUQMasked128, + ssa.OpAMD64VPMINUQMasked256, + ssa.OpAMD64VPMINUQMasked512, + ssa.OpAMD64VPMULHWMasked128, + ssa.OpAMD64VPMULHWMasked256, + ssa.OpAMD64VPMULHWMasked512, + ssa.OpAMD64VPMULHUWMasked128, + ssa.OpAMD64VPMULHUWMasked256, + ssa.OpAMD64VPMULHUWMasked512, + ssa.OpAMD64VMULPSMasked128, + ssa.OpAMD64VMULPSMasked256, + ssa.OpAMD64VMULPSMasked512, + ssa.OpAMD64VMULPDMasked128, + ssa.OpAMD64VMULPDMasked256, + ssa.OpAMD64VMULPDMasked512, + ssa.OpAMD64VPMULLWMasked128, + ssa.OpAMD64VPMULLWMasked256, + ssa.OpAMD64VPMULLWMasked512, + ssa.OpAMD64VPMULLDMasked128, + ssa.OpAMD64VPMULLDMasked256, + ssa.OpAMD64VPMULLDMasked512, + ssa.OpAMD64VPMULLQMasked128, + ssa.OpAMD64VPMULLQMasked256, + ssa.OpAMD64VPMULLQMasked512, + ssa.OpAMD64VPORDMasked128, + ssa.OpAMD64VPORDMasked256, + ssa.OpAMD64VPORDMasked512, + ssa.OpAMD64VPORQMasked128, + ssa.OpAMD64VPORQMasked256, + ssa.OpAMD64VPORQMasked512, + ssa.OpAMD64VPERMBMasked128, + ssa.OpAMD64VPERMBMasked256, + ssa.OpAMD64VPERMBMasked512, + ssa.OpAMD64VPERMWMasked128, + ssa.OpAMD64VPERMWMasked256, + ssa.OpAMD64VPERMWMasked512, + ssa.OpAMD64VPERMPSMasked256, + ssa.OpAMD64VPERMDMasked256, + ssa.OpAMD64VPERMPSMasked512, + ssa.OpAMD64VPERMDMasked512, + ssa.OpAMD64VPERMPDMasked256, + ssa.OpAMD64VPERMQMasked256, + ssa.OpAMD64VPERMPDMasked512, + ssa.OpAMD64VPERMQMasked512, + ssa.OpAMD64VPSHUFBMasked256, + ssa.OpAMD64VPSHUFBMasked512, + ssa.OpAMD64VPSHUFBMasked128, + ssa.OpAMD64VPROLVDMasked128, + ssa.OpAMD64VPROLVDMasked256, + ssa.OpAMD64VPROLVDMasked512, + ssa.OpAMD64VPROLVQMasked128, + ssa.OpAMD64VPROLVQMasked256, + ssa.OpAMD64VPROLVQMasked512, + ssa.OpAMD64VPRORVDMasked128, + ssa.OpAMD64VPRORVDMasked256, + ssa.OpAMD64VPRORVDMasked512, + ssa.OpAMD64VPRORVQMasked128, + ssa.OpAMD64VPRORVQMasked256, + ssa.OpAMD64VPRORVQMasked512, + ssa.OpAMD64VPACKSSDWMasked256, + ssa.OpAMD64VPACKSSDWMasked512, + ssa.OpAMD64VPACKSSDWMasked128, + ssa.OpAMD64VPACKUSDWMasked256, + ssa.OpAMD64VPACKUSDWMasked512, + ssa.OpAMD64VPACKUSDWMasked128, + ssa.OpAMD64VSCALEFPSMasked128, + ssa.OpAMD64VSCALEFPSMasked256, + ssa.OpAMD64VSCALEFPSMasked512, + ssa.OpAMD64VSCALEFPDMasked128, + ssa.OpAMD64VSCALEFPDMasked256, + ssa.OpAMD64VSCALEFPDMasked512, + ssa.OpAMD64VPSLLVWMasked128, + ssa.OpAMD64VPSLLVWMasked256, + ssa.OpAMD64VPSLLVWMasked512, + ssa.OpAMD64VPSLLVDMasked128, + ssa.OpAMD64VPSLLVDMasked256, + ssa.OpAMD64VPSLLVDMasked512, + ssa.OpAMD64VPSLLVQMasked128, + ssa.OpAMD64VPSLLVQMasked256, + ssa.OpAMD64VPSLLVQMasked512, + ssa.OpAMD64VPSRAVWMasked128, + ssa.OpAMD64VPSRAVWMasked256, + ssa.OpAMD64VPSRAVWMasked512, + ssa.OpAMD64VPSRAVDMasked128, + ssa.OpAMD64VPSRAVDMasked256, + ssa.OpAMD64VPSRAVDMasked512, + ssa.OpAMD64VPSRAVQMasked128, + ssa.OpAMD64VPSRAVQMasked256, + ssa.OpAMD64VPSRAVQMasked512, + ssa.OpAMD64VPSRLVWMasked128, + ssa.OpAMD64VPSRLVWMasked256, + ssa.OpAMD64VPSRLVWMasked512, + ssa.OpAMD64VPSRLVDMasked128, + ssa.OpAMD64VPSRLVDMasked256, + ssa.OpAMD64VPSRLVDMasked512, + ssa.OpAMD64VPSRLVQMasked128, + ssa.OpAMD64VPSRLVQMasked256, + ssa.OpAMD64VPSRLVQMasked512, + ssa.OpAMD64VSUBPSMasked128, + ssa.OpAMD64VSUBPSMasked256, + ssa.OpAMD64VSUBPSMasked512, + ssa.OpAMD64VSUBPDMasked128, + ssa.OpAMD64VSUBPDMasked256, + ssa.OpAMD64VSUBPDMasked512, + ssa.OpAMD64VPSUBBMasked128, + ssa.OpAMD64VPSUBBMasked256, + ssa.OpAMD64VPSUBBMasked512, + ssa.OpAMD64VPSUBWMasked128, + ssa.OpAMD64VPSUBWMasked256, + ssa.OpAMD64VPSUBWMasked512, + ssa.OpAMD64VPSUBDMasked128, + ssa.OpAMD64VPSUBDMasked256, + ssa.OpAMD64VPSUBDMasked512, + ssa.OpAMD64VPSUBQMasked128, + ssa.OpAMD64VPSUBQMasked256, + ssa.OpAMD64VPSUBQMasked512, + ssa.OpAMD64VPSUBSBMasked128, + ssa.OpAMD64VPSUBSBMasked256, + ssa.OpAMD64VPSUBSBMasked512, + ssa.OpAMD64VPSUBSWMasked128, + ssa.OpAMD64VPSUBSWMasked256, + ssa.OpAMD64VPSUBSWMasked512, + ssa.OpAMD64VPSUBUSBMasked128, + ssa.OpAMD64VPSUBUSBMasked256, + ssa.OpAMD64VPSUBUSBMasked512, + ssa.OpAMD64VPSUBUSWMasked128, + ssa.OpAMD64VPSUBUSWMasked256, + ssa.OpAMD64VPSUBUSWMasked512, + ssa.OpAMD64VPXORDMasked128, + ssa.OpAMD64VPXORDMasked256, + ssa.OpAMD64VPXORDMasked512, + ssa.OpAMD64VPXORQMasked128, + ssa.OpAMD64VPXORQMasked256, + ssa.OpAMD64VPXORQMasked512, + ssa.OpAMD64VPBLENDMBMasked512, + ssa.OpAMD64VPBLENDMWMasked512, + ssa.OpAMD64VPBLENDMDMasked512, + ssa.OpAMD64VPBLENDMQMasked512: + p = simdV2kv(s, v) + + case ssa.OpAMD64VPABSBMasked128, + ssa.OpAMD64VPABSBMasked256, + ssa.OpAMD64VPABSBMasked512, + ssa.OpAMD64VPABSWMasked128, + ssa.OpAMD64VPABSWMasked256, + ssa.OpAMD64VPABSWMasked512, + ssa.OpAMD64VPABSDMasked128, + ssa.OpAMD64VPABSDMasked256, + ssa.OpAMD64VPABSDMasked512, + ssa.OpAMD64VPABSQMasked128, + ssa.OpAMD64VPABSQMasked256, + ssa.OpAMD64VPABSQMasked512, + ssa.OpAMD64VPBROADCASTQMasked128, + ssa.OpAMD64VBROADCASTSSMasked128, + ssa.OpAMD64VBROADCASTSDMasked256, + ssa.OpAMD64VPBROADCASTDMasked128, + ssa.OpAMD64VPBROADCASTQMasked256, + ssa.OpAMD64VBROADCASTSSMasked256, + ssa.OpAMD64VBROADCASTSDMasked512, + ssa.OpAMD64VPBROADCASTWMasked128, + ssa.OpAMD64VPBROADCASTDMasked256, + ssa.OpAMD64VPBROADCASTQMasked512, + ssa.OpAMD64VBROADCASTSSMasked512, + ssa.OpAMD64VPBROADCASTBMasked128, + ssa.OpAMD64VPBROADCASTWMasked256, + ssa.OpAMD64VPBROADCASTDMasked512, + ssa.OpAMD64VPBROADCASTBMasked256, + ssa.OpAMD64VPBROADCASTWMasked512, + ssa.OpAMD64VPBROADCASTBMasked512, + ssa.OpAMD64VCOMPRESSPSMasked128, + ssa.OpAMD64VCOMPRESSPSMasked256, + ssa.OpAMD64VCOMPRESSPSMasked512, + ssa.OpAMD64VCOMPRESSPDMasked128, + ssa.OpAMD64VCOMPRESSPDMasked256, + ssa.OpAMD64VCOMPRESSPDMasked512, + ssa.OpAMD64VPCOMPRESSBMasked128, + ssa.OpAMD64VPCOMPRESSBMasked256, + ssa.OpAMD64VPCOMPRESSBMasked512, + ssa.OpAMD64VPCOMPRESSWMasked128, + ssa.OpAMD64VPCOMPRESSWMasked256, + ssa.OpAMD64VPCOMPRESSWMasked512, + ssa.OpAMD64VPCOMPRESSDMasked128, + ssa.OpAMD64VPCOMPRESSDMasked256, + ssa.OpAMD64VPCOMPRESSDMasked512, + ssa.OpAMD64VPCOMPRESSQMasked128, + ssa.OpAMD64VPCOMPRESSQMasked256, + ssa.OpAMD64VPCOMPRESSQMasked512, + ssa.OpAMD64VCVTPD2PSXMasked128, + ssa.OpAMD64VCVTPD2PSYMasked128, + ssa.OpAMD64VCVTPD2PSMasked256, + ssa.OpAMD64VCVTDQ2PSMasked128, + ssa.OpAMD64VCVTDQ2PSMasked256, + ssa.OpAMD64VCVTDQ2PSMasked512, + ssa.OpAMD64VCVTQQ2PSXMasked128, + ssa.OpAMD64VCVTQQ2PSYMasked128, + ssa.OpAMD64VCVTQQ2PSMasked256, + ssa.OpAMD64VCVTUDQ2PSMasked128, + ssa.OpAMD64VCVTUDQ2PSMasked256, + ssa.OpAMD64VCVTUDQ2PSMasked512, + ssa.OpAMD64VCVTUQQ2PSXMasked128, + ssa.OpAMD64VCVTUQQ2PSYMasked128, + ssa.OpAMD64VCVTUQQ2PSMasked256, + ssa.OpAMD64VCVTPS2PDMasked256, + ssa.OpAMD64VCVTPS2PDMasked512, + ssa.OpAMD64VCVTDQ2PDMasked256, + ssa.OpAMD64VCVTDQ2PDMasked512, + ssa.OpAMD64VCVTQQ2PDMasked128, + ssa.OpAMD64VCVTQQ2PDMasked256, + ssa.OpAMD64VCVTQQ2PDMasked512, + ssa.OpAMD64VCVTUDQ2PDMasked256, + ssa.OpAMD64VCVTUDQ2PDMasked512, + ssa.OpAMD64VCVTUQQ2PDMasked128, + ssa.OpAMD64VCVTUQQ2PDMasked256, + ssa.OpAMD64VCVTUQQ2PDMasked512, + ssa.OpAMD64VCVTTPS2DQMasked128, + ssa.OpAMD64VCVTTPS2DQMasked256, + ssa.OpAMD64VCVTTPS2DQMasked512, + ssa.OpAMD64VCVTTPD2DQXMasked128, + ssa.OpAMD64VCVTTPD2DQYMasked128, + ssa.OpAMD64VCVTTPD2DQMasked256, + ssa.OpAMD64VCVTTPS2QQMasked256, + ssa.OpAMD64VCVTTPS2QQMasked512, + ssa.OpAMD64VCVTTPD2QQMasked128, + ssa.OpAMD64VCVTTPD2QQMasked256, + ssa.OpAMD64VCVTTPD2QQMasked512, + ssa.OpAMD64VCVTTPS2UDQMasked128, + ssa.OpAMD64VCVTTPS2UDQMasked256, + ssa.OpAMD64VCVTTPS2UDQMasked512, + ssa.OpAMD64VCVTTPD2UDQXMasked128, + ssa.OpAMD64VCVTTPD2UDQYMasked128, + ssa.OpAMD64VCVTTPD2UDQMasked256, + ssa.OpAMD64VCVTTPS2UQQMasked256, + ssa.OpAMD64VCVTTPS2UQQMasked512, + ssa.OpAMD64VCVTTPD2UQQMasked128, + ssa.OpAMD64VCVTTPD2UQQMasked256, + ssa.OpAMD64VCVTTPD2UQQMasked512, + ssa.OpAMD64VEXPANDPSMasked128, + ssa.OpAMD64VEXPANDPSMasked256, + ssa.OpAMD64VEXPANDPSMasked512, + ssa.OpAMD64VEXPANDPDMasked128, + ssa.OpAMD64VEXPANDPDMasked256, + ssa.OpAMD64VEXPANDPDMasked512, + ssa.OpAMD64VPEXPANDBMasked128, + ssa.OpAMD64VPEXPANDBMasked256, + ssa.OpAMD64VPEXPANDBMasked512, + ssa.OpAMD64VPEXPANDWMasked128, + ssa.OpAMD64VPEXPANDWMasked256, + ssa.OpAMD64VPEXPANDWMasked512, + ssa.OpAMD64VPEXPANDDMasked128, + ssa.OpAMD64VPEXPANDDMasked256, + ssa.OpAMD64VPEXPANDDMasked512, + ssa.OpAMD64VPEXPANDQMasked128, + ssa.OpAMD64VPEXPANDQMasked256, + ssa.OpAMD64VPEXPANDQMasked512, + ssa.OpAMD64VPMOVSXBQMasked128, + ssa.OpAMD64VPMOVSXWQMasked128, + ssa.OpAMD64VPMOVSXDQMasked128, + ssa.OpAMD64VPMOVZXBQMasked128, + ssa.OpAMD64VPMOVZXWQMasked128, + ssa.OpAMD64VPMOVZXDQMasked128, + ssa.OpAMD64VPMOVSXBDMasked128, + ssa.OpAMD64VPMOVSXWDMasked128, + ssa.OpAMD64VPMOVSXBQMasked256, + ssa.OpAMD64VPMOVSXWQMasked256, + ssa.OpAMD64VPMOVZXBDMasked128, + ssa.OpAMD64VPMOVZXWDMasked128, + ssa.OpAMD64VPMOVZXBQMasked256, + ssa.OpAMD64VPMOVZXWQMasked256, + ssa.OpAMD64VPMOVSXBWMasked128, + ssa.OpAMD64VPMOVSXBDMasked256, + ssa.OpAMD64VPMOVSXBQMasked512, + ssa.OpAMD64VPMOVZXBWMasked128, + ssa.OpAMD64VPMOVZXBDMasked256, + ssa.OpAMD64VPMOVZXBQMasked512, + ssa.OpAMD64VPMOVSXBWMasked256, + ssa.OpAMD64VPMOVSXBWMasked512, + ssa.OpAMD64VPMOVSXBDMasked512, + ssa.OpAMD64VPMOVSXWDMasked256, + ssa.OpAMD64VPMOVSXWDMasked512, + ssa.OpAMD64VPMOVSXWQMasked512, + ssa.OpAMD64VPMOVSXDQMasked256, + ssa.OpAMD64VPMOVSXDQMasked512, + ssa.OpAMD64VPMOVZXBWMasked256, + ssa.OpAMD64VPMOVZXBWMasked512, + ssa.OpAMD64VPMOVZXBDMasked512, + ssa.OpAMD64VPMOVZXWDMasked256, + ssa.OpAMD64VPMOVZXWDMasked512, + ssa.OpAMD64VPMOVZXWQMasked512, + ssa.OpAMD64VPMOVZXDQMasked256, + ssa.OpAMD64VPMOVZXDQMasked512, + ssa.OpAMD64VPLZCNTDMasked128, + ssa.OpAMD64VPLZCNTDMasked256, + ssa.OpAMD64VPLZCNTDMasked512, + ssa.OpAMD64VPLZCNTQMasked128, + ssa.OpAMD64VPLZCNTQMasked256, + ssa.OpAMD64VPLZCNTQMasked512, + ssa.OpAMD64VPOPCNTBMasked128, + ssa.OpAMD64VPOPCNTBMasked256, + ssa.OpAMD64VPOPCNTBMasked512, + ssa.OpAMD64VPOPCNTWMasked128, + ssa.OpAMD64VPOPCNTWMasked256, + ssa.OpAMD64VPOPCNTWMasked512, + ssa.OpAMD64VPOPCNTDMasked128, + ssa.OpAMD64VPOPCNTDMasked256, + ssa.OpAMD64VPOPCNTDMasked512, + ssa.OpAMD64VPOPCNTQMasked128, + ssa.OpAMD64VPOPCNTQMasked256, + ssa.OpAMD64VPOPCNTQMasked512, + ssa.OpAMD64VRCP14PSMasked128, + ssa.OpAMD64VRCP14PSMasked256, + ssa.OpAMD64VRCP14PSMasked512, + ssa.OpAMD64VRCP14PDMasked128, + ssa.OpAMD64VRCP14PDMasked256, + ssa.OpAMD64VRCP14PDMasked512, + ssa.OpAMD64VRSQRT14PSMasked128, + ssa.OpAMD64VRSQRT14PSMasked256, + ssa.OpAMD64VRSQRT14PSMasked512, + ssa.OpAMD64VRSQRT14PDMasked128, + ssa.OpAMD64VRSQRT14PDMasked256, + ssa.OpAMD64VRSQRT14PDMasked512, + ssa.OpAMD64VPMOVSWBMasked128_128, + ssa.OpAMD64VPMOVSWBMasked128_256, + ssa.OpAMD64VPMOVSWBMasked256, + ssa.OpAMD64VPMOVSDBMasked128_128, + ssa.OpAMD64VPMOVSDBMasked128_256, + ssa.OpAMD64VPMOVSDBMasked128_512, + ssa.OpAMD64VPMOVSQBMasked128_128, + ssa.OpAMD64VPMOVSQBMasked128_256, + ssa.OpAMD64VPMOVSQBMasked128_512, + ssa.OpAMD64VPMOVSDWMasked128_128, + ssa.OpAMD64VPMOVSDWMasked128_256, + ssa.OpAMD64VPMOVSDWMasked256, + ssa.OpAMD64VPMOVSQWMasked128_128, + ssa.OpAMD64VPMOVSQWMasked128_256, + ssa.OpAMD64VPMOVSQWMasked128_512, + ssa.OpAMD64VPMOVSQDMasked128_128, + ssa.OpAMD64VPMOVSQDMasked128_256, + ssa.OpAMD64VPMOVSQDMasked256, + ssa.OpAMD64VPMOVUSWBMasked128_128, + ssa.OpAMD64VPMOVUSWBMasked128_256, + ssa.OpAMD64VPMOVUSWBMasked256, + ssa.OpAMD64VPMOVUSDBMasked128_128, + ssa.OpAMD64VPMOVUSDBMasked128_256, + ssa.OpAMD64VPMOVUSDBMasked128_512, + ssa.OpAMD64VPMOVUSQBMasked128_128, + ssa.OpAMD64VPMOVUSQBMasked128_256, + ssa.OpAMD64VPMOVUSQBMasked128_512, + ssa.OpAMD64VPMOVUSDWMasked128_128, + ssa.OpAMD64VPMOVUSDWMasked128_256, + ssa.OpAMD64VPMOVUSDWMasked256, + ssa.OpAMD64VPMOVUSQWMasked128_128, + ssa.OpAMD64VPMOVUSQWMasked128_256, + ssa.OpAMD64VPMOVUSQWMasked128_512, + ssa.OpAMD64VPMOVUSQDMasked128_128, + ssa.OpAMD64VPMOVUSQDMasked128_256, + ssa.OpAMD64VPMOVUSQDMasked256, + ssa.OpAMD64VSQRTPSMasked128, + ssa.OpAMD64VSQRTPSMasked256, + ssa.OpAMD64VSQRTPSMasked512, + ssa.OpAMD64VSQRTPDMasked128, + ssa.OpAMD64VSQRTPDMasked256, + ssa.OpAMD64VSQRTPDMasked512, + ssa.OpAMD64VPMOVWBMasked128_128, + ssa.OpAMD64VPMOVWBMasked128_256, + ssa.OpAMD64VPMOVWBMasked256, + ssa.OpAMD64VPMOVDBMasked128_128, + ssa.OpAMD64VPMOVDBMasked128_256, + ssa.OpAMD64VPMOVDBMasked128_512, + ssa.OpAMD64VPMOVQBMasked128_128, + ssa.OpAMD64VPMOVQBMasked128_256, + ssa.OpAMD64VPMOVQBMasked128_512, + ssa.OpAMD64VPMOVDWMasked128_128, + ssa.OpAMD64VPMOVDWMasked128_256, + ssa.OpAMD64VPMOVDWMasked256, + ssa.OpAMD64VPMOVQWMasked128_128, + ssa.OpAMD64VPMOVQWMasked128_256, + ssa.OpAMD64VPMOVQWMasked128_512, + ssa.OpAMD64VPMOVQDMasked128_128, + ssa.OpAMD64VPMOVQDMasked128_256, + ssa.OpAMD64VPMOVQDMasked256, + ssa.OpAMD64VMOVDQU8Masked128, + ssa.OpAMD64VMOVDQU8Masked256, + ssa.OpAMD64VMOVDQU8Masked512, + ssa.OpAMD64VMOVDQU16Masked128, + ssa.OpAMD64VMOVDQU16Masked256, + ssa.OpAMD64VMOVDQU16Masked512, + ssa.OpAMD64VMOVDQU32Masked128, + ssa.OpAMD64VMOVDQU32Masked256, + ssa.OpAMD64VMOVDQU32Masked512, + ssa.OpAMD64VMOVDQU64Masked128, + ssa.OpAMD64VMOVDQU64Masked256, + ssa.OpAMD64VMOVDQU64Masked512: + p = simdVkv(s, v) + + case ssa.OpAMD64VPBLENDVB128, + ssa.OpAMD64VPBLENDVB256: + p = simdV31(s, v) + + case ssa.OpAMD64VAESKEYGENASSIST128, + ssa.OpAMD64VROUNDPS128, + ssa.OpAMD64VROUNDPS256, + ssa.OpAMD64VROUNDPD128, + ssa.OpAMD64VROUNDPD256, + ssa.OpAMD64VRNDSCALEPS128, + ssa.OpAMD64VRNDSCALEPS256, + ssa.OpAMD64VRNDSCALEPS512, + ssa.OpAMD64VRNDSCALEPD128, + ssa.OpAMD64VRNDSCALEPD256, + ssa.OpAMD64VRNDSCALEPD512, + ssa.OpAMD64VREDUCEPS128, + ssa.OpAMD64VREDUCEPS256, + ssa.OpAMD64VREDUCEPS512, + ssa.OpAMD64VREDUCEPD128, + ssa.OpAMD64VREDUCEPD256, + ssa.OpAMD64VREDUCEPD512, + ssa.OpAMD64VEXTRACTF128128, + ssa.OpAMD64VEXTRACTF64X4256, + ssa.OpAMD64VEXTRACTI128128, + ssa.OpAMD64VEXTRACTI64X4256, + ssa.OpAMD64VPROLD128, + ssa.OpAMD64VPROLD256, + ssa.OpAMD64VPROLD512, + ssa.OpAMD64VPROLQ128, + ssa.OpAMD64VPROLQ256, + ssa.OpAMD64VPROLQ512, + ssa.OpAMD64VPRORD128, + ssa.OpAMD64VPRORD256, + ssa.OpAMD64VPRORD512, + ssa.OpAMD64VPRORQ128, + ssa.OpAMD64VPRORQ256, + ssa.OpAMD64VPRORQ512, + ssa.OpAMD64VPSHUFD128, + ssa.OpAMD64VPSHUFD256, + ssa.OpAMD64VPSHUFD512, + ssa.OpAMD64VPSHUFHW128, + ssa.OpAMD64VPSHUFHW256, + ssa.OpAMD64VPSHUFHW512, + ssa.OpAMD64VPSHUFLW128, + ssa.OpAMD64VPSHUFLW256, + ssa.OpAMD64VPSHUFLW512, + ssa.OpAMD64VPSLLW128const, + ssa.OpAMD64VPSLLW256const, + ssa.OpAMD64VPSLLW512const, + ssa.OpAMD64VPSLLD128const, + ssa.OpAMD64VPSLLD256const, + ssa.OpAMD64VPSLLD512const, + ssa.OpAMD64VPSLLQ128const, + ssa.OpAMD64VPSLLQ256const, + ssa.OpAMD64VPSLLQ512const, + ssa.OpAMD64VPSRLW128const, + ssa.OpAMD64VPSRLW256const, + ssa.OpAMD64VPSRLW512const, + ssa.OpAMD64VPSRLD128const, + ssa.OpAMD64VPSRLD256const, + ssa.OpAMD64VPSRLD512const, + ssa.OpAMD64VPSRLQ128const, + ssa.OpAMD64VPSRLQ256const, + ssa.OpAMD64VPSRLQ512const, + ssa.OpAMD64VPSRAW128const, + ssa.OpAMD64VPSRAW256const, + ssa.OpAMD64VPSRAW512const, + ssa.OpAMD64VPSRAD128const, + ssa.OpAMD64VPSRAD256const, + ssa.OpAMD64VPSRAD512const, + ssa.OpAMD64VPSRAQ128const, + ssa.OpAMD64VPSRAQ256const, + ssa.OpAMD64VPSRAQ512const: + p = simdV11Imm8(s, v) + + case ssa.OpAMD64VRNDSCALEPSMasked128, + ssa.OpAMD64VRNDSCALEPSMasked256, + ssa.OpAMD64VRNDSCALEPSMasked512, + ssa.OpAMD64VRNDSCALEPDMasked128, + ssa.OpAMD64VRNDSCALEPDMasked256, + ssa.OpAMD64VRNDSCALEPDMasked512, + ssa.OpAMD64VREDUCEPSMasked128, + ssa.OpAMD64VREDUCEPSMasked256, + ssa.OpAMD64VREDUCEPSMasked512, + ssa.OpAMD64VREDUCEPDMasked128, + ssa.OpAMD64VREDUCEPDMasked256, + ssa.OpAMD64VREDUCEPDMasked512, + ssa.OpAMD64VPROLDMasked128, + ssa.OpAMD64VPROLDMasked256, + ssa.OpAMD64VPROLDMasked512, + ssa.OpAMD64VPROLQMasked128, + ssa.OpAMD64VPROLQMasked256, + ssa.OpAMD64VPROLQMasked512, + ssa.OpAMD64VPRORDMasked128, + ssa.OpAMD64VPRORDMasked256, + ssa.OpAMD64VPRORDMasked512, + ssa.OpAMD64VPRORQMasked128, + ssa.OpAMD64VPRORQMasked256, + ssa.OpAMD64VPRORQMasked512, + ssa.OpAMD64VPSHUFDMasked256, + ssa.OpAMD64VPSHUFDMasked512, + ssa.OpAMD64VPSHUFHWMasked256, + ssa.OpAMD64VPSHUFHWMasked512, + ssa.OpAMD64VPSHUFHWMasked128, + ssa.OpAMD64VPSHUFLWMasked256, + ssa.OpAMD64VPSHUFLWMasked512, + ssa.OpAMD64VPSHUFLWMasked128, + ssa.OpAMD64VPSHUFDMasked128, + ssa.OpAMD64VPSLLWMasked128const, + ssa.OpAMD64VPSLLWMasked256const, + ssa.OpAMD64VPSLLWMasked512const, + ssa.OpAMD64VPSLLDMasked128const, + ssa.OpAMD64VPSLLDMasked256const, + ssa.OpAMD64VPSLLDMasked512const, + ssa.OpAMD64VPSLLQMasked128const, + ssa.OpAMD64VPSLLQMasked256const, + ssa.OpAMD64VPSLLQMasked512const, + ssa.OpAMD64VPSRLWMasked128const, + ssa.OpAMD64VPSRLWMasked256const, + ssa.OpAMD64VPSRLWMasked512const, + ssa.OpAMD64VPSRLDMasked128const, + ssa.OpAMD64VPSRLDMasked256const, + ssa.OpAMD64VPSRLDMasked512const, + ssa.OpAMD64VPSRLQMasked128const, + ssa.OpAMD64VPSRLQMasked256const, + ssa.OpAMD64VPSRLQMasked512const, + ssa.OpAMD64VPSRAWMasked128const, + ssa.OpAMD64VPSRAWMasked256const, + ssa.OpAMD64VPSRAWMasked512const, + ssa.OpAMD64VPSRADMasked128const, + ssa.OpAMD64VPSRADMasked256const, + ssa.OpAMD64VPSRADMasked512const, + ssa.OpAMD64VPSRAQMasked128const, + ssa.OpAMD64VPSRAQMasked256const, + ssa.OpAMD64VPSRAQMasked512const: + p = simdVkvImm8(s, v) + + case ssa.OpAMD64VPALIGNR128, + ssa.OpAMD64VPALIGNR256, + ssa.OpAMD64VPALIGNR512, + ssa.OpAMD64VCMPPS128, + ssa.OpAMD64VCMPPS256, + ssa.OpAMD64VCMPPD128, + ssa.OpAMD64VCMPPD256, + ssa.OpAMD64VGF2P8AFFINEQB128, + ssa.OpAMD64VGF2P8AFFINEQB256, + ssa.OpAMD64VGF2P8AFFINEQB512, + ssa.OpAMD64VGF2P8AFFINEINVQB128, + ssa.OpAMD64VGF2P8AFFINEINVQB256, + ssa.OpAMD64VGF2P8AFFINEINVQB512, + ssa.OpAMD64VPERM2F128256, + ssa.OpAMD64VPERM2I128256, + ssa.OpAMD64VINSERTF128256, + ssa.OpAMD64VINSERTF64X4512, + ssa.OpAMD64VINSERTI128256, + ssa.OpAMD64VINSERTI64X4512, + ssa.OpAMD64VPSHLDW128, + ssa.OpAMD64VPSHLDW256, + ssa.OpAMD64VPSHLDW512, + ssa.OpAMD64VPSHLDD128, + ssa.OpAMD64VPSHLDD256, + ssa.OpAMD64VPSHLDD512, + ssa.OpAMD64VPSHLDQ128, + ssa.OpAMD64VPSHLDQ256, + ssa.OpAMD64VPSHLDQ512, + ssa.OpAMD64VPSHRDW128, + ssa.OpAMD64VPSHRDW256, + ssa.OpAMD64VPSHRDW512, + ssa.OpAMD64VPSHRDD128, + ssa.OpAMD64VPSHRDD256, + ssa.OpAMD64VPSHRDD512, + ssa.OpAMD64VPSHRDQ128, + ssa.OpAMD64VPSHRDQ256, + ssa.OpAMD64VPSHRDQ512, + ssa.OpAMD64VPCLMULQDQ128, + ssa.OpAMD64VPCLMULQDQ256, + ssa.OpAMD64VPCLMULQDQ512, + ssa.OpAMD64VSHUFPS128, + ssa.OpAMD64VSHUFPD128, + ssa.OpAMD64VSHUFPS256, + ssa.OpAMD64VSHUFPS512, + ssa.OpAMD64VSHUFPD256, + ssa.OpAMD64VSHUFPD512: + p = simdV21Imm8(s, v) + + case ssa.OpAMD64VCMPPS512, + ssa.OpAMD64VCMPPD512, + ssa.OpAMD64VPCMPUB512, + ssa.OpAMD64VPCMPUW512, + ssa.OpAMD64VPCMPUD512, + ssa.OpAMD64VPCMPUQ512, + ssa.OpAMD64VPCMPB512, + ssa.OpAMD64VPCMPW512, + ssa.OpAMD64VPCMPD512, + ssa.OpAMD64VPCMPQ512: + p = simdV2kImm8(s, v) + + case ssa.OpAMD64VCMPPSMasked128, + ssa.OpAMD64VCMPPSMasked256, + ssa.OpAMD64VCMPPSMasked512, + ssa.OpAMD64VCMPPDMasked128, + ssa.OpAMD64VCMPPDMasked256, + ssa.OpAMD64VCMPPDMasked512, + ssa.OpAMD64VPCMPBMasked128, + ssa.OpAMD64VPCMPBMasked256, + ssa.OpAMD64VPCMPBMasked512, + ssa.OpAMD64VPCMPWMasked128, + ssa.OpAMD64VPCMPWMasked256, + ssa.OpAMD64VPCMPWMasked512, + ssa.OpAMD64VPCMPDMasked128, + ssa.OpAMD64VPCMPDMasked256, + ssa.OpAMD64VPCMPDMasked512, + ssa.OpAMD64VPCMPQMasked128, + ssa.OpAMD64VPCMPQMasked256, + ssa.OpAMD64VPCMPQMasked512, + ssa.OpAMD64VPCMPUBMasked128, + ssa.OpAMD64VPCMPUBMasked256, + ssa.OpAMD64VPCMPUBMasked512, + ssa.OpAMD64VPCMPUWMasked128, + ssa.OpAMD64VPCMPUWMasked256, + ssa.OpAMD64VPCMPUWMasked512, + ssa.OpAMD64VPCMPUDMasked128, + ssa.OpAMD64VPCMPUDMasked256, + ssa.OpAMD64VPCMPUDMasked512, + ssa.OpAMD64VPCMPUQMasked128, + ssa.OpAMD64VPCMPUQMasked256, + ssa.OpAMD64VPCMPUQMasked512: + p = simdV2kkImm8(s, v) + + case ssa.OpAMD64VPDPWSSD128, + ssa.OpAMD64VPDPWSSD256, + ssa.OpAMD64VPDPWSSD512, + ssa.OpAMD64VPERMI2B128, + ssa.OpAMD64VPERMI2B256, + ssa.OpAMD64VPERMI2B512, + ssa.OpAMD64VPERMI2W128, + ssa.OpAMD64VPERMI2W256, + ssa.OpAMD64VPERMI2W512, + ssa.OpAMD64VPERMI2PS128, + ssa.OpAMD64VPERMI2D128, + ssa.OpAMD64VPERMI2PS256, + ssa.OpAMD64VPERMI2D256, + ssa.OpAMD64VPERMI2PS512, + ssa.OpAMD64VPERMI2D512, + ssa.OpAMD64VPERMI2PD128, + ssa.OpAMD64VPERMI2Q128, + ssa.OpAMD64VPERMI2PD256, + ssa.OpAMD64VPERMI2Q256, + ssa.OpAMD64VPERMI2PD512, + ssa.OpAMD64VPERMI2Q512, + ssa.OpAMD64VFMADD213PS128, + ssa.OpAMD64VFMADD213PS256, + ssa.OpAMD64VFMADD213PS512, + ssa.OpAMD64VFMADD213PD128, + ssa.OpAMD64VFMADD213PD256, + ssa.OpAMD64VFMADD213PD512, + ssa.OpAMD64VFMADDSUB213PS128, + ssa.OpAMD64VFMADDSUB213PS256, + ssa.OpAMD64VFMADDSUB213PS512, + ssa.OpAMD64VFMADDSUB213PD128, + ssa.OpAMD64VFMADDSUB213PD256, + ssa.OpAMD64VFMADDSUB213PD512, + ssa.OpAMD64VFMSUBADD213PS128, + ssa.OpAMD64VFMSUBADD213PS256, + ssa.OpAMD64VFMSUBADD213PS512, + ssa.OpAMD64VFMSUBADD213PD128, + ssa.OpAMD64VFMSUBADD213PD256, + ssa.OpAMD64VFMSUBADD213PD512, + ssa.OpAMD64VPSHLDVW128, + ssa.OpAMD64VPSHLDVW256, + ssa.OpAMD64VPSHLDVW512, + ssa.OpAMD64VPSHLDVD128, + ssa.OpAMD64VPSHLDVD256, + ssa.OpAMD64VPSHLDVD512, + ssa.OpAMD64VPSHLDVQ128, + ssa.OpAMD64VPSHLDVQ256, + ssa.OpAMD64VPSHLDVQ512, + ssa.OpAMD64VPSHRDVW128, + ssa.OpAMD64VPSHRDVW256, + ssa.OpAMD64VPSHRDVW512, + ssa.OpAMD64VPSHRDVD128, + ssa.OpAMD64VPSHRDVD256, + ssa.OpAMD64VPSHRDVD512, + ssa.OpAMD64VPSHRDVQ128, + ssa.OpAMD64VPSHRDVQ256, + ssa.OpAMD64VPSHRDVQ512: + p = simdV31ResultInArg0(s, v) + + case ssa.OpAMD64VPDPWSSDMasked128, + ssa.OpAMD64VPDPWSSDMasked256, + ssa.OpAMD64VPDPWSSDMasked512, + ssa.OpAMD64VADDPSMasked128Merging, + ssa.OpAMD64VADDPSMasked256Merging, + ssa.OpAMD64VADDPSMasked512Merging, + ssa.OpAMD64VADDPDMasked128Merging, + ssa.OpAMD64VADDPDMasked256Merging, + ssa.OpAMD64VADDPDMasked512Merging, + ssa.OpAMD64VPADDBMasked128Merging, + ssa.OpAMD64VPADDBMasked256Merging, + ssa.OpAMD64VPADDBMasked512Merging, + ssa.OpAMD64VPADDWMasked128Merging, + ssa.OpAMD64VPADDWMasked256Merging, + ssa.OpAMD64VPADDWMasked512Merging, + ssa.OpAMD64VPADDDMasked128Merging, + ssa.OpAMD64VPADDDMasked256Merging, + ssa.OpAMD64VPADDDMasked512Merging, + ssa.OpAMD64VPADDQMasked128Merging, + ssa.OpAMD64VPADDQMasked256Merging, + ssa.OpAMD64VPADDQMasked512Merging, + ssa.OpAMD64VPADDSBMasked128Merging, + ssa.OpAMD64VPADDSBMasked256Merging, + ssa.OpAMD64VPADDSBMasked512Merging, + ssa.OpAMD64VPADDSWMasked128Merging, + ssa.OpAMD64VPADDSWMasked256Merging, + ssa.OpAMD64VPADDSWMasked512Merging, + ssa.OpAMD64VPADDUSBMasked128Merging, + ssa.OpAMD64VPADDUSBMasked256Merging, + ssa.OpAMD64VPADDUSBMasked512Merging, + ssa.OpAMD64VPADDUSWMasked128Merging, + ssa.OpAMD64VPADDUSWMasked256Merging, + ssa.OpAMD64VPADDUSWMasked512Merging, + ssa.OpAMD64VPANDDMasked128Merging, + ssa.OpAMD64VPANDDMasked256Merging, + ssa.OpAMD64VPANDDMasked512Merging, + ssa.OpAMD64VPANDQMasked128Merging, + ssa.OpAMD64VPANDQMasked256Merging, + ssa.OpAMD64VPANDQMasked512Merging, + ssa.OpAMD64VPAVGBMasked128Merging, + ssa.OpAMD64VPAVGBMasked256Merging, + ssa.OpAMD64VPAVGBMasked512Merging, + ssa.OpAMD64VPAVGWMasked128Merging, + ssa.OpAMD64VPAVGWMasked256Merging, + ssa.OpAMD64VPAVGWMasked512Merging, + ssa.OpAMD64VPERMI2BMasked128, + ssa.OpAMD64VPERMI2BMasked256, + ssa.OpAMD64VPERMI2BMasked512, + ssa.OpAMD64VPERMI2WMasked128, + ssa.OpAMD64VPERMI2WMasked256, + ssa.OpAMD64VPERMI2WMasked512, + ssa.OpAMD64VPERMI2PSMasked128, + ssa.OpAMD64VPERMI2DMasked128, + ssa.OpAMD64VPERMI2PSMasked256, + ssa.OpAMD64VPERMI2DMasked256, + ssa.OpAMD64VPERMI2PSMasked512, + ssa.OpAMD64VPERMI2DMasked512, + ssa.OpAMD64VPERMI2PDMasked128, + ssa.OpAMD64VPERMI2QMasked128, + ssa.OpAMD64VPERMI2PDMasked256, + ssa.OpAMD64VPERMI2QMasked256, + ssa.OpAMD64VPERMI2PDMasked512, + ssa.OpAMD64VPERMI2QMasked512, + ssa.OpAMD64VPALIGNRMasked256Merging, + ssa.OpAMD64VPALIGNRMasked512Merging, + ssa.OpAMD64VPALIGNRMasked128Merging, + ssa.OpAMD64VDIVPSMasked128Merging, + ssa.OpAMD64VDIVPSMasked256Merging, + ssa.OpAMD64VDIVPSMasked512Merging, + ssa.OpAMD64VDIVPDMasked128Merging, + ssa.OpAMD64VDIVPDMasked256Merging, + ssa.OpAMD64VDIVPDMasked512Merging, + ssa.OpAMD64VPMADDWDMasked128Merging, + ssa.OpAMD64VPMADDWDMasked256Merging, + ssa.OpAMD64VPMADDWDMasked512Merging, + ssa.OpAMD64VPMADDUBSWMasked128Merging, + ssa.OpAMD64VPMADDUBSWMasked256Merging, + ssa.OpAMD64VPMADDUBSWMasked512Merging, + ssa.OpAMD64VGF2P8MULBMasked128Merging, + ssa.OpAMD64VGF2P8MULBMasked256Merging, + ssa.OpAMD64VGF2P8MULBMasked512Merging, + ssa.OpAMD64VMAXPSMasked128Merging, + ssa.OpAMD64VMAXPSMasked256Merging, + ssa.OpAMD64VMAXPSMasked512Merging, + ssa.OpAMD64VMAXPDMasked128Merging, + ssa.OpAMD64VMAXPDMasked256Merging, + ssa.OpAMD64VMAXPDMasked512Merging, + ssa.OpAMD64VPMAXSBMasked128Merging, + ssa.OpAMD64VPMAXSBMasked256Merging, + ssa.OpAMD64VPMAXSBMasked512Merging, + ssa.OpAMD64VPMAXSWMasked128Merging, + ssa.OpAMD64VPMAXSWMasked256Merging, + ssa.OpAMD64VPMAXSWMasked512Merging, + ssa.OpAMD64VPMAXSDMasked128Merging, + ssa.OpAMD64VPMAXSDMasked256Merging, + ssa.OpAMD64VPMAXSDMasked512Merging, + ssa.OpAMD64VPMAXSQMasked128Merging, + ssa.OpAMD64VPMAXSQMasked256Merging, + ssa.OpAMD64VPMAXSQMasked512Merging, + ssa.OpAMD64VPMAXUBMasked128Merging, + ssa.OpAMD64VPMAXUBMasked256Merging, + ssa.OpAMD64VPMAXUBMasked512Merging, + ssa.OpAMD64VPMAXUWMasked128Merging, + ssa.OpAMD64VPMAXUWMasked256Merging, + ssa.OpAMD64VPMAXUWMasked512Merging, + ssa.OpAMD64VPMAXUDMasked128Merging, + ssa.OpAMD64VPMAXUDMasked256Merging, + ssa.OpAMD64VPMAXUDMasked512Merging, + ssa.OpAMD64VPMAXUQMasked128Merging, + ssa.OpAMD64VPMAXUQMasked256Merging, + ssa.OpAMD64VPMAXUQMasked512Merging, + ssa.OpAMD64VMINPSMasked128Merging, + ssa.OpAMD64VMINPSMasked256Merging, + ssa.OpAMD64VMINPSMasked512Merging, + ssa.OpAMD64VMINPDMasked128Merging, + ssa.OpAMD64VMINPDMasked256Merging, + ssa.OpAMD64VMINPDMasked512Merging, + ssa.OpAMD64VPMINSBMasked128Merging, + ssa.OpAMD64VPMINSBMasked256Merging, + ssa.OpAMD64VPMINSBMasked512Merging, + ssa.OpAMD64VPMINSWMasked128Merging, + ssa.OpAMD64VPMINSWMasked256Merging, + ssa.OpAMD64VPMINSWMasked512Merging, + ssa.OpAMD64VPMINSDMasked128Merging, + ssa.OpAMD64VPMINSDMasked256Merging, + ssa.OpAMD64VPMINSDMasked512Merging, + ssa.OpAMD64VPMINSQMasked128Merging, + ssa.OpAMD64VPMINSQMasked256Merging, + ssa.OpAMD64VPMINSQMasked512Merging, + ssa.OpAMD64VPMINUBMasked128Merging, + ssa.OpAMD64VPMINUBMasked256Merging, + ssa.OpAMD64VPMINUBMasked512Merging, + ssa.OpAMD64VPMINUWMasked128Merging, + ssa.OpAMD64VPMINUWMasked256Merging, + ssa.OpAMD64VPMINUWMasked512Merging, + ssa.OpAMD64VPMINUDMasked128Merging, + ssa.OpAMD64VPMINUDMasked256Merging, + ssa.OpAMD64VPMINUDMasked512Merging, + ssa.OpAMD64VPMINUQMasked128Merging, + ssa.OpAMD64VPMINUQMasked256Merging, + ssa.OpAMD64VPMINUQMasked512Merging, + ssa.OpAMD64VFMADD213PSMasked128, + ssa.OpAMD64VFMADD213PSMasked256, + ssa.OpAMD64VFMADD213PSMasked512, + ssa.OpAMD64VFMADD213PDMasked128, + ssa.OpAMD64VFMADD213PDMasked256, + ssa.OpAMD64VFMADD213PDMasked512, + ssa.OpAMD64VFMADDSUB213PSMasked128, + ssa.OpAMD64VFMADDSUB213PSMasked256, + ssa.OpAMD64VFMADDSUB213PSMasked512, + ssa.OpAMD64VFMADDSUB213PDMasked128, + ssa.OpAMD64VFMADDSUB213PDMasked256, + ssa.OpAMD64VFMADDSUB213PDMasked512, + ssa.OpAMD64VPMULHWMasked128Merging, + ssa.OpAMD64VPMULHWMasked256Merging, + ssa.OpAMD64VPMULHWMasked512Merging, + ssa.OpAMD64VPMULHUWMasked128Merging, + ssa.OpAMD64VPMULHUWMasked256Merging, + ssa.OpAMD64VPMULHUWMasked512Merging, + ssa.OpAMD64VMULPSMasked128Merging, + ssa.OpAMD64VMULPSMasked256Merging, + ssa.OpAMD64VMULPSMasked512Merging, + ssa.OpAMD64VMULPDMasked128Merging, + ssa.OpAMD64VMULPDMasked256Merging, + ssa.OpAMD64VMULPDMasked512Merging, + ssa.OpAMD64VPMULLWMasked128Merging, + ssa.OpAMD64VPMULLWMasked256Merging, + ssa.OpAMD64VPMULLWMasked512Merging, + ssa.OpAMD64VPMULLDMasked128Merging, + ssa.OpAMD64VPMULLDMasked256Merging, + ssa.OpAMD64VPMULLDMasked512Merging, + ssa.OpAMD64VPMULLQMasked128Merging, + ssa.OpAMD64VPMULLQMasked256Merging, + ssa.OpAMD64VPMULLQMasked512Merging, + ssa.OpAMD64VFMSUBADD213PSMasked128, + ssa.OpAMD64VFMSUBADD213PSMasked256, + ssa.OpAMD64VFMSUBADD213PSMasked512, + ssa.OpAMD64VFMSUBADD213PDMasked128, + ssa.OpAMD64VFMSUBADD213PDMasked256, + ssa.OpAMD64VFMSUBADD213PDMasked512, + ssa.OpAMD64VPORDMasked128Merging, + ssa.OpAMD64VPORDMasked256Merging, + ssa.OpAMD64VPORDMasked512Merging, + ssa.OpAMD64VPORQMasked128Merging, + ssa.OpAMD64VPORQMasked256Merging, + ssa.OpAMD64VPORQMasked512Merging, + ssa.OpAMD64VPSHUFBMasked256Merging, + ssa.OpAMD64VPSHUFBMasked512Merging, + ssa.OpAMD64VPSHUFBMasked128Merging, + ssa.OpAMD64VPROLVDMasked128Merging, + ssa.OpAMD64VPROLVDMasked256Merging, + ssa.OpAMD64VPROLVDMasked512Merging, + ssa.OpAMD64VPROLVQMasked128Merging, + ssa.OpAMD64VPROLVQMasked256Merging, + ssa.OpAMD64VPROLVQMasked512Merging, + ssa.OpAMD64VPRORVDMasked128Merging, + ssa.OpAMD64VPRORVDMasked256Merging, + ssa.OpAMD64VPRORVDMasked512Merging, + ssa.OpAMD64VPRORVQMasked128Merging, + ssa.OpAMD64VPRORVQMasked256Merging, + ssa.OpAMD64VPRORVQMasked512Merging, + ssa.OpAMD64VPACKSSDWMasked256Merging, + ssa.OpAMD64VPACKSSDWMasked512Merging, + ssa.OpAMD64VPACKSSDWMasked128Merging, + ssa.OpAMD64VPACKUSDWMasked256Merging, + ssa.OpAMD64VPACKUSDWMasked512Merging, + ssa.OpAMD64VPACKUSDWMasked128Merging, + ssa.OpAMD64VSCALEFPSMasked128Merging, + ssa.OpAMD64VSCALEFPSMasked256Merging, + ssa.OpAMD64VSCALEFPSMasked512Merging, + ssa.OpAMD64VSCALEFPDMasked128Merging, + ssa.OpAMD64VSCALEFPDMasked256Merging, + ssa.OpAMD64VSCALEFPDMasked512Merging, + ssa.OpAMD64VPSHLDWMasked128Merging, + ssa.OpAMD64VPSHLDWMasked256Merging, + ssa.OpAMD64VPSHLDWMasked512Merging, + ssa.OpAMD64VPSHLDDMasked128Merging, + ssa.OpAMD64VPSHLDDMasked256Merging, + ssa.OpAMD64VPSHLDDMasked512Merging, + ssa.OpAMD64VPSHLDQMasked128Merging, + ssa.OpAMD64VPSHLDQMasked256Merging, + ssa.OpAMD64VPSHLDQMasked512Merging, + ssa.OpAMD64VPSHRDWMasked128Merging, + ssa.OpAMD64VPSHRDWMasked256Merging, + ssa.OpAMD64VPSHRDWMasked512Merging, + ssa.OpAMD64VPSHRDDMasked128Merging, + ssa.OpAMD64VPSHRDDMasked256Merging, + ssa.OpAMD64VPSHRDDMasked512Merging, + ssa.OpAMD64VPSHRDQMasked128Merging, + ssa.OpAMD64VPSHRDQMasked256Merging, + ssa.OpAMD64VPSHRDQMasked512Merging, + ssa.OpAMD64VPSHLDVWMasked128, + ssa.OpAMD64VPSHLDVWMasked256, + ssa.OpAMD64VPSHLDVWMasked512, + ssa.OpAMD64VPSHLDVDMasked128, + ssa.OpAMD64VPSHLDVDMasked256, + ssa.OpAMD64VPSHLDVDMasked512, + ssa.OpAMD64VPSHLDVQMasked128, + ssa.OpAMD64VPSHLDVQMasked256, + ssa.OpAMD64VPSHLDVQMasked512, + ssa.OpAMD64VPSLLVWMasked128Merging, + ssa.OpAMD64VPSLLVWMasked256Merging, + ssa.OpAMD64VPSLLVWMasked512Merging, + ssa.OpAMD64VPSLLVDMasked128Merging, + ssa.OpAMD64VPSLLVDMasked256Merging, + ssa.OpAMD64VPSLLVDMasked512Merging, + ssa.OpAMD64VPSLLVQMasked128Merging, + ssa.OpAMD64VPSLLVQMasked256Merging, + ssa.OpAMD64VPSLLVQMasked512Merging, + ssa.OpAMD64VPSHRDVWMasked128, + ssa.OpAMD64VPSHRDVWMasked256, + ssa.OpAMD64VPSHRDVWMasked512, + ssa.OpAMD64VPSHRDVDMasked128, + ssa.OpAMD64VPSHRDVDMasked256, + ssa.OpAMD64VPSHRDVDMasked512, + ssa.OpAMD64VPSHRDVQMasked128, + ssa.OpAMD64VPSHRDVQMasked256, + ssa.OpAMD64VPSHRDVQMasked512, + ssa.OpAMD64VPSRAVWMasked128Merging, + ssa.OpAMD64VPSRAVWMasked256Merging, + ssa.OpAMD64VPSRAVWMasked512Merging, + ssa.OpAMD64VPSRAVDMasked128Merging, + ssa.OpAMD64VPSRAVDMasked256Merging, + ssa.OpAMD64VPSRAVDMasked512Merging, + ssa.OpAMD64VPSRAVQMasked128Merging, + ssa.OpAMD64VPSRAVQMasked256Merging, + ssa.OpAMD64VPSRAVQMasked512Merging, + ssa.OpAMD64VPSRLVWMasked128Merging, + ssa.OpAMD64VPSRLVWMasked256Merging, + ssa.OpAMD64VPSRLVWMasked512Merging, + ssa.OpAMD64VPSRLVDMasked128Merging, + ssa.OpAMD64VPSRLVDMasked256Merging, + ssa.OpAMD64VPSRLVDMasked512Merging, + ssa.OpAMD64VPSRLVQMasked128Merging, + ssa.OpAMD64VPSRLVQMasked256Merging, + ssa.OpAMD64VPSRLVQMasked512Merging, + ssa.OpAMD64VSUBPSMasked128Merging, + ssa.OpAMD64VSUBPSMasked256Merging, + ssa.OpAMD64VSUBPSMasked512Merging, + ssa.OpAMD64VSUBPDMasked128Merging, + ssa.OpAMD64VSUBPDMasked256Merging, + ssa.OpAMD64VSUBPDMasked512Merging, + ssa.OpAMD64VPSUBBMasked128Merging, + ssa.OpAMD64VPSUBBMasked256Merging, + ssa.OpAMD64VPSUBBMasked512Merging, + ssa.OpAMD64VPSUBWMasked128Merging, + ssa.OpAMD64VPSUBWMasked256Merging, + ssa.OpAMD64VPSUBWMasked512Merging, + ssa.OpAMD64VPSUBDMasked128Merging, + ssa.OpAMD64VPSUBDMasked256Merging, + ssa.OpAMD64VPSUBDMasked512Merging, + ssa.OpAMD64VPSUBQMasked128Merging, + ssa.OpAMD64VPSUBQMasked256Merging, + ssa.OpAMD64VPSUBQMasked512Merging, + ssa.OpAMD64VPSUBSBMasked128Merging, + ssa.OpAMD64VPSUBSBMasked256Merging, + ssa.OpAMD64VPSUBSBMasked512Merging, + ssa.OpAMD64VPSUBSWMasked128Merging, + ssa.OpAMD64VPSUBSWMasked256Merging, + ssa.OpAMD64VPSUBSWMasked512Merging, + ssa.OpAMD64VPSUBUSBMasked128Merging, + ssa.OpAMD64VPSUBUSBMasked256Merging, + ssa.OpAMD64VPSUBUSBMasked512Merging, + ssa.OpAMD64VPSUBUSWMasked128Merging, + ssa.OpAMD64VPSUBUSWMasked256Merging, + ssa.OpAMD64VPSUBUSWMasked512Merging, + ssa.OpAMD64VPXORDMasked128Merging, + ssa.OpAMD64VPXORDMasked256Merging, + ssa.OpAMD64VPXORDMasked512Merging, + ssa.OpAMD64VPXORQMasked128Merging, + ssa.OpAMD64VPXORQMasked256Merging, + ssa.OpAMD64VPXORQMasked512Merging: + p = simdV3kvResultInArg0(s, v) + + case ssa.OpAMD64VPSLLW128, + ssa.OpAMD64VPSLLW256, + ssa.OpAMD64VPSLLW512, + ssa.OpAMD64VPSLLD128, + ssa.OpAMD64VPSLLD256, + ssa.OpAMD64VPSLLD512, + ssa.OpAMD64VPSLLQ128, + ssa.OpAMD64VPSLLQ256, + ssa.OpAMD64VPSLLQ512, + ssa.OpAMD64VPSRAW128, + ssa.OpAMD64VPSRAW256, + ssa.OpAMD64VPSRAW512, + ssa.OpAMD64VPSRAD128, + ssa.OpAMD64VPSRAD256, + ssa.OpAMD64VPSRAD512, + ssa.OpAMD64VPSRAQ128, + ssa.OpAMD64VPSRAQ256, + ssa.OpAMD64VPSRAQ512, + ssa.OpAMD64VPSRLW128, + ssa.OpAMD64VPSRLW256, + ssa.OpAMD64VPSRLW512, + ssa.OpAMD64VPSRLD128, + ssa.OpAMD64VPSRLD256, + ssa.OpAMD64VPSRLD512, + ssa.OpAMD64VPSRLQ128, + ssa.OpAMD64VPSRLQ256, + ssa.OpAMD64VPSRLQ512: + p = simdVfpv(s, v) + + case ssa.OpAMD64VPSLLWMasked128, + ssa.OpAMD64VPSLLWMasked256, + ssa.OpAMD64VPSLLWMasked512, + ssa.OpAMD64VPSLLDMasked128, + ssa.OpAMD64VPSLLDMasked256, + ssa.OpAMD64VPSLLDMasked512, + ssa.OpAMD64VPSLLQMasked128, + ssa.OpAMD64VPSLLQMasked256, + ssa.OpAMD64VPSLLQMasked512, + ssa.OpAMD64VPSRAWMasked128, + ssa.OpAMD64VPSRAWMasked256, + ssa.OpAMD64VPSRAWMasked512, + ssa.OpAMD64VPSRADMasked128, + ssa.OpAMD64VPSRADMasked256, + ssa.OpAMD64VPSRADMasked512, + ssa.OpAMD64VPSRAQMasked128, + ssa.OpAMD64VPSRAQMasked256, + ssa.OpAMD64VPSRAQMasked512, + ssa.OpAMD64VPSRLWMasked128, + ssa.OpAMD64VPSRLWMasked256, + ssa.OpAMD64VPSRLWMasked512, + ssa.OpAMD64VPSRLDMasked128, + ssa.OpAMD64VPSRLDMasked256, + ssa.OpAMD64VPSRLDMasked512, + ssa.OpAMD64VPSRLQMasked128, + ssa.OpAMD64VPSRLQMasked256, + ssa.OpAMD64VPSRLQMasked512: + p = simdVfpkv(s, v) + + case ssa.OpAMD64VPINSRD128, + ssa.OpAMD64VPINSRQ128, + ssa.OpAMD64VPINSRB128, + ssa.OpAMD64VPINSRW128: + p = simdVgpvImm8(s, v) + + case ssa.OpAMD64VPEXTRD128, + ssa.OpAMD64VPEXTRQ128, + ssa.OpAMD64VPEXTRB128, + ssa.OpAMD64VPEXTRW128: + p = simdVgpImm8(s, v) + + case ssa.OpAMD64VPALIGNRMasked256, + ssa.OpAMD64VPALIGNRMasked512, + ssa.OpAMD64VPALIGNRMasked128, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked128, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked256, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked512, + ssa.OpAMD64VGF2P8AFFINEQBMasked128, + ssa.OpAMD64VGF2P8AFFINEQBMasked256, + ssa.OpAMD64VGF2P8AFFINEQBMasked512, + ssa.OpAMD64VPSHLDWMasked128, + ssa.OpAMD64VPSHLDWMasked256, + ssa.OpAMD64VPSHLDWMasked512, + ssa.OpAMD64VPSHLDDMasked128, + ssa.OpAMD64VPSHLDDMasked256, + ssa.OpAMD64VPSHLDDMasked512, + ssa.OpAMD64VPSHLDQMasked128, + ssa.OpAMD64VPSHLDQMasked256, + ssa.OpAMD64VPSHLDQMasked512, + ssa.OpAMD64VPSHRDWMasked128, + ssa.OpAMD64VPSHRDWMasked256, + ssa.OpAMD64VPSHRDWMasked512, + ssa.OpAMD64VPSHRDDMasked128, + ssa.OpAMD64VPSHRDDMasked256, + ssa.OpAMD64VPSHRDDMasked512, + ssa.OpAMD64VPSHRDQMasked128, + ssa.OpAMD64VPSHRDQMasked256, + ssa.OpAMD64VPSHRDQMasked512: + p = simdV2kvImm8(s, v) + + case ssa.OpAMD64VPABSDMasked128load, + ssa.OpAMD64VPABSDMasked256load, + ssa.OpAMD64VPABSDMasked512load, + ssa.OpAMD64VPABSQMasked128load, + ssa.OpAMD64VPABSQMasked256load, + ssa.OpAMD64VPABSQMasked512load, + ssa.OpAMD64VCVTPD2PSXMasked128load, + ssa.OpAMD64VCVTPD2PSYMasked128load, + ssa.OpAMD64VCVTPD2PSMasked256load, + ssa.OpAMD64VCVTDQ2PSMasked128load, + ssa.OpAMD64VCVTDQ2PSMasked256load, + ssa.OpAMD64VCVTDQ2PSMasked512load, + ssa.OpAMD64VCVTQQ2PSXMasked128load, + ssa.OpAMD64VCVTQQ2PSYMasked128load, + ssa.OpAMD64VCVTQQ2PSMasked256load, + ssa.OpAMD64VCVTUDQ2PSMasked128load, + ssa.OpAMD64VCVTUDQ2PSMasked256load, + ssa.OpAMD64VCVTUDQ2PSMasked512load, + ssa.OpAMD64VCVTUQQ2PSXMasked128load, + ssa.OpAMD64VCVTUQQ2PSYMasked128load, + ssa.OpAMD64VCVTUQQ2PSMasked256load, + ssa.OpAMD64VCVTPS2PDMasked256load, + ssa.OpAMD64VCVTPS2PDMasked512load, + ssa.OpAMD64VCVTDQ2PDMasked256load, + ssa.OpAMD64VCVTDQ2PDMasked512load, + ssa.OpAMD64VCVTQQ2PDMasked128load, + ssa.OpAMD64VCVTQQ2PDMasked256load, + ssa.OpAMD64VCVTQQ2PDMasked512load, + ssa.OpAMD64VCVTUDQ2PDMasked256load, + ssa.OpAMD64VCVTUDQ2PDMasked512load, + ssa.OpAMD64VCVTUQQ2PDMasked128load, + ssa.OpAMD64VCVTUQQ2PDMasked256load, + ssa.OpAMD64VCVTUQQ2PDMasked512load, + ssa.OpAMD64VCVTTPS2DQMasked128load, + ssa.OpAMD64VCVTTPS2DQMasked256load, + ssa.OpAMD64VCVTTPS2DQMasked512load, + ssa.OpAMD64VCVTTPD2DQXMasked128load, + ssa.OpAMD64VCVTTPD2DQYMasked128load, + ssa.OpAMD64VCVTTPD2DQMasked256load, + ssa.OpAMD64VCVTTPS2QQMasked256load, + ssa.OpAMD64VCVTTPS2QQMasked512load, + ssa.OpAMD64VCVTTPD2QQMasked128load, + ssa.OpAMD64VCVTTPD2QQMasked256load, + ssa.OpAMD64VCVTTPD2QQMasked512load, + ssa.OpAMD64VCVTTPS2UDQMasked128load, + ssa.OpAMD64VCVTTPS2UDQMasked256load, + ssa.OpAMD64VCVTTPS2UDQMasked512load, + ssa.OpAMD64VCVTTPD2UDQXMasked128load, + ssa.OpAMD64VCVTTPD2UDQYMasked128load, + ssa.OpAMD64VCVTTPD2UDQMasked256load, + ssa.OpAMD64VCVTTPS2UQQMasked256load, + ssa.OpAMD64VCVTTPS2UQQMasked512load, + ssa.OpAMD64VCVTTPD2UQQMasked128load, + ssa.OpAMD64VCVTTPD2UQQMasked256load, + ssa.OpAMD64VCVTTPD2UQQMasked512load, + ssa.OpAMD64VPLZCNTDMasked128load, + ssa.OpAMD64VPLZCNTDMasked256load, + ssa.OpAMD64VPLZCNTDMasked512load, + ssa.OpAMD64VPLZCNTQMasked128load, + ssa.OpAMD64VPLZCNTQMasked256load, + ssa.OpAMD64VPLZCNTQMasked512load, + ssa.OpAMD64VPOPCNTDMasked128load, + ssa.OpAMD64VPOPCNTDMasked256load, + ssa.OpAMD64VPOPCNTDMasked512load, + ssa.OpAMD64VPOPCNTQMasked128load, + ssa.OpAMD64VPOPCNTQMasked256load, + ssa.OpAMD64VPOPCNTQMasked512load, + ssa.OpAMD64VRCP14PSMasked128load, + ssa.OpAMD64VRCP14PSMasked256load, + ssa.OpAMD64VRCP14PSMasked512load, + ssa.OpAMD64VRCP14PDMasked128load, + ssa.OpAMD64VRCP14PDMasked256load, + ssa.OpAMD64VRCP14PDMasked512load, + ssa.OpAMD64VRSQRT14PSMasked128load, + ssa.OpAMD64VRSQRT14PSMasked256load, + ssa.OpAMD64VRSQRT14PSMasked512load, + ssa.OpAMD64VRSQRT14PDMasked128load, + ssa.OpAMD64VRSQRT14PDMasked256load, + ssa.OpAMD64VRSQRT14PDMasked512load, + ssa.OpAMD64VSQRTPSMasked128load, + ssa.OpAMD64VSQRTPSMasked256load, + ssa.OpAMD64VSQRTPSMasked512load, + ssa.OpAMD64VSQRTPDMasked128load, + ssa.OpAMD64VSQRTPDMasked256load, + ssa.OpAMD64VSQRTPDMasked512load: + p = simdVkvload(s, v) + + case ssa.OpAMD64VADDPS512load, + ssa.OpAMD64VADDPD512load, + ssa.OpAMD64VPADDD512load, + ssa.OpAMD64VPADDQ512load, + ssa.OpAMD64VPANDD512load, + ssa.OpAMD64VPANDQ512load, + ssa.OpAMD64VPANDND512load, + ssa.OpAMD64VPANDNQ512load, + ssa.OpAMD64VDIVPS512load, + ssa.OpAMD64VDIVPD512load, + ssa.OpAMD64VPUNPCKHDQ512load, + ssa.OpAMD64VPUNPCKHQDQ512load, + ssa.OpAMD64VPUNPCKLDQ512load, + ssa.OpAMD64VPUNPCKLQDQ512load, + ssa.OpAMD64VMAXPS512load, + ssa.OpAMD64VMAXPD512load, + ssa.OpAMD64VPMAXSD512load, + ssa.OpAMD64VPMAXSQ128load, + ssa.OpAMD64VPMAXSQ256load, + ssa.OpAMD64VPMAXSQ512load, + ssa.OpAMD64VPMAXUD512load, + ssa.OpAMD64VPMAXUQ128load, + ssa.OpAMD64VPMAXUQ256load, + ssa.OpAMD64VPMAXUQ512load, + ssa.OpAMD64VMINPS512load, + ssa.OpAMD64VMINPD512load, + ssa.OpAMD64VPMINSD512load, + ssa.OpAMD64VPMINSQ128load, + ssa.OpAMD64VPMINSQ256load, + ssa.OpAMD64VPMINSQ512load, + ssa.OpAMD64VPMINUD512load, + ssa.OpAMD64VPMINUQ128load, + ssa.OpAMD64VPMINUQ256load, + ssa.OpAMD64VPMINUQ512load, + ssa.OpAMD64VMULPS512load, + ssa.OpAMD64VMULPD512load, + ssa.OpAMD64VPMULLD512load, + ssa.OpAMD64VPMULLQ128load, + ssa.OpAMD64VPMULLQ256load, + ssa.OpAMD64VPMULLQ512load, + ssa.OpAMD64VPORD512load, + ssa.OpAMD64VPORQ512load, + ssa.OpAMD64VPERMPS512load, + ssa.OpAMD64VPERMD512load, + ssa.OpAMD64VPERMPD256load, + ssa.OpAMD64VPERMQ256load, + ssa.OpAMD64VPERMPD512load, + ssa.OpAMD64VPERMQ512load, + ssa.OpAMD64VPROLVD128load, + ssa.OpAMD64VPROLVD256load, + ssa.OpAMD64VPROLVD512load, + ssa.OpAMD64VPROLVQ128load, + ssa.OpAMD64VPROLVQ256load, + ssa.OpAMD64VPROLVQ512load, + ssa.OpAMD64VPRORVD128load, + ssa.OpAMD64VPRORVD256load, + ssa.OpAMD64VPRORVD512load, + ssa.OpAMD64VPRORVQ128load, + ssa.OpAMD64VPRORVQ256load, + ssa.OpAMD64VPRORVQ512load, + ssa.OpAMD64VPACKSSDW512load, + ssa.OpAMD64VPACKUSDW512load, + ssa.OpAMD64VSCALEFPS128load, + ssa.OpAMD64VSCALEFPS256load, + ssa.OpAMD64VSCALEFPS512load, + ssa.OpAMD64VSCALEFPD128load, + ssa.OpAMD64VSCALEFPD256load, + ssa.OpAMD64VSCALEFPD512load, + ssa.OpAMD64VPSLLVD512load, + ssa.OpAMD64VPSLLVQ512load, + ssa.OpAMD64VPSRAVD512load, + ssa.OpAMD64VPSRAVQ128load, + ssa.OpAMD64VPSRAVQ256load, + ssa.OpAMD64VPSRAVQ512load, + ssa.OpAMD64VPSRLVD512load, + ssa.OpAMD64VPSRLVQ512load, + ssa.OpAMD64VSUBPS512load, + ssa.OpAMD64VSUBPD512load, + ssa.OpAMD64VPSUBD512load, + ssa.OpAMD64VPSUBQ512load, + ssa.OpAMD64VPXORD512load, + ssa.OpAMD64VPXORQ512load: + p = simdV21load(s, v) + + case ssa.OpAMD64VPDPWSSD512load, + ssa.OpAMD64VPERMI2PS128load, + ssa.OpAMD64VPERMI2D128load, + ssa.OpAMD64VPERMI2PS256load, + ssa.OpAMD64VPERMI2D256load, + ssa.OpAMD64VPERMI2PS512load, + ssa.OpAMD64VPERMI2D512load, + ssa.OpAMD64VPERMI2PD128load, + ssa.OpAMD64VPERMI2Q128load, + ssa.OpAMD64VPERMI2PD256load, + ssa.OpAMD64VPERMI2Q256load, + ssa.OpAMD64VPERMI2PD512load, + ssa.OpAMD64VPERMI2Q512load, + ssa.OpAMD64VFMADD213PS512load, + ssa.OpAMD64VFMADD213PD512load, + ssa.OpAMD64VFMADDSUB213PS512load, + ssa.OpAMD64VFMADDSUB213PD512load, + ssa.OpAMD64VFMSUBADD213PS512load, + ssa.OpAMD64VFMSUBADD213PD512load, + ssa.OpAMD64VPSHLDVD128load, + ssa.OpAMD64VPSHLDVD256load, + ssa.OpAMD64VPSHLDVD512load, + ssa.OpAMD64VPSHLDVQ128load, + ssa.OpAMD64VPSHLDVQ256load, + ssa.OpAMD64VPSHLDVQ512load, + ssa.OpAMD64VPSHRDVD128load, + ssa.OpAMD64VPSHRDVD256load, + ssa.OpAMD64VPSHRDVD512load, + ssa.OpAMD64VPSHRDVQ128load, + ssa.OpAMD64VPSHRDVQ256load, + ssa.OpAMD64VPSHRDVQ512load: + p = simdV31loadResultInArg0(s, v) + + case ssa.OpAMD64VPDPWSSDMasked128load, + ssa.OpAMD64VPDPWSSDMasked256load, + ssa.OpAMD64VPDPWSSDMasked512load, + ssa.OpAMD64VPERMI2PSMasked128load, + ssa.OpAMD64VPERMI2DMasked128load, + ssa.OpAMD64VPERMI2PSMasked256load, + ssa.OpAMD64VPERMI2DMasked256load, + ssa.OpAMD64VPERMI2PSMasked512load, + ssa.OpAMD64VPERMI2DMasked512load, + ssa.OpAMD64VPERMI2PDMasked128load, + ssa.OpAMD64VPERMI2QMasked128load, + ssa.OpAMD64VPERMI2PDMasked256load, + ssa.OpAMD64VPERMI2QMasked256load, + ssa.OpAMD64VPERMI2PDMasked512load, + ssa.OpAMD64VPERMI2QMasked512load, + ssa.OpAMD64VFMADD213PSMasked128load, + ssa.OpAMD64VFMADD213PSMasked256load, + ssa.OpAMD64VFMADD213PSMasked512load, + ssa.OpAMD64VFMADD213PDMasked128load, + ssa.OpAMD64VFMADD213PDMasked256load, + ssa.OpAMD64VFMADD213PDMasked512load, + ssa.OpAMD64VFMADDSUB213PSMasked128load, + ssa.OpAMD64VFMADDSUB213PSMasked256load, + ssa.OpAMD64VFMADDSUB213PSMasked512load, + ssa.OpAMD64VFMADDSUB213PDMasked128load, + ssa.OpAMD64VFMADDSUB213PDMasked256load, + ssa.OpAMD64VFMADDSUB213PDMasked512load, + ssa.OpAMD64VFMSUBADD213PSMasked128load, + ssa.OpAMD64VFMSUBADD213PSMasked256load, + ssa.OpAMD64VFMSUBADD213PSMasked512load, + ssa.OpAMD64VFMSUBADD213PDMasked128load, + ssa.OpAMD64VFMSUBADD213PDMasked256load, + ssa.OpAMD64VFMSUBADD213PDMasked512load, + ssa.OpAMD64VPSHLDVDMasked128load, + ssa.OpAMD64VPSHLDVDMasked256load, + ssa.OpAMD64VPSHLDVDMasked512load, + ssa.OpAMD64VPSHLDVQMasked128load, + ssa.OpAMD64VPSHLDVQMasked256load, + ssa.OpAMD64VPSHLDVQMasked512load, + ssa.OpAMD64VPSHRDVDMasked128load, + ssa.OpAMD64VPSHRDVDMasked256load, + ssa.OpAMD64VPSHRDVDMasked512load, + ssa.OpAMD64VPSHRDVQMasked128load, + ssa.OpAMD64VPSHRDVQMasked256load, + ssa.OpAMD64VPSHRDVQMasked512load: + p = simdV3kvloadResultInArg0(s, v) + + case ssa.OpAMD64VADDPSMasked128load, + ssa.OpAMD64VADDPSMasked256load, + ssa.OpAMD64VADDPSMasked512load, + ssa.OpAMD64VADDPDMasked128load, + ssa.OpAMD64VADDPDMasked256load, + ssa.OpAMD64VADDPDMasked512load, + ssa.OpAMD64VPADDDMasked128load, + ssa.OpAMD64VPADDDMasked256load, + ssa.OpAMD64VPADDDMasked512load, + ssa.OpAMD64VPADDQMasked128load, + ssa.OpAMD64VPADDQMasked256load, + ssa.OpAMD64VPADDQMasked512load, + ssa.OpAMD64VPANDDMasked128load, + ssa.OpAMD64VPANDDMasked256load, + ssa.OpAMD64VPANDDMasked512load, + ssa.OpAMD64VPANDQMasked128load, + ssa.OpAMD64VPANDQMasked256load, + ssa.OpAMD64VPANDQMasked512load, + ssa.OpAMD64VPANDNDMasked128load, + ssa.OpAMD64VPANDNDMasked256load, + ssa.OpAMD64VPANDNDMasked512load, + ssa.OpAMD64VPANDNQMasked128load, + ssa.OpAMD64VPANDNQMasked256load, + ssa.OpAMD64VPANDNQMasked512load, + ssa.OpAMD64VDIVPSMasked128load, + ssa.OpAMD64VDIVPSMasked256load, + ssa.OpAMD64VDIVPSMasked512load, + ssa.OpAMD64VDIVPDMasked128load, + ssa.OpAMD64VDIVPDMasked256load, + ssa.OpAMD64VDIVPDMasked512load, + ssa.OpAMD64VMAXPSMasked128load, + ssa.OpAMD64VMAXPSMasked256load, + ssa.OpAMD64VMAXPSMasked512load, + ssa.OpAMD64VMAXPDMasked128load, + ssa.OpAMD64VMAXPDMasked256load, + ssa.OpAMD64VMAXPDMasked512load, + ssa.OpAMD64VPMAXSDMasked128load, + ssa.OpAMD64VPMAXSDMasked256load, + ssa.OpAMD64VPMAXSDMasked512load, + ssa.OpAMD64VPMAXSQMasked128load, + ssa.OpAMD64VPMAXSQMasked256load, + ssa.OpAMD64VPMAXSQMasked512load, + ssa.OpAMD64VPMAXUDMasked128load, + ssa.OpAMD64VPMAXUDMasked256load, + ssa.OpAMD64VPMAXUDMasked512load, + ssa.OpAMD64VPMAXUQMasked128load, + ssa.OpAMD64VPMAXUQMasked256load, + ssa.OpAMD64VPMAXUQMasked512load, + ssa.OpAMD64VMINPSMasked128load, + ssa.OpAMD64VMINPSMasked256load, + ssa.OpAMD64VMINPSMasked512load, + ssa.OpAMD64VMINPDMasked128load, + ssa.OpAMD64VMINPDMasked256load, + ssa.OpAMD64VMINPDMasked512load, + ssa.OpAMD64VPMINSDMasked128load, + ssa.OpAMD64VPMINSDMasked256load, + ssa.OpAMD64VPMINSDMasked512load, + ssa.OpAMD64VPMINSQMasked128load, + ssa.OpAMD64VPMINSQMasked256load, + ssa.OpAMD64VPMINSQMasked512load, + ssa.OpAMD64VPMINUDMasked128load, + ssa.OpAMD64VPMINUDMasked256load, + ssa.OpAMD64VPMINUDMasked512load, + ssa.OpAMD64VPMINUQMasked128load, + ssa.OpAMD64VPMINUQMasked256load, + ssa.OpAMD64VPMINUQMasked512load, + ssa.OpAMD64VMULPSMasked128load, + ssa.OpAMD64VMULPSMasked256load, + ssa.OpAMD64VMULPSMasked512load, + ssa.OpAMD64VMULPDMasked128load, + ssa.OpAMD64VMULPDMasked256load, + ssa.OpAMD64VMULPDMasked512load, + ssa.OpAMD64VPMULLDMasked128load, + ssa.OpAMD64VPMULLDMasked256load, + ssa.OpAMD64VPMULLDMasked512load, + ssa.OpAMD64VPMULLQMasked128load, + ssa.OpAMD64VPMULLQMasked256load, + ssa.OpAMD64VPMULLQMasked512load, + ssa.OpAMD64VPORDMasked128load, + ssa.OpAMD64VPORDMasked256load, + ssa.OpAMD64VPORDMasked512load, + ssa.OpAMD64VPORQMasked128load, + ssa.OpAMD64VPORQMasked256load, + ssa.OpAMD64VPORQMasked512load, + ssa.OpAMD64VPERMPSMasked256load, + ssa.OpAMD64VPERMDMasked256load, + ssa.OpAMD64VPERMPSMasked512load, + ssa.OpAMD64VPERMDMasked512load, + ssa.OpAMD64VPERMPDMasked256load, + ssa.OpAMD64VPERMQMasked256load, + ssa.OpAMD64VPERMPDMasked512load, + ssa.OpAMD64VPERMQMasked512load, + ssa.OpAMD64VPROLVDMasked128load, + ssa.OpAMD64VPROLVDMasked256load, + ssa.OpAMD64VPROLVDMasked512load, + ssa.OpAMD64VPROLVQMasked128load, + ssa.OpAMD64VPROLVQMasked256load, + ssa.OpAMD64VPROLVQMasked512load, + ssa.OpAMD64VPRORVDMasked128load, + ssa.OpAMD64VPRORVDMasked256load, + ssa.OpAMD64VPRORVDMasked512load, + ssa.OpAMD64VPRORVQMasked128load, + ssa.OpAMD64VPRORVQMasked256load, + ssa.OpAMD64VPRORVQMasked512load, + ssa.OpAMD64VPACKSSDWMasked256load, + ssa.OpAMD64VPACKSSDWMasked512load, + ssa.OpAMD64VPACKSSDWMasked128load, + ssa.OpAMD64VPACKUSDWMasked256load, + ssa.OpAMD64VPACKUSDWMasked512load, + ssa.OpAMD64VPACKUSDWMasked128load, + ssa.OpAMD64VSCALEFPSMasked128load, + ssa.OpAMD64VSCALEFPSMasked256load, + ssa.OpAMD64VSCALEFPSMasked512load, + ssa.OpAMD64VSCALEFPDMasked128load, + ssa.OpAMD64VSCALEFPDMasked256load, + ssa.OpAMD64VSCALEFPDMasked512load, + ssa.OpAMD64VPSLLVDMasked128load, + ssa.OpAMD64VPSLLVDMasked256load, + ssa.OpAMD64VPSLLVDMasked512load, + ssa.OpAMD64VPSLLVQMasked128load, + ssa.OpAMD64VPSLLVQMasked256load, + ssa.OpAMD64VPSLLVQMasked512load, + ssa.OpAMD64VPSRAVDMasked128load, + ssa.OpAMD64VPSRAVDMasked256load, + ssa.OpAMD64VPSRAVDMasked512load, + ssa.OpAMD64VPSRAVQMasked128load, + ssa.OpAMD64VPSRAVQMasked256load, + ssa.OpAMD64VPSRAVQMasked512load, + ssa.OpAMD64VPSRLVDMasked128load, + ssa.OpAMD64VPSRLVDMasked256load, + ssa.OpAMD64VPSRLVDMasked512load, + ssa.OpAMD64VPSRLVQMasked128load, + ssa.OpAMD64VPSRLVQMasked256load, + ssa.OpAMD64VPSRLVQMasked512load, + ssa.OpAMD64VSUBPSMasked128load, + ssa.OpAMD64VSUBPSMasked256load, + ssa.OpAMD64VSUBPSMasked512load, + ssa.OpAMD64VSUBPDMasked128load, + ssa.OpAMD64VSUBPDMasked256load, + ssa.OpAMD64VSUBPDMasked512load, + ssa.OpAMD64VPSUBDMasked128load, + ssa.OpAMD64VPSUBDMasked256load, + ssa.OpAMD64VPSUBDMasked512load, + ssa.OpAMD64VPSUBQMasked128load, + ssa.OpAMD64VPSUBQMasked256load, + ssa.OpAMD64VPSUBQMasked512load, + ssa.OpAMD64VPXORDMasked128load, + ssa.OpAMD64VPXORDMasked256load, + ssa.OpAMD64VPXORDMasked512load, + ssa.OpAMD64VPXORQMasked128load, + ssa.OpAMD64VPXORQMasked256load, + ssa.OpAMD64VPXORQMasked512load, + ssa.OpAMD64VPBLENDMDMasked512load, + ssa.OpAMD64VPBLENDMQMasked512load: + p = simdV2kvload(s, v) + + case ssa.OpAMD64VPCMPEQD512load, + ssa.OpAMD64VPCMPEQQ512load, + ssa.OpAMD64VPCMPGTD512load, + ssa.OpAMD64VPCMPGTQ512load: + p = simdV2kload(s, v) + + case ssa.OpAMD64VPABSD512load, + ssa.OpAMD64VPABSQ128load, + ssa.OpAMD64VPABSQ256load, + ssa.OpAMD64VPABSQ512load, + ssa.OpAMD64VCVTPD2PS256load, + ssa.OpAMD64VCVTDQ2PS512load, + ssa.OpAMD64VCVTQQ2PSX128load, + ssa.OpAMD64VCVTQQ2PSY128load, + ssa.OpAMD64VCVTQQ2PS256load, + ssa.OpAMD64VCVTUDQ2PS128load, + ssa.OpAMD64VCVTUDQ2PS256load, + ssa.OpAMD64VCVTUDQ2PS512load, + ssa.OpAMD64VCVTUQQ2PSX128load, + ssa.OpAMD64VCVTUQQ2PSY128load, + ssa.OpAMD64VCVTUQQ2PS256load, + ssa.OpAMD64VCVTPS2PD512load, + ssa.OpAMD64VCVTDQ2PD512load, + ssa.OpAMD64VCVTQQ2PD128load, + ssa.OpAMD64VCVTQQ2PD256load, + ssa.OpAMD64VCVTQQ2PD512load, + ssa.OpAMD64VCVTUDQ2PD256load, + ssa.OpAMD64VCVTUDQ2PD512load, + ssa.OpAMD64VCVTUQQ2PD128load, + ssa.OpAMD64VCVTUQQ2PD256load, + ssa.OpAMD64VCVTUQQ2PD512load, + ssa.OpAMD64VCVTTPS2DQ512load, + ssa.OpAMD64VCVTTPD2DQ256load, + ssa.OpAMD64VCVTTPS2QQ256load, + ssa.OpAMD64VCVTTPS2QQ512load, + ssa.OpAMD64VCVTTPD2QQ128load, + ssa.OpAMD64VCVTTPD2QQ256load, + ssa.OpAMD64VCVTTPD2QQ512load, + ssa.OpAMD64VCVTTPS2UDQ128load, + ssa.OpAMD64VCVTTPS2UDQ256load, + ssa.OpAMD64VCVTTPS2UDQ512load, + ssa.OpAMD64VCVTTPD2UDQX128load, + ssa.OpAMD64VCVTTPD2UDQY128load, + ssa.OpAMD64VCVTTPD2UDQ256load, + ssa.OpAMD64VCVTTPS2UQQ256load, + ssa.OpAMD64VCVTTPS2UQQ512load, + ssa.OpAMD64VCVTTPD2UQQ128load, + ssa.OpAMD64VCVTTPD2UQQ256load, + ssa.OpAMD64VCVTTPD2UQQ512load, + ssa.OpAMD64VPLZCNTD128load, + ssa.OpAMD64VPLZCNTD256load, + ssa.OpAMD64VPLZCNTD512load, + ssa.OpAMD64VPLZCNTQ128load, + ssa.OpAMD64VPLZCNTQ256load, + ssa.OpAMD64VPLZCNTQ512load, + ssa.OpAMD64VPOPCNTD128load, + ssa.OpAMD64VPOPCNTD256load, + ssa.OpAMD64VPOPCNTD512load, + ssa.OpAMD64VPOPCNTQ128load, + ssa.OpAMD64VPOPCNTQ256load, + ssa.OpAMD64VPOPCNTQ512load, + ssa.OpAMD64VRCP14PS512load, + ssa.OpAMD64VRCP14PD128load, + ssa.OpAMD64VRCP14PD256load, + ssa.OpAMD64VRCP14PD512load, + ssa.OpAMD64VRSQRT14PS512load, + ssa.OpAMD64VRSQRT14PD128load, + ssa.OpAMD64VRSQRT14PD256load, + ssa.OpAMD64VRSQRT14PD512load, + ssa.OpAMD64VSQRTPS512load, + ssa.OpAMD64VSQRTPD512load: + p = simdV11load(s, v) + + case ssa.OpAMD64VRNDSCALEPS128load, + ssa.OpAMD64VRNDSCALEPS256load, + ssa.OpAMD64VRNDSCALEPS512load, + ssa.OpAMD64VRNDSCALEPD128load, + ssa.OpAMD64VRNDSCALEPD256load, + ssa.OpAMD64VRNDSCALEPD512load, + ssa.OpAMD64VREDUCEPS128load, + ssa.OpAMD64VREDUCEPS256load, + ssa.OpAMD64VREDUCEPS512load, + ssa.OpAMD64VREDUCEPD128load, + ssa.OpAMD64VREDUCEPD256load, + ssa.OpAMD64VREDUCEPD512load, + ssa.OpAMD64VPROLD128load, + ssa.OpAMD64VPROLD256load, + ssa.OpAMD64VPROLD512load, + ssa.OpAMD64VPROLQ128load, + ssa.OpAMD64VPROLQ256load, + ssa.OpAMD64VPROLQ512load, + ssa.OpAMD64VPRORD128load, + ssa.OpAMD64VPRORD256load, + ssa.OpAMD64VPRORD512load, + ssa.OpAMD64VPRORQ128load, + ssa.OpAMD64VPRORQ256load, + ssa.OpAMD64VPRORQ512load, + ssa.OpAMD64VPSHUFD512load, + ssa.OpAMD64VPSLLD512constload, + ssa.OpAMD64VPSLLQ512constload, + ssa.OpAMD64VPSRLD512constload, + ssa.OpAMD64VPSRLQ512constload, + ssa.OpAMD64VPSRAD512constload, + ssa.OpAMD64VPSRAQ128constload, + ssa.OpAMD64VPSRAQ256constload, + ssa.OpAMD64VPSRAQ512constload: + p = simdV11loadImm8(s, v) + + case ssa.OpAMD64VRNDSCALEPSMasked128load, + ssa.OpAMD64VRNDSCALEPSMasked256load, + ssa.OpAMD64VRNDSCALEPSMasked512load, + ssa.OpAMD64VRNDSCALEPDMasked128load, + ssa.OpAMD64VRNDSCALEPDMasked256load, + ssa.OpAMD64VRNDSCALEPDMasked512load, + ssa.OpAMD64VREDUCEPSMasked128load, + ssa.OpAMD64VREDUCEPSMasked256load, + ssa.OpAMD64VREDUCEPSMasked512load, + ssa.OpAMD64VREDUCEPDMasked128load, + ssa.OpAMD64VREDUCEPDMasked256load, + ssa.OpAMD64VREDUCEPDMasked512load, + ssa.OpAMD64VPROLDMasked128load, + ssa.OpAMD64VPROLDMasked256load, + ssa.OpAMD64VPROLDMasked512load, + ssa.OpAMD64VPROLQMasked128load, + ssa.OpAMD64VPROLQMasked256load, + ssa.OpAMD64VPROLQMasked512load, + ssa.OpAMD64VPRORDMasked128load, + ssa.OpAMD64VPRORDMasked256load, + ssa.OpAMD64VPRORDMasked512load, + ssa.OpAMD64VPRORQMasked128load, + ssa.OpAMD64VPRORQMasked256load, + ssa.OpAMD64VPRORQMasked512load, + ssa.OpAMD64VPSHUFDMasked256load, + ssa.OpAMD64VPSHUFDMasked512load, + ssa.OpAMD64VPSHUFDMasked128load, + ssa.OpAMD64VPSLLDMasked128constload, + ssa.OpAMD64VPSLLDMasked256constload, + ssa.OpAMD64VPSLLDMasked512constload, + ssa.OpAMD64VPSLLQMasked128constload, + ssa.OpAMD64VPSLLQMasked256constload, + ssa.OpAMD64VPSLLQMasked512constload, + ssa.OpAMD64VPSRLDMasked128constload, + ssa.OpAMD64VPSRLDMasked256constload, + ssa.OpAMD64VPSRLDMasked512constload, + ssa.OpAMD64VPSRLQMasked128constload, + ssa.OpAMD64VPSRLQMasked256constload, + ssa.OpAMD64VPSRLQMasked512constload, + ssa.OpAMD64VPSRADMasked128constload, + ssa.OpAMD64VPSRADMasked256constload, + ssa.OpAMD64VPSRADMasked512constload, + ssa.OpAMD64VPSRAQMasked128constload, + ssa.OpAMD64VPSRAQMasked256constload, + ssa.OpAMD64VPSRAQMasked512constload: + p = simdVkvloadImm8(s, v) + + case ssa.OpAMD64VGF2P8AFFINEQB128load, + ssa.OpAMD64VGF2P8AFFINEQB256load, + ssa.OpAMD64VGF2P8AFFINEQB512load, + ssa.OpAMD64VGF2P8AFFINEINVQB128load, + ssa.OpAMD64VGF2P8AFFINEINVQB256load, + ssa.OpAMD64VGF2P8AFFINEINVQB512load, + ssa.OpAMD64VPSHLDD128load, + ssa.OpAMD64VPSHLDD256load, + ssa.OpAMD64VPSHLDD512load, + ssa.OpAMD64VPSHLDQ128load, + ssa.OpAMD64VPSHLDQ256load, + ssa.OpAMD64VPSHLDQ512load, + ssa.OpAMD64VPSHRDD128load, + ssa.OpAMD64VPSHRDD256load, + ssa.OpAMD64VPSHRDD512load, + ssa.OpAMD64VPSHRDQ128load, + ssa.OpAMD64VPSHRDQ256load, + ssa.OpAMD64VPSHRDQ512load, + ssa.OpAMD64VSHUFPS512load, + ssa.OpAMD64VSHUFPD512load: + p = simdV21loadImm8(s, v) + + case ssa.OpAMD64VCMPPS512load, + ssa.OpAMD64VCMPPD512load, + ssa.OpAMD64VPCMPUD512load, + ssa.OpAMD64VPCMPUQ512load, + ssa.OpAMD64VPCMPD512load, + ssa.OpAMD64VPCMPQ512load: + p = simdV2kloadImm8(s, v) + + case ssa.OpAMD64VCMPPSMasked128load, + ssa.OpAMD64VCMPPSMasked256load, + ssa.OpAMD64VCMPPSMasked512load, + ssa.OpAMD64VCMPPDMasked128load, + ssa.OpAMD64VCMPPDMasked256load, + ssa.OpAMD64VCMPPDMasked512load, + ssa.OpAMD64VPCMPDMasked128load, + ssa.OpAMD64VPCMPDMasked256load, + ssa.OpAMD64VPCMPDMasked512load, + ssa.OpAMD64VPCMPQMasked128load, + ssa.OpAMD64VPCMPQMasked256load, + ssa.OpAMD64VPCMPQMasked512load, + ssa.OpAMD64VPCMPUDMasked128load, + ssa.OpAMD64VPCMPUDMasked256load, + ssa.OpAMD64VPCMPUDMasked512load, + ssa.OpAMD64VPCMPUQMasked128load, + ssa.OpAMD64VPCMPUQMasked256load, + ssa.OpAMD64VPCMPUQMasked512load: + p = simdV2kkloadImm8(s, v) + + case ssa.OpAMD64VGF2P8AFFINEINVQBMasked128load, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked256load, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked512load, + ssa.OpAMD64VGF2P8AFFINEQBMasked128load, + ssa.OpAMD64VGF2P8AFFINEQBMasked256load, + ssa.OpAMD64VGF2P8AFFINEQBMasked512load, + ssa.OpAMD64VPSHLDDMasked128load, + ssa.OpAMD64VPSHLDDMasked256load, + ssa.OpAMD64VPSHLDDMasked512load, + ssa.OpAMD64VPSHLDQMasked128load, + ssa.OpAMD64VPSHLDQMasked256load, + ssa.OpAMD64VPSHLDQMasked512load, + ssa.OpAMD64VPSHRDDMasked128load, + ssa.OpAMD64VPSHRDDMasked256load, + ssa.OpAMD64VPSHRDDMasked512load, + ssa.OpAMD64VPSHRDQMasked128load, + ssa.OpAMD64VPSHRDQMasked256load, + ssa.OpAMD64VPSHRDQMasked512load: + p = simdV2kvloadImm8(s, v) + + case ssa.OpAMD64VPTERNLOGD128, + ssa.OpAMD64VPTERNLOGD256, + ssa.OpAMD64VPTERNLOGD512, + ssa.OpAMD64VPTERNLOGQ128, + ssa.OpAMD64VPTERNLOGQ256, + ssa.OpAMD64VPTERNLOGQ512: + p = simdV31ResultInArg0Imm8(s, v) + + case ssa.OpAMD64VPTERNLOGD128load, + ssa.OpAMD64VPTERNLOGD256load, + ssa.OpAMD64VPTERNLOGD512load, + ssa.OpAMD64VPTERNLOGQ128load, + ssa.OpAMD64VPTERNLOGQ256load, + ssa.OpAMD64VPTERNLOGQ512load: + p = simdV31loadResultInArg0Imm8(s, v) + + case ssa.OpAMD64SHA1MSG1128, + ssa.OpAMD64SHA1MSG2128, + ssa.OpAMD64SHA1NEXTE128, + ssa.OpAMD64SHA256MSG1128, + ssa.OpAMD64SHA256MSG2128: + p = simdV21ResultInArg0(s, v) + + case ssa.OpAMD64SHA1RNDS4128: + p = simdV21ResultInArg0Imm8(s, v) + + case ssa.OpAMD64SHA256RNDS2128: + p = simdV31x0AtIn2ResultInArg0(s, v) + + case ssa.OpAMD64VPABSBMasked128Merging, + ssa.OpAMD64VPABSBMasked256Merging, + ssa.OpAMD64VPABSBMasked512Merging, + ssa.OpAMD64VPABSWMasked128Merging, + ssa.OpAMD64VPABSWMasked256Merging, + ssa.OpAMD64VPABSWMasked512Merging, + ssa.OpAMD64VPABSDMasked128Merging, + ssa.OpAMD64VPABSDMasked256Merging, + ssa.OpAMD64VPABSDMasked512Merging, + ssa.OpAMD64VPABSQMasked128Merging, + ssa.OpAMD64VPABSQMasked256Merging, + ssa.OpAMD64VPABSQMasked512Merging, + ssa.OpAMD64VPBROADCASTQMasked128Merging, + ssa.OpAMD64VBROADCASTSSMasked128Merging, + ssa.OpAMD64VBROADCASTSDMasked256Merging, + ssa.OpAMD64VPBROADCASTDMasked128Merging, + ssa.OpAMD64VPBROADCASTQMasked256Merging, + ssa.OpAMD64VBROADCASTSSMasked256Merging, + ssa.OpAMD64VBROADCASTSDMasked512Merging, + ssa.OpAMD64VPBROADCASTWMasked128Merging, + ssa.OpAMD64VPBROADCASTDMasked256Merging, + ssa.OpAMD64VPBROADCASTQMasked512Merging, + ssa.OpAMD64VBROADCASTSSMasked512Merging, + ssa.OpAMD64VPBROADCASTBMasked128Merging, + ssa.OpAMD64VPBROADCASTWMasked256Merging, + ssa.OpAMD64VPBROADCASTDMasked512Merging, + ssa.OpAMD64VPBROADCASTBMasked256Merging, + ssa.OpAMD64VPBROADCASTWMasked512Merging, + ssa.OpAMD64VPBROADCASTBMasked512Merging, + ssa.OpAMD64VRNDSCALEPSMasked128Merging, + ssa.OpAMD64VRNDSCALEPSMasked256Merging, + ssa.OpAMD64VRNDSCALEPSMasked512Merging, + ssa.OpAMD64VRNDSCALEPDMasked128Merging, + ssa.OpAMD64VRNDSCALEPDMasked256Merging, + ssa.OpAMD64VRNDSCALEPDMasked512Merging, + ssa.OpAMD64VREDUCEPSMasked128Merging, + ssa.OpAMD64VREDUCEPSMasked256Merging, + ssa.OpAMD64VREDUCEPSMasked512Merging, + ssa.OpAMD64VREDUCEPDMasked128Merging, + ssa.OpAMD64VREDUCEPDMasked256Merging, + ssa.OpAMD64VREDUCEPDMasked512Merging, + ssa.OpAMD64VCVTPD2PSXMasked128Merging, + ssa.OpAMD64VCVTPD2PSYMasked128Merging, + ssa.OpAMD64VCVTPD2PSMasked256Merging, + ssa.OpAMD64VCVTDQ2PSMasked128Merging, + ssa.OpAMD64VCVTDQ2PSMasked256Merging, + ssa.OpAMD64VCVTDQ2PSMasked512Merging, + ssa.OpAMD64VCVTQQ2PSXMasked128Merging, + ssa.OpAMD64VCVTQQ2PSYMasked128Merging, + ssa.OpAMD64VCVTQQ2PSMasked256Merging, + ssa.OpAMD64VCVTUDQ2PSMasked128Merging, + ssa.OpAMD64VCVTUDQ2PSMasked256Merging, + ssa.OpAMD64VCVTUDQ2PSMasked512Merging, + ssa.OpAMD64VCVTUQQ2PSXMasked128Merging, + ssa.OpAMD64VCVTUQQ2PSYMasked128Merging, + ssa.OpAMD64VCVTUQQ2PSMasked256Merging, + ssa.OpAMD64VCVTPS2PDMasked256Merging, + ssa.OpAMD64VCVTPS2PDMasked512Merging, + ssa.OpAMD64VCVTDQ2PDMasked256Merging, + ssa.OpAMD64VCVTDQ2PDMasked512Merging, + ssa.OpAMD64VCVTQQ2PDMasked128Merging, + ssa.OpAMD64VCVTQQ2PDMasked256Merging, + ssa.OpAMD64VCVTQQ2PDMasked512Merging, + ssa.OpAMD64VCVTUDQ2PDMasked256Merging, + ssa.OpAMD64VCVTUDQ2PDMasked512Merging, + ssa.OpAMD64VCVTUQQ2PDMasked128Merging, + ssa.OpAMD64VCVTUQQ2PDMasked256Merging, + ssa.OpAMD64VCVTUQQ2PDMasked512Merging, + ssa.OpAMD64VCVTTPS2DQMasked128Merging, + ssa.OpAMD64VCVTTPS2DQMasked256Merging, + ssa.OpAMD64VCVTTPS2DQMasked512Merging, + ssa.OpAMD64VCVTTPD2DQXMasked128Merging, + ssa.OpAMD64VCVTTPD2DQYMasked128Merging, + ssa.OpAMD64VCVTTPD2DQMasked256Merging, + ssa.OpAMD64VCVTTPS2QQMasked256Merging, + ssa.OpAMD64VCVTTPS2QQMasked512Merging, + ssa.OpAMD64VCVTTPD2QQMasked128Merging, + ssa.OpAMD64VCVTTPD2QQMasked256Merging, + ssa.OpAMD64VCVTTPD2QQMasked512Merging, + ssa.OpAMD64VCVTTPS2UDQMasked128Merging, + ssa.OpAMD64VCVTTPS2UDQMasked256Merging, + ssa.OpAMD64VCVTTPS2UDQMasked512Merging, + ssa.OpAMD64VCVTTPD2UDQXMasked128Merging, + ssa.OpAMD64VCVTTPD2UDQYMasked128Merging, + ssa.OpAMD64VCVTTPD2UDQMasked256Merging, + ssa.OpAMD64VCVTTPS2UQQMasked256Merging, + ssa.OpAMD64VCVTTPS2UQQMasked512Merging, + ssa.OpAMD64VCVTTPD2UQQMasked128Merging, + ssa.OpAMD64VCVTTPD2UQQMasked256Merging, + ssa.OpAMD64VCVTTPD2UQQMasked512Merging, + ssa.OpAMD64VPMOVSXBQMasked128Merging, + ssa.OpAMD64VPMOVSXWQMasked128Merging, + ssa.OpAMD64VPMOVSXDQMasked128Merging, + ssa.OpAMD64VPMOVZXBQMasked128Merging, + ssa.OpAMD64VPMOVZXWQMasked128Merging, + ssa.OpAMD64VPMOVZXDQMasked128Merging, + ssa.OpAMD64VPMOVSXBDMasked128Merging, + ssa.OpAMD64VPMOVSXWDMasked128Merging, + ssa.OpAMD64VPMOVSXBQMasked256Merging, + ssa.OpAMD64VPMOVSXWQMasked256Merging, + ssa.OpAMD64VPMOVZXBDMasked128Merging, + ssa.OpAMD64VPMOVZXWDMasked128Merging, + ssa.OpAMD64VPMOVZXBQMasked256Merging, + ssa.OpAMD64VPMOVZXWQMasked256Merging, + ssa.OpAMD64VPMOVSXBWMasked128Merging, + ssa.OpAMD64VPMOVSXBDMasked256Merging, + ssa.OpAMD64VPMOVSXBQMasked512Merging, + ssa.OpAMD64VPMOVZXBWMasked128Merging, + ssa.OpAMD64VPMOVZXBDMasked256Merging, + ssa.OpAMD64VPMOVZXBQMasked512Merging, + ssa.OpAMD64VPMOVSXBWMasked256Merging, + ssa.OpAMD64VPMOVSXBWMasked512Merging, + ssa.OpAMD64VPMOVSXBDMasked512Merging, + ssa.OpAMD64VPMOVSXWDMasked256Merging, + ssa.OpAMD64VPMOVSXWDMasked512Merging, + ssa.OpAMD64VPMOVSXWQMasked512Merging, + ssa.OpAMD64VPMOVSXDQMasked256Merging, + ssa.OpAMD64VPMOVSXDQMasked512Merging, + ssa.OpAMD64VPMOVZXBWMasked256Merging, + ssa.OpAMD64VPMOVZXBWMasked512Merging, + ssa.OpAMD64VPMOVZXBDMasked512Merging, + ssa.OpAMD64VPMOVZXWDMasked256Merging, + ssa.OpAMD64VPMOVZXWDMasked512Merging, + ssa.OpAMD64VPMOVZXWQMasked512Merging, + ssa.OpAMD64VPMOVZXDQMasked256Merging, + ssa.OpAMD64VPMOVZXDQMasked512Merging, + ssa.OpAMD64VPLZCNTDMasked128Merging, + ssa.OpAMD64VPLZCNTDMasked256Merging, + ssa.OpAMD64VPLZCNTDMasked512Merging, + ssa.OpAMD64VPLZCNTQMasked128Merging, + ssa.OpAMD64VPLZCNTQMasked256Merging, + ssa.OpAMD64VPLZCNTQMasked512Merging, + ssa.OpAMD64VPOPCNTBMasked128Merging, + ssa.OpAMD64VPOPCNTBMasked256Merging, + ssa.OpAMD64VPOPCNTBMasked512Merging, + ssa.OpAMD64VPOPCNTWMasked128Merging, + ssa.OpAMD64VPOPCNTWMasked256Merging, + ssa.OpAMD64VPOPCNTWMasked512Merging, + ssa.OpAMD64VPOPCNTDMasked128Merging, + ssa.OpAMD64VPOPCNTDMasked256Merging, + ssa.OpAMD64VPOPCNTDMasked512Merging, + ssa.OpAMD64VPOPCNTQMasked128Merging, + ssa.OpAMD64VPOPCNTQMasked256Merging, + ssa.OpAMD64VPOPCNTQMasked512Merging, + ssa.OpAMD64VRCP14PSMasked128Merging, + ssa.OpAMD64VRCP14PSMasked256Merging, + ssa.OpAMD64VRCP14PSMasked512Merging, + ssa.OpAMD64VRCP14PDMasked128Merging, + ssa.OpAMD64VRCP14PDMasked256Merging, + ssa.OpAMD64VRCP14PDMasked512Merging, + ssa.OpAMD64VRSQRT14PSMasked128Merging, + ssa.OpAMD64VRSQRT14PSMasked256Merging, + ssa.OpAMD64VRSQRT14PSMasked512Merging, + ssa.OpAMD64VRSQRT14PDMasked128Merging, + ssa.OpAMD64VRSQRT14PDMasked256Merging, + ssa.OpAMD64VRSQRT14PDMasked512Merging, + ssa.OpAMD64VPROLDMasked128Merging, + ssa.OpAMD64VPROLDMasked256Merging, + ssa.OpAMD64VPROLDMasked512Merging, + ssa.OpAMD64VPROLQMasked128Merging, + ssa.OpAMD64VPROLQMasked256Merging, + ssa.OpAMD64VPROLQMasked512Merging, + ssa.OpAMD64VPRORDMasked128Merging, + ssa.OpAMD64VPRORDMasked256Merging, + ssa.OpAMD64VPRORDMasked512Merging, + ssa.OpAMD64VPRORQMasked128Merging, + ssa.OpAMD64VPRORQMasked256Merging, + ssa.OpAMD64VPRORQMasked512Merging, + ssa.OpAMD64VPMOVSWBMasked128_128Merging, + ssa.OpAMD64VPMOVSWBMasked128_256Merging, + ssa.OpAMD64VPMOVSWBMasked256Merging, + ssa.OpAMD64VPMOVSDBMasked128_128Merging, + ssa.OpAMD64VPMOVSDBMasked128_256Merging, + ssa.OpAMD64VPMOVSDBMasked128_512Merging, + ssa.OpAMD64VPMOVSQBMasked128_128Merging, + ssa.OpAMD64VPMOVSQBMasked128_256Merging, + ssa.OpAMD64VPMOVSQBMasked128_512Merging, + ssa.OpAMD64VPMOVSDWMasked128_128Merging, + ssa.OpAMD64VPMOVSDWMasked128_256Merging, + ssa.OpAMD64VPMOVSDWMasked256Merging, + ssa.OpAMD64VPMOVSQWMasked128_128Merging, + ssa.OpAMD64VPMOVSQWMasked128_256Merging, + ssa.OpAMD64VPMOVSQWMasked128_512Merging, + ssa.OpAMD64VPMOVSQDMasked128_128Merging, + ssa.OpAMD64VPMOVSQDMasked128_256Merging, + ssa.OpAMD64VPMOVSQDMasked256Merging, + ssa.OpAMD64VPMOVUSWBMasked128_128Merging, + ssa.OpAMD64VPMOVUSWBMasked128_256Merging, + ssa.OpAMD64VPMOVUSWBMasked256Merging, + ssa.OpAMD64VPMOVUSDBMasked128_128Merging, + ssa.OpAMD64VPMOVUSDBMasked128_256Merging, + ssa.OpAMD64VPMOVUSDBMasked128_512Merging, + ssa.OpAMD64VPMOVUSQBMasked128_128Merging, + ssa.OpAMD64VPMOVUSQBMasked128_256Merging, + ssa.OpAMD64VPMOVUSQBMasked128_512Merging, + ssa.OpAMD64VPMOVUSDWMasked128_128Merging, + ssa.OpAMD64VPMOVUSDWMasked128_256Merging, + ssa.OpAMD64VPMOVUSDWMasked256Merging, + ssa.OpAMD64VPMOVUSQWMasked128_128Merging, + ssa.OpAMD64VPMOVUSQWMasked128_256Merging, + ssa.OpAMD64VPMOVUSQWMasked128_512Merging, + ssa.OpAMD64VPMOVUSQDMasked128_128Merging, + ssa.OpAMD64VPMOVUSQDMasked128_256Merging, + ssa.OpAMD64VPMOVUSQDMasked256Merging, + ssa.OpAMD64VSQRTPSMasked128Merging, + ssa.OpAMD64VSQRTPSMasked256Merging, + ssa.OpAMD64VSQRTPSMasked512Merging, + ssa.OpAMD64VSQRTPDMasked128Merging, + ssa.OpAMD64VSQRTPDMasked256Merging, + ssa.OpAMD64VSQRTPDMasked512Merging, + ssa.OpAMD64VPMOVWBMasked128_128Merging, + ssa.OpAMD64VPMOVWBMasked128_256Merging, + ssa.OpAMD64VPMOVWBMasked256Merging, + ssa.OpAMD64VPMOVDBMasked128_128Merging, + ssa.OpAMD64VPMOVDBMasked128_256Merging, + ssa.OpAMD64VPMOVDBMasked128_512Merging, + ssa.OpAMD64VPMOVQBMasked128_128Merging, + ssa.OpAMD64VPMOVQBMasked128_256Merging, + ssa.OpAMD64VPMOVQBMasked128_512Merging, + ssa.OpAMD64VPMOVDWMasked128_128Merging, + ssa.OpAMD64VPMOVDWMasked128_256Merging, + ssa.OpAMD64VPMOVDWMasked256Merging, + ssa.OpAMD64VPMOVQWMasked128_128Merging, + ssa.OpAMD64VPMOVQWMasked128_256Merging, + ssa.OpAMD64VPMOVQWMasked128_512Merging, + ssa.OpAMD64VPMOVQDMasked128_128Merging, + ssa.OpAMD64VPMOVQDMasked128_256Merging, + ssa.OpAMD64VPMOVQDMasked256Merging, + ssa.OpAMD64VPSHUFDMasked256Merging, + ssa.OpAMD64VPSHUFDMasked512Merging, + ssa.OpAMD64VPSHUFHWMasked256Merging, + ssa.OpAMD64VPSHUFHWMasked512Merging, + ssa.OpAMD64VPSHUFHWMasked128Merging, + ssa.OpAMD64VPSHUFLWMasked256Merging, + ssa.OpAMD64VPSHUFLWMasked512Merging, + ssa.OpAMD64VPSHUFLWMasked128Merging, + ssa.OpAMD64VPSHUFDMasked128Merging, + ssa.OpAMD64VPSLLWMasked128constMerging, + ssa.OpAMD64VPSLLWMasked256constMerging, + ssa.OpAMD64VPSLLWMasked512constMerging, + ssa.OpAMD64VPSLLDMasked128constMerging, + ssa.OpAMD64VPSLLDMasked256constMerging, + ssa.OpAMD64VPSLLDMasked512constMerging, + ssa.OpAMD64VPSLLQMasked128constMerging, + ssa.OpAMD64VPSLLQMasked256constMerging, + ssa.OpAMD64VPSLLQMasked512constMerging, + ssa.OpAMD64VPSRLWMasked128constMerging, + ssa.OpAMD64VPSRLWMasked256constMerging, + ssa.OpAMD64VPSRLWMasked512constMerging, + ssa.OpAMD64VPSRLDMasked128constMerging, + ssa.OpAMD64VPSRLDMasked256constMerging, + ssa.OpAMD64VPSRLDMasked512constMerging, + ssa.OpAMD64VPSRLQMasked128constMerging, + ssa.OpAMD64VPSRLQMasked256constMerging, + ssa.OpAMD64VPSRLQMasked512constMerging, + ssa.OpAMD64VPSRAWMasked128constMerging, + ssa.OpAMD64VPSRAWMasked256constMerging, + ssa.OpAMD64VPSRAWMasked512constMerging, + ssa.OpAMD64VPSRADMasked128constMerging, + ssa.OpAMD64VPSRADMasked256constMerging, + ssa.OpAMD64VPSRADMasked512constMerging, + ssa.OpAMD64VPSRAQMasked128constMerging, + ssa.OpAMD64VPSRAQMasked256constMerging, + ssa.OpAMD64VPSRAQMasked512constMerging: + p = simdV2kvResultInArg0(s, v) + + default: + // Unknown reg shape + return false + } + + // Masked operation are always compiled with zeroing. + switch v.Op { + case ssa.OpAMD64VPABSBMasked128, + ssa.OpAMD64VPABSBMasked256, + ssa.OpAMD64VPABSBMasked512, + ssa.OpAMD64VPABSWMasked128, + ssa.OpAMD64VPABSWMasked256, + ssa.OpAMD64VPABSWMasked512, + ssa.OpAMD64VPABSDMasked128, + ssa.OpAMD64VPABSDMasked128load, + ssa.OpAMD64VPABSDMasked256, + ssa.OpAMD64VPABSDMasked256load, + ssa.OpAMD64VPABSDMasked512, + ssa.OpAMD64VPABSDMasked512load, + ssa.OpAMD64VPABSQMasked128, + ssa.OpAMD64VPABSQMasked128load, + ssa.OpAMD64VPABSQMasked256, + ssa.OpAMD64VPABSQMasked256load, + ssa.OpAMD64VPABSQMasked512, + ssa.OpAMD64VPABSQMasked512load, + ssa.OpAMD64VPDPWSSDMasked128, + ssa.OpAMD64VPDPWSSDMasked128load, + ssa.OpAMD64VPDPWSSDMasked256, + ssa.OpAMD64VPDPWSSDMasked256load, + ssa.OpAMD64VPDPWSSDMasked512, + ssa.OpAMD64VPDPWSSDMasked512load, + ssa.OpAMD64VADDPSMasked128, + ssa.OpAMD64VADDPSMasked128load, + ssa.OpAMD64VADDPSMasked256, + ssa.OpAMD64VADDPSMasked256load, + ssa.OpAMD64VADDPSMasked512, + ssa.OpAMD64VADDPSMasked512load, + ssa.OpAMD64VADDPDMasked128, + ssa.OpAMD64VADDPDMasked128load, + ssa.OpAMD64VADDPDMasked256, + ssa.OpAMD64VADDPDMasked256load, + ssa.OpAMD64VADDPDMasked512, + ssa.OpAMD64VADDPDMasked512load, + ssa.OpAMD64VPADDBMasked128, + ssa.OpAMD64VPADDBMasked256, + ssa.OpAMD64VPADDBMasked512, + ssa.OpAMD64VPADDWMasked128, + ssa.OpAMD64VPADDWMasked256, + ssa.OpAMD64VPADDWMasked512, + ssa.OpAMD64VPADDDMasked128, + ssa.OpAMD64VPADDDMasked128load, + ssa.OpAMD64VPADDDMasked256, + ssa.OpAMD64VPADDDMasked256load, + ssa.OpAMD64VPADDDMasked512, + ssa.OpAMD64VPADDDMasked512load, + ssa.OpAMD64VPADDQMasked128, + ssa.OpAMD64VPADDQMasked128load, + ssa.OpAMD64VPADDQMasked256, + ssa.OpAMD64VPADDQMasked256load, + ssa.OpAMD64VPADDQMasked512, + ssa.OpAMD64VPADDQMasked512load, + ssa.OpAMD64VPADDSBMasked128, + ssa.OpAMD64VPADDSBMasked256, + ssa.OpAMD64VPADDSBMasked512, + ssa.OpAMD64VPADDSWMasked128, + ssa.OpAMD64VPADDSWMasked256, + ssa.OpAMD64VPADDSWMasked512, + ssa.OpAMD64VPADDUSBMasked128, + ssa.OpAMD64VPADDUSBMasked256, + ssa.OpAMD64VPADDUSBMasked512, + ssa.OpAMD64VPADDUSWMasked128, + ssa.OpAMD64VPADDUSWMasked256, + ssa.OpAMD64VPADDUSWMasked512, + ssa.OpAMD64VPANDDMasked128, + ssa.OpAMD64VPANDDMasked128load, + ssa.OpAMD64VPANDDMasked256, + ssa.OpAMD64VPANDDMasked256load, + ssa.OpAMD64VPANDDMasked512, + ssa.OpAMD64VPANDDMasked512load, + ssa.OpAMD64VPANDQMasked128, + ssa.OpAMD64VPANDQMasked128load, + ssa.OpAMD64VPANDQMasked256, + ssa.OpAMD64VPANDQMasked256load, + ssa.OpAMD64VPANDQMasked512, + ssa.OpAMD64VPANDQMasked512load, + ssa.OpAMD64VPANDNDMasked128, + ssa.OpAMD64VPANDNDMasked128load, + ssa.OpAMD64VPANDNDMasked256, + ssa.OpAMD64VPANDNDMasked256load, + ssa.OpAMD64VPANDNDMasked512, + ssa.OpAMD64VPANDNDMasked512load, + ssa.OpAMD64VPANDNQMasked128, + ssa.OpAMD64VPANDNQMasked128load, + ssa.OpAMD64VPANDNQMasked256, + ssa.OpAMD64VPANDNQMasked256load, + ssa.OpAMD64VPANDNQMasked512, + ssa.OpAMD64VPANDNQMasked512load, + ssa.OpAMD64VPAVGBMasked128, + ssa.OpAMD64VPAVGBMasked256, + ssa.OpAMD64VPAVGBMasked512, + ssa.OpAMD64VPAVGWMasked128, + ssa.OpAMD64VPAVGWMasked256, + ssa.OpAMD64VPAVGWMasked512, + ssa.OpAMD64VPBROADCASTQMasked128, + ssa.OpAMD64VBROADCASTSSMasked128, + ssa.OpAMD64VBROADCASTSDMasked256, + ssa.OpAMD64VPBROADCASTDMasked128, + ssa.OpAMD64VPBROADCASTQMasked256, + ssa.OpAMD64VBROADCASTSSMasked256, + ssa.OpAMD64VBROADCASTSDMasked512, + ssa.OpAMD64VPBROADCASTWMasked128, + ssa.OpAMD64VPBROADCASTDMasked256, + ssa.OpAMD64VPBROADCASTQMasked512, + ssa.OpAMD64VBROADCASTSSMasked512, + ssa.OpAMD64VPBROADCASTBMasked128, + ssa.OpAMD64VPBROADCASTWMasked256, + ssa.OpAMD64VPBROADCASTDMasked512, + ssa.OpAMD64VPBROADCASTBMasked256, + ssa.OpAMD64VPBROADCASTWMasked512, + ssa.OpAMD64VPBROADCASTBMasked512, + ssa.OpAMD64VRNDSCALEPSMasked128, + ssa.OpAMD64VRNDSCALEPSMasked128load, + ssa.OpAMD64VRNDSCALEPSMasked256, + ssa.OpAMD64VRNDSCALEPSMasked256load, + ssa.OpAMD64VRNDSCALEPSMasked512, + ssa.OpAMD64VRNDSCALEPSMasked512load, + ssa.OpAMD64VRNDSCALEPDMasked128, + ssa.OpAMD64VRNDSCALEPDMasked128load, + ssa.OpAMD64VRNDSCALEPDMasked256, + ssa.OpAMD64VRNDSCALEPDMasked256load, + ssa.OpAMD64VRNDSCALEPDMasked512, + ssa.OpAMD64VRNDSCALEPDMasked512load, + ssa.OpAMD64VREDUCEPSMasked128, + ssa.OpAMD64VREDUCEPSMasked128load, + ssa.OpAMD64VREDUCEPSMasked256, + ssa.OpAMD64VREDUCEPSMasked256load, + ssa.OpAMD64VREDUCEPSMasked512, + ssa.OpAMD64VREDUCEPSMasked512load, + ssa.OpAMD64VREDUCEPDMasked128, + ssa.OpAMD64VREDUCEPDMasked128load, + ssa.OpAMD64VREDUCEPDMasked256, + ssa.OpAMD64VREDUCEPDMasked256load, + ssa.OpAMD64VREDUCEPDMasked512, + ssa.OpAMD64VREDUCEPDMasked512load, + ssa.OpAMD64VCOMPRESSPSMasked128, + ssa.OpAMD64VCOMPRESSPSMasked256, + ssa.OpAMD64VCOMPRESSPSMasked512, + ssa.OpAMD64VCOMPRESSPDMasked128, + ssa.OpAMD64VCOMPRESSPDMasked256, + ssa.OpAMD64VCOMPRESSPDMasked512, + ssa.OpAMD64VPCOMPRESSBMasked128, + ssa.OpAMD64VPCOMPRESSBMasked256, + ssa.OpAMD64VPCOMPRESSBMasked512, + ssa.OpAMD64VPCOMPRESSWMasked128, + ssa.OpAMD64VPCOMPRESSWMasked256, + ssa.OpAMD64VPCOMPRESSWMasked512, + ssa.OpAMD64VPCOMPRESSDMasked128, + ssa.OpAMD64VPCOMPRESSDMasked256, + ssa.OpAMD64VPCOMPRESSDMasked512, + ssa.OpAMD64VPCOMPRESSQMasked128, + ssa.OpAMD64VPCOMPRESSQMasked256, + ssa.OpAMD64VPCOMPRESSQMasked512, + ssa.OpAMD64VPERMI2BMasked128, + ssa.OpAMD64VPERMI2BMasked256, + ssa.OpAMD64VPERMI2BMasked512, + ssa.OpAMD64VPERMI2WMasked128, + ssa.OpAMD64VPERMI2WMasked256, + ssa.OpAMD64VPERMI2WMasked512, + ssa.OpAMD64VPERMI2PSMasked128, + ssa.OpAMD64VPERMI2PSMasked128load, + ssa.OpAMD64VPERMI2DMasked128, + ssa.OpAMD64VPERMI2DMasked128load, + ssa.OpAMD64VPERMI2PSMasked256, + ssa.OpAMD64VPERMI2PSMasked256load, + ssa.OpAMD64VPERMI2DMasked256, + ssa.OpAMD64VPERMI2DMasked256load, + ssa.OpAMD64VPERMI2PSMasked512, + ssa.OpAMD64VPERMI2PSMasked512load, + ssa.OpAMD64VPERMI2DMasked512, + ssa.OpAMD64VPERMI2DMasked512load, + ssa.OpAMD64VPERMI2PDMasked128, + ssa.OpAMD64VPERMI2PDMasked128load, + ssa.OpAMD64VPERMI2QMasked128, + ssa.OpAMD64VPERMI2QMasked128load, + ssa.OpAMD64VPERMI2PDMasked256, + ssa.OpAMD64VPERMI2PDMasked256load, + ssa.OpAMD64VPERMI2QMasked256, + ssa.OpAMD64VPERMI2QMasked256load, + ssa.OpAMD64VPERMI2PDMasked512, + ssa.OpAMD64VPERMI2PDMasked512load, + ssa.OpAMD64VPERMI2QMasked512, + ssa.OpAMD64VPERMI2QMasked512load, + ssa.OpAMD64VPALIGNRMasked256, + ssa.OpAMD64VPALIGNRMasked512, + ssa.OpAMD64VPALIGNRMasked128, + ssa.OpAMD64VCVTPD2PSXMasked128, + ssa.OpAMD64VCVTPD2PSXMasked128load, + ssa.OpAMD64VCVTPD2PSYMasked128, + ssa.OpAMD64VCVTPD2PSYMasked128load, + ssa.OpAMD64VCVTPD2PSMasked256, + ssa.OpAMD64VCVTPD2PSMasked256load, + ssa.OpAMD64VCVTDQ2PSMasked128, + ssa.OpAMD64VCVTDQ2PSMasked128load, + ssa.OpAMD64VCVTDQ2PSMasked256, + ssa.OpAMD64VCVTDQ2PSMasked256load, + ssa.OpAMD64VCVTDQ2PSMasked512, + ssa.OpAMD64VCVTDQ2PSMasked512load, + ssa.OpAMD64VCVTQQ2PSXMasked128, + ssa.OpAMD64VCVTQQ2PSXMasked128load, + ssa.OpAMD64VCVTQQ2PSYMasked128, + ssa.OpAMD64VCVTQQ2PSYMasked128load, + ssa.OpAMD64VCVTQQ2PSMasked256, + ssa.OpAMD64VCVTQQ2PSMasked256load, + ssa.OpAMD64VCVTUDQ2PSMasked128, + ssa.OpAMD64VCVTUDQ2PSMasked128load, + ssa.OpAMD64VCVTUDQ2PSMasked256, + ssa.OpAMD64VCVTUDQ2PSMasked256load, + ssa.OpAMD64VCVTUDQ2PSMasked512, + ssa.OpAMD64VCVTUDQ2PSMasked512load, + ssa.OpAMD64VCVTUQQ2PSXMasked128, + ssa.OpAMD64VCVTUQQ2PSXMasked128load, + ssa.OpAMD64VCVTUQQ2PSYMasked128, + ssa.OpAMD64VCVTUQQ2PSYMasked128load, + ssa.OpAMD64VCVTUQQ2PSMasked256, + ssa.OpAMD64VCVTUQQ2PSMasked256load, + ssa.OpAMD64VCVTPS2PDMasked256, + ssa.OpAMD64VCVTPS2PDMasked256load, + ssa.OpAMD64VCVTPS2PDMasked512, + ssa.OpAMD64VCVTPS2PDMasked512load, + ssa.OpAMD64VCVTDQ2PDMasked256, + ssa.OpAMD64VCVTDQ2PDMasked256load, + ssa.OpAMD64VCVTDQ2PDMasked512, + ssa.OpAMD64VCVTDQ2PDMasked512load, + ssa.OpAMD64VCVTQQ2PDMasked128, + ssa.OpAMD64VCVTQQ2PDMasked128load, + ssa.OpAMD64VCVTQQ2PDMasked256, + ssa.OpAMD64VCVTQQ2PDMasked256load, + ssa.OpAMD64VCVTQQ2PDMasked512, + ssa.OpAMD64VCVTQQ2PDMasked512load, + ssa.OpAMD64VCVTUDQ2PDMasked256, + ssa.OpAMD64VCVTUDQ2PDMasked256load, + ssa.OpAMD64VCVTUDQ2PDMasked512, + ssa.OpAMD64VCVTUDQ2PDMasked512load, + ssa.OpAMD64VCVTUQQ2PDMasked128, + ssa.OpAMD64VCVTUQQ2PDMasked128load, + ssa.OpAMD64VCVTUQQ2PDMasked256, + ssa.OpAMD64VCVTUQQ2PDMasked256load, + ssa.OpAMD64VCVTUQQ2PDMasked512, + ssa.OpAMD64VCVTUQQ2PDMasked512load, + ssa.OpAMD64VCVTTPS2DQMasked128, + ssa.OpAMD64VCVTTPS2DQMasked128load, + ssa.OpAMD64VCVTTPS2DQMasked256, + ssa.OpAMD64VCVTTPS2DQMasked256load, + ssa.OpAMD64VCVTTPS2DQMasked512, + ssa.OpAMD64VCVTTPS2DQMasked512load, + ssa.OpAMD64VCVTTPD2DQXMasked128, + ssa.OpAMD64VCVTTPD2DQXMasked128load, + ssa.OpAMD64VCVTTPD2DQYMasked128, + ssa.OpAMD64VCVTTPD2DQYMasked128load, + ssa.OpAMD64VCVTTPD2DQMasked256, + ssa.OpAMD64VCVTTPD2DQMasked256load, + ssa.OpAMD64VCVTTPS2QQMasked256, + ssa.OpAMD64VCVTTPS2QQMasked256load, + ssa.OpAMD64VCVTTPS2QQMasked512, + ssa.OpAMD64VCVTTPS2QQMasked512load, + ssa.OpAMD64VCVTTPD2QQMasked128, + ssa.OpAMD64VCVTTPD2QQMasked128load, + ssa.OpAMD64VCVTTPD2QQMasked256, + ssa.OpAMD64VCVTTPD2QQMasked256load, + ssa.OpAMD64VCVTTPD2QQMasked512, + ssa.OpAMD64VCVTTPD2QQMasked512load, + ssa.OpAMD64VCVTTPS2UDQMasked128, + ssa.OpAMD64VCVTTPS2UDQMasked128load, + ssa.OpAMD64VCVTTPS2UDQMasked256, + ssa.OpAMD64VCVTTPS2UDQMasked256load, + ssa.OpAMD64VCVTTPS2UDQMasked512, + ssa.OpAMD64VCVTTPS2UDQMasked512load, + ssa.OpAMD64VCVTTPD2UDQXMasked128, + ssa.OpAMD64VCVTTPD2UDQXMasked128load, + ssa.OpAMD64VCVTTPD2UDQYMasked128, + ssa.OpAMD64VCVTTPD2UDQYMasked128load, + ssa.OpAMD64VCVTTPD2UDQMasked256, + ssa.OpAMD64VCVTTPD2UDQMasked256load, + ssa.OpAMD64VCVTTPS2UQQMasked256, + ssa.OpAMD64VCVTTPS2UQQMasked256load, + ssa.OpAMD64VCVTTPS2UQQMasked512, + ssa.OpAMD64VCVTTPS2UQQMasked512load, + ssa.OpAMD64VCVTTPD2UQQMasked128, + ssa.OpAMD64VCVTTPD2UQQMasked128load, + ssa.OpAMD64VCVTTPD2UQQMasked256, + ssa.OpAMD64VCVTTPD2UQQMasked256load, + ssa.OpAMD64VCVTTPD2UQQMasked512, + ssa.OpAMD64VCVTTPD2UQQMasked512load, + ssa.OpAMD64VDIVPSMasked128, + ssa.OpAMD64VDIVPSMasked128load, + ssa.OpAMD64VDIVPSMasked256, + ssa.OpAMD64VDIVPSMasked256load, + ssa.OpAMD64VDIVPSMasked512, + ssa.OpAMD64VDIVPSMasked512load, + ssa.OpAMD64VDIVPDMasked128, + ssa.OpAMD64VDIVPDMasked128load, + ssa.OpAMD64VDIVPDMasked256, + ssa.OpAMD64VDIVPDMasked256load, + ssa.OpAMD64VDIVPDMasked512, + ssa.OpAMD64VDIVPDMasked512load, + ssa.OpAMD64VPMADDWDMasked128, + ssa.OpAMD64VPMADDWDMasked256, + ssa.OpAMD64VPMADDWDMasked512, + ssa.OpAMD64VPMADDUBSWMasked128, + ssa.OpAMD64VPMADDUBSWMasked256, + ssa.OpAMD64VPMADDUBSWMasked512, + ssa.OpAMD64VEXPANDPSMasked128, + ssa.OpAMD64VEXPANDPSMasked256, + ssa.OpAMD64VEXPANDPSMasked512, + ssa.OpAMD64VEXPANDPDMasked128, + ssa.OpAMD64VEXPANDPDMasked256, + ssa.OpAMD64VEXPANDPDMasked512, + ssa.OpAMD64VPEXPANDBMasked128, + ssa.OpAMD64VPEXPANDBMasked256, + ssa.OpAMD64VPEXPANDBMasked512, + ssa.OpAMD64VPEXPANDWMasked128, + ssa.OpAMD64VPEXPANDWMasked256, + ssa.OpAMD64VPEXPANDWMasked512, + ssa.OpAMD64VPEXPANDDMasked128, + ssa.OpAMD64VPEXPANDDMasked256, + ssa.OpAMD64VPEXPANDDMasked512, + ssa.OpAMD64VPEXPANDQMasked128, + ssa.OpAMD64VPEXPANDQMasked256, + ssa.OpAMD64VPEXPANDQMasked512, + ssa.OpAMD64VPMOVSXBQMasked128, + ssa.OpAMD64VPMOVSXWQMasked128, + ssa.OpAMD64VPMOVSXDQMasked128, + ssa.OpAMD64VPMOVZXBQMasked128, + ssa.OpAMD64VPMOVZXWQMasked128, + ssa.OpAMD64VPMOVZXDQMasked128, + ssa.OpAMD64VPMOVSXBDMasked128, + ssa.OpAMD64VPMOVSXWDMasked128, + ssa.OpAMD64VPMOVSXBQMasked256, + ssa.OpAMD64VPMOVSXWQMasked256, + ssa.OpAMD64VPMOVZXBDMasked128, + ssa.OpAMD64VPMOVZXWDMasked128, + ssa.OpAMD64VPMOVZXBQMasked256, + ssa.OpAMD64VPMOVZXWQMasked256, + ssa.OpAMD64VPMOVSXBWMasked128, + ssa.OpAMD64VPMOVSXBDMasked256, + ssa.OpAMD64VPMOVSXBQMasked512, + ssa.OpAMD64VPMOVZXBWMasked128, + ssa.OpAMD64VPMOVZXBDMasked256, + ssa.OpAMD64VPMOVZXBQMasked512, + ssa.OpAMD64VPMOVSXBWMasked256, + ssa.OpAMD64VPMOVSXBWMasked512, + ssa.OpAMD64VPMOVSXBDMasked512, + ssa.OpAMD64VPMOVSXWDMasked256, + ssa.OpAMD64VPMOVSXWDMasked512, + ssa.OpAMD64VPMOVSXWQMasked512, + ssa.OpAMD64VPMOVSXDQMasked256, + ssa.OpAMD64VPMOVSXDQMasked512, + ssa.OpAMD64VPMOVZXBWMasked256, + ssa.OpAMD64VPMOVZXBWMasked512, + ssa.OpAMD64VPMOVZXBDMasked512, + ssa.OpAMD64VPMOVZXWDMasked256, + ssa.OpAMD64VPMOVZXWDMasked512, + ssa.OpAMD64VPMOVZXWQMasked512, + ssa.OpAMD64VPMOVZXDQMasked256, + ssa.OpAMD64VPMOVZXDQMasked512, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked128, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked128load, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked256, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked256load, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked512, + ssa.OpAMD64VGF2P8AFFINEINVQBMasked512load, + ssa.OpAMD64VGF2P8AFFINEQBMasked128, + ssa.OpAMD64VGF2P8AFFINEQBMasked128load, + ssa.OpAMD64VGF2P8AFFINEQBMasked256, + ssa.OpAMD64VGF2P8AFFINEQBMasked256load, + ssa.OpAMD64VGF2P8AFFINEQBMasked512, + ssa.OpAMD64VGF2P8AFFINEQBMasked512load, + ssa.OpAMD64VGF2P8MULBMasked128, + ssa.OpAMD64VGF2P8MULBMasked256, + ssa.OpAMD64VGF2P8MULBMasked512, + ssa.OpAMD64VPLZCNTDMasked128, + ssa.OpAMD64VPLZCNTDMasked128load, + ssa.OpAMD64VPLZCNTDMasked256, + ssa.OpAMD64VPLZCNTDMasked256load, + ssa.OpAMD64VPLZCNTDMasked512, + ssa.OpAMD64VPLZCNTDMasked512load, + ssa.OpAMD64VPLZCNTQMasked128, + ssa.OpAMD64VPLZCNTQMasked128load, + ssa.OpAMD64VPLZCNTQMasked256, + ssa.OpAMD64VPLZCNTQMasked256load, + ssa.OpAMD64VPLZCNTQMasked512, + ssa.OpAMD64VPLZCNTQMasked512load, + ssa.OpAMD64VMAXPSMasked128, + ssa.OpAMD64VMAXPSMasked128load, + ssa.OpAMD64VMAXPSMasked256, + ssa.OpAMD64VMAXPSMasked256load, + ssa.OpAMD64VMAXPSMasked512, + ssa.OpAMD64VMAXPSMasked512load, + ssa.OpAMD64VMAXPDMasked128, + ssa.OpAMD64VMAXPDMasked128load, + ssa.OpAMD64VMAXPDMasked256, + ssa.OpAMD64VMAXPDMasked256load, + ssa.OpAMD64VMAXPDMasked512, + ssa.OpAMD64VMAXPDMasked512load, + ssa.OpAMD64VPMAXSBMasked128, + ssa.OpAMD64VPMAXSBMasked256, + ssa.OpAMD64VPMAXSBMasked512, + ssa.OpAMD64VPMAXSWMasked128, + ssa.OpAMD64VPMAXSWMasked256, + ssa.OpAMD64VPMAXSWMasked512, + ssa.OpAMD64VPMAXSDMasked128, + ssa.OpAMD64VPMAXSDMasked128load, + ssa.OpAMD64VPMAXSDMasked256, + ssa.OpAMD64VPMAXSDMasked256load, + ssa.OpAMD64VPMAXSDMasked512, + ssa.OpAMD64VPMAXSDMasked512load, + ssa.OpAMD64VPMAXSQMasked128, + ssa.OpAMD64VPMAXSQMasked128load, + ssa.OpAMD64VPMAXSQMasked256, + ssa.OpAMD64VPMAXSQMasked256load, + ssa.OpAMD64VPMAXSQMasked512, + ssa.OpAMD64VPMAXSQMasked512load, + ssa.OpAMD64VPMAXUBMasked128, + ssa.OpAMD64VPMAXUBMasked256, + ssa.OpAMD64VPMAXUBMasked512, + ssa.OpAMD64VPMAXUWMasked128, + ssa.OpAMD64VPMAXUWMasked256, + ssa.OpAMD64VPMAXUWMasked512, + ssa.OpAMD64VPMAXUDMasked128, + ssa.OpAMD64VPMAXUDMasked128load, + ssa.OpAMD64VPMAXUDMasked256, + ssa.OpAMD64VPMAXUDMasked256load, + ssa.OpAMD64VPMAXUDMasked512, + ssa.OpAMD64VPMAXUDMasked512load, + ssa.OpAMD64VPMAXUQMasked128, + ssa.OpAMD64VPMAXUQMasked128load, + ssa.OpAMD64VPMAXUQMasked256, + ssa.OpAMD64VPMAXUQMasked256load, + ssa.OpAMD64VPMAXUQMasked512, + ssa.OpAMD64VPMAXUQMasked512load, + ssa.OpAMD64VMINPSMasked128, + ssa.OpAMD64VMINPSMasked128load, + ssa.OpAMD64VMINPSMasked256, + ssa.OpAMD64VMINPSMasked256load, + ssa.OpAMD64VMINPSMasked512, + ssa.OpAMD64VMINPSMasked512load, + ssa.OpAMD64VMINPDMasked128, + ssa.OpAMD64VMINPDMasked128load, + ssa.OpAMD64VMINPDMasked256, + ssa.OpAMD64VMINPDMasked256load, + ssa.OpAMD64VMINPDMasked512, + ssa.OpAMD64VMINPDMasked512load, + ssa.OpAMD64VPMINSBMasked128, + ssa.OpAMD64VPMINSBMasked256, + ssa.OpAMD64VPMINSBMasked512, + ssa.OpAMD64VPMINSWMasked128, + ssa.OpAMD64VPMINSWMasked256, + ssa.OpAMD64VPMINSWMasked512, + ssa.OpAMD64VPMINSDMasked128, + ssa.OpAMD64VPMINSDMasked128load, + ssa.OpAMD64VPMINSDMasked256, + ssa.OpAMD64VPMINSDMasked256load, + ssa.OpAMD64VPMINSDMasked512, + ssa.OpAMD64VPMINSDMasked512load, + ssa.OpAMD64VPMINSQMasked128, + ssa.OpAMD64VPMINSQMasked128load, + ssa.OpAMD64VPMINSQMasked256, + ssa.OpAMD64VPMINSQMasked256load, + ssa.OpAMD64VPMINSQMasked512, + ssa.OpAMD64VPMINSQMasked512load, + ssa.OpAMD64VPMINUBMasked128, + ssa.OpAMD64VPMINUBMasked256, + ssa.OpAMD64VPMINUBMasked512, + ssa.OpAMD64VPMINUWMasked128, + ssa.OpAMD64VPMINUWMasked256, + ssa.OpAMD64VPMINUWMasked512, + ssa.OpAMD64VPMINUDMasked128, + ssa.OpAMD64VPMINUDMasked128load, + ssa.OpAMD64VPMINUDMasked256, + ssa.OpAMD64VPMINUDMasked256load, + ssa.OpAMD64VPMINUDMasked512, + ssa.OpAMD64VPMINUDMasked512load, + ssa.OpAMD64VPMINUQMasked128, + ssa.OpAMD64VPMINUQMasked128load, + ssa.OpAMD64VPMINUQMasked256, + ssa.OpAMD64VPMINUQMasked256load, + ssa.OpAMD64VPMINUQMasked512, + ssa.OpAMD64VPMINUQMasked512load, + ssa.OpAMD64VFMADD213PSMasked128, + ssa.OpAMD64VFMADD213PSMasked128load, + ssa.OpAMD64VFMADD213PSMasked256, + ssa.OpAMD64VFMADD213PSMasked256load, + ssa.OpAMD64VFMADD213PSMasked512, + ssa.OpAMD64VFMADD213PSMasked512load, + ssa.OpAMD64VFMADD213PDMasked128, + ssa.OpAMD64VFMADD213PDMasked128load, + ssa.OpAMD64VFMADD213PDMasked256, + ssa.OpAMD64VFMADD213PDMasked256load, + ssa.OpAMD64VFMADD213PDMasked512, + ssa.OpAMD64VFMADD213PDMasked512load, + ssa.OpAMD64VFMADDSUB213PSMasked128, + ssa.OpAMD64VFMADDSUB213PSMasked128load, + ssa.OpAMD64VFMADDSUB213PSMasked256, + ssa.OpAMD64VFMADDSUB213PSMasked256load, + ssa.OpAMD64VFMADDSUB213PSMasked512, + ssa.OpAMD64VFMADDSUB213PSMasked512load, + ssa.OpAMD64VFMADDSUB213PDMasked128, + ssa.OpAMD64VFMADDSUB213PDMasked128load, + ssa.OpAMD64VFMADDSUB213PDMasked256, + ssa.OpAMD64VFMADDSUB213PDMasked256load, + ssa.OpAMD64VFMADDSUB213PDMasked512, + ssa.OpAMD64VFMADDSUB213PDMasked512load, + ssa.OpAMD64VPMULHWMasked128, + ssa.OpAMD64VPMULHWMasked256, + ssa.OpAMD64VPMULHWMasked512, + ssa.OpAMD64VPMULHUWMasked128, + ssa.OpAMD64VPMULHUWMasked256, + ssa.OpAMD64VPMULHUWMasked512, + ssa.OpAMD64VMULPSMasked128, + ssa.OpAMD64VMULPSMasked128load, + ssa.OpAMD64VMULPSMasked256, + ssa.OpAMD64VMULPSMasked256load, + ssa.OpAMD64VMULPSMasked512, + ssa.OpAMD64VMULPSMasked512load, + ssa.OpAMD64VMULPDMasked128, + ssa.OpAMD64VMULPDMasked128load, + ssa.OpAMD64VMULPDMasked256, + ssa.OpAMD64VMULPDMasked256load, + ssa.OpAMD64VMULPDMasked512, + ssa.OpAMD64VMULPDMasked512load, + ssa.OpAMD64VPMULLWMasked128, + ssa.OpAMD64VPMULLWMasked256, + ssa.OpAMD64VPMULLWMasked512, + ssa.OpAMD64VPMULLDMasked128, + ssa.OpAMD64VPMULLDMasked128load, + ssa.OpAMD64VPMULLDMasked256, + ssa.OpAMD64VPMULLDMasked256load, + ssa.OpAMD64VPMULLDMasked512, + ssa.OpAMD64VPMULLDMasked512load, + ssa.OpAMD64VPMULLQMasked128, + ssa.OpAMD64VPMULLQMasked128load, + ssa.OpAMD64VPMULLQMasked256, + ssa.OpAMD64VPMULLQMasked256load, + ssa.OpAMD64VPMULLQMasked512, + ssa.OpAMD64VPMULLQMasked512load, + ssa.OpAMD64VFMSUBADD213PSMasked128, + ssa.OpAMD64VFMSUBADD213PSMasked128load, + ssa.OpAMD64VFMSUBADD213PSMasked256, + ssa.OpAMD64VFMSUBADD213PSMasked256load, + ssa.OpAMD64VFMSUBADD213PSMasked512, + ssa.OpAMD64VFMSUBADD213PSMasked512load, + ssa.OpAMD64VFMSUBADD213PDMasked128, + ssa.OpAMD64VFMSUBADD213PDMasked128load, + ssa.OpAMD64VFMSUBADD213PDMasked256, + ssa.OpAMD64VFMSUBADD213PDMasked256load, + ssa.OpAMD64VFMSUBADD213PDMasked512, + ssa.OpAMD64VFMSUBADD213PDMasked512load, + ssa.OpAMD64VPOPCNTBMasked128, + ssa.OpAMD64VPOPCNTBMasked256, + ssa.OpAMD64VPOPCNTBMasked512, + ssa.OpAMD64VPOPCNTWMasked128, + ssa.OpAMD64VPOPCNTWMasked256, + ssa.OpAMD64VPOPCNTWMasked512, + ssa.OpAMD64VPOPCNTDMasked128, + ssa.OpAMD64VPOPCNTDMasked128load, + ssa.OpAMD64VPOPCNTDMasked256, + ssa.OpAMD64VPOPCNTDMasked256load, + ssa.OpAMD64VPOPCNTDMasked512, + ssa.OpAMD64VPOPCNTDMasked512load, + ssa.OpAMD64VPOPCNTQMasked128, + ssa.OpAMD64VPOPCNTQMasked128load, + ssa.OpAMD64VPOPCNTQMasked256, + ssa.OpAMD64VPOPCNTQMasked256load, + ssa.OpAMD64VPOPCNTQMasked512, + ssa.OpAMD64VPOPCNTQMasked512load, + ssa.OpAMD64VPORDMasked128, + ssa.OpAMD64VPORDMasked128load, + ssa.OpAMD64VPORDMasked256, + ssa.OpAMD64VPORDMasked256load, + ssa.OpAMD64VPORDMasked512, + ssa.OpAMD64VPORDMasked512load, + ssa.OpAMD64VPORQMasked128, + ssa.OpAMD64VPORQMasked128load, + ssa.OpAMD64VPORQMasked256, + ssa.OpAMD64VPORQMasked256load, + ssa.OpAMD64VPORQMasked512, + ssa.OpAMD64VPORQMasked512load, + ssa.OpAMD64VPERMBMasked128, + ssa.OpAMD64VPERMBMasked256, + ssa.OpAMD64VPERMBMasked512, + ssa.OpAMD64VPERMWMasked128, + ssa.OpAMD64VPERMWMasked256, + ssa.OpAMD64VPERMWMasked512, + ssa.OpAMD64VPERMPSMasked256, + ssa.OpAMD64VPERMPSMasked256load, + ssa.OpAMD64VPERMDMasked256, + ssa.OpAMD64VPERMDMasked256load, + ssa.OpAMD64VPERMPSMasked512, + ssa.OpAMD64VPERMPSMasked512load, + ssa.OpAMD64VPERMDMasked512, + ssa.OpAMD64VPERMDMasked512load, + ssa.OpAMD64VPERMPDMasked256, + ssa.OpAMD64VPERMPDMasked256load, + ssa.OpAMD64VPERMQMasked256, + ssa.OpAMD64VPERMQMasked256load, + ssa.OpAMD64VPERMPDMasked512, + ssa.OpAMD64VPERMPDMasked512load, + ssa.OpAMD64VPERMQMasked512, + ssa.OpAMD64VPERMQMasked512load, + ssa.OpAMD64VPSHUFBMasked256, + ssa.OpAMD64VPSHUFBMasked512, + ssa.OpAMD64VPSHUFBMasked128, + ssa.OpAMD64VRCP14PSMasked128, + ssa.OpAMD64VRCP14PSMasked128load, + ssa.OpAMD64VRCP14PSMasked256, + ssa.OpAMD64VRCP14PSMasked256load, + ssa.OpAMD64VRCP14PSMasked512, + ssa.OpAMD64VRCP14PSMasked512load, + ssa.OpAMD64VRCP14PDMasked128, + ssa.OpAMD64VRCP14PDMasked128load, + ssa.OpAMD64VRCP14PDMasked256, + ssa.OpAMD64VRCP14PDMasked256load, + ssa.OpAMD64VRCP14PDMasked512, + ssa.OpAMD64VRCP14PDMasked512load, + ssa.OpAMD64VRSQRT14PSMasked128, + ssa.OpAMD64VRSQRT14PSMasked128load, + ssa.OpAMD64VRSQRT14PSMasked256, + ssa.OpAMD64VRSQRT14PSMasked256load, + ssa.OpAMD64VRSQRT14PSMasked512, + ssa.OpAMD64VRSQRT14PSMasked512load, + ssa.OpAMD64VRSQRT14PDMasked128, + ssa.OpAMD64VRSQRT14PDMasked128load, + ssa.OpAMD64VRSQRT14PDMasked256, + ssa.OpAMD64VRSQRT14PDMasked256load, + ssa.OpAMD64VRSQRT14PDMasked512, + ssa.OpAMD64VRSQRT14PDMasked512load, + ssa.OpAMD64VPROLDMasked128, + ssa.OpAMD64VPROLDMasked128load, + ssa.OpAMD64VPROLDMasked256, + ssa.OpAMD64VPROLDMasked256load, + ssa.OpAMD64VPROLDMasked512, + ssa.OpAMD64VPROLDMasked512load, + ssa.OpAMD64VPROLQMasked128, + ssa.OpAMD64VPROLQMasked128load, + ssa.OpAMD64VPROLQMasked256, + ssa.OpAMD64VPROLQMasked256load, + ssa.OpAMD64VPROLQMasked512, + ssa.OpAMD64VPROLQMasked512load, + ssa.OpAMD64VPRORDMasked128, + ssa.OpAMD64VPRORDMasked128load, + ssa.OpAMD64VPRORDMasked256, + ssa.OpAMD64VPRORDMasked256load, + ssa.OpAMD64VPRORDMasked512, + ssa.OpAMD64VPRORDMasked512load, + ssa.OpAMD64VPRORQMasked128, + ssa.OpAMD64VPRORQMasked128load, + ssa.OpAMD64VPRORQMasked256, + ssa.OpAMD64VPRORQMasked256load, + ssa.OpAMD64VPRORQMasked512, + ssa.OpAMD64VPRORQMasked512load, + ssa.OpAMD64VPROLVDMasked128, + ssa.OpAMD64VPROLVDMasked128load, + ssa.OpAMD64VPROLVDMasked256, + ssa.OpAMD64VPROLVDMasked256load, + ssa.OpAMD64VPROLVDMasked512, + ssa.OpAMD64VPROLVDMasked512load, + ssa.OpAMD64VPROLVQMasked128, + ssa.OpAMD64VPROLVQMasked128load, + ssa.OpAMD64VPROLVQMasked256, + ssa.OpAMD64VPROLVQMasked256load, + ssa.OpAMD64VPROLVQMasked512, + ssa.OpAMD64VPROLVQMasked512load, + ssa.OpAMD64VPRORVDMasked128, + ssa.OpAMD64VPRORVDMasked128load, + ssa.OpAMD64VPRORVDMasked256, + ssa.OpAMD64VPRORVDMasked256load, + ssa.OpAMD64VPRORVDMasked512, + ssa.OpAMD64VPRORVDMasked512load, + ssa.OpAMD64VPRORVQMasked128, + ssa.OpAMD64VPRORVQMasked128load, + ssa.OpAMD64VPRORVQMasked256, + ssa.OpAMD64VPRORVQMasked256load, + ssa.OpAMD64VPRORVQMasked512, + ssa.OpAMD64VPRORVQMasked512load, + ssa.OpAMD64VPMOVSWBMasked128_128, + ssa.OpAMD64VPMOVSWBMasked128_256, + ssa.OpAMD64VPMOVSWBMasked256, + ssa.OpAMD64VPMOVSDBMasked128_128, + ssa.OpAMD64VPMOVSDBMasked128_256, + ssa.OpAMD64VPMOVSDBMasked128_512, + ssa.OpAMD64VPMOVSQBMasked128_128, + ssa.OpAMD64VPMOVSQBMasked128_256, + ssa.OpAMD64VPMOVSQBMasked128_512, + ssa.OpAMD64VPACKSSDWMasked256, + ssa.OpAMD64VPACKSSDWMasked256load, + ssa.OpAMD64VPACKSSDWMasked512, + ssa.OpAMD64VPACKSSDWMasked512load, + ssa.OpAMD64VPACKSSDWMasked128, + ssa.OpAMD64VPACKSSDWMasked128load, + ssa.OpAMD64VPMOVSDWMasked128_128, + ssa.OpAMD64VPMOVSDWMasked128_256, + ssa.OpAMD64VPMOVSDWMasked256, + ssa.OpAMD64VPMOVSQWMasked128_128, + ssa.OpAMD64VPMOVSQWMasked128_256, + ssa.OpAMD64VPMOVSQWMasked128_512, + ssa.OpAMD64VPMOVSQDMasked128_128, + ssa.OpAMD64VPMOVSQDMasked128_256, + ssa.OpAMD64VPMOVSQDMasked256, + ssa.OpAMD64VPMOVUSWBMasked128_128, + ssa.OpAMD64VPMOVUSWBMasked128_256, + ssa.OpAMD64VPMOVUSWBMasked256, + ssa.OpAMD64VPMOVUSDBMasked128_128, + ssa.OpAMD64VPMOVUSDBMasked128_256, + ssa.OpAMD64VPMOVUSDBMasked128_512, + ssa.OpAMD64VPMOVUSQBMasked128_128, + ssa.OpAMD64VPMOVUSQBMasked128_256, + ssa.OpAMD64VPMOVUSQBMasked128_512, + ssa.OpAMD64VPACKUSDWMasked256, + ssa.OpAMD64VPACKUSDWMasked256load, + ssa.OpAMD64VPACKUSDWMasked512, + ssa.OpAMD64VPACKUSDWMasked512load, + ssa.OpAMD64VPACKUSDWMasked128, + ssa.OpAMD64VPACKUSDWMasked128load, + ssa.OpAMD64VPMOVUSDWMasked128_128, + ssa.OpAMD64VPMOVUSDWMasked128_256, + ssa.OpAMD64VPMOVUSDWMasked256, + ssa.OpAMD64VPMOVUSQWMasked128_128, + ssa.OpAMD64VPMOVUSQWMasked128_256, + ssa.OpAMD64VPMOVUSQWMasked128_512, + ssa.OpAMD64VPMOVUSQDMasked128_128, + ssa.OpAMD64VPMOVUSQDMasked128_256, + ssa.OpAMD64VPMOVUSQDMasked256, + ssa.OpAMD64VSCALEFPSMasked128, + ssa.OpAMD64VSCALEFPSMasked128load, + ssa.OpAMD64VSCALEFPSMasked256, + ssa.OpAMD64VSCALEFPSMasked256load, + ssa.OpAMD64VSCALEFPSMasked512, + ssa.OpAMD64VSCALEFPSMasked512load, + ssa.OpAMD64VSCALEFPDMasked128, + ssa.OpAMD64VSCALEFPDMasked128load, + ssa.OpAMD64VSCALEFPDMasked256, + ssa.OpAMD64VSCALEFPDMasked256load, + ssa.OpAMD64VSCALEFPDMasked512, + ssa.OpAMD64VSCALEFPDMasked512load, + ssa.OpAMD64VPSHLDWMasked128, + ssa.OpAMD64VPSHLDWMasked256, + ssa.OpAMD64VPSHLDWMasked512, + ssa.OpAMD64VPSHLDDMasked128, + ssa.OpAMD64VPSHLDDMasked128load, + ssa.OpAMD64VPSHLDDMasked256, + ssa.OpAMD64VPSHLDDMasked256load, + ssa.OpAMD64VPSHLDDMasked512, + ssa.OpAMD64VPSHLDDMasked512load, + ssa.OpAMD64VPSHLDQMasked128, + ssa.OpAMD64VPSHLDQMasked128load, + ssa.OpAMD64VPSHLDQMasked256, + ssa.OpAMD64VPSHLDQMasked256load, + ssa.OpAMD64VPSHLDQMasked512, + ssa.OpAMD64VPSHLDQMasked512load, + ssa.OpAMD64VPSLLWMasked128, + ssa.OpAMD64VPSLLWMasked256, + ssa.OpAMD64VPSLLWMasked512, + ssa.OpAMD64VPSLLDMasked128, + ssa.OpAMD64VPSLLDMasked256, + ssa.OpAMD64VPSLLDMasked512, + ssa.OpAMD64VPSLLQMasked128, + ssa.OpAMD64VPSLLQMasked256, + ssa.OpAMD64VPSLLQMasked512, + ssa.OpAMD64VPSHRDWMasked128, + ssa.OpAMD64VPSHRDWMasked256, + ssa.OpAMD64VPSHRDWMasked512, + ssa.OpAMD64VPSHRDDMasked128, + ssa.OpAMD64VPSHRDDMasked128load, + ssa.OpAMD64VPSHRDDMasked256, + ssa.OpAMD64VPSHRDDMasked256load, + ssa.OpAMD64VPSHRDDMasked512, + ssa.OpAMD64VPSHRDDMasked512load, + ssa.OpAMD64VPSHRDQMasked128, + ssa.OpAMD64VPSHRDQMasked128load, + ssa.OpAMD64VPSHRDQMasked256, + ssa.OpAMD64VPSHRDQMasked256load, + ssa.OpAMD64VPSHRDQMasked512, + ssa.OpAMD64VPSHRDQMasked512load, + ssa.OpAMD64VPSRAWMasked128, + ssa.OpAMD64VPSRAWMasked256, + ssa.OpAMD64VPSRAWMasked512, + ssa.OpAMD64VPSRADMasked128, + ssa.OpAMD64VPSRADMasked256, + ssa.OpAMD64VPSRADMasked512, + ssa.OpAMD64VPSRAQMasked128, + ssa.OpAMD64VPSRAQMasked256, + ssa.OpAMD64VPSRAQMasked512, + ssa.OpAMD64VPSRLWMasked128, + ssa.OpAMD64VPSRLWMasked256, + ssa.OpAMD64VPSRLWMasked512, + ssa.OpAMD64VPSRLDMasked128, + ssa.OpAMD64VPSRLDMasked256, + ssa.OpAMD64VPSRLDMasked512, + ssa.OpAMD64VPSRLQMasked128, + ssa.OpAMD64VPSRLQMasked256, + ssa.OpAMD64VPSRLQMasked512, + ssa.OpAMD64VPSHLDVWMasked128, + ssa.OpAMD64VPSHLDVWMasked256, + ssa.OpAMD64VPSHLDVWMasked512, + ssa.OpAMD64VPSHLDVDMasked128, + ssa.OpAMD64VPSHLDVDMasked128load, + ssa.OpAMD64VPSHLDVDMasked256, + ssa.OpAMD64VPSHLDVDMasked256load, + ssa.OpAMD64VPSHLDVDMasked512, + ssa.OpAMD64VPSHLDVDMasked512load, + ssa.OpAMD64VPSHLDVQMasked128, + ssa.OpAMD64VPSHLDVQMasked128load, + ssa.OpAMD64VPSHLDVQMasked256, + ssa.OpAMD64VPSHLDVQMasked256load, + ssa.OpAMD64VPSHLDVQMasked512, + ssa.OpAMD64VPSHLDVQMasked512load, + ssa.OpAMD64VPSLLVWMasked128, + ssa.OpAMD64VPSLLVWMasked256, + ssa.OpAMD64VPSLLVWMasked512, + ssa.OpAMD64VPSLLVDMasked128, + ssa.OpAMD64VPSLLVDMasked128load, + ssa.OpAMD64VPSLLVDMasked256, + ssa.OpAMD64VPSLLVDMasked256load, + ssa.OpAMD64VPSLLVDMasked512, + ssa.OpAMD64VPSLLVDMasked512load, + ssa.OpAMD64VPSLLVQMasked128, + ssa.OpAMD64VPSLLVQMasked128load, + ssa.OpAMD64VPSLLVQMasked256, + ssa.OpAMD64VPSLLVQMasked256load, + ssa.OpAMD64VPSLLVQMasked512, + ssa.OpAMD64VPSLLVQMasked512load, + ssa.OpAMD64VPSHRDVWMasked128, + ssa.OpAMD64VPSHRDVWMasked256, + ssa.OpAMD64VPSHRDVWMasked512, + ssa.OpAMD64VPSHRDVDMasked128, + ssa.OpAMD64VPSHRDVDMasked128load, + ssa.OpAMD64VPSHRDVDMasked256, + ssa.OpAMD64VPSHRDVDMasked256load, + ssa.OpAMD64VPSHRDVDMasked512, + ssa.OpAMD64VPSHRDVDMasked512load, + ssa.OpAMD64VPSHRDVQMasked128, + ssa.OpAMD64VPSHRDVQMasked128load, + ssa.OpAMD64VPSHRDVQMasked256, + ssa.OpAMD64VPSHRDVQMasked256load, + ssa.OpAMD64VPSHRDVQMasked512, + ssa.OpAMD64VPSHRDVQMasked512load, + ssa.OpAMD64VPSRAVWMasked128, + ssa.OpAMD64VPSRAVWMasked256, + ssa.OpAMD64VPSRAVWMasked512, + ssa.OpAMD64VPSRAVDMasked128, + ssa.OpAMD64VPSRAVDMasked128load, + ssa.OpAMD64VPSRAVDMasked256, + ssa.OpAMD64VPSRAVDMasked256load, + ssa.OpAMD64VPSRAVDMasked512, + ssa.OpAMD64VPSRAVDMasked512load, + ssa.OpAMD64VPSRAVQMasked128, + ssa.OpAMD64VPSRAVQMasked128load, + ssa.OpAMD64VPSRAVQMasked256, + ssa.OpAMD64VPSRAVQMasked256load, + ssa.OpAMD64VPSRAVQMasked512, + ssa.OpAMD64VPSRAVQMasked512load, + ssa.OpAMD64VPSRLVWMasked128, + ssa.OpAMD64VPSRLVWMasked256, + ssa.OpAMD64VPSRLVWMasked512, + ssa.OpAMD64VPSRLVDMasked128, + ssa.OpAMD64VPSRLVDMasked128load, + ssa.OpAMD64VPSRLVDMasked256, + ssa.OpAMD64VPSRLVDMasked256load, + ssa.OpAMD64VPSRLVDMasked512, + ssa.OpAMD64VPSRLVDMasked512load, + ssa.OpAMD64VPSRLVQMasked128, + ssa.OpAMD64VPSRLVQMasked128load, + ssa.OpAMD64VPSRLVQMasked256, + ssa.OpAMD64VPSRLVQMasked256load, + ssa.OpAMD64VPSRLVQMasked512, + ssa.OpAMD64VPSRLVQMasked512load, + ssa.OpAMD64VSQRTPSMasked128, + ssa.OpAMD64VSQRTPSMasked128load, + ssa.OpAMD64VSQRTPSMasked256, + ssa.OpAMD64VSQRTPSMasked256load, + ssa.OpAMD64VSQRTPSMasked512, + ssa.OpAMD64VSQRTPSMasked512load, + ssa.OpAMD64VSQRTPDMasked128, + ssa.OpAMD64VSQRTPDMasked128load, + ssa.OpAMD64VSQRTPDMasked256, + ssa.OpAMD64VSQRTPDMasked256load, + ssa.OpAMD64VSQRTPDMasked512, + ssa.OpAMD64VSQRTPDMasked512load, + ssa.OpAMD64VSUBPSMasked128, + ssa.OpAMD64VSUBPSMasked128load, + ssa.OpAMD64VSUBPSMasked256, + ssa.OpAMD64VSUBPSMasked256load, + ssa.OpAMD64VSUBPSMasked512, + ssa.OpAMD64VSUBPSMasked512load, + ssa.OpAMD64VSUBPDMasked128, + ssa.OpAMD64VSUBPDMasked128load, + ssa.OpAMD64VSUBPDMasked256, + ssa.OpAMD64VSUBPDMasked256load, + ssa.OpAMD64VSUBPDMasked512, + ssa.OpAMD64VSUBPDMasked512load, + ssa.OpAMD64VPSUBBMasked128, + ssa.OpAMD64VPSUBBMasked256, + ssa.OpAMD64VPSUBBMasked512, + ssa.OpAMD64VPSUBWMasked128, + ssa.OpAMD64VPSUBWMasked256, + ssa.OpAMD64VPSUBWMasked512, + ssa.OpAMD64VPSUBDMasked128, + ssa.OpAMD64VPSUBDMasked128load, + ssa.OpAMD64VPSUBDMasked256, + ssa.OpAMD64VPSUBDMasked256load, + ssa.OpAMD64VPSUBDMasked512, + ssa.OpAMD64VPSUBDMasked512load, + ssa.OpAMD64VPSUBQMasked128, + ssa.OpAMD64VPSUBQMasked128load, + ssa.OpAMD64VPSUBQMasked256, + ssa.OpAMD64VPSUBQMasked256load, + ssa.OpAMD64VPSUBQMasked512, + ssa.OpAMD64VPSUBQMasked512load, + ssa.OpAMD64VPSUBSBMasked128, + ssa.OpAMD64VPSUBSBMasked256, + ssa.OpAMD64VPSUBSBMasked512, + ssa.OpAMD64VPSUBSWMasked128, + ssa.OpAMD64VPSUBSWMasked256, + ssa.OpAMD64VPSUBSWMasked512, + ssa.OpAMD64VPSUBUSBMasked128, + ssa.OpAMD64VPSUBUSBMasked256, + ssa.OpAMD64VPSUBUSBMasked512, + ssa.OpAMD64VPSUBUSWMasked128, + ssa.OpAMD64VPSUBUSWMasked256, + ssa.OpAMD64VPSUBUSWMasked512, + ssa.OpAMD64VPMOVWBMasked128_128, + ssa.OpAMD64VPMOVWBMasked128_256, + ssa.OpAMD64VPMOVWBMasked256, + ssa.OpAMD64VPMOVDBMasked128_128, + ssa.OpAMD64VPMOVDBMasked128_256, + ssa.OpAMD64VPMOVDBMasked128_512, + ssa.OpAMD64VPMOVQBMasked128_128, + ssa.OpAMD64VPMOVQBMasked128_256, + ssa.OpAMD64VPMOVQBMasked128_512, + ssa.OpAMD64VPMOVDWMasked128_128, + ssa.OpAMD64VPMOVDWMasked128_256, + ssa.OpAMD64VPMOVDWMasked256, + ssa.OpAMD64VPMOVQWMasked128_128, + ssa.OpAMD64VPMOVQWMasked128_256, + ssa.OpAMD64VPMOVQWMasked128_512, + ssa.OpAMD64VPMOVQDMasked128_128, + ssa.OpAMD64VPMOVQDMasked128_256, + ssa.OpAMD64VPMOVQDMasked256, + ssa.OpAMD64VPXORDMasked128, + ssa.OpAMD64VPXORDMasked128load, + ssa.OpAMD64VPXORDMasked256, + ssa.OpAMD64VPXORDMasked256load, + ssa.OpAMD64VPXORDMasked512, + ssa.OpAMD64VPXORDMasked512load, + ssa.OpAMD64VPXORQMasked128, + ssa.OpAMD64VPXORQMasked128load, + ssa.OpAMD64VPXORQMasked256, + ssa.OpAMD64VPXORQMasked256load, + ssa.OpAMD64VPXORQMasked512, + ssa.OpAMD64VPXORQMasked512load, + ssa.OpAMD64VMOVDQU8Masked128, + ssa.OpAMD64VMOVDQU8Masked256, + ssa.OpAMD64VMOVDQU8Masked512, + ssa.OpAMD64VMOVDQU16Masked128, + ssa.OpAMD64VMOVDQU16Masked256, + ssa.OpAMD64VMOVDQU16Masked512, + ssa.OpAMD64VMOVDQU32Masked128, + ssa.OpAMD64VMOVDQU32Masked256, + ssa.OpAMD64VMOVDQU32Masked512, + ssa.OpAMD64VMOVDQU64Masked128, + ssa.OpAMD64VMOVDQU64Masked256, + ssa.OpAMD64VMOVDQU64Masked512, + ssa.OpAMD64VPSHUFDMasked256, + ssa.OpAMD64VPSHUFDMasked256load, + ssa.OpAMD64VPSHUFDMasked512, + ssa.OpAMD64VPSHUFDMasked512load, + ssa.OpAMD64VPSHUFHWMasked256, + ssa.OpAMD64VPSHUFHWMasked512, + ssa.OpAMD64VPSHUFHWMasked128, + ssa.OpAMD64VPSHUFLWMasked256, + ssa.OpAMD64VPSHUFLWMasked512, + ssa.OpAMD64VPSHUFLWMasked128, + ssa.OpAMD64VPSHUFDMasked128, + ssa.OpAMD64VPSHUFDMasked128load, + ssa.OpAMD64VPSLLWMasked128const, + ssa.OpAMD64VPSLLWMasked256const, + ssa.OpAMD64VPSLLWMasked512const, + ssa.OpAMD64VPSLLDMasked128const, + ssa.OpAMD64VPSLLDMasked128constload, + ssa.OpAMD64VPSLLDMasked256const, + ssa.OpAMD64VPSLLDMasked256constload, + ssa.OpAMD64VPSLLDMasked512const, + ssa.OpAMD64VPSLLDMasked512constload, + ssa.OpAMD64VPSLLQMasked128const, + ssa.OpAMD64VPSLLQMasked128constload, + ssa.OpAMD64VPSLLQMasked256const, + ssa.OpAMD64VPSLLQMasked256constload, + ssa.OpAMD64VPSLLQMasked512const, + ssa.OpAMD64VPSLLQMasked512constload, + ssa.OpAMD64VPSRLWMasked128const, + ssa.OpAMD64VPSRLWMasked256const, + ssa.OpAMD64VPSRLWMasked512const, + ssa.OpAMD64VPSRLDMasked128const, + ssa.OpAMD64VPSRLDMasked128constload, + ssa.OpAMD64VPSRLDMasked256const, + ssa.OpAMD64VPSRLDMasked256constload, + ssa.OpAMD64VPSRLDMasked512const, + ssa.OpAMD64VPSRLDMasked512constload, + ssa.OpAMD64VPSRLQMasked128const, + ssa.OpAMD64VPSRLQMasked128constload, + ssa.OpAMD64VPSRLQMasked256const, + ssa.OpAMD64VPSRLQMasked256constload, + ssa.OpAMD64VPSRLQMasked512const, + ssa.OpAMD64VPSRLQMasked512constload, + ssa.OpAMD64VPSRAWMasked128const, + ssa.OpAMD64VPSRAWMasked256const, + ssa.OpAMD64VPSRAWMasked512const, + ssa.OpAMD64VPSRADMasked128const, + ssa.OpAMD64VPSRADMasked128constload, + ssa.OpAMD64VPSRADMasked256const, + ssa.OpAMD64VPSRADMasked256constload, + ssa.OpAMD64VPSRADMasked512const, + ssa.OpAMD64VPSRADMasked512constload, + ssa.OpAMD64VPSRAQMasked128const, + ssa.OpAMD64VPSRAQMasked128constload, + ssa.OpAMD64VPSRAQMasked256const, + ssa.OpAMD64VPSRAQMasked256constload, + ssa.OpAMD64VPSRAQMasked512const, + ssa.OpAMD64VPSRAQMasked512constload: + x86.ParseSuffix(p, "Z") + } + + return true +} diff --git a/go/src/cmd/compile/internal/amd64/ssa.go b/go/src/cmd/compile/internal/amd64/ssa.go new file mode 100644 index 0000000000000000000000000000000000000000..e9a566d759dc0cdfcef750e6bb9bd9236662b235 --- /dev/null +++ b/go/src/cmd/compile/internal/amd64/ssa.go @@ -0,0 +1,2568 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package amd64 + +import ( + "fmt" + "math" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/objw" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/x86" + "internal/abi" +) + +// ssaMarkMoves marks any MOVXconst ops that need to avoid clobbering flags. +func ssaMarkMoves(s *ssagen.State, b *ssa.Block) { + flive := b.FlagsLiveAtEnd + for _, c := range b.ControlValues() { + flive = c.Type.IsFlags() || flive + } + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + if flive && (v.Op == ssa.OpAMD64MOVLconst || v.Op == ssa.OpAMD64MOVQconst) { + // The "mark" is any non-nil Aux value. + v.Aux = ssa.AuxMark + } + if v.Type.IsFlags() { + flive = false + } + for _, a := range v.Args { + if a.Type.IsFlags() { + flive = true + } + } + } +} + +func isFPReg(r int16) bool { + return x86.REG_X0 <= r && r <= x86.REG_Z31 +} + +func isKReg(r int16) bool { + return x86.REG_K0 <= r && r <= x86.REG_K7 +} + +func isLowFPReg(r int16) bool { + return x86.REG_X0 <= r && r <= x86.REG_X15 +} + +// loadByRegWidth returns the load instruction of the given register of a given width. +func loadByRegWidth(r int16, width int64) obj.As { + // Avoid partial register write for GPR + if !isFPReg(r) && !isKReg(r) { + switch width { + case 1: + return x86.AMOVBLZX + case 2: + return x86.AMOVWLZX + } + } + // Otherwise, there's no difference between load and store opcodes. + return storeByRegWidth(r, width) +} + +// storeByRegWidth returns the store instruction of the given register of a given width. +// It's also used for loading const to a reg. +func storeByRegWidth(r int16, width int64) obj.As { + if isFPReg(r) { + switch width { + case 4: + return x86.AMOVSS + case 8: + return x86.AMOVSD + case 16: + // int128s are in SSE registers + if isLowFPReg(r) { + return x86.AMOVUPS + } else { + return x86.AVMOVDQU + } + case 32: + return x86.AVMOVDQU + case 64: + return x86.AVMOVDQU64 + } + } + if isKReg(r) { + return x86.AKMOVQ + } + // gp + switch width { + case 1: + return x86.AMOVB + case 2: + return x86.AMOVW + case 4: + return x86.AMOVL + case 8: + return x86.AMOVQ + } + panic(fmt.Sprintf("bad store reg=%v, width=%d", r, width)) +} + +// moveByRegsWidth returns the reg->reg move instruction of the given dest/src registers of a given width. +func moveByRegsWidth(dest, src int16, width int64) obj.As { + // fp -> fp + if isFPReg(dest) && isFPReg(src) { + // Moving the whole sse2 register is faster + // than moving just the correct low portion of it. + // There is no xmm->xmm move with 1 byte opcode, + // so use movups, which has 2 byte opcode. + if isLowFPReg(dest) && isLowFPReg(src) && width <= 16 { + return x86.AMOVUPS + } + if width <= 32 { + return x86.AVMOVDQU + } + return x86.AVMOVDQU64 + } + // k -> gp, gp -> k, k -> k + if isKReg(dest) || isKReg(src) { + if isFPReg(dest) || isFPReg(src) { + panic(fmt.Sprintf("bad move, src=%v, dest=%v, width=%d", src, dest, width)) + } + return x86.AKMOVQ + } + // gp -> fp, fp -> gp, gp -> gp + switch width { + case 1: + // Avoids partial register write + return x86.AMOVL + case 2: + return x86.AMOVL + case 4: + return x86.AMOVL + case 8: + return x86.AMOVQ + case 16: + if isLowFPReg(dest) && isLowFPReg(src) { + // int128s are in SSE registers + return x86.AMOVUPS + } else { + return x86.AVMOVDQU + } + case 32: + return x86.AVMOVDQU + case 64: + return x86.AVMOVDQU64 + } + panic(fmt.Sprintf("bad move, src=%v, dest=%v, width=%d", src, dest, width)) +} + +// opregreg emits instructions for +// +// dest := dest(To) op src(From) +// +// and also returns the created obj.Prog so it +// may be further adjusted (offset, scale, etc). +func opregreg(s *ssagen.State, op obj.As, dest, src int16) *obj.Prog { + p := s.Prog(op) + p.From.Type = obj.TYPE_REG + p.To.Type = obj.TYPE_REG + p.To.Reg = dest + p.From.Reg = src + return p +} + +// memIdx fills out a as an indexed memory reference for v. +// It assumes that the base register and the index register +// are v.Args[0].Reg() and v.Args[1].Reg(), respectively. +// The caller must still use gc.AddAux/gc.AddAux2 to handle v.Aux as necessary. +func memIdx(a *obj.Addr, v *ssa.Value) { + r, i := v.Args[0].Reg(), v.Args[1].Reg() + a.Type = obj.TYPE_MEM + a.Scale = v.Op.Scale() + if a.Scale == 1 && i == x86.REG_SP { + r, i = i, r + } + a.Reg = r + a.Index = i +} + +func getgFromTLS(s *ssagen.State, r int16) { + // See the comments in cmd/internal/obj/x86/obj6.go + // near CanUse1InsnTLS for a detailed explanation of these instructions. + if x86.CanUse1InsnTLS(base.Ctxt) { + // MOVQ (TLS), r + p := s.Prog(x86.AMOVQ) + p.From.Type = obj.TYPE_MEM + p.From.Reg = x86.REG_TLS + p.To.Type = obj.TYPE_REG + p.To.Reg = r + } else { + // MOVQ TLS, r + // MOVQ (r)(TLS*1), r + p := s.Prog(x86.AMOVQ) + p.From.Type = obj.TYPE_REG + p.From.Reg = x86.REG_TLS + p.To.Type = obj.TYPE_REG + p.To.Reg = r + q := s.Prog(x86.AMOVQ) + q.From.Type = obj.TYPE_MEM + q.From.Reg = r + q.From.Index = x86.REG_TLS + q.From.Scale = 1 + q.To.Type = obj.TYPE_REG + q.To.Reg = r + } +} + +func ssaGenValue(s *ssagen.State, v *ssa.Value) { + switch v.Op { + case ssa.OpAMD64VFMADD231SD, ssa.OpAMD64VFMADD231SS: + p := s.Prog(v.Op.Asm()) + p.From = obj.Addr{Type: obj.TYPE_REG, Reg: v.Args[2].Reg()} + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: v.Reg()} + p.AddRestSourceReg(v.Args[1].Reg()) + case ssa.OpAMD64ADDQ, ssa.OpAMD64ADDL: + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + switch { + case r == r1: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case r == r2: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + default: + var asm obj.As + if v.Op == ssa.OpAMD64ADDQ { + asm = x86.ALEAQ + } else { + asm = x86.ALEAL + } + p := s.Prog(asm) + p.From.Type = obj.TYPE_MEM + p.From.Reg = r1 + p.From.Scale = 1 + p.From.Index = r2 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + } + // 2-address opcode arithmetic + case ssa.OpAMD64SUBQ, ssa.OpAMD64SUBL, + ssa.OpAMD64MULQ, ssa.OpAMD64MULL, + ssa.OpAMD64ANDQ, ssa.OpAMD64ANDL, + ssa.OpAMD64ORQ, ssa.OpAMD64ORL, + ssa.OpAMD64XORQ, ssa.OpAMD64XORL, + ssa.OpAMD64SHLQ, ssa.OpAMD64SHLL, + ssa.OpAMD64SHRQ, ssa.OpAMD64SHRL, ssa.OpAMD64SHRW, ssa.OpAMD64SHRB, + ssa.OpAMD64SARQ, ssa.OpAMD64SARL, ssa.OpAMD64SARW, ssa.OpAMD64SARB, + ssa.OpAMD64ROLQ, ssa.OpAMD64ROLL, ssa.OpAMD64ROLW, ssa.OpAMD64ROLB, + ssa.OpAMD64RORQ, ssa.OpAMD64RORL, ssa.OpAMD64RORW, ssa.OpAMD64RORB, + ssa.OpAMD64ADDSS, ssa.OpAMD64ADDSD, ssa.OpAMD64SUBSS, ssa.OpAMD64SUBSD, + ssa.OpAMD64MULSS, ssa.OpAMD64MULSD, ssa.OpAMD64DIVSS, ssa.OpAMD64DIVSD, + ssa.OpAMD64MINSS, ssa.OpAMD64MINSD, + ssa.OpAMD64POR, ssa.OpAMD64PXOR, + ssa.OpAMD64BTSL, ssa.OpAMD64BTSQ, + ssa.OpAMD64BTCL, ssa.OpAMD64BTCQ, + ssa.OpAMD64BTRL, ssa.OpAMD64BTRQ, + ssa.OpAMD64PCMPEQB, ssa.OpAMD64PSIGNB, + ssa.OpAMD64PUNPCKLBW: + opregreg(s, v.Op.Asm(), v.Reg(), v.Args[1].Reg()) + + case ssa.OpAMD64PSHUFLW: + p := s.Prog(v.Op.Asm()) + imm := v.AuxInt + if imm < 0 || imm > 255 { + v.Fatalf("Invalid source selection immediate") + } + p.From.Offset = imm + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(v.Args[0].Reg()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64PSHUFBbroadcast: + // PSHUFB with a control mask of zero copies byte 0 to all + // bytes in the register. + // + // X15 is always zero with ABIInternal. + if s.ABI != obj.ABIInternal { + // zero X15 manually + opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15) + } + + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + p.From.Reg = x86.REG_X15 + + case ssa.OpAMD64SHRDQ, ssa.OpAMD64SHLDQ: + p := s.Prog(v.Op.Asm()) + lo, hi, bits := v.Args[0].Reg(), v.Args[1].Reg(), v.Args[2].Reg() + p.From.Type = obj.TYPE_REG + p.From.Reg = bits + p.To.Type = obj.TYPE_REG + p.To.Reg = lo + p.AddRestSourceReg(hi) + + case ssa.OpAMD64BLSIQ, ssa.OpAMD64BLSIL, + ssa.OpAMD64BLSMSKQ, ssa.OpAMD64BLSMSKL, + ssa.OpAMD64BLSRQ, ssa.OpAMD64BLSRL: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + switch v.Op { + case ssa.OpAMD64BLSRQ, ssa.OpAMD64BLSRL: + p.To.Reg = v.Reg0() + default: + p.To.Reg = v.Reg() + } + + case ssa.OpAMD64ANDNQ, ssa.OpAMD64ANDNL: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + p.AddRestSourceReg(v.Args[1].Reg()) + + case ssa.OpAMD64SARXL, ssa.OpAMD64SARXQ, + ssa.OpAMD64SHLXL, ssa.OpAMD64SHLXQ, + ssa.OpAMD64SHRXL, ssa.OpAMD64SHRXQ: + p := opregreg(s, v.Op.Asm(), v.Reg(), v.Args[1].Reg()) + p.AddRestSourceReg(v.Args[0].Reg()) + + case ssa.OpAMD64SHLXLload, ssa.OpAMD64SHLXQload, + ssa.OpAMD64SHRXLload, ssa.OpAMD64SHRXQload, + ssa.OpAMD64SARXLload, ssa.OpAMD64SARXQload: + p := opregreg(s, v.Op.Asm(), v.Reg(), v.Args[1].Reg()) + m := obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[0].Reg()} + ssagen.AddAux(&m, v) + p.AddRestSource(m) + + case ssa.OpAMD64SHLXLloadidx1, ssa.OpAMD64SHLXLloadidx4, ssa.OpAMD64SHLXLloadidx8, + ssa.OpAMD64SHRXLloadidx1, ssa.OpAMD64SHRXLloadidx4, ssa.OpAMD64SHRXLloadidx8, + ssa.OpAMD64SARXLloadidx1, ssa.OpAMD64SARXLloadidx4, ssa.OpAMD64SARXLloadidx8, + ssa.OpAMD64SHLXQloadidx1, ssa.OpAMD64SHLXQloadidx8, + ssa.OpAMD64SHRXQloadidx1, ssa.OpAMD64SHRXQloadidx8, + ssa.OpAMD64SARXQloadidx1, ssa.OpAMD64SARXQloadidx8: + p := opregreg(s, v.Op.Asm(), v.Reg(), v.Args[2].Reg()) + m := obj.Addr{Type: obj.TYPE_MEM} + memIdx(&m, v) + ssagen.AddAux(&m, v) + p.AddRestSource(m) + + case ssa.OpAMD64DIVQU, ssa.OpAMD64DIVLU, ssa.OpAMD64DIVWU: + // Arg[0] (the dividend) is in AX. + // Arg[1] (the divisor) can be in any other register. + // Result[0] (the quotient) is in AX. + // Result[1] (the remainder) is in DX. + r := v.Args[1].Reg() + + // Zero extend dividend. + opregreg(s, x86.AXORL, x86.REG_DX, x86.REG_DX) + + // Issue divide. + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r + + case ssa.OpAMD64DIVQ, ssa.OpAMD64DIVL, ssa.OpAMD64DIVW: + // Arg[0] (the dividend) is in AX. + // Arg[1] (the divisor) can be in any other register. + // Result[0] (the quotient) is in AX. + // Result[1] (the remainder) is in DX. + r := v.Args[1].Reg() + + var opCMP, opNEG, opSXD obj.As + switch v.Op { + case ssa.OpAMD64DIVQ: + opCMP, opNEG, opSXD = x86.ACMPQ, x86.ANEGQ, x86.ACQO + case ssa.OpAMD64DIVL: + opCMP, opNEG, opSXD = x86.ACMPL, x86.ANEGL, x86.ACDQ + case ssa.OpAMD64DIVW: + opCMP, opNEG, opSXD = x86.ACMPW, x86.ANEGW, x86.ACWD + } + + // CPU faults upon signed overflow, which occurs when the most + // negative int is divided by -1. Handle divide by -1 as a special case. + var j1, j2 *obj.Prog + if ssa.DivisionNeedsFixUp(v) { + c := s.Prog(opCMP) + c.From.Type = obj.TYPE_REG + c.From.Reg = r + c.To.Type = obj.TYPE_CONST + c.To.Offset = -1 + + // Divisor is not -1, proceed with normal division. + j1 = s.Prog(x86.AJNE) + j1.To.Type = obj.TYPE_BRANCH + + // Divisor is -1, manually compute quotient and remainder via fixup code. + // n / -1 = -n + n1 := s.Prog(opNEG) + n1.To.Type = obj.TYPE_REG + n1.To.Reg = x86.REG_AX + + // n % -1 == 0 + opregreg(s, x86.AXORL, x86.REG_DX, x86.REG_DX) + + // TODO(khr): issue only the -1 fixup code we need. + // For instance, if only the quotient is used, no point in zeroing the remainder. + + // Skip over normal division. + j2 = s.Prog(obj.AJMP) + j2.To.Type = obj.TYPE_BRANCH + } + + // Sign extend dividend and perform division. + p := s.Prog(opSXD) + if j1 != nil { + j1.To.SetTarget(p) + } + p = s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r + + if j2 != nil { + j2.To.SetTarget(s.Pc()) + } + + case ssa.OpAMD64HMULQ, ssa.OpAMD64HMULL, ssa.OpAMD64HMULQU, ssa.OpAMD64HMULLU: + // the frontend rewrites constant division by 8/16/32 bit integers into + // HMUL by a constant + // SSA rewrites generate the 64 bit versions + + // Arg[0] is already in AX as it's the only register we allow + // and DX is the only output we care about (the high bits) + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + + // IMULB puts the high portion in AH instead of DL, + // so move it to DL for consistency + if v.Type.Size() == 1 { + m := s.Prog(x86.AMOVB) + m.From.Type = obj.TYPE_REG + m.From.Reg = x86.REG_AH + m.To.Type = obj.TYPE_REG + m.To.Reg = x86.REG_DX + } + + case ssa.OpAMD64MULQU, ssa.OpAMD64MULLU: + // Arg[0] is already in AX as it's the only register we allow + // results lo in AX + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + + case ssa.OpAMD64MULQU2: + // Arg[0] is already in AX as it's the only register we allow + // results hi in DX, lo in AX + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + + case ssa.OpAMD64DIVQU2: + // Arg[0], Arg[1] are already in Dx, AX, as they're the only registers we allow + // results q in AX, r in DX + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + + case ssa.OpAMD64AVGQU: + // compute (x+y)/2 unsigned. + // Do a 64-bit add, the overflow goes into the carry. + // Shift right once and pull the carry back into the 63rd bit. + p := s.Prog(x86.AADDQ) + p.From.Type = obj.TYPE_REG + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + p.From.Reg = v.Args[1].Reg() + p = s.Prog(x86.ARCRQ) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 1 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64ADDQcarry, ssa.OpAMD64ADCQ: + r := v.Reg0() + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + switch r { + case r0: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case r1: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + default: + v.Fatalf("output not in same register as an input %s", v.LongString()) + } + + case ssa.OpAMD64SUBQborrow, ssa.OpAMD64SBBQ: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + case ssa.OpAMD64ADDQconstcarry, ssa.OpAMD64ADCQconst, ssa.OpAMD64SUBQconstborrow, ssa.OpAMD64SBBQconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + case ssa.OpAMD64ADDQconst, ssa.OpAMD64ADDLconst: + r := v.Reg() + a := v.Args[0].Reg() + if r == a { + switch v.AuxInt { + case 1: + var asm obj.As + // Software optimization manual recommends add $1,reg. + // But inc/dec is 1 byte smaller. ICC always uses inc + // Clang/GCC choose depending on flags, but prefer add. + // Experiments show that inc/dec is both a little faster + // and make a binary a little smaller. + if v.Op == ssa.OpAMD64ADDQconst { + asm = x86.AINCQ + } else { + asm = x86.AINCL + } + p := s.Prog(asm) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + return + case -1: + var asm obj.As + if v.Op == ssa.OpAMD64ADDQconst { + asm = x86.ADECQ + } else { + asm = x86.ADECL + } + p := s.Prog(asm) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + return + case 0x80: + // 'SUBQ $-0x80, r' is shorter to encode than + // and functionally equivalent to 'ADDQ $0x80, r'. + asm := x86.ASUBL + if v.Op == ssa.OpAMD64ADDQconst { + asm = x86.ASUBQ + } + p := s.Prog(asm) + p.From.Type = obj.TYPE_CONST + p.From.Offset = -0x80 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + return + + } + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = r + return + } + var asm obj.As + if v.Op == ssa.OpAMD64ADDQconst { + asm = x86.ALEAQ + } else { + asm = x86.ALEAL + } + p := s.Prog(asm) + p.From.Type = obj.TYPE_MEM + p.From.Reg = a + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + case ssa.OpAMD64CMOVQEQ, ssa.OpAMD64CMOVLEQ, ssa.OpAMD64CMOVWEQ, + ssa.OpAMD64CMOVQLT, ssa.OpAMD64CMOVLLT, ssa.OpAMD64CMOVWLT, + ssa.OpAMD64CMOVQNE, ssa.OpAMD64CMOVLNE, ssa.OpAMD64CMOVWNE, + ssa.OpAMD64CMOVQGT, ssa.OpAMD64CMOVLGT, ssa.OpAMD64CMOVWGT, + ssa.OpAMD64CMOVQLE, ssa.OpAMD64CMOVLLE, ssa.OpAMD64CMOVWLE, + ssa.OpAMD64CMOVQGE, ssa.OpAMD64CMOVLGE, ssa.OpAMD64CMOVWGE, + ssa.OpAMD64CMOVQHI, ssa.OpAMD64CMOVLHI, ssa.OpAMD64CMOVWHI, + ssa.OpAMD64CMOVQLS, ssa.OpAMD64CMOVLLS, ssa.OpAMD64CMOVWLS, + ssa.OpAMD64CMOVQCC, ssa.OpAMD64CMOVLCC, ssa.OpAMD64CMOVWCC, + ssa.OpAMD64CMOVQCS, ssa.OpAMD64CMOVLCS, ssa.OpAMD64CMOVWCS, + ssa.OpAMD64CMOVQGTF, ssa.OpAMD64CMOVLGTF, ssa.OpAMD64CMOVWGTF, + ssa.OpAMD64CMOVQGEF, ssa.OpAMD64CMOVLGEF, ssa.OpAMD64CMOVWGEF: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64CMOVQNEF, ssa.OpAMD64CMOVLNEF, ssa.OpAMD64CMOVWNEF: + // Flag condition: ^ZERO || PARITY + // Generate: + // CMOV*NE SRC,DST + // CMOV*PS SRC,DST + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + var q *obj.Prog + if v.Op == ssa.OpAMD64CMOVQNEF { + q = s.Prog(x86.ACMOVQPS) + } else if v.Op == ssa.OpAMD64CMOVLNEF { + q = s.Prog(x86.ACMOVLPS) + } else { + q = s.Prog(x86.ACMOVWPS) + } + q.From.Type = obj.TYPE_REG + q.From.Reg = v.Args[1].Reg() + q.To.Type = obj.TYPE_REG + q.To.Reg = v.Reg() + + case ssa.OpAMD64CMOVQEQF, ssa.OpAMD64CMOVLEQF, ssa.OpAMD64CMOVWEQF: + // Flag condition: ZERO && !PARITY + // Generate: + // MOV SRC,TMP + // CMOV*NE DST,TMP + // CMOV*PC TMP,DST + // + // TODO(rasky): we could generate: + // CMOV*NE DST,SRC + // CMOV*PC SRC,DST + // But this requires a way for regalloc to know that SRC might be + // clobbered by this instruction. + t := v.RegTmp() + opregreg(s, moveByRegsWidth(t, v.Args[1].Reg(), v.Type.Size()), t, v.Args[1].Reg()) + + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = t + var q *obj.Prog + if v.Op == ssa.OpAMD64CMOVQEQF { + q = s.Prog(x86.ACMOVQPC) + } else if v.Op == ssa.OpAMD64CMOVLEQF { + q = s.Prog(x86.ACMOVLPC) + } else { + q = s.Prog(x86.ACMOVWPC) + } + q.From.Type = obj.TYPE_REG + q.From.Reg = t + q.To.Type = obj.TYPE_REG + q.To.Reg = v.Reg() + + case ssa.OpAMD64MULQconst, ssa.OpAMD64MULLconst: + r := v.Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = r + p.AddRestSourceReg(v.Args[0].Reg()) + + case ssa.OpAMD64ANDQconst: + asm := v.Op.Asm() + // If the constant is positive and fits into 32 bits, use ANDL. + // This saves a few bytes of encoding. + if 0 <= v.AuxInt && v.AuxInt <= (1<<32-1) { + asm = x86.AANDL + } + p := s.Prog(asm) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64SUBQconst, ssa.OpAMD64SUBLconst, + ssa.OpAMD64ANDLconst, + ssa.OpAMD64ORQconst, ssa.OpAMD64ORLconst, + ssa.OpAMD64XORQconst, ssa.OpAMD64XORLconst, + ssa.OpAMD64SHLQconst, ssa.OpAMD64SHLLconst, + ssa.OpAMD64SHRQconst, ssa.OpAMD64SHRLconst, ssa.OpAMD64SHRWconst, ssa.OpAMD64SHRBconst, + ssa.OpAMD64SARQconst, ssa.OpAMD64SARLconst, ssa.OpAMD64SARWconst, ssa.OpAMD64SARBconst, + ssa.OpAMD64ROLQconst, ssa.OpAMD64ROLLconst, ssa.OpAMD64ROLWconst, ssa.OpAMD64ROLBconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpAMD64SBBQcarrymask, ssa.OpAMD64SBBLcarrymask: + r := v.Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpAMD64LEAQ1, ssa.OpAMD64LEAQ2, ssa.OpAMD64LEAQ4, ssa.OpAMD64LEAQ8, + ssa.OpAMD64LEAL1, ssa.OpAMD64LEAL2, ssa.OpAMD64LEAL4, ssa.OpAMD64LEAL8, + ssa.OpAMD64LEAW1, ssa.OpAMD64LEAW2, ssa.OpAMD64LEAW4, ssa.OpAMD64LEAW8: + p := s.Prog(v.Op.Asm()) + memIdx(&p.From, v) + o := v.Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = o + if v.AuxInt != 0 && v.Aux == nil { + // Emit an additional LEA to add the displacement instead of creating a slow 3 operand LEA. + switch v.Op { + case ssa.OpAMD64LEAQ1, ssa.OpAMD64LEAQ2, ssa.OpAMD64LEAQ4, ssa.OpAMD64LEAQ8: + p = s.Prog(x86.ALEAQ) + case ssa.OpAMD64LEAL1, ssa.OpAMD64LEAL2, ssa.OpAMD64LEAL4, ssa.OpAMD64LEAL8: + p = s.Prog(x86.ALEAL) + case ssa.OpAMD64LEAW1, ssa.OpAMD64LEAW2, ssa.OpAMD64LEAW4, ssa.OpAMD64LEAW8: + p = s.Prog(x86.ALEAW) + } + p.From.Type = obj.TYPE_MEM + p.From.Reg = o + p.To.Type = obj.TYPE_REG + p.To.Reg = o + } + ssagen.AddAux(&p.From, v) + case ssa.OpAMD64LEAQ, ssa.OpAMD64LEAL, ssa.OpAMD64LEAW: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpAMD64CMPQ, ssa.OpAMD64CMPL, ssa.OpAMD64CMPW, ssa.OpAMD64CMPB, + ssa.OpAMD64TESTQ, ssa.OpAMD64TESTL, ssa.OpAMD64TESTW, ssa.OpAMD64TESTB, + ssa.OpAMD64BTL, ssa.OpAMD64BTQ: + opregreg(s, v.Op.Asm(), v.Args[1].Reg(), v.Args[0].Reg()) + case ssa.OpAMD64UCOMISS, ssa.OpAMD64UCOMISD: + // Go assembler has swapped operands for UCOMISx relative to CMP, + // must account for that right here. + opregreg(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg()) + case ssa.OpAMD64CMPQconst, ssa.OpAMD64CMPLconst, ssa.OpAMD64CMPWconst, ssa.OpAMD64CMPBconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_CONST + p.To.Offset = v.AuxInt + case ssa.OpAMD64BTLconst, ssa.OpAMD64BTQconst, + ssa.OpAMD64TESTQconst, ssa.OpAMD64TESTLconst, ssa.OpAMD64TESTWconst, ssa.OpAMD64TESTBconst, + ssa.OpAMD64BTSQconst, + ssa.OpAMD64BTCQconst, + ssa.OpAMD64BTRQconst: + op := v.Op + if op == ssa.OpAMD64BTQconst && v.AuxInt < 32 { + // Emit 32-bit version because it's shorter + op = ssa.OpAMD64BTLconst + } + p := s.Prog(op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Args[0].Reg() + case ssa.OpAMD64CMPQload, ssa.OpAMD64CMPLload, ssa.OpAMD64CMPWload, ssa.OpAMD64CMPBload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Args[1].Reg() + case ssa.OpAMD64CMPQconstload, ssa.OpAMD64CMPLconstload, ssa.OpAMD64CMPWconstload, ssa.OpAMD64CMPBconstload: + sc := v.AuxValAndOff() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux2(&p.From, v, sc.Off64()) + p.To.Type = obj.TYPE_CONST + p.To.Offset = sc.Val64() + case ssa.OpAMD64CMPQloadidx8, ssa.OpAMD64CMPQloadidx1, ssa.OpAMD64CMPLloadidx4, ssa.OpAMD64CMPLloadidx1, ssa.OpAMD64CMPWloadidx2, ssa.OpAMD64CMPWloadidx1, ssa.OpAMD64CMPBloadidx1: + p := s.Prog(v.Op.Asm()) + memIdx(&p.From, v) + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Args[2].Reg() + case ssa.OpAMD64CMPQconstloadidx8, ssa.OpAMD64CMPQconstloadidx1, ssa.OpAMD64CMPLconstloadidx4, ssa.OpAMD64CMPLconstloadidx1, ssa.OpAMD64CMPWconstloadidx2, ssa.OpAMD64CMPWconstloadidx1, ssa.OpAMD64CMPBconstloadidx1: + sc := v.AuxValAndOff() + p := s.Prog(v.Op.Asm()) + memIdx(&p.From, v) + ssagen.AddAux2(&p.From, v, sc.Off64()) + p.To.Type = obj.TYPE_CONST + p.To.Offset = sc.Val64() + case ssa.OpAMD64MOVLconst, ssa.OpAMD64MOVQconst: + x := v.Reg() + + // If flags aren't live (indicated by v.Aux == nil), + // then we can rewrite MOV $0, AX into XOR AX, AX. + if v.AuxInt == 0 && v.Aux == nil { + opregreg(s, x86.AXORL, x, x) + break + } + + asm := v.Op.Asm() + // Use MOVL to move a small constant into a register + // when the constant is positive and fits into 32 bits. + if 0 <= v.AuxInt && v.AuxInt <= (1<<32-1) { + // The upper 32bit are zeroed automatically when using MOVL. + asm = x86.AMOVL + } + p := s.Prog(asm) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = x + + case ssa.OpAMD64MOVSSconst, ssa.OpAMD64MOVSDconst: + x := v.Reg() + if !isFPReg(x) && v.AuxInt == 0 && v.Aux == nil { + opregreg(s, x86.AXORL, x, x) + break + } + p := s.Prog(storeByRegWidth(x, v.Type.Size())) + p.From.Type = obj.TYPE_FCONST + p.From.Val = math.Float64frombits(uint64(v.AuxInt)) + p.To.Type = obj.TYPE_REG + p.To.Reg = x + case ssa.OpAMD64MOVQload, ssa.OpAMD64MOVLload, ssa.OpAMD64MOVWload, ssa.OpAMD64MOVBload, ssa.OpAMD64MOVOload, + ssa.OpAMD64MOVSSload, ssa.OpAMD64MOVSDload, ssa.OpAMD64MOVBQSXload, ssa.OpAMD64MOVWQSXload, ssa.OpAMD64MOVLQSXload, + ssa.OpAMD64MOVBEQload, ssa.OpAMD64MOVBELload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpAMD64MOVBloadidx1, ssa.OpAMD64MOVWloadidx1, ssa.OpAMD64MOVLloadidx1, ssa.OpAMD64MOVQloadidx1, ssa.OpAMD64MOVSSloadidx1, ssa.OpAMD64MOVSDloadidx1, + ssa.OpAMD64MOVQloadidx8, ssa.OpAMD64MOVSDloadidx8, ssa.OpAMD64MOVLloadidx8, ssa.OpAMD64MOVLloadidx4, ssa.OpAMD64MOVSSloadidx4, ssa.OpAMD64MOVWloadidx2, + ssa.OpAMD64MOVBELloadidx1, ssa.OpAMD64MOVBELloadidx4, ssa.OpAMD64MOVBELloadidx8, ssa.OpAMD64MOVBEQloadidx1, ssa.OpAMD64MOVBEQloadidx8: + p := s.Prog(v.Op.Asm()) + memIdx(&p.From, v) + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpAMD64MOVQstore, ssa.OpAMD64MOVSSstore, ssa.OpAMD64MOVSDstore, ssa.OpAMD64MOVLstore, ssa.OpAMD64MOVWstore, ssa.OpAMD64MOVBstore, ssa.OpAMD64MOVOstore, + ssa.OpAMD64ADDQmodify, ssa.OpAMD64SUBQmodify, ssa.OpAMD64ANDQmodify, ssa.OpAMD64ORQmodify, ssa.OpAMD64XORQmodify, + ssa.OpAMD64ADDLmodify, ssa.OpAMD64SUBLmodify, ssa.OpAMD64ANDLmodify, ssa.OpAMD64ORLmodify, ssa.OpAMD64XORLmodify, + ssa.OpAMD64MOVBEQstore, ssa.OpAMD64MOVBELstore, ssa.OpAMD64MOVBEWstore: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpAMD64MOVBstoreidx1, ssa.OpAMD64MOVWstoreidx1, ssa.OpAMD64MOVLstoreidx1, ssa.OpAMD64MOVQstoreidx1, ssa.OpAMD64MOVSSstoreidx1, ssa.OpAMD64MOVSDstoreidx1, + ssa.OpAMD64MOVQstoreidx8, ssa.OpAMD64MOVSDstoreidx8, ssa.OpAMD64MOVLstoreidx8, ssa.OpAMD64MOVSSstoreidx4, ssa.OpAMD64MOVLstoreidx4, ssa.OpAMD64MOVWstoreidx2, + ssa.OpAMD64ADDLmodifyidx1, ssa.OpAMD64ADDLmodifyidx4, ssa.OpAMD64ADDLmodifyidx8, ssa.OpAMD64ADDQmodifyidx1, ssa.OpAMD64ADDQmodifyidx8, + ssa.OpAMD64SUBLmodifyidx1, ssa.OpAMD64SUBLmodifyidx4, ssa.OpAMD64SUBLmodifyidx8, ssa.OpAMD64SUBQmodifyidx1, ssa.OpAMD64SUBQmodifyidx8, + ssa.OpAMD64ANDLmodifyidx1, ssa.OpAMD64ANDLmodifyidx4, ssa.OpAMD64ANDLmodifyidx8, ssa.OpAMD64ANDQmodifyidx1, ssa.OpAMD64ANDQmodifyidx8, + ssa.OpAMD64ORLmodifyidx1, ssa.OpAMD64ORLmodifyidx4, ssa.OpAMD64ORLmodifyidx8, ssa.OpAMD64ORQmodifyidx1, ssa.OpAMD64ORQmodifyidx8, + ssa.OpAMD64XORLmodifyidx1, ssa.OpAMD64XORLmodifyidx4, ssa.OpAMD64XORLmodifyidx8, ssa.OpAMD64XORQmodifyidx1, ssa.OpAMD64XORQmodifyidx8, + ssa.OpAMD64MOVBEWstoreidx1, ssa.OpAMD64MOVBEWstoreidx2, ssa.OpAMD64MOVBELstoreidx1, ssa.OpAMD64MOVBELstoreidx4, ssa.OpAMD64MOVBELstoreidx8, ssa.OpAMD64MOVBEQstoreidx1, ssa.OpAMD64MOVBEQstoreidx8: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + memIdx(&p.To, v) + ssagen.AddAux(&p.To, v) + case ssa.OpAMD64ADDQconstmodify, ssa.OpAMD64ADDLconstmodify: + sc := v.AuxValAndOff() + off := sc.Off64() + val := sc.Val() + if val == 1 || val == -1 { + var asm obj.As + if v.Op == ssa.OpAMD64ADDQconstmodify { + if val == 1 { + asm = x86.AINCQ + } else { + asm = x86.ADECQ + } + } else { + if val == 1 { + asm = x86.AINCL + } else { + asm = x86.ADECL + } + } + p := s.Prog(asm) + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux2(&p.To, v, off) + break + } + fallthrough + case ssa.OpAMD64ANDQconstmodify, ssa.OpAMD64ANDLconstmodify, ssa.OpAMD64ORQconstmodify, ssa.OpAMD64ORLconstmodify, + ssa.OpAMD64XORQconstmodify, ssa.OpAMD64XORLconstmodify, + ssa.OpAMD64BTSQconstmodify, ssa.OpAMD64BTRQconstmodify, ssa.OpAMD64BTCQconstmodify: + sc := v.AuxValAndOff() + off := sc.Off64() + val := sc.Val64() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = val + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux2(&p.To, v, off) + + case ssa.OpAMD64MOVQstoreconst, ssa.OpAMD64MOVLstoreconst, ssa.OpAMD64MOVWstoreconst, ssa.OpAMD64MOVBstoreconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + sc := v.AuxValAndOff() + p.From.Offset = sc.Val64() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux2(&p.To, v, sc.Off64()) + case ssa.OpAMD64MOVOstoreconst: + sc := v.AuxValAndOff() + if sc.Val() != 0 { + v.Fatalf("MOVO for non zero constants not implemented: %s", v.LongString()) + } + + if s.ABI != obj.ABIInternal { + // zero X15 manually + opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15) + } + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = x86.REG_X15 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux2(&p.To, v, sc.Off64()) + + case ssa.OpAMD64MOVQstoreconstidx1, ssa.OpAMD64MOVQstoreconstidx8, ssa.OpAMD64MOVLstoreconstidx1, ssa.OpAMD64MOVLstoreconstidx4, ssa.OpAMD64MOVWstoreconstidx1, ssa.OpAMD64MOVWstoreconstidx2, ssa.OpAMD64MOVBstoreconstidx1, + ssa.OpAMD64ADDLconstmodifyidx1, ssa.OpAMD64ADDLconstmodifyidx4, ssa.OpAMD64ADDLconstmodifyidx8, ssa.OpAMD64ADDQconstmodifyidx1, ssa.OpAMD64ADDQconstmodifyidx8, + ssa.OpAMD64ANDLconstmodifyidx1, ssa.OpAMD64ANDLconstmodifyidx4, ssa.OpAMD64ANDLconstmodifyidx8, ssa.OpAMD64ANDQconstmodifyidx1, ssa.OpAMD64ANDQconstmodifyidx8, + ssa.OpAMD64ORLconstmodifyidx1, ssa.OpAMD64ORLconstmodifyidx4, ssa.OpAMD64ORLconstmodifyidx8, ssa.OpAMD64ORQconstmodifyidx1, ssa.OpAMD64ORQconstmodifyidx8, + ssa.OpAMD64XORLconstmodifyidx1, ssa.OpAMD64XORLconstmodifyidx4, ssa.OpAMD64XORLconstmodifyidx8, ssa.OpAMD64XORQconstmodifyidx1, ssa.OpAMD64XORQconstmodifyidx8: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + sc := v.AuxValAndOff() + p.From.Offset = sc.Val64() + switch { + case p.As == x86.AADDQ && p.From.Offset == 1: + p.As = x86.AINCQ + p.From.Type = obj.TYPE_NONE + case p.As == x86.AADDQ && p.From.Offset == -1: + p.As = x86.ADECQ + p.From.Type = obj.TYPE_NONE + case p.As == x86.AADDL && p.From.Offset == 1: + p.As = x86.AINCL + p.From.Type = obj.TYPE_NONE + case p.As == x86.AADDL && p.From.Offset == -1: + p.As = x86.ADECL + p.From.Type = obj.TYPE_NONE + } + memIdx(&p.To, v) + ssagen.AddAux2(&p.To, v, sc.Off64()) + case ssa.OpAMD64MOVLQSX, ssa.OpAMD64MOVWQSX, ssa.OpAMD64MOVBQSX, ssa.OpAMD64MOVLQZX, ssa.OpAMD64MOVWQZX, ssa.OpAMD64MOVBQZX, + ssa.OpAMD64CVTTSS2SL, ssa.OpAMD64CVTTSD2SL, ssa.OpAMD64CVTTSS2SQ, ssa.OpAMD64CVTTSD2SQ, + ssa.OpAMD64CVTSS2SD, ssa.OpAMD64CVTSD2SS, ssa.OpAMD64VPBROADCASTB, ssa.OpAMD64PMOVMSKB: + opregreg(s, v.Op.Asm(), v.Reg(), v.Args[0].Reg()) + case ssa.OpAMD64CVTSL2SD, ssa.OpAMD64CVTSQ2SD, ssa.OpAMD64CVTSQ2SS, ssa.OpAMD64CVTSL2SS: + r := v.Reg() + // Break false dependency on destination register. + opregreg(s, x86.AXORPS, r, r) + opregreg(s, v.Op.Asm(), r, v.Args[0].Reg()) + case ssa.OpAMD64MOVQi2f, ssa.OpAMD64MOVQf2i, ssa.OpAMD64MOVLi2f, ssa.OpAMD64MOVLf2i: + var p *obj.Prog + switch v.Op { + case ssa.OpAMD64MOVQi2f, ssa.OpAMD64MOVQf2i: + p = s.Prog(x86.AMOVQ) + case ssa.OpAMD64MOVLi2f, ssa.OpAMD64MOVLf2i: + p = s.Prog(x86.AMOVL) + } + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpAMD64ADDQload, ssa.OpAMD64ADDLload, ssa.OpAMD64SUBQload, ssa.OpAMD64SUBLload, + ssa.OpAMD64ANDQload, ssa.OpAMD64ANDLload, ssa.OpAMD64ORQload, ssa.OpAMD64ORLload, + ssa.OpAMD64XORQload, ssa.OpAMD64XORLload, ssa.OpAMD64ADDSDload, ssa.OpAMD64ADDSSload, + ssa.OpAMD64SUBSDload, ssa.OpAMD64SUBSSload, ssa.OpAMD64MULSDload, ssa.OpAMD64MULSSload, + ssa.OpAMD64DIVSDload, ssa.OpAMD64DIVSSload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[1].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpAMD64ADDLloadidx1, ssa.OpAMD64ADDLloadidx4, ssa.OpAMD64ADDLloadidx8, ssa.OpAMD64ADDQloadidx1, ssa.OpAMD64ADDQloadidx8, + ssa.OpAMD64SUBLloadidx1, ssa.OpAMD64SUBLloadidx4, ssa.OpAMD64SUBLloadidx8, ssa.OpAMD64SUBQloadidx1, ssa.OpAMD64SUBQloadidx8, + ssa.OpAMD64ANDLloadidx1, ssa.OpAMD64ANDLloadidx4, ssa.OpAMD64ANDLloadidx8, ssa.OpAMD64ANDQloadidx1, ssa.OpAMD64ANDQloadidx8, + ssa.OpAMD64ORLloadidx1, ssa.OpAMD64ORLloadidx4, ssa.OpAMD64ORLloadidx8, ssa.OpAMD64ORQloadidx1, ssa.OpAMD64ORQloadidx8, + ssa.OpAMD64XORLloadidx1, ssa.OpAMD64XORLloadidx4, ssa.OpAMD64XORLloadidx8, ssa.OpAMD64XORQloadidx1, ssa.OpAMD64XORQloadidx8, + ssa.OpAMD64ADDSSloadidx1, ssa.OpAMD64ADDSSloadidx4, ssa.OpAMD64ADDSDloadidx1, ssa.OpAMD64ADDSDloadidx8, + ssa.OpAMD64SUBSSloadidx1, ssa.OpAMD64SUBSSloadidx4, ssa.OpAMD64SUBSDloadidx1, ssa.OpAMD64SUBSDloadidx8, + ssa.OpAMD64MULSSloadidx1, ssa.OpAMD64MULSSloadidx4, ssa.OpAMD64MULSDloadidx1, ssa.OpAMD64MULSDloadidx8, + ssa.OpAMD64DIVSSloadidx1, ssa.OpAMD64DIVSSloadidx4, ssa.OpAMD64DIVSDloadidx1, ssa.OpAMD64DIVSDloadidx8: + p := s.Prog(v.Op.Asm()) + + r, i := v.Args[1].Reg(), v.Args[2].Reg() + p.From.Type = obj.TYPE_MEM + p.From.Scale = v.Op.Scale() + if p.From.Scale == 1 && i == x86.REG_SP { + r, i = i, r + } + p.From.Reg = r + p.From.Index = i + + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64LoweredZero: + if s.ABI != obj.ABIInternal { + // zero X15 manually + opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15) + } + ptrReg := v.Args[0].Reg() + n := v.AuxInt + if n < 16 { + v.Fatalf("Zero too small %d", n) + } + zero16 := func(off int64) { + zero16(s, ptrReg, off) + } + + // Generate zeroing instructions. + var off int64 + for n >= 16 { + zero16(off) + off += 16 + n -= 16 + } + if n != 0 { + // use partially overlapped write. + // TODO: n <= 8, use smaller write? + zero16(off + n - 16) + } + + case ssa.OpAMD64LoweredZeroLoop: + if s.ABI != obj.ABIInternal { + // zero X15 manually + opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15) + } + ptrReg := v.Args[0].Reg() + countReg := v.RegTmp() + n := v.AuxInt + loopSize := int64(64) + if n < 3*loopSize { + // - a loop count of 0 won't work. + // - a loop count of 1 is useless. + // - a loop count of 2 is a code size ~tie + // 4 instructions to implement the loop + // 4 instructions in the loop body + // vs + // 8 instructions in the straightline code + // Might as well use straightline code. + v.Fatalf("ZeroLoop size too small %d", n) + } + zero16 := func(off int64) { + zero16(s, ptrReg, off) + } + + // Put iteration count in a register. + // MOVL $n, countReg + p := s.Prog(x86.AMOVL) + p.From.Type = obj.TYPE_CONST + p.From.Offset = n / loopSize + p.To.Type = obj.TYPE_REG + p.To.Reg = countReg + cntInit := p + + // Zero loopSize bytes starting at ptrReg. + for i := range loopSize / 16 { + zero16(i * 16) + } + // ADDQ $loopSize, ptrReg + p = s.Prog(x86.AADDQ) + p.From.Type = obj.TYPE_CONST + p.From.Offset = loopSize + p.To.Type = obj.TYPE_REG + p.To.Reg = ptrReg + // DECL countReg + p = s.Prog(x86.ADECL) + p.To.Type = obj.TYPE_REG + p.To.Reg = countReg + // Jump to first instruction in loop if we're not done yet. + // JNE head + p = s.Prog(x86.AJNE) + p.To.Type = obj.TYPE_BRANCH + p.To.SetTarget(cntInit.Link) + + // Multiples of the loop size are now done. + n %= loopSize + + // Write any fractional portion. + var off int64 + for n >= 16 { + zero16(off) + off += 16 + n -= 16 + } + if n != 0 { + // Use partially-overlapping write. + // TODO: n <= 8, use smaller write? + zero16(off + n - 16) + } + + case ssa.OpAMD64LoweredMove: + dstReg := v.Args[0].Reg() + srcReg := v.Args[1].Reg() + if dstReg == srcReg { + break + } + tmpReg := int16(x86.REG_X14) + n := v.AuxInt + if n < 16 { + v.Fatalf("Move too small %d", n) + } + // move 16 bytes from srcReg+off to dstReg+off. + move16 := func(off int64) { + move16(s, srcReg, dstReg, tmpReg, off) + } + + // Generate copying instructions. + var off int64 + for n >= 16 { + move16(off) + off += 16 + n -= 16 + } + if n != 0 { + // use partially overlapped read/write. + // TODO: use smaller operations when we can? + move16(off + n - 16) + } + + case ssa.OpAMD64LoweredMoveLoop: + dstReg := v.Args[0].Reg() + srcReg := v.Args[1].Reg() + if dstReg == srcReg { + break + } + countReg := v.RegTmp() + tmpReg := int16(x86.REG_X14) + n := v.AuxInt + loopSize := int64(64) + if n < 3*loopSize { + // - a loop count of 0 won't work. + // - a loop count of 1 is useless. + // - a loop count of 2 is a code size ~tie + // 4 instructions to implement the loop + // 4 instructions in the loop body + // vs + // 8 instructions in the straightline code + // Might as well use straightline code. + v.Fatalf("ZeroLoop size too small %d", n) + } + // move 16 bytes from srcReg+off to dstReg+off. + move16 := func(off int64) { + move16(s, srcReg, dstReg, tmpReg, off) + } + + // Put iteration count in a register. + // MOVL $n, countReg + p := s.Prog(x86.AMOVL) + p.From.Type = obj.TYPE_CONST + p.From.Offset = n / loopSize + p.To.Type = obj.TYPE_REG + p.To.Reg = countReg + cntInit := p + + // Copy loopSize bytes starting at srcReg to dstReg. + for i := range loopSize / 16 { + move16(i * 16) + } + // ADDQ $loopSize, srcReg + p = s.Prog(x86.AADDQ) + p.From.Type = obj.TYPE_CONST + p.From.Offset = loopSize + p.To.Type = obj.TYPE_REG + p.To.Reg = srcReg + // ADDQ $loopSize, dstReg + p = s.Prog(x86.AADDQ) + p.From.Type = obj.TYPE_CONST + p.From.Offset = loopSize + p.To.Type = obj.TYPE_REG + p.To.Reg = dstReg + // DECL countReg + p = s.Prog(x86.ADECL) + p.To.Type = obj.TYPE_REG + p.To.Reg = countReg + // Jump to loop header if we're not done yet. + // JNE head + p = s.Prog(x86.AJNE) + p.To.Type = obj.TYPE_BRANCH + p.To.SetTarget(cntInit.Link) + + // Multiples of the loop size are now done. + n %= loopSize + + // Copy any fractional portion. + var off int64 + for n >= 16 { + move16(off) + off += 16 + n -= 16 + } + if n != 0 { + // Use partially-overlapping copy. + move16(off + n - 16) + } + + case ssa.OpCopy: // TODO: use MOVQreg for reg->reg copies instead of OpCopy? + if v.Type.IsMemory() { + return + } + x := v.Args[0].Reg() + y := v.Reg() + if v.Type.IsSIMD() { + x = simdOrMaskReg(v.Args[0]) + y = simdOrMaskReg(v) + } + if x != y { + opregreg(s, moveByRegsWidth(y, x, v.Type.Size()), y, x) + } + case ssa.OpLoadReg: + if v.Type.IsFlags() { + v.Fatalf("load flags not implemented: %v", v.LongString()) + return + } + r := v.Reg() + p := s.Prog(loadByRegWidth(r, v.Type.Size())) + ssagen.AddrAuto(&p.From, v.Args[0]) + p.To.Type = obj.TYPE_REG + if v.Type.IsSIMD() { + r = simdOrMaskReg(v) + } + p.To.Reg = r + + case ssa.OpStoreReg: + if v.Type.IsFlags() { + v.Fatalf("store flags not implemented: %v", v.LongString()) + return + } + r := v.Args[0].Reg() + if v.Type.IsSIMD() { + r = simdOrMaskReg(v.Args[0]) + } + p := s.Prog(storeByRegWidth(r, v.Type.Size())) + p.From.Type = obj.TYPE_REG + p.From.Reg = r + ssagen.AddrAuto(&p.To, v) + case ssa.OpAMD64LoweredHasCPUFeature: + p := s.Prog(x86.AMOVBLZX) + p.From.Type = obj.TYPE_MEM + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpArgIntReg, ssa.OpArgFloatReg: + // The assembler needs to wrap the entry safepoint/stack growth code with spill/unspill + // The loop only runs once. + for _, ap := range v.Block.Func.RegArgs { + // Pass the spill/unspill information along to the assembler, offset by size of return PC pushed on stack. + addr := ssagen.SpillSlotAddr(ap, x86.REG_SP, v.Block.Func.Config.PtrSize) + reg := ap.Reg + t := ap.Type + sz := t.Size() + if t.IsSIMD() { + reg = simdRegBySize(reg, sz) + } + s.FuncInfo().AddSpill( + obj.RegSpill{Reg: reg, Addr: addr, Unspill: loadByRegWidth(reg, sz), Spill: storeByRegWidth(reg, sz)}) + } + v.Block.Func.RegArgs = nil + ssagen.CheckArgReg(v) + case ssa.OpAMD64LoweredGetClosurePtr: + // Closure pointer is DX. + ssagen.CheckLoweredGetClosurePtr(v) + case ssa.OpAMD64LoweredGetG: + if s.ABI == obj.ABIInternal { + v.Fatalf("LoweredGetG should not appear in ABIInternal") + } + r := v.Reg() + getgFromTLS(s, r) + case ssa.OpAMD64CALLstatic, ssa.OpAMD64CALLtail: + if s.ABI == obj.ABI0 && v.Aux.(*ssa.AuxCall).Fn.ABI() == obj.ABIInternal { + // zeroing X15 when entering ABIInternal from ABI0 + zeroX15(s) + // set G register from TLS + getgFromTLS(s, x86.REG_R14) + } + if v.Op == ssa.OpAMD64CALLtail { + s.TailCall(v) + break + } + s.Call(v) + if s.ABI == obj.ABIInternal && v.Aux.(*ssa.AuxCall).Fn.ABI() == obj.ABI0 { + // zeroing X15 when entering ABIInternal from ABI0 + zeroX15(s) + // set G register from TLS + getgFromTLS(s, x86.REG_R14) + } + case ssa.OpAMD64CALLclosure, ssa.OpAMD64CALLinter: + s.Call(v) + + case ssa.OpAMD64LoweredGetCallerPC: + p := s.Prog(x86.AMOVQ) + p.From.Type = obj.TYPE_MEM + p.From.Offset = -8 // PC is stored 8 bytes below first parameter. + p.From.Name = obj.NAME_PARAM + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64LoweredGetCallerSP: + // caller's SP is the address of the first arg + mov := x86.AMOVQ + if types.PtrSize == 4 { + mov = x86.AMOVL + } + p := s.Prog(mov) + p.From.Type = obj.TYPE_ADDR + p.From.Offset = -base.Ctxt.Arch.FixedFrameSize // 0 on amd64, just to be consistent with other architectures + p.From.Name = obj.NAME_PARAM + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64LoweredWB: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + // AuxInt encodes how many buffer entries we need. + p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1] + + case ssa.OpAMD64LoweredPanicBoundsRR, ssa.OpAMD64LoweredPanicBoundsRC, ssa.OpAMD64LoweredPanicBoundsCR, ssa.OpAMD64LoweredPanicBoundsCC: + // Compute the constant we put in the PCData entry for this call. + code, signed := ssa.BoundsKind(v.AuxInt).Code() + xIsReg := false + yIsReg := false + xVal := 0 + yVal := 0 + switch v.Op { + case ssa.OpAMD64LoweredPanicBoundsRR: + xIsReg = true + xVal = int(v.Args[0].Reg() - x86.REG_AX) + yIsReg = true + yVal = int(v.Args[1].Reg() - x86.REG_AX) + case ssa.OpAMD64LoweredPanicBoundsRC: + xIsReg = true + xVal = int(v.Args[0].Reg() - x86.REG_AX) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + if yVal == xVal { + yVal = 1 + } + p := s.Prog(x86.AMOVQ) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = x86.REG_AX + int16(yVal) + } + case ssa.OpAMD64LoweredPanicBoundsCR: + yIsReg = true + yVal = int(v.Args[0].Reg() - x86.REG_AX) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + xIsReg = true + if xVal == yVal { + xVal = 1 + } + p := s.Prog(x86.AMOVQ) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = x86.REG_AX + int16(xVal) + } + case ssa.OpAMD64LoweredPanicBoundsCC: + c := v.Aux.(ssa.PanicBoundsCC).Cx + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + xIsReg = true + p := s.Prog(x86.AMOVQ) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = x86.REG_AX + int16(xVal) + } + c = v.Aux.(ssa.PanicBoundsCC).Cy + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + yVal = 1 + p := s.Prog(x86.AMOVQ) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = x86.REG_AX + int16(yVal) + } + } + c := abi.BoundsEncode(code, signed, xIsReg, yIsReg, xVal, yVal) + + p := s.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_PanicBounds) + p.To.SetConst(int64(c)) + p = s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.PanicBounds + + case ssa.OpAMD64NEGQ, ssa.OpAMD64NEGL, + ssa.OpAMD64BSWAPQ, ssa.OpAMD64BSWAPL, + ssa.OpAMD64NOTQ, ssa.OpAMD64NOTL: + p := s.Prog(v.Op.Asm()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64NEGLflags: + p := s.Prog(v.Op.Asm()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + case ssa.OpAMD64ADDQconstflags, ssa.OpAMD64ADDLconstflags: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + // Note: the inc/dec instructions do not modify + // the carry flag like add$1 / sub$1 do. + // We currently never use the CF/OF flags from + // these instructions, so that is ok. + switch { + case p.As == x86.AADDQ && p.From.Offset == 1: + p.As = x86.AINCQ + p.From.Type = obj.TYPE_NONE + case p.As == x86.AADDQ && p.From.Offset == -1: + p.As = x86.ADECQ + p.From.Type = obj.TYPE_NONE + case p.As == x86.AADDL && p.From.Offset == 1: + p.As = x86.AINCL + p.From.Type = obj.TYPE_NONE + case p.As == x86.AADDL && p.From.Offset == -1: + p.As = x86.ADECL + p.From.Type = obj.TYPE_NONE + } + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + case ssa.OpAMD64BSFQ, ssa.OpAMD64BSRQ, ssa.OpAMD64BSFL, ssa.OpAMD64BSRL, ssa.OpAMD64SQRTSD, ssa.OpAMD64SQRTSS: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + switch v.Op { + case ssa.OpAMD64BSFQ, ssa.OpAMD64BSRQ: + p.To.Reg = v.Reg0() + case ssa.OpAMD64BSFL, ssa.OpAMD64BSRL, ssa.OpAMD64SQRTSD, ssa.OpAMD64SQRTSS: + p.To.Reg = v.Reg() + } + case ssa.OpAMD64LoweredRound32F, ssa.OpAMD64LoweredRound64F: + // input is already rounded + case ssa.OpAMD64ROUNDSD: + p := s.Prog(v.Op.Asm()) + val := v.AuxInt + // 0 means math.RoundToEven, 1 Floor, 2 Ceil, 3 Trunc + if val < 0 || val > 3 { + v.Fatalf("Invalid rounding mode") + } + p.From.Offset = val + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(v.Args[0].Reg()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpAMD64POPCNTQ, ssa.OpAMD64POPCNTL, + ssa.OpAMD64TZCNTQ, ssa.OpAMD64TZCNTL, + ssa.OpAMD64LZCNTQ, ssa.OpAMD64LZCNTL: + if v.Args[0].Reg() != v.Reg() { + // POPCNT/TZCNT/LZCNT have a false dependency on the destination register on Intel cpus. + // TZCNT/LZCNT problem affects pre-Skylake models. See discussion at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62011#c7. + // Xor register with itself to break the dependency. + opregreg(s, x86.AXORL, v.Reg(), v.Reg()) + } + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64SETEQ, ssa.OpAMD64SETNE, + ssa.OpAMD64SETL, ssa.OpAMD64SETLE, + ssa.OpAMD64SETG, ssa.OpAMD64SETGE, + ssa.OpAMD64SETGF, ssa.OpAMD64SETGEF, + ssa.OpAMD64SETB, ssa.OpAMD64SETBE, + ssa.OpAMD64SETORD, ssa.OpAMD64SETNAN, + ssa.OpAMD64SETA, ssa.OpAMD64SETAE, + ssa.OpAMD64SETO: + p := s.Prog(v.Op.Asm()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64SETEQstore, ssa.OpAMD64SETNEstore, + ssa.OpAMD64SETLstore, ssa.OpAMD64SETLEstore, + ssa.OpAMD64SETGstore, ssa.OpAMD64SETGEstore, + ssa.OpAMD64SETBstore, ssa.OpAMD64SETBEstore, + ssa.OpAMD64SETAstore, ssa.OpAMD64SETAEstore: + p := s.Prog(v.Op.Asm()) + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + + case ssa.OpAMD64SETEQstoreidx1, ssa.OpAMD64SETNEstoreidx1, + ssa.OpAMD64SETLstoreidx1, ssa.OpAMD64SETLEstoreidx1, + ssa.OpAMD64SETGstoreidx1, ssa.OpAMD64SETGEstoreidx1, + ssa.OpAMD64SETBstoreidx1, ssa.OpAMD64SETBEstoreidx1, + ssa.OpAMD64SETAstoreidx1, ssa.OpAMD64SETAEstoreidx1: + p := s.Prog(v.Op.Asm()) + memIdx(&p.To, v) + ssagen.AddAux(&p.To, v) + + case ssa.OpAMD64SETNEF: + t := v.RegTmp() + p := s.Prog(v.Op.Asm()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + q := s.Prog(x86.ASETPS) + q.To.Type = obj.TYPE_REG + q.To.Reg = t + // ORL avoids partial register write and is smaller than ORQ, used by old compiler + opregreg(s, x86.AORL, v.Reg(), t) + + case ssa.OpAMD64SETEQF: + t := v.RegTmp() + p := s.Prog(v.Op.Asm()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + q := s.Prog(x86.ASETPC) + q.To.Type = obj.TYPE_REG + q.To.Reg = t + // ANDL avoids partial register write and is smaller than ANDQ, used by old compiler + opregreg(s, x86.AANDL, v.Reg(), t) + + case ssa.OpAMD64InvertFlags: + v.Fatalf("InvertFlags should never make it to codegen %v", v.LongString()) + case ssa.OpAMD64FlagEQ, ssa.OpAMD64FlagLT_ULT, ssa.OpAMD64FlagLT_UGT, ssa.OpAMD64FlagGT_ULT, ssa.OpAMD64FlagGT_UGT: + v.Fatalf("Flag* ops should never make it to codegen %v", v.LongString()) + case ssa.OpAMD64AddTupleFirst32, ssa.OpAMD64AddTupleFirst64: + v.Fatalf("AddTupleFirst* should never make it to codegen %v", v.LongString()) + case ssa.OpAMD64REPSTOSQ: + s.Prog(x86.AREP) + s.Prog(x86.ASTOSQ) + case ssa.OpAMD64REPMOVSQ: + s.Prog(x86.AREP) + s.Prog(x86.AMOVSQ) + case ssa.OpAMD64LoweredNilCheck: + // Issue a load which will fault if the input is nil. + // TODO: We currently use the 2-byte instruction TESTB AX, (reg). + // Should we use the 3-byte TESTB $0, (reg) instead? It is larger + // but it doesn't have false dependency on AX. + // Or maybe allocate an output register and use MOVL (reg),reg2 ? + // That trades clobbering flags for clobbering a register. + p := s.Prog(x86.ATESTB) + p.From.Type = obj.TYPE_REG + p.From.Reg = x86.REG_AX + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + if logopt.Enabled() { + logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name) + } + if base.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers + base.WarnfAt(v.Pos, "generated nil check") + } + case ssa.OpAMD64MOVBatomicload, ssa.OpAMD64MOVLatomicload, ssa.OpAMD64MOVQatomicload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + case ssa.OpAMD64XCHGB, ssa.OpAMD64XCHGL, ssa.OpAMD64XCHGQ: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Reg0() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[1].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpAMD64XADDLlock, ssa.OpAMD64XADDQlock: + s.Prog(x86.ALOCK) + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Reg0() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[1].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpAMD64CMPXCHGLlock, ssa.OpAMD64CMPXCHGQlock: + if v.Args[1].Reg() != x86.REG_AX { + v.Fatalf("input[1] not in AX %s", v.LongString()) + } + s.Prog(x86.ALOCK) + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + p = s.Prog(x86.ASETEQ) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + case ssa.OpAMD64ANDBlock, ssa.OpAMD64ANDLlock, ssa.OpAMD64ANDQlock, ssa.OpAMD64ORBlock, ssa.OpAMD64ORLlock, ssa.OpAMD64ORQlock: + // Atomic memory operations that don't need to return the old value. + s.Prog(x86.ALOCK) + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpAMD64LoweredAtomicAnd64, ssa.OpAMD64LoweredAtomicOr64, ssa.OpAMD64LoweredAtomicAnd32, ssa.OpAMD64LoweredAtomicOr32: + // Atomic memory operations that need to return the old value. + // We need to do these with compare-and-exchange to get access to the old value. + // loop: + // MOVQ mask, tmp + // MOVQ (addr), AX + // ANDQ AX, tmp + // LOCK CMPXCHGQ tmp, (addr) : note that AX is implicit old value to compare against + // JNE loop + // : result in AX + mov := x86.AMOVQ + op := x86.AANDQ + cmpxchg := x86.ACMPXCHGQ + switch v.Op { + case ssa.OpAMD64LoweredAtomicOr64: + op = x86.AORQ + case ssa.OpAMD64LoweredAtomicAnd32: + mov = x86.AMOVL + op = x86.AANDL + cmpxchg = x86.ACMPXCHGL + case ssa.OpAMD64LoweredAtomicOr32: + mov = x86.AMOVL + op = x86.AORL + cmpxchg = x86.ACMPXCHGL + } + addr := v.Args[0].Reg() + mask := v.Args[1].Reg() + tmp := v.RegTmp() + p1 := s.Prog(mov) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = mask + p1.To.Type = obj.TYPE_REG + p1.To.Reg = tmp + p2 := s.Prog(mov) + p2.From.Type = obj.TYPE_MEM + p2.From.Reg = addr + ssagen.AddAux(&p2.From, v) + p2.To.Type = obj.TYPE_REG + p2.To.Reg = x86.REG_AX + p3 := s.Prog(op) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = x86.REG_AX + p3.To.Type = obj.TYPE_REG + p3.To.Reg = tmp + s.Prog(x86.ALOCK) + p5 := s.Prog(cmpxchg) + p5.From.Type = obj.TYPE_REG + p5.From.Reg = tmp + p5.To.Type = obj.TYPE_MEM + p5.To.Reg = addr + ssagen.AddAux(&p5.To, v) + p6 := s.Prog(x86.AJNE) + p6.To.Type = obj.TYPE_BRANCH + p6.To.SetTarget(p1) + case ssa.OpAMD64PrefetchT0, ssa.OpAMD64PrefetchNTA: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + case ssa.OpClobber: + p := s.Prog(x86.AMOVL) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 0xdeaddead + p.To.Type = obj.TYPE_MEM + p.To.Reg = x86.REG_SP + ssagen.AddAux(&p.To, v) + p = s.Prog(x86.AMOVL) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 0xdeaddead + p.To.Type = obj.TYPE_MEM + p.To.Reg = x86.REG_SP + ssagen.AddAux(&p.To, v) + p.To.Offset += 4 + case ssa.OpClobberReg: + x := uint64(0xdeaddeaddeaddead) + p := s.Prog(x86.AMOVQ) + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(x) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + // SIMD ops + case ssa.OpAMD64VZEROUPPER, ssa.OpAMD64VZEROALL: + s.Prog(v.Op.Asm()) + + case ssa.OpAMD64Zero128: // no code emitted + + case ssa.OpAMD64Zero256, ssa.OpAMD64Zero512: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v) + p.AddRestSourceReg(simdReg(v)) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + + case ssa.OpAMD64VMOVSSf2v, ssa.OpAMD64VMOVSDf2v: + // These are for initializing the least 32/64 bits of a SIMD register from a "float". + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.AddRestSourceReg(x86.REG_X15) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + + case ssa.OpAMD64VMOVQload, ssa.OpAMD64VMOVDload, + ssa.OpAMD64VMOVSSload, ssa.OpAMD64VMOVSDload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + + case ssa.OpAMD64VMOVSSconst, ssa.OpAMD64VMOVSDconst: + // for loading constants directly into SIMD registers + x := simdReg(v) + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_FCONST + p.From.Val = math.Float64frombits(uint64(v.AuxInt)) + p.To.Type = obj.TYPE_REG + p.To.Reg = x + + case ssa.OpAMD64VMOVD, ssa.OpAMD64VMOVQ: + // These are for initializing the least 32/64 bits of a SIMD register from an "int". + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + + case ssa.OpAMD64VMOVDQUload128, ssa.OpAMD64VMOVDQUload256, ssa.OpAMD64VMOVDQUload512, + ssa.OpAMD64KMOVBload, ssa.OpAMD64KMOVWload, ssa.OpAMD64KMOVDload, ssa.OpAMD64KMOVQload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdOrMaskReg(v) + case ssa.OpAMD64VMOVDQUstore128, ssa.OpAMD64VMOVDQUstore256, ssa.OpAMD64VMOVDQUstore512, + ssa.OpAMD64KMOVBstore, ssa.OpAMD64KMOVWstore, ssa.OpAMD64KMOVDstore, ssa.OpAMD64KMOVQstore: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdOrMaskReg(v.Args[1]) + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + + case ssa.OpAMD64VPMASK32load128, ssa.OpAMD64VPMASK64load128, ssa.OpAMD64VPMASK32load256, ssa.OpAMD64VPMASK64load256: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + p.AddRestSourceReg(simdReg(v.Args[1])) // masking simd reg + + case ssa.OpAMD64VPMASK32store128, ssa.OpAMD64VPMASK64store128, ssa.OpAMD64VPMASK32store256, ssa.OpAMD64VPMASK64store256: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[2]) + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + p.AddRestSourceReg(simdReg(v.Args[1])) // masking simd reg + + case ssa.OpAMD64VPMASK64load512, ssa.OpAMD64VPMASK32load512, ssa.OpAMD64VPMASK16load512, ssa.OpAMD64VPMASK8load512: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + p.AddRestSourceReg(v.Args[1].Reg()) // simd mask reg + x86.ParseSuffix(p, "Z") // must be zero if not in mask + + case ssa.OpAMD64VPMASK64store512, ssa.OpAMD64VPMASK32store512, ssa.OpAMD64VPMASK16store512, ssa.OpAMD64VPMASK8store512: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[2]) + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + p.AddRestSourceReg(v.Args[1].Reg()) // simd mask reg + + case ssa.OpAMD64VPMOVMToVec8x16, + ssa.OpAMD64VPMOVMToVec8x32, + ssa.OpAMD64VPMOVMToVec8x64, + ssa.OpAMD64VPMOVMToVec16x8, + ssa.OpAMD64VPMOVMToVec16x16, + ssa.OpAMD64VPMOVMToVec16x32, + ssa.OpAMD64VPMOVMToVec32x4, + ssa.OpAMD64VPMOVMToVec32x8, + ssa.OpAMD64VPMOVMToVec32x16, + ssa.OpAMD64VPMOVMToVec64x2, + ssa.OpAMD64VPMOVMToVec64x4, + ssa.OpAMD64VPMOVMToVec64x8: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + + case ssa.OpAMD64VPMOVVec8x16ToM, + ssa.OpAMD64VPMOVVec8x32ToM, + ssa.OpAMD64VPMOVVec8x64ToM, + ssa.OpAMD64VPMOVVec16x8ToM, + ssa.OpAMD64VPMOVVec16x16ToM, + ssa.OpAMD64VPMOVVec16x32ToM, + ssa.OpAMD64VPMOVVec32x4ToM, + ssa.OpAMD64VPMOVVec32x8ToM, + ssa.OpAMD64VPMOVVec32x16ToM, + ssa.OpAMD64VPMOVVec64x2ToM, + ssa.OpAMD64VPMOVVec64x4ToM, + ssa.OpAMD64VPMOVVec64x8ToM, + ssa.OpAMD64VPMOVMSKB128, + ssa.OpAMD64VPMOVMSKB256, + ssa.OpAMD64VMOVMSKPS128, + ssa.OpAMD64VMOVMSKPS256, + ssa.OpAMD64VMOVMSKPD128, + ssa.OpAMD64VMOVMSKPD256: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpAMD64KMOVQk, ssa.OpAMD64KMOVDk, ssa.OpAMD64KMOVWk, ssa.OpAMD64KMOVBk, + ssa.OpAMD64KMOVQi, ssa.OpAMD64KMOVDi, ssa.OpAMD64KMOVWi, ssa.OpAMD64KMOVBi: + // See also ssa.OpAMD64KMOVQload + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpAMD64VPTEST: + // Some instructions setting flags put their second operand into the destination reg. + // See also CMP[BWDQ]. + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v.Args[1]) + + default: + if !ssaGenSIMDValue(s, v) { + v.Fatalf("genValue not implemented: %s", v.LongString()) + } + } +} + +// zeroX15 zeroes the X15 register. +func zeroX15(s *ssagen.State) { + opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15) +} + +// Example instruction: VRSQRTPS X1, X1 +func simdV11(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPSUBD X1, X2, X3 +func simdV21(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + // Vector registers operands follows a right-to-left order. + // e.g. VPSUBD X1, X2, X3 means X3 = X2 - X1. + p.From.Reg = simdReg(v.Args[1]) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// This function is to accustomize the shifts. +// The 2nd arg is an XMM, and this function merely checks that. +// Example instruction: VPSLLQ Z1, X1, Z2 +func simdVfpv(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + // Vector registers operands follows a right-to-left order. + // e.g. VPSUBD X1, X2, X3 means X3 = X2 - X1. + p.From.Reg = v.Args[1].Reg() + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPCMPEQW Z26, Z30, K4 +func simdV2k(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[1]) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = maskReg(v) + return p +} + +// Example instruction: VPMINUQ X21, X3, K3, X31 +func simdV2kv(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[1]) + p.AddRestSourceReg(simdReg(v.Args[0])) + // These "simd*" series of functions assumes: + // Any "K" register that serves as the write-mask + // or "predicate" for "predicated AVX512 instructions" + // sits right at the end of the operand list. + // TODO: verify this assumption. + p.AddRestSourceReg(maskReg(v.Args[2])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPABSB X1, X2, K3 (masking merging) +func simdV2kvResultInArg0(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[1]) + // These "simd*" series of functions assumes: + // Any "K" register that serves as the write-mask + // or "predicate" for "predicated AVX512 instructions" + // sits right at the end of the operand list. + // TODO: verify this assumption. + p.AddRestSourceReg(maskReg(v.Args[2])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// This function is to accustomize the shifts. +// The 2nd arg is an XMM, and this function merely checks that. +// Example instruction: VPSLLQ Z1, X1, K1, Z2 +func simdVfpkv(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.AddRestSourceReg(simdReg(v.Args[0])) + p.AddRestSourceReg(maskReg(v.Args[2])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPCMPEQW Z26, Z30, K1, K4 +func simdV2kk(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[1]) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.AddRestSourceReg(maskReg(v.Args[2])) + p.To.Type = obj.TYPE_REG + p.To.Reg = maskReg(v) + return p +} + +// Example instruction: VPOPCNTB X14, K4, X16 +func simdVkv(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[0]) + p.AddRestSourceReg(maskReg(v.Args[1])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VROUNDPD $7, X2, X2 +func simdV11Imm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Offset = int64(v.AuxUInt8()) + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VREDUCEPD $126, X1, K3, X31 +func simdVkvImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Offset = int64(v.AuxUInt8()) + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(simdReg(v.Args[0])) + p.AddRestSourceReg(maskReg(v.Args[1])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VCMPPS $7, X2, X9, X2 +func simdV21Imm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Offset = int64(v.AuxUInt8()) + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(simdReg(v.Args[1])) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPINSRB $3, DX, X0, X0 +func simdVgpvImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Offset = int64(v.AuxUInt8()) + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(v.Args[1].Reg()) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPCMPD $1, Z1, Z2, K1 +func simdV2kImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Offset = int64(v.AuxUInt8()) + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(simdReg(v.Args[1])) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = maskReg(v) + return p +} + +// Example instruction: VPCMPD $1, Z1, Z2, K2, K1 +func simdV2kkImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Offset = int64(v.AuxUInt8()) + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(simdReg(v.Args[1])) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.AddRestSourceReg(maskReg(v.Args[2])) + p.To.Type = obj.TYPE_REG + p.To.Reg = maskReg(v) + return p +} + +func simdV2kvImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Offset = int64(v.AuxUInt8()) + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(simdReg(v.Args[1])) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.AddRestSourceReg(maskReg(v.Args[2])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VFMADD213PD Z2, Z1, Z0 +func simdV31ResultInArg0(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[2]) + p.AddRestSourceReg(simdReg(v.Args[1])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +func simdV31ResultInArg0Imm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Offset = int64(v.AuxUInt8()) + p.From.Type = obj.TYPE_CONST + + p.AddRestSourceReg(simdReg(v.Args[2])) + p.AddRestSourceReg(simdReg(v.Args[1])) + // p.AddRestSourceReg(x86.REG_K0) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// v31loadResultInArg0Imm8 +// Example instruction: +// for (VPTERNLOGD128load {sym} [makeValAndOff(int32(int8(c)),off)] x y ptr mem) +func simdV31loadResultInArg0Imm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + sc := v.AuxValAndOff() + p := s.Prog(v.Op.Asm()) + + p.From.Type = obj.TYPE_CONST + p.From.Offset = sc.Val64() + + m := obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[2].Reg()} + ssagen.AddAux2(&m, v, sc.Off64()) + p.AddRestSource(m) + + p.AddRestSourceReg(simdReg(v.Args[1])) + return p +} + +// Example instruction: VFMADD213PD Z2, Z1, K1, Z0 +func simdV3kvResultInArg0(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[2]) + p.AddRestSourceReg(simdReg(v.Args[1])) + p.AddRestSourceReg(maskReg(v.Args[3])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +func simdVgpImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Offset = int64(v.AuxUInt8()) + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + return p +} + +// Currently unused +func simdV31(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[2]) + p.AddRestSourceReg(simdReg(v.Args[1])) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Currently unused +func simdV3kv(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[2]) + p.AddRestSourceReg(simdReg(v.Args[1])) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.AddRestSourceReg(maskReg(v.Args[3])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VRCP14PS (DI), K6, X22 +func simdVkvload(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.AddRestSourceReg(maskReg(v.Args[1])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPSLLVD (DX), X7, X18 +func simdV21load(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[1].Reg() + ssagen.AddAux(&p.From, v) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPDPWSSD (SI), X24, X18 +func simdV31loadResultInArg0(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[2].Reg() + ssagen.AddAux(&p.From, v) + p.AddRestSourceReg(simdReg(v.Args[1])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPDPWSSD (SI), X24, K1, X18 +func simdV3kvloadResultInArg0(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[2].Reg() + ssagen.AddAux(&p.From, v) + p.AddRestSourceReg(simdReg(v.Args[1])) + p.AddRestSourceReg(maskReg(v.Args[3])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPSLLVD (SI), X1, K1, X2 +func simdV2kvload(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[1].Reg() + ssagen.AddAux(&p.From, v) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.AddRestSourceReg(maskReg(v.Args[2])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPCMPEQD (SI), X1, K1 +func simdV2kload(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[1].Reg() + ssagen.AddAux(&p.From, v) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = maskReg(v) + return p +} + +// Example instruction: VCVTTPS2DQ (BX), X2 +func simdV11load(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPSHUFD $7, (BX), X11 +func simdV11loadImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + sc := v.AuxValAndOff() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = sc.Val64() + m := obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[0].Reg()} + ssagen.AddAux2(&m, v, sc.Off64()) + p.AddRestSource(m) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPRORD $81, -15(R14), K7, Y1 +func simdVkvloadImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + sc := v.AuxValAndOff() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = sc.Val64() + m := obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[0].Reg()} + ssagen.AddAux2(&m, v, sc.Off64()) + p.AddRestSource(m) + p.AddRestSourceReg(maskReg(v.Args[1])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VPSHLDD $82, 7(SI), Y21, Y3 +func simdV21loadImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + sc := v.AuxValAndOff() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = sc.Val64() + m := obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[1].Reg()} + ssagen.AddAux2(&m, v, sc.Off64()) + p.AddRestSource(m) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: VCMPPS $81, -7(DI), Y16, K3 +func simdV2kloadImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + sc := v.AuxValAndOff() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = sc.Val64() + m := obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[1].Reg()} + ssagen.AddAux2(&m, v, sc.Off64()) + p.AddRestSource(m) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.To.Type = obj.TYPE_REG + p.To.Reg = maskReg(v) + return p +} + +// Example instruction: VCMPPS $81, -7(DI), Y16, K1, K3 +func simdV2kkloadImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + sc := v.AuxValAndOff() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = sc.Val64() + m := obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[1].Reg()} + ssagen.AddAux2(&m, v, sc.Off64()) + p.AddRestSource(m) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.AddRestSourceReg(maskReg(v.Args[2])) + p.To.Type = obj.TYPE_REG + p.To.Reg = maskReg(v) + return p +} + +// Example instruction: VGF2P8AFFINEINVQB $64, -17(BP), X31, K3, X26 +func simdV2kvloadImm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + sc := v.AuxValAndOff() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = sc.Val64() + m := obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[1].Reg()} + ssagen.AddAux2(&m, v, sc.Off64()) + p.AddRestSource(m) + p.AddRestSourceReg(simdReg(v.Args[0])) + p.AddRestSourceReg(maskReg(v.Args[2])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: SHA1NEXTE X2, X2 +func simdV21ResultInArg0(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = simdReg(v.Args[1]) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: SHA1RNDS4 $1, X2, X2 +func simdV21ResultInArg0Imm8(s *ssagen.State, v *ssa.Value) *obj.Prog { + p := s.Prog(v.Op.Asm()) + p.From.Offset = int64(v.AuxUInt8()) + p.From.Type = obj.TYPE_CONST + p.AddRestSourceReg(simdReg(v.Args[1])) + p.To.Type = obj.TYPE_REG + p.To.Reg = simdReg(v) + return p +} + +// Example instruction: SHA256RNDS2 X0, X11, X2 +func simdV31x0AtIn2ResultInArg0(s *ssagen.State, v *ssa.Value) *obj.Prog { + return simdV31ResultInArg0(s, v) +} + +var blockJump = [...]struct { + asm, invasm obj.As +}{ + ssa.BlockAMD64EQ: {x86.AJEQ, x86.AJNE}, + ssa.BlockAMD64NE: {x86.AJNE, x86.AJEQ}, + ssa.BlockAMD64LT: {x86.AJLT, x86.AJGE}, + ssa.BlockAMD64GE: {x86.AJGE, x86.AJLT}, + ssa.BlockAMD64LE: {x86.AJLE, x86.AJGT}, + ssa.BlockAMD64GT: {x86.AJGT, x86.AJLE}, + ssa.BlockAMD64OS: {x86.AJOS, x86.AJOC}, + ssa.BlockAMD64OC: {x86.AJOC, x86.AJOS}, + ssa.BlockAMD64ULT: {x86.AJCS, x86.AJCC}, + ssa.BlockAMD64UGE: {x86.AJCC, x86.AJCS}, + ssa.BlockAMD64UGT: {x86.AJHI, x86.AJLS}, + ssa.BlockAMD64ULE: {x86.AJLS, x86.AJHI}, + ssa.BlockAMD64ORD: {x86.AJPC, x86.AJPS}, + ssa.BlockAMD64NAN: {x86.AJPS, x86.AJPC}, +} + +var eqfJumps = [2][2]ssagen.IndexJump{ + {{Jump: x86.AJNE, Index: 1}, {Jump: x86.AJPS, Index: 1}}, // next == b.Succs[0] + {{Jump: x86.AJNE, Index: 1}, {Jump: x86.AJPC, Index: 0}}, // next == b.Succs[1] +} +var nefJumps = [2][2]ssagen.IndexJump{ + {{Jump: x86.AJNE, Index: 0}, {Jump: x86.AJPC, Index: 1}}, // next == b.Succs[0] + {{Jump: x86.AJNE, Index: 0}, {Jump: x86.AJPS, Index: 0}}, // next == b.Succs[1] +} + +func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) { + switch b.Kind { + case ssa.BlockPlain, ssa.BlockDefer: + if b.Succs[0].Block() != next { + p := s.Prog(obj.AJMP) + p.To.Type = obj.TYPE_BRANCH + s.Branches = append(s.Branches, ssagen.Branch{P: p, B: b.Succs[0].Block()}) + } + case ssa.BlockExit, ssa.BlockRetJmp: + case ssa.BlockRet: + s.Prog(obj.ARET) + + case ssa.BlockAMD64EQF: + s.CombJump(b, next, &eqfJumps) + + case ssa.BlockAMD64NEF: + s.CombJump(b, next, &nefJumps) + + case ssa.BlockAMD64EQ, ssa.BlockAMD64NE, + ssa.BlockAMD64LT, ssa.BlockAMD64GE, + ssa.BlockAMD64LE, ssa.BlockAMD64GT, + ssa.BlockAMD64OS, ssa.BlockAMD64OC, + ssa.BlockAMD64ULT, ssa.BlockAMD64UGT, + ssa.BlockAMD64ULE, ssa.BlockAMD64UGE: + jmp := blockJump[b.Kind] + switch next { + case b.Succs[0].Block(): + s.Br(jmp.invasm, b.Succs[1].Block()) + case b.Succs[1].Block(): + s.Br(jmp.asm, b.Succs[0].Block()) + default: + if b.Likely != ssa.BranchUnlikely { + s.Br(jmp.asm, b.Succs[0].Block()) + s.Br(obj.AJMP, b.Succs[1].Block()) + } else { + s.Br(jmp.invasm, b.Succs[1].Block()) + s.Br(obj.AJMP, b.Succs[0].Block()) + } + } + + case ssa.BlockAMD64JUMPTABLE: + // JMP *(TABLE)(INDEX*8) + p := s.Prog(obj.AJMP) + p.To.Type = obj.TYPE_MEM + p.To.Reg = b.Controls[1].Reg() + p.To.Index = b.Controls[0].Reg() + p.To.Scale = 8 + // Save jump tables for later resolution of the target blocks. + s.JumpTables = append(s.JumpTables, b) + + default: + b.Fatalf("branch not implemented: %s", b.LongString()) + } +} + +func loadRegResult(s *ssagen.State, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p := s.Prog(loadByRegWidth(reg, t.Size())) + p.From.Type = obj.TYPE_MEM + p.From.Name = obj.NAME_AUTO + p.From.Sym = n.Linksym() + p.From.Offset = n.FrameOffset() + off + p.To.Type = obj.TYPE_REG + p.To.Reg = reg + return p +} + +func spillArgReg(pp *objw.Progs, p *obj.Prog, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p = pp.Append(p, storeByRegWidth(reg, t.Size()), obj.TYPE_REG, reg, 0, obj.TYPE_MEM, 0, n.FrameOffset()+off) + p.To.Name = obj.NAME_PARAM + p.To.Sym = n.Linksym() + p.Pos = p.Pos.WithNotStmt() + return p +} + +// zero 16 bytes at reg+off. +func zero16(s *ssagen.State, reg int16, off int64) { + // MOVUPS X15, off(ptrReg) + p := s.Prog(x86.AMOVUPS) + p.From.Type = obj.TYPE_REG + p.From.Reg = x86.REG_X15 + p.To.Type = obj.TYPE_MEM + p.To.Reg = reg + p.To.Offset = off +} + +// move 16 bytes from src+off to dst+off using temporary register tmp. +func move16(s *ssagen.State, src, dst, tmp int16, off int64) { + // MOVUPS off(srcReg), tmpReg + // MOVUPS tmpReg, off(dstReg) + p := s.Prog(x86.AMOVUPS) + p.From.Type = obj.TYPE_MEM + p.From.Reg = src + p.From.Offset = off + p.To.Type = obj.TYPE_REG + p.To.Reg = tmp + p = s.Prog(x86.AMOVUPS) + p.From.Type = obj.TYPE_REG + p.From.Reg = tmp + p.To.Type = obj.TYPE_MEM + p.To.Reg = dst + p.To.Offset = off +} + +// XXX maybe make this part of v.Reg? +// On the other hand, it is architecture-specific. +func simdReg(v *ssa.Value) int16 { + t := v.Type + if !t.IsSIMD() { + base.Fatalf("simdReg: not a simd type; v=%s, b=b%d, f=%s", v.LongString(), v.Block.ID, v.Block.Func.Name) + } + return simdRegBySize(v.Reg(), t.Size()) +} + +func simdRegBySize(reg int16, size int64) int16 { + switch size { + case 16: + return reg + case 32: + return reg + (x86.REG_Y0 - x86.REG_X0) + case 64: + return reg + (x86.REG_Z0 - x86.REG_X0) + } + panic("simdRegBySize: bad size") +} + +// XXX k mask +func maskReg(v *ssa.Value) int16 { + t := v.Type + if !t.IsSIMD() { + base.Fatalf("maskReg: not a simd type; v=%s, b=b%d, f=%s", v.LongString(), v.Block.ID, v.Block.Func.Name) + } + switch t.Size() { + case 8: + return v.Reg() + } + panic("unreachable") +} + +// XXX k mask + vec +func simdOrMaskReg(v *ssa.Value) int16 { + t := v.Type + if t.Size() <= 8 { + return maskReg(v) + } + return simdReg(v) +} + +// XXX this is used for shift operations only. +// regalloc will issue OpCopy with incorrect type, but the assigned +// register should be correct, and this function is merely checking +// the sanity of this part. +func simdCheckRegOnly(v *ssa.Value, regStart, regEnd int16) int16 { + if v.Reg() > regEnd || v.Reg() < regStart { + panic("simdCheckRegOnly: not the desired register") + } + return v.Reg() +} diff --git a/go/src/cmd/compile/internal/amd64/versions_test.go b/go/src/cmd/compile/internal/amd64/versions_test.go new file mode 100644 index 0000000000000000000000000000000000000000..15395fc5e5283faec8afa2d7f75c1fdb14060986 --- /dev/null +++ b/go/src/cmd/compile/internal/amd64/versions_test.go @@ -0,0 +1,434 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// When using GOEXPERIMENT=boringcrypto, the test program links in the boringcrypto syso, +// which does not respect GOAMD64, so we skip the test if boringcrypto is enabled. +//go:build !boringcrypto + +package amd64_test + +import ( + "bufio" + "debug/elf" + "debug/macho" + "errors" + "fmt" + "go/build" + "internal/testenv" + "io" + "math" + "math/bits" + "os" + "os/exec" + "regexp" + "runtime" + "strconv" + "strings" + "testing" +) + +// Test to make sure that when building for GOAMD64=v1, we don't +// use any >v1 instructions. +func TestGoAMD64v1(t *testing.T) { + if runtime.GOARCH != "amd64" { + t.Skip("amd64-only test") + } + if runtime.GOOS != "linux" && runtime.GOOS != "darwin" { + t.Skip("test only works on elf or macho platforms") + } + for _, tag := range build.Default.ToolTags { + if tag == "amd64.v2" { + t.Skip("compiling for GOAMD64=v2 or higher") + } + } + if os.Getenv("TESTGOAMD64V1") != "" { + t.Skip("recursive call") + } + + // Make a binary which will be a modified version of the + // currently running binary. + dst, err := os.CreateTemp("", "TestGoAMD64v1") + if err != nil { + t.Fatalf("failed to create temp file: %v", err) + } + defer os.Remove(dst.Name()) + dst.Chmod(0500) // make executable + + // Clobber all the non-v1 opcodes. + opcodes := map[string]bool{} + var features []string + for feature, opcodeList := range featureToOpcodes { + if runtimeFeatures[feature] { + features = append(features, fmt.Sprintf("cpu.%s=off", feature)) + } + for _, op := range opcodeList { + opcodes[op] = true + } + } + clobber(t, os.Args[0], dst, opcodes) + if err = dst.Close(); err != nil { + t.Fatalf("can't close binary: %v", err) + } + + // Run the resulting binary. + cmd := testenv.Command(t, dst.Name()) + testenv.CleanCmdEnv(cmd) + cmd.Env = append(cmd.Env, "TESTGOAMD64V1=yes") + // Disable FIPS 140-3 mode, since it would detect the modified binary. + cmd.Env = append(cmd.Env, fmt.Sprintf("GODEBUG=%s,fips140=off", strings.Join(features, ","))) + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("couldn't execute test: %s\n%s", err, out) + } + // Expect to see output of the form "PASS\n", unless the test binary + // was compiled for coverage (in which case there will be an extra line). + success := false + lines := strings.Split(string(out), "\n") + if len(lines) == 2 { + success = lines[0] == "PASS" && lines[1] == "" + } else if len(lines) == 3 { + success = lines[0] == "PASS" && + strings.HasPrefix(lines[1], "coverage") && lines[2] == "" + } + if !success { + t.Fatalf("test reported error: %s lines=%+v", string(out), lines) + } +} + +// Clobber copies the binary src to dst, replacing all the instructions in opcodes with +// faulting instructions. +func clobber(t *testing.T, src string, dst *os.File, opcodes map[string]bool) { + // Run objdump to get disassembly. + var re *regexp.Regexp + var disasm io.Reader + if false { + // TODO: go tool objdump doesn't disassemble the bmi1 instructions + // in question correctly. See issue 48584. + cmd := testenv.Command(t, "go", "tool", "objdump", src) + var err error + disasm, err = cmd.StdoutPipe() + if err != nil { + t.Fatal(err) + } + if err := cmd.Start(); err != nil { + t.Fatal(err) + } + t.Cleanup(func() { + if err := cmd.Wait(); err != nil { + t.Error(err) + } + }) + re = regexp.MustCompile(`^[^:]*:[-\d]+\s+0x([\da-f]+)\s+([\da-f]+)\s+([A-Z]+)`) + } else { + // TODO: we're depending on platform-native objdump here. Hence the Skipf + // below if it doesn't run for some reason. + cmd := testenv.Command(t, "objdump", "-d", src) + var err error + disasm, err = cmd.StdoutPipe() + if err != nil { + t.Fatal(err) + } + if err := cmd.Start(); err != nil { + if errors.Is(err, exec.ErrNotFound) { + t.Skipf("can't run test due to missing objdump: %s", err) + } + t.Fatal(err) + } + t.Cleanup(func() { + if err := cmd.Wait(); err != nil { + t.Error(err) + } + }) + re = regexp.MustCompile(`^\s*([\da-f]+):\s*((?:[\da-f][\da-f] )+)\s*([a-z\d]+)`) + } + + // Find all the instruction addresses we need to edit. + virtualEdits := map[uint64]bool{} + scanner := bufio.NewScanner(disasm) + for scanner.Scan() { + line := scanner.Text() + parts := re.FindStringSubmatch(line) + if len(parts) == 0 { + continue + } + addr, err := strconv.ParseUint(parts[1], 16, 64) + if err != nil { + continue // not a hex address + } + opcode := strings.ToLower(parts[3]) + if !opcodes[opcode] { + continue + } + t.Logf("clobbering instruction %s", line) + n := (len(parts[2]) - strings.Count(parts[2], " ")) / 2 // number of bytes in instruction encoding + for i := 0; i < n; i++ { + // Only really need to make the first byte faulting, but might + // as well make all the bytes faulting. + virtualEdits[addr+uint64(i)] = true + } + } + + // Figure out where in the binary the edits must be done. + physicalEdits := map[uint64]bool{} + if e, err := elf.Open(src); err == nil { + for _, sec := range e.Sections { + vaddr := sec.Addr + paddr := sec.Offset + size := sec.Size + for a := range virtualEdits { + if a >= vaddr && a < vaddr+size { + physicalEdits[paddr+(a-vaddr)] = true + } + } + } + } else if m, err2 := macho.Open(src); err2 == nil { + for _, sec := range m.Sections { + vaddr := sec.Addr + paddr := uint64(sec.Offset) + size := sec.Size + for a := range virtualEdits { + if a >= vaddr && a < vaddr+size { + physicalEdits[paddr+(a-vaddr)] = true + } + } + } + } else { + t.Log(err) + t.Log(err2) + t.Fatal("executable format not elf or macho") + } + if len(virtualEdits) != len(physicalEdits) { + t.Fatal("couldn't find an instruction in text sections") + } + + // Copy source to destination, making edits along the way. + f, err := os.Open(src) + if err != nil { + t.Fatal(err) + } + r := bufio.NewReader(f) + w := bufio.NewWriter(dst) + a := uint64(0) + done := 0 + for { + b, err := r.ReadByte() + if err == io.EOF { + break + } + if err != nil { + t.Fatal("can't read") + } + if physicalEdits[a] { + b = 0xcc // INT3 opcode + done++ + } + err = w.WriteByte(b) + if err != nil { + t.Fatal("can't write") + } + a++ + } + if done != len(physicalEdits) { + t.Fatal("physical edits remaining") + } + w.Flush() + f.Close() +} + +func setOf(keys ...string) map[string]bool { + m := make(map[string]bool, len(keys)) + for _, key := range keys { + m[key] = true + } + return m +} + +var runtimeFeatures = setOf( + "adx", "aes", "avx", "avx2", "bmi1", "bmi2", "erms", "fma", + "pclmulqdq", "popcnt", "rdtscp", "sse3", "sse41", "sse42", "ssse3", +) + +var featureToOpcodes = map[string][]string{ + // Note: we include *q, *l, and plain opcodes here. + // go tool objdump doesn't include a [QL] on popcnt instructions, until CL 351889 + // native objdump doesn't include [QL] on linux. + "popcnt": {"popcntq", "popcntl", "popcnt"}, + "bmi1": { + "andnq", "andnl", "andn", + "blsiq", "blsil", "blsi", + "blsmskq", "blsmskl", "blsmsk", + "blsrq", "blsrl", "blsr", + "tzcntq", "tzcntl", "tzcnt", + }, + "bmi2": { + "sarxq", "sarxl", "sarx", + "shlxq", "shlxl", "shlx", + "shrxq", "shrxl", "shrx", + }, + "sse41": { + "roundsd", + "pinsrq", "pinsrl", "pinsrd", "pinsrb", "pinsr", + "pextrq", "pextrl", "pextrd", "pextrb", "pextr", + "pminsb", "pminsd", "pminuw", "pminud", // Note: ub and sw are ok. + "pmaxsb", "pmaxsd", "pmaxuw", "pmaxud", + "pmovzxbw", "pmovzxbd", "pmovzxbq", "pmovzxwd", "pmovzxwq", "pmovzxdq", + "pmovsxbw", "pmovsxbd", "pmovsxbq", "pmovsxwd", "pmovsxwq", "pmovsxdq", + "pblendvb", + }, + "fma": {"vfmadd231sd"}, + "movbe": {"movbeqq", "movbeq", "movbell", "movbel", "movbe"}, + "lzcnt": {"lzcntq", "lzcntl", "lzcnt"}, +} + +// Test to use POPCNT instruction, if available +func TestPopCnt(t *testing.T) { + for _, tt := range []struct { + x uint64 + want int + }{ + {0b00001111, 4}, + {0b00001110, 3}, + {0b00001100, 2}, + {0b00000000, 0}, + } { + if got := bits.OnesCount64(tt.x); got != tt.want { + t.Errorf("OnesCount64(%#x) = %d, want %d", tt.x, got, tt.want) + } + if got := bits.OnesCount32(uint32(tt.x)); got != tt.want { + t.Errorf("OnesCount32(%#x) = %d, want %d", tt.x, got, tt.want) + } + } +} + +// Test to use ANDN, if available +func TestAndNot(t *testing.T) { + for _, tt := range []struct { + x, y, want uint64 + }{ + {0b00001111, 0b00000011, 0b1100}, + {0b00001111, 0b00001100, 0b0011}, + {0b00000000, 0b00000000, 0b0000}, + } { + if got := tt.x &^ tt.y; got != tt.want { + t.Errorf("%#x &^ %#x = %#x, want %#x", tt.x, tt.y, got, tt.want) + } + if got := uint32(tt.x) &^ uint32(tt.y); got != uint32(tt.want) { + t.Errorf("%#x &^ %#x = %#x, want %#x", tt.x, tt.y, got, tt.want) + } + } +} + +// Test to use BLSI, if available +func TestBLSI(t *testing.T) { + for _, tt := range []struct { + x, want uint64 + }{ + {0b00001111, 0b001}, + {0b00001110, 0b010}, + {0b00001100, 0b100}, + {0b11000110, 0b010}, + {0b00000000, 0b000}, + } { + if got := tt.x & -tt.x; got != tt.want { + t.Errorf("%#x & (-%#x) = %#x, want %#x", tt.x, tt.x, got, tt.want) + } + if got := uint32(tt.x) & -uint32(tt.x); got != uint32(tt.want) { + t.Errorf("%#x & (-%#x) = %#x, want %#x", tt.x, tt.x, got, tt.want) + } + } +} + +// Test to use BLSMSK, if available +func TestBLSMSK(t *testing.T) { + for _, tt := range []struct { + x, want uint64 + }{ + {0b00001111, 0b001}, + {0b00001110, 0b011}, + {0b00001100, 0b111}, + {0b11000110, 0b011}, + {0b00000000, 1<<64 - 1}, + } { + if got := tt.x ^ (tt.x - 1); got != tt.want { + t.Errorf("%#x ^ (%#x-1) = %#x, want %#x", tt.x, tt.x, got, tt.want) + } + if got := uint32(tt.x) ^ (uint32(tt.x) - 1); got != uint32(tt.want) { + t.Errorf("%#x ^ (%#x-1) = %#x, want %#x", tt.x, tt.x, got, uint32(tt.want)) + } + } +} + +// Test to use BLSR, if available +func TestBLSR(t *testing.T) { + for _, tt := range []struct { + x, want uint64 + }{ + {0b00001111, 0b00001110}, + {0b00001110, 0b00001100}, + {0b00001100, 0b00001000}, + {0b11000110, 0b11000100}, + {0b00000000, 0b00000000}, + } { + if got := tt.x & (tt.x - 1); got != tt.want { + t.Errorf("%#x & (%#x-1) = %#x, want %#x", tt.x, tt.x, got, tt.want) + } + if got := uint32(tt.x) & (uint32(tt.x) - 1); got != uint32(tt.want) { + t.Errorf("%#x & (%#x-1) = %#x, want %#x", tt.x, tt.x, got, tt.want) + } + } +} + +func TestTrailingZeros(t *testing.T) { + for _, tt := range []struct { + x uint64 + want int + }{ + {0b00001111, 0}, + {0b00001110, 1}, + {0b00001100, 2}, + {0b00001000, 3}, + {0b00000000, 64}, + } { + if got := bits.TrailingZeros64(tt.x); got != tt.want { + t.Errorf("TrailingZeros64(%#x) = %d, want %d", tt.x, got, tt.want) + } + want := tt.want + if want == 64 { + want = 32 + } + if got := bits.TrailingZeros32(uint32(tt.x)); got != want { + t.Errorf("TrailingZeros64(%#x) = %d, want %d", tt.x, got, want) + } + } +} + +func TestRound(t *testing.T) { + for _, tt := range []struct { + x, want float64 + }{ + {1.4, 1}, + {1.5, 2}, + {1.6, 2}, + {2.4, 2}, + {2.5, 2}, + {2.6, 3}, + } { + if got := math.RoundToEven(tt.x); got != tt.want { + t.Errorf("RoundToEven(%f) = %f, want %f", tt.x, got, tt.want) + } + } +} + +func TestFMA(t *testing.T) { + for _, tt := range []struct { + x, y, z, want float64 + }{ + {2, 3, 4, 10}, + {3, 4, 5, 17}, + } { + if got := math.FMA(tt.x, tt.y, tt.z); got != tt.want { + t.Errorf("FMA(%f,%f,%f) = %f, want %f", tt.x, tt.y, tt.z, got, tt.want) + } + } +} diff --git a/go/src/cmd/compile/internal/arm/galign.go b/go/src/cmd/compile/internal/arm/galign.go new file mode 100644 index 0000000000000000000000000000000000000000..43d811832eb82c427508a99c887ce6e31d85d08f --- /dev/null +++ b/go/src/cmd/compile/internal/arm/galign.go @@ -0,0 +1,25 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package arm + +import ( + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/internal/obj/arm" + "internal/buildcfg" +) + +func Init(arch *ssagen.ArchInfo) { + arch.LinkArch = &arm.Linkarm + arch.REGSP = arm.REGSP + arch.MAXWIDTH = (1 << 32) - 1 + arch.SoftFloat = buildcfg.GOARM.SoftFloat + arch.ZeroRange = zerorange + arch.Ginsnop = ginsnop + + arch.SSAMarkMoves = func(s *ssagen.State, b *ssa.Block) {} + arch.SSAGenValue = ssaGenValue + arch.SSAGenBlock = ssaGenBlock +} diff --git a/go/src/cmd/compile/internal/arm/ggen.go b/go/src/cmd/compile/internal/arm/ggen.go new file mode 100644 index 0000000000000000000000000000000000000000..f2c676300a93a5531c2f160fb0dba7f121068683 --- /dev/null +++ b/go/src/cmd/compile/internal/arm/ggen.go @@ -0,0 +1,60 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package arm + +import ( + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/arm" +) + +func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, r0 *uint32) *obj.Prog { + if cnt == 0 { + return p + } + if *r0 == 0 { + p = pp.Append(p, arm.AMOVW, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, arm.REG_R0, 0) + *r0 = 1 + } + + if cnt < int64(4*types.PtrSize) { + for i := int64(0); i < cnt; i += int64(types.PtrSize) { + p = pp.Append(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REGSP, 4+off+i) + } + } else if cnt <= int64(128*types.PtrSize) { + p = pp.Append(p, arm.AADD, obj.TYPE_CONST, 0, 4+off, obj.TYPE_REG, arm.REG_R1, 0) + p.Reg = arm.REGSP + p = pp.Append(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0) + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.Duffzero + p.To.Offset = 4 * (128 - cnt/int64(types.PtrSize)) + } else { + p = pp.Append(p, arm.AADD, obj.TYPE_CONST, 0, 4+off, obj.TYPE_REG, arm.REG_R1, 0) + p.Reg = arm.REGSP + p = pp.Append(p, arm.AADD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, arm.REG_R2, 0) + p.Reg = arm.REG_R1 + p = pp.Append(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REG_R1, 4) + p1 := p + p.Scond |= arm.C_PBIT + p = pp.Append(p, arm.ACMP, obj.TYPE_REG, arm.REG_R1, 0, obj.TYPE_NONE, 0, 0) + p.Reg = arm.REG_R2 + p = pp.Append(p, arm.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0) + p.To.SetTarget(p1) + } + + return p +} + +func ginsnop(pp *objw.Progs) *obj.Prog { + p := pp.Prog(arm.AAND) + p.From.Type = obj.TYPE_REG + p.From.Reg = arm.REG_R0 + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REG_R0 + p.Scond = arm.C_SCOND_EQ + return p +} diff --git a/go/src/cmd/compile/internal/arm/ssa.go b/go/src/cmd/compile/internal/arm/ssa.go new file mode 100644 index 0000000000000000000000000000000000000000..b31ffa474bc6d3066005f3c6556f58e4b0e423ba --- /dev/null +++ b/go/src/cmd/compile/internal/arm/ssa.go @@ -0,0 +1,1115 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package arm + +import ( + "fmt" + "internal/buildcfg" + "math" + "math/bits" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/arm" + "internal/abi" +) + +// loadByType returns the load instruction of the given type. +func loadByType(t *types.Type) obj.As { + if t.IsFloat() { + switch t.Size() { + case 4: + return arm.AMOVF + case 8: + return arm.AMOVD + } + } else { + switch t.Size() { + case 1: + if t.IsSigned() { + return arm.AMOVB + } else { + return arm.AMOVBU + } + case 2: + if t.IsSigned() { + return arm.AMOVH + } else { + return arm.AMOVHU + } + case 4: + return arm.AMOVW + } + } + panic("bad load type") +} + +// storeByType returns the store instruction of the given type. +func storeByType(t *types.Type) obj.As { + if t.IsFloat() { + switch t.Size() { + case 4: + return arm.AMOVF + case 8: + return arm.AMOVD + } + } else { + switch t.Size() { + case 1: + return arm.AMOVB + case 2: + return arm.AMOVH + case 4: + return arm.AMOVW + } + } + panic("bad store type") +} + +// shift type is used as Offset in obj.TYPE_SHIFT operands to encode shifted register operands. +type shift int64 + +// copied from ../../../internal/obj/util.go:/TYPE_SHIFT +func (v shift) String() string { + op := "<<>>->@>"[((v>>5)&3)<<1:] + if v&(1<<4) != 0 { + // register shift + return fmt.Sprintf("R%d%c%cR%d", v&15, op[0], op[1], (v>>8)&15) + } else { + // constant shift + return fmt.Sprintf("R%d%c%c%d", v&15, op[0], op[1], (v>>7)&31) + } +} + +// makeshift encodes a register shifted by a constant. +func makeshift(v *ssa.Value, reg int16, typ int64, s int64) shift { + if s < 0 || s >= 32 { + v.Fatalf("shift out of range: %d", s) + } + return shift(int64(reg&0xf) | typ | (s&31)<<7) +} + +// genshift generates a Prog for r = r0 op (r1 shifted by n). +func genshift(s *ssagen.State, v *ssa.Value, as obj.As, r0, r1, r int16, typ int64, n int64) *obj.Prog { + p := s.Prog(as) + p.From.Type = obj.TYPE_SHIFT + p.From.Offset = int64(makeshift(v, r1, typ, n)) + p.Reg = r0 + if r != 0 { + p.To.Type = obj.TYPE_REG + p.To.Reg = r + } + return p +} + +// makeregshift encodes a register shifted by a register. +func makeregshift(r1 int16, typ int64, r2 int16) shift { + return shift(int64(r1&0xf) | typ | int64(r2&0xf)<<8 | 1<<4) +} + +// genregshift generates a Prog for r = r0 op (r1 shifted by r2). +func genregshift(s *ssagen.State, as obj.As, r0, r1, r2, r int16, typ int64) *obj.Prog { + p := s.Prog(as) + p.From.Type = obj.TYPE_SHIFT + p.From.Offset = int64(makeregshift(r1, typ, r2)) + p.Reg = r0 + if r != 0 { + p.To.Type = obj.TYPE_REG + p.To.Reg = r + } + return p +} + +// find a (lsb, width) pair for BFC +// lsb must be in [0, 31], width must be in [1, 32 - lsb] +// return (0xffffffff, 0) if v is not a binary like 0...01...10...0 +func getBFC(v uint32) (uint32, uint32) { + var m, l uint32 + // BFC is not applicable with zero + if v == 0 { + return 0xffffffff, 0 + } + // find the lowest set bit, for example l=2 for 0x3ffffffc + l = uint32(bits.TrailingZeros32(v)) + // m-1 represents the highest set bit index, for example m=30 for 0x3ffffffc + m = 32 - uint32(bits.LeadingZeros32(v)) + // check if v is a binary like 0...01...10...0 + if (1< l for non-zero v + return l, m - l + } + // invalid + return 0xffffffff, 0 +} + +func ssaGenValue(s *ssagen.State, v *ssa.Value) { + switch v.Op { + case ssa.OpCopy, ssa.OpARMMOVWreg: + if v.Type.IsMemory() { + return + } + x := v.Args[0].Reg() + y := v.Reg() + if x == y { + return + } + as := arm.AMOVW + if v.Type.IsFloat() { + switch v.Type.Size() { + case 4: + as = arm.AMOVF + case 8: + as = arm.AMOVD + default: + panic("bad float size") + } + } + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = x + p.To.Type = obj.TYPE_REG + p.To.Reg = y + case ssa.OpARMMOVWnop: + // nothing to do + case ssa.OpLoadReg: + if v.Type.IsFlags() { + v.Fatalf("load flags not implemented: %v", v.LongString()) + return + } + p := s.Prog(loadByType(v.Type)) + ssagen.AddrAuto(&p.From, v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpStoreReg: + if v.Type.IsFlags() { + v.Fatalf("store flags not implemented: %v", v.LongString()) + return + } + p := s.Prog(storeByType(v.Type)) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + ssagen.AddrAuto(&p.To, v) + case ssa.OpARMADD, + ssa.OpARMADC, + ssa.OpARMSUB, + ssa.OpARMSBC, + ssa.OpARMRSB, + ssa.OpARMAND, + ssa.OpARMOR, + ssa.OpARMXOR, + ssa.OpARMBIC, + ssa.OpARMMUL, + ssa.OpARMADDF, + ssa.OpARMADDD, + ssa.OpARMSUBF, + ssa.OpARMSUBD, + ssa.OpARMSLL, + ssa.OpARMSRL, + ssa.OpARMSRA, + ssa.OpARMMULF, + ssa.OpARMMULD, + ssa.OpARMNMULF, + ssa.OpARMNMULD, + ssa.OpARMDIVF, + ssa.OpARMDIVD: + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpARMSRR: + genregshift(s, arm.AMOVW, 0, v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm.SHIFT_RR) + case ssa.OpARMMULAF, ssa.OpARMMULAD, ssa.OpARMMULSF, ssa.OpARMMULSD, ssa.OpARMFMULAD: + r := v.Reg() + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + r2 := v.Args[2].Reg() + if r != r0 { + v.Fatalf("result and addend are not in the same register: %v", v.LongString()) + } + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpARMADDS, + ssa.OpARMADCS, + ssa.OpARMSUBS: + r := v.Reg0() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + p := s.Prog(v.Op.Asm()) + p.Scond = arm.C_SBIT + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpARMSRAcond: + // ARM shift instructions uses only the low-order byte of the shift amount + // generate conditional instructions to deal with large shifts + // flag is already set + // SRA.HS $31, Rarg0, Rdst // shift 31 bits to get the sign bit + // SRA.LO Rarg1, Rarg0, Rdst + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + p := s.Prog(arm.ASRA) + p.Scond = arm.C_SCOND_HS + p.From.Type = obj.TYPE_CONST + p.From.Offset = 31 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + p = s.Prog(arm.ASRA) + p.Scond = arm.C_SCOND_LO + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpARMBFX, ssa.OpARMBFXU: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt >> 8 + p.AddRestSourceConst(v.AuxInt & 0xff) + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMANDconst, ssa.OpARMBICconst: + // try to optimize ANDconst and BICconst to BFC, which saves bytes and ticks + // BFC is only available on ARMv7, and its result and source are in the same register + if buildcfg.GOARM.Version == 7 && v.Reg() == v.Args[0].Reg() { + var val uint32 + if v.Op == ssa.OpARMANDconst { + val = ^uint32(v.AuxInt) + } else { // BICconst + val = uint32(v.AuxInt) + } + lsb, width := getBFC(val) + // omit BFC for ARM's imm12 + if 8 < width && width < 24 { + p := s.Prog(arm.ABFC) + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(width) + p.AddRestSourceConst(int64(lsb)) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + break + } + } + // fall back to ordinary form + fallthrough + case ssa.OpARMADDconst, + ssa.OpARMADCconst, + ssa.OpARMSUBconst, + ssa.OpARMSBCconst, + ssa.OpARMRSBconst, + ssa.OpARMRSCconst, + ssa.OpARMORconst, + ssa.OpARMXORconst, + ssa.OpARMSLLconst, + ssa.OpARMSRLconst, + ssa.OpARMSRAconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMADDSconst, + ssa.OpARMSUBSconst, + ssa.OpARMRSBSconst: + p := s.Prog(v.Op.Asm()) + p.Scond = arm.C_SBIT + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + case ssa.OpARMSRRconst: + genshift(s, v, arm.AMOVW, 0, v.Args[0].Reg(), v.Reg(), arm.SHIFT_RR, v.AuxInt) + case ssa.OpARMADDshiftLL, + ssa.OpARMADCshiftLL, + ssa.OpARMSUBshiftLL, + ssa.OpARMSBCshiftLL, + ssa.OpARMRSBshiftLL, + ssa.OpARMRSCshiftLL, + ssa.OpARMANDshiftLL, + ssa.OpARMORshiftLL, + ssa.OpARMXORshiftLL, + ssa.OpARMBICshiftLL: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm.SHIFT_LL, v.AuxInt) + case ssa.OpARMADDSshiftLL, + ssa.OpARMSUBSshiftLL, + ssa.OpARMRSBSshiftLL: + p := genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg0(), arm.SHIFT_LL, v.AuxInt) + p.Scond = arm.C_SBIT + case ssa.OpARMADDshiftRL, + ssa.OpARMADCshiftRL, + ssa.OpARMSUBshiftRL, + ssa.OpARMSBCshiftRL, + ssa.OpARMRSBshiftRL, + ssa.OpARMRSCshiftRL, + ssa.OpARMANDshiftRL, + ssa.OpARMORshiftRL, + ssa.OpARMXORshiftRL, + ssa.OpARMBICshiftRL: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm.SHIFT_LR, v.AuxInt) + case ssa.OpARMADDSshiftRL, + ssa.OpARMSUBSshiftRL, + ssa.OpARMRSBSshiftRL: + p := genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg0(), arm.SHIFT_LR, v.AuxInt) + p.Scond = arm.C_SBIT + case ssa.OpARMADDshiftRA, + ssa.OpARMADCshiftRA, + ssa.OpARMSUBshiftRA, + ssa.OpARMSBCshiftRA, + ssa.OpARMRSBshiftRA, + ssa.OpARMRSCshiftRA, + ssa.OpARMANDshiftRA, + ssa.OpARMORshiftRA, + ssa.OpARMXORshiftRA, + ssa.OpARMBICshiftRA: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm.SHIFT_AR, v.AuxInt) + case ssa.OpARMADDSshiftRA, + ssa.OpARMSUBSshiftRA, + ssa.OpARMRSBSshiftRA: + p := genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg0(), arm.SHIFT_AR, v.AuxInt) + p.Scond = arm.C_SBIT + case ssa.OpARMXORshiftRR: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm.SHIFT_RR, v.AuxInt) + case ssa.OpARMMVNshiftLL: + genshift(s, v, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm.SHIFT_LL, v.AuxInt) + case ssa.OpARMMVNshiftRL: + genshift(s, v, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm.SHIFT_LR, v.AuxInt) + case ssa.OpARMMVNshiftRA: + genshift(s, v, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm.SHIFT_AR, v.AuxInt) + case ssa.OpARMMVNshiftLLreg: + genregshift(s, v.Op.Asm(), 0, v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm.SHIFT_LL) + case ssa.OpARMMVNshiftRLreg: + genregshift(s, v.Op.Asm(), 0, v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm.SHIFT_LR) + case ssa.OpARMMVNshiftRAreg: + genregshift(s, v.Op.Asm(), 0, v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm.SHIFT_AR) + case ssa.OpARMADDshiftLLreg, + ssa.OpARMADCshiftLLreg, + ssa.OpARMSUBshiftLLreg, + ssa.OpARMSBCshiftLLreg, + ssa.OpARMRSBshiftLLreg, + ssa.OpARMRSCshiftLLreg, + ssa.OpARMANDshiftLLreg, + ssa.OpARMORshiftLLreg, + ssa.OpARMXORshiftLLreg, + ssa.OpARMBICshiftLLreg: + genregshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Args[2].Reg(), v.Reg(), arm.SHIFT_LL) + case ssa.OpARMADDSshiftLLreg, + ssa.OpARMSUBSshiftLLreg, + ssa.OpARMRSBSshiftLLreg: + p := genregshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Args[2].Reg(), v.Reg0(), arm.SHIFT_LL) + p.Scond = arm.C_SBIT + case ssa.OpARMADDshiftRLreg, + ssa.OpARMADCshiftRLreg, + ssa.OpARMSUBshiftRLreg, + ssa.OpARMSBCshiftRLreg, + ssa.OpARMRSBshiftRLreg, + ssa.OpARMRSCshiftRLreg, + ssa.OpARMANDshiftRLreg, + ssa.OpARMORshiftRLreg, + ssa.OpARMXORshiftRLreg, + ssa.OpARMBICshiftRLreg: + genregshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Args[2].Reg(), v.Reg(), arm.SHIFT_LR) + case ssa.OpARMADDSshiftRLreg, + ssa.OpARMSUBSshiftRLreg, + ssa.OpARMRSBSshiftRLreg: + p := genregshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Args[2].Reg(), v.Reg0(), arm.SHIFT_LR) + p.Scond = arm.C_SBIT + case ssa.OpARMADDshiftRAreg, + ssa.OpARMADCshiftRAreg, + ssa.OpARMSUBshiftRAreg, + ssa.OpARMSBCshiftRAreg, + ssa.OpARMRSBshiftRAreg, + ssa.OpARMRSCshiftRAreg, + ssa.OpARMANDshiftRAreg, + ssa.OpARMORshiftRAreg, + ssa.OpARMXORshiftRAreg, + ssa.OpARMBICshiftRAreg: + genregshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Args[2].Reg(), v.Reg(), arm.SHIFT_AR) + case ssa.OpARMADDSshiftRAreg, + ssa.OpARMSUBSshiftRAreg, + ssa.OpARMRSBSshiftRAreg: + p := genregshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Args[2].Reg(), v.Reg0(), arm.SHIFT_AR) + p.Scond = arm.C_SBIT + case ssa.OpARMHMUL, + ssa.OpARMHMULU: + // 32-bit high multiplication + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REGREG + p.To.Reg = v.Reg() + p.To.Offset = arm.REGTMP // throw away low 32-bit into tmp register + case ssa.OpARMMULLU: + // 32-bit multiplication, results 64-bit, high 32-bit in out0, low 32-bit in out1 + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REGREG + p.To.Reg = v.Reg0() // high 32-bit + p.To.Offset = int64(v.Reg1()) // low 32-bit + case ssa.OpARMMULA, ssa.OpARMMULS: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REGREG2 + p.To.Reg = v.Reg() // result + p.To.Offset = int64(v.Args[2].Reg()) // addend + case ssa.OpARMMOVWconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMMOVFconst, + ssa.OpARMMOVDconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_FCONST + p.From.Val = math.Float64frombits(uint64(v.AuxInt)) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMCMP, + ssa.OpARMCMN, + ssa.OpARMTST, + ssa.OpARMTEQ, + ssa.OpARMCMPF, + ssa.OpARMCMPD: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + // Special layout in ARM assembly + // Comparing to x86, the operands of ARM's CMP are reversed. + p.From.Reg = v.Args[1].Reg() + p.Reg = v.Args[0].Reg() + case ssa.OpARMCMPconst, + ssa.OpARMCMNconst, + ssa.OpARMTSTconst, + ssa.OpARMTEQconst: + // Special layout in ARM assembly + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + case ssa.OpARMCMPF0, + ssa.OpARMCMPD0: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + case ssa.OpARMCMPshiftLL, ssa.OpARMCMNshiftLL, ssa.OpARMTSTshiftLL, ssa.OpARMTEQshiftLL: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), 0, arm.SHIFT_LL, v.AuxInt) + case ssa.OpARMCMPshiftRL, ssa.OpARMCMNshiftRL, ssa.OpARMTSTshiftRL, ssa.OpARMTEQshiftRL: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), 0, arm.SHIFT_LR, v.AuxInt) + case ssa.OpARMCMPshiftRA, ssa.OpARMCMNshiftRA, ssa.OpARMTSTshiftRA, ssa.OpARMTEQshiftRA: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), 0, arm.SHIFT_AR, v.AuxInt) + case ssa.OpARMCMPshiftLLreg, ssa.OpARMCMNshiftLLreg, ssa.OpARMTSTshiftLLreg, ssa.OpARMTEQshiftLLreg: + genregshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Args[2].Reg(), 0, arm.SHIFT_LL) + case ssa.OpARMCMPshiftRLreg, ssa.OpARMCMNshiftRLreg, ssa.OpARMTSTshiftRLreg, ssa.OpARMTEQshiftRLreg: + genregshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Args[2].Reg(), 0, arm.SHIFT_LR) + case ssa.OpARMCMPshiftRAreg, ssa.OpARMCMNshiftRAreg, ssa.OpARMTSTshiftRAreg, ssa.OpARMTEQshiftRAreg: + genregshift(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Args[2].Reg(), 0, arm.SHIFT_AR) + case ssa.OpARMMOVWaddr: + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + var wantreg string + // MOVW $sym+off(base), R + // the assembler expands it as the following: + // - base is SP: add constant offset to SP (R13) + // when constant is large, tmp register (R11) may be used + // - base is SB: load external address from constant pool (use relocation) + switch v.Aux.(type) { + default: + v.Fatalf("aux is of unknown type %T", v.Aux) + case *obj.LSym: + wantreg = "SB" + ssagen.AddAux(&p.From, v) + case *ir.Name: + wantreg = "SP" + ssagen.AddAux(&p.From, v) + case nil: + // No sym, just MOVW $off(SP), R + wantreg = "SP" + p.From.Offset = v.AuxInt + } + if reg := v.Args[0].RegName(); reg != wantreg { + v.Fatalf("bad reg %s for symbol type %T, want %s", reg, v.Aux, wantreg) + } + + case ssa.OpARMMOVBload, + ssa.OpARMMOVBUload, + ssa.OpARMMOVHload, + ssa.OpARMMOVHUload, + ssa.OpARMMOVWload, + ssa.OpARMMOVFload, + ssa.OpARMMOVDload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMMOVBstore, + ssa.OpARMMOVHstore, + ssa.OpARMMOVWstore, + ssa.OpARMMOVFstore, + ssa.OpARMMOVDstore: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpARMMOVWloadidx, ssa.OpARMMOVBUloadidx, ssa.OpARMMOVBloadidx, ssa.OpARMMOVHUloadidx, ssa.OpARMMOVHloadidx: + // this is just shift 0 bits + fallthrough + case ssa.OpARMMOVWloadshiftLL: + p := genshift(s, v, v.Op.Asm(), 0, v.Args[1].Reg(), v.Reg(), arm.SHIFT_LL, v.AuxInt) + p.From.Reg = v.Args[0].Reg() + case ssa.OpARMMOVWloadshiftRL: + p := genshift(s, v, v.Op.Asm(), 0, v.Args[1].Reg(), v.Reg(), arm.SHIFT_LR, v.AuxInt) + p.From.Reg = v.Args[0].Reg() + case ssa.OpARMMOVWloadshiftRA: + p := genshift(s, v, v.Op.Asm(), 0, v.Args[1].Reg(), v.Reg(), arm.SHIFT_AR, v.AuxInt) + p.From.Reg = v.Args[0].Reg() + case ssa.OpARMMOVWstoreidx, ssa.OpARMMOVBstoreidx, ssa.OpARMMOVHstoreidx: + // this is just shift 0 bits + fallthrough + case ssa.OpARMMOVWstoreshiftLL: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + p.To.Type = obj.TYPE_SHIFT + p.To.Reg = v.Args[0].Reg() + p.To.Offset = int64(makeshift(v, v.Args[1].Reg(), arm.SHIFT_LL, v.AuxInt)) + case ssa.OpARMMOVWstoreshiftRL: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + p.To.Type = obj.TYPE_SHIFT + p.To.Reg = v.Args[0].Reg() + p.To.Offset = int64(makeshift(v, v.Args[1].Reg(), arm.SHIFT_LR, v.AuxInt)) + case ssa.OpARMMOVWstoreshiftRA: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + p.To.Type = obj.TYPE_SHIFT + p.To.Reg = v.Args[0].Reg() + p.To.Offset = int64(makeshift(v, v.Args[1].Reg(), arm.SHIFT_AR, v.AuxInt)) + case ssa.OpARMMOVBreg, + ssa.OpARMMOVBUreg, + ssa.OpARMMOVHreg, + ssa.OpARMMOVHUreg: + a := v.Args[0] + for a.Op == ssa.OpCopy || a.Op == ssa.OpARMMOVWreg || a.Op == ssa.OpARMMOVWnop { + a = a.Args[0] + } + if a.Op == ssa.OpLoadReg { + t := a.Type + switch { + case v.Op == ssa.OpARMMOVBreg && t.Size() == 1 && t.IsSigned(), + v.Op == ssa.OpARMMOVBUreg && t.Size() == 1 && !t.IsSigned(), + v.Op == ssa.OpARMMOVHreg && t.Size() == 2 && t.IsSigned(), + v.Op == ssa.OpARMMOVHUreg && t.Size() == 2 && !t.IsSigned(): + // arg is a proper-typed load, already zero/sign-extended, don't extend again + if v.Reg() == v.Args[0].Reg() { + return + } + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + return + default: + } + } + if buildcfg.GOARM.Version >= 6 { + // generate more efficient "MOVB/MOVBU/MOVH/MOVHU Reg@>0, Reg" on ARMv6 & ARMv7 + genshift(s, v, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm.SHIFT_RR, 0) + return + } + fallthrough + case ssa.OpARMMVN, + ssa.OpARMCLZ, + ssa.OpARMREV, + ssa.OpARMREV16, + ssa.OpARMRBIT, + ssa.OpARMSQRTF, + ssa.OpARMSQRTD, + ssa.OpARMNEGF, + ssa.OpARMNEGD, + ssa.OpARMABSD, + ssa.OpARMMOVWF, + ssa.OpARMMOVWD, + ssa.OpARMMOVFW, + ssa.OpARMMOVDW, + ssa.OpARMMOVFD, + ssa.OpARMMOVDF: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMMOVWUF, + ssa.OpARMMOVWUD, + ssa.OpARMMOVFWU, + ssa.OpARMMOVDWU: + p := s.Prog(v.Op.Asm()) + p.Scond = arm.C_UBIT + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMCMOVWHSconst: + p := s.Prog(arm.AMOVW) + p.Scond = arm.C_SCOND_HS + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMCMOVWLSconst: + p := s.Prog(arm.AMOVW) + p.Scond = arm.C_SCOND_LS + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMCALLstatic, ssa.OpARMCALLclosure, ssa.OpARMCALLinter: + s.Call(v) + case ssa.OpARMCALLtail: + s.TailCall(v) + case ssa.OpARMCALLudiv: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.Udiv + case ssa.OpARMLoweredWB: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + // AuxInt encodes how many buffer entries we need. + p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1] + + case ssa.OpARMLoweredPanicBoundsRR, ssa.OpARMLoweredPanicBoundsRC, ssa.OpARMLoweredPanicBoundsCR, ssa.OpARMLoweredPanicBoundsCC, + ssa.OpARMLoweredPanicExtendRR, ssa.OpARMLoweredPanicExtendRC: + // Compute the constant we put in the PCData entry for this call. + code, signed := ssa.BoundsKind(v.AuxInt).Code() + xIsReg := false + yIsReg := false + xVal := 0 + yVal := 0 + extend := false + switch v.Op { + case ssa.OpARMLoweredPanicBoundsRR: + xIsReg = true + xVal = int(v.Args[0].Reg() - arm.REG_R0) + yIsReg = true + yVal = int(v.Args[1].Reg() - arm.REG_R0) + case ssa.OpARMLoweredPanicExtendRR: + extend = true + xIsReg = true + hi := int(v.Args[0].Reg() - arm.REG_R0) + lo := int(v.Args[1].Reg() - arm.REG_R0) + xVal = hi<<2 + lo // encode 2 register numbers + yIsReg = true + yVal = int(v.Args[2].Reg() - arm.REG_R0) + case ssa.OpARMLoweredPanicBoundsRC: + xIsReg = true + xVal = int(v.Args[0].Reg() - arm.REG_R0) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + if yVal == xVal { + yVal = 1 + } + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REG_R0 + int16(yVal) + } + case ssa.OpARMLoweredPanicExtendRC: + extend = true + xIsReg = true + hi := int(v.Args[0].Reg() - arm.REG_R0) + lo := int(v.Args[1].Reg() - arm.REG_R0) + xVal = hi<<2 + lo // encode 2 register numbers + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + for yVal == hi || yVal == lo { + yVal++ + } + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REG_R0 + int16(yVal) + } + case ssa.OpARMLoweredPanicBoundsCR: + yIsReg = true + yVal = int(v.Args[0].Reg() - arm.REG_R0) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else if signed && int64(int32(c)) == c || !signed && int64(uint32(c)) == c { + // Move constant to a register + xIsReg = true + if xVal == yVal { + xVal = 1 + } + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REG_R0 + int16(xVal) + } else { + // Move constant to two registers + extend = true + xIsReg = true + hi := 0 + lo := 1 + if hi == yVal { + hi = 2 + } + if lo == yVal { + lo = 2 + } + xVal = hi<<2 + lo + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c >> 32 + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REG_R0 + int16(hi) + p = s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(int32(c)) + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REG_R0 + int16(lo) + } + case ssa.OpARMLoweredPanicBoundsCC: + c := v.Aux.(ssa.PanicBoundsCC).Cx + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else if signed && int64(int32(c)) == c || !signed && int64(uint32(c)) == c { + // Move constant to a register + xIsReg = true + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REG_R0 + int16(xVal) + } else { + // Move constant to two registers + extend = true + xIsReg = true + hi := 0 + lo := 1 + xVal = hi<<2 + lo + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c >> 32 + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REG_R0 + int16(hi) + p = s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(int32(c)) + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REG_R0 + int16(lo) + } + c = v.Aux.(ssa.PanicBoundsCC).Cy + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + yVal = 2 + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REG_R0 + int16(yVal) + } + } + c := abi.BoundsEncode(code, signed, xIsReg, yIsReg, xVal, yVal) + + p := s.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_PanicBounds) + p.To.SetConst(int64(c)) + p = s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + if extend { + p.To.Sym = ir.Syms.PanicExtend + } else { + p.To.Sym = ir.Syms.PanicBounds + } + + case ssa.OpARMDUFFZERO: + p := s.Prog(obj.ADUFFZERO) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.Duffzero + p.To.Offset = v.AuxInt + case ssa.OpARMDUFFCOPY: + p := s.Prog(obj.ADUFFCOPY) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.Duffcopy + p.To.Offset = v.AuxInt + case ssa.OpARMLoweredNilCheck: + // Issue a load which will fault if arg is nil. + p := s.Prog(arm.AMOVB) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REGTMP + if logopt.Enabled() { + logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name) + } + if base.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers + base.WarnfAt(v.Pos, "generated nil check") + } + case ssa.OpARMLoweredZero: + // MOVW.P Rarg2, 4(R1) + // CMP Rarg1, R1 + // BLE -2(PC) + // arg1 is the address of the last element to zero + // arg2 is known to be zero + // auxint is alignment + var sz int64 + var mov obj.As + switch { + case v.AuxInt%4 == 0: + sz = 4 + mov = arm.AMOVW + case v.AuxInt%2 == 0: + sz = 2 + mov = arm.AMOVH + default: + sz = 1 + mov = arm.AMOVB + } + p := s.Prog(mov) + p.Scond = arm.C_PBIT + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = arm.REG_R1 + p.To.Offset = sz + p2 := s.Prog(arm.ACMP) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = v.Args[1].Reg() + p2.Reg = arm.REG_R1 + p3 := s.Prog(arm.ABLE) + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + case ssa.OpARMLoweredMove: + // MOVW.P 4(R1), Rtmp + // MOVW.P Rtmp, 4(R2) + // CMP Rarg2, R1 + // BLE -3(PC) + // arg2 is the address of the last element of src + // auxint is alignment + var sz int64 + var mov obj.As + switch { + case v.AuxInt%4 == 0: + sz = 4 + mov = arm.AMOVW + case v.AuxInt%2 == 0: + sz = 2 + mov = arm.AMOVH + default: + sz = 1 + mov = arm.AMOVB + } + p := s.Prog(mov) + p.Scond = arm.C_PBIT + p.From.Type = obj.TYPE_MEM + p.From.Reg = arm.REG_R1 + p.From.Offset = sz + p.To.Type = obj.TYPE_REG + p.To.Reg = arm.REGTMP + p2 := s.Prog(mov) + p2.Scond = arm.C_PBIT + p2.From.Type = obj.TYPE_REG + p2.From.Reg = arm.REGTMP + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = arm.REG_R2 + p2.To.Offset = sz + p3 := s.Prog(arm.ACMP) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = v.Args[2].Reg() + p3.Reg = arm.REG_R1 + p4 := s.Prog(arm.ABLE) + p4.To.Type = obj.TYPE_BRANCH + p4.To.SetTarget(p) + case ssa.OpARMEqual, + ssa.OpARMNotEqual, + ssa.OpARMLessThan, + ssa.OpARMLessEqual, + ssa.OpARMGreaterThan, + ssa.OpARMGreaterEqual, + ssa.OpARMLessThanU, + ssa.OpARMLessEqualU, + ssa.OpARMGreaterThanU, + ssa.OpARMGreaterEqualU: + // generate boolean values + // use conditional move + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 0 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + p = s.Prog(arm.AMOVW) + p.Scond = condBits[v.Op] + p.From.Type = obj.TYPE_CONST + p.From.Offset = 1 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMLoweredGetClosurePtr: + // Closure pointer is R7 (arm.REGCTXT). + ssagen.CheckLoweredGetClosurePtr(v) + case ssa.OpARMLoweredGetCallerSP: + // caller's SP is FixedFrameSize below the address of the first arg + p := s.Prog(arm.AMOVW) + p.From.Type = obj.TYPE_ADDR + p.From.Offset = -base.Ctxt.Arch.FixedFrameSize + p.From.Name = obj.NAME_PARAM + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMLoweredGetCallerPC: + p := s.Prog(obj.AGETCALLERPC) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARMFlagConstant: + v.Fatalf("FlagConstant op should never make it to codegen %v", v.LongString()) + case ssa.OpARMInvertFlags: + v.Fatalf("InvertFlags should never make it to codegen %v", v.LongString()) + case ssa.OpClobber, ssa.OpClobberReg: + // TODO: implement for clobberdead experiment. Nop is ok for now. + default: + v.Fatalf("genValue not implemented: %s", v.LongString()) + } +} + +var condBits = map[ssa.Op]uint8{ + ssa.OpARMEqual: arm.C_SCOND_EQ, + ssa.OpARMNotEqual: arm.C_SCOND_NE, + ssa.OpARMLessThan: arm.C_SCOND_LT, + ssa.OpARMLessThanU: arm.C_SCOND_LO, + ssa.OpARMLessEqual: arm.C_SCOND_LE, + ssa.OpARMLessEqualU: arm.C_SCOND_LS, + ssa.OpARMGreaterThan: arm.C_SCOND_GT, + ssa.OpARMGreaterThanU: arm.C_SCOND_HI, + ssa.OpARMGreaterEqual: arm.C_SCOND_GE, + ssa.OpARMGreaterEqualU: arm.C_SCOND_HS, +} + +var blockJump = map[ssa.BlockKind]struct { + asm, invasm obj.As +}{ + ssa.BlockARMEQ: {arm.ABEQ, arm.ABNE}, + ssa.BlockARMNE: {arm.ABNE, arm.ABEQ}, + ssa.BlockARMLT: {arm.ABLT, arm.ABGE}, + ssa.BlockARMGE: {arm.ABGE, arm.ABLT}, + ssa.BlockARMLE: {arm.ABLE, arm.ABGT}, + ssa.BlockARMGT: {arm.ABGT, arm.ABLE}, + ssa.BlockARMULT: {arm.ABLO, arm.ABHS}, + ssa.BlockARMUGE: {arm.ABHS, arm.ABLO}, + ssa.BlockARMUGT: {arm.ABHI, arm.ABLS}, + ssa.BlockARMULE: {arm.ABLS, arm.ABHI}, + ssa.BlockARMLTnoov: {arm.ABMI, arm.ABPL}, + ssa.BlockARMGEnoov: {arm.ABPL, arm.ABMI}, +} + +// To model a 'LEnoov' ('<=' without overflow checking) branching. +var leJumps = [2][2]ssagen.IndexJump{ + {{Jump: arm.ABEQ, Index: 0}, {Jump: arm.ABPL, Index: 1}}, // next == b.Succs[0] + {{Jump: arm.ABMI, Index: 0}, {Jump: arm.ABEQ, Index: 0}}, // next == b.Succs[1] +} + +// To model a 'GTnoov' ('>' without overflow checking) branching. +var gtJumps = [2][2]ssagen.IndexJump{ + {{Jump: arm.ABMI, Index: 1}, {Jump: arm.ABEQ, Index: 1}}, // next == b.Succs[0] + {{Jump: arm.ABEQ, Index: 1}, {Jump: arm.ABPL, Index: 0}}, // next == b.Succs[1] +} + +func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) { + switch b.Kind { + case ssa.BlockPlain, ssa.BlockDefer: + if b.Succs[0].Block() != next { + p := s.Prog(obj.AJMP) + p.To.Type = obj.TYPE_BRANCH + s.Branches = append(s.Branches, ssagen.Branch{P: p, B: b.Succs[0].Block()}) + } + + case ssa.BlockExit, ssa.BlockRetJmp: + + case ssa.BlockRet: + s.Prog(obj.ARET) + + case ssa.BlockARMEQ, ssa.BlockARMNE, + ssa.BlockARMLT, ssa.BlockARMGE, + ssa.BlockARMLE, ssa.BlockARMGT, + ssa.BlockARMULT, ssa.BlockARMUGT, + ssa.BlockARMULE, ssa.BlockARMUGE, + ssa.BlockARMLTnoov, ssa.BlockARMGEnoov: + jmp := blockJump[b.Kind] + switch next { + case b.Succs[0].Block(): + s.Br(jmp.invasm, b.Succs[1].Block()) + case b.Succs[1].Block(): + s.Br(jmp.asm, b.Succs[0].Block()) + default: + if b.Likely != ssa.BranchUnlikely { + s.Br(jmp.asm, b.Succs[0].Block()) + s.Br(obj.AJMP, b.Succs[1].Block()) + } else { + s.Br(jmp.invasm, b.Succs[1].Block()) + s.Br(obj.AJMP, b.Succs[0].Block()) + } + } + + case ssa.BlockARMLEnoov: + s.CombJump(b, next, &leJumps) + + case ssa.BlockARMGTnoov: + s.CombJump(b, next, >Jumps) + + default: + b.Fatalf("branch not implemented: %s", b.LongString()) + } +} diff --git a/go/src/cmd/compile/internal/arm64/galign.go b/go/src/cmd/compile/internal/arm64/galign.go new file mode 100644 index 0000000000000000000000000000000000000000..3ebd860de8f887c4c0b4dbc3934b7ed297995398 --- /dev/null +++ b/go/src/cmd/compile/internal/arm64/galign.go @@ -0,0 +1,27 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package arm64 + +import ( + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/internal/obj/arm64" +) + +func Init(arch *ssagen.ArchInfo) { + arch.LinkArch = &arm64.Linkarm64 + arch.REGSP = arm64.REGSP + arch.MAXWIDTH = 1 << 50 + + arch.PadFrame = padframe + arch.ZeroRange = zerorange + arch.Ginsnop = ginsnop + + arch.SSAMarkMoves = func(s *ssagen.State, b *ssa.Block) {} + arch.SSAGenValue = ssaGenValue + arch.SSAGenBlock = ssaGenBlock + arch.LoadRegResult = loadRegResult + arch.SpillArgReg = spillArgReg +} diff --git a/go/src/cmd/compile/internal/arm64/ggen.go b/go/src/cmd/compile/internal/arm64/ggen.go new file mode 100644 index 0000000000000000000000000000000000000000..14027467002a3ebb61efcfcb3be0c79ee25f7d9f --- /dev/null +++ b/go/src/cmd/compile/internal/arm64/ggen.go @@ -0,0 +1,44 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package arm64 + +import ( + "cmd/compile/internal/objw" + "cmd/internal/obj" + "cmd/internal/obj/arm64" +) + +func padframe(frame int64) int64 { + // arm64 requires that the frame size (not counting saved FP&LR) + // be 16 bytes aligned. If not, pad it. + if frame%16 != 0 { + frame += 16 - (frame % 16) + } + return frame +} + +func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { + if cnt%8 != 0 { + panic("zeroed region not aligned") + } + off += 8 // return address was ignored in offset calculation + for cnt >= 16 && off < 512 { + p = pp.Append(p, arm64.ASTP, obj.TYPE_REGREG, arm64.REGZERO, arm64.REGZERO, obj.TYPE_MEM, arm64.REGSP, off) + off += 16 + cnt -= 16 + } + for cnt != 0 { + p = pp.Append(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGSP, off) + off += 8 + cnt -= 8 + } + return p +} + +func ginsnop(pp *objw.Progs) *obj.Prog { + p := pp.Prog(arm64.AHINT) + p.From.Type = obj.TYPE_CONST + return p +} diff --git a/go/src/cmd/compile/internal/arm64/ssa.go b/go/src/cmd/compile/internal/arm64/ssa.go new file mode 100644 index 0000000000000000000000000000000000000000..74371104a310ed8abf56381186384f2101502287 --- /dev/null +++ b/go/src/cmd/compile/internal/arm64/ssa.go @@ -0,0 +1,1800 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package arm64 + +import ( + "math" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/objw" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/arm64" + "internal/abi" +) + +// loadByType returns the load instruction of the given type. +func loadByType(t *types.Type) obj.As { + if t.IsFloat() { + switch t.Size() { + case 4: + return arm64.AFMOVS + case 8: + return arm64.AFMOVD + } + } else { + switch t.Size() { + case 1: + if t.IsSigned() { + return arm64.AMOVB + } else { + return arm64.AMOVBU + } + case 2: + if t.IsSigned() { + return arm64.AMOVH + } else { + return arm64.AMOVHU + } + case 4: + if t.IsSigned() { + return arm64.AMOVW + } else { + return arm64.AMOVWU + } + case 8: + return arm64.AMOVD + } + } + panic("bad load type") +} + +// storeByType returns the store instruction of the given type. +func storeByType(t *types.Type) obj.As { + if t.IsFloat() { + switch t.Size() { + case 4: + return arm64.AFMOVS + case 8: + return arm64.AFMOVD + } + } else { + switch t.Size() { + case 1: + return arm64.AMOVB + case 2: + return arm64.AMOVH + case 4: + return arm64.AMOVW + case 8: + return arm64.AMOVD + } + } + panic("bad store type") +} + +// loadByType2 returns an opcode that can load consecutive memory locations into 2 registers with type t. +// returns obj.AXXX if no such opcode exists. +func loadByType2(t *types.Type) obj.As { + if t.IsFloat() { + switch t.Size() { + case 4: + return arm64.AFLDPS + case 8: + return arm64.AFLDPD + } + } else { + switch t.Size() { + case 4: + return arm64.ALDPW + case 8: + return arm64.ALDP + } + } + return obj.AXXX +} + +// storeByType2 returns an opcode that can store registers with type t into 2 consecutive memory locations. +// returns obj.AXXX if no such opcode exists. +func storeByType2(t *types.Type) obj.As { + if t.IsFloat() { + switch t.Size() { + case 4: + return arm64.AFSTPS + case 8: + return arm64.AFSTPD + } + } else { + switch t.Size() { + case 4: + return arm64.ASTPW + case 8: + return arm64.ASTP + } + } + return obj.AXXX +} + +// makeshift encodes a register shifted by a constant, used as an Offset in Prog. +func makeshift(v *ssa.Value, reg int16, typ int64, s int64) int64 { + if s < 0 || s >= 64 { + v.Fatalf("shift out of range: %d", s) + } + return int64(reg&31)<<16 | typ | (s&63)<<10 +} + +// genshift generates a Prog for r = r0 op (r1 shifted by n). +func genshift(s *ssagen.State, v *ssa.Value, as obj.As, r0, r1, r int16, typ int64, n int64) *obj.Prog { + p := s.Prog(as) + p.From.Type = obj.TYPE_SHIFT + p.From.Offset = makeshift(v, r1, typ, n) + p.Reg = r0 + if r != 0 { + p.To.Type = obj.TYPE_REG + p.To.Reg = r + } + return p +} + +// generate the memory operand for the indexed load/store instructions. +// base and idx are registers. +func genIndexedOperand(op ssa.Op, base, idx int16) obj.Addr { + // Reg: base register, Index: (shifted) index register + mop := obj.Addr{Type: obj.TYPE_MEM, Reg: base} + switch op { + case ssa.OpARM64MOVDloadidx8, ssa.OpARM64MOVDstoreidx8, + ssa.OpARM64FMOVDloadidx8, ssa.OpARM64FMOVDstoreidx8: + mop.Index = arm64.REG_LSL | 3<<5 | idx&31 + case ssa.OpARM64MOVWloadidx4, ssa.OpARM64MOVWUloadidx4, ssa.OpARM64MOVWstoreidx4, + ssa.OpARM64FMOVSloadidx4, ssa.OpARM64FMOVSstoreidx4: + mop.Index = arm64.REG_LSL | 2<<5 | idx&31 + case ssa.OpARM64MOVHloadidx2, ssa.OpARM64MOVHUloadidx2, ssa.OpARM64MOVHstoreidx2: + mop.Index = arm64.REG_LSL | 1<<5 | idx&31 + default: // not shifted + mop.Index = idx + } + return mop +} + +func ssaGenValue(s *ssagen.State, v *ssa.Value) { + switch v.Op { + case ssa.OpCopy, ssa.OpARM64MOVDreg: + if v.Type.IsMemory() { + return + } + x := v.Args[0].Reg() + y := v.Reg() + if x == y { + return + } + as := arm64.AMOVD + if v.Type.IsFloat() { + switch v.Type.Size() { + case 4: + as = arm64.AFMOVS + case 8: + as = arm64.AFMOVD + default: + panic("bad float size") + } + } + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = x + p.To.Type = obj.TYPE_REG + p.To.Reg = y + case ssa.OpARM64MOVDnop, ssa.OpARM64ZERO: + // nothing to do + case ssa.OpLoadReg: + if v.Type.IsFlags() { + v.Fatalf("load flags not implemented: %v", v.LongString()) + return + } + p := s.Prog(loadByType(v.Type)) + ssagen.AddrAuto(&p.From, v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpStoreReg: + if v.Type.IsFlags() { + v.Fatalf("store flags not implemented: %v", v.LongString()) + return + } + p := s.Prog(storeByType(v.Type)) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + ssagen.AddrAuto(&p.To, v) + case ssa.OpArgIntReg, ssa.OpArgFloatReg: + ssagen.CheckArgReg(v) + // The assembler needs to wrap the entry safepoint/stack growth code with spill/unspill + // The loop only runs once. + args := v.Block.Func.RegArgs + if len(args) == 0 { + break + } + v.Block.Func.RegArgs = nil // prevent from running again + + for i := 0; i < len(args); i++ { + a := args[i] + // Offset by size of the saved LR slot. + addr := ssagen.SpillSlotAddr(a, arm64.REGSP, base.Ctxt.Arch.FixedFrameSize) + // Look for double-register operations if we can. + if i < len(args)-1 { + b := args[i+1] + if a.Type.Size() == b.Type.Size() && + a.Type.IsFloat() == b.Type.IsFloat() && + b.Offset == a.Offset+a.Type.Size() { + ld := loadByType2(a.Type) + st := storeByType2(a.Type) + if ld != obj.AXXX && st != obj.AXXX { + s.FuncInfo().AddSpill(obj.RegSpill{Reg: a.Reg, Reg2: b.Reg, Addr: addr, Unspill: ld, Spill: st}) + i++ // b is done also, skip it. + continue + } + } + } + // Pass the spill/unspill information along to the assembler. + s.FuncInfo().AddSpill(obj.RegSpill{Reg: a.Reg, Addr: addr, Unspill: loadByType(a.Type), Spill: storeByType(a.Type)}) + } + + case ssa.OpARM64ADD, + ssa.OpARM64SUB, + ssa.OpARM64AND, + ssa.OpARM64OR, + ssa.OpARM64XOR, + ssa.OpARM64BIC, + ssa.OpARM64EON, + ssa.OpARM64ORN, + ssa.OpARM64MUL, + ssa.OpARM64MULW, + ssa.OpARM64MNEG, + ssa.OpARM64MNEGW, + ssa.OpARM64MULH, + ssa.OpARM64UMULH, + ssa.OpARM64MULL, + ssa.OpARM64UMULL, + ssa.OpARM64DIV, + ssa.OpARM64UDIV, + ssa.OpARM64DIVW, + ssa.OpARM64UDIVW, + ssa.OpARM64MOD, + ssa.OpARM64UMOD, + ssa.OpARM64MODW, + ssa.OpARM64UMODW, + ssa.OpARM64SLL, + ssa.OpARM64SRL, + ssa.OpARM64SRA, + ssa.OpARM64FADDS, + ssa.OpARM64FADDD, + ssa.OpARM64FSUBS, + ssa.OpARM64FSUBD, + ssa.OpARM64FMULS, + ssa.OpARM64FMULD, + ssa.OpARM64FNMULS, + ssa.OpARM64FNMULD, + ssa.OpARM64FDIVS, + ssa.OpARM64FDIVD, + ssa.OpARM64FMINS, + ssa.OpARM64FMIND, + ssa.OpARM64FMAXS, + ssa.OpARM64FMAXD, + ssa.OpARM64ROR, + ssa.OpARM64RORW: + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpARM64FMADDS, + ssa.OpARM64FMADDD, + ssa.OpARM64FNMADDS, + ssa.OpARM64FNMADDD, + ssa.OpARM64FMSUBS, + ssa.OpARM64FMSUBD, + ssa.OpARM64FNMSUBS, + ssa.OpARM64FNMSUBD, + ssa.OpARM64MADD, + ssa.OpARM64MADDW, + ssa.OpARM64MSUB, + ssa.OpARM64MSUBW: + rt := v.Reg() + ra := v.Args[0].Reg() + rm := v.Args[1].Reg() + rn := v.Args[2].Reg() + p := s.Prog(v.Op.Asm()) + p.Reg = ra + p.From.Type = obj.TYPE_REG + p.From.Reg = rm + p.AddRestSourceReg(rn) + p.To.Type = obj.TYPE_REG + p.To.Reg = rt + case ssa.OpARM64ADDconst, + ssa.OpARM64SUBconst, + ssa.OpARM64ANDconst, + ssa.OpARM64ORconst, + ssa.OpARM64XORconst, + ssa.OpARM64SLLconst, + ssa.OpARM64SRLconst, + ssa.OpARM64SRAconst, + ssa.OpARM64RORconst, + ssa.OpARM64RORWconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64ADDSconstflags: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + case ssa.OpARM64ADCzerocarry: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = arm64.REGZERO + p.Reg = arm64.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64ADCSflags, + ssa.OpARM64ADDSflags, + ssa.OpARM64SBCSflags, + ssa.OpARM64SUBSflags: + r := v.Reg0() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpARM64NEGSflags: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + case ssa.OpARM64NGCzerocarry: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = arm64.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64EXTRconst, + ssa.OpARM64EXTRWconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.AddRestSourceReg(v.Args[0].Reg()) + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64MVNshiftLL, ssa.OpARM64NEGshiftLL: + genshift(s, v, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm64.SHIFT_LL, v.AuxInt) + case ssa.OpARM64MVNshiftRL, ssa.OpARM64NEGshiftRL: + genshift(s, v, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm64.SHIFT_LR, v.AuxInt) + case ssa.OpARM64MVNshiftRA, ssa.OpARM64NEGshiftRA: + genshift(s, v, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm64.SHIFT_AR, v.AuxInt) + case ssa.OpARM64MVNshiftRO: + genshift(s, v, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm64.SHIFT_ROR, v.AuxInt) + case ssa.OpARM64ADDshiftLL, + ssa.OpARM64SUBshiftLL, + ssa.OpARM64ANDshiftLL, + ssa.OpARM64ORshiftLL, + ssa.OpARM64XORshiftLL, + ssa.OpARM64EONshiftLL, + ssa.OpARM64ORNshiftLL, + ssa.OpARM64BICshiftLL: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm64.SHIFT_LL, v.AuxInt) + case ssa.OpARM64ADDshiftRL, + ssa.OpARM64SUBshiftRL, + ssa.OpARM64ANDshiftRL, + ssa.OpARM64ORshiftRL, + ssa.OpARM64XORshiftRL, + ssa.OpARM64EONshiftRL, + ssa.OpARM64ORNshiftRL, + ssa.OpARM64BICshiftRL: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm64.SHIFT_LR, v.AuxInt) + case ssa.OpARM64ADDshiftRA, + ssa.OpARM64SUBshiftRA, + ssa.OpARM64ANDshiftRA, + ssa.OpARM64ORshiftRA, + ssa.OpARM64XORshiftRA, + ssa.OpARM64EONshiftRA, + ssa.OpARM64ORNshiftRA, + ssa.OpARM64BICshiftRA: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm64.SHIFT_AR, v.AuxInt) + case ssa.OpARM64ANDshiftRO, + ssa.OpARM64ORshiftRO, + ssa.OpARM64XORshiftRO, + ssa.OpARM64EONshiftRO, + ssa.OpARM64ORNshiftRO, + ssa.OpARM64BICshiftRO: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), v.Reg(), arm64.SHIFT_ROR, v.AuxInt) + case ssa.OpARM64MOVDconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64FMOVSconst, + ssa.OpARM64FMOVDconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_FCONST + p.From.Val = math.Float64frombits(uint64(v.AuxInt)) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64FCMPS0, + ssa.OpARM64FCMPD0: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_FCONST + p.From.Val = math.Float64frombits(0) + p.Reg = v.Args[0].Reg() + case ssa.OpARM64CMP, + ssa.OpARM64CMPW, + ssa.OpARM64CMN, + ssa.OpARM64CMNW, + ssa.OpARM64TST, + ssa.OpARM64TSTW, + ssa.OpARM64FCMPS, + ssa.OpARM64FCMPD: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.Reg = v.Args[0].Reg() + case ssa.OpARM64CMPconst, + ssa.OpARM64CMPWconst, + ssa.OpARM64CMNconst, + ssa.OpARM64CMNWconst, + ssa.OpARM64TSTconst, + ssa.OpARM64TSTWconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + case ssa.OpARM64CMPshiftLL, ssa.OpARM64CMNshiftLL, ssa.OpARM64TSTshiftLL: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), 0, arm64.SHIFT_LL, v.AuxInt) + case ssa.OpARM64CMPshiftRL, ssa.OpARM64CMNshiftRL, ssa.OpARM64TSTshiftRL: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), 0, arm64.SHIFT_LR, v.AuxInt) + case ssa.OpARM64CMPshiftRA, ssa.OpARM64CMNshiftRA, ssa.OpARM64TSTshiftRA: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), 0, arm64.SHIFT_AR, v.AuxInt) + case ssa.OpARM64TSTshiftRO: + genshift(s, v, v.Op.Asm(), v.Args[0].Reg(), v.Args[1].Reg(), 0, arm64.SHIFT_ROR, v.AuxInt) + case ssa.OpARM64MOVDaddr: + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + var wantreg string + // MOVD $sym+off(base), R + // the assembler expands it as the following: + // - base is SP: add constant offset to SP (R13) + // when constant is large, tmp register (R11) may be used + // - base is SB: load external address from constant pool (use relocation) + switch v.Aux.(type) { + default: + v.Fatalf("aux is of unknown type %T", v.Aux) + case *obj.LSym: + wantreg = "SB" + ssagen.AddAux(&p.From, v) + case *ir.Name: + wantreg = "SP" + ssagen.AddAux(&p.From, v) + case nil: + // No sym, just MOVD $off(SP), R + wantreg = "SP" + p.From.Offset = v.AuxInt + } + if reg := v.Args[0].RegName(); reg != wantreg { + v.Fatalf("bad reg %s for symbol type %T, want %s", reg, v.Aux, wantreg) + } + case ssa.OpARM64MOVBload, + ssa.OpARM64MOVBUload, + ssa.OpARM64MOVHload, + ssa.OpARM64MOVHUload, + ssa.OpARM64MOVWload, + ssa.OpARM64MOVWUload, + ssa.OpARM64MOVDload, + ssa.OpARM64FMOVSload, + ssa.OpARM64FMOVDload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64LDP, ssa.OpARM64LDPW, ssa.OpARM64LDPSW, ssa.OpARM64FLDPD, ssa.OpARM64FLDPS: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REGREG + p.To.Reg = v.Reg0() + p.To.Offset = int64(v.Reg1()) + case ssa.OpARM64MOVBloadidx, + ssa.OpARM64MOVBUloadidx, + ssa.OpARM64MOVHloadidx, + ssa.OpARM64MOVHUloadidx, + ssa.OpARM64MOVWloadidx, + ssa.OpARM64MOVWUloadidx, + ssa.OpARM64MOVDloadidx, + ssa.OpARM64FMOVSloadidx, + ssa.OpARM64FMOVDloadidx, + ssa.OpARM64MOVHloadidx2, + ssa.OpARM64MOVHUloadidx2, + ssa.OpARM64MOVWloadidx4, + ssa.OpARM64MOVWUloadidx4, + ssa.OpARM64MOVDloadidx8, + ssa.OpARM64FMOVDloadidx8, + ssa.OpARM64FMOVSloadidx4: + p := s.Prog(v.Op.Asm()) + p.From = genIndexedOperand(v.Op, v.Args[0].Reg(), v.Args[1].Reg()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64LDAR, + ssa.OpARM64LDARB, + ssa.OpARM64LDARW: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + case ssa.OpARM64MOVBstore, + ssa.OpARM64MOVHstore, + ssa.OpARM64MOVWstore, + ssa.OpARM64MOVDstore, + ssa.OpARM64FMOVSstore, + ssa.OpARM64FMOVDstore, + ssa.OpARM64STLRB, + ssa.OpARM64STLR, + ssa.OpARM64STLRW: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpARM64MOVBstoreidx, + ssa.OpARM64MOVHstoreidx, + ssa.OpARM64MOVWstoreidx, + ssa.OpARM64MOVDstoreidx, + ssa.OpARM64FMOVSstoreidx, + ssa.OpARM64FMOVDstoreidx, + ssa.OpARM64MOVHstoreidx2, + ssa.OpARM64MOVWstoreidx4, + ssa.OpARM64FMOVSstoreidx4, + ssa.OpARM64MOVDstoreidx8, + ssa.OpARM64FMOVDstoreidx8: + p := s.Prog(v.Op.Asm()) + p.To = genIndexedOperand(v.Op, v.Args[0].Reg(), v.Args[1].Reg()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + case ssa.OpARM64STP, ssa.OpARM64STPW, ssa.OpARM64FSTPD, ssa.OpARM64FSTPS: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REGREG + p.From.Reg = v.Args[1].Reg() + p.From.Offset = int64(v.Args[2].Reg()) + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpARM64BFI, + ssa.OpARM64BFXIL: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt >> 8 + p.AddRestSourceConst(v.AuxInt & 0xff) + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64SBFIZ, + ssa.OpARM64SBFX, + ssa.OpARM64UBFIZ, + ssa.OpARM64UBFX: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt >> 8 + p.AddRestSourceConst(v.AuxInt & 0xff) + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64LoweredAtomicExchange64, + ssa.OpARM64LoweredAtomicExchange32, + ssa.OpARM64LoweredAtomicExchange8: + // LDAXR (Rarg0), Rout + // STLXR Rarg1, (Rarg0), Rtmp + // CBNZ Rtmp, -2(PC) + var ld, st obj.As + switch v.Op { + case ssa.OpARM64LoweredAtomicExchange8: + ld = arm64.ALDAXRB + st = arm64.ASTLXRB + case ssa.OpARM64LoweredAtomicExchange32: + ld = arm64.ALDAXRW + st = arm64.ASTLXRW + case ssa.OpARM64LoweredAtomicExchange64: + ld = arm64.ALDAXR + st = arm64.ASTLXR + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg0() + p := s.Prog(ld) + p.From.Type = obj.TYPE_MEM + p.From.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = out + p1 := s.Prog(st) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.To.Type = obj.TYPE_MEM + p1.To.Reg = r0 + p1.RegTo2 = arm64.REGTMP + p2 := s.Prog(arm64.ACBNZ) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = arm64.REGTMP + p2.To.Type = obj.TYPE_BRANCH + p2.To.SetTarget(p) + case ssa.OpARM64LoweredAtomicExchange64Variant, + ssa.OpARM64LoweredAtomicExchange32Variant, + ssa.OpARM64LoweredAtomicExchange8Variant: + var swap obj.As + switch v.Op { + case ssa.OpARM64LoweredAtomicExchange8Variant: + swap = arm64.ASWPALB + case ssa.OpARM64LoweredAtomicExchange32Variant: + swap = arm64.ASWPALW + case ssa.OpARM64LoweredAtomicExchange64Variant: + swap = arm64.ASWPALD + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg0() + + // SWPALD Rarg1, (Rarg0), Rout + p := s.Prog(swap) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.To.Type = obj.TYPE_MEM + p.To.Reg = r0 + p.RegTo2 = out + + case ssa.OpARM64LoweredAtomicAdd64, + ssa.OpARM64LoweredAtomicAdd32: + // LDAXR (Rarg0), Rout + // ADD Rarg1, Rout + // STLXR Rout, (Rarg0), Rtmp + // CBNZ Rtmp, -3(PC) + ld := arm64.ALDAXR + st := arm64.ASTLXR + if v.Op == ssa.OpARM64LoweredAtomicAdd32 { + ld = arm64.ALDAXRW + st = arm64.ASTLXRW + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg0() + p := s.Prog(ld) + p.From.Type = obj.TYPE_MEM + p.From.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = out + p1 := s.Prog(arm64.AADD) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.To.Type = obj.TYPE_REG + p1.To.Reg = out + p2 := s.Prog(st) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = out + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = r0 + p2.RegTo2 = arm64.REGTMP + p3 := s.Prog(arm64.ACBNZ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = arm64.REGTMP + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + case ssa.OpARM64LoweredAtomicAdd64Variant, + ssa.OpARM64LoweredAtomicAdd32Variant: + // LDADDAL Rarg1, (Rarg0), Rout + // ADD Rarg1, Rout + op := arm64.ALDADDALD + if v.Op == ssa.OpARM64LoweredAtomicAdd32Variant { + op = arm64.ALDADDALW + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg0() + p := s.Prog(op) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.To.Type = obj.TYPE_MEM + p.To.Reg = r0 + p.RegTo2 = out + p1 := s.Prog(arm64.AADD) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.To.Type = obj.TYPE_REG + p1.To.Reg = out + case ssa.OpARM64LoweredAtomicCas64, + ssa.OpARM64LoweredAtomicCas32: + // LDAXR (Rarg0), Rtmp + // CMP Rarg1, Rtmp + // BNE 3(PC) + // STLXR Rarg2, (Rarg0), Rtmp + // CBNZ Rtmp, -4(PC) + // CSET EQ, Rout + ld := arm64.ALDAXR + st := arm64.ASTLXR + cmp := arm64.ACMP + if v.Op == ssa.OpARM64LoweredAtomicCas32 { + ld = arm64.ALDAXRW + st = arm64.ASTLXRW + cmp = arm64.ACMPW + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + r2 := v.Args[2].Reg() + out := v.Reg0() + p := s.Prog(ld) + p.From.Type = obj.TYPE_MEM + p.From.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = arm64.REGTMP + p1 := s.Prog(cmp) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.Reg = arm64.REGTMP + p2 := s.Prog(arm64.ABNE) + p2.To.Type = obj.TYPE_BRANCH + p3 := s.Prog(st) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = r2 + p3.To.Type = obj.TYPE_MEM + p3.To.Reg = r0 + p3.RegTo2 = arm64.REGTMP + p4 := s.Prog(arm64.ACBNZ) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = arm64.REGTMP + p4.To.Type = obj.TYPE_BRANCH + p4.To.SetTarget(p) + p5 := s.Prog(arm64.ACSET) + p5.From.Type = obj.TYPE_SPECIAL // assembler encodes conditional bits in Offset + p5.From.Offset = int64(arm64.SPOP_EQ) + p5.To.Type = obj.TYPE_REG + p5.To.Reg = out + p2.To.SetTarget(p5) + case ssa.OpARM64LoweredAtomicCas64Variant, + ssa.OpARM64LoweredAtomicCas32Variant: + // Rarg0: ptr + // Rarg1: old + // Rarg2: new + // MOV Rarg1, Rtmp + // CASAL Rtmp, (Rarg0), Rarg2 + // CMP Rarg1, Rtmp + // CSET EQ, Rout + cas := arm64.ACASALD + cmp := arm64.ACMP + mov := arm64.AMOVD + if v.Op == ssa.OpARM64LoweredAtomicCas32Variant { + cas = arm64.ACASALW + cmp = arm64.ACMPW + mov = arm64.AMOVW + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + r2 := v.Args[2].Reg() + out := v.Reg0() + + // MOV Rarg1, Rtmp + p := s.Prog(mov) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = arm64.REGTMP + + // CASAL Rtmp, (Rarg0), Rarg2 + p1 := s.Prog(cas) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = arm64.REGTMP + p1.To.Type = obj.TYPE_MEM + p1.To.Reg = r0 + p1.RegTo2 = r2 + + // CMP Rarg1, Rtmp + p2 := s.Prog(cmp) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = r1 + p2.Reg = arm64.REGTMP + + // CSET EQ, Rout + p3 := s.Prog(arm64.ACSET) + p3.From.Type = obj.TYPE_SPECIAL // assembler encodes conditional bits in Offset + p3.From.Offset = int64(arm64.SPOP_EQ) + p3.To.Type = obj.TYPE_REG + p3.To.Reg = out + + case ssa.OpARM64LoweredAtomicAnd64, + ssa.OpARM64LoweredAtomicOr64, + ssa.OpARM64LoweredAtomicAnd32, + ssa.OpARM64LoweredAtomicOr32, + ssa.OpARM64LoweredAtomicAnd8, + ssa.OpARM64LoweredAtomicOr8: + // LDAXR[BW] (Rarg0), Rout + // AND/OR Rarg1, Rout, tmp1 + // STLXR[BW] tmp1, (Rarg0), Rtmp + // CBNZ Rtmp, -3(PC) + ld := arm64.ALDAXR + st := arm64.ASTLXR + if v.Op == ssa.OpARM64LoweredAtomicAnd32 || v.Op == ssa.OpARM64LoweredAtomicOr32 { + ld = arm64.ALDAXRW + st = arm64.ASTLXRW + } + if v.Op == ssa.OpARM64LoweredAtomicAnd8 || v.Op == ssa.OpARM64LoweredAtomicOr8 { + ld = arm64.ALDAXRB + st = arm64.ASTLXRB + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg0() + tmp := v.RegTmp() + p := s.Prog(ld) + p.From.Type = obj.TYPE_MEM + p.From.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = out + p1 := s.Prog(v.Op.Asm()) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.Reg = out + p1.To.Type = obj.TYPE_REG + p1.To.Reg = tmp + p2 := s.Prog(st) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = tmp + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = r0 + p2.RegTo2 = arm64.REGTMP + p3 := s.Prog(arm64.ACBNZ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = arm64.REGTMP + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + + case ssa.OpARM64LoweredAtomicAnd8Variant, + ssa.OpARM64LoweredAtomicAnd32Variant, + ssa.OpARM64LoweredAtomicAnd64Variant: + atomic_clear := arm64.ALDCLRALD + if v.Op == ssa.OpARM64LoweredAtomicAnd32Variant { + atomic_clear = arm64.ALDCLRALW + } + if v.Op == ssa.OpARM64LoweredAtomicAnd8Variant { + atomic_clear = arm64.ALDCLRALB + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg0() + + // MNV Rarg1 Rtemp + p := s.Prog(arm64.AMVN) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = arm64.REGTMP + + // LDCLRAL[BDW] Rtemp, (Rarg0), Rout + p1 := s.Prog(atomic_clear) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = arm64.REGTMP + p1.To.Type = obj.TYPE_MEM + p1.To.Reg = r0 + p1.RegTo2 = out + + case ssa.OpARM64LoweredAtomicOr8Variant, + ssa.OpARM64LoweredAtomicOr32Variant, + ssa.OpARM64LoweredAtomicOr64Variant: + atomic_or := arm64.ALDORALD + if v.Op == ssa.OpARM64LoweredAtomicOr32Variant { + atomic_or = arm64.ALDORALW + } + if v.Op == ssa.OpARM64LoweredAtomicOr8Variant { + atomic_or = arm64.ALDORALB + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg0() + + // LDORAL[BDW] Rarg1, (Rarg0), Rout + p := s.Prog(atomic_or) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.To.Type = obj.TYPE_MEM + p.To.Reg = r0 + p.RegTo2 = out + + case ssa.OpARM64MOVBreg, + ssa.OpARM64MOVBUreg, + ssa.OpARM64MOVHreg, + ssa.OpARM64MOVHUreg, + ssa.OpARM64MOVWreg, + ssa.OpARM64MOVWUreg: + a := v.Args[0] + for a.Op == ssa.OpCopy || a.Op == ssa.OpARM64MOVDreg { + a = a.Args[0] + } + if a.Op == ssa.OpLoadReg { + t := a.Type + switch { + case v.Op == ssa.OpARM64MOVBreg && t.Size() == 1 && t.IsSigned(), + v.Op == ssa.OpARM64MOVBUreg && t.Size() == 1 && !t.IsSigned(), + v.Op == ssa.OpARM64MOVHreg && t.Size() == 2 && t.IsSigned(), + v.Op == ssa.OpARM64MOVHUreg && t.Size() == 2 && !t.IsSigned(), + v.Op == ssa.OpARM64MOVWreg && t.Size() == 4 && t.IsSigned(), + v.Op == ssa.OpARM64MOVWUreg && t.Size() == 4 && !t.IsSigned(): + // arg is a proper-typed load, already zero/sign-extended, don't extend again + if v.Reg() == v.Args[0].Reg() { + return + } + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + return + default: + } + } + fallthrough + case ssa.OpARM64MVN, + ssa.OpARM64NEG, + ssa.OpARM64FABSD, + ssa.OpARM64FMOVDfpgp, + ssa.OpARM64FMOVDgpfp, + ssa.OpARM64FMOVSfpgp, + ssa.OpARM64FMOVSgpfp, + ssa.OpARM64FNEGS, + ssa.OpARM64FNEGD, + ssa.OpARM64FSQRTS, + ssa.OpARM64FSQRTD, + ssa.OpARM64FCVTZSSW, + ssa.OpARM64FCVTZSDW, + ssa.OpARM64FCVTZUSW, + ssa.OpARM64FCVTZUDW, + ssa.OpARM64FCVTZSS, + ssa.OpARM64FCVTZSD, + ssa.OpARM64FCVTZUS, + ssa.OpARM64FCVTZUD, + ssa.OpARM64SCVTFWS, + ssa.OpARM64SCVTFWD, + ssa.OpARM64SCVTFS, + ssa.OpARM64SCVTFD, + ssa.OpARM64UCVTFWS, + ssa.OpARM64UCVTFWD, + ssa.OpARM64UCVTFS, + ssa.OpARM64UCVTFD, + ssa.OpARM64FCVTSD, + ssa.OpARM64FCVTDS, + ssa.OpARM64REV, + ssa.OpARM64REVW, + ssa.OpARM64REV16, + ssa.OpARM64REV16W, + ssa.OpARM64RBIT, + ssa.OpARM64RBITW, + ssa.OpARM64CLZ, + ssa.OpARM64CLZW, + ssa.OpARM64FRINTAD, + ssa.OpARM64FRINTMD, + ssa.OpARM64FRINTND, + ssa.OpARM64FRINTPD, + ssa.OpARM64FRINTZD: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64LoweredRound32F, ssa.OpARM64LoweredRound64F: + // input is already rounded + case ssa.OpARM64VCNT: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = (v.Args[0].Reg()-arm64.REG_F0)&31 + arm64.REG_ARNG + ((arm64.ARNG_8B & 15) << 5) + p.To.Type = obj.TYPE_REG + p.To.Reg = (v.Reg()-arm64.REG_F0)&31 + arm64.REG_ARNG + ((arm64.ARNG_8B & 15) << 5) + case ssa.OpARM64VUADDLV: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = (v.Args[0].Reg()-arm64.REG_F0)&31 + arm64.REG_ARNG + ((arm64.ARNG_8B & 15) << 5) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() - arm64.REG_F0 + arm64.REG_V0 + case ssa.OpARM64CSEL, ssa.OpARM64CSEL0: + r1 := int16(arm64.REGZERO) + if v.Op != ssa.OpARM64CSEL0 { + r1 = v.Args[1].Reg() + } + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_SPECIAL // assembler encodes conditional bits in Offset + condCode := condBits[ssa.Op(v.AuxInt)] + p.From.Offset = int64(condCode) + p.Reg = v.Args[0].Reg() + p.AddRestSourceReg(r1) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64CSINC, ssa.OpARM64CSINV, ssa.OpARM64CSNEG: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_SPECIAL // assembler encodes conditional bits in Offset + condCode := condBits[ssa.Op(v.AuxInt)] + p.From.Offset = int64(condCode) + p.Reg = v.Args[0].Reg() + p.AddRestSourceReg(v.Args[1].Reg()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64CSETM: + p := s.Prog(arm64.ACSETM) + p.From.Type = obj.TYPE_SPECIAL // assembler encodes conditional bits in Offset + condCode := condBits[ssa.Op(v.AuxInt)] + p.From.Offset = int64(condCode) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64CCMP, + ssa.OpARM64CCMN, + ssa.OpARM64CCMPconst, + ssa.OpARM64CCMNconst, + ssa.OpARM64CCMPW, + ssa.OpARM64CCMNW, + ssa.OpARM64CCMPWconst, + ssa.OpARM64CCMNWconst: + p := s.Prog(v.Op.Asm()) + p.Reg = v.Args[0].Reg() + params := v.AuxArm64ConditionalParams() + p.From.Type = obj.TYPE_SPECIAL // assembler encodes conditional bits in Offset + p.From.Offset = int64(condBits[params.Cond()]) + constValue, ok := params.ConstValue() + if ok { + p.AddRestSourceConst(constValue) + } else { + p.AddRestSourceReg(v.Args[1].Reg()) + } + p.To.Type = obj.TYPE_CONST + p.To.Offset = params.Nzcv() + case ssa.OpARM64LoweredZero: + ptrReg := v.Args[0].Reg() + n := v.AuxInt + if n < 16 { + v.Fatalf("Zero too small %d", n) + } + + // Generate zeroing instructions. + var off int64 + for n >= 16 { + // STP (ZR, ZR), off(ptrReg) + zero16(s, ptrReg, off, false) + off += 16 + n -= 16 + } + // Write any fractional portion. + // An overlapping 16-byte write can't be used here + // because STP's offsets must be a multiple of 8. + if n > 8 { + // MOVD ZR, off(ptrReg) + zero8(s, ptrReg, off) + off += 8 + n -= 8 + } + if n != 0 { + // MOVD ZR, off+n-8(ptrReg) + // TODO: for n<=4 we could use a smaller write. + zero8(s, ptrReg, off+n-8) + } + case ssa.OpARM64LoweredZeroLoop: + ptrReg := v.Args[0].Reg() + countReg := v.RegTmp() + n := v.AuxInt + loopSize := int64(64) + if n < 3*loopSize { + // - a loop count of 0 won't work. + // - a loop count of 1 is useless. + // - a loop count of 2 is a code size ~tie + // 3 instructions to implement the loop + // 4 instructions in the loop body + // vs + // 8 instructions in the straightline code + // Might as well use straightline code. + v.Fatalf("ZeroLoop size too small %d", n) + } + + // Put iteration count in a register. + // MOVD $n, countReg + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = n / loopSize + p.To.Type = obj.TYPE_REG + p.To.Reg = countReg + cntInit := p + + // Zero loopSize bytes starting at ptrReg. + // Increment ptrReg by loopSize as a side effect. + for range loopSize / 16 { + // STP.P (ZR, ZR), 16(ptrReg) + zero16(s, ptrReg, 0, true) + // TODO: should we use the postincrement form, + // or use a separate += 64 instruction? + // postincrement saves an instruction, but maybe + // it requires more integer units to do the +=16s. + } + // Decrement loop count. + // SUB $1, countReg + p = s.Prog(arm64.ASUB) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 1 + p.To.Type = obj.TYPE_REG + p.To.Reg = countReg + // Jump to loop header if we're not done yet. + // CBNZ head + p = s.Prog(arm64.ACBNZ) + p.From.Type = obj.TYPE_REG + p.From.Reg = countReg + p.To.Type = obj.TYPE_BRANCH + p.To.SetTarget(cntInit.Link) + + // Multiples of the loop size are now done. + n %= loopSize + + // Write any fractional portion. + var off int64 + for n >= 16 { + // STP (ZR, ZR), off(ptrReg) + zero16(s, ptrReg, off, false) + off += 16 + n -= 16 + } + if n > 8 { + // Note: an overlapping 16-byte write can't be used + // here because STP's offsets must be a multiple of 8. + // MOVD ZR, off(ptrReg) + zero8(s, ptrReg, off) + off += 8 + n -= 8 + } + if n != 0 { + // MOVD ZR, off+n-8(ptrReg) + // TODO: for n<=4 we could use a smaller write. + zero8(s, ptrReg, off+n-8) + } + // TODO: maybe we should use the count register to instead + // hold an end pointer and compare against that? + // ADD $n, ptrReg, endReg + // then + // CMP ptrReg, endReg + // BNE loop + // There's a past-the-end pointer here, any problem with that? + + case ssa.OpARM64LoweredMove: + dstReg := v.Args[0].Reg() + srcReg := v.Args[1].Reg() + if dstReg == srcReg { + break + } + tmpReg1 := int16(arm64.REG_R25) + tmpFReg1 := int16(arm64.REG_F16) + tmpFReg2 := int16(arm64.REG_F17) + n := v.AuxInt + if n < 16 { + v.Fatalf("Move too small %d", n) + } + + // Generate copying instructions. + var off int64 + for n >= 32 { + // FLDPQ off(srcReg), (tmpFReg1, tmpFReg2) + // FSTPQ (tmpFReg1, tmpFReg2), off(dstReg) + move32(s, srcReg, dstReg, tmpFReg1, tmpFReg2, off, false) + off += 32 + n -= 32 + } + for n >= 16 { + // FMOVQ off(src), tmpFReg1 + // FMOVQ tmpFReg1, off(dst) + move16(s, srcReg, dstReg, tmpFReg1, off, false) + off += 16 + n -= 16 + } + if n > 8 { + // MOVD off(srcReg), tmpReg1 + // MOVD tmpReg1, off(dstReg) + move8(s, srcReg, dstReg, tmpReg1, off) + off += 8 + n -= 8 + } + if n != 0 { + // MOVD off+n-8(srcReg), tmpReg1 + // MOVD tmpReg1, off+n-8(dstReg) + move8(s, srcReg, dstReg, tmpReg1, off+n-8) + } + case ssa.OpARM64LoweredMoveLoop: + dstReg := v.Args[0].Reg() + srcReg := v.Args[1].Reg() + if dstReg == srcReg { + break + } + countReg := int16(arm64.REG_R24) + tmpReg1 := int16(arm64.REG_R25) + tmpFReg1 := int16(arm64.REG_F16) + tmpFReg2 := int16(arm64.REG_F17) + n := v.AuxInt + loopSize := int64(64) + if n < 3*loopSize { + // - a loop count of 0 won't work. + // - a loop count of 1 is useless. + // - a loop count of 2 is a code size ~tie + // 3 instructions to implement the loop + // 4 instructions in the loop body + // vs + // 8 instructions in the straightline code + // Might as well use straightline code. + v.Fatalf("ZeroLoop size too small %d", n) + } + + // Put iteration count in a register. + // MOVD $n, countReg + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = n / loopSize + p.To.Type = obj.TYPE_REG + p.To.Reg = countReg + cntInit := p + + // Move loopSize bytes starting at srcReg to dstReg. + // Increment srcReg and destReg by loopSize as a side effect. + for range loopSize / 32 { + // FLDPQ.P 32(srcReg), (tmpFReg1, tmpFReg2) + // FSTPQ.P (tmpFReg1, tmpFReg2), 32(dstReg) + move32(s, srcReg, dstReg, tmpFReg1, tmpFReg2, 0, true) + } + // Decrement loop count. + // SUB $1, countReg + p = s.Prog(arm64.ASUB) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 1 + p.To.Type = obj.TYPE_REG + p.To.Reg = countReg + // Jump to loop header if we're not done yet. + // CBNZ head + p = s.Prog(arm64.ACBNZ) + p.From.Type = obj.TYPE_REG + p.From.Reg = countReg + p.To.Type = obj.TYPE_BRANCH + p.To.SetTarget(cntInit.Link) + + // Multiples of the loop size are now done. + n %= loopSize + + // Copy any fractional portion. + var off int64 + for n >= 32 { + // FLDPQ off(srcReg), (tmpFReg1, tmpFReg2) + // FSTPQ (tmpFReg1, tmpFReg2), off(dstReg) + move32(s, srcReg, dstReg, tmpFReg1, tmpFReg2, off, false) + off += 32 + n -= 32 + } + for n >= 16 { + // FMOVQ off(src), tmpFReg1 + // FMOVQ tmpFReg1, off(dst) + move16(s, srcReg, dstReg, tmpFReg1, off, false) + off += 16 + n -= 16 + } + if n > 8 { + // MOVD off(srcReg), tmpReg1 + // MOVD tmpReg1, off(dstReg) + move8(s, srcReg, dstReg, tmpReg1, off) + off += 8 + n -= 8 + } + if n != 0 { + // MOVD off+n-8(srcReg), tmpReg1 + // MOVD tmpReg1, off+n-8(dstReg) + move8(s, srcReg, dstReg, tmpReg1, off+n-8) + } + + case ssa.OpARM64CALLstatic, ssa.OpARM64CALLclosure, ssa.OpARM64CALLinter: + s.Call(v) + case ssa.OpARM64CALLtail: + s.TailCall(v) + case ssa.OpARM64LoweredWB: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + // AuxInt encodes how many buffer entries we need. + p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1] + case ssa.OpARM64LoweredMemEq: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.Memequal + + case ssa.OpARM64LoweredPanicBoundsRR, ssa.OpARM64LoweredPanicBoundsRC, ssa.OpARM64LoweredPanicBoundsCR, ssa.OpARM64LoweredPanicBoundsCC: + // Compute the constant we put in the PCData entry for this call. + code, signed := ssa.BoundsKind(v.AuxInt).Code() + xIsReg := false + yIsReg := false + xVal := 0 + yVal := 0 + switch v.Op { + case ssa.OpARM64LoweredPanicBoundsRR: + xIsReg = true + xVal = int(v.Args[0].Reg() - arm64.REG_R0) + yIsReg = true + yVal = int(v.Args[1].Reg() - arm64.REG_R0) + case ssa.OpARM64LoweredPanicBoundsRC: + xIsReg = true + xVal = int(v.Args[0].Reg() - arm64.REG_R0) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + if yVal == xVal { + yVal = 1 + } + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = arm64.REG_R0 + int16(yVal) + } + case ssa.OpARM64LoweredPanicBoundsCR: + yIsReg = true + yVal = int(v.Args[0].Reg() - arm64.REG_R0) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + if xVal == yVal { + xVal = 1 + } + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = arm64.REG_R0 + int16(xVal) + } + case ssa.OpARM64LoweredPanicBoundsCC: + c := v.Aux.(ssa.PanicBoundsCC).Cx + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + xIsReg = true + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = arm64.REG_R0 + int16(xVal) + } + c = v.Aux.(ssa.PanicBoundsCC).Cy + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + yVal = 1 + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = arm64.REG_R0 + int16(yVal) + } + } + c := abi.BoundsEncode(code, signed, xIsReg, yIsReg, xVal, yVal) + + p := s.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_PanicBounds) + p.To.SetConst(int64(c)) + p = s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.PanicBounds + + case ssa.OpARM64LoweredNilCheck: + // Issue a load which will fault if arg is nil. + p := s.Prog(arm64.AMOVB) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = arm64.REGTMP + if logopt.Enabled() { + logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name) + } + if base.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Line==1 in generated wrappers + base.WarnfAt(v.Pos, "generated nil check") + } + case ssa.OpARM64Equal, + ssa.OpARM64NotEqual, + ssa.OpARM64LessThan, + ssa.OpARM64LessEqual, + ssa.OpARM64GreaterThan, + ssa.OpARM64GreaterEqual, + ssa.OpARM64LessThanU, + ssa.OpARM64LessEqualU, + ssa.OpARM64GreaterThanU, + ssa.OpARM64GreaterEqualU, + ssa.OpARM64LessThanF, + ssa.OpARM64LessEqualF, + ssa.OpARM64GreaterThanF, + ssa.OpARM64GreaterEqualF, + ssa.OpARM64NotLessThanF, + ssa.OpARM64NotLessEqualF, + ssa.OpARM64NotGreaterThanF, + ssa.OpARM64NotGreaterEqualF, + ssa.OpARM64LessThanNoov, + ssa.OpARM64GreaterEqualNoov: + // generate boolean values using CSET + p := s.Prog(arm64.ACSET) + p.From.Type = obj.TYPE_SPECIAL // assembler encodes conditional bits in Offset + condCode := condBits[v.Op] + p.From.Offset = int64(condCode) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64PRFM: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_CONST + p.To.Offset = v.AuxInt + case ssa.OpARM64LoweredGetClosurePtr: + // Closure pointer is R26 (arm64.REGCTXT). + ssagen.CheckLoweredGetClosurePtr(v) + case ssa.OpARM64LoweredGetCallerSP: + // caller's SP is FixedFrameSize below the address of the first arg + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_ADDR + p.From.Offset = -base.Ctxt.Arch.FixedFrameSize + p.From.Name = obj.NAME_PARAM + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64LoweredGetCallerPC: + p := s.Prog(obj.AGETCALLERPC) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpARM64DMB: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + case ssa.OpARM64FlagConstant: + v.Fatalf("FlagConstant op should never make it to codegen %v", v.LongString()) + case ssa.OpARM64InvertFlags: + v.Fatalf("InvertFlags should never make it to codegen %v", v.LongString()) + case ssa.OpClobber: + // MOVW $0xdeaddead, REGTMP + // MOVW REGTMP, (slot) + // MOVW REGTMP, 4(slot) + p := s.Prog(arm64.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 0xdeaddead + p.To.Type = obj.TYPE_REG + p.To.Reg = arm64.REGTMP + p = s.Prog(arm64.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = arm64.REGTMP + p.To.Type = obj.TYPE_MEM + p.To.Reg = arm64.REGSP + ssagen.AddAux(&p.To, v) + p = s.Prog(arm64.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = arm64.REGTMP + p.To.Type = obj.TYPE_MEM + p.To.Reg = arm64.REGSP + ssagen.AddAux2(&p.To, v, v.AuxInt+4) + case ssa.OpClobberReg: + x := uint64(0xdeaddeaddeaddead) + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(x) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + default: + v.Fatalf("genValue not implemented: %s", v.LongString()) + } +} + +var condBits = map[ssa.Op]arm64.SpecialOperand{ + ssa.OpARM64Equal: arm64.SPOP_EQ, + ssa.OpARM64NotEqual: arm64.SPOP_NE, + ssa.OpARM64LessThan: arm64.SPOP_LT, + ssa.OpARM64LessThanU: arm64.SPOP_LO, + ssa.OpARM64LessEqual: arm64.SPOP_LE, + ssa.OpARM64LessEqualU: arm64.SPOP_LS, + ssa.OpARM64GreaterThan: arm64.SPOP_GT, + ssa.OpARM64GreaterThanU: arm64.SPOP_HI, + ssa.OpARM64GreaterEqual: arm64.SPOP_GE, + ssa.OpARM64GreaterEqualU: arm64.SPOP_HS, + ssa.OpARM64LessThanF: arm64.SPOP_MI, // Less than + ssa.OpARM64LessEqualF: arm64.SPOP_LS, // Less than or equal to + ssa.OpARM64GreaterThanF: arm64.SPOP_GT, // Greater than + ssa.OpARM64GreaterEqualF: arm64.SPOP_GE, // Greater than or equal to + + // The following condition codes have unordered to handle comparisons related to NaN. + ssa.OpARM64NotLessThanF: arm64.SPOP_PL, // Greater than, equal to, or unordered + ssa.OpARM64NotLessEqualF: arm64.SPOP_HI, // Greater than or unordered + ssa.OpARM64NotGreaterThanF: arm64.SPOP_LE, // Less than, equal to or unordered + ssa.OpARM64NotGreaterEqualF: arm64.SPOP_LT, // Less than or unordered + + ssa.OpARM64LessThanNoov: arm64.SPOP_MI, // Less than but without honoring overflow + ssa.OpARM64GreaterEqualNoov: arm64.SPOP_PL, // Greater than or equal to but without honoring overflow +} + +var blockJump = map[ssa.BlockKind]struct { + asm, invasm obj.As +}{ + ssa.BlockARM64EQ: {arm64.ABEQ, arm64.ABNE}, + ssa.BlockARM64NE: {arm64.ABNE, arm64.ABEQ}, + ssa.BlockARM64LT: {arm64.ABLT, arm64.ABGE}, + ssa.BlockARM64GE: {arm64.ABGE, arm64.ABLT}, + ssa.BlockARM64LE: {arm64.ABLE, arm64.ABGT}, + ssa.BlockARM64GT: {arm64.ABGT, arm64.ABLE}, + ssa.BlockARM64ULT: {arm64.ABLO, arm64.ABHS}, + ssa.BlockARM64UGE: {arm64.ABHS, arm64.ABLO}, + ssa.BlockARM64UGT: {arm64.ABHI, arm64.ABLS}, + ssa.BlockARM64ULE: {arm64.ABLS, arm64.ABHI}, + ssa.BlockARM64Z: {arm64.ACBZ, arm64.ACBNZ}, + ssa.BlockARM64NZ: {arm64.ACBNZ, arm64.ACBZ}, + ssa.BlockARM64ZW: {arm64.ACBZW, arm64.ACBNZW}, + ssa.BlockARM64NZW: {arm64.ACBNZW, arm64.ACBZW}, + ssa.BlockARM64TBZ: {arm64.ATBZ, arm64.ATBNZ}, + ssa.BlockARM64TBNZ: {arm64.ATBNZ, arm64.ATBZ}, + ssa.BlockARM64FLT: {arm64.ABMI, arm64.ABPL}, + ssa.BlockARM64FGE: {arm64.ABGE, arm64.ABLT}, + ssa.BlockARM64FLE: {arm64.ABLS, arm64.ABHI}, + ssa.BlockARM64FGT: {arm64.ABGT, arm64.ABLE}, + ssa.BlockARM64LTnoov: {arm64.ABMI, arm64.ABPL}, + ssa.BlockARM64GEnoov: {arm64.ABPL, arm64.ABMI}, +} + +// To model a 'LEnoov' ('<=' without overflow checking) branching. +var leJumps = [2][2]ssagen.IndexJump{ + {{Jump: arm64.ABEQ, Index: 0}, {Jump: arm64.ABPL, Index: 1}}, // next == b.Succs[0] + {{Jump: arm64.ABMI, Index: 0}, {Jump: arm64.ABEQ, Index: 0}}, // next == b.Succs[1] +} + +// To model a 'GTnoov' ('>' without overflow checking) branching. +var gtJumps = [2][2]ssagen.IndexJump{ + {{Jump: arm64.ABMI, Index: 1}, {Jump: arm64.ABEQ, Index: 1}}, // next == b.Succs[0] + {{Jump: arm64.ABEQ, Index: 1}, {Jump: arm64.ABPL, Index: 0}}, // next == b.Succs[1] +} + +func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) { + switch b.Kind { + case ssa.BlockPlain, ssa.BlockDefer: + if b.Succs[0].Block() != next { + p := s.Prog(obj.AJMP) + p.To.Type = obj.TYPE_BRANCH + s.Branches = append(s.Branches, ssagen.Branch{P: p, B: b.Succs[0].Block()}) + } + + case ssa.BlockExit, ssa.BlockRetJmp: + + case ssa.BlockRet: + s.Prog(obj.ARET) + + case ssa.BlockARM64EQ, ssa.BlockARM64NE, + ssa.BlockARM64LT, ssa.BlockARM64GE, + ssa.BlockARM64LE, ssa.BlockARM64GT, + ssa.BlockARM64ULT, ssa.BlockARM64UGT, + ssa.BlockARM64ULE, ssa.BlockARM64UGE, + ssa.BlockARM64Z, ssa.BlockARM64NZ, + ssa.BlockARM64ZW, ssa.BlockARM64NZW, + ssa.BlockARM64FLT, ssa.BlockARM64FGE, + ssa.BlockARM64FLE, ssa.BlockARM64FGT, + ssa.BlockARM64LTnoov, ssa.BlockARM64GEnoov: + jmp := blockJump[b.Kind] + var p *obj.Prog + switch next { + case b.Succs[0].Block(): + p = s.Br(jmp.invasm, b.Succs[1].Block()) + case b.Succs[1].Block(): + p = s.Br(jmp.asm, b.Succs[0].Block()) + default: + if b.Likely != ssa.BranchUnlikely { + p = s.Br(jmp.asm, b.Succs[0].Block()) + s.Br(obj.AJMP, b.Succs[1].Block()) + } else { + p = s.Br(jmp.invasm, b.Succs[1].Block()) + s.Br(obj.AJMP, b.Succs[0].Block()) + } + } + if !b.Controls[0].Type.IsFlags() { + p.From.Type = obj.TYPE_REG + p.From.Reg = b.Controls[0].Reg() + } + case ssa.BlockARM64TBZ, ssa.BlockARM64TBNZ: + jmp := blockJump[b.Kind] + var p *obj.Prog + switch next { + case b.Succs[0].Block(): + p = s.Br(jmp.invasm, b.Succs[1].Block()) + case b.Succs[1].Block(): + p = s.Br(jmp.asm, b.Succs[0].Block()) + default: + if b.Likely != ssa.BranchUnlikely { + p = s.Br(jmp.asm, b.Succs[0].Block()) + s.Br(obj.AJMP, b.Succs[1].Block()) + } else { + p = s.Br(jmp.invasm, b.Succs[1].Block()) + s.Br(obj.AJMP, b.Succs[0].Block()) + } + } + p.From.Offset = b.AuxInt + p.From.Type = obj.TYPE_CONST + p.Reg = b.Controls[0].Reg() + + case ssa.BlockARM64LEnoov: + s.CombJump(b, next, &leJumps) + case ssa.BlockARM64GTnoov: + s.CombJump(b, next, >Jumps) + + case ssa.BlockARM64JUMPTABLE: + // MOVD (TABLE)(IDX<<3), Rtmp + // JMP (Rtmp) + p := s.Prog(arm64.AMOVD) + p.From = genIndexedOperand(ssa.OpARM64MOVDloadidx8, b.Controls[1].Reg(), b.Controls[0].Reg()) + p.To.Type = obj.TYPE_REG + p.To.Reg = arm64.REGTMP + p = s.Prog(obj.AJMP) + p.To.Type = obj.TYPE_MEM + p.To.Reg = arm64.REGTMP + // Save jump tables for later resolution of the target blocks. + s.JumpTables = append(s.JumpTables, b) + + default: + b.Fatalf("branch not implemented: %s", b.LongString()) + } +} + +func loadRegResult(s *ssagen.State, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p := s.Prog(loadByType(t)) + p.From.Type = obj.TYPE_MEM + p.From.Name = obj.NAME_AUTO + p.From.Sym = n.Linksym() + p.From.Offset = n.FrameOffset() + off + p.To.Type = obj.TYPE_REG + p.To.Reg = reg + return p +} + +func spillArgReg(pp *objw.Progs, p *obj.Prog, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p = pp.Append(p, storeByType(t), obj.TYPE_REG, reg, 0, obj.TYPE_MEM, 0, n.FrameOffset()+off) + p.To.Name = obj.NAME_PARAM + p.To.Sym = n.Linksym() + p.Pos = p.Pos.WithNotStmt() + return p +} + +// zero16 zeroes 16 bytes at reg+off. +// If postInc is true, increment reg by 16. +func zero16(s *ssagen.State, reg int16, off int64, postInc bool) { + // STP (ZR, ZR), off(reg) + p := s.Prog(arm64.ASTP) + p.From.Type = obj.TYPE_REGREG + p.From.Reg = arm64.REGZERO + p.From.Offset = int64(arm64.REGZERO) + p.To.Type = obj.TYPE_MEM + p.To.Reg = reg + p.To.Offset = off + if postInc { + if off != 0 { + panic("can't postinc with non-zero offset") + } + // STP.P (ZR, ZR), 16(reg) + p.Scond = arm64.C_XPOST + p.To.Offset = 16 + } +} + +// zero8 zeroes 8 bytes at reg+off. +func zero8(s *ssagen.State, reg int16, off int64) { + // MOVD ZR, off(reg) + p := s.Prog(arm64.AMOVD) + p.From.Type = obj.TYPE_REG + p.From.Reg = arm64.REGZERO + p.To.Type = obj.TYPE_MEM + p.To.Reg = reg + p.To.Offset = off +} + +// move32 copies 32 bytes at src+off to dst+off. +// Uses registers tmp1 and tmp2. +// If postInc is true, increment src and dst by 32. +func move32(s *ssagen.State, src, dst, tmp1, tmp2 int16, off int64, postInc bool) { + // FLDPQ off(src), (tmp1, tmp2) + ld := s.Prog(arm64.AFLDPQ) + ld.From.Type = obj.TYPE_MEM + ld.From.Reg = src + ld.From.Offset = off + ld.To.Type = obj.TYPE_REGREG + ld.To.Reg = tmp1 + ld.To.Offset = int64(tmp2) + // FSTPQ (tmp1, tmp2), off(dst) + st := s.Prog(arm64.AFSTPQ) + st.From.Type = obj.TYPE_REGREG + st.From.Reg = tmp1 + st.From.Offset = int64(tmp2) + st.To.Type = obj.TYPE_MEM + st.To.Reg = dst + st.To.Offset = off + if postInc { + if off != 0 { + panic("can't postinc with non-zero offset") + } + ld.Scond = arm64.C_XPOST + st.Scond = arm64.C_XPOST + ld.From.Offset = 32 + st.To.Offset = 32 + } +} + +// move16 copies 16 bytes at src+off to dst+off. +// Uses register tmp1 +// If postInc is true, increment src and dst by 16. +func move16(s *ssagen.State, src, dst, tmp1 int16, off int64, postInc bool) { + // FMOVQ off(src), tmp1 + ld := s.Prog(arm64.AFMOVQ) + ld.From.Type = obj.TYPE_MEM + ld.From.Reg = src + ld.From.Offset = off + ld.To.Type = obj.TYPE_REG + ld.To.Reg = tmp1 + // FMOVQ tmp1, off(dst) + st := s.Prog(arm64.AFMOVQ) + st.From.Type = obj.TYPE_REG + st.From.Reg = tmp1 + st.To.Type = obj.TYPE_MEM + st.To.Reg = dst + st.To.Offset = off + if postInc { + if off != 0 { + panic("can't postinc with non-zero offset") + } + ld.Scond = arm64.C_XPOST + st.Scond = arm64.C_XPOST + ld.From.Offset = 16 + st.To.Offset = 16 + } +} + +// move8 copies 8 bytes at src+off to dst+off. +// Uses register tmp. +func move8(s *ssagen.State, src, dst, tmp int16, off int64) { + // MOVD off(src), tmp + ld := s.Prog(arm64.AMOVD) + ld.From.Type = obj.TYPE_MEM + ld.From.Reg = src + ld.From.Offset = off + ld.To.Type = obj.TYPE_REG + ld.To.Reg = tmp + // MOVD tmp, off(dst) + st := s.Prog(arm64.AMOVD) + st.From.Type = obj.TYPE_REG + st.From.Reg = tmp + st.To.Type = obj.TYPE_MEM + st.To.Reg = dst + st.To.Offset = off +} diff --git a/go/src/cmd/compile/internal/base/base.go b/go/src/cmd/compile/internal/base/base.go new file mode 100644 index 0000000000000000000000000000000000000000..405c7938a51aad16e92f69b8ff480e85b61b78bb --- /dev/null +++ b/go/src/cmd/compile/internal/base/base.go @@ -0,0 +1,27 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "os" +) + +var atExitFuncs []func() + +func AtExit(f func()) { + atExitFuncs = append(atExitFuncs, f) +} + +func Exit(code int) { + for i := len(atExitFuncs) - 1; i >= 0; i-- { + f := atExitFuncs[i] + atExitFuncs = atExitFuncs[:i] + f() + } + os.Exit(code) +} + +// To enable tracing support (-t flag), set EnableTrace to true. +const EnableTrace = false diff --git a/go/src/cmd/compile/internal/base/bootstrap_false.go b/go/src/cmd/compile/internal/base/bootstrap_false.go new file mode 100644 index 0000000000000000000000000000000000000000..ea6da4348f53971936dcfbeb2055f137ca246011 --- /dev/null +++ b/go/src/cmd/compile/internal/base/bootstrap_false.go @@ -0,0 +1,11 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !compiler_bootstrap + +package base + +// CompilerBootstrap reports whether the current compiler binary was +// built with -tags=compiler_bootstrap. +const CompilerBootstrap = false diff --git a/go/src/cmd/compile/internal/base/bootstrap_true.go b/go/src/cmd/compile/internal/base/bootstrap_true.go new file mode 100644 index 0000000000000000000000000000000000000000..d0c6c88f56f94cc20f559e1bff38252853ca3354 --- /dev/null +++ b/go/src/cmd/compile/internal/base/bootstrap_true.go @@ -0,0 +1,11 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build compiler_bootstrap + +package base + +// CompilerBootstrap reports whether the current compiler binary was +// built with -tags=compiler_bootstrap. +const CompilerBootstrap = true diff --git a/go/src/cmd/compile/internal/base/debug.go b/go/src/cmd/compile/internal/base/debug.go new file mode 100644 index 0000000000000000000000000000000000000000..5e0268bb8813043263b64b1176bba01c7959ff6a --- /dev/null +++ b/go/src/cmd/compile/internal/base/debug.go @@ -0,0 +1,95 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Debug arguments, set by -d flag. + +package base + +// Debug holds the parsed debugging configuration values. +var Debug DebugFlags + +// DebugFlags defines the debugging configuration values (see var Debug). +// Each struct field is a different value, named for the lower-case of the field name. +// Each field must be an int or string and must have a `help` struct tag. +// +// The -d option takes a comma-separated list of settings. +// Each setting is name=value; for ints, name is short for name=1. +type DebugFlags struct { + AlignHot int `help:"enable hot block alignment (currently requires -pgo)" concurrent:"ok"` + Append int `help:"print information about append compilation"` + Checkptr int `help:"instrument unsafe pointer conversions\n0: instrumentation disabled\n1: conversions involving unsafe.Pointer are instrumented\n2: conversions to unsafe.Pointer force heap allocation" concurrent:"ok"` + Closure int `help:"print information about closure compilation"` + CompressInstructions int `help:"use compressed instructions when possible (if supported by architecture)"` + Converthash string `help:"hash value for use in debugging changes to platform-dependent float-to-[u]int conversion" concurrent:"ok"` + Defer int `help:"print information about defer compilation"` + DisableNil int `help:"disable nil checks" concurrent:"ok"` + DumpInlFuncProps string `help:"dump function properties from inl heuristics to specified file"` + DumpInlCallSiteScores int `help:"dump scored callsites during inlining"` + InlScoreAdj string `help:"set inliner score adjustments (ex: -d=inlscoreadj=panicPathAdj:10/passConstToNestedIfAdj:-90)"` + InlBudgetSlack int `help:"amount to expand the initial inline budget when new inliner enabled. Defaults to 80 if option not set." concurrent:"ok"` + DumpPtrs int `help:"show Node pointers values in dump output"` + DwarfInl int `help:"print information about DWARF inlined function creation"` + EscapeMutationsCalls int `help:"print extra escape analysis diagnostics about mutations and calls" concurrent:"ok"` + EscapeDebug int `help:"print information about escape analysis and resulting optimizations" concurrent:"ok"` + EscapeAlias int `help:"print information about alias analysis" concurrent:"ok"` + EscapeAliasCheck int `help:"enable additional validation for alias analysis" concurrent:"ok"` + Export int `help:"print export data"` + FIPSHash string `help:"hash value for FIPS debugging" concurrent:"ok"` + Fmahash string `help:"hash value for use in debugging platform-dependent multiply-add use" concurrent:"ok"` + FreeAppend int `help:"insert frees of append results when proven safe (0 disabled, 1 enabled, 2 enabled + log)" concurrent:"ok"` + GCAdjust int `help:"log adjustments to GOGC" concurrent:"ok"` + GCCheck int `help:"check heap/gc use by compiler" concurrent:"ok"` + GCProg int `help:"print dump of GC programs"` + GCStart int `help:"specify \"starting\" compiler's heap size in MiB" concurrent:"ok"` + Gossahash string `help:"hash value for use in debugging the compiler"` + InlFuncsWithClosures int `help:"allow functions with closures to be inlined" concurrent:"ok"` + InlStaticInit int `help:"allow static initialization of inlined calls" concurrent:"ok"` + Libfuzzer int `help:"enable coverage instrumentation for libfuzzer"` + LiteralAllocHash string `help:"hash value for use in debugging literal allocation optimizations" concurrent:"ok"` + LoopVar int `help:"shared (0, default), 1 (private loop variables), 2, private + log"` + LoopVarHash string `help:"for debugging changes in loop behavior. Overrides experiment and loopvar flag."` + LocationLists int `help:"print information about DWARF location list creation"` + MaxShapeLen int `help:"hash shape names longer than this threshold (default 500)" concurrent:"ok"` + MergeLocals int `help:"merge together non-interfering local stack slots" concurrent:"ok"` + MergeLocalsDumpFunc string `help:"dump specified func in merge locals"` + MergeLocalsHash string `help:"hash value for debugging stack slot merging of local variables" concurrent:"ok"` + MergeLocalsTrace int `help:"trace debug output for locals merging"` + MergeLocalsHTrace int `help:"hash-selected trace debug output for locals merging"` + Nil int `help:"print information about nil checks"` + NoDeadLocals int `help:"disable deadlocals pass" concurrent:"ok"` + NoOpenDefer int `help:"disable open-coded defers" concurrent:"ok"` + NoRefName int `help:"do not include referenced symbol names in object file" concurrent:"ok"` + PCTab string `help:"print named pc-value table\nOne of: pctospadj, pctofile, pctoline, pctoinline, pctopcdata"` + Panic int `help:"show all compiler panics"` + Reshape int `help:"print information about expression reshaping"` + Shapify int `help:"print information about shaping recursive types"` + Slice int `help:"print information about slice compilation"` + SoftFloat int `help:"force compiler to emit soft-float code" concurrent:"ok"` + StaticCopy int `help:"print information about missed static copies" concurrent:"ok"` + SyncFrames int `help:"how many writer stack frames to include at sync points in unified export data"` + TailCall int `help:"print information about tail calls"` + TypeAssert int `help:"print information about type assertion inlining"` + WB int `help:"print information about write barriers"` + ABIWrap int `help:"print information about ABI wrapper generation"` + MayMoreStack string `help:"call named function before all stack growth checks" concurrent:"ok"` + PGODebug int `help:"debug profile-guided optimizations"` + PGOHash string `help:"hash value for debugging profile-guided optimizations" concurrent:"ok"` + PGOInline int `help:"enable profile-guided inlining" concurrent:"ok"` + PGOInlineCDFThreshold string `help:"cumulative threshold percentage for determining call sites as hot candidates for inlining" concurrent:"ok"` + PGOInlineBudget int `help:"inline budget for hot functions" concurrent:"ok"` + PGODevirtualize int `help:"enable profile-guided devirtualization; 0 to disable, 1 to enable interface devirtualization, 2 to enable function devirtualization" concurrent:"ok"` + RangeFuncCheck int `help:"insert code to check behavior of range iterator functions" concurrent:"ok"` + VariableMakeHash string `help:"hash value for debugging stack allocation of variable-sized make results" concurrent:"ok"` + VariableMakeThreshold int `help:"threshold in bytes for possible stack allocation of variable-sized make results" concurrent:"ok"` + WrapGlobalMapDbg int `help:"debug trace output for global map init wrapping"` + WrapGlobalMapCtl int `help:"global map init wrap control (0 => default, 1 => off, 2 => stress mode, no size cutoff)"` + ZeroCopy int `help:"enable zero-copy string->[]byte conversions" concurrent:"ok"` + + ConcurrentOk bool // true if only concurrentOk flags seen +} + +// DebugSSA is called to set a -d ssa/... option. +// If nil, those options are reported as invalid options. +// If DebugSSA returns a non-empty string, that text is reported as a compiler error. +var DebugSSA func(phase, flag string, val int, valString string) string diff --git a/go/src/cmd/compile/internal/base/flag.go b/go/src/cmd/compile/internal/base/flag.go new file mode 100644 index 0000000000000000000000000000000000000000..4a2b7c5434f210dcae99603c606c58fb8dce0c21 --- /dev/null +++ b/go/src/cmd/compile/internal/base/flag.go @@ -0,0 +1,607 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "cmd/internal/cov/covcmd" + "cmd/internal/telemetry/counter" + "encoding/json" + "flag" + "fmt" + "internal/buildcfg" + "internal/platform" + "log" + "os" + "reflect" + "runtime" + "strings" + + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/sys" +) + +func usage() { + fmt.Fprintf(os.Stderr, "usage: compile [options] file.go...\n") + objabi.Flagprint(os.Stderr) + Exit(2) +} + +// Flag holds the parsed command-line flags. +// See ParseFlag for non-zero defaults. +var Flag CmdFlags + +// A CountFlag is a counting integer flag. +// It accepts -name=value to set the value directly, +// but it also accepts -name with no =value to increment the count. +type CountFlag int + +// CmdFlags defines the command-line flags (see var Flag). +// Each struct field is a different flag, by default named for the lower-case of the field name. +// If the flag name is a single letter, the default flag name is left upper-case. +// If the flag name is "Lower" followed by a single letter, the default flag name is the lower-case of the last letter. +// +// If this default flag name can't be made right, the `flag` struct tag can be used to replace it, +// but this should be done only in exceptional circumstances: it helps everyone if the flag name +// is obvious from the field name when the flag is used elsewhere in the compiler sources. +// The `flag:"-"` struct tag makes a field invisible to the flag logic and should also be used sparingly. +// +// Each field must have a `help` struct tag giving the flag help message. +// +// The allowed field types are bool, int, string, pointers to those (for values stored elsewhere), +// CountFlag (for a counting flag), and func(string) (for a flag that uses special code for parsing). +type CmdFlags struct { + // Single letters + B CountFlag "help:\"disable bounds checking\"" + C CountFlag "help:\"disable printing of columns in error messages\"" + D string "help:\"set relative `path` for local imports\"" + E CountFlag "help:\"debug symbol export\"" + I func(string) "help:\"add `directory` to import search path\"" + K CountFlag "help:\"debug missing line numbers\"" + L CountFlag "help:\"also show actual source file names in error messages for positions affected by //line directives\"" + N CountFlag "help:\"disable optimizations\"" + S CountFlag "help:\"print assembly listing\"" + // V is added by objabi.AddVersionFlag + W CountFlag "help:\"debug parse tree after type checking\"" + + LowerC int "help:\"concurrency during compilation (1 means no concurrency)\"" + LowerD flag.Value "help:\"enable debugging settings; try -d help\"" + LowerE CountFlag "help:\"no limit on number of errors reported\"" + LowerH CountFlag "help:\"halt on error\"" + LowerJ CountFlag "help:\"debug runtime-initialized variables\"" + LowerL CountFlag "help:\"disable inlining\"" + LowerM CountFlag "help:\"print optimization decisions\"" + LowerO string "help:\"write output to `file`\"" + LowerP *string "help:\"set expected package import `path`\"" // &Ctxt.Pkgpath, set below + LowerR CountFlag "help:\"debug generated wrappers\"" + LowerT bool "help:\"enable tracing for debugging the compiler\"" + LowerW CountFlag "help:\"debug type checking\"" + LowerV *bool "help:\"increase debug verbosity\"" + + // Special characters + Percent CountFlag "flag:\"%\" help:\"debug non-static initializers\"" + CompilingRuntime bool "flag:\"+\" help:\"compiling runtime\"" + + // Longer names + AsmHdr string "help:\"write assembly header to `file`\"" + ASan bool "help:\"build code compatible with C/C++ address sanitizer\"" + Bench string "help:\"append benchmark times to `file`\"" + BlockProfile string "help:\"write block profile to `file`\"" + BuildID string "help:\"record `id` as the build id in the export metadata\"" + CPUProfile string "help:\"write cpu profile to `file`\"" + Complete bool "help:\"compiling complete package (no C or assembly)\"" + ClobberDead bool "help:\"clobber dead stack slots (for debugging)\"" + ClobberDeadReg bool "help:\"clobber dead registers (for debugging)\"" + Dwarf bool "help:\"generate DWARF symbols\"" + DwarfBASEntries *bool "help:\"use base address selection entries in DWARF\"" // &Ctxt.UseBASEntries, set below + DwarfLocationLists *bool "help:\"add location lists to DWARF in optimized mode\"" // &Ctxt.Flag_locationlists, set below + Dynlink *bool "help:\"support references to Go symbols defined in other shared libraries\"" // &Ctxt.Flag_dynlink, set below + EmbedCfg func(string) "help:\"read go:embed configuration from `file`\"" + Env func(string) "help:\"add `definition` of the form key=value to environment\"" + GenDwarfInl int "help:\"generate DWARF inline info records\"" // 0=disabled, 1=funcs, 2=funcs+formals/locals + GoVersion string "help:\"required version of the runtime\"" + ImportCfg func(string) "help:\"read import configuration from `file`\"" + InstallSuffix string "help:\"set pkg directory `suffix`\"" + JSON string "help:\"version,file for JSON compiler/optimizer detail output\"" + Lang string "help:\"Go language version source code expects\"" + LinkObj string "help:\"write linker-specific object to `file`\"" + LinkShared *bool "help:\"generate code that will be linked against Go shared libraries\"" // &Ctxt.Flag_linkshared, set below + Live CountFlag "help:\"debug liveness analysis\"" + MSan bool "help:\"build code compatible with C/C++ memory sanitizer\"" + MemProfile string "help:\"write memory profile to `file`\"" + MemProfileRate int "help:\"set runtime.MemProfileRate to `rate`\"" + MutexProfile string "help:\"write mutex profile to `file`\"" + NoLocalImports bool "help:\"reject local (relative) imports\"" + CoverageCfg func(string) "help:\"read coverage configuration from `file`\"" + Pack bool "help:\"write to file.a instead of file.o\"" + Race bool "help:\"enable race detector\"" + Shared *bool "help:\"generate code that can be linked into a shared library\"" // &Ctxt.Flag_shared, set below + SmallFrames bool "help:\"reduce the size limit for stack allocated objects\"" // small stacks, to diagnose GC latency; see golang.org/issue/27732 + Spectre string "help:\"enable spectre mitigations in `list` (all, index, ret)\"" + Std bool "help:\"compiling standard library\"" + SymABIs string "help:\"read symbol ABIs from `file`\"" + TraceProfile string "help:\"write an execution trace to `file`\"" + TrimPath string "help:\"remove `prefix` from recorded source file paths\"" + WB bool "help:\"enable write barrier\"" // TODO: remove + PgoProfile string "help:\"read profile or pre-process profile from `file`\"" + ErrorURL bool "help:\"print explanatory URL with error message if applicable\"" + + // Configuration derived from flags; not a flag itself. + Cfg struct { + Embed struct { // set by -embedcfg + Patterns map[string][]string + Files map[string]string + } + ImportDirs []string // appended to by -I + ImportMap map[string]string // set by -importcfg + PackageFile map[string]string // set by -importcfg; nil means not in use + CoverageInfo *covcmd.CoverFixupConfig // set by -coveragecfg + SpectreIndex bool // set by -spectre=index or -spectre=all + // Whether we are adding any sort of code instrumentation, such as + // when the race detector is enabled. + Instrumenting bool + } +} + +func addEnv(s string) { + i := strings.Index(s, "=") + if i < 0 { + log.Fatal("-env argument must be of the form key=value") + } + os.Setenv(s[:i], s[i+1:]) +} + +// ParseFlags parses the command-line flags into Flag. +func ParseFlags() { + Flag.I = addImportDir + + Flag.LowerC = runtime.GOMAXPROCS(0) + Flag.LowerD = objabi.NewDebugFlag(&Debug, DebugSSA) + Flag.LowerP = &Ctxt.Pkgpath + Flag.LowerV = &Ctxt.Debugvlog + + Flag.Dwarf = buildcfg.GOARCH != "wasm" + Flag.DwarfBASEntries = &Ctxt.UseBASEntries + Flag.DwarfLocationLists = &Ctxt.Flag_locationlists + *Flag.DwarfLocationLists = true + Flag.Dynlink = &Ctxt.Flag_dynlink + Flag.EmbedCfg = readEmbedCfg + Flag.Env = addEnv + Flag.GenDwarfInl = 2 + Flag.ImportCfg = readImportCfg + Flag.CoverageCfg = readCoverageCfg + Flag.LinkShared = &Ctxt.Flag_linkshared + Flag.Shared = &Ctxt.Flag_shared + Flag.WB = true + + Debug.ConcurrentOk = true + Debug.CompressInstructions = 1 + Debug.MaxShapeLen = 500 + Debug.AlignHot = 1 + Debug.InlFuncsWithClosures = 1 + Debug.InlStaticInit = 1 + Debug.FreeAppend = 1 + Debug.PGOInline = 1 + Debug.PGODevirtualize = 2 + Debug.SyncFrames = -1 // disable sync markers by default + Debug.VariableMakeThreshold = 32 // 32 byte default for stack allocated make results + Debug.ZeroCopy = 1 + Debug.RangeFuncCheck = 1 + Debug.MergeLocals = 1 + + Debug.Checkptr = -1 // so we can tell whether it is set explicitly + + Flag.Cfg.ImportMap = make(map[string]string) + + objabi.AddVersionFlag() // -V + registerFlags() + objabi.Flagparse(usage) + counter.CountFlags("compile/flag:", *flag.CommandLine) + + if gcd := os.Getenv("GOCOMPILEDEBUG"); gcd != "" { + // This will only override the flags set in gcd; + // any others set on the command line remain set. + Flag.LowerD.Set(gcd) + } + + if Debug.Gossahash != "" { + hashDebug = NewHashDebug("gossahash", Debug.Gossahash, nil) + } + obj.SetFIPSDebugHash(Debug.FIPSHash) + + // Compute whether we're compiling the runtime from the package path. Test + // code can also use the flag to set this explicitly. + if Flag.Std && objabi.LookupPkgSpecial(Ctxt.Pkgpath).Runtime { + Flag.CompilingRuntime = true + } + + Ctxt.Std = Flag.Std + + // Three inputs govern loop iteration variable rewriting, hash, experiment, flag. + // The loop variable rewriting is: + // IF non-empty hash, then hash determines behavior (function+line match) (*) + // ELSE IF experiment and flag==0, then experiment (set flag=1) + // ELSE flag (note that build sets flag per-package), with behaviors: + // -1 => no change to behavior. + // 0 => no change to behavior (unless non-empty hash, see above) + // 1 => apply change to likely-iteration-variable-escaping loops + // 2 => apply change, log results + // 11 => apply change EVERYWHERE, do not log results (for debugging/benchmarking) + // 12 => apply change EVERYWHERE, log results (for debugging/benchmarking) + // + // The expected uses of the these inputs are, in believed most-likely to least likely: + // GOEXPERIMENT=loopvar -- apply change to entire application + // -gcflags=some_package=-d=loopvar=1 -- apply change to some_package (**) + // -gcflags=some_package=-d=loopvar=2 -- apply change to some_package, log it + // GOEXPERIMENT=loopvar -gcflags=some_package=-d=loopvar=-1 -- apply change to all but one package + // GOCOMPILEDEBUG=loopvarhash=... -- search for failure cause + // + // (*) For debugging purposes, providing loopvar flag >= 11 will expand the hash-eligible set of loops to all. + // (**) Loop semantics, changed or not, follow code from a package when it is inlined; that is, the behavior + // of an application compiled with partially modified loop semantics does not depend on inlining. + + if Debug.LoopVarHash != "" { + // This first little bit controls the inputs for debug-hash-matching. + mostInlineOnly := true + if strings.HasPrefix(Debug.LoopVarHash, "IL") { + // When hash-searching on a position that is an inline site, default is to use the + // most-inlined position only. This makes the hash faster, plus there's no point + // reporting a problem with all the inlining; there's only one copy of the source. + // However, if for some reason you wanted it per-site, you can get this. (The default + // hash-search behavior for compiler debugging is at an inline site.) + Debug.LoopVarHash = Debug.LoopVarHash[2:] + mostInlineOnly = false + } + // end of testing trickiness + LoopVarHash = NewHashDebug("loopvarhash", Debug.LoopVarHash, nil) + if Debug.LoopVar < 11 { // >= 11 means all loops are rewrite-eligible + Debug.LoopVar = 1 // 1 means those loops that syntactically escape their dcl vars are eligible. + } + LoopVarHash.SetInlineSuffixOnly(mostInlineOnly) + } else if buildcfg.Experiment.LoopVar && Debug.LoopVar == 0 { + Debug.LoopVar = 1 + } + + if Debug.Converthash != "" { + ConvertHash = NewHashDebug("converthash", Debug.Converthash, nil) + } else { + // quietly disable the convert hash changes + ConvertHash = NewHashDebug("converthash", "qn", nil) + } + if Debug.Fmahash != "" { + FmaHash = NewHashDebug("fmahash", Debug.Fmahash, nil) + } + if Debug.PGOHash != "" { + PGOHash = NewHashDebug("pgohash", Debug.PGOHash, nil) + } + if Debug.LiteralAllocHash != "" { + LiteralAllocHash = NewHashDebug("literalalloc", Debug.LiteralAllocHash, nil) + } + + if Debug.MergeLocalsHash != "" { + MergeLocalsHash = NewHashDebug("mergelocals", Debug.MergeLocalsHash, nil) + } + if Debug.VariableMakeHash != "" { + VariableMakeHash = NewHashDebug("variablemake", Debug.VariableMakeHash, nil) + } + + if Flag.MSan && !platform.MSanSupported(buildcfg.GOOS, buildcfg.GOARCH) { + log.Fatalf("%s/%s does not support -msan", buildcfg.GOOS, buildcfg.GOARCH) + } + if Flag.ASan && !platform.ASanSupported(buildcfg.GOOS, buildcfg.GOARCH) { + log.Fatalf("%s/%s does not support -asan", buildcfg.GOOS, buildcfg.GOARCH) + } + if Flag.Race && !platform.RaceDetectorSupported(buildcfg.GOOS, buildcfg.GOARCH) { + log.Fatalf("%s/%s does not support -race", buildcfg.GOOS, buildcfg.GOARCH) + } + if (*Flag.Shared || *Flag.Dynlink || *Flag.LinkShared) && !Ctxt.Arch.InFamily(sys.AMD64, sys.ARM, sys.ARM64, sys.I386, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) { + log.Fatalf("%s/%s does not support -shared", buildcfg.GOOS, buildcfg.GOARCH) + } + parseSpectre(Flag.Spectre) // left as string for RecordFlags + + Ctxt.CompressInstructions = Debug.CompressInstructions != 0 + Ctxt.Flag_shared = Ctxt.Flag_dynlink || Ctxt.Flag_shared + Ctxt.Flag_optimize = Flag.N == 0 + Ctxt.Debugasm = int(Flag.S) + Ctxt.Flag_maymorestack = Debug.MayMoreStack + Ctxt.Flag_noRefName = Debug.NoRefName != 0 + + if flag.NArg() < 1 { + usage() + } + + if Flag.GoVersion != "" && Flag.GoVersion != runtime.Version() { + fmt.Printf("compile: version %q does not match go tool version %q\n", runtime.Version(), Flag.GoVersion) + Exit(2) + } + + if *Flag.LowerP == "" { + *Flag.LowerP = obj.UnlinkablePkg + } + + if Flag.LowerO == "" { + p := flag.Arg(0) + if i := strings.LastIndex(p, "/"); i >= 0 { + p = p[i+1:] + } + if runtime.GOOS == "windows" { + if i := strings.LastIndex(p, `\`); i >= 0 { + p = p[i+1:] + } + } + if i := strings.LastIndex(p, "."); i >= 0 { + p = p[:i] + } + suffix := ".o" + if Flag.Pack { + suffix = ".a" + } + Flag.LowerO = p + suffix + } + switch { + case Flag.Race && Flag.MSan: + log.Fatal("cannot use both -race and -msan") + case Flag.Race && Flag.ASan: + log.Fatal("cannot use both -race and -asan") + case Flag.MSan && Flag.ASan: + log.Fatal("cannot use both -msan and -asan") + } + if Flag.Race || Flag.MSan || Flag.ASan { + // -race, -msan and -asan imply -d=checkptr for now. + if Debug.Checkptr == -1 { // if not set explicitly + Debug.Checkptr = 1 + } + } + + if Flag.LowerC < 1 { + log.Fatalf("-c must be at least 1, got %d", Flag.LowerC) + } + if !concurrentBackendAllowed() { + Flag.LowerC = 1 + } + + if Flag.CompilingRuntime { + // It is not possible to build the runtime with no optimizations, + // because the compiler cannot eliminate enough write barriers. + Flag.N = 0 + Ctxt.Flag_optimize = true + + // Runtime can't use -d=checkptr, at least not yet. + Debug.Checkptr = 0 + + // Fuzzing the runtime isn't interesting either. + Debug.Libfuzzer = 0 + } + + if Debug.Checkptr == -1 { // if not set explicitly + Debug.Checkptr = 0 + } + + // set via a -d flag + Ctxt.Debugpcln = Debug.PCTab + + // https://golang.org/issue/67502 + if buildcfg.GOOS == "plan9" && buildcfg.GOARCH == "386" { + Debug.AlignHot = 0 + } +} + +// registerFlags adds flag registrations for all the fields in Flag. +// See the comment on type CmdFlags for the rules. +func registerFlags() { + var ( + boolType = reflect.TypeFor[bool]() + intType = reflect.TypeFor[int]() + stringType = reflect.TypeFor[string]() + ptrBoolType = reflect.TypeFor[*bool]() + ptrIntType = reflect.TypeFor[*int]() + ptrStringType = reflect.TypeFor[*string]() + countType = reflect.TypeFor[CountFlag]() + funcType = reflect.TypeFor[func(string)]() + ) + + v := reflect.ValueOf(&Flag).Elem() + t := v.Type() + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + if f.Name == "Cfg" { + continue + } + + var name string + if len(f.Name) == 1 { + name = f.Name + } else if len(f.Name) == 6 && f.Name[:5] == "Lower" && 'A' <= f.Name[5] && f.Name[5] <= 'Z' { + name = string(rune(f.Name[5] + 'a' - 'A')) + } else { + name = strings.ToLower(f.Name) + } + if tag := f.Tag.Get("flag"); tag != "" { + name = tag + } + + help := f.Tag.Get("help") + if help == "" { + panic(fmt.Sprintf("base.Flag.%s is missing help text", f.Name)) + } + + if k := f.Type.Kind(); (k == reflect.Ptr || k == reflect.Func) && v.Field(i).IsNil() { + panic(fmt.Sprintf("base.Flag.%s is uninitialized %v", f.Name, f.Type)) + } + + switch f.Type { + case boolType: + p := v.Field(i).Addr().Interface().(*bool) + flag.BoolVar(p, name, *p, help) + case intType: + p := v.Field(i).Addr().Interface().(*int) + flag.IntVar(p, name, *p, help) + case stringType: + p := v.Field(i).Addr().Interface().(*string) + flag.StringVar(p, name, *p, help) + case ptrBoolType: + p := v.Field(i).Interface().(*bool) + flag.BoolVar(p, name, *p, help) + case ptrIntType: + p := v.Field(i).Interface().(*int) + flag.IntVar(p, name, *p, help) + case ptrStringType: + p := v.Field(i).Interface().(*string) + flag.StringVar(p, name, *p, help) + case countType: + p := (*int)(v.Field(i).Addr().Interface().(*CountFlag)) + objabi.Flagcount(name, help, p) + case funcType: + f := v.Field(i).Interface().(func(string)) + objabi.Flagfn1(name, help, f) + default: + if val, ok := v.Field(i).Interface().(flag.Value); ok { + flag.Var(val, name, help) + } else { + panic(fmt.Sprintf("base.Flag.%s has unexpected type %s", f.Name, f.Type)) + } + } + } +} + +// concurrentFlagOk reports whether the current compiler flags +// are compatible with concurrent compilation. +func concurrentFlagOk() bool { + // TODO(rsc): Many of these are fine. Remove them. + return Flag.Percent == 0 && + Flag.E == 0 && + Flag.K == 0 && + Flag.L == 0 && + Flag.LowerH == 0 && + Flag.LowerJ == 0 && + Flag.LowerM == 0 && + Flag.LowerR == 0 +} + +func concurrentBackendAllowed() bool { + if !concurrentFlagOk() { + return false + } + + // Debug.S by itself is ok, because all printing occurs + // while writing the object file, and that is non-concurrent. + // Adding Debug_vlog, however, causes Debug.S to also print + // while flushing the plist, which happens concurrently. + if Ctxt.Debugvlog || !Debug.ConcurrentOk || Flag.Live > 0 { + return false + } + // TODO: Test and delete this condition. + if buildcfg.Experiment.FieldTrack { + return false + } + // TODO: fix races and enable the following flags + if Ctxt.Flag_dynlink || Flag.Race { + return false + } + return true +} + +func addImportDir(dir string) { + if dir != "" { + Flag.Cfg.ImportDirs = append(Flag.Cfg.ImportDirs, dir) + } +} + +func readImportCfg(file string) { + if Flag.Cfg.ImportMap == nil { + Flag.Cfg.ImportMap = make(map[string]string) + } + Flag.Cfg.PackageFile = map[string]string{} + data, err := os.ReadFile(file) + if err != nil { + log.Fatalf("-importcfg: %v", err) + } + + for lineNum, line := range strings.Split(string(data), "\n") { + lineNum++ // 1-based + line = strings.TrimSpace(line) + if line == "" || strings.HasPrefix(line, "#") { + continue + } + + verb, args, found := strings.Cut(line, " ") + if found { + args = strings.TrimSpace(args) + } + before, after, hasEq := strings.Cut(args, "=") + + switch verb { + default: + log.Fatalf("%s:%d: unknown directive %q", file, lineNum, verb) + case "importmap": + if !hasEq || before == "" || after == "" { + log.Fatalf(`%s:%d: invalid importmap: syntax is "importmap old=new"`, file, lineNum) + } + Flag.Cfg.ImportMap[before] = after + case "packagefile": + if !hasEq || before == "" || after == "" { + log.Fatalf(`%s:%d: invalid packagefile: syntax is "packagefile path=filename"`, file, lineNum) + } + Flag.Cfg.PackageFile[before] = after + } + } +} + +func readCoverageCfg(file string) { + var cfg covcmd.CoverFixupConfig + data, err := os.ReadFile(file) + if err != nil { + log.Fatalf("-coveragecfg: %v", err) + } + if err := json.Unmarshal(data, &cfg); err != nil { + log.Fatalf("error reading -coveragecfg file %q: %v", file, err) + } + Flag.Cfg.CoverageInfo = &cfg +} + +func readEmbedCfg(file string) { + data, err := os.ReadFile(file) + if err != nil { + log.Fatalf("-embedcfg: %v", err) + } + if err := json.Unmarshal(data, &Flag.Cfg.Embed); err != nil { + log.Fatalf("%s: %v", file, err) + } + if Flag.Cfg.Embed.Patterns == nil { + log.Fatalf("%s: invalid embedcfg: missing Patterns", file) + } + if Flag.Cfg.Embed.Files == nil { + log.Fatalf("%s: invalid embedcfg: missing Files", file) + } +} + +// parseSpectre parses the spectre configuration from the string s. +func parseSpectre(s string) { + for f := range strings.SplitSeq(s, ",") { + f = strings.TrimSpace(f) + switch f { + default: + log.Fatalf("unknown setting -spectre=%s", f) + case "": + // nothing + case "all": + Flag.Cfg.SpectreIndex = true + Ctxt.Retpoline = true + case "index": + Flag.Cfg.SpectreIndex = true + case "ret": + Ctxt.Retpoline = true + } + } + + if Flag.Cfg.SpectreIndex { + switch buildcfg.GOARCH { + case "amd64": + // ok + default: + log.Fatalf("GOARCH=%s does not support -spectre=index", buildcfg.GOARCH) + } + } +} diff --git a/go/src/cmd/compile/internal/base/hashdebug.go b/go/src/cmd/compile/internal/base/hashdebug.go new file mode 100644 index 0000000000000000000000000000000000000000..edf567457cb04bd39979288438770eae58a0ba75 --- /dev/null +++ b/go/src/cmd/compile/internal/base/hashdebug.go @@ -0,0 +1,421 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "bytes" + "cmd/internal/obj" + "cmd/internal/src" + "fmt" + "internal/bisect" + "io" + "os" + "path/filepath" + "strconv" + "strings" + "sync" +) + +type hashAndMask struct { + // a hash h matches if (h^hash)&mask == 0 + hash uint64 + mask uint64 + name string // base name, or base name + "0", "1", etc. +} + +type HashDebug struct { + mu sync.Mutex // for logfile, posTmp, bytesTmp + name string // base name of the flag/variable. + // what file (if any) receives the yes/no logging? + // default is os.Stdout + logfile io.Writer + posTmp []src.Pos + bytesTmp bytes.Buffer + matches []hashAndMask // A hash matches if one of these matches. + excludes []hashAndMask // explicitly excluded hash suffixes + bisect *bisect.Matcher + fileSuffixOnly bool // for Pos hashes, remove the directory prefix. + inlineSuffixOnly bool // for Pos hashes, remove all but the most inline position. +} + +// SetInlineSuffixOnly controls whether hashing and reporting use the entire +// inline position, or just the most-inline suffix. Compiler debugging tends +// to want the whole inlining, debugging user problems (loopvarhash, e.g.) +// typically does not need to see the entire inline tree, there is just one +// copy of the source code. +func (d *HashDebug) SetInlineSuffixOnly(b bool) *HashDebug { + d.inlineSuffixOnly = b + return d +} + +// The default compiler-debugging HashDebug, for "-d=gossahash=..." +var hashDebug *HashDebug + +var ConvertHash *HashDebug // for debugging float-to-[u]int conversion changes +var FmaHash *HashDebug // for debugging fused-multiply-add floating point changes +var LoopVarHash *HashDebug // for debugging shared/private loop variable changes +var PGOHash *HashDebug // for debugging PGO optimization decisions +var LiteralAllocHash *HashDebug // for debugging literal allocation optimizations +var MergeLocalsHash *HashDebug // for debugging local stack slot merging changes +var VariableMakeHash *HashDebug // for debugging variable-sized make optimizations + +// DebugHashMatchPkgFunc reports whether debug variable Gossahash +// +// 1. is empty (returns true; this is a special more-quickly implemented case of 4 below) +// +// 2. is "y" or "Y" (returns true) +// +// 3. is "n" or "N" (returns false) +// +// 4. does not explicitly exclude the sha1 hash of pkgAndName (see step 6) +// +// 5. is a suffix of the sha1 hash of pkgAndName (returns true) +// +// 6. OR +// if the (non-empty) value is in the regular language +// "(-[01]+/)+?([01]+(/[01]+)+?" +// (exclude..)(....include...) +// test the [01]+ exclude substrings, if any suffix-match, return false (4 above) +// test the [01]+ include substrings, if any suffix-match, return true +// The include substrings AFTER the first slash are numbered 0,1, etc and +// are named fmt.Sprintf("%s%d", varname, number) +// As an extra-special case for multiple failure search, +// an excludes-only string ending in a slash (terminated, not separated) +// implicitly specifies the include string "0/1", that is, match everything. +// (Exclude strings are used for automated search for multiple failures.) +// Clause 6 is not really intended for human use and only +// matters for failures that require multiple triggers. +// +// Otherwise it returns false. +// +// Unless Flags.Gossahash is empty, when DebugHashMatchPkgFunc returns true the message +// +// "%s triggered %s\n", varname, pkgAndName +// +// is printed on the file named in environment variable GSHS_LOGFILE, +// or standard out if that is empty. "Varname" is either the name of +// the variable or the name of the substring, depending on which matched. +// +// Typical use: +// +// 1. you make a change to the compiler, say, adding a new phase +// +// 2. it is broken in some mystifying way, for example, make.bash builds a broken +// compiler that almost works, but crashes compiling a test in run.bash. +// +// 3. add this guard to the code, which by default leaves it broken, but does not +// run the broken new code if Flags.Gossahash is non-empty and non-matching: +// +// if !base.DebugHashMatch(ir.PkgFuncName(fn)) { +// return nil // early exit, do nothing +// } +// +// 4. rebuild w/o the bad code, +// GOCOMPILEDEBUG=gossahash=n ./all.bash +// to verify that you put the guard in the right place with the right sense of the test. +// +// 5. use github.com/dr2chase/gossahash to search for the error: +// +// go install github.com/dr2chase/gossahash@latest +// +// gossahash -- +// +// for example: GOMAXPROCS=1 gossahash -- ./all.bash +// +// 6. gossahash should return a single function whose miscompilation +// causes the problem, and you can focus on that. +func DebugHashMatchPkgFunc(pkg, fn string) bool { + return hashDebug.MatchPkgFunc(pkg, fn, nil) +} + +func DebugHashMatchPos(pos src.XPos) bool { + return hashDebug.MatchPos(pos, nil) +} + +// HasDebugHash returns true if Flags.Gossahash is non-empty, which +// results in hashDebug being not-nil. I.e., if !HasDebugHash(), +// there is no need to create the string for hashing and testing. +func HasDebugHash() bool { + return hashDebug != nil +} + +// TODO: Delete when we switch to bisect-only. +func toHashAndMask(s, varname string) hashAndMask { + l := len(s) + if l > 64 { + s = s[l-64:] + l = 64 + } + m := ^(^uint64(0) << l) + h, err := strconv.ParseUint(s, 2, 64) + if err != nil { + Fatalf("Could not parse %s (=%s) as a binary number", varname, s) + } + + return hashAndMask{name: varname, hash: h, mask: m} +} + +// NewHashDebug returns a new hash-debug tester for the +// environment variable ev. If ev is not set, it returns +// nil, allowing a lightweight check for normal-case behavior. +func NewHashDebug(ev, s string, file io.Writer) *HashDebug { + if s == "" { + return nil + } + + hd := &HashDebug{name: ev, logfile: file} + if !strings.Contains(s, "/") { + m, err := bisect.New(s) + if err != nil { + Fatalf("%s: %v", ev, err) + } + hd.bisect = m + return hd + } + + // TODO: Delete remainder of function when we switch to bisect-only. + ss := strings.Split(s, "/") + // first remove any leading exclusions; these are preceded with "-" + i := 0 + for len(ss) > 0 { + s := ss[0] + if len(s) == 0 || len(s) > 0 && s[0] != '-' { + break + } + ss = ss[1:] + hd.excludes = append(hd.excludes, toHashAndMask(s[1:], fmt.Sprintf("%s%d", "HASH_EXCLUDE", i))) + i++ + } + // hash searches may use additional EVs with 0, 1, 2, ... suffixes. + i = 0 + for _, s := range ss { + if s == "" { + if i != 0 || len(ss) > 1 && ss[1] != "" || len(ss) > 2 { + Fatalf("Empty hash match string for %s should be first (and only) one", ev) + } + // Special case of should match everything. + hd.matches = append(hd.matches, toHashAndMask("0", fmt.Sprintf("%s0", ev))) + hd.matches = append(hd.matches, toHashAndMask("1", fmt.Sprintf("%s1", ev))) + break + } + if i == 0 { + hd.matches = append(hd.matches, toHashAndMask(s, ev)) + } else { + hd.matches = append(hd.matches, toHashAndMask(s, fmt.Sprintf("%s%d", ev, i-1))) + } + i++ + } + return hd +} + +// TODO: Delete when we switch to bisect-only. +func (d *HashDebug) excluded(hash uint64) bool { + for _, m := range d.excludes { + if (m.hash^hash)&m.mask == 0 { + return true + } + } + return false +} + +// TODO: Delete when we switch to bisect-only. +func hashString(hash uint64) string { + hstr := "" + if hash == 0 { + hstr = "0" + } else { + for ; hash != 0; hash = hash >> 1 { + hstr = string('0'+byte(hash&1)) + hstr + } + } + if len(hstr) > 24 { + hstr = hstr[len(hstr)-24:] + } + return hstr +} + +// TODO: Delete when we switch to bisect-only. +func (d *HashDebug) match(hash uint64) *hashAndMask { + for i, m := range d.matches { + if (m.hash^hash)&m.mask == 0 { + return &d.matches[i] + } + } + return nil +} + +// MatchPkgFunc returns true if either the variable used to create d is +// unset, or if its value is y, or if it is a suffix of the base-two +// representation of the hash of pkg and fn. If the variable is not nil, +// then a true result is accompanied by stylized output to d.logfile, which +// is used for automated bug search. +func (d *HashDebug) MatchPkgFunc(pkg, fn string, note func() string) bool { + if d == nil { + return true + } + // Written this way to make inlining likely. + return d.matchPkgFunc(pkg, fn, note) +} + +func (d *HashDebug) matchPkgFunc(pkg, fn string, note func() string) bool { + hash := bisect.Hash(pkg, fn) + return d.matchAndLog(hash, func() string { return pkg + "." + fn }, note) +} + +// MatchPos is similar to MatchPkgFunc, but for hash computation +// it uses the source position including all inlining information instead of +// package name and path. +// Note that the default answer for no environment variable (d == nil) +// is "yes", do the thing. +func (d *HashDebug) MatchPos(pos src.XPos, desc func() string) bool { + if d == nil { + return true + } + // Written this way to make inlining likely. + return d.matchPos(Ctxt, pos, desc) +} + +func (d *HashDebug) matchPos(ctxt *obj.Link, pos src.XPos, note func() string) bool { + return d.matchPosWithInfo(ctxt, pos, nil, note) +} + +func (d *HashDebug) matchPosWithInfo(ctxt *obj.Link, pos src.XPos, info any, note func() string) bool { + hash := d.hashPos(ctxt, pos) + if info != nil { + hash = bisect.Hash(hash, info) + } + return d.matchAndLog(hash, + func() string { + r := d.fmtPos(ctxt, pos) + if info != nil { + r += fmt.Sprintf(" (%v)", info) + } + return r + }, + note) +} + +// MatchPosWithInfo is similar to MatchPos, but with additional information +// that is included for hash computation, so it can distinguish multiple +// matches on the same source location. +// Note that the default answer for no environment variable (d == nil) +// is "yes", do the thing. +func (d *HashDebug) MatchPosWithInfo(pos src.XPos, info any, desc func() string) bool { + if d == nil { + return true + } + // Written this way to make inlining likely. + return d.matchPosWithInfo(Ctxt, pos, info, desc) +} + +// matchAndLog is the core matcher. It reports whether the hash matches the pattern. +// If a report needs to be printed, match prints that report to the log file. +// The text func must be non-nil and should return a user-readable +// representation of what was hashed. The note func may be nil; if non-nil, +// it should return additional information to display to the user when this +// change is selected. +func (d *HashDebug) matchAndLog(hash uint64, text, note func() string) bool { + if d.bisect != nil { + enabled := d.bisect.ShouldEnable(hash) + if d.bisect.ShouldPrint(hash) { + disabled := "" + if !enabled { + disabled = " [DISABLED]" + } + var t string + if !d.bisect.MarkerOnly() { + t = text() + if note != nil { + if n := note(); n != "" { + t += ": " + n + disabled + disabled = "" + } + } + } + d.log(d.name, hash, strings.TrimSpace(t+disabled)) + } + return enabled + } + + // TODO: Delete rest of function body when we switch to bisect-only. + if d.excluded(hash) { + return false + } + if m := d.match(hash); m != nil { + d.log(m.name, hash, text()) + return true + } + return false +} + +// short returns the form of file name to use for d. +// The default is the full path, but fileSuffixOnly selects +// just the final path element. +func (d *HashDebug) short(name string) string { + if d.fileSuffixOnly { + return filepath.Base(name) + } + return name +} + +// hashPos returns a hash of the position pos, including its entire inline stack. +// If d.inlineSuffixOnly is true, hashPos only considers the innermost (leaf) position on the inline stack. +func (d *HashDebug) hashPos(ctxt *obj.Link, pos src.XPos) uint64 { + if d.inlineSuffixOnly { + p := ctxt.InnermostPos(pos) + return bisect.Hash(d.short(p.Filename()), p.Line(), p.Col()) + } + h := bisect.Hash() + ctxt.AllPos(pos, func(p src.Pos) { + h = bisect.Hash(h, d.short(p.Filename()), p.Line(), p.Col()) + }) + return h +} + +// fmtPos returns a textual formatting of the position pos, including its entire inline stack. +// If d.inlineSuffixOnly is true, fmtPos only considers the innermost (leaf) position on the inline stack. +func (d *HashDebug) fmtPos(ctxt *obj.Link, pos src.XPos) string { + format := func(p src.Pos) string { + return fmt.Sprintf("%s:%d:%d", d.short(p.Filename()), p.Line(), p.Col()) + } + if d.inlineSuffixOnly { + return format(ctxt.InnermostPos(pos)) + } + var stk []string + ctxt.AllPos(pos, func(p src.Pos) { + stk = append(stk, format(p)) + }) + return strings.Join(stk, "; ") +} + +// log prints a match with the given hash and textual formatting. +// TODO: Delete varname parameter when we switch to bisect-only. +func (d *HashDebug) log(varname string, hash uint64, text string) { + d.mu.Lock() + defer d.mu.Unlock() + + file := d.logfile + if file == nil { + if tmpfile := os.Getenv("GSHS_LOGFILE"); tmpfile != "" { + var err error + file, err = os.OpenFile(tmpfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) + if err != nil { + Fatalf("could not open hash-testing logfile %s", tmpfile) + return + } + } + if file == nil { + file = os.Stdout + } + d.logfile = file + } + + // Bisect output. + fmt.Fprintf(file, "%s %s\n", text, bisect.Marker(hash)) + + // Gossahash output. + // TODO: Delete rest of function when we switch to bisect-only. + fmt.Fprintf(file, "%s triggered %s %s\n", varname, text, hashString(hash)) +} diff --git a/go/src/cmd/compile/internal/base/hashdebug_test.go b/go/src/cmd/compile/internal/base/hashdebug_test.go new file mode 100644 index 0000000000000000000000000000000000000000..62ef2ed4939d64bd4f8de5fc307b477a173a2bab --- /dev/null +++ b/go/src/cmd/compile/internal/base/hashdebug_test.go @@ -0,0 +1,140 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "bytes" + "internal/bisect" + "strings" + "testing" +) + +func TestHashDebugGossahashY(t *testing.T) { + hd := NewHashDebug("GOSSAHASH", "y", new(bytes.Buffer)) + if hd == nil { + t.Errorf("NewHashDebug should not return nil for GOSSASHASH=y") + } + if !hd.MatchPkgFunc("anything", "anyfunc", nil) { + t.Errorf("NewHashDebug should return yes for everything for GOSSASHASH=y") + } +} + +func TestHashDebugGossahashN(t *testing.T) { + hd := NewHashDebug("GOSSAHASH", "n", new(bytes.Buffer)) + if hd == nil { + t.Errorf("NewHashDebug should not return nil for GOSSASHASH=n") + } + if hd.MatchPkgFunc("anything", "anyfunc", nil) { + t.Errorf("NewHashDebug should return no for everything for GOSSASHASH=n") + } +} + +func TestHashDebugGossahashEmpty(t *testing.T) { + hd := NewHashDebug("GOSSAHASH", "", nil) + if hd != nil { + t.Errorf("NewHashDebug should return nil for GOSSASHASH=\"\"") + } +} + +func TestHashDebugMagic(t *testing.T) { + hd := NewHashDebug("FOOXYZZY", "y", nil) + hd0 := NewHashDebug("FOOXYZZY0", "n", nil) + if hd == nil { + t.Errorf("NewHashDebug should have succeeded for FOOXYZZY") + } + if hd0 == nil { + t.Errorf("NewHashDebug should have succeeded for FOOXYZZY0") + } +} + +func TestHash(t *testing.T) { + h0 := bisect.Hash("bar", "0") + h1 := bisect.Hash("bar", "1") + t.Logf(`These values are used in other tests: Hash("bar", "0")=%#64b, Hash("bar", "1")=%#64b`, h0, h1) + if h0 == h1 { + t.Errorf("Hashes 0x%x and 0x%x should differ", h0, h1) + } +} + +func TestHashMatch(t *testing.T) { + b := new(bytes.Buffer) + hd := NewHashDebug("GOSSAHASH", "v1110", b) + check := hd.MatchPkgFunc("bar", "0", func() string { return "note" }) + msg := b.String() + t.Logf("message was '%s'", msg) + if !check { + t.Errorf("GOSSAHASH=1110 should have matched for 'bar', '0'") + } + wantPrefix(t, msg, "bar.0: note [bisect-match ") + wantContains(t, msg, "\nGOSSAHASH triggered bar.0: note ") +} + +func TestYMatch(t *testing.T) { + b := new(bytes.Buffer) + hd := NewHashDebug("GOSSAHASH", "vy", b) + check := hd.MatchPkgFunc("bar", "0", nil) + msg := b.String() + t.Logf("message was '%s'", msg) + if !check { + t.Errorf("GOSSAHASH=y should have matched for 'bar', '0'") + } + wantPrefix(t, msg, "bar.0 [bisect-match ") + wantContains(t, msg, "\nGOSSAHASH triggered bar.0 010100100011100101011110") +} + +func TestNMatch(t *testing.T) { + b := new(bytes.Buffer) + hd := NewHashDebug("GOSSAHASH", "vn", b) + check := hd.MatchPkgFunc("bar", "0", nil) + msg := b.String() + t.Logf("message was '%s'", msg) + if check { + t.Errorf("GOSSAHASH=n should NOT have matched for 'bar', '0'") + } + wantPrefix(t, msg, "bar.0 [DISABLED] [bisect-match ") + wantContains(t, msg, "\nGOSSAHASH triggered bar.0 [DISABLED] 010100100011100101011110") +} + +func TestHashNoMatch(t *testing.T) { + b := new(bytes.Buffer) + hd := NewHashDebug("GOSSAHASH", "01110", b) + check := hd.MatchPkgFunc("bar", "0", nil) + msg := b.String() + t.Logf("message was '%s'", msg) + if check { + t.Errorf("GOSSAHASH=001100 should NOT have matched for 'bar', '0'") + } + if msg != "" { + t.Errorf("Message should have been empty, instead %s", msg) + } + +} + +func TestHashSecondMatch(t *testing.T) { + b := new(bytes.Buffer) + hd := NewHashDebug("GOSSAHASH", "01110/11110", b) + + check := hd.MatchPkgFunc("bar", "0", nil) + msg := b.String() + t.Logf("message was '%s'", msg) + if !check { + t.Errorf("GOSSAHASH=001100, GOSSAHASH0=0011 should have matched for 'bar', '0'") + } + wantContains(t, msg, "\nGOSSAHASH0 triggered bar") +} + +func wantPrefix(t *testing.T, got, want string) { + t.Helper() + if !strings.HasPrefix(got, want) { + t.Errorf("want prefix %q, got:\n%s", want, got) + } +} + +func wantContains(t *testing.T, got, want string) { + t.Helper() + if !strings.Contains(got, want) { + t.Errorf("want contains %q, got:\n%s", want, got) + } +} diff --git a/go/src/cmd/compile/internal/base/link.go b/go/src/cmd/compile/internal/base/link.go new file mode 100644 index 0000000000000000000000000000000000000000..d8aa5a7dccd209c4e17f758442a1427e1dd3d8b6 --- /dev/null +++ b/go/src/cmd/compile/internal/base/link.go @@ -0,0 +1,53 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "cmd/internal/obj" +) + +// ReservedImports are import paths used internally for generated +// symbols by the compiler. +// +// The linker uses the magic symbol prefixes "go:" and "type:". +// Avoid potential confusion between import paths and symbols +// by rejecting these reserved imports for now. Also, people +// "can do weird things in GOPATH and we'd prefer they didn't +// do _that_ weird thing" (per rsc). See also #4257. +var ReservedImports = map[string]bool{ + "go": true, + "type": true, +} + +var Ctxt *obj.Link + +// TODO(mdempsky): These should probably be obj.Link methods. + +// PkgLinksym returns the linker symbol for name within the given +// package prefix. For user packages, prefix should be the package +// path encoded with objabi.PathToPrefix. +func PkgLinksym(prefix, name string, abi obj.ABI) *obj.LSym { + if name == "_" { + // TODO(mdempsky): Cleanup callers and Fatalf instead. + return linksym(prefix, "_", abi) + } + sep := "." + if ReservedImports[prefix] { + sep = ":" + } + return linksym(prefix, prefix+sep+name, abi) +} + +// Linkname returns the linker symbol for the given name as it might +// appear within a //go:linkname directive. +func Linkname(name string, abi obj.ABI) *obj.LSym { + return linksym("_", name, abi) +} + +// linksym is an internal helper function for implementing the above +// exported APIs. +func linksym(pkg, name string, abi obj.ABI) *obj.LSym { + return Ctxt.LookupABIInit(name, abi, func(r *obj.LSym) { r.Pkg = pkg }) +} diff --git a/go/src/cmd/compile/internal/base/mapfile_mmap.go b/go/src/cmd/compile/internal/base/mapfile_mmap.go new file mode 100644 index 0000000000000000000000000000000000000000..aeead9d4ec2a27466934c9de2693640195b0227d --- /dev/null +++ b/go/src/cmd/compile/internal/base/mapfile_mmap.go @@ -0,0 +1,45 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix + +package base + +import ( + "internal/unsafeheader" + "os" + "runtime" + "syscall" + "unsafe" +) + +// TODO(mdempsky): Is there a higher-level abstraction that still +// works well for iimport? + +// MapFile returns length bytes from the file starting at the +// specified offset as a string. +func MapFile(f *os.File, offset, length int64) (string, error) { + // POSIX mmap: "The implementation may require that off is a + // multiple of the page size." + x := offset & int64(os.Getpagesize()-1) + offset -= x + length += x + + buf, err := syscall.Mmap(int(f.Fd()), offset, int(length), syscall.PROT_READ, syscall.MAP_SHARED) + runtime.KeepAlive(f) + if err != nil { + return "", err + } + + buf = buf[x:] + pSlice := (*unsafeheader.Slice)(unsafe.Pointer(&buf)) + + var res string + pString := (*unsafeheader.String)(unsafe.Pointer(&res)) + + pString.Data = pSlice.Data + pString.Len = pSlice.Len + + return res, nil +} diff --git a/go/src/cmd/compile/internal/base/mapfile_read.go b/go/src/cmd/compile/internal/base/mapfile_read.go new file mode 100644 index 0000000000000000000000000000000000000000..6ad2f84fb20c0ae8127282e296ae59dbed447115 --- /dev/null +++ b/go/src/cmd/compile/internal/base/mapfile_read.go @@ -0,0 +1,21 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !unix + +package base + +import ( + "io" + "os" +) + +func MapFile(f *os.File, offset, length int64) (string, error) { + buf := make([]byte, length) + _, err := io.ReadFull(io.NewSectionReader(f, offset, length), buf) + if err != nil { + return "", err + } + return string(buf), nil +} diff --git a/go/src/cmd/compile/internal/base/print.go b/go/src/cmd/compile/internal/base/print.go new file mode 100644 index 0000000000000000000000000000000000000000..6bfc84cd62df648072689012a8a3fbd9d1683973 --- /dev/null +++ b/go/src/cmd/compile/internal/base/print.go @@ -0,0 +1,288 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "fmt" + "internal/buildcfg" + "internal/types/errors" + "os" + "runtime/debug" + "sort" + "strings" + + "cmd/internal/src" + "cmd/internal/telemetry/counter" +) + +// An errorMsg is a queued error message, waiting to be printed. +type errorMsg struct { + pos src.XPos + msg string + code errors.Code +} + +// Pos is the current source position being processed, +// printed by Errorf, ErrorfLang, Fatalf, and Warnf. +var Pos src.XPos + +var ( + errorMsgs []errorMsg + numErrors int // number of entries in errorMsgs that are errors (as opposed to warnings) + numSyntaxErrors int +) + +// Errors returns the number of errors reported. +func Errors() int { + return numErrors +} + +// SyntaxErrors returns the number of syntax errors reported. +func SyntaxErrors() int { + return numSyntaxErrors +} + +// addErrorMsg adds a new errorMsg (which may be a warning) to errorMsgs. +func addErrorMsg(pos src.XPos, code errors.Code, format string, args ...any) { + msg := fmt.Sprintf(format, args...) + // Only add the position if know the position. + // See issue golang.org/issue/11361. + if pos.IsKnown() { + msg = fmt.Sprintf("%v: %s", FmtPos(pos), msg) + } + errorMsgs = append(errorMsgs, errorMsg{ + pos: pos, + msg: msg + "\n", + code: code, + }) +} + +// FmtPos formats pos as a file:line string. +func FmtPos(pos src.XPos) string { + if Ctxt == nil { + return "???" + } + return Ctxt.OutermostPos(pos).Format(Flag.C == 0, Flag.L == 1) +} + +// byPos sorts errors by source position. +type byPos []errorMsg + +func (x byPos) Len() int { return len(x) } +func (x byPos) Less(i, j int) bool { return x[i].pos.Before(x[j].pos) } +func (x byPos) Swap(i, j int) { x[i], x[j] = x[j], x[i] } + +// FlushErrors sorts errors seen so far by line number, prints them to stdout, +// and empties the errors array. +func FlushErrors() { + if Ctxt != nil && Ctxt.Bso != nil { + Ctxt.Bso.Flush() + } + if len(errorMsgs) == 0 { + return + } + sort.Stable(byPos(errorMsgs)) + for i, err := range errorMsgs { + if i == 0 || err.msg != errorMsgs[i-1].msg { + fmt.Print(err.msg) + } + } + errorMsgs = errorMsgs[:0] +} + +// lasterror keeps track of the most recently issued error, +// to avoid printing multiple error messages on the same line. +var lasterror struct { + syntax src.XPos // source position of last syntax error + other src.XPos // source position of last non-syntax error + msg string // error message of last non-syntax error +} + +// sameline reports whether two positions a, b are on the same line. +func sameline(a, b src.XPos) bool { + p := Ctxt.PosTable.Pos(a) + q := Ctxt.PosTable.Pos(b) + return p.Base() == q.Base() && p.Line() == q.Line() +} + +// Errorf reports a formatted error at the current line. +func Errorf(format string, args ...any) { + ErrorfAt(Pos, 0, format, args...) +} + +// ErrorfAt reports a formatted error message at pos. +func ErrorfAt(pos src.XPos, code errors.Code, format string, args ...any) { + msg := fmt.Sprintf(format, args...) + + if strings.HasPrefix(msg, "syntax error") { + numSyntaxErrors++ + // only one syntax error per line, no matter what error + if sameline(lasterror.syntax, pos) { + return + } + lasterror.syntax = pos + } else { + // only one of multiple equal non-syntax errors per line + // (FlushErrors shows only one of them, so we filter them + // here as best as we can (they may not appear in order) + // so that we don't count them here and exit early, and + // then have nothing to show for.) + if sameline(lasterror.other, pos) && lasterror.msg == msg { + return + } + lasterror.other = pos + lasterror.msg = msg + } + + addErrorMsg(pos, code, "%s", msg) + numErrors++ + + hcrash() + if numErrors >= 10 && Flag.LowerE == 0 { + FlushErrors() + fmt.Printf("%v: too many errors\n", FmtPos(pos)) + ErrorExit() + } +} + +// UpdateErrorDot is a clumsy hack that rewrites the last error, +// if it was "LINE: undefined: NAME", to be "LINE: undefined: NAME in EXPR". +// It is used to give better error messages for dot (selector) expressions. +func UpdateErrorDot(line string, name, expr string) { + if len(errorMsgs) == 0 { + return + } + e := &errorMsgs[len(errorMsgs)-1] + if strings.HasPrefix(e.msg, line) && e.msg == fmt.Sprintf("%v: undefined: %v\n", line, name) { + e.msg = fmt.Sprintf("%v: undefined: %v in %v\n", line, name, expr) + } +} + +// Warn reports a formatted warning at the current line. +// In general the Go compiler does NOT generate warnings, +// so this should be used only when the user has opted in +// to additional output by setting a particular flag. +func Warn(format string, args ...any) { + WarnfAt(Pos, format, args...) +} + +// WarnfAt reports a formatted warning at pos. +// In general the Go compiler does NOT generate warnings, +// so this should be used only when the user has opted in +// to additional output by setting a particular flag. +func WarnfAt(pos src.XPos, format string, args ...any) { + addErrorMsg(pos, 0, format, args...) + if Flag.LowerM != 0 { + FlushErrors() + } +} + +// Fatalf reports a fatal error - an internal problem - at the current line and exits. +// If other errors have already been printed, then Fatalf just quietly exits. +// (The internal problem may have been caused by incomplete information +// after the already-reported errors, so best to let users fix those and +// try again without being bothered about a spurious internal error.) +// +// But if no errors have been printed, or if -d panic has been specified, +// Fatalf prints the error as an "internal compiler error". In a released build, +// it prints an error asking to file a bug report. In development builds, it +// prints a stack trace. +// +// If -h has been specified, Fatalf panics to force the usual runtime info dump. +func Fatalf(format string, args ...any) { + FatalfAt(Pos, format, args...) +} + +var bugStack = counter.NewStack("compile/bug", 16) // 16 is arbitrary; used by gopls and crashmonitor + +// FatalfAt reports a fatal error - an internal problem - at pos and exits. +// If other errors have already been printed, then FatalfAt just quietly exits. +// (The internal problem may have been caused by incomplete information +// after the already-reported errors, so best to let users fix those and +// try again without being bothered about a spurious internal error.) +// +// But if no errors have been printed, or if -d panic has been specified, +// FatalfAt prints the error as an "internal compiler error". In a released build, +// it prints an error asking to file a bug report. In development builds, it +// prints a stack trace. +// +// If -h has been specified, FatalfAt panics to force the usual runtime info dump. +func FatalfAt(pos src.XPos, format string, args ...any) { + FlushErrors() + + bugStack.Inc() + + if Debug.Panic != 0 || numErrors == 0 { + fmt.Printf("%v: internal compiler error: ", FmtPos(pos)) + fmt.Printf(format, args...) + fmt.Printf("\n") + + // If this is a released compiler version, ask for a bug report. + if Debug.Panic == 0 && strings.HasPrefix(buildcfg.Version, "go") && !strings.Contains(buildcfg.Version, "devel") { + fmt.Printf("\n") + fmt.Printf("Please file a bug report including a short program that triggers the error.\n") + fmt.Printf("https://go.dev/issue/new\n") + } else { + // Not a release; dump a stack trace, too. + fmt.Println() + os.Stdout.Write(debug.Stack()) + fmt.Println() + } + } + + hcrash() + ErrorExit() +} + +// Assert reports "assertion failed" with Fatalf, unless b is true. +func Assert(b bool) { + if !b { + Fatalf("assertion failed") + } +} + +// Assertf reports a fatal error with Fatalf, unless b is true. +func Assertf(b bool, format string, args ...any) { + if !b { + Fatalf(format, args...) + } +} + +// AssertfAt reports a fatal error with FatalfAt, unless b is true. +func AssertfAt(b bool, pos src.XPos, format string, args ...any) { + if !b { + FatalfAt(pos, format, args...) + } +} + +// hcrash crashes the compiler when -h is set, to find out where a message is generated. +func hcrash() { + if Flag.LowerH != 0 { + FlushErrors() + if Flag.LowerO != "" { + os.Remove(Flag.LowerO) + } + panic("-h") + } +} + +// ErrorExit handles an error-status exit. +// It flushes any pending errors, removes the output file, and exits. +func ErrorExit() { + FlushErrors() + if Flag.LowerO != "" { + os.Remove(Flag.LowerO) + } + os.Exit(2) +} + +// ExitIfErrors calls ErrorExit if any errors have been reported. +func ExitIfErrors() { + if Errors() > 0 { + ErrorExit() + } +} + +var AutogeneratedPos src.XPos diff --git a/go/src/cmd/compile/internal/base/startheap.go b/go/src/cmd/compile/internal/base/startheap.go new file mode 100644 index 0000000000000000000000000000000000000000..1d2713efdbc3f9e6d847d57e0853ff4c123639ac --- /dev/null +++ b/go/src/cmd/compile/internal/base/startheap.go @@ -0,0 +1,272 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "fmt" + "os" + "runtime" + "runtime/debug" + "runtime/metrics" + "sync" +) + +// forEachGC calls fn each GC cycle until it returns false. +func forEachGC(fn func() bool) { + type T [32]byte // large enough to avoid runtime's tiny object allocator + var finalizer func(*T) + finalizer = func(p *T) { + + if fn() { + runtime.SetFinalizer(p, finalizer) + } + } + + finalizer(new(T)) +} + +// AdjustStartingHeap modifies GOGC so that GC should not occur until the heap +// grows to the requested size. This is intended but not promised, though it +// is true-mostly, depending on when the adjustment occurs and on the +// compiler's input and behavior. Once the live heap is approximately half +// this size, GOGC is reset to its value when AdjustStartingHeap was called; +// subsequent GCs may reduce the heap below the requested size, but this +// function does not affect that. +// +// logHeapTweaks (-d=gcadjust=1) enables logging of GOGC adjustment events. +// +// The temporarily requested GOGC is derated from what would be the "obvious" +// value necessary to hit the starting heap goal because the obvious +// (goal/live-1)*100 value seems to grow RSS a little more than it "should" +// (compared to GOMEMLIMIT, e.g.) and the assumption is that the GC's control +// algorithms are tuned for GOGC near 100, and not tuned for huge values of +// GOGC. Different derating factors apply for "lo" and "hi" values of GOGC; +// lo is below derateBreak, hi is above derateBreak. The derating factors, +// expressed as integer percentages, are derateLoPct and derateHiPct. +// 60-75 is an okay value for derateLoPct, 30-65 seems like a good value for +// derateHiPct, and 600 seems like a good value for derateBreak. If these +// are zero, defaults are used instead. +// +// NOTE: If you think this code would help startup time in your own +// application and you decide to use it, please benchmark first to see if it +// actually works for you (it may not: the Go compiler is not typical), and +// whatever the outcome, please leave a comment on bug #56546. This code +// uses supported interfaces, but depends more than we like on +// current+observed behavior of the garbage collector, so if many people need +// this feature, we should consider/propose a better way to accomplish it. +func AdjustStartingHeap(requestedHeapGoal, derateBreak, derateLoPct, derateHiPct uint64, logHeapTweaks bool) { + mp := runtime.GOMAXPROCS(0) + + const ( + SHgoal = "/gc/heap/goal:bytes" + SHcount = "/gc/cycles/total:gc-cycles" + SHallocs = "/gc/heap/allocs:bytes" + SHfrees = "/gc/heap/frees:bytes" + ) + + var sample = []metrics.Sample{{Name: SHgoal}, {Name: SHcount}, {Name: SHallocs}, {Name: SHfrees}} + + const ( + SH_GOAL = 0 + SH_COUNT = 1 + SH_ALLOCS = 2 + SH_FREES = 3 + + MB = 1_000_000 + ) + + // These particular magic numbers are designed to make the RSS footprint of -d=-gcstart=2000 + // resemble that of GOMEMLIMIT=2000MiB GOGC=10000 when building large projects + // (e.g. the Go compiler itself, and the microsoft's typescript AST package), + // with the further restriction that these magic numbers did a good job of reducing user-cpu + // for builds at either gcstart=2000 or gcstart=128. + // + // The benchmarking to obtain this was (a version of): + // + // for i in {1..50} ; do + // for what in std cmd/compile cmd/fix cmd/go github.com/microsoft/typescript-go/internal/ast ; do + // whatbase=`basename ${what}` + // for sh in 128 2000 ; do + // for br in 500 600 ; do + // for shlo in 65 70; do + // for shhi in 55 60 ; do + // benchcmd -n=2 ${whatbase} go build -a \ + // -gcflags=all=-d=gcstart=${sh},gcstartloderate=${shlo},gcstarthiderate=${shhi},gcstartbreak=${br} \ + // ${what} | tee -a startheap${sh}_${br}_${shhi}_${shlo}.bench + // done + // done + // done + // done + // done + // done + // + // benchcmd is "go install github.com/aclements/go-misc/benchcmd@latest" + + if derateBreak == 0 { + derateBreak = 600 + } + if derateLoPct == 0 { + derateLoPct = 70 + } + if derateHiPct == 0 { + derateHiPct = 55 + } + + gogcDerate := func(myGogc uint64) uint64 { + if myGogc < derateBreak { + return (myGogc * derateLoPct) / 100 + } + return (myGogc * derateHiPct) / 100 + } + + // Assumptions and observations of Go's garbage collector, as of Go 1.17-1.20: + + // - the initial heap goal is 4MiB, by fiat. It is possible for Go to start + // with a heap as small as 512k, so this may change in the future. + + // - except for the first heap goal, heap goal is a function of + // observed-live at the previous GC and current GOGC. After the first + // GC, adjusting GOGC immediately updates GOGC; before the first GC, + // adjusting GOGC does not modify goal (but the change takes effect after + // the first GC). + + // - the before/after first GC behavior is not guaranteed anywhere, it's + // just behavior, and it's a bad idea to rely on it. + + // - we don't know exactly when GC will run, even after we adjust GOGC; the + // first GC may not have happened yet, may have already happened, or may + // be currently in progress, and GCs can start for several reasons. + + // - forEachGC above will run the provided function at some delay after each + // GC's mark phase terminates; finalizers are run after marking as the + // spans containing finalizable objects are swept, driven by GC + // background activity and allocation demand. + + // - "live at last GC" is not available through the current metrics + // interface. Instead, live is estimated by knowing the adjusted value of + // GOGC and the new heap goal following a GC (this requires knowing that + // at least one GC has occurred): + // estLive = 100 * newGoal / (100 + currentGogc) + // this new value of GOGC + // newGogc = 100*requestedHeapGoal/estLive - 100 + // will result in the desired goal. The logging code checks that the + // resulting goal is correct. + + // There's a small risk that the finalizer will be slow to run after a GC + // that expands the goal to a huge value, and that this will lead to + // out-of-memory. This doesn't seem to happen; in experiments on a variety + // of machines with a variety of extra loads to disrupt scheduling, the + // worst overshoot observed was 50% past requestedHeapGoal. + + metrics.Read(sample) + for _, s := range sample { + if s.Value.Kind() == metrics.KindBad { + // Just return, a slightly slower compilation is a tolerable outcome. + if logHeapTweaks { + fmt.Fprintf(os.Stderr, "GCAdjust: Regret unexpected KindBad for metric %s\n", s.Name) + } + return + } + } + + // Tinker with GOGC to make the heap grow rapidly at first. + currentGoal := sample[SH_GOAL].Value.Uint64() // Believe this will be 4MByte or less, perhaps 512k + myGogc := 100 * requestedHeapGoal / currentGoal + myGogc = gogcDerate(myGogc) + if myGogc <= 125 { + return + } + + if logHeapTweaks { + sample := append([]metrics.Sample(nil), sample...) // avoid races with GC callback + AtExit(func() { + metrics.Read(sample) + goal := sample[SH_GOAL].Value.Uint64() + count := sample[SH_COUNT].Value.Uint64() + oldGogc := debug.SetGCPercent(100) + if oldGogc == 100 { + fmt.Fprintf(os.Stderr, "GCAdjust: AtExit goal %dMB gogc %d count %d maxprocs %d\n", + goal/MB, oldGogc, count, mp) + } else { + inUse := sample[SH_ALLOCS].Value.Uint64() - sample[SH_FREES].Value.Uint64() + overPct := 100 * (int(inUse) - int(requestedHeapGoal)) / int(requestedHeapGoal) + fmt.Fprintf(os.Stderr, "GCAdjust: AtExit goal %dMB gogc %d count %d maxprocs %d overPct %d\n", + goal/MB, oldGogc, count, mp, overPct) + + } + }) + } + + originalGOGC := debug.SetGCPercent(int(myGogc)) + + // forEachGC finalizers ought not overlap, but they could run in separate threads. + // This ought not matter, but just in case it bothers the/a race detector, + // use this mutex. + var forEachGCLock sync.Mutex + + adjustFunc := func() bool { + + forEachGCLock.Lock() + defer forEachGCLock.Unlock() + + metrics.Read(sample) + goal := sample[SH_GOAL].Value.Uint64() + count := sample[SH_COUNT].Value.Uint64() + + if goal <= requestedHeapGoal { // Stay the course + if logHeapTweaks { + fmt.Fprintf(os.Stderr, "GCAdjust: Reuse GOGC adjust, current goal %dMB, count is %d, current gogc %d\n", + goal/MB, count, myGogc) + } + return true + } + + // Believe goal has been adjusted upwards, else it would be less-than-or-equal to requestedHeapGoal + calcLive := 100 * goal / (100 + myGogc) + + if 2*calcLive < requestedHeapGoal { // calcLive can exceed requestedHeapGoal! + myGogc = 100*requestedHeapGoal/calcLive - 100 + myGogc = gogcDerate(myGogc) + + if myGogc > 125 { + // Not done growing the heap. + oldGogc := debug.SetGCPercent(int(myGogc)) + + if logHeapTweaks { + // Check that the new goal looks right + inUse := sample[SH_ALLOCS].Value.Uint64() - sample[SH_FREES].Value.Uint64() + metrics.Read(sample) + newGoal := sample[SH_GOAL].Value.Uint64() + pctOff := 100 * (int64(newGoal) - int64(requestedHeapGoal)) / int64(requestedHeapGoal) + // Check that the new goal is close to requested. 3% of make.bash fails this test. Why, TBD. + if pctOff < 2 { + fmt.Fprintf(os.Stderr, "GCAdjust: Retry GOGC adjust, current goal %dMB, count is %d, gogc was %d, is now %d, calcLive %dMB pctOff %d\n", + goal/MB, count, oldGogc, myGogc, calcLive/MB, pctOff) + } else { + // The GC is being annoying and not giving us the goal that we requested, say more to help understand when/why. + fmt.Fprintf(os.Stderr, "GCAdjust: Retry GOGC adjust, current goal %dMB, count is %d, gogc was %d, is now %d, calcLive %dMB pctOff %d inUse %dMB\n", + goal/MB, count, oldGogc, myGogc, calcLive/MB, pctOff, inUse/MB) + } + } + return true + } + } + + // In this case we're done boosting GOGC, set it to its original value and don't set a new finalizer. + oldGogc := debug.SetGCPercent(originalGOGC) + // inUse helps estimate how late the finalizer ran; at the instant the previous GC ended, + // it was (in theory) equal to the previous GC's heap goal. In a growing heap it is + // expected to grow to the new heap goal. + if logHeapTweaks { + inUse := sample[SH_ALLOCS].Value.Uint64() - sample[SH_FREES].Value.Uint64() + overPct := 100 * (int(inUse) - int(requestedHeapGoal)) / int(requestedHeapGoal) + fmt.Fprintf(os.Stderr, "GCAdjust: Reset GOGC adjust, old goal %dMB, count is %d, gogc was %d, gogc is now %d, calcLive %dMB inUse %dMB overPct %d\n", + goal/MB, count, oldGogc, originalGOGC, calcLive/MB, inUse/MB, overPct) + } + return false + } + + forEachGC(adjustFunc) +} diff --git a/go/src/cmd/compile/internal/base/timings.go b/go/src/cmd/compile/internal/base/timings.go new file mode 100644 index 0000000000000000000000000000000000000000..cbcd4dc6f55b55279597ccdd6ebeaacb14dfec46 --- /dev/null +++ b/go/src/cmd/compile/internal/base/timings.go @@ -0,0 +1,237 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "fmt" + "io" + "strings" + "time" +) + +var Timer Timings + +// Timings collects the execution times of labeled phases +// which are added through a sequence of Start/Stop calls. +// Events may be associated with each phase via AddEvent. +type Timings struct { + list []timestamp + events map[int][]*event // lazily allocated +} + +type timestamp struct { + time time.Time + label string + start bool +} + +type event struct { + size int64 // count or amount of data processed (allocations, data size, lines, funcs, ...) + unit string // unit of size measure (count, MB, lines, funcs, ...) +} + +func (t *Timings) append(labels []string, start bool) { + t.list = append(t.list, timestamp{time.Now(), strings.Join(labels, ":"), start}) +} + +// Start marks the beginning of a new phase and implicitly stops the previous phase. +// The phase name is the colon-separated concatenation of the labels. +func (t *Timings) Start(labels ...string) { + t.append(labels, true) +} + +// Stop marks the end of a phase and implicitly starts a new phase. +// The labels are added to the labels of the ended phase. +func (t *Timings) Stop(labels ...string) { + t.append(labels, false) +} + +// AddEvent associates an event, i.e., a count, or an amount of data, +// with the most recently started or stopped phase; or the very first +// phase if Start or Stop hasn't been called yet. The unit specifies +// the unit of measurement (e.g., MB, lines, no. of funcs, etc.). +func (t *Timings) AddEvent(size int64, unit string) { + m := t.events + if m == nil { + m = make(map[int][]*event) + t.events = m + } + i := len(t.list) + if i > 0 { + i-- + } + m[i] = append(m[i], &event{size, unit}) +} + +// Write prints the phase times to w. +// The prefix is printed at the start of each line. +func (t *Timings) Write(w io.Writer, prefix string) { + if len(t.list) > 0 { + var lines lines + + // group of phases with shared non-empty label prefix + var group struct { + label string // label prefix + tot time.Duration // accumulated phase time + size int // number of phases collected in group + } + + // accumulated time between Stop/Start timestamps + var unaccounted time.Duration + + // process Start/Stop timestamps + pt := &t.list[0] // previous timestamp + tot := t.list[len(t.list)-1].time.Sub(pt.time) + for i := 1; i < len(t.list); i++ { + qt := &t.list[i] // current timestamp + dt := qt.time.Sub(pt.time) + + var label string + var events []*event + if pt.start { + // previous phase started + label = pt.label + events = t.events[i-1] + if qt.start { + // start implicitly ended previous phase; nothing to do + } else { + // stop ended previous phase; append stop labels, if any + if qt.label != "" { + label += ":" + qt.label + } + // events associated with stop replace prior events + if e := t.events[i]; e != nil { + events = e + } + } + } else { + // previous phase stopped + if qt.start { + // between a stopped and started phase; unaccounted time + unaccounted += dt + } else { + // previous stop implicitly started current phase + label = qt.label + events = t.events[i] + } + } + if label != "" { + // add phase to existing group, or start a new group + l := commonPrefix(group.label, label) + if group.size == 1 && l != "" || group.size > 1 && l == group.label { + // add to existing group + group.label = l + group.tot += dt + group.size++ + } else { + // start a new group + if group.size > 1 { + lines.add(prefix+group.label+"subtotal", 1, group.tot, tot, nil) + } + group.label = label + group.tot = dt + group.size = 1 + } + + // write phase + lines.add(prefix+label, 1, dt, tot, events) + } + + pt = qt + } + + if group.size > 1 { + lines.add(prefix+group.label+"subtotal", 1, group.tot, tot, nil) + } + + if unaccounted != 0 { + lines.add(prefix+"unaccounted", 1, unaccounted, tot, nil) + } + + lines.add(prefix+"total", 1, tot, tot, nil) + + lines.write(w) + } +} + +func commonPrefix(a, b string) string { + i := 0 + for i < len(a) && i < len(b) && a[i] == b[i] { + i++ + } + return a[:i] +} + +type lines [][]string + +func (lines *lines) add(label string, n int, dt, tot time.Duration, events []*event) { + var line []string + add := func(format string, args ...any) { + line = append(line, fmt.Sprintf(format, args...)) + } + + add("%s", label) + add(" %d", n) + add(" %d ns/op", dt) + add(" %.2f %%", float64(dt)/float64(tot)*100) + + for _, e := range events { + add(" %d", e.size) + add(" %s", e.unit) + add(" %d", int64(float64(e.size)/dt.Seconds()+0.5)) + add(" %s/s", e.unit) + } + + *lines = append(*lines, line) +} + +func (lines lines) write(w io.Writer) { + // determine column widths and contents + var widths []int + var number []bool + for _, line := range lines { + for i, col := range line { + if i < len(widths) { + if len(col) > widths[i] { + widths[i] = len(col) + } + } else { + widths = append(widths, len(col)) + number = append(number, isnumber(col)) // first line determines column contents + } + } + } + + // make column widths a multiple of align for more stable output + const align = 1 // set to a value > 1 to enable + if align > 1 { + for i, w := range widths { + w += align - 1 + widths[i] = w - w%align + } + } + + // print lines taking column widths and contents into account + for _, line := range lines { + for i, col := range line { + format := "%-*s" + if number[i] { + format = "%*s" // numbers are right-aligned + } + fmt.Fprintf(w, format, widths[i], col) + } + fmt.Fprintln(w) + } +} + +func isnumber(s string) bool { + for _, ch := range s { + if ch <= ' ' { + continue // ignore leading whitespace + } + return '0' <= ch && ch <= '9' || ch == '.' || ch == '-' || ch == '+' + } + return false +} diff --git a/go/src/cmd/compile/internal/bitvec/bv.go b/go/src/cmd/compile/internal/bitvec/bv.go new file mode 100644 index 0000000000000000000000000000000000000000..9214aa6cd05560aa6253d8b16143de26f5f13563 --- /dev/null +++ b/go/src/cmd/compile/internal/bitvec/bv.go @@ -0,0 +1,200 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package bitvec + +import ( + "math/bits" + + "cmd/compile/internal/base" + "cmd/internal/src" +) + +const ( + wordBits = 32 + wordMask = wordBits - 1 + wordShift = 5 +) + +// A BitVec is a bit vector. +type BitVec struct { + N int32 // number of bits in vector + B []uint32 // words holding bits +} + +func New(n int32) BitVec { + nword := (n + wordBits - 1) / wordBits + return BitVec{n, make([]uint32, nword)} +} + +type Bulk struct { + words []uint32 + nbit int32 + nword int32 +} + +func NewBulk(nbit int32, count int32, pos src.XPos) Bulk { + nword := (nbit + wordBits - 1) / wordBits + size := int64(nword) * int64(count) + if int64(int32(size*4)) != size*4 { + base.FatalfAt(pos, "NewBulk too big: nbit=%d count=%d nword=%d size=%d", nbit, count, nword, size) + } + return Bulk{ + words: make([]uint32, size), + nbit: nbit, + nword: nword, + } +} + +func (b *Bulk) Next() BitVec { + out := BitVec{b.nbit, b.words[:b.nword]} + b.words = b.words[b.nword:] + return out +} + +func (bv1 BitVec) Eq(bv2 BitVec) bool { + if bv1.N != bv2.N { + base.Fatalf("bvequal: lengths %d and %d are not equal", bv1.N, bv2.N) + } + for i, x := range bv1.B { + if x != bv2.B[i] { + return false + } + } + return true +} + +func (dst BitVec) Copy(src BitVec) { + copy(dst.B, src.B) +} + +func (bv BitVec) Get(i int32) bool { + if i < 0 || i >= bv.N { + base.Fatalf("bvget: index %d is out of bounds with length %d\n", i, bv.N) + } + mask := uint32(1 << uint(i%wordBits)) + return bv.B[i>>wordShift]&mask != 0 +} + +func (bv BitVec) Set(i int32) { + if i < 0 || i >= bv.N { + base.Fatalf("bvset: index %d is out of bounds with length %d\n", i, bv.N) + } + mask := uint32(1 << uint(i%wordBits)) + bv.B[i/wordBits] |= mask +} + +func (bv BitVec) Unset(i int32) { + if i < 0 || i >= bv.N { + base.Fatalf("bvunset: index %d is out of bounds with length %d\n", i, bv.N) + } + mask := uint32(1 << uint(i%wordBits)) + bv.B[i/wordBits] &^= mask +} + +// Next returns the smallest index >= i for which bvget(bv, i) == 1. +// If there is no such index, bvnext returns -1. +func (bv BitVec) Next(i int32) int32 { + if i >= bv.N { + return -1 + } + + // Jump i ahead to next word with bits. + if bv.B[i>>wordShift]>>uint(i&wordMask) == 0 { + i &^= wordMask + i += wordBits + for i < bv.N && bv.B[i>>wordShift] == 0 { + i += wordBits + } + } + + if i >= bv.N { + return -1 + } + + // Find 1 bit. + w := bv.B[i>>wordShift] >> uint(i&wordMask) + i += int32(bits.TrailingZeros32(w)) + + return i +} + +func (bv BitVec) IsEmpty() bool { + for _, x := range bv.B { + if x != 0 { + return false + } + } + return true +} + +func (bv BitVec) Count() int { + n := 0 + for _, x := range bv.B { + n += bits.OnesCount32(x) + } + return n +} + +func (bv BitVec) Not() { + for i, x := range bv.B { + bv.B[i] = ^x + } + if bv.N%wordBits != 0 { + bv.B[len(bv.B)-1] &= 1< 1 { + if name.Linksym() != nil { + base.WarnfAt(pos, "%s will be kept alive", name.Linksym().Name) + } else { + base.WarnfAt(pos, "expr will be kept alive") + } + } +} + +// preserveStmt transforms stmt so that any names defined/assigned within it +// are used after stmt's execution, preventing their dead code elimination +// and dead store elimination. The return value is the transformed statement. +func preserveStmt(curFn *ir.Func, stmt ir.Node) (ret ir.Node) { + ret = stmt + switch n := stmt.(type) { + case *ir.AssignStmt: + // If the left hand side is blank, we need to assign it to a temp + // so that it can be kept alive. + if ir.IsBlank(n.X) { + tmp := typecheck.TempAt(n.Pos(), curFn, n.Y.Type()) + n.X = tmp + n.Def = true + n.PtrInit().Append(typecheck.Stmt(ir.NewDecl(n.Pos(), ir.ODCL, tmp))) + stmt = typecheck.AssignExpr(n) + n = stmt.(*ir.AssignStmt) + } + // Peel down struct and slice indexing to get the names + name := getAddressableNameFromNode(n.X) + if name != nil { + debugName(name, n.Pos()) + ret = keepAliveAt([]ir.Node{name}, n) + } else if deref, ok := n.X.(*ir.StarExpr); ok && deref != nil { + ret = keepAliveAt([]ir.Node{deref}, n) + if base.Flag.LowerM > 1 { + base.WarnfAt(n.Pos(), "dereference will be kept alive") + } + } else if base.Flag.LowerM > 1 { + base.WarnfAt(n.Pos(), "expr is unknown to bloop pass") + } + case *ir.AssignListStmt: + ns := []ir.Node{} + hasBlank := false + for i, lhs := range n.Lhs { + if ir.IsBlank(lhs) { + // If the left hand side has blanks, we need to assign them to temps + // so that they can be kept alive. + var typ *types.Type + // AssignListStmt can have tuple or a list of expressions on the right hand side. + if len(n.Rhs) == 1 && n.Rhs[0].Type() != nil && + n.Rhs[0].Type().IsTuple() && + len(n.Lhs) == n.Rhs[0].Type().NumFields() { + typ = n.Rhs[0].Type().Field(i).Type + } else if len(n.Rhs) == len(n.Lhs) { + typ = n.Rhs[i].Type() + } else { + // Unrecognized shapes, skip? + base.WarnfAt(n.Pos(), "unrecognized shape for assign list stmt for blank assignment") + continue + } + tmp := typecheck.TempAt(n.Pos(), curFn, typ) + n.Lhs[i] = tmp + n.PtrInit().Append(typecheck.Stmt(ir.NewDecl(n.Pos(), ir.ODCL, tmp))) + hasBlank = true + lhs = tmp + } + name := getAddressableNameFromNode(lhs) + if name != nil { + debugName(name, n.Pos()) + ns = append(ns, name) + } else if deref, ok := lhs.(*ir.StarExpr); ok && deref != nil { + ns = append(ns, deref) + if base.Flag.LowerM > 1 { + base.WarnfAt(n.Pos(), "dereference will be kept alive") + } + } else if base.Flag.LowerM > 1 { + base.WarnfAt(n.Pos(), "expr is unknown to bloop pass") + } + } + if hasBlank { + // blank nodes are rewritten to temps, we need to typecheck the node again. + n.Def = true + stmt = typecheck.AssignExpr(n) + n = stmt.(*ir.AssignListStmt) + } + ret = keepAliveAt(ns, n) + case *ir.AssignOpStmt: + name := getAddressableNameFromNode(n.X) + if name != nil { + debugName(name, n.Pos()) + ret = keepAliveAt([]ir.Node{name}, n) + } else if deref, ok := n.X.(*ir.StarExpr); ok && deref != nil { + ret = keepAliveAt([]ir.Node{deref}, n) + if base.Flag.LowerM > 1 { + base.WarnfAt(n.Pos(), "dereference will be kept alive") + } + } else if base.Flag.LowerM > 1 { + base.WarnfAt(n.Pos(), "expr is unknown to bloop pass") + } + case *ir.CallExpr: + curNode := stmt + if n.Fun != nil && n.Fun.Type() != nil && n.Fun.Type().NumResults() != 0 { + ns := []ir.Node{} + // This function's results are not assigned, assign them to + // auto tmps and then keepAliveAt these autos. + // Note: markStmt assumes the context that it's called - this CallExpr is + // not within another OAS2, which is guaranteed by the case above. + results := n.Fun.Type().Results() + lhs := make([]ir.Node, len(results)) + for i, res := range results { + tmp := typecheck.TempAt(n.Pos(), curFn, res.Type) + lhs[i] = tmp + ns = append(ns, tmp) + } + + // Create an assignment statement. + assign := typecheck.AssignExpr( + ir.NewAssignListStmt(n.Pos(), ir.OAS2, lhs, + []ir.Node{n})).(*ir.AssignListStmt) + assign.Def = true + for _, tmp := range lhs { + // Place temp declarations in the loop body to help escape analysis. + assign.PtrInit().Append(typecheck.Stmt(ir.NewDecl(assign.Pos(), ir.ODCL, tmp.(*ir.Name)))) + } + curNode = assign + plural := "" + if len(results) > 1 { + plural = "s" + } + if base.Flag.LowerM > 1 { + base.WarnfAt(n.Pos(), "function result%s will be kept alive", plural) + } + ret = keepAliveAt(ns, curNode) + } else { + // This function probably doesn't return anything, keep its args alive. + argTmps := []ir.Node{} + names := []ir.Node{} + for i, a := range n.Args { + if name := getAddressableNameFromNode(a); name != nil { + // If they are name, keep them alive directly. + debugName(name, n.Pos()) + names = append(names, name) + } else if a.Op() == ir.OSLICELIT { + // variadic args are encoded as slice literal. + s := a.(*ir.CompLitExpr) + ns := []ir.Node{} + for i, elem := range s.List { + if name := getAddressableNameFromNode(elem); name != nil { + debugName(name, n.Pos()) + ns = append(ns, name) + } else { + // We need a temporary to save this arg. + tmp := typecheck.TempAt(elem.Pos(), curFn, elem.Type()) + assign := ir.NewAssignStmt(elem.Pos(), tmp, elem) + assign.Def = true + // Place temp declarations in the loop body to help escape analysis. + assign.PtrInit().Append(typecheck.Stmt(ir.NewDecl(assign.Pos(), ir.ODCL, tmp))) + argTmps = append(argTmps, typecheck.AssignExpr(assign)) + names = append(names, tmp) + s.List[i] = tmp + if base.Flag.LowerM > 1 { + base.WarnfAt(n.Pos(), "function arg will be kept alive") + } + } + } + names = append(names, ns...) + } else { + // expressions, we need to assign them to temps and change the original arg to reference + // them. + tmp := typecheck.TempAt(n.Pos(), curFn, a.Type()) + assign := ir.NewAssignStmt(n.Pos(), tmp, a) + assign.Def = true + // Place temp declarations in the loop body to help escape analysis. + assign.PtrInit().Append(typecheck.Stmt(ir.NewDecl(assign.Pos(), ir.ODCL, tmp))) + argTmps = append(argTmps, typecheck.AssignExpr(assign)) + names = append(names, tmp) + n.Args[i] = tmp + if base.Flag.LowerM > 1 { + base.WarnfAt(n.Pos(), "function arg will be kept alive") + } + } + } + if len(argTmps) > 0 { + argTmps = append(argTmps, n) + curNode = ir.NewBlockStmt(n.Pos(), argTmps) + } + ret = keepAliveAt(names, curNode) + } + } + return +} + +func preserveStmts(curFn *ir.Func, list ir.Nodes) { + for i := range list { + list[i] = preserveStmt(curFn, list[i]) + } +} + +// isTestingBLoop returns true if it matches the node as a +// testing.(*B).Loop. See issue #61515. +func isTestingBLoop(t ir.Node) bool { + if t.Op() != ir.OFOR { + return false + } + nFor, ok := t.(*ir.ForStmt) + if !ok || nFor.Cond == nil || nFor.Cond.Op() != ir.OCALLFUNC { + return false + } + n, ok := nFor.Cond.(*ir.CallExpr) + if !ok || n.Fun == nil || n.Fun.Op() != ir.OMETHEXPR { + return false + } + name := ir.MethodExprName(n.Fun) + if name == nil { + return false + } + if fSym := name.Sym(); fSym != nil && name.Class == ir.PFUNC && fSym.Pkg != nil && + fSym.Name == "(*B).Loop" && fSym.Pkg.Path == "testing" { + // Attempting to match a function call to testing.(*B).Loop + return true + } + return false +} + +type editor struct { + inBloop bool + curFn *ir.Func +} + +func (e editor) edit(n ir.Node) ir.Node { + e.inBloop = isTestingBLoop(n) || e.inBloop + // It's in bloop, mark the stmts with bodies. + ir.EditChildren(n, e.edit) + if e.inBloop { + switch n := n.(type) { + case *ir.ForStmt: + preserveStmts(e.curFn, n.Body) + case *ir.IfStmt: + preserveStmts(e.curFn, n.Body) + preserveStmts(e.curFn, n.Else) + case *ir.BlockStmt: + preserveStmts(e.curFn, n.List) + case *ir.CaseClause: + preserveStmts(e.curFn, n.List) + preserveStmts(e.curFn, n.Body) + case *ir.CommClause: + preserveStmts(e.curFn, n.Body) + case *ir.RangeStmt: + preserveStmts(e.curFn, n.Body) + } + } + return n +} + +// BloopWalk performs a walk on all functions in the package +// if it imports testing and wrap the results of all qualified +// statements in a runtime.KeepAlive intrinsic call. See package +// doc for more details. +// +// for b.Loop() {...} +// +// loop's body. +func BloopWalk(pkg *ir.Package) { + hasTesting := false + for _, i := range pkg.Imports { + if i.Path == "testing" { + hasTesting = true + break + } + } + if !hasTesting { + return + } + for _, fn := range pkg.Funcs { + e := editor{false, fn} + ir.EditChildren(fn, e.edit) + } +} diff --git a/go/src/cmd/compile/internal/compare/compare.go b/go/src/cmd/compile/internal/compare/compare.go new file mode 100644 index 0000000000000000000000000000000000000000..638eb37a6221098ef8f999f349a1cb80e36134c8 --- /dev/null +++ b/go/src/cmd/compile/internal/compare/compare.go @@ -0,0 +1,385 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package compare contains code for generating comparison +// routines for structs, strings and interfaces. +package compare + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "fmt" + "math/bits" + "sort" +) + +// IsRegularMemory reports whether t can be compared/hashed as regular memory. +func IsRegularMemory(t *types.Type) bool { + return types.AlgType(t) == types.AMEM +} + +// Memrun finds runs of struct fields for which memory-only algs are appropriate. +// t is the parent struct type, and start is the field index at which to start the run. +// size is the length in bytes of the memory included in the run. +// next is the index just after the end of the memory run. +func Memrun(t *types.Type, start int) (size int64, next int) { + next = start + for { + next++ + if next == t.NumFields() { + break + } + // Stop run after a padded field. + if types.IsPaddedField(t, next-1) { + break + } + // Also, stop before a blank or non-memory field. + if f := t.Field(next); f.Sym.IsBlank() || !IsRegularMemory(f.Type) { + break + } + // For issue 46283, don't combine fields if the resulting load would + // require a larger alignment than the component fields. + if base.Ctxt.Arch.Alignment > 1 { + align := t.Alignment() + if off := t.Field(start).Offset; off&(align-1) != 0 { + // Offset is less aligned than the containing type. + // Use offset to determine alignment. + align = 1 << uint(bits.TrailingZeros64(uint64(off))) + } + size := t.Field(next).End() - t.Field(start).Offset + if size > align { + break + } + } + } + return t.Field(next-1).End() - t.Field(start).Offset, next +} + +// EqCanPanic reports whether == on type t could panic (has an interface somewhere). +// t must be comparable. +func EqCanPanic(t *types.Type) bool { + switch t.Kind() { + default: + return false + case types.TINTER: + return true + case types.TARRAY: + return EqCanPanic(t.Elem()) + case types.TSTRUCT: + for _, f := range t.Fields() { + if !f.Sym.IsBlank() && EqCanPanic(f.Type) { + return true + } + } + return false + } +} + +// EqStructCost returns the cost of an equality comparison of two structs. +// +// The cost is determined using an algorithm which takes into consideration +// the size of the registers in the current architecture and the size of the +// memory-only fields in the struct. +func EqStructCost(t *types.Type) int64 { + cost := int64(0) + + for i, fields := 0, t.Fields(); i < len(fields); { + f := fields[i] + + // Skip blank-named fields. + if f.Sym.IsBlank() { + i++ + continue + } + + n, _, next := eqStructFieldCost(t, i) + + cost += n + i = next + } + + return cost +} + +// eqStructFieldCost returns the cost of an equality comparison of two struct fields. +// t is the parent struct type, and i is the index of the field in the parent struct type. +// eqStructFieldCost may compute the cost of several adjacent fields at once. It returns +// the cost, the size of the set of fields it computed the cost for (in bytes), and the +// index of the first field not part of the set of fields for which the cost +// has already been calculated. +func eqStructFieldCost(t *types.Type, i int) (int64, int64, int) { + var ( + cost = int64(0) + regSize = int64(types.RegSize) + + size int64 + next int + ) + + if base.Ctxt.Arch.CanMergeLoads { + // If we can merge adjacent loads then we can calculate the cost of the + // comparison using the size of the memory run and the size of the registers. + size, next = Memrun(t, i) + cost = size / regSize + if size%regSize != 0 { + cost++ + } + return cost, size, next + } + + // If we cannot merge adjacent loads then we have to use the size of the + // field and take into account the type to determine how many loads and compares + // are needed. + ft := t.Field(i).Type + size = ft.Size() + next = i + 1 + + return calculateCostForType(ft), size, next +} + +func calculateCostForType(t *types.Type) int64 { + var cost int64 + switch t.Kind() { + case types.TSTRUCT: + return EqStructCost(t) + case types.TSLICE: + // Slices are not comparable. + base.Fatalf("calculateCostForType: unexpected slice type") + case types.TARRAY: + elemCost := calculateCostForType(t.Elem()) + cost = t.NumElem() * elemCost + case types.TSTRING, types.TINTER, types.TCOMPLEX64, types.TCOMPLEX128: + cost = 2 + case types.TINT64, types.TUINT64: + cost = 8 / int64(types.RegSize) + default: + cost = 1 + } + return cost +} + +// EqStruct compares two structs np and nq for equality. +// It works by building a list of boolean conditions to satisfy. +// Conditions must be evaluated in the returned order and +// properly short-circuited by the caller. +// The first return value is the flattened list of conditions, +// the second value is a boolean indicating whether any of the +// comparisons could panic. +func EqStruct(t *types.Type, np, nq ir.Node) ([]ir.Node, bool) { + // The conditions are a list-of-lists. Conditions are reorderable + // within each inner list. The outer lists must be evaluated in order. + var conds [][]ir.Node + conds = append(conds, []ir.Node{}) + and := func(n ir.Node) { + i := len(conds) - 1 + conds[i] = append(conds[i], n) + } + + // Walk the struct using memequal for runs of AMEM + // and calling specific equality tests for the others. + for i, fields := 0, t.Fields(); i < len(fields); { + f := fields[i] + + // Skip blank-named fields. + if f.Sym.IsBlank() { + i++ + continue + } + + typeCanPanic := EqCanPanic(f.Type) + + // Compare non-memory fields with field equality. + if !IsRegularMemory(f.Type) { + if typeCanPanic { + // Enforce ordering by starting a new set of reorderable conditions. + conds = append(conds, []ir.Node{}) + } + switch { + case f.Type.IsString(): + p := typecheck.DotField(base.Pos, typecheck.Expr(np), i) + q := typecheck.DotField(base.Pos, typecheck.Expr(nq), i) + eqlen, eqmem := EqString(p, q) + and(eqlen) + and(eqmem) + default: + and(eqfield(np, nq, i)) + } + if typeCanPanic { + // Also enforce ordering after something that can panic. + conds = append(conds, []ir.Node{}) + } + i++ + continue + } + + cost, size, next := eqStructFieldCost(t, i) + if cost <= 4 { + // Cost of 4 or less: use plain field equality. + for j := i; j < next; j++ { + and(eqfield(np, nq, j)) + } + } else { + // Higher cost: use memequal. + cc := eqmem(np, nq, i, size) + and(cc) + } + i = next + } + + // Sort conditions to put runtime calls last. + // Preserve the rest of the ordering. + var flatConds []ir.Node + for _, c := range conds { + isCall := func(n ir.Node) bool { + return n.Op() == ir.OCALL || n.Op() == ir.OCALLFUNC + } + sort.SliceStable(c, func(i, j int) bool { + return !isCall(c[i]) && isCall(c[j]) + }) + flatConds = append(flatConds, c...) + } + return flatConds, len(conds) > 1 +} + +// EqString returns the nodes +// +// len(s) == len(t) +// +// and +// +// memequal(s.ptr, t.ptr, len(s)) +// +// which can be used to construct string equality comparison. +// eqlen must be evaluated before eqmem, and shortcircuiting is required. +func EqString(s, t ir.Node) (eqlen *ir.BinaryExpr, eqmem *ir.CallExpr) { + s = typecheck.Conv(s, types.Types[types.TSTRING]) + t = typecheck.Conv(t, types.Types[types.TSTRING]) + sptr := ir.NewUnaryExpr(base.Pos, ir.OSPTR, s) + tptr := ir.NewUnaryExpr(base.Pos, ir.OSPTR, t) + slen := typecheck.Conv(ir.NewUnaryExpr(base.Pos, ir.OLEN, s), types.Types[types.TUINTPTR]) + tlen := typecheck.Conv(ir.NewUnaryExpr(base.Pos, ir.OLEN, t), types.Types[types.TUINTPTR]) + + // Pick the 3rd arg to memequal. Both slen and tlen are fine to use, because we short + // circuit the memequal call if they aren't the same. But if one is a constant some + // memequal optimizations are easier to apply. + probablyConstant := func(n ir.Node) bool { + if n.Op() == ir.OCONVNOP { + n = n.(*ir.ConvExpr).X + } + if n.Op() == ir.OLITERAL { + return true + } + if n.Op() != ir.ONAME { + return false + } + name := n.(*ir.Name) + if name.Class != ir.PAUTO { + return false + } + if def := name.Defn; def == nil { + // n starts out as the empty string + return true + } else if def.Op() == ir.OAS && (def.(*ir.AssignStmt).Y == nil || def.(*ir.AssignStmt).Y.Op() == ir.OLITERAL) { + // n starts out as a constant string + return true + } + return false + } + cmplen := slen + if probablyConstant(t) && !probablyConstant(s) { + cmplen = tlen + } + + fn := typecheck.LookupRuntime("memequal", types.Types[types.TUINT8], types.Types[types.TUINT8]) + call := typecheck.Call(base.Pos, fn, []ir.Node{sptr, tptr, ir.Copy(cmplen)}, false).(*ir.CallExpr) + + cmp := ir.NewBinaryExpr(base.Pos, ir.OEQ, slen, tlen) + cmp = typecheck.Expr(cmp).(*ir.BinaryExpr) + cmp.SetType(types.Types[types.TBOOL]) + return cmp, call +} + +// EqInterface returns the nodes +// +// s.tab == t.tab (or s.typ == t.typ, as appropriate) +// +// and +// +// ifaceeq(s.tab, s.data, t.data) (or efaceeq(s.typ, s.data, t.data), as appropriate) +// +// which can be used to construct interface equality comparison. +// eqtab must be evaluated before eqdata, and shortcircuiting is required. +func EqInterface(s, t ir.Node) (eqtab *ir.BinaryExpr, eqdata *ir.CallExpr) { + if !types.Identical(s.Type(), t.Type()) { + base.Fatalf("EqInterface %v %v", s.Type(), t.Type()) + } + // func ifaceeq(tab *uintptr, x, y unsafe.Pointer) (ret bool) + // func efaceeq(typ *uintptr, x, y unsafe.Pointer) (ret bool) + var fn ir.Node + if s.Type().IsEmptyInterface() { + fn = typecheck.LookupRuntime("efaceeq") + } else { + fn = typecheck.LookupRuntime("ifaceeq") + } + + stab := ir.NewUnaryExpr(base.Pos, ir.OITAB, s) + ttab := ir.NewUnaryExpr(base.Pos, ir.OITAB, t) + sdata := ir.NewUnaryExpr(base.Pos, ir.OIDATA, s) + tdata := ir.NewUnaryExpr(base.Pos, ir.OIDATA, t) + sdata.SetType(types.Types[types.TUNSAFEPTR]) + tdata.SetType(types.Types[types.TUNSAFEPTR]) + sdata.SetTypecheck(1) + tdata.SetTypecheck(1) + + call := typecheck.Call(base.Pos, fn, []ir.Node{stab, sdata, tdata}, false).(*ir.CallExpr) + + cmp := ir.NewBinaryExpr(base.Pos, ir.OEQ, stab, ttab) + cmp = typecheck.Expr(cmp).(*ir.BinaryExpr) + cmp.SetType(types.Types[types.TBOOL]) + return cmp, call +} + +// eqfield returns the node +// +// p.field == q.field +func eqfield(p, q ir.Node, field int) ir.Node { + nx := typecheck.DotField(base.Pos, typecheck.Expr(p), field) + ny := typecheck.DotField(base.Pos, typecheck.Expr(q), field) + return typecheck.Expr(ir.NewBinaryExpr(base.Pos, ir.OEQ, nx, ny)) +} + +// eqmem returns the node +// +// memequal(&p.field, &q.field, size) +func eqmem(p, q ir.Node, field int, size int64) ir.Node { + nx := typecheck.Expr(typecheck.NodAddr(typecheck.DotField(base.Pos, p, field))) + ny := typecheck.Expr(typecheck.NodAddr(typecheck.DotField(base.Pos, q, field))) + + fn, needsize := eqmemfunc(size, nx.Type().Elem()) + call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, nil) + call.Args.Append(nx) + call.Args.Append(ny) + if needsize { + call.Args.Append(ir.NewInt(base.Pos, size)) + } + + return call +} + +func eqmemfunc(size int64, t *types.Type) (fn *ir.Name, needsize bool) { + if !base.Ctxt.Arch.CanMergeLoads && t.Alignment() < int64(base.Ctxt.Arch.Alignment) && t.Alignment() < t.Size() { + // We can't use larger comparisons if the value might not be aligned + // enough for the larger comparison. See issues 46283 and 67160. + size = 0 + } + switch size { + case 1, 2, 4, 8, 16: + buf := fmt.Sprintf("memequal%d", int(size)*8) + return typecheck.LookupRuntime(buf, t, t), false + } + + return typecheck.LookupRuntime("memequal", t, t), true +} diff --git a/go/src/cmd/compile/internal/compare/compare_test.go b/go/src/cmd/compile/internal/compare/compare_test.go new file mode 100644 index 0000000000000000000000000000000000000000..4271effbdbb3d930a9df4e406c8b029fc9dddf13 --- /dev/null +++ b/go/src/cmd/compile/internal/compare/compare_test.go @@ -0,0 +1,101 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package compare + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" + "cmd/internal/sys" + "testing" +) + +type typefn func() *types.Type + +func init() { + // These are the few constants that need to be initialized in order to use + // the types package without using the typecheck package by calling + // typecheck.InitUniverse() (the normal way to initialize the types package). + types.PtrSize = 8 + types.RegSize = 8 + types.MaxWidth = 1 << 50 + base.Ctxt = &obj.Link{Arch: &obj.LinkArch{Arch: &sys.Arch{Alignment: 1, CanMergeLoads: true}}} + typecheck.InitUniverse() +} + +func TestEqStructCost(t *testing.T) { + repeat := func(n int, typ *types.Type) []*types.Type { + typs := make([]*types.Type, n) + for i := range typs { + typs[i] = typ + } + return typs + } + + tt := []struct { + name string + cost int64 + nonMergeLoadCost int64 + fieldTypes []*types.Type + }{ + {"struct without fields", 0, 0, nil}, + {"struct with 1 byte field", 1, 1, repeat(1, types.ByteType)}, + {"struct with 8 byte fields", 1, 8, repeat(8, types.ByteType)}, + {"struct with 16 byte fields", 2, 16, repeat(16, types.ByteType)}, + {"struct with 32 byte fields", 4, 32, repeat(32, types.ByteType)}, + {"struct with 2 int32 fields", 1, 2, repeat(2, types.Types[types.TINT32])}, + {"struct with 2 int32 fields and 1 int64", 2, 3, + []*types.Type{ + types.Types[types.TINT32], + types.Types[types.TINT32], + types.Types[types.TINT64], + }, + }, + {"struct with 1 int field and 1 string", 3, 3, + []*types.Type{ + types.Types[types.TINT64], + types.Types[types.TSTRING], + }, + }, + {"struct with 2 strings", 4, 4, repeat(2, types.Types[types.TSTRING])}, + {"struct with 1 large byte array field", 26, 101, + []*types.Type{ + types.NewArray(types.Types[types.TUINT16], 101), + }, + }, + {"struct with string array field", 4, 4, + []*types.Type{ + types.NewArray(types.Types[types.TSTRING], 2), + }, + }, + } + + for _, tc := range tt { + t.Run(tc.name, func(t *testing.T) { + fields := make([]*types.Field, len(tc.fieldTypes)) + for i, ftyp := range tc.fieldTypes { + fields[i] = types.NewField(src.NoXPos, typecheck.LookupNum("f", i), ftyp) + } + typ := types.NewStruct(fields) + types.CalcSize(typ) + + want := tc.cost + base.Ctxt.Arch.CanMergeLoads = true + actual := EqStructCost(typ) + if actual != want { + t.Errorf("CanMergeLoads=true EqStructCost(%v) = %d, want %d", typ, actual, want) + } + + base.Ctxt.Arch.CanMergeLoads = false + want = tc.nonMergeLoadCost + actual = EqStructCost(typ) + if actual != want { + t.Errorf("CanMergeLoads=false EqStructCost(%v) = %d, want %d", typ, actual, want) + } + }) + } +} diff --git a/go/src/cmd/compile/internal/coverage/cover.go b/go/src/cmd/compile/internal/coverage/cover.go new file mode 100644 index 0000000000000000000000000000000000000000..5ecd5271f617e2aa7fe28644eb3cc025e3ad5046 --- /dev/null +++ b/go/src/cmd/compile/internal/coverage/cover.go @@ -0,0 +1,200 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package coverage + +// This package contains support routines for coverage "fixup" in the +// compiler, which happens when compiling a package whose source code +// has been run through "cmd/cover" to add instrumentation. The two +// important entry points are FixupVars (called prior to package init +// generation) and FixupInit (called following package init +// generation). + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/objabi" + "internal/coverage" + "strconv" + "strings" +) + +// names records state information collected in the first fixup +// phase so that it can be passed to the second fixup phase. +type names struct { + MetaVar *ir.Name + PkgIdVar *ir.Name + InitFn *ir.Func + CounterMode coverage.CounterMode + CounterGran coverage.CounterGranularity +} + +// Fixup adds calls to the pkg init function as appropriate to +// register coverage-related variables with the runtime. +// +// It also reclassifies selected variables (for example, tagging +// coverage counter variables with flags so that they can be handled +// properly downstream). +func Fixup() { + if base.Flag.Cfg.CoverageInfo == nil { + return // not using coverage + } + + metaVarName := base.Flag.Cfg.CoverageInfo.MetaVar + pkgIdVarName := base.Flag.Cfg.CoverageInfo.PkgIdVar + counterMode := base.Flag.Cfg.CoverageInfo.CounterMode + counterGran := base.Flag.Cfg.CoverageInfo.CounterGranularity + counterPrefix := base.Flag.Cfg.CoverageInfo.CounterPrefix + var metavar *ir.Name + var pkgidvar *ir.Name + + ckTypSanity := func(nm *ir.Name, tag string) { + if nm.Type() == nil || nm.Type().HasPointers() { + base.Fatalf("unsuitable %s %q mentioned in coveragecfg, improper type '%v'", tag, nm.Sym().Name, nm.Type()) + } + } + + for _, nm := range typecheck.Target.Externs { + s := nm.Sym() + switch s.Name { + case metaVarName: + metavar = nm + ckTypSanity(nm, "metavar") + nm.MarkReadonly() + continue + case pkgIdVarName: + pkgidvar = nm + ckTypSanity(nm, "pkgidvar") + nm.SetCoverageAuxVar(true) + s := nm.Linksym() + s.Type = objabi.SCOVERAGE_AUXVAR + continue + } + if strings.HasPrefix(s.Name, counterPrefix) { + ckTypSanity(nm, "countervar") + nm.SetCoverageAuxVar(true) + s := nm.Linksym() + s.Type = objabi.SCOVERAGE_COUNTER + } + } + cm := coverage.ParseCounterMode(counterMode) + if cm == coverage.CtrModeInvalid { + base.Fatalf("bad setting %q for covermode in coveragecfg:", + counterMode) + } + var cg coverage.CounterGranularity + switch counterGran { + case "perblock": + cg = coverage.CtrGranularityPerBlock + case "perfunc": + cg = coverage.CtrGranularityPerFunc + default: + base.Fatalf("bad setting %q for covergranularity in coveragecfg:", + counterGran) + } + + cnames := names{ + MetaVar: metavar, + PkgIdVar: pkgidvar, + CounterMode: cm, + CounterGran: cg, + } + + for _, fn := range typecheck.Target.Funcs { + if ir.FuncName(fn) == "init" { + cnames.InitFn = fn + break + } + } + if cnames.InitFn == nil { + panic("unexpected (no init func for -cover build)") + } + + hashv, len := metaHashAndLen() + if cnames.CounterMode != coverage.CtrModeTestMain { + registerMeta(cnames, hashv, len) + } + if base.Ctxt.Pkgpath == "main" { + addInitHookCall(cnames.InitFn, cnames.CounterMode) + } +} + +func metaHashAndLen() ([16]byte, int) { + + // Read meta-data hash from config entry. + mhash := base.Flag.Cfg.CoverageInfo.MetaHash + if len(mhash) != 32 { + base.Fatalf("unexpected: got metahash length %d want 32", len(mhash)) + } + var hv [16]byte + for i := 0; i < 16; i++ { + nib := mhash[i*2 : i*2+2] + x, err := strconv.ParseInt(nib, 16, 32) + if err != nil { + base.Fatalf("metahash bad byte %q", nib) + } + hv[i] = byte(x) + } + + // Return hash and meta-data len + return hv, base.Flag.Cfg.CoverageInfo.MetaLen +} + +func registerMeta(cnames names, hashv [16]byte, mdlen int) { + // Materialize expression for hash (an array literal) + pos := cnames.InitFn.Pos() + elist := make([]ir.Node, 0, 16) + for i := 0; i < 16; i++ { + elem := ir.NewInt(base.Pos, int64(hashv[i])) + elist = append(elist, elem) + } + ht := types.NewArray(types.Types[types.TUINT8], 16) + hashx := ir.NewCompLitExpr(pos, ir.OCOMPLIT, ht, elist) + + // Materalize expression corresponding to address of the meta-data symbol. + mdax := typecheck.NodAddr(cnames.MetaVar) + mdauspx := typecheck.ConvNop(mdax, types.Types[types.TUNSAFEPTR]) + + // Materialize expression for length. + lenx := ir.NewInt(base.Pos, int64(mdlen)) // untyped + + // Generate a call to runtime.addCovMeta, e.g. + // + // pkgIdVar = runtime.addCovMeta(&sym, len, hash, pkgpath, pkid, cmode, cgran) + // + fn := typecheck.LookupRuntime("addCovMeta") + pkid := coverage.HardCodedPkgID(base.Ctxt.Pkgpath) + pkIdNode := ir.NewInt(base.Pos, int64(pkid)) + cmodeNode := ir.NewInt(base.Pos, int64(cnames.CounterMode)) + cgranNode := ir.NewInt(base.Pos, int64(cnames.CounterGran)) + pkPathNode := ir.NewString(base.Pos, base.Ctxt.Pkgpath) + callx := typecheck.Call(pos, fn, []ir.Node{mdauspx, lenx, hashx, + pkPathNode, pkIdNode, cmodeNode, cgranNode}, false) + assign := callx + if pkid == coverage.NotHardCoded { + assign = typecheck.Stmt(ir.NewAssignStmt(pos, cnames.PkgIdVar, callx)) + } + + // Tack the call onto the start of our init function. We do this + // early in the init since it's possible that instrumented function + // bodies (with counter updates) might be inlined into init. + cnames.InitFn.Body.Prepend(assign) +} + +// addInitHookCall generates a call to runtime/coverage.initHook() and +// inserts it into the package main init function, which will kick off +// the process for coverage data writing (emit meta data, and register +// an exit hook to emit counter data). +func addInitHookCall(initfn *ir.Func, cmode coverage.CounterMode) { + typecheck.InitCoverage() + pos := initfn.Pos() + istest := cmode == coverage.CtrModeTestMain + initf := typecheck.LookupCoverage("initHook") + istestNode := ir.NewBool(base.Pos, istest) + args := []ir.Node{istestNode} + callx := typecheck.Call(pos, initf, args, false) + initfn.Body.Append(callx) +} diff --git a/go/src/cmd/compile/internal/deadlocals/deadlocals.go b/go/src/cmd/compile/internal/deadlocals/deadlocals.go new file mode 100644 index 0000000000000000000000000000000000000000..55ad0387a4de2cfb423edb40387fd917ebb9e258 --- /dev/null +++ b/go/src/cmd/compile/internal/deadlocals/deadlocals.go @@ -0,0 +1,199 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// The deadlocals pass removes assignments to unused local variables. +package deadlocals + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" + "fmt" + "go/constant" +) + +// Funcs applies the deadlocals pass to fns. +func Funcs(fns []*ir.Func) { + if base.Flag.N != 0 || base.Debug.NoDeadLocals != 0 { + return + } + + zero := ir.NewBasicLit(base.AutogeneratedPos, types.Types[types.TINT], constant.MakeInt64(0)) + + for _, fn := range fns { + if fn.IsClosure() { + continue + } + + v := newVisitor(fn) + v.nodes(fn.Body) + + for _, k := range v.defsKeys { + assigns := v.defs[k] + for _, as := range assigns { + // Kludge for "missing func info" linker panic. + // See also closureInitLSym in inline/inl.go. + if clo, ok := (*as.rhs).(*ir.ClosureExpr); ok && clo.Op() == ir.OCLOSURE { + if clo.Func.IsClosure() { + ir.InitLSym(clo.Func, true) + } + } + + *as.lhs = ir.BlankNode + *as.rhs = zero + } + if len(assigns) > 0 { + // k.Defn might be pointing at one of the + // assignments we're overwriting. + k.Defn = nil + } + } + } +} + +type visitor struct { + curfn *ir.Func + // defs[name] contains assignments that can be discarded if name can be discarded. + // if defs[name] is defined nil, then name is actually used. + defs map[*ir.Name][]assign + defsKeys []*ir.Name // insertion order of keys, for reproducible iteration (and builds) + + doNode func(ir.Node) bool +} + +type assign struct { + pos src.XPos + lhs, rhs *ir.Node +} + +func newVisitor(fn *ir.Func) *visitor { + v := &visitor{ + curfn: fn, + defs: make(map[*ir.Name][]assign), + } + v.doNode = func(n ir.Node) bool { + v.node(n) + return false + } + return v +} + +func (v *visitor) node(n ir.Node) { + if n == nil { + return + } + + switch n.Op() { + default: + ir.DoChildrenWithHidden(n, v.doNode) + case ir.OCLOSURE: + n := n.(*ir.ClosureExpr) + v.nodes(n.Init()) + for _, cv := range n.Func.ClosureVars { + v.node(cv) + } + v.nodes(n.Func.Body) + + case ir.ODCL: + // ignore + case ir.ONAME: + n := n.(*ir.Name) + n = n.Canonical() + if isLocal(n, false) { + // Force any lazy definitions. + s, ok := v.defs[n] + if !ok { + v.defsKeys = append(v.defsKeys, n) + } + v.defs[n] = nil + for _, as := range s { + // do the visit that was skipped in v.assign when as was appended to v.defs[n] + v.node(*as.rhs) + } + } + + case ir.OAS: + n := n.(*ir.AssignStmt) + v.assign(n.Pos(), &n.X, &n.Y, false) + case ir.OAS2: + n := n.(*ir.AssignListStmt) + + // If all LHS vars are blank, treat them as intentional + // uses of corresponding RHS vars. If any are non-blank + // then any blanks are discards. + hasNonBlank := false + for i := range n.Lhs { + if !ir.IsBlank(n.Lhs[i]) { + hasNonBlank = true + break + } + } + for i := range n.Lhs { + v.assign(n.Pos(), &n.Lhs[i], &n.Rhs[i], hasNonBlank) + } + } +} + +func (v *visitor) nodes(list ir.Nodes) { + for _, n := range list { + v.node(n) + } +} + +func hasEffects(n ir.Node) bool { + if n == nil { + return false + } + if len(n.Init()) != 0 { + return true + } + + switch n.Op() { + // TODO(mdempsky): More. + case ir.ONAME, ir.OLITERAL, ir.ONIL, ir.OCLOSURE: + return false + } + return true +} + +func (v *visitor) assign(pos src.XPos, lhs, rhs *ir.Node, blankIsNotUse bool) { + name, ok := (*lhs).(*ir.Name) + if !ok { + v.node(*lhs) // XXX: Interpret as variable, not value. + v.node(*rhs) + return + } + name = name.Canonical() + + if isLocal(name, blankIsNotUse) && !hasEffects(*rhs) { + if s, ok := v.defs[name]; !ok || s != nil { + // !ok || s != nil is FALSE if previously "v.defs[name] = nil" -- that marks a use. + if !ok { + v.defsKeys = append(v.defsKeys, name) + } + v.defs[name] = append(s, assign{pos, lhs, rhs}) + return // don't visit rhs unless that node ends up live, later. + } + } + + v.node(*rhs) +} + +func isLocal(n *ir.Name, blankIsNotUse bool) bool { + if ir.IsBlank(n) { + // Treat single assignments as intentional use (false), anything else is a discard (true). + return blankIsNotUse + } + + switch n.Class { + case ir.PAUTO, ir.PPARAM: + return true + case ir.PPARAMOUT: + return false + case ir.PEXTERN, ir.PFUNC: + return false + } + panic(fmt.Sprintf("unexpected Class: %+v", n)) +} diff --git a/go/src/cmd/compile/internal/devirtualize/devirtualize.go b/go/src/cmd/compile/internal/devirtualize/devirtualize.go new file mode 100644 index 0000000000000000000000000000000000000000..59ddc2e5366cd6c5ed0d371c0c857b6af978bdc4 --- /dev/null +++ b/go/src/cmd/compile/internal/devirtualize/devirtualize.go @@ -0,0 +1,600 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package devirtualize implements two "devirtualization" optimization passes: +// +// - "Static" devirtualization which replaces interface method calls with +// direct concrete-type method calls where possible. +// - "Profile-guided" devirtualization which replaces indirect calls with a +// conditional direct call to the hottest concrete callee from a profile, as +// well as a fallback using the original indirect call. +package devirtualize + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" +) + +const go126ImprovedConcreteTypeAnalysis = true + +// StaticCall devirtualizes the given call if possible when the concrete callee +// is available statically. +func StaticCall(s *State, call *ir.CallExpr) { + // For promoted methods (including value-receiver methods promoted + // to pointer-receivers), the interface method wrapper may contain + // expressions that can panic (e.g., ODEREF, ODOTPTR, + // ODOTINTER). Devirtualization involves inlining these expressions + // (and possible panics) to the call site. This normally isn't a + // problem, but for go/defer statements it can move the panic from + // when/where the call executes to the go/defer statement itself, + // which is a visible change in semantics (e.g., #52072). To prevent + // this, we skip devirtualizing calls within go/defer statements + // altogether. + if call.GoDefer { + return + } + + if call.Op() != ir.OCALLINTER { + return + } + + sel := call.Fun.(*ir.SelectorExpr) + var typ *types.Type + if go126ImprovedConcreteTypeAnalysis { + typ = concreteType(s, sel.X) + if typ == nil { + return + } + + // Don't create type-assertions that would be impossible at compile-time. + // This can happen in such case: any(0).(interface {A()}).A(), this typechecks without + // any errors, but will cause a runtime panic. We statically know that int(0) does not + // implement that interface, thus we skip the devirtualization, as it is not possible + // to make an assertion: any(0).(interface{A()}).(int) (int does not implement interface{A()}). + if !typecheck.Implements(typ, sel.X.Type()) { + return + } + } else { + r := ir.StaticValue(sel.X) + if r.Op() != ir.OCONVIFACE { + return + } + recv := r.(*ir.ConvExpr) + typ = recv.X.Type() + if typ.IsInterface() { + return + } + } + + // If typ is a shape type, then it was a type argument originally + // and we'd need an indirect call through the dictionary anyway. + // We're unable to devirtualize this call. + if typ.IsShape() { + return + } + + // If typ *has* a shape type, then it's a shaped, instantiated + // type like T[go.shape.int], and its methods (may) have an extra + // dictionary parameter. We could devirtualize this call if we + // could derive an appropriate dictionary argument. + // + // TODO(mdempsky): If typ has a promoted non-generic method, + // then that method won't require a dictionary argument. We could + // still devirtualize those calls. + // + // TODO(mdempsky): We have the *runtime.itab in recv.TypeWord. It + // should be possible to compute the represented type's runtime + // dictionary from this (e.g., by adding a pointer from T[int]'s + // *runtime._type to .dict.T[int]; or by recognizing static + // references to go:itab.T[int],iface and constructing a direct + // reference to .dict.T[int]). + if typ.HasShape() { + if base.Flag.LowerM != 0 { + base.WarnfAt(call.Pos(), "cannot devirtualize %v: shaped receiver %v", call, typ) + } + return + } + + // Further, if sel.X's type has a shape type, then it's a shaped + // interface type. In this case, the (non-dynamic) TypeAssertExpr + // we construct below would attempt to create an itab + // corresponding to this shaped interface type; but the actual + // itab pointer in the interface value will correspond to the + // original (non-shaped) interface type instead. These are + // functionally equivalent, but they have distinct pointer + // identities, which leads to the type assertion failing. + // + // TODO(mdempsky): We know the type assertion here is safe, so we + // could instead set a flag so that walk skips the itab check. For + // now, punting is easy and safe. + if sel.X.Type().HasShape() { + if base.Flag.LowerM != 0 { + base.WarnfAt(call.Pos(), "cannot devirtualize %v: shaped interface %v", call, sel.X.Type()) + } + return + } + + dt := ir.NewTypeAssertExpr(sel.Pos(), sel.X, typ) + + if go126ImprovedConcreteTypeAnalysis { + // Consider: + // + // var v Iface + // v.A() + // v = &Impl{} + // + // Here in the devirtualizer, we determine the concrete type of v as being an *Impl, + // but it can still be a nil interface, we have not detected that. The v.(*Impl) + // type assertion that we make here would also have failed, but with a different + // panic "pkg.Iface is nil, not *pkg.Impl", where previously we would get a nil panic. + // We fix this, by introducing an additional nilcheck on the itab. + // Calling a method on a nil interface (in most cases) is a bug in a program, so it is fine + // to devirtualize and further (possibly) inline them, even though we would never reach + // the called function. + dt.UseNilPanic = true + dt.SetPos(call.Pos()) + } + + x := typecheck.XDotMethod(sel.Pos(), dt, sel.Sel, true) + switch x.Op() { + case ir.ODOTMETH: + if base.Flag.LowerM != 0 { + base.WarnfAt(call.Pos(), "devirtualizing %v to %v", sel, typ) + } + call.SetOp(ir.OCALLMETH) + call.Fun = x + case ir.ODOTINTER: + // Promoted method from embedded interface-typed field (#42279). + if base.Flag.LowerM != 0 { + base.WarnfAt(call.Pos(), "partially devirtualizing %v to %v", sel, typ) + } + call.SetOp(ir.OCALLINTER) + call.Fun = x + default: + base.FatalfAt(call.Pos(), "failed to devirtualize %v (%v)", x, x.Op()) + } + + // Duplicated logic from typecheck for function call return + // value types. + // + // Receiver parameter size may have changed; need to update + // call.Type to get correct stack offsets for result + // parameters. + types.CheckSize(x.Type()) + switch ft := x.Type(); ft.NumResults() { + case 0: + case 1: + call.SetType(ft.Result(0).Type) + default: + call.SetType(ft.ResultsTuple()) + } + + // Desugar OCALLMETH, if we created one (#57309). + typecheck.FixMethodCall(call) +} + +const concreteTypeDebug = false + +// concreteType determines the concrete type of n, following OCONVIFACEs and type asserts. +// Returns nil when the concrete type could not be determined, or when there are multiple +// (different) types assigned to an interface. +func concreteType(s *State, n ir.Node) (typ *types.Type) { + typ = concreteType1(s, n, make(map[*ir.Name]struct{})) + if typ == &noType { + return nil + } + if typ != nil && typ.IsInterface() { + base.FatalfAt(n.Pos(), "typ.IsInterface() = true; want = false; typ = %v", typ) + } + return typ +} + +// noType is a sentinel value returned by [concreteType1]. +var noType types.Type + +// concreteType1 analyzes the node n and returns its concrete type if it is statically known. +// Otherwise, it returns a nil Type, indicating that a concrete type was not determined. +// When n is known to be statically nil or a self-assignment is detected, it returns a sentinel [noType] type instead. +func concreteType1(s *State, n ir.Node, seen map[*ir.Name]struct{}) (outT *types.Type) { + nn := n // for debug messages + + if concreteTypeDebug { + defer func() { + t := "&noType" + if outT != &noType { + t = outT.String() + } + base.Warn("concreteType1(%v) -> %v", nn, t) + }() + } + + for { + if concreteTypeDebug { + base.Warn("concreteType1(%v): analyzing %v", nn, n) + } + + if !n.Type().IsInterface() { + return n.Type() + } + + switch n1 := n.(type) { + case *ir.ConvExpr: + if n1.Op() == ir.OCONVNOP { + if !n1.Type().IsInterface() || !types.Identical(n1.Type().Underlying(), n1.X.Type().Underlying()) { + // As we check (directly before this switch) whether n is an interface, thus we should only reach + // here for iface conversions where both operands are the same. + base.FatalfAt(n1.Pos(), "not identical/interface types found n1.Type = %v; n1.X.Type = %v", n1.Type(), n1.X.Type()) + } + n = n1.X + continue + } + if n1.Op() == ir.OCONVIFACE { + n = n1.X + continue + } + case *ir.InlinedCallExpr: + if n1.Op() == ir.OINLCALL { + n = n1.SingleResult() + continue + } + case *ir.ParenExpr: + n = n1.X + continue + case *ir.TypeAssertExpr: + n = n1.X + continue + } + break + } + + if n.Op() != ir.ONAME { + return nil + } + + name := n.(*ir.Name).Canonical() + if name.Class != ir.PAUTO { + return nil + } + + if name.Op() != ir.ONAME { + base.FatalfAt(name.Pos(), "name.Op = %v; want = ONAME", n.Op()) + } + + // name.Curfn must be set, as we checked name.Class != ir.PAUTO before. + if name.Curfn == nil { + base.FatalfAt(name.Pos(), "name.Curfn = nil; want not nil") + } + + if name.Addrtaken() { + return nil // conservatively assume it's reassigned with a different type indirectly + } + + if _, ok := seen[name]; ok { + return &noType // Already analyzed assignments to name, no need to do that twice. + } + seen[name] = struct{}{} + + if concreteTypeDebug { + base.Warn("concreteType1(%v): analyzing assignments to %v", nn, name) + } + + var typ *types.Type + for _, v := range s.assignments(name) { + var t *types.Type + switch v := v.(type) { + case *types.Type: + t = v + case ir.Node: + t = concreteType1(s, v, seen) + if t == &noType { + continue + } + } + if t == nil { + return nil // unknown concrete type + } + + // Methods are only declared on named types, and each named type + // is represented by a unique [*types.Type], thus pointer comparison + // is fine here. + // + // The only scenario where [types.IdenticalStrict] could help here is with + // unnamed struct types that embed another type (e.g. foo = struct { Impl }{}). + // However, such patterns are uncommon and not worth the additional complexity + // in the devirtualizer. + if typ != nil && typ != t { + return nil // assigned with a different type + } + + typ = t + } + + if typ == nil { + // Variable either declared with zero value, or only assigned with nil. + return &noType + } + + return typ +} + +// assignment can be one of: +// - nil - assignment from an interface type. +// - *types.Type - assignment from a concrete type (non-interface). +// - ir.Node - assignment from an ir.Node. +// +// In most cases assignment should be an [ir.Node], but in cases where we +// do not follow the data-flow, we return either a concrete type (*types.Type) or a nil. +// For example in range over a slice, if the slice elem is of an interface type, then we return +// a nil, otherwise the elem's concrete type (We do so because we do not analyze assignment to the +// slice being ranged-over). +type assignment any + +// State holds precomputed state for use in [StaticCall]. +type State struct { + // ifaceAssignments maps interface variables to all their assignments + // defined inside functions stored in the analyzedFuncs set. + // Note: it does not include direct assignments to nil. + ifaceAssignments map[*ir.Name][]assignment + + // ifaceCallExprAssigns stores every [*ir.CallExpr], which has an interface + // result, that is assigned to a variable. + ifaceCallExprAssigns map[*ir.CallExpr][]ifaceAssignRef + + // analyzedFuncs is a set of Funcs that were analyzed for iface assignments. + analyzedFuncs map[*ir.Func]struct{} +} + +type ifaceAssignRef struct { + name *ir.Name // ifaceAssignments[name] + assignmentIndex int // ifaceAssignments[name][assignmentIndex] + returnIndex int // (*ir.CallExpr).Result(returnIndex) +} + +// InlinedCall updates the [State] to take into account a newly inlined call. +func (s *State) InlinedCall(fun *ir.Func, origCall *ir.CallExpr, inlinedCall *ir.InlinedCallExpr) { + if _, ok := s.analyzedFuncs[fun]; !ok { + // Full analyze has not been yet executed for the provided function, so we can skip it for now. + // When no devirtualization happens in a function, it is unnecessary to analyze it. + return + } + + // Analyze assignments in the newly inlined function. + s.analyze(inlinedCall.Init()) + s.analyze(inlinedCall.Body) + + refs, ok := s.ifaceCallExprAssigns[origCall] + if !ok { + return + } + delete(s.ifaceCallExprAssigns, origCall) + + // Update assignments to reference the new ReturnVars of the inlined call. + for _, ref := range refs { + vt := &s.ifaceAssignments[ref.name][ref.assignmentIndex] + if *vt != nil { + base.Fatalf("unexpected non-nil assignment") + } + if concreteTypeDebug { + base.Warn( + "InlinedCall(%v, %v): replacing interface node in (%v,%v) to %v (typ %v)", + origCall, inlinedCall, ref.name, ref.assignmentIndex, + inlinedCall.ReturnVars[ref.returnIndex], + inlinedCall.ReturnVars[ref.returnIndex].Type(), + ) + } + + // Update ifaceAssignments with an ir.Node from the inlined function’s ReturnVars. + // This may enable future devirtualization of calls that reference ref.name. + // We will get calls to [StaticCall] from the interleaved package, + // to try devirtualize such calls afterwards. + *vt = inlinedCall.ReturnVars[ref.returnIndex] + } +} + +// assignments returns all assignments to n. +func (s *State) assignments(n *ir.Name) []assignment { + fun := n.Curfn + if fun == nil { + base.FatalfAt(n.Pos(), "n.Curfn = ") + } + if n.Class != ir.PAUTO { + base.FatalfAt(n.Pos(), "n.Class = %v; want = PAUTO", n.Class) + } + + if !n.Type().IsInterface() { + base.FatalfAt(n.Pos(), "name passed to assignments is not of an interface type: %v", n.Type()) + } + + // Analyze assignments in func, if not analyzed before. + if _, ok := s.analyzedFuncs[fun]; !ok { + if concreteTypeDebug { + base.Warn("assignments(): analyzing assignments in %v func", fun) + } + if s.analyzedFuncs == nil { + s.ifaceAssignments = make(map[*ir.Name][]assignment) + s.ifaceCallExprAssigns = make(map[*ir.CallExpr][]ifaceAssignRef) + s.analyzedFuncs = make(map[*ir.Func]struct{}) + } + s.analyzedFuncs[fun] = struct{}{} + s.analyze(fun.Init()) + s.analyze(fun.Body) + } + + return s.ifaceAssignments[n] +} + +// analyze analyzes every assignment to interface variables in nodes, updating [State]. +func (s *State) analyze(nodes ir.Nodes) { + assign := func(name ir.Node, assignment assignment) (*ir.Name, int) { + if name == nil || name.Op() != ir.ONAME || ir.IsBlank(name) { + return nil, -1 + } + + n, ok := ir.OuterValue(name).(*ir.Name) + if !ok || n.Curfn == nil { + return nil, -1 + } + + // Do not track variables that are not of interface types. + // For devirtualization they are unnecessary, we will not even look them up. + if !n.Type().IsInterface() { + return nil, -1 + } + + n = n.Canonical() + if n.Op() != ir.ONAME { + base.FatalfAt(n.Pos(), "n.Op = %v; want = ONAME", n.Op()) + } + if n.Class != ir.PAUTO { + return nil, -1 + } + + switch a := assignment.(type) { + case nil: + case *types.Type: + if a != nil && a.IsInterface() { + assignment = nil // non-concrete type + } + case ir.Node: + // nil assignment, we can safely ignore them, see [StaticCall]. + if ir.IsNil(a) { + return nil, -1 + } + default: + base.Fatalf("unexpected type: %v", assignment) + } + + if concreteTypeDebug { + base.Warn("analyze(): assignment found %v = %v", name, assignment) + } + + s.ifaceAssignments[n] = append(s.ifaceAssignments[n], assignment) + return n, len(s.ifaceAssignments[n]) - 1 + } + + var do func(n ir.Node) + do = func(n ir.Node) { + switch n.Op() { + case ir.OAS: + n := n.(*ir.AssignStmt) + if rhs := n.Y; rhs != nil { + for { + if r, ok := rhs.(*ir.ParenExpr); ok { + rhs = r.X + continue + } + break + } + if call, ok := rhs.(*ir.CallExpr); ok && call.Fun != nil { + retTyp := call.Fun.Type().Results()[0].Type + n, idx := assign(n.X, retTyp) + if n != nil && retTyp.IsInterface() { + // We have a call expression, that returns an interface, store it for later evaluation. + // In case this func gets inlined later, we will update the assignment (added before) + // with a reference to ReturnVars, see [State.InlinedCall], which might allow for future devirtualizing of n.X. + s.ifaceCallExprAssigns[call] = append(s.ifaceCallExprAssigns[call], ifaceAssignRef{n, idx, 0}) + } + } else { + assign(n.X, rhs) + } + } + case ir.OAS2: + n := n.(*ir.AssignListStmt) + for i, p := range n.Lhs { + if n.Rhs[i] != nil { + assign(p, n.Rhs[i]) + } + } + case ir.OAS2DOTTYPE: + n := n.(*ir.AssignListStmt) + if n.Rhs[0] == nil { + base.FatalfAt(n.Pos(), "n.Rhs[0] == nil; n = %v", n) + } + assign(n.Lhs[0], n.Rhs[0]) + assign(n.Lhs[1], nil) // boolean does not have methods to devirtualize + case ir.OAS2MAPR, ir.OAS2RECV, ir.OSELRECV2: + n := n.(*ir.AssignListStmt) + if n.Rhs[0] == nil { + base.FatalfAt(n.Pos(), "n.Rhs[0] == nil; n = %v", n) + } + assign(n.Lhs[0], n.Rhs[0].Type()) + assign(n.Lhs[1], nil) // boolean does not have methods to devirtualize + case ir.OAS2FUNC: + n := n.(*ir.AssignListStmt) + rhs := n.Rhs[0] + for { + if r, ok := rhs.(*ir.ParenExpr); ok { + rhs = r.X + continue + } + break + } + if call, ok := rhs.(*ir.CallExpr); ok { + for i, p := range n.Lhs { + retTyp := call.Fun.Type().Results()[i].Type + n, idx := assign(p, retTyp) + if n != nil && retTyp.IsInterface() { + // We have a call expression, that returns an interface, store it for later evaluation. + // In case this func gets inlined later, we will update the assignment (added before) + // with a reference to ReturnVars, see [State.InlinedCall], which might allow for future devirtualizing of n.X. + s.ifaceCallExprAssigns[call] = append(s.ifaceCallExprAssigns[call], ifaceAssignRef{n, idx, i}) + } + } + } else if call, ok := rhs.(*ir.InlinedCallExpr); ok { + for i, p := range n.Lhs { + assign(p, call.ReturnVars[i]) + } + } else { + base.FatalfAt(n.Pos(), "unexpected type %T in OAS2FUNC Rhs[0]", call) + } + case ir.ORANGE: + n := n.(*ir.RangeStmt) + xTyp := n.X.Type() + + // Range over an array pointer. + if xTyp.IsPtr() && xTyp.Elem().IsArray() { + xTyp = xTyp.Elem() + } + + if xTyp.IsArray() || xTyp.IsSlice() { + assign(n.Key, nil) // integer does not have methods to devirtualize + assign(n.Value, xTyp.Elem()) + } else if xTyp.IsChan() { + assign(n.Key, xTyp.Elem()) + base.AssertfAt(n.Value == nil, n.Pos(), "n.Value != nil in range over chan") + } else if xTyp.IsMap() { + assign(n.Key, xTyp.Key()) + assign(n.Value, xTyp.Elem()) + } else if xTyp.IsInteger() || xTyp.IsString() { + // Range over int/string, results do not have methods, so nothing to devirtualize. + assign(n.Key, nil) + assign(n.Value, nil) + } else { + // We will not reach here in case of a range-over-func, as it is + // rewritten to function calls in the noder package. + base.FatalfAt(n.Pos(), "range over unexpected type %v", n.X.Type()) + } + case ir.OSWITCH: + n := n.(*ir.SwitchStmt) + if guard, ok := n.Tag.(*ir.TypeSwitchGuard); ok { + for _, v := range n.Cases { + if v.Var == nil { + base.Assert(guard.Tag == nil) + continue + } + assign(v.Var, guard.X) + } + } + case ir.OCLOSURE: + n := n.(*ir.ClosureExpr) + if _, ok := s.analyzedFuncs[n.Func]; !ok { + s.analyzedFuncs[n.Func] = struct{}{} + ir.Visit(n.Func, do) + } + } + } + ir.VisitList(nodes, do) +} diff --git a/go/src/cmd/compile/internal/devirtualize/pgo.go b/go/src/cmd/compile/internal/devirtualize/pgo.go new file mode 100644 index 0000000000000000000000000000000000000000..a8980bb86b1547447b85986b9d1132359e042928 --- /dev/null +++ b/go/src/cmd/compile/internal/devirtualize/pgo.go @@ -0,0 +1,829 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package devirtualize + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/inline" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/pgoir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" + "encoding/json" + "fmt" + "os" + "strings" +) + +// CallStat summarizes a single call site. +// +// This is used only for debug logging. +type CallStat struct { + Pkg string // base.Ctxt.Pkgpath + Pos string // file:line:col of call. + + Caller string // Linker symbol name of calling function. + + // Direct or indirect call. + Direct bool + + // For indirect calls, interface call or other indirect function call. + Interface bool + + // Total edge weight from this call site. + Weight int64 + + // Hottest callee from this call site, regardless of type + // compatibility. + Hottest string + HottestWeight int64 + + // Devirtualized callee if != "". + // + // Note that this may be different than Hottest because we apply + // type-check restrictions, which helps distinguish multiple calls on + // the same line. + Devirtualized string + DevirtualizedWeight int64 +} + +// ProfileGuided performs call devirtualization of indirect calls based on +// profile information. +// +// Specifically, it performs conditional devirtualization of interface calls or +// function value calls for the hottest callee. +// +// That is, for interface calls it performs a transformation like: +// +// type Iface interface { +// Foo() +// } +// +// type Concrete struct{} +// +// func (Concrete) Foo() {} +// +// func foo(i Iface) { +// i.Foo() +// } +// +// to: +// +// func foo(i Iface) { +// if c, ok := i.(Concrete); ok { +// c.Foo() +// } else { +// i.Foo() +// } +// } +// +// For function value calls it performs a transformation like: +// +// func Concrete() {} +// +// func foo(fn func()) { +// fn() +// } +// +// to: +// +// func foo(fn func()) { +// if internal/abi.FuncPCABIInternal(fn) == internal/abi.FuncPCABIInternal(Concrete) { +// Concrete() +// } else { +// fn() +// } +// } +// +// The primary benefit of this transformation is enabling inlining of the +// direct call. +func ProfileGuided(fn *ir.Func, p *pgoir.Profile) { + ir.CurFunc = fn + + name := ir.LinkFuncName(fn) + + var jsonW *json.Encoder + if base.Debug.PGODebug >= 3 { + jsonW = json.NewEncoder(os.Stdout) + } + + var edit func(n ir.Node) ir.Node + edit = func(n ir.Node) ir.Node { + if n == nil { + return n + } + + ir.EditChildren(n, edit) + + call, ok := n.(*ir.CallExpr) + if !ok { + return n + } + + var stat *CallStat + if base.Debug.PGODebug >= 3 { + // Statistics about every single call. Handy for external data analysis. + // + // TODO(prattmic): Log via logopt? + stat = constructCallStat(p, fn, name, call) + if stat != nil { + defer func() { + jsonW.Encode(&stat) + }() + } + } + + op := call.Op() + if op != ir.OCALLFUNC && op != ir.OCALLINTER { + return n + } + + if base.Debug.PGODebug >= 2 { + fmt.Printf("%v: PGO devirtualize considering call %v\n", ir.Line(call), call) + } + + if call.GoDefer { + if base.Debug.PGODebug >= 2 { + fmt.Printf("%v: can't PGO devirtualize go/defer call %v\n", ir.Line(call), call) + } + return n + } + + var newNode ir.Node + var callee *ir.Func + var weight int64 + switch op { + case ir.OCALLFUNC: + newNode, callee, weight = maybeDevirtualizeFunctionCall(p, fn, call) + case ir.OCALLINTER: + newNode, callee, weight = maybeDevirtualizeInterfaceCall(p, fn, call) + default: + panic("unreachable") + } + + if newNode == nil { + return n + } + + if stat != nil { + stat.Devirtualized = ir.LinkFuncName(callee) + stat.DevirtualizedWeight = weight + } + + return newNode + } + + ir.EditChildren(fn, edit) +} + +// Devirtualize interface call if possible and eligible. Returns the new +// ir.Node if call was devirtualized, and if so also the callee and weight of +// the devirtualized edge. +func maybeDevirtualizeInterfaceCall(p *pgoir.Profile, fn *ir.Func, call *ir.CallExpr) (ir.Node, *ir.Func, int64) { + if base.Debug.PGODevirtualize < 1 { + return nil, nil, 0 + } + + // Bail if we do not have a hot callee. + callee, weight := findHotConcreteInterfaceCallee(p, fn, call) + if callee == nil { + return nil, nil, 0 + } + // Bail if we do not have a Type node for the hot callee. + ctyp := methodRecvType(callee) + if ctyp == nil { + return nil, nil, 0 + } + // Bail if we know for sure it won't inline. + if !shouldPGODevirt(callee) { + return nil, nil, 0 + } + // Bail if de-selected by PGO Hash. + if !base.PGOHash.MatchPosWithInfo(call.Pos(), "devirt", nil) { + return nil, nil, 0 + } + + return rewriteInterfaceCall(call, fn, callee, ctyp), callee, weight +} + +// Devirtualize an indirect function call if possible and eligible. Returns the new +// ir.Node if call was devirtualized, and if so also the callee and weight of +// the devirtualized edge. +func maybeDevirtualizeFunctionCall(p *pgoir.Profile, fn *ir.Func, call *ir.CallExpr) (ir.Node, *ir.Func, int64) { + if base.Debug.PGODevirtualize < 2 { + return nil, nil, 0 + } + + // Bail if this is a direct call; no devirtualization necessary. + callee := pgoir.DirectCallee(call.Fun) + if callee != nil { + return nil, nil, 0 + } + + // Bail if we do not have a hot callee. + callee, weight := findHotConcreteFunctionCallee(p, fn, call) + if callee == nil { + return nil, nil, 0 + } + + // TODO(go.dev/issue/61577): Closures need the closure context passed + // via the context register. That requires extra plumbing that we + // haven't done yet. + if callee.OClosure != nil { + if base.Debug.PGODebug >= 3 { + fmt.Printf("callee %s is a closure, skipping\n", ir.FuncName(callee)) + } + return nil, nil, 0 + } + // runtime.memhash_varlen does not look like a closure, but it uses + // internal/runtime/sys.GetClosurePtr to access data encoded by + // callers, which are generated by + // cmd/compile/internal/reflectdata.genhash. + if callee.Sym().Pkg.Path == "runtime" && callee.Sym().Name == "memhash_varlen" { + if base.Debug.PGODebug >= 3 { + fmt.Printf("callee %s is a closure (runtime.memhash_varlen), skipping\n", ir.FuncName(callee)) + } + return nil, nil, 0 + } + // TODO(prattmic): We don't properly handle methods as callees in two + // different dimensions: + // + // 1. Method expressions. e.g., + // + // var fn func(*os.File, []byte) (int, error) = (*os.File).Read + // + // In this case, typ will report *os.File as the receiver while + // ctyp reports it as the first argument. types.Identical ignores + // receiver parameters, so it treats these as different, even though + // they are still call compatible. + // + // 2. Method values. e.g., + // + // var f *os.File + // var fn func([]byte) (int, error) = f.Read + // + // types.Identical will treat these as compatible (since receiver + // parameters are ignored). However, in this case, we do not call + // (*os.File).Read directly. Instead, f is stored in closure context + // and we call the wrapper (*os.File).Read-fm. However, runtime/pprof + // hides wrappers from profiles, making it appear that there is a call + // directly to the method. We could recognize this pattern return the + // wrapper rather than the method. + // + // N.B. perf profiles will report wrapper symbols directly, so + // ideally we should support direct wrapper references as well. + if callee.Type().Recv() != nil { + if base.Debug.PGODebug >= 3 { + fmt.Printf("callee %s is a method, skipping\n", ir.FuncName(callee)) + } + return nil, nil, 0 + } + + // Bail if we know for sure it won't inline. + if !shouldPGODevirt(callee) { + return nil, nil, 0 + } + // Bail if de-selected by PGO Hash. + if !base.PGOHash.MatchPosWithInfo(call.Pos(), "devirt", nil) { + return nil, nil, 0 + } + + return rewriteFunctionCall(call, fn, callee), callee, weight +} + +// shouldPGODevirt checks if we should perform PGO devirtualization to the +// target function. +// +// PGO devirtualization is most valuable when the callee is inlined, so if it +// won't inline we can skip devirtualizing. +func shouldPGODevirt(fn *ir.Func) bool { + var reason string + if base.Flag.LowerM > 1 || logopt.Enabled() { + defer func() { + if reason != "" { + if base.Flag.LowerM > 1 { + fmt.Printf("%v: should not PGO devirtualize %v: %s\n", ir.Line(fn), ir.FuncName(fn), reason) + } + if logopt.Enabled() { + logopt.LogOpt(fn.Pos(), ": should not PGO devirtualize function", "pgoir-devirtualize", ir.FuncName(fn), reason) + } + } + }() + } + + reason = inline.InlineImpossible(fn) + if reason != "" { + return false + } + + // TODO(prattmic): checking only InlineImpossible is very conservative, + // primarily excluding only functions with pragmas. We probably want to + // move in either direction. Either: + // + // 1. Don't even bother to check InlineImpossible, as it affects so few + // functions. + // + // 2. Or consider the function body (notably cost) to better determine + // if the function will actually inline. + + return true +} + +// constructCallStat builds an initial CallStat describing this call, for +// logging. If the call is devirtualized, the devirtualization fields should be +// updated. +func constructCallStat(p *pgoir.Profile, fn *ir.Func, name string, call *ir.CallExpr) *CallStat { + switch call.Op() { + case ir.OCALLFUNC, ir.OCALLINTER, ir.OCALLMETH: + default: + // We don't care about logging builtin functions. + return nil + } + + stat := CallStat{ + Pkg: base.Ctxt.Pkgpath, + Pos: ir.Line(call), + Caller: name, + } + + offset := pgoir.NodeLineOffset(call, fn) + + hotter := func(e *pgoir.IREdge) bool { + if stat.Hottest == "" { + return true + } + if e.Weight != stat.HottestWeight { + return e.Weight > stat.HottestWeight + } + // If weight is the same, arbitrarily sort lexicographally, as + // findHotConcreteCallee does. + return e.Dst.Name() < stat.Hottest + } + + callerNode := p.WeightedCG.IRNodes[name] + if callerNode == nil { + return nil + } + + // Sum of all edges from this callsite, regardless of callee. + // For direct calls, this should be the same as the single edge + // weight (except for multiple calls on one line, which we + // can't distinguish). + for _, edge := range callerNode.OutEdges { + if edge.CallSiteOffset != offset { + continue + } + stat.Weight += edge.Weight + if hotter(edge) { + stat.HottestWeight = edge.Weight + stat.Hottest = edge.Dst.Name() + } + } + + switch call.Op() { + case ir.OCALLFUNC: + stat.Interface = false + + callee := pgoir.DirectCallee(call.Fun) + if callee != nil { + stat.Direct = true + if stat.Hottest == "" { + stat.Hottest = ir.LinkFuncName(callee) + } + } else { + stat.Direct = false + } + case ir.OCALLINTER: + stat.Direct = false + stat.Interface = true + case ir.OCALLMETH: + base.FatalfAt(call.Pos(), "OCALLMETH missed by typecheck") + } + + return &stat +} + +// copyInputs copies the inputs to a call: the receiver (for interface calls) +// or function value (for function value calls) and the arguments. These +// expressions are evaluated once and assigned to temporaries. +// +// The assignment statement is added to init and the copied receiver/fn +// expression and copied arguments expressions are returned. +func copyInputs(curfn *ir.Func, pos src.XPos, recvOrFn ir.Node, args []ir.Node, init *ir.Nodes) (ir.Node, []ir.Node) { + // Evaluate receiver/fn and argument expressions. The receiver/fn is + // used twice but we don't want to cause side effects twice. The + // arguments are used in two different calls and we can't trivially + // copy them. + // + // recvOrFn must be first in the assignment list as its side effects + // must be ordered before argument side effects. + var lhs, rhs []ir.Node + newRecvOrFn := typecheck.TempAt(pos, curfn, recvOrFn.Type()) + lhs = append(lhs, newRecvOrFn) + rhs = append(rhs, recvOrFn) + + for _, arg := range args { + argvar := typecheck.TempAt(pos, curfn, arg.Type()) + + lhs = append(lhs, argvar) + rhs = append(rhs, arg) + } + + asList := ir.NewAssignListStmt(pos, ir.OAS2, lhs, rhs) + init.Append(typecheck.Stmt(asList)) + + return newRecvOrFn, lhs[1:] +} + +// retTemps returns a slice of temporaries to be used for storing result values from call. +func retTemps(curfn *ir.Func, pos src.XPos, call *ir.CallExpr) []ir.Node { + sig := call.Fun.Type() + var retvars []ir.Node + for _, ret := range sig.Results() { + retvars = append(retvars, typecheck.TempAt(pos, curfn, ret.Type)) + } + return retvars +} + +// condCall returns an ir.InlinedCallExpr that performs a call to thenCall if +// cond is true and elseCall if cond is false. The return variables of the +// InlinedCallExpr evaluate to the return values from the call. +func condCall(curfn *ir.Func, pos src.XPos, cond ir.Node, thenCall, elseCall *ir.CallExpr, init ir.Nodes) *ir.InlinedCallExpr { + // Doesn't matter whether we use thenCall or elseCall, they must have + // the same return types. + retvars := retTemps(curfn, pos, thenCall) + + var thenBlock, elseBlock ir.Nodes + if len(retvars) == 0 { + thenBlock.Append(thenCall) + elseBlock.Append(elseCall) + } else { + // Copy slice so edits in one location don't affect another. + thenRet := append([]ir.Node(nil), retvars...) + thenAsList := ir.NewAssignListStmt(pos, ir.OAS2, thenRet, []ir.Node{thenCall}) + thenBlock.Append(typecheck.Stmt(thenAsList)) + + elseRet := append([]ir.Node(nil), retvars...) + elseAsList := ir.NewAssignListStmt(pos, ir.OAS2, elseRet, []ir.Node{elseCall}) + elseBlock.Append(typecheck.Stmt(elseAsList)) + } + + nif := ir.NewIfStmt(pos, cond, thenBlock, elseBlock) + nif.SetInit(init) + nif.Likely = true + + body := []ir.Node{typecheck.Stmt(nif)} + + // This isn't really an inlined call of course, but InlinedCallExpr + // makes handling reassignment of return values easier. + res := ir.NewInlinedCallExpr(pos, body, retvars) + res.SetType(thenCall.Type()) + res.SetTypecheck(1) + return res +} + +// rewriteInterfaceCall devirtualizes the given interface call using a direct +// method call to concretetyp. +func rewriteInterfaceCall(call *ir.CallExpr, curfn, callee *ir.Func, concretetyp *types.Type) ir.Node { + if base.Flag.LowerM != 0 { + fmt.Printf("%v: PGO devirtualizing interface call %v to %v\n", ir.Line(call), call.Fun, callee) + } + + // We generate an OINCALL of: + // + // var recv Iface + // + // var arg1 A1 + // var argN AN + // + // var ret1 R1 + // var retN RN + // + // recv, arg1, argN = recv expr, arg1 expr, argN expr + // + // t, ok := recv.(Concrete) + // if ok { + // ret1, retN = t.Method(arg1, ... argN) + // } else { + // ret1, retN = recv.Method(arg1, ... argN) + // } + // + // OINCALL retvars: ret1, ... retN + // + // This isn't really an inlined call of course, but InlinedCallExpr + // makes handling reassignment of return values easier. + // + // TODO(prattmic): This increases the size of the AST in the caller, + // making it less like to inline. We may want to compensate for this + // somehow. + + sel := call.Fun.(*ir.SelectorExpr) + method := sel.Sel + pos := call.Pos() + init := ir.TakeInit(call) + + recv, args := copyInputs(curfn, pos, sel.X, call.Args.Take(), &init) + + // Copy slice so edits in one location don't affect another. + argvars := append([]ir.Node(nil), args...) + call.Args = argvars + + tmpnode := typecheck.TempAt(base.Pos, curfn, concretetyp) + tmpok := typecheck.TempAt(base.Pos, curfn, types.Types[types.TBOOL]) + + assert := ir.NewTypeAssertExpr(pos, recv, concretetyp) + + assertAsList := ir.NewAssignListStmt(pos, ir.OAS2, []ir.Node{tmpnode, tmpok}, []ir.Node{typecheck.Expr(assert)}) + init.Append(typecheck.Stmt(assertAsList)) + + concreteCallee := typecheck.XDotMethod(pos, tmpnode, method, true) + // Copy slice so edits in one location don't affect another. + argvars = append([]ir.Node(nil), argvars...) + concreteCall := typecheck.Call(pos, concreteCallee, argvars, call.IsDDD).(*ir.CallExpr) + + res := condCall(curfn, pos, tmpok, concreteCall, call, init) + + if base.Debug.PGODebug >= 3 { + fmt.Printf("PGO devirtualizing interface call to %+v. After: %+v\n", concretetyp, res) + } + + return res +} + +// rewriteFunctionCall devirtualizes the given OCALLFUNC using a direct +// function call to callee. +func rewriteFunctionCall(call *ir.CallExpr, curfn, callee *ir.Func) ir.Node { + if base.Flag.LowerM != 0 { + fmt.Printf("%v: PGO devirtualizing function call %v to %v\n", ir.Line(call), call.Fun, callee) + } + + // We generate an OINCALL of: + // + // var fn FuncType + // + // var arg1 A1 + // var argN AN + // + // var ret1 R1 + // var retN RN + // + // fn, arg1, argN = fn expr, arg1 expr, argN expr + // + // fnPC := internal/abi.FuncPCABIInternal(fn) + // concretePC := internal/abi.FuncPCABIInternal(concrete) + // + // if fnPC == concretePC { + // ret1, retN = concrete(arg1, ... argN) // Same closure context passed (TODO) + // } else { + // ret1, retN = fn(arg1, ... argN) + // } + // + // OINCALL retvars: ret1, ... retN + // + // This isn't really an inlined call of course, but InlinedCallExpr + // makes handling reassignment of return values easier. + + pos := call.Pos() + init := ir.TakeInit(call) + + fn, args := copyInputs(curfn, pos, call.Fun, call.Args.Take(), &init) + + // Copy slice so edits in one location don't affect another. + argvars := append([]ir.Node(nil), args...) + call.Args = argvars + + // FuncPCABIInternal takes an interface{}, emulate that. This is needed + // for to ensure we get the MAKEFACE we need for SSA. + fnIface := typecheck.Expr(ir.NewConvExpr(pos, ir.OCONV, types.Types[types.TINTER], fn)) + calleeIface := typecheck.Expr(ir.NewConvExpr(pos, ir.OCONV, types.Types[types.TINTER], callee.Nname)) + + fnPC := ir.FuncPC(pos, fnIface, obj.ABIInternal) + concretePC := ir.FuncPC(pos, calleeIface, obj.ABIInternal) + + pcEq := typecheck.Expr(ir.NewBinaryExpr(base.Pos, ir.OEQ, fnPC, concretePC)) + + // TODO(go.dev/issue/61577): Handle callees that a closures and need a + // copy of the closure context from call. For now, we skip callees that + // are closures in maybeDevirtualizeFunctionCall. + if callee.OClosure != nil { + base.Fatalf("Callee is a closure: %+v", callee) + } + + // Copy slice so edits in one location don't affect another. + argvars = append([]ir.Node(nil), argvars...) + concreteCall := typecheck.Call(pos, callee.Nname, argvars, call.IsDDD).(*ir.CallExpr) + + res := condCall(curfn, pos, pcEq, concreteCall, call, init) + + if base.Debug.PGODebug >= 3 { + fmt.Printf("PGO devirtualizing function call to %+v. After: %+v\n", ir.FuncName(callee), res) + } + + return res +} + +// methodRecvType returns the type containing method fn. Returns nil if fn +// is not a method. +func methodRecvType(fn *ir.Func) *types.Type { + recv := fn.Nname.Type().Recv() + if recv == nil { + return nil + } + return recv.Type +} + +// interfaceCallRecvTypeAndMethod returns the type and the method of the interface +// used in an interface call. +func interfaceCallRecvTypeAndMethod(call *ir.CallExpr) (*types.Type, *types.Sym) { + if call.Op() != ir.OCALLINTER { + base.Fatalf("Call isn't OCALLINTER: %+v", call) + } + + sel, ok := call.Fun.(*ir.SelectorExpr) + if !ok { + base.Fatalf("OCALLINTER doesn't contain SelectorExpr: %+v", call) + } + + return sel.X.Type(), sel.Sel +} + +// findHotConcreteCallee returns the *ir.Func of the hottest callee of a call, +// if available, and its edge weight. extraFn can perform additional +// applicability checks on each candidate edge. If extraFn returns false, +// candidate will not be considered a valid callee candidate. +func findHotConcreteCallee(p *pgoir.Profile, caller *ir.Func, call *ir.CallExpr, extraFn func(callerName string, callOffset int, candidate *pgoir.IREdge) bool) (*ir.Func, int64) { + callerName := ir.LinkFuncName(caller) + callerNode := p.WeightedCG.IRNodes[callerName] + callOffset := pgoir.NodeLineOffset(call, caller) + + if callerNode == nil { + return nil, 0 + } + + var hottest *pgoir.IREdge + + // Returns true if e is hotter than hottest. + // + // Naively this is just e.Weight > hottest.Weight, but because OutEdges + // has arbitrary iteration order, we need to apply additional sort + // criteria when e.Weight == hottest.Weight to ensure we have stable + // selection. + hotter := func(e *pgoir.IREdge) bool { + if hottest == nil { + return true + } + if e.Weight != hottest.Weight { + return e.Weight > hottest.Weight + } + + // Now e.Weight == hottest.Weight, we must select on other + // criteria. + + // If only one edge has IR, prefer that one. + if (hottest.Dst.AST == nil) != (e.Dst.AST == nil) { + if e.Dst.AST != nil { + return true + } + return false + } + + // Arbitrary, but the callee names will always differ. Select + // the lexicographically first callee. + return e.Dst.Name() < hottest.Dst.Name() + } + + for _, e := range callerNode.OutEdges { + if e.CallSiteOffset != callOffset { + continue + } + + if !hotter(e) { + // TODO(prattmic): consider total caller weight? i.e., + // if the hottest callee is only 10% of the weight, + // maybe don't devirtualize? Similarly, if this is call + // is globally very cold, there is not much value in + // devirtualizing. + if base.Debug.PGODebug >= 2 { + fmt.Printf("%v: edge %s:%d -> %s (weight %d): too cold (hottest %d)\n", ir.Line(call), callerName, callOffset, e.Dst.Name(), e.Weight, hottest.Weight) + } + continue + } + + if e.Dst.AST == nil { + // Destination isn't visible from this package + // compilation. + // + // We must assume it implements the interface. + // + // We still record this as the hottest callee so far + // because we only want to return the #1 hottest + // callee. If we skip this then we'd return the #2 + // hottest callee. + if base.Debug.PGODebug >= 2 { + fmt.Printf("%v: edge %s:%d -> %s (weight %d) (missing IR): hottest so far\n", ir.Line(call), callerName, callOffset, e.Dst.Name(), e.Weight) + } + hottest = e + continue + } + + if extraFn != nil && !extraFn(callerName, callOffset, e) { + continue + } + + if base.Debug.PGODebug >= 2 { + fmt.Printf("%v: edge %s:%d -> %s (weight %d): hottest so far\n", ir.Line(call), callerName, callOffset, e.Dst.Name(), e.Weight) + } + hottest = e + } + + if hottest == nil || hottest.Weight == 0 { + if base.Debug.PGODebug >= 2 { + fmt.Printf("%v: call %s:%d: no hot callee\n", ir.Line(call), callerName, callOffset) + } + return nil, 0 + } + + if base.Debug.PGODebug >= 2 { + fmt.Printf("%v: call %s:%d: hottest callee %s (weight %d)\n", ir.Line(call), callerName, callOffset, hottest.Dst.Name(), hottest.Weight) + } + return hottest.Dst.AST, hottest.Weight +} + +// findHotConcreteInterfaceCallee returns the *ir.Func of the hottest callee of an +// interface call, if available, and its edge weight. +func findHotConcreteInterfaceCallee(p *pgoir.Profile, caller *ir.Func, call *ir.CallExpr) (*ir.Func, int64) { + inter, method := interfaceCallRecvTypeAndMethod(call) + + return findHotConcreteCallee(p, caller, call, func(callerName string, callOffset int, e *pgoir.IREdge) bool { + ctyp := methodRecvType(e.Dst.AST) + if ctyp == nil { + // Not a method. + // TODO(prattmic): Support non-interface indirect calls. + if base.Debug.PGODebug >= 2 { + fmt.Printf("%v: edge %s:%d -> %s (weight %d): callee not a method\n", ir.Line(call), callerName, callOffset, e.Dst.Name(), e.Weight) + } + return false + } + + // If ctyp doesn't implement inter it is most likely from a + // different call on the same line + if !typecheck.Implements(ctyp, inter) { + // TODO(prattmic): this is overly strict. Consider if + // ctyp is a partial implementation of an interface + // that gets embedded in types that complete the + // interface. It would still be OK to devirtualize a + // call to this method. + // + // What we'd need to do is check that the function + // pointer in the itab matches the method we want, + // rather than doing a full type assertion. + if base.Debug.PGODebug >= 2 { + why := typecheck.ImplementsExplain(ctyp, inter) + fmt.Printf("%v: edge %s:%d -> %s (weight %d): %v doesn't implement %v (%s)\n", ir.Line(call), callerName, callOffset, e.Dst.Name(), e.Weight, ctyp, inter, why) + } + return false + } + + // If the method name is different it is most likely from a + // different call on the same line + if !strings.HasSuffix(e.Dst.Name(), "."+method.Name) { + if base.Debug.PGODebug >= 2 { + fmt.Printf("%v: edge %s:%d -> %s (weight %d): callee is a different method\n", ir.Line(call), callerName, callOffset, e.Dst.Name(), e.Weight) + } + return false + } + + return true + }) +} + +// findHotConcreteFunctionCallee returns the *ir.Func of the hottest callee of an +// indirect function call, if available, and its edge weight. +func findHotConcreteFunctionCallee(p *pgoir.Profile, caller *ir.Func, call *ir.CallExpr) (*ir.Func, int64) { + typ := call.Fun.Type().Underlying() + + return findHotConcreteCallee(p, caller, call, func(callerName string, callOffset int, e *pgoir.IREdge) bool { + ctyp := e.Dst.AST.Type().Underlying() + + // If ctyp doesn't match typ it is most likely from a different + // call on the same line. + // + // Note that we are comparing underlying types, as different + // defined types are OK. e.g., a call to a value of type + // net/http.HandlerFunc can be devirtualized to a function with + // the same underlying type. + if !types.Identical(typ, ctyp) { + if base.Debug.PGODebug >= 2 { + fmt.Printf("%v: edge %s:%d -> %s (weight %d): %v doesn't match %v\n", ir.Line(call), callerName, callOffset, e.Dst.Name(), e.Weight, ctyp, typ) + } + return false + } + + return true + }) +} diff --git a/go/src/cmd/compile/internal/devirtualize/pgo_test.go b/go/src/cmd/compile/internal/devirtualize/pgo_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6153b8c5ec7043e4812875858d6089a0765ca489 --- /dev/null +++ b/go/src/cmd/compile/internal/devirtualize/pgo_test.go @@ -0,0 +1,219 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package devirtualize + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/pgoir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/pgo" + "cmd/internal/src" + "cmd/internal/sys" + "testing" +) + +func init() { + // These are the few constants that need to be initialized in order to use + // the types package without using the typecheck package by calling + // typecheck.InitUniverse() (the normal way to initialize the types package). + types.PtrSize = 8 + types.RegSize = 8 + types.MaxWidth = 1 << 50 + base.Ctxt = &obj.Link{Arch: &obj.LinkArch{Arch: &sys.Arch{Alignment: 1, CanMergeLoads: true}}} + typecheck.InitUniverse() + base.Debug.PGODebug = 3 +} + +func makePos(b *src.PosBase, line, col uint) src.XPos { + return base.Ctxt.PosTable.XPos(src.MakePos(b, line, col)) +} + +type profileBuilder struct { + p *pgoir.Profile +} + +func newProfileBuilder() *profileBuilder { + // findHotConcreteCallee only uses pgoir.Profile.WeightedCG, so we're + // going to take a shortcut and only construct that. + return &profileBuilder{ + p: &pgoir.Profile{ + WeightedCG: &pgoir.IRGraph{ + IRNodes: make(map[string]*pgoir.IRNode), + }, + }, + } +} + +// Profile returns the constructed profile. +func (p *profileBuilder) Profile() *pgoir.Profile { + return p.p +} + +// NewNode creates a new IRNode and adds it to the profile. +// +// fn may be nil, in which case the node will set LinkerSymbolName. +func (p *profileBuilder) NewNode(name string, fn *ir.Func) *pgoir.IRNode { + n := &pgoir.IRNode{ + OutEdges: make(map[pgo.NamedCallEdge]*pgoir.IREdge), + } + if fn != nil { + n.AST = fn + } else { + n.LinkerSymbolName = name + } + p.p.WeightedCG.IRNodes[name] = n + return n +} + +// Add a new call edge from caller to callee. +func addEdge(caller, callee *pgoir.IRNode, offset int, weight int64) { + namedEdge := pgo.NamedCallEdge{ + CallerName: caller.Name(), + CalleeName: callee.Name(), + CallSiteOffset: offset, + } + irEdge := &pgoir.IREdge{ + Src: caller, + Dst: callee, + CallSiteOffset: offset, + Weight: weight, + } + caller.OutEdges[namedEdge] = irEdge +} + +// Create a new struct type named structName with a method named methName and +// return the method. +func makeStructWithMethod(pkg *types.Pkg, structName, methName string) *ir.Func { + // type structName struct{} + structType := types.NewStruct(nil) + + // func (structName) methodName() + recv := types.NewField(src.NoXPos, typecheck.Lookup(structName), structType) + sig := types.NewSignature(recv, nil, nil) + fn := ir.NewFunc(src.NoXPos, src.NoXPos, pkg.Lookup(structName+"."+methName), sig) + + // Add the method to the struct. + structType.SetMethods([]*types.Field{types.NewField(src.NoXPos, typecheck.Lookup(methName), sig)}) + + return fn +} + +func TestFindHotConcreteInterfaceCallee(t *testing.T) { + p := newProfileBuilder() + + pkgFoo := types.NewPkg("example.com/foo", "foo") + basePos := src.NewFileBase("foo.go", "/foo.go") + + const ( + // Caller start line. + callerStart = 42 + + // The line offset of the call we care about. + callOffset = 1 + + // The line offset of some other call we don't care about. + wrongCallOffset = 2 + ) + + // type IFace interface { + // Foo() + // } + fooSig := types.NewSignature(types.FakeRecv(), nil, nil) + method := types.NewField(src.NoXPos, typecheck.Lookup("Foo"), fooSig) + iface := types.NewInterface([]*types.Field{method}) + + callerFn := ir.NewFunc(makePos(basePos, callerStart, 1), src.NoXPos, pkgFoo.Lookup("Caller"), types.NewSignature(nil, nil, nil)) + + hotCalleeFn := makeStructWithMethod(pkgFoo, "HotCallee", "Foo") + coldCalleeFn := makeStructWithMethod(pkgFoo, "ColdCallee", "Foo") + wrongLineCalleeFn := makeStructWithMethod(pkgFoo, "WrongLineCallee", "Foo") + wrongMethodCalleeFn := makeStructWithMethod(pkgFoo, "WrongMethodCallee", "Bar") + + callerNode := p.NewNode("example.com/foo.Caller", callerFn) + hotCalleeNode := p.NewNode("example.com/foo.HotCallee.Foo", hotCalleeFn) + coldCalleeNode := p.NewNode("example.com/foo.ColdCallee.Foo", coldCalleeFn) + wrongLineCalleeNode := p.NewNode("example.com/foo.WrongCalleeLine.Foo", wrongLineCalleeFn) + wrongMethodCalleeNode := p.NewNode("example.com/foo.WrongCalleeMethod.Foo", wrongMethodCalleeFn) + + hotMissingCalleeNode := p.NewNode("example.com/bar.HotMissingCallee.Foo", nil) + + addEdge(callerNode, wrongLineCalleeNode, wrongCallOffset, 100) // Really hot, but wrong line. + addEdge(callerNode, wrongMethodCalleeNode, callOffset, 100) // Really hot, but wrong method type. + addEdge(callerNode, hotCalleeNode, callOffset, 10) + addEdge(callerNode, coldCalleeNode, callOffset, 1) + + // Equal weight, but IR missing. + // + // N.B. example.com/bar sorts lexicographically before example.com/foo, + // so if the IR availability of hotCalleeNode doesn't get precedence, + // this would be mistakenly selected. + addEdge(callerNode, hotMissingCalleeNode, callOffset, 10) + + // IFace.Foo() + sel := typecheck.NewMethodExpr(src.NoXPos, iface, typecheck.Lookup("Foo")) + call := ir.NewCallExpr(makePos(basePos, callerStart+callOffset, 1), ir.OCALLINTER, sel, nil) + + gotFn, gotWeight := findHotConcreteInterfaceCallee(p.Profile(), callerFn, call) + if gotFn != hotCalleeFn { + t.Errorf("findHotConcreteInterfaceCallee func got %v want %v", gotFn, hotCalleeFn) + } + if gotWeight != 10 { + t.Errorf("findHotConcreteInterfaceCallee weight got %v want 10", gotWeight) + } +} + +func TestFindHotConcreteFunctionCallee(t *testing.T) { + // TestFindHotConcreteInterfaceCallee already covered basic weight + // comparisons, which is shared logic. Here we just test type signature + // disambiguation. + + p := newProfileBuilder() + + pkgFoo := types.NewPkg("example.com/foo", "foo") + basePos := src.NewFileBase("foo.go", "/foo.go") + + const ( + // Caller start line. + callerStart = 42 + + // The line offset of the call we care about. + callOffset = 1 + ) + + callerFn := ir.NewFunc(makePos(basePos, callerStart, 1), src.NoXPos, pkgFoo.Lookup("Caller"), types.NewSignature(nil, nil, nil)) + + // func HotCallee() + hotCalleeFn := ir.NewFunc(src.NoXPos, src.NoXPos, pkgFoo.Lookup("HotCallee"), types.NewSignature(nil, nil, nil)) + + // func WrongCallee() bool + wrongCalleeFn := ir.NewFunc(src.NoXPos, src.NoXPos, pkgFoo.Lookup("WrongCallee"), types.NewSignature(nil, nil, + []*types.Field{ + types.NewField(src.NoXPos, nil, types.Types[types.TBOOL]), + }, + )) + + callerNode := p.NewNode("example.com/foo.Caller", callerFn) + hotCalleeNode := p.NewNode("example.com/foo.HotCallee", hotCalleeFn) + wrongCalleeNode := p.NewNode("example.com/foo.WrongCallee", wrongCalleeFn) + + addEdge(callerNode, wrongCalleeNode, callOffset, 100) // Really hot, but wrong function type. + addEdge(callerNode, hotCalleeNode, callOffset, 10) + + // var fn func() + name := ir.NewNameAt(src.NoXPos, typecheck.Lookup("fn"), types.NewSignature(nil, nil, nil)) + // fn() + call := ir.NewCallExpr(makePos(basePos, callerStart+callOffset, 1), ir.OCALL, name, nil) + + gotFn, gotWeight := findHotConcreteFunctionCallee(p.Profile(), callerFn, call) + if gotFn != hotCalleeFn { + t.Errorf("findHotConcreteFunctionCallee func got %v want %v", gotFn, hotCalleeFn) + } + if gotWeight != 10 { + t.Errorf("findHotConcreteFunctionCallee weight got %v want 10", gotWeight) + } +} diff --git a/go/src/cmd/compile/internal/dwarfgen/dwarf.go b/go/src/cmd/compile/internal/dwarfgen/dwarf.go new file mode 100644 index 0000000000000000000000000000000000000000..9d975e0bc1ac7d2d8865b87933df2028d50d0522 --- /dev/null +++ b/go/src/cmd/compile/internal/dwarfgen/dwarf.go @@ -0,0 +1,672 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package dwarfgen + +import ( + "bytes" + "flag" + "fmt" + "internal/buildcfg" + "slices" + "sort" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/reflectdata" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/dwarf" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" +) + +func Info(ctxt *obj.Link, fnsym *obj.LSym, infosym *obj.LSym, curfn obj.Func) (scopes []dwarf.Scope, inlcalls dwarf.InlCalls) { + fn := curfn.(*ir.Func) + + if fn.Nname != nil { + expect := fn.Linksym() + if fnsym.ABI() == obj.ABI0 { + expect = fn.LinksymABI(obj.ABI0) + } + if fnsym != expect { + base.Fatalf("unexpected fnsym: %v != %v", fnsym, expect) + } + } + + // Back when there were two different *Funcs for a function, this code + // was not consistent about whether a particular *Node being processed + // was an ODCLFUNC or ONAME node. Partly this is because inlined function + // bodies have no ODCLFUNC node, which was it's own inconsistency. + // In any event, the handling of the two different nodes for DWARF purposes + // was subtly different, likely in unintended ways. CL 272253 merged the + // two nodes' Func fields, so that code sees the same *Func whether it is + // holding the ODCLFUNC or the ONAME. This resulted in changes in the + // DWARF output. To preserve the existing DWARF output and leave an + // intentional change for a future CL, this code does the following when + // fn.Op == ONAME: + // + // 1. Disallow use of createComplexVars in createDwarfVars. + // It was not possible to reach that code for an ONAME before, + // because the DebugInfo was set only on the ODCLFUNC Func. + // Calling into it in the ONAME case causes an index out of bounds panic. + // + // 2. Do not populate apdecls. fn.Func.Dcl was in the ODCLFUNC Func, + // not the ONAME Func. Populating apdecls for the ONAME case results + // in selected being populated after createSimpleVars is called in + // createDwarfVars, and then that causes the loop to skip all the entries + // in dcl, meaning that the RecordAutoType calls don't happen. + // + // These two adjustments keep toolstash -cmp working for now. + // Deciding the right answer is, as they say, future work. + // + // We can tell the difference between the old ODCLFUNC and ONAME + // cases by looking at the infosym.Name. If it's empty, DebugInfo is + // being called from (*obj.Link).populateDWARF, which used to use + // the ODCLFUNC. If it's non-empty (the name will end in $abstract), + // DebugInfo is being called from (*obj.Link).DwarfAbstractFunc, + // which used to use the ONAME form. + isODCLFUNC := infosym.Name == "" + + var apdecls []*ir.Name + // Populate decls for fn. + if isODCLFUNC { + for _, n := range fn.Dcl { + if n.Op() != ir.ONAME { // might be OTYPE or OLITERAL + continue + } + switch n.Class { + case ir.PAUTO: + if !n.Used() { + // Text == nil -> generating abstract function + if fnsym.Func().Text != nil { + base.Fatalf("debuginfo unused node (AllocFrame should truncate fn.Func.Dcl)") + } + continue + } + case ir.PPARAM, ir.PPARAMOUT: + default: + continue + } + if !ssa.IsVarWantedForDebug(n) { + continue + } + apdecls = append(apdecls, n) + if n.Type().Kind() == types.TSSA { + // Can happen for TypeInt128 types. This only happens for + // spill locations, so not a huge deal. + continue + } + fnsym.Func().RecordAutoType(reflectdata.TypeLinksym(n.Type())) + } + } + + var closureVars map[*ir.Name]int64 + if fn.Needctxt() { + closureVars = make(map[*ir.Name]int64) + csiter := typecheck.NewClosureStructIter(fn.ClosureVars) + for { + n, _, offset := csiter.Next() + if n == nil { + break + } + closureVars[n] = offset + if n.Heapaddr != nil { + closureVars[n.Heapaddr] = offset + } + } + } + + decls, dwarfVars := createDwarfVars(fnsym, isODCLFUNC, fn, apdecls, closureVars) + + // For each type referenced by the functions auto vars but not + // already referenced by a dwarf var, attach an R_USETYPE relocation to + // the function symbol to insure that the type included in DWARF + // processing during linking. + // Do the same with R_USEIFACE relocations from the function symbol for the + // same reason. + // All these R_USETYPE relocations are only looked at if the function + // survives deadcode elimination in the linker. + typesyms := []*obj.LSym{} + for t := range fnsym.Func().Autot { + typesyms = append(typesyms, t) + } + for i := range fnsym.R { + if fnsym.R[i].Type == objabi.R_USEIFACE && !strings.HasPrefix(fnsym.R[i].Sym.Name, "go:itab.") { + // Types referenced through itab will be referenced from somewhere else + typesyms = append(typesyms, fnsym.R[i].Sym) + } + } + slices.SortFunc(typesyms, func(a, b *obj.LSym) int { + return strings.Compare(a.Name, b.Name) + }) + var lastsym *obj.LSym + for _, sym := range typesyms { + if sym == lastsym { + continue + } + lastsym = sym + infosym.AddRel(ctxt, obj.Reloc{Type: objabi.R_USETYPE, Sym: sym}) + } + fnsym.Func().Autot = nil + + var varScopes []ir.ScopeID + for _, decl := range decls { + pos := declPos(decl) + varScopes = append(varScopes, findScope(fn.Marks, pos)) + } + + scopes = assembleScopes(fnsym, fn, dwarfVars, varScopes) + if base.Flag.GenDwarfInl > 0 { + inlcalls = assembleInlines(fnsym, dwarfVars) + } + return scopes, inlcalls +} + +func declPos(decl *ir.Name) src.XPos { + return decl.Canonical().Pos() +} + +// createDwarfVars process fn, returning a list of DWARF variables and the +// Nodes they represent. +func createDwarfVars(fnsym *obj.LSym, complexOK bool, fn *ir.Func, apDecls []*ir.Name, closureVars map[*ir.Name]int64) ([]*ir.Name, []*dwarf.Var) { + // Collect a raw list of DWARF vars. + var vars []*dwarf.Var + var decls []*ir.Name + var selected ir.NameSet + + if base.Ctxt.Flag_locationlists && base.Ctxt.Flag_optimize && fn.DebugInfo != nil && complexOK { + decls, vars, selected = createComplexVars(fnsym, fn, closureVars) + } else if fn.ABI == obj.ABIInternal && base.Flag.N != 0 && complexOK { + decls, vars, selected = createABIVars(fnsym, fn, apDecls, closureVars) + } else { + decls, vars, selected = createSimpleVars(fnsym, apDecls, closureVars) + } + if fn.DebugInfo != nil { + // Recover zero sized variables eliminated by the stackframe pass + for _, n := range fn.DebugInfo.(*ssa.FuncDebug).OptDcl { + if n.Class != ir.PAUTO { + continue + } + types.CalcSize(n.Type()) + if n.Type().Size() == 0 { + decls = append(decls, n) + vars = append(vars, createSimpleVar(fnsym, n, closureVars)) + vars[len(vars)-1].StackOffset = 0 + fnsym.Func().RecordAutoType(reflectdata.TypeLinksym(n.Type())) + } + } + } + + dcl := apDecls + if fnsym.WasInlined() { + dcl = preInliningDcls(fnsym) + } else { + // The backend's stackframe pass prunes away entries from the + // fn's Dcl list, including PARAMOUT nodes that correspond to + // output params passed in registers. Add back in these + // entries here so that we can process them properly during + // DWARF-gen. See issue 48573 for more details. + debugInfo := fn.DebugInfo.(*ssa.FuncDebug) + for _, n := range debugInfo.RegOutputParams { + if !ssa.IsVarWantedForDebug(n) { + continue + } + if n.Class != ir.PPARAMOUT || !n.IsOutputParamInRegisters() { + base.Fatalf("invalid ir.Name on debugInfo.RegOutputParams list") + } + dcl = append(dcl, n) + } + } + + // If optimization is enabled, the list above will typically be + // missing some of the original pre-optimization variables in the + // function (they may have been promoted to registers, folded into + // constants, dead-coded away, etc). Input arguments not eligible + // for SSA optimization are also missing. Here we add back in entries + // for selected missing vars. Note that the recipe below creates a + // conservative location. The idea here is that we want to + // communicate to the user that "yes, there is a variable named X + // in this function, but no, I don't have enough information to + // reliably report its contents." + // For non-SSA-able arguments, however, the correct information + // is known -- they have a single home on the stack. + for _, n := range dcl { + if selected.Has(n) { + continue + } + c := n.Sym().Name[0] + if c == '.' || n.Type().IsUntyped() { + continue + } + if n.Class == ir.PPARAM && !ssa.CanSSA(n.Type()) { + // SSA-able args get location lists, and may move in and + // out of registers, so those are handled elsewhere. + // Autos and named output params seem to get handled + // with VARDEF, which creates location lists. + // Args not of SSA-able type are treated here; they + // are homed on the stack in a single place for the + // entire call. + vars = append(vars, createSimpleVar(fnsym, n, closureVars)) + decls = append(decls, n) + continue + } + typename := dwarf.InfoPrefix + types.TypeSymName(n.Type()) + decls = append(decls, n) + tag := dwarf.DW_TAG_variable + isReturnValue := (n.Class == ir.PPARAMOUT) + if n.Class == ir.PPARAM || n.Class == ir.PPARAMOUT { + tag = dwarf.DW_TAG_formal_parameter + } + inlIndex := 0 + if base.Flag.GenDwarfInl > 1 { + if n.InlFormal() || n.InlLocal() { + inlIndex = posInlIndex(n.Pos()) + 1 + if n.InlFormal() { + tag = dwarf.DW_TAG_formal_parameter + } + } + } + declpos := base.Ctxt.InnermostPos(n.Pos()) + dvar := &dwarf.Var{ + Name: n.Sym().Name, + IsReturnValue: isReturnValue, + Tag: tag, + WithLoclist: true, + StackOffset: int32(n.FrameOffset()), + Type: base.Ctxt.Lookup(typename), + DeclFile: declpos.RelFilename(), + DeclLine: declpos.RelLine(), + DeclCol: declpos.RelCol(), + InlIndex: int32(inlIndex), + ChildIndex: -1, + DictIndex: n.DictIndex, + ClosureOffset: closureOffset(n, closureVars), + } + if n.Esc() == ir.EscHeap { + if n.Heapaddr == nil { + base.Fatalf("invalid heap allocated var without Heapaddr") + } + debug := fn.DebugInfo.(*ssa.FuncDebug) + list := createHeapDerefLocationList(n, debug.EntryID) + dvar.PutLocationList = func(listSym, startPC dwarf.Sym) { + debug.PutLocationList(list, base.Ctxt, listSym.(*obj.LSym), startPC.(*obj.LSym)) + } + } + vars = append(vars, dvar) + // Record go type to ensure that it gets emitted by the linker. + fnsym.Func().RecordAutoType(reflectdata.TypeLinksym(n.Type())) + } + + // Sort decls and vars. + sortDeclsAndVars(fn, decls, vars) + + return decls, vars +} + +// sortDeclsAndVars sorts the decl and dwarf var lists according to +// parameter declaration order, so as to insure that when a subprogram +// DIE is emitted, its parameter children appear in declaration order. +// Prior to the advent of the register ABI, sorting by frame offset +// would achieve this; with the register we now need to go back to the +// original function signature. +func sortDeclsAndVars(fn *ir.Func, decls []*ir.Name, vars []*dwarf.Var) { + paramOrder := make(map[*ir.Name]int) + idx := 1 + for _, f := range fn.Type().RecvParamsResults() { + if n, ok := f.Nname.(*ir.Name); ok { + paramOrder[n] = idx + idx++ + } + } + sort.Stable(varsAndDecls{decls, vars, paramOrder}) +} + +type varsAndDecls struct { + decls []*ir.Name + vars []*dwarf.Var + paramOrder map[*ir.Name]int +} + +func (v varsAndDecls) Len() int { + return len(v.decls) +} + +func (v varsAndDecls) Less(i, j int) bool { + nameLT := func(ni, nj *ir.Name) bool { + oi, foundi := v.paramOrder[ni] + oj, foundj := v.paramOrder[nj] + if foundi { + if foundj { + return oi < oj + } else { + return true + } + } + return false + } + return nameLT(v.decls[i], v.decls[j]) +} + +func (v varsAndDecls) Swap(i, j int) { + v.vars[i], v.vars[j] = v.vars[j], v.vars[i] + v.decls[i], v.decls[j] = v.decls[j], v.decls[i] +} + +// Given a function that was inlined at some point during the +// compilation, return a sorted list of nodes corresponding to the +// autos/locals in that function prior to inlining. If this is a +// function that is not local to the package being compiled, then the +// names of the variables may have been "versioned" to avoid conflicts +// with local vars; disregard this versioning when sorting. +func preInliningDcls(fnsym *obj.LSym) []*ir.Name { + fn := base.Ctxt.DwFixups.GetPrecursorFunc(fnsym).(*ir.Func) + var rdcl []*ir.Name + for _, n := range fn.Inl.Dcl { + c := n.Sym().Name[0] + // Avoid reporting "_" parameters, since if there are more than + // one, it can result in a collision later on, as in #23179. + if n.Sym().Name == "_" || c == '.' || n.Type().IsUntyped() { + continue + } + rdcl = append(rdcl, n) + } + return rdcl +} + +// createSimpleVars creates a DWARF entry for every variable declared in the +// function, claiming that they are permanently on the stack. +func createSimpleVars(fnsym *obj.LSym, apDecls []*ir.Name, closureVars map[*ir.Name]int64) ([]*ir.Name, []*dwarf.Var, ir.NameSet) { + var vars []*dwarf.Var + var decls []*ir.Name + var selected ir.NameSet + for _, n := range apDecls { + if ir.IsAutoTmp(n) { + continue + } + + decls = append(decls, n) + vars = append(vars, createSimpleVar(fnsym, n, closureVars)) + selected.Add(n) + } + return decls, vars, selected +} + +func createSimpleVar(fnsym *obj.LSym, n *ir.Name, closureVars map[*ir.Name]int64) *dwarf.Var { + var tag int + var offs int64 + + localAutoOffset := func() int64 { + offs = n.FrameOffset() + if base.Ctxt.Arch.FixedFrameSize == 0 { + offs -= int64(types.PtrSize) + } + if buildcfg.FramePointerEnabled { + offs -= int64(types.PtrSize) + } + return offs + } + + switch n.Class { + case ir.PAUTO: + offs = localAutoOffset() + tag = dwarf.DW_TAG_variable + case ir.PPARAM, ir.PPARAMOUT: + tag = dwarf.DW_TAG_formal_parameter + if n.IsOutputParamInRegisters() { + offs = localAutoOffset() + } else { + offs = n.FrameOffset() + base.Ctxt.Arch.FixedFrameSize + } + + default: + base.Fatalf("createSimpleVar unexpected class %v for node %v", n.Class, n) + } + + typename := dwarf.InfoPrefix + types.TypeSymName(n.Type()) + delete(fnsym.Func().Autot, reflectdata.TypeLinksym(n.Type())) + inlIndex := 0 + if base.Flag.GenDwarfInl > 1 { + if n.InlFormal() || n.InlLocal() { + inlIndex = posInlIndex(n.Pos()) + 1 + if n.InlFormal() { + tag = dwarf.DW_TAG_formal_parameter + } + } + } + declpos := base.Ctxt.InnermostPos(declPos(n)) + return &dwarf.Var{ + Name: n.Sym().Name, + IsReturnValue: n.Class == ir.PPARAMOUT, + IsInlFormal: n.InlFormal(), + Tag: tag, + StackOffset: int32(offs), + Type: base.Ctxt.Lookup(typename), + DeclFile: declpos.RelFilename(), + DeclLine: declpos.RelLine(), + DeclCol: declpos.RelCol(), + InlIndex: int32(inlIndex), + ChildIndex: -1, + DictIndex: n.DictIndex, + ClosureOffset: closureOffset(n, closureVars), + } +} + +// createABIVars creates DWARF variables for functions in which the +// register ABI is enabled but optimization is turned off. It uses a +// hybrid approach in which register-resident input params are +// captured with location lists, and all other vars use the "simple" +// strategy. +func createABIVars(fnsym *obj.LSym, fn *ir.Func, apDecls []*ir.Name, closureVars map[*ir.Name]int64) ([]*ir.Name, []*dwarf.Var, ir.NameSet) { + + // Invoke createComplexVars to generate dwarf vars for input parameters + // that are register-allocated according to the ABI rules. + decls, vars, selected := createComplexVars(fnsym, fn, closureVars) + + // Now fill in the remainder of the variables: input parameters + // that are not register-resident, output parameters, and local + // variables. + for _, n := range apDecls { + if ir.IsAutoTmp(n) { + continue + } + if _, ok := selected[n]; ok { + // already handled + continue + } + + decls = append(decls, n) + vars = append(vars, createSimpleVar(fnsym, n, closureVars)) + selected.Add(n) + } + + return decls, vars, selected +} + +// createComplexVars creates recomposed DWARF vars with location lists, +// suitable for describing optimized code. +func createComplexVars(fnsym *obj.LSym, fn *ir.Func, closureVars map[*ir.Name]int64) ([]*ir.Name, []*dwarf.Var, ir.NameSet) { + debugInfo := fn.DebugInfo.(*ssa.FuncDebug) + + // Produce a DWARF variable entry for each user variable. + var decls []*ir.Name + var vars []*dwarf.Var + var ssaVars ir.NameSet + + for varID, dvar := range debugInfo.Vars { + n := dvar + ssaVars.Add(n) + for _, slot := range debugInfo.VarSlots[varID] { + ssaVars.Add(debugInfo.Slots[slot].N) + } + + if dvar := createComplexVar(fnsym, fn, ssa.VarID(varID), closureVars); dvar != nil { + decls = append(decls, n) + vars = append(vars, dvar) + } + } + + return decls, vars, ssaVars +} + +// createComplexVar builds a single DWARF variable entry and location list. +func createComplexVar(fnsym *obj.LSym, fn *ir.Func, varID ssa.VarID, closureVars map[*ir.Name]int64) *dwarf.Var { + debug := fn.DebugInfo.(*ssa.FuncDebug) + n := debug.Vars[varID] + + var tag int + switch n.Class { + case ir.PAUTO: + tag = dwarf.DW_TAG_variable + case ir.PPARAM, ir.PPARAMOUT: + tag = dwarf.DW_TAG_formal_parameter + default: + return nil + } + + gotype := reflectdata.TypeLinksym(n.Type()) + delete(fnsym.Func().Autot, gotype) + typename := dwarf.InfoPrefix + gotype.Name[len("type:"):] + inlIndex := 0 + if base.Flag.GenDwarfInl > 1 { + if n.InlFormal() || n.InlLocal() { + inlIndex = posInlIndex(n.Pos()) + 1 + if n.InlFormal() { + tag = dwarf.DW_TAG_formal_parameter + } + } + } + declpos := base.Ctxt.InnermostPos(n.Pos()) + dvar := &dwarf.Var{ + Name: n.Sym().Name, + IsReturnValue: n.Class == ir.PPARAMOUT, + IsInlFormal: n.InlFormal(), + Tag: tag, + WithLoclist: true, + Type: base.Ctxt.Lookup(typename), + // The stack offset is used as a sorting key, so for decomposed + // variables just give it the first one. It's not used otherwise. + // This won't work well if the first slot hasn't been assigned a stack + // location, but it's not obvious how to do better. + StackOffset: ssagen.StackOffset(debug.Slots[debug.VarSlots[varID][0]]), + DeclFile: declpos.RelFilename(), + DeclLine: declpos.RelLine(), + DeclCol: declpos.RelCol(), + InlIndex: int32(inlIndex), + ChildIndex: -1, + DictIndex: n.DictIndex, + ClosureOffset: closureOffset(n, closureVars), + } + list := debug.LocationLists[varID] + if len(list) != 0 { + dvar.PutLocationList = func(listSym, startPC dwarf.Sym) { + debug.PutLocationList(list, base.Ctxt, listSym.(*obj.LSym), startPC.(*obj.LSym)) + } + } + return dvar +} + +// createHeapDerefLocationList creates a location list for a heap-escaped variable +// that describes "dereference pointer at stack offset" +func createHeapDerefLocationList(n *ir.Name, entryID ssa.ID) []byte { + // Get the stack offset where the heap pointer is stored + heapPtrOffset := n.Heapaddr.FrameOffset() + if base.Ctxt.Arch.FixedFrameSize == 0 { + heapPtrOffset -= int64(types.PtrSize) + } + if buildcfg.FramePointerEnabled { + heapPtrOffset -= int64(types.PtrSize) + } + + // Create a location expression: DW_OP_fbreg DW_OP_deref + var locExpr []byte + var sizeIdx int + locExpr, sizeIdx = ssa.SetupLocList(base.Ctxt, entryID, locExpr, ssa.BlockStart.ID, ssa.FuncEnd.ID) + locExpr = append(locExpr, dwarf.DW_OP_fbreg) + locExpr = dwarf.AppendSleb128(locExpr, heapPtrOffset) + locExpr = append(locExpr, dwarf.DW_OP_deref) + base.Ctxt.Arch.ByteOrder.PutUint16(locExpr[sizeIdx:], uint16(len(locExpr)-sizeIdx-2)) + return locExpr +} + +// RecordFlags records the specified command-line flags to be placed +// in the DWARF info. +func RecordFlags(flags ...string) { + if base.Ctxt.Pkgpath == "" { + base.Fatalf("missing pkgpath") + } + + type BoolFlag interface { + IsBoolFlag() bool + } + type CountFlag interface { + IsCountFlag() bool + } + var cmd bytes.Buffer + for _, name := range flags { + f := flag.Lookup(name) + if f == nil { + continue + } + getter := f.Value.(flag.Getter) + if getter.String() == f.DefValue { + // Flag has default value, so omit it. + continue + } + if bf, ok := f.Value.(BoolFlag); ok && bf.IsBoolFlag() { + val, ok := getter.Get().(bool) + if ok && val { + fmt.Fprintf(&cmd, " -%s", f.Name) + continue + } + } + if cf, ok := f.Value.(CountFlag); ok && cf.IsCountFlag() { + val, ok := getter.Get().(int) + if ok && val == 1 { + fmt.Fprintf(&cmd, " -%s", f.Name) + continue + } + } + fmt.Fprintf(&cmd, " -%s=%v", f.Name, getter.Get()) + } + + // Adds flag to producer string signaling whether regabi is turned on or + // off. + // Once regabi is turned on across the board and the relative GOEXPERIMENT + // knobs no longer exist this code should be removed. + if buildcfg.Experiment.RegabiArgs { + cmd.Write([]byte(" regabi")) + } + + if cmd.Len() == 0 { + return + } + s := base.Ctxt.Lookup(dwarf.CUInfoPrefix + "producer." + base.Ctxt.Pkgpath) + s.Type = objabi.SDWARFCUINFO + // Sometimes (for example when building tests) we can link + // together two package main archives. So allow dups. + s.Set(obj.AttrDuplicateOK, true) + base.Ctxt.Data = append(base.Ctxt.Data, s) + s.P = cmd.Bytes()[1:] +} + +// RecordPackageName records the name of the package being +// compiled, so that the linker can save it in the compile unit's DIE. +func RecordPackageName() { + s := base.Ctxt.Lookup(dwarf.CUInfoPrefix + "packagename." + base.Ctxt.Pkgpath) + s.Type = objabi.SDWARFCUINFO + // Sometimes (for example when building tests) we can link + // together two package main archives. So allow dups. + s.Set(obj.AttrDuplicateOK, true) + base.Ctxt.Data = append(base.Ctxt.Data, s) + s.P = []byte(types.LocalPkg.Name) +} + +func closureOffset(n *ir.Name, closureVars map[*ir.Name]int64) int64 { + return closureVars[n] +} diff --git a/go/src/cmd/compile/internal/dwarfgen/dwinl.go b/go/src/cmd/compile/internal/dwarfgen/dwinl.go new file mode 100644 index 0000000000000000000000000000000000000000..bb3ef84df8639e01f41e6b4e3717a8e6e5a8a0b4 --- /dev/null +++ b/go/src/cmd/compile/internal/dwarfgen/dwinl.go @@ -0,0 +1,441 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package dwarfgen + +import ( + "fmt" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/internal/dwarf" + "cmd/internal/obj" + "cmd/internal/src" +) + +// To identify variables by original source position. +type varPos struct { + DeclName string + DeclFile string + DeclLine uint + DeclCol uint +} + +// This is the main entry point for collection of raw material to +// drive generation of DWARF "inlined subroutine" DIEs. See proposal +// 22080 for more details and background info. +func assembleInlines(fnsym *obj.LSym, dwVars []*dwarf.Var) dwarf.InlCalls { + var inlcalls dwarf.InlCalls + + if base.Debug.DwarfInl != 0 { + base.Ctxt.Logf("assembling DWARF inlined routine info for %v\n", fnsym.Name) + } + + // This maps inline index (from Ctxt.InlTree) to index in inlcalls.Calls + imap := make(map[int]int) + + // Walk progs to build up the InlCalls data structure + var prevpos src.XPos + for p := fnsym.Func().Text; p != nil; p = p.Link { + if p.Pos == prevpos { + continue + } + ii := posInlIndex(p.Pos) + if ii >= 0 { + insertInlCall(&inlcalls, ii, imap) + } + prevpos = p.Pos + } + + // This is used to partition DWARF vars by inline index. Vars not + // produced by the inliner will wind up in the vmap[0] entry. + vmap := make(map[int32][]*dwarf.Var) + + // Now walk the dwarf vars and partition them based on whether they + // were produced by the inliner (dwv.InlIndex > 0) or were original + // vars/params from the function (dwv.InlIndex == 0). + for _, dwv := range dwVars { + + vmap[dwv.InlIndex] = append(vmap[dwv.InlIndex], dwv) + + // Zero index => var was not produced by an inline + if dwv.InlIndex == 0 { + continue + } + + // Look up index in our map, then tack the var in question + // onto the vars list for the correct inlined call. + ii := int(dwv.InlIndex) - 1 + idx, ok := imap[ii] + if !ok { + // We can occasionally encounter a var produced by the + // inliner for which there is no remaining prog; add a new + // entry to the call list in this scenario. + idx = insertInlCall(&inlcalls, ii, imap) + } + inlcalls.Calls[idx].InlVars = + append(inlcalls.Calls[idx].InlVars, dwv) + } + + // Post process the map above to assign child indices to vars. + // + // A given variable is treated differently depending on whether it + // is part of the top-level function (ii == 0) or if it was + // produced as a result of an inline (ii != 0). + // + // If a variable was not produced by an inline and its containing + // function was not inlined, then we just assign an ordering of + // based on variable name. + // + // If a variable was not produced by an inline and its containing + // function was inlined, then we need to assign a child index + // based on the order of vars in the abstract function (in + // addition, those vars that don't appear in the abstract + // function, such as "~r1", are flagged as such). + // + // If a variable was produced by an inline, then we locate it in + // the pre-inlining decls for the target function and assign child + // index accordingly. + for ii, sl := range vmap { + var m map[varPos]int + if ii == 0 { + if !fnsym.WasInlined() { + for j, v := range sl { + v.ChildIndex = int32(j) + } + continue + } + m = makePreinlineDclMap(fnsym) + } else { + ifnlsym := base.Ctxt.InlTree.InlinedFunction(int(ii - 1)) + m = makePreinlineDclMap(ifnlsym) + } + + // Here we assign child indices to variables based on + // pre-inlined decls, and set the "IsInAbstract" flag + // appropriately. In addition: parameter and local variable + // names are given "middle dot" version numbers as part of the + // writing them out to export data (see issue 4326). If DWARF + // inlined routine generation is turned on, we want to undo + // this versioning, since DWARF variables in question will be + // parented by the inlined routine and not the top-level + // caller. + synthCount := len(m) + for _, v := range sl { + vp := varPos{ + DeclName: v.Name, + DeclFile: v.DeclFile, + DeclLine: v.DeclLine, + DeclCol: v.DeclCol, + } + synthesized := strings.HasPrefix(v.Name, "~") || v.Name == "_" + if idx, found := m[vp]; found { + v.ChildIndex = int32(idx) + v.IsInAbstract = !synthesized + } else { + // Variable can't be found in the pre-inline dcl list. + // In the top-level case (ii=0) this can happen + // because a composite variable was split into pieces, + // and we're looking at a piece. We can also see + // return temps (~r%d) that were created during + // lowering, or unnamed params ("_"). + v.ChildIndex = int32(synthCount) + synthCount++ + } + } + } + + // Make a second pass through the progs to compute PC ranges for + // the various inlined calls. + start := int64(-1) + curii := -1 + var prevp *obj.Prog + for p := fnsym.Func().Text; p != nil; prevp, p = p, p.Link { + if prevp != nil && p.Pos == prevp.Pos { + continue + } + ii := posInlIndex(p.Pos) + if ii == curii { + continue + } + // Close out the current range + if start != -1 { + addRange(inlcalls.Calls, start, p.Pc, curii, imap) + } + // Begin new range + start = p.Pc + curii = ii + } + if start != -1 { + addRange(inlcalls.Calls, start, fnsym.Size, curii, imap) + } + + // Issue 33188: if II foo is a child of II bar, then ensure that + // bar's ranges include the ranges of foo (the loop above will produce + // disjoint ranges). + for k, c := range inlcalls.Calls { + if c.Root { + unifyCallRanges(inlcalls, k) + } + } + + // Debugging + if base.Debug.DwarfInl != 0 { + dumpInlCalls(inlcalls) + dumpInlVars(dwVars) + } + + // Perform a consistency check on inlined routine PC ranges + // produced by unifyCallRanges above. In particular, complain in + // cases where you have A -> B -> C (e.g. C is inlined into B, and + // B is inlined into A) and the ranges for B are not enclosed + // within the ranges for A, or C within B. + for k, c := range inlcalls.Calls { + if c.Root { + checkInlCall(fnsym.Name, inlcalls, fnsym.Size, k, -1) + } + } + + return inlcalls +} + +// Secondary hook for DWARF inlined subroutine generation. This is called +// late in the compilation when it is determined that we need an +// abstract function DIE for an inlined routine imported from a +// previously compiled package. +func AbstractFunc(fn *obj.LSym) { + ifn := base.Ctxt.DwFixups.GetPrecursorFunc(fn) + if ifn == nil { + base.Ctxt.Diag("failed to locate precursor fn for %v", fn) + return + } + _ = ifn.(*ir.Func) + if base.Debug.DwarfInl != 0 { + base.Ctxt.Logf("DwarfAbstractFunc(%v)\n", fn.Name) + } + base.Ctxt.DwarfAbstractFunc(ifn, fn) +} + +// Given a function that was inlined as part of the compilation, dig +// up the pre-inlining DCL list for the function and create a map that +// supports lookup of pre-inline dcl index, based on variable +// position/name. NB: the recipe for computing variable pos/file/line +// needs to be kept in sync with the similar code in gc.createSimpleVars +// and related functions. +func makePreinlineDclMap(fnsym *obj.LSym) map[varPos]int { + dcl := preInliningDcls(fnsym) + m := make(map[varPos]int) + for i, n := range dcl { + pos := base.Ctxt.InnermostPos(n.Pos()) + vp := varPos{ + DeclName: n.Sym().Name, + DeclFile: pos.RelFilename(), + DeclLine: pos.RelLine(), + DeclCol: pos.RelCol(), + } + if _, found := m[vp]; found { + // We can see collisions (variables with the same name/file/line/col) in obfuscated or machine-generated code -- see issue 44378 for an example. Skip duplicates in such cases, since it is unlikely that a human will be debugging such code. + continue + } + m[vp] = i + } + return m +} + +func insertInlCall(dwcalls *dwarf.InlCalls, inlIdx int, imap map[int]int) int { + callIdx, found := imap[inlIdx] + if found { + return callIdx + } + + // Haven't seen this inline yet. Visit parent of inline if there + // is one. We do this first so that parents appear before their + // children in the resulting table. + parCallIdx := -1 + parInlIdx := base.Ctxt.InlTree.Parent(inlIdx) + if parInlIdx >= 0 { + parCallIdx = insertInlCall(dwcalls, parInlIdx, imap) + } + + // Create new entry for this inline + inlinedFn := base.Ctxt.InlTree.InlinedFunction(inlIdx) + callXPos := base.Ctxt.InlTree.CallPos(inlIdx) + callPos := base.Ctxt.InnermostPos(callXPos) + absFnSym := base.Ctxt.DwFixups.AbsFuncDwarfSym(inlinedFn) + ic := dwarf.InlCall{ + InlIndex: inlIdx, + CallPos: callPos, + AbsFunSym: absFnSym, + Root: parCallIdx == -1, + } + dwcalls.Calls = append(dwcalls.Calls, ic) + callIdx = len(dwcalls.Calls) - 1 + imap[inlIdx] = callIdx + + if parCallIdx != -1 { + // Add this inline to parent's child list + dwcalls.Calls[parCallIdx].Children = append(dwcalls.Calls[parCallIdx].Children, callIdx) + } + + return callIdx +} + +// Given a src.XPos, return its associated inlining index if it +// corresponds to something created as a result of an inline, or -1 if +// there is no inline info. Note that the index returned will refer to +// the deepest call in the inlined stack, e.g. if you have "A calls B +// calls C calls D" and all three callees are inlined (B, C, and D), +// the index for a node from the inlined body of D will refer to the +// call to D from C. Whew. +func posInlIndex(xpos src.XPos) int { + pos := base.Ctxt.PosTable.Pos(xpos) + if b := pos.Base(); b != nil { + ii := b.InliningIndex() + if ii >= 0 { + return ii + } + } + return -1 +} + +func addRange(calls []dwarf.InlCall, start, end int64, ii int, imap map[int]int) { + if start == -1 { + panic("bad range start") + } + if end == -1 { + panic("bad range end") + } + if ii == -1 { + return + } + if start == end { + return + } + // Append range to correct inlined call + callIdx, found := imap[ii] + if !found { + base.Fatalf("can't find inlIndex %d in imap for prog at %d\n", ii, start) + } + call := &calls[callIdx] + call.Ranges = append(call.Ranges, dwarf.Range{Start: start, End: end}) +} + +func dumpInlCall(inlcalls dwarf.InlCalls, idx, ilevel int) { + for i := 0; i < ilevel; i++ { + base.Ctxt.Logf(" ") + } + ic := inlcalls.Calls[idx] + callee := base.Ctxt.InlTree.InlinedFunction(ic.InlIndex) + base.Ctxt.Logf(" %d: II:%d (%s) V: (", idx, ic.InlIndex, callee.Name) + for _, f := range ic.InlVars { + base.Ctxt.Logf(" %v", f.Name) + } + base.Ctxt.Logf(" ) C: (") + for _, k := range ic.Children { + base.Ctxt.Logf(" %v", k) + } + base.Ctxt.Logf(" ) R:") + for _, r := range ic.Ranges { + base.Ctxt.Logf(" [%d,%d)", r.Start, r.End) + } + base.Ctxt.Logf("\n") + for _, k := range ic.Children { + dumpInlCall(inlcalls, k, ilevel+1) + } + +} + +func dumpInlCalls(inlcalls dwarf.InlCalls) { + for k, c := range inlcalls.Calls { + if c.Root { + dumpInlCall(inlcalls, k, 0) + } + } +} + +func dumpInlVars(dwvars []*dwarf.Var) { + for i, dwv := range dwvars { + typ := "local" + if dwv.Tag == dwarf.DW_TAG_formal_parameter { + typ = "param" + } + ia := 0 + if dwv.IsInAbstract { + ia = 1 + } + base.Ctxt.Logf("V%d: %s CI:%d II:%d IA:%d %s\n", i, dwv.Name, dwv.ChildIndex, dwv.InlIndex-1, ia, typ) + } +} + +func rangesContains(par []dwarf.Range, rng dwarf.Range) (bool, string) { + for _, r := range par { + if rng.Start >= r.Start && rng.End <= r.End { + return true, "" + } + } + msg := fmt.Sprintf("range [%d,%d) not contained in {", rng.Start, rng.End) + for _, r := range par { + msg += fmt.Sprintf(" [%d,%d)", r.Start, r.End) + } + msg += " }" + return false, msg +} + +func rangesContainsAll(parent, child []dwarf.Range) (bool, string) { + for _, r := range child { + c, m := rangesContains(parent, r) + if !c { + return false, m + } + } + return true, "" +} + +// checkInlCall verifies that the PC ranges for inline info 'idx' are +// enclosed/contained within the ranges of its parent inline (or if +// this is a root/toplevel inline, checks that the ranges fall within +// the extent of the top level function). A panic is issued if a +// malformed range is found. +func checkInlCall(funcName string, inlCalls dwarf.InlCalls, funcSize int64, idx, parentIdx int) { + + // Callee + ic := inlCalls.Calls[idx] + callee := base.Ctxt.InlTree.InlinedFunction(ic.InlIndex).Name + calleeRanges := ic.Ranges + + // Caller + caller := funcName + parentRanges := []dwarf.Range{dwarf.Range{Start: int64(0), End: funcSize}} + if parentIdx != -1 { + pic := inlCalls.Calls[parentIdx] + caller = base.Ctxt.InlTree.InlinedFunction(pic.InlIndex).Name + parentRanges = pic.Ranges + } + + // Callee ranges contained in caller ranges? + c, m := rangesContainsAll(parentRanges, calleeRanges) + if !c { + base.Fatalf("** malformed inlined routine range in %s: caller %s callee %s II=%d %s\n", funcName, caller, callee, idx, m) + } + + // Now visit kids + for _, k := range ic.Children { + checkInlCall(funcName, inlCalls, funcSize, k, idx) + } +} + +// unifyCallRanges ensures that the ranges for a given inline +// transitively include all of the ranges for its child inlines. +func unifyCallRanges(inlcalls dwarf.InlCalls, idx int) { + ic := &inlcalls.Calls[idx] + for _, childIdx := range ic.Children { + // First make sure child ranges are unified. + unifyCallRanges(inlcalls, childIdx) + + // Then merge child ranges into ranges for this inline. + cic := inlcalls.Calls[childIdx] + ic.Ranges = dwarf.MergeRanges(ic.Ranges, cic.Ranges) + } +} diff --git a/go/src/cmd/compile/internal/dwarfgen/linenum_test.go b/go/src/cmd/compile/internal/dwarfgen/linenum_test.go new file mode 100644 index 0000000000000000000000000000000000000000..05e72c2a06f1da6c6e3ffe5b1d9c1d75666142d9 --- /dev/null +++ b/go/src/cmd/compile/internal/dwarfgen/linenum_test.go @@ -0,0 +1,105 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package dwarfgen + +import ( + "debug/dwarf" + "internal/platform" + "internal/testenv" + "io" + "runtime" + "testing" +) + +func TestIssue75249(t *testing.T) { + testenv.MustHaveGoRun(t) + t.Parallel() + + if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) { + t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH) + } + + code := ` +package main + +type Data struct { + Field1 int + Field2 *int + Field3 int + Field4 *int + Field5 int + Field6 *int + Field7 int + Field8 *int +} + +//go:noinline +func InitializeData(d *Data) { + d.Field1++ // line 16 + d.Field2 = d.Field4 + d.Field3++ + d.Field4 = d.Field6 + d.Field5++ + d.Field6 = d.Field8 + d.Field7++ + d.Field8 = d.Field2 // line 23 +} + +func main() { + var data Data + InitializeData(&data) +} +` + + _, f := gobuild(t, t.TempDir(), true, []testline{{line: code}}) + defer f.Close() + + dwarfData, err := f.DWARF() + if err != nil { + t.Fatal(err) + } + dwarfReader := dwarfData.Reader() + + for { + entry, err := dwarfReader.Next() + if err != nil { + t.Fatal(err) + } + if entry == nil { + break + } + if entry.Tag != dwarf.TagCompileUnit { + continue + } + name := entry.AttrField(dwarf.AttrName) + if name == nil || name.Class != dwarf.ClassString || name.Val != "main" { + continue + } + lr, err := dwarfData.LineReader(entry) + if err != nil { + t.Fatal(err) + } + stmts := map[int]bool{} + for { + var le dwarf.LineEntry + err := lr.Next(&le) + if err == io.EOF { + break + } + if err != nil { + t.Fatal(err) + } + if !le.IsStmt { + continue + } + stmts[le.Line] = true + } + for i := 16; i <= 23; i++ { + if !stmts[i] { + t.Errorf("missing statement at line %d", i) + } + } + } +} diff --git a/go/src/cmd/compile/internal/dwarfgen/marker.go b/go/src/cmd/compile/internal/dwarfgen/marker.go new file mode 100644 index 0000000000000000000000000000000000000000..ec6ce45a900bc098b97773ce16f1c33a5217e23f --- /dev/null +++ b/go/src/cmd/compile/internal/dwarfgen/marker.go @@ -0,0 +1,94 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package dwarfgen + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/internal/src" +) + +// A ScopeMarker tracks scope nesting and boundaries for later use +// during DWARF generation. +type ScopeMarker struct { + parents []ir.ScopeID + marks []ir.Mark +} + +// checkPos validates the given position and returns the current scope. +func (m *ScopeMarker) checkPos(pos src.XPos) ir.ScopeID { + if !pos.IsKnown() { + base.Fatalf("unknown scope position") + } + + if len(m.marks) == 0 { + return 0 + } + + last := &m.marks[len(m.marks)-1] + if xposBefore(pos, last.Pos) { + base.FatalfAt(pos, "non-monotonic scope positions\n\t%v: previous scope position", base.FmtPos(last.Pos)) + } + return last.Scope +} + +// Push records a transition to a new child scope of the current scope. +func (m *ScopeMarker) Push(pos src.XPos) { + current := m.checkPos(pos) + + m.parents = append(m.parents, current) + child := ir.ScopeID(len(m.parents)) + + m.marks = append(m.marks, ir.Mark{Pos: pos, Scope: child}) +} + +// Pop records a transition back to the current scope's parent. +func (m *ScopeMarker) Pop(pos src.XPos) { + current := m.checkPos(pos) + + parent := m.parents[current-1] + + m.marks = append(m.marks, ir.Mark{Pos: pos, Scope: parent}) +} + +// Unpush removes the current scope, which must be empty. +func (m *ScopeMarker) Unpush() { + i := len(m.marks) - 1 + current := m.marks[i].Scope + + if current != ir.ScopeID(len(m.parents)) { + base.FatalfAt(m.marks[i].Pos, "current scope is not empty") + } + + m.parents = m.parents[:current-1] + m.marks = m.marks[:i] +} + +// WriteTo writes the recorded scope marks to the given function, +// and resets the marker for reuse. +func (m *ScopeMarker) WriteTo(fn *ir.Func) { + m.compactMarks() + + fn.Parents = make([]ir.ScopeID, len(m.parents)) + copy(fn.Parents, m.parents) + m.parents = m.parents[:0] + + fn.Marks = make([]ir.Mark, len(m.marks)) + copy(fn.Marks, m.marks) + m.marks = m.marks[:0] +} + +func (m *ScopeMarker) compactMarks() { + n := 0 + for _, next := range m.marks { + if n > 0 && next.Pos == m.marks[n-1].Pos { + m.marks[n-1].Scope = next.Scope + continue + } + m.marks[n] = next + n++ + } + m.marks = m.marks[:n] +} diff --git a/go/src/cmd/compile/internal/dwarfgen/scope.go b/go/src/cmd/compile/internal/dwarfgen/scope.go new file mode 100644 index 0000000000000000000000000000000000000000..b4ae69e96fa7c4f64adca5a488286a7838f1ce8e --- /dev/null +++ b/go/src/cmd/compile/internal/dwarfgen/scope.go @@ -0,0 +1,136 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package dwarfgen + +import ( + "sort" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/internal/dwarf" + "cmd/internal/obj" + "cmd/internal/src" +) + +// See golang.org/issue/20390. +func xposBefore(p, q src.XPos) bool { + return base.Ctxt.PosTable.Pos(p).Before(base.Ctxt.PosTable.Pos(q)) +} + +func findScope(marks []ir.Mark, pos src.XPos) ir.ScopeID { + i := sort.Search(len(marks), func(i int) bool { + return xposBefore(pos, marks[i].Pos) + }) + if i == 0 { + return 0 + } + return marks[i-1].Scope +} + +func assembleScopes(fnsym *obj.LSym, fn *ir.Func, dwarfVars []*dwarf.Var, varScopes []ir.ScopeID) []dwarf.Scope { + // Initialize the DWARF scope tree based on lexical scopes. + dwarfScopes := make([]dwarf.Scope, 1+len(fn.Parents)) + for i, parent := range fn.Parents { + dwarfScopes[i+1].Parent = int32(parent) + } + + scopeVariables(dwarfVars, varScopes, dwarfScopes, fnsym.ABI() != obj.ABI0) + if fnsym.Func().Text != nil { + scopePCs(fnsym, fn.Marks, dwarfScopes) + } + return compactScopes(dwarfScopes) +} + +// scopeVariables assigns DWARF variable records to their scopes. +func scopeVariables(dwarfVars []*dwarf.Var, varScopes []ir.ScopeID, dwarfScopes []dwarf.Scope, regabi bool) { + if regabi { + sort.Stable(varsByScope{dwarfVars, varScopes}) + } else { + sort.Stable(varsByScopeAndOffset{dwarfVars, varScopes}) + } + + i0 := 0 + for i := range dwarfVars { + if varScopes[i] == varScopes[i0] { + continue + } + dwarfScopes[varScopes[i0]].Vars = dwarfVars[i0:i] + i0 = i + } + if i0 < len(dwarfVars) { + dwarfScopes[varScopes[i0]].Vars = dwarfVars[i0:] + } +} + +// scopePCs assigns PC ranges to their scopes. +func scopePCs(fnsym *obj.LSym, marks []ir.Mark, dwarfScopes []dwarf.Scope) { + // If there aren't any child scopes (in particular, when scope + // tracking is disabled), we can skip a whole lot of work. + if len(marks) == 0 { + return + } + p0 := fnsym.Func().Text + scope := findScope(marks, p0.Pos) + for p := p0; p != nil; p = p.Link { + if p.Pos == p0.Pos { + continue + } + dwarfScopes[scope].AppendRange(dwarf.Range{Start: p0.Pc, End: p.Pc}) + p0 = p + scope = findScope(marks, p0.Pos) + } + if p0.Pc < fnsym.Size { + dwarfScopes[scope].AppendRange(dwarf.Range{Start: p0.Pc, End: fnsym.Size}) + } +} + +func compactScopes(dwarfScopes []dwarf.Scope) []dwarf.Scope { + // Reverse pass to propagate PC ranges to parent scopes. + for i := len(dwarfScopes) - 1; i > 0; i-- { + s := &dwarfScopes[i] + dwarfScopes[s.Parent].UnifyRanges(s) + } + + return dwarfScopes +} + +type varsByScopeAndOffset struct { + vars []*dwarf.Var + scopes []ir.ScopeID +} + +func (v varsByScopeAndOffset) Len() int { + return len(v.vars) +} + +func (v varsByScopeAndOffset) Less(i, j int) bool { + if v.scopes[i] != v.scopes[j] { + return v.scopes[i] < v.scopes[j] + } + return v.vars[i].StackOffset < v.vars[j].StackOffset +} + +func (v varsByScopeAndOffset) Swap(i, j int) { + v.vars[i], v.vars[j] = v.vars[j], v.vars[i] + v.scopes[i], v.scopes[j] = v.scopes[j], v.scopes[i] +} + +type varsByScope struct { + vars []*dwarf.Var + scopes []ir.ScopeID +} + +func (v varsByScope) Len() int { + return len(v.vars) +} + +func (v varsByScope) Less(i, j int) bool { + return v.scopes[i] < v.scopes[j] +} + +func (v varsByScope) Swap(i, j int) { + v.vars[i], v.vars[j] = v.vars[j], v.vars[i] + v.scopes[i], v.scopes[j] = v.scopes[j], v.scopes[i] +} diff --git a/go/src/cmd/compile/internal/dwarfgen/scope_test.go b/go/src/cmd/compile/internal/dwarfgen/scope_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a8d24a697374e48cbf73531ed78ac31c1af1790a --- /dev/null +++ b/go/src/cmd/compile/internal/dwarfgen/scope_test.go @@ -0,0 +1,528 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package dwarfgen + +import ( + "cmp" + "debug/dwarf" + "fmt" + "internal/platform" + "internal/testenv" + "os" + "path/filepath" + "runtime" + "slices" + "strconv" + "strings" + "testing" + + "cmd/internal/objfile" +) + +type testline struct { + // line is one line of go source + line string + + // scopes is a list of scope IDs of all the lexical scopes that this line + // of code belongs to. + // Scope IDs are assigned by traversing the tree of lexical blocks of a + // function in pre-order + // Scope IDs are function specific, i.e. scope 0 is always the root scope + // of the function that this line belongs to. Empty scopes are not assigned + // an ID (because they are not saved in debug_info). + // Scope 0 is always omitted from this list since all lines always belong + // to it. + scopes []int + + // vars is the list of variables that belong in scopes[len(scopes)-1]. + // Local variables are prefixed with "var ", formal parameters with "arg ". + // Must be ordered alphabetically. + // Set to nil to skip the check. + vars []string + + // decl is the list of variables declared at this line. + decl []string + + // declBefore is the list of variables declared at or before this line. + declBefore []string +} + +var testfile = []testline{ + {line: "package main"}, + {line: "var sink any"}, + {line: "func f1(x int) { }"}, + {line: "func f2(x int) { }"}, + {line: "func f3(x int) { }"}, + {line: "func f4(x int) { }"}, + {line: "func f5(x int) { }"}, + {line: "func f6(x int) { }"}, + {line: "func leak(x interface{}) { sink = x }"}, + {line: "func gret1() int { return 2 }"}, + {line: "func gretbool() bool { return true }"}, + {line: "func gret3() (int, int, int) { return 0, 1, 2 }"}, + {line: "var v = []int{ 0, 1, 2 }"}, + {line: "var ch = make(chan int)"}, + {line: "var floatch = make(chan float64)"}, + {line: "var iface interface{}"}, + {line: "func TestNestedFor() {", vars: []string{"var a int"}}, + {line: " a := 0", decl: []string{"a"}}, + {line: " f1(a)"}, + {line: " for i := 0; i < 5; i++ {", scopes: []int{1}, vars: []string{"var i int"}, decl: []string{"i"}}, + {line: " f2(i)", scopes: []int{1}}, + {line: " for i := 0; i < 5; i++ {", scopes: []int{1, 2}, vars: []string{"var i int"}, decl: []string{"i"}}, + {line: " f3(i)", scopes: []int{1, 2}}, + {line: " }"}, + {line: " f4(i)", scopes: []int{1}}, + {line: " }"}, + {line: " f5(a)"}, + {line: "}"}, + {line: "func TestOas2() {", vars: []string{}}, + {line: " if a, b, c := gret3(); a != 1 {", scopes: []int{1}, vars: []string{"var a int", "var b int", "var c int"}}, + {line: " f1(a)", scopes: []int{1}}, + {line: " f1(b)", scopes: []int{1}}, + {line: " f1(c)", scopes: []int{1}}, + {line: " }"}, + {line: " for i, x := range v {", scopes: []int{2}, vars: []string{"var i int", "var x int"}}, + {line: " f1(i)", scopes: []int{2}}, + {line: " f1(x)", scopes: []int{2}}, + {line: " }"}, + {line: " if a, ok := <- ch; ok {", scopes: []int{3}, vars: []string{"var a int", "var ok bool"}}, + {line: " f1(a)", scopes: []int{3}}, + {line: " }"}, + {line: " if a, ok := iface.(int); ok {", scopes: []int{4}, vars: []string{"var a int", "var ok bool"}}, + {line: " f1(a)", scopes: []int{4}}, + {line: " }"}, + {line: "}"}, + {line: "func TestIfElse() {"}, + {line: " if x := gret1(); x != 0 {", scopes: []int{1}, vars: []string{"var x int"}}, + {line: " a := 0", scopes: []int{1, 2}, vars: []string{"var a int"}}, + {line: " f1(a); f1(x)", scopes: []int{1, 2}}, + {line: " } else {"}, + {line: " b := 1", scopes: []int{1, 3}, vars: []string{"var b int"}}, + {line: " f1(b); f1(x+1)", scopes: []int{1, 3}}, + {line: " }"}, + {line: "}"}, + {line: "func TestSwitch() {", vars: []string{}}, + {line: " switch x := gret1(); x {", scopes: []int{1}, vars: []string{"var x int"}}, + {line: " case 0:", scopes: []int{1, 2}}, + {line: " i := x + 5", scopes: []int{1, 2}, vars: []string{"var i int"}}, + {line: " f1(x); f1(i)", scopes: []int{1, 2}}, + {line: " case 1:", scopes: []int{1, 3}}, + {line: " j := x + 10", scopes: []int{1, 3}, vars: []string{"var j int"}}, + {line: " f1(x); f1(j)", scopes: []int{1, 3}}, + {line: " case 2:", scopes: []int{1, 4}}, + {line: " k := x + 2", scopes: []int{1, 4}, vars: []string{"var k int"}}, + {line: " f1(x); f1(k)", scopes: []int{1, 4}}, + {line: " }"}, + {line: "}"}, + {line: "func TestTypeSwitch() {", vars: []string{}}, + {line: " switch x := iface.(type) {"}, + {line: " case int:", scopes: []int{1}}, + {line: " f1(x)", scopes: []int{1}, vars: []string{"var x int"}}, + {line: " case uint8:", scopes: []int{2}}, + {line: " f1(int(x))", scopes: []int{2}, vars: []string{"var x uint8"}}, + {line: " case float64:", scopes: []int{3}}, + {line: " f1(int(x)+1)", scopes: []int{3}, vars: []string{"var x float64"}}, + {line: " }"}, + {line: "}"}, + {line: "func TestSelectScope() {"}, + {line: " select {"}, + {line: " case i := <- ch:", scopes: []int{1}}, + {line: " f1(i)", scopes: []int{1}, vars: []string{"var i int"}}, + {line: " case f := <- floatch:", scopes: []int{2}}, + {line: " f1(int(f))", scopes: []int{2}, vars: []string{"var f float64"}}, + {line: " }"}, + {line: "}"}, + {line: "func TestBlock() {", vars: []string{"var a int"}}, + {line: " a := 1"}, + {line: " {"}, + {line: " b := 2", scopes: []int{1}, vars: []string{"var b int"}}, + {line: " f1(b)", scopes: []int{1}}, + {line: " f1(a)", scopes: []int{1}}, + {line: " }"}, + {line: "}"}, + {line: "func TestDiscontiguousRanges() {", vars: []string{"var a int"}}, + {line: " a := 0"}, + {line: " f1(a)"}, + {line: " {"}, + {line: " b := 0", scopes: []int{1}, vars: []string{"var b int"}}, + {line: " f2(b)", scopes: []int{1}}, + {line: " if gretbool() {", scopes: []int{1}}, + {line: " c := 0", scopes: []int{1, 2}, vars: []string{"var c int"}}, + {line: " f3(c)", scopes: []int{1, 2}}, + {line: " } else {"}, + {line: " c := 1.1", scopes: []int{1, 3}, vars: []string{"var c float64"}}, + {line: " f4(int(c))", scopes: []int{1, 3}}, + {line: " }"}, + {line: " f5(b)", scopes: []int{1}}, + {line: " }"}, + {line: " f6(a)"}, + {line: "}"}, + {line: "func TestClosureScope() {", vars: []string{"var a int", "var b int", "var f func(int)"}}, + {line: " a := 1; b := 1"}, + {line: " f := func(c int) {", scopes: []int{0}, vars: []string{"arg c int", "var &b *int", "var a int", "var d int"}, declBefore: []string{"&b", "a"}}, + {line: " d := 3"}, + {line: " f1(c); f1(d)"}, + {line: " if e := 3; e != 0 {", scopes: []int{1}, vars: []string{"var e int"}}, + {line: " f1(e)", scopes: []int{1}}, + {line: " f1(a)", scopes: []int{1}}, + {line: " b = 2", scopes: []int{1}}, + {line: " }"}, + {line: " }"}, + {line: " f(3); f1(b)"}, + {line: "}"}, + {line: "func TestEscape() {"}, + {line: " a := 1", vars: []string{"var a int"}}, + {line: " {"}, + {line: " b := 2", scopes: []int{1}, vars: []string{"var &b *int", "var p *int"}}, + {line: " p := &b", scopes: []int{1}}, + {line: " f1(a)", scopes: []int{1}}, + {line: " leak(p)", scopes: []int{1}}, + {line: " }"}, + {line: "}"}, + {line: "var fglob func() int"}, + {line: "func TestCaptureVar(flag bool) {"}, + {line: " a := 1", vars: []string{"arg flag bool", "var a int"}}, // TODO(register args) restore "arg ~r1 func() int", + {line: " if flag {"}, + {line: " b := 2", scopes: []int{1}, vars: []string{"var b int", "var f func() int"}}, + {line: " f := func() int {", scopes: []int{1, 0}}, + {line: " return b + 1"}, + {line: " }"}, + {line: " fglob = f", scopes: []int{1}}, + {line: " }"}, + {line: " f1(a)"}, + {line: "}"}, + {line: "func main() {"}, + {line: " TestNestedFor()"}, + {line: " TestOas2()"}, + {line: " TestIfElse()"}, + {line: " TestSwitch()"}, + {line: " TestTypeSwitch()"}, + {line: " TestSelectScope()"}, + {line: " TestBlock()"}, + {line: " TestDiscontiguousRanges()"}, + {line: " TestClosureScope()"}, + {line: " TestEscape()"}, + {line: " TestCaptureVar(true)"}, + {line: "}"}, +} + +const detailOutput = false + +// Compiles testfile checks that the description of lexical blocks emitted +// by the linker in debug_info, for each function in the main package, +// corresponds to what we expect it to be. +func TestScopeRanges(t *testing.T) { + testenv.MustHaveGoBuild(t) + t.Parallel() + + if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) { + t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH) + } + + src, f := gobuild(t, t.TempDir(), false, testfile) + defer f.Close() + + // the compiler uses forward slashes for paths even on windows + src = strings.ReplaceAll(src, "\\", "/") + + pcln, err := f.PCLineTable() + if err != nil { + t.Fatal(err) + } + dwarfData, err := f.DWARF() + if err != nil { + t.Fatal(err) + } + dwarfReader := dwarfData.Reader() + + lines := make(map[line][]*lexblock) + + for { + entry, err := dwarfReader.Next() + if err != nil { + t.Fatal(err) + } + if entry == nil { + break + } + + if entry.Tag != dwarf.TagSubprogram { + continue + } + + name, ok := entry.Val(dwarf.AttrName).(string) + if !ok || !strings.HasPrefix(name, "main.Test") { + continue + } + + var scope lexblock + ctxt := scopexplainContext{ + dwarfData: dwarfData, + dwarfReader: dwarfReader, + scopegen: 1, + } + + readScope(&ctxt, &scope, entry) + + scope.markLines(pcln, lines) + } + + anyerror := false + for i := range testfile { + tgt := testfile[i].scopes + out := lines[line{src, i + 1}] + + if detailOutput { + t.Logf("%s // %v", testfile[i].line, out) + } + + scopesok := checkScopes(tgt, out) + if !scopesok { + t.Logf("mismatch at line %d %q: expected: %v got: %v\n", i, testfile[i].line, tgt, scopesToString(out)) + } + + varsok := true + if testfile[i].vars != nil { + if len(out) > 0 { + varsok = checkVars(testfile[i].vars, out[len(out)-1].vars) + if !varsok { + t.Logf("variable mismatch at line %d %q for scope %d: expected: %v got: %v\n", i+1, testfile[i].line, out[len(out)-1].id, testfile[i].vars, out[len(out)-1].vars) + } + for j := range testfile[i].decl { + if line := declLineForVar(out[len(out)-1].vars, testfile[i].decl[j]); line != i+1 { + t.Errorf("wrong declaration line for variable %s, expected %d got: %d", testfile[i].decl[j], i+1, line) + } + } + + for j := range testfile[i].declBefore { + if line := declLineForVar(out[len(out)-1].vars, testfile[i].declBefore[j]); line > i+1 { + t.Errorf("wrong declaration line for variable %s, expected %d (or less) got: %d", testfile[i].declBefore[j], i+1, line) + } + } + } + } + + anyerror = anyerror || !scopesok || !varsok + } + + if anyerror { + t.Fatalf("mismatched output") + } +} + +func scopesToString(v []*lexblock) string { + r := make([]string, len(v)) + for i, s := range v { + r[i] = strconv.Itoa(s.id) + } + return "[ " + strings.Join(r, ", ") + " ]" +} + +func checkScopes(tgt []int, out []*lexblock) bool { + if len(out) > 0 { + // omit scope 0 + out = out[1:] + } + if len(tgt) != len(out) { + return false + } + for i := range tgt { + if tgt[i] != out[i].id { + return false + } + } + return true +} + +func checkVars(tgt []string, out []variable) bool { + if len(tgt) != len(out) { + return false + } + for i := range tgt { + if tgt[i] != out[i].expr { + return false + } + } + return true +} + +func declLineForVar(scope []variable, name string) int { + for i := range scope { + if scope[i].name() == name { + return scope[i].declLine + } + } + return -1 +} + +type lexblock struct { + id int + ranges [][2]uint64 + vars []variable + scopes []lexblock +} + +type variable struct { + expr string + declLine int +} + +func (v *variable) name() string { + return strings.Split(v.expr, " ")[1] +} + +type line struct { + file string + lineno int +} + +type scopexplainContext struct { + dwarfData *dwarf.Data + dwarfReader *dwarf.Reader + scopegen int +} + +// readScope reads the DW_TAG_lexical_block or the DW_TAG_subprogram in +// entry and writes a description in scope. +// Nested DW_TAG_lexical_block entries are read recursively. +func readScope(ctxt *scopexplainContext, scope *lexblock, entry *dwarf.Entry) { + var err error + scope.ranges, err = ctxt.dwarfData.Ranges(entry) + if err != nil { + panic(err) + } + for { + e, err := ctxt.dwarfReader.Next() + if err != nil { + panic(err) + } + switch e.Tag { + case 0: + slices.SortFunc(scope.vars, func(a, b variable) int { + return cmp.Compare(a.expr, b.expr) + }) + return + case dwarf.TagFormalParameter: + typ, err := ctxt.dwarfData.Type(e.Val(dwarf.AttrType).(dwarf.Offset)) + if err != nil { + panic(err) + } + scope.vars = append(scope.vars, entryToVar(e, "arg", typ)) + case dwarf.TagVariable: + typ, err := ctxt.dwarfData.Type(e.Val(dwarf.AttrType).(dwarf.Offset)) + if err != nil { + panic(err) + } + scope.vars = append(scope.vars, entryToVar(e, "var", typ)) + case dwarf.TagLexDwarfBlock: + scope.scopes = append(scope.scopes, lexblock{id: ctxt.scopegen}) + ctxt.scopegen++ + readScope(ctxt, &scope.scopes[len(scope.scopes)-1], e) + } + } +} + +func entryToVar(e *dwarf.Entry, kind string, typ dwarf.Type) variable { + return variable{ + fmt.Sprintf("%s %s %s", kind, e.Val(dwarf.AttrName).(string), typ.String()), + int(e.Val(dwarf.AttrDeclLine).(int64)), + } +} + +// markLines marks all lines that belong to this scope with this scope +// Recursively calls markLines for all children scopes. +func (scope *lexblock) markLines(pcln objfile.Liner, lines map[line][]*lexblock) { + for _, r := range scope.ranges { + for pc := r[0]; pc < r[1]; pc++ { + file, lineno, _ := pcln.PCToLine(pc) + l := line{file, lineno} + if len(lines[l]) == 0 || lines[l][len(lines[l])-1] != scope { + lines[l] = append(lines[l], scope) + } + } + } + + for i := range scope.scopes { + scope.scopes[i].markLines(pcln, lines) + } +} + +func gobuild(t *testing.T, dir string, optimized bool, testfile []testline) (string, *objfile.File) { + src := filepath.Join(dir, "test.go") + dst := filepath.Join(dir, "out.o") + + f, err := os.Create(src) + if err != nil { + t.Fatal(err) + } + for i := range testfile { + f.Write([]byte(testfile[i].line)) + f.Write([]byte{'\n'}) + } + f.Close() + + args := []string{"build"} + if !optimized { + args = append(args, "-gcflags=-N -l") + } + args = append(args, "-o", dst, src) + + cmd := testenv.Command(t, testenv.GoToolPath(t), args...) + if b, err := cmd.CombinedOutput(); err != nil { + t.Logf("build: %s\n", string(b)) + t.Fatal(err) + } + + pkg, err := objfile.Open(dst) + if err != nil { + t.Fatal(err) + } + return src, pkg +} + +// TestEmptyDwarfRanges tests that no list entry in debug_ranges has start == end. +// See issue #23928. +func TestEmptyDwarfRanges(t *testing.T) { + testenv.MustHaveGoRun(t) + t.Parallel() + + if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) { + t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH) + } + + _, f := gobuild(t, t.TempDir(), true, []testline{{line: "package main"}, {line: "func main(){ println(\"hello\") }"}}) + defer f.Close() + + dwarfData, err := f.DWARF() + if err != nil { + t.Fatal(err) + } + dwarfReader := dwarfData.Reader() + + for { + entry, err := dwarfReader.Next() + if err != nil { + t.Fatal(err) + } + if entry == nil { + break + } + + ranges, err := dwarfData.Ranges(entry) + if err != nil { + t.Fatal(err) + } + if ranges == nil { + continue + } + + for _, rng := range ranges { + if rng[0] == rng[1] { + t.Errorf("range entry with start == end: %v", rng) + } + } + } +} diff --git a/go/src/cmd/compile/internal/escape/alias.go b/go/src/cmd/compile/internal/escape/alias.go new file mode 100644 index 0000000000000000000000000000000000000000..f0351e8f67144140b99a9e0c46887c857b9e153a --- /dev/null +++ b/go/src/cmd/compile/internal/escape/alias.go @@ -0,0 +1,528 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package escape + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/internal/src" + "fmt" + "maps" + "path/filepath" +) + +type aliasAnalysis struct { + // fn is the function being analyzed. + fn *ir.Func + + // candidateSlices are declared slices that + // start unaliased and might still be unaliased. + candidateSlices map[*ir.Name]candidateSlice + + // noAliasAppends are appends that have been + // proven to use an unaliased slice. + noAliasAppends []*ir.CallExpr + + // loops is a stack of observed loops, + // each with a list of candidate appends. + loops [][]candidateAppend + + // State for optional validation checking (doubleCheck mode): + processed map[ir.Node]int // count of times each node was processed, for doubleCheck mode + doubleCheck bool // whether to do doubleCheck mode +} + +// candidateSlice tracks information about a declared slice +// that might be unaliased. +type candidateSlice struct { + loopDepth int // depth of loop when slice was declared +} + +// candidateAppend tracks information about an OAPPEND that +// might be using an unaliased slice. +type candidateAppend struct { + s *ir.Name // the slice argument in 's = append(s, ...)' + call *ir.CallExpr // the append call +} + +// aliasAnalysis looks for specific patterns of slice usage and proves +// that certain appends are operating on non-aliased slices. +// +// This allows us to emit calls to free the backing arrays for certain +// non-aliased slices at runtime when we know the memory is logically dead. +// +// The analysis is conservative, giving up on any operation we do not +// explicitly understand. +func (aa *aliasAnalysis) analyze(fn *ir.Func) { + // Walk the function body to discover slice declarations, their uses, + // and any append that we can prove is using an unaliased slice. + // + // An example is: + // + // var s []T + // for _, v := range input { + // f() + // s = append(s, g(v)) // s cannot be aliased here + // h() + // } + // return s + // + // Here, we can prove that the append to s is operating on an unaliased slice, + // and that conclusion is unaffected by s later being returned and escaping. + // + // In contrast, in this example, the aliasing of s in the loop body means the + // append can be operating on an aliased slice, so we do not record s as unaliased: + // + // var s []T + // var alias []T + // for _, v := range input { + // s = append(s, v) // s is aliased on second pass through loop body + // alias = s + // } + // + // Arbitrary uses of s after an append do not affect the aliasing conclusion + // for that append, but only if the append cannot be revisited at execution time + // via a loop or goto. + // + // We track the loop depth when a slice was declared and verify all uses of a slice + // are non-aliasing until we return to that depth. In other words, we make sure + // we have processed any possible execution-time revisiting of the slice prior + // to making our final determination. + // + // This approach helps for example with nested loops, such as: + // + // var s []int + // for range 10 { + // for range 10 { + // s = append(s, 0) // s is proven as non-aliased here + // } + // } + // alias = s // both loops are complete + // + // Or in contrast: + // + // var s []int + // for range 10 { + // for range 10 { + // s = append(s, 0) // s is treated as aliased here + // } + // alias = s // aliased, and outermost loop cycles back + // } + // + // As we walk the function, we look for things like: + // + // 1. Slice declarations (currently supporting 'var s []T', 's := make([]T, ...)', + // and 's := []T{...}'). + // 2. Appends to a slice of the form 's = append(s, ...)'. + // 3. Other uses of the slice, which we treat as potential aliasing outside + // of a few known safe cases. + // 4. A start of a loop, which we track in a stack so that + // any uses of a slice within a loop body are treated as potential + // aliasing, including statements in the loop body after an append. + // Candidate appends are stored in the loop stack at the loop depth of their + // corresponding slice declaration (rather than the loop depth of the append), + // which essentially postpones a decision about the candidate append. + // 5. An end of a loop, which pops the loop stack and allows us to + // conclusively treat candidate appends from the loop body based + // on the loop depth of the slice declaration. + // + // Note that as we pop a candidate append at the end of a loop, we know + // its corresponding slice was unaliased throughout the loop being popped + // if the slice is still in the candidate slice map (without having been + // removed for potential aliasing), and we know we can make a final decision + // about a candidate append if we have returned to the loop depth + // where its slice was declared. In other words, there is no unanalyzed + // control flow that could take us back at execution-time to the + // candidate append in the now analyzed loop. This helps for example + // with nested loops, such as in our examples just above. + // + // We give up on a particular candidate slice if we see any use of it + // that we don't explicitly understand, and we give up on all of + // our candidate slices if we see any goto or label, which could be + // unstructured control flow. (TODO(thepudds): we remove the goto/label + // restriction in a subsequent CL.) + // + // Note that the intended use is to indicate that a slice is safe to pass + // to runtime.freegc, which currently requires that the passed pointer + // point to the base of its heap object. + // + // Therefore, we currently do not allow any re-slicing of the slice, though we could + // potentially allow s[0:x] or s[:x] or similar. (Slice expressions that alter + // the capacity might be possible to allow with freegc changes, though they are + // currently disallowed here like all slice expressions). + // + // TODO(thepudds): we could support the slice being used as non-escaping function call parameter + // but to do that, we need to verify any creation of specials via user code triggers an escape, + // or mail better runtime.freegc support for specials, or have a temporary compile-time solution + // for specials. (Currently, this analysis side-steps specials because any use of a slice + // that might cause a user-created special will cause it to be treated as aliased, and + // separately, runtime.freegc handles profiling-related specials). + + // Initialize. + aa.fn = fn + aa.candidateSlices = make(map[*ir.Name]candidateSlice) // slices that might be unaliased + + // doubleCheck controls whether we do a sanity check of our processing logic + // by counting each node visited in our main pass, and then comparing those counts + // against a simple walk at the end. The main intent is to help catch missing + // any nodes squirreled away in some spot we forgot to examine in our main pass. + aa.doubleCheck = base.Debug.EscapeAliasCheck > 0 + aa.processed = make(map[ir.Node]int) + + if base.Debug.EscapeAlias >= 2 { + aa.diag(fn.Pos(), fn, "====== starting func", "======") + } + + ir.DoChildren(fn, aa.visit) + + for _, call := range aa.noAliasAppends { + if base.Debug.EscapeAlias >= 1 { + base.WarnfAt(call.Pos(), "alias analysis: append using non-aliased slice: %v in func %v", + call, fn) + } + if base.Debug.FreeAppend > 0 { + call.AppendNoAlias = true + } + } + + if aa.doubleCheck { + doubleCheckProcessed(fn, aa.processed) + } +} + +func (aa *aliasAnalysis) visit(n ir.Node) bool { + if n == nil { + return false + } + + if base.Debug.EscapeAlias >= 3 { + fmt.Printf("%-25s alias analysis: visiting node: %12s %-18T %v\n", + fmtPosShort(n.Pos())+":", n.Op().String(), n, n) + } + + // As we visit nodes, we want to ensure we handle all children + // without missing any (through ignorance or future changes). + // We do this by counting nodes as we visit them or otherwise + // declare a node to be fully processed. + // + // In particular, we want to ensure we don't miss the use + // of a slice in some expression that might be an aliasing usage. + // + // When doubleCheck is enabled, we compare the counts + // accumulated in our analysis against counts from a trivial walk, + // failing if there is any mismatch. + // + // This call here counts that we have visited this node n + // via our main visit method. (In contrast, some nodes won't + // be visited by the main visit method, but instead will be + // manually marked via countProcessed when we believe we have fully + // dealt with the node). + aa.countProcessed(n) + + switch n.Op() { + case ir.ODCL: + decl := n.(*ir.Decl) + + if decl.X != nil && decl.X.Type().IsSlice() && decl.X.Class == ir.PAUTO { + s := decl.X + if _, ok := aa.candidateSlices[s]; ok { + base.FatalfAt(n.Pos(), "candidate slice already tracked as candidate: %v", s) + } + if base.Debug.EscapeAlias >= 2 { + aa.diag(n.Pos(), s, "adding candidate slice", "(loop depth: %d)", len(aa.loops)) + } + aa.candidateSlices[s] = candidateSlice{loopDepth: len(aa.loops)} + } + // No children aside from the declared ONAME. + aa.countProcessed(decl.X) + return false + + case ir.ONAME: + + // We are seeing a name we have not already handled in another case, + // so remove any corresponding candidate slice. + if n.Type().IsSlice() { + name := n.(*ir.Name) + _, ok := aa.candidateSlices[name] + if ok { + delete(aa.candidateSlices, name) + if base.Debug.EscapeAlias >= 2 { + aa.diag(n.Pos(), name, "removing candidate slice", "") + } + } + } + // No children. + return false + + case ir.OAS2: + n := n.(*ir.AssignListStmt) + aa.analyzeAssign(n, n.Lhs, n.Rhs) + return false + + case ir.OAS: + assign := n.(*ir.AssignStmt) + aa.analyzeAssign(n, []ir.Node{assign.X}, []ir.Node{assign.Y}) + return false + + case ir.OFOR, ir.ORANGE: + aa.visitList(n.Init()) + + if n.Op() == ir.ORANGE { + // TODO(thepudds): previously we visited this range expression + // in the switch just below, after pushing the loop. This current placement + // is more correct, but generate a test or find an example in stdlib or similar + // where it matters. (Our current tests do not complain.) + aa.visit(n.(*ir.RangeStmt).X) + } + + // Push a new loop. + aa.loops = append(aa.loops, nil) + + // Process the loop. + switch n.Op() { + case ir.OFOR: + forstmt := n.(*ir.ForStmt) + aa.visit(forstmt.Cond) + aa.visitList(forstmt.Body) + aa.visit(forstmt.Post) + case ir.ORANGE: + rangestmt := n.(*ir.RangeStmt) + aa.visit(rangestmt.Key) + aa.visit(rangestmt.Value) + aa.visitList(rangestmt.Body) + default: + base.Fatalf("loop not OFOR or ORANGE: %v", n) + } + + // Pop the loop. + var candidateAppends []candidateAppend + candidateAppends, aa.loops = aa.loops[len(aa.loops)-1], aa.loops[:len(aa.loops)-1] + for _, a := range candidateAppends { + // We are done with the loop, so we can validate any candidate appends + // that have not had their slice removed yet. We know a slice is unaliased + // throughout the loop if the slice is still in the candidate slice map. + if cs, ok := aa.candidateSlices[a.s]; ok { + if cs.loopDepth == len(aa.loops) { + // We've returned to the loop depth where the slice was declared and + // hence made it all the way through any loops that started after + // that declaration. + if base.Debug.EscapeAlias >= 2 { + aa.diag(n.Pos(), a.s, "proved non-aliased append", + "(completed loop, decl at depth: %d)", cs.loopDepth) + } + aa.noAliasAppends = append(aa.noAliasAppends, a.call) + } else if cs.loopDepth < len(aa.loops) { + if base.Debug.EscapeAlias >= 2 { + aa.diag(n.Pos(), a.s, "cannot prove non-aliased append", + "(completed loop, decl at depth: %d)", cs.loopDepth) + } + } else { + panic("impossible: candidate slice loopDepth > current loop depth") + } + } + } + return false + + case ir.OLEN, ir.OCAP: + n := n.(*ir.UnaryExpr) + if n.X.Op() == ir.ONAME { + // This does not disqualify a candidate slice. + aa.visitList(n.Init()) + aa.countProcessed(n.X) + } else { + ir.DoChildren(n, aa.visit) + } + return false + + case ir.OCLOSURE: + // Give up on all our in-progress slices. + closure := n.(*ir.ClosureExpr) + if base.Debug.EscapeAlias >= 2 { + aa.diag(n.Pos(), closure.Func, "clearing all in-progress slices due to OCLOSURE", + "(was %d in-progress slices)", len(aa.candidateSlices)) + } + clear(aa.candidateSlices) + return ir.DoChildren(n, aa.visit) + + case ir.OLABEL, ir.OGOTO: + // Give up on all our in-progress slices. + if base.Debug.EscapeAlias >= 2 { + aa.diag(n.Pos(), n, "clearing all in-progress slices due to label or goto", + "(was %d in-progress slices)", len(aa.candidateSlices)) + } + clear(aa.candidateSlices) + return false + + default: + return ir.DoChildren(n, aa.visit) + } +} + +func (aa *aliasAnalysis) visitList(nodes []ir.Node) { + for _, n := range nodes { + aa.visit(n) + } +} + +// analyzeAssign evaluates the assignment dsts... = srcs... +// +// assign is an *ir.AssignStmt or *ir.AssignListStmt. +func (aa *aliasAnalysis) analyzeAssign(assign ir.Node, dsts, srcs []ir.Node) { + aa.visitList(assign.Init()) + for i := range dsts { + dst := dsts[i] + src := srcs[i] + + if dst.Op() != ir.ONAME || !dst.Type().IsSlice() { + // Nothing for us to do aside from visiting the remaining children. + aa.visit(dst) + aa.visit(src) + continue + } + + // We have a slice being assigned to an ONAME. + + // Check for simple zero value assignments to an ONAME, which we ignore. + if src == nil { + aa.countProcessed(dst) + continue + } + + if base.Debug.EscapeAlias >= 4 { + srcfn := "" + if src.Op() == ir.ONAME { + srcfn = fmt.Sprintf("%v.", src.Name().Curfn) + } + aa.diag(assign.Pos(), assign, "visiting slice assignment", "%v.%v = %s%v (%s %T = %s %T)", + dst.Name().Curfn, dst, srcfn, src, dst.Op().String(), dst, src.Op().String(), src) + } + + // Now check what we have on the RHS. + switch src.Op() { + // Cases: + + // Check for s := make([]T, ...) or s := []T{...}, along with the '=' version + // of those which does not alias s as long as s is not used in the make. + // + // TODO(thepudds): we need to be sure that 's := []T{1,2,3}' does not end up backed by a + // global static. Ad-hoc testing indicates that example and similar seem to be + // stack allocated, but that was not exhaustive testing. We do have runtime.freegc + // able to throw if it finds a global static, but should test more. + // + // TODO(thepudds): could also possibly allow 's := append([]T(nil), ...)' + // and 's := append([]T{}, ...)'. + case ir.OMAKESLICE, ir.OSLICELIT: + name := dst.(*ir.Name) + if name.Class == ir.PAUTO { + if base.Debug.EscapeAlias > 1 { + aa.diag(assign.Pos(), assign, "assignment from make or slice literal", "") + } + // If this is Def=true, the ODCL in the init will causes this to be tracked + // as a candidate slice. We walk the init and RHS but avoid visiting the name + // in the LHS, which would remove the slice from the candidate list after it + // was just added. + aa.visit(src) + aa.countProcessed(name) + continue + } + + // Check for s = append(s, <...>). + case ir.OAPPEND: + s := dst.(*ir.Name) + call := src.(*ir.CallExpr) + if call.Args[0] == s { + // Matches s = append(s, <...>). + // First visit other arguments in case they use s. + aa.visitList(call.Args[1:]) + // Mark the call as processed, and s twice. + aa.countProcessed(s, call, s) + + // We have now examined all non-ONAME children of assign. + + // This is now the heart of the analysis. + // Check to see if this slice is a live candidate. + cs, ok := aa.candidateSlices[s] + if ok { + if cs.loopDepth == len(aa.loops) { + // No new loop has started after the declaration of s, + // so this is definitive. + if base.Debug.EscapeAlias >= 2 { + aa.diag(assign.Pos(), assign, "proved non-aliased append", + "(loop depth: %d, equals decl depth)", len(aa.loops)) + } + aa.noAliasAppends = append(aa.noAliasAppends, call) + } else if cs.loopDepth < len(aa.loops) { + // A new loop has started since the declaration of s, + // so we can't validate this append yet, but + // remember it in case we can validate it later when + // all loops using s are done. + aa.loops[cs.loopDepth] = append(aa.loops[cs.loopDepth], + candidateAppend{s: s, call: call}) + } else { + panic("impossible: candidate slice loopDepth > current loop depth") + } + } + continue + } + } // End of switch on src.Op(). + + // Reached bottom of the loop over assignments. + // If we get here, we need to visit the dst and src normally. + aa.visit(dst) + aa.visit(src) + } +} + +func (aa *aliasAnalysis) countProcessed(nodes ...ir.Node) { + if aa.doubleCheck { + for _, n := range nodes { + aa.processed[n]++ + } + } +} + +func (aa *aliasAnalysis) diag(pos src.XPos, n ir.Node, what string, format string, args ...any) { + fmt.Printf("%-25s alias analysis: %-30s %-20s %s\n", + fmtPosShort(pos)+":", + what+":", + fmt.Sprintf("%v", n), + fmt.Sprintf(format, args...)) +} + +// doubleCheckProcessed does a sanity check for missed nodes in our visit. +func doubleCheckProcessed(fn *ir.Func, processed map[ir.Node]int) { + // Do a trivial walk while counting the nodes + // to compare against the counts in processed. + + observed := make(map[ir.Node]int) + var walk func(n ir.Node) bool + walk = func(n ir.Node) bool { + observed[n]++ + return ir.DoChildren(n, walk) + } + ir.DoChildren(fn, walk) + + if !maps.Equal(processed, observed) { + // The most likely mistake might be something was missed while building processed, + // so print extra details in that direction. + for n, observedCount := range observed { + processedCount, ok := processed[n] + if processedCount != observedCount || !ok { + base.WarnfAt(n.Pos(), + "alias analysis: mismatch for %T: %v: processed %d times, observed %d times", + n, n, processedCount, observedCount) + } + } + base.FatalfAt(fn.Pos(), "alias analysis: mismatch in visited nodes") + } +} + +func fmtPosShort(xpos src.XPos) string { + // TODO(thepudds): I think I did this a simpler way a while ago? Or maybe add base.FmtPosShort + // or similar? Or maybe just use base.FmtPos and give up on nicely aligned log messages? + pos := base.Ctxt.PosTable.Pos(xpos) + shortLine := filepath.Base(pos.AbsFilename()) + ":" + pos.LineNumber() + return shortLine +} diff --git a/go/src/cmd/compile/internal/escape/assign.go b/go/src/cmd/compile/internal/escape/assign.go new file mode 100644 index 0000000000000000000000000000000000000000..6af53886831a1ebaebe3a14ad79f2601e3b00d95 --- /dev/null +++ b/go/src/cmd/compile/internal/escape/assign.go @@ -0,0 +1,128 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package escape + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" +) + +// addr evaluates an addressable expression n and returns a hole +// that represents storing into the represented location. +func (e *escape) addr(n ir.Node) hole { + if n == nil || ir.IsBlank(n) { + // Can happen in select case, range, maybe others. + return e.discardHole() + } + + k := e.heapHole() + + switch n.Op() { + default: + base.Fatalf("unexpected addr: %v", n) + case ir.ONAME: + n := n.(*ir.Name) + if n.Class == ir.PEXTERN { + break + } + k = e.oldLoc(n).asHole() + case ir.OLINKSYMOFFSET: + break + case ir.ODOT: + n := n.(*ir.SelectorExpr) + k = e.addr(n.X) + case ir.OINDEX: + n := n.(*ir.IndexExpr) + e.discard(n.Index) + if n.X.Type().IsArray() { + k = e.addr(n.X) + } else { + e.mutate(n.X) + } + case ir.ODEREF: + n := n.(*ir.StarExpr) + e.mutate(n.X) + case ir.ODOTPTR: + n := n.(*ir.SelectorExpr) + e.mutate(n.X) + case ir.OINDEXMAP: + n := n.(*ir.IndexExpr) + e.discard(n.X) + e.assignHeap(n.Index, "key of map put", n) + } + + return k +} + +func (e *escape) mutate(n ir.Node) { + e.expr(e.mutatorHole(), n) +} + +func (e *escape) addrs(l ir.Nodes) []hole { + var ks []hole + for _, n := range l { + ks = append(ks, e.addr(n)) + } + return ks +} + +func (e *escape) assignHeap(src ir.Node, why string, where ir.Node) { + e.expr(e.heapHole().note(where, why), src) +} + +// assignList evaluates the assignment dsts... = srcs.... +func (e *escape) assignList(dsts, srcs []ir.Node, why string, where ir.Node) { + ks := e.addrs(dsts) + for i, k := range ks { + var src ir.Node + if i < len(srcs) { + src = srcs[i] + } + + if dst := dsts[i]; dst != nil { + // Detect implicit conversion of uintptr to unsafe.Pointer when + // storing into reflect.{Slice,String}Header. + if dst.Op() == ir.ODOTPTR && ir.IsReflectHeaderDataField(dst) { + e.unsafeValue(e.heapHole().note(where, why), src) + continue + } + + // Filter out some no-op assignments for escape analysis. + if src != nil && isSelfAssign(dst, src) { + if base.Flag.LowerM != 0 { + base.WarnfAt(where.Pos(), "%v ignoring self-assignment in %v", e.curfn, where) + } + k = e.discardHole() + } + } + + e.expr(k.note(where, why), src) + } + + e.reassigned(ks, where) +} + +// reassigned marks the locations associated with the given holes as +// reassigned, unless the location represents a variable declared and +// assigned exactly once by where. +func (e *escape) reassigned(ks []hole, where ir.Node) { + if as, ok := where.(*ir.AssignStmt); ok && as.Op() == ir.OAS && as.Y == nil { + if dst, ok := as.X.(*ir.Name); ok && dst.Op() == ir.ONAME && dst.Defn == nil { + // Zero-value assignment for variable declared without an + // explicit initial value. Assume this is its initialization + // statement. + return + } + } + + for _, k := range ks { + loc := k.dst + // Variables declared by range statements are assigned on every iteration. + if n, ok := loc.n.(*ir.Name); ok && n.Defn == where && where.Op() != ir.ORANGE { + continue + } + loc.reassigned = true + } +} diff --git a/go/src/cmd/compile/internal/escape/call.go b/go/src/cmd/compile/internal/escape/call.go new file mode 100644 index 0000000000000000000000000000000000000000..f9d34630346024ec1b89b03adffd9e7128198a21 --- /dev/null +++ b/go/src/cmd/compile/internal/escape/call.go @@ -0,0 +1,425 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package escape + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/src" + "strings" +) + +// call evaluates a call expressions, including builtin calls. ks +// should contain the holes representing where the function callee's +// results flows. +func (e *escape) call(ks []hole, call ir.Node) { + argument := func(k hole, arg ir.Node) { + // TODO(mdempsky): Should be "call argument". + e.expr(k.note(call, "call parameter"), arg) + } + + switch call.Op() { + default: + ir.Dump("esc", call) + base.Fatalf("unexpected call op: %v", call.Op()) + + case ir.OCALLFUNC, ir.OCALLINTER: + call := call.(*ir.CallExpr) + typecheck.AssertFixedCall(call) + + // Pick out the function callee, if statically known. + // + // TODO(mdempsky): Change fn from *ir.Name to *ir.Func, but some + // functions (e.g., runtime builtins, method wrappers, generated + // eq/hash functions) don't have it set. Investigate whether + // that's a concern. + var fn *ir.Name + switch call.Op() { + case ir.OCALLFUNC: + // TODO(thepudds): use an ir.ReassignOracle here. + v := ir.StaticValue(call.Fun) + fn = ir.StaticCalleeName(v) + } + + // argumentParam handles escape analysis of assigning a call + // argument to its corresponding parameter. + argumentParam := func(param *types.Field, arg ir.Node) { + e.rewriteArgument(arg, call, fn) + argument(e.tagHole(ks, fn, param), arg) + } + + if call.IsCompilerVarLive { + // Don't escape compiler-inserted KeepAlive. + argumentParam = func(param *types.Field, arg ir.Node) { + argument(e.discardHole(), arg) + } + } + + fntype := call.Fun.Type() + if fn != nil { + fntype = fn.Type() + } + + if ks != nil && fn != nil && e.inMutualBatch(fn) { + for i, result := range fn.Type().Results() { + e.expr(ks[i], result.Nname.(*ir.Name)) + } + } + + var recvArg ir.Node + if call.Op() == ir.OCALLFUNC { + // Evaluate callee function expression. + calleeK := e.discardHole() + if fn == nil { // unknown callee + for _, k := range ks { + if k.dst != &e.blankLoc { + // The results flow somewhere, but we don't statically + // know the callee function. If a closure flows here, we + // need to conservatively assume its results might flow to + // the heap. + calleeK = e.calleeHole().note(call, "callee operand") + break + } + } + } + e.expr(calleeK, call.Fun) + } else { + recvArg = call.Fun.(*ir.SelectorExpr).X + } + + // internal/abi.EscapeNonString forces its argument to be on + // the heap, if it contains a non-string pointer. + // This is used in hash/maphash.Comparable, where we cannot + // hash pointers to local variables, as the address of the + // local variable might change on stack growth. + // Strings are okay as the hash depends on only the content, + // not the pointer. + // This is also used in unique.clone, to model the data flow + // edge on the value with strings excluded, because strings + // are cloned (by content). + // The actual call we match is + // internal/abi.EscapeNonString[go.shape.T](dict, go.shape.T) + if fn != nil && fn.Sym().Pkg.Path == "internal/abi" && strings.HasPrefix(fn.Sym().Name, "EscapeNonString[") { + ps := fntype.Params() + if len(ps) == 2 && ps[1].Type.IsShape() { + if !hasNonStringPointers(ps[1].Type) { + argumentParam = func(param *types.Field, arg ir.Node) { + argument(e.discardHole(), arg) + } + } else { + argumentParam = func(param *types.Field, arg ir.Node) { + argument(e.heapHole(), arg) + } + } + } + } + + args := call.Args + if recvParam := fntype.Recv(); recvParam != nil { + if recvArg == nil { + // Function call using method expression. Receiver argument is + // at the front of the regular arguments list. + recvArg, args = args[0], args[1:] + } + + argumentParam(recvParam, recvArg) + } + + for i, param := range fntype.Params() { + argumentParam(param, args[i]) + } + + case ir.OINLCALL: + call := call.(*ir.InlinedCallExpr) + e.stmts(call.Body) + for i, result := range call.ReturnVars { + k := e.discardHole() + if ks != nil { + k = ks[i] + } + e.expr(k, result) + } + + case ir.OAPPEND: + call := call.(*ir.CallExpr) + args := call.Args + + // Appendee slice may flow directly to the result, if + // it has enough capacity. Alternatively, a new heap + // slice might be allocated, and all slice elements + // might flow to heap. + appendeeK := e.teeHole(ks[0], e.mutatorHole()) + if args[0].Type().Elem().HasPointers() { + appendeeK = e.teeHole(appendeeK, e.heapHole().deref(call, "appendee slice")) + } + argument(appendeeK, args[0]) + + if call.IsDDD { + appendedK := e.discardHole() + if args[1].Type().IsSlice() && args[1].Type().Elem().HasPointers() { + appendedK = e.heapHole().deref(call, "appended slice...") + } + argument(appendedK, args[1]) + } else { + for i := 1; i < len(args); i++ { + argument(e.heapHole(), args[i]) + } + } + e.discard(call.RType) + + // Model the new backing store that might be allocated by append. + // Its address flows to the result. + // Users of escape analysis can look at the escape information for OAPPEND + // and use that to decide where to allocate the backing store. + backingStore := e.spill(ks[0], call) + // As we have a boolean to prevent reuse, we can treat these allocations as outside any loops. + backingStore.dst.loopDepth = 0 + + case ir.OCOPY: + call := call.(*ir.BinaryExpr) + argument(e.mutatorHole(), call.X) + + copiedK := e.discardHole() + if call.Y.Type().IsSlice() && call.Y.Type().Elem().HasPointers() { + copiedK = e.heapHole().deref(call, "copied slice") + } + argument(copiedK, call.Y) + e.discard(call.RType) + + case ir.OPANIC: + call := call.(*ir.UnaryExpr) + argument(e.heapHole(), call.X) + + case ir.OCOMPLEX: + call := call.(*ir.BinaryExpr) + e.discard(call.X) + e.discard(call.Y) + + case ir.ODELETE, ir.OPRINT, ir.OPRINTLN, ir.ORECOVER: + call := call.(*ir.CallExpr) + for _, arg := range call.Args { + e.discard(arg) + } + e.discard(call.RType) + + case ir.OMIN, ir.OMAX: + call := call.(*ir.CallExpr) + for _, arg := range call.Args { + argument(ks[0], arg) + } + e.discard(call.RType) + + case ir.OLEN, ir.OCAP, ir.OREAL, ir.OIMAG, ir.OCLOSE: + call := call.(*ir.UnaryExpr) + e.discard(call.X) + + case ir.OCLEAR: + call := call.(*ir.UnaryExpr) + argument(e.mutatorHole(), call.X) + + case ir.OUNSAFESTRINGDATA, ir.OUNSAFESLICEDATA: + call := call.(*ir.UnaryExpr) + argument(ks[0], call.X) + + case ir.OUNSAFEADD, ir.OUNSAFESLICE, ir.OUNSAFESTRING: + call := call.(*ir.BinaryExpr) + argument(ks[0], call.X) + e.discard(call.Y) + e.discard(call.RType) + } +} + +// goDeferStmt analyzes a "go" or "defer" statement. +func (e *escape) goDeferStmt(n *ir.GoDeferStmt) { + k := e.heapHole() + if n.Op() == ir.ODEFER && e.loopDepth == 1 && n.DeferAt == nil { + // Top-level defer arguments don't escape to the heap, + // but they do need to last until they're invoked. + k = e.later(e.discardHole()) + + // force stack allocation of defer record, unless + // open-coded defers are used (see ssa.go) + n.SetEsc(ir.EscNever) + } + + // If the function is already a zero argument/result function call, + // just escape analyze it normally. + // + // Note that the runtime is aware of this optimization for + // "go" statements that start in reflect.makeFuncStub or + // reflect.methodValueCall. + + call, ok := n.Call.(*ir.CallExpr) + if !ok || call.Op() != ir.OCALLFUNC { + base.FatalfAt(n.Pos(), "expected function call: %v", n.Call) + } + if sig := call.Fun.Type(); sig.NumParams()+sig.NumResults() != 0 { + base.FatalfAt(n.Pos(), "expected signature without parameters or results: %v", sig) + } + + if clo, ok := call.Fun.(*ir.ClosureExpr); ok && n.Op() == ir.OGO { + clo.IsGoWrap = true + } + + e.expr(k, call.Fun) +} + +// rewriteArgument rewrites the argument arg of the given call expression. +// fn is the static callee function, if known. +func (e *escape) rewriteArgument(arg ir.Node, call *ir.CallExpr, fn *ir.Name) { + if fn == nil || fn.Func == nil { + return + } + pragma := fn.Func.Pragma + if pragma&(ir.UintptrKeepAlive|ir.UintptrEscapes) == 0 { + return + } + + // unsafeUintptr rewrites "uintptr(ptr)" arguments to syscall-like + // functions, so that ptr is kept alive and/or escaped as + // appropriate. unsafeUintptr also reports whether it modified arg0. + unsafeUintptr := func(arg ir.Node) { + // If the argument is really a pointer being converted to uintptr, + // arrange for the pointer to be kept alive until the call + // returns, by copying it into a temp and marking that temp still + // alive when we pop the temp stack. + conv, ok := arg.(*ir.ConvExpr) + if !ok || conv.Op() != ir.OCONVNOP { + return // not a conversion + } + if !conv.X.Type().IsUnsafePtr() || !conv.Type().IsUintptr() { + return // not an unsafe.Pointer->uintptr conversion + } + + // Create and declare a new pointer-typed temp variable. + // + // TODO(mdempsky): This potentially violates the Go spec's order + // of evaluations, by evaluating arg.X before any other + // operands. + tmp := e.copyExpr(conv.Pos(), conv.X, call.PtrInit()) + conv.X = tmp + + k := e.mutatorHole() + if pragma&ir.UintptrEscapes != 0 { + k = e.heapHole().note(conv, "//go:uintptrescapes") + } + e.flow(k, e.oldLoc(tmp)) + + if pragma&ir.UintptrKeepAlive != 0 { + tmp.SetAddrtaken(true) // ensure SSA keeps the tmp variable + call.KeepAlive = append(call.KeepAlive, tmp) + } + } + + // For variadic functions, the compiler has already rewritten: + // + // f(a, b, c) + // + // to: + // + // f([]T{a, b, c}...) + // + // So we need to look into slice elements to handle uintptr(ptr) + // arguments to variadic syscall-like functions correctly. + if arg.Op() == ir.OSLICELIT { + list := arg.(*ir.CompLitExpr).List + for _, el := range list { + if el.Op() == ir.OKEY { + el = el.(*ir.KeyExpr).Value + } + unsafeUintptr(el) + } + } else { + unsafeUintptr(arg) + } +} + +// copyExpr creates and returns a new temporary variable within fn; +// appends statements to init to declare and initialize it to expr; +// and escape analyzes the data flow. +func (e *escape) copyExpr(pos src.XPos, expr ir.Node, init *ir.Nodes) *ir.Name { + if ir.HasUniquePos(expr) { + pos = expr.Pos() + } + + tmp := typecheck.TempAt(pos, e.curfn, expr.Type()) + + stmts := []ir.Node{ + ir.NewDecl(pos, ir.ODCL, tmp), + ir.NewAssignStmt(pos, tmp, expr), + } + typecheck.Stmts(stmts) + init.Append(stmts...) + + e.newLoc(tmp, true) + e.stmts(stmts) + + return tmp +} + +// tagHole returns a hole for evaluating an argument passed to param. +// ks should contain the holes representing where the function +// callee's results flows. fn is the statically-known callee function, +// if any. +func (e *escape) tagHole(ks []hole, fn *ir.Name, param *types.Field) hole { + // If this is a dynamic call, we can't rely on param.Note. + if fn == nil { + return e.heapHole() + } + + if e.inMutualBatch(fn) { + if param.Nname == nil { + return e.discardHole() + } + return e.addr(param.Nname.(*ir.Name)) + } + + // Call to previously tagged function. + + var tagKs []hole + esc := parseLeaks(param.Note) + + if x := esc.Heap(); x >= 0 { + tagKs = append(tagKs, e.heapHole().shift(x)) + } + if x := esc.Mutator(); x >= 0 { + tagKs = append(tagKs, e.mutatorHole().shift(x)) + } + if x := esc.Callee(); x >= 0 { + tagKs = append(tagKs, e.calleeHole().shift(x)) + } + + if ks != nil { + for i := 0; i < numEscResults; i++ { + if x := esc.Result(i); x >= 0 { + tagKs = append(tagKs, ks[i].shift(x)) + } + } + } + + return e.teeHole(tagKs...) +} + +func hasNonStringPointers(t *types.Type) bool { + if !t.HasPointers() { + return false + } + switch t.Kind() { + case types.TSTRING: + return false + case types.TSTRUCT: + for _, f := range t.Fields() { + if hasNonStringPointers(f.Type) { + return true + } + } + return false + case types.TARRAY: + return hasNonStringPointers(t.Elem()) + } + return true +} diff --git a/go/src/cmd/compile/internal/escape/escape.go b/go/src/cmd/compile/internal/escape/escape.go new file mode 100644 index 0000000000000000000000000000000000000000..9d01156eb8ec0ece5941587b6be91c2db62c7e4e --- /dev/null +++ b/go/src/cmd/compile/internal/escape/escape.go @@ -0,0 +1,672 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package escape + +import ( + "fmt" + "go/constant" + "go/token" + "internal/goexperiment" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +// Escape analysis. +// +// Here we analyze functions to determine which Go variables +// (including implicit allocations such as calls to "new" or "make", +// composite literals, etc.) can be allocated on the stack. The two +// key invariants we have to ensure are: (1) pointers to stack objects +// cannot be stored in the heap, and (2) pointers to a stack object +// cannot outlive that object (e.g., because the declaring function +// returned and destroyed the object's stack frame, or its space is +// reused across loop iterations for logically distinct variables). +// +// We implement this with a static data-flow analysis of the AST. +// First, we construct a directed weighted graph where vertices +// (termed "locations") represent variables allocated by statements +// and expressions, and edges represent assignments between variables +// (with weights representing addressing/dereference counts). +// +// Next we walk the graph looking for assignment paths that might +// violate the invariants stated above. If a variable v's address is +// stored in the heap or elsewhere that may outlive it, then v is +// marked as requiring heap allocation. +// +// To support interprocedural analysis, we also record data-flow from +// each function's parameters to the heap and to its result +// parameters. This information is summarized as "parameter tags", +// which are used at static call sites to improve escape analysis of +// function arguments. + +// Constructing the location graph. +// +// Every allocating statement (e.g., variable declaration) or +// expression (e.g., "new" or "make") is first mapped to a unique +// "location." +// +// We also model every Go assignment as a directed edges between +// locations. The number of dereference operations minus the number of +// addressing operations is recorded as the edge's weight (termed +// "derefs"). For example: +// +// p = &q // -1 +// p = q // 0 +// p = *q // 1 +// p = **q // 2 +// +// p = **&**&q // 2 +// +// Note that the & operator can only be applied to addressable +// expressions, and the expression &x itself is not addressable, so +// derefs cannot go below -1. +// +// Every Go language construct is lowered into this representation, +// generally without sensitivity to flow, path, or context; and +// without distinguishing elements within a compound variable. For +// example: +// +// var x struct { f, g *int } +// var u []*int +// +// x.f = u[0] +// +// is modeled simply as +// +// x = *u +// +// That is, we don't distinguish x.f from x.g, or u[0] from u[1], +// u[2], etc. However, we do record the implicit dereference involved +// in indexing a slice. + +// A batch holds escape analysis state that's shared across an entire +// batch of functions being analyzed at once. +type batch struct { + allLocs []*location + closures []closure + reassignOracles map[*ir.Func]*ir.ReassignOracle + + heapLoc location + mutatorLoc location + calleeLoc location + blankLoc location +} + +// A closure holds a closure expression and its spill hole (i.e., +// where the hole representing storing into its closure record). +type closure struct { + k hole + clo *ir.ClosureExpr +} + +// An escape holds state specific to a single function being analyzed +// within a batch. +type escape struct { + *batch + + curfn *ir.Func // function being analyzed + + labels map[*types.Sym]labelState // known labels + + // loopDepth counts the current loop nesting depth within + // curfn. It increments within each "for" loop and at each + // label with a corresponding backwards "goto" (i.e., + // unstructured loop). + loopDepth int +} + +func Funcs(all []*ir.Func) { + // Make a cache of ir.ReassignOracles. The cache is lazily populated. + // TODO(thepudds): consider adding a field on ir.Func instead. We might also be able + // to use that field elsewhere, like in walk. See discussion in https://go.dev/cl/688075. + reassignOracles := make(map[*ir.Func]*ir.ReassignOracle) + + ir.VisitFuncsBottomUp(all, func(list []*ir.Func, recursive bool) { + Batch(list, reassignOracles) + }) +} + +// Batch performs escape analysis on a minimal batch of +// functions. +func Batch(fns []*ir.Func, reassignOracles map[*ir.Func]*ir.ReassignOracle) { + var b batch + b.heapLoc.attrs = attrEscapes | attrPersists | attrMutates | attrCalls + b.mutatorLoc.attrs = attrMutates + b.calleeLoc.attrs = attrCalls + b.reassignOracles = reassignOracles + + // Construct data-flow graph from syntax trees. + for _, fn := range fns { + if base.Flag.W > 1 { + s := fmt.Sprintf("\nbefore escape %v", fn) + ir.Dump(s, fn) + } + b.initFunc(fn) + } + for _, fn := range fns { + if !fn.IsClosure() { + b.walkFunc(fn) + } + } + + // We've walked the function bodies, so we've seen everywhere a + // variable might be reassigned or have its address taken. Now we + // can decide whether closures should capture their free variables + // by value or reference. + for _, closure := range b.closures { + b.flowClosure(closure.k, closure.clo) + } + b.closures = nil + + for _, loc := range b.allLocs { + // Try to replace some non-constant expressions with literals. + b.rewriteWithLiterals(loc.n, loc.curfn) + + // Check if the node must be heap allocated for certain reasons + // such as OMAKESLICE for a large slice. + if why := HeapAllocReason(loc.n); why != "" { + b.flow(b.heapHole().addr(loc.n, why), loc) + } + } + + b.walkAll() + b.finish(fns) +} + +func (b *batch) with(fn *ir.Func) *escape { + return &escape{ + batch: b, + curfn: fn, + loopDepth: 1, + } +} + +func (b *batch) initFunc(fn *ir.Func) { + e := b.with(fn) + if fn.Esc() != escFuncUnknown { + base.Fatalf("unexpected node: %v", fn) + } + fn.SetEsc(escFuncPlanned) + if base.Flag.LowerM > 3 { + ir.Dump("escAnalyze", fn) + } + + // Allocate locations for local variables. + for _, n := range fn.Dcl { + e.newLoc(n, true) + } + + // Also for hidden parameters (e.g., the ".this" parameter to a + // method value wrapper). + if fn.OClosure == nil { + for _, n := range fn.ClosureVars { + e.newLoc(n.Canonical(), true) + } + } + + // Initialize resultIndex for result parameters. + for i, f := range fn.Type().Results() { + e.oldLoc(f.Nname.(*ir.Name)).resultIndex = 1 + i + } +} + +func (b *batch) walkFunc(fn *ir.Func) { + e := b.with(fn) + fn.SetEsc(escFuncStarted) + + // Identify labels that mark the head of an unstructured loop. + ir.Visit(fn, func(n ir.Node) { + switch n.Op() { + case ir.OLABEL: + n := n.(*ir.LabelStmt) + if n.Label.IsBlank() { + break + } + if e.labels == nil { + e.labels = make(map[*types.Sym]labelState) + } + e.labels[n.Label] = nonlooping + + case ir.OGOTO: + // If we visited the label before the goto, + // then this is a looping label. + n := n.(*ir.BranchStmt) + if e.labels[n.Label] == nonlooping { + e.labels[n.Label] = looping + } + } + }) + + e.block(fn.Body) + + if len(e.labels) != 0 { + base.FatalfAt(fn.Pos(), "leftover labels after walkFunc") + } +} + +func (b *batch) flowClosure(k hole, clo *ir.ClosureExpr) { + for _, cv := range clo.Func.ClosureVars { + n := cv.Canonical() + loc := b.oldLoc(cv) + if !loc.captured { + base.FatalfAt(cv.Pos(), "closure variable never captured: %v", cv) + } + + // Capture by value for variables <= 128 bytes that are never reassigned. + n.SetByval(!loc.addrtaken && !loc.reassigned && n.Type().Size() <= 128) + if !n.Byval() { + n.SetAddrtaken(true) + if n.Sym().Name == typecheck.LocalDictName { + base.FatalfAt(n.Pos(), "dictionary variable not captured by value") + } + } + + if base.Flag.LowerM > 1 { + how := "ref" + if n.Byval() { + how = "value" + } + base.WarnfAt(n.Pos(), "%v capturing by %s: %v (addr=%v assign=%v width=%d)", n.Curfn, how, n, loc.addrtaken, loc.reassigned, n.Type().Size()) + } + + // Flow captured variables to closure. + k := k + if !cv.Byval() { + k = k.addr(cv, "reference") + } + b.flow(k.note(cv, "captured by a closure"), loc) + } +} + +func (b *batch) finish(fns []*ir.Func) { + // Record parameter tags for package export data. + for _, fn := range fns { + fn.SetEsc(escFuncTagged) + + for i, param := range fn.Type().RecvParams() { + param.Note = b.paramTag(fn, 1+i, param) + } + } + + for _, loc := range b.allLocs { + n := loc.n + if n == nil { + continue + } + + if n.Op() == ir.ONAME { + n := n.(*ir.Name) + n.Opt = nil + } + + // Update n.Esc based on escape analysis results. + + // Omit escape diagnostics for go/defer wrappers, at least for now. + // Historically, we haven't printed them, and test cases don't expect them. + // TODO(mdempsky): Update tests to expect this. + goDeferWrapper := n.Op() == ir.OCLOSURE && n.(*ir.ClosureExpr).Func.Wrapper() + + if loc.hasAttr(attrEscapes) { + if n.Op() == ir.ONAME { + if base.Flag.CompilingRuntime { + base.ErrorfAt(n.Pos(), 0, "%v escapes to heap, not allowed in runtime", n) + } + if base.Flag.LowerM != 0 { + base.WarnfAt(n.Pos(), "moved to heap: %v", n) + } + } else { + if base.Flag.LowerM != 0 && !goDeferWrapper { + if n.Op() == ir.OAPPEND { + base.WarnfAt(n.Pos(), "append escapes to heap") + } else { + base.WarnfAt(n.Pos(), "%v escapes to heap", n) + } + } + if logopt.Enabled() { + var e_curfn *ir.Func // TODO(mdempsky): Fix. + logopt.LogOpt(n.Pos(), "escape", "escape", ir.FuncName(e_curfn)) + } + } + n.SetEsc(ir.EscHeap) + } else { + if base.Flag.LowerM != 0 && n.Op() != ir.ONAME && !goDeferWrapper { + if n.Op() == ir.OAPPEND { + base.WarnfAt(n.Pos(), "append does not escape") + } else { + base.WarnfAt(n.Pos(), "%v does not escape", n) + } + } + n.SetEsc(ir.EscNone) + if !loc.hasAttr(attrPersists) { + switch n.Op() { + case ir.OCLOSURE: + n := n.(*ir.ClosureExpr) + n.SetTransient(true) + case ir.OMETHVALUE: + n := n.(*ir.SelectorExpr) + n.SetTransient(true) + case ir.OSLICELIT: + n := n.(*ir.CompLitExpr) + n.SetTransient(true) + } + } + } + + // If the result of a string->[]byte conversion is never mutated, + // then it can simply reuse the string's memory directly. + if base.Debug.ZeroCopy != 0 { + if n, ok := n.(*ir.ConvExpr); ok && n.Op() == ir.OSTR2BYTES && !loc.hasAttr(attrMutates) { + if base.Flag.LowerM >= 1 { + base.WarnfAt(n.Pos(), "zero-copy string->[]byte conversion") + } + n.SetOp(ir.OSTR2BYTESTMP) + } + } + } + + if goexperiment.RuntimeFreegc { + // Look for specific patterns of usage, such as appends + // to slices that we can prove are not aliased. + for _, fn := range fns { + a := aliasAnalysis{} + a.analyze(fn) + } + } + +} + +// inMutualBatch reports whether function fn is in the batch of +// mutually recursive functions being analyzed. When this is true, +// fn has not yet been analyzed, so its parameters and results +// should be incorporated directly into the flow graph instead of +// relying on its escape analysis tagging. +func (b *batch) inMutualBatch(fn *ir.Name) bool { + if fn.Defn != nil && fn.Defn.Esc() < escFuncTagged { + if fn.Defn.Esc() == escFuncUnknown { + base.FatalfAt(fn.Pos(), "graph inconsistency: %v", fn) + } + return true + } + return false +} + +const ( + escFuncUnknown = 0 + iota + escFuncPlanned + escFuncStarted + escFuncTagged +) + +// Mark labels that have no backjumps to them as not increasing e.loopdepth. +type labelState int + +const ( + looping labelState = 1 + iota + nonlooping +) + +func (b *batch) paramTag(fn *ir.Func, narg int, f *types.Field) string { + name := func() string { + if f.Nname != nil { + return f.Nname.Sym().Name + } + return fmt.Sprintf("arg#%d", narg) + } + + // Only report diagnostics for user code; + // not for wrappers generated around them. + // TODO(mdempsky): Generalize this. + diagnose := base.Flag.LowerM != 0 && !(fn.Wrapper() || fn.Dupok()) + + if len(fn.Body) == 0 { + // Assume that uintptr arguments must be held live across the call. + // This is most important for syscall.Syscall. + // See golang.org/issue/13372. + // This really doesn't have much to do with escape analysis per se, + // but we are reusing the ability to annotate an individual function + // argument and pass those annotations along to importing code. + fn.Pragma |= ir.UintptrKeepAlive + + if f.Type.IsUintptr() { + if diagnose { + base.WarnfAt(f.Pos, "assuming %v is unsafe uintptr", name()) + } + return "" + } + + if !f.Type.HasPointers() { // don't bother tagging for scalars + return "" + } + + var esc leaks + + // External functions are assumed unsafe, unless + // //go:noescape is given before the declaration. + if fn.Pragma&ir.Noescape != 0 { + if diagnose && f.Sym != nil { + base.WarnfAt(f.Pos, "%v does not escape", name()) + } + esc.AddMutator(0) + esc.AddCallee(0) + } else { + if diagnose && f.Sym != nil { + base.WarnfAt(f.Pos, "leaking param: %v", name()) + } + esc.AddHeap(0) + } + + return esc.Encode() + } + + if fn.Pragma&ir.UintptrEscapes != 0 { + if f.Type.IsUintptr() { + if diagnose { + base.WarnfAt(f.Pos, "marking %v as escaping uintptr", name()) + } + return "" + } + if f.IsDDD() && f.Type.Elem().IsUintptr() { + // final argument is ...uintptr. + if diagnose { + base.WarnfAt(f.Pos, "marking %v as escaping ...uintptr", name()) + } + return "" + } + } + + if !f.Type.HasPointers() { // don't bother tagging for scalars + return "" + } + + // Unnamed parameters are unused and therefore do not escape. + if f.Sym == nil || f.Sym.IsBlank() { + var esc leaks + return esc.Encode() + } + + n := f.Nname.(*ir.Name) + loc := b.oldLoc(n) + esc := loc.paramEsc + esc.Optimize() + + if diagnose && !loc.hasAttr(attrEscapes) { + b.reportLeaks(f.Pos, name(), esc, fn.Type()) + } + + return esc.Encode() +} + +func (b *batch) reportLeaks(pos src.XPos, name string, esc leaks, sig *types.Type) { + warned := false + if x := esc.Heap(); x >= 0 { + if x == 0 { + base.WarnfAt(pos, "leaking param: %v", name) + } else { + // TODO(mdempsky): Mention level=x like below? + base.WarnfAt(pos, "leaking param content: %v", name) + } + warned = true + } + for i := 0; i < numEscResults; i++ { + if x := esc.Result(i); x >= 0 { + res := sig.Result(i).Nname.Sym().Name + base.WarnfAt(pos, "leaking param: %v to result %v level=%d", name, res, x) + warned = true + } + } + + if base.Debug.EscapeMutationsCalls <= 0 { + if !warned { + base.WarnfAt(pos, "%v does not escape", name) + } + return + } + + if x := esc.Mutator(); x >= 0 { + base.WarnfAt(pos, "mutates param: %v derefs=%v", name, x) + warned = true + } + if x := esc.Callee(); x >= 0 { + base.WarnfAt(pos, "calls param: %v derefs=%v", name, x) + warned = true + } + + if !warned { + base.WarnfAt(pos, "%v does not escape, mutate, or call", name) + } +} + +// rewriteWithLiterals attempts to replace certain non-constant expressions +// within n with a literal if possible. +func (b *batch) rewriteWithLiterals(n ir.Node, fn *ir.Func) { + if n == nil || fn == nil { + return + } + + assignTemp := func(pos src.XPos, n ir.Node, init *ir.Nodes) { + // Preserve any side effects of n by assigning it to an otherwise unused temp. + tmp := typecheck.TempAt(pos, fn, n.Type()) + init.Append(typecheck.Stmt(ir.NewDecl(pos, ir.ODCL, tmp))) + init.Append(typecheck.Stmt(ir.NewAssignStmt(pos, tmp, n))) + } + + switch n.Op() { + case ir.OMAKESLICE: + // Check if we can replace a non-constant argument to make with + // a literal to allow for this slice to be stack allocated if otherwise allowed. + n := n.(*ir.MakeExpr) + + r := &n.Cap + if n.Cap == nil { + r = &n.Len + } + + if (*r).Op() != ir.OLITERAL { + // Look up a cached ReassignOracle for the function, lazily computing one if needed. + ro := b.reassignOracle(fn) + if ro == nil { + base.Fatalf("no ReassignOracle for function %v with closure parent %v", fn, fn.ClosureParent) + } + + s := ro.StaticValue(*r) + switch s.Op() { + case ir.OLITERAL: + lit, ok := s.(*ir.BasicLit) + if !ok || lit.Val().Kind() != constant.Int { + base.Fatalf("unexpected BasicLit Kind") + } + if constant.Compare(lit.Val(), token.GEQ, constant.MakeInt64(0)) { + if !base.LiteralAllocHash.MatchPos(n.Pos(), nil) { + // De-selected by literal alloc optimizations debug hash. + return + } + // Preserve any side effects of the original expression, then replace it. + assignTemp(n.Pos(), *r, n.PtrInit()) + *r = ir.NewBasicLit(n.Pos(), (*r).Type(), lit.Val()) + } + case ir.OLEN: + x := ro.StaticValue(s.(*ir.UnaryExpr).X) + if x.Op() == ir.OSLICELIT { + x := x.(*ir.CompLitExpr) + // Preserve any side effects of the original expression, then update the value. + assignTemp(n.Pos(), *r, n.PtrInit()) + *r = ir.NewBasicLit(n.Pos(), types.Types[types.TINT], constant.MakeInt64(x.Len)) + } + } + } + case ir.OCONVIFACE: + // Check if we can replace a non-constant expression in an interface conversion with + // a literal to avoid heap allocating the underlying interface value. + conv := n.(*ir.ConvExpr) + if conv.X.Op() != ir.OLITERAL && !conv.X.Type().IsInterface() { + // TODO(thepudds): likely could avoid some work by tightening the check of conv.X's type. + // Look up a cached ReassignOracle for the function, lazily computing one if needed. + ro := b.reassignOracle(fn) + if ro == nil { + base.Fatalf("no ReassignOracle for function %v with closure parent %v", fn, fn.ClosureParent) + } + v := ro.StaticValue(conv.X) + if v != nil && v.Op() == ir.OLITERAL && ir.ValidTypeForConst(conv.X.Type(), v.Val()) { + if !base.LiteralAllocHash.MatchPos(n.Pos(), nil) { + // De-selected by literal alloc optimizations debug hash. + return + } + if base.Debug.EscapeDebug >= 3 { + base.WarnfAt(n.Pos(), "rewriting OCONVIFACE value from %v (%v) to %v (%v)", conv.X, conv.X.Type(), v, v.Type()) + } + // Preserve any side effects of the original expression, then replace it. + assignTemp(conv.Pos(), conv.X, conv.PtrInit()) + v := v.(*ir.BasicLit) + conv.X = ir.NewBasicLit(conv.Pos(), conv.X.Type(), v.Val()) + typecheck.Expr(conv) + } + } + } +} + +// reassignOracle returns an initialized *ir.ReassignOracle for fn. +// If fn is a closure, it returns the ReassignOracle for the ultimate parent. +// +// A new ReassignOracle is initialized lazily if needed, and the result +// is cached to reduce duplicative work of preparing a ReassignOracle. +func (b *batch) reassignOracle(fn *ir.Func) *ir.ReassignOracle { + if ro, ok := b.reassignOracles[fn]; ok { + return ro // Hit. + } + + // For closures, we want the ultimate parent's ReassignOracle, + // so walk up the parent chain, if any. + f := fn + for f.ClosureParent != nil && !f.ClosureParent.IsPackageInit() { + f = f.ClosureParent + } + + if f != fn { + // We found a parent. + ro := b.reassignOracles[f] + if ro != nil { + // Hit, via a parent. Before returning, store this ro for the original fn as well. + b.reassignOracles[fn] = ro + return ro + } + } + + // Miss. We did not find a ReassignOracle for fn or a parent, so lazily create one. + ro := &ir.ReassignOracle{} + ro.Init(f) + + // Cache the answer for the original fn. + b.reassignOracles[fn] = ro + if f != fn { + // Cache for the parent as well. + b.reassignOracles[f] = ro + } + return ro +} diff --git a/go/src/cmd/compile/internal/escape/expr.go b/go/src/cmd/compile/internal/escape/expr.go new file mode 100644 index 0000000000000000000000000000000000000000..1521c2edd176054253b8ea7dcaf0256b25feb5ef --- /dev/null +++ b/go/src/cmd/compile/internal/escape/expr.go @@ -0,0 +1,341 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package escape + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" +) + +// expr models evaluating an expression n and flowing the result into +// hole k. +func (e *escape) expr(k hole, n ir.Node) { + if n == nil { + return + } + e.stmts(n.Init()) + e.exprSkipInit(k, n) +} + +func (e *escape) exprSkipInit(k hole, n ir.Node) { + if n == nil { + return + } + + lno := ir.SetPos(n) + defer func() { + base.Pos = lno + }() + + if k.derefs >= 0 && !n.Type().IsUntyped() && !n.Type().HasPointers() { + k.dst = &e.blankLoc + } + + switch n.Op() { + default: + base.Fatalf("unexpected expr: %s %v", n.Op().String(), n) + + case ir.OLITERAL, ir.ONIL, ir.OGETG, ir.OGETCALLERSP, ir.OTYPE, ir.OMETHEXPR, ir.OLINKSYMOFFSET: + // nop + + case ir.ONAME: + n := n.(*ir.Name) + if n.Class == ir.PFUNC || n.Class == ir.PEXTERN { + return + } + e.flow(k, e.oldLoc(n)) + + case ir.OPLUS, ir.ONEG, ir.OBITNOT, ir.ONOT: + n := n.(*ir.UnaryExpr) + e.discard(n.X) + case ir.OADD, ir.OSUB, ir.OOR, ir.OXOR, ir.OMUL, ir.ODIV, ir.OMOD, ir.OLSH, ir.ORSH, ir.OAND, ir.OANDNOT, ir.OEQ, ir.ONE, ir.OLT, ir.OLE, ir.OGT, ir.OGE: + n := n.(*ir.BinaryExpr) + e.discard(n.X) + e.discard(n.Y) + case ir.OANDAND, ir.OOROR: + n := n.(*ir.LogicalExpr) + e.discard(n.X) + e.discard(n.Y) + case ir.OADDR: + n := n.(*ir.AddrExpr) + e.expr(k.addr(n, "address-of"), n.X) // "address-of" + case ir.ODEREF: + n := n.(*ir.StarExpr) + e.expr(k.deref(n, "indirection"), n.X) // "indirection" + case ir.ODOT, ir.ODOTMETH, ir.ODOTINTER: + n := n.(*ir.SelectorExpr) + e.expr(k.note(n, "dot"), n.X) + case ir.ODOTPTR: + n := n.(*ir.SelectorExpr) + e.expr(k.deref(n, "dot of pointer"), n.X) // "dot of pointer" + case ir.ODOTTYPE, ir.ODOTTYPE2: + n := n.(*ir.TypeAssertExpr) + e.expr(k.dotType(n.Type(), n, "dot"), n.X) + case ir.ODYNAMICDOTTYPE, ir.ODYNAMICDOTTYPE2: + n := n.(*ir.DynamicTypeAssertExpr) + e.expr(k.dotType(n.Type(), n, "dot"), n.X) + // n.T doesn't need to be tracked; it always points to read-only storage. + case ir.OINDEX: + n := n.(*ir.IndexExpr) + if n.X.Type().IsArray() { + e.expr(k.note(n, "fixed-array-index-of"), n.X) + } else { + // TODO(mdempsky): Fix why reason text. + e.expr(k.deref(n, "dot of pointer"), n.X) + } + e.discard(n.Index) + case ir.OINDEXMAP: + n := n.(*ir.IndexExpr) + e.discard(n.X) + e.discard(n.Index) + case ir.OSLICE, ir.OSLICEARR, ir.OSLICE3, ir.OSLICE3ARR, ir.OSLICESTR: + n := n.(*ir.SliceExpr) + e.expr(k.note(n, "slice"), n.X) + e.discard(n.Low) + e.discard(n.High) + e.discard(n.Max) + + case ir.OCONV, ir.OCONVNOP: + n := n.(*ir.ConvExpr) + if (ir.ShouldCheckPtr(e.curfn, 2) || ir.ShouldAsanCheckPtr(e.curfn)) && n.Type().IsUnsafePtr() && n.X.Type().IsPtr() { + // When -d=checkptr=2 or -asan is enabled, + // treat conversions to unsafe.Pointer as an + // escaping operation. This allows better + // runtime instrumentation, since we can more + // easily detect object boundaries on the heap + // than the stack. + e.assignHeap(n.X, "conversion to unsafe.Pointer", n) + } else if n.Type().IsUnsafePtr() && n.X.Type().IsUintptr() { + e.unsafeValue(k, n.X) + } else { + e.expr(k, n.X) + } + case ir.OCONVIFACE: + n := n.(*ir.ConvExpr) + if !n.X.Type().IsInterface() && !types.IsDirectIface(n.X.Type()) { + k = e.spill(k, n) + } + e.expr(k.note(n, "interface-converted"), n.X) + case ir.OMAKEFACE: + n := n.(*ir.BinaryExpr) + // Note: n.X is not needed because it can never point to memory that might escape. + e.expr(k, n.Y) + case ir.OITAB, ir.OIDATA, ir.OSPTR: + n := n.(*ir.UnaryExpr) + e.expr(k, n.X) + case ir.OSLICE2ARR: + // Converting a slice to array is effectively a deref. + n := n.(*ir.ConvExpr) + e.expr(k.deref(n, "slice-to-array"), n.X) + case ir.OSLICE2ARRPTR: + // the slice pointer flows directly to the result + n := n.(*ir.ConvExpr) + e.expr(k, n.X) + case ir.ORECV: + n := n.(*ir.UnaryExpr) + e.discard(n.X) + + case ir.OCALLMETH, ir.OCALLFUNC, ir.OCALLINTER, ir.OINLCALL, + ir.OLEN, ir.OCAP, ir.OMIN, ir.OMAX, ir.OCOMPLEX, ir.OREAL, ir.OIMAG, ir.OAPPEND, ir.OCOPY, ir.ORECOVER, + ir.OUNSAFEADD, ir.OUNSAFESLICE, ir.OUNSAFESTRING, ir.OUNSAFESTRINGDATA, ir.OUNSAFESLICEDATA: + e.call([]hole{k}, n) + + case ir.ONEW: + n := n.(*ir.UnaryExpr) + e.spill(k, n) + + case ir.OMAKESLICE: + n := n.(*ir.MakeExpr) + e.spill(k, n) + e.discard(n.Len) + e.discard(n.Cap) + case ir.OMAKECHAN: + n := n.(*ir.MakeExpr) + e.discard(n.Len) + case ir.OMAKEMAP: + n := n.(*ir.MakeExpr) + e.spill(k, n) + e.discard(n.Len) + + case ir.OMETHVALUE: + // Flow the receiver argument to both the closure and + // to the receiver parameter. + + n := n.(*ir.SelectorExpr) + closureK := e.spill(k, n) + + m := n.Selection + + // We don't know how the method value will be called + // later, so conservatively assume the result + // parameters all flow to the heap. + // + // TODO(mdempsky): Change ks into a callback, so that + // we don't have to create this slice? + var ks []hole + for i := m.Type.NumResults(); i > 0; i-- { + ks = append(ks, e.heapHole()) + } + name, _ := m.Nname.(*ir.Name) + paramK := e.tagHole(ks, name, m.Type.Recv()) + + e.expr(e.teeHole(paramK, closureK), n.X) + + case ir.OPTRLIT: + n := n.(*ir.AddrExpr) + e.expr(e.spill(k, n), n.X) + + case ir.OARRAYLIT: + n := n.(*ir.CompLitExpr) + for _, elt := range n.List { + if elt.Op() == ir.OKEY { + elt = elt.(*ir.KeyExpr).Value + } + e.expr(k.note(n, "array literal element"), elt) + } + + case ir.OSLICELIT: + n := n.(*ir.CompLitExpr) + k = e.spill(k, n) + + for _, elt := range n.List { + if elt.Op() == ir.OKEY { + elt = elt.(*ir.KeyExpr).Value + } + e.expr(k.note(n, "slice-literal-element"), elt) + } + + case ir.OSTRUCTLIT: + n := n.(*ir.CompLitExpr) + for _, elt := range n.List { + e.expr(k.note(n, "struct literal element"), elt.(*ir.StructKeyExpr).Value) + } + + case ir.OMAPLIT: + n := n.(*ir.CompLitExpr) + e.spill(k, n) + + // Map keys and values are always stored in the heap. + for _, elt := range n.List { + elt := elt.(*ir.KeyExpr) + e.assignHeap(elt.Key, "map literal key", n) + e.assignHeap(elt.Value, "map literal value", n) + } + + case ir.OCLOSURE: + n := n.(*ir.ClosureExpr) + k = e.spill(k, n) + e.closures = append(e.closures, closure{k, n}) + + if fn := n.Func; fn.IsClosure() { + for _, cv := range fn.ClosureVars { + if loc := e.oldLoc(cv); !loc.captured { + loc.captured = true + + // Ignore reassignments to the variable in straightline code + // preceding the first capture by a closure. + if loc.loopDepth == e.loopDepth { + loc.reassigned = false + } + } + } + + for _, n := range fn.Dcl { + // Add locations for local variables of the + // closure, if needed, in case we're not including + // the closure func in the batch for escape + // analysis (happens for escape analysis called + // from reflectdata.methodWrapper) + if n.Op() == ir.ONAME && n.Opt == nil { + e.with(fn).newLoc(n, true) + } + } + e.walkFunc(fn) + } + + case ir.ORUNES2STR, ir.OBYTES2STR, ir.OSTR2RUNES, ir.OSTR2BYTES, ir.ORUNESTR: + n := n.(*ir.ConvExpr) + e.spill(k, n) + e.discard(n.X) + + case ir.OADDSTR: + n := n.(*ir.AddStringExpr) + e.spill(k, n) + + // Arguments of OADDSTR never escape; + // runtime.concatstrings makes sure of that. + e.discards(n.List) + + case ir.ODYNAMICTYPE: + // Nothing to do - argument is a *runtime._type (+ maybe a *runtime.itab) pointing to static data section + } +} + +// unsafeValue evaluates a uintptr-typed arithmetic expression looking +// for conversions from an unsafe.Pointer. +func (e *escape) unsafeValue(k hole, n ir.Node) { + if n.Type().Kind() != types.TUINTPTR { + base.Fatalf("unexpected type %v for %v", n.Type(), n) + } + if k.addrtaken { + base.Fatalf("unexpected addrtaken") + } + + e.stmts(n.Init()) + + switch n.Op() { + case ir.OCONV, ir.OCONVNOP: + n := n.(*ir.ConvExpr) + if n.X.Type().IsUnsafePtr() { + e.expr(k, n.X) + } else { + e.discard(n.X) + } + case ir.ODOTPTR: + n := n.(*ir.SelectorExpr) + if ir.IsReflectHeaderDataField(n) { + e.expr(k.deref(n, "reflect.Header.Data"), n.X) + } else { + e.discard(n.X) + } + case ir.OPLUS, ir.ONEG, ir.OBITNOT: + n := n.(*ir.UnaryExpr) + e.unsafeValue(k, n.X) + case ir.OADD, ir.OSUB, ir.OOR, ir.OXOR, ir.OMUL, ir.ODIV, ir.OMOD, ir.OAND, ir.OANDNOT: + n := n.(*ir.BinaryExpr) + e.unsafeValue(k, n.X) + e.unsafeValue(k, n.Y) + case ir.OLSH, ir.ORSH: + n := n.(*ir.BinaryExpr) + e.unsafeValue(k, n.X) + // RHS need not be uintptr-typed (#32959) and can't meaningfully + // flow pointers anyway. + e.discard(n.Y) + default: + e.exprSkipInit(e.discardHole(), n) + } +} + +// discard evaluates an expression n for side-effects, but discards +// its value. +func (e *escape) discard(n ir.Node) { + e.expr(e.discardHole(), n) +} + +func (e *escape) discards(l ir.Nodes) { + for _, n := range l { + e.discard(n) + } +} + +// spill allocates a new location associated with expression n, flows +// its address to k, and returns a hole that flows values to it. It's +// intended for use with most expressions that allocate storage. +func (e *escape) spill(k hole, n ir.Node) hole { + loc := e.newLoc(n, false) + e.flow(k.addr(n, "spill"), loc) + return loc.asHole() +} diff --git a/go/src/cmd/compile/internal/escape/graph.go b/go/src/cmd/compile/internal/escape/graph.go new file mode 100644 index 0000000000000000000000000000000000000000..0ffb4a0bb5a4dee8609bd8f1a8bd8e058e0099e7 --- /dev/null +++ b/go/src/cmd/compile/internal/escape/graph.go @@ -0,0 +1,360 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package escape + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/types" + "fmt" +) + +// Below we implement the methods for walking the AST and recording +// data flow edges. Note that because a sub-expression might have +// side-effects, it's important to always visit the entire AST. +// +// For example, write either: +// +// if x { +// e.discard(n.Left) +// } else { +// e.value(k, n.Left) +// } +// +// or +// +// if x { +// k = e.discardHole() +// } +// e.value(k, n.Left) +// +// Do NOT write: +// +// // BAD: possibly loses side-effects within n.Left +// if !x { +// e.value(k, n.Left) +// } + +// A location represents an abstract location that stores a Go +// variable. +type location struct { + n ir.Node // represented variable or expression, if any + curfn *ir.Func // enclosing function + edges []edge // incoming edges + loopDepth int // loopDepth at declaration + + // resultIndex records the tuple index (starting at 1) for + // PPARAMOUT variables within their function's result type. + // For non-PPARAMOUT variables it's 0. + resultIndex int + + // derefs and walkgen are used during walkOne to track the + // minimal dereferences from the walk root. + derefs int // >= -1 + walkgen uint32 + + // dst and dstEdgeindex track the next immediate assignment + // destination location during walkone, along with the index + // of the edge pointing back to this location. + dst *location + dstEdgeIdx int + + // queuedWalkAll is used by walkAll to track whether this location is + // in its work queue. + queuedWalkAll bool + + // queuedWalkOne is used by walkOne to track whether this location is + // in its work queue. The value is the walkgen when this location was + // last queued for walkOne, or 0 if it's not currently queued. + queuedWalkOne uint32 + + // attrs is a bitset of location attributes. + attrs locAttr + + // paramEsc records the represented parameter's leak set. + paramEsc leaks + + captured bool // has a closure captured this variable? + reassigned bool // has this variable been reassigned? + addrtaken bool // has this variable's address been taken? + param bool // is this variable a parameter (ONAME of class ir.PPARAM)? + paramOut bool // is this variable an out parameter (ONAME of class ir.PPARAMOUT)? +} + +type locAttr uint8 + +const ( + // attrEscapes indicates whether the represented variable's address + // escapes; that is, whether the variable must be heap allocated. + attrEscapes locAttr = 1 << iota + + // attrPersists indicates whether the represented expression's + // address outlives the statement; that is, whether its storage + // cannot be immediately reused. + attrPersists + + // attrMutates indicates whether pointers that are reachable from + // this location may have their addressed memory mutated. This is + // used to detect string->[]byte conversions that can be safely + // optimized away. + attrMutates + + // attrCalls indicates whether closures that are reachable from this + // location may be called without tracking their results. This is + // used to better optimize indirect closure calls. + attrCalls +) + +func (l *location) hasAttr(attr locAttr) bool { return l.attrs&attr != 0 } + +// An edge represents an assignment edge between two Go variables. +type edge struct { + src *location + derefs int // >= -1 + notes *note +} + +func (l *location) asHole() hole { + return hole{dst: l} +} + +// leak records that parameter l leaks to sink. +func (l *location) leakTo(sink *location, derefs int) { + // If sink is a result parameter that doesn't escape (#44614) + // and we can fit return bits into the escape analysis tag, + // then record as a result leak. + if !sink.hasAttr(attrEscapes) && sink.isName(ir.PPARAMOUT) && sink.curfn == l.curfn { + ri := sink.resultIndex - 1 + if ri < numEscResults { + // Leak to result parameter. + l.paramEsc.AddResult(ri, derefs) + return + } + } + + // Otherwise, record as heap leak. + l.paramEsc.AddHeap(derefs) +} + +func (l *location) isName(c ir.Class) bool { + return l.n != nil && l.n.Op() == ir.ONAME && l.n.(*ir.Name).Class == c +} + +// A hole represents a context for evaluation of a Go +// expression. E.g., when evaluating p in "x = **p", we'd have a hole +// with dst==x and derefs==2. +type hole struct { + dst *location + derefs int // >= -1 + notes *note + + // addrtaken indicates whether this context is taking the address of + // the expression, independent of whether the address will actually + // be stored into a variable. + addrtaken bool +} + +type note struct { + next *note + where ir.Node + why string +} + +func (k hole) note(where ir.Node, why string) hole { + if where == nil || why == "" { + base.Fatalf("note: missing where/why") + } + if base.Flag.LowerM >= 2 || logopt.Enabled() { + k.notes = ¬e{ + next: k.notes, + where: where, + why: why, + } + } + return k +} + +func (k hole) shift(delta int) hole { + k.derefs += delta + if k.derefs < -1 { + base.Fatalf("derefs underflow: %v", k.derefs) + } + k.addrtaken = delta < 0 + return k +} + +func (k hole) deref(where ir.Node, why string) hole { return k.shift(1).note(where, why) } +func (k hole) addr(where ir.Node, why string) hole { return k.shift(-1).note(where, why) } + +func (k hole) dotType(t *types.Type, where ir.Node, why string) hole { + if !t.IsInterface() && !types.IsDirectIface(t) { + k = k.shift(1) + } + return k.note(where, why) +} + +func (b *batch) flow(k hole, src *location) { + if k.addrtaken { + src.addrtaken = true + } + + dst := k.dst + if dst == &b.blankLoc { + return + } + if dst == src && k.derefs >= 0 { // dst = dst, dst = *dst, ... + return + } + if dst.hasAttr(attrEscapes) && k.derefs < 0 { // dst = &src + if base.Flag.LowerM >= 2 || logopt.Enabled() { + pos := base.FmtPos(src.n.Pos()) + if base.Flag.LowerM >= 2 { + fmt.Printf("%s: %v escapes to heap in %v:\n", pos, src.n, ir.FuncName(src.curfn)) + } + explanation := b.explainFlow(pos, dst, src, k.derefs, k.notes, []*logopt.LoggedOpt{}) + if logopt.Enabled() { + var e_curfn *ir.Func // TODO(mdempsky): Fix. + logopt.LogOpt(src.n.Pos(), "escapes", "escape", ir.FuncName(e_curfn), fmt.Sprintf("%v escapes to heap", src.n), explanation) + } + + } + src.attrs |= attrEscapes | attrPersists | attrMutates | attrCalls + return + } + + // TODO(mdempsky): Deduplicate edges? + dst.edges = append(dst.edges, edge{src: src, derefs: k.derefs, notes: k.notes}) +} + +func (b *batch) heapHole() hole { return b.heapLoc.asHole() } +func (b *batch) mutatorHole() hole { return b.mutatorLoc.asHole() } +func (b *batch) calleeHole() hole { return b.calleeLoc.asHole() } +func (b *batch) discardHole() hole { return b.blankLoc.asHole() } + +func (b *batch) oldLoc(n *ir.Name) *location { + if n.Canonical().Opt == nil { + base.FatalfAt(n.Pos(), "%v has no location", n) + } + return n.Canonical().Opt.(*location) +} + +func (e *escape) newLoc(n ir.Node, persists bool) *location { + if e.curfn == nil { + base.Fatalf("e.curfn isn't set") + } + if n != nil && n.Type() != nil && n.Type().NotInHeap() { + base.ErrorfAt(n.Pos(), 0, "%v is incomplete (or unallocatable); stack allocation disallowed", n.Type()) + } + + if n != nil && n.Op() == ir.ONAME { + if canon := n.(*ir.Name).Canonical(); n != canon { + base.FatalfAt(n.Pos(), "newLoc on non-canonical %v (canonical is %v)", n, canon) + } + } + loc := &location{ + n: n, + curfn: e.curfn, + loopDepth: e.loopDepth, + } + if loc.isName(ir.PPARAM) { + loc.param = true + } else if loc.isName(ir.PPARAMOUT) { + loc.paramOut = true + } + + if persists { + loc.attrs |= attrPersists + } + e.allLocs = append(e.allLocs, loc) + if n != nil { + if n.Op() == ir.ONAME { + n := n.(*ir.Name) + if n.Class == ir.PPARAM && n.Curfn == nil { + // ok; hidden parameter + } else if n.Curfn != e.curfn { + base.FatalfAt(n.Pos(), "curfn mismatch: %v != %v for %v", n.Curfn, e.curfn, n) + } + + if n.Opt != nil { + base.FatalfAt(n.Pos(), "%v already has a location", n) + } + n.Opt = loc + } + } + return loc +} + +// teeHole returns a new hole that flows into each hole of ks, +// similar to the Unix tee(1) command. +func (e *escape) teeHole(ks ...hole) hole { + if len(ks) == 0 { + return e.discardHole() + } + if len(ks) == 1 { + return ks[0] + } + // TODO(mdempsky): Optimize if there's only one non-discard hole? + + // Given holes "l1 = _", "l2 = **_", "l3 = *_", ..., create a + // new temporary location ltmp, wire it into place, and return + // a hole for "ltmp = _". + loc := e.newLoc(nil, false) + for _, k := range ks { + // N.B., "p = &q" and "p = &tmp; tmp = q" are not + // semantically equivalent. To combine holes like "l1 + // = _" and "l2 = &_", we'd need to wire them as "l1 = + // *ltmp" and "l2 = ltmp" and return "ltmp = &_" + // instead. + if k.derefs < 0 { + base.Fatalf("teeHole: negative derefs") + } + + e.flow(k, loc) + } + return loc.asHole() +} + +// later returns a new hole that flows into k, but some time later. +// Its main effect is to prevent immediate reuse of temporary +// variables introduced during Order. +func (e *escape) later(k hole) hole { + loc := e.newLoc(nil, true) + e.flow(k, loc) + return loc.asHole() +} + +// Fmt is called from node printing to print information about escape analysis results. +func Fmt(n ir.Node) string { + text := "" + switch n.Esc() { + case ir.EscUnknown: + break + + case ir.EscHeap: + text = "esc(h)" + + case ir.EscNone: + text = "esc(no)" + + case ir.EscNever: + text = "esc(N)" + + default: + text = fmt.Sprintf("esc(%d)", n.Esc()) + } + + if n.Op() == ir.ONAME { + n := n.(*ir.Name) + if loc, ok := n.Opt.(*location); ok && loc.loopDepth != 0 { + if text != "" { + text += " " + } + text += fmt.Sprintf("ld(%d)", loc.loopDepth) + } + } + + return text +} diff --git a/go/src/cmd/compile/internal/escape/leaks.go b/go/src/cmd/compile/internal/escape/leaks.go new file mode 100644 index 0000000000000000000000000000000000000000..176bccd8470e7bfd1c060b6a312fd3b3dd150bb6 --- /dev/null +++ b/go/src/cmd/compile/internal/escape/leaks.go @@ -0,0 +1,144 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package escape + +import ( + "cmd/compile/internal/base" + "math" + "strings" +) + +// A leaks represents a set of assignment flows from a parameter to +// the heap, mutator, callee, or to any of its function's (first +// numEscResults) result parameters. +type leaks [8]uint8 + +const ( + leakHeap = iota + leakMutator + leakCallee + leakResult0 +) + +const numEscResults = len(leaks{}) - leakResult0 + +// Heap returns the minimum deref count of any assignment flow from l +// to the heap. If no such flows exist, Heap returns -1. +func (l leaks) Heap() int { return l.get(leakHeap) } + +// Mutator returns the minimum deref count of any assignment flow from +// l to the pointer operand of an indirect assignment statement. If no +// such flows exist, Mutator returns -1. +func (l leaks) Mutator() int { return l.get(leakMutator) } + +// Callee returns the minimum deref count of any assignment flow from +// l to the callee operand of call expression. If no such flows exist, +// Callee returns -1. +func (l leaks) Callee() int { return l.get(leakCallee) } + +// Result returns the minimum deref count of any assignment flow from +// l to its function's i'th result parameter. If no such flows exist, +// Result returns -1. +func (l leaks) Result(i int) int { return l.get(leakResult0 + i) } + +// AddHeap adds an assignment flow from l to the heap. +func (l *leaks) AddHeap(derefs int) { l.add(leakHeap, derefs) } + +// AddMutator adds a flow from l to the mutator (i.e., a pointer +// operand of an indirect assignment statement). +func (l *leaks) AddMutator(derefs int) { l.add(leakMutator, derefs) } + +// AddCallee adds an assignment flow from l to the callee operand of a +// call expression. +func (l *leaks) AddCallee(derefs int) { l.add(leakCallee, derefs) } + +// AddResult adds an assignment flow from l to its function's i'th +// result parameter. +func (l *leaks) AddResult(i, derefs int) { l.add(leakResult0+i, derefs) } + +func (l leaks) get(i int) int { return int(l[i]) - 1 } + +func (l *leaks) add(i, derefs int) { + if old := l.get(i); old < 0 || derefs < old { + l.set(i, derefs) + } +} + +func (l *leaks) set(i, derefs int) { + v := derefs + 1 + if v < 0 { + base.Fatalf("invalid derefs count: %v", derefs) + } + if v > math.MaxUint8 { + v = math.MaxUint8 + } + + l[i] = uint8(v) +} + +// Optimize removes result flow paths that are equal in length or +// longer than the shortest heap flow path. +func (l *leaks) Optimize() { + // If we have a path to the heap, then there's no use in + // keeping equal or longer paths elsewhere. + if x := l.Heap(); x >= 0 { + for i := 1; i < len(*l); i++ { + if l.get(i) >= x { + l.set(i, -1) + } + } + } +} + +var leakTagCache = map[leaks]string{} + +// Encode converts l into a binary string for export data. +func (l leaks) Encode() string { + if l.Heap() == 0 { + // Space optimization: empty string encodes more + // efficiently in export data. + return "" + } + if s, ok := leakTagCache[l]; ok { + return s + } + + n := len(l) + for n > 0 && l[n-1] == 0 { + n-- + } + s := "esc:" + string(l[:n]) + leakTagCache[l] = s + return s +} + +// parseLeaks parses a binary string representing a leaks. +func parseLeaks(s string) leaks { + var l leaks + if !strings.HasPrefix(s, "esc:") { + l.AddHeap(0) + return l + } + copy(l[:], s[4:]) + return l +} + +func ParseLeaks(s string) leaks { + return parseLeaks(s) +} + +// Any reports whether the value flows anywhere at all. +func (l leaks) Any() bool { + // TODO: do mutator/callee matter? + if l.Heap() >= 0 || l.Mutator() >= 0 || l.Callee() >= 0 { + return true + } + for i := range numEscResults { + if l.Result(i) >= 0 { + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/escape/solve.go b/go/src/cmd/compile/internal/escape/solve.go new file mode 100644 index 0000000000000000000000000000000000000000..e2ca3eabda99ad8717efd1f4c4020f8d91831682 --- /dev/null +++ b/go/src/cmd/compile/internal/escape/solve.go @@ -0,0 +1,397 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package escape + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/internal/src" + "fmt" + "math/bits" + "strings" +) + +// walkAll computes the minimal dereferences between all pairs of +// locations. +func (b *batch) walkAll() { + // We use a work queue to keep track of locations that we need + // to visit, and repeatedly walk until we reach a fixed point. + // + // We walk once from each location (including the heap), and + // then re-enqueue each location on its transition from + // !persists->persists and !escapes->escapes, which can each + // happen at most once. So we take Θ(len(e.allLocs)) walks. + + // Queue of locations to walk. Has enough room for b.allLocs + // plus b.heapLoc, b.mutatorLoc, b.calleeLoc. + todo := newQueue(len(b.allLocs) + 3) + + enqueue := func(loc *location) { + if !loc.queuedWalkAll { + loc.queuedWalkAll = true + if loc.hasAttr(attrEscapes) { + // Favor locations that escape to the heap, + // which in some cases allows attrEscape to + // propagate faster. + todo.pushFront(loc) + } else { + todo.pushBack(loc) + } + } + } + + for _, loc := range b.allLocs { + todo.pushFront(loc) + // TODO(thepudds): clean up setting queuedWalkAll. + loc.queuedWalkAll = true + } + todo.pushFront(&b.mutatorLoc) + todo.pushFront(&b.calleeLoc) + todo.pushFront(&b.heapLoc) + + b.mutatorLoc.queuedWalkAll = true + b.calleeLoc.queuedWalkAll = true + b.heapLoc.queuedWalkAll = true + + var walkgen uint32 + for todo.len() > 0 { + root := todo.popFront() + root.queuedWalkAll = false + walkgen++ + b.walkOne(root, walkgen, enqueue) + } +} + +// walkOne computes the minimal number of dereferences from root to +// all other locations. +func (b *batch) walkOne(root *location, walkgen uint32, enqueue func(*location)) { + // The data flow graph has negative edges (from addressing + // operations), so we use the Bellman-Ford algorithm. However, + // we don't have to worry about infinite negative cycles since + // we bound intermediate dereference counts to 0. + + root.walkgen = walkgen + root.derefs = 0 + root.dst = nil + + if root.hasAttr(attrCalls) { + if clo, ok := root.n.(*ir.ClosureExpr); ok { + if fn := clo.Func; b.inMutualBatch(fn.Nname) && !fn.ClosureResultsLost() { + fn.SetClosureResultsLost(true) + + // Re-flow from the closure's results, now that we're aware + // we lost track of them. + for _, result := range fn.Type().Results() { + enqueue(b.oldLoc(result.Nname.(*ir.Name))) + } + } + } + } + + todo := newQueue(1) + todo.pushFront(root) + + for todo.len() > 0 { + l := todo.popFront() + l.queuedWalkOne = 0 // no longer queued for walkOne + + derefs := l.derefs + var newAttrs locAttr + + // If l.derefs < 0, then l's address flows to root. + addressOf := derefs < 0 + if addressOf { + // For a flow path like "root = &l; l = x", + // l's address flows to root, but x's does + // not. We recognize this by lower bounding + // derefs at 0. + derefs = 0 + + // If l's address flows somewhere that + // outlives it, then l needs to be heap + // allocated. + if b.outlives(root, l) { + if !l.hasAttr(attrEscapes) && (logopt.Enabled() || base.Flag.LowerM >= 2) { + if base.Flag.LowerM >= 2 { + fmt.Printf("%s: %v escapes to heap in %v:\n", base.FmtPos(l.n.Pos()), l.n, ir.FuncName(l.curfn)) + } + explanation := b.explainPath(root, l) + if logopt.Enabled() { + var e_curfn *ir.Func // TODO(mdempsky): Fix. + logopt.LogOpt(l.n.Pos(), "escape", "escape", ir.FuncName(e_curfn), fmt.Sprintf("%v escapes to heap", l.n), explanation) + } + } + newAttrs |= attrEscapes | attrPersists | attrMutates | attrCalls + } else + // If l's address flows to a persistent location, then l needs + // to persist too. + if root.hasAttr(attrPersists) { + newAttrs |= attrPersists + } + } + + if derefs == 0 { + newAttrs |= root.attrs & (attrMutates | attrCalls) + } + + // l's value flows to root. If l is a function + // parameter and root is the heap or a + // corresponding result parameter, then record + // that value flow for tagging the function + // later. + if l.param { + if b.outlives(root, l) { + if !l.hasAttr(attrEscapes) && (logopt.Enabled() || base.Flag.LowerM >= 2) { + if base.Flag.LowerM >= 2 { + fmt.Printf("%s: parameter %v leaks to %s for %v with derefs=%d:\n", base.FmtPos(l.n.Pos()), l.n, b.explainLoc(root), ir.FuncName(l.curfn), derefs) + } + explanation := b.explainPath(root, l) + if logopt.Enabled() { + var e_curfn *ir.Func // TODO(mdempsky): Fix. + logopt.LogOpt(l.n.Pos(), "leak", "escape", ir.FuncName(e_curfn), + fmt.Sprintf("parameter %v leaks to %s with derefs=%d", l.n, b.explainLoc(root), derefs), explanation) + } + } + l.leakTo(root, derefs) + } + if root.hasAttr(attrMutates) { + l.paramEsc.AddMutator(derefs) + } + if root.hasAttr(attrCalls) { + l.paramEsc.AddCallee(derefs) + } + } + + if newAttrs&^l.attrs != 0 { + l.attrs |= newAttrs + enqueue(l) + if l.attrs&attrEscapes != 0 { + continue + } + } + + for i, edge := range l.edges { + if edge.src.hasAttr(attrEscapes) { + continue + } + d := derefs + edge.derefs + if edge.src.walkgen != walkgen || edge.src.derefs > d { + edge.src.walkgen = walkgen + edge.src.derefs = d + edge.src.dst = l + edge.src.dstEdgeIdx = i + // Check if already queued in todo. + if edge.src.queuedWalkOne != walkgen { + edge.src.queuedWalkOne = walkgen // Mark queued for this walkgen. + + // Place at the back to possibly give time for + // other possible attribute changes to src. + todo.pushBack(edge.src) + } + } + } + } +} + +// explainPath prints an explanation of how src flows to the walk root. +func (b *batch) explainPath(root, src *location) []*logopt.LoggedOpt { + visited := make(map[*location]bool) + pos := base.FmtPos(src.n.Pos()) + var explanation []*logopt.LoggedOpt + for { + // Prevent infinite loop. + if visited[src] { + if base.Flag.LowerM >= 2 { + fmt.Printf("%s: warning: truncated explanation due to assignment cycle; see golang.org/issue/35518\n", pos) + } + break + } + visited[src] = true + dst := src.dst + edge := &dst.edges[src.dstEdgeIdx] + if edge.src != src { + base.Fatalf("path inconsistency: %v != %v", edge.src, src) + } + + explanation = b.explainFlow(pos, dst, src, edge.derefs, edge.notes, explanation) + + if dst == root { + break + } + src = dst + } + + return explanation +} + +func (b *batch) explainFlow(pos string, dst, srcloc *location, derefs int, notes *note, explanation []*logopt.LoggedOpt) []*logopt.LoggedOpt { + ops := "&" + if derefs >= 0 { + ops = strings.Repeat("*", derefs) + } + print := base.Flag.LowerM >= 2 + + flow := fmt.Sprintf(" flow: %s ← %s%v:", b.explainLoc(dst), ops, b.explainLoc(srcloc)) + if print { + fmt.Printf("%s:%s\n", pos, flow) + } + if logopt.Enabled() { + var epos src.XPos + if notes != nil { + epos = notes.where.Pos() + } else if srcloc != nil && srcloc.n != nil { + epos = srcloc.n.Pos() + } + var e_curfn *ir.Func // TODO(mdempsky): Fix. + explanation = append(explanation, logopt.NewLoggedOpt(epos, epos, "escflow", "escape", ir.FuncName(e_curfn), flow)) + } + + for note := notes; note != nil; note = note.next { + if print { + fmt.Printf("%s: from %v (%v) at %s\n", pos, note.where, note.why, base.FmtPos(note.where.Pos())) + } + if logopt.Enabled() { + var e_curfn *ir.Func // TODO(mdempsky): Fix. + notePos := note.where.Pos() + explanation = append(explanation, logopt.NewLoggedOpt(notePos, notePos, "escflow", "escape", ir.FuncName(e_curfn), + fmt.Sprintf(" from %v (%v)", note.where, note.why))) + } + } + return explanation +} + +func (b *batch) explainLoc(l *location) string { + if l == &b.heapLoc { + return "{heap}" + } + if l.n == nil { + // TODO(mdempsky): Omit entirely. + return "{temp}" + } + if l.n.Op() == ir.ONAME { + return fmt.Sprintf("%v", l.n) + } + return fmt.Sprintf("{storage for %v}", l.n) +} + +// outlives reports whether values stored in l may survive beyond +// other's lifetime if stack allocated. +func (b *batch) outlives(l, other *location) bool { + // The heap outlives everything. + if l.hasAttr(attrEscapes) { + return true + } + + // Pseudo-locations that don't really exist. + if l == &b.mutatorLoc || l == &b.calleeLoc { + return false + } + + // We don't know what callers do with returned values, so + // pessimistically we need to assume they flow to the heap and + // outlive everything too. + if l.paramOut { + // Exception: Closures can return locations allocated outside of + // them without forcing them to the heap, if we can statically + // identify all call sites. For example: + // + // var u int // okay to stack allocate + // fn := func() *int { return &u }() + // *fn() = 42 + if ir.ContainsClosure(other.curfn, l.curfn) && !l.curfn.ClosureResultsLost() { + return false + } + + return true + } + + // If l and other are within the same function, then l + // outlives other if it was declared outside other's loop + // scope. For example: + // + // var l *int + // for { + // l = new(int) // must heap allocate: outlives for loop + // } + if l.curfn == other.curfn && l.loopDepth < other.loopDepth { + return true + } + + // If other is declared within a child closure of where l is + // declared, then l outlives it. For example: + // + // var l *int + // func() { + // l = new(int) // must heap allocate: outlives call frame (if not inlined) + // }() + if ir.ContainsClosure(l.curfn, other.curfn) { + return true + } + + return false +} + +// queue implements a queue of locations for use in WalkAll and WalkOne. +// It supports pushing to front & back, and popping from front. +// TODO(thepudds): does cmd/compile have a deque or similar somewhere? +type queue struct { + locs []*location + head int // index of front element + tail int // next back element + elems int +} + +func newQueue(capacity int) *queue { + capacity = max(capacity, 2) + capacity = 1 << bits.Len64(uint64(capacity-1)) // round up to a power of 2 + return &queue{locs: make([]*location, capacity)} +} + +// pushFront adds an element to the front of the queue. +func (q *queue) pushFront(loc *location) { + if q.elems == len(q.locs) { + q.grow() + } + q.head = q.wrap(q.head - 1) + q.locs[q.head] = loc + q.elems++ +} + +// pushBack adds an element to the back of the queue. +func (q *queue) pushBack(loc *location) { + if q.elems == len(q.locs) { + q.grow() + } + q.locs[q.tail] = loc + q.tail = q.wrap(q.tail + 1) + q.elems++ +} + +// popFront removes the front of the queue. +func (q *queue) popFront() *location { + if q.elems == 0 { + return nil + } + loc := q.locs[q.head] + q.head = q.wrap(q.head + 1) + q.elems-- + return loc +} + +// grow doubles the capacity. +func (q *queue) grow() { + newLocs := make([]*location, len(q.locs)*2) + for i := range q.elems { + // Copy over our elements in order. + newLocs[i] = q.locs[q.wrap(q.head+i)] + } + q.locs = newLocs + q.head = 0 + q.tail = q.elems +} + +func (q *queue) len() int { return q.elems } +func (q *queue) wrap(i int) int { return i & (len(q.locs) - 1) } diff --git a/go/src/cmd/compile/internal/escape/stmt.go b/go/src/cmd/compile/internal/escape/stmt.go new file mode 100644 index 0000000000000000000000000000000000000000..2388873caf7bf5a147751ba0d83d342f553eefdf --- /dev/null +++ b/go/src/cmd/compile/internal/escape/stmt.go @@ -0,0 +1,218 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package escape + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "fmt" +) + +// stmt evaluates a single Go statement. +func (e *escape) stmt(n ir.Node) { + if n == nil { + return + } + + lno := ir.SetPos(n) + defer func() { + base.Pos = lno + }() + + if base.Flag.LowerM > 2 { + fmt.Printf("%v:[%d] %v stmt: %v\n", base.FmtPos(base.Pos), e.loopDepth, e.curfn, n) + } + + e.stmts(n.Init()) + + switch n.Op() { + default: + base.Fatalf("unexpected stmt: %v", n) + + case ir.OFALL, ir.OINLMARK: + // nop + + case ir.OBREAK, ir.OCONTINUE, ir.OGOTO: + // TODO(mdempsky): Handle dead code? + + case ir.OBLOCK: + n := n.(*ir.BlockStmt) + e.stmts(n.List) + + case ir.ODCL: + // Record loop depth at declaration. + n := n.(*ir.Decl) + if !ir.IsBlank(n.X) { + e.dcl(n.X) + } + + case ir.OLABEL: + n := n.(*ir.LabelStmt) + if n.Label.IsBlank() { + break + } + switch e.labels[n.Label] { + case nonlooping: + if base.Flag.LowerM > 2 { + fmt.Printf("%v:%v non-looping label\n", base.FmtPos(base.Pos), n) + } + case looping: + if base.Flag.LowerM > 2 { + fmt.Printf("%v: %v looping label\n", base.FmtPos(base.Pos), n) + } + e.loopDepth++ + default: + base.Fatalf("label %v missing tag", n.Label) + } + delete(e.labels, n.Label) + + case ir.OIF: + n := n.(*ir.IfStmt) + e.discard(n.Cond) + e.block(n.Body) + e.block(n.Else) + + case ir.OCHECKNIL: + n := n.(*ir.UnaryExpr) + e.discard(n.X) + + case ir.OFOR: + n := n.(*ir.ForStmt) + base.Assert(!n.DistinctVars) // Should all be rewritten before escape analysis + e.loopDepth++ + e.discard(n.Cond) + e.stmt(n.Post) + e.block(n.Body) + e.loopDepth-- + + case ir.ORANGE: + // for Key, Value = range X { Body } + n := n.(*ir.RangeStmt) + base.Assert(!n.DistinctVars) // Should all be rewritten before escape analysis + + // X is evaluated outside the loop and persists until the loop + // terminates. + tmp := e.newLoc(nil, true) + e.expr(tmp.asHole(), n.X) + + e.loopDepth++ + ks := e.addrs([]ir.Node{n.Key, n.Value}) + if n.X.Type().IsArray() { + e.flow(ks[1].note(n, "range"), tmp) + } else { + e.flow(ks[1].deref(n, "range-deref"), tmp) + } + e.reassigned(ks, n) + + e.block(n.Body) + e.loopDepth-- + + case ir.OSWITCH: + n := n.(*ir.SwitchStmt) + + if guard, ok := n.Tag.(*ir.TypeSwitchGuard); ok { + var ks []hole + if guard.Tag != nil { + for _, cas := range n.Cases { + cv := cas.Var + k := e.dcl(cv) // type switch variables have no ODCL. + if cv.Type().HasPointers() { + ks = append(ks, k.dotType(cv.Type(), cas, "switch case")) + } + } + } + e.expr(e.teeHole(ks...), n.Tag.(*ir.TypeSwitchGuard).X) + } else { + e.discard(n.Tag) + } + + for _, cas := range n.Cases { + e.discards(cas.List) + e.block(cas.Body) + } + + case ir.OSELECT: + n := n.(*ir.SelectStmt) + for _, cas := range n.Cases { + e.stmt(cas.Comm) + e.block(cas.Body) + } + case ir.ORECV: + // TODO(mdempsky): Consider e.discard(n.Left). + n := n.(*ir.UnaryExpr) + e.exprSkipInit(e.discardHole(), n) // already visited n.Ninit + case ir.OSEND: + n := n.(*ir.SendStmt) + e.discard(n.Chan) + e.assignHeap(n.Value, "send", n) + + case ir.OAS: + n := n.(*ir.AssignStmt) + e.assignList([]ir.Node{n.X}, []ir.Node{n.Y}, "assign", n) + case ir.OASOP: + n := n.(*ir.AssignOpStmt) + // TODO(mdempsky): Worry about OLSH/ORSH? + e.assignList([]ir.Node{n.X}, []ir.Node{n.Y}, "assign", n) + case ir.OAS2: + n := n.(*ir.AssignListStmt) + e.assignList(n.Lhs, n.Rhs, "assign-pair", n) + + case ir.OAS2DOTTYPE: // v, ok = x.(type) + n := n.(*ir.AssignListStmt) + e.assignList(n.Lhs, n.Rhs, "assign-pair-dot-type", n) + case ir.OAS2MAPR: // v, ok = m[k] + n := n.(*ir.AssignListStmt) + e.assignList(n.Lhs, n.Rhs, "assign-pair-mapr", n) + case ir.OAS2RECV, ir.OSELRECV2: // v, ok = <-ch + n := n.(*ir.AssignListStmt) + e.assignList(n.Lhs, n.Rhs, "assign-pair-receive", n) + + case ir.OAS2FUNC: + n := n.(*ir.AssignListStmt) + e.stmts(n.Rhs[0].Init()) + ks := e.addrs(n.Lhs) + e.call(ks, n.Rhs[0]) + e.reassigned(ks, n) + case ir.ORETURN: + n := n.(*ir.ReturnStmt) + results := e.curfn.Type().Results() + dsts := make([]ir.Node, len(results)) + for i, res := range results { + dsts[i] = res.Nname.(*ir.Name) + } + e.assignList(dsts, n.Results, "return", n) + case ir.OCALLFUNC, ir.OCALLMETH, ir.OCALLINTER, ir.OINLCALL, ir.OCLEAR, ir.OCLOSE, ir.OCOPY, ir.ODELETE, ir.OPANIC, ir.OPRINT, ir.OPRINTLN, ir.ORECOVER: + e.call(nil, n) + case ir.OGO, ir.ODEFER: + n := n.(*ir.GoDeferStmt) + e.goDeferStmt(n) + + case ir.OTAILCALL: + n := n.(*ir.TailCallStmt) + e.call(nil, n.Call) + } +} + +func (e *escape) stmts(l ir.Nodes) { + for _, n := range l { + e.stmt(n) + } +} + +// block is like stmts, but preserves loopDepth. +func (e *escape) block(l ir.Nodes) { + old := e.loopDepth + e.stmts(l) + e.loopDepth = old +} + +func (e *escape) dcl(n *ir.Name) hole { + if n.Curfn != e.curfn || n.IsClosureVar() { + base.Fatalf("bad declaration of %v", n) + } + loc := e.oldLoc(n) + loc.loopDepth = e.loopDepth + return loc.asHole() +} diff --git a/go/src/cmd/compile/internal/escape/utils.go b/go/src/cmd/compile/internal/escape/utils.go new file mode 100644 index 0000000000000000000000000000000000000000..2718a7f841817e5f2726b7c892d41443d64aec91 --- /dev/null +++ b/go/src/cmd/compile/internal/escape/utils.go @@ -0,0 +1,243 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package escape + +import ( + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" +) + +func isSliceSelfAssign(dst, src ir.Node) bool { + // Detect the following special case. + // + // func (b *Buffer) Foo() { + // n, m := ... + // b.buf = b.buf[n:m] + // } + // + // This assignment is a no-op for escape analysis, + // it does not store any new pointers into b that were not already there. + // However, without this special case b will escape, because we assign to OIND/ODOTPTR. + // Here we assume that the statement will not contain calls, + // that is, that order will move any calls to init. + // Otherwise base ONAME value could change between the moments + // when we evaluate it for dst and for src. + + // dst is ONAME dereference. + var dstX ir.Node + switch dst.Op() { + default: + return false + case ir.ODEREF: + dst := dst.(*ir.StarExpr) + dstX = dst.X + case ir.ODOTPTR: + dst := dst.(*ir.SelectorExpr) + dstX = dst.X + } + if dstX.Op() != ir.ONAME { + return false + } + // src is a slice operation. + switch src.Op() { + case ir.OSLICE, ir.OSLICE3, ir.OSLICESTR: + // OK. + case ir.OSLICEARR, ir.OSLICE3ARR: + // Since arrays are embedded into containing object, + // slice of non-pointer array will introduce a new pointer into b that was not already there + // (pointer to b itself). After such assignment, if b contents escape, + // b escapes as well. If we ignore such OSLICEARR, we will conclude + // that b does not escape when b contents do. + // + // Pointer to an array is OK since it's not stored inside b directly. + // For slicing an array (not pointer to array), there is an implicit OADDR. + // We check that to determine non-pointer array slicing. + src := src.(*ir.SliceExpr) + if src.X.Op() == ir.OADDR { + return false + } + default: + return false + } + // slice is applied to ONAME dereference. + var baseX ir.Node + switch base := src.(*ir.SliceExpr).X; base.Op() { + default: + return false + case ir.ODEREF: + base := base.(*ir.StarExpr) + baseX = base.X + case ir.ODOTPTR: + base := base.(*ir.SelectorExpr) + baseX = base.X + } + if baseX.Op() != ir.ONAME { + return false + } + // dst and src reference the same base ONAME. + return dstX.(*ir.Name) == baseX.(*ir.Name) +} + +// isSelfAssign reports whether assignment from src to dst can +// be ignored by the escape analysis as it's effectively a self-assignment. +func isSelfAssign(dst, src ir.Node) bool { + if isSliceSelfAssign(dst, src) { + return true + } + + // Detect trivial assignments that assign back to the same object. + // + // It covers these cases: + // val.x = val.y + // val.x[i] = val.y[j] + // val.x1.x2 = val.x1.y2 + // ... etc + // + // These assignments do not change assigned object lifetime. + + if dst == nil || src == nil || dst.Op() != src.Op() { + return false + } + + // The expression prefix must be both "safe" and identical. + switch dst.Op() { + case ir.ODOT, ir.ODOTPTR: + // Safe trailing accessors that are permitted to differ. + dst := dst.(*ir.SelectorExpr) + src := src.(*ir.SelectorExpr) + return ir.SameSafeExpr(dst.X, src.X) + case ir.OINDEX: + dst := dst.(*ir.IndexExpr) + src := src.(*ir.IndexExpr) + if mayAffectMemory(dst.Index) || mayAffectMemory(src.Index) { + return false + } + return ir.SameSafeExpr(dst.X, src.X) + default: + return false + } +} + +// mayAffectMemory reports whether evaluation of n may affect the program's +// memory state. If the expression can't affect memory state, then it can be +// safely ignored by the escape analysis. +func mayAffectMemory(n ir.Node) bool { + // We may want to use a list of "memory safe" ops instead of generally + // "side-effect free", which would include all calls and other ops that can + // allocate or change global state. For now, it's safer to start with the latter. + // + // We're ignoring things like division by zero, index out of range, + // and nil pointer dereference here. + + // TODO(rsc): It seems like it should be possible to replace this with + // an ir.Any looking for any op that's not the ones in the case statement. + // But that produces changes in the compiled output detected by buildall. + switch n.Op() { + case ir.ONAME, ir.OLITERAL, ir.ONIL: + return false + + case ir.OADD, ir.OSUB, ir.OOR, ir.OXOR, ir.OMUL, ir.OLSH, ir.ORSH, ir.OAND, ir.OANDNOT, ir.ODIV, ir.OMOD: + n := n.(*ir.BinaryExpr) + return mayAffectMemory(n.X) || mayAffectMemory(n.Y) + + case ir.OINDEX: + n := n.(*ir.IndexExpr) + return mayAffectMemory(n.X) || mayAffectMemory(n.Index) + + case ir.OCONVNOP, ir.OCONV: + n := n.(*ir.ConvExpr) + return mayAffectMemory(n.X) + + case ir.OLEN, ir.OCAP, ir.ONOT, ir.OBITNOT, ir.OPLUS, ir.ONEG: + n := n.(*ir.UnaryExpr) + return mayAffectMemory(n.X) + + case ir.ODOT, ir.ODOTPTR: + n := n.(*ir.SelectorExpr) + return mayAffectMemory(n.X) + + case ir.ODEREF: + n := n.(*ir.StarExpr) + return mayAffectMemory(n.X) + + default: + return true + } +} + +// HeapAllocReason returns the reason the given Node must be heap +// allocated, or the empty string if it doesn't. +func HeapAllocReason(n ir.Node) string { + if n == nil || n.Type() == nil { + return "" + } + + // Parameters are always passed via the stack. + if n.Op() == ir.ONAME { + n := n.(*ir.Name) + if n.Class == ir.PPARAM || n.Class == ir.PPARAMOUT { + return "" + } + } + + if n.Type().Size() > ir.MaxStackVarSize { + return "too large for stack" + } + if n.Type().Alignment() > int64(types.PtrSize) { + return "too aligned for stack" + } + + if (n.Op() == ir.ONEW || n.Op() == ir.OPTRLIT) && n.Type().Elem().Size() > ir.MaxImplicitStackVarSize { + return "too large for stack" + } + if (n.Op() == ir.ONEW || n.Op() == ir.OPTRLIT) && n.Type().Elem().Alignment() > int64(types.PtrSize) { + return "too aligned for stack" + } + + if n.Op() == ir.OCLOSURE && typecheck.ClosureType(n.(*ir.ClosureExpr)).Size() > ir.MaxImplicitStackVarSize { + return "too large for stack" + } + if n.Op() == ir.OMETHVALUE && typecheck.MethodValueType(n.(*ir.SelectorExpr)).Size() > ir.MaxImplicitStackVarSize { + return "too large for stack" + } + + if n.Op() == ir.OMAKESLICE { + n := n.(*ir.MakeExpr) + + r := n.Cap + if n.Cap == nil { + r = n.Len + } + + elem := n.Type().Elem() + if elem.Size() == 0 { + // TODO: stack allocate these? See #65685. + return "zero-sized element" + } + if !ir.IsSmallIntConst(r) { + // For non-constant sizes, we do a hybrid approach: + // + // if cap <= K { + // var backing [K]E + // s = backing[:len:cap] + // } else { + // s = makeslice(E, len, cap) + // } + // + // It costs a constant amount of stack space, but may + // avoid a heap allocation. + // Note we have to be careful that assigning s[i] = v + // still escapes v, because we forbid heap->stack pointers. + // Implementation is in ../walk/builtin.go:walkMakeSlice. + return "" + } + if ir.Int64Val(r) > ir.MaxImplicitStackVarSize/elem.Size() { + return "too large for stack" + } + } + + return "" +} diff --git a/go/src/cmd/compile/internal/gc/compile.go b/go/src/cmd/compile/internal/gc/compile.go new file mode 100644 index 0000000000000000000000000000000000000000..1eb4b8cc37c30c18a8362049d12e0dc4c728b99d --- /dev/null +++ b/go/src/cmd/compile/internal/gc/compile.go @@ -0,0 +1,215 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gc + +import ( + "cmp" + "internal/race" + "math/rand" + "slices" + "sync" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/liveness" + "cmd/compile/internal/objw" + "cmd/compile/internal/pgoir" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/staticinit" + "cmd/compile/internal/types" + "cmd/compile/internal/walk" + "cmd/internal/obj" +) + +// "Portable" code generation. + +var ( + compilequeue []*ir.Func // functions waiting to be compiled +) + +func enqueueFunc(fn *ir.Func, symABIs *ssagen.SymABIs) { + if ir.CurFunc != nil { + base.FatalfAt(fn.Pos(), "enqueueFunc %v inside %v", fn, ir.CurFunc) + } + + if ir.FuncName(fn) == "_" { + // Skip compiling blank functions. + // Frontend already reported any spec-mandated errors (#29870). + return + } + + if fn.IsClosure() { + return // we'll get this as part of its enclosing function + } + + if ssagen.CreateWasmImportWrapper(fn) { + return + } + + if len(fn.Body) == 0 { + if ir.IsIntrinsicSym(fn.Sym()) && fn.Sym().Linkname == "" && !symABIs.HasDef(fn.Sym()) { + // Generate the function body for a bodyless intrinsic, in case it + // is used in a non-call context (e.g. as a function pointer). + // We skip functions defined in assembly, or has a linkname (which + // could be defined in another package). + ssagen.GenIntrinsicBody(fn) + } else { + // Initialize ABI wrappers if necessary. + ir.InitLSym(fn, false) + types.CalcSize(fn.Type()) + a := ssagen.AbiForBodylessFuncStackMap(fn) + abiInfo := a.ABIAnalyzeFuncType(fn.Type()) // abiInfo has spill/home locations for wrapper + if fn.ABI == obj.ABI0 { + // The current args_stackmap generation assumes the function + // is ABI0, and only ABI0 assembly function can have a FUNCDATA + // reference to args_stackmap (see cmd/internal/obj/plist.go:Flushplist). + // So avoid introducing an args_stackmap if the func is not ABI0. + liveness.WriteFuncMap(fn, abiInfo) + + x := ssagen.EmitArgInfo(fn, abiInfo) + objw.Global(x, int32(len(x.P)), obj.RODATA|obj.LOCAL) + } + return + } + } + + errorsBefore := base.Errors() + + todo := []*ir.Func{fn} + for len(todo) > 0 { + next := todo[len(todo)-1] + todo = todo[:len(todo)-1] + + prepareFunc(next) + todo = append(todo, next.Closures...) + } + + if base.Errors() > errorsBefore { + return + } + + // Enqueue just fn itself. compileFunctions will handle + // scheduling compilation of its closures after it's done. + compilequeue = append(compilequeue, fn) +} + +// prepareFunc handles any remaining frontend compilation tasks that +// aren't yet safe to perform concurrently. +func prepareFunc(fn *ir.Func) { + // Set up the function's LSym early to avoid data races with the assemblers. + // Do this before walk, as walk needs the LSym to set attributes/relocations + // (e.g. in MarkTypeUsedInInterface). + ir.InitLSym(fn, true) + + // If this function is a compiler-generated outlined global map + // initializer function, register its LSym for later processing. + if staticinit.MapInitToVar != nil { + if _, ok := staticinit.MapInitToVar[fn]; ok { + ssagen.RegisterMapInitLsym(fn.Linksym()) + } + } + + // Calculate parameter offsets. + types.CalcSize(fn.Type()) + + // Generate wrappers between Go ABI and Wasm ABI, for a wasmexport + // function. + // Must be done after InitLSym and CalcSize. + ssagen.GenWasmExportWrapper(fn) + + ir.CurFunc = fn + walk.Walk(fn) + ir.CurFunc = nil // enforce no further uses of CurFunc + + base.Ctxt.DwTextCount++ +} + +// compileFunctions compiles all functions in compilequeue. +// It fans out nBackendWorkers to do the work +// and waits for them to complete. +func compileFunctions(profile *pgoir.Profile) { + if race.Enabled { + // Randomize compilation order to try to shake out races. + tmp := make([]*ir.Func, len(compilequeue)) + perm := rand.Perm(len(compilequeue)) + for i, v := range perm { + tmp[v] = compilequeue[i] + } + copy(compilequeue, tmp) + } else { + // Compile the longest functions first, + // since they're most likely to be the slowest. + // This helps avoid stragglers. + slices.SortFunc(compilequeue, func(a, b *ir.Func) int { + return cmp.Compare(len(b.Body), len(a.Body)) + }) + } + + // By default, we perform work right away on the current goroutine + // as the solo worker. + queue := func(work func(int)) { + work(0) + } + + if nWorkers := base.Flag.LowerC; nWorkers > 1 { + // For concurrent builds, we allow the work queue + // to grow arbitrarily large, but only nWorkers work items + // can be running concurrently. + workq := make(chan func(int)) + done := make(chan int) + go func() { + ids := make([]int, nWorkers) + for i := range ids { + ids[i] = i + } + var pending []func(int) + for { + select { + case work := <-workq: + pending = append(pending, work) + case id := <-done: + ids = append(ids, id) + } + for len(pending) > 0 && len(ids) > 0 { + work := pending[len(pending)-1] + id := ids[len(ids)-1] + pending = pending[:len(pending)-1] + ids = ids[:len(ids)-1] + go func() { + work(id) + done <- id + }() + } + } + }() + queue = func(work func(int)) { + workq <- work + } + } + + var wg sync.WaitGroup + var compile func([]*ir.Func) + compile = func(fns []*ir.Func) { + wg.Add(len(fns)) + for _, fn := range fns { + fn := fn + queue(func(worker int) { + ssagen.Compile(fn, worker, profile) + compile(fn.Closures) + wg.Done() + }) + } + } + + types.CalcSizeDisabled = true // not safe to calculate sizes concurrently + base.Ctxt.InParallel = true + + compile(compilequeue) + compilequeue = nil + wg.Wait() + + base.Ctxt.InParallel = false + types.CalcSizeDisabled = false +} diff --git a/go/src/cmd/compile/internal/gc/export.go b/go/src/cmd/compile/internal/gc/export.go new file mode 100644 index 0000000000000000000000000000000000000000..9afbeb9d3b5c9197bdad042ccbde1c32b0c6f59d --- /dev/null +++ b/go/src/cmd/compile/internal/gc/export.go @@ -0,0 +1,53 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gc + +import ( + "fmt" + "go/constant" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/bio" +) + +func dumpasmhdr() { + b, err := bio.Create(base.Flag.AsmHdr) + if err != nil { + base.Fatalf("%v", err) + } + fmt.Fprintf(b, "// generated by compile -asmhdr from package %s\n\n", types.LocalPkg.Name) + for _, n := range typecheck.Target.AsmHdrDecls { + if n.Sym().IsBlank() { + continue + } + switch n.Op() { + case ir.OLITERAL: + t := n.Val().Kind() + if t == constant.Float || t == constant.Complex { + break + } + fmt.Fprintf(b, "#define const_%s %v\n", n.Sym().Name, n.Val().ExactString()) + + case ir.OTYPE: + t := n.Type() + if !t.IsStruct() || t.StructType().Map != nil || t.IsFuncArgStruct() { + break + } + fmt.Fprintf(b, "#define %s__size %d\n", n.Sym().Name, int(t.Size())) + for _, f := range t.Fields() { + if !f.Sym.IsBlank() { + fmt.Fprintf(b, "#define %s_%s %d\n", n.Sym().Name, f.Sym.Name, int(f.Offset)) + } + } + } + } + + if err := b.Close(); err != nil { + base.Fatalf("%v", err) + } +} diff --git a/go/src/cmd/compile/internal/gc/main.go b/go/src/cmd/compile/internal/gc/main.go new file mode 100644 index 0000000000000000000000000000000000000000..afa16508d1994e924e97d42d98263177aa403da9 --- /dev/null +++ b/go/src/cmd/compile/internal/gc/main.go @@ -0,0 +1,417 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gc + +import ( + "bufio" + "bytes" + "cmd/compile/internal/base" + "cmd/compile/internal/bloop" + "cmd/compile/internal/coverage" + "cmd/compile/internal/deadlocals" + "cmd/compile/internal/dwarfgen" + "cmd/compile/internal/escape" + "cmd/compile/internal/inline" + "cmd/compile/internal/inline/interleaved" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/loopvar" + "cmd/compile/internal/noder" + "cmd/compile/internal/pgoir" + "cmd/compile/internal/pkginit" + "cmd/compile/internal/reflectdata" + "cmd/compile/internal/rttype" + "cmd/compile/internal/slice" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/staticinit" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/dwarf" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" + "cmd/internal/telemetry/counter" + "flag" + "fmt" + "internal/buildcfg" + "log" + "os" + "runtime" +) + +// handlePanic ensures that we print out an "internal compiler error" for any panic +// or runtime exception during front-end compiler processing (unless there have +// already been some compiler errors). It may also be invoked from the explicit panic in +// hcrash(), in which case, we pass the panic on through. +func handlePanic() { + if err := recover(); err != nil { + if err == "-h" { + // Force real panic now with -h option (hcrash) - the error + // information will have already been printed. + panic(err) + } + base.Fatalf("panic: %v", err) + } +} + +// Main parses flags and Go source files specified in the command-line +// arguments, type-checks the parsed Go package, compiles functions to machine +// code, and finally writes the compiled package definition to disk. +func Main(archInit func(*ssagen.ArchInfo)) { + base.Timer.Start("fe", "init") + counter.Open() + counter.Inc("compile/invocations") + + defer handlePanic() + + archInit(&ssagen.Arch) + + base.Ctxt = obj.Linknew(ssagen.Arch.LinkArch) + base.Ctxt.DiagFunc = base.Errorf + base.Ctxt.DiagFlush = base.FlushErrors + base.Ctxt.Bso = bufio.NewWriter(os.Stdout) + + // UseBASEntries is preferred because it shaves about 2% off build time, but LLDB, dsymutil, and dwarfdump + // on Darwin don't support it properly, especially since macOS 10.14 (Mojave). This is exposed as a flag + // to allow testing with LLVM tools on Linux, and to help with reporting this bug to the LLVM project. + // See bugs 31188 and 21945 (CLs 170638, 98075, 72371). + base.Ctxt.UseBASEntries = base.Ctxt.Headtype != objabi.Hdarwin + + base.DebugSSA = ssa.PhaseOption + base.ParseFlags() + + if flagGCStart := base.Debug.GCStart; flagGCStart > 0 || // explicit flags overrides environment variable disable of GC boost + os.Getenv("GOGC") == "" && os.Getenv("GOMEMLIMIT") == "" && base.Flag.LowerC != 1 { // explicit GC knobs or no concurrency implies default heap + startHeapMB := int64(128) + if flagGCStart > 0 { + startHeapMB = int64(flagGCStart) + } + base.AdjustStartingHeap(uint64(startHeapMB)<<20, 0, 0, 0, base.Debug.GCAdjust == 1) + } + + types.LocalPkg = types.NewPkg(base.Ctxt.Pkgpath, "") + + // pseudo-package, for scoping + types.BuiltinPkg = types.NewPkg("go.builtin", "") // TODO(gri) name this package go.builtin? + types.BuiltinPkg.Prefix = "go:builtin" + + // pseudo-package, accessed by import "unsafe" + types.UnsafePkg = types.NewPkg("unsafe", "unsafe") + + // Pseudo-package that contains the compiler's builtin + // declarations for package runtime. These are declared in a + // separate package to avoid conflicts with package runtime's + // actual declarations, which may differ intentionally but + // insignificantly. + ir.Pkgs.Runtime = types.NewPkg("go.runtime", "runtime") + ir.Pkgs.Runtime.Prefix = "runtime" + + // Pseudo-package that contains the compiler's builtin + // declarations for maps. + ir.Pkgs.InternalMaps = types.NewPkg("go.internal/runtime/maps", "internal/runtime/maps") + ir.Pkgs.InternalMaps.Prefix = "internal/runtime/maps" + + // pseudo-packages used in symbol tables + ir.Pkgs.Itab = types.NewPkg("go.itab", "go.itab") + ir.Pkgs.Itab.Prefix = "go:itab" + + // pseudo-package used for methods with anonymous receivers + ir.Pkgs.Go = types.NewPkg("go", "") + + // pseudo-package for use with code coverage instrumentation. + ir.Pkgs.Coverage = types.NewPkg("go.coverage", "runtime/coverage") + ir.Pkgs.Coverage.Prefix = "runtime/coverage" + + // Record flags that affect the build result. (And don't + // record flags that don't, since that would cause spurious + // changes in the binary.) + dwarfgen.RecordFlags("B", "N", "l", "msan", "race", "asan", "shared", "dynlink", "dwarf", "dwarflocationlists", "dwarfbasentries", "smallframes", "spectre") + + if !base.EnableTrace && base.Flag.LowerT { + log.Fatalf("compiler not built with support for -t") + } + + // Enable inlining (after RecordFlags, to avoid recording the rewritten -l). For now: + // default: inlining on. (Flag.LowerL == 1) + // -l: inlining off (Flag.LowerL == 0) + // -l=2, -l=3: inlining on again, with extra debugging (Flag.LowerL > 1) + if base.Flag.LowerL <= 1 { + base.Flag.LowerL = 1 - base.Flag.LowerL + } + + if base.Flag.SmallFrames { + ir.MaxStackVarSize = 64 * 1024 + ir.MaxImplicitStackVarSize = 16 * 1024 + } + + if base.Flag.Dwarf { + base.Ctxt.DebugInfo = dwarfgen.Info + base.Ctxt.GenAbstractFunc = dwarfgen.AbstractFunc + base.Ctxt.DwFixups = obj.NewDwarfFixupTable(base.Ctxt) + } else { + // turn off inline generation if no dwarf at all + base.Flag.GenDwarfInl = 0 + base.Ctxt.Flag_locationlists = false + } + if base.Ctxt.Flag_locationlists && len(base.Ctxt.Arch.DWARFRegisters) == 0 { + log.Fatalf("location lists requested but register mapping not available on %v", base.Ctxt.Arch.Name) + } + + types.ParseLangFlag() + + symABIs := ssagen.NewSymABIs() + if base.Flag.SymABIs != "" { + symABIs.ReadSymABIs(base.Flag.SymABIs) + } + + if objabi.LookupPkgSpecial(base.Ctxt.Pkgpath).NoInstrument { + base.Flag.Race = false + base.Flag.MSan = false + base.Flag.ASan = false + } + + ssagen.Arch.LinkArch.Init(base.Ctxt) + startProfile() + if base.Flag.Race || base.Flag.MSan || base.Flag.ASan { + base.Flag.Cfg.Instrumenting = true + } + if base.Flag.Dwarf { + dwarf.EnableLogging(base.Debug.DwarfInl != 0) + } + if base.Debug.SoftFloat != 0 { + ssagen.Arch.SoftFloat = true + } + + if base.Flag.JSON != "" { // parse version,destination from json logging optimization. + logopt.LogJsonOption(base.Flag.JSON) + } + + ir.EscFmt = escape.Fmt + ir.IsIntrinsicCall = ssagen.IsIntrinsicCall + ir.IsIntrinsicSym = ssagen.IsIntrinsicSym + inline.SSADumpInline = ssagen.DumpInline + ssagen.InitEnv() + + types.PtrSize = ssagen.Arch.LinkArch.PtrSize + types.RegSize = ssagen.Arch.LinkArch.RegSize + types.MaxWidth = ssagen.Arch.MAXWIDTH + + typecheck.Target = new(ir.Package) + + base.AutogeneratedPos = makePos(src.NewFileBase("", ""), 1, 0) + + typecheck.InitUniverse() + typecheck.InitRuntime() + rttype.Init() + + // Some intrinsics (notably, the simd intrinsics) mention + // types "eagerly", thus ssagen must be initialized AFTER + // the type system is ready. + ssagen.InitTables() + + // Parse and typecheck input. + noder.LoadPackage(flag.Args()) + + // As a convenience to users (toolchain maintainers, in particular), + // when compiling a package named "main", we default the package + // path to "main" if the -p flag was not specified. + if base.Ctxt.Pkgpath == obj.UnlinkablePkg && types.LocalPkg.Name == "main" { + base.Ctxt.Pkgpath = "main" + types.LocalPkg.Path = "main" + types.LocalPkg.Prefix = "main" + } + + dwarfgen.RecordPackageName() + + // Prepare for backend processing. + ssagen.InitConfig() + + // Apply coverage fixups, if applicable. + coverage.Fixup() + + // Read profile file and build profile-graph and weighted-call-graph. + base.Timer.Start("fe", "pgo-load-profile") + var profile *pgoir.Profile + if base.Flag.PgoProfile != "" { + var err error + profile, err = pgoir.New(base.Flag.PgoProfile) + if err != nil { + log.Fatalf("%s: PGO error: %v", base.Flag.PgoProfile, err) + } + } + + // Apply bloop markings. + bloop.BloopWalk(typecheck.Target) + + // Interleaved devirtualization and inlining. + base.Timer.Start("fe", "devirtualize-and-inline") + interleaved.DevirtualizeAndInlinePackage(typecheck.Target, profile) + + noder.MakeWrappers(typecheck.Target) // must happen after inlining + + // Get variable capture right in for loops. + var transformed []loopvar.VarAndLoop + for _, fn := range typecheck.Target.Funcs { + transformed = append(transformed, loopvar.ForCapture(fn)...) + } + ir.CurFunc = nil + + // Build init task, if needed. + pkginit.MakeTask() + + // Generate ABI wrappers. Must happen before escape analysis + // and doesn't benefit from dead-coding or inlining. + symABIs.GenABIWrappers() + + deadlocals.Funcs(typecheck.Target.Funcs) + + // Escape analysis. + // Required for moving heap allocations onto stack, + // which in turn is required by the closure implementation, + // which stores the addresses of stack variables into the closure. + // If the closure does not escape, it needs to be on the stack + // or else the stack copier will not update it. + // Large values are also moved off stack in escape analysis; + // because large values may contain pointers, it must happen early. + base.Timer.Start("fe", "escapes") + escape.Funcs(typecheck.Target.Funcs) + + slice.Funcs(typecheck.Target.Funcs) + + loopvar.LogTransformations(transformed) + + // Collect information for go:nowritebarrierrec + // checking. This must happen before transforming closures during Walk + // We'll do the final check after write barriers are + // inserted. + if base.Flag.CompilingRuntime { + ssagen.EnableNoWriteBarrierRecCheck() + } + + ir.CurFunc = nil + + reflectdata.WriteBasicTypes() + + // Compile top-level declarations. + // + // There are cyclic dependencies between all of these phases, so we + // need to iterate all of them until we reach a fixed point. + base.Timer.Start("be", "compilefuncs") + for nextFunc, nextExtern := 0, 0; ; { + reflectdata.WriteRuntimeTypes() + + if nextExtern < len(typecheck.Target.Externs) { + switch n := typecheck.Target.Externs[nextExtern]; n.Op() { + case ir.ONAME: + dumpGlobal(n) + case ir.OLITERAL: + dumpGlobalConst(n) + case ir.OTYPE: + reflectdata.NeedRuntimeType(n.Type()) + } + nextExtern++ + continue + } + + if nextFunc < len(typecheck.Target.Funcs) { + enqueueFunc(typecheck.Target.Funcs[nextFunc], symABIs) + nextFunc++ + continue + } + + // The SSA backend supports using multiple goroutines, so keep it + // as late as possible to maximize how much work we can batch and + // process concurrently. + if len(compilequeue) != 0 { + compileFunctions(profile) + continue + } + + // Finalize DWARF inline routine DIEs, then explicitly turn off + // further DWARF inlining generation to avoid problems with + // generated method wrappers. + // + // Note: The DWARF fixup code for inlined calls currently doesn't + // allow multiple invocations, so we intentionally run it just + // once after everything else. Worst case, some generated + // functions have slightly larger DWARF DIEs. + if base.Ctxt.DwFixups != nil { + base.Ctxt.DwFixups.Finalize(base.Ctxt.Pkgpath, base.Debug.DwarfInl != 0) + base.Ctxt.DwFixups = nil + base.Flag.GenDwarfInl = 0 + continue // may have called reflectdata.TypeLinksym (#62156) + } + + break + } + + base.Timer.AddEvent(int64(len(typecheck.Target.Funcs)), "funcs") + + if base.Flag.CompilingRuntime { + // Write barriers are now known. Check the call graph. + ssagen.NoWriteBarrierRecCheck() + } + + // Add keep relocations for global maps. + if base.Debug.WrapGlobalMapCtl != 1 { + staticinit.AddKeepRelocations() + } + + // Write object data to disk. + base.Timer.Start("be", "dumpobj") + dumpdata() + base.Ctxt.NumberSyms() + dumpobj() + if base.Flag.AsmHdr != "" { + dumpasmhdr() + } + + ssagen.CheckLargeStacks() + typecheck.CheckFuncStack() + + if len(compilequeue) != 0 { + base.Fatalf("%d uncompiled functions", len(compilequeue)) + } + + logopt.FlushLoggedOpts(base.Ctxt, base.Ctxt.Pkgpath) + base.ExitIfErrors() + + base.FlushErrors() + base.Timer.Stop() + + if base.Flag.Bench != "" { + if err := writebench(base.Flag.Bench); err != nil { + log.Fatalf("cannot write benchmark data: %v", err) + } + } +} + +func writebench(filename string) error { + f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666) + if err != nil { + return err + } + + var buf bytes.Buffer + fmt.Fprintln(&buf, "commit:", buildcfg.Version) + fmt.Fprintln(&buf, "goos:", runtime.GOOS) + fmt.Fprintln(&buf, "goarch:", runtime.GOARCH) + base.Timer.Write(&buf, "BenchmarkCompile:"+base.Ctxt.Pkgpath+":") + + n, err := f.Write(buf.Bytes()) + if err != nil { + return err + } + if n != buf.Len() { + panic("bad writer") + } + + return f.Close() +} + +func makePos(b *src.PosBase, line, col uint) src.XPos { + return base.Ctxt.PosTable.XPos(src.MakePos(b, line, col)) +} diff --git a/go/src/cmd/compile/internal/gc/obj.go b/go/src/cmd/compile/internal/gc/obj.go new file mode 100644 index 0000000000000000000000000000000000000000..37bbce03189c24294e164a947901966648ad2962 --- /dev/null +++ b/go/src/cmd/compile/internal/gc/obj.go @@ -0,0 +1,296 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gc + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/noder" + "cmd/compile/internal/objw" + "cmd/compile/internal/pkginit" + "cmd/compile/internal/reflectdata" + "cmd/compile/internal/staticdata" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/archive" + "cmd/internal/bio" + "cmd/internal/obj" + "cmd/internal/objabi" + "encoding/json" + "fmt" + "strings" +) + +// These modes say which kind of object file to generate. +// The default use of the toolchain is to set both bits, +// generating a combined compiler+linker object, one that +// serves to describe the package to both the compiler and the linker. +// In fact the compiler and linker read nearly disjoint sections of +// that file, though, so in a distributed build setting it can be more +// efficient to split the output into two files, supplying the compiler +// object only to future compilations and the linker object only to +// future links. +// +// By default a combined object is written, but if -linkobj is specified +// on the command line then the default -o output is a compiler object +// and the -linkobj output is a linker object. +const ( + modeCompilerObj = 1 << iota + modeLinkerObj +) + +func dumpobj() { + if base.Flag.LinkObj == "" { + dumpobj1(base.Flag.LowerO, modeCompilerObj|modeLinkerObj) + return + } + dumpobj1(base.Flag.LowerO, modeCompilerObj) + dumpobj1(base.Flag.LinkObj, modeLinkerObj) +} + +func dumpobj1(outfile string, mode int) { + bout, err := bio.Create(outfile) + if err != nil { + base.FlushErrors() + fmt.Printf("can't create %s: %v\n", outfile, err) + base.ErrorExit() + } + + bout.WriteString("!\n") + + if mode&modeCompilerObj != 0 { + start := startArchiveEntry(bout) + dumpCompilerObj(bout) + finishArchiveEntry(bout, start, "__.PKGDEF") + } + if mode&modeLinkerObj != 0 { + start := startArchiveEntry(bout) + dumpLinkerObj(bout) + finishArchiveEntry(bout, start, "_go_.o") + } + + if err := bout.Close(); err != nil { + base.FlushErrors() + fmt.Printf("error while writing to file %s: %v\n", outfile, err) + base.ErrorExit() + } +} + +func printObjHeader(bout *bio.Writer) { + bout.WriteString(objabi.HeaderString()) + if base.Flag.BuildID != "" { + fmt.Fprintf(bout, "build id %q\n", base.Flag.BuildID) + } + if types.LocalPkg.Name == "main" { + fmt.Fprintf(bout, "main\n") + } + fmt.Fprintf(bout, "\n") // header ends with blank line +} + +func startArchiveEntry(bout *bio.Writer) int64 { + var arhdr [archive.HeaderSize]byte + bout.Write(arhdr[:]) + return bout.Offset() +} + +func finishArchiveEntry(bout *bio.Writer, start int64, name string) { + bout.Flush() + size := bout.Offset() - start + if size&1 != 0 { + bout.WriteByte(0) + } + bout.MustSeek(start-archive.HeaderSize, 0) + + var arhdr [archive.HeaderSize]byte + archive.FormatHeader(arhdr[:], name, size) + bout.Write(arhdr[:]) + bout.Flush() + bout.MustSeek(start+size+(size&1), 0) +} + +func dumpCompilerObj(bout *bio.Writer) { + printObjHeader(bout) + noder.WriteExports(bout) +} + +func dumpdata() { + reflectdata.WriteGCSymbols() + reflectdata.WritePluginTable() + dumpembeds() + + if reflectdata.ZeroSize > 0 { + zero := base.PkgLinksym("go:map", "zero", obj.ABI0) + objw.Global(zero, int32(reflectdata.ZeroSize), obj.DUPOK|obj.RODATA) + zero.Set(obj.AttrStatic, true) + } + + staticdata.WriteFuncSyms() + addGCLocals() +} + +func dumpLinkerObj(bout *bio.Writer) { + printObjHeader(bout) + + if len(typecheck.Target.CgoPragmas) != 0 { + // write empty export section; must be before cgo section + fmt.Fprintf(bout, "\n$$\n\n$$\n\n") + fmt.Fprintf(bout, "\n$$ // cgo\n") + if err := json.NewEncoder(bout).Encode(typecheck.Target.CgoPragmas); err != nil { + base.Fatalf("serializing pragcgobuf: %v", err) + } + fmt.Fprintf(bout, "\n$$\n\n") + } + + fmt.Fprintf(bout, "\n!\n") + + obj.WriteObjFile(base.Ctxt, bout) +} + +func dumpGlobal(n *ir.Name) { + if n.Type() == nil { + base.Fatalf("external %v nil type\n", n) + } + if n.Class == ir.PFUNC { + return + } + if n.Sym().Pkg != types.LocalPkg { + return + } + types.CalcSize(n.Type()) + ggloblnod(n) + if n.CoverageAuxVar() || n.Linksym().Static() { + return + } + base.Ctxt.DwarfGlobal(types.TypeSymName(n.Type()), n.Linksym()) +} + +func dumpGlobalConst(n *ir.Name) { + // only export typed constants + t := n.Type() + if t == nil { + return + } + if n.Sym().Pkg != types.LocalPkg { + return + } + // only export integer constants for now + if !t.IsInteger() { + return + } + v := n.Val() + if t.IsUntyped() { + // Export untyped integers as int (if they fit). + t = types.Types[types.TINT] + if ir.ConstOverflow(v, t) { + return + } + } else { + // If the type of the constant is an instantiated generic, we need to emit + // that type so the linker knows about it. See issue 51245. + _ = reflectdata.TypeLinksym(t) + } + base.Ctxt.DwarfIntConst(n.Sym().Name, types.TypeSymName(t), ir.IntVal(t, v)) +} + +// addGCLocals adds gcargs, gclocals, gcregs, and stack object symbols to Ctxt.Data. +// +// This is done during the sequential phase after compilation, since +// global symbols can't be declared during parallel compilation. +func addGCLocals() { + for _, s := range base.Ctxt.Text { + fn := s.Func() + if fn == nil { + continue + } + for _, gcsym := range []*obj.LSym{fn.GCArgs, fn.GCLocals} { + if gcsym != nil && !gcsym.OnList() { + objw.Global(gcsym, int32(len(gcsym.P)), obj.RODATA|obj.DUPOK) + } + } + if x := fn.StackObjects; x != nil { + objw.Global(x, int32(len(x.P)), obj.RODATA) + x.Set(obj.AttrStatic, true) + } + if x := fn.OpenCodedDeferInfo; x != nil { + objw.Global(x, int32(len(x.P)), obj.RODATA|obj.DUPOK) + } + if x := fn.ArgInfo; x != nil { + objw.Global(x, int32(len(x.P)), obj.RODATA|obj.DUPOK) + x.Set(obj.AttrStatic, true) + } + if x := fn.ArgLiveInfo; x != nil { + objw.Global(x, int32(len(x.P)), obj.RODATA|obj.DUPOK) + x.Set(obj.AttrStatic, true) + } + if x := fn.WrapInfo; x != nil && !x.OnList() { + objw.Global(x, int32(len(x.P)), obj.RODATA|obj.DUPOK) + x.Set(obj.AttrStatic, true) + } + for _, jt := range fn.JumpTables { + objw.Global(jt.Sym, int32(len(jt.Targets)*base.Ctxt.Arch.PtrSize), obj.RODATA) + } + } +} + +func ggloblnod(nam *ir.Name) { + s := nam.Linksym() + + // main_inittask and runtime_inittask in package runtime (and in + // test/initempty.go) aren't real variable declarations, but + // linknamed variables pointing to the compiler's generated + // .inittask symbol. The real symbol was already written out in + // pkginit.Task, so we need to avoid writing them out a second time + // here, otherwise base.Ctxt.Globl will fail. + if strings.HasSuffix(s.Name, "..inittask") && s.OnList() { + return + } + + s.Gotype = reflectdata.TypeLinksym(nam.Type()) + flags := 0 + if nam.Readonly() { + flags = obj.RODATA + } + if nam.Type() != nil && !nam.Type().HasPointers() { + flags |= obj.NOPTR + } + size := nam.Type().Size() + linkname := nam.Sym().Linkname + name := nam.Sym().Name + + var saveType objabi.SymKind + if nam.CoverageAuxVar() { + saveType = s.Type + } + + // We've skipped linkname'd globals's instrument, so we can skip them here as well. + if base.Flag.ASan && linkname == "" && pkginit.InstrumentGlobalsMap[name] != nil { + // Write the new size of instrumented global variables that have + // trailing redzones into object file. + rzSize := pkginit.GetRedzoneSizeForGlobal(size) + sizeWithRZ := rzSize + size + base.Ctxt.Globl(s, sizeWithRZ, flags) + } else { + base.Ctxt.Globl(s, size, flags) + } + if nam.Libfuzzer8BitCounter() { + s.Type = objabi.SLIBFUZZER_8BIT_COUNTER + } + if nam.CoverageAuxVar() && saveType == objabi.SCOVERAGE_COUNTER { + // restore specialized counter type (which Globl call above overwrote) + s.Type = saveType + } + if nam.Sym().Linkname != "" { + // Make sure linkname'd symbol is non-package. When a symbol is + // both imported and linkname'd, s.Pkg may not set to "_" in + // types.Sym.Linksym because LSym already exists. Set it here. + s.Pkg = "_" + } +} + +func dumpembeds() { + for _, v := range typecheck.Target.Embeds { + staticdata.WriteEmbed(v) + } +} diff --git a/go/src/cmd/compile/internal/gc/util.go b/go/src/cmd/compile/internal/gc/util.go new file mode 100644 index 0000000000000000000000000000000000000000..dcaca892db6a671761618fb800fda70f80a4ac82 --- /dev/null +++ b/go/src/cmd/compile/internal/gc/util.go @@ -0,0 +1,130 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gc + +import ( + "net/url" + "os" + "path/filepath" + "runtime" + "runtime/pprof" + tracepkg "runtime/trace" + "strings" + + "cmd/compile/internal/base" +) + +func profileName(fn, suffix string) string { + if strings.HasSuffix(fn, string(os.PathSeparator)) { + err := os.MkdirAll(fn, 0755) + if err != nil { + base.Fatalf("%v", err) + } + } + if fi, statErr := os.Stat(fn); statErr == nil && fi.IsDir() { + fn = filepath.Join(fn, url.PathEscape(base.Ctxt.Pkgpath)+suffix) + } + return fn +} + +func startProfile() { + if base.Flag.CPUProfile != "" { + fn := profileName(base.Flag.CPUProfile, ".cpuprof") + f, err := os.Create(fn) + if err != nil { + base.Fatalf("%v", err) + } + if err := pprof.StartCPUProfile(f); err != nil { + base.Fatalf("%v", err) + } + base.AtExit(func() { + pprof.StopCPUProfile() + if err = f.Close(); err != nil { + base.Fatalf("error closing cpu profile: %v", err) + } + }) + } + if base.Flag.MemProfile != "" { + if base.Flag.MemProfileRate != 0 { + runtime.MemProfileRate = base.Flag.MemProfileRate + } + const ( + gzipFormat = 0 + textFormat = 1 + ) + // compilebench parses the memory profile to extract memstats, + // which are only written in the legacy (text) pprof format. + // See golang.org/issue/18641 and runtime/pprof/pprof.go:writeHeap. + // gzipFormat is what most people want, otherwise + var format = textFormat + fn := base.Flag.MemProfile + if strings.HasSuffix(fn, string(os.PathSeparator)) { + err := os.MkdirAll(fn, 0755) + if err != nil { + base.Fatalf("%v", err) + } + } + if fi, statErr := os.Stat(fn); statErr == nil && fi.IsDir() { + fn = filepath.Join(fn, url.PathEscape(base.Ctxt.Pkgpath)+".memprof") + format = gzipFormat + } + + f, err := os.Create(fn) + + if err != nil { + base.Fatalf("%v", err) + } + base.AtExit(func() { + // Profile all outstanding allocations. + runtime.GC() + if err := pprof.Lookup("heap").WriteTo(f, format); err != nil { + base.Fatalf("%v", err) + } + if err = f.Close(); err != nil { + base.Fatalf("error closing memory profile: %v", err) + } + }) + } else { + // Not doing memory profiling; disable it entirely. + runtime.MemProfileRate = 0 + } + if base.Flag.BlockProfile != "" { + f, err := os.Create(profileName(base.Flag.BlockProfile, ".blockprof")) + if err != nil { + base.Fatalf("%v", err) + } + runtime.SetBlockProfileRate(1) + base.AtExit(func() { + pprof.Lookup("block").WriteTo(f, 0) + f.Close() + }) + } + if base.Flag.MutexProfile != "" { + f, err := os.Create(profileName(base.Flag.MutexProfile, ".mutexprof")) + if err != nil { + base.Fatalf("%v", err) + } + runtime.SetMutexProfileFraction(1) + base.AtExit(func() { + pprof.Lookup("mutex").WriteTo(f, 0) + f.Close() + }) + } + if base.Flag.TraceProfile != "" { + f, err := os.Create(profileName(base.Flag.TraceProfile, ".trace")) + if err != nil { + base.Fatalf("%v", err) + } + if err := tracepkg.Start(f); err != nil { + base.Fatalf("%v", err) + } + base.AtExit(func() { + tracepkg.Stop() + if err = f.Close(); err != nil { + base.Fatalf("error closing trace profile: %v", err) + } + }) + } +} diff --git a/go/src/cmd/compile/internal/importer/gcimporter.go b/go/src/cmd/compile/internal/importer/gcimporter.go new file mode 100644 index 0000000000000000000000000000000000000000..e0aec9823189495e789eeb2c84faaf1a0e47280e --- /dev/null +++ b/go/src/cmd/compile/internal/importer/gcimporter.go @@ -0,0 +1,87 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements the Import function for tests to use gc-generated object files. + +package importer + +import ( + "bufio" + "fmt" + "internal/exportdata" + "internal/pkgbits" + "io" + "os" + + "cmd/compile/internal/types2" +) + +// Import imports a gc-generated package given its import path and srcDir, adds +// the corresponding package object to the packages map, and returns the object. +// The packages map must contain all packages already imported. +// +// This function should only be used in tests. +func Import(packages map[string]*types2.Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *types2.Package, err error) { + var rc io.ReadCloser + var id string + if lookup != nil { + // With custom lookup specified, assume that caller has + // converted path to a canonical import path for use in the map. + if path == "unsafe" { + return types2.Unsafe, nil + } + id = path + + // No need to re-import if the package was imported completely before. + if pkg = packages[id]; pkg != nil && pkg.Complete() { + return + } + f, err := lookup(path) + if err != nil { + return nil, err + } + rc = f + } else { + var filename string + filename, id, err = exportdata.FindPkg(path, srcDir) + if filename == "" { + if path == "unsafe" { + return types2.Unsafe, nil + } + return nil, err + } + + // no need to re-import if the package was imported completely before + if pkg = packages[id]; pkg != nil && pkg.Complete() { + return + } + + // open file + f, err := os.Open(filename) + if err != nil { + return nil, err + } + defer func() { + if err != nil { + // add file name to error + err = fmt.Errorf("%s: %v", filename, err) + } + }() + rc = f + } + defer rc.Close() + + buf := bufio.NewReader(rc) + data, err := exportdata.ReadUnified(buf) + if err != nil { + err = fmt.Errorf("import %q: %v", path, err) + return + } + s := string(data) + + input := pkgbits.NewPkgDecoder(id, s) + pkg = ReadPackage(nil, packages, input) + + return +} diff --git a/go/src/cmd/compile/internal/importer/gcimporter_test.go b/go/src/cmd/compile/internal/importer/gcimporter_test.go new file mode 100644 index 0000000000000000000000000000000000000000..11e4ee6b583b6af839dd7e4938253a4891994c98 --- /dev/null +++ b/go/src/cmd/compile/internal/importer/gcimporter_test.go @@ -0,0 +1,722 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package importer + +import ( + "bytes" + "cmd/compile/internal/syntax" + "cmd/compile/internal/types2" + "fmt" + "go/build" + "internal/exportdata" + "internal/testenv" + "os" + "os/exec" + "path" + "path/filepath" + "runtime" + "strings" + "sync" + "testing" + "time" +) + +func TestMain(m *testing.M) { + build.Default.GOROOT = testenv.GOROOT(nil) + os.Exit(m.Run()) +} + +// compile runs the compiler on filename, with dirname as the working directory, +// and writes the output file to outdirname. +// compile gives the resulting package a packagepath of testdata/. +func compile(t *testing.T, dirname, filename, outdirname string, packagefiles map[string]string) string { + // filename must end with ".go" + basename, ok := strings.CutSuffix(filepath.Base(filename), ".go") + if !ok { + t.Helper() + t.Fatalf("filename doesn't end in .go: %s", filename) + } + objname := basename + ".o" + outname := filepath.Join(outdirname, objname) + pkgpath := path.Join("testdata", basename) + + importcfgfile := os.DevNull + if len(packagefiles) > 0 { + importcfgfile = filepath.Join(outdirname, basename) + ".importcfg" + importcfg := new(bytes.Buffer) + for k, v := range packagefiles { + fmt.Fprintf(importcfg, "packagefile %s=%s\n", k, v) + } + if err := os.WriteFile(importcfgfile, importcfg.Bytes(), 0655); err != nil { + t.Fatal(err) + } + } + + cmd := testenv.Command(t, testenv.GoToolPath(t), "tool", "compile", "-p", pkgpath, "-D", "testdata", "-importcfg", importcfgfile, "-o", outname, filename) + cmd.Dir = dirname + out, err := cmd.CombinedOutput() + if err != nil { + t.Helper() + t.Logf("%s", out) + t.Fatalf("go tool compile %s failed: %s", filename, err) + } + return outname +} + +func testPath(t *testing.T, path, srcDir string) *types2.Package { + t0 := time.Now() + pkg, err := Import(make(map[string]*types2.Package), path, srcDir, nil) + if err != nil { + t.Errorf("testPath(%s): %s", path, err) + return nil + } + t.Logf("testPath(%s): %v", path, time.Since(t0)) + return pkg +} + +func mktmpdir(t *testing.T) string { + tmpdir := t.TempDir() + if err := os.Mkdir(filepath.Join(tmpdir, "testdata"), 0700); err != nil { + t.Fatal("mktmpdir:", err) + } + return tmpdir +} + +func TestImportTestdata(t *testing.T) { + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + testenv.MustHaveGoBuild(t) + + testfiles := map[string][]string{ + "exports.go": {"go/ast"}, + "generics.go": nil, + } + + for testfile, wantImports := range testfiles { + tmpdir := mktmpdir(t) + + importMap := map[string]string{} + for _, pkg := range wantImports { + export, _, err := exportdata.FindPkg(pkg, "testdata") + if export == "" { + t.Fatalf("no export data found for %s: %v", pkg, err) + } + importMap[pkg] = export + } + + compile(t, "testdata", testfile, filepath.Join(tmpdir, "testdata"), importMap) + path := "./testdata/" + strings.TrimSuffix(testfile, ".go") + + if pkg := testPath(t, path, tmpdir); pkg != nil { + // The package's Imports list must include all packages + // explicitly imported by testfile, plus all packages + // referenced indirectly via exported objects in testfile. + got := fmt.Sprint(pkg.Imports()) + for _, want := range wantImports { + if !strings.Contains(got, want) { + t.Errorf(`Package("exports").Imports() = %s, does not contain %s`, got, want) + } + } + } + } +} + +func TestVersionHandling(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + const dir = "./testdata/versions" + list, err := os.ReadDir(dir) + if err != nil { + t.Fatal(err) + } + + tmpdir := mktmpdir(t) + corruptdir := filepath.Join(tmpdir, "testdata", "versions") + if err := os.Mkdir(corruptdir, 0700); err != nil { + t.Fatal(err) + } + + for _, f := range list { + name := f.Name() + if !strings.HasSuffix(name, ".a") { + continue // not a package file + } + if strings.Contains(name, "corrupted") { + continue // don't process a leftover corrupted file + } + pkgpath := "./" + name[:len(name)-2] + + if testing.Verbose() { + t.Logf("importing %s", name) + } + + // test that export data can be imported + _, err := Import(make(map[string]*types2.Package), pkgpath, dir, nil) + if err != nil { + // ok to fail if it fails with a 'not the start of an archive file' error for select files + if strings.Contains(err.Error(), "not the start of an archive file") { + switch name { + case "test_go1.8_4.a", + "test_go1.8_5.a": + continue + } + // fall through + } + // ok to fail if it fails with a 'no longer supported' error for select files + if strings.Contains(err.Error(), "no longer supported") { + switch name { + case "test_go1.7_0.a", + "test_go1.7_1.a", + "test_go1.8_4.a", + "test_go1.8_5.a", + "test_go1.11_6b.a", + "test_go1.11_999b.a": + continue + } + // fall through + } + // ok to fail if it fails with a 'newer version' error for select files + if strings.Contains(err.Error(), "newer version") { + switch name { + case "test_go1.11_999i.a": + continue + } + // fall through + } + t.Errorf("import %q failed: %v", pkgpath, err) + continue + } + + // create file with corrupted export data + // 1) read file + data, err := os.ReadFile(filepath.Join(dir, name)) + if err != nil { + t.Fatal(err) + } + // 2) find export data + i := bytes.Index(data, []byte("\n$$B\n")) + 5 + // Export data can contain "\n$$\n" in string constants, however, + // searching for the next end of section marker "\n$$\n" is good enough for testzs. + j := bytes.Index(data[i:], []byte("\n$$\n")) + i + if i < 0 || j < 0 || i > j { + t.Fatalf("export data section not found (i = %d, j = %d)", i, j) + } + // 3) corrupt the data (increment every 7th byte) + for k := j - 13; k >= i; k -= 7 { + data[k]++ + } + // 4) write the file + pkgpath += "_corrupted" + filename := filepath.Join(corruptdir, pkgpath) + ".a" + os.WriteFile(filename, data, 0666) + + // test that importing the corrupted file results in an error + _, err = Import(make(map[string]*types2.Package), pkgpath, corruptdir, nil) + if err == nil { + t.Errorf("import corrupted %q succeeded", pkgpath) + } else if msg := err.Error(); !strings.Contains(msg, "version skew") { + t.Errorf("import %q error incorrect (%s)", pkgpath, msg) + } + } +} + +func TestImportStdLib(t *testing.T) { + if testing.Short() { + t.Skip("the imports can be expensive, and this test is especially slow when the build cache is empty") + } + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + // Get list of packages in stdlib. Filter out test-only packages with {{if .GoFiles}} check. + var stderr bytes.Buffer + cmd := exec.Command(testenv.GoToolPath(t), "list", "-f", "{{if .GoFiles}}{{.ImportPath}}{{end}}", "std") + cmd.Stderr = &stderr + out, err := cmd.Output() + if err != nil { + t.Fatalf("failed to run go list to determine stdlib packages: %v\nstderr:\n%v", err, stderr.String()) + } + pkgs := strings.Fields(string(out)) + + var nimports int + for _, pkg := range pkgs { + t.Run(pkg, func(t *testing.T) { + if testPath(t, pkg, filepath.Join(testenv.GOROOT(t), "src", path.Dir(pkg))) != nil { + nimports++ + } + }) + } + const minPkgs = 225 // 'GOOS=plan9 go1.18 list std | wc -l' reports 228; most other platforms have more. + if len(pkgs) < minPkgs { + t.Fatalf("too few packages (%d) were imported", nimports) + } + + t.Logf("tested %d imports", nimports) +} + +var importedObjectTests = []struct { + name string + want string +}{ + // non-interfaces + {"crypto.Hash", "type Hash uint"}, + {"go/ast.ObjKind", "type ObjKind int"}, + {"go/types.Qualifier", "type Qualifier func(*Package) string"}, + {"go/types.Comparable", "func Comparable(T Type) bool"}, + {"math.Pi", "const Pi untyped float"}, + {"math.Sin", "func Sin(x float64) float64"}, + {"go/ast.NotNilFilter", "func NotNilFilter(_ string, v reflect.Value) bool"}, + {"internal/exportdata.FindPkg", "func FindPkg(path string, srcDir string) (filename string, id string, err error)"}, + + // interfaces + {"context.Context", "type Context interface{Deadline() (deadline time.Time, ok bool); Done() <-chan struct{}; Err() error; Value(key any) any}"}, + {"crypto.Decrypter", "type Decrypter interface{Decrypt(rand io.Reader, msg []byte, opts DecrypterOpts) (plaintext []byte, err error); Public() PublicKey}"}, + {"encoding.BinaryMarshaler", "type BinaryMarshaler interface{MarshalBinary() (data []byte, err error)}"}, + {"io.Reader", "type Reader interface{Read(p []byte) (n int, err error)}"}, + {"io.ReadWriter", "type ReadWriter interface{Reader; Writer}"}, + {"go/ast.Node", "type Node interface{End() go/token.Pos; Pos() go/token.Pos}"}, + {"go/types.Type", "type Type interface{String() string; Underlying() Type}"}, +} + +func TestImportedTypes(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + for _, test := range importedObjectTests { + s := strings.Split(test.name, ".") + if len(s) != 2 { + t.Fatal("inconsistent test data") + } + importPath := s[0] + objName := s[1] + + pkg, err := Import(make(map[string]*types2.Package), importPath, ".", nil) + if err != nil { + t.Error(err) + continue + } + + obj := pkg.Scope().Lookup(objName) + if obj == nil { + t.Errorf("%s: object not found", test.name) + continue + } + + got := types2.ObjectString(obj, types2.RelativeTo(pkg)) + if got != test.want { + t.Errorf("%s: got %q; want %q", test.name, got, test.want) + } + + if named, _ := obj.Type().(*types2.Named); named != nil { + verifyInterfaceMethodRecvs(t, named, 0) + } + } +} + +// verifyInterfaceMethodRecvs verifies that method receiver types +// are named if the methods belong to a named interface type. +func verifyInterfaceMethodRecvs(t *testing.T, named *types2.Named, level int) { + // avoid endless recursion in case of an embedding bug that lead to a cycle + if level > 10 { + t.Errorf("%s: embeds itself", named) + return + } + + iface, _ := named.Underlying().(*types2.Interface) + if iface == nil { + return // not an interface + } + + // The unified IR importer always sets interface method receiver + // parameters to point to the Interface type, rather than the Named. + // See #49906. + var want types2.Type = iface + + // check explicitly declared methods + for i := 0; i < iface.NumExplicitMethods(); i++ { + m := iface.ExplicitMethod(i) + recv := m.Type().(*types2.Signature).Recv() + if recv == nil { + t.Errorf("%s: missing receiver type", m) + continue + } + if recv.Type() != want { + t.Errorf("%s: got recv type %s; want %s", m, recv.Type(), named) + } + } + + // check embedded interfaces (if they are named, too) + for i := 0; i < iface.NumEmbeddeds(); i++ { + // embedding of interfaces cannot have cycles; recursion will terminate + if etype, _ := iface.EmbeddedType(i).(*types2.Named); etype != nil { + verifyInterfaceMethodRecvs(t, etype, level+1) + } + } +} + +func TestIssue5815(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + pkg := importPkg(t, "strings", ".") + + scope := pkg.Scope() + for _, name := range scope.Names() { + obj := scope.Lookup(name) + if obj.Pkg() == nil { + t.Errorf("no pkg for %s", obj) + } + if tname, _ := obj.(*types2.TypeName); tname != nil { + named := tname.Type().(*types2.Named) + for i := 0; i < named.NumMethods(); i++ { + m := named.Method(i) + if m.Pkg() == nil { + t.Errorf("no pkg for %s", m) + } + } + } + } +} + +// Smoke test to ensure that imported methods get the correct package. +func TestCorrectMethodPackage(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + imports := make(map[string]*types2.Package) + _, err := Import(imports, "net/http", ".", nil) + if err != nil { + t.Fatal(err) + } + + mutex := imports["sync"].Scope().Lookup("Mutex").(*types2.TypeName).Type() + obj, _, _ := types2.LookupFieldOrMethod(types2.NewPointer(mutex), false, nil, "Lock") + lock := obj.(*types2.Func) + if got, want := lock.Pkg().Path(), "sync"; got != want { + t.Errorf("got package path %q; want %q", got, want) + } +} + +func TestIssue13566(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + tmpdir := mktmpdir(t) + testoutdir := filepath.Join(tmpdir, "testdata") + + // b.go needs to be compiled from the output directory so that the compiler can + // find the compiled package a. We pass the full path to compile() so that we + // don't have to copy the file to that directory. + bpath, err := filepath.Abs(filepath.Join("testdata", "b.go")) + if err != nil { + t.Fatal(err) + } + + jsonExport, _, err := exportdata.FindPkg("encoding/json", "testdata") + if jsonExport == "" { + t.Fatalf("no export data found for encoding/json: %v", err) + } + + compile(t, "testdata", "a.go", testoutdir, map[string]string{"encoding/json": jsonExport}) + compile(t, testoutdir, bpath, testoutdir, map[string]string{"testdata/a": filepath.Join(testoutdir, "a.o")}) + + // import must succeed (test for issue at hand) + pkg := importPkg(t, "./testdata/b", tmpdir) + + // make sure all indirectly imported packages have names + for _, imp := range pkg.Imports() { + if imp.Name() == "" { + t.Errorf("no name for %s package", imp.Path()) + } + } +} + +func TestIssue13898(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + // import go/internal/gcimporter which imports go/types partially + imports := make(map[string]*types2.Package) + _, err := Import(imports, "go/internal/gcimporter", ".", nil) + if err != nil { + t.Fatal(err) + } + + // look for go/types package + var goTypesPkg *types2.Package + for path, pkg := range imports { + if path == "go/types" { + goTypesPkg = pkg + break + } + } + if goTypesPkg == nil { + t.Fatal("go/types not found") + } + + // look for go/types.Object type + obj := lookupObj(t, goTypesPkg.Scope(), "Object") + typ, ok := obj.Type().(*types2.Named) + if !ok { + t.Fatalf("go/types.Object type is %v; wanted named type", typ) + } + + // lookup go/types.Object.Pkg method + m, index, indirect := types2.LookupFieldOrMethod(typ, false, nil, "Pkg") + if m == nil { + t.Fatalf("go/types.Object.Pkg not found (index = %v, indirect = %v)", index, indirect) + } + + // the method must belong to go/types + if m.Pkg().Path() != "go/types" { + t.Fatalf("found %v; want go/types", m.Pkg()) + } +} + +func TestIssue15517(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + tmpdir := mktmpdir(t) + + compile(t, "testdata", "p.go", filepath.Join(tmpdir, "testdata"), nil) + + // Multiple imports of p must succeed without redeclaration errors. + // We use an import path that's not cleaned up so that the eventual + // file path for the package is different from the package path; this + // will expose the error if it is present. + // + // (Issue: Both the textual and the binary importer used the file path + // of the package to be imported as key into the shared packages map. + // However, the binary importer then used the package path to identify + // the imported package to mark it as complete; effectively marking the + // wrong package as complete. By using an "unclean" package path, the + // file and package path are different, exposing the problem if present. + // The same issue occurs with vendoring.) + imports := make(map[string]*types2.Package) + for i := 0; i < 3; i++ { + if _, err := Import(imports, "./././testdata/p", tmpdir, nil); err != nil { + t.Fatal(err) + } + } +} + +func TestIssue15920(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + compileAndImportPkg(t, "issue15920") +} + +func TestIssue20046(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + // "./issue20046".V.M must exist + pkg := compileAndImportPkg(t, "issue20046") + obj := lookupObj(t, pkg.Scope(), "V") + if m, index, indirect := types2.LookupFieldOrMethod(obj.Type(), false, nil, "M"); m == nil { + t.Fatalf("V.M not found (index = %v, indirect = %v)", index, indirect) + } +} +func TestIssue25301(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + compileAndImportPkg(t, "issue25301") +} + +func TestIssue25596(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + compileAndImportPkg(t, "issue25596") +} + +func importPkg(t *testing.T, path, srcDir string) *types2.Package { + pkg, err := Import(make(map[string]*types2.Package), path, srcDir, nil) + if err != nil { + t.Helper() + t.Fatal(err) + } + return pkg +} + +func compileAndImportPkg(t *testing.T, name string) *types2.Package { + t.Helper() + tmpdir := mktmpdir(t) + compile(t, "testdata", name+".go", filepath.Join(tmpdir, "testdata"), nil) + return importPkg(t, "./testdata/"+name, tmpdir) +} + +func lookupObj(t *testing.T, scope *types2.Scope, name string) types2.Object { + if obj := scope.Lookup(name); obj != nil { + return obj + } + t.Helper() + t.Fatalf("%s not found", name) + return nil +} + +// importMap implements the types2.Importer interface. +type importMap map[string]*types2.Package + +func (m importMap) Import(path string) (*types2.Package, error) { return m[path], nil } + +func TestIssue69912(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + tmpdir := t.TempDir() + testoutdir := filepath.Join(tmpdir, "testdata") + if err := os.Mkdir(testoutdir, 0700); err != nil { + t.Fatalf("making output dir: %v", err) + } + + compile(t, "testdata", "issue69912.go", testoutdir, nil) + + issue69912, err := Import(make(map[string]*types2.Package), "./testdata/issue69912", tmpdir, nil) + if err != nil { + t.Fatal(err) + } + + check := func(pkgname, src string, imports importMap) (*types2.Package, error) { + f, err := syntax.Parse(syntax.NewFileBase(pkgname), strings.NewReader(src), nil, nil, 0) + if err != nil { + return nil, err + } + config := &types2.Config{ + Importer: imports, + } + return config.Check(pkgname, []*syntax.File{f}, nil) + } + + // Use the resulting package concurrently, via dot-imports, to exercise the + // race of issue #69912. + const pSrc = `package p + +import . "issue69912" + +type S struct { + f T +} +` + importer := importMap{ + "issue69912": issue69912, + } + var wg sync.WaitGroup + for range 10 { + wg.Add(1) + go func() { + defer wg.Done() + if _, err := check("p", pSrc, importer); err != nil { + t.Errorf("Check failed: %v", err) + } + }() + } + wg.Wait() +} + +func TestIssue63285(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This package only handles gc export data. + if runtime.Compiler != "gc" { + t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) + } + + tmpdir := t.TempDir() + testoutdir := filepath.Join(tmpdir, "testdata") + if err := os.Mkdir(testoutdir, 0700); err != nil { + t.Fatalf("making output dir: %v", err) + } + + compile(t, "testdata", "issue63285.go", testoutdir, nil) + + issue63285, err := Import(make(map[string]*types2.Package), "./testdata/issue63285", tmpdir, nil) + if err != nil { + t.Fatal(err) + } + + check := func(pkgname, src string, imports importMap) (*types2.Package, error) { + f, err := syntax.Parse(syntax.NewFileBase(pkgname), strings.NewReader(src), nil, nil, 0) + if err != nil { + return nil, err + } + config := &types2.Config{ + Importer: imports, + } + return config.Check(pkgname, []*syntax.File{f}, nil) + } + + const pSrc = `package p + +import "issue63285" + +var _ issue63285.A[issue63285.B[any]] +` + + importer := importMap{ + "issue63285": issue63285, + } + if _, err := check("p", pSrc, importer); err != nil { + t.Errorf("Check failed: %v", err) + } +} diff --git a/go/src/cmd/compile/internal/importer/support.go b/go/src/cmd/compile/internal/importer/support.go new file mode 100644 index 0000000000000000000000000000000000000000..6ce721557a052e9241b74d38b8bd3b03f7eea71e --- /dev/null +++ b/go/src/cmd/compile/internal/importer/support.go @@ -0,0 +1,43 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements support functionality for iimport.go. + +package importer + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/types2" + "go/token" + "internal/pkgbits" +) + +func assert(p bool) { + base.Assert(p) +} + +const deltaNewFile = -64 // see cmd/compile/internal/gc/bexport.go + +// Synthesize a token.Pos +type fakeFileSet struct { + fset *token.FileSet + files map[string]*token.File +} + +type anyType struct{} + +func (t anyType) Underlying() types2.Type { return t } +func (t anyType) String() string { return "any" } + +// See cmd/compile/internal/noder.derivedInfo. +type derivedInfo struct { + idx pkgbits.Index + needed bool +} + +// See cmd/compile/internal/noder.typeInfo. +type typeInfo struct { + idx pkgbits.Index + derived bool +} diff --git a/go/src/cmd/compile/internal/importer/ureader.go b/go/src/cmd/compile/internal/importer/ureader.go new file mode 100644 index 0000000000000000000000000000000000000000..f6df56b70e665c4efdf9c942405187c8f396e839 --- /dev/null +++ b/go/src/cmd/compile/internal/importer/ureader.go @@ -0,0 +1,586 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// package importer implements package reading for gc-generated object files. +package importer + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/syntax" + "cmd/compile/internal/types2" + "cmd/internal/src" + "internal/pkgbits" +) + +type pkgReader struct { + pkgbits.PkgDecoder + + ctxt *types2.Context + imports map[string]*types2.Package + enableAlias bool // whether to use aliases + + posBases []*syntax.PosBase + pkgs []*types2.Package + typs []types2.Type +} + +func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input pkgbits.PkgDecoder) *types2.Package { + pr := pkgReader{ + PkgDecoder: input, + + ctxt: ctxt, + imports: imports, + enableAlias: true, + + posBases: make([]*syntax.PosBase, input.NumElems(pkgbits.SectionPosBase)), + pkgs: make([]*types2.Package, input.NumElems(pkgbits.SectionPkg)), + typs: make([]types2.Type, input.NumElems(pkgbits.SectionType)), + } + + r := pr.newReader(pkgbits.SectionMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic) + pkg := r.pkg() + + if r.Version().Has(pkgbits.HasInit) { + r.Bool() + } + + for i, n := 0, r.Len(); i < n; i++ { + // As if r.obj(), but avoiding the Scope.Lookup call, + // to avoid eager loading of imports. + r.Sync(pkgbits.SyncObject) + if r.Version().Has(pkgbits.DerivedFuncInstance) { + assert(!r.Bool()) + } + r.p.objIdx(r.Reloc(pkgbits.SectionObj)) + assert(r.Len() == 0) + } + + r.Sync(pkgbits.SyncEOF) + + pkg.MarkComplete() + return pkg +} + +type reader struct { + pkgbits.Decoder + + p *pkgReader + + dict *readerDict + delayed []func() +} + +type readerDict struct { + bounds []typeInfo + + tparams []*types2.TypeParam + + derived []derivedInfo + derivedTypes []types2.Type +} + +type readerTypeBound struct { + derived bool + boundIdx int +} + +func (pr *pkgReader) newReader(k pkgbits.SectionKind, idx pkgbits.Index, marker pkgbits.SyncMarker) *reader { + return &reader{ + Decoder: pr.NewDecoder(k, idx, marker), + p: pr, + } +} + +func (pr *pkgReader) tempReader(k pkgbits.SectionKind, idx pkgbits.Index, marker pkgbits.SyncMarker) *reader { + return &reader{ + Decoder: pr.TempDecoder(k, idx, marker), + p: pr, + } +} + +func (pr *pkgReader) retireReader(r *reader) { + pr.RetireDecoder(&r.Decoder) +} + +// @@@ Positions + +func (r *reader) pos() syntax.Pos { + r.Sync(pkgbits.SyncPos) + if !r.Bool() { + return syntax.Pos{} + } + + // TODO(mdempsky): Delta encoding. + posBase := r.posBase() + line := r.Uint() + col := r.Uint() + return syntax.MakePos(posBase, line, col) +} + +func (r *reader) posBase() *syntax.PosBase { + return r.p.posBaseIdx(r.Reloc(pkgbits.SectionPosBase)) +} + +func (pr *pkgReader) posBaseIdx(idx pkgbits.Index) *syntax.PosBase { + if b := pr.posBases[idx]; b != nil { + return b + } + var b *syntax.PosBase + { + r := pr.tempReader(pkgbits.SectionPosBase, idx, pkgbits.SyncPosBase) + + filename := r.String() + + if r.Bool() { + b = syntax.NewTrimmedFileBase(filename, true) + } else { + pos := r.pos() + line := r.Uint() + col := r.Uint() + b = syntax.NewLineBase(pos, filename, true, line, col) + } + pr.retireReader(r) + } + + pr.posBases[idx] = b + return b +} + +// @@@ Packages + +func (r *reader) pkg() *types2.Package { + r.Sync(pkgbits.SyncPkg) + return r.p.pkgIdx(r.Reloc(pkgbits.SectionPkg)) +} + +func (pr *pkgReader) pkgIdx(idx pkgbits.Index) *types2.Package { + // TODO(mdempsky): Consider using some non-nil pointer to indicate + // the universe scope, so we don't need to keep re-reading it. + if pkg := pr.pkgs[idx]; pkg != nil { + return pkg + } + + pkg := pr.newReader(pkgbits.SectionPkg, idx, pkgbits.SyncPkgDef).doPkg() + pr.pkgs[idx] = pkg + return pkg +} + +func (r *reader) doPkg() *types2.Package { + path := r.String() + switch path { + case "": + path = r.p.PkgPath() + case "builtin": + return nil // universe + case "unsafe": + return types2.Unsafe + } + + if pkg := r.p.imports[path]; pkg != nil { + return pkg + } + + name := r.String() + pkg := types2.NewPackage(path, name) + r.p.imports[path] = pkg + + // TODO(mdempsky): The list of imported packages is important for + // go/types, but we could probably skip populating it for types2. + imports := make([]*types2.Package, r.Len()) + for i := range imports { + imports[i] = r.pkg() + } + pkg.SetImports(imports) + + return pkg +} + +// @@@ Types + +func (r *reader) typ() types2.Type { + return r.p.typIdx(r.typInfo(), r.dict) +} + +func (r *reader) typInfo() typeInfo { + r.Sync(pkgbits.SyncType) + if r.Bool() { + return typeInfo{idx: pkgbits.Index(r.Len()), derived: true} + } + return typeInfo{idx: r.Reloc(pkgbits.SectionType), derived: false} +} + +func (pr *pkgReader) typIdx(info typeInfo, dict *readerDict) types2.Type { + idx := info.idx + var where *types2.Type + if info.derived { + where = &dict.derivedTypes[idx] + idx = dict.derived[idx].idx + } else { + where = &pr.typs[idx] + } + + if typ := *where; typ != nil { + return typ + } + + var typ types2.Type + { + r := pr.tempReader(pkgbits.SectionType, idx, pkgbits.SyncTypeIdx) + r.dict = dict + + typ = r.doTyp() + assert(typ != nil) + pr.retireReader(r) + } + + // See comment in pkgReader.typIdx explaining how this happens. + if prev := *where; prev != nil { + return prev + } + + *where = typ + return typ +} + +func (r *reader) doTyp() (res types2.Type) { + switch tag := pkgbits.CodeType(r.Code(pkgbits.SyncType)); tag { + default: + base.FatalfAt(src.NoXPos, "unhandled type tag: %v", tag) + panic("unreachable") + + case pkgbits.TypeBasic: + return types2.Typ[r.Len()] + + case pkgbits.TypeNamed: + obj, targs := r.obj() + name := obj.(*types2.TypeName) + if len(targs) != 0 { + t, _ := types2.Instantiate(r.p.ctxt, name.Type(), targs, false) + return t + } + return name.Type() + + case pkgbits.TypeTypeParam: + return r.dict.tparams[r.Len()] + + case pkgbits.TypeArray: + len := int64(r.Uint64()) + return types2.NewArray(r.typ(), len) + case pkgbits.TypeChan: + dir := types2.ChanDir(r.Len()) + return types2.NewChan(dir, r.typ()) + case pkgbits.TypeMap: + return types2.NewMap(r.typ(), r.typ()) + case pkgbits.TypePointer: + return types2.NewPointer(r.typ()) + case pkgbits.TypeSignature: + return r.signature(nil, nil, nil) + case pkgbits.TypeSlice: + return types2.NewSlice(r.typ()) + case pkgbits.TypeStruct: + return r.structType() + case pkgbits.TypeInterface: + return r.interfaceType() + case pkgbits.TypeUnion: + return r.unionType() + } +} + +func (r *reader) structType() *types2.Struct { + fields := make([]*types2.Var, r.Len()) + var tags []string + for i := range fields { + pos := r.pos() + pkg, name := r.selector() + ftyp := r.typ() + tag := r.String() + embedded := r.Bool() + + fields[i] = types2.NewField(pos, pkg, name, ftyp, embedded) + if tag != "" { + for len(tags) < i { + tags = append(tags, "") + } + tags = append(tags, tag) + } + } + return types2.NewStruct(fields, tags) +} + +func (r *reader) unionType() *types2.Union { + terms := make([]*types2.Term, r.Len()) + for i := range terms { + terms[i] = types2.NewTerm(r.Bool(), r.typ()) + } + return types2.NewUnion(terms) +} + +func (r *reader) interfaceType() *types2.Interface { + methods := make([]*types2.Func, r.Len()) + embeddeds := make([]types2.Type, r.Len()) + implicit := len(methods) == 0 && len(embeddeds) == 1 && r.Bool() + + for i := range methods { + pos := r.pos() + pkg, name := r.selector() + mtyp := r.signature(nil, nil, nil) + methods[i] = types2.NewFunc(pos, pkg, name, mtyp) + } + + for i := range embeddeds { + embeddeds[i] = r.typ() + } + + iface := types2.NewInterfaceType(methods, embeddeds) + if implicit { + iface.MarkImplicit() + } + return iface +} + +func (r *reader) signature(recv *types2.Var, rtparams, tparams []*types2.TypeParam) *types2.Signature { + r.Sync(pkgbits.SyncSignature) + + params := r.params() + results := r.params() + variadic := r.Bool() + + return types2.NewSignatureType(recv, rtparams, tparams, params, results, variadic) +} + +func (r *reader) params() *types2.Tuple { + r.Sync(pkgbits.SyncParams) + params := make([]*types2.Var, r.Len()) + for i := range params { + params[i] = r.param() + } + return types2.NewTuple(params...) +} + +func (r *reader) param() *types2.Var { + r.Sync(pkgbits.SyncParam) + + pos := r.pos() + pkg, name := r.localIdent() + typ := r.typ() + + return types2.NewParam(pos, pkg, name, typ) +} + +// @@@ Objects + +func (r *reader) obj() (types2.Object, []types2.Type) { + r.Sync(pkgbits.SyncObject) + + if r.Version().Has(pkgbits.DerivedFuncInstance) { + assert(!r.Bool()) + } + + pkg, name := r.p.objIdx(r.Reloc(pkgbits.SectionObj)) + obj := pkg.Scope().Lookup(name) + + targs := make([]types2.Type, r.Len()) + for i := range targs { + targs[i] = r.typ() + } + + return obj, targs +} + +func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types2.Package, string) { + var objPkg *types2.Package + var objName string + var tag pkgbits.CodeObj + { + rname := pr.tempReader(pkgbits.SectionName, idx, pkgbits.SyncObject1) + + objPkg, objName = rname.qualifiedIdent() + assert(objName != "") + + tag = pkgbits.CodeObj(rname.Code(pkgbits.SyncCodeObj)) + pr.retireReader(rname) + } + + if tag == pkgbits.ObjStub { + base.Assertf(objPkg == nil || objPkg == types2.Unsafe, "unexpected stub package: %v", objPkg) + return objPkg, objName + } + + objPkg.Scope().InsertLazy(objName, func() types2.Object { + dict := pr.objDictIdx(idx) + + r := pr.newReader(pkgbits.SectionObj, idx, pkgbits.SyncObject1) + r.dict = dict + + switch tag { + default: + panic("weird") + + case pkgbits.ObjAlias: + pos := r.pos() + var tparams []*types2.TypeParam + if r.Version().Has(pkgbits.AliasTypeParamNames) { + tparams = r.typeParamNames(false) + } + typ := r.typ() + return newAliasTypeName(pr.enableAlias, pos, objPkg, objName, typ, tparams) + + case pkgbits.ObjConst: + pos := r.pos() + typ := r.typ() + val := r.Value() + return types2.NewConst(pos, objPkg, objName, typ, val) + + case pkgbits.ObjFunc: + pos := r.pos() + tparams := r.typeParamNames(false) + sig := r.signature(nil, nil, tparams) + return types2.NewFunc(pos, objPkg, objName, sig) + + case pkgbits.ObjType: + pos := r.pos() + + return types2.NewTypeNameLazy(pos, objPkg, objName, func(_ *types2.Named) ([]*types2.TypeParam, types2.Type, []*types2.Func, []func()) { + tparams := r.typeParamNames(true) + + // TODO(mdempsky): Rewrite receiver types to underlying is an + // Interface? The go/types importer does this (I think because + // unit tests expected that), but cmd/compile doesn't care + // about it, so maybe we can avoid worrying about that here. + underlying := r.typ().Underlying() + + methods := make([]*types2.Func, r.Len()) + for i := range methods { + methods[i] = r.method(true) + } + + return tparams, underlying, methods, r.delayed + }) + + case pkgbits.ObjVar: + pos := r.pos() + typ := r.typ() + return types2.NewVar(pos, objPkg, objName, typ) + } + }) + + return objPkg, objName +} + +func (pr *pkgReader) objDictIdx(idx pkgbits.Index) *readerDict { + var dict readerDict + { + r := pr.tempReader(pkgbits.SectionObjDict, idx, pkgbits.SyncObject1) + + if implicits := r.Len(); implicits != 0 { + base.Fatalf("unexpected object with %v implicit type parameter(s)", implicits) + } + + dict.bounds = make([]typeInfo, r.Len()) + for i := range dict.bounds { + dict.bounds[i] = r.typInfo() + } + + dict.derived = make([]derivedInfo, r.Len()) + dict.derivedTypes = make([]types2.Type, len(dict.derived)) + for i := range dict.derived { + dict.derived[i] = derivedInfo{idx: r.Reloc(pkgbits.SectionType)} + if r.Version().Has(pkgbits.DerivedInfoNeeded) { + assert(!r.Bool()) + } + } + + pr.retireReader(r) + } + // function references follow, but reader doesn't need those + + return &dict +} + +func (r *reader) typeParamNames(isLazy bool) []*types2.TypeParam { + r.Sync(pkgbits.SyncTypeParamNames) + + // Note: This code assumes it only processes objects without + // implement type parameters. This is currently fine, because + // reader is only used to read in exported declarations, which are + // always package scoped. + + if len(r.dict.bounds) == 0 { + return nil + } + + // Careful: Type parameter lists may have cycles. To allow for this, + // we construct the type parameter list in two passes: first we + // create all the TypeNames and TypeParams, then we construct and + // set the bound type. + + r.dict.tparams = make([]*types2.TypeParam, len(r.dict.bounds)) + for i := range r.dict.bounds { + pos := r.pos() + pkg, name := r.localIdent() + + tname := types2.NewTypeName(pos, pkg, name, nil) + r.dict.tparams[i] = types2.NewTypeParam(tname, nil) + } + + // Type parameters that are read by lazy loaders cannot have their + // constraints set eagerly; do them after loading (go.dev/issue/63285). + if isLazy { + // The reader dictionary will continue mutating before we have time + // to call delayed functions; must make a local copy of both the type + // parameters and their (unexpanded) constraints. + bounds := make([]types2.Type, len(r.dict.bounds)) + for i, bound := range r.dict.bounds { + bounds[i] = r.p.typIdx(bound, r.dict) + } + + tparams := r.dict.tparams + r.delayed = append(r.delayed, func() { + for i, bound := range bounds { + tparams[i].SetConstraint(bound) + } + }) + } else { + for i, bound := range r.dict.bounds { + r.dict.tparams[i].SetConstraint(r.p.typIdx(bound, r.dict)) + } + } + + return r.dict.tparams +} + +func (r *reader) method(isLazy bool) *types2.Func { + r.Sync(pkgbits.SyncMethod) + pos := r.pos() + pkg, name := r.selector() + + rtparams := r.typeParamNames(isLazy) + sig := r.signature(r.param(), rtparams, nil) + + _ = r.pos() // TODO(mdempsky): Remove; this is a hacker for linker.go. + return types2.NewFunc(pos, pkg, name, sig) +} + +func (r *reader) qualifiedIdent() (*types2.Package, string) { return r.ident(pkgbits.SyncSym) } +func (r *reader) localIdent() (*types2.Package, string) { return r.ident(pkgbits.SyncLocalIdent) } +func (r *reader) selector() (*types2.Package, string) { return r.ident(pkgbits.SyncSelector) } + +func (r *reader) ident(marker pkgbits.SyncMarker) (*types2.Package, string) { + r.Sync(marker) + return r.pkg(), r.String() +} + +// newAliasTypeName returns a new TypeName, with a materialized *types2.Alias if supported. +func newAliasTypeName(aliases bool, pos syntax.Pos, pkg *types2.Package, name string, rhs types2.Type, tparams []*types2.TypeParam) *types2.TypeName { + // Copied from x/tools/internal/aliases.NewAlias via + // GOROOT/src/go/internal/gcimporter/ureader.go. + if aliases { + tname := types2.NewTypeName(pos, pkg, name, nil) + a := types2.NewAlias(tname, rhs) // form TypeName -> Alias cycle + a.SetTypeParams(tparams) + return tname + } + assert(len(tparams) == 0) + return types2.NewTypeName(pos, pkg, name, rhs) +} diff --git a/go/src/cmd/compile/internal/inline/inl.go b/go/src/cmd/compile/internal/inline/inl.go new file mode 100644 index 0000000000000000000000000000000000000000..4fa9cf07fb86e452e4860bd467a56a3b8dbcf3fb --- /dev/null +++ b/go/src/cmd/compile/internal/inline/inl.go @@ -0,0 +1,1354 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +// +// The inlining facility makes 2 passes: first CanInline determines which +// functions are suitable for inlining, and for those that are it +// saves a copy of the body. Then InlineCalls walks each function body to +// expand calls to inlinable functions. +// +// The Debug.l flag controls the aggressiveness. Note that main() swaps level 0 and 1, +// making 1 the default and -l disable. Additional levels (beyond -l) may be buggy and +// are not supported. +// 0: disabled +// 1: 80-nodes leaf functions, oneliners, panic, lazy typechecking (default) +// 2: (unassigned) +// 3: (unassigned) +// 4: allow non-leaf functions +// +// At some point this may get another default and become switch-offable with -N. +// +// The -d typcheckinl flag enables early typechecking of all imported bodies, +// which is useful to flush out bugs. +// +// The Debug.m flag enables diagnostic output. a single -m is useful for verifying +// which calls get inlined or not, more is for debugging, and may go away at any point. + +package inline + +import ( + "fmt" + "go/constant" + "internal/buildcfg" + "strconv" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/inline/inlheur" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/pgoir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/pgo" + "cmd/internal/src" +) + +// Inlining budget parameters, gathered in one place +const ( + inlineMaxBudget = 80 + inlineExtraAppendCost = 0 + // default is to inline if there's at most one call. -l=4 overrides this by using 1 instead. + inlineExtraCallCost = 57 // 57 was benchmarked to provided most benefit with no bad surprises; see https://github.com/golang/go/issues/19348#issuecomment-439370742 + inlineParamCallCost = 17 // calling a parameter only costs this much extra (inlining might expose a constant function) + inlineExtraPanicCost = 1 // do not penalize inlining panics. + inlineExtraThrowCost = inlineMaxBudget // with current (2018-05/1.11) code, inlining runtime.throw does not help. + + inlineBigFunctionNodes = 5000 // Functions with this many nodes are considered "big". + inlineBigFunctionMaxCost = 20 // Max cost of inlinee when inlining into a "big" function. + inlineClosureCalledOnceCost = 10 * inlineMaxBudget // if a closure is just called once, inline it. +) + +var ( + // List of all hot callee nodes. + // TODO(prattmic): Make this non-global. + candHotCalleeMap = make(map[*pgoir.IRNode]struct{}) + + // Set of functions that contain hot call sites. + hasHotCall = make(map[*ir.Func]struct{}) + + // List of all hot call sites. CallSiteInfo.Callee is always nil. + // TODO(prattmic): Make this non-global. + candHotEdgeMap = make(map[pgoir.CallSiteInfo]struct{}) + + // Threshold in percentage for hot callsite inlining. + inlineHotCallSiteThresholdPercent float64 + + // Threshold in CDF percentage for hot callsite inlining, + // that is, for a threshold of X the hottest callsites that + // make up the top X% of total edge weight will be + // considered hot for inlining candidates. + inlineCDFHotCallSiteThresholdPercent = float64(99) + + // Budget increased due to hotness. + inlineHotMaxBudget int32 = 2000 +) + +func IsPgoHotFunc(fn *ir.Func, profile *pgoir.Profile) bool { + if profile == nil { + return false + } + if n, ok := profile.WeightedCG.IRNodes[ir.LinkFuncName(fn)]; ok { + _, ok := candHotCalleeMap[n] + return ok + } + return false +} + +func HasPgoHotInline(fn *ir.Func) bool { + _, has := hasHotCall[fn] + return has +} + +// PGOInlinePrologue records the hot callsites from ir-graph. +func PGOInlinePrologue(p *pgoir.Profile) { + if base.Debug.PGOInlineCDFThreshold != "" { + if s, err := strconv.ParseFloat(base.Debug.PGOInlineCDFThreshold, 64); err == nil && s >= 0 && s <= 100 { + inlineCDFHotCallSiteThresholdPercent = s + } else { + base.Fatalf("invalid PGOInlineCDFThreshold, must be between 0 and 100") + } + } + var hotCallsites []pgo.NamedCallEdge + inlineHotCallSiteThresholdPercent, hotCallsites = hotNodesFromCDF(p) + if base.Debug.PGODebug > 0 { + fmt.Printf("hot-callsite-thres-from-CDF=%v\n", inlineHotCallSiteThresholdPercent) + } + + if x := base.Debug.PGOInlineBudget; x != 0 { + inlineHotMaxBudget = int32(x) + } + + for _, n := range hotCallsites { + // mark inlineable callees from hot edges + if callee := p.WeightedCG.IRNodes[n.CalleeName]; callee != nil { + candHotCalleeMap[callee] = struct{}{} + } + // mark hot call sites + if caller := p.WeightedCG.IRNodes[n.CallerName]; caller != nil && caller.AST != nil { + csi := pgoir.CallSiteInfo{LineOffset: n.CallSiteOffset, Caller: caller.AST} + candHotEdgeMap[csi] = struct{}{} + } + } + + if base.Debug.PGODebug >= 3 { + fmt.Printf("hot-cg before inline in dot format:") + p.PrintWeightedCallGraphDOT(inlineHotCallSiteThresholdPercent) + } +} + +// hotNodesFromCDF computes an edge weight threshold and the list of hot +// nodes that make up the given percentage of the CDF. The threshold, as +// a percent, is the lower bound of weight for nodes to be considered hot +// (currently only used in debug prints) (in case of equal weights, +// comparing with the threshold may not accurately reflect which nodes are +// considered hot). +func hotNodesFromCDF(p *pgoir.Profile) (float64, []pgo.NamedCallEdge) { + cum := int64(0) + for i, n := range p.NamedEdgeMap.ByWeight { + w := p.NamedEdgeMap.Weight[n] + cum += w + if pgo.WeightInPercentage(cum, p.TotalWeight) > inlineCDFHotCallSiteThresholdPercent { + // nodes[:i+1] to include the very last node that makes it to go over the threshold. + // (Say, if the CDF threshold is 50% and one hot node takes 60% of weight, we want to + // include that node instead of excluding it.) + return pgo.WeightInPercentage(w, p.TotalWeight), p.NamedEdgeMap.ByWeight[:i+1] + } + } + return 0, p.NamedEdgeMap.ByWeight +} + +// CanInlineFuncs computes whether a batch of functions are inlinable. +func CanInlineFuncs(funcs []*ir.Func, profile *pgoir.Profile) { + if profile != nil { + PGOInlinePrologue(profile) + } + + if base.Flag.LowerL == 0 { + return + } + + ir.VisitFuncsBottomUp(funcs, func(funcs []*ir.Func, recursive bool) { + for _, fn := range funcs { + CanInline(fn, profile) + if inlheur.Enabled() { + analyzeFuncProps(fn, profile) + } + } + }) +} + +func simdCreditMultiplier(fn *ir.Func) int32 { + for _, field := range fn.Type().RecvParamsResults() { + if field.Type.IsSIMD() { + return 3 + } + } + // Sometimes code uses closures, that do not take simd + // parameters, to perform repetitive SIMD operations. + // fn. These really need to be inlined, or the anticipated + // awesome SIMD performance will be missed. + for _, v := range fn.ClosureVars { + if v.Type().IsSIMD() { + return 11 // 11 ought to be enough. + } + } + + return 1 +} + +// inlineBudget determines the max budget for function 'fn' prior to +// analyzing the hairiness of the body of 'fn'. We pass in the pgo +// profile if available (which can change the budget), also a +// 'relaxed' flag, which expands the budget slightly to allow for the +// possibility that a call to the function might have its score +// adjusted downwards. If 'verbose' is set, then print a remark where +// we boost the budget due to PGO. +// Note that inlineCostOk has the final say on whether an inline will +// happen; changes here merely make inlines possible. +func inlineBudget(fn *ir.Func, profile *pgoir.Profile, relaxed bool, verbose bool) int32 { + // Update the budget for profile-guided inlining. + budget := int32(inlineMaxBudget) + + budget *= simdCreditMultiplier(fn) + + if IsPgoHotFunc(fn, profile) { + budget = inlineHotMaxBudget + if verbose { + fmt.Printf("hot-node enabled increased budget=%v for func=%v\n", budget, ir.PkgFuncName(fn)) + } + } + if relaxed { + budget += inlheur.BudgetExpansion(inlineMaxBudget) + } + if fn.ClosureParent != nil { + // be very liberal here, if the closure is only called once, the budget is large + budget = max(budget, inlineClosureCalledOnceCost) + } + + return budget +} + +// CanInline determines whether fn is inlineable. +// If so, CanInline saves copies of fn.Body and fn.Dcl in fn.Inl. +// fn and fn.Body will already have been typechecked. +func CanInline(fn *ir.Func, profile *pgoir.Profile) { + if fn.Nname == nil { + base.Fatalf("CanInline no nname %+v", fn) + } + + var reason string // reason, if any, that the function was not inlined + if base.Flag.LowerM > 1 || logopt.Enabled() { + defer func() { + if reason != "" { + if base.Flag.LowerM > 1 { + fmt.Printf("%v: cannot inline %v: %s\n", ir.Line(fn), fn.Nname, reason) + } + if logopt.Enabled() { + logopt.LogOpt(fn.Pos(), "cannotInlineFunction", "inline", ir.FuncName(fn), reason) + } + } + }() + } + + reason = InlineImpossible(fn) + if reason != "" { + return + } + if fn.Typecheck() == 0 { + base.Fatalf("CanInline on non-typechecked function %v", fn) + } + + n := fn.Nname + if n.Func.InlinabilityChecked() { + return + } + defer n.Func.SetInlinabilityChecked(true) + + cc := int32(inlineExtraCallCost) + if base.Flag.LowerL == 4 { + cc = 1 // this appears to yield better performance than 0. + } + + // Used a "relaxed" inline budget if the new inliner is enabled. + relaxed := inlheur.Enabled() + + // Compute the inline budget for this func. + budget := inlineBudget(fn, profile, relaxed, base.Debug.PGODebug > 0) + + // At this point in the game the function we're looking at may + // have "stale" autos, vars that still appear in the Dcl list, but + // which no longer have any uses in the function body (due to + // elimination by deadcode). We'd like to exclude these dead vars + // when creating the "Inline.Dcl" field below; to accomplish this, + // the hairyVisitor below builds up a map of used/referenced + // locals, and we use this map to produce a pruned Inline.Dcl + // list. See issue 25459 for more context. + + visitor := hairyVisitor{ + curFunc: fn, + debug: isDebugFn(fn), + isBigFunc: IsBigFunc(fn), + budget: budget, + maxBudget: budget, + extraCallCost: cc, + profile: profile, + } + if visitor.tooHairy(fn) { + reason = visitor.reason + return + } + + n.Func.Inl = &ir.Inline{ + Cost: budget - visitor.budget, + Dcl: pruneUnusedAutos(n.Func.Dcl, &visitor), + HaveDcl: true, + CanDelayResults: canDelayResults(fn), + } + if base.Flag.LowerM != 0 || logopt.Enabled() { + noteInlinableFunc(n, fn, budget-visitor.budget) + } +} + +// noteInlinableFunc issues a message to the user that the specified +// function is inlinable. +func noteInlinableFunc(n *ir.Name, fn *ir.Func, cost int32) { + if base.Flag.LowerM > 1 { + fmt.Printf("%v: can inline %v with cost %d as: %v { %v }\n", ir.Line(fn), n, cost, fn.Type(), fn.Body) + } else if base.Flag.LowerM != 0 { + fmt.Printf("%v: can inline %v\n", ir.Line(fn), n) + } + // JSON optimization log output. + if logopt.Enabled() { + logopt.LogOpt(fn.Pos(), "canInlineFunction", "inline", ir.FuncName(fn), fmt.Sprintf("cost: %d", cost)) + } +} + +// InlineImpossible returns a non-empty reason string if fn is impossible to +// inline regardless of cost or contents. +func InlineImpossible(fn *ir.Func) string { + var reason string // reason, if any, that the function can not be inlined. + if fn.Nname == nil { + reason = "no name" + return reason + } + + // If marked "go:noinline", don't inline. + if fn.Pragma&ir.Noinline != 0 { + reason = "marked go:noinline" + return reason + } + + // If marked "go:norace" and -race compilation, don't inline. + if base.Flag.Race && fn.Pragma&ir.Norace != 0 { + reason = "marked go:norace with -race compilation" + return reason + } + + // If marked "go:nocheckptr" and -d checkptr compilation, don't inline. + if base.Debug.Checkptr != 0 && fn.Pragma&ir.NoCheckPtr != 0 { + reason = "marked go:nocheckptr" + return reason + } + + // If marked "go:cgo_unsafe_args", don't inline, since the function + // makes assumptions about its argument frame layout. + if fn.Pragma&ir.CgoUnsafeArgs != 0 { + reason = "marked go:cgo_unsafe_args" + return reason + } + + // If marked as "go:uintptrkeepalive", don't inline, since the keep + // alive information is lost during inlining. + // + // TODO(prattmic): This is handled on calls during escape analysis, + // which is after inlining. Move prior to inlining so the keep-alive is + // maintained after inlining. + if fn.Pragma&ir.UintptrKeepAlive != 0 { + reason = "marked as having a keep-alive uintptr argument" + return reason + } + + // If marked as "go:uintptrescapes", don't inline, since the escape + // information is lost during inlining. + if fn.Pragma&ir.UintptrEscapes != 0 { + reason = "marked as having an escaping uintptr argument" + return reason + } + + // The nowritebarrierrec checker currently works at function + // granularity, so inlining yeswritebarrierrec functions can confuse it + // (#22342). As a workaround, disallow inlining them for now. + if fn.Pragma&ir.Yeswritebarrierrec != 0 { + reason = "marked go:yeswritebarrierrec" + return reason + } + + // If a local function has no fn.Body (is defined outside of Go), cannot inline it. + // Imported functions don't have fn.Body but might have inline body in fn.Inl. + if len(fn.Body) == 0 && !typecheck.HaveInlineBody(fn) { + reason = "no function body" + return reason + } + + return "" +} + +// canDelayResults reports whether inlined calls to fn can delay +// declaring the result parameter until the "return" statement. +func canDelayResults(fn *ir.Func) bool { + // We can delay declaring+initializing result parameters if: + // (1) there's exactly one "return" statement in the inlined function; + // (2) it's not an empty return statement (#44355); and + // (3) the result parameters aren't named. + + nreturns := 0 + ir.VisitList(fn.Body, func(n ir.Node) { + if n, ok := n.(*ir.ReturnStmt); ok { + nreturns++ + if len(n.Results) == 0 { + nreturns++ // empty return statement (case 2) + } + } + }) + + if nreturns != 1 { + return false // not exactly one return statement (case 1) + } + + // temporaries for return values. + for _, param := range fn.Type().Results() { + if sym := param.Sym; sym != nil && !sym.IsBlank() { + return false // found a named result parameter (case 3) + } + } + + return true +} + +// hairyVisitor visits a function body to determine its inlining +// hairiness and whether or not it can be inlined. +type hairyVisitor struct { + // This is needed to access the current caller in the doNode function. + curFunc *ir.Func + isBigFunc bool + debug bool + budget int32 + maxBudget int32 + reason string + extraCallCost int32 + usedLocals ir.NameSet + do func(ir.Node) bool + profile *pgoir.Profile +} + +func isDebugFn(fn *ir.Func) bool { + // if n := fn.Nname; n != nil { + // if n.Sym().Name == "Int32x8.Transpose8" && n.Sym().Pkg.Path == "simd/archsimd" { + // fmt.Printf("isDebugFn '%s' DOT '%s'\n", n.Sym().Pkg.Path, n.Sym().Name) + // return true + // } + // } + return false +} + +func (v *hairyVisitor) tooHairy(fn *ir.Func) bool { + v.do = v.doNode // cache closure + if ir.DoChildren(fn, v.do) { + return true + } + if v.budget < 0 { + v.reason = fmt.Sprintf("function too complex: cost %d exceeds budget %d", v.maxBudget-v.budget, v.maxBudget) + return true + } + return false +} + +// doNode visits n and its children, updates the state in v, and returns true if +// n makes the current function too hairy for inlining. +func (v *hairyVisitor) doNode(n ir.Node) bool { + if n == nil { + return false + } + if v.debug { + fmt.Printf("%v: doNode %v budget is %d\n", ir.Line(n), n.Op(), v.budget) + } +opSwitch: + switch n.Op() { + // Call is okay if inlinable and we have the budget for the body. + case ir.OCALLFUNC: + n := n.(*ir.CallExpr) + var cheap bool + if n.Fun.Op() == ir.ONAME { + name := n.Fun.(*ir.Name) + if name.Class == ir.PFUNC { + s := name.Sym() + fn := s.Name + switch s.Pkg.Path { + case "internal/abi": + switch fn { + case "NoEscape": + // Special case for internal/abi.NoEscape. It does just type + // conversions to appease the escape analysis, and doesn't + // generate code. + cheap = true + } + if strings.HasPrefix(fn, "EscapeNonString[") { + // internal/abi.EscapeNonString[T] is a compiler intrinsic + // implemented in the escape analysis phase. + cheap = true + } + case "internal/runtime/sys": + switch fn { + case "GetCallerPC", "GetCallerSP": + // Functions that call GetCallerPC/SP can not be inlined + // because users expect the PC/SP of the logical caller, + // but GetCallerPC/SP returns the physical caller. + v.reason = "call to " + fn + return true + } + case "go.runtime": + switch fn { + case "throw": + // runtime.throw is a "cheap call" like panic in normal code. + v.budget -= inlineExtraThrowCost + break opSwitch + case "panicrangestate": + cheap = true + case "deferrangefunc": + v.reason = "defer call in range func" + return true + } + } + } + // Special case for coverage counter updates; although + // these correspond to real operations, we treat them as + // zero cost for the moment. This is due to the existence + // of tests that are sensitive to inlining-- if the + // insertion of coverage instrumentation happens to tip a + // given function over the threshold and move it from + // "inlinable" to "not-inlinable", this can cause changes + // in allocation behavior, which can then result in test + // failures (a good example is the TestAllocations in + // crypto/ed25519). + if isAtomicCoverageCounterUpdate(n) { + return false + } + } + if n.Fun.Op() == ir.OMETHEXPR { + if meth := ir.MethodExprName(n.Fun); meth != nil { + if fn := meth.Func; fn != nil { + s := fn.Sym() + if types.RuntimeSymName(s) == "heapBits.nextArena" { + // Special case: explicitly allow mid-stack inlining of + // runtime.heapBits.next even though it calls slow-path + // runtime.heapBits.nextArena. + cheap = true + } + // Special case: on architectures that can do unaligned loads, + // explicitly mark encoding/binary methods as cheap, + // because in practice they are, even though our inlining + // budgeting system does not see that. See issue 42958. + if base.Ctxt.Arch.CanMergeLoads && s.Pkg.Path == "encoding/binary" { + switch s.Name { + case "littleEndian.Uint64", "littleEndian.Uint32", "littleEndian.Uint16", + "bigEndian.Uint64", "bigEndian.Uint32", "bigEndian.Uint16", + "littleEndian.PutUint64", "littleEndian.PutUint32", "littleEndian.PutUint16", + "bigEndian.PutUint64", "bigEndian.PutUint32", "bigEndian.PutUint16", + "littleEndian.AppendUint64", "littleEndian.AppendUint32", "littleEndian.AppendUint16", + "bigEndian.AppendUint64", "bigEndian.AppendUint32", "bigEndian.AppendUint16": + cheap = true + } + } + } + } + } + + // A call to a parameter is optimistically a cheap call, if it's a constant function + // perhaps it will inline, it also can simplify escape analysis. + extraCost := v.extraCallCost + + if n.Fun.Op() == ir.ONAME { + name := n.Fun.(*ir.Name) + if name.Class == ir.PFUNC { + // Special case: on architectures that can do unaligned loads, + // explicitly mark internal/byteorder methods as cheap, + // because in practice they are, even though our inlining + // budgeting system does not see that. See issue 42958. + if base.Ctxt.Arch.CanMergeLoads && name.Sym().Pkg.Path == "internal/byteorder" { + switch name.Sym().Name { + case "LEUint64", "LEUint32", "LEUint16", + "BEUint64", "BEUint32", "BEUint16", + "LEPutUint64", "LEPutUint32", "LEPutUint16", + "BEPutUint64", "BEPutUint32", "BEPutUint16", + "LEAppendUint64", "LEAppendUint32", "LEAppendUint16", + "BEAppendUint64", "BEAppendUint32", "BEAppendUint16": + cheap = true + } + } + } + if name.Class == ir.PPARAM || name.Class == ir.PAUTOHEAP && name.IsClosureVar() { + extraCost = min(extraCost, inlineParamCallCost) + } + } + + if cheap { + if v.debug { + if ir.IsIntrinsicCall(n) { + fmt.Printf("%v: cheap call is also intrinsic, %v\n", ir.Line(n), n) + } + } + break // treat like any other node, that is, cost of 1 + } + + if ir.IsIntrinsicCall(n) { + if v.debug { + fmt.Printf("%v: intrinsic call, %v\n", ir.Line(n), n) + } + break // Treat like any other node. + } + + if callee := inlCallee(v.curFunc, n.Fun, v.profile, false); callee != nil && typecheck.HaveInlineBody(callee) { + // Check whether we'd actually inline this call. Set + // log == false since we aren't actually doing inlining + // yet. + if ok, _, _ := canInlineCallExpr(v.curFunc, n, callee, v.isBigFunc, false, false); ok { + // mkinlcall would inline this call [1], so use + // the cost of the inline body as the cost of + // the call, as that is what will actually + // appear in the code. + // + // [1] This is almost a perfect match to the + // mkinlcall logic, except that + // canInlineCallExpr considers inlining cycles + // by looking at what has already been inlined. + // Since we haven't done any inlining yet we + // will miss those. + // + // TODO: in the case of a single-call closure, the inlining budget here is potentially much, much larger. + // + v.budget -= callee.Inl.Cost + break + } + } + + if v.debug { + fmt.Printf("%v: costly OCALLFUNC %v\n", ir.Line(n), n) + } + + // Call cost for non-leaf inlining. + v.budget -= extraCost + + case ir.OCALLMETH: + base.FatalfAt(n.Pos(), "OCALLMETH missed by typecheck") + + // Things that are too hairy, irrespective of the budget + case ir.OCALL, ir.OCALLINTER: + // Call cost for non-leaf inlining. + if v.debug { + fmt.Printf("%v: costly OCALL %v\n", ir.Line(n), n) + } + v.budget -= v.extraCallCost + + case ir.OPANIC: + n := n.(*ir.UnaryExpr) + if n.X.Op() == ir.OCONVIFACE && n.X.(*ir.ConvExpr).Implicit() { + // Hack to keep reflect.flag.mustBe inlinable for TestIntendedInlining. + // Before CL 284412, these conversions were introduced later in the + // compiler, so they didn't count against inlining budget. + v.budget++ + } + v.budget -= inlineExtraPanicCost + + case ir.ORECOVER: + // TODO: maybe we could allow inlining of recover() now? + v.reason = "call to recover" + return true + + case ir.OCLOSURE: + if base.Debug.InlFuncsWithClosures == 0 { + v.reason = "not inlining functions with closures" + return true + } + + // TODO(danscales): Maybe make budget proportional to number of closure + // variables, e.g.: + //v.budget -= int32(len(n.(*ir.ClosureExpr).Func.ClosureVars) * 3) + // TODO(austin): However, if we're able to inline this closure into + // v.curFunc, then we actually pay nothing for the closure captures. We + // should try to account for that if we're going to account for captures. + v.budget -= 15 + + case ir.OGO, ir.ODEFER, ir.OTAILCALL: + v.reason = "unhandled op " + n.Op().String() + return true + + case ir.OAPPEND: + v.budget -= inlineExtraAppendCost + + case ir.OADDR: + n := n.(*ir.AddrExpr) + // Make "&s.f" cost 0 when f's offset is zero. + if dot, ok := n.X.(*ir.SelectorExpr); ok && (dot.Op() == ir.ODOT || dot.Op() == ir.ODOTPTR) { + if _, ok := dot.X.(*ir.Name); ok && dot.Selection.Offset == 0 { + v.budget += 2 // undo ir.OADDR+ir.ODOT/ir.ODOTPTR + } + } + + case ir.ODEREF: + // *(*X)(unsafe.Pointer(&x)) is low-cost + n := n.(*ir.StarExpr) + + ptr := n.X + for ptr.Op() == ir.OCONVNOP { + ptr = ptr.(*ir.ConvExpr).X + } + if ptr.Op() == ir.OADDR { + v.budget += 1 // undo half of default cost of ir.ODEREF+ir.OADDR + } + + case ir.OCONVNOP: + // This doesn't produce code, but the children might. + v.budget++ // undo default cost + + case ir.OFALL, ir.OTYPE: + // These nodes don't produce code; omit from inlining budget. + return false + + case ir.OIF: + n := n.(*ir.IfStmt) + if ir.IsConst(n.Cond, constant.Bool) { + // This if and the condition cost nothing. + if doList(n.Init(), v.do) { + return true + } + if ir.BoolVal(n.Cond) { + return doList(n.Body, v.do) + } else { + return doList(n.Else, v.do) + } + } + + case ir.ONAME: + n := n.(*ir.Name) + if n.Class == ir.PAUTO { + v.usedLocals.Add(n) + } + + case ir.OBLOCK: + // The only OBLOCK we should see at this point is an empty one. + // In any event, let the visitList(n.List()) below take care of the statements, + // and don't charge for the OBLOCK itself. The ++ undoes the -- below. + v.budget++ + + case ir.OMETHVALUE, ir.OSLICELIT: + v.budget-- // Hack for toolstash -cmp. + + case ir.OMETHEXPR: + v.budget++ // Hack for toolstash -cmp. + + case ir.OAS2: + n := n.(*ir.AssignListStmt) + + // Unified IR unconditionally rewrites: + // + // a, b = f() + // + // into: + // + // DCL tmp1 + // DCL tmp2 + // tmp1, tmp2 = f() + // a, b = tmp1, tmp2 + // + // so that it can insert implicit conversions as necessary. To + // minimize impact to the existing inlining heuristics (in + // particular, to avoid breaking the existing inlinability regress + // tests), we need to compensate for this here. + // + // See also identical logic in IsBigFunc. + if len(n.Rhs) > 0 { + if init := n.Rhs[0].Init(); len(init) == 1 { + if _, ok := init[0].(*ir.AssignListStmt); ok { + // 4 for each value, because each temporary variable now + // appears 3 times (DCL, LHS, RHS), plus an extra DCL node. + // + // 1 for the extra "tmp1, tmp2 = f()" assignment statement. + v.budget += 4*int32(len(n.Lhs)) + 1 + } + } + } + + case ir.OAS: + // Special case for coverage counter updates and coverage + // function registrations. Although these correspond to real + // operations, we treat them as zero cost for the moment. This + // is primarily due to the existence of tests that are + // sensitive to inlining-- if the insertion of coverage + // instrumentation happens to tip a given function over the + // threshold and move it from "inlinable" to "not-inlinable", + // this can cause changes in allocation behavior, which can + // then result in test failures (a good example is the + // TestAllocations in crypto/ed25519). + n := n.(*ir.AssignStmt) + if n.X.Op() == ir.OINDEX && isIndexingCoverageCounter(n.X) { + return false + } + + case ir.OSLICE, ir.OSLICEARR, ir.OSLICESTR, ir.OSLICE3, ir.OSLICE3ARR: + n := n.(*ir.SliceExpr) + + // Ignore superfluous slicing. + if n.Low != nil && n.Low.Op() == ir.OLITERAL && ir.Int64Val(n.Low) == 0 { + v.budget++ + } + if n.High != nil && n.High.Op() == ir.OLEN && n.High.(*ir.UnaryExpr).X == n.X { + v.budget += 2 + } + } + + v.budget-- + + // When debugging, don't stop early, to get full cost of inlining this function + if v.budget < 0 && base.Flag.LowerM < 2 && !logopt.Enabled() && !v.debug { + v.reason = "too expensive" + return true + } + + return ir.DoChildren(n, v.do) +} + +// IsBigFunc reports whether fn is a "big" function. +// +// Note: The criteria for "big" is heuristic and subject to change. +func IsBigFunc(fn *ir.Func) bool { + budget := inlineBigFunctionNodes + return ir.Any(fn, func(n ir.Node) bool { + // See logic in hairyVisitor.doNode, explaining unified IR's + // handling of "a, b = f()" assignments. + if n, ok := n.(*ir.AssignListStmt); ok && n.Op() == ir.OAS2 && len(n.Rhs) > 0 { + if init := n.Rhs[0].Init(); len(init) == 1 { + if _, ok := init[0].(*ir.AssignListStmt); ok { + budget += 4*len(n.Lhs) + 1 + } + } + } + + budget-- + return budget <= 0 + }) +} + +// inlineCallCheck returns whether a call will never be inlineable +// for basic reasons, and whether the call is an intrinisic call. +// The intrinsic result singles out intrinsic calls for debug logging. +func inlineCallCheck(callerfn *ir.Func, call *ir.CallExpr) (bool, bool) { + if base.Flag.LowerL == 0 { + return false, false + } + if call.Op() != ir.OCALLFUNC { + return false, false + } + if call.GoDefer || call.NoInline { + return false, false + } + + // Prevent inlining some reflect.Value methods when using checkptr, + // even when package reflect was compiled without it (#35073). + if base.Debug.Checkptr != 0 && call.Fun.Op() == ir.OMETHEXPR { + if method := ir.MethodExprName(call.Fun); method != nil { + switch types.ReflectSymName(method.Sym()) { + case "Value.UnsafeAddr", "Value.Pointer": + return false, false + } + } + } + + // internal/abi.EscapeNonString[T] is a compiler intrinsic implemented + // in the escape analysis phase. + if fn := ir.StaticCalleeName(call.Fun); fn != nil && fn.Sym().Pkg.Path == "internal/abi" && + strings.HasPrefix(fn.Sym().Name, "EscapeNonString[") { + return false, true + } + + if ir.IsIntrinsicCall(call) { + return false, true + } + return true, false +} + +// InlineCallTarget returns the resolved-for-inlining target of a call. +// It does not necessarily guarantee that the target can be inlined, though +// obvious exclusions are applied. +func InlineCallTarget(callerfn *ir.Func, call *ir.CallExpr, profile *pgoir.Profile) *ir.Func { + if mightInline, _ := inlineCallCheck(callerfn, call); !mightInline { + return nil + } + return inlCallee(callerfn, call.Fun, profile, true) +} + +// TryInlineCall returns an inlined call expression for call, or nil +// if inlining is not possible. +func TryInlineCall(callerfn *ir.Func, call *ir.CallExpr, bigCaller bool, profile *pgoir.Profile, closureCalledOnce bool) *ir.InlinedCallExpr { + mightInline, isIntrinsic := inlineCallCheck(callerfn, call) + + // Preserve old logging behavior + if (mightInline || isIntrinsic) && base.Flag.LowerM > 3 { + fmt.Printf("%v:call to func %+v\n", ir.Line(call), call.Fun) + } + if !mightInline { + return nil + } + + if fn := inlCallee(callerfn, call.Fun, profile, false); fn != nil && typecheck.HaveInlineBody(fn) { + return mkinlcall(callerfn, call, fn, bigCaller, closureCalledOnce) + } + return nil +} + +// inlCallee takes a function-typed expression and returns the underlying function ONAME +// that it refers to if statically known. Otherwise, it returns nil. +// resolveOnly skips cost-based inlineability checks for closures; the result may not actually be inlineable. +func inlCallee(caller *ir.Func, fn ir.Node, profile *pgoir.Profile, resolveOnly bool) (res *ir.Func) { + fn = ir.StaticValue(fn) + switch fn.Op() { + case ir.OMETHEXPR: + fn := fn.(*ir.SelectorExpr) + n := ir.MethodExprName(fn) + // Check that receiver type matches fn.X. + // TODO(mdempsky): Handle implicit dereference + // of pointer receiver argument? + if n == nil || !types.Identical(n.Type().Recv().Type, fn.X.Type()) { + return nil + } + return n.Func + case ir.ONAME: + fn := fn.(*ir.Name) + if fn.Class == ir.PFUNC { + return fn.Func + } + case ir.OCLOSURE: + fn := fn.(*ir.ClosureExpr) + c := fn.Func + if len(c.ClosureVars) != 0 && c.ClosureVars[0].Outer.Curfn != caller { + return nil // inliner doesn't support inlining across closure frames + } + if !resolveOnly { + CanInline(c, profile) + } + return c + } + return nil +} + +var inlgen int + +// SSADumpInline gives the SSA back end a chance to dump the function +// when producing output for debugging the compiler itself. +var SSADumpInline = func(*ir.Func) {} + +// InlineCall allows the inliner implementation to be overridden. +// If it returns nil, the function will not be inlined. +var InlineCall = func(callerfn *ir.Func, call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExpr { + base.Fatalf("inline.InlineCall not overridden") + panic("unreachable") +} + +// inlineCostOK returns true if call n from caller to callee is cheap enough to +// inline. bigCaller indicates that caller is a big function. +// +// In addition to the "cost OK" boolean, it also returns +// - the "max cost" limit used to make the decision (which may differ depending on func size) +// - the score assigned to this specific callsite +// - whether the inlined function is "hot" according to PGO. +func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller, closureCalledOnce bool) (bool, int32, int32, bool) { + maxCost := int32(inlineMaxBudget) + + if bigCaller { + // We use this to restrict inlining into very big functions. + // See issue 26546 and 17566. + maxCost = inlineBigFunctionMaxCost + } + + simdMaxCost := simdCreditMultiplier(callee) * maxCost + + if callee.ClosureParent != nil { + maxCost *= 2 // favor inlining closures + if closureCalledOnce { // really favor inlining the one call to this closure + maxCost = max(maxCost, inlineClosureCalledOnceCost) + } + } + + maxCost = max(maxCost, simdMaxCost) + + metric := callee.Inl.Cost + if inlheur.Enabled() { + score, ok := inlheur.GetCallSiteScore(caller, n) + if ok { + metric = int32(score) + } + } + + lineOffset := pgoir.NodeLineOffset(n, caller) + csi := pgoir.CallSiteInfo{LineOffset: lineOffset, Caller: caller} + _, hot := candHotEdgeMap[csi] + + if metric <= maxCost { + // Simple case. Function is already cheap enough. + return true, 0, metric, hot + } + + // We'll also allow inlining of hot functions below inlineHotMaxBudget, + // but only in small functions. + + if !hot { + // Cold + return false, maxCost, metric, false + } + + // Hot + + if bigCaller { + if base.Debug.PGODebug > 0 { + fmt.Printf("hot-big check disallows inlining for call %s (cost %d) at %v in big function %s\n", ir.PkgFuncName(callee), callee.Inl.Cost, ir.Line(n), ir.PkgFuncName(caller)) + } + return false, maxCost, metric, false + } + + if metric > inlineHotMaxBudget { + return false, inlineHotMaxBudget, metric, false + } + + if !base.PGOHash.MatchPosWithInfo(n.Pos(), "inline", nil) { + // De-selected by PGO Hash. + return false, maxCost, metric, false + } + + if base.Debug.PGODebug > 0 { + fmt.Printf("hot-budget check allows inlining for call %s (cost %d) at %v in function %s\n", ir.PkgFuncName(callee), callee.Inl.Cost, ir.Line(n), ir.PkgFuncName(caller)) + } + + return true, 0, metric, hot +} + +// parsePos returns all the inlining positions and the innermost position. +func parsePos(pos src.XPos, posTmp []src.Pos) ([]src.Pos, src.Pos) { + ctxt := base.Ctxt + ctxt.AllPos(pos, func(p src.Pos) { + posTmp = append(posTmp, p) + }) + l := len(posTmp) - 1 + return posTmp[:l], posTmp[l] +} + +// canInlineCallExpr returns true if the call n from caller to callee +// can be inlined, plus the score computed for the call expr in question, +// and whether the callee is hot according to PGO. +// bigCaller indicates that caller is a big function. log +// indicates that the 'cannot inline' reason should be logged. +// +// Preconditions: CanInline(callee) has already been called. +func canInlineCallExpr(callerfn *ir.Func, n *ir.CallExpr, callee *ir.Func, bigCaller, closureCalledOnce bool, log bool) (bool, int32, bool) { + if callee.Inl == nil { + // callee is never inlinable. + if log && logopt.Enabled() { + logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", ir.FuncName(callerfn), + fmt.Sprintf("%s cannot be inlined", ir.PkgFuncName(callee))) + } + return false, 0, false + } + + ok, maxCost, callSiteScore, hot := inlineCostOK(n, callerfn, callee, bigCaller, closureCalledOnce) + if !ok { + // callee cost too high for this call site. + if log && logopt.Enabled() { + logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", ir.FuncName(callerfn), + fmt.Sprintf("cost %d of %s exceeds max caller cost %d", callee.Inl.Cost, ir.PkgFuncName(callee), maxCost)) + } + return false, 0, false + } + + callees, calleeInner := parsePos(n.Pos(), make([]src.Pos, 0, 10)) + + for _, p := range callees { + if p.Line() == calleeInner.Line() && p.Col() == calleeInner.Col() && p.AbsFilename() == calleeInner.AbsFilename() { + if log && logopt.Enabled() { + logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", fmt.Sprintf("recursive call to %s", ir.FuncName(callerfn))) + } + return false, 0, false + } + } + + if base.Flag.Cfg.Instrumenting && types.IsNoInstrumentPkg(callee.Sym().Pkg) { + // Runtime package must not be instrumented. + // Instrument skips runtime package. However, some runtime code can be + // inlined into other packages and instrumented there. To avoid this, + // we disable inlining of runtime functions when instrumenting. + // The example that we observed is inlining of LockOSThread, + // which lead to false race reports on m contents. + if log && logopt.Enabled() { + logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", ir.FuncName(callerfn), + fmt.Sprintf("call to runtime function %s in instrumented build", ir.PkgFuncName(callee))) + } + return false, 0, false + } + + if base.Flag.Race && types.IsNoRacePkg(callee.Sym().Pkg) { + if log && logopt.Enabled() { + logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", ir.FuncName(callerfn), + fmt.Sprintf(`call to into "no-race" package function %s in race build`, ir.PkgFuncName(callee))) + } + return false, 0, false + } + + if base.Debug.Checkptr != 0 && types.IsRuntimePkg(callee.Sym().Pkg) { + // We don't instrument runtime packages for checkptr (see base/flag.go). + if log && logopt.Enabled() { + logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", ir.FuncName(callerfn), + fmt.Sprintf(`call to into runtime package function %s in -d=checkptr build`, ir.PkgFuncName(callee))) + } + return false, 0, false + } + + // Check if we've already inlined this function at this particular + // call site, in order to stop inlining when we reach the beginning + // of a recursion cycle again. We don't inline immediately recursive + // functions, but allow inlining if there is a recursion cycle of + // many functions. Most likely, the inlining will stop before we + // even hit the beginning of the cycle again, but this catches the + // unusual case. + parent := base.Ctxt.PosTable.Pos(n.Pos()).Base().InliningIndex() + sym := callee.Linksym() + for inlIndex := parent; inlIndex >= 0; inlIndex = base.Ctxt.InlTree.Parent(inlIndex) { + if base.Ctxt.InlTree.InlinedFunction(inlIndex) == sym { + if log { + if base.Flag.LowerM > 1 { + fmt.Printf("%v: cannot inline %v into %v: repeated recursive cycle\n", ir.Line(n), callee, ir.FuncName(callerfn)) + } + if logopt.Enabled() { + logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", ir.FuncName(callerfn), + fmt.Sprintf("repeated recursive cycle to %s", ir.PkgFuncName(callee))) + } + } + return false, 0, false + } + } + + return true, callSiteScore, hot +} + +// mkinlcall returns an OINLCALL node that can replace OCALLFUNC n, or +// nil if it cannot be inlined. callerfn is the function that contains +// n, and fn is the function being called. +// +// The result of mkinlcall MUST be assigned back to n, e.g. +// +// n.Left = mkinlcall(n.Left, fn, isddd) +func mkinlcall(callerfn *ir.Func, n *ir.CallExpr, fn *ir.Func, bigCaller, closureCalledOnce bool) *ir.InlinedCallExpr { + ok, score, hot := canInlineCallExpr(callerfn, n, fn, bigCaller, closureCalledOnce, true) + if !ok { + return nil + } + if hot { + hasHotCall[callerfn] = struct{}{} + } + typecheck.AssertFixedCall(n) + + parent := base.Ctxt.PosTable.Pos(n.Pos()).Base().InliningIndex() + sym := fn.Linksym() + inlIndex := base.Ctxt.InlTree.Add(parent, n.Pos(), sym, ir.FuncName(fn)) + + closureInitLSym := func(n *ir.CallExpr, fn *ir.Func) { + // The linker needs FuncInfo metadata for all inlined + // functions. This is typically handled by gc.enqueueFunc + // calling ir.InitLSym for all function declarations in + // typecheck.Target.Decls (ir.UseClosure adds all closures to + // Decls). + // + // However, closures in Decls are ignored, and are + // instead enqueued when walk of the calling function + // discovers them. + // + // This presents a problem for direct calls to closures. + // Inlining will replace the entire closure definition with its + // body, which hides the closure from walk and thus suppresses + // symbol creation. + // + // Explicitly create a symbol early in this edge case to ensure + // we keep this metadata. + // + // TODO: Refactor to keep a reference so this can all be done + // by enqueueFunc. + + if n.Op() != ir.OCALLFUNC { + // Not a standard call. + return + } + + var nf = n.Fun + // Skips ir.OCONVNOPs, see issue #73716. + for nf.Op() == ir.OCONVNOP { + nf = nf.(*ir.ConvExpr).X + } + if nf.Op() != ir.OCLOSURE { + // Not a direct closure call or one with type conversion. + return + } + + clo := nf.(*ir.ClosureExpr) + if !clo.Func.IsClosure() { + // enqueueFunc will handle non closures anyways. + return + } + + ir.InitLSym(fn, true) + } + + closureInitLSym(n, fn) + + if base.Flag.GenDwarfInl > 0 { + if !sym.WasInlined() { + base.Ctxt.DwFixups.SetPrecursorFunc(sym, fn) + sym.Set(obj.AttrWasInlined, true) + } + } + + if base.Flag.LowerM != 0 { + if buildcfg.Experiment.NewInliner { + fmt.Printf("%v: inlining call to %v with score %d\n", + ir.Line(n), fn, score) + } else { + fmt.Printf("%v: inlining call to %v\n", ir.Line(n), fn) + } + } + if base.Flag.LowerM > 2 { + fmt.Printf("%v: Before inlining: %+v\n", ir.Line(n), n) + } + + res := InlineCall(callerfn, n, fn, inlIndex) + + if res == nil { + base.FatalfAt(n.Pos(), "inlining call to %v failed", fn) + } + + if base.Flag.LowerM > 2 { + fmt.Printf("%v: After inlining %+v\n\n", ir.Line(res), res) + } + + if inlheur.Enabled() { + inlheur.UpdateCallsiteTable(callerfn, n, res) + } + + return res +} + +// CalleeEffects appends any side effects from evaluating callee to init. +func CalleeEffects(init *ir.Nodes, callee ir.Node) { + for { + init.Append(ir.TakeInit(callee)...) + + switch callee.Op() { + case ir.ONAME, ir.OCLOSURE, ir.OMETHEXPR: + return // done + + case ir.OCONVNOP: + conv := callee.(*ir.ConvExpr) + callee = conv.X + + case ir.OINLCALL: + ic := callee.(*ir.InlinedCallExpr) + init.Append(ic.Body.Take()...) + callee = ic.SingleResult() + + default: + base.FatalfAt(callee.Pos(), "unexpected callee expression: %v", callee) + } + } +} + +func pruneUnusedAutos(ll []*ir.Name, vis *hairyVisitor) []*ir.Name { + s := make([]*ir.Name, 0, len(ll)) + for _, n := range ll { + if n.Class == ir.PAUTO { + if !vis.usedLocals.Has(n) { + // TODO(mdempsky): Simplify code after confident that this + // never happens anymore. + base.FatalfAt(n.Pos(), "unused auto: %v", n) + continue + } + } + s = append(s, n) + } + return s +} + +func doList(list []ir.Node, do func(ir.Node) bool) bool { + for _, x := range list { + if x != nil { + if do(x) { + return true + } + } + } + return false +} + +// isIndexingCoverageCounter returns true if the specified node 'n' is indexing +// into a coverage counter array. +func isIndexingCoverageCounter(n ir.Node) bool { + if n.Op() != ir.OINDEX { + return false + } + ixn := n.(*ir.IndexExpr) + if ixn.X.Op() != ir.ONAME || !ixn.X.Type().IsArray() { + return false + } + nn := ixn.X.(*ir.Name) + // CoverageAuxVar implies either a coverage counter or a package + // ID; since the cover tool never emits code to index into ID vars + // this is effectively testing whether nn is a coverage counter. + return nn.CoverageAuxVar() +} + +// isAtomicCoverageCounterUpdate examines the specified node to +// determine whether it represents a call to sync/atomic.AddUint32 to +// increment a coverage counter. +func isAtomicCoverageCounterUpdate(cn *ir.CallExpr) bool { + if cn.Fun.Op() != ir.ONAME { + return false + } + name := cn.Fun.(*ir.Name) + if name.Class != ir.PFUNC { + return false + } + fn := name.Sym().Name + if name.Sym().Pkg.Path != "sync/atomic" || + (fn != "AddUint32" && fn != "StoreUint32") { + return false + } + if len(cn.Args) != 2 || cn.Args[0].Op() != ir.OADDR { + return false + } + adn := cn.Args[0].(*ir.AddrExpr) + v := isIndexingCoverageCounter(adn.X) + return v +} + +func PostProcessCallSites(profile *pgoir.Profile) { + if base.Debug.DumpInlCallSiteScores != 0 { + budgetCallback := func(fn *ir.Func, prof *pgoir.Profile) (int32, bool) { + v := inlineBudget(fn, prof, false, false) + return v, v == inlineHotMaxBudget + } + inlheur.DumpInlCallSiteScores(profile, budgetCallback) + } +} + +func analyzeFuncProps(fn *ir.Func, p *pgoir.Profile) { + canInline := func(fn *ir.Func) { CanInline(fn, p) } + budgetForFunc := func(fn *ir.Func) int32 { + return inlineBudget(fn, p, true, false) + } + inlheur.AnalyzeFunc(fn, canInline, budgetForFunc, inlineMaxBudget) +} diff --git a/go/src/cmd/compile/internal/ir/abi.go b/go/src/cmd/compile/internal/ir/abi.go new file mode 100644 index 0000000000000000000000000000000000000000..ebe0fbfb2a731998df0bb34abf2f2185376a372c --- /dev/null +++ b/go/src/cmd/compile/internal/ir/abi.go @@ -0,0 +1,78 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "cmd/compile/internal/base" + "cmd/internal/obj" +) + +// InitLSym defines f's obj.LSym and initializes it based on the +// properties of f. This includes setting the symbol flags and ABI and +// creating and initializing related DWARF symbols. +// +// InitLSym must be called exactly once per function and must be +// called for both functions with bodies and functions without bodies. +// For body-less functions, we only create the LSym; for functions +// with bodies call a helper to setup up / populate the LSym. +func InitLSym(f *Func, hasBody bool) { + if f.LSym != nil { + base.FatalfAt(f.Pos(), "InitLSym called twice on %v", f) + } + + if nam := f.Nname; !IsBlank(nam) { + f.LSym = nam.LinksymABI(f.ABI) + if f.Pragma&Systemstack != 0 { + f.LSym.Set(obj.AttrCFunc, true) + } + } + if hasBody { + setupTextLSym(f, 0) + } +} + +// setupTextLSym initializes the LSym for a with-body text symbol. +func setupTextLSym(f *Func, flag int) { + if f.Dupok() { + flag |= obj.DUPOK + } + if f.Wrapper() { + flag |= obj.WRAPPER + } + if f.ABIWrapper() { + flag |= obj.ABIWRAPPER + } + if f.Needctxt() { + flag |= obj.NEEDCTXT + } + if f.Pragma&Nosplit != 0 { + flag |= obj.NOSPLIT + } + if f.IsPackageInit() { + flag |= obj.PKGINIT + } + + // Clumsy but important. + // For functions that could be on the path of invoking a deferred + // function that can recover (runtime.reflectcall, reflect.callReflect, + // and reflect.callMethod), we want the panic+recover special handling. + // See test/recover.go for test cases and src/reflect/value.go + // for the actual functions being considered. + // + // runtime.reflectcall is an assembly function which tailcalls + // WRAPPER functions (runtime.callNN). Its ABI wrapper needs WRAPPER + // flag as well. + fnname := f.Sym().Name + if base.Ctxt.Pkgpath == "runtime" && fnname == "reflectcall" { + flag |= obj.WRAPPER + } else if base.Ctxt.Pkgpath == "reflect" { + switch fnname { + case "callReflect", "callMethod": + flag |= obj.WRAPPER + } + } + + base.Ctxt.InitTextSym(f.LSym, flag, f.Pos()) +} diff --git a/go/src/cmd/compile/internal/ir/bitset.go b/go/src/cmd/compile/internal/ir/bitset.go new file mode 100644 index 0000000000000000000000000000000000000000..339e4e524f1df91b5330093f2a01ee6288b62ead --- /dev/null +++ b/go/src/cmd/compile/internal/ir/bitset.go @@ -0,0 +1,37 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +type bitset8 uint8 + +func (f *bitset8) set(mask uint8, b bool) { + if b { + *(*uint8)(f) |= mask + } else { + *(*uint8)(f) &^= mask + } +} + +func (f bitset8) get2(shift uint8) uint8 { + return uint8(f>>shift) & 3 +} + +// set2 sets two bits in f using the bottom two bits of b. +func (f *bitset8) set2(shift uint8, b uint8) { + // Clear old bits. + *(*uint8)(f) &^= 3 << shift + // Set new bits. + *(*uint8)(f) |= (b & 3) << shift +} + +type bitset16 uint16 + +func (f *bitset16) set(mask uint16, b bool) { + if b { + *(*uint16)(f) |= mask + } else { + *(*uint16)(f) &^= mask + } +} diff --git a/go/src/cmd/compile/internal/ir/cfg.go b/go/src/cmd/compile/internal/ir/cfg.go new file mode 100644 index 0000000000000000000000000000000000000000..123d8c612a39b1a51278ccba733672123ce03037 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/cfg.go @@ -0,0 +1,26 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +var ( + // MaxStackVarSize is the maximum size variable which we will allocate on the stack. + // This limit is for explicit variable declarations like "var x T" or "x := ...". + // Note: the flag smallframes can update this value. + MaxStackVarSize = int64(128 * 1024) + + // MaxImplicitStackVarSize is the maximum size of implicit variables that we will allocate on the stack. + // p := new(T) allocating T on the stack + // p := &T{} allocating T on the stack + // s := make([]T, n) allocating [n]T on the stack + // s := []byte("...") allocating [n]byte on the stack + // Note: the flag smallframes can update this value. + MaxImplicitStackVarSize = int64(64 * 1024) + + // MaxSmallArraySize is the maximum size of an array which is considered small. + // Small arrays will be initialized directly with a sequence of constant stores. + // Large arrays will be initialized by copying from a static temp. + // 256 bytes was chosen to minimize generated code + statictmp size. + MaxSmallArraySize = int64(256) +) diff --git a/go/src/cmd/compile/internal/ir/check_reassign_no.go b/go/src/cmd/compile/internal/ir/check_reassign_no.go new file mode 100644 index 0000000000000000000000000000000000000000..8290a7da7e824496d70cc856938c8da8874cde20 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/check_reassign_no.go @@ -0,0 +1,9 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !checknewoldreassignment + +package ir + +const consistencyCheckEnabled = false diff --git a/go/src/cmd/compile/internal/ir/check_reassign_yes.go b/go/src/cmd/compile/internal/ir/check_reassign_yes.go new file mode 100644 index 0000000000000000000000000000000000000000..30876cca20f7afa8e206cd51242febbe901ccb49 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/check_reassign_yes.go @@ -0,0 +1,9 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build checknewoldreassignment + +package ir + +const consistencyCheckEnabled = true diff --git a/go/src/cmd/compile/internal/ir/class_string.go b/go/src/cmd/compile/internal/ir/class_string.go new file mode 100644 index 0000000000000000000000000000000000000000..11a94c004701ba4f6238217b145b2972abbea1a7 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/class_string.go @@ -0,0 +1,30 @@ +// Code generated by "stringer -type=Class name.go"; DO NOT EDIT. + +package ir + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Pxxx-0] + _ = x[PEXTERN-1] + _ = x[PAUTO-2] + _ = x[PAUTOHEAP-3] + _ = x[PPARAM-4] + _ = x[PPARAMOUT-5] + _ = x[PTYPEPARAM-6] + _ = x[PFUNC-7] +} + +const _Class_name = "PxxxPEXTERNPAUTOPAUTOHEAPPPARAMPPARAMOUTPTYPEPARAMPFUNC" + +var _Class_index = [...]uint8{0, 4, 11, 16, 25, 31, 40, 50, 55} + +func (i Class) String() string { + if i >= Class(len(_Class_index)-1) { + return "Class(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Class_name[_Class_index[i]:_Class_index[i+1]] +} diff --git a/go/src/cmd/compile/internal/ir/const.go b/go/src/cmd/compile/internal/ir/const.go new file mode 100644 index 0000000000000000000000000000000000000000..0efd1137fe4b9aa3aca9df608d4e3143e33cbca5 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/const.go @@ -0,0 +1,161 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "go/constant" + "math" + "math/big" + + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +// NewBool returns an OLITERAL representing b as an untyped boolean. +func NewBool(pos src.XPos, b bool) Node { + return NewBasicLit(pos, types.UntypedBool, constant.MakeBool(b)) +} + +// NewInt returns an OLITERAL representing v as an untyped integer. +func NewInt(pos src.XPos, v int64) Node { + return NewBasicLit(pos, types.UntypedInt, constant.MakeInt64(v)) +} + +// NewString returns an OLITERAL representing s as an untyped string. +func NewString(pos src.XPos, s string) Node { + return NewBasicLit(pos, types.UntypedString, constant.MakeString(s)) +} + +// NewUintptr returns an OLITERAL representing v as a uintptr. +func NewUintptr(pos src.XPos, v int64) Node { + return NewBasicLit(pos, types.Types[types.TUINTPTR], constant.MakeInt64(v)) +} + +// NewZero returns a zero value of the given type. +func NewZero(pos src.XPos, typ *types.Type) Node { + switch { + case typ.HasNil(): + return NewNilExpr(pos, typ) + case typ.IsInteger(): + return NewBasicLit(pos, typ, intZero) + case typ.IsFloat(): + return NewBasicLit(pos, typ, floatZero) + case typ.IsComplex(): + return NewBasicLit(pos, typ, complexZero) + case typ.IsBoolean(): + return NewBasicLit(pos, typ, constant.MakeBool(false)) + case typ.IsString(): + return NewBasicLit(pos, typ, constant.MakeString("")) + case typ.IsArray() || typ.IsStruct(): + // TODO(mdempsky): Return a typechecked expression instead. + return NewCompLitExpr(pos, OCOMPLIT, typ, nil) + } + + base.FatalfAt(pos, "unexpected type: %v", typ) + panic("unreachable") +} + +var ( + intZero = constant.MakeInt64(0) + floatZero = constant.ToFloat(intZero) + complexZero = constant.ToComplex(intZero) +) + +// NewOne returns an OLITERAL representing 1 with the given type. +func NewOne(pos src.XPos, typ *types.Type) Node { + var val constant.Value + switch { + case typ.IsInteger(): + val = intOne + case typ.IsFloat(): + val = floatOne + case typ.IsComplex(): + val = complexOne + default: + base.FatalfAt(pos, "%v cannot represent 1", typ) + } + + return NewBasicLit(pos, typ, val) +} + +var ( + intOne = constant.MakeInt64(1) + floatOne = constant.ToFloat(intOne) + complexOne = constant.ToComplex(intOne) +) + +const ( + // Maximum size in bits for big.Ints before signaling + // overflow and also mantissa precision for big.Floats. + ConstPrec = 512 +) + +func BigFloat(v constant.Value) *big.Float { + f := new(big.Float) + f.SetPrec(ConstPrec) + switch u := constant.Val(v).(type) { + case int64: + f.SetInt64(u) + case *big.Int: + f.SetInt(u) + case *big.Float: + f.Set(u) + case *big.Rat: + f.SetRat(u) + default: + base.Fatalf("unexpected: %v", u) + } + return f +} + +// ConstOverflow reports whether constant value v is too large +// to represent with type t. +func ConstOverflow(v constant.Value, t *types.Type) bool { + switch { + case t.IsInteger(): + bits := uint(8 * t.Size()) + if t.IsUnsigned() { + x, ok := constant.Uint64Val(v) + return !ok || x>>bits != 0 + } + x, ok := constant.Int64Val(v) + if x < 0 { + x = ^x + } + return !ok || x>>(bits-1) != 0 + case t.IsFloat(): + switch t.Size() { + case 4: + f, _ := constant.Float32Val(v) + return math.IsInf(float64(f), 0) + case 8: + f, _ := constant.Float64Val(v) + return math.IsInf(f, 0) + } + case t.IsComplex(): + ft := types.FloatForComplex(t) + return ConstOverflow(constant.Real(v), ft) || ConstOverflow(constant.Imag(v), ft) + } + base.Fatalf("ConstOverflow: %v, %v", v, t) + panic("unreachable") +} + +// IsConstNode reports whether n is a Go language constant (as opposed to a +// compile-time constant). +// +// Expressions derived from nil, like string([]byte(nil)), while they +// may be known at compile time, are not Go language constants. +func IsConstNode(n Node) bool { + return n.Op() == OLITERAL +} + +func IsSmallIntConst(n Node) bool { + if n.Op() == OLITERAL { + v, ok := constant.Int64Val(n.Val()) + return ok && int64(int32(v)) == v + } + return false +} diff --git a/go/src/cmd/compile/internal/ir/copy.go b/go/src/cmd/compile/internal/ir/copy.go new file mode 100644 index 0000000000000000000000000000000000000000..4ec887d397ca68cbc772d5ee8111bc9e810a3b31 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/copy.go @@ -0,0 +1,34 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "cmd/internal/src" +) + +// Copy returns a shallow copy of n. +func Copy(n Node) Node { + return n.copy() +} + +// DeepCopy returns a “deep” copy of n, with its entire structure copied +// (except for shared nodes like ONAME, ONONAME, OLITERAL, and OTYPE). +// If pos.IsKnown(), it sets the source position of newly allocated Nodes to pos. +func DeepCopy(pos src.XPos, n Node) Node { + var edit func(Node) Node + edit = func(x Node) Node { + switch x.Op() { + case ONAME, ONONAME, OLITERAL, ONIL, OTYPE: + return x + } + x = Copy(x) + if pos.IsKnown() { + x.SetPos(pos) + } + EditChildren(x, edit) + return x + } + return edit(n) +} diff --git a/go/src/cmd/compile/internal/ir/dump.go b/go/src/cmd/compile/internal/ir/dump.go new file mode 100644 index 0000000000000000000000000000000000000000..3e5e6fbdcee95fb9bf9f5ed01659a59e85ca0519 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/dump.go @@ -0,0 +1,256 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements textual dumping of arbitrary data structures +// for debugging purposes. The code is customized for Node graphs +// and may be used for an alternative view of the node structure. + +package ir + +import ( + "fmt" + "io" + "os" + "reflect" + "regexp" + + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +// DumpAny is like FDumpAny but prints to stderr. +func DumpAny(root any, filter string, depth int) { + FDumpAny(os.Stderr, root, filter, depth) +} + +// FDumpAny prints the structure of a rooted data structure +// to w by depth-first traversal of the data structure. +// +// The filter parameter is a regular expression. If it is +// non-empty, only struct fields whose names match filter +// are printed. +// +// The depth parameter controls how deep traversal recurses +// before it returns (higher value means greater depth). +// If an empty field filter is given, a good depth default value +// is 4. A negative depth means no depth limit, which may be fine +// for small data structures or if there is a non-empty filter. +// +// In the output, Node structs are identified by their Op name +// rather than their type; struct fields with zero values or +// non-matching field names are omitted, and "…" means recursion +// depth has been reached or struct fields have been omitted. +func FDumpAny(w io.Writer, root any, filter string, depth int) { + if root == nil { + fmt.Fprintln(w, "nil") + return + } + + if filter == "" { + filter = ".*" // default + } + + p := dumper{ + output: w, + fieldrx: regexp.MustCompile(filter), + ptrmap: make(map[uintptr]int), + last: '\n', // force printing of line number on first line + } + + p.dump(reflect.ValueOf(root), depth) + p.printf("\n") +} + +type dumper struct { + output io.Writer + fieldrx *regexp.Regexp // field name filter + ptrmap map[uintptr]int // ptr -> dump line number + lastadr string // last address string printed (for shortening) + + // output + indent int // current indentation level + last byte // last byte processed by Write + line int // current line number +} + +var indentBytes = []byte(". ") + +func (p *dumper) Write(data []byte) (n int, err error) { + var m int + for i, b := range data { + // invariant: data[0:n] has been written + if b == '\n' { + m, err = p.output.Write(data[n : i+1]) + n += m + if err != nil { + return + } + } else if p.last == '\n' { + p.line++ + _, err = fmt.Fprintf(p.output, "%6d ", p.line) + if err != nil { + return + } + for j := p.indent; j > 0; j-- { + _, err = p.output.Write(indentBytes) + if err != nil { + return + } + } + } + p.last = b + } + if len(data) > n { + m, err = p.output.Write(data[n:]) + n += m + } + return +} + +// printf is a convenience wrapper. +func (p *dumper) printf(format string, args ...any) { + if _, err := fmt.Fprintf(p, format, args...); err != nil { + panic(err) + } +} + +// addr returns the (hexadecimal) address string of the object +// represented by x (or "?" if x is not addressable), with the +// common prefix between this and the prior address replaced by +// "0x…" to make it easier to visually match addresses. +func (p *dumper) addr(x reflect.Value) string { + if !x.CanAddr() { + return "?" + } + adr := fmt.Sprintf("%p", x.Addr().Interface()) + s := adr + if i := commonPrefixLen(p.lastadr, adr); i > 0 { + s = "0x…" + adr[i:] + } + p.lastadr = adr + return s +} + +// dump prints the contents of x. +func (p *dumper) dump(x reflect.Value, depth int) { + if depth == 0 { + p.printf("…") + return + } + + if pos, ok := x.Interface().(src.XPos); ok { + p.printf("%s", base.FmtPos(pos)) + return + } + + switch x.Kind() { + case reflect.String: + p.printf("%q", x.Interface()) // print strings in quotes + + case reflect.Interface: + if x.IsNil() { + p.printf("nil") + return + } + p.dump(x.Elem(), depth-1) + + case reflect.Ptr: + if x.IsNil() { + p.printf("nil") + return + } + + p.printf("*") + ptr := x.Pointer() + if line, exists := p.ptrmap[ptr]; exists { + p.printf("(@%d)", line) + return + } + p.ptrmap[ptr] = p.line + p.dump(x.Elem(), depth) // don't count pointer indirection towards depth + + case reflect.Slice: + if x.IsNil() { + p.printf("nil") + return + } + p.printf("%s (%d entries) {", x.Type(), x.Len()) + if x.Len() > 0 { + p.indent++ + p.printf("\n") + for i, n := 0, x.Len(); i < n; i++ { + p.printf("%d: ", i) + p.dump(x.Index(i), depth-1) + p.printf("\n") + } + p.indent-- + } + p.printf("}") + + case reflect.Struct: + typ := x.Type() + + isNode := false + if n, ok := x.Interface().(Node); ok { + isNode = true + p.printf("%s %s {", n.Op().String(), p.addr(x)) + } else { + p.printf("%s {", typ) + } + p.indent++ + + first := true + omitted := false + for i, n := 0, typ.NumField(); i < n; i++ { + // Exclude non-exported fields because their + // values cannot be accessed via reflection. + if name := typ.Field(i).Name; types.IsExported(name) { + if !p.fieldrx.MatchString(name) { + omitted = true + continue // field name not selected by filter + } + + // special cases + if isNode && name == "Op" { + omitted = true + continue // Op field already printed for Nodes + } + x := x.Field(i) + if x.IsZero() { + omitted = true + continue // exclude zero-valued fields + } + if n, ok := x.Interface().(Nodes); ok && len(n) == 0 { + omitted = true + continue // exclude empty Nodes slices + } + + if first { + p.printf("\n") + first = false + } + p.printf("%s: ", name) + p.dump(x, depth-1) + p.printf("\n") + } + } + if omitted { + p.printf("…\n") + } + + p.indent-- + p.printf("}") + + default: + p.printf("%v", x.Interface()) + } +} + +func commonPrefixLen(a, b string) (i int) { + for i < len(a) && i < len(b) && a[i] == b[i] { + i++ + } + return +} diff --git a/go/src/cmd/compile/internal/ir/expr.go b/go/src/cmd/compile/internal/ir/expr.go new file mode 100644 index 0000000000000000000000000000000000000000..f32998f333ea46e7bca753ee068249e38e97d8e6 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/expr.go @@ -0,0 +1,1312 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "bytes" + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" + "fmt" + "go/constant" + "go/token" +) + +// An Expr is a Node that can appear as an expression. +type Expr interface { + Node + isExpr() +} + +// A miniExpr is a miniNode with extra fields common to expressions. +// TODO(rsc): Once we are sure about the contents, compact the bools +// into a bit field and leave extra bits available for implementations +// embedding miniExpr. Right now there are ~24 unused bits sitting here. +type miniExpr struct { + miniNode + flags bitset8 + typ *types.Type + init Nodes // TODO(rsc): Don't require every Node to have an init +} + +const ( + miniExprNonNil = 1 << iota + miniExprTransient + miniExprBounded + miniExprImplicit // for use by implementations; not supported by every Expr + miniExprCheckPtr +) + +func (*miniExpr) isExpr() {} + +func (n *miniExpr) Type() *types.Type { return n.typ } +func (n *miniExpr) SetType(x *types.Type) { n.typ = x } +func (n *miniExpr) NonNil() bool { return n.flags&miniExprNonNil != 0 } +func (n *miniExpr) MarkNonNil() { n.flags |= miniExprNonNil } +func (n *miniExpr) Transient() bool { return n.flags&miniExprTransient != 0 } +func (n *miniExpr) SetTransient(b bool) { n.flags.set(miniExprTransient, b) } +func (n *miniExpr) Bounded() bool { return n.flags&miniExprBounded != 0 } +func (n *miniExpr) SetBounded(b bool) { n.flags.set(miniExprBounded, b) } +func (n *miniExpr) Init() Nodes { return n.init } +func (n *miniExpr) PtrInit() *Nodes { return &n.init } +func (n *miniExpr) SetInit(x Nodes) { n.init = x } + +// An AddStringExpr is a string concatenation List[0] + List[1] + ... + List[len(List)-1]. +type AddStringExpr struct { + miniExpr + List Nodes + Prealloc *Name +} + +func NewAddStringExpr(pos src.XPos, list []Node) *AddStringExpr { + n := &AddStringExpr{} + n.pos = pos + n.op = OADDSTR + n.List = list + return n +} + +// An AddrExpr is an address-of expression &X. +// It may end up being a normal address-of or an allocation of a composite literal. +type AddrExpr struct { + miniExpr + X Node + Prealloc *Name // preallocated storage if any +} + +func NewAddrExpr(pos src.XPos, x Node) *AddrExpr { + if x == nil || x.Typecheck() != 1 { + base.FatalfAt(pos, "missed typecheck: %L", x) + } + n := &AddrExpr{X: x} + n.pos = pos + + switch x.Op() { + case OARRAYLIT, OMAPLIT, OSLICELIT, OSTRUCTLIT: + n.op = OPTRLIT + + default: + n.op = OADDR + if r, ok := OuterValue(x).(*Name); ok && r.Op() == ONAME { + r.SetAddrtaken(true) + + // If r is a closure variable, we need to mark its canonical + // variable as addrtaken too, so that closure conversion + // captures it by reference. + // + // Exception: if we've already marked the variable as + // capture-by-value, then that means this variable isn't + // logically modified, and we must be taking its address to pass + // to a runtime function that won't mutate it. In that case, we + // only need to make sure our own copy is addressable. + if r.IsClosureVar() && !r.Byval() { + r.Canonical().SetAddrtaken(true) + } + } + } + + n.SetType(types.NewPtr(x.Type())) + n.SetTypecheck(1) + + return n +} + +func (n *AddrExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *AddrExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } + +func (n *AddrExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OADDR, OPTRLIT: + n.op = op + } +} + +// A BasicLit is a literal of basic type. +type BasicLit struct { + miniExpr + val constant.Value +} + +// NewBasicLit returns an OLITERAL representing val with the given type. +func NewBasicLit(pos src.XPos, typ *types.Type, val constant.Value) Node { + AssertValidTypeForConst(typ, val) + + n := &BasicLit{val: val} + n.op = OLITERAL + n.pos = pos + n.SetType(typ) + n.SetTypecheck(1) + return n +} + +func (n *BasicLit) Val() constant.Value { return n.val } +func (n *BasicLit) SetVal(val constant.Value) { n.val = val } + +// NewConstExpr returns an OLITERAL representing val, copying the +// position and type from orig. +func NewConstExpr(val constant.Value, orig Node) Node { + return NewBasicLit(orig.Pos(), orig.Type(), val) +} + +// A BinaryExpr is a binary expression X Op Y, +// or Op(X, Y) for builtin functions that do not become calls. +type BinaryExpr struct { + miniExpr + X Node + Y Node + RType Node `mknode:"-"` // see reflectdata/helpers.go +} + +func NewBinaryExpr(pos src.XPos, op Op, x, y Node) *BinaryExpr { + n := &BinaryExpr{X: x, Y: y} + n.pos = pos + n.SetOp(op) + return n +} + +func (n *BinaryExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OADD, OADDSTR, OAND, OANDNOT, ODIV, OEQ, OGE, OGT, OLE, + OLSH, OLT, OMOD, OMUL, ONE, OOR, ORSH, OSUB, OXOR, + OCOPY, OCOMPLEX, OUNSAFEADD, OUNSAFESLICE, OUNSAFESTRING, + OMAKEFACE: + n.op = op + } +} + +// A CallExpr is a function call Fun(Args). +type CallExpr struct { + miniExpr + Fun Node + Args Nodes + DeferAt Node + RType Node `mknode:"-"` // see reflectdata/helpers.go + KeepAlive []*Name // vars to be kept alive until call returns + IsDDD bool + GoDefer bool // whether this call is part of a go or defer statement + NoInline bool // whether this call must not be inlined + UseBuf bool // use stack buffer for backing store (OAPPEND only) + AppendNoAlias bool // backing store proven to be unaliased (OAPPEND only) + // whether it's a runtime.KeepAlive call the compiler generates to + // keep a variable alive. See #73137. + IsCompilerVarLive bool +} + +func NewCallExpr(pos src.XPos, op Op, fun Node, args []Node) *CallExpr { + n := &CallExpr{Fun: fun} + n.pos = pos + n.SetOp(op) + n.Args = args + return n +} + +func (*CallExpr) isStmt() {} + +func (n *CallExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OAPPEND, + OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, + ODELETE, + OGETG, OGETCALLERSP, + OMAKE, OMAX, OMIN, OPRINT, OPRINTLN, + ORECOVER: + n.op = op + } +} + +// A ClosureExpr is a function literal expression. +type ClosureExpr struct { + miniExpr + Func *Func `mknode:"-"` + Prealloc *Name + IsGoWrap bool // whether this is wrapper closure of a go statement +} + +// A CompLitExpr is a composite literal Type{Vals}. +// Before type-checking, the type is Ntype. +type CompLitExpr struct { + miniExpr + List Nodes // initialized values + RType Node `mknode:"-"` // *runtime._type for OMAPLIT map types + Prealloc *Name + // For OSLICELIT, Len is the backing array length. + // For OMAPLIT, Len is the number of entries that we've removed from List and + // generated explicit mapassign calls for. This is used to inform the map alloc hint. + Len int64 +} + +func NewCompLitExpr(pos src.XPos, op Op, typ *types.Type, list []Node) *CompLitExpr { + n := &CompLitExpr{List: list} + n.pos = pos + n.SetOp(op) + if typ != nil { + n.SetType(typ) + } + return n +} + +func (n *CompLitExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *CompLitExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } + +func (n *CompLitExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OARRAYLIT, OCOMPLIT, OMAPLIT, OSTRUCTLIT, OSLICELIT: + n.op = op + } +} + +// A ConvExpr is a conversion Type(X). +// It may end up being a value or a type. +type ConvExpr struct { + miniExpr + X Node + + // For implementing OCONVIFACE expressions. + // + // TypeWord is an expression yielding a *runtime._type or + // *runtime.itab value to go in the type word of the iface/eface + // result. See reflectdata.ConvIfaceTypeWord for further details. + // + // SrcRType is an expression yielding a *runtime._type value for X, + // if it's not pointer-shaped and needs to be heap allocated. + TypeWord Node `mknode:"-"` + SrcRType Node `mknode:"-"` + + // For -d=checkptr instrumentation of conversions from + // unsafe.Pointer to *Elem or *[Len]Elem. + // + // TODO(mdempsky): We only ever need one of these, but currently we + // don't decide which one until walk. Longer term, it probably makes + // sense to have a dedicated IR op for `(*[Len]Elem)(ptr)[:n:m]` + // expressions. + ElemRType Node `mknode:"-"` + ElemElemRType Node `mknode:"-"` +} + +func NewConvExpr(pos src.XPos, op Op, typ *types.Type, x Node) *ConvExpr { + n := &ConvExpr{X: x} + n.pos = pos + n.typ = typ + n.SetOp(op) + return n +} + +func (n *ConvExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *ConvExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } +func (n *ConvExpr) CheckPtr() bool { return n.flags&miniExprCheckPtr != 0 } +func (n *ConvExpr) SetCheckPtr(b bool) { n.flags.set(miniExprCheckPtr, b) } + +func (n *ConvExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OCONV, OCONVIFACE, OCONVNOP, OBYTES2STR, OBYTES2STRTMP, ORUNES2STR, OSTR2BYTES, OSTR2BYTESTMP, OSTR2RUNES, ORUNESTR, OSLICE2ARR, OSLICE2ARRPTR: + n.op = op + } +} + +// An IndexExpr is an index expression X[Index]. +type IndexExpr struct { + miniExpr + X Node + Index Node + RType Node `mknode:"-"` // see reflectdata/helpers.go + Assigned bool +} + +func NewIndexExpr(pos src.XPos, x, index Node) *IndexExpr { + n := &IndexExpr{X: x, Index: index} + n.pos = pos + n.op = OINDEX + return n +} + +func (n *IndexExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OINDEX, OINDEXMAP: + n.op = op + } +} + +// A KeyExpr is a Key: Value composite literal key. +type KeyExpr struct { + miniExpr + Key Node + Value Node +} + +func NewKeyExpr(pos src.XPos, key, value Node) *KeyExpr { + n := &KeyExpr{Key: key, Value: value} + n.pos = pos + n.op = OKEY + return n +} + +// A StructKeyExpr is a Field: Value composite literal key. +type StructKeyExpr struct { + miniExpr + Field *types.Field + Value Node +} + +func NewStructKeyExpr(pos src.XPos, field *types.Field, value Node) *StructKeyExpr { + n := &StructKeyExpr{Field: field, Value: value} + n.pos = pos + n.op = OSTRUCTKEY + return n +} + +func (n *StructKeyExpr) Sym() *types.Sym { return n.Field.Sym } + +// An InlinedCallExpr is an inlined function call. +type InlinedCallExpr struct { + miniExpr + Body Nodes + ReturnVars Nodes // must be side-effect free +} + +func NewInlinedCallExpr(pos src.XPos, body, retvars []Node) *InlinedCallExpr { + n := &InlinedCallExpr{} + n.pos = pos + n.op = OINLCALL + n.Body = body + n.ReturnVars = retvars + return n +} + +func (n *InlinedCallExpr) SingleResult() Node { + if have := len(n.ReturnVars); have != 1 { + base.FatalfAt(n.Pos(), "inlined call has %v results, expected 1", have) + } + if !n.Type().HasShape() && n.ReturnVars[0].Type().HasShape() { + // If the type of the call is not a shape, but the type of the return value + // is a shape, we need to do an implicit conversion, so the real type + // of n is maintained. + r := NewConvExpr(n.Pos(), OCONVNOP, n.Type(), n.ReturnVars[0]) + r.SetTypecheck(1) + return r + } + return n.ReturnVars[0] +} + +// A LogicalExpr is an expression X Op Y where Op is && or ||. +// It is separate from BinaryExpr to make room for statements +// that must be executed before Y but after X. +type LogicalExpr struct { + miniExpr + X Node + Y Node +} + +func NewLogicalExpr(pos src.XPos, op Op, x, y Node) *LogicalExpr { + n := &LogicalExpr{X: x, Y: y} + n.pos = pos + n.SetOp(op) + return n +} + +func (n *LogicalExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OANDAND, OOROR: + n.op = op + } +} + +// A MakeExpr is a make expression: make(Type[, Len[, Cap]]). +// Op is OMAKECHAN, OMAKEMAP, OMAKESLICE, or OMAKESLICECOPY, +// but *not* OMAKE (that's a pre-typechecking CallExpr). +type MakeExpr struct { + miniExpr + RType Node `mknode:"-"` // see reflectdata/helpers.go + Len Node + Cap Node +} + +func NewMakeExpr(pos src.XPos, op Op, len, cap Node) *MakeExpr { + n := &MakeExpr{Len: len, Cap: cap} + n.pos = pos + n.SetOp(op) + return n +} + +func (n *MakeExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OMAKECHAN, OMAKEMAP, OMAKESLICE, OMAKESLICECOPY: + n.op = op + } +} + +// A NilExpr represents the predefined untyped constant nil. +type NilExpr struct { + miniExpr +} + +func NewNilExpr(pos src.XPos, typ *types.Type) *NilExpr { + if typ == nil { + base.FatalfAt(pos, "missing type") + } + n := &NilExpr{} + n.pos = pos + n.op = ONIL + n.SetType(typ) + n.SetTypecheck(1) + return n +} + +// A ParenExpr is a parenthesized expression (X). +// It may end up being a value or a type. +type ParenExpr struct { + miniExpr + X Node +} + +func NewParenExpr(pos src.XPos, x Node) *ParenExpr { + n := &ParenExpr{X: x} + n.op = OPAREN + n.pos = pos + return n +} + +func (n *ParenExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *ParenExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } + +// A ResultExpr represents a direct access to a result. +type ResultExpr struct { + miniExpr + Index int64 // index of the result expr. +} + +func NewResultExpr(pos src.XPos, typ *types.Type, index int64) *ResultExpr { + n := &ResultExpr{Index: index} + n.pos = pos + n.op = ORESULT + n.typ = typ + return n +} + +// A LinksymOffsetExpr refers to an offset within a global variable. +// It is like a SelectorExpr but without the field name. +type LinksymOffsetExpr struct { + miniExpr + Linksym *obj.LSym + Offset_ int64 +} + +func NewLinksymOffsetExpr(pos src.XPos, lsym *obj.LSym, offset int64, typ *types.Type) *LinksymOffsetExpr { + if typ == nil { + base.FatalfAt(pos, "nil type") + } + n := &LinksymOffsetExpr{Linksym: lsym, Offset_: offset} + n.typ = typ + n.op = OLINKSYMOFFSET + n.SetTypecheck(1) + return n +} + +// NewLinksymExpr is NewLinksymOffsetExpr, but with offset fixed at 0. +func NewLinksymExpr(pos src.XPos, lsym *obj.LSym, typ *types.Type) *LinksymOffsetExpr { + return NewLinksymOffsetExpr(pos, lsym, 0, typ) +} + +// NewNameOffsetExpr is NewLinksymOffsetExpr, but taking a *Name +// representing a global variable instead of an *obj.LSym directly. +func NewNameOffsetExpr(pos src.XPos, name *Name, offset int64, typ *types.Type) *LinksymOffsetExpr { + if name == nil || IsBlank(name) || !(name.Op() == ONAME && name.Class == PEXTERN) { + base.FatalfAt(pos, "cannot take offset of nil, blank name or non-global variable: %v", name) + } + return NewLinksymOffsetExpr(pos, name.Linksym(), offset, typ) +} + +// A SelectorExpr is a selector expression X.Sel. +type SelectorExpr struct { + miniExpr + X Node + // Sel is the name of the field or method being selected, without (in the + // case of methods) any preceding type specifier. If the field/method is + // exported, than the Sym uses the local package regardless of the package + // of the containing type. + Sel *types.Sym + // The actual selected field - may not be filled in until typechecking. + Selection *types.Field + Prealloc *Name // preallocated storage for OMETHVALUE, if any +} + +func NewSelectorExpr(pos src.XPos, op Op, x Node, sel *types.Sym) *SelectorExpr { + n := &SelectorExpr{X: x, Sel: sel} + n.pos = pos + n.SetOp(op) + return n +} + +func (n *SelectorExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OXDOT, ODOT, ODOTPTR, ODOTMETH, ODOTINTER, OMETHVALUE, OMETHEXPR: + n.op = op + } +} + +func (n *SelectorExpr) Sym() *types.Sym { return n.Sel } +func (n *SelectorExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *SelectorExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } +func (n *SelectorExpr) Offset() int64 { return n.Selection.Offset } + +func (n *SelectorExpr) FuncName() *Name { + if n.Op() != OMETHEXPR { + panic(n.no("FuncName")) + } + fn := NewNameAt(n.Selection.Pos, MethodSym(n.X.Type(), n.Sel), n.Type()) + fn.Class = PFUNC + if n.Selection.Nname != nil { + // TODO(austin): Nname is nil for interface method + // expressions (I.M), so we can't attach a Func to + // those here. + fn.Func = n.Selection.Nname.(*Name).Func + } + return fn +} + +// A SliceExpr is a slice expression X[Low:High] or X[Low:High:Max]. +type SliceExpr struct { + miniExpr + X Node + Low Node + High Node + Max Node +} + +func NewSliceExpr(pos src.XPos, op Op, x, low, high, max Node) *SliceExpr { + n := &SliceExpr{X: x, Low: low, High: high, Max: max} + n.pos = pos + n.op = op + return n +} + +func (n *SliceExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OSLICE, OSLICEARR, OSLICESTR, OSLICE3, OSLICE3ARR: + n.op = op + } +} + +// IsSlice3 reports whether o is a slice3 op (OSLICE3, OSLICE3ARR). +// o must be a slicing op. +func (o Op) IsSlice3() bool { + switch o { + case OSLICE, OSLICEARR, OSLICESTR: + return false + case OSLICE3, OSLICE3ARR: + return true + } + base.Fatalf("IsSlice3 op %v", o) + return false +} + +// A SliceHeaderExpr constructs a slice header from its parts. +type SliceHeaderExpr struct { + miniExpr + Ptr Node + Len Node + Cap Node +} + +func NewSliceHeaderExpr(pos src.XPos, typ *types.Type, ptr, len, cap Node) *SliceHeaderExpr { + n := &SliceHeaderExpr{Ptr: ptr, Len: len, Cap: cap} + n.pos = pos + n.op = OSLICEHEADER + n.typ = typ + return n +} + +// A StringHeaderExpr expression constructs a string header from its parts. +type StringHeaderExpr struct { + miniExpr + Ptr Node + Len Node +} + +func NewStringHeaderExpr(pos src.XPos, ptr, len Node) *StringHeaderExpr { + n := &StringHeaderExpr{Ptr: ptr, Len: len} + n.pos = pos + n.op = OSTRINGHEADER + n.typ = types.Types[types.TSTRING] + return n +} + +// A StarExpr is a dereference expression *X. +// It may end up being a value or a type. +type StarExpr struct { + miniExpr + X Node +} + +func NewStarExpr(pos src.XPos, x Node) *StarExpr { + n := &StarExpr{X: x} + n.op = ODEREF + n.pos = pos + return n +} + +func (n *StarExpr) Implicit() bool { return n.flags&miniExprImplicit != 0 } +func (n *StarExpr) SetImplicit(b bool) { n.flags.set(miniExprImplicit, b) } + +// A TypeAssertExpr is a selector expression X.(Type). +// Before type-checking, the type is Ntype. +type TypeAssertExpr struct { + miniExpr + X Node + + // Runtime type information provided by walkDotType for + // assertions from non-empty interface to concrete type. + ITab Node `mknode:"-"` // *runtime.itab for Type implementing X's type + + // An internal/abi.TypeAssert descriptor to pass to the runtime. + Descriptor *obj.LSym + + // When set to true, if this assert would panic, then use a nil pointer panic + // instead of an interface conversion panic. + // It must not be set for type assertions using the commaok form. + UseNilPanic bool +} + +func NewTypeAssertExpr(pos src.XPos, x Node, typ *types.Type) *TypeAssertExpr { + n := &TypeAssertExpr{X: x} + n.pos = pos + n.op = ODOTTYPE + if typ != nil { + n.SetType(typ) + } + return n +} + +func (n *TypeAssertExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case ODOTTYPE, ODOTTYPE2: + n.op = op + } +} + +// A DynamicTypeAssertExpr asserts that X is of dynamic type RType. +type DynamicTypeAssertExpr struct { + miniExpr + X Node + + // SrcRType is an expression that yields a *runtime._type value + // representing X's type. It's used in failed assertion panic + // messages. + SrcRType Node + + // RType is an expression that yields a *runtime._type value + // representing the asserted type. + // + // BUG(mdempsky): If ITab is non-nil, RType may be nil. + RType Node + + // ITab is an expression that yields a *runtime.itab value + // representing the asserted type within the assertee expression's + // original interface type. + // + // ITab is only used for assertions from non-empty interface type to + // a concrete (i.e., non-interface) type. For all other assertions, + // ITab is nil. + ITab Node +} + +func NewDynamicTypeAssertExpr(pos src.XPos, op Op, x, rtype Node) *DynamicTypeAssertExpr { + n := &DynamicTypeAssertExpr{X: x, RType: rtype} + n.pos = pos + n.op = op + return n +} + +func (n *DynamicTypeAssertExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case ODYNAMICDOTTYPE, ODYNAMICDOTTYPE2: + n.op = op + } +} + +// A UnaryExpr is a unary expression Op X, +// or Op(X) for a builtin function that does not end up being a call. +type UnaryExpr struct { + miniExpr + X Node +} + +func NewUnaryExpr(pos src.XPos, op Op, x Node) *UnaryExpr { + n := &UnaryExpr{X: x} + n.pos = pos + n.SetOp(op) + return n +} + +func (n *UnaryExpr) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OBITNOT, ONEG, ONOT, OPLUS, ORECV, + OCAP, OCLEAR, OCLOSE, OIMAG, OLEN, ONEW, OPANIC, OREAL, + OCHECKNIL, OCFUNC, OIDATA, OITAB, OSPTR, + OUNSAFESTRINGDATA, OUNSAFESLICEDATA: + n.op = op + } +} + +func IsZero(n Node) bool { + switch n.Op() { + case ONIL: + return true + + case OLITERAL: + switch u := n.Val(); u.Kind() { + case constant.String: + return constant.StringVal(u) == "" + case constant.Bool: + return !constant.BoolVal(u) + default: + return constant.Sign(u) == 0 + } + + case OARRAYLIT: + n := n.(*CompLitExpr) + for _, n1 := range n.List { + if n1.Op() == OKEY { + n1 = n1.(*KeyExpr).Value + } + if !IsZero(n1) { + return false + } + } + return true + + case OSTRUCTLIT: + n := n.(*CompLitExpr) + for _, n1 := range n.List { + n1 := n1.(*StructKeyExpr) + if !IsZero(n1.Value) { + return false + } + } + return true + } + + return false +} + +// lvalue etc +func IsAddressable(n Node) bool { + switch n.Op() { + case OINDEX: + n := n.(*IndexExpr) + if n.X.Type() != nil && n.X.Type().IsArray() { + return IsAddressable(n.X) + } + if n.X.Type() != nil && n.X.Type().IsString() { + return false + } + fallthrough + case ODEREF, ODOTPTR: + return true + + case ODOT: + n := n.(*SelectorExpr) + return IsAddressable(n.X) + + case ONAME: + n := n.(*Name) + if n.Class == PFUNC { + return false + } + return true + + case OLINKSYMOFFSET: + return true + } + + return false +} + +// StaticValue analyzes n to find the earliest expression that always +// evaluates to the same value as n, which might be from an enclosing +// function. +// +// For example, given: +// +// var x int = g() +// func() { +// y := x +// *p = int(y) +// } +// +// calling StaticValue on the "int(y)" expression returns the outer +// "g()" expression. +// +// NOTE: StaticValue can return a result with a different type than +// n's type because it can traverse through OCONVNOP operations. +// TODO: consider reapplying OCONVNOP operations to the result. See https://go.dev/cl/676517. +func StaticValue(n Node) Node { + for { + switch n1 := n.(type) { + case *ConvExpr: + if n1.Op() == OCONVNOP { + n = n1.X + continue + } + case *InlinedCallExpr: + if n1.Op() == OINLCALL { + n = n1.SingleResult() + continue + } + case *ParenExpr: + n = n1.X + continue + } + + n1 := staticValue1(n) + if n1 == nil { + return n + } + n = n1 + } +} + +func staticValue1(nn Node) Node { + if nn.Op() != ONAME { + return nil + } + n := nn.(*Name).Canonical() + if n.Class != PAUTO { + return nil + } + + defn := n.Defn + if defn == nil { + return nil + } + + var rhs Node +FindRHS: + switch defn.Op() { + case OAS: + defn := defn.(*AssignStmt) + rhs = defn.Y + case OAS2: + defn := defn.(*AssignListStmt) + for i, lhs := range defn.Lhs { + if lhs == n { + rhs = defn.Rhs[i] + break FindRHS + } + } + base.FatalfAt(defn.Pos(), "%v missing from LHS of %v", n, defn) + default: + return nil + } + if rhs == nil { + base.FatalfAt(defn.Pos(), "RHS is nil: %v", defn) + } + + if Reassigned(n) { + return nil + } + + return rhs +} + +// Reassigned takes an ONAME node, walks the function in which it is +// defined, and returns a boolean indicating whether the name has any +// assignments other than its declaration. +// NB: global variables are always considered to be re-assigned. +// TODO: handle initial declaration not including an assignment and +// followed by a single assignment? +// NOTE: any changes made here should also be made in the corresponding +// code in the ReassignOracle.Init method. +func Reassigned(name *Name) bool { + if name.Op() != ONAME { + base.Fatalf("reassigned %v", name) + } + // no way to reliably check for no-reassignment of globals, assume it can be + if name.Curfn == nil { + return true + } + + if name.Addrtaken() { + return true // conservatively assume it's reassigned indirectly + } + + // TODO(mdempsky): This is inefficient and becoming increasingly + // unwieldy. Figure out a way to generalize escape analysis's + // reassignment detection for use by inlining and devirtualization. + + // isName reports whether n is a reference to name. + isName := func(x Node) bool { + if x == nil { + return false + } + n, ok := OuterValue(x).(*Name) + return ok && n.Canonical() == name + } + + var do func(n Node) bool + do = func(n Node) bool { + switch n.Op() { + case OAS: + n := n.(*AssignStmt) + if isName(n.X) && n != name.Defn { + return true + } + case OAS2, OAS2FUNC, OAS2MAPR, OAS2DOTTYPE, OAS2RECV, OSELRECV2: + n := n.(*AssignListStmt) + for _, p := range n.Lhs { + if isName(p) && n != name.Defn { + return true + } + } + case OASOP: + n := n.(*AssignOpStmt) + if isName(n.X) { + return true + } + case OADDR: + n := n.(*AddrExpr) + if isName(n.X) { + base.FatalfAt(n.Pos(), "%v not marked addrtaken", name) + } + case ORANGE: + n := n.(*RangeStmt) + if isName(n.Key) || isName(n.Value) { + return true + } + case OCLOSURE: + n := n.(*ClosureExpr) + if Any(n.Func, do) { + return true + } + } + return false + } + return Any(name.Curfn, do) +} + +// StaticCalleeName returns the ONAME/PFUNC for n, if known. +func StaticCalleeName(n Node) *Name { + switch n.Op() { + case OMETHEXPR: + n := n.(*SelectorExpr) + return MethodExprName(n) + case ONAME: + n := n.(*Name) + if n.Class == PFUNC { + return n + } + case OCLOSURE: + return n.(*ClosureExpr).Func.Nname + } + return nil +} + +// IsIntrinsicCall reports whether the compiler back end will treat the call as an intrinsic operation. +var IsIntrinsicCall = func(*CallExpr) bool { return false } + +// IsIntrinsicSym reports whether the compiler back end will treat a call to this symbol as an intrinsic operation. +var IsIntrinsicSym = func(*types.Sym) bool { return false } + +// SameSafeExpr checks whether it is safe to reuse one of l and r +// instead of computing both. SameSafeExpr assumes that l and r are +// used in the same statement or expression. In order for it to be +// safe to reuse l or r, they must: +// - be the same expression +// - not have side-effects (no function calls, no channel ops); +// however, panics are ok +// - not cause inappropriate aliasing; e.g. two string to []byte +// conversions, must result in two distinct slices +// +// The handling of OINDEXMAP is subtle. OINDEXMAP can occur both +// as an lvalue (map assignment) and an rvalue (map access). This is +// currently OK, since the only place SameSafeExpr gets used on an +// lvalue expression is for OSLICE and OAPPEND optimizations, and it +// is correct in those settings. +func SameSafeExpr(l Node, r Node) bool { + for l.Op() == OCONVNOP { + l = l.(*ConvExpr).X + } + for r.Op() == OCONVNOP { + r = r.(*ConvExpr).X + } + if l.Op() != r.Op() || !types.Identical(l.Type(), r.Type()) { + return false + } + + switch l.Op() { + case ONAME: + return l == r + + case ODOT, ODOTPTR: + l := l.(*SelectorExpr) + r := r.(*SelectorExpr) + return l.Sel != nil && r.Sel != nil && l.Sel == r.Sel && SameSafeExpr(l.X, r.X) + + case ODEREF: + l := l.(*StarExpr) + r := r.(*StarExpr) + return SameSafeExpr(l.X, r.X) + + case ONOT, OBITNOT, OPLUS, ONEG: + l := l.(*UnaryExpr) + r := r.(*UnaryExpr) + return SameSafeExpr(l.X, r.X) + + case OCONV: + l := l.(*ConvExpr) + r := r.(*ConvExpr) + // Some conversions can't be reused, such as []byte(str). + // Allow only numeric-ish types. This is a bit conservative. + return types.IsSimple[l.Type().Kind()] && SameSafeExpr(l.X, r.X) + + case OINDEX, OINDEXMAP: + l := l.(*IndexExpr) + r := r.(*IndexExpr) + return SameSafeExpr(l.X, r.X) && SameSafeExpr(l.Index, r.Index) + + case OADD, OSUB, OOR, OXOR, OMUL, OLSH, ORSH, OAND, OANDNOT, ODIV, OMOD: + l := l.(*BinaryExpr) + r := r.(*BinaryExpr) + return SameSafeExpr(l.X, r.X) && SameSafeExpr(l.Y, r.Y) + + case OLITERAL: + return constant.Compare(l.Val(), token.EQL, r.Val()) + + case ONIL: + return true + } + + return false +} + +// ShouldCheckPtr reports whether pointer checking should be enabled for +// function fn at a given level. See debugHelpFooter for defined +// levels. +func ShouldCheckPtr(fn *Func, level int) bool { + return base.Debug.Checkptr >= level && fn.Pragma&NoCheckPtr == 0 +} + +// ShouldAsanCheckPtr reports whether pointer checking should be enabled for +// function fn when -asan is enabled. +func ShouldAsanCheckPtr(fn *Func) bool { + return base.Flag.ASan && fn.Pragma&NoCheckPtr == 0 +} + +// IsReflectHeaderDataField reports whether l is an expression p.Data +// where p has type reflect.SliceHeader or reflect.StringHeader. +func IsReflectHeaderDataField(l Node) bool { + if l.Type() != types.Types[types.TUINTPTR] { + return false + } + + var tsym *types.Sym + switch l.Op() { + case ODOT: + l := l.(*SelectorExpr) + tsym = l.X.Type().Sym() + case ODOTPTR: + l := l.(*SelectorExpr) + tsym = l.X.Type().Elem().Sym() + default: + return false + } + + if tsym == nil || l.Sym().Name != "Data" || tsym.Pkg.Path != "reflect" { + return false + } + return tsym.Name == "SliceHeader" || tsym.Name == "StringHeader" +} + +func ParamNames(ft *types.Type) []Node { + args := make([]Node, ft.NumParams()) + for i, f := range ft.Params() { + args[i] = f.Nname.(*Name) + } + return args +} + +func RecvParamNames(ft *types.Type) []Node { + args := make([]Node, ft.NumRecvs()+ft.NumParams()) + for i, f := range ft.RecvParams() { + args[i] = f.Nname.(*Name) + } + return args +} + +// MethodSym returns the method symbol representing a method name +// associated with a specific receiver type. +// +// Method symbols can be used to distinguish the same method appearing +// in different method sets. For example, T.M and (*T).M have distinct +// method symbols. +// +// The returned symbol will be marked as a function. +func MethodSym(recv *types.Type, msym *types.Sym) *types.Sym { + sym := MethodSymSuffix(recv, msym, "") + sym.SetFunc(true) + return sym +} + +// MethodSymSuffix is like MethodSym, but allows attaching a +// distinguisher suffix. To avoid collisions, the suffix must not +// start with a letter, number, or period. +func MethodSymSuffix(recv *types.Type, msym *types.Sym, suffix string) *types.Sym { + if msym.IsBlank() { + base.Fatalf("blank method name") + } + + rsym := recv.Sym() + if recv.IsPtr() { + if rsym != nil { + base.Fatalf("declared pointer receiver type: %v", recv) + } + rsym = recv.Elem().Sym() + } + + // Find the package the receiver type appeared in. For + // anonymous receiver types (i.e., anonymous structs with + // embedded fields), use the "go" pseudo-package instead. + rpkg := Pkgs.Go + if rsym != nil { + rpkg = rsym.Pkg + } + + var b bytes.Buffer + if recv.IsPtr() { + // The parentheses aren't really necessary, but + // they're pretty traditional at this point. + fmt.Fprintf(&b, "(%-S)", recv) + } else { + fmt.Fprintf(&b, "%-S", recv) + } + + // A particular receiver type may have multiple non-exported + // methods with the same name. To disambiguate them, include a + // package qualifier for names that came from a different + // package than the receiver type. + if !types.IsExported(msym.Name) && msym.Pkg != rpkg { + b.WriteString(".") + b.WriteString(msym.Pkg.Prefix) + } + + b.WriteString(".") + b.WriteString(msym.Name) + b.WriteString(suffix) + return rpkg.LookupBytes(b.Bytes()) +} + +// LookupMethodSelector returns the types.Sym of the selector for a method +// named in local symbol name, as well as the types.Sym of the receiver. +// +// TODO(prattmic): this does not attempt to handle method suffixes (wrappers). +func LookupMethodSelector(pkg *types.Pkg, name string) (typ, meth *types.Sym, err error) { + typeName, methName := splitType(name) + if typeName == "" { + return nil, nil, fmt.Errorf("%s doesn't contain type split", name) + } + + if len(typeName) > 3 && typeName[:2] == "(*" && typeName[len(typeName)-1] == ')' { + // Symbol name is for a pointer receiver method. We just want + // the base type name. + typeName = typeName[2 : len(typeName)-1] + } + + typ = pkg.Lookup(typeName) + meth = pkg.Selector(methName) + return typ, meth, nil +} + +// splitType splits a local symbol name into type and method (fn). If this a +// free function, typ == "". +// +// N.B. closures and methods can be ambiguous (e.g., bar.func1). These cases +// are returned as methods. +func splitType(name string) (typ, fn string) { + // Types are split on the first dot, ignoring everything inside + // brackets (instantiation of type parameter, usually including + // "go.shape"). + bracket := 0 + for i, r := range name { + if r == '.' && bracket == 0 { + return name[:i], name[i+1:] + } + if r == '[' { + bracket++ + } + if r == ']' { + bracket-- + } + } + return "", name +} + +// MethodExprName returns the ONAME representing the method +// referenced by expression n, which must be a method selector, +// method expression, or method value. +func MethodExprName(n Node) *Name { + name, _ := MethodExprFunc(n).Nname.(*Name) + return name +} + +// MethodExprFunc is like MethodExprName, but returns the types.Field instead. +func MethodExprFunc(n Node) *types.Field { + switch n.Op() { + case ODOTMETH, OMETHEXPR, OMETHVALUE: + return n.(*SelectorExpr).Selection + } + base.Fatalf("unexpected node: %v (%v)", n, n.Op()) + panic("unreachable") +} + +// A MoveToHeapExpr takes a slice as input and moves it to the +// heap (by copying the backing store if it is not already +// on the heap). +type MoveToHeapExpr struct { + miniExpr + Slice Node + // An expression that evaluates to a *runtime._type + // that represents the slice element type. + RType Node + // If PreserveCapacity is true, the capacity of + // the resulting slice, and all of the elements in + // [len:cap], must be preserved. + // If PreserveCapacity is false, the resulting + // slice may have any capacity >= len, with any + // elements in the resulting [len:cap] range zeroed. + PreserveCapacity bool +} + +func NewMoveToHeapExpr(pos src.XPos, slice Node) *MoveToHeapExpr { + n := &MoveToHeapExpr{Slice: slice} + n.pos = pos + n.op = OMOVE2HEAP + return n +} diff --git a/go/src/cmd/compile/internal/ir/fmt.go b/go/src/cmd/compile/internal/ir/fmt.go new file mode 100644 index 0000000000000000000000000000000000000000..eb64cce47bf9410f3f40d178cb18ae2b67e9f494 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/fmt.go @@ -0,0 +1,1208 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "bytes" + "fmt" + "go/constant" + "io" + "os" + "path/filepath" + "reflect" + "strings" + + "unicode/utf8" + + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +// Op + +var OpNames = []string{ + OADDR: "&", + OADD: "+", + OADDSTR: "+", + OANDAND: "&&", + OANDNOT: "&^", + OAND: "&", + OAPPEND: "append", + OAS: "=", + OAS2: "=", + OBREAK: "break", + OCALL: "function call", // not actual syntax + OCAP: "cap", + OCASE: "case", + OCLEAR: "clear", + OCLOSE: "close", + OCOMPLEX: "complex", + OBITNOT: "^", + OCONTINUE: "continue", + OCOPY: "copy", + ODELETE: "delete", + ODEFER: "defer", + ODIV: "/", + OEQ: "==", + OFALL: "fallthrough", + OFOR: "for", + OGE: ">=", + OGOTO: "goto", + OGT: ">", + OIF: "if", + OIMAG: "imag", + OINLMARK: "inlmark", + ODEREF: "*", + OLEN: "len", + OLE: "<=", + OLSH: "<<", + OLT: "<", + OMAKE: "make", + ONEG: "-", + OMAX: "max", + OMIN: "min", + OMOD: "%", + OMUL: "*", + ONEW: "new", + ONE: "!=", + ONOT: "!", + OOROR: "||", + OOR: "|", + OPANIC: "panic", + OPLUS: "+", + OPRINTLN: "println", + OPRINT: "print", + ORANGE: "range", + OREAL: "real", + ORECV: "<-", + ORECOVER: "recover", + ORETURN: "return", + ORSH: ">>", + OSELECT: "select", + OSEND: "<-", + OSUB: "-", + OSWITCH: "switch", + OUNSAFEADD: "unsafe.Add", + OUNSAFESLICE: "unsafe.Slice", + OUNSAFESLICEDATA: "unsafe.SliceData", + OUNSAFESTRING: "unsafe.String", + OUNSAFESTRINGDATA: "unsafe.StringData", + OXOR: "^", +} + +// GoString returns the Go syntax for the Op, or else its name. +func (o Op) GoString() string { + if int(o) < len(OpNames) && OpNames[o] != "" { + return OpNames[o] + } + return o.String() +} + +// Format implements formatting for an Op. +// The valid formats are: +// +// %v Go syntax ("+", "<-", "print") +// %+v Debug syntax ("ADD", "RECV", "PRINT") +func (o Op) Format(s fmt.State, verb rune) { + switch verb { + default: + fmt.Fprintf(s, "%%!%c(Op=%d)", verb, int(o)) + case 'v': + if s.Flag('+') { + // %+v is OMUL instead of "*" + io.WriteString(s, o.String()) + return + } + io.WriteString(s, o.GoString()) + } +} + +// Node + +// fmtNode implements formatting for a Node n. +// Every Node implementation must define a Format method that calls fmtNode. +// The valid formats are: +// +// %v Go syntax +// %L Go syntax followed by " (type T)" if type is known. +// %+v Debug syntax, as in Dump. +func fmtNode(n Node, s fmt.State, verb rune) { + // %+v prints Dump. + // Otherwise we print Go syntax. + if s.Flag('+') && verb == 'v' { + dumpNode(s, n, 1) + return + } + + if verb != 'v' && verb != 'S' && verb != 'L' { + fmt.Fprintf(s, "%%!%c(*Node=%p)", verb, n) + return + } + + if n == nil { + fmt.Fprint(s, "") + return + } + + t := n.Type() + if verb == 'L' && t != nil { + if t.Kind() == types.TNIL { + fmt.Fprint(s, "nil") + } else if n.Op() == ONAME && n.Name().AutoTemp() { + fmt.Fprintf(s, "%v value", t) + } else { + fmt.Fprintf(s, "%v (type %v)", n, t) + } + return + } + + // TODO inlining produces expressions with ninits. we can't print these yet. + + if OpPrec[n.Op()] < 0 { + stmtFmt(n, s) + return + } + + exprFmt(n, s, 0) +} + +var OpPrec = []int{ + OAPPEND: 8, + OBYTES2STR: 8, + OARRAYLIT: 8, + OSLICELIT: 8, + ORUNES2STR: 8, + OCALLFUNC: 8, + OCALLINTER: 8, + OCALLMETH: 8, + OCALL: 8, + OCAP: 8, + OCLEAR: 8, + OCLOSE: 8, + OCOMPLIT: 8, + OCONVIFACE: 8, + OCONVNOP: 8, + OCONV: 8, + OCOPY: 8, + ODELETE: 8, + OGETG: 8, + OLEN: 8, + OLITERAL: 8, + OMAKESLICE: 8, + OMAKESLICECOPY: 8, + OMAKE: 8, + OMAPLIT: 8, + OMAX: 8, + OMIN: 8, + ONAME: 8, + ONEW: 8, + ONIL: 8, + ONONAME: 8, + OPANIC: 8, + OPAREN: 8, + OPRINTLN: 8, + OPRINT: 8, + ORUNESTR: 8, + OSLICE2ARR: 8, + OSLICE2ARRPTR: 8, + OSTR2BYTES: 8, + OSTR2RUNES: 8, + OSTRUCTLIT: 8, + OTYPE: 8, + OUNSAFEADD: 8, + OUNSAFESLICE: 8, + OUNSAFESLICEDATA: 8, + OUNSAFESTRING: 8, + OUNSAFESTRINGDATA: 8, + OINDEXMAP: 8, + OINDEX: 8, + OSLICE: 8, + OSLICESTR: 8, + OSLICEARR: 8, + OSLICE3: 8, + OSLICE3ARR: 8, + OSLICEHEADER: 8, + OSTRINGHEADER: 8, + ODOTINTER: 8, + ODOTMETH: 8, + ODOTPTR: 8, + ODOTTYPE2: 8, + ODOTTYPE: 8, + ODOT: 8, + OXDOT: 8, + OMETHVALUE: 8, + OMETHEXPR: 8, + OPLUS: 7, + ONOT: 7, + OBITNOT: 7, + ONEG: 7, + OADDR: 7, + ODEREF: 7, + ORECV: 7, + OMUL: 6, + ODIV: 6, + OMOD: 6, + OLSH: 6, + ORSH: 6, + OAND: 6, + OANDNOT: 6, + OADD: 5, + OSUB: 5, + OOR: 5, + OXOR: 5, + OEQ: 4, + OLT: 4, + OLE: 4, + OGE: 4, + OGT: 4, + ONE: 4, + OSEND: 3, + OANDAND: 2, + OOROR: 1, + + // Statements handled by stmtfmt + OAS: -1, + OAS2: -1, + OAS2DOTTYPE: -1, + OAS2FUNC: -1, + OAS2MAPR: -1, + OAS2RECV: -1, + OASOP: -1, + OBLOCK: -1, + OBREAK: -1, + OCASE: -1, + OCONTINUE: -1, + ODCL: -1, + ODEFER: -1, + OFALL: -1, + OFOR: -1, + OGOTO: -1, + OIF: -1, + OLABEL: -1, + OGO: -1, + ORANGE: -1, + ORETURN: -1, + OSELECT: -1, + OSWITCH: -1, + + OEND: 0, +} + +// StmtWithInit reports whether op is a statement with an explicit init list. +func StmtWithInit(op Op) bool { + switch op { + case OIF, OFOR, OSWITCH: + return true + } + return false +} + +func stmtFmt(n Node, s fmt.State) { + // NOTE(rsc): This code used to support the text-based + // which was more aggressive about printing full Go syntax + // (for example, an actual loop instead of "for loop"). + // The code is preserved for now in case we want to expand + // any of those shortenings later. Or maybe we will delete + // the code. But for now, keep it. + const exportFormat = false + + // some statements allow for an init, but at most one, + // but we may have an arbitrary number added, eg by typecheck + // and inlining. If it doesn't fit the syntax, emit an enclosing + // block starting with the init statements. + + // if we can just say "for" n->ninit; ... then do so + simpleinit := len(n.Init()) == 1 && len(n.Init()[0].Init()) == 0 && StmtWithInit(n.Op()) + + // otherwise, print the inits as separate statements + complexinit := len(n.Init()) != 0 && !simpleinit && exportFormat + + // but if it was for if/for/switch, put in an extra surrounding block to limit the scope + extrablock := complexinit && StmtWithInit(n.Op()) + + if extrablock { + fmt.Fprint(s, "{") + } + + if complexinit { + fmt.Fprintf(s, " %v; ", n.Init()) + } + + switch n.Op() { + case ODCL: + n := n.(*Decl) + fmt.Fprintf(s, "var %v %v", n.X.Sym(), n.X.Type()) + + // Don't export "v = " initializing statements, hope they're always + // preceded by the DCL which will be re-parsed and typechecked to reproduce + // the "v = " again. + case OAS: + n := n.(*AssignStmt) + if n.Def && !complexinit { + fmt.Fprintf(s, "%v := %v", n.X, n.Y) + } else { + fmt.Fprintf(s, "%v = %v", n.X, n.Y) + } + + case OASOP: + n := n.(*AssignOpStmt) + if n.IncDec { + if n.AsOp == OADD { + fmt.Fprintf(s, "%v++", n.X) + } else { + fmt.Fprintf(s, "%v--", n.X) + } + break + } + + fmt.Fprintf(s, "%v %v= %v", n.X, n.AsOp, n.Y) + + case OAS2, OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV: + n := n.(*AssignListStmt) + if n.Def && !complexinit { + fmt.Fprintf(s, "%.v := %.v", n.Lhs, n.Rhs) + } else { + fmt.Fprintf(s, "%.v = %.v", n.Lhs, n.Rhs) + } + + case OBLOCK: + n := n.(*BlockStmt) + if len(n.List) != 0 { + fmt.Fprintf(s, "%v", n.List) + } + + case ORETURN: + n := n.(*ReturnStmt) + fmt.Fprintf(s, "return %.v", n.Results) + + case OTAILCALL: + n := n.(*TailCallStmt) + fmt.Fprintf(s, "tailcall %v", n.Call) + + case OINLMARK: + n := n.(*InlineMarkStmt) + fmt.Fprintf(s, "inlmark %d", n.Index) + + case OGO: + n := n.(*GoDeferStmt) + fmt.Fprintf(s, "go %v", n.Call) + + case ODEFER: + n := n.(*GoDeferStmt) + fmt.Fprintf(s, "defer %v", n.Call) + + case OIF: + n := n.(*IfStmt) + if simpleinit { + fmt.Fprintf(s, "if %v; %v { %v }", n.Init()[0], n.Cond, n.Body) + } else { + fmt.Fprintf(s, "if %v { %v }", n.Cond, n.Body) + } + if len(n.Else) != 0 { + fmt.Fprintf(s, " else { %v }", n.Else) + } + + case OFOR: + n := n.(*ForStmt) + if !exportFormat { // TODO maybe only if FmtShort, same below + fmt.Fprintf(s, "for loop") + break + } + + fmt.Fprint(s, "for") + if n.DistinctVars { + fmt.Fprint(s, " /* distinct */") + } + if simpleinit { + fmt.Fprintf(s, " %v;", n.Init()[0]) + } else if n.Post != nil { + fmt.Fprint(s, " ;") + } + + if n.Cond != nil { + fmt.Fprintf(s, " %v", n.Cond) + } + + if n.Post != nil { + fmt.Fprintf(s, "; %v", n.Post) + } else if simpleinit { + fmt.Fprint(s, ";") + } + + fmt.Fprintf(s, " { %v }", n.Body) + + case ORANGE: + n := n.(*RangeStmt) + if !exportFormat { + fmt.Fprint(s, "for loop") + break + } + + fmt.Fprint(s, "for") + if n.Key != nil { + fmt.Fprintf(s, " %v", n.Key) + if n.Value != nil { + fmt.Fprintf(s, ", %v", n.Value) + } + fmt.Fprint(s, " =") + } + fmt.Fprintf(s, " range %v { %v }", n.X, n.Body) + if n.DistinctVars { + fmt.Fprint(s, " /* distinct vars */") + } + + case OSELECT: + n := n.(*SelectStmt) + if !exportFormat { + fmt.Fprintf(s, "%v statement", n.Op()) + break + } + fmt.Fprintf(s, "select { %v }", n.Cases) + + case OSWITCH: + n := n.(*SwitchStmt) + if !exportFormat { + fmt.Fprintf(s, "%v statement", n.Op()) + break + } + fmt.Fprintf(s, "switch") + if simpleinit { + fmt.Fprintf(s, " %v;", n.Init()[0]) + } + if n.Tag != nil { + fmt.Fprintf(s, " %v ", n.Tag) + } + fmt.Fprintf(s, " { %v }", n.Cases) + + case OCASE: + n := n.(*CaseClause) + if len(n.List) != 0 { + fmt.Fprintf(s, "case %.v", n.List) + } else { + fmt.Fprint(s, "default") + } + fmt.Fprintf(s, ": %v", n.Body) + + case OBREAK, OCONTINUE, OGOTO, OFALL: + n := n.(*BranchStmt) + if n.Label != nil { + fmt.Fprintf(s, "%v %v", n.Op(), n.Label) + } else { + fmt.Fprintf(s, "%v", n.Op()) + } + + case OLABEL: + n := n.(*LabelStmt) + fmt.Fprintf(s, "%v: ", n.Label) + } + + if extrablock { + fmt.Fprint(s, "}") + } +} + +func exprFmt(n Node, s fmt.State, prec int) { + // NOTE(rsc): This code used to support the text-based + // which was more aggressive about printing full Go syntax + // (for example, an actual loop instead of "for loop"). + // The code is preserved for now in case we want to expand + // any of those shortenings later. Or maybe we will delete + // the code. But for now, keep it. + const exportFormat = false + + for { + if n == nil { + fmt.Fprint(s, "") + return + } + + // Skip implicit operations introduced during typechecking. + switch nn := n; nn.Op() { + case OADDR: + nn := nn.(*AddrExpr) + if nn.Implicit() { + n = nn.X + continue + } + case ODEREF: + nn := nn.(*StarExpr) + if nn.Implicit() { + n = nn.X + continue + } + case OCONV, OCONVNOP, OCONVIFACE: + nn := nn.(*ConvExpr) + if nn.Implicit() { + n = nn.X + continue + } + } + + break + } + + nprec := OpPrec[n.Op()] + if n.Op() == OTYPE && n.Type() != nil && n.Type().IsPtr() { + nprec = OpPrec[ODEREF] + } + + if prec > nprec { + fmt.Fprintf(s, "(%v)", n) + return + } + + switch n.Op() { + case OPAREN: + n := n.(*ParenExpr) + fmt.Fprintf(s, "(%v)", n.X) + + case ONIL: + fmt.Fprint(s, "nil") + + case OLITERAL: + if n.Sym() != nil { + fmt.Fprint(s, n.Sym()) + return + } + + typ := n.Type() + val := n.Val() + + // Special case for rune constants. + if typ == types.RuneType || typ == types.UntypedRune { + if x, ok := constant.Uint64Val(val); ok && x <= utf8.MaxRune { + fmt.Fprintf(s, "%q", rune(x)) + return + } + } + + // Only include typ if it's neither the default nor untyped type + // for the constant value. + if k := val.Kind(); typ == types.Types[types.DefaultKinds[k]] || typ == types.UntypedTypes[k] { + fmt.Fprint(s, val) + } else { + fmt.Fprintf(s, "%v(%v)", typ, val) + } + + case ODCLFUNC: + n := n.(*Func) + if sym := n.Sym(); sym != nil { + fmt.Fprint(s, sym) + return + } + fmt.Fprintf(s, "") + + case ONAME: + n := n.(*Name) + // Special case: name used as local variable in export. + // _ becomes ~b%d internally; print as _ for export + if !exportFormat && n.Sym() != nil && n.Sym().Name[0] == '~' && n.Sym().Name[1] == 'b' { + fmt.Fprint(s, "_") + return + } + fallthrough + case ONONAME: + fmt.Fprint(s, n.Sym()) + + case OLINKSYMOFFSET: + n := n.(*LinksymOffsetExpr) + fmt.Fprintf(s, "(%v)(%s@%d)", n.Type(), n.Linksym.Name, n.Offset_) + + case OTYPE: + if n.Type() == nil && n.Sym() != nil { + fmt.Fprint(s, n.Sym()) + return + } + fmt.Fprintf(s, "%v", n.Type()) + + case OCLOSURE: + n := n.(*ClosureExpr) + if !exportFormat { + fmt.Fprint(s, "func literal") + return + } + fmt.Fprintf(s, "%v { %v }", n.Type(), n.Func.Body) + + case OPTRLIT: + n := n.(*AddrExpr) + fmt.Fprintf(s, "&%v", n.X) + + case OCOMPLIT, OSTRUCTLIT, OARRAYLIT, OSLICELIT, OMAPLIT: + n := n.(*CompLitExpr) + if n.Implicit() { + fmt.Fprintf(s, "... argument") + return + } + fmt.Fprintf(s, "%v{%s}", n.Type(), ellipsisIf(len(n.List) != 0)) + + case OKEY: + n := n.(*KeyExpr) + if n.Key != nil && n.Value != nil { + fmt.Fprintf(s, "%v:%v", n.Key, n.Value) + return + } + + if n.Key == nil && n.Value != nil { + fmt.Fprintf(s, ":%v", n.Value) + return + } + if n.Key != nil && n.Value == nil { + fmt.Fprintf(s, "%v:", n.Key) + return + } + fmt.Fprint(s, ":") + + case OSTRUCTKEY: + n := n.(*StructKeyExpr) + fmt.Fprintf(s, "%v:%v", n.Field, n.Value) + + case OXDOT, ODOT, ODOTPTR, ODOTINTER, ODOTMETH, OMETHVALUE, OMETHEXPR: + n := n.(*SelectorExpr) + exprFmt(n.X, s, nprec) + if n.Sel == nil { + fmt.Fprint(s, ".") + return + } + fmt.Fprintf(s, ".%s", n.Sel.Name) + + case ODOTTYPE, ODOTTYPE2: + n := n.(*TypeAssertExpr) + exprFmt(n.X, s, nprec) + fmt.Fprintf(s, ".(%v)", n.Type()) + + case OINDEX, OINDEXMAP: + n := n.(*IndexExpr) + exprFmt(n.X, s, nprec) + fmt.Fprintf(s, "[%v]", n.Index) + + case OSLICE, OSLICESTR, OSLICEARR, OSLICE3, OSLICE3ARR: + n := n.(*SliceExpr) + exprFmt(n.X, s, nprec) + fmt.Fprint(s, "[") + if n.Low != nil { + fmt.Fprint(s, n.Low) + } + fmt.Fprint(s, ":") + if n.High != nil { + fmt.Fprint(s, n.High) + } + if n.Op().IsSlice3() { + fmt.Fprint(s, ":") + if n.Max != nil { + fmt.Fprint(s, n.Max) + } + } + fmt.Fprint(s, "]") + + case OSLICEHEADER: + n := n.(*SliceHeaderExpr) + fmt.Fprintf(s, "sliceheader{%v,%v,%v}", n.Ptr, n.Len, n.Cap) + + case OCOMPLEX, OCOPY, OUNSAFEADD, OUNSAFESLICE: + n := n.(*BinaryExpr) + fmt.Fprintf(s, "%v(%v, %v)", n.Op(), n.X, n.Y) + + case OCONV, + OCONVIFACE, + OCONVNOP, + OBYTES2STR, + ORUNES2STR, + OSTR2BYTES, + OSTR2RUNES, + ORUNESTR, + OSLICE2ARR, + OSLICE2ARRPTR: + n := n.(*ConvExpr) + if n.Type() == nil || n.Type().Sym() == nil { + fmt.Fprintf(s, "(%v)", n.Type()) + } else { + fmt.Fprintf(s, "%v", n.Type()) + } + fmt.Fprintf(s, "(%v)", n.X) + + case OREAL, + OIMAG, + OCAP, + OCLEAR, + OCLOSE, + OLEN, + ONEW, + OPANIC: + n := n.(*UnaryExpr) + fmt.Fprintf(s, "%v(%v)", n.Op(), n.X) + + case OAPPEND, + ODELETE, + OMAKE, + OMAX, + OMIN, + ORECOVER, + OPRINT, + OPRINTLN: + n := n.(*CallExpr) + if n.IsDDD { + fmt.Fprintf(s, "%v(%.v...)", n.Op(), n.Args) + return + } + fmt.Fprintf(s, "%v(%.v)", n.Op(), n.Args) + + case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG: + n := n.(*CallExpr) + exprFmt(n.Fun, s, nprec) + if n.IsDDD { + fmt.Fprintf(s, "(%.v...)", n.Args) + return + } + fmt.Fprintf(s, "(%.v)", n.Args) + + case OINLCALL: + n := n.(*InlinedCallExpr) + // TODO(mdempsky): Print Init and/or Body? + if len(n.ReturnVars) == 1 { + fmt.Fprintf(s, "%v", n.ReturnVars[0]) + return + } + fmt.Fprintf(s, "(.%v)", n.ReturnVars) + + case OMAKEMAP, OMAKECHAN, OMAKESLICE: + n := n.(*MakeExpr) + if n.Cap != nil { + fmt.Fprintf(s, "make(%v, %v, %v)", n.Type(), n.Len, n.Cap) + return + } + if n.Len != nil && (n.Op() == OMAKESLICE || !n.Len.Type().IsUntyped()) { + fmt.Fprintf(s, "make(%v, %v)", n.Type(), n.Len) + return + } + fmt.Fprintf(s, "make(%v)", n.Type()) + + case OMAKESLICECOPY: + n := n.(*MakeExpr) + fmt.Fprintf(s, "makeslicecopy(%v, %v, %v)", n.Type(), n.Len, n.Cap) + + case OPLUS, ONEG, OBITNOT, ONOT, ORECV: + // Unary + n := n.(*UnaryExpr) + fmt.Fprintf(s, "%v", n.Op()) + if n.X != nil && n.X.Op() == n.Op() { + fmt.Fprint(s, " ") + } + exprFmt(n.X, s, nprec+1) + + case OADDR: + n := n.(*AddrExpr) + fmt.Fprintf(s, "%v", n.Op()) + if n.X != nil && n.X.Op() == n.Op() { + fmt.Fprint(s, " ") + } + exprFmt(n.X, s, nprec+1) + + case ODEREF: + n := n.(*StarExpr) + fmt.Fprintf(s, "%v", n.Op()) + exprFmt(n.X, s, nprec+1) + + // Binary + case OADD, + OAND, + OANDNOT, + ODIV, + OEQ, + OGE, + OGT, + OLE, + OLT, + OLSH, + OMOD, + OMUL, + ONE, + OOR, + ORSH, + OSUB, + OXOR: + n := n.(*BinaryExpr) + exprFmt(n.X, s, nprec) + fmt.Fprintf(s, " %v ", n.Op()) + exprFmt(n.Y, s, nprec+1) + + case OANDAND, + OOROR: + n := n.(*LogicalExpr) + exprFmt(n.X, s, nprec) + fmt.Fprintf(s, " %v ", n.Op()) + exprFmt(n.Y, s, nprec+1) + + case OSEND: + n := n.(*SendStmt) + exprFmt(n.Chan, s, nprec) + fmt.Fprintf(s, " <- ") + exprFmt(n.Value, s, nprec+1) + + case OADDSTR: + n := n.(*AddStringExpr) + for i, n1 := range n.List { + if i != 0 { + fmt.Fprint(s, " + ") + } + exprFmt(n1, s, nprec) + } + default: + fmt.Fprintf(s, "", n.Op()) + } +} + +func ellipsisIf(b bool) string { + if b { + return "..." + } + return "" +} + +// Nodes + +// Format implements formatting for a Nodes. +// The valid formats are: +// +// %v Go syntax, semicolon-separated +// %.v Go syntax, comma-separated +// %+v Debug syntax, as in DumpList. +func (l Nodes) Format(s fmt.State, verb rune) { + if s.Flag('+') && verb == 'v' { + // %+v is DumpList output + dumpNodes(s, l, 1) + return + } + + if verb != 'v' { + fmt.Fprintf(s, "%%!%c(Nodes)", verb) + return + } + + sep := "; " + if _, ok := s.Precision(); ok { // %.v is expr list + sep = ", " + } + + for i, n := range l { + fmt.Fprint(s, n) + if i+1 < len(l) { + fmt.Fprint(s, sep) + } + } +} + +// Dump + +// Dump prints the message s followed by a debug dump of n. +func Dump(s string, n Node) { + fmt.Printf("%s%+v\n", s, n) +} + +// DumpList prints the message s followed by a debug dump of each node in the list. +func DumpList(s string, list Nodes) { + var buf bytes.Buffer + FDumpList(&buf, s, list) + os.Stdout.Write(buf.Bytes()) +} + +// FDumpList prints to w the message s followed by a debug dump of each node in the list. +func FDumpList(w io.Writer, s string, list Nodes) { + io.WriteString(w, s) + dumpNodes(w, list, 1) + io.WriteString(w, "\n") +} + +// indent prints indentation to w. +func indent(w io.Writer, depth int) { + fmt.Fprint(w, "\n") + for i := 0; i < depth; i++ { + fmt.Fprint(w, ". ") + } +} + +// EscFmt is set by the escape analysis code to add escape analysis details to the node print. +var EscFmt func(n Node) string + +// dumpNodeHeader prints the debug-format node header line to w. +func dumpNodeHeader(w io.Writer, n Node) { + // Useful to see which nodes in an AST printout are actually identical + if base.Debug.DumpPtrs != 0 { + fmt.Fprintf(w, " p(%p)", n) + } + + if base.Debug.DumpPtrs != 0 && n.Name() != nil && n.Name().Defn != nil { + // Useful to see where Defn is set and what node it points to + fmt.Fprintf(w, " defn(%p)", n.Name().Defn) + } + + if base.Debug.DumpPtrs != 0 && n.Name() != nil && n.Name().Curfn != nil { + // Useful to see where Defn is set and what node it points to + fmt.Fprintf(w, " curfn(%p)", n.Name().Curfn) + } + if base.Debug.DumpPtrs != 0 && n.Name() != nil && n.Name().Outer != nil { + // Useful to see where Defn is set and what node it points to + fmt.Fprintf(w, " outer(%p)", n.Name().Outer) + } + + if EscFmt != nil { + if esc := EscFmt(n); esc != "" { + fmt.Fprintf(w, " %s", esc) + } + } + + if n.Sym() != nil && n.Op() != ONAME && n.Op() != ONONAME && n.Op() != OTYPE { + fmt.Fprintf(w, " %+v", n.Sym()) + } + + // Print Node-specific fields of basic type in header line. + v := reflect.ValueOf(n).Elem() + t := v.Type() + nf := t.NumField() + for i := 0; i < nf; i++ { + tf := t.Field(i) + if tf.PkgPath != "" { + // skip unexported field - Interface will fail + continue + } + k := tf.Type.Kind() + if reflect.Bool <= k && k <= reflect.Complex128 { + name := strings.TrimSuffix(tf.Name, "_") + vf := v.Field(i) + vfi := vf.Interface() + if name == "Offset" && vfi == types.BADWIDTH || name != "Offset" && vf.IsZero() { + continue + } + if vfi == true { + fmt.Fprintf(w, " %s", name) + } else { + fmt.Fprintf(w, " %s:%+v", name, vf.Interface()) + } + } + } + + // Print Node-specific booleans by looking for methods. + // Different v, t from above - want *Struct not Struct, for methods. + v = reflect.ValueOf(n) + t = v.Type() + nm := t.NumMethod() + for i := 0; i < nm; i++ { + tm := t.Method(i) + if tm.PkgPath != "" { + // skip unexported method - call will fail + continue + } + m := v.Method(i) + mt := m.Type() + if mt.NumIn() == 0 && mt.NumOut() == 1 && mt.Out(0).Kind() == reflect.Bool { + // TODO(rsc): Remove the func/defer/recover wrapping, + // which is guarding against panics in miniExpr, + // once we get down to the simpler state in which + // nodes have no getter methods that aren't allowed to be called. + func() { + defer func() { recover() }() + if m.Call(nil)[0].Bool() { + name := strings.TrimSuffix(tm.Name, "_") + fmt.Fprintf(w, " %s", name) + } + }() + } + } + + if n.Op() == OCLOSURE { + n := n.(*ClosureExpr) + if fn := n.Func; fn != nil && fn.Nname.Sym() != nil { + fmt.Fprintf(w, " fnName(%+v)", fn.Nname.Sym()) + } + } + + if n.Type() != nil { + if n.Op() == OTYPE { + fmt.Fprintf(w, " type") + } + fmt.Fprintf(w, " %+v", n.Type()) + } + if n.Typecheck() != 0 { + fmt.Fprintf(w, " tc(%d)", n.Typecheck()) + } + + if n.Pos().IsKnown() { + fmt.Fprint(w, " # ") + switch n.Pos().IsStmt() { + case src.PosNotStmt: + fmt.Fprint(w, "_") // "-" would be confusing + case src.PosIsStmt: + fmt.Fprint(w, "+") + } + sep := "" + base.Ctxt.AllPos(n.Pos(), func(pos src.Pos) { + fmt.Fprint(w, sep) + sep = " " + // TODO(mdempsky): Print line pragma details too. + file := filepath.Base(pos.Filename()) + // Note: this output will be parsed by ssa/html.go:(*HTMLWriter).WriteAST. Keep in sync. + fmt.Fprintf(w, "%s:%d:%d", file, pos.Line(), pos.Col()) + }) + } +} + +func dumpNode(w io.Writer, n Node, depth int) { + indent(w, depth) + if depth > 40 { + fmt.Fprint(w, "...") + return + } + + if n == nil { + fmt.Fprint(w, "NilIrNode") + return + } + + if len(n.Init()) != 0 { + fmt.Fprintf(w, "%+v-init", n.Op()) + dumpNodes(w, n.Init(), depth+1) + indent(w, depth) + } + + switch n.Op() { + default: + fmt.Fprintf(w, "%+v", n.Op()) + dumpNodeHeader(w, n) + + case OLITERAL: + fmt.Fprintf(w, "%+v-%v", n.Op(), n.Val()) + dumpNodeHeader(w, n) + return + + case ONAME, ONONAME: + if n.Sym() != nil { + fmt.Fprintf(w, "%+v-%+v", n.Op(), n.Sym()) + } else { + fmt.Fprintf(w, "%+v", n.Op()) + } + dumpNodeHeader(w, n) + return + + case OLINKSYMOFFSET: + n := n.(*LinksymOffsetExpr) + fmt.Fprintf(w, "%+v-%v", n.Op(), n.Linksym) + // Offset is almost always 0, so only print when it's interesting. + if n.Offset_ != 0 { + fmt.Fprintf(w, "%+v", n.Offset_) + } + dumpNodeHeader(w, n) + + case OASOP: + n := n.(*AssignOpStmt) + fmt.Fprintf(w, "%+v-%+v", n.Op(), n.AsOp) + dumpNodeHeader(w, n) + + case OTYPE: + fmt.Fprintf(w, "%+v %+v", n.Op(), n.Sym()) + dumpNodeHeader(w, n) + return + + case OCLOSURE: + fmt.Fprintf(w, "%+v", n.Op()) + dumpNodeHeader(w, n) + + case ODCLFUNC: + // Func has many fields we don't want to print. + // Bypass reflection and just print what we want. + n := n.(*Func) + fmt.Fprintf(w, "%+v", n.Op()) + dumpNodeHeader(w, n) + fn := n + if len(fn.Dcl) > 0 { + indent(w, depth) + fmt.Fprintf(w, "%+v-Dcl", n.Op()) + for _, dcl := range n.Dcl { + dumpNode(w, dcl, depth+1) + } + } + if len(fn.ClosureVars) > 0 { + indent(w, depth) + fmt.Fprintf(w, "%+v-ClosureVars", n.Op()) + for _, cv := range fn.ClosureVars { + dumpNode(w, cv, depth+1) + } + } + if len(fn.Body) > 0 { + indent(w, depth) + fmt.Fprintf(w, "%+v-body", n.Op()) + dumpNodes(w, fn.Body, depth+1) + } + return + } + + v := reflect.ValueOf(n).Elem() + t := reflect.TypeOf(n).Elem() + nf := t.NumField() + for i := 0; i < nf; i++ { + tf := t.Field(i) + vf := v.Field(i) + if tf.PkgPath != "" { + // skip unexported field - Interface will fail + continue + } + switch tf.Type.Kind() { + case reflect.Interface, reflect.Ptr, reflect.Slice: + if vf.IsNil() { + continue + } + } + name := strings.TrimSuffix(tf.Name, "_") + // Do not bother with field name header lines for the + // most common positional arguments: unary, binary expr, + // index expr, send stmt, go and defer call expression. + switch name { + case "X", "Y", "Index", "Chan", "Value", "Call": + name = "" + } + switch val := vf.Interface().(type) { + case Node: + if name != "" { + indent(w, depth) + fmt.Fprintf(w, "%+v-%s", n.Op(), name) + } + dumpNode(w, val, depth+1) + case Nodes: + if len(val) == 0 { + continue + } + if name != "" { + indent(w, depth) + fmt.Fprintf(w, "%+v-%s", n.Op(), name) + } + dumpNodes(w, val, depth+1) + default: + if vf.Kind() == reflect.Slice && vf.Type().Elem().Implements(nodeType) { + if vf.Len() == 0 { + continue + } + if name != "" { + indent(w, depth) + fmt.Fprintf(w, "%+v-%s", n.Op(), name) + } + for i, n := 0, vf.Len(); i < n; i++ { + dumpNode(w, vf.Index(i).Interface().(Node), depth+1) + } + } + } + } +} + +var nodeType = reflect.TypeFor[Node]() + +func dumpNodes(w io.Writer, list Nodes, depth int) { + if len(list) == 0 { + fmt.Fprintf(w, " ") + return + } + + for _, n := range list { + dumpNode(w, n, depth) + } +} diff --git a/go/src/cmd/compile/internal/ir/func.go b/go/src/cmd/compile/internal/ir/func.go new file mode 100644 index 0000000000000000000000000000000000000000..e027fe829088c2219af260de95b64d9db1f07fcc --- /dev/null +++ b/go/src/cmd/compile/internal/ir/func.go @@ -0,0 +1,644 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" + "fmt" + "strings" + "unicode/utf8" +) + +// A Func corresponds to a single function in a Go program +// (and vice versa: each function is denoted by exactly one *Func). +// +// There are multiple nodes that represent a Func in the IR. +// +// The ONAME node (Func.Nname) is used for plain references to it. +// The ODCLFUNC node (the Func itself) is used for its declaration code. +// The OCLOSURE node (Func.OClosure) is used for a reference to a +// function literal. +// +// An imported function will have an ONAME node which points to a Func +// with an empty body. +// A declared function or method has an ODCLFUNC (the Func itself) and an ONAME. +// A function literal is represented directly by an OCLOSURE, but it also +// has an ODCLFUNC (and a matching ONAME) representing the compiled +// underlying form of the closure, which accesses the captured variables +// using a special data structure passed in a register. +// +// A method declaration is represented like functions, except f.Sym +// will be the qualified method name (e.g., "T.m"). +// +// A method expression (T.M) is represented as an OMETHEXPR node, +// in which n.Left and n.Right point to the type and method, respectively. +// Each distinct mention of a method expression in the source code +// constructs a fresh node. +// +// A method value (t.M) is represented by ODOTMETH/ODOTINTER +// when it is called directly and by OMETHVALUE otherwise. +// These are like method expressions, except that for ODOTMETH/ODOTINTER, +// the method name is stored in Sym instead of Right. +// Each OMETHVALUE ends up being implemented as a new +// function, a bit like a closure, with its own ODCLFUNC. +// The OMETHVALUE uses n.Func to record the linkage to +// the generated ODCLFUNC, but there is no +// pointer from the Func back to the OMETHVALUE. +type Func struct { + // if you add or remove a field, don't forget to update sizeof_test.go + + miniNode + Body Nodes + + Nname *Name // ONAME node + OClosure *ClosureExpr // OCLOSURE node + + // ONAME nodes for all params/locals for this func/closure, does NOT + // include closurevars until transforming closures during walk. + // Names must be listed PPARAMs, PPARAMOUTs, then PAUTOs, + // with PPARAMs and PPARAMOUTs in order corresponding to the function signature. + // Anonymous and blank params are declared as ~pNN (for PPARAMs) and ~rNN (for PPARAMOUTs). + Dcl []*Name + + // ClosureVars lists the free variables that are used within a + // function literal, but formally declared in an enclosing + // function. The variables in this slice are the closure function's + // own copy of the variables, which are used within its function + // body. They will also each have IsClosureVar set, and will have + // Byval set if they're captured by value. + ClosureVars []*Name + + // Enclosed functions that need to be compiled. + // Populated during walk. + Closures []*Func + + // Parent of a closure + ClosureParent *Func + + // Parents records the parent scope of each scope within a + // function. The root scope (0) has no parent, so the i'th + // scope's parent is stored at Parents[i-1]. + Parents []ScopeID + + // Marks records scope boundary changes. + Marks []Mark + + FieldTrack map[*obj.LSym]struct{} + DebugInfo any + LSym *obj.LSym // Linker object in this function's native ABI (Func.ABI) + + Inl *Inline + + // RangeParent, if non-nil, is the first non-range body function containing + // the closure for the body of a range function. + RangeParent *Func + + // funcLitGen, rangeLitGen and goDeferGen track how many closures have been + // created in this function for function literals, range-over-func loops, + // and go/defer wrappers, respectively. Used by closureName for creating + // unique function names. + // Tracking goDeferGen separately avoids wrappers throwing off + // function literal numbering (e.g., runtime/trace_test.TestTraceSymbolize.func11). + funcLitGen int32 + rangeLitGen int32 + goDeferGen int32 + + Label int32 // largest auto-generated label in this function + + Endlineno src.XPos + WBPos src.XPos // position of first write barrier; see SetWBPos + + Pragma PragmaFlag // go:xxx function annotations + + flags bitset16 + + // ABI is a function's "definition" ABI. This is the ABI that + // this function's generated code is expecting to be called by. + // + // For most functions, this will be obj.ABIInternal. It may be + // a different ABI for functions defined in assembly or ABI wrappers. + // + // This is included in the export data and tracked across packages. + ABI obj.ABI + // ABIRefs is the set of ABIs by which this function is referenced. + // For ABIs other than this function's definition ABI, the + // compiler generates ABI wrapper functions. This is only tracked + // within a package. + ABIRefs obj.ABISet + + NumDefers int32 // number of defer calls in the function + NumReturns int32 // number of explicit returns in the function + + // NWBRCalls records the LSyms of functions called by this + // function for go:nowritebarrierrec analysis. Only filled in + // if nowritebarrierrecCheck != nil. + NWBRCalls *[]SymAndPos + + // For wrapper functions, WrappedFunc point to the original Func. + // Currently only used for go/defer wrappers. + WrappedFunc *Func + + // WasmImport is used by the //go:wasmimport directive to store info about + // a WebAssembly function import. + WasmImport *WasmImport + // WasmExport is used by the //go:wasmexport directive to store info about + // a WebAssembly function import. + WasmExport *WasmExport +} + +// WasmImport stores metadata associated with the //go:wasmimport pragma. +type WasmImport struct { + Module string + Name string +} + +// WasmExport stores metadata associated with the //go:wasmexport pragma. +type WasmExport struct { + Name string +} + +// NewFunc returns a new Func with the given name and type. +// +// fpos is the position of the "func" token, and npos is the position +// of the name identifier. +// +// TODO(mdempsky): I suspect there's no need for separate fpos and +// npos. +func NewFunc(fpos, npos src.XPos, sym *types.Sym, typ *types.Type) *Func { + name := NewNameAt(npos, sym, typ) + name.Class = PFUNC + sym.SetFunc(true) + + fn := &Func{Nname: name} + fn.pos = fpos + fn.op = ODCLFUNC + // Most functions are ABIInternal. The importer or symabis + // pass may override this. + fn.ABI = obj.ABIInternal + fn.SetTypecheck(1) + + name.Func = fn + + return fn +} + +func (f *Func) isStmt() {} + +func (n *Func) copy() Node { panic(n.no("copy")) } +func (n *Func) doChildren(do func(Node) bool) bool { return doNodes(n.Body, do) } +func (n *Func) doChildrenWithHidden(do func(Node) bool) bool { return doNodes(n.Body, do) } +func (n *Func) editChildren(edit func(Node) Node) { editNodes(n.Body, edit) } +func (n *Func) editChildrenWithHidden(edit func(Node) Node) { editNodes(n.Body, edit) } + +func (f *Func) Type() *types.Type { return f.Nname.Type() } +func (f *Func) Sym() *types.Sym { return f.Nname.Sym() } +func (f *Func) Linksym() *obj.LSym { return f.Nname.Linksym() } +func (f *Func) LinksymABI(abi obj.ABI) *obj.LSym { return f.Nname.LinksymABI(abi) } + +// An Inline holds fields used for function bodies that can be inlined. +type Inline struct { + Cost int32 // heuristic cost of inlining this function + + // Copy of Func.Dcl for use during inlining. This copy is needed + // because the function's Dcl may change from later compiler + // transformations. This field is also populated when a function + // from another package is imported and inlined. + Dcl []*Name + HaveDcl bool // whether we've loaded Dcl + + // Function properties, encoded as a string (these are used for + // making inlining decisions). See cmd/compile/internal/inline/inlheur. + Properties string + + // CanDelayResults reports whether it's safe for the inliner to delay + // initializing the result parameters until immediately before the + // "return" statement. + CanDelayResults bool +} + +// A Mark represents a scope boundary. +type Mark struct { + // Pos is the position of the token that marks the scope + // change. + Pos src.XPos + + // Scope identifies the innermost scope to the right of Pos. + Scope ScopeID +} + +// A ScopeID represents a lexical scope within a function. +type ScopeID int32 + +const ( + funcDupok = 1 << iota // duplicate definitions ok + funcWrapper // hide frame from users (elide in tracebacks, don't count as a frame for recover()) + funcABIWrapper // is an ABI wrapper (also set flagWrapper) + funcNeedctxt // function uses context register (has closure variables) + funcHasDefer // contains a defer statement + funcNilCheckDisabled // disable nil checks when compiling this function + funcInlinabilityChecked // inliner has already determined whether the function is inlinable + funcNeverReturns // function never returns (in most cases calls panic(), os.Exit(), or equivalent) + funcOpenCodedDeferDisallowed // can't do open-coded defers + funcClosureResultsLost // closure is called indirectly and we lost track of its results; used by escape analysis + funcPackageInit // compiler emitted .init func for package +) + +type SymAndPos struct { + Sym *obj.LSym // LSym of callee + Pos src.XPos // line of call +} + +func (f *Func) Dupok() bool { return f.flags&funcDupok != 0 } +func (f *Func) Wrapper() bool { return f.flags&funcWrapper != 0 } +func (f *Func) ABIWrapper() bool { return f.flags&funcABIWrapper != 0 } +func (f *Func) Needctxt() bool { return f.flags&funcNeedctxt != 0 } +func (f *Func) HasDefer() bool { return f.flags&funcHasDefer != 0 } +func (f *Func) NilCheckDisabled() bool { return f.flags&funcNilCheckDisabled != 0 } +func (f *Func) InlinabilityChecked() bool { return f.flags&funcInlinabilityChecked != 0 } +func (f *Func) NeverReturns() bool { return f.flags&funcNeverReturns != 0 } +func (f *Func) OpenCodedDeferDisallowed() bool { return f.flags&funcOpenCodedDeferDisallowed != 0 } +func (f *Func) ClosureResultsLost() bool { return f.flags&funcClosureResultsLost != 0 } +func (f *Func) IsPackageInit() bool { return f.flags&funcPackageInit != 0 } + +func (f *Func) SetDupok(b bool) { f.flags.set(funcDupok, b) } +func (f *Func) SetWrapper(b bool) { f.flags.set(funcWrapper, b) } +func (f *Func) SetABIWrapper(b bool) { f.flags.set(funcABIWrapper, b) } +func (f *Func) SetNeedctxt(b bool) { f.flags.set(funcNeedctxt, b) } +func (f *Func) SetHasDefer(b bool) { f.flags.set(funcHasDefer, b) } +func (f *Func) SetNilCheckDisabled(b bool) { f.flags.set(funcNilCheckDisabled, b) } +func (f *Func) SetInlinabilityChecked(b bool) { f.flags.set(funcInlinabilityChecked, b) } +func (f *Func) SetNeverReturns(b bool) { f.flags.set(funcNeverReturns, b) } +func (f *Func) SetOpenCodedDeferDisallowed(b bool) { f.flags.set(funcOpenCodedDeferDisallowed, b) } +func (f *Func) SetClosureResultsLost(b bool) { f.flags.set(funcClosureResultsLost, b) } +func (f *Func) SetIsPackageInit(b bool) { f.flags.set(funcPackageInit, b) } + +func (f *Func) SetWBPos(pos src.XPos) { + if base.Debug.WB != 0 { + base.WarnfAt(pos, "write barrier") + } + if !f.WBPos.IsKnown() { + f.WBPos = pos + } +} + +// IsClosure reports whether f is a function literal that captures at least one value. +func (f *Func) IsClosure() bool { + if f.OClosure == nil { + return false + } + return len(f.ClosureVars) > 0 +} + +// FuncName returns the name (without the package) of the function f. +func FuncName(f *Func) string { + if f == nil || f.Nname == nil { + return "" + } + return f.Sym().Name +} + +// PkgFuncName returns the name of the function referenced by f, with package +// prepended. +// +// This differs from the compiler's internal convention where local functions +// lack a package. This is primarily useful when the ultimate consumer of this +// is a human looking at message. +func PkgFuncName(f *Func) string { + if f == nil || f.Nname == nil { + return "" + } + s := f.Sym() + pkg := s.Pkg + + return pkg.Path + "." + s.Name +} + +// LinkFuncName returns the name of the function f, as it will appear in the +// symbol table of the final linked binary. +func LinkFuncName(f *Func) string { + if f == nil || f.Nname == nil { + return "" + } + s := f.Sym() + pkg := s.Pkg + + return objabi.PathToPrefix(pkg.Path) + "." + s.Name +} + +// ParseLinkFuncName parsers a symbol name (as returned from LinkFuncName) back +// to the package path and local symbol name. +func ParseLinkFuncName(name string) (pkg, sym string, err error) { + pkg, sym = splitPkg(name) + if pkg == "" { + return "", "", fmt.Errorf("no package path in name") + } + + pkg, err = objabi.PrefixToPath(pkg) // unescape + if err != nil { + return "", "", fmt.Errorf("malformed package path: %v", err) + } + + return pkg, sym, nil +} + +// Borrowed from x/mod. +func modPathOK(r rune) bool { + if r < utf8.RuneSelf { + return r == '-' || r == '.' || r == '_' || r == '~' || + '0' <= r && r <= '9' || + 'A' <= r && r <= 'Z' || + 'a' <= r && r <= 'z' + } + return false +} + +func escapedImportPathOK(r rune) bool { + return modPathOK(r) || r == '+' || r == '/' || r == '%' +} + +// splitPkg splits the full linker symbol name into package and local symbol +// name. +func splitPkg(name string) (pkgpath, sym string) { + // package-sym split is at first dot after last the / that comes before + // any characters illegal in a package path. + + lastSlashIdx := 0 + for i, r := range name { + // Catches cases like: + // * example.foo[sync/atomic.Uint64]. + // * example%2ecom.foo[sync/atomic.Uint64]. + // + // Note that name is still escaped; unescape occurs after splitPkg. + if !escapedImportPathOK(r) { + break + } + if r == '/' { + lastSlashIdx = i + } + } + for i := lastSlashIdx; i < len(name); i++ { + r := name[i] + if r == '.' { + return name[:i], name[i+1:] + } + } + + return "", name +} + +var CurFunc *Func + +// WithFunc invokes do with CurFunc and base.Pos set to curfn and +// curfn.Pos(), respectively, and then restores their previous values +// before returning. +func WithFunc(curfn *Func, do func()) { + oldfn, oldpos := CurFunc, base.Pos + defer func() { CurFunc, base.Pos = oldfn, oldpos }() + + CurFunc, base.Pos = curfn, curfn.Pos() + do() +} + +func FuncSymName(s *types.Sym) string { + return s.Name + "·f" +} + +// ClosureDebugRuntimeCheck applies boilerplate checks for debug flags +// and compiling runtime. +func ClosureDebugRuntimeCheck(clo *ClosureExpr) { + if base.Debug.Closure > 0 { + if clo.Esc() == EscHeap { + base.WarnfAt(clo.Pos(), "heap closure, captured vars = %v", clo.Func.ClosureVars) + } else { + base.WarnfAt(clo.Pos(), "stack closure, captured vars = %v", clo.Func.ClosureVars) + } + } + if base.Flag.CompilingRuntime && clo.Esc() == EscHeap && !clo.IsGoWrap { + base.ErrorfAt(clo.Pos(), 0, "heap-allocated closure %s, not allowed in runtime", FuncName(clo.Func)) + } +} + +// globClosgen is like Func.Closgen, but for the global scope. +var globClosgen int32 + +// closureName generates a new unique name for a closure within outerfn at pos. +func closureName(outerfn *Func, pos src.XPos, why Op) *types.Sym { + if outerfn.OClosure != nil && outerfn.OClosure.Func.RangeParent != nil { + outerfn = outerfn.OClosure.Func.RangeParent + } + pkg := types.LocalPkg + outer := "glob." + var suffix string = "." + switch why { + default: + base.FatalfAt(pos, "closureName: bad Op: %v", why) + case OCLOSURE: + if outerfn.OClosure == nil { + suffix = ".func" + } + case ORANGE: + suffix = "-range" + case OGO: + suffix = ".gowrap" + case ODEFER: + suffix = ".deferwrap" + } + gen := &globClosgen + + // There may be multiple functions named "_". In those + // cases, we can't use their individual Closgens as it + // would lead to name clashes. + if !IsBlank(outerfn.Nname) { + pkg = outerfn.Sym().Pkg + outer = FuncName(outerfn) + + switch why { + case OCLOSURE: + gen = &outerfn.funcLitGen + case ORANGE: + gen = &outerfn.rangeLitGen + default: + gen = &outerfn.goDeferGen + } + } + + // If this closure was created due to inlining, then incorporate any + // inlined functions' names into the closure's linker symbol name + // too (#60324). + if inlIndex := base.Ctxt.InnermostPos(pos).Base().InliningIndex(); inlIndex >= 0 { + names := []string{outer} + base.Ctxt.InlTree.AllParents(inlIndex, func(call obj.InlinedCall) { + names = append(names, call.Name) + }) + outer = strings.Join(names, ".") + } + + *gen++ + return pkg.Lookup(fmt.Sprintf("%s%s%d", outer, suffix, *gen)) +} + +// NewClosureFunc creates a new Func to represent a function literal +// with the given type. +// +// fpos the position used for the underlying ODCLFUNC and ONAME, +// whereas cpos is the position used for the OCLOSURE. They're +// separate because in the presence of inlining, the OCLOSURE node +// should have an inline-adjusted position, whereas the ODCLFUNC and +// ONAME must not. +// +// outerfn is the enclosing function. The returned function is +// appending to pkg.Funcs. +// +// why is the reason we're generating this Func. It can be OCLOSURE +// (for a normal function literal) or OGO or ODEFER (for wrapping a +// call expression that has parameters or results). +func NewClosureFunc(fpos, cpos src.XPos, why Op, typ *types.Type, outerfn *Func, pkg *Package) *Func { + if outerfn == nil { + base.FatalfAt(fpos, "outerfn is nil") + } + + fn := NewFunc(fpos, fpos, closureName(outerfn, cpos, why), typ) + fn.SetDupok(outerfn.Dupok()) // if the outer function is dupok, so is the closure + + clo := &ClosureExpr{Func: fn} + clo.op = OCLOSURE + clo.pos = cpos + clo.SetType(typ) + clo.SetTypecheck(1) + if why == ORANGE { + clo.Func.RangeParent = outerfn + if outerfn.OClosure != nil && outerfn.OClosure.Func.RangeParent != nil { + clo.Func.RangeParent = outerfn.OClosure.Func.RangeParent + } + } + fn.OClosure = clo + + fn.Nname.Defn = fn + pkg.Funcs = append(pkg.Funcs, fn) + fn.ClosureParent = outerfn + + return fn +} + +// IsFuncPCIntrinsic returns whether n is a direct call of internal/abi.FuncPCABIxxx functions. +func IsFuncPCIntrinsic(n *CallExpr) bool { + if n.Op() != OCALLFUNC || n.Fun.Op() != ONAME { + return false + } + fn := n.Fun.(*Name).Sym() + return (fn.Name == "FuncPCABI0" || fn.Name == "FuncPCABIInternal") && + fn.Pkg.Path == "internal/abi" +} + +// IsIfaceOfFunc inspects whether n is an interface conversion from a direct +// reference of a func. If so, it returns referenced Func; otherwise nil. +// +// This is only usable before walk.walkConvertInterface, which converts to an +// OMAKEFACE. +func IsIfaceOfFunc(n Node) *Func { + if n, ok := n.(*ConvExpr); ok && n.Op() == OCONVIFACE { + if name, ok := n.X.(*Name); ok && name.Op() == ONAME && name.Class == PFUNC { + return name.Func + } + } + return nil +} + +// FuncPC returns a uintptr-typed expression that evaluates to the PC of a +// function as uintptr, as returned by internal/abi.FuncPC{ABI0,ABIInternal}. +// +// n should be a Node of an interface type, as is passed to +// internal/abi.FuncPC{ABI0,ABIInternal}. +// +// TODO(prattmic): Since n is simply an interface{} there is no assertion that +// it is actually a function at all. Perhaps we should emit a runtime type +// assertion? +func FuncPC(pos src.XPos, n Node, wantABI obj.ABI) Node { + if !n.Type().IsInterface() { + base.ErrorfAt(pos, 0, "internal/abi.FuncPC%s expects an interface value, got %v", wantABI, n.Type()) + } + + if fn := IsIfaceOfFunc(n); fn != nil { + name := fn.Nname + abi := fn.ABI + if abi != wantABI { + base.ErrorfAt(pos, 0, "internal/abi.FuncPC%s expects an %v function, %s is defined as %v", wantABI, wantABI, name.Sym().Name, abi) + } + var e Node = NewLinksymExpr(pos, name.LinksymABI(abi), types.Types[types.TUINTPTR]) + e = NewAddrExpr(pos, e) + e.SetType(types.Types[types.TUINTPTR].PtrTo()) + e = NewConvExpr(pos, OCONVNOP, types.Types[types.TUINTPTR], e) + e.SetTypecheck(1) + return e + } + // fn is not a defined function. It must be ABIInternal. + // Read the address from func value, i.e. *(*uintptr)(idata(fn)). + if wantABI != obj.ABIInternal { + base.ErrorfAt(pos, 0, "internal/abi.FuncPC%s does not accept func expression, which is ABIInternal", wantABI) + } + var e Node = NewUnaryExpr(pos, OIDATA, n) + e.SetType(types.Types[types.TUINTPTR].PtrTo()) + e.SetTypecheck(1) + e = NewStarExpr(pos, e) + e.SetType(types.Types[types.TUINTPTR]) + e.SetTypecheck(1) + return e +} + +// DeclareParams creates Names for all of the parameters in fn's +// signature and adds them to fn.Dcl. +// +// If setNname is true, then it also sets types.Field.Nname for each +// parameter. +func (fn *Func) DeclareParams(setNname bool) { + if fn.Dcl != nil { + base.FatalfAt(fn.Pos(), "%v already has Dcl", fn) + } + + declareParams := func(params []*types.Field, ctxt Class, prefix string, offset int) { + for i, param := range params { + sym := param.Sym + if sym == nil || sym.IsBlank() { + sym = fn.Sym().Pkg.LookupNum(prefix, i) + } + + name := NewNameAt(param.Pos, sym, param.Type) + name.Class = ctxt + name.Curfn = fn + fn.Dcl[offset+i] = name + + if setNname { + param.Nname = name + } + } + } + + sig := fn.Type() + params := sig.RecvParams() + results := sig.Results() + + fn.Dcl = make([]*Name, len(params)+len(results)) + declareParams(params, PPARAM, "~p", 0) + declareParams(results, PPARAMOUT, "~r", len(params)) +} + +// ContainsClosure reports whether c is a closure contained within f. +func ContainsClosure(f, c *Func) bool { + // Common cases. + if f == c || c.OClosure == nil { + return false + } + + for p := c.ClosureParent; p != nil; p = p.ClosureParent { + if p == f { + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ir/func_test.go b/go/src/cmd/compile/internal/ir/func_test.go new file mode 100644 index 0000000000000000000000000000000000000000..5b40c02dc4f2ad81fecf354380b008dc6f5949a0 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/func_test.go @@ -0,0 +1,82 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "testing" +) + +func TestSplitPkg(t *testing.T) { + tests := []struct { + in string + pkg string + sym string + }{ + { + in: "foo.Bar", + pkg: "foo", + sym: "Bar", + }, + { + in: "foo/bar.Baz", + pkg: "foo/bar", + sym: "Baz", + }, + { + in: "memeqbody", + pkg: "", + sym: "memeqbody", + }, + { + in: `example%2ecom.Bar`, + pkg: `example%2ecom`, + sym: "Bar", + }, + { + // Not a real generated symbol name, but easier to catch the general parameter form. + in: `foo.Bar[sync/atomic.Uint64]`, + pkg: `foo`, + sym: "Bar[sync/atomic.Uint64]", + }, + { + in: `example%2ecom.Bar[sync/atomic.Uint64]`, + pkg: `example%2ecom`, + sym: "Bar[sync/atomic.Uint64]", + }, + { + in: `gopkg.in/yaml%2ev3.Bar[sync/atomic.Uint64]`, + pkg: `gopkg.in/yaml%2ev3`, + sym: "Bar[sync/atomic.Uint64]", + }, + { + // This one is a real symbol name. + in: `foo.Bar[go.shape.struct { sync/atomic._ sync/atomic.noCopy; sync/atomic._ sync/atomic.align64; sync/atomic.v uint64 }]`, + pkg: `foo`, + sym: "Bar[go.shape.struct { sync/atomic._ sync/atomic.noCopy; sync/atomic._ sync/atomic.align64; sync/atomic.v uint64 }]", + }, + { + in: `example%2ecom.Bar[go.shape.struct { sync/atomic._ sync/atomic.noCopy; sync/atomic._ sync/atomic.align64; sync/atomic.v uint64 }]`, + pkg: `example%2ecom`, + sym: "Bar[go.shape.struct { sync/atomic._ sync/atomic.noCopy; sync/atomic._ sync/atomic.align64; sync/atomic.v uint64 }]", + }, + { + in: `gopkg.in/yaml%2ev3.Bar[go.shape.struct { sync/atomic._ sync/atomic.noCopy; sync/atomic._ sync/atomic.align64; sync/atomic.v uint64 }]`, + pkg: `gopkg.in/yaml%2ev3`, + sym: "Bar[go.shape.struct { sync/atomic._ sync/atomic.noCopy; sync/atomic._ sync/atomic.align64; sync/atomic.v uint64 }]", + }, + } + + for _, tc := range tests { + t.Run(tc.in, func(t *testing.T) { + pkg, sym := splitPkg(tc.in) + if pkg != tc.pkg { + t.Errorf("splitPkg(%q) got pkg %q want %q", tc.in, pkg, tc.pkg) + } + if sym != tc.sym { + t.Errorf("splitPkg(%q) got sym %q want %q", tc.in, sym, tc.sym) + } + }) + } +} diff --git a/go/src/cmd/compile/internal/ir/ir.go b/go/src/cmd/compile/internal/ir/ir.go new file mode 100644 index 0000000000000000000000000000000000000000..82224ca2ed8350660cb412acb7e483e27e073ff3 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/ir.go @@ -0,0 +1,5 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir diff --git a/go/src/cmd/compile/internal/ir/mini.go b/go/src/cmd/compile/internal/ir/mini.go new file mode 100644 index 0000000000000000000000000000000000000000..6c91560e526441f3cd27def3fb3e06acff065185 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/mini.go @@ -0,0 +1,77 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:generate go run mknode.go + +package ir + +import ( + "cmd/compile/internal/types" + "cmd/internal/src" + "fmt" + "go/constant" +) + +// A miniNode is a minimal node implementation, +// meant to be embedded as the first field in a larger node implementation, +// at a cost of 12 bytes. +// +// A miniNode is NOT a valid Node by itself: the embedding struct +// must at the least provide: +// +// func (n *MyNode) String() string { return fmt.Sprint(n) } +// func (n *MyNode) rawCopy() Node { c := *n; return &c } +// func (n *MyNode) Format(s fmt.State, verb rune) { FmtNode(n, s, verb) } +// +// The embedding struct should also fill in n.op in its constructor, +// for more useful panic messages when invalid methods are called, +// instead of implementing Op itself. +type miniNode struct { + pos src.XPos + op Op + bits bitset8 + esc uint16 +} + +// op can be read, but not written. +// An embedding implementation can provide a SetOp if desired. +// (The panicking SetOp is with the other panics below.) +func (n *miniNode) Op() Op { return n.op } +func (n *miniNode) Pos() src.XPos { return n.pos } +func (n *miniNode) SetPos(x src.XPos) { n.pos = x } +func (n *miniNode) Esc() uint16 { return n.esc } +func (n *miniNode) SetEsc(x uint16) { n.esc = x } + +const ( + miniTypecheckShift = 0 + miniWalked = 1 << 2 // to prevent/catch re-walking +) + +func (n *miniNode) Typecheck() uint8 { return n.bits.get2(miniTypecheckShift) } +func (n *miniNode) SetTypecheck(x uint8) { + if x > 2 { + panic(fmt.Sprintf("cannot SetTypecheck %d", x)) + } + n.bits.set2(miniTypecheckShift, x) +} + +func (n *miniNode) Walked() bool { return n.bits&miniWalked != 0 } +func (n *miniNode) SetWalked(x bool) { n.bits.set(miniWalked, x) } + +// Empty, immutable graph structure. + +func (n *miniNode) Init() Nodes { return Nodes{} } + +// Additional functionality unavailable. + +func (n *miniNode) no(name string) string { return "cannot " + name + " on " + n.op.String() } + +func (n *miniNode) Type() *types.Type { return nil } +func (n *miniNode) SetType(*types.Type) { panic(n.no("SetType")) } +func (n *miniNode) Name() *Name { return nil } +func (n *miniNode) Sym() *types.Sym { return nil } +func (n *miniNode) Val() constant.Value { panic(n.no("Val")) } +func (n *miniNode) SetVal(v constant.Value) { panic(n.no("SetVal")) } +func (n *miniNode) NonNil() bool { return false } +func (n *miniNode) MarkNonNil() { panic(n.no("MarkNonNil")) } diff --git a/go/src/cmd/compile/internal/ir/mknode.go b/go/src/cmd/compile/internal/ir/mknode.go new file mode 100644 index 0000000000000000000000000000000000000000..2f439b9996d86627d8332fd2be50ccb3501b5ed0 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/mknode.go @@ -0,0 +1,384 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +// Note: this program must be run in this directory. +// go run mknode.go + +package main + +import ( + "bytes" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/token" + "io/fs" + "log" + "os" + "slices" + "strings" +) + +var fset = token.NewFileSet() + +var buf bytes.Buffer + +// concreteNodes contains all concrete types in the package that implement Node +// (except for the mini* types). +var concreteNodes []*ast.TypeSpec + +// interfaceNodes contains all interface types in the package that implement Node. +var interfaceNodes []*ast.TypeSpec + +// mini contains the embeddable mini types (miniNode, miniExpr, and miniStmt). +var mini = map[string]*ast.TypeSpec{} + +// implementsNode reports whether the type t is one which represents a Node +// in the AST. +func implementsNode(t ast.Expr) bool { + id, ok := t.(*ast.Ident) + if !ok { + return false // only named types + } + for _, ts := range interfaceNodes { + if ts.Name.Name == id.Name { + return true + } + } + for _, ts := range concreteNodes { + if ts.Name.Name == id.Name { + return true + } + } + return false +} + +func isMini(t ast.Expr) bool { + id, ok := t.(*ast.Ident) + return ok && mini[id.Name] != nil +} + +func isNamedType(t ast.Expr, name string) bool { + if id, ok := t.(*ast.Ident); ok { + if id.Name == name { + return true + } + } + return false +} + +func main() { + fmt.Fprintln(&buf, "// Code generated by mknode.go. DO NOT EDIT.") + fmt.Fprintln(&buf) + fmt.Fprintln(&buf, "package ir") + fmt.Fprintln(&buf) + fmt.Fprintln(&buf, `import "fmt"`) + + filter := func(file fs.FileInfo) bool { + return !strings.HasPrefix(file.Name(), "mknode") + } + pkgs, err := parser.ParseDir(fset, ".", filter, 0) + if err != nil { + panic(err) + } + pkg := pkgs["ir"] + + // Find all the mini types. These let us determine which + // concrete types implement Node, so we need to find them first. + for _, f := range pkg.Files { + for _, d := range f.Decls { + g, ok := d.(*ast.GenDecl) + if !ok { + continue + } + for _, s := range g.Specs { + t, ok := s.(*ast.TypeSpec) + if !ok { + continue + } + if strings.HasPrefix(t.Name.Name, "mini") { + mini[t.Name.Name] = t + // Double-check that it is or embeds miniNode. + if t.Name.Name != "miniNode" { + s := t.Type.(*ast.StructType) + if !isNamedType(s.Fields.List[0].Type, "miniNode") { + panic(fmt.Sprintf("can't find miniNode in %s", t.Name.Name)) + } + } + } + } + } + } + + // Find all the declarations of concrete types that implement Node. + for _, f := range pkg.Files { + for _, d := range f.Decls { + g, ok := d.(*ast.GenDecl) + if !ok { + continue + } + for _, s := range g.Specs { + t, ok := s.(*ast.TypeSpec) + if !ok { + continue + } + if strings.HasPrefix(t.Name.Name, "mini") { + // We don't treat the mini types as + // concrete implementations of Node + // (even though they are) because + // we only use them by embedding them. + continue + } + if isConcreteNode(t) { + concreteNodes = append(concreteNodes, t) + } + if isInterfaceNode(t) { + interfaceNodes = append(interfaceNodes, t) + } + } + } + } + // Sort for deterministic output. + slices.SortFunc(concreteNodes, func(a, b *ast.TypeSpec) int { + return strings.Compare(a.Name.Name, b.Name.Name) + }) + // Generate code for each concrete type. + for _, t := range concreteNodes { + processType(t) + } + // Add some helpers. + generateHelpers() + + // Format and write output. + out, err := format.Source(buf.Bytes()) + if err != nil { + // write out mangled source so we can see the bug. + out = buf.Bytes() + } + err = os.WriteFile("node_gen.go", out, 0666) + if err != nil { + log.Fatal(err) + } +} + +// isConcreteNode reports whether the type t is a concrete type +// implementing Node. +func isConcreteNode(t *ast.TypeSpec) bool { + s, ok := t.Type.(*ast.StructType) + if !ok { + return false + } + for _, f := range s.Fields.List { + if isMini(f.Type) { + return true + } + } + return false +} + +// isInterfaceNode reports whether the type t is an interface type +// implementing Node (including Node itself). +func isInterfaceNode(t *ast.TypeSpec) bool { + s, ok := t.Type.(*ast.InterfaceType) + if !ok { + return false + } + if t.Name.Name == "Node" { + return true + } + if t.Name.Name == "OrigNode" || t.Name.Name == "InitNode" { + // These we exempt from consideration (fields of + // this type don't need to be walked or copied). + return false + } + + // Look for embedded Node type. + // Note that this doesn't handle multi-level embedding, but + // we have none of that at the moment. + for _, f := range s.Methods.List { + if len(f.Names) != 0 { + continue + } + if isNamedType(f.Type, "Node") { + return true + } + } + return false +} + +func processType(t *ast.TypeSpec) { + name := t.Name.Name + fmt.Fprintf(&buf, "\n") + fmt.Fprintf(&buf, "func (n *%s) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }\n", name) + + switch name { + case "Name", "Func": + // Too specialized to automate. + return + } + + s := t.Type.(*ast.StructType) + fields := s.Fields.List + + // Expand any embedded fields. + for i := 0; i < len(fields); i++ { + f := fields[i] + if len(f.Names) != 0 { + continue // not embedded + } + if isMini(f.Type) { + // Insert the fields of the embedded type into the main type. + // (It would be easier just to append, but inserting in place + // matches the old mknode behavior.) + ss := mini[f.Type.(*ast.Ident).Name].Type.(*ast.StructType) + var f2 []*ast.Field + f2 = append(f2, fields[:i]...) + f2 = append(f2, ss.Fields.List...) + f2 = append(f2, fields[i+1:]...) + fields = f2 + i-- + continue + } else if isNamedType(f.Type, "origNode") { + // Ignore this field + copy(fields[i:], fields[i+1:]) + fields = fields[:len(fields)-1] + i-- + continue + } else { + panic("unknown embedded field " + fmt.Sprintf("%v", f.Type)) + } + } + // Process fields. + var copyBody strings.Builder + var doChildrenBody strings.Builder + var doChildrenWithHiddenBody strings.Builder + var editChildrenBody strings.Builder + var editChildrenWithHiddenBody strings.Builder + var hasHidden bool + for _, f := range fields { + names := f.Names + ft := f.Type + hidden := false + if f.Tag != nil { + tag := f.Tag.Value[1 : len(f.Tag.Value)-1] + if strings.HasPrefix(tag, "mknode:") { + if tag[7:] == "\"-\"" { + if !isNamedType(ft, "Node") { + continue + } + hidden = true + } else { + panic(fmt.Sprintf("unexpected tag value: %s", tag)) + } + } + } + if isNamedType(ft, "Nodes") { + // Nodes == []Node + ft = &ast.ArrayType{Elt: &ast.Ident{Name: "Node"}} + } + isSlice := false + if a, ok := ft.(*ast.ArrayType); ok && a.Len == nil { + isSlice = true + ft = a.Elt + } + isPtr := false + if p, ok := ft.(*ast.StarExpr); ok { + isPtr = true + ft = p.X + } + if !implementsNode(ft) { + continue + } + for _, name := range names { + ptr := "" + if isPtr { + ptr = "*" + } + if isSlice { + fmt.Fprintf(&doChildrenWithHiddenBody, + "if do%ss(n.%s, do) {\nreturn true\n}\n", ft, name) + fmt.Fprintf(&editChildrenWithHiddenBody, + "edit%ss(n.%s, edit)\n", ft, name) + } else { + fmt.Fprintf(&doChildrenWithHiddenBody, + "if n.%s != nil && do(n.%s) {\nreturn true\n}\n", name, name) + fmt.Fprintf(&editChildrenWithHiddenBody, + "if n.%s != nil {\nn.%s = edit(n.%s).(%s%s)\n}\n", name, name, name, ptr, ft) + } + if hidden { + hasHidden = true + continue + } + if isSlice { + fmt.Fprintf(©Body, "c.%s = copy%ss(c.%s)\n", name, ft, name) + fmt.Fprintf(&doChildrenBody, + "if do%ss(n.%s, do) {\nreturn true\n}\n", ft, name) + fmt.Fprintf(&editChildrenBody, + "edit%ss(n.%s, edit)\n", ft, name) + } else { + fmt.Fprintf(&doChildrenBody, + "if n.%s != nil && do(n.%s) {\nreturn true\n}\n", name, name) + fmt.Fprintf(&editChildrenBody, + "if n.%s != nil {\nn.%s = edit(n.%s).(%s%s)\n}\n", name, name, name, ptr, ft) + } + } + } + fmt.Fprintf(&buf, "func (n *%s) copy() Node {\nc := *n\n", name) + buf.WriteString(copyBody.String()) + buf.WriteString("return &c\n}\n") + fmt.Fprintf(&buf, "func (n *%s) doChildren(do func(Node) bool) bool {\n", name) + buf.WriteString(doChildrenBody.String()) + buf.WriteString("return false\n}\n") + fmt.Fprintf(&buf, "func (n *%s) doChildrenWithHidden(do func(Node) bool) bool {\n", name) + if hasHidden { + buf.WriteString(doChildrenWithHiddenBody.String()) + buf.WriteString("return false\n}\n") + } else { + buf.WriteString("return n.doChildren(do)\n}\n") + } + fmt.Fprintf(&buf, "func (n *%s) editChildren(edit func(Node) Node) {\n", name) + buf.WriteString(editChildrenBody.String()) + buf.WriteString("}\n") + fmt.Fprintf(&buf, "func (n *%s) editChildrenWithHidden(edit func(Node) Node) {\n", name) + if hasHidden { + buf.WriteString(editChildrenWithHiddenBody.String()) + } else { + buf.WriteString("n.editChildren(edit)\n") + } + buf.WriteString("}\n") +} + +func generateHelpers() { + for _, typ := range []string{"CaseClause", "CommClause", "Name", "Node"} { + ptr := "*" + if typ == "Node" { + ptr = "" // interfaces don't need * + } + fmt.Fprintf(&buf, "\n") + fmt.Fprintf(&buf, "func copy%ss(list []%s%s) []%s%s {\n", typ, ptr, typ, ptr, typ) + fmt.Fprintf(&buf, "if list == nil { return nil }\n") + fmt.Fprintf(&buf, "c := make([]%s%s, len(list))\n", ptr, typ) + fmt.Fprintf(&buf, "copy(c, list)\n") + fmt.Fprintf(&buf, "return c\n") + fmt.Fprintf(&buf, "}\n") + fmt.Fprintf(&buf, "func do%ss(list []%s%s, do func(Node) bool) bool {\n", typ, ptr, typ) + fmt.Fprintf(&buf, "for _, x := range list {\n") + fmt.Fprintf(&buf, "if x != nil && do(x) {\n") + fmt.Fprintf(&buf, "return true\n") + fmt.Fprintf(&buf, "}\n") + fmt.Fprintf(&buf, "}\n") + fmt.Fprintf(&buf, "return false\n") + fmt.Fprintf(&buf, "}\n") + fmt.Fprintf(&buf, "func edit%ss(list []%s%s, edit func(Node) Node) {\n", typ, ptr, typ) + fmt.Fprintf(&buf, "for i, x := range list {\n") + fmt.Fprintf(&buf, "if x != nil {\n") + fmt.Fprintf(&buf, "list[i] = edit(x).(%s%s)\n", ptr, typ) + fmt.Fprintf(&buf, "}\n") + fmt.Fprintf(&buf, "}\n") + fmt.Fprintf(&buf, "}\n") + } +} diff --git a/go/src/cmd/compile/internal/ir/name.go b/go/src/cmd/compile/internal/ir/name.go new file mode 100644 index 0000000000000000000000000000000000000000..63f1b1c931c7b412d93760c899c24c07787f6e31 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/name.go @@ -0,0 +1,400 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" + "fmt" + + "go/constant" +) + +// An Ident is an identifier, possibly qualified. +type Ident struct { + miniExpr + sym *types.Sym +} + +func NewIdent(pos src.XPos, sym *types.Sym) *Ident { + n := new(Ident) + n.op = ONONAME + n.pos = pos + n.sym = sym + return n +} + +func (n *Ident) Sym() *types.Sym { return n.sym } + +// Name holds Node fields used only by named nodes (ONAME, OTYPE, some OLITERAL). +type Name struct { + miniExpr + BuiltinOp Op // uint8 + Class Class // uint8 + pragma PragmaFlag // int16 + flags bitset16 + DictIndex uint16 // index of the dictionary entry describing the type of this variable declaration plus 1 + sym *types.Sym + Func *Func // TODO(austin): nil for I.M + Offset_ int64 + val constant.Value + Opt any // for use by escape or slice analysis + Embed *[]Embed // list of embedded files, for ONAME var + + // For a local variable (not param) or extern, the initializing assignment (OAS or OAS2). + // For a closure var, the ONAME node of the original (outermost) captured variable. + // For the case-local variables of a type switch, the type switch guard (OTYPESW). + // For a range variable, the range statement (ORANGE) + // For a recv variable in a case of a select statement, the receive assignment (OSELRECV2) + // For the name of a function, points to corresponding Func node. + Defn Node + + // The function, method, or closure in which local variable or param is declared. + Curfn *Func + + Heapaddr *Name // temp holding heap address of param + + // Outer points to the immediately enclosing function's copy of this + // closure variable. If not a closure variable, then Outer is nil. + Outer *Name +} + +func (n *Name) isExpr() {} + +func (n *Name) copy() Node { panic(n.no("copy")) } +func (n *Name) doChildren(do func(Node) bool) bool { return false } +func (n *Name) doChildrenWithHidden(do func(Node) bool) bool { return false } +func (n *Name) editChildren(edit func(Node) Node) {} +func (n *Name) editChildrenWithHidden(edit func(Node) Node) {} + +// RecordFrameOffset records the frame offset for the name. +// It is used by package types when laying out function arguments. +func (n *Name) RecordFrameOffset(offset int64) { + n.SetFrameOffset(offset) +} + +// NewNameAt returns a new ONAME Node associated with symbol s at position pos. +// The caller is responsible for setting Curfn. +func NewNameAt(pos src.XPos, sym *types.Sym, typ *types.Type) *Name { + if sym == nil { + base.Fatalf("NewNameAt nil") + } + n := newNameAt(pos, ONAME, sym) + if typ != nil { + n.SetType(typ) + n.SetTypecheck(1) + } + return n +} + +// NewBuiltin returns a new Name representing a builtin function, +// either predeclared or from package unsafe. +func NewBuiltin(sym *types.Sym, op Op) *Name { + n := newNameAt(src.NoXPos, ONAME, sym) + n.BuiltinOp = op + n.SetTypecheck(1) + sym.Def = n + return n +} + +// NewLocal returns a new function-local variable with the given name and type. +func (fn *Func) NewLocal(pos src.XPos, sym *types.Sym, typ *types.Type) *Name { + if fn.Dcl == nil { + base.FatalfAt(pos, "must call DeclParams on %v first", fn) + } + + n := NewNameAt(pos, sym, typ) + n.Class = PAUTO + n.Curfn = fn + fn.Dcl = append(fn.Dcl, n) + return n +} + +// NewDeclNameAt returns a new Name associated with symbol s at position pos. +// The caller is responsible for setting Curfn. +func NewDeclNameAt(pos src.XPos, op Op, sym *types.Sym) *Name { + if sym == nil { + base.Fatalf("NewDeclNameAt nil") + } + switch op { + case ONAME, OTYPE, OLITERAL: + // ok + default: + base.Fatalf("NewDeclNameAt op %v", op) + } + return newNameAt(pos, op, sym) +} + +// NewConstAt returns a new OLITERAL Node associated with symbol s at position pos. +func NewConstAt(pos src.XPos, sym *types.Sym, typ *types.Type, val constant.Value) *Name { + if sym == nil { + base.Fatalf("NewConstAt nil") + } + n := newNameAt(pos, OLITERAL, sym) + n.SetType(typ) + n.SetTypecheck(1) + n.SetVal(val) + return n +} + +// newNameAt is like NewNameAt but allows sym == nil. +func newNameAt(pos src.XPos, op Op, sym *types.Sym) *Name { + n := new(Name) + n.op = op + n.pos = pos + n.sym = sym + return n +} + +func (n *Name) Name() *Name { return n } +func (n *Name) Sym() *types.Sym { return n.sym } +func (n *Name) SetSym(x *types.Sym) { n.sym = x } +func (n *Name) SubOp() Op { return n.BuiltinOp } +func (n *Name) SetSubOp(x Op) { n.BuiltinOp = x } +func (n *Name) SetFunc(x *Func) { n.Func = x } +func (n *Name) FrameOffset() int64 { return n.Offset_ } +func (n *Name) SetFrameOffset(x int64) { n.Offset_ = x } + +func (n *Name) Linksym() *obj.LSym { return n.sym.Linksym() } +func (n *Name) LinksymABI(abi obj.ABI) *obj.LSym { return n.sym.LinksymABI(abi) } + +func (*Name) CanBeNtype() {} +func (*Name) CanBeAnSSASym() {} +func (*Name) CanBeAnSSAAux() {} + +// Pragma returns the PragmaFlag for p, which must be for an OTYPE. +func (n *Name) Pragma() PragmaFlag { return n.pragma } + +// SetPragma sets the PragmaFlag for p, which must be for an OTYPE. +func (n *Name) SetPragma(flag PragmaFlag) { n.pragma = flag } + +// Alias reports whether p, which must be for an OTYPE, is a type alias. +func (n *Name) Alias() bool { return n.flags&nameAlias != 0 } + +// SetAlias sets whether p, which must be for an OTYPE, is a type alias. +func (n *Name) SetAlias(alias bool) { n.flags.set(nameAlias, alias) } + +const ( + nameReadonly = 1 << iota + nameByval // is the variable captured by value or by reference + nameNeedzero // if it contains pointers, needs to be zeroed on function entry + nameAutoTemp // is the variable a temporary (implies no dwarf info. reset if escapes to heap) + nameUsed // for variable declared and not used error + nameIsClosureVar // PAUTOHEAP closure pseudo-variable; original (if any) at n.Defn + nameIsOutputParamHeapAddr // pointer to a result parameter's heap copy + nameIsOutputParamInRegisters // output parameter in registers spills as an auto + nameAddrtaken // address taken, even if not moved to heap + nameInlFormal // PAUTO created by inliner, derived from callee formal + nameInlLocal // PAUTO created by inliner, derived from callee local + nameOpenDeferSlot // if temporary var storing info for open-coded defers + nameLibfuzzer8BitCounter // if PEXTERN should be assigned to __sancov_cntrs section + nameCoverageAuxVar // instrumentation counter var or pkg ID for cmd/cover + nameAlias // is type name an alias + nameNonMergeable // not a candidate for stack slot merging +) + +func (n *Name) Readonly() bool { return n.flags&nameReadonly != 0 } +func (n *Name) Needzero() bool { return n.flags&nameNeedzero != 0 } +func (n *Name) AutoTemp() bool { return n.flags&nameAutoTemp != 0 } +func (n *Name) Used() bool { return n.flags&nameUsed != 0 } +func (n *Name) IsClosureVar() bool { return n.flags&nameIsClosureVar != 0 } +func (n *Name) IsOutputParamHeapAddr() bool { return n.flags&nameIsOutputParamHeapAddr != 0 } +func (n *Name) IsOutputParamInRegisters() bool { return n.flags&nameIsOutputParamInRegisters != 0 } +func (n *Name) Addrtaken() bool { return n.flags&nameAddrtaken != 0 } +func (n *Name) InlFormal() bool { return n.flags&nameInlFormal != 0 } +func (n *Name) InlLocal() bool { return n.flags&nameInlLocal != 0 } +func (n *Name) OpenDeferSlot() bool { return n.flags&nameOpenDeferSlot != 0 } +func (n *Name) Libfuzzer8BitCounter() bool { return n.flags&nameLibfuzzer8BitCounter != 0 } +func (n *Name) CoverageAuxVar() bool { return n.flags&nameCoverageAuxVar != 0 } +func (n *Name) NonMergeable() bool { return n.flags&nameNonMergeable != 0 } + +func (n *Name) setReadonly(b bool) { n.flags.set(nameReadonly, b) } +func (n *Name) SetNeedzero(b bool) { n.flags.set(nameNeedzero, b) } +func (n *Name) SetAutoTemp(b bool) { n.flags.set(nameAutoTemp, b) } +func (n *Name) SetUsed(b bool) { n.flags.set(nameUsed, b) } +func (n *Name) SetIsClosureVar(b bool) { n.flags.set(nameIsClosureVar, b) } +func (n *Name) SetIsOutputParamHeapAddr(b bool) { n.flags.set(nameIsOutputParamHeapAddr, b) } +func (n *Name) SetIsOutputParamInRegisters(b bool) { n.flags.set(nameIsOutputParamInRegisters, b) } +func (n *Name) SetAddrtaken(b bool) { n.flags.set(nameAddrtaken, b) } +func (n *Name) SetInlFormal(b bool) { n.flags.set(nameInlFormal, b) } +func (n *Name) SetInlLocal(b bool) { n.flags.set(nameInlLocal, b) } +func (n *Name) SetOpenDeferSlot(b bool) { n.flags.set(nameOpenDeferSlot, b) } +func (n *Name) SetLibfuzzer8BitCounter(b bool) { n.flags.set(nameLibfuzzer8BitCounter, b) } +func (n *Name) SetCoverageAuxVar(b bool) { n.flags.set(nameCoverageAuxVar, b) } +func (n *Name) SetNonMergeable(b bool) { n.flags.set(nameNonMergeable, b) } + +// OnStack reports whether variable n may reside on the stack. +func (n *Name) OnStack() bool { + if n.Op() == ONAME { + switch n.Class { + case PPARAM, PPARAMOUT, PAUTO: + return n.Esc() != EscHeap + case PEXTERN, PAUTOHEAP: + return false + } + } + // Note: fmt.go:dumpNodeHeader calls all "func() bool"-typed + // methods, but it can only recover from panics, not Fatalf. + panic(fmt.Sprintf("%v: not a variable: %v", base.FmtPos(n.Pos()), n)) +} + +// MarkReadonly indicates that n is an ONAME with readonly contents. +func (n *Name) MarkReadonly() { + if n.Op() != ONAME { + base.Fatalf("Node.MarkReadonly %v", n.Op()) + } + n.setReadonly(true) + // Mark the linksym as readonly immediately + // so that the SSA backend can use this information. + // It will be overridden later during dumpglobls. + n.Linksym().Type = objabi.SRODATA +} + +// Val returns the constant.Value for the node. +func (n *Name) Val() constant.Value { + if n.val == nil { + return constant.MakeUnknown() + } + return n.val +} + +// SetVal sets the constant.Value for the node. +func (n *Name) SetVal(v constant.Value) { + if n.op != OLITERAL { + panic(n.no("SetVal")) + } + AssertValidTypeForConst(n.Type(), v) + n.val = v +} + +// Canonical returns the logical declaration that n represents. If n +// is a closure variable, then Canonical returns the original Name as +// it appears in the function that immediately contains the +// declaration. Otherwise, Canonical simply returns n itself. +func (n *Name) Canonical() *Name { + if n.IsClosureVar() && n.Defn != nil { + n = n.Defn.(*Name) + } + return n +} + +func (n *Name) SetByval(b bool) { + if n.Canonical() != n { + base.Fatalf("SetByval called on non-canonical variable: %v", n) + } + n.flags.set(nameByval, b) +} + +func (n *Name) Byval() bool { + // We require byval to be set on the canonical variable, but we + // allow it to be accessed from any instance. + return n.Canonical().flags&nameByval != 0 +} + +// NewClosureVar returns a new closure variable for fn to refer to +// outer variable n. +func NewClosureVar(pos src.XPos, fn *Func, n *Name) *Name { + switch n.Class { + case PAUTO, PPARAM, PPARAMOUT, PAUTOHEAP: + // ok + default: + // Prevent mistaken capture of global variables. + base.Fatalf("NewClosureVar: %+v", n) + } + + c := NewNameAt(pos, n.Sym(), n.Type()) + c.Curfn = fn + c.Class = PAUTOHEAP + c.SetIsClosureVar(true) + c.Defn = n.Canonical() + c.Outer = n + + fn.ClosureVars = append(fn.ClosureVars, c) + + return c +} + +// NewHiddenParam returns a new hidden parameter for fn with the given +// name and type. +func NewHiddenParam(pos src.XPos, fn *Func, sym *types.Sym, typ *types.Type) *Name { + if fn.OClosure != nil { + base.FatalfAt(fn.Pos(), "cannot add hidden parameters to closures") + } + + fn.SetNeedctxt(true) + + // Create a fake parameter, disassociated from any real function, to + // pretend to capture. + fake := NewNameAt(pos, sym, typ) + fake.Class = PPARAM + fake.SetByval(true) + + return NewClosureVar(pos, fn, fake) +} + +// SameSource reports whether two nodes refer to the same source +// element. +// +// It exists to help incrementally migrate the compiler towards +// allowing the introduction of IdentExpr (#42990). Once we have +// IdentExpr, it will no longer be safe to directly compare Node +// values to tell if they refer to the same Name. Instead, code will +// need to explicitly get references to the underlying Name object(s), +// and compare those instead. +// +// It will still be safe to compare Nodes directly for checking if two +// nodes are syntactically the same. The SameSource function exists to +// indicate code that intentionally compares Nodes for syntactic +// equality as opposed to code that has yet to be updated in +// preparation for IdentExpr. +func SameSource(n1, n2 Node) bool { + return n1 == n2 +} + +// Uses reports whether expression x is a (direct) use of the given +// variable. +func Uses(x Node, v *Name) bool { + if v == nil || v.Op() != ONAME { + base.Fatalf("RefersTo bad Name: %v", v) + } + return x.Op() == ONAME && x.Name() == v +} + +// DeclaredBy reports whether expression x refers (directly) to a +// variable that was declared by the given statement. +func DeclaredBy(x, stmt Node) bool { + if stmt == nil { + base.Fatalf("DeclaredBy nil") + } + return x.Op() == ONAME && SameSource(x.Name().Defn, stmt) +} + +// The Class of a variable/function describes the "storage class" +// of a variable or function. During parsing, storage classes are +// called declaration contexts. +type Class uint8 + +//go:generate stringer -type=Class name.go +const ( + Pxxx Class = iota // no class; used during ssa conversion to indicate pseudo-variables + PEXTERN // global variables + PAUTO // local variables + PAUTOHEAP // local variables or parameters moved to heap + PPARAM // input arguments + PPARAMOUT // output results + PTYPEPARAM // type params + PFUNC // global functions + + // Careful: Class is stored in three bits in Node.flags. + _ = uint((1 << 3) - iota) // static assert for iota <= (1 << 3) +) + +type Embed struct { + Pos src.XPos + Patterns []string +} diff --git a/go/src/cmd/compile/internal/ir/node.go b/go/src/cmd/compile/internal/ir/node.go new file mode 100644 index 0000000000000000000000000000000000000000..f26f61cb18a6f4ab86a77a983ebc6505693447a2 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/node.go @@ -0,0 +1,575 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// “Abstract” syntax representation. + +package ir + +import ( + "fmt" + "go/constant" + + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +// A Node is the abstract interface to an IR node. +type Node interface { + // Formatting + Format(s fmt.State, verb rune) + + // Source position. + Pos() src.XPos + SetPos(x src.XPos) + + // For making copies. For Copy and SepCopy. + copy() Node + + doChildren(func(Node) bool) bool + doChildrenWithHidden(func(Node) bool) bool + editChildren(func(Node) Node) + editChildrenWithHidden(func(Node) Node) + + // Abstract graph structure, for generic traversals. + Op() Op + Init() Nodes + + // Fields specific to certain Ops only. + Type() *types.Type + SetType(t *types.Type) + Name() *Name + Sym() *types.Sym + Val() constant.Value + SetVal(v constant.Value) + + // Storage for analysis passes. + Esc() uint16 + SetEsc(x uint16) + + // Typecheck values: + // 0 means the node is not typechecked + // 1 means the node is completely typechecked + // 2 means typechecking of the node is in progress + Typecheck() uint8 + SetTypecheck(x uint8) + NonNil() bool + MarkNonNil() +} + +// Line returns n's position as a string. If n has been inlined, +// it uses the outermost position where n has been inlined. +func Line(n Node) string { + return base.FmtPos(n.Pos()) +} + +func IsSynthetic(n Node) bool { + name := n.Sym().Name + return name[0] == '.' || name[0] == '~' +} + +// IsAutoTmp indicates if n was created by the compiler as a temporary, +// based on the setting of the .AutoTemp flag in n's Name. +func IsAutoTmp(n Node) bool { + if n == nil || n.Op() != ONAME { + return false + } + return n.Name().AutoTemp() +} + +// MayBeShared reports whether n may occur in multiple places in the AST. +// Extra care must be taken when mutating such a node. +func MayBeShared(n Node) bool { + switch n.Op() { + case ONAME, OLITERAL, ONIL, OTYPE: + return true + } + return false +} + +type InitNode interface { + Node + PtrInit() *Nodes + SetInit(x Nodes) +} + +func TakeInit(n Node) Nodes { + init := n.Init() + if len(init) != 0 { + n.(InitNode).SetInit(nil) + } + return init +} + +//go:generate stringer -type=Op -trimprefix=O node.go + +type Op uint8 + +// Node ops. +const ( + OXXX Op = iota + + // names + ONAME // var or func name + // Unnamed arg or return value: f(int, string) (int, error) { etc } + // Also used for a qualified package identifier that hasn't been resolved yet. + ONONAME + OTYPE // type name + OLITERAL // literal + ONIL // nil + + // expressions + OADD // X + Y + OSUB // X - Y + OOR // X | Y + OXOR // X ^ Y + OADDSTR // +{List} (string addition, list elements are strings) + OADDR // &X + OANDAND // X && Y + OAPPEND // append(Args); after walk, X may contain elem type descriptor + OBYTES2STR // Type(X) (Type is string, X is a []byte) + OBYTES2STRTMP // Type(X) (Type is string, X is a []byte, ephemeral) + ORUNES2STR // Type(X) (Type is string, X is a []rune) + OSTR2BYTES // Type(X) (Type is []byte, X is a string) + OSTR2BYTESTMP // Type(X) (Type is []byte, X is a string, ephemeral) + OSTR2RUNES // Type(X) (Type is []rune, X is a string) + OSLICE2ARR // Type(X) (Type is [N]T, X is a []T) + OSLICE2ARRPTR // Type(X) (Type is *[N]T, X is a []T) + // X = Y or (if Def=true) X := Y + // If Def, then Init includes a DCL node for X. + OAS + // Lhs = Rhs (x, y, z = a, b, c) or (if Def=true) Lhs := Rhs + // If Def, then Init includes DCL nodes for Lhs + OAS2 + OAS2DOTTYPE // Lhs = Rhs (x, ok = I.(int)) + OAS2FUNC // Lhs = Rhs (x, y = f()) + OAS2MAPR // Lhs = Rhs (x, ok = m["foo"]) + OAS2RECV // Lhs = Rhs (x, ok = <-c) + OASOP // X AsOp= Y (x += y) + OCALL // X(Args) (function call, method call or type conversion) + + // OCALLFUNC, OCALLMETH, and OCALLINTER have the same structure. + // Prior to walk, they are: X(Args), where Args is all regular arguments. + // After walk, if any argument whose evaluation might requires temporary variable, + // that temporary variable will be pushed to Init, Args will contain an updated + // set of arguments. + OCALLFUNC // X(Args) (function call f(args)) + OCALLMETH // X(Args) (direct method call x.Method(args)) + OCALLINTER // X(Args) (interface method call x.Method(args)) + OCAP // cap(X) + OCLEAR // clear(X) + OCLOSE // close(X) + OCLOSURE // func Type { Func.Closure.Body } (func literal) + OCOMPLIT // Type{List} (composite literal, not yet lowered to specific form) + OMAPLIT // Type{List} (composite literal, Type is map) + OSTRUCTLIT // Type{List} (composite literal, Type is struct) + OARRAYLIT // Type{List} (composite literal, Type is array) + OSLICELIT // Type{List} (composite literal, Type is slice), Len is slice length. + OPTRLIT // &X (X is composite literal) + OCONV // Type(X) (type conversion) + OCONVIFACE // Type(X) (type conversion, to interface) + OCONVNOP // Type(X) (type conversion, no effect) + OCOPY // copy(X, Y) + ODCL // var X (declares X of type X.Type) + + // Used during parsing but don't last. + ODCLFUNC // func f() or func (r) f() + + ODELETE // delete(Args) + ODOT // X.Sel (X is of struct type) + ODOTPTR // X.Sel (X is of pointer to struct type) + ODOTMETH // X.Sel (X is non-interface, Sel is method name) + ODOTINTER // X.Sel (X is interface, Sel is method name) + OXDOT // X.Sel (before rewrite to one of the preceding) + ODOTTYPE // X.Ntype or X.Type (.Ntype during parsing, .Type once resolved); after walk, Itab contains address of interface type descriptor and Itab.X contains address of concrete type descriptor + ODOTTYPE2 // X.Ntype or X.Type (.Ntype during parsing, .Type once resolved; on rhs of OAS2DOTTYPE); after walk, Itab contains address of interface type descriptor + OEQ // X == Y + ONE // X != Y + OLT // X < Y + OLE // X <= Y + OGE // X >= Y + OGT // X > Y + ODEREF // *X + OINDEX // X[Index] (index of array or slice) + OINDEXMAP // X[Index] (index of map) + OKEY // Key:Value (key:value in struct/array/map literal) + OSTRUCTKEY // Field:Value (key:value in struct literal, after type checking) + OLEN // len(X) + OMAKE // make(Args) (before type checking converts to one of the following) + OMAKECHAN // make(Type[, Len]) (type is chan) + OMAKEMAP // make(Type[, Len]) (type is map) + OMAKESLICE // make(Type[, Len[, Cap]]) (type is slice) + OMAKESLICECOPY // makeslicecopy(Type, Len, Cap) (type is slice; Len is length and Cap is the copied from slice) + // OMAKESLICECOPY is created by the order pass and corresponds to: + // s = make(Type, Len); copy(s, Cap) + // + // Bounded can be set on the node when Len == len(Cap) is known at compile time. + // + // This node is created so the walk pass can optimize this pattern which would + // otherwise be hard to detect after the order pass. + OMUL // X * Y + ODIV // X / Y + OMOD // X % Y + OLSH // X << Y + ORSH // X >> Y + OAND // X & Y + OANDNOT // X &^ Y + ONEW // new(X); corresponds to calls to new(T) in source code + ONOT // !X + OBITNOT // ^X + OPLUS // +X + ONEG // -X + OOROR // X || Y + OPANIC // panic(X) + OPRINT // print(List) + OPRINTLN // println(List) + OPAREN // (X) + OSEND // Chan <- Value + OSLICE // X[Low : High] (X is untypechecked or slice) + OSLICEARR // X[Low : High] (X is pointer to array) + OSLICESTR // X[Low : High] (X is string) + OSLICE3 // X[Low : High : Max] (X is untypedchecked or slice) + OSLICE3ARR // X[Low : High : Max] (X is pointer to array) + OSLICEHEADER // sliceheader{Ptr, Len, Cap} (Ptr is unsafe.Pointer, Len is length, Cap is capacity) + OSTRINGHEADER // stringheader{Ptr, Len} (Ptr is unsafe.Pointer, Len is length) + ORECOVER // recover() + ORECV // <-X + ORUNESTR // Type(X) (Type is string, X is rune) + OSELRECV2 // like OAS2: Lhs = Rhs where len(Lhs)=2, len(Rhs)=1, Rhs[0].Op = ORECV (appears as .Var of OCASE) + OMIN // min(List) + OMAX // max(List) + OREAL // real(X) + OIMAG // imag(X) + OCOMPLEX // complex(X, Y) + OUNSAFEADD // unsafe.Add(X, Y) + OUNSAFESLICE // unsafe.Slice(X, Y) + OUNSAFESLICEDATA // unsafe.SliceData(X) + OUNSAFESTRING // unsafe.String(X, Y) + OUNSAFESTRINGDATA // unsafe.StringData(X) + OMETHEXPR // X(Args) (method expression T.Method(args), first argument is the method receiver) + OMETHVALUE // X.Sel (method expression t.Method, not called) + + // statements + OBLOCK // { List } (block of code) + OBREAK // break [Label] + // OCASE: case List: Body (List==nil means default) + // For OTYPESW, List is a OTYPE node for the specified type (or OLITERAL + // for nil) or an ODYNAMICTYPE indicating a runtime type for generics. + // If a type-switch variable is specified, Var is an + // ONAME for the version of the type-switch variable with the specified + // type. + OCASE + OCONTINUE // continue [Label] + ODEFER // defer Call + OFALL // fallthrough + OFOR // for Init; Cond; Post { Body } + OGOTO // goto Label + OIF // if Init; Cond { Then } else { Else } + OLABEL // Label: + OGO // go Call + ORANGE // for Key, Value = range X { Body } + ORETURN // return Results + OSELECT // select { Cases } + OSWITCH // switch Init; Expr { Cases } + // OTYPESW: X := Y.(type) (appears as .Tag of OSWITCH) + // X is nil if there is no type-switch variable + OTYPESW + + // misc + // intermediate representation of an inlined call. Uses Init (assignments + // for the captured variables, parameters, retvars, & INLMARK op), + // Body (body of the inlined function), and ReturnVars (list of + // return values) + OINLCALL // intermediary representation of an inlined call. + OMAKEFACE // construct an interface value from rtype/itab and data pointers + OITAB // rtype/itab pointer of an interface value + OIDATA // data pointer of an interface value + OSPTR // base pointer of a slice or string. Bounded==1 means known non-nil. + OCFUNC // reference to c function pointer (not go func value) + OCHECKNIL // emit code to ensure pointer/interface not nil + ORESULT // result of a function call; Xoffset is stack offset + OINLMARK // start of an inlined body, with file/line of caller. Xoffset is an index into the inline tree. + OLINKSYMOFFSET // offset within a name + OJUMPTABLE // A jump table structure for implementing dense expression switches + OINTERFACESWITCH // A type switch with interface cases + OMOVE2HEAP // Promote a stack-backed slice to heap + + // opcodes for generics + ODYNAMICDOTTYPE // x = i.(T) where T is a type parameter (or derived from a type parameter) + ODYNAMICDOTTYPE2 // x, ok = i.(T) where T is a type parameter (or derived from a type parameter) + ODYNAMICTYPE // a type node for type switches (represents a dynamic target type for a type switch) + + // arch-specific opcodes + OTAILCALL // tail call to another function + OGETG // runtime.getg() (read g pointer) + OGETCALLERSP // internal/runtime/sys.GetCallerSP() (stack pointer in caller frame) + + OEND +) + +// IsCmp reports whether op is a comparison operation (==, !=, <, <=, +// >, or >=). +func (op Op) IsCmp() bool { + switch op { + case OEQ, ONE, OLT, OLE, OGT, OGE: + return true + } + return false +} + +// Nodes is a slice of Node. +type Nodes []Node + +// ToNodes returns s as a slice of Nodes. +func ToNodes[T Node](s []T) Nodes { + res := make(Nodes, len(s)) + for i, n := range s { + res[i] = n + } + return res +} + +// Append appends entries to Nodes. +func (n *Nodes) Append(a ...Node) { + if len(a) == 0 { + return + } + *n = append(*n, a...) +} + +// Prepend prepends entries to Nodes. +// If a slice is passed in, this will take ownership of it. +func (n *Nodes) Prepend(a ...Node) { + if len(a) == 0 { + return + } + *n = append(a, *n...) +} + +// Take clears n, returning its former contents. +func (n *Nodes) Take() []Node { + ret := *n + *n = nil + return ret +} + +// Copy returns a copy of the content of the slice. +func (n Nodes) Copy() Nodes { + if n == nil { + return nil + } + c := make(Nodes, len(n)) + copy(c, n) + return c +} + +// NameQueue is a FIFO queue of *Name. The zero value of NameQueue is +// a ready-to-use empty queue. +type NameQueue struct { + ring []*Name + head, tail int +} + +// Empty reports whether q contains no Names. +func (q *NameQueue) Empty() bool { + return q.head == q.tail +} + +// PushRight appends n to the right of the queue. +func (q *NameQueue) PushRight(n *Name) { + if len(q.ring) == 0 { + q.ring = make([]*Name, 16) + } else if q.head+len(q.ring) == q.tail { + // Grow the ring. + nring := make([]*Name, len(q.ring)*2) + // Copy the old elements. + part := q.ring[q.head%len(q.ring):] + if q.tail-q.head <= len(part) { + part = part[:q.tail-q.head] + copy(nring, part) + } else { + pos := copy(nring, part) + copy(nring[pos:], q.ring[:q.tail%len(q.ring)]) + } + q.ring, q.head, q.tail = nring, 0, q.tail-q.head + } + + q.ring[q.tail%len(q.ring)] = n + q.tail++ +} + +// PopLeft pops a Name from the left of the queue. It panics if q is +// empty. +func (q *NameQueue) PopLeft() *Name { + if q.Empty() { + panic("dequeue empty") + } + n := q.ring[q.head%len(q.ring)] + q.head++ + return n +} + +// NameSet is a set of Names. +type NameSet map[*Name]struct{} + +// Has reports whether s contains n. +func (s NameSet) Has(n *Name) bool { + _, isPresent := s[n] + return isPresent +} + +// Add adds n to s. +func (s *NameSet) Add(n *Name) { + if *s == nil { + *s = make(map[*Name]struct{}) + } + (*s)[n] = struct{}{} +} + +type PragmaFlag uint16 + +const ( + // Func pragmas. + Nointerface PragmaFlag = 1 << iota + Noescape // func parameters don't escape + Norace // func must not have race detector annotations + Nosplit // func should not execute on separate stack + Noinline // func should not be inlined + NoCheckPtr // func should not be instrumented by checkptr + CgoUnsafeArgs // treat a pointer to one arg as a pointer to them all + UintptrKeepAlive // pointers converted to uintptr must be kept alive + UintptrEscapes // pointers converted to uintptr escape + + // Runtime-only func pragmas. + // See ../../../../runtime/HACKING.md for detailed descriptions. + Systemstack // func must run on system stack + Nowritebarrier // emit compiler error instead of write barrier + Nowritebarrierrec // error on write barrier in this or recursive callees + Yeswritebarrierrec // cancels Nowritebarrierrec in this function and callees + + // Go command pragmas + GoBuildPragma + + RegisterParams // TODO(register args) remove after register abi is working + +) + +var BlankNode *Name + +func IsConst(n Node, ct constant.Kind) bool { + return ConstType(n) == ct +} + +// IsNil reports whether n represents the universal untyped zero value "nil". +func IsNil(n Node) bool { + return n != nil && n.Op() == ONIL +} + +func IsBlank(n Node) bool { + if n == nil { + return false + } + return n.Sym().IsBlank() +} + +// IsMethod reports whether n is a method. +// n must be a function or a method. +func IsMethod(n Node) bool { + return n.Type().Recv() != nil +} + +// HasUniquePos reports whether n has a unique position that can be +// used for reporting error messages. +// +// It's primarily used to distinguish references to named objects, +// whose Pos will point back to their declaration position rather than +// their usage position. +func HasUniquePos(n Node) bool { + switch n.Op() { + case ONAME: + return false + case OLITERAL, ONIL, OTYPE: + if n.Sym() != nil { + return false + } + } + + if !n.Pos().IsKnown() { + if base.Flag.K != 0 { + base.Warn("setlineno: unknown position (line 0)") + } + return false + } + + return true +} + +func SetPos(n Node) src.XPos { + lno := base.Pos + if n != nil && HasUniquePos(n) { + base.Pos = n.Pos() + } + return lno +} + +// The result of InitExpr MUST be assigned back to n, e.g. +// +// n.X = InitExpr(init, n.X) +func InitExpr(init []Node, expr Node) Node { + if len(init) == 0 { + return expr + } + + n, ok := expr.(InitNode) + if !ok || MayBeShared(n) { + // Introduce OCONVNOP to hold init list. + n = NewConvExpr(base.Pos, OCONVNOP, nil, expr) + n.SetType(expr.Type()) + n.SetTypecheck(1) + } + + n.PtrInit().Prepend(init...) + return n +} + +// what's the outer value that a write to n affects? +// outer value means containing struct or array. +func OuterValue(n Node) Node { + for { + switch nn := n; nn.Op() { + case OXDOT: + base.FatalfAt(n.Pos(), "OXDOT in OuterValue: %v", n) + case ODOT: + nn := nn.(*SelectorExpr) + n = nn.X + continue + case OPAREN: + nn := nn.(*ParenExpr) + n = nn.X + continue + case OCONVNOP: + nn := nn.(*ConvExpr) + n = nn.X + continue + case OINDEX: + nn := nn.(*IndexExpr) + if nn.X.Type() == nil { + base.Fatalf("OuterValue needs type for %v", nn.X) + } + if nn.X.Type().IsArray() { + n = nn.X + continue + } + } + + return n + } +} + +const ( + EscUnknown = iota + EscNone // Does not escape to heap, result, or parameters. + EscHeap // Reachable from the heap + EscNever // By construction will not escape. +) diff --git a/go/src/cmd/compile/internal/ir/node_gen.go b/go/src/cmd/compile/internal/ir/node_gen.go new file mode 100644 index 0000000000000000000000000000000000000000..2ae0a43e49617c5c2b6af85183db08dd8daf0a4c --- /dev/null +++ b/go/src/cmd/compile/internal/ir/node_gen.go @@ -0,0 +1,1978 @@ +// Code generated by mknode.go. DO NOT EDIT. + +package ir + +import "fmt" + +func (n *AddStringExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *AddStringExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.List = copyNodes(c.List) + return &c +} +func (n *AddStringExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if doNodes(n.List, do) { + return true + } + if n.Prealloc != nil && do(n.Prealloc) { + return true + } + return false +} +func (n *AddStringExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *AddStringExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + editNodes(n.List, edit) + if n.Prealloc != nil { + n.Prealloc = edit(n.Prealloc).(*Name) + } +} +func (n *AddStringExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *AddrExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *AddrExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *AddrExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Prealloc != nil && do(n.Prealloc) { + return true + } + return false +} +func (n *AddrExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *AddrExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Prealloc != nil { + n.Prealloc = edit(n.Prealloc).(*Name) + } +} +func (n *AddrExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *AssignListStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *AssignListStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.Lhs = copyNodes(c.Lhs) + c.Rhs = copyNodes(c.Rhs) + return &c +} +func (n *AssignListStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if doNodes(n.Lhs, do) { + return true + } + if doNodes(n.Rhs, do) { + return true + } + return false +} +func (n *AssignListStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *AssignListStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + editNodes(n.Lhs, edit) + editNodes(n.Rhs, edit) +} +func (n *AssignListStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *AssignOpStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *AssignOpStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *AssignOpStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Y != nil && do(n.Y) { + return true + } + return false +} +func (n *AssignOpStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *AssignOpStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Y != nil { + n.Y = edit(n.Y).(Node) + } +} +func (n *AssignOpStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *AssignStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *AssignStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *AssignStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Y != nil && do(n.Y) { + return true + } + return false +} +func (n *AssignStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *AssignStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Y != nil { + n.Y = edit(n.Y).(Node) + } +} +func (n *AssignStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *BasicLit) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *BasicLit) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *BasicLit) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + return false +} +func (n *BasicLit) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *BasicLit) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) +} +func (n *BasicLit) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *BinaryExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *BinaryExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *BinaryExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Y != nil && do(n.Y) { + return true + } + return false +} +func (n *BinaryExpr) doChildrenWithHidden(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Y != nil && do(n.Y) { + return true + } + if n.RType != nil && do(n.RType) { + return true + } + return false +} +func (n *BinaryExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Y != nil { + n.Y = edit(n.Y).(Node) + } +} +func (n *BinaryExpr) editChildrenWithHidden(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Y != nil { + n.Y = edit(n.Y).(Node) + } + if n.RType != nil { + n.RType = edit(n.RType).(Node) + } +} + +func (n *BlockStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *BlockStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.List = copyNodes(c.List) + return &c +} +func (n *BlockStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if doNodes(n.List, do) { + return true + } + return false +} +func (n *BlockStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *BlockStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + editNodes(n.List, edit) +} +func (n *BlockStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *BranchStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *BranchStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *BranchStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + return false +} +func (n *BranchStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *BranchStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) +} +func (n *BranchStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *CallExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *CallExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.Args = copyNodes(c.Args) + c.KeepAlive = copyNames(c.KeepAlive) + return &c +} +func (n *CallExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Fun != nil && do(n.Fun) { + return true + } + if doNodes(n.Args, do) { + return true + } + if n.DeferAt != nil && do(n.DeferAt) { + return true + } + if doNames(n.KeepAlive, do) { + return true + } + return false +} +func (n *CallExpr) doChildrenWithHidden(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Fun != nil && do(n.Fun) { + return true + } + if doNodes(n.Args, do) { + return true + } + if n.DeferAt != nil && do(n.DeferAt) { + return true + } + if n.RType != nil && do(n.RType) { + return true + } + if doNames(n.KeepAlive, do) { + return true + } + return false +} +func (n *CallExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Fun != nil { + n.Fun = edit(n.Fun).(Node) + } + editNodes(n.Args, edit) + if n.DeferAt != nil { + n.DeferAt = edit(n.DeferAt).(Node) + } + editNames(n.KeepAlive, edit) +} +func (n *CallExpr) editChildrenWithHidden(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Fun != nil { + n.Fun = edit(n.Fun).(Node) + } + editNodes(n.Args, edit) + if n.DeferAt != nil { + n.DeferAt = edit(n.DeferAt).(Node) + } + if n.RType != nil { + n.RType = edit(n.RType).(Node) + } + editNames(n.KeepAlive, edit) +} + +func (n *CaseClause) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *CaseClause) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.List = copyNodes(c.List) + c.RTypes = copyNodes(c.RTypes) + c.Body = copyNodes(c.Body) + return &c +} +func (n *CaseClause) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Var != nil && do(n.Var) { + return true + } + if doNodes(n.List, do) { + return true + } + if doNodes(n.RTypes, do) { + return true + } + if doNodes(n.Body, do) { + return true + } + return false +} +func (n *CaseClause) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *CaseClause) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Var != nil { + n.Var = edit(n.Var).(*Name) + } + editNodes(n.List, edit) + editNodes(n.RTypes, edit) + editNodes(n.Body, edit) +} +func (n *CaseClause) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *ClosureExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *ClosureExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *ClosureExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Prealloc != nil && do(n.Prealloc) { + return true + } + return false +} +func (n *ClosureExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *ClosureExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Prealloc != nil { + n.Prealloc = edit(n.Prealloc).(*Name) + } +} +func (n *ClosureExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *CommClause) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *CommClause) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.Body = copyNodes(c.Body) + return &c +} +func (n *CommClause) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Comm != nil && do(n.Comm) { + return true + } + if doNodes(n.Body, do) { + return true + } + return false +} +func (n *CommClause) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *CommClause) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Comm != nil { + n.Comm = edit(n.Comm).(Node) + } + editNodes(n.Body, edit) +} +func (n *CommClause) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *CompLitExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *CompLitExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.List = copyNodes(c.List) + return &c +} +func (n *CompLitExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if doNodes(n.List, do) { + return true + } + if n.Prealloc != nil && do(n.Prealloc) { + return true + } + return false +} +func (n *CompLitExpr) doChildrenWithHidden(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if doNodes(n.List, do) { + return true + } + if n.RType != nil && do(n.RType) { + return true + } + if n.Prealloc != nil && do(n.Prealloc) { + return true + } + return false +} +func (n *CompLitExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + editNodes(n.List, edit) + if n.Prealloc != nil { + n.Prealloc = edit(n.Prealloc).(*Name) + } +} +func (n *CompLitExpr) editChildrenWithHidden(edit func(Node) Node) { + editNodes(n.init, edit) + editNodes(n.List, edit) + if n.RType != nil { + n.RType = edit(n.RType).(Node) + } + if n.Prealloc != nil { + n.Prealloc = edit(n.Prealloc).(*Name) + } +} + +func (n *ConvExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *ConvExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *ConvExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + return false +} +func (n *ConvExpr) doChildrenWithHidden(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.TypeWord != nil && do(n.TypeWord) { + return true + } + if n.SrcRType != nil && do(n.SrcRType) { + return true + } + if n.ElemRType != nil && do(n.ElemRType) { + return true + } + if n.ElemElemRType != nil && do(n.ElemElemRType) { + return true + } + return false +} +func (n *ConvExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } +} +func (n *ConvExpr) editChildrenWithHidden(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.TypeWord != nil { + n.TypeWord = edit(n.TypeWord).(Node) + } + if n.SrcRType != nil { + n.SrcRType = edit(n.SrcRType).(Node) + } + if n.ElemRType != nil { + n.ElemRType = edit(n.ElemRType).(Node) + } + if n.ElemElemRType != nil { + n.ElemElemRType = edit(n.ElemElemRType).(Node) + } +} + +func (n *Decl) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *Decl) copy() Node { + c := *n + return &c +} +func (n *Decl) doChildren(do func(Node) bool) bool { + if n.X != nil && do(n.X) { + return true + } + return false +} +func (n *Decl) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *Decl) editChildren(edit func(Node) Node) { + if n.X != nil { + n.X = edit(n.X).(*Name) + } +} +func (n *Decl) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *DynamicType) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *DynamicType) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *DynamicType) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.RType != nil && do(n.RType) { + return true + } + if n.ITab != nil && do(n.ITab) { + return true + } + return false +} +func (n *DynamicType) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *DynamicType) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.RType != nil { + n.RType = edit(n.RType).(Node) + } + if n.ITab != nil { + n.ITab = edit(n.ITab).(Node) + } +} +func (n *DynamicType) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *DynamicTypeAssertExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *DynamicTypeAssertExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *DynamicTypeAssertExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.SrcRType != nil && do(n.SrcRType) { + return true + } + if n.RType != nil && do(n.RType) { + return true + } + if n.ITab != nil && do(n.ITab) { + return true + } + return false +} +func (n *DynamicTypeAssertExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *DynamicTypeAssertExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.SrcRType != nil { + n.SrcRType = edit(n.SrcRType).(Node) + } + if n.RType != nil { + n.RType = edit(n.RType).(Node) + } + if n.ITab != nil { + n.ITab = edit(n.ITab).(Node) + } +} +func (n *DynamicTypeAssertExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *ForStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *ForStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.Body = copyNodes(c.Body) + return &c +} +func (n *ForStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Cond != nil && do(n.Cond) { + return true + } + if n.Post != nil && do(n.Post) { + return true + } + if doNodes(n.Body, do) { + return true + } + return false +} +func (n *ForStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *ForStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Cond != nil { + n.Cond = edit(n.Cond).(Node) + } + if n.Post != nil { + n.Post = edit(n.Post).(Node) + } + editNodes(n.Body, edit) +} +func (n *ForStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *Func) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } + +func (n *GoDeferStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *GoDeferStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *GoDeferStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Call != nil && do(n.Call) { + return true + } + if n.DeferAt != nil && do(n.DeferAt) { + return true + } + return false +} +func (n *GoDeferStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *GoDeferStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Call != nil { + n.Call = edit(n.Call).(Node) + } + if n.DeferAt != nil { + n.DeferAt = edit(n.DeferAt).(Expr) + } +} +func (n *GoDeferStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *Ident) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *Ident) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *Ident) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + return false +} +func (n *Ident) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *Ident) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) +} +func (n *Ident) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *IfStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *IfStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.Body = copyNodes(c.Body) + c.Else = copyNodes(c.Else) + return &c +} +func (n *IfStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Cond != nil && do(n.Cond) { + return true + } + if doNodes(n.Body, do) { + return true + } + if doNodes(n.Else, do) { + return true + } + return false +} +func (n *IfStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *IfStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Cond != nil { + n.Cond = edit(n.Cond).(Node) + } + editNodes(n.Body, edit) + editNodes(n.Else, edit) +} +func (n *IfStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *IndexExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *IndexExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *IndexExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Index != nil && do(n.Index) { + return true + } + return false +} +func (n *IndexExpr) doChildrenWithHidden(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Index != nil && do(n.Index) { + return true + } + if n.RType != nil && do(n.RType) { + return true + } + return false +} +func (n *IndexExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Index != nil { + n.Index = edit(n.Index).(Node) + } +} +func (n *IndexExpr) editChildrenWithHidden(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Index != nil { + n.Index = edit(n.Index).(Node) + } + if n.RType != nil { + n.RType = edit(n.RType).(Node) + } +} + +func (n *InlineMarkStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *InlineMarkStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *InlineMarkStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + return false +} +func (n *InlineMarkStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *InlineMarkStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) +} +func (n *InlineMarkStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *InlinedCallExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *InlinedCallExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.Body = copyNodes(c.Body) + c.ReturnVars = copyNodes(c.ReturnVars) + return &c +} +func (n *InlinedCallExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if doNodes(n.Body, do) { + return true + } + if doNodes(n.ReturnVars, do) { + return true + } + return false +} +func (n *InlinedCallExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *InlinedCallExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + editNodes(n.Body, edit) + editNodes(n.ReturnVars, edit) +} +func (n *InlinedCallExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *InterfaceSwitchStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *InterfaceSwitchStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *InterfaceSwitchStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Case != nil && do(n.Case) { + return true + } + if n.Itab != nil && do(n.Itab) { + return true + } + if n.RuntimeType != nil && do(n.RuntimeType) { + return true + } + if n.Hash != nil && do(n.Hash) { + return true + } + return false +} +func (n *InterfaceSwitchStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *InterfaceSwitchStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Case != nil { + n.Case = edit(n.Case).(Node) + } + if n.Itab != nil { + n.Itab = edit(n.Itab).(Node) + } + if n.RuntimeType != nil { + n.RuntimeType = edit(n.RuntimeType).(Node) + } + if n.Hash != nil { + n.Hash = edit(n.Hash).(Node) + } +} +func (n *InterfaceSwitchStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *JumpTableStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *JumpTableStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *JumpTableStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Idx != nil && do(n.Idx) { + return true + } + return false +} +func (n *JumpTableStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *JumpTableStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Idx != nil { + n.Idx = edit(n.Idx).(Node) + } +} +func (n *JumpTableStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *KeyExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *KeyExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *KeyExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Key != nil && do(n.Key) { + return true + } + if n.Value != nil && do(n.Value) { + return true + } + return false +} +func (n *KeyExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *KeyExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Key != nil { + n.Key = edit(n.Key).(Node) + } + if n.Value != nil { + n.Value = edit(n.Value).(Node) + } +} +func (n *KeyExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *LabelStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *LabelStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *LabelStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + return false +} +func (n *LabelStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *LabelStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) +} +func (n *LabelStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *LinksymOffsetExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *LinksymOffsetExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *LinksymOffsetExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + return false +} +func (n *LinksymOffsetExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *LinksymOffsetExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) +} +func (n *LinksymOffsetExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *LogicalExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *LogicalExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *LogicalExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Y != nil && do(n.Y) { + return true + } + return false +} +func (n *LogicalExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *LogicalExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Y != nil { + n.Y = edit(n.Y).(Node) + } +} +func (n *LogicalExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *MakeExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *MakeExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *MakeExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Len != nil && do(n.Len) { + return true + } + if n.Cap != nil && do(n.Cap) { + return true + } + return false +} +func (n *MakeExpr) doChildrenWithHidden(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.RType != nil && do(n.RType) { + return true + } + if n.Len != nil && do(n.Len) { + return true + } + if n.Cap != nil && do(n.Cap) { + return true + } + return false +} +func (n *MakeExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Len != nil { + n.Len = edit(n.Len).(Node) + } + if n.Cap != nil { + n.Cap = edit(n.Cap).(Node) + } +} +func (n *MakeExpr) editChildrenWithHidden(edit func(Node) Node) { + editNodes(n.init, edit) + if n.RType != nil { + n.RType = edit(n.RType).(Node) + } + if n.Len != nil { + n.Len = edit(n.Len).(Node) + } + if n.Cap != nil { + n.Cap = edit(n.Cap).(Node) + } +} + +func (n *MoveToHeapExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *MoveToHeapExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *MoveToHeapExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Slice != nil && do(n.Slice) { + return true + } + if n.RType != nil && do(n.RType) { + return true + } + return false +} +func (n *MoveToHeapExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *MoveToHeapExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Slice != nil { + n.Slice = edit(n.Slice).(Node) + } + if n.RType != nil { + n.RType = edit(n.RType).(Node) + } +} +func (n *MoveToHeapExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *Name) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } + +func (n *NilExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *NilExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *NilExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + return false +} +func (n *NilExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *NilExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) +} +func (n *NilExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *ParenExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *ParenExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *ParenExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + return false +} +func (n *ParenExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *ParenExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } +} +func (n *ParenExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *RangeStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *RangeStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.Body = copyNodes(c.Body) + return &c +} +func (n *RangeStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Key != nil && do(n.Key) { + return true + } + if n.Value != nil && do(n.Value) { + return true + } + if doNodes(n.Body, do) { + return true + } + if n.Prealloc != nil && do(n.Prealloc) { + return true + } + return false +} +func (n *RangeStmt) doChildrenWithHidden(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.RType != nil && do(n.RType) { + return true + } + if n.Key != nil && do(n.Key) { + return true + } + if n.Value != nil && do(n.Value) { + return true + } + if doNodes(n.Body, do) { + return true + } + if n.Prealloc != nil && do(n.Prealloc) { + return true + } + if n.KeyTypeWord != nil && do(n.KeyTypeWord) { + return true + } + if n.KeySrcRType != nil && do(n.KeySrcRType) { + return true + } + if n.ValueTypeWord != nil && do(n.ValueTypeWord) { + return true + } + if n.ValueSrcRType != nil && do(n.ValueSrcRType) { + return true + } + return false +} +func (n *RangeStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Key != nil { + n.Key = edit(n.Key).(Node) + } + if n.Value != nil { + n.Value = edit(n.Value).(Node) + } + editNodes(n.Body, edit) + if n.Prealloc != nil { + n.Prealloc = edit(n.Prealloc).(*Name) + } +} +func (n *RangeStmt) editChildrenWithHidden(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.RType != nil { + n.RType = edit(n.RType).(Node) + } + if n.Key != nil { + n.Key = edit(n.Key).(Node) + } + if n.Value != nil { + n.Value = edit(n.Value).(Node) + } + editNodes(n.Body, edit) + if n.Prealloc != nil { + n.Prealloc = edit(n.Prealloc).(*Name) + } + if n.KeyTypeWord != nil { + n.KeyTypeWord = edit(n.KeyTypeWord).(Node) + } + if n.KeySrcRType != nil { + n.KeySrcRType = edit(n.KeySrcRType).(Node) + } + if n.ValueTypeWord != nil { + n.ValueTypeWord = edit(n.ValueTypeWord).(Node) + } + if n.ValueSrcRType != nil { + n.ValueSrcRType = edit(n.ValueSrcRType).(Node) + } +} + +func (n *ResultExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *ResultExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *ResultExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + return false +} +func (n *ResultExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *ResultExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) +} +func (n *ResultExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *ReturnStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *ReturnStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.Results = copyNodes(c.Results) + return &c +} +func (n *ReturnStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if doNodes(n.Results, do) { + return true + } + return false +} +func (n *ReturnStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *ReturnStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + editNodes(n.Results, edit) +} +func (n *ReturnStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *SelectStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *SelectStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.Cases = copyCommClauses(c.Cases) + c.Compiled = copyNodes(c.Compiled) + return &c +} +func (n *SelectStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if doCommClauses(n.Cases, do) { + return true + } + if doNodes(n.Compiled, do) { + return true + } + return false +} +func (n *SelectStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *SelectStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + editCommClauses(n.Cases, edit) + editNodes(n.Compiled, edit) +} +func (n *SelectStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *SelectorExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *SelectorExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *SelectorExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Prealloc != nil && do(n.Prealloc) { + return true + } + return false +} +func (n *SelectorExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *SelectorExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Prealloc != nil { + n.Prealloc = edit(n.Prealloc).(*Name) + } +} +func (n *SelectorExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *SendStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *SendStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *SendStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Chan != nil && do(n.Chan) { + return true + } + if n.Value != nil && do(n.Value) { + return true + } + return false +} +func (n *SendStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *SendStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Chan != nil { + n.Chan = edit(n.Chan).(Node) + } + if n.Value != nil { + n.Value = edit(n.Value).(Node) + } +} +func (n *SendStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *SliceExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *SliceExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *SliceExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.Low != nil && do(n.Low) { + return true + } + if n.High != nil && do(n.High) { + return true + } + if n.Max != nil && do(n.Max) { + return true + } + return false +} +func (n *SliceExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *SliceExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.Low != nil { + n.Low = edit(n.Low).(Node) + } + if n.High != nil { + n.High = edit(n.High).(Node) + } + if n.Max != nil { + n.Max = edit(n.Max).(Node) + } +} +func (n *SliceExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *SliceHeaderExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *SliceHeaderExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *SliceHeaderExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Ptr != nil && do(n.Ptr) { + return true + } + if n.Len != nil && do(n.Len) { + return true + } + if n.Cap != nil && do(n.Cap) { + return true + } + return false +} +func (n *SliceHeaderExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *SliceHeaderExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Ptr != nil { + n.Ptr = edit(n.Ptr).(Node) + } + if n.Len != nil { + n.Len = edit(n.Len).(Node) + } + if n.Cap != nil { + n.Cap = edit(n.Cap).(Node) + } +} +func (n *SliceHeaderExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *StarExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *StarExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *StarExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + return false +} +func (n *StarExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *StarExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } +} +func (n *StarExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *StringHeaderExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *StringHeaderExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *StringHeaderExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Ptr != nil && do(n.Ptr) { + return true + } + if n.Len != nil && do(n.Len) { + return true + } + return false +} +func (n *StringHeaderExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *StringHeaderExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Ptr != nil { + n.Ptr = edit(n.Ptr).(Node) + } + if n.Len != nil { + n.Len = edit(n.Len).(Node) + } +} +func (n *StringHeaderExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *StructKeyExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *StructKeyExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *StructKeyExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Value != nil && do(n.Value) { + return true + } + return false +} +func (n *StructKeyExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *StructKeyExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Value != nil { + n.Value = edit(n.Value).(Node) + } +} +func (n *StructKeyExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *SwitchStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *SwitchStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + c.Cases = copyCaseClauses(c.Cases) + c.Compiled = copyNodes(c.Compiled) + return &c +} +func (n *SwitchStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Tag != nil && do(n.Tag) { + return true + } + if doCaseClauses(n.Cases, do) { + return true + } + if doNodes(n.Compiled, do) { + return true + } + return false +} +func (n *SwitchStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *SwitchStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Tag != nil { + n.Tag = edit(n.Tag).(Node) + } + editCaseClauses(n.Cases, edit) + editNodes(n.Compiled, edit) +} +func (n *SwitchStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *TailCallStmt) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *TailCallStmt) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *TailCallStmt) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.Call != nil && do(n.Call) { + return true + } + return false +} +func (n *TailCallStmt) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *TailCallStmt) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.Call != nil { + n.Call = edit(n.Call).(*CallExpr) + } +} +func (n *TailCallStmt) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *TypeAssertExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *TypeAssertExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *TypeAssertExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + return false +} +func (n *TypeAssertExpr) doChildrenWithHidden(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + if n.ITab != nil && do(n.ITab) { + return true + } + return false +} +func (n *TypeAssertExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } +} +func (n *TypeAssertExpr) editChildrenWithHidden(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } + if n.ITab != nil { + n.ITab = edit(n.ITab).(Node) + } +} + +func (n *TypeSwitchGuard) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *TypeSwitchGuard) copy() Node { + c := *n + return &c +} +func (n *TypeSwitchGuard) doChildren(do func(Node) bool) bool { + if n.Tag != nil && do(n.Tag) { + return true + } + if n.X != nil && do(n.X) { + return true + } + return false +} +func (n *TypeSwitchGuard) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *TypeSwitchGuard) editChildren(edit func(Node) Node) { + if n.Tag != nil { + n.Tag = edit(n.Tag).(*Ident) + } + if n.X != nil { + n.X = edit(n.X).(Node) + } +} +func (n *TypeSwitchGuard) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *UnaryExpr) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *UnaryExpr) copy() Node { + c := *n + c.init = copyNodes(c.init) + return &c +} +func (n *UnaryExpr) doChildren(do func(Node) bool) bool { + if doNodes(n.init, do) { + return true + } + if n.X != nil && do(n.X) { + return true + } + return false +} +func (n *UnaryExpr) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *UnaryExpr) editChildren(edit func(Node) Node) { + editNodes(n.init, edit) + if n.X != nil { + n.X = edit(n.X).(Node) + } +} +func (n *UnaryExpr) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func (n *typeNode) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) } +func (n *typeNode) copy() Node { + c := *n + return &c +} +func (n *typeNode) doChildren(do func(Node) bool) bool { + return false +} +func (n *typeNode) doChildrenWithHidden(do func(Node) bool) bool { + return n.doChildren(do) +} +func (n *typeNode) editChildren(edit func(Node) Node) { +} +func (n *typeNode) editChildrenWithHidden(edit func(Node) Node) { + n.editChildren(edit) +} + +func copyCaseClauses(list []*CaseClause) []*CaseClause { + if list == nil { + return nil + } + c := make([]*CaseClause, len(list)) + copy(c, list) + return c +} +func doCaseClauses(list []*CaseClause, do func(Node) bool) bool { + for _, x := range list { + if x != nil && do(x) { + return true + } + } + return false +} +func editCaseClauses(list []*CaseClause, edit func(Node) Node) { + for i, x := range list { + if x != nil { + list[i] = edit(x).(*CaseClause) + } + } +} + +func copyCommClauses(list []*CommClause) []*CommClause { + if list == nil { + return nil + } + c := make([]*CommClause, len(list)) + copy(c, list) + return c +} +func doCommClauses(list []*CommClause, do func(Node) bool) bool { + for _, x := range list { + if x != nil && do(x) { + return true + } + } + return false +} +func editCommClauses(list []*CommClause, edit func(Node) Node) { + for i, x := range list { + if x != nil { + list[i] = edit(x).(*CommClause) + } + } +} + +func copyNames(list []*Name) []*Name { + if list == nil { + return nil + } + c := make([]*Name, len(list)) + copy(c, list) + return c +} +func doNames(list []*Name, do func(Node) bool) bool { + for _, x := range list { + if x != nil && do(x) { + return true + } + } + return false +} +func editNames(list []*Name, edit func(Node) Node) { + for i, x := range list { + if x != nil { + list[i] = edit(x).(*Name) + } + } +} + +func copyNodes(list []Node) []Node { + if list == nil { + return nil + } + c := make([]Node, len(list)) + copy(c, list) + return c +} +func doNodes(list []Node, do func(Node) bool) bool { + for _, x := range list { + if x != nil && do(x) { + return true + } + } + return false +} +func editNodes(list []Node, edit func(Node) Node) { + for i, x := range list { + if x != nil { + list[i] = edit(x).(Node) + } + } +} diff --git a/go/src/cmd/compile/internal/ir/op_string.go b/go/src/cmd/compile/internal/ir/op_string.go new file mode 100644 index 0000000000000000000000000000000000000000..f042ad84a405d0ebbfce7733dcc01279957a5055 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/op_string.go @@ -0,0 +1,173 @@ +// Code generated by "stringer -type=Op -trimprefix=O node.go"; DO NOT EDIT. + +package ir + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[OXXX-0] + _ = x[ONAME-1] + _ = x[ONONAME-2] + _ = x[OTYPE-3] + _ = x[OLITERAL-4] + _ = x[ONIL-5] + _ = x[OADD-6] + _ = x[OSUB-7] + _ = x[OOR-8] + _ = x[OXOR-9] + _ = x[OADDSTR-10] + _ = x[OADDR-11] + _ = x[OANDAND-12] + _ = x[OAPPEND-13] + _ = x[OBYTES2STR-14] + _ = x[OBYTES2STRTMP-15] + _ = x[ORUNES2STR-16] + _ = x[OSTR2BYTES-17] + _ = x[OSTR2BYTESTMP-18] + _ = x[OSTR2RUNES-19] + _ = x[OSLICE2ARR-20] + _ = x[OSLICE2ARRPTR-21] + _ = x[OAS-22] + _ = x[OAS2-23] + _ = x[OAS2DOTTYPE-24] + _ = x[OAS2FUNC-25] + _ = x[OAS2MAPR-26] + _ = x[OAS2RECV-27] + _ = x[OASOP-28] + _ = x[OCALL-29] + _ = x[OCALLFUNC-30] + _ = x[OCALLMETH-31] + _ = x[OCALLINTER-32] + _ = x[OCAP-33] + _ = x[OCLEAR-34] + _ = x[OCLOSE-35] + _ = x[OCLOSURE-36] + _ = x[OCOMPLIT-37] + _ = x[OMAPLIT-38] + _ = x[OSTRUCTLIT-39] + _ = x[OARRAYLIT-40] + _ = x[OSLICELIT-41] + _ = x[OPTRLIT-42] + _ = x[OCONV-43] + _ = x[OCONVIFACE-44] + _ = x[OCONVNOP-45] + _ = x[OCOPY-46] + _ = x[ODCL-47] + _ = x[ODCLFUNC-48] + _ = x[ODELETE-49] + _ = x[ODOT-50] + _ = x[ODOTPTR-51] + _ = x[ODOTMETH-52] + _ = x[ODOTINTER-53] + _ = x[OXDOT-54] + _ = x[ODOTTYPE-55] + _ = x[ODOTTYPE2-56] + _ = x[OEQ-57] + _ = x[ONE-58] + _ = x[OLT-59] + _ = x[OLE-60] + _ = x[OGE-61] + _ = x[OGT-62] + _ = x[ODEREF-63] + _ = x[OINDEX-64] + _ = x[OINDEXMAP-65] + _ = x[OKEY-66] + _ = x[OSTRUCTKEY-67] + _ = x[OLEN-68] + _ = x[OMAKE-69] + _ = x[OMAKECHAN-70] + _ = x[OMAKEMAP-71] + _ = x[OMAKESLICE-72] + _ = x[OMAKESLICECOPY-73] + _ = x[OMUL-74] + _ = x[ODIV-75] + _ = x[OMOD-76] + _ = x[OLSH-77] + _ = x[ORSH-78] + _ = x[OAND-79] + _ = x[OANDNOT-80] + _ = x[ONEW-81] + _ = x[ONOT-82] + _ = x[OBITNOT-83] + _ = x[OPLUS-84] + _ = x[ONEG-85] + _ = x[OOROR-86] + _ = x[OPANIC-87] + _ = x[OPRINT-88] + _ = x[OPRINTLN-89] + _ = x[OPAREN-90] + _ = x[OSEND-91] + _ = x[OSLICE-92] + _ = x[OSLICEARR-93] + _ = x[OSLICESTR-94] + _ = x[OSLICE3-95] + _ = x[OSLICE3ARR-96] + _ = x[OSLICEHEADER-97] + _ = x[OSTRINGHEADER-98] + _ = x[ORECOVER-99] + _ = x[ORECV-100] + _ = x[ORUNESTR-101] + _ = x[OSELRECV2-102] + _ = x[OMIN-103] + _ = x[OMAX-104] + _ = x[OREAL-105] + _ = x[OIMAG-106] + _ = x[OCOMPLEX-107] + _ = x[OUNSAFEADD-108] + _ = x[OUNSAFESLICE-109] + _ = x[OUNSAFESLICEDATA-110] + _ = x[OUNSAFESTRING-111] + _ = x[OUNSAFESTRINGDATA-112] + _ = x[OMETHEXPR-113] + _ = x[OMETHVALUE-114] + _ = x[OBLOCK-115] + _ = x[OBREAK-116] + _ = x[OCASE-117] + _ = x[OCONTINUE-118] + _ = x[ODEFER-119] + _ = x[OFALL-120] + _ = x[OFOR-121] + _ = x[OGOTO-122] + _ = x[OIF-123] + _ = x[OLABEL-124] + _ = x[OGO-125] + _ = x[ORANGE-126] + _ = x[ORETURN-127] + _ = x[OSELECT-128] + _ = x[OSWITCH-129] + _ = x[OTYPESW-130] + _ = x[OINLCALL-131] + _ = x[OMAKEFACE-132] + _ = x[OITAB-133] + _ = x[OIDATA-134] + _ = x[OSPTR-135] + _ = x[OCFUNC-136] + _ = x[OCHECKNIL-137] + _ = x[ORESULT-138] + _ = x[OINLMARK-139] + _ = x[OLINKSYMOFFSET-140] + _ = x[OJUMPTABLE-141] + _ = x[OINTERFACESWITCH-142] + _ = x[OMOVE2HEAP-143] + _ = x[ODYNAMICDOTTYPE-144] + _ = x[ODYNAMICDOTTYPE2-145] + _ = x[ODYNAMICTYPE-146] + _ = x[OTAILCALL-147] + _ = x[OGETG-148] + _ = x[OGETCALLERSP-149] + _ = x[OEND-150] +} + +const _Op_name = "XXXNAMENONAMETYPELITERALNILADDSUBORXORADDSTRADDRANDANDAPPENDBYTES2STRBYTES2STRTMPRUNES2STRSTR2BYTESSTR2BYTESTMPSTR2RUNESSLICE2ARRSLICE2ARRPTRASAS2AS2DOTTYPEAS2FUNCAS2MAPRAS2RECVASOPCALLCALLFUNCCALLMETHCALLINTERCAPCLEARCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVNOPCOPYDCLDCLFUNCDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTDEREFINDEXINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMAKESLICECOPYMULDIVMODLSHRSHANDANDNOTNEWNOTBITNOTPLUSNEGORORPANICPRINTPRINTLNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERSTRINGHEADERRECOVERRECVRUNESTRSELRECV2MINMAXREALIMAGCOMPLEXUNSAFEADDUNSAFESLICEUNSAFESLICEDATAUNSAFESTRINGUNSAFESTRINGDATAMETHEXPRMETHVALUEBLOCKBREAKCASECONTINUEDEFERFALLFORGOTOIFLABELGORANGERETURNSELECTSWITCHTYPESWINLCALLMAKEFACEITABIDATASPTRCFUNCCHECKNILRESULTINLMARKLINKSYMOFFSETJUMPTABLEINTERFACESWITCHMOVE2HEAPDYNAMICDOTTYPEDYNAMICDOTTYPE2DYNAMICTYPETAILCALLGETGGETCALLERSPEND" + +var _Op_index = [...]uint16{0, 3, 7, 13, 17, 24, 27, 30, 33, 35, 38, 44, 48, 54, 60, 69, 81, 90, 99, 111, 120, 129, 141, 143, 146, 156, 163, 170, 177, 181, 185, 193, 201, 210, 213, 218, 223, 230, 237, 243, 252, 260, 268, 274, 278, 287, 294, 298, 301, 308, 314, 317, 323, 330, 338, 342, 349, 357, 359, 361, 363, 365, 367, 369, 374, 379, 387, 390, 399, 402, 406, 414, 421, 430, 443, 446, 449, 452, 455, 458, 461, 467, 470, 473, 479, 483, 486, 490, 495, 500, 507, 512, 516, 521, 529, 537, 543, 552, 563, 575, 582, 586, 593, 601, 604, 607, 611, 615, 622, 631, 642, 657, 669, 685, 693, 702, 707, 712, 716, 724, 729, 733, 736, 740, 742, 747, 749, 754, 760, 766, 772, 778, 785, 793, 797, 802, 806, 811, 819, 825, 832, 845, 854, 869, 878, 892, 907, 918, 926, 930, 941, 944} + +func (i Op) String() string { + if i >= Op(len(_Op_index)-1) { + return "Op(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Op_name[_Op_index[i]:_Op_index[i+1]] +} diff --git a/go/src/cmd/compile/internal/ir/package.go b/go/src/cmd/compile/internal/ir/package.go new file mode 100644 index 0000000000000000000000000000000000000000..3b70a9281a34791a5edea4cbf897db60804b12fb --- /dev/null +++ b/go/src/cmd/compile/internal/ir/package.go @@ -0,0 +1,42 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import "cmd/compile/internal/types" + +// A Package holds information about the package being compiled. +type Package struct { + // Imports, listed in source order. + // See golang.org/issue/31636. + Imports []*types.Pkg + + // Init functions, listed in source order. + Inits []*Func + + // Funcs contains all (instantiated) functions, methods, and + // function literals to be compiled. + Funcs []*Func + + // Externs holds constants, (non-generic) types, and variables + // declared at package scope. + Externs []*Name + + // AsmHdrDecls holds declared constants and struct types that should + // be included in -asmhdr output. It's only populated when -asmhdr + // is set. + AsmHdrDecls []*Name + + // Cgo directives. + CgoPragmas [][]string + + // Variables with //go:embed lines. + Embeds []*Name + + // PluginExports holds exported functions and variables that are + // accessible through the package plugin API. It's only populated + // for -buildmode=plugin (i.e., compiling package main and -dynlink + // is set). + PluginExports []*Name +} diff --git a/go/src/cmd/compile/internal/ir/reassign_consistency_check.go b/go/src/cmd/compile/internal/ir/reassign_consistency_check.go new file mode 100644 index 0000000000000000000000000000000000000000..24bbfdfd4479acc7c206df9bc495659adc933866 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/reassign_consistency_check.go @@ -0,0 +1,46 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "cmd/compile/internal/base" + "cmd/internal/src" + "fmt" + "path/filepath" + "strings" +) + +// checkStaticValueResult compares the result from ReassignOracle.StaticValue +// with the corresponding result from ir.StaticValue to make sure they agree. +// This method is called only when turned on via build tag. +func checkStaticValueResult(n Node, newres Node) { + oldres := StaticValue(n) + if oldres != newres { + base.Fatalf("%s: new/old static value disagreement on %v:\nnew=%v\nold=%v", fmtFullPos(n.Pos()), n, newres, oldres) + } +} + +// checkReassignedResult compares the result from ReassignOracle.Reassigned +// with the corresponding result from ir.Reassigned to make sure they agree. +// This method is called only when turned on via build tag. +func checkReassignedResult(n *Name, newres bool) { + origres := Reassigned(n) + if newres != origres { + base.Fatalf("%s: new/old reassigned disagreement on %v (class %s) newres=%v oldres=%v", fmtFullPos(n.Pos()), n, n.Class.String(), newres, origres) + } +} + +// fmtFullPos returns a verbose dump for pos p, including inlines. +func fmtFullPos(p src.XPos) string { + var sb strings.Builder + sep := "" + base.Ctxt.AllPos(p, func(pos src.Pos) { + sb.WriteString(sep) + sep = "|" + file := filepath.Base(pos.Filename()) + fmt.Fprintf(&sb, "%s:%d:%d", file, pos.Line(), pos.Col()) + }) + return sb.String() +} diff --git a/go/src/cmd/compile/internal/ir/reassignment.go b/go/src/cmd/compile/internal/ir/reassignment.go new file mode 100644 index 0000000000000000000000000000000000000000..ba14d078a2ff26f00264ad95e9aaedd270c214de --- /dev/null +++ b/go/src/cmd/compile/internal/ir/reassignment.go @@ -0,0 +1,205 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "cmd/compile/internal/base" +) + +// A ReassignOracle efficiently answers queries about whether local +// variables are reassigned. This helper works by looking for function +// params and short variable declarations (e.g. +// https://go.dev/ref/spec#Short_variable_declarations) that are +// neither address taken nor subsequently re-assigned. It is intended +// to operate much like "ir.StaticValue" and "ir.Reassigned", but in a +// way that does just a single walk of the containing function (as +// opposed to a new walk on every call). +type ReassignOracle struct { + fn *Func + // maps candidate name to its defining assignment (or + // for params, defining func). + singleDef map[*Name]Node +} + +// Init initializes the oracle based on the IR in function fn, laying +// the groundwork for future calls to the StaticValue and Reassigned +// methods. If the fn's IR is subsequently modified, Init must be +// called again. +func (ro *ReassignOracle) Init(fn *Func) { + ro.fn = fn + + // Collect candidate map. Start by adding function parameters + // explicitly. + ro.singleDef = make(map[*Name]Node) + sig := fn.Type() + numParams := sig.NumRecvs() + sig.NumParams() + for _, param := range fn.Dcl[:numParams] { + if IsBlank(param) { + continue + } + // For params, use func itself as defining node. + ro.singleDef[param] = fn + } + + // Walk the function body to discover any locals assigned + // via ":=" syntax (e.g. "a := "). + var findLocals func(n Node) bool + findLocals = func(n Node) bool { + if nn, ok := n.(*Name); ok { + if nn.Defn != nil && !nn.Addrtaken() && nn.Class == PAUTO { + ro.singleDef[nn] = nn.Defn + } + } else if nn, ok := n.(*ClosureExpr); ok { + Any(nn.Func, findLocals) + } + return false + } + Any(fn, findLocals) + + outerName := func(x Node) *Name { + if x == nil { + return nil + } + n, ok := OuterValue(x).(*Name) + if ok { + return n.Canonical() + } + return nil + } + + // pruneIfNeeded examines node nn appearing on the left hand side + // of assignment statement asn to see if it contains a reassignment + // to any nodes in our candidate map ro.singleDef; if a reassignment + // is found, the corresponding name is deleted from singleDef. + pruneIfNeeded := func(nn Node, asn Node) { + oname := outerName(nn) + if oname == nil { + return + } + defn, ok := ro.singleDef[oname] + if !ok { + return + } + // any assignment to a param invalidates the entry. + paramAssigned := oname.Class == PPARAM + // assignment to local ok iff assignment is its orig def. + localAssigned := (oname.Class == PAUTO && asn != defn) + if paramAssigned || localAssigned { + // We found an assignment to name N that doesn't + // correspond to its original definition; remove + // from candidates. + delete(ro.singleDef, oname) + } + } + + // Prune away anything that looks assigned. This code modeled after + // similar code in ir.Reassigned; any changes there should be made + // here as well. + var do func(n Node) bool + do = func(n Node) bool { + switch n.Op() { + case OAS: + asn := n.(*AssignStmt) + pruneIfNeeded(asn.X, n) + case OAS2, OAS2FUNC, OAS2MAPR, OAS2DOTTYPE, OAS2RECV, OSELRECV2: + asn := n.(*AssignListStmt) + for _, p := range asn.Lhs { + pruneIfNeeded(p, n) + } + case OASOP: + asn := n.(*AssignOpStmt) + pruneIfNeeded(asn.X, n) + case ORANGE: + rs := n.(*RangeStmt) + pruneIfNeeded(rs.Key, n) + pruneIfNeeded(rs.Value, n) + case OCLOSURE: + n := n.(*ClosureExpr) + Any(n.Func, do) + } + return false + } + Any(fn, do) +} + +// StaticValue method has the same semantics as the ir package function +// of the same name; see comments on [StaticValue]. +func (ro *ReassignOracle) StaticValue(n Node) Node { + arg := n + for { + if n.Op() == OCONVNOP { + n = n.(*ConvExpr).X + continue + } + + if n.Op() == OINLCALL { + n = n.(*InlinedCallExpr).SingleResult() + continue + } + + n1 := ro.staticValue1(n) + if n1 == nil { + if consistencyCheckEnabled { + checkStaticValueResult(arg, n) + } + return n + } + n = n1 + } +} + +func (ro *ReassignOracle) staticValue1(nn Node) Node { + if nn.Op() != ONAME { + return nil + } + n := nn.(*Name).Canonical() + if n.Class != PAUTO { + return nil + } + + defn := n.Defn + if defn == nil { + return nil + } + + var rhs Node +FindRHS: + switch defn.Op() { + case OAS: + defn := defn.(*AssignStmt) + rhs = defn.Y + case OAS2: + defn := defn.(*AssignListStmt) + for i, lhs := range defn.Lhs { + if lhs == n { + rhs = defn.Rhs[i] + break FindRHS + } + } + base.FatalfAt(defn.Pos(), "%v missing from LHS of %v", n, defn) + default: + return nil + } + if rhs == nil { + base.FatalfAt(defn.Pos(), "RHS is nil: %v", defn) + } + + if _, ok := ro.singleDef[n]; !ok { + return nil + } + + return rhs +} + +// Reassigned method has the same semantics as the ir package function +// of the same name; see comments on [Reassigned] for more info. +func (ro *ReassignOracle) Reassigned(n *Name) bool { + _, ok := ro.singleDef[n] + result := !ok + if consistencyCheckEnabled { + checkReassignedResult(n, result) + } + return result +} diff --git a/go/src/cmd/compile/internal/ir/scc.go b/go/src/cmd/compile/internal/ir/scc.go new file mode 100644 index 0000000000000000000000000000000000000000..7beacc78498a77cde917ebc6be603bb0e4b554c4 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/scc.go @@ -0,0 +1,125 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +// Strongly connected components. +// +// Run analysis on minimal sets of mutually recursive functions +// or single non-recursive functions, bottom up. +// +// Finding these sets is finding strongly connected components +// by reverse topological order in the static call graph. +// The algorithm (known as Tarjan's algorithm) for doing that is taken from +// Sedgewick, Algorithms, Second Edition, p. 482, with two adaptations. +// +// First, a closure function (fn.IsClosure()) cannot be +// the root of a connected component. Refusing to use it as a root forces +// it into the component of the function in which it appears. This is +// more convenient for escape analysis. +// +// Second, each function becomes two virtual nodes in the graph, +// with numbers n and n+1. We record the function's node number as n +// but search from node n+1. If the search tells us that the component +// number (minVisitGen) is n+1, we know that this is a trivial component: one function +// plus its closures. If the search tells us that the component number is +// n, then there was a path from node n+1 back to node n, meaning that +// the function set is mutually recursive. The escape analysis can be +// more precise when analyzing a single non-recursive function than +// when analyzing a set of mutually recursive functions. + +type bottomUpVisitor struct { + analyze func([]*Func, bool) + visitgen uint32 + nodeID map[*Func]uint32 + stack []*Func +} + +// VisitFuncsBottomUp invokes analyze on the ODCLFUNC nodes listed in list. +// It calls analyze with successive groups of functions, working from +// the bottom of the call graph upward. Each time analyze is called with +// a list of functions, every function on that list only calls other functions +// on the list or functions that have been passed in previous invocations of +// analyze. Closures appear in the same list as their outer functions. +// The lists are as short as possible while preserving those requirements. +// (In a typical program, many invocations of analyze will be passed just +// a single function.) The boolean argument 'recursive' passed to analyze +// specifies whether the functions on the list are mutually recursive. +// If recursive is false, the list consists of only a single function and its closures. +// If recursive is true, the list may still contain only a single function, +// if that function is itself recursive. +func VisitFuncsBottomUp(list []*Func, analyze func(list []*Func, recursive bool)) { + var v bottomUpVisitor + v.analyze = analyze + v.nodeID = make(map[*Func]uint32) + for _, n := range list { + if !n.IsClosure() { + v.visit(n) + } + } +} + +func (v *bottomUpVisitor) visit(n *Func) uint32 { + if id := v.nodeID[n]; id > 0 { + // already visited + return id + } + + v.visitgen++ + id := v.visitgen + v.nodeID[n] = id + v.visitgen++ + minVisitGen := v.visitgen + v.stack = append(v.stack, n) + + do := func(defn Node) { + if defn != nil { + if m := v.visit(defn.(*Func)); m < minVisitGen { + minVisitGen = m + } + } + } + + Visit(n, func(n Node) { + switch n.Op() { + case ONAME: + if n := n.(*Name); n.Class == PFUNC { + do(n.Defn) + } + case ODOTMETH, OMETHVALUE, OMETHEXPR: + if fn := MethodExprName(n); fn != nil { + do(fn.Defn) + } + case OCLOSURE: + n := n.(*ClosureExpr) + do(n.Func) + } + }) + + if (minVisitGen == id || minVisitGen == id+1) && !n.IsClosure() { + // This node is the root of a strongly connected component. + + // The original minVisitGen was id+1. If the bottomUpVisitor found its way + // back to id, then this block is a set of mutually recursive functions. + // Otherwise, it's just a lone function that does not recurse. + recursive := minVisitGen == id + + // Remove connected component from stack and mark v.nodeID so that future + // visits return a large number, which will not affect the caller's min. + var i int + for i = len(v.stack) - 1; i >= 0; i-- { + x := v.stack[i] + v.nodeID[x] = ^uint32(0) + if x == n { + break + } + } + block := v.stack[i:] + // Call analyze on this set of functions. + v.stack = v.stack[:i] + v.analyze(block, recursive) + } + + return minVisitGen +} diff --git a/go/src/cmd/compile/internal/ir/sizeof_test.go b/go/src/cmd/compile/internal/ir/sizeof_test.go new file mode 100644 index 0000000000000000000000000000000000000000..b805155e6e3b799290b8752316e528f647f56d9b --- /dev/null +++ b/go/src/cmd/compile/internal/ir/sizeof_test.go @@ -0,0 +1,39 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "reflect" + "testing" + "unsafe" +) + +// Assert that the size of important structures do not change unexpectedly. + +func TestSizeof(t *testing.T) { + const _64bit = unsafe.Sizeof(uintptr(0)) == 8 + + var tests = []struct { + val any // type as a value + _32bit uintptr // size on 32bit platforms + _64bit uintptr // size on 64bit platforms + }{ + {Func{}, 184, 312}, + {Name{}, 96, 160}, + {miniExpr{}, 32, 48}, + {miniNode{}, 12, 12}, + } + + for _, tt := range tests { + want := tt._32bit + if _64bit { + want = tt._64bit + } + got := reflect.TypeOf(tt.val).Size() + if want != got { + t.Errorf("unsafe.Sizeof(%T) = %d, want %d", tt.val, got, want) + } + } +} diff --git a/go/src/cmd/compile/internal/ir/stmt.go b/go/src/cmd/compile/internal/ir/stmt.go new file mode 100644 index 0000000000000000000000000000000000000000..affa5f4551e45061bf827b6257cf95baafd6783b --- /dev/null +++ b/go/src/cmd/compile/internal/ir/stmt.go @@ -0,0 +1,506 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" + "go/constant" +) + +// A Decl is a declaration of a const, type, or var. (A declared func is a Func.) +type Decl struct { + miniNode + X *Name // the thing being declared +} + +func NewDecl(pos src.XPos, op Op, x *Name) *Decl { + n := &Decl{X: x} + n.pos = pos + switch op { + default: + panic("invalid Decl op " + op.String()) + case ODCL: + n.op = op + } + return n +} + +func (*Decl) isStmt() {} + +// A Stmt is a Node that can appear as a statement. +// This includes statement-like expressions such as f(). +// +// (It's possible it should include <-c, but that would require +// splitting ORECV out of UnaryExpr, which hasn't yet been +// necessary. Maybe instead we will introduce ExprStmt at +// some point.) +type Stmt interface { + Node + isStmt() + PtrInit() *Nodes +} + +// A miniStmt is a miniNode with extra fields common to statements. +type miniStmt struct { + miniNode + init Nodes +} + +func (*miniStmt) isStmt() {} + +func (n *miniStmt) Init() Nodes { return n.init } +func (n *miniStmt) SetInit(x Nodes) { n.init = x } +func (n *miniStmt) PtrInit() *Nodes { return &n.init } + +// An AssignListStmt is an assignment statement with +// more than one item on at least one side: Lhs = Rhs. +// If Def is true, the assignment is a :=. +type AssignListStmt struct { + miniStmt + Lhs Nodes + Def bool + Rhs Nodes +} + +func NewAssignListStmt(pos src.XPos, op Op, lhs, rhs []Node) *AssignListStmt { + n := &AssignListStmt{} + n.pos = pos + n.SetOp(op) + n.Lhs = lhs + n.Rhs = rhs + return n +} + +func (n *AssignListStmt) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OAS2, OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, OSELRECV2: + n.op = op + } +} + +// An AssignStmt is a simple assignment statement: X = Y. +// If Def is true, the assignment is a :=. +type AssignStmt struct { + miniStmt + X Node + Def bool + Y Node +} + +func NewAssignStmt(pos src.XPos, x, y Node) *AssignStmt { + n := &AssignStmt{X: x, Y: y} + n.pos = pos + n.op = OAS + return n +} + +func (n *AssignStmt) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OAS: + n.op = op + } +} + +// An AssignOpStmt is an AsOp= assignment statement: X AsOp= Y. +type AssignOpStmt struct { + miniStmt + X Node + AsOp Op // OADD etc + Y Node + IncDec bool // actually ++ or -- +} + +func NewAssignOpStmt(pos src.XPos, asOp Op, x, y Node) *AssignOpStmt { + n := &AssignOpStmt{AsOp: asOp, X: x, Y: y} + n.pos = pos + n.op = OASOP + return n +} + +// A BlockStmt is a block: { List }. +type BlockStmt struct { + miniStmt + List Nodes +} + +func NewBlockStmt(pos src.XPos, list []Node) *BlockStmt { + n := &BlockStmt{} + n.pos = pos + if !pos.IsKnown() { + n.pos = base.Pos + if len(list) > 0 { + n.pos = list[0].Pos() + } + } + n.op = OBLOCK + n.List = list + return n +} + +// A BranchStmt is a break, continue, fallthrough, or goto statement. +type BranchStmt struct { + miniStmt + Label *types.Sym // label if present +} + +func NewBranchStmt(pos src.XPos, op Op, label *types.Sym) *BranchStmt { + switch op { + case OBREAK, OCONTINUE, OFALL, OGOTO: + // ok + default: + panic("NewBranch " + op.String()) + } + n := &BranchStmt{Label: label} + n.pos = pos + n.op = op + return n +} + +func (n *BranchStmt) SetOp(op Op) { + switch op { + default: + panic(n.no("SetOp " + op.String())) + case OBREAK, OCONTINUE, OFALL, OGOTO: + n.op = op + } +} + +func (n *BranchStmt) Sym() *types.Sym { return n.Label } + +// A CaseClause is a case statement in a switch or select: case List: Body. +type CaseClause struct { + miniStmt + Var *Name // declared variable for this case in type switch + List Nodes // list of expressions for switch, early select + + // RTypes is a list of RType expressions, which are copied to the + // corresponding OEQ nodes that are emitted when switch statements + // are desugared. RTypes[i] must be non-nil if the emitted + // comparison for List[i] will be a mixed interface/concrete + // comparison; see reflectdata.CompareRType for details. + // + // Because mixed interface/concrete switch cases are rare, we allow + // len(RTypes) < len(List). Missing entries are implicitly nil. + RTypes Nodes + + Body Nodes +} + +func NewCaseStmt(pos src.XPos, list, body []Node) *CaseClause { + n := &CaseClause{List: list, Body: body} + n.pos = pos + n.op = OCASE + return n +} + +type CommClause struct { + miniStmt + Comm Node // communication case + Body Nodes +} + +func NewCommStmt(pos src.XPos, comm Node, body []Node) *CommClause { + n := &CommClause{Comm: comm, Body: body} + n.pos = pos + n.op = OCASE + return n +} + +// A ForStmt is a non-range for loop: for Init; Cond; Post { Body } +type ForStmt struct { + miniStmt + Label *types.Sym + Cond Node + Post Node + Body Nodes + DistinctVars bool +} + +func NewForStmt(pos src.XPos, init Node, cond, post Node, body []Node, distinctVars bool) *ForStmt { + n := &ForStmt{Cond: cond, Post: post} + n.pos = pos + n.op = OFOR + if init != nil { + n.init = []Node{init} + } + n.Body = body + n.DistinctVars = distinctVars + return n +} + +// A GoDeferStmt is a go or defer statement: go Call / defer Call. +// +// The two opcodes use a single syntax because the implementations +// are very similar: both are concerned with saving Call and running it +// in a different context (a separate goroutine or a later time). +type GoDeferStmt struct { + miniStmt + Call Node + DeferAt Expr +} + +func NewGoDeferStmt(pos src.XPos, op Op, call Node) *GoDeferStmt { + n := &GoDeferStmt{Call: call} + n.pos = pos + switch op { + case ODEFER, OGO: + n.op = op + default: + panic("NewGoDeferStmt " + op.String()) + } + return n +} + +// An IfStmt is a return statement: if Init; Cond { Body } else { Else }. +type IfStmt struct { + miniStmt + Cond Node + Body Nodes + Else Nodes + Likely bool // code layout hint +} + +func NewIfStmt(pos src.XPos, cond Node, body, els []Node) *IfStmt { + n := &IfStmt{Cond: cond} + n.pos = pos + n.op = OIF + n.Body = body + n.Else = els + return n +} + +// A JumpTableStmt is used to implement switches. Its semantics are: +// +// tmp := jt.Idx +// if tmp == Cases[0] goto Targets[0] +// if tmp == Cases[1] goto Targets[1] +// ... +// if tmp == Cases[n] goto Targets[n] +// +// Note that a JumpTableStmt is more like a multiway-goto than +// a multiway-if. In particular, the case bodies are just +// labels to jump to, not full Nodes lists. +type JumpTableStmt struct { + miniStmt + + // Value used to index the jump table. + // We support only integer types that + // are at most the size of a uintptr. + Idx Node + + // If Idx is equal to Cases[i], jump to Targets[i]. + // Cases entries must be distinct and in increasing order. + // The length of Cases and Targets must be equal. + Cases []constant.Value + Targets []*types.Sym +} + +func NewJumpTableStmt(pos src.XPos, idx Node) *JumpTableStmt { + n := &JumpTableStmt{Idx: idx} + n.pos = pos + n.op = OJUMPTABLE + return n +} + +// An InterfaceSwitchStmt is used to implement type switches. +// Its semantics are: +// +// if RuntimeType implements Descriptor.Cases[0] { +// Case, Itab = 0, itab +// } else if RuntimeType implements Descriptor.Cases[1] { +// Case, Itab = 1, itab +// ... +// } else if RuntimeType implements Descriptor.Cases[N-1] { +// Case, Itab = N-1, itab +// } else { +// Case, Itab = len(cases), nil +// } +// +// RuntimeType must be a non-nil *runtime._type. +// Hash must be the hash field of RuntimeType (or its copy loaded from an itab). +// Descriptor must represent an abi.InterfaceSwitch global variable. +type InterfaceSwitchStmt struct { + miniStmt + + Case Node + Itab Node + RuntimeType Node + Hash Node + Descriptor *obj.LSym +} + +func NewInterfaceSwitchStmt(pos src.XPos, case_, itab, runtimeType, hash Node, descriptor *obj.LSym) *InterfaceSwitchStmt { + n := &InterfaceSwitchStmt{ + Case: case_, + Itab: itab, + RuntimeType: runtimeType, + Hash: hash, + Descriptor: descriptor, + } + n.pos = pos + n.op = OINTERFACESWITCH + return n +} + +// An InlineMarkStmt is a marker placed just before an inlined body. +type InlineMarkStmt struct { + miniStmt + Index int64 +} + +func NewInlineMarkStmt(pos src.XPos, index int64) *InlineMarkStmt { + n := &InlineMarkStmt{Index: index} + n.pos = pos + n.op = OINLMARK + return n +} + +func (n *InlineMarkStmt) Offset() int64 { return n.Index } +func (n *InlineMarkStmt) SetOffset(x int64) { n.Index = x } + +// A LabelStmt is a label statement (just the label, not including the statement it labels). +type LabelStmt struct { + miniStmt + Label *types.Sym // "Label:" +} + +func NewLabelStmt(pos src.XPos, label *types.Sym) *LabelStmt { + n := &LabelStmt{Label: label} + n.pos = pos + n.op = OLABEL + return n +} + +func (n *LabelStmt) Sym() *types.Sym { return n.Label } + +// A RangeStmt is a range loop: for Key, Value = range X { Body } +type RangeStmt struct { + miniStmt + Label *types.Sym + Def bool + X Node + RType Node `mknode:"-"` // see reflectdata/helpers.go + Key Node + Value Node + Body Nodes + DistinctVars bool + Prealloc *Name + + // When desugaring the RangeStmt during walk, the assignments to Key + // and Value may require OCONVIFACE operations. If so, these fields + // will be copied to their respective ConvExpr fields. + KeyTypeWord Node `mknode:"-"` + KeySrcRType Node `mknode:"-"` + ValueTypeWord Node `mknode:"-"` + ValueSrcRType Node `mknode:"-"` +} + +func NewRangeStmt(pos src.XPos, key, value, x Node, body []Node, distinctVars bool) *RangeStmt { + n := &RangeStmt{X: x, Key: key, Value: value} + n.pos = pos + n.op = ORANGE + n.Body = body + n.DistinctVars = distinctVars + return n +} + +// A ReturnStmt is a return statement. +type ReturnStmt struct { + miniStmt + Results Nodes // return list +} + +func NewReturnStmt(pos src.XPos, results []Node) *ReturnStmt { + n := &ReturnStmt{} + n.pos = pos + n.op = ORETURN + n.Results = results + return n +} + +// A SelectStmt is a block: { Cases }. +type SelectStmt struct { + miniStmt + Label *types.Sym + Cases []*CommClause + + // TODO(rsc): Instead of recording here, replace with a block? + Compiled Nodes // compiled form, after walkSelect +} + +func NewSelectStmt(pos src.XPos, cases []*CommClause) *SelectStmt { + n := &SelectStmt{Cases: cases} + n.pos = pos + n.op = OSELECT + return n +} + +// A SendStmt is a send statement: X <- Y. +type SendStmt struct { + miniStmt + Chan Node + Value Node +} + +func NewSendStmt(pos src.XPos, ch, value Node) *SendStmt { + n := &SendStmt{Chan: ch, Value: value} + n.pos = pos + n.op = OSEND + return n +} + +// A SwitchStmt is a switch statement: switch Init; Tag { Cases }. +type SwitchStmt struct { + miniStmt + Tag Node + Cases []*CaseClause + Label *types.Sym + + // TODO(rsc): Instead of recording here, replace with a block? + Compiled Nodes // compiled form, after walkSwitch +} + +func NewSwitchStmt(pos src.XPos, tag Node, cases []*CaseClause) *SwitchStmt { + n := &SwitchStmt{Tag: tag, Cases: cases} + n.pos = pos + n.op = OSWITCH + return n +} + +// A TailCallStmt is a tail call statement, which is used for back-end +// code generation to jump directly to another function entirely. +type TailCallStmt struct { + miniStmt + Call *CallExpr // the underlying call +} + +func NewTailCallStmt(pos src.XPos, call *CallExpr) *TailCallStmt { + n := &TailCallStmt{Call: call} + n.pos = pos + n.op = OTAILCALL + return n +} + +// A TypeSwitchGuard is the [Name :=] X.(type) in a type switch. +type TypeSwitchGuard struct { + miniNode + Tag *Ident + X Node + Used bool +} + +func NewTypeSwitchGuard(pos src.XPos, tag *Ident, x Node) *TypeSwitchGuard { + n := &TypeSwitchGuard{Tag: tag, X: x} + n.pos = pos + n.op = OTYPESW + return n +} diff --git a/go/src/cmd/compile/internal/ir/symtab.go b/go/src/cmd/compile/internal/ir/symtab.go new file mode 100644 index 0000000000000000000000000000000000000000..f0e91f6db360130aa19cd326db8ecfc795564e26 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/symtab.go @@ -0,0 +1,102 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "cmd/compile/internal/types" + "cmd/internal/obj" +) + +// Syms holds known symbols. +var Syms symsStruct + +type symsStruct struct { + AssertE2I *obj.LSym + AssertE2I2 *obj.LSym + Asanread *obj.LSym + Asanwrite *obj.LSym + CgoCheckMemmove *obj.LSym + CgoCheckPtrWrite *obj.LSym + CheckPtrAlignment *obj.LSym + Deferproc *obj.LSym + Deferprocat *obj.LSym + DeferprocStack *obj.LSym + Deferreturn *obj.LSym + Duffcopy *obj.LSym + Duffzero *obj.LSym + GCWriteBarrier [8]*obj.LSym + Goschedguarded *obj.LSym + Growslice *obj.LSym + GrowsliceBuf *obj.LSym + GrowsliceBufNoAlias *obj.LSym + GrowsliceNoAlias *obj.LSym + MoveSlice *obj.LSym + MoveSliceNoScan *obj.LSym + MoveSliceNoCap *obj.LSym + MoveSliceNoCapNoScan *obj.LSym + InterfaceSwitch *obj.LSym + MallocGC *obj.LSym + MallocGCSmallNoScan [27]*obj.LSym + MallocGCSmallScanNoHeader [27]*obj.LSym + MallocGCTiny [16]*obj.LSym + Memmove *obj.LSym + Memequal *obj.LSym + Msanread *obj.LSym + Msanwrite *obj.LSym + Msanmove *obj.LSym + Newobject *obj.LSym + Newproc *obj.LSym + PanicBounds *obj.LSym + PanicExtend *obj.LSym + Panicdivide *obj.LSym + Panicshift *obj.LSym + PanicdottypeE *obj.LSym + PanicdottypeI *obj.LSym + Panicnildottype *obj.LSym + Panicoverflow *obj.LSym + PanicSimdImm *obj.LSym + Racefuncenter *obj.LSym + Racefuncexit *obj.LSym + Raceread *obj.LSym + Racereadrange *obj.LSym + Racewrite *obj.LSym + Racewriterange *obj.LSym + TypeAssert *obj.LSym + WBZero *obj.LSym + WBMove *obj.LSym + // Wasm + SigPanic *obj.LSym + Staticuint64s *obj.LSym + Typedmemmove *obj.LSym + Udiv *obj.LSym + WriteBarrier *obj.LSym + Zerobase *obj.LSym + ZeroVal *obj.LSym + ARM64HasATOMICS *obj.LSym + ARMHasVFPv4 *obj.LSym + Loong64HasLAMCAS *obj.LSym + Loong64HasLAM_BH *obj.LSym + Loong64HasLSX *obj.LSym + RISCV64HasZbb *obj.LSym + X86HasAVX *obj.LSym + X86HasFMA *obj.LSym + X86HasPOPCNT *obj.LSym + X86HasSSE41 *obj.LSym + // Wasm + WasmDiv *obj.LSym + // Wasm + WasmTruncS *obj.LSym + // Wasm + WasmTruncU *obj.LSym +} + +// Pkgs holds known packages. +var Pkgs struct { + Go *types.Pkg + Itab *types.Pkg + Runtime *types.Pkg + InternalMaps *types.Pkg + Coverage *types.Pkg +} diff --git a/go/src/cmd/compile/internal/ir/type.go b/go/src/cmd/compile/internal/ir/type.go new file mode 100644 index 0000000000000000000000000000000000000000..0f44cf8d04771eb97d42663f4295c2f37b63a0f6 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/type.go @@ -0,0 +1,93 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +// Calling TypeNode converts a *types.Type to a Node shell. + +// A typeNode is a Node wrapper for type t. +type typeNode struct { + miniNode + typ *types.Type +} + +func newTypeNode(typ *types.Type) *typeNode { + n := &typeNode{typ: typ} + n.pos = src.NoXPos + n.op = OTYPE + n.SetTypecheck(1) + return n +} + +func (n *typeNode) Type() *types.Type { return n.typ } +func (n *typeNode) Sym() *types.Sym { return n.typ.Sym() } + +// TypeNode returns the Node representing the type t. +func TypeNode(t *types.Type) Node { + if n := t.Obj(); n != nil { + if n.Type() != t { + base.Fatalf("type skew: %v has type %v, but expected %v", n, n.Type(), t) + } + return n.(*Name) + } + return newTypeNode(t) +} + +// A DynamicType represents a type expression whose exact type must be +// computed dynamically. +// +// TODO(adonovan): I think "dynamic" is a misnomer here; it's really a +// type with free type parameters that needs to be instantiated to obtain +// a ground type for which an rtype can exist. +type DynamicType struct { + miniExpr + + // RType is an expression that yields a *runtime._type value + // representing the asserted type. + // + // BUG(mdempsky): If ITab is non-nil, RType may be nil. + RType Node + + // ITab is an expression that yields a *runtime.itab value + // representing the asserted type within the assertee expression's + // original interface type. + // + // ITab is only used for assertions (including type switches) from + // non-empty interface type to a concrete (i.e., non-interface) + // type. For all other assertions, ITab is nil. + ITab Node +} + +func NewDynamicType(pos src.XPos, rtype Node) *DynamicType { + n := &DynamicType{RType: rtype} + n.pos = pos + n.op = ODYNAMICTYPE + return n +} + +// ToStatic returns static type of dt if it is actually static. +func (dt *DynamicType) ToStatic() Node { + if dt.Typecheck() == 0 { + base.Fatalf("missing typecheck: %v", dt) + } + if dt.RType != nil && dt.RType.Op() == OADDR { + addr := dt.RType.(*AddrExpr) + if addr.X.Op() == OLINKSYMOFFSET { + return TypeNode(dt.Type()) + } + } + if dt.ITab != nil && dt.ITab.Op() == OADDR { + addr := dt.ITab.(*AddrExpr) + if addr.X.Op() == OLINKSYMOFFSET { + return TypeNode(dt.Type()) + } + } + return nil +} diff --git a/go/src/cmd/compile/internal/ir/val.go b/go/src/cmd/compile/internal/ir/val.go new file mode 100644 index 0000000000000000000000000000000000000000..16c8a08ca0ddffd7a65ba1c97e07056ddd5c369f --- /dev/null +++ b/go/src/cmd/compile/internal/ir/val.go @@ -0,0 +1,107 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ir + +import ( + "go/constant" + + "cmd/compile/internal/base" + "cmd/compile/internal/types" +) + +func ConstType(n Node) constant.Kind { + if n == nil || n.Op() != OLITERAL { + return constant.Unknown + } + return n.Val().Kind() +} + +// IntVal returns v converted to int64. +// Note: if t is uint64, very large values will be converted to negative int64. +func IntVal(t *types.Type, v constant.Value) int64 { + if t.IsUnsigned() { + if x, ok := constant.Uint64Val(v); ok { + return int64(x) + } + } else { + if x, ok := constant.Int64Val(v); ok { + return x + } + } + base.Fatalf("%v out of range for %v", v, t) + panic("unreachable") +} + +func AssertValidTypeForConst(t *types.Type, v constant.Value) { + if !ValidTypeForConst(t, v) { + base.Fatalf("%v (%v) does not represent %v (%v)", t, t.Kind(), v, v.Kind()) + } +} + +func ValidTypeForConst(t *types.Type, v constant.Value) bool { + switch v.Kind() { + case constant.Unknown: + return OKForConst[t.Kind()] + case constant.Bool: + return t.IsBoolean() + case constant.String: + return t.IsString() + case constant.Int: + return t.IsInteger() + case constant.Float: + return t.IsFloat() + case constant.Complex: + return t.IsComplex() + } + + base.Fatalf("unexpected constant kind: %v", v) + panic("unreachable") +} + +var OKForConst [types.NTYPE]bool + +// Int64Val returns n as an int64. +// n must be an integer or rune constant. +func Int64Val(n Node) int64 { + if !IsConst(n, constant.Int) { + base.Fatalf("Int64Val(%v)", n) + } + x, ok := constant.Int64Val(n.Val()) + if !ok { + base.Fatalf("Int64Val(%v)", n) + } + return x +} + +// Uint64Val returns n as a uint64. +// n must be an integer or rune constant. +func Uint64Val(n Node) uint64 { + if !IsConst(n, constant.Int) { + base.Fatalf("Uint64Val(%v)", n) + } + x, ok := constant.Uint64Val(n.Val()) + if !ok { + base.Fatalf("Uint64Val(%v)", n) + } + return x +} + +// BoolVal returns n as a bool. +// n must be a boolean constant. +func BoolVal(n Node) bool { + if !IsConst(n, constant.Bool) { + base.Fatalf("BoolVal(%v)", n) + } + return constant.BoolVal(n.Val()) +} + +// StringVal returns the value of a literal string Node as a string. +// n must be a string constant. +func StringVal(n Node) string { + if !IsConst(n, constant.String) { + base.Fatalf("StringVal(%v)", n) + } + return constant.StringVal(n.Val()) +} diff --git a/go/src/cmd/compile/internal/ir/visit.go b/go/src/cmd/compile/internal/ir/visit.go new file mode 100644 index 0000000000000000000000000000000000000000..c68bb5d0330337cac0ee8b2fc903187990241cd5 --- /dev/null +++ b/go/src/cmd/compile/internal/ir/visit.go @@ -0,0 +1,208 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// IR visitors for walking the IR tree. +// +// The lowest level helpers are DoChildren and EditChildren, which +// nodes help implement and provide control over whether and when +// recursion happens during the walk of the IR. +// +// Although these are both useful directly, two simpler patterns +// are fairly common and also provided: Visit and Any. + +package ir + +// DoChildren calls do(x) on each of n's non-nil child nodes x. +// If any call returns true, DoChildren stops and returns true. +// Otherwise, DoChildren returns false. +// +// Note that DoChildren(n, do) only calls do(x) for n's immediate children. +// If x's children should be processed, then do(x) must call DoChildren(x, do). +// +// DoChildren allows constructing general traversals of the IR graph +// that can stop early if needed. The most general usage is: +// +// var do func(ir.Node) bool +// do = func(x ir.Node) bool { +// ... processing BEFORE visiting children ... +// if ... should visit children ... { +// ir.DoChildren(x, do) +// ... processing AFTER visiting children ... +// } +// if ... should stop parent DoChildren call from visiting siblings ... { +// return true +// } +// return false +// } +// do(root) +// +// Since DoChildren does not return true itself, if the do function +// never wants to stop the traversal, it can assume that DoChildren +// itself will always return false, simplifying to: +// +// var do func(ir.Node) bool +// do = func(x ir.Node) bool { +// ... processing BEFORE visiting children ... +// if ... should visit children ... { +// ir.DoChildren(x, do) +// } +// ... processing AFTER visiting children ... +// return false +// } +// do(root) +// +// The Visit function illustrates a further simplification of the pattern, +// only processing before visiting children and never stopping: +// +// func Visit(n ir.Node, visit func(ir.Node)) { +// if n == nil { +// return +// } +// var do func(ir.Node) bool +// do = func(x ir.Node) bool { +// visit(x) +// return ir.DoChildren(x, do) +// } +// do(n) +// } +// +// The Any function illustrates a different simplification of the pattern, +// visiting each node and then its children, recursively, until finding +// a node x for which cond(x) returns true, at which point the entire +// traversal stops and returns true. +// +// func Any(n ir.Node, cond(ir.Node) bool) bool { +// if n == nil { +// return false +// } +// var do func(ir.Node) bool +// do = func(x ir.Node) bool { +// return cond(x) || ir.DoChildren(x, do) +// } +// return do(n) +// } +// +// Visit and Any are presented above as examples of how to use +// DoChildren effectively, but of course, usage that fits within the +// simplifications captured by Visit or Any will be best served +// by directly calling the ones provided by this package. +func DoChildren(n Node, do func(Node) bool) bool { + if n == nil { + return false + } + return n.doChildren(do) +} + +// DoChildrenWithHidden is like DoChildren, but also visits +// Node-typed fields tagged with `mknode:"-"`. +// +// TODO(mdempsky): Remove the `mknode:"-"` tags so this function can +// go away. +func DoChildrenWithHidden(n Node, do func(Node) bool) bool { + if n == nil { + return false + } + return n.doChildrenWithHidden(do) +} + +// Visit visits each non-nil node x in the IR tree rooted at n +// in a depth-first preorder traversal, calling visit on each node visited. +func Visit(n Node, visit func(Node)) { + if n == nil { + return + } + var do func(Node) bool + do = func(x Node) bool { + visit(x) + return DoChildren(x, do) + } + do(n) +} + +// VisitList calls Visit(x, visit) for each node x in the list. +func VisitList(list Nodes, visit func(Node)) { + for _, x := range list { + Visit(x, visit) + } +} + +// VisitFuncAndClosures calls visit on each non-nil node in fn.Body, +// including any nested closure bodies. +func VisitFuncAndClosures(fn *Func, visit func(n Node)) { + VisitList(fn.Body, func(n Node) { + visit(n) + if n, ok := n.(*ClosureExpr); ok && n.Op() == OCLOSURE { + VisitFuncAndClosures(n.Func, visit) + } + }) +} + +// Any looks for a non-nil node x in the IR tree rooted at n +// for which cond(x) returns true. +// Any considers nodes in a depth-first, preorder traversal. +// When Any finds a node x such that cond(x) is true, +// Any ends the traversal and returns true immediately. +// Otherwise Any returns false after completing the entire traversal. +func Any(n Node, cond func(Node) bool) bool { + if n == nil { + return false + } + var do func(Node) bool + do = func(x Node) bool { + return cond(x) || DoChildren(x, do) + } + return do(n) +} + +// EditChildren edits the child nodes of n, replacing each child x with edit(x). +// +// Note that EditChildren(n, edit) only calls edit(x) for n's immediate children. +// If x's children should be processed, then edit(x) must call EditChildren(x, edit). +// +// EditChildren allows constructing general editing passes of the IR graph. +// The most general usage is: +// +// var edit func(ir.Node) ir.Node +// edit = func(x ir.Node) ir.Node { +// ... processing BEFORE editing children ... +// if ... should edit children ... { +// EditChildren(x, edit) +// ... processing AFTER editing children ... +// } +// ... return x ... +// } +// n = edit(n) +// +// EditChildren edits the node in place. To edit a copy, call Copy first. +// As an example, a simple deep copy implementation would be: +// +// func deepCopy(n ir.Node) ir.Node { +// var edit func(ir.Node) ir.Node +// edit = func(x ir.Node) ir.Node { +// x = ir.Copy(x) +// ir.EditChildren(x, edit) +// return x +// } +// return edit(n) +// } +// +// Of course, in this case it is better to call ir.DeepCopy than to build one anew. +func EditChildren(n Node, edit func(Node) Node) { + if n == nil { + return + } + n.editChildren(edit) +} + +// EditChildrenWithHidden is like EditChildren, but also edits +// Node-typed fields tagged with `mknode:"-"`. +// +// TODO(mdempsky): Remove the `mknode:"-"` tags so this function can +// go away. +func EditChildrenWithHidden(n Node, edit func(Node) Node) { + if n == nil { + return + } + n.editChildrenWithHidden(edit) +} diff --git a/go/src/cmd/compile/internal/liveness/arg.go b/go/src/cmd/compile/internal/liveness/arg.go new file mode 100644 index 0000000000000000000000000000000000000000..77960f5e15a1f9314f51c638379f84ed5059834e --- /dev/null +++ b/go/src/cmd/compile/internal/liveness/arg.go @@ -0,0 +1,339 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package liveness + +import ( + "fmt" + "internal/abi" + + "cmd/compile/internal/base" + "cmd/compile/internal/bitvec" + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/ssa" + "cmd/internal/obj" +) + +// Argument liveness tracking. +// +// For arguments passed in registers, this file tracks if their spill slots +// are live for runtime traceback. An argument spill slot is live at a PC +// if we know that an actual value has stored into it at or before this point. +// +// Stack args are always live and not tracked in this code. Stack args are +// laid out before register spill slots, so we emit the smallest offset that +// needs tracking. Slots before that offset are always live. That offset is +// usually the offset of the first spill slot. But if the first spill slot is +// always live (e.g. if it is address-taken), it will be the offset of a later +// one. +// +// The liveness information is emitted as a FUNCDATA and a PCDATA. +// +// FUNCDATA format: +// - start (smallest) offset that needs tracking (1 byte) +// - a list of bitmaps. +// In a bitmap bit i is set if the i-th spill slot is live. +// +// At a PC where the liveness info changes, a PCDATA indicates the +// byte offset of the liveness map in the FUNCDATA. PCDATA -1 is a +// special case indicating all slots are live (for binary size +// saving). + +const allLiveIdx = -1 + +// name and offset +type nameOff struct { + n *ir.Name + off int64 +} + +func (a nameOff) FrameOffset() int64 { return a.n.FrameOffset() + a.off } +func (a nameOff) String() string { return fmt.Sprintf("%v+%d", a.n, a.off) } + +type blockArgEffects struct { + livein bitvec.BitVec // variables live at block entry + liveout bitvec.BitVec // variables live at block exit +} + +type argLiveness struct { + fn *ir.Func + f *ssa.Func + args []nameOff // name and offset of spill slots + idx map[nameOff]int32 // index in args + + be []blockArgEffects // indexed by block ID + + bvset bvecSet // Set of liveness bitmaps, used for uniquifying. + + // Liveness map indices at each Value (where it changes) and Block entry. + // During the computation the indices are temporarily index to bvset. + // At the end they will be index (offset) to the output funcdata (changed + // in (*argLiveness).emit). + blockIdx map[ssa.ID]int + valueIdx map[ssa.ID]int +} + +// ArgLiveness computes the liveness information of register argument spill slots. +// An argument's spill slot is "live" if we know it contains a meaningful value, +// that is, we have stored the register value to it. +// Returns the liveness map indices at each Block entry and at each Value (where +// it changes). +func ArgLiveness(fn *ir.Func, f *ssa.Func, pp *objw.Progs) (blockIdx, valueIdx map[ssa.ID]int) { + if f.OwnAux.ABIInfo().InRegistersUsed() == 0 || base.Flag.N != 0 { + // No register args. Nothing to emit. + // Or if -N is used we spill everything upfront so it is always live. + return nil, nil + } + + lv := &argLiveness{ + fn: fn, + f: f, + idx: make(map[nameOff]int32), + be: make([]blockArgEffects, f.NumBlocks()), + blockIdx: make(map[ssa.ID]int), + valueIdx: make(map[ssa.ID]int), + } + // Gather all register arg spill slots. + for _, a := range f.OwnAux.ABIInfo().InParams() { + n := a.Name + if n == nil || len(a.Registers) == 0 { + continue + } + _, offs := a.RegisterTypesAndOffsets() + for _, off := range offs { + if n.FrameOffset()+off > 0xff { + // We only print a limited number of args, with stack + // offsets no larger than 255. + continue + } + lv.args = append(lv.args, nameOff{n, off}) + } + } + if len(lv.args) > 10 { + lv.args = lv.args[:10] // We print no more than 10 args. + } + + // We spill address-taken or non-SSA-able value upfront, so they are always live. + alwaysLive := func(n *ir.Name) bool { return n.Addrtaken() || !ssa.CanSSA(n.Type()) } + + // We'll emit the smallest offset for the slots that need liveness info. + // No need to include a slot with a lower offset if it is always live. + for len(lv.args) > 0 && alwaysLive(lv.args[0].n) { + lv.args = lv.args[1:] + } + if len(lv.args) == 0 { + return // everything is always live + } + + for i, a := range lv.args { + lv.idx[a] = int32(i) + } + + nargs := int32(len(lv.args)) + bulk := bitvec.NewBulk(nargs, int32(len(f.Blocks)*2), fn.Pos()) + for _, b := range f.Blocks { + be := &lv.be[b.ID] + be.livein = bulk.Next() + be.liveout = bulk.Next() + + // initialize to all 1s, so we can AND them + be.livein.Not() + be.liveout.Not() + } + + entrybe := &lv.be[f.Entry.ID] + entrybe.livein.Clear() + for i, a := range lv.args { + if alwaysLive(a.n) { + entrybe.livein.Set(int32(i)) + } + } + + // Visit blocks in reverse-postorder, compute block effects. + po := f.Postorder() + for i := len(po) - 1; i >= 0; i-- { + b := po[i] + be := &lv.be[b.ID] + + // A slot is live at block entry if it is live in all predecessors. + for _, pred := range b.Preds { + pb := pred.Block() + be.livein.And(be.livein, lv.be[pb.ID].liveout) + } + + be.liveout.Copy(be.livein) + for _, v := range b.Values { + lv.valueEffect(v, be.liveout) + } + } + + // Coalesce identical live vectors. Compute liveness indices at each PC + // where it changes. + live := bitvec.New(nargs) + addToSet := func(bv bitvec.BitVec) (int, bool) { + if bv.Count() == int(nargs) { // special case for all live + return allLiveIdx, false + } + return lv.bvset.add(bv) + } + for _, b := range lv.f.Blocks { + be := &lv.be[b.ID] + lv.blockIdx[b.ID], _ = addToSet(be.livein) + + live.Copy(be.livein) + var lastv *ssa.Value + for i, v := range b.Values { + if lv.valueEffect(v, live) { + // Record that liveness changes but not emit a map now. + // For a sequence of StoreRegs we only need to emit one + // at last. + lastv = v + } + if lastv != nil && (mayFault(v) || i == len(b.Values)-1) { + // Emit the liveness map if it may fault or at the end of + // the block. We may need a traceback if the instruction + // may cause a panic. + var added bool + lv.valueIdx[lastv.ID], added = addToSet(live) + if added { + // live is added to bvset and we cannot modify it now. + // Make a copy. + t := live + live = bitvec.New(nargs) + live.Copy(t) + } + lastv = nil + } + } + + // Sanity check. + if !live.Eq(be.liveout) { + panic("wrong arg liveness map at block end") + } + } + + // Emit funcdata symbol, update indices to offsets in the symbol data. + lsym := lv.emit() + fn.LSym.Func().ArgLiveInfo = lsym + + //lv.print() + + p := pp.Prog(obj.AFUNCDATA) + p.From.SetConst(abi.FUNCDATA_ArgLiveInfo) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = lsym + + return lv.blockIdx, lv.valueIdx +} + +// valueEffect applies the effect of v to live, return whether it is changed. +func (lv *argLiveness) valueEffect(v *ssa.Value, live bitvec.BitVec) bool { + if v.Op != ssa.OpStoreReg { // TODO: include other store instructions? + return false + } + n, off := ssa.AutoVar(v) + if n.Class != ir.PPARAM { + return false + } + i, ok := lv.idx[nameOff{n, off}] + if !ok || live.Get(i) { + return false + } + live.Set(i) + return true +} + +func mayFault(v *ssa.Value) bool { + switch v.Op { + case ssa.OpLoadReg, ssa.OpStoreReg, ssa.OpCopy, ssa.OpPhi, + ssa.OpVarDef, ssa.OpVarLive, ssa.OpKeepAlive, + ssa.OpSelect0, ssa.OpSelect1, ssa.OpSelectN, ssa.OpMakeResult, + ssa.OpConvert, ssa.OpInlMark, ssa.OpGetG: + return false + } + if len(v.Args) == 0 { + return false // assume constant op cannot fault + } + return true // conservatively assume all other ops could fault +} + +func (lv *argLiveness) print() { + fmt.Println("argument liveness:", lv.f.Name) + live := bitvec.New(int32(len(lv.args))) + for _, b := range lv.f.Blocks { + be := &lv.be[b.ID] + + fmt.Printf("%v: live in: ", b) + lv.printLivenessVec(be.livein) + if idx, ok := lv.blockIdx[b.ID]; ok { + fmt.Printf(" #%d", idx) + } + fmt.Println() + + for _, v := range b.Values { + if lv.valueEffect(v, live) { + fmt.Printf(" %v: ", v) + lv.printLivenessVec(live) + if idx, ok := lv.valueIdx[v.ID]; ok { + fmt.Printf(" #%d", idx) + } + fmt.Println() + } + } + + fmt.Printf("%v: live out: ", b) + lv.printLivenessVec(be.liveout) + fmt.Println() + } + fmt.Println("liveness maps data:", lv.fn.LSym.Func().ArgLiveInfo.P) +} + +func (lv *argLiveness) printLivenessVec(bv bitvec.BitVec) { + for i, a := range lv.args { + if bv.Get(int32(i)) { + fmt.Printf("%v ", a) + } + } +} + +func (lv *argLiveness) emit() *obj.LSym { + livenessMaps := lv.bvset.extractUnique() + + // stack offsets of register arg spill slots + argOffsets := make([]uint8, len(lv.args)) + for i, a := range lv.args { + off := a.FrameOffset() + if off > 0xff { + panic("offset too large") + } + argOffsets[i] = uint8(off) + } + + idx2off := make([]int, len(livenessMaps)) + + lsym := base.Ctxt.Lookup(lv.fn.LSym.Name + ".argliveinfo") + lsym.Set(obj.AttrContentAddressable, true) + + off := objw.Uint8(lsym, 0, argOffsets[0]) // smallest offset that needs liveness info. + for idx, live := range livenessMaps { + idx2off[idx] = off + off = objw.BitVec(lsym, off, live) + } + + // Update liveness indices to offsets. + for i, x := range lv.blockIdx { + if x != allLiveIdx { + lv.blockIdx[i] = idx2off[x] + } + } + for i, x := range lv.valueIdx { + if x != allLiveIdx { + lv.valueIdx[i] = idx2off[x] + } + } + + return lsym +} diff --git a/go/src/cmd/compile/internal/liveness/bvset.go b/go/src/cmd/compile/internal/liveness/bvset.go new file mode 100644 index 0000000000000000000000000000000000000000..60b25938677c85c1ce7c07be102159230f506637 --- /dev/null +++ b/go/src/cmd/compile/internal/liveness/bvset.go @@ -0,0 +1,98 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package liveness + +import "cmd/compile/internal/bitvec" + +// FNV-1 hash function constants. +const ( + h0 = 2166136261 + hp = 16777619 +) + +// bvecSet is a set of bvecs, in initial insertion order. +type bvecSet struct { + index []int // hash -> uniq index. -1 indicates empty slot. + uniq []bitvec.BitVec // unique bvecs, in insertion order +} + +func (m *bvecSet) grow() { + // Allocate new index. + n := len(m.index) * 2 + if n == 0 { + n = 32 + } + newIndex := make([]int, n) + for i := range newIndex { + newIndex[i] = -1 + } + + // Rehash into newIndex. + for i, bv := range m.uniq { + h := hashbitmap(h0, bv) % uint32(len(newIndex)) + for { + j := newIndex[h] + if j < 0 { + newIndex[h] = i + break + } + h++ + if h == uint32(len(newIndex)) { + h = 0 + } + } + } + m.index = newIndex +} + +// add adds bv to the set and returns its index in m.extractUnique, +// and whether it is newly added. +// If it is newly added, the caller must not modify bv after this. +func (m *bvecSet) add(bv bitvec.BitVec) (int, bool) { + if len(m.uniq)*4 >= len(m.index) { + m.grow() + } + + index := m.index + h := hashbitmap(h0, bv) % uint32(len(index)) + for { + j := index[h] + if j < 0 { + // New bvec. + index[h] = len(m.uniq) + m.uniq = append(m.uniq, bv) + return len(m.uniq) - 1, true + } + jlive := m.uniq[j] + if bv.Eq(jlive) { + // Existing bvec. + return j, false + } + + h++ + if h == uint32(len(index)) { + h = 0 + } + } +} + +// extractUnique returns this slice of unique bit vectors in m, as +// indexed by the result of bvecSet.add. +func (m *bvecSet) extractUnique() []bitvec.BitVec { + return m.uniq +} + +func hashbitmap(h uint32, bv bitvec.BitVec) uint32 { + n := int((bv.N + 31) / 32) + for i := 0; i < n; i++ { + w := bv.B[i] + h = (h * hp) ^ (w & 0xff) + h = (h * hp) ^ ((w >> 8) & 0xff) + h = (h * hp) ^ ((w >> 16) & 0xff) + h = (h * hp) ^ ((w >> 24) & 0xff) + } + + return h +} diff --git a/go/src/cmd/compile/internal/liveness/intervals.go b/go/src/cmd/compile/internal/liveness/intervals.go new file mode 100644 index 0000000000000000000000000000000000000000..04b1ea50bad135ad3c17f02a484f4cbf7d51e0c6 --- /dev/null +++ b/go/src/cmd/compile/internal/liveness/intervals.go @@ -0,0 +1,384 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package liveness + +// This file defines an "Intervals" helper type that stores a +// sorted sequence of disjoint ranges or intervals. An Intervals +// example: { [0,5) [9-12) [100,101) }, which corresponds to the +// numbers 0-4, 9-11, and 100. Once an Intervals object is created, it +// can be tested to see if it has any overlap with another Intervals +// object, or it can be merged with another Intervals object to form a +// union of the two. +// +// The intended use case for this helper is in describing object or +// variable lifetime ranges within a linearized program representation +// where each IR instruction has a slot or index. Example: +// +// b1: +// 0 VarDef abc +// 1 memset(abc,0) +// 2 VarDef xyz +// 3 memset(xyz,0) +// 4 abc.f1 = 2 +// 5 xyz.f3 = 9 +// 6 if q goto B4 +// 7 B3: z = xyz.x +// 8 goto B5 +// 9 B4: z = abc.x +// // fallthrough +// 10 B5: z++ +// +// To describe the lifetime of the variables above we might use these +// intervals: +// +// "abc" [1,7), [9,10) +// "xyz" [3,8) +// +// Clients can construct an Intervals object from a given IR sequence +// using the "IntervalsBuilder" helper abstraction (one builder per +// candidate variable), by making a +// backwards sweep and invoking the Live/Kill methods to note the +// starts and end of a given lifetime. For the example above, we would +// expect to see this sequence of calls to Live/Kill: +// +// abc: Live(9), Kill(8), Live(6), Kill(0) +// xyz: Live(8), Kill(2) + +import ( + "fmt" + "os" + "slices" + "strings" +) + +const debugtrace = false + +// Interval hols the range [st,en). +type Interval struct { + st, en int +} + +// Intervals is a sequence of sorted, disjoint intervals. +type Intervals []Interval + +func (i Interval) String() string { + return fmt.Sprintf("[%d,%d)", i.st, i.en) +} + +// TEMPORARY until bootstrap version catches up. +func imin(i, j int) int { + if i < j { + return i + } + return j +} + +// TEMPORARY until bootstrap version catches up. +func imax(i, j int) int { + if i > j { + return i + } + return j +} + +// Overlaps returns true if here is any overlap between i and i2. +func (i Interval) Overlaps(i2 Interval) bool { + return (imin(i.en, i2.en) - imax(i.st, i2.st)) > 0 +} + +// adjacent returns true if the start of one interval is equal to the +// end of another interval (e.g. they represent consecutive ranges). +func (i1 Interval) adjacent(i2 Interval) bool { + return i1.en == i2.st || i2.en == i1.st +} + +// MergeInto merges interval i2 into i1. This version happens to +// require that the two intervals either overlap or are adjacent. +func (i1 *Interval) MergeInto(i2 Interval) error { + if !i1.Overlaps(i2) && !i1.adjacent(i2) { + return fmt.Errorf("merge method invoked on non-overlapping/non-adjacent") + } + i1.st = imin(i1.st, i2.st) + i1.en = imax(i1.en, i2.en) + return nil +} + +// IntervalsBuilder is a helper for constructing intervals based on +// live dataflow sets for a series of BBs where we're making a +// backwards pass over each BB looking for uses and kills. The +// expected use case is: +// +// - invoke MakeIntervalsBuilder to create a new object "b" +// - series of calls to b.Live/b.Kill based on a backwards reverse layout +// order scan over instructions +// - invoke b.Finish() to produce final set +// +// See the Live method comment for an IR example. +type IntervalsBuilder struct { + s Intervals + // index of last instruction visited plus 1 + lidx int +} + +func (c *IntervalsBuilder) last() int { + return c.lidx - 1 +} + +func (c *IntervalsBuilder) setLast(x int) { + c.lidx = x + 1 +} + +func (c *IntervalsBuilder) Finish() (Intervals, error) { + // Reverse intervals list and check. + slices.Reverse(c.s) + if err := check(c.s); err != nil { + return Intervals{}, err + } + r := c.s + return r, nil +} + +// Live method should be invoked on instruction at position p if instr +// contains an upwards-exposed use of a resource. See the example in +// the comment at the beginning of this file for an example. +func (c *IntervalsBuilder) Live(pos int) error { + if pos < 0 { + return fmt.Errorf("bad pos, negative") + } + if c.last() == -1 { + c.setLast(pos) + if debugtrace { + fmt.Fprintf(os.Stderr, "=-= begin lifetime at pos=%d\n", pos) + } + c.s = append(c.s, Interval{st: pos, en: pos + 1}) + return nil + } + if pos >= c.last() { + return fmt.Errorf("pos not decreasing") + } + // extend lifetime across this pos + c.s[len(c.s)-1].st = pos + c.setLast(pos) + return nil +} + +// Kill method should be invoked on instruction at position p if instr +// should be treated as having a kill (lifetime end) for the +// resource. See the example in the comment at the beginning of this +// file for an example. Note that if we see a kill at position K for a +// resource currently live since J, this will result in a lifetime +// segment of [K+1,J+1), the assumption being that the first live +// instruction will be the one after the kill position, not the kill +// position itself. +func (c *IntervalsBuilder) Kill(pos int) error { + if pos < 0 { + return fmt.Errorf("bad pos, negative") + } + if c.last() == -1 { + return nil + } + if pos >= c.last() { + return fmt.Errorf("pos not decreasing") + } + c.s[len(c.s)-1].st = pos + 1 + // terminate lifetime + c.setLast(-1) + if debugtrace { + fmt.Fprintf(os.Stderr, "=-= term lifetime at pos=%d\n", pos) + } + return nil +} + +// check examines the intervals in "is" to try to find internal +// inconsistencies or problems. +func check(is Intervals) error { + for i := 0; i < len(is); i++ { + st := is[i].st + en := is[i].en + if en <= st { + return fmt.Errorf("bad range elem %d:%d, en<=st", st, en) + } + if i == 0 { + continue + } + // check for badly ordered starts + pst := is[i-1].st + pen := is[i-1].en + if pst >= st { + return fmt.Errorf("range start not ordered %d:%d less than prev %d:%d", st, en, + pst, pen) + } + // check end of last range against start of this range + if pen > st { + return fmt.Errorf("bad range elem %d:%d overlaps prev %d:%d", st, en, + pst, pen) + } + } + return nil +} + +func (is *Intervals) String() string { + var sb strings.Builder + for i := range *is { + if i != 0 { + sb.WriteString(" ") + } + sb.WriteString((*is)[i].String()) + } + return sb.String() +} + +// intWithIdx holds an interval i and an index pairIndex storing i's +// position (either 0 or 1) within some previously specified interval +// pair ; a pairIndex of -1 is used to signal "end of +// iteration". Used for Intervals operations, not expected to be +// exported. +type intWithIdx struct { + i Interval + pairIndex int +} + +func (iwi intWithIdx) done() bool { + return iwi.pairIndex == -1 +} + +// pairVisitor provides a way to visit (iterate through) each interval +// within a pair of Intervals in order of increasing start time. Expected +// usage model: +// +// func example(i1, i2 Intervals) { +// var pairVisitor pv +// cur := pv.init(i1, i2); +// for !cur.done() { +// fmt.Printf("interval %s from i%d", cur.i.String(), cur.pairIndex+1) +// cur = pv.nxt() +// } +// } +// +// Used internally for Intervals operations, not expected to be exported. +type pairVisitor struct { + cur intWithIdx + i1pos int + i2pos int + i1, i2 Intervals +} + +// init initializes a pairVisitor for the specified pair of intervals +// i1 and i2 and returns an intWithIdx object that points to the first +// interval by start position within i1/i2. +func (pv *pairVisitor) init(i1, i2 Intervals) intWithIdx { + pv.i1, pv.i2 = i1, i2 + pv.cur = pv.sel() + return pv.cur +} + +// nxt advances the pairVisitor to the next interval by starting +// position within the pair, returning an intWithIdx that describes +// the interval. +func (pv *pairVisitor) nxt() intWithIdx { + if pv.cur.pairIndex == 0 { + pv.i1pos++ + } else { + pv.i2pos++ + } + pv.cur = pv.sel() + return pv.cur +} + +// sel is a helper function used by 'init' and 'nxt' above; it selects +// the earlier of the two intervals at the current positions within i1 +// and i2, or a degenerate (pairIndex -1) intWithIdx if we have no +// more intervals to visit. +func (pv *pairVisitor) sel() intWithIdx { + var c1, c2 intWithIdx + if pv.i1pos >= len(pv.i1) { + c1.pairIndex = -1 + } else { + c1 = intWithIdx{i: pv.i1[pv.i1pos], pairIndex: 0} + } + if pv.i2pos >= len(pv.i2) { + c2.pairIndex = -1 + } else { + c2 = intWithIdx{i: pv.i2[pv.i2pos], pairIndex: 1} + } + if c1.pairIndex == -1 { + return c2 + } + if c2.pairIndex == -1 { + return c1 + } + if c1.i.st <= c2.i.st { + return c1 + } + return c2 +} + +// Overlaps returns whether any of the component ranges in is overlaps +// with some range in is2. +func (is Intervals) Overlaps(is2 Intervals) bool { + // check for empty intervals + if len(is) == 0 || len(is2) == 0 { + return false + } + li := len(is) + li2 := len(is2) + // check for completely disjoint ranges + if is[li-1].en <= is2[0].st || + is[0].st >= is2[li2-1].en { + return false + } + // walk the combined sets of intervals and check for piecewise + // overlap. + var pv pairVisitor + first := pv.init(is, is2) + for { + second := pv.nxt() + if second.done() { + break + } + if first.pairIndex == second.pairIndex { + first = second + continue + } + if first.i.Overlaps(second.i) { + return true + } + first = second + } + return false +} + +// Merge combines the intervals from "is" and "is2" and returns +// a new Intervals object containing all combined ranges from the +// two inputs. +func (is Intervals) Merge(is2 Intervals) Intervals { + if len(is) == 0 { + return is2 + } else if len(is2) == 0 { + return is + } + // walk the combined set of intervals and merge them together. + var ret Intervals + var pv pairVisitor + cur := pv.init(is, is2) + for { + second := pv.nxt() + if second.done() { + break + } + + // Check for overlap between cur and second. If no overlap + // then add cur to result and move on. + if !cur.i.Overlaps(second.i) && !cur.i.adjacent(second.i) { + ret = append(ret, cur.i) + cur = second + continue + } + // cur overlaps with second; merge second into cur + cur.i.MergeInto(second.i) + } + ret = append(ret, cur.i) + return ret +} diff --git a/go/src/cmd/compile/internal/liveness/intervals_test.go b/go/src/cmd/compile/internal/liveness/intervals_test.go new file mode 100644 index 0000000000000000000000000000000000000000..bf65a293b9577b582d7b3dfae568127ac1376c0c --- /dev/null +++ b/go/src/cmd/compile/internal/liveness/intervals_test.go @@ -0,0 +1,527 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package liveness + +import ( + "flag" + "fmt" + "math/rand" + "os" + "sort" + "testing" +) + +func TestMain(m *testing.M) { + flag.Parse() + os.Exit(m.Run()) +} + +func TestMakeAndPrint(t *testing.T) { + testcases := []struct { + inp []int + exp string + err bool + }{ + { + inp: []int{0, 1, 2, 3}, + exp: "[0,1) [2,3)", + }, + { // degenerate but legal + inp: []int{0, 1, 1, 2}, + exp: "[0,1) [1,2)", + }, + { // odd number of elems + inp: []int{0}, + err: true, + exp: "odd number of elems 1", + }, + { + // bad range element + inp: []int{0, 0}, + err: true, + exp: "bad range elem 0:0, en<=st", + }, + { + // overlap w/ previous + inp: []int{0, 9, 3, 12}, + err: true, + exp: "bad range elem 3:12 overlaps prev 0:9", + }, + { + // range starts not ordered + inp: []int{10, 11, 3, 4}, + err: true, + exp: "range start not ordered 3:4 less than prev 10:11", + }, + } + + for k, tc := range testcases { + is, err := makeIntervals(tc.inp...) + want := tc.exp + if err != nil { + if !tc.err { + t.Fatalf("unexpected error on tc:%d %+v -> %v", k, tc.inp, err) + } else { + got := fmt.Sprintf("%v", err) + if got != want { + t.Fatalf("bad error on tc:%d %+v got %q want %q", k, tc.inp, got, want) + } + } + continue + } else if tc.err { + t.Fatalf("missing error on tc:%d %+v return was %q", k, tc.inp, is.String()) + } + got := is.String() + if got != want { + t.Fatalf("exp mismatch on tc:%d %+v got %q want %q", k, tc.inp, got, want) + } + } +} + +func TestIntervalOverlap(t *testing.T) { + testcases := []struct { + i1, i2 Interval + exp bool + }{ + { + i1: Interval{st: 0, en: 1}, + i2: Interval{st: 0, en: 1}, + exp: true, + }, + { + i1: Interval{st: 0, en: 1}, + i2: Interval{st: 1, en: 2}, + exp: false, + }, + { + i1: Interval{st: 9, en: 10}, + i2: Interval{st: 1, en: 2}, + exp: false, + }, + { + i1: Interval{st: 0, en: 10}, + i2: Interval{st: 5, en: 6}, + exp: true, + }, + } + + for _, tc := range testcases { + want := tc.exp + got := tc.i1.Overlaps(tc.i2) + if want != got { + t.Fatalf("Overlaps([%d,%d), [%d,%d)): got %v want %v", + tc.i1.st, tc.i1.en, tc.i2.st, tc.i2.en, got, want) + } + } +} + +func TestIntervalAdjacent(t *testing.T) { + testcases := []struct { + i1, i2 Interval + exp bool + }{ + { + i1: Interval{st: 0, en: 1}, + i2: Interval{st: 0, en: 1}, + exp: false, + }, + { + i1: Interval{st: 0, en: 1}, + i2: Interval{st: 1, en: 2}, + exp: true, + }, + { + i1: Interval{st: 1, en: 2}, + i2: Interval{st: 0, en: 1}, + exp: true, + }, + { + i1: Interval{st: 0, en: 10}, + i2: Interval{st: 0, en: 3}, + exp: false, + }, + } + + for k, tc := range testcases { + want := tc.exp + got := tc.i1.adjacent(tc.i2) + if want != got { + t.Fatalf("tc=%d adjacent([%d,%d), [%d,%d)): got %v want %v", + k, tc.i1.st, tc.i1.en, tc.i2.st, tc.i2.en, got, want) + } + } +} + +func TestIntervalMerge(t *testing.T) { + testcases := []struct { + i1, i2 Interval + exp Interval + err bool + }{ + { + // error case + i1: Interval{st: 0, en: 1}, + i2: Interval{st: 2, en: 3}, + err: true, + }, + { + // same + i1: Interval{st: 0, en: 1}, + i2: Interval{st: 0, en: 1}, + exp: Interval{st: 0, en: 1}, + err: false, + }, + { + // adjacent + i1: Interval{st: 0, en: 1}, + i2: Interval{st: 1, en: 2}, + exp: Interval{st: 0, en: 2}, + err: false, + }, + { + // overlapping 1 + i1: Interval{st: 0, en: 5}, + i2: Interval{st: 3, en: 10}, + exp: Interval{st: 0, en: 10}, + err: false, + }, + { + // overlapping 2 + i1: Interval{st: 9, en: 15}, + i2: Interval{st: 3, en: 11}, + exp: Interval{st: 3, en: 15}, + err: false, + }, + } + + for k, tc := range testcases { + var dst Interval + dstp := &dst + dst = tc.i1 + err := dstp.MergeInto(tc.i2) + if (err != nil) != tc.err { + t.Fatalf("tc=%d MergeInto([%d,%d) <= [%d,%d)): got err=%v want err=%v", k, tc.i1.st, tc.i1.en, tc.i2.st, tc.i2.en, err, tc.err) + } + if err != nil { + continue + } + want := tc.exp.String() + got := dst.String() + if want != got { + t.Fatalf("tc=%d MergeInto([%d,%d) <= [%d,%d)): got %v want %v", + k, tc.i1.st, tc.i1.en, tc.i2.st, tc.i2.en, got, want) + } + } +} + +func TestIntervalsOverlap(t *testing.T) { + testcases := []struct { + inp1, inp2 []int + exp bool + }{ + { + // first empty + inp1: []int{}, + inp2: []int{1, 2}, + exp: false, + }, + { + // second empty + inp1: []int{9, 10}, + inp2: []int{}, + exp: false, + }, + { + // disjoint 1 + inp1: []int{1, 2}, + inp2: []int{2, 3}, + exp: false, + }, + { + // disjoint 2 + inp1: []int{2, 3}, + inp2: []int{1, 2}, + exp: false, + }, + { + // interleaved 1 + inp1: []int{1, 2, 3, 4}, + inp2: []int{2, 3, 5, 6}, + exp: false, + }, + { + // interleaved 2 + inp1: []int{2, 3, 5, 6}, + inp2: []int{1, 2, 3, 4}, + exp: false, + }, + { + // overlap 1 + inp1: []int{1, 3}, + inp2: []int{2, 9, 10, 11}, + exp: true, + }, + { + // overlap 2 + inp1: []int{18, 29}, + inp2: []int{2, 9, 10, 19}, + exp: true, + }, + } + + for k, tc := range testcases { + is1, err1 := makeIntervals(tc.inp1...) + if err1 != nil { + t.Fatalf("unexpected error on tc:%d %+v: %v", k, tc.inp1, err1) + } + is2, err2 := makeIntervals(tc.inp2...) + if err2 != nil { + t.Fatalf("unexpected error on tc:%d %+v: %v", k, tc.inp2, err2) + } + got := is1.Overlaps(is2) + want := tc.exp + if got != want { + t.Fatalf("overlaps mismatch on tc:%d %+v %+v got %v want %v", k, tc.inp1, tc.inp2, got, want) + } + } +} + +var seedflag = flag.Int64("seed", 101, "Random seed") +var trialsflag = flag.Int64("trials", 10000, "Number of trials") +var segsflag = flag.Int64("segs", 4, "Max segments within interval") +var limitflag = flag.Int64("limit", 20, "Limit of interval max end") + +// NB: consider turning this into a fuzz test if the interval data +// structures or code get any more complicated. + +func TestRandomIntervalsOverlap(t *testing.T) { + rand.Seed(*seedflag) + + // Return a pseudo-random intervals object with 0-3 segments within + // the range of 0 to limit + mk := func() Intervals { + vals := rand.Perm(int(*limitflag)) + // decide how many segments + segs := rand.Intn(int(*segsflag)) + picked := vals[:(segs * 2)] + sort.Ints(picked) + ii, err := makeIntervals(picked...) + if err != nil { + t.Fatalf("makeIntervals(%+v) returns err %v", picked, err) + } + return ii + } + + brute := func(i1, i2 Intervals) bool { + for i := range i1 { + for j := range i2 { + if i1[i].Overlaps(i2[j]) { + return true + } + } + } + return false + } + + for k := range *trialsflag { + // Create two interval ranges and test if they overlap. Then + // compare the overlap with a brute-force overlap calculation. + i1, i2 := mk(), mk() + got := i1.Overlaps(i2) + want := brute(i1, i2) + if got != want { + t.Fatalf("overlap mismatch on t:%d %v %v got %v want %v", + k, i1, i2, got, want) + } + } +} + +func TestIntervalsMerge(t *testing.T) { + testcases := []struct { + inp1, inp2 []int + exp []int + }{ + { + // first empty + inp1: []int{}, + inp2: []int{1, 2}, + exp: []int{1, 2}, + }, + { + // second empty + inp1: []int{1, 2}, + inp2: []int{}, + exp: []int{1, 2}, + }, + { + // overlap 1 + inp1: []int{1, 2}, + inp2: []int{2, 3}, + exp: []int{1, 3}, + }, + { + // overlap 2 + inp1: []int{1, 5}, + inp2: []int{2, 10}, + exp: []int{1, 10}, + }, + { + // non-overlap 1 + inp1: []int{1, 2}, + inp2: []int{11, 12}, + exp: []int{1, 2, 11, 12}, + }, + { + // non-overlap 2 + inp1: []int{1, 2, 3, 4, 5, 6}, + inp2: []int{2, 3, 4, 5, 6, 7}, + exp: []int{1, 7}, + }, + } + + for k, tc := range testcases { + is1, err1 := makeIntervals(tc.inp1...) + if err1 != nil { + t.Fatalf("unexpected error on tc:%d %+v: %v", k, tc.inp1, err1) + } + is2, err2 := makeIntervals(tc.inp2...) + if err2 != nil { + t.Fatalf("unexpected error on tc:%d %+v: %v", k, tc.inp2, err2) + } + m := is1.Merge(is2) + wis, werr := makeIntervals(tc.exp...) + if werr != nil { + t.Fatalf("unexpected error on tc:%d %+v: %v", k, tc.exp, werr) + } + want := wis.String() + got := m.String() + if want != got { + t.Fatalf("k=%d Merge(%s, %s): got %v want %v", + k, is1, is2, m, want) + } + } +} + +func TestBuilder(t *testing.T) { + type posLiveKill struct { + pos int + becomesLive, isKill bool // what to pass to IntervalsBuilder + } + testcases := []struct { + inp []posLiveKill + exp []int + aerr, ferr bool + }{ + // error case, position non-decreasing + { + inp: []posLiveKill{ + posLiveKill{pos: 10, becomesLive: true}, + posLiveKill{pos: 18, isKill: true}, + }, + aerr: true, + }, + // error case, position negative + { + inp: []posLiveKill{ + posLiveKill{pos: -1, becomesLive: true}, + }, + aerr: true, + }, + // empty + { + exp: nil, + }, + // single BB + { + inp: []posLiveKill{ + posLiveKill{pos: 10, becomesLive: true}, + posLiveKill{pos: 9, isKill: true}, + }, + exp: []int{10, 11}, + }, + // couple of BBs + { + inp: []posLiveKill{ + posLiveKill{pos: 11, becomesLive: true}, + posLiveKill{pos: 10, becomesLive: true}, + posLiveKill{pos: 9, isKill: true}, + posLiveKill{pos: 4, becomesLive: true}, + posLiveKill{pos: 1, isKill: true}, + }, + exp: []int{2, 5, 10, 12}, + }, + // couple of BBs + { + inp: []posLiveKill{ + posLiveKill{pos: 20, isKill: true}, + posLiveKill{pos: 19, isKill: true}, + posLiveKill{pos: 17, becomesLive: true}, + posLiveKill{pos: 14, becomesLive: true}, + posLiveKill{pos: 10, isKill: true}, + posLiveKill{pos: 4, becomesLive: true}, + posLiveKill{pos: 0, isKill: true}, + }, + exp: []int{1, 5, 11, 18}, + }, + } + + for k, tc := range testcases { + var c IntervalsBuilder + var aerr error + for _, event := range tc.inp { + if event.becomesLive { + if err := c.Live(event.pos); err != nil { + aerr = err + break + } + } + if event.isKill { + if err := c.Kill(event.pos); err != nil { + aerr = err + break + } + } + } + if (aerr != nil) != tc.aerr { + t.Fatalf("k=%d add err mismatch: tc.aerr:%v aerr!=nil:%v", + k, tc.aerr, (aerr != nil)) + } + if tc.aerr { + continue + } + ii, ferr := c.Finish() + if ferr != nil { + if tc.ferr { + continue + } + t.Fatalf("h=%d finish err mismatch: tc.ferr:%v ferr!=nil:%v", k, tc.ferr, ferr != nil) + } + got := ii.String() + wis, werr := makeIntervals(tc.exp...) + if werr != nil { + t.Fatalf("unexpected error on tc:%d %+v: %v", k, tc.exp, werr) + } + want := wis.String() + if want != got { + t.Fatalf("k=%d Ctor test: got %v want %v", k, got, want) + } + } +} + +// makeIntervals constructs an Intervals object from the start/end +// sequence in nums, expected to be of the form +// s1,en1,st2,en2,...,stk,enk. Used only for unit testing. +func makeIntervals(nums ...int) (Intervals, error) { + var r Intervals + if len(nums)&1 != 0 { + return r, fmt.Errorf("odd number of elems %d", len(nums)) + } + for i := 0; i < len(nums); i += 2 { + st := nums[i] + en := nums[i+1] + r = append(r, Interval{st: st, en: en}) + } + return r, check(r) +} diff --git a/go/src/cmd/compile/internal/liveness/mergelocals.go b/go/src/cmd/compile/internal/liveness/mergelocals.go new file mode 100644 index 0000000000000000000000000000000000000000..6967ee016ee71055d99ac51eeeff350292c08d09 --- /dev/null +++ b/go/src/cmd/compile/internal/liveness/mergelocals.go @@ -0,0 +1,1028 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package liveness + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/bitvec" + "cmd/compile/internal/ir" + "cmd/compile/internal/ssa" + "cmd/internal/src" + "fmt" + "os" + "path/filepath" + "slices" + "sort" + "strings" +) + +// MergeLocalsState encapsulates information about which AUTO +// (stack-allocated) variables within a function can be safely +// merged/overlapped, e.g. share a stack slot with some other auto). +// An instance of MergeLocalsState is produced by MergeLocals() below +// and then consumed in ssagen.AllocFrame. The map 'partition' +// contains entries of the form where N is an *ir.Name and SL +// is a slice holding the indices (within 'vars') of other variables +// that share the same slot, specifically the slot of the first +// element in the partition, which we'll call the "leader". For +// example, if a function contains five variables where v1/v2/v3 are +// safe to overlap and v4/v5 are safe to overlap, the MergeLocalsState +// content might look like +// +// vars: [v1, v2, v3, v4, v5] +// partition: v1 -> [1, 0, 2], v2 -> [1, 0, 2], v3 -> [1, 0, 2] +// v4 -> [3, 4], v5 -> [3, 4] +// +// A nil MergeLocalsState indicates that no local variables meet the +// necessary criteria for overlap. +type MergeLocalsState struct { + // contains auto vars that participate in overlapping + vars []*ir.Name + // maps auto variable to overlap partition + partition map[*ir.Name][]int +} + +// candRegion is a sub-range (start, end) corresponding to an interval +// [st,en] within the list of candidate variables. +type candRegion struct { + st, en int +} + +// cstate holds state information we'll need during the analysis +// phase of stack slot merging but can be discarded when the analysis +// is done. +type cstate struct { + fn *ir.Func + f *ssa.Func + lv *Liveness + cands []*ir.Name + nameToSlot map[*ir.Name]int32 + regions []candRegion + indirectUE map[ssa.ID][]*ir.Name + ivs []Intervals + hashDeselected map[*ir.Name]bool + trace int // debug trace level +} + +// MergeLocals analyzes the specified ssa function f to determine which +// of its auto variables can safely share the same stack slot, returning +// a state object that describes how the overlap should be done. +func MergeLocals(fn *ir.Func, f *ssa.Func) *MergeLocalsState { + + // Create a container object for useful state info and then + // call collectMergeCandidates to see if there are vars suitable + // for stack slot merging. + cs := &cstate{ + fn: fn, + f: f, + trace: base.Debug.MergeLocalsTrace, + } + cs.collectMergeCandidates() + if len(cs.regions) == 0 { + return nil + } + + // Kick off liveness analysis. + // + // If we have a local variable such as "r2" below that's written + // but then not read, something like: + // + // vardef r1 + // r1.x = ... + // vardef r2 + // r2.x = 0 + // r2.y = ... + // + // // no subsequent use of r2 + // ... = r1.x + // + // then for the purpose of calculating stack maps at the call, we + // can ignore "r2" completely during liveness analysis for stack + // maps, however for stack slock merging we most definitely want + // to treat the writes as "uses". + cs.lv = newliveness(fn, f, cs.cands, cs.nameToSlot, 0) + cs.lv.conservativeWrites = true + cs.lv.prologue() + cs.lv.solve() + + // Compute intervals for each candidate based on the liveness and + // on block effects. + cs.computeIntervals() + + // Perform merging within each region of the candidates list. + rv := cs.performMerging() + if err := rv.check(); err != nil { + base.FatalfAt(fn.Pos(), "invalid mergelocals state: %v", err) + } + return rv +} + +// Subsumed returns whether variable n is subsumed, e.g. appears +// in an overlap position but is not the leader in that partition. +func (mls *MergeLocalsState) Subsumed(n *ir.Name) bool { + if sl, ok := mls.partition[n]; ok && mls.vars[sl[0]] != n { + return true + } + return false +} + +// IsLeader returns whether a variable n is the leader (first element) +// in a sharing partition. +func (mls *MergeLocalsState) IsLeader(n *ir.Name) bool { + if sl, ok := mls.partition[n]; ok && mls.vars[sl[0]] == n { + return true + } + return false +} + +// Leader returns the leader variable for subsumed var n. +func (mls *MergeLocalsState) Leader(n *ir.Name) *ir.Name { + if sl, ok := mls.partition[n]; ok { + if mls.vars[sl[0]] == n { + panic("variable is not subsumed") + } + return mls.vars[sl[0]] + } + panic("not a merge candidate") +} + +// Followers writes a list of the followers for leader n into the slice tmp. +func (mls *MergeLocalsState) Followers(n *ir.Name, tmp []*ir.Name) []*ir.Name { + tmp = tmp[:0] + sl, ok := mls.partition[n] + if !ok { + panic("no entry for leader") + } + if mls.vars[sl[0]] != n { + panic("followers invoked on subsumed var") + } + for _, k := range sl[1:] { + tmp = append(tmp, mls.vars[k]) + } + slices.SortStableFunc(tmp, func(a, b *ir.Name) int { + return strings.Compare(a.Sym().Name, b.Sym().Name) + }) + return tmp +} + +// EstSavings returns the estimated reduction in stack size (number of bytes) for +// the given merge locals state via a pair of ints, the first for non-pointer types and the second for pointer types. +func (mls *MergeLocalsState) EstSavings() (int, int) { + totnp := 0 + totp := 0 + for n := range mls.partition { + if mls.Subsumed(n) { + sz := int(n.Type().Size()) + if n.Type().HasPointers() { + totp += sz + } else { + totnp += sz + } + } + } + return totnp, totp +} + +// check tests for various inconsistencies and problems in mls, +// returning an error if any problems are found. +func (mls *MergeLocalsState) check() error { + if mls == nil { + return nil + } + used := make(map[int]bool) + seenv := make(map[*ir.Name]int) + for ii, v := range mls.vars { + if prev, ok := seenv[v]; ok { + return fmt.Errorf("duplicate var %q in vslots: %d and %d\n", + v.Sym().Name, ii, prev) + } + seenv[v] = ii + } + for k, sl := range mls.partition { + // length of slice value needs to be more than 1 + if len(sl) < 2 { + return fmt.Errorf("k=%q v=%+v slice len %d invalid", + k.Sym().Name, sl, len(sl)) + } + // values in the slice need to be var indices + for i, v := range sl { + if v < 0 || v > len(mls.vars)-1 { + return fmt.Errorf("k=%q v=+%v slpos %d vslot %d out of range of m.v", k.Sym().Name, sl, i, v) + } + } + } + for k, sl := range mls.partition { + foundk := false + for i, v := range sl { + vv := mls.vars[v] + if i == 0 { + if !mls.IsLeader(vv) { + return fmt.Errorf("k=%s v=+%v slpos 0 vslot %d IsLeader(%q) is false should be true", k.Sym().Name, sl, v, vv.Sym().Name) + } + } else { + if !mls.Subsumed(vv) { + return fmt.Errorf("k=%s v=+%v slpos %d vslot %d Subsumed(%q) is false should be true", k.Sym().Name, sl, i, v, vv.Sym().Name) + } + if mls.Leader(vv) != mls.vars[sl[0]] { + return fmt.Errorf("k=%s v=+%v slpos %d vslot %d Leader(%q) got %v want %v", k.Sym().Name, sl, i, v, vv.Sym().Name, mls.Leader(vv), mls.vars[sl[0]]) + } + } + if vv == k { + foundk = true + if used[v] { + return fmt.Errorf("k=%s v=+%v val slice used violation at slpos %d vslot %d", k.Sym().Name, sl, i, v) + } + used[v] = true + } + } + if !foundk { + return fmt.Errorf("k=%s v=+%v slice value missing k", k.Sym().Name, sl) + } + vl := mls.vars[sl[0]] + for _, v := range sl[1:] { + vv := mls.vars[v] + if vv.Type().Size() > vl.Type().Size() { + return fmt.Errorf("k=%s v=+%v follower %s size %d larger than leader %s size %d", k.Sym().Name, sl, vv.Sym().Name, vv.Type().Size(), vl.Sym().Name, vl.Type().Size()) + } + if vv.Type().HasPointers() && !vl.Type().HasPointers() { + return fmt.Errorf("k=%s v=+%v follower %s hasptr=true but leader %s hasptr=false", k.Sym().Name, sl, vv.Sym().Name, vl.Sym().Name) + } + if vv.Type().Alignment() > vl.Type().Alignment() { + return fmt.Errorf("k=%s v=+%v follower %s align %d greater than leader %s align %d", k.Sym().Name, sl, vv.Sym().Name, vv.Type().Alignment(), vl.Sym().Name, vl.Type().Alignment()) + } + } + } + for i := range used { + if !used[i] { + return fmt.Errorf("pos %d var %q unused", i, mls.vars[i]) + } + } + return nil +} + +func (mls *MergeLocalsState) String() string { + var leaders []*ir.Name + for n, sl := range mls.partition { + if n == mls.vars[sl[0]] { + leaders = append(leaders, n) + } + } + slices.SortFunc(leaders, func(a, b *ir.Name) int { + return strings.Compare(a.Sym().Name, b.Sym().Name) + }) + var sb strings.Builder + for _, n := range leaders { + sb.WriteString(n.Sym().Name + ":") + sl := mls.partition[n] + for _, k := range sl[1:] { + n := mls.vars[k] + sb.WriteString(" " + n.Sym().Name) + } + sb.WriteString("\n") + } + return sb.String() +} + +// collectMergeCandidates visits all of the AUTO vars declared in +// function fn and identifies a list of candidate variables for +// merging / overlapping. On return the "cands" field of cs will be +// filled in with our set of potentially overlappable candidate +// variables, the "regions" field will hold regions/sequence of +// compatible vars within the candidates list, "nameToSlot" field will +// be populated, and the "indirectUE" field will be filled in with +// information about indirect upwards-exposed uses in the func. +func (cs *cstate) collectMergeCandidates() { + var cands []*ir.Name + + // Collect up the available set of appropriate AUTOs in the + // function as a first step, and bail if we have fewer than + // two candidates. + for _, n := range cs.fn.Dcl { + if !n.Used() { + continue + } + if !ssa.IsMergeCandidate(n) { + continue + } + cands = append(cands, n) + } + if len(cands) < 2 { + return + } + + // Sort by pointerness, size, and then name. + sort.SliceStable(cands, func(i, j int) bool { + return nameLess(cands[i], cands[j]) + }) + + if cs.trace > 1 { + fmt.Fprintf(os.Stderr, "=-= raw cand list for func %v:\n", cs.fn) + for i := range cands { + dumpCand(cands[i], i) + } + } + + // Now generate an initial pruned candidate list and regions list. + // This may be empty if we don't have enough compatible candidates. + initial, _ := cs.genRegions(cands) + if len(initial) < 2 { + return + } + + // Set up for hash bisection if enabled. + cs.setupHashBisection(initial) + + // Create and populate an indirect use table that we'll use + // during interval construction. As part of this process we may + // wind up tossing out additional candidates, so check to make + // sure we still have something to work with. + cs.cands, cs.regions = cs.populateIndirectUseTable(initial) + if len(cs.cands) < 2 { + return + } + + // At this point we have a final pruned set of candidates and a + // corresponding set of regions for the candidates. Build a + // name-to-slot map for the candidates. + cs.nameToSlot = make(map[*ir.Name]int32) + for i, n := range cs.cands { + cs.nameToSlot[n] = int32(i) + } + + if cs.trace > 1 { + fmt.Fprintf(os.Stderr, "=-= pruned candidate list for fn %v:\n", cs.fn) + for i := range cs.cands { + dumpCand(cs.cands[i], i) + } + } +} + +// genRegions generates a set of regions within cands corresponding +// to potentially overlappable/mergeable variables. +func (cs *cstate) genRegions(cands []*ir.Name) ([]*ir.Name, []candRegion) { + var pruned []*ir.Name + var regions []candRegion + st := 0 + for { + en := nextRegion(cands, st) + if en == -1 { + break + } + if st == en { + // region has just one element, we can skip it + st++ + continue + } + pst := len(pruned) + pen := pst + (en - st) + if cs.trace > 1 { + fmt.Fprintf(os.Stderr, "=-= addregion st=%d en=%d: add part %d -> %d\n", st, en, pst, pen) + } + + // non-empty region, add to pruned + pruned = append(pruned, cands[st:en+1]...) + regions = append(regions, candRegion{st: pst, en: pen}) + st = en + 1 + } + if len(pruned) < 2 { + return nil, nil + } + return pruned, regions +} + +func (cs *cstate) dumpFunc() { + fmt.Fprintf(os.Stderr, "=-= mergelocalsdumpfunc %v:\n", cs.fn) + ii := 0 + for k, b := range cs.f.Blocks { + fmt.Fprintf(os.Stderr, "b%d:\n", k) + for _, v := range b.Values { + pos := base.Ctxt.PosTable.Pos(v.Pos) + fmt.Fprintf(os.Stderr, "=-= %d L%d|C%d %s\n", ii, pos.RelLine(), pos.RelCol(), v.LongString()) + ii++ + } + } +} + +func (cs *cstate) dumpFuncIfSelected() { + if base.Debug.MergeLocalsDumpFunc == "" { + return + } + if !strings.HasSuffix(fmt.Sprintf("%v", cs.fn), + base.Debug.MergeLocalsDumpFunc) { + return + } + cs.dumpFunc() +} + +// setupHashBisection checks to see if any of the candidate +// variables have been de-selected by our hash debug. Here +// we also implement the -d=mergelocalshtrace flag, which turns +// on debug tracing only if we have at least two candidates +// selected by the hash debug for this function. +func (cs *cstate) setupHashBisection(cands []*ir.Name) { + if base.Debug.MergeLocalsHash == "" { + return + } + deselected := make(map[*ir.Name]bool) + selCount := 0 + for _, cand := range cands { + if !base.MergeLocalsHash.MatchPosWithInfo(cand.Pos(), "mergelocals", nil) { + deselected[cand] = true + } else { + deselected[cand] = false + selCount++ + } + } + if selCount < len(cands) { + cs.hashDeselected = deselected + } + if base.Debug.MergeLocalsHTrace != 0 && selCount >= 2 { + cs.trace = base.Debug.MergeLocalsHTrace + } +} + +// populateIndirectUseTable creates and populates the "indirectUE" table +// within cs by doing some additional analysis of how the vars in +// cands are accessed in the function. +// +// It is possible to have situations where a given ir.Name is +// non-address-taken at the source level, but whose address is +// materialized in order to accommodate the needs of +// architecture-dependent operations or one sort or another (examples +// include things like LoweredZero/DuffZero, etc). The issue here is +// that the SymAddr op will show up as touching a variable of +// interest, but the subsequent memory op will not. This is generally +// not an issue for computing whether something is live across a call, +// but it is problematic for collecting the more fine-grained live +// interval info that drives stack slot merging. +// +// To handle this problem, make a forward pass over each basic block +// looking for instructions of the form vK := SymAddr(N) where N is a +// raw candidate. Create an entry in a map at that point from vK to +// its use count. Continue the walk, looking for uses of vK: when we +// see one, record it in a side table as an upwards exposed use of N. +// Each time we see a use, decrement the use count in the map, and if +// we hit zero, remove the map entry. If we hit the end of the basic +// block and we still have map entries, then evict the name in +// question from the candidate set. +func (cs *cstate) populateIndirectUseTable(cands []*ir.Name) ([]*ir.Name, []candRegion) { + + // main indirect UE table, this is what we're producing in this func + indirectUE := make(map[ssa.ID][]*ir.Name) + + // this map holds the current set of candidates; the set may + // shrink if we have to evict any candidates. + rawcands := make(map[*ir.Name]struct{}) + + // maps ssa value V to the ir.Name it is taking the addr of, + // plus a count of the uses we've seen of V during a block walk. + pendingUses := make(map[ssa.ID]nameCount) + + // A temporary indirect UE tab just for the current block + // being processed; used to help with evictions. + blockIndirectUE := make(map[ssa.ID][]*ir.Name) + + // temporary map used to record evictions in a given block. + evicted := make(map[*ir.Name]bool) + for _, n := range cands { + rawcands[n] = struct{}{} + } + for k := 0; k < len(cs.f.Blocks); k++ { + clear(pendingUses) + clear(blockIndirectUE) + b := cs.f.Blocks[k] + for _, v := range b.Values { + if n, e := affectedVar(v); n != nil { + if _, ok := rawcands[n]; ok { + if e&ssa.SymAddr != 0 && v.Uses != 0 { + // we're taking the address of candidate var n + if _, ok := pendingUses[v.ID]; ok { + // should never happen + base.FatalfAt(v.Pos, "internal error: apparent multiple defs for SSA value %d", v.ID) + } + // Stash an entry in pendingUses recording + // that we took the address of "n" via this + // val. + pendingUses[v.ID] = nameCount{n: n, count: v.Uses} + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=-= SymAddr(%s) on %s\n", + n.Sym().Name, v.LongString()) + } + } + } + } + for _, arg := range v.Args { + if nc, ok := pendingUses[arg.ID]; ok { + // We found a use of some value that took the + // address of nc.n. Record this inst as a + // potential indirect use. + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=-= add indirectUE(%s) count=%d on %s\n", nc.n.Sym().Name, nc.count, v.LongString()) + } + blockIndirectUE[v.ID] = append(blockIndirectUE[v.ID], nc.n) + nc.count-- + if nc.count == 0 { + // That was the last use of the value. Clean + // up the entry in pendingUses. + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=-= last use of v%d\n", + arg.ID) + } + delete(pendingUses, arg.ID) + } else { + // Not the last use; record the decremented + // use count and move on. + pendingUses[arg.ID] = nc + } + } + } + } + + // We've reached the end of this basic block: if we have any + // leftover entries in pendingUses, then evict the + // corresponding names from the candidate set. The idea here + // is that if we materialized the address of some local and + // that value is flowing out of the block off somewhere else, + // we're going to treat that local as truly address-taken and + // not have it be a merge candidate. + clear(evicted) + if len(pendingUses) != 0 { + for id, nc := range pendingUses { + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=-= evicting %q due to pendingUse %d count %d\n", nc.n.Sym().Name, id, nc.count) + } + delete(rawcands, nc.n) + evicted[nc.n] = true + } + } + // Copy entries from blockIndirectUE into final indirectUE. Skip + // anything that we evicted in the loop above. + for id, sl := range blockIndirectUE { + for _, n := range sl { + if evicted[n] { + continue + } + indirectUE[id] = append(indirectUE[id], n) + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=-= add final indUE v%d name %s\n", id, n.Sym().Name) + } + } + } + } + if len(rawcands) < 2 { + return nil, nil + } + cs.indirectUE = indirectUE + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=-= iuetab:\n") + ids := make([]ssa.ID, 0, len(indirectUE)) + for k := range indirectUE { + ids = append(ids, k) + } + slices.Sort(ids) + for _, id := range ids { + fmt.Fprintf(os.Stderr, " v%d:", id) + for _, n := range indirectUE[id] { + fmt.Fprintf(os.Stderr, " %s", n.Sym().Name) + } + fmt.Fprintf(os.Stderr, "\n") + } + } + + pruned := cands[:0] + for k := range rawcands { + pruned = append(pruned, k) + } + sort.Slice(pruned, func(i, j int) bool { + return nameLess(pruned[i], pruned[j]) + }) + var regions []candRegion + pruned, regions = cs.genRegions(pruned) + if len(pruned) < 2 { + return nil, nil + } + return pruned, regions +} + +type nameCount struct { + n *ir.Name + count int32 +} + +// nameLess compares ci with cj to see if ci should be less than cj in +// a relative ordering of candidate variables. This is used to sort +// vars by pointerness (variables with pointers first), then in order +// of decreasing alignment, then by decreasing size. We are assuming a +// merging algorithm that merges later entries in the list into +// earlier entries. An example ordered candidate list produced by +// nameLess: +// +// idx name type align size +// 0: abc [10]*int 8 80 +// 1: xyz [9]*int 8 72 +// 2: qrs [2]*int 8 16 +// 3: tuv [9]int 8 72 +// 4: wxy [9]int32 4 36 +// 5: jkl [8]int32 4 32 +func nameLess(ci, cj *ir.Name) bool { + if ci.Type().HasPointers() != cj.Type().HasPointers() { + return ci.Type().HasPointers() + } + if ci.Type().Alignment() != cj.Type().Alignment() { + return cj.Type().Alignment() < ci.Type().Alignment() + } + if ci.Type().Size() != cj.Type().Size() { + return cj.Type().Size() < ci.Type().Size() + } + if ci.Sym().Name != cj.Sym().Name { + return ci.Sym().Name < cj.Sym().Name + } + return fmt.Sprintf("%v", ci.Pos()) < fmt.Sprintf("%v", cj.Pos()) +} + +// nextRegion starts at location idx and walks forward in the cands +// slice looking for variables that are "compatible" (potentially +// overlappable, in the sense that they could potentially share the +// stack slot of cands[idx]); it returns the end of the new region +// (range of compatible variables starting at idx). +func nextRegion(cands []*ir.Name, idx int) int { + n := len(cands) + if idx >= n { + return -1 + } + c0 := cands[idx] + szprev := c0.Type().Size() + alnprev := c0.Type().Alignment() + for j := idx + 1; j < n; j++ { + cj := cands[j] + szj := cj.Type().Size() + if szj > szprev { + return j - 1 + } + alnj := cj.Type().Alignment() + if alnj > alnprev { + return j - 1 + } + szprev = szj + alnprev = alnj + } + return n - 1 +} + +// mergeVisitRegion tries to perform overlapping of variables with a +// given subrange of cands described by st and en (indices into our +// candidate var list), where the variables within this range have +// already been determined to be compatible with respect to type, +// size, etc. Overlapping is done in a greedy fashion: we select the +// first element in the st->en range, then walk the rest of the +// elements adding in vars whose lifetimes don't overlap with the +// first element, then repeat the process until we run out of work. +// Ordering of the candidates within the region [st,en] is important; +// within the list the assumption is that if we overlap two variables +// X and Y where X precedes Y in the list, we need to make X the +// "leader" (keep X's slot and set Y's frame offset to X's) as opposed +// to the other way around, since it's possible that Y is smaller in +// size than X. +func (cs *cstate) mergeVisitRegion(mls *MergeLocalsState, st, en int) { + if cs.trace > 1 { + fmt.Fprintf(os.Stderr, "=-= mergeVisitRegion(st=%d, en=%d)\n", st, en) + } + n := en - st + 1 + used := bitvec.New(int32(n)) + + nxt := func(slot int) int { + for c := slot - st; c < n; c++ { + if used.Get(int32(c)) { + continue + } + return c + st + } + return -1 + } + + navail := n + cands := cs.cands + ivs := cs.ivs + if cs.trace > 1 { + fmt.Fprintf(os.Stderr, " =-= navail = %d\n", navail) + } + for navail >= 2 { + leader := nxt(st) + used.Set(int32(leader - st)) + navail-- + + if cs.trace > 1 { + fmt.Fprintf(os.Stderr, " =-= begin leader %d used=%s\n", leader, + used.String()) + } + elems := []int{leader} + lints := ivs[leader] + + for succ := nxt(leader + 1); succ != -1; succ = nxt(succ + 1) { + + // Skip if de-selected by merge locals hash. + if cs.hashDeselected != nil && cs.hashDeselected[cands[succ]] { + continue + } + // Skip if already used. + if used.Get(int32(succ - st)) { + continue + } + if cs.trace > 1 { + fmt.Fprintf(os.Stderr, " =-= overlap of %d[%v] {%s} with %d[%v] {%s} is: %v\n", leader, cands[leader], lints.String(), succ, cands[succ], ivs[succ].String(), lints.Overlaps(ivs[succ])) + } + + // Can we overlap leader with this var? + if lints.Overlaps(ivs[succ]) { + continue + } else { + // Add to overlap set. + elems = append(elems, succ) + lints = lints.Merge(ivs[succ]) + } + } + if len(elems) > 1 { + // We found some things to overlap with leader. Add the + // candidate elements to "vars" and update "partition". + off := len(mls.vars) + sl := make([]int, len(elems)) + for i, candslot := range elems { + sl[i] = off + i + mls.vars = append(mls.vars, cands[candslot]) + mls.partition[cands[candslot]] = sl + } + navail -= (len(elems) - 1) + for i := range elems { + used.Set(int32(elems[i] - st)) + } + if cs.trace > 1 { + fmt.Fprintf(os.Stderr, "=-= overlapping %+v:\n", sl) + for i := range sl { + dumpCand(mls.vars[sl[i]], sl[i]) + } + for i, v := range elems { + fmt.Fprintf(os.Stderr, "=-= %d: sl=%d %s\n", i, v, ivs[v]) + } + } + } + } +} + +// performMerging carries out variable merging within each of the +// candidate ranges in regions, returning a state object +// that describes the variable overlaps. +func (cs *cstate) performMerging() *MergeLocalsState { + cands := cs.cands + + mls := &MergeLocalsState{ + partition: make(map[*ir.Name][]int), + } + + // Dump state before attempting overlap. + if cs.trace > 1 { + fmt.Fprintf(os.Stderr, "=-= cands live before overlap:\n") + for i := range cands { + c := cands[i] + fmt.Fprintf(os.Stderr, "%d: %v sz=%d ivs=%s\n", + i, c.Sym().Name, c.Type().Size(), cs.ivs[i].String()) + } + fmt.Fprintf(os.Stderr, "=-= regions (%d): ", len(cs.regions)) + for _, cr := range cs.regions { + fmt.Fprintf(os.Stderr, " [%d,%d]", cr.st, cr.en) + } + fmt.Fprintf(os.Stderr, "\n") + } + + // Apply a greedy merge/overlap strategy within each region + // of compatible variables. + for _, cr := range cs.regions { + cs.mergeVisitRegion(mls, cr.st, cr.en) + } + if len(mls.vars) == 0 { + return nil + } + return mls +} + +// computeIntervals performs a backwards sweep over the instructions +// of the function we're compiling, building up an Intervals object +// for each candidate variable by looking for upwards exposed uses +// and kills. +func (cs *cstate) computeIntervals() { + lv := cs.lv + ibuilders := make([]IntervalsBuilder, len(cs.cands)) + nvars := int32(len(lv.vars)) + liveout := bitvec.New(nvars) + + cs.dumpFuncIfSelected() + + // Count instructions. + ninstr := 0 + for _, b := range lv.f.Blocks { + ninstr += len(b.Values) + } + // current instruction index during backwards walk + iidx := ninstr - 1 + + // Make a backwards pass over all blocks + for k := len(lv.f.Blocks) - 1; k >= 0; k-- { + b := lv.f.Blocks[k] + be := lv.blockEffects(b) + + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=-= liveout from tail of b%d: ", k) + for j := range lv.vars { + if be.liveout.Get(int32(j)) { + fmt.Fprintf(os.Stderr, " %q", lv.vars[j].Sym().Name) + } + } + fmt.Fprintf(os.Stderr, "\n") + } + + // Take into account effects taking place at end of this basic + // block by comparing our current live set with liveout for + // the block. If a given var was not live before and is now + // becoming live we need to mark this transition with a + // builder "Live" call; similarly if a var was live before and + // is now no longer live, we need a "Kill" call. + for j := range lv.vars { + isLive := liveout.Get(int32(j)) + blockLiveOut := be.liveout.Get(int32(j)) + if isLive { + if !blockLiveOut { + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=+= at instr %d block boundary kill of %v\n", iidx, lv.vars[j]) + } + ibuilders[j].Kill(iidx) + } + } else if blockLiveOut { + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=+= at block-end instr %d %v becomes live\n", + iidx, lv.vars[j]) + } + ibuilders[j].Live(iidx) + } + } + + // Set our working "currently live" set to the previously + // computed live out set for the block. + liveout.Copy(be.liveout) + + // Now walk backwards through this block. + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=-= b%d instr %d: %s\n", k, iidx, v.LongString()) + } + + // Update liveness based on what we see happening in this + // instruction. + pos, e := lv.valueEffects(v) + becomeslive := e&uevar != 0 + iskilled := e&varkill != 0 + if becomeslive && iskilled { + // we do not ever expect to see both a kill and an + // upwards exposed use given our size constraints. + panic("should never happen") + } + if iskilled && liveout.Get(pos) { + ibuilders[pos].Kill(iidx) + liveout.Unset(pos) + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=+= at instr %d kill of %v\n", + iidx, lv.vars[pos]) + } + } else if becomeslive && !liveout.Get(pos) { + ibuilders[pos].Live(iidx) + liveout.Set(pos) + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=+= at instr %d upwards-exposed use of %v\n", + iidx, lv.vars[pos]) + } + } + + if cs.indirectUE != nil { + // Now handle "indirect" upwards-exposed uses. + ues := cs.indirectUE[v.ID] + for _, n := range ues { + if pos, ok := lv.idx[n]; ok { + if !liveout.Get(pos) { + ibuilders[pos].Live(iidx) + liveout.Set(pos) + if cs.trace > 2 { + fmt.Fprintf(os.Stderr, "=+= at instr %d v%d indirect upwards-exposed use of %v\n", iidx, v.ID, lv.vars[pos]) + } + } + } + } + } + iidx-- + } + + // This check disabled for now due to the way scheduling works + // for ops that materialize values of local variables. For + // many architecture we have rewrite rules of this form: + // + // (LocalAddr {sym} base mem) && t.Elem().HasPointers() => (MOVDaddr {sym} (SPanchored base mem)) + // (LocalAddr {sym} base _) && !t.Elem().HasPointers() => (MOVDaddr {sym} base) + // + // which are designed to ensure that if you have a pointerful + // variable "abc" sequence + // + // v30 = VarDef {abc} v21 + // v31 = LocalAddr <*SB> {abc} v2 v30 + // v32 = Zero {SB} [2056] v31 v30 + // + // this will be lowered into + // + // v30 = VarDef {sb} v21 + // v106 = SPanchored v2 v30 + // v31 = MOVDaddr <*SB> {sb} v106 + // v3 = DUFFZERO [2056] v31 v30 + // + // Note the SPanchored: this ensures that the scheduler won't + // move the MOVDaddr earlier than the vardef. With a variable + // "xyz" that has no pointers, however, if we start with + // + // v66 = VarDef {t2} v65 + // v67 = LocalAddr <*T> {t2} v2 v66 + // v68 = Zero {T} [2056] v67 v66 + // + // we might lower to + // + // v66 = VarDef {t2} v65 + // v29 = MOVDaddr <*T> {t2} [2032] v2 + // v43 = LoweredZero v67 v29 v66 + // v68 = Zero [2056] v2 v43 + // + // where that MOVDaddr can float around arbitrarily, meaning + // that we may see an upwards-exposed use to it before the + // VarDef. + // + // One avenue to restoring the check below would be to change + // the rewrite rules to something like + // + // (LocalAddr {sym} base mem) && (t.Elem().HasPointers() || isMergeCandidate(t) => (MOVDaddr {sym} (SPanchored base mem)) + // + // however that change will have to be carefully evaluated, + // since it would constrain the scheduler for _all_ LocalAddr + // ops for potential merge candidates, even if we don't + // actually succeed in any overlaps. This will be revisitged in + // a later CL if possible. + // + const checkLiveOnEntry = false + if checkLiveOnEntry && b == lv.f.Entry { + for j, v := range lv.vars { + if liveout.Get(int32(j)) { + lv.f.Fatalf("%v %L recorded as live on entry", + lv.fn.Nname, v) + } + } + } + } + if iidx != -1 { + panic("iidx underflow") + } + + // Finish intervals construction. + ivs := make([]Intervals, len(cs.cands)) + for i := range cs.cands { + var err error + ivs[i], err = ibuilders[i].Finish() + if err != nil { + cs.dumpFunc() + base.FatalfAt(cs.cands[i].Pos(), "interval construct error for var %q in func %q (%d instrs): %v", cs.cands[i].Sym().Name, ir.FuncName(cs.fn), ninstr, err) + } + } + cs.ivs = ivs +} + +func fmtFullPos(p src.XPos) string { + var sb strings.Builder + sep := "" + base.Ctxt.AllPos(p, func(pos src.Pos) { + sb.WriteString(sep) + sep = "|" + file := filepath.Base(pos.Filename()) + fmt.Fprintf(&sb, "%s:%d:%d", file, pos.Line(), pos.Col()) + }) + return sb.String() +} + +func dumpCand(c *ir.Name, i int) { + fmt.Fprintf(os.Stderr, " %d: %s %q sz=%d hp=%v align=%d t=%v\n", + i, fmtFullPos(c.Pos()), c.Sym().Name, c.Type().Size(), + c.Type().HasPointers(), c.Type().Alignment(), c.Type()) +} + +// for unit testing only. +func MakeMergeLocalsState(partition map[*ir.Name][]int, vars []*ir.Name) (*MergeLocalsState, error) { + mls := &MergeLocalsState{partition: partition, vars: vars} + if err := mls.check(); err != nil { + return nil, err + } + return mls, nil +} diff --git a/go/src/cmd/compile/internal/liveness/plive.go b/go/src/cmd/compile/internal/liveness/plive.go new file mode 100644 index 0000000000000000000000000000000000000000..63c85ea26db605988027fb051339cd1a5520005f --- /dev/null +++ b/go/src/cmd/compile/internal/liveness/plive.go @@ -0,0 +1,1585 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Garbage collector liveness bitmap generation. + +// The command line flag -live causes this code to print debug information. +// The levels are: +// +// -live (aka -live=1): print liveness lists as code warnings at safe points +// -live=2: print an assembly listing with liveness annotations +// +// Each level includes the earlier output as well. + +package liveness + +import ( + "cmp" + "fmt" + "os" + "slices" + "sort" + "strings" + + "cmd/compile/internal/abi" + "cmd/compile/internal/base" + "cmd/compile/internal/bitvec" + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/reflectdata" + "cmd/compile/internal/ssa" + "cmd/compile/internal/typebits" + "cmd/compile/internal/types" + "cmd/internal/hash" + "cmd/internal/obj" + "cmd/internal/src" + + rtabi "internal/abi" +) + +// OpVarDef is an annotation for the liveness analysis, marking a place +// where a complete initialization (definition) of a variable begins. +// Since the liveness analysis can see initialization of single-word +// variables quite easy, OpVarDef is only needed for multi-word +// variables satisfying isfat(n.Type). For simplicity though, buildssa +// emits OpVarDef regardless of variable width. +// +// An 'OpVarDef x' annotation in the instruction stream tells the liveness +// analysis to behave as though the variable x is being initialized at that +// point in the instruction stream. The OpVarDef must appear before the +// actual (multi-instruction) initialization, and it must also appear after +// any uses of the previous value, if any. For example, if compiling: +// +// x = x[1:] +// +// it is important to generate code like: +// +// base, len, cap = pieces of x[1:] +// OpVarDef x +// x = {base, len, cap} +// +// If instead the generated code looked like: +// +// OpVarDef x +// base, len, cap = pieces of x[1:] +// x = {base, len, cap} +// +// then the liveness analysis would decide the previous value of x was +// unnecessary even though it is about to be used by the x[1:] computation. +// Similarly, if the generated code looked like: +// +// base, len, cap = pieces of x[1:] +// x = {base, len, cap} +// OpVarDef x +// +// then the liveness analysis will not preserve the new value of x, because +// the OpVarDef appears to have "overwritten" it. +// +// OpVarDef is a bit of a kludge to work around the fact that the instruction +// stream is working on single-word values but the liveness analysis +// wants to work on individual variables, which might be multi-word +// aggregates. It might make sense at some point to look into letting +// the liveness analysis work on single-word values as well, although +// there are complications around interface values, slices, and strings, +// all of which cannot be treated as individual words. + +// blockEffects summarizes the liveness effects on an SSA block. +type blockEffects struct { + // Computed during Liveness.prologue using only the content of + // individual blocks: + // + // uevar: upward exposed variables (used before set in block) + // varkill: killed variables (set in block) + uevar bitvec.BitVec + varkill bitvec.BitVec + + // Computed during Liveness.solve using control flow information: + // + // livein: variables live at block entry + // liveout: variables live at block exit + livein bitvec.BitVec + liveout bitvec.BitVec +} + +// A collection of global state used by Liveness analysis. +type Liveness struct { + fn *ir.Func + f *ssa.Func + vars []*ir.Name + idx map[*ir.Name]int32 + stkptrsize int64 + + be []blockEffects + + // allUnsafe indicates that all points in this function are + // unsafe-points. + allUnsafe bool + // unsafePoints bit i is set if Value ID i is an unsafe-point + // (preemption is not allowed). Only valid if !allUnsafe. + unsafePoints bitvec.BitVec + // unsafeBlocks bit i is set if Block ID i is an unsafe-point + // (preemption is not allowed on any end-of-block + // instructions). Only valid if !allUnsafe. + unsafeBlocks bitvec.BitVec + + // An array with a bit vector for each safe point in the + // current Block during liveness.epilogue. Indexed in Value + // order for that block. Additionally, for the entry block + // livevars[0] is the entry bitmap. liveness.compact moves + // these to stackMaps. + livevars []bitvec.BitVec + + // livenessMap maps from safe points (i.e., CALLs) to their + // liveness map indexes. + livenessMap Map + stackMapSet bvecSet + stackMaps []bitvec.BitVec + + cache progeffectscache + + // partLiveArgs includes input arguments (PPARAM) that may + // be partially live. That is, it is considered live because + // a part of it is used, but we may not initialize all parts. + partLiveArgs map[*ir.Name]bool + + doClobber bool // Whether to clobber dead stack slots in this function. + noClobberArgs bool // Do not clobber function arguments + + // treat "dead" writes as equivalent to reads during the analysis; + // used only during liveness analysis for stack slot merging (doesn't + // make sense for stackmap analysis). + conservativeWrites bool +} + +// Map maps from *ssa.Value to StackMapIndex. +// Also keeps track of unsafe ssa.Values and ssa.Blocks. +// (unsafe = can't be interrupted during GC.) +type Map struct { + Vals map[ssa.ID]objw.StackMapIndex + UnsafeVals map[ssa.ID]bool + UnsafeBlocks map[ssa.ID]bool + // The set of live, pointer-containing variables at the DeferReturn + // call (only set when open-coded defers are used). + DeferReturn objw.StackMapIndex +} + +func (m *Map) reset() { + if m.Vals == nil { + m.Vals = make(map[ssa.ID]objw.StackMapIndex) + m.UnsafeVals = make(map[ssa.ID]bool) + m.UnsafeBlocks = make(map[ssa.ID]bool) + } else { + clear(m.Vals) + clear(m.UnsafeVals) + clear(m.UnsafeBlocks) + } + m.DeferReturn = objw.StackMapDontCare +} + +func (m *Map) set(v *ssa.Value, i objw.StackMapIndex) { + m.Vals[v.ID] = i +} +func (m *Map) setUnsafeVal(v *ssa.Value) { + m.UnsafeVals[v.ID] = true +} +func (m *Map) setUnsafeBlock(b *ssa.Block) { + m.UnsafeBlocks[b.ID] = true +} + +func (m Map) Get(v *ssa.Value) objw.StackMapIndex { + // If v isn't in the map, then it's a "don't care". + if idx, ok := m.Vals[v.ID]; ok { + return idx + } + return objw.StackMapDontCare +} +func (m Map) GetUnsafe(v *ssa.Value) bool { + // default is safe + return m.UnsafeVals[v.ID] +} +func (m Map) GetUnsafeBlock(b *ssa.Block) bool { + // default is safe + return m.UnsafeBlocks[b.ID] +} + +type progeffectscache struct { + retuevar []int32 + tailuevar []int32 + initialized bool +} + +// shouldTrack reports whether the liveness analysis +// should track the variable n. +// We don't care about variables that have no pointers, +// nor do we care about non-local variables, +// nor do we care about empty structs (handled by the pointer check), +// nor do we care about the fake PAUTOHEAP variables. +func shouldTrack(n *ir.Name) bool { + return (n.Class == ir.PAUTO && n.Esc() != ir.EscHeap || n.Class == ir.PPARAM || n.Class == ir.PPARAMOUT) && n.Type().HasPointers() +} + +// getvariables returns the list of on-stack variables that we need to track +// and a map for looking up indices by *Node. +func getvariables(fn *ir.Func) ([]*ir.Name, map[*ir.Name]int32) { + var vars []*ir.Name + for _, n := range fn.Dcl { + if shouldTrack(n) { + vars = append(vars, n) + } + } + idx := make(map[*ir.Name]int32, len(vars)) + for i, n := range vars { + idx[n] = int32(i) + } + return vars, idx +} + +func (lv *Liveness) initcache() { + if lv.cache.initialized { + base.Fatalf("liveness cache initialized twice") + return + } + lv.cache.initialized = true + + for i, node := range lv.vars { + switch node.Class { + case ir.PPARAM: + // A return instruction with a p.to is a tail return, which brings + // the stack pointer back up (if it ever went down) and then jumps + // to a new function entirely. That form of instruction must read + // all the parameters for correctness, and similarly it must not + // read the out arguments - they won't be set until the new + // function runs. + lv.cache.tailuevar = append(lv.cache.tailuevar, int32(i)) + + case ir.PPARAMOUT: + // All results are live at every return point. + // Note that this point is after escaping return values + // are copied back to the stack using their PAUTOHEAP references. + lv.cache.retuevar = append(lv.cache.retuevar, int32(i)) + } + } +} + +// A liveEffect is a set of flags that describe an instruction's +// liveness effects on a variable. +// +// The possible flags are: +// +// uevar - used by the instruction +// varkill - killed by the instruction (set) +// +// A kill happens after the use (for an instruction that updates a value, for example). +type liveEffect int + +const ( + uevar liveEffect = 1 << iota + varkill +) + +// valueEffects returns the index of a variable in lv.vars and the +// liveness effects v has on that variable. +// If v does not affect any tracked variables, it returns -1, 0. +func (lv *Liveness) valueEffects(v *ssa.Value) (int32, liveEffect) { + n, e := affectedVar(v) + if e == 0 || n == nil { // cheapest checks first + return -1, 0 + } + // AllocFrame has dropped unused variables from + // lv.fn.Func.Dcl, but they might still be referenced by + // OpVarFoo pseudo-ops. Ignore them to prevent "lost track of + // variable" ICEs (issue 19632). + switch v.Op { + case ssa.OpVarDef, ssa.OpVarLive, ssa.OpKeepAlive: + if !n.Used() { + return -1, 0 + } + } + + if n.Class == ir.PPARAM && !n.Addrtaken() && n.Type().Size() > int64(types.PtrSize) { + // Only aggregate-typed arguments that are not address-taken can be + // partially live. + lv.partLiveArgs[n] = true + } + + var effect liveEffect + // Read is a read, obviously. + // + // Addr is a read also, as any subsequent holder of the pointer must be able + // to see all the values (including initialization) written so far. + // This also prevents a variable from "coming back from the dead" and presenting + // stale pointers to the garbage collector. See issue 28445. + if e&(ssa.SymRead|ssa.SymAddr) != 0 { + effect |= uevar + } + if e&ssa.SymWrite != 0 { + if !isfat(n.Type()) || v.Op == ssa.OpVarDef { + effect |= varkill + } else if lv.conservativeWrites { + effect |= uevar + } + } + + if effect == 0 { + return -1, 0 + } + + if pos, ok := lv.idx[n]; ok { + return pos, effect + } + return -1, 0 +} + +// affectedVar returns the *ir.Name node affected by v. +func affectedVar(v *ssa.Value) (*ir.Name, ssa.SymEffect) { + // Special cases. + switch v.Op { + case ssa.OpLoadReg: + n, _ := ssa.AutoVar(v.Args[0]) + return n, ssa.SymRead + case ssa.OpStoreReg: + n, _ := ssa.AutoVar(v) + return n, ssa.SymWrite + + case ssa.OpArgIntReg: + // This forces the spill slot for the register to be live at function entry. + // one of the following holds for a function F with pointer-valued register arg X: + // 0. No GC (so an uninitialized spill slot is okay) + // 1. GC at entry of F. GC is precise, but the spills around morestack initialize X's spill slot + // 2. Stack growth at entry of F. Same as GC. + // 3. GC occurs within F itself. This has to be from preemption, and thus GC is conservative. + // a. X is in a register -- then X is seen, and the spill slot is also scanned conservatively. + // b. X is spilled -- the spill slot is initialized, and scanned conservatively + // c. X is not live -- the spill slot is scanned conservatively, and it may contain X from an earlier spill. + // 4. GC within G, transitively called from F + // a. X is live at call site, therefore is spilled, to its spill slot (which is live because of subsequent LoadReg). + // b. X is not live at call site -- but neither is its spill slot. + n, _ := ssa.AutoVar(v) + return n, ssa.SymRead + + case ssa.OpVarLive: + return v.Aux.(*ir.Name), ssa.SymRead + case ssa.OpVarDef: + return v.Aux.(*ir.Name), ssa.SymWrite + case ssa.OpKeepAlive: + n, _ := ssa.AutoVar(v.Args[0]) + return n, ssa.SymRead + } + + e := v.Op.SymEffect() + if e == 0 { + return nil, 0 + } + + switch a := v.Aux.(type) { + case nil, *obj.LSym: + // ok, but no node + return nil, e + case *ir.Name: + return a, e + default: + base.Fatalf("weird aux: %s", v.LongString()) + return nil, e + } +} + +type livenessFuncCache struct { + be []blockEffects + livenessMap Map +} + +// Constructs a new liveness structure used to hold the global state of the +// liveness computation. The cfg argument is a slice of *BasicBlocks and the +// vars argument is a slice of *Nodes. +func newliveness(fn *ir.Func, f *ssa.Func, vars []*ir.Name, idx map[*ir.Name]int32, stkptrsize int64) *Liveness { + lv := &Liveness{ + fn: fn, + f: f, + vars: vars, + idx: idx, + stkptrsize: stkptrsize, + } + + // Significant sources of allocation are kept in the ssa.Cache + // and reused. Surprisingly, the bit vectors themselves aren't + // a major source of allocation, but the liveness maps are. + if lc, _ := f.Cache.Liveness.(*livenessFuncCache); lc == nil { + // Prep the cache so liveness can fill it later. + f.Cache.Liveness = new(livenessFuncCache) + } else { + if cap(lc.be) >= f.NumBlocks() { + lv.be = lc.be[:f.NumBlocks()] + } + lv.livenessMap = Map{ + Vals: lc.livenessMap.Vals, + UnsafeVals: lc.livenessMap.UnsafeVals, + UnsafeBlocks: lc.livenessMap.UnsafeBlocks, + DeferReturn: objw.StackMapDontCare, + } + lc.livenessMap.Vals = nil + lc.livenessMap.UnsafeVals = nil + lc.livenessMap.UnsafeBlocks = nil + } + if lv.be == nil { + lv.be = make([]blockEffects, f.NumBlocks()) + } + + nblocks := int32(len(f.Blocks)) + nvars := int32(len(vars)) + bulk := bitvec.NewBulk(nvars, nblocks*7, fn.Pos()) + for _, b := range f.Blocks { + be := lv.blockEffects(b) + + be.uevar = bulk.Next() + be.varkill = bulk.Next() + be.livein = bulk.Next() + be.liveout = bulk.Next() + } + lv.livenessMap.reset() + + lv.markUnsafePoints() + + lv.partLiveArgs = make(map[*ir.Name]bool) + + lv.enableClobber() + + return lv +} + +func (lv *Liveness) blockEffects(b *ssa.Block) *blockEffects { + return &lv.be[b.ID] +} + +// Generates live pointer value maps for arguments and local variables. The +// this argument and the in arguments are always assumed live. The vars +// argument is a slice of *Nodes. +func (lv *Liveness) pointerMap(liveout bitvec.BitVec, vars []*ir.Name, args, locals bitvec.BitVec) { + var slotsSeen map[int64]*ir.Name + checkForDuplicateSlots := base.Debug.MergeLocals != 0 + if checkForDuplicateSlots { + slotsSeen = make(map[int64]*ir.Name) + } + for i := int32(0); ; i++ { + i = liveout.Next(i) + if i < 0 { + break + } + node := vars[i] + switch node.Class { + case ir.PPARAM, ir.PPARAMOUT: + if !node.IsOutputParamInRegisters() { + if node.FrameOffset() < 0 { + lv.f.Fatalf("Node %v has frameoffset %d\n", node.Sym().Name, node.FrameOffset()) + } + typebits.SetNoCheck(node.Type(), node.FrameOffset(), args) + break + } + fallthrough // PPARAMOUT in registers acts memory-allocates like an AUTO + case ir.PAUTO: + if checkForDuplicateSlots { + if prev, ok := slotsSeen[node.FrameOffset()]; ok { + base.FatalfAt(node.Pos(), "two vars live at pointerMap generation: %q and %q", prev.Sym().Name, node.Sym().Name) + } + slotsSeen[node.FrameOffset()] = node + } + typebits.Set(node.Type(), node.FrameOffset()+lv.stkptrsize, locals) + } + } +} + +// IsUnsafe indicates that all points in this function are +// unsafe-points. +func IsUnsafe(f *ssa.Func) bool { + // The runtime assumes the only safe-points are function + // prologues (because that's how it used to be). We could and + // should improve that, but for now keep consider all points + // in the runtime unsafe. obj will add prologues and their + // safe-points. + // + // go:nosplit functions are similar. Since safe points used to + // be coupled with stack checks, go:nosplit often actually + // means "no safe points in this function". + return base.Flag.CompilingRuntime || f.NoSplit +} + +// markUnsafePoints finds unsafe points and computes lv.unsafePoints. +func (lv *Liveness) markUnsafePoints() { + if IsUnsafe(lv.f) { + // No complex analysis necessary. + lv.allUnsafe = true + return + } + + lv.unsafePoints = bitvec.New(int32(lv.f.NumValues())) + lv.unsafeBlocks = bitvec.New(int32(lv.f.NumBlocks())) + + // Mark architecture-specific unsafe points. + for _, b := range lv.f.Blocks { + for _, v := range b.Values { + if v.Op.UnsafePoint() { + lv.unsafePoints.Set(int32(v.ID)) + } + } + } + + for _, b := range lv.f.Blocks { + for _, v := range b.Values { + if v.Op != ssa.OpWBend { + continue + } + // WBend appears at the start of a block, like this: + // ... + // if wbEnabled: goto C else D + // C: + // ... some write barrier enabled code ... + // goto B + // D: + // ... some write barrier disabled code ... + // goto B + // B: + // m1 = Phi mem_C mem_D + // m2 = store operation ... m1 + // m3 = store operation ... m2 + // m4 = WBend m3 + + // Find first memory op in the block, which should be a Phi. + m := v + for { + m = m.MemoryArg() + if m.Block != b { + lv.f.Fatalf("can't find Phi before write barrier end mark %v", v) + } + if m.Op == ssa.OpPhi { + break + } + } + // Find the two predecessor blocks (write barrier on and write barrier off) + if len(m.Args) != 2 { + lv.f.Fatalf("phi before write barrier end mark has %d args, want 2", len(m.Args)) + } + c := b.Preds[0].Block() + d := b.Preds[1].Block() + + // Find their common predecessor block (the one that branches based on wb on/off). + // It might be a diamond pattern, or one of the blocks in the diamond pattern might + // be missing. + var decisionBlock *ssa.Block + if len(c.Preds) == 1 && c.Preds[0].Block() == d { + decisionBlock = d + } else if len(d.Preds) == 1 && d.Preds[0].Block() == c { + decisionBlock = c + } else if len(c.Preds) == 1 && len(d.Preds) == 1 && c.Preds[0].Block() == d.Preds[0].Block() { + decisionBlock = c.Preds[0].Block() + } else { + lv.f.Fatalf("can't find write barrier pattern %v", v) + } + if len(decisionBlock.Succs) != 2 { + lv.f.Fatalf("common predecessor block the wrong type %s", decisionBlock.Kind) + } + + // Flow backwards from the control value to find the + // flag load. We don't know what lowered ops we're + // looking for, but all current arches produce a + // single op that does the memory load from the flag + // address, so we look for that. + var load *ssa.Value + v := decisionBlock.Controls[0] + for { + if v.MemoryArg() != nil { + // Single instruction to load (and maybe compare) the write barrier flag. + if sym, ok := v.Aux.(*obj.LSym); ok && sym == ir.Syms.WriteBarrier { + load = v + break + } + // Some architectures have to materialize the address separate from + // the load. + if sym, ok := v.Args[0].Aux.(*obj.LSym); ok && sym == ir.Syms.WriteBarrier { + load = v + break + } + v.Fatalf("load of write barrier flag not from correct global: %s", v.LongString()) + } + // Common case: just flow backwards. + if len(v.Args) == 1 || len(v.Args) == 2 && v.Args[0] == v.Args[1] { + // Note: 386 lowers Neq32 to (TESTL cond cond), + v = v.Args[0] + continue + } + v.Fatalf("write barrier control value has more than one argument: %s", v.LongString()) + } + + // Mark everything after the load unsafe. + found := false + for _, v := range decisionBlock.Values { + if found { + lv.unsafePoints.Set(int32(v.ID)) + } + found = found || v == load + } + lv.unsafeBlocks.Set(int32(decisionBlock.ID)) + + // Mark the write barrier on/off blocks as unsafe. + for _, e := range decisionBlock.Succs { + x := e.Block() + if x == b { + continue + } + for _, v := range x.Values { + lv.unsafePoints.Set(int32(v.ID)) + } + lv.unsafeBlocks.Set(int32(x.ID)) + } + + // Mark from the join point up to the WBend as unsafe. + for _, v := range b.Values { + if v.Op == ssa.OpWBend { + break + } + lv.unsafePoints.Set(int32(v.ID)) + } + } + } +} + +// Returns true for instructions that must have a stack map. +// +// This does not necessarily mean the instruction is a safe-point. In +// particular, call Values can have a stack map in case the callee +// grows the stack, but not themselves be a safe-point. +func (lv *Liveness) hasStackMap(v *ssa.Value) bool { + if !v.Op.IsCall() { + return false + } + // wbZero and wbCopy are write barriers and + // deeply non-preemptible. They are unsafe points and + // hence should not have liveness maps. + if sym, ok := v.Aux.(*ssa.AuxCall); ok && (sym.Fn == ir.Syms.WBZero || sym.Fn == ir.Syms.WBMove) { + return false + } + return true +} + +// Initializes the sets for solving the live variables. Visits all the +// instructions in each basic block to summarizes the information at each basic +// block +func (lv *Liveness) prologue() { + lv.initcache() + + for _, b := range lv.f.Blocks { + be := lv.blockEffects(b) + + // Walk the block instructions backward and update the block + // effects with the each prog effects. + for j := len(b.Values) - 1; j >= 0; j-- { + pos, e := lv.valueEffects(b.Values[j]) + if e&varkill != 0 { + be.varkill.Set(pos) + be.uevar.Unset(pos) + } + if e&uevar != 0 { + be.uevar.Set(pos) + } + } + } +} + +// Solve the liveness dataflow equations. +func (lv *Liveness) solve() { + // These temporary bitvectors exist to avoid successive allocations and + // frees within the loop. + nvars := int32(len(lv.vars)) + newlivein := bitvec.New(nvars) + newliveout := bitvec.New(nvars) + + // Walk blocks in postorder ordering. This improves convergence. + po := lv.f.Postorder() + + // Iterate through the blocks in reverse round-robin fashion. A work + // queue might be slightly faster. As is, the number of iterations is + // so low that it hardly seems to be worth the complexity. + + for change := true; change; { + change = false + for _, b := range po { + be := lv.blockEffects(b) + + newliveout.Clear() + switch b.Kind { + case ssa.BlockRet: + for _, pos := range lv.cache.retuevar { + newliveout.Set(pos) + } + case ssa.BlockRetJmp: + for _, pos := range lv.cache.tailuevar { + newliveout.Set(pos) + } + case ssa.BlockExit: + // panic exit - nothing to do + default: + // A variable is live on output from this block + // if it is live on input to some successor. + // + // out[b] = \bigcup_{s \in succ[b]} in[s] + newliveout.Copy(lv.blockEffects(b.Succs[0].Block()).livein) + for _, succ := range b.Succs[1:] { + newliveout.Or(newliveout, lv.blockEffects(succ.Block()).livein) + } + } + + if !be.liveout.Eq(newliveout) { + change = true + be.liveout.Copy(newliveout) + } + + // A variable is live on input to this block + // if it is used by this block, or live on output from this block and + // not set by the code in this block. + // + // in[b] = uevar[b] \cup (out[b] \setminus varkill[b]) + newlivein.AndNot(be.liveout, be.varkill) + be.livein.Or(newlivein, be.uevar) + } + } +} + +// Visits all instructions in a basic block and computes a bit vector of live +// variables at each safe point locations. +func (lv *Liveness) epilogue() { + nvars := int32(len(lv.vars)) + liveout := bitvec.New(nvars) + livedefer := bitvec.New(nvars) // always-live variables + + // If there is a defer (that could recover), then all output + // parameters are live all the time. In addition, any locals + // that are pointers to heap-allocated output parameters are + // also always live (post-deferreturn code needs these + // pointers to copy values back to the stack). + // TODO: if the output parameter is heap-allocated, then we + // don't need to keep the stack copy live? + if lv.fn.HasDefer() { + for i, n := range lv.vars { + if n.Class == ir.PPARAMOUT { + if n.IsOutputParamHeapAddr() { + // Just to be paranoid. Heap addresses are PAUTOs. + base.Fatalf("variable %v both output param and heap output param", n) + } + if n.Heapaddr != nil { + // If this variable moved to the heap, then + // its stack copy is not live. + continue + } + // Note: zeroing is handled by zeroResults in ../ssagen/ssa.go. + livedefer.Set(int32(i)) + } + if n.IsOutputParamHeapAddr() { + // This variable will be overwritten early in the function + // prologue (from the result of a mallocgc) but we need to + // zero it in case that malloc causes a stack scan. + n.SetNeedzero(true) + livedefer.Set(int32(i)) + } + if n.OpenDeferSlot() { + // Open-coded defer args slots must be live + // everywhere in a function, since a panic can + // occur (almost) anywhere. Because it is live + // everywhere, it must be zeroed on entry. + livedefer.Set(int32(i)) + // It was already marked as Needzero when created. + if !n.Needzero() { + base.Fatalf("all pointer-containing defer arg slots should have Needzero set") + } + } + } + } + + // We must analyze the entry block first. The runtime assumes + // the function entry map is index 0. Conveniently, layout + // already ensured that the entry block is first. + if lv.f.Entry != lv.f.Blocks[0] { + lv.f.Fatalf("entry block must be first") + } + + { + // Reserve an entry for function entry. + live := bitvec.New(nvars) + lv.livevars = append(lv.livevars, live) + } + + for _, b := range lv.f.Blocks { + be := lv.blockEffects(b) + + // Walk forward through the basic block instructions and + // allocate liveness maps for those instructions that need them. + for _, v := range b.Values { + if !lv.hasStackMap(v) { + continue + } + + live := bitvec.New(nvars) + lv.livevars = append(lv.livevars, live) + } + + // walk backward, construct maps at each safe point + index := int32(len(lv.livevars) - 1) + + liveout.Copy(be.liveout) + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + + if lv.hasStackMap(v) { + // Found an interesting instruction, record the + // corresponding liveness information. + + live := &lv.livevars[index] + live.Or(*live, liveout) + live.Or(*live, livedefer) // only for non-entry safe points + index-- + } + + // Update liveness information. + pos, e := lv.valueEffects(v) + if e&varkill != 0 { + liveout.Unset(pos) + } + if e&uevar != 0 { + liveout.Set(pos) + } + } + + if b == lv.f.Entry { + if index != 0 { + base.Fatalf("bad index for entry point: %v", index) + } + + // Check to make sure only input variables are live. + for i, n := range lv.vars { + if !liveout.Get(int32(i)) { + continue + } + if n.Class == ir.PPARAM { + continue // ok + } + base.FatalfAt(n.Pos(), "bad live variable at entry of %v: %L", lv.fn.Nname, n) + } + + // Record live variables. + live := &lv.livevars[index] + live.Or(*live, liveout) + } + + if lv.doClobber { + lv.clobber(b) + } + + // The liveness maps for this block are now complete. Compact them. + lv.compact(b) + } + + // If we have an open-coded deferreturn call, make a liveness map for it. + if lv.fn.OpenCodedDeferDisallowed() { + lv.livenessMap.DeferReturn = objw.StackMapDontCare + } else { + idx, _ := lv.stackMapSet.add(livedefer) + lv.livenessMap.DeferReturn = objw.StackMapIndex(idx) + } + + // Done compacting. Throw out the stack map set. + lv.stackMaps = lv.stackMapSet.extractUnique() + lv.stackMapSet = bvecSet{} + + // Useful sanity check: on entry to the function, + // the only things that can possibly be live are the + // input parameters. + for j, n := range lv.vars { + if n.Class != ir.PPARAM && lv.stackMaps[0].Get(int32(j)) { + lv.f.Fatalf("%v %L recorded as live on entry", lv.fn.Nname, n) + } + } +} + +// Compact coalesces identical bitmaps from lv.livevars into the sets +// lv.stackMapSet. +// +// Compact clears lv.livevars. +// +// There are actually two lists of bitmaps, one list for the local variables and one +// list for the function arguments. Both lists are indexed by the same PCDATA +// index, so the corresponding pairs must be considered together when +// merging duplicates. The argument bitmaps change much less often during +// function execution than the local variable bitmaps, so it is possible that +// we could introduce a separate PCDATA index for arguments vs locals and +// then compact the set of argument bitmaps separately from the set of +// local variable bitmaps. As of 2014-04-02, doing this to the godoc binary +// is actually a net loss: we save about 50k of argument bitmaps but the new +// PCDATA tables cost about 100k. So for now we keep using a single index for +// both bitmap lists. +func (lv *Liveness) compact(b *ssa.Block) { + pos := 0 + if b == lv.f.Entry { + // Handle entry stack map. + lv.stackMapSet.add(lv.livevars[0]) + pos++ + } + for _, v := range b.Values { + if lv.hasStackMap(v) { + idx, _ := lv.stackMapSet.add(lv.livevars[pos]) + pos++ + lv.livenessMap.set(v, objw.StackMapIndex(idx)) + } + if lv.allUnsafe || v.Op != ssa.OpClobber && lv.unsafePoints.Get(int32(v.ID)) { + lv.livenessMap.setUnsafeVal(v) + } + } + if lv.allUnsafe || lv.unsafeBlocks.Get(int32(b.ID)) { + lv.livenessMap.setUnsafeBlock(b) + } + + // Reset livevars. + lv.livevars = lv.livevars[:0] +} + +func (lv *Liveness) enableClobber() { + // The clobberdead experiment inserts code to clobber pointer slots in all + // the dead variables (locals and args) at every synchronous safepoint. + if !base.Flag.ClobberDead { + return + } + if lv.fn.Pragma&ir.CgoUnsafeArgs != 0 { + // C or assembly code uses the exact frame layout. Don't clobber. + return + } + if len(lv.vars) > 10000 || len(lv.f.Blocks) > 10000 { + // Be careful to avoid doing too much work. + // Bail if >10000 variables or >10000 blocks. + // Otherwise, giant functions make this experiment generate too much code. + return + } + if lv.f.Name == "forkAndExecInChild" { + // forkAndExecInChild calls vfork on some platforms. + // The code we add here clobbers parts of the stack in the child. + // When the parent resumes, it is using the same stack frame. But the + // child has clobbered stack variables that the parent needs. Boom! + // In particular, the sys argument gets clobbered. + return + } + if lv.f.Name == "wbBufFlush" || + ((lv.f.Name == "callReflect" || lv.f.Name == "callMethod") && lv.fn.ABIWrapper()) { + // runtime.wbBufFlush must not modify its arguments. See the comments + // in runtime/mwbbuf.go:wbBufFlush. + // + // reflect.callReflect and reflect.callMethod are called from special + // functions makeFuncStub and methodValueCall. The runtime expects + // that it can find the first argument (ctxt) at 0(SP) in makeFuncStub + // and methodValueCall's frame (see runtime/traceback.go:getArgInfo). + // Normally callReflect and callMethod already do not modify the + // argument, and keep it alive. But the compiler-generated ABI wrappers + // don't do that. Special case the wrappers to not clobber its arguments. + lv.noClobberArgs = true + } + if h := os.Getenv("GOCLOBBERDEADHASH"); h != "" { + // Clobber only functions where the hash of the function name matches a pattern. + // Useful for binary searching for a miscompiled function. + hstr := "" + for _, b := range hash.Sum32([]byte(lv.f.Name)) { + hstr += fmt.Sprintf("%08b", b) + } + if !strings.HasSuffix(hstr, h) { + return + } + fmt.Printf("\t\t\tCLOBBERDEAD %s\n", lv.f.Name) + } + lv.doClobber = true +} + +// Inserts code to clobber pointer slots in all the dead variables (locals and args) +// at every synchronous safepoint in b. +func (lv *Liveness) clobber(b *ssa.Block) { + // Copy block's values to a temporary. + oldSched := append([]*ssa.Value{}, b.Values...) + b.Values = b.Values[:0] + idx := 0 + + // Clobber pointer slots in all dead variables at entry. + if b == lv.f.Entry { + for len(oldSched) > 0 && len(oldSched[0].Args) == 0 { + // Skip argless ops. We need to skip at least + // the lowered ClosurePtr op, because it + // really wants to be first. This will also + // skip ops like InitMem and SP, which are ok. + b.Values = append(b.Values, oldSched[0]) + oldSched = oldSched[1:] + } + clobber(lv, b, lv.livevars[0]) + idx++ + } + + // Copy values into schedule, adding clobbering around safepoints. + for _, v := range oldSched { + if !lv.hasStackMap(v) { + b.Values = append(b.Values, v) + continue + } + clobber(lv, b, lv.livevars[idx]) + b.Values = append(b.Values, v) + idx++ + } +} + +// clobber generates code to clobber pointer slots in all dead variables +// (those not marked in live). Clobbering instructions are added to the end +// of b.Values. +func clobber(lv *Liveness, b *ssa.Block, live bitvec.BitVec) { + for i, n := range lv.vars { + if !live.Get(int32(i)) && !n.Addrtaken() && !n.OpenDeferSlot() && !n.IsOutputParamHeapAddr() { + // Don't clobber stack objects (address-taken). They are + // tracked dynamically. + // Also don't clobber slots that are live for defers (see + // the code setting livedefer in epilogue). + if lv.noClobberArgs && n.Class == ir.PPARAM { + continue + } + clobberVar(b, n) + } + } +} + +// clobberVar generates code to trash the pointers in v. +// Clobbering instructions are added to the end of b.Values. +func clobberVar(b *ssa.Block, v *ir.Name) { + clobberWalk(b, v, 0, v.Type()) +} + +// b = block to which we append instructions +// v = variable +// offset = offset of (sub-portion of) variable to clobber (in bytes) +// t = type of sub-portion of v. +func clobberWalk(b *ssa.Block, v *ir.Name, offset int64, t *types.Type) { + if !t.HasPointers() { + return + } + switch t.Kind() { + case types.TPTR, + types.TUNSAFEPTR, + types.TFUNC, + types.TCHAN, + types.TMAP: + clobberPtr(b, v, offset) + + case types.TSTRING: + // struct { byte *str; int len; } + clobberPtr(b, v, offset) + + case types.TINTER: + // struct { Itab *tab; void *data; } + // or, when isnilinter(t)==true: + // struct { Type *type; void *data; } + clobberPtr(b, v, offset) + clobberPtr(b, v, offset+int64(types.PtrSize)) + + case types.TSLICE: + // struct { byte *array; int len; int cap; } + clobberPtr(b, v, offset) + + case types.TARRAY: + for i := int64(0); i < t.NumElem(); i++ { + clobberWalk(b, v, offset+i*t.Elem().Size(), t.Elem()) + } + + case types.TSTRUCT: + for _, t1 := range t.Fields() { + clobberWalk(b, v, offset+t1.Offset, t1.Type) + } + + default: + base.Fatalf("clobberWalk: unexpected type, %v", t) + } +} + +// clobberPtr generates a clobber of the pointer at offset offset in v. +// The clobber instruction is added at the end of b. +func clobberPtr(b *ssa.Block, v *ir.Name, offset int64) { + b.NewValue0IA(src.NoXPos, ssa.OpClobber, types.TypeVoid, offset, v) +} + +func (lv *Liveness) showlive(v *ssa.Value, live bitvec.BitVec) { + if base.Flag.Live == 0 || ir.FuncName(lv.fn) == "init" || strings.HasPrefix(ir.FuncName(lv.fn), ".") { + return + } + if lv.fn.Wrapper() || lv.fn.Dupok() { + // Skip reporting liveness information for compiler-generated wrappers. + return + } + if !(v == nil || v.Op.IsCall()) { + // Historically we only printed this information at + // calls. Keep doing so. + return + } + if live.IsEmpty() { + return + } + + pos, s := lv.format(v, live) + + base.WarnfAt(pos, "%s", s) +} + +func (lv *Liveness) Format(v *ssa.Value) string { + if v == nil { + _, s := lv.format(nil, lv.stackMaps[0]) + return s + } + if idx := lv.livenessMap.Get(v); idx.StackMapValid() { + _, s := lv.format(v, lv.stackMaps[idx]) + return s + } + return "" +} + +func (lv *Liveness) format(v *ssa.Value, live bitvec.BitVec) (src.XPos, string) { + pos := lv.fn.Nname.Pos() + if v != nil { + pos = v.Pos + } + + s := "live at " + if v == nil { + s += fmt.Sprintf("entry to %s:", ir.FuncName(lv.fn)) + } else if sym, ok := v.Aux.(*ssa.AuxCall); ok && sym.Fn != nil { + fn := sym.Fn.Name + if pos := strings.Index(fn, "."); pos >= 0 { + fn = fn[pos+1:] + } + s += fmt.Sprintf("call to %s:", fn) + } else { + s += "indirect call:" + } + + // Sort variable names for display. Variables aren't in any particular order, and + // the order can change by architecture, particularly with differences in regabi. + var names []string + for j, n := range lv.vars { + if live.Get(int32(j)) { + names = append(names, n.Sym().Name) + } + } + sort.Strings(names) + for _, v := range names { + s += " " + v + } + return pos, s +} + +func (lv *Liveness) printbvec(printed bool, name string, live bitvec.BitVec) bool { + if live.IsEmpty() { + return printed + } + + if !printed { + fmt.Printf("\t") + } else { + fmt.Printf(" ") + } + fmt.Printf("%s=", name) + + comma := "" + for i, n := range lv.vars { + if !live.Get(int32(i)) { + continue + } + fmt.Printf("%s%s", comma, n.Sym().Name) + comma = "," + } + return true +} + +// printeffect is like printbvec, but for valueEffects. +func (lv *Liveness) printeffect(printed bool, name string, pos int32, x bool) bool { + if !x { + return printed + } + if !printed { + fmt.Printf("\t") + } else { + fmt.Printf(" ") + } + fmt.Printf("%s=", name) + if x { + fmt.Printf("%s", lv.vars[pos].Sym().Name) + } + + return true +} + +// Prints the computed liveness information and inputs, for debugging. +// This format synthesizes the information used during the multiple passes +// into a single presentation. +func (lv *Liveness) printDebug() { + fmt.Printf("liveness: %s\n", ir.FuncName(lv.fn)) + + for i, b := range lv.f.Blocks { + if i > 0 { + fmt.Printf("\n") + } + + // bb#0 pred=1,2 succ=3,4 + fmt.Printf("bb#%d pred=", b.ID) + for j, pred := range b.Preds { + if j > 0 { + fmt.Printf(",") + } + fmt.Printf("%d", pred.Block().ID) + } + fmt.Printf(" succ=") + for j, succ := range b.Succs { + if j > 0 { + fmt.Printf(",") + } + fmt.Printf("%d", succ.Block().ID) + } + fmt.Printf("\n") + + be := lv.blockEffects(b) + + // initial settings + printed := false + printed = lv.printbvec(printed, "uevar", be.uevar) + printed = lv.printbvec(printed, "livein", be.livein) + if printed { + fmt.Printf("\n") + } + + // program listing, with individual effects listed + + if b == lv.f.Entry { + live := lv.stackMaps[0] + fmt.Printf("(%s) function entry\n", base.FmtPos(lv.fn.Nname.Pos())) + fmt.Printf("\tlive=") + printed = false + for j, n := range lv.vars { + if !live.Get(int32(j)) { + continue + } + if printed { + fmt.Printf(",") + } + fmt.Printf("%v", n) + printed = true + } + fmt.Printf("\n") + } + + for _, v := range b.Values { + fmt.Printf("(%s) %v\n", base.FmtPos(v.Pos), v.LongString()) + + pcdata := lv.livenessMap.Get(v) + + pos, effect := lv.valueEffects(v) + printed = false + printed = lv.printeffect(printed, "uevar", pos, effect&uevar != 0) + printed = lv.printeffect(printed, "varkill", pos, effect&varkill != 0) + if printed { + fmt.Printf("\n") + } + + if pcdata.StackMapValid() { + fmt.Printf("\tlive=") + printed = false + if pcdata.StackMapValid() { + live := lv.stackMaps[pcdata] + for j, n := range lv.vars { + if !live.Get(int32(j)) { + continue + } + if printed { + fmt.Printf(",") + } + fmt.Printf("%v", n) + printed = true + } + } + fmt.Printf("\n") + } + + if lv.livenessMap.GetUnsafe(v) { + fmt.Printf("\tunsafe-point\n") + } + } + if lv.livenessMap.GetUnsafeBlock(b) { + fmt.Printf("\tunsafe-block\n") + } + + // bb bitsets + fmt.Printf("end\n") + printed = false + printed = lv.printbvec(printed, "varkill", be.varkill) + printed = lv.printbvec(printed, "liveout", be.liveout) + if printed { + fmt.Printf("\n") + } + } + + fmt.Printf("\n") +} + +// Dumps a slice of bitmaps to a symbol as a sequence of uint32 values. The +// first word dumped is the total number of bitmaps. The second word is the +// length of the bitmaps. All bitmaps are assumed to be of equal length. The +// remaining bytes are the raw bitmaps. +func (lv *Liveness) emit() (argsSym, liveSym *obj.LSym) { + // Size args bitmaps to be just large enough to hold the largest pointer. + // First, find the largest Xoffset node we care about. + // (Nodes without pointers aren't in lv.vars; see ShouldTrack.) + var maxArgNode *ir.Name + for _, n := range lv.vars { + switch n.Class { + case ir.PPARAM, ir.PPARAMOUT: + if !n.IsOutputParamInRegisters() { + if maxArgNode == nil || n.FrameOffset() > maxArgNode.FrameOffset() { + maxArgNode = n + } + } + } + } + // Next, find the offset of the largest pointer in the largest node. + var maxArgs int64 + if maxArgNode != nil { + maxArgs = maxArgNode.FrameOffset() + types.PtrDataSize(maxArgNode.Type()) + } + + // Size locals bitmaps to be stkptrsize sized. + // We cannot shrink them to only hold the largest pointer, + // because their size is used to calculate the beginning + // of the local variables frame. + // Further discussion in https://golang.org/cl/104175. + // TODO: consider trimming leading zeros. + // This would require shifting all bitmaps. + maxLocals := lv.stkptrsize + + // Temporary symbols for encoding bitmaps. + var argsSymTmp, liveSymTmp obj.LSym + + args := bitvec.New(int32(maxArgs / int64(types.PtrSize))) + aoff := objw.Uint32(&argsSymTmp, 0, uint32(len(lv.stackMaps))) // number of bitmaps + aoff = objw.Uint32(&argsSymTmp, aoff, uint32(args.N)) // number of bits in each bitmap + + locals := bitvec.New(int32(maxLocals / int64(types.PtrSize))) + loff := objw.Uint32(&liveSymTmp, 0, uint32(len(lv.stackMaps))) // number of bitmaps + loff = objw.Uint32(&liveSymTmp, loff, uint32(locals.N)) // number of bits in each bitmap + + for _, live := range lv.stackMaps { + args.Clear() + locals.Clear() + + lv.pointerMap(live, lv.vars, args, locals) + + aoff = objw.BitVec(&argsSymTmp, aoff, args) + loff = objw.BitVec(&liveSymTmp, loff, locals) + } + + // These symbols will be added to Ctxt.Data by addGCLocals + // after parallel compilation is done. + return base.Ctxt.GCLocalsSym(argsSymTmp.P), base.Ctxt.GCLocalsSym(liveSymTmp.P) +} + +// Entry pointer for Compute analysis. Solves for the Compute of +// pointer variables in the function and emits a runtime data +// structure read by the garbage collector. +// Returns a map from GC safe points to their corresponding stack map index, +// and a map that contains all input parameters that may be partially live. +func Compute(curfn *ir.Func, f *ssa.Func, stkptrsize int64, pp *objw.Progs, retLiveness bool) (Map, map[*ir.Name]bool, *Liveness) { + // Construct the global liveness state. + vars, idx := getvariables(curfn) + lv := newliveness(curfn, f, vars, idx, stkptrsize) + + // Run the dataflow framework. + lv.prologue() + lv.solve() + lv.epilogue() + if base.Flag.Live > 0 { + lv.showlive(nil, lv.stackMaps[0]) + for _, b := range f.Blocks { + for _, val := range b.Values { + if idx := lv.livenessMap.Get(val); idx.StackMapValid() { + lv.showlive(val, lv.stackMaps[idx]) + } + } + } + } + if base.Flag.Live >= 2 { + lv.printDebug() + } + + // Update the function cache. + { + cache := f.Cache.Liveness.(*livenessFuncCache) + if cap(lv.be) < 2000 { // Threshold from ssa.Cache slices. + clear(lv.be) + cache.be = lv.be + } + if len(lv.livenessMap.Vals) < 2000 { + cache.livenessMap = lv.livenessMap + } + } + + // Emit the live pointer map data structures + ls := curfn.LSym + fninfo := ls.Func() + fninfo.GCArgs, fninfo.GCLocals = lv.emit() + + p := pp.Prog(obj.AFUNCDATA) + p.From.SetConst(rtabi.FUNCDATA_ArgsPointerMaps) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = fninfo.GCArgs + + p = pp.Prog(obj.AFUNCDATA) + p.From.SetConst(rtabi.FUNCDATA_LocalsPointerMaps) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = fninfo.GCLocals + + if x := lv.emitStackObjects(); x != nil { + p := pp.Prog(obj.AFUNCDATA) + p.From.SetConst(rtabi.FUNCDATA_StackObjects) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = x + } + + retLv := lv + if !retLiveness { + retLv = nil + } + + return lv.livenessMap, lv.partLiveArgs, retLv +} + +func (lv *Liveness) emitStackObjects() *obj.LSym { + var vars []*ir.Name + for _, n := range lv.fn.Dcl { + if shouldTrack(n) && n.Addrtaken() && n.Esc() != ir.EscHeap { + vars = append(vars, n) + } + } + if len(vars) == 0 { + return nil + } + + // Sort variables from lowest to highest address. + slices.SortFunc(vars, func(a, b *ir.Name) int { return cmp.Compare(a.FrameOffset(), b.FrameOffset()) }) + + // Populate the stack object data. + // Format must match runtime/stack.go:stackObjectRecord. + x := base.Ctxt.Lookup(lv.fn.LSym.Name + ".stkobj") + x.Set(obj.AttrContentAddressable, true) + lv.fn.LSym.Func().StackObjects = x + off := 0 + off = objw.Uintptr(x, off, uint64(len(vars))) + for _, v := range vars { + // Note: arguments and return values have non-negative Xoffset, + // in which case the offset is relative to argp. + // Locals have a negative Xoffset, in which case the offset is relative to varp. + // We already limit the frame size, so the offset and the object size + // should not be too big. + frameOffset := v.FrameOffset() + if frameOffset != int64(int32(frameOffset)) { + base.Fatalf("frame offset too big: %v %d", v, frameOffset) + } + off = objw.Uint32(x, off, uint32(frameOffset)) + + t := v.Type() + sz := t.Size() + if sz != int64(int32(sz)) { + base.Fatalf("stack object too big: %v of type %v, size %d", v, t, sz) + } + lsym, ptrBytes := reflectdata.GCSym(t, false) + off = objw.Uint32(x, off, uint32(sz)) + off = objw.Uint32(x, off, uint32(ptrBytes)) + off = objw.SymPtrOff(x, off, lsym) + } + + if base.Flag.Live != 0 { + for _, v := range vars { + base.WarnfAt(v.Pos(), "stack object %v %v", v, v.Type()) + } + } + + return x +} + +// isfat reports whether a variable of type t needs multiple assignments to initialize. +// For example: +// +// type T struct { x, y int } +// x := T{x: 0, y: 1} +// +// Then we need: +// +// var t T +// t.x = 0 +// t.y = 1 +// +// to fully initialize t. +func isfat(t *types.Type) bool { + if t != nil { + switch t.Kind() { + case types.TSLICE, types.TSTRING, + types.TINTER: // maybe remove later + return true + case types.TARRAY: + // Array of 1 element, check if element is fat + if t.NumElem() == 1 { + return isfat(t.Elem()) + } + return true + case types.TSTRUCT: + if t.IsSIMD() { + return false + } + // Struct with 1 field, check if field is fat + if t.NumFields() == 1 { + return isfat(t.Field(0).Type) + } + return true + } + } + + return false +} + +// WriteFuncMap writes the pointer bitmaps for bodyless function fn's +// inputs and outputs as the value of symbol .args_stackmap. +// If fn has outputs, two bitmaps are written, otherwise just one. +func WriteFuncMap(fn *ir.Func, abiInfo *abi.ABIParamResultInfo) { + if ir.FuncName(fn) == "_" { + return + } + nptr := int(abiInfo.ArgWidth() / int64(types.PtrSize)) + bv := bitvec.New(int32(nptr)) + + for _, p := range abiInfo.InParams() { + typebits.SetNoCheck(p.Type, p.FrameOffset(abiInfo), bv) + } + + nbitmap := 1 + if fn.Type().NumResults() > 0 { + nbitmap = 2 + } + lsym := base.Ctxt.Lookup(fn.LSym.Name + ".args_stackmap") + lsym.Set(obj.AttrLinkname, true) // allow args_stackmap referenced from assembly + off := objw.Uint32(lsym, 0, uint32(nbitmap)) + off = objw.Uint32(lsym, off, uint32(bv.N)) + off = objw.BitVec(lsym, off, bv) + + if fn.Type().NumResults() > 0 { + for _, p := range abiInfo.OutParams() { + if len(p.Registers) == 0 { + typebits.SetNoCheck(p.Type, p.FrameOffset(abiInfo), bv) + } + } + off = objw.BitVec(lsym, off, bv) + } + + objw.Global(lsym, int32(off), obj.RODATA|obj.LOCAL) +} diff --git a/go/src/cmd/compile/internal/logopt/log_opts.go b/go/src/cmd/compile/internal/logopt/log_opts.go new file mode 100644 index 0000000000000000000000000000000000000000..c47c9ee5afb23bf8a1fd6030bacb8326868e978f --- /dev/null +++ b/go/src/cmd/compile/internal/logopt/log_opts.go @@ -0,0 +1,540 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package logopt + +import ( + "cmd/internal/obj" + "cmd/internal/src" + "encoding/json" + "fmt" + "internal/buildcfg" + "io" + "log" + "net/url" + "os" + "path/filepath" + "sort" + "strconv" + "strings" + "sync" + "unicode" +) + +// This implements (non)optimization logging for -json option to the Go compiler +// The option is -json 0,. +// +// 0 is the version number; to avoid the need for synchronized updates, if +// new versions of the logging appear, the compiler will support both, for a while, +// and clients will specify what they need. +// +// is a directory. +// Directories are specified with a leading / or os.PathSeparator, +// or more explicitly with file://directory. The second form is intended to +// deal with corner cases on Windows, and to allow specification of a relative +// directory path (which is normally a bad idea, because the local directory +// varies a lot in a build, especially with modules and/or vendoring, and may +// not be writeable). +// +// For each package pkg compiled, a url.PathEscape(pkg)-named subdirectory +// is created. For each source file.go in that package that generates +// diagnostics (no diagnostics means no file), +// a url.PathEscape(file)+".json"-named file is created and contains the +// logged diagnostics. +// +// For example, "cmd%2Finternal%2Fdwarf/%3Cautogenerated%3E.json" +// for "cmd/internal/dwarf" and (which is not really a file, but the compiler sees it) +// +// If the package string is empty, it is replaced internally with string(0) which encodes to %00. +// +// Each log file begins with a JSON record identifying version, +// platform, and other context, followed by optimization-relevant +// LSP Diagnostic records, one per line (LSP version 3.15, no difference from 3.14 on the subset used here +// see https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/ ) +// +// The fields of a Diagnostic are used in the following way: +// Range: the outermost source position, for now begin and end are equal. +// Severity: (always) SeverityInformation (3) +// Source: (always) "go compiler" +// Code: a string describing the missed optimization, e.g., "nilcheck", "cannotInline", "isInBounds", "escape" +// Message: depending on code, additional information, e.g., the reason a function cannot be inlined. +// RelatedInformation: if the missed optimization actually occurred at a function inlined at Range, +// then the sequence of inlined locations appears here, from (second) outermost to innermost, +// each with message="inlineLoc". +// +// In the case of escape analysis explanations, after any outer inlining locations, +// the lines of the explanation appear, each potentially followed with its own inlining +// location if the escape flow occurred within an inlined function. +// +// For example /cmd%2Fcompile%2Finternal%2Fssa/prove.json +// might begin with the following line (wrapped for legibility): +// +// {"version":0,"package":"cmd/compile/internal/ssa","goos":"darwin","goarch":"amd64", +// "gc_version":"devel +e1b9a57852 Fri Nov 1 15:07:00 2019 -0400", +// "file":"/Users/drchase/work/go/src/cmd/compile/internal/ssa/prove.go"} +// +// and later contain (also wrapped for legibility): +// +// {"range":{"start":{"line":191,"character":24},"end":{"line":191,"character":24}}, +// "severity":3,"code":"nilcheck","source":"go compiler","message":"", +// "relatedInformation":[ +// {"location":{"uri":"file:///Users/drchase/work/go/src/cmd/compile/internal/ssa/func.go", +// "range":{"start":{"line":153,"character":16},"end":{"line":153,"character":16}}}, +// "message":"inlineLoc"}]} +// +// That is, at prove.go (implicit from context, provided in both filename and header line), +// line 191, column 24, a nilcheck occurred in the generated code. +// The relatedInformation indicates that this code actually came from +// an inlined call to func.go, line 153, character 16. +// +// prove.go:191: +// ft.orderS = f.newPoset() +// func.go:152 and 153: +// func (f *Func) newPoset() *poset { +// if len(f.Cache.scrPoset) > 0 { +// +// In the case that the package is empty, the string(0) package name is also used in the header record, for example +// +// go tool compile -json=0,file://logopt x.go # no -p option to set the package +// head -1 logopt/%00/x.json +// {"version":0,"package":"\u0000","goos":"darwin","goarch":"amd64","gc_version":"devel +86487adf6a Thu Nov 7 19:34:56 2019 -0500","file":"x.go"} + +type VersionHeader struct { + Version int `json:"version"` + Package string `json:"package"` + Goos string `json:"goos"` + Goarch string `json:"goarch"` + GcVersion string `json:"gc_version"` + File string `json:"file,omitempty"` // LSP requires an enclosing resource, i.e., a file +} + +// DocumentURI, Position, Range, Location, Diagnostic, DiagnosticRelatedInformation all reuse json definitions from gopls. +// See https://github.com/golang/tools/blob/22afafe3322a860fcd3d88448768f9db36f8bc5f/internal/lsp/protocol/tsprotocol.go + +type DocumentURI string + +type Position struct { + Line uint `json:"line"` // gopls uses float64, but json output is the same for integers + Character uint `json:"character"` // gopls uses float64, but json output is the same for integers +} + +// A Range in a text document expressed as (zero-based) start and end positions. +// A range is comparable to a selection in an editor. Therefore the end position is exclusive. +// If you want to specify a range that contains a line including the line ending character(s) +// then use an end position denoting the start of the next line. +type Range struct { + /*Start defined: + * The range's start position + */ + Start Position `json:"start"` + + /*End defined: + * The range's end position + */ + End Position `json:"end"` // exclusive +} + +// A Location represents a location inside a resource, such as a line inside a text file. +type Location struct { + // URI is + URI DocumentURI `json:"uri"` + + // Range is + Range Range `json:"range"` +} + +/* DiagnosticRelatedInformation defined: + * Represents a related message and source code location for a diagnostic. This should be + * used to point to code locations that cause or related to a diagnostics, e.g when duplicating + * a symbol in a scope. + */ +type DiagnosticRelatedInformation struct { + + /*Location defined: + * The location of this related diagnostic information. + */ + Location Location `json:"location"` + + /*Message defined: + * The message of this related diagnostic information. + */ + Message string `json:"message"` +} + +// DiagnosticSeverity defines constants +type DiagnosticSeverity uint + +const ( + /*SeverityInformation defined: + * Reports an information. + */ + SeverityInformation DiagnosticSeverity = 3 +) + +// DiagnosticTag defines constants +type DiagnosticTag uint + +/*Diagnostic defined: + * Represents a diagnostic, such as a compiler error or warning. Diagnostic objects + * are only valid in the scope of a resource. + */ +type Diagnostic struct { + + /*Range defined: + * The range at which the message applies + */ + Range Range `json:"range"` + + /*Severity defined: + * The diagnostic's severity. Can be omitted. If omitted it is up to the + * client to interpret diagnostics as error, warning, info or hint. + */ + Severity DiagnosticSeverity `json:"severity,omitempty"` // always SeverityInformation for optimizer logging. + + /*Code defined: + * The diagnostic's code, which usually appear in the user interface. + */ + Code string `json:"code,omitempty"` // LSP uses 'number | string' = gopls interface{}, but only string here, e.g. "boundsCheck", "nilcheck", etc. + + /*Source defined: + * A human-readable string describing the source of this + * diagnostic, e.g. 'typescript' or 'super lint'. It usually + * appears in the user interface. + */ + Source string `json:"source,omitempty"` // "go compiler" + + /*Message defined: + * The diagnostic's message. It usually appears in the user interface + */ + Message string `json:"message"` // sometimes used, provides additional information. + + /*Tags defined: + * Additional metadata about the diagnostic. + */ + Tags []DiagnosticTag `json:"tags,omitempty"` // always empty for logging optimizations. + + /*RelatedInformation defined: + * An array of related diagnostic information, e.g. when symbol-names within + * a scope collide all definitions can be marked via this property. + */ + RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"` +} + +// A LoggedOpt is what the compiler produces and accumulates, +// to be converted to JSON for human or IDE consumption. +type LoggedOpt struct { + pos src.XPos // Source code position at which the event occurred. If it is inlined, outer and all inlined locations will appear in JSON. + lastPos src.XPos // Usually the same as pos; current exception is for reporting entire range of transformed loops + compilerPass string // Compiler pass. For human/adhoc consumption; does not appear in JSON (yet) + functionName string // Function name. For human/adhoc consumption; does not appear in JSON (yet) + what string // The (non) optimization; "nilcheck", "boundsCheck", "inline", "noInline" + target []any // Optional target(s) or parameter(s) of "what" -- what was inlined, why it was not, size of copy, etc. 1st is most important/relevant. +} + +type logFormat uint8 + +const ( + None logFormat = iota + Json0 // version 0 for LSP 3.14, 3.15; future versions of LSP may change the format and the compiler may need to support both as clients are updated. +) + +var Format = None +var dest string + +// LogJsonOption parses and validates the version,directory value attached to the -json compiler flag. +func LogJsonOption(flagValue string) { + version, directory := parseLogFlag("json", flagValue) + if version != 0 { + log.Fatal("-json version must be 0") + } + dest = checkLogPath(directory) + Format = Json0 +} + +// parseLogFlag checks the flag passed to -json +// for version,destination format and returns the two parts. +func parseLogFlag(flag, value string) (version int, directory string) { + if Format != None { + log.Fatal("Cannot repeat -json flag") + } + commaAt := strings.Index(value, ",") + if commaAt <= 0 { + log.Fatalf("-%s option should be ',' where is a number", flag) + } + v, err := strconv.Atoi(value[:commaAt]) + if err != nil { + log.Fatalf("-%s option should be ',' where is a number: err=%v", flag, err) + } + version = v + directory = value[commaAt+1:] + return +} + +// isWindowsDriveURIPath returns true if the file URI is of the format used by +// Windows URIs. The url.Parse package does not specially handle Windows paths +// (see golang/go#6027), so we check if the URI path has a drive prefix (e.g. "/C:"). +// (copied from tools/internal/span/uri.go) +// this is less comprehensive that the processing in filepath.IsAbs on Windows. +func isWindowsDriveURIPath(uri string) bool { + if len(uri) < 4 { + return false + } + return uri[0] == '/' && unicode.IsLetter(rune(uri[1])) && uri[2] == ':' +} + +func parseLogPath(destination string) (string, string) { + if filepath.IsAbs(destination) { + return filepath.Clean(destination), "" + } + if strings.HasPrefix(destination, "file://") { // IKWIAD, or Windows C:\foo\bar\baz + uri, err := url.Parse(destination) + if err != nil { + return "", fmt.Sprintf("optimizer logging destination looked like file:// URI but failed to parse: err=%v", err) + } + destination = uri.Host + uri.Path + if isWindowsDriveURIPath(destination) { + // strip leading / from /C: + // unlike tools/internal/span/uri.go, do not uppercase the drive letter -- let filepath.Clean do what it does. + destination = destination[1:] + } + return filepath.Clean(destination), "" + } + return "", fmt.Sprintf("optimizer logging destination %s was neither %s-prefixed directory nor file://-prefixed file URI", destination, string(filepath.Separator)) +} + +// checkLogPath does superficial early checking of the string specifying +// the directory to which optimizer logging is directed, and if +// it passes the test, stores the string in LO_dir. +func checkLogPath(destination string) string { + path, complaint := parseLogPath(destination) + if complaint != "" { + log.Fatal(complaint) + } + err := os.MkdirAll(path, 0755) + if err != nil { + log.Fatalf("optimizer logging destination ',' but could not create : err=%v", err) + } + return path +} + +var loggedOpts []*LoggedOpt +var mu = sync.Mutex{} // mu protects loggedOpts. + +// NewLoggedOpt allocates a new LoggedOpt, to later be passed to either NewLoggedOpt or LogOpt as "args". +// Pos is the source position (including inlining), what is the message, pass is which pass created the message, +// funcName is the name of the function +// A typical use for this to accumulate an explanation for a missed optimization, for example, why did something escape? +func NewLoggedOpt(pos, lastPos src.XPos, what, pass, funcName string, args ...any) *LoggedOpt { + pass = strings.ReplaceAll(pass, " ", "_") + return &LoggedOpt{pos, lastPos, pass, funcName, what, args} +} + +// LogOpt logs information about a (usually missed) optimization performed by the compiler. +// Pos is the source position (including inlining), what is the message, pass is which pass created the message, +// funcName is the name of the function. +func LogOpt(pos src.XPos, what, pass, funcName string, args ...any) { + if Format == None { + return + } + lo := NewLoggedOpt(pos, pos, what, pass, funcName, args...) + mu.Lock() + defer mu.Unlock() + // Because of concurrent calls from back end, no telling what the order will be, but is stable-sorted by outer Pos before use. + loggedOpts = append(loggedOpts, lo) +} + +// LogOptRange is the same as LogOpt, but includes the ability to express a range of positions, +// not just a point. +func LogOptRange(pos, lastPos src.XPos, what, pass, funcName string, args ...any) { + if Format == None { + return + } + lo := NewLoggedOpt(pos, lastPos, what, pass, funcName, args...) + mu.Lock() + defer mu.Unlock() + // Because of concurrent calls from back end, no telling what the order will be, but is stable-sorted by outer Pos before use. + loggedOpts = append(loggedOpts, lo) +} + +// Enabled returns whether optimization logging is enabled. +func Enabled() bool { + switch Format { + case None: + return false + case Json0: + return true + } + panic("Unexpected optimizer-logging level") +} + +// byPos sorts diagnostics by source position. +type byPos struct { + ctxt *obj.Link + a []*LoggedOpt +} + +func (x byPos) Len() int { return len(x.a) } +func (x byPos) Less(i, j int) bool { + return x.ctxt.OutermostPos(x.a[i].pos).Before(x.ctxt.OutermostPos(x.a[j].pos)) +} +func (x byPos) Swap(i, j int) { x.a[i], x.a[j] = x.a[j], x.a[i] } + +func writerForLSP(subdirpath, file string) io.WriteCloser { + basename := file + lastslash := strings.LastIndexAny(basename, "\\/") + if lastslash != -1 { + basename = basename[lastslash+1:] + } + lastdot := strings.LastIndex(basename, ".go") + if lastdot != -1 { + basename = basename[:lastdot] + } + basename = url.PathEscape(basename) + + // Assume a directory, make a file + p := filepath.Join(subdirpath, basename+".json") + w, err := os.Create(p) + if err != nil { + log.Fatalf("Could not create file %s for logging optimizer actions, %v", p, err) + } + return w +} + +func fixSlash(f string) string { + if os.PathSeparator == '/' { + return f + } + return strings.ReplaceAll(f, string(os.PathSeparator), "/") +} + +func uriIfy(f string) DocumentURI { + url := url.URL{ + Scheme: "file", + Path: fixSlash(f), + } + return DocumentURI(url.String()) +} + +// Return filename, replacing a first occurrence of $GOROOT with the +// actual value of the GOROOT (because LSP does not speak "$GOROOT"). +func uprootedPath(filename string) string { + if filename == "" { + return "__unnamed__" + } + if buildcfg.GOROOT == "" || !strings.HasPrefix(filename, "$GOROOT/") { + return filename + } + return buildcfg.GOROOT + filename[len("$GOROOT"):] +} + +// FlushLoggedOpts flushes all the accumulated optimization log entries. +func FlushLoggedOpts(ctxt *obj.Link, slashPkgPath string) { + if Format == None { + return + } + + sort.Stable(byPos{ctxt, loggedOpts}) // Stable is necessary to preserve the per-function order, which is repeatable. + switch Format { + + case Json0: // LSP 3.15 + var posTmp, lastTmp []src.Pos + var encoder *json.Encoder + var w io.WriteCloser + + if slashPkgPath == "" { + slashPkgPath = "\000" + } + subdirpath := filepath.Join(dest, url.PathEscape(slashPkgPath)) + err := os.MkdirAll(subdirpath, 0755) + if err != nil { + log.Fatalf("Could not create directory %s for logging optimizer actions, %v", subdirpath, err) + } + diagnostic := Diagnostic{Source: "go compiler", Severity: SeverityInformation} + + // For LSP, make a subdirectory for the package, and for each file foo.go, create foo.json in that subdirectory. + currentFile := "" + for _, x := range loggedOpts { + posTmp, p0 := parsePos(ctxt, x.pos, posTmp) + lastTmp, l0 := parsePos(ctxt, x.lastPos, lastTmp) // These match posTmp/p0 except for most-inline, and that often also matches. + p0f := uprootedPath(p0.Filename()) + + if currentFile != p0f { + if w != nil { + w.Close() + } + currentFile = p0f + w = writerForLSP(subdirpath, currentFile) + encoder = json.NewEncoder(w) + encoder.Encode(VersionHeader{Version: 0, Package: slashPkgPath, Goos: buildcfg.GOOS, Goarch: buildcfg.GOARCH, GcVersion: buildcfg.Version, File: currentFile}) + } + + // The first "target" is the most important one. + var target string + if len(x.target) > 0 { + target = fmt.Sprint(x.target[0]) + } + + diagnostic.Code = x.what + diagnostic.Message = target + diagnostic.Range = newRange(p0, l0) + diagnostic.RelatedInformation = diagnostic.RelatedInformation[:0] + + appendInlinedPos(posTmp, lastTmp, &diagnostic) + + // Diagnostic explanation is stored in RelatedInformation after inlining info + if len(x.target) > 1 { + switch y := x.target[1].(type) { + case []*LoggedOpt: + for _, z := range y { + posTmp, p0 := parsePos(ctxt, z.pos, posTmp) + lastTmp, l0 := parsePos(ctxt, z.lastPos, lastTmp) + loc := newLocation(p0, l0) + msg := z.what + if len(z.target) > 0 { + msg = msg + ": " + fmt.Sprint(z.target[0]) + } + + diagnostic.RelatedInformation = append(diagnostic.RelatedInformation, DiagnosticRelatedInformation{Location: loc, Message: msg}) + appendInlinedPos(posTmp, lastTmp, &diagnostic) + } + } + } + + encoder.Encode(diagnostic) + } + if w != nil { + w.Close() + } + } +} + +// newRange returns a single-position Range for the compiler source location p. +func newRange(p, last src.Pos) Range { + return Range{Start: Position{p.Line(), p.Col()}, + End: Position{last.Line(), last.Col()}} +} + +// newLocation returns the Location for the compiler source location p. +func newLocation(p, last src.Pos) Location { + loc := Location{URI: uriIfy(uprootedPath(p.Filename())), Range: newRange(p, last)} + return loc +} + +// appendInlinedPos extracts inlining information from posTmp and append it to diagnostic. +func appendInlinedPos(posTmp, lastTmp []src.Pos, diagnostic *Diagnostic) { + for i := 1; i < len(posTmp); i++ { + loc := newLocation(posTmp[i], lastTmp[i]) + diagnostic.RelatedInformation = append(diagnostic.RelatedInformation, DiagnosticRelatedInformation{Location: loc, Message: "inlineLoc"}) + } +} + +// parsePos expands a src.XPos into a slice of src.Pos, with the outermost first. +// It returns the slice, and the outermost. +func parsePos(ctxt *obj.Link, pos src.XPos, posTmp []src.Pos) ([]src.Pos, src.Pos) { + posTmp = posTmp[:0] + ctxt.AllPos(pos, func(p src.Pos) { + posTmp = append(posTmp, p) + }) + return posTmp, posTmp[0] +} diff --git a/go/src/cmd/compile/internal/logopt/logopt_test.go b/go/src/cmd/compile/internal/logopt/logopt_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1edabf9fb7ff0430844da72b3f1e51c6b0814603 --- /dev/null +++ b/go/src/cmd/compile/internal/logopt/logopt_test.go @@ -0,0 +1,250 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package logopt + +import ( + "internal/testenv" + "os" + "path/filepath" + "runtime" + "strings" + "testing" +) + +const srcCode = `package x +type pair struct {a,b int} +func bar(y *pair) *int { + return &y.b +} +var a []int +func foo(w, z *pair) *int { + if *bar(w) > 0 { + return bar(z) + } + if a[1] > 0 { + a = a[:2] + } + return &a[0] +} + +// address taking prevents closure inlining +func n() int { + foo := func() int { return 1 } + bar := &foo + x := (*bar)() + foo() + return x +} +` + +func want(t *testing.T, out string, desired string) { + // On Windows, Unicode escapes in the JSON output end up "normalized" elsewhere to /u...., + // so "normalize" what we're looking for to match that. + s := strings.ReplaceAll(desired, string(os.PathSeparator), "/") + if !strings.Contains(out, s) { + t.Errorf("did not see phrase %s in \n%s", s, out) + } +} + +func wantN(t *testing.T, out string, desired string, n int) { + if strings.Count(out, desired) != n { + t.Errorf("expected exactly %d occurrences of %s in \n%s", n, desired, out) + } +} + +func TestPathStuff(t *testing.T) { + sep := string(filepath.Separator) + if path, whine := parseLogPath("file:///c:foo"); path != "c:foo" || whine != "" { // good path + t.Errorf("path='%s', whine='%s'", path, whine) + } + if path, whine := parseLogPath("file:///foo"); path != sep+"foo" || whine != "" { // good path + t.Errorf("path='%s', whine='%s'", path, whine) + } + if path, whine := parseLogPath("foo"); path != "" || whine == "" { // BAD path + t.Errorf("path='%s', whine='%s'", path, whine) + } + if sep == "\\" { // On WINDOWS ONLY + if path, whine := parseLogPath("C:/foo"); path != "C:\\foo" || whine != "" { // good path + t.Errorf("path='%s', whine='%s'", path, whine) + } + if path, whine := parseLogPath("c:foo"); path != "" || whine == "" { // BAD path + t.Errorf("path='%s', whine='%s'", path, whine) + } + if path, whine := parseLogPath("/foo"); path != "" || whine == "" { // BAD path + t.Errorf("path='%s', whine='%s'", path, whine) + } + } else { // ON UNIX ONLY + if path, whine := parseLogPath("/foo"); path != sep+"foo" || whine != "" { // good path + t.Errorf("path='%s', whine='%s'", path, whine) + } + } +} + +func TestLogOpt(t *testing.T) { + t.Parallel() + + testenv.MustHaveGoBuild(t) + + dir := fixSlash(t.TempDir()) // Normalize the directory name as much as possible, for Windows testing + src := filepath.Join(dir, "file.go") + if err := os.WriteFile(src, []byte(srcCode), 0644); err != nil { + t.Fatal(err) + } + + outfile := filepath.Join(dir, "file.o") + + t.Run("JSON_fails", func(t *testing.T) { + // Test malformed flag + out, err := testLogOpt(t, "-json=foo", src, outfile) + if err == nil { + t.Error("-json=foo succeeded unexpectedly") + } + want(t, out, "option should be") + want(t, out, "number") + + // Test a version number that is currently unsupported (and should remain unsupported for a while) + out, err = testLogOpt(t, "-json=9,foo", src, outfile) + if err == nil { + t.Error("-json=0,foo succeeded unexpectedly") + } + want(t, out, "version must be") + + }) + + // replace d (dir) with t ("tmpdir") and convert path separators to '/' + normalize := func(out []byte, d, t string) string { + s := string(out) + s = strings.ReplaceAll(s, d, t) + s = strings.ReplaceAll(s, string(os.PathSeparator), "/") + return s + } + + // Ensure that <128 byte copies are not reported and that 128-byte copies are. + // Check at both 1 and 8-byte alignments. + t.Run("Copy", func(t *testing.T) { + const copyCode = `package x +func s128a1(x *[128]int8) [128]int8 { + return *x +} +func s127a1(x *[127]int8) [127]int8 { + return *x +} +func s16a8(x *[16]int64) [16]int64 { + return *x +} +func s15a8(x *[15]int64) [15]int64 { + return *x +} +` + copy := filepath.Join(dir, "copy.go") + if err := os.WriteFile(copy, []byte(copyCode), 0644); err != nil { + t.Fatal(err) + } + outcopy := filepath.Join(dir, "copy.o") + + // On not-amd64, test the host architecture and os + arches := []string{runtime.GOARCH} + goos0 := runtime.GOOS + if runtime.GOARCH == "amd64" { // Test many things with "linux" (wasm will get "js") + arches = []string{"arm", "arm64", "386", "amd64", "mips", "mips64", "loong64", "ppc64le", "riscv64", "s390x", "wasm"} + goos0 = "linux" + } + + for _, arch := range arches { + t.Run(arch, func(t *testing.T) { + goos := goos0 + if arch == "wasm" { + goos = "js" + } + _, err := testCopy(t, dir, arch, goos, copy, outcopy) + if err != nil { + t.Error("-json=0,file://log/opt should have succeeded") + } + logged, err := os.ReadFile(filepath.Join(dir, "log", "opt", "x", "copy.json")) + if err != nil { + t.Error("-json=0,file://log/opt missing expected log file") + } + slogged := normalize(logged, string(uriIfy(dir)), string(uriIfy("tmpdir"))) + t.Logf("%s", slogged) + want(t, slogged, `{"range":{"start":{"line":3,"character":2},"end":{"line":3,"character":2}},"severity":3,"code":"copy","source":"go compiler","message":"128 bytes"}`) + want(t, slogged, `{"range":{"start":{"line":9,"character":2},"end":{"line":9,"character":2}},"severity":3,"code":"copy","source":"go compiler","message":"128 bytes"}`) + wantN(t, slogged, `"code":"copy"`, 2) + }) + } + }) + + // Some architectures don't fault on nil dereference, so nilchecks are eliminated differently. + // The N-way copy test also doesn't need to run N-ways N times. + if runtime.GOARCH != "amd64" { + return + } + + t.Run("Success", func(t *testing.T) { + // This test is supposed to succeed + + // Note 'file://' is the I-Know-What-I-Am-Doing way of specifying a file, also to deal with corner cases for Windows. + _, err := testLogOptDir(t, dir, "-json=0,file://log/opt", src, outfile) + if err != nil { + t.Error("-json=0,file://log/opt should have succeeded") + } + logged, err := os.ReadFile(filepath.Join(dir, "log", "opt", "x", "file.json")) + if err != nil { + t.Error("-json=0,file://log/opt missing expected log file") + } + // All this delicacy with uriIfy and filepath.Join is to get this test to work right on Windows. + slogged := normalize(logged, string(uriIfy(dir)), string(uriIfy("tmpdir"))) + t.Logf("%s", slogged) + // below shows proper nilcheck + want(t, slogged, `{"range":{"start":{"line":9,"character":13},"end":{"line":9,"character":13}},"severity":3,"code":"nilcheck","source":"go compiler","message":"",`+ + `"relatedInformation":[{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":4,"character":11},"end":{"line":4,"character":11}}},"message":"inlineLoc"}]}`) + want(t, slogged, `{"range":{"start":{"line":11,"character":6},"end":{"line":11,"character":6}},"severity":3,"code":"isInBounds","source":"go compiler","message":""}`) + want(t, slogged, `{"range":{"start":{"line":7,"character":6},"end":{"line":7,"character":6}},"severity":3,"code":"canInlineFunction","source":"go compiler","message":"cost: 35"}`) + // escape analysis explanation + want(t, slogged, `{"range":{"start":{"line":7,"character":13},"end":{"line":7,"character":13}},"severity":3,"code":"leak","source":"go compiler","message":"parameter z leaks to ~r0 with derefs=0",`+ + `"relatedInformation":[`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":13},"end":{"line":9,"character":13}}},"message":"escflow: flow: y ← z:"},`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":13},"end":{"line":9,"character":13}}},"message":"escflow: from y := z (assign-pair)"},`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":13},"end":{"line":9,"character":13}}},"message":"escflow: flow: ~r0 ← y:"},`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":4,"character":11},"end":{"line":4,"character":11}}},"message":"inlineLoc"},`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":13},"end":{"line":9,"character":13}}},"message":"escflow: from y.b (dot of pointer)"},`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":4,"character":11},"end":{"line":4,"character":11}}},"message":"inlineLoc"},`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":13},"end":{"line":9,"character":13}}},"message":"escflow: from \u0026y.b (address-of)"},`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":4,"character":9},"end":{"line":4,"character":9}}},"message":"inlineLoc"},`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":13},"end":{"line":9,"character":13}}},"message":"escflow: from ~r0 = \u0026y.b (assign-pair)"},`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":3},"end":{"line":9,"character":3}}},"message":"escflow: flow: ~r0 ← ~r0:"},`+ + `{"location":{"uri":"file://tmpdir/file.go","range":{"start":{"line":9,"character":3},"end":{"line":9,"character":3}}},"message":"escflow: from return ~r0 (return)"}]}`) + }) +} + +func testLogOpt(t *testing.T, flag, src, outfile string) (string, error) { + run := []string{testenv.GoToolPath(t), "tool", "compile", "-p=p", flag, "-o", outfile, src} + t.Log(run) + cmd := testenv.Command(t, run[0], run[1:]...) + out, err := cmd.CombinedOutput() + t.Logf("%s", out) + return string(out), err +} + +func testLogOptDir(t *testing.T, dir, flag, src, outfile string) (string, error) { + // Notice the specified import path "x" + run := []string{testenv.GoToolPath(t), "tool", "compile", "-p=x", flag, "-o", outfile, src} + t.Log(run) + cmd := testenv.Command(t, run[0], run[1:]...) + cmd.Dir = dir + out, err := cmd.CombinedOutput() + t.Logf("%s", out) + return string(out), err +} + +func testCopy(t *testing.T, dir, goarch, goos, src, outfile string) (string, error) { + // Notice the specified import path "x" + run := []string{testenv.GoToolPath(t), "tool", "compile", "-p=x", "-json=0,file://log/opt", "-o", outfile, src} + t.Log(run) + cmd := testenv.Command(t, run[0], run[1:]...) + cmd.Dir = dir + cmd.Env = append(os.Environ(), "GOARCH="+goarch, "GOOS="+goos) + out, err := cmd.CombinedOutput() + t.Logf("%s", out) + return string(out), err +} diff --git a/go/src/cmd/compile/internal/loong64/galign.go b/go/src/cmd/compile/internal/loong64/galign.go new file mode 100644 index 0000000000000000000000000000000000000000..a613165054429f995b569f049880fd5618611a09 --- /dev/null +++ b/go/src/cmd/compile/internal/loong64/galign.go @@ -0,0 +1,25 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package loong64 + +import ( + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/internal/obj/loong64" +) + +func Init(arch *ssagen.ArchInfo) { + arch.LinkArch = &loong64.Linkloong64 + arch.REGSP = loong64.REGSP + arch.MAXWIDTH = 1 << 50 + arch.ZeroRange = zerorange + arch.Ginsnop = ginsnop + + arch.SSAMarkMoves = func(s *ssagen.State, b *ssa.Block) {} + arch.SSAGenValue = ssaGenValue + arch.SSAGenBlock = ssaGenBlock + arch.LoadRegResult = loadRegResult + arch.SpillArgReg = spillArgReg +} diff --git a/go/src/cmd/compile/internal/loong64/ggen.go b/go/src/cmd/compile/internal/loong64/ggen.go new file mode 100644 index 0000000000000000000000000000000000000000..bb1b146346191c8417e62bfcd72772ce329eef32 --- /dev/null +++ b/go/src/cmd/compile/internal/loong64/ggen.go @@ -0,0 +1,34 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package loong64 + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/objw" + "cmd/internal/obj" + "cmd/internal/obj/loong64" +) + +func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { + if cnt%8 != 0 { + panic("zeroed region not aligned") + } + + // Adjust the frame to account for LR. + off += base.Ctxt.Arch.FixedFrameSize + + for cnt != 0 { + p = pp.Append(p, loong64.AMOVV, obj.TYPE_REG, loong64.REGZERO, 0, obj.TYPE_MEM, loong64.REGSP, off) + off += 8 + cnt -= 8 + } + + return p +} + +func ginsnop(pp *objw.Progs) *obj.Prog { + p := pp.Prog(loong64.ANOOP) + return p +} diff --git a/go/src/cmd/compile/internal/loong64/ssa.go b/go/src/cmd/compile/internal/loong64/ssa.go new file mode 100644 index 0000000000000000000000000000000000000000..dc737732f1b09da786be795614f7f615a0eee19f --- /dev/null +++ b/go/src/cmd/compile/internal/loong64/ssa.go @@ -0,0 +1,1417 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package loong64 + +import ( + "math" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/objw" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/loong64" + "internal/abi" +) + +// isFPreg reports whether r is an FP register. +func isFPreg(r int16) bool { + return loong64.REG_F0 <= r && r <= loong64.REG_F31 +} + +// loadByType returns the load instruction of the given type. +func loadByType(t *types.Type, r int16) obj.As { + if isFPreg(r) { + if t.Size() == 4 { + return loong64.AMOVF + } else { + return loong64.AMOVD + } + } else { + switch t.Size() { + case 1: + if t.IsSigned() { + return loong64.AMOVB + } else { + return loong64.AMOVBU + } + case 2: + if t.IsSigned() { + return loong64.AMOVH + } else { + return loong64.AMOVHU + } + case 4: + if t.IsSigned() { + return loong64.AMOVW + } else { + return loong64.AMOVWU + } + case 8: + return loong64.AMOVV + } + } + panic("bad load type") +} + +// storeByType returns the store instruction of the given type. +func storeByType(t *types.Type, r int16) obj.As { + if isFPreg(r) { + if t.Size() == 4 { + return loong64.AMOVF + } else { + return loong64.AMOVD + } + } else { + switch t.Size() { + case 1: + return loong64.AMOVB + case 2: + return loong64.AMOVH + case 4: + return loong64.AMOVW + case 8: + return loong64.AMOVV + } + } + panic("bad store type") +} + +// largestMove returns the largest move instruction possible and its size, +// given the alignment of the total size of the move. +// +// e.g., a 16-byte move may use MOVV, but an 11-byte move must use MOVB. +// +// Note that the moves may not be on naturally aligned addresses depending on +// the source and destination. +// +// This matches the calculation in ssa.moveSize. +func largestMove(alignment int64) (obj.As, int64) { + switch { + case alignment%8 == 0: + return loong64.AMOVV, 8 + case alignment%4 == 0: + return loong64.AMOVW, 4 + case alignment%2 == 0: + return loong64.AMOVH, 2 + default: + return loong64.AMOVB, 1 + } +} + +func ssaGenValue(s *ssagen.State, v *ssa.Value) { + switch v.Op { + case ssa.OpCopy, ssa.OpLOONG64MOVVreg: + if v.Type.IsMemory() { + return + } + x := v.Args[0].Reg() + y := v.Reg() + if x == y { + return + } + as := loong64.AMOVV + if isFPreg(x) && isFPreg(y) { + as = loong64.AMOVD + } + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = x + p.To.Type = obj.TYPE_REG + p.To.Reg = y + case ssa.OpLOONG64MOVVnop, + ssa.OpLOONG64ZERO, + ssa.OpLOONG64LoweredRound32F, + ssa.OpLOONG64LoweredRound64F: + // nothing to do + case ssa.OpLoadReg: + if v.Type.IsFlags() { + v.Fatalf("load flags not implemented: %v", v.LongString()) + return + } + r := v.Reg() + p := s.Prog(loadByType(v.Type, r)) + ssagen.AddrAuto(&p.From, v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpStoreReg: + if v.Type.IsFlags() { + v.Fatalf("store flags not implemented: %v", v.LongString()) + return + } + r := v.Args[0].Reg() + p := s.Prog(storeByType(v.Type, r)) + p.From.Type = obj.TYPE_REG + p.From.Reg = r + ssagen.AddrAuto(&p.To, v) + case ssa.OpArgIntReg, ssa.OpArgFloatReg: + // The assembler needs to wrap the entry safepoint/stack growth code with spill/unspill + // The loop only runs once. + for _, a := range v.Block.Func.RegArgs { + // Pass the spill/unspill information along to the assembler, offset by size of + // the saved LR slot. + addr := ssagen.SpillSlotAddr(a, loong64.REGSP, base.Ctxt.Arch.FixedFrameSize) + s.FuncInfo().AddSpill( + obj.RegSpill{Reg: a.Reg, Addr: addr, Unspill: loadByType(a.Type, a.Reg), Spill: storeByType(a.Type, a.Reg)}) + } + v.Block.Func.RegArgs = nil + ssagen.CheckArgReg(v) + case ssa.OpLOONG64ADDV, + ssa.OpLOONG64SUBV, + ssa.OpLOONG64AND, + ssa.OpLOONG64OR, + ssa.OpLOONG64XOR, + ssa.OpLOONG64NOR, + ssa.OpLOONG64ANDN, + ssa.OpLOONG64ORN, + ssa.OpLOONG64SLL, + ssa.OpLOONG64SLLV, + ssa.OpLOONG64SRL, + ssa.OpLOONG64SRLV, + ssa.OpLOONG64SRA, + ssa.OpLOONG64SRAV, + ssa.OpLOONG64ROTR, + ssa.OpLOONG64ROTRV, + ssa.OpLOONG64ADDF, + ssa.OpLOONG64ADDD, + ssa.OpLOONG64SUBF, + ssa.OpLOONG64SUBD, + ssa.OpLOONG64MULF, + ssa.OpLOONG64MULD, + ssa.OpLOONG64DIVF, + ssa.OpLOONG64DIVD, + ssa.OpLOONG64MULV, ssa.OpLOONG64MULHV, ssa.OpLOONG64MULHVU, ssa.OpLOONG64MULH, ssa.OpLOONG64MULHU, + ssa.OpLOONG64DIVV, ssa.OpLOONG64REMV, ssa.OpLOONG64DIVVU, ssa.OpLOONG64REMVU, + ssa.OpLOONG64MULWVW, ssa.OpLOONG64MULWVWU, + ssa.OpLOONG64FCOPYSGD: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpLOONG64BSTRPICKV, + ssa.OpLOONG64BSTRPICKW: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + if v.Op == ssa.OpLOONG64BSTRPICKW { + p.From.Offset = v.AuxInt >> 5 + p.AddRestSourceConst(v.AuxInt & 0x1f) + } else { + p.From.Offset = v.AuxInt >> 6 + p.AddRestSourceConst(v.AuxInt & 0x3f) + } + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpLOONG64FMINF, + ssa.OpLOONG64FMIND, + ssa.OpLOONG64FMAXF, + ssa.OpLOONG64FMAXD: + // ADDD Rarg0, Rarg1, Rout + // CMPEQD Rarg0, Rarg0, FCC0 + // bceqz FCC0, end + // CMPEQD Rarg1, Rarg1, FCC0 + // bceqz FCC0, end + // F(MIN|MAX)(F|D) + + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg() + add, fcmp := loong64.AADDD, loong64.ACMPEQD + if v.Op == ssa.OpLOONG64FMINF || v.Op == ssa.OpLOONG64FMAXF { + add = loong64.AADDF + fcmp = loong64.ACMPEQF + } + p1 := s.Prog(add) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r0 + p1.Reg = r1 + p1.To.Type = obj.TYPE_REG + p1.To.Reg = out + + p2 := s.Prog(fcmp) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = r0 + p2.Reg = r0 + p2.To.Type = obj.TYPE_REG + p2.To.Reg = loong64.REG_FCC0 + + p3 := s.Prog(loong64.ABFPF) + p3.To.Type = obj.TYPE_BRANCH + + p4 := s.Prog(fcmp) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = r1 + p4.Reg = r1 + p4.To.Type = obj.TYPE_REG + p4.To.Reg = loong64.REG_FCC0 + + p5 := s.Prog(loong64.ABFPF) + p5.To.Type = obj.TYPE_BRANCH + + p6 := s.Prog(v.Op.Asm()) + p6.From.Type = obj.TYPE_REG + p6.From.Reg = r1 + p6.Reg = r0 + p6.To.Type = obj.TYPE_REG + p6.To.Reg = out + + nop := s.Prog(obj.ANOP) + p3.To.SetTarget(nop) + p5.To.SetTarget(nop) + + case ssa.OpLOONG64SGT, + ssa.OpLOONG64SGTU: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpLOONG64ADDVconst, + ssa.OpLOONG64ADDV16const, + ssa.OpLOONG64SUBVconst, + ssa.OpLOONG64ANDconst, + ssa.OpLOONG64ORconst, + ssa.OpLOONG64XORconst, + ssa.OpLOONG64SLLconst, + ssa.OpLOONG64SLLVconst, + ssa.OpLOONG64SRLconst, + ssa.OpLOONG64SRLVconst, + ssa.OpLOONG64SRAconst, + ssa.OpLOONG64SRAVconst, + ssa.OpLOONG64ROTRconst, + ssa.OpLOONG64ROTRVconst, + ssa.OpLOONG64SGTconst, + ssa.OpLOONG64SGTUconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpLOONG64NORconst: + // MOVV $const, Rtmp + // NOR Rtmp, Rarg0, Rout + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = loong64.REGTMP + + p2 := s.Prog(v.Op.Asm()) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = loong64.REGTMP + p2.Reg = v.Args[0].Reg() + p2.To.Type = obj.TYPE_REG + p2.To.Reg = v.Reg() + + case ssa.OpLOONG64MOVVconst: + r := v.Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = r + if isFPreg(r) { + // cannot move into FP or special registers, use TMP as intermediate + p.To.Reg = loong64.REGTMP + p = s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = loong64.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = r + } + case ssa.OpLOONG64MOVFconst, + ssa.OpLOONG64MOVDconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_FCONST + p.From.Val = math.Float64frombits(uint64(v.AuxInt)) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpLOONG64CMPEQF, + ssa.OpLOONG64CMPEQD, + ssa.OpLOONG64CMPGEF, + ssa.OpLOONG64CMPGED, + ssa.OpLOONG64CMPGTF, + ssa.OpLOONG64CMPGTD: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = loong64.REG_FCC0 + + case ssa.OpLOONG64FMADDF, + ssa.OpLOONG64FMADDD, + ssa.OpLOONG64FMSUBF, + ssa.OpLOONG64FMSUBD, + ssa.OpLOONG64FNMADDF, + ssa.OpLOONG64FNMADDD, + ssa.OpLOONG64FNMSUBF, + ssa.OpLOONG64FNMSUBD: + p := s.Prog(v.Op.Asm()) + // r=(FMA x y z) -> FMADDD z, y, x, r + // the SSA operand order is for taking advantage of + // commutativity (that only applies for the first two operands) + r := v.Reg() + x := v.Args[0].Reg() + y := v.Args[1].Reg() + z := v.Args[2].Reg() + p.From.Type = obj.TYPE_REG + p.From.Reg = z + p.Reg = y + p.AddRestSourceReg(x) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + case ssa.OpLOONG64MOVVaddr: + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() + var wantreg string + // MOVV $sym+off(base), R + // the assembler expands it as the following: + // - base is SP: add constant offset to SP (R3) + // when constant is large, tmp register (R30) may be used + // - base is SB: load external address with relocation + switch v.Aux.(type) { + default: + v.Fatalf("aux is of unknown type %T", v.Aux) + case *obj.LSym: + wantreg = "SB" + ssagen.AddAux(&p.From, v) + case *ir.Name: + wantreg = "SP" + ssagen.AddAux(&p.From, v) + case nil: + // No sym, just MOVV $off(SP), R + wantreg = "SP" + p.From.Offset = v.AuxInt + } + if reg := v.Args[0].RegName(); reg != wantreg { + v.Fatalf("bad reg %s for symbol type %T, want %s", reg, v.Aux, wantreg) + } + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpLOONG64MOVBloadidx, + ssa.OpLOONG64MOVBUloadidx, + ssa.OpLOONG64MOVHloadidx, + ssa.OpLOONG64MOVHUloadidx, + ssa.OpLOONG64MOVWloadidx, + ssa.OpLOONG64MOVWUloadidx, + ssa.OpLOONG64MOVVloadidx, + ssa.OpLOONG64MOVFloadidx, + ssa.OpLOONG64MOVDloadidx: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Name = obj.NAME_NONE + p.From.Reg = v.Args[0].Reg() + p.From.Index = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpLOONG64MOVBstoreidx, + ssa.OpLOONG64MOVHstoreidx, + ssa.OpLOONG64MOVWstoreidx, + ssa.OpLOONG64MOVVstoreidx, + ssa.OpLOONG64MOVFstoreidx, + ssa.OpLOONG64MOVDstoreidx: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_NONE + p.To.Reg = v.Args[0].Reg() + p.To.Index = v.Args[1].Reg() + + case ssa.OpLOONG64MOVBload, + ssa.OpLOONG64MOVBUload, + ssa.OpLOONG64MOVHload, + ssa.OpLOONG64MOVHUload, + ssa.OpLOONG64MOVWload, + ssa.OpLOONG64MOVWUload, + ssa.OpLOONG64MOVVload, + ssa.OpLOONG64MOVFload, + ssa.OpLOONG64MOVDload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpLOONG64MOVBstore, + ssa.OpLOONG64MOVHstore, + ssa.OpLOONG64MOVWstore, + ssa.OpLOONG64MOVVstore, + ssa.OpLOONG64MOVFstore, + ssa.OpLOONG64MOVDstore: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpLOONG64MOVBreg, + ssa.OpLOONG64MOVBUreg, + ssa.OpLOONG64MOVHreg, + ssa.OpLOONG64MOVHUreg, + ssa.OpLOONG64MOVWreg, + ssa.OpLOONG64MOVWUreg: + a := v.Args[0] + for a.Op == ssa.OpCopy || a.Op == ssa.OpLOONG64MOVVreg { + a = a.Args[0] + } + if a.Op == ssa.OpLoadReg && loong64.REG_R0 <= a.Reg() && a.Reg() <= loong64.REG_R31 { + // LoadReg from a narrower type does an extension, except loading + // to a floating point register. So only eliminate the extension + // if it is loaded to an integer register. + + t := a.Type + switch { + case v.Op == ssa.OpLOONG64MOVBreg && t.Size() == 1 && t.IsSigned(), + v.Op == ssa.OpLOONG64MOVBUreg && t.Size() == 1 && !t.IsSigned(), + v.Op == ssa.OpLOONG64MOVHreg && t.Size() == 2 && t.IsSigned(), + v.Op == ssa.OpLOONG64MOVHUreg && t.Size() == 2 && !t.IsSigned(), + v.Op == ssa.OpLOONG64MOVWreg && t.Size() == 4 && t.IsSigned(), + v.Op == ssa.OpLOONG64MOVWUreg && t.Size() == 4 && !t.IsSigned(): + // arg is a proper-typed load, already zero/sign-extended, don't extend again + if v.Reg() == v.Args[0].Reg() { + return + } + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + return + default: + } + } + fallthrough + + case ssa.OpLOONG64MOVWF, + ssa.OpLOONG64MOVWD, + ssa.OpLOONG64TRUNCFW, + ssa.OpLOONG64TRUNCDW, + ssa.OpLOONG64MOVVF, + ssa.OpLOONG64MOVVD, + ssa.OpLOONG64TRUNCFV, + ssa.OpLOONG64TRUNCDV, + ssa.OpLOONG64MOVFD, + ssa.OpLOONG64MOVDF, + ssa.OpLOONG64MOVWfpgp, + ssa.OpLOONG64MOVWgpfp, + ssa.OpLOONG64MOVVfpgp, + ssa.OpLOONG64MOVVgpfp, + ssa.OpLOONG64NEGF, + ssa.OpLOONG64NEGD, + ssa.OpLOONG64CLZW, + ssa.OpLOONG64CLZV, + ssa.OpLOONG64CTZW, + ssa.OpLOONG64CTZV, + ssa.OpLOONG64SQRTD, + ssa.OpLOONG64SQRTF, + ssa.OpLOONG64REVB2H, + ssa.OpLOONG64REVB2W, + ssa.OpLOONG64REVB4H, + ssa.OpLOONG64REVBV, + ssa.OpLOONG64BITREV4B, + ssa.OpLOONG64BITREVW, + ssa.OpLOONG64BITREVV, + ssa.OpLOONG64ABSD: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpLOONG64VPCNT64, + ssa.OpLOONG64VPCNT32, + ssa.OpLOONG64VPCNT16: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = ((v.Args[0].Reg() - loong64.REG_F0) & 31) + loong64.REG_V0 + p.To.Type = obj.TYPE_REG + p.To.Reg = ((v.Reg() - loong64.REG_F0) & 31) + loong64.REG_V0 + + case ssa.OpLOONG64NEGV: + // SUB from REGZERO + p := s.Prog(loong64.ASUBVU) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = loong64.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpLOONG64LoweredZero: + ptrReg := v.Args[0].Reg() + n := v.AuxInt + if n < 16 { + v.Fatalf("Zero too small %d", n) + } + + // Generate Zeroing instructions. + var off int64 + for n >= 8 { + // MOVV ZR, off(ptrReg) + zero8(s, ptrReg, off) + off += 8 + n -= 8 + } + if n != 0 { + // MOVV ZR, off+n-8(ptrReg) + zero8(s, ptrReg, off+n-8) + } + case ssa.OpLOONG64LoweredZeroLoop: + ptrReg := v.Args[0].Reg() + countReg := v.RegTmp() + flagReg := int16(loong64.REGTMP) + var off int64 + n := v.AuxInt + loopSize := int64(64) + if n < 3*loopSize { + // - a loop count of 0 won't work. + // - a loop count of 1 is useless. + // - a loop count of 2 is a code size ~tie + // 4 instructions to implement the loop + // 8 instructions in the loop body + // vs + // 16 instuctions in the straightline code + // Might as well use straightline code. + v.Fatalf("ZeroLoop size too small %d", n) + } + + // MOVV $n/loopSize, countReg + // MOVBU ir.Syms.Loong64HasLSX, flagReg + // BNE flagReg, lsxInit + // genericInit: + // for off = 0; off < loopSize; off += 8 { + // zero8(s, ptrReg, off) + // } + // ADDV $loopSize, ptrReg + // SUBV $1, countReg + // BNE countReg, genericInit + // JMP tail + // lsxInit: + // VXORV V31, V31, V31, v31 = 0 + // for off = 0; off < loopSize; off += 16 { + // zero16(s, V31, ptrReg, off) + // } + // ADDV $loopSize, ptrReg + // SUBV $1, countReg + // BNE countReg, lsxInit + // tail: + // n %= loopSize + // for off = 0; n >= 8; off += 8, n -= 8 { + // zero8(s, ptrReg, off) + // } + // + // if n != 0 { + // zero8(s, ptrReg, off+n-8) + // } + + p1 := s.Prog(loong64.AMOVV) + p1.From.Type = obj.TYPE_CONST + p1.From.Offset = n / loopSize + p1.To.Type = obj.TYPE_REG + p1.To.Reg = countReg + + p2 := s.Prog(loong64.AMOVBU) + p2.From.Type = obj.TYPE_MEM + p2.From.Name = obj.NAME_EXTERN + p2.From.Sym = ir.Syms.Loong64HasLSX + p2.To.Type = obj.TYPE_REG + p2.To.Reg = flagReg + + p3 := s.Prog(loong64.ABNE) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = flagReg + p3.To.Type = obj.TYPE_BRANCH + + for off = 0; off < loopSize; off += 8 { + zero8(s, ptrReg, off) + } + + p4 := s.Prog(loong64.AADDV) + p4.From.Type = obj.TYPE_CONST + p4.From.Offset = loopSize + p4.To.Type = obj.TYPE_REG + p4.To.Reg = ptrReg + + p5 := s.Prog(loong64.ASUBV) + p5.From.Type = obj.TYPE_CONST + p5.From.Offset = 1 + p5.To.Type = obj.TYPE_REG + p5.To.Reg = countReg + + p6 := s.Prog(loong64.ABNE) + p6.From.Type = obj.TYPE_REG + p6.From.Reg = countReg + p6.To.Type = obj.TYPE_BRANCH + p6.To.SetTarget(p3.Link) + + p7 := s.Prog(obj.AJMP) + p7.To.Type = obj.TYPE_BRANCH + + p8 := s.Prog(loong64.AVXORV) + p8.From.Type = obj.TYPE_REG + p8.From.Reg = loong64.REG_V31 + p8.To.Type = obj.TYPE_REG + p8.To.Reg = loong64.REG_V31 + p3.To.SetTarget(p8) + + for off = 0; off < loopSize; off += 16 { + zero16(s, loong64.REG_V31, ptrReg, off) + } + + p9 := s.Prog(loong64.AADDV) + p9.From.Type = obj.TYPE_CONST + p9.From.Offset = loopSize + p9.To.Type = obj.TYPE_REG + p9.To.Reg = ptrReg + + p10 := s.Prog(loong64.ASUBV) + p10.From.Type = obj.TYPE_CONST + p10.From.Offset = 1 + p10.To.Type = obj.TYPE_REG + p10.To.Reg = countReg + + p11 := s.Prog(loong64.ABNE) + p11.From.Type = obj.TYPE_REG + p11.From.Reg = countReg + p11.To.Type = obj.TYPE_BRANCH + p11.To.SetTarget(p8.Link) + + p12 := s.Prog(obj.ANOP) + p7.To.SetTarget(p12) + + // Multiples of the loop size are now done. + n %= loopSize + // Write any fractional portion. + for off = 0; n >= 8; off += 8 { + // MOVV ZR, off(ptrReg) + zero8(s, ptrReg, off) + n -= 8 + } + + if n != 0 { + zero8(s, ptrReg, off+n-8) + } + + case ssa.OpLOONG64LoweredMove: + dstReg := v.Args[0].Reg() + srcReg := v.Args[1].Reg() + if dstReg == srcReg { + break + } + tmpReg := int16(loong64.REG_R20) + n := v.AuxInt + if n < 16 { + v.Fatalf("Move too small %d", n) + } + + var off int64 + for n >= 8 { + // MOVV off(srcReg), tmpReg + // MOVV tmpReg, off(dstReg) + move8(s, srcReg, dstReg, tmpReg, off) + off += 8 + n -= 8 + } + + if n != 0 { + // MOVV off+n-8(srcReg), tmpReg + // MOVV tmpReg, off+n-8(srcReg) + move8(s, srcReg, dstReg, tmpReg, off+n-8) + } + case ssa.OpLOONG64LoweredMoveLoop: + dstReg := v.Args[0].Reg() + srcReg := v.Args[1].Reg() + if dstReg == srcReg { + break + } + countReg := int16(loong64.REG_R20) + tmpReg := int16(loong64.REG_R21) + var off int64 + n := v.AuxInt + loopSize := int64(64) + if n < 3*loopSize { + // - a loop count of 0 won't work. + // - a loop count of 1 is useless. + // - a loop count of 2 is a code size ~tie + // 4 instructions to implement the loop + // 8 instructions in the loop body + // vs + // 16 instructions in the straightline code + // Might as well use straightline code. + v.Fatalf("MoveLoop size too small %d", n) + } + + // Put iteration count in a register. + // MOVV $n/loopSize, countReg + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = n / loopSize + p.To.Type = obj.TYPE_REG + p.To.Reg = countReg + cntInit := p + + // Move loopSize bytes starting at srcReg to dstReg. + for range loopSize / 8 { + // MOVV off(srcReg), tmpReg + // MOVV tmpReg, off(dstReg) + move8(s, srcReg, dstReg, tmpReg, off) + off += 8 + } + + // Increment srcReg and destReg by loopSize. + // ADDV $loopSize, srcReg + p = s.Prog(loong64.AADDV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = loopSize + p.To.Type = obj.TYPE_REG + p.To.Reg = srcReg + // ADDV $loopSize, dstReg + p = s.Prog(loong64.AADDV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = loopSize + p.To.Type = obj.TYPE_REG + p.To.Reg = dstReg + + // Decrement loop count. + // SUBV $1, countReg + p = s.Prog(loong64.ASUBV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 1 + p.To.Type = obj.TYPE_REG + p.To.Reg = countReg + + // Jump to loop header if we're not done yet. + // BNE countReg, loop header + p = s.Prog(loong64.ABNE) + p.From.Type = obj.TYPE_REG + p.From.Reg = countReg + p.To.Type = obj.TYPE_BRANCH + p.To.SetTarget(cntInit.Link) + + // Multiples of the loop size are now done. + n %= loopSize + + off = 0 + // Copy any fractional portion. + for n >= 8 { + // MOVV off(srcReg), tmpReg + // MOVV tmpReg, off(dstReg) + move8(s, srcReg, dstReg, tmpReg, off) + off += 8 + n -= 8 + } + + if n != 0 { + // MOVV off+n-8(srcReg), tmpReg + // MOVV tmpReg, off+n-8(srcReg) + move8(s, srcReg, dstReg, tmpReg, off+n-8) + } + + case ssa.OpLOONG64CALLstatic, ssa.OpLOONG64CALLclosure, ssa.OpLOONG64CALLinter: + s.Call(v) + case ssa.OpLOONG64CALLtail: + s.TailCall(v) + case ssa.OpLOONG64LoweredWB: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + // AuxInt encodes how many buffer entries we need. + p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1] + + case ssa.OpLOONG64LoweredPubBarrier: + // DBAR 0x1A + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 0x1A + + case ssa.OpLOONG64LoweredPanicBoundsRR, ssa.OpLOONG64LoweredPanicBoundsRC, ssa.OpLOONG64LoweredPanicBoundsCR, ssa.OpLOONG64LoweredPanicBoundsCC: + // Compute the constant we put in the PCData entry for this call. + code, signed := ssa.BoundsKind(v.AuxInt).Code() + xIsReg := false + yIsReg := false + xVal := 0 + yVal := 0 + switch v.Op { + case ssa.OpLOONG64LoweredPanicBoundsRR: + xIsReg = true + xVal = int(v.Args[0].Reg() - loong64.REG_R4) + yIsReg = true + yVal = int(v.Args[1].Reg() - loong64.REG_R4) + case ssa.OpLOONG64LoweredPanicBoundsRC: + xIsReg = true + xVal = int(v.Args[0].Reg() - loong64.REG_R4) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + if yVal == xVal { + yVal = 1 + } + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = loong64.REG_R4 + int16(yVal) + } + case ssa.OpLOONG64LoweredPanicBoundsCR: + yIsReg = true + yVal = int(v.Args[0].Reg() - loong64.REG_R4) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + xIsReg = true + if xVal == yVal { + xVal = 1 + } + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = loong64.REG_R4 + int16(xVal) + } + case ssa.OpLOONG64LoweredPanicBoundsCC: + c := v.Aux.(ssa.PanicBoundsCC).Cx + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + xIsReg = true + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = loong64.REG_R4 + int16(xVal) + } + c = v.Aux.(ssa.PanicBoundsCC).Cy + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + yVal = 1 + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = loong64.REG_R4 + int16(yVal) + } + } + c := abi.BoundsEncode(code, signed, xIsReg, yIsReg, xVal, yVal) + + p := s.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_PanicBounds) + p.To.SetConst(int64(c)) + p = s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.PanicBounds + + case ssa.OpLOONG64LoweredAtomicLoad8, ssa.OpLOONG64LoweredAtomicLoad32, ssa.OpLOONG64LoweredAtomicLoad64: + // MOVB (Rarg0), Rout + // DBAR 0x14 + as := loong64.AMOVV + switch v.Op { + case ssa.OpLOONG64LoweredAtomicLoad8: + as = loong64.AMOVB + case ssa.OpLOONG64LoweredAtomicLoad32: + as = loong64.AMOVW + } + p := s.Prog(as) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + p1 := s.Prog(loong64.ADBAR) + p1.From.Type = obj.TYPE_CONST + p1.From.Offset = 0x14 + + case ssa.OpLOONG64LoweredAtomicStore8, + ssa.OpLOONG64LoweredAtomicStore32, + ssa.OpLOONG64LoweredAtomicStore64: + // DBAR 0x12 + // MOVx (Rarg1), Rout + // DBAR 0x18 + movx := loong64.AMOVV + switch v.Op { + case ssa.OpLOONG64LoweredAtomicStore8: + movx = loong64.AMOVB + case ssa.OpLOONG64LoweredAtomicStore32: + movx = loong64.AMOVW + } + p := s.Prog(loong64.ADBAR) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 0x12 + + p1 := s.Prog(movx) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = v.Args[1].Reg() + p1.To.Type = obj.TYPE_MEM + p1.To.Reg = v.Args[0].Reg() + + p2 := s.Prog(loong64.ADBAR) + p2.From.Type = obj.TYPE_CONST + p2.From.Offset = 0x18 + + case ssa.OpLOONG64LoweredAtomicStore8Variant, + ssa.OpLOONG64LoweredAtomicStore32Variant, + ssa.OpLOONG64LoweredAtomicStore64Variant: + //AMSWAPx Rarg1, (Rarg0), Rout + amswapx := loong64.AAMSWAPDBV + switch v.Op { + case ssa.OpLOONG64LoweredAtomicStore32Variant: + amswapx = loong64.AAMSWAPDBW + case ssa.OpLOONG64LoweredAtomicStore8Variant: + amswapx = loong64.AAMSWAPDBB + } + p := s.Prog(amswapx) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.RegTo2 = loong64.REGZERO + + case ssa.OpLOONG64LoweredAtomicExchange32, ssa.OpLOONG64LoweredAtomicExchange64: + // AMSWAPx Rarg1, (Rarg0), Rout + amswapx := loong64.AAMSWAPDBV + if v.Op == ssa.OpLOONG64LoweredAtomicExchange32 { + amswapx = loong64.AAMSWAPDBW + } + p := s.Prog(amswapx) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.RegTo2 = v.Reg0() + + case ssa.OpLOONG64LoweredAtomicExchange8Variant: + // AMSWAPDBB Rarg1, (Rarg0), Rout + p := s.Prog(loong64.AAMSWAPDBB) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.RegTo2 = v.Reg0() + + case ssa.OpLOONG64LoweredAtomicAdd32, ssa.OpLOONG64LoweredAtomicAdd64: + // AMADDx Rarg1, (Rarg0), Rout + // ADDV Rarg1, Rout, Rout + amaddx := loong64.AAMADDDBV + addx := loong64.AADDV + if v.Op == ssa.OpLOONG64LoweredAtomicAdd32 { + amaddx = loong64.AAMADDDBW + } + p := s.Prog(amaddx) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.RegTo2 = v.Reg0() + + p1 := s.Prog(addx) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = v.Args[1].Reg() + p1.Reg = v.Reg0() + p1.To.Type = obj.TYPE_REG + p1.To.Reg = v.Reg0() + + case ssa.OpLOONG64LoweredAtomicCas32, ssa.OpLOONG64LoweredAtomicCas64: + // MOVV $0, Rout + // DBAR 0x14 + // LL (Rarg0), Rtmp + // BNE Rtmp, Rarg1, 4(PC) + // MOVV Rarg2, Rout + // SC Rout, (Rarg0) + // BEQ Rout, -4(PC) + // DBAR 0x12 + ll := loong64.ALLV + sc := loong64.ASCV + if v.Op == ssa.OpLOONG64LoweredAtomicCas32 { + ll = loong64.ALL + sc = loong64.ASC + } + + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = loong64.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + p1 := s.Prog(loong64.ADBAR) + p1.From.Type = obj.TYPE_CONST + p1.From.Offset = 0x14 + + p2 := s.Prog(ll) + p2.From.Type = obj.TYPE_MEM + p2.From.Reg = v.Args[0].Reg() + p2.To.Type = obj.TYPE_REG + p2.To.Reg = loong64.REGTMP + + p3 := s.Prog(loong64.ABNE) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = v.Args[1].Reg() + p3.Reg = loong64.REGTMP + p3.To.Type = obj.TYPE_BRANCH + + p4 := s.Prog(loong64.AMOVV) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = v.Args[2].Reg() + p4.To.Type = obj.TYPE_REG + p4.To.Reg = v.Reg0() + + p5 := s.Prog(sc) + p5.From.Type = obj.TYPE_REG + p5.From.Reg = v.Reg0() + p5.To.Type = obj.TYPE_MEM + p5.To.Reg = v.Args[0].Reg() + + p6 := s.Prog(loong64.ABEQ) + p6.From.Type = obj.TYPE_REG + p6.From.Reg = v.Reg0() + p6.To.Type = obj.TYPE_BRANCH + p6.To.SetTarget(p2) + + p7 := s.Prog(loong64.ADBAR) + p7.From.Type = obj.TYPE_CONST + p7.From.Offset = 0x12 + p3.To.SetTarget(p7) + + case ssa.OpLOONG64LoweredAtomicAnd32, + ssa.OpLOONG64LoweredAtomicOr32: + // AM{AND,OR}DBx Rarg1, (Rarg0), RegZero + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.RegTo2 = loong64.REGZERO + + case ssa.OpLOONG64LoweredAtomicAnd32value, + ssa.OpLOONG64LoweredAtomicAnd64value, + ssa.OpLOONG64LoweredAtomicOr64value, + ssa.OpLOONG64LoweredAtomicOr32value: + // AM{AND,OR}DBx Rarg1, (Rarg0), Rout + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.RegTo2 = v.Reg0() + + case ssa.OpLOONG64LoweredAtomicCas64Variant, ssa.OpLOONG64LoweredAtomicCas32Variant: + // MOVV $0, Rout + // MOVV Rarg1, Rtmp + // AMCASDBx Rarg2, (Rarg0), Rtmp + // BNE Rarg1, Rtmp, 2(PC) + // MOVV $1, Rout + // NOP + + amcasx := loong64.AAMCASDBV + if v.Op == ssa.OpLOONG64LoweredAtomicCas32Variant { + amcasx = loong64.AAMCASDBW + } + + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = loong64.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + p1 := s.Prog(loong64.AMOVV) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = v.Args[1].Reg() + p1.To.Type = obj.TYPE_REG + p1.To.Reg = loong64.REGTMP + + p2 := s.Prog(amcasx) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = v.Args[2].Reg() + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = v.Args[0].Reg() + p2.RegTo2 = loong64.REGTMP + + p3 := s.Prog(loong64.ABNE) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = v.Args[1].Reg() + p3.Reg = loong64.REGTMP + p3.To.Type = obj.TYPE_BRANCH + + p4 := s.Prog(loong64.AMOVV) + p4.From.Type = obj.TYPE_CONST + p4.From.Offset = 0x1 + p4.To.Type = obj.TYPE_REG + p4.To.Reg = v.Reg0() + + p5 := s.Prog(obj.ANOP) + p3.To.SetTarget(p5) + + case ssa.OpLOONG64LoweredNilCheck: + // Issue a load which will fault if arg is nil. + p := s.Prog(loong64.AMOVB) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = loong64.REGTMP + if logopt.Enabled() { + logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name) + } + if base.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers + base.WarnfAt(v.Pos, "generated nil check") + } + case ssa.OpLOONG64FPFlagTrue, + ssa.OpLOONG64FPFlagFalse: + // MOVV $0, r + // BFPF 2(PC) + // MOVV $1, r + branch := loong64.ABFPF + if v.Op == ssa.OpLOONG64FPFlagFalse { + branch = loong64.ABFPT + } + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = loong64.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + p2 := s.Prog(branch) + p2.To.Type = obj.TYPE_BRANCH + p3 := s.Prog(loong64.AMOVV) + p3.From.Type = obj.TYPE_CONST + p3.From.Offset = 1 + p3.To.Type = obj.TYPE_REG + p3.To.Reg = v.Reg() + p4 := s.Prog(obj.ANOP) // not a machine instruction, for branch to land + p2.To.SetTarget(p4) + case ssa.OpLOONG64LoweredGetClosurePtr: + // Closure pointer is R22 (loong64.REGCTXT). + ssagen.CheckLoweredGetClosurePtr(v) + case ssa.OpLOONG64LoweredGetCallerSP: + // caller's SP is FixedFrameSize below the address of the first arg + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_ADDR + p.From.Offset = -base.Ctxt.Arch.FixedFrameSize + p.From.Name = obj.NAME_PARAM + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpLOONG64LoweredGetCallerPC: + p := s.Prog(obj.AGETCALLERPC) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpLOONG64MASKEQZ, ssa.OpLOONG64MASKNEZ: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpLOONG64PRELD: + // PRELD (Rarg0), hint + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.AddRestSourceConst(v.AuxInt & 0x1f) + + case ssa.OpLOONG64PRELDX: + // PRELDX (Rarg0), $n, $hint + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.AddRestSourceArgs([]obj.Addr{ + {Type: obj.TYPE_CONST, Offset: (v.AuxInt >> 5) & 0x1fffffffff}, + {Type: obj.TYPE_CONST, Offset: (v.AuxInt >> 0) & 0x1f}, + }) + + case ssa.OpLOONG64ADDshiftLLV: + // ADDshiftLLV Rarg0, Rarg1, $shift + // ALSLV $shift, Rarg1, Rarg0, Rtmp + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[1].Reg() + p.AddRestSourceReg(v.Args[0].Reg()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpClobber, ssa.OpClobberReg: + // TODO: implement for clobberdead experiment. Nop is ok for now. + default: + v.Fatalf("genValue not implemented: %s", v.LongString()) + } +} + +var blockJump = map[ssa.BlockKind]struct { + asm, invasm obj.As +}{ + ssa.BlockLOONG64EQZ: {loong64.ABEQ, loong64.ABNE}, + ssa.BlockLOONG64NEZ: {loong64.ABNE, loong64.ABEQ}, + ssa.BlockLOONG64LTZ: {loong64.ABLTZ, loong64.ABGEZ}, + ssa.BlockLOONG64GEZ: {loong64.ABGEZ, loong64.ABLTZ}, + ssa.BlockLOONG64LEZ: {loong64.ABLEZ, loong64.ABGTZ}, + ssa.BlockLOONG64GTZ: {loong64.ABGTZ, loong64.ABLEZ}, + ssa.BlockLOONG64FPT: {loong64.ABFPT, loong64.ABFPF}, + ssa.BlockLOONG64FPF: {loong64.ABFPF, loong64.ABFPT}, + ssa.BlockLOONG64BEQ: {loong64.ABEQ, loong64.ABNE}, + ssa.BlockLOONG64BNE: {loong64.ABNE, loong64.ABEQ}, + ssa.BlockLOONG64BGE: {loong64.ABGE, loong64.ABLT}, + ssa.BlockLOONG64BLT: {loong64.ABLT, loong64.ABGE}, + ssa.BlockLOONG64BLTU: {loong64.ABLTU, loong64.ABGEU}, + ssa.BlockLOONG64BGEU: {loong64.ABGEU, loong64.ABLTU}, +} + +func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) { + switch b.Kind { + case ssa.BlockPlain, ssa.BlockDefer: + if b.Succs[0].Block() != next { + p := s.Prog(obj.AJMP) + p.To.Type = obj.TYPE_BRANCH + s.Branches = append(s.Branches, ssagen.Branch{P: p, B: b.Succs[0].Block()}) + } + case ssa.BlockExit, ssa.BlockRetJmp: + case ssa.BlockRet: + s.Prog(obj.ARET) + case ssa.BlockLOONG64EQZ, ssa.BlockLOONG64NEZ, + ssa.BlockLOONG64LTZ, ssa.BlockLOONG64GEZ, + ssa.BlockLOONG64LEZ, ssa.BlockLOONG64GTZ, + ssa.BlockLOONG64BEQ, ssa.BlockLOONG64BNE, + ssa.BlockLOONG64BLT, ssa.BlockLOONG64BGE, + ssa.BlockLOONG64BLTU, ssa.BlockLOONG64BGEU, + ssa.BlockLOONG64FPT, ssa.BlockLOONG64FPF: + jmp := blockJump[b.Kind] + var p *obj.Prog + switch next { + case b.Succs[0].Block(): + p = s.Br(jmp.invasm, b.Succs[1].Block()) + case b.Succs[1].Block(): + p = s.Br(jmp.asm, b.Succs[0].Block()) + default: + if b.Likely != ssa.BranchUnlikely { + p = s.Br(jmp.asm, b.Succs[0].Block()) + s.Br(obj.AJMP, b.Succs[1].Block()) + } else { + p = s.Br(jmp.invasm, b.Succs[1].Block()) + s.Br(obj.AJMP, b.Succs[0].Block()) + } + } + switch b.Kind { + case ssa.BlockLOONG64BEQ, ssa.BlockLOONG64BNE, + ssa.BlockLOONG64BGE, ssa.BlockLOONG64BLT, + ssa.BlockLOONG64BGEU, ssa.BlockLOONG64BLTU: + p.From.Type = obj.TYPE_REG + p.From.Reg = b.Controls[0].Reg() + p.Reg = b.Controls[1].Reg() + case ssa.BlockLOONG64EQZ, ssa.BlockLOONG64NEZ, + ssa.BlockLOONG64LTZ, ssa.BlockLOONG64GEZ, + ssa.BlockLOONG64LEZ, ssa.BlockLOONG64GTZ, + ssa.BlockLOONG64FPT, ssa.BlockLOONG64FPF: + if !b.Controls[0].Type.IsFlags() { + p.From.Type = obj.TYPE_REG + p.From.Reg = b.Controls[0].Reg() + } + } + case ssa.BlockLOONG64JUMPTABLE: + // ALSLV $3, Rarg0, Rarg1, REGTMP + // MOVV (REGTMP), REGTMP + // JMP (REGTMP) + p := s.Prog(loong64.AALSLV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 3 // idx*8 + p.Reg = b.Controls[0].Reg() + p.AddRestSourceReg(b.Controls[1].Reg()) + p.To.Type = obj.TYPE_REG + p.To.Reg = loong64.REGTMP + p1 := s.Prog(loong64.AMOVV) + p1.From.Type = obj.TYPE_MEM + p1.From.Reg = loong64.REGTMP + p1.From.Offset = 0 + p1.To.Type = obj.TYPE_REG + p1.To.Reg = loong64.REGTMP + p2 := s.Prog(obj.AJMP) + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = loong64.REGTMP + // Save jump tables for later resolution of the target blocks. + s.JumpTables = append(s.JumpTables, b) + + default: + b.Fatalf("branch not implemented: %s", b.LongString()) + } +} + +func loadRegResult(s *ssagen.State, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p := s.Prog(loadByType(t, reg)) + p.From.Type = obj.TYPE_MEM + p.From.Name = obj.NAME_AUTO + p.From.Sym = n.Linksym() + p.From.Offset = n.FrameOffset() + off + p.To.Type = obj.TYPE_REG + p.To.Reg = reg + return p +} + +func spillArgReg(pp *objw.Progs, p *obj.Prog, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p = pp.Append(p, storeByType(t, reg), obj.TYPE_REG, reg, 0, obj.TYPE_MEM, 0, n.FrameOffset()+off) + p.To.Name = obj.NAME_PARAM + p.To.Sym = n.Linksym() + p.Pos = p.Pos.WithNotStmt() + return p +} + +// move8 copies 8 bytes at src+off to dst+off. +func move8(s *ssagen.State, src, dst, tmp int16, off int64) { + // MOVV off(src), tmp + ld := s.Prog(loong64.AMOVV) + ld.From.Type = obj.TYPE_MEM + ld.From.Reg = src + ld.From.Offset = off + ld.To.Type = obj.TYPE_REG + ld.To.Reg = tmp + // MOVV tmp, off(dst) + st := s.Prog(loong64.AMOVV) + st.From.Type = obj.TYPE_REG + st.From.Reg = tmp + st.To.Type = obj.TYPE_MEM + st.To.Reg = dst + st.To.Offset = off +} + +// zero8 zeroes 8 bytes at reg+off. +func zero8(s *ssagen.State, reg int16, off int64) { + // MOVV ZR, off(reg) + p := s.Prog(loong64.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = loong64.REGZERO + p.To.Type = obj.TYPE_MEM + p.To.Reg = reg + p.To.Offset = off +} + +// zero16 zeroes 16 bytes at reg+off. +func zero16(s *ssagen.State, regZero, regBase int16, off int64) { + // VMOVQ regZero, off(regBase) + p := s.Prog(loong64.AVMOVQ) + p.From.Type = obj.TYPE_REG + p.From.Reg = regZero + p.To.Type = obj.TYPE_MEM + p.To.Reg = regBase + p.To.Offset = off +} diff --git a/go/src/cmd/compile/internal/loopvar/loopvar.go b/go/src/cmd/compile/internal/loopvar/loopvar.go new file mode 100644 index 0000000000000000000000000000000000000000..267df2f905c086a9f13b3af13c89e4c65ac52c50 --- /dev/null +++ b/go/src/cmd/compile/internal/loopvar/loopvar.go @@ -0,0 +1,613 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package loopvar applies the proper variable capture, according +// to experiment, flags, language version, etc. +package loopvar + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/src" + "fmt" +) + +type VarAndLoop struct { + Name *ir.Name + Loop ir.Node // the *ir.RangeStmt or *ir.ForStmt. Used for identity and position + LastPos src.XPos // the last position observed within Loop +} + +// ForCapture transforms for and range loops that declare variables that might be +// captured by a closure or escaped to the heap, using a syntactic check that +// conservatively overestimates the loops where capture occurs, but still avoids +// transforming the (large) majority of loops. It returns the list of names +// subject to this change, that may (once transformed) be heap allocated in the +// process. (This allows checking after escape analysis to call out any such +// variables, in case it causes allocation/performance problems). +// +// The decision to transform loops is normally encoded in the For/Range loop node +// field DistinctVars but is also dependent on base.LoopVarHash, and some values +// of base.Debug.LoopVar (which is set per-package). Decisions encoded in DistinctVars +// are preserved across inlining, so if package a calls b.F and loops in b.F are +// transformed, then they are always transformed, whether b.F is inlined or not. +// +// Per-package, the debug flag settings that affect this transformer: +// +// base.LoopVarHash != nil => use hash setting to govern transformation. +// note that LoopVarHash != nil sets base.Debug.LoopVar to 1 (unless it is >= 11, for testing/debugging). +// +// base.Debug.LoopVar == 11 => transform ALL loops ignoring syntactic/potential escape. Do not log, can be in addition to GOEXPERIMENT. +// +// The effect of GOEXPERIMENT=loopvar is to change the default value (0) of base.Debug.LoopVar to 1 for all packages. +func ForCapture(fn *ir.Func) []VarAndLoop { + // if a loop variable is transformed it is appended to this slice for later logging + var transformed []VarAndLoop + + describe := func(n *ir.Name) string { + pos := n.Pos() + inner := base.Ctxt.InnermostPos(pos) + outer := base.Ctxt.OutermostPos(pos) + if inner == outer { + return fmt.Sprintf("loop variable %v now per-iteration", n) + } + return fmt.Sprintf("loop variable %v now per-iteration (loop inlined into %s:%d)", n, outer.Filename(), outer.Line()) + } + + forCapture := func() { + seq := 1 + + dclFixups := make(map[*ir.Name]ir.Stmt) + + // possibly leaked includes names of declared loop variables that may be leaked; + // the mapped value is true if the name is *syntactically* leaked, and those loops + // will be transformed. + possiblyLeaked := make(map[*ir.Name]bool) + + // these enable an optimization of "escape" under return statements + loopDepth := 0 + returnInLoopDepth := 0 + + // noteMayLeak is called for candidate variables in for range/3-clause, and + // adds them (mapped to false) to possiblyLeaked. + noteMayLeak := func(x ir.Node) { + if n, ok := x.(*ir.Name); ok { + if n.Type().Kind() == types.TBLANK { + return + } + // default is false (leak candidate, not yet known to leak), but flag can make all variables "leak" + possiblyLeaked[n] = base.Debug.LoopVar >= 11 + } + } + + // For reporting, keep track of the last position within any loop. + // Loops nest, also need to be sensitive to inlining. + var lastPos src.XPos + + updateLastPos := func(p src.XPos) { + pl, ll := p.Line(), lastPos.Line() + if p.SameFile(lastPos) && + (pl > ll || pl == ll && p.Col() > lastPos.Col()) { + lastPos = p + } + } + + // maybeReplaceVar unshares an iteration variable for a range loop, + // if that variable was actually (syntactically) leaked, + // subject to hash-variable debugging. + maybeReplaceVar := func(k ir.Node, x *ir.RangeStmt) ir.Node { + if n, ok := k.(*ir.Name); ok && possiblyLeaked[n] { + desc := func() string { + return describe(n) + } + if base.LoopVarHash.MatchPos(n.Pos(), desc) { + // Rename the loop key, prefix body with assignment from loop key + transformed = append(transformed, VarAndLoop{n, x, lastPos}) + tk := typecheck.TempAt(base.Pos, fn, n.Type()) + tk.SetTypecheck(1) + as := ir.NewAssignStmt(x.Pos(), n, tk) + as.Def = true + as.SetTypecheck(1) + x.Body.Prepend(as) + dclFixups[n] = as + return tk + } + } + return k + } + + // scanChildrenThenTransform processes node x to: + // 1. if x is a for/range w/ DistinctVars, note declared iteration variables possiblyLeaked (PL) + // 2. search all of x's children for syntactically escaping references to v in PL, + // meaning either address-of-v or v-captured-by-a-closure + // 3. for all v in PL that had a syntactically escaping reference, transform the declaration + // and (in case of 3-clause loop) the loop to the unshared loop semantics. + // This is all much simpler for range loops; 3-clause loops can have an arbitrary number + // of iteration variables and the transformation is more involved, range loops have at most 2. + var scanChildrenThenTransform func(x ir.Node) bool + scanChildrenThenTransform = func(n ir.Node) bool { + + if loopDepth > 0 { + updateLastPos(n.Pos()) + } + + switch x := n.(type) { + case *ir.ClosureExpr: + if returnInLoopDepth >= loopDepth { + // This expression is a child of a return, which escapes all loops above + // the return, but not those between this expression and the return. + break + } + for _, cv := range x.Func.ClosureVars { + v := cv.Canonical() + if _, ok := possiblyLeaked[v]; ok { + possiblyLeaked[v] = true + } + } + + case *ir.AddrExpr: + if returnInLoopDepth >= loopDepth { + // This expression is a child of a return, which escapes all loops above + // the return, but not those between this expression and the return. + break + } + // Explicitly note address-taken so that return-statements can be excluded + y := ir.OuterValue(x.X) + if y.Op() != ir.ONAME { + break + } + z, ok := y.(*ir.Name) + if !ok { + break + } + switch z.Class { + case ir.PAUTO, ir.PPARAM, ir.PPARAMOUT, ir.PAUTOHEAP: + if _, ok := possiblyLeaked[z]; ok { + possiblyLeaked[z] = true + } + } + + case *ir.ReturnStmt: + savedRILD := returnInLoopDepth + returnInLoopDepth = loopDepth + defer func() { returnInLoopDepth = savedRILD }() + + case *ir.RangeStmt: + if !(x.Def && x.DistinctVars) { + // range loop must define its iteration variables AND have distinctVars. + x.DistinctVars = false + break + } + noteMayLeak(x.Key) + noteMayLeak(x.Value) + loopDepth++ + savedLastPos := lastPos + lastPos = x.Pos() // this sets the file. + ir.DoChildren(n, scanChildrenThenTransform) + loopDepth-- + x.Key = maybeReplaceVar(x.Key, x) + x.Value = maybeReplaceVar(x.Value, x) + thisLastPos := lastPos + lastPos = savedLastPos + updateLastPos(thisLastPos) // this will propagate lastPos if in the same file. + x.DistinctVars = false + return false + + case *ir.ForStmt: + if !x.DistinctVars { + break + } + forAllDefInInit(x, noteMayLeak) + loopDepth++ + savedLastPos := lastPos + lastPos = x.Pos() // this sets the file. + ir.DoChildren(n, scanChildrenThenTransform) + loopDepth-- + var leaked []*ir.Name + // Collect the leaking variables for the much-more-complex transformation. + forAllDefInInit(x, func(z ir.Node) { + if n, ok := z.(*ir.Name); ok && possiblyLeaked[n] { + desc := func() string { + return describe(n) + } + // Hash on n.Pos() for most precise failure location. + if base.LoopVarHash.MatchPos(n.Pos(), desc) { + leaked = append(leaked, n) + } + } + }) + + if len(leaked) > 0 { + // need to transform the for loop just so. + + /* Contrived example, w/ numbered comments from the transformation: + BEFORE: + var escape []*int + for z := 0; z < n; z++ { + if reason() { + escape = append(escape, &z) + continue + } + z = z + z + stuff + } + AFTER: + for z', tmp_first := 0, true; ; { // (4) + // (5) body' follows: + z := z' // (1) + if tmp_first {tmp_first = false} else {z++} // (6) + if ! (z < n) { break } // (7) + // (3, 8) body_continue + if reason() { + escape = append(escape, &z) + goto next // rewritten continue + } + z = z + z + stuff + next: // (9) + z' = z // (2) + } + + In the case that the loop contains no increment (z++), + there is no need for step 6, + and thus no need to test, update, or declare tmp_first (part of step 4). + Similarly if the loop contains no exit test (z < n), + then there is no need for step 7. + */ + + // Expressed in terms of the input ForStmt + // + // type ForStmt struct { + // init Nodes + // Label *types.Sym + // Cond Node // empty if OFORUNTIL + // Post Node + // Body Nodes + // HasBreak bool + // } + + // OFOR: init; loop: if !Cond {break}; Body; Post; goto loop + + // (1) prebody = {z := z' for z in leaked} + // (2) postbody = {z' = z for z in leaked} + // (3) body_continue = {body : s/continue/goto next} + // (4) init' = (init : s/z/z' for z in leaked) + tmp_first := true + // (5) body' = prebody + // appears out of order below + // (6) if tmp_first {tmp_first = false} else {Post} + + // (7) if !cond {break} + + // (8) body_continue (3) + + // (9) next: postbody (2) + // (10) cond' = {} + // (11) post' = {} + + // minor optimizations: + // if Post is empty, tmp_first and step 6 can be skipped. + // if Cond is empty, that code can also be skipped. + + var preBody, postBody ir.Nodes + + // Given original iteration variable z, what is the corresponding z' + // that carries the value from iteration to iteration? + zPrimeForZ := make(map[*ir.Name]*ir.Name) + + // (1,2) initialize preBody and postBody + for _, z := range leaked { + transformed = append(transformed, VarAndLoop{z, x, lastPos}) + + tz := typecheck.TempAt(base.Pos, fn, z.Type()) + tz.SetTypecheck(1) + zPrimeForZ[z] = tz + + as := ir.NewAssignStmt(x.Pos(), z, tz) + as.Def = true + as.SetTypecheck(1) + z.Defn = as + preBody.Append(as) + dclFixups[z] = as + + as = ir.NewAssignStmt(x.Pos(), tz, z) + as.SetTypecheck(1) + postBody.Append(as) + + } + + // (3) rewrite continues in body -- rewrite is inplace, so works for top level visit, too. + label := typecheck.Lookup(fmt.Sprintf(".3clNext_%d", seq)) + seq++ + labelStmt := ir.NewLabelStmt(x.Pos(), label) + labelStmt.SetTypecheck(1) + + loopLabel := x.Label + loopDepth := 0 + var editContinues func(x ir.Node) bool + editContinues = func(x ir.Node) bool { + + switch c := x.(type) { + case *ir.BranchStmt: + // If this is a continue targeting the loop currently being rewritten, transform it to an appropriate GOTO + if c.Op() == ir.OCONTINUE && (loopDepth == 0 && c.Label == nil || loopLabel != nil && c.Label == loopLabel) { + c.Label = label + c.SetOp(ir.OGOTO) + } + case *ir.RangeStmt, *ir.ForStmt: + loopDepth++ + ir.DoChildren(x, editContinues) + loopDepth-- + return false + } + ir.DoChildren(x, editContinues) + return false + } + for _, y := range x.Body { + editContinues(y) + } + bodyContinue := x.Body + + // (4) rewrite init + forAllDefInInitUpdate(x, func(z ir.Node, pz *ir.Node) { + // note tempFor[n] can be nil if hash searching. + if n, ok := z.(*ir.Name); ok && possiblyLeaked[n] && zPrimeForZ[n] != nil { + *pz = zPrimeForZ[n] + } + }) + + postNotNil := x.Post != nil + var tmpFirstDcl ir.Node + if postNotNil { + // body' = prebody + + // (6) if tmp_first {tmp_first = false} else {Post} + + // if !cond {break} + ... + tmpFirst := typecheck.TempAt(base.Pos, fn, types.Types[types.TBOOL]) + tmpFirstDcl = typecheck.Stmt(ir.NewAssignStmt(x.Pos(), tmpFirst, ir.NewBool(base.Pos, true))) + tmpFirstSetFalse := typecheck.Stmt(ir.NewAssignStmt(x.Pos(), tmpFirst, ir.NewBool(base.Pos, false))) + ifTmpFirst := ir.NewIfStmt(x.Pos(), tmpFirst, ir.Nodes{tmpFirstSetFalse}, ir.Nodes{x.Post}) + ifTmpFirst.PtrInit().Append(typecheck.Stmt(ir.NewDecl(base.Pos, ir.ODCL, tmpFirst))) // declares tmpFirst + preBody.Append(typecheck.Stmt(ifTmpFirst)) + } + + // body' = prebody + + // if tmp_first {tmp_first = false} else {Post} + + // (7) if !cond {break} + ... + if x.Cond != nil { + notCond := ir.NewUnaryExpr(x.Cond.Pos(), ir.ONOT, x.Cond) + notCond.SetType(x.Cond.Type()) + notCond.SetTypecheck(1) + newBreak := ir.NewBranchStmt(x.Pos(), ir.OBREAK, nil) + newBreak.SetTypecheck(1) + ifNotCond := ir.NewIfStmt(x.Pos(), notCond, ir.Nodes{newBreak}, nil) + ifNotCond.SetTypecheck(1) + preBody.Append(ifNotCond) + } + + if postNotNil { + x.PtrInit().Append(tmpFirstDcl) + } + + // (8) + preBody.Append(bodyContinue...) + // (9) + preBody.Append(labelStmt) + preBody.Append(postBody...) + + // (5) body' = prebody + ... + x.Body = preBody + + // (10) cond' = {} + x.Cond = nil + + // (11) post' = {} + x.Post = nil + } + thisLastPos := lastPos + lastPos = savedLastPos + updateLastPos(thisLastPos) // this will propagate lastPos if in the same file. + x.DistinctVars = false + + return false + } + + ir.DoChildren(n, scanChildrenThenTransform) + + return false + } + scanChildrenThenTransform(fn) + if len(transformed) > 0 { + // editNodes scans a slice C of ir.Node, looking for declarations that + // appear in dclFixups. Any declaration D whose "fixup" is an assignmnt + // statement A is removed from the C and relocated to the Init + // of A. editNodes returns the modified slice of ir.Node. + editNodes := func(c ir.Nodes) ir.Nodes { + j := 0 + for _, n := range c { + if d, ok := n.(*ir.Decl); ok { + if s := dclFixups[d.X]; s != nil { + switch a := s.(type) { + case *ir.AssignStmt: + a.PtrInit().Prepend(d) + delete(dclFixups, d.X) // can't be sure of visit order, wouldn't want to visit twice. + default: + base.Fatalf("not implemented yet for node type %v", s.Op()) + } + continue // do not copy this node, and do not increment j + } + } + c[j] = n + j++ + } + for k := j; k < len(c); k++ { + c[k] = nil + } + return c[:j] + } + // fixup all tagged declarations in all the statements lists in fn. + rewriteNodes(fn, editNodes) + } + } + ir.WithFunc(fn, forCapture) + return transformed +} + +// forAllDefInInitUpdate applies "do" to all the defining assignments in the Init clause of a ForStmt. +// This abstracts away some of the boilerplate from the already complex and verbose for-3-clause case. +func forAllDefInInitUpdate(x *ir.ForStmt, do func(z ir.Node, update *ir.Node)) { + for _, s := range x.Init() { + switch y := s.(type) { + case *ir.AssignListStmt: + if !y.Def { + continue + } + for i, z := range y.Lhs { + do(z, &y.Lhs[i]) + } + case *ir.AssignStmt: + if !y.Def { + continue + } + do(y.X, &y.X) + } + } +} + +// forAllDefInInit is forAllDefInInitUpdate without the update option. +func forAllDefInInit(x *ir.ForStmt, do func(z ir.Node)) { + forAllDefInInitUpdate(x, func(z ir.Node, _ *ir.Node) { do(z) }) +} + +// rewriteNodes applies editNodes to all statement lists in fn. +func rewriteNodes(fn *ir.Func, editNodes func(c ir.Nodes) ir.Nodes) { + var forNodes func(x ir.Node) bool + forNodes = func(n ir.Node) bool { + if stmt, ok := n.(ir.InitNode); ok { + // process init list + stmt.SetInit(editNodes(stmt.Init())) + } + switch x := n.(type) { + case *ir.Func: + x.Body = editNodes(x.Body) + case *ir.InlinedCallExpr: + x.Body = editNodes(x.Body) + + case *ir.CaseClause: + x.Body = editNodes(x.Body) + case *ir.CommClause: + x.Body = editNodes(x.Body) + + case *ir.BlockStmt: + x.List = editNodes(x.List) + + case *ir.ForStmt: + x.Body = editNodes(x.Body) + case *ir.RangeStmt: + x.Body = editNodes(x.Body) + case *ir.IfStmt: + x.Body = editNodes(x.Body) + x.Else = editNodes(x.Else) + case *ir.SelectStmt: + x.Compiled = editNodes(x.Compiled) + case *ir.SwitchStmt: + x.Compiled = editNodes(x.Compiled) + } + ir.DoChildren(n, forNodes) + return false + } + forNodes(fn) +} + +func LogTransformations(transformed []VarAndLoop) { + print := 2 <= base.Debug.LoopVar && base.Debug.LoopVar != 11 + + if print || logopt.Enabled() { // 11 is do them all, quietly, 12 includes debugging. + fileToPosBase := make(map[string]*src.PosBase) // used to remove inline context for innermost reporting. + + // trueInlinedPos rebases inner w/o inline context so that it prints correctly in WarnfAt; otherwise it prints as outer. + trueInlinedPos := func(inner src.Pos) src.XPos { + afn := inner.AbsFilename() + pb, ok := fileToPosBase[afn] + if !ok { + pb = src.NewFileBase(inner.Filename(), afn) + fileToPosBase[afn] = pb + } + inner.SetBase(pb) + return base.Ctxt.PosTable.XPos(inner) + } + + type unit struct{} + loopsSeen := make(map[ir.Node]unit) + type loopPos struct { + loop ir.Node + last src.XPos + curfn *ir.Func + } + var loops []loopPos + for _, lv := range transformed { + n := lv.Name + if _, ok := loopsSeen[lv.Loop]; !ok { + l := lv.Loop + loopsSeen[l] = unit{} + loops = append(loops, loopPos{l, lv.LastPos, n.Curfn}) + } + pos := n.Pos() + + inner := base.Ctxt.InnermostPos(pos) + outer := base.Ctxt.OutermostPos(pos) + + if logopt.Enabled() { + // For automated checking of coverage of this transformation, include this in the JSON information. + var nString any = n + if inner != outer { + nString = fmt.Sprintf("%v (from inline)", n) + } + if n.Esc() == ir.EscHeap { + logopt.LogOpt(pos, "iteration-variable-to-heap", "loopvar", ir.FuncName(n.Curfn), nString) + } else { + logopt.LogOpt(pos, "iteration-variable-to-stack", "loopvar", ir.FuncName(n.Curfn), nString) + } + } + if print { + if inner == outer { + if n.Esc() == ir.EscHeap { + base.WarnfAt(pos, "loop variable %v now per-iteration, heap-allocated", n) + } else { + base.WarnfAt(pos, "loop variable %v now per-iteration, stack-allocated", n) + } + } else { + innerXPos := trueInlinedPos(inner) + if n.Esc() == ir.EscHeap { + base.WarnfAt(innerXPos, "loop variable %v now per-iteration, heap-allocated (loop inlined into %s:%d)", n, outer.Filename(), outer.Line()) + } else { + base.WarnfAt(innerXPos, "loop variable %v now per-iteration, stack-allocated (loop inlined into %s:%d)", n, outer.Filename(), outer.Line()) + } + } + } + } + for _, l := range loops { + pos := l.loop.Pos() + last := l.last + loopKind := "range" + if _, ok := l.loop.(*ir.ForStmt); ok { + loopKind = "for" + } + if logopt.Enabled() { + // Intended to help with performance debugging, we record whole loop ranges + logopt.LogOptRange(pos, last, "loop-modified-"+loopKind, "loopvar", ir.FuncName(l.curfn)) + } + if print && 4 <= base.Debug.LoopVar { + // TODO decide if we want to keep this, or not. It was helpful for validating logopt, otherwise, eh. + inner := base.Ctxt.InnermostPos(pos) + outer := base.Ctxt.OutermostPos(pos) + + if inner == outer { + base.WarnfAt(pos, "%s loop ending at %d:%d was modified", loopKind, last.Line(), last.Col()) + } else { + pos = trueInlinedPos(inner) + last = trueInlinedPos(base.Ctxt.InnermostPos(last)) + base.WarnfAt(pos, "%s loop ending at %d:%d was modified (loop inlined into %s:%d)", loopKind, last.Line(), last.Col(), outer.Filename(), outer.Line()) + } + } + } + } +} diff --git a/go/src/cmd/compile/internal/loopvar/loopvar_test.go b/go/src/cmd/compile/internal/loopvar/loopvar_test.go new file mode 100644 index 0000000000000000000000000000000000000000..c4ff8f620dc5e63f4f0f2be75d4978ca7e95fbb7 --- /dev/null +++ b/go/src/cmd/compile/internal/loopvar/loopvar_test.go @@ -0,0 +1,443 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package loopvar_test + +import ( + "internal/testenv" + "os" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "strings" + "testing" +) + +type testcase struct { + lvFlag string // ==-2, -1, 0, 1, 2 + buildExpect string // message, if any + expectRC int + files []string +} + +var for_files = []string{ + "for_esc_address.go", // address of variable + "for_esc_closure.go", // closure of variable + "for_esc_minimal_closure.go", // simple closure of variable + "for_esc_method.go", // method value of variable + "for_complicated_esc_address.go", // modifies loop index in body +} + +var range_files = []string{ + "range_esc_address.go", // address of variable + "range_esc_closure.go", // closure of variable + "range_esc_minimal_closure.go", // simple closure of variable + "range_esc_method.go", // method value of variable +} + +var cases = []testcase{ + {"-1", "", 11, for_files[:1]}, + {"0", "", 0, for_files[:1]}, + {"1", "", 0, for_files[:1]}, + {"2", "loop variable i now per-iteration,", 0, for_files}, + + {"-1", "", 11, range_files[:1]}, + {"0", "", 0, range_files[:1]}, + {"1", "", 0, range_files[:1]}, + {"2", "loop variable i now per-iteration,", 0, range_files}, + + {"1", "", 0, []string{"for_nested.go"}}, +} + +// TestLoopVarGo1_21 checks that the GOEXPERIMENT and debug flags behave as expected. +func TestLoopVarGo1_21(t *testing.T) { + switch runtime.GOOS { + case "linux", "darwin": + default: + t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS) + } + switch runtime.GOARCH { + case "amd64", "arm64": + default: + t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH) + } + + testenv.MustHaveGoBuild(t) + gocmd := testenv.GoToolPath(t) + tmpdir := t.TempDir() + output := filepath.Join(tmpdir, "foo.exe") + + for i, tc := range cases { + for _, f := range tc.files { + source := f + cmd := testenv.Command(t, gocmd, "build", "-o", output, "-gcflags=-lang=go1.21 -d=loopvar="+tc.lvFlag, source) + cmd.Env = append(cmd.Env, "GOEXPERIMENT=loopvar", "HOME="+tmpdir) + cmd.Dir = "testdata" + t.Logf("File %s loopvar=%s expect '%s' exit code %d", f, tc.lvFlag, tc.buildExpect, tc.expectRC) + b, e := cmd.CombinedOutput() + if e != nil { + t.Error(e) + } + if tc.buildExpect != "" { + s := string(b) + if !strings.Contains(s, tc.buildExpect) { + t.Errorf("File %s test %d expected to match '%s' with \n-----\n%s\n-----", f, i, tc.buildExpect, s) + } + } + // run what we just built. + cmd = testenv.Command(t, output) + b, e = cmd.CombinedOutput() + if tc.expectRC != 0 { + if e == nil { + t.Errorf("Missing expected error, file %s, case %d", f, i) + } else if ee, ok := (e).(*exec.ExitError); !ok || ee.ExitCode() != tc.expectRC { + t.Error(e) + } else { + // okay + } + } else if e != nil { + t.Error(e) + } + } + } +} + +func TestLoopVarInlinesGo1_21(t *testing.T) { + switch runtime.GOOS { + case "linux", "darwin": + default: + t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS) + } + switch runtime.GOARCH { + case "amd64", "arm64": + default: + t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH) + } + + testenv.MustHaveGoBuild(t) + gocmd := testenv.GoToolPath(t) + tmpdir := t.TempDir() + + root := "cmd/compile/internal/loopvar/testdata/inlines" + + f := func(pkg string) string { + // This disables the loopvar change, except for the specified package. + // The effect should follow the package, even though everything (except "c") + // is inlined. + cmd := testenv.Command(t, gocmd, "run", "-gcflags="+root+"/...=-lang=go1.21", "-gcflags="+pkg+"=-d=loopvar=1", root) + cmd.Env = append(cmd.Env, "GOEXPERIMENT=noloopvar", "HOME="+tmpdir) + cmd.Dir = filepath.Join("testdata", "inlines") + + b, e := cmd.CombinedOutput() + if e != nil { + t.Error(e) + } + return string(b) + } + + a := f(root + "/a") + b := f(root + "/b") + c := f(root + "/c") + m := f(root) + + t.Log(a) + t.Log(b) + t.Log(c) + t.Log(m) + + if !strings.Contains(a, "f, af, bf, abf, cf sums = 100, 45, 100, 100, 100") { + t.Errorf("Did not see expected value of a") + } + if !strings.Contains(b, "f, af, bf, abf, cf sums = 100, 100, 45, 45, 100") { + t.Errorf("Did not see expected value of b") + } + if !strings.Contains(c, "f, af, bf, abf, cf sums = 100, 100, 100, 100, 45") { + t.Errorf("Did not see expected value of c") + } + if !strings.Contains(m, "f, af, bf, abf, cf sums = 45, 100, 100, 100, 100") { + t.Errorf("Did not see expected value of m") + } +} + +func countMatches(s, re string) int { + slice := regexp.MustCompile(re).FindAllString(s, -1) + return len(slice) +} + +func TestLoopVarHashes(t *testing.T) { + // This behavior does not depend on Go version (1.21 or greater) + switch runtime.GOOS { + case "linux", "darwin": + default: + t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS) + } + switch runtime.GOARCH { + case "amd64", "arm64": + default: + t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH) + } + + testenv.MustHaveGoBuild(t) + gocmd := testenv.GoToolPath(t) + tmpdir := t.TempDir() + + root := "cmd/compile/internal/loopvar/testdata/inlines" + + f := func(hash string) string { + // This disables the loopvar change, except for the specified hash pattern. + // -trimpath is necessary so we get the same answer no matter where the + // Go repository is checked out. This is not normally a concern since people + // do not normally rely on the meaning of specific hashes. + cmd := testenv.Command(t, gocmd, "run", "-trimpath", root) + cmd.Env = append(cmd.Env, "GOCOMPILEDEBUG=loopvarhash="+hash, "HOME="+tmpdir) + cmd.Dir = filepath.Join("testdata", "inlines") + + b, _ := cmd.CombinedOutput() + // Ignore the error, sometimes it's supposed to fail, the output test will catch it. + return string(b) + } + + for _, arg := range []string{"v001100110110110010100100", "vx336ca4"} { + m := f(arg) + t.Log(m) + + mCount := countMatches(m, "loopvarhash triggered cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6: .* 001100110110110010100100") + otherCount := strings.Count(m, "loopvarhash") + if mCount < 1 { + t.Errorf("%s: did not see triggered main.go:27:6", arg) + } + if mCount != otherCount { + t.Errorf("%s: too many matches", arg) + } + mCount = countMatches(m, "cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6: .* \\[bisect-match 0x7802e115b9336ca4\\]") + otherCount = strings.Count(m, "[bisect-match ") + if mCount < 1 { + t.Errorf("%s: did not see bisect-match for main.go:27:6", arg) + } + if mCount != otherCount { + t.Errorf("%s: too many matches", arg) + } + + // This next test carefully dodges a bug-to-be-fixed with inlined locations for ir.Names. + if !strings.Contains(m, ", 100, 100, 100, 100") { + t.Errorf("%s: did not see expected value of m run", arg) + } + } +} + +// TestLoopVarVersionEnableFlag checks for loopvar transformation enabled by command line flag (1.22). +func TestLoopVarVersionEnableFlag(t *testing.T) { + switch runtime.GOOS { + case "linux", "darwin": + default: + t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS) + } + switch runtime.GOARCH { + case "amd64", "arm64": + default: + t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH) + } + + testenv.MustHaveGoBuild(t) + gocmd := testenv.GoToolPath(t) + + // loopvar=3 logs info but does not change loopvarness + cmd := testenv.Command(t, gocmd, "run", "-gcflags=-lang=go1.22 -d=loopvar=3", "opt.go") + cmd.Dir = filepath.Join("testdata") + + b, err := cmd.CombinedOutput() + m := string(b) + + t.Log(m) + + yCount := strings.Count(m, "opt.go:16:6: loop variable private now per-iteration, heap-allocated (loop inlined into ./opt.go:29)") + nCount := strings.Count(m, "shared") + + if yCount != 1 { + t.Errorf("yCount=%d != 1", yCount) + } + if nCount > 0 { + t.Errorf("nCount=%d > 0", nCount) + } + if err != nil { + t.Errorf("err=%v != nil", err) + } +} + +// TestLoopVarVersionEnableGoBuild checks for loopvar transformation enabled by go:build version (1.22). +func TestLoopVarVersionEnableGoBuild(t *testing.T) { + switch runtime.GOOS { + case "linux", "darwin": + default: + t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS) + } + switch runtime.GOARCH { + case "amd64", "arm64": + default: + t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH) + } + + testenv.MustHaveGoBuild(t) + gocmd := testenv.GoToolPath(t) + + // loopvar=3 logs info but does not change loopvarness + cmd := testenv.Command(t, gocmd, "run", "-gcflags=-lang=go1.21 -d=loopvar=3", "opt-122.go") + cmd.Dir = filepath.Join("testdata") + + b, err := cmd.CombinedOutput() + m := string(b) + + t.Log(m) + + yCount := strings.Count(m, "opt-122.go:18:6: loop variable private now per-iteration, heap-allocated (loop inlined into ./opt-122.go:31)") + nCount := strings.Count(m, "shared") + + if yCount != 1 { + t.Errorf("yCount=%d != 1", yCount) + } + if nCount > 0 { + t.Errorf("nCount=%d > 0", nCount) + } + if err != nil { + t.Errorf("err=%v != nil", err) + } +} + +// TestLoopVarVersionDisableFlag checks for loopvar transformation DISABLED by command line version (1.21). +func TestLoopVarVersionDisableFlag(t *testing.T) { + switch runtime.GOOS { + case "linux", "darwin": + default: + t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS) + } + switch runtime.GOARCH { + case "amd64", "arm64": + default: + t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH) + } + + testenv.MustHaveGoBuild(t) + gocmd := testenv.GoToolPath(t) + + // loopvar=3 logs info but does not change loopvarness + cmd := testenv.Command(t, gocmd, "run", "-gcflags=-lang=go1.21 -d=loopvar=3", "opt.go") + cmd.Dir = filepath.Join("testdata") + + b, err := cmd.CombinedOutput() + m := string(b) + + t.Log(m) // expect error + + yCount := strings.Count(m, "opt.go:16:6: loop variable private now per-iteration, heap-allocated (loop inlined into ./opt.go:29)") + nCount := strings.Count(m, "shared") + + if yCount != 0 { + t.Errorf("yCount=%d != 0", yCount) + } + if nCount > 0 { + t.Errorf("nCount=%d > 0", nCount) + } + if err == nil { // expect error + t.Errorf("err=%v == nil", err) + } +} + +// TestLoopVarVersionDisableGoBuild checks for loopvar transformation DISABLED by go:build version (1.21). +func TestLoopVarVersionDisableGoBuild(t *testing.T) { + switch runtime.GOOS { + case "linux", "darwin": + default: + t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS) + } + switch runtime.GOARCH { + case "amd64", "arm64": + default: + t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH) + } + + testenv.MustHaveGoBuild(t) + gocmd := testenv.GoToolPath(t) + + // loopvar=3 logs info but does not change loopvarness + cmd := testenv.Command(t, gocmd, "run", "-gcflags=-lang=go1.22 -d=loopvar=3", "opt-121.go") + cmd.Dir = filepath.Join("testdata") + + b, err := cmd.CombinedOutput() + m := string(b) + + t.Log(m) // expect error + + yCount := strings.Count(m, "opt-121.go:18:6: loop variable private now per-iteration, heap-allocated (loop inlined into ./opt-121.go:31)") + nCount := strings.Count(m, "shared") + + if yCount != 0 { + t.Errorf("yCount=%d != 0", yCount) + } + if nCount > 0 { + t.Errorf("nCount=%d > 0", nCount) + } + if err == nil { // expect error + t.Errorf("err=%v == nil", err) + } +} + +// TestLoopVarLineDirective tests that loopvar version detection works correctly +// with line directives. This is a regression test for a bug where FileBase() was +// used instead of Base(), causing incorrect version lookup when line directives +// were present. +func TestLoopVarLineDirective(t *testing.T) { + switch runtime.GOOS { + case "linux", "darwin": + default: + t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS) + } + switch runtime.GOARCH { + case "amd64", "arm64": + default: + t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH) + } + + testenv.MustHaveGoBuild(t) + gocmd := testenv.GoToolPath(t) + tmpdir := t.TempDir() + output := filepath.Join(tmpdir, "foo.exe") + + // Create a go.mod file with Go 1.21 to test compatibility behavior. + // When building with a higher Go compiler, the loopvar should be created per-loop. + gomodPath := filepath.Join(tmpdir, "go.mod") + if err := os.WriteFile(gomodPath, []byte("module test\n\ngo 1.21\n"), 0644); err != nil { + t.Fatal(err) + } + + // Copy the test file (with line directive) to the temporary module + testFile := "range_esc_closure_linedir.go" + srcPath := filepath.Join("testdata", testFile) + dstPath := filepath.Join(tmpdir, testFile) + src, err := os.ReadFile(srcPath) + if err != nil { + t.Fatal(err) + } + if err := os.WriteFile(dstPath, src, 0644); err != nil { + t.Fatal(err) + } + + // Build the module (not as a single file, so go.mod is respected) + cmd := testenv.Command(t, gocmd, "build", "-o", output, ".") + cmd.Dir = tmpdir + b, err := cmd.CombinedOutput() + if err != nil { + t.Logf("build output: %s", b) + t.Fatal(err) + } + t.Logf("build output: %s", b) + + cmd = testenv.Command(t, output) + b, err = cmd.CombinedOutput() + t.Logf("run output: %s", b) + + if err != nil { + t.Errorf("expected success (exit code 0), got: %v", err) + } +} diff --git a/go/src/cmd/compile/internal/mips/galign.go b/go/src/cmd/compile/internal/mips/galign.go new file mode 100644 index 0000000000000000000000000000000000000000..4e6897042ec04ce2e81fa58960a26541fa5aaeb0 --- /dev/null +++ b/go/src/cmd/compile/internal/mips/galign.go @@ -0,0 +1,27 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mips + +import ( + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/internal/obj/mips" + "internal/buildcfg" +) + +func Init(arch *ssagen.ArchInfo) { + arch.LinkArch = &mips.Linkmips + if buildcfg.GOARCH == "mipsle" { + arch.LinkArch = &mips.Linkmipsle + } + arch.REGSP = mips.REGSP + arch.MAXWIDTH = (1 << 31) - 1 + arch.SoftFloat = (buildcfg.GOMIPS == "softfloat") + arch.ZeroRange = zerorange + arch.Ginsnop = ginsnop + arch.SSAMarkMoves = func(s *ssagen.State, b *ssa.Block) {} + arch.SSAGenValue = ssaGenValue + arch.SSAGenBlock = ssaGenBlock +} diff --git a/go/src/cmd/compile/internal/mips/ggen.go b/go/src/cmd/compile/internal/mips/ggen.go new file mode 100644 index 0000000000000000000000000000000000000000..394f0155895e8d9b8d6f546c582d83efb6dcc269 --- /dev/null +++ b/go/src/cmd/compile/internal/mips/ggen.go @@ -0,0 +1,32 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mips + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/objw" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/mips" +) + +func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { + if cnt%int64(types.PtrSize) != 0 { + panic("zeroed region not aligned") + } + + for cnt != 0 { + p = pp.Append(p, mips.AMOVW, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGSP, base.Ctxt.Arch.FixedFrameSize+off) + cnt -= int64(types.PtrSize) + off += int64(types.PtrSize) + } + + return p +} + +func ginsnop(pp *objw.Progs) *obj.Prog { + p := pp.Prog(mips.ANOOP) + return p +} diff --git a/go/src/cmd/compile/internal/mips/ssa.go b/go/src/cmd/compile/internal/mips/ssa.go new file mode 100644 index 0000000000000000000000000000000000000000..c338fdc6b3e46b1d25b1562b1e5d6e65b89197a3 --- /dev/null +++ b/go/src/cmd/compile/internal/mips/ssa.go @@ -0,0 +1,1018 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mips + +import ( + "math" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/mips" + "internal/abi" +) + +// isFPreg reports whether r is an FP register. +func isFPreg(r int16) bool { + return mips.REG_F0 <= r && r <= mips.REG_F31 +} + +// isHILO reports whether r is HI or LO register. +func isHILO(r int16) bool { + return r == mips.REG_HI || r == mips.REG_LO +} + +// loadByType returns the load instruction of the given type. +func loadByType(t *types.Type, r int16) obj.As { + if isFPreg(r) { + if t.Size() == 4 { // float32 or int32 + return mips.AMOVF + } else { // float64 or int64 + return mips.AMOVD + } + } else { + switch t.Size() { + case 1: + if t.IsSigned() { + return mips.AMOVB + } else { + return mips.AMOVBU + } + case 2: + if t.IsSigned() { + return mips.AMOVH + } else { + return mips.AMOVHU + } + case 4: + return mips.AMOVW + } + } + panic("bad load type") +} + +// storeByType returns the store instruction of the given type. +func storeByType(t *types.Type, r int16) obj.As { + if isFPreg(r) { + if t.Size() == 4 { // float32 or int32 + return mips.AMOVF + } else { // float64 or int64 + return mips.AMOVD + } + } else { + switch t.Size() { + case 1: + return mips.AMOVB + case 2: + return mips.AMOVH + case 4: + return mips.AMOVW + } + } + panic("bad store type") +} + +func ssaGenValue(s *ssagen.State, v *ssa.Value) { + switch v.Op { + case ssa.OpCopy, ssa.OpMIPSMOVWreg: + t := v.Type + if t.IsMemory() { + return + } + x := v.Args[0].Reg() + y := v.Reg() + if x == y { + return + } + as := mips.AMOVW + if isFPreg(x) && isFPreg(y) { + as = mips.AMOVF + if t.Size() == 8 { + as = mips.AMOVD + } + } + + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = x + p.To.Type = obj.TYPE_REG + p.To.Reg = y + if isHILO(x) && isHILO(y) || isHILO(x) && isFPreg(y) || isFPreg(x) && isHILO(y) { + // cannot move between special registers, use TMP as intermediate + p.To.Reg = mips.REGTMP + p = s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = y + } + case ssa.OpMIPSMOVWnop: + // nothing to do + case ssa.OpLoadReg: + if v.Type.IsFlags() { + v.Fatalf("load flags not implemented: %v", v.LongString()) + return + } + r := v.Reg() + p := s.Prog(loadByType(v.Type, r)) + ssagen.AddrAuto(&p.From, v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + if isHILO(r) { + // cannot directly load, load to TMP and move + p.To.Reg = mips.REGTMP + p = s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = r + } + case ssa.OpStoreReg: + if v.Type.IsFlags() { + v.Fatalf("store flags not implemented: %v", v.LongString()) + return + } + r := v.Args[0].Reg() + if isHILO(r) { + // cannot directly store, move to TMP and store + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = r + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REGTMP + r = mips.REGTMP + } + p := s.Prog(storeByType(v.Type, r)) + p.From.Type = obj.TYPE_REG + p.From.Reg = r + ssagen.AddrAuto(&p.To, v) + case ssa.OpMIPSADD, + ssa.OpMIPSSUB, + ssa.OpMIPSAND, + ssa.OpMIPSOR, + ssa.OpMIPSXOR, + ssa.OpMIPSNOR, + ssa.OpMIPSSLL, + ssa.OpMIPSSRL, + ssa.OpMIPSSRA, + ssa.OpMIPSADDF, + ssa.OpMIPSADDD, + ssa.OpMIPSSUBF, + ssa.OpMIPSSUBD, + ssa.OpMIPSMULF, + ssa.OpMIPSMULD, + ssa.OpMIPSDIVF, + ssa.OpMIPSDIVD, + ssa.OpMIPSMUL: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSSGT, + ssa.OpMIPSSGTU: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSSGTzero, + ssa.OpMIPSSGTUzero: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = mips.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSADDconst, + ssa.OpMIPSSUBconst, + ssa.OpMIPSANDconst, + ssa.OpMIPSORconst, + ssa.OpMIPSXORconst, + ssa.OpMIPSNORconst, + ssa.OpMIPSSLLconst, + ssa.OpMIPSSRLconst, + ssa.OpMIPSSRAconst, + ssa.OpMIPSSGTconst, + ssa.OpMIPSSGTUconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSMULT, + ssa.OpMIPSMULTU, + ssa.OpMIPSDIV, + ssa.OpMIPSDIVU: + // result in hi,lo + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.Reg = v.Args[0].Reg() + case ssa.OpMIPSMOVWconst: + r := v.Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = r + if isFPreg(r) || isHILO(r) { + // cannot move into FP or special registers, use TMP as intermediate + p.To.Reg = mips.REGTMP + p = s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = r + } + case ssa.OpMIPSMOVFconst, + ssa.OpMIPSMOVDconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_FCONST + p.From.Val = math.Float64frombits(uint64(v.AuxInt)) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSCMOVZ: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSCMOVZzero: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.Reg = mips.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSCMPEQF, + ssa.OpMIPSCMPEQD, + ssa.OpMIPSCMPGEF, + ssa.OpMIPSCMPGED, + ssa.OpMIPSCMPGTF, + ssa.OpMIPSCMPGTD: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = v.Args[1].Reg() + case ssa.OpMIPSMOVWaddr: + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() + var wantreg string + // MOVW $sym+off(base), R + // the assembler expands it as the following: + // - base is SP: add constant offset to SP (R29) + // when constant is large, tmp register (R23) may be used + // - base is SB: load external address with relocation + switch v.Aux.(type) { + default: + v.Fatalf("aux is of unknown type %T", v.Aux) + case *obj.LSym: + wantreg = "SB" + ssagen.AddAux(&p.From, v) + case *ir.Name: + wantreg = "SP" + ssagen.AddAux(&p.From, v) + case nil: + // No sym, just MOVW $off(SP), R + wantreg = "SP" + p.From.Offset = v.AuxInt + } + if reg := v.Args[0].RegName(); reg != wantreg { + v.Fatalf("bad reg %s for symbol type %T, want %s", reg, v.Aux, wantreg) + } + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSMOVBload, + ssa.OpMIPSMOVBUload, + ssa.OpMIPSMOVHload, + ssa.OpMIPSMOVHUload, + ssa.OpMIPSMOVWload, + ssa.OpMIPSMOVFload, + ssa.OpMIPSMOVDload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSMOVBstore, + ssa.OpMIPSMOVHstore, + ssa.OpMIPSMOVWstore, + ssa.OpMIPSMOVFstore, + ssa.OpMIPSMOVDstore: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpMIPSMOVBstorezero, + ssa.OpMIPSMOVHstorezero, + ssa.OpMIPSMOVWstorezero: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGZERO + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpMIPSMOVBreg, + ssa.OpMIPSMOVBUreg, + ssa.OpMIPSMOVHreg, + ssa.OpMIPSMOVHUreg: + a := v.Args[0] + for a.Op == ssa.OpCopy || a.Op == ssa.OpMIPSMOVWreg || a.Op == ssa.OpMIPSMOVWnop { + a = a.Args[0] + } + if a.Op == ssa.OpLoadReg { + t := a.Type + switch { + case v.Op == ssa.OpMIPSMOVBreg && t.Size() == 1 && t.IsSigned(), + v.Op == ssa.OpMIPSMOVBUreg && t.Size() == 1 && !t.IsSigned(), + v.Op == ssa.OpMIPSMOVHreg && t.Size() == 2 && t.IsSigned(), + v.Op == ssa.OpMIPSMOVHUreg && t.Size() == 2 && !t.IsSigned(): + // arg is a proper-typed load, already zero/sign-extended, don't extend again + if v.Reg() == v.Args[0].Reg() { + return + } + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + return + default: + } + } + fallthrough + case ssa.OpMIPSMOVWF, + ssa.OpMIPSMOVWD, + ssa.OpMIPSTRUNCFW, + ssa.OpMIPSTRUNCDW, + ssa.OpMIPSMOVFD, + ssa.OpMIPSMOVDF, + ssa.OpMIPSMOVWfpgp, + ssa.OpMIPSMOVWgpfp, + ssa.OpMIPSNEGF, + ssa.OpMIPSNEGD, + ssa.OpMIPSABSD, + ssa.OpMIPSSQRTF, + ssa.OpMIPSSQRTD, + ssa.OpMIPSCLZ: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSNEG: + // SUB from REGZERO + p := s.Prog(mips.ASUBU) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = mips.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSLoweredZero: + // SUBU $4, R1 + // MOVW R0, 4(R1) + // ADDU $4, R1 + // BNE Rarg1, R1, -2(PC) + // arg1 is the address of the last element to zero + var sz int64 + var mov obj.As + switch { + case v.AuxInt%4 == 0: + sz = 4 + mov = mips.AMOVW + case v.AuxInt%2 == 0: + sz = 2 + mov = mips.AMOVH + default: + sz = 1 + mov = mips.AMOVB + } + p := s.Prog(mips.ASUBU) + p.From.Type = obj.TYPE_CONST + p.From.Offset = sz + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + p2 := s.Prog(mov) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = mips.REGZERO + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = mips.REG_R1 + p2.To.Offset = sz + p3 := s.Prog(mips.AADDU) + p3.From.Type = obj.TYPE_CONST + p3.From.Offset = sz + p3.To.Type = obj.TYPE_REG + p3.To.Reg = mips.REG_R1 + p4 := s.Prog(mips.ABNE) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = v.Args[1].Reg() + p4.Reg = mips.REG_R1 + p4.To.Type = obj.TYPE_BRANCH + p4.To.SetTarget(p2) + case ssa.OpMIPSLoweredMove: + // SUBU $4, R1 + // MOVW 4(R1), Rtmp + // MOVW Rtmp, (R2) + // ADDU $4, R1 + // ADDU $4, R2 + // BNE Rarg2, R1, -4(PC) + // arg2 is the address of the last element of src + var sz int64 + var mov obj.As + switch { + case v.AuxInt%4 == 0: + sz = 4 + mov = mips.AMOVW + case v.AuxInt%2 == 0: + sz = 2 + mov = mips.AMOVH + default: + sz = 1 + mov = mips.AMOVB + } + p := s.Prog(mips.ASUBU) + p.From.Type = obj.TYPE_CONST + p.From.Offset = sz + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + p2 := s.Prog(mov) + p2.From.Type = obj.TYPE_MEM + p2.From.Reg = mips.REG_R1 + p2.From.Offset = sz + p2.To.Type = obj.TYPE_REG + p2.To.Reg = mips.REGTMP + p3 := s.Prog(mov) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = mips.REGTMP + p3.To.Type = obj.TYPE_MEM + p3.To.Reg = mips.REG_R2 + p4 := s.Prog(mips.AADDU) + p4.From.Type = obj.TYPE_CONST + p4.From.Offset = sz + p4.To.Type = obj.TYPE_REG + p4.To.Reg = mips.REG_R1 + p5 := s.Prog(mips.AADDU) + p5.From.Type = obj.TYPE_CONST + p5.From.Offset = sz + p5.To.Type = obj.TYPE_REG + p5.To.Reg = mips.REG_R2 + p6 := s.Prog(mips.ABNE) + p6.From.Type = obj.TYPE_REG + p6.From.Reg = v.Args[2].Reg() + p6.Reg = mips.REG_R1 + p6.To.Type = obj.TYPE_BRANCH + p6.To.SetTarget(p2) + case ssa.OpMIPSCALLstatic, ssa.OpMIPSCALLclosure, ssa.OpMIPSCALLinter: + s.Call(v) + case ssa.OpMIPSCALLtail: + s.TailCall(v) + case ssa.OpMIPSLoweredWB: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + // AuxInt encodes how many buffer entries we need. + p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1] + + case ssa.OpMIPSLoweredPanicBoundsRR, ssa.OpMIPSLoweredPanicBoundsRC, ssa.OpMIPSLoweredPanicBoundsCR, ssa.OpMIPSLoweredPanicBoundsCC, + ssa.OpMIPSLoweredPanicExtendRR, ssa.OpMIPSLoweredPanicExtendRC: + // Compute the constant we put in the PCData entry for this call. + code, signed := ssa.BoundsKind(v.AuxInt).Code() + xIsReg := false + yIsReg := false + xVal := 0 + yVal := 0 + extend := false + switch v.Op { + case ssa.OpMIPSLoweredPanicBoundsRR: + xIsReg = true + xVal = int(v.Args[0].Reg() - mips.REG_R1) + yIsReg = true + yVal = int(v.Args[1].Reg() - mips.REG_R1) + case ssa.OpMIPSLoweredPanicExtendRR: + extend = true + xIsReg = true + hi := int(v.Args[0].Reg() - mips.REG_R1) + lo := int(v.Args[1].Reg() - mips.REG_R1) + xVal = hi<<2 + lo // encode 2 register numbers + yIsReg = true + yVal = int(v.Args[2].Reg() - mips.REG_R1) + case ssa.OpMIPSLoweredPanicBoundsRC: + xIsReg = true + xVal = int(v.Args[0].Reg() - mips.REG_R1) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + if yVal == xVal { + yVal = 1 + } + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(yVal) + } + case ssa.OpMIPSLoweredPanicExtendRC: + extend = true + xIsReg = true + hi := int(v.Args[0].Reg() - mips.REG_R1) + lo := int(v.Args[1].Reg() - mips.REG_R1) + xVal = hi<<2 + lo // encode 2 register numbers + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + for yVal == hi || yVal == lo { + yVal++ + } + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(yVal) + } + case ssa.OpMIPSLoweredPanicBoundsCR: + yIsReg = true + yVal = int(v.Args[0].Reg() - mips.REG_R1) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else if signed && int64(int32(c)) == c || !signed && int64(uint32(c)) == c { + // Move constant to a register + xIsReg = true + if xVal == yVal { + xVal = 1 + } + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(xVal) + } else { + // Move constant to two registers + extend = true + xIsReg = true + hi := 0 + lo := 1 + if hi == yVal { + hi = 2 + } + if lo == yVal { + lo = 2 + } + xVal = hi<<2 + lo + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c >> 32 + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(hi) + p = s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(int32(c)) + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(lo) + } + case ssa.OpMIPSLoweredPanicBoundsCC: + c := v.Aux.(ssa.PanicBoundsCC).Cx + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else if signed && int64(int32(c)) == c || !signed && int64(uint32(c)) == c { + // Move constant to a register + xIsReg = true + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(xVal) + } else { + // Move constant to two registers + extend = true + xIsReg = true + hi := 0 + lo := 1 + xVal = hi<<2 + lo + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c >> 32 + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(hi) + p = s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(int32(c)) + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(lo) + } + c = v.Aux.(ssa.PanicBoundsCC).Cy + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + yVal = 2 + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(yVal) + } + } + c := abi.BoundsEncode(code, signed, xIsReg, yIsReg, xVal, yVal) + + p := s.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_PanicBounds) + p.To.SetConst(int64(c)) + p = s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + if extend { + p.To.Sym = ir.Syms.PanicExtend + } else { + p.To.Sym = ir.Syms.PanicBounds + } + + case ssa.OpMIPSLoweredAtomicLoad8, + ssa.OpMIPSLoweredAtomicLoad32: + s.Prog(mips.ASYNC) + + var op obj.As + switch v.Op { + case ssa.OpMIPSLoweredAtomicLoad8: + op = mips.AMOVB + case ssa.OpMIPSLoweredAtomicLoad32: + op = mips.AMOVW + } + p := s.Prog(op) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + s.Prog(mips.ASYNC) + case ssa.OpMIPSLoweredAtomicStore8, + ssa.OpMIPSLoweredAtomicStore32: + s.Prog(mips.ASYNC) + + var op obj.As + switch v.Op { + case ssa.OpMIPSLoweredAtomicStore8: + op = mips.AMOVB + case ssa.OpMIPSLoweredAtomicStore32: + op = mips.AMOVW + } + p := s.Prog(op) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + + s.Prog(mips.ASYNC) + case ssa.OpMIPSLoweredAtomicStorezero: + s.Prog(mips.ASYNC) + + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGZERO + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + + s.Prog(mips.ASYNC) + case ssa.OpMIPSLoweredAtomicExchange: + // SYNC + // MOVW Rarg1, Rtmp + // LL (Rarg0), Rout + // SC Rtmp, (Rarg0) + // BEQ Rtmp, -3(PC) + // SYNC + s.Prog(mips.ASYNC) + + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REGTMP + + p1 := s.Prog(mips.ALL) + p1.From.Type = obj.TYPE_MEM + p1.From.Reg = v.Args[0].Reg() + p1.To.Type = obj.TYPE_REG + p1.To.Reg = v.Reg0() + + p2 := s.Prog(mips.ASC) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = mips.REGTMP + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = v.Args[0].Reg() + + p3 := s.Prog(mips.ABEQ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = mips.REGTMP + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + + s.Prog(mips.ASYNC) + case ssa.OpMIPSLoweredAtomicAdd: + // SYNC + // LL (Rarg0), Rout + // ADDU Rarg1, Rout, Rtmp + // SC Rtmp, (Rarg0) + // BEQ Rtmp, -3(PC) + // SYNC + // ADDU Rarg1, Rout + s.Prog(mips.ASYNC) + + p := s.Prog(mips.ALL) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + p1 := s.Prog(mips.AADDU) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = v.Args[1].Reg() + p1.Reg = v.Reg0() + p1.To.Type = obj.TYPE_REG + p1.To.Reg = mips.REGTMP + + p2 := s.Prog(mips.ASC) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = mips.REGTMP + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = v.Args[0].Reg() + + p3 := s.Prog(mips.ABEQ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = mips.REGTMP + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + + s.Prog(mips.ASYNC) + + p4 := s.Prog(mips.AADDU) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = v.Args[1].Reg() + p4.Reg = v.Reg0() + p4.To.Type = obj.TYPE_REG + p4.To.Reg = v.Reg0() + + case ssa.OpMIPSLoweredAtomicAddconst: + // SYNC + // LL (Rarg0), Rout + // ADDU $auxInt, Rout, Rtmp + // SC Rtmp, (Rarg0) + // BEQ Rtmp, -3(PC) + // SYNC + // ADDU $auxInt, Rout + s.Prog(mips.ASYNC) + + p := s.Prog(mips.ALL) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + p1 := s.Prog(mips.AADDU) + p1.From.Type = obj.TYPE_CONST + p1.From.Offset = v.AuxInt + p1.Reg = v.Reg0() + p1.To.Type = obj.TYPE_REG + p1.To.Reg = mips.REGTMP + + p2 := s.Prog(mips.ASC) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = mips.REGTMP + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = v.Args[0].Reg() + + p3 := s.Prog(mips.ABEQ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = mips.REGTMP + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + + s.Prog(mips.ASYNC) + + p4 := s.Prog(mips.AADDU) + p4.From.Type = obj.TYPE_CONST + p4.From.Offset = v.AuxInt + p4.Reg = v.Reg0() + p4.To.Type = obj.TYPE_REG + p4.To.Reg = v.Reg0() + + case ssa.OpMIPSLoweredAtomicAnd, + ssa.OpMIPSLoweredAtomicOr: + // SYNC + // LL (Rarg0), Rtmp + // AND/OR Rarg1, Rtmp + // SC Rtmp, (Rarg0) + // BEQ Rtmp, -3(PC) + // SYNC + s.Prog(mips.ASYNC) + + p := s.Prog(mips.ALL) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REGTMP + + p1 := s.Prog(v.Op.Asm()) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = v.Args[1].Reg() + p1.Reg = mips.REGTMP + p1.To.Type = obj.TYPE_REG + p1.To.Reg = mips.REGTMP + + p2 := s.Prog(mips.ASC) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = mips.REGTMP + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = v.Args[0].Reg() + + p3 := s.Prog(mips.ABEQ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = mips.REGTMP + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + + s.Prog(mips.ASYNC) + + case ssa.OpMIPSLoweredAtomicCas: + // MOVW $0, Rout + // SYNC + // LL (Rarg0), Rtmp + // BNE Rtmp, Rarg1, 4(PC) + // MOVW Rarg2, Rout + // SC Rout, (Rarg0) + // BEQ Rout, -4(PC) + // SYNC + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + s.Prog(mips.ASYNC) + + p1 := s.Prog(mips.ALL) + p1.From.Type = obj.TYPE_MEM + p1.From.Reg = v.Args[0].Reg() + p1.To.Type = obj.TYPE_REG + p1.To.Reg = mips.REGTMP + + p2 := s.Prog(mips.ABNE) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = v.Args[1].Reg() + p2.Reg = mips.REGTMP + p2.To.Type = obj.TYPE_BRANCH + + p3 := s.Prog(mips.AMOVW) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = v.Args[2].Reg() + p3.To.Type = obj.TYPE_REG + p3.To.Reg = v.Reg0() + + p4 := s.Prog(mips.ASC) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = v.Reg0() + p4.To.Type = obj.TYPE_MEM + p4.To.Reg = v.Args[0].Reg() + + p5 := s.Prog(mips.ABEQ) + p5.From.Type = obj.TYPE_REG + p5.From.Reg = v.Reg0() + p5.To.Type = obj.TYPE_BRANCH + p5.To.SetTarget(p1) + + s.Prog(mips.ASYNC) + + p6 := s.Prog(obj.ANOP) + p2.To.SetTarget(p6) + + case ssa.OpMIPSLoweredNilCheck: + // Issue a load which will fault if arg is nil. + p := s.Prog(mips.AMOVB) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REGTMP + if logopt.Enabled() { + logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name) + } + if base.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers + base.WarnfAt(v.Pos, "generated nil check") + } + case ssa.OpMIPSFPFlagTrue, + ssa.OpMIPSFPFlagFalse: + // MOVW $1, r + // CMOVF R0, r + + cmov := mips.ACMOVF + if v.Op == ssa.OpMIPSFPFlagFalse { + cmov = mips.ACMOVT + } + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 1 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + p1 := s.Prog(cmov) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = mips.REGZERO + p1.To.Type = obj.TYPE_REG + p1.To.Reg = v.Reg() + + case ssa.OpMIPSLoweredGetClosurePtr: + // Closure pointer is R22 (mips.REGCTXT). + ssagen.CheckLoweredGetClosurePtr(v) + case ssa.OpMIPSLoweredGetCallerSP: + // caller's SP is FixedFrameSize below the address of the first arg + p := s.Prog(mips.AMOVW) + p.From.Type = obj.TYPE_ADDR + p.From.Offset = -base.Ctxt.Arch.FixedFrameSize + p.From.Name = obj.NAME_PARAM + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSLoweredGetCallerPC: + p := s.Prog(obj.AGETCALLERPC) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPSLoweredPubBarrier: + // SYNC + s.Prog(v.Op.Asm()) + case ssa.OpClobber, ssa.OpClobberReg: + // TODO: implement for clobberdead experiment. Nop is ok for now. + default: + v.Fatalf("genValue not implemented: %s", v.LongString()) + } +} + +var blockJump = map[ssa.BlockKind]struct { + asm, invasm obj.As +}{ + ssa.BlockMIPSEQ: {mips.ABEQ, mips.ABNE}, + ssa.BlockMIPSNE: {mips.ABNE, mips.ABEQ}, + ssa.BlockMIPSLTZ: {mips.ABLTZ, mips.ABGEZ}, + ssa.BlockMIPSGEZ: {mips.ABGEZ, mips.ABLTZ}, + ssa.BlockMIPSLEZ: {mips.ABLEZ, mips.ABGTZ}, + ssa.BlockMIPSGTZ: {mips.ABGTZ, mips.ABLEZ}, + ssa.BlockMIPSFPT: {mips.ABFPT, mips.ABFPF}, + ssa.BlockMIPSFPF: {mips.ABFPF, mips.ABFPT}, +} + +func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) { + switch b.Kind { + case ssa.BlockPlain, ssa.BlockDefer: + if b.Succs[0].Block() != next { + p := s.Prog(obj.AJMP) + p.To.Type = obj.TYPE_BRANCH + s.Branches = append(s.Branches, ssagen.Branch{P: p, B: b.Succs[0].Block()}) + } + case ssa.BlockExit, ssa.BlockRetJmp: + case ssa.BlockRet: + s.Prog(obj.ARET) + case ssa.BlockMIPSEQ, ssa.BlockMIPSNE, + ssa.BlockMIPSLTZ, ssa.BlockMIPSGEZ, + ssa.BlockMIPSLEZ, ssa.BlockMIPSGTZ, + ssa.BlockMIPSFPT, ssa.BlockMIPSFPF: + jmp := blockJump[b.Kind] + var p *obj.Prog + switch next { + case b.Succs[0].Block(): + p = s.Br(jmp.invasm, b.Succs[1].Block()) + case b.Succs[1].Block(): + p = s.Br(jmp.asm, b.Succs[0].Block()) + default: + if b.Likely != ssa.BranchUnlikely { + p = s.Br(jmp.asm, b.Succs[0].Block()) + s.Br(obj.AJMP, b.Succs[1].Block()) + } else { + p = s.Br(jmp.invasm, b.Succs[1].Block()) + s.Br(obj.AJMP, b.Succs[0].Block()) + } + } + if !b.Controls[0].Type.IsFlags() { + p.From.Type = obj.TYPE_REG + p.From.Reg = b.Controls[0].Reg() + } + default: + b.Fatalf("branch not implemented: %s", b.LongString()) + } +} diff --git a/go/src/cmd/compile/internal/mips64/galign.go b/go/src/cmd/compile/internal/mips64/galign.go new file mode 100644 index 0000000000000000000000000000000000000000..412bc71aab270d97befa5dd3296ad381db180dcc --- /dev/null +++ b/go/src/cmd/compile/internal/mips64/galign.go @@ -0,0 +1,28 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mips64 + +import ( + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/internal/obj/mips" + "internal/buildcfg" +) + +func Init(arch *ssagen.ArchInfo) { + arch.LinkArch = &mips.Linkmips64 + if buildcfg.GOARCH == "mips64le" { + arch.LinkArch = &mips.Linkmips64le + } + arch.REGSP = mips.REGSP + arch.MAXWIDTH = 1 << 50 + arch.SoftFloat = buildcfg.GOMIPS64 == "softfloat" + arch.ZeroRange = zerorange + arch.Ginsnop = ginsnop + + arch.SSAMarkMoves = func(s *ssagen.State, b *ssa.Block) {} + arch.SSAGenValue = ssaGenValue + arch.SSAGenBlock = ssaGenBlock +} diff --git a/go/src/cmd/compile/internal/mips64/ggen.go b/go/src/cmd/compile/internal/mips64/ggen.go new file mode 100644 index 0000000000000000000000000000000000000000..740d68e335b7bd6a6b684200e11285016e05884b --- /dev/null +++ b/go/src/cmd/compile/internal/mips64/ggen.go @@ -0,0 +1,31 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mips64 + +import ( + "cmd/compile/internal/objw" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/mips" +) + +func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { + if cnt%int64(types.PtrSize) != 0 { + panic("zeroed region not aligned") + } + + for cnt != 0 { + p = pp.Append(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGSP, off+8) + cnt -= int64(types.PtrSize) + off += int64(types.PtrSize) + } + + return p +} + +func ginsnop(pp *objw.Progs) *obj.Prog { + p := pp.Prog(mips.ANOOP) + return p +} diff --git a/go/src/cmd/compile/internal/mips64/ssa.go b/go/src/cmd/compile/internal/mips64/ssa.go new file mode 100644 index 0000000000000000000000000000000000000000..6eae8fe0dd50ebb4a2232a9c917a59ebdd88580e --- /dev/null +++ b/go/src/cmd/compile/internal/mips64/ssa.go @@ -0,0 +1,949 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mips64 + +import ( + "math" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/mips" + "internal/abi" +) + +// isFPreg reports whether r is an FP register. +func isFPreg(r int16) bool { + return mips.REG_F0 <= r && r <= mips.REG_F31 +} + +// isHILO reports whether r is HI or LO register. +func isHILO(r int16) bool { + return r == mips.REG_HI || r == mips.REG_LO +} + +// loadByType returns the load instruction of the given type. +func loadByType(t *types.Type, r int16) obj.As { + if isFPreg(r) { + if t.Size() == 4 { // float32 or int32 + return mips.AMOVF + } else { // float64 or int64 + return mips.AMOVD + } + } else { + switch t.Size() { + case 1: + if t.IsSigned() { + return mips.AMOVB + } else { + return mips.AMOVBU + } + case 2: + if t.IsSigned() { + return mips.AMOVH + } else { + return mips.AMOVHU + } + case 4: + if t.IsSigned() { + return mips.AMOVW + } else { + return mips.AMOVWU + } + case 8: + return mips.AMOVV + } + } + panic("bad load type") +} + +// storeByType returns the store instruction of the given type. +func storeByType(t *types.Type, r int16) obj.As { + if isFPreg(r) { + if t.Size() == 4 { // float32 or int32 + return mips.AMOVF + } else { // float64 or int64 + return mips.AMOVD + } + } else { + switch t.Size() { + case 1: + return mips.AMOVB + case 2: + return mips.AMOVH + case 4: + return mips.AMOVW + case 8: + return mips.AMOVV + } + } + panic("bad store type") +} + +func ssaGenValue(s *ssagen.State, v *ssa.Value) { + switch v.Op { + case ssa.OpCopy, ssa.OpMIPS64MOVVreg: + if v.Type.IsMemory() { + return + } + x := v.Args[0].Reg() + y := v.Reg() + if x == y { + return + } + as := mips.AMOVV + if isFPreg(x) && isFPreg(y) { + as = mips.AMOVD + } + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = x + p.To.Type = obj.TYPE_REG + p.To.Reg = y + if isHILO(x) && isHILO(y) || isHILO(x) && isFPreg(y) || isFPreg(x) && isHILO(y) { + // cannot move between special registers, use TMP as intermediate + p.To.Reg = mips.REGTMP + p = s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = y + } + case ssa.OpMIPS64MOVVnop, ssa.OpMIPS64ZERO: + // nothing to do + case ssa.OpLoadReg: + if v.Type.IsFlags() { + v.Fatalf("load flags not implemented: %v", v.LongString()) + return + } + r := v.Reg() + p := s.Prog(loadByType(v.Type, r)) + ssagen.AddrAuto(&p.From, v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + if isHILO(r) { + // cannot directly load, load to TMP and move + p.To.Reg = mips.REGTMP + p = s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = r + } + case ssa.OpStoreReg: + if v.Type.IsFlags() { + v.Fatalf("store flags not implemented: %v", v.LongString()) + return + } + r := v.Args[0].Reg() + if isHILO(r) { + // cannot directly store, move to TMP and store + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = r + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REGTMP + r = mips.REGTMP + } + p := s.Prog(storeByType(v.Type, r)) + p.From.Type = obj.TYPE_REG + p.From.Reg = r + ssagen.AddrAuto(&p.To, v) + case ssa.OpMIPS64ADDV, + ssa.OpMIPS64SUBV, + ssa.OpMIPS64AND, + ssa.OpMIPS64OR, + ssa.OpMIPS64XOR, + ssa.OpMIPS64NOR, + ssa.OpMIPS64SLLV, + ssa.OpMIPS64SRLV, + ssa.OpMIPS64SRAV, + ssa.OpMIPS64ADDF, + ssa.OpMIPS64ADDD, + ssa.OpMIPS64SUBF, + ssa.OpMIPS64SUBD, + ssa.OpMIPS64MULF, + ssa.OpMIPS64MULD, + ssa.OpMIPS64DIVF, + ssa.OpMIPS64DIVD: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPS64SGT, + ssa.OpMIPS64SGTU: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPS64ADDVconst, + ssa.OpMIPS64SUBVconst, + ssa.OpMIPS64ANDconst, + ssa.OpMIPS64ORconst, + ssa.OpMIPS64XORconst, + ssa.OpMIPS64NORconst, + ssa.OpMIPS64SLLVconst, + ssa.OpMIPS64SRLVconst, + ssa.OpMIPS64SRAVconst, + ssa.OpMIPS64SGTconst, + ssa.OpMIPS64SGTUconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPS64MULV, + ssa.OpMIPS64MULVU, + ssa.OpMIPS64DIVV, + ssa.OpMIPS64DIVVU: + // result in hi,lo + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.Reg = v.Args[0].Reg() + case ssa.OpMIPS64MOVVconst: + r := v.Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = r + if isFPreg(r) || isHILO(r) { + // cannot move into FP or special registers, use TMP as intermediate + p.To.Reg = mips.REGTMP + p = s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = r + } + case ssa.OpMIPS64MOVFconst, + ssa.OpMIPS64MOVDconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_FCONST + p.From.Val = math.Float64frombits(uint64(v.AuxInt)) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPS64CMPEQF, + ssa.OpMIPS64CMPEQD, + ssa.OpMIPS64CMPGEF, + ssa.OpMIPS64CMPGED, + ssa.OpMIPS64CMPGTF, + ssa.OpMIPS64CMPGTD: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = v.Args[1].Reg() + case ssa.OpMIPS64MOVVaddr: + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() + var wantreg string + // MOVV $sym+off(base), R + // the assembler expands it as the following: + // - base is SP: add constant offset to SP (R29) + // when constant is large, tmp register (R23) may be used + // - base is SB: load external address with relocation + switch v.Aux.(type) { + default: + v.Fatalf("aux is of unknown type %T", v.Aux) + case *obj.LSym: + wantreg = "SB" + ssagen.AddAux(&p.From, v) + case *ir.Name: + wantreg = "SP" + ssagen.AddAux(&p.From, v) + case nil: + // No sym, just MOVV $off(SP), R + wantreg = "SP" + p.From.Offset = v.AuxInt + } + if reg := v.Args[0].RegName(); reg != wantreg { + v.Fatalf("bad reg %s for symbol type %T, want %s", reg, v.Aux, wantreg) + } + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPS64MOVBload, + ssa.OpMIPS64MOVBUload, + ssa.OpMIPS64MOVHload, + ssa.OpMIPS64MOVHUload, + ssa.OpMIPS64MOVWload, + ssa.OpMIPS64MOVWUload, + ssa.OpMIPS64MOVVload, + ssa.OpMIPS64MOVFload, + ssa.OpMIPS64MOVDload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPS64MOVBstore, + ssa.OpMIPS64MOVHstore, + ssa.OpMIPS64MOVWstore, + ssa.OpMIPS64MOVVstore, + ssa.OpMIPS64MOVFstore, + ssa.OpMIPS64MOVDstore: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpMIPS64MOVBreg, + ssa.OpMIPS64MOVBUreg, + ssa.OpMIPS64MOVHreg, + ssa.OpMIPS64MOVHUreg, + ssa.OpMIPS64MOVWreg, + ssa.OpMIPS64MOVWUreg: + a := v.Args[0] + for a.Op == ssa.OpCopy || a.Op == ssa.OpMIPS64MOVVreg { + a = a.Args[0] + } + if a.Op == ssa.OpLoadReg && mips.REG_R0 <= a.Reg() && a.Reg() <= mips.REG_R31 { + // LoadReg from a narrower type does an extension, except loading + // to a floating point register. So only eliminate the extension + // if it is loaded to an integer register. + t := a.Type + switch { + case v.Op == ssa.OpMIPS64MOVBreg && t.Size() == 1 && t.IsSigned(), + v.Op == ssa.OpMIPS64MOVBUreg && t.Size() == 1 && !t.IsSigned(), + v.Op == ssa.OpMIPS64MOVHreg && t.Size() == 2 && t.IsSigned(), + v.Op == ssa.OpMIPS64MOVHUreg && t.Size() == 2 && !t.IsSigned(), + v.Op == ssa.OpMIPS64MOVWreg && t.Size() == 4 && t.IsSigned(), + v.Op == ssa.OpMIPS64MOVWUreg && t.Size() == 4 && !t.IsSigned(): + // arg is a proper-typed load, already zero/sign-extended, don't extend again + if v.Reg() == v.Args[0].Reg() { + return + } + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + return + default: + } + } + fallthrough + case ssa.OpMIPS64MOVWF, + ssa.OpMIPS64MOVWD, + ssa.OpMIPS64TRUNCFW, + ssa.OpMIPS64TRUNCDW, + ssa.OpMIPS64MOVVF, + ssa.OpMIPS64MOVVD, + ssa.OpMIPS64TRUNCFV, + ssa.OpMIPS64TRUNCDV, + ssa.OpMIPS64MOVFD, + ssa.OpMIPS64MOVDF, + ssa.OpMIPS64MOVWfpgp, + ssa.OpMIPS64MOVWgpfp, + ssa.OpMIPS64MOVVfpgp, + ssa.OpMIPS64MOVVgpfp, + ssa.OpMIPS64NEGF, + ssa.OpMIPS64NEGD, + ssa.OpMIPS64ABSD, + ssa.OpMIPS64SQRTF, + ssa.OpMIPS64SQRTD: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPS64NEGV: + // SUB from REGZERO + p := s.Prog(mips.ASUBVU) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.Reg = mips.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPS64DUFFZERO: + // runtime.duffzero expects start address - 8 in R1 + p := s.Prog(mips.ASUBVU) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 8 + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + p = s.Prog(obj.ADUFFZERO) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.Duffzero + p.To.Offset = v.AuxInt + case ssa.OpMIPS64LoweredZero: + // SUBV $8, R1 + // MOVV R0, 8(R1) + // ADDV $8, R1 + // BNE Rarg1, R1, -2(PC) + // arg1 is the address of the last element to zero + var sz int64 + var mov obj.As + switch { + case v.AuxInt%8 == 0: + sz = 8 + mov = mips.AMOVV + case v.AuxInt%4 == 0: + sz = 4 + mov = mips.AMOVW + case v.AuxInt%2 == 0: + sz = 2 + mov = mips.AMOVH + default: + sz = 1 + mov = mips.AMOVB + } + p := s.Prog(mips.ASUBVU) + p.From.Type = obj.TYPE_CONST + p.From.Offset = sz + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + p2 := s.Prog(mov) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = mips.REGZERO + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = mips.REG_R1 + p2.To.Offset = sz + p3 := s.Prog(mips.AADDVU) + p3.From.Type = obj.TYPE_CONST + p3.From.Offset = sz + p3.To.Type = obj.TYPE_REG + p3.To.Reg = mips.REG_R1 + p4 := s.Prog(mips.ABNE) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = v.Args[1].Reg() + p4.Reg = mips.REG_R1 + p4.To.Type = obj.TYPE_BRANCH + p4.To.SetTarget(p2) + case ssa.OpMIPS64DUFFCOPY: + p := s.Prog(obj.ADUFFCOPY) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.Duffcopy + p.To.Offset = v.AuxInt + case ssa.OpMIPS64LoweredMove: + // SUBV $8, R1 + // MOVV 8(R1), Rtmp + // MOVV Rtmp, (R2) + // ADDV $8, R1 + // ADDV $8, R2 + // BNE Rarg2, R1, -4(PC) + // arg2 is the address of the last element of src + var sz int64 + var mov obj.As + switch { + case v.AuxInt%8 == 0: + sz = 8 + mov = mips.AMOVV + case v.AuxInt%4 == 0: + sz = 4 + mov = mips.AMOVW + case v.AuxInt%2 == 0: + sz = 2 + mov = mips.AMOVH + default: + sz = 1 + mov = mips.AMOVB + } + p := s.Prog(mips.ASUBVU) + p.From.Type = obj.TYPE_CONST + p.From.Offset = sz + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + p2 := s.Prog(mov) + p2.From.Type = obj.TYPE_MEM + p2.From.Reg = mips.REG_R1 + p2.From.Offset = sz + p2.To.Type = obj.TYPE_REG + p2.To.Reg = mips.REGTMP + p3 := s.Prog(mov) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = mips.REGTMP + p3.To.Type = obj.TYPE_MEM + p3.To.Reg = mips.REG_R2 + p4 := s.Prog(mips.AADDVU) + p4.From.Type = obj.TYPE_CONST + p4.From.Offset = sz + p4.To.Type = obj.TYPE_REG + p4.To.Reg = mips.REG_R1 + p5 := s.Prog(mips.AADDVU) + p5.From.Type = obj.TYPE_CONST + p5.From.Offset = sz + p5.To.Type = obj.TYPE_REG + p5.To.Reg = mips.REG_R2 + p6 := s.Prog(mips.ABNE) + p6.From.Type = obj.TYPE_REG + p6.From.Reg = v.Args[2].Reg() + p6.Reg = mips.REG_R1 + p6.To.Type = obj.TYPE_BRANCH + p6.To.SetTarget(p2) + case ssa.OpMIPS64CALLstatic, ssa.OpMIPS64CALLclosure, ssa.OpMIPS64CALLinter: + s.Call(v) + case ssa.OpMIPS64CALLtail: + s.TailCall(v) + case ssa.OpMIPS64LoweredWB: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + // AuxInt encodes how many buffer entries we need. + p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1] + + case ssa.OpMIPS64LoweredPanicBoundsRR, ssa.OpMIPS64LoweredPanicBoundsRC, ssa.OpMIPS64LoweredPanicBoundsCR, ssa.OpMIPS64LoweredPanicBoundsCC: + // Compute the constant we put in the PCData entry for this call. + code, signed := ssa.BoundsKind(v.AuxInt).Code() + xIsReg := false + yIsReg := false + xVal := 0 + yVal := 0 + switch v.Op { + case ssa.OpMIPS64LoweredPanicBoundsRR: + xIsReg = true + xVal = int(v.Args[0].Reg() - mips.REG_R1) + yIsReg = true + yVal = int(v.Args[1].Reg() - mips.REG_R1) + case ssa.OpMIPS64LoweredPanicBoundsRC: + xIsReg = true + xVal = int(v.Args[0].Reg() - mips.REG_R1) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + if yVal == xVal { + yVal = 1 + } + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(yVal) + } + case ssa.OpMIPS64LoweredPanicBoundsCR: + yIsReg = true + yVal = int(v.Args[0].Reg() - mips.REG_R1) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + xIsReg = true + if xVal == yVal { + xVal = 1 + } + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(xVal) + } + case ssa.OpMIPS64LoweredPanicBoundsCC: + c := v.Aux.(ssa.PanicBoundsCC).Cx + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + xIsReg = true + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(xVal) + } + c = v.Aux.(ssa.PanicBoundsCC).Cy + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + yVal = 1 + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REG_R1 + int16(yVal) + } + } + c := abi.BoundsEncode(code, signed, xIsReg, yIsReg, xVal, yVal) + + p := s.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_PanicBounds) + p.To.SetConst(int64(c)) + p = s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.PanicBounds + + case ssa.OpMIPS64LoweredAtomicLoad8, ssa.OpMIPS64LoweredAtomicLoad32, ssa.OpMIPS64LoweredAtomicLoad64: + as := mips.AMOVV + switch v.Op { + case ssa.OpMIPS64LoweredAtomicLoad8: + as = mips.AMOVB + case ssa.OpMIPS64LoweredAtomicLoad32: + as = mips.AMOVW + } + s.Prog(mips.ASYNC) + p := s.Prog(as) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + s.Prog(mips.ASYNC) + case ssa.OpMIPS64LoweredAtomicStore8, ssa.OpMIPS64LoweredAtomicStore32, ssa.OpMIPS64LoweredAtomicStore64: + as := mips.AMOVV + switch v.Op { + case ssa.OpMIPS64LoweredAtomicStore8: + as = mips.AMOVB + case ssa.OpMIPS64LoweredAtomicStore32: + as = mips.AMOVW + } + s.Prog(mips.ASYNC) + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + s.Prog(mips.ASYNC) + case ssa.OpMIPS64LoweredAtomicStorezero32, ssa.OpMIPS64LoweredAtomicStorezero64: + as := mips.AMOVV + if v.Op == ssa.OpMIPS64LoweredAtomicStorezero32 { + as = mips.AMOVW + } + s.Prog(mips.ASYNC) + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGZERO + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + s.Prog(mips.ASYNC) + case ssa.OpMIPS64LoweredAtomicExchange32, ssa.OpMIPS64LoweredAtomicExchange64: + // SYNC + // MOVV Rarg1, Rtmp + // LL (Rarg0), Rout + // SC Rtmp, (Rarg0) + // BEQ Rtmp, -3(PC) + // SYNC + ll := mips.ALLV + sc := mips.ASCV + if v.Op == ssa.OpMIPS64LoweredAtomicExchange32 { + ll = mips.ALL + sc = mips.ASC + } + s.Prog(mips.ASYNC) + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REGTMP + p1 := s.Prog(ll) + p1.From.Type = obj.TYPE_MEM + p1.From.Reg = v.Args[0].Reg() + p1.To.Type = obj.TYPE_REG + p1.To.Reg = v.Reg0() + p2 := s.Prog(sc) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = mips.REGTMP + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = v.Args[0].Reg() + p3 := s.Prog(mips.ABEQ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = mips.REGTMP + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + s.Prog(mips.ASYNC) + case ssa.OpMIPS64LoweredAtomicAdd32, ssa.OpMIPS64LoweredAtomicAdd64: + // SYNC + // LL (Rarg0), Rout + // ADDV Rarg1, Rout, Rtmp + // SC Rtmp, (Rarg0) + // BEQ Rtmp, -3(PC) + // SYNC + // ADDV Rarg1, Rout + ll := mips.ALLV + sc := mips.ASCV + if v.Op == ssa.OpMIPS64LoweredAtomicAdd32 { + ll = mips.ALL + sc = mips.ASC + } + s.Prog(mips.ASYNC) + p := s.Prog(ll) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + p1 := s.Prog(mips.AADDVU) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = v.Args[1].Reg() + p1.Reg = v.Reg0() + p1.To.Type = obj.TYPE_REG + p1.To.Reg = mips.REGTMP + p2 := s.Prog(sc) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = mips.REGTMP + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = v.Args[0].Reg() + p3 := s.Prog(mips.ABEQ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = mips.REGTMP + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + s.Prog(mips.ASYNC) + p4 := s.Prog(mips.AADDVU) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = v.Args[1].Reg() + p4.Reg = v.Reg0() + p4.To.Type = obj.TYPE_REG + p4.To.Reg = v.Reg0() + case ssa.OpMIPS64LoweredAtomicAddconst32, ssa.OpMIPS64LoweredAtomicAddconst64: + // SYNC + // LL (Rarg0), Rout + // ADDV $auxint, Rout, Rtmp + // SC Rtmp, (Rarg0) + // BEQ Rtmp, -3(PC) + // SYNC + // ADDV $auxint, Rout + ll := mips.ALLV + sc := mips.ASCV + if v.Op == ssa.OpMIPS64LoweredAtomicAddconst32 { + ll = mips.ALL + sc = mips.ASC + } + s.Prog(mips.ASYNC) + p := s.Prog(ll) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + p1 := s.Prog(mips.AADDVU) + p1.From.Type = obj.TYPE_CONST + p1.From.Offset = v.AuxInt + p1.Reg = v.Reg0() + p1.To.Type = obj.TYPE_REG + p1.To.Reg = mips.REGTMP + p2 := s.Prog(sc) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = mips.REGTMP + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = v.Args[0].Reg() + p3 := s.Prog(mips.ABEQ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = mips.REGTMP + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + s.Prog(mips.ASYNC) + p4 := s.Prog(mips.AADDVU) + p4.From.Type = obj.TYPE_CONST + p4.From.Offset = v.AuxInt + p4.Reg = v.Reg0() + p4.To.Type = obj.TYPE_REG + p4.To.Reg = v.Reg0() + case ssa.OpMIPS64LoweredAtomicAnd32, + ssa.OpMIPS64LoweredAtomicOr32: + // SYNC + // LL (Rarg0), Rtmp + // AND/OR Rarg1, Rtmp + // SC Rtmp, (Rarg0) + // BEQ Rtmp, -3(PC) + // SYNC + s.Prog(mips.ASYNC) + + p := s.Prog(mips.ALL) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REGTMP + + p1 := s.Prog(v.Op.Asm()) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = v.Args[1].Reg() + p1.Reg = mips.REGTMP + p1.To.Type = obj.TYPE_REG + p1.To.Reg = mips.REGTMP + + p2 := s.Prog(mips.ASC) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = mips.REGTMP + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = v.Args[0].Reg() + + p3 := s.Prog(mips.ABEQ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = mips.REGTMP + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + + s.Prog(mips.ASYNC) + + case ssa.OpMIPS64LoweredAtomicCas32, ssa.OpMIPS64LoweredAtomicCas64: + // MOVV $0, Rout + // SYNC + // LL (Rarg0), Rtmp + // BNE Rtmp, Rarg1, 4(PC) + // MOVV Rarg2, Rout + // SC Rout, (Rarg0) + // BEQ Rout, -4(PC) + // SYNC + ll := mips.ALLV + sc := mips.ASCV + if v.Op == ssa.OpMIPS64LoweredAtomicCas32 { + ll = mips.ALL + sc = mips.ASC + } + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + s.Prog(mips.ASYNC) + p1 := s.Prog(ll) + p1.From.Type = obj.TYPE_MEM + p1.From.Reg = v.Args[0].Reg() + p1.To.Type = obj.TYPE_REG + p1.To.Reg = mips.REGTMP + p2 := s.Prog(mips.ABNE) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = v.Args[1].Reg() + p2.Reg = mips.REGTMP + p2.To.Type = obj.TYPE_BRANCH + p3 := s.Prog(mips.AMOVV) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = v.Args[2].Reg() + p3.To.Type = obj.TYPE_REG + p3.To.Reg = v.Reg0() + p4 := s.Prog(sc) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = v.Reg0() + p4.To.Type = obj.TYPE_MEM + p4.To.Reg = v.Args[0].Reg() + p5 := s.Prog(mips.ABEQ) + p5.From.Type = obj.TYPE_REG + p5.From.Reg = v.Reg0() + p5.To.Type = obj.TYPE_BRANCH + p5.To.SetTarget(p1) + p6 := s.Prog(mips.ASYNC) + p2.To.SetTarget(p6) + case ssa.OpMIPS64LoweredNilCheck: + // Issue a load which will fault if arg is nil. + p := s.Prog(mips.AMOVB) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = mips.REGTMP + if logopt.Enabled() { + logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name) + } + if base.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers + base.WarnfAt(v.Pos, "generated nil check") + } + case ssa.OpMIPS64FPFlagTrue, + ssa.OpMIPS64FPFlagFalse: + // MOVV $0, r + // BFPF 2(PC) + // MOVV $1, r + branch := mips.ABFPF + if v.Op == ssa.OpMIPS64FPFlagFalse { + branch = mips.ABFPT + } + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_REG + p.From.Reg = mips.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + p2 := s.Prog(branch) + p2.To.Type = obj.TYPE_BRANCH + p3 := s.Prog(mips.AMOVV) + p3.From.Type = obj.TYPE_CONST + p3.From.Offset = 1 + p3.To.Type = obj.TYPE_REG + p3.To.Reg = v.Reg() + p4 := s.Prog(obj.ANOP) // not a machine instruction, for branch to land + p2.To.SetTarget(p4) + case ssa.OpMIPS64LoweredGetClosurePtr: + // Closure pointer is R22 (mips.REGCTXT). + ssagen.CheckLoweredGetClosurePtr(v) + case ssa.OpMIPS64LoweredGetCallerSP: + // caller's SP is FixedFrameSize below the address of the first arg + p := s.Prog(mips.AMOVV) + p.From.Type = obj.TYPE_ADDR + p.From.Offset = -base.Ctxt.Arch.FixedFrameSize + p.From.Name = obj.NAME_PARAM + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPS64LoweredGetCallerPC: + p := s.Prog(obj.AGETCALLERPC) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpMIPS64LoweredPubBarrier: + // SYNC + s.Prog(v.Op.Asm()) + case ssa.OpClobber, ssa.OpClobberReg: + // TODO: implement for clobberdead experiment. Nop is ok for now. + default: + v.Fatalf("genValue not implemented: %s", v.LongString()) + } +} + +var blockJump = map[ssa.BlockKind]struct { + asm, invasm obj.As +}{ + ssa.BlockMIPS64EQ: {mips.ABEQ, mips.ABNE}, + ssa.BlockMIPS64NE: {mips.ABNE, mips.ABEQ}, + ssa.BlockMIPS64LTZ: {mips.ABLTZ, mips.ABGEZ}, + ssa.BlockMIPS64GEZ: {mips.ABGEZ, mips.ABLTZ}, + ssa.BlockMIPS64LEZ: {mips.ABLEZ, mips.ABGTZ}, + ssa.BlockMIPS64GTZ: {mips.ABGTZ, mips.ABLEZ}, + ssa.BlockMIPS64FPT: {mips.ABFPT, mips.ABFPF}, + ssa.BlockMIPS64FPF: {mips.ABFPF, mips.ABFPT}, +} + +func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) { + switch b.Kind { + case ssa.BlockPlain, ssa.BlockDefer: + if b.Succs[0].Block() != next { + p := s.Prog(obj.AJMP) + p.To.Type = obj.TYPE_BRANCH + s.Branches = append(s.Branches, ssagen.Branch{P: p, B: b.Succs[0].Block()}) + } + case ssa.BlockExit, ssa.BlockRetJmp: + case ssa.BlockRet: + s.Prog(obj.ARET) + case ssa.BlockMIPS64EQ, ssa.BlockMIPS64NE, + ssa.BlockMIPS64LTZ, ssa.BlockMIPS64GEZ, + ssa.BlockMIPS64LEZ, ssa.BlockMIPS64GTZ, + ssa.BlockMIPS64FPT, ssa.BlockMIPS64FPF: + jmp := blockJump[b.Kind] + var p *obj.Prog + switch next { + case b.Succs[0].Block(): + p = s.Br(jmp.invasm, b.Succs[1].Block()) + case b.Succs[1].Block(): + p = s.Br(jmp.asm, b.Succs[0].Block()) + default: + if b.Likely != ssa.BranchUnlikely { + p = s.Br(jmp.asm, b.Succs[0].Block()) + s.Br(obj.AJMP, b.Succs[1].Block()) + } else { + p = s.Br(jmp.invasm, b.Succs[1].Block()) + s.Br(obj.AJMP, b.Succs[0].Block()) + } + } + if !b.Controls[0].Type.IsFlags() { + p.From.Type = obj.TYPE_REG + p.From.Reg = b.Controls[0].Reg() + } + default: + b.Fatalf("branch not implemented: %s", b.LongString()) + } +} diff --git a/go/src/cmd/compile/internal/noder/codes.go b/go/src/cmd/compile/internal/noder/codes.go new file mode 100644 index 0000000000000000000000000000000000000000..8bdbfc9a8800b8aa56a9abc3fc6936bdf55c8693 --- /dev/null +++ b/go/src/cmd/compile/internal/noder/codes.go @@ -0,0 +1,91 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import "internal/pkgbits" + +// A codeStmt distinguishes among statement encodings. +type codeStmt int + +func (c codeStmt) Marker() pkgbits.SyncMarker { return pkgbits.SyncStmt1 } +func (c codeStmt) Value() int { return int(c) } + +const ( + stmtEnd codeStmt = iota + stmtLabel + stmtBlock + stmtExpr + stmtSend + stmtAssign + stmtAssignOp + stmtIncDec + stmtBranch + stmtCall + stmtReturn + stmtIf + stmtFor + stmtSwitch + stmtSelect +) + +// A codeExpr distinguishes among expression encodings. +type codeExpr int + +func (c codeExpr) Marker() pkgbits.SyncMarker { return pkgbits.SyncExpr } +func (c codeExpr) Value() int { return int(c) } + +// TODO(mdempsky): Split expr into addr, for lvalues. +const ( + exprConst codeExpr = iota + exprLocal // local variable + exprGlobal // global variable or function + exprCompLit + exprFuncLit + exprFieldVal + exprMethodVal + exprMethodExpr + exprIndex + exprSlice + exprAssert + exprUnaryOp + exprBinaryOp + exprCall + exprConvert + exprNew + exprMake + exprSizeof + exprAlignof + exprOffsetof + exprZero + exprFuncInst + exprRecv + exprReshape + exprRuntimeBuiltin // a reference to a runtime function from transformed syntax. Followed by string name, e.g., "panicrangeexit" +) + +type codeAssign int + +func (c codeAssign) Marker() pkgbits.SyncMarker { return pkgbits.SyncAssign } +func (c codeAssign) Value() int { return int(c) } + +const ( + assignBlank codeAssign = iota + assignDef + assignExpr +) + +// A codeDecl distinguishes among declaration encodings. +type codeDecl int + +func (c codeDecl) Marker() pkgbits.SyncMarker { return pkgbits.SyncDecl } +func (c codeDecl) Value() int { return int(c) } + +const ( + declEnd codeDecl = iota + declFunc + declMethod + declVar + declOther +) diff --git a/go/src/cmd/compile/internal/noder/doc.go b/go/src/cmd/compile/internal/noder/doc.go new file mode 100644 index 0000000000000000000000000000000000000000..8eb67e92f0dcbf07b9aadcbd5d01c5cba3eb92ec --- /dev/null +++ b/go/src/cmd/compile/internal/noder/doc.go @@ -0,0 +1,273 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/* +The Unified IR (UIR) format is implicitly defined by the package noder. + +At the highest level, a package encoded in UIR follows the grammar +below. + + File = Header Payload fingerprint . + Header = version [ flags ] sectionEnds elementEnds . + + version = uint32 . // used for backward compatibility + flags = uint32 . // feature flags used across versions + sectionEnds = [10]uint32 . // defines section boundaries + elementEnds = []uint32 . // defines element boundaries + fingerprint = [8]byte . // sha256 fingerprint + +The payload is a series of sections. Each section has a kind which +determines its index in the series. + + SectionKind = Uint64 . + Payload = SectionString + SectionMeta + SectionPosBase + SectionPkg + SectionName + SectionType + SectionObj + SectionObjExt // TODO(markfreeman) Define. + SectionObjDict // TODO(markfreeman) Define. + SectionBody // TODO(markfreeman) Define. + . + +# Sections +A section is a series of elements of a type determined by the section's +kind. Go constructs are mapped onto one or more elements with possibly +different types; in that case, the elements are in different sections. + +Elements are accessed using an element index relative to the start of +the section. + + RelElemIdx = Uint64 . + +## String Section +String values are stored as elements in the string section. Elements +outside the string section access string values by reference. + + SectionString = { String } . + +Note that despite being an element, a string does not begin with a +reference table. + +## Meta Section +The meta section provides fundamental information for a package. It +contains exactly two elements — a public root and a private root. + + SectionMeta = PublicRoot + PrivateRoot // TODO(markfreeman): Define. + . + +The public root element identifies the package and provides references +for all exported objects it contains. + + PublicRoot = RefTable + [ Sync ] + PkgRef + [ HasInit ] + ObjectRefCount // TODO(markfreeman): Define. + { ObjectRef } // TODO(markfreeman): Define. + . + HasInit = Bool . // Whether the package uses any + // initialization functions. + +## PosBase Section +This section provides position information. It is a series of PosBase +elements. + + SectionPosBase = { PosBase } . + +A base is either a file base or line base (produced by a line +directive). Every base has a position, line, and column; these are +constant for file bases and hence not encoded. + + PosBase = RefTable + [ Sync ] + StringRef // the (absolute) file name for the base + Bool // true if a file base, else a line base + // The below is omitted for file bases. + [ Pos + Uint64 // line + Uint64 ] // column + . + +A source position Pos represents a file-absolute (line, column) pair +and a PosBase indicating the position Pos is relative to. Positions +without a PosBase have no line or column. + + Pos = [ Sync ] + Bool // true if the position has a base + // The below is omitted if the position has no base. + [ Ref[PosBase] + Uint64 // line + Uint64 ] // column + . + +## Package Section +The package section holds package information. It is a series of Pkg +elements. + + SectionPkg = { Pkg } . + +A Pkg element contains a (path, name) pair and a series of imported +packages. The below package paths have special meaning. + + +--------------+-----------------------------------+ + | package path | indicates | + +--------------+-----------------------------------+ + | "" | the current package | + | "builtin" | the fake builtin package | + | "unsafe" | the compiler-known unsafe package | + +--------------+-----------------------------------+ + + Pkg = RefTable + [ Sync ] + StringRef // path + // The below is omitted for the special package paths + // "builtin" and "unsafe". + [ StringRef // name + Imports ] + . + Imports = Uint64 // the number of declared imports + { PkgRef } // references to declared imports + . + +Note, a PkgRef is *not* equivalent to Ref[Pkg] due to an extra marker. + + PkgRef = [ Sync ] + Ref[Pkg] + . + +## Type Section +The type section is a series of type definition elements. + + SectionType = { TypeDef } . + +A type definition can be in one of several formats, which are identified +by their TypeSpec code. + + TypeDef = RefTable + [ Sync ] + [ Sync ] + Uint64 // denotes which TypeSpec to use + TypeSpec + . + + TypeSpec = TypeSpecBasic // TODO(markfreeman): Define. + | TypeSpecNamed // TODO(markfreeman): Define. + | TypeSpecPointer // TODO(markfreeman): Define. + | TypeSpecSlice // TODO(markfreeman): Define. + | TypeSpecArray // TODO(markfreeman): Define. + | TypeSpecChan // TODO(markfreeman): Define. + | TypeSpecMap // TODO(markfreeman): Define. + | TypeSpecSignature // TODO(markfreeman): Define. + | TypeSpecStruct // TODO(markfreeman): Define. + | TypeSpecInterface // TODO(markfreeman): Define. + | TypeSpecUnion // TODO(markfreeman): Define. + | TypeSpecTypeParam // TODO(markfreeman): Define. + . + +// TODO(markfreeman): Document the reader dictionary once we understand it more. +To use a type elsewhere, a TypeUse is encoded. + + TypeUse = [ Sync ] + Bool // whether it is a derived type + [ Uint64 ] // if derived, an index into the reader dictionary + [ Ref[TypeDef] ] // else, a reference to the type + . + +## Object Sections +Information about an object (e.g. variable, function, type name, etc.) +is split into multiple elements in different sections. Those elements +have the same section-relative element index. + +### Name Section +The name section holds a series of names. + + SectionName = { Name } . + +Names are elements holding qualified identifiers and type information +for objects. + + Name = RefTable + [ Sync ] + [ Sync ] + PkgRef // the object's package + StringRef // the object's package-local name + [ Sync ] + Uint64 // the object's type (e.g. Var, Func, etc.) + . + +### Definition Section +The definition section holds definitions for objects defined by the target +package; it does not contain definitions for imported objects. + + SectionObj = { ObjectDef } . + +Object definitions can be in one of several formats. To determine the correct +format, the name section must be referenced; it contains a code indicating +the object's type. + + ObjectDef = RefTable + [ Sync ] + ObjectSpec + . + + ObjectSpec = ObjectSpecConst // TODO(markfreeman) Define. + | ObjectSpecFunc // TODO(markfreeman) Define. + | ObjectSpecAlias // TODO(markfreeman) Define. + | ObjectSpecNamedType // TODO(markfreeman) Define. + | ObjectSpecVar // TODO(markfreeman) Define. + . + +To use an object definition elsewhere, an ObjectUse is encoded. + + ObjectUse = [ Sync ] + [ Bool ] + Ref[ObjectDef] + Uint64 // the number of type arguments + { TypeUse } // references to the type arguments + . + +# References +A reference table precedes every element. Each entry in the table +contains a (section, index) pair denoting the location of the +referenced element. + + RefTable = [ Sync ] + Uint64 // the number of table entries + { RefTableEntry } + . + RefTableEntry = [ Sync ] + SectionKind + RelElemIdx + . + +Elements encode references to other elements as an index in the +reference table — not the location of the referenced element directly. + + RefTableIdx = Uint64 . + +To do this, the Ref[T] primitive is used as below; note that this is +the same shape as provided by package pkgbits, just with new +interpretation applied. + + Ref[T] = [ Sync ] + RefTableIdx // the Uint64 + . + +# Primitives +Primitive encoding is handled separately by the pkgbits package. Check +there for definitions of the below productions. + + * Bool + * Int64 + * Uint64 + * String + * Ref[T] + * Sync +*/ + +package noder diff --git a/go/src/cmd/compile/internal/noder/export.go b/go/src/cmd/compile/internal/noder/export.go new file mode 100644 index 0000000000000000000000000000000000000000..e1f289b56f8c9c9174b4a71aa9c07a7c9fbb3a4a --- /dev/null +++ b/go/src/cmd/compile/internal/noder/export.go @@ -0,0 +1,30 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "bytes" + "fmt" + "io" + + "cmd/compile/internal/base" + "cmd/internal/bio" +) + +func WriteExports(out *bio.Writer) { + var data bytes.Buffer + + data.WriteByte('u') + writeUnifiedExport(&data) + + // The linker also looks for the $$ marker - use char after $$ to distinguish format. + out.WriteString("\n$$B\n") // indicate binary export format + io.Copy(out, &data) + out.WriteString("\n$$\n") + + if base.Debug.Export != 0 { + fmt.Printf("BenchmarkExportSize:%s 1 %d bytes\n", base.Ctxt.Pkgpath, data.Len()) + } +} diff --git a/go/src/cmd/compile/internal/noder/helpers.go b/go/src/cmd/compile/internal/noder/helpers.go new file mode 100644 index 0000000000000000000000000000000000000000..45512706d2c590478bb9e70a72a9a755465a3e21 --- /dev/null +++ b/go/src/cmd/compile/internal/noder/helpers.go @@ -0,0 +1,140 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "go/constant" + + "cmd/compile/internal/ir" + "cmd/compile/internal/syntax" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/compile/internal/types2" + "cmd/internal/src" +) + +// Helpers for constructing typed IR nodes. +// +// TODO(mdempsky): Move into their own package so they can be easily +// reused by iimport and frontend optimizations. + +type ImplicitNode interface { + ir.Node + SetImplicit(x bool) +} + +// Implicit returns n after marking it as Implicit. +func Implicit(n ImplicitNode) ImplicitNode { + n.SetImplicit(true) + return n +} + +// typed returns n after setting its type to typ. +func typed(typ *types.Type, n ir.Node) ir.Node { + n.SetType(typ) + n.SetTypecheck(1) + return n +} + +// Values + +// FixValue returns val after converting and truncating it as +// appropriate for typ. +func FixValue(typ *types.Type, val constant.Value) constant.Value { + assert(typ.Kind() != types.TFORW) + switch { + case typ.IsInteger(): + val = constant.ToInt(val) + case typ.IsFloat(): + val = constant.ToFloat(val) + case typ.IsComplex(): + val = constant.ToComplex(val) + } + if !typ.IsUntyped() { + val = typecheck.ConvertVal(val, typ, false) + } + ir.AssertValidTypeForConst(typ, val) + return val +} + +// Expressions + +func Addr(pos src.XPos, x ir.Node) *ir.AddrExpr { + n := typecheck.NodAddrAt(pos, x) + typed(types.NewPtr(x.Type()), n) + return n +} + +func Deref(pos src.XPos, typ *types.Type, x ir.Node) *ir.StarExpr { + n := ir.NewStarExpr(pos, x) + typed(typ, n) + return n +} + +// Statements + +func idealType(tv syntax.TypeAndValue) types2.Type { + // The gc backend expects all expressions to have a concrete type, and + // types2 mostly satisfies this expectation already. But there are a few + // cases where the Go spec doesn't require converting to concrete type, + // and so types2 leaves them untyped. So we need to fix those up here. + typ := types2.Unalias(tv.Type) + if basic, ok := typ.(*types2.Basic); ok && basic.Info()&types2.IsUntyped != 0 { + switch basic.Kind() { + case types2.UntypedNil: + // ok; can appear in type switch case clauses + // TODO(mdempsky): Handle as part of type switches instead? + case types2.UntypedInt, types2.UntypedFloat, types2.UntypedComplex: + typ = types2.Typ[types2.Uint] + if tv.Value != nil { + s := constant.ToInt(tv.Value) + assert(s.Kind() == constant.Int) + if constant.Sign(s) < 0 { + typ = types2.Typ[types2.Int] + } + } + case types2.UntypedBool: + typ = types2.Typ[types2.Bool] // expression in "if" or "for" condition + case types2.UntypedString: + typ = types2.Typ[types2.String] // argument to "append" or "copy" calls + case types2.UntypedRune: + typ = types2.Typ[types2.Int32] // range over rune + default: + return nil + } + } + return typ +} + +func isTypeParam(t types2.Type) bool { + _, ok := types2.Unalias(t).(*types2.TypeParam) + return ok +} + +// isNotInHeap reports whether typ is or contains an element of type +// internal/runtime/sys.NotInHeap. +func isNotInHeap(typ types2.Type) bool { + typ = types2.Unalias(typ) + if named, ok := typ.(*types2.Named); ok { + if obj := named.Obj(); obj.Name() == "nih" && obj.Pkg().Path() == "internal/runtime/sys" { + return true + } + typ = named.Underlying() + } + + switch typ := typ.(type) { + case *types2.Array: + return isNotInHeap(typ.Elem()) + case *types2.Struct: + for i := 0; i < typ.NumFields(); i++ { + if isNotInHeap(typ.Field(i).Type()) { + return true + } + } + return false + default: + return false + } +} diff --git a/go/src/cmd/compile/internal/noder/import.go b/go/src/cmd/compile/internal/noder/import.go new file mode 100644 index 0000000000000000000000000000000000000000..910988f0612ca99ed1b5ba26f09d7957e54b51f3 --- /dev/null +++ b/go/src/cmd/compile/internal/noder/import.go @@ -0,0 +1,330 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "errors" + "fmt" + "internal/buildcfg" + "internal/exportdata" + "internal/pkgbits" + "os" + pathpkg "path" + "runtime" + "strings" + "unicode" + "unicode/utf8" + + "cmd/compile/internal/base" + "cmd/compile/internal/importer" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/compile/internal/types2" + "cmd/internal/bio" + "cmd/internal/goobj" + "cmd/internal/objabi" +) + +type gcimports struct { + ctxt *types2.Context + packages map[string]*types2.Package +} + +func (m *gcimports) Import(path string) (*types2.Package, error) { + return m.ImportFrom(path, "" /* no vendoring */, 0) +} + +func (m *gcimports) ImportFrom(path, srcDir string, mode types2.ImportMode) (*types2.Package, error) { + if mode != 0 { + panic("mode must be 0") + } + + _, pkg, err := readImportFile(path, typecheck.Target, m.ctxt, m.packages) + return pkg, err +} + +func isDriveLetter(b byte) bool { + return 'a' <= b && b <= 'z' || 'A' <= b && b <= 'Z' +} + +// is this path a local name? begins with ./ or ../ or / +func islocalname(name string) bool { + return strings.HasPrefix(name, "/") || + runtime.GOOS == "windows" && len(name) >= 3 && isDriveLetter(name[0]) && name[1] == ':' && name[2] == '/' || + strings.HasPrefix(name, "./") || name == "." || + strings.HasPrefix(name, "../") || name == ".." +} + +func openPackage(path string) (*os.File, error) { + if islocalname(path) { + if base.Flag.NoLocalImports { + return nil, errors.New("local imports disallowed") + } + + if base.Flag.Cfg.PackageFile != nil { + return os.Open(base.Flag.Cfg.PackageFile[path]) + } + + // try .a before .o. important for building libraries: + // if there is an array.o in the array.a library, + // want to find all of array.a, not just array.o. + if file, err := os.Open(fmt.Sprintf("%s.a", path)); err == nil { + return file, nil + } + if file, err := os.Open(fmt.Sprintf("%s.o", path)); err == nil { + return file, nil + } + return nil, errors.New("file not found") + } + + // local imports should be canonicalized already. + // don't want to see "encoding/../encoding/base64" + // as different from "encoding/base64". + if q := pathpkg.Clean(path); q != path { + return nil, fmt.Errorf("non-canonical import path %q (should be %q)", path, q) + } + + if base.Flag.Cfg.PackageFile != nil { + return os.Open(base.Flag.Cfg.PackageFile[path]) + } + + for _, dir := range base.Flag.Cfg.ImportDirs { + if file, err := os.Open(fmt.Sprintf("%s/%s.a", dir, path)); err == nil { + return file, nil + } + if file, err := os.Open(fmt.Sprintf("%s/%s.o", dir, path)); err == nil { + return file, nil + } + } + + if buildcfg.GOROOT != "" { + suffix := "" + if base.Flag.InstallSuffix != "" { + suffix = "_" + base.Flag.InstallSuffix + } else if base.Flag.Race { + suffix = "_race" + } else if base.Flag.MSan { + suffix = "_msan" + } else if base.Flag.ASan { + suffix = "_asan" + } + + if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.a", buildcfg.GOROOT, buildcfg.GOOS, buildcfg.GOARCH, suffix, path)); err == nil { + return file, nil + } + if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.o", buildcfg.GOROOT, buildcfg.GOOS, buildcfg.GOARCH, suffix, path)); err == nil { + return file, nil + } + } + return nil, errors.New("file not found") +} + +// resolveImportPath resolves an import path as it appears in a Go +// source file to the package's full path. +func resolveImportPath(path string) (string, error) { + // The package name main is no longer reserved, + // but we reserve the import path "main" to identify + // the main package, just as we reserve the import + // path "math" to identify the standard math package. + if path == "main" { + return "", errors.New("cannot import \"main\"") + } + + if base.Ctxt.Pkgpath == "" { + panic("missing pkgpath") + } + if path == base.Ctxt.Pkgpath { + return "", fmt.Errorf("import %q while compiling that package (import cycle)", path) + } + + if mapped, ok := base.Flag.Cfg.ImportMap[path]; ok { + path = mapped + } + + if islocalname(path) { + if path[0] == '/' { + return "", errors.New("import path cannot be absolute path") + } + + prefix := base.Flag.D + if prefix == "" { + // Questionable, but when -D isn't specified, historically we + // resolve local import paths relative to the directory the + // compiler's current directory, not the respective source + // file's directory. + prefix = base.Ctxt.Pathname + } + path = pathpkg.Join(prefix, path) + + if err := checkImportPath(path, true); err != nil { + return "", err + } + } + + return path, nil +} + +// readImportFile reads the import file for the given package path and +// returns its types.Pkg representation. If packages is non-nil, the +// types2.Package representation is also returned. +func readImportFile(path string, target *ir.Package, env *types2.Context, packages map[string]*types2.Package) (pkg1 *types.Pkg, pkg2 *types2.Package, err error) { + path, err = resolveImportPath(path) + if err != nil { + return + } + + if path == "unsafe" { + pkg1, pkg2 = types.UnsafePkg, types2.Unsafe + + // TODO(mdempsky): Investigate if this actually matters. Why would + // the linker or runtime care whether a package imported unsafe? + if !pkg1.Direct { + pkg1.Direct = true + target.Imports = append(target.Imports, pkg1) + } + + return + } + + pkg1 = types.NewPkg(path, "") + if packages != nil { + pkg2 = packages[path] + assert(pkg1.Direct == (pkg2 != nil && pkg2.Complete())) + } + + if pkg1.Direct { + return + } + pkg1.Direct = true + target.Imports = append(target.Imports, pkg1) + + f, err := openPackage(path) + if err != nil { + return + } + defer f.Close() + + data, err := readExportData(f) + if err != nil { + return + } + + if base.Debug.Export != 0 { + fmt.Printf("importing %s (%s)\n", path, f.Name()) + } + + pr := pkgbits.NewPkgDecoder(pkg1.Path, data) + + // Read package descriptors for both types2 and compiler backend. + readPackage(newPkgReader(pr), pkg1, false) + pkg2 = importer.ReadPackage(env, packages, pr) + + err = addFingerprint(path, data) + return +} + +// readExportData returns the contents of GC-created unified export data. +func readExportData(f *os.File) (data string, err error) { + r := bio.NewReader(f) + + sz, err := exportdata.FindPackageDefinition(r.Reader) + if err != nil { + return + } + end := r.Offset() + int64(sz) + + abihdr, _, err := exportdata.ReadObjectHeaders(r.Reader) + if err != nil { + return + } + + if expect := objabi.HeaderString(); abihdr != expect { + err = fmt.Errorf("object is [%s] expected [%s]", abihdr, expect) + return + } + + _, err = exportdata.ReadExportDataHeader(r.Reader) + if err != nil { + return + } + + pos := r.Offset() + + // Map export data section (+ end-of-section marker) into memory + // as a single large string. This reduces heap fragmentation and + // allows returning individual substrings very efficiently. + var mapped string + mapped, err = base.MapFile(r.File(), pos, end-pos) + if err != nil { + return + } + + // check for end-of-section marker "\n$$\n" and remove it + const marker = "\n$$\n" + + var ok bool + data, ok = strings.CutSuffix(mapped, marker) + if !ok { + cutoff := data // include last 10 bytes in error message + if len(cutoff) >= 10 { + cutoff = cutoff[len(cutoff)-10:] + } + err = fmt.Errorf("expected $$ marker, but found %q (recompile package)", cutoff) + return + } + + return +} + +// addFingerprint reads the linker fingerprint included at the end of +// the exportdata. +func addFingerprint(path string, data string) error { + var fingerprint goobj.FingerprintType + + pos := len(data) - len(fingerprint) + if pos < 0 { + return fmt.Errorf("missing linker fingerprint in exportdata, but found %q", data) + } + buf := []byte(data[pos:]) + + copy(fingerprint[:], buf) + base.Ctxt.AddImport(path, fingerprint) + + return nil +} + +func checkImportPath(path string, allowSpace bool) error { + if path == "" { + return errors.New("import path is empty") + } + + if strings.Contains(path, "\x00") { + return errors.New("import path contains NUL") + } + + for ri := range base.ReservedImports { + if path == ri { + return fmt.Errorf("import path %q is reserved and cannot be used", path) + } + } + + for _, r := range path { + switch { + case r == utf8.RuneError: + return fmt.Errorf("import path contains invalid UTF-8 sequence: %q", path) + case r < 0x20 || r == 0x7f: + return fmt.Errorf("import path contains control character: %q", path) + case r == '\\': + return fmt.Errorf("import path contains backslash; use slash: %q", path) + case !allowSpace && unicode.IsSpace(r): + return fmt.Errorf("import path contains space character: %q", path) + case strings.ContainsRune("!\"#$%&'()*,:;<=>?[]^`{|}", r): + return fmt.Errorf("import path contains invalid character '%c': %q", r, path) + } + } + + return nil +} diff --git a/go/src/cmd/compile/internal/noder/irgen.go b/go/src/cmd/compile/internal/noder/irgen.go new file mode 100644 index 0000000000000000000000000000000000000000..05f0affe8a8a4320129dfe1fe227535b35b75234 --- /dev/null +++ b/go/src/cmd/compile/internal/noder/irgen.go @@ -0,0 +1,273 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "fmt" + "internal/buildcfg" + "internal/types/errors" + "regexp" + "sort" + + "cmd/compile/internal/base" + "cmd/compile/internal/rangefunc" + "cmd/compile/internal/syntax" + "cmd/compile/internal/types2" + "cmd/internal/src" +) + +var versionErrorRx = regexp.MustCompile(`requires go[0-9]+\.[0-9]+ or later`) + +// checkFiles configures and runs the types2 checker on the given +// parsed source files and then returns the result. +// The map result value indicates which closures are generated from the bodies of range function loops. +func checkFiles(m posMap, noders []*noder) (*types2.Package, *types2.Info, map[*syntax.FuncLit]bool) { + if base.SyntaxErrors() != 0 { + base.ErrorExit() + } + + // setup and syntax error reporting + files := make([]*syntax.File, len(noders)) + // fileBaseMap maps all file pos bases back to *syntax.File + // for checking Go version mismatched. + fileBaseMap := make(map[*syntax.PosBase]*syntax.File) + for i, p := range noders { + files[i] = p.file + // The file.Pos() is the position of the package clause. + // If there's a //line directive before that, file.Pos().Base() + // refers to that directive, not the file itself. + // Make sure to consistently map back to file base, here and + // when we look for a file in the conf.Error handler below, + // otherwise the file may not be found (was go.dev/issue/67141). + fileBaseMap[p.file.Pos().FileBase()] = p.file + } + + // typechecking + ctxt := types2.NewContext() + importer := gcimports{ + ctxt: ctxt, + packages: make(map[string]*types2.Package), + } + conf := types2.Config{ + Context: ctxt, + GoVersion: base.Flag.Lang, + IgnoreBranchErrors: true, // parser already checked via syntax.CheckBranches mode + Importer: &importer, + Sizes: types2.SizesFor("gc", buildcfg.GOARCH), + EnableAlias: true, + } + if base.Flag.ErrorURL { + conf.ErrorURL = " [go.dev/e/%s]" + } + info := &types2.Info{ + StoreTypesInSyntax: true, + Defs: make(map[*syntax.Name]types2.Object), + Uses: make(map[*syntax.Name]types2.Object), + Selections: make(map[*syntax.SelectorExpr]*types2.Selection), + Implicits: make(map[syntax.Node]types2.Object), + Scopes: make(map[syntax.Node]*types2.Scope), + Instances: make(map[*syntax.Name]types2.Instance), + FileVersions: make(map[*syntax.PosBase]string), + // expand as needed + } + conf.Error = func(err error) { + terr := err.(types2.Error) + msg := terr.Msg + if versionErrorRx.MatchString(msg) { + fileBase := terr.Pos.FileBase() + fileVersion := info.FileVersions[fileBase] + file := fileBaseMap[fileBase] + if file == nil { + // This should never happen, but be careful and don't crash. + } else if file.GoVersion == fileVersion { + // If we have a version error caused by //go:build, report it. + msg = fmt.Sprintf("%s (file declares //go:build %s)", msg, fileVersion) + } else { + // Otherwise, hint at the -lang setting. + msg = fmt.Sprintf("%s (-lang was set to %s; check go.mod)", msg, base.Flag.Lang) + } + } + base.ErrorfAt(m.makeXPos(terr.Pos), terr.Code, "%s", msg) + } + + pkg, err := conf.Check(base.Ctxt.Pkgpath, files, info) + base.ExitIfErrors() + if err != nil { + base.FatalfAt(src.NoXPos, "conf.Check error: %v", err) + } + + // Check for anonymous interface cycles (#56103). + // TODO(gri) move this code into the type checkers (types2 and go/types) + var f cycleFinder + for _, file := range files { + syntax.Inspect(file, func(n syntax.Node) bool { + if n, ok := n.(*syntax.InterfaceType); ok { + if f.hasCycle(types2.Unalias(n.GetTypeInfo().Type).(*types2.Interface)) { + base.ErrorfAt(m.makeXPos(n.Pos()), errors.InvalidTypeCycle, "invalid recursive type: anonymous interface refers to itself (see https://go.dev/issue/56103)") + + for typ := range f.cyclic { + f.cyclic[typ] = false // suppress duplicate errors + } + } + return false + } + return true + }) + } + base.ExitIfErrors() + + // Implementation restriction: we don't allow not-in-heap types to + // be used as type arguments (#54765). + { + type nihTarg struct { + pos src.XPos + typ types2.Type + } + var nihTargs []nihTarg + + for name, inst := range info.Instances { + for i := 0; i < inst.TypeArgs.Len(); i++ { + if targ := inst.TypeArgs.At(i); isNotInHeap(targ) { + nihTargs = append(nihTargs, nihTarg{m.makeXPos(name.Pos()), targ}) + } + } + } + sort.Slice(nihTargs, func(i, j int) bool { + ti, tj := nihTargs[i], nihTargs[j] + return ti.pos.Before(tj.pos) + }) + for _, targ := range nihTargs { + base.ErrorfAt(targ.pos, 0, "cannot use incomplete (or unallocatable) type as a type argument: %v", targ.typ) + } + } + base.ExitIfErrors() + + // Implementation restriction: we don't allow not-in-heap types to + // be used as map keys/values, or channel. + { + for _, file := range files { + syntax.Inspect(file, func(n syntax.Node) bool { + if n, ok := n.(*syntax.TypeDecl); ok { + switch n := n.Type.(type) { + case *syntax.MapType: + typ := n.GetTypeInfo().Type.Underlying().(*types2.Map) + if isNotInHeap(typ.Key()) { + base.ErrorfAt(m.makeXPos(n.Pos()), 0, "incomplete (or unallocatable) map key not allowed") + } + if isNotInHeap(typ.Elem()) { + base.ErrorfAt(m.makeXPos(n.Pos()), 0, "incomplete (or unallocatable) map value not allowed") + } + case *syntax.ChanType: + typ := n.GetTypeInfo().Type.Underlying().(*types2.Chan) + if isNotInHeap(typ.Elem()) { + base.ErrorfAt(m.makeXPos(n.Pos()), 0, "chan of incomplete (or unallocatable) type not allowed") + } + } + } + return true + }) + } + } + base.ExitIfErrors() + + // Rewrite range over function to explicit function calls + // with the loop bodies converted into new implicit closures. + // We do this now, before serialization to unified IR, so that if the + // implicit closures are inlined, we will have the unified IR form. + // If we do the rewrite in the back end, like between typecheck and walk, + // then the new implicit closure will not have a unified IR inline body, + // and bodyReaderFor will fail. + rangeInfo := rangefunc.Rewrite(pkg, info, files) + + return pkg, info, rangeInfo +} + +// A cycleFinder detects anonymous interface cycles (go.dev/issue/56103). +type cycleFinder struct { + cyclic map[*types2.Interface]bool +} + +// hasCycle reports whether typ is part of an anonymous interface cycle. +func (f *cycleFinder) hasCycle(typ *types2.Interface) bool { + // We use Method instead of ExplicitMethod to implicitly expand any + // embedded interfaces. Then we just need to walk any anonymous + // types, keeping track of *types2.Interface types we visit along + // the way. + for i := 0; i < typ.NumMethods(); i++ { + if f.visit(typ.Method(i).Type()) { + return true + } + } + return false +} + +// visit recursively walks typ0 to check any referenced interface types. +func (f *cycleFinder) visit(typ0 types2.Type) bool { + for { // loop for tail recursion + switch typ := types2.Unalias(typ0).(type) { + default: + base.Fatalf("unexpected type: %T", typ) + + case *types2.Basic, *types2.Named, *types2.TypeParam: + return false // named types cannot be part of an anonymous cycle + case *types2.Pointer: + typ0 = typ.Elem() + case *types2.Array: + typ0 = typ.Elem() + case *types2.Chan: + typ0 = typ.Elem() + case *types2.Map: + if f.visit(typ.Key()) { + return true + } + typ0 = typ.Elem() + case *types2.Slice: + typ0 = typ.Elem() + + case *types2.Struct: + for i := 0; i < typ.NumFields(); i++ { + if f.visit(typ.Field(i).Type()) { + return true + } + } + return false + + case *types2.Interface: + // The empty interface (e.g., "any") cannot be part of a cycle. + if typ.NumExplicitMethods() == 0 && typ.NumEmbeddeds() == 0 { + return false + } + + // As an optimization, we wait to allocate cyclic here, after + // we've found at least one other (non-empty) anonymous + // interface. This means when a cycle is present, we need to + // make an extra recursive call to actually detect it. But for + // most packages, it allows skipping the map allocation + // entirely. + if x, ok := f.cyclic[typ]; ok { + return x + } + if f.cyclic == nil { + f.cyclic = make(map[*types2.Interface]bool) + } + f.cyclic[typ] = true + if f.hasCycle(typ) { + return true + } + f.cyclic[typ] = false + return false + + case *types2.Signature: + return f.visit(typ.Params()) || f.visit(typ.Results()) + case *types2.Tuple: + for i := 0; i < typ.Len(); i++ { + if f.visit(typ.At(i).Type()) { + return true + } + } + return false + } + } +} diff --git a/go/src/cmd/compile/internal/noder/lex.go b/go/src/cmd/compile/internal/noder/lex.go new file mode 100644 index 0000000000000000000000000000000000000000..c964eca678416c8d440c14af47b3a8b4a9968865 --- /dev/null +++ b/go/src/cmd/compile/internal/noder/lex.go @@ -0,0 +1,184 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "fmt" + "internal/buildcfg" + "strings" + + "cmd/compile/internal/ir" + "cmd/compile/internal/syntax" +) + +func isSpace(c rune) bool { + return c == ' ' || c == '\t' || c == '\n' || c == '\r' +} + +func isQuoted(s string) bool { + return len(s) >= 2 && s[0] == '"' && s[len(s)-1] == '"' +} + +const ( + funcPragmas = ir.Nointerface | + ir.Noescape | + ir.Norace | + ir.Nosplit | + ir.Noinline | + ir.NoCheckPtr | + ir.RegisterParams | // TODO(register args) remove after register abi is working + ir.CgoUnsafeArgs | + ir.UintptrKeepAlive | + ir.UintptrEscapes | + ir.Systemstack | + ir.Nowritebarrier | + ir.Nowritebarrierrec | + ir.Yeswritebarrierrec +) + +func pragmaFlag(verb string) ir.PragmaFlag { + switch verb { + case "go:build": + return ir.GoBuildPragma + case "go:nointerface": + if buildcfg.Experiment.FieldTrack { + return ir.Nointerface + } + case "go:noescape": + return ir.Noescape + case "go:norace": + return ir.Norace + case "go:nosplit": + return ir.Nosplit | ir.NoCheckPtr // implies NoCheckPtr (see #34972) + case "go:noinline": + return ir.Noinline + case "go:nocheckptr": + return ir.NoCheckPtr + case "go:systemstack": + return ir.Systemstack + case "go:nowritebarrier": + return ir.Nowritebarrier + case "go:nowritebarrierrec": + return ir.Nowritebarrierrec | ir.Nowritebarrier // implies Nowritebarrier + case "go:yeswritebarrierrec": + return ir.Yeswritebarrierrec + case "go:cgo_unsafe_args": + return ir.CgoUnsafeArgs | ir.NoCheckPtr // implies NoCheckPtr (see #34968) + case "go:uintptrkeepalive": + return ir.UintptrKeepAlive + case "go:uintptrescapes": + // This directive extends //go:uintptrkeepalive by forcing + // uintptr arguments to escape to the heap, which makes stack + // growth safe. + return ir.UintptrEscapes | ir.UintptrKeepAlive // implies UintptrKeepAlive + case "go:registerparams": // TODO(register args) remove after register abi is working + return ir.RegisterParams + } + return 0 +} + +// pragcgo is called concurrently if files are parsed concurrently. +func (p *noder) pragcgo(pos syntax.Pos, text string) { + f := pragmaFields(text) + + verb := strings.TrimPrefix(f[0], "go:") + f[0] = verb + + switch verb { + case "cgo_export_static", "cgo_export_dynamic": + switch { + case len(f) == 2 && !isQuoted(f[1]): + case len(f) == 3 && !isQuoted(f[1]) && !isQuoted(f[2]): + default: + p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf(`usage: //go:%s local [remote]`, verb)}) + return + } + case "cgo_import_dynamic": + switch { + case len(f) == 2 && !isQuoted(f[1]): + case len(f) == 3 && !isQuoted(f[1]) && !isQuoted(f[2]): + case len(f) == 4 && !isQuoted(f[1]) && !isQuoted(f[2]) && isQuoted(f[3]): + f[3] = strings.Trim(f[3], `"`) + if buildcfg.GOOS == "aix" && f[3] != "" { + // On Aix, library pattern must be "lib.a/object.o" + // or "lib.a/libname.so.X" + n := strings.Split(f[3], "/") + if len(n) != 2 || !strings.HasSuffix(n[0], ".a") || (!strings.HasSuffix(n[1], ".o") && !strings.Contains(n[1], ".so.")) { + p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_import_dynamic local [remote ["lib.a/object.o"]]`}) + return + } + } + default: + p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_import_dynamic local [remote ["library"]]`}) + return + } + case "cgo_import_static": + switch { + case len(f) == 2 && !isQuoted(f[1]): + default: + p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_import_static local`}) + return + } + case "cgo_dynamic_linker": + switch { + case len(f) == 2 && isQuoted(f[1]): + f[1] = strings.Trim(f[1], `"`) + default: + p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_dynamic_linker "path"`}) + return + } + case "cgo_ldflag": + switch { + case len(f) == 2 && isQuoted(f[1]): + f[1] = strings.Trim(f[1], `"`) + default: + p.error(syntax.Error{Pos: pos, Msg: `usage: //go:cgo_ldflag "arg"`}) + return + } + default: + return + } + p.pragcgobuf = append(p.pragcgobuf, f) +} + +// pragmaFields is similar to strings.FieldsFunc(s, isSpace) +// but does not split when inside double quoted regions and always +// splits before the start and after the end of a double quoted region. +// pragmaFields does not recognize escaped quotes. If a quote in s is not +// closed the part after the opening quote will not be returned as a field. +func pragmaFields(s string) []string { + var a []string + inQuote := false + fieldStart := -1 // Set to -1 when looking for start of field. + for i, c := range s { + switch { + case c == '"': + if inQuote { + inQuote = false + a = append(a, s[fieldStart:i+1]) + fieldStart = -1 + } else { + inQuote = true + if fieldStart >= 0 { + a = append(a, s[fieldStart:i]) + } + fieldStart = i + } + case !inQuote && isSpace(c): + if fieldStart >= 0 { + a = append(a, s[fieldStart:i]) + fieldStart = -1 + } + default: + if fieldStart == -1 { + fieldStart = i + } + } + } + if !inQuote && fieldStart >= 0 { // Last field might end at the end of the string. + a = append(a, s[fieldStart:]) + } + return a +} diff --git a/go/src/cmd/compile/internal/noder/lex_test.go b/go/src/cmd/compile/internal/noder/lex_test.go new file mode 100644 index 0000000000000000000000000000000000000000..85a3f06759ad7b477b111db6b0c4ad1ab71b615d --- /dev/null +++ b/go/src/cmd/compile/internal/noder/lex_test.go @@ -0,0 +1,122 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "reflect" + "runtime" + "testing" + + "cmd/compile/internal/syntax" +) + +func eq(a, b []string) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + return true +} + +func TestPragmaFields(t *testing.T) { + var tests = []struct { + in string + want []string + }{ + {"", []string{}}, + {" \t ", []string{}}, + {`""""`, []string{`""`, `""`}}, + {" a'b'c ", []string{"a'b'c"}}, + {"1 2 3 4", []string{"1", "2", "3", "4"}}, + {"\n☺\t☹\n", []string{"☺", "☹"}}, + {`"1 2 " 3 " 4 5"`, []string{`"1 2 "`, `3`, `" 4 5"`}}, + {`"1""2 3""4"`, []string{`"1"`, `"2 3"`, `"4"`}}, + {`12"34"`, []string{`12`, `"34"`}}, + {`12"34 `, []string{`12`}}, + } + + for _, tt := range tests { + got := pragmaFields(tt.in) + if !eq(got, tt.want) { + t.Errorf("pragmaFields(%q) = %v; want %v", tt.in, got, tt.want) + continue + } + } +} + +func TestPragcgo(t *testing.T) { + type testStruct struct { + in string + want []string + } + + var tests = []testStruct{ + {`go:cgo_export_dynamic local`, []string{`cgo_export_dynamic`, `local`}}, + {`go:cgo_export_dynamic local remote`, []string{`cgo_export_dynamic`, `local`, `remote`}}, + {`go:cgo_export_dynamic local' remote'`, []string{`cgo_export_dynamic`, `local'`, `remote'`}}, + {`go:cgo_export_static local`, []string{`cgo_export_static`, `local`}}, + {`go:cgo_export_static local remote`, []string{`cgo_export_static`, `local`, `remote`}}, + {`go:cgo_export_static local' remote'`, []string{`cgo_export_static`, `local'`, `remote'`}}, + {`go:cgo_import_dynamic local`, []string{`cgo_import_dynamic`, `local`}}, + {`go:cgo_import_dynamic local remote`, []string{`cgo_import_dynamic`, `local`, `remote`}}, + {`go:cgo_import_static local`, []string{`cgo_import_static`, `local`}}, + {`go:cgo_import_static local'`, []string{`cgo_import_static`, `local'`}}, + {`go:cgo_dynamic_linker "/path/"`, []string{`cgo_dynamic_linker`, `/path/`}}, + {`go:cgo_dynamic_linker "/p ath/"`, []string{`cgo_dynamic_linker`, `/p ath/`}}, + {`go:cgo_ldflag "arg"`, []string{`cgo_ldflag`, `arg`}}, + {`go:cgo_ldflag "a rg"`, []string{`cgo_ldflag`, `a rg`}}, + } + + if runtime.GOOS != "aix" { + tests = append(tests, []testStruct{ + {`go:cgo_import_dynamic local remote "library"`, []string{`cgo_import_dynamic`, `local`, `remote`, `library`}}, + {`go:cgo_import_dynamic local' remote' "lib rary"`, []string{`cgo_import_dynamic`, `local'`, `remote'`, `lib rary`}}, + }...) + } else { + // cgo_import_dynamic with a library is slightly different on AIX + // as the library field must follow the pattern [libc.a/object.o]. + tests = append(tests, []testStruct{ + {`go:cgo_import_dynamic local remote "lib.a/obj.o"`, []string{`cgo_import_dynamic`, `local`, `remote`, `lib.a/obj.o`}}, + // This test must fail. + {`go:cgo_import_dynamic local' remote' "library"`, []string{`: usage: //go:cgo_import_dynamic local [remote ["lib.a/object.o"]]`}}, + }...) + + } + + var p noder + var nopos syntax.Pos + for _, tt := range tests { + + p.err = make(chan syntax.Error) + gotch := make(chan [][]string, 1) + go func() { + p.pragcgobuf = nil + p.pragcgo(nopos, tt.in) + if p.pragcgobuf != nil { + gotch <- p.pragcgobuf + } + }() + + select { + case e := <-p.err: + want := tt.want[0] + if e.Error() != want { + t.Errorf("pragcgo(%q) = %q; want %q", tt.in, e, want) + continue + } + case got := <-gotch: + want := [][]string{tt.want} + if !reflect.DeepEqual(got, want) { + t.Errorf("pragcgo(%q) = %q; want %q", tt.in, got, want) + continue + } + } + + } +} diff --git a/go/src/cmd/compile/internal/noder/linker.go b/go/src/cmd/compile/internal/noder/linker.go new file mode 100644 index 0000000000000000000000000000000000000000..51b03a1897e8303d38d75c7de34361c9c61d4eb2 --- /dev/null +++ b/go/src/cmd/compile/internal/noder/linker.go @@ -0,0 +1,354 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "internal/buildcfg" + "internal/pkgbits" + "io" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/reflectdata" + "cmd/compile/internal/types" + "cmd/internal/goobj" + "cmd/internal/obj" +) + +// This file implements the unified IR linker, which combines the +// local package's stub data with imported package data to produce a +// complete export data file. It also rewrites the compiler's +// extension data sections based on the results of compilation (e.g., +// the function inlining cost and linker symbol index assignments). +// +// TODO(mdempsky): Using the name "linker" here is confusing, because +// readers are likely to mistake references to it for cmd/link. But +// there's a shortage of good names for "something that combines +// multiple parts into a cohesive whole"... e.g., "assembler" and +// "compiler" are also already taken. + +// TODO(mdempsky): Should linker go into pkgbits? Probably the +// low-level linking details can be moved there, but the logic for +// handling extension data needs to stay in the compiler. + +// A linker combines a package's stub export data with any referenced +// elements from imported packages into a single, self-contained +// export data file. +type linker struct { + pw pkgbits.PkgEncoder + + pkgs map[string]index + decls map[*types.Sym]index + bodies map[*types.Sym]index +} + +// relocAll ensures that all elements specified by pr and relocs are +// copied into the output export data file, and returns the +// corresponding indices in the output. +func (l *linker) relocAll(pr *pkgReader, relocs []pkgbits.RefTableEntry) []pkgbits.RefTableEntry { + res := make([]pkgbits.RefTableEntry, len(relocs)) + for i, rent := range relocs { + rent.Idx = l.relocIdx(pr, rent.Kind, rent.Idx) + res[i] = rent + } + return res +} + +// relocIdx ensures a single element is copied into the output export +// data file, and returns the corresponding index in the output. +func (l *linker) relocIdx(pr *pkgReader, k pkgbits.SectionKind, idx index) index { + assert(pr != nil) + + absIdx := pr.AbsIdx(k, idx) + + if newidx := pr.newindex[absIdx]; newidx != 0 { + return ^newidx + } + + var newidx index + switch k { + case pkgbits.SectionString: + newidx = l.relocString(pr, idx) + case pkgbits.SectionPkg: + newidx = l.relocPkg(pr, idx) + case pkgbits.SectionObj: + newidx = l.relocObj(pr, idx) + + default: + // Generic relocations. + // + // TODO(mdempsky): Deduplicate more sections? In fact, I think + // every section could be deduplicated. This would also be easier + // if we do external relocations. + + w := l.pw.NewEncoderRaw(k) + l.relocCommon(pr, w, k, idx) + newidx = w.Idx + } + + pr.newindex[absIdx] = ^newidx + + return newidx +} + +// relocString copies the specified string from pr into the output +// export data file, deduplicating it against other strings. +func (l *linker) relocString(pr *pkgReader, idx index) index { + return l.pw.StringIdx(pr.StringIdx(idx)) +} + +// relocPkg copies the specified package from pr into the output +// export data file, rewriting its import path to match how it was +// imported. +// +// TODO(mdempsky): Since CL 391014, we already have the compilation +// unit's import path, so there should be no need to rewrite packages +// anymore. +func (l *linker) relocPkg(pr *pkgReader, idx index) index { + path := pr.PeekPkgPath(idx) + + if newidx, ok := l.pkgs[path]; ok { + return newidx + } + + r := pr.NewDecoder(pkgbits.SectionPkg, idx, pkgbits.SyncPkgDef) + w := l.pw.NewEncoder(pkgbits.SectionPkg, pkgbits.SyncPkgDef) + l.pkgs[path] = w.Idx + + // TODO(mdempsky): We end up leaving an empty string reference here + // from when the package was originally written as "". Probably not + // a big deal, but a little annoying. Maybe relocating + // cross-references in place is the way to go after all. + w.Relocs = l.relocAll(pr, r.Relocs) + + _ = r.String() // original path + w.String(path) + + io.Copy(&w.Data, &r.Data) + + return w.Flush() +} + +// relocObj copies the specified object from pr into the output export +// data file, rewriting its compiler-private extension data (e.g., +// adding inlining cost and escape analysis results for functions). +func (l *linker) relocObj(pr *pkgReader, idx index) index { + path, name, tag := pr.PeekObj(idx) + sym := types.NewPkg(path, "").Lookup(name) + + if newidx, ok := l.decls[sym]; ok { + return newidx + } + + if tag == pkgbits.ObjStub && path != "builtin" && path != "unsafe" { + pri, ok := objReader[sym] + if !ok { + base.Fatalf("missing reader for %q.%v", path, name) + } + assert(ok) + + pr = pri.pr + idx = pri.idx + + path2, name2, tag2 := pr.PeekObj(idx) + sym2 := types.NewPkg(path2, "").Lookup(name2) + assert(sym == sym2) + assert(tag2 != pkgbits.ObjStub) + } + + w := l.pw.NewEncoderRaw(pkgbits.SectionObj) + wext := l.pw.NewEncoderRaw(pkgbits.SectionObjExt) + wname := l.pw.NewEncoderRaw(pkgbits.SectionName) + wdict := l.pw.NewEncoderRaw(pkgbits.SectionObjDict) + + l.decls[sym] = w.Idx + assert(wext.Idx == w.Idx) + assert(wname.Idx == w.Idx) + assert(wdict.Idx == w.Idx) + + l.relocCommon(pr, w, pkgbits.SectionObj, idx) + l.relocCommon(pr, wname, pkgbits.SectionName, idx) + l.relocCommon(pr, wdict, pkgbits.SectionObjDict, idx) + + // Generic types and functions won't have definitions, and imported + // objects may not either. + obj, _ := sym.Def.(*ir.Name) + local := sym.Pkg == types.LocalPkg + + if local && obj != nil { + wext.Sync(pkgbits.SyncObject1) + switch tag { + case pkgbits.ObjFunc: + l.relocFuncExt(wext, obj) + case pkgbits.ObjType: + l.relocTypeExt(wext, obj) + case pkgbits.ObjVar: + l.relocVarExt(wext, obj) + } + wext.Flush() + } else { + l.relocCommon(pr, wext, pkgbits.SectionObjExt, idx) + } + + // Check if we need to export the inline bodies for functions and + // methods. + if obj != nil { + if obj.Op() == ir.ONAME && obj.Class == ir.PFUNC { + l.exportBody(obj, local) + } + + if obj.Op() == ir.OTYPE && !obj.Alias() { + if typ := obj.Type(); !typ.IsInterface() { + for _, method := range typ.Methods() { + l.exportBody(method.Nname.(*ir.Name), local) + } + } + } + } + + return w.Idx +} + +// exportBody exports the given function or method's body, if +// appropriate. local indicates whether it's a local function or +// method available on a locally declared type. (Due to cross-package +// type aliases, a method may be imported, but still available on a +// locally declared type.) +func (l *linker) exportBody(obj *ir.Name, local bool) { + assert(obj.Op() == ir.ONAME && obj.Class == ir.PFUNC) + + fn := obj.Func + if fn.Inl == nil { + return // not inlinable anyway + } + + // As a simple heuristic, if the function was declared in this + // package or we inlined it somewhere in this package, then we'll + // (re)export the function body. This isn't perfect, but seems + // reasonable in practice. In particular, it has the nice property + // that in the worst case, adding a blank import ensures the + // function body is available for inlining. + // + // TODO(mdempsky): Reimplement the reachable method crawling logic + // from typecheck/crawler.go. + exportBody := local || fn.Inl.HaveDcl + if !exportBody { + return + } + + sym := obj.Sym() + if _, ok := l.bodies[sym]; ok { + // Due to type aliases, we might visit methods multiple times. + base.AssertfAt(obj.Type().Recv() != nil, obj.Pos(), "expected method: %v", obj) + return + } + + pri, ok := bodyReaderFor(fn) + assert(ok) + l.bodies[sym] = l.relocIdx(pri.pr, pkgbits.SectionBody, pri.idx) +} + +// relocCommon copies the specified element from pr into w, +// recursively relocating any referenced elements as well. +func (l *linker) relocCommon(pr *pkgReader, w *pkgbits.Encoder, k pkgbits.SectionKind, idx index) { + r := pr.NewDecoderRaw(k, idx) + w.Relocs = l.relocAll(pr, r.Relocs) + io.Copy(&w.Data, &r.Data) + w.Flush() +} + +func (l *linker) pragmaFlag(w *pkgbits.Encoder, pragma ir.PragmaFlag) { + w.Sync(pkgbits.SyncPragma) + w.Int(int(pragma)) +} + +func (l *linker) relocFuncExt(w *pkgbits.Encoder, name *ir.Name) { + w.Sync(pkgbits.SyncFuncExt) + + l.pragmaFlag(w, name.Func.Pragma) + l.linkname(w, name) + + if buildcfg.GOARCH == "wasm" { + if name.Func.WasmImport != nil { + w.String(name.Func.WasmImport.Module) + w.String(name.Func.WasmImport.Name) + } else { + w.String("") + w.String("") + } + if name.Func.WasmExport != nil { + w.String(name.Func.WasmExport.Name) + } else { + w.String("") + } + } + + // Relocated extension data. + w.Bool(true) + + // Record definition ABI so cross-ABI calls can be direct. + // This is important for the performance of calling some + // common functions implemented in assembly (e.g., bytealg). + w.Uint64(uint64(name.Func.ABI)) + + // Escape analysis. + for _, f := range name.Type().RecvParams() { + w.String(f.Note) + } + + if inl := name.Func.Inl; w.Bool(inl != nil) { + w.Len(int(inl.Cost)) + w.Bool(inl.CanDelayResults) + if buildcfg.Experiment.NewInliner { + w.String(inl.Properties) + } + } + + w.Sync(pkgbits.SyncEOF) +} + +func (l *linker) relocTypeExt(w *pkgbits.Encoder, name *ir.Name) { + w.Sync(pkgbits.SyncTypeExt) + + typ := name.Type() + + l.pragmaFlag(w, name.Pragma()) + + // For type T, export the index of type descriptor symbols of T and *T. + l.lsymIdx(w, "", reflectdata.TypeLinksym(typ)) + l.lsymIdx(w, "", reflectdata.TypeLinksym(typ.PtrTo())) + + if typ.Kind() != types.TINTER { + for _, method := range typ.Methods() { + l.relocFuncExt(w, method.Nname.(*ir.Name)) + } + } +} + +func (l *linker) relocVarExt(w *pkgbits.Encoder, name *ir.Name) { + w.Sync(pkgbits.SyncVarExt) + l.linkname(w, name) +} + +func (l *linker) linkname(w *pkgbits.Encoder, name *ir.Name) { + w.Sync(pkgbits.SyncLinkname) + + linkname := name.Sym().Linkname + if !l.lsymIdx(w, linkname, name.Linksym()) { + w.String(linkname) + } +} + +func (l *linker) lsymIdx(w *pkgbits.Encoder, linkname string, lsym *obj.LSym) bool { + if lsym.PkgIdx > goobj.PkgIdxSelf || (lsym.PkgIdx == goobj.PkgIdxInvalid && !lsym.Indexed()) || linkname != "" { + w.Int64(-1) + return false + } + + // For a defined symbol, export its index. + // For re-exporting an imported symbol, pass its index through. + w.Int64(int64(lsym.SymIdx)) + return true +} diff --git a/go/src/cmd/compile/internal/noder/noder.go b/go/src/cmd/compile/internal/noder/noder.go new file mode 100644 index 0000000000000000000000000000000000000000..79a907833360309930b5e028c4b34c40e5b738bb --- /dev/null +++ b/go/src/cmd/compile/internal/noder/noder.go @@ -0,0 +1,477 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "errors" + "fmt" + "internal/buildcfg" + "os" + "path/filepath" + "runtime" + "strconv" + "strings" + "unicode" + "unicode/utf8" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/syntax" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/objabi" +) + +func LoadPackage(filenames []string) { + base.Timer.Start("fe", "parse") + + // Limit the number of simultaneously open files. + sem := make(chan struct{}, runtime.GOMAXPROCS(0)+10) + + noders := make([]*noder, len(filenames)) + for i := range noders { + p := noder{ + err: make(chan syntax.Error), + } + noders[i] = &p + } + + // Move the entire syntax processing logic into a separate goroutine to avoid blocking on the "sem". + go func() { + for i, filename := range filenames { + filename := filename + p := noders[i] + sem <- struct{}{} + go func() { + defer func() { <-sem }() + defer close(p.err) + fbase := syntax.NewFileBase(filename) + + f, err := os.Open(filename) + if err != nil { + p.error(syntax.Error{Msg: err.Error()}) + return + } + defer f.Close() + + p.file, _ = syntax.Parse(fbase, f, p.error, p.pragma, syntax.CheckBranches) // errors are tracked via p.error + }() + } + }() + + var lines uint + var m posMap + for _, p := range noders { + for e := range p.err { + base.ErrorfAt(m.makeXPos(e.Pos), 0, "%s", e.Msg) + } + if p.file == nil { + base.ErrorExit() + } + lines += p.file.EOF.Line() + } + base.Timer.AddEvent(int64(lines), "lines") + + unified(m, noders) +} + +// trimFilename returns the "trimmed" filename of b, which is the +// absolute filename after applying -trimpath processing. This +// filename form is suitable for use in object files and export data. +// +// If b's filename has already been trimmed (i.e., because it was read +// in from an imported package's export data), then the filename is +// returned unchanged. +func trimFilename(b *syntax.PosBase) string { + filename := b.Filename() + if !b.Trimmed() { + dir := "" + if b.IsFileBase() { + dir = base.Ctxt.Pathname + } + filename = objabi.AbsFile(dir, filename, base.Flag.TrimPath) + } + return filename +} + +// noder transforms package syntax's AST into a Node tree. +type noder struct { + file *syntax.File + linknames []linkname + pragcgobuf [][]string + err chan syntax.Error +} + +// linkname records a //go:linkname directive. +type linkname struct { + pos syntax.Pos + local string + remote string +} + +var unOps = [...]ir.Op{ + syntax.Recv: ir.ORECV, + syntax.Mul: ir.ODEREF, + syntax.And: ir.OADDR, + + syntax.Not: ir.ONOT, + syntax.Xor: ir.OBITNOT, + syntax.Add: ir.OPLUS, + syntax.Sub: ir.ONEG, +} + +var binOps = [...]ir.Op{ + syntax.OrOr: ir.OOROR, + syntax.AndAnd: ir.OANDAND, + + syntax.Eql: ir.OEQ, + syntax.Neq: ir.ONE, + syntax.Lss: ir.OLT, + syntax.Leq: ir.OLE, + syntax.Gtr: ir.OGT, + syntax.Geq: ir.OGE, + + syntax.Add: ir.OADD, + syntax.Sub: ir.OSUB, + syntax.Or: ir.OOR, + syntax.Xor: ir.OXOR, + + syntax.Mul: ir.OMUL, + syntax.Div: ir.ODIV, + syntax.Rem: ir.OMOD, + syntax.And: ir.OAND, + syntax.AndNot: ir.OANDNOT, + syntax.Shl: ir.OLSH, + syntax.Shr: ir.ORSH, +} + +// error is called concurrently if files are parsed concurrently. +func (p *noder) error(err error) { + p.err <- err.(syntax.Error) +} + +// pragmas that are allowed in the std lib, but don't have +// a syntax.Pragma value (see lex.go) associated with them. +var allowedStdPragmas = map[string]bool{ + "go:cgo_export_static": true, + "go:cgo_export_dynamic": true, + "go:cgo_import_static": true, + "go:cgo_import_dynamic": true, + "go:cgo_ldflag": true, + "go:cgo_dynamic_linker": true, + "go:embed": true, + "go:fix": true, + "go:generate": true, +} + +// *pragmas is the value stored in a syntax.pragmas during parsing. +type pragmas struct { + Flag ir.PragmaFlag // collected bits + Pos []pragmaPos // position of each individual flag + Embeds []pragmaEmbed + WasmImport *WasmImport + WasmExport *WasmExport +} + +// WasmImport stores metadata associated with the //go:wasmimport pragma +type WasmImport struct { + Pos syntax.Pos + Module string + Name string +} + +// WasmExport stores metadata associated with the //go:wasmexport pragma +type WasmExport struct { + Pos syntax.Pos + Name string +} + +type pragmaPos struct { + Flag ir.PragmaFlag + Pos syntax.Pos +} + +type pragmaEmbed struct { + Pos syntax.Pos + Patterns []string +} + +func (p *noder) checkUnusedDuringParse(pragma *pragmas) { + for _, pos := range pragma.Pos { + if pos.Flag&pragma.Flag != 0 { + p.error(syntax.Error{Pos: pos.Pos, Msg: "misplaced compiler directive"}) + } + } + if len(pragma.Embeds) > 0 { + for _, e := range pragma.Embeds { + p.error(syntax.Error{Pos: e.Pos, Msg: "misplaced go:embed directive"}) + } + } + if pragma.WasmImport != nil { + p.error(syntax.Error{Pos: pragma.WasmImport.Pos, Msg: "misplaced go:wasmimport directive"}) + } + if pragma.WasmExport != nil { + p.error(syntax.Error{Pos: pragma.WasmExport.Pos, Msg: "misplaced go:wasmexport directive"}) + } +} + +// pragma is called concurrently if files are parsed concurrently. +func (p *noder) pragma(pos syntax.Pos, blankLine bool, text string, old syntax.Pragma) syntax.Pragma { + pragma, _ := old.(*pragmas) + if pragma == nil { + pragma = new(pragmas) + } + + if text == "" { + // unused pragma; only called with old != nil. + p.checkUnusedDuringParse(pragma) + return nil + } + + if strings.HasPrefix(text, "line ") { + // line directives are handled by syntax package + panic("unreachable") + } + + if !blankLine { + // directive must be on line by itself + p.error(syntax.Error{Pos: pos, Msg: "misplaced compiler directive"}) + return pragma + } + + switch { + case strings.HasPrefix(text, "go:wasmimport "): + f := strings.Fields(text) + if len(f) != 3 { + p.error(syntax.Error{Pos: pos, Msg: "usage: //go:wasmimport importmodule importname"}) + break + } + + if buildcfg.GOARCH == "wasm" { + // Only actually use them if we're compiling to WASM though. + pragma.WasmImport = &WasmImport{ + Pos: pos, + Module: f[1], + Name: f[2], + } + } + + case strings.HasPrefix(text, "go:wasmexport "): + f := strings.Fields(text) + if len(f) != 2 { + // TODO: maybe make the name optional? It was once mentioned on proposal 65199. + p.error(syntax.Error{Pos: pos, Msg: "usage: //go:wasmexport exportname"}) + break + } + + if buildcfg.GOARCH == "wasm" { + // Only actually use them if we're compiling to WASM though. + pragma.WasmExport = &WasmExport{ + Pos: pos, + Name: f[1], + } + } + + case strings.HasPrefix(text, "go:linkname "): + f := strings.Fields(text) + if !(2 <= len(f) && len(f) <= 3) { + p.error(syntax.Error{Pos: pos, Msg: "usage: //go:linkname localname [linkname]"}) + break + } + // The second argument is optional. If omitted, we use + // the default object symbol name for this and + // linkname only serves to mark this symbol as + // something that may be referenced via the object + // symbol name from another package. + var target string + if len(f) == 3 { + target = f[2] + } else if base.Ctxt.Pkgpath != "" { + // Use the default object symbol name if the + // user didn't provide one. + target = objabi.PathToPrefix(base.Ctxt.Pkgpath) + "." + f[1] + } else { + panic("missing pkgpath") + } + p.linknames = append(p.linknames, linkname{pos, f[1], target}) + + case text == "go:embed", strings.HasPrefix(text, "go:embed "): + args, err := parseGoEmbed(text[len("go:embed"):]) + if err != nil { + p.error(syntax.Error{Pos: pos, Msg: err.Error()}) + } + if len(args) == 0 { + p.error(syntax.Error{Pos: pos, Msg: "usage: //go:embed pattern..."}) + break + } + pragma.Embeds = append(pragma.Embeds, pragmaEmbed{pos, args}) + + case strings.HasPrefix(text, "go:cgo_import_dynamic "): + // This is permitted for general use because Solaris + // code relies on it in golang.org/x/sys/unix and others. + fields := pragmaFields(text) + if len(fields) >= 4 { + lib := strings.Trim(fields[3], `"`) + if lib != "" && !safeArg(lib) && !isCgoGeneratedFile(pos) { + p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf("invalid library name %q in cgo_import_dynamic directive", lib)}) + } + p.pragcgo(pos, text) + pragma.Flag |= pragmaFlag("go:cgo_import_dynamic") + break + } + fallthrough + case strings.HasPrefix(text, "go:cgo_"): + // For security, we disallow //go:cgo_* directives other + // than cgo_import_dynamic outside cgo-generated files. + // Exception: they are allowed in the standard library, for runtime and syscall. + if !isCgoGeneratedFile(pos) && !base.Flag.Std { + p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf("//%s only allowed in cgo-generated code", text)}) + } + p.pragcgo(pos, text) + fallthrough // because of //go:cgo_unsafe_args + default: + verb := text + if i := strings.Index(text, " "); i >= 0 { + verb = verb[:i] + } + flag := pragmaFlag(verb) + const runtimePragmas = ir.Systemstack | ir.Nowritebarrier | ir.Nowritebarrierrec | ir.Yeswritebarrierrec + if !base.Flag.CompilingRuntime && flag&runtimePragmas != 0 { + p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf("//%s only allowed in runtime", verb)}) + } + if flag == ir.UintptrKeepAlive && !base.Flag.Std { + p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf("//%s is only allowed in the standard library", verb)}) + } + if flag == 0 && !allowedStdPragmas[verb] && base.Flag.Std { + p.error(syntax.Error{Pos: pos, Msg: fmt.Sprintf("//%s is not allowed in the standard library", verb)}) + } + pragma.Flag |= flag + pragma.Pos = append(pragma.Pos, pragmaPos{flag, pos}) + } + + return pragma +} + +// isCgoGeneratedFile reports whether pos is in a file +// generated by cgo, which is to say a file with name +// beginning with "_cgo_". Such files are allowed to +// contain cgo directives, and for security reasons +// (primarily misuse of linker flags), other files are not. +// See golang.org/issue/23672. +// Note that cmd/go ignores files whose names start with underscore, +// so the only _cgo_ files we will see from cmd/go are generated by cgo. +// It's easy to bypass this check by calling the compiler directly; +// we only protect against uses by cmd/go. +func isCgoGeneratedFile(pos syntax.Pos) bool { + // We need the absolute file, independent of //line directives, + // so we call pos.Base().Pos(). + return strings.HasPrefix(filepath.Base(trimFilename(pos.Base().Pos().Base())), "_cgo_") +} + +// safeArg reports whether arg is a "safe" command-line argument, +// meaning that when it appears in a command-line, it probably +// doesn't have some special meaning other than its own name. +// This is copied from SafeArg in cmd/go/internal/load/pkg.go. +func safeArg(name string) bool { + if name == "" { + return false + } + c := name[0] + return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '.' || c == '_' || c == '/' || c >= utf8.RuneSelf +} + +// parseGoEmbed parses the text following "//go:embed" to extract the glob patterns. +// It accepts unquoted space-separated patterns as well as double-quoted and back-quoted Go strings. +// go/build/read.go also processes these strings and contains similar logic. +func parseGoEmbed(args string) ([]string, error) { + var list []string + for args = strings.TrimSpace(args); args != ""; args = strings.TrimSpace(args) { + var path string + Switch: + switch args[0] { + default: + i := len(args) + for j, c := range args { + if unicode.IsSpace(c) { + i = j + break + } + } + path = args[:i] + args = args[i:] + + case '`': + i := strings.Index(args[1:], "`") + if i < 0 { + return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args) + } + path = args[1 : 1+i] + args = args[1+i+1:] + + case '"': + i := 1 + for ; i < len(args); i++ { + if args[i] == '\\' { + i++ + continue + } + if args[i] == '"' { + q, err := strconv.Unquote(args[:i+1]) + if err != nil { + return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args[:i+1]) + } + path = q + args = args[i+1:] + break Switch + } + } + if i >= len(args) { + return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args) + } + } + + if args != "" { + r, _ := utf8.DecodeRuneInString(args) + if !unicode.IsSpace(r) { + return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args) + } + } + list = append(list, path) + } + return list, nil +} + +// A function named init is a special case. +// It is called by the initialization before main is run. +// To make it unique within a package and also uncallable, +// the name, normally "pkg.init", is altered to "pkg.init.0". +var renameinitgen int + +func Renameinit() *types.Sym { + s := typecheck.LookupNum("init.", renameinitgen) + renameinitgen++ + return s +} + +func checkEmbed(decl *syntax.VarDecl, haveEmbed, withinFunc bool) error { + switch { + case !haveEmbed: + return errors.New("go:embed requires import \"embed\" (or import _ \"embed\", if package is not used)") + case len(decl.NameList) > 1: + return errors.New("go:embed cannot apply to multiple vars") + case decl.Values != nil: + return errors.New("go:embed cannot apply to var with initializer") + case decl.Type == nil: + // Should not happen, since Values == nil now. + return errors.New("go:embed cannot apply to var without type") + case withinFunc: + return errors.New("go:embed cannot apply to var inside func") + case !types.AllowsGoVersion(1, 16): + return fmt.Errorf("go:embed requires go1.16 or later (-lang was set to %s; check go.mod)", base.Flag.Lang) + + default: + return nil + } +} diff --git a/go/src/cmd/compile/internal/noder/posmap.go b/go/src/cmd/compile/internal/noder/posmap.go new file mode 100644 index 0000000000000000000000000000000000000000..9b02765e95cfe75c181bacee4d26d6c9fd7f75d3 --- /dev/null +++ b/go/src/cmd/compile/internal/noder/posmap.go @@ -0,0 +1,73 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/syntax" + "cmd/internal/src" +) + +// A posMap handles mapping from syntax.Pos to src.XPos. +type posMap struct { + bases map[*syntax.PosBase]*src.PosBase + cache struct { + last *syntax.PosBase + base *src.PosBase + } +} + +type poser interface{ Pos() syntax.Pos } +type ender interface{ End() syntax.Pos } + +func (m *posMap) pos(p poser) src.XPos { return m.makeXPos(p.Pos()) } + +func (m *posMap) makeXPos(pos syntax.Pos) src.XPos { + // Predeclared objects (e.g., the result parameter for error.Error) + // do not have a position. + if !pos.IsKnown() { + return src.NoXPos + } + + posBase := m.makeSrcPosBase(pos.Base()) + return base.Ctxt.PosTable.XPos(src.MakePos(posBase, pos.Line(), pos.Col())) +} + +// makeSrcPosBase translates from a *syntax.PosBase to a *src.PosBase. +func (m *posMap) makeSrcPosBase(b0 *syntax.PosBase) *src.PosBase { + // fast path: most likely PosBase hasn't changed + if m.cache.last == b0 { + return m.cache.base + } + + b1, ok := m.bases[b0] + if !ok { + fn := b0.Filename() + absfn := trimFilename(b0) + + if b0.IsFileBase() { + b1 = src.NewFileBase(fn, absfn) + } else { + // line directive base + p0 := b0.Pos() + p0b := p0.Base() + if p0b == b0 { + panic("infinite recursion in makeSrcPosBase") + } + p1 := src.MakePos(m.makeSrcPosBase(p0b), p0.Line(), p0.Col()) + b1 = src.NewLinePragmaBase(p1, fn, absfn, b0.Line(), b0.Col()) + } + if m.bases == nil { + m.bases = make(map[*syntax.PosBase]*src.PosBase) + } + m.bases[b0] = b1 + } + + // update cache + m.cache.last = b0 + m.cache.base = b1 + + return b1 +} diff --git a/go/src/cmd/compile/internal/noder/quirks.go b/go/src/cmd/compile/internal/noder/quirks.go new file mode 100644 index 0000000000000000000000000000000000000000..dd9cec9250e98bd931178d19517e62f46b71bf22 --- /dev/null +++ b/go/src/cmd/compile/internal/noder/quirks.go @@ -0,0 +1,79 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "fmt" + + "cmd/compile/internal/syntax" +) + +// typeExprEndPos returns the position that noder would leave base.Pos +// after parsing the given type expression. +// +// Deprecated: This function exists to emulate position semantics from +// Go 1.17, necessary for compatibility with the backend DWARF +// generation logic that assigns variables to their appropriate scope. +func typeExprEndPos(expr0 syntax.Expr) syntax.Pos { + for { + switch expr := expr0.(type) { + case *syntax.Name: + return expr.Pos() + case *syntax.SelectorExpr: + return expr.X.Pos() + + case *syntax.ParenExpr: + expr0 = expr.X + + case *syntax.Operation: + assert(expr.Op == syntax.Mul) + assert(expr.Y == nil) + expr0 = expr.X + + case *syntax.ArrayType: + expr0 = expr.Elem + case *syntax.ChanType: + expr0 = expr.Elem + case *syntax.DotsType: + expr0 = expr.Elem + case *syntax.MapType: + expr0 = expr.Value + case *syntax.SliceType: + expr0 = expr.Elem + + case *syntax.StructType: + return expr.Pos() + + case *syntax.InterfaceType: + expr0 = lastFieldType(expr.MethodList) + if expr0 == nil { + return expr.Pos() + } + + case *syntax.FuncType: + expr0 = lastFieldType(expr.ResultList) + if expr0 == nil { + expr0 = lastFieldType(expr.ParamList) + if expr0 == nil { + return expr.Pos() + } + } + + case *syntax.IndexExpr: // explicit type instantiation + targs := syntax.UnpackListExpr(expr.Index) + expr0 = targs[len(targs)-1] + + default: + panic(fmt.Sprintf("%s: unexpected type expression %v", expr.Pos(), syntax.String(expr))) + } + } +} + +func lastFieldType(fields []*syntax.Field) syntax.Expr { + if len(fields) == 0 { + return nil + } + return fields[len(fields)-1].Type +} diff --git a/go/src/cmd/compile/internal/noder/reader.go b/go/src/cmd/compile/internal/noder/reader.go new file mode 100644 index 0000000000000000000000000000000000000000..d7dd58d8caafe8beddda21690f4e30622811853f --- /dev/null +++ b/go/src/cmd/compile/internal/noder/reader.go @@ -0,0 +1,4060 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "encoding/hex" + "fmt" + "go/constant" + "internal/buildcfg" + "internal/pkgbits" + "path/filepath" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/dwarfgen" + "cmd/compile/internal/inline" + "cmd/compile/internal/inline/interleaved" + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/reflectdata" + "cmd/compile/internal/staticinit" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/hash" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" +) + +// This file implements cmd/compile backend's reader for the Unified +// IR export data. + +// A pkgReader reads Unified IR export data. +type pkgReader struct { + pkgbits.PkgDecoder + + // Indices for encoded things; lazily populated as needed. + // + // Note: Objects (i.e., ir.Names) are lazily instantiated by + // populating their types.Sym.Def; see objReader below. + + posBases []*src.PosBase + pkgs []*types.Pkg + typs []*types.Type + + // offset for rewriting the given (absolute!) index into the output, + // but bitwise inverted so we can detect if we're missing the entry + // or not. + newindex []index +} + +func newPkgReader(pr pkgbits.PkgDecoder) *pkgReader { + return &pkgReader{ + PkgDecoder: pr, + + posBases: make([]*src.PosBase, pr.NumElems(pkgbits.SectionPosBase)), + pkgs: make([]*types.Pkg, pr.NumElems(pkgbits.SectionPkg)), + typs: make([]*types.Type, pr.NumElems(pkgbits.SectionType)), + + newindex: make([]index, pr.TotalElems()), + } +} + +// A pkgReaderIndex compactly identifies an index (and its +// corresponding dictionary) within a package's export data. +type pkgReaderIndex struct { + pr *pkgReader + idx index + dict *readerDict + methodSym *types.Sym + + synthetic func(pos src.XPos, r *reader) +} + +func (pri pkgReaderIndex) asReader(k pkgbits.SectionKind, marker pkgbits.SyncMarker) *reader { + if pri.synthetic != nil { + return &reader{synthetic: pri.synthetic} + } + + r := pri.pr.newReader(k, pri.idx, marker) + r.dict = pri.dict + r.methodSym = pri.methodSym + return r +} + +func (pr *pkgReader) newReader(k pkgbits.SectionKind, idx index, marker pkgbits.SyncMarker) *reader { + return &reader{ + Decoder: pr.NewDecoder(k, idx, marker), + p: pr, + } +} + +// A reader provides APIs for reading an individual element. +type reader struct { + pkgbits.Decoder + + p *pkgReader + + dict *readerDict + + // TODO(mdempsky): The state below is all specific to reading + // function bodies. It probably makes sense to split it out + // separately so that it doesn't take up space in every reader + // instance. + + curfn *ir.Func + locals []*ir.Name + closureVars []*ir.Name + + // funarghack is used during inlining to suppress setting + // Field.Nname to the inlined copies of the parameters. This is + // necessary because we reuse the same types.Type as the original + // function, and most of the compiler still relies on field.Nname to + // find parameters/results. + funarghack bool + + // methodSym is the name of method's name, if reading a method. + // It's nil if reading a normal function or closure body. + methodSym *types.Sym + + // dictParam is the .dict param, if any. + dictParam *ir.Name + + // synthetic is a callback function to construct a synthetic + // function body. It's used for creating the bodies of function + // literals used to curry arguments to shaped functions. + synthetic func(pos src.XPos, r *reader) + + // scopeVars is a stack tracking the number of variables declared in + // the current function at the moment each open scope was opened. + scopeVars []int + marker dwarfgen.ScopeMarker + lastCloseScopePos src.XPos + + // === details for handling inline body expansion === + + // If we're reading in a function body because of inlining, this is + // the call that we're inlining for. + inlCaller *ir.Func + inlCall *ir.CallExpr + inlFunc *ir.Func + inlTreeIndex int + inlPosBases map[*src.PosBase]*src.PosBase + + // suppressInlPos tracks whether position base rewriting for + // inlining should be suppressed. See funcLit. + suppressInlPos int + + delayResults bool + + // Label to return to. + retlabel *types.Sym +} + +// A readerDict represents an instantiated "compile-time dictionary," +// used for resolving any derived types needed for instantiating a +// generic object. +// +// A compile-time dictionary can either be "shaped" or "non-shaped." +// Shaped compile-time dictionaries are only used for instantiating +// shaped type definitions and function bodies, while non-shaped +// compile-time dictionaries are used for instantiating runtime +// dictionaries. +type readerDict struct { + shaped bool // whether this is a shaped dictionary + + // baseSym is the symbol for the object this dictionary belongs to. + // If the object is an instantiated function or defined type, then + // baseSym is the mangled symbol, including any type arguments. + baseSym *types.Sym + + // For non-shaped dictionaries, shapedObj is a reference to the + // corresponding shaped object (always a function or defined type). + shapedObj *ir.Name + + // targs holds the implicit and explicit type arguments in use for + // reading the current object. For example: + // + // func F[T any]() { + // type X[U any] struct { t T; u U } + // var _ X[string] + // } + // + // var _ = F[int] + // + // While instantiating F[int], we need to in turn instantiate + // X[string]. [int] and [string] are explicit type arguments for F + // and X, respectively; but [int] is also the implicit type + // arguments for X. + // + // (As an analogy to function literals, explicits are the function + // literal's formal parameters, while implicits are variables + // captured by the function literal.) + targs []*types.Type + + // implicits counts how many of types within targs are implicit type + // arguments; the rest are explicit. + implicits int + + derived []derivedInfo // reloc index of the derived type's descriptor + derivedTypes []*types.Type // slice of previously computed derived types + + // These slices correspond to entries in the runtime dictionary. + typeParamMethodExprs []readerMethodExprInfo + subdicts []objInfo + rtypes []typeInfo + itabs []itabInfo +} + +type readerMethodExprInfo struct { + typeParamIdx int + method *types.Sym +} + +func setType(n ir.Node, typ *types.Type) { + n.SetType(typ) + n.SetTypecheck(1) +} + +func setValue(name *ir.Name, val constant.Value) { + name.SetVal(val) + name.Defn = nil +} + +// @@@ Positions + +// pos reads a position from the bitstream. +func (r *reader) pos() src.XPos { + return base.Ctxt.PosTable.XPos(r.pos0()) +} + +// origPos reads a position from the bitstream, and returns both the +// original raw position and an inlining-adjusted position. +func (r *reader) origPos() (origPos, inlPos src.XPos) { + r.suppressInlPos++ + origPos = r.pos() + r.suppressInlPos-- + inlPos = r.inlPos(origPos) + return +} + +func (r *reader) pos0() src.Pos { + r.Sync(pkgbits.SyncPos) + if !r.Bool() { + return src.NoPos + } + + posBase := r.posBase() + line := r.Uint() + col := r.Uint() + return src.MakePos(posBase, line, col) +} + +// posBase reads a position base from the bitstream. +func (r *reader) posBase() *src.PosBase { + return r.inlPosBase(r.p.posBaseIdx(r.Reloc(pkgbits.SectionPosBase))) +} + +// posBaseIdx returns the specified position base, reading it first if +// needed. +func (pr *pkgReader) posBaseIdx(idx index) *src.PosBase { + if b := pr.posBases[idx]; b != nil { + return b + } + + r := pr.newReader(pkgbits.SectionPosBase, idx, pkgbits.SyncPosBase) + var b *src.PosBase + + absFilename := r.String() + filename := absFilename + + // For build artifact stability, the export data format only + // contains the "absolute" filename as returned by objabi.AbsFile. + // However, some tests (e.g., test/run.go's asmcheck tests) expect + // to see the full, original filename printed out. Re-expanding + // "$GOROOT" to buildcfg.GOROOT is a close-enough approximation to + // satisfy this. + // + // The export data format only ever uses slash paths + // (for cross-operating-system reproducible builds), + // but error messages need to use native paths (backslash on Windows) + // as if they had been specified on the command line. + // (The go command always passes native paths to the compiler.) + const dollarGOROOT = "$GOROOT" + if buildcfg.GOROOT != "" && strings.HasPrefix(filename, dollarGOROOT) { + filename = filepath.FromSlash(buildcfg.GOROOT + filename[len(dollarGOROOT):]) + } + + if r.Bool() { + b = src.NewFileBase(filename, absFilename) + } else { + pos := r.pos0() + line := r.Uint() + col := r.Uint() + b = src.NewLinePragmaBase(pos, filename, absFilename, line, col) + } + + pr.posBases[idx] = b + return b +} + +// inlPosBase returns the inlining-adjusted src.PosBase corresponding +// to oldBase, which must be a non-inlined position. When not +// inlining, this is just oldBase. +func (r *reader) inlPosBase(oldBase *src.PosBase) *src.PosBase { + if index := oldBase.InliningIndex(); index >= 0 { + base.Fatalf("oldBase %v already has inlining index %v", oldBase, index) + } + + if r.inlCall == nil || r.suppressInlPos != 0 { + return oldBase + } + + if newBase, ok := r.inlPosBases[oldBase]; ok { + return newBase + } + + newBase := src.NewInliningBase(oldBase, r.inlTreeIndex) + r.inlPosBases[oldBase] = newBase + return newBase +} + +// inlPos returns the inlining-adjusted src.XPos corresponding to +// xpos, which must be a non-inlined position. When not inlining, this +// is just xpos. +func (r *reader) inlPos(xpos src.XPos) src.XPos { + pos := base.Ctxt.PosTable.Pos(xpos) + pos.SetBase(r.inlPosBase(pos.Base())) + return base.Ctxt.PosTable.XPos(pos) +} + +// @@@ Packages + +// pkg reads a package reference from the bitstream. +func (r *reader) pkg() *types.Pkg { + r.Sync(pkgbits.SyncPkg) + return r.p.pkgIdx(r.Reloc(pkgbits.SectionPkg)) +} + +// pkgIdx returns the specified package from the export data, reading +// it first if needed. +func (pr *pkgReader) pkgIdx(idx index) *types.Pkg { + if pkg := pr.pkgs[idx]; pkg != nil { + return pkg + } + + pkg := pr.newReader(pkgbits.SectionPkg, idx, pkgbits.SyncPkgDef).doPkg() + pr.pkgs[idx] = pkg + return pkg +} + +// doPkg reads a package definition from the bitstream. +func (r *reader) doPkg() *types.Pkg { + path := r.String() + switch path { + case "": + path = r.p.PkgPath() + case "builtin": + return types.BuiltinPkg + case "unsafe": + return types.UnsafePkg + } + + name := r.String() + + pkg := types.NewPkg(path, "") + + if pkg.Name == "" { + pkg.Name = name + } else { + base.Assertf(pkg.Name == name, "package %q has name %q, but want %q", pkg.Path, pkg.Name, name) + } + + return pkg +} + +// @@@ Types + +func (r *reader) typ() *types.Type { + return r.typWrapped(true) +} + +// typWrapped is like typ, but allows suppressing generation of +// unnecessary wrappers as a compile-time optimization. +func (r *reader) typWrapped(wrapped bool) *types.Type { + return r.p.typIdx(r.typInfo(), r.dict, wrapped) +} + +func (r *reader) typInfo() typeInfo { + r.Sync(pkgbits.SyncType) + if r.Bool() { + return typeInfo{idx: index(r.Len()), derived: true} + } + return typeInfo{idx: r.Reloc(pkgbits.SectionType), derived: false} +} + +// typListIdx returns a list of the specified types, resolving derived +// types within the given dictionary. +func (pr *pkgReader) typListIdx(infos []typeInfo, dict *readerDict) []*types.Type { + typs := make([]*types.Type, len(infos)) + for i, info := range infos { + typs[i] = pr.typIdx(info, dict, true) + } + return typs +} + +// typIdx returns the specified type. If info specifies a derived +// type, it's resolved within the given dictionary. If wrapped is +// true, then method wrappers will be generated, if appropriate. +func (pr *pkgReader) typIdx(info typeInfo, dict *readerDict, wrapped bool) *types.Type { + idx := info.idx + var where **types.Type + if info.derived { + where = &dict.derivedTypes[idx] + idx = dict.derived[idx].idx + } else { + where = &pr.typs[idx] + } + + if typ := *where; typ != nil { + return typ + } + + r := pr.newReader(pkgbits.SectionType, idx, pkgbits.SyncTypeIdx) + r.dict = dict + + typ := r.doTyp() + if typ == nil { + base.Fatalf("doTyp returned nil for info=%v", info) + } + + // For recursive type declarations involving interfaces and aliases, + // above r.doTyp() call may have already set pr.typs[idx], so just + // double check and return the type. + // + // Example: + // + // type F = func(I) + // + // type I interface { + // m(F) + // } + // + // The writer writes data types in following index order: + // + // 0: func(I) + // 1: I + // 2: interface{m(func(I))} + // + // The reader resolves it in following index order: + // + // 0 -> 1 -> 2 -> 0 -> 1 + // + // and can divide in logically 2 steps: + // + // - 0 -> 1 : first time the reader reach type I, + // it creates new named type with symbol I. + // + // - 2 -> 0 -> 1: the reader ends up reaching symbol I again, + // now the symbol I was setup in above step, so + // the reader just return the named type. + // + // Now, the functions called return, the pr.typs looks like below: + // + // - 0 -> 1 -> 2 -> 0 : [ I ] + // - 0 -> 1 -> 2 : [func(I) I ] + // - 0 -> 1 : [func(I) I interface { "".m(func("".I)) }] + // + // The idx 1, corresponding with type I was resolved successfully + // after r.doTyp() call. + + if prev := *where; prev != nil { + return prev + } + + if wrapped { + // Only cache if we're adding wrappers, so that other callers that + // find a cached type know it was wrapped. + *where = typ + + r.needWrapper(typ) + } + + if !typ.IsUntyped() { + types.CheckSize(typ) + } + + return typ +} + +func (r *reader) doTyp() *types.Type { + switch tag := pkgbits.CodeType(r.Code(pkgbits.SyncType)); tag { + default: + panic(fmt.Sprintf("unexpected type: %v", tag)) + + case pkgbits.TypeBasic: + return *basics[r.Len()] + + case pkgbits.TypeNamed: + obj := r.obj() + assert(obj.Op() == ir.OTYPE) + return obj.Type() + + case pkgbits.TypeTypeParam: + return r.dict.targs[r.Len()] + + case pkgbits.TypeArray: + len := int64(r.Uint64()) + return types.NewArray(r.typ(), len) + case pkgbits.TypeChan: + dir := dirs[r.Len()] + return types.NewChan(r.typ(), dir) + case pkgbits.TypeMap: + return types.NewMap(r.typ(), r.typ()) + case pkgbits.TypePointer: + return types.NewPtr(r.typ()) + case pkgbits.TypeSignature: + return r.signature(nil) + case pkgbits.TypeSlice: + return types.NewSlice(r.typ()) + case pkgbits.TypeStruct: + return r.structType() + case pkgbits.TypeInterface: + return r.interfaceType() + case pkgbits.TypeUnion: + return r.unionType() + } +} + +func (r *reader) unionType() *types.Type { + // In the types1 universe, we only need to handle value types. + // Impure interfaces (i.e., interfaces with non-trivial type sets + // like "int | string") can only appear as type parameter bounds, + // and this is enforced by the types2 type checker. + // + // However, type unions can still appear in pure interfaces if the + // type union is equivalent to "any". E.g., typeparam/issue52124.go + // declares variables with the type "interface { any | int }". + // + // To avoid needing to represent type unions in types1 (since we + // don't have any uses for that today anyway), we simply fold them + // to "any". + + // TODO(mdempsky): Restore consistency check to make sure folding to + // "any" is safe. This is unfortunately tricky, because a pure + // interface can reference impure interfaces too, including + // cyclically (#60117). + if false { + pure := false + for i, n := 0, r.Len(); i < n; i++ { + _ = r.Bool() // tilde + term := r.typ() + if term.IsEmptyInterface() { + pure = true + } + } + if !pure { + base.Fatalf("impure type set used in value type") + } + } + + return types.Types[types.TINTER] +} + +func (r *reader) interfaceType() *types.Type { + nmethods, nembeddeds := r.Len(), r.Len() + implicit := nmethods == 0 && nembeddeds == 1 && r.Bool() + assert(!implicit) // implicit interfaces only appear in constraints + + fields := make([]*types.Field, nmethods+nembeddeds) + methods, embeddeds := fields[:nmethods], fields[nmethods:] + + for i := range methods { + methods[i] = types.NewField(r.pos(), r.selector(), r.signature(types.FakeRecv())) + } + for i := range embeddeds { + embeddeds[i] = types.NewField(src.NoXPos, nil, r.typ()) + } + + if len(fields) == 0 { + return types.Types[types.TINTER] // empty interface + } + return types.NewInterface(fields) +} + +func (r *reader) structType() *types.Type { + fields := make([]*types.Field, r.Len()) + for i := range fields { + field := types.NewField(r.pos(), r.selector(), r.typ()) + field.Note = r.String() + if r.Bool() { + field.Embedded = 1 + } + fields[i] = field + } + return types.NewStruct(fields) +} + +func (r *reader) signature(recv *types.Field) *types.Type { + r.Sync(pkgbits.SyncSignature) + + params := r.params() + results := r.params() + if r.Bool() { // variadic + params[len(params)-1].SetIsDDD(true) + } + + return types.NewSignature(recv, params, results) +} + +func (r *reader) params() []*types.Field { + r.Sync(pkgbits.SyncParams) + params := make([]*types.Field, r.Len()) + for i := range params { + params[i] = r.param() + } + return params +} + +func (r *reader) param() *types.Field { + r.Sync(pkgbits.SyncParam) + return types.NewField(r.pos(), r.localIdent(), r.typ()) +} + +// @@@ Objects + +// objReader maps qualified identifiers (represented as *types.Sym) to +// a pkgReader and corresponding index that can be used for reading +// that object's definition. +var objReader = map[*types.Sym]pkgReaderIndex{} + +// obj reads an instantiated object reference from the bitstream. +func (r *reader) obj() ir.Node { + return r.p.objInstIdx(r.objInfo(), r.dict, false) +} + +// objInfo reads an instantiated object reference from the bitstream +// and returns the encoded reference to it, without instantiating it. +func (r *reader) objInfo() objInfo { + r.Sync(pkgbits.SyncObject) + if r.Version().Has(pkgbits.DerivedFuncInstance) { + assert(!r.Bool()) + } + idx := r.Reloc(pkgbits.SectionObj) + + explicits := make([]typeInfo, r.Len()) + for i := range explicits { + explicits[i] = r.typInfo() + } + + return objInfo{idx, explicits} +} + +// objInstIdx returns the encoded, instantiated object. If shaped is +// true, then the shaped variant of the object is returned instead. +func (pr *pkgReader) objInstIdx(info objInfo, dict *readerDict, shaped bool) ir.Node { + explicits := pr.typListIdx(info.explicits, dict) + + var implicits []*types.Type + if dict != nil { + implicits = dict.targs + } + + return pr.objIdx(info.idx, implicits, explicits, shaped) +} + +// objIdx returns the specified object, instantiated with the given +// type arguments, if any. +// If shaped is true, then the shaped variant of the object is returned +// instead. +func (pr *pkgReader) objIdx(idx index, implicits, explicits []*types.Type, shaped bool) ir.Node { + n, err := pr.objIdxMayFail(idx, implicits, explicits, shaped) + if err != nil { + base.Fatalf("%v", err) + } + return n +} + +// objIdxMayFail is equivalent to objIdx, but returns an error rather than +// failing the build if this object requires type arguments and the incorrect +// number of type arguments were passed. +// +// Other sources of internal failure (such as duplicate definitions) still fail +// the build. +func (pr *pkgReader) objIdxMayFail(idx index, implicits, explicits []*types.Type, shaped bool) (ir.Node, error) { + rname := pr.newReader(pkgbits.SectionName, idx, pkgbits.SyncObject1) + _, sym := rname.qualifiedIdent() + tag := pkgbits.CodeObj(rname.Code(pkgbits.SyncCodeObj)) + + if tag == pkgbits.ObjStub { + assert(!sym.IsBlank()) + switch sym.Pkg { + case types.BuiltinPkg, types.UnsafePkg: + return sym.Def.(ir.Node), nil + } + if pri, ok := objReader[sym]; ok { + return pri.pr.objIdxMayFail(pri.idx, nil, explicits, shaped) + } + if sym.Pkg.Path == "runtime" { + return typecheck.LookupRuntime(sym.Name), nil + } + base.Fatalf("unresolved stub: %v", sym) + } + + dict, err := pr.objDictIdx(sym, idx, implicits, explicits, shaped) + if err != nil { + return nil, err + } + + sym = dict.baseSym + if !sym.IsBlank() && sym.Def != nil { + return sym.Def.(*ir.Name), nil + } + + r := pr.newReader(pkgbits.SectionObj, idx, pkgbits.SyncObject1) + rext := pr.newReader(pkgbits.SectionObjExt, idx, pkgbits.SyncObject1) + + r.dict = dict + rext.dict = dict + + do := func(op ir.Op, hasTParams bool) *ir.Name { + pos := r.pos() + setBasePos(pos) + if hasTParams { + r.typeParamNames() + } + + name := ir.NewDeclNameAt(pos, op, sym) + name.Class = ir.PEXTERN // may be overridden later + if !sym.IsBlank() { + if sym.Def != nil { + base.FatalfAt(name.Pos(), "already have a definition for %v", name) + } + assert(sym.Def == nil) + sym.Def = name + } + return name + } + + switch tag { + default: + panic("unexpected object") + + case pkgbits.ObjAlias: + name := do(ir.OTYPE, false) + + if r.Version().Has(pkgbits.AliasTypeParamNames) { + r.typeParamNames() + } + + // Clumsy dance: the r.typ() call here might recursively find this + // type alias name, before we've set its type (#66873). So we + // temporarily clear sym.Def and then restore it later, if still + // unset. + hack := sym.Def == name + if hack { + sym.Def = nil + } + typ := r.typ() + if hack { + if sym.Def != nil { + name = sym.Def.(*ir.Name) + assert(types.IdenticalStrict(name.Type(), typ)) + return name, nil + } + sym.Def = name + } + + setType(name, typ) + name.SetAlias(true) + return name, nil + + case pkgbits.ObjConst: + name := do(ir.OLITERAL, false) + typ := r.typ() + val := FixValue(typ, r.Value()) + setType(name, typ) + setValue(name, val) + return name, nil + + case pkgbits.ObjFunc: + if sym.Name == "init" { + sym = Renameinit() + } + + npos := r.pos() + setBasePos(npos) + r.typeParamNames() + typ := r.signature(nil) + fpos := r.pos() + + fn := ir.NewFunc(fpos, npos, sym, typ) + name := fn.Nname + if !sym.IsBlank() { + if sym.Def != nil { + base.FatalfAt(name.Pos(), "already have a definition for %v", name) + } + assert(sym.Def == nil) + sym.Def = name + } + + if r.hasTypeParams() { + name.Func.SetDupok(true) + if r.dict.shaped { + setType(name, shapeSig(name.Func, r.dict)) + } else { + todoDicts = append(todoDicts, func() { + r.dict.shapedObj = pr.objIdx(idx, implicits, explicits, true).(*ir.Name) + }) + } + } + + rext.funcExt(name, nil) + return name, nil + + case pkgbits.ObjType: + name := do(ir.OTYPE, true) + typ := types.NewNamed(name) + setType(name, typ) + if r.hasTypeParams() && r.dict.shaped { + typ.SetHasShape(true) + } + + // Important: We need to do this before SetUnderlying. + rext.typeExt(name) + + // We need to defer CheckSize until we've called SetUnderlying to + // handle recursive types. + types.DeferCheckSize() + typ.SetUnderlying(r.typWrapped(false)) + types.ResumeCheckSize() + + if r.hasTypeParams() && !r.dict.shaped { + todoDicts = append(todoDicts, func() { + r.dict.shapedObj = pr.objIdx(idx, implicits, explicits, true).(*ir.Name) + }) + } + + methods := make([]*types.Field, r.Len()) + for i := range methods { + methods[i] = r.method(rext) + } + if len(methods) != 0 { + typ.SetMethods(methods) + } + + if !r.dict.shaped { + r.needWrapper(typ) + } + + return name, nil + + case pkgbits.ObjVar: + name := do(ir.ONAME, false) + setType(name, r.typ()) + rext.varExt(name) + return name, nil + } +} + +func (dict *readerDict) mangle(sym *types.Sym) *types.Sym { + if !dict.hasTypeParams() { + return sym + } + + // If sym is a locally defined generic type, we need the suffix to + // stay at the end after mangling so that types/fmt.go can strip it + // out again when writing the type's runtime descriptor (#54456). + base, suffix := types.SplitVargenSuffix(sym.Name) + + var buf strings.Builder + buf.WriteString(base) + buf.WriteByte('[') + for i, targ := range dict.targs { + if i > 0 { + if i == dict.implicits { + buf.WriteByte(';') + } else { + buf.WriteByte(',') + } + } + buf.WriteString(targ.LinkString()) + } + buf.WriteByte(']') + buf.WriteString(suffix) + return sym.Pkg.Lookup(buf.String()) +} + +// shapify returns the shape type for targ. +// +// If basic is true, then the type argument is used to instantiate a +// type parameter whose constraint is a basic interface. +func shapify(targ *types.Type, basic bool) *types.Type { + if targ.Kind() == types.TFORW { + if targ.IsFullyInstantiated() { + // For recursive instantiated type argument, it may still be a TFORW + // when shapifying happens. If we don't have targ's underlying type, + // shapify won't work. The worst case is we end up not reusing code + // optimally in some tricky cases. + if base.Debug.Shapify != 0 { + base.Warn("skipping shaping of recursive type %v", targ) + } + if targ.HasShape() { + return targ + } + } else { + base.Fatalf("%v is missing its underlying type", targ) + } + } + // For fully instantiated shape interface type, use it as-is. Otherwise, the instantiation + // involved recursive generic interface may cause mismatching in function signature, see issue #65362. + if targ.Kind() == types.TINTER && targ.IsFullyInstantiated() && targ.HasShape() { + return targ + } + + // When a pointer type is used to instantiate a type parameter + // constrained by a basic interface, we know the pointer's element + // type can't matter to the generated code. In this case, we can use + // an arbitrary pointer type as the shape type. (To match the + // non-unified frontend, we use `*byte`.) + // + // Otherwise, we simply use the type's underlying type as its shape. + // + // TODO(mdempsky): It should be possible to do much more aggressive + // shaping still; e.g., collapsing all pointer-shaped types into a + // common type, collapsing scalars of the same size/alignment into a + // common type, recursively shaping the element types of composite + // types, and discarding struct field names and tags. However, we'll + // need to start tracking how type parameters are actually used to + // implement some of these optimizations. + pointerShaping := basic && targ.IsPtr() && !targ.Elem().NotInHeap() + // The exception is when the type parameter is a pointer to a type + // which `Type.HasShape()` returns true, but `Type.IsShape()` returns + // false, like `*[]go.shape.T`. This is because the type parameter is + // used to instantiate a generic function inside another generic function. + // In this case, we want to keep the targ as-is, otherwise, we may lose the + // original type after `*[]go.shape.T` is shapified to `*go.shape.uint8`. + // See issue #54535, #71184. + if pointerShaping && !targ.Elem().IsShape() && targ.Elem().HasShape() { + return targ + } + under := targ.Underlying() + if pointerShaping { + under = types.NewPtr(types.Types[types.TUINT8]) + } + + // Hash long type names to bound symbol name length seen by users, + // particularly for large protobuf structs (#65030). + uls := under.LinkString() + if base.Debug.MaxShapeLen != 0 && + len(uls) > base.Debug.MaxShapeLen { + h := hash.Sum32([]byte(uls)) + uls = hex.EncodeToString(h[:]) + } + + sym := types.ShapePkg.Lookup(uls) + if sym.Def == nil { + name := ir.NewDeclNameAt(under.Pos(), ir.OTYPE, sym) + typ := types.NewNamed(name) + typ.SetUnderlying(under) + sym.Def = typed(typ, name) + } + res := sym.Def.Type() + assert(res.IsShape()) + assert(res.HasShape()) + return res +} + +// objDictIdx reads and returns the specified object dictionary. +func (pr *pkgReader) objDictIdx(sym *types.Sym, idx index, implicits, explicits []*types.Type, shaped bool) (*readerDict, error) { + r := pr.newReader(pkgbits.SectionObjDict, idx, pkgbits.SyncObject1) + + dict := readerDict{ + shaped: shaped, + } + + nimplicits := r.Len() + nexplicits := r.Len() + + if nimplicits > len(implicits) || nexplicits != len(explicits) { + return nil, fmt.Errorf("%v has %v+%v params, but instantiated with %v+%v args", sym, nimplicits, nexplicits, len(implicits), len(explicits)) + } + + dict.targs = append(implicits[:nimplicits:nimplicits], explicits...) + dict.implicits = nimplicits + + // Within the compiler, we can just skip over the type parameters. + for range dict.targs[dict.implicits:] { + // Skip past bounds without actually evaluating them. + r.typInfo() + } + + dict.derived = make([]derivedInfo, r.Len()) + dict.derivedTypes = make([]*types.Type, len(dict.derived)) + for i := range dict.derived { + dict.derived[i] = derivedInfo{idx: r.Reloc(pkgbits.SectionType)} + if r.Version().Has(pkgbits.DerivedInfoNeeded) { + assert(!r.Bool()) + } + } + + // Runtime dictionary information; private to the compiler. + + // If any type argument is already shaped, then we're constructing a + // shaped object, even if not explicitly requested (i.e., calling + // objIdx with shaped==true). This can happen with instantiating + // types that are referenced within a function body. + for _, targ := range dict.targs { + if targ.HasShape() { + dict.shaped = true + break + } + } + + // And if we're constructing a shaped object, then shapify all type + // arguments. + for i, targ := range dict.targs { + basic := r.Bool() + if dict.shaped { + dict.targs[i] = shapify(targ, basic) + } + } + + dict.baseSym = dict.mangle(sym) + + dict.typeParamMethodExprs = make([]readerMethodExprInfo, r.Len()) + for i := range dict.typeParamMethodExprs { + typeParamIdx := r.Len() + method := r.selector() + + dict.typeParamMethodExprs[i] = readerMethodExprInfo{typeParamIdx, method} + } + + dict.subdicts = make([]objInfo, r.Len()) + for i := range dict.subdicts { + dict.subdicts[i] = r.objInfo() + } + + dict.rtypes = make([]typeInfo, r.Len()) + for i := range dict.rtypes { + dict.rtypes[i] = r.typInfo() + } + + dict.itabs = make([]itabInfo, r.Len()) + for i := range dict.itabs { + dict.itabs[i] = itabInfo{typ: r.typInfo(), iface: r.typInfo()} + } + + return &dict, nil +} + +func (r *reader) typeParamNames() { + r.Sync(pkgbits.SyncTypeParamNames) + + for range r.dict.targs[r.dict.implicits:] { + r.pos() + r.localIdent() + } +} + +func (r *reader) method(rext *reader) *types.Field { + r.Sync(pkgbits.SyncMethod) + npos := r.pos() + sym := r.selector() + r.typeParamNames() + recv := r.param() + typ := r.signature(recv) + + fpos := r.pos() + fn := ir.NewFunc(fpos, npos, ir.MethodSym(recv.Type, sym), typ) + name := fn.Nname + + if r.hasTypeParams() { + name.Func.SetDupok(true) + if r.dict.shaped { + typ = shapeSig(name.Func, r.dict) + setType(name, typ) + } + } + + rext.funcExt(name, sym) + + meth := types.NewField(name.Func.Pos(), sym, typ) + meth.Nname = name + meth.SetNointerface(name.Func.Pragma&ir.Nointerface != 0) + + return meth +} + +func (r *reader) qualifiedIdent() (pkg *types.Pkg, sym *types.Sym) { + r.Sync(pkgbits.SyncSym) + pkg = r.pkg() + if name := r.String(); name != "" { + sym = pkg.Lookup(name) + } + return +} + +func (r *reader) localIdent() *types.Sym { + r.Sync(pkgbits.SyncLocalIdent) + pkg := r.pkg() + if name := r.String(); name != "" { + return pkg.Lookup(name) + } + return nil +} + +func (r *reader) selector() *types.Sym { + r.Sync(pkgbits.SyncSelector) + pkg := r.pkg() + name := r.String() + if types.IsExported(name) { + pkg = types.LocalPkg + } + return pkg.Lookup(name) +} + +func (r *reader) hasTypeParams() bool { + return r.dict.hasTypeParams() +} + +func (dict *readerDict) hasTypeParams() bool { + return dict != nil && len(dict.targs) != 0 +} + +// @@@ Compiler extensions + +func (r *reader) funcExt(name *ir.Name, method *types.Sym) { + r.Sync(pkgbits.SyncFuncExt) + + fn := name.Func + + // XXX: Workaround because linker doesn't know how to copy Pos. + if !fn.Pos().IsKnown() { + fn.SetPos(name.Pos()) + } + + // Normally, we only compile local functions, which saves redundant compilation work. + // n.Defn is not nil for local functions, and is nil for imported function. But for + // generic functions, we might have an instantiation that no other package has seen before. + // So we need to be conservative and compile it again. + // + // That's why name.Defn is set here, so ir.VisitFuncsBottomUp can analyze function. + // TODO(mdempsky,cuonglm): find a cleaner way to handle this. + if name.Sym().Pkg == types.LocalPkg || r.hasTypeParams() { + name.Defn = fn + } + + fn.Pragma = r.pragmaFlag() + r.linkname(name) + + if buildcfg.GOARCH == "wasm" { + importmod := r.String() + importname := r.String() + exportname := r.String() + + if importmod != "" && importname != "" { + fn.WasmImport = &ir.WasmImport{ + Module: importmod, + Name: importname, + } + } + if exportname != "" { + if method != nil { + base.ErrorfAt(fn.Pos(), 0, "cannot use //go:wasmexport on a method") + } + fn.WasmExport = &ir.WasmExport{Name: exportname} + } + } + + if r.Bool() { + assert(name.Defn == nil) + + fn.ABI = obj.ABI(r.Uint64()) + + // Escape analysis. + for _, f := range name.Type().RecvParams() { + f.Note = r.String() + } + + if r.Bool() { + fn.Inl = &ir.Inline{ + Cost: int32(r.Len()), + CanDelayResults: r.Bool(), + } + if buildcfg.Experiment.NewInliner { + fn.Inl.Properties = r.String() + } + } + } else { + r.addBody(name.Func, method) + } + r.Sync(pkgbits.SyncEOF) +} + +func (r *reader) typeExt(name *ir.Name) { + r.Sync(pkgbits.SyncTypeExt) + + typ := name.Type() + + if r.hasTypeParams() { + // Mark type as fully instantiated to ensure the type descriptor is written + // out as DUPOK and method wrappers are generated even for imported types. + typ.SetIsFullyInstantiated(true) + // HasShape should be set if any type argument is or has a shape type. + for _, targ := range r.dict.targs { + if targ.HasShape() { + typ.SetHasShape(true) + break + } + } + } + + name.SetPragma(r.pragmaFlag()) + + typecheck.SetBaseTypeIndex(typ, r.Int64(), r.Int64()) +} + +func (r *reader) varExt(name *ir.Name) { + r.Sync(pkgbits.SyncVarExt) + r.linkname(name) +} + +func (r *reader) linkname(name *ir.Name) { + assert(name.Op() == ir.ONAME) + r.Sync(pkgbits.SyncLinkname) + + if idx := r.Int64(); idx >= 0 { + lsym := name.Linksym() + lsym.SymIdx = int32(idx) + lsym.Set(obj.AttrIndexed, true) + } else { + linkname := r.String() + sym := name.Sym() + sym.Linkname = linkname + if sym.Pkg == types.LocalPkg && linkname != "" { + // Mark linkname in the current package. We don't mark the + // ones that are imported and propagated (e.g. through + // inlining or instantiation, which are marked in their + // corresponding packages). So we can tell in which package + // the linkname is used (pulled), and the linker can + // make a decision for allowing or disallowing it. + sym.Linksym().Set(obj.AttrLinkname, true) + } + } +} + +func (r *reader) pragmaFlag() ir.PragmaFlag { + r.Sync(pkgbits.SyncPragma) + return ir.PragmaFlag(r.Int()) +} + +// @@@ Function bodies + +// bodyReader tracks where the serialized IR for a local or imported, +// generic function's body can be found. +var bodyReader = map[*ir.Func]pkgReaderIndex{} + +// importBodyReader tracks where the serialized IR for an imported, +// static (i.e., non-generic) function body can be read. +var importBodyReader = map[*types.Sym]pkgReaderIndex{} + +// bodyReaderFor returns the pkgReaderIndex for reading fn's +// serialized IR, and whether one was found. +func bodyReaderFor(fn *ir.Func) (pri pkgReaderIndex, ok bool) { + if fn.Nname.Defn != nil { + pri, ok = bodyReader[fn] + base.AssertfAt(ok, base.Pos, "must have bodyReader for %v", fn) // must always be available + } else { + pri, ok = importBodyReader[fn.Sym()] + } + return +} + +// todoDicts holds the list of dictionaries that still need their +// runtime dictionary objects constructed. +var todoDicts []func() + +// todoBodies holds the list of function bodies that still need to be +// constructed. +var todoBodies []*ir.Func + +// addBody reads a function body reference from the element bitstream, +// and associates it with fn. +func (r *reader) addBody(fn *ir.Func, method *types.Sym) { + // addBody should only be called for local functions or imported + // generic functions; see comment in funcExt. + assert(fn.Nname.Defn != nil) + + idx := r.Reloc(pkgbits.SectionBody) + + pri := pkgReaderIndex{r.p, idx, r.dict, method, nil} + bodyReader[fn] = pri + + if r.curfn == nil { + todoBodies = append(todoBodies, fn) + return + } + + pri.funcBody(fn) +} + +func (pri pkgReaderIndex) funcBody(fn *ir.Func) { + r := pri.asReader(pkgbits.SectionBody, pkgbits.SyncFuncBody) + r.funcBody(fn) +} + +// funcBody reads a function body definition from the element +// bitstream, and populates fn with it. +func (r *reader) funcBody(fn *ir.Func) { + r.curfn = fn + r.closureVars = fn.ClosureVars + if len(r.closureVars) != 0 && r.hasTypeParams() { + r.dictParam = r.closureVars[len(r.closureVars)-1] // dictParam is last; see reader.funcLit + } + + ir.WithFunc(fn, func() { + r.declareParams() + + if r.syntheticBody(fn.Pos()) { + return + } + + if !r.Bool() { + return + } + + body := r.stmts() + if body == nil { + body = []ir.Node{typecheck.Stmt(ir.NewBlockStmt(src.NoXPos, nil))} + } + fn.Body = body + fn.Endlineno = r.pos() + }) + + r.marker.WriteTo(fn) +} + +// syntheticBody adds a synthetic body to r.curfn if appropriate, and +// reports whether it did. +func (r *reader) syntheticBody(pos src.XPos) bool { + if r.synthetic != nil { + r.synthetic(pos, r) + return true + } + + // If this function has type parameters and isn't shaped, then we + // just tail call its corresponding shaped variant. + if r.hasTypeParams() && !r.dict.shaped { + r.callShaped(pos) + return true + } + + return false +} + +// callShaped emits a tail call to r.shapedFn, passing along the +// arguments to the current function. +func (r *reader) callShaped(pos src.XPos) { + shapedObj := r.dict.shapedObj + assert(shapedObj != nil) + + var shapedFn ir.Node + if r.methodSym == nil { + // Instantiating a generic function; shapedObj is the shaped + // function itself. + assert(shapedObj.Op() == ir.ONAME && shapedObj.Class == ir.PFUNC) + shapedFn = shapedObj + } else { + // Instantiating a generic type's method; shapedObj is the shaped + // type, so we need to select it's corresponding method. + shapedFn = shapedMethodExpr(pos, shapedObj, r.methodSym) + } + + params := r.syntheticArgs() + + // Construct the arguments list: receiver (if any), then runtime + // dictionary, and finally normal parameters. + // + // Note: For simplicity, shaped methods are added as normal methods + // on their shaped types. So existing code (e.g., packages ir and + // typecheck) expects the shaped type to appear as the receiver + // parameter (or first parameter, as a method expression). Hence + // putting the dictionary parameter after that is the least invasive + // solution at the moment. + var args ir.Nodes + if r.methodSym != nil { + args.Append(params[0]) + params = params[1:] + } + args.Append(typecheck.Expr(ir.NewAddrExpr(pos, r.p.dictNameOf(r.dict)))) + args.Append(params...) + + r.syntheticTailCall(pos, shapedFn, args) +} + +// syntheticArgs returns the recvs and params arguments passed to the +// current function. +func (r *reader) syntheticArgs() ir.Nodes { + sig := r.curfn.Nname.Type() + return ir.ToNodes(r.curfn.Dcl[:sig.NumRecvs()+sig.NumParams()]) +} + +// syntheticTailCall emits a tail call to fn, passing the given +// arguments list. +func (r *reader) syntheticTailCall(pos src.XPos, fn ir.Node, args ir.Nodes) { + // Mark the function as a wrapper so it doesn't show up in stack + // traces. + r.curfn.SetWrapper(true) + + call := typecheck.Call(pos, fn, args, fn.Type().IsVariadic()).(*ir.CallExpr) + + var stmt ir.Node + if fn.Type().NumResults() != 0 { + stmt = typecheck.Stmt(ir.NewReturnStmt(pos, []ir.Node{call})) + } else { + stmt = call + } + r.curfn.Body.Append(stmt) +} + +// dictNameOf returns the runtime dictionary corresponding to dict. +func (pr *pkgReader) dictNameOf(dict *readerDict) *ir.Name { + pos := base.AutogeneratedPos + + // Check that we only instantiate runtime dictionaries with real types. + base.AssertfAt(!dict.shaped, pos, "runtime dictionary of shaped object %v", dict.baseSym) + + sym := dict.baseSym.Pkg.Lookup(objabi.GlobalDictPrefix + "." + dict.baseSym.Name) + if sym.Def != nil { + return sym.Def.(*ir.Name) + } + + name := ir.NewNameAt(pos, sym, dict.varType()) + name.Class = ir.PEXTERN + sym.Def = name // break cycles with mutual subdictionaries + + lsym := name.Linksym() + ot := 0 + + assertOffset := func(section string, offset int) { + base.AssertfAt(ot == offset*types.PtrSize, pos, "writing section %v at offset %v, but it should be at %v*%v", section, ot, offset, types.PtrSize) + } + + assertOffset("type param method exprs", dict.typeParamMethodExprsOffset()) + for _, info := range dict.typeParamMethodExprs { + typeParam := dict.targs[info.typeParamIdx] + method := typecheck.NewMethodExpr(pos, typeParam, info.method) + + rsym := method.FuncName().Linksym() + assert(rsym.ABI() == obj.ABIInternal) // must be ABIInternal; see ir.OCFUNC in ssagen/ssa.go + + ot = objw.SymPtr(lsym, ot, rsym, 0) + } + + assertOffset("subdictionaries", dict.subdictsOffset()) + for _, info := range dict.subdicts { + explicits := pr.typListIdx(info.explicits, dict) + + // Careful: Due to subdictionary cycles, name may not be fully + // initialized yet. + name := pr.objDictName(info.idx, dict.targs, explicits) + + ot = objw.SymPtr(lsym, ot, name.Linksym(), 0) + } + + assertOffset("rtypes", dict.rtypesOffset()) + for _, info := range dict.rtypes { + typ := pr.typIdx(info, dict, true) + ot = objw.SymPtr(lsym, ot, reflectdata.TypeLinksym(typ), 0) + + // TODO(mdempsky): Double check this. + reflectdata.MarkTypeUsedInInterface(typ, lsym) + } + + // For each (typ, iface) pair, we write the *runtime.itab pointer + // for the pair. For pairs that don't actually require an itab + // (i.e., typ is an interface, or iface is an empty interface), we + // write a nil pointer instead. This is wasteful, but rare in + // practice (e.g., instantiating a type parameter with an interface + // type). + assertOffset("itabs", dict.itabsOffset()) + for _, info := range dict.itabs { + typ := pr.typIdx(info.typ, dict, true) + iface := pr.typIdx(info.iface, dict, true) + + if !typ.IsInterface() && iface.IsInterface() && !iface.IsEmptyInterface() { + ot = objw.SymPtr(lsym, ot, reflectdata.ITabLsym(typ, iface), 0) + } else { + ot += types.PtrSize + } + + // TODO(mdempsky): Double check this. + reflectdata.MarkTypeUsedInInterface(typ, lsym) + reflectdata.MarkTypeUsedInInterface(iface, lsym) + } + + objw.Global(lsym, int32(ot), obj.DUPOK|obj.RODATA) + + return name +} + +// typeParamMethodExprsOffset returns the offset of the runtime +// dictionary's type parameter method expressions section, in words. +func (dict *readerDict) typeParamMethodExprsOffset() int { + return 0 +} + +// subdictsOffset returns the offset of the runtime dictionary's +// subdictionary section, in words. +func (dict *readerDict) subdictsOffset() int { + return dict.typeParamMethodExprsOffset() + len(dict.typeParamMethodExprs) +} + +// rtypesOffset returns the offset of the runtime dictionary's rtypes +// section, in words. +func (dict *readerDict) rtypesOffset() int { + return dict.subdictsOffset() + len(dict.subdicts) +} + +// itabsOffset returns the offset of the runtime dictionary's itabs +// section, in words. +func (dict *readerDict) itabsOffset() int { + return dict.rtypesOffset() + len(dict.rtypes) +} + +// numWords returns the total number of words that comprise dict's +// runtime dictionary variable. +func (dict *readerDict) numWords() int64 { + return int64(dict.itabsOffset() + len(dict.itabs)) +} + +// varType returns the type of dict's runtime dictionary variable. +func (dict *readerDict) varType() *types.Type { + return types.NewArray(types.Types[types.TUINTPTR], dict.numWords()) +} + +func (r *reader) declareParams() { + r.curfn.DeclareParams(!r.funarghack) + + for _, name := range r.curfn.Dcl { + if name.Sym().Name == dictParamName { + r.dictParam = name + continue + } + + r.addLocal(name) + } +} + +func (r *reader) addLocal(name *ir.Name) { + if r.synthetic == nil { + r.Sync(pkgbits.SyncAddLocal) + if r.p.SyncMarkers() { + want := r.Int() + if have := len(r.locals); have != want { + base.FatalfAt(name.Pos(), "locals table has desynced") + } + } + r.varDictIndex(name) + } + + r.locals = append(r.locals, name) +} + +func (r *reader) useLocal() *ir.Name { + r.Sync(pkgbits.SyncUseObjLocal) + if r.Bool() { + return r.locals[r.Len()] + } + return r.closureVars[r.Len()] +} + +func (r *reader) openScope() { + r.Sync(pkgbits.SyncOpenScope) + pos := r.pos() + + if base.Flag.Dwarf { + r.scopeVars = append(r.scopeVars, len(r.curfn.Dcl)) + r.marker.Push(pos) + } +} + +func (r *reader) closeScope() { + r.Sync(pkgbits.SyncCloseScope) + r.lastCloseScopePos = r.pos() + + r.closeAnotherScope() +} + +// closeAnotherScope is like closeScope, but it reuses the same mark +// position as the last closeScope call. This is useful for "for" and +// "if" statements, as their implicit blocks always end at the same +// position as an explicit block. +func (r *reader) closeAnotherScope() { + r.Sync(pkgbits.SyncCloseAnotherScope) + + if base.Flag.Dwarf { + scopeVars := r.scopeVars[len(r.scopeVars)-1] + r.scopeVars = r.scopeVars[:len(r.scopeVars)-1] + + // Quirkish: noder decides which scopes to keep before + // typechecking, whereas incremental typechecking during IR + // construction can result in new autotemps being allocated. To + // produce identical output, we ignore autotemps here for the + // purpose of deciding whether to retract the scope. + // + // This is important for net/http/fcgi, because it contains: + // + // var body io.ReadCloser + // if len(content) > 0 { + // body, req.pw = io.Pipe() + // } else { … } + // + // Notably, io.Pipe is inlinable, and inlining it introduces a ~R0 + // variable at the call site. + // + // Noder does not preserve the scope where the io.Pipe() call + // resides, because it doesn't contain any declared variables in + // source. So the ~R0 variable ends up being assigned to the + // enclosing scope instead. + // + // However, typechecking this assignment also introduces + // autotemps, because io.Pipe's results need conversion before + // they can be assigned to their respective destination variables. + // + // TODO(mdempsky): We should probably just keep all scopes, and + // let dwarfgen take care of pruning them instead. + retract := true + for _, n := range r.curfn.Dcl[scopeVars:] { + if !n.AutoTemp() { + retract = false + break + } + } + + if retract { + // no variables were declared in this scope, so we can retract it. + r.marker.Unpush() + } else { + r.marker.Pop(r.lastCloseScopePos) + } + } +} + +// @@@ Statements + +func (r *reader) stmt() ir.Node { + return block(r.stmts()) +} + +func block(stmts []ir.Node) ir.Node { + switch len(stmts) { + case 0: + return nil + case 1: + return stmts[0] + default: + return ir.NewBlockStmt(stmts[0].Pos(), stmts) + } +} + +func (r *reader) stmts() ir.Nodes { + assert(ir.CurFunc == r.curfn) + var res ir.Nodes + + r.Sync(pkgbits.SyncStmts) + for { + tag := codeStmt(r.Code(pkgbits.SyncStmt1)) + if tag == stmtEnd { + r.Sync(pkgbits.SyncStmtsEnd) + return res + } + + if n := r.stmt1(tag, &res); n != nil { + res.Append(typecheck.Stmt(n)) + } + } +} + +func (r *reader) stmt1(tag codeStmt, out *ir.Nodes) ir.Node { + var label *types.Sym + if n := len(*out); n > 0 { + if ls, ok := (*out)[n-1].(*ir.LabelStmt); ok { + label = ls.Label + } + } + + switch tag { + default: + panic("unexpected statement") + + case stmtAssign: + pos := r.pos() + names, lhs := r.assignList() + rhs := r.multiExpr() + + if len(rhs) == 0 { + for _, name := range names { + as := ir.NewAssignStmt(pos, name, nil) + as.PtrInit().Append(ir.NewDecl(pos, ir.ODCL, name)) + out.Append(typecheck.Stmt(as)) + } + return nil + } + + if len(lhs) == 1 && len(rhs) == 1 { + n := ir.NewAssignStmt(pos, lhs[0], rhs[0]) + n.Def = r.initDefn(n, names) + return n + } + + n := ir.NewAssignListStmt(pos, ir.OAS2, lhs, rhs) + n.Def = r.initDefn(n, names) + return n + + case stmtAssignOp: + op := r.op() + lhs := r.expr() + pos := r.pos() + rhs := r.expr() + return ir.NewAssignOpStmt(pos, op, lhs, rhs) + + case stmtIncDec: + op := r.op() + lhs := r.expr() + pos := r.pos() + n := ir.NewAssignOpStmt(pos, op, lhs, ir.NewOne(pos, lhs.Type())) + n.IncDec = true + return n + + case stmtBlock: + out.Append(r.blockStmt()...) + return nil + + case stmtBranch: + pos := r.pos() + op := r.op() + sym := r.optLabel() + return ir.NewBranchStmt(pos, op, sym) + + case stmtCall: + pos := r.pos() + op := r.op() + call := r.expr() + stmt := ir.NewGoDeferStmt(pos, op, call) + if op == ir.ODEFER { + x := r.optExpr() + if x != nil { + stmt.DeferAt = x.(ir.Expr) + } + } + return stmt + + case stmtExpr: + return r.expr() + + case stmtFor: + return r.forStmt(label) + + case stmtIf: + return r.ifStmt() + + case stmtLabel: + pos := r.pos() + sym := r.label() + return ir.NewLabelStmt(pos, sym) + + case stmtReturn: + pos := r.pos() + results := r.multiExpr() + return ir.NewReturnStmt(pos, results) + + case stmtSelect: + return r.selectStmt(label) + + case stmtSend: + pos := r.pos() + ch := r.expr() + value := r.expr() + return ir.NewSendStmt(pos, ch, value) + + case stmtSwitch: + return r.switchStmt(label) + } +} + +func (r *reader) assignList() ([]*ir.Name, []ir.Node) { + lhs := make([]ir.Node, r.Len()) + var names []*ir.Name + + for i := range lhs { + expr, def := r.assign() + lhs[i] = expr + if def { + names = append(names, expr.(*ir.Name)) + } + } + + return names, lhs +} + +// assign returns an assignee expression. It also reports whether the +// returned expression is a newly declared variable. +func (r *reader) assign() (ir.Node, bool) { + switch tag := codeAssign(r.Code(pkgbits.SyncAssign)); tag { + default: + panic("unhandled assignee expression") + + case assignBlank: + return typecheck.AssignExpr(ir.BlankNode), false + + case assignDef: + pos := r.pos() + setBasePos(pos) // test/fixedbugs/issue49767.go depends on base.Pos being set for the r.typ() call here, ugh + name := r.curfn.NewLocal(pos, r.localIdent(), r.typ()) + r.addLocal(name) + return name, true + + case assignExpr: + return r.expr(), false + } +} + +func (r *reader) blockStmt() []ir.Node { + r.Sync(pkgbits.SyncBlockStmt) + r.openScope() + stmts := r.stmts() + r.closeScope() + return stmts +} + +func (r *reader) forStmt(label *types.Sym) ir.Node { + r.Sync(pkgbits.SyncForStmt) + + r.openScope() + + if r.Bool() { + pos := r.pos() + rang := ir.NewRangeStmt(pos, nil, nil, nil, nil, false) + rang.Label = label + + names, lhs := r.assignList() + if len(lhs) >= 1 { + rang.Key = lhs[0] + if len(lhs) >= 2 { + rang.Value = lhs[1] + } + } + rang.Def = r.initDefn(rang, names) + + rang.X = r.expr() + if rang.X.Type().IsMap() { + rang.RType = r.rtype(pos) + } + if rang.Key != nil && !ir.IsBlank(rang.Key) { + rang.KeyTypeWord, rang.KeySrcRType = r.convRTTI(pos) + } + if rang.Value != nil && !ir.IsBlank(rang.Value) { + rang.ValueTypeWord, rang.ValueSrcRType = r.convRTTI(pos) + } + + rang.Body = r.blockStmt() + rang.DistinctVars = r.Bool() + r.closeAnotherScope() + + return rang + } + + pos := r.pos() + init := r.stmt() + cond := r.optExpr() + post := r.stmt() + body := r.blockStmt() + perLoopVars := r.Bool() + r.closeAnotherScope() + + if ir.IsConst(cond, constant.Bool) && !ir.BoolVal(cond) { + return init // simplify "for init; false; post { ... }" into "init" + } + + stmt := ir.NewForStmt(pos, init, cond, post, body, perLoopVars) + stmt.Label = label + return stmt +} + +func (r *reader) ifStmt() ir.Node { + r.Sync(pkgbits.SyncIfStmt) + r.openScope() + pos := r.pos() + init := r.stmts() + cond := r.expr() + staticCond := r.Int() + var then, els []ir.Node + if staticCond >= 0 { + then = r.blockStmt() + } else { + r.lastCloseScopePos = r.pos() + } + if staticCond <= 0 { + els = r.stmts() + } + r.closeAnotherScope() + + if staticCond != 0 { + // We may have removed a dead return statement, which can trip up + // later passes (#62211). To avoid confusion, we instead flatten + // the if statement into a block. + + if cond.Op() != ir.OLITERAL { + init.Append(typecheck.Stmt(ir.NewAssignStmt(pos, ir.BlankNode, cond))) // for side effects + } + init.Append(then...) + init.Append(els...) + return block(init) + } + + n := ir.NewIfStmt(pos, cond, then, els) + n.SetInit(init) + return n +} + +func (r *reader) selectStmt(label *types.Sym) ir.Node { + r.Sync(pkgbits.SyncSelectStmt) + + pos := r.pos() + clauses := make([]*ir.CommClause, r.Len()) + for i := range clauses { + if i > 0 { + r.closeScope() + } + r.openScope() + + pos := r.pos() + comm := r.stmt() + body := r.stmts() + + // "case i = <-c: ..." may require an implicit conversion (e.g., + // see fixedbugs/bug312.go). Currently, typecheck throws away the + // implicit conversion and relies on it being reinserted later, + // but that would lose any explicit RTTI operands too. To preserve + // RTTI, we rewrite this as "case tmp := <-c: i = tmp; ...". + if as, ok := comm.(*ir.AssignStmt); ok && as.Op() == ir.OAS && !as.Def { + if conv, ok := as.Y.(*ir.ConvExpr); ok && conv.Op() == ir.OCONVIFACE { + base.AssertfAt(conv.Implicit(), conv.Pos(), "expected implicit conversion: %v", conv) + + recv := conv.X + base.AssertfAt(recv.Op() == ir.ORECV, recv.Pos(), "expected receive expression: %v", recv) + + tmp := r.temp(pos, recv.Type()) + + // Replace comm with `tmp := <-c`. + tmpAs := ir.NewAssignStmt(pos, tmp, recv) + tmpAs.Def = true + tmpAs.PtrInit().Append(ir.NewDecl(pos, ir.ODCL, tmp)) + comm = tmpAs + + // Change original assignment to `i = tmp`, and prepend to body. + conv.X = tmp + body = append([]ir.Node{as}, body...) + } + } + + // multiExpr will have desugared a comma-ok receive expression + // into a separate statement. However, the rest of the compiler + // expects comm to be the OAS2RECV statement itself, so we need to + // shuffle things around to fit that pattern. + if as2, ok := comm.(*ir.AssignListStmt); ok && as2.Op() == ir.OAS2 { + init := ir.TakeInit(as2.Rhs[0]) + base.AssertfAt(len(init) == 1 && init[0].Op() == ir.OAS2RECV, as2.Pos(), "unexpected assignment: %+v", as2) + + comm = init[0] + body = append([]ir.Node{as2}, body...) + } + + clauses[i] = ir.NewCommStmt(pos, comm, body) + } + if len(clauses) > 0 { + r.closeScope() + } + n := ir.NewSelectStmt(pos, clauses) + n.Label = label + return n +} + +func (r *reader) switchStmt(label *types.Sym) ir.Node { + r.Sync(pkgbits.SyncSwitchStmt) + + r.openScope() + pos := r.pos() + init := r.stmt() + + var tag ir.Node + var ident *ir.Ident + var iface *types.Type + if r.Bool() { + pos := r.pos() + if r.Bool() { + ident = ir.NewIdent(r.pos(), r.localIdent()) + } + x := r.expr() + iface = x.Type() + tag = ir.NewTypeSwitchGuard(pos, ident, x) + } else { + tag = r.optExpr() + } + + clauses := make([]*ir.CaseClause, r.Len()) + for i := range clauses { + if i > 0 { + r.closeScope() + } + r.openScope() + + pos := r.pos() + var cases, rtypes []ir.Node + if iface != nil { + cases = make([]ir.Node, r.Len()) + if len(cases) == 0 { + cases = nil // TODO(mdempsky): Unclear if this matters. + } + for i := range cases { + if r.Bool() { // case nil + cases[i] = typecheck.Expr(types.BuiltinPkg.Lookup("nil").Def.(*ir.NilExpr)) + } else { + cases[i] = r.exprType() + } + } + } else { + cases = r.exprList() + + // For `switch { case any(true): }` (e.g., issue 3980 in + // test/switch.go), the backend still creates a mixed bool/any + // comparison, and we need to explicitly supply the RTTI for the + // comparison. + // + // TODO(mdempsky): Change writer.go to desugar "switch {" into + // "switch true {", which we already handle correctly. + if tag == nil { + for i, cas := range cases { + if cas.Type().IsEmptyInterface() { + for len(rtypes) < i { + rtypes = append(rtypes, nil) + } + rtypes = append(rtypes, reflectdata.TypePtrAt(cas.Pos(), types.Types[types.TBOOL])) + } + } + } + } + + clause := ir.NewCaseStmt(pos, cases, nil) + clause.RTypes = rtypes + + if ident != nil { + name := r.curfn.NewLocal(r.pos(), ident.Sym(), r.typ()) + r.addLocal(name) + clause.Var = name + name.Defn = tag + } + + clause.Body = r.stmts() + clauses[i] = clause + } + if len(clauses) > 0 { + r.closeScope() + } + r.closeScope() + + n := ir.NewSwitchStmt(pos, tag, clauses) + n.Label = label + if init != nil { + n.SetInit([]ir.Node{init}) + } + return n +} + +func (r *reader) label() *types.Sym { + r.Sync(pkgbits.SyncLabel) + name := r.String() + if r.inlCall != nil && name != "_" { + name = fmt.Sprintf("~%s·%d", name, inlgen) + } + return typecheck.Lookup(name) +} + +func (r *reader) optLabel() *types.Sym { + r.Sync(pkgbits.SyncOptLabel) + if r.Bool() { + return r.label() + } + return nil +} + +// initDefn marks the given names as declared by defn and populates +// its Init field with ODCL nodes. It then reports whether any names +// were so declared, which can be used to initialize defn.Def. +func (r *reader) initDefn(defn ir.InitNode, names []*ir.Name) bool { + if len(names) == 0 { + return false + } + + init := make([]ir.Node, len(names)) + for i, name := range names { + name.Defn = defn + init[i] = ir.NewDecl(name.Pos(), ir.ODCL, name) + } + defn.SetInit(init) + return true +} + +// @@@ Expressions + +// expr reads and returns a typechecked expression. +func (r *reader) expr() (res ir.Node) { + defer func() { + if res != nil && res.Typecheck() == 0 { + base.FatalfAt(res.Pos(), "%v missed typecheck", res) + } + }() + + switch tag := codeExpr(r.Code(pkgbits.SyncExpr)); tag { + default: + panic("unhandled expression") + + case exprLocal: + return typecheck.Expr(r.useLocal()) + + case exprGlobal: + // Callee instead of Expr allows builtins + // TODO(mdempsky): Handle builtins directly in exprCall, like method calls? + return typecheck.Callee(r.obj()) + + case exprFuncInst: + origPos, pos := r.origPos() + wrapperFn, baseFn, dictPtr := r.funcInst(pos) + if wrapperFn != nil { + return wrapperFn + } + return r.curry(origPos, false, baseFn, dictPtr, nil) + + case exprConst: + pos := r.pos() + typ := r.typ() + val := FixValue(typ, r.Value()) + return ir.NewBasicLit(pos, typ, val) + + case exprZero: + pos := r.pos() + typ := r.typ() + return ir.NewZero(pos, typ) + + case exprCompLit: + return r.compLit() + + case exprFuncLit: + return r.funcLit() + + case exprFieldVal: + x := r.expr() + pos := r.pos() + sym := r.selector() + + return typecheck.XDotField(pos, x, sym) + + case exprMethodVal: + recv := r.expr() + origPos, pos := r.origPos() + wrapperFn, baseFn, dictPtr := r.methodExpr() + + // For simple wrapperFn values, the existing machinery for creating + // and deduplicating wrapperFn value wrappers still works fine. + if wrapperFn, ok := wrapperFn.(*ir.SelectorExpr); ok && wrapperFn.Op() == ir.OMETHEXPR { + // The receiver expression we constructed may have a shape type. + // For example, in fixedbugs/issue54343.go, `New[int]()` is + // constructed as `New[go.shape.int](&.dict.New[int])`, which + // has type `*T[go.shape.int]`, not `*T[int]`. + // + // However, the method we want to select here is `(*T[int]).M`, + // not `(*T[go.shape.int]).M`, so we need to manually convert + // the type back so that the OXDOT resolves correctly. + // + // TODO(mdempsky): Logically it might make more sense for + // exprCall to take responsibility for setting a non-shaped + // result type, but this is the only place where we care + // currently. And only because existing ir.OMETHVALUE backend + // code relies on n.X.Type() instead of n.Selection.Recv().Type + // (because the latter is types.FakeRecvType() in the case of + // interface method values). + // + if recv.Type().HasShape() { + typ := wrapperFn.Type().Param(0).Type + if !types.Identical(typ, recv.Type()) { + base.FatalfAt(wrapperFn.Pos(), "receiver %L does not match %L", recv, wrapperFn) + } + recv = typecheck.Expr(ir.NewConvExpr(recv.Pos(), ir.OCONVNOP, typ, recv)) + } + + n := typecheck.XDotMethod(pos, recv, wrapperFn.Sel, false) + + // As a consistency check here, we make sure "n" selected the + // same method (represented by a types.Field) that wrapperFn + // selected. However, for anonymous receiver types, there can be + // multiple such types.Field instances (#58563). So we may need + // to fallback to making sure Sym and Type (including the + // receiver parameter's type) match. + if n.Selection != wrapperFn.Selection { + assert(n.Selection.Sym == wrapperFn.Selection.Sym) + assert(types.Identical(n.Selection.Type, wrapperFn.Selection.Type)) + assert(types.Identical(n.Selection.Type.Recv().Type, wrapperFn.Selection.Type.Recv().Type)) + } + + wrapper := methodValueWrapper{ + rcvr: n.X.Type(), + method: n.Selection, + } + + if r.importedDef() { + haveMethodValueWrappers = append(haveMethodValueWrappers, wrapper) + } else { + needMethodValueWrappers = append(needMethodValueWrappers, wrapper) + } + return n + } + + // For more complicated method expressions, we construct a + // function literal wrapper. + return r.curry(origPos, true, baseFn, recv, dictPtr) + + case exprMethodExpr: + recv := r.typ() + + implicits := make([]int, r.Len()) + for i := range implicits { + implicits[i] = r.Len() + } + var deref, addr bool + if r.Bool() { + deref = true + } else if r.Bool() { + addr = true + } + + origPos, pos := r.origPos() + wrapperFn, baseFn, dictPtr := r.methodExpr() + + // If we already have a wrapper and don't need to do anything with + // it, we can just return the wrapper directly. + // + // N.B., we use implicits/deref/addr here as the source of truth + // rather than types.Identical, because the latter can be confused + // by tricky promoted methods (e.g., typeparam/mdempsky/21.go). + if wrapperFn != nil && len(implicits) == 0 && !deref && !addr { + if !types.Identical(recv, wrapperFn.Type().Param(0).Type) { + base.FatalfAt(pos, "want receiver type %v, but have method %L", recv, wrapperFn) + } + return wrapperFn + } + + // Otherwise, if the wrapper function is a static method + // expression (OMETHEXPR) and the receiver type is unshaped, then + // we can rely on a statically generated wrapper being available. + if method, ok := wrapperFn.(*ir.SelectorExpr); ok && method.Op() == ir.OMETHEXPR && !recv.HasShape() { + return typecheck.NewMethodExpr(pos, recv, method.Sel) + } + + return r.methodExprWrap(origPos, recv, implicits, deref, addr, baseFn, dictPtr) + + case exprIndex: + x := r.expr() + pos := r.pos() + index := r.expr() + n := typecheck.Expr(ir.NewIndexExpr(pos, x, index)) + switch n.Op() { + case ir.OINDEXMAP: + n := n.(*ir.IndexExpr) + n.RType = r.rtype(pos) + } + return n + + case exprSlice: + x := r.expr() + pos := r.pos() + var index [3]ir.Node + for i := range index { + index[i] = r.optExpr() + } + op := ir.OSLICE + if index[2] != nil { + op = ir.OSLICE3 + } + return typecheck.Expr(ir.NewSliceExpr(pos, op, x, index[0], index[1], index[2])) + + case exprAssert: + x := r.expr() + pos := r.pos() + typ := r.exprType() + srcRType := r.rtype(pos) + + // TODO(mdempsky): Always emit ODYNAMICDOTTYPE for uniformity? + if typ, ok := typ.(*ir.DynamicType); ok && typ.Op() == ir.ODYNAMICTYPE { + assert := ir.NewDynamicTypeAssertExpr(pos, ir.ODYNAMICDOTTYPE, x, typ.RType) + assert.SrcRType = srcRType + assert.ITab = typ.ITab + return typed(typ.Type(), assert) + } + return typecheck.Expr(ir.NewTypeAssertExpr(pos, x, typ.Type())) + + case exprUnaryOp: + op := r.op() + pos := r.pos() + x := r.expr() + + switch op { + case ir.OADDR: + return typecheck.Expr(typecheck.NodAddrAt(pos, x)) + case ir.ODEREF: + return typecheck.Expr(ir.NewStarExpr(pos, x)) + } + return typecheck.Expr(ir.NewUnaryExpr(pos, op, x)) + + case exprBinaryOp: + op := r.op() + x := r.expr() + pos := r.pos() + y := r.expr() + + switch op { + case ir.OANDAND, ir.OOROR: + return typecheck.Expr(ir.NewLogicalExpr(pos, op, x, y)) + case ir.OLSH, ir.ORSH: + // Untyped rhs of non-constant shift, e.g. x << 1.0. + // If we have a constant value, it must be an int >= 0. + if ir.IsConstNode(y) { + val := constant.ToInt(y.Val()) + assert(val.Kind() == constant.Int && constant.Sign(val) >= 0) + } + } + return typecheck.Expr(ir.NewBinaryExpr(pos, op, x, y)) + + case exprRecv: + x := r.expr() + pos := r.pos() + for i, n := 0, r.Len(); i < n; i++ { + x = Implicit(typecheck.DotField(pos, x, r.Len())) + } + if r.Bool() { // needs deref + x = Implicit(Deref(pos, x.Type().Elem(), x)) + } else if r.Bool() { // needs addr + x = Implicit(Addr(pos, x)) + } + return x + + case exprCall: + var fun ir.Node + var args ir.Nodes + if r.Bool() { // method call + recv := r.expr() + _, method, dictPtr := r.methodExpr() + + if recv.Type().IsInterface() && method.Op() == ir.OMETHEXPR { + method := method.(*ir.SelectorExpr) + + // The compiler backend (e.g., devirtualization) handle + // OCALLINTER/ODOTINTER better than OCALLFUNC/OMETHEXPR for + // interface calls, so we prefer to continue constructing + // calls that way where possible. + // + // There are also corner cases where semantically it's perhaps + // significant; e.g., fixedbugs/issue15975.go, #38634, #52025. + + fun = typecheck.XDotMethod(method.Pos(), recv, method.Sel, true) + } else { + if recv.Type().IsInterface() { + // N.B., this happens currently for typeparam/issue51521.go + // and typeparam/typeswitch3.go. + if base.Flag.LowerM != 0 { + base.WarnfAt(method.Pos(), "imprecise interface call") + } + } + + fun = method + args.Append(recv) + } + if dictPtr != nil { + args.Append(dictPtr) + } + } else if r.Bool() { // call to instanced function + pos := r.pos() + _, shapedFn, dictPtr := r.funcInst(pos) + fun = shapedFn + args.Append(dictPtr) + } else { + fun = r.expr() + } + pos := r.pos() + args.Append(r.multiExpr()...) + dots := r.Bool() + n := typecheck.Call(pos, fun, args, dots) + switch n.Op() { + case ir.OAPPEND: + n := n.(*ir.CallExpr) + n.RType = r.rtype(pos) + // For append(a, b...), we don't need the implicit conversion. The typechecker already + // ensured that a and b are both slices with the same base type, or []byte and string. + if n.IsDDD { + if conv, ok := n.Args[1].(*ir.ConvExpr); ok && conv.Op() == ir.OCONVNOP && conv.Implicit() { + n.Args[1] = conv.X + } + } + case ir.OCOPY: + n := n.(*ir.BinaryExpr) + n.RType = r.rtype(pos) + case ir.ODELETE: + n := n.(*ir.CallExpr) + n.RType = r.rtype(pos) + case ir.OUNSAFESLICE: + n := n.(*ir.BinaryExpr) + n.RType = r.rtype(pos) + } + return n + + case exprMake: + pos := r.pos() + typ := r.exprType() + extra := r.exprs() + n := typecheck.Expr(ir.NewCallExpr(pos, ir.OMAKE, nil, append([]ir.Node{typ}, extra...))).(*ir.MakeExpr) + n.RType = r.rtype(pos) + return n + + case exprNew: + pos := r.pos() + if r.Bool() { + // new(expr) -> tmp := expr; &tmp + x := r.expr() + x = typecheck.DefaultLit(x, nil) // See TODO in exprConvert case. + var init ir.Nodes + addr := ir.NewAddrExpr(pos, r.tempCopy(pos, x, &init)) + addr.SetInit(init) + return typecheck.Expr(addr) + } + // new(T) + return typecheck.Expr(ir.NewUnaryExpr(pos, ir.ONEW, r.exprType())) + + case exprSizeof: + return ir.NewUintptr(r.pos(), r.typ().Size()) + + case exprAlignof: + return ir.NewUintptr(r.pos(), r.typ().Alignment()) + + case exprOffsetof: + pos := r.pos() + typ := r.typ() + types.CalcSize(typ) + + var offset int64 + for i := r.Len(); i >= 0; i-- { + field := typ.Field(r.Len()) + offset += field.Offset + typ = field.Type + } + + return ir.NewUintptr(pos, offset) + + case exprReshape: + typ := r.typ() + x := r.expr() + + if types.IdenticalStrict(x.Type(), typ) { + return x + } + + // Comparison expressions are constructed as "untyped bool" still. + // + // TODO(mdempsky): It should be safe to reshape them here too, but + // maybe it's better to construct them with the proper type + // instead. + if x.Type() == types.UntypedBool && typ.IsBoolean() { + return x + } + + base.AssertfAt(x.Type().HasShape() || typ.HasShape(), x.Pos(), "%L and %v are not shape types", x, typ) + base.AssertfAt(types.Identical(x.Type(), typ), x.Pos(), "%L is not shape-identical to %v", x, typ) + + // We use ir.HasUniquePos here as a check that x only appears once + // in the AST, so it's okay for us to call SetType without + // breaking any other uses of it. + // + // Notably, any ONAMEs should already have the exactly right shape + // type and been caught by types.IdenticalStrict above. + base.AssertfAt(ir.HasUniquePos(x), x.Pos(), "cannot call SetType(%v) on %L", typ, x) + + if base.Debug.Reshape != 0 { + base.WarnfAt(x.Pos(), "reshaping %L to %v", x, typ) + } + + x.SetType(typ) + return x + + case exprConvert: + implicit := r.Bool() + typ := r.typ() + pos := r.pos() + typeWord, srcRType := r.convRTTI(pos) + dstTypeParam := r.Bool() + identical := r.Bool() + x := r.expr() + + // TODO(mdempsky): Stop constructing expressions of untyped type. + x = typecheck.DefaultLit(x, typ) + + ce := ir.NewConvExpr(pos, ir.OCONV, typ, x) + ce.TypeWord, ce.SrcRType = typeWord, srcRType + if implicit { + ce.SetImplicit(true) + } + n := typecheck.Expr(ce) + + // Conversions between non-identical, non-empty interfaces always + // requires a runtime call, even if they have identical underlying + // interfaces. This is because we create separate itab instances + // for each unique interface type, not merely each unique + // interface shape. + // + // However, due to shape types, typecheck.Expr might mistakenly + // think a conversion between two non-empty interfaces are + // identical and set ir.OCONVNOP, instead of ir.OCONVIFACE. To + // ensure we update the itab field appropriately, we force it to + // ir.OCONVIFACE instead when shape types are involved. + // + // TODO(mdempsky): Are there other places we might get this wrong? + // Should this be moved down into typecheck.{Assign,Convert}op? + // This would be a non-issue if itabs were unique for each + // *underlying* interface type instead. + if !identical { + if n, ok := n.(*ir.ConvExpr); ok && n.Op() == ir.OCONVNOP && n.Type().IsInterface() && !n.Type().IsEmptyInterface() && (n.Type().HasShape() || n.X.Type().HasShape()) { + n.SetOp(ir.OCONVIFACE) + } + } + + // spec: "If the type is a type parameter, the constant is converted + // into a non-constant value of the type parameter." + if dstTypeParam && ir.IsConstNode(n) { + // Wrap in an OCONVNOP node to ensure result is non-constant. + n = Implicit(ir.NewConvExpr(pos, ir.OCONVNOP, n.Type(), n)) + n.SetTypecheck(1) + } + return n + + case exprRuntimeBuiltin: + builtin := typecheck.LookupRuntime(r.String()) + return builtin + } +} + +// funcInst reads an instantiated function reference, and returns +// three (possibly nil) expressions related to it: +// +// baseFn is always non-nil: it's either a function of the appropriate +// type already, or it has an extra dictionary parameter as the first +// parameter. +// +// If dictPtr is non-nil, then it's a dictionary argument that must be +// passed as the first argument to baseFn. +// +// If wrapperFn is non-nil, then it's either the same as baseFn (if +// dictPtr is nil), or it's semantically equivalent to currying baseFn +// to pass dictPtr. (wrapperFn is nil when dictPtr is an expression +// that needs to be computed dynamically.) +// +// For callers that are creating a call to the returned function, it's +// best to emit a call to baseFn, and include dictPtr in the arguments +// list as appropriate. +// +// For callers that want to return the function without invoking it, +// they may return wrapperFn if it's non-nil; but otherwise, they need +// to create their own wrapper. +func (r *reader) funcInst(pos src.XPos) (wrapperFn, baseFn, dictPtr ir.Node) { + // Like in methodExpr, I'm pretty sure this isn't needed. + var implicits []*types.Type + if r.dict != nil { + implicits = r.dict.targs + } + + if r.Bool() { // dynamic subdictionary + idx := r.Len() + info := r.dict.subdicts[idx] + explicits := r.p.typListIdx(info.explicits, r.dict) + + baseFn = r.p.objIdx(info.idx, implicits, explicits, true).(*ir.Name) + + // TODO(mdempsky): Is there a more robust way to get the + // dictionary pointer type here? + dictPtrType := baseFn.Type().Param(0).Type + dictPtr = typecheck.Expr(ir.NewConvExpr(pos, ir.OCONVNOP, dictPtrType, r.dictWord(pos, r.dict.subdictsOffset()+idx))) + + return + } + + info := r.objInfo() + explicits := r.p.typListIdx(info.explicits, r.dict) + + wrapperFn = r.p.objIdx(info.idx, implicits, explicits, false).(*ir.Name) + baseFn = r.p.objIdx(info.idx, implicits, explicits, true).(*ir.Name) + + dictName := r.p.objDictName(info.idx, implicits, explicits) + dictPtr = typecheck.Expr(ir.NewAddrExpr(pos, dictName)) + + return +} + +func (pr *pkgReader) objDictName(idx index, implicits, explicits []*types.Type) *ir.Name { + rname := pr.newReader(pkgbits.SectionName, idx, pkgbits.SyncObject1) + _, sym := rname.qualifiedIdent() + tag := pkgbits.CodeObj(rname.Code(pkgbits.SyncCodeObj)) + + if tag == pkgbits.ObjStub { + assert(!sym.IsBlank()) + if pri, ok := objReader[sym]; ok { + return pri.pr.objDictName(pri.idx, nil, explicits) + } + base.Fatalf("unresolved stub: %v", sym) + } + + dict, err := pr.objDictIdx(sym, idx, implicits, explicits, false) + if err != nil { + base.Fatalf("%v", err) + } + + return pr.dictNameOf(dict) +} + +// curry returns a function literal that calls fun with arg0 and +// (optionally) arg1, accepting additional arguments to the function +// literal as necessary to satisfy fun's signature. +// +// If nilCheck is true and arg0 is an interface value, then it's +// checked to be non-nil as an initial step at the point of evaluating +// the function literal itself. +func (r *reader) curry(origPos src.XPos, ifaceHack bool, fun ir.Node, arg0, arg1 ir.Node) ir.Node { + var captured ir.Nodes + captured.Append(fun, arg0) + if arg1 != nil { + captured.Append(arg1) + } + + params, results := syntheticSig(fun.Type()) + params = params[len(captured)-1:] // skip curried parameters + typ := types.NewSignature(nil, params, results) + + addBody := func(pos src.XPos, r *reader, captured []ir.Node) { + fun := captured[0] + + var args ir.Nodes + args.Append(captured[1:]...) + args.Append(r.syntheticArgs()...) + + r.syntheticTailCall(pos, fun, args) + } + + return r.syntheticClosure(origPos, typ, ifaceHack, captured, addBody) +} + +// methodExprWrap returns a function literal that changes method's +// first parameter's type to recv, and uses implicits/deref/addr to +// select the appropriate receiver parameter to pass to method. +func (r *reader) methodExprWrap(origPos src.XPos, recv *types.Type, implicits []int, deref, addr bool, method, dictPtr ir.Node) ir.Node { + var captured ir.Nodes + captured.Append(method) + + params, results := syntheticSig(method.Type()) + + // Change first parameter to recv. + params[0].Type = recv + + // If we have a dictionary pointer argument to pass, then omit the + // underlying method expression's dictionary parameter from the + // returned signature too. + if dictPtr != nil { + captured.Append(dictPtr) + params = append(params[:1], params[2:]...) + } + + typ := types.NewSignature(nil, params, results) + + addBody := func(pos src.XPos, r *reader, captured []ir.Node) { + fn := captured[0] + args := r.syntheticArgs() + + // Rewrite first argument based on implicits/deref/addr. + { + arg := args[0] + for _, ix := range implicits { + arg = Implicit(typecheck.DotField(pos, arg, ix)) + } + if deref { + arg = Implicit(Deref(pos, arg.Type().Elem(), arg)) + } else if addr { + arg = Implicit(Addr(pos, arg)) + } + args[0] = arg + } + + // Insert dictionary argument, if provided. + if dictPtr != nil { + newArgs := make([]ir.Node, len(args)+1) + newArgs[0] = args[0] + newArgs[1] = captured[1] + copy(newArgs[2:], args[1:]) + args = newArgs + } + + r.syntheticTailCall(pos, fn, args) + } + + return r.syntheticClosure(origPos, typ, false, captured, addBody) +} + +// syntheticClosure constructs a synthetic function literal for +// currying dictionary arguments. origPos is the position used for the +// closure, which must be a non-inlined position. typ is the function +// literal's signature type. +// +// captures is a list of expressions that need to be evaluated at the +// point of function literal evaluation and captured by the function +// literal. If ifaceHack is true and captures[1] is an interface type, +// it's checked to be non-nil after evaluation. +// +// addBody is a callback function to populate the function body. The +// list of captured values passed back has the captured variables for +// use within the function literal, corresponding to the expressions +// in captures. +func (r *reader) syntheticClosure(origPos src.XPos, typ *types.Type, ifaceHack bool, captures ir.Nodes, addBody func(pos src.XPos, r *reader, captured []ir.Node)) ir.Node { + // isSafe reports whether n is an expression that we can safely + // defer to evaluating inside the closure instead, to avoid storing + // them into the closure. + // + // In practice this is always (and only) the wrappee function. + isSafe := func(n ir.Node) bool { + if n.Op() == ir.ONAME && n.(*ir.Name).Class == ir.PFUNC { + return true + } + if n.Op() == ir.OMETHEXPR { + return true + } + + return false + } + + fn := r.inlClosureFunc(origPos, typ, ir.OCLOSURE) + fn.SetWrapper(true) + + clo := fn.OClosure + inlPos := clo.Pos() + + var init ir.Nodes + for i, n := range captures { + if isSafe(n) { + continue // skip capture; can reference directly + } + + tmp := r.tempCopy(inlPos, n, &init) + ir.NewClosureVar(origPos, fn, tmp) + + // We need to nil check interface receivers at the point of method + // value evaluation, ugh. + if ifaceHack && i == 1 && n.Type().IsInterface() { + check := ir.NewUnaryExpr(inlPos, ir.OCHECKNIL, ir.NewUnaryExpr(inlPos, ir.OITAB, tmp)) + init.Append(typecheck.Stmt(check)) + } + } + + pri := pkgReaderIndex{synthetic: func(pos src.XPos, r *reader) { + captured := make([]ir.Node, len(captures)) + next := 0 + for i, n := range captures { + if isSafe(n) { + captured[i] = n + } else { + captured[i] = r.closureVars[next] + next++ + } + } + assert(next == len(r.closureVars)) + + addBody(origPos, r, captured) + }} + bodyReader[fn] = pri + pri.funcBody(fn) + + return ir.InitExpr(init, clo) +} + +// syntheticSig duplicates and returns the params and results lists +// for sig, but renaming anonymous parameters so they can be assigned +// ir.Names. +func syntheticSig(sig *types.Type) (params, results []*types.Field) { + clone := func(params []*types.Field) []*types.Field { + res := make([]*types.Field, len(params)) + for i, param := range params { + // TODO(mdempsky): It would be nice to preserve the original + // parameter positions here instead, but at least + // typecheck.NewMethodType replaces them with base.Pos, making + // them useless. Worse, the positions copied from base.Pos may + // have inlining contexts, which we definitely don't want here + // (e.g., #54625). + res[i] = types.NewField(base.AutogeneratedPos, param.Sym, param.Type) + res[i].SetIsDDD(param.IsDDD()) + } + return res + } + + return clone(sig.Params()), clone(sig.Results()) +} + +func (r *reader) optExpr() ir.Node { + if r.Bool() { + return r.expr() + } + return nil +} + +// methodExpr reads a method expression reference, and returns three +// (possibly nil) expressions related to it: +// +// baseFn is always non-nil: it's either a function of the appropriate +// type already, or it has an extra dictionary parameter as the second +// parameter (i.e., immediately after the promoted receiver +// parameter). +// +// If dictPtr is non-nil, then it's a dictionary argument that must be +// passed as the second argument to baseFn. +// +// If wrapperFn is non-nil, then it's either the same as baseFn (if +// dictPtr is nil), or it's semantically equivalent to currying baseFn +// to pass dictPtr. (wrapperFn is nil when dictPtr is an expression +// that needs to be computed dynamically.) +// +// For callers that are creating a call to the returned method, it's +// best to emit a call to baseFn, and include dictPtr in the arguments +// list as appropriate. +// +// For callers that want to return a method expression without +// invoking it, they may return wrapperFn if it's non-nil; but +// otherwise, they need to create their own wrapper. +func (r *reader) methodExpr() (wrapperFn, baseFn, dictPtr ir.Node) { + recv := r.typ() + sig0 := r.typ() + pos := r.pos() + sym := r.selector() + + // Signature type to return (i.e., recv prepended to the method's + // normal parameters list). + sig := typecheck.NewMethodType(sig0, recv) + + if r.Bool() { // type parameter method expression + idx := r.Len() + word := r.dictWord(pos, r.dict.typeParamMethodExprsOffset()+idx) + + // TODO(mdempsky): If the type parameter was instantiated with an + // interface type (i.e., embed.IsInterface()), then we could + // return the OMETHEXPR instead and save an indirection. + + // We wrote the method expression's entry point PC into the + // dictionary, but for Go `func` values we need to return a + // closure (i.e., pointer to a structure with the PC as the first + // field). Because method expressions don't have any closure + // variables, we pun the dictionary entry as the closure struct. + fn := typecheck.Expr(ir.NewConvExpr(pos, ir.OCONVNOP, sig, ir.NewAddrExpr(pos, word))) + return fn, fn, nil + } + + // TODO(mdempsky): I'm pretty sure this isn't needed: implicits is + // only relevant to locally defined types, but they can't have + // (non-promoted) methods. + var implicits []*types.Type + if r.dict != nil { + implicits = r.dict.targs + } + + if r.Bool() { // dynamic subdictionary + idx := r.Len() + info := r.dict.subdicts[idx] + explicits := r.p.typListIdx(info.explicits, r.dict) + + shapedObj := r.p.objIdx(info.idx, implicits, explicits, true).(*ir.Name) + shapedFn := shapedMethodExpr(pos, shapedObj, sym) + + // TODO(mdempsky): Is there a more robust way to get the + // dictionary pointer type here? + dictPtrType := shapedFn.Type().Param(1).Type + dictPtr := typecheck.Expr(ir.NewConvExpr(pos, ir.OCONVNOP, dictPtrType, r.dictWord(pos, r.dict.subdictsOffset()+idx))) + + return nil, shapedFn, dictPtr + } + + if r.Bool() { // static dictionary + info := r.objInfo() + explicits := r.p.typListIdx(info.explicits, r.dict) + + shapedObj := r.p.objIdx(info.idx, implicits, explicits, true).(*ir.Name) + shapedFn := shapedMethodExpr(pos, shapedObj, sym) + + dict := r.p.objDictName(info.idx, implicits, explicits) + dictPtr := typecheck.Expr(ir.NewAddrExpr(pos, dict)) + + // Check that dictPtr matches shapedFn's dictionary parameter. + if !types.Identical(dictPtr.Type(), shapedFn.Type().Param(1).Type) { + base.FatalfAt(pos, "dict %L, but shaped method %L", dict, shapedFn) + } + + // For statically known instantiations, we can take advantage of + // the stenciled wrapper. + base.AssertfAt(!recv.HasShape(), pos, "shaped receiver %v", recv) + wrapperFn := typecheck.NewMethodExpr(pos, recv, sym) + base.AssertfAt(types.Identical(sig, wrapperFn.Type()), pos, "wrapper %L does not have type %v", wrapperFn, sig) + + return wrapperFn, shapedFn, dictPtr + } + + // Simple method expression; no dictionary needed. + base.AssertfAt(!recv.HasShape() || recv.IsInterface(), pos, "shaped receiver %v", recv) + fn := typecheck.NewMethodExpr(pos, recv, sym) + return fn, fn, nil +} + +// shapedMethodExpr returns the specified method on the given shaped +// type. +func shapedMethodExpr(pos src.XPos, obj *ir.Name, sym *types.Sym) *ir.SelectorExpr { + assert(obj.Op() == ir.OTYPE) + + typ := obj.Type() + assert(typ.HasShape()) + + method := func() *types.Field { + for _, method := range typ.Methods() { + if method.Sym == sym { + return method + } + } + + base.FatalfAt(pos, "failed to find method %v in shaped type %v", sym, typ) + panic("unreachable") + }() + + // Construct an OMETHEXPR node. + recv := method.Type.Recv().Type + return typecheck.NewMethodExpr(pos, recv, sym) +} + +func (r *reader) multiExpr() []ir.Node { + r.Sync(pkgbits.SyncMultiExpr) + + if r.Bool() { // N:1 + pos := r.pos() + expr := r.expr() + + results := make([]ir.Node, r.Len()) + as := ir.NewAssignListStmt(pos, ir.OAS2, nil, []ir.Node{expr}) + as.Def = true + for i := range results { + tmp := r.temp(pos, r.typ()) + tmp.Defn = as + as.PtrInit().Append(ir.NewDecl(pos, ir.ODCL, tmp)) + as.Lhs.Append(tmp) + + res := ir.Node(tmp) + if r.Bool() { + n := ir.NewConvExpr(pos, ir.OCONV, r.typ(), res) + n.TypeWord, n.SrcRType = r.convRTTI(pos) + n.SetImplicit(true) + res = typecheck.Expr(n) + } + results[i] = res + } + + // TODO(mdempsky): Could use ir.InlinedCallExpr instead? + results[0] = ir.InitExpr([]ir.Node{typecheck.Stmt(as)}, results[0]) + return results + } + + // N:N + exprs := make([]ir.Node, r.Len()) + if len(exprs) == 0 { + return nil + } + for i := range exprs { + exprs[i] = r.expr() + } + return exprs +} + +// temp returns a new autotemp of the specified type. +func (r *reader) temp(pos src.XPos, typ *types.Type) *ir.Name { + return typecheck.TempAt(pos, r.curfn, typ) +} + +// tempCopy declares and returns a new autotemp initialized to the +// value of expr. +func (r *reader) tempCopy(pos src.XPos, expr ir.Node, init *ir.Nodes) *ir.Name { + tmp := r.temp(pos, expr.Type()) + + init.Append(typecheck.Stmt(ir.NewDecl(pos, ir.ODCL, tmp))) + + assign := ir.NewAssignStmt(pos, tmp, expr) + assign.Def = true + init.Append(typecheck.Stmt(ir.NewAssignStmt(pos, tmp, expr))) + + tmp.Defn = assign + + return tmp +} + +func (r *reader) compLit() ir.Node { + r.Sync(pkgbits.SyncCompLit) + pos := r.pos() + typ0 := r.typ() + + typ := typ0 + if typ.IsPtr() { + typ = typ.Elem() + } + if typ.Kind() == types.TFORW { + base.FatalfAt(pos, "unresolved composite literal type: %v", typ) + } + var rtype ir.Node + if typ.IsMap() { + rtype = r.rtype(pos) + } + isStruct := typ.Kind() == types.TSTRUCT + + elems := make([]ir.Node, r.Len()) + for i := range elems { + elemp := &elems[i] + + if isStruct { + sk := ir.NewStructKeyExpr(r.pos(), typ.Field(r.Len()), nil) + *elemp, elemp = sk, &sk.Value + } else if r.Bool() { + kv := ir.NewKeyExpr(r.pos(), r.expr(), nil) + *elemp, elemp = kv, &kv.Value + } + + *elemp = r.expr() + } + + lit := typecheck.Expr(ir.NewCompLitExpr(pos, ir.OCOMPLIT, typ, elems)) + if rtype != nil { + lit := lit.(*ir.CompLitExpr) + lit.RType = rtype + } + if typ0.IsPtr() { + lit = typecheck.Expr(typecheck.NodAddrAt(pos, lit)) + lit.SetType(typ0) + } + return lit +} + +func (r *reader) funcLit() ir.Node { + r.Sync(pkgbits.SyncFuncLit) + + // The underlying function declaration (including its parameters' + // positions, if any) need to remain the original, uninlined + // positions. This is because we track inlining-context on nodes so + // we can synthesize the extra implied stack frames dynamically when + // generating tracebacks, whereas those stack frames don't make + // sense *within* the function literal. (Any necessary inlining + // adjustments will have been applied to the call expression + // instead.) + // + // This is subtle, and getting it wrong leads to cycles in the + // inlining tree, which lead to infinite loops during stack + // unwinding (#46234, #54625). + // + // Note that we *do* want the inline-adjusted position for the + // OCLOSURE node, because that position represents where any heap + // allocation of the closure is credited (#49171). + r.suppressInlPos++ + origPos := r.pos() + sig := r.signature(nil) + r.suppressInlPos-- + why := ir.OCLOSURE + if r.Bool() { + why = ir.ORANGE + } + + fn := r.inlClosureFunc(origPos, sig, why) + + fn.ClosureVars = make([]*ir.Name, 0, r.Len()) + for len(fn.ClosureVars) < cap(fn.ClosureVars) { + // TODO(mdempsky): I think these should be original positions too + // (i.e., not inline-adjusted). + ir.NewClosureVar(r.pos(), fn, r.useLocal()) + } + if param := r.dictParam; param != nil { + // If we have a dictionary parameter, capture it too. For + // simplicity, we capture it last and unconditionally. + ir.NewClosureVar(param.Pos(), fn, param) + } + + r.addBody(fn, nil) + + return fn.OClosure +} + +// inlClosureFunc constructs a new closure function, but correctly +// handles inlining. +func (r *reader) inlClosureFunc(origPos src.XPos, sig *types.Type, why ir.Op) *ir.Func { + curfn := r.inlCaller + if curfn == nil { + curfn = r.curfn + } + + // TODO(mdempsky): Remove hard-coding of typecheck.Target. + return ir.NewClosureFunc(origPos, r.inlPos(origPos), why, sig, curfn, typecheck.Target) +} + +func (r *reader) exprList() []ir.Node { + r.Sync(pkgbits.SyncExprList) + return r.exprs() +} + +func (r *reader) exprs() []ir.Node { + r.Sync(pkgbits.SyncExprs) + nodes := make([]ir.Node, r.Len()) + if len(nodes) == 0 { + return nil // TODO(mdempsky): Unclear if this matters. + } + for i := range nodes { + nodes[i] = r.expr() + } + return nodes +} + +// dictWord returns an expression to return the specified +// uintptr-typed word from the dictionary parameter. +func (r *reader) dictWord(pos src.XPos, idx int) ir.Node { + base.AssertfAt(r.dictParam != nil, pos, "expected dictParam in %v", r.curfn) + return typecheck.Expr(ir.NewIndexExpr(pos, r.dictParam, ir.NewInt(pos, int64(idx)))) +} + +// rttiWord is like dictWord, but converts it to *byte (the type used +// internally to represent *runtime._type and *runtime.itab). +func (r *reader) rttiWord(pos src.XPos, idx int) ir.Node { + return typecheck.Expr(ir.NewConvExpr(pos, ir.OCONVNOP, types.NewPtr(types.Types[types.TUINT8]), r.dictWord(pos, idx))) +} + +// rtype reads a type reference from the element bitstream, and +// returns an expression of type *runtime._type representing that +// type. +func (r *reader) rtype(pos src.XPos) ir.Node { + _, rtype := r.rtype0(pos) + return rtype +} + +func (r *reader) rtype0(pos src.XPos) (typ *types.Type, rtype ir.Node) { + r.Sync(pkgbits.SyncRType) + if r.Bool() { // derived type + idx := r.Len() + info := r.dict.rtypes[idx] + typ = r.p.typIdx(info, r.dict, true) + rtype = r.rttiWord(pos, r.dict.rtypesOffset()+idx) + return + } + + typ = r.typ() + rtype = reflectdata.TypePtrAt(pos, typ) + return +} + +// varDictIndex populates name.DictIndex if name is a derived type. +func (r *reader) varDictIndex(name *ir.Name) { + if r.Bool() { + idx := 1 + r.dict.rtypesOffset() + r.Len() + if int(uint16(idx)) != idx { + base.FatalfAt(name.Pos(), "DictIndex overflow for %v: %v", name, idx) + } + name.DictIndex = uint16(idx) + } +} + +// itab returns a (typ, iface) pair of types. +// +// typRType and ifaceRType are expressions that evaluate to the +// *runtime._type for typ and iface, respectively. +// +// If typ is a concrete type and iface is a non-empty interface type, +// then itab is an expression that evaluates to the *runtime.itab for +// the pair. Otherwise, itab is nil. +func (r *reader) itab(pos src.XPos) (typ *types.Type, typRType ir.Node, iface *types.Type, ifaceRType ir.Node, itab ir.Node) { + typ, typRType = r.rtype0(pos) + iface, ifaceRType = r.rtype0(pos) + + idx := -1 + if r.Bool() { + idx = r.Len() + } + + if !typ.IsInterface() && iface.IsInterface() && !iface.IsEmptyInterface() { + if idx >= 0 { + itab = r.rttiWord(pos, r.dict.itabsOffset()+idx) + } else { + base.AssertfAt(!typ.HasShape(), pos, "%v is a shape type", typ) + base.AssertfAt(!iface.HasShape(), pos, "%v is a shape type", iface) + + lsym := reflectdata.ITabLsym(typ, iface) + itab = typecheck.LinksymAddr(pos, lsym, types.Types[types.TUINT8]) + } + } + + return +} + +// convRTTI returns expressions appropriate for populating an +// ir.ConvExpr's TypeWord and SrcRType fields, respectively. +func (r *reader) convRTTI(pos src.XPos) (typeWord, srcRType ir.Node) { + r.Sync(pkgbits.SyncConvRTTI) + src, srcRType0, dst, dstRType, itab := r.itab(pos) + if !dst.IsInterface() { + return + } + + // See reflectdata.ConvIfaceTypeWord. + switch { + case dst.IsEmptyInterface(): + if !src.IsInterface() { + typeWord = srcRType0 // direct eface construction + } + case !src.IsInterface(): + typeWord = itab // direct iface construction + default: + typeWord = dstRType // convI2I + } + + // See reflectdata.ConvIfaceSrcRType. + if !src.IsInterface() { + srcRType = srcRType0 + } + + return +} + +func (r *reader) exprType() ir.Node { + r.Sync(pkgbits.SyncExprType) + pos := r.pos() + + var typ *types.Type + var rtype, itab ir.Node + + if r.Bool() { + // non-empty interface + typ, rtype, _, _, itab = r.itab(pos) + if !typ.IsInterface() { + rtype = nil // TODO(mdempsky): Leave set? + } + } else { + typ, rtype = r.rtype0(pos) + + if !r.Bool() { // not derived + return ir.TypeNode(typ) + } + } + + dt := ir.NewDynamicType(pos, rtype) + dt.ITab = itab + dt = typed(typ, dt).(*ir.DynamicType) + if st := dt.ToStatic(); st != nil { + return st + } + return dt +} + +func (r *reader) op() ir.Op { + r.Sync(pkgbits.SyncOp) + return ir.Op(r.Len()) +} + +// @@@ Package initialization + +func (r *reader) pkgInit(self *types.Pkg, target *ir.Package) { + cgoPragmas := make([][]string, r.Len()) + for i := range cgoPragmas { + cgoPragmas[i] = r.Strings() + } + target.CgoPragmas = cgoPragmas + + r.pkgInitOrder(target) + + r.pkgDecls(target) + + r.Sync(pkgbits.SyncEOF) +} + +// pkgInitOrder creates a synthetic init function to handle any +// package-scope initialization statements. +func (r *reader) pkgInitOrder(target *ir.Package) { + initOrder := make([]ir.Node, r.Len()) + if len(initOrder) == 0 { + return + } + + // Make a function that contains all the initialization statements. + pos := base.AutogeneratedPos + base.Pos = pos + + fn := ir.NewFunc(pos, pos, typecheck.Lookup("init"), types.NewSignature(nil, nil, nil)) + fn.SetIsPackageInit(true) + fn.SetInlinabilityChecked(true) // suppress useless "can inline" diagnostics + + typecheck.DeclFunc(fn) + r.curfn = fn + + for i := range initOrder { + lhs := make([]ir.Node, r.Len()) + for j := range lhs { + lhs[j] = r.obj() + } + rhs := r.expr() + pos := lhs[0].Pos() + + var as ir.Node + if len(lhs) == 1 { + as = typecheck.Stmt(ir.NewAssignStmt(pos, lhs[0], rhs)) + } else { + as = typecheck.Stmt(ir.NewAssignListStmt(pos, ir.OAS2, lhs, []ir.Node{rhs})) + } + + for _, v := range lhs { + v.(*ir.Name).Defn = as + } + + initOrder[i] = as + } + + fn.Body = initOrder + + typecheck.FinishFuncBody() + r.curfn = nil + r.locals = nil + + // Outline (if legal/profitable) global map inits. + staticinit.OutlineMapInits(fn) + + target.Inits = append(target.Inits, fn) +} + +func (r *reader) pkgDecls(target *ir.Package) { + r.Sync(pkgbits.SyncDecls) + for { + switch code := codeDecl(r.Code(pkgbits.SyncDecl)); code { + default: + panic(fmt.Sprintf("unhandled decl: %v", code)) + + case declEnd: + return + + case declFunc: + names := r.pkgObjs(target) + assert(len(names) == 1) + target.Funcs = append(target.Funcs, names[0].Func) + + case declMethod: + typ := r.typ() + sym := r.selector() + + method := typecheck.Lookdot1(nil, sym, typ, typ.Methods(), 0) + target.Funcs = append(target.Funcs, method.Nname.(*ir.Name).Func) + + case declVar: + names := r.pkgObjs(target) + + if n := r.Len(); n > 0 { + assert(len(names) == 1) + embeds := make([]ir.Embed, n) + for i := range embeds { + embeds[i] = ir.Embed{Pos: r.pos(), Patterns: r.Strings()} + } + names[0].Embed = &embeds + target.Embeds = append(target.Embeds, names[0]) + } + + case declOther: + r.pkgObjs(target) + } + } +} + +func (r *reader) pkgObjs(target *ir.Package) []*ir.Name { + r.Sync(pkgbits.SyncDeclNames) + nodes := make([]*ir.Name, r.Len()) + for i := range nodes { + r.Sync(pkgbits.SyncDeclName) + + name := r.obj().(*ir.Name) + nodes[i] = name + + sym := name.Sym() + if sym.IsBlank() { + continue + } + + switch name.Class { + default: + base.FatalfAt(name.Pos(), "unexpected class: %v", name.Class) + + case ir.PEXTERN: + target.Externs = append(target.Externs, name) + + case ir.PFUNC: + assert(name.Type().Recv() == nil) + + // TODO(mdempsky): Cleaner way to recognize init? + if strings.HasPrefix(sym.Name, "init.") { + target.Inits = append(target.Inits, name.Func) + } + } + + if base.Ctxt.Flag_dynlink && types.LocalPkg.Name == "main" && types.IsExported(sym.Name) && name.Op() == ir.ONAME { + assert(!sym.OnExportList()) + target.PluginExports = append(target.PluginExports, name) + sym.SetOnExportList(true) + } + + if base.Flag.AsmHdr != "" && (name.Op() == ir.OLITERAL || name.Op() == ir.OTYPE) { + assert(!sym.Asm()) + target.AsmHdrDecls = append(target.AsmHdrDecls, name) + sym.SetAsm(true) + } + } + + return nodes +} + +// @@@ Inlining + +// unifiedHaveInlineBody reports whether we have the function body for +// fn, so we can inline it. +func unifiedHaveInlineBody(fn *ir.Func) bool { + if fn.Inl == nil { + return false + } + + _, ok := bodyReaderFor(fn) + return ok +} + +var inlgen = 0 + +// unifiedInlineCall implements inline.NewInline by re-reading the function +// body from its Unified IR export data. +func unifiedInlineCall(callerfn *ir.Func, call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExpr { + pri, ok := bodyReaderFor(fn) + if !ok { + base.FatalfAt(call.Pos(), "cannot inline call to %v: missing inline body", fn) + } + + if !fn.Inl.HaveDcl { + expandInline(fn, pri) + } + + r := pri.asReader(pkgbits.SectionBody, pkgbits.SyncFuncBody) + + tmpfn := ir.NewFunc(fn.Pos(), fn.Nname.Pos(), callerfn.Sym(), fn.Type()) + + r.curfn = tmpfn + + r.inlCaller = callerfn + r.inlCall = call + r.inlFunc = fn + r.inlTreeIndex = inlIndex + r.inlPosBases = make(map[*src.PosBase]*src.PosBase) + r.funarghack = true + + r.closureVars = make([]*ir.Name, len(r.inlFunc.ClosureVars)) + for i, cv := range r.inlFunc.ClosureVars { + // TODO(mdempsky): It should be possible to support this case, but + // for now we rely on the inliner avoiding it. + if cv.Outer.Curfn != callerfn { + base.FatalfAt(call.Pos(), "inlining closure call across frames") + } + r.closureVars[i] = cv.Outer + } + if len(r.closureVars) != 0 && r.hasTypeParams() { + r.dictParam = r.closureVars[len(r.closureVars)-1] // dictParam is last; see reader.funcLit + } + + r.declareParams() + + var inlvars, retvars []*ir.Name + { + sig := r.curfn.Type() + endParams := sig.NumRecvs() + sig.NumParams() + endResults := endParams + sig.NumResults() + + inlvars = r.curfn.Dcl[:endParams] + retvars = r.curfn.Dcl[endParams:endResults] + } + + r.delayResults = fn.Inl.CanDelayResults + + r.retlabel = typecheck.AutoLabel(".i") + inlgen++ + + init := ir.TakeInit(call) + + // For normal function calls, the function callee expression + // may contain side effects. Make sure to preserve these, + // if necessary (#42703). + if call.Op() == ir.OCALLFUNC { + inline.CalleeEffects(&init, call.Fun) + } + + var args ir.Nodes + if call.Op() == ir.OCALLMETH { + base.FatalfAt(call.Pos(), "OCALLMETH missed by typecheck") + } + args.Append(call.Args...) + + // Create assignment to declare and initialize inlvars. + as2 := ir.NewAssignListStmt(call.Pos(), ir.OAS2, ir.ToNodes(inlvars), args) + as2.Def = true + var as2init ir.Nodes + for _, name := range inlvars { + if ir.IsBlank(name) { + continue + } + // TODO(mdempsky): Use inlined position of name.Pos() instead? + as2init.Append(ir.NewDecl(call.Pos(), ir.ODCL, name)) + name.Defn = as2 + } + as2.SetInit(as2init) + init.Append(typecheck.Stmt(as2)) + + if !r.delayResults { + // If not delaying retvars, declare and zero initialize the + // result variables now. + for _, name := range retvars { + // TODO(mdempsky): Use inlined position of name.Pos() instead? + init.Append(ir.NewDecl(call.Pos(), ir.ODCL, name)) + ras := ir.NewAssignStmt(call.Pos(), name, nil) + init.Append(typecheck.Stmt(ras)) + } + } + + // Add an inline mark just before the inlined body. + // This mark is inline in the code so that it's a reasonable spot + // to put a breakpoint. Not sure if that's really necessary or not + // (in which case it could go at the end of the function instead). + // Note issue 28603. + init.Append(ir.NewInlineMarkStmt(call.Pos().WithIsStmt(), int64(r.inlTreeIndex))) + + ir.WithFunc(r.curfn, func() { + if !r.syntheticBody(call.Pos()) { + assert(r.Bool()) // have body + + r.curfn.Body = r.stmts() + r.curfn.Endlineno = r.pos() + } + + // TODO(mdempsky): This shouldn't be necessary. Inlining might + // read in new function/method declarations, which could + // potentially be recursively inlined themselves; but we shouldn't + // need to read in the non-inlined bodies for the declarations + // themselves. But currently it's an easy fix to #50552. + readBodies(typecheck.Target, true) + + // Replace any "return" statements within the function body. + var edit func(ir.Node) ir.Node + edit = func(n ir.Node) ir.Node { + if ret, ok := n.(*ir.ReturnStmt); ok { + n = typecheck.Stmt(r.inlReturn(ret, retvars)) + } + ir.EditChildren(n, edit) + return n + } + edit(r.curfn) + }) + + body := r.curfn.Body + + // Reparent any declarations into the caller function. + for _, name := range r.curfn.Dcl { + name.Curfn = callerfn + + if name.Class != ir.PAUTO { + name.SetPos(r.inlPos(name.Pos())) + name.SetInlFormal(true) + name.Class = ir.PAUTO + } else { + name.SetInlLocal(true) + } + } + callerfn.Dcl = append(callerfn.Dcl, r.curfn.Dcl...) + + body.Append(ir.NewLabelStmt(call.Pos(), r.retlabel)) + + res := ir.NewInlinedCallExpr(call.Pos(), body, ir.ToNodes(retvars)) + res.SetInit(init) + res.SetType(call.Type()) + res.SetTypecheck(1) + + // Inlining shouldn't add any functions to todoBodies. + assert(len(todoBodies) == 0) + + return res +} + +// inlReturn returns a statement that can substitute for the given +// return statement when inlining. +func (r *reader) inlReturn(ret *ir.ReturnStmt, retvars []*ir.Name) *ir.BlockStmt { + pos := r.inlCall.Pos() + + block := ir.TakeInit(ret) + + if results := ret.Results; len(results) != 0 { + assert(len(retvars) == len(results)) + + as2 := ir.NewAssignListStmt(pos, ir.OAS2, ir.ToNodes(retvars), ret.Results) + + if r.delayResults { + for _, name := range retvars { + // TODO(mdempsky): Use inlined position of name.Pos() instead? + block.Append(ir.NewDecl(pos, ir.ODCL, name)) + name.Defn = as2 + } + } + + block.Append(as2) + } + + block.Append(ir.NewBranchStmt(pos, ir.OGOTO, r.retlabel)) + return ir.NewBlockStmt(pos, block) +} + +// expandInline reads in an extra copy of IR to populate +// fn.Inl.Dcl. +func expandInline(fn *ir.Func, pri pkgReaderIndex) { + // TODO(mdempsky): Remove this function. It's currently needed by + // dwarfgen/dwarf.go:preInliningDcls, which requires fn.Inl.Dcl to + // create abstract function DIEs. But we should be able to provide it + // with the same information some other way. + + fndcls := len(fn.Dcl) + topdcls := len(typecheck.Target.Funcs) + + tmpfn := ir.NewFunc(fn.Pos(), fn.Nname.Pos(), fn.Sym(), fn.Type()) + tmpfn.ClosureVars = fn.ClosureVars + + { + r := pri.asReader(pkgbits.SectionBody, pkgbits.SyncFuncBody) + + // Don't change parameter's Sym/Nname fields. + r.funarghack = true + + r.funcBody(tmpfn) + } + + // Move tmpfn's params to fn.Inl.Dcl, and reparent under fn. + for _, name := range tmpfn.Dcl { + name.Curfn = fn + } + fn.Inl.Dcl = tmpfn.Dcl + fn.Inl.HaveDcl = true + + // Double check that we didn't change fn.Dcl by accident. + assert(fndcls == len(fn.Dcl)) + + // typecheck.Stmts may have added function literals to + // typecheck.Target.Decls. Remove them again so we don't risk trying + // to compile them multiple times. + typecheck.Target.Funcs = typecheck.Target.Funcs[:topdcls] +} + +// @@@ Method wrappers +// +// Here we handle constructing "method wrappers," alternative entry +// points that adapt methods to different calling conventions. Given a +// user-declared method "func (T) M(i int) bool { ... }", there are a +// few wrappers we may need to construct: +// +// - Implicit dereferencing. Methods declared with a value receiver T +// are also included in the method set of the pointer type *T, so +// we need to construct a wrapper like "func (recv *T) M(i int) +// bool { return (*recv).M(i) }". +// +// - Promoted methods. If struct type U contains an embedded field of +// type T or *T, we need to construct a wrapper like "func (recv U) +// M(i int) bool { return recv.T.M(i) }". +// +// - Method values. If x is an expression of type T, then "x.M" is +// roughly "tmp := x; func(i int) bool { return tmp.M(i) }". +// +// At call sites, we always prefer to call the user-declared method +// directly, if known, so wrappers are only needed for indirect calls +// (for example, interface method calls that can't be devirtualized). +// Consequently, we can save some compile time by skipping +// construction of wrappers that are never needed. +// +// Alternatively, because the linker doesn't care which compilation +// unit constructed a particular wrapper, we can instead construct +// them as needed. However, if a wrapper is needed in multiple +// downstream packages, we may end up needing to compile it multiple +// times, costing us more compile time and object file size. (We mark +// the wrappers as DUPOK, so the linker doesn't complain about the +// duplicate symbols.) +// +// The current heuristics we use to balance these trade offs are: +// +// - For a (non-parameterized) defined type T, we construct wrappers +// for *T and any promoted methods on T (and *T) in the same +// compilation unit as the type declaration. +// +// - For a parameterized defined type, we construct wrappers in the +// compilation units in which the type is instantiated. We +// similarly handle wrappers for anonymous types with methods and +// compilation units where their type literals appear in source. +// +// - Method value expressions are relatively uncommon, so we +// construct their wrappers in the compilation units that they +// appear in. +// +// Finally, as an opportunistic compile-time optimization, if we know +// a wrapper was constructed in any imported package's compilation +// unit, then we skip constructing a duplicate one. However, currently +// this is only done on a best-effort basis. + +// needWrapperTypes lists types for which we may need to generate +// method wrappers. +var needWrapperTypes []*types.Type + +// haveWrapperTypes lists types for which we know we already have +// method wrappers, because we found the type in an imported package. +var haveWrapperTypes []*types.Type + +// needMethodValueWrappers lists methods for which we may need to +// generate method value wrappers. +var needMethodValueWrappers []methodValueWrapper + +// haveMethodValueWrappers lists methods for which we know we already +// have method value wrappers, because we found it in an imported +// package. +var haveMethodValueWrappers []methodValueWrapper + +type methodValueWrapper struct { + rcvr *types.Type + method *types.Field +} + +// needWrapper records that wrapper methods may be needed at link +// time. +func (r *reader) needWrapper(typ *types.Type) { + if typ.IsPtr() { + return + } + + // Special case: runtime must define error even if imported packages mention it (#29304). + forceNeed := typ == types.ErrorType && base.Ctxt.Pkgpath == "runtime" + + // If a type was found in an imported package, then we can assume + // that package (or one of its transitive dependencies) already + // generated method wrappers for it. + if r.importedDef() && !forceNeed { + haveWrapperTypes = append(haveWrapperTypes, typ) + } else { + needWrapperTypes = append(needWrapperTypes, typ) + } +} + +// importedDef reports whether r is reading from an imported and +// non-generic element. +// +// If a type was found in an imported package, then we can assume that +// package (or one of its transitive dependencies) already generated +// method wrappers for it. +// +// Exception: If we're instantiating an imported generic type or +// function, we might be instantiating it with type arguments not +// previously seen before. +// +// TODO(mdempsky): Distinguish when a generic function or type was +// instantiated in an imported package so that we can add types to +// haveWrapperTypes instead. +func (r *reader) importedDef() bool { + return r.p != localPkgReader && !r.hasTypeParams() +} + +// MakeWrappers constructs all wrapper methods needed for the target +// compilation unit. +func MakeWrappers(target *ir.Package) { + // always generate a wrapper for error.Error (#29304) + needWrapperTypes = append(needWrapperTypes, types.ErrorType) + + seen := make(map[string]*types.Type) + + for _, typ := range haveWrapperTypes { + wrapType(typ, target, seen, false) + } + haveWrapperTypes = nil + + for _, typ := range needWrapperTypes { + wrapType(typ, target, seen, true) + } + needWrapperTypes = nil + + for _, wrapper := range haveMethodValueWrappers { + wrapMethodValue(wrapper.rcvr, wrapper.method, target, false) + } + haveMethodValueWrappers = nil + + for _, wrapper := range needMethodValueWrappers { + wrapMethodValue(wrapper.rcvr, wrapper.method, target, true) + } + needMethodValueWrappers = nil +} + +func wrapType(typ *types.Type, target *ir.Package, seen map[string]*types.Type, needed bool) { + key := typ.LinkString() + if prev := seen[key]; prev != nil { + if !types.Identical(typ, prev) { + base.Fatalf("collision: types %v and %v have link string %q", typ, prev, key) + } + return + } + seen[key] = typ + + if !needed { + // Only called to add to 'seen'. + return + } + + if !typ.IsInterface() { + typecheck.CalcMethods(typ) + } + for _, meth := range typ.AllMethods() { + if meth.Sym.IsBlank() || !meth.IsMethod() { + base.FatalfAt(meth.Pos, "invalid method: %v", meth) + } + + methodWrapper(0, typ, meth, target) + + // For non-interface types, we also want *T wrappers. + if !typ.IsInterface() { + methodWrapper(1, typ, meth, target) + + // For not-in-heap types, *T is a scalar, not pointer shaped, + // so the interface wrappers use **T. + if typ.NotInHeap() { + methodWrapper(2, typ, meth, target) + } + } + } +} + +func methodWrapper(derefs int, tbase *types.Type, method *types.Field, target *ir.Package) { + wrapper := tbase + for i := 0; i < derefs; i++ { + wrapper = types.NewPtr(wrapper) + } + + sym := ir.MethodSym(wrapper, method.Sym) + base.Assertf(!sym.Siggen(), "already generated wrapper %v", sym) + sym.SetSiggen(true) + + wrappee := method.Type.Recv().Type + if types.Identical(wrapper, wrappee) || + !types.IsMethodApplicable(wrapper, method) || + !reflectdata.NeedEmit(tbase) { + return + } + + // TODO(mdempsky): Use method.Pos instead? + pos := base.AutogeneratedPos + + fn := newWrapperFunc(pos, sym, wrapper, method) + + var recv ir.Node = fn.Nname.Type().Recv().Nname.(*ir.Name) + + // For simple *T wrappers around T methods, panicwrap produces a + // nicer panic message. + if wrapper.IsPtr() && types.Identical(wrapper.Elem(), wrappee) { + cond := ir.NewBinaryExpr(pos, ir.OEQ, recv, types.BuiltinPkg.Lookup("nil").Def.(ir.Node)) + then := []ir.Node{ir.NewCallExpr(pos, ir.OCALL, typecheck.LookupRuntime("panicwrap"), nil)} + fn.Body.Append(ir.NewIfStmt(pos, cond, then, nil)) + } + + // typecheck will add one implicit deref, if necessary, + // but not-in-heap types require more for their **T wrappers. + for i := 1; i < derefs; i++ { + recv = Implicit(ir.NewStarExpr(pos, recv)) + } + + addTailCall(pos, fn, recv, method) + + finishWrapperFunc(fn, target) +} + +func wrapMethodValue(recvType *types.Type, method *types.Field, target *ir.Package, needed bool) { + sym := ir.MethodSymSuffix(recvType, method.Sym, "-fm") + if sym.Uniq() { + return + } + sym.SetUniq(true) + + // TODO(mdempsky): Use method.Pos instead? + pos := base.AutogeneratedPos + + fn := newWrapperFunc(pos, sym, nil, method) + sym.Def = fn.Nname + + // Declare and initialize variable holding receiver. + recv := ir.NewHiddenParam(pos, fn, typecheck.Lookup(".this"), recvType) + + if !needed { + return + } + + addTailCall(pos, fn, recv, method) + + finishWrapperFunc(fn, target) +} + +func newWrapperFunc(pos src.XPos, sym *types.Sym, wrapper *types.Type, method *types.Field) *ir.Func { + sig := newWrapperType(wrapper, method) + fn := ir.NewFunc(pos, pos, sym, sig) + fn.DeclareParams(true) + fn.SetDupok(true) // TODO(mdempsky): Leave unset for local, non-generic wrappers? + + return fn +} + +func finishWrapperFunc(fn *ir.Func, target *ir.Package) { + ir.WithFunc(fn, func() { + typecheck.Stmts(fn.Body) + }) + + // We generate wrappers after the global inlining pass, + // so we're responsible for applying inlining ourselves here. + // TODO(prattmic): plumb PGO. + interleaved.DevirtualizeAndInlineFunc(fn, nil) + + // The body of wrapper function after inlining may reveal new ir.OMETHVALUE node, + // we don't know whether wrapper function has been generated for it or not, so + // generate one immediately here. + // + // Further, after CL 492017, function that construct closures is allowed to be inlined, + // even though the closure itself can't be inline. So we also need to visit body of any + // closure that we see when visiting body of the wrapper function. + ir.VisitFuncAndClosures(fn, func(n ir.Node) { + if n, ok := n.(*ir.SelectorExpr); ok && n.Op() == ir.OMETHVALUE { + wrapMethodValue(n.X.Type(), n.Selection, target, true) + } + }) + + fn.Nname.Defn = fn + target.Funcs = append(target.Funcs, fn) +} + +// newWrapperType returns a copy of the given signature type, but with +// the receiver parameter type substituted with recvType. +// If recvType is nil, newWrapperType returns a signature +// without a receiver parameter. +func newWrapperType(recvType *types.Type, method *types.Field) *types.Type { + clone := func(params []*types.Field) []*types.Field { + res := make([]*types.Field, len(params)) + for i, param := range params { + res[i] = types.NewField(param.Pos, param.Sym, param.Type) + res[i].SetIsDDD(param.IsDDD()) + } + return res + } + + sig := method.Type + + var recv *types.Field + if recvType != nil { + recv = types.NewField(sig.Recv().Pos, sig.Recv().Sym, recvType) + } + params := clone(sig.Params()) + results := clone(sig.Results()) + + return types.NewSignature(recv, params, results) +} + +func addTailCall(pos src.XPos, fn *ir.Func, recv ir.Node, method *types.Field) { + sig := fn.Nname.Type() + args := make([]ir.Node, sig.NumParams()) + for i, param := range sig.Params() { + args[i] = param.Nname.(*ir.Name) + } + + dot := typecheck.XDotMethod(pos, recv, method.Sym, true) + call := typecheck.Call(pos, dot, args, method.Type.IsVariadic()).(*ir.CallExpr) + + if recv.Type() != nil && recv.Type().IsPtr() && method.Type.Recv().Type.IsPtr() && + method.Embedded != 0 && !types.IsInterfaceMethod(method.Type) && + !unifiedHaveInlineBody(ir.MethodExprName(dot).Func) && + !(base.Ctxt.Arch.Name == "ppc64le" && base.Ctxt.Flag_dynlink) { + if base.Debug.TailCall != 0 { + base.WarnfAt(fn.Nname.Type().Recv().Type.Elem().Pos(), "tail call emitted for the method %v wrapper", method.Nname) + } + // Prefer OTAILCALL to reduce code size (except the case when the called method can be inlined). + fn.Body.Append(ir.NewTailCallStmt(pos, call)) + return + } + + fn.SetWrapper(true) + + if method.Type.NumResults() == 0 { + fn.Body.Append(call) + return + } + + ret := ir.NewReturnStmt(pos, nil) + ret.Results = []ir.Node{call} + fn.Body.Append(ret) +} + +func setBasePos(pos src.XPos) { + // Set the position for any error messages we might print (e.g. too large types). + base.Pos = pos +} + +// dictParamName is the name of the synthetic dictionary parameter +// added to shaped functions. +// +// N.B., this variable name is known to Delve: +// https://github.com/go-delve/delve/blob/cb91509630529e6055be845688fd21eb89ae8714/pkg/proc/eval.go#L28 +const dictParamName = typecheck.LocalDictName + +// shapeSig returns a copy of fn's signature, except adding a +// dictionary parameter and promoting the receiver parameter (if any) +// to a normal parameter. +// +// The parameter types.Fields are all copied too, so their Nname +// fields can be initialized for use by the shape function. +func shapeSig(fn *ir.Func, dict *readerDict) *types.Type { + sig := fn.Nname.Type() + oldRecv := sig.Recv() + + var recv *types.Field + if oldRecv != nil { + recv = types.NewField(oldRecv.Pos, oldRecv.Sym, oldRecv.Type) + } + + params := make([]*types.Field, 1+sig.NumParams()) + params[0] = types.NewField(fn.Pos(), fn.Sym().Pkg.Lookup(dictParamName), types.NewPtr(dict.varType())) + for i, param := range sig.Params() { + d := types.NewField(param.Pos, param.Sym, param.Type) + d.SetIsDDD(param.IsDDD()) + params[1+i] = d + } + + results := make([]*types.Field, sig.NumResults()) + for i, result := range sig.Results() { + results[i] = types.NewField(result.Pos, result.Sym, result.Type) + } + + return types.NewSignature(recv, params, results) +} diff --git a/go/src/cmd/compile/internal/noder/types.go b/go/src/cmd/compile/internal/noder/types.go new file mode 100644 index 0000000000000000000000000000000000000000..76c6d15dd83357bacade5c2182e6c1063e15343f --- /dev/null +++ b/go/src/cmd/compile/internal/noder/types.go @@ -0,0 +1,53 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "cmd/compile/internal/types" + "cmd/compile/internal/types2" +) + +var basics = [...]**types.Type{ + types2.Invalid: new(*types.Type), + types2.Bool: &types.Types[types.TBOOL], + types2.Int: &types.Types[types.TINT], + types2.Int8: &types.Types[types.TINT8], + types2.Int16: &types.Types[types.TINT16], + types2.Int32: &types.Types[types.TINT32], + types2.Int64: &types.Types[types.TINT64], + types2.Uint: &types.Types[types.TUINT], + types2.Uint8: &types.Types[types.TUINT8], + types2.Uint16: &types.Types[types.TUINT16], + types2.Uint32: &types.Types[types.TUINT32], + types2.Uint64: &types.Types[types.TUINT64], + types2.Uintptr: &types.Types[types.TUINTPTR], + types2.Float32: &types.Types[types.TFLOAT32], + types2.Float64: &types.Types[types.TFLOAT64], + types2.Complex64: &types.Types[types.TCOMPLEX64], + types2.Complex128: &types.Types[types.TCOMPLEX128], + types2.String: &types.Types[types.TSTRING], + types2.UnsafePointer: &types.Types[types.TUNSAFEPTR], + types2.UntypedBool: &types.UntypedBool, + types2.UntypedInt: &types.UntypedInt, + types2.UntypedRune: &types.UntypedRune, + types2.UntypedFloat: &types.UntypedFloat, + types2.UntypedComplex: &types.UntypedComplex, + types2.UntypedString: &types.UntypedString, + types2.UntypedNil: &types.Types[types.TNIL], +} + +var dirs = [...]types.ChanDir{ + types2.SendRecv: types.Cboth, + types2.SendOnly: types.Csend, + types2.RecvOnly: types.Crecv, +} + +// deref2 does a single deref of types2 type t, if it is a pointer type. +func deref2(t types2.Type) types2.Type { + if ptr := types2.AsPointer(t); ptr != nil { + t = ptr.Elem() + } + return t +} diff --git a/go/src/cmd/compile/internal/noder/unified.go b/go/src/cmd/compile/internal/noder/unified.go new file mode 100644 index 0000000000000000000000000000000000000000..05f4483d0d9f284b57514b768ecf5ca7a5f034f8 --- /dev/null +++ b/go/src/cmd/compile/internal/noder/unified.go @@ -0,0 +1,571 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "cmp" + "fmt" + "internal/pkgbits" + "internal/types/errors" + "io" + "runtime" + "slices" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/inline" + "cmd/compile/internal/ir" + "cmd/compile/internal/pgoir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/compile/internal/types2" + "cmd/internal/src" +) + +// localPkgReader holds the package reader used for reading the local +// package. It exists so the unified IR linker can refer back to it +// later. +var localPkgReader *pkgReader + +// LookupFunc returns the ir.Func for an arbitrary full symbol name if +// that function exists in the set of available export data. +// +// This allows lookup of arbitrary functions and methods that aren't otherwise +// referenced by the local package and thus haven't been read yet. +// +// TODO(prattmic): Does not handle instantiation of generic types. Currently +// profiles don't contain the original type arguments, so we won't be able to +// create the runtime dictionaries. +// +// TODO(prattmic): Hit rate of this function is usually fairly low, and errors +// are only used when debug logging is enabled. Consider constructing cheaper +// errors by default. +func LookupFunc(fullName string) (*ir.Func, error) { + pkgPath, symName, err := ir.ParseLinkFuncName(fullName) + if err != nil { + return nil, fmt.Errorf("error parsing symbol name %q: %v", fullName, err) + } + + pkg, ok := types.PkgMap()[pkgPath] + if !ok { + return nil, fmt.Errorf("pkg %s doesn't exist in %v", pkgPath, types.PkgMap()) + } + + // Symbol naming is ambiguous. We can't necessarily distinguish between + // a method and a closure. e.g., is foo.Bar.func1 a closure defined in + // function Bar, or a method on type Bar? Thus we must simply attempt + // to lookup both. + + fn, err := lookupFunction(pkg, symName) + if err == nil { + return fn, nil + } + + fn, mErr := lookupMethod(pkg, symName) + if mErr == nil { + return fn, nil + } + + return nil, fmt.Errorf("%s is not a function (%v) or method (%v)", fullName, err, mErr) +} + +// PostLookupCleanup performs cleanup operations needed +// after a series of calls to LookupFunc, specifically invoking +// readBodies to post-process any funcs on the "todoBodies" list +// that were added as a result of the lookup operations. +func PostLookupCleanup() { + readBodies(typecheck.Target, false) +} + +func lookupFunction(pkg *types.Pkg, symName string) (*ir.Func, error) { + sym := pkg.Lookup(symName) + + // TODO(prattmic): Enclosed functions (e.g., foo.Bar.func1) are not + // present in objReader, only as OCLOSURE nodes in the enclosing + // function. + pri, ok := objReader[sym] + if !ok { + return nil, fmt.Errorf("func sym %v missing objReader", sym) + } + + node, err := pri.pr.objIdxMayFail(pri.idx, nil, nil, false) + if err != nil { + return nil, fmt.Errorf("func sym %v lookup error: %w", sym, err) + } + name := node.(*ir.Name) + if name.Op() != ir.ONAME || name.Class != ir.PFUNC { + return nil, fmt.Errorf("func sym %v refers to non-function name: %v", sym, name) + } + return name.Func, nil +} + +func lookupMethod(pkg *types.Pkg, symName string) (*ir.Func, error) { + // N.B. readPackage creates a Sym for every object in the package to + // initialize objReader and importBodyReader, even if the object isn't + // read. + // + // However, objReader is only initialized for top-level objects, so we + // must first lookup the type and use that to find the method rather + // than looking for the method directly. + typ, meth, err := ir.LookupMethodSelector(pkg, symName) + if err != nil { + return nil, fmt.Errorf("error looking up method symbol %q: %v", symName, err) + } + + pri, ok := objReader[typ] + if !ok { + return nil, fmt.Errorf("type sym %v missing objReader", typ) + } + + node, err := pri.pr.objIdxMayFail(pri.idx, nil, nil, false) + if err != nil { + return nil, fmt.Errorf("func sym %v lookup error: %w", typ, err) + } + name := node.(*ir.Name) + if name.Op() != ir.OTYPE { + return nil, fmt.Errorf("type sym %v refers to non-type name: %v", typ, name) + } + if name.Alias() { + return nil, fmt.Errorf("type sym %v refers to alias", typ) + } + if name.Type().IsInterface() { + return nil, fmt.Errorf("type sym %v refers to interface type", typ) + } + + for _, m := range name.Type().Methods() { + if m.Sym == meth { + fn := m.Nname.(*ir.Name).Func + return fn, nil + } + } + + return nil, fmt.Errorf("method %s missing from method set of %v", symName, typ) +} + +// unified constructs the local package's Internal Representation (IR) +// from its syntax tree (AST). +// +// The pipeline contains 2 steps: +// +// 1. Generate the export data "stub". +// +// 2. Generate the IR from the export data above. +// +// The package data "stub" at step (1) contains everything from the local package, +// but nothing that has been imported. When we're actually writing out export data +// to the output files (see writeNewExport), we run the "linker", which: +// +// - Updates compiler extensions data (e.g. inlining cost, escape analysis results). +// +// - Handles re-exporting any transitive dependencies. +// +// - Prunes out any unnecessary details (e.g. non-inlineable functions, because any +// downstream importers only care about inlinable functions). +// +// The source files are typechecked twice: once before writing the export data +// using types2, and again after reading the export data using gc/typecheck. +// The duplication of work will go away once we only use the types2 type checker, +// removing the gc/typecheck step. For now, it is kept because: +// +// - It reduces the engineering costs in maintaining a fork of typecheck +// (e.g. no need to backport fixes like CL 327651). +// +// - It makes it easier to pass toolstash -cmp. +// +// - Historically, we would always re-run the typechecker after importing a package, +// even though we know the imported data is valid. It's not ideal, but it's +// not causing any problems either. +// +// - gc/typecheck is still in charge of some transformations, such as rewriting +// multi-valued function calls or transforming ir.OINDEX to ir.OINDEXMAP. +// +// Using the syntax tree with types2, which has a complete representation of generics, +// the unified IR has the full typed AST needed for introspection during step (1). +// In other words, we have all the necessary information to build the generic IR form +// (see writer.captureVars for an example). +func unified(m posMap, noders []*noder) { + inline.InlineCall = unifiedInlineCall + typecheck.HaveInlineBody = unifiedHaveInlineBody + pgoir.LookupFunc = LookupFunc + pgoir.PostLookupCleanup = PostLookupCleanup + + data := writePkgStub(m, noders) + + target := typecheck.Target + + localPkgReader = newPkgReader(pkgbits.NewPkgDecoder(types.LocalPkg.Path, data)) + readPackage(localPkgReader, types.LocalPkg, true) + + r := localPkgReader.newReader(pkgbits.SectionMeta, pkgbits.PrivateRootIdx, pkgbits.SyncPrivate) + r.pkgInit(types.LocalPkg, target) + + readBodies(target, false) + + // Check that nothing snuck past typechecking. + for _, fn := range target.Funcs { + if fn.Typecheck() == 0 { + base.FatalfAt(fn.Pos(), "missed typecheck: %v", fn) + } + + // For functions, check that at least their first statement (if + // any) was typechecked too. + if len(fn.Body) != 0 { + if stmt := fn.Body[0]; stmt.Typecheck() == 0 { + base.FatalfAt(stmt.Pos(), "missed typecheck: %v", stmt) + } + } + } + + // For functions originally came from package runtime, + // mark as norace to prevent instrumenting, see issue #60439. + for _, fn := range target.Funcs { + if !base.Flag.CompilingRuntime && types.RuntimeSymName(fn.Sym()) != "" { + fn.Pragma |= ir.Norace + } + } + + base.ExitIfErrors() // just in case +} + +// readBodies iteratively expands all pending dictionaries and +// function bodies. +// +// If duringInlining is true, then the inline.InlineDecls is called as +// necessary on instantiations of imported generic functions, so their +// inlining costs can be computed. +func readBodies(target *ir.Package, duringInlining bool) { + var inlDecls []*ir.Func + + // Don't use range--bodyIdx can add closures to todoBodies. + for { + // The order we expand dictionaries and bodies doesn't matter, so + // pop from the end to reduce todoBodies reallocations if it grows + // further. + // + // However, we do at least need to flush any pending dictionaries + // before reading bodies, because bodies might reference the + // dictionaries. + + if len(todoDicts) > 0 { + fn := todoDicts[len(todoDicts)-1] + todoDicts = todoDicts[:len(todoDicts)-1] + fn() + continue + } + + if len(todoBodies) > 0 { + fn := todoBodies[len(todoBodies)-1] + todoBodies = todoBodies[:len(todoBodies)-1] + + pri, ok := bodyReader[fn] + assert(ok) + pri.funcBody(fn) + + // Instantiated generic function: add to Decls for typechecking + // and compilation. + if fn.OClosure == nil && len(pri.dict.targs) != 0 { + // cmd/link does not support a type symbol referencing a method symbol + // across DSO boundary, so force re-compiling methods on a generic type + // even it was seen from imported package in linkshared mode, see #58966. + canSkipNonGenericMethod := !(base.Ctxt.Flag_linkshared && ir.IsMethod(fn)) + if duringInlining && canSkipNonGenericMethod { + inlDecls = append(inlDecls, fn) + } else { + target.Funcs = append(target.Funcs, fn) + } + } + + continue + } + + break + } + + todoDicts = nil + todoBodies = nil + + if len(inlDecls) != 0 { + // If we instantiated any generic functions during inlining, we need + // to call CanInline on them so they'll be transitively inlined + // correctly (#56280). + // + // We know these functions were already compiled in an imported + // package though, so we don't need to actually apply InlineCalls or + // save the function bodies any further than this. + // + // We can also lower the -m flag to 0, to suppress duplicate "can + // inline" diagnostics reported against the imported package. Again, + // we already reported those diagnostics in the original package, so + // it's pointless repeating them here. + + oldLowerM := base.Flag.LowerM + base.Flag.LowerM = 0 + inline.CanInlineFuncs(inlDecls, nil) + base.Flag.LowerM = oldLowerM + + for _, fn := range inlDecls { + fn.Body = nil // free memory + } + } +} + +// writePkgStub type checks the given parsed source files, +// writes an export data package stub representing them, +// and returns the result. +func writePkgStub(m posMap, noders []*noder) string { + pkg, info, otherInfo := checkFiles(m, noders) + + pw := newPkgWriter(m, pkg, info, otherInfo) + + pw.collectDecls(noders) + + publicRootWriter := pw.newWriter(pkgbits.SectionMeta, pkgbits.SyncPublic) + privateRootWriter := pw.newWriter(pkgbits.SectionMeta, pkgbits.SyncPrivate) + + assert(publicRootWriter.Idx == pkgbits.PublicRootIdx) + assert(privateRootWriter.Idx == pkgbits.PrivateRootIdx) + + { + w := publicRootWriter + w.pkg(pkg) + + if w.Version().Has(pkgbits.HasInit) { + w.Bool(false) + } + + scope := pkg.Scope() + names := scope.Names() + w.Len(len(names)) + for _, name := range names { + w.obj(scope.Lookup(name), nil) + } + + w.Sync(pkgbits.SyncEOF) + w.Flush() + } + + { + w := privateRootWriter + w.pkgInit(noders) + w.Flush() + } + + var sb strings.Builder + pw.DumpTo(&sb) + + // At this point, we're done with types2. Make sure the package is + // garbage collected. + freePackage(pkg) + + return sb.String() +} + +// freePackage ensures the given package is garbage collected. +func freePackage(pkg *types2.Package) { + // The GC test below relies on a precise GC that runs finalizers as + // soon as objects are unreachable. Our implementation provides + // this, but other/older implementations may not (e.g., Go 1.4 does + // not because of #22350). To avoid imposing unnecessary + // restrictions on the GOROOT_BOOTSTRAP toolchain, we skip the test + // during bootstrapping. + if base.CompilerBootstrap || base.Debug.GCCheck == 0 { + *pkg = types2.Package{} + return + } + + // Set a finalizer on pkg so we can detect if/when it's collected. + done := make(chan struct{}) + runtime.SetFinalizer(pkg, func(*types2.Package) { close(done) }) + + // Important: objects involved in cycles are not finalized, so zero + // out pkg to break its cycles and allow the finalizer to run. + *pkg = types2.Package{} + + // It typically takes just 1 or 2 cycles to release pkg, but it + // doesn't hurt to try a few more times. + for i := 0; i < 10; i++ { + select { + case <-done: + return + default: + runtime.GC() + } + } + + base.Fatalf("package never finalized") +} + +// readPackage reads package export data from pr to populate +// importpkg. +// +// localStub indicates whether pr is reading the stub export data for +// the local package, as opposed to relocated export data for an +// import. +func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) { + { + r := pr.newReader(pkgbits.SectionMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic) + + pkg := r.pkg() + // This error can happen if "go tool compile" is called with wrong "-p" flag, see issue #54542. + if pkg != importpkg { + base.ErrorfAt(base.AutogeneratedPos, errors.BadImportPath, "mismatched import path, have %q (%p), want %q (%p)", pkg.Path, pkg, importpkg.Path, importpkg) + base.ErrorExit() + } + + if r.Version().Has(pkgbits.HasInit) { + r.Bool() + } + + for i, n := 0, r.Len(); i < n; i++ { + r.Sync(pkgbits.SyncObject) + if r.Version().Has(pkgbits.DerivedFuncInstance) { + assert(!r.Bool()) + } + idx := r.Reloc(pkgbits.SectionObj) + assert(r.Len() == 0) + + path, name, code := r.p.PeekObj(idx) + if code != pkgbits.ObjStub { + objReader[types.NewPkg(path, "").Lookup(name)] = pkgReaderIndex{pr, idx, nil, nil, nil} + } + } + + r.Sync(pkgbits.SyncEOF) + } + + if !localStub { + r := pr.newReader(pkgbits.SectionMeta, pkgbits.PrivateRootIdx, pkgbits.SyncPrivate) + + if r.Bool() { + sym := importpkg.Lookup(".inittask") + task := ir.NewNameAt(src.NoXPos, sym, nil) + task.Class = ir.PEXTERN + sym.Def = task + } + + for i, n := 0, r.Len(); i < n; i++ { + path := r.String() + name := r.String() + idx := r.Reloc(pkgbits.SectionBody) + + sym := types.NewPkg(path, "").Lookup(name) + if _, ok := importBodyReader[sym]; !ok { + importBodyReader[sym] = pkgReaderIndex{pr, idx, nil, nil, nil} + } + } + + r.Sync(pkgbits.SyncEOF) + } +} + +// writeUnifiedExport writes to `out` the finalized, self-contained +// Unified IR export data file for the current compilation unit. +func writeUnifiedExport(out io.Writer) { + // Use V2 as the encoded version for aliastypeparams. + version := pkgbits.V2 + l := linker{ + pw: pkgbits.NewPkgEncoder(version, base.Debug.SyncFrames), + + pkgs: make(map[string]index), + decls: make(map[*types.Sym]index), + bodies: make(map[*types.Sym]index), + } + + publicRootWriter := l.pw.NewEncoder(pkgbits.SectionMeta, pkgbits.SyncPublic) + privateRootWriter := l.pw.NewEncoder(pkgbits.SectionMeta, pkgbits.SyncPrivate) + assert(publicRootWriter.Idx == pkgbits.PublicRootIdx) + assert(privateRootWriter.Idx == pkgbits.PrivateRootIdx) + + var selfPkgIdx index + + { + pr := localPkgReader + r := pr.NewDecoder(pkgbits.SectionMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic) + + r.Sync(pkgbits.SyncPkg) + selfPkgIdx = l.relocIdx(pr, pkgbits.SectionPkg, r.Reloc(pkgbits.SectionPkg)) + + if r.Version().Has(pkgbits.HasInit) { + r.Bool() + } + + for i, n := 0, r.Len(); i < n; i++ { + r.Sync(pkgbits.SyncObject) + if r.Version().Has(pkgbits.DerivedFuncInstance) { + assert(!r.Bool()) + } + idx := r.Reloc(pkgbits.SectionObj) + assert(r.Len() == 0) + + xpath, xname, xtag := pr.PeekObj(idx) + assert(xpath == pr.PkgPath()) + assert(xtag != pkgbits.ObjStub) + + if types.IsExported(xname) { + l.relocIdx(pr, pkgbits.SectionObj, idx) + } + } + + r.Sync(pkgbits.SyncEOF) + } + + { + var idxs []index + for _, idx := range l.decls { + idxs = append(idxs, idx) + } + slices.Sort(idxs) + + w := publicRootWriter + + w.Sync(pkgbits.SyncPkg) + w.Reloc(pkgbits.SectionPkg, selfPkgIdx) + + if w.Version().Has(pkgbits.HasInit) { + w.Bool(false) + } + + w.Len(len(idxs)) + for _, idx := range idxs { + w.Sync(pkgbits.SyncObject) + if w.Version().Has(pkgbits.DerivedFuncInstance) { + w.Bool(false) + } + w.Reloc(pkgbits.SectionObj, idx) + w.Len(0) + } + + w.Sync(pkgbits.SyncEOF) + w.Flush() + } + + { + type symIdx struct { + sym *types.Sym + idx index + } + var bodies []symIdx + for sym, idx := range l.bodies { + bodies = append(bodies, symIdx{sym, idx}) + } + slices.SortFunc(bodies, func(a, b symIdx) int { return cmp.Compare(a.idx, b.idx) }) + + w := privateRootWriter + + w.Bool(typecheck.Lookup(".inittask").Def != nil) + + w.Len(len(bodies)) + for _, body := range bodies { + w.String(body.sym.Pkg.Path) + w.String(body.sym.Name) + w.Reloc(pkgbits.SectionBody, body.idx) + } + + w.Sync(pkgbits.SyncEOF) + w.Flush() + } + + base.Ctxt.Fingerprint = l.pw.DumpTo(out) +} diff --git a/go/src/cmd/compile/internal/noder/writer.go b/go/src/cmd/compile/internal/noder/writer.go new file mode 100644 index 0000000000000000000000000000000000000000..e772328b0a5b9781c97edc0b54d921cb275bca63 --- /dev/null +++ b/go/src/cmd/compile/internal/noder/writer.go @@ -0,0 +1,3129 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package noder + +import ( + "fmt" + "go/constant" + "go/token" + "go/version" + "internal/buildcfg" + "internal/pkgbits" + "os" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/syntax" + "cmd/compile/internal/types" + "cmd/compile/internal/types2" +) + +// This file implements the Unified IR package writer and defines the +// Unified IR export data format. +// +// Low-level coding details (e.g., byte-encoding of individual +// primitive values, or handling element bitstreams and +// cross-references) are handled by internal/pkgbits, so here we only +// concern ourselves with higher-level worries like mapping Go +// language constructs into elements. + +// There are two central types in the writing process: the "writer" +// type handles writing out individual elements, while the "pkgWriter" +// type keeps track of which elements have already been created. +// +// For each sort of "thing" (e.g., position, package, object, type) +// that can be written into the export data, there are generally +// several methods that work together: +// +// - writer.thing handles writing out a *use* of a thing, which often +// means writing a relocation to that thing's encoded index. +// +// - pkgWriter.thingIdx handles reserving an index for a thing, and +// writing out any elements needed for the thing. +// +// - writer.doThing handles writing out the *definition* of a thing, +// which in general is a mix of low-level coding primitives (e.g., +// ints and strings) or uses of other things. +// +// A design goal of Unified IR is to have a single, canonical writer +// implementation, but multiple reader implementations each tailored +// to their respective needs. For example, within cmd/compile's own +// backend, inlining is implemented largely by just re-running the +// function body reading code. + +// TODO(mdempsky): Add an importer for Unified IR to the x/tools repo, +// and better document the file format boundary between public and +// private data. + +type index = pkgbits.Index + +func assert(p bool) { base.Assert(p) } + +// A pkgWriter constructs Unified IR export data from the results of +// running the types2 type checker on a Go compilation unit. +type pkgWriter struct { + pkgbits.PkgEncoder + + m posMap + curpkg *types2.Package + info *types2.Info + rangeFuncBodyClosures map[*syntax.FuncLit]bool // non-public information, e.g., which functions are closures range function bodies? + + // Indices for previously written syntax and types2 things. + + posBasesIdx map[*syntax.PosBase]index + pkgsIdx map[*types2.Package]index + typsIdx map[types2.Type]index + objsIdx map[types2.Object]index + + // Maps from types2.Objects back to their syntax.Decl. + + funDecls map[*types2.Func]*syntax.FuncDecl + typDecls map[*types2.TypeName]typeDeclGen + + // linknames maps package-scope objects to their linker symbol name, + // if specified by a //go:linkname directive. + linknames map[types2.Object]string + + // cgoPragmas accumulates any //go:cgo_* pragmas that need to be + // passed through to cmd/link. + cgoPragmas [][]string +} + +// newPkgWriter returns an initialized pkgWriter for the specified +// package. +func newPkgWriter(m posMap, pkg *types2.Package, info *types2.Info, otherInfo map[*syntax.FuncLit]bool) *pkgWriter { + // Use V2 as the encoded version for aliastypeparams. + version := pkgbits.V2 + return &pkgWriter{ + PkgEncoder: pkgbits.NewPkgEncoder(version, base.Debug.SyncFrames), + + m: m, + curpkg: pkg, + info: info, + rangeFuncBodyClosures: otherInfo, + + pkgsIdx: make(map[*types2.Package]index), + objsIdx: make(map[types2.Object]index), + typsIdx: make(map[types2.Type]index), + + posBasesIdx: make(map[*syntax.PosBase]index), + + funDecls: make(map[*types2.Func]*syntax.FuncDecl), + typDecls: make(map[*types2.TypeName]typeDeclGen), + + linknames: make(map[types2.Object]string), + } +} + +// errorf reports a user error about thing p. +func (pw *pkgWriter) errorf(p poser, msg string, args ...any) { + base.ErrorfAt(pw.m.pos(p), 0, msg, args...) +} + +// fatalf reports an internal compiler error about thing p. +func (pw *pkgWriter) fatalf(p poser, msg string, args ...any) { + base.FatalfAt(pw.m.pos(p), msg, args...) +} + +// unexpected reports a fatal error about a thing of unexpected +// dynamic type. +func (pw *pkgWriter) unexpected(what string, p poser) { + pw.fatalf(p, "unexpected %s: %v (%T)", what, p, p) +} + +func (pw *pkgWriter) typeAndValue(x syntax.Expr) syntax.TypeAndValue { + tv, ok := pw.maybeTypeAndValue(x) + if !ok { + pw.fatalf(x, "missing Types entry: %v", syntax.String(x)) + } + return tv +} + +func (pw *pkgWriter) maybeTypeAndValue(x syntax.Expr) (syntax.TypeAndValue, bool) { + tv := x.GetTypeInfo() + + // If x is a generic function whose type arguments are inferred + // from assignment context, then we need to find its inferred type + // in Info.Instances instead. + if name, ok := x.(*syntax.Name); ok { + if inst, ok := pw.info.Instances[name]; ok { + tv.Type = inst.Type + } + } + + return tv, tv.Type != nil +} + +// typeOf returns the Type of the given value expression. +func (pw *pkgWriter) typeOf(expr syntax.Expr) types2.Type { + tv := pw.typeAndValue(expr) + if !tv.IsValue() { + pw.fatalf(expr, "expected value: %v", syntax.String(expr)) + } + return tv.Type +} + +// A writer provides APIs for writing out an individual element. +type writer struct { + p *pkgWriter + + *pkgbits.Encoder + + // sig holds the signature for the current function body, if any. + sig *types2.Signature + + // TODO(mdempsky): We should be able to prune localsIdx whenever a + // scope closes, and then maybe we can just use the same map for + // storing the TypeParams too (as their TypeName instead). + + // localsIdx tracks any local variables declared within this + // function body. It's unused for writing out non-body things. + localsIdx map[*types2.Var]int + + // closureVars tracks any free variables that are referenced by this + // function body. It's unused for writing out non-body things. + closureVars []posVar + closureVarsIdx map[*types2.Var]int // index of previously seen free variables + + dict *writerDict + + // derived tracks whether the type being written out references any + // type parameters. It's unused for writing non-type things. + derived bool +} + +// A writerDict tracks types and objects that are used by a declaration. +type writerDict struct { + // implicits is a slice of type parameters from the enclosing + // declarations. + implicits []*types2.TypeParam + + // derived is a slice of type indices for computing derived types + // (i.e., types that depend on the declaration's type parameters). + derived []derivedInfo + + // derivedIdx maps a Type to its corresponding index within the + // derived slice, if present. + derivedIdx map[types2.Type]index + + // These slices correspond to entries in the runtime dictionary. + typeParamMethodExprs []writerMethodExprInfo + subdicts []objInfo + rtypes []typeInfo + itabs []itabInfo +} + +type itabInfo struct { + typ typeInfo + iface typeInfo +} + +// typeParamIndex returns the index of the given type parameter within +// the dictionary. This may differ from typ.Index() when there are +// implicit type parameters due to defined types declared within a +// generic function or method. +func (dict *writerDict) typeParamIndex(typ *types2.TypeParam) int { + for idx, implicit := range dict.implicits { + if implicit == typ { + return idx + } + } + + return len(dict.implicits) + typ.Index() +} + +// A derivedInfo represents a reference to an encoded generic Go type. +type derivedInfo struct { + idx index +} + +// A typeInfo represents a reference to an encoded Go type. +// +// If derived is true, then the typeInfo represents a generic Go type +// that contains type parameters. In this case, idx is an index into +// the readerDict.derived{,Types} arrays. +// +// Otherwise, the typeInfo represents a non-generic Go type, and idx +// is an index into the reader.typs array instead. +type typeInfo struct { + idx index + derived bool +} + +// An objInfo represents a reference to an encoded, instantiated (if +// applicable) Go object. +type objInfo struct { + idx index // index for the generic function declaration + explicits []typeInfo // info for the type arguments +} + +// A selectorInfo represents a reference to an encoded field or method +// name (i.e., objects that can only be accessed using selector +// expressions). +type selectorInfo struct { + pkgIdx index + nameIdx index +} + +// anyDerived reports whether any of info's explicit type arguments +// are derived types. +func (info objInfo) anyDerived() bool { + for _, explicit := range info.explicits { + if explicit.derived { + return true + } + } + return false +} + +// equals reports whether info and other represent the same Go object +// (i.e., same base object and identical type arguments, if any). +func (info objInfo) equals(other objInfo) bool { + if info.idx != other.idx { + return false + } + assert(len(info.explicits) == len(other.explicits)) + for i, targ := range info.explicits { + if targ != other.explicits[i] { + return false + } + } + return true +} + +type writerMethodExprInfo struct { + typeParamIdx int + methodInfo selectorInfo +} + +// typeParamMethodExprIdx returns the index where the given encoded +// method expression function pointer appears within this dictionary's +// type parameters method expressions section, adding it if necessary. +func (dict *writerDict) typeParamMethodExprIdx(typeParamIdx int, methodInfo selectorInfo) int { + newInfo := writerMethodExprInfo{typeParamIdx, methodInfo} + + for idx, oldInfo := range dict.typeParamMethodExprs { + if oldInfo == newInfo { + return idx + } + } + + idx := len(dict.typeParamMethodExprs) + dict.typeParamMethodExprs = append(dict.typeParamMethodExprs, newInfo) + return idx +} + +// subdictIdx returns the index where the given encoded object's +// runtime dictionary appears within this dictionary's subdictionary +// section, adding it if necessary. +func (dict *writerDict) subdictIdx(newInfo objInfo) int { + for idx, oldInfo := range dict.subdicts { + if oldInfo.equals(newInfo) { + return idx + } + } + + idx := len(dict.subdicts) + dict.subdicts = append(dict.subdicts, newInfo) + return idx +} + +// rtypeIdx returns the index where the given encoded type's +// *runtime._type value appears within this dictionary's rtypes +// section, adding it if necessary. +func (dict *writerDict) rtypeIdx(newInfo typeInfo) int { + for idx, oldInfo := range dict.rtypes { + if oldInfo == newInfo { + return idx + } + } + + idx := len(dict.rtypes) + dict.rtypes = append(dict.rtypes, newInfo) + return idx +} + +// itabIdx returns the index where the given encoded type pair's +// *runtime.itab value appears within this dictionary's itabs section, +// adding it if necessary. +func (dict *writerDict) itabIdx(typInfo, ifaceInfo typeInfo) int { + newInfo := itabInfo{typInfo, ifaceInfo} + + for idx, oldInfo := range dict.itabs { + if oldInfo == newInfo { + return idx + } + } + + idx := len(dict.itabs) + dict.itabs = append(dict.itabs, newInfo) + return idx +} + +func (pw *pkgWriter) newWriter(k pkgbits.SectionKind, marker pkgbits.SyncMarker) *writer { + return &writer{ + Encoder: pw.NewEncoder(k, marker), + p: pw, + } +} + +// @@@ Positions + +// pos writes the position of p into the element bitstream. +func (w *writer) pos(p poser) { + w.Sync(pkgbits.SyncPos) + pos := p.Pos() + + // TODO(mdempsky): Track down the remaining cases here and fix them. + if !w.Bool(pos.IsKnown()) { + return + } + + // TODO(mdempsky): Delta encoding. + w.posBase(pos.Base()) + w.Uint(pos.Line()) + w.Uint(pos.Col()) +} + +// posBase writes a reference to the given PosBase into the element +// bitstream. +func (w *writer) posBase(b *syntax.PosBase) { + w.Reloc(pkgbits.SectionPosBase, w.p.posBaseIdx(b)) +} + +// posBaseIdx returns the index for the given PosBase. +func (pw *pkgWriter) posBaseIdx(b *syntax.PosBase) index { + if idx, ok := pw.posBasesIdx[b]; ok { + return idx + } + + w := pw.newWriter(pkgbits.SectionPosBase, pkgbits.SyncPosBase) + w.p.posBasesIdx[b] = w.Idx + + w.String(trimFilename(b)) + + if !w.Bool(b.IsFileBase()) { + w.pos(b) + w.Uint(b.Line()) + w.Uint(b.Col()) + } + + return w.Flush() +} + +// @@@ Packages + +// pkg writes a use of the given Package into the element bitstream. +func (w *writer) pkg(pkg *types2.Package) { + w.pkgRef(w.p.pkgIdx(pkg)) +} + +func (w *writer) pkgRef(idx index) { + w.Sync(pkgbits.SyncPkg) + w.Reloc(pkgbits.SectionPkg, idx) +} + +// pkgIdx returns the index for the given package, adding it to the +// package export data if needed. +func (pw *pkgWriter) pkgIdx(pkg *types2.Package) index { + if idx, ok := pw.pkgsIdx[pkg]; ok { + return idx + } + + w := pw.newWriter(pkgbits.SectionPkg, pkgbits.SyncPkgDef) + pw.pkgsIdx[pkg] = w.Idx + + // The universe and package unsafe need to be handled specially by + // importers anyway, so we serialize them using just their package + // path. This ensures that readers don't confuse them for + // user-defined packages. + switch pkg { + case nil: // universe + w.String("builtin") // same package path used by godoc + case types2.Unsafe: + w.String("unsafe") + default: + // TODO(mdempsky): Write out pkg.Path() for curpkg too. + var path string + if pkg != w.p.curpkg { + path = pkg.Path() + } + base.Assertf(path != "builtin" && path != "unsafe", "unexpected path for user-defined package: %q", path) + w.String(path) + w.String(pkg.Name()) + + w.Len(len(pkg.Imports())) + for _, imp := range pkg.Imports() { + w.pkg(imp) + } + } + + return w.Flush() +} + +// @@@ Types + +var ( + anyTypeName = types2.Universe.Lookup("any").(*types2.TypeName) + comparableTypeName = types2.Universe.Lookup("comparable").(*types2.TypeName) + runeTypeName = types2.Universe.Lookup("rune").(*types2.TypeName) +) + +// typ writes a use of the given type into the bitstream. +func (w *writer) typ(typ types2.Type) { + w.typInfo(w.p.typIdx(typ, w.dict)) +} + +// typInfo writes a use of the given type (specified as a typeInfo +// instead) into the bitstream. +func (w *writer) typInfo(info typeInfo) { + w.Sync(pkgbits.SyncType) + if w.Bool(info.derived) { + w.Len(int(info.idx)) + w.derived = true + } else { + w.Reloc(pkgbits.SectionType, info.idx) + } +} + +// typIdx returns the index where the export data description of type +// can be read back in. If no such index exists yet, it's created. +// +// typIdx also reports whether typ is a derived type; that is, whether +// its identity depends on type parameters. +func (pw *pkgWriter) typIdx(typ types2.Type, dict *writerDict) typeInfo { + // Strip non-global aliases, because they only appear in inline + // bodies anyway. Otherwise, they can cause types.Sym collisions + // (e.g., "main.C" for both of the local type aliases in + // test/fixedbugs/issue50190.go). + for { + if alias, ok := typ.(*types2.Alias); ok && !isGlobal(alias.Obj()) { + typ = alias.Rhs() + } else { + break + } + } + + if idx, ok := pw.typsIdx[typ]; ok { + return typeInfo{idx: idx, derived: false} + } + if dict != nil { + if idx, ok := dict.derivedIdx[typ]; ok { + return typeInfo{idx: idx, derived: true} + } + } + + w := pw.newWriter(pkgbits.SectionType, pkgbits.SyncTypeIdx) + w.dict = dict + + switch typ := typ.(type) { + default: + base.Fatalf("unexpected type: %v (%T)", typ, typ) + + case *types2.Basic: + switch kind := typ.Kind(); { + case kind == types2.Invalid: + base.Fatalf("unexpected types2.Invalid") + + case types2.Typ[kind] == typ: + w.Code(pkgbits.TypeBasic) + w.Len(int(kind)) + + default: + // Handle "byte" and "rune" as references to their TypeNames. + obj := types2.Universe.Lookup(typ.Name()).(*types2.TypeName) + assert(obj.Type() == typ) + + w.Code(pkgbits.TypeNamed) + w.namedType(obj, nil) + } + + case *types2.Named: + w.Code(pkgbits.TypeNamed) + w.namedType(splitNamed(typ)) + + case *types2.Alias: + w.Code(pkgbits.TypeNamed) + w.namedType(splitAlias(typ)) + + case *types2.TypeParam: + w.derived = true + w.Code(pkgbits.TypeTypeParam) + w.Len(w.dict.typeParamIndex(typ)) + + case *types2.Array: + w.Code(pkgbits.TypeArray) + w.Uint64(uint64(typ.Len())) + w.typ(typ.Elem()) + + case *types2.Chan: + w.Code(pkgbits.TypeChan) + w.Len(int(typ.Dir())) + w.typ(typ.Elem()) + + case *types2.Map: + w.Code(pkgbits.TypeMap) + w.typ(typ.Key()) + w.typ(typ.Elem()) + + case *types2.Pointer: + w.Code(pkgbits.TypePointer) + w.typ(typ.Elem()) + + case *types2.Signature: + base.Assertf(typ.TypeParams() == nil, "unexpected type params: %v", typ) + w.Code(pkgbits.TypeSignature) + w.signature(typ) + + case *types2.Slice: + w.Code(pkgbits.TypeSlice) + w.typ(typ.Elem()) + + case *types2.Struct: + w.Code(pkgbits.TypeStruct) + w.structType(typ) + + case *types2.Interface: + // Handle "any" as reference to its TypeName. + // The underlying "any" interface is canonical, so this logic handles both + // GODEBUG=gotypesalias=1 (when any is represented as a types2.Alias), and + // gotypesalias=0. + if types2.Unalias(typ) == types2.Unalias(anyTypeName.Type()) { + w.Code(pkgbits.TypeNamed) + w.obj(anyTypeName, nil) + break + } + + w.Code(pkgbits.TypeInterface) + w.interfaceType(typ) + + case *types2.Union: + w.Code(pkgbits.TypeUnion) + w.unionType(typ) + } + + if w.derived { + idx := index(len(dict.derived)) + dict.derived = append(dict.derived, derivedInfo{idx: w.Flush()}) + dict.derivedIdx[typ] = idx + return typeInfo{idx: idx, derived: true} + } + + pw.typsIdx[typ] = w.Idx + return typeInfo{idx: w.Flush(), derived: false} +} + +// namedType writes a use of the given named type into the bitstream. +func (w *writer) namedType(obj *types2.TypeName, targs *types2.TypeList) { + // Named types that are declared within a generic function (and + // thus have implicit type parameters) are always derived types. + if w.p.hasImplicitTypeParams(obj) { + w.derived = true + } + + w.obj(obj, targs) +} + +func (w *writer) structType(typ *types2.Struct) { + w.Len(typ.NumFields()) + for i := 0; i < typ.NumFields(); i++ { + f := typ.Field(i) + w.pos(f) + w.selector(f) + w.typ(f.Type()) + w.String(typ.Tag(i)) + w.Bool(f.Embedded()) + } +} + +func (w *writer) unionType(typ *types2.Union) { + w.Len(typ.Len()) + for i := 0; i < typ.Len(); i++ { + t := typ.Term(i) + w.Bool(t.Tilde()) + w.typ(t.Type()) + } +} + +func (w *writer) interfaceType(typ *types2.Interface) { + // If typ has no embedded types but it's not a basic interface, then + // the natural description we write out below will fail to + // reconstruct it. + if typ.NumEmbeddeds() == 0 && !typ.IsMethodSet() { + // Currently, this can only happen for the underlying Interface of + // "comparable", which is needed to handle type declarations like + // "type C comparable". + assert(typ == comparableTypeName.Type().(*types2.Named).Underlying()) + + // Export as "interface{ comparable }". + w.Len(0) // NumExplicitMethods + w.Len(1) // NumEmbeddeds + w.Bool(false) // IsImplicit + w.typ(comparableTypeName.Type()) // EmbeddedType(0) + return + } + + w.Len(typ.NumExplicitMethods()) + w.Len(typ.NumEmbeddeds()) + + if typ.NumExplicitMethods() == 0 && typ.NumEmbeddeds() == 1 { + w.Bool(typ.IsImplicit()) + } else { + // Implicit interfaces always have 0 explicit methods and 1 + // embedded type, so we skip writing out the implicit flag + // otherwise as a space optimization. + assert(!typ.IsImplicit()) + } + + for i := 0; i < typ.NumExplicitMethods(); i++ { + m := typ.ExplicitMethod(i) + sig := m.Type().(*types2.Signature) + assert(sig.TypeParams() == nil) + + w.pos(m) + w.selector(m) + w.signature(sig) + } + + for i := 0; i < typ.NumEmbeddeds(); i++ { + w.typ(typ.EmbeddedType(i)) + } +} + +func (w *writer) signature(sig *types2.Signature) { + w.Sync(pkgbits.SyncSignature) + w.params(sig.Params()) + w.params(sig.Results()) + w.Bool(sig.Variadic()) +} + +func (w *writer) params(typ *types2.Tuple) { + w.Sync(pkgbits.SyncParams) + w.Len(typ.Len()) + for i := 0; i < typ.Len(); i++ { + w.param(typ.At(i)) + } +} + +func (w *writer) param(param *types2.Var) { + w.Sync(pkgbits.SyncParam) + w.pos(param) + w.localIdent(param) + w.typ(param.Type()) +} + +// @@@ Objects + +// obj writes a use of the given object into the bitstream. +// +// If obj is a generic object, then explicits are the explicit type +// arguments used to instantiate it (i.e., used to substitute the +// object's own declared type parameters). +func (w *writer) obj(obj types2.Object, explicits *types2.TypeList) { + w.objInfo(w.p.objInstIdx(obj, explicits, w.dict)) +} + +// objInfo writes a use of the given encoded object into the +// bitstream. +func (w *writer) objInfo(info objInfo) { + w.Sync(pkgbits.SyncObject) + if w.Version().Has(pkgbits.DerivedFuncInstance) { + w.Bool(false) + } + w.Reloc(pkgbits.SectionObj, info.idx) + + w.Len(len(info.explicits)) + for _, info := range info.explicits { + w.typInfo(info) + } +} + +// objInstIdx returns the indices for an object and a corresponding +// list of type arguments used to instantiate it, adding them to the +// export data as needed. +func (pw *pkgWriter) objInstIdx(obj types2.Object, explicits *types2.TypeList, dict *writerDict) objInfo { + explicitInfos := make([]typeInfo, explicits.Len()) + for i := range explicitInfos { + explicitInfos[i] = pw.typIdx(explicits.At(i), dict) + } + return objInfo{idx: pw.objIdx(obj), explicits: explicitInfos} +} + +// objIdx returns the index for the given Object, adding it to the +// export data as needed. +func (pw *pkgWriter) objIdx(obj types2.Object) index { + // TODO(mdempsky): Validate that obj is a global object (or a local + // defined type, which we hoist to global scope anyway). + + if idx, ok := pw.objsIdx[obj]; ok { + return idx + } + + dict := &writerDict{ + derivedIdx: make(map[types2.Type]index), + } + + if isDefinedType(obj) && obj.Pkg() == pw.curpkg { + decl, ok := pw.typDecls[obj.(*types2.TypeName)] + assert(ok) + dict.implicits = decl.implicits + } + + // We encode objects into 4 elements across different sections, all + // sharing the same index: + // + // - RelocName has just the object's qualified name (i.e., + // Object.Pkg and Object.Name) and the CodeObj indicating what + // specific type of Object it is (Var, Func, etc). + // + // - RelocObj has the remaining public details about the object, + // relevant to go/types importers. + // + // - RelocObjExt has additional private details about the object, + // which are only relevant to cmd/compile itself. This is + // separated from RelocObj so that go/types importers are + // unaffected by internal compiler changes. + // + // - RelocObjDict has public details about the object's type + // parameters and derived type's used by the object. This is + // separated to facilitate the eventual introduction of + // shape-based stenciling. + // + // TODO(mdempsky): Re-evaluate whether RelocName still makes sense + // to keep separate from RelocObj. + + w := pw.newWriter(pkgbits.SectionObj, pkgbits.SyncObject1) + wext := pw.newWriter(pkgbits.SectionObjExt, pkgbits.SyncObject1) + wname := pw.newWriter(pkgbits.SectionName, pkgbits.SyncObject1) + wdict := pw.newWriter(pkgbits.SectionObjDict, pkgbits.SyncObject1) + + pw.objsIdx[obj] = w.Idx // break cycles + assert(wext.Idx == w.Idx) + assert(wname.Idx == w.Idx) + assert(wdict.Idx == w.Idx) + + w.dict = dict + wext.dict = dict + + code := w.doObj(wext, obj) + w.Flush() + wext.Flush() + + wname.qualifiedIdent(obj) + wname.Code(code) + wname.Flush() + + wdict.objDict(obj, w.dict) + wdict.Flush() + + return w.Idx +} + +// doObj writes the RelocObj definition for obj to w, and the +// RelocObjExt definition to wext. +func (w *writer) doObj(wext *writer, obj types2.Object) pkgbits.CodeObj { + if obj.Pkg() != w.p.curpkg { + return pkgbits.ObjStub + } + + switch obj := obj.(type) { + default: + w.p.unexpected("object", obj) + panic("unreachable") + + case *types2.Const: + w.pos(obj) + w.typ(obj.Type()) + w.Value(obj.Val()) + return pkgbits.ObjConst + + case *types2.Func: + decl, ok := w.p.funDecls[obj] + assert(ok) + sig := obj.Type().(*types2.Signature) + + w.pos(obj) + w.typeParamNames(sig.TypeParams()) + w.signature(sig) + w.pos(decl) + wext.funcExt(obj) + return pkgbits.ObjFunc + + case *types2.TypeName: + if obj.IsAlias() { + w.pos(obj) + rhs := obj.Type() + var tparams *types2.TypeParamList + if alias, ok := rhs.(*types2.Alias); ok { // materialized alias + assert(alias.TypeArgs() == nil) + tparams = alias.TypeParams() + rhs = alias.Rhs() + } + if w.Version().Has(pkgbits.AliasTypeParamNames) { + w.typeParamNames(tparams) + } + assert(w.Version().Has(pkgbits.AliasTypeParamNames) || tparams.Len() == 0) + w.typ(rhs) + return pkgbits.ObjAlias + } + + named := obj.Type().(*types2.Named) + assert(named.TypeArgs() == nil) + + w.pos(obj) + w.typeParamNames(named.TypeParams()) + wext.typeExt(obj) + w.typ(named.Underlying()) + + w.Len(named.NumMethods()) + for i := 0; i < named.NumMethods(); i++ { + w.method(wext, named.Method(i)) + } + + return pkgbits.ObjType + + case *types2.Var: + w.pos(obj) + w.typ(obj.Type()) + wext.varExt(obj) + return pkgbits.ObjVar + } +} + +// objDict writes the dictionary needed for reading the given object. +func (w *writer) objDict(obj types2.Object, dict *writerDict) { + // TODO(mdempsky): Split objDict into multiple entries? reader.go + // doesn't care about the type parameter bounds, and reader2.go + // doesn't care about referenced functions. + + w.dict = dict // TODO(mdempsky): This is a bit sketchy. + + w.Len(len(dict.implicits)) + + tparams := objTypeParams(obj) + ntparams := tparams.Len() + w.Len(ntparams) + for i := 0; i < ntparams; i++ { + w.typ(tparams.At(i).Constraint()) + } + + nderived := len(dict.derived) + w.Len(nderived) + for _, typ := range dict.derived { + w.Reloc(pkgbits.SectionType, typ.idx) + if w.Version().Has(pkgbits.DerivedInfoNeeded) { + w.Bool(false) + } + } + + // Write runtime dictionary information. + // + // N.B., the go/types importer reads up to the section, but doesn't + // read any further, so it's safe to change. (See TODO above.) + + // For each type parameter, write out whether the constraint is a + // basic interface. This is used to determine how aggressively we + // can shape corresponding type arguments. + // + // This is somewhat redundant with writing out the full type + // parameter constraints above, but the compiler currently skips + // over those. Also, we don't care about the *declared* constraints, + // but how the type parameters are actually *used*. E.g., if a type + // parameter is constrained to `int | uint` but then never used in + // arithmetic/conversions/etc, we could shape those together. + for _, implicit := range dict.implicits { + w.Bool(implicit.Underlying().(*types2.Interface).IsMethodSet()) + } + for i := 0; i < ntparams; i++ { + tparam := tparams.At(i) + w.Bool(tparam.Underlying().(*types2.Interface).IsMethodSet()) + } + + w.Len(len(dict.typeParamMethodExprs)) + for _, info := range dict.typeParamMethodExprs { + w.Len(info.typeParamIdx) + w.selectorInfo(info.methodInfo) + } + + w.Len(len(dict.subdicts)) + for _, info := range dict.subdicts { + w.objInfo(info) + } + + w.Len(len(dict.rtypes)) + for _, info := range dict.rtypes { + w.typInfo(info) + } + + w.Len(len(dict.itabs)) + for _, info := range dict.itabs { + w.typInfo(info.typ) + w.typInfo(info.iface) + } + + assert(len(dict.derived) == nderived) +} + +func (w *writer) typeParamNames(tparams *types2.TypeParamList) { + w.Sync(pkgbits.SyncTypeParamNames) + + ntparams := tparams.Len() + for i := 0; i < ntparams; i++ { + tparam := tparams.At(i).Obj() + w.pos(tparam) + w.localIdent(tparam) + } +} + +func (w *writer) method(wext *writer, meth *types2.Func) { + decl, ok := w.p.funDecls[meth] + assert(ok) + sig := meth.Type().(*types2.Signature) + + w.Sync(pkgbits.SyncMethod) + w.pos(meth) + w.selector(meth) + w.typeParamNames(sig.RecvTypeParams()) + w.param(sig.Recv()) + w.signature(sig) + + w.pos(decl) // XXX: Hack to workaround linker limitations. + wext.funcExt(meth) +} + +// qualifiedIdent writes out the name of an object declared at package +// scope. (For now, it's also used to refer to local defined types.) +func (w *writer) qualifiedIdent(obj types2.Object) { + w.Sync(pkgbits.SyncSym) + + name := obj.Name() + if isDefinedType(obj) && obj.Pkg() == w.p.curpkg { + decl, ok := w.p.typDecls[obj.(*types2.TypeName)] + assert(ok) + if decl.gen != 0 { + // For local defined types, we embed a scope-disambiguation + // number directly into their name. types.SplitVargenSuffix then + // knows to look for this. + // + // TODO(mdempsky): Find a better solution; this is terrible. + name = fmt.Sprintf("%s·%v", name, decl.gen) + } + } + + w.pkg(obj.Pkg()) + w.String(name) +} + +// TODO(mdempsky): We should be able to omit pkg from both localIdent +// and selector, because they should always be known from context. +// However, past frustrations with this optimization in iexport make +// me a little nervous to try it again. + +// localIdent writes the name of a locally declared object (i.e., +// objects that can only be accessed by non-qualified name, within the +// context of a particular function). +func (w *writer) localIdent(obj types2.Object) { + assert(!isGlobal(obj)) + w.Sync(pkgbits.SyncLocalIdent) + w.pkg(obj.Pkg()) + w.String(obj.Name()) +} + +// selector writes the name of a field or method (i.e., objects that +// can only be accessed using selector expressions). +func (w *writer) selector(obj types2.Object) { + w.selectorInfo(w.p.selectorIdx(obj)) +} + +func (w *writer) selectorInfo(info selectorInfo) { + w.Sync(pkgbits.SyncSelector) + w.pkgRef(info.pkgIdx) + w.StringRef(info.nameIdx) +} + +func (pw *pkgWriter) selectorIdx(obj types2.Object) selectorInfo { + pkgIdx := pw.pkgIdx(obj.Pkg()) + nameIdx := pw.StringIdx(obj.Name()) + return selectorInfo{pkgIdx: pkgIdx, nameIdx: nameIdx} +} + +// @@@ Compiler extensions + +func (w *writer) funcExt(obj *types2.Func) { + decl, ok := w.p.funDecls[obj] + assert(ok) + + // TODO(mdempsky): Extend these pragma validation flags to account + // for generics. E.g., linkname probably doesn't make sense at + // least. + + pragma := asPragmaFlag(decl.Pragma) + if pragma&ir.Systemstack != 0 && pragma&ir.Nosplit != 0 { + w.p.errorf(decl, "go:nosplit and go:systemstack cannot be combined") + } + wi := asWasmImport(decl.Pragma) + we := asWasmExport(decl.Pragma) + + if decl.Body != nil { + if pragma&ir.Noescape != 0 { + w.p.errorf(decl, "can only use //go:noescape with external func implementations") + } + if wi != nil { + w.p.errorf(decl, "can only use //go:wasmimport with external func implementations") + } + if (pragma&ir.UintptrKeepAlive != 0 && pragma&ir.UintptrEscapes == 0) && pragma&ir.Nosplit == 0 { + // Stack growth can't handle uintptr arguments that may + // be pointers (as we don't know which are pointers + // when creating the stack map). Thus uintptrkeepalive + // functions (and all transitive callees) must be + // nosplit. + // + // N.B. uintptrescapes implies uintptrkeepalive but it + // is OK since the arguments must escape to the heap. + // + // TODO(prattmic): Add recursive nosplit check of callees. + // TODO(prattmic): Functions with no body (i.e., + // assembly) must also be nosplit, but we can't check + // that here. + w.p.errorf(decl, "go:uintptrkeepalive requires go:nosplit") + } + } else { + if base.Flag.Complete || decl.Name.Value == "init" { + // Linknamed functions are allowed to have no body. Hopefully + // the linkname target has a body. See issue 23311. + // Wasmimport functions are also allowed to have no body. + if _, ok := w.p.linknames[obj]; !ok && wi == nil { + w.p.errorf(decl, "missing function body") + } + } + } + + sig, block := obj.Type().(*types2.Signature), decl.Body + body, closureVars := w.p.bodyIdx(sig, block, w.dict) + if len(closureVars) > 0 { + fmt.Fprintln(os.Stderr, "CLOSURE", closureVars) + } + assert(len(closureVars) == 0) + + w.Sync(pkgbits.SyncFuncExt) + w.pragmaFlag(pragma) + w.linkname(obj) + + if buildcfg.GOARCH == "wasm" { + if wi != nil { + w.String(wi.Module) + w.String(wi.Name) + } else { + w.String("") + w.String("") + } + if we != nil { + w.String(we.Name) + } else { + w.String("") + } + } + + w.Bool(false) // stub extension + w.Reloc(pkgbits.SectionBody, body) + w.Sync(pkgbits.SyncEOF) +} + +func (w *writer) typeExt(obj *types2.TypeName) { + decl, ok := w.p.typDecls[obj] + assert(ok) + + w.Sync(pkgbits.SyncTypeExt) + + w.pragmaFlag(asPragmaFlag(decl.Pragma)) + + // No LSym.SymIdx info yet. + w.Int64(-1) + w.Int64(-1) +} + +func (w *writer) varExt(obj *types2.Var) { + w.Sync(pkgbits.SyncVarExt) + w.linkname(obj) +} + +func (w *writer) linkname(obj types2.Object) { + w.Sync(pkgbits.SyncLinkname) + w.Int64(-1) + w.String(w.p.linknames[obj]) +} + +func (w *writer) pragmaFlag(p ir.PragmaFlag) { + w.Sync(pkgbits.SyncPragma) + w.Int(int(p)) +} + +// @@@ Function bodies + +// bodyIdx returns the index for the given function body (specified by +// block), adding it to the export data +func (pw *pkgWriter) bodyIdx(sig *types2.Signature, block *syntax.BlockStmt, dict *writerDict) (idx index, closureVars []posVar) { + w := pw.newWriter(pkgbits.SectionBody, pkgbits.SyncFuncBody) + w.sig = sig + w.dict = dict + + w.declareParams(sig) + if w.Bool(block != nil) { + w.stmts(block.List) + w.pos(block.Rbrace) + } + + return w.Flush(), w.closureVars +} + +func (w *writer) declareParams(sig *types2.Signature) { + addLocals := func(params *types2.Tuple) { + for i := 0; i < params.Len(); i++ { + w.addLocal(params.At(i)) + } + } + + if recv := sig.Recv(); recv != nil { + w.addLocal(recv) + } + addLocals(sig.Params()) + addLocals(sig.Results()) +} + +// addLocal records the declaration of a new local variable. +func (w *writer) addLocal(obj *types2.Var) { + idx := len(w.localsIdx) + + w.Sync(pkgbits.SyncAddLocal) + if w.p.SyncMarkers() { + w.Int(idx) + } + w.varDictIndex(obj) + + if w.localsIdx == nil { + w.localsIdx = make(map[*types2.Var]int) + } + w.localsIdx[obj] = idx +} + +// useLocal writes a reference to the given local or free variable +// into the bitstream. +func (w *writer) useLocal(pos syntax.Pos, obj *types2.Var) { + w.Sync(pkgbits.SyncUseObjLocal) + + if idx, ok := w.localsIdx[obj]; w.Bool(ok) { + w.Len(idx) + return + } + + idx, ok := w.closureVarsIdx[obj] + if !ok { + if w.closureVarsIdx == nil { + w.closureVarsIdx = make(map[*types2.Var]int) + } + idx = len(w.closureVars) + w.closureVars = append(w.closureVars, posVar{pos, obj}) + w.closureVarsIdx[obj] = idx + } + w.Len(idx) +} + +func (w *writer) openScope(pos syntax.Pos) { + w.Sync(pkgbits.SyncOpenScope) + w.pos(pos) +} + +func (w *writer) closeScope(pos syntax.Pos) { + w.Sync(pkgbits.SyncCloseScope) + w.pos(pos) + w.closeAnotherScope() +} + +func (w *writer) closeAnotherScope() { + w.Sync(pkgbits.SyncCloseAnotherScope) +} + +// @@@ Statements + +// stmt writes the given statement into the function body bitstream. +func (w *writer) stmt(stmt syntax.Stmt) { + var stmts []syntax.Stmt + if stmt != nil { + stmts = []syntax.Stmt{stmt} + } + w.stmts(stmts) +} + +func (w *writer) stmts(stmts []syntax.Stmt) { + dead := false + w.Sync(pkgbits.SyncStmts) + var lastLabel = -1 + for i, stmt := range stmts { + if _, ok := stmt.(*syntax.LabeledStmt); ok { + lastLabel = i + } + } + for i, stmt := range stmts { + if dead && i > lastLabel { + // Any statements after a terminating and last label statement are safe to omit. + // Otherwise, code after label statement may refer to dead stmts between terminating + // and label statement, see issue #65593. + if _, ok := stmt.(*syntax.LabeledStmt); !ok { + continue + } + } + w.stmt1(stmt) + dead = w.p.terminates(stmt) + } + w.Code(stmtEnd) + w.Sync(pkgbits.SyncStmtsEnd) +} + +func (w *writer) stmt1(stmt syntax.Stmt) { + switch stmt := stmt.(type) { + default: + w.p.unexpected("statement", stmt) + + case nil, *syntax.EmptyStmt: + return + + case *syntax.AssignStmt: + switch { + case stmt.Rhs == nil: + w.Code(stmtIncDec) + w.op(binOps[stmt.Op]) + w.expr(stmt.Lhs) + w.pos(stmt) + + case stmt.Op != 0 && stmt.Op != syntax.Def: + w.Code(stmtAssignOp) + w.op(binOps[stmt.Op]) + w.expr(stmt.Lhs) + w.pos(stmt) + + var typ types2.Type + if stmt.Op != syntax.Shl && stmt.Op != syntax.Shr { + typ = w.p.typeOf(stmt.Lhs) + } + w.implicitConvExpr(typ, stmt.Rhs) + + default: + w.assignStmt(stmt, stmt.Lhs, stmt.Rhs) + } + + case *syntax.BlockStmt: + w.Code(stmtBlock) + w.blockStmt(stmt) + + case *syntax.BranchStmt: + w.Code(stmtBranch) + w.pos(stmt) + var op ir.Op + switch stmt.Tok { + case syntax.Break: + op = ir.OBREAK + case syntax.Continue: + op = ir.OCONTINUE + case syntax.Fallthrough: + op = ir.OFALL + case syntax.Goto: + op = ir.OGOTO + } + w.op(op) + w.optLabel(stmt.Label) + + case *syntax.CallStmt: + w.Code(stmtCall) + w.pos(stmt) + var op ir.Op + switch stmt.Tok { + case syntax.Defer: + op = ir.ODEFER + case syntax.Go: + op = ir.OGO + } + w.op(op) + w.expr(stmt.Call) + if stmt.Tok == syntax.Defer { + w.optExpr(stmt.DeferAt) + } + + case *syntax.DeclStmt: + for _, decl := range stmt.DeclList { + w.declStmt(decl) + } + + case *syntax.ExprStmt: + w.Code(stmtExpr) + w.expr(stmt.X) + + case *syntax.ForStmt: + w.Code(stmtFor) + w.forStmt(stmt) + + case *syntax.IfStmt: + w.Code(stmtIf) + w.ifStmt(stmt) + + case *syntax.LabeledStmt: + w.Code(stmtLabel) + w.pos(stmt) + w.label(stmt.Label) + w.stmt1(stmt.Stmt) + + case *syntax.ReturnStmt: + w.Code(stmtReturn) + w.pos(stmt) + + resultTypes := w.sig.Results() + dstType := func(i int) types2.Type { + return resultTypes.At(i).Type() + } + w.multiExpr(stmt, dstType, syntax.UnpackListExpr(stmt.Results)) + + case *syntax.SelectStmt: + w.Code(stmtSelect) + w.selectStmt(stmt) + + case *syntax.SendStmt: + chanType := types2.CoreType(w.p.typeOf(stmt.Chan)).(*types2.Chan) + + w.Code(stmtSend) + w.pos(stmt) + w.expr(stmt.Chan) + w.implicitConvExpr(chanType.Elem(), stmt.Value) + + case *syntax.SwitchStmt: + w.Code(stmtSwitch) + w.switchStmt(stmt) + } +} + +func (w *writer) assignList(expr syntax.Expr) { + exprs := syntax.UnpackListExpr(expr) + w.Len(len(exprs)) + + for _, expr := range exprs { + w.assign(expr) + } +} + +func (w *writer) assign(expr syntax.Expr) { + expr = syntax.Unparen(expr) + + if name, ok := expr.(*syntax.Name); ok { + if name.Value == "_" { + w.Code(assignBlank) + return + } + + if obj, ok := w.p.info.Defs[name]; ok { + obj := obj.(*types2.Var) + + w.Code(assignDef) + w.pos(obj) + w.localIdent(obj) + w.typ(obj.Type()) + + // TODO(mdempsky): Minimize locals index size by deferring + // this until the variables actually come into scope. + w.addLocal(obj) + return + } + } + + w.Code(assignExpr) + w.expr(expr) +} + +func (w *writer) declStmt(decl syntax.Decl) { + switch decl := decl.(type) { + default: + w.p.unexpected("declaration", decl) + + case *syntax.ConstDecl, *syntax.TypeDecl: + + case *syntax.VarDecl: + w.assignStmt(decl, namesAsExpr(decl.NameList), decl.Values) + } +} + +// assignStmt writes out an assignment for "lhs = rhs". +func (w *writer) assignStmt(pos poser, lhs0, rhs0 syntax.Expr) { + lhs := syntax.UnpackListExpr(lhs0) + rhs := syntax.UnpackListExpr(rhs0) + + w.Code(stmtAssign) + w.pos(pos) + + // As if w.assignList(lhs0). + w.Len(len(lhs)) + for _, expr := range lhs { + w.assign(expr) + } + + dstType := func(i int) types2.Type { + dst := lhs[i] + + // Finding dstType is somewhat involved, because for VarDecl + // statements, the Names are only added to the info.{Defs,Uses} + // maps, not to info.Types. + if name, ok := syntax.Unparen(dst).(*syntax.Name); ok { + if name.Value == "_" { + return nil // ok: no implicit conversion + } else if def, ok := w.p.info.Defs[name].(*types2.Var); ok { + return def.Type() + } else if use, ok := w.p.info.Uses[name].(*types2.Var); ok { + return use.Type() + } else { + w.p.fatalf(dst, "cannot find type of destination object: %v", dst) + } + } + + return w.p.typeOf(dst) + } + + w.multiExpr(pos, dstType, rhs) +} + +func (w *writer) blockStmt(stmt *syntax.BlockStmt) { + w.Sync(pkgbits.SyncBlockStmt) + w.openScope(stmt.Pos()) + w.stmts(stmt.List) + w.closeScope(stmt.Rbrace) +} + +func (w *writer) forStmt(stmt *syntax.ForStmt) { + w.Sync(pkgbits.SyncForStmt) + w.openScope(stmt.Pos()) + + if rang, ok := stmt.Init.(*syntax.RangeClause); w.Bool(ok) { + w.pos(rang) + w.assignList(rang.Lhs) + w.expr(rang.X) + + xtyp := w.p.typeOf(rang.X) + if _, isMap := types2.CoreType(xtyp).(*types2.Map); isMap { + w.rtype(xtyp) + } + { + lhs := syntax.UnpackListExpr(rang.Lhs) + assign := func(i int, src types2.Type) { + if i >= len(lhs) { + return + } + dst := syntax.Unparen(lhs[i]) + if name, ok := dst.(*syntax.Name); ok && name.Value == "_" { + return + } + + var dstType types2.Type + if rang.Def { + // For `:=` assignments, the LHS names only appear in Defs, + // not Types (as used by typeOf). + dstType = w.p.info.Defs[dst.(*syntax.Name)].(*types2.Var).Type() + } else { + dstType = w.p.typeOf(dst) + } + + w.convRTTI(src, dstType) + } + + keyType, valueType := types2.RangeKeyVal(w.p.typeOf(rang.X)) + assign(0, keyType) + assign(1, valueType) + } + + } else { + if stmt.Cond != nil && w.p.staticBool(&stmt.Cond) < 0 { // always false + stmt.Post = nil + stmt.Body.List = nil + } + + w.pos(stmt) + w.stmt(stmt.Init) + w.optExpr(stmt.Cond) + w.stmt(stmt.Post) + } + + w.blockStmt(stmt.Body) + w.Bool(w.distinctVars(stmt)) + w.closeAnotherScope() +} + +func (w *writer) distinctVars(stmt *syntax.ForStmt) bool { + lv := base.Debug.LoopVar + fileVersion := w.p.info.FileVersions[stmt.Pos().FileBase()] + is122 := fileVersion == "" || version.Compare(fileVersion, "go1.22") >= 0 + + // Turning off loopvar for 1.22 is only possible with loopvarhash=qn + // + // Debug.LoopVar values to be preserved for 1.21 compatibility are 1 and 2, + // which are also set (=1) by GOEXPERIMENT=loopvar. The knobs for turning on + // the new, unshared, loopvar behavior apply to versions less than 1.21 because + // (1) 1.21 also did that and (2) this is believed to be the likely use case; + // anyone checking to see if it affects their code will just run the GOEXPERIMENT + // but will not also update all their go.mod files to 1.21. + // + // -gcflags=-d=loopvar=3 enables logging for 1.22 but does not turn loopvar on for <= 1.21. + + return is122 || lv > 0 && lv != 3 +} + +func (w *writer) ifStmt(stmt *syntax.IfStmt) { + cond := w.p.staticBool(&stmt.Cond) + + w.Sync(pkgbits.SyncIfStmt) + w.openScope(stmt.Pos()) + w.pos(stmt) + w.stmt(stmt.Init) + w.expr(stmt.Cond) + w.Int(cond) + if cond >= 0 { + w.blockStmt(stmt.Then) + } else { + w.pos(stmt.Then.Rbrace) + } + if cond <= 0 { + w.stmt(stmt.Else) + } + w.closeAnotherScope() +} + +func (w *writer) selectStmt(stmt *syntax.SelectStmt) { + w.Sync(pkgbits.SyncSelectStmt) + + w.pos(stmt) + w.Len(len(stmt.Body)) + for i, clause := range stmt.Body { + if i > 0 { + w.closeScope(clause.Pos()) + } + w.openScope(clause.Pos()) + + w.pos(clause) + w.stmt(clause.Comm) + w.stmts(clause.Body) + } + if len(stmt.Body) > 0 { + w.closeScope(stmt.Rbrace) + } +} + +func (w *writer) switchStmt(stmt *syntax.SwitchStmt) { + w.Sync(pkgbits.SyncSwitchStmt) + + w.openScope(stmt.Pos()) + w.pos(stmt) + w.stmt(stmt.Init) + + var iface, tagType types2.Type + var tagTypeIsChan bool + if guard, ok := stmt.Tag.(*syntax.TypeSwitchGuard); w.Bool(ok) { + iface = w.p.typeOf(guard.X) + + w.pos(guard) + if tag := guard.Lhs; w.Bool(tag != nil) { + w.pos(tag) + + // Like w.localIdent, but we don't have a types2.Object. + w.Sync(pkgbits.SyncLocalIdent) + w.pkg(w.p.curpkg) + w.String(tag.Value) + } + w.expr(guard.X) + } else { + tag := stmt.Tag + + var tagValue constant.Value + if tag != nil { + tv := w.p.typeAndValue(tag) + tagType = tv.Type + tagValue = tv.Value + _, tagTypeIsChan = tagType.Underlying().(*types2.Chan) + } else { + tagType = types2.Typ[types2.Bool] + tagValue = constant.MakeBool(true) + } + + if tagValue != nil { + // If the switch tag has a constant value, look for a case + // clause that we always branch to. + func() { + var target *syntax.CaseClause + Outer: + for _, clause := range stmt.Body { + if clause.Cases == nil { + target = clause + } + for _, cas := range syntax.UnpackListExpr(clause.Cases) { + tv := w.p.typeAndValue(cas) + if tv.Value == nil { + return // non-constant case; give up + } + if constant.Compare(tagValue, token.EQL, tv.Value) { + target = clause + break Outer + } + } + } + // We've found the target clause, if any. + + if target != nil { + if hasFallthrough(target.Body) { + return // fallthrough is tricky; give up + } + + // Rewrite as single "default" case. + target.Cases = nil + stmt.Body = []*syntax.CaseClause{target} + } else { + stmt.Body = nil + } + + // Clear switch tag (i.e., replace with implicit "true"). + tag = nil + stmt.Tag = nil + tagType = types2.Typ[types2.Bool] + }() + } + + // Walk is going to emit comparisons between the tag value and + // each case expression, and we want these comparisons to always + // have the same type. If there are any case values that can't be + // converted to the tag value's type, then convert everything to + // `any` instead. + // + // Except that we need to keep comparisons of channel values from + // being wrapped in any(). See issue #67190. + + if !tagTypeIsChan { + Outer: + for _, clause := range stmt.Body { + for _, cas := range syntax.UnpackListExpr(clause.Cases) { + if casType := w.p.typeOf(cas); !types2.AssignableTo(casType, tagType) && (types2.IsInterface(casType) || types2.IsInterface(tagType)) { + tagType = types2.NewInterfaceType(nil, nil) + break Outer + } + } + } + } + + if w.Bool(tag != nil) { + w.implicitConvExpr(tagType, tag) + } + } + + w.Len(len(stmt.Body)) + for i, clause := range stmt.Body { + if i > 0 { + w.closeScope(clause.Pos()) + } + w.openScope(clause.Pos()) + + w.pos(clause) + + cases := syntax.UnpackListExpr(clause.Cases) + if iface != nil { + w.Len(len(cases)) + for _, cas := range cases { + if w.Bool(isNil(w.p, cas)) { + continue + } + w.exprType(iface, cas) + } + } else { + // As if w.exprList(clause.Cases), + // but with implicit conversions to tagType. + + w.Sync(pkgbits.SyncExprList) + w.Sync(pkgbits.SyncExprs) + w.Len(len(cases)) + for _, cas := range cases { + typ := tagType + if tagTypeIsChan { + typ = nil + } + w.implicitConvExpr(typ, cas) + } + } + + if obj, ok := w.p.info.Implicits[clause]; ok { + // TODO(mdempsky): These pos details are quirkish, but also + // necessary so the variable's position is correct for DWARF + // scope assignment later. It would probably be better for us to + // instead just set the variable's DWARF scoping info earlier so + // we can give it the correct position information. + pos := clause.Pos() + if typs := syntax.UnpackListExpr(clause.Cases); len(typs) != 0 { + pos = typeExprEndPos(typs[len(typs)-1]) + } + w.pos(pos) + + obj := obj.(*types2.Var) + w.typ(obj.Type()) + w.addLocal(obj) + } + + w.stmts(clause.Body) + } + if len(stmt.Body) > 0 { + w.closeScope(stmt.Rbrace) + } + + w.closeScope(stmt.Rbrace) +} + +func (w *writer) label(label *syntax.Name) { + w.Sync(pkgbits.SyncLabel) + + // TODO(mdempsky): Replace label strings with dense indices. + w.String(label.Value) +} + +func (w *writer) optLabel(label *syntax.Name) { + w.Sync(pkgbits.SyncOptLabel) + if w.Bool(label != nil) { + w.label(label) + } +} + +// @@@ Expressions + +// expr writes the given expression into the function body bitstream. +func (w *writer) expr(expr syntax.Expr) { + base.Assertf(expr != nil, "missing expression") + + expr = syntax.Unparen(expr) // skip parens; unneeded after typecheck + + obj, inst := lookupObj(w.p, expr) + targs := inst.TypeArgs + + if tv, ok := w.p.maybeTypeAndValue(expr); ok { + if tv.IsRuntimeHelper() { + if pkg := obj.Pkg(); pkg != nil && pkg.Name() == "runtime" { + objName := obj.Name() + w.Code(exprRuntimeBuiltin) + w.String(objName) + return + } + } + + if tv.IsType() { + w.p.fatalf(expr, "unexpected type expression %v", syntax.String(expr)) + } + + if tv.Value != nil { + w.Code(exprConst) + w.pos(expr) + typ := idealType(tv) + assert(typ != nil) + w.typ(typ) + w.Value(tv.Value) + return + } + + if _, isNil := obj.(*types2.Nil); isNil { + w.Code(exprZero) + w.pos(expr) + w.typ(tv.Type) + return + } + + // With shape types (and particular pointer shaping), we may have + // an expression of type "go.shape.*uint8", but need to reshape it + // to another shape-identical type to allow use in field + // selection, indexing, etc. + if typ := tv.Type; !tv.IsBuiltin() && !isTuple(typ) && !isUntyped(typ) { + w.Code(exprReshape) + w.typ(typ) + // fallthrough + } + } + + if obj != nil { + if targs.Len() != 0 { + obj := obj.(*types2.Func) + + w.Code(exprFuncInst) + w.pos(expr) + w.funcInst(obj, targs) + return + } + + if isGlobal(obj) { + w.Code(exprGlobal) + w.obj(obj, nil) + return + } + + obj := obj.(*types2.Var) + assert(!obj.IsField()) + + w.Code(exprLocal) + w.useLocal(expr.Pos(), obj) + return + } + + switch expr := expr.(type) { + default: + w.p.unexpected("expression", expr) + + case *syntax.CompositeLit: + w.Code(exprCompLit) + w.compLit(expr) + + case *syntax.FuncLit: + w.Code(exprFuncLit) + w.funcLit(expr) + + case *syntax.SelectorExpr: + sel, ok := w.p.info.Selections[expr] + assert(ok) + + switch sel.Kind() { + default: + w.p.fatalf(expr, "unexpected selection kind: %v", sel.Kind()) + + case types2.FieldVal: + w.Code(exprFieldVal) + w.expr(expr.X) + w.pos(expr) + w.selector(sel.Obj()) + + case types2.MethodVal: + w.Code(exprMethodVal) + typ := w.recvExpr(expr, sel) + w.pos(expr) + w.methodExpr(expr, typ, sel) + + case types2.MethodExpr: + w.Code(exprMethodExpr) + + tv := w.p.typeAndValue(expr.X) + assert(tv.IsType()) + + index := sel.Index() + implicits := index[:len(index)-1] + + typ := tv.Type + w.typ(typ) + + w.Len(len(implicits)) + for _, ix := range implicits { + w.Len(ix) + typ = deref2(typ).Underlying().(*types2.Struct).Field(ix).Type() + } + + recv := sel.Obj().(*types2.Func).Type().(*types2.Signature).Recv().Type() + if w.Bool(isPtrTo(typ, recv)) { // need deref + typ = recv + } else if w.Bool(isPtrTo(recv, typ)) { // need addr + typ = recv + } + + w.pos(expr) + w.methodExpr(expr, typ, sel) + } + + case *syntax.IndexExpr: + _ = w.p.typeOf(expr.Index) // ensure this is an index expression, not an instantiation + + xtyp := w.p.typeOf(expr.X) + + var keyType types2.Type + if mapType, ok := types2.CoreType(xtyp).(*types2.Map); ok { + keyType = mapType.Key() + } + + w.Code(exprIndex) + w.expr(expr.X) + w.pos(expr) + w.implicitConvExpr(keyType, expr.Index) + if keyType != nil { + w.rtype(xtyp) + } + + case *syntax.SliceExpr: + w.Code(exprSlice) + w.expr(expr.X) + w.pos(expr) + for _, n := range &expr.Index { + w.optExpr(n) + } + + case *syntax.AssertExpr: + iface := w.p.typeOf(expr.X) + + w.Code(exprAssert) + w.expr(expr.X) + w.pos(expr) + w.exprType(iface, expr.Type) + w.rtype(iface) + + case *syntax.Operation: + if expr.Y == nil { + w.Code(exprUnaryOp) + w.op(unOps[expr.Op]) + w.pos(expr) + w.expr(expr.X) + break + } + + var commonType types2.Type + switch expr.Op { + case syntax.Shl, syntax.Shr: + // ok: operands are allowed to have different types + default: + xtyp := w.p.typeOf(expr.X) + ytyp := w.p.typeOf(expr.Y) + switch { + case types2.AssignableTo(xtyp, ytyp): + commonType = ytyp + case types2.AssignableTo(ytyp, xtyp): + commonType = xtyp + default: + w.p.fatalf(expr, "failed to find common type between %v and %v", xtyp, ytyp) + } + } + + w.Code(exprBinaryOp) + w.op(binOps[expr.Op]) + w.implicitConvExpr(commonType, expr.X) + w.pos(expr) + w.implicitConvExpr(commonType, expr.Y) + + case *syntax.CallExpr: + tv := w.p.typeAndValue(expr.Fun) + if tv.IsType() { + assert(len(expr.ArgList) == 1) + assert(!expr.HasDots) + w.convertExpr(tv.Type, expr.ArgList[0], false) + break + } + + var rtype types2.Type + if tv.IsBuiltin() { + switch obj, _ := lookupObj(w.p, syntax.Unparen(expr.Fun)); obj.Name() { + case "make": + assert(len(expr.ArgList) >= 1) + assert(!expr.HasDots) + + w.Code(exprMake) + w.pos(expr) + w.exprType(nil, expr.ArgList[0]) + w.exprs(expr.ArgList[1:]) + + typ := w.p.typeOf(expr) + switch coreType := types2.CoreType(typ).(type) { + default: + w.p.fatalf(expr, "unexpected core type: %v", coreType) + case *types2.Chan: + w.rtype(typ) + case *types2.Map: + w.rtype(typ) + case *types2.Slice: + w.rtype(sliceElem(typ)) + } + + return + + case "new": + assert(len(expr.ArgList) == 1) + assert(!expr.HasDots) + arg := expr.ArgList[0] + + w.Code(exprNew) + w.pos(expr) + tv := w.p.typeAndValue(arg) + if w.Bool(!tv.IsType()) { + w.expr(arg) // new(expr), go1.26 + } else { + w.exprType(nil, arg) // new(T) + } + return + + case "Sizeof": + assert(len(expr.ArgList) == 1) + assert(!expr.HasDots) + + w.Code(exprSizeof) + w.pos(expr) + w.typ(w.p.typeOf(expr.ArgList[0])) + return + + case "Alignof": + assert(len(expr.ArgList) == 1) + assert(!expr.HasDots) + + w.Code(exprAlignof) + w.pos(expr) + w.typ(w.p.typeOf(expr.ArgList[0])) + return + + case "Offsetof": + assert(len(expr.ArgList) == 1) + assert(!expr.HasDots) + selector := syntax.Unparen(expr.ArgList[0]).(*syntax.SelectorExpr) + index := w.p.info.Selections[selector].Index() + + w.Code(exprOffsetof) + w.pos(expr) + w.typ(deref2(w.p.typeOf(selector.X))) + w.Len(len(index) - 1) + for _, idx := range index { + w.Len(idx) + } + return + + case "append": + rtype = sliceElem(w.p.typeOf(expr)) + case "copy": + typ := w.p.typeOf(expr.ArgList[0]) + if tuple, ok := typ.(*types2.Tuple); ok { // "copy(g())" + typ = tuple.At(0).Type() + } + rtype = sliceElem(typ) + case "delete": + typ := w.p.typeOf(expr.ArgList[0]) + if tuple, ok := typ.(*types2.Tuple); ok { // "delete(g())" + typ = tuple.At(0).Type() + } + rtype = typ + case "Slice": + rtype = sliceElem(w.p.typeOf(expr)) + } + } + + writeFunExpr := func() { + fun := syntax.Unparen(expr.Fun) + + if selector, ok := fun.(*syntax.SelectorExpr); ok { + if sel, ok := w.p.info.Selections[selector]; ok && sel.Kind() == types2.MethodVal { + w.Bool(true) // method call + typ := w.recvExpr(selector, sel) + w.methodExpr(selector, typ, sel) + return + } + } + + w.Bool(false) // not a method call (i.e., normal function call) + + if obj, inst := lookupObj(w.p, fun); w.Bool(obj != nil && inst.TypeArgs.Len() != 0) { + obj := obj.(*types2.Func) + + w.pos(fun) + w.funcInst(obj, inst.TypeArgs) + return + } + + w.expr(fun) + } + + sigType := types2.CoreType(tv.Type).(*types2.Signature) + paramTypes := sigType.Params() + + w.Code(exprCall) + writeFunExpr() + w.pos(expr) + + paramType := func(i int) types2.Type { + if sigType.Variadic() && !expr.HasDots && i >= paramTypes.Len()-1 { + return paramTypes.At(paramTypes.Len() - 1).Type().(*types2.Slice).Elem() + } + return paramTypes.At(i).Type() + } + + w.multiExpr(expr, paramType, expr.ArgList) + w.Bool(expr.HasDots) + if rtype != nil { + w.rtype(rtype) + } + } +} + +func sliceElem(typ types2.Type) types2.Type { + return types2.CoreType(typ).(*types2.Slice).Elem() +} + +func (w *writer) optExpr(expr syntax.Expr) { + if w.Bool(expr != nil) { + w.expr(expr) + } +} + +// recvExpr writes out expr.X, but handles any implicit addressing, +// dereferencing, and field selections appropriate for the method +// selection. +func (w *writer) recvExpr(expr *syntax.SelectorExpr, sel *types2.Selection) types2.Type { + index := sel.Index() + implicits := index[:len(index)-1] + + w.Code(exprRecv) + w.expr(expr.X) + w.pos(expr) + w.Len(len(implicits)) + + typ := w.p.typeOf(expr.X) + for _, ix := range implicits { + typ = deref2(typ).Underlying().(*types2.Struct).Field(ix).Type() + w.Len(ix) + } + + recv := sel.Obj().(*types2.Func).Type().(*types2.Signature).Recv().Type() + if w.Bool(isPtrTo(typ, recv)) { // needs deref + typ = recv + } else if w.Bool(isPtrTo(recv, typ)) { // needs addr + typ = recv + } + + return typ +} + +// funcInst writes a reference to an instantiated function. +func (w *writer) funcInst(obj *types2.Func, targs *types2.TypeList) { + info := w.p.objInstIdx(obj, targs, w.dict) + + // Type arguments list contains derived types; we can emit a static + // call to the shaped function, but need to dynamically compute the + // runtime dictionary pointer. + if w.Bool(info.anyDerived()) { + w.Len(w.dict.subdictIdx(info)) + return + } + + // Type arguments list is statically known; we can emit a static + // call with a statically reference to the respective runtime + // dictionary. + w.objInfo(info) +} + +// methodExpr writes out a reference to the method selected by +// expr. sel should be the corresponding types2.Selection, and recv +// the type produced after any implicit addressing, dereferencing, and +// field selection. (Note: recv might differ from sel.Obj()'s receiver +// parameter in the case of interface types, and is needed for +// handling type parameter methods.) +func (w *writer) methodExpr(expr *syntax.SelectorExpr, recv types2.Type, sel *types2.Selection) { + fun := sel.Obj().(*types2.Func) + sig := fun.Type().(*types2.Signature) + + w.typ(recv) + w.typ(sig) + w.pos(expr) + w.selector(fun) + + // Method on a type parameter. These require an indirect call + // through the current function's runtime dictionary. + if typeParam, ok := types2.Unalias(recv).(*types2.TypeParam); w.Bool(ok) { + typeParamIdx := w.dict.typeParamIndex(typeParam) + methodInfo := w.p.selectorIdx(fun) + + w.Len(w.dict.typeParamMethodExprIdx(typeParamIdx, methodInfo)) + return + } + + if isInterface(recv) != isInterface(sig.Recv().Type()) { + w.p.fatalf(expr, "isInterface inconsistency: %v and %v", recv, sig.Recv().Type()) + } + + if !isInterface(recv) { + if named, ok := types2.Unalias(deref2(recv)).(*types2.Named); ok { + obj, targs := splitNamed(named) + info := w.p.objInstIdx(obj, targs, w.dict) + + // Method on a derived receiver type. These can be handled by a + // static call to the shaped method, but require dynamically + // looking up the appropriate dictionary argument in the current + // function's runtime dictionary. + if w.p.hasImplicitTypeParams(obj) || info.anyDerived() { + w.Bool(true) // dynamic subdictionary + w.Len(w.dict.subdictIdx(info)) + return + } + + // Method on a fully known receiver type. These can be handled + // by a static call to the shaped method, and with a static + // reference to the receiver type's dictionary. + if targs.Len() != 0 { + w.Bool(false) // no dynamic subdictionary + w.Bool(true) // static dictionary + w.objInfo(info) + return + } + } + } + + w.Bool(false) // no dynamic subdictionary + w.Bool(false) // no static dictionary +} + +// multiExpr writes a sequence of expressions, where the i'th value is +// implicitly converted to dstType(i). It also handles when exprs is a +// single, multi-valued expression (e.g., the multi-valued argument in +// an f(g()) call, or the RHS operand in a comma-ok assignment). +func (w *writer) multiExpr(pos poser, dstType func(int) types2.Type, exprs []syntax.Expr) { + w.Sync(pkgbits.SyncMultiExpr) + + if len(exprs) == 1 { + expr := exprs[0] + if tuple, ok := w.p.typeOf(expr).(*types2.Tuple); ok { + assert(tuple.Len() > 1) + w.Bool(true) // N:1 assignment + w.pos(pos) + w.expr(expr) + + w.Len(tuple.Len()) + for i := 0; i < tuple.Len(); i++ { + src := tuple.At(i).Type() + // TODO(mdempsky): Investigate not writing src here. I think + // the reader should be able to infer it from expr anyway. + w.typ(src) + if dst := dstType(i); w.Bool(dst != nil && !types2.Identical(src, dst)) { + if src == nil || dst == nil { + w.p.fatalf(pos, "src is %v, dst is %v", src, dst) + } + if !types2.AssignableTo(src, dst) { + w.p.fatalf(pos, "%v is not assignable to %v", src, dst) + } + w.typ(dst) + w.convRTTI(src, dst) + } + } + return + } + } + + w.Bool(false) // N:N assignment + w.Len(len(exprs)) + for i, expr := range exprs { + w.implicitConvExpr(dstType(i), expr) + } +} + +// implicitConvExpr is like expr, but if dst is non-nil and different +// from expr's type, then an implicit conversion operation is inserted +// at expr's position. +func (w *writer) implicitConvExpr(dst types2.Type, expr syntax.Expr) { + w.convertExpr(dst, expr, true) +} + +func (w *writer) convertExpr(dst types2.Type, expr syntax.Expr, implicit bool) { + src := w.p.typeOf(expr) + + // Omit implicit no-op conversions. + identical := dst == nil || types2.Identical(src, dst) + if implicit && identical { + w.expr(expr) + return + } + + if implicit && !types2.AssignableTo(src, dst) { + w.p.fatalf(expr, "%v is not assignable to %v", src, dst) + } + + w.Code(exprConvert) + w.Bool(implicit) + w.typ(dst) + w.pos(expr) + w.convRTTI(src, dst) + w.Bool(isTypeParam(dst)) + w.Bool(identical) + w.expr(expr) +} + +func (w *writer) compLit(lit *syntax.CompositeLit) { + typ := w.p.typeOf(lit) + + w.Sync(pkgbits.SyncCompLit) + w.pos(lit) + w.typ(typ) + + if ptr, ok := types2.CoreType(typ).(*types2.Pointer); ok { + typ = ptr.Elem() + } + var keyType, elemType types2.Type + var structType *types2.Struct + switch typ0 := typ; typ := types2.CoreType(typ).(type) { + default: + w.p.fatalf(lit, "unexpected composite literal type: %v", typ) + case *types2.Array: + elemType = typ.Elem() + case *types2.Map: + w.rtype(typ0) + keyType, elemType = typ.Key(), typ.Elem() + case *types2.Slice: + elemType = typ.Elem() + case *types2.Struct: + structType = typ + } + + w.Len(len(lit.ElemList)) + for i, elem := range lit.ElemList { + elemType := elemType + if structType != nil { + if kv, ok := elem.(*syntax.KeyValueExpr); ok { + // use position of expr.Key rather than of elem (which has position of ':') + w.pos(kv.Key) + i = fieldIndex(w.p.info, structType, kv.Key.(*syntax.Name)) + elem = kv.Value + } else { + w.pos(elem) + } + elemType = structType.Field(i).Type() + w.Len(i) + } else { + if kv, ok := elem.(*syntax.KeyValueExpr); w.Bool(ok) { + // use position of expr.Key rather than of elem (which has position of ':') + w.pos(kv.Key) + w.implicitConvExpr(keyType, kv.Key) + elem = kv.Value + } + } + w.implicitConvExpr(elemType, elem) + } +} + +func (w *writer) funcLit(expr *syntax.FuncLit) { + sig := w.p.typeOf(expr).(*types2.Signature) + + body, closureVars := w.p.bodyIdx(sig, expr.Body, w.dict) + + w.Sync(pkgbits.SyncFuncLit) + w.pos(expr) + w.signature(sig) + w.Bool(w.p.rangeFuncBodyClosures[expr]) + + w.Len(len(closureVars)) + for _, cv := range closureVars { + w.pos(cv.pos) + w.useLocal(cv.pos, cv.var_) + } + + w.Reloc(pkgbits.SectionBody, body) +} + +type posVar struct { + pos syntax.Pos + var_ *types2.Var +} + +func (p posVar) String() string { + return p.pos.String() + ":" + p.var_.String() +} + +func (w *writer) exprs(exprs []syntax.Expr) { + w.Sync(pkgbits.SyncExprs) + w.Len(len(exprs)) + for _, expr := range exprs { + w.expr(expr) + } +} + +// rtype writes information so that the reader can construct an +// expression of type *runtime._type representing typ. +func (w *writer) rtype(typ types2.Type) { + typ = types2.Default(typ) + + info := w.p.typIdx(typ, w.dict) + w.rtypeInfo(info) +} + +func (w *writer) rtypeInfo(info typeInfo) { + w.Sync(pkgbits.SyncRType) + + if w.Bool(info.derived) { + w.Len(w.dict.rtypeIdx(info)) + } else { + w.typInfo(info) + } +} + +// varDictIndex writes out information for populating DictIndex for +// the ir.Name that will represent obj. +func (w *writer) varDictIndex(obj *types2.Var) { + info := w.p.typIdx(obj.Type(), w.dict) + if w.Bool(info.derived) { + w.Len(w.dict.rtypeIdx(info)) + } +} + +// isUntyped reports whether typ is an untyped type. +func isUntyped(typ types2.Type) bool { + // Note: types2.Unalias is unnecessary here, since untyped types can't be aliased. + basic, ok := typ.(*types2.Basic) + return ok && basic.Info()&types2.IsUntyped != 0 +} + +// isTuple reports whether typ is a tuple type. +func isTuple(typ types2.Type) bool { + // Note: types2.Unalias is unnecessary here, since tuple types can't be aliased. + _, ok := typ.(*types2.Tuple) + return ok +} + +func (w *writer) itab(typ, iface types2.Type) { + typ = types2.Default(typ) + iface = types2.Default(iface) + + typInfo := w.p.typIdx(typ, w.dict) + ifaceInfo := w.p.typIdx(iface, w.dict) + + w.rtypeInfo(typInfo) + w.rtypeInfo(ifaceInfo) + if w.Bool(typInfo.derived || ifaceInfo.derived) { + w.Len(w.dict.itabIdx(typInfo, ifaceInfo)) + } +} + +// convRTTI writes information so that the reader can construct +// expressions for converting from src to dst. +func (w *writer) convRTTI(src, dst types2.Type) { + w.Sync(pkgbits.SyncConvRTTI) + w.itab(src, dst) +} + +func (w *writer) exprType(iface types2.Type, typ syntax.Expr) { + base.Assertf(iface == nil || isInterface(iface), "%v must be nil or an interface type", iface) + + tv := w.p.typeAndValue(typ) + assert(tv.IsType()) + + w.Sync(pkgbits.SyncExprType) + w.pos(typ) + + if w.Bool(iface != nil && !iface.Underlying().(*types2.Interface).Empty()) { + w.itab(tv.Type, iface) + } else { + w.rtype(tv.Type) + + info := w.p.typIdx(tv.Type, w.dict) + w.Bool(info.derived) + } +} + +// isInterface reports whether typ is known to be an interface type. +// If typ is a type parameter, then isInterface reports an internal +// compiler error instead. +func isInterface(typ types2.Type) bool { + if _, ok := types2.Unalias(typ).(*types2.TypeParam); ok { + // typ is a type parameter and may be instantiated as either a + // concrete or interface type, so the writer can't depend on + // knowing this. + base.Fatalf("%v is a type parameter", typ) + } + + _, ok := typ.Underlying().(*types2.Interface) + return ok +} + +// op writes an Op into the bitstream. +func (w *writer) op(op ir.Op) { + // TODO(mdempsky): Remove in favor of explicit codes? Would make + // export data more stable against internal refactorings, but low + // priority at the moment. + assert(op != 0) + w.Sync(pkgbits.SyncOp) + w.Len(int(op)) +} + +// @@@ Package initialization + +// Caution: This code is still clumsy, because toolstash -cmp is +// particularly sensitive to it. + +type typeDeclGen struct { + *syntax.TypeDecl + gen int + + // Implicit type parameters in scope at this type declaration. + implicits []*types2.TypeParam +} + +type fileImports struct { + importedEmbed, importedUnsafe bool +} + +// declCollector is a visitor type that collects compiler-needed +// information about declarations that types2 doesn't track. +// +// Notably, it maps declared types and functions back to their +// declaration statement, keeps track of implicit type parameters, and +// assigns unique type "generation" numbers to local defined types. +type declCollector struct { + pw *pkgWriter + typegen *int + file *fileImports + withinFunc bool + implicits []*types2.TypeParam +} + +func (c *declCollector) withTParams(obj types2.Object) *declCollector { + tparams := objTypeParams(obj) + n := tparams.Len() + if n == 0 { + return c + } + + copy := *c + copy.implicits = copy.implicits[:len(copy.implicits):len(copy.implicits)] + for i := 0; i < n; i++ { + copy.implicits = append(copy.implicits, tparams.At(i)) + } + return © +} + +func (c *declCollector) Visit(n syntax.Node) syntax.Visitor { + pw := c.pw + + switch n := n.(type) { + case *syntax.File: + pw.checkPragmas(n.Pragma, ir.GoBuildPragma, false) + + case *syntax.ImportDecl: + pw.checkPragmas(n.Pragma, 0, false) + + switch pw.info.PkgNameOf(n).Imported().Path() { + case "embed": + c.file.importedEmbed = true + case "unsafe": + c.file.importedUnsafe = true + } + + case *syntax.ConstDecl: + pw.checkPragmas(n.Pragma, 0, false) + + case *syntax.FuncDecl: + pw.checkPragmas(n.Pragma, funcPragmas, false) + + obj := pw.info.Defs[n.Name].(*types2.Func) + pw.funDecls[obj] = n + + return c.withTParams(obj) + + case *syntax.TypeDecl: + obj := pw.info.Defs[n.Name].(*types2.TypeName) + d := typeDeclGen{TypeDecl: n, implicits: c.implicits} + + if n.Alias { + pw.checkPragmas(n.Pragma, 0, false) + } else { + pw.checkPragmas(n.Pragma, 0, false) + + // Assign a unique ID to function-scoped defined types. + if c.withinFunc { + *c.typegen++ + d.gen = *c.typegen + } + } + + pw.typDecls[obj] = d + + // TODO(mdempsky): Omit? Not strictly necessary; only matters for + // type declarations within function literals within parameterized + // type declarations, but types2 the function literals will be + // constant folded away. + return c.withTParams(obj) + + case *syntax.VarDecl: + pw.checkPragmas(n.Pragma, 0, true) + + if p, ok := n.Pragma.(*pragmas); ok && len(p.Embeds) > 0 { + if err := checkEmbed(n, c.file.importedEmbed, c.withinFunc); err != nil { + pw.errorf(p.Embeds[0].Pos, "%s", err) + } + } + + case *syntax.BlockStmt: + if !c.withinFunc { + copy := *c + copy.withinFunc = true + return © + } + } + + return c +} + +func (pw *pkgWriter) collectDecls(noders []*noder) { + var typegen int + for _, p := range noders { + var file fileImports + + syntax.Walk(p.file, &declCollector{ + pw: pw, + typegen: &typegen, + file: &file, + }) + + pw.cgoPragmas = append(pw.cgoPragmas, p.pragcgobuf...) + + for _, l := range p.linknames { + if !file.importedUnsafe { + pw.errorf(l.pos, "//go:linkname only allowed in Go files that import \"unsafe\"") + continue + } + if strings.Contains(l.remote, "[") && strings.Contains(l.remote, "]") { + pw.errorf(l.pos, "//go:linkname reference of an instantiation is not allowed") + continue + } + + switch obj := pw.curpkg.Scope().Lookup(l.local).(type) { + case *types2.Func, *types2.Var: + if _, ok := pw.linknames[obj]; !ok { + pw.linknames[obj] = l.remote + } else { + pw.errorf(l.pos, "duplicate //go:linkname for %s", l.local) + } + + default: + if types.AllowsGoVersion(1, 18) { + pw.errorf(l.pos, "//go:linkname must refer to declared function or variable") + } + } + } + } +} + +func (pw *pkgWriter) checkPragmas(p syntax.Pragma, allowed ir.PragmaFlag, embedOK bool) { + if p == nil { + return + } + pragma := p.(*pragmas) + + for _, pos := range pragma.Pos { + if pos.Flag&^allowed != 0 { + pw.errorf(pos.Pos, "misplaced compiler directive") + } + } + + if !embedOK { + for _, e := range pragma.Embeds { + pw.errorf(e.Pos, "misplaced go:embed directive") + } + } +} + +func (w *writer) pkgInit(noders []*noder) { + w.Len(len(w.p.cgoPragmas)) + for _, cgoPragma := range w.p.cgoPragmas { + w.Strings(cgoPragma) + } + + w.pkgInitOrder() + + w.Sync(pkgbits.SyncDecls) + for _, p := range noders { + for _, decl := range p.file.DeclList { + w.pkgDecl(decl) + } + } + w.Code(declEnd) + + w.Sync(pkgbits.SyncEOF) +} + +func (w *writer) pkgInitOrder() { + // TODO(mdempsky): Write as a function body instead? + w.Len(len(w.p.info.InitOrder)) + for _, init := range w.p.info.InitOrder { + w.Len(len(init.Lhs)) + for _, v := range init.Lhs { + w.obj(v, nil) + } + w.expr(init.Rhs) + } +} + +func (w *writer) pkgDecl(decl syntax.Decl) { + switch decl := decl.(type) { + default: + w.p.unexpected("declaration", decl) + + case *syntax.ImportDecl: + + case *syntax.ConstDecl: + w.Code(declOther) + w.pkgObjs(decl.NameList...) + + case *syntax.FuncDecl: + if decl.Name.Value == "_" { + break // skip blank functions + } + + obj := w.p.info.Defs[decl.Name].(*types2.Func) + sig := obj.Type().(*types2.Signature) + + if sig.RecvTypeParams() != nil || sig.TypeParams() != nil { + break // skip generic functions + } + + if recv := sig.Recv(); recv != nil { + w.Code(declMethod) + w.typ(recvBase(recv)) + w.selector(obj) + break + } + + w.Code(declFunc) + w.pkgObjs(decl.Name) + + case *syntax.TypeDecl: + if len(decl.TParamList) != 0 { + break // skip generic type decls + } + + if decl.Name.Value == "_" { + break // skip blank type decls + } + + name := w.p.info.Defs[decl.Name].(*types2.TypeName) + // Skip type declarations for interfaces that are only usable as + // type parameter bounds. + if iface, ok := name.Type().Underlying().(*types2.Interface); ok && !iface.IsMethodSet() { + break + } + + w.Code(declOther) + w.pkgObjs(decl.Name) + + case *syntax.VarDecl: + w.Code(declVar) + w.pkgObjs(decl.NameList...) + + var embeds []pragmaEmbed + if p, ok := decl.Pragma.(*pragmas); ok { + embeds = p.Embeds + } + w.Len(len(embeds)) + for _, embed := range embeds { + w.pos(embed.Pos) + w.Strings(embed.Patterns) + } + } +} + +func (w *writer) pkgObjs(names ...*syntax.Name) { + w.Sync(pkgbits.SyncDeclNames) + w.Len(len(names)) + + for _, name := range names { + obj, ok := w.p.info.Defs[name] + assert(ok) + + w.Sync(pkgbits.SyncDeclName) + w.obj(obj, nil) + } +} + +// @@@ Helpers + +// staticBool analyzes a boolean expression and reports whether it's +// always true (positive result), always false (negative result), or +// unknown (zero). +// +// It also simplifies the expression while preserving semantics, if +// possible. +func (pw *pkgWriter) staticBool(ep *syntax.Expr) int { + if val := pw.typeAndValue(*ep).Value; val != nil { + if constant.BoolVal(val) { + return +1 + } else { + return -1 + } + } + + if e, ok := (*ep).(*syntax.Operation); ok { + switch e.Op { + case syntax.Not: + return pw.staticBool(&e.X) + + case syntax.AndAnd: + x := pw.staticBool(&e.X) + if x < 0 { + *ep = e.X + return x + } + + y := pw.staticBool(&e.Y) + if x > 0 || y < 0 { + if pw.typeAndValue(e.X).Value != nil { + *ep = e.Y + } + return y + } + + case syntax.OrOr: + x := pw.staticBool(&e.X) + if x > 0 { + *ep = e.X + return x + } + + y := pw.staticBool(&e.Y) + if x < 0 || y > 0 { + if pw.typeAndValue(e.X).Value != nil { + *ep = e.Y + } + return y + } + } + } + + return 0 +} + +// hasImplicitTypeParams reports whether obj is a defined type with +// implicit type parameters (e.g., declared within a generic function +// or method). +func (pw *pkgWriter) hasImplicitTypeParams(obj *types2.TypeName) bool { + if obj.Pkg() == pw.curpkg { + decl, ok := pw.typDecls[obj] + assert(ok) + if len(decl.implicits) != 0 { + return true + } + } + return false +} + +// isDefinedType reports whether obj is a defined type. +func isDefinedType(obj types2.Object) bool { + if obj, ok := obj.(*types2.TypeName); ok { + return !obj.IsAlias() + } + return false +} + +// isGlobal reports whether obj was declared at package scope. +// +// Caveat: blank objects are not declared. +func isGlobal(obj types2.Object) bool { + return obj.Parent() == obj.Pkg().Scope() +} + +// lookupObj returns the object that expr refers to, if any. If expr +// is an explicit instantiation of a generic object, then the instance +// object is returned as well. +func lookupObj(p *pkgWriter, expr syntax.Expr) (obj types2.Object, inst types2.Instance) { + if index, ok := expr.(*syntax.IndexExpr); ok { + args := syntax.UnpackListExpr(index.Index) + if len(args) == 1 { + tv := p.typeAndValue(args[0]) + if tv.IsValue() { + return // normal index expression + } + } + + expr = index.X + } + + // Strip package qualifier, if present. + if sel, ok := expr.(*syntax.SelectorExpr); ok { + if !isPkgQual(p.info, sel) { + return // normal selector expression + } + expr = sel.Sel + } + + if name, ok := expr.(*syntax.Name); ok { + obj = p.info.Uses[name] + inst = p.info.Instances[name] + } + return +} + +// isPkgQual reports whether the given selector expression is a +// package-qualified identifier. +func isPkgQual(info *types2.Info, sel *syntax.SelectorExpr) bool { + if name, ok := sel.X.(*syntax.Name); ok { + _, isPkgName := info.Uses[name].(*types2.PkgName) + return isPkgName + } + return false +} + +// isNil reports whether expr is a (possibly parenthesized) reference +// to the predeclared nil value. +func isNil(p *pkgWriter, expr syntax.Expr) bool { + tv := p.typeAndValue(expr) + return tv.IsNil() +} + +// isBuiltin reports whether expr is a (possibly parenthesized) +// referenced to the specified built-in function. +func (pw *pkgWriter) isBuiltin(expr syntax.Expr, builtin string) bool { + if name, ok := syntax.Unparen(expr).(*syntax.Name); ok && name.Value == builtin { + return pw.typeAndValue(name).IsBuiltin() + } + return false +} + +// recvBase returns the base type for the given receiver parameter. +func recvBase(recv *types2.Var) *types2.Named { + typ := types2.Unalias(recv.Type()) + if ptr, ok := typ.(*types2.Pointer); ok { + typ = types2.Unalias(ptr.Elem()) + } + return typ.(*types2.Named) +} + +// namesAsExpr returns a list of names as a syntax.Expr. +func namesAsExpr(names []*syntax.Name) syntax.Expr { + if len(names) == 1 { + return names[0] + } + + exprs := make([]syntax.Expr, len(names)) + for i, name := range names { + exprs[i] = name + } + return &syntax.ListExpr{ElemList: exprs} +} + +// fieldIndex returns the index of the struct field named by key. +func fieldIndex(info *types2.Info, str *types2.Struct, key *syntax.Name) int { + field := info.Uses[key].(*types2.Var) + + for i := 0; i < str.NumFields(); i++ { + if str.Field(i) == field { + return i + } + } + + panic(fmt.Sprintf("%s: %v is not a field of %v", key.Pos(), field, str)) +} + +// objTypeParams returns the type parameters on the given object. +func objTypeParams(obj types2.Object) *types2.TypeParamList { + switch obj := obj.(type) { + case *types2.Func: + sig := obj.Type().(*types2.Signature) + if sig.Recv() != nil { + return sig.RecvTypeParams() + } + return sig.TypeParams() + case *types2.TypeName: + switch t := obj.Type().(type) { + case *types2.Named: + return t.TypeParams() + case *types2.Alias: + return t.TypeParams() + } + } + return nil +} + +// splitNamed decomposes a use of a defined type into its original +// type definition and the type arguments used to instantiate it. +func splitNamed(typ *types2.Named) (*types2.TypeName, *types2.TypeList) { + base.Assertf(typ.TypeParams().Len() == typ.TypeArgs().Len(), "use of uninstantiated type: %v", typ) + + orig := typ.Origin() + base.Assertf(orig.TypeArgs() == nil, "origin %v of %v has type arguments", orig, typ) + base.Assertf(typ.Obj() == orig.Obj(), "%v has object %v, but %v has object %v", typ, typ.Obj(), orig, orig.Obj()) + + return typ.Obj(), typ.TypeArgs() +} + +// splitAlias is like splitNamed, but for an alias type. +func splitAlias(typ *types2.Alias) (*types2.TypeName, *types2.TypeList) { + orig := typ.Origin() + base.Assertf(typ.Obj() == orig.Obj(), "alias type %v has object %v, but %v has object %v", typ, typ.Obj(), orig, orig.Obj()) + + return typ.Obj(), typ.TypeArgs() +} + +func asPragmaFlag(p syntax.Pragma) ir.PragmaFlag { + if p == nil { + return 0 + } + return p.(*pragmas).Flag +} + +func asWasmImport(p syntax.Pragma) *WasmImport { + if p == nil { + return nil + } + return p.(*pragmas).WasmImport +} + +func asWasmExport(p syntax.Pragma) *WasmExport { + if p == nil { + return nil + } + return p.(*pragmas).WasmExport +} + +// isPtrTo reports whether from is the type *to. +func isPtrTo(from, to types2.Type) bool { + ptr, ok := types2.Unalias(from).(*types2.Pointer) + return ok && types2.Identical(ptr.Elem(), to) +} + +// hasFallthrough reports whether stmts ends in a fallthrough +// statement. +func hasFallthrough(stmts []syntax.Stmt) bool { + // From spec: the last non-empty statement may be a (possibly labeled) "fallthrough" statement + // Stripping (possible nested) labeled statement if any. + stmt := lastNonEmptyStmt(stmts) + for { + ls, ok := stmt.(*syntax.LabeledStmt) + if !ok { + break + } + stmt = ls.Stmt + } + last, ok := stmt.(*syntax.BranchStmt) + return ok && last.Tok == syntax.Fallthrough +} + +// lastNonEmptyStmt returns the last non-empty statement in list, if +// any. +func lastNonEmptyStmt(stmts []syntax.Stmt) syntax.Stmt { + for i := len(stmts) - 1; i >= 0; i-- { + stmt := stmts[i] + if _, ok := stmt.(*syntax.EmptyStmt); !ok { + return stmt + } + } + return nil +} + +// terminates reports whether stmt terminates normal control flow +// (i.e., does not merely advance to the following statement). +func (pw *pkgWriter) terminates(stmt syntax.Stmt) bool { + switch stmt := stmt.(type) { + case *syntax.BranchStmt: + if stmt.Tok == syntax.Goto { + return true + } + case *syntax.ReturnStmt: + return true + case *syntax.ExprStmt: + if call, ok := syntax.Unparen(stmt.X).(*syntax.CallExpr); ok { + if pw.isBuiltin(call.Fun, "panic") { + return true + } + } + + // The handling of BlockStmt here is approximate, but it serves to + // allow dead-code elimination for: + // + // if true { + // return x + // } + // unreachable + case *syntax.IfStmt: + cond := pw.staticBool(&stmt.Cond) + return (cond < 0 || pw.terminates(stmt.Then)) && (cond > 0 || pw.terminates(stmt.Else)) + case *syntax.BlockStmt: + return pw.terminates(lastNonEmptyStmt(stmt.List)) + } + + return false +} diff --git a/go/src/cmd/compile/internal/objw/objw.go b/go/src/cmd/compile/internal/objw/objw.go new file mode 100644 index 0000000000000000000000000000000000000000..77744672c197a980e42b990414f4ccc66db86047 --- /dev/null +++ b/go/src/cmd/compile/internal/objw/objw.go @@ -0,0 +1,102 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package objw + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/bitvec" + "cmd/compile/internal/types" + "cmd/internal/obj" + "encoding/binary" +) + +// Uint8 writes an unsigned byte v into s at offset off, +// and returns the next unused offset (i.e., off+1). +func Uint8(s *obj.LSym, off int, v uint8) int { + return UintN(s, off, uint64(v), 1) +} + +func Uint16(s *obj.LSym, off int, v uint16) int { + return UintN(s, off, uint64(v), 2) +} + +func Uint32(s *obj.LSym, off int, v uint32) int { + return UintN(s, off, uint64(v), 4) +} + +func Uintptr(s *obj.LSym, off int, v uint64) int { + return UintN(s, off, v, types.PtrSize) +} + +// Uvarint writes a varint v into s at offset off, +// and returns the next unused offset. +func Uvarint(s *obj.LSym, off int, v uint64) int { + var buf [binary.MaxVarintLen64]byte + n := binary.PutUvarint(buf[:], v) + return int(s.WriteBytes(base.Ctxt, int64(off), buf[:n])) +} + +func Bool(s *obj.LSym, off int, v bool) int { + w := 0 + if v { + w = 1 + } + return UintN(s, off, uint64(w), 1) +} + +// UintN writes an unsigned integer v of size wid bytes into s at offset off, +// and returns the next unused offset. +func UintN(s *obj.LSym, off int, v uint64, wid int) int { + if off&(wid-1) != 0 { + base.Fatalf("duintxxLSym: misaligned: v=%d wid=%d off=%d", v, wid, off) + } + s.WriteInt(base.Ctxt, int64(off), wid, int64(v)) + return off + wid +} + +func SymPtr(s *obj.LSym, off int, x *obj.LSym, xoff int) int { + off = int(types.RoundUp(int64(off), int64(types.PtrSize))) + s.WriteAddr(base.Ctxt, int64(off), types.PtrSize, x, int64(xoff)) + off += types.PtrSize + return off +} + +func SymPtrWeak(s *obj.LSym, off int, x *obj.LSym, xoff int) int { + off = int(types.RoundUp(int64(off), int64(types.PtrSize))) + s.WriteWeakAddr(base.Ctxt, int64(off), types.PtrSize, x, int64(xoff)) + off += types.PtrSize + return off +} + +func SymPtrOff(s *obj.LSym, off int, x *obj.LSym) int { + s.WriteOff(base.Ctxt, int64(off), x, 0) + off += 4 + return off +} + +func SymPtrWeakOff(s *obj.LSym, off int, x *obj.LSym) int { + s.WriteWeakOff(base.Ctxt, int64(off), x, 0) + off += 4 + return off +} + +func Global(s *obj.LSym, width int32, flags int16) { + if flags&obj.LOCAL != 0 { + s.Set(obj.AttrLocal, true) + flags &^= obj.LOCAL + } + base.Ctxt.Globl(s, int64(width), int(flags)) +} + +// BitVec writes the contents of bv into s as sequence of bytes +// in little-endian order, and returns the next unused offset. +func BitVec(s *obj.LSym, off int, bv bitvec.BitVec) int { + // Runtime reads the bitmaps as byte arrays. Oblige. + for j := 0; int32(j) < bv.N; j += 8 { + word := bv.B[j/32] + off = Uint8(s, off, uint8(word>>(uint(j)%32))) + } + return off +} diff --git a/go/src/cmd/compile/internal/objw/prog.go b/go/src/cmd/compile/internal/objw/prog.go new file mode 100644 index 0000000000000000000000000000000000000000..753fd8615ca9c53e84c1b119dcefc335cb8d0bf8 --- /dev/null +++ b/go/src/cmd/compile/internal/objw/prog.go @@ -0,0 +1,211 @@ +// Derived from Inferno utils/6c/txt.c +// https://bitbucket.org/inferno-os/inferno-os/src/master/utils/6c/txt.c +// +// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. +// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) +// Portions Copyright © 1997-1999 Vita Nuova Limited +// Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com) +// Portions Copyright © 2004,2006 Bruce Ellis +// Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) +// Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others +// Portions Copyright © 2009 The Go Authors. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package objw + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/internal/obj" + "cmd/internal/src" + "internal/abi" +) + +var sharedProgArray = new([10000]obj.Prog) // *T instead of T to work around issue 19839 + +// NewProgs returns a new Progs for fn. +// worker indicates which of the backend workers will use the Progs. +func NewProgs(fn *ir.Func, worker int) *Progs { + pp := new(Progs) + if base.Ctxt.CanReuseProgs() { + sz := len(sharedProgArray) / base.Flag.LowerC + pp.Cache = sharedProgArray[sz*worker : sz*(worker+1)] + } + pp.CurFunc = fn + + // prime the pump + pp.Next = pp.NewProg() + pp.Clear(pp.Next) + + pp.Pos = fn.Pos() + pp.SetText(fn) + // PCDATA tables implicitly start with index -1. + pp.PrevLive = -1 + pp.NextLive = pp.PrevLive + pp.NextUnsafe = pp.PrevUnsafe + return pp +} + +// Progs accumulates Progs for a function and converts them into machine code. +type Progs struct { + Text *obj.Prog // ATEXT Prog for this function + Next *obj.Prog // next Prog + PC int64 // virtual PC; count of Progs + Pos src.XPos // position to use for new Progs + CurFunc *ir.Func // fn these Progs are for + Cache []obj.Prog // local progcache + CacheIndex int // first free element of progcache + + NextLive StackMapIndex // liveness index for the next Prog + PrevLive StackMapIndex // last emitted liveness index + + NextUnsafe bool // unsafe mark for the next Prog + PrevUnsafe bool // last emitted unsafe mark +} + +type StackMapIndex int + +// StackMapDontCare indicates that the stack map index at a Value +// doesn't matter. +// +// This is a sentinel value that should never be emitted to the PCDATA +// stream. We use -1000 because that's obviously never a valid stack +// index (but -1 is). +const StackMapDontCare StackMapIndex = -1000 + +func (s StackMapIndex) StackMapValid() bool { + return s != StackMapDontCare +} + +func (pp *Progs) NewProg() *obj.Prog { + var p *obj.Prog + if pp.CacheIndex < len(pp.Cache) { + p = &pp.Cache[pp.CacheIndex] + pp.CacheIndex++ + } else { + p = new(obj.Prog) + } + p.Ctxt = base.Ctxt + return p +} + +// Flush converts from pp to machine code. +func (pp *Progs) Flush() { + plist := &obj.Plist{Firstpc: pp.Text, Curfn: pp.CurFunc} + obj.Flushplist(base.Ctxt, plist, pp.NewProg) +} + +// Free clears pp and any associated resources. +func (pp *Progs) Free() { + if base.Ctxt.CanReuseProgs() { + // Clear progs to enable GC and avoid abuse. + clear(pp.Cache[:pp.CacheIndex]) + } + // Clear pp to avoid abuse. + *pp = Progs{} +} + +// Prog adds a Prog with instruction As to pp. +func (pp *Progs) Prog(as obj.As) *obj.Prog { + if pp.NextLive != StackMapDontCare && pp.NextLive != pp.PrevLive { + // Emit stack map index change. + idx := pp.NextLive + pp.PrevLive = idx + p := pp.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_StackMapIndex) + p.To.SetConst(int64(idx)) + } + if pp.NextUnsafe != pp.PrevUnsafe { + // Emit unsafe-point marker. + pp.PrevUnsafe = pp.NextUnsafe + p := pp.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_UnsafePoint) + if pp.NextUnsafe { + p.To.SetConst(abi.UnsafePointUnsafe) + } else { + p.To.SetConst(abi.UnsafePointSafe) + } + } + + p := pp.Next + pp.Next = pp.NewProg() + pp.Clear(pp.Next) + p.Link = pp.Next + + if !pp.Pos.IsKnown() && base.Flag.K != 0 { + base.Warn("prog: unknown position (line 0)") + } + + p.As = as + p.Pos = pp.Pos + if pp.Pos.IsStmt() == src.PosIsStmt { + // Clear IsStmt for later Progs at this pos provided that as can be marked as a stmt + if LosesStmtMark(as) { + return p + } + pp.Pos = pp.Pos.WithNotStmt() + } + return p +} + +func (pp *Progs) Clear(p *obj.Prog) { + obj.Nopout(p) + p.As = obj.AEND + p.Pc = pp.PC + pp.PC++ +} + +func (pp *Progs) Append(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog { + q := pp.NewProg() + pp.Clear(q) + q.As = as + q.Pos = p.Pos + q.From.Type = ftype + q.From.Reg = freg + q.From.Offset = foffset + q.To.Type = ttype + q.To.Reg = treg + q.To.Offset = toffset + q.Link = p.Link + p.Link = q + return q +} + +func (pp *Progs) SetText(fn *ir.Func) { + if pp.Text != nil { + base.Fatalf("Progs.SetText called twice") + } + ptxt := pp.Prog(obj.ATEXT) + pp.Text = ptxt + + fn.LSym.Func().Text = ptxt + ptxt.From.Type = obj.TYPE_MEM + ptxt.From.Name = obj.NAME_EXTERN + ptxt.From.Sym = fn.LSym +} + +// LosesStmtMark reports whether a prog with op as loses its statement mark on the way to DWARF. +// The attributes from some opcodes are lost in translation. +// TODO: this is an artifact of how funcpctab combines information for instructions at a single PC. +// Should try to fix it there. +func LosesStmtMark(as obj.As) bool { + // is_stmt does not work for these; it DOES for ANOP even though that generates no code. + return as == obj.APCDATA || as == obj.AFUNCDATA +} diff --git a/go/src/cmd/compile/internal/pgoir/irgraph.go b/go/src/cmd/compile/internal/pgoir/irgraph.go new file mode 100644 index 0000000000000000000000000000000000000000..e879d438a620130a7bac3236f58b77ad40bdad8e --- /dev/null +++ b/go/src/cmd/compile/internal/pgoir/irgraph.go @@ -0,0 +1,503 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// A note on line numbers: when working with line numbers, we always use the +// binary-visible relative line number. i.e., the line number as adjusted by +// //line directives (ctxt.InnermostPos(ir.Node.Pos()).RelLine()). Use +// NodeLineOffset to compute line offsets. +// +// If you are thinking, "wait, doesn't that just make things more complex than +// using the real line number?", then you are 100% correct. Unfortunately, +// pprof profiles generated by the runtime always contain line numbers as +// adjusted by //line directives (because that is what we put in pclntab). Thus +// for the best behavior when attempting to match the source with the profile +// it makes sense to use the same line number space. +// +// Some of the effects of this to keep in mind: +// +// - For files without //line directives there is no impact, as RelLine() == +// Line(). +// - For functions entirely covered by the same //line directive (i.e., a +// directive before the function definition and no directives within the +// function), there should also be no impact, as line offsets within the +// function should be the same as the real line offsets. +// - Functions containing //line directives may be impacted. As fake line +// numbers need not be monotonic, we may compute negative line offsets. We +// should accept these and attempt to use them for best-effort matching, as +// these offsets should still match if the source is unchanged, and may +// continue to match with changed source depending on the impact of the +// changes on fake line numbers. +// - Functions containing //line directives may also contain duplicate lines, +// making it ambiguous which call the profile is referencing. This is a +// similar problem to multiple calls on a single real line, as we don't +// currently track column numbers. +// +// Long term it would be best to extend pprof profiles to include real line +// numbers. Until then, we have to live with these complexities. Luckily, +// //line directives that change line numbers in strange ways should be rare, +// and failing PGO matching on these files is not too big of a loss. + +// Package pgoir associates a PGO profile with the IR of the current package +// compilation. +package pgoir + +import ( + "bufio" + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/pgo" + "fmt" + "maps" + "os" +) + +// IRGraph is a call graph with nodes pointing to IRs of functions and edges +// carrying weights and callsite information. +// +// Nodes for indirect calls may have missing IR (IRNode.AST == nil) if the node +// is not visible from this package (e.g., not in the transitive deps). Keeping +// these nodes allows determining the hottest edge from a call even if that +// callee is not available. +// +// TODO(prattmic): Consider merging this data structure with Graph. This is +// effectively a copy of Graph aggregated to line number and pointing to IR. +type IRGraph struct { + // Nodes of the graph. Each node represents a function, keyed by linker + // symbol name. + IRNodes map[string]*IRNode +} + +// IRNode represents a node (function) in the IRGraph. +type IRNode struct { + // Pointer to the IR of the Function represented by this node. + AST *ir.Func + // Linker symbol name of the Function represented by this node. + // Populated only if AST == nil. + LinkerSymbolName string + + // Set of out-edges in the callgraph. The map uniquely identifies each + // edge based on the callsite and callee, for fast lookup. + OutEdges map[pgo.NamedCallEdge]*IREdge +} + +// Name returns the symbol name of this function. +func (i *IRNode) Name() string { + if i.AST != nil { + return ir.LinkFuncName(i.AST) + } + return i.LinkerSymbolName +} + +// IREdge represents a call edge in the IRGraph with source, destination, +// weight, callsite, and line number information. +type IREdge struct { + // Source and destination of the edge in IRNode. + Src, Dst *IRNode + Weight int64 + CallSiteOffset int // Line offset from function start line. +} + +// CallSiteInfo captures call-site information and its caller/callee. +type CallSiteInfo struct { + LineOffset int // Line offset from function start line. + Caller *ir.Func + Callee *ir.Func +} + +// Profile contains the processed PGO profile and weighted call graph used for +// PGO optimizations. +type Profile struct { + // Profile is the base data from the raw profile, without IR attribution. + *pgo.Profile + + // WeightedCG represents the IRGraph built from profile, which we will + // update as part of inlining. + WeightedCG *IRGraph +} + +// New generates a profile-graph from the profile or pre-processed profile. +func New(profileFile string) (*Profile, error) { + f, err := os.Open(profileFile) + if err != nil { + return nil, fmt.Errorf("error opening profile: %w", err) + } + defer f.Close() + r := bufio.NewReader(f) + + isSerialized, err := pgo.IsSerialized(r) + if err != nil { + return nil, fmt.Errorf("error processing profile header: %w", err) + } + + var base *pgo.Profile + if isSerialized { + base, err = pgo.FromSerialized(r) + if err != nil { + return nil, fmt.Errorf("error processing serialized PGO profile: %w", err) + } + } else { + base, err = pgo.FromPProf(r) + if err != nil { + return nil, fmt.Errorf("error processing pprof PGO profile: %w", err) + } + } + + if base.TotalWeight == 0 { + return nil, nil // accept but ignore profile with no samples. + } + + // Create package-level call graph with weights from profile and IR. + wg := createIRGraph(base.NamedEdgeMap) + + return &Profile{ + Profile: base, + WeightedCG: wg, + }, nil +} + +// createIRGraph builds the IRGraph by visiting all the ir.Func in decl list +// of a package. +func createIRGraph(namedEdgeMap pgo.NamedEdgeMap) *IRGraph { + g := &IRGraph{ + IRNodes: make(map[string]*IRNode), + } + + // Bottomup walk over the function to create IRGraph. + ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func(list []*ir.Func, recursive bool) { + for _, fn := range list { + visitIR(fn, namedEdgeMap, g) + } + }) + + // Add additional edges for indirect calls. This must be done second so + // that IRNodes is fully populated (see the dummy node TODO in + // addIndirectEdges). + // + // TODO(prattmic): visitIR above populates the graph via direct calls + // discovered via the IR. addIndirectEdges populates the graph via + // calls discovered via the profile. This combination of opposite + // approaches is a bit awkward, particularly because direct calls are + // discoverable via the profile as well. Unify these into a single + // approach. + addIndirectEdges(g, namedEdgeMap) + + return g +} + +// visitIR traverses the body of each ir.Func adds edges to g from ir.Func to +// any called function in the body. +func visitIR(fn *ir.Func, namedEdgeMap pgo.NamedEdgeMap, g *IRGraph) { + name := ir.LinkFuncName(fn) + node, ok := g.IRNodes[name] + if !ok { + node = &IRNode{ + AST: fn, + } + g.IRNodes[name] = node + } + + // Recursively walk over the body of the function to create IRGraph edges. + createIRGraphEdge(fn, node, name, namedEdgeMap, g) +} + +// createIRGraphEdge traverses the nodes in the body of ir.Func and adds edges +// between the callernode which points to the ir.Func and the nodes in the +// body. +func createIRGraphEdge(fn *ir.Func, callernode *IRNode, name string, namedEdgeMap pgo.NamedEdgeMap, g *IRGraph) { + ir.VisitList(fn.Body, func(n ir.Node) { + switch n.Op() { + case ir.OCALLFUNC: + call := n.(*ir.CallExpr) + // Find the callee function from the call site and add the edge. + callee := DirectCallee(call.Fun) + if callee != nil { + addIREdge(callernode, name, n, callee, namedEdgeMap, g) + } + case ir.OCALLMETH: + call := n.(*ir.CallExpr) + // Find the callee method from the call site and add the edge. + callee := ir.MethodExprName(call.Fun).Func + addIREdge(callernode, name, n, callee, namedEdgeMap, g) + } + }) +} + +// NodeLineOffset returns the line offset of n in fn. +func NodeLineOffset(n ir.Node, fn *ir.Func) int { + // See "A note on line numbers" at the top of the file. + line := int(base.Ctxt.InnermostPos(n.Pos()).RelLine()) + startLine := int(base.Ctxt.InnermostPos(fn.Pos()).RelLine()) + return line - startLine +} + +// addIREdge adds an edge between caller and new node that points to `callee` +// based on the profile-graph and NodeMap. +func addIREdge(callerNode *IRNode, callerName string, call ir.Node, callee *ir.Func, namedEdgeMap pgo.NamedEdgeMap, g *IRGraph) { + calleeName := ir.LinkFuncName(callee) + calleeNode, ok := g.IRNodes[calleeName] + if !ok { + calleeNode = &IRNode{ + AST: callee, + } + g.IRNodes[calleeName] = calleeNode + } + + namedEdge := pgo.NamedCallEdge{ + CallerName: callerName, + CalleeName: calleeName, + CallSiteOffset: NodeLineOffset(call, callerNode.AST), + } + + // Add edge in the IRGraph from caller to callee. + edge := &IREdge{ + Src: callerNode, + Dst: calleeNode, + Weight: namedEdgeMap.Weight[namedEdge], + CallSiteOffset: namedEdge.CallSiteOffset, + } + + if callerNode.OutEdges == nil { + callerNode.OutEdges = make(map[pgo.NamedCallEdge]*IREdge) + } + callerNode.OutEdges[namedEdge] = edge +} + +// LookupFunc looks up a function or method in export data. It is expected to +// be overridden by package noder, to break a dependency cycle. +var LookupFunc = func(fullName string) (*ir.Func, error) { + base.Fatalf("pgoir.LookupMethodFunc not overridden") + panic("unreachable") +} + +// PostLookupCleanup performs any remaining cleanup operations needed +// after a series of calls to LookupFunc, specifically reading in the +// bodies of functions that may have been delayed due being encountered +// in a stage where the reader's curfn state was not set up. +var PostLookupCleanup = func() { + base.Fatalf("pgoir.PostLookupCleanup not overridden") + panic("unreachable") +} + +// addIndirectEdges adds indirect call edges found in the profile to the graph, +// to be used for devirtualization. +// +// N.B. despite the name, addIndirectEdges will add any edges discovered via +// the profile. We don't know for sure that they are indirect, but assume they +// are since direct calls would already be added. (e.g., direct calls that have +// been deleted from source since the profile was taken would be added here). +// +// TODO(prattmic): Devirtualization runs before inlining, so we can't devirtualize +// calls inside inlined call bodies. If we did add that, we'd need edges from +// inlined bodies as well. +func addIndirectEdges(g *IRGraph, namedEdgeMap pgo.NamedEdgeMap) { + // g.IRNodes is populated with the set of functions in the local + // package build by VisitIR. We want to filter for local functions + // below, but we also add unknown callees to IRNodes as we go. So make + // an initial copy of IRNodes to recall just the local functions. + localNodes := maps.Clone(g.IRNodes) + + // N.B. We must consider edges in a stable order because export data + // lookup order (LookupMethodFunc, below) can impact the export data of + // this package, which must be stable across different invocations for + // reproducibility. + // + // The weight ordering of ByWeight is irrelevant, it just happens to be + // an ordered list of edges that is already available. + for _, key := range namedEdgeMap.ByWeight { + weight := namedEdgeMap.Weight[key] + // All callers in the local package build were added to IRNodes + // in VisitIR. If a caller isn't in the local package build we + // can skip adding edges, since we won't be devirtualizing in + // them anyway. This keeps the graph smaller. + callerNode, ok := localNodes[key.CallerName] + if !ok { + continue + } + + // Already handled this edge? + if _, ok := callerNode.OutEdges[key]; ok { + continue + } + + calleeNode, ok := g.IRNodes[key.CalleeName] + if !ok { + // IR is missing for this callee. VisitIR populates + // IRNodes with all functions discovered via local + // package function declarations and calls. This + // function may still be available from export data of + // a transitive dependency. + // + // TODO(prattmic): Parameterized types/functions are + // not supported. + // + // TODO(prattmic): This eager lookup during graph load + // is simple, but wasteful. We are likely to load many + // functions that we never need. We could delay load + // until we actually need the method in + // devirtualization. Instantiation of generic functions + // will likely need to be done at the devirtualization + // site, if at all. + if base.Debug.PGODebug >= 3 { + fmt.Printf("addIndirectEdges: %s attempting export data lookup\n", key.CalleeName) + } + fn, err := LookupFunc(key.CalleeName) + if err == nil { + if base.Debug.PGODebug >= 3 { + fmt.Printf("addIndirectEdges: %s found in export data\n", key.CalleeName) + } + calleeNode = &IRNode{AST: fn} + + // N.B. we could call createIRGraphEdge to add + // direct calls in this newly-imported + // function's body to the graph. Similarly, we + // could add to this function's queue to add + // indirect calls. However, those would be + // useless given the visit order of inlining, + // and the ordering of PGO devirtualization and + // inlining. This function can only be used as + // an inlined body. We will never do PGO + // devirtualization inside an inlined call. Nor + // will we perform inlining inside an inlined + // call. + } else { + // Still not found. Most likely this is because + // the callee isn't in the transitive deps of + // this package. + // + // Record this call anyway. If this is the hottest, + // then we want to skip devirtualization rather than + // devirtualizing to the second most common callee. + if base.Debug.PGODebug >= 3 { + fmt.Printf("addIndirectEdges: %s not found in export data: %v\n", key.CalleeName, err) + } + calleeNode = &IRNode{LinkerSymbolName: key.CalleeName} + } + + // Add dummy node back to IRNodes. We don't need this + // directly, but PrintWeightedCallGraphDOT uses these + // to print nodes. + g.IRNodes[key.CalleeName] = calleeNode + } + edge := &IREdge{ + Src: callerNode, + Dst: calleeNode, + Weight: weight, + CallSiteOffset: key.CallSiteOffset, + } + + if callerNode.OutEdges == nil { + callerNode.OutEdges = make(map[pgo.NamedCallEdge]*IREdge) + } + callerNode.OutEdges[key] = edge + } + + PostLookupCleanup() +} + +// PrintWeightedCallGraphDOT prints IRGraph in DOT format. +func (p *Profile) PrintWeightedCallGraphDOT(edgeThreshold float64) { + fmt.Printf("\ndigraph G {\n") + fmt.Printf("forcelabels=true;\n") + + // List of functions in this package. + funcs := make(map[string]struct{}) + ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func(list []*ir.Func, recursive bool) { + for _, f := range list { + name := ir.LinkFuncName(f) + funcs[name] = struct{}{} + } + }) + + // Determine nodes of DOT. + // + // Note that ir.Func may be nil for functions not visible from this + // package. + nodes := make(map[string]*ir.Func) + for name := range funcs { + if n, ok := p.WeightedCG.IRNodes[name]; ok { + for _, e := range n.OutEdges { + if _, ok := nodes[e.Src.Name()]; !ok { + nodes[e.Src.Name()] = e.Src.AST + } + if _, ok := nodes[e.Dst.Name()]; !ok { + nodes[e.Dst.Name()] = e.Dst.AST + } + } + if _, ok := nodes[n.Name()]; !ok { + nodes[n.Name()] = n.AST + } + } + } + + // Print nodes. + for name, ast := range nodes { + if _, ok := p.WeightedCG.IRNodes[name]; ok { + style := "solid" + if ast == nil { + style = "dashed" + } + + if ast != nil && ast.Inl != nil { + fmt.Printf("\"%v\" [color=black, style=%s, label=\"%v,inl_cost=%d\"];\n", name, style, name, ast.Inl.Cost) + } else { + fmt.Printf("\"%v\" [color=black, style=%s, label=\"%v\"];\n", name, style, name) + } + } + } + // Print edges. + ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func(list []*ir.Func, recursive bool) { + for _, f := range list { + name := ir.LinkFuncName(f) + if n, ok := p.WeightedCG.IRNodes[name]; ok { + for _, e := range n.OutEdges { + style := "solid" + if e.Dst.AST == nil { + style = "dashed" + } + color := "black" + edgepercent := pgo.WeightInPercentage(e.Weight, p.TotalWeight) + if edgepercent > edgeThreshold { + color = "red" + } + + fmt.Printf("edge [color=%s, style=%s];\n", color, style) + fmt.Printf("\"%v\" -> \"%v\" [label=\"%.2f\"];\n", n.Name(), e.Dst.Name(), edgepercent) + } + } + } + }) + fmt.Printf("}\n") +} + +// DirectCallee takes a function-typed expression and returns the underlying +// function that it refers to if statically known. Otherwise, it returns nil. +// +// Equivalent to inline.inlCallee without calling CanInline on closures. +func DirectCallee(fn ir.Node) *ir.Func { + fn = ir.StaticValue(fn) + switch fn.Op() { + case ir.OMETHEXPR: + fn := fn.(*ir.SelectorExpr) + n := ir.MethodExprName(fn) + // Check that receiver type matches fn.X. + // TODO(mdempsky): Handle implicit dereference + // of pointer receiver argument? + if n == nil || !types.Identical(n.Type().Recv().Type, fn.X.Type()) { + return nil + } + return n.Func + case ir.ONAME: + fn := fn.(*ir.Name) + if fn.Class == ir.PFUNC { + return fn.Func + } + case ir.OCLOSURE: + fn := fn.(*ir.ClosureExpr) + c := fn.Func + return c + } + return nil +} diff --git a/go/src/cmd/compile/internal/pkginit/init.go b/go/src/cmd/compile/internal/pkginit/init.go new file mode 100644 index 0000000000000000000000000000000000000000..04f6a5d3509f85fee8d9c453ab51a3b8bee2fb63 --- /dev/null +++ b/go/src/cmd/compile/internal/pkginit/init.go @@ -0,0 +1,146 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package pkginit + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/noder" + "cmd/compile/internal/objw" + "cmd/compile/internal/staticinit" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" +) + +// MakeTask makes an initialization record for the package, if necessary. +// See runtime/proc.go:initTask for its layout. +// The 3 tasks for initialization are: +// 1. Initialize all of the packages the current package depends on. +// 2. Initialize all the variables that have initializers. +// 3. Run any init functions. +func MakeTask() { + var deps []*obj.LSym // initTask records for packages the current package depends on + var fns []*obj.LSym // functions to call for package initialization + + // Find imported packages with init tasks. + for _, pkg := range typecheck.Target.Imports { + n, ok := pkg.Lookup(".inittask").Def.(*ir.Name) + if !ok { + continue + } + if n.Op() != ir.ONAME || n.Class != ir.PEXTERN { + base.Fatalf("bad inittask: %v", n) + } + deps = append(deps, n.Linksym()) + } + if base.Flag.ASan { + // Make an initialization function to call runtime.asanregisterglobals to register an + // array of instrumented global variables when -asan is enabled. An instrumented global + // variable is described by a structure. + // See the _asan_global structure declared in src/runtime/asan/asan.go. + // + // func init { + // var globals []_asan_global {...} + // asanregisterglobals(&globals[0], len(globals)) + // } + for _, n := range typecheck.Target.Externs { + if canInstrumentGlobal(n) { + name := n.Sym().Name + InstrumentGlobalsMap[name] = n + InstrumentGlobalsSlice = append(InstrumentGlobalsSlice, n) + } + } + ni := len(InstrumentGlobalsMap) + if ni != 0 { + // Make an init._ function. + pos := base.AutogeneratedPos + base.Pos = pos + + sym := noder.Renameinit() + fnInit := ir.NewFunc(pos, pos, sym, types.NewSignature(nil, nil, nil)) + typecheck.DeclFunc(fnInit) + + // Get an array of instrumented global variables. + globals := instrumentGlobals(fnInit) + + // Call runtime.asanregisterglobals function to poison redzones. + // runtime.asanregisterglobals(unsafe.Pointer(&globals[0]), ni) + asancall := ir.NewCallExpr(base.Pos, ir.OCALL, typecheck.LookupRuntime("asanregisterglobals"), nil) + asancall.Args.Append(typecheck.ConvNop(typecheck.NodAddr( + ir.NewIndexExpr(base.Pos, globals, ir.NewInt(base.Pos, 0))), types.Types[types.TUNSAFEPTR])) + asancall.Args.Append(typecheck.DefaultLit(ir.NewInt(base.Pos, int64(ni)), types.Types[types.TUINTPTR])) + + fnInit.Body.Append(asancall) + typecheck.FinishFuncBody() + ir.CurFunc = fnInit + typecheck.Stmts(fnInit.Body) + ir.CurFunc = nil + + typecheck.Target.Inits = append(typecheck.Target.Inits, fnInit) + } + } + + // Record user init functions. + for _, fn := range typecheck.Target.Inits { + if fn.Sym().Name == "init" { + // Synthetic init function for initialization of package-scope + // variables. We can use staticinit to optimize away static + // assignments. + s := staticinit.Schedule{ + Plans: make(map[ir.Node]*staticinit.Plan), + Temps: make(map[ir.Node]*ir.Name), + } + for _, n := range fn.Body { + s.StaticInit(n) + } + fn.Body = s.Out + ir.WithFunc(fn, func() { + typecheck.Stmts(fn.Body) + }) + + if len(fn.Body) == 0 { + fn.Body = []ir.Node{ir.NewBlockStmt(src.NoXPos, nil)} + } + } + + // Skip init functions with empty bodies. + if len(fn.Body) == 1 { + if stmt := fn.Body[0]; stmt.Op() == ir.OBLOCK && len(stmt.(*ir.BlockStmt).List) == 0 { + continue + } + } + fns = append(fns, fn.Nname.Linksym()) + } + + if len(deps) == 0 && len(fns) == 0 && types.LocalPkg.Path != "main" && types.LocalPkg.Path != "runtime" { + return // nothing to initialize + } + + // Make an .inittask structure. + sym := typecheck.Lookup(".inittask") + task := ir.NewNameAt(base.Pos, sym, types.Types[types.TUINT8]) // fake type + task.Class = ir.PEXTERN + sym.Def = task + lsym := task.Linksym() + ot := 0 + ot = objw.Uint32(lsym, ot, 0) // state: not initialized yet + ot = objw.Uint32(lsym, ot, uint32(len(fns))) + for _, f := range fns { + ot = objw.SymPtr(lsym, ot, f, 0) + } + + // Add relocations which tell the linker all of the packages + // that this package depends on (and thus, all of the packages + // that need to be initialized before this one). + for _, d := range deps { + lsym.AddRel(base.Ctxt, obj.Reloc{Type: objabi.R_INITORDER, Sym: d}) + } + // An initTask has pointers, but none into the Go heap. + // It's not quite read only, the state field must be modifiable. + objw.Global(lsym, int32(ot), obj.NOPTR) +} diff --git a/go/src/cmd/compile/internal/pkginit/initAsanGlobals.go b/go/src/cmd/compile/internal/pkginit/initAsanGlobals.go new file mode 100644 index 0000000000000000000000000000000000000000..96c052204a2c116475c1d664b0495f1924edc8ff --- /dev/null +++ b/go/src/cmd/compile/internal/pkginit/initAsanGlobals.go @@ -0,0 +1,242 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package pkginit + +import ( + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +// instrumentGlobals declares a global array of _asan_global structures and initializes it. +func instrumentGlobals(fn *ir.Func) *ir.Name { + asanGlobalStruct, asanLocationStruct, defStringstruct := createtypes() + lname := typecheck.Lookup + tconv := typecheck.ConvNop + // Make a global array of asanGlobalStruct type. + // var asanglobals []asanGlobalStruct + arraytype := types.NewArray(asanGlobalStruct, int64(len(InstrumentGlobalsMap))) + symG := lname(".asanglobals") + globals := ir.NewNameAt(base.Pos, symG, arraytype) + globals.Class = ir.PEXTERN + symG.Def = globals + typecheck.Target.Externs = append(typecheck.Target.Externs, globals) + // Make a global array of asanLocationStruct type. + // var asanL []asanLocationStruct + arraytype = types.NewArray(asanLocationStruct, int64(len(InstrumentGlobalsMap))) + symL := lname(".asanL") + asanlocation := ir.NewNameAt(base.Pos, symL, arraytype) + asanlocation.Class = ir.PEXTERN + symL.Def = asanlocation + typecheck.Target.Externs = append(typecheck.Target.Externs, asanlocation) + // Make three global string variables to pass the global name and module name + // and the name of the source file that defines it. + // var asanName string + // var asanModulename string + // var asanFilename string + symL = lname(".asanName") + asanName := ir.NewNameAt(base.Pos, symL, types.Types[types.TSTRING]) + asanName.Class = ir.PEXTERN + symL.Def = asanName + typecheck.Target.Externs = append(typecheck.Target.Externs, asanName) + + symL = lname(".asanModulename") + asanModulename := ir.NewNameAt(base.Pos, symL, types.Types[types.TSTRING]) + asanModulename.Class = ir.PEXTERN + symL.Def = asanModulename + typecheck.Target.Externs = append(typecheck.Target.Externs, asanModulename) + + symL = lname(".asanFilename") + asanFilename := ir.NewNameAt(base.Pos, symL, types.Types[types.TSTRING]) + asanFilename.Class = ir.PEXTERN + symL.Def = asanFilename + typecheck.Target.Externs = append(typecheck.Target.Externs, asanFilename) + + var init ir.Nodes + var c ir.Node + // globals[i].odrIndicator = 0 is the default, no need to set it explicitly here. + for i, n := range InstrumentGlobalsSlice { + setField := func(f string, val ir.Node, i int) { + r := ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, + ir.NewIndexExpr(base.Pos, globals, ir.NewInt(base.Pos, int64(i))), lname(f)), val) + init.Append(typecheck.Stmt(r)) + } + // globals[i].beg = uintptr(unsafe.Pointer(&n)) + c = tconv(typecheck.NodAddr(n), types.Types[types.TUNSAFEPTR]) + c = tconv(c, types.Types[types.TUINTPTR]) + setField("beg", c, i) + // Assign globals[i].size. + g := n.(*ir.Name) + size := g.Type().Size() + c = typecheck.DefaultLit(ir.NewInt(base.Pos, size), types.Types[types.TUINTPTR]) + setField("size", c, i) + // Assign globals[i].sizeWithRedzone. + rzSize := GetRedzoneSizeForGlobal(size) + sizeWithRz := rzSize + size + c = typecheck.DefaultLit(ir.NewInt(base.Pos, sizeWithRz), types.Types[types.TUINTPTR]) + setField("sizeWithRedzone", c, i) + // The C string type is terminated by a null character "\0", Go should use three-digit + // octal "\000" or two-digit hexadecimal "\x00" to create null terminated string. + // asanName = symbol's linkname + "\000" + // globals[i].name = (*defString)(unsafe.Pointer(&asanName)).data + name := g.Linksym().Name + init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, asanName, ir.NewString(base.Pos, name+"\000")))) + c = tconv(typecheck.NodAddr(asanName), types.Types[types.TUNSAFEPTR]) + c = tconv(c, types.NewPtr(defStringstruct)) + c = ir.NewSelectorExpr(base.Pos, ir.ODOT, c, lname("data")) + setField("name", c, i) + + // Set the name of package being compiled as a unique identifier of a module. + // asanModulename = pkgName + "\000" + init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, asanModulename, ir.NewString(base.Pos, types.LocalPkg.Name+"\000")))) + c = tconv(typecheck.NodAddr(asanModulename), types.Types[types.TUNSAFEPTR]) + c = tconv(c, types.NewPtr(defStringstruct)) + c = ir.NewSelectorExpr(base.Pos, ir.ODOT, c, lname("data")) + setField("moduleName", c, i) + // Assign asanL[i].filename, asanL[i].line, asanL[i].column + // and assign globals[i].location = uintptr(unsafe.Pointer(&asanL[i])) + asanLi := ir.NewIndexExpr(base.Pos, asanlocation, ir.NewInt(base.Pos, int64(i))) + filename := ir.NewString(base.Pos, base.Ctxt.PosTable.Pos(n.Pos()).Filename()+"\000") + init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, asanFilename, filename))) + c = tconv(typecheck.NodAddr(asanFilename), types.Types[types.TUNSAFEPTR]) + c = tconv(c, types.NewPtr(defStringstruct)) + c = ir.NewSelectorExpr(base.Pos, ir.ODOT, c, lname("data")) + init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, asanLi, lname("filename")), c))) + line := ir.NewInt(base.Pos, int64(n.Pos().Line())) + init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, asanLi, lname("line")), line))) + col := ir.NewInt(base.Pos, int64(n.Pos().Col())) + init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, asanLi, lname("column")), col))) + c = tconv(typecheck.NodAddr(asanLi), types.Types[types.TUNSAFEPTR]) + c = tconv(c, types.Types[types.TUINTPTR]) + setField("sourceLocation", c, i) + } + fn.Body.Append(init...) + return globals +} + +// createtypes creates the asanGlobal, asanLocation and defString struct type. +// Go compiler does not refer to the C types, we represent the struct field +// by a uintptr, then use type conversion to make copies of the data. +// E.g., (*defString)(asanGlobal.name).data to C string. +// +// Keep in sync with src/runtime/asan/asan.go. +// type asanGlobal struct { +// beg uintptr +// size uintptr +// size_with_redzone uintptr +// name uintptr +// moduleName uintptr +// hasDynamicInit uintptr +// sourceLocation uintptr +// odrIndicator uintptr +// } +// +// type asanLocation struct { +// filename uintptr +// line int32 +// column int32 +// } +// +// defString is synthesized struct type meant to capture the underlying +// implementations of string. +// type defString struct { +// data uintptr +// len uintptr +// } + +func createtypes() (*types.Type, *types.Type, *types.Type) { + up := types.Types[types.TUINTPTR] + i32 := types.Types[types.TINT32] + fname := typecheck.Lookup + nxp := src.NoXPos + nfield := types.NewField + asanGlobal := types.NewStruct([]*types.Field{ + nfield(nxp, fname("beg"), up), + nfield(nxp, fname("size"), up), + nfield(nxp, fname("sizeWithRedzone"), up), + nfield(nxp, fname("name"), up), + nfield(nxp, fname("moduleName"), up), + nfield(nxp, fname("hasDynamicInit"), up), + nfield(nxp, fname("sourceLocation"), up), + nfield(nxp, fname("odrIndicator"), up), + }) + types.CalcSize(asanGlobal) + + asanLocation := types.NewStruct([]*types.Field{ + nfield(nxp, fname("filename"), up), + nfield(nxp, fname("line"), i32), + nfield(nxp, fname("column"), i32), + }) + types.CalcSize(asanLocation) + + defString := types.NewStruct([]*types.Field{ + types.NewField(nxp, fname("data"), up), + types.NewField(nxp, fname("len"), up), + }) + types.CalcSize(defString) + + return asanGlobal, asanLocation, defString +} + +// Calculate redzone for globals. +func GetRedzoneSizeForGlobal(size int64) int64 { + maxRZ := int64(1 << 18) + minRZ := int64(32) + redZone := (size / minRZ / 4) * minRZ + switch { + case redZone > maxRZ: + redZone = maxRZ + case redZone < minRZ: + redZone = minRZ + } + // Round up to multiple of minRZ. + if size%minRZ != 0 { + redZone += minRZ - (size % minRZ) + } + return redZone +} + +// InstrumentGlobalsMap contains only package-local (and unlinknamed from somewhere else) +// globals. +// And the key is the object name. For example, in package p, a global foo would be in this +// map as "foo". +// Consider range over maps is nondeterministic, make a slice to hold all the values in the +// InstrumentGlobalsMap and iterate over the InstrumentGlobalsSlice. +var InstrumentGlobalsMap = make(map[string]ir.Node) +var InstrumentGlobalsSlice = make([]ir.Node, 0, 0) + +func canInstrumentGlobal(g ir.Node) bool { + if g.Op() != ir.ONAME { + return false + } + n := g.(*ir.Name) + if n.Class == ir.PFUNC { + return false + } + if n.Sym().Pkg != types.LocalPkg { + return false + } + // Do not instrument any _cgo_ related global variables, because they are declared in C code. + if strings.Contains(n.Sym().Name, "cgo") { + return false + } + + // Do not instrument counter globals in internal/fuzz. These globals are replaced by the linker. + // See go.dev/issue/72766 for more details. + if n.Sym().Pkg.Path == "internal/fuzz" && (n.Sym().Name == "_counters" || n.Sym().Name == "_ecounters") { + return false + } + + // Do not instrument globals that are linknamed, because their home package will do the work. + if n.Sym().Linkname != "" { + return false + } + + return true +} diff --git a/go/src/cmd/compile/internal/ppc64/galign.go b/go/src/cmd/compile/internal/ppc64/galign.go new file mode 100644 index 0000000000000000000000000000000000000000..20fd8cec54f397fb9d05f490798b0c4f3965ae17 --- /dev/null +++ b/go/src/cmd/compile/internal/ppc64/galign.go @@ -0,0 +1,29 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ppc64 + +import ( + "cmd/compile/internal/ssagen" + "cmd/internal/obj/ppc64" + "internal/buildcfg" +) + +func Init(arch *ssagen.ArchInfo) { + arch.LinkArch = &ppc64.Linkppc64 + if buildcfg.GOARCH == "ppc64le" { + arch.LinkArch = &ppc64.Linkppc64le + } + arch.REGSP = ppc64.REGSP + arch.MAXWIDTH = 1 << 50 + + arch.ZeroRange = zerorange + arch.Ginsnop = ginsnop + + arch.SSAMarkMoves = ssaMarkMoves + arch.SSAGenValue = ssaGenValue + arch.SSAGenBlock = ssaGenBlock + arch.LoadRegResult = loadRegResult + arch.SpillArgReg = spillArgReg +} diff --git a/go/src/cmd/compile/internal/ppc64/ggen.go b/go/src/cmd/compile/internal/ppc64/ggen.go new file mode 100644 index 0000000000000000000000000000000000000000..4c935cfc71f8d36b7c3b13b0041d9f624e930ecb --- /dev/null +++ b/go/src/cmd/compile/internal/ppc64/ggen.go @@ -0,0 +1,54 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ppc64 + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/ppc64" +) + +func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { + if cnt == 0 { + return p + } + if cnt < int64(4*types.PtrSize) { + for i := int64(0); i < cnt; i += int64(types.PtrSize) { + p = pp.Append(p, ppc64.AMOVD, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGSP, base.Ctxt.Arch.FixedFrameSize+off+i) + } + } else if cnt <= int64(128*types.PtrSize) { + p = pp.Append(p, ppc64.AADD, obj.TYPE_CONST, 0, base.Ctxt.Arch.FixedFrameSize+off-8, obj.TYPE_REG, ppc64.REGRT1, 0) + p.Reg = ppc64.REGSP + p = pp.Append(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0) + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.Duffzero + p.To.Offset = 4 * (128 - cnt/int64(types.PtrSize)) + } else { + p = pp.Append(p, ppc64.AMOVD, obj.TYPE_CONST, 0, base.Ctxt.Arch.FixedFrameSize+off-8, obj.TYPE_REG, ppc64.REGTMP, 0) + p = pp.Append(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT1, 0) + p.Reg = ppc64.REGSP + p = pp.Append(p, ppc64.AMOVD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, ppc64.REGTMP, 0) + p = pp.Append(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT2, 0) + p.Reg = ppc64.REGRT1 + p = pp.Append(p, ppc64.AMOVDU, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGRT1, int64(types.PtrSize)) + p1 := p + p = pp.Append(p, ppc64.ACMP, obj.TYPE_REG, ppc64.REGRT1, 0, obj.TYPE_REG, ppc64.REGRT2, 0) + p = pp.Append(p, ppc64.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0) + p.To.SetTarget(p1) + } + + return p +} + +func ginsnop(pp *objw.Progs) *obj.Prog { + // Generate the preferred hardware nop: ori 0,0,0 + p := pp.Prog(ppc64.AOR) + p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: 0} + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: ppc64.REG_R0} + return p +} diff --git a/go/src/cmd/compile/internal/ppc64/opt.go b/go/src/cmd/compile/internal/ppc64/opt.go new file mode 100644 index 0000000000000000000000000000000000000000..4f81aa9c1eb2913043047b5ff134bac4237aa424 --- /dev/null +++ b/go/src/cmd/compile/internal/ppc64/opt.go @@ -0,0 +1,12 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ppc64 + +// Many Power ISA arithmetic and logical instructions come in four +// standard variants. These bits let us map between variants. +const ( + V_CC = 1 << 0 // xCC (affect CR field 0 flags) + V_V = 1 << 1 // xV (affect SO and OV flags) +) diff --git a/go/src/cmd/compile/internal/ppc64/ssa.go b/go/src/cmd/compile/internal/ppc64/ssa.go new file mode 100644 index 0000000000000000000000000000000000000000..f0d228559f3a876040b59e6dc8f0f3209f72063a --- /dev/null +++ b/go/src/cmd/compile/internal/ppc64/ssa.go @@ -0,0 +1,2151 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ppc64 + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/objw" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/ppc64" + "internal/abi" + "internal/buildcfg" + "math" + "strings" +) + +// ssaMarkMoves marks any MOVXconst ops that need to avoid clobbering flags. +func ssaMarkMoves(s *ssagen.State, b *ssa.Block) { + // flive := b.FlagsLiveAtEnd + // if b.Control != nil && b.Control.Type.IsFlags() { + // flive = true + // } + // for i := len(b.Values) - 1; i >= 0; i-- { + // v := b.Values[i] + // if flive && (v.Op == v.Op == ssa.OpPPC64MOVDconst) { + // // The "mark" is any non-nil Aux value. + // v.Aux = v + // } + // if v.Type.IsFlags() { + // flive = false + // } + // for _, a := range v.Args { + // if a.Type.IsFlags() { + // flive = true + // } + // } + // } +} + +// loadByType returns the load instruction of the given type. +func loadByType(t *types.Type) obj.As { + if t.IsFloat() { + switch t.Size() { + case 4: + return ppc64.AFMOVS + case 8: + return ppc64.AFMOVD + } + } else { + switch t.Size() { + case 1: + if t.IsSigned() { + return ppc64.AMOVB + } else { + return ppc64.AMOVBZ + } + case 2: + if t.IsSigned() { + return ppc64.AMOVH + } else { + return ppc64.AMOVHZ + } + case 4: + if t.IsSigned() { + return ppc64.AMOVW + } else { + return ppc64.AMOVWZ + } + case 8: + return ppc64.AMOVD + } + } + panic("bad load type") +} + +// storeByType returns the store instruction of the given type. +func storeByType(t *types.Type) obj.As { + if t.IsFloat() { + switch t.Size() { + case 4: + return ppc64.AFMOVS + case 8: + return ppc64.AFMOVD + } + } else { + switch t.Size() { + case 1: + return ppc64.AMOVB + case 2: + return ppc64.AMOVH + case 4: + return ppc64.AMOVW + case 8: + return ppc64.AMOVD + } + } + panic("bad store type") +} + +func ssaGenValue(s *ssagen.State, v *ssa.Value) { + switch v.Op { + case ssa.OpCopy: + t := v.Type + if t.IsMemory() { + return + } + x := v.Args[0].Reg() + y := v.Reg() + if x != y { + rt := obj.TYPE_REG + op := ppc64.AMOVD + + if t.IsFloat() { + op = ppc64.AFMOVD + } + p := s.Prog(op) + p.From.Type = rt + p.From.Reg = x + p.To.Type = rt + p.To.Reg = y + } + + case ssa.OpPPC64LoweredAtomicAnd8, + ssa.OpPPC64LoweredAtomicAnd32, + ssa.OpPPC64LoweredAtomicOr8, + ssa.OpPPC64LoweredAtomicOr32: + // LWSYNC + // LBAR/LWAR (Rarg0), Rtmp + // AND/OR Rarg1, Rtmp + // STBCCC/STWCCC Rtmp, (Rarg0) + // BNE -3(PC) + ld := ppc64.ALBAR + st := ppc64.ASTBCCC + if v.Op == ssa.OpPPC64LoweredAtomicAnd32 || v.Op == ssa.OpPPC64LoweredAtomicOr32 { + ld = ppc64.ALWAR + st = ppc64.ASTWCCC + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + // LWSYNC - Assuming shared data not write-through-required nor + // caching-inhibited. See Appendix B.2.2.2 in the ISA 2.07b. + plwsync := s.Prog(ppc64.ALWSYNC) + plwsync.To.Type = obj.TYPE_NONE + // LBAR or LWAR + p := s.Prog(ld) + p.From.Type = obj.TYPE_MEM + p.From.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + // AND/OR reg1,out + p1 := s.Prog(v.Op.Asm()) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.To.Type = obj.TYPE_REG + p1.To.Reg = ppc64.REGTMP + // STBCCC or STWCCC + p2 := s.Prog(st) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = ppc64.REGTMP + p2.To.Type = obj.TYPE_MEM + p2.To.Reg = r0 + p2.RegTo2 = ppc64.REGTMP + // BNE retry + p3 := s.Prog(ppc64.ABNE) + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p) + + case ssa.OpPPC64LoweredAtomicAdd32, + ssa.OpPPC64LoweredAtomicAdd64: + // LWSYNC + // LDAR/LWAR (Rarg0), Rout + // ADD Rarg1, Rout + // STDCCC/STWCCC Rout, (Rarg0) + // BNE -3(PC) + // MOVW Rout,Rout (if Add32) + ld := ppc64.ALDAR + st := ppc64.ASTDCCC + if v.Op == ssa.OpPPC64LoweredAtomicAdd32 { + ld = ppc64.ALWAR + st = ppc64.ASTWCCC + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg0() + // LWSYNC - Assuming shared data not write-through-required nor + // caching-inhibited. See Appendix B.2.2.2 in the ISA 2.07b. + plwsync := s.Prog(ppc64.ALWSYNC) + plwsync.To.Type = obj.TYPE_NONE + // LDAR or LWAR + p := s.Prog(ld) + p.From.Type = obj.TYPE_MEM + p.From.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = out + // ADD reg1,out + p1 := s.Prog(ppc64.AADD) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.To.Reg = out + p1.To.Type = obj.TYPE_REG + // STDCCC or STWCCC + p3 := s.Prog(st) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = out + p3.To.Type = obj.TYPE_MEM + p3.To.Reg = r0 + // BNE retry + p4 := s.Prog(ppc64.ABNE) + p4.To.Type = obj.TYPE_BRANCH + p4.To.SetTarget(p) + + // Ensure a 32 bit result + if v.Op == ssa.OpPPC64LoweredAtomicAdd32 { + p5 := s.Prog(ppc64.AMOVWZ) + p5.To.Type = obj.TYPE_REG + p5.To.Reg = out + p5.From.Type = obj.TYPE_REG + p5.From.Reg = out + } + + case ssa.OpPPC64LoweredAtomicExchange8, + ssa.OpPPC64LoweredAtomicExchange32, + ssa.OpPPC64LoweredAtomicExchange64: + // LWSYNC + // LDAR/LWAR/LBAR (Rarg0), Rout + // STDCCC/STWCCC/STBWCCC Rout, (Rarg0) + // BNE -2(PC) + // ISYNC + ld := ppc64.ALDAR + st := ppc64.ASTDCCC + switch v.Op { + case ssa.OpPPC64LoweredAtomicExchange8: + ld = ppc64.ALBAR + st = ppc64.ASTBCCC + case ssa.OpPPC64LoweredAtomicExchange32: + ld = ppc64.ALWAR + st = ppc64.ASTWCCC + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg0() + // LWSYNC - Assuming shared data not write-through-required nor + // caching-inhibited. See Appendix B.2.2.2 in the ISA 2.07b. + plwsync := s.Prog(ppc64.ALWSYNC) + plwsync.To.Type = obj.TYPE_NONE + // L[B|W|D]AR + p := s.Prog(ld) + p.From.Type = obj.TYPE_MEM + p.From.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = out + // ST[B|W|D]CCC + p1 := s.Prog(st) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.To.Type = obj.TYPE_MEM + p1.To.Reg = r0 + // BNE retry + p2 := s.Prog(ppc64.ABNE) + p2.To.Type = obj.TYPE_BRANCH + p2.To.SetTarget(p) + // ISYNC + pisync := s.Prog(ppc64.AISYNC) + pisync.To.Type = obj.TYPE_NONE + + case ssa.OpPPC64LoweredAtomicLoad8, + ssa.OpPPC64LoweredAtomicLoad32, + ssa.OpPPC64LoweredAtomicLoad64, + ssa.OpPPC64LoweredAtomicLoadPtr: + // SYNC + // MOVB/MOVD/MOVW (Rarg0), Rout + // CMP Rout,Rout + // BNE 1(PC) + // ISYNC + ld := ppc64.AMOVD + cmp := ppc64.ACMP + switch v.Op { + case ssa.OpPPC64LoweredAtomicLoad8: + ld = ppc64.AMOVBZ + case ssa.OpPPC64LoweredAtomicLoad32: + ld = ppc64.AMOVWZ + cmp = ppc64.ACMPW + } + arg0 := v.Args[0].Reg() + out := v.Reg0() + // SYNC when AuxInt == 1; otherwise, load-acquire + if v.AuxInt == 1 { + psync := s.Prog(ppc64.ASYNC) + psync.To.Type = obj.TYPE_NONE + } + // Load + p := s.Prog(ld) + p.From.Type = obj.TYPE_MEM + p.From.Reg = arg0 + p.To.Type = obj.TYPE_REG + p.To.Reg = out + // CMP + p1 := s.Prog(cmp) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = out + p1.To.Type = obj.TYPE_REG + p1.To.Reg = out + // BNE + p2 := s.Prog(ppc64.ABNE) + p2.To.Type = obj.TYPE_BRANCH + // ISYNC + pisync := s.Prog(ppc64.AISYNC) + pisync.To.Type = obj.TYPE_NONE + p2.To.SetTarget(pisync) + + case ssa.OpPPC64LoweredAtomicStore8, + ssa.OpPPC64LoweredAtomicStore32, + ssa.OpPPC64LoweredAtomicStore64: + // SYNC or LWSYNC + // MOVB/MOVW/MOVD arg1,(arg0) + st := ppc64.AMOVD + switch v.Op { + case ssa.OpPPC64LoweredAtomicStore8: + st = ppc64.AMOVB + case ssa.OpPPC64LoweredAtomicStore32: + st = ppc64.AMOVW + } + arg0 := v.Args[0].Reg() + arg1 := v.Args[1].Reg() + // If AuxInt == 0, LWSYNC (Store-Release), else SYNC + // SYNC + syncOp := ppc64.ASYNC + if v.AuxInt == 0 { + syncOp = ppc64.ALWSYNC + } + psync := s.Prog(syncOp) + psync.To.Type = obj.TYPE_NONE + // Store + p := s.Prog(st) + p.To.Type = obj.TYPE_MEM + p.To.Reg = arg0 + p.From.Type = obj.TYPE_REG + p.From.Reg = arg1 + + case ssa.OpPPC64LoweredAtomicCas64, + ssa.OpPPC64LoweredAtomicCas32: + // MOVD $0, Rout + // LWSYNC + // loop: + // LDAR (Rarg0), MutexHint, Rtmp + // CMP Rarg1, Rtmp + // BNE end + // STDCCC Rarg2, (Rarg0) + // BNE loop + // MOVD $1, Rout + // end: + // LWSYNC // Only for sequential consistency; not required in CasRel. + ld := ppc64.ALDAR + st := ppc64.ASTDCCC + cmp := ppc64.ACMP + if v.Op == ssa.OpPPC64LoweredAtomicCas32 { + ld = ppc64.ALWAR + st = ppc64.ASTWCCC + cmp = ppc64.ACMPW + } + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + r2 := v.Args[2].Reg() + out := v.Reg0() + // Initialize return value to false + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 0 + p.To.Type = obj.TYPE_REG + p.To.Reg = out + // LWSYNC - Assuming shared data not write-through-required nor + // caching-inhibited. See Appendix B.2.2.2 in the ISA 2.07b. + plwsync1 := s.Prog(ppc64.ALWSYNC) + plwsync1.To.Type = obj.TYPE_NONE + // LDAR or LWAR + p0 := s.Prog(ld) + p0.From.Type = obj.TYPE_MEM + p0.From.Reg = r0 + p0.To.Type = obj.TYPE_REG + p0.To.Reg = ppc64.REGTMP + // If it is a Compare-and-Swap-Release operation, set the EH field with + // the release hint. + if v.AuxInt == 0 { + p0.AddRestSourceConst(0) + } + // CMP reg1,reg2 + p1 := s.Prog(cmp) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.To.Reg = ppc64.REGTMP + p1.To.Type = obj.TYPE_REG + // BNE done with return value = false + p2 := s.Prog(ppc64.ABNE) + p2.To.Type = obj.TYPE_BRANCH + // STDCCC or STWCCC + p3 := s.Prog(st) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = r2 + p3.To.Type = obj.TYPE_MEM + p3.To.Reg = r0 + // BNE retry + p4 := s.Prog(ppc64.ABNE) + p4.To.Type = obj.TYPE_BRANCH + p4.To.SetTarget(p0) + // return value true + p5 := s.Prog(ppc64.AMOVD) + p5.From.Type = obj.TYPE_CONST + p5.From.Offset = 1 + p5.To.Type = obj.TYPE_REG + p5.To.Reg = out + // LWSYNC - Assuming shared data not write-through-required nor + // caching-inhibited. See Appendix B.2.1.1 in the ISA 2.07b. + // If the operation is a CAS-Release, then synchronization is not necessary. + if v.AuxInt != 0 { + plwsync2 := s.Prog(ppc64.ALWSYNC) + plwsync2.To.Type = obj.TYPE_NONE + p2.To.SetTarget(plwsync2) + } else { + // done (label) + p6 := s.Prog(obj.ANOP) + p2.To.SetTarget(p6) + } + + case ssa.OpPPC64LoweredPubBarrier: + // LWSYNC + s.Prog(v.Op.Asm()) + + case ssa.OpPPC64LoweredGetClosurePtr: + // Closure pointer is R11 (already) + ssagen.CheckLoweredGetClosurePtr(v) + + case ssa.OpPPC64LoweredGetCallerSP: + // caller's SP is FixedFrameSize below the address of the first arg + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_ADDR + p.From.Offset = -base.Ctxt.Arch.FixedFrameSize + p.From.Name = obj.NAME_PARAM + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64LoweredGetCallerPC: + p := s.Prog(obj.AGETCALLERPC) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64LoweredRound32F, ssa.OpPPC64LoweredRound64F: + // input is already rounded + + case ssa.OpLoadReg: + loadOp := loadByType(v.Type) + p := s.Prog(loadOp) + ssagen.AddrAuto(&p.From, v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpStoreReg: + storeOp := storeByType(v.Type) + p := s.Prog(storeOp) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + ssagen.AddrAuto(&p.To, v) + + case ssa.OpArgIntReg, ssa.OpArgFloatReg: + // The assembler needs to wrap the entry safepoint/stack growth code with spill/unspill + // The loop only runs once. + for _, a := range v.Block.Func.RegArgs { + // Pass the spill/unspill information along to the assembler, offset by size of + // the saved LR slot. + addr := ssagen.SpillSlotAddr(a, ppc64.REGSP, base.Ctxt.Arch.FixedFrameSize) + s.FuncInfo().AddSpill( + obj.RegSpill{Reg: a.Reg, Addr: addr, Unspill: loadByType(a.Type), Spill: storeByType(a.Type)}) + } + v.Block.Func.RegArgs = nil + + ssagen.CheckArgReg(v) + + case ssa.OpPPC64DIVD: + // For now, + // + // cmp arg1, -1 + // be ahead + // v = arg0 / arg1 + // b over + // ahead: v = - arg0 + // over: nop + r := v.Reg() + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + + p := s.Prog(ppc64.ACMP) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.To.Type = obj.TYPE_CONST + p.To.Offset = -1 + + pbahead := s.Prog(ppc64.ABEQ) + pbahead.To.Type = obj.TYPE_BRANCH + + p = s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + pbover := s.Prog(obj.AJMP) + pbover.To.Type = obj.TYPE_BRANCH + + p = s.Prog(ppc64.ANEG) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + p.From.Type = obj.TYPE_REG + p.From.Reg = r0 + pbahead.To.SetTarget(p) + + p = s.Prog(obj.ANOP) + pbover.To.SetTarget(p) + + case ssa.OpPPC64DIVW: + // word-width version of above + r := v.Reg() + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + + p := s.Prog(ppc64.ACMPW) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.To.Type = obj.TYPE_CONST + p.To.Offset = -1 + + pbahead := s.Prog(ppc64.ABEQ) + pbahead.To.Type = obj.TYPE_BRANCH + + p = s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + pbover := s.Prog(obj.AJMP) + pbover.To.Type = obj.TYPE_BRANCH + + p = s.Prog(ppc64.ANEG) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + p.From.Type = obj.TYPE_REG + p.From.Reg = r0 + pbahead.To.SetTarget(p) + + p = s.Prog(obj.ANOP) + pbover.To.SetTarget(p) + + case ssa.OpPPC64CLRLSLWI: + r := v.Reg() + r1 := v.Args[0].Reg() + shifts := v.AuxInt + p := s.Prog(v.Op.Asm()) + // clrlslwi ra,rs,mb,sh will become rlwinm ra,rs,sh,mb-sh,31-sh as described in ISA + p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: ssa.GetPPC64Shiftmb(shifts)} + p.AddRestSourceConst(ssa.GetPPC64Shiftsh(shifts)) + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + case ssa.OpPPC64CLRLSLDI: + r := v.Reg() + r1 := v.Args[0].Reg() + shifts := v.AuxInt + p := s.Prog(v.Op.Asm()) + // clrlsldi ra,rs,mb,sh will become rldic ra,rs,sh,mb-sh + p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: ssa.GetPPC64Shiftmb(shifts)} + p.AddRestSourceConst(ssa.GetPPC64Shiftsh(shifts)) + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + case ssa.OpPPC64ADD, ssa.OpPPC64FADD, ssa.OpPPC64FADDS, ssa.OpPPC64SUB, ssa.OpPPC64FSUB, ssa.OpPPC64FSUBS, + ssa.OpPPC64MULLD, ssa.OpPPC64MULLW, ssa.OpPPC64DIVDU, ssa.OpPPC64DIVWU, + ssa.OpPPC64SRAD, ssa.OpPPC64SRAW, ssa.OpPPC64SRD, ssa.OpPPC64SRW, ssa.OpPPC64SLD, ssa.OpPPC64SLW, + ssa.OpPPC64ROTL, ssa.OpPPC64ROTLW, + ssa.OpPPC64MULHD, ssa.OpPPC64MULHW, ssa.OpPPC64MULHDU, ssa.OpPPC64MULHWU, + ssa.OpPPC64FMUL, ssa.OpPPC64FMULS, ssa.OpPPC64FDIV, ssa.OpPPC64FDIVS, ssa.OpPPC64FCPSGN, + ssa.OpPPC64AND, ssa.OpPPC64OR, ssa.OpPPC64ANDN, ssa.OpPPC64ORN, ssa.OpPPC64NOR, ssa.OpPPC64XOR, ssa.OpPPC64EQV, + ssa.OpPPC64MODUD, ssa.OpPPC64MODSD, ssa.OpPPC64MODUW, ssa.OpPPC64MODSW, ssa.OpPPC64XSMINJDP, ssa.OpPPC64XSMAXJDP: + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + case ssa.OpPPC64ADDCC, ssa.OpPPC64ANDCC, ssa.OpPPC64SUBCC, ssa.OpPPC64ORCC, ssa.OpPPC64XORCC, ssa.OpPPC64NORCC, + ssa.OpPPC64ANDNCC, ssa.OpPPC64MULHDUCC: + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + case ssa.OpPPC64NEGCC, ssa.OpPPC64CNTLZDCC: + p := s.Prog(v.Op.Asm()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + + case ssa.OpPPC64ROTLconst, ssa.OpPPC64ROTLWconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + // Auxint holds encoded rotate + mask + case ssa.OpPPC64RLWINM, ssa.OpPPC64RLWMI: + sh, mb, me, _ := ssa.DecodePPC64RotateMask(v.AuxInt) + p := s.Prog(v.Op.Asm()) + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: v.Reg()} + p.Reg = v.Args[0].Reg() + p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: sh} + p.AddRestSourceArgs([]obj.Addr{{Type: obj.TYPE_CONST, Offset: mb}, {Type: obj.TYPE_CONST, Offset: me}}) + // Auxint holds mask + + case ssa.OpPPC64RLDICL, ssa.OpPPC64RLDICLCC, ssa.OpPPC64RLDICR: + sh, mb, me, _ := ssa.DecodePPC64RotateMask(v.AuxInt) + p := s.Prog(v.Op.Asm()) + p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: sh} + switch v.Op { + case ssa.OpPPC64RLDICL, ssa.OpPPC64RLDICLCC: + p.AddRestSourceConst(mb) + case ssa.OpPPC64RLDICR: + p.AddRestSourceConst(me) + } + p.Reg = v.Args[0].Reg() + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: v.ResultReg()} + + case ssa.OpPPC64RLWNM: + _, mb, me, _ := ssa.DecodePPC64RotateMask(v.AuxInt) + p := s.Prog(v.Op.Asm()) + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: v.Reg()} + p.Reg = v.Args[0].Reg() + p.From = obj.Addr{Type: obj.TYPE_REG, Reg: v.Args[1].Reg()} + p.AddRestSourceArgs([]obj.Addr{{Type: obj.TYPE_CONST, Offset: mb}, {Type: obj.TYPE_CONST, Offset: me}}) + + case ssa.OpPPC64MADDLD: + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + r3 := v.Args[2].Reg() + // r = r1*r2 ± r3 + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.Reg = r2 + p.AddRestSourceReg(r3) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + case ssa.OpPPC64FMADD, ssa.OpPPC64FMADDS, ssa.OpPPC64FMSUB, ssa.OpPPC64FMSUBS: + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + r3 := v.Args[2].Reg() + // r = r1*r2 ± r3 + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.Reg = r3 + p.AddRestSourceReg(r2) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + case ssa.OpPPC64NEG, ssa.OpPPC64FNEG, ssa.OpPPC64FSQRT, ssa.OpPPC64FSQRTS, ssa.OpPPC64FFLOOR, ssa.OpPPC64FTRUNC, ssa.OpPPC64FCEIL, + ssa.OpPPC64FCTIDZ, ssa.OpPPC64FCTIWZ, ssa.OpPPC64FCFID, ssa.OpPPC64FCFIDS, ssa.OpPPC64FRSP, ssa.OpPPC64CNTLZD, ssa.OpPPC64CNTLZW, + ssa.OpPPC64POPCNTD, ssa.OpPPC64POPCNTW, ssa.OpPPC64POPCNTB, ssa.OpPPC64MFVSRD, ssa.OpPPC64MTVSRD, ssa.OpPPC64FABS, ssa.OpPPC64FNABS, + ssa.OpPPC64FROUND, ssa.OpPPC64CNTTZW, ssa.OpPPC64CNTTZD, ssa.OpPPC64BRH, ssa.OpPPC64BRW, ssa.OpPPC64BRD: + r := v.Reg() + p := s.Prog(v.Op.Asm()) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + + case ssa.OpPPC64ADDconst, ssa.OpPPC64ORconst, ssa.OpPPC64XORconst, + ssa.OpPPC64SRADconst, ssa.OpPPC64SRAWconst, ssa.OpPPC64SRDconst, ssa.OpPPC64SRWconst, + ssa.OpPPC64SLDconst, ssa.OpPPC64SLWconst, ssa.OpPPC64EXTSWSLconst, ssa.OpPPC64MULLWconst, ssa.OpPPC64MULLDconst, + ssa.OpPPC64ANDconst: + p := s.Prog(v.Op.Asm()) + p.Reg = v.Args[0].Reg() + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64ADDC, ssa.OpPPC64ADDE, ssa.OpPPC64SUBC, ssa.OpPPC64SUBE: + r := v.Reg0() // CA is the first, implied argument. + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + case ssa.OpPPC64ADDZE: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + case ssa.OpPPC64ADDZEzero, ssa.OpPPC64SUBZEzero: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_R0 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64ADDCconst: + p := s.Prog(v.Op.Asm()) + p.Reg = v.Args[0].Reg() + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + // Output is a pair, the second is the CA, which is implied. + p.To.Reg = v.Reg0() + + case ssa.OpPPC64SUBCconst: + p := s.Prog(v.Op.Asm()) + p.AddRestSourceConst(v.AuxInt) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + case ssa.OpPPC64SUBFCconst: + p := s.Prog(v.Op.Asm()) + p.AddRestSourceConst(v.AuxInt) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64ADDCCconst, ssa.OpPPC64ANDCCconst: + p := s.Prog(v.Op.Asm()) + p.Reg = v.Args[0].Reg() + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + case ssa.OpPPC64MOVDaddr: + switch v.Aux.(type) { + default: + v.Fatalf("aux in MOVDaddr is of unknown type %T", v.Aux) + case nil: + // If aux offset and aux int are both 0, and the same + // input and output regs are used, no instruction + // needs to be generated, since it would just be + // addi rx, rx, 0. + if v.AuxInt != 0 || v.Args[0].Reg() != v.Reg() { + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + } + + case *obj.LSym, ir.Node: + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + ssagen.AddAux(&p.From, v) + + } + + case ssa.OpPPC64MOVDconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64FMOVDconst, ssa.OpPPC64FMOVSconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_FCONST + p.From.Val = math.Float64frombits(uint64(v.AuxInt)) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64FCMPU, ssa.OpPPC64CMP, ssa.OpPPC64CMPW, ssa.OpPPC64CMPU, ssa.OpPPC64CMPWU: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Args[1].Reg() + + case ssa.OpPPC64CMPconst, ssa.OpPPC64CMPUconst, ssa.OpPPC64CMPWconst, ssa.OpPPC64CMPWUconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_CONST + p.To.Offset = v.AuxInt + + case ssa.OpPPC64MOVBreg, ssa.OpPPC64MOVBZreg, ssa.OpPPC64MOVHreg, ssa.OpPPC64MOVHZreg, ssa.OpPPC64MOVWreg, ssa.OpPPC64MOVWZreg: + // Shift in register to required size + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Reg = v.Reg() + p.To.Type = obj.TYPE_REG + + case ssa.OpPPC64MOVDload, ssa.OpPPC64MOVWload: + + // MOVDload and MOVWload are DS form instructions that are restricted to + // offsets that are a multiple of 4. If the offset is not a multiple of 4, + // then the address of the symbol to be loaded is computed (base + offset) + // and used as the new base register and the offset field in the instruction + // can be set to zero. + + // This same problem can happen with gostrings since the final offset is not + // known yet, but could be unaligned after the relocation is resolved. + // So gostrings are handled the same way. + + // This allows the MOVDload and MOVWload to be generated in more cases and + // eliminates some offset and alignment checking in the rules file. + + fromAddr := obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[0].Reg()} + ssagen.AddAux(&fromAddr, v) + + genAddr := false + + switch fromAddr.Name { + case obj.NAME_EXTERN, obj.NAME_STATIC: + // Special case for a rule combines the bytes of gostring. + // The v alignment might seem OK, but we don't want to load it + // using an offset because relocation comes later. + genAddr = strings.HasPrefix(fromAddr.Sym.Name, "go:string") || v.Type.Alignment()%4 != 0 || fromAddr.Offset%4 != 0 + default: + genAddr = fromAddr.Offset%4 != 0 + } + if genAddr { + // Load full address into the temp register. + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + // Load target using temp as base register + // and offset zero. Setting NAME_NONE + // prevents any extra offsets from being + // added. + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + fromAddr.Reg = ppc64.REGTMP + // Clear the offset field and other + // information that might be used + // by the assembler to add to the + // final offset value. + fromAddr.Offset = 0 + fromAddr.Name = obj.NAME_NONE + fromAddr.Sym = nil + } + p := s.Prog(v.Op.Asm()) + p.From = fromAddr + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64MOVHload, ssa.OpPPC64MOVWZload, ssa.OpPPC64MOVBZload, ssa.OpPPC64MOVHZload, ssa.OpPPC64FMOVDload, ssa.OpPPC64FMOVSload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64MOVDBRload, ssa.OpPPC64MOVWBRload, ssa.OpPPC64MOVHBRload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64MOVDBRstore, ssa.OpPPC64MOVWBRstore, ssa.OpPPC64MOVHBRstore: + p := s.Prog(v.Op.Asm()) + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + + case ssa.OpPPC64MOVDloadidx, ssa.OpPPC64MOVWloadidx, ssa.OpPPC64MOVHloadidx, ssa.OpPPC64MOVWZloadidx, + ssa.OpPPC64MOVBZloadidx, ssa.OpPPC64MOVHZloadidx, ssa.OpPPC64FMOVDloadidx, ssa.OpPPC64FMOVSloadidx, + ssa.OpPPC64MOVDBRloadidx, ssa.OpPPC64MOVWBRloadidx, ssa.OpPPC64MOVHBRloadidx: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.From.Index = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpPPC64DCBT: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_CONST + p.To.Offset = v.AuxInt + + case ssa.OpPPC64MOVWstorezero, ssa.OpPPC64MOVHstorezero, ssa.OpPPC64MOVBstorezero: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REGZERO + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + + case ssa.OpPPC64MOVDstore, ssa.OpPPC64MOVDstorezero: + + // MOVDstore and MOVDstorezero become DS form instructions that are restricted + // to offset values that are a multiple of 4. If the offset field is not a + // multiple of 4, then the full address of the store target is computed (base + + // offset) and used as the new base register and the offset in the instruction + // is set to 0. + + // This allows the MOVDstore and MOVDstorezero to be generated in more cases, + // and prevents checking of the offset value and alignment in the rules. + + toAddr := obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[0].Reg()} + ssagen.AddAux(&toAddr, v) + + if toAddr.Offset%4 != 0 { + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + toAddr.Reg = ppc64.REGTMP + // Clear the offset field and other + // information that might be used + // by the assembler to add to the + // final offset value. + toAddr.Offset = 0 + toAddr.Name = obj.NAME_NONE + toAddr.Sym = nil + } + p := s.Prog(v.Op.Asm()) + p.To = toAddr + p.From.Type = obj.TYPE_REG + if v.Op == ssa.OpPPC64MOVDstorezero { + p.From.Reg = ppc64.REGZERO + } else { + p.From.Reg = v.Args[1].Reg() + } + + case ssa.OpPPC64MOVWstore, ssa.OpPPC64MOVHstore, ssa.OpPPC64MOVBstore, ssa.OpPPC64FMOVDstore, ssa.OpPPC64FMOVSstore: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + + case ssa.OpPPC64MOVDstoreidx, ssa.OpPPC64MOVWstoreidx, ssa.OpPPC64MOVHstoreidx, ssa.OpPPC64MOVBstoreidx, + ssa.OpPPC64FMOVDstoreidx, ssa.OpPPC64FMOVSstoreidx, ssa.OpPPC64MOVDBRstoreidx, ssa.OpPPC64MOVWBRstoreidx, + ssa.OpPPC64MOVHBRstoreidx: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + p.To.Index = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + + case ssa.OpPPC64ISEL, ssa.OpPPC64ISELZ: + // ISEL AuxInt ? arg0 : arg1 + // ISELZ is a special case of ISEL where arg1 is implicitly $0. + // + // AuxInt value indicates conditions 0=LT 1=GT 2=EQ 3=SO 4=GE 5=LE 6=NE 7=NSO. + // ISEL accepts a CR bit argument, not a condition as expressed by AuxInt. + // Convert the condition to a CR bit argument by the following conversion: + // + // AuxInt&3 ? arg0 : arg1 for conditions LT, GT, EQ, SO + // AuxInt&3 ? arg1 : arg0 for conditions GE, LE, NE, NSO + p := s.Prog(v.Op.Asm()) + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: v.Reg()} + p.Reg = v.Args[0].Reg() + if v.Op == ssa.OpPPC64ISEL { + p.AddRestSourceReg(v.Args[1].Reg()) + } else { + p.AddRestSourceReg(ppc64.REG_R0) + } + // AuxInt values 4,5,6 implemented with reverse operand order from 0,1,2 + if v.AuxInt > 3 { + p.Reg, p.GetFrom3().Reg = p.GetFrom3().Reg, p.Reg + } + p.From.SetConst(v.AuxInt & 3) + + case ssa.OpPPC64SETBC, ssa.OpPPC64SETBCR: + p := s.Prog(v.Op.Asm()) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + p.From.Type = obj.TYPE_REG + p.From.Reg = int16(ppc64.REG_CR0LT + v.AuxInt) + + case ssa.OpPPC64LoweredQuadZero, ssa.OpPPC64LoweredQuadZeroShort: + // The LoweredQuad code generation + // generates STXV instructions on + // power9. The Short variation is used + // if no loop is generated. + + // sizes >= 64 generate a loop as follows: + + // Set up loop counter in CTR, used by BC + // XXLXOR clears VS32 + // XXLXOR VS32,VS32,VS32 + // MOVD len/64,REG_TMP + // MOVD REG_TMP,CTR + // loop: + // STXV VS32,0(R20) + // STXV VS32,16(R20) + // STXV VS32,32(R20) + // STXV VS32,48(R20) + // ADD $64,R20 + // BC 16, 0, loop + + // Bytes per iteration + ctr := v.AuxInt / 64 + + // Remainder bytes + rem := v.AuxInt % 64 + + // Only generate a loop if there is more + // than 1 iteration. + if ctr > 1 { + // Set up VS32 (V0) to hold 0s + p := s.Prog(ppc64.AXXLXOR) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + p.Reg = ppc64.REG_VS32 + + // Set up CTR loop counter + p = s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = ctr + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + + p = s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_CTR + + // Don't generate padding for + // loops with few iterations. + if ctr > 3 { + p = s.Prog(obj.APCALIGN) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 16 + } + + // generate 4 STXVs to zero 64 bytes + var top *obj.Prog + + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + + // Save the top of loop + if top == nil { + top = p + } + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Offset = 16 + + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Offset = 32 + + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Offset = 48 + + // Increment address for the + // 64 bytes just zeroed. + p = s.Prog(ppc64.AADD) + p.Reg = v.Args[0].Reg() + p.From.Type = obj.TYPE_CONST + p.From.Offset = 64 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Args[0].Reg() + + // Branch back to top of loop + // based on CTR + // BC with BO_BCTR generates bdnz + p = s.Prog(ppc64.ABC) + p.From.Type = obj.TYPE_CONST + p.From.Offset = ppc64.BO_BCTR + p.Reg = ppc64.REG_CR0LT + p.To.Type = obj.TYPE_BRANCH + p.To.SetTarget(top) + } + // When ctr == 1 the loop was not generated but + // there are at least 64 bytes to clear, so add + // that to the remainder to generate the code + // to clear those doublewords + if ctr == 1 { + rem += 64 + } + + // Clear the remainder starting at offset zero + offset := int64(0) + + if rem >= 16 && ctr <= 1 { + // If the XXLXOR hasn't already been + // generated, do it here to initialize + // VS32 (V0) to 0. + p := s.Prog(ppc64.AXXLXOR) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + p.Reg = ppc64.REG_VS32 + } + // Generate STXV for 32 or 64 + // bytes. + for rem >= 32 { + p := s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Offset = offset + + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Offset = offset + 16 + offset += 32 + rem -= 32 + } + // Generate 16 bytes + if rem >= 16 { + p := s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Offset = offset + offset += 16 + rem -= 16 + } + + // first clear as many doublewords as possible + // then clear remaining sizes as available + for rem > 0 { + op, size := ppc64.AMOVB, int64(1) + switch { + case rem >= 8: + op, size = ppc64.AMOVD, 8 + case rem >= 4: + op, size = ppc64.AMOVW, 4 + case rem >= 2: + op, size = ppc64.AMOVH, 2 + } + p := s.Prog(op) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_R0 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Offset = offset + rem -= size + offset += size + } + + case ssa.OpPPC64LoweredZero, ssa.OpPPC64LoweredZeroShort: + + // Unaligned data doesn't hurt performance + // for these instructions on power8. + + // For sizes >= 64 generate a loop as follows: + + // Set up loop counter in CTR, used by BC + // XXLXOR VS32,VS32,VS32 + // MOVD len/32,REG_TMP + // MOVD REG_TMP,CTR + // MOVD $16,REG_TMP + // loop: + // STXVD2X VS32,(R0)(R20) + // STXVD2X VS32,(R31)(R20) + // ADD $32,R20 + // BC 16, 0, loop + // + // any remainder is done as described below + + // for sizes < 64 bytes, first clear as many doublewords as possible, + // then handle the remainder + // MOVD R0,(R20) + // MOVD R0,8(R20) + // .... etc. + // + // the remainder bytes are cleared using one or more + // of the following instructions with the appropriate + // offsets depending which instructions are needed + // + // MOVW R0,n1(R20) 4 bytes + // MOVH R0,n2(R20) 2 bytes + // MOVB R0,n3(R20) 1 byte + // + // 7 bytes: MOVW, MOVH, MOVB + // 6 bytes: MOVW, MOVH + // 5 bytes: MOVW, MOVB + // 3 bytes: MOVH, MOVB + + // each loop iteration does 32 bytes + ctr := v.AuxInt / 32 + + // remainder bytes + rem := v.AuxInt % 32 + + // only generate a loop if there is more + // than 1 iteration. + if ctr > 1 { + // Set up VS32 (V0) to hold 0s + p := s.Prog(ppc64.AXXLXOR) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + p.Reg = ppc64.REG_VS32 + + // Set up CTR loop counter + p = s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = ctr + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + + p = s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_CTR + + // Set up R31 to hold index value 16 + p = s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 16 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + + // Don't add padding for alignment + // with few loop iterations. + if ctr > 3 { + p = s.Prog(obj.APCALIGN) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 16 + } + + // generate 2 STXVD2Xs to store 16 bytes + // when this is a loop then the top must be saved + var top *obj.Prog + // This is the top of loop + + p = s.Prog(ppc64.ASTXVD2X) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Index = ppc64.REGZERO + // Save the top of loop + if top == nil { + top = p + } + p = s.Prog(ppc64.ASTXVD2X) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Index = ppc64.REGTMP + + // Increment address for the + // 4 doublewords just zeroed. + p = s.Prog(ppc64.AADD) + p.Reg = v.Args[0].Reg() + p.From.Type = obj.TYPE_CONST + p.From.Offset = 32 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Args[0].Reg() + + // Branch back to top of loop + // based on CTR + // BC with BO_BCTR generates bdnz + p = s.Prog(ppc64.ABC) + p.From.Type = obj.TYPE_CONST + p.From.Offset = ppc64.BO_BCTR + p.Reg = ppc64.REG_CR0LT + p.To.Type = obj.TYPE_BRANCH + p.To.SetTarget(top) + } + + // when ctr == 1 the loop was not generated but + // there are at least 32 bytes to clear, so add + // that to the remainder to generate the code + // to clear those doublewords + if ctr == 1 { + rem += 32 + } + + // clear the remainder starting at offset zero + offset := int64(0) + + // first clear as many doublewords as possible + // then clear remaining sizes as available + for rem > 0 { + op, size := ppc64.AMOVB, int64(1) + switch { + case rem >= 8: + op, size = ppc64.AMOVD, 8 + case rem >= 4: + op, size = ppc64.AMOVW, 4 + case rem >= 2: + op, size = ppc64.AMOVH, 2 + } + p := s.Prog(op) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_R0 + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Offset = offset + rem -= size + offset += size + } + + case ssa.OpPPC64LoweredMove, ssa.OpPPC64LoweredMoveShort: + + bytesPerLoop := int64(32) + // This will be used when moving more + // than 8 bytes. Moves start with + // as many 8 byte moves as possible, then + // 4, 2, or 1 byte(s) as remaining. This will + // work and be efficient for power8 or later. + // If there are 64 or more bytes, then a + // loop is generated to move 32 bytes and + // update the src and dst addresses on each + // iteration. When < 64 bytes, the appropriate + // number of moves are generated based on the + // size. + // When moving >= 64 bytes a loop is used + // MOVD len/32,REG_TMP + // MOVD REG_TMP,CTR + // MOVD $16,REG_TMP + // top: + // LXVD2X (R0)(R21),VS32 + // LXVD2X (R31)(R21),VS33 + // ADD $32,R21 + // STXVD2X VS32,(R0)(R20) + // STXVD2X VS33,(R31)(R20) + // ADD $32,R20 + // BC 16,0,top + // Bytes not moved by this loop are moved + // with a combination of the following instructions, + // starting with the largest sizes and generating as + // many as needed, using the appropriate offset value. + // MOVD n(R21),R31 + // MOVD R31,n(R20) + // MOVW n1(R21),R31 + // MOVW R31,n1(R20) + // MOVH n2(R21),R31 + // MOVH R31,n2(R20) + // MOVB n3(R21),R31 + // MOVB R31,n3(R20) + + // Each loop iteration moves 32 bytes + ctr := v.AuxInt / bytesPerLoop + + // Remainder after the loop + rem := v.AuxInt % bytesPerLoop + + dstReg := v.Args[0].Reg() + srcReg := v.Args[1].Reg() + + // The set of registers used here, must match the clobbered reg list + // in PPC64Ops.go. + offset := int64(0) + + // top of the loop + var top *obj.Prog + // Only generate looping code when loop counter is > 1 for >= 64 bytes + if ctr > 1 { + // Set up the CTR + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = ctr + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + + p = s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_CTR + + // Use REGTMP as index reg + p = s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 16 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + + // Don't adding padding for + // alignment with small iteration + // counts. + if ctr > 3 { + p = s.Prog(obj.APCALIGN) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 16 + } + + // Generate 16 byte loads and stores. + // Use temp register for index (16) + // on the second one. + + p = s.Prog(ppc64.ALXVD2X) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Index = ppc64.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + if top == nil { + top = p + } + p = s.Prog(ppc64.ALXVD2X) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Index = ppc64.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS33 + + // increment the src reg for next iteration + p = s.Prog(ppc64.AADD) + p.Reg = srcReg + p.From.Type = obj.TYPE_CONST + p.From.Offset = bytesPerLoop + p.To.Type = obj.TYPE_REG + p.To.Reg = srcReg + + // generate 16 byte stores + p = s.Prog(ppc64.ASTXVD2X) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Index = ppc64.REGZERO + + p = s.Prog(ppc64.ASTXVD2X) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS33 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Index = ppc64.REGTMP + + // increment the dst reg for next iteration + p = s.Prog(ppc64.AADD) + p.Reg = dstReg + p.From.Type = obj.TYPE_CONST + p.From.Offset = bytesPerLoop + p.To.Type = obj.TYPE_REG + p.To.Reg = dstReg + + // BC with BO_BCTR generates bdnz to branch on nonzero CTR + // to loop top. + p = s.Prog(ppc64.ABC) + p.From.Type = obj.TYPE_CONST + p.From.Offset = ppc64.BO_BCTR + p.Reg = ppc64.REG_CR0LT + p.To.Type = obj.TYPE_BRANCH + p.To.SetTarget(top) + + // srcReg and dstReg were incremented in the loop, so + // later instructions start with offset 0. + offset = int64(0) + } + + // No loop was generated for one iteration, so + // add 32 bytes to the remainder to move those bytes. + if ctr == 1 { + rem += bytesPerLoop + } + + if rem >= 16 { + // Generate 16 byte loads and stores. + // Use temp register for index (value 16) + // on the second one. + p := s.Prog(ppc64.ALXVD2X) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Index = ppc64.REGZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + + p = s.Prog(ppc64.ASTXVD2X) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Index = ppc64.REGZERO + + offset = 16 + rem -= 16 + + if rem >= 16 { + // Use REGTMP as index reg + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 16 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + + p = s.Prog(ppc64.ALXVD2X) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Index = ppc64.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + + p = s.Prog(ppc64.ASTXVD2X) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Index = ppc64.REGTMP + + offset = 32 + rem -= 16 + } + } + + // Generate all the remaining load and store pairs, starting with + // as many 8 byte moves as possible, then 4, 2, 1. + for rem > 0 { + op, size := ppc64.AMOVB, int64(1) + switch { + case rem >= 8: + op, size = ppc64.AMOVD, 8 + case rem >= 4: + op, size = ppc64.AMOVWZ, 4 + case rem >= 2: + op, size = ppc64.AMOVH, 2 + } + // Load + p := s.Prog(op) + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Offset = offset + + // Store + p = s.Prog(op) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REGTMP + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Offset = offset + rem -= size + offset += size + } + + case ssa.OpPPC64LoweredQuadMove, ssa.OpPPC64LoweredQuadMoveShort: + bytesPerLoop := int64(64) + // This is used when moving more + // than 8 bytes on power9. Moves start with + // as many 8 byte moves as possible, then + // 4, 2, or 1 byte(s) as remaining. This will + // work and be efficient for power8 or later. + // If there are 64 or more bytes, then a + // loop is generated to move 32 bytes and + // update the src and dst addresses on each + // iteration. When < 64 bytes, the appropriate + // number of moves are generated based on the + // size. + // When moving >= 64 bytes a loop is used + // MOVD len/32,REG_TMP + // MOVD REG_TMP,CTR + // top: + // LXV 0(R21),VS32 + // LXV 16(R21),VS33 + // ADD $32,R21 + // STXV VS32,0(R20) + // STXV VS33,16(R20) + // ADD $32,R20 + // BC 16,0,top + // Bytes not moved by this loop are moved + // with a combination of the following instructions, + // starting with the largest sizes and generating as + // many as needed, using the appropriate offset value. + // MOVD n(R21),R31 + // MOVD R31,n(R20) + // MOVW n1(R21),R31 + // MOVW R31,n1(R20) + // MOVH n2(R21),R31 + // MOVH R31,n2(R20) + // MOVB n3(R21),R31 + // MOVB R31,n3(R20) + + // Each loop iteration moves 32 bytes + ctr := v.AuxInt / bytesPerLoop + + // Remainder after the loop + rem := v.AuxInt % bytesPerLoop + + dstReg := v.Args[0].Reg() + srcReg := v.Args[1].Reg() + + offset := int64(0) + + // top of the loop + var top *obj.Prog + + // Only generate looping code when loop counter is > 1 for >= 64 bytes + if ctr > 1 { + // Set up the CTR + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = ctr + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + + p = s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REGTMP + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_CTR + + p = s.Prog(obj.APCALIGN) + p.From.Type = obj.TYPE_CONST + p.From.Offset = 16 + + // Generate 16 byte loads and stores. + p = s.Prog(ppc64.ALXV) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Offset = offset + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + if top == nil { + top = p + } + p = s.Prog(ppc64.ALXV) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Offset = offset + 16 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS33 + + // generate 16 byte stores + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Offset = offset + + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS33 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Offset = offset + 16 + + // Generate 16 byte loads and stores. + p = s.Prog(ppc64.ALXV) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Offset = offset + 32 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + + p = s.Prog(ppc64.ALXV) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Offset = offset + 48 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS33 + + // generate 16 byte stores + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Offset = offset + 32 + + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS33 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Offset = offset + 48 + + // increment the src reg for next iteration + p = s.Prog(ppc64.AADD) + p.Reg = srcReg + p.From.Type = obj.TYPE_CONST + p.From.Offset = bytesPerLoop + p.To.Type = obj.TYPE_REG + p.To.Reg = srcReg + + // increment the dst reg for next iteration + p = s.Prog(ppc64.AADD) + p.Reg = dstReg + p.From.Type = obj.TYPE_CONST + p.From.Offset = bytesPerLoop + p.To.Type = obj.TYPE_REG + p.To.Reg = dstReg + + // BC with BO_BCTR generates bdnz to branch on nonzero CTR + // to loop top. + p = s.Prog(ppc64.ABC) + p.From.Type = obj.TYPE_CONST + p.From.Offset = ppc64.BO_BCTR + p.Reg = ppc64.REG_CR0LT + p.To.Type = obj.TYPE_BRANCH + p.To.SetTarget(top) + + // srcReg and dstReg were incremented in the loop, so + // later instructions start with offset 0. + offset = int64(0) + } + + // No loop was generated for one iteration, so + // add 32 bytes to the remainder to move those bytes. + if ctr == 1 { + rem += bytesPerLoop + } + if rem >= 32 { + p := s.Prog(ppc64.ALXV) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + + p = s.Prog(ppc64.ALXV) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Offset = 16 + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS33 + + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS33 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Offset = 16 + + offset = 32 + rem -= 32 + } + + if rem >= 16 { + // Generate 16 byte loads and stores. + p := s.Prog(ppc64.ALXV) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Offset = offset + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Offset = offset + + offset += 16 + rem -= 16 + + if rem >= 16 { + p := s.Prog(ppc64.ALXV) + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Offset = offset + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_VS32 + + p = s.Prog(ppc64.ASTXV) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_VS32 + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Offset = offset + + offset += 16 + rem -= 16 + } + } + // Generate all the remaining load and store pairs, starting with + // as many 8 byte moves as possible, then 4, 2, 1. + for rem > 0 { + op, size := ppc64.AMOVB, int64(1) + switch { + case rem >= 8: + op, size = ppc64.AMOVD, 8 + case rem >= 4: + op, size = ppc64.AMOVWZ, 4 + case rem >= 2: + op, size = ppc64.AMOVH, 2 + } + // Load + p := s.Prog(op) + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + p.From.Type = obj.TYPE_MEM + p.From.Reg = srcReg + p.From.Offset = offset + + // Store + p = s.Prog(op) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REGTMP + p.To.Type = obj.TYPE_MEM + p.To.Reg = dstReg + p.To.Offset = offset + rem -= size + offset += size + } + + case ssa.OpPPC64CALLstatic: + s.Call(v) + + case ssa.OpPPC64CALLtail: + s.TailCall(v) + + case ssa.OpPPC64CALLclosure, ssa.OpPPC64CALLinter: + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_LR + + if v.Args[0].Reg() != ppc64.REG_R12 { + v.Fatalf("Function address for %v should be in R12 %d but is in %d", v.LongString(), ppc64.REG_R12, p.From.Reg) + } + + pp := s.Call(v) + + // Convert the call into a blrl with hint this is not a subroutine return. + // The full bclrl opcode must be specified when passing a hint. + pp.As = ppc64.ABCL + pp.From.Type = obj.TYPE_CONST + pp.From.Offset = ppc64.BO_ALWAYS + pp.Reg = ppc64.REG_CR0LT // The preferred value if BI is ignored. + pp.To.Reg = ppc64.REG_LR + pp.AddRestSourceConst(1) + + if ppc64.NeedTOCpointer(base.Ctxt) { + // When compiling Go into PIC, the function we just + // called via pointer might have been implemented in + // a separate module and so overwritten the TOC + // pointer in R2; reload it. + q := s.Prog(ppc64.AMOVD) + q.From.Type = obj.TYPE_MEM + q.From.Offset = 24 + q.From.Reg = ppc64.REGSP + q.To.Type = obj.TYPE_REG + q.To.Reg = ppc64.REG_R2 + } + + case ssa.OpPPC64LoweredWB: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + // AuxInt encodes how many buffer entries we need. + p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1] + + case ssa.OpPPC64LoweredPanicBoundsRR, ssa.OpPPC64LoweredPanicBoundsRC, ssa.OpPPC64LoweredPanicBoundsCR, ssa.OpPPC64LoweredPanicBoundsCC: + // Compute the constant we put in the PCData entry for this call. + code, signed := ssa.BoundsKind(v.AuxInt).Code() + xIsReg := false + yIsReg := false + xVal := 0 + yVal := 0 + switch v.Op { + case ssa.OpPPC64LoweredPanicBoundsRR: + xIsReg = true + xVal = int(v.Args[0].Reg() - ppc64.REG_R3) + yIsReg = true + yVal = int(v.Args[1].Reg() - ppc64.REG_R3) + case ssa.OpPPC64LoweredPanicBoundsRC: + xIsReg = true + xVal = int(v.Args[0].Reg() - ppc64.REG_R3) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + if yVal == xVal { + yVal = 1 + } + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_R3 + int16(yVal) + } + case ssa.OpPPC64LoweredPanicBoundsCR: + yIsReg = true + yVal = int(v.Args[0].Reg() - ppc64.REG_R3) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + if xVal == yVal { + xVal = 1 + } + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_R3 + int16(xVal) + } + case ssa.OpPPC64LoweredPanicBoundsCC: + c := v.Aux.(ssa.PanicBoundsCC).Cx + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + xIsReg = true + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_R3 + int16(xVal) + } + c = v.Aux.(ssa.PanicBoundsCC).Cy + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + yVal = 1 + p := s.Prog(ppc64.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REG_R3 + int16(yVal) + } + } + c := abi.BoundsEncode(code, signed, xIsReg, yIsReg, xVal, yVal) + + p := s.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_PanicBounds) + p.To.SetConst(int64(c)) + p = s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.PanicBounds + + case ssa.OpPPC64LoweredNilCheck: + if buildcfg.GOOS == "aix" { + // CMP Rarg0, $0 + // BNE 2(PC) + // STW R0, 0(R0) + // NOP (so the BNE has somewhere to land) + + // CMP Rarg0, $0 + p := s.Prog(ppc64.ACMP) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_CONST + p.To.Offset = 0 + + // BNE 2(PC) + p2 := s.Prog(ppc64.ABNE) + p2.To.Type = obj.TYPE_BRANCH + + // STW R0, 0(R0) + // Write at 0 is forbidden and will trigger a SIGSEGV + p = s.Prog(ppc64.AMOVW) + p.From.Type = obj.TYPE_REG + p.From.Reg = ppc64.REG_R0 + p.To.Type = obj.TYPE_MEM + p.To.Reg = ppc64.REG_R0 + + // NOP (so the BNE has somewhere to land) + nop := s.Prog(obj.ANOP) + p2.To.SetTarget(nop) + + } else { + // Issue a load which will fault if arg is nil. + p := s.Prog(ppc64.AMOVBZ) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = ppc64.REGTMP + } + if logopt.Enabled() { + logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name) + } + if base.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers + base.WarnfAt(v.Pos, "generated nil check") + } + + // These should be resolved by rules and not make it here. + case ssa.OpPPC64Equal, ssa.OpPPC64NotEqual, ssa.OpPPC64LessThan, ssa.OpPPC64FLessThan, + ssa.OpPPC64LessEqual, ssa.OpPPC64GreaterThan, ssa.OpPPC64FGreaterThan, ssa.OpPPC64GreaterEqual, + ssa.OpPPC64FLessEqual, ssa.OpPPC64FGreaterEqual: + v.Fatalf("Pseudo-op should not make it to codegen: %s ###\n", v.LongString()) + case ssa.OpPPC64InvertFlags: + v.Fatalf("InvertFlags should never make it to codegen %v", v.LongString()) + case ssa.OpPPC64FlagEQ, ssa.OpPPC64FlagLT, ssa.OpPPC64FlagGT: + v.Fatalf("Flag* ops should never make it to codegen %v", v.LongString()) + case ssa.OpClobber, ssa.OpClobberReg: + // TODO: implement for clobberdead experiment. Nop is ok for now. + default: + v.Fatalf("genValue not implemented: %s", v.LongString()) + } +} + +var blockJump = [...]struct { + asm, invasm obj.As + asmeq, invasmun bool +}{ + ssa.BlockPPC64EQ: {ppc64.ABEQ, ppc64.ABNE, false, false}, + ssa.BlockPPC64NE: {ppc64.ABNE, ppc64.ABEQ, false, false}, + + ssa.BlockPPC64LT: {ppc64.ABLT, ppc64.ABGE, false, false}, + ssa.BlockPPC64GE: {ppc64.ABGE, ppc64.ABLT, false, false}, + ssa.BlockPPC64LE: {ppc64.ABLE, ppc64.ABGT, false, false}, + ssa.BlockPPC64GT: {ppc64.ABGT, ppc64.ABLE, false, false}, + + // TODO: need to work FP comparisons into block jumps + ssa.BlockPPC64FLT: {ppc64.ABLT, ppc64.ABGE, false, false}, + ssa.BlockPPC64FGE: {ppc64.ABGT, ppc64.ABLT, true, true}, // GE = GT or EQ; !GE = LT or UN + ssa.BlockPPC64FLE: {ppc64.ABLT, ppc64.ABGT, true, true}, // LE = LT or EQ; !LE = GT or UN + ssa.BlockPPC64FGT: {ppc64.ABGT, ppc64.ABLE, false, false}, +} + +func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) { + switch b.Kind { + case ssa.BlockPlain, ssa.BlockDefer: + if b.Succs[0].Block() != next { + p := s.Prog(obj.AJMP) + p.To.Type = obj.TYPE_BRANCH + s.Branches = append(s.Branches, ssagen.Branch{P: p, B: b.Succs[0].Block()}) + } + case ssa.BlockExit, ssa.BlockRetJmp: + case ssa.BlockRet: + s.Prog(obj.ARET) + + case ssa.BlockPPC64EQ, ssa.BlockPPC64NE, + ssa.BlockPPC64LT, ssa.BlockPPC64GE, + ssa.BlockPPC64LE, ssa.BlockPPC64GT, + ssa.BlockPPC64FLT, ssa.BlockPPC64FGE, + ssa.BlockPPC64FLE, ssa.BlockPPC64FGT: + jmp := blockJump[b.Kind] + switch next { + case b.Succs[0].Block(): + s.Br(jmp.invasm, b.Succs[1].Block()) + if jmp.invasmun { + // TODO: The second branch is probably predict-not-taken since it is for FP unordered + s.Br(ppc64.ABVS, b.Succs[1].Block()) + } + case b.Succs[1].Block(): + s.Br(jmp.asm, b.Succs[0].Block()) + if jmp.asmeq { + s.Br(ppc64.ABEQ, b.Succs[0].Block()) + } + default: + if b.Likely != ssa.BranchUnlikely { + s.Br(jmp.asm, b.Succs[0].Block()) + if jmp.asmeq { + s.Br(ppc64.ABEQ, b.Succs[0].Block()) + } + s.Br(obj.AJMP, b.Succs[1].Block()) + } else { + s.Br(jmp.invasm, b.Succs[1].Block()) + if jmp.invasmun { + // TODO: The second branch is probably predict-not-taken since it is for FP unordered + s.Br(ppc64.ABVS, b.Succs[1].Block()) + } + s.Br(obj.AJMP, b.Succs[0].Block()) + } + } + default: + b.Fatalf("branch not implemented: %s", b.LongString()) + } +} + +func loadRegResult(s *ssagen.State, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p := s.Prog(loadByType(t)) + p.From.Type = obj.TYPE_MEM + p.From.Name = obj.NAME_AUTO + p.From.Sym = n.Linksym() + p.From.Offset = n.FrameOffset() + off + p.To.Type = obj.TYPE_REG + p.To.Reg = reg + return p +} + +func spillArgReg(pp *objw.Progs, p *obj.Prog, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p = pp.Append(p, storeByType(t), obj.TYPE_REG, reg, 0, obj.TYPE_MEM, 0, n.FrameOffset()+off) + p.To.Name = obj.NAME_PARAM + p.To.Sym = n.Linksym() + p.Pos = p.Pos.WithNotStmt() + return p +} diff --git a/go/src/cmd/compile/internal/rangefunc/rangefunc_test.go b/go/src/cmd/compile/internal/rangefunc/rangefunc_test.go new file mode 100644 index 0000000000000000000000000000000000000000..4b4974b9dddd5465ea327497f6f124fe5b266cbe --- /dev/null +++ b/go/src/cmd/compile/internal/rangefunc/rangefunc_test.go @@ -0,0 +1,2206 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package rangefunc_test + +import ( + "fmt" + "regexp" + "slices" + "testing" +) + +type Seq[T any] func(yield func(T) bool) +type Seq2[T1, T2 any] func(yield func(T1, T2) bool) + +// OfSliceIndex returns a Seq2 over the elements of s. It is equivalent +// to range s. +func OfSliceIndex[T any, S ~[]T](s S) Seq2[int, T] { + return func(yield func(int, T) bool) { + for i, v := range s { + if !yield(i, v) { + return + } + } + return + } +} + +// BadOfSliceIndex is "bad" because it ignores the return value from yield +// and just keeps on iterating. +func BadOfSliceIndex[T any, S ~[]T](s S) Seq2[int, T] { + return func(yield func(int, T) bool) { + for i, v := range s { + yield(i, v) + } + return + } +} + +// VeryBadOfSliceIndex is "very bad" because it ignores the return value from yield +// and just keeps on iterating, and also wraps that call in a defer-recover so it can +// keep on trying after the first panic. +func VeryBadOfSliceIndex[T any, S ~[]T](s S) Seq2[int, T] { + return func(yield func(int, T) bool) { + for i, v := range s { + func() { + defer func() { + recover() + }() + yield(i, v) + }() + } + return + } +} + +// SwallowPanicOfSliceIndex hides panics and converts them to normal return +func SwallowPanicOfSliceIndex[T any, S ~[]T](s S) Seq2[int, T] { + return func(yield func(int, T) bool) { + for i, v := range s { + done := false + func() { + defer func() { + if r := recover(); r != nil { + done = true + } + }() + done = !yield(i, v) + }() + if done { + return + } + } + return + } +} + +// PanickyOfSliceIndex iterates the slice but panics if it exits the loop early +func PanickyOfSliceIndex[T any, S ~[]T](s S) Seq2[int, T] { + return func(yield func(int, T) bool) { + for i, v := range s { + if !yield(i, v) { + panic(fmt.Errorf("Panicky iterator panicking")) + } + } + return + } +} + +// CooperativeBadOfSliceIndex calls the loop body from a goroutine after +// a ping on a channel, and returns recover()on that same channel. +func CooperativeBadOfSliceIndex[T any, S ~[]T](s S, proceed chan any) Seq2[int, T] { + return func(yield func(int, T) bool) { + for i, v := range s { + if !yield(i, v) { + // if the body breaks, call yield just once in a goroutine + go func() { + <-proceed + defer func() { + proceed <- recover() + }() + yield(0, s[0]) + }() + return + } + } + return + } +} + +// TrickyIterator is a type intended to test whether an iterator that +// calls a yield function after loop exit must inevitably escape the +// closure; this might be relevant to future checking/optimization. +type TrickyIterator struct { + yield func(int, int) bool +} + +func (ti *TrickyIterator) iterEcho(s []int) Seq2[int, int] { + return func(yield func(int, int) bool) { + for i, v := range s { + if !yield(i, v) { + ti.yield = yield + return + } + if ti.yield != nil && !ti.yield(i, v) { + return + } + } + ti.yield = yield + return + } +} + +func (ti *TrickyIterator) iterAll(s []int) Seq2[int, int] { + return func(yield func(int, int) bool) { + ti.yield = yield // Save yield for future abuse + for i, v := range s { + if !yield(i, v) { + return + } + } + return + } +} + +func (ti *TrickyIterator) iterOne(s []int) Seq2[int, int] { + return func(yield func(int, int) bool) { + ti.yield = yield // Save yield for future abuse + if len(s) > 0 { // Not in a loop might escape differently + yield(0, s[0]) + } + return + } +} + +func (ti *TrickyIterator) iterZero(s []int) Seq2[int, int] { + return func(yield func(int, int) bool) { + ti.yield = yield // Save yield for future abuse + // Don't call it at all, maybe it won't escape + return + } +} + +func (ti *TrickyIterator) fail() { + if ti.yield != nil { + ti.yield(1, 1) + } +} + +const DONE = 0 // body of loop has exited in a non-panic way +const READY = 1 // body of loop has not exited yet, is not running +const PANIC = 2 // body of loop is either currently running, or has panicked +const EXHAUSTED = 3 // iterator function return, i.e., sequence is "exhausted" + +const MISSING_PANIC = 4 // overload "READY" for panic call + +// Check2 wraps the function body passed to iterator forall +// in code that ensures that it cannot (successfully) be called +// either after body return false (control flow out of loop) or +// forall itself returns (the iteration is now done). +// +// Note that this can catch errors before the inserted checks. +func Check2[U, V any](forall Seq2[U, V]) Seq2[U, V] { + return func(body func(U, V) bool) { + state := READY + forall(func(u U, v V) bool { + tmp := state + state = PANIC + if tmp != READY { + panic(fail[tmp]) + } + ret := body(u, v) + if ret { + state = READY + } else { + state = DONE + } + return ret + }) + if state == PANIC { + panic(fail[MISSING_PANIC]) + } + state = EXHAUSTED + } +} + +func Check[U any](forall Seq[U]) Seq[U] { + return func(body func(U) bool) { + state := READY + forall(func(u U) bool { + tmp := state + state = PANIC + if tmp != READY { + panic(fail[tmp]) + } + ret := body(u) + if ret { + state = READY + } else { + state = DONE + } + return ret + }) + if state == PANIC { + panic(fail[MISSING_PANIC]) + } + state = EXHAUSTED + } +} + +func matchError(r any, x string) bool { + if r == nil { + return false + } + if x == "" { + return true + } + if p, ok := r.(errorString); ok { + return p.Error() == x + } + if p, ok := r.(error); ok { + e, err := regexp.Compile(x) + if err != nil { + panic(fmt.Errorf("Bad regexp '%s' passed to matchError", x)) + } + return e.MatchString(p.Error()) + } + return false +} + +func matchErrorHelper(t *testing.T, r any, x string) { + if matchError(r, x) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v', expected '%s'", r, x) + } +} + +// An errorString represents a runtime error described by a single string. +type errorString string + +func (e errorString) Error() string { + return string(e) +} + +const ( + // RERR_ is for runtime error, and may be regexps/substrings, to simplify use of tests with tools + RERR_DONE = "runtime error: range function continued iteration after function for loop body returned false" + RERR_PANIC = "runtime error: range function continued iteration after loop body panic" + RERR_EXHAUSTED = "runtime error: range function continued iteration after whole loop exit" + RERR_MISSING = "runtime error: range function recovered a loop body panic and did not resume panicking" + + // CERR_ is for checked errors in the Check combinator defined above, and should be literal strings + CERR_PFX = "checked rangefunc error: " + CERR_DONE = CERR_PFX + "loop iteration after body done" + CERR_PANIC = CERR_PFX + "loop iteration after panic" + CERR_EXHAUSTED = CERR_PFX + "loop iteration after iterator exit" + CERR_MISSING = CERR_PFX + "loop iterator swallowed panic" +) + +var fail []error = []error{ + errorString(CERR_DONE), + errorString(CERR_PFX + "loop iterator, unexpected error"), + errorString(CERR_PANIC), + errorString(CERR_EXHAUSTED), + errorString(CERR_MISSING), +} + +// TestNoVars ensures that versions of rangefunc that use zero or one +// iteration variable (instead of two) run the proper number of times +// and in the one variable case supply the proper values. +// For #65236. +func TestNoVars(t *testing.T) { + i, k := 0, 0 + for range Check2(OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})) { + i++ + } + for j := range Check2(OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})) { + k += j + } + if i != 10 { + t.Errorf("Expected 10, got %d", i) + } + if k != 45 { + t.Errorf("Expected 45, got %d", k) + } +} + +func TestCheck(t *testing.T) { + i := 0 + defer func() { + if r := recover(); r != nil { + if matchError(r, CERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + } else { + t.Error("Wanted to see a failure") + } + }() + for _, x := range Check2(BadOfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})) { + i += x + if i > 4*9 { + break + } + } +} + +func TestCooperativeBadOfSliceIndex(t *testing.T) { + i := 0 + proceed := make(chan any) + for _, x := range CooperativeBadOfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, proceed) { + i += x + if i >= 36 { + break + } + } + proceed <- true + if r := <-proceed; r != nil { + if matchError(r, RERR_EXHAUSTED) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + } else { + t.Error("Wanted to see a failure") + } + if i != 36 { + t.Errorf("Expected i == 36, saw %d instead", i) + } else { + t.Logf("i = %d", i) + } +} + +func TestCooperativeBadOfSliceIndexCheck(t *testing.T) { + i := 0 + proceed := make(chan any) + for _, x := range Check2(CooperativeBadOfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, proceed)) { + i += x + if i >= 36 { + break + } + } + proceed <- true + if r := <-proceed; r != nil { + if matchError(r, CERR_EXHAUSTED) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + + } else { + t.Error("Wanted to see a failure") + } + if i != 36 { + t.Errorf("Expected i == 36, saw %d instead", i) + } else { + t.Logf("i = %d", i) + } +} + +func TestTrickyIterAll(t *testing.T) { + trickItAll := TrickyIterator{} + i := 0 + for _, x := range trickItAll.iterAll([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + i += x + if i >= 36 { + break + } + } + + if i != 36 { + t.Errorf("Expected i == 36, saw %d instead", i) + } else { + t.Logf("i = %d", i) + } + + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_EXHAUSTED) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + trickItAll.fail() +} + +func TestTrickyIterOne(t *testing.T) { + trickItOne := TrickyIterator{} + i := 0 + for _, x := range trickItOne.iterOne([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + i += x + if i >= 36 { + break + } + } + + // Don't care about value, ought to be 36 anyhow. + t.Logf("i = %d", i) + + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_EXHAUSTED) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + trickItOne.fail() +} + +func TestTrickyIterZero(t *testing.T) { + trickItZero := TrickyIterator{} + i := 0 + for _, x := range trickItZero.iterZero([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + i += x + if i >= 36 { + break + } + } + + // Don't care about value, ought to be 0 anyhow. + t.Logf("i = %d", i) + + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_EXHAUSTED) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + trickItZero.fail() +} + +func TestTrickyIterZeroCheck(t *testing.T) { + trickItZero := TrickyIterator{} + i := 0 + for _, x := range Check2(trickItZero.iterZero([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})) { + i += x + if i >= 36 { + break + } + } + + // Don't care about value, ought to be 0 anyhow. + t.Logf("i = %d", i) + + defer func() { + if r := recover(); r != nil { + if matchError(r, CERR_EXHAUSTED) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + trickItZero.fail() +} + +func TestTrickyIterEcho(t *testing.T) { + trickItAll := TrickyIterator{} + i := 0 + for _, x := range trickItAll.iterAll([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + t.Logf("first loop i=%d", i) + i += x + if i >= 10 { + break + } + } + + if i != 10 { + t.Errorf("Expected i == 10, saw %d instead", i) + } else { + t.Logf("i = %d", i) + } + + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_EXHAUSTED) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + i = 0 + for _, x := range trickItAll.iterEcho([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + t.Logf("second loop i=%d", i) + if x >= 5 { + break + } + } + +} + +func TestTrickyIterEcho2(t *testing.T) { + trickItAll := TrickyIterator{} + var i int + + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_EXHAUSTED) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + for k := range 2 { + i = 0 + for _, x := range trickItAll.iterEcho([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + t.Logf("k,x,i=%d,%d,%d", k, x, i) + i += x + if i >= 10 { + break + } + } + t.Logf("i = %d", i) + + if i != 10 { + t.Errorf("Expected i == 10, saw %d instead", i) + } + } +} + +// TestBreak1 should just work, with well-behaved iterators. +// (The misbehaving iterator detector should not trigger.) +func TestBreak1(t *testing.T) { + var result []int + var expect = []int{1, 2, -1, 1, 2, -2, 1, 2, -3} + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4}) { + if x == -4 { + break + } + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + break + } + result = append(result, y) + } + result = append(result, x) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestBreak2 should just work, with well-behaved iterators. +// (The misbehaving iterator detector should not trigger.) +func TestBreak2(t *testing.T) { + var result []int + var expect = []int{1, 2, -1, 1, 2, -2, 1, 2, -3} +outer: + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4}) { + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + break + } + if x == -4 { + break outer + } + + result = append(result, y) + } + result = append(result, x) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestContinue should just work, with well-behaved iterators. +// (The misbehaving iterator detector should not trigger.) +func TestContinue(t *testing.T) { + var result []int + var expect = []int{-1, 1, 2, -2, 1, 2, -3, 1, 2, -4} +outer: + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4}) { + result = append(result, x) + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + continue outer + } + if x == -4 { + break outer + } + + result = append(result, y) + } + result = append(result, x-10) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestBreak3 should just work, with well-behaved iterators. +// (The misbehaving iterator detector should not trigger.) +func TestBreak3(t *testing.T) { + var result []int + var expect = []int{100, 10, 2, 4, 200, 10, 2, 4, 20, 2, 4, 300, 10, 2, 4, 20, 2, 4, 30} +X: + for _, x := range OfSliceIndex([]int{100, 200, 300, 400}) { + Y: + for _, y := range OfSliceIndex([]int{10, 20, 30, 40}) { + if 10*y >= x { + break + } + result = append(result, y) + if y == 30 { + continue X + } + Z: + for _, z := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if z&1 == 1 { + continue Z + } + result = append(result, z) + if z >= 4 { + continue Y + } + } + result = append(result, -y) // should never be executed + } + result = append(result, x) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestBreak1BadA should end in a panic when the outer-loop's +// single-level break is ignore by BadOfSliceIndex +func TestBreak1BadA(t *testing.T) { + var result []int + var expect = []int{1, 2, -1, 1, 2, -2, 1, 2, -3} + + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + for _, x := range BadOfSliceIndex([]int{-1, -2, -3, -4, -5}) { + if x == -4 { + break + } + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + break + } + result = append(result, y) + } + result = append(result, x) + } +} + +// TestBreak1BadB should end in a panic, sooner, when the inner-loop's +// (nested) single-level break is ignored by BadOfSliceIndex +func TestBreak1BadB(t *testing.T) { + var result []int + var expect = []int{1, 2} // inner breaks, panics, after before outer appends + + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4, -5}) { + if x == -4 { + break + } + for _, y := range BadOfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + break + } + result = append(result, y) + } + result = append(result, x) + } +} + +// TestMultiCont0 tests multilevel continue with no bad iterators +// (it should just work) +func TestMultiCont0(t *testing.T) { + var result []int + var expect = []int{1000, 10, 2, 4, 2000} + +W: + for _, w := range OfSliceIndex([]int{1000, 2000}) { + result = append(result, w) + if w == 2000 { + break + } + for _, x := range OfSliceIndex([]int{100, 200, 300, 400}) { + for _, y := range OfSliceIndex([]int{10, 20, 30, 40}) { + result = append(result, y) + for _, z := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if z&1 == 1 { + continue + } + result = append(result, z) + if z >= 4 { + continue W // modified to be multilevel + } + } + result = append(result, -y) // should never be executed + } + result = append(result, x) + } + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestMultiCont1 tests multilevel continue with a bad iterator +// in the outermost loop exited by the continue. +func TestMultiCont1(t *testing.T) { + var result []int + var expect = []int{1000, 10, 2, 4} + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a failure, result was %v", result) + } + }() + +W: + for _, w := range OfSliceIndex([]int{1000, 2000}) { + result = append(result, w) + if w == 2000 { + break + } + for _, x := range BadOfSliceIndex([]int{100, 200, 300, 400}) { + for _, y := range OfSliceIndex([]int{10, 20, 30, 40}) { + result = append(result, y) + for _, z := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if z&1 == 1 { + continue + } + result = append(result, z) + if z >= 4 { + continue W + } + } + result = append(result, -y) // should never be executed + } + result = append(result, x) + } + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestMultiCont2 tests multilevel continue with a bad iterator +// in a middle loop exited by the continue. +func TestMultiCont2(t *testing.T) { + var result []int + var expect = []int{1000, 10, 2, 4} + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a failure, result was %v", result) + } + }() + +W: + for _, w := range OfSliceIndex([]int{1000, 2000}) { + result = append(result, w) + if w == 2000 { + break + } + for _, x := range OfSliceIndex([]int{100, 200, 300, 400}) { + for _, y := range BadOfSliceIndex([]int{10, 20, 30, 40}) { + result = append(result, y) + for _, z := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if z&1 == 1 { + continue + } + result = append(result, z) + if z >= 4 { + continue W + } + } + result = append(result, -y) // should never be executed + } + result = append(result, x) + } + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestMultiCont3 tests multilevel continue with a bad iterator +// in the innermost loop exited by the continue. +func TestMultiCont3(t *testing.T) { + var result []int + var expect = []int{1000, 10, 2, 4} + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a failure, result was %v", result) + } + }() + +W: + for _, w := range OfSliceIndex([]int{1000, 2000}) { + result = append(result, w) + if w == 2000 { + break + } + for _, x := range OfSliceIndex([]int{100, 200, 300, 400}) { + for _, y := range OfSliceIndex([]int{10, 20, 30, 40}) { + result = append(result, y) + for _, z := range BadOfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if z&1 == 1 { + continue + } + result = append(result, z) + if z >= 4 { + continue W + } + } + result = append(result, -y) // should never be executed + } + result = append(result, x) + } + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestMultiBreak0 tests multilevel break with a bad iterator +// in the outermost loop exited by the break (the outermost loop). +func TestMultiBreak0(t *testing.T) { + var result []int + var expect = []int{1000, 10, 2, 4} + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a failure, result was %v", result) + } + }() + +W: + for _, w := range BadOfSliceIndex([]int{1000, 2000}) { + result = append(result, w) + if w == 2000 { + break + } + for _, x := range OfSliceIndex([]int{100, 200, 300, 400}) { + for _, y := range OfSliceIndex([]int{10, 20, 30, 40}) { + result = append(result, y) + for _, z := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if z&1 == 1 { + continue + } + result = append(result, z) + if z >= 4 { + break W + } + } + result = append(result, -y) // should never be executed + } + result = append(result, x) + } + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestMultiBreak1 tests multilevel break with a bad iterator +// in an intermediate loop exited by the break. +func TestMultiBreak1(t *testing.T) { + var result []int + var expect = []int{1000, 10, 2, 4} + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a failure, result was %v", result) + } + }() + +W: + for _, w := range OfSliceIndex([]int{1000, 2000}) { + result = append(result, w) + if w == 2000 { + break + } + for _, x := range BadOfSliceIndex([]int{100, 200, 300, 400}) { + for _, y := range OfSliceIndex([]int{10, 20, 30, 40}) { + result = append(result, y) + for _, z := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if z&1 == 1 { + continue + } + result = append(result, z) + if z >= 4 { + break W + } + } + result = append(result, -y) // should never be executed + } + result = append(result, x) + } + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestMultiBreak2 tests multilevel break with two bad iterators +// in intermediate loops exited by the break. +func TestMultiBreak2(t *testing.T) { + var result []int + var expect = []int{1000, 10, 2, 4} + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a failure, result was %v", result) + } + }() + +W: + for _, w := range OfSliceIndex([]int{1000, 2000}) { + result = append(result, w) + if w == 2000 { + break + } + for _, x := range BadOfSliceIndex([]int{100, 200, 300, 400}) { + for _, y := range BadOfSliceIndex([]int{10, 20, 30, 40}) { + result = append(result, y) + for _, z := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if z&1 == 1 { + continue + } + result = append(result, z) + if z >= 4 { + break W + } + } + result = append(result, -y) // should never be executed + } + result = append(result, x) + } + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// TestMultiBreak3 tests multilevel break with the bad iterator +// in the innermost loop exited by the break. +func TestMultiBreak3(t *testing.T) { + var result []int + var expect = []int{1000, 10, 2, 4} + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a failure, result was %v", result) + } + }() + +W: + for _, w := range OfSliceIndex([]int{1000, 2000}) { + result = append(result, w) + if w == 2000 { + break + } + for _, x := range OfSliceIndex([]int{100, 200, 300, 400}) { + for _, y := range OfSliceIndex([]int{10, 20, 30, 40}) { + result = append(result, y) + for _, z := range BadOfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if z&1 == 1 { + continue + } + result = append(result, z) + if z >= 4 { + break W + } + } + result = append(result, -y) // should never be executed + } + result = append(result, x) + } + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +func TestPanickyIterator1(t *testing.T) { + var result []int + var expect = []int{1, 2, 3, 4} + defer func() { + if r := recover(); r != nil { + if matchError(r, "Panicky iterator panicking") { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a failure, result was %v", result) + } + }() + for _, z := range PanickyOfSliceIndex([]int{1, 2, 3, 4}) { + result = append(result, z) + if z == 4 { + break + } + } +} + +func TestPanickyIterator1Check(t *testing.T) { + var result []int + var expect = []int{1, 2, 3, 4} + defer func() { + if r := recover(); r != nil { + if matchError(r, "Panicky iterator panicking") { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a failure, result was %v", result) + } + }() + for _, z := range Check2(PanickyOfSliceIndex([]int{1, 2, 3, 4})) { + result = append(result, z) + if z == 4 { + break + } + } +} + +func TestPanickyIterator2(t *testing.T) { + var result []int + var expect = []int{100, 10, 1, 2} + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_MISSING) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a failure, result was %v", result) + } + }() + for _, x := range OfSliceIndex([]int{100, 200}) { + result = append(result, x) + Y: + // swallows panics and iterates to end BUT `break Y` disables the body, so--> 10, 1, 2 + for _, y := range VeryBadOfSliceIndex([]int{10, 20}) { + result = append(result, y) + + // converts early exit into a panic --> 1, 2 + for k, z := range PanickyOfSliceIndex([]int{1, 2}) { // iterator panics + result = append(result, z) + if k == 1 { + break Y + } + } + } + } +} + +func TestPanickyIterator2Check(t *testing.T) { + var result []int + var expect = []int{100, 10, 1, 2} + defer func() { + if r := recover(); r != nil { + if matchError(r, CERR_MISSING) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a panic, result was %v", result) + } + }() + for _, x := range Check2(OfSliceIndex([]int{100, 200})) { + result = append(result, x) + Y: + // swallows panics and iterates to end BUT `break Y` disables the body, so--> 10, 1, 2 + for _, y := range Check2(VeryBadOfSliceIndex([]int{10, 20})) { + result = append(result, y) + + // converts early exit into a panic --> 1, 2 + for k, z := range Check2(PanickyOfSliceIndex([]int{1, 2})) { // iterator panics + result = append(result, z) + if k == 1 { + break Y + } + } + } + } +} + +func TestPanickyIterator3(t *testing.T) { + var result []int + var expect = []int{100, 10, 1, 2} + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_MISSING) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a panic, result was %v", result) + } + }() + for _, x := range OfSliceIndex([]int{100, 200}) { + result = append(result, x) + Y: + // swallows panics and iterates to end BUT `break Y` disables the body, so--> 10, 1, 2 + // This is cross-checked against the checked iterator below; the combinator should behave the same. + for _, y := range VeryBadOfSliceIndex([]int{10, 20}) { + result = append(result, y) + + for k, z := range OfSliceIndex([]int{1, 2}) { // iterator does not panic + result = append(result, z) + if k == 1 { + break Y + } + } + } + } +} +func TestPanickyIterator3Check(t *testing.T) { + var result []int + var expect = []int{100, 10, 1, 2} + defer func() { + if r := recover(); r != nil { + if matchError(r, CERR_MISSING) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a panic, result was %v", result) + } + }() + for _, x := range Check2(OfSliceIndex([]int{100, 200})) { + result = append(result, x) + Y: + // swallows panics and iterates to end BUT `break Y` disables the body, so--> 10, 1, 2 + for _, y := range Check2(VeryBadOfSliceIndex([]int{10, 20})) { + result = append(result, y) + + for k, z := range Check2(OfSliceIndex([]int{1, 2})) { // iterator does not panic + result = append(result, z) + if k == 1 { + break Y + } + } + } + } +} + +func TestPanickyIterator4(t *testing.T) { + var result []int + var expect = []int{1, 2, 3} + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_MISSING) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a panic, result was %v", result) + } + }() + for _, x := range SwallowPanicOfSliceIndex([]int{1, 2, 3, 4}) { + result = append(result, x) + if x == 3 { + panic("x is 3") + } + } + +} +func TestPanickyIterator4Check(t *testing.T) { + var result []int + var expect = []int{1, 2, 3} + defer func() { + if r := recover(); r != nil { + if matchError(r, CERR_MISSING) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + } else { + t.Errorf("Wanted to see a panic, result was %v", result) + } + }() + for _, x := range Check2(SwallowPanicOfSliceIndex([]int{1, 2, 3, 4})) { + result = append(result, x) + if x == 3 { + panic("x is 3") + } + } + +} + +// veryBad tests that a loop nest behaves sensibly in the face of a +// "very bad" iterator. In this case, "sensibly" means that the +// break out of X still occurs after the very bad iterator finally +// quits running (the control flow bread crumbs remain.) +func veryBad(s []int) []int { + var result []int +X: + for _, x := range OfSliceIndex([]int{1, 2, 3}) { + + result = append(result, x) + + for _, y := range VeryBadOfSliceIndex(s) { + result = append(result, y) + break X + } + for _, z := range OfSliceIndex([]int{100, 200, 300}) { + result = append(result, z) + if z == 100 { + break + } + } + } + return result +} + +// veryBadCheck wraps a "very bad" iterator with Check, +// demonstrating that the very bad iterator also hides panics +// thrown by Check. +func veryBadCheck(s []int) []int { + var result []int +X: + for _, x := range OfSliceIndex([]int{1, 2, 3}) { + + result = append(result, x) + + for _, y := range Check2(VeryBadOfSliceIndex(s)) { + result = append(result, y) + break X + } + for _, z := range OfSliceIndex([]int{100, 200, 300}) { + result = append(result, z) + if z == 100 { + break + } + } + } + return result +} + +// okay is the not-bad version of veryBad. +// They should behave the same. +func okay(s []int) []int { + var result []int +X: + for _, x := range OfSliceIndex([]int{1, 2, 3}) { + + result = append(result, x) + + for _, y := range OfSliceIndex(s) { + result = append(result, y) + break X + } + for _, z := range OfSliceIndex([]int{100, 200, 300}) { + result = append(result, z) + if z == 100 { + break + } + } + } + return result +} + +// TestVeryBad1 checks the behavior of an extremely poorly behaved iterator. +func TestVeryBad1(t *testing.T) { + expect := []int{} // assignment does not happen + var result []int + + defer func() { + if r := recover(); r != nil { + expectPanic(t, r, RERR_MISSING) + if !slices.Equal(expect, result) { + t.Errorf("(Inner) Expected %v, got %v", expect, result) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + result = veryBad([]int{10, 20, 30, 40, 50}) // odd length + +} + +func expectPanic(t *testing.T, r any, s string) { + if matchError(r, s) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } +} + +func expectError(t *testing.T, err any, s string) { + if matchError(err, s) { + t.Logf("Saw expected error '%v'", err) + } else { + t.Errorf("Saw wrong error '%v'", err) + } +} + +// TestVeryBad2 checks the behavior of an extremely poorly behaved iterator. +func TestVeryBad2(t *testing.T) { + result := []int{} + expect := []int{} + + defer func() { + if r := recover(); r != nil { + expectPanic(t, r, RERR_MISSING) + if !slices.Equal(expect, result) { + t.Errorf("(Inner) Expected %v, got %v", expect, result) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + result = veryBad([]int{10, 20, 30, 40}) // even length + +} + +// TestVeryBadCheck checks the behavior of an extremely poorly behaved iterator, +// which also suppresses the exceptions from "Check" +func TestVeryBadCheck(t *testing.T) { + expect := []int{} + var result []int + defer func() { + if r := recover(); r != nil { + expectPanic(t, r, CERR_MISSING) + } + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + }() + + result = veryBadCheck([]int{10, 20, 30, 40}) // even length + +} + +// TestOk is the nice version of the very bad iterator. +func TestOk(t *testing.T) { + result := okay([]int{10, 20, 30, 40, 50}) // odd length + expect := []int{1, 10} + + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } +} + +// testBreak1BadDefer checks that defer behaves properly even in +// the presence of loop bodies panicking out of bad iterators. +// (i.e., the instrumentation did not break defer in these loops) +func testBreak1BadDefer(t *testing.T) (result []int) { + var expect = []int{1, 2, -1, 1, 2, -2, 1, 2, -3, -30, -20, -10} + + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_DONE) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + if !slices.Equal(expect, result) { + t.Errorf("(Inner) Expected %v, got %v", expect, result) + } + } else { + t.Error("Wanted to see a failure") + } + }() + + for _, x := range BadOfSliceIndex([]int{-1, -2, -3, -4, -5}) { + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + break + } + result = append(result, y) + } + result = append(result, x) + } + return +} + +func TestBreak1BadDefer(t *testing.T) { + var result []int + var expect = []int{1, 2, -1, 1, 2, -2, 1, 2, -3, -30, -20, -10} + result = testBreak1BadDefer(t) + if !slices.Equal(expect, result) { + t.Errorf("(Outer) Expected %v, got %v", expect, result) + } +} + +// testReturn1 has no bad iterators. +func testReturn1(t *testing.T) (result []int, err any) { + defer func() { + err = recover() + }() + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4, -5}) { + result = append(result, x) + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + return + } + result = append(result, y) + } + result = append(result, x) + } + return +} + +// testReturn2 has an outermost bad iterator +func testReturn2(t *testing.T) (result []int, err any) { + defer func() { + err = recover() + }() + for _, x := range BadOfSliceIndex([]int{-1, -2, -3, -4, -5}) { + result = append(result, x) + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + return + } + result = append(result, y) + } + result = append(result, x) + } + return +} + +// testReturn3 has an innermost bad iterator +func testReturn3(t *testing.T) (result []int, err any) { + defer func() { + err = recover() + }() + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4, -5}) { + result = append(result, x) + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range BadOfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + return + } + result = append(result, y) + } + } + return +} + +// testReturn4 has no bad iterators, but exercises return variable rewriting +// differs from testReturn1 because deferred append to "result" does not change +// the return value in this case. +func testReturn4(t *testing.T) (_ []int, _ []int, err any) { + var result []int + defer func() { + err = recover() + }() + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4, -5}) { + result = append(result, x) + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + return result, result, nil + } + result = append(result, y) + } + result = append(result, x) + } + return +} + +// TestReturns checks that returns through bad iterators behave properly, +// for inner and outer bad iterators. +func TestReturns(t *testing.T) { + var result []int + var result2 []int + var expect = []int{-1, 1, 2, -10} + var expect2 = []int{-1, 1, 2} + var err any + + result, err = testReturn1(t) + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + if err != nil { + t.Errorf("Unexpected error %v", err) + } + + result, err = testReturn2(t) + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + if err == nil { + t.Errorf("Missing expected error") + } else { + if matchError(err, RERR_DONE) { + t.Logf("Saw expected panic '%v'", err) + } else { + t.Errorf("Saw wrong panic '%v'", err) + } + } + + result, err = testReturn3(t) + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + if err == nil { + t.Errorf("Missing expected error") + } else { + if matchError(err, RERR_DONE) { + t.Logf("Saw expected panic '%v'", err) + } else { + t.Errorf("Saw wrong panic '%v'", err) + } + } + + result, result2, err = testReturn4(t) + if !slices.Equal(expect2, result) { + t.Errorf("Expected %v, got %v", expect2, result) + } + if !slices.Equal(expect2, result2) { + t.Errorf("Expected %v, got %v", expect2, result2) + } + if err != nil { + t.Errorf("Unexpected error %v", err) + } +} + +// testGotoA1 tests loop-nest-internal goto, no bad iterators. +func testGotoA1(t *testing.T) (result []int, err any) { + defer func() { + err = recover() + }() + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4, -5}) { + result = append(result, x) + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + goto A + } + result = append(result, y) + } + result = append(result, x) + A: + } + return +} + +// testGotoA2 tests loop-nest-internal goto, outer bad iterator. +func testGotoA2(t *testing.T) (result []int, err any) { + defer func() { + err = recover() + }() + for _, x := range BadOfSliceIndex([]int{-1, -2, -3, -4, -5}) { + result = append(result, x) + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + goto A + } + result = append(result, y) + } + result = append(result, x) + A: + } + return +} + +// testGotoA3 tests loop-nest-internal goto, inner bad iterator. +func testGotoA3(t *testing.T) (result []int, err any) { + defer func() { + err = recover() + }() + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4, -5}) { + result = append(result, x) + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range BadOfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + goto A + } + result = append(result, y) + } + result = append(result, x) + A: + } + return +} + +func TestGotoA(t *testing.T) { + var result []int + var expect = []int{-1, 1, 2, -2, 1, 2, -3, 1, 2, -4, -30, -20, -10} + var expect3 = []int{-1, 1, 2, -10} // first goto becomes a panic + var err any + + result, err = testGotoA1(t) + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + if err != nil { + t.Errorf("Unexpected error %v", err) + } + + result, err = testGotoA2(t) + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + if err == nil { + t.Errorf("Missing expected error") + } else { + if matchError(err, RERR_DONE) { + t.Logf("Saw expected panic '%v'", err) + } else { + t.Errorf("Saw wrong panic '%v'", err) + } + } + + result, err = testGotoA3(t) + if !slices.Equal(expect3, result) { + t.Errorf("Expected %v, got %v", expect3, result) + } + if err == nil { + t.Errorf("Missing expected error") + } else { + if matchError(err, RERR_DONE) { + t.Logf("Saw expected panic '%v'", err) + } else { + t.Errorf("Saw wrong panic '%v'", err) + } + } +} + +// testGotoB1 tests loop-nest-exiting goto, no bad iterators. +func testGotoB1(t *testing.T) (result []int, err any) { + defer func() { + err = recover() + }() + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4, -5}) { + result = append(result, x) + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + goto B + } + result = append(result, y) + } + result = append(result, x) + } +B: + result = append(result, 999) + return +} + +// testGotoB2 tests loop-nest-exiting goto, outer bad iterator. +func testGotoB2(t *testing.T) (result []int, err any) { + defer func() { + err = recover() + }() + for _, x := range BadOfSliceIndex([]int{-1, -2, -3, -4, -5}) { + result = append(result, x) + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range OfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + goto B + } + result = append(result, y) + } + result = append(result, x) + } +B: + result = append(result, 999) + return +} + +// testGotoB3 tests loop-nest-exiting goto, inner bad iterator. +func testGotoB3(t *testing.T) (result []int, err any) { + defer func() { + err = recover() + }() + for _, x := range OfSliceIndex([]int{-1, -2, -3, -4, -5}) { + result = append(result, x) + if x == -4 { + break + } + defer func() { + result = append(result, x*10) + }() + for _, y := range BadOfSliceIndex([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) { + if y == 3 { + goto B + } + result = append(result, y) + } + result = append(result, x) + } +B: + result = append(result, 999) + return +} + +func TestGotoB(t *testing.T) { + var result []int + var expect = []int{-1, 1, 2, 999, -10} + var expectX = []int{-1, 1, 2, -10} + var err any + + result, err = testGotoB1(t) + if !slices.Equal(expect, result) { + t.Errorf("Expected %v, got %v", expect, result) + } + if err != nil { + t.Errorf("Unexpected error %v", err) + } + + result, err = testGotoB2(t) + if !slices.Equal(expectX, result) { + t.Errorf("Expected %v, got %v", expectX, result) + } + if err == nil { + t.Errorf("Missing expected error") + } else { + if matchError(err, RERR_DONE) { + t.Logf("Saw expected panic '%v'", err) + } else { + t.Errorf("Saw wrong panic '%v'", err) + } + } + + result, err = testGotoB3(t) + if !slices.Equal(expectX, result) { + t.Errorf("Expected %v, got %v", expectX, result) + } + if err == nil { + t.Errorf("Missing expected error") + } else { + matchErrorHelper(t, err, RERR_DONE) + } +} + +// once returns an iterator that runs its loop body once with the supplied value +func once[T any](x T) Seq[T] { + return func(yield func(T) bool) { + yield(x) + } +} + +// terrify converts an iterator into one that panics with the supplied string +// if/when the loop body terminates early (returns false, for break, goto, outer +// continue, or return). +func terrify[T any](s string, forall Seq[T]) Seq[T] { + return func(yield func(T) bool) { + forall(func(v T) bool { + if !yield(v) { + panic(s) + } + return true + }) + } +} + +func use[T any](T) { +} + +// f runs a not-rangefunc iterator that recovers from a panic that follows execution of a return. +// what does f return? +func f() string { + defer func() { recover() }() + defer panic("f panic") + for _, s := range []string{"f return"} { + return s + } + return "f not reached" +} + +// g runs a rangefunc iterator that recovers from a panic that follows execution of a return. +// what does g return? +func g() string { + defer func() { recover() }() + for s := range terrify("g panic", once("g return")) { + return s + } + return "g not reached" +} + +// h runs a rangefunc iterator that recovers from a panic that follows execution of a return. +// the panic occurs in the rangefunc iterator itself. +// what does h return? +func h() (hashS string) { + defer func() { recover() }() + for s := range terrify("h panic", once("h return")) { + hashS := s + use(hashS) + return s + } + return "h not reached" +} + +func j() (hashS string) { + defer func() { recover() }() + for s := range terrify("j panic", once("j return")) { + hashS = s + return + } + return "j not reached" +} + +// k runs a rangefunc iterator that recovers from a panic that follows execution of a return. +// the panic occurs in the rangefunc iterator itself. +// k includes an additional mechanism to for making the return happen +// what does k return? +func k() (hashS string) { + _return := func(s string) { hashS = s } + + defer func() { recover() }() + for s := range terrify("k panic", once("k return")) { + _return(s) + return + } + return "k not reached" +} + +func m() (hashS string) { + _return := func(s string) { hashS = s } + + defer func() { recover() }() + for s := range terrify("m panic", once("m return")) { + defer _return(s) + return s + ", but should be replaced in a defer" + } + return "m not reached" +} + +func n() string { + defer func() { recover() }() + for s := range terrify("n panic", once("n return")) { + return s + func(s string) string { + defer func() { recover() }() + for s := range terrify("n closure panic", once(s)) { + return s + } + return "n closure not reached" + }(" and n closure return") + } + return "n not reached" +} + +type terrifyTestCase struct { + f func() string + e string +} + +func TestPanicReturns(t *testing.T) { + tcs := []terrifyTestCase{ + {f, "f return"}, + {g, "g return"}, + {h, "h return"}, + {k, "k return"}, + {j, "j return"}, + {m, "m return"}, + {n, "n return and n closure return"}, + } + + for _, tc := range tcs { + got := tc.f() + if got != tc.e { + t.Errorf("Got %s expected %s", got, tc.e) + } else { + t.Logf("Got expected %s", got) + } + } +} + +// twice calls yield twice, the first time defer-recover-saving any panic, +// for re-panicking later if the second call to yield does not also panic. +// If the first call panicked, the second call ought to also panic because +// it was called after a panic-termination of the loop body. +func twice[T any](x, y T) Seq[T] { + return func(yield func(T) bool) { + var p any + done := false + func() { + defer func() { + p = recover() + }() + done = !yield(x) + }() + if done { + return + } + yield(y) + if p != nil { + // do not swallow the panic + panic(p) + } + } +} + +func TestRunBodyAfterPanic(t *testing.T) { + defer func() { + if r := recover(); r != nil { + if matchError(r, RERR_PANIC) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + } else { + t.Errorf("Wanted to see a failure, result") + } + }() + for x := range twice(0, 1) { + if x == 0 { + panic("x is zero") + } + } +} + +func TestRunBodyAfterPanicCheck(t *testing.T) { + defer func() { + if r := recover(); r != nil { + if matchError(r, CERR_PANIC) { + t.Logf("Saw expected panic '%v'", r) + } else { + t.Errorf("Saw wrong panic '%v'", r) + } + } else { + t.Errorf("Wanted to see a failure, result") + } + }() + for x := range Check(twice(0, 1)) { + if x == 0 { + panic("x is zero") + } + } +} + +func TestTwoLevelReturn(t *testing.T) { + f := func() int { + for a := range twice(0, 1) { + for b := range twice(0, 2) { + x := a + b + t.Logf("x=%d", x) + if x == 3 { + return x + } + } + } + return -1 + } + y := f() + if y != 3 { + t.Errorf("Expected y=3, got y=%d\n", y) + } +} + +func TestTwoLevelReturnCheck(t *testing.T) { + f := func() int { + for a := range Check(twice(0, 1)) { + for b := range Check(twice(0, 2)) { + x := a + b + t.Logf("a=%d, b=%d, x=%d", a, b, x) + if x == 3 { + return x + } + } + } + return -1 + } + y := f() + if y != 3 { + t.Errorf("Expected y=3, got y=%d\n", y) + } +} + +func Bug70035(s1, s2, s3 []string) string { + var c1 string + for v1 := range slices.Values(s1) { + var c2 string + for v2 := range slices.Values(s2) { + var c3 string + for v3 := range slices.Values(s3) { + c3 = c3 + v3 + } + c2 = c2 + v2 + c3 + } + c1 = c1 + v1 + c2 + } + return c1 +} + +func Test70035(t *testing.T) { + got := Bug70035([]string{"1", "2", "3"}, []string{"a", "b", "c"}, []string{"A", "B", "C"}) + want := "1aABCbABCcABC2aABCbABCcABC3aABCbABCcABC" + if got != want { + t.Errorf("got %v, want %v", got, want) + } +} diff --git a/go/src/cmd/compile/internal/rangefunc/rewrite.go b/go/src/cmd/compile/internal/rangefunc/rewrite.go new file mode 100644 index 0000000000000000000000000000000000000000..74c7f55801c6d7291e4c4f507d184243f29a8884 --- /dev/null +++ b/go/src/cmd/compile/internal/rangefunc/rewrite.go @@ -0,0 +1,1534 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/* +Package rangefunc rewrites range-over-func to code that doesn't use range-over-funcs. +Rewriting the construct in the front end, before noder, means the functions generated during +the rewrite are available in a noder-generated representation for inlining by the back end. + +# Theory of Operation + +The basic idea is to rewrite + + for x := range f { + ... + } + +into + + f(func(x T) bool { + ... + }) + +But it's not usually that easy. + +# Range variables + +For a range not using :=, the assigned variables cannot be function parameters +in the generated body function. Instead, we allocate fake parameters and +start the body with an assignment. For example: + + for expr1, expr2 = range f { + ... + } + +becomes + + f(func(#p1 T1, #p2 T2) bool { + expr1, expr2 = #p1, #p2 + ... + }) + +(All the generated variables have a # at the start to signal that they +are internal variables when looking at the generated code in a +debugger. Because variables have all been resolved to the specific +objects they represent, there is no danger of using plain "p1" and +colliding with a Go variable named "p1"; the # is just nice to have, +not for correctness.) + +It can also happen that there are fewer range variables than function +arguments, in which case we end up with something like + + f(func(x T1, _ T2) bool { + ... + }) + +or + + f(func(#p1 T1, #p2 T2, _ T3) bool { + expr1, expr2 = #p1, #p2 + ... + }) + +# Return + +If the body contains a "break", that break turns into "return false", +to tell f to stop. And if the body contains a "continue", that turns +into "return true", to tell f to proceed with the next value. +Those are the easy cases. + +If the body contains a return or a break/continue/goto L, then we need +to rewrite that into code that breaks out of the loop and then +triggers that control flow. In general we rewrite + + for x := range f { + ... + } + +into + + { + var #next int + f(func(x T1) bool { + ... + return true + }) + ... check #next ... + } + +The variable #next is an integer code that says what to do when f +returns. Each difficult statement sets #next and then returns false to +stop f. + +A plain "return" rewrites to {#next = -1; return false}. +The return false breaks the loop. Then when f returns, the "check +#next" section includes + + if #next == -1 { return } + +which causes the return we want. + +Return with arguments is more involved, and has to deal with +corner cases involving panic, defer, and recover. The results +of the enclosing function or closure are rewritten to give them +names if they don't have them already, and the names are assigned +at the return site. + + func foo() (#rv1 A, #rv2 B) { + + { + var ( + #next int + ) + f(func(x T1) bool { + ... + { + // return a, b + #rv1, #rv2 = a, b + #next = -1 + return false + } + ... + return true + }) + if #next == -1 { return } + } + +# Checking + +To permit checking that an iterator is well-behaved -- that is, that +it does not call the loop body again after it has returned false or +after the entire loop has exited (it might retain a copy of the body +function, or pass it to another goroutine) -- each generated loop has +its own #stateK variable that is used to check for permitted call +patterns to the yield function for a loop body. + +The state values are: + +abi.RF_DONE = 0 // body of loop has exited in a non-panic way +abi.RF_READY = 1 // body of loop has not exited yet, is not running +abi.RF_PANIC = 2 // body of loop is either currently running, or has panicked +abi.RF_EXHAUSTED = 3 // iterator function call, e.g. f(func(x t){...}), returned so the sequence is "exhausted". + +abi.RF_MISSING_PANIC = 4 // used to report errors. + +The value of #stateK transitions +(1) before calling the iterator function, + + var #stateN = abi.RF_READY + +(2) after the iterator function call returns, + + if #stateN == abi.RF_PANIC { + panic(runtime.panicrangestate(abi.RF_MISSING_PANIC)) + } + #stateN = abi.RF_EXHAUSTED + +(3) at the beginning of the iteration of the loop body, + + if #stateN != abi.RF_READY { #stateN = abi.RF_PANIC ; runtime.panicrangestate(#stateN) } + #stateN = abi.RF_PANIC + // This is slightly rearranged below for better code generation. + +(4) when loop iteration continues, + + #stateN = abi.RF_READY + [return true] + +(5) when control flow exits the loop body. + + #stateN = abi.RF_DONE + [return false] + +For example: + + for x := range f { + ... + if ... { break } + ... + } + +becomes + + { + var #state1 = abi.RF_READY + f(func(x T1) bool { + if #state1 != abi.RF_READY { #state1 = abi.RF_PANIC; runtime.panicrangestate(#state1) } + #state1 = abi.RF_PANIC + ... + if ... { #state1 = abi.RF_DONE ; return false } + ... + #state1 = abi.RF_READY + return true + }) + if #state1 == abi.RF_PANIC { + // the code for the loop body did not return normally + panic(runtime.panicrangestate(abi.RF_MISSING_PANIC)) + } + #state1 = abi.RF_EXHAUSTED + } + +# Nested Loops + +So far we've only considered a single loop. If a function contains a +sequence of loops, each can be translated individually. But loops can +be nested. It would work to translate the innermost loop and then +translate the loop around it, and so on, except that there'd be a lot +of rewriting of rewritten code and the overall traversals could end up +taking time quadratic in the depth of the nesting. To avoid all that, +we use a single rewriting pass that handles a top-most range-over-func +loop and all the range-over-func loops it contains at the same time. + +If we need to return from inside a doubly-nested loop, the rewrites +above stay the same, but the check after the inner loop only says + + if #next < 0 { return false } + +to stop the outer loop so it can do the actual return. That is, + + for range f { + for range g { + ... + return a, b + ... + } + } + +becomes + + { + var ( + #next int + ) + var #state1 = abi.RF_READY + f(func() bool { + if #state1 != abi.RF_READY { #state1 = abi.RF_PANIC; runtime.panicrangestate(#state1) } + #state1 = abi.RF_PANIC + var #state2 = abi.RF_READY + g(func() bool { + if #state2 != abi.RF_READY { #state2 = abi.RF_PANIC; runtime.panicrangestate(#state2) } + ... + { + // return a, b + #rv1, #rv2 = a, b + #next = -1 + #state2 = abi.RF_DONE + return false + } + ... + #state2 = abi.RF_READY + return true + }) + if #state2 == abi.RF_PANIC { + panic(runtime.panicrangestate(abi.RF_MISSING_PANIC)) + } + #state2 = abi.RF_EXHAUSTED + if #next < 0 { + #state1 = abi.RF_DONE + return false + } + #state1 = abi.RF_READY + return true + }) + if #state1 == abi.RF_PANIC { + panic(runtime.panicrangestate(abi.RF_MISSING_PANIC)) + } + #state1 = abi.RF_EXHAUSTED + if #next == -1 { + return + } + } + +# Labeled break/continue of range-over-func loops + +For a labeled break or continue of an outer range-over-func, we +use positive #next values. + +Any such labeled break or continue +really means "do N breaks" or "do N breaks and 1 continue". + +The positive #next value tells which level of loop N to target +with a break or continue, where perLoopStep*N means break out of +level N and perLoopStep*N-1 means continue into level N. The +outermost loop has level 1, therefore #next == perLoopStep means +to break from the outermost loop, and #next == perLoopStep-1 means +to continue the outermost loop. + +Loops that might need to propagate a labeled break or continue +add one or both of these to the #next checks: + + // N == depth of this loop, one less than the one just exited. + if #next != 0 { + if #next >= perLoopStep*N-1 { // break or continue this loop + if #next >= perLoopStep*N+1 { // error checking + // TODO reason about what exactly can appear + // here given full or partial checking. + runtime.panicrangestate(abi.RF_DONE) + } + rv := #next & 1 == 1 // code generates into #next&1 + #next = 0 + return rv + } + return false // or handle returns and gotos + } + +For example (with perLoopStep == 2) + + F: for range f { // 1, 2 + for range g { // 3, 4 + for range h { + ... + break F + ... + ... + continue F + ... + } + } + ... + } + +becomes + + { + var #next int + var #state1 = abi.RF_READY + f(func() { // 1,2 + if #state1 != abi.RF_READY { #state1 = abi.RF_PANIC; runtime.panicrangestate(#state1) } + #state1 = abi.RF_PANIC + var #state2 = abi.RF_READY + g(func() { // 3,4 + if #state2 != abi.RF_READY { #state2 = abi.RF_PANIC; runtime.panicrangestate(#state2) } + #state2 = abi.RF_PANIC + var #state3 = abi.RF_READY + h(func() { // 5,6 + if #state3 != abi.RF_READY { #state3 = abi.RF_PANIC; runtime.panicrangestate(#state3) } + #state3 = abi.RF_PANIC + ... + { + // break F + #next = 2 + #state3 = abi.RF_DONE + return false + } + ... + { + // continue F + #next = 1 + #state3 = abi.RF_DONE + return false + } + ... + #state3 = abi.RF_READY + return true + }) + if #state3 == abi.RF_PANIC { + panic(runtime.panicrangestate(abi.RF_MISSING_PANIC)) + } + #state3 = abi.RF_EXHAUSTED + if #next != 0 { + // no breaks or continues targeting this loop + #state2 = abi.RF_DONE + return false + } + return true + }) + if #state2 == abi.RF_PANIC { + panic(runtime.panicrangestate(abi.RF_MISSING_PANIC)) + } + #state2 = abi.RF_EXHAUSTED + if #next != 0 { // just exited g, test for break/continue applied to f/F + if #next >= 1 { + if #next >= 3 { runtime.panicrangestate(abi.RF_DONE) } // error + rv := #next&1 == 1 + #next = 0 + return rv + } + #state1 = abi.RF_DONE + return false + } + ... + return true + }) + if #state1 == abi.RF_PANIC { + panic(runtime.panicrangestate(abi.RF_MISSING_PANIC)) + } + #state1 = abi.RF_EXHAUSTED + } + +Note that the post-h checks only consider a break, +since no generated code tries to continue g. + +# Gotos and other labeled break/continue + +The final control flow translations are goto and break/continue of a +non-range-over-func statement. In both cases, we may need to break +out of one or more range-over-func loops before we can do the actual +control flow statement. Each such break/continue/goto L statement is +assigned a unique negative #next value (since -1 is return). Then +the post-checks for a given loop test for the specific codes that +refer to labels directly targetable from that block. Otherwise, the +generic + + if #next < 0 { return false } + +check handles stopping the next loop to get one step closer to the label. + +For example + + Top: print("start\n") + for range f { + for range g { + ... + for range h { + ... + goto Top + ... + } + } + } + +becomes + + Top: print("start\n") + { + var #next int + var #state1 = abi.RF_READY + f(func() { + if #state1 != abi.RF_READY{ #state1 = abi.RF_PANIC; runtime.panicrangestate(#state1) } + #state1 = abi.RF_PANIC + var #state2 = abi.RF_READY + g(func() { + if #state2 != abi.RF_READY { #state2 = abi.RF_PANIC; runtime.panicrangestate(#state2) } + #state2 = abi.RF_PANIC + ... + var #state3 bool = abi.RF_READY + h(func() { + if #state3 != abi.RF_READY { #state3 = abi.RF_PANIC; runtime.panicrangestate(#state3) } + #state3 = abi.RF_PANIC + ... + { + // goto Top + #next = -3 + #state3 = abi.RF_DONE + return false + } + ... + #state3 = abi.RF_READY + return true + }) + if #state3 == abi.RF_PANIC {runtime.panicrangestate(abi.RF_MISSING_PANIC)} + #state3 = abi.RF_EXHAUSTED + if #next < 0 { + #state2 = abi.RF_DONE + return false + } + #state2 = abi.RF_READY + return true + }) + if #state2 == abi.RF_PANIC {runtime.panicrangestate(abi.RF_MISSING_PANIC)} + #state2 = abi.RF_EXHAUSTED + if #next < 0 { + #state1 = abi.RF_DONE + return false + } + #state1 = abi.RF_READY + return true + }) + if #state1 == abi.RF_PANIC {runtime.panicrangestate(abi.RF_MISSING_PANIC)} + #state1 = abi.RF_EXHAUSTED + if #next == -3 { + #next = 0 + goto Top + } + } + +Labeled break/continue to non-range-over-funcs are handled the same +way as goto. + +# Defers + +The last wrinkle is handling defer statements. If we have + + for range f { + defer print("A") + } + +we cannot rewrite that into + + f(func() { + defer print("A") + }) + +because the deferred code will run at the end of the iteration, not +the end of the containing function. To fix that, the runtime provides +a special hook that lets us obtain a defer "token" representing the +outer function and then use it in a later defer to attach the deferred +code to that outer function. + +Normally, + + defer print("A") + +compiles to + + runtime.deferproc(func() { print("A") }) + +This changes in a range-over-func. For example: + + for range f { + defer print("A") + } + +compiles to + + var #defers = runtime.deferrangefunc() + f(func() { + runtime.deferprocat(func() { print("A") }, #defers) + }) + +For this rewriting phase, we insert the explicit initialization of +#defers and then attach the #defers variable to the CallStmt +representing the defer. That variable will be propagated to the +backend and will cause the backend to compile the defer using +deferprocat instead of an ordinary deferproc. + +TODO: Could call runtime.deferrangefuncend after f. +*/ +package rangefunc + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/syntax" + "cmd/compile/internal/types2" + "fmt" + "go/constant" + "internal/abi" + "os" +) + +// nopos is the zero syntax.Pos. +var nopos syntax.Pos + +// A rewriter implements rewriting the range-over-funcs in a given function. +type rewriter struct { + pkg *types2.Package + info *types2.Info + sig *types2.Signature + outer *syntax.FuncType + body *syntax.BlockStmt + + // References to important types and values. + any types2.Object + bool types2.Object + int types2.Object + true types2.Object + false types2.Object + + // Branch numbering, computed as needed. + branchNext map[branch]int // branch -> #next value + labelLoop map[string]*syntax.ForStmt // label -> innermost rangefunc loop it is declared inside (nil for no loop) + + // Stack of nodes being visited. + stack []syntax.Node // all nodes + forStack []*forLoop // range-over-func loops + + rewritten map[*syntax.ForStmt]syntax.Stmt + + // Declared variables in generated code for outermost loop. + declStmt *syntax.DeclStmt + nextVar types2.Object + defers types2.Object + stateVarCount int // stateVars are referenced from their respective loops + bodyClosureCount int // to help the debugger, the closures generated for loop bodies get names + + rangefuncBodyClosures map[*syntax.FuncLit]bool +} + +// A branch is a single labeled branch. +type branch struct { + tok syntax.Token + label string +} + +// A forLoop describes a single range-over-func loop being processed. +type forLoop struct { + nfor *syntax.ForStmt // actual syntax + stateVar *types2.Var // #state variable for this loop + stateVarDecl *syntax.VarDecl + depth int // outermost loop has depth 1, otherwise depth = depth(parent)+1 + + checkRet bool // add check for "return" after loop + checkBreak bool // add check for "break" after loop + checkContinue bool // add check for "continue" after loop + checkBranch []branch // add check for labeled branch after loop +} + +type State int + +// Rewrite rewrites all the range-over-funcs in the files. +// It returns the set of function literals generated from rangefunc loop bodies. +// This allows for rangefunc loop bodies to be distinguished by debuggers. +func Rewrite(pkg *types2.Package, info *types2.Info, files []*syntax.File) map[*syntax.FuncLit]bool { + ri := make(map[*syntax.FuncLit]bool) + for _, file := range files { + syntax.Inspect(file, func(n syntax.Node) bool { + switch n := n.(type) { + case *syntax.FuncDecl: + sig, _ := info.Defs[n.Name].Type().(*types2.Signature) + rewriteFunc(pkg, info, n.Type, n.Body, sig, ri) + return false + case *syntax.FuncLit: + sig, _ := info.Types[n].Type.(*types2.Signature) + if sig == nil { + tv := n.GetTypeInfo() + sig = tv.Type.(*types2.Signature) + } + rewriteFunc(pkg, info, n.Type, n.Body, sig, ri) + return false + } + return true + }) + } + return ri +} + +// rewriteFunc rewrites all the range-over-funcs in a single function (a top-level func or a func literal). +// The typ and body are the function's type and body. +func rewriteFunc(pkg *types2.Package, info *types2.Info, typ *syntax.FuncType, body *syntax.BlockStmt, sig *types2.Signature, ri map[*syntax.FuncLit]bool) { + if body == nil { + return + } + r := &rewriter{ + pkg: pkg, + info: info, + outer: typ, + body: body, + sig: sig, + rangefuncBodyClosures: ri, + } + syntax.Inspect(body, r.inspect) + if (base.Flag.W != 0) && r.forStack != nil { + syntax.Fdump(os.Stderr, body) + } +} + +// checkFuncMisuse reports whether to check for misuse of iterator callbacks functions. +func (r *rewriter) checkFuncMisuse() bool { + return base.Debug.RangeFuncCheck != 0 +} + +// inspect is a callback for syntax.Inspect that drives the actual rewriting. +// If it sees a func literal, it kicks off a separate rewrite for that literal. +// Otherwise, it maintains a stack of range-over-func loops and +// converts each in turn. +func (r *rewriter) inspect(n syntax.Node) bool { + switch n := n.(type) { + case *syntax.FuncLit: + sig, _ := r.info.Types[n].Type.(*types2.Signature) + if sig == nil { + tv := n.GetTypeInfo() + sig = tv.Type.(*types2.Signature) + } + rewriteFunc(r.pkg, r.info, n.Type, n.Body, sig, r.rangefuncBodyClosures) + return false + + default: + // Push n onto stack. + r.stack = append(r.stack, n) + if nfor, ok := forRangeFunc(n); ok { + loop := &forLoop{nfor: nfor, depth: 1 + len(r.forStack)} + r.forStack = append(r.forStack, loop) + r.startLoop(loop) + } + + case nil: + // n == nil signals that we are done visiting + // the top-of-stack node's children. Find it. + n = r.stack[len(r.stack)-1] + + // If we are inside a range-over-func, + // take this moment to replace any break/continue/goto/return + // statements directly contained in this node. + // Also replace any converted for statements + // with the rewritten block. + switch n := n.(type) { + case *syntax.BlockStmt: + for i, s := range n.List { + n.List[i] = r.editStmt(s) + } + case *syntax.CaseClause: + for i, s := range n.Body { + n.Body[i] = r.editStmt(s) + } + case *syntax.CommClause: + for i, s := range n.Body { + n.Body[i] = r.editStmt(s) + } + case *syntax.LabeledStmt: + n.Stmt = r.editStmt(n.Stmt) + } + + // Pop n. + if len(r.forStack) > 0 && r.stack[len(r.stack)-1] == r.forStack[len(r.forStack)-1].nfor { + r.endLoop(r.forStack[len(r.forStack)-1]) + r.forStack = r.forStack[:len(r.forStack)-1] + } + r.stack = r.stack[:len(r.stack)-1] + } + return true +} + +// startLoop sets up for converting a range-over-func loop. +func (r *rewriter) startLoop(loop *forLoop) { + // For first loop in function, allocate syntax for any, bool, int, true, and false. + if r.any == nil { + r.any = types2.Universe.Lookup("any") + r.bool = types2.Universe.Lookup("bool") + r.int = types2.Universe.Lookup("int") + r.true = types2.Universe.Lookup("true") + r.false = types2.Universe.Lookup("false") + r.rewritten = make(map[*syntax.ForStmt]syntax.Stmt) + } + if r.checkFuncMisuse() { + // declare the state flag for this loop's body + loop.stateVar, loop.stateVarDecl = r.stateVar(loop.nfor.Pos()) + } +} + +// editStmt returns the replacement for the statement x, +// or x itself if it should be left alone. +// This includes the for loops we are converting, +// as left in x.rewritten by r.endLoop. +func (r *rewriter) editStmt(x syntax.Stmt) syntax.Stmt { + if x, ok := x.(*syntax.ForStmt); ok { + if s := r.rewritten[x]; s != nil { + return s + } + } + + if len(r.forStack) > 0 { + switch x := x.(type) { + case *syntax.BranchStmt: + return r.editBranch(x) + case *syntax.CallStmt: + if x.Tok == syntax.Defer { + return r.editDefer(x) + } + case *syntax.ReturnStmt: + return r.editReturn(x) + } + } + + return x +} + +// editDefer returns the replacement for the defer statement x. +// See the "Defers" section in the package doc comment above for more context. +func (r *rewriter) editDefer(x *syntax.CallStmt) syntax.Stmt { + if r.defers == nil { + // Declare and initialize the #defers token. + init := &syntax.CallExpr{ + Fun: runtimeSym(r.info, "deferrangefunc"), + } + tv := syntax.TypeAndValue{Type: r.any.Type()} + tv.SetIsValue() + init.SetTypeInfo(tv) + r.defers = r.declOuterVar("#defers", r.any.Type(), init) + } + + // Attach the token as an "extra" argument to the defer. + x.DeferAt = r.useObj(r.defers) + setPos(x.DeferAt, x.Pos()) + return x +} + +func (r *rewriter) stateVar(pos syntax.Pos) (*types2.Var, *syntax.VarDecl) { + r.stateVarCount++ + + name := fmt.Sprintf("#state%d", r.stateVarCount) + typ := r.int.Type() + obj := types2.NewVar(pos, r.pkg, name, typ) + n := syntax.NewName(pos, name) + setValueType(n, typ) + r.info.Defs[n] = obj + + return obj, &syntax.VarDecl{NameList: []*syntax.Name{n}, Values: r.stateConst(abi.RF_READY)} +} + +// editReturn returns the replacement for the return statement x. +// See the "Return" section in the package doc comment above for more context. +func (r *rewriter) editReturn(x *syntax.ReturnStmt) syntax.Stmt { + bl := &syntax.BlockStmt{} + + if x.Results != nil { + // rewrite "return val" into "assign to named result; return" + if len(r.outer.ResultList) > 0 { + // Make sure that result parameters all have names + for i, a := range r.outer.ResultList { + if a.Name == nil || a.Name.Value == "_" { + r.generateParamName(r.outer.ResultList, i) // updates a.Name + } + } + } + // Assign to named results + results := []types2.Object{} + for _, a := range r.outer.ResultList { + results = append(results, r.info.Defs[a.Name]) + } + bl.List = append(bl.List, &syntax.AssignStmt{Lhs: r.useList(results), Rhs: x.Results}) + x.Results = nil + } + + next := -1 // return + + // Tell the loops along the way to check for a return. + for _, loop := range r.forStack { + loop.checkRet = true + } + + // Set #next, and return false. + + bl.List = append(bl.List, &syntax.AssignStmt{Lhs: r.next(), Rhs: r.intConst(next)}) + if r.checkFuncMisuse() { + // mark this loop as exited, the others (which will be exited if iterators do not interfere) have not, yet. + bl.List = append(bl.List, r.setState(abi.RF_DONE, x.Pos())) + } + bl.List = append(bl.List, &syntax.ReturnStmt{Results: r.useObj(r.false)}) + setPos(bl, x.Pos()) + return bl +} + +// perLoopStep is part of the encoding of loop-spanning control flow +// for function range iterators. Each multiple of two encodes a "return false" +// passing control to an enclosing iterator; a terminal value of 1 encodes +// "return true" (i.e., local continue) from the body function, and a terminal +// value of 0 encodes executing the remainder of the body function. +const perLoopStep = 2 + +// editBranch returns the replacement for the branch statement x, +// or x itself if it should be left alone. +// See the package doc comment above for more context. +func (r *rewriter) editBranch(x *syntax.BranchStmt) syntax.Stmt { + if x.Tok == syntax.Fallthrough { + // Fallthrough is unaffected by the rewrite. + return x + } + + // Find target of break/continue/goto in r.forStack. + // (The target may not be in r.forStack at all.) + targ := x.Target + i := len(r.forStack) - 1 + if x.Label == nil && r.forStack[i].nfor != targ { + // Unlabeled break or continue that's not nfor must be inside nfor. Leave alone. + return x + } + for i >= 0 && r.forStack[i].nfor != targ { + i-- + } + // exitFrom is the index of the loop interior to the target of the control flow, + // if such a loop exists (it does not if i == len(r.forStack) - 1) + exitFrom := i + 1 + + // Compute the value to assign to #next and the specific return to use. + var next int + var ret *syntax.ReturnStmt + if x.Tok == syntax.Goto || i < 0 { + // goto Label + // or break/continue of labeled non-range-over-func loop (x.Label != nil). + // We may be able to leave it alone, or we may have to break + // out of one or more nested loops and then use #next to signal + // to complete the break/continue/goto. + // Figure out which range-over-func loop contains the label. + r.computeBranchNext() + nfor := r.forStack[len(r.forStack)-1].nfor + label := x.Label.Value + targ := r.labelLoop[label] + if nfor == targ { + // Label is in the innermost range-over-func loop; use it directly. + return x + } + + // Set #next to the code meaning break/continue/goto label. + next = r.branchNext[branch{x.Tok, label}] + + // Break out of nested loops up to targ. + i := len(r.forStack) - 1 + for i >= 0 && r.forStack[i].nfor != targ { + i-- + } + exitFrom = i + 1 + + // Mark loop we exit to get to targ to check for that branch. + // When i==-1 / exitFrom == 0 that's the outermost func body. + top := r.forStack[exitFrom] + top.checkBranch = append(top.checkBranch, branch{x.Tok, label}) + + // Mark loops along the way to check for a plain return, so they break. + for j := exitFrom + 1; j < len(r.forStack); j++ { + r.forStack[j].checkRet = true + } + + // In the innermost loop, use a plain "return false". + ret = &syntax.ReturnStmt{Results: r.useObj(r.false)} + } else { + // break/continue of labeled range-over-func loop. + if exitFrom == len(r.forStack) { + // Simple break or continue. + // Continue returns true, break returns false, optionally both adjust state, + // neither modifies #next. + var state abi.RF_State + if x.Tok == syntax.Continue { + ret = &syntax.ReturnStmt{Results: r.useObj(r.true)} + state = abi.RF_READY + } else { + ret = &syntax.ReturnStmt{Results: r.useObj(r.false)} + state = abi.RF_DONE + } + var stmts []syntax.Stmt + if r.checkFuncMisuse() { + stmts = []syntax.Stmt{r.setState(state, x.Pos()), ret} + } else { + stmts = []syntax.Stmt{ret} + } + bl := &syntax.BlockStmt{ + List: stmts, + } + setPos(bl, x.Pos()) + return bl + } + + ret = &syntax.ReturnStmt{Results: r.useObj(r.false)} + + // The loop inside the one we are break/continue-ing + // needs to make that happen when we break out of it. + if x.Tok == syntax.Continue { + r.forStack[exitFrom].checkContinue = true + } else { + exitFrom = i // exitFrom-- + r.forStack[exitFrom].checkBreak = true + } + + // The loops along the way just need to break. + for j := exitFrom + 1; j < len(r.forStack); j++ { + r.forStack[j].checkBreak = true + } + + // Set next to break the appropriate number of times; + // the final time may be a continue, not a break. + next = perLoopStep * (i + 1) + if x.Tok == syntax.Continue { + next-- + } + } + + // Assign #next = next and do the return. + as := &syntax.AssignStmt{Lhs: r.next(), Rhs: r.intConst(next)} + bl := &syntax.BlockStmt{ + List: []syntax.Stmt{as}, + } + + if r.checkFuncMisuse() { + // Set #stateK for this loop. + // The exterior loops have not exited yet, and the iterator might interfere. + bl.List = append(bl.List, r.setState(abi.RF_DONE, x.Pos())) + } + + bl.List = append(bl.List, ret) + setPos(bl, x.Pos()) + return bl +} + +// computeBranchNext computes the branchNext numbering +// and determines which labels end up inside which range-over-func loop bodies. +func (r *rewriter) computeBranchNext() { + if r.labelLoop != nil { + return + } + + r.labelLoop = make(map[string]*syntax.ForStmt) + r.branchNext = make(map[branch]int) + + var labels []string + var stack []syntax.Node + var forStack []*syntax.ForStmt + forStack = append(forStack, nil) + syntax.Inspect(r.body, func(n syntax.Node) bool { + if n != nil { + stack = append(stack, n) + if nfor, ok := forRangeFunc(n); ok { + forStack = append(forStack, nfor) + } + if n, ok := n.(*syntax.LabeledStmt); ok { + l := n.Label.Value + labels = append(labels, l) + f := forStack[len(forStack)-1] + r.labelLoop[l] = f + } + } else { + n := stack[len(stack)-1] + stack = stack[:len(stack)-1] + if n == forStack[len(forStack)-1] { + forStack = forStack[:len(forStack)-1] + } + } + return true + }) + + // Assign numbers to all the labels we observed. + used := -1 // returns use -1 + for _, l := range labels { + used -= 3 + r.branchNext[branch{syntax.Break, l}] = used + r.branchNext[branch{syntax.Continue, l}] = used + 1 + r.branchNext[branch{syntax.Goto, l}] = used + 2 + } +} + +// endLoop finishes the conversion of a range-over-func loop. +// We have inspected and rewritten the body of the loop and can now +// construct the body function and rewrite the for loop into a call +// bracketed by any declarations and checks it requires. +func (r *rewriter) endLoop(loop *forLoop) { + // Pick apart for range X { ... } + nfor := loop.nfor + start, end := nfor.Pos(), nfor.Body.Rbrace // start, end position of for loop + rclause := nfor.Init.(*syntax.RangeClause) + rfunc := types2.CoreType(rclause.X.GetTypeInfo().Type).(*types2.Signature) // type of X - func(func(...)bool) + if rfunc.Params().Len() != 1 { + base.Fatalf("invalid typecheck of range func") + } + ftyp := types2.CoreType(rfunc.Params().At(0).Type()).(*types2.Signature) // func(...) bool + if ftyp.Results().Len() != 1 { + base.Fatalf("invalid typecheck of range func") + } + + // Give the closure generated for the body a name, to help the debugger connect it to its frame, if active. + r.bodyClosureCount++ + clo := r.bodyFunc(nfor.Body.List, syntax.UnpackListExpr(rclause.Lhs), rclause.Def, ftyp, start, end) + cloDecl, cloVar := r.declSingleVar(fmt.Sprintf("#yield%d", r.bodyClosureCount), clo.GetTypeInfo().Type, clo) + setPos(cloDecl, start) + + // Build X(bodyFunc) + call := &syntax.ExprStmt{ + X: &syntax.CallExpr{ + Fun: rclause.X, + ArgList: []syntax.Expr{ + r.useObj(cloVar), + }, + }, + } + setPos(call, start) + + // Build checks based on #next after X(bodyFunc) + checks := r.checks(loop, end) + + // Rewrite for vars := range X { ... } to + // + // { + // r.declStmt + // call + // checks + // } + // + // The r.declStmt can be added to by this loop or any inner loop + // during the creation of r.bodyFunc; it is only emitted in the outermost + // converted range loop. + block := &syntax.BlockStmt{Rbrace: end} + setPos(block, start) + if len(r.forStack) == 1 && r.declStmt != nil { + setPos(r.declStmt, start) + block.List = append(block.List, r.declStmt) + } + + // declare the state variable here so it has proper scope and initialization + if r.checkFuncMisuse() { + stateVarDecl := &syntax.DeclStmt{DeclList: []syntax.Decl{loop.stateVarDecl}} + setPos(stateVarDecl, start) + block.List = append(block.List, stateVarDecl) + } + + // iteratorFunc(bodyFunc) + block.List = append(block.List, cloDecl, call) + + if r.checkFuncMisuse() { + // iteratorFunc has exited, check for swallowed panic, and set body state to abi.RF_EXHAUSTED + nif := &syntax.IfStmt{ + Cond: r.cond(syntax.Eql, r.useObj(loop.stateVar), r.stateConst(abi.RF_PANIC)), + Then: &syntax.BlockStmt{ + List: []syntax.Stmt{r.callPanic(start, r.stateConst(abi.RF_MISSING_PANIC))}, + }, + } + setPos(nif, end) + block.List = append(block.List, nif) + block.List = append(block.List, r.setState(abi.RF_EXHAUSTED, end)) + } + block.List = append(block.List, checks...) + + if len(r.forStack) == 1 { // ending an outermost loop + r.declStmt = nil + r.nextVar = nil + r.defers = nil + } + + r.rewritten[nfor] = block +} + +func (r *rewriter) cond(op syntax.Operator, x, y syntax.Expr) *syntax.Operation { + cond := &syntax.Operation{Op: op, X: x, Y: y} + tv := syntax.TypeAndValue{Type: r.bool.Type()} + tv.SetIsValue() + cond.SetTypeInfo(tv) + return cond +} + +func (r *rewriter) setState(val abi.RF_State, pos syntax.Pos) *syntax.AssignStmt { + ss := r.setStateAt(len(r.forStack)-1, val) + setPos(ss, pos) + return ss +} + +func (r *rewriter) setStateAt(index int, stateVal abi.RF_State) *syntax.AssignStmt { + loop := r.forStack[index] + return &syntax.AssignStmt{ + Lhs: r.useObj(loop.stateVar), + Rhs: r.stateConst(stateVal), + } +} + +// bodyFunc converts the loop body (control flow has already been updated) +// to a func literal that can be passed to the range function. +// +// vars is the range variables from the range statement. +// def indicates whether this is a := range statement. +// ftyp is the type of the function we are creating +// start and end are the syntax positions to use for new nodes +// that should be at the start or end of the loop. +func (r *rewriter) bodyFunc(body []syntax.Stmt, lhs []syntax.Expr, def bool, ftyp *types2.Signature, start, end syntax.Pos) *syntax.FuncLit { + // Starting X(bodyFunc); build up bodyFunc first. + var params, results []*types2.Var + results = append(results, types2.NewVar(start, nil, "#r", r.bool.Type())) + bodyFunc := &syntax.FuncLit{ + // Note: Type is ignored but needs to be non-nil to avoid panic in syntax.Inspect. + Type: &syntax.FuncType{}, + Body: &syntax.BlockStmt{ + List: []syntax.Stmt{}, + Rbrace: end, + }, + } + r.rangefuncBodyClosures[bodyFunc] = true + setPos(bodyFunc, start) + + for i := 0; i < ftyp.Params().Len(); i++ { + typ := ftyp.Params().At(i).Type() + var paramVar *types2.Var + if i < len(lhs) && def { + // Reuse range variable as parameter. + x := lhs[i] + paramVar = r.info.Defs[x.(*syntax.Name)].(*types2.Var) + } else { + // Declare new parameter and assign it to range expression. + paramVar = types2.NewVar(start, r.pkg, fmt.Sprintf("#p%d", 1+i), typ) + if i < len(lhs) { + x := lhs[i] + as := &syntax.AssignStmt{Lhs: x, Rhs: r.useObj(paramVar)} + as.SetPos(x.Pos()) + setPos(as.Rhs, x.Pos()) + bodyFunc.Body.List = append(bodyFunc.Body.List, as) + } + } + params = append(params, paramVar) + } + + tv := syntax.TypeAndValue{ + Type: types2.NewSignatureType(nil, nil, nil, + types2.NewTuple(params...), + types2.NewTuple(results...), + false), + } + tv.SetIsValue() + bodyFunc.SetTypeInfo(tv) + + loop := r.forStack[len(r.forStack)-1] + + if r.checkFuncMisuse() { + // #tmpState := #stateVarN + // #stateVarN = abi.RF_PANIC + // if #tmpState != abi.RF_READY { + // runtime.panicrangestate(#tmpState) + // } + // + // That is a slightly code-size-optimized version of + // + // if #stateVarN != abi.RF_READY { + // #stateVarN = abi.RF_PANIC // If we ever need to specially detect "iterator swallowed checking panic" we put a different value here. + // runtime.panicrangestate(#tmpState) + // } + // #stateVarN = abi.RF_PANIC + // + + tmpDecl, tmpState := r.declSingleVar("#tmpState", r.int.Type(), r.useObj(loop.stateVar)) + bodyFunc.Body.List = append(bodyFunc.Body.List, tmpDecl) + bodyFunc.Body.List = append(bodyFunc.Body.List, r.setState(abi.RF_PANIC, start)) + bodyFunc.Body.List = append(bodyFunc.Body.List, r.assertReady(start, tmpState)) + } + + // Original loop body (already rewritten by editStmt during inspect). + bodyFunc.Body.List = append(bodyFunc.Body.List, body...) + + // end of loop body, set state to abi.RF_READY and return true to continue iteration + if r.checkFuncMisuse() { + bodyFunc.Body.List = append(bodyFunc.Body.List, r.setState(abi.RF_READY, end)) + } + ret := &syntax.ReturnStmt{Results: r.useObj(r.true)} + ret.SetPos(end) + bodyFunc.Body.List = append(bodyFunc.Body.List, ret) + + return bodyFunc +} + +// checks returns the post-call checks that need to be done for the given loop. +func (r *rewriter) checks(loop *forLoop, pos syntax.Pos) []syntax.Stmt { + var list []syntax.Stmt + if len(loop.checkBranch) > 0 { + did := make(map[branch]bool) + for _, br := range loop.checkBranch { + if did[br] { + continue + } + did[br] = true + doBranch := &syntax.BranchStmt{Tok: br.tok, Label: &syntax.Name{Value: br.label}} + list = append(list, r.ifNext(syntax.Eql, r.branchNext[br], true, doBranch)) + } + } + + curLoop := loop.depth - 1 + curLoopIndex := curLoop - 1 + + if len(r.forStack) == 1 { + if loop.checkRet { + list = append(list, r.ifNext(syntax.Eql, -1, false, retStmt(nil))) + } + } else { + + // Idealized check, implemented more simply for now. + + // // N == depth of this loop, one less than the one just exited. + // if #next != 0 { + // if #next >= perLoopStep*N-1 { // this loop + // if #next >= perLoopStep*N+1 { // error checking + // runtime.panicrangestate(abi.RF_DONE) + // } + // rv := #next & 1 == 1 // code generates into #next&1 + // #next = 0 + // return rv + // } + // return false // or handle returns and gotos + // } + + if loop.checkRet { + // Note: next < 0 also handles gotos handled by outer loops. + // We set checkRet in that case to trigger this check. + if r.checkFuncMisuse() { + list = append(list, r.ifNext(syntax.Lss, 0, false, r.setStateAt(curLoopIndex, abi.RF_DONE), retStmt(r.useObj(r.false)))) + } else { + list = append(list, r.ifNext(syntax.Lss, 0, false, retStmt(r.useObj(r.false)))) + } + } + + depthStep := perLoopStep * (curLoop) + + if r.checkFuncMisuse() { + list = append(list, r.ifNext(syntax.Gtr, depthStep, false, r.callPanic(pos, r.stateConst(abi.RF_DONE)))) + } else { + list = append(list, r.ifNext(syntax.Gtr, depthStep, true)) + } + + if r.checkFuncMisuse() { + if loop.checkContinue { + list = append(list, r.ifNext(syntax.Eql, depthStep-1, true, r.setStateAt(curLoopIndex, abi.RF_READY), retStmt(r.useObj(r.true)))) + } + + if loop.checkBreak { + list = append(list, r.ifNext(syntax.Eql, depthStep, true, r.setStateAt(curLoopIndex, abi.RF_DONE), retStmt(r.useObj(r.false)))) + } + + if loop.checkContinue || loop.checkBreak { + list = append(list, r.ifNext(syntax.Gtr, 0, false, r.setStateAt(curLoopIndex, abi.RF_DONE), retStmt(r.useObj(r.false)))) + } + + } else { + if loop.checkContinue { + list = append(list, r.ifNext(syntax.Eql, depthStep-1, true, retStmt(r.useObj(r.true)))) + } + if loop.checkBreak { + list = append(list, r.ifNext(syntax.Eql, depthStep, true, retStmt(r.useObj(r.false)))) + } + if loop.checkContinue || loop.checkBreak { + list = append(list, r.ifNext(syntax.Gtr, 0, false, retStmt(r.useObj(r.false)))) + } + } + } + + for _, j := range list { + setPos(j, pos) + } + return list +} + +// retStmt returns a return statement returning the given return values. +func retStmt(results syntax.Expr) *syntax.ReturnStmt { + return &syntax.ReturnStmt{Results: results} +} + +// ifNext returns the statement: +// +// if #next op c { [#next = 0;] thens... } +func (r *rewriter) ifNext(op syntax.Operator, c int, zeroNext bool, thens ...syntax.Stmt) syntax.Stmt { + var thenList []syntax.Stmt + if zeroNext { + clr := &syntax.AssignStmt{ + Lhs: r.next(), + Rhs: r.intConst(0), + } + thenList = append(thenList, clr) + } + for _, then := range thens { + thenList = append(thenList, then) + } + nif := &syntax.IfStmt{ + Cond: r.cond(op, r.next(), r.intConst(c)), + Then: &syntax.BlockStmt{ + List: thenList, + }, + } + return nif +} + +// setValueType marks x as a value with type typ. +func setValueType(x syntax.Expr, typ syntax.Type) { + tv := syntax.TypeAndValue{Type: typ} + tv.SetIsValue() + x.SetTypeInfo(tv) +} + +// assertReady returns the statement: +// +// if #tmpState != abi.RF_READY { runtime.panicrangestate(#tmpState) } +func (r *rewriter) assertReady(start syntax.Pos, tmpState *types2.Var) syntax.Stmt { + + nif := &syntax.IfStmt{ + Cond: r.cond(syntax.Neq, r.useObj(tmpState), r.stateConst(abi.RF_READY)), + Then: &syntax.BlockStmt{ + List: []syntax.Stmt{ + r.callPanic(start, r.useObj(tmpState))}, + }, + } + setPos(nif, start) + return nif +} + +func (r *rewriter) callPanic(start syntax.Pos, arg syntax.Expr) syntax.Stmt { + callPanicExpr := &syntax.CallExpr{ + Fun: runtimeSym(r.info, "panicrangestate"), + ArgList: []syntax.Expr{arg}, + } + setValueType(callPanicExpr, nil) // no result type + return &syntax.ExprStmt{X: callPanicExpr} +} + +// next returns a reference to the #next variable. +func (r *rewriter) next() *syntax.Name { + if r.nextVar == nil { + r.nextVar = r.declOuterVar("#next", r.int.Type(), nil) + } + return r.useObj(r.nextVar) +} + +// forRangeFunc checks whether n is a range-over-func. +// If so, it returns n.(*syntax.ForStmt), true. +// Otherwise it returns nil, false. +func forRangeFunc(n syntax.Node) (*syntax.ForStmt, bool) { + nfor, ok := n.(*syntax.ForStmt) + if !ok { + return nil, false + } + nrange, ok := nfor.Init.(*syntax.RangeClause) + if !ok { + return nil, false + } + _, ok = types2.CoreType(nrange.X.GetTypeInfo().Type).(*types2.Signature) + if !ok { + return nil, false + } + return nfor, true +} + +// intConst returns syntax for an integer literal with the given value. +func (r *rewriter) intConst(c int) *syntax.BasicLit { + lit := &syntax.BasicLit{ + Value: fmt.Sprint(c), + Kind: syntax.IntLit, + } + tv := syntax.TypeAndValue{Type: r.int.Type(), Value: constant.MakeInt64(int64(c))} + tv.SetIsValue() + lit.SetTypeInfo(tv) + return lit +} + +func (r *rewriter) stateConst(s abi.RF_State) *syntax.BasicLit { + return r.intConst(int(s)) +} + +// useObj returns syntax for a reference to decl, which should be its declaration. +func (r *rewriter) useObj(obj types2.Object) *syntax.Name { + n := syntax.NewName(nopos, obj.Name()) + tv := syntax.TypeAndValue{Type: obj.Type()} + tv.SetIsValue() + n.SetTypeInfo(tv) + r.info.Uses[n] = obj + return n +} + +// useList is useVar for a list of decls. +func (r *rewriter) useList(vars []types2.Object) syntax.Expr { + var new []syntax.Expr + for _, obj := range vars { + new = append(new, r.useObj(obj)) + } + if len(new) == 1 { + return new[0] + } + return &syntax.ListExpr{ElemList: new} +} + +func (r *rewriter) makeVarName(pos syntax.Pos, name string, typ types2.Type) (*types2.Var, *syntax.Name) { + obj := types2.NewVar(pos, r.pkg, name, typ) + n := syntax.NewName(pos, name) + tv := syntax.TypeAndValue{Type: typ} + tv.SetIsValue() + n.SetTypeInfo(tv) + r.info.Defs[n] = obj + return obj, n +} + +func (r *rewriter) generateParamName(results []*syntax.Field, i int) { + obj, n := r.sig.RenameResult(results, i) + r.info.Defs[n] = obj +} + +// declOuterVar declares a variable with a given name, type, and initializer value, +// in the same scope as the outermost loop in a loop nest. +func (r *rewriter) declOuterVar(name string, typ types2.Type, init syntax.Expr) *types2.Var { + if r.declStmt == nil { + r.declStmt = &syntax.DeclStmt{} + } + stmt := r.declStmt + obj, n := r.makeVarName(stmt.Pos(), name, typ) + stmt.DeclList = append(stmt.DeclList, &syntax.VarDecl{ + NameList: []*syntax.Name{n}, + // Note: Type is ignored + Values: init, + }) + return obj +} + +// declSingleVar declares a variable with a given name, type, and initializer value, +// and returns both the declaration and variable, so that the declaration can be placed +// in a specific scope. +func (r *rewriter) declSingleVar(name string, typ types2.Type, init syntax.Expr) (*syntax.DeclStmt, *types2.Var) { + stmt := &syntax.DeclStmt{} + obj, n := r.makeVarName(stmt.Pos(), name, typ) + stmt.DeclList = append(stmt.DeclList, &syntax.VarDecl{ + NameList: []*syntax.Name{n}, + // Note: Type is ignored + Values: init, + }) + return stmt, obj +} + +// runtimePkg is a fake runtime package that contains what we need to refer to in package runtime. +var runtimePkg = func() *types2.Package { + var nopos syntax.Pos + pkg := types2.NewPackage("runtime", "runtime") + anyType := types2.Universe.Lookup("any").Type() + intType := types2.Universe.Lookup("int").Type() + + // func deferrangefunc() unsafe.Pointer + obj := types2.NewFunc(nopos, pkg, "deferrangefunc", types2.NewSignatureType(nil, nil, nil, nil, types2.NewTuple(types2.NewParam(nopos, pkg, "extra", anyType)), false)) + pkg.Scope().Insert(obj) + + // func panicrangestate() + obj = types2.NewFunc(nopos, pkg, "panicrangestate", types2.NewSignatureType(nil, nil, nil, types2.NewTuple(types2.NewParam(nopos, pkg, "state", intType)), nil, false)) + pkg.Scope().Insert(obj) + + return pkg +}() + +// runtimeSym returns a reference to a symbol in the fake runtime package. +func runtimeSym(info *types2.Info, name string) *syntax.Name { + obj := runtimePkg.Scope().Lookup(name) + n := syntax.NewName(nopos, "runtime."+name) + tv := syntax.TypeAndValue{Type: obj.Type()} + tv.SetIsValue() + tv.SetIsRuntimeHelper() + n.SetTypeInfo(tv) + info.Uses[n] = obj + return n +} + +// setPos walks the top structure of x that has no position assigned +// and assigns it all to have position pos. +// When setPos encounters a syntax node with a position assigned, +// setPos does not look inside that node. +// setPos only needs to handle syntax we create in this package; +// all other syntax should have positions assigned already. +func setPos(x syntax.Node, pos syntax.Pos) { + if x == nil { + return + } + syntax.Inspect(x, func(n syntax.Node) bool { + if n == nil || n.Pos() != nopos { + return false + } + n.SetPos(pos) + switch n := n.(type) { + case *syntax.BlockStmt: + if n.Rbrace == nopos { + n.Rbrace = pos + } + } + return true + }) +} diff --git a/go/src/cmd/compile/internal/reflectdata/alg.go b/go/src/cmd/compile/internal/reflectdata/alg.go new file mode 100644 index 0000000000000000000000000000000000000000..7cc50d866f2740b64df9ef2f3e47b9b9f17014a6 --- /dev/null +++ b/go/src/cmd/compile/internal/reflectdata/alg.go @@ -0,0 +1,667 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package reflectdata + +import ( + "fmt" + + "cmd/compile/internal/base" + "cmd/compile/internal/compare" + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" +) + +// AlgType returns the fixed-width AMEMxx variants instead of the general +// AMEM kind when possible. +func AlgType(t *types.Type) types.AlgKind { + a := types.AlgType(t) + if a == types.AMEM { + if t.Alignment() < int64(base.Ctxt.Arch.Alignment) && t.Alignment() < t.Size() { + // For example, we can't treat [2]int16 as an int32 if int32s require + // 4-byte alignment. See issue 46283. + return a + } + switch t.Size() { + case 0: + return types.AMEM0 + case 1: + return types.AMEM8 + case 2: + return types.AMEM16 + case 4: + return types.AMEM32 + case 8: + return types.AMEM64 + case 16: + return types.AMEM128 + } + } + + return a +} + +// genhash returns a symbol which is the closure used to compute +// the hash of a value of type t. +// Note: the generated function must match runtime.typehash exactly. +func genhash(t *types.Type) *obj.LSym { + switch AlgType(t) { + default: + // genhash is only called for types that have equality + base.Fatalf("genhash %v", t) + case types.AMEM0: + return sysClosure("memhash0") + case types.AMEM8: + return sysClosure("memhash8") + case types.AMEM16: + return sysClosure("memhash16") + case types.AMEM32: + return sysClosure("memhash32") + case types.AMEM64: + return sysClosure("memhash64") + case types.AMEM128: + return sysClosure("memhash128") + case types.ASTRING: + return sysClosure("strhash") + case types.AINTER: + return sysClosure("interhash") + case types.ANILINTER: + return sysClosure("nilinterhash") + case types.AFLOAT32: + return sysClosure("f32hash") + case types.AFLOAT64: + return sysClosure("f64hash") + case types.ACPLX64: + return sysClosure("c64hash") + case types.ACPLX128: + return sysClosure("c128hash") + case types.AMEM: + // For other sizes of plain memory, we build a closure + // that calls memhash_varlen. The size of the memory is + // encoded in the first slot of the closure. + closure := TypeLinksymLookup(fmt.Sprintf(".hashfunc%d", t.Size())) + if len(closure.P) > 0 { // already generated + return closure + } + if memhashvarlen == nil { + memhashvarlen = typecheck.LookupRuntimeFunc("memhash_varlen") + } + ot := 0 + ot = objw.SymPtr(closure, ot, memhashvarlen, 0) + ot = objw.Uintptr(closure, ot, uint64(t.Size())) // size encoded in closure + objw.Global(closure, int32(ot), obj.DUPOK|obj.RODATA) + return closure + case types.ASPECIAL: + break + } + + closure := TypeLinksymPrefix(".hashfunc", t) + if len(closure.P) > 0 { // already generated + return closure + } + + // Generate hash functions for subtypes. + // There are cases where we might not use these hashes, + // but in that case they will get dead-code eliminated. + // (And the closure generated by genhash will also get + // dead-code eliminated, as we call the subtype hashers + // directly.) + switch t.Kind() { + case types.TARRAY: + genhash(t.Elem()) + case types.TSTRUCT: + for _, f := range t.Fields() { + genhash(f.Type) + } + } + + if base.Flag.LowerR != 0 { + fmt.Printf("genhash %v %v\n", closure, t) + } + + fn := hashFunc(t) + + // Build closure. It doesn't close over any variables, so + // it contains just the function pointer. + objw.SymPtr(closure, 0, fn.Linksym(), 0) + objw.Global(closure, int32(types.PtrSize), obj.DUPOK|obj.RODATA) + + return closure +} + +func hashFunc(t *types.Type) *ir.Func { + sym := TypeSymPrefix(".hash", t) + if sym.Def != nil { + return sym.Def.(*ir.Name).Func + } + + pos := base.AutogeneratedPos // less confusing than end of input + base.Pos = pos + + // func sym(p *T, h uintptr) uintptr + fn := ir.NewFunc(pos, pos, sym, types.NewSignature(nil, + []*types.Field{ + types.NewField(pos, typecheck.Lookup("p"), types.NewPtr(t)), + types.NewField(pos, typecheck.Lookup("h"), types.Types[types.TUINTPTR]), + }, + []*types.Field{ + types.NewField(pos, nil, types.Types[types.TUINTPTR]), + }, + )) + sym.Def = fn.Nname + fn.Pragma |= ir.Noinline // TODO(mdempsky): We need to emit this during the unified frontend instead, to allow inlining. + + typecheck.DeclFunc(fn) + np := fn.Dcl[0] + nh := fn.Dcl[1] + + switch t.Kind() { + case types.TARRAY: + // An array of pure memory would be handled by the + // standard algorithm, so the element type must not be + // pure memory. + hashel := hashfor(t.Elem()) + + // for i := 0; i < nelem; i++ + ni := typecheck.TempAt(base.Pos, ir.CurFunc, types.Types[types.TINT]) + init := ir.NewAssignStmt(base.Pos, ni, ir.NewInt(base.Pos, 0)) + cond := ir.NewBinaryExpr(base.Pos, ir.OLT, ni, ir.NewInt(base.Pos, t.NumElem())) + post := ir.NewAssignStmt(base.Pos, ni, ir.NewBinaryExpr(base.Pos, ir.OADD, ni, ir.NewInt(base.Pos, 1))) + loop := ir.NewForStmt(base.Pos, nil, cond, post, nil, false) + loop.PtrInit().Append(init) + + // h = hashel(&p[i], h) + call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil) + + nx := ir.NewIndexExpr(base.Pos, np, ni) + nx.SetBounded(true) + na := typecheck.NodAddr(nx) + call.Args.Append(na) + call.Args.Append(nh) + loop.Body.Append(ir.NewAssignStmt(base.Pos, nh, call)) + + fn.Body.Append(loop) + + case types.TSTRUCT: + // Walk the struct using memhash for runs of AMEM + // and calling specific hash functions for the others. + for i, fields := 0, t.Fields(); i < len(fields); { + f := fields[i] + + // Skip blank fields. + if f.Sym.IsBlank() { + i++ + continue + } + + // Hash non-memory fields with appropriate hash function. + if !compare.IsRegularMemory(f.Type) { + hashel := hashfor(f.Type) + call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil) + na := typecheck.NodAddr(typecheck.DotField(base.Pos, np, i)) + call.Args.Append(na) + call.Args.Append(nh) + fn.Body.Append(ir.NewAssignStmt(base.Pos, nh, call)) + i++ + continue + } + + // Otherwise, hash a maximal length run of raw memory. + size, next := compare.Memrun(t, i) + + // h = hashel(&p.first, size, h) + hashel := hashmem(f.Type) + call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil) + na := typecheck.NodAddr(typecheck.DotField(base.Pos, np, i)) + call.Args.Append(na) + call.Args.Append(nh) + call.Args.Append(ir.NewInt(base.Pos, size)) + fn.Body.Append(ir.NewAssignStmt(base.Pos, nh, call)) + + i = next + } + } + + r := ir.NewReturnStmt(base.Pos, nil) + r.Results.Append(nh) + fn.Body.Append(r) + + if base.Flag.LowerR != 0 { + ir.DumpList("genhash body", fn.Body) + } + + typecheck.FinishFuncBody() + + fn.SetDupok(true) + + ir.WithFunc(fn, func() { + typecheck.Stmts(fn.Body) + }) + + fn.SetNilCheckDisabled(true) + + return fn +} + +func runtimeHashFor(name string, t *types.Type) *ir.Name { + return typecheck.LookupRuntime(name, t) +} + +// hashfor returns the function to compute the hash of a value of type t. +func hashfor(t *types.Type) *ir.Name { + switch types.AlgType(t) { + case types.AMEM: + base.Fatalf("hashfor with AMEM type") + case types.AINTER: + return runtimeHashFor("interhash", t) + case types.ANILINTER: + return runtimeHashFor("nilinterhash", t) + case types.ASTRING: + return runtimeHashFor("strhash", t) + case types.AFLOAT32: + return runtimeHashFor("f32hash", t) + case types.AFLOAT64: + return runtimeHashFor("f64hash", t) + case types.ACPLX64: + return runtimeHashFor("c64hash", t) + case types.ACPLX128: + return runtimeHashFor("c128hash", t) + } + + fn := hashFunc(t) + return fn.Nname +} + +// sysClosure returns a closure which will call the +// given runtime function (with no closed-over variables). +func sysClosure(name string) *obj.LSym { + s := typecheck.LookupRuntimeVar(name + "·f") + if len(s.P) == 0 { + f := typecheck.LookupRuntimeFunc(name) + objw.SymPtr(s, 0, f, 0) + objw.Global(s, int32(types.PtrSize), obj.DUPOK|obj.RODATA) + } + return s +} + +// geneq returns a symbol which is the closure used to compute +// equality for two objects of type t. +func geneq(t *types.Type) *obj.LSym { + switch AlgType(t) { + case types.ANOEQ, types.ANOALG: + // The runtime will panic if it tries to compare + // a type with a nil equality function. + return nil + case types.AMEM0: + return sysClosure("memequal0") + case types.AMEM8: + return sysClosure("memequal8") + case types.AMEM16: + return sysClosure("memequal16") + case types.AMEM32: + return sysClosure("memequal32") + case types.AMEM64: + return sysClosure("memequal64") + case types.AMEM128: + return sysClosure("memequal128") + case types.ASTRING: + return sysClosure("strequal") + case types.AINTER: + return sysClosure("interequal") + case types.ANILINTER: + return sysClosure("nilinterequal") + case types.AFLOAT32: + return sysClosure("f32equal") + case types.AFLOAT64: + return sysClosure("f64equal") + case types.ACPLX64: + return sysClosure("c64equal") + case types.ACPLX128: + return sysClosure("c128equal") + case types.AMEM: + // make equality closure. The size of the type + // is encoded in the closure. + closure := TypeLinksymLookup(fmt.Sprintf(".eqfunc%d", t.Size())) + if len(closure.P) != 0 { + return closure + } + if memequalvarlen == nil { + memequalvarlen = typecheck.LookupRuntimeFunc("memequal_varlen") + } + ot := 0 + ot = objw.SymPtr(closure, ot, memequalvarlen, 0) + ot = objw.Uintptr(closure, ot, uint64(t.Size())) + objw.Global(closure, int32(ot), obj.DUPOK|obj.RODATA) + return closure + case types.ASPECIAL: + break + } + + closure := TypeLinksymPrefix(".eqfunc", t) + if len(closure.P) > 0 { // already generated + return closure + } + + if base.Flag.LowerR != 0 { + fmt.Printf("geneq %v\n", t) + } + + fn := eqFunc(t) + + // Generate a closure which points at the function we just generated. + objw.SymPtr(closure, 0, fn.Linksym(), 0) + objw.Global(closure, int32(types.PtrSize), obj.DUPOK|obj.RODATA) + return closure +} + +func eqFunc(t *types.Type) *ir.Func { + // Autogenerate code for equality of structs and arrays. + sym := TypeSymPrefix(".eq", t) + if sym.Def != nil { + return sym.Def.(*ir.Name).Func + } + + pos := base.AutogeneratedPos // less confusing than end of input + base.Pos = pos + + // func sym(p, q *T) bool + fn := ir.NewFunc(pos, pos, sym, types.NewSignature(nil, + []*types.Field{ + types.NewField(pos, typecheck.Lookup("p"), types.NewPtr(t)), + types.NewField(pos, typecheck.Lookup("q"), types.NewPtr(t)), + }, + []*types.Field{ + types.NewField(pos, typecheck.Lookup("r"), types.Types[types.TBOOL]), + }, + )) + sym.Def = fn.Nname + fn.Pragma |= ir.Noinline // TODO(mdempsky): We need to emit this during the unified frontend instead, to allow inlining. + + typecheck.DeclFunc(fn) + np := fn.Dcl[0] + nq := fn.Dcl[1] + nr := fn.Dcl[2] + + // Label to jump to if an equality test fails. + neq := typecheck.AutoLabel(".neq") + + // We reach here only for types that have equality but + // cannot be handled by the standard algorithms, + // so t must be either an array or a struct. + switch t.Kind() { + default: + base.Fatalf("geneq %v", t) + + case types.TARRAY: + nelem := t.NumElem() + + // checkAll generates code to check the equality of all array elements. + // If unroll is greater than nelem, checkAll generates: + // + // if eq(p[0], q[0]) && eq(p[1], q[1]) && ... { + // } else { + // goto neq + // } + // + // And so on. + // + // Otherwise it generates: + // + // iterateTo := nelem/unroll*unroll + // for i := 0; i < iterateTo; i += unroll { + // if eq(p[i+0], q[i+0]) && eq(p[i+1], q[i+1]) && ... && eq(p[i+unroll-1], q[i+unroll-1]) { + // } else { + // goto neq + // } + // } + // if eq(p[iterateTo+0], q[iterateTo+0]) && eq(p[iterateTo+1], q[iterateTo+1]) && ... { + // } else { + // goto neq + // } + // + checkAll := func(unroll int64, last bool, eq func(pi, qi ir.Node) ir.Node) { + // checkIdx generates a node to check for equality at index i. + checkIdx := func(i ir.Node) ir.Node { + // pi := p[i] + pi := ir.NewIndexExpr(base.Pos, np, i) + pi.SetBounded(true) + pi.SetType(t.Elem()) + // qi := q[i] + qi := ir.NewIndexExpr(base.Pos, nq, i) + qi.SetBounded(true) + qi.SetType(t.Elem()) + return eq(pi, qi) + } + + iterations := nelem / unroll + iterateTo := iterations * unroll + // If a loop is iterated only once, there shouldn't be any loop at all. + if iterations == 1 { + iterateTo = 0 + } + + if iterateTo > 0 { + // Generate an unrolled for loop. + // for i := 0; i < nelem/unroll*unroll; i += unroll + i := typecheck.TempAt(base.Pos, ir.CurFunc, types.Types[types.TINT]) + init := ir.NewAssignStmt(base.Pos, i, ir.NewInt(base.Pos, 0)) + cond := ir.NewBinaryExpr(base.Pos, ir.OLT, i, ir.NewInt(base.Pos, iterateTo)) + loop := ir.NewForStmt(base.Pos, nil, cond, nil, nil, false) + loop.PtrInit().Append(init) + + // if eq(p[i+0], q[i+0]) && eq(p[i+1], q[i+1]) && ... && eq(p[i+unroll-1], q[i+unroll-1]) { + // } else { + // goto neq + // } + for j := int64(0); j < unroll; j++ { + // if check {} else { goto neq } + nif := ir.NewIfStmt(base.Pos, checkIdx(i), nil, nil) + nif.Else.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, neq)) + loop.Body.Append(nif) + post := ir.NewAssignStmt(base.Pos, i, ir.NewBinaryExpr(base.Pos, ir.OADD, i, ir.NewInt(base.Pos, 1))) + loop.Body.Append(post) + } + + fn.Body.Append(loop) + + if nelem == iterateTo { + if last { + fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(base.Pos, true))) + } + return + } + } + + // Generate remaining checks, if nelem is not a multiple of unroll. + if last { + // Do last comparison in a different manner. + nelem-- + } + // if eq(p[iterateTo+0], q[iterateTo+0]) && eq(p[iterateTo+1], q[iterateTo+1]) && ... { + // } else { + // goto neq + // } + for j := iterateTo; j < nelem; j++ { + // if check {} else { goto neq } + nif := ir.NewIfStmt(base.Pos, checkIdx(ir.NewInt(base.Pos, j)), nil, nil) + nif.Else.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, neq)) + fn.Body.Append(nif) + } + if last { + fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, checkIdx(ir.NewInt(base.Pos, nelem)))) + } + } + + switch t.Elem().Kind() { + case types.TSTRING: + // Do two loops. First, check that all the lengths match (cheap). + // Second, check that all the contents match (expensive). + checkAll(3, false, func(pi, qi ir.Node) ir.Node { + // Compare lengths. + eqlen, _ := compare.EqString(pi, qi) + return eqlen + }) + checkAll(1, true, func(pi, qi ir.Node) ir.Node { + // Compare contents. + _, eqmem := compare.EqString(pi, qi) + return eqmem + }) + case types.TFLOAT32, types.TFLOAT64: + checkAll(2, true, func(pi, qi ir.Node) ir.Node { + // p[i] == q[i] + return ir.NewBinaryExpr(base.Pos, ir.OEQ, pi, qi) + }) + case types.TSTRUCT: + isCall := func(n ir.Node) bool { + return n.Op() == ir.OCALL || n.Op() == ir.OCALLFUNC + } + var expr ir.Node + var hasCallExprs bool + allCallExprs := true + and := func(cond ir.Node) { + if expr == nil { + expr = cond + } else { + expr = ir.NewLogicalExpr(base.Pos, ir.OANDAND, expr, cond) + } + } + + var tmpPos src.XPos + pi := ir.NewIndexExpr(tmpPos, np, ir.NewInt(tmpPos, 0)) + pi.SetBounded(true) + pi.SetType(t.Elem()) + qi := ir.NewIndexExpr(tmpPos, nq, ir.NewInt(tmpPos, 0)) + qi.SetBounded(true) + qi.SetType(t.Elem()) + flatConds, canPanic := compare.EqStruct(t.Elem(), pi, qi) + for _, c := range flatConds { + if isCall(c) { + hasCallExprs = true + } else { + allCallExprs = false + } + } + if !hasCallExprs || allCallExprs || canPanic { + checkAll(1, true, func(pi, qi ir.Node) ir.Node { + // p[i] == q[i] + return ir.NewBinaryExpr(base.Pos, ir.OEQ, pi, qi) + }) + } else { + checkAll(4, false, func(pi, qi ir.Node) ir.Node { + expr = nil + flatConds, _ := compare.EqStruct(t.Elem(), pi, qi) + if len(flatConds) == 0 { + return ir.NewBool(base.Pos, true) + } + for _, c := range flatConds { + if !isCall(c) { + and(c) + } + } + return expr + }) + checkAll(2, true, func(pi, qi ir.Node) ir.Node { + expr = nil + flatConds, _ := compare.EqStruct(t.Elem(), pi, qi) + for _, c := range flatConds { + if isCall(c) { + and(c) + } + } + return expr + }) + } + default: + checkAll(1, true, func(pi, qi ir.Node) ir.Node { + // p[i] == q[i] + return ir.NewBinaryExpr(base.Pos, ir.OEQ, pi, qi) + }) + } + + case types.TSTRUCT: + flatConds, _ := compare.EqStruct(t, np, nq) + if len(flatConds) == 0 { + fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(base.Pos, true))) + } else { + for _, c := range flatConds[:len(flatConds)-1] { + // if cond {} else { goto neq } + n := ir.NewIfStmt(base.Pos, c, nil, nil) + n.Else.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, neq)) + fn.Body.Append(n) + } + fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, flatConds[len(flatConds)-1])) + } + } + + // ret: + // return + ret := typecheck.AutoLabel(".ret") + fn.Body.Append(ir.NewLabelStmt(base.Pos, ret)) + fn.Body.Append(ir.NewReturnStmt(base.Pos, nil)) + + // neq: + // r = false + // return (or goto ret) + fn.Body.Append(ir.NewLabelStmt(base.Pos, neq)) + fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(base.Pos, false))) + if compare.EqCanPanic(t) || anyCall(fn) { + // Epilogue is large, so share it with the equal case. + fn.Body.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, ret)) + } else { + // Epilogue is small, so don't bother sharing. + fn.Body.Append(ir.NewReturnStmt(base.Pos, nil)) + } + // TODO(khr): the epilogue size detection condition above isn't perfect. + // We should really do a generic CL that shares epilogues across + // the board. See #24936. + + if base.Flag.LowerR != 0 { + ir.DumpList("geneq body", fn.Body) + } + + typecheck.FinishFuncBody() + + fn.SetDupok(true) + + ir.WithFunc(fn, func() { + typecheck.Stmts(fn.Body) + }) + + // Disable checknils while compiling this code. + // We are comparing a struct or an array, + // neither of which can be nil, and our comparisons + // are shallow. + fn.SetNilCheckDisabled(true) + return fn +} + +// EqFor returns ONAME node represents type t's equal function, and a boolean +// to indicates whether a length needs to be passed when calling the function. +func EqFor(t *types.Type) (ir.Node, bool) { + switch types.AlgType(t) { + case types.AMEM: + return typecheck.LookupRuntime("memequal", t, t), true + case types.ASPECIAL: + fn := eqFunc(t) + return fn.Nname, false + } + base.Fatalf("EqFor %v", t) + return nil, false +} + +func anyCall(fn *ir.Func) bool { + return ir.Any(fn, func(n ir.Node) bool { + // TODO(rsc): No methods? + op := n.Op() + return op == ir.OCALL || op == ir.OCALLFUNC + }) +} + +func hashmem(t *types.Type) ir.Node { + return typecheck.LookupRuntime("memhash", t) +} diff --git a/go/src/cmd/compile/internal/reflectdata/alg_test.go b/go/src/cmd/compile/internal/reflectdata/alg_test.go new file mode 100644 index 0000000000000000000000000000000000000000..38fb974f6197ba39502a24a0806b14b83c0f7394 --- /dev/null +++ b/go/src/cmd/compile/internal/reflectdata/alg_test.go @@ -0,0 +1,147 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package reflectdata_test + +import ( + "testing" +) + +func BenchmarkEqArrayOfStrings5(b *testing.B) { + var a [5]string + var c [5]string + + for i := 0; i < 5; i++ { + a[i] = "aaaa" + c[i] = "cccc" + } + + for j := 0; j < b.N; j++ { + _ = a == c + } +} + +func BenchmarkEqArrayOfStrings64(b *testing.B) { + var a [64]string + var c [64]string + + for i := 0; i < 64; i++ { + a[i] = "aaaa" + c[i] = "cccc" + } + + for j := 0; j < b.N; j++ { + _ = a == c + } +} + +func BenchmarkEqArrayOfStrings1024(b *testing.B) { + var a [1024]string + var c [1024]string + + for i := 0; i < 1024; i++ { + a[i] = "aaaa" + c[i] = "cccc" + } + + for j := 0; j < b.N; j++ { + _ = a == c + } +} + +func BenchmarkEqArrayOfFloats5(b *testing.B) { + var a [5]float32 + var c [5]float32 + + for i := 0; i < b.N; i++ { + _ = a == c + } +} + +func BenchmarkEqArrayOfFloats64(b *testing.B) { + var a [64]float32 + var c [64]float32 + + for i := 0; i < b.N; i++ { + _ = a == c + } +} + +func BenchmarkEqArrayOfFloats1024(b *testing.B) { + var a [1024]float32 + var c [1024]float32 + + for i := 0; i < b.N; i++ { + _ = a == c + } +} + +func BenchmarkEqArrayOfStructsEq(b *testing.B) { + type T2 struct { + a string + b int + } + const size = 1024 + var ( + str1 = "foobar" + + a [size]T2 + c [size]T2 + ) + + for i := 0; i < size; i++ { + a[i].a = str1 + c[i].a = str1 + } + + b.ResetTimer() + for j := 0; j < b.N; j++ { + _ = a == c + } +} + +func BenchmarkEqArrayOfStructsNotEq(b *testing.B) { + type T2 struct { + a string + b int + } + const size = 1024 + var ( + str1 = "foobar" + str2 = "foobarz" + + a [size]T2 + c [size]T2 + ) + + for i := 0; i < size; i++ { + a[i].a = str1 + c[i].a = str1 + } + c[len(c)-1].a = str2 + + b.ResetTimer() + for j := 0; j < b.N; j++ { + _ = a == c + } +} + +const size = 16 + +type T1 struct { + a [size]byte +} + +func BenchmarkEqStruct(b *testing.B) { + x, y := T1{}, T1{} + x.a = [size]byte{1, 2, 3, 4, 5, 6, 7, 8} + y.a = [size]byte{2, 3, 4, 5, 6, 7, 8, 9} + + for i := 0; i < b.N; i++ { + f := x == y + if f { + println("hello") + } + } +} diff --git a/go/src/cmd/compile/internal/reflectdata/helpers.go b/go/src/cmd/compile/internal/reflectdata/helpers.go new file mode 100644 index 0000000000000000000000000000000000000000..9ba62d6a2967da53fd7e7a62e812980b7666b962 --- /dev/null +++ b/go/src/cmd/compile/internal/reflectdata/helpers.go @@ -0,0 +1,216 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package reflectdata + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +func hasRType(n, rtype ir.Node, fieldName string) bool { + if rtype != nil { + return true + } + + return false +} + +// assertOp asserts that n is an op. +func assertOp(n ir.Node, op ir.Op) { + base.AssertfAt(n.Op() == op, n.Pos(), "want %v, have %v", op, n) +} + +// assertOp2 asserts that n is an op1 or op2. +func assertOp2(n ir.Node, op1, op2 ir.Op) { + base.AssertfAt(n.Op() == op1 || n.Op() == op2, n.Pos(), "want %v or %v, have %v", op1, op2, n) +} + +// kindRType asserts that typ has the given kind, and returns an +// expression that yields the *runtime._type value representing typ. +func kindRType(pos src.XPos, typ *types.Type, k types.Kind) ir.Node { + base.AssertfAt(typ.Kind() == k, pos, "want %v type, have %v", k, typ) + return TypePtrAt(pos, typ) +} + +// mapRType asserts that typ is a map type, and returns an expression +// that yields the *runtime._type value representing typ. +func mapRType(pos src.XPos, typ *types.Type) ir.Node { + return kindRType(pos, typ, types.TMAP) +} + +// chanRType asserts that typ is a map type, and returns an expression +// that yields the *runtime._type value representing typ. +func chanRType(pos src.XPos, typ *types.Type) ir.Node { + return kindRType(pos, typ, types.TCHAN) +} + +// sliceElemRType asserts that typ is a slice type, and returns an +// expression that yields the *runtime._type value representing typ's +// element type. +func sliceElemRType(pos src.XPos, typ *types.Type) ir.Node { + base.AssertfAt(typ.IsSlice(), pos, "want slice type, have %v", typ) + return TypePtrAt(pos, typ.Elem()) +} + +// concreteRType asserts that typ is not an interface type, and +// returns an expression that yields the *runtime._type value +// representing typ. +func concreteRType(pos src.XPos, typ *types.Type) ir.Node { + base.AssertfAt(!typ.IsInterface(), pos, "want non-interface type, have %v", typ) + return TypePtrAt(pos, typ) +} + +// AppendElemRType asserts that n is an "append" operation, and +// returns an expression that yields the *runtime._type value +// representing the result slice type's element type. +func AppendElemRType(pos src.XPos, n *ir.CallExpr) ir.Node { + assertOp(n, ir.OAPPEND) + if hasRType(n, n.RType, "RType") { + return n.RType + } + return sliceElemRType(pos, n.Type()) +} + +// CompareRType asserts that n is a comparison (== or !=) operation +// between expressions of interface and non-interface type, and +// returns an expression that yields the *runtime._type value +// representing the non-interface type. +func CompareRType(pos src.XPos, n *ir.BinaryExpr) ir.Node { + assertOp2(n, ir.OEQ, ir.ONE) + base.AssertfAt(n.X.Type().IsInterface() != n.Y.Type().IsInterface(), n.Pos(), "expect mixed interface and non-interface, have %L and %L", n.X, n.Y) + if hasRType(n, n.RType, "RType") { + return n.RType + } + typ := n.X.Type() + if typ.IsInterface() { + typ = n.Y.Type() + } + return concreteRType(pos, typ) +} + +// ConvIfaceTypeWord asserts that n is conversion to interface type, +// and returns an expression that yields the *runtime._type or +// *runtime.itab value necessary for implementing the conversion. +// +// - *runtime._type for the destination type, for I2I conversions +// - *runtime.itab, for T2I conversions +// - *runtime._type for the source type, for T2E conversions +func ConvIfaceTypeWord(pos src.XPos, n *ir.ConvExpr) ir.Node { + assertOp(n, ir.OCONVIFACE) + src, dst := n.X.Type(), n.Type() + base.AssertfAt(dst.IsInterface(), n.Pos(), "want interface type, have %L", n) + if hasRType(n, n.TypeWord, "TypeWord") { + return n.TypeWord + } + if dst.IsEmptyInterface() { + return concreteRType(pos, src) // direct eface construction + } + if !src.IsInterface() { + return ITabAddrAt(pos, src, dst) // direct iface construction + } + return TypePtrAt(pos, dst) // convI2I +} + +// ConvIfaceSrcRType asserts that n is a conversion from +// non-interface type to interface type, and +// returns an expression that yields the *runtime._type for copying +// the convertee value to the heap. +func ConvIfaceSrcRType(pos src.XPos, n *ir.ConvExpr) ir.Node { + assertOp(n, ir.OCONVIFACE) + if hasRType(n, n.SrcRType, "SrcRType") { + return n.SrcRType + } + return concreteRType(pos, n.X.Type()) +} + +// CopyElemRType asserts that n is a "copy" operation, and returns an +// expression that yields the *runtime._type value representing the +// destination slice type's element type. +func CopyElemRType(pos src.XPos, n *ir.BinaryExpr) ir.Node { + assertOp(n, ir.OCOPY) + if hasRType(n, n.RType, "RType") { + return n.RType + } + return sliceElemRType(pos, n.X.Type()) +} + +// DeleteMapRType asserts that n is a "delete" operation, and returns +// an expression that yields the *runtime._type value representing the +// map type. +func DeleteMapRType(pos src.XPos, n *ir.CallExpr) ir.Node { + assertOp(n, ir.ODELETE) + if hasRType(n, n.RType, "RType") { + return n.RType + } + return mapRType(pos, n.Args[0].Type()) +} + +// IndexMapRType asserts that n is a map index operation, and returns +// an expression that yields the *runtime._type value representing the +// map type. +func IndexMapRType(pos src.XPos, n *ir.IndexExpr) ir.Node { + assertOp(n, ir.OINDEXMAP) + if hasRType(n, n.RType, "RType") { + return n.RType + } + return mapRType(pos, n.X.Type()) +} + +// MakeChanRType asserts that n is a "make" operation for a channel +// type, and returns an expression that yields the *runtime._type +// value representing that channel type. +func MakeChanRType(pos src.XPos, n *ir.MakeExpr) ir.Node { + assertOp(n, ir.OMAKECHAN) + if hasRType(n, n.RType, "RType") { + return n.RType + } + return chanRType(pos, n.Type()) +} + +// MakeMapRType asserts that n is a "make" operation for a map type, +// and returns an expression that yields the *runtime._type value +// representing that map type. +func MakeMapRType(pos src.XPos, n *ir.MakeExpr) ir.Node { + assertOp(n, ir.OMAKEMAP) + if hasRType(n, n.RType, "RType") { + return n.RType + } + return mapRType(pos, n.Type()) +} + +// MakeSliceElemRType asserts that n is a "make" operation for a slice +// type, and returns an expression that yields the *runtime._type +// value representing that slice type's element type. +func MakeSliceElemRType(pos src.XPos, n *ir.MakeExpr) ir.Node { + assertOp2(n, ir.OMAKESLICE, ir.OMAKESLICECOPY) + if hasRType(n, n.RType, "RType") { + return n.RType + } + return sliceElemRType(pos, n.Type()) +} + +// RangeMapRType asserts that n is a "range" loop over a map value, +// and returns an expression that yields the *runtime._type value +// representing that map type. +func RangeMapRType(pos src.XPos, n *ir.RangeStmt) ir.Node { + assertOp(n, ir.ORANGE) + if hasRType(n, n.RType, "RType") { + return n.RType + } + return mapRType(pos, n.X.Type()) +} + +// UnsafeSliceElemRType asserts that n is an "unsafe.Slice" operation, +// and returns an expression that yields the *runtime._type value +// representing the result slice type's element type. +func UnsafeSliceElemRType(pos src.XPos, n *ir.BinaryExpr) ir.Node { + assertOp(n, ir.OUNSAFESLICE) + if hasRType(n, n.RType, "RType") { + return n.RType + } + return sliceElemRType(pos, n.Type()) +} diff --git a/go/src/cmd/compile/internal/reflectdata/map.go b/go/src/cmd/compile/internal/reflectdata/map.go new file mode 100644 index 0000000000000000000000000000000000000000..2b43d4af27a25075fdae31596be3533361359bf1 --- /dev/null +++ b/go/src/cmd/compile/internal/reflectdata/map.go @@ -0,0 +1,310 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package reflectdata + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/rttype" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" + "internal/abi" +) + +// MapGroupType makes the map slot group type given the type of the map. +func MapGroupType(t *types.Type) *types.Type { + if t.MapType().Group != nil { + return t.MapType().Group + } + + // Builds a type representing a group structure for the given map type. + // This type is not visible to users, we include it so we can generate + // a correct GC program for it. + // + // Make sure this stays in sync with internal/runtime/maps/group.go. + // + // type group struct { + // ctrl uint64 + // slots [abi.MapGroupSlots]struct { + // key keyType + // elem elemType + // } + // } + + keytype := t.Key() + elemtype := t.Elem() + types.CalcSize(keytype) + types.CalcSize(elemtype) + if keytype.Size() > abi.MapMaxKeyBytes { + keytype = types.NewPtr(keytype) + } + if elemtype.Size() > abi.MapMaxElemBytes { + elemtype = types.NewPtr(elemtype) + } + + slotFields := []*types.Field{ + makefield("key", keytype), + makefield("elem", elemtype), + } + slot := types.NewStruct(slotFields) + slot.SetNoalg(true) + + slotArr := types.NewArray(slot, abi.MapGroupSlots) + slotArr.SetNoalg(true) + + fields := []*types.Field{ + makefield("ctrl", types.Types[types.TUINT64]), + makefield("slots", slotArr), + } + + group := types.NewStruct(fields) + group.SetNoalg(true) + types.CalcSize(group) + + // Check invariants that map code depends on. + if !types.IsComparable(t.Key()) { + base.Fatalf("unsupported map key type for %v", t) + } + if group.Size() <= 8 { + // internal/runtime/maps creates pointers to slots, even if + // both key and elem are size zero. In this case, each slot is + // size 0, but group should still reserve a word of padding at + // the end to ensure pointers are valid. + base.Fatalf("bad group size for %v", t) + } + if t.Key().Size() > abi.MapMaxKeyBytes && !keytype.IsPtr() { + base.Fatalf("key indirect incorrect for %v", t) + } + if t.Elem().Size() > abi.MapMaxElemBytes && !elemtype.IsPtr() { + base.Fatalf("elem indirect incorrect for %v", t) + } + + t.MapType().Group = group + group.StructType().Map = t + return group +} + +var cachedMapTableType *types.Type + +// mapTableType returns a type interchangeable with internal/runtime/maps.table. +// Make sure this stays in sync with internal/runtime/maps/table.go. +func mapTableType() *types.Type { + if cachedMapTableType != nil { + return cachedMapTableType + } + + // type table struct { + // used uint16 + // capacity uint16 + // growthLeft uint16 + // localDepth uint8 + // // N.B Padding + // + // index int + // + // // From groups. + // groups_data unsafe.Pointer + // groups_lengthMask uint64 + // } + // must match internal/runtime/maps/table.go:table. + fields := []*types.Field{ + makefield("used", types.Types[types.TUINT16]), + makefield("capacity", types.Types[types.TUINT16]), + makefield("growthLeft", types.Types[types.TUINT16]), + makefield("localDepth", types.Types[types.TUINT8]), + makefield("index", types.Types[types.TINT]), + makefield("groups_data", types.Types[types.TUNSAFEPTR]), + makefield("groups_lengthMask", types.Types[types.TUINT64]), + } + + n := ir.NewDeclNameAt(src.NoXPos, ir.OTYPE, ir.Pkgs.InternalMaps.Lookup("table")) + table := types.NewNamed(n) + n.SetType(table) + n.SetTypecheck(1) + + table.SetUnderlying(types.NewStruct(fields)) + types.CalcSize(table) + + // The size of table should be 32 bytes on 64 bit + // and 24 bytes on 32 bit platforms. + if size := int64(3*2 + 2*1 /* one extra for padding */ + 1*8 + 2*types.PtrSize); table.Size() != size { + base.Fatalf("internal/runtime/maps.table size not correct: got %d, want %d", table.Size(), size) + } + + cachedMapTableType = table + return table +} + +var cachedMapType *types.Type + +// MapType returns a type interchangeable with internal/runtime/maps.Map. +// Make sure this stays in sync with internal/runtime/maps/map.go. +func MapType() *types.Type { + if cachedMapType != nil { + return cachedMapType + } + + // type Map struct { + // used uint64 + // seed uintptr + // + // dirPtr unsafe.Pointer + // dirLen int + // + // globalDepth uint8 + // globalShift uint8 + // + // writing uint8 + // tombstonePossible bool + // // N.B Padding + // + // clearSeq uint64 + // } + // must match internal/runtime/maps/map.go:Map. + fields := []*types.Field{ + makefield("used", types.Types[types.TUINT64]), + makefield("seed", types.Types[types.TUINTPTR]), + makefield("dirPtr", types.Types[types.TUNSAFEPTR]), + makefield("dirLen", types.Types[types.TINT]), + makefield("globalDepth", types.Types[types.TUINT8]), + makefield("globalShift", types.Types[types.TUINT8]), + makefield("writing", types.Types[types.TUINT8]), + makefield("tombstonePossible", types.Types[types.TBOOL]), + makefield("clearSeq", types.Types[types.TUINT64]), + } + + n := ir.NewDeclNameAt(src.NoXPos, ir.OTYPE, ir.Pkgs.InternalMaps.Lookup("Map")) + m := types.NewNamed(n) + n.SetType(m) + n.SetTypecheck(1) + + m.SetUnderlying(types.NewStruct(fields)) + types.CalcSize(m) + + // The size of Map should be 48 bytes on 64 bit + // and 32 bytes on 32 bit platforms. + if size := int64(2*8 + 4*types.PtrSize /* one extra for globalDepth/globalShift/writing + padding */); m.Size() != size { + base.Fatalf("internal/runtime/maps.Map size not correct: got %d, want %d", m.Size(), size) + } + + cachedMapType = m + return m +} + +var cachedMapIterType *types.Type + +// MapIterType returns a type interchangeable with internal/runtime/maps.Iter. +// Make sure this stays in sync with internal/runtime/maps/table.go. +func MapIterType() *types.Type { + if cachedMapIterType != nil { + return cachedMapIterType + } + + // type Iter struct { + // key unsafe.Pointer // *Key + // elem unsafe.Pointer // *Elem + // typ unsafe.Pointer // *MapType + // m *Map + // + // groupSlotOffset uint64 + // dirOffset uint64 + // + // clearSeq uint64 + // + // globalDepth uint8 + // // N.B. padding + // + // dirIdx int + // + // tab *table + // + // group unsafe.Pointer // actually groupReference.data + // + // entryIdx uint64 + // } + // must match internal/runtime/maps/table.go:Iter. + fields := []*types.Field{ + makefield("key", types.Types[types.TUNSAFEPTR]), // Used in range.go for TMAP. + makefield("elem", types.Types[types.TUNSAFEPTR]), // Used in range.go for TMAP. + makefield("typ", types.Types[types.TUNSAFEPTR]), + makefield("m", types.NewPtr(MapType())), + makefield("groupSlotOffset", types.Types[types.TUINT64]), + makefield("dirOffset", types.Types[types.TUINT64]), + makefield("clearSeq", types.Types[types.TUINT64]), + makefield("globalDepth", types.Types[types.TUINT8]), + makefield("dirIdx", types.Types[types.TINT]), + makefield("tab", types.NewPtr(mapTableType())), + makefield("group", types.Types[types.TUNSAFEPTR]), + makefield("entryIdx", types.Types[types.TUINT64]), + } + + // build iterator struct holding the above fields + n := ir.NewDeclNameAt(src.NoXPos, ir.OTYPE, ir.Pkgs.InternalMaps.Lookup("Iter")) + iter := types.NewNamed(n) + n.SetType(iter) + n.SetTypecheck(1) + + iter.SetUnderlying(types.NewStruct(fields)) + types.CalcSize(iter) + + // The size of Iter should be 96 bytes on 64 bit + // and 64 bytes on 32 bit platforms. + if size := 8*types.PtrSize /* one extra for globalDepth + padding */ + 4*8; iter.Size() != int64(size) { + base.Fatalf("internal/runtime/maps.Iter size not correct: got %d, want %d", iter.Size(), size) + } + + cachedMapIterType = iter + return iter +} + +func writeMapType(t *types.Type, lsym *obj.LSym, c rttype.Cursor) { + // internal/abi.MapType + gtyp := MapGroupType(t) + s1 := writeType(t.Key()) + s2 := writeType(t.Elem()) + s3 := writeType(gtyp) + hasher := genhash(t.Key()) + + slotTyp := gtyp.Field(1).Type.Elem() + elemOff := slotTyp.Field(1).Offset + if AlgType(t.Key()) == types.AMEM64 && elemOff != 8 { + base.Fatalf("runtime assumes elemOff for 8-byte keys is 8, got %d", elemOff) + } + if AlgType(t.Key()) == types.ASTRING && elemOff != int64(2*types.PtrSize) { + base.Fatalf("runtime assumes elemOff for string keys is %d, got %d", 2*types.PtrSize, elemOff) + } + + c.Field("Key").WritePtr(s1) + c.Field("Elem").WritePtr(s2) + c.Field("Group").WritePtr(s3) + c.Field("Hasher").WritePtr(hasher) + c.Field("GroupSize").WriteUintptr(uint64(gtyp.Size())) + c.Field("SlotSize").WriteUintptr(uint64(slotTyp.Size())) + c.Field("ElemOff").WriteUintptr(uint64(elemOff)) + var flags uint32 + if needkeyupdate(t.Key()) { + flags |= abi.MapNeedKeyUpdate + } + if hashMightPanic(t.Key()) { + flags |= abi.MapHashMightPanic + } + if t.Key().Size() > abi.MapMaxKeyBytes { + flags |= abi.MapIndirectKey + } + if t.Elem().Size() > abi.MapMaxKeyBytes { + flags |= abi.MapIndirectElem + } + c.Field("Flags").WriteUint32(flags) + + if u := t.Underlying(); u != t { + // If t is a named map type, also keep the underlying map + // type live in the binary. This is important to make sure that + // a named map and that same map cast to its underlying type via + // reflection, use the same hash function. See issue 37716. + lsym.AddRel(base.Ctxt, obj.Reloc{Type: objabi.R_KEEP, Sym: writeType(u)}) + } +} diff --git a/go/src/cmd/compile/internal/reflectdata/reflect.go b/go/src/cmd/compile/internal/reflectdata/reflect.go new file mode 100644 index 0000000000000000000000000000000000000000..324007ea798f13a379206d5448186624af06d3d6 --- /dev/null +++ b/go/src/cmd/compile/internal/reflectdata/reflect.go @@ -0,0 +1,1476 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package reflectdata + +import ( + "encoding/binary" + "fmt" + "internal/abi" + "slices" + "sort" + "strings" + "sync" + + "cmd/compile/internal/base" + "cmd/compile/internal/bitvec" + "cmd/compile/internal/compare" + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/rttype" + "cmd/compile/internal/staticdata" + "cmd/compile/internal/typebits" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" +) + +type ptabEntry struct { + s *types.Sym + t *types.Type +} + +// runtime interface and reflection data structures +var ( + // protects signatset and signatslice + signatmu sync.Mutex + // Tracking which types need runtime type descriptor + signatset = make(map[*types.Type]struct{}) + // Queue of types wait to be generated runtime type descriptor + signatslice []typeAndStr + + gcsymmu sync.Mutex // protects gcsymset and gcsymslice + gcsymset = make(map[*types.Type]struct{}) +) + +type typeSig struct { + name *types.Sym + isym *obj.LSym + tsym *obj.LSym + type_ *types.Type + mtype *types.Type +} + +func commonSize() int { return int(rttype.Type.Size()) } // Sizeof(runtime._type{}) + +func uncommonSize(t *types.Type) int { // Sizeof(runtime.uncommontype{}) + if t.Sym() == nil && len(methods(t)) == 0 { + return 0 + } + return int(rttype.UncommonType.Size()) +} + +func makefield(name string, t *types.Type) *types.Field { + sym := (*types.Pkg)(nil).Lookup(name) + return types.NewField(src.NoXPos, sym, t) +} + +// methods returns the methods of the non-interface type t, sorted by name. +// Generates stub functions as needed. +func methods(t *types.Type) []*typeSig { + if t.HasShape() { + // Shape types have no methods. + return nil + } + // method type + mt := types.ReceiverBaseType(t) + + if mt == nil { + return nil + } + typecheck.CalcMethods(mt) + + // make list of methods for t, + // generating code if necessary. + var ms []*typeSig + for _, f := range mt.AllMethods() { + if f.Sym == nil { + base.Fatalf("method with no sym on %v", mt) + } + if !f.IsMethod() { + base.Fatalf("non-method on %v method %v %v", mt, f.Sym, f) + } + if f.Type.Recv() == nil { + base.Fatalf("receiver with no type on %v method %v %v", mt, f.Sym, f) + } + if f.Nointerface() && !t.IsFullyInstantiated() { + // Skip creating method wrappers if f is nointerface. But, if + // t is an instantiated type, we still have to call + // methodWrapper, because methodWrapper generates the actual + // generic method on the type as well. + continue + } + + // get receiver type for this particular method. + // if pointer receiver but non-pointer t and + // this is not an embedded pointer inside a struct, + // method does not apply. + if !types.IsMethodApplicable(t, f) { + continue + } + + sig := &typeSig{ + name: f.Sym, + isym: methodWrapper(t, f, true), + tsym: methodWrapper(t, f, false), + type_: typecheck.NewMethodType(f.Type, t), + mtype: typecheck.NewMethodType(f.Type, nil), + } + if f.Nointerface() { + // In the case of a nointerface method on an instantiated + // type, don't actually append the typeSig. + continue + } + ms = append(ms, sig) + } + + return ms +} + +// imethods returns the methods of the interface type t, sorted by name. +func imethods(t *types.Type) []*typeSig { + var methods []*typeSig + for _, f := range t.AllMethods() { + if f.Type.Kind() != types.TFUNC || f.Sym == nil { + continue + } + if f.Sym.IsBlank() { + base.Fatalf("unexpected blank symbol in interface method set") + } + if n := len(methods); n > 0 { + last := methods[n-1] + if types.CompareSyms(last.name, f.Sym) >= 0 { + base.Fatalf("sigcmp vs sortinter %v %v", last.name, f.Sym) + } + } + + sig := &typeSig{ + name: f.Sym, + mtype: f.Type, + type_: typecheck.NewMethodType(f.Type, nil), + } + methods = append(methods, sig) + + // NOTE(rsc): Perhaps an oversight that + // IfaceType.Method is not in the reflect data. + // Generate the method body, so that compiled + // code can refer to it. + methodWrapper(t, f, false) + } + + return methods +} + +func dimportpath(p *types.Pkg) { + if p.Pathsym != nil { + return + } + + if p == types.LocalPkg && base.Ctxt.Pkgpath == "" { + panic("missing pkgpath") + } + + // If we are compiling the runtime package, there are two runtime packages around + // -- localpkg and Pkgs.Runtime. We don't want to produce import path symbols for + // both of them, so just produce one for localpkg. + if base.Ctxt.Pkgpath == "runtime" && p == ir.Pkgs.Runtime { + return + } + + s := base.Ctxt.Lookup("type:.importpath." + p.Prefix + ".") + ot := dnameData(s, 0, p.Path, "", nil, false, false) + objw.Global(s, int32(ot), obj.DUPOK|obj.RODATA) + s.Set(obj.AttrContentAddressable, true) + p.Pathsym = s +} + +func dgopkgpath(c rttype.Cursor, pkg *types.Pkg) { + c = c.Field("Bytes") + if pkg == nil { + c.WritePtr(nil) + return + } + + dimportpath(pkg) + c.WritePtr(pkg.Pathsym) +} + +// dgopkgpathOff writes an offset relocation to the pkg path symbol to c. +func dgopkgpathOff(c rttype.Cursor, pkg *types.Pkg) { + if pkg == nil { + c.WriteInt32(0) + return + } + + dimportpath(pkg) + c.WriteSymPtrOff(pkg.Pathsym, false) +} + +// dnameField dumps a reflect.name for a struct field. +func dnameField(c rttype.Cursor, spkg *types.Pkg, ft *types.Field) { + if !types.IsExported(ft.Sym.Name) && ft.Sym.Pkg != spkg { + base.Fatalf("package mismatch for %v", ft.Sym) + } + nsym := dname(ft.Sym.Name, ft.Note, nil, types.IsExported(ft.Sym.Name), ft.Embedded != 0) + c.Field("Bytes").WritePtr(nsym) +} + +// dnameData writes the contents of a reflect.name into s at offset ot. +func dnameData(s *obj.LSym, ot int, name, tag string, pkg *types.Pkg, exported, embedded bool) int { + if len(name) >= 1<<29 { + base.Fatalf("name too long: %d %s...", len(name), name[:1024]) + } + if len(tag) >= 1<<29 { + base.Fatalf("tag too long: %d %s...", len(tag), tag[:1024]) + } + var nameLen [binary.MaxVarintLen64]byte + nameLenLen := binary.PutUvarint(nameLen[:], uint64(len(name))) + var tagLen [binary.MaxVarintLen64]byte + tagLenLen := binary.PutUvarint(tagLen[:], uint64(len(tag))) + + // Encode name and tag. See reflect/type.go for details. + var bits byte + l := 1 + nameLenLen + len(name) + if exported { + bits |= 1 << 0 + } + if len(tag) > 0 { + l += tagLenLen + len(tag) + bits |= 1 << 1 + } + if pkg != nil { + bits |= 1 << 2 + } + if embedded { + bits |= 1 << 3 + } + b := make([]byte, l) + b[0] = bits + copy(b[1:], nameLen[:nameLenLen]) + copy(b[1+nameLenLen:], name) + if len(tag) > 0 { + tb := b[1+nameLenLen+len(name):] + copy(tb, tagLen[:tagLenLen]) + copy(tb[tagLenLen:], tag) + } + + ot = int(s.WriteBytes(base.Ctxt, int64(ot), b)) + + if pkg != nil { + c := rttype.NewCursor(s, int64(ot), types.Types[types.TUINT32]) + dgopkgpathOff(c, pkg) + ot += 4 + } + + return ot +} + +var dnameCount int + +// dname creates a reflect.name for a struct field or method. +func dname(name, tag string, pkg *types.Pkg, exported, embedded bool) *obj.LSym { + // Write out data as "type:." to signal two things to the + // linker, first that when dynamically linking, the symbol + // should be moved to a relro section, and second that the + // contents should not be decoded as a type. + sname := "type:.namedata." + if pkg == nil { + // In the common case, share data with other packages. + if name == "" { + if exported { + sname += "-noname-exported." + tag + } else { + sname += "-noname-unexported." + tag + } + } else { + if exported { + sname += name + "." + tag + } else { + sname += name + "-" + tag + } + } + } else { + // TODO(mdempsky): We should be able to share these too (except + // maybe when dynamic linking). + sname = fmt.Sprintf("%s%s.%d", sname, types.LocalPkg.Prefix, dnameCount) + dnameCount++ + } + if embedded { + sname += ".embedded" + } + s := base.Ctxt.Lookup(sname) + if len(s.P) > 0 { + return s + } + ot := dnameData(s, 0, name, tag, pkg, exported, embedded) + objw.Global(s, int32(ot), obj.DUPOK|obj.RODATA) + s.Set(obj.AttrContentAddressable, true) + return s +} + +// dextratype dumps the fields of a runtime.uncommontype. +// dataAdd is the offset in bytes after the header where the +// backing array of the []method field should be written. +func dextratype(lsym *obj.LSym, off int64, t *types.Type, dataAdd int) { + m := methods(t) + if t.Sym() == nil && len(m) == 0 { + base.Fatalf("extra requested of type with no extra info %v", t) + } + noff := types.RoundUp(off, int64(types.PtrSize)) + if noff != off { + base.Fatalf("unexpected alignment in dextratype for %v", t) + } + + for _, a := range m { + writeType(a.type_) + } + + c := rttype.NewCursor(lsym, off, rttype.UncommonType) + dgopkgpathOff(c.Field("PkgPath"), typePkg(t)) + + dataAdd += uncommonSize(t) + mcount := len(m) + if mcount != int(uint16(mcount)) { + base.Fatalf("too many methods on %v: %d", t, mcount) + } + xcount := sort.Search(mcount, func(i int) bool { return !types.IsExported(m[i].name.Name) }) + if dataAdd != int(uint32(dataAdd)) { + base.Fatalf("methods are too far away on %v: %d", t, dataAdd) + } + + c.Field("Mcount").WriteUint16(uint16(mcount)) + c.Field("Xcount").WriteUint16(uint16(xcount)) + c.Field("Moff").WriteUint32(uint32(dataAdd)) + // Note: there is an unused uint32 field here. + + // Write the backing array for the []method field. + array := rttype.NewArrayCursor(lsym, off+int64(dataAdd), rttype.Method, mcount) + for i, a := range m { + exported := types.IsExported(a.name.Name) + var pkg *types.Pkg + if !exported && a.name.Pkg != typePkg(t) { + pkg = a.name.Pkg + } + nsym := dname(a.name.Name, "", pkg, exported, false) + + e := array.Elem(i) + e.Field("Name").WriteSymPtrOff(nsym, false) + dmethodptrOff(e.Field("Mtyp"), writeType(a.mtype)) + dmethodptrOff(e.Field("Ifn"), a.isym) + dmethodptrOff(e.Field("Tfn"), a.tsym) + } +} + +func typePkg(t *types.Type) *types.Pkg { + tsym := t.Sym() + if tsym == nil { + switch t.Kind() { + case types.TARRAY, types.TSLICE, types.TPTR, types.TCHAN: + if t.Elem() != nil { + tsym = t.Elem().Sym() + } + } + } + if tsym != nil && tsym.Pkg != types.BuiltinPkg { + return tsym.Pkg + } + return nil +} + +func dmethodptrOff(c rttype.Cursor, x *obj.LSym) { + c.WriteInt32(0) + c.Reloc(obj.Reloc{Type: objabi.R_METHODOFF, Sym: x}) +} + +var kinds = []abi.Kind{ + types.TINT: abi.Int, + types.TUINT: abi.Uint, + types.TINT8: abi.Int8, + types.TUINT8: abi.Uint8, + types.TINT16: abi.Int16, + types.TUINT16: abi.Uint16, + types.TINT32: abi.Int32, + types.TUINT32: abi.Uint32, + types.TINT64: abi.Int64, + types.TUINT64: abi.Uint64, + types.TUINTPTR: abi.Uintptr, + types.TFLOAT32: abi.Float32, + types.TFLOAT64: abi.Float64, + types.TBOOL: abi.Bool, + types.TSTRING: abi.String, + types.TPTR: abi.Pointer, + types.TSTRUCT: abi.Struct, + types.TINTER: abi.Interface, + types.TCHAN: abi.Chan, + types.TMAP: abi.Map, + types.TARRAY: abi.Array, + types.TSLICE: abi.Slice, + types.TFUNC: abi.Func, + types.TCOMPLEX64: abi.Complex64, + types.TCOMPLEX128: abi.Complex128, + types.TUNSAFEPTR: abi.UnsafePointer, +} + +func ABIKindOfType(t *types.Type) abi.Kind { + return kinds[t.Kind()] +} + +var ( + memhashvarlen *obj.LSym + memequalvarlen *obj.LSym +) + +// dcommontype dumps the contents of a reflect.rtype (runtime._type) to c. +func dcommontype(c rttype.Cursor, t *types.Type) { + types.CalcSize(t) + eqfunc := geneq(t) + + sptrWeak := true + var sptr *obj.LSym + if !t.IsPtr() || t.IsPtrElem() { + tptr := types.NewPtr(t) + if t.Sym() != nil || methods(tptr) != nil { + sptrWeak = false + } + sptr = writeType(tptr) + } + + gcsym, onDemand, ptrdata := dgcsym(t, true, true) + if !onDemand { + delete(gcsymset, t) + } + + // ../../../../reflect/type.go:/^type.rtype + // actual type structure + // type rtype struct { + // size uintptr + // ptrdata uintptr + // hash uint32 + // tflag tflag + // align uint8 + // fieldAlign uint8 + // kind uint8 + // equal func(unsafe.Pointer, unsafe.Pointer) bool + // gcdata *byte + // str nameOff + // ptrToThis typeOff + // } + c.Field("Size_").WriteUintptr(uint64(t.Size())) + c.Field("PtrBytes").WriteUintptr(uint64(ptrdata)) + c.Field("Hash").WriteUint32(types.TypeHash(t)) + + var tflag abi.TFlag + if uncommonSize(t) != 0 { + tflag |= abi.TFlagUncommon + } + if t.Sym() != nil && t.Sym().Name != "" { + tflag |= abi.TFlagNamed + } + if compare.IsRegularMemory(t) { + tflag |= abi.TFlagRegularMemory + } + if onDemand { + tflag |= abi.TFlagGCMaskOnDemand + } + + exported := false + p := t.NameString() + // If we're writing out type T, + // we are very likely to write out type *T as well. + // Use the string "*T"[1:] for "T", so that the two + // share storage. This is a cheap way to reduce the + // amount of space taken up by reflect strings. + if !strings.HasPrefix(p, "*") { + p = "*" + p + tflag |= abi.TFlagExtraStar + if t.Sym() != nil { + exported = types.IsExported(t.Sym().Name) + } + } else { + if t.Elem() != nil && t.Elem().Sym() != nil { + exported = types.IsExported(t.Elem().Sym().Name) + } + } + if types.IsDirectIface(t) { + tflag |= abi.TFlagDirectIface + } + + if tflag != abi.TFlag(uint8(tflag)) { + // this should optimize away completely + panic("Unexpected change in size of abi.TFlag") + } + c.Field("TFlag").WriteUint8(uint8(tflag)) + + // runtime (and common sense) expects alignment to be a power of two. + i := int(uint8(t.Alignment())) + + if i == 0 { + i = 1 + } + if i&(i-1) != 0 { + base.Fatalf("invalid alignment %d for %v", uint8(t.Alignment()), t) + } + c.Field("Align_").WriteUint8(uint8(t.Alignment())) + c.Field("FieldAlign_").WriteUint8(uint8(t.Alignment())) + + c.Field("Kind_").WriteUint8(uint8(ABIKindOfType(t))) + + c.Field("Equal").WritePtr(eqfunc) + c.Field("GCData").WritePtr(gcsym) + + nsym := dname(p, "", nil, exported, false) + c.Field("Str").WriteSymPtrOff(nsym, false) + c.Field("PtrToThis").WriteSymPtrOff(sptr, sptrWeak) +} + +// TrackSym returns the symbol for tracking use of field/method f, assumed +// to be a member of struct/interface type t. +func TrackSym(t *types.Type, f *types.Field) *obj.LSym { + return base.PkgLinksym("go:track", t.LinkString()+"."+f.Sym.Name, obj.ABI0) +} + +func TypeSymPrefix(prefix string, t *types.Type) *types.Sym { + p := prefix + "." + t.LinkString() + s := types.TypeSymLookup(p) + + // This function is for looking up type-related generated functions + // (e.g. eq and hash). Make sure they are indeed generated. + signatmu.Lock() + NeedRuntimeType(t) + signatmu.Unlock() + + //print("algsym: %s -> %+S\n", p, s); + + return s +} + +func TypeSym(t *types.Type) *types.Sym { + if t == nil || (t.IsPtr() && t.Elem() == nil) || t.IsUntyped() { + base.Fatalf("TypeSym %v", t) + } + if t.Kind() == types.TFUNC && t.Recv() != nil { + base.Fatalf("misuse of method type: %v", t) + } + s := types.TypeSym(t) + signatmu.Lock() + NeedRuntimeType(t) + signatmu.Unlock() + return s +} + +func TypeLinksymPrefix(prefix string, t *types.Type) *obj.LSym { + return TypeSymPrefix(prefix, t).Linksym() +} + +func TypeLinksymLookup(name string) *obj.LSym { + return types.TypeSymLookup(name).Linksym() +} + +func TypeLinksym(t *types.Type) *obj.LSym { + lsym := TypeSym(t).Linksym() + signatmu.Lock() + if lsym.Extra == nil { + ti := lsym.NewTypeInfo() + ti.Type = t + } + signatmu.Unlock() + return lsym +} + +// TypePtrAt returns an expression that evaluates to the +// *runtime._type value for t. +func TypePtrAt(pos src.XPos, t *types.Type) *ir.AddrExpr { + return typecheck.LinksymAddr(pos, TypeLinksym(t), types.Types[types.TUINT8]) +} + +// ITabLsym returns the LSym representing the itab for concrete type typ implementing +// interface iface. A dummy tab will be created in the unusual case where typ doesn't +// implement iface. Normally, this wouldn't happen, because the typechecker would +// have reported a compile-time error. This situation can only happen when the +// destination type of a type assert or a type in a type switch is parameterized, so +// it may sometimes, but not always, be a type that can't implement the specified +// interface. +func ITabLsym(typ, iface *types.Type) *obj.LSym { + return itabLsym(typ, iface, true) +} + +func itabLsym(typ, iface *types.Type, allowNonImplement bool) *obj.LSym { + s, existed := ir.Pkgs.Itab.LookupOK(typ.LinkString() + "," + iface.LinkString()) + lsym := s.Linksym() + signatmu.Lock() + if lsym.Extra == nil { + ii := lsym.NewItabInfo() + ii.Type = typ + } + signatmu.Unlock() + + if !existed { + writeITab(lsym, typ, iface, allowNonImplement) + } + return lsym +} + +// ITabAddrAt returns an expression that evaluates to the +// *runtime.itab value for concrete type typ implementing interface +// iface. +func ITabAddrAt(pos src.XPos, typ, iface *types.Type) *ir.AddrExpr { + lsym := itabLsym(typ, iface, false) + return typecheck.LinksymAddr(pos, lsym, types.Types[types.TUINT8]) +} + +// needkeyupdate reports whether map updates with t as a key +// need the key to be updated. +func needkeyupdate(t *types.Type) bool { + switch t.Kind() { + case types.TBOOL, types.TINT, types.TUINT, types.TINT8, types.TUINT8, types.TINT16, types.TUINT16, types.TINT32, types.TUINT32, + types.TINT64, types.TUINT64, types.TUINTPTR, types.TPTR, types.TUNSAFEPTR, types.TCHAN: + return false + + case types.TFLOAT32, types.TFLOAT64, types.TCOMPLEX64, types.TCOMPLEX128, // floats and complex can be +0/-0 + types.TINTER, + types.TSTRING: // strings might have smaller backing stores + return true + + case types.TARRAY: + return needkeyupdate(t.Elem()) + + case types.TSTRUCT: + for _, t1 := range t.Fields() { + if needkeyupdate(t1.Type) { + return true + } + } + return false + + default: + base.Fatalf("bad type for map key: %v", t) + return true + } +} + +// hashMightPanic reports whether the hash of a map key of type t might panic. +func hashMightPanic(t *types.Type) bool { + switch t.Kind() { + case types.TINTER: + return true + + case types.TARRAY: + return hashMightPanic(t.Elem()) + + case types.TSTRUCT: + for _, t1 := range t.Fields() { + if hashMightPanic(t1.Type) { + return true + } + } + return false + + default: + return false + } +} + +// formalType replaces predeclared aliases with real types. +// They've been separate internally to make error messages +// better, but we have to merge them in the reflect tables. +func formalType(t *types.Type) *types.Type { + switch t { + case types.AnyType, types.ByteType, types.RuneType: + return types.Types[t.Kind()] + } + return t +} + +func writeType(t *types.Type) *obj.LSym { + t = formalType(t) + if t.IsUntyped() { + base.Fatalf("writeType %v", t) + } + + s := types.TypeSym(t) + lsym := s.Linksym() + + // special case (look for runtime below): + // when compiling package runtime, + // emit the type structures for int, float, etc. + tbase := t + if t.IsPtr() && t.Sym() == nil && t.Elem().Sym() != nil { + tbase = t.Elem() + } + if tbase.Kind() == types.TFORW { + base.Fatalf("unresolved defined type: %v", tbase) + } + + // This is a fake type we generated for our builtin pseudo-runtime + // package. We'll emit a description for the real type while + // compiling package runtime, so we don't need or want to emit one + // from this fake type. + if sym := tbase.Sym(); sym != nil && sym.Pkg == ir.Pkgs.Runtime { + return lsym + } + + if s.Siggen() { + return lsym + } + s.SetSiggen(true) + + if !tbase.HasShape() { + TypeLinksym(t) // ensure lsym.Extra is set + } + + if !NeedEmit(tbase) { + if i := typecheck.BaseTypeIndex(t); i >= 0 { + lsym.Pkg = tbase.Sym().Pkg.Prefix + lsym.SymIdx = int32(i) + lsym.Set(obj.AttrIndexed, true) + } + + // TODO(mdempsky): Investigate whether this still happens. + // If we know we don't need to emit code for a type, + // we should have a link-symbol index for it. + // See also TODO in NeedEmit. + return lsym + } + + // Type layout Written by Marker + // +--------------------------------+ - 0 + // | abi/internal.Type | dcommontype + // +--------------------------------+ - A + // | additional type-dependent | code in the switch below + // | fields, e.g. | + // | abi/internal.ArrayType.Len | + // +--------------------------------+ - B + // | internal/abi.UncommonType | dextratype + // | This section is optional, | + // | if type has a name or methods | + // +--------------------------------+ - C + // | variable-length data | code in the switch below + // | referenced by | + // | type-dependent fields, e.g. | + // | abi/internal.StructType.Fields | + // | dataAdd = size of this section | + // +--------------------------------+ - D + // | method list, if any | dextratype + // +--------------------------------+ - E + + // UncommonType section is included if we have a name or a method. + extra := t.Sym() != nil || len(methods(t)) != 0 + + // Decide the underlying type of the descriptor, and remember + // the size we need for variable-length data. + var rt *types.Type + dataAdd := 0 + switch t.Kind() { + default: + rt = rttype.Type + case types.TARRAY: + rt = rttype.ArrayType + case types.TSLICE: + rt = rttype.SliceType + case types.TCHAN: + rt = rttype.ChanType + case types.TFUNC: + rt = rttype.FuncType + dataAdd = (t.NumRecvs() + t.NumParams() + t.NumResults()) * types.PtrSize + case types.TINTER: + rt = rttype.InterfaceType + dataAdd = len(imethods(t)) * int(rttype.IMethod.Size()) + case types.TMAP: + rt = rttype.MapType + case types.TPTR: + rt = rttype.PtrType + // TODO: use rttype.Type for Elem() is ANY? + case types.TSTRUCT: + rt = rttype.StructType + dataAdd = t.NumFields() * int(rttype.StructField.Size()) + } + + // Compute offsets of each section. + B := rt.Size() + C := B + if extra { + C = B + rttype.UncommonType.Size() + } + D := C + int64(dataAdd) + E := D + int64(len(methods(t)))*rttype.Method.Size() + + // Write the runtime._type + c := rttype.NewCursor(lsym, 0, rt) + if rt == rttype.Type { + dcommontype(c, t) + } else { + dcommontype(c.Field("Type"), t) + } + + // Write additional type-specific data + // (Both the fixed size and variable-sized sections.) + switch t.Kind() { + case types.TARRAY: + // internal/abi.ArrayType + s1 := writeType(t.Elem()) + t2 := types.NewSlice(t.Elem()) + s2 := writeType(t2) + c.Field("Elem").WritePtr(s1) + c.Field("Slice").WritePtr(s2) + c.Field("Len").WriteUintptr(uint64(t.NumElem())) + + case types.TSLICE: + // internal/abi.SliceType + s1 := writeType(t.Elem()) + c.Field("Elem").WritePtr(s1) + + case types.TCHAN: + // internal/abi.ChanType + s1 := writeType(t.Elem()) + c.Field("Elem").WritePtr(s1) + c.Field("Dir").WriteInt(int64(t.ChanDir())) + + case types.TFUNC: + // internal/abi.FuncType + for _, t1 := range t.RecvParamsResults() { + writeType(t1.Type) + } + inCount := t.NumRecvs() + t.NumParams() + outCount := t.NumResults() + if t.IsVariadic() { + outCount |= 1 << 15 + } + + c.Field("InCount").WriteUint16(uint16(inCount)) + c.Field("OutCount").WriteUint16(uint16(outCount)) + + // Array of rtype pointers follows funcType. + typs := t.RecvParamsResults() + array := rttype.NewArrayCursor(lsym, C, types.Types[types.TUNSAFEPTR], len(typs)) + for i, t1 := range typs { + array.Elem(i).WritePtr(writeType(t1.Type)) + } + + case types.TINTER: + // internal/abi.InterfaceType + m := imethods(t) + n := len(m) + for _, a := range m { + writeType(a.type_) + } + + var tpkg *types.Pkg + if t.Sym() != nil && t != types.Types[t.Kind()] && t != types.ErrorType { + tpkg = t.Sym().Pkg + } + dgopkgpath(c.Field("PkgPath"), tpkg) + c.Field("Methods").WriteSlice(lsym, C, int64(n), int64(n)) + + array := rttype.NewArrayCursor(lsym, C, rttype.IMethod, n) + for i, a := range m { + exported := types.IsExported(a.name.Name) + var pkg *types.Pkg + if !exported && a.name.Pkg != tpkg { + pkg = a.name.Pkg + } + nsym := dname(a.name.Name, "", pkg, exported, false) + + e := array.Elem(i) + e.Field("Name").WriteSymPtrOff(nsym, false) + e.Field("Typ").WriteSymPtrOff(writeType(a.type_), false) + } + + case types.TMAP: + writeMapType(t, lsym, c) + + case types.TPTR: + // internal/abi.PtrType + if t.Elem().Kind() == types.TANY { + base.Fatalf("bad pointer base type") + } + + s1 := writeType(t.Elem()) + c.Field("Elem").WritePtr(s1) + + case types.TSTRUCT: + // internal/abi.StructType + fields := t.Fields() + for _, t1 := range fields { + writeType(t1.Type) + } + + // All non-exported struct field names within a struct + // type must originate from a single package. By + // identifying and recording that package within the + // struct type descriptor, we can omit that + // information from the field descriptors. + var spkg *types.Pkg + for _, f := range fields { + if !types.IsExported(f.Sym.Name) { + spkg = f.Sym.Pkg + break + } + } + + dgopkgpath(c.Field("PkgPath"), spkg) + c.Field("Fields").WriteSlice(lsym, C, int64(len(fields)), int64(len(fields))) + + array := rttype.NewArrayCursor(lsym, C, rttype.StructField, len(fields)) + for i, f := range fields { + e := array.Elem(i) + dnameField(e.Field("Name"), spkg, f) + e.Field("Typ").WritePtr(writeType(f.Type)) + e.Field("Offset").WriteUintptr(uint64(f.Offset)) + } + } + + // Write the extra info, if any. + if extra { + dextratype(lsym, B, t, dataAdd) + } + + // Note: DUPOK is required to ensure that we don't end up with more + // than one type descriptor for a given type, if the type descriptor + // can be defined in multiple packages, that is, unnamed types, + // instantiated types and shape types. + dupok := 0 + if tbase.Sym() == nil || tbase.IsFullyInstantiated() || tbase.HasShape() { + dupok = obj.DUPOK + } + + objw.Global(lsym, int32(E), int16(dupok|obj.RODATA)) + + // The linker will leave a table of all the typelinks for + // types in the binary, so the runtime can find them. + // + // When buildmode=shared, all types are in typelinks so the + // runtime can deduplicate type pointers. + keep := base.Ctxt.Flag_dynlink + if !keep && t.Sym() == nil { + // For an unnamed type, we only need the link if the type can + // be created at run time by reflect.PointerTo and similar + // functions. If the type exists in the program, those + // functions must return the existing type structure rather + // than creating a new one. + switch t.Kind() { + case types.TPTR, types.TARRAY, types.TCHAN, types.TFUNC, types.TMAP, types.TSLICE, types.TSTRUCT: + keep = true + } + } + // Do not put Noalg types in typelinks. See issue #22605. + if types.TypeHasNoAlg(t) { + keep = false + } + lsym.Set(obj.AttrMakeTypelink, keep) + + return lsym +} + +// InterfaceMethodOffset returns the offset of the i-th method in the interface +// type descriptor, ityp. +func InterfaceMethodOffset(ityp *types.Type, i int64) int64 { + // interface type descriptor layout is struct { + // _type // commonSize + // pkgpath // 1 word + // []imethod // 3 words (pointing to [...]imethod below) + // uncommontype // uncommonSize + // [...]imethod + // } + // The size of imethod is 8. + return int64(commonSize()+4*types.PtrSize+uncommonSize(ityp)) + i*8 +} + +// NeedRuntimeType ensures that a runtime type descriptor is emitted for t. +func NeedRuntimeType(t *types.Type) { + if _, ok := signatset[t]; !ok { + signatset[t] = struct{}{} + signatslice = append(signatslice, typeAndStr{t: t, short: types.TypeSymName(t), regular: t.String()}) + } +} + +func WriteRuntimeTypes() { + // Process signatslice. Use a loop, as writeType adds + // entries to signatslice while it is being processed. + for len(signatslice) > 0 { + signats := signatslice + // Sort for reproducible builds. + slices.SortFunc(signats, typesStrCmp) + for _, ts := range signats { + t := ts.t + writeType(t) + if t.Sym() != nil { + writeType(types.NewPtr(t)) + } + } + signatslice = signatslice[len(signats):] + } +} + +func WriteGCSymbols() { + // Emit GC data symbols. + gcsyms := make([]typeAndStr, 0, len(gcsymset)) + for t := range gcsymset { + gcsyms = append(gcsyms, typeAndStr{t: t, short: types.TypeSymName(t), regular: t.String()}) + } + slices.SortFunc(gcsyms, typesStrCmp) + for _, ts := range gcsyms { + dgcsym(ts.t, true, false) + } +} + +// writeITab writes the itab for concrete type typ implementing interface iface. If +// allowNonImplement is true, allow the case where typ does not implement iface, and just +// create a dummy itab with zeroed-out method entries. +func writeITab(lsym *obj.LSym, typ, iface *types.Type, allowNonImplement bool) { + // TODO(mdempsky): Fix methodWrapper, geneq, and genhash (and maybe + // others) to stop clobbering these. + oldpos, oldfn := base.Pos, ir.CurFunc + defer func() { base.Pos, ir.CurFunc = oldpos, oldfn }() + + if typ == nil || (typ.IsPtr() && typ.Elem() == nil) || typ.IsUntyped() || iface == nil || !iface.IsInterface() || iface.IsEmptyInterface() { + base.Fatalf("writeITab(%v, %v)", typ, iface) + } + + sigs := iface.AllMethods() + entries := make([]*obj.LSym, 0, len(sigs)) + + // both sigs and methods are sorted by name, + // so we can find the intersection in a single pass + for _, m := range methods(typ) { + if m.name == sigs[0].Sym { + entries = append(entries, m.isym) + if m.isym == nil { + panic("NO ISYM") + } + sigs = sigs[1:] + if len(sigs) == 0 { + break + } + } + } + completeItab := len(sigs) == 0 + if !allowNonImplement && !completeItab { + base.Fatalf("incomplete itab") + } + + // dump empty itab symbol into i.sym + // type itab struct { + // inter *interfacetype + // _type *_type + // hash uint32 // copy of _type.hash. Used for type switches. + // _ [4]byte + // fun [1]uintptr // variable sized. fun[0]==0 means _type does not implement inter. + // } + c := rttype.NewCursor(lsym, 0, rttype.ITab) + c.Field("Inter").WritePtr(writeType(iface)) + c.Field("Type").WritePtr(writeType(typ)) + c.Field("Hash").WriteUint32(types.TypeHash(typ)) // copy of type hash + + var delta int64 + c = c.Field("Fun") + if !completeItab { + // If typ doesn't implement iface, make method entries be zero. + c.Elem(0).WriteUintptr(0) + } else { + var a rttype.ArrayCursor + a, delta = c.ModifyArray(len(entries)) + for i, fn := range entries { + a.Elem(i).WritePtrWeak(fn) // method pointer for each method + } + } + // Nothing writes static itabs, so they are read only. + objw.Global(lsym, int32(rttype.ITab.Size()+delta), int16(obj.DUPOK|obj.RODATA)) + lsym.Set(obj.AttrContentAddressable, true) +} + +func WritePluginTable() { + ptabs := typecheck.Target.PluginExports + if len(ptabs) == 0 { + return + } + + lsym := base.Ctxt.Lookup("go:plugin.tabs") + ot := 0 + for _, p := range ptabs { + // Dump ptab symbol into go.pluginsym package. + // + // type ptab struct { + // name nameOff + // typ typeOff // pointer to symbol + // } + nsym := dname(p.Sym().Name, "", nil, true, false) + t := p.Type() + if p.Class != ir.PFUNC { + t = types.NewPtr(t) + } + tsym := writeType(t) + ot = objw.SymPtrOff(lsym, ot, nsym) + ot = objw.SymPtrOff(lsym, ot, tsym) + // Plugin exports symbols as interfaces. Mark their types + // as UsedInIface. + tsym.Set(obj.AttrUsedInIface, true) + } + objw.Global(lsym, int32(ot), int16(obj.RODATA)) + + lsym = base.Ctxt.Lookup("go:plugin.exports") + ot = 0 + for _, p := range ptabs { + ot = objw.SymPtr(lsym, ot, p.Linksym(), 0) + } + objw.Global(lsym, int32(ot), int16(obj.RODATA)) +} + +// writtenByWriteBasicTypes reports whether typ is written by WriteBasicTypes. +// WriteBasicTypes always writes pointer types; any pointer has been stripped off typ already. +func writtenByWriteBasicTypes(typ *types.Type) bool { + if typ.Sym() == nil && typ.Kind() == types.TFUNC { + // func(error) string + if typ.NumRecvs() == 0 && + typ.NumParams() == 1 && typ.NumResults() == 1 && + typ.Param(0).Type == types.ErrorType && + typ.Result(0).Type == types.Types[types.TSTRING] { + return true + } + } + + // Now we have left the basic types plus any and error, plus slices of them. + // Strip the slice. + if typ.Sym() == nil && typ.IsSlice() { + typ = typ.Elem() + } + + // Basic types. + sym := typ.Sym() + if sym != nil && (sym.Pkg == types.BuiltinPkg || sym.Pkg == types.UnsafePkg) { + return true + } + // any or error + return (sym == nil && typ.IsEmptyInterface()) || typ == types.ErrorType +} + +func WriteBasicTypes() { + // do basic types if compiling package runtime. + // they have to be in at least one package, + // and runtime is always loaded implicitly, + // so this is as good as any. + // another possible choice would be package main, + // but using runtime means fewer copies in object files. + // The code here needs to be in sync with writtenByWriteBasicTypes above. + if base.Ctxt.Pkgpath != "runtime" { + return + } + + // Note: always write NewPtr(t) because NeedEmit's caller strips the pointer. + var list []*types.Type + for i := types.Kind(1); i <= types.TBOOL; i++ { + list = append(list, types.Types[i]) + } + list = append(list, + types.Types[types.TSTRING], + types.Types[types.TUNSAFEPTR], + types.AnyType, + types.ErrorType) + for _, t := range list { + writeType(types.NewPtr(t)) + writeType(types.NewPtr(types.NewSlice(t))) + } + + // emit type for func(error) string, + // which is the type of an auto-generated wrapper. + writeType(types.NewPtr(types.NewSignature(nil, []*types.Field{ + types.NewField(base.Pos, nil, types.ErrorType), + }, []*types.Field{ + types.NewField(base.Pos, nil, types.Types[types.TSTRING]), + }))) +} + +type typeAndStr struct { + t *types.Type + short string // "short" here means TypeSymName + regular string +} + +func typesStrCmp(a, b typeAndStr) int { + // put named types before unnamed types + if a.t.Sym() != nil && b.t.Sym() == nil { + return -1 + } + if a.t.Sym() == nil && b.t.Sym() != nil { + return +1 + } + + if r := strings.Compare(a.short, b.short); r != 0 { + return r + } + // When the only difference between the types is whether + // they refer to byte or uint8, such as **byte vs **uint8, + // the types' NameStrings can be identical. + // To preserve deterministic sort ordering, sort these by String(). + // + // TODO(mdempsky): This all seems suspect. Using LinkString would + // avoid naming collisions, and there shouldn't be a reason to care + // about "byte" vs "uint8": they share the same runtime type + // descriptor anyway. + if r := strings.Compare(a.regular, b.regular); r != 0 { + return r + } + // Identical anonymous interfaces defined in different locations + // will be equal for the above checks, but different in DWARF output. + // Sort by source position to ensure deterministic order. + // See issues 27013 and 30202. + if a.t.Kind() == types.TINTER && len(a.t.AllMethods()) > 0 { + if a.t.AllMethods()[0].Pos.Before(b.t.AllMethods()[0].Pos) { + return -1 + } + return +1 + } + return 0 +} + +// GCSym returns a data symbol containing GC information for type t. +// GC information is always a bitmask, never a gc program. +// GCSym may be called in concurrent backend, so it does not emit the symbol +// content. +func GCSym(t *types.Type, onDemandAllowed bool) (lsym *obj.LSym, ptrdata int64) { + // Record that we need to emit the GC symbol. + gcsymmu.Lock() + if _, ok := gcsymset[t]; !ok { + gcsymset[t] = struct{}{} + } + gcsymmu.Unlock() + + lsym, _, ptrdata = dgcsym(t, false, onDemandAllowed) + return +} + +// dgcsym returns a data symbol containing GC information for type t, along +// with a boolean reporting whether the gc mask should be computed on demand +// at runtime, and the ptrdata field to record in the reflect type information. +// When write is true, it writes the symbol data. +func dgcsym(t *types.Type, write, onDemandAllowed bool) (lsym *obj.LSym, onDemand bool, ptrdata int64) { + ptrdata = types.PtrDataSize(t) + if !onDemandAllowed || ptrdata/int64(types.PtrSize) <= abi.MaxPtrmaskBytes*8 { + lsym = dgcptrmask(t, write) + return + } + + onDemand = true + lsym = dgcptrmaskOnDemand(t, write) + return +} + +// dgcptrmask emits and returns the symbol containing a pointer mask for type t. +func dgcptrmask(t *types.Type, write bool) *obj.LSym { + // Bytes we need for the ptrmask. + n := (types.PtrDataSize(t)/int64(types.PtrSize) + 7) / 8 + // Runtime wants ptrmasks padded to a multiple of uintptr in size. + n = (n + int64(types.PtrSize) - 1) &^ (int64(types.PtrSize) - 1) + ptrmask := make([]byte, n) + fillptrmask(t, ptrmask) + p := fmt.Sprintf("runtime.gcbits.%x", ptrmask) + + lsym := base.Ctxt.Lookup(p) + if write && !lsym.OnList() { + for i, x := range ptrmask { + objw.Uint8(lsym, i, x) + } + objw.Global(lsym, int32(len(ptrmask)), obj.DUPOK|obj.RODATA|obj.LOCAL) + lsym.Set(obj.AttrContentAddressable, true) + } + return lsym +} + +// fillptrmask fills in ptrmask with 1s corresponding to the +// word offsets in t that hold pointers. +// ptrmask is assumed to fit at least types.PtrDataSize(t)/PtrSize bits. +func fillptrmask(t *types.Type, ptrmask []byte) { + if !t.HasPointers() { + return + } + + vec := bitvec.New(8 * int32(len(ptrmask))) + typebits.Set(t, 0, vec) + + nptr := types.PtrDataSize(t) / int64(types.PtrSize) + for i := int64(0); i < nptr; i++ { + if vec.Get(int32(i)) { + ptrmask[i/8] |= 1 << (uint(i) % 8) + } + } +} + +// dgcptrmaskOnDemand emits and returns the symbol that should be referenced by +// the GCData field of a type, for large types. +func dgcptrmaskOnDemand(t *types.Type, write bool) *obj.LSym { + lsym := TypeLinksymPrefix(".gcmask", t) + if write && !lsym.OnList() { + // Note: contains a pointer, but a pointer to a + // persistentalloc allocation. Starts with nil. + objw.Uintptr(lsym, 0, 0) + objw.Global(lsym, int32(types.PtrSize), obj.DUPOK|obj.NOPTR|obj.LOCAL) // TODO:bss? + } + return lsym +} + +// ZeroAddr returns the address of a symbol with at least +// size bytes of zeros. +func ZeroAddr(size int64) ir.Node { + if size >= 1<<31 { + base.Fatalf("map elem too big %d", size) + } + if ZeroSize < size { + ZeroSize = size + } + lsym := base.PkgLinksym("go:map", "zero", obj.ABI0) + x := ir.NewLinksymExpr(base.Pos, lsym, types.Types[types.TUINT8]) + return typecheck.Expr(typecheck.NodAddr(x)) +} + +// NeedEmit reports whether typ is a type that we need to emit code +// for (e.g., runtime type descriptors, method wrappers). +func NeedEmit(typ *types.Type) bool { + // TODO(mdempsky): Export data should keep track of which anonymous + // and instantiated types were emitted, so at least downstream + // packages can skip re-emitting them. + // + // Perhaps we can just generalize the linker-symbol indexing to + // track the index of arbitrary types, not just defined types, and + // use its presence to detect this. The same idea would work for + // instantiated generic functions too. + + switch sym := typ.Sym(); { + case writtenByWriteBasicTypes(typ): + return base.Ctxt.Pkgpath == "runtime" + + case sym == nil: + // Anonymous type; possibly never seen before or ever again. + // Need to emit to be safe (however, see TODO above). + return true + + case sym.Pkg == types.LocalPkg: + // Local defined type; our responsibility. + return true + + case typ.IsFullyInstantiated(): + // Instantiated type; possibly instantiated with unique type arguments. + // Need to emit to be safe (however, see TODO above). + return true + + case typ.HasShape(): + // Shape type; need to emit even though it lives in the .shape package. + // TODO: make sure the linker deduplicates them (see dupok in writeType above). + return true + + default: + // Should have been emitted by an imported package. + return false + } +} + +// Generate a wrapper function to convert from +// a receiver of type T to a receiver of type U. +// That is, +// +// func (t T) M() { +// ... +// } +// +// already exists; this function generates +// +// func (u U) M() { +// u.M() +// } +// +// where the types T and U are such that u.M() is valid +// and calls the T.M method. +// The resulting function is for use in method tables. +// +// rcvr - U +// method - M func (t T)(), a TFIELD type struct +// +// Also wraps methods on instantiated generic types for use in itab entries. +// For an instantiated generic type G[int], we generate wrappers like: +// G[int] pointer shaped: +// +// func (x G[int]) f(arg) { +// .inst.G[int].f(dictionary, x, arg) +// } +// +// G[int] not pointer shaped: +// +// func (x *G[int]) f(arg) { +// .inst.G[int].f(dictionary, *x, arg) +// } +// +// These wrappers are always fully stenciled. +func methodWrapper(rcvr *types.Type, method *types.Field, forItab bool) *obj.LSym { + if forItab && !types.IsDirectIface(rcvr) { + rcvr = rcvr.PtrTo() + } + + newnam := ir.MethodSym(rcvr, method.Sym) + lsym := newnam.Linksym() + + // Unified IR creates its own wrappers. + return lsym +} + +var ZeroSize int64 + +// MarkTypeUsedInInterface marks that type t is converted to an interface. +// This information is used in the linker in dead method elimination. +func MarkTypeUsedInInterface(t *types.Type, from *obj.LSym) { + if t.HasShape() { + // Shape types shouldn't be put in interfaces, so we shouldn't ever get here. + base.Fatalf("shape types have no methods %+v", t) + } + MarkTypeSymUsedInInterface(TypeLinksym(t), from) +} +func MarkTypeSymUsedInInterface(tsym *obj.LSym, from *obj.LSym) { + // Emit a marker relocation. The linker will know the type is converted + // to an interface if "from" is reachable. + from.AddRel(base.Ctxt, obj.Reloc{Type: objabi.R_USEIFACE, Sym: tsym}) +} + +// MarkUsedIfaceMethod marks that an interface method is used in the current +// function. n is OCALLINTER node. +func MarkUsedIfaceMethod(n *ir.CallExpr) { + // skip unnamed functions (func _()) + if ir.CurFunc.LSym == nil { + return + } + dot := n.Fun.(*ir.SelectorExpr) + ityp := dot.X.Type() + if ityp.HasShape() { + // Here we're calling a method on a generic interface. Something like: + // + // type I[T any] interface { foo() T } + // func f[T any](x I[T]) { + // ... = x.foo() + // } + // f[int](...) + // f[string](...) + // + // In this case, in f we're calling foo on a generic interface. + // Which method could that be? Normally we could match the method + // both by name and by type. But in this case we don't really know + // the type of the method we're calling. It could be func()int + // or func()string. So we match on just the function name, instead + // of both the name and the type used for the non-generic case below. + // TODO: instantiations at least know the shape of the instantiated + // type, and the linker could do more complicated matching using + // some sort of fuzzy shape matching. For now, only use the name + // of the method for matching. + ir.CurFunc.LSym.AddRel(base.Ctxt, obj.Reloc{ + Type: objabi.R_USENAMEDMETHOD, + Sym: staticdata.StringSymNoCommon(dot.Sel.Name), + }) + return + } + + // dot.Offset() is the method index * PtrSize (the offset of code pointer in itab). + midx := dot.Offset() / int64(types.PtrSize) + ir.CurFunc.LSym.AddRel(base.Ctxt, obj.Reloc{ + Type: objabi.R_USEIFACEMETHOD, + Sym: TypeLinksym(ityp), + Add: InterfaceMethodOffset(ityp, midx), + }) +} diff --git a/go/src/cmd/compile/internal/riscv64/galign.go b/go/src/cmd/compile/internal/riscv64/galign.go new file mode 100644 index 0000000000000000000000000000000000000000..4244afba3e19689286c03633849890e449facb32 --- /dev/null +++ b/go/src/cmd/compile/internal/riscv64/galign.go @@ -0,0 +1,26 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package riscv64 + +import ( + "cmd/compile/internal/ssagen" + "cmd/internal/obj/riscv" +) + +func Init(arch *ssagen.ArchInfo) { + arch.LinkArch = &riscv.LinkRISCV64 + + arch.REGSP = riscv.REG_SP + arch.MAXWIDTH = 1 << 50 + + arch.Ginsnop = ginsnop + arch.ZeroRange = zeroRange + + arch.SSAMarkMoves = ssaMarkMoves + arch.SSAGenValue = ssaGenValue + arch.SSAGenBlock = ssaGenBlock + arch.LoadRegResult = loadRegResult + arch.SpillArgReg = spillArgReg +} diff --git a/go/src/cmd/compile/internal/riscv64/ggen.go b/go/src/cmd/compile/internal/riscv64/ggen.go new file mode 100644 index 0000000000000000000000000000000000000000..d8afb01f3b81b5dcc570217251caacea724d9291 --- /dev/null +++ b/go/src/cmd/compile/internal/riscv64/ggen.go @@ -0,0 +1,31 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package riscv64 + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/objw" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/riscv" +) + +func zeroRange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { + + if cnt%int64(types.PtrSize) != 0 { + panic("zeroed region not aligned") + } + + // Adjust the frame to account for LR. + off += base.Ctxt.Arch.FixedFrameSize + + for cnt != 0 { + p = pp.Append(p, riscv.AMOV, obj.TYPE_REG, riscv.REG_ZERO, 0, obj.TYPE_MEM, riscv.REG_SP, off) + cnt -= int64(types.PtrSize) + off += int64(types.PtrSize) + } + + return p +} diff --git a/go/src/cmd/compile/internal/riscv64/gsubr.go b/go/src/cmd/compile/internal/riscv64/gsubr.go new file mode 100644 index 0000000000000000000000000000000000000000..74bccf8d42ab1b00cad26b7c06e79b8824bf294e --- /dev/null +++ b/go/src/cmd/compile/internal/riscv64/gsubr.go @@ -0,0 +1,20 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package riscv64 + +import ( + "cmd/compile/internal/objw" + "cmd/internal/obj" + "cmd/internal/obj/riscv" +) + +func ginsnop(pp *objw.Progs) *obj.Prog { + // Hardware nop is ADD $0, ZERO + p := pp.Prog(riscv.AADD) + p.From.Type = obj.TYPE_CONST + p.Reg = riscv.REG_ZERO + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: riscv.REG_ZERO} + return p +} diff --git a/go/src/cmd/compile/internal/riscv64/ssa.go b/go/src/cmd/compile/internal/riscv64/ssa.go new file mode 100644 index 0000000000000000000000000000000000000000..9aa77c3d02bd914fb5d9591a9821928c50b458c6 --- /dev/null +++ b/go/src/cmd/compile/internal/riscv64/ssa.go @@ -0,0 +1,1092 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package riscv64 + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/objw" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/riscv" + "internal/abi" +) + +// ssaRegToReg maps ssa register numbers to obj register numbers. +var ssaRegToReg = []int16{ + riscv.REG_X0, + // X1 (LR): unused + riscv.REG_X2, + riscv.REG_X3, + riscv.REG_X4, + riscv.REG_X5, + riscv.REG_X6, + riscv.REG_X7, + riscv.REG_X8, + riscv.REG_X9, + riscv.REG_X10, + riscv.REG_X11, + riscv.REG_X12, + riscv.REG_X13, + riscv.REG_X14, + riscv.REG_X15, + riscv.REG_X16, + riscv.REG_X17, + riscv.REG_X18, + riscv.REG_X19, + riscv.REG_X20, + riscv.REG_X21, + riscv.REG_X22, + riscv.REG_X23, + riscv.REG_X24, + riscv.REG_X25, + riscv.REG_X26, + riscv.REG_X27, + riscv.REG_X28, + riscv.REG_X29, + riscv.REG_X30, + riscv.REG_X31, + riscv.REG_F0, + riscv.REG_F1, + riscv.REG_F2, + riscv.REG_F3, + riscv.REG_F4, + riscv.REG_F5, + riscv.REG_F6, + riscv.REG_F7, + riscv.REG_F8, + riscv.REG_F9, + riscv.REG_F10, + riscv.REG_F11, + riscv.REG_F12, + riscv.REG_F13, + riscv.REG_F14, + riscv.REG_F15, + riscv.REG_F16, + riscv.REG_F17, + riscv.REG_F18, + riscv.REG_F19, + riscv.REG_F20, + riscv.REG_F21, + riscv.REG_F22, + riscv.REG_F23, + riscv.REG_F24, + riscv.REG_F25, + riscv.REG_F26, + riscv.REG_F27, + riscv.REG_F28, + riscv.REG_F29, + riscv.REG_F30, + riscv.REG_F31, + 0, // SB isn't a real register. We fill an Addr.Reg field with 0 in this case. +} + +func loadByType(t *types.Type) obj.As { + width := t.Size() + + if t.IsFloat() { + switch width { + case 4: + return riscv.AMOVF + case 8: + return riscv.AMOVD + default: + base.Fatalf("unknown float width for load %d in type %v", width, t) + return 0 + } + } + + switch width { + case 1: + if t.IsSigned() { + return riscv.AMOVB + } else { + return riscv.AMOVBU + } + case 2: + if t.IsSigned() { + return riscv.AMOVH + } else { + return riscv.AMOVHU + } + case 4: + if t.IsSigned() { + return riscv.AMOVW + } else { + return riscv.AMOVWU + } + case 8: + return riscv.AMOV + default: + base.Fatalf("unknown width for load %d in type %v", width, t) + return 0 + } +} + +// storeByType returns the store instruction of the given type. +func storeByType(t *types.Type) obj.As { + width := t.Size() + + if t.IsFloat() { + switch width { + case 4: + return riscv.AMOVF + case 8: + return riscv.AMOVD + default: + base.Fatalf("unknown float width for store %d in type %v", width, t) + return 0 + } + } + + switch width { + case 1: + return riscv.AMOVB + case 2: + return riscv.AMOVH + case 4: + return riscv.AMOVW + case 8: + return riscv.AMOV + default: + base.Fatalf("unknown width for store %d in type %v", width, t) + return 0 + } +} + +// largestMove returns the largest move instruction possible and its size, +// given the alignment of the total size of the move. +// +// e.g., a 16-byte move may use MOV, but an 11-byte move must use MOVB. +// +// Note that the moves may not be on naturally aligned addresses depending on +// the source and destination. +// +// This matches the calculation in ssa.moveSize. +func largestMove(alignment int64) (obj.As, int64) { + switch { + case alignment%8 == 0: + return riscv.AMOV, 8 + case alignment%4 == 0: + return riscv.AMOVW, 4 + case alignment%2 == 0: + return riscv.AMOVH, 2 + default: + return riscv.AMOVB, 1 + } +} + +var fracMovOps = []obj.As{riscv.AMOVB, riscv.AMOVH, riscv.AMOVW, riscv.AMOV} + +// ssaMarkMoves marks any MOVXconst ops that need to avoid clobbering flags. +// RISC-V has no flags, so this is a no-op. +func ssaMarkMoves(s *ssagen.State, b *ssa.Block) {} + +func ssaGenValue(s *ssagen.State, v *ssa.Value) { + s.SetPos(v.Pos) + + switch v.Op { + case ssa.OpInitMem: + // memory arg needs no code + case ssa.OpArg: + // input args need no code + case ssa.OpPhi: + ssagen.CheckLoweredPhi(v) + case ssa.OpCopy, ssa.OpRISCV64MOVDreg: + if v.Type.IsMemory() { + return + } + rs := v.Args[0].Reg() + rd := v.Reg() + if rs == rd { + return + } + as := riscv.AMOV + if v.Type.IsFloat() { + as = riscv.AMOVD + } + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = rs + p.To.Type = obj.TYPE_REG + p.To.Reg = rd + case ssa.OpRISCV64MOVDnop: + // nothing to do + case ssa.OpLoadReg: + if v.Type.IsFlags() { + v.Fatalf("load flags not implemented: %v", v.LongString()) + return + } + p := s.Prog(loadByType(v.Type)) + ssagen.AddrAuto(&p.From, v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpStoreReg: + if v.Type.IsFlags() { + v.Fatalf("store flags not implemented: %v", v.LongString()) + return + } + p := s.Prog(storeByType(v.Type)) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + ssagen.AddrAuto(&p.To, v) + case ssa.OpArgIntReg, ssa.OpArgFloatReg: + // The assembler needs to wrap the entry safepoint/stack growth code with spill/unspill + // The loop only runs once. + for _, a := range v.Block.Func.RegArgs { + // Pass the spill/unspill information along to the assembler, offset by size of + // the saved LR slot. + addr := ssagen.SpillSlotAddr(a, riscv.REG_SP, base.Ctxt.Arch.FixedFrameSize) + s.FuncInfo().AddSpill( + obj.RegSpill{Reg: a.Reg, Addr: addr, Unspill: loadByType(a.Type), Spill: storeByType(a.Type)}) + } + v.Block.Func.RegArgs = nil + + ssagen.CheckArgReg(v) + case ssa.OpSP, ssa.OpSB, ssa.OpGetG: + // nothing to do + case ssa.OpRISCV64MOVBreg, ssa.OpRISCV64MOVHreg, ssa.OpRISCV64MOVWreg, + ssa.OpRISCV64MOVBUreg, ssa.OpRISCV64MOVHUreg, ssa.OpRISCV64MOVWUreg: + a := v.Args[0] + for a.Op == ssa.OpCopy || a.Op == ssa.OpRISCV64MOVDreg { + a = a.Args[0] + } + as := v.Op.Asm() + rs := v.Args[0].Reg() + rd := v.Reg() + if a.Op == ssa.OpLoadReg { + t := a.Type + switch { + case v.Op == ssa.OpRISCV64MOVBreg && t.Size() == 1 && t.IsSigned(), + v.Op == ssa.OpRISCV64MOVHreg && t.Size() == 2 && t.IsSigned(), + v.Op == ssa.OpRISCV64MOVWreg && t.Size() == 4 && t.IsSigned(), + v.Op == ssa.OpRISCV64MOVBUreg && t.Size() == 1 && !t.IsSigned(), + v.Op == ssa.OpRISCV64MOVHUreg && t.Size() == 2 && !t.IsSigned(), + v.Op == ssa.OpRISCV64MOVWUreg && t.Size() == 4 && !t.IsSigned(): + // arg is a proper-typed load and already sign/zero-extended + if rs == rd { + return + } + as = riscv.AMOV + default: + } + } + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = rs + p.To.Type = obj.TYPE_REG + p.To.Reg = rd + case ssa.OpRISCV64ADD, ssa.OpRISCV64SUB, ssa.OpRISCV64SUBW, ssa.OpRISCV64XNOR, ssa.OpRISCV64XOR, + ssa.OpRISCV64OR, ssa.OpRISCV64ORN, ssa.OpRISCV64AND, ssa.OpRISCV64ANDN, + ssa.OpRISCV64SLL, ssa.OpRISCV64SLLW, ssa.OpRISCV64SRA, ssa.OpRISCV64SRAW, ssa.OpRISCV64SRL, ssa.OpRISCV64SRLW, + ssa.OpRISCV64SLT, ssa.OpRISCV64SLTU, ssa.OpRISCV64MUL, ssa.OpRISCV64MULW, ssa.OpRISCV64MULH, + ssa.OpRISCV64MULHU, ssa.OpRISCV64DIV, ssa.OpRISCV64DIVU, ssa.OpRISCV64DIVW, + ssa.OpRISCV64DIVUW, ssa.OpRISCV64REM, ssa.OpRISCV64REMU, ssa.OpRISCV64REMW, + ssa.OpRISCV64REMUW, + ssa.OpRISCV64ROL, ssa.OpRISCV64ROLW, ssa.OpRISCV64ROR, ssa.OpRISCV64RORW, + ssa.OpRISCV64FADDS, ssa.OpRISCV64FSUBS, ssa.OpRISCV64FMULS, ssa.OpRISCV64FDIVS, + ssa.OpRISCV64FEQS, ssa.OpRISCV64FNES, ssa.OpRISCV64FLTS, ssa.OpRISCV64FLES, + ssa.OpRISCV64FADDD, ssa.OpRISCV64FSUBD, ssa.OpRISCV64FMULD, ssa.OpRISCV64FDIVD, + ssa.OpRISCV64FEQD, ssa.OpRISCV64FNED, ssa.OpRISCV64FLTD, ssa.OpRISCV64FLED, ssa.OpRISCV64FSGNJD, + ssa.OpRISCV64MIN, ssa.OpRISCV64MAX, ssa.OpRISCV64MINU, ssa.OpRISCV64MAXU, + ssa.OpRISCV64SH1ADD, ssa.OpRISCV64SH2ADD, ssa.OpRISCV64SH3ADD: + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.To.Type = obj.TYPE_REG + p.To.Reg = r + + case ssa.OpRISCV64LoweredFMAXD, ssa.OpRISCV64LoweredFMIND, ssa.OpRISCV64LoweredFMAXS, ssa.OpRISCV64LoweredFMINS: + // Most of FMIN/FMAX result match Go's required behaviour, unless one of the + // inputs is a NaN. As such, we need to explicitly test for NaN + // before using FMIN/FMAX. + + // FADD Rarg0, Rarg1, Rout // FADD is used to propagate a NaN to the result in these cases. + // FEQ Rarg0, Rarg0, Rtmp + // BEQZ Rtmp, end + // FEQ Rarg1, Rarg1, Rtmp + // BEQZ Rtmp, end + // F(MIN | MAX) + + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + out := v.Reg() + add, feq := riscv.AFADDD, riscv.AFEQD + if v.Op == ssa.OpRISCV64LoweredFMAXS || v.Op == ssa.OpRISCV64LoweredFMINS { + add = riscv.AFADDS + feq = riscv.AFEQS + } + + p1 := s.Prog(add) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r0 + p1.Reg = r1 + p1.To.Type = obj.TYPE_REG + p1.To.Reg = out + + p2 := s.Prog(feq) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = r0 + p2.Reg = r0 + p2.To.Type = obj.TYPE_REG + p2.To.Reg = riscv.REG_TMP + + p3 := s.Prog(riscv.ABEQ) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = riscv.REG_ZERO + p3.Reg = riscv.REG_TMP + p3.To.Type = obj.TYPE_BRANCH + + p4 := s.Prog(feq) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = r1 + p4.Reg = r1 + p4.To.Type = obj.TYPE_REG + p4.To.Reg = riscv.REG_TMP + + p5 := s.Prog(riscv.ABEQ) + p5.From.Type = obj.TYPE_REG + p5.From.Reg = riscv.REG_ZERO + p5.Reg = riscv.REG_TMP + p5.To.Type = obj.TYPE_BRANCH + + p6 := s.Prog(v.Op.Asm()) + p6.From.Type = obj.TYPE_REG + p6.From.Reg = r1 + p6.Reg = r0 + p6.To.Type = obj.TYPE_REG + p6.To.Reg = out + + nop := s.Prog(obj.ANOP) + p3.To.SetTarget(nop) + p5.To.SetTarget(nop) + + case ssa.OpRISCV64LoweredMuluhilo: + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + p := s.Prog(riscv.AMULHU) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + p1 := s.Prog(riscv.AMUL) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.Reg = r0 + p1.To.Type = obj.TYPE_REG + p1.To.Reg = v.Reg1() + case ssa.OpRISCV64LoweredMuluover: + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + p := s.Prog(riscv.AMULHU) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.Reg = r0 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg1() + p1 := s.Prog(riscv.AMUL) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = r1 + p1.Reg = r0 + p1.To.Type = obj.TYPE_REG + p1.To.Reg = v.Reg0() + p2 := s.Prog(riscv.ASNEZ) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = v.Reg1() + p2.To.Type = obj.TYPE_REG + p2.To.Reg = v.Reg1() + case ssa.OpRISCV64FMADDD, ssa.OpRISCV64FMSUBD, ssa.OpRISCV64FNMADDD, ssa.OpRISCV64FNMSUBD, + ssa.OpRISCV64FMADDS, ssa.OpRISCV64FMSUBS, ssa.OpRISCV64FNMADDS, ssa.OpRISCV64FNMSUBS: + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + r3 := v.Args[2].Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r2 + p.Reg = r1 + p.AddRestSource(obj.Addr{Type: obj.TYPE_REG, Reg: r3}) + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpRISCV64FSQRTS, ssa.OpRISCV64FNEGS, ssa.OpRISCV64FABSD, ssa.OpRISCV64FSQRTD, ssa.OpRISCV64FNEGD, + ssa.OpRISCV64FMVSX, ssa.OpRISCV64FMVXS, ssa.OpRISCV64FMVDX, ssa.OpRISCV64FMVXD, + ssa.OpRISCV64FCVTSW, ssa.OpRISCV64FCVTSL, ssa.OpRISCV64FCVTWS, ssa.OpRISCV64FCVTLS, + ssa.OpRISCV64FCVTDW, ssa.OpRISCV64FCVTDL, ssa.OpRISCV64FCVTWD, ssa.OpRISCV64FCVTLD, ssa.OpRISCV64FCVTDS, ssa.OpRISCV64FCVTSD, + ssa.OpRISCV64FCLASSS, ssa.OpRISCV64FCLASSD, + ssa.OpRISCV64NOT, ssa.OpRISCV64NEG, ssa.OpRISCV64NEGW, ssa.OpRISCV64CLZ, ssa.OpRISCV64CLZW, ssa.OpRISCV64CTZ, ssa.OpRISCV64CTZW, + ssa.OpRISCV64REV8, ssa.OpRISCV64CPOP, ssa.OpRISCV64CPOPW: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpRISCV64ADDI, ssa.OpRISCV64ADDIW, ssa.OpRISCV64XORI, ssa.OpRISCV64ORI, ssa.OpRISCV64ANDI, + ssa.OpRISCV64SLLI, ssa.OpRISCV64SLLIW, ssa.OpRISCV64SRAI, ssa.OpRISCV64SRAIW, + ssa.OpRISCV64SRLI, ssa.OpRISCV64SRLIW, ssa.OpRISCV64SLTI, ssa.OpRISCV64SLTIU, + ssa.OpRISCV64RORI, ssa.OpRISCV64RORIW: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpRISCV64MOVDconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpRISCV64FMOVDconst, ssa.OpRISCV64FMOVFconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_FCONST + p.From.Val = v.AuxFloat() + p.From.Name = obj.NAME_NONE + p.From.Reg = obj.REG_NONE + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpRISCV64MOVaddr: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_ADDR + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + var wantreg string + // MOVW $sym+off(base), R + switch v.Aux.(type) { + default: + v.Fatalf("aux is of unknown type %T", v.Aux) + case *obj.LSym: + wantreg = "SB" + ssagen.AddAux(&p.From, v) + case *ir.Name: + wantreg = "SP" + ssagen.AddAux(&p.From, v) + case nil: + // No sym, just MOVW $off(SP), R + wantreg = "SP" + p.From.Reg = riscv.REG_SP + p.From.Offset = v.AuxInt + } + if reg := v.Args[0].RegName(); reg != wantreg { + v.Fatalf("bad reg %s for symbol type %T, want %s", reg, v.Aux, wantreg) + } + case ssa.OpRISCV64MOVBload, ssa.OpRISCV64MOVHload, ssa.OpRISCV64MOVWload, ssa.OpRISCV64MOVDload, + ssa.OpRISCV64MOVBUload, ssa.OpRISCV64MOVHUload, ssa.OpRISCV64MOVWUload, + ssa.OpRISCV64FMOVWload, ssa.OpRISCV64FMOVDload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpRISCV64MOVBstore, ssa.OpRISCV64MOVHstore, ssa.OpRISCV64MOVWstore, ssa.OpRISCV64MOVDstore, + ssa.OpRISCV64FMOVWstore, ssa.OpRISCV64FMOVDstore: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpRISCV64MOVBstorezero, ssa.OpRISCV64MOVHstorezero, ssa.OpRISCV64MOVWstorezero, ssa.OpRISCV64MOVDstorezero: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = riscv.REG_ZERO + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpRISCV64SEQZ, ssa.OpRISCV64SNEZ: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpRISCV64CALLstatic, ssa.OpRISCV64CALLclosure, ssa.OpRISCV64CALLinter: + s.Call(v) + case ssa.OpRISCV64CALLtail: + s.TailCall(v) + case ssa.OpRISCV64LoweredWB: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + // AuxInt encodes how many buffer entries we need. + p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1] + + case ssa.OpRISCV64LoweredPanicBoundsRR, ssa.OpRISCV64LoweredPanicBoundsRC, ssa.OpRISCV64LoweredPanicBoundsCR, ssa.OpRISCV64LoweredPanicBoundsCC: + // Compute the constant we put in the PCData entry for this call. + code, signed := ssa.BoundsKind(v.AuxInt).Code() + xIsReg := false + yIsReg := false + xVal := 0 + yVal := 0 + switch v.Op { + case ssa.OpRISCV64LoweredPanicBoundsRR: + xIsReg = true + xVal = int(v.Args[0].Reg() - riscv.REG_X5) + yIsReg = true + yVal = int(v.Args[1].Reg() - riscv.REG_X5) + case ssa.OpRISCV64LoweredPanicBoundsRC: + xIsReg = true + xVal = int(v.Args[0].Reg() - riscv.REG_X5) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + if yVal == xVal { + yVal = 1 + } + p := s.Prog(riscv.AMOV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = riscv.REG_X5 + int16(yVal) + } + case ssa.OpRISCV64LoweredPanicBoundsCR: + yIsReg = true + yVal = int(v.Args[0].Reg() - riscv.REG_X5) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + if xVal == yVal { + xVal = 1 + } + p := s.Prog(riscv.AMOV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = riscv.REG_X5 + int16(xVal) + } + case ssa.OpRISCV64LoweredPanicBoundsCC: + c := v.Aux.(ssa.PanicBoundsCC).Cx + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + xIsReg = true + p := s.Prog(riscv.AMOV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = riscv.REG_X5 + int16(xVal) + } + c = v.Aux.(ssa.PanicBoundsCC).Cy + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + yVal = 1 + p := s.Prog(riscv.AMOV) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = riscv.REG_X5 + int16(yVal) + } + } + c := abi.BoundsEncode(code, signed, xIsReg, yIsReg, xVal, yVal) + + p := s.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_PanicBounds) + p.To.SetConst(int64(c)) + p = s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.PanicBounds + + case ssa.OpRISCV64LoweredAtomicLoad8: + s.Prog(riscv.AFENCE) + p := s.Prog(riscv.AMOVBU) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + s.Prog(riscv.AFENCE) + + case ssa.OpRISCV64LoweredAtomicLoad32, ssa.OpRISCV64LoweredAtomicLoad64: + as := riscv.ALRW + if v.Op == ssa.OpRISCV64LoweredAtomicLoad64 { + as = riscv.ALRD + } + p := s.Prog(as) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + + case ssa.OpRISCV64LoweredAtomicStore8: + s.Prog(riscv.AFENCE) + p := s.Prog(riscv.AMOVB) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + s.Prog(riscv.AFENCE) + + case ssa.OpRISCV64LoweredAtomicStore32, ssa.OpRISCV64LoweredAtomicStore64: + as := riscv.AAMOSWAPW + if v.Op == ssa.OpRISCV64LoweredAtomicStore64 { + as = riscv.AAMOSWAPD + } + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.RegTo2 = riscv.REG_ZERO + + case ssa.OpRISCV64LoweredAtomicAdd32, ssa.OpRISCV64LoweredAtomicAdd64: + as := riscv.AAMOADDW + if v.Op == ssa.OpRISCV64LoweredAtomicAdd64 { + as = riscv.AAMOADDD + } + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.RegTo2 = riscv.REG_TMP + + p2 := s.Prog(riscv.AADD) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = riscv.REG_TMP + p2.Reg = v.Args[1].Reg() + p2.To.Type = obj.TYPE_REG + p2.To.Reg = v.Reg0() + + case ssa.OpRISCV64LoweredAtomicExchange32, ssa.OpRISCV64LoweredAtomicExchange64: + as := riscv.AAMOSWAPW + if v.Op == ssa.OpRISCV64LoweredAtomicExchange64 { + as = riscv.AAMOSWAPD + } + p := s.Prog(as) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.RegTo2 = v.Reg0() + + case ssa.OpRISCV64LoweredAtomicCas32, ssa.OpRISCV64LoweredAtomicCas64: + // MOV ZERO, Rout + // LR (Rarg0), Rtmp + // BNE Rtmp, Rarg1, 3(PC) + // SC Rarg2, (Rarg0), Rtmp + // BNE Rtmp, ZERO, -3(PC) + // MOV $1, Rout + + lr := riscv.ALRW + sc := riscv.ASCW + if v.Op == ssa.OpRISCV64LoweredAtomicCas64 { + lr = riscv.ALRD + sc = riscv.ASCD + } + + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + r2 := v.Args[2].Reg() + out := v.Reg0() + + p := s.Prog(riscv.AMOV) + p.From.Type = obj.TYPE_REG + p.From.Reg = riscv.REG_ZERO + p.To.Type = obj.TYPE_REG + p.To.Reg = out + + p1 := s.Prog(lr) + p1.From.Type = obj.TYPE_MEM + p1.From.Reg = r0 + p1.To.Type = obj.TYPE_REG + p1.To.Reg = riscv.REG_TMP + + p2 := s.Prog(riscv.ABNE) + p2.From.Type = obj.TYPE_REG + p2.From.Reg = r1 + p2.Reg = riscv.REG_TMP + p2.To.Type = obj.TYPE_BRANCH + + p3 := s.Prog(sc) + p3.From.Type = obj.TYPE_REG + p3.From.Reg = r2 + p3.To.Type = obj.TYPE_MEM + p3.To.Reg = r0 + p3.RegTo2 = riscv.REG_TMP + + p4 := s.Prog(riscv.ABNE) + p4.From.Type = obj.TYPE_REG + p4.From.Reg = riscv.REG_TMP + p4.Reg = riscv.REG_ZERO + p4.To.Type = obj.TYPE_BRANCH + p4.To.SetTarget(p1) + + p5 := s.Prog(riscv.AMOV) + p5.From.Type = obj.TYPE_CONST + p5.From.Offset = 1 + p5.To.Type = obj.TYPE_REG + p5.To.Reg = out + + p6 := s.Prog(obj.ANOP) + p2.To.SetTarget(p6) + + case ssa.OpRISCV64LoweredAtomicAnd32, ssa.OpRISCV64LoweredAtomicOr32: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.RegTo2 = riscv.REG_ZERO + + case ssa.OpRISCV64LoweredZero: + ptr := v.Args[0].Reg() + sc := v.AuxValAndOff() + n := sc.Val64() + + mov, sz := largestMove(sc.Off64()) + + // mov ZERO, (offset)(Rarg0) + var off int64 + for n >= sz { + zeroOp(s, mov, ptr, off) + off += sz + n -= sz + } + + for i := len(fracMovOps) - 1; i >= 0; i-- { + tsz := int64(1 << i) + if n < tsz { + continue + } + zeroOp(s, fracMovOps[i], ptr, off) + off += tsz + n -= tsz + } + + case ssa.OpRISCV64LoweredZeroLoop: + ptr := v.Args[0].Reg() + sc := v.AuxValAndOff() + n := sc.Val64() + mov, sz := largestMove(sc.Off64()) + chunk := 8 * sz + + if n <= 3*chunk { + v.Fatalf("ZeroLoop too small:%d, expect:%d", n, 3*chunk) + } + + tmp := v.RegTmp() + + p := s.Prog(riscv.AADD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = n - n%chunk + p.Reg = ptr + p.To.Type = obj.TYPE_REG + p.To.Reg = tmp + + for i := int64(0); i < 8; i++ { + zeroOp(s, mov, ptr, sz*i) + } + + p2 := s.Prog(riscv.AADD) + p2.From.Type = obj.TYPE_CONST + p2.From.Offset = chunk + p2.To.Type = obj.TYPE_REG + p2.To.Reg = ptr + + p3 := s.Prog(riscv.ABNE) + p3.From.Reg = tmp + p3.From.Type = obj.TYPE_REG + p3.Reg = ptr + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p.Link) + + n %= chunk + + // mov ZERO, (offset)(Rarg0) + var off int64 + for n >= sz { + zeroOp(s, mov, ptr, off) + off += sz + n -= sz + } + + for i := len(fracMovOps) - 1; i >= 0; i-- { + tsz := int64(1 << i) + if n < tsz { + continue + } + zeroOp(s, fracMovOps[i], ptr, off) + off += tsz + n -= tsz + } + + case ssa.OpRISCV64LoweredMove: + dst := v.Args[0].Reg() + src := v.Args[1].Reg() + if dst == src { + break + } + + sa := v.AuxValAndOff() + n := sa.Val64() + mov, sz := largestMove(sa.Off64()) + + var off int64 + tmp := int16(riscv.REG_X5) + for n >= sz { + moveOp(s, mov, dst, src, tmp, off) + off += sz + n -= sz + } + + for i := len(fracMovOps) - 1; i >= 0; i-- { + tsz := int64(1 << i) + if n < tsz { + continue + } + moveOp(s, fracMovOps[i], dst, src, tmp, off) + off += tsz + n -= tsz + } + + case ssa.OpRISCV64LoweredMoveLoop: + dst := v.Args[0].Reg() + src := v.Args[1].Reg() + if dst == src { + break + } + + sc := v.AuxValAndOff() + n := sc.Val64() + mov, sz := largestMove(sc.Off64()) + chunk := 8 * sz + + if n <= 3*chunk { + v.Fatalf("MoveLoop too small:%d, expect:%d", n, 3*chunk) + } + tmp := int16(riscv.REG_X5) + + p := s.Prog(riscv.AADD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = n - n%chunk + p.Reg = src + p.To.Type = obj.TYPE_REG + p.To.Reg = riscv.REG_X6 + + for i := int64(0); i < 8; i++ { + moveOp(s, mov, dst, src, tmp, sz*i) + } + + p1 := s.Prog(riscv.AADD) + p1.From.Type = obj.TYPE_CONST + p1.From.Offset = chunk + p1.To.Type = obj.TYPE_REG + p1.To.Reg = src + + p2 := s.Prog(riscv.AADD) + p2.From.Type = obj.TYPE_CONST + p2.From.Offset = chunk + p2.To.Type = obj.TYPE_REG + p2.To.Reg = dst + + p3 := s.Prog(riscv.ABNE) + p3.From.Reg = riscv.REG_X6 + p3.From.Type = obj.TYPE_REG + p3.Reg = src + p3.To.Type = obj.TYPE_BRANCH + p3.To.SetTarget(p.Link) + + n %= chunk + + var off int64 + for n >= sz { + moveOp(s, mov, dst, src, tmp, off) + off += sz + n -= sz + } + + for i := len(fracMovOps) - 1; i >= 0; i-- { + tsz := int64(1 << i) + if n < tsz { + continue + } + moveOp(s, fracMovOps[i], dst, src, tmp, off) + off += tsz + n -= tsz + } + + case ssa.OpRISCV64LoweredNilCheck: + // Issue a load which will fault if arg is nil. + p := s.Prog(riscv.AMOVB) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = riscv.REG_ZERO + if logopt.Enabled() { + logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name) + } + if base.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos == 1 in generated wrappers + base.WarnfAt(v.Pos, "generated nil check") + } + + case ssa.OpRISCV64LoweredGetClosurePtr: + // Closure pointer is S10 (riscv.REG_CTXT). + ssagen.CheckLoweredGetClosurePtr(v) + + case ssa.OpRISCV64LoweredGetCallerSP: + // caller's SP is FixedFrameSize below the address of the first arg + p := s.Prog(riscv.AMOV) + p.From.Type = obj.TYPE_ADDR + p.From.Offset = -base.Ctxt.Arch.FixedFrameSize + p.From.Name = obj.NAME_PARAM + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpRISCV64LoweredGetCallerPC: + p := s.Prog(obj.AGETCALLERPC) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + + case ssa.OpRISCV64LoweredPubBarrier: + // FENCE + s.Prog(v.Op.Asm()) + + case ssa.OpRISCV64LoweredRound32F, ssa.OpRISCV64LoweredRound64F: + // input is already rounded + + case ssa.OpClobber, ssa.OpClobberReg: + // TODO: implement for clobberdead experiment. Nop is ok for now. + + default: + v.Fatalf("Unhandled op %v", v.Op) + } +} + +var blockBranch = [...]obj.As{ + ssa.BlockRISCV64BEQ: riscv.ABEQ, + ssa.BlockRISCV64BEQZ: riscv.ABEQZ, + ssa.BlockRISCV64BGE: riscv.ABGE, + ssa.BlockRISCV64BGEU: riscv.ABGEU, + ssa.BlockRISCV64BGEZ: riscv.ABGEZ, + ssa.BlockRISCV64BGTZ: riscv.ABGTZ, + ssa.BlockRISCV64BLEZ: riscv.ABLEZ, + ssa.BlockRISCV64BLT: riscv.ABLT, + ssa.BlockRISCV64BLTU: riscv.ABLTU, + ssa.BlockRISCV64BLTZ: riscv.ABLTZ, + ssa.BlockRISCV64BNE: riscv.ABNE, + ssa.BlockRISCV64BNEZ: riscv.ABNEZ, +} + +func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) { + s.SetPos(b.Pos) + + switch b.Kind { + case ssa.BlockPlain, ssa.BlockDefer: + if b.Succs[0].Block() != next { + p := s.Prog(obj.AJMP) + p.To.Type = obj.TYPE_BRANCH + s.Branches = append(s.Branches, ssagen.Branch{P: p, B: b.Succs[0].Block()}) + } + case ssa.BlockExit, ssa.BlockRetJmp: + case ssa.BlockRet: + s.Prog(obj.ARET) + case ssa.BlockRISCV64BEQ, ssa.BlockRISCV64BEQZ, ssa.BlockRISCV64BNE, ssa.BlockRISCV64BNEZ, + ssa.BlockRISCV64BLT, ssa.BlockRISCV64BLEZ, ssa.BlockRISCV64BGE, ssa.BlockRISCV64BGEZ, + ssa.BlockRISCV64BLTZ, ssa.BlockRISCV64BGTZ, ssa.BlockRISCV64BLTU, ssa.BlockRISCV64BGEU: + + as := blockBranch[b.Kind] + invAs := riscv.InvertBranch(as) + + var p *obj.Prog + switch next { + case b.Succs[0].Block(): + p = s.Br(invAs, b.Succs[1].Block()) + case b.Succs[1].Block(): + p = s.Br(as, b.Succs[0].Block()) + default: + if b.Likely != ssa.BranchUnlikely { + p = s.Br(as, b.Succs[0].Block()) + s.Br(obj.AJMP, b.Succs[1].Block()) + } else { + p = s.Br(invAs, b.Succs[1].Block()) + s.Br(obj.AJMP, b.Succs[0].Block()) + } + } + + p.From.Type = obj.TYPE_REG + switch b.Kind { + case ssa.BlockRISCV64BEQ, ssa.BlockRISCV64BNE, ssa.BlockRISCV64BLT, ssa.BlockRISCV64BGE, ssa.BlockRISCV64BLTU, ssa.BlockRISCV64BGEU: + if b.NumControls() != 2 { + b.Fatalf("Unexpected number of controls (%d != 2): %s", b.NumControls(), b.LongString()) + } + p.From.Reg = b.Controls[0].Reg() + p.Reg = b.Controls[1].Reg() + + case ssa.BlockRISCV64BEQZ, ssa.BlockRISCV64BNEZ, ssa.BlockRISCV64BGEZ, ssa.BlockRISCV64BLEZ, ssa.BlockRISCV64BLTZ, ssa.BlockRISCV64BGTZ: + if b.NumControls() != 1 { + b.Fatalf("Unexpected number of controls (%d != 1): %s", b.NumControls(), b.LongString()) + } + p.From.Reg = b.Controls[0].Reg() + } + + default: + b.Fatalf("Unhandled block: %s", b.LongString()) + } +} + +func loadRegResult(s *ssagen.State, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p := s.Prog(loadByType(t)) + p.From.Type = obj.TYPE_MEM + p.From.Name = obj.NAME_AUTO + p.From.Sym = n.Linksym() + p.From.Offset = n.FrameOffset() + off + p.To.Type = obj.TYPE_REG + p.To.Reg = reg + return p +} + +func spillArgReg(pp *objw.Progs, p *obj.Prog, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p = pp.Append(p, storeByType(t), obj.TYPE_REG, reg, 0, obj.TYPE_MEM, 0, n.FrameOffset()+off) + p.To.Name = obj.NAME_PARAM + p.To.Sym = n.Linksym() + p.Pos = p.Pos.WithNotStmt() + return p +} + +func zeroOp(s *ssagen.State, mov obj.As, reg int16, off int64) { + p := s.Prog(mov) + p.From.Type = obj.TYPE_REG + p.From.Reg = riscv.REG_ZERO + p.To.Type = obj.TYPE_MEM + p.To.Reg = reg + p.To.Offset = off + return +} + +func moveOp(s *ssagen.State, mov obj.As, dst int16, src int16, tmp int16, off int64) { + p := s.Prog(mov) + p.From.Type = obj.TYPE_MEM + p.From.Reg = src + p.From.Offset = off + p.To.Type = obj.TYPE_REG + p.To.Reg = tmp + + p1 := s.Prog(mov) + p1.From.Type = obj.TYPE_REG + p1.From.Reg = tmp + p1.To.Type = obj.TYPE_MEM + p1.To.Reg = dst + p1.To.Offset = off + + return +} diff --git a/go/src/cmd/compile/internal/rttype/rttype.go b/go/src/cmd/compile/internal/rttype/rttype.go new file mode 100644 index 0000000000000000000000000000000000000000..b8c95339915a52db032bd98fef10affd485da3da --- /dev/null +++ b/go/src/cmd/compile/internal/rttype/rttype.go @@ -0,0 +1,323 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package rttype allows the compiler to share type information with +// the runtime. The shared type information is stored in +// internal/abi. This package translates those types from the host +// machine on which the compiler runs to the target machine on which +// the compiled program will run. In particular, this package handles +// layout differences between e.g. a 64 bit compiler and 32 bit +// target. +package rttype + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/objw" + "cmd/compile/internal/types" + "cmd/internal/obj" + "internal/abi" + "reflect" +) + +// The type structures shared with the runtime. +var Type *types.Type + +var ArrayType *types.Type +var ChanType *types.Type +var FuncType *types.Type +var InterfaceType *types.Type +var MapType *types.Type +var PtrType *types.Type +var SliceType *types.Type +var StructType *types.Type + +// Types that are parts of the types above. +var IMethod *types.Type +var Method *types.Type +var StructField *types.Type +var UncommonType *types.Type + +// Type switches and asserts +var InterfaceSwitch *types.Type +var TypeAssert *types.Type + +// Interface tables (itabs) +var ITab *types.Type + +func Init() { + // Note: this has to be called explicitly instead of being + // an init function so it runs after the types package has + // been properly initialized. + Type = FromReflect(reflect.TypeFor[abi.Type]()) + ArrayType = FromReflect(reflect.TypeFor[abi.ArrayType]()) + ChanType = FromReflect(reflect.TypeFor[abi.ChanType]()) + FuncType = FromReflect(reflect.TypeFor[abi.FuncType]()) + InterfaceType = FromReflect(reflect.TypeFor[abi.InterfaceType]()) + MapType = FromReflect(reflect.TypeFor[abi.MapType]()) + PtrType = FromReflect(reflect.TypeFor[abi.PtrType]()) + SliceType = FromReflect(reflect.TypeFor[abi.SliceType]()) + StructType = FromReflect(reflect.TypeFor[abi.StructType]()) + + IMethod = FromReflect(reflect.TypeFor[abi.Imethod]()) + Method = FromReflect(reflect.TypeFor[abi.Method]()) + StructField = FromReflect(reflect.TypeFor[abi.StructField]()) + UncommonType = FromReflect(reflect.TypeFor[abi.UncommonType]()) + + InterfaceSwitch = FromReflect(reflect.TypeFor[abi.InterfaceSwitch]()) + TypeAssert = FromReflect(reflect.TypeFor[abi.TypeAssert]()) + + ITab = FromReflect(reflect.TypeFor[abi.ITab]()) + + // Make sure abi functions are correct. These functions are used + // by the linker which doesn't have the ability to do type layout, + // so we check the functions it uses here. + ptrSize := types.PtrSize + if got, want := int64(abi.CommonSize(ptrSize)), Type.Size(); got != want { + base.Fatalf("abi.CommonSize() == %d, want %d", got, want) + } + if got, want := int64(abi.StructFieldSize(ptrSize)), StructField.Size(); got != want { + base.Fatalf("abi.StructFieldSize() == %d, want %d", got, want) + } + if got, want := int64(abi.UncommonSize()), UncommonType.Size(); got != want { + base.Fatalf("abi.UncommonSize() == %d, want %d", got, want) + } + if got, want := int64(abi.TFlagOff(ptrSize)), Type.OffsetOf("TFlag"); got != want { + base.Fatalf("abi.TFlagOff() == %d, want %d", got, want) + } + if got, want := int64(abi.ITabTypeOff(ptrSize)), ITab.OffsetOf("Type"); got != want { + base.Fatalf("abi.ITabTypeOff() == %d, want %d", got, want) + } +} + +// FromReflect translates from a host type to the equivalent target type. +func FromReflect(rt reflect.Type) *types.Type { + t := reflectToType(rt) + types.CalcSize(t) + return t +} + +// reflectToType converts from a reflect.Type (which is a compiler +// host type) to a *types.Type, which is a target type. The result +// must be CalcSize'd before using. +func reflectToType(rt reflect.Type) *types.Type { + switch rt.Kind() { + case reflect.Bool: + return types.Types[types.TBOOL] + case reflect.Int: + return types.Types[types.TINT] + case reflect.Int8: + return types.Types[types.TINT8] + case reflect.Int16: + return types.Types[types.TINT16] + case reflect.Int32: + return types.Types[types.TINT32] + case reflect.Uint8: + return types.Types[types.TUINT8] + case reflect.Uint16: + return types.Types[types.TUINT16] + case reflect.Uint32: + return types.Types[types.TUINT32] + case reflect.Float32: + return types.Types[types.TFLOAT32] + case reflect.Float64: + return types.Types[types.TFLOAT64] + case reflect.Uintptr: + return types.Types[types.TUINTPTR] + case reflect.Ptr: + return types.NewPtr(reflectToType(rt.Elem())) + case reflect.Func, reflect.UnsafePointer: + // TODO: there's no mechanism to distinguish different pointer types, + // so we treat them all as unsafe.Pointer. + return types.Types[types.TUNSAFEPTR] + case reflect.Slice: + return types.NewSlice(reflectToType(rt.Elem())) + case reflect.Array: + return types.NewArray(reflectToType(rt.Elem()), int64(rt.Len())) + case reflect.Struct: + fields := make([]*types.Field, rt.NumField()) + for i := 0; i < rt.NumField(); i++ { + f := rt.Field(i) + ft := reflectToType(f.Type) + fields[i] = &types.Field{Sym: &types.Sym{Name: f.Name}, Type: ft} + } + return types.NewStruct(fields) + case reflect.Chan: + return types.NewChan(reflectToType(rt.Elem()), types.ChanDir(rt.ChanDir())) + case reflect.String: + return types.Types[types.TSTRING] + case reflect.Complex128: + return types.Types[types.TCOMPLEX128] + default: + base.Fatalf("unhandled kind %s", rt.Kind()) + return nil + } +} + +// A Cursor represents a typed location inside a static variable where we +// are going to write. +type Cursor struct { + lsym *obj.LSym + offset int64 + typ *types.Type +} + +// NewCursor returns a cursor starting at lsym+off and having type t. +func NewCursor(lsym *obj.LSym, off int64, t *types.Type) Cursor { + return Cursor{lsym: lsym, offset: off, typ: t} +} + +// WritePtr writes a pointer "target" to the component at the location specified by c. +func (c Cursor) WritePtr(target *obj.LSym) { + if c.typ.Kind() != types.TUNSAFEPTR && c.typ.Kind() != types.TPTR { + base.Fatalf("can't write ptr, it has kind %s", c.typ.Kind()) + } + if target == nil { + objw.Uintptr(c.lsym, int(c.offset), 0) + } else { + objw.SymPtr(c.lsym, int(c.offset), target, 0) + } +} +func (c Cursor) WritePtrWeak(target *obj.LSym) { + if c.typ.Kind() != types.TUINTPTR { + base.Fatalf("can't write ptr, it has kind %s", c.typ.Kind()) + } + objw.SymPtrWeak(c.lsym, int(c.offset), target, 0) +} +func (c Cursor) WriteUintptr(val uint64) { + if c.typ.Kind() != types.TUINTPTR { + base.Fatalf("can't write uintptr, it has kind %s", c.typ.Kind()) + } + objw.Uintptr(c.lsym, int(c.offset), val) +} +func (c Cursor) WriteUint32(val uint32) { + if c.typ.Kind() != types.TUINT32 { + base.Fatalf("can't write uint32, it has kind %s", c.typ.Kind()) + } + objw.Uint32(c.lsym, int(c.offset), val) +} +func (c Cursor) WriteUint16(val uint16) { + if c.typ.Kind() != types.TUINT16 { + base.Fatalf("can't write uint16, it has kind %s", c.typ.Kind()) + } + objw.Uint16(c.lsym, int(c.offset), val) +} +func (c Cursor) WriteUint8(val uint8) { + if c.typ.Kind() != types.TUINT8 { + base.Fatalf("can't write uint8, it has kind %s", c.typ.Kind()) + } + objw.Uint8(c.lsym, int(c.offset), val) +} +func (c Cursor) WriteInt(val int64) { + if c.typ.Kind() != types.TINT { + base.Fatalf("can't write int, it has kind %s", c.typ.Kind()) + } + objw.Uintptr(c.lsym, int(c.offset), uint64(val)) +} +func (c Cursor) WriteInt32(val int32) { + if c.typ.Kind() != types.TINT32 { + base.Fatalf("can't write int32, it has kind %s", c.typ.Kind()) + } + objw.Uint32(c.lsym, int(c.offset), uint32(val)) +} +func (c Cursor) WriteBool(val bool) { + if c.typ.Kind() != types.TBOOL { + base.Fatalf("can't write bool, it has kind %s", c.typ.Kind()) + } + objw.Bool(c.lsym, int(c.offset), val) +} + +// WriteSymPtrOff writes a "pointer" to the given symbol. The symbol +// is encoded as a uint32 offset from the start of the section. +func (c Cursor) WriteSymPtrOff(target *obj.LSym, weak bool) { + if c.typ.Kind() != types.TINT32 && c.typ.Kind() != types.TUINT32 { + base.Fatalf("can't write SymPtr, it has kind %s", c.typ.Kind()) + } + if target == nil { + objw.Uint32(c.lsym, int(c.offset), 0) + } else if weak { + objw.SymPtrWeakOff(c.lsym, int(c.offset), target) + } else { + objw.SymPtrOff(c.lsym, int(c.offset), target) + } +} + +// WriteSlice writes a slice header to c. The pointer is target+off, the len and cap fields are given. +func (c Cursor) WriteSlice(target *obj.LSym, off, len, cap int64) { + if c.typ.Kind() != types.TSLICE { + base.Fatalf("can't write slice, it has kind %s", c.typ.Kind()) + } + objw.SymPtr(c.lsym, int(c.offset), target, int(off)) + objw.Uintptr(c.lsym, int(c.offset)+types.PtrSize, uint64(len)) + objw.Uintptr(c.lsym, int(c.offset)+2*types.PtrSize, uint64(cap)) + // TODO: ability to switch len&cap. Maybe not needed here, as every caller + // passes the same thing for both? + if len != cap { + base.Fatalf("len != cap (%d != %d)", len, cap) + } +} + +// Reloc adds a relocation from the current cursor position. +// Reloc fills in Off and Siz fields. Caller should fill in the rest (Type, others). +func (c Cursor) Reloc(rel obj.Reloc) { + rel.Off = int32(c.offset) + rel.Siz = uint8(c.typ.Size()) + c.lsym.AddRel(base.Ctxt, rel) +} + +// Field selects the field with the given name from the struct pointed to by c. +func (c Cursor) Field(name string) Cursor { + if c.typ.Kind() != types.TSTRUCT { + base.Fatalf("can't call Field on non-struct %v", c.typ) + } + for _, f := range c.typ.Fields() { + if f.Sym.Name == name { + return Cursor{lsym: c.lsym, offset: c.offset + f.Offset, typ: f.Type} + } + } + base.Fatalf("couldn't find field %s in %v", name, c.typ) + return Cursor{} +} + +func (c Cursor) Elem(i int64) Cursor { + if c.typ.Kind() != types.TARRAY { + base.Fatalf("can't call Elem on non-array %v", c.typ) + } + if i < 0 || i >= c.typ.NumElem() { + base.Fatalf("element access out of bounds [%d] in [0:%d]", i, c.typ.NumElem()) + } + elem := c.typ.Elem() + return Cursor{lsym: c.lsym, offset: c.offset + i*elem.Size(), typ: elem} +} + +type ArrayCursor struct { + c Cursor // cursor pointing at first element + n int // number of elements +} + +// NewArrayCursor returns a cursor starting at lsym+off and having n copies of type t. +func NewArrayCursor(lsym *obj.LSym, off int64, t *types.Type, n int) ArrayCursor { + return ArrayCursor{ + c: NewCursor(lsym, off, t), + n: n, + } +} + +// Elem selects element i of the array pointed to by c. +func (a ArrayCursor) Elem(i int) Cursor { + if i < 0 || i >= a.n { + base.Fatalf("element index %d out of range [0:%d]", i, a.n) + } + return Cursor{lsym: a.c.lsym, offset: a.c.offset + int64(i)*a.c.typ.Size(), typ: a.c.typ} +} + +// ModifyArray converts a cursor pointing at a type [k]T to a cursor pointing +// at a type [n]T. +// Also returns the size delta, aka (n-k)*sizeof(T). +func (c Cursor) ModifyArray(n int) (ArrayCursor, int64) { + if c.typ.Kind() != types.TARRAY { + base.Fatalf("can't call ModifyArray on non-array %v", c.typ) + } + k := c.typ.NumElem() + return ArrayCursor{c: Cursor{lsym: c.lsym, offset: c.offset, typ: c.typ.Elem()}, n: n}, (int64(n) - k) * c.typ.Elem().Size() +} diff --git a/go/src/cmd/compile/internal/s390x/galign.go b/go/src/cmd/compile/internal/s390x/galign.go new file mode 100644 index 0000000000000000000000000000000000000000..1fb371a52c6ac2f13f7d5821aa1ce43bcc520dbb --- /dev/null +++ b/go/src/cmd/compile/internal/s390x/galign.go @@ -0,0 +1,25 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package s390x + +import ( + "cmd/compile/internal/ssagen" + "cmd/internal/obj/s390x" +) + +func Init(arch *ssagen.ArchInfo) { + arch.LinkArch = &s390x.Links390x + arch.REGSP = s390x.REGSP + arch.MAXWIDTH = 1 << 50 + + arch.ZeroRange = zerorange + arch.Ginsnop = ginsnop + + arch.SSAMarkMoves = ssaMarkMoves + arch.SSAGenValue = ssaGenValue + arch.SSAGenBlock = ssaGenBlock + arch.LoadRegResult = loadRegResult + arch.SpillArgReg = spillArgReg +} diff --git a/go/src/cmd/compile/internal/s390x/ggen.go b/go/src/cmd/compile/internal/s390x/ggen.go new file mode 100644 index 0000000000000000000000000000000000000000..c4f88e782623e6dbe3683d15ccae6543e4b71715 --- /dev/null +++ b/go/src/cmd/compile/internal/s390x/ggen.go @@ -0,0 +1,89 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package s390x + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/objw" + "cmd/internal/obj" + "cmd/internal/obj/s390x" +) + +// clearLoopCutoff is the (somewhat arbitrary) value above which it is better +// to have a loop of clear instructions (e.g. XCs) rather than just generating +// multiple instructions (i.e. loop unrolling). +// Must be between 256 and 4096. +const clearLoopCutoff = 1024 + +// zerorange clears the stack in the given range. +func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { + if cnt == 0 { + return p + } + + // Adjust the frame to account for LR. + off += base.Ctxt.Arch.FixedFrameSize + reg := int16(s390x.REGSP) + + // If the off cannot fit in a 12-bit unsigned displacement then we + // need to create a copy of the stack pointer that we can adjust. + // We also need to do this if we are going to loop. + if off < 0 || off > 4096-clearLoopCutoff || cnt > clearLoopCutoff { + p = pp.Append(p, s390x.AADD, obj.TYPE_CONST, 0, off, obj.TYPE_REG, s390x.REGRT1, 0) + p.Reg = int16(s390x.REGSP) + reg = s390x.REGRT1 + off = 0 + } + + // Generate a loop of large clears. + if cnt > clearLoopCutoff { + ireg := int16(s390x.REGRT2) // register holds number of remaining loop iterations + p = pp.Append(p, s390x.AMOVD, obj.TYPE_CONST, 0, cnt/256, obj.TYPE_REG, ireg, 0) + p = pp.Append(p, s390x.ACLEAR, obj.TYPE_CONST, 0, 256, obj.TYPE_MEM, reg, off) + pl := p + p = pp.Append(p, s390x.AADD, obj.TYPE_CONST, 0, 256, obj.TYPE_REG, reg, 0) + p = pp.Append(p, s390x.ABRCTG, obj.TYPE_REG, ireg, 0, obj.TYPE_BRANCH, 0, 0) + p.To.SetTarget(pl) + cnt = cnt % 256 + } + + // Generate remaining clear instructions without a loop. + for cnt > 0 { + n := cnt + + // Can clear at most 256 bytes per instruction. + if n > 256 { + n = 256 + } + + switch n { + // Handle very small clears with move instructions. + case 8, 4, 2, 1: + ins := s390x.AMOVB + switch n { + case 8: + ins = s390x.AMOVD + case 4: + ins = s390x.AMOVW + case 2: + ins = s390x.AMOVH + } + p = pp.Append(p, ins, obj.TYPE_CONST, 0, 0, obj.TYPE_MEM, reg, off) + + // Handle clears that would require multiple move instructions with CLEAR (assembled as XC). + default: + p = pp.Append(p, s390x.ACLEAR, obj.TYPE_CONST, 0, n, obj.TYPE_MEM, reg, off) + } + + cnt -= n + off += n + } + + return p +} + +func ginsnop(pp *objw.Progs) *obj.Prog { + return pp.Prog(s390x.ANOPH) +} diff --git a/go/src/cmd/compile/internal/s390x/ssa.go b/go/src/cmd/compile/internal/s390x/ssa.go new file mode 100644 index 0000000000000000000000000000000000000000..ce060597d9a4c4c6dfab673c5242be48b3adbf33 --- /dev/null +++ b/go/src/cmd/compile/internal/s390x/ssa.go @@ -0,0 +1,1064 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package s390x + +import ( + "math" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/objw" + "cmd/compile/internal/ssa" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/s390x" + "internal/abi" +) + +// ssaMarkMoves marks any MOVXconst ops that need to avoid clobbering flags. +func ssaMarkMoves(s *ssagen.State, b *ssa.Block) { + flive := b.FlagsLiveAtEnd + for _, c := range b.ControlValues() { + flive = c.Type.IsFlags() || flive + } + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + if flive && v.Op == ssa.OpS390XMOVDconst { + // The "mark" is any non-nil Aux value. + v.Aux = ssa.AuxMark + } + if v.Type.IsFlags() { + flive = false + } + for _, a := range v.Args { + if a.Type.IsFlags() { + flive = true + } + } + } +} + +// loadByType returns the load instruction of the given type. +func loadByType(t *types.Type) obj.As { + if t.IsFloat() { + switch t.Size() { + case 4: + return s390x.AFMOVS + case 8: + return s390x.AFMOVD + } + } else { + switch t.Size() { + case 1: + if t.IsSigned() { + return s390x.AMOVB + } else { + return s390x.AMOVBZ + } + case 2: + if t.IsSigned() { + return s390x.AMOVH + } else { + return s390x.AMOVHZ + } + case 4: + if t.IsSigned() { + return s390x.AMOVW + } else { + return s390x.AMOVWZ + } + case 8: + return s390x.AMOVD + } + } + panic("bad load type") +} + +// storeByType returns the store instruction of the given type. +func storeByType(t *types.Type) obj.As { + width := t.Size() + if t.IsFloat() { + switch width { + case 4: + return s390x.AFMOVS + case 8: + return s390x.AFMOVD + } + } else { + switch width { + case 1: + return s390x.AMOVB + case 2: + return s390x.AMOVH + case 4: + return s390x.AMOVW + case 8: + return s390x.AMOVD + } + } + panic("bad store type") +} + +// moveByType returns the reg->reg move instruction of the given type. +func moveByType(t *types.Type) obj.As { + if t.IsFloat() { + return s390x.AFMOVD + } else { + switch t.Size() { + case 1: + if t.IsSigned() { + return s390x.AMOVB + } else { + return s390x.AMOVBZ + } + case 2: + if t.IsSigned() { + return s390x.AMOVH + } else { + return s390x.AMOVHZ + } + case 4: + if t.IsSigned() { + return s390x.AMOVW + } else { + return s390x.AMOVWZ + } + case 8: + return s390x.AMOVD + } + } + panic("bad load type") +} + +// opregreg emits instructions for +// +// dest := dest(To) op src(From) +// +// and also returns the created obj.Prog so it +// may be further adjusted (offset, scale, etc). +func opregreg(s *ssagen.State, op obj.As, dest, src int16) *obj.Prog { + p := s.Prog(op) + p.From.Type = obj.TYPE_REG + p.To.Type = obj.TYPE_REG + p.To.Reg = dest + p.From.Reg = src + return p +} + +// opregregimm emits instructions for +// +// dest := src(From) op off +// +// and also returns the created obj.Prog so it +// may be further adjusted (offset, scale, etc). +func opregregimm(s *ssagen.State, op obj.As, dest, src int16, off int64) *obj.Prog { + p := s.Prog(op) + p.From.Type = obj.TYPE_CONST + p.From.Offset = off + p.Reg = src + p.To.Reg = dest + p.To.Type = obj.TYPE_REG + return p +} + +func ssaGenValue(s *ssagen.State, v *ssa.Value) { + switch v.Op { + case ssa.OpS390XSLD, ssa.OpS390XSLW, + ssa.OpS390XSRD, ssa.OpS390XSRW, + ssa.OpS390XSRAD, ssa.OpS390XSRAW, + ssa.OpS390XRLLG, ssa.OpS390XRLL: + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + if r2 == s390x.REG_R0 { + v.Fatalf("cannot use R0 as shift value %s", v.LongString()) + } + p := opregreg(s, v.Op.Asm(), r, r2) + if r != r1 { + p.Reg = r1 + } + case ssa.OpS390XRXSBG: + r2 := v.Args[1].Reg() + i := v.Aux.(s390x.RotateParams) + p := s.Prog(v.Op.Asm()) + p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: int64(i.Start)} + p.AddRestSourceArgs([]obj.Addr{ + {Type: obj.TYPE_CONST, Offset: int64(i.End)}, + {Type: obj.TYPE_CONST, Offset: int64(i.Amount)}, + {Type: obj.TYPE_REG, Reg: r2}, + }) + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: v.Reg()} + case ssa.OpS390XRISBGZ: + r1 := v.Reg() + r2 := v.Args[0].Reg() + i := v.Aux.(s390x.RotateParams) + p := s.Prog(v.Op.Asm()) + p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: int64(i.Start)} + p.AddRestSourceArgs([]obj.Addr{ + {Type: obj.TYPE_CONST, Offset: int64(i.End)}, + {Type: obj.TYPE_CONST, Offset: int64(i.Amount)}, + {Type: obj.TYPE_REG, Reg: r2}, + }) + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: r1} + case ssa.OpS390XADD, ssa.OpS390XADDW, + ssa.OpS390XSUB, ssa.OpS390XSUBW, + ssa.OpS390XAND, ssa.OpS390XANDW, + ssa.OpS390XOR, ssa.OpS390XORW, + ssa.OpS390XXOR, ssa.OpS390XXORW: + r := v.Reg() + r1 := v.Args[0].Reg() + r2 := v.Args[1].Reg() + p := opregreg(s, v.Op.Asm(), r, r2) + if r != r1 { + p.Reg = r1 + } + case ssa.OpS390XADDC: + r1 := v.Reg0() + r2 := v.Args[0].Reg() + r3 := v.Args[1].Reg() + if r1 == r2 { + r2, r3 = r3, r2 + } + p := opregreg(s, v.Op.Asm(), r1, r2) + if r3 != r1 { + p.Reg = r3 + } + case ssa.OpS390XSUBC: + r1 := v.Reg0() + r2 := v.Args[0].Reg() + r3 := v.Args[1].Reg() + p := opregreg(s, v.Op.Asm(), r1, r3) + if r1 != r2 { + p.Reg = r2 + } + case ssa.OpS390XADDE, ssa.OpS390XSUBE: + r2 := v.Args[1].Reg() + opregreg(s, v.Op.Asm(), v.Reg0(), r2) + case ssa.OpS390XADDCconst: + r1 := v.Reg0() + r3 := v.Args[0].Reg() + i2 := int64(int16(v.AuxInt)) + opregregimm(s, v.Op.Asm(), r1, r3, i2) + // 2-address opcode arithmetic + case ssa.OpS390XMULLD, ssa.OpS390XMULLW, + ssa.OpS390XMULHD, ssa.OpS390XMULHDU, + ssa.OpS390XFMULS, ssa.OpS390XFMUL, ssa.OpS390XFDIVS, ssa.OpS390XFDIV: + opregreg(s, v.Op.Asm(), v.Reg(), v.Args[1].Reg()) + case ssa.OpS390XFSUBS, ssa.OpS390XFSUB, + ssa.OpS390XFADDS, ssa.OpS390XFADD: + opregreg(s, v.Op.Asm(), v.Reg0(), v.Args[1].Reg()) + case ssa.OpS390XMLGR: + // MLGR Rx R3 -> R2:R3 + r0 := v.Args[0].Reg() + r1 := v.Args[1].Reg() + if r1 != s390x.REG_R3 { + v.Fatalf("We require the multiplcand to be stored in R3 for MLGR %s", v.LongString()) + } + p := s.Prog(s390x.AMLGR) + p.From.Type = obj.TYPE_REG + p.From.Reg = r0 + p.To.Reg = s390x.REG_R2 + p.To.Type = obj.TYPE_REG + case ssa.OpS390XFMADD, ssa.OpS390XFMADDS, + ssa.OpS390XFMSUB, ssa.OpS390XFMSUBS: + r1 := v.Args[1].Reg() + r2 := v.Args[2].Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = r1 + p.Reg = r2 + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XFIDBR: + switch v.AuxInt { + case 0, 1, 3, 4, 5, 6, 7: + opregregimm(s, v.Op.Asm(), v.Reg(), v.Args[0].Reg(), v.AuxInt) + default: + v.Fatalf("invalid FIDBR mask: %v", v.AuxInt) + } + case ssa.OpS390XCPSDR: + p := opregreg(s, v.Op.Asm(), v.Reg(), v.Args[1].Reg()) + p.Reg = v.Args[0].Reg() + case ssa.OpS390XWFMAXDB, ssa.OpS390XWFMAXSB, + ssa.OpS390XWFMINDB, ssa.OpS390XWFMINSB: + p := opregregimm(s, v.Op.Asm(), v.Reg(), v.Args[0].Reg(), 1 /* Java Math.Max() */) + p.AddRestSource(obj.Addr{Type: obj.TYPE_REG, Reg: v.Args[1].Reg()}) + case ssa.OpS390XDIVD, ssa.OpS390XDIVW, + ssa.OpS390XDIVDU, ssa.OpS390XDIVWU, + ssa.OpS390XMODD, ssa.OpS390XMODW, + ssa.OpS390XMODDU, ssa.OpS390XMODWU: + + // TODO(mundaym): use the temp registers every time like x86 does with AX? + dividend := v.Args[0].Reg() + divisor := v.Args[1].Reg() + + // CPU faults upon signed overflow, which occurs when most + // negative int is divided by -1. + var j *obj.Prog + if v.Op == ssa.OpS390XDIVD || v.Op == ssa.OpS390XDIVW || + v.Op == ssa.OpS390XMODD || v.Op == ssa.OpS390XMODW { + + var c *obj.Prog + c = s.Prog(s390x.ACMP) + j = s.Prog(s390x.ABEQ) + + c.From.Type = obj.TYPE_REG + c.From.Reg = divisor + c.To.Type = obj.TYPE_CONST + c.To.Offset = -1 + + j.To.Type = obj.TYPE_BRANCH + + } + + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = divisor + p.Reg = 0 + p.To.Type = obj.TYPE_REG + p.To.Reg = dividend + + // signed division, rest of the check for -1 case + if j != nil { + j2 := s.Prog(s390x.ABR) + j2.To.Type = obj.TYPE_BRANCH + + var n *obj.Prog + if v.Op == ssa.OpS390XDIVD || v.Op == ssa.OpS390XDIVW { + // n * -1 = -n + n = s.Prog(s390x.ANEG) + n.To.Type = obj.TYPE_REG + n.To.Reg = dividend + } else { + // n % -1 == 0 + n = s.Prog(s390x.AXOR) + n.From.Type = obj.TYPE_REG + n.From.Reg = dividend + n.To.Type = obj.TYPE_REG + n.To.Reg = dividend + } + + j.To.SetTarget(n) + j2.To.SetTarget(s.Pc()) + } + case ssa.OpS390XADDconst, ssa.OpS390XADDWconst: + opregregimm(s, v.Op.Asm(), v.Reg(), v.Args[0].Reg(), v.AuxInt) + case ssa.OpS390XMULLDconst, ssa.OpS390XMULLWconst, + ssa.OpS390XSUBconst, ssa.OpS390XSUBWconst, + ssa.OpS390XANDconst, ssa.OpS390XANDWconst, + ssa.OpS390XORconst, ssa.OpS390XORWconst, + ssa.OpS390XXORconst, ssa.OpS390XXORWconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XSLDconst, ssa.OpS390XSLWconst, + ssa.OpS390XSRDconst, ssa.OpS390XSRWconst, + ssa.OpS390XSRADconst, ssa.OpS390XSRAWconst, + ssa.OpS390XRLLconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + r := v.Reg() + r1 := v.Args[0].Reg() + if r != r1 { + p.Reg = r1 + } + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpS390XMOVDaddridx: + r := v.Args[0].Reg() + i := v.Args[1].Reg() + p := s.Prog(s390x.AMOVD) + p.From.Scale = 1 + if i == s390x.REGSP { + r, i = i, r + } + p.From.Type = obj.TYPE_ADDR + p.From.Reg = r + p.From.Index = i + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XMOVDaddr: + p := s.Prog(s390x.AMOVD) + p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XCMP, ssa.OpS390XCMPW, ssa.OpS390XCMPU, ssa.OpS390XCMPWU: + opregreg(s, v.Op.Asm(), v.Args[1].Reg(), v.Args[0].Reg()) + case ssa.OpS390XFCMPS, ssa.OpS390XFCMP: + opregreg(s, v.Op.Asm(), v.Args[1].Reg(), v.Args[0].Reg()) + case ssa.OpS390XCMPconst, ssa.OpS390XCMPWconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_CONST + p.To.Offset = v.AuxInt + case ssa.OpS390XCMPUconst, ssa.OpS390XCMPWUconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_CONST + p.To.Offset = int64(uint32(v.AuxInt)) + case ssa.OpS390XMOVDconst: + x := v.Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = v.AuxInt + p.To.Type = obj.TYPE_REG + p.To.Reg = x + case ssa.OpS390XFMOVSconst, ssa.OpS390XFMOVDconst: + x := v.Reg() + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_FCONST + p.From.Val = math.Float64frombits(uint64(v.AuxInt)) + p.To.Type = obj.TYPE_REG + p.To.Reg = x + case ssa.OpS390XADDWload, ssa.OpS390XADDload, + ssa.OpS390XMULLWload, ssa.OpS390XMULLDload, + ssa.OpS390XSUBWload, ssa.OpS390XSUBload, + ssa.OpS390XANDWload, ssa.OpS390XANDload, + ssa.OpS390XORWload, ssa.OpS390XORload, + ssa.OpS390XXORWload, ssa.OpS390XXORload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[1].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XMOVDload, + ssa.OpS390XMOVWZload, ssa.OpS390XMOVHZload, ssa.OpS390XMOVBZload, + ssa.OpS390XMOVDBRload, ssa.OpS390XMOVWBRload, ssa.OpS390XMOVHBRload, + ssa.OpS390XMOVBload, ssa.OpS390XMOVHload, ssa.OpS390XMOVWload, + ssa.OpS390XFMOVSload, ssa.OpS390XFMOVDload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XMOVBZloadidx, ssa.OpS390XMOVHZloadidx, ssa.OpS390XMOVWZloadidx, + ssa.OpS390XMOVBloadidx, ssa.OpS390XMOVHloadidx, ssa.OpS390XMOVWloadidx, ssa.OpS390XMOVDloadidx, + ssa.OpS390XMOVHBRloadidx, ssa.OpS390XMOVWBRloadidx, ssa.OpS390XMOVDBRloadidx, + ssa.OpS390XFMOVSloadidx, ssa.OpS390XFMOVDloadidx: + r := v.Args[0].Reg() + i := v.Args[1].Reg() + if i == s390x.REGSP { + r, i = i, r + } + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = r + p.From.Scale = 1 + p.From.Index = i + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XMOVBstore, ssa.OpS390XMOVHstore, ssa.OpS390XMOVWstore, ssa.OpS390XMOVDstore, + ssa.OpS390XMOVHBRstore, ssa.OpS390XMOVWBRstore, ssa.OpS390XMOVDBRstore, + ssa.OpS390XFMOVSstore, ssa.OpS390XFMOVDstore: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpS390XMOVBstoreidx, ssa.OpS390XMOVHstoreidx, ssa.OpS390XMOVWstoreidx, ssa.OpS390XMOVDstoreidx, + ssa.OpS390XMOVHBRstoreidx, ssa.OpS390XMOVWBRstoreidx, ssa.OpS390XMOVDBRstoreidx, + ssa.OpS390XFMOVSstoreidx, ssa.OpS390XFMOVDstoreidx: + r := v.Args[0].Reg() + i := v.Args[1].Reg() + if i == s390x.REGSP { + r, i = i, r + } + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[2].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = r + p.To.Scale = 1 + p.To.Index = i + ssagen.AddAux(&p.To, v) + case ssa.OpS390XMOVDstoreconst, ssa.OpS390XMOVWstoreconst, ssa.OpS390XMOVHstoreconst, ssa.OpS390XMOVBstoreconst: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + sc := v.AuxValAndOff() + p.From.Offset = sc.Val64() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux2(&p.To, v, sc.Off64()) + case ssa.OpS390XMOVBreg, ssa.OpS390XMOVHreg, ssa.OpS390XMOVWreg, + ssa.OpS390XMOVBZreg, ssa.OpS390XMOVHZreg, ssa.OpS390XMOVWZreg, + ssa.OpS390XLDGR, ssa.OpS390XLGDR, + ssa.OpS390XCEFBRA, ssa.OpS390XCDFBRA, ssa.OpS390XCEGBRA, ssa.OpS390XCDGBRA, + ssa.OpS390XCFEBRA, ssa.OpS390XCFDBRA, ssa.OpS390XCGEBRA, ssa.OpS390XCGDBRA, + ssa.OpS390XCELFBR, ssa.OpS390XCDLFBR, ssa.OpS390XCELGBR, ssa.OpS390XCDLGBR, + ssa.OpS390XCLFEBR, ssa.OpS390XCLFDBR, ssa.OpS390XCLGEBR, ssa.OpS390XCLGDBR, + ssa.OpS390XLDEBR, ssa.OpS390XLEDBR, + ssa.OpS390XFNEG, ssa.OpS390XFNEGS, + ssa.OpS390XLPDFR, ssa.OpS390XLNDFR: + opregreg(s, v.Op.Asm(), v.Reg(), v.Args[0].Reg()) + case ssa.OpS390XCLEAR: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + sc := v.AuxValAndOff() + p.From.Offset = sc.Val64() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux2(&p.To, v, sc.Off64()) + case ssa.OpCopy: + if v.Type.IsMemory() { + return + } + x := v.Args[0].Reg() + y := v.Reg() + if x != y { + opregreg(s, moveByType(v.Type), y, x) + } + case ssa.OpLoadReg: + if v.Type.IsFlags() { + v.Fatalf("load flags not implemented: %v", v.LongString()) + return + } + p := s.Prog(loadByType(v.Type)) + ssagen.AddrAuto(&p.From, v.Args[0]) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpStoreReg: + if v.Type.IsFlags() { + v.Fatalf("store flags not implemented: %v", v.LongString()) + return + } + p := s.Prog(storeByType(v.Type)) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + ssagen.AddrAuto(&p.To, v) + case ssa.OpArgIntReg, ssa.OpArgFloatReg: + // The assembler needs to wrap the entry safepoint/stack growth code with spill/unspill + // The loop only runs once. + for _, a := range v.Block.Func.RegArgs { + // Pass the spill/unspill information along to the assembler, offset by size of + // the saved LR slot. + addr := ssagen.SpillSlotAddr(a, s390x.REGSP, base.Ctxt.Arch.FixedFrameSize) + s.FuncInfo().AddSpill( + obj.RegSpill{Reg: a.Reg, Addr: addr, Unspill: loadByType(a.Type), Spill: storeByType(a.Type)}) + } + v.Block.Func.RegArgs = nil + + ssagen.CheckArgReg(v) + case ssa.OpS390XLoweredGetClosurePtr: + // Closure pointer is R12 (already) + ssagen.CheckLoweredGetClosurePtr(v) + case ssa.OpS390XLoweredRound32F, ssa.OpS390XLoweredRound64F: + // input is already rounded + case ssa.OpS390XLoweredGetG: + r := v.Reg() + p := s.Prog(s390x.AMOVD) + p.From.Type = obj.TYPE_REG + p.From.Reg = s390x.REGG + p.To.Type = obj.TYPE_REG + p.To.Reg = r + case ssa.OpS390XLoweredGetCallerSP: + // caller's SP is FixedFrameSize below the address of the first arg + p := s.Prog(s390x.AMOVD) + p.From.Type = obj.TYPE_ADDR + p.From.Offset = -base.Ctxt.Arch.FixedFrameSize + p.From.Name = obj.NAME_PARAM + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XLoweredGetCallerPC: + p := s.Prog(obj.AGETCALLERPC) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XCALLstatic, ssa.OpS390XCALLclosure, ssa.OpS390XCALLinter: + s.Call(v) + case ssa.OpS390XCALLtail: + s.TailCall(v) + case ssa.OpS390XLoweredWB: + p := s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + // AuxInt encodes how many buffer entries we need. + p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1] + + case ssa.OpS390XLoweredPanicBoundsRR, ssa.OpS390XLoweredPanicBoundsRC, ssa.OpS390XLoweredPanicBoundsCR, ssa.OpS390XLoweredPanicBoundsCC: + // Compute the constant we put in the PCData entry for this call. + code, signed := ssa.BoundsKind(v.AuxInt).Code() + xIsReg := false + yIsReg := false + xVal := 0 + yVal := 0 + switch v.Op { + case ssa.OpS390XLoweredPanicBoundsRR: + xIsReg = true + xVal = int(v.Args[0].Reg() - s390x.REG_R0) + yIsReg = true + yVal = int(v.Args[1].Reg() - s390x.REG_R0) + case ssa.OpS390XLoweredPanicBoundsRC: + xIsReg = true + xVal = int(v.Args[0].Reg() - s390x.REG_R0) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + if yVal == xVal { + yVal = 1 + } + p := s.Prog(s390x.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = s390x.REG_R0 + int16(yVal) + } + case ssa.OpS390XLoweredPanicBoundsCR: + yIsReg = true + yVal = int(v.Args[0].Reg() - s390x.REG_R0) + c := v.Aux.(ssa.PanicBoundsC).C + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + if xVal == yVal { + xVal = 1 + } + p := s.Prog(s390x.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = s390x.REG_R0 + int16(xVal) + } + case ssa.OpS390XLoweredPanicBoundsCC: + c := v.Aux.(ssa.PanicBoundsCC).Cx + if c >= 0 && c <= abi.BoundsMaxConst { + xVal = int(c) + } else { + // Move constant to a register + xIsReg = true + p := s.Prog(s390x.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = s390x.REG_R0 + int16(xVal) + } + c = v.Aux.(ssa.PanicBoundsCC).Cy + if c >= 0 && c <= abi.BoundsMaxConst { + yVal = int(c) + } else { + // Move constant to a register + yIsReg = true + yVal = 1 + p := s.Prog(s390x.AMOVD) + p.From.Type = obj.TYPE_CONST + p.From.Offset = c + p.To.Type = obj.TYPE_REG + p.To.Reg = s390x.REG_R0 + int16(yVal) + } + } + c := abi.BoundsEncode(code, signed, xIsReg, yIsReg, xVal, yVal) + + p := s.Prog(obj.APCDATA) + p.From.SetConst(abi.PCDATA_PanicBounds) + p.To.SetConst(int64(c)) + p = s.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.PanicBounds + + case ssa.OpS390XFLOGR, ssa.OpS390XPOPCNT, + ssa.OpS390XNEG, ssa.OpS390XNEGW, + ssa.OpS390XMOVWBR, ssa.OpS390XMOVDBR: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XNOT, ssa.OpS390XNOTW: + v.Fatalf("NOT/NOTW generated %s", v.LongString()) + case ssa.OpS390XSumBytes2, ssa.OpS390XSumBytes4, ssa.OpS390XSumBytes8: + v.Fatalf("SumBytes generated %s", v.LongString()) + case ssa.OpS390XLOCGR: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(v.Aux.(s390x.CCMask)) + p.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XFSQRTS, ssa.OpS390XFSQRT: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[0].Reg() + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg() + case ssa.OpS390XLTDBR, ssa.OpS390XLTEBR: + opregreg(s, v.Op.Asm(), v.Args[0].Reg(), v.Args[0].Reg()) + case ssa.OpS390XInvertFlags: + v.Fatalf("InvertFlags should never make it to codegen %v", v.LongString()) + case ssa.OpS390XFlagEQ, ssa.OpS390XFlagLT, ssa.OpS390XFlagGT, ssa.OpS390XFlagOV: + v.Fatalf("Flag* ops should never make it to codegen %v", v.LongString()) + case ssa.OpS390XAddTupleFirst32, ssa.OpS390XAddTupleFirst64: + v.Fatalf("AddTupleFirst* should never make it to codegen %v", v.LongString()) + case ssa.OpS390XLoweredNilCheck: + // Issue a load which will fault if the input is nil. + p := s.Prog(s390x.AMOVBZ) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = s390x.REGTMP + if logopt.Enabled() { + logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name) + } + if base.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers + base.WarnfAt(v.Pos, "generated nil check") + } + case ssa.OpS390XMVC: + vo := v.AuxValAndOff() + p := s.Prog(s390x.AMVC) + p.From.Type = obj.TYPE_CONST + p.From.Offset = vo.Val64() + p.AddRestSource(obj.Addr{ + Type: obj.TYPE_MEM, + Reg: v.Args[1].Reg(), + Offset: vo.Off64(), + }) + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + p.To.Offset = vo.Off64() + case ssa.OpS390XSTMG2, ssa.OpS390XSTMG3, ssa.OpS390XSTMG4, + ssa.OpS390XSTM2, ssa.OpS390XSTM3, ssa.OpS390XSTM4: + for i := 2; i < len(v.Args)-1; i++ { + if v.Args[i].Reg() != v.Args[i-1].Reg()+1 { + v.Fatalf("invalid store multiple %s", v.LongString()) + } + } + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.Reg = v.Args[len(v.Args)-2].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpS390XLoweredMove: + // Inputs must be valid pointers to memory, + // so adjust arg0 and arg1 as part of the expansion. + // arg2 should be src+size, + // + // mvc: MVC $256, 0(R2), 0(R1) + // MOVD $256(R1), R1 + // MOVD $256(R2), R2 + // CMP R2, Rarg2 + // BNE mvc + // MVC $rem, 0(R2), 0(R1) // if rem > 0 + // arg2 is the last address to move in the loop + 256 + mvc := s.Prog(s390x.AMVC) + mvc.From.Type = obj.TYPE_CONST + mvc.From.Offset = 256 + mvc.AddRestSource(obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[1].Reg()}) + mvc.To.Type = obj.TYPE_MEM + mvc.To.Reg = v.Args[0].Reg() + + for i := 0; i < 2; i++ { + movd := s.Prog(s390x.AMOVD) + movd.From.Type = obj.TYPE_ADDR + movd.From.Reg = v.Args[i].Reg() + movd.From.Offset = 256 + movd.To.Type = obj.TYPE_REG + movd.To.Reg = v.Args[i].Reg() + } + + cmpu := s.Prog(s390x.ACMPU) + cmpu.From.Reg = v.Args[1].Reg() + cmpu.From.Type = obj.TYPE_REG + cmpu.To.Reg = v.Args[2].Reg() + cmpu.To.Type = obj.TYPE_REG + + bne := s.Prog(s390x.ABLT) + bne.To.Type = obj.TYPE_BRANCH + bne.To.SetTarget(mvc) + + if v.AuxInt > 0 { + mvc := s.Prog(s390x.AMVC) + mvc.From.Type = obj.TYPE_CONST + mvc.From.Offset = v.AuxInt + mvc.AddRestSource(obj.Addr{Type: obj.TYPE_MEM, Reg: v.Args[1].Reg()}) + mvc.To.Type = obj.TYPE_MEM + mvc.To.Reg = v.Args[0].Reg() + } + case ssa.OpS390XLoweredZero: + // Input must be valid pointers to memory, + // so adjust arg0 as part of the expansion. + // arg1 should be src+size, + // + // clear: CLEAR $256, 0(R1) + // MOVD $256(R1), R1 + // CMP R1, Rarg1 + // BNE clear + // CLEAR $rem, 0(R1) // if rem > 0 + // arg1 is the last address to zero in the loop + 256 + clear := s.Prog(s390x.ACLEAR) + clear.From.Type = obj.TYPE_CONST + clear.From.Offset = 256 + clear.To.Type = obj.TYPE_MEM + clear.To.Reg = v.Args[0].Reg() + + movd := s.Prog(s390x.AMOVD) + movd.From.Type = obj.TYPE_ADDR + movd.From.Reg = v.Args[0].Reg() + movd.From.Offset = 256 + movd.To.Type = obj.TYPE_REG + movd.To.Reg = v.Args[0].Reg() + + cmpu := s.Prog(s390x.ACMPU) + cmpu.From.Reg = v.Args[0].Reg() + cmpu.From.Type = obj.TYPE_REG + cmpu.To.Reg = v.Args[1].Reg() + cmpu.To.Type = obj.TYPE_REG + + bne := s.Prog(s390x.ABLT) + bne.To.Type = obj.TYPE_BRANCH + bne.To.SetTarget(clear) + + if v.AuxInt > 0 { + clear := s.Prog(s390x.ACLEAR) + clear.From.Type = obj.TYPE_CONST + clear.From.Offset = v.AuxInt + clear.To.Type = obj.TYPE_MEM + clear.To.Reg = v.Args[0].Reg() + } + case ssa.OpS390XMOVBZatomicload, ssa.OpS390XMOVWZatomicload, ssa.OpS390XMOVDatomicload: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_MEM + p.From.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.From, v) + p.To.Type = obj.TYPE_REG + p.To.Reg = v.Reg0() + case ssa.OpS390XMOVBatomicstore, ssa.OpS390XMOVWatomicstore, ssa.OpS390XMOVDatomicstore: + p := s.Prog(v.Op.Asm()) + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpS390XLAN, ssa.OpS390XLAO: + // LA(N|O) Ry, TMP, 0(Rx) + op := s.Prog(v.Op.Asm()) + op.From.Type = obj.TYPE_REG + op.From.Reg = v.Args[1].Reg() + op.Reg = s390x.REGTMP + op.To.Type = obj.TYPE_MEM + op.To.Reg = v.Args[0].Reg() + case ssa.OpS390XLANfloor, ssa.OpS390XLAOfloor: + r := v.Args[0].Reg() // clobbered, assumed R1 in comments + + // Round ptr down to nearest multiple of 4. + // ANDW $~3, R1 + ptr := s.Prog(s390x.AANDW) + ptr.From.Type = obj.TYPE_CONST + ptr.From.Offset = 0xfffffffc + ptr.To.Type = obj.TYPE_REG + ptr.To.Reg = r + + // Redirect output of LA(N|O) into R1 since it is clobbered anyway. + // LA(N|O) Rx, R1, 0(R1) + op := s.Prog(v.Op.Asm()) + op.From.Type = obj.TYPE_REG + op.From.Reg = v.Args[1].Reg() + op.Reg = r + op.To.Type = obj.TYPE_MEM + op.To.Reg = r + case ssa.OpS390XLAA, ssa.OpS390XLAAG: + p := s.Prog(v.Op.Asm()) + p.Reg = v.Reg0() + p.From.Type = obj.TYPE_REG + p.From.Reg = v.Args[1].Reg() + p.To.Type = obj.TYPE_MEM + p.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&p.To, v) + case ssa.OpS390XLoweredAtomicCas32, ssa.OpS390XLoweredAtomicCas64: + // Convert the flags output of CS{,G} into a bool. + // CS{,G} arg1, arg2, arg0 + // MOVD $0, ret + // BNE 2(PC) + // MOVD $1, ret + // NOP (so the BNE has somewhere to land) + + // CS{,G} arg1, arg2, arg0 + cs := s.Prog(v.Op.Asm()) + cs.From.Type = obj.TYPE_REG + cs.From.Reg = v.Args[1].Reg() // old + cs.Reg = v.Args[2].Reg() // new + cs.To.Type = obj.TYPE_MEM + cs.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&cs.To, v) + + // MOVD $0, ret + movd := s.Prog(s390x.AMOVD) + movd.From.Type = obj.TYPE_CONST + movd.From.Offset = 0 + movd.To.Type = obj.TYPE_REG + movd.To.Reg = v.Reg0() + + // BNE 2(PC) + bne := s.Prog(s390x.ABNE) + bne.To.Type = obj.TYPE_BRANCH + + // MOVD $1, ret + movd = s.Prog(s390x.AMOVD) + movd.From.Type = obj.TYPE_CONST + movd.From.Offset = 1 + movd.To.Type = obj.TYPE_REG + movd.To.Reg = v.Reg0() + + // NOP (so the BNE has somewhere to land) + nop := s.Prog(obj.ANOP) + bne.To.SetTarget(nop) + case ssa.OpS390XLoweredAtomicExchange32, ssa.OpS390XLoweredAtomicExchange64: + // Loop until the CS{,G} succeeds. + // MOV{WZ,D} arg0, ret + // cs: CS{,G} ret, arg1, arg0 + // BNE cs + + // MOV{WZ,D} arg0, ret + load := s.Prog(loadByType(v.Type.FieldType(0))) + load.From.Type = obj.TYPE_MEM + load.From.Reg = v.Args[0].Reg() + load.To.Type = obj.TYPE_REG + load.To.Reg = v.Reg0() + ssagen.AddAux(&load.From, v) + + // CS{,G} ret, arg1, arg0 + cs := s.Prog(v.Op.Asm()) + cs.From.Type = obj.TYPE_REG + cs.From.Reg = v.Reg0() // old + cs.Reg = v.Args[1].Reg() // new + cs.To.Type = obj.TYPE_MEM + cs.To.Reg = v.Args[0].Reg() + ssagen.AddAux(&cs.To, v) + + // BNE cs + bne := s.Prog(s390x.ABNE) + bne.To.Type = obj.TYPE_BRANCH + bne.To.SetTarget(cs) + case ssa.OpS390XSYNC: + s.Prog(s390x.ASYNC) + case ssa.OpClobber, ssa.OpClobberReg: + // TODO: implement for clobberdead experiment. Nop is ok for now. + default: + v.Fatalf("genValue not implemented: %s", v.LongString()) + } +} + +func blockAsm(b *ssa.Block) obj.As { + switch b.Kind { + case ssa.BlockS390XBRC: + return s390x.ABRC + case ssa.BlockS390XCRJ: + return s390x.ACRJ + case ssa.BlockS390XCGRJ: + return s390x.ACGRJ + case ssa.BlockS390XCLRJ: + return s390x.ACLRJ + case ssa.BlockS390XCLGRJ: + return s390x.ACLGRJ + case ssa.BlockS390XCIJ: + return s390x.ACIJ + case ssa.BlockS390XCGIJ: + return s390x.ACGIJ + case ssa.BlockS390XCLIJ: + return s390x.ACLIJ + case ssa.BlockS390XCLGIJ: + return s390x.ACLGIJ + } + b.Fatalf("blockAsm not implemented: %s", b.LongString()) + panic("unreachable") +} + +func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) { + // Handle generic blocks first. + switch b.Kind { + case ssa.BlockPlain, ssa.BlockDefer: + if b.Succs[0].Block() != next { + p := s.Prog(s390x.ABR) + p.To.Type = obj.TYPE_BRANCH + s.Branches = append(s.Branches, ssagen.Branch{P: p, B: b.Succs[0].Block()}) + } + return + case ssa.BlockExit, ssa.BlockRetJmp: + return + case ssa.BlockRet: + s.Prog(obj.ARET) + return + } + + // Handle s390x-specific blocks. These blocks all have a + // condition code mask in the Aux value and 2 successors. + succs := [...]*ssa.Block{b.Succs[0].Block(), b.Succs[1].Block()} + mask := b.Aux.(s390x.CCMask) + + // TODO: take into account Likely property for forward/backward + // branches. We currently can't do this because we don't know + // whether a block has already been emitted. In general forward + // branches are assumed 'not taken' and backward branches are + // assumed 'taken'. + if next == succs[0] { + succs[0], succs[1] = succs[1], succs[0] + mask = mask.Inverse() + } + + p := s.Br(blockAsm(b), succs[0]) + switch b.Kind { + case ssa.BlockS390XBRC: + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(mask) + case ssa.BlockS390XCGRJ, ssa.BlockS390XCRJ, + ssa.BlockS390XCLGRJ, ssa.BlockS390XCLRJ: + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(mask & s390x.NotUnordered) // unordered is not possible + p.Reg = b.Controls[0].Reg() + p.AddRestSourceReg(b.Controls[1].Reg()) + case ssa.BlockS390XCGIJ, ssa.BlockS390XCIJ: + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(mask & s390x.NotUnordered) // unordered is not possible + p.Reg = b.Controls[0].Reg() + p.AddRestSourceConst(int64(int8(b.AuxInt))) + case ssa.BlockS390XCLGIJ, ssa.BlockS390XCLIJ: + p.From.Type = obj.TYPE_CONST + p.From.Offset = int64(mask & s390x.NotUnordered) // unordered is not possible + p.Reg = b.Controls[0].Reg() + p.AddRestSourceConst(int64(uint8(b.AuxInt))) + default: + b.Fatalf("branch not implemented: %s", b.LongString()) + } + if next != succs[1] { + s.Br(s390x.ABR, succs[1]) + } +} + +func loadRegResult(s *ssagen.State, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p := s.Prog(loadByType(t)) + p.From.Type = obj.TYPE_MEM + p.From.Name = obj.NAME_AUTO + p.From.Sym = n.Linksym() + p.From.Offset = n.FrameOffset() + off + p.To.Type = obj.TYPE_REG + p.To.Reg = reg + return p +} + +func spillArgReg(pp *objw.Progs, p *obj.Prog, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog { + p = pp.Append(p, storeByType(t), obj.TYPE_REG, reg, 0, obj.TYPE_MEM, 0, n.FrameOffset()+off) + p.To.Name = obj.NAME_PARAM + p.To.Sym = n.Linksym() + p.Pos = p.Pos.WithNotStmt() + return p +} diff --git a/go/src/cmd/compile/internal/slice/slice.go b/go/src/cmd/compile/internal/slice/slice.go new file mode 100644 index 0000000000000000000000000000000000000000..17eba5b77265612c7847301202d827c97121579f --- /dev/null +++ b/go/src/cmd/compile/internal/slice/slice.go @@ -0,0 +1,475 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package slice + +// This file implements a stack-allocation optimization +// for the backing store of slices. +// +// Consider the code: +// +// var s []int +// for i := range ... { +// s = append(s, i) +// } +// return s +// +// Some of the append operations will need to do an allocation +// by calling growslice. This will happen on the 1st, 2nd, 4th, +// 8th, etc. append calls. The allocations done by all but the +// last growslice call will then immediately be garbage. +// +// We'd like to avoid doing some of those intermediate +// allocations if possible. +// +// If we can determine that the "return s" statement is the +// *only* way that the backing store for s escapes, then we +// can rewrite the code to something like: +// +// var s []int +// for i := range N { +// s = append(s, i) +// } +// s = move2heap(s) +// return s +// +// Using the move2heap runtime function, which does: +// +// move2heap(s): +// If s is not backed by a stackframe-allocated +// backing store, return s. Otherwise, copy s +// to the heap and return the copy. +// +// Now we can treat the backing store of s allocated at the +// append site as not escaping. Previous stack allocation +// optimizations now apply, which can use a fixed-size +// stack-allocated backing store for s when appending. +// (See ../ssagen/ssa.go:(*state).append) +// +// It is tricky to do this optimization safely. To describe +// our analysis, we first define what an "exclusive" slice +// variable is. +// +// A slice variable (a variable of slice type) is called +// "exclusive" if, when it has a reference to a +// stackframe-allocated backing store, it is the only +// variable with such a reference. +// +// In other words, a slice variable is exclusive if +// any of the following holds: +// 1) It points to a heap-allocated backing store +// 2) It points to a stack-allocated backing store +// for any parent frame. +// 3) It is the only variable that references its +// backing store. +// 4) It is nil. +// +// The nice thing about exclusive slice variables is that +// it is always safe to do +// s = move2heap(s) +// whenever s is an exclusive slice variable. Because no +// one else has a reference to the backing store, no one +// else can tell that we moved the backing store from one +// location to another. +// +// Note that exclusiveness is a dynamic property. A slice +// variable may be exclusive during some parts of execution +// and not exclusive during others. +// +// The following operations set or preserve the exclusivity +// of a slice variable s: +// s = nil +// s = append(s, ...) +// s = s[i:j] +// ... = s[i] +// s[i] = ... +// f(s) where f does not escape its argument +// Other operations destroy exclusivity. A non-exhaustive list includes: +// x = s +// *p = s +// f(s) where f escapes its argument +// return s +// To err on the safe side, we white list exclusivity-preserving +// operations and we asssume that any other operations that mention s +// destroy its exclusivity. +// +// Our strategy is to move the backing store of s to the heap before +// any exclusive->nonexclusive transition. That way, s will only ever +// have a reference to a stack backing store while it is exclusive. +// +// move2heap for a variable s is implemented with: +// if s points to within the stack frame { +// s2 := make([]T, s.len, s.cap) +// copy(s2[:s.cap], s[:s.cap]) +// s = s2 +// } +// Note that in general we need to copy all of s[:cap(s)] elements when +// moving to the heap. As an optimization, we keep track of slice variables +// whose capacity, and the elements in s[len(s):cap(s)], are never accessed. +// For those slice variables, we can allocate to the next size class above +// the length, which saves memory and copying cost. + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/escape" + "cmd/compile/internal/ir" + "cmd/compile/internal/reflectdata" +) + +func Funcs(all []*ir.Func) { + if base.Flag.N != 0 { + return + } + for _, fn := range all { + analyze(fn) + } +} + +func analyze(fn *ir.Func) { + type sliceInfo struct { + // Slice variable. + s *ir.Name + + // Count of uses that this pass understands. + okUses int32 + // Count of all uses found. + allUses int32 + + // A place where the slice variable transitions from + // exclusive to nonexclusive. + // We could keep track of more than one, but one is enough for now. + // Currently, this can be either a return statement or + // an assignment. + // TODO: other possible transitions? + transition ir.Stmt + + // Each s = append(s, ...) instance we found. + appends []*ir.CallExpr + + // Weight of the number of s = append(s, ...) instances we found. + // The optimizations we do are only really useful if there are at + // least weight 2. (Note: appends in loops have weight >= 2.) + appendWeight int + + // Loop depth at declaration point. + // Use for heuristics only, it is not guaranteed to be correct + // in the presence of gotos. + declDepth int + + // Whether we ever do cap(s), or other operations that use cap(s) + // (possibly implicitly), like s[i:j]. + capUsed bool + } + + // Every variable (*ir.Name) that we are tracking will have + // a non-nil *sliceInfo in its Opt field. + haveLocalSlice := false + maxStackSize := int64(base.Debug.VariableMakeThreshold) + var namedRets []*ir.Name + for _, s := range fn.Dcl { + if !s.Type().IsSlice() { + continue + } + if s.Type().Elem().Size() > maxStackSize { + continue + } + if !base.VariableMakeHash.MatchPos(s.Pos(), nil) { + continue + } + s.Opt = &sliceInfo{s: s} // start tracking s + haveLocalSlice = true + if s.Class == ir.PPARAMOUT { + namedRets = append(namedRets, s) + } + } + if !haveLocalSlice { + return + } + + // Keep track of loop depth while walking. + loopDepth := 0 + + // tracking returns the info for the slice variable if n is a slice + // variable that we're still considering, or nil otherwise. + tracking := func(n ir.Node) *sliceInfo { + if n == nil || n.Op() != ir.ONAME { + return nil + } + s := n.(*ir.Name) + if s.Opt == nil { + return nil + } + return s.Opt.(*sliceInfo) + } + + // addTransition(n, loc) records that s experiences an exclusive->nonexclusive + // transition somewhere within loc. + addTransition := func(i *sliceInfo, loc ir.Stmt) { + if i.transition != nil { + // We only keep track of a single exclusive->nonexclusive transition + // for a slice variable. If we find more than one, give up. + // (More than one transition location would be fine, but we would + // start to get worried about introducing too much additional code.) + i.s.Opt = nil + return + } + if loopDepth > i.declDepth { + // Conservatively, we disable this optimization when the + // transition is inside a loop. This can result in adding + // overhead unnecessarily in cases like: + // func f(n int, p *[]byte) { + // var s []byte + // for i := range n { + // *p = s + // s = append(s, 0) + // } + // } + i.s.Opt = nil + return + } + i.transition = loc + } + + // Examine an x = y assignment that occurs somewhere within statement stmt. + assign := func(x, y ir.Node, stmt ir.Stmt) { + if i := tracking(x); i != nil { + // s = y. Check for understood patterns for y. + if y == nil || y.Op() == ir.ONIL { + // s = nil is ok. + i.okUses++ + } else if y.Op() == ir.OSLICELIT { + // s = []{...} is ok. + // Note: this reveals capacity. Should it? + i.okUses++ + i.capUsed = true + } else if y.Op() == ir.OSLICE { + y := y.(*ir.SliceExpr) + if y.X == i.s { + // s = s[...:...] is ok + i.okUses += 2 + i.capUsed = true + } + } else if y.Op() == ir.OAPPEND { + y := y.(*ir.CallExpr) + if y.Args[0] == i.s { + // s = append(s, ...) is ok + i.okUses += 2 + i.appends = append(i.appends, y) + i.appendWeight += 1 + (loopDepth - i.declDepth) + } + // TODO: s = append(nil, ...)? + } + // Note that technically s = make([]T, ...) preserves exclusivity, but + // we don't track that because we assume users who wrote that know + // better than the compiler does. + + // TODO: figure out how to handle s = fn(..., s, ...) + // It would be nice to maintain exclusivity of s in this situation. + // But unfortunately, fn can return one of its other arguments, which + // may be a slice with a stack-allocated backing store other than s. + // (which may have preexisting references to its backing store). + // + // Maybe we could do it if s is the only argument? + } + + if i := tracking(y); i != nil { + // ... = s + // Treat this as an exclusive->nonexclusive transition. + i.okUses++ + addTransition(i, stmt) + } + } + + var do func(ir.Node) bool + do = func(n ir.Node) bool { + if n == nil { + return false + } + switch n.Op() { + case ir.ONAME: + if i := tracking(n); i != nil { + // A use of a slice variable. Count it. + i.allUses++ + } + case ir.ODCL: + n := n.(*ir.Decl) + if i := tracking(n.X); i != nil { + i.okUses++ + i.declDepth = loopDepth + } + case ir.OINDEX: + n := n.(*ir.IndexExpr) + if i := tracking(n.X); i != nil { + // s[i] is ok. + i.okUses++ + } + case ir.OLEN: + n := n.(*ir.UnaryExpr) + if i := tracking(n.X); i != nil { + // len(s) is ok + i.okUses++ + } + case ir.OCAP: + n := n.(*ir.UnaryExpr) + if i := tracking(n.X); i != nil { + // cap(s) is ok + i.okUses++ + i.capUsed = true + } + case ir.OADDR: + n := n.(*ir.AddrExpr) + if n.X.Op() == ir.OINDEX { + n := n.X.(*ir.IndexExpr) + if i := tracking(n.X); i != nil { + // &s[i] is definitely a nonexclusive transition. + // (We need this case because s[i] is ok, but &s[i] is not.) + i.s.Opt = nil + } + } + case ir.ORETURN: + n := n.(*ir.ReturnStmt) + for _, x := range n.Results { + if i := tracking(x); i != nil { + i.okUses++ + // We go exclusive->nonexclusive here + addTransition(i, n) + } + } + if len(n.Results) == 0 { + // Uses of named result variables are implicit here. + for _, x := range namedRets { + if i := tracking(x); i != nil { + addTransition(i, n) + } + } + } + case ir.OCALLFUNC: + n := n.(*ir.CallExpr) + for idx, arg := range n.Args { + if i := tracking(arg); i != nil { + if !argLeak(n, idx) { + // Passing s to a nonescaping arg is ok. + i.okUses++ + i.capUsed = true + } + } + } + case ir.ORANGE: + // Range over slice is ok. + n := n.(*ir.RangeStmt) + if i := tracking(n.X); i != nil { + i.okUses++ + } + case ir.OAS: + n := n.(*ir.AssignStmt) + assign(n.X, n.Y, n) + case ir.OAS2: + n := n.(*ir.AssignListStmt) + for i := range len(n.Lhs) { + assign(n.Lhs[i], n.Rhs[i], n) + } + case ir.OCLOSURE: + n := n.(*ir.ClosureExpr) + for _, v := range n.Func.ClosureVars { + do(v.Outer) + } + } + if n.Op() == ir.OFOR || n.Op() == ir.ORANGE { + // Note: loopDepth isn't really right for init portion + // of the for statement, but that's ok. Correctness + // does not depend on depth info. + loopDepth++ + defer func() { loopDepth-- }() + } + // Check all the children. + ir.DoChildren(n, do) + return false + } + + // Run the analysis over the whole body. + for _, stmt := range fn.Body { + do(stmt) + } + + // Process accumulated info to find slice variables + // that we can allocate on the stack. + for _, s := range fn.Dcl { + if s.Opt == nil { + continue + } + i := s.Opt.(*sliceInfo) + s.Opt = nil + if i.okUses != i.allUses { + // Some use of i.s that don't understand lurks. Give up. + continue + } + + // At this point, we've decided that we *can* do + // the optimization. + + if i.transition == nil { + // Exclusive for its whole lifetime. That means it + // didn't escape. We can already handle nonescaping + // slices without this pass. + continue + } + if i.appendWeight < 2 { + // This optimization only really helps if there is + // (dynamically) more than one append. + continue + } + + // Commit point - at this point we've decided we *should* + // do the optimization. + + // Insert a move2heap operation before the exclusive->nonexclusive + // transition. + move := ir.NewMoveToHeapExpr(i.transition.Pos(), i.s) + if i.capUsed { + move.PreserveCapacity = true + } + move.RType = reflectdata.AppendElemRType(i.transition.Pos(), i.appends[0]) + move.SetType(i.s.Type()) + move.SetTypecheck(1) + as := ir.NewAssignStmt(i.transition.Pos(), i.s, move) + as.SetTypecheck(1) + i.transition.PtrInit().Prepend(as) + // Note: we prepend because we need to put the move2heap + // operation first, before any other init work, as the transition + // might occur in the init work. + + // Now that we've inserted a move2heap operation before every + // exclusive -> nonexclusive transition, appends can now use + // stack backing stores. + // (This is the whole point of this pass, to enable stack + // allocation of append backing stores.) + for _, a := range i.appends { + a.SetEsc(ir.EscNone) + if i.capUsed { + a.UseBuf = true + } + } + } +} + +// argLeak reports if the idx'th argument to the call n escapes anywhere +// (to the heap, another argument, return value, etc.) +// If unknown returns true. +func argLeak(n *ir.CallExpr, idx int) bool { + if n.Op() != ir.OCALLFUNC { + return true + } + fn := ir.StaticCalleeName(ir.StaticValue(n.Fun)) + if fn == nil { + return true + } + fntype := fn.Type() + if recv := fntype.Recv(); recv != nil { + if idx == 0 { + return escape.ParseLeaks(recv.Note).Any() + } + idx-- + } + return escape.ParseLeaks(fntype.Params()[idx].Note).Any() +} diff --git a/go/src/cmd/compile/internal/ssa/README.md b/go/src/cmd/compile/internal/ssa/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3626f5bb7b2083c03e47efbe6fdce99cdb233adb --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/README.md @@ -0,0 +1,245 @@ + + +## Introduction to the Go compiler's SSA backend + +This package contains the compiler's Static Single Assignment form component. If +you're not familiar with SSA, its [Wikipedia +article](https://en.wikipedia.org/wiki/Static_single_assignment_form) is a good +starting point. + +It is recommended that you first read [cmd/compile/README.md](../../README.md) +if you are not familiar with the Go compiler already. That document gives an +overview of the compiler, and explains what is SSA's part and purpose in it. + +### Key concepts + +The names described below may be loosely related to their Go counterparts, but +note that they are not equivalent. For example, a Go block statement has a +variable scope, yet SSA has no notion of variables nor variable scopes. + +It may also be surprising that values and blocks are named after their unique +sequential IDs. They rarely correspond to named entities in the original code, +such as variables or function parameters. The sequential IDs also allow the +compiler to avoid maps, and it is always possible to track back the values to Go +code using debug and position information. + +#### Values + +Values are the basic building blocks of SSA. Per SSA's very definition, a +value is defined exactly once, but it may be used any number of times. A value +mainly consists of a unique identifier, an operator, a type, and some arguments. + +An operator or `Op` describes the operation that computes the value. The +semantics of each operator can be found in `_gen/*Ops.go`. For example, `OpAdd8` +takes two value arguments holding 8-bit integers and results in their addition. +Here is a possible SSA representation of the addition of two `uint8` values: + + // var c uint8 = a + b + v4 = Add8 v2 v3 + +A value's type will usually be a Go type. For example, the value in the example +above has a `uint8` type, and a constant boolean value will have a `bool` type. +However, certain types don't come from Go and are special; below we will cover +`memory`, the most common of them. + +Some operators contain an auxiliary field. The aux fields are usually printed as +enclosed in `[]` or `{}`, and could be the constant op argument, argument type, +etc. For example: + + v13 (?) = Const64 [1] + +Here the aux field is the constant op argument, the op is creating a `Const64` +value of 1. One more example: + + v17 (361) = Store {int} v16 v14 v8 + +Here the aux field is the type of the value being `Store`ed, which is int. + +See [value.go](value.go) and `_gen/*Ops.go` for more information. + +#### Memory types + +`memory` represents the global memory state. An `Op` that takes a memory +argument depends on that memory state, and an `Op` which has the memory type +impacts the state of memory. This ensures that memory operations are kept in the +right order. For example: + + // *a = 3 + // *b = *a + v10 = Store {int} v6 v8 v1 + v14 = Store {int} v7 v8 v10 + +Here, `Store` stores its second argument (of type `int`) into the first argument +(of type `*int`). The last argument is the memory state; since the second store +depends on the memory value defined by the first store, the two stores cannot be +reordered. + +See [cmd/compile/internal/types/type.go](../types/type.go) for more information. + +#### Blocks + +A block represents a basic block in the control flow graph of a function. It is, +essentially, a list of values that define the operation of this block. Besides +the list of values, blocks mainly consist of a unique identifier, a kind, and a +list of successor blocks. + +The simplest kind is a `plain` block; it simply hands the control flow to +another block, thus its successors list contains one block. + +Another common block kind is the `exit` block. These have a final value, called +control value, which must return a memory state. This is necessary for functions +to return some values, for example - the caller needs some memory state to +depend on, to ensure that it receives those return values correctly. + +The last important block kind we will mention is the `if` block. It has a single +control value that must be a boolean value, and it has exactly two successor +blocks. The control flow is handed to the first successor if the bool is true, +and to the second otherwise. + +Here is a sample if-else control flow represented with basic blocks: + + // func(b bool) int { + // if b { + // return 2 + // } + // return 3 + // } + b1: + v1 = InitMem + v2 = SP + v5 = Addr <*int> {~r1} v2 + v6 = Arg {b} + v8 = Const64 [2] + v12 = Const64 [3] + If v6 -> b2 b3 + b2: <- b1 + v10 = VarDef {~r1} v1 + v11 = Store {int} v5 v8 v10 + Ret v11 + b3: <- b1 + v14 = VarDef {~r1} v1 + v15 = Store {int} v5 v12 v14 + Ret v15 + + + +See [block.go](block.go) for more information. + +#### Functions + +A function represents a function declaration along with its body. It mainly +consists of a name, a type (its signature), a list of blocks that form its body, +and the entry block within said list. + +When a function is called, the control flow is handed to its entry block. If the +function terminates, the control flow will eventually reach an exit block, thus +ending the function call. + +Note that a function may have zero or multiple exit blocks, just like a Go +function can have any number of return points, but it must have exactly one +entry point block. + +Also note that some SSA functions are autogenerated, such as the hash functions +for each type used as a map key. + +For example, this is what an empty function can look like in SSA, with a single +exit block that returns an uninteresting memory state: + + foo func() + b1: + v1 = InitMem + Ret v1 + +See [func.go](func.go) for more information. + +### Compiler passes + +Having a program in SSA form is not very useful on its own. Its advantage lies +in how easy it is to write optimizations that modify the program to make it +better. The way the Go compiler accomplishes this is via a list of passes. + +Each pass transforms a SSA function in some way. For example, a dead code +elimination pass will remove blocks and values that it can prove will never be +executed, and a nil check elimination pass will remove nil checks which it can +prove to be redundant. + +Compiler passes work on one function at a time, and by default run sequentially +and exactly once. + +The `lower` pass is special; it converts the SSA representation from being +machine-independent to being machine-dependent. That is, some abstract operators +are replaced with their non-generic counterparts, potentially reducing or +increasing the final number of values. + + + +See the `passes` list defined in [compile.go](compile.go) for more information. + +### Playing with SSA + +A good way to see and get used to the compiler's SSA in action is via +`GOSSAFUNC`. For example, to see func `Foo`'s initial SSA form and final +generated assembly, one can run: + + GOSSAFUNC=Foo go build + +The generated `ssa.html` file will also contain the SSA func at each of the +compile passes, making it easy to see what each pass does to a particular +program. You can also click on values and blocks to highlight them, to help +follow the control flow and values. + +The value specified in GOSSAFUNC can also be a package-qualified function +name, e.g. + + GOSSAFUNC=blah.Foo go build + +This will match any function named "Foo" within a package whose final +suffix is "blah" (e.g. something/blah.Foo, anotherthing/extra/blah.Foo). + +The users may also print the Control Flow Graph(CFG) by specifying in +`GOSSAFUNC` value in the following format: + + GOSSAFUNC="$FunctionName:$PassName1,$PassName2,..." go build + +For example, the following command will print SSA with CFGs attached to the +`sccp` and `generic deadcode` pass columns: + + GOSSAFUNC="blah.Foo:sccp,generic deadcode" go build + +If non-HTML dumps are needed, append a "+" to the GOSSAFUNC value +and dumps will be written to stdout: + + GOSSAFUNC=Bar+ go build + + + +### Hacking on SSA + +While most compiler passes are implemented directly in Go code, some others are +code generated. This is currently done via rewrite rules, which have their own +syntax and are maintained in `_gen/*.rules`. Simpler optimizations can be written +easily and quickly this way, but rewrite rules are not suitable for more complex +optimizations. + +To read more on rewrite rules, have a look at the top comments in +[_gen/generic.rules](_gen/generic.rules) and [_gen/rulegen.go](_gen/rulegen.go). + +Similarly, the code to manage operators is also code generated from +`_gen/*Ops.go`, as it is easier to maintain a few tables than a lot of code. +After changing the rules or operators, run `go generate cmd/compile/internal/ssa` +to generate the Go code again. + + diff --git a/go/src/cmd/compile/internal/ssa/TODO b/go/src/cmd/compile/internal/ssa/TODO new file mode 100644 index 0000000000000000000000000000000000000000..f4e438258c1c4d90c6106ae97070fcd6d6787a57 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/TODO @@ -0,0 +1,24 @@ +This is a list of possible improvements to the SSA pass of the compiler. + +Optimizations (better compiled code) +------------------------------------ +- Reduce register pressure in scheduler +- Make dead store pass inter-block +- If there are a lot of MOVQ $0, ..., then load + 0 into a register and use the register as the source instead. +- Allow large structs to be SSAable (issue 24416) +- Allow arrays of length >1 to be SSAable +- If strings are being passed around without being interpreted (ptr + and len fields being accessed) pass them in xmm registers? + Same for interfaces? +- any pointer generated by unsafe arithmetic must be non-nil? + (Of course that may not be true in general, but it is for all uses + in the runtime, and we can play games with unsafe.) + +Optimizations (better compiler) +------------------------------- +- Handle signed division overflow and sign extension earlier + +Regalloc +-------- +- Make liveness analysis non-quadratic diff --git a/go/src/cmd/compile/internal/ssa/addressingmodes.go b/go/src/cmd/compile/internal/ssa/addressingmodes.go new file mode 100644 index 0000000000000000000000000000000000000000..4e3209e396b5af2266494b95727cca2ce77ab9f9 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/addressingmodes.go @@ -0,0 +1,518 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// addressingModes combines address calculations into memory operations +// that can perform complicated addressing modes. +func addressingModes(f *Func) { + isInImmediateRange := is32Bit + switch f.Config.arch { + default: + // Most architectures can't do this. + return + case "amd64", "386": + case "s390x": + isInImmediateRange = is20Bit + } + + var tmp []*Value + for _, b := range f.Blocks { + for _, v := range b.Values { + if !combineFirst[v.Op] { + continue + } + // All matched operations have the pointer in arg[0]. + // All results have the pointer in arg[0] and the index in arg[1]. + // *Except* for operations which update a register, + // which are marked with resultInArg0. Those have + // the pointer in arg[1], and the corresponding result op + // has the pointer in arg[1] and the index in arg[2]. + ptrIndex := 0 + if opcodeTable[v.Op].resultInArg0 { + ptrIndex = 1 + } + p := v.Args[ptrIndex] + c, ok := combine[[2]Op{v.Op, p.Op}] + if !ok { + continue + } + // See if we can combine the Aux/AuxInt values. + switch [2]auxType{opcodeTable[v.Op].auxType, opcodeTable[p.Op].auxType} { + case [2]auxType{auxSymOff, auxInt32}: + // TODO: introduce auxSymOff32 + if !isInImmediateRange(v.AuxInt + p.AuxInt) { + continue + } + v.AuxInt += p.AuxInt + case [2]auxType{auxSymOff, auxSymOff}: + if v.Aux != nil && p.Aux != nil { + continue + } + if !isInImmediateRange(v.AuxInt + p.AuxInt) { + continue + } + if p.Aux != nil { + v.Aux = p.Aux + } + v.AuxInt += p.AuxInt + case [2]auxType{auxSymValAndOff, auxInt32}: + vo := ValAndOff(v.AuxInt) + if !vo.canAdd64(p.AuxInt) { + continue + } + v.AuxInt = int64(vo.addOffset64(p.AuxInt)) + case [2]auxType{auxSymValAndOff, auxSymOff}: + vo := ValAndOff(v.AuxInt) + if v.Aux != nil && p.Aux != nil { + continue + } + if !vo.canAdd64(p.AuxInt) { + continue + } + if p.Aux != nil { + v.Aux = p.Aux + } + v.AuxInt = int64(vo.addOffset64(p.AuxInt)) + case [2]auxType{auxSymOff, auxNone}: + // nothing to do + case [2]auxType{auxSymValAndOff, auxNone}: + // nothing to do + default: + f.Fatalf("unknown aux combining for %s and %s\n", v.Op, p.Op) + } + // Combine the operations. + tmp = append(tmp[:0], v.Args[:ptrIndex]...) + tmp = append(tmp, p.Args...) + tmp = append(tmp, v.Args[ptrIndex+1:]...) + v.resetArgs() + v.Op = c + v.AddArgs(tmp...) + if needSplit[c] { + // It turns out that some of the combined instructions have faster two-instruction equivalents, + // but not the two instructions that led to them being combined here. For example + // (CMPBconstload c (ADDQ x y)) -> (CMPBconstloadidx1 c x y) -> (CMPB c (MOVBloadidx1 x y)) + // The final pair of instructions turns out to be notably faster, at least in some benchmarks. + f.Config.splitLoad(v) + } + } + } +} + +// combineFirst contains ops which appear in combine as the +// first part of the key. +var combineFirst = map[Op]bool{} + +func init() { + for k := range combine { + combineFirst[k[0]] = true + } +} + +// needSplit contains instructions that should be postprocessed by splitLoad +// into a more-efficient two-instruction form. +var needSplit = map[Op]bool{ + OpAMD64CMPBloadidx1: true, + OpAMD64CMPWloadidx1: true, + OpAMD64CMPLloadidx1: true, + OpAMD64CMPQloadidx1: true, + OpAMD64CMPWloadidx2: true, + OpAMD64CMPLloadidx4: true, + OpAMD64CMPQloadidx8: true, + + OpAMD64CMPBconstloadidx1: true, + OpAMD64CMPWconstloadidx1: true, + OpAMD64CMPLconstloadidx1: true, + OpAMD64CMPQconstloadidx1: true, + OpAMD64CMPWconstloadidx2: true, + OpAMD64CMPLconstloadidx4: true, + OpAMD64CMPQconstloadidx8: true, +} + +// For each entry k, v in this map, if we have a value x with: +// +// x.Op == k[0] +// x.Args[0].Op == k[1] +// +// then we can set x.Op to v and set x.Args like this: +// +// x.Args[0].Args + x.Args[1:] +// +// Additionally, the Aux/AuxInt from x.Args[0] is merged into x. +var combine = map[[2]Op]Op{ + // amd64 + [2]Op{OpAMD64MOVBload, OpAMD64ADDQ}: OpAMD64MOVBloadidx1, + [2]Op{OpAMD64MOVWload, OpAMD64ADDQ}: OpAMD64MOVWloadidx1, + [2]Op{OpAMD64MOVLload, OpAMD64ADDQ}: OpAMD64MOVLloadidx1, + [2]Op{OpAMD64MOVQload, OpAMD64ADDQ}: OpAMD64MOVQloadidx1, + [2]Op{OpAMD64MOVSSload, OpAMD64ADDQ}: OpAMD64MOVSSloadidx1, + [2]Op{OpAMD64MOVSDload, OpAMD64ADDQ}: OpAMD64MOVSDloadidx1, + + [2]Op{OpAMD64MOVBstore, OpAMD64ADDQ}: OpAMD64MOVBstoreidx1, + [2]Op{OpAMD64MOVWstore, OpAMD64ADDQ}: OpAMD64MOVWstoreidx1, + [2]Op{OpAMD64MOVLstore, OpAMD64ADDQ}: OpAMD64MOVLstoreidx1, + [2]Op{OpAMD64MOVQstore, OpAMD64ADDQ}: OpAMD64MOVQstoreidx1, + [2]Op{OpAMD64MOVSSstore, OpAMD64ADDQ}: OpAMD64MOVSSstoreidx1, + [2]Op{OpAMD64MOVSDstore, OpAMD64ADDQ}: OpAMD64MOVSDstoreidx1, + + [2]Op{OpAMD64MOVBstoreconst, OpAMD64ADDQ}: OpAMD64MOVBstoreconstidx1, + [2]Op{OpAMD64MOVWstoreconst, OpAMD64ADDQ}: OpAMD64MOVWstoreconstidx1, + [2]Op{OpAMD64MOVLstoreconst, OpAMD64ADDQ}: OpAMD64MOVLstoreconstidx1, + [2]Op{OpAMD64MOVQstoreconst, OpAMD64ADDQ}: OpAMD64MOVQstoreconstidx1, + + [2]Op{OpAMD64MOVBload, OpAMD64LEAQ1}: OpAMD64MOVBloadidx1, + [2]Op{OpAMD64MOVWload, OpAMD64LEAQ1}: OpAMD64MOVWloadidx1, + [2]Op{OpAMD64MOVWload, OpAMD64LEAQ2}: OpAMD64MOVWloadidx2, + [2]Op{OpAMD64MOVLload, OpAMD64LEAQ1}: OpAMD64MOVLloadidx1, + [2]Op{OpAMD64MOVLload, OpAMD64LEAQ4}: OpAMD64MOVLloadidx4, + [2]Op{OpAMD64MOVLload, OpAMD64LEAQ8}: OpAMD64MOVLloadidx8, + [2]Op{OpAMD64MOVQload, OpAMD64LEAQ1}: OpAMD64MOVQloadidx1, + [2]Op{OpAMD64MOVQload, OpAMD64LEAQ8}: OpAMD64MOVQloadidx8, + [2]Op{OpAMD64MOVSSload, OpAMD64LEAQ1}: OpAMD64MOVSSloadidx1, + [2]Op{OpAMD64MOVSSload, OpAMD64LEAQ4}: OpAMD64MOVSSloadidx4, + [2]Op{OpAMD64MOVSDload, OpAMD64LEAQ1}: OpAMD64MOVSDloadidx1, + [2]Op{OpAMD64MOVSDload, OpAMD64LEAQ8}: OpAMD64MOVSDloadidx8, + + [2]Op{OpAMD64MOVBstore, OpAMD64LEAQ1}: OpAMD64MOVBstoreidx1, + [2]Op{OpAMD64MOVWstore, OpAMD64LEAQ1}: OpAMD64MOVWstoreidx1, + [2]Op{OpAMD64MOVWstore, OpAMD64LEAQ2}: OpAMD64MOVWstoreidx2, + [2]Op{OpAMD64MOVLstore, OpAMD64LEAQ1}: OpAMD64MOVLstoreidx1, + [2]Op{OpAMD64MOVLstore, OpAMD64LEAQ4}: OpAMD64MOVLstoreidx4, + [2]Op{OpAMD64MOVLstore, OpAMD64LEAQ8}: OpAMD64MOVLstoreidx8, + [2]Op{OpAMD64MOVQstore, OpAMD64LEAQ1}: OpAMD64MOVQstoreidx1, + [2]Op{OpAMD64MOVQstore, OpAMD64LEAQ8}: OpAMD64MOVQstoreidx8, + [2]Op{OpAMD64MOVSSstore, OpAMD64LEAQ1}: OpAMD64MOVSSstoreidx1, + [2]Op{OpAMD64MOVSSstore, OpAMD64LEAQ4}: OpAMD64MOVSSstoreidx4, + [2]Op{OpAMD64MOVSDstore, OpAMD64LEAQ1}: OpAMD64MOVSDstoreidx1, + [2]Op{OpAMD64MOVSDstore, OpAMD64LEAQ8}: OpAMD64MOVSDstoreidx8, + + [2]Op{OpAMD64MOVBstoreconst, OpAMD64LEAQ1}: OpAMD64MOVBstoreconstidx1, + [2]Op{OpAMD64MOVWstoreconst, OpAMD64LEAQ1}: OpAMD64MOVWstoreconstidx1, + [2]Op{OpAMD64MOVWstoreconst, OpAMD64LEAQ2}: OpAMD64MOVWstoreconstidx2, + [2]Op{OpAMD64MOVLstoreconst, OpAMD64LEAQ1}: OpAMD64MOVLstoreconstidx1, + [2]Op{OpAMD64MOVLstoreconst, OpAMD64LEAQ4}: OpAMD64MOVLstoreconstidx4, + [2]Op{OpAMD64MOVQstoreconst, OpAMD64LEAQ1}: OpAMD64MOVQstoreconstidx1, + [2]Op{OpAMD64MOVQstoreconst, OpAMD64LEAQ8}: OpAMD64MOVQstoreconstidx8, + + [2]Op{OpAMD64SETEQstore, OpAMD64LEAQ1}: OpAMD64SETEQstoreidx1, + [2]Op{OpAMD64SETNEstore, OpAMD64LEAQ1}: OpAMD64SETNEstoreidx1, + [2]Op{OpAMD64SETLstore, OpAMD64LEAQ1}: OpAMD64SETLstoreidx1, + [2]Op{OpAMD64SETLEstore, OpAMD64LEAQ1}: OpAMD64SETLEstoreidx1, + [2]Op{OpAMD64SETGstore, OpAMD64LEAQ1}: OpAMD64SETGstoreidx1, + [2]Op{OpAMD64SETGEstore, OpAMD64LEAQ1}: OpAMD64SETGEstoreidx1, + [2]Op{OpAMD64SETBstore, OpAMD64LEAQ1}: OpAMD64SETBstoreidx1, + [2]Op{OpAMD64SETBEstore, OpAMD64LEAQ1}: OpAMD64SETBEstoreidx1, + [2]Op{OpAMD64SETAstore, OpAMD64LEAQ1}: OpAMD64SETAstoreidx1, + [2]Op{OpAMD64SETAEstore, OpAMD64LEAQ1}: OpAMD64SETAEstoreidx1, + + // These instructions are re-split differently for performance, see needSplit above. + // TODO if 386 versions are created, also update needSplit and _gen/386splitload.rules + [2]Op{OpAMD64CMPBload, OpAMD64ADDQ}: OpAMD64CMPBloadidx1, + [2]Op{OpAMD64CMPWload, OpAMD64ADDQ}: OpAMD64CMPWloadidx1, + [2]Op{OpAMD64CMPLload, OpAMD64ADDQ}: OpAMD64CMPLloadidx1, + [2]Op{OpAMD64CMPQload, OpAMD64ADDQ}: OpAMD64CMPQloadidx1, + + [2]Op{OpAMD64CMPBload, OpAMD64LEAQ1}: OpAMD64CMPBloadidx1, + [2]Op{OpAMD64CMPWload, OpAMD64LEAQ1}: OpAMD64CMPWloadidx1, + [2]Op{OpAMD64CMPWload, OpAMD64LEAQ2}: OpAMD64CMPWloadidx2, + [2]Op{OpAMD64CMPLload, OpAMD64LEAQ1}: OpAMD64CMPLloadidx1, + [2]Op{OpAMD64CMPLload, OpAMD64LEAQ4}: OpAMD64CMPLloadidx4, + [2]Op{OpAMD64CMPQload, OpAMD64LEAQ1}: OpAMD64CMPQloadidx1, + [2]Op{OpAMD64CMPQload, OpAMD64LEAQ8}: OpAMD64CMPQloadidx8, + + [2]Op{OpAMD64CMPBconstload, OpAMD64ADDQ}: OpAMD64CMPBconstloadidx1, + [2]Op{OpAMD64CMPWconstload, OpAMD64ADDQ}: OpAMD64CMPWconstloadidx1, + [2]Op{OpAMD64CMPLconstload, OpAMD64ADDQ}: OpAMD64CMPLconstloadidx1, + [2]Op{OpAMD64CMPQconstload, OpAMD64ADDQ}: OpAMD64CMPQconstloadidx1, + + [2]Op{OpAMD64CMPBconstload, OpAMD64LEAQ1}: OpAMD64CMPBconstloadidx1, + [2]Op{OpAMD64CMPWconstload, OpAMD64LEAQ1}: OpAMD64CMPWconstloadidx1, + [2]Op{OpAMD64CMPWconstload, OpAMD64LEAQ2}: OpAMD64CMPWconstloadidx2, + [2]Op{OpAMD64CMPLconstload, OpAMD64LEAQ1}: OpAMD64CMPLconstloadidx1, + [2]Op{OpAMD64CMPLconstload, OpAMD64LEAQ4}: OpAMD64CMPLconstloadidx4, + [2]Op{OpAMD64CMPQconstload, OpAMD64LEAQ1}: OpAMD64CMPQconstloadidx1, + [2]Op{OpAMD64CMPQconstload, OpAMD64LEAQ8}: OpAMD64CMPQconstloadidx8, + + [2]Op{OpAMD64ADDLload, OpAMD64ADDQ}: OpAMD64ADDLloadidx1, + [2]Op{OpAMD64ADDQload, OpAMD64ADDQ}: OpAMD64ADDQloadidx1, + [2]Op{OpAMD64SUBLload, OpAMD64ADDQ}: OpAMD64SUBLloadidx1, + [2]Op{OpAMD64SUBQload, OpAMD64ADDQ}: OpAMD64SUBQloadidx1, + [2]Op{OpAMD64ANDLload, OpAMD64ADDQ}: OpAMD64ANDLloadidx1, + [2]Op{OpAMD64ANDQload, OpAMD64ADDQ}: OpAMD64ANDQloadidx1, + [2]Op{OpAMD64ORLload, OpAMD64ADDQ}: OpAMD64ORLloadidx1, + [2]Op{OpAMD64ORQload, OpAMD64ADDQ}: OpAMD64ORQloadidx1, + [2]Op{OpAMD64XORLload, OpAMD64ADDQ}: OpAMD64XORLloadidx1, + [2]Op{OpAMD64XORQload, OpAMD64ADDQ}: OpAMD64XORQloadidx1, + + [2]Op{OpAMD64ADDLload, OpAMD64LEAQ1}: OpAMD64ADDLloadidx1, + [2]Op{OpAMD64ADDLload, OpAMD64LEAQ4}: OpAMD64ADDLloadidx4, + [2]Op{OpAMD64ADDLload, OpAMD64LEAQ8}: OpAMD64ADDLloadidx8, + [2]Op{OpAMD64ADDQload, OpAMD64LEAQ1}: OpAMD64ADDQloadidx1, + [2]Op{OpAMD64ADDQload, OpAMD64LEAQ8}: OpAMD64ADDQloadidx8, + [2]Op{OpAMD64SUBLload, OpAMD64LEAQ1}: OpAMD64SUBLloadidx1, + [2]Op{OpAMD64SUBLload, OpAMD64LEAQ4}: OpAMD64SUBLloadidx4, + [2]Op{OpAMD64SUBLload, OpAMD64LEAQ8}: OpAMD64SUBLloadidx8, + [2]Op{OpAMD64SUBQload, OpAMD64LEAQ1}: OpAMD64SUBQloadidx1, + [2]Op{OpAMD64SUBQload, OpAMD64LEAQ8}: OpAMD64SUBQloadidx8, + [2]Op{OpAMD64ANDLload, OpAMD64LEAQ1}: OpAMD64ANDLloadidx1, + [2]Op{OpAMD64ANDLload, OpAMD64LEAQ4}: OpAMD64ANDLloadidx4, + [2]Op{OpAMD64ANDLload, OpAMD64LEAQ8}: OpAMD64ANDLloadidx8, + [2]Op{OpAMD64ANDQload, OpAMD64LEAQ1}: OpAMD64ANDQloadidx1, + [2]Op{OpAMD64ANDQload, OpAMD64LEAQ8}: OpAMD64ANDQloadidx8, + [2]Op{OpAMD64ORLload, OpAMD64LEAQ1}: OpAMD64ORLloadidx1, + [2]Op{OpAMD64ORLload, OpAMD64LEAQ4}: OpAMD64ORLloadidx4, + [2]Op{OpAMD64ORLload, OpAMD64LEAQ8}: OpAMD64ORLloadidx8, + [2]Op{OpAMD64ORQload, OpAMD64LEAQ1}: OpAMD64ORQloadidx1, + [2]Op{OpAMD64ORQload, OpAMD64LEAQ8}: OpAMD64ORQloadidx8, + [2]Op{OpAMD64XORLload, OpAMD64LEAQ1}: OpAMD64XORLloadidx1, + [2]Op{OpAMD64XORLload, OpAMD64LEAQ4}: OpAMD64XORLloadidx4, + [2]Op{OpAMD64XORLload, OpAMD64LEAQ8}: OpAMD64XORLloadidx8, + [2]Op{OpAMD64XORQload, OpAMD64LEAQ1}: OpAMD64XORQloadidx1, + [2]Op{OpAMD64XORQload, OpAMD64LEAQ8}: OpAMD64XORQloadidx8, + + [2]Op{OpAMD64ADDLmodify, OpAMD64ADDQ}: OpAMD64ADDLmodifyidx1, + [2]Op{OpAMD64ADDQmodify, OpAMD64ADDQ}: OpAMD64ADDQmodifyidx1, + [2]Op{OpAMD64SUBLmodify, OpAMD64ADDQ}: OpAMD64SUBLmodifyidx1, + [2]Op{OpAMD64SUBQmodify, OpAMD64ADDQ}: OpAMD64SUBQmodifyidx1, + [2]Op{OpAMD64ANDLmodify, OpAMD64ADDQ}: OpAMD64ANDLmodifyidx1, + [2]Op{OpAMD64ANDQmodify, OpAMD64ADDQ}: OpAMD64ANDQmodifyidx1, + [2]Op{OpAMD64ORLmodify, OpAMD64ADDQ}: OpAMD64ORLmodifyidx1, + [2]Op{OpAMD64ORQmodify, OpAMD64ADDQ}: OpAMD64ORQmodifyidx1, + [2]Op{OpAMD64XORLmodify, OpAMD64ADDQ}: OpAMD64XORLmodifyidx1, + [2]Op{OpAMD64XORQmodify, OpAMD64ADDQ}: OpAMD64XORQmodifyidx1, + + [2]Op{OpAMD64ADDLmodify, OpAMD64LEAQ1}: OpAMD64ADDLmodifyidx1, + [2]Op{OpAMD64ADDLmodify, OpAMD64LEAQ4}: OpAMD64ADDLmodifyidx4, + [2]Op{OpAMD64ADDLmodify, OpAMD64LEAQ8}: OpAMD64ADDLmodifyidx8, + [2]Op{OpAMD64ADDQmodify, OpAMD64LEAQ1}: OpAMD64ADDQmodifyidx1, + [2]Op{OpAMD64ADDQmodify, OpAMD64LEAQ8}: OpAMD64ADDQmodifyidx8, + [2]Op{OpAMD64SUBLmodify, OpAMD64LEAQ1}: OpAMD64SUBLmodifyidx1, + [2]Op{OpAMD64SUBLmodify, OpAMD64LEAQ4}: OpAMD64SUBLmodifyidx4, + [2]Op{OpAMD64SUBLmodify, OpAMD64LEAQ8}: OpAMD64SUBLmodifyidx8, + [2]Op{OpAMD64SUBQmodify, OpAMD64LEAQ1}: OpAMD64SUBQmodifyidx1, + [2]Op{OpAMD64SUBQmodify, OpAMD64LEAQ8}: OpAMD64SUBQmodifyidx8, + [2]Op{OpAMD64ANDLmodify, OpAMD64LEAQ1}: OpAMD64ANDLmodifyidx1, + [2]Op{OpAMD64ANDLmodify, OpAMD64LEAQ4}: OpAMD64ANDLmodifyidx4, + [2]Op{OpAMD64ANDLmodify, OpAMD64LEAQ8}: OpAMD64ANDLmodifyidx8, + [2]Op{OpAMD64ANDQmodify, OpAMD64LEAQ1}: OpAMD64ANDQmodifyidx1, + [2]Op{OpAMD64ANDQmodify, OpAMD64LEAQ8}: OpAMD64ANDQmodifyidx8, + [2]Op{OpAMD64ORLmodify, OpAMD64LEAQ1}: OpAMD64ORLmodifyidx1, + [2]Op{OpAMD64ORLmodify, OpAMD64LEAQ4}: OpAMD64ORLmodifyidx4, + [2]Op{OpAMD64ORLmodify, OpAMD64LEAQ8}: OpAMD64ORLmodifyidx8, + [2]Op{OpAMD64ORQmodify, OpAMD64LEAQ1}: OpAMD64ORQmodifyidx1, + [2]Op{OpAMD64ORQmodify, OpAMD64LEAQ8}: OpAMD64ORQmodifyidx8, + [2]Op{OpAMD64XORLmodify, OpAMD64LEAQ1}: OpAMD64XORLmodifyidx1, + [2]Op{OpAMD64XORLmodify, OpAMD64LEAQ4}: OpAMD64XORLmodifyidx4, + [2]Op{OpAMD64XORLmodify, OpAMD64LEAQ8}: OpAMD64XORLmodifyidx8, + [2]Op{OpAMD64XORQmodify, OpAMD64LEAQ1}: OpAMD64XORQmodifyidx1, + [2]Op{OpAMD64XORQmodify, OpAMD64LEAQ8}: OpAMD64XORQmodifyidx8, + + [2]Op{OpAMD64ADDLconstmodify, OpAMD64ADDQ}: OpAMD64ADDLconstmodifyidx1, + [2]Op{OpAMD64ADDQconstmodify, OpAMD64ADDQ}: OpAMD64ADDQconstmodifyidx1, + [2]Op{OpAMD64ANDLconstmodify, OpAMD64ADDQ}: OpAMD64ANDLconstmodifyidx1, + [2]Op{OpAMD64ANDQconstmodify, OpAMD64ADDQ}: OpAMD64ANDQconstmodifyidx1, + [2]Op{OpAMD64ORLconstmodify, OpAMD64ADDQ}: OpAMD64ORLconstmodifyidx1, + [2]Op{OpAMD64ORQconstmodify, OpAMD64ADDQ}: OpAMD64ORQconstmodifyidx1, + [2]Op{OpAMD64XORLconstmodify, OpAMD64ADDQ}: OpAMD64XORLconstmodifyidx1, + [2]Op{OpAMD64XORQconstmodify, OpAMD64ADDQ}: OpAMD64XORQconstmodifyidx1, + + [2]Op{OpAMD64ADDLconstmodify, OpAMD64LEAQ1}: OpAMD64ADDLconstmodifyidx1, + [2]Op{OpAMD64ADDLconstmodify, OpAMD64LEAQ4}: OpAMD64ADDLconstmodifyidx4, + [2]Op{OpAMD64ADDLconstmodify, OpAMD64LEAQ8}: OpAMD64ADDLconstmodifyidx8, + [2]Op{OpAMD64ADDQconstmodify, OpAMD64LEAQ1}: OpAMD64ADDQconstmodifyidx1, + [2]Op{OpAMD64ADDQconstmodify, OpAMD64LEAQ8}: OpAMD64ADDQconstmodifyidx8, + [2]Op{OpAMD64ANDLconstmodify, OpAMD64LEAQ1}: OpAMD64ANDLconstmodifyidx1, + [2]Op{OpAMD64ANDLconstmodify, OpAMD64LEAQ4}: OpAMD64ANDLconstmodifyidx4, + [2]Op{OpAMD64ANDLconstmodify, OpAMD64LEAQ8}: OpAMD64ANDLconstmodifyidx8, + [2]Op{OpAMD64ANDQconstmodify, OpAMD64LEAQ1}: OpAMD64ANDQconstmodifyidx1, + [2]Op{OpAMD64ANDQconstmodify, OpAMD64LEAQ8}: OpAMD64ANDQconstmodifyidx8, + [2]Op{OpAMD64ORLconstmodify, OpAMD64LEAQ1}: OpAMD64ORLconstmodifyidx1, + [2]Op{OpAMD64ORLconstmodify, OpAMD64LEAQ4}: OpAMD64ORLconstmodifyidx4, + [2]Op{OpAMD64ORLconstmodify, OpAMD64LEAQ8}: OpAMD64ORLconstmodifyidx8, + [2]Op{OpAMD64ORQconstmodify, OpAMD64LEAQ1}: OpAMD64ORQconstmodifyidx1, + [2]Op{OpAMD64ORQconstmodify, OpAMD64LEAQ8}: OpAMD64ORQconstmodifyidx8, + [2]Op{OpAMD64XORLconstmodify, OpAMD64LEAQ1}: OpAMD64XORLconstmodifyidx1, + [2]Op{OpAMD64XORLconstmodify, OpAMD64LEAQ4}: OpAMD64XORLconstmodifyidx4, + [2]Op{OpAMD64XORLconstmodify, OpAMD64LEAQ8}: OpAMD64XORLconstmodifyidx8, + [2]Op{OpAMD64XORQconstmodify, OpAMD64LEAQ1}: OpAMD64XORQconstmodifyidx1, + [2]Op{OpAMD64XORQconstmodify, OpAMD64LEAQ8}: OpAMD64XORQconstmodifyidx8, + + [2]Op{OpAMD64ADDSSload, OpAMD64LEAQ1}: OpAMD64ADDSSloadidx1, + [2]Op{OpAMD64ADDSSload, OpAMD64LEAQ4}: OpAMD64ADDSSloadidx4, + [2]Op{OpAMD64ADDSDload, OpAMD64LEAQ1}: OpAMD64ADDSDloadidx1, + [2]Op{OpAMD64ADDSDload, OpAMD64LEAQ8}: OpAMD64ADDSDloadidx8, + [2]Op{OpAMD64SUBSSload, OpAMD64LEAQ1}: OpAMD64SUBSSloadidx1, + [2]Op{OpAMD64SUBSSload, OpAMD64LEAQ4}: OpAMD64SUBSSloadidx4, + [2]Op{OpAMD64SUBSDload, OpAMD64LEAQ1}: OpAMD64SUBSDloadidx1, + [2]Op{OpAMD64SUBSDload, OpAMD64LEAQ8}: OpAMD64SUBSDloadidx8, + [2]Op{OpAMD64MULSSload, OpAMD64LEAQ1}: OpAMD64MULSSloadidx1, + [2]Op{OpAMD64MULSSload, OpAMD64LEAQ4}: OpAMD64MULSSloadidx4, + [2]Op{OpAMD64MULSDload, OpAMD64LEAQ1}: OpAMD64MULSDloadidx1, + [2]Op{OpAMD64MULSDload, OpAMD64LEAQ8}: OpAMD64MULSDloadidx8, + [2]Op{OpAMD64DIVSSload, OpAMD64LEAQ1}: OpAMD64DIVSSloadidx1, + [2]Op{OpAMD64DIVSSload, OpAMD64LEAQ4}: OpAMD64DIVSSloadidx4, + [2]Op{OpAMD64DIVSDload, OpAMD64LEAQ1}: OpAMD64DIVSDloadidx1, + [2]Op{OpAMD64DIVSDload, OpAMD64LEAQ8}: OpAMD64DIVSDloadidx8, + + [2]Op{OpAMD64SARXLload, OpAMD64ADDQ}: OpAMD64SARXLloadidx1, + [2]Op{OpAMD64SARXQload, OpAMD64ADDQ}: OpAMD64SARXQloadidx1, + [2]Op{OpAMD64SHLXLload, OpAMD64ADDQ}: OpAMD64SHLXLloadidx1, + [2]Op{OpAMD64SHLXQload, OpAMD64ADDQ}: OpAMD64SHLXQloadidx1, + [2]Op{OpAMD64SHRXLload, OpAMD64ADDQ}: OpAMD64SHRXLloadidx1, + [2]Op{OpAMD64SHRXQload, OpAMD64ADDQ}: OpAMD64SHRXQloadidx1, + + [2]Op{OpAMD64SARXLload, OpAMD64LEAQ1}: OpAMD64SARXLloadidx1, + [2]Op{OpAMD64SARXLload, OpAMD64LEAQ4}: OpAMD64SARXLloadidx4, + [2]Op{OpAMD64SARXLload, OpAMD64LEAQ8}: OpAMD64SARXLloadidx8, + [2]Op{OpAMD64SARXQload, OpAMD64LEAQ1}: OpAMD64SARXQloadidx1, + [2]Op{OpAMD64SARXQload, OpAMD64LEAQ8}: OpAMD64SARXQloadidx8, + [2]Op{OpAMD64SHLXLload, OpAMD64LEAQ1}: OpAMD64SHLXLloadidx1, + [2]Op{OpAMD64SHLXLload, OpAMD64LEAQ4}: OpAMD64SHLXLloadidx4, + [2]Op{OpAMD64SHLXLload, OpAMD64LEAQ8}: OpAMD64SHLXLloadidx8, + [2]Op{OpAMD64SHLXQload, OpAMD64LEAQ1}: OpAMD64SHLXQloadidx1, + [2]Op{OpAMD64SHLXQload, OpAMD64LEAQ8}: OpAMD64SHLXQloadidx8, + [2]Op{OpAMD64SHRXLload, OpAMD64LEAQ1}: OpAMD64SHRXLloadidx1, + [2]Op{OpAMD64SHRXLload, OpAMD64LEAQ4}: OpAMD64SHRXLloadidx4, + [2]Op{OpAMD64SHRXLload, OpAMD64LEAQ8}: OpAMD64SHRXLloadidx8, + [2]Op{OpAMD64SHRXQload, OpAMD64LEAQ1}: OpAMD64SHRXQloadidx1, + [2]Op{OpAMD64SHRXQload, OpAMD64LEAQ8}: OpAMD64SHRXQloadidx8, + + // amd64/v3 + [2]Op{OpAMD64MOVBELload, OpAMD64ADDQ}: OpAMD64MOVBELloadidx1, + [2]Op{OpAMD64MOVBEQload, OpAMD64ADDQ}: OpAMD64MOVBEQloadidx1, + [2]Op{OpAMD64MOVBELload, OpAMD64LEAQ1}: OpAMD64MOVBELloadidx1, + [2]Op{OpAMD64MOVBELload, OpAMD64LEAQ4}: OpAMD64MOVBELloadidx4, + [2]Op{OpAMD64MOVBELload, OpAMD64LEAQ8}: OpAMD64MOVBELloadidx8, + [2]Op{OpAMD64MOVBEQload, OpAMD64LEAQ1}: OpAMD64MOVBEQloadidx1, + [2]Op{OpAMD64MOVBEQload, OpAMD64LEAQ8}: OpAMD64MOVBEQloadidx8, + + [2]Op{OpAMD64MOVBEWstore, OpAMD64ADDQ}: OpAMD64MOVBEWstoreidx1, + [2]Op{OpAMD64MOVBELstore, OpAMD64ADDQ}: OpAMD64MOVBELstoreidx1, + [2]Op{OpAMD64MOVBEQstore, OpAMD64ADDQ}: OpAMD64MOVBEQstoreidx1, + [2]Op{OpAMD64MOVBEWstore, OpAMD64LEAQ1}: OpAMD64MOVBEWstoreidx1, + [2]Op{OpAMD64MOVBEWstore, OpAMD64LEAQ2}: OpAMD64MOVBEWstoreidx2, + [2]Op{OpAMD64MOVBELstore, OpAMD64LEAQ1}: OpAMD64MOVBELstoreidx1, + [2]Op{OpAMD64MOVBELstore, OpAMD64LEAQ4}: OpAMD64MOVBELstoreidx4, + [2]Op{OpAMD64MOVBELstore, OpAMD64LEAQ8}: OpAMD64MOVBELstoreidx8, + [2]Op{OpAMD64MOVBEQstore, OpAMD64LEAQ1}: OpAMD64MOVBEQstoreidx1, + [2]Op{OpAMD64MOVBEQstore, OpAMD64LEAQ8}: OpAMD64MOVBEQstoreidx8, + + // 386 + [2]Op{Op386MOVBload, Op386ADDL}: Op386MOVBloadidx1, + [2]Op{Op386MOVWload, Op386ADDL}: Op386MOVWloadidx1, + [2]Op{Op386MOVLload, Op386ADDL}: Op386MOVLloadidx1, + [2]Op{Op386MOVSSload, Op386ADDL}: Op386MOVSSloadidx1, + [2]Op{Op386MOVSDload, Op386ADDL}: Op386MOVSDloadidx1, + + [2]Op{Op386MOVBstore, Op386ADDL}: Op386MOVBstoreidx1, + [2]Op{Op386MOVWstore, Op386ADDL}: Op386MOVWstoreidx1, + [2]Op{Op386MOVLstore, Op386ADDL}: Op386MOVLstoreidx1, + [2]Op{Op386MOVSSstore, Op386ADDL}: Op386MOVSSstoreidx1, + [2]Op{Op386MOVSDstore, Op386ADDL}: Op386MOVSDstoreidx1, + + [2]Op{Op386MOVBstoreconst, Op386ADDL}: Op386MOVBstoreconstidx1, + [2]Op{Op386MOVWstoreconst, Op386ADDL}: Op386MOVWstoreconstidx1, + [2]Op{Op386MOVLstoreconst, Op386ADDL}: Op386MOVLstoreconstidx1, + + [2]Op{Op386MOVBload, Op386LEAL1}: Op386MOVBloadidx1, + [2]Op{Op386MOVWload, Op386LEAL1}: Op386MOVWloadidx1, + [2]Op{Op386MOVWload, Op386LEAL2}: Op386MOVWloadidx2, + [2]Op{Op386MOVLload, Op386LEAL1}: Op386MOVLloadidx1, + [2]Op{Op386MOVLload, Op386LEAL4}: Op386MOVLloadidx4, + [2]Op{Op386MOVSSload, Op386LEAL1}: Op386MOVSSloadidx1, + [2]Op{Op386MOVSSload, Op386LEAL4}: Op386MOVSSloadidx4, + [2]Op{Op386MOVSDload, Op386LEAL1}: Op386MOVSDloadidx1, + [2]Op{Op386MOVSDload, Op386LEAL8}: Op386MOVSDloadidx8, + + [2]Op{Op386MOVBstore, Op386LEAL1}: Op386MOVBstoreidx1, + [2]Op{Op386MOVWstore, Op386LEAL1}: Op386MOVWstoreidx1, + [2]Op{Op386MOVWstore, Op386LEAL2}: Op386MOVWstoreidx2, + [2]Op{Op386MOVLstore, Op386LEAL1}: Op386MOVLstoreidx1, + [2]Op{Op386MOVLstore, Op386LEAL4}: Op386MOVLstoreidx4, + [2]Op{Op386MOVSSstore, Op386LEAL1}: Op386MOVSSstoreidx1, + [2]Op{Op386MOVSSstore, Op386LEAL4}: Op386MOVSSstoreidx4, + [2]Op{Op386MOVSDstore, Op386LEAL1}: Op386MOVSDstoreidx1, + [2]Op{Op386MOVSDstore, Op386LEAL8}: Op386MOVSDstoreidx8, + + [2]Op{Op386MOVBstoreconst, Op386LEAL1}: Op386MOVBstoreconstidx1, + [2]Op{Op386MOVWstoreconst, Op386LEAL1}: Op386MOVWstoreconstidx1, + [2]Op{Op386MOVWstoreconst, Op386LEAL2}: Op386MOVWstoreconstidx2, + [2]Op{Op386MOVLstoreconst, Op386LEAL1}: Op386MOVLstoreconstidx1, + [2]Op{Op386MOVLstoreconst, Op386LEAL4}: Op386MOVLstoreconstidx4, + + [2]Op{Op386ADDLload, Op386LEAL4}: Op386ADDLloadidx4, + [2]Op{Op386SUBLload, Op386LEAL4}: Op386SUBLloadidx4, + [2]Op{Op386MULLload, Op386LEAL4}: Op386MULLloadidx4, + [2]Op{Op386ANDLload, Op386LEAL4}: Op386ANDLloadidx4, + [2]Op{Op386ORLload, Op386LEAL4}: Op386ORLloadidx4, + [2]Op{Op386XORLload, Op386LEAL4}: Op386XORLloadidx4, + + [2]Op{Op386ADDLmodify, Op386LEAL4}: Op386ADDLmodifyidx4, + [2]Op{Op386SUBLmodify, Op386LEAL4}: Op386SUBLmodifyidx4, + [2]Op{Op386ANDLmodify, Op386LEAL4}: Op386ANDLmodifyidx4, + [2]Op{Op386ORLmodify, Op386LEAL4}: Op386ORLmodifyidx4, + [2]Op{Op386XORLmodify, Op386LEAL4}: Op386XORLmodifyidx4, + + [2]Op{Op386ADDLconstmodify, Op386LEAL4}: Op386ADDLconstmodifyidx4, + [2]Op{Op386ANDLconstmodify, Op386LEAL4}: Op386ANDLconstmodifyidx4, + [2]Op{Op386ORLconstmodify, Op386LEAL4}: Op386ORLconstmodifyidx4, + [2]Op{Op386XORLconstmodify, Op386LEAL4}: Op386XORLconstmodifyidx4, + + // s390x + [2]Op{OpS390XMOVDload, OpS390XADD}: OpS390XMOVDloadidx, + [2]Op{OpS390XMOVWload, OpS390XADD}: OpS390XMOVWloadidx, + [2]Op{OpS390XMOVHload, OpS390XADD}: OpS390XMOVHloadidx, + [2]Op{OpS390XMOVBload, OpS390XADD}: OpS390XMOVBloadidx, + + [2]Op{OpS390XMOVWZload, OpS390XADD}: OpS390XMOVWZloadidx, + [2]Op{OpS390XMOVHZload, OpS390XADD}: OpS390XMOVHZloadidx, + [2]Op{OpS390XMOVBZload, OpS390XADD}: OpS390XMOVBZloadidx, + + [2]Op{OpS390XMOVDBRload, OpS390XADD}: OpS390XMOVDBRloadidx, + [2]Op{OpS390XMOVWBRload, OpS390XADD}: OpS390XMOVWBRloadidx, + [2]Op{OpS390XMOVHBRload, OpS390XADD}: OpS390XMOVHBRloadidx, + + [2]Op{OpS390XFMOVDload, OpS390XADD}: OpS390XFMOVDloadidx, + [2]Op{OpS390XFMOVSload, OpS390XADD}: OpS390XFMOVSloadidx, + + [2]Op{OpS390XMOVDstore, OpS390XADD}: OpS390XMOVDstoreidx, + [2]Op{OpS390XMOVWstore, OpS390XADD}: OpS390XMOVWstoreidx, + [2]Op{OpS390XMOVHstore, OpS390XADD}: OpS390XMOVHstoreidx, + [2]Op{OpS390XMOVBstore, OpS390XADD}: OpS390XMOVBstoreidx, + + [2]Op{OpS390XMOVDBRstore, OpS390XADD}: OpS390XMOVDBRstoreidx, + [2]Op{OpS390XMOVWBRstore, OpS390XADD}: OpS390XMOVWBRstoreidx, + [2]Op{OpS390XMOVHBRstore, OpS390XADD}: OpS390XMOVHBRstoreidx, + + [2]Op{OpS390XFMOVDstore, OpS390XADD}: OpS390XFMOVDstoreidx, + [2]Op{OpS390XFMOVSstore, OpS390XADD}: OpS390XFMOVSstoreidx, + + [2]Op{OpS390XMOVDload, OpS390XMOVDaddridx}: OpS390XMOVDloadidx, + [2]Op{OpS390XMOVWload, OpS390XMOVDaddridx}: OpS390XMOVWloadidx, + [2]Op{OpS390XMOVHload, OpS390XMOVDaddridx}: OpS390XMOVHloadidx, + [2]Op{OpS390XMOVBload, OpS390XMOVDaddridx}: OpS390XMOVBloadidx, + + [2]Op{OpS390XMOVWZload, OpS390XMOVDaddridx}: OpS390XMOVWZloadidx, + [2]Op{OpS390XMOVHZload, OpS390XMOVDaddridx}: OpS390XMOVHZloadidx, + [2]Op{OpS390XMOVBZload, OpS390XMOVDaddridx}: OpS390XMOVBZloadidx, + + [2]Op{OpS390XMOVDBRload, OpS390XMOVDaddridx}: OpS390XMOVDBRloadidx, + [2]Op{OpS390XMOVWBRload, OpS390XMOVDaddridx}: OpS390XMOVWBRloadidx, + [2]Op{OpS390XMOVHBRload, OpS390XMOVDaddridx}: OpS390XMOVHBRloadidx, + + [2]Op{OpS390XFMOVDload, OpS390XMOVDaddridx}: OpS390XFMOVDloadidx, + [2]Op{OpS390XFMOVSload, OpS390XMOVDaddridx}: OpS390XFMOVSloadidx, + + [2]Op{OpS390XMOVDstore, OpS390XMOVDaddridx}: OpS390XMOVDstoreidx, + [2]Op{OpS390XMOVWstore, OpS390XMOVDaddridx}: OpS390XMOVWstoreidx, + [2]Op{OpS390XMOVHstore, OpS390XMOVDaddridx}: OpS390XMOVHstoreidx, + [2]Op{OpS390XMOVBstore, OpS390XMOVDaddridx}: OpS390XMOVBstoreidx, + + [2]Op{OpS390XMOVDBRstore, OpS390XMOVDaddridx}: OpS390XMOVDBRstoreidx, + [2]Op{OpS390XMOVWBRstore, OpS390XMOVDaddridx}: OpS390XMOVWBRstoreidx, + [2]Op{OpS390XMOVHBRstore, OpS390XMOVDaddridx}: OpS390XMOVHBRstoreidx, + + [2]Op{OpS390XFMOVDstore, OpS390XMOVDaddridx}: OpS390XFMOVDstoreidx, + [2]Op{OpS390XFMOVSstore, OpS390XMOVDaddridx}: OpS390XFMOVSstoreidx, +} diff --git a/go/src/cmd/compile/internal/ssa/allocators.go b/go/src/cmd/compile/internal/ssa/allocators.go new file mode 100644 index 0000000000000000000000000000000000000000..a84f409b5ba96819077b110f3393c99c09011959 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/allocators.go @@ -0,0 +1,359 @@ +// Code generated from _gen/allocators.go using 'go generate'; DO NOT EDIT. + +package ssa + +import ( + "internal/unsafeheader" + "math/bits" + "sync" + "unsafe" +) + +var poolFreeValueSlice [27]sync.Pool + +func (c *Cache) allocValueSlice(n int) []*Value { + var s []*Value + n2 := n + if n2 < 32 { + n2 = 32 + } + b := bits.Len(uint(n2 - 1)) + v := poolFreeValueSlice[b-5].Get() + if v == nil { + s = make([]*Value, 1< 0 { + if b < 0 { + d = d + 1 + } + c = true + } + return c +} + +func BenchmarkPhioptPass(b *testing.B) { + for i := 0; i < b.N; i++ { + a := rand.Perm(i/10 + 10) + for i := 1; i < len(a)/2; i++ { + fn(a[i]-a[i-1], a[i+len(a)/2-2]-a[i+len(a)/2-1]) + } + } +} + +type Point struct { + X, Y int +} + +//go:noinline +func sign(p1, p2, p3 Point) bool { + return (p1.X-p3.X)*(p2.Y-p3.Y)-(p2.X-p3.X)*(p1.Y-p3.Y) < 0 +} + +func BenchmarkInvertLessThanNoov(b *testing.B) { + p1 := Point{1, 2} + p2 := Point{2, 3} + p3 := Point{3, 4} + for i := 0; i < b.N; i++ { + sign(p1, p2, p3) + } +} diff --git a/go/src/cmd/compile/internal/ssa/biasedsparsemap.go b/go/src/cmd/compile/internal/ssa/biasedsparsemap.go new file mode 100644 index 0000000000000000000000000000000000000000..a8bda831b1f73b2da524e21a1d55936112c96f05 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/biasedsparsemap.go @@ -0,0 +1,107 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "math" +) + +// A biasedSparseMap is a sparseMap for integers between J and K inclusive, +// where J might be somewhat larger than zero (and K-J is probably much smaller than J). +// (The motivating use case is the line numbers of statements for a single function.) +// Not all features of a SparseMap are exported, and it is also easy to treat a +// biasedSparseMap like a SparseSet. +type biasedSparseMap struct { + s *sparseMap + first int +} + +// newBiasedSparseMap returns a new biasedSparseMap for values between first and last, inclusive. +func newBiasedSparseMap(first, last int) *biasedSparseMap { + if first > last { + return &biasedSparseMap{first: math.MaxInt32, s: nil} + } + return &biasedSparseMap{first: first, s: newSparseMap(1 + last - first)} +} + +// cap returns one more than the largest key valid for s +func (s *biasedSparseMap) cap() int { + if s == nil || s.s == nil { + return 0 + } + return s.s.cap() + s.first +} + +// size returns the number of entries stored in s +func (s *biasedSparseMap) size() int { + if s == nil || s.s == nil { + return 0 + } + return s.s.size() +} + +// contains reports whether x is a key in s +func (s *biasedSparseMap) contains(x uint) bool { + if s == nil || s.s == nil { + return false + } + if int(x) < s.first { + return false + } + if int(x) >= s.cap() { + return false + } + return s.s.contains(ID(int(x) - s.first)) +} + +// get returns the value s maps for key x and true, or +// 0/false if x is not mapped or is out of range for s. +func (s *biasedSparseMap) get(x uint) (int32, bool) { + if s == nil || s.s == nil { + return 0, false + } + if int(x) < s.first { + return 0, false + } + if int(x) >= s.cap() { + return 0, false + } + k := ID(int(x) - s.first) + if !s.s.contains(k) { + return 0, false + } + return s.s.get(k) +} + +// getEntry returns the i'th key and value stored in s, +// where 0 <= i < s.size() +func (s *biasedSparseMap) getEntry(i int) (x uint, v int32) { + e := s.s.contents()[i] + x = uint(int(e.key) + s.first) + v = e.val + return +} + +// add inserts x->v into s, provided that x is in the range of keys stored in s. +func (s *biasedSparseMap) set(x uint, v int32) { + if int(x) < s.first || int(x) >= s.cap() { + return + } + s.s.set(ID(int(x)-s.first), v) +} + +// remove removes key x from s. +func (s *biasedSparseMap) remove(x uint) { + if int(x) < s.first || int(x) >= s.cap() { + return + } + s.s.remove(ID(int(x) - s.first)) +} + +func (s *biasedSparseMap) clear() { + if s.s != nil { + s.s.clear() + } +} diff --git a/go/src/cmd/compile/internal/ssa/block.go b/go/src/cmd/compile/internal/ssa/block.go new file mode 100644 index 0000000000000000000000000000000000000000..6564b85ec512bb027184264013e9fa417fdeb1bd --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/block.go @@ -0,0 +1,508 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/internal/src" + "fmt" +) + +// Block represents a basic block in the control flow graph of a function. +type Block struct { + // A unique identifier for the block. The system will attempt to allocate + // these IDs densely, but no guarantees. + ID ID + + // Source position for block's control operation + Pos src.XPos + + // What cpu features (AVXnnn, SVEyyy) are implied to reach/execute this block? + CPUfeatures CPUfeatures + + // The kind of block this is. + Kind BlockKind + + // Likely direction for branches. + // If BranchLikely, Succs[0] is the most likely branch taken. + // If BranchUnlikely, Succs[1] is the most likely branch taken. + // Ignored if len(Succs) < 2. + // Fatal if not BranchUnknown and len(Succs) > 2. + Likely BranchPrediction + + // After flagalloc, records whether flags are live at the end of the block. + FlagsLiveAtEnd bool + + // A block that would be good to align (according to the optimizer's guesses) + Hotness Hotness + + // Subsequent blocks, if any. The number and order depend on the block kind. + Succs []Edge + + // Inverse of successors. + // The order is significant to Phi nodes in the block. + // TODO: predecessors is a pain to maintain. Can we somehow order phi + // arguments by block id and have this field computed explicitly when needed? + Preds []Edge + + // A list of values that determine how the block is exited. The number + // and type of control values depends on the Kind of the block. For + // instance, a BlockIf has a single boolean control value and BlockExit + // has a single memory control value. + // + // The ControlValues() method may be used to get a slice with the non-nil + // control values that can be ranged over. + // + // Controls[1] must be nil if Controls[0] is nil. + Controls [2]*Value + + // Auxiliary info for the block. Its value depends on the Kind. + Aux Aux + AuxInt int64 + + // The unordered set of Values that define the operation of this block. + // After the scheduling pass, this list is ordered. + Values []*Value + + // The containing function + Func *Func + + // Storage for Succs, Preds and Values. + succstorage [2]Edge + predstorage [4]Edge + valstorage [9]*Value +} + +// Edge represents a CFG edge. +// Example edges for b branching to either c or d. +// (c and d have other predecessors.) +// +// b.Succs = [{c,3}, {d,1}] +// c.Preds = [?, ?, ?, {b,0}] +// d.Preds = [?, {b,1}, ?] +// +// These indexes allow us to edit the CFG in constant time. +// In addition, it informs phi ops in degenerate cases like: +// +// b: +// if k then c else c +// c: +// v = Phi(x, y) +// +// Then the indexes tell you whether x is chosen from +// the if or else branch from b. +// +// b.Succs = [{c,0},{c,1}] +// c.Preds = [{b,0},{b,1}] +// +// means x is chosen if k is true. +type Edge struct { + // block edge goes to (in a Succs list) or from (in a Preds list) + b *Block + // index of reverse edge. Invariant: + // e := x.Succs[idx] + // e.b.Preds[e.i] = Edge{x,idx} + // and similarly for predecessors. + i int +} + +func (e Edge) Block() *Block { + return e.b +} +func (e Edge) Index() int { + return e.i +} +func (e Edge) String() string { + return fmt.Sprintf("{%v,%d}", e.b, e.i) +} + +// BlockKind is the kind of SSA block. +type BlockKind uint8 + +// short form print +func (b *Block) String() string { + return fmt.Sprintf("b%d", b.ID) +} + +// long form print +func (b *Block) LongString() string { + s := b.Kind.String() + if b.Aux != nil { + s += fmt.Sprintf(" {%s}", b.Aux) + } + if t := b.AuxIntString(); t != "" { + s += fmt.Sprintf(" [%s]", t) + } + for _, c := range b.ControlValues() { + s += fmt.Sprintf(" %s", c) + } + if len(b.Succs) > 0 { + s += " ->" + for _, c := range b.Succs { + s += " " + c.b.String() + } + } + switch b.Likely { + case BranchUnlikely: + s += " (unlikely)" + case BranchLikely: + s += " (likely)" + } + return s +} + +// NumControls returns the number of non-nil control values the +// block has. +func (b *Block) NumControls() int { + if b.Controls[0] == nil { + return 0 + } + if b.Controls[1] == nil { + return 1 + } + return 2 +} + +// ControlValues returns a slice containing the non-nil control +// values of the block. The index of each control value will be +// the same as it is in the Controls property and can be used +// in ReplaceControl calls. +func (b *Block) ControlValues() []*Value { + if b.Controls[0] == nil { + return b.Controls[:0] + } + if b.Controls[1] == nil { + return b.Controls[:1] + } + return b.Controls[:2] +} + +// SetControl removes all existing control values and then adds +// the control value provided. The number of control values after +// a call to SetControl will always be 1. +func (b *Block) SetControl(v *Value) { + b.ResetControls() + b.Controls[0] = v + v.Uses++ +} + +// ResetControls sets the number of controls for the block to 0. +func (b *Block) ResetControls() { + if b.Controls[0] != nil { + b.Controls[0].Uses-- + } + if b.Controls[1] != nil { + b.Controls[1].Uses-- + } + b.Controls = [2]*Value{} // reset both controls to nil +} + +// AddControl appends a control value to the existing list of control values. +func (b *Block) AddControl(v *Value) { + i := b.NumControls() + b.Controls[i] = v // panics if array is full + v.Uses++ +} + +// ReplaceControl exchanges the existing control value at the index provided +// for the new value. The index must refer to a valid control value. +func (b *Block) ReplaceControl(i int, v *Value) { + b.Controls[i].Uses-- + b.Controls[i] = v + v.Uses++ +} + +// CopyControls replaces the controls for this block with those from the +// provided block. The provided block is not modified. +func (b *Block) CopyControls(from *Block) { + if b == from { + return + } + b.ResetControls() + for _, c := range from.ControlValues() { + b.AddControl(c) + } +} + +// Reset sets the block to the provided kind and clears all the blocks control +// and auxiliary values. Other properties of the block, such as its successors, +// predecessors and values are left unmodified. +func (b *Block) Reset(kind BlockKind) { + b.Kind = kind + b.ResetControls() + b.Aux = nil + b.AuxInt = 0 +} + +// resetWithControl resets b and adds control v. +// It is equivalent to b.Reset(kind); b.AddControl(v), +// except that it is one call instead of two and avoids a bounds check. +// It is intended for use by rewrite rules, where this matters. +func (b *Block) resetWithControl(kind BlockKind, v *Value) { + b.Kind = kind + b.ResetControls() + b.Aux = nil + b.AuxInt = 0 + b.Controls[0] = v + v.Uses++ +} + +// resetWithControl2 resets b and adds controls v and w. +// It is equivalent to b.Reset(kind); b.AddControl(v); b.AddControl(w), +// except that it is one call instead of three and avoids two bounds checks. +// It is intended for use by rewrite rules, where this matters. +func (b *Block) resetWithControl2(kind BlockKind, v, w *Value) { + b.Kind = kind + b.ResetControls() + b.Aux = nil + b.AuxInt = 0 + b.Controls[0] = v + b.Controls[1] = w + v.Uses++ + w.Uses++ +} + +// truncateValues truncates b.Values at the ith element, zeroing subsequent elements. +// The values in b.Values after i must already have had their args reset, +// to maintain correct value uses counts. +func (b *Block) truncateValues(i int) { + clear(b.Values[i:]) + b.Values = b.Values[:i] +} + +// AddEdgeTo adds an edge from block b to block c. +func (b *Block) AddEdgeTo(c *Block) { + i := len(b.Succs) + j := len(c.Preds) + b.Succs = append(b.Succs, Edge{c, j}) + c.Preds = append(c.Preds, Edge{b, i}) + b.Func.invalidateCFG() +} + +// removePred removes the ith input edge from b. +// It is the responsibility of the caller to remove +// the corresponding successor edge, and adjust any +// phi values by calling b.removePhiArg(v, i). +func (b *Block) removePred(i int) { + n := len(b.Preds) - 1 + if i != n { + e := b.Preds[n] + b.Preds[i] = e + // Update the other end of the edge we moved. + e.b.Succs[e.i].i = i + } + b.Preds[n] = Edge{} + b.Preds = b.Preds[:n] + b.Func.invalidateCFG() +} + +// removeSucc removes the ith output edge from b. +// It is the responsibility of the caller to remove +// the corresponding predecessor edge. +// Note that this potentially reorders successors of b, so it +// must be used very carefully. +func (b *Block) removeSucc(i int) { + n := len(b.Succs) - 1 + if i != n { + e := b.Succs[n] + b.Succs[i] = e + // Update the other end of the edge we moved. + e.b.Preds[e.i].i = i + } + b.Succs[n] = Edge{} + b.Succs = b.Succs[:n] + b.Func.invalidateCFG() +} + +func (b *Block) swapSuccessors() { + if len(b.Succs) != 2 { + b.Fatalf("swapSuccessors with len(Succs)=%d", len(b.Succs)) + } + e0 := b.Succs[0] + e1 := b.Succs[1] + b.Succs[0] = e1 + b.Succs[1] = e0 + e0.b.Preds[e0.i].i = 1 + e1.b.Preds[e1.i].i = 0 + b.Likely *= -1 +} + +// Swaps b.Succs[x] and b.Succs[y]. +func (b *Block) swapSuccessorsByIdx(x, y int) { + if x == y { + return + } + ex := b.Succs[x] + ey := b.Succs[y] + b.Succs[x] = ey + b.Succs[y] = ex + ex.b.Preds[ex.i].i = y + ey.b.Preds[ey.i].i = x +} + +// removePhiArg removes the ith arg from phi. +// It must be called after calling b.removePred(i) to +// adjust the corresponding phi value of the block: +// +// b.removePred(i) +// for _, v := range b.Values { +// +// if v.Op != OpPhi { +// continue +// } +// b.removePhiArg(v, i) +// +// } +func (b *Block) removePhiArg(phi *Value, i int) { + n := len(b.Preds) + if numPhiArgs := len(phi.Args); numPhiArgs-1 != n { + b.Fatalf("inconsistent state for %v, num predecessors: %d, num phi args: %d", phi, n, numPhiArgs) + } + phi.Args[i].Uses-- + phi.Args[i] = phi.Args[n] + phi.Args[n] = nil + phi.Args = phi.Args[:n] + phielimValue(phi) +} + +// uniquePred returns the predecessor of b, if there is exactly one. +// Returns nil otherwise. +func (b *Block) uniquePred() *Block { + if len(b.Preds) != 1 { + return nil + } + return b.Preds[0].b +} + +// LackingPos indicates whether b is a block whose position should be inherited +// from its successors. This is true if all the values within it have unreliable positions +// and if it is "plain", meaning that there is no control flow that is also very likely +// to correspond to a well-understood source position. +func (b *Block) LackingPos() bool { + // Non-plain predecessors are If or Defer, which both (1) have two successors, + // which might have different line numbers and (2) correspond to statements + // in the source code that have positions, so this case ought not occur anyway. + if b.Kind != BlockPlain { + return false + } + if b.Pos != src.NoXPos { + return false + } + for _, v := range b.Values { + if v.LackingPos() { + continue + } + return false + } + return true +} + +func (b *Block) AuxIntString() string { + switch b.Kind.AuxIntType() { + case "int8": + return fmt.Sprintf("%v", int8(b.AuxInt)) + case "uint8": + return fmt.Sprintf("%v", uint8(b.AuxInt)) + case "": // no aux int type + return "" + default: // type specified but not implemented - print as int64 + return fmt.Sprintf("%v", b.AuxInt) + } +} + +// likelyBranch reports whether block b is the likely branch of all of its predecessors. +func (b *Block) likelyBranch() bool { + if len(b.Preds) == 0 { + return false + } + for _, e := range b.Preds { + p := e.b + if len(p.Succs) == 1 || len(p.Succs) == 2 && (p.Likely == BranchLikely && p.Succs[0].b == b || + p.Likely == BranchUnlikely && p.Succs[1].b == b) { + continue + } + return false + } + return true +} + +func (b *Block) Logf(msg string, args ...any) { b.Func.Logf(msg, args...) } +func (b *Block) Log() bool { return b.Func.Log() } +func (b *Block) Fatalf(msg string, args ...any) { b.Func.Fatalf(msg, args...) } + +type BranchPrediction int8 + +const ( + BranchUnlikely = BranchPrediction(-1) + BranchUnknown = BranchPrediction(0) + BranchLikely = BranchPrediction(+1) +) + +type Hotness int8 // Could use negative numbers for specifically non-hot blocks, but don't, yet. +const ( + // These values are arranged in what seems to be order of increasing alignment importance. + // Currently only a few are relevant. Implicitly, they are all in a loop. + HotNotFlowIn Hotness = 1 << iota // This block is only reached by branches + HotInitial // In the block order, the first one for a given loop. Not necessarily topological header. + HotPgo // By PGO-based heuristics, this block occurs in a hot loop + + HotNot = 0 + HotInitialNotFlowIn = HotInitial | HotNotFlowIn // typically first block of a rotated loop, loop is entered with a branch (not to this block). No PGO + HotPgoInitial = HotPgo | HotInitial // special case; single block loop, initial block is header block has a flow-in entry, but PGO says it is hot + HotPgoInitialNotFLowIn = HotPgo | HotInitial | HotNotFlowIn // PGO says it is hot, and the loop is rotated so flow enters loop with a branch +) + +type CPUfeatures uint32 + +const ( + CPUNone CPUfeatures = 0 + CPUAll CPUfeatures = ^CPUfeatures(0) + CPUavx CPUfeatures = 1 << iota + CPUavx2 + CPUavxvnni + CPUavx512 + CPUbitalg + CPUgfni + CPUvbmi + CPUvbmi2 + CPUvpopcntdq + CPUavx512vnni + + CPUneon + CPUsve2 +) + +func (f CPUfeatures) hasFeature(x CPUfeatures) bool { + return f&x == x +} + +func (f CPUfeatures) String() string { + if f == CPUNone { + return "none" + } + if f == CPUAll { + return "all" + } + s := "" + foo := func(what string, feat CPUfeatures) { + if feat&f != 0 { + if s != "" { + s += "+" + } + s += what + } + } + foo("avx", CPUavx) + foo("avx2", CPUavx2) + foo("avx512", CPUavx512) + foo("avxvnni", CPUavxvnni) + foo("bitalg", CPUbitalg) + foo("gfni", CPUgfni) + foo("vbmi", CPUvbmi) + foo("vbmi2", CPUvbmi2) + foo("popcntdq", CPUvpopcntdq) + foo("avx512vnni", CPUavx512vnni) + + return s +} diff --git a/go/src/cmd/compile/internal/ssa/branchelim.go b/go/src/cmd/compile/internal/ssa/branchelim.go new file mode 100644 index 0000000000000000000000000000000000000000..8c411b541d4c81cd2e63bb3937cea7a2284e1e19 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/branchelim.go @@ -0,0 +1,475 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import "cmd/internal/src" + +// branchelim tries to eliminate branches by +// generating CondSelect instructions. +// +// Search for basic blocks that look like +// +// bb0 bb0 +// | \ / \ +// | bb1 or bb1 bb2 <- trivial if/else blocks +// | / \ / +// bb2 bb3 +// +// where the intermediate blocks are mostly empty (with no side-effects); +// rewrite Phis in the postdominator as CondSelects. +func branchelim(f *Func) { + // FIXME: add support for lowering CondSelects on more architectures + if !f.Config.haveCondSelect { + return + } + + // Find all the values used in computing the address of any load. + // Typically these values have operations like AddPtr, Lsh64x64, etc. + loadAddr := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(loadAddr) + for _, b := range f.Blocks { + for _, v := range b.Values { + switch v.Op { + case OpLoad, OpAtomicLoad8, OpAtomicLoad32, OpAtomicLoad64, OpAtomicLoadPtr, OpAtomicLoadAcq32, OpAtomicLoadAcq64: + loadAddr.add(v.Args[0].ID) + case OpMove: + loadAddr.add(v.Args[1].ID) + } + } + } + po := f.postorder() + for { + n := loadAddr.size() + for _, b := range po { + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + if !loadAddr.contains(v.ID) { + continue + } + for _, a := range v.Args { + if a.Type.IsInteger() || a.Type.IsPtr() || a.Type.IsUnsafePtr() { + loadAddr.add(a.ID) + } + } + } + } + if loadAddr.size() == n { + break + } + } + + change := true + for change { + change = false + for _, b := range f.Blocks { + change = elimIf(f, loadAddr, b) || elimIfElse(f, loadAddr, b) || change + } + } +} + +func canCondSelect(v *Value, arch string, loadAddr *sparseSet) bool { + if loadAddr != nil && // prove calls this on some multiplies and doesn't take care of loadAddrs + loadAddr.contains(v.ID) { + // The result of the soon-to-be conditional move is used to compute a load address. + // We want to avoid generating a conditional move in this case + // because the load address would now be data-dependent on the condition. + // Previously it would only be control-dependent on the condition, which is faster + // if the branch predicts well (or possibly even if it doesn't, if the load will + // be an expensive cache miss). + // See issue #26306. + return false + } + if arch == "loong64" { + // We should not generate conditional moves if neither of the arguments is constant zero, + // because it requires three instructions (OR, MASKEQZ, MASKNEZ) and will increase the + // register pressure. + if !(v.Args[0].isGenericIntConst() && v.Args[0].AuxInt == 0) && + !(v.Args[1].isGenericIntConst() && v.Args[1].AuxInt == 0) { + return false + } + } + // For now, stick to simple scalars that fit in registers + switch { + case v.Type.Size() > v.Block.Func.Config.RegSize: + return false + case v.Type.IsPtrShaped(): + return true + case v.Type.IsInteger(): + if arch == "amd64" && v.Type.Size() < 2 { + // amd64 doesn't support CMOV with byte registers + return false + } + return true + default: + return false + } +} + +// elimIf converts the one-way branch starting at dom in f to a conditional move if possible. +// loadAddr is a set of values which are used to compute the address of a load. +// Those values are exempt from CMOV generation. +func elimIf(f *Func, loadAddr *sparseSet, dom *Block) bool { + // See if dom is an If with one arm that + // is trivial and succeeded by the other + // successor of dom. + if dom.Kind != BlockIf || dom.Likely != BranchUnknown { + return false + } + var simple, post *Block + for i := range dom.Succs { + bb, other := dom.Succs[i].Block(), dom.Succs[i^1].Block() + if isLeafPlain(bb) && bb.Succs[0].Block() == other { + simple = bb + post = other + break + } + } + if simple == nil || len(post.Preds) != 2 || post == dom { + return false + } + + // We've found our diamond CFG of blocks. + // Now decide if fusing 'simple' into dom+post + // looks profitable. + + // Check that there are Phis, and that all of them + // can be safely rewritten to CondSelect. + hasphis := false + for _, v := range post.Values { + if v.Op == OpPhi { + hasphis = true + if !canCondSelect(v, f.Config.arch, loadAddr) { + return false + } + } + } + if !hasphis { + return false + } + + // Pick some upper bound for the number of instructions + // we'd be willing to execute just to generate a dead + // argument to CondSelect. In the worst case, this is + // the number of useless instructions executed. + const maxfuseinsts = 2 + + if len(simple.Values) > maxfuseinsts || !canSpeculativelyExecute(simple) { + return false + } + + // Replace Phi instructions in b with CondSelect instructions + swap := (post.Preds[0].Block() == dom) != (dom.Succs[0].Block() == post) + for _, v := range post.Values { + if v.Op != OpPhi { + continue + } + v.Op = OpCondSelect + if swap { + v.Args[0], v.Args[1] = v.Args[1], v.Args[0] + } + v.AddArg(dom.Controls[0]) + } + + // Put all of the instructions into 'dom' + // and update the CFG appropriately. + dom.Kind = post.Kind + dom.CopyControls(post) + dom.Aux = post.Aux + dom.Succs = append(dom.Succs[:0], post.Succs...) + for i := range dom.Succs { + e := dom.Succs[i] + e.b.Preds[e.i].b = dom + } + + // Try really hard to preserve statement marks attached to blocks. + simplePos := simple.Pos + postPos := post.Pos + simpleStmt := simplePos.IsStmt() == src.PosIsStmt + postStmt := postPos.IsStmt() == src.PosIsStmt + + for _, v := range simple.Values { + v.Block = dom + } + for _, v := range post.Values { + v.Block = dom + } + + // findBlockPos determines if b contains a stmt-marked value + // that has the same line number as the Pos for b itself. + // (i.e. is the position on b actually redundant?) + findBlockPos := func(b *Block) bool { + pos := b.Pos + for _, v := range b.Values { + // See if there is a stmt-marked value already that matches simple.Pos (and perhaps post.Pos) + if pos.SameFileAndLine(v.Pos) && v.Pos.IsStmt() == src.PosIsStmt { + return true + } + } + return false + } + if simpleStmt { + simpleStmt = !findBlockPos(simple) + if !simpleStmt && simplePos.SameFileAndLine(postPos) { + postStmt = false + } + + } + if postStmt { + postStmt = !findBlockPos(post) + } + + // If simpleStmt and/or postStmt are still true, then try harder + // to find the corresponding statement marks new homes. + + // setBlockPos determines if b contains a can-be-statement value + // that has the same line number as the Pos for b itself, and + // puts a statement mark on it, and returns whether it succeeded + // in this operation. + setBlockPos := func(b *Block) bool { + pos := b.Pos + for _, v := range b.Values { + if pos.SameFileAndLine(v.Pos) && !isPoorStatementOp(v.Op) { + v.Pos = v.Pos.WithIsStmt() + return true + } + } + return false + } + // If necessary and possible, add a mark to a value in simple + if simpleStmt { + if setBlockPos(simple) && simplePos.SameFileAndLine(postPos) { + postStmt = false + } + } + // If necessary and possible, add a mark to a value in post + if postStmt { + postStmt = !setBlockPos(post) + } + + // Before giving up (this was added because it helps), try the end of "dom", and if that is not available, + // try the values in the successor block if it is uncomplicated. + if postStmt { + if dom.Pos.IsStmt() != src.PosIsStmt { + dom.Pos = postPos + } else { + // Try the successor block + if len(dom.Succs) == 1 && len(dom.Succs[0].Block().Preds) == 1 { + succ := dom.Succs[0].Block() + for _, v := range succ.Values { + if isPoorStatementOp(v.Op) { + continue + } + if postPos.SameFileAndLine(v.Pos) { + v.Pos = v.Pos.WithIsStmt() + } + postStmt = false + break + } + // If postStmt still true, tag the block itself if possible + if postStmt && succ.Pos.IsStmt() != src.PosIsStmt { + succ.Pos = postPos + } + } + } + } + + dom.Values = append(dom.Values, simple.Values...) + dom.Values = append(dom.Values, post.Values...) + + // Trash 'post' and 'simple' + clobberBlock(post) + clobberBlock(simple) + + f.invalidateCFG() + return true +} + +// is this a BlockPlain with one predecessor? +func isLeafPlain(b *Block) bool { + return b.Kind == BlockPlain && len(b.Preds) == 1 +} + +func clobberBlock(b *Block) { + b.Values = nil + b.Preds = nil + b.Succs = nil + b.Aux = nil + b.ResetControls() + b.Likely = BranchUnknown + b.Kind = BlockInvalid +} + +// elimIfElse converts the two-way branch starting at dom in f to a conditional move if possible. +// loadAddr is a set of values which are used to compute the address of a load. +// Those values are exempt from CMOV generation. +func elimIfElse(f *Func, loadAddr *sparseSet, b *Block) bool { + // See if 'b' ends in an if/else: it should + // have two successors, both of which are BlockPlain + // and succeeded by the same block. + if b.Kind != BlockIf || b.Likely != BranchUnknown { + return false + } + yes, no := b.Succs[0].Block(), b.Succs[1].Block() + if !isLeafPlain(yes) || len(yes.Values) > 1 || !canSpeculativelyExecute(yes) { + return false + } + if !isLeafPlain(no) || len(no.Values) > 1 || !canSpeculativelyExecute(no) { + return false + } + if b.Succs[0].Block().Succs[0].Block() != b.Succs[1].Block().Succs[0].Block() { + return false + } + // block that postdominates the if/else + post := b.Succs[0].Block().Succs[0].Block() + if len(post.Preds) != 2 || post == b { + return false + } + hasphis := false + for _, v := range post.Values { + if v.Op == OpPhi { + hasphis = true + if !canCondSelect(v, f.Config.arch, loadAddr) { + return false + } + } + } + if !hasphis { + return false + } + + // Don't generate CondSelects if branch is cheaper. + if !shouldElimIfElse(no, yes, post, f.Config.arch) { + return false + } + + // now we're committed: rewrite each Phi as a CondSelect + swap := post.Preds[0].Block() != b.Succs[0].Block() + for _, v := range post.Values { + if v.Op != OpPhi { + continue + } + v.Op = OpCondSelect + if swap { + v.Args[0], v.Args[1] = v.Args[1], v.Args[0] + } + v.AddArg(b.Controls[0]) + } + + // Move the contents of all of these + // blocks into 'b' and update CFG edges accordingly + b.Kind = post.Kind + b.CopyControls(post) + b.Aux = post.Aux + b.Succs = append(b.Succs[:0], post.Succs...) + for i := range b.Succs { + e := b.Succs[i] + e.b.Preds[e.i].b = b + } + for i := range post.Values { + post.Values[i].Block = b + } + for i := range yes.Values { + yes.Values[i].Block = b + } + for i := range no.Values { + no.Values[i].Block = b + } + b.Values = append(b.Values, yes.Values...) + b.Values = append(b.Values, no.Values...) + b.Values = append(b.Values, post.Values...) + + // trash post, yes, and no + clobberBlock(yes) + clobberBlock(no) + clobberBlock(post) + + f.invalidateCFG() + return true +} + +// shouldElimIfElse reports whether estimated cost of eliminating branch +// is lower than threshold. +func shouldElimIfElse(no, yes, post *Block, arch string) bool { + switch arch { + default: + return true + case "amd64": + const maxcost = 2 + phi := 0 + other := 0 + for _, v := range post.Values { + if v.Op == OpPhi { + // Each phi results in CondSelect, which lowers into CMOV, + // CMOV has latency >1 on most CPUs. + phi++ + } + for _, x := range v.Args { + if x.Block == no || x.Block == yes { + other++ + } + } + } + cost := phi * 1 + if phi > 1 { + // If we have more than 1 phi and some values in post have args + // in yes or no blocks, we may have to recalculate condition, because + // those args may clobber flags. For now assume that all operations clobber flags. + cost += other * 1 + } + return cost < maxcost + } +} + +// canSpeculativelyExecute reports whether every value in the block can +// be evaluated without causing any observable side effects (memory +// accesses, panics and so on) except for execution time changes. It +// also ensures that the block does not contain any phis which we can't +// speculatively execute. +// Warning: this function cannot currently detect values that represent +// instructions the execution of which need to be guarded with CPU +// hardware feature checks. See issue #34950. +func canSpeculativelyExecute(b *Block) bool { + // don't fuse memory ops, Phi ops, divides (can panic), + // or anything else with side-effects + for _, v := range b.Values { + if v.Op == OpPhi || isDivMod(v.Op) || isPtrArithmetic(v.Op) || + v.Type.IsMemory() || opcodeTable[v.Op].hasSideEffects { + return false + } + + // Allow inlining markers to be speculatively executed + // even though they have a memory argument. + // See issue #74915. + if v.Op != OpInlMark && v.MemoryArg() != nil { + return false + } + } + return true +} + +func isDivMod(op Op) bool { + switch op { + case OpDiv8, OpDiv8u, OpDiv16, OpDiv16u, + OpDiv32, OpDiv32u, OpDiv64, OpDiv64u, OpDiv128u, + OpDiv32F, OpDiv64F, + OpMod8, OpMod8u, OpMod16, OpMod16u, + OpMod32, OpMod32u, OpMod64, OpMod64u: + return true + default: + return false + } +} + +func isPtrArithmetic(op Op) bool { + // Pointer arithmetic can't be speculatively executed because the result + // may be an invalid pointer (if, for example, the condition is that the + // base pointer is not nil). See issue 56990. + switch op { + case OpOffPtr, OpAddPtr, OpSubPtr: + return true + default: + return false + } +} diff --git a/go/src/cmd/compile/internal/ssa/branchelim_test.go b/go/src/cmd/compile/internal/ssa/branchelim_test.go new file mode 100644 index 0000000000000000000000000000000000000000..20fa84d63ae53ba252d8eee10fd58bc2847545a0 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/branchelim_test.go @@ -0,0 +1,172 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "testing" +) + +// Test that a trivial 'if' is eliminated +func TestBranchElimIf(t *testing.T) { + var testData = []struct { + arch string + intType string + ok bool + }{ + {"arm64", "int32", true}, + {"amd64", "int32", true}, + {"amd64", "int8", false}, + } + + for _, data := range testData { + t.Run(data.arch+"/"+data.intType, func(t *testing.T) { + c := testConfigArch(t, data.arch) + boolType := c.config.Types.Bool + var intType *types.Type + switch data.intType { + case "int32": + intType = c.config.Types.Int32 + case "int8": + intType = c.config.Types.Int8 + default: + t.Fatal("invalid integer type:", data.intType) + } + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("const1", OpConst32, intType, 1, nil), + Valu("const2", OpConst32, intType, 2, nil), + Valu("addr", OpAddr, boolType.PtrTo(), 0, nil, "sb"), + Valu("cond", OpLoad, boolType, 0, nil, "addr", "start"), + If("cond", "b2", "b3")), + Bloc("b2", + Goto("b3")), + Bloc("b3", + Valu("phi", OpPhi, intType, 0, nil, "const1", "const2"), + Valu("retstore", OpStore, types.TypeMem, 0, nil, "phi", "sb", "start"), + Exit("retstore"))) + + CheckFunc(fun.f) + branchelim(fun.f) + CheckFunc(fun.f) + Deadcode(fun.f) + CheckFunc(fun.f) + + if data.ok { + + if len(fun.f.Blocks) != 1 { + t.Fatalf("expected 1 block after branchelim and deadcode; found %d", len(fun.f.Blocks)) + } + if fun.values["phi"].Op != OpCondSelect { + t.Fatalf("expected phi op to be CondSelect; found op %s", fun.values["phi"].Op) + } + if fun.values["phi"].Args[2] != fun.values["cond"] { + t.Errorf("expected CondSelect condition to be %s; found %s", fun.values["cond"], fun.values["phi"].Args[2]) + } + if fun.blocks["entry"].Kind != BlockExit { + t.Errorf("expected entry to be BlockExit; found kind %s", fun.blocks["entry"].Kind.String()) + } + } else { + if len(fun.f.Blocks) != 3 { + t.Fatalf("expected 3 block after branchelim and deadcode; found %d", len(fun.f.Blocks)) + } + } + }) + } +} + +// Test that a trivial if/else is eliminated +func TestBranchElimIfElse(t *testing.T) { + for _, arch := range []string{"arm64", "amd64"} { + t.Run(arch, func(t *testing.T) { + c := testConfigArch(t, arch) + boolType := c.config.Types.Bool + intType := c.config.Types.Int32 + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("const1", OpConst32, intType, 1, nil), + Valu("const2", OpConst32, intType, 2, nil), + Valu("addr", OpAddr, boolType.PtrTo(), 0, nil, "sb"), + Valu("cond", OpLoad, boolType, 0, nil, "addr", "start"), + If("cond", "b2", "b3")), + Bloc("b2", + Goto("b4")), + Bloc("b3", + Goto("b4")), + Bloc("b4", + Valu("phi", OpPhi, intType, 0, nil, "const1", "const2"), + Valu("retstore", OpStore, types.TypeMem, 0, nil, "phi", "sb", "start"), + Exit("retstore"))) + + CheckFunc(fun.f) + branchelim(fun.f) + CheckFunc(fun.f) + Deadcode(fun.f) + CheckFunc(fun.f) + + if len(fun.f.Blocks) != 1 { + t.Fatalf("expected 1 block after branchelim; found %d", len(fun.f.Blocks)) + } + if fun.values["phi"].Op != OpCondSelect { + t.Fatalf("expected phi op to be CondSelect; found op %s", fun.values["phi"].Op) + } + if fun.values["phi"].Args[2] != fun.values["cond"] { + t.Errorf("expected CondSelect condition to be %s; found %s", fun.values["cond"], fun.values["phi"].Args[2]) + } + if fun.blocks["entry"].Kind != BlockExit { + t.Errorf("expected entry to be BlockExit; found kind %s", fun.blocks["entry"].Kind.String()) + } + }) + } +} + +// Test that an if/else CFG that loops back +// into itself does *not* get eliminated. +func TestNoBranchElimLoop(t *testing.T) { + for _, arch := range []string{"arm64", "amd64"} { + t.Run(arch, func(t *testing.T) { + c := testConfigArch(t, arch) + boolType := c.config.Types.Bool + intType := c.config.Types.Int32 + + // The control flow here is totally bogus, + // but a dead cycle seems like the only plausible + // way to arrive at a diamond CFG that is also a loop. + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("const2", OpConst32, intType, 2, nil), + Valu("const3", OpConst32, intType, 3, nil), + Goto("b5")), + Bloc("b2", + Valu("addr", OpAddr, boolType.PtrTo(), 0, nil, "sb"), + Valu("cond", OpLoad, boolType, 0, nil, "addr", "start"), + Valu("phi", OpPhi, intType, 0, nil, "const2", "const3"), + If("cond", "b3", "b4")), + Bloc("b3", + Goto("b2")), + Bloc("b4", + Goto("b2")), + Bloc("b5", + Exit("start"))) + + CheckFunc(fun.f) + branchelim(fun.f) + CheckFunc(fun.f) + + if len(fun.f.Blocks) != 5 { + t.Errorf("expected 5 block after branchelim; found %d", len(fun.f.Blocks)) + } + if fun.values["phi"].Op != OpPhi { + t.Errorf("expected phi op to be CondSelect; found op %s", fun.values["phi"].Op) + } + }) + } +} diff --git a/go/src/cmd/compile/internal/ssa/cache.go b/go/src/cmd/compile/internal/ssa/cache.go new file mode 100644 index 0000000000000000000000000000000000000000..59d768c34f483880461591a5c67a9c859fbb925c --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/cache.go @@ -0,0 +1,51 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/internal/obj" + "sort" +) + +// A Cache holds reusable compiler state. +// It is intended to be re-used for multiple Func compilations. +type Cache struct { + // Storage for low-numbered values and blocks. + values [2000]Value + blocks [200]Block + locs [2000]Location + + // Reusable stackAllocState. + // See stackalloc.go's {new,put}StackAllocState. + stackAllocState *stackAllocState + + scrPoset []*poset // scratch poset to be reused + + // Reusable regalloc state. + regallocValues []valState + + ValueToProgAfter []*obj.Prog + debugState debugState + + Liveness any // *gc.livenessFuncCache + + // Free "headers" for use by the allocators in allocators.go. + // Used to put slices in sync.Pools without allocation. + hdrValueSlice []*[]*Value + hdrLimitSlice []*[]limit +} + +func (c *Cache) Reset() { + nv := sort.Search(len(c.values), func(i int) bool { return c.values[i].ID == 0 }) + clear(c.values[:nv]) + nb := sort.Search(len(c.blocks), func(i int) bool { return c.blocks[i].ID == 0 }) + clear(c.blocks[:nb]) + nl := sort.Search(len(c.locs), func(i int) bool { return c.locs[i] == nil }) + clear(c.locs[:nl]) + + // regalloc sets the length of c.regallocValues to whatever it may use, + // so clear according to length. + clear(c.regallocValues) +} diff --git a/go/src/cmd/compile/internal/ssa/check.go b/go/src/cmd/compile/internal/ssa/check.go new file mode 100644 index 0000000000000000000000000000000000000000..a41c110faa9b9380cd01ae3bc94ea37509e45185 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/check.go @@ -0,0 +1,639 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/ir" + "cmd/internal/obj/s390x" + "math" + "math/bits" +) + +// checkFunc checks invariants of f. +func checkFunc(f *Func) { + blockMark := make([]bool, f.NumBlocks()) + valueMark := make([]bool, f.NumValues()) + + for _, b := range f.Blocks { + if blockMark[b.ID] { + f.Fatalf("block %s appears twice in %s!", b, f.Name) + } + blockMark[b.ID] = true + if b.Func != f { + f.Fatalf("%s.Func=%s, want %s", b, b.Func.Name, f.Name) + } + + for i, e := range b.Preds { + if se := e.b.Succs[e.i]; se.b != b || se.i != i { + f.Fatalf("block pred/succ not crosslinked correctly %d:%s %d:%s", i, b, se.i, se.b) + } + } + for i, e := range b.Succs { + if pe := e.b.Preds[e.i]; pe.b != b || pe.i != i { + f.Fatalf("block succ/pred not crosslinked correctly %d:%s %d:%s", i, b, pe.i, pe.b) + } + } + + switch b.Kind { + case BlockExit: + if len(b.Succs) != 0 { + f.Fatalf("exit block %s has successors", b) + } + if b.NumControls() != 1 { + f.Fatalf("exit block %s has no control value", b) + } + if !b.Controls[0].Type.IsMemory() { + f.Fatalf("exit block %s has non-memory control value %s", b, b.Controls[0].LongString()) + } + case BlockRet: + if len(b.Succs) != 0 { + f.Fatalf("ret block %s has successors", b) + } + if b.NumControls() != 1 { + f.Fatalf("ret block %s has nil control", b) + } + if !b.Controls[0].Type.IsMemory() { + f.Fatalf("ret block %s has non-memory control value %s", b, b.Controls[0].LongString()) + } + case BlockRetJmp: + if len(b.Succs) != 0 { + f.Fatalf("retjmp block %s len(Succs)==%d, want 0", b, len(b.Succs)) + } + if b.NumControls() != 1 { + f.Fatalf("retjmp block %s has nil control", b) + } + if !b.Controls[0].Type.IsMemory() { + f.Fatalf("retjmp block %s has non-memory control value %s", b, b.Controls[0].LongString()) + } + case BlockPlain: + if len(b.Succs) != 1 { + f.Fatalf("plain block %s len(Succs)==%d, want 1", b, len(b.Succs)) + } + if b.NumControls() != 0 { + f.Fatalf("plain block %s has non-nil control %s", b, b.Controls[0].LongString()) + } + case BlockIf: + if len(b.Succs) != 2 { + f.Fatalf("if block %s len(Succs)==%d, want 2", b, len(b.Succs)) + } + if b.NumControls() != 1 { + f.Fatalf("if block %s has no control value", b) + } + if !b.Controls[0].Type.IsBoolean() { + f.Fatalf("if block %s has non-bool control value %s", b, b.Controls[0].LongString()) + } + case BlockDefer: + if len(b.Succs) != 2 { + f.Fatalf("defer block %s len(Succs)==%d, want 2", b, len(b.Succs)) + } + if b.NumControls() != 1 { + f.Fatalf("defer block %s has no control value", b) + } + if !b.Controls[0].Type.IsMemory() { + f.Fatalf("defer block %s has non-memory control value %s", b, b.Controls[0].LongString()) + } + case BlockFirst: + if len(b.Succs) != 2 { + f.Fatalf("plain/dead block %s len(Succs)==%d, want 2", b, len(b.Succs)) + } + if b.NumControls() != 0 { + f.Fatalf("plain/dead block %s has a control value", b) + } + case BlockJumpTable: + if b.NumControls() != 1 { + f.Fatalf("jumpTable block %s has no control value", b) + } + } + if len(b.Succs) != 2 && b.Likely != BranchUnknown { + f.Fatalf("likeliness prediction %d for block %s with %d successors", b.Likely, b, len(b.Succs)) + } + + for _, v := range b.Values { + // Check to make sure argument count makes sense (argLen of -1 indicates + // variable length args) + nArgs := opcodeTable[v.Op].argLen + if nArgs != -1 && int32(len(v.Args)) != nArgs { + f.Fatalf("value %s has %d args, expected %d", v.LongString(), + len(v.Args), nArgs) + } + + // Check to make sure aux values make sense. + canHaveAux := false + canHaveAuxInt := false + // TODO: enforce types of Aux in this switch (like auxString does below) + switch opcodeTable[v.Op].auxType { + case auxNone: + case auxBool: + if v.AuxInt < 0 || v.AuxInt > 1 { + f.Fatalf("bad bool AuxInt value for %v", v) + } + canHaveAuxInt = true + case auxInt8: + if v.AuxInt != int64(int8(v.AuxInt)) { + f.Fatalf("bad int8 AuxInt value for %v", v) + } + canHaveAuxInt = true + case auxInt16: + if v.AuxInt != int64(int16(v.AuxInt)) { + f.Fatalf("bad int16 AuxInt value for %v", v) + } + canHaveAuxInt = true + case auxInt32: + if v.AuxInt != int64(int32(v.AuxInt)) { + f.Fatalf("bad int32 AuxInt value for %v", v) + } + canHaveAuxInt = true + case auxInt64, auxARM64BitField, auxARM64ConditionalParams: + canHaveAuxInt = true + case auxInt128: + // AuxInt must be zero, so leave canHaveAuxInt set to false. + case auxUInt8: + // Cast to int8 due to requirement of AuxInt, check its comment for details. + if v.AuxInt != int64(int8(v.AuxInt)) { + f.Fatalf("bad uint8 AuxInt value for %v, saw %d but need %d", v, v.AuxInt, int64(int8(v.AuxInt))) + } + canHaveAuxInt = true + case auxFloat32: + canHaveAuxInt = true + if math.IsNaN(v.AuxFloat()) { + f.Fatalf("value %v has an AuxInt that encodes a NaN", v) + } + if !isExactFloat32(v.AuxFloat()) { + f.Fatalf("value %v has an AuxInt value that is not an exact float32", v) + } + case auxFloat64: + canHaveAuxInt = true + if math.IsNaN(v.AuxFloat()) { + f.Fatalf("value %v has an AuxInt that encodes a NaN", v) + } + case auxString: + if _, ok := v.Aux.(stringAux); !ok { + f.Fatalf("value %v has Aux type %T, want string", v, v.Aux) + } + canHaveAux = true + case auxCallOff: + canHaveAuxInt = true + fallthrough + case auxCall: + if ac, ok := v.Aux.(*AuxCall); ok { + if v.Op == OpStaticCall && ac.Fn == nil { + f.Fatalf("value %v has *AuxCall with nil Fn", v) + } + } else { + f.Fatalf("value %v has Aux type %T, want *AuxCall", v, v.Aux) + } + canHaveAux = true + case auxNameOffsetInt8: + if _, ok := v.Aux.(*AuxNameOffset); !ok { + f.Fatalf("value %v has Aux type %T, want *AuxNameOffset", v, v.Aux) + } + canHaveAux = true + canHaveAuxInt = true + case auxSym, auxTyp: + canHaveAux = true + case auxSymOff, auxSymValAndOff, auxTypSize: + canHaveAuxInt = true + canHaveAux = true + case auxCCop: + if opcodeTable[Op(v.AuxInt)].name == "OpInvalid" { + f.Fatalf("value %v has an AuxInt value that is a valid opcode", v) + } + canHaveAuxInt = true + case auxS390XCCMask: + if _, ok := v.Aux.(s390x.CCMask); !ok { + f.Fatalf("bad type %T for S390XCCMask in %v", v.Aux, v) + } + canHaveAux = true + case auxS390XRotateParams: + if _, ok := v.Aux.(s390x.RotateParams); !ok { + f.Fatalf("bad type %T for S390XRotateParams in %v", v.Aux, v) + } + canHaveAux = true + case auxFlagConstant: + if v.AuxInt < 0 || v.AuxInt > 15 { + f.Fatalf("bad FlagConstant AuxInt value for %v", v) + } + canHaveAuxInt = true + case auxPanicBoundsC, auxPanicBoundsCC: + canHaveAux = true + canHaveAuxInt = true + default: + f.Fatalf("unknown aux type for %s", v.Op) + } + if !canHaveAux && v.Aux != nil { + f.Fatalf("value %s has an Aux value %v but shouldn't", v.LongString(), v.Aux) + } + if !canHaveAuxInt && v.AuxInt != 0 { + f.Fatalf("value %s has an AuxInt value %d but shouldn't", v.LongString(), v.AuxInt) + } + + for i, arg := range v.Args { + if arg == nil { + f.Fatalf("value %s has nil arg", v.LongString()) + } + if v.Op != OpPhi { + // For non-Phi ops, memory args must be last, if present + if arg.Type.IsMemory() && i != len(v.Args)-1 { + f.Fatalf("value %s has non-final memory arg (%d < %d)", v.LongString(), i, len(v.Args)-1) + } + } + } + + if valueMark[v.ID] { + f.Fatalf("value %s appears twice!", v.LongString()) + } + valueMark[v.ID] = true + + if v.Block != b { + f.Fatalf("%s.block != %s", v, b) + } + if v.Op == OpPhi && len(v.Args) != len(b.Preds) { + f.Fatalf("phi length %s does not match pred length %d for block %s", v.LongString(), len(b.Preds), b) + } + + if v.Op == OpAddr { + if len(v.Args) == 0 { + f.Fatalf("no args for OpAddr %s", v.LongString()) + } + if v.Args[0].Op != OpSB { + f.Fatalf("bad arg to OpAddr %v", v) + } + } + + if v.Op == OpLocalAddr { + if len(v.Args) != 2 { + f.Fatalf("wrong # of args for OpLocalAddr %s", v.LongString()) + } + if v.Args[0].Op != OpSP { + f.Fatalf("bad arg 0 to OpLocalAddr %v", v) + } + if !v.Args[1].Type.IsMemory() { + f.Fatalf("bad arg 1 to OpLocalAddr %v", v) + } + } + + if (v.Op == OpStructMake || v.Op == OpArrayMake1) && v.Type.Size() == 0 { + f.Fatalf("zero-sized Make; use Empty instead %v", v) + } + + if f.RegAlloc != nil && f.Config.SoftFloat && v.Type.IsFloat() { + f.Fatalf("unexpected floating-point type %v", v.LongString()) + } + + // Check types. + // TODO: more type checks? + switch c := f.Config; v.Op { + case OpSP, OpSB: + if v.Type != c.Types.Uintptr { + f.Fatalf("bad %s type: want uintptr, have %s", + v.Op, v.Type.String()) + } + case OpStringLen: + if v.Type != c.Types.Int { + f.Fatalf("bad %s type: want int, have %s", + v.Op, v.Type.String()) + } + case OpLoad: + if !v.Args[1].Type.IsMemory() { + f.Fatalf("bad arg 1 type to %s: want mem, have %s", + v.Op, v.Args[1].Type.String()) + } + case OpStore: + if !v.Type.IsMemory() { + f.Fatalf("bad %s type: want mem, have %s", + v.Op, v.Type.String()) + } + if !v.Args[2].Type.IsMemory() { + f.Fatalf("bad arg 2 type to %s: want mem, have %s", + v.Op, v.Args[2].Type.String()) + } + case OpCondSelect: + if !v.Args[2].Type.IsBoolean() { + f.Fatalf("bad arg 2 type to %s: want boolean, have %s", + v.Op, v.Args[2].Type.String()) + } + case OpAddPtr: + if !v.Args[0].Type.IsPtrShaped() && v.Args[0].Type != c.Types.Uintptr { + f.Fatalf("bad arg 0 type to %s: want ptr, have %s", v.Op, v.Args[0].LongString()) + } + if !v.Args[1].Type.IsInteger() { + f.Fatalf("bad arg 1 type to %s: want integer, have %s", v.Op, v.Args[1].LongString()) + } + case OpVarDef: + n := v.Aux.(*ir.Name) + if !n.Type().HasPointers() && !IsMergeCandidate(n) { + f.Fatalf("vardef must be merge candidate or have pointer type %s", v.Aux.(*ir.Name).Type().String()) + } + case OpNilCheck: + // nil checks have pointer type before scheduling, and + // void type after scheduling. + if f.scheduled { + if v.Uses != 0 { + f.Fatalf("nilcheck must have 0 uses %s", v.Uses) + } + if !v.Type.IsVoid() { + f.Fatalf("nilcheck must have void type %s", v.Type.String()) + } + } else { + if !v.Type.IsPtrShaped() && !v.Type.IsUintptr() { + f.Fatalf("nilcheck must have pointer type %s", v.Type.String()) + } + } + if !v.Args[0].Type.IsPtrShaped() && !v.Args[0].Type.IsUintptr() { + f.Fatalf("nilcheck must have argument of pointer type %s", v.Args[0].Type.String()) + } + if !v.Args[1].Type.IsMemory() { + f.Fatalf("bad arg 1 type to %s: want mem, have %s", + v.Op, v.Args[1].Type.String()) + } + } + + // TODO: check for cycles in values + } + } + + // Check to make sure all Blocks referenced are in the function. + if !blockMark[f.Entry.ID] { + f.Fatalf("entry block %v is missing", f.Entry) + } + for _, b := range f.Blocks { + for _, c := range b.Preds { + if !blockMark[c.b.ID] { + f.Fatalf("predecessor block %v for %v is missing", c, b) + } + } + for _, c := range b.Succs { + if !blockMark[c.b.ID] { + f.Fatalf("successor block %v for %v is missing", c, b) + } + } + } + + if len(f.Entry.Preds) > 0 { + f.Fatalf("entry block %s of %s has predecessor(s) %v", f.Entry, f.Name, f.Entry.Preds) + } + + // Check to make sure all Values referenced are in the function. + for _, b := range f.Blocks { + for _, v := range b.Values { + for i, a := range v.Args { + if !valueMark[a.ID] { + f.Fatalf("%v, arg %d of %s, is missing", a, i, v.LongString()) + } + } + } + for _, c := range b.ControlValues() { + if !valueMark[c.ID] { + f.Fatalf("control value for %s is missing: %v", b, c) + } + } + } + for b := f.freeBlocks; b != nil; b = b.succstorage[0].b { + if blockMark[b.ID] { + f.Fatalf("used block b%d in free list", b.ID) + } + } + for v := f.freeValues; v != nil; v = v.argstorage[0] { + if valueMark[v.ID] { + f.Fatalf("used value v%d in free list", v.ID) + } + } + + // Check to make sure all args dominate uses. + if f.RegAlloc == nil { + // Note: regalloc introduces non-dominating args. + // See TODO in regalloc.go. + sdom := f.Sdom() + for _, b := range f.Blocks { + for _, v := range b.Values { + for i, arg := range v.Args { + x := arg.Block + y := b + if v.Op == OpPhi { + y = b.Preds[i].b + } + if !domCheck(f, sdom, x, y) { + f.Fatalf("arg %d of value %s does not dominate, arg=%s", i, v.LongString(), arg.LongString()) + } + } + } + for _, c := range b.ControlValues() { + if !domCheck(f, sdom, c.Block, b) { + f.Fatalf("control value %s for %s doesn't dominate", c, b) + } + } + } + } + + // Check loop construction + if f.RegAlloc == nil && f.pass != nil { // non-nil pass allows better-targeted debug printing + ln := f.loopnest() + if !ln.hasIrreducible { + po := f.postorder() // use po to avoid unreachable blocks. + for _, b := range po { + for _, s := range b.Succs { + bb := s.Block() + if ln.b2l[b.ID] == nil && ln.b2l[bb.ID] != nil && bb != ln.b2l[bb.ID].header { + f.Fatalf("block %s not in loop branches to non-header block %s in loop", b.String(), bb.String()) + } + if ln.b2l[b.ID] != nil && ln.b2l[bb.ID] != nil && bb != ln.b2l[bb.ID].header && !ln.b2l[b.ID].isWithinOrEq(ln.b2l[bb.ID]) { + f.Fatalf("block %s in loop branches to non-header block %s in non-containing loop", b.String(), bb.String()) + } + } + } + } + } + + // Check use counts + uses := make([]int32, f.NumValues()) + for _, b := range f.Blocks { + for _, v := range b.Values { + for _, a := range v.Args { + uses[a.ID]++ + } + } + for _, c := range b.ControlValues() { + uses[c.ID]++ + } + } + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Uses != uses[v.ID] { + f.Fatalf("%s has %d uses, but has Uses=%d", v, uses[v.ID], v.Uses) + } + } + } + + memCheck(f) +} + +func memCheck(f *Func) { + // Check that if a tuple has a memory type, it is second. + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Type.IsTuple() && v.Type.FieldType(0).IsMemory() { + f.Fatalf("memory is first in a tuple: %s\n", v.LongString()) + } + } + } + + // Single live memory checks. + // These checks only work if there are no memory copies. + // (Memory copies introduce ambiguity about which mem value is really live. + // probably fixable, but it's easier to avoid the problem.) + // For the same reason, disable this check if some memory ops are unused. + for _, b := range f.Blocks { + for _, v := range b.Values { + if (v.Op == OpCopy || v.Uses == 0) && v.Type.IsMemory() { + return + } + } + if b != f.Entry && len(b.Preds) == 0 { + return + } + } + + // Compute live memory at the end of each block. + lastmem := make([]*Value, f.NumBlocks()) + ss := newSparseSet(f.NumValues()) + for _, b := range f.Blocks { + // Mark overwritten memory values. Those are args of other + // ops that generate memory values. + ss.clear() + for _, v := range b.Values { + if v.Op == OpPhi || !v.Type.IsMemory() { + continue + } + if m := v.MemoryArg(); m != nil { + ss.add(m.ID) + } + } + // There should be at most one remaining unoverwritten memory value. + for _, v := range b.Values { + if !v.Type.IsMemory() { + continue + } + if ss.contains(v.ID) { + continue + } + if lastmem[b.ID] != nil { + f.Fatalf("two live memory values in %s: %s and %s", b, lastmem[b.ID], v) + } + lastmem[b.ID] = v + } + // If there is no remaining memory value, that means there was no memory update. + // Take any memory arg. + if lastmem[b.ID] == nil { + for _, v := range b.Values { + if v.Op == OpPhi { + continue + } + m := v.MemoryArg() + if m == nil { + continue + } + if lastmem[b.ID] != nil && lastmem[b.ID] != m { + f.Fatalf("two live memory values in %s: %s and %s", b, lastmem[b.ID], m) + } + lastmem[b.ID] = m + } + } + } + // Propagate last live memory through storeless blocks. + for { + changed := false + for _, b := range f.Blocks { + if lastmem[b.ID] != nil { + continue + } + for _, e := range b.Preds { + p := e.b + if lastmem[p.ID] != nil { + lastmem[b.ID] = lastmem[p.ID] + changed = true + break + } + } + } + if !changed { + break + } + } + // Check merge points. + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op == OpPhi && v.Type.IsMemory() { + for i, a := range v.Args { + if a != lastmem[b.Preds[i].b.ID] { + f.Fatalf("inconsistent memory phi %s %d %s %s", v.LongString(), i, a, lastmem[b.Preds[i].b.ID]) + } + } + } + } + } + + // Check that only one memory is live at any point. + if f.scheduled { + for _, b := range f.Blocks { + var mem *Value // the current live memory in the block + for _, v := range b.Values { + if v.Op == OpPhi { + if v.Type.IsMemory() { + mem = v + } + continue + } + if mem == nil && len(b.Preds) > 0 { + // If no mem phi, take mem of any predecessor. + mem = lastmem[b.Preds[0].b.ID] + } + for _, a := range v.Args { + if a.Type.IsMemory() && a != mem { + f.Fatalf("two live mems @ %s: %s and %s", v, mem, a) + } + } + if v.Type.IsMemory() { + mem = v + } + } + } + } + + // Check that after scheduling, phis are always first in the block. + if f.scheduled { + for _, b := range f.Blocks { + seenNonPhi := false + for _, v := range b.Values { + switch v.Op { + case OpPhi: + if seenNonPhi { + f.Fatalf("phi after non-phi @ %s: %s", b, v) + } + default: + seenNonPhi = true + } + } + } + } +} + +// domCheck reports whether x dominates y (including x==y). +func domCheck(f *Func, sdom SparseTree, x, y *Block) bool { + if !sdom.IsAncestorEq(f.Entry, y) { + // unreachable - ignore + return true + } + return sdom.IsAncestorEq(x, y) +} + +// isExactFloat32 reports whether x can be exactly represented as a float32. +func isExactFloat32(x float64) bool { + // Check the mantissa is in range. + if bits.TrailingZeros64(math.Float64bits(x)) < 52-23 { + return false + } + // Check the exponent is in range. The mantissa check above is sufficient for NaN values. + return math.IsNaN(x) || x == float64(float32(x)) +} diff --git a/go/src/cmd/compile/internal/ssa/checkbce.go b/go/src/cmd/compile/internal/ssa/checkbce.go new file mode 100644 index 0000000000000000000000000000000000000000..d7400b2ae9c9ecd3e8f7eaffc21c4b18558d9703 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/checkbce.go @@ -0,0 +1,38 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import "cmd/compile/internal/logopt" + +// checkbce prints all bounds checks that are present in the function. +// Useful to find regressions. checkbce is only activated when with +// corresponding debug options, so it's off by default. +// See test/checkbce.go +func checkbce(f *Func) { + if f.pass.debug <= 0 && !logopt.Enabled() { + return + } + + for _, b := range f.Blocks { + if b.Kind == BlockInvalid { + continue + } + for _, v := range b.Values { + if v.Op == OpIsInBounds || v.Op == OpIsSliceInBounds { + if f.pass.debug > 0 { + f.Warnl(v.Pos, "Found %v", v.Op) + } + if logopt.Enabled() { + if v.Op == OpIsInBounds { + logopt.LogOpt(v.Pos, "isInBounds", "checkbce", f.Name) + } + if v.Op == OpIsSliceInBounds { + logopt.LogOpt(v.Pos, "isSliceInBounds", "checkbce", f.Name) + } + } + } + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/compile.go b/go/src/cmd/compile/internal/ssa/compile.go new file mode 100644 index 0000000000000000000000000000000000000000..f8cbd1c9a4ac1f07c34df81954bcc02a2862b6b9 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/compile.go @@ -0,0 +1,628 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/internal/src" + "fmt" + "hash/crc32" + "internal/buildcfg" + "io" + "log" + "math/rand" + "os" + "path/filepath" + "regexp" + "runtime" + "sort" + "strings" + "time" +) + +// Compile is the main entry point for this package. +// Compile modifies f so that on return: +// - all Values in f map to 0 or 1 assembly instructions of the target architecture +// - the order of f.Blocks is the order to emit the Blocks +// - the order of b.Values is the order to emit the Values in each Block +// - f has a non-nil regAlloc field +func Compile(f *Func) { + // TODO: debugging - set flags to control verbosity of compiler, + // which phases to dump IR before/after, etc. + if f.Log() { + f.Logf("compiling %s\n", f.Name) + } + + var rnd *rand.Rand + if checkEnabled { + seed := int64(crc32.ChecksumIEEE(([]byte)(f.Name))) ^ int64(checkRandSeed) + rnd = rand.New(rand.NewSource(seed)) + } + + // hook to print function & phase if panic happens + phaseName := "init" + defer func() { + if phaseName != "" { + err := recover() + stack := make([]byte, 16384) + n := runtime.Stack(stack, false) + stack = stack[:n] + if f.HTMLWriter != nil { + f.HTMLWriter.flushPhases() + } + f.Fatalf("panic during %s while compiling %s:\n\n%v\n\n%s\n", phaseName, f.Name, err, stack) + } + }() + + // Run all the passes + if f.Log() { + printFunc(f) + } + f.HTMLWriter.WritePhase("start", "start") + if BuildDump[f.Name] { + f.dumpFile("build") + } + if checkEnabled { + checkFunc(f) + } + const logMemStats = false + for _, p := range passes { + if !f.Config.optimize && !p.required || p.disabled { + continue + } + f.pass = &p + phaseName = p.name + if f.Log() { + f.Logf(" pass %s begin\n", p.name) + } + // TODO: capture logging during this pass, add it to the HTML + var mStart runtime.MemStats + if logMemStats || p.mem { + runtime.ReadMemStats(&mStart) + } + + if checkEnabled && !f.scheduled { + // Test that we don't depend on the value order, by randomizing + // the order of values in each block. See issue 18169. + for _, b := range f.Blocks { + for i := 0; i < len(b.Values)-1; i++ { + j := i + rnd.Intn(len(b.Values)-i) + b.Values[i], b.Values[j] = b.Values[j], b.Values[i] + } + } + } + + tStart := time.Now() + p.fn(f) + tEnd := time.Now() + + // Need something less crude than "Log the whole intermediate result". + if f.Log() || f.HTMLWriter != nil { + time := tEnd.Sub(tStart).Nanoseconds() + var stats string + if logMemStats { + var mEnd runtime.MemStats + runtime.ReadMemStats(&mEnd) + nBytes := mEnd.TotalAlloc - mStart.TotalAlloc + nAllocs := mEnd.Mallocs - mStart.Mallocs + stats = fmt.Sprintf("[%d ns %d allocs %d bytes]", time, nAllocs, nBytes) + } else { + stats = fmt.Sprintf("[%d ns]", time) + } + + if f.Log() { + f.Logf(" pass %s end %s\n", p.name, stats) + printFunc(f) + } + f.HTMLWriter.WritePhase(phaseName, fmt.Sprintf("%s %s", phaseName, stats)) + } + if p.time || p.mem { + // Surround timing information w/ enough context to allow comparisons. + time := tEnd.Sub(tStart).Nanoseconds() + if p.time { + f.LogStat("TIME(ns)", time) + } + if p.mem { + var mEnd runtime.MemStats + runtime.ReadMemStats(&mEnd) + nBytes := mEnd.TotalAlloc - mStart.TotalAlloc + nAllocs := mEnd.Mallocs - mStart.Mallocs + f.LogStat("TIME(ns):BYTES:ALLOCS", time, nBytes, nAllocs) + } + } + if p.dump != nil && p.dump[f.Name] { + // Dump function to appropriately named file + f.dumpFile(phaseName) + } + if checkEnabled { + checkFunc(f) + } + } + + if f.HTMLWriter != nil { + // Ensure we write any pending phases to the html + f.HTMLWriter.flushPhases() + } + + if f.ruleMatches != nil { + var keys []string + for key := range f.ruleMatches { + keys = append(keys, key) + } + sort.Strings(keys) + buf := new(strings.Builder) + fmt.Fprintf(buf, "%s: ", f.Name) + for _, key := range keys { + fmt.Fprintf(buf, "%s=%d ", key, f.ruleMatches[key]) + } + fmt.Fprint(buf, "\n") + fmt.Print(buf.String()) + } + + // Squash error printing defer + phaseName = "" +} + +// DumpFileForPhase creates a file from the function name and phase name, +// warning and returning nil if this is not possible. +func (f *Func) DumpFileForPhase(phaseName string) io.WriteCloser { + f.dumpFileSeq++ + fname := fmt.Sprintf("%s_%02d__%s.dump", f.Name, int(f.dumpFileSeq), phaseName) + fname = strings.ReplaceAll(fname, " ", "_") + fname = strings.ReplaceAll(fname, "/", "_") + fname = strings.ReplaceAll(fname, ":", "_") + + if ssaDir := os.Getenv("GOSSADIR"); ssaDir != "" { + fname = filepath.Join(ssaDir, fname) + } + + fi, err := os.Create(fname) + if err != nil { + f.Warnl(src.NoXPos, "Unable to create after-phase dump file %s", fname) + return nil + } + return fi +} + +// dumpFile creates a file from the phase name and function name +// Dumping is done to files to avoid buffering huge strings before +// output. +func (f *Func) dumpFile(phaseName string) { + fi := f.DumpFileForPhase(phaseName) + if fi != nil { + p := stringFuncPrinter{w: fi} + fprintFunc(p, f) + fi.Close() + } +} + +type pass struct { + name string + fn func(*Func) + required bool + disabled bool + time bool // report time to run pass + mem bool // report mem stats to run pass + stats int // pass reports own "stats" (e.g., branches removed) + debug int // pass performs some debugging. =1 should be in error-testing-friendly Warnl format. + test int // pass-specific ad-hoc option, perhaps useful in development + dump map[string]bool // dump if function name matches +} + +func (p *pass) addDump(s string) { + if p.dump == nil { + p.dump = make(map[string]bool) + } + p.dump[s] = true +} + +func (p *pass) String() string { + if p == nil { + return "nil pass" + } + return p.name +} + +// Run consistency checker between each phase +var ( + checkEnabled = false + checkRandSeed = 0 +) + +// Debug output +var IntrinsicsDebug int +var IntrinsicsDisable bool + +var BuildDebug int +var BuildTest int +var BuildStats int +var BuildDump map[string]bool = make(map[string]bool) // names of functions to dump after initial build of ssa + +var GenssaDump map[string]bool = make(map[string]bool) // names of functions to dump after ssa has been converted to asm + +// PhaseOption sets the specified flag in the specified ssa phase, +// returning empty string if this was successful or a string explaining +// the error if it was not. +// A version of the phase name with "_" replaced by " " is also checked for a match. +// If the phase name begins a '~' then the rest of the underscores-replaced-with-blanks +// version is used as a regular expression to match the phase name(s). +// +// Special cases that have turned out to be useful: +// - ssa/check/on enables checking after each phase +// - ssa/all/time enables time reporting for all phases +// +// See gc/lex.go for dissection of the option string. +// Example uses: +// +// GO_GCFLAGS=-d=ssa/generic_cse/time,ssa/generic_cse/stats,ssa/generic_cse/debug=3 ./make.bash +// +// BOOT_GO_GCFLAGS=-d='ssa/~^.*scc$/off' GO_GCFLAGS='-d=ssa/~^.*scc$/off' ./make.bash +func PhaseOption(phase, flag string, val int, valString string) string { + switch phase { + case "", "help": + lastcr := 0 + phasenames := " check, all, build, intrinsics, genssa" + for _, p := range passes { + pn := strings.ReplaceAll(p.name, " ", "_") + if len(pn)+len(phasenames)-lastcr > 70 { + phasenames += "\n " + lastcr = len(phasenames) + phasenames += pn + } else { + phasenames += ", " + pn + } + } + return `PhaseOptions usage: + + go tool compile -d=ssa//[=|] + +where: + +- is one of: +` + phasenames + ` + +- is one of: + on, off, debug, mem, time, test, stats, dump, seed + +- defaults to 1 + +- is required for the "dump" flag, and specifies the + name of function to dump after + +Phase "all" supports flags "time", "mem", and "dump". +Phase "intrinsics" supports flags "on", "off", and "debug". +Phase "genssa" (assembly generation) supports the flag "dump". + +If the "dump" flag is specified, the output is written on a file named +___.dump; otherwise it is directed to stdout. + +Examples: + + -d=ssa/check/on +enables checking after each phase + + -d=ssa/check/seed=1234 +enables checking after each phase, using 1234 to seed the PRNG +used for value order randomization + + -d=ssa/all/time +enables time reporting for all phases + + -d=ssa/prove/debug=2 +sets debugging level to 2 in the prove pass + +Be aware that when "/debug=X" is applied to a pass, some passes +will emit debug output for all functions, and other passes will +only emit debug output for functions that match the current +GOSSAFUNC value. + +Multiple flags can be passed at once, by separating them with +commas. For example: + + -d=ssa/check/on,ssa/all/time +` + } + + if phase == "check" { + switch flag { + case "on": + checkEnabled = val != 0 + debugPoset = checkEnabled // also turn on advanced self-checking in prove's data structure + return "" + case "off": + checkEnabled = val == 0 + debugPoset = checkEnabled + return "" + case "seed": + checkEnabled = true + checkRandSeed = val + debugPoset = checkEnabled + return "" + } + } + + alltime := false + allmem := false + alldump := false + if phase == "all" { + switch flag { + case "time": + alltime = val != 0 + case "mem": + allmem = val != 0 + case "dump": + alldump = val != 0 + if alldump { + BuildDump[valString] = true + GenssaDump[valString] = true + } + default: + return fmt.Sprintf("Did not find a flag matching %s in -d=ssa/%s debug option (expected ssa/all/{time,mem,dump=function_name})", flag, phase) + } + } + + if phase == "intrinsics" { + switch flag { + case "on": + IntrinsicsDisable = val == 0 + case "off": + IntrinsicsDisable = val != 0 + case "debug": + IntrinsicsDebug = val + default: + return fmt.Sprintf("Did not find a flag matching %s in -d=ssa/%s debug option (expected ssa/intrinsics/{on,off,debug})", flag, phase) + } + return "" + } + if phase == "build" { + switch flag { + case "debug": + BuildDebug = val + case "test": + BuildTest = val + case "stats": + BuildStats = val + case "dump": + BuildDump[valString] = true + default: + return fmt.Sprintf("Did not find a flag matching %s in -d=ssa/%s debug option (expected ssa/build/{debug,test,stats,dump=function_name})", flag, phase) + } + return "" + } + if phase == "genssa" { + switch flag { + case "dump": + GenssaDump[valString] = true + default: + return fmt.Sprintf("Did not find a flag matching %s in -d=ssa/%s debug option (expected ssa/genssa/dump=function_name)", flag, phase) + } + return "" + } + + underphase := strings.ReplaceAll(phase, "_", " ") + var re *regexp.Regexp + if phase[0] == '~' { + r, ok := regexp.Compile(underphase[1:]) + if ok != nil { + return fmt.Sprintf("Error %s in regexp for phase %s, flag %s", ok.Error(), phase, flag) + } + re = r + } + matchedOne := false + for i, p := range passes { + if phase == "all" { + p.time = alltime + p.mem = allmem + if alldump { + p.addDump(valString) + } + passes[i] = p + matchedOne = true + } else if p.name == phase || p.name == underphase || re != nil && re.MatchString(p.name) { + switch flag { + case "on": + p.disabled = val == 0 + case "off": + p.disabled = val != 0 + case "time": + p.time = val != 0 + case "mem": + p.mem = val != 0 + case "debug": + p.debug = val + case "stats": + p.stats = val + case "test": + p.test = val + case "dump": + p.addDump(valString) + default: + return fmt.Sprintf("Did not find a flag matching %s in -d=ssa/%s debug option", flag, phase) + } + if p.disabled && p.required { + return fmt.Sprintf("Cannot disable required SSA phase %s using -d=ssa/%s debug option", phase, phase) + } + passes[i] = p + matchedOne = true + } + } + if matchedOne { + return "" + } + return fmt.Sprintf("Did not find a phase matching %s in -d=ssa/... debug option", phase) +} + +// list of passes for the compiler +var passes = [...]pass{ + {name: "number lines", fn: numberLines, required: true}, + {name: "early phielim and copyelim", fn: copyelim}, + {name: "early deadcode", fn: deadcode}, // remove generated dead code to avoid doing pointless work during opt + {name: "short circuit", fn: shortcircuit}, + {name: "decompose user", fn: decomposeUser, required: true}, + {name: "pre-opt deadcode", fn: deadcode}, + {name: "opt", fn: opt, required: true}, + {name: "zero arg cse", fn: zcse, required: true}, // required to merge OpSB values + {name: "opt deadcode", fn: deadcode, required: true}, // remove any blocks orphaned during opt + {name: "generic cse", fn: cse}, + {name: "phiopt", fn: phiopt}, + {name: "gcse deadcode", fn: deadcode, required: true}, // clean out after cse and phiopt + {name: "nilcheckelim", fn: nilcheckelim}, + {name: "prove", fn: prove}, + {name: "divisible", fn: divisible, required: true}, + {name: "divmod", fn: divmod, required: true}, + {name: "middle opt", fn: opt, required: true}, + {name: "early fuse", fn: fuseEarly}, + {name: "expand calls", fn: expandCalls, required: true}, + {name: "decompose builtin", fn: postExpandCallsDecompose, required: true}, + {name: "softfloat", fn: softfloat, required: true}, + {name: "branchelim", fn: branchelim}, + {name: "late opt", fn: opt, required: true}, + {name: "dead auto elim", fn: elimDeadAutosGeneric}, + {name: "sccp", fn: sccp}, + {name: "generic deadcode", fn: deadcode, required: true}, // remove dead stores, which otherwise mess up store chain + {name: "late fuse", fn: fuseLate}, + {name: "check bce", fn: checkbce}, + {name: "dse", fn: dse}, + {name: "memcombine", fn: memcombine}, + {name: "writebarrier", fn: writebarrier, required: true}, // expand write barrier ops + {name: "insert resched checks", fn: insertLoopReschedChecks, + disabled: !buildcfg.Experiment.PreemptibleLoops}, // insert resched checks in loops. + {name: "cpufeatures", fn: cpufeatures, required: buildcfg.Experiment.SIMD, disabled: !buildcfg.Experiment.SIMD}, + {name: "rewrite tern", fn: rewriteTern, required: false, disabled: !buildcfg.Experiment.SIMD}, + {name: "lower", fn: lower, required: true}, + {name: "addressing modes", fn: addressingModes, required: false}, + {name: "late lower", fn: lateLower, required: true}, + {name: "pair", fn: pair}, + {name: "lowered deadcode for cse", fn: deadcode}, // deadcode immediately before CSE avoids CSE making dead values live again + {name: "lowered cse", fn: cse}, + {name: "elim unread autos", fn: elimUnreadAutos}, + {name: "tighten tuple selectors", fn: tightenTupleSelectors, required: true}, + {name: "lowered deadcode", fn: deadcode, required: true}, + {name: "checkLower", fn: checkLower, required: true}, + {name: "late phielim and copyelim", fn: copyelim}, + {name: "tighten", fn: tighten, required: true}, // move values closer to their uses + {name: "late deadcode", fn: deadcode}, + {name: "critical", fn: critical, required: true}, // remove critical edges + {name: "phi tighten", fn: phiTighten}, // place rematerializable phi args near uses to reduce value lifetimes + {name: "likelyadjust", fn: likelyadjust}, + {name: "layout", fn: layout, required: true}, // schedule blocks + {name: "schedule", fn: schedule, required: true}, // schedule values + {name: "late nilcheck", fn: nilcheckelim2}, + {name: "flagalloc", fn: flagalloc, required: true}, // allocate flags register + {name: "regalloc", fn: regalloc, required: true}, // allocate int & float registers + stack slots + {name: "loop rotate", fn: loopRotate}, + {name: "trim", fn: trim}, // remove empty blocks +} + +// Double-check phase ordering constraints. +// This code is intended to document the ordering requirements +// between different phases. It does not override the passes +// list above. +type constraint struct { + a, b string // a must come before b +} + +var passOrder = [...]constraint{ + // "insert resched checks" uses mem, better to clean out stores first. + {"dse", "insert resched checks"}, + // insert resched checks adds new blocks containing generic instructions + {"insert resched checks", "lower"}, + {"insert resched checks", "tighten"}, + + // prove relies on common-subexpression elimination for maximum benefits. + {"generic cse", "prove"}, + // deadcode after prove to eliminate all new dead blocks. + {"prove", "generic deadcode"}, + // divisible after prove to let prove analyze div and mod + {"prove", "divisible"}, + // divmod after divisible to avoid rewriting subexpressions of ones divisible will handle + {"divisible", "divmod"}, + // divmod before decompose builtin to handle 64-bit on 32-bit systems + {"divmod", "decompose builtin"}, + // common-subexpression before dead-store elim, so that we recognize + // when two address expressions are the same. + {"generic cse", "dse"}, + // cse substantially improves nilcheckelim efficacy + {"generic cse", "nilcheckelim"}, + // allow deadcode to clean up after nilcheckelim + {"nilcheckelim", "generic deadcode"}, + // nilcheckelim generates sequences of plain basic blocks + {"nilcheckelim", "late fuse"}, + // nilcheckelim relies on the first opt to rewrite user nil checks + {"opt", "nilcheckelim"}, + // tighten will be most effective when as many values have been removed as possible + {"generic deadcode", "tighten"}, + {"generic cse", "tighten"}, + // checkbce needs the values removed + {"generic deadcode", "check bce"}, + // decompose builtin now also cleans up after expand calls + {"expand calls", "decompose builtin"}, + // don't run optimization pass until we've decomposed builtin objects + {"decompose builtin", "late opt"}, + // decompose builtin is the last pass that may introduce new float ops, so run softfloat after it + {"decompose builtin", "softfloat"}, + // tuple selectors must be tightened to generators and de-duplicated before scheduling + {"tighten tuple selectors", "schedule"}, + // remove critical edges before phi tighten, so that phi args get better placement + {"critical", "phi tighten"}, + // don't layout blocks until critical edges have been removed + {"critical", "layout"}, + // regalloc requires the removal of all critical edges + {"critical", "regalloc"}, + // regalloc requires all the values in a block to be scheduled + {"schedule", "regalloc"}, + // the rules in late lower run after the general rules. + {"lower", "late lower"}, + // late lower may generate some values that need to be CSEed. + {"late lower", "lowered cse"}, + // checkLower must run after lowering & subsequent dead code elim + {"lower", "checkLower"}, + {"lowered deadcode", "checkLower"}, + {"late lower", "checkLower"}, + // late nilcheck needs instructions to be scheduled. + {"schedule", "late nilcheck"}, + // flagalloc needs instructions to be scheduled. + {"schedule", "flagalloc"}, + // regalloc needs flags to be allocated first. + {"flagalloc", "regalloc"}, + // loopRotate will confuse regalloc. + {"regalloc", "loop rotate"}, + // trim needs regalloc to be done first. + {"regalloc", "trim"}, + // memcombine works better if fuse happens first, to help merge stores. + {"late fuse", "memcombine"}, + // memcombine is a arch-independent pass. + {"memcombine", "lower"}, + // late opt transform some CondSelects into math. + {"branchelim", "late opt"}, + // branchelim is an arch-independent pass. + {"branchelim", "lower"}, + // lower needs cpu feature information (for SIMD) + {"cpufeatures", "lower"}, +} + +func init() { + for _, c := range passOrder { + a, b := c.a, c.b + i := -1 + j := -1 + for k, p := range passes { + if p.name == a { + i = k + } + if p.name == b { + j = k + } + } + if i < 0 { + log.Panicf("pass %s not found", a) + } + if j < 0 { + log.Panicf("pass %s not found", b) + } + if i >= j { + log.Panicf("passes %s and %s out of order", a, b) + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/config.go b/go/src/cmd/compile/internal/ssa/config.go new file mode 100644 index 0000000000000000000000000000000000000000..9cfaa58839fa7212295ad8e0a0ca6f325d5729e5 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/config.go @@ -0,0 +1,746 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/abi" + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" +) + +// A Config holds readonly compilation information. +// It is created once, early during compilation, +// and shared across all compilations. +type Config struct { + arch string // "amd64", etc. + PtrSize int64 // 4 or 8; copy of cmd/internal/sys.Arch.PtrSize + RegSize int64 // 4 or 8; copy of cmd/internal/sys.Arch.RegSize + Types Types + lowerBlock blockRewriter // block lowering function, first round + lowerValue valueRewriter // value lowering function, first round + lateLowerBlock blockRewriter // block lowering function that needs to be run after the first round; only used on some architectures + lateLowerValue valueRewriter // value lowering function that needs to be run after the first round; only used on some architectures + splitLoad valueRewriter // function for splitting merged load ops; only used on some architectures + registers []Register // machine registers + gpRegMask regMask // general purpose integer register mask + fpRegMask regMask // floating point register mask + fp32RegMask regMask // floating point register mask + fp64RegMask regMask // floating point register mask + specialRegMask regMask // special register mask + intParamRegs []int8 // register numbers of integer param (in/out) registers + floatParamRegs []int8 // register numbers of floating param (in/out) registers + ABI1 *abi.ABIConfig // "ABIInternal" under development // TODO change comment when this becomes current + ABI0 *abi.ABIConfig + FPReg int8 // register number of frame pointer, -1 if not used + LinkReg int8 // register number of link register if it is a general purpose register, -1 if not used + hasGReg bool // has hardware g register + ctxt *obj.Link // Generic arch information + optimize bool // Do optimization + SoftFloat bool // + Race bool // race detector enabled + BigEndian bool // + unalignedOK bool // Unaligned loads/stores are ok + haveBswap64 bool // architecture implements Bswap64 + haveBswap32 bool // architecture implements Bswap32 + haveBswap16 bool // architecture implements Bswap16 + haveCondSelect bool // architecture implements CondSelect + + // mulRecipes[x] = function to build v * x from v. + mulRecipes map[int64]mulRecipe +} + +type mulRecipe struct { + cost int + build func(*Value, *Value) *Value // build(m, v) returns v * x built at m. +} + +type ( + blockRewriter func(*Block) bool + valueRewriter func(*Value) bool +) + +type Types struct { + Bool *types.Type + Int8 *types.Type + Int16 *types.Type + Int32 *types.Type + Int64 *types.Type + UInt8 *types.Type + UInt16 *types.Type + UInt32 *types.Type + UInt64 *types.Type + Int *types.Type + Float32 *types.Type + Float64 *types.Type + UInt *types.Type + Uintptr *types.Type + String *types.Type + BytePtr *types.Type // TODO: use unsafe.Pointer instead? + Int32Ptr *types.Type + UInt32Ptr *types.Type + IntPtr *types.Type + UintptrPtr *types.Type + Float32Ptr *types.Type + Float64Ptr *types.Type + BytePtrPtr *types.Type + Vec128 *types.Type + Vec256 *types.Type + Vec512 *types.Type + Mask *types.Type +} + +// NewTypes creates and populates a Types. +func NewTypes() *Types { + t := new(Types) + t.SetTypPtrs() + return t +} + +// SetTypPtrs populates t. +func (t *Types) SetTypPtrs() { + t.Bool = types.Types[types.TBOOL] + t.Int8 = types.Types[types.TINT8] + t.Int16 = types.Types[types.TINT16] + t.Int32 = types.Types[types.TINT32] + t.Int64 = types.Types[types.TINT64] + t.UInt8 = types.Types[types.TUINT8] + t.UInt16 = types.Types[types.TUINT16] + t.UInt32 = types.Types[types.TUINT32] + t.UInt64 = types.Types[types.TUINT64] + t.Int = types.Types[types.TINT] + t.Float32 = types.Types[types.TFLOAT32] + t.Float64 = types.Types[types.TFLOAT64] + t.UInt = types.Types[types.TUINT] + t.Uintptr = types.Types[types.TUINTPTR] + t.String = types.Types[types.TSTRING] + t.BytePtr = types.NewPtr(types.Types[types.TUINT8]) + t.Int32Ptr = types.NewPtr(types.Types[types.TINT32]) + t.UInt32Ptr = types.NewPtr(types.Types[types.TUINT32]) + t.IntPtr = types.NewPtr(types.Types[types.TINT]) + t.UintptrPtr = types.NewPtr(types.Types[types.TUINTPTR]) + t.Float32Ptr = types.NewPtr(types.Types[types.TFLOAT32]) + t.Float64Ptr = types.NewPtr(types.Types[types.TFLOAT64]) + t.BytePtrPtr = types.NewPtr(types.NewPtr(types.Types[types.TUINT8])) + t.Vec128 = types.TypeVec128 + t.Vec256 = types.TypeVec256 + t.Vec512 = types.TypeVec512 + t.Mask = types.TypeMask +} + +type Logger interface { + // Logf logs a message from the compiler. + Logf(string, ...any) + + // Log reports whether logging is not a no-op + // some logging calls account for more than a few heap allocations. + Log() bool + + // Fatalf reports a compiler error and exits. + Fatalf(pos src.XPos, msg string, args ...any) + + // Warnl writes compiler messages in the form expected by "errorcheck" tests + Warnl(pos src.XPos, fmt_ string, args ...any) + + // Forwards the Debug flags from gc + Debug_checknil() bool +} + +type Frontend interface { + Logger + + // StringData returns a symbol pointing to the given string's contents. + StringData(string) *obj.LSym + + // Given the name for a compound type, returns the name we should use + // for the parts of that compound type. + SplitSlot(parent *LocalSlot, suffix string, offset int64, t *types.Type) LocalSlot + + // Syslook returns a symbol of the runtime function/variable with the + // given name. + Syslook(string) *obj.LSym + + // UseWriteBarrier reports whether write barrier is enabled + UseWriteBarrier() bool + + // Func returns the ir.Func of the function being compiled. + Func() *ir.Func +} + +// NewConfig returns a new configuration object for the given architecture. +func NewConfig(arch string, types Types, ctxt *obj.Link, optimize, softfloat bool) *Config { + c := &Config{arch: arch, Types: types} + switch arch { + case "amd64": + c.PtrSize = 8 + c.RegSize = 8 + c.lowerBlock = rewriteBlockAMD64 + c.lowerValue = rewriteValueAMD64 + c.lateLowerBlock = rewriteBlockAMD64latelower + c.lateLowerValue = rewriteValueAMD64latelower + c.splitLoad = rewriteValueAMD64splitload + c.registers = registersAMD64[:] + c.gpRegMask = gpRegMaskAMD64 + c.fpRegMask = fpRegMaskAMD64 + c.specialRegMask = specialRegMaskAMD64 + c.intParamRegs = paramIntRegAMD64 + c.floatParamRegs = paramFloatRegAMD64 + c.FPReg = framepointerRegAMD64 + c.LinkReg = linkRegAMD64 + c.hasGReg = true + c.unalignedOK = true + c.haveBswap64 = true + c.haveBswap32 = true + c.haveBswap16 = true + c.haveCondSelect = true + case "386": + c.PtrSize = 4 + c.RegSize = 4 + c.lowerBlock = rewriteBlock386 + c.lowerValue = rewriteValue386 + c.splitLoad = rewriteValue386splitload + c.registers = registers386[:] + c.gpRegMask = gpRegMask386 + c.fpRegMask = fpRegMask386 + c.FPReg = framepointerReg386 + c.LinkReg = linkReg386 + c.hasGReg = false + c.unalignedOK = true + c.haveBswap32 = true + c.haveBswap16 = true + case "arm": + c.PtrSize = 4 + c.RegSize = 4 + c.lowerBlock = rewriteBlockARM + c.lowerValue = rewriteValueARM + c.registers = registersARM[:] + c.gpRegMask = gpRegMaskARM + c.fpRegMask = fpRegMaskARM + c.FPReg = framepointerRegARM + c.LinkReg = linkRegARM + c.hasGReg = true + case "arm64": + c.PtrSize = 8 + c.RegSize = 8 + c.lowerBlock = rewriteBlockARM64 + c.lowerValue = rewriteValueARM64 + c.lateLowerBlock = rewriteBlockARM64latelower + c.lateLowerValue = rewriteValueARM64latelower + c.registers = registersARM64[:] + c.gpRegMask = gpRegMaskARM64 + c.fpRegMask = fpRegMaskARM64 + c.intParamRegs = paramIntRegARM64 + c.floatParamRegs = paramFloatRegARM64 + c.FPReg = framepointerRegARM64 + c.LinkReg = linkRegARM64 + c.hasGReg = true + c.unalignedOK = true + c.haveBswap64 = true + c.haveBswap32 = true + c.haveBswap16 = true + c.haveCondSelect = true + case "ppc64": + c.BigEndian = true + fallthrough + case "ppc64le": + c.PtrSize = 8 + c.RegSize = 8 + c.lowerBlock = rewriteBlockPPC64 + c.lowerValue = rewriteValuePPC64 + c.lateLowerBlock = rewriteBlockPPC64latelower + c.lateLowerValue = rewriteValuePPC64latelower + c.registers = registersPPC64[:] + c.gpRegMask = gpRegMaskPPC64 + c.fpRegMask = fpRegMaskPPC64 + c.specialRegMask = specialRegMaskPPC64 + c.intParamRegs = paramIntRegPPC64 + c.floatParamRegs = paramFloatRegPPC64 + c.FPReg = framepointerRegPPC64 + c.LinkReg = linkRegPPC64 + c.hasGReg = true + c.unalignedOK = true + // Note: ppc64 has register bswap ops only when GOPPC64>=10. + // But it has bswap+load and bswap+store ops for all ppc64 variants. + // That is the sense we're using them here - they are only used + // in contexts where they can be merged with a load or store. + c.haveBswap64 = true + c.haveBswap32 = true + c.haveBswap16 = true + c.haveCondSelect = true + case "mips64": + c.BigEndian = true + fallthrough + case "mips64le": + c.PtrSize = 8 + c.RegSize = 8 + c.lowerBlock = rewriteBlockMIPS64 + c.lowerValue = rewriteValueMIPS64 + c.lateLowerBlock = rewriteBlockMIPS64latelower + c.lateLowerValue = rewriteValueMIPS64latelower + c.registers = registersMIPS64[:] + c.gpRegMask = gpRegMaskMIPS64 + c.fpRegMask = fpRegMaskMIPS64 + c.specialRegMask = specialRegMaskMIPS64 + c.FPReg = framepointerRegMIPS64 + c.LinkReg = linkRegMIPS64 + c.hasGReg = true + case "loong64": + c.PtrSize = 8 + c.RegSize = 8 + c.lowerBlock = rewriteBlockLOONG64 + c.lowerValue = rewriteValueLOONG64 + c.lateLowerBlock = rewriteBlockLOONG64latelower + c.lateLowerValue = rewriteValueLOONG64latelower + c.registers = registersLOONG64[:] + c.gpRegMask = gpRegMaskLOONG64 + c.fpRegMask = fpRegMaskLOONG64 + c.intParamRegs = paramIntRegLOONG64 + c.floatParamRegs = paramFloatRegLOONG64 + c.FPReg = framepointerRegLOONG64 + c.LinkReg = linkRegLOONG64 + c.hasGReg = true + c.unalignedOK = true + c.haveCondSelect = true + case "s390x": + c.PtrSize = 8 + c.RegSize = 8 + c.lowerBlock = rewriteBlockS390X + c.lowerValue = rewriteValueS390X + c.registers = registersS390X[:] + c.gpRegMask = gpRegMaskS390X + c.fpRegMask = fpRegMaskS390X + c.intParamRegs = paramIntRegS390X + c.floatParamRegs = paramFloatRegS390X + c.FPReg = framepointerRegS390X + c.LinkReg = linkRegS390X + c.hasGReg = true + c.BigEndian = true + c.unalignedOK = true + c.haveBswap64 = true + c.haveBswap32 = true + c.haveBswap16 = true // only for loads&stores, see ppc64 comment + case "mips": + c.BigEndian = true + fallthrough + case "mipsle": + c.PtrSize = 4 + c.RegSize = 4 + c.lowerBlock = rewriteBlockMIPS + c.lowerValue = rewriteValueMIPS + c.registers = registersMIPS[:] + c.gpRegMask = gpRegMaskMIPS + c.fpRegMask = fpRegMaskMIPS + c.specialRegMask = specialRegMaskMIPS + c.FPReg = framepointerRegMIPS + c.LinkReg = linkRegMIPS + c.hasGReg = true + case "riscv64": + c.PtrSize = 8 + c.RegSize = 8 + c.lowerBlock = rewriteBlockRISCV64 + c.lowerValue = rewriteValueRISCV64 + c.lateLowerBlock = rewriteBlockRISCV64latelower + c.lateLowerValue = rewriteValueRISCV64latelower + c.registers = registersRISCV64[:] + c.gpRegMask = gpRegMaskRISCV64 + c.fpRegMask = fpRegMaskRISCV64 + c.intParamRegs = paramIntRegRISCV64 + c.floatParamRegs = paramFloatRegRISCV64 + c.FPReg = framepointerRegRISCV64 + c.hasGReg = true + case "wasm": + c.PtrSize = 8 + c.RegSize = 8 + c.lowerBlock = rewriteBlockWasm + c.lowerValue = rewriteValueWasm + c.registers = registersWasm[:] + c.gpRegMask = gpRegMaskWasm + c.fpRegMask = fpRegMaskWasm + c.fp32RegMask = fp32RegMaskWasm + c.fp64RegMask = fp64RegMaskWasm + c.FPReg = framepointerRegWasm + c.LinkReg = linkRegWasm + c.hasGReg = true + c.unalignedOK = true + c.haveCondSelect = true + default: + ctxt.Diag("arch %s not implemented", arch) + } + c.ctxt = ctxt + c.optimize = optimize + c.SoftFloat = softfloat + if softfloat { + c.floatParamRegs = nil // no FP registers in softfloat mode + } + + c.ABI0 = abi.NewABIConfig(0, 0, ctxt.Arch.FixedFrameSize, 0) + c.ABI1 = abi.NewABIConfig(len(c.intParamRegs), len(c.floatParamRegs), ctxt.Arch.FixedFrameSize, 1) + + if ctxt.Flag_shared { + // LoweredWB is secretly a CALL and CALLs on 386 in + // shared mode get rewritten by obj6.go to go through + // the GOT, which clobbers BX. + opcodeTable[Op386LoweredWB].reg.clobbers |= 1 << 3 // BX + } + + c.buildRecipes(arch) + + return c +} + +func (c *Config) Ctxt() *obj.Link { return c.ctxt } + +func (c *Config) haveByteSwap(size int64) bool { + switch size { + case 8: + return c.haveBswap64 + case 4: + return c.haveBswap32 + case 2: + return c.haveBswap16 + default: + base.Fatalf("bad size %d\n", size) + return false + } +} + +func (c *Config) buildRecipes(arch string) { + // Information for strength-reducing multiplies. + type linearCombo struct { + // we can compute a*x+b*y in one instruction + a, b int64 + // cost, in arbitrary units (tenths of cycles, usually) + cost int + // builds SSA value for a*x+b*y. Use the position + // information from m. + build func(m, x, y *Value) *Value + } + + // List all the linear combination instructions we have. + var linearCombos []linearCombo + r := func(a, b int64, cost int, build func(m, x, y *Value) *Value) { + linearCombos = append(linearCombos, linearCombo{a: a, b: b, cost: cost, build: build}) + } + var mulCost int + switch arch { + case "amd64": + // Assumes that the following costs from https://gmplib.org/~tege/x86-timing.pdf: + // 1 - addq, shlq, leaq, negq, subq + // 3 - imulq + // These costs limit the rewrites to two instructions. + // Operations which have to happen in place (and thus + // may require a reg-reg move) score slightly higher. + mulCost = 30 + // add + r(1, 1, 10, + func(m, x, y *Value) *Value { + v := m.Block.NewValue2(m.Pos, OpAMD64ADDQ, m.Type, x, y) + if m.Type.Size() == 4 { + v.Op = OpAMD64ADDL + } + return v + }) + // neg + r(-1, 0, 11, + func(m, x, y *Value) *Value { + v := m.Block.NewValue1(m.Pos, OpAMD64NEGQ, m.Type, x) + if m.Type.Size() == 4 { + v.Op = OpAMD64NEGL + } + return v + }) + // sub + r(1, -1, 11, + func(m, x, y *Value) *Value { + v := m.Block.NewValue2(m.Pos, OpAMD64SUBQ, m.Type, x, y) + if m.Type.Size() == 4 { + v.Op = OpAMD64SUBL + } + return v + }) + // lea + r(1, 2, 10, + func(m, x, y *Value) *Value { + v := m.Block.NewValue2(m.Pos, OpAMD64LEAQ2, m.Type, x, y) + if m.Type.Size() == 4 { + v.Op = OpAMD64LEAL2 + } + return v + }) + r(1, 4, 10, + func(m, x, y *Value) *Value { + v := m.Block.NewValue2(m.Pos, OpAMD64LEAQ4, m.Type, x, y) + if m.Type.Size() == 4 { + v.Op = OpAMD64LEAL4 + } + return v + }) + r(1, 8, 10, + func(m, x, y *Value) *Value { + v := m.Block.NewValue2(m.Pos, OpAMD64LEAQ8, m.Type, x, y) + if m.Type.Size() == 4 { + v.Op = OpAMD64LEAL8 + } + return v + }) + // regular shifts + for i := 2; i < 64; i++ { + r(1< 4 { + c++ + } + r(1, 1< 4 { + c++ + } + r(-1< 4 { + c++ + } + r(1, -1< 0 { + f.Warnl(v.Pos, "eliminated phi") + } + return true +} diff --git a/go/src/cmd/compile/internal/ssa/copyelim_test.go b/go/src/cmd/compile/internal/ssa/copyelim_test.go new file mode 100644 index 0000000000000000000000000000000000000000..20e548f7fc9d3e1ccb217417a159ea2f7ffa9a7b --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/copyelim_test.go @@ -0,0 +1,41 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "fmt" + "testing" +) + +func BenchmarkCopyElim1(b *testing.B) { benchmarkCopyElim(b, 1) } +func BenchmarkCopyElim10(b *testing.B) { benchmarkCopyElim(b, 10) } +func BenchmarkCopyElim100(b *testing.B) { benchmarkCopyElim(b, 100) } +func BenchmarkCopyElim1000(b *testing.B) { benchmarkCopyElim(b, 1000) } +func BenchmarkCopyElim10000(b *testing.B) { benchmarkCopyElim(b, 10000) } +func BenchmarkCopyElim100000(b *testing.B) { benchmarkCopyElim(b, 100000) } + +func benchmarkCopyElim(b *testing.B, n int) { + c := testConfig(b) + + values := make([]any, 0, n+2) + values = append(values, Valu("mem", OpInitMem, types.TypeMem, 0, nil)) + last := "mem" + for i := 0; i < n; i++ { + name := fmt.Sprintf("copy%d", i) + values = append(values, Valu(name, OpCopy, types.TypeMem, 0, nil, last)) + last = name + } + values = append(values, Exit(last)) + // Reverse values array to make it hard + for i := 0; i < len(values)/2; i++ { + values[i], values[len(values)-1-i] = values[len(values)-1-i], values[i] + } + + for i := 0; i < b.N; i++ { + fun := c.Fun("entry", Bloc("entry", values...)) + Copyelim(fun.f) + } +} diff --git a/go/src/cmd/compile/internal/ssa/cpufeatures.go b/go/src/cmd/compile/internal/ssa/cpufeatures.go new file mode 100644 index 0000000000000000000000000000000000000000..e668958fab5339896733cf6da2f49732083f644e --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/cpufeatures.go @@ -0,0 +1,262 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "cmd/internal/obj" + "fmt" + "internal/goarch" +) + +type localEffect struct { + start CPUfeatures // features present at beginning of block + internal CPUfeatures // features implied by execution of block + end [2]CPUfeatures // for BlockIf, features present on outgoing edges + visited bool // On the first iteration this will be false for backedges. +} + +func (e localEffect) String() string { + return fmt.Sprintf("visited=%v, start=%v, internal=%v, end[0]=%v, end[1]=%v", e.visited, e.start, e.internal, e.end[0], e.end[1]) +} + +// ifEffect pattern matches for a BlockIf conditional on a load +// of a field from internal/cpu.X86 and returns the corresponding +// effect. +func ifEffect(b *Block) (features CPUfeatures, taken int) { + // TODO generalize for other architectures. + if b.Kind != BlockIf { + return + } + c := b.Controls[0] + + if c.Op == OpNot { + taken = 1 + c = c.Args[0] + } + if c.Op != OpLoad { + return + } + offPtr := c.Args[0] + if offPtr.Op != OpOffPtr { + return + } + addr := offPtr.Args[0] + if addr.Op != OpAddr || addr.Args[0].Op != OpSB { + return + } + sym := addr.Aux.(*obj.LSym) + if sym.Name != "internal/cpu.X86" { + return + } + o := offPtr.AuxInt + t := addr.Type + if !t.IsPtr() { + b.Func.Fatalf("The symbol %s is not a pointer, found %v instead", sym.Name, t) + } + t = t.Elem() + if !t.IsStruct() { + b.Func.Fatalf("The referent of symbol %s is not a struct, found %v instead", sym.Name, t) + } + match := "" + for _, f := range t.Fields() { + if o == f.Offset && f.Sym != nil { + match = f.Sym.Name + break + } + } + + switch match { + + case "HasAVX": + features = CPUavx + case "HasAVXVNNI": + features = CPUavx | CPUavxvnni + case "HasAVX2": + features = CPUavx2 | CPUavx + + // Compiler currently treats these all alike. + case "HasAVX512", "HasAVX512F", "HasAVX512CD", "HasAVX512BW", + "HasAVX512DQ", "HasAVX512VL", "HasAVX512VPCLMULQDQ": + features = CPUavx512 | CPUavx2 | CPUavx + + case "HasAVX512GFNI": + features = CPUavx512 | CPUgfni | CPUavx2 | CPUavx + case "HasAVX512VNNI": + features = CPUavx512 | CPUavx512vnni | CPUavx2 | CPUavx + case "HasAVX512VBMI": + features = CPUavx512 | CPUvbmi | CPUavx2 | CPUavx + case "HasAVX512VBMI2": + features = CPUavx512 | CPUvbmi2 | CPUavx2 | CPUavx + case "HasAVX512BITALG": + features = CPUavx512 | CPUbitalg | CPUavx2 | CPUavx + case "HasAVX512VPOPCNTDQ": + features = CPUavx512 | CPUvpopcntdq | CPUavx2 | CPUavx + + case "HasBMI1": + features = CPUvbmi + case "HasBMI2": + features = CPUvbmi2 + + // Features that are not currently interesting to the compiler. + case "HasAES", "HasADX", "HasERMS", "HasFSRM", "HasFMA", "HasGFNI", "HasOSXSAVE", + "HasPCLMULQDQ", "HasPOPCNT", "HasRDTSCP", "HasSHA", + "HasSSE3", "HasSSSE3", "HasSSE41", "HasSSE42": + + } + if b.Func.pass.debug > 2 { + b.Func.Warnl(b.Pos, "%s, block b%v has features offset %d, match is %s, features is %v", b.Func.Name, b.ID, o, match, features) + } + return +} + +func cpufeatures(f *Func) { + arch := f.Config.Ctxt().Arch.Family + // TODO there are other SIMD architectures + if arch != goarch.AMD64 { + return + } + + po := f.Postorder() + + effects := make([]localEffect, 1+f.NumBlocks(), 1+f.NumBlocks()) + + features := func(t *types.Type) CPUfeatures { + if t.IsSIMD() { + switch t.Size() { + case 16, 32: + return CPUavx + case 64: + return CPUavx512 | CPUavx2 | CPUavx + } + } + return CPUNone + } + + // visit blocks in reverse post order + // when b is visited, all of its predecessors (except for loop back edges) + // will have been visited + for i := len(po) - 1; i >= 0; i-- { + b := po[i] + + var feat CPUfeatures + + if b == f.Entry { + // Check the types of inputs and outputs, as well as annotations. + // Start with none and union all that is implied by all the types seen. + if f.Type != nil { // a problem for SSA tests + for _, field := range f.Type.RecvParamsResults() { + feat |= features(field.Type) + } + } + + } else { + // Start with all and intersect over predecessors + feat = CPUAll + for _, p := range b.Preds { + pb := p.Block() + if !effects[pb.ID].visited { + + continue + } + pi := p.Index() + if pb.Kind != BlockIf { + pi = 0 + } + + feat &= effects[pb.ID].end[pi] + } + } + + e := localEffect{start: feat, visited: true} + + // Separately capture the internal effects of this block + var internal CPUfeatures + for _, v := range b.Values { + // the rule applied here is, if the block contains any + // instruction that would fault if the feature (avx, avx512) + // were not present, then assume that the feature is present + // for all the instructions in the block, a fault is a fault. + t := v.Type + if t.IsResults() { + for i := 0; i < t.NumFields(); i++ { + feat |= features(t.FieldType(i)) + } + } else { + internal |= features(v.Type) + } + } + e.internal = internal + feat |= internal + + branchEffect, taken := ifEffect(b) + e.end = [2]CPUfeatures{feat, feat} + e.end[taken] |= branchEffect + + effects[b.ID] = e + if f.pass.debug > 1 && feat != CPUNone { + f.Warnl(b.Pos, "%s, block b%v has features %v", b.Func.Name, b.ID, feat) + } + + b.CPUfeatures = feat + f.maxCPUFeatures |= feat // not necessary to refine this estimate below + } + + // If the flow graph is irreducible, things can still change on backedges. + change := true + for change { + change = false + for i := len(po) - 1; i >= 0; i-- { + b := po[i] + + if b == f.Entry { + continue // cannot change + } + feat := CPUAll + for _, p := range b.Preds { + pb := p.Block() + pi := p.Index() + if pb.Kind != BlockIf { + pi = 0 + } + feat &= effects[pb.ID].end[pi] + } + e := effects[b.ID] + if feat == e.start { + continue + } + e.start = feat + effects[b.ID] = e + // uh-oh, something changed + if f.pass.debug > 1 { + f.Warnl(b.Pos, "%s, block b%v saw predecessor feature change", b.Func.Name, b.ID) + } + + feat |= e.internal + if feat == e.end[0]&e.end[1] { + continue + } + + branchEffect, taken := ifEffect(b) + e.end = [2]CPUfeatures{feat, feat} + e.end[taken] |= branchEffect + + effects[b.ID] = e + b.CPUfeatures = feat + if f.pass.debug > 1 { + f.Warnl(b.Pos, "%s, block b%v has new features %v", b.Func.Name, b.ID, feat) + } + change = true + } + } + if f.pass.debug > 0 { + for _, b := range f.Blocks { + if b.CPUfeatures != CPUNone { + f.Warnl(b.Pos, "%s, block b%v has features %v", b.Func.Name, b.ID, b.CPUfeatures) + } + + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/critical.go b/go/src/cmd/compile/internal/ssa/critical.go new file mode 100644 index 0000000000000000000000000000000000000000..f14bb93e6d324131b9b7a4c0c7e6d64614f8d8c7 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/critical.go @@ -0,0 +1,111 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// critical splits critical edges (those that go from a block with +// more than one outedge to a block with more than one inedge). +// Regalloc wants a critical-edge-free CFG so it can implement phi values. +func critical(f *Func) { + // maps from phi arg ID to the new block created for that argument + blocks := f.Cache.allocBlockSlice(f.NumValues()) + defer f.Cache.freeBlockSlice(blocks) + // need to iterate over f.Blocks without range, as we might + // need to split critical edges on newly constructed blocks + for j := 0; j < len(f.Blocks); j++ { + b := f.Blocks[j] + if len(b.Preds) <= 1 { + continue + } + + var phi *Value + // determine if we've only got a single phi in this + // block, this is easier to handle than the general + // case of a block with multiple phi values. + for _, v := range b.Values { + if v.Op == OpPhi { + if phi != nil { + phi = nil + break + } + phi = v + } + } + + // reset our block map + if phi != nil { + for _, v := range phi.Args { + blocks[v.ID] = nil + } + } + + // split input edges coming from multi-output blocks. + for i := 0; i < len(b.Preds); { + e := b.Preds[i] + p := e.b + pi := e.i + if p.Kind == BlockPlain { + i++ + continue // only single output block + } + + var d *Block // new block used to remove critical edge + reusedBlock := false // if true, then this is not the first use of this block + if phi != nil { + argID := phi.Args[i].ID + // find or record the block that we used to split + // critical edges for this argument + if d = blocks[argID]; d == nil { + // splitting doesn't necessarily remove the critical edge, + // since we're iterating over len(f.Blocks) above, this forces + // the new blocks to be re-examined. + d = f.NewBlock(BlockPlain) + d.Pos = p.Pos + blocks[argID] = d + if f.pass.debug > 0 { + f.Warnl(p.Pos, "split critical edge") + } + } else { + reusedBlock = true + } + } else { + // no existing block, so allocate a new block + // to place on the edge + d = f.NewBlock(BlockPlain) + d.Pos = p.Pos + if f.pass.debug > 0 { + f.Warnl(p.Pos, "split critical edge") + } + } + + // if this not the first argument for the + // block, then we need to remove the + // corresponding elements from the block + // predecessors and phi args + if reusedBlock { + // Add p->d edge + p.Succs[pi] = Edge{d, len(d.Preds)} + d.Preds = append(d.Preds, Edge{p, pi}) + + // Remove p as a predecessor from b. + b.removePred(i) + + // Update corresponding phi args + b.removePhiArg(phi, i) + + // splitting occasionally leads to a phi having + // a single argument (occurs with -N) + // Don't increment i in this case because we moved + // an unprocessed predecessor down into slot i. + } else { + // splice it in + p.Succs[pi] = Edge{d, 0} + b.Preds[i] = Edge{d, 0} + d.Preds = append(d.Preds, Edge{p, pi}) + d.Succs = append(d.Succs, Edge{b, i}) + i++ + } + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/cse.go b/go/src/cmd/compile/internal/ssa/cse.go new file mode 100644 index 0000000000000000000000000000000000000000..28eb4f76a9d134e15f0d96aed53b240c06fd8719 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/cse.go @@ -0,0 +1,422 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "cmd/internal/src" + "cmp" + "fmt" + "slices" +) + +// cse does common-subexpression elimination on the Function. +// Values are just relinked, nothing is deleted. A subsequent deadcode +// pass is required to actually remove duplicate expressions. +func cse(f *Func) { + // Two values are equivalent if they satisfy the following definition: + // equivalent(v, w): + // v.op == w.op + // v.type == w.type + // v.aux == w.aux + // v.auxint == w.auxint + // len(v.args) == len(w.args) + // v.block == w.block if v.op == OpPhi + // equivalent(v.args[i], w.args[i]) for i in 0..len(v.args)-1 + + // The algorithm searches for a partition of f's values into + // equivalence classes using the above definition. + // It starts with a coarse partition and iteratively refines it + // until it reaches a fixed point. + + // Make initial coarse partitions by using a subset of the conditions above. + a := f.Cache.allocValueSlice(f.NumValues()) + defer func() { f.Cache.freeValueSlice(a) }() // inside closure to use final value of a + a = a[:0] + o := f.Cache.allocInt32Slice(f.NumValues()) // the ordering score for stores + defer func() { f.Cache.freeInt32Slice(o) }() + if f.auxmap == nil { + f.auxmap = auxmap{} + } + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Type.IsMemory() { + continue // memory values can never cse + } + if f.auxmap[v.Aux] == 0 { + f.auxmap[v.Aux] = int32(len(f.auxmap)) + 1 + } + a = append(a, v) + } + } + partition := partitionValues(a, f.auxmap) + + // map from value id back to eqclass id + valueEqClass := f.Cache.allocIDSlice(f.NumValues()) + defer f.Cache.freeIDSlice(valueEqClass) + for _, b := range f.Blocks { + for _, v := range b.Values { + // Use negative equivalence class #s for unique values. + valueEqClass[v.ID] = -v.ID + } + } + var pNum ID = 1 + for _, e := range partition { + if f.pass.debug > 1 && len(e) > 500 { + fmt.Printf("CSE.large partition (%d): ", len(e)) + for j := 0; j < 3; j++ { + fmt.Printf("%s ", e[j].LongString()) + } + fmt.Println() + } + + for _, v := range e { + valueEqClass[v.ID] = pNum + } + if f.pass.debug > 2 && len(e) > 1 { + fmt.Printf("CSE.partition #%d:", pNum) + for _, v := range e { + fmt.Printf(" %s", v.String()) + } + fmt.Printf("\n") + } + pNum++ + } + + // Split equivalence classes at points where they have + // non-equivalent arguments. Repeat until we can't find any + // more splits. + var splitPoints []int + for { + changed := false + + // partition can grow in the loop. By not using a range loop here, + // we process new additions as they arrive, avoiding O(n^2) behavior. + for i := 0; i < len(partition); i++ { + e := partition[i] + + if opcodeTable[e[0].Op].commutative { + // Order the first two args before comparison. + for _, v := range e { + if valueEqClass[v.Args[0].ID] > valueEqClass[v.Args[1].ID] { + v.Args[0], v.Args[1] = v.Args[1], v.Args[0] + } + } + } + + // Sort by eq class of arguments. + slices.SortFunc(e, func(v, w *Value) int { + for i, a := range v.Args { + b := w.Args[i] + if valueEqClass[a.ID] < valueEqClass[b.ID] { + return -1 + } + if valueEqClass[a.ID] > valueEqClass[b.ID] { + return +1 + } + } + return 0 + }) + + // Find split points. + splitPoints = append(splitPoints[:0], 0) + for j := 1; j < len(e); j++ { + v, w := e[j-1], e[j] + // Note: commutative args already correctly ordered by byArgClass. + eqArgs := true + for k, a := range v.Args { + if v.Op == OpLocalAddr && k == 1 { + continue + } + b := w.Args[k] + if valueEqClass[a.ID] != valueEqClass[b.ID] { + eqArgs = false + break + } + } + if !eqArgs { + splitPoints = append(splitPoints, j) + } + } + if len(splitPoints) == 1 { + continue // no splits, leave equivalence class alone. + } + + // Move another equivalence class down in place of e. + partition[i] = partition[len(partition)-1] + partition = partition[:len(partition)-1] + i-- + + // Add new equivalence classes for the parts of e we found. + splitPoints = append(splitPoints, len(e)) + for j := 0; j < len(splitPoints)-1; j++ { + f := e[splitPoints[j]:splitPoints[j+1]] + if len(f) == 1 { + // Don't add singletons. + valueEqClass[f[0].ID] = -f[0].ID + continue + } + for _, v := range f { + valueEqClass[v.ID] = pNum + } + pNum++ + partition = append(partition, f) + } + changed = true + } + + if !changed { + break + } + } + + sdom := f.Sdom() + + // Compute substitutions we would like to do. We substitute v for w + // if v and w are in the same equivalence class and v dominates w. + rewrite := f.Cache.allocValueSlice(f.NumValues()) + defer f.Cache.freeValueSlice(rewrite) + for _, e := range partition { + slices.SortFunc(e, func(v, w *Value) int { + c := cmp.Compare(sdom.domorder(v.Block), sdom.domorder(w.Block)) + if c != 0 { + return c + } + if v.Op == OpLocalAddr { + // compare the memory args for OpLocalAddrs in the same block + vm := v.Args[1] + wm := w.Args[1] + if vm == wm { + return 0 + } + // if the two OpLocalAddrs are in the same block, and one's memory + // arg also in the same block, but the other one's memory arg not, + // the latter must be in an ancestor block + if vm.Block != v.Block { + return -1 + } + if wm.Block != w.Block { + return +1 + } + // use store order if the memory args are in the same block + vs := storeOrdering(vm, o) + ws := storeOrdering(wm, o) + if vs <= 0 { + f.Fatalf("unable to determine the order of %s", vm.LongString()) + } + if ws <= 0 { + f.Fatalf("unable to determine the order of %s", wm.LongString()) + } + return cmp.Compare(vs, ws) + } + vStmt := v.Pos.IsStmt() == src.PosIsStmt + wStmt := w.Pos.IsStmt() == src.PosIsStmt + if vStmt != wStmt { + if vStmt { + return -1 + } + return +1 + } + return 0 + }) + + for i := 0; i < len(e)-1; i++ { + // e is sorted by domorder, so a maximal dominant element is first in the slice + v := e[i] + if v == nil { + continue + } + + e[i] = nil + // Replace all elements of e which v dominates + for j := i + 1; j < len(e); j++ { + w := e[j] + if w == nil { + continue + } + if sdom.IsAncestorEq(v.Block, w.Block) { + rewrite[w.ID] = v + e[j] = nil + } else { + // e is sorted by domorder, so v.Block doesn't dominate any subsequent blocks in e + break + } + } + } + } + + rewrites := int64(0) + + // Apply substitutions + for _, b := range f.Blocks { + for _, v := range b.Values { + for i, w := range v.Args { + if x := rewrite[w.ID]; x != nil { + if w.Pos.IsStmt() == src.PosIsStmt { + // about to lose a statement marker, w + // w is an input to v; if they're in the same block + // and the same line, v is a good-enough new statement boundary. + if w.Block == v.Block && w.Pos.Line() == v.Pos.Line() { + v.Pos = v.Pos.WithIsStmt() + w.Pos = w.Pos.WithNotStmt() + } // TODO and if this fails? + } + v.SetArg(i, x) + rewrites++ + } + } + } + for i, v := range b.ControlValues() { + if x := rewrite[v.ID]; x != nil { + if v.Op == OpNilCheck { + // nilcheck pass will remove the nil checks and log + // them appropriately, so don't mess with them here. + continue + } + b.ReplaceControl(i, x) + } + } + } + + if f.pass.stats > 0 { + f.LogStat("CSE REWRITES", rewrites) + } +} + +// storeOrdering computes the order for stores by iterate over the store +// chain, assigns a score to each store. The scores only make sense for +// stores within the same block, and the first store by store order has +// the lowest score. The cache was used to ensure only compute once. +func storeOrdering(v *Value, cache []int32) int32 { + const minScore int32 = 1 + score := minScore + w := v + for { + if s := cache[w.ID]; s >= minScore { + score += s + break + } + if w.Op == OpPhi || w.Op == OpInitMem { + break + } + a := w.MemoryArg() + if a.Block != w.Block { + break + } + w = a + score++ + } + w = v + for cache[w.ID] == 0 { + cache[w.ID] = score + if score == minScore { + break + } + w = w.MemoryArg() + score-- + } + return cache[v.ID] +} + +// An eqclass approximates an equivalence class. During the +// algorithm it may represent the union of several of the +// final equivalence classes. +type eqclass []*Value + +// partitionValues partitions the values into equivalence classes +// based on having all the following features match: +// - opcode +// - type +// - auxint +// - aux +// - nargs +// - block # if a phi op +// - first two arg's opcodes and auxint +// - NOT first two arg's aux; that can break CSE. +// +// partitionValues returns a list of equivalence classes, each +// being a sorted by ID list of *Values. The eqclass slices are +// backed by the same storage as the input slice. +// Equivalence classes of size 1 are ignored. +func partitionValues(a []*Value, auxIDs auxmap) []eqclass { + slices.SortFunc(a, func(v, w *Value) int { + switch cmpVal(v, w, auxIDs) { + case types.CMPlt: + return -1 + case types.CMPgt: + return +1 + default: + // Sort by value ID last to keep the sort result deterministic. + return cmp.Compare(v.ID, w.ID) + } + }) + + var partition []eqclass + for len(a) > 0 { + v := a[0] + j := 1 + for ; j < len(a); j++ { + w := a[j] + if cmpVal(v, w, auxIDs) != types.CMPeq { + break + } + } + if j > 1 { + partition = append(partition, a[:j]) + } + a = a[j:] + } + + return partition +} +func lt2Cmp(isLt bool) types.Cmp { + if isLt { + return types.CMPlt + } + return types.CMPgt +} + +type auxmap map[Aux]int32 + +func cmpVal(v, w *Value, auxIDs auxmap) types.Cmp { + // Try to order these comparison by cost (cheaper first) + if v.Op != w.Op { + return lt2Cmp(v.Op < w.Op) + } + if v.AuxInt != w.AuxInt { + return lt2Cmp(v.AuxInt < w.AuxInt) + } + if len(v.Args) != len(w.Args) { + return lt2Cmp(len(v.Args) < len(w.Args)) + } + if v.Op == OpPhi && v.Block != w.Block { + return lt2Cmp(v.Block.ID < w.Block.ID) + } + if v.Type.IsMemory() { + // We will never be able to CSE two values + // that generate memory. + return lt2Cmp(v.ID < w.ID) + } + // OpSelect is a pseudo-op. We need to be more aggressive + // regarding CSE to keep multiple OpSelect's of the same + // argument from existing. + if v.Op != OpSelect0 && v.Op != OpSelect1 && v.Op != OpSelectN { + if tc := v.Type.Compare(w.Type); tc != types.CMPeq { + return tc + } + } + + if v.Aux != w.Aux { + if v.Aux == nil { + return types.CMPlt + } + if w.Aux == nil { + return types.CMPgt + } + return lt2Cmp(auxIDs[v.Aux] < auxIDs[w.Aux]) + } + + return types.CMPeq +} diff --git a/go/src/cmd/compile/internal/ssa/cse_test.go b/go/src/cmd/compile/internal/ssa/cse_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7d3e44fbe06e4ca689e042ba0e8034ee1e40cc1c --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/cse_test.go @@ -0,0 +1,130 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "testing" +) + +type tstAux struct { + s string +} + +func (*tstAux) CanBeAnSSAAux() {} + +// This tests for a bug found when partitioning, but not sorting by the Aux value. +func TestCSEAuxPartitionBug(t *testing.T) { + c := testConfig(t) + arg1Aux := &tstAux{"arg1-aux"} + arg2Aux := &tstAux{"arg2-aux"} + arg3Aux := &tstAux{"arg3-aux"} + a := c.Temp(c.config.Types.Int8.PtrTo()) + + // construct lots of values with args that have aux values and place + // them in an order that triggers the bug + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil), + Valu("r7", OpAdd64, c.config.Types.Int64, 0, nil, "arg3", "arg1"), + Valu("r1", OpAdd64, c.config.Types.Int64, 0, nil, "arg1", "arg2"), + Valu("arg1", OpArg, c.config.Types.Int64, 0, arg1Aux), + Valu("arg2", OpArg, c.config.Types.Int64, 0, arg2Aux), + Valu("arg3", OpArg, c.config.Types.Int64, 0, arg3Aux), + Valu("r9", OpAdd64, c.config.Types.Int64, 0, nil, "r7", "r8"), + Valu("r4", OpAdd64, c.config.Types.Int64, 0, nil, "r1", "r2"), + Valu("r8", OpAdd64, c.config.Types.Int64, 0, nil, "arg3", "arg2"), + Valu("r2", OpAdd64, c.config.Types.Int64, 0, nil, "arg1", "arg2"), + Valu("raddr", OpLocalAddr, c.config.Types.Int64.PtrTo(), 0, nil, "sp", "start"), + Valu("raddrdef", OpVarDef, types.TypeMem, 0, a, "start"), + Valu("r6", OpAdd64, c.config.Types.Int64, 0, nil, "r4", "r5"), + Valu("r3", OpAdd64, c.config.Types.Int64, 0, nil, "arg1", "arg2"), + Valu("r5", OpAdd64, c.config.Types.Int64, 0, nil, "r2", "r3"), + Valu("r10", OpAdd64, c.config.Types.Int64, 0, nil, "r6", "r9"), + Valu("rstore", OpStore, types.TypeMem, 0, c.config.Types.Int64, "raddr", "r10", "raddrdef"), + Goto("exit")), + Bloc("exit", + Exit("rstore"))) + + CheckFunc(fun.f) + cse(fun.f) + deadcode(fun.f) + CheckFunc(fun.f) + + s1Cnt := 2 + // r1 == r2 == r3, needs to remove two of this set + s2Cnt := 1 + // r4 == r5, needs to remove one of these + for k, v := range fun.values { + if v.Op == OpInvalid { + switch k { + case "r1": + fallthrough + case "r2": + fallthrough + case "r3": + if s1Cnt == 0 { + t.Errorf("cse removed all of r1,r2,r3") + } + s1Cnt-- + + case "r4": + fallthrough + case "r5": + if s2Cnt == 0 { + t.Errorf("cse removed all of r4,r5") + } + s2Cnt-- + default: + t.Errorf("cse removed %s, but shouldn't have", k) + } + } + } + + if s1Cnt != 0 || s2Cnt != 0 { + t.Errorf("%d values missed during cse", s1Cnt+s2Cnt) + } +} + +// TestZCSE tests the zero arg cse. +func TestZCSE(t *testing.T) { + c := testConfig(t) + a := c.Temp(c.config.Types.Int8.PtrTo()) + + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil), + Valu("sb1", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("sb2", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("addr1", OpAddr, c.config.Types.Int64.PtrTo(), 0, nil, "sb1"), + Valu("addr2", OpAddr, c.config.Types.Int64.PtrTo(), 0, nil, "sb2"), + Valu("a1ld", OpLoad, c.config.Types.Int64, 0, nil, "addr1", "start"), + Valu("a2ld", OpLoad, c.config.Types.Int64, 0, nil, "addr2", "start"), + Valu("c1", OpConst64, c.config.Types.Int64, 1, nil), + Valu("r1", OpAdd64, c.config.Types.Int64, 0, nil, "a1ld", "c1"), + Valu("c2", OpConst64, c.config.Types.Int64, 1, nil), + Valu("r2", OpAdd64, c.config.Types.Int64, 0, nil, "a2ld", "c2"), + Valu("r3", OpAdd64, c.config.Types.Int64, 0, nil, "r1", "r2"), + Valu("raddr", OpLocalAddr, c.config.Types.Int64.PtrTo(), 0, nil, "sp", "start"), + Valu("raddrdef", OpVarDef, types.TypeMem, 0, a, "start"), + Valu("rstore", OpStore, types.TypeMem, 0, c.config.Types.Int64, "raddr", "r3", "raddrdef"), + Goto("exit")), + Bloc("exit", + Exit("rstore"))) + + CheckFunc(fun.f) + zcse(fun.f) + deadcode(fun.f) + CheckFunc(fun.f) + + if fun.values["c1"].Op != OpInvalid && fun.values["c2"].Op != OpInvalid { + t.Errorf("zsce should have removed c1 or c2") + } + if fun.values["sb1"].Op != OpInvalid && fun.values["sb2"].Op != OpInvalid { + t.Errorf("zsce should have removed sb1 or sb2") + } +} diff --git a/go/src/cmd/compile/internal/ssa/deadcode.go b/go/src/cmd/compile/internal/ssa/deadcode.go new file mode 100644 index 0000000000000000000000000000000000000000..aa85097c29d63e1e81e27f3bfdeb1efdf3f2e40c --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/deadcode.go @@ -0,0 +1,360 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/internal/src" +) + +// findlive returns the reachable blocks and live values in f. +// The caller should call f.Cache.freeBoolSlice(live) when it is done with it. +func findlive(f *Func) (reachable []bool, live []bool) { + reachable = ReachableBlocks(f) + var order []*Value + live, order = liveValues(f, reachable) + f.Cache.freeValueSlice(order) + return +} + +// ReachableBlocks returns the reachable blocks in f. +func ReachableBlocks(f *Func) []bool { + reachable := make([]bool, f.NumBlocks()) + reachable[f.Entry.ID] = true + p := make([]*Block, 0, 64) // stack-like worklist + p = append(p, f.Entry) + for len(p) > 0 { + // Pop a reachable block + b := p[len(p)-1] + p = p[:len(p)-1] + // Mark successors as reachable + s := b.Succs + if b.Kind == BlockFirst { + s = s[:1] + } + for _, e := range s { + c := e.b + if int(c.ID) >= len(reachable) { + f.Fatalf("block %s >= f.NumBlocks()=%d?", c, len(reachable)) + } + if !reachable[c.ID] { + reachable[c.ID] = true + p = append(p, c) // push + } + } + } + return reachable +} + +// liveValues returns the live values in f and a list of values that are eligible +// to be statements in reversed data flow order. +// The second result is used to help conserve statement boundaries for debugging. +// reachable is a map from block ID to whether the block is reachable. +// The caller should call f.Cache.freeBoolSlice(live) and f.Cache.freeValueSlice(liveOrderStmts). +// when they are done with the return values. +func liveValues(f *Func, reachable []bool) (live []bool, liveOrderStmts []*Value) { + live = f.Cache.allocBoolSlice(f.NumValues()) + liveOrderStmts = f.Cache.allocValueSlice(f.NumValues())[:0] + + // After regalloc, consider all values to be live. + // See the comment at the top of regalloc.go and in deadcode for details. + if f.RegAlloc != nil { + for i := range live { + live[i] = true + } + return + } + + // Record all the inline indexes we need + var liveInlIdx map[int]bool + pt := f.Config.ctxt.PosTable + for _, b := range f.Blocks { + for _, v := range b.Values { + i := pt.Pos(v.Pos).Base().InliningIndex() + if i < 0 { + continue + } + if liveInlIdx == nil { + liveInlIdx = map[int]bool{} + } + liveInlIdx[i] = true + } + i := pt.Pos(b.Pos).Base().InliningIndex() + if i < 0 { + continue + } + if liveInlIdx == nil { + liveInlIdx = map[int]bool{} + } + liveInlIdx[i] = true + } + + // Find all live values + q := f.Cache.allocValueSlice(f.NumValues())[:0] + defer f.Cache.freeValueSlice(q) + + // Starting set: all control values of reachable blocks are live. + // Calls are live (because callee can observe the memory state). + for _, b := range f.Blocks { + if !reachable[b.ID] { + continue + } + for _, v := range b.ControlValues() { + if !live[v.ID] { + live[v.ID] = true + q = append(q, v) + if v.Pos.IsStmt() != src.PosNotStmt { + liveOrderStmts = append(liveOrderStmts, v) + } + } + } + for _, v := range b.Values { + if (opcodeTable[v.Op].call || opcodeTable[v.Op].hasSideEffects || opcodeTable[v.Op].nilCheck) && !live[v.ID] { + live[v.ID] = true + q = append(q, v) + if v.Pos.IsStmt() != src.PosNotStmt { + liveOrderStmts = append(liveOrderStmts, v) + } + } + if v.Op == OpInlMark { + if !liveInlIdx[int(v.AuxInt)] { + // We don't need marks for bodies that + // have been completely optimized away. + // TODO: save marks only for bodies which + // have a faulting instruction or a call? + continue + } + live[v.ID] = true + q = append(q, v) + if v.Pos.IsStmt() != src.PosNotStmt { + liveOrderStmts = append(liveOrderStmts, v) + } + } + } + } + + // Compute transitive closure of live values. + for len(q) > 0 { + // pop a reachable value + v := q[len(q)-1] + q[len(q)-1] = nil + q = q[:len(q)-1] + for i, x := range v.Args { + if v.Op == OpPhi && !reachable[v.Block.Preds[i].b.ID] { + continue + } + if !live[x.ID] { + live[x.ID] = true + q = append(q, x) // push + if x.Pos.IsStmt() != src.PosNotStmt { + liveOrderStmts = append(liveOrderStmts, x) + } + } + } + } + + return +} + +// deadcode removes dead code from f. +func deadcode(f *Func) { + // deadcode after regalloc is forbidden for now. Regalloc + // doesn't quite generate legal SSA which will lead to some + // required moves being eliminated. See the comment at the + // top of regalloc.go for details. + if f.RegAlloc != nil { + f.Fatalf("deadcode after regalloc") + } + + // Find reachable blocks. + reachable := ReachableBlocks(f) + + // Get rid of edges from dead to live code. + for _, b := range f.Blocks { + if reachable[b.ID] { + continue + } + for i := 0; i < len(b.Succs); { + e := b.Succs[i] + if reachable[e.b.ID] { + b.removeEdge(i) + } else { + i++ + } + } + } + + // Get rid of dead edges from live code. + for _, b := range f.Blocks { + if !reachable[b.ID] { + continue + } + if b.Kind != BlockFirst { + continue + } + b.removeEdge(1) + b.Kind = BlockPlain + b.Likely = BranchUnknown + } + + // Splice out any copies introduced during dead block removal. + copyelim(f) + + // Find live values. + live, order := liveValues(f, reachable) + defer func() { f.Cache.freeBoolSlice(live) }() + defer func() { f.Cache.freeValueSlice(order) }() + + // Remove dead & duplicate entries from namedValues map. + s := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(s) + i := 0 + for _, name := range f.Names { + j := 0 + s.clear() + values := f.NamedValues[*name] + for _, v := range values { + if live[v.ID] && !s.contains(v.ID) { + values[j] = v + j++ + s.add(v.ID) + } + } + if j == 0 { + delete(f.NamedValues, *name) + } else { + f.Names[i] = name + i++ + for k := len(values) - 1; k >= j; k-- { + values[k] = nil + } + f.NamedValues[*name] = values[:j] + } + } + clear(f.Names[i:]) + f.Names = f.Names[:i] + + pendingLines := f.cachedLineStarts // Holds statement boundaries that need to be moved to a new value/block + pendingLines.clear() + + // Unlink values and conserve statement boundaries + for i, b := range f.Blocks { + if !reachable[b.ID] { + // TODO what if control is statement boundary? Too late here. + b.ResetControls() + } + for _, v := range b.Values { + if !live[v.ID] { + v.resetArgs() + if v.Pos.IsStmt() == src.PosIsStmt && reachable[b.ID] { + pendingLines.set(v.Pos, int32(i)) // TODO could be more than one pos for a line + } + } + } + } + + // Find new homes for lost lines -- require earliest in data flow with same line that is also in same block + for i := len(order) - 1; i >= 0; i-- { + w := order[i] + if j, ok := pendingLines.get(w.Pos); ok && f.Blocks[j] == w.Block { + w.Pos = w.Pos.WithIsStmt() + pendingLines.remove(w.Pos) + } + } + + // Any boundary that failed to match a live value can move to a block end + pendingLines.foreachEntry(func(j int32, l uint, bi int32) { + b := f.Blocks[bi] + if b.Pos.Line() == l && b.Pos.FileIndex() == j { + b.Pos = b.Pos.WithIsStmt() + } + }) + + // Remove dead values from blocks' value list. Return dead + // values to the allocator. + for _, b := range f.Blocks { + i := 0 + for _, v := range b.Values { + if live[v.ID] { + b.Values[i] = v + i++ + } else { + f.freeValue(v) + } + } + b.truncateValues(i) + } + + // Remove unreachable blocks. Return dead blocks to allocator. + i = 0 + for _, b := range f.Blocks { + if reachable[b.ID] { + f.Blocks[i] = b + i++ + } else { + if len(b.Values) > 0 { + b.Fatalf("live values in unreachable block %v: %v", b, b.Values) + } + f.freeBlock(b) + } + } + // zero remainder to help GC + clear(f.Blocks[i:]) + f.Blocks = f.Blocks[:i] +} + +// removeEdge removes the i'th outgoing edge from b (and +// the corresponding incoming edge from b.Succs[i].b). +// Note that this potentially reorders successors of b, so it +// must be used very carefully. +func (b *Block) removeEdge(i int) { + e := b.Succs[i] + c := e.b + j := e.i + + // Adjust b.Succs + b.removeSucc(i) + + // Adjust c.Preds + c.removePred(j) + + // Remove phi args from c's phis. + for _, v := range c.Values { + if v.Op != OpPhi { + continue + } + c.removePhiArg(v, j) + // Note: this is trickier than it looks. Replacing + // a Phi with a Copy can in general cause problems because + // Phi and Copy don't have exactly the same semantics. + // Phi arguments always come from a predecessor block, + // whereas copies don't. This matters in loops like: + // 1: x = (Phi y) + // y = (Add x 1) + // goto 1 + // If we replace Phi->Copy, we get + // 1: x = (Copy y) + // y = (Add x 1) + // goto 1 + // (Phi y) refers to the *previous* value of y, whereas + // (Copy y) refers to the *current* value of y. + // The modified code has a cycle and the scheduler + // will barf on it. + // + // Fortunately, this situation can only happen for dead + // code loops. We know the code we're working with is + // not dead, so we're ok. + // Proof: If we have a potential bad cycle, we have a + // situation like this: + // x = (Phi z) + // y = (op1 x ...) + // z = (op2 y ...) + // Where opX are not Phi ops. But such a situation + // implies a cycle in the dominator graph. In the + // example, x.Block dominates y.Block, y.Block dominates + // z.Block, and z.Block dominates x.Block (treating + // "dominates" as reflexive). Cycles in the dominator + // graph can only happen in an unreachable cycle. + } +} diff --git a/go/src/cmd/compile/internal/ssa/deadcode_test.go b/go/src/cmd/compile/internal/ssa/deadcode_test.go new file mode 100644 index 0000000000000000000000000000000000000000..5777b841ef58bbf4da30251465f8d2d4b9d712a0 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/deadcode_test.go @@ -0,0 +1,161 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "fmt" + "strconv" + "testing" +) + +func TestDeadLoop(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Goto("exit")), + Bloc("exit", + Exit("mem")), + // dead loop + Bloc("deadblock", + // dead value in dead block + Valu("deadval", OpConstBool, c.config.Types.Bool, 1, nil), + If("deadval", "deadblock", "exit"))) + + CheckFunc(fun.f) + Deadcode(fun.f) + CheckFunc(fun.f) + + for _, b := range fun.f.Blocks { + if b == fun.blocks["deadblock"] { + t.Errorf("dead block not removed") + } + for _, v := range b.Values { + if v == fun.values["deadval"] { + t.Errorf("control value of dead block not removed") + } + } + } +} + +func TestDeadValue(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("deadval", OpConst64, c.config.Types.Int64, 37, nil), + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + Deadcode(fun.f) + CheckFunc(fun.f) + + for _, b := range fun.f.Blocks { + for _, v := range b.Values { + if v == fun.values["deadval"] { + t.Errorf("dead value not removed") + } + } + } +} + +func TestNeverTaken(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("cond", OpConstBool, c.config.Types.Bool, 0, nil), + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + If("cond", "then", "else")), + Bloc("then", + Goto("exit")), + Bloc("else", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + Opt(fun.f) + Deadcode(fun.f) + CheckFunc(fun.f) + + if fun.blocks["entry"].Kind != BlockPlain { + t.Errorf("if(false) not simplified") + } + for _, b := range fun.f.Blocks { + if b == fun.blocks["then"] { + t.Errorf("then block still present") + } + for _, v := range b.Values { + if v == fun.values["cond"] { + t.Errorf("constant condition still present") + } + } + } + +} + +func TestNestedDeadBlocks(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("cond", OpConstBool, c.config.Types.Bool, 0, nil), + If("cond", "b2", "b4")), + Bloc("b2", + If("cond", "b3", "b4")), + Bloc("b3", + If("cond", "b3", "b4")), + Bloc("b4", + If("cond", "b3", "exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + Opt(fun.f) + CheckFunc(fun.f) + Deadcode(fun.f) + CheckFunc(fun.f) + if fun.blocks["entry"].Kind != BlockPlain { + t.Errorf("if(false) not simplified") + } + for _, b := range fun.f.Blocks { + if b == fun.blocks["b2"] { + t.Errorf("b2 block still present") + } + if b == fun.blocks["b3"] { + t.Errorf("b3 block still present") + } + for _, v := range b.Values { + if v == fun.values["cond"] { + t.Errorf("constant condition still present") + } + } + } +} + +func BenchmarkDeadCode(b *testing.B) { + for _, n := range [...]int{1, 10, 100, 1000, 10000, 100000, 200000} { + b.Run(strconv.Itoa(n), func(b *testing.B) { + c := testConfig(b) + blocks := make([]bloc, 0, n+2) + blocks = append(blocks, + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Goto("exit"))) + blocks = append(blocks, Bloc("exit", Exit("mem"))) + for i := 0; i < n; i++ { + blocks = append(blocks, Bloc(fmt.Sprintf("dead%d", i), Goto("exit"))) + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + fun := c.Fun("entry", blocks...) + Deadcode(fun.f) + } + }) + } +} diff --git a/go/src/cmd/compile/internal/ssa/deadstore.go b/go/src/cmd/compile/internal/ssa/deadstore.go new file mode 100644 index 0000000000000000000000000000000000000000..17a0809cb70e9869d81f75fa4f5d225547c774ee --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/deadstore.go @@ -0,0 +1,484 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/obj" +) + +// maxShadowRanges bounds the number of disjoint byte intervals +// we track per pointer to avoid quadratic behaviour. +const maxShadowRanges = 64 + +// dse does dead-store elimination on the Function. +// Dead stores are those which are unconditionally followed by +// another store to the same location, with no intervening load. +// This implementation only works within a basic block. TODO: use something more global. +func dse(f *Func) { + var stores []*Value + loadUse := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(loadUse) + storeUse := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(storeUse) + shadowed := f.newSparseMap(f.NumValues()) + defer f.retSparseMap(shadowed) + // localAddrs maps from a local variable (the Aux field of a LocalAddr value) to an instance of a LocalAddr value for that variable in the current block. + localAddrs := map[any]*Value{} + + // shadowedRanges stores the actual range data. The 'shadowed' sparseMap stores a 1-based index into this slice. + var shadowedRanges []*shadowRanges + + for _, b := range f.Blocks { + // Find all the stores in this block. Categorize their uses: + // loadUse contains stores which are used by a subsequent load. + // storeUse contains stores which are used by a subsequent store. + loadUse.clear() + storeUse.clear() + clear(localAddrs) + stores = stores[:0] + for _, v := range b.Values { + if v.Op == OpPhi { + // Ignore phis - they will always be first and can't be eliminated + continue + } + if v.Type.IsMemory() { + stores = append(stores, v) + for _, a := range v.Args { + if a.Block == b && a.Type.IsMemory() { + storeUse.add(a.ID) + if v.Op != OpStore && v.Op != OpZero && v.Op != OpVarDef { + // CALL, DUFFCOPY, etc. are both + // reads and writes. + loadUse.add(a.ID) + } + } + } + } else { + if v.Op == OpLocalAddr { + if _, ok := localAddrs[v.Aux]; !ok { + localAddrs[v.Aux] = v + } + continue + } + if v.Op == OpInlMark || v.Op == OpConvert { + // Not really a use of the memory. See #67957. + continue + } + for _, a := range v.Args { + if a.Block == b && a.Type.IsMemory() { + loadUse.add(a.ID) + } + } + } + } + if len(stores) == 0 { + continue + } + + // find last store in the block + var last *Value + for _, v := range stores { + if storeUse.contains(v.ID) { + continue + } + if last != nil { + b.Fatalf("two final stores - simultaneous live stores %s %s", last.LongString(), v.LongString()) + } + last = v + } + if last == nil { + b.Fatalf("no last store found - cycle?") + } + + // Walk backwards looking for dead stores. Keep track of shadowed addresses. + // A "shadowed address" is a pointer, offset, and size describing a memory region that + // is known to be written. We keep track of shadowed addresses in the shadowed map, + // mapping the ID of the address to a shadowRanges where future writes will happen. + // Since we're walking backwards, writes to a shadowed region are useless, + // as they will be immediately overwritten. + shadowed.clear() + shadowedRanges = shadowedRanges[:0] + v := last + + walkloop: + if loadUse.contains(v.ID) { + // Someone might be reading this memory state. + // Clear all shadowed addresses. + shadowed.clear() + shadowedRanges = shadowedRanges[:0] + } + if v.Op == OpStore || v.Op == OpZero { + ptr := v.Args[0] + var off int64 + for ptr.Op == OpOffPtr { // Walk to base pointer + off += ptr.AuxInt + ptr = ptr.Args[0] + } + var sz int64 + if v.Op == OpStore { + sz = v.Aux.(*types.Type).Size() + } else { // OpZero + sz = v.AuxInt + } + if ptr.Op == OpLocalAddr { + if la, ok := localAddrs[ptr.Aux]; ok { + ptr = la + } + } + var si *shadowRanges + idx, ok := shadowed.get(ptr.ID) + if ok { + // The sparseMap stores a 1-based index, so we subtract 1. + si = shadowedRanges[idx-1] + } + + if si != nil && si.contains(off, off+sz) { + // Modify the store/zero into a copy of the memory state, + // effectively eliding the store operation. + if v.Op == OpStore { + // store addr value mem + v.SetArgs1(v.Args[2]) + } else { + // zero addr mem + v.SetArgs1(v.Args[1]) + } + v.Aux = nil + v.AuxInt = 0 + v.Op = OpCopy + } else { + // Extend shadowed region. + if si == nil { + si = &shadowRanges{} + shadowedRanges = append(shadowedRanges, si) + // Store a 1-based index in the sparseMap. + shadowed.set(ptr.ID, int32(len(shadowedRanges))) + } + si.add(off, off+sz) + } + } + // walk to previous store + if v.Op == OpPhi { + // At start of block. Move on to next block. + // The memory phi, if it exists, is always + // the first logical store in the block. + // (Even if it isn't the first in the current b.Values order.) + continue + } + for _, a := range v.Args { + if a.Block == b && a.Type.IsMemory() { + v = a + goto walkloop + } + } + } +} + +// shadowRange represents a single byte range [lo,hi] that will be written. +type shadowRange struct { + lo, hi uint16 +} + +// shadowRanges stores an unordered collection of disjoint byte ranges. +type shadowRanges struct { + ranges []shadowRange +} + +// contains reports whether [lo:hi] is completely within sr. +func (sr *shadowRanges) contains(lo, hi int64) bool { + for _, r := range sr.ranges { + if lo >= int64(r.lo) && hi <= int64(r.hi) { + return true + } + } + return false +} + +func (sr *shadowRanges) add(lo, hi int64) { + // Ignore the store if: + // - the range doesn't fit in 16 bits, or + // - we already track maxShadowRanges intervals. + // The cap prevents a theoretical O(n^2) blow-up. + if lo < 0 || hi > 0xffff || len(sr.ranges) >= maxShadowRanges { + return + } + nlo := lo + nhi := hi + out := sr.ranges[:0] + + for _, r := range sr.ranges { + if nhi < int64(r.lo) || nlo > int64(r.hi) { + out = append(out, r) + continue + } + if int64(r.lo) < nlo { + nlo = int64(r.lo) + } + if int64(r.hi) > nhi { + nhi = int64(r.hi) + } + } + sr.ranges = append(out, shadowRange{uint16(nlo), uint16(nhi)}) +} + +// elimDeadAutosGeneric deletes autos that are never accessed. To achieve this +// we track the operations that the address of each auto reaches and if it only +// reaches stores then we delete all the stores. The other operations will then +// be eliminated by the dead code elimination pass. +func elimDeadAutosGeneric(f *Func) { + addr := make(map[*Value]*ir.Name) // values that the address of the auto reaches + elim := make(map[*Value]*ir.Name) // values that could be eliminated if the auto is + move := make(map[*ir.Name]ir.NameSet) // for a (Move &y &x _) and y is unused, move[y].Add(x) + var used ir.NameSet // used autos that must be kept + + // Adds a name to used and, when it is the target of a move, also + // propagates the used state to its source. + var usedAdd func(n *ir.Name) bool + usedAdd = func(n *ir.Name) bool { + if used.Has(n) { + return false + } + used.Add(n) + if s := move[n]; s != nil { + delete(move, n) + for n := range s { + usedAdd(n) + } + } + return true + } + + // visit the value and report whether any of the maps are updated + visit := func(v *Value) (changed bool) { + args := v.Args + switch v.Op { + case OpAddr, OpLocalAddr: + // Propagate the address if it points to an auto. + n, ok := v.Aux.(*ir.Name) + if !ok || (n.Class != ir.PAUTO && !isABIInternalParam(f, n)) { + return + } + if addr[v] == nil { + addr[v] = n + changed = true + } + return + case OpVarDef: + // v should be eliminated if we eliminate the auto. + n, ok := v.Aux.(*ir.Name) + if !ok || (n.Class != ir.PAUTO && !isABIInternalParam(f, n)) { + return + } + if elim[v] == nil { + elim[v] = n + changed = true + } + return + case OpVarLive: + // Don't delete the auto if it needs to be kept alive. + + // We depend on this check to keep the autotmp stack slots + // for open-coded defers from being removed (since they + // may not be used by the inline code, but will be used by + // panic processing). + n, ok := v.Aux.(*ir.Name) + if !ok || (n.Class != ir.PAUTO && !isABIInternalParam(f, n)) { + return + } + changed = usedAdd(n) || changed + return + case OpStore, OpMove, OpZero: + // v should be eliminated if we eliminate the auto. + n, ok := addr[args[0]] + if ok && elim[v] == nil { + elim[v] = n + changed = true + } + // Other args might hold pointers to autos. + args = args[1:] + } + + // The code below assumes that we have handled all the ops + // with sym effects already. Sanity check that here. + // Ignore Args since they can't be autos. + if v.Op.SymEffect() != SymNone && v.Op != OpArg { + panic("unhandled op with sym effect") + } + + if v.Uses == 0 && v.Op != OpNilCheck && !v.Op.IsCall() && !v.Op.HasSideEffects() || len(args) == 0 { + // We need to keep nil checks even if they have no use. + // Also keep calls and values that have side effects. + return + } + + // If the address of the auto reaches a memory or control + // operation not covered above then we probably need to keep it. + // We also need to keep autos if they reach Phis (issue #26153). + if v.Type.IsMemory() || v.Type.IsFlags() || v.Op == OpPhi || v.MemoryArg() != nil { + for _, a := range args { + if n, ok := addr[a]; ok { + // If the addr of n is used by an OpMove as its source arg, + // and the OpMove's target arg is the addr of a unused name, + // then temporarily treat n as unused, and record in move map. + if nam, ok := elim[v]; ok && v.Op == OpMove && !used.Has(nam) { + if used.Has(n) { + continue + } + s := move[nam] + if s == nil { + s = ir.NameSet{} + move[nam] = s + } + s.Add(n) + continue + } + changed = usedAdd(n) || changed + } + } + return + } + + // Propagate any auto addresses through v. + var node *ir.Name + for _, a := range args { + if n, ok := addr[a]; ok { + if node == nil { + if !used.Has(n) { + node = n + } + } else { + if node == n { + continue + } + // Most of the time we only see one pointer + // reaching an op, but some ops can take + // multiple pointers (e.g. NeqPtr, Phi etc.). + // This is rare, so just propagate the first + // value to keep things simple. + changed = usedAdd(n) || changed + } + } + } + if node == nil { + return + } + if addr[v] == nil { + // The address of an auto reaches this op. + addr[v] = node + changed = true + return + } + if addr[v] != node { + // This doesn't happen in practice, but catch it just in case. + changed = usedAdd(node) || changed + } + return + } + + iterations := 0 + for { + if iterations == 4 { + // give up + return + } + iterations++ + changed := false + for _, b := range f.Blocks { + for _, v := range b.Values { + changed = visit(v) || changed + } + // keep the auto if its address reaches a control value + for _, c := range b.ControlValues() { + if n, ok := addr[c]; ok { + changed = usedAdd(n) || changed + } + } + } + if !changed { + break + } + } + + // Eliminate stores to unread autos. + for v, n := range elim { + if used.Has(n) { + continue + } + // replace with OpCopy + v.SetArgs1(v.MemoryArg()) + v.Aux = nil + v.AuxInt = 0 + v.Op = OpCopy + } +} + +// elimUnreadAutos deletes stores (and associated bookkeeping ops VarDef and VarKill) +// to autos that are never read from. +func elimUnreadAutos(f *Func) { + // Loop over all ops that affect autos taking note of which + // autos we need and also stores that we might be able to + // eliminate. + var seen ir.NameSet + var stores []*Value + for _, b := range f.Blocks { + for _, v := range b.Values { + n, ok := v.Aux.(*ir.Name) + if !ok { + continue + } + if n.Class != ir.PAUTO && !isABIInternalParam(f, n) { + continue + } + + effect := v.Op.SymEffect() + switch effect { + case SymNone, SymWrite: + // If we haven't seen the auto yet + // then this might be a store we can + // eliminate. + if !seen.Has(n) { + stores = append(stores, v) + } + default: + // Assume the auto is needed (loaded, + // has its address taken, etc.). + // Note we have to check the uses + // because dead loads haven't been + // eliminated yet. + if v.Uses > 0 { + seen.Add(n) + } + } + } + } + + // Eliminate stores to unread autos. + for _, store := range stores { + n, _ := store.Aux.(*ir.Name) + if seen.Has(n) { + continue + } + + // replace store with OpCopy + store.SetArgs1(store.MemoryArg()) + store.Aux = nil + store.AuxInt = 0 + store.Op = OpCopy + } +} + +// isABIInternalParam returns whether n is a parameter of an ABIInternal +// function. For dead store elimination, we can treat parameters the same +// way as autos. Storing to a parameter can be removed if it is not read +// or address-taken. +// +// We check ABI here because for a cgo_unsafe_arg function (which is ABI0), +// all the args are effectively address-taken, but not necessarily have +// an Addr or LocalAddr op. We could probably just check for cgo_unsafe_arg, +// but ABIInternal is mostly what matters. +func isABIInternalParam(f *Func, n *ir.Name) bool { + return n.Class == ir.PPARAM && f.ABISelf.Which() == obj.ABIInternal +} diff --git a/go/src/cmd/compile/internal/ssa/deadstore_test.go b/go/src/cmd/compile/internal/ssa/deadstore_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7c7a4dacf01c568f27dd72a8cb85a1d29a64ab77 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/deadstore_test.go @@ -0,0 +1,508 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "cmd/internal/src" + "fmt" + "sort" + "testing" +) + +func TestDeadStore(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + t.Logf("PTRTYPE %v", ptrType) + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("v", OpConstBool, c.config.Types.Bool, 1, nil), + Valu("addr1", OpAddr, ptrType, 0, nil, "sb"), + Valu("addr2", OpAddr, ptrType, 0, nil, "sb"), + Valu("addr3", OpAddr, ptrType, 0, nil, "sb"), + Valu("zero1", OpZero, types.TypeMem, 1, c.config.Types.Bool, "addr3", "start"), + Valu("store1", OpStore, types.TypeMem, 0, c.config.Types.Bool, "addr1", "v", "zero1"), + Valu("store2", OpStore, types.TypeMem, 0, c.config.Types.Bool, "addr2", "v", "store1"), + Valu("store3", OpStore, types.TypeMem, 0, c.config.Types.Bool, "addr1", "v", "store2"), + Valu("store4", OpStore, types.TypeMem, 0, c.config.Types.Bool, "addr3", "v", "store3"), + Goto("exit")), + Bloc("exit", + Exit("store3"))) + + CheckFunc(fun.f) + dse(fun.f) + CheckFunc(fun.f) + + v1 := fun.values["store1"] + if v1.Op != OpCopy { + t.Errorf("dead store not removed") + } + + v2 := fun.values["zero1"] + if v2.Op != OpCopy { + t.Errorf("dead store (zero) not removed") + } +} + +func TestDeadStorePhi(t *testing.T) { + // make sure we don't get into an infinite loop with phi values. + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("v", OpConstBool, c.config.Types.Bool, 1, nil), + Valu("addr", OpAddr, ptrType, 0, nil, "sb"), + Goto("loop")), + Bloc("loop", + Valu("phi", OpPhi, types.TypeMem, 0, nil, "start", "store"), + Valu("store", OpStore, types.TypeMem, 0, c.config.Types.Bool, "addr", "v", "phi"), + If("v", "loop", "exit")), + Bloc("exit", + Exit("store"))) + + CheckFunc(fun.f) + dse(fun.f) + CheckFunc(fun.f) +} + +func TestDeadStoreTypes(t *testing.T) { + // Make sure a narrow store can't shadow a wider one. We test an even + // stronger restriction, that one store can't shadow another unless the + // types of the address fields are identical (where identicalness is + // decided by the CSE pass). + c := testConfig(t) + t1 := c.config.Types.UInt64.PtrTo() + t2 := c.config.Types.UInt32.PtrTo() + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("v", OpConstBool, c.config.Types.Bool, 1, nil), + Valu("addr1", OpAddr, t1, 0, nil, "sb"), + Valu("addr2", OpAddr, t2, 0, nil, "sb"), + Valu("store1", OpStore, types.TypeMem, 0, c.config.Types.Bool, "addr1", "v", "start"), + Valu("store2", OpStore, types.TypeMem, 0, c.config.Types.Bool, "addr2", "v", "store1"), + Goto("exit")), + Bloc("exit", + Exit("store2"))) + + CheckFunc(fun.f) + cse(fun.f) + dse(fun.f) + CheckFunc(fun.f) + + v := fun.values["store1"] + if v.Op == OpCopy { + t.Errorf("store %s incorrectly removed", v) + } +} + +func TestDeadStoreUnsafe(t *testing.T) { + // Make sure a narrow store can't shadow a wider one. The test above + // covers the case of two different types, but unsafe pointer casting + // can get to a point where the size is changed but type unchanged. + c := testConfig(t) + ptrType := c.config.Types.UInt64.PtrTo() + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("v", OpConstBool, c.config.Types.Bool, 1, nil), + Valu("addr1", OpAddr, ptrType, 0, nil, "sb"), + Valu("store1", OpStore, types.TypeMem, 0, c.config.Types.Int64, "addr1", "v", "start"), // store 8 bytes + Valu("store2", OpStore, types.TypeMem, 0, c.config.Types.Bool, "addr1", "v", "store1"), // store 1 byte + Goto("exit")), + Bloc("exit", + Exit("store2"))) + + CheckFunc(fun.f) + cse(fun.f) + dse(fun.f) + CheckFunc(fun.f) + + v := fun.values["store1"] + if v.Op == OpCopy { + t.Errorf("store %s incorrectly removed", v) + } +} + +func TestDeadStoreSmallStructInit(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + typ := types.NewStruct([]*types.Field{ + types.NewField(src.NoXPos, &types.Sym{Name: "A"}, c.config.Types.Int), + types.NewField(src.NoXPos, &types.Sym{Name: "B"}, c.config.Types.Int), + }) + name := c.Temp(typ) + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil), + Valu("zero", OpConst64, c.config.Types.Int, 0, nil), + Valu("v6", OpLocalAddr, ptrType, 0, name, "sp", "start"), + Valu("v3", OpOffPtr, ptrType, 8, nil, "v6"), + Valu("v22", OpOffPtr, ptrType, 0, nil, "v6"), + Valu("zerostore1", OpStore, types.TypeMem, 0, c.config.Types.Int, "v22", "zero", "start"), + Valu("zerostore2", OpStore, types.TypeMem, 0, c.config.Types.Int, "v3", "zero", "zerostore1"), + Valu("v8", OpLocalAddr, ptrType, 0, name, "sp", "zerostore2"), + Valu("v23", OpOffPtr, ptrType, 8, nil, "v8"), + Valu("v25", OpOffPtr, ptrType, 0, nil, "v8"), + Valu("zerostore3", OpStore, types.TypeMem, 0, c.config.Types.Int, "v25", "zero", "zerostore2"), + Valu("zerostore4", OpStore, types.TypeMem, 0, c.config.Types.Int, "v23", "zero", "zerostore3"), + Goto("exit")), + Bloc("exit", + Exit("zerostore4"))) + + fun.f.Name = "smallstructinit" + CheckFunc(fun.f) + cse(fun.f) + dse(fun.f) + CheckFunc(fun.f) + + v1 := fun.values["zerostore1"] + if v1.Op != OpCopy { + t.Errorf("dead store not removed") + } + v2 := fun.values["zerostore2"] + if v2.Op != OpCopy { + t.Errorf("dead store not removed") + } +} + +func TestDeadStoreArrayGap(t *testing.T) { + c := testConfig(t) + ptr := c.config.Types.BytePtr + i64 := c.config.Types.Int64 + + typ := types.NewArray(i64, 5) + tmp := c.Temp(typ) + + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil), + + Valu("base", OpLocalAddr, ptr, 0, tmp, "sp", "start"), + + Valu("p0", OpOffPtr, ptr, 0, nil, "base"), + Valu("p1", OpOffPtr, ptr, 8, nil, "base"), + Valu("p2", OpOffPtr, ptr, 16, nil, "base"), + Valu("p3", OpOffPtr, ptr, 24, nil, "base"), + Valu("p4", OpOffPtr, ptr, 32, nil, "base"), + + Valu("one", OpConst64, i64, 1, nil), + Valu("seven", OpConst64, i64, 7, nil), + Valu("zero", OpConst64, i64, 0, nil), + + Valu("mem0", OpZero, types.TypeMem, 40, typ, "base", "start"), + + Valu("s0", OpStore, types.TypeMem, 0, i64, "p0", "one", "mem0"), + Valu("s1", OpStore, types.TypeMem, 0, i64, "p1", "seven", "s0"), + Valu("s2", OpStore, types.TypeMem, 0, i64, "p3", "one", "s1"), + Valu("s3", OpStore, types.TypeMem, 0, i64, "p4", "one", "s2"), + Valu("s4", OpStore, types.TypeMem, 0, i64, "p2", "zero", "s3"), + + Goto("exit")), + Bloc("exit", + Exit("s4"))) + + CheckFunc(fun.f) + dse(fun.f) + CheckFunc(fun.f) + + if op := fun.values["mem0"].Op; op != OpCopy { + t.Fatalf("dead Zero not removed: got %s, want OpCopy", op) + } +} + +func TestShadowRanges(t *testing.T) { + t.Run("simple insert & contains", func(t *testing.T) { + var sr shadowRanges + sr.add(10, 20) + + wantRanges(t, sr.ranges, [][2]uint16{{10, 20}}) + if !sr.contains(12, 18) || !sr.contains(10, 20) { + t.Fatalf("contains failed after simple add") + } + if sr.contains(9, 11) || sr.contains(11, 21) { + t.Fatalf("contains erroneously true for non-contained range") + } + }) + + t.Run("merge overlapping", func(t *testing.T) { + var sr shadowRanges + sr.add(10, 20) + sr.add(15, 25) + + wantRanges(t, sr.ranges, [][2]uint16{{10, 25}}) + if !sr.contains(13, 24) { + t.Fatalf("contains should be true after merge") + } + }) + + t.Run("merge touching boundary", func(t *testing.T) { + var sr shadowRanges + sr.add(100, 150) + // touches at 150 - should coalesce + sr.add(150, 180) + + wantRanges(t, sr.ranges, [][2]uint16{{100, 180}}) + }) + + t.Run("union across several ranges", func(t *testing.T) { + var sr shadowRanges + sr.add(10, 20) + sr.add(30, 40) + // bridges second, not first + sr.add(25, 35) + + wantRanges(t, sr.ranges, [][2]uint16{{10, 20}, {25, 40}}) + + // envelops everything + sr.add(5, 50) + wantRanges(t, sr.ranges, [][2]uint16{{5, 50}}) + }) + + t.Run("disjoint intervals stay separate", func(t *testing.T) { + var sr shadowRanges + sr.add(10, 20) + sr.add(22, 30) + + wantRanges(t, sr.ranges, [][2]uint16{{10, 20}, {22, 30}}) + // spans both + if sr.contains(15, 25) { + t.Fatalf("contains across two disjoint ranges should be false") + } + }) + + t.Run("large uint16 offsets still work", func(t *testing.T) { + var sr shadowRanges + sr.add(40000, 45000) + + if !sr.contains(42000, 43000) { + t.Fatalf("contains failed for large uint16 values") + } + }) + + t.Run("out-of-bounds inserts ignored", func(t *testing.T) { + var sr shadowRanges + sr.add(10, 20) + sr.add(-5, 5) + sr.add(70000, 70010) + + wantRanges(t, sr.ranges, [][2]uint16{{10, 20}}) + }) +} + +// canonicalise order for comparisons +func sortRanges(r []shadowRange) { + sort.Slice(r, func(i, j int) bool { return r[i].lo < r[j].lo }) +} + +// compare actual slice with expected pairs +func wantRanges(t *testing.T, got []shadowRange, want [][2]uint16) { + t.Helper() + sortRanges(got) + + if len(got) != len(want) { + t.Fatalf("len(ranges)=%d, want %d (got=%v)", len(got), len(want), got) + } + + for i, w := range want { + if got[i].lo != w[0] || got[i].hi != w[1] { + t.Fatalf("range %d = [%d,%d], want [%d,%d] (full=%v)", + i, got[i].lo, got[i].hi, w[0], w[1], got) + } + } +} + +func BenchmarkDeadStore(b *testing.B) { + cfg := testConfig(b) + ptr := cfg.config.Types.BytePtr + + f := cfg.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, cfg.config.Types.Uintptr, 0, nil), + Valu("v", OpConstBool, cfg.config.Types.Bool, 1, nil), + Valu("a1", OpAddr, ptr, 0, nil, "sb"), + Valu("a2", OpAddr, ptr, 0, nil, "sb"), + Valu("a3", OpAddr, ptr, 0, nil, "sb"), + Valu("z1", OpZero, types.TypeMem, 1, cfg.config.Types.Bool, "a3", "start"), + Valu("s1", OpStore, types.TypeMem, 0, cfg.config.Types.Bool, "a1", "v", "z1"), + Valu("s2", OpStore, types.TypeMem, 0, cfg.config.Types.Bool, "a2", "v", "s1"), + Valu("s3", OpStore, types.TypeMem, 0, cfg.config.Types.Bool, "a1", "v", "s2"), + Valu("s4", OpStore, types.TypeMem, 0, cfg.config.Types.Bool, "a3", "v", "s3"), + Goto("exit")), + Bloc("exit", + Exit("s3"))) + + runBench(b, func() { + dse(f.f) + }) +} + +func BenchmarkDeadStorePhi(b *testing.B) { + cfg := testConfig(b) + ptr := cfg.config.Types.BytePtr + + f := cfg.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, cfg.config.Types.Uintptr, 0, nil), + Valu("v", OpConstBool, cfg.config.Types.Bool, 1, nil), + Valu("addr", OpAddr, ptr, 0, nil, "sb"), + Goto("loop")), + Bloc("loop", + Valu("phi", OpPhi, types.TypeMem, 0, nil, "start", "store"), + Valu("store", OpStore, types.TypeMem, 0, cfg.config.Types.Bool, "addr", "v", "phi"), + If("v", "loop", "exit")), + Bloc("exit", + Exit("store"))) + + runBench(b, func() { + dse(f.f) + }) +} + +func BenchmarkDeadStoreTypes(b *testing.B) { + cfg := testConfig(b) + + t1 := cfg.config.Types.UInt64.PtrTo() + t2 := cfg.config.Types.UInt32.PtrTo() + + f := cfg.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, cfg.config.Types.Uintptr, 0, nil), + Valu("v", OpConstBool, cfg.config.Types.Bool, 1, nil), + Valu("a1", OpAddr, t1, 0, nil, "sb"), + Valu("a2", OpAddr, t2, 0, nil, "sb"), + Valu("s1", OpStore, types.TypeMem, 0, cfg.config.Types.Bool, "a1", "v", "start"), + Valu("s2", OpStore, types.TypeMem, 0, cfg.config.Types.Bool, "a2", "v", "s1"), + Goto("exit")), + Bloc("exit", + Exit("s2"))) + cse(f.f) + + runBench(b, func() { + dse(f.f) + }) +} + +func BenchmarkDeadStoreUnsafe(b *testing.B) { + cfg := testConfig(b) + ptr := cfg.config.Types.UInt64.PtrTo() + f := cfg.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, cfg.config.Types.Uintptr, 0, nil), + Valu("v", OpConstBool, cfg.config.Types.Bool, 1, nil), + Valu("a1", OpAddr, ptr, 0, nil, "sb"), + Valu("s1", OpStore, types.TypeMem, 0, cfg.config.Types.Int64, "a1", "v", "start"), + Valu("s2", OpStore, types.TypeMem, 0, cfg.config.Types.Bool, "a1", "v", "s1"), + Goto("exit")), + Bloc("exit", + Exit("s2"))) + cse(f.f) + runBench(b, func() { + dse(f.f) + }) +} + +func BenchmarkDeadStoreSmallStructInit(b *testing.B) { + cfg := testConfig(b) + ptr := cfg.config.Types.BytePtr + + typ := types.NewStruct([]*types.Field{ + types.NewField(src.NoXPos, &types.Sym{Name: "A"}, cfg.config.Types.Int), + types.NewField(src.NoXPos, &types.Sym{Name: "B"}, cfg.config.Types.Int), + }) + tmp := cfg.Temp(typ) + + f := cfg.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sp", OpSP, cfg.config.Types.Uintptr, 0, nil), + Valu("zero", OpConst64, cfg.config.Types.Int, 0, nil), + + Valu("v6", OpLocalAddr, ptr, 0, tmp, "sp", "start"), + Valu("v3", OpOffPtr, ptr, 8, nil, "v6"), + Valu("v22", OpOffPtr, ptr, 0, nil, "v6"), + Valu("s1", OpStore, types.TypeMem, 0, cfg.config.Types.Int, "v22", "zero", "start"), + Valu("s2", OpStore, types.TypeMem, 0, cfg.config.Types.Int, "v3", "zero", "s1"), + + Valu("v8", OpLocalAddr, ptr, 0, tmp, "sp", "s2"), + Valu("v23", OpOffPtr, ptr, 8, nil, "v8"), + Valu("v25", OpOffPtr, ptr, 0, nil, "v8"), + Valu("s3", OpStore, types.TypeMem, 0, cfg.config.Types.Int, "v25", "zero", "s2"), + Valu("s4", OpStore, types.TypeMem, 0, cfg.config.Types.Int, "v23", "zero", "s3"), + Goto("exit")), + Bloc("exit", + Exit("s4"))) + cse(f.f) + + runBench(b, func() { + dse(f.f) + }) +} + +func BenchmarkDeadStoreLargeBlock(b *testing.B) { + // create a very large block with many shadowed stores + const ( + addrCount = 128 + // first 7 are dead + storesPerAddr = 8 + ) + cfg := testConfig(b) + ptrType := cfg.config.Types.BytePtr + boolType := cfg.config.Types.Bool + + items := []interface{}{ + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, cfg.config.Types.Uintptr, 0, nil), + Valu("v", OpConstBool, boolType, 1, nil), + } + + for i := 0; i < addrCount; i++ { + items = append(items, + Valu(fmt.Sprintf("addr%d", i), OpAddr, ptrType, 0, nil, "sb"), + ) + } + + prev := "start" + for round := 0; round < storesPerAddr; round++ { + for i := 0; i < addrCount; i++ { + store := fmt.Sprintf("s_%03d_%d", i, round) + addr := fmt.Sprintf("addr%d", i) + items = append(items, + Valu(store, OpStore, types.TypeMem, 0, boolType, addr, "v", prev), + ) + prev = store + } + } + + items = append(items, Goto("exit")) + entryBlk := Bloc("entry", items...) + exitBlk := Bloc("exit", Exit(prev)) + + f := cfg.Fun("stress", entryBlk, exitBlk) + + runBench(b, func() { + dse(f.f) + }) +} + +func runBench(b *testing.B, build func()) { + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + build() + } +} diff --git a/go/src/cmd/compile/internal/ssa/debug.go b/go/src/cmd/compile/internal/ssa/debug.go new file mode 100644 index 0000000000000000000000000000000000000000..687abc42cc66cca92a9331f90c3bd33c3105defe --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/debug.go @@ -0,0 +1,2001 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/abi" + "cmd/compile/internal/abt" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/dwarf" + "cmd/internal/obj" + "cmd/internal/src" + "cmp" + "encoding/hex" + "fmt" + "internal/buildcfg" + "math/bits" + "slices" + "strings" +) + +type SlotID int32 +type VarID int32 + +// A FuncDebug contains all the debug information for the variables in a +// function. Variables are identified by their LocalSlot, which may be +// the result of decomposing a larger variable. +type FuncDebug struct { + // Slots is all the slots used in the debug info, indexed by their SlotID. + Slots []LocalSlot + // The user variables, indexed by VarID. + Vars []*ir.Name + // The slots that make up each variable, indexed by VarID. + VarSlots [][]SlotID + // The location list data, indexed by VarID. Must be processed by PutLocationList. + LocationLists [][]byte + // Register-resident output parameters for the function. This is filled in at + // SSA generation time. + RegOutputParams []*ir.Name + // Variable declarations that were removed during optimization + OptDcl []*ir.Name + // The ssa.Func.EntryID value, used to build location lists for + // return values promoted to heap in later DWARF generation. + EntryID ID + + // Filled in by the user. Translates Block and Value ID to PC. + // + // NOTE: block is only used if value is BlockStart.ID or BlockEnd.ID. + // Otherwise, it is ignored. + GetPC func(block, value ID) int64 +} + +type BlockDebug struct { + // State at the start and end of the block. These are initialized, + // and updated from new information that flows on back edges. + startState, endState abt.T + // Use these to avoid excess work in the merge. If none of the + // predecessors has changed since the last check, the old answer is + // still good. + lastCheckedTime, lastChangedTime int32 + // Whether the block had any changes to user variables at all. + relevant bool + // false until the block has been processed at least once. This + // affects how the merge is done; the goal is to maximize sharing + // and avoid allocation. + everProcessed bool +} + +// A liveSlot is a slot that's live in loc at entry/exit of a block. +type liveSlot struct { + VarLoc +} + +func (ls *liveSlot) String() string { + return fmt.Sprintf("0x%x.%d.%d", ls.Registers, ls.stackOffsetValue(), int32(ls.StackOffset)&1) +} + +// StackOffset encodes whether a value is on the stack and if so, where. +// It is a 31-bit integer followed by a presence flag at the low-order +// bit. +type StackOffset int32 + +func (s StackOffset) onStack() bool { + return s != 0 +} + +func (s StackOffset) stackOffsetValue() int32 { + return int32(s) >> 1 +} + +// stateAtPC is the current state of all variables at some point. +type stateAtPC struct { + // The location of each known slot, indexed by SlotID. + slots []VarLoc + // The slots present in each register, indexed by register number. + registers [][]SlotID +} + +// reset fills state with the live variables from live. +func (state *stateAtPC) reset(live abt.T) { + slots, registers := state.slots, state.registers + clear(slots) + for i := range registers { + registers[i] = registers[i][:0] + } + for it := live.Iterator(); !it.Done(); { + k, d := it.Next() + live := d.(*liveSlot) + slots[k] = live.VarLoc + if live.VarLoc.Registers == 0 { + continue + } + + mask := uint64(live.VarLoc.Registers) + for { + if mask == 0 { + break + } + reg := uint8(bits.TrailingZeros64(mask)) + mask &^= 1 << reg + + registers[reg] = append(registers[reg], SlotID(k)) + } + } + state.slots, state.registers = slots, registers +} + +func (s *debugState) LocString(loc VarLoc) string { + if loc.absent() { + return "" + } + + var storage []string + if loc.onStack() { + storage = append(storage, fmt.Sprintf("@%+d", loc.stackOffsetValue())) + } + + mask := uint64(loc.Registers) + for { + if mask == 0 { + break + } + reg := uint8(bits.TrailingZeros64(mask)) + mask &^= 1 << reg + + storage = append(storage, s.registers[reg].String()) + } + return strings.Join(storage, ",") +} + +// A VarLoc describes the storage for part of a user variable. +type VarLoc struct { + // The registers this variable is available in. There can be more than + // one in various situations, e.g. it's being moved between registers. + Registers RegisterSet + + StackOffset +} + +func (loc VarLoc) absent() bool { + return loc.Registers == 0 && !loc.onStack() +} + +func (loc VarLoc) intersect(other VarLoc) VarLoc { + if !loc.onStack() || !other.onStack() || loc.StackOffset != other.StackOffset { + loc.StackOffset = 0 + } + loc.Registers &= other.Registers + return loc +} + +var BlockStart = &Value{ + ID: -10000, + Op: OpInvalid, + Aux: StringToAux("BlockStart"), +} + +var BlockEnd = &Value{ + ID: -20000, + Op: OpInvalid, + Aux: StringToAux("BlockEnd"), +} + +var FuncEnd = &Value{ + ID: -30000, + Op: OpInvalid, + Aux: StringToAux("FuncEnd"), +} + +// RegisterSet is a bitmap of registers, indexed by Register.num. +type RegisterSet uint64 + +// logf prints debug-specific logging to stdout (always stdout) if the +// current function is tagged by GOSSAFUNC (for ssa output directed +// either to stdout or html). +func (s *debugState) logf(msg string, args ...any) { + if s.f.PrintOrHtmlSSA { + fmt.Printf(msg, args...) + } +} + +type debugState struct { + // See FuncDebug. + slots []LocalSlot + vars []*ir.Name + varSlots [][]SlotID + lists [][]byte + + // The user variable that each slot rolls up to, indexed by SlotID. + slotVars []VarID + + f *Func + loggingLevel int + convergeCount int // testing; iterate over block debug state this many times + registers []Register + stackOffset func(LocalSlot) int32 + ctxt *obj.Link + + // The names (slots) associated with each value, indexed by Value ID. + valueNames [][]SlotID + + // The current state of whatever analysis is running. + currentState stateAtPC + changedVars *sparseSet + changedSlots *sparseSet + + // The pending location list entry for each user variable, indexed by VarID. + pendingEntries []pendingEntry + + varParts map[*ir.Name][]SlotID + blockDebug []BlockDebug + pendingSlotLocs []VarLoc +} + +func (state *debugState) initializeCache(f *Func, numVars, numSlots int) { + // One blockDebug per block. Initialized in allocBlock. + if cap(state.blockDebug) < f.NumBlocks() { + state.blockDebug = make([]BlockDebug, f.NumBlocks()) + } else { + clear(state.blockDebug[:f.NumBlocks()]) + } + + // A list of slots per Value. Reuse the previous child slices. + if cap(state.valueNames) < f.NumValues() { + old := state.valueNames + state.valueNames = make([][]SlotID, f.NumValues()) + copy(state.valueNames, old) + } + vn := state.valueNames[:f.NumValues()] + for i := range vn { + vn[i] = vn[i][:0] + } + + // Slot and register contents for currentState. Cleared by reset(). + if cap(state.currentState.slots) < numSlots { + state.currentState.slots = make([]VarLoc, numSlots) + } else { + state.currentState.slots = state.currentState.slots[:numSlots] + } + if cap(state.currentState.registers) < len(state.registers) { + state.currentState.registers = make([][]SlotID, len(state.registers)) + } else { + state.currentState.registers = state.currentState.registers[:len(state.registers)] + } + + // A relatively small slice, but used many times as the return from processValue. + state.changedVars = newSparseSet(numVars) + state.changedSlots = newSparseSet(numSlots) + + // A pending entry per user variable, with space to track each of its pieces. + numPieces := 0 + for i := range state.varSlots { + numPieces += len(state.varSlots[i]) + } + if cap(state.pendingSlotLocs) < numPieces { + state.pendingSlotLocs = make([]VarLoc, numPieces) + } else { + clear(state.pendingSlotLocs[:numPieces]) + } + if cap(state.pendingEntries) < numVars { + state.pendingEntries = make([]pendingEntry, numVars) + } + pe := state.pendingEntries[:numVars] + freePieceIdx := 0 + for varID, slots := range state.varSlots { + pe[varID] = pendingEntry{ + pieces: state.pendingSlotLocs[freePieceIdx : freePieceIdx+len(slots)], + } + freePieceIdx += len(slots) + } + state.pendingEntries = pe + + if cap(state.lists) < numVars { + state.lists = make([][]byte, numVars) + } else { + state.lists = state.lists[:numVars] + clear(state.lists) + } +} + +func (state *debugState) allocBlock(b *Block) *BlockDebug { + return &state.blockDebug[b.ID] +} + +func (s *debugState) blockEndStateString(b *BlockDebug) string { + endState := stateAtPC{slots: make([]VarLoc, len(s.slots)), registers: make([][]SlotID, len(s.registers))} + endState.reset(b.endState) + return s.stateString(endState) +} + +func (s *debugState) stateString(state stateAtPC) string { + var strs []string + for slotID, loc := range state.slots { + if !loc.absent() { + strs = append(strs, fmt.Sprintf("\t%v = %v\n", s.slots[slotID], s.LocString(loc))) + } + } + + strs = append(strs, "\n") + for reg, slots := range state.registers { + if len(slots) != 0 { + var slotStrs []string + for _, slot := range slots { + slotStrs = append(slotStrs, s.slots[slot].String()) + } + strs = append(strs, fmt.Sprintf("\t%v = %v\n", &s.registers[reg], slotStrs)) + } + } + + if len(strs) == 1 { + return "(no vars)\n" + } + return strings.Join(strs, "") +} + +// slotCanonicalizer is a table used to lookup and canonicalize +// LocalSlot's in a type insensitive way (e.g. taking into account the +// base name, offset, and width of the slot, but ignoring the slot +// type). +type slotCanonicalizer struct { + slmap map[slotKey]SlKeyIdx + slkeys []LocalSlot +} + +func newSlotCanonicalizer() *slotCanonicalizer { + return &slotCanonicalizer{ + slmap: make(map[slotKey]SlKeyIdx), + slkeys: []LocalSlot{LocalSlot{N: nil}}, + } +} + +type SlKeyIdx uint32 + +const noSlot = SlKeyIdx(0) + +// slotKey is a type-insensitive encapsulation of a LocalSlot; it +// is used to key a map within slotCanonicalizer. +type slotKey struct { + name *ir.Name + offset int64 + width int64 + splitOf SlKeyIdx // idx in slkeys slice in slotCanonicalizer + splitOffset int64 +} + +// lookup looks up a LocalSlot in the slot canonicalizer "sc", returning +// a canonical index for the slot, and adding it to the table if need +// be. Return value is the canonical slot index, and a boolean indicating +// whether the slot was found in the table already (TRUE => found). +func (sc *slotCanonicalizer) lookup(ls LocalSlot) (SlKeyIdx, bool) { + split := noSlot + if ls.SplitOf != nil { + split, _ = sc.lookup(*ls.SplitOf) + } + k := slotKey{ + name: ls.N, offset: ls.Off, width: ls.Type.Size(), + splitOf: split, splitOffset: ls.SplitOffset, + } + if idx, ok := sc.slmap[k]; ok { + return idx, true + } + rv := SlKeyIdx(len(sc.slkeys)) + sc.slkeys = append(sc.slkeys, ls) + sc.slmap[k] = rv + return rv, false +} + +func (sc *slotCanonicalizer) canonSlot(idx SlKeyIdx) LocalSlot { + return sc.slkeys[idx] +} + +// PopulateABIInRegArgOps examines the entry block of the function +// and looks for incoming parameters that have missing or partial +// OpArg{Int,Float}Reg values, inserting additional values in +// cases where they are missing. Example: +// +// func foo(s string, used int, notused int) int { +// return len(s) + used +// } +// +// In the function above, the incoming parameter "used" is fully live, +// "notused" is not live, and "s" is partially live (only the length +// field of the string is used). At the point where debug value +// analysis runs, we might expect to see an entry block with: +// +// b1: +// v4 = ArgIntReg {s+8} [0] : BX +// v5 = ArgIntReg {used} [0] : CX +// +// While this is an accurate picture of the live incoming params, +// we also want to have debug locations for non-live params (or +// their non-live pieces), e.g. something like +// +// b1: +// v9 = ArgIntReg <*uint8> {s+0} [0] : AX +// v4 = ArgIntReg {s+8} [0] : BX +// v5 = ArgIntReg {used} [0] : CX +// v10 = ArgIntReg {unused} [0] : DI +// +// This function examines the live OpArg{Int,Float}Reg values and +// synthesizes new (dead) values for the non-live params or the +// non-live pieces of partially live params. +func PopulateABIInRegArgOps(f *Func) { + pri := f.ABISelf.ABIAnalyzeFuncType(f.Type) + + // When manufacturing new slots that correspond to splits of + // composite parameters, we want to avoid creating a new sub-slot + // that differs from some existing sub-slot only by type, since + // the debug location analysis will treat that slot as a separate + // entity. To achieve this, create a lookup table of existing + // slots that is type-insenstitive. + sc := newSlotCanonicalizer() + for _, sl := range f.Names { + sc.lookup(*sl) + } + + // Add slot -> value entry to f.NamedValues if not already present. + addToNV := func(v *Value, sl LocalSlot) { + values, ok := f.NamedValues[sl] + if !ok { + // Haven't seen this slot yet. + sla := f.localSlotAddr(sl) + f.Names = append(f.Names, sla) + } else { + for _, ev := range values { + if v == ev { + return + } + } + } + values = append(values, v) + f.NamedValues[sl] = values + } + + newValues := []*Value{} + + abiRegIndexToRegister := func(reg abi.RegIndex) int8 { + i := f.ABISelf.FloatIndexFor(reg) + if i >= 0 { // float PR + return f.Config.floatParamRegs[i] + } else { + return f.Config.intParamRegs[reg] + } + } + + // Helper to construct a new OpArg{Float,Int}Reg op value. + var pos src.XPos + if len(f.Entry.Values) != 0 { + pos = f.Entry.Values[0].Pos + } + synthesizeOpIntFloatArg := func(n *ir.Name, t *types.Type, reg abi.RegIndex, sl LocalSlot) *Value { + aux := &AuxNameOffset{n, sl.Off} + op, auxInt := ArgOpAndRegisterFor(reg, f.ABISelf) + v := f.newValueNoBlock(op, t, pos) + v.AuxInt = auxInt + v.Aux = aux + v.Args = nil + v.Block = f.Entry + newValues = append(newValues, v) + addToNV(v, sl) + f.setHome(v, &f.Config.registers[abiRegIndexToRegister(reg)]) + return v + } + + // Make a pass through the entry block looking for + // OpArg{Int,Float}Reg ops. Record the slots they use in a table + // ("sc"). We use a type-insensitive lookup for the slot table, + // since the type we get from the ABI analyzer won't always match + // what the compiler uses when creating OpArg{Int,Float}Reg ops. + for _, v := range f.Entry.Values { + if v.Op == OpArgIntReg || v.Op == OpArgFloatReg { + aux := v.Aux.(*AuxNameOffset) + sl := LocalSlot{N: aux.Name, Type: v.Type, Off: aux.Offset} + // install slot in lookup table + idx, _ := sc.lookup(sl) + // add to f.NamedValues if not already present + addToNV(v, sc.canonSlot(idx)) + } else if v.Op.IsCall() { + // if we hit a call, we've gone too far. + break + } + } + + // Now make a pass through the ABI in-params, looking for params + // or pieces of params that we didn't encounter in the loop above. + for _, inp := range pri.InParams() { + if !isNamedRegParam(inp) { + continue + } + n := inp.Name + + // Param is spread across one or more registers. Walk through + // each piece to see whether we've seen an arg reg op for it. + types, offsets := inp.RegisterTypesAndOffsets() + for k, t := range types { + // Note: this recipe for creating a LocalSlot is designed + // to be compatible with the one used in expand_calls.go + // as opposed to decompose.go. The expand calls code just + // takes the base name and creates an offset into it, + // without using the SplitOf/SplitOffset fields. The code + // in decompose.go does the opposite -- it creates a + // LocalSlot object with "Off" set to zero, but with + // SplitOf pointing to a parent slot, and SplitOffset + // holding the offset into the parent object. + pieceSlot := LocalSlot{N: n, Type: t, Off: offsets[k]} + + // Look up this piece to see if we've seen a reg op + // for it. If not, create one. + _, found := sc.lookup(pieceSlot) + if !found { + // This slot doesn't appear in the map, meaning it + // corresponds to an in-param that is not live, or + // a portion of an in-param that is not live/used. + // Add a new dummy OpArg{Int,Float}Reg for it. + synthesizeOpIntFloatArg(n, t, inp.Registers[k], + pieceSlot) + } + } + } + + // Insert the new values into the head of the block. + f.Entry.Values = append(newValues, f.Entry.Values...) +} + +// BuildFuncDebug builds debug information for f, placing the results +// in "rval". f must be fully processed, so that each Value is where it +// will be when machine code is emitted. +func BuildFuncDebug(ctxt *obj.Link, f *Func, loggingLevel int, stackOffset func(LocalSlot) int32, rval *FuncDebug) { + if f.RegAlloc == nil { + f.Fatalf("BuildFuncDebug on func %v that has not been fully processed", f) + } + state := &f.Cache.debugState + state.loggingLevel = loggingLevel % 1000 + + // A specific number demands exactly that many iterations. Under + // particular circumstances it make require more than the total of + // 2 passes implied by a single run through liveness and a single + // run through location list generation. + state.convergeCount = loggingLevel / 1000 + state.f = f + state.registers = f.Config.registers + state.stackOffset = stackOffset + state.ctxt = ctxt + + if buildcfg.Experiment.RegabiArgs { + PopulateABIInRegArgOps(f) + } + + if state.loggingLevel > 0 { + state.logf("Generating location lists for function %q\n", f.Name) + } + + if state.varParts == nil { + state.varParts = make(map[*ir.Name][]SlotID) + } else { + clear(state.varParts) + } + + // Recompose any decomposed variables, and establish the canonical + // IDs for each var and slot by filling out state.vars and state.slots. + + state.slots = state.slots[:0] + state.vars = state.vars[:0] + for i, slot := range f.Names { + state.slots = append(state.slots, *slot) + if ir.IsSynthetic(slot.N) || !IsVarWantedForDebug(slot.N) { + continue + } + + topSlot := slot + for topSlot.SplitOf != nil { + topSlot = topSlot.SplitOf + } + if _, ok := state.varParts[topSlot.N]; !ok { + state.vars = append(state.vars, topSlot.N) + } + state.varParts[topSlot.N] = append(state.varParts[topSlot.N], SlotID(i)) + } + + // Recreate the LocalSlot for each stack-only variable. + // This would probably be better as an output from stackframe. + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op == OpVarDef { + n := v.Aux.(*ir.Name) + if ir.IsSynthetic(n) || !IsVarWantedForDebug(n) { + continue + } + + if _, ok := state.varParts[n]; !ok { + slot := LocalSlot{N: n, Type: v.Type, Off: 0} + state.slots = append(state.slots, slot) + state.varParts[n] = []SlotID{SlotID(len(state.slots) - 1)} + state.vars = append(state.vars, n) + } + } + } + } + + // Fill in the var<->slot mappings. + if cap(state.varSlots) < len(state.vars) { + state.varSlots = make([][]SlotID, len(state.vars)) + } else { + state.varSlots = state.varSlots[:len(state.vars)] + for i := range state.varSlots { + state.varSlots[i] = state.varSlots[i][:0] + } + } + if cap(state.slotVars) < len(state.slots) { + state.slotVars = make([]VarID, len(state.slots)) + } else { + state.slotVars = state.slotVars[:len(state.slots)] + } + + for varID, n := range state.vars { + parts := state.varParts[n] + slices.SortFunc(parts, func(a, b SlotID) int { + return cmp.Compare(varOffset(state.slots[a]), varOffset(state.slots[b])) + }) + + state.varSlots[varID] = parts + for _, slotID := range parts { + state.slotVars[slotID] = VarID(varID) + } + } + + state.initializeCache(f, len(state.varParts), len(state.slots)) + + for i, slot := range f.Names { + if ir.IsSynthetic(slot.N) || !IsVarWantedForDebug(slot.N) { + continue + } + for _, value := range f.NamedValues[*slot] { + state.valueNames[value.ID] = append(state.valueNames[value.ID], SlotID(i)) + } + } + + blockLocs := state.liveness() + state.buildLocationLists(blockLocs) + + // Populate "rval" with what we've computed. + rval.Slots = state.slots + rval.VarSlots = state.varSlots + rval.Vars = state.vars + rval.LocationLists = state.lists +} + +// liveness walks the function in control flow order, calculating the start +// and end state of each block. +func (state *debugState) liveness() []*BlockDebug { + blockLocs := make([]*BlockDebug, state.f.NumBlocks()) + counterTime := int32(1) + + // Reverse postorder: visit a block after as many as possible of its + // predecessors have been visited. + po := state.f.Postorder() + converged := false + + // The iteration rule is that by default, run until converged, but + // if a particular iteration count is specified, run that many + // iterations, no more, no less. A count is specified as the + // thousands digit of the location lists debug flag, + // e.g. -d=locationlists=4000 + keepGoing := func(k int) bool { + if state.convergeCount == 0 { + return !converged + } + return k < state.convergeCount + } + for k := 0; keepGoing(k); k++ { + if state.loggingLevel > 0 { + state.logf("Liveness pass %d\n", k) + } + converged = true + for i := len(po) - 1; i >= 0; i-- { + b := po[i] + locs := blockLocs[b.ID] + if locs == nil { + locs = state.allocBlock(b) + blockLocs[b.ID] = locs + } + + // Build the starting state for the block from the final + // state of its predecessors. + startState, blockChanged := state.mergePredecessors(b, blockLocs, nil, false) + locs.lastCheckedTime = counterTime + counterTime++ + if state.loggingLevel > 1 { + state.logf("Processing %v, block changed %v, initial state:\n%v", b, blockChanged, state.stateString(state.currentState)) + } + + if blockChanged { + // If the start did not change, then the old endState is good + converged = false + changed := false + state.changedSlots.clear() + + // Update locs/registers with the effects of each Value. + for _, v := range b.Values { + slots := state.valueNames[v.ID] + + // Loads and stores inherit the names of their sources. + var source *Value + switch v.Op { + case OpStoreReg: + source = v.Args[0] + case OpLoadReg: + switch a := v.Args[0]; a.Op { + case OpArg, OpPhi: + source = a + case OpStoreReg: + source = a.Args[0] + default: + if state.loggingLevel > 1 { + state.logf("at %v: load with unexpected source op: %v (%v)\n", v, a.Op, a) + } + } + } + // Update valueNames with the source so that later steps + // don't need special handling. + if source != nil && k == 0 { + // limit to k == 0 otherwise there are duplicates. + slots = append(slots, state.valueNames[source.ID]...) + state.valueNames[v.ID] = slots + } + + reg, _ := state.f.getHome(v.ID).(*Register) + c := state.processValue(v, slots, reg) + changed = changed || c + } + + if state.loggingLevel > 1 { + state.logf("Block %v done, locs:\n%v", b, state.stateString(state.currentState)) + } + + locs.relevant = locs.relevant || changed + if !changed { + locs.endState = startState + } else { + for _, id := range state.changedSlots.contents() { + slotID := SlotID(id) + slotLoc := state.currentState.slots[slotID] + if slotLoc.absent() { + startState.Delete(int32(slotID)) + continue + } + old := startState.Find(int32(slotID)) // do NOT replace existing values + if oldLS, ok := old.(*liveSlot); !ok || oldLS.VarLoc != slotLoc { + startState.Insert(int32(slotID), + &liveSlot{VarLoc: slotLoc}) + } + } + locs.endState = startState + } + locs.lastChangedTime = counterTime + } + counterTime++ + } + } + return blockLocs +} + +// mergePredecessors takes the end state of each of b's predecessors and +// intersects them to form the starting state for b. It puts that state +// in blockLocs[b.ID].startState, and fills state.currentState with it. +// It returns the start state and whether this is changed from the +// previously approximated value of startState for this block. After +// the first call, subsequent calls can only shrink startState. +// +// Passing forLocationLists=true enables additional side-effects that +// are necessary for building location lists but superfluous while still +// iterating to an answer. +// +// If previousBlock is non-nil, it registers changes vs. that block's +// end state in state.changedVars. Note that previousBlock will often +// not be a predecessor. +// +// Note that mergePredecessors behaves slightly differently between +// first and subsequent calls for a block. For the first call, the +// starting state is approximated by taking the state from the +// predecessor whose state is smallest, and removing any elements not +// in all the other predecessors; this makes the smallest number of +// changes and shares the most state. On subsequent calls the old +// value of startState is adjusted with new information; this is judged +// to do the least amount of extra work. +// +// To improve performance, each block's state information is marked with +// lastChanged and lastChecked "times" so unchanged predecessors can be +// skipped on after-the-first iterations. Doing this allows extra +// iterations by the caller to be almost free. +// +// It is important to know that the set representation used for +// startState, endState, and merges can share data for two sets where +// one is a small delta from the other. Doing this does require a +// little care in how sets are updated, both in mergePredecessors, and +// using its result. +func (state *debugState) mergePredecessors(b *Block, blockLocs []*BlockDebug, previousBlock *Block, forLocationLists bool) (abt.T, bool) { + // Filter out back branches. + var predsBuf [10]*Block + + preds := predsBuf[:0] + locs := blockLocs[b.ID] + + blockChanged := !locs.everProcessed // the first time it always changes. + updating := locs.everProcessed + + // For the first merge, exclude predecessors that have not been seen yet. + // I.e., backedges. + for _, pred := range b.Preds { + if bl := blockLocs[pred.b.ID]; bl != nil && bl.everProcessed { + // crucially, a self-edge has bl != nil, but bl.everProcessed is false the first time. + preds = append(preds, pred.b) + } + } + + locs.everProcessed = true + + if state.loggingLevel > 1 { + // The logf below would cause preds to be heap-allocated if + // it were passed directly. + preds2 := make([]*Block, len(preds)) + copy(preds2, preds) + state.logf("Merging %v into %v (changed=%d, checked=%d)\n", preds2, b, locs.lastChangedTime, locs.lastCheckedTime) + } + + state.changedVars.clear() + + markChangedVars := func(slots, merged abt.T) { + if !forLocationLists { + return + } + // Fill changedVars with those that differ between the previous + // block (in the emit order, not necessarily a flow predecessor) + // and the start state for this block. + for it := slots.Iterator(); !it.Done(); { + k, v := it.Next() + m := merged.Find(k) + if m == nil || v.(*liveSlot).VarLoc != m.(*liveSlot).VarLoc { + state.changedVars.add(ID(state.slotVars[k])) + } + } + } + + reset := func(ourStartState abt.T) { + if !(forLocationLists || blockChanged) { + // there is no change and this is not for location lists, do + // not bother to reset currentState because it will not be + // examined. + return + } + state.currentState.reset(ourStartState) + } + + // Zero predecessors + if len(preds) == 0 { + if previousBlock != nil { + state.f.Fatalf("Function %v, block %s with no predecessors is not first block, has previous %s", state.f, b.String(), previousBlock.String()) + } + // startState is empty + reset(abt.T{}) + return abt.T{}, blockChanged + } + + // One predecessor + l0 := blockLocs[preds[0].ID] + p0 := l0.endState + if len(preds) == 1 { + if previousBlock != nil && preds[0].ID != previousBlock.ID { + // Change from previous block is its endState minus the predecessor's endState + markChangedVars(blockLocs[previousBlock.ID].endState, p0) + } + locs.startState = p0 + blockChanged = blockChanged || l0.lastChangedTime > locs.lastCheckedTime + reset(p0) + return p0, blockChanged + } + + // More than one predecessor + + if updating { + // After the first approximation, i.e., when updating, results + // can only get smaller, because initially backedge + // predecessors do not participate in the intersection. This + // means that for the update, given the prior approximation of + // startState, there is no need to re-intersect with unchanged + // blocks. Therefore remove unchanged blocks from the + // predecessor list. + for i := len(preds) - 1; i >= 0; i-- { + pred := preds[i] + if blockLocs[pred.ID].lastChangedTime > locs.lastCheckedTime { + continue // keep this predecessor + } + preds[i] = preds[len(preds)-1] + preds = preds[:len(preds)-1] + if state.loggingLevel > 2 { + state.logf("Pruned b%d, lastChanged was %d but b%d lastChecked is %d\n", pred.ID, blockLocs[pred.ID].lastChangedTime, b.ID, locs.lastCheckedTime) + } + } + // Check for an early out; this should always hit for the update + // if there are no cycles. + if len(preds) == 0 { + blockChanged = false + + reset(locs.startState) + if state.loggingLevel > 2 { + state.logf("Early out, no predecessors changed since last check\n") + } + if previousBlock != nil { + markChangedVars(blockLocs[previousBlock.ID].endState, locs.startState) + } + return locs.startState, blockChanged + } + } + + baseID := preds[0].ID + baseState := p0 + + // Choose the predecessor with the smallest endState for intersection work + for _, pred := range preds[1:] { + if blockLocs[pred.ID].endState.Size() < baseState.Size() { + baseState = blockLocs[pred.ID].endState + baseID = pred.ID + } + } + + if state.loggingLevel > 2 { + state.logf("Starting %v with state from b%v:\n%v", b, baseID, state.blockEndStateString(blockLocs[baseID])) + for _, pred := range preds { + if pred.ID == baseID { + continue + } + state.logf("Merging in state from %v:\n%v", pred, state.blockEndStateString(blockLocs[pred.ID])) + } + } + + state.currentState.reset(abt.T{}) + // The normal logic of "reset" is included in the intersection loop below. + + slotLocs := state.currentState.slots + + // If this is the first call, do updates on the "baseState"; if this + // is a subsequent call, tweak the startState instead. Note that + // these "set" values are values; there are no side effects to + // other values as these are modified. + newState := baseState + if updating { + newState = blockLocs[b.ID].startState + } + + for it := newState.Iterator(); !it.Done(); { + k, d := it.Next() + thisSlot := d.(*liveSlot) + x := thisSlot.VarLoc + x0 := x // initial value in newState + + // Intersect this slot with the slot in all the predecessors + for _, other := range preds { + if !updating && other.ID == baseID { + continue + } + otherSlot := blockLocs[other.ID].endState.Find(k) + if otherSlot == nil { + x = VarLoc{} + break + } + y := otherSlot.(*liveSlot).VarLoc + x = x.intersect(y) + if x.absent() { + x = VarLoc{} + break + } + } + + // Delete if necessary, but not otherwise (in order to maximize sharing). + if x.absent() { + if !x0.absent() { + blockChanged = true + newState.Delete(k) + } + slotLocs[k] = VarLoc{} + continue + } + if x != x0 { + blockChanged = true + newState.Insert(k, &liveSlot{VarLoc: x}) + } + + slotLocs[k] = x + mask := uint64(x.Registers) + for { + if mask == 0 { + break + } + reg := uint8(bits.TrailingZeros64(mask)) + mask &^= 1 << reg + state.currentState.registers[reg] = append(state.currentState.registers[reg], SlotID(k)) + } + } + + if previousBlock != nil { + markChangedVars(blockLocs[previousBlock.ID].endState, newState) + } + locs.startState = newState + return newState, blockChanged +} + +// processValue updates locs and state.registerContents to reflect v, a +// value with the names in vSlots and homed in vReg. "v" becomes +// visible after execution of the instructions evaluating it. It +// returns which VarIDs were modified by the Value's execution. +func (state *debugState) processValue(v *Value, vSlots []SlotID, vReg *Register) bool { + locs := state.currentState + changed := false + setSlot := func(slot SlotID, loc VarLoc) { + changed = true + state.changedVars.add(ID(state.slotVars[slot])) + state.changedSlots.add(ID(slot)) + state.currentState.slots[slot] = loc + } + + // Handle any register clobbering. Call operations, for example, + // clobber all registers even though they don't explicitly write to + // them. + clobbers := uint64(opcodeTable[v.Op].reg.clobbers) + for { + if clobbers == 0 { + break + } + reg := uint8(bits.TrailingZeros64(clobbers)) + clobbers &^= 1 << reg + + for _, slot := range locs.registers[reg] { + if state.loggingLevel > 1 { + state.logf("at %v: %v clobbered out of %v\n", v, state.slots[slot], &state.registers[reg]) + } + + last := locs.slots[slot] + if last.absent() { + state.f.Fatalf("at %v: slot %v in register %v with no location entry", v, state.slots[slot], &state.registers[reg]) + continue + } + regs := last.Registers &^ (1 << reg) + setSlot(slot, VarLoc{regs, last.StackOffset}) + } + + locs.registers[reg] = locs.registers[reg][:0] + } + + switch { + case v.Op == OpVarDef: + n := v.Aux.(*ir.Name) + if ir.IsSynthetic(n) || !IsVarWantedForDebug(n) { + break + } + + slotID := state.varParts[n][0] + var stackOffset StackOffset + if v.Op == OpVarDef { + stackOffset = StackOffset(state.stackOffset(state.slots[slotID])<<1 | 1) + } + setSlot(slotID, VarLoc{0, stackOffset}) + if state.loggingLevel > 1 { + if v.Op == OpVarDef { + state.logf("at %v: stack-only var %v now live\n", v, state.slots[slotID]) + } else { + state.logf("at %v: stack-only var %v now dead\n", v, state.slots[slotID]) + } + } + + case v.Op == OpArg: + home := state.f.getHome(v.ID).(LocalSlot) + stackOffset := state.stackOffset(home)<<1 | 1 + for _, slot := range vSlots { + if state.loggingLevel > 1 { + state.logf("at %v: arg %v now on stack in location %v\n", v, state.slots[slot], home) + if last := locs.slots[slot]; !last.absent() { + state.logf("at %v: unexpected arg op on already-live slot %v\n", v, state.slots[slot]) + } + } + + setSlot(slot, VarLoc{0, StackOffset(stackOffset)}) + } + + case v.Op == OpStoreReg: + home := state.f.getHome(v.ID).(LocalSlot) + stackOffset := state.stackOffset(home)<<1 | 1 + for _, slot := range vSlots { + last := locs.slots[slot] + if last.absent() { + if state.loggingLevel > 1 { + state.logf("at %v: unexpected spill of unnamed register %s\n", v, vReg) + } + break + } + + setSlot(slot, VarLoc{last.Registers, StackOffset(stackOffset)}) + if state.loggingLevel > 1 { + state.logf("at %v: %v spilled to stack location %v@%d\n", v, state.slots[slot], home, state.stackOffset(home)) + } + } + + case vReg != nil: + if state.loggingLevel > 1 { + newSlots := make([]bool, len(state.slots)) + for _, slot := range vSlots { + newSlots[slot] = true + } + + for _, slot := range locs.registers[vReg.num] { + if !newSlots[slot] { + state.logf("at %v: overwrote %v in register %v\n", v, state.slots[slot], vReg) + } + } + } + + for _, slot := range locs.registers[vReg.num] { + last := locs.slots[slot] + setSlot(slot, VarLoc{last.Registers &^ (1 << uint8(vReg.num)), last.StackOffset}) + } + locs.registers[vReg.num] = locs.registers[vReg.num][:0] + locs.registers[vReg.num] = append(locs.registers[vReg.num], vSlots...) + for _, slot := range vSlots { + if state.loggingLevel > 1 { + state.logf("at %v: %v now in %s\n", v, state.slots[slot], vReg) + } + + last := locs.slots[slot] + setSlot(slot, VarLoc{1< {foo+0} [0] : AX (foo) + // v34 = ArgIntReg {bar+0} [0] : BX (bar) + // ... + // v77 = StoreReg v67 : ctx+8[unsafe.Pointer] + // v78 = StoreReg v68 : ctx[unsafe.Pointer] + // v79 = Arg <*uint8> {args} : args[*uint8] (args[*uint8]) + // v80 = Arg {args} [8] : args+8[int] (args+8[int]) + // ... + // v1 = InitMem + // + // We can stop scanning the initial portion of the block when + // we either see the InitMem op (for entry blocks) or the + // first non-zero-width op (for other blocks). + for idx := 0; idx < len(b.Values); idx++ { + v := b.Values[idx] + if blockPrologComplete(v) { + break + } + // Consider only "lifetime begins at block start" ops. + if !mustBeFirst(v) && v.Op != OpArg { + continue + } + slots := state.valueNames[v.ID] + reg, _ := state.f.getHome(v.ID).(*Register) + changed := state.processValue(v, slots, reg) // changed == added to state.changedVars + if changed { + for _, varID := range state.changedVars.contents() { + state.updateVar(VarID(varID), v.Block, BlockStart) + } + state.changedVars.clear() + } + } + + // Now examine the block again, handling things other than the + // "begins at block start" lifetimes. + zeroWidthPending := false + prologComplete := false + // expect to see values in pattern (apc)* (zerowidth|real)* + for _, v := range b.Values { + if blockPrologComplete(v) { + prologComplete = true + } + slots := state.valueNames[v.ID] + reg, _ := state.f.getHome(v.ID).(*Register) + changed := state.processValue(v, slots, reg) // changed == added to state.changedVars + + if opcodeTable[v.Op].zeroWidth { + if prologComplete && mustBeFirst(v) { + panic(fmt.Errorf("Unexpected placement of op '%s' appearing after non-pseudo-op at beginning of block %s in %s\n%s", v.LongString(), b, b.Func.Name, b.Func)) + } + if changed { + if mustBeFirst(v) || v.Op == OpArg { + // already taken care of above + continue + } + zeroWidthPending = true + } + continue + } + if !changed && !zeroWidthPending { + continue + } + + // Not zero-width; i.e., a "real" instruction. + zeroWidthPending = false + for _, varID := range state.changedVars.contents() { + state.updateVar(VarID(varID), v.Block, v) + } + state.changedVars.clear() + } + for _, varID := range state.changedVars.contents() { + state.updateVar(VarID(varID), b, BlockEnd) + } + + prevBlock = b + } + + if state.loggingLevel > 0 { + state.logf("location lists:\n") + } + + // Flush any leftover entries live at the end of the last block. + for varID := range state.lists { + state.writePendingEntry(VarID(varID), -1, FuncEnd.ID) + list := state.lists[varID] + if state.loggingLevel > 0 { + if len(list) == 0 { + state.logf("\t%v : empty list\n", state.vars[varID]) + } else { + state.logf("\t%v : %q\n", state.vars[varID], hex.EncodeToString(state.lists[varID])) + } + } + } +} + +// updateVar updates the pending location list entry for varID to +// reflect the new locations in curLoc, beginning at v in block b. +// v may be one of the special values indicating block start or end. +func (state *debugState) updateVar(varID VarID, b *Block, v *Value) { + curLoc := state.currentState.slots + // Assemble the location list entry with whatever's live. + empty := true + for _, slotID := range state.varSlots[varID] { + if !curLoc[slotID].absent() { + empty = false + break + } + } + pending := &state.pendingEntries[varID] + if empty { + state.writePendingEntry(varID, b.ID, v.ID) + pending.clear() + return + } + + // Extend the previous entry if possible. + if pending.present { + merge := true + for i, slotID := range state.varSlots[varID] { + if !canMerge(pending.pieces[i], curLoc[slotID]) { + merge = false + break + } + } + if merge { + return + } + } + + state.writePendingEntry(varID, b.ID, v.ID) + pending.present = true + pending.startBlock = b.ID + pending.startValue = v.ID + for i, slot := range state.varSlots[varID] { + pending.pieces[i] = curLoc[slot] + } +} + +// writePendingEntry writes out the pending entry for varID, if any, +// terminated at endBlock/Value. +func (state *debugState) writePendingEntry(varID VarID, endBlock, endValue ID) { + pending := state.pendingEntries[varID] + if !pending.present { + return + } + + // Pack the start/end coordinates into the start/end addresses + // of the entry, for decoding by PutLocationList. + start, startOK := encodeValue(state.ctxt, pending.startBlock, pending.startValue) + end, endOK := encodeValue(state.ctxt, endBlock, endValue) + if !startOK || !endOK { + // If someone writes a function that uses >65K values, + // they get incomplete debug info on 32-bit platforms. + return + } + if start == end { + if state.loggingLevel > 1 { + // Printf not logf so not gated by GOSSAFUNC; this should fire very rarely. + // TODO this fires a lot, need to figure out why. + state.logf("Skipping empty location list for %v in %s\n", state.vars[varID], state.f.Name) + } + return + } + + list := state.lists[varID] + list = appendPtr(state.ctxt, list, start) + list = appendPtr(state.ctxt, list, end) + // Where to write the length of the location description once + // we know how big it is. + sizeIdx := len(list) + list = list[:len(list)+2] + + if state.loggingLevel > 1 { + var partStrs []string + for i, slot := range state.varSlots[varID] { + partStrs = append(partStrs, fmt.Sprintf("%v@%v", state.slots[slot], state.LocString(pending.pieces[i]))) + } + state.logf("Add entry for %v: \tb%vv%v-b%vv%v = \t%v\n", state.vars[varID], pending.startBlock, pending.startValue, endBlock, endValue, strings.Join(partStrs, " ")) + } + + for i, slotID := range state.varSlots[varID] { + loc := pending.pieces[i] + slot := state.slots[slotID] + + if !loc.absent() { + if loc.onStack() { + if loc.stackOffsetValue() == 0 { + list = append(list, dwarf.DW_OP_call_frame_cfa) + } else { + list = append(list, dwarf.DW_OP_fbreg) + list = dwarf.AppendSleb128(list, int64(loc.stackOffsetValue())) + } + } else { + regnum := state.ctxt.Arch.DWARFRegisters[state.registers[firstReg(loc.Registers)].ObjNum()] + if regnum < 32 { + list = append(list, dwarf.DW_OP_reg0+byte(regnum)) + } else { + list = append(list, dwarf.DW_OP_regx) + list = dwarf.AppendUleb128(list, uint64(regnum)) + } + } + } + + if len(state.varSlots[varID]) > 1 { + list = append(list, dwarf.DW_OP_piece) + list = dwarf.AppendUleb128(list, uint64(slot.Type.Size())) + } + } + state.ctxt.Arch.ByteOrder.PutUint16(list[sizeIdx:], uint16(len(list)-sizeIdx-2)) + state.lists[varID] = list +} + +// PutLocationList adds list (a location list in its intermediate +// representation) to listSym. +func (debugInfo *FuncDebug) PutLocationList(list []byte, ctxt *obj.Link, listSym, startPC *obj.LSym) { + if buildcfg.Experiment.Dwarf5 { + debugInfo.PutLocationListDwarf5(list, ctxt, listSym, startPC) + } else { + debugInfo.PutLocationListDwarf4(list, ctxt, listSym, startPC) + } +} + +// PutLocationListDwarf5 adds list (a location list in its intermediate +// representation) to listSym in DWARF 5 format. NB: this is a somewhat +// hacky implementation in that it actually reads a DWARF4 encoded +// info from list (with all its DWARF4-specific quirks) then re-encodes +// it in DWARF5. It would probably be better at some point to have +// ssa/debug encode the list in a version-independent form and then +// have this func (and PutLocationListDwarf4) intoduce the quirks. +func (debugInfo *FuncDebug) PutLocationListDwarf5(list []byte, ctxt *obj.Link, listSym, startPC *obj.LSym) { + getPC := debugInfo.GetPC + + // base address entry + listSym.WriteInt(ctxt, listSym.Size, 1, dwarf.DW_LLE_base_addressx) + listSym.WriteDwTxtAddrx(ctxt, listSym.Size, startPC, ctxt.DwTextCount*2) + + var stbuf, enbuf [10]byte + stb, enb := stbuf[:], enbuf[:] + // Re-read list, translating its address from block/value ID to PC. + for i := 0; i < len(list); { + begin := getPC(decodeValue(ctxt, readPtr(ctxt, list[i:]))) + end := getPC(decodeValue(ctxt, readPtr(ctxt, list[i+ctxt.Arch.PtrSize:]))) + + // Write LLE_offset_pair tag followed by payload (ULEB for start + // and then end). + listSym.WriteInt(ctxt, listSym.Size, 1, dwarf.DW_LLE_offset_pair) + stb, enb = stb[:0], enb[:0] + stb = dwarf.AppendUleb128(stb, uint64(begin)) + enb = dwarf.AppendUleb128(enb, uint64(end)) + listSym.WriteBytes(ctxt, listSym.Size, stb) + listSym.WriteBytes(ctxt, listSym.Size, enb) + + // The encoded data in "list" is in DWARF4 format, which uses + // a 2-byte length; DWARF5 uses an LEB-encoded value for this + // length. Read the length and then re-encode it. + i += 2 * ctxt.Arch.PtrSize + datalen := int(ctxt.Arch.ByteOrder.Uint16(list[i:])) + i += 2 + stb = stb[:0] + stb = dwarf.AppendUleb128(stb, uint64(datalen)) + listSym.WriteBytes(ctxt, listSym.Size, stb) // copy length + listSym.WriteBytes(ctxt, listSym.Size, list[i:i+datalen]) // loc desc + + i += datalen + } + + // Terminator + listSym.WriteInt(ctxt, listSym.Size, 1, dwarf.DW_LLE_end_of_list) +} + +// PutLocationListDwarf4 adds list (a location list in its intermediate +// representation) to listSym in DWARF 4 format. +func (debugInfo *FuncDebug) PutLocationListDwarf4(list []byte, ctxt *obj.Link, listSym, startPC *obj.LSym) { + getPC := debugInfo.GetPC + + if ctxt.UseBASEntries { + listSym.WriteInt(ctxt, listSym.Size, ctxt.Arch.PtrSize, ^0) + listSym.WriteAddr(ctxt, listSym.Size, ctxt.Arch.PtrSize, startPC, 0) + } + + // Re-read list, translating its address from block/value ID to PC. + for i := 0; i < len(list); { + begin := getPC(decodeValue(ctxt, readPtr(ctxt, list[i:]))) + end := getPC(decodeValue(ctxt, readPtr(ctxt, list[i+ctxt.Arch.PtrSize:]))) + + // Horrible hack. If a range contains only zero-width + // instructions, e.g. an Arg, and it's at the beginning of the + // function, this would be indistinguishable from an + // end entry. Fudge it. + if begin == 0 && end == 0 { + end = 1 + } + + if ctxt.UseBASEntries { + listSym.WriteInt(ctxt, listSym.Size, ctxt.Arch.PtrSize, begin) + listSym.WriteInt(ctxt, listSym.Size, ctxt.Arch.PtrSize, end) + } else { + listSym.WriteCURelativeAddr(ctxt, listSym.Size, startPC, begin) + listSym.WriteCURelativeAddr(ctxt, listSym.Size, startPC, end) + } + + i += 2 * ctxt.Arch.PtrSize + datalen := 2 + int(ctxt.Arch.ByteOrder.Uint16(list[i:])) + listSym.WriteBytes(ctxt, listSym.Size, list[i:i+datalen]) // copy datalen and location encoding + i += datalen + } + + // Location list contents, now with real PCs. + // End entry. + listSym.WriteInt(ctxt, listSym.Size, ctxt.Arch.PtrSize, 0) + listSym.WriteInt(ctxt, listSym.Size, ctxt.Arch.PtrSize, 0) +} + +// Pack a value and block ID into an address-sized uint, returning +// encoded value and boolean indicating whether the encoding succeeded. +// For 32-bit architectures the process may fail for very large +// procedures(the theory being that it's ok to have degraded debug +// quality in this case). +func encodeValue(ctxt *obj.Link, b, v ID) (uint64, bool) { + if ctxt.Arch.PtrSize == 8 { + result := uint64(b)<<32 | uint64(uint32(v)) + //ctxt.Logf("b %#x (%d) v %#x (%d) -> %#x\n", b, b, v, v, result) + return result, true + } + if ctxt.Arch.PtrSize != 4 { + panic("unexpected pointer size") + } + if ID(int16(b)) != b || ID(int16(v)) != v { + return 0, false + } + return uint64(b)<<16 | uint64(uint16(v)), true +} + +// Unpack a value and block ID encoded by encodeValue. +func decodeValue(ctxt *obj.Link, word uint64) (ID, ID) { + if ctxt.Arch.PtrSize == 8 { + b, v := ID(word>>32), ID(word) + //ctxt.Logf("%#x -> b %#x (%d) v %#x (%d)\n", word, b, b, v, v) + return b, v + } + if ctxt.Arch.PtrSize != 4 { + panic("unexpected pointer size") + } + return ID(word >> 16), ID(int16(word)) +} + +// Append a pointer-sized uint to buf. +func appendPtr(ctxt *obj.Link, buf []byte, word uint64) []byte { + if cap(buf) < len(buf)+20 { + b := make([]byte, len(buf), 20+cap(buf)*2) + copy(b, buf) + buf = b + } + writeAt := len(buf) + buf = buf[0 : len(buf)+ctxt.Arch.PtrSize] + writePtr(ctxt, buf[writeAt:], word) + return buf +} + +// Write a pointer-sized uint to the beginning of buf. +func writePtr(ctxt *obj.Link, buf []byte, word uint64) { + switch ctxt.Arch.PtrSize { + case 4: + ctxt.Arch.ByteOrder.PutUint32(buf, uint32(word)) + case 8: + ctxt.Arch.ByteOrder.PutUint64(buf, word) + default: + panic("unexpected pointer size") + } + +} + +// Read a pointer-sized uint from the beginning of buf. +func readPtr(ctxt *obj.Link, buf []byte) uint64 { + switch ctxt.Arch.PtrSize { + case 4: + return uint64(ctxt.Arch.ByteOrder.Uint32(buf)) + case 8: + return ctxt.Arch.ByteOrder.Uint64(buf) + default: + panic("unexpected pointer size") + } + +} + +// SetupLocList creates the initial portion of a location list for a +// user variable. It emits the encoded start/end of the range and a +// placeholder for the size. Return value is the new list plus the +// slot in the list holding the size (to be updated later). +func SetupLocList(ctxt *obj.Link, entryID ID, list []byte, st, en ID) ([]byte, int) { + start, startOK := encodeValue(ctxt, entryID, st) + end, endOK := encodeValue(ctxt, entryID, en) + if !startOK || !endOK { + // This could happen if someone writes a function that uses + // >65K values on a 32-bit platform. Hopefully a degraded debugging + // experience is ok in that case. + return nil, 0 + } + list = appendPtr(ctxt, list, start) + list = appendPtr(ctxt, list, end) + + // Where to write the length of the location description once + // we know how big it is. + sizeIdx := len(list) + list = list[:len(list)+2] + return list, sizeIdx +} + +// locatePrologEnd walks the entry block of a function with incoming +// register arguments and locates the last instruction in the prolog +// that spills a register arg. It returns the ID of that instruction, +// and (where appropriate) the prolog's lowered closure ptr store inst. +// +// Example: +// +// b1: +// v3 = ArgIntReg {p1+0} [0] : AX +// ... more arg regs .. +// v4 = ArgFloatReg {f1+0} [0] : X0 +// v52 = MOVQstore {p1} v2 v3 v1 +// ... more stores ... +// v68 = MOVSSstore {f4} v2 v67 v66 +// v38 = MOVQstoreconst {blob} [val=0,off=0] v2 v32 +// +// Important: locatePrologEnd is expected to work properly only with +// optimization turned off (e.g. "-N"). If optimization is enabled +// we can't be assured of finding all input arguments spilled in the +// entry block prolog. +func locatePrologEnd(f *Func, needCloCtx bool) (ID, *Value) { + + // returns true if this instruction looks like it moves an ABI + // register (or context register for rangefunc bodies) to the + // stack, along with the value being stored. + isRegMoveLike := func(v *Value) (bool, ID) { + n, ok := v.Aux.(*ir.Name) + var r ID + if (!ok || n.Class != ir.PPARAM) && !needCloCtx { + return false, r + } + regInputs, memInputs, spInputs := 0, 0, 0 + for _, a := range v.Args { + if a.Op == OpArgIntReg || a.Op == OpArgFloatReg || + (needCloCtx && a.Op.isLoweredGetClosurePtr()) { + regInputs++ + r = a.ID + } else if a.Type.IsMemory() { + memInputs++ + } else if a.Op == OpSP { + spInputs++ + } else { + return false, r + } + } + return v.Type.IsMemory() && memInputs == 1 && + regInputs == 1 && spInputs == 1, r + } + + // OpArg*Reg values we've seen so far on our forward walk, + // for which we have not yet seen a corresponding spill. + regArgs := make([]ID, 0, 32) + + // removeReg tries to remove a value from regArgs, returning true + // if found and removed, or false otherwise. + removeReg := func(r ID) bool { + for i := 0; i < len(regArgs); i++ { + if regArgs[i] == r { + regArgs = slices.Delete(regArgs, i, i+1) + return true + } + } + return false + } + + // Walk forwards through the block. When we see OpArg*Reg, record + // the value it produces in the regArgs list. When see a store that uses + // the value, remove the entry. When we hit the last store (use) + // then we've arrived at the end of the prolog. + var cloRegStore *Value + for k, v := range f.Entry.Values { + if v.Op == OpArgIntReg || v.Op == OpArgFloatReg { + regArgs = append(regArgs, v.ID) + continue + } + if needCloCtx && v.Op.isLoweredGetClosurePtr() { + regArgs = append(regArgs, v.ID) + cloRegStore = v + continue + } + if ok, r := isRegMoveLike(v); ok { + if removed := removeReg(r); removed { + if len(regArgs) == 0 { + // Found our last spill; return the value after + // it. Note that it is possible that this spill is + // the last instruction in the block. If so, then + // return the "end of block" sentinel. + if k < len(f.Entry.Values)-1 { + return f.Entry.Values[k+1].ID, cloRegStore + } + return BlockEnd.ID, cloRegStore + } + } + } + if v.Op.IsCall() { + // if we hit a call, we've gone too far. + return v.ID, cloRegStore + } + } + // nothing found + return ID(-1), cloRegStore +} + +// isNamedRegParam returns true if the param corresponding to "p" +// is a named, non-blank input parameter assigned to one or more +// registers. +func isNamedRegParam(p abi.ABIParamAssignment) bool { + if p.Name == nil { + return false + } + n := p.Name + if n.Sym() == nil || n.Sym().IsBlank() { + return false + } + if len(p.Registers) == 0 { + return false + } + return true +} + +// BuildFuncDebugNoOptimized populates a FuncDebug object "rval" with +// entries corresponding to the register-resident input parameters for +// the function "f"; it is used when we are compiling without +// optimization but the register ABI is enabled. For each reg param, +// it constructs a 2-element location list: the first element holds +// the input register, and the second element holds the stack location +// of the param (the assumption being that when optimization is off, +// each input param reg will be spilled in the prolog). In addition +// to the register params, here we also build location lists (where +// appropriate for the ".closureptr" compiler-synthesized variable +// needed by the debugger for range func bodies. +func BuildFuncDebugNoOptimized(ctxt *obj.Link, f *Func, loggingEnabled bool, stackOffset func(LocalSlot) int32, rval *FuncDebug) { + needCloCtx := f.CloSlot != nil + pri := f.ABISelf.ABIAnalyzeFuncType(f.Type) + + // Look to see if we have any named register-promoted parameters, + // and/or whether we need location info for the ".closureptr" + // synthetic variable; if not bail early and let the caller sort + // things out for the remainder of the params/locals. + numRegParams := 0 + for _, inp := range pri.InParams() { + if isNamedRegParam(inp) { + numRegParams++ + } + } + if numRegParams == 0 && !needCloCtx { + return + } + + state := debugState{f: f} + + if loggingEnabled { + state.logf("generating -N reg param loc lists for func %q\n", f.Name) + } + + // cloReg stores the obj register num that the context register + // appears in within the function prolog, where appropriate. + var cloReg int16 + + extraForCloCtx := 0 + if needCloCtx { + extraForCloCtx = 1 + } + + // Allocate location lists. + rval.LocationLists = make([][]byte, numRegParams+extraForCloCtx) + + // Locate the value corresponding to the last spill of + // an input register. + afterPrologVal, cloRegStore := locatePrologEnd(f, needCloCtx) + + if needCloCtx { + reg, _ := state.f.getHome(cloRegStore.ID).(*Register) + cloReg = reg.ObjNum() + if loggingEnabled { + state.logf("needCloCtx is true for func %q, cloreg=%v\n", + f.Name, reg) + } + } + + addVarSlot := func(name *ir.Name, typ *types.Type) { + sl := LocalSlot{N: name, Type: typ, Off: 0} + rval.Vars = append(rval.Vars, name) + rval.Slots = append(rval.Slots, sl) + slid := len(rval.VarSlots) + rval.VarSlots = append(rval.VarSlots, []SlotID{SlotID(slid)}) + } + + // Make an initial pass to populate the vars/slots for our return + // value, covering first the input parameters and then (if needed) + // the special ".closureptr" var for rangefunc bodies. + params := []abi.ABIParamAssignment{} + for _, inp := range pri.InParams() { + if !isNamedRegParam(inp) { + // will be sorted out elsewhere + continue + } + if !IsVarWantedForDebug(inp.Name) { + continue + } + addVarSlot(inp.Name, inp.Type) + params = append(params, inp) + } + if needCloCtx { + addVarSlot(f.CloSlot, f.CloSlot.Type()) + cloAssign := abi.ABIParamAssignment{ + Type: f.CloSlot.Type(), + Name: f.CloSlot, + Registers: []abi.RegIndex{0}, // dummy + } + params = append(params, cloAssign) + } + + // Walk the input params again and process the register-resident elements. + pidx := 0 + for _, inp := range params { + if !isNamedRegParam(inp) { + // will be sorted out elsewhere + continue + } + if !IsVarWantedForDebug(inp.Name) { + continue + } + + sl := rval.Slots[pidx] + n := rval.Vars[pidx] + + if afterPrologVal == ID(-1) { + // This can happen for degenerate functions with infinite + // loops such as that in issue 45948. In such cases, leave + // the var/slot set up for the param, but don't try to + // emit a location list. + if loggingEnabled { + state.logf("locatePrologEnd failed, skipping %v\n", n) + } + pidx++ + continue + } + + // Param is arriving in one or more registers. We need a 2-element + // location expression for it. First entry in location list + // will correspond to lifetime in input registers. + list, sizeIdx := SetupLocList(ctxt, f.Entry.ID, rval.LocationLists[pidx], + BlockStart.ID, afterPrologVal) + if list == nil { + pidx++ + continue + } + if loggingEnabled { + state.logf("param %v:\n [, %d]:\n", n, afterPrologVal) + } + rtypes, _ := inp.RegisterTypesAndOffsets() + padding := make([]uint64, 0, 32) + padding = inp.ComputePadding(padding) + for k, r := range inp.Registers { + var reg int16 + if n == f.CloSlot { + reg = cloReg + } else { + reg = ObjRegForAbiReg(r, f.Config) + } + dwreg := ctxt.Arch.DWARFRegisters[reg] + if dwreg < 32 { + list = append(list, dwarf.DW_OP_reg0+byte(dwreg)) + } else { + list = append(list, dwarf.DW_OP_regx) + list = dwarf.AppendUleb128(list, uint64(dwreg)) + } + if loggingEnabled { + state.logf(" piece %d -> dwreg %d", k, dwreg) + } + if len(inp.Registers) > 1 { + list = append(list, dwarf.DW_OP_piece) + ts := rtypes[k].Size() + list = dwarf.AppendUleb128(list, uint64(ts)) + if padding[k] > 0 { + if loggingEnabled { + state.logf(" [pad %d bytes]", padding[k]) + } + list = append(list, dwarf.DW_OP_piece) + list = dwarf.AppendUleb128(list, padding[k]) + } + } + if loggingEnabled { + state.logf("\n") + } + } + // fill in length of location expression element + ctxt.Arch.ByteOrder.PutUint16(list[sizeIdx:], uint16(len(list)-sizeIdx-2)) + + // Second entry in the location list will be the stack home + // of the param, once it has been spilled. Emit that now. + list, sizeIdx = SetupLocList(ctxt, f.Entry.ID, list, + afterPrologVal, FuncEnd.ID) + if list == nil { + pidx++ + continue + } + soff := stackOffset(sl) + if soff == 0 { + list = append(list, dwarf.DW_OP_call_frame_cfa) + } else { + list = append(list, dwarf.DW_OP_fbreg) + list = dwarf.AppendSleb128(list, int64(soff)) + } + if loggingEnabled { + state.logf(" [%d, ): stackOffset=%d\n", afterPrologVal, soff) + } + + // fill in size + ctxt.Arch.ByteOrder.PutUint16(list[sizeIdx:], uint16(len(list)-sizeIdx-2)) + + rval.LocationLists[pidx] = list + pidx++ + } +} + +// IsVarWantedForDebug returns true if the debug info for the node should +// be generated. +// For example, internal variables for range-over-func loops have little +// value to users, so we don't generate debug info for them. +func IsVarWantedForDebug(n ir.Node) bool { + name := n.Sym().Name + if len(name) > 0 && name[0] == '&' { + name = name[1:] + } + if len(name) > 0 && name[0] == '#' { + // #yield is used by delve. + return strings.HasPrefix(name, "#yield") + } + return true +} diff --git a/go/src/cmd/compile/internal/ssa/debug_lines_test.go b/go/src/cmd/compile/internal/ssa/debug_lines_test.go new file mode 100644 index 0000000000000000000000000000000000000000..5dbfdeb7f6ee4c941b989ef6b12595e854debf58 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/debug_lines_test.go @@ -0,0 +1,293 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa_test + +import ( + "bufio" + "bytes" + "cmp" + "flag" + "fmt" + "internal/testenv" + "os" + "path/filepath" + "reflect" + "regexp" + "runtime" + "slices" + "strconv" + "strings" + "testing" +) + +// Matches lines in genssa output that are marked "isstmt", and the parenthesized plus-prefixed line number is a submatch +var asmLine *regexp.Regexp = regexp.MustCompile(`^\s[vb]\d+\s+\d+\s\(\+(\d+)\)`) + +// this matches e.g. ` v123456789 000007 (+9876654310) MOVUPS X15, ""..autotmp_2-32(SP)` + +// Matches lines in genssa output that describe an inlined file. +// Note it expects an unadventurous choice of basename. +var sepRE = regexp.QuoteMeta(string(filepath.Separator)) +var inlineLine *regexp.Regexp = regexp.MustCompile(`^#\s.*` + sepRE + `[-\w]+\.go:(\d+)`) + +// this matches e.g. # /pa/inline-dumpxxxx.go:6 + +var testGoArchFlag = flag.String("arch", "", "run test for specified architecture") + +func testGoArch() string { + if *testGoArchFlag == "" { + return runtime.GOARCH + } + return *testGoArchFlag +} + +func hasRegisterABI() bool { + switch testGoArch() { + case "amd64", "arm64", "loong64", "ppc64", "ppc64le", "riscv", "s390x": + return true + } + return false +} + +func unixOnly(t *testing.T) { + if runtime.GOOS != "linux" && runtime.GOOS != "darwin" { // in particular, it could be windows. + t.Skip("this test depends on creating a file with a wonky name, only works for sure on Linux and Darwin") + } +} + +// testDebugLinesDefault removes the first wanted statement on architectures that are not (yet) register ABI. +func testDebugLinesDefault(t *testing.T, gcflags, file, function string, wantStmts []int, ignoreRepeats bool) { + unixOnly(t) + if !hasRegisterABI() { + wantStmts = wantStmts[1:] + } + testDebugLines(t, gcflags, file, function, wantStmts, ignoreRepeats) +} + +func TestDebugLinesSayHi(t *testing.T) { + // This test is potentially fragile, the goal is that debugging should step properly through "sayhi" + // If the blocks are reordered in a way that changes the statement order but execution flows correctly, + // then rearrange the expected numbers. Register abi and not-register-abi also have different sequences, + // at least for now. + + testDebugLinesDefault(t, "-N -l", "sayhi.go", "sayhi", []int{8, 9, 10, 11}, false) +} + +func TestDebugLinesPushback(t *testing.T) { + unixOnly(t) + + switch testGoArch() { + default: + t.Skip("skipped for many architectures") + + case "arm64", "amd64", "loong64": // register ABI + fn := "(*List[go.shape.int]).PushBack" + testDebugLines(t, "-N -l", "pushback.go", fn, []int{17, 18, 19, 20, 21, 22, 24}, true) + } +} + +func TestDebugLinesConvert(t *testing.T) { + unixOnly(t) + + switch testGoArch() { + default: + t.Skip("skipped for many architectures") + + case "arm64", "amd64", "loong64": // register ABI + fn := "G[go.shape.int]" + testDebugLines(t, "-N -l", "convertline.go", fn, []int{9, 10, 11}, true) + } +} + +func TestInlineLines(t *testing.T) { + if runtime.GOARCH != "amd64" && *testGoArchFlag == "" { + // As of september 2021, works for everything except mips64, but still potentially fragile + t.Skip("only runs for amd64 unless -arch explicitly supplied") + } + + want := [][]int{{3}, {4, 10}, {4, 10, 16}, {4, 10}, {4, 11, 16}, {4, 11}, {4}, {5, 10}, {5, 10, 16}, {5, 10}, {5, 11, 16}, {5, 11}, {5}} + testInlineStack(t, "inline-dump.go", "f", want) +} + +func TestDebugLines_53456(t *testing.T) { + testDebugLinesDefault(t, "-N -l", "b53456.go", "(*T).Inc", []int{15, 16, 17, 18}, true) +} + +func TestDebugLines_74576(t *testing.T) { + unixOnly(t) + + switch testGoArch() { + default: + // Failed on linux/riscv64 (issue 74669), but conservatively + // skip many architectures like several other tests here. + t.Skip("skipped for many architectures") + + case "arm64", "amd64", "loong64": + tests := []struct { + file string + wantStmts []int + }{ + {"i74576a.go", []int{12, 13, 13, 14}}, + {"i74576b.go", []int{12, 13, 13, 14}}, + {"i74576c.go", []int{12, 13, 13, 14}}, + } + t.Parallel() + for _, test := range tests { + t.Run(test.file, func(t *testing.T) { + t.Parallel() + testDebugLines(t, "-N -l", test.file, "main", test.wantStmts, false) + }) + } + } +} + +func compileAndDump(t *testing.T, file, function, moreGCFlags string) []byte { + testenv.MustHaveGoBuild(t) + + tmpdir, err := os.MkdirTemp("", "debug_lines_test") + if err != nil { + panic(fmt.Sprintf("Problem creating TempDir, error %v", err)) + } + if testing.Verbose() { + fmt.Printf("Preserving temporary directory %s\n", tmpdir) + } else { + defer os.RemoveAll(tmpdir) + } + + source, err := filepath.Abs(filepath.Join("testdata", file)) + if err != nil { + panic(fmt.Sprintf("Could not get abspath of testdata directory and file, %v", err)) + } + + cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-o", "foo.o", "-gcflags=-d=ssa/genssa/dump="+function+" "+moreGCFlags, source) + cmd.Dir = tmpdir + cmd.Env = replaceEnv(cmd.Env, "GOSSADIR", tmpdir) + testGoos := "linux" // default to linux + if testGoArch() == "wasm" { + testGoos = "js" + } + cmd.Env = replaceEnv(cmd.Env, "GOOS", testGoos) + cmd.Env = replaceEnv(cmd.Env, "GOARCH", testGoArch()) + + if testing.Verbose() { + fmt.Printf("About to run %s\n", asCommandLine("", cmd)) + } + + var stdout, stderr strings.Builder + cmd.Stdout = &stdout + cmd.Stderr = &stderr + + if err := cmd.Run(); err != nil { + t.Fatalf("error running cmd %s: %v\nstdout:\n%sstderr:\n%s\n", asCommandLine("", cmd), err, stdout.String(), stderr.String()) + } + + if s := stderr.String(); s != "" { + t.Fatalf("Wanted empty stderr, instead got:\n%s\n", s) + } + + dumpFile := filepath.Join(tmpdir, function+"_01__genssa.dump") + dumpBytes, err := os.ReadFile(dumpFile) + if err != nil { + t.Fatalf("Could not read dump file %s, err=%v", dumpFile, err) + } + return dumpBytes +} + +func sortInlineStacks(x [][]int) { + slices.SortFunc(x, func(a, b []int) int { + if len(a) != len(b) { + return cmp.Compare(len(a), len(b)) + } + for k := range a { + if a[k] != b[k] { + return cmp.Compare(a[k], b[k]) + } + } + return 0 + }) +} + +// testInlineStack ensures that inlining is described properly in the comments in the dump file +func testInlineStack(t *testing.T, file, function string, wantStacks [][]int) { + // this is an inlining reporting test, not an optimization test. -N makes it less fragile + dumpBytes := compileAndDump(t, file, function, "-N") + dump := bufio.NewScanner(bytes.NewReader(dumpBytes)) + dumpLineNum := 0 + var gotStmts []int + var gotStacks [][]int + for dump.Scan() { + line := dump.Text() + dumpLineNum++ + matches := inlineLine.FindStringSubmatch(line) + if len(matches) == 2 { + stmt, err := strconv.ParseInt(matches[1], 10, 32) + if err != nil { + t.Fatalf("Expected to parse a line number but saw %s instead on dump line #%d, error %v", matches[1], dumpLineNum, err) + } + if testing.Verbose() { + fmt.Printf("Saw stmt# %d for submatch '%s' on dump line #%d = '%s'\n", stmt, matches[1], dumpLineNum, line) + } + gotStmts = append(gotStmts, int(stmt)) + } else if len(gotStmts) > 0 { + gotStacks = append(gotStacks, gotStmts) + gotStmts = nil + } + } + if len(gotStmts) > 0 { + gotStacks = append(gotStacks, gotStmts) + gotStmts = nil + } + sortInlineStacks(gotStacks) + sortInlineStacks(wantStacks) + if !reflect.DeepEqual(wantStacks, gotStacks) { + t.Errorf("wanted inlines %+v but got %+v\n%s", wantStacks, gotStacks, dumpBytes) + } + +} + +// testDebugLines compiles testdata/ with flags -N -l and -d=ssa/genssa/dump= +// then verifies that the statement-marked lines in that file are the same as those in wantStmts +// These files must all be short because this is super-fragile. +// "go build" is run in a temporary directory that is normally deleted, unless -test.v +// +// TODO: the tests calling this are somewhat expensive; perhaps more tests can be marked t.Parallel, +// or perhaps the mechanism here can be made more efficient. +func testDebugLines(t *testing.T, gcflags, file, function string, wantStmts []int, ignoreRepeats bool) { + dumpBytes := compileAndDump(t, file, function, gcflags) + dump := bufio.NewScanner(bytes.NewReader(dumpBytes)) + var gotStmts []int + dumpLineNum := 0 + for dump.Scan() { + line := dump.Text() + dumpLineNum++ + matches := asmLine.FindStringSubmatch(line) + if len(matches) == 2 { + stmt, err := strconv.ParseInt(matches[1], 10, 32) + if err != nil { + t.Fatalf("Expected to parse a line number but saw %s instead on dump line #%d, error %v", matches[1], dumpLineNum, err) + } + if testing.Verbose() { + fmt.Printf("Saw stmt# %d for submatch '%s' on dump line #%d = '%s'\n", stmt, matches[1], dumpLineNum, line) + } + gotStmts = append(gotStmts, int(stmt)) + } + } + if ignoreRepeats { // remove repeats from gotStmts + newGotStmts := []int{gotStmts[0]} + for _, x := range gotStmts { + if x != newGotStmts[len(newGotStmts)-1] { + newGotStmts = append(newGotStmts, x) + } + } + if !reflect.DeepEqual(wantStmts, newGotStmts) { + t.Errorf("wanted stmts %v but got %v (with repeats still in: %v)", wantStmts, newGotStmts, gotStmts) + } + + } else { + if !reflect.DeepEqual(wantStmts, gotStmts) { + t.Errorf("wanted stmts %v but got %v", wantStmts, gotStmts) + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/debug_test.go b/go/src/cmd/compile/internal/ssa/debug_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6dced6edc8151719cae418d2137b10a24c282b54 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/debug_test.go @@ -0,0 +1,1016 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa_test + +import ( + "flag" + "fmt" + "internal/testenv" + "io" + "os" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "strconv" + "strings" + "testing" + "time" +) + +var ( + update = flag.Bool("u", false, "update test reference files") + verbose = flag.Bool("v", false, "print debugger interactions (very verbose)") + dryrun = flag.Bool("n", false, "just print the command line and first debugging bits") + useGdb = flag.Bool("g", false, "use Gdb instead of Delve (dlv), use gdb reference files") + force = flag.Bool("f", false, "force run under not linux-amd64; also do not use tempdir") + repeats = flag.Bool("r", false, "detect repeats in debug steps and don't ignore them") + inlines = flag.Bool("i", false, "do inlining for gdb (makes testing flaky till inlining info is correct)") +) + +var ( + hexRe = regexp.MustCompile("0x[a-zA-Z0-9]+") + numRe = regexp.MustCompile(`-?\d+`) + stringRe = regexp.MustCompile(`([^\"]|(\.))*`) + leadingDollarNumberRe = regexp.MustCompile(`^[$]\d+`) + optOutGdbRe = regexp.MustCompile("[<]optimized out[>]") + numberColonRe = regexp.MustCompile(`^ *\d+:`) +) + +var gdb = "gdb" // Might be "ggdb" on Darwin, because gdb no longer part of XCode +var debugger = "dlv" // For naming files, etc. + +var gogcflags = os.Getenv("GO_GCFLAGS") + +// optimizedLibs usually means "not running in a noopt test builder". +var optimizedLibs = (!strings.Contains(gogcflags, "-N") && !strings.Contains(gogcflags, "-l")) + +// TestNexting go-builds a file, then uses a debugger (default delve, optionally gdb) +// to next through the generated executable, recording each line landed at, and +// then compares those lines with reference file(s). +// Flag -u updates the reference file(s). +// Flag -g changes the debugger to gdb (and uses gdb-specific reference files) +// Flag -v is ever-so-slightly verbose. +// Flag -n is for dry-run, and prints the shell and first debug commands. +// +// Because this test (combined with existing compiler deficiencies) is flaky, +// for gdb-based testing by default inlining is disabled +// (otherwise output depends on library internals) +// and for both gdb and dlv by default repeated lines in the next stream are ignored +// (because this appears to be timing-dependent in gdb, and the cleanest fix is in code common to gdb and dlv). +// +// Also by default, any source code outside of .../testdata/ is not mentioned +// in the debugging histories. This deals both with inlined library code once +// the compiler is generating clean inline records, and also deals with +// runtime code between return from main and process exit. This is hidden +// so that those files (in the runtime/library) can change without affecting +// this test. +// +// These choices can be reversed with -i (inlining on) and -r (repeats detected) which +// will also cause their own failures against the expected outputs. Note that if the compiler +// and debugger were behaving properly, the inlined code and repeated lines would not appear, +// so the expected output is closer to what we hope to see, though it also encodes all our +// current bugs. +// +// The file being tested may contain comments of the form +// //DBG-TAG=(v1,v2,v3) +// where DBG = {gdb,dlv} and TAG={dbg,opt} +// each variable may optionally be followed by a / and one or more of S,A,N,O +// to indicate normalization of Strings, (hex) addresses, and numbers. +// "O" is an explicit indication that we expect it to be optimized out. +// For example: +// +// if len(os.Args) > 1 { //gdb-dbg=(hist/A,cannedInput/A) //dlv-dbg=(hist/A,cannedInput/A) +// +// TODO: not implemented for Delve yet, but this is the plan +// +// After a compiler change that causes a difference in the debug behavior, check +// to see if it is sensible or not, and if it is, update the reference files with +// go test debug_test.go -args -u +// (for Delve) +// go test debug_test.go -args -u -d +func TestNexting(t *testing.T) { + testenv.SkipFlaky(t, 37404) + + skipReasons := "" // Many possible skip reasons, list all that apply + if testing.Short() { + skipReasons = "not run in short mode; " + } + testenv.MustHaveGoBuild(t) + + if *useGdb && !*force && !(runtime.GOOS == "linux" && runtime.GOARCH == "amd64") { + // Running gdb on OSX/darwin is very flaky. + // Sometimes it is called ggdb, depending on how it is installed. + // It also sometimes requires an admin password typed into a dialog box. + // Various architectures tend to differ slightly sometimes, and keeping them + // all in sync is a pain for people who don't have them all at hand, + // so limit testing to amd64 (for now) + skipReasons += "not run when testing gdb (-g) unless forced (-f) or linux-amd64; " + } + + if !*useGdb && !*force && testenv.Builder() == "linux-386-longtest" { + // The latest version of Delve does support linux/386. However, the version currently + // installed in the linux-386-longtest builder does not. See golang.org/issue/39309. + skipReasons += "not run when testing delve on linux-386-longtest builder unless forced (-f); " + } + + if *useGdb { + debugger = "gdb" + _, err := exec.LookPath(gdb) + if err != nil { + if runtime.GOOS != "darwin" { + skipReasons += "not run because gdb not on path; " + } else { + // On Darwin, MacPorts installs gdb as "ggdb". + _, err = exec.LookPath("ggdb") + if err != nil { + skipReasons += "not run because gdb (and also ggdb) request by -g option not on path; " + } else { + gdb = "ggdb" + } + } + } + } else { // Delve + debugger = "dlv" + _, err := exec.LookPath("dlv") + if err != nil { + skipReasons += "not run because dlv not on path; " + } + } + + if skipReasons != "" { + t.Skip(skipReasons[:len(skipReasons)-2]) + } + + optFlags := "" // Whatever flags are needed to test debugging of optimized code. + dbgFlags := "-N -l" + if *useGdb && !*inlines { + // For gdb (default), disable inlining so that a compiler test does not depend on library code. + // TODO: Technically not necessary in 1.10 and later, but it causes a largish regression that needs investigation. + optFlags += " -l" + } + + moreargs := []string{} + if *useGdb && (runtime.GOOS == "darwin" || runtime.GOOS == "windows") { + // gdb and lldb on Darwin do not deal with compressed dwarf. + // also, Windows. + moreargs = append(moreargs, "-ldflags=-compressdwarf=false") + } + + subTest(t, debugger+"-dbg", "hist", dbgFlags, moreargs...) + subTest(t, debugger+"-dbg", "scopes", dbgFlags, moreargs...) + subTest(t, debugger+"-dbg", "i22558", dbgFlags, moreargs...) + + subTest(t, debugger+"-dbg-race", "i22600", dbgFlags, append(moreargs, "-race")...) + + optSubTest(t, debugger+"-opt", "hist", optFlags, 1000, moreargs...) + optSubTest(t, debugger+"-opt", "scopes", optFlags, 1000, moreargs...) + + // Was optSubtest, this test is observed flaky on Linux in Docker on (busy) macOS, probably because of timing + // glitches in this harness. + // TODO get rid of timing glitches in this harness. + skipSubTest(t, debugger+"-opt", "infloop", optFlags, 10, moreargs...) + +} + +// subTest creates a subtest that compiles basename.go with the specified gcflags and additional compiler arguments, +// then runs the debugger on the resulting binary, with any comment-specified actions matching tag triggered. +func subTest(t *testing.T, tag string, basename string, gcflags string, moreargs ...string) { + t.Run(tag+"-"+basename, func(t *testing.T) { + if t.Name() == "TestNexting/gdb-dbg-i22558" { + testenv.SkipFlaky(t, 31263) + } + testNexting(t, basename, tag, gcflags, 1000, moreargs...) + }) +} + +// skipSubTest is the same as subTest except that it skips the test if execution is not forced (-f) +func skipSubTest(t *testing.T, tag string, basename string, gcflags string, count int, moreargs ...string) { + t.Run(tag+"-"+basename, func(t *testing.T) { + if *force { + testNexting(t, basename, tag, gcflags, count, moreargs...) + } else { + t.Skip("skipping flaky test because not forced (-f)") + } + }) +} + +// optSubTest is the same as subTest except that it skips the test if the runtime and libraries +// were not compiled with optimization turned on. (The skip may not be necessary with Go 1.10 and later) +func optSubTest(t *testing.T, tag string, basename string, gcflags string, count int, moreargs ...string) { + // If optimized test is run with unoptimized libraries (compiled with -N -l), it is very likely to fail. + // This occurs in the noopt builders (for example). + t.Run(tag+"-"+basename, func(t *testing.T) { + if *force || optimizedLibs { + testNexting(t, basename, tag, gcflags, count, moreargs...) + } else { + t.Skip("skipping for unoptimized stdlib/runtime") + } + }) +} + +func testNexting(t *testing.T, base, tag, gcflags string, count int, moreArgs ...string) { + // (1) In testdata, build sample.go into test-sample. + // (2) Run debugger gathering a history + // (3) Read expected history from testdata/sample..nexts + // optionally, write out testdata/sample..nexts + + testbase := filepath.Join("testdata", base) + "." + tag + tmpbase := filepath.Join("testdata", "test-"+base+"."+tag) + + // Use a temporary directory unless -f is specified + if !*force { + tmpdir := t.TempDir() + tmpbase = filepath.Join(tmpdir, "test-"+base+"."+tag) + if *verbose { + fmt.Printf("Tempdir is %s\n", tmpdir) + } + } + exe := tmpbase + + runGoArgs := []string{"build", "-o", exe, "-gcflags=all=" + gcflags} + runGoArgs = append(runGoArgs, moreArgs...) + runGoArgs = append(runGoArgs, filepath.Join("testdata", base+".go")) + + runGo(t, "", runGoArgs...) + + nextlog := testbase + ".nexts" + tmplog := tmpbase + ".nexts" + var dbg dbgr + if *useGdb { + dbg = newGdb(t, tag, exe) + } else { + dbg = newDelve(t, tag, exe) + } + h1 := runDbgr(dbg, count) + if *dryrun { + fmt.Printf("# Tag for above is %s\n", dbg.tag()) + return + } + if *update { + h1.write(nextlog) + } else { + h0 := &nextHist{} + h0.read(nextlog) + if !h0.equals(h1) { + // Be very noisy about exactly what's wrong to simplify debugging. + h1.write(tmplog) + cmd := testenv.Command(t, "diff", "-u", nextlog, tmplog) + line := asCommandLine("", cmd) + bytes, err := cmd.CombinedOutput() + if err != nil && len(bytes) == 0 { + t.Fatalf("step/next histories differ, diff command %s failed with error=%v", line, err) + } + t.Fatalf("step/next histories differ, diff=\n%s", string(bytes)) + } + } +} + +type dbgr interface { + start() + stepnext(s string) bool // step or next, possible with parameter, gets line etc. returns true for success, false for unsure response + quit() + hist() *nextHist + tag() string +} + +func runDbgr(dbg dbgr, maxNext int) *nextHist { + dbg.start() + if *dryrun { + return nil + } + for i := 0; i < maxNext; i++ { + if !dbg.stepnext("n") { + break + } + } + dbg.quit() + h := dbg.hist() + return h +} + +func runGo(t *testing.T, dir string, args ...string) string { + var stdout, stderr strings.Builder + cmd := testenv.Command(t, testenv.GoToolPath(t), args...) + cmd.Dir = dir + if *dryrun { + fmt.Printf("%s\n", asCommandLine("", cmd)) + return "" + } + cmd.Stdout = &stdout + cmd.Stderr = &stderr + + if err := cmd.Run(); err != nil { + t.Fatalf("error running cmd (%s): %v\nstdout:\n%sstderr:\n%s\n", asCommandLine("", cmd), err, stdout.String(), stderr.String()) + } + + if s := stderr.String(); s != "" { + t.Fatalf("Stderr = %s\nWant empty", s) + } + + return stdout.String() +} + +// tstring provides two strings, o (stdout) and e (stderr) +type tstring struct { + o string + e string +} + +func (t tstring) String() string { + return t.o + t.e +} + +type pos struct { + line uint32 + file uint8 // Artifact of plans to implement differencing instead of calling out to diff. +} + +type nextHist struct { + f2i map[string]uint8 + fs []string + ps []pos + texts []string + vars [][]string +} + +func (h *nextHist) write(filename string) { + file, err := os.Create(filename) + if err != nil { + panic(fmt.Sprintf("Problem opening %s, error %v\n", filename, err)) + } + defer file.Close() + var lastfile uint8 + for i, x := range h.texts { + p := h.ps[i] + if lastfile != p.file { + fmt.Fprintf(file, " %s\n", h.fs[p.file-1]) + lastfile = p.file + } + fmt.Fprintf(file, "%d:%s\n", p.line, x) + // TODO, normalize between gdb and dlv into a common, comparable format. + for _, y := range h.vars[i] { + y = strings.TrimSpace(y) + fmt.Fprintf(file, "%s\n", y) + } + } + file.Close() +} + +func (h *nextHist) read(filename string) { + h.f2i = make(map[string]uint8) + bytes, err := os.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("Problem reading %s, error %v\n", filename, err)) + } + var lastfile string + lines := strings.Split(string(bytes), "\n") + for i, l := range lines { + if len(l) > 0 && l[0] != '#' { + if l[0] == ' ' { + // file -- first two characters expected to be " " + lastfile = strings.TrimSpace(l) + } else if numberColonRe.MatchString(l) { + // line number -- : + colonPos := strings.Index(l, ":") + if colonPos == -1 { + panic(fmt.Sprintf("Line %d (%s) in file %s expected to contain ':' but does not.\n", i+1, l, filename)) + } + h.add(lastfile, l[0:colonPos], l[colonPos+1:]) + } else { + h.addVar(l) + } + } + } +} + +// add appends file (name), line (number) and text (string) to the history, +// provided that the file+line combo does not repeat the previous position, +// and provided that the file is within the testdata directory. The return +// value indicates whether the append occurred. +func (h *nextHist) add(file, line, text string) bool { + // Only record source code in testdata unless the inlines flag is set + if !*inlines && !strings.Contains(file, "/testdata/") { + return false + } + fi := h.f2i[file] + if fi == 0 { + h.fs = append(h.fs, file) + fi = uint8(len(h.fs)) + h.f2i[file] = fi + } + + line = strings.TrimSpace(line) + var li int + var err error + if line != "" { + li, err = strconv.Atoi(line) + if err != nil { + panic(fmt.Sprintf("Non-numeric line: %s, error %v\n", line, err)) + } + } + l := len(h.ps) + p := pos{line: uint32(li), file: fi} + + if l == 0 || *repeats || h.ps[l-1] != p { + h.ps = append(h.ps, p) + h.texts = append(h.texts, text) + h.vars = append(h.vars, []string{}) + return true + } + return false +} + +func (h *nextHist) addVar(text string) { + l := len(h.texts) + h.vars[l-1] = append(h.vars[l-1], text) +} + +func invertMapSU8(hf2i map[string]uint8) map[uint8]string { + hi2f := make(map[uint8]string) + for hs, i := range hf2i { + hi2f[i] = hs + } + return hi2f +} + +func (h *nextHist) equals(k *nextHist) bool { + if len(h.f2i) != len(k.f2i) { + return false + } + if len(h.ps) != len(k.ps) { + return false + } + hi2f := invertMapSU8(h.f2i) + ki2f := invertMapSU8(k.f2i) + + for i, hs := range hi2f { + if hs != ki2f[i] { + return false + } + } + + for i, x := range h.ps { + if k.ps[i] != x { + return false + } + } + + for i, hv := range h.vars { + kv := k.vars[i] + if len(hv) != len(kv) { + return false + } + for j, hvt := range hv { + if hvt != kv[j] { + return false + } + } + } + + return true +} + +// canonFileName strips everything before "/src/" from a filename. +// This makes file names portable across different machines, +// home directories, and temporary directories. +func canonFileName(f string) string { + i := strings.Index(f, "/src/") + if i != -1 { + f = f[i+1:] + } + return f +} + +/* Delve */ + +type delveState struct { + cmd *exec.Cmd + tagg string + *ioState + atLineRe *regexp.Regexp // "\n =>" + funcFileLinePCre *regexp.Regexp // "^> ([^ ]+) ([^:]+):([0-9]+) .*[(]PC: (0x[a-z0-9]+)" + line string + file string + function string +} + +func newDelve(t testing.TB, tag, executable string, args ...string) dbgr { + cmd := testenv.Command(t, "dlv", "exec", executable) + cmd.Env = replaceEnv(cmd.Env, "TERM", "dumb") + if len(args) > 0 { + cmd.Args = append(cmd.Args, "--") + cmd.Args = append(cmd.Args, args...) + } + s := &delveState{tagg: tag, cmd: cmd} + // HAHA Delve has control characters embedded to change the color of the => and the line number + // that would be '(\\x1b\\[[0-9;]+m)?' OR TERM=dumb + s.atLineRe = regexp.MustCompile("\n=>[[:space:]]+[0-9]+:(.*)") + s.funcFileLinePCre = regexp.MustCompile("> ([^ ]+) ([^:]+):([0-9]+) .*[(]PC: (0x[a-z0-9]+)[)]\n") + s.ioState = newIoState(s.cmd) + return s +} + +func (s *delveState) tag() string { + return s.tagg +} + +func (s *delveState) stepnext(ss string) bool { + x := s.ioState.writeReadExpect(ss+"\n", "[(]dlv[)] ") + excerpts := s.atLineRe.FindStringSubmatch(x.o) + locations := s.funcFileLinePCre.FindStringSubmatch(x.o) + excerpt := "" + if len(excerpts) > 1 { + excerpt = excerpts[1] + } + if len(locations) > 0 { + fn := canonFileName(locations[2]) + if *verbose { + if s.file != fn { + fmt.Printf("%s\n", locations[2]) // don't canonocalize verbose logging + } + fmt.Printf(" %s\n", locations[3]) + } + s.line = locations[3] + s.file = fn + s.function = locations[1] + s.ioState.history.add(s.file, s.line, excerpt) + // TODO: here is where variable processing will be added. See gdbState.stepnext as a guide. + // Adding this may require some amount of normalization so that logs are comparable. + return true + } + if *verbose { + fmt.Printf("DID NOT MATCH EXPECTED NEXT OUTPUT\nO='%s'\nE='%s'\n", x.o, x.e) + } + return false +} + +func (s *delveState) start() { + if *dryrun { + fmt.Printf("%s\n", asCommandLine("", s.cmd)) + fmt.Printf("b main.test\n") + fmt.Printf("c\n") + return + } + err := s.cmd.Start() + if err != nil { + line := asCommandLine("", s.cmd) + panic(fmt.Sprintf("There was an error [start] running '%s', %v\n", line, err)) + } + s.ioState.readExpecting(-1, 5000, "Type 'help' for list of commands.") + s.ioState.writeReadExpect("b main.test\n", "[(]dlv[)] ") + s.stepnext("c") +} + +func (s *delveState) quit() { + expect("", s.ioState.writeRead("q\n")) +} + +/* Gdb */ + +type gdbState struct { + cmd *exec.Cmd + tagg string + args []string + *ioState + atLineRe *regexp.Regexp + funcFileLinePCre *regexp.Regexp + line string + file string + function string +} + +func newGdb(t testing.TB, tag, executable string, args ...string) dbgr { + // Turn off shell, necessary for Darwin apparently + cmd := testenv.Command(t, gdb, "-nx", + "-iex", fmt.Sprintf("add-auto-load-safe-path %s/src/runtime", runtime.GOROOT()), + "-ex", "set startup-with-shell off", executable) + cmd.Env = replaceEnv(cmd.Env, "TERM", "dumb") + s := &gdbState{tagg: tag, cmd: cmd, args: args} + s.atLineRe = regexp.MustCompile("(^|\n)([0-9]+)(.*)") + s.funcFileLinePCre = regexp.MustCompile( + `([^ ]+) [(][^)]*[)][ \t\n]+at ([^:]+):([0-9]+)`) + // runtime.main () at /Users/drchase/GoogleDrive/work/go/src/runtime/proc.go:201 + // function file line + // Thread 2 hit Breakpoint 1, main.main () at /Users/drchase/GoogleDrive/work/debug/hist.go:18 + s.ioState = newIoState(s.cmd) + return s +} + +func (s *gdbState) tag() string { + return s.tagg +} + +func (s *gdbState) start() { + run := "run" + for _, a := range s.args { + run += " " + a // Can't quote args for gdb, it will pass them through including the quotes + } + if *dryrun { + fmt.Printf("%s\n", asCommandLine("", s.cmd)) + fmt.Printf("tbreak main.test\n") + fmt.Printf("%s\n", run) + return + } + err := s.cmd.Start() + if err != nil { + line := asCommandLine("", s.cmd) + panic(fmt.Sprintf("There was an error [start] running '%s', %v\n", line, err)) + } + s.ioState.readSimpleExpecting("[(]gdb[)] ") + x := s.ioState.writeReadExpect("b main.test\n", "[(]gdb[)] ") + expect("Breakpoint [0-9]+ at", x) + s.stepnext(run) +} + +func (s *gdbState) stepnext(ss string) bool { + x := s.ioState.writeReadExpect(ss+"\n", "[(]gdb[)] ") + excerpts := s.atLineRe.FindStringSubmatch(x.o) + locations := s.funcFileLinePCre.FindStringSubmatch(x.o) + excerpt := "" + addedLine := false + if len(excerpts) == 0 && len(locations) == 0 { + if *verbose { + fmt.Printf("DID NOT MATCH %s", x.o) + } + return false + } + if len(excerpts) > 0 { + excerpt = excerpts[3] + } + if len(locations) > 0 { + fn := canonFileName(locations[2]) + if *verbose { + if s.file != fn { + fmt.Printf("%s\n", locations[2]) + } + fmt.Printf(" %s\n", locations[3]) + } + s.line = locations[3] + s.file = fn + s.function = locations[1] + addedLine = s.ioState.history.add(s.file, s.line, excerpt) + } + if len(excerpts) > 0 { + if *verbose { + fmt.Printf(" %s\n", excerpts[2]) + } + s.line = excerpts[2] + addedLine = s.ioState.history.add(s.file, s.line, excerpt) + } + + if !addedLine { + // True if this was a repeat line + return true + } + // Look for //gdb-=(v1,v2,v3) and print v1, v2, v3 + vars := varsToPrint(excerpt, "//"+s.tag()+"=(") + for _, v := range vars { + response := printVariableAndNormalize(v, func(v string) string { + return s.ioState.writeReadExpect("p "+v+"\n", "[(]gdb[)] ").String() + }) + s.ioState.history.addVar(response) + } + return true +} + +// printVariableAndNormalize extracts any slash-indicated normalizing requests from the variable +// name, then uses printer to get the value of the variable from the debugger, and then +// normalizes and returns the response. +func printVariableAndNormalize(v string, printer func(v string) string) string { + slashIndex := strings.Index(v, "/") + substitutions := "" + if slashIndex != -1 { + substitutions = v[slashIndex:] + v = v[:slashIndex] + } + response := printer(v) + // expect something like "$1 = ..." + dollar := strings.Index(response, "$") + cr := strings.Index(response, "\n") + + if dollar == -1 { // some not entirely expected response, whine and carry on. + if cr == -1 { + response = strings.TrimSpace(response) // discards trailing newline + response = strings.ReplaceAll(response, "\n", "
") + return "$ Malformed response " + response + } + response = strings.TrimSpace(response[:cr]) + return "$ " + response + } + if cr == -1 { + cr = len(response) + } + // Convert the leading $ into the variable name to enhance readability + // and reduce scope of diffs if an earlier print-variable is added. + response = strings.TrimSpace(response[dollar:cr]) + response = leadingDollarNumberRe.ReplaceAllString(response, v) + + // Normalize value as requested. + if strings.Contains(substitutions, "A") { + response = hexRe.ReplaceAllString(response, "") + } + if strings.Contains(substitutions, "N") { + response = numRe.ReplaceAllString(response, "") + } + if strings.Contains(substitutions, "S") { + response = stringRe.ReplaceAllString(response, "") + } + if strings.Contains(substitutions, "O") { + response = optOutGdbRe.ReplaceAllString(response, "") + } + return response +} + +// varsToPrint takes a source code line, and extracts the comma-separated variable names +// found between lookfor and the next ")". +// For example, if line includes "... //gdb-foo=(v1,v2,v3)" and +// lookfor="//gdb-foo=(", then varsToPrint returns ["v1", "v2", "v3"] +func varsToPrint(line, lookfor string) []string { + var vars []string + if strings.Contains(line, lookfor) { + x := line[strings.Index(line, lookfor)+len(lookfor):] + end := strings.Index(x, ")") + if end == -1 { + panic(fmt.Sprintf("Saw variable list begin %s in %s but no closing ')'", lookfor, line)) + } + vars = strings.Split(x[:end], ",") + for i, y := range vars { + vars[i] = strings.TrimSpace(y) + } + } + return vars +} + +func (s *gdbState) quit() { + response := s.ioState.writeRead("q\n") + if strings.Contains(response.o, "Quit anyway? (y or n)") { + defer func() { + if r := recover(); r != nil { + if s, ok := r.(string); !(ok && strings.Contains(s, "'Y\n'")) { + // Not the panic that was expected. + fmt.Printf("Expected a broken pipe panic, but saw the following panic instead") + panic(r) + } + } + }() + s.ioState.writeRead("Y\n") + } +} + +type ioState struct { + stdout io.ReadCloser + stderr io.ReadCloser + stdin io.WriteCloser + outChan chan string + errChan chan string + last tstring // Output of previous step + history *nextHist +} + +func newIoState(cmd *exec.Cmd) *ioState { + var err error + s := &ioState{} + s.history = &nextHist{} + s.history.f2i = make(map[string]uint8) + s.stdout, err = cmd.StdoutPipe() + line := asCommandLine("", cmd) + if err != nil { + panic(fmt.Sprintf("There was an error [stdoutpipe] running '%s', %v\n", line, err)) + } + s.stderr, err = cmd.StderrPipe() + if err != nil { + panic(fmt.Sprintf("There was an error [stdouterr] running '%s', %v\n", line, err)) + } + s.stdin, err = cmd.StdinPipe() + if err != nil { + panic(fmt.Sprintf("There was an error [stdinpipe] running '%s', %v\n", line, err)) + } + + s.outChan = make(chan string, 1) + s.errChan = make(chan string, 1) + go func() { + buffer := make([]byte, 4096) + for { + n, err := s.stdout.Read(buffer) + if n > 0 { + s.outChan <- string(buffer[0:n]) + } + if err == io.EOF || n == 0 { + break + } + if err != nil { + fmt.Printf("Saw an error forwarding stdout") + break + } + } + close(s.outChan) + s.stdout.Close() + }() + + go func() { + buffer := make([]byte, 4096) + for { + n, err := s.stderr.Read(buffer) + if n > 0 { + s.errChan <- string(buffer[0:n]) + } + if err == io.EOF || n == 0 { + break + } + if err != nil { + fmt.Printf("Saw an error forwarding stderr") + break + } + } + close(s.errChan) + s.stderr.Close() + }() + return s +} + +func (s *ioState) hist() *nextHist { + return s.history +} + +// writeRead writes ss, then reads stdout and stderr, waiting 500ms to +// be sure all the output has appeared. +func (s *ioState) writeRead(ss string) tstring { + if *verbose { + fmt.Printf("=> %s", ss) + } + _, err := io.WriteString(s.stdin, ss) + if err != nil { + panic(fmt.Sprintf("There was an error writing '%s', %v\n", ss, err)) + } + return s.readExpecting(-1, 500, "") +} + +// writeReadExpect writes ss, then reads stdout and stderr until something +// that matches expectRE appears. expectRE should not be "" +func (s *ioState) writeReadExpect(ss, expectRE string) tstring { + if *verbose { + fmt.Printf("=> %s", ss) + } + if expectRE == "" { + panic("expectRE should not be empty; use .* instead") + } + _, err := io.WriteString(s.stdin, ss) + if err != nil { + panic(fmt.Sprintf("There was an error writing '%s', %v\n", ss, err)) + } + return s.readSimpleExpecting(expectRE) +} + +func (s *ioState) readExpecting(millis, interlineTimeout int, expectedRE string) tstring { + timeout := time.Millisecond * time.Duration(millis) + interline := time.Millisecond * time.Duration(interlineTimeout) + s.last = tstring{} + var re *regexp.Regexp + if expectedRE != "" { + re = regexp.MustCompile(expectedRE) + } +loop: + for { + var timer <-chan time.Time + if timeout > 0 { + timer = time.After(timeout) + } + select { + case x, ok := <-s.outChan: + if !ok { + s.outChan = nil + } + s.last.o += x + case x, ok := <-s.errChan: + if !ok { + s.errChan = nil + } + s.last.e += x + case <-timer: + break loop + } + if re != nil { + if re.MatchString(s.last.o) { + break + } + if re.MatchString(s.last.e) { + break + } + } + timeout = interline + } + if *verbose { + fmt.Printf("<= %s%s", s.last.o, s.last.e) + } + return s.last +} + +func (s *ioState) readSimpleExpecting(expectedRE string) tstring { + s.last = tstring{} + var re *regexp.Regexp + if expectedRE != "" { + re = regexp.MustCompile(expectedRE) + } + for { + select { + case x, ok := <-s.outChan: + if !ok { + s.outChan = nil + } + s.last.o += x + case x, ok := <-s.errChan: + if !ok { + s.errChan = nil + } + s.last.e += x + } + if re != nil { + if re.MatchString(s.last.o) { + break + } + if re.MatchString(s.last.e) { + break + } + } + } + if *verbose { + fmt.Printf("<= %s%s", s.last.o, s.last.e) + } + return s.last +} + +// replaceEnv returns a new environment derived from env +// by removing any existing definition of ev and adding ev=evv. +func replaceEnv(env []string, ev string, evv string) []string { + if env == nil { + env = os.Environ() + } + evplus := ev + "=" + var found bool + for i, v := range env { + if strings.HasPrefix(v, evplus) { + found = true + env[i] = evplus + evv + } + } + if !found { + env = append(env, evplus+evv) + } + return env +} + +// asCommandLine renders cmd as something that could be copy-and-pasted into a command line +// If cwd is not empty and different from the command's directory, prepend an appropriate "cd" +func asCommandLine(cwd string, cmd *exec.Cmd) string { + s := "(" + if cmd.Dir != "" && cmd.Dir != cwd { + s += "cd" + escape(cmd.Dir) + ";" + } + for _, e := range cmd.Env { + if !strings.HasPrefix(e, "PATH=") && + !strings.HasPrefix(e, "HOME=") && + !strings.HasPrefix(e, "USER=") && + !strings.HasPrefix(e, "SHELL=") { + s += escape(e) + } + } + for _, a := range cmd.Args { + s += escape(a) + } + s += " )" + return s +} + +// escape inserts escapes appropriate for use in a shell command line +func escape(s string) string { + s = strings.ReplaceAll(s, "\\", "\\\\") + s = strings.ReplaceAll(s, "'", "\\'") + // Conservative guess at characters that will force quoting + if strings.ContainsAny(s, "\\ ;#*&$~?!|[]()<>{}`") { + s = " '" + s + "'" + } else { + s = " " + s + } + return s +} + +func expect(want string, got tstring) { + if want != "" { + match, err := regexp.MatchString(want, got.o) + if err != nil { + panic(fmt.Sprintf("Error for regexp %s, %v\n", want, err)) + } + if match { + return + } + // Ignore error as we have already checked for it before + match, _ = regexp.MatchString(want, got.e) + if match { + return + } + fmt.Printf("EXPECTED '%s'\n GOT O='%s'\nAND E='%s'\n", want, got.o, got.e) + } +} diff --git a/go/src/cmd/compile/internal/ssa/decompose.go b/go/src/cmd/compile/internal/ssa/decompose.go new file mode 100644 index 0000000000000000000000000000000000000000..6ea69da0169fa3ea0070f13d8cbfa02a5d306331 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/decompose.go @@ -0,0 +1,468 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "cmp" + "slices" +) + +// decompose converts phi ops on compound builtin types into phi +// ops on simple types, then invokes rewrite rules to decompose +// other ops on those types. +func decomposeBuiltin(f *Func) { + // Decompose phis + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op != OpPhi { + continue + } + decomposeBuiltinPhi(v) + } + } + + // Decompose other values + // Note: Leave dead values because we need to keep the original + // values around so the name component resolution below can still work. + applyRewrite(f, rewriteBlockdec, rewriteValuedec, leaveDeadValues) + if f.Config.RegSize == 4 { + applyRewrite(f, rewriteBlockdec64, rewriteValuedec64, leaveDeadValues) + } + + // Split up named values into their components. + // accumulate old names for aggregates (that are decomposed) in toDelete for efficient bulk deletion, + // accumulate new LocalSlots in newNames for addition after the iteration. This decomposition is for + // builtin types with leaf components, and thus there is no need to reprocess the newly create LocalSlots. + var toDelete []namedVal + var newNames []*LocalSlot + for i, name := range f.Names { + t := name.Type + switch { + case t.IsInteger() && t.Size() > f.Config.RegSize: + hiName, loName := f.SplitInt64(name) + newNames = maybeAppend2(f, newNames, hiName, loName) + for j, v := range f.NamedValues[*name] { + if v.Op != OpInt64Make { + continue + } + f.NamedValues[*hiName] = append(f.NamedValues[*hiName], v.Args[0]) + f.NamedValues[*loName] = append(f.NamedValues[*loName], v.Args[1]) + toDelete = append(toDelete, namedVal{i, j}) + } + case t.IsComplex(): + rName, iName := f.SplitComplex(name) + newNames = maybeAppend2(f, newNames, rName, iName) + for j, v := range f.NamedValues[*name] { + if v.Op != OpComplexMake { + continue + } + f.NamedValues[*rName] = append(f.NamedValues[*rName], v.Args[0]) + f.NamedValues[*iName] = append(f.NamedValues[*iName], v.Args[1]) + toDelete = append(toDelete, namedVal{i, j}) + } + case t.IsString(): + ptrName, lenName := f.SplitString(name) + newNames = maybeAppend2(f, newNames, ptrName, lenName) + for j, v := range f.NamedValues[*name] { + if v.Op != OpStringMake { + continue + } + f.NamedValues[*ptrName] = append(f.NamedValues[*ptrName], v.Args[0]) + f.NamedValues[*lenName] = append(f.NamedValues[*lenName], v.Args[1]) + toDelete = append(toDelete, namedVal{i, j}) + } + case t.IsSlice(): + ptrName, lenName, capName := f.SplitSlice(name) + newNames = maybeAppend2(f, newNames, ptrName, lenName) + newNames = maybeAppend(f, newNames, capName) + for j, v := range f.NamedValues[*name] { + if v.Op != OpSliceMake { + continue + } + f.NamedValues[*ptrName] = append(f.NamedValues[*ptrName], v.Args[0]) + f.NamedValues[*lenName] = append(f.NamedValues[*lenName], v.Args[1]) + f.NamedValues[*capName] = append(f.NamedValues[*capName], v.Args[2]) + toDelete = append(toDelete, namedVal{i, j}) + } + case t.IsInterface(): + typeName, dataName := f.SplitInterface(name) + newNames = maybeAppend2(f, newNames, typeName, dataName) + for j, v := range f.NamedValues[*name] { + if v.Op != OpIMake { + continue + } + f.NamedValues[*typeName] = append(f.NamedValues[*typeName], v.Args[0]) + f.NamedValues[*dataName] = append(f.NamedValues[*dataName], v.Args[1]) + toDelete = append(toDelete, namedVal{i, j}) + } + case t.IsFloat(): + // floats are never decomposed, even ones bigger than RegSize + case t.Size() > f.Config.RegSize && !t.IsSIMD(): + f.Fatalf("undecomposed named type %s %v", name, t) + } + } + + deleteNamedVals(f, toDelete) + f.Names = append(f.Names, newNames...) +} + +func maybeAppend(f *Func, ss []*LocalSlot, s *LocalSlot) []*LocalSlot { + if _, ok := f.NamedValues[*s]; !ok { + f.NamedValues[*s] = nil + return append(ss, s) + } + return ss +} + +func maybeAppend2(f *Func, ss []*LocalSlot, s1, s2 *LocalSlot) []*LocalSlot { + return maybeAppend(f, maybeAppend(f, ss, s1), s2) +} + +func decomposeBuiltinPhi(v *Value) { + switch { + case v.Type.IsInteger() && v.Type.Size() > v.Block.Func.Config.RegSize: + decomposeInt64Phi(v) + case v.Type.IsComplex(): + decomposeComplexPhi(v) + case v.Type.IsString(): + decomposeStringPhi(v) + case v.Type.IsSlice(): + decomposeSlicePhi(v) + case v.Type.IsInterface(): + decomposeInterfacePhi(v) + case v.Type.IsFloat(): + // floats are never decomposed, even ones bigger than RegSize + case v.Type.Size() > v.Block.Func.Config.RegSize && !v.Type.IsSIMD(): + v.Fatalf("%v undecomposed type %v", v, v.Type) + } +} + +func decomposeStringPhi(v *Value) { + types := &v.Block.Func.Config.Types + ptrType := types.BytePtr + lenType := types.Int + + ptr := v.Block.NewValue0(v.Pos, OpPhi, ptrType) + len := v.Block.NewValue0(v.Pos, OpPhi, lenType) + for _, a := range v.Args { + ptr.AddArg(a.Block.NewValue1(v.Pos, OpStringPtr, ptrType, a)) + len.AddArg(a.Block.NewValue1(v.Pos, OpStringLen, lenType, a)) + } + v.reset(OpStringMake) + v.AddArg(ptr) + v.AddArg(len) +} + +func decomposeSlicePhi(v *Value) { + types := &v.Block.Func.Config.Types + ptrType := v.Type.Elem().PtrTo() + lenType := types.Int + + ptr := v.Block.NewValue0(v.Pos, OpPhi, ptrType) + len := v.Block.NewValue0(v.Pos, OpPhi, lenType) + cap := v.Block.NewValue0(v.Pos, OpPhi, lenType) + for _, a := range v.Args { + ptr.AddArg(a.Block.NewValue1(v.Pos, OpSlicePtr, ptrType, a)) + len.AddArg(a.Block.NewValue1(v.Pos, OpSliceLen, lenType, a)) + cap.AddArg(a.Block.NewValue1(v.Pos, OpSliceCap, lenType, a)) + } + v.reset(OpSliceMake) + v.AddArg(ptr) + v.AddArg(len) + v.AddArg(cap) +} + +func decomposeInt64Phi(v *Value) { + cfgtypes := &v.Block.Func.Config.Types + var partType *types.Type + if v.Type.IsSigned() { + partType = cfgtypes.Int32 + } else { + partType = cfgtypes.UInt32 + } + + hi := v.Block.NewValue0(v.Pos, OpPhi, partType) + lo := v.Block.NewValue0(v.Pos, OpPhi, cfgtypes.UInt32) + for _, a := range v.Args { + hi.AddArg(a.Block.NewValue1(v.Pos, OpInt64Hi, partType, a)) + lo.AddArg(a.Block.NewValue1(v.Pos, OpInt64Lo, cfgtypes.UInt32, a)) + } + v.reset(OpInt64Make) + v.AddArg(hi) + v.AddArg(lo) +} + +func decomposeComplexPhi(v *Value) { + cfgtypes := &v.Block.Func.Config.Types + var partType *types.Type + switch z := v.Type.Size(); z { + case 8: + partType = cfgtypes.Float32 + case 16: + partType = cfgtypes.Float64 + default: + v.Fatalf("decomposeComplexPhi: bad complex size %d", z) + } + + real := v.Block.NewValue0(v.Pos, OpPhi, partType) + imag := v.Block.NewValue0(v.Pos, OpPhi, partType) + for _, a := range v.Args { + real.AddArg(a.Block.NewValue1(v.Pos, OpComplexReal, partType, a)) + imag.AddArg(a.Block.NewValue1(v.Pos, OpComplexImag, partType, a)) + } + v.reset(OpComplexMake) + v.AddArg(real) + v.AddArg(imag) +} + +func decomposeInterfacePhi(v *Value) { + uintptrType := v.Block.Func.Config.Types.Uintptr + ptrType := v.Block.Func.Config.Types.BytePtr + + itab := v.Block.NewValue0(v.Pos, OpPhi, uintptrType) + data := v.Block.NewValue0(v.Pos, OpPhi, ptrType) + for _, a := range v.Args { + itab.AddArg(a.Block.NewValue1(v.Pos, OpITab, uintptrType, a)) + data.AddArg(a.Block.NewValue1(v.Pos, OpIData, ptrType, a)) + } + v.reset(OpIMake) + v.AddArg(itab) + v.AddArg(data) +} + +func decomposeUser(f *Func) { + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op != OpPhi { + continue + } + decomposeUserPhi(v) + } + } + // Split up named values into their components. + i := 0 + var newNames []*LocalSlot + for _, name := range f.Names { + t := name.Type + switch { + case isStructNotSIMD(t): + newNames = decomposeUserStructInto(f, name, newNames) + case t.IsArray(): + newNames = decomposeUserArrayInto(f, name, newNames) + default: + f.Names[i] = name + i++ + } + } + f.Names = f.Names[:i] + f.Names = append(f.Names, newNames...) +} + +// decomposeUserArrayInto creates names for the element(s) of arrays referenced +// by name where possible, and appends those new names to slots, which is then +// returned. +func decomposeUserArrayInto(f *Func, name *LocalSlot, slots []*LocalSlot) []*LocalSlot { + t := name.Type + if t.Size() == 0 { + // TODO(khr): Not sure what to do here. Probably nothing. + // Names for empty arrays aren't important. + return slots + } + if t.NumElem() != 1 { + // shouldn't get here due to CanSSA + f.Fatalf("array not of size 1") + } + elemName := f.SplitArray(name) + var keep []*Value + for _, v := range f.NamedValues[*name] { + if v.Op != OpArrayMake1 { + keep = append(keep, v) + continue + } + f.NamedValues[*elemName] = append(f.NamedValues[*elemName], v.Args[0]) + } + if len(keep) == 0 { + // delete the name for the array as a whole + delete(f.NamedValues, *name) + } else { + f.NamedValues[*name] = keep + } + + if t.Elem().IsArray() { + return decomposeUserArrayInto(f, elemName, slots) + } else if isStructNotSIMD(t.Elem()) { + return decomposeUserStructInto(f, elemName, slots) + } + + return append(slots, elemName) +} + +// decomposeUserStructInto creates names for the fields(s) of structs referenced +// by name where possible, and appends those new names to slots, which is then +// returned. +func decomposeUserStructInto(f *Func, name *LocalSlot, slots []*LocalSlot) []*LocalSlot { + fnames := []*LocalSlot{} // slots for struct in name + t := name.Type + n := t.NumFields() + + for i := 0; i < n; i++ { + fs := f.SplitStruct(name, i) + fnames = append(fnames, fs) + // arrays and structs will be decomposed further, so + // there's no need to record a name + if !fs.Type.IsArray() && !isStructNotSIMD(fs.Type) { + slots = maybeAppend(f, slots, fs) + } + } + + var keep []*Value + // create named values for each struct field + for _, v := range f.NamedValues[*name] { + if v.Op != OpStructMake || len(v.Args) != n { + keep = append(keep, v) + continue + } + for i := 0; i < len(fnames); i++ { + f.NamedValues[*fnames[i]] = append(f.NamedValues[*fnames[i]], v.Args[i]) + } + } + if len(keep) == 0 { + // delete the name for the struct as a whole + delete(f.NamedValues, *name) + } else { + f.NamedValues[*name] = keep + } + + // now that this f.NamedValues contains values for the struct + // fields, recurse into nested structs + for i := 0; i < n; i++ { + if isStructNotSIMD(name.Type.FieldType(i)) { + slots = decomposeUserStructInto(f, fnames[i], slots) + delete(f.NamedValues, *fnames[i]) + } else if name.Type.FieldType(i).IsArray() { + slots = decomposeUserArrayInto(f, fnames[i], slots) + delete(f.NamedValues, *fnames[i]) + } + } + return slots +} +func decomposeUserPhi(v *Value) { + switch { + case isStructNotSIMD(v.Type): + decomposeStructPhi(v) + case v.Type.IsArray(): + decomposeArrayPhi(v) + } +} + +// decomposeStructPhi replaces phi-of-struct with structmake(phi-for-each-field), +// and then recursively decomposes the phis for each field. +func decomposeStructPhi(v *Value) { + t := v.Type + if t.Size() == 0 { + v.reset(OpEmpty) + return + } + n := t.NumFields() + fields := make([]*Value, 0, MaxStruct) + for i := 0; i < n; i++ { + fields = append(fields, v.Block.NewValue0(v.Pos, OpPhi, t.FieldType(i))) + } + for _, a := range v.Args { + for i := 0; i < n; i++ { + fields[i].AddArg(a.Block.NewValue1I(v.Pos, OpStructSelect, t.FieldType(i), int64(i), a)) + } + } + v.reset(OpStructMake) + v.AddArgs(fields...) + + // Recursively decompose phis for each field. + for _, f := range fields { + decomposeUserPhi(f) + } +} + +// decomposeArrayPhi replaces phi-of-array with arraymake(phi-of-array-element), +// and then recursively decomposes the element phi. +func decomposeArrayPhi(v *Value) { + t := v.Type + if t.Size() == 0 { + v.reset(OpEmpty) + return + } + if t.NumElem() != 1 { + v.Fatalf("SSAable array must have no more than 1 element") + } + elem := v.Block.NewValue0(v.Pos, OpPhi, t.Elem()) + for _, a := range v.Args { + elem.AddArg(a.Block.NewValue1I(v.Pos, OpArraySelect, t.Elem(), 0, a)) + } + v.reset(OpArrayMake1) + v.AddArg(elem) + + // Recursively decompose elem phi. + decomposeUserPhi(elem) +} + +// MaxStruct is the maximum number of fields a struct +// can have and still be SSAable. +const MaxStruct = 4 + +type namedVal struct { + locIndex, valIndex int // f.NamedValues[f.Names[locIndex]][valIndex] = key +} + +// deleteNamedVals removes particular values with debugger names from f's naming data structures, +// removes all values with OpInvalid, and re-sorts the list of Names. +func deleteNamedVals(f *Func, toDelete []namedVal) { + // Arrange to delete from larger indices to smaller, to ensure swap-with-end deletion does not invalidate pending indices. + slices.SortFunc(toDelete, func(a, b namedVal) int { + if a.locIndex != b.locIndex { + return cmp.Compare(b.locIndex, a.locIndex) + } + return cmp.Compare(b.valIndex, a.valIndex) + }) + + // Get rid of obsolete names + for _, d := range toDelete { + loc := f.Names[d.locIndex] + vals := f.NamedValues[*loc] + l := len(vals) - 1 + if l > 0 { + vals[d.valIndex] = vals[l] + } + vals[l] = nil + f.NamedValues[*loc] = vals[:l] + } + // Delete locations with no values attached. + end := len(f.Names) + for i := len(f.Names) - 1; i >= 0; i-- { + loc := f.Names[i] + vals := f.NamedValues[*loc] + last := len(vals) + for j := len(vals) - 1; j >= 0; j-- { + if vals[j].Op == OpInvalid { + last-- + vals[j] = vals[last] + vals[last] = nil + } + } + if last < len(vals) { + f.NamedValues[*loc] = vals[:last] + } + if len(vals) == 0 { + delete(f.NamedValues, *loc) + end-- + f.Names[i] = f.Names[end] + f.Names[end] = nil + } + } + f.Names = f.Names[:end] +} + +func isStructNotSIMD(t *types.Type) bool { + return t.IsStruct() && !t.IsSIMD() +} diff --git a/go/src/cmd/compile/internal/ssa/dom.go b/go/src/cmd/compile/internal/ssa/dom.go new file mode 100644 index 0000000000000000000000000000000000000000..1aa0c2db564b8e7cdd22c633f41134596efcacfb --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/dom.go @@ -0,0 +1,268 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// This file contains code to compute the dominator tree +// of a control-flow graph. + +// postorder computes a postorder traversal ordering for the +// basic blocks in f. Unreachable blocks will not appear. +func postorder(f *Func) []*Block { + return postorderWithNumbering(f, nil) +} + +type blockAndIndex struct { + b *Block + index int // index is the number of successor edges of b that have already been explored. +} + +// postorderWithNumbering provides a DFS postordering. +// This seems to make loop-finding more robust. +func postorderWithNumbering(f *Func, ponums []int32) []*Block { + seen := f.Cache.allocBoolSlice(f.NumBlocks()) + defer f.Cache.freeBoolSlice(seen) + + // result ordering + order := make([]*Block, 0, len(f.Blocks)) + + // stack of blocks and next child to visit + // A constant bound allows this to be stack-allocated. 32 is + // enough to cover almost every postorderWithNumbering call. + s := make([]blockAndIndex, 0, 32) + s = append(s, blockAndIndex{b: f.Entry}) + seen[f.Entry.ID] = true + for len(s) > 0 { + tos := len(s) - 1 + x := s[tos] + b := x.b + if i := x.index; i < len(b.Succs) { + s[tos].index++ + bb := b.Succs[i].Block() + if !seen[bb.ID] { + seen[bb.ID] = true + s = append(s, blockAndIndex{b: bb}) + } + continue + } + s = s[:tos] + if ponums != nil { + ponums[b.ID] = int32(len(order)) + } + order = append(order, b) + } + return order +} + +func dominators(f *Func) []*Block { + // TODO: benchmark and try to find criteria for swapping between + // dominatorsSimple and dominatorsLT + return f.dominatorsLTOrig(f.Entry) +} + +// dominatorsLTOrig runs Lengauer-Tarjan to compute a dominator tree starting at entry. +func (f *Func) dominatorsLTOrig(entry *Block) []*Block { + // Adapted directly from the original TOPLAS article's "simple" algorithm + + maxBlockID := entry.Func.NumBlocks() + scratch := f.Cache.allocIDSlice(7 * maxBlockID) + defer f.Cache.freeIDSlice(scratch) + semi := scratch[0*maxBlockID : 1*maxBlockID] + vertex := scratch[1*maxBlockID : 2*maxBlockID] + label := scratch[2*maxBlockID : 3*maxBlockID] + parent := scratch[3*maxBlockID : 4*maxBlockID] + ancestor := scratch[4*maxBlockID : 5*maxBlockID] + bucketHead := scratch[5*maxBlockID : 6*maxBlockID] + bucketLink := scratch[6*maxBlockID : 7*maxBlockID] + + // This version uses integers for most of the computation, + // to make the work arrays smaller and pointer-free. + // fromID translates from ID to *Block where that is needed. + fromID := f.Cache.allocBlockSlice(maxBlockID) + defer f.Cache.freeBlockSlice(fromID) + for _, v := range f.Blocks { + fromID[v.ID] = v + } + idom := make([]*Block, maxBlockID) + + // Step 1. Carry out a depth first search of the problem graph. Number + // the vertices from 1 to n as they are reached during the search. + n := f.dfsOrig(entry, semi, vertex, label, parent) + + for i := n; i >= 2; i-- { + w := vertex[i] + + // step2 in TOPLAS paper + for _, e := range fromID[w].Preds { + v := e.b + if semi[v.ID] == 0 { + // skip unreachable predecessor + // not in original, but we're using existing pred instead of building one. + continue + } + u := evalOrig(v.ID, ancestor, semi, label) + if semi[u] < semi[w] { + semi[w] = semi[u] + } + } + + // add w to bucket[vertex[semi[w]]] + // implement bucket as a linked list implemented + // in a pair of arrays. + vsw := vertex[semi[w]] + bucketLink[w] = bucketHead[vsw] + bucketHead[vsw] = w + + linkOrig(parent[w], w, ancestor) + + // step3 in TOPLAS paper + for v := bucketHead[parent[w]]; v != 0; v = bucketLink[v] { + u := evalOrig(v, ancestor, semi, label) + if semi[u] < semi[v] { + idom[v] = fromID[u] + } else { + idom[v] = fromID[parent[w]] + } + } + } + // step 4 in toplas paper + for i := ID(2); i <= n; i++ { + w := vertex[i] + if idom[w].ID != vertex[semi[w]] { + idom[w] = idom[idom[w].ID] + } + } + + return idom +} + +// dfsOrig performs a depth first search over the blocks starting at entry block +// (in arbitrary order). This is a de-recursed version of dfs from the +// original Tarjan-Lengauer TOPLAS article. It's important to return the +// same values for parent as the original algorithm. +func (f *Func) dfsOrig(entry *Block, semi, vertex, label, parent []ID) ID { + n := ID(0) + s := make([]*Block, 0, 256) + s = append(s, entry) + + for len(s) > 0 { + v := s[len(s)-1] + s = s[:len(s)-1] + // recursing on v + + if semi[v.ID] != 0 { + continue // already visited + } + n++ + semi[v.ID] = n + vertex[n] = v.ID + label[v.ID] = v.ID + // ancestor[v] already zero + for _, e := range v.Succs { + w := e.b + // if it has a dfnum, we've already visited it + if semi[w.ID] == 0 { + // yes, w can be pushed multiple times. + s = append(s, w) + parent[w.ID] = v.ID // keep overwriting this till it is visited. + } + } + } + return n +} + +// compressOrig is the "simple" compress function from LT paper. +func compressOrig(v ID, ancestor, semi, label []ID) { + if ancestor[ancestor[v]] != 0 { + compressOrig(ancestor[v], ancestor, semi, label) + if semi[label[ancestor[v]]] < semi[label[v]] { + label[v] = label[ancestor[v]] + } + ancestor[v] = ancestor[ancestor[v]] + } +} + +// evalOrig is the "simple" eval function from LT paper. +func evalOrig(v ID, ancestor, semi, label []ID) ID { + if ancestor[v] == 0 { + return v + } + compressOrig(v, ancestor, semi, label) + return label[v] +} + +func linkOrig(v, w ID, ancestor []ID) { + ancestor[w] = v +} + +// dominatorsSimple computes the dominator tree for f. It returns a slice +// which maps block ID to the immediate dominator of that block. +// Unreachable blocks map to nil. The entry block maps to nil. +func dominatorsSimple(f *Func) []*Block { + // A simple algorithm for now + // Cooper, Harvey, Kennedy + idom := make([]*Block, f.NumBlocks()) + + // Compute postorder walk + post := f.postorder() + + // Make map from block id to order index (for intersect call) + postnum := f.Cache.allocIntSlice(f.NumBlocks()) + defer f.Cache.freeIntSlice(postnum) + for i, b := range post { + postnum[b.ID] = i + } + + // Make the entry block a self-loop + idom[f.Entry.ID] = f.Entry + if postnum[f.Entry.ID] != len(post)-1 { + f.Fatalf("entry block %v not last in postorder", f.Entry) + } + + // Compute relaxation of idom entries + for { + changed := false + + for i := len(post) - 2; i >= 0; i-- { + b := post[i] + var d *Block + for _, e := range b.Preds { + p := e.b + if idom[p.ID] == nil { + continue + } + if d == nil { + d = p + continue + } + d = intersect(d, p, postnum, idom) + } + if d != idom[b.ID] { + idom[b.ID] = d + changed = true + } + } + if !changed { + break + } + } + // Set idom of entry block to nil instead of itself. + idom[f.Entry.ID] = nil + return idom +} + +// intersect finds the closest dominator of both b and c. +// It requires a postorder numbering of all the blocks. +func intersect(b, c *Block, postnum []int, idom []*Block) *Block { + // TODO: This loop is O(n^2). It used to be used in nilcheck, + // see BenchmarkNilCheckDeep*. + for b != c { + if postnum[b.ID] < postnum[c.ID] { + b = idom[b.ID] + } else { + c = idom[c.ID] + } + } + return b +} diff --git a/go/src/cmd/compile/internal/ssa/dom_test.go b/go/src/cmd/compile/internal/ssa/dom_test.go new file mode 100644 index 0000000000000000000000000000000000000000..945b46fce4fedcbbb6cad90dd799198f1597e6df --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/dom_test.go @@ -0,0 +1,608 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "testing" +) + +func BenchmarkDominatorsLinear(b *testing.B) { benchmarkDominators(b, 10000, genLinear) } +func BenchmarkDominatorsFwdBack(b *testing.B) { benchmarkDominators(b, 10000, genFwdBack) } +func BenchmarkDominatorsManyPred(b *testing.B) { benchmarkDominators(b, 10000, genManyPred) } +func BenchmarkDominatorsMaxPred(b *testing.B) { benchmarkDominators(b, 10000, genMaxPred) } +func BenchmarkDominatorsMaxPredVal(b *testing.B) { benchmarkDominators(b, 10000, genMaxPredValue) } + +type blockGen func(size int) []bloc + +// genLinear creates an array of blocks that succeed one another +// b_n -> [b_n+1]. +func genLinear(size int) []bloc { + var blocs []bloc + blocs = append(blocs, + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Goto(blockn(0)), + ), + ) + for i := 0; i < size; i++ { + blocs = append(blocs, Bloc(blockn(i), + Goto(blockn(i+1)))) + } + + blocs = append(blocs, + Bloc(blockn(size), Goto("exit")), + Bloc("exit", Exit("mem")), + ) + + return blocs +} + +// genFwdBack creates an array of blocks that alternate between +// b_n -> [b_n+1], b_n -> [b_n+1, b_n-1] , b_n -> [b_n+1, b_n+2] +func genFwdBack(size int) []bloc { + var blocs []bloc + blocs = append(blocs, + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 1, nil), + Goto(blockn(0)), + ), + ) + for i := 0; i < size; i++ { + switch i % 2 { + case 0: + blocs = append(blocs, Bloc(blockn(i), + If("p", blockn(i+1), blockn(i+2)))) + case 1: + blocs = append(blocs, Bloc(blockn(i), + If("p", blockn(i+1), blockn(i-1)))) + } + } + + blocs = append(blocs, + Bloc(blockn(size), Goto("exit")), + Bloc("exit", Exit("mem")), + ) + + return blocs +} + +// genManyPred creates an array of blocks where 1/3rd have a successor of the +// first block, 1/3rd the last block, and the remaining third are plain. +func genManyPred(size int) []bloc { + var blocs []bloc + blocs = append(blocs, + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 1, nil), + Goto(blockn(0)), + ), + ) + + // We want predecessor lists to be long, so 2/3rds of the blocks have a + // successor of the first or last block. + for i := 0; i < size; i++ { + switch i % 3 { + case 0: + blocs = append(blocs, Bloc(blockn(i), + Valu("a", OpConstBool, types.Types[types.TBOOL], 1, nil), + Goto(blockn(i+1)))) + case 1: + blocs = append(blocs, Bloc(blockn(i), + Valu("a", OpConstBool, types.Types[types.TBOOL], 1, nil), + If("p", blockn(i+1), blockn(0)))) + case 2: + blocs = append(blocs, Bloc(blockn(i), + Valu("a", OpConstBool, types.Types[types.TBOOL], 1, nil), + If("p", blockn(i+1), blockn(size)))) + } + } + + blocs = append(blocs, + Bloc(blockn(size), Goto("exit")), + Bloc("exit", Exit("mem")), + ) + + return blocs +} + +// genMaxPred maximizes the size of the 'exit' predecessor list. +func genMaxPred(size int) []bloc { + var blocs []bloc + blocs = append(blocs, + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 1, nil), + Goto(blockn(0)), + ), + ) + + for i := 0; i < size; i++ { + blocs = append(blocs, Bloc(blockn(i), + If("p", blockn(i+1), "exit"))) + } + + blocs = append(blocs, + Bloc(blockn(size), Goto("exit")), + Bloc("exit", Exit("mem")), + ) + + return blocs +} + +// genMaxPredValue is identical to genMaxPred but contains an +// additional value. +func genMaxPredValue(size int) []bloc { + var blocs []bloc + blocs = append(blocs, + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 1, nil), + Goto(blockn(0)), + ), + ) + + for i := 0; i < size; i++ { + blocs = append(blocs, Bloc(blockn(i), + Valu("a", OpConstBool, types.Types[types.TBOOL], 1, nil), + If("p", blockn(i+1), "exit"))) + } + + blocs = append(blocs, + Bloc(blockn(size), Goto("exit")), + Bloc("exit", Exit("mem")), + ) + + return blocs +} + +// sink for benchmark +var domBenchRes []*Block + +func benchmarkDominators(b *testing.B, size int, bg blockGen) { + c := testConfig(b) + fun := c.Fun("entry", bg(size)...) + + CheckFunc(fun.f) + b.SetBytes(int64(size)) + b.ResetTimer() + for i := 0; i < b.N; i++ { + domBenchRes = dominators(fun.f) + } +} + +type domFunc func(f *Func) []*Block + +// verifyDominators verifies that the dominators of fut (function under test) +// as determined by domFn, match the map node->dominator +func verifyDominators(t *testing.T, fut fun, domFn domFunc, doms map[string]string) { + blockNames := map[*Block]string{} + for n, b := range fut.blocks { + blockNames[b] = n + } + + calcDom := domFn(fut.f) + + for n, d := range doms { + nblk, ok := fut.blocks[n] + if !ok { + t.Errorf("invalid block name %s", n) + } + dblk, ok := fut.blocks[d] + if !ok { + t.Errorf("invalid block name %s", d) + } + + domNode := calcDom[nblk.ID] + switch { + case calcDom[nblk.ID] == dblk: + calcDom[nblk.ID] = nil + continue + case calcDom[nblk.ID] != dblk: + t.Errorf("expected %s as dominator of %s, found %s", d, n, blockNames[domNode]) + default: + t.Fatal("unexpected dominator condition") + } + } + + for id, d := range calcDom { + // If nil, we've already verified it + if d == nil { + continue + } + for _, b := range fut.blocks { + if int(b.ID) == id { + t.Errorf("unexpected dominator of %s for %s", blockNames[d], blockNames[b]) + } + } + } + +} + +func TestDominatorsSingleBlock(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Exit("mem"))) + + doms := map[string]string{} + + CheckFunc(fun.f) + verifyDominators(t, fun, dominators, doms) + verifyDominators(t, fun, dominatorsSimple, doms) + +} + +func TestDominatorsSimple(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Goto("a")), + Bloc("a", + Goto("b")), + Bloc("b", + Goto("c")), + Bloc("c", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + doms := map[string]string{ + "a": "entry", + "b": "a", + "c": "b", + "exit": "c", + } + + CheckFunc(fun.f) + verifyDominators(t, fun, dominators, doms) + verifyDominators(t, fun, dominatorsSimple, doms) + +} + +func TestDominatorsMultPredFwd(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 1, nil), + If("p", "a", "c")), + Bloc("a", + If("p", "b", "c")), + Bloc("b", + Goto("c")), + Bloc("c", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + doms := map[string]string{ + "a": "entry", + "b": "a", + "c": "entry", + "exit": "c", + } + + CheckFunc(fun.f) + verifyDominators(t, fun, dominators, doms) + verifyDominators(t, fun, dominatorsSimple, doms) +} + +func TestDominatorsDeadCode(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 0, nil), + If("p", "b3", "b5")), + Bloc("b2", Exit("mem")), + Bloc("b3", Goto("b2")), + Bloc("b4", Goto("b2")), + Bloc("b5", Goto("b2"))) + + doms := map[string]string{ + "b2": "entry", + "b3": "entry", + "b5": "entry", + } + + CheckFunc(fun.f) + verifyDominators(t, fun, dominators, doms) + verifyDominators(t, fun, dominatorsSimple, doms) +} + +func TestDominatorsMultPredRev(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Goto("first")), + Bloc("first", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 1, nil), + Goto("a")), + Bloc("a", + If("p", "b", "first")), + Bloc("b", + Goto("c")), + Bloc("c", + If("p", "exit", "b")), + Bloc("exit", + Exit("mem"))) + + doms := map[string]string{ + "first": "entry", + "a": "first", + "b": "a", + "c": "b", + "exit": "c", + } + + CheckFunc(fun.f) + verifyDominators(t, fun, dominators, doms) + verifyDominators(t, fun, dominatorsSimple, doms) +} + +func TestDominatorsMultPred(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 1, nil), + If("p", "a", "c")), + Bloc("a", + If("p", "b", "c")), + Bloc("b", + Goto("c")), + Bloc("c", + If("p", "b", "exit")), + Bloc("exit", + Exit("mem"))) + + doms := map[string]string{ + "a": "entry", + "b": "entry", + "c": "entry", + "exit": "c", + } + + CheckFunc(fun.f) + verifyDominators(t, fun, dominators, doms) + verifyDominators(t, fun, dominatorsSimple, doms) +} + +func TestInfiniteLoop(t *testing.T) { + c := testConfig(t) + // note lack of an exit block + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 1, nil), + Goto("a")), + Bloc("a", + Goto("b")), + Bloc("b", + Goto("a"))) + + CheckFunc(fun.f) + doms := map[string]string{"a": "entry", + "b": "a"} + verifyDominators(t, fun, dominators, doms) +} + +func TestDomTricky(t *testing.T) { + doms := map[string]string{ + "4": "1", + "2": "4", + "5": "4", + "11": "4", + "15": "4", // the incorrect answer is "5" + "10": "15", + "19": "15", + } + + if4 := [2]string{"2", "5"} + if5 := [2]string{"15", "11"} + if15 := [2]string{"19", "10"} + + for i := 0; i < 8; i++ { + a := 1 & i + b := 1 & i >> 1 + c := 1 & i >> 2 + + cfg := testConfig(t) + fun := cfg.Fun("1", + Bloc("1", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 1, nil), + Goto("4")), + Bloc("2", + Goto("11")), + Bloc("4", + If("p", if4[a], if4[1-a])), // 2, 5 + Bloc("5", + If("p", if5[b], if5[1-b])), //15, 11 + Bloc("10", + Exit("mem")), + Bloc("11", + Goto("15")), + Bloc("15", + If("p", if15[c], if15[1-c])), //19, 10 + Bloc("19", + Goto("10"))) + CheckFunc(fun.f) + verifyDominators(t, fun, dominators, doms) + verifyDominators(t, fun, dominatorsSimple, doms) + } +} + +// generateDominatorMap uses dominatorsSimple to obtain a +// reference dominator tree for testing faster algorithms. +func generateDominatorMap(fut fun) map[string]string { + blockNames := map[*Block]string{} + for n, b := range fut.blocks { + blockNames[b] = n + } + referenceDom := dominatorsSimple(fut.f) + doms := make(map[string]string) + for _, b := range fut.f.Blocks { + if d := referenceDom[b.ID]; d != nil { + doms[blockNames[b]] = blockNames[d] + } + } + return doms +} + +func TestDominatorsPostTrickyA(t *testing.T) { + testDominatorsPostTricky(t, "b8", "b11", "b10", "b8", "b14", "b15") +} + +func TestDominatorsPostTrickyB(t *testing.T) { + testDominatorsPostTricky(t, "b11", "b8", "b10", "b8", "b14", "b15") +} + +func TestDominatorsPostTrickyC(t *testing.T) { + testDominatorsPostTricky(t, "b8", "b11", "b8", "b10", "b14", "b15") +} + +func TestDominatorsPostTrickyD(t *testing.T) { + testDominatorsPostTricky(t, "b11", "b8", "b8", "b10", "b14", "b15") +} + +func TestDominatorsPostTrickyE(t *testing.T) { + testDominatorsPostTricky(t, "b8", "b11", "b10", "b8", "b15", "b14") +} + +func TestDominatorsPostTrickyF(t *testing.T) { + testDominatorsPostTricky(t, "b11", "b8", "b10", "b8", "b15", "b14") +} + +func TestDominatorsPostTrickyG(t *testing.T) { + testDominatorsPostTricky(t, "b8", "b11", "b8", "b10", "b15", "b14") +} + +func TestDominatorsPostTrickyH(t *testing.T) { + testDominatorsPostTricky(t, "b11", "b8", "b8", "b10", "b15", "b14") +} + +func testDominatorsPostTricky(t *testing.T, b7then, b7else, b12then, b12else, b13then, b13else string) { + c := testConfig(t) + fun := c.Fun("b1", + Bloc("b1", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("p", OpConstBool, types.Types[types.TBOOL], 1, nil), + If("p", "b3", "b2")), + Bloc("b3", + If("p", "b5", "b6")), + Bloc("b5", + Goto("b7")), + Bloc("b7", + If("p", b7then, b7else)), + Bloc("b8", + Goto("b13")), + Bloc("b13", + If("p", b13then, b13else)), + Bloc("b14", + Goto("b10")), + Bloc("b15", + Goto("b16")), + Bloc("b16", + Goto("b9")), + Bloc("b9", + Goto("b7")), + Bloc("b11", + Goto("b12")), + Bloc("b12", + If("p", b12then, b12else)), + Bloc("b10", + Goto("b6")), + Bloc("b6", + Goto("b17")), + Bloc("b17", + Goto("b18")), + Bloc("b18", + If("p", "b22", "b19")), + Bloc("b22", + Goto("b23")), + Bloc("b23", + If("p", "b21", "b19")), + Bloc("b19", + If("p", "b24", "b25")), + Bloc("b24", + Goto("b26")), + Bloc("b26", + Goto("b25")), + Bloc("b25", + If("p", "b27", "b29")), + Bloc("b27", + Goto("b30")), + Bloc("b30", + Goto("b28")), + Bloc("b29", + Goto("b31")), + Bloc("b31", + Goto("b28")), + Bloc("b28", + If("p", "b32", "b33")), + Bloc("b32", + Goto("b21")), + Bloc("b21", + Goto("b47")), + Bloc("b47", + If("p", "b45", "b46")), + Bloc("b45", + Goto("b48")), + Bloc("b48", + Goto("b49")), + Bloc("b49", + If("p", "b50", "b51")), + Bloc("b50", + Goto("b52")), + Bloc("b52", + Goto("b53")), + Bloc("b53", + Goto("b51")), + Bloc("b51", + Goto("b54")), + Bloc("b54", + Goto("b46")), + Bloc("b46", + Exit("mem")), + Bloc("b33", + Goto("b34")), + Bloc("b34", + Goto("b37")), + Bloc("b37", + If("p", "b35", "b36")), + Bloc("b35", + Goto("b38")), + Bloc("b38", + Goto("b39")), + Bloc("b39", + If("p", "b40", "b41")), + Bloc("b40", + Goto("b42")), + Bloc("b42", + Goto("b43")), + Bloc("b43", + Goto("b41")), + Bloc("b41", + Goto("b44")), + Bloc("b44", + Goto("b36")), + Bloc("b36", + Goto("b20")), + Bloc("b20", + Goto("b18")), + Bloc("b2", + Goto("b4")), + Bloc("b4", + Exit("mem"))) + CheckFunc(fun.f) + doms := generateDominatorMap(fun) + verifyDominators(t, fun, dominators, doms) +} diff --git a/go/src/cmd/compile/internal/ssa/expand_calls.go b/go/src/cmd/compile/internal/ssa/expand_calls.go new file mode 100644 index 0000000000000000000000000000000000000000..3b434e4791ad7490797aee00bfd67bed8ac0a5de --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/expand_calls.go @@ -0,0 +1,987 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/abi" + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" + "fmt" +) + +func postExpandCallsDecompose(f *Func) { + decomposeUser(f) // redo user decompose to cleanup after expand calls + decomposeBuiltin(f) // handles both regular decomposition and cleanup. +} + +func expandCalls(f *Func) { + // Convert each aggregate arg to a call into "dismantle aggregate, store/pass parts" + // Convert each aggregate result from a call into "assemble aggregate from parts" + // Convert each multivalue exit into "dismantle aggregate, store/return parts" + // Convert incoming aggregate arg into assembly of parts. + // Feed modified AST to decompose. + + sp, _ := f.spSb() + + x := &expandState{ + f: f, + debug: f.pass.debug, + regSize: f.Config.RegSize, + sp: sp, + typs: &f.Config.Types, + wideSelects: make(map[*Value]*Value), + commonArgs: make(map[selKey]*Value), + commonSelectors: make(map[selKey]*Value), + memForCall: make(map[ID]*Value), + } + + // For 32-bit, need to deal with decomposition of 64-bit integers, which depends on endianness. + if f.Config.BigEndian { + x.firstOp = OpInt64Hi + x.secondOp = OpInt64Lo + x.firstType = x.typs.Int32 + x.secondType = x.typs.UInt32 + } else { + x.firstOp = OpInt64Lo + x.secondOp = OpInt64Hi + x.firstType = x.typs.UInt32 + x.secondType = x.typs.Int32 + } + + // Defer select processing until after all calls and selects are seen. + var selects []*Value + var calls []*Value + var args []*Value + var exitBlocks []*Block + + var m0 *Value + + // Accumulate lists of calls, args, selects, and exit blocks to process, + // note "wide" selects consumed by stores, + // rewrite mem for each call, + // rewrite each OpSelectNAddr. + for _, b := range f.Blocks { + for _, v := range b.Values { + switch v.Op { + case OpInitMem: + m0 = v + + case OpClosureLECall, OpInterLECall, OpStaticLECall, OpTailLECall: + calls = append(calls, v) + + case OpArg: + args = append(args, v) + + case OpStore: + if a := v.Args[1]; a.Op == OpSelectN && !CanSSA(a.Type) { + if a.Uses > 1 { + panic(fmt.Errorf("Saw double use of wide SelectN %s operand of Store %s", + a.LongString(), v.LongString())) + } + x.wideSelects[a] = v + } + + case OpSelectN: + if v.Type == types.TypeMem { + // rewrite the mem selector in place + call := v.Args[0] + aux := call.Aux.(*AuxCall) + mem := x.memForCall[call.ID] + if mem == nil { + v.AuxInt = int64(aux.abiInfo.OutRegistersUsed()) + x.memForCall[call.ID] = v + } else { + panic(fmt.Errorf("Saw two memories for call %v, %v and %v", call, mem, v)) + } + } else { + selects = append(selects, v) + } + + case OpSelectNAddr: + call := v.Args[0] + which := v.AuxInt + aux := call.Aux.(*AuxCall) + pt := v.Type + off := x.offsetFrom(x.f.Entry, x.sp, aux.OffsetOfResult(which), pt) + v.copyOf(off) + } + } + + // rewrite function results from an exit block + // values returned by function need to be split out into registers. + if isBlockMultiValueExit(b) { + exitBlocks = append(exitBlocks, b) + } + } + + // Convert each aggregate arg into Make of its parts (and so on, to primitive types) + for _, v := range args { + var rc registerCursor + a := x.prAssignForArg(v) + aux := x.f.OwnAux + regs := a.Registers + var offset int64 + if len(regs) == 0 { + offset = a.FrameOffset(aux.abiInfo) + } + auxBase := x.offsetFrom(x.f.Entry, x.sp, offset, types.NewPtr(v.Type)) + rc.init(regs, aux.abiInfo, nil, auxBase, 0) + x.rewriteSelectOrArg(f.Entry.Pos, f.Entry, v, v, m0, v.Type, rc) + } + + // Rewrite selects of results (which may be aggregates) into make-aggregates of register/memory-targeted selects + for _, v := range selects { + if v.Op == OpInvalid { + continue + } + + call := v.Args[0] + aux := call.Aux.(*AuxCall) + mem := x.memForCall[call.ID] + if mem == nil { + mem = call.Block.NewValue1I(call.Pos, OpSelectN, types.TypeMem, int64(aux.abiInfo.OutRegistersUsed()), call) + x.memForCall[call.ID] = mem + } + + i := v.AuxInt + regs := aux.RegsOfResult(i) + + // If this select cannot fit into SSA and is stored, either disaggregate to register stores, or mem-mem move. + if store := x.wideSelects[v]; store != nil { + // Use the mem that comes from the store operation. + storeAddr := store.Args[0] + mem := store.Args[2] + if len(regs) > 0 { + // Cannot do a rewrite that builds up a result from pieces; instead, copy pieces to the store operation. + var rc registerCursor + rc.init(regs, aux.abiInfo, nil, storeAddr, 0) + mem = x.rewriteWideSelectToStores(call.Pos, call.Block, v, mem, v.Type, rc) + store.copyOf(mem) + } else { + // Move directly from AuxBase to store target; rewrite the store instruction. + offset := aux.OffsetOfResult(i) + auxBase := x.offsetFrom(x.f.Entry, x.sp, offset, types.NewPtr(v.Type)) + // was Store dst, v, mem + // now Move dst, auxBase, mem + move := store.Block.NewValue3A(store.Pos, OpMove, types.TypeMem, v.Type, storeAddr, auxBase, mem) + move.AuxInt = v.Type.Size() + store.copyOf(move) + } + continue + } + + var auxBase *Value + if len(regs) == 0 { + offset := aux.OffsetOfResult(i) + auxBase = x.offsetFrom(x.f.Entry, x.sp, offset, types.NewPtr(v.Type)) + } + var rc registerCursor + rc.init(regs, aux.abiInfo, nil, auxBase, 0) + x.rewriteSelectOrArg(call.Pos, call.Block, v, v, mem, v.Type, rc) + } + + rewriteCall := func(v *Value, newOp Op, argStart int) { + // Break aggregate args passed to call into smaller pieces. + x.rewriteCallArgs(v, argStart) + v.Op = newOp + rts := abi.RegisterTypes(v.Aux.(*AuxCall).abiInfo.OutParams()) + v.Type = types.NewResults(append(rts, types.TypeMem)) + } + + // Rewrite calls + for _, v := range calls { + switch v.Op { + case OpStaticLECall: + rewriteCall(v, OpStaticCall, 0) + case OpTailLECall: + rewriteCall(v, OpTailCall, 0) + case OpClosureLECall: + rewriteCall(v, OpClosureCall, 2) + case OpInterLECall: + rewriteCall(v, OpInterCall, 1) + } + } + + // Rewrite results from exit blocks + for _, b := range exitBlocks { + v := b.Controls[0] + x.rewriteFuncResults(v, b, f.OwnAux) + b.SetControl(v) + } + +} + +func (x *expandState) rewriteFuncResults(v *Value, b *Block, aux *AuxCall) { + // This is very similar to rewriteCallArgs + // differences: + // firstArg + preArgs + // sp vs auxBase + + m0 := v.MemoryArg() + mem := m0 + + allResults := []*Value{} + var oldArgs []*Value + argsWithoutMem := v.Args[:len(v.Args)-1] + + for j, a := range argsWithoutMem { + oldArgs = append(oldArgs, a) + i := int64(j) + auxType := aux.TypeOfResult(i) + auxBase := b.NewValue2A(v.Pos, OpLocalAddr, types.NewPtr(auxType), aux.NameOfResult(i), x.sp, mem) + auxOffset := int64(0) + aRegs := aux.RegsOfResult(int64(j)) + if a.Op == OpDereference { + a.Op = OpLoad + } + var rc registerCursor + var result *[]*Value + if len(aRegs) > 0 { + result = &allResults + } else { + if a.Op == OpLoad && a.Args[0].Op == OpLocalAddr && a.Args[0].Aux == aux.NameOfResult(i) { + continue // Self move to output parameter + } + } + rc.init(aRegs, aux.abiInfo, result, auxBase, auxOffset) + mem = x.decomposeAsNecessary(v.Pos, b, a, mem, rc) + } + v.resetArgs() + v.AddArgs(allResults...) + v.AddArg(mem) + for _, a := range oldArgs { + if a.Uses == 0 { + if x.debug > 1 { + x.Printf("...marking %v unused\n", a.LongString()) + } + x.invalidateRecursively(a) + } + } + v.Type = types.NewResults(append(abi.RegisterTypes(aux.abiInfo.OutParams()), types.TypeMem)) + return +} + +func (x *expandState) rewriteCallArgs(v *Value, firstArg int) { + if x.debug > 1 { + x.indent(3) + defer x.indent(-3) + x.Printf("rewriteCallArgs(%s; %d)\n", v.LongString(), firstArg) + } + // Thread the stores on the memory arg + aux := v.Aux.(*AuxCall) + m0 := v.MemoryArg() + mem := m0 + allResults := []*Value{} + oldArgs := []*Value{} + argsWithoutMem := v.Args[firstArg : len(v.Args)-1] // Also strip closure/interface Op-specific args + + sp := x.sp + if v.Op == OpTailLECall { + // For tail call, we unwind the frame before the call so we'll use the caller's + // SP. + sp = v.Block.NewValue1(src.NoXPos, OpGetCallerSP, x.typs.Uintptr, mem) + } + + for i, a := range argsWithoutMem { // skip leading non-parameter SSA Args and trailing mem SSA Arg. + oldArgs = append(oldArgs, a) + auxI := int64(i) + aRegs := aux.RegsOfArg(auxI) + aType := aux.TypeOfArg(auxI) + + if a.Op == OpDereference { + a.Op = OpLoad + } + var rc registerCursor + var result *[]*Value + var aOffset int64 + if len(aRegs) > 0 { + result = &allResults + } else { + aOffset = aux.OffsetOfArg(auxI) + } + if v.Op == OpTailLECall && a.Op == OpArg && a.AuxInt == 0 { + // It's common for a tail call passing the same arguments (e.g. method wrapper), + // so this would be a self copy. Detect this and optimize it out. + n := a.Aux.(*ir.Name) + if n.Class == ir.PPARAM && n.FrameOffset()+x.f.Config.ctxt.Arch.FixedFrameSize == aOffset { + continue + } + } + if x.debug > 1 { + x.Printf("...storeArg %s, %v, %d\n", a.LongString(), aType, aOffset) + } + + rc.init(aRegs, aux.abiInfo, result, sp, aOffset) + mem = x.decomposeAsNecessary(v.Pos, v.Block, a, mem, rc) + } + var preArgStore [2]*Value + preArgs := append(preArgStore[:0], v.Args[0:firstArg]...) + v.resetArgs() + v.AddArgs(preArgs...) + v.AddArgs(allResults...) + v.AddArg(mem) + for _, a := range oldArgs { + if a.Uses == 0 { + x.invalidateRecursively(a) + } + } + + return +} + +func (x *expandState) decomposePair(pos src.XPos, b *Block, a, mem *Value, t0, t1 *types.Type, o0, o1 Op, rc *registerCursor) *Value { + e := b.NewValue1(pos, o0, t0, a) + pos = pos.WithNotStmt() + mem = x.decomposeAsNecessary(pos, b, e, mem, rc.next(t0)) + e = b.NewValue1(pos, o1, t1, a) + mem = x.decomposeAsNecessary(pos, b, e, mem, rc.next(t1)) + return mem +} + +func (x *expandState) decomposeOne(pos src.XPos, b *Block, a, mem *Value, t0 *types.Type, o0 Op, rc *registerCursor) *Value { + e := b.NewValue1(pos, o0, t0, a) + pos = pos.WithNotStmt() + mem = x.decomposeAsNecessary(pos, b, e, mem, rc.next(t0)) + return mem +} + +// decomposeAsNecessary converts a value (perhaps an aggregate) passed to a call or returned by a function, +// into the appropriate sequence of stores and register assignments to transmit that value in a given ABI, and +// returns the current memory after this convert/rewrite (it may be the input memory, perhaps stores were needed.) +// 'pos' is the source position all this is tied to +// 'b' is the enclosing block +// 'a' is the value to decompose +// 'm0' is the input memory arg used for the first store (or returned if there are no stores) +// 'rc' is a registerCursor which identifies the register/memory destination for the value +func (x *expandState) decomposeAsNecessary(pos src.XPos, b *Block, a, m0 *Value, rc registerCursor) *Value { + if x.debug > 1 { + x.indent(3) + defer x.indent(-3) + } + at := a.Type + if at.Size() == 0 { + return m0 + } + if a.Op == OpDereference { + a.Op = OpLoad // For purposes of parameter passing expansion, a Dereference is a Load. + } + + if !rc.hasRegs() && !CanSSA(at) { + dst := x.offsetFrom(b, rc.storeDest, rc.storeOffset, types.NewPtr(at)) + if x.debug > 1 { + x.Printf("...recur store %s at %s\n", a.LongString(), dst.LongString()) + } + if a.Op == OpLoad { + m0 = b.NewValue3A(pos, OpMove, types.TypeMem, at, dst, a.Args[0], m0) + m0.AuxInt = at.Size() + return m0 + } else { + panic(fmt.Errorf("Store of not a load")) + } + } + + mem := m0 + switch at.Kind() { + case types.TARRAY: + et := at.Elem() + for i := int64(0); i < at.NumElem(); i++ { + e := b.NewValue1I(pos, OpArraySelect, et, i, a) + pos = pos.WithNotStmt() + mem = x.decomposeAsNecessary(pos, b, e, mem, rc.next(et)) + } + return mem + + case types.TSTRUCT: + if at.IsSIMD() { + break // XXX + } + for i := 0; i < at.NumFields(); i++ { + et := at.Field(i).Type // might need to read offsets from the fields + e := b.NewValue1I(pos, OpStructSelect, et, int64(i), a) + pos = pos.WithNotStmt() + if x.debug > 1 { + x.Printf("...recur decompose %s, %v\n", e.LongString(), et) + } + mem = x.decomposeAsNecessary(pos, b, e, mem, rc.next(et)) + } + return mem + + case types.TSLICE: + mem = x.decomposeOne(pos, b, a, mem, at.Elem().PtrTo(), OpSlicePtr, &rc) + pos = pos.WithNotStmt() + mem = x.decomposeOne(pos, b, a, mem, x.typs.Int, OpSliceLen, &rc) + return x.decomposeOne(pos, b, a, mem, x.typs.Int, OpSliceCap, &rc) + + case types.TSTRING: + return x.decomposePair(pos, b, a, mem, x.typs.BytePtr, x.typs.Int, OpStringPtr, OpStringLen, &rc) + + case types.TINTER: + mem = x.decomposeOne(pos, b, a, mem, x.typs.Uintptr, OpITab, &rc) + pos = pos.WithNotStmt() + // Immediate interfaces cause so many headaches. + if a.Op == OpIMake { + data := a.Args[1] + for data.Op == OpStructMake || data.Op == OpArrayMake1 { + // A struct make might have a few zero-sized fields. + // Use the pointer-y one we know is there. + for _, a := range data.Args { + if a.Type.Size() > 0 { + data = a + break + } + } + } + return x.decomposeAsNecessary(pos, b, data, mem, rc.next(data.Type)) + } + return x.decomposeOne(pos, b, a, mem, x.typs.BytePtr, OpIData, &rc) + + case types.TCOMPLEX64: + return x.decomposePair(pos, b, a, mem, x.typs.Float32, x.typs.Float32, OpComplexReal, OpComplexImag, &rc) + + case types.TCOMPLEX128: + return x.decomposePair(pos, b, a, mem, x.typs.Float64, x.typs.Float64, OpComplexReal, OpComplexImag, &rc) + + case types.TINT64: + if at.Size() > x.regSize { + return x.decomposePair(pos, b, a, mem, x.firstType, x.secondType, x.firstOp, x.secondOp, &rc) + } + case types.TUINT64: + if at.Size() > x.regSize { + return x.decomposePair(pos, b, a, mem, x.typs.UInt32, x.typs.UInt32, x.firstOp, x.secondOp, &rc) + } + } + + // An atomic type, either record the register or store it and update the memory. + + if rc.hasRegs() { + if x.debug > 1 { + x.Printf("...recur addArg %s\n", a.LongString()) + } + rc.addArg(a) + } else { + dst := x.offsetFrom(b, rc.storeDest, rc.storeOffset, types.NewPtr(at)) + if x.debug > 1 { + x.Printf("...recur store %s at %s\n", a.LongString(), dst.LongString()) + } + mem = b.NewValue3A(pos, OpStore, types.TypeMem, at, dst, a, mem) + } + + return mem +} + +// Convert scalar OpArg into the proper OpWhateverArg instruction +// Convert scalar OpSelectN into perhaps-differently-indexed OpSelectN +// Convert aggregate OpArg into Make of its parts (which are eventually scalars) +// Convert aggregate OpSelectN into Make of its parts (which are eventually scalars) +// Returns the converted value. +// +// - "pos" the position for any generated instructions +// - "b" the block for any generated instructions +// - "container" the outermost OpArg/OpSelectN +// - "a" the instruction to overwrite, if any (only the outermost caller) +// - "m0" the memory arg for any loads that are necessary +// - "at" the type of the Arg/part +// - "rc" the register/memory cursor locating the various parts of the Arg. +func (x *expandState) rewriteSelectOrArg(pos src.XPos, b *Block, container, a, m0 *Value, at *types.Type, rc registerCursor) *Value { + + if at == types.TypeMem { + a.copyOf(m0) + return a + } + + makeOf := func(a *Value, op Op, args []*Value) *Value { + if a == nil { + a = b.NewValue0(pos, op, at) + a.AddArgs(args...) + } else { + a.resetArgs() + a.Aux, a.AuxInt = nil, 0 + a.Pos, a.Op, a.Type = pos, op, at + a.AddArgs(args...) + } + return a + } + + if at.Size() == 0 { + // For consistency, create these values even though they'll ultimately be unused + return makeOf(a, OpEmpty, nil) + } + + sk := selKey{from: container, size: 0, offsetOrIndex: rc.storeOffset, typ: at} + dupe := x.commonSelectors[sk] + if dupe != nil { + if a == nil { + return dupe + } + a.copyOf(dupe) + return a + } + + var argStore [10]*Value + args := argStore[:0] + + addArg := func(a0 *Value) { + if a0 == nil { + as := "" + if a != nil { + as = a.LongString() + } + panic(fmt.Errorf("a0 should not be nil, a=%v, container=%v, at=%v", as, container.LongString(), at)) + } + args = append(args, a0) + } + + switch at.Kind() { + case types.TARRAY: + et := at.Elem() + for i := int64(0); i < at.NumElem(); i++ { + e := x.rewriteSelectOrArg(pos, b, container, nil, m0, et, rc.next(et)) + addArg(e) + } + a = makeOf(a, OpArrayMake1, args) + x.commonSelectors[sk] = a + return a + + case types.TSTRUCT: + // Assume ssagen/ssa.go (in buildssa) spills large aggregates so they won't appear here. + if at.IsSIMD() { + break // XXX + } + for i := 0; i < at.NumFields(); i++ { + et := at.Field(i).Type + e := x.rewriteSelectOrArg(pos, b, container, nil, m0, et, rc.next(et)) + if e == nil { + panic(fmt.Errorf("nil e, et=%v, et.Size()=%d, i=%d", et, et.Size(), i)) + } + addArg(e) + pos = pos.WithNotStmt() + } + if at.NumFields() > MaxStruct && !types.IsDirectIface(at) { + panic(fmt.Errorf("Too many fields (%d, %d bytes), container=%s", at.NumFields(), at.Size(), container.LongString())) + } + a = makeOf(a, OpStructMake, args) + x.commonSelectors[sk] = a + return a + + case types.TSLICE: + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, at.Elem().PtrTo(), rc.next(x.typs.BytePtr))) + pos = pos.WithNotStmt() + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.Int, rc.next(x.typs.Int))) + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.Int, rc.next(x.typs.Int))) + a = makeOf(a, OpSliceMake, args) + x.commonSelectors[sk] = a + return a + + case types.TSTRING: + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.BytePtr, rc.next(x.typs.BytePtr))) + pos = pos.WithNotStmt() + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.Int, rc.next(x.typs.Int))) + a = makeOf(a, OpStringMake, args) + x.commonSelectors[sk] = a + return a + + case types.TINTER: + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.Uintptr, rc.next(x.typs.Uintptr))) + pos = pos.WithNotStmt() + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.BytePtr, rc.next(x.typs.BytePtr))) + a = makeOf(a, OpIMake, args) + x.commonSelectors[sk] = a + return a + + case types.TCOMPLEX64: + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.Float32, rc.next(x.typs.Float32))) + pos = pos.WithNotStmt() + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.Float32, rc.next(x.typs.Float32))) + a = makeOf(a, OpComplexMake, args) + x.commonSelectors[sk] = a + return a + + case types.TCOMPLEX128: + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.Float64, rc.next(x.typs.Float64))) + pos = pos.WithNotStmt() + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.Float64, rc.next(x.typs.Float64))) + a = makeOf(a, OpComplexMake, args) + x.commonSelectors[sk] = a + return a + + case types.TINT64: + if at.Size() > x.regSize { + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.firstType, rc.next(x.firstType))) + pos = pos.WithNotStmt() + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.secondType, rc.next(x.secondType))) + if !x.f.Config.BigEndian { + // Int64Make args are big, little + args[0], args[1] = args[1], args[0] + } + a = makeOf(a, OpInt64Make, args) + x.commonSelectors[sk] = a + return a + } + case types.TUINT64: + if at.Size() > x.regSize { + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.UInt32, rc.next(x.typs.UInt32))) + pos = pos.WithNotStmt() + addArg(x.rewriteSelectOrArg(pos, b, container, nil, m0, x.typs.UInt32, rc.next(x.typs.UInt32))) + if !x.f.Config.BigEndian { + // Int64Make args are big, little + args[0], args[1] = args[1], args[0] + } + a = makeOf(a, OpInt64Make, args) + x.commonSelectors[sk] = a + return a + } + } + + // An atomic type, either record the register or store it and update the memory. + + // Depending on the container Op, the leaves are either OpSelectN or OpArg{Int,Float}Reg + + if container.Op == OpArg { + if rc.hasRegs() { + op, i := rc.ArgOpAndRegisterFor() + name := container.Aux.(*ir.Name) + a = makeOf(a, op, nil) + a.AuxInt = i + a.Aux = &AuxNameOffset{name, rc.storeOffset} + } else { + key := selKey{container, rc.storeOffset, at.Size(), at} + w := x.commonArgs[key] + if w != nil && w.Uses != 0 { + if a == nil { + a = w + } else { + a.copyOf(w) + } + } else { + if a == nil { + aux := container.Aux + auxInt := container.AuxInt + rc.storeOffset + a = container.Block.NewValue0IA(container.Pos, OpArg, at, auxInt, aux) + } else { + // do nothing, the original should be okay. + } + x.commonArgs[key] = a + } + } + } else if container.Op == OpSelectN { + call := container.Args[0] + aux := call.Aux.(*AuxCall) + which := container.AuxInt + + if at == types.TypeMem { + if a != m0 || a != x.memForCall[call.ID] { + panic(fmt.Errorf("Memories %s, %s, and %s should all be equal after %s", a.LongString(), m0.LongString(), x.memForCall[call.ID], call.LongString())) + } + } else if rc.hasRegs() { + firstReg := uint32(0) + for i := 0; i < int(which); i++ { + firstReg += uint32(len(aux.abiInfo.OutParam(i).Registers)) + } + reg := int64(rc.nextSlice + Abi1RO(firstReg)) + a = makeOf(a, OpSelectN, []*Value{call}) + a.AuxInt = reg + } else { + off := x.offsetFrom(x.f.Entry, x.sp, rc.storeOffset+aux.OffsetOfResult(which), types.NewPtr(at)) + a = makeOf(a, OpLoad, []*Value{off, m0}) + } + + } else { + panic(fmt.Errorf("Expected container OpArg or OpSelectN, saw %v instead", container.LongString())) + } + + x.commonSelectors[sk] = a + return a +} + +// rewriteWideSelectToStores handles the case of a SelectN'd result from a function call that is too large for SSA, +// but is transferred in registers. In this case the register cursor tracks both operands; the register sources and +// the memory destinations. +// This returns the memory flowing out of the last store +func (x *expandState) rewriteWideSelectToStores(pos src.XPos, b *Block, container, m0 *Value, at *types.Type, rc registerCursor) *Value { + + if at.Size() == 0 { + return m0 + } + + switch at.Kind() { + case types.TARRAY: + et := at.Elem() + for i := int64(0); i < at.NumElem(); i++ { + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, et, rc.next(et)) + } + return m0 + + case types.TSTRUCT: + // Assume ssagen/ssa.go (in buildssa) spills large aggregates so they won't appear here. + if at.IsSIMD() { + break // XXX + } + for i := 0; i < at.NumFields(); i++ { + et := at.Field(i).Type + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, et, rc.next(et)) + pos = pos.WithNotStmt() + } + return m0 + + case types.TSLICE: + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, at.Elem().PtrTo(), rc.next(x.typs.BytePtr)) + pos = pos.WithNotStmt() + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.Int, rc.next(x.typs.Int)) + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.Int, rc.next(x.typs.Int)) + return m0 + + case types.TSTRING: + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.BytePtr, rc.next(x.typs.BytePtr)) + pos = pos.WithNotStmt() + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.Int, rc.next(x.typs.Int)) + return m0 + + case types.TINTER: + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.Uintptr, rc.next(x.typs.Uintptr)) + pos = pos.WithNotStmt() + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.BytePtr, rc.next(x.typs.BytePtr)) + return m0 + + case types.TCOMPLEX64: + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.Float32, rc.next(x.typs.Float32)) + pos = pos.WithNotStmt() + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.Float32, rc.next(x.typs.Float32)) + return m0 + + case types.TCOMPLEX128: + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.Float64, rc.next(x.typs.Float64)) + pos = pos.WithNotStmt() + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.Float64, rc.next(x.typs.Float64)) + return m0 + + case types.TINT64: + if at.Size() > x.regSize { + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.firstType, rc.next(x.firstType)) + pos = pos.WithNotStmt() + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.secondType, rc.next(x.secondType)) + return m0 + } + case types.TUINT64: + if at.Size() > x.regSize { + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.UInt32, rc.next(x.typs.UInt32)) + pos = pos.WithNotStmt() + m0 = x.rewriteWideSelectToStores(pos, b, container, m0, x.typs.UInt32, rc.next(x.typs.UInt32)) + return m0 + } + } + + // TODO could change treatment of too-large OpArg, would deal with it here. + if container.Op == OpSelectN { + call := container.Args[0] + aux := call.Aux.(*AuxCall) + which := container.AuxInt + + if rc.hasRegs() { + firstReg := uint32(0) + for i := 0; i < int(which); i++ { + firstReg += uint32(len(aux.abiInfo.OutParam(i).Registers)) + } + reg := int64(rc.nextSlice + Abi1RO(firstReg)) + a := b.NewValue1I(pos, OpSelectN, at, reg, call) + dst := x.offsetFrom(b, rc.storeDest, rc.storeOffset, types.NewPtr(at)) + m0 = b.NewValue3A(pos, OpStore, types.TypeMem, at, dst, a, m0) + } else { + panic(fmt.Errorf("Expected rc to have registers")) + } + } else { + panic(fmt.Errorf("Expected container OpSelectN, saw %v instead", container.LongString())) + } + return m0 +} + +func isBlockMultiValueExit(b *Block) bool { + return (b.Kind == BlockRet || b.Kind == BlockRetJmp) && b.Controls[0] != nil && b.Controls[0].Op == OpMakeResult +} + +type Abi1RO uint8 // An offset within a parameter's slice of register indices, for abi1. + +// A registerCursor tracks which register is used for an Arg or regValues, or a piece of such. +type registerCursor struct { + storeDest *Value // if there are no register targets, then this is the base of the store. + storeOffset int64 + regs []abi.RegIndex // the registers available for this Arg/result (which is all in registers or not at all) + nextSlice Abi1RO // the next register/register-slice offset + config *abi.ABIConfig + regValues *[]*Value // values assigned to registers accumulate here +} + +func (c *registerCursor) String() string { + dest := "" + if c.storeDest != nil { + dest = fmt.Sprintf("%s+%d", c.storeDest.String(), c.storeOffset) + } + regs := "" + if c.regValues != nil { + regs = "" + for i, x := range *c.regValues { + if i > 0 { + regs = regs + "; " + } + regs = regs + x.LongString() + } + } + + // not printing the config because that has not been useful + return fmt.Sprintf("RCSR{storeDest=%v, regsLen=%d, nextSlice=%d, regValues=[%s]}", dest, len(c.regs), c.nextSlice, regs) +} + +// next effectively post-increments the register cursor; the receiver is advanced, +// the (aligned) old value is returned. +func (c *registerCursor) next(t *types.Type) registerCursor { + c.storeOffset = types.RoundUp(c.storeOffset, t.Alignment()) + rc := *c + c.storeOffset = types.RoundUp(c.storeOffset+t.Size(), t.Alignment()) + if int(c.nextSlice) < len(c.regs) { + w := c.config.NumParamRegs(t) + c.nextSlice += Abi1RO(w) + } + return rc +} + +// plus returns a register cursor offset from the original, without modifying the original. +func (c *registerCursor) plus(regWidth Abi1RO) registerCursor { + rc := *c + rc.nextSlice += regWidth + return rc +} + +func (c *registerCursor) init(regs []abi.RegIndex, info *abi.ABIParamResultInfo, result *[]*Value, storeDest *Value, storeOffset int64) { + c.regs = regs + c.nextSlice = 0 + c.storeOffset = storeOffset + c.storeDest = storeDest + c.config = info.Config() + c.regValues = result +} + +func (c *registerCursor) addArg(v *Value) { + *c.regValues = append(*c.regValues, v) +} + +func (c *registerCursor) hasRegs() bool { + return len(c.regs) > 0 +} + +func (c *registerCursor) ArgOpAndRegisterFor() (Op, int64) { + r := c.regs[c.nextSlice] + return ArgOpAndRegisterFor(r, c.config) +} + +// ArgOpAndRegisterFor converts an abi register index into an ssa Op and corresponding +// arg register index. +func ArgOpAndRegisterFor(r abi.RegIndex, abiConfig *abi.ABIConfig) (Op, int64) { + i := abiConfig.FloatIndexFor(r) + if i >= 0 { // float PR + return OpArgFloatReg, i + } + return OpArgIntReg, int64(r) +} + +type selKey struct { + from *Value // what is selected from + offsetOrIndex int64 // whatever is appropriate for the selector + size int64 + typ *types.Type +} + +type expandState struct { + f *Func + debug int // odd values log lost statement markers, so likely settings are 1 (stmts), 2 (expansion), and 3 (both) + regSize int64 + sp *Value + typs *Types + + firstOp Op // for 64-bit integers on 32-bit machines, first word in memory + secondOp Op // for 64-bit integers on 32-bit machines, second word in memory + firstType *types.Type // first half type, for Int64 + secondType *types.Type // second half type, for Int64 + + wideSelects map[*Value]*Value // Selects that are not SSA-able, mapped to consuming stores. + commonSelectors map[selKey]*Value // used to de-dupe selectors + commonArgs map[selKey]*Value // used to de-dupe OpArg/OpArgIntReg/OpArgFloatReg + memForCall map[ID]*Value // For a call, need to know the unique selector that gets the mem. + indentLevel int // Indentation for debugging recursion +} + +// offsetFrom creates an offset from a pointer, simplifying chained offsets and offsets from SP +func (x *expandState) offsetFrom(b *Block, from *Value, offset int64, pt *types.Type) *Value { + ft := from.Type + if offset == 0 { + if ft == pt { + return from + } + // This captures common, (apparently) safe cases. The unsafe cases involve ft == uintptr + if (ft.IsPtr() || ft.IsUnsafePtr()) && pt.IsPtr() { + return from + } + } + // Simplify, canonicalize + for from.Op == OpOffPtr { + offset += from.AuxInt + from = from.Args[0] + } + if from == x.sp { + return x.f.ConstOffPtrSP(pt, offset, x.sp) + } + return b.NewValue1I(from.Pos.WithNotStmt(), OpOffPtr, pt, offset, from) +} + +// prAssignForArg returns the ABIParamAssignment for v, assumed to be an OpArg. +func (x *expandState) prAssignForArg(v *Value) *abi.ABIParamAssignment { + if v.Op != OpArg { + panic(fmt.Errorf("Wanted OpArg, instead saw %s", v.LongString())) + } + return ParamAssignmentForArgName(x.f, v.Aux.(*ir.Name)) +} + +// ParamAssignmentForArgName returns the ABIParamAssignment for f's arg with matching name. +func ParamAssignmentForArgName(f *Func, name *ir.Name) *abi.ABIParamAssignment { + abiInfo := f.OwnAux.abiInfo + ip := abiInfo.InParams() + for i, a := range ip { + if a.Name == name { + return &ip[i] + } + } + panic(fmt.Errorf("Did not match param %v in prInfo %+v", name, abiInfo.InParams())) +} + +// indent increments (or decrements) the indentation. +func (x *expandState) indent(n int) { + x.indentLevel += n +} + +// Printf does an indented fmt.Printf on the format and args. +func (x *expandState) Printf(format string, a ...any) (n int, err error) { + if x.indentLevel > 0 { + fmt.Printf("%[1]*s", x.indentLevel, "") + } + return fmt.Printf(format, a...) +} + +func (x *expandState) invalidateRecursively(a *Value) { + var s string + if x.debug > 0 { + plus := " " + if a.Pos.IsStmt() == src.PosIsStmt { + plus = " +" + } + s = a.String() + plus + a.Pos.LineNumber() + " " + a.LongString() + if x.debug > 1 { + x.Printf("...marking %v unused\n", s) + } + } + lost := a.invalidateRecursively() + if x.debug&1 != 0 && lost { // For odd values of x.debug, do this. + x.Printf("Lost statement marker in %s on former %s\n", base.Ctxt.Pkgpath+"."+x.f.Name, s) + } +} diff --git a/go/src/cmd/compile/internal/ssa/export_test.go b/go/src/cmd/compile/internal/ssa/export_test.go new file mode 100644 index 0000000000000000000000000000000000000000..3ab0be7311338c3b6f2f07c6e27927924e07c7be --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/export_test.go @@ -0,0 +1,123 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "testing" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/arm64" + "cmd/internal/obj/s390x" + "cmd/internal/obj/x86" + "cmd/internal/src" + "cmd/internal/sys" +) + +var CheckFunc = checkFunc +var Opt = opt +var Deadcode = deadcode +var Copyelim = copyelim + +var testCtxts = map[string]*obj.Link{ + "amd64": obj.Linknew(&x86.Linkamd64), + "s390x": obj.Linknew(&s390x.Links390x), + "arm64": obj.Linknew(&arm64.Linkarm64), +} + +func testConfig(tb testing.TB) *Conf { return testConfigArch(tb, "amd64") } +func testConfigS390X(tb testing.TB) *Conf { return testConfigArch(tb, "s390x") } +func testConfigARM64(tb testing.TB) *Conf { return testConfigArch(tb, "arm64") } + +func testConfigArch(tb testing.TB, arch string) *Conf { + ctxt, ok := testCtxts[arch] + if !ok { + tb.Fatalf("unknown arch %s", arch) + } + if ctxt.Arch.PtrSize != 8 { + tb.Fatal("testTypes is 64-bit only") + } + c := &Conf{ + config: NewConfig(arch, testTypes, ctxt, true, false), + tb: tb, + } + return c +} + +type Conf struct { + config *Config + tb testing.TB + fe Frontend +} + +func (c *Conf) Frontend() Frontend { + if c.fe == nil { + pkg := types.NewPkg("my/import/path", "path") + fn := ir.NewFunc(src.NoXPos, src.NoXPos, pkg.Lookup("function"), types.NewSignature(nil, nil, nil)) + fn.DeclareParams(true) + fn.LSym = &obj.LSym{Name: "my/import/path.function"} + + c.fe = TestFrontend{ + t: c.tb, + ctxt: c.config.ctxt, + f: fn, + } + } + return c.fe +} + +func (c *Conf) Temp(typ *types.Type) *ir.Name { + n := ir.NewNameAt(src.NoXPos, &types.Sym{Name: "aFakeAuto"}, typ) + n.Class = ir.PAUTO + return n +} + +// TestFrontend is a test-only frontend. +// It assumes 64 bit integers and pointers. +type TestFrontend struct { + t testing.TB + ctxt *obj.Link + f *ir.Func +} + +func (TestFrontend) StringData(s string) *obj.LSym { + return nil +} +func (d TestFrontend) SplitSlot(parent *LocalSlot, suffix string, offset int64, t *types.Type) LocalSlot { + return LocalSlot{N: parent.N, Type: t, Off: offset} +} +func (d TestFrontend) Syslook(s string) *obj.LSym { + return d.ctxt.Lookup(s) +} +func (TestFrontend) UseWriteBarrier() bool { + return true // only writebarrier_test cares +} + +func (d TestFrontend) Logf(msg string, args ...any) { d.t.Logf(msg, args...) } +func (d TestFrontend) Log() bool { return true } + +func (d TestFrontend) Fatalf(_ src.XPos, msg string, args ...any) { d.t.Fatalf(msg, args...) } +func (d TestFrontend) Warnl(_ src.XPos, msg string, args ...any) { d.t.Logf(msg, args...) } +func (d TestFrontend) Debug_checknil() bool { return false } + +func (d TestFrontend) Func() *ir.Func { + return d.f +} + +var testTypes Types + +func init() { + // TODO(mdempsky): Push into types.InitUniverse or typecheck.InitUniverse. + types.PtrSize = 8 + types.RegSize = 8 + types.MaxWidth = 1 << 50 + + base.Ctxt = &obj.Link{Arch: &obj.LinkArch{Arch: &sys.Arch{Alignment: 1, CanMergeLoads: true}}} + typecheck.InitUniverse() + testTypes.SetTypPtrs() +} diff --git a/go/src/cmd/compile/internal/ssa/flagalloc.go b/go/src/cmd/compile/internal/ssa/flagalloc.go new file mode 100644 index 0000000000000000000000000000000000000000..cf2c9a0023f925a003c6bdac4ff7f56702204a89 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/flagalloc.go @@ -0,0 +1,270 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// flagalloc allocates the flag register among all the flag-generating +// instructions. Flag values are recomputed if they need to be +// spilled/restored. +func flagalloc(f *Func) { + // Compute the in-register flag value we want at the end of + // each block. This is basically a best-effort live variable + // analysis, so it can be much simpler than a full analysis. + end := f.Cache.allocValueSlice(f.NumBlocks()) + defer f.Cache.freeValueSlice(end) + po := f.postorder() + for n := 0; n < 2; n++ { + for _, b := range po { + // Walk values backwards to figure out what flag + // value we want in the flag register at the start + // of the block. + var flag *Value + for _, c := range b.ControlValues() { + if c.Type.IsFlags() { + if flag != nil { + panic("cannot have multiple controls using flags") + } + flag = c + } + } + if flag == nil { + flag = end[b.ID] + } + for j := len(b.Values) - 1; j >= 0; j-- { + v := b.Values[j] + if v == flag { + flag = nil + } + if v.clobbersFlags() { + flag = nil + } + for _, a := range v.Args { + if a.Type.IsFlags() { + flag = a + } + } + } + if flag != nil { + for _, e := range b.Preds { + p := e.b + end[p.ID] = flag + } + } + } + } + + // For blocks which have a flags control value, that's the only value + // we can leave in the flags register at the end of the block. (There + // is no place to put a flag regeneration instruction.) + for _, b := range f.Blocks { + if b.Kind == BlockDefer { + // Defer blocks internally use/clobber the flags value. + end[b.ID] = nil + continue + } + for _, v := range b.ControlValues() { + if v.Type.IsFlags() && end[b.ID] != v { + end[b.ID] = nil + } + } + } + + // Compute which flags values will need to be spilled. + spill := map[ID]bool{} + for _, b := range f.Blocks { + var flag *Value + if len(b.Preds) > 0 { + flag = end[b.Preds[0].b.ID] + } + for _, v := range b.Values { + for _, a := range v.Args { + if !a.Type.IsFlags() { + continue + } + if a == flag { + continue + } + // a will need to be restored here. + spill[a.ID] = true + flag = a + } + if v.clobbersFlags() { + flag = nil + } + if v.Type.IsFlags() { + flag = v + } + } + for _, v := range b.ControlValues() { + if v != flag && v.Type.IsFlags() { + spill[v.ID] = true + } + } + if v := end[b.ID]; v != nil && v != flag { + spill[v.ID] = true + } + } + + // Add flag spill and recomputation where they are needed. + var remove []*Value // values that should be checked for possible removal + var oldSched []*Value + for _, b := range f.Blocks { + oldSched = append(oldSched[:0], b.Values...) + b.Values = b.Values[:0] + // The current live flag value (the pre-flagalloc copy). + var flag *Value + if len(b.Preds) > 0 { + flag = end[b.Preds[0].b.ID] + // Note: the following condition depends on the lack of critical edges. + for _, e := range b.Preds[1:] { + p := e.b + if end[p.ID] != flag { + f.Fatalf("live flag in %s's predecessors not consistent", b) + } + } + } + for _, v := range oldSched { + if v.Op == OpPhi && v.Type.IsFlags() { + f.Fatalf("phi of flags not supported: %s", v.LongString()) + } + + // If v will be spilled, and v uses memory, then we must split it + // into a load + a flag generator. + if spill[v.ID] && v.MemoryArg() != nil { + remove = append(remove, v) + if !f.Config.splitLoad(v) { + f.Fatalf("can't split flag generator: %s", v.LongString()) + } + } + + // Make sure any flag arg of v is in the flags register. + // If not, recompute it. + for i, a := range v.Args { + if !a.Type.IsFlags() { + continue + } + if a == flag { + continue + } + // Recalculate a + c := copyFlags(a, b) + // Update v. + v.SetArg(i, c) + // Remember the most-recently computed flag value. + flag = a + } + // Issue v. + b.Values = append(b.Values, v) + if v.clobbersFlags() { + flag = nil + } + if v.Type.IsFlags() { + flag = v + } + } + for i, v := range b.ControlValues() { + if v != flag && v.Type.IsFlags() { + // Recalculate control value. + remove = append(remove, v) + c := copyFlags(v, b) + b.ReplaceControl(i, c) + flag = v + } + } + if v := end[b.ID]; v != nil && v != flag { + // Need to reissue flag generator for use by + // subsequent blocks. + remove = append(remove, v) + copyFlags(v, b) + // Note: this flag generator is not properly linked up + // with the flag users. This breaks the SSA representation. + // We could fix up the users with another pass, but for now + // we'll just leave it. (Regalloc has the same issue for + // standard regs, and it runs next.) + // For this reason, take care not to add this flag + // generator to the remove list. + } + } + + // Save live flag state for later. + for _, b := range f.Blocks { + b.FlagsLiveAtEnd = end[b.ID] != nil + } + + // Remove any now-dead values. + // The number of values to remove is likely small, + // and removing them requires processing all values in a block, + // so minimize the number of blocks that we touch. + + // Shrink remove to contain only dead values, and clobber those dead values. + for i := 0; i < len(remove); i++ { + v := remove[i] + if v.Uses == 0 { + v.reset(OpInvalid) + continue + } + // Remove v. + last := len(remove) - 1 + remove[i] = remove[last] + remove[last] = nil + remove = remove[:last] + i-- // reprocess value at i + } + + if len(remove) == 0 { + return + } + + removeBlocks := f.newSparseSet(f.NumBlocks()) + defer f.retSparseSet(removeBlocks) + for _, v := range remove { + removeBlocks.add(v.Block.ID) + } + + // Process affected blocks, preserving value order. + for _, b := range f.Blocks { + if !removeBlocks.contains(b.ID) { + continue + } + i := 0 + for j := 0; j < len(b.Values); j++ { + v := b.Values[j] + if v.Op == OpInvalid { + continue + } + b.Values[i] = v + i++ + } + b.truncateValues(i) + } +} + +func (v *Value) clobbersFlags() bool { + if opcodeTable[v.Op].clobberFlags { + return true + } + if v.Type.IsTuple() && (v.Type.FieldType(0).IsFlags() || v.Type.FieldType(1).IsFlags()) { + // This case handles the possibility where a flag value is generated but never used. + // In that case, there's no corresponding Select to overwrite the flags value, + // so we must consider flags clobbered by the tuple-generating instruction. + return true + } + return false +} + +// copyFlags copies v (flag generator) into b, returns the copy. +// If v's arg is also flags, copy recursively. +func copyFlags(v *Value, b *Block) *Value { + flagsArgs := make(map[int]*Value) + for i, a := range v.Args { + if a.Type.IsFlags() || a.Type.IsTuple() { + flagsArgs[i] = copyFlags(a, b) + } + } + c := v.copyInto(b) + for i, a := range flagsArgs { + c.SetArg(i, a) + } + return c +} diff --git a/go/src/cmd/compile/internal/ssa/flags_amd64_test.s b/go/src/cmd/compile/internal/ssa/flags_amd64_test.s new file mode 100644 index 0000000000000000000000000000000000000000..7402f6badb1d8254bd879a4d7e92118860ca2b81 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/flags_amd64_test.s @@ -0,0 +1,29 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "textflag.h" + +TEXT ·asmAddFlags(SB),NOSPLIT,$0-24 + MOVQ x+0(FP), AX + ADDQ y+8(FP), AX + PUSHFQ + POPQ AX + MOVQ AX, ret+16(FP) + RET + +TEXT ·asmSubFlags(SB),NOSPLIT,$0-24 + MOVQ x+0(FP), AX + SUBQ y+8(FP), AX + PUSHFQ + POPQ AX + MOVQ AX, ret+16(FP) + RET + +TEXT ·asmAndFlags(SB),NOSPLIT,$0-24 + MOVQ x+0(FP), AX + ANDQ y+8(FP), AX + PUSHFQ + POPQ AX + MOVQ AX, ret+16(FP) + RET diff --git a/go/src/cmd/compile/internal/ssa/flags_arm64_test.s b/go/src/cmd/compile/internal/ssa/flags_arm64_test.s new file mode 100644 index 0000000000000000000000000000000000000000..639d7e3aedc299ece9b9a0a27debc8b566eee922 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/flags_arm64_test.s @@ -0,0 +1,30 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "textflag.h" + +TEXT ·asmAddFlags(SB),NOSPLIT,$0-24 + MOVD x+0(FP), R0 + MOVD y+8(FP), R1 + CMN R0, R1 + WORD $0xd53b4200 // MOVD NZCV, R0 + MOVD R0, ret+16(FP) + RET + +TEXT ·asmSubFlags(SB),NOSPLIT,$0-24 + MOVD x+0(FP), R0 + MOVD y+8(FP), R1 + CMP R1, R0 + WORD $0xd53b4200 // MOVD NZCV, R0 + MOVD R0, ret+16(FP) + RET + +TEXT ·asmAndFlags(SB),NOSPLIT,$0-24 + MOVD x+0(FP), R0 + MOVD y+8(FP), R1 + TST R1, R0 + WORD $0xd53b4200 // MOVD NZCV, R0 + BIC $0x30000000, R0 // clear C, V bits, as TST does not change those flags + MOVD R0, ret+16(FP) + RET diff --git a/go/src/cmd/compile/internal/ssa/flags_test.go b/go/src/cmd/compile/internal/ssa/flags_test.go new file mode 100644 index 0000000000000000000000000000000000000000..d0079ac5e83823d8e22ad414f88f61af3aa56bf5 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/flags_test.go @@ -0,0 +1,108 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build amd64 || arm64 + +package ssa + +// This file tests the functions addFlags64 and subFlags64 by comparing their +// results to what the chip calculates. + +import ( + "runtime" + "testing" +) + +func TestAddFlagsNative(t *testing.T) { + var numbers = []int64{ + 1, 0, -1, + 2, -2, + 1<<63 - 1, -1 << 63, + } + coverage := map[flagConstant]bool{} + for _, x := range numbers { + for _, y := range numbers { + a := addFlags64(x, y) + b := flagRegister2flagConstant(asmAddFlags(x, y), false) + if a != b { + t.Errorf("asmAdd diff: x=%x y=%x got=%s want=%s\n", x, y, a, b) + } + coverage[a] = true + } + } + if len(coverage) != 9 { // TODO: can we cover all outputs? + t.Errorf("coverage too small, got %d want 9", len(coverage)) + } +} + +func TestSubFlagsNative(t *testing.T) { + var numbers = []int64{ + 1, 0, -1, + 2, -2, + 1<<63 - 1, -1 << 63, + } + coverage := map[flagConstant]bool{} + for _, x := range numbers { + for _, y := range numbers { + a := subFlags64(x, y) + b := flagRegister2flagConstant(asmSubFlags(x, y), true) + if a != b { + t.Errorf("asmSub diff: x=%x y=%x got=%s want=%s\n", x, y, a, b) + } + coverage[a] = true + } + } + if len(coverage) != 7 { // TODO: can we cover all outputs? + t.Errorf("coverage too small, got %d want 7", len(coverage)) + } +} + +func TestAndFlagsNative(t *testing.T) { + var numbers = []int64{ + 1, 0, -1, + 2, -2, + 1<<63 - 1, -1 << 63, + } + coverage := map[flagConstant]bool{} + for _, x := range numbers { + for _, y := range numbers { + a := logicFlags64(x & y) + b := flagRegister2flagConstant(asmAndFlags(x, y), false) + if a != b { + t.Errorf("asmAnd diff: x=%x y=%x got=%s want=%s\n", x, y, a, b) + } + coverage[a] = true + } + } + if len(coverage) != 3 { + t.Errorf("coverage too small, got %d want 3", len(coverage)) + } +} + +func asmAddFlags(x, y int64) int +func asmSubFlags(x, y int64) int +func asmAndFlags(x, y int64) int + +func flagRegister2flagConstant(x int, sub bool) flagConstant { + var fcb flagConstantBuilder + switch runtime.GOARCH { + case "amd64": + fcb.Z = x>>6&1 != 0 + fcb.N = x>>7&1 != 0 + fcb.C = x>>0&1 != 0 + if sub { + // Convert from amd64-sense to arm-sense + fcb.C = !fcb.C + } + fcb.V = x>>11&1 != 0 + case "arm64": + fcb.Z = x>>30&1 != 0 + fcb.N = x>>31&1 != 0 + fcb.C = x>>29&1 != 0 + fcb.V = x>>28&1 != 0 + default: + panic("unsupported architecture: " + runtime.GOARCH) + } + return fcb.encode() +} diff --git a/go/src/cmd/compile/internal/ssa/fmahash_test.go b/go/src/cmd/compile/internal/ssa/fmahash_test.go new file mode 100644 index 0000000000000000000000000000000000000000..c563d5b8d9d01be650306cfc7cc8af559c782835 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/fmahash_test.go @@ -0,0 +1,52 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa_test + +import ( + "internal/testenv" + "path/filepath" + "regexp" + "runtime" + "testing" +) + +// TestFmaHash checks that the hash-test machinery works properly for a single case. +// It also runs ssa/check and gccheck to be sure that those are checked at least a +// little in each run.bash. It does not check or run the generated code. +// The test file is however a useful example of fused-vs-cascaded multiply-add. +func TestFmaHash(t *testing.T) { + switch runtime.GOOS { + case "linux", "darwin": + default: + t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS) + } + switch runtime.GOARCH { + case "amd64", "arm64": + default: + t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH) + } + + testenv.MustHaveGoBuild(t) + gocmd := testenv.GoToolPath(t) + tmpdir := t.TempDir() + source := filepath.Join("testdata", "fma.go") + output := filepath.Join(tmpdir, "fma.exe") + cmd := testenv.Command(t, gocmd, "build", "-o", output, source) + // The hash-dependence on file path name is dodged by specifying "all hashes ending in 1" plus "all hashes ending in 0" + // i.e., all hashes. This will print all the FMAs; this test is only interested in one of them (that should appear near the end). + cmd.Env = append(cmd.Env, "GOCOMPILEDEBUG=fmahash=1/0", "GOOS=linux", "GOARCH=arm64", "HOME="+tmpdir) + t.Logf("%v", cmd) + t.Logf("%v", cmd.Env) + b, e := cmd.CombinedOutput() + if e != nil { + t.Errorf("build failed: %v\n%s", e, b) + } + s := string(b) // Looking for "GOFMAHASH triggered main.main:24" + re := "fmahash(0?) triggered .*fma.go:29:..;.*fma.go:18:.." + match := regexp.MustCompile(re) + if !match.MatchString(s) { + t.Errorf("Expected to match '%s' with \n-----\n%s-----", re, s) + } +} diff --git a/go/src/cmd/compile/internal/ssa/func.go b/go/src/cmd/compile/internal/ssa/func.go new file mode 100644 index 0000000000000000000000000000000000000000..690e2f033d67e6ac52ccabde6f873ba6d4a2df2d --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/func.go @@ -0,0 +1,880 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/abi" + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" + "fmt" + "math" + "strings" +) + +// A Func represents a Go func declaration (or function literal) and its body. +// This package compiles each Func independently. +// Funcs are single-use; a new Func must be created for every compiled function. +type Func struct { + Config *Config // architecture information + Cache *Cache // re-usable cache + fe Frontend // frontend state associated with this Func, callbacks into compiler frontend + pass *pass // current pass information (name, options, etc.) + Name string // e.g. NewFunc or (*Func).NumBlocks (no package prefix) + Type *types.Type // type signature of the function. + Blocks []*Block // unordered set of all basic blocks (note: not indexable by ID) + Entry *Block // the entry basic block + + bid idAlloc // block ID allocator + vid idAlloc // value ID allocator + + HTMLWriter *HTMLWriter // html writer, for debugging + PrintOrHtmlSSA bool // true if GOSSAFUNC matches, true even if fe.Log() (spew phase results to stdout) is false. There's an odd dependence on this in debug.go for method logf. + ruleMatches map[string]int // number of times countRule was called during compilation for any given string + ABI0 *abi.ABIConfig // A copy, for no-sync access + ABI1 *abi.ABIConfig // A copy, for no-sync access + ABISelf *abi.ABIConfig // ABI for function being compiled + ABIDefault *abi.ABIConfig // ABI for rtcall and other no-parsed-signature/pragma functions. + + maxCPUFeatures CPUfeatures // union of all the CPU features in all the blocks. + + scheduled bool // Values in Blocks are in final order + laidout bool // Blocks are ordered + NoSplit bool // true if function is marked as nosplit. Used by schedule check pass. + dumpFileSeq uint8 // the sequence numbers of dump file. (%s_%02d__%s.dump", funcname, dumpFileSeq, phaseName) + IsPgoHot bool + DeferReturn *Block // avoid creating more than one deferreturn if there's multiple calls to deferproc-etc. + + // when register allocation is done, maps value ids to locations + RegAlloc []Location + + // temporary registers allocated to rare instructions + tempRegs map[ID]*Register + + // map from LocalSlot to set of Values that we want to store in that slot. + NamedValues map[LocalSlot][]*Value + // Names is a copy of NamedValues.Keys. We keep a separate list + // of keys to make iteration order deterministic. + Names []*LocalSlot + // Canonicalize root/top-level local slots, and canonicalize their pieces. + // Because LocalSlot pieces refer to their parents with a pointer, this ensures that equivalent slots really are equal. + CanonicalLocalSlots map[LocalSlot]*LocalSlot + CanonicalLocalSplits map[LocalSlotSplitKey]*LocalSlot + + // RegArgs is a slice of register-memory pairs that must be spilled and unspilled in the uncommon path of function entry. + RegArgs []Spill + // OwnAux describes parameters and results for this function. + OwnAux *AuxCall + // CloSlot holds the compiler-synthesized name (".closureptr") + // where we spill the closure pointer for range func bodies. + CloSlot *ir.Name + + freeValues *Value // free Values linked by argstorage[0]. All other fields except ID are 0/nil. + freeBlocks *Block // free Blocks linked by succstorage[0].b. All other fields except ID are 0/nil. + + cachedPostorder []*Block // cached postorder traversal + cachedIdom []*Block // cached immediate dominators + cachedSdom SparseTree // cached dominator tree + cachedLoopnest *loopnest // cached loop nest information + cachedLineStarts *xposmap // cached map/set of xpos to integers + + auxmap auxmap // map from aux values to opaque ids used by CSE + constants map[int64][]*Value // constants cache, keyed by constant value; users must check value's Op and Type +} + +type LocalSlotSplitKey struct { + parent *LocalSlot + Off int64 // offset of slot in N + Type *types.Type // type of slot +} + +// NewFunc returns a new, empty function object. +// Caller must reset cache before calling NewFunc. +func (c *Config) NewFunc(fe Frontend, cache *Cache) *Func { + return &Func{ + fe: fe, + Config: c, + Cache: cache, + + NamedValues: make(map[LocalSlot][]*Value), + CanonicalLocalSlots: make(map[LocalSlot]*LocalSlot), + CanonicalLocalSplits: make(map[LocalSlotSplitKey]*LocalSlot), + OwnAux: &AuxCall{}, + } +} + +// NumBlocks returns an integer larger than the id of any Block in the Func. +func (f *Func) NumBlocks() int { + return f.bid.num() +} + +// NumValues returns an integer larger than the id of any Value in the Func. +func (f *Func) NumValues() int { + return f.vid.num() +} + +// NameABI returns the function name followed by comma and the ABI number. +// This is intended for use with GOSSAFUNC and HTML dumps, and differs from +// the linker's "<1>" convention because "<" and ">" require shell quoting +// and are not legal file names (for use with GOSSADIR) on Windows. +func (f *Func) NameABI() string { + return FuncNameABI(f.Name, f.ABISelf.Which()) +} + +// FuncNameABI returns n followed by a comma and the value of a. +// This is a separate function to allow a single point encoding +// of the format, which is used in places where there's not a Func yet. +func FuncNameABI(n string, a obj.ABI) string { + return fmt.Sprintf("%s,%d", n, a) +} + +// newSparseSet returns a sparse set that can store at least up to n integers. +func (f *Func) newSparseSet(n int) *sparseSet { + return f.Cache.allocSparseSet(n) +} + +// retSparseSet returns a sparse set to the config's cache of sparse +// sets to be reused by f.newSparseSet. +func (f *Func) retSparseSet(ss *sparseSet) { + f.Cache.freeSparseSet(ss) +} + +// newSparseMap returns a sparse map that can store at least up to n integers. +func (f *Func) newSparseMap(n int) *sparseMap { + return f.Cache.allocSparseMap(n) +} + +// retSparseMap returns a sparse map to the config's cache of sparse +// sets to be reused by f.newSparseMap. +func (f *Func) retSparseMap(ss *sparseMap) { + f.Cache.freeSparseMap(ss) +} + +// newSparseMapPos returns a sparse map that can store at least up to n integers. +func (f *Func) newSparseMapPos(n int) *sparseMapPos { + return f.Cache.allocSparseMapPos(n) +} + +// retSparseMapPos returns a sparse map to the config's cache of sparse +// sets to be reused by f.newSparseMapPos. +func (f *Func) retSparseMapPos(ss *sparseMapPos) { + f.Cache.freeSparseMapPos(ss) +} + +// newPoset returns a new poset from the internal cache +func (f *Func) newPoset() *poset { + if len(f.Cache.scrPoset) > 0 { + po := f.Cache.scrPoset[len(f.Cache.scrPoset)-1] + f.Cache.scrPoset = f.Cache.scrPoset[:len(f.Cache.scrPoset)-1] + return po + } + return newPoset() +} + +// retPoset returns a poset to the internal cache +func (f *Func) retPoset(po *poset) { + f.Cache.scrPoset = append(f.Cache.scrPoset, po) +} + +func (f *Func) localSlotAddr(slot LocalSlot) *LocalSlot { + a, ok := f.CanonicalLocalSlots[slot] + if !ok { + a = new(LocalSlot) + *a = slot // don't escape slot + f.CanonicalLocalSlots[slot] = a + } + return a +} + +func (f *Func) SplitString(name *LocalSlot) (*LocalSlot, *LocalSlot) { + ptrType := types.NewPtr(types.Types[types.TUINT8]) + lenType := types.Types[types.TINT] + // Split this string up into two separate variables. + p := f.SplitSlot(name, ".ptr", 0, ptrType) + l := f.SplitSlot(name, ".len", ptrType.Size(), lenType) + return p, l +} + +func (f *Func) SplitInterface(name *LocalSlot) (*LocalSlot, *LocalSlot) { + n := name.N + u := types.Types[types.TUINTPTR] + t := types.NewPtr(types.Types[types.TUINT8]) + // Split this interface up into two separate variables. + sfx := ".itab" + if n.Type().IsEmptyInterface() { + sfx = ".type" + } + c := f.SplitSlot(name, sfx, 0, u) // see comment in typebits.Set + d := f.SplitSlot(name, ".data", u.Size(), t) + return c, d +} + +func (f *Func) SplitSlice(name *LocalSlot) (*LocalSlot, *LocalSlot, *LocalSlot) { + ptrType := types.NewPtr(name.Type.Elem()) + lenType := types.Types[types.TINT] + p := f.SplitSlot(name, ".ptr", 0, ptrType) + l := f.SplitSlot(name, ".len", ptrType.Size(), lenType) + c := f.SplitSlot(name, ".cap", ptrType.Size()+lenType.Size(), lenType) + return p, l, c +} + +func (f *Func) SplitComplex(name *LocalSlot) (*LocalSlot, *LocalSlot) { + s := name.Type.Size() / 2 + var t *types.Type + if s == 8 { + t = types.Types[types.TFLOAT64] + } else { + t = types.Types[types.TFLOAT32] + } + r := f.SplitSlot(name, ".real", 0, t) + i := f.SplitSlot(name, ".imag", t.Size(), t) + return r, i +} + +func (f *Func) SplitInt64(name *LocalSlot) (*LocalSlot, *LocalSlot) { + var t *types.Type + if name.Type.IsSigned() { + t = types.Types[types.TINT32] + } else { + t = types.Types[types.TUINT32] + } + if f.Config.BigEndian { + return f.SplitSlot(name, ".hi", 0, t), f.SplitSlot(name, ".lo", t.Size(), types.Types[types.TUINT32]) + } + return f.SplitSlot(name, ".hi", t.Size(), t), f.SplitSlot(name, ".lo", 0, types.Types[types.TUINT32]) +} + +func (f *Func) SplitStruct(name *LocalSlot, i int) *LocalSlot { + st := name.Type + return f.SplitSlot(name, st.FieldName(i), st.FieldOff(i), st.FieldType(i)) +} +func (f *Func) SplitArray(name *LocalSlot) *LocalSlot { + n := name.N + at := name.Type + if at.NumElem() != 1 { + base.FatalfAt(n.Pos(), "bad array size") + } + et := at.Elem() + return f.SplitSlot(name, "[0]", 0, et) +} + +func (f *Func) SplitSlot(name *LocalSlot, sfx string, offset int64, t *types.Type) *LocalSlot { + lssk := LocalSlotSplitKey{name, offset, t} + if als, ok := f.CanonicalLocalSplits[lssk]; ok { + return als + } + // Note: the _ field may appear several times. But + // have no fear, identically-named but distinct Autos are + // ok, albeit maybe confusing for a debugger. + ls := f.fe.SplitSlot(name, sfx, offset, t) + f.CanonicalLocalSplits[lssk] = &ls + return &ls +} + +// newValue allocates a new Value with the given fields and places it at the end of b.Values. +func (f *Func) newValue(op Op, t *types.Type, b *Block, pos src.XPos) *Value { + var v *Value + if f.freeValues != nil { + v = f.freeValues + f.freeValues = v.argstorage[0] + v.argstorage[0] = nil + } else { + ID := f.vid.get() + if int(ID) < len(f.Cache.values) { + v = &f.Cache.values[ID] + v.ID = ID + } else { + v = &Value{ID: ID} + } + } + v.Op = op + v.Type = t + v.Block = b + if notStmtBoundary(op) { + pos = pos.WithNotStmt() + } + v.Pos = pos + b.Values = append(b.Values, v) + return v +} + +// newValueNoBlock allocates a new Value with the given fields. +// The returned value is not placed in any block. Once the caller +// decides on a block b, it must set b.Block and append +// the returned value to b.Values. +func (f *Func) newValueNoBlock(op Op, t *types.Type, pos src.XPos) *Value { + var v *Value + if f.freeValues != nil { + v = f.freeValues + f.freeValues = v.argstorage[0] + v.argstorage[0] = nil + } else { + ID := f.vid.get() + if int(ID) < len(f.Cache.values) { + v = &f.Cache.values[ID] + v.ID = ID + } else { + v = &Value{ID: ID} + } + } + v.Op = op + v.Type = t + v.Block = nil // caller must fix this. + if notStmtBoundary(op) { + pos = pos.WithNotStmt() + } + v.Pos = pos + return v +} + +// LogStat writes a string key and int value as a warning in a +// tab-separated format easily handled by spreadsheets or awk. +// file names, lines, and function names are included to provide enough (?) +// context to allow item-by-item comparisons across runs. +// For example: +// awk 'BEGIN {FS="\t"} $3~/TIME/{sum+=$4} END{print "t(ns)=",sum}' t.log +func (f *Func) LogStat(key string, args ...any) { + value := "" + for _, a := range args { + value += fmt.Sprintf("\t%v", a) + } + n := "missing_pass" + if f.pass != nil { + n = strings.ReplaceAll(f.pass.name, " ", "_") + } + f.Warnl(f.Entry.Pos, "\t%s\t%s%s\t%s", n, key, value, f.Name) +} + +// unCacheLine removes v from f's constant cache "line" for aux, +// resets v.InCache when it is found (and removed), +// and returns whether v was found in that line. +func (f *Func) unCacheLine(v *Value, aux int64) bool { + vv := f.constants[aux] + for i, cv := range vv { + if v == cv { + vv[i] = vv[len(vv)-1] + vv[len(vv)-1] = nil + f.constants[aux] = vv[0 : len(vv)-1] + v.InCache = false + return true + } + } + return false +} + +// unCache removes v from f's constant cache. +func (f *Func) unCache(v *Value) { + if v.InCache { + aux := v.AuxInt + if f.unCacheLine(v, aux) { + return + } + if aux == 0 { + switch v.Op { + case OpConstNil: + aux = constNilMagic + case OpConstSlice: + aux = constSliceMagic + case OpConstString: + aux = constEmptyStringMagic + case OpConstInterface: + aux = constInterfaceMagic + } + if aux != 0 && f.unCacheLine(v, aux) { + return + } + } + f.Fatalf("unCached value %s not found in cache, auxInt=0x%x, adjusted aux=0x%x", v.LongString(), v.AuxInt, aux) + } +} + +// freeValue frees a value. It must no longer be referenced or have any args. +func (f *Func) freeValue(v *Value) { + if v.Block == nil { + f.Fatalf("trying to free an already freed value") + } + if v.Uses != 0 { + f.Fatalf("value %s still has %d uses", v, v.Uses) + } + if len(v.Args) != 0 { + f.Fatalf("value %s still has %d args", v, len(v.Args)) + } + // Clear everything but ID (which we reuse). + id := v.ID + if v.InCache { + f.unCache(v) + } + *v = Value{} + v.ID = id + v.argstorage[0] = f.freeValues + f.freeValues = v +} + +// NewBlock allocates a new Block of the given kind and places it at the end of f.Blocks. +func (f *Func) NewBlock(kind BlockKind) *Block { + var b *Block + if f.freeBlocks != nil { + b = f.freeBlocks + f.freeBlocks = b.succstorage[0].b + b.succstorage[0].b = nil + } else { + ID := f.bid.get() + if int(ID) < len(f.Cache.blocks) { + b = &f.Cache.blocks[ID] + b.ID = ID + } else { + b = &Block{ID: ID} + } + } + b.Kind = kind + b.Func = f + b.Preds = b.predstorage[:0] + b.Succs = b.succstorage[:0] + b.Values = b.valstorage[:0] + f.Blocks = append(f.Blocks, b) + f.invalidateCFG() + return b +} + +func (f *Func) freeBlock(b *Block) { + if b.Func == nil { + f.Fatalf("trying to free an already freed block") + } + // Clear everything but ID (which we reuse). + id := b.ID + *b = Block{} + b.ID = id + b.succstorage[0].b = f.freeBlocks + f.freeBlocks = b +} + +// NewValue0 returns a new value in the block with no arguments and zero aux values. +func (b *Block) NewValue0(pos src.XPos, op Op, t *types.Type) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = 0 + v.Args = v.argstorage[:0] + return v +} + +// NewValue0I returns a new value in the block with no arguments and an auxint value. +func (b *Block) NewValue0I(pos src.XPos, op Op, t *types.Type, auxint int64) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = auxint + v.Args = v.argstorage[:0] + return v +} + +// NewValue0A returns a new value in the block with no arguments and an aux value. +func (b *Block) NewValue0A(pos src.XPos, op Op, t *types.Type, aux Aux) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = 0 + v.Aux = aux + v.Args = v.argstorage[:0] + return v +} + +// NewValue0IA returns a new value in the block with no arguments and both an auxint and aux values. +func (b *Block) NewValue0IA(pos src.XPos, op Op, t *types.Type, auxint int64, aux Aux) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = auxint + v.Aux = aux + v.Args = v.argstorage[:0] + return v +} + +// NewValue1 returns a new value in the block with one argument and zero aux values. +func (b *Block) NewValue1(pos src.XPos, op Op, t *types.Type, arg *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = 0 + v.Args = v.argstorage[:1] + v.argstorage[0] = arg + arg.Uses++ + return v +} + +// NewValue1I returns a new value in the block with one argument and an auxint value. +func (b *Block) NewValue1I(pos src.XPos, op Op, t *types.Type, auxint int64, arg *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = auxint + v.Args = v.argstorage[:1] + v.argstorage[0] = arg + arg.Uses++ + return v +} + +// NewValue1A returns a new value in the block with one argument and an aux value. +func (b *Block) NewValue1A(pos src.XPos, op Op, t *types.Type, aux Aux, arg *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = 0 + v.Aux = aux + v.Args = v.argstorage[:1] + v.argstorage[0] = arg + arg.Uses++ + return v +} + +// NewValue1IA returns a new value in the block with one argument and both an auxint and aux values. +func (b *Block) NewValue1IA(pos src.XPos, op Op, t *types.Type, auxint int64, aux Aux, arg *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = auxint + v.Aux = aux + v.Args = v.argstorage[:1] + v.argstorage[0] = arg + arg.Uses++ + return v +} + +// NewValue2 returns a new value in the block with two arguments and zero aux values. +func (b *Block) NewValue2(pos src.XPos, op Op, t *types.Type, arg0, arg1 *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = 0 + v.Args = v.argstorage[:2] + v.argstorage[0] = arg0 + v.argstorage[1] = arg1 + arg0.Uses++ + arg1.Uses++ + return v +} + +// NewValue2A returns a new value in the block with two arguments and one aux values. +func (b *Block) NewValue2A(pos src.XPos, op Op, t *types.Type, aux Aux, arg0, arg1 *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = 0 + v.Aux = aux + v.Args = v.argstorage[:2] + v.argstorage[0] = arg0 + v.argstorage[1] = arg1 + arg0.Uses++ + arg1.Uses++ + return v +} + +// NewValue2I returns a new value in the block with two arguments and an auxint value. +func (b *Block) NewValue2I(pos src.XPos, op Op, t *types.Type, auxint int64, arg0, arg1 *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = auxint + v.Args = v.argstorage[:2] + v.argstorage[0] = arg0 + v.argstorage[1] = arg1 + arg0.Uses++ + arg1.Uses++ + return v +} + +// NewValue2IA returns a new value in the block with two arguments and both an auxint and aux values. +func (b *Block) NewValue2IA(pos src.XPos, op Op, t *types.Type, auxint int64, aux Aux, arg0, arg1 *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = auxint + v.Aux = aux + v.Args = v.argstorage[:2] + v.argstorage[0] = arg0 + v.argstorage[1] = arg1 + arg0.Uses++ + arg1.Uses++ + return v +} + +// NewValue3 returns a new value in the block with three arguments and zero aux values. +func (b *Block) NewValue3(pos src.XPos, op Op, t *types.Type, arg0, arg1, arg2 *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = 0 + v.Args = v.argstorage[:3] + v.argstorage[0] = arg0 + v.argstorage[1] = arg1 + v.argstorage[2] = arg2 + arg0.Uses++ + arg1.Uses++ + arg2.Uses++ + return v +} + +// NewValue3I returns a new value in the block with three arguments and an auxint value. +func (b *Block) NewValue3I(pos src.XPos, op Op, t *types.Type, auxint int64, arg0, arg1, arg2 *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = auxint + v.Args = v.argstorage[:3] + v.argstorage[0] = arg0 + v.argstorage[1] = arg1 + v.argstorage[2] = arg2 + arg0.Uses++ + arg1.Uses++ + arg2.Uses++ + return v +} + +// NewValue3A returns a new value in the block with three argument and an aux value. +func (b *Block) NewValue3A(pos src.XPos, op Op, t *types.Type, aux Aux, arg0, arg1, arg2 *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = 0 + v.Aux = aux + v.Args = v.argstorage[:3] + v.argstorage[0] = arg0 + v.argstorage[1] = arg1 + v.argstorage[2] = arg2 + arg0.Uses++ + arg1.Uses++ + arg2.Uses++ + return v +} + +// NewValue4 returns a new value in the block with four arguments and zero aux values. +func (b *Block) NewValue4(pos src.XPos, op Op, t *types.Type, arg0, arg1, arg2, arg3 *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = 0 + v.Args = []*Value{arg0, arg1, arg2, arg3} + arg0.Uses++ + arg1.Uses++ + arg2.Uses++ + arg3.Uses++ + return v +} + +// NewValue4A returns a new value in the block with four arguments and zero aux values. +func (b *Block) NewValue4A(pos src.XPos, op Op, t *types.Type, aux Aux, arg0, arg1, arg2, arg3 *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = 0 + v.Aux = aux + v.Args = []*Value{arg0, arg1, arg2, arg3} + arg0.Uses++ + arg1.Uses++ + arg2.Uses++ + arg3.Uses++ + return v +} + +// NewValue4I returns a new value in the block with four arguments and auxint value. +func (b *Block) NewValue4I(pos src.XPos, op Op, t *types.Type, auxint int64, arg0, arg1, arg2, arg3 *Value) *Value { + v := b.Func.newValue(op, t, b, pos) + v.AuxInt = auxint + v.Args = []*Value{arg0, arg1, arg2, arg3} + arg0.Uses++ + arg1.Uses++ + arg2.Uses++ + arg3.Uses++ + return v +} + +// constVal returns a constant value for c. +func (f *Func) constVal(op Op, t *types.Type, c int64, setAuxInt bool) *Value { + if f.constants == nil { + f.constants = make(map[int64][]*Value) + } + vv := f.constants[c] + for _, v := range vv { + if v.Op == op && v.Type.Compare(t) == types.CMPeq { + if setAuxInt && v.AuxInt != c { + panic(fmt.Sprintf("cached const %s should have AuxInt of %d", v.LongString(), c)) + } + return v + } + } + var v *Value + if setAuxInt { + v = f.Entry.NewValue0I(src.NoXPos, op, t, c) + } else { + v = f.Entry.NewValue0(src.NoXPos, op, t) + } + f.constants[c] = append(vv, v) + v.InCache = true + return v +} + +// These magic auxint values let us easily cache non-numeric constants +// using the same constants map while making collisions unlikely. +// These values are unlikely to occur in regular code and +// are easy to grep for in case of bugs. +const ( + constSliceMagic = 1122334455 + constInterfaceMagic = 2233445566 + constNilMagic = 3344556677 + constEmptyStringMagic = 4455667788 +) + +// ConstBool returns an int constant representing its argument. +func (f *Func) ConstBool(t *types.Type, c bool) *Value { + i := int64(0) + if c { + i = 1 + } + return f.constVal(OpConstBool, t, i, true) +} +func (f *Func) ConstInt8(t *types.Type, c int8) *Value { + return f.constVal(OpConst8, t, int64(c), true) +} +func (f *Func) ConstInt16(t *types.Type, c int16) *Value { + return f.constVal(OpConst16, t, int64(c), true) +} +func (f *Func) ConstInt32(t *types.Type, c int32) *Value { + return f.constVal(OpConst32, t, int64(c), true) +} +func (f *Func) ConstInt64(t *types.Type, c int64) *Value { + return f.constVal(OpConst64, t, c, true) +} +func (f *Func) ConstFloat32(t *types.Type, c float64) *Value { + return f.constVal(OpConst32F, t, int64(math.Float64bits(float64(float32(c)))), true) +} +func (f *Func) ConstFloat64(t *types.Type, c float64) *Value { + return f.constVal(OpConst64F, t, int64(math.Float64bits(c)), true) +} + +func (f *Func) ConstSlice(t *types.Type) *Value { + return f.constVal(OpConstSlice, t, constSliceMagic, false) +} +func (f *Func) ConstInterface(t *types.Type) *Value { + return f.constVal(OpConstInterface, t, constInterfaceMagic, false) +} +func (f *Func) ConstNil(t *types.Type) *Value { + return f.constVal(OpConstNil, t, constNilMagic, false) +} +func (f *Func) ConstEmptyString(t *types.Type) *Value { + v := f.constVal(OpConstString, t, constEmptyStringMagic, false) + v.Aux = StringToAux("") + return v +} +func (f *Func) ConstOffPtrSP(t *types.Type, c int64, sp *Value) *Value { + v := f.constVal(OpOffPtr, t, c, true) + if len(v.Args) == 0 { + v.AddArg(sp) + } + return v +} + +func (f *Func) Frontend() Frontend { return f.fe } +func (f *Func) Warnl(pos src.XPos, msg string, args ...any) { f.fe.Warnl(pos, msg, args...) } +func (f *Func) Logf(msg string, args ...any) { f.fe.Logf(msg, args...) } +func (f *Func) Log() bool { return f.fe.Log() } + +func (f *Func) Fatalf(msg string, args ...any) { + stats := "crashed" + if f.Log() { + f.Logf(" pass %s end %s\n", f.pass.name, stats) + printFunc(f) + } + if f.HTMLWriter != nil { + f.HTMLWriter.WritePhase(f.pass.name, fmt.Sprintf("%s %s", f.pass.name, stats)) + f.HTMLWriter.flushPhases() + } + f.fe.Fatalf(f.Entry.Pos, msg, args...) +} + +// postorder returns the reachable blocks in f in a postorder traversal. +func (f *Func) postorder() []*Block { + if f.cachedPostorder == nil { + f.cachedPostorder = postorder(f) + } + return f.cachedPostorder +} + +func (f *Func) Postorder() []*Block { + return f.postorder() +} + +// Idom returns a map from block ID to the immediate dominator of that block. +// f.Entry.ID maps to nil. Unreachable blocks map to nil as well. +func (f *Func) Idom() []*Block { + if f.cachedIdom == nil { + f.cachedIdom = dominators(f) + } + return f.cachedIdom +} + +// Sdom returns a sparse tree representing the dominator relationships +// among the blocks of f. +func (f *Func) Sdom() SparseTree { + if f.cachedSdom == nil { + f.cachedSdom = newSparseTree(f, f.Idom()) + } + return f.cachedSdom +} + +// loopnest returns the loop nest information for f. +func (f *Func) loopnest() *loopnest { + if f.cachedLoopnest == nil { + f.cachedLoopnest = loopnestfor(f) + } + return f.cachedLoopnest +} + +// invalidateCFG tells f that its CFG has changed. +func (f *Func) invalidateCFG() { + f.cachedPostorder = nil + f.cachedIdom = nil + f.cachedSdom = nil + f.cachedLoopnest = nil +} + +// DebugHashMatch returns +// +// base.DebugHashMatch(this function's package.name) +// +// for use in bug isolation. The return value is true unless +// environment variable GOCOMPILEDEBUG=gossahash=X is set, in which case "it depends on X". +// See [base.DebugHashMatch] for more information. +func (f *Func) DebugHashMatch() bool { + if !base.HasDebugHash() { + return true + } + sym := f.fe.Func().Sym() + return base.DebugHashMatchPkgFunc(sym.Pkg.Path, sym.Name) +} + +func (f *Func) spSb() (sp, sb *Value) { + initpos := src.NoXPos // These are originally created with no position in ssa.go; if they are optimized out then recreated, should be the same. + for _, v := range f.Entry.Values { + if v.Op == OpSB { + sb = v + } + if v.Op == OpSP { + sp = v + } + if sb != nil && sp != nil { + return + } + } + if sb == nil { + sb = f.Entry.NewValue0(initpos.WithNotStmt(), OpSB, f.Config.Types.Uintptr) + } + if sp == nil { + sp = f.Entry.NewValue0(initpos.WithNotStmt(), OpSP, f.Config.Types.Uintptr) + } + return +} + +// useFMA allows targeted debugging w/ GOFMAHASH +// If you have an architecture-dependent FP glitch, this will help you find it. +func (f *Func) useFMA(v *Value) bool { + if base.FmaHash == nil { + return true + } + return base.FmaHash.MatchPos(v.Pos, nil) +} + +// NewLocal returns a new anonymous local variable of the given type. +func (f *Func) NewLocal(pos src.XPos, typ *types.Type) *ir.Name { + nn := typecheck.TempAt(pos, f.fe.Func(), typ) // Note: adds new auto to fn.Dcl list + nn.SetNonMergeable(true) + return nn +} + +// IsMergeCandidate returns true if variable n could participate in +// stack slot merging. For now we're restricting the set to things to +// items larger than what CanSSA would allow (approximateky, we disallow things +// marked as open defer slots so as to avoid complicating liveness +// analysis. +func IsMergeCandidate(n *ir.Name) bool { + if base.Debug.MergeLocals == 0 || + base.Flag.N != 0 || + n.Class != ir.PAUTO || + n.Type().Size() <= int64(3*types.PtrSize) || + n.Addrtaken() || + n.NonMergeable() || + n.OpenDeferSlot() { + return false + } + return true +} diff --git a/go/src/cmd/compile/internal/ssa/func_test.go b/go/src/cmd/compile/internal/ssa/func_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1a378d4a95fb000c017a06424d847be8a4f02863 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/func_test.go @@ -0,0 +1,487 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains some utility functions to help define Funcs for testing. +// As an example, the following func +// +// b1: +// v1 = InitMem +// Plain -> b2 +// b2: +// Exit v1 +// b3: +// v2 = Const [true] +// If v2 -> b3 b2 +// +// can be defined as +// +// fun := Fun("entry", +// Bloc("entry", +// Valu("mem", OpInitMem, types.TypeMem, 0, nil), +// Goto("exit")), +// Bloc("exit", +// Exit("mem")), +// Bloc("deadblock", +// Valu("deadval", OpConstBool, c.config.Types.Bool, 0, true), +// If("deadval", "deadblock", "exit"))) +// +// and the Blocks or Values used in the Func can be accessed +// like this: +// fun.blocks["entry"] or fun.values["deadval"] + +package ssa + +// TODO(matloob): Choose better names for Fun, Bloc, Goto, etc. +// TODO(matloob): Write a parser for the Func disassembly. Maybe +// the parser can be used instead of Fun. + +import ( + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" + "fmt" + "reflect" + "testing" +) + +// Compare two Funcs for equivalence. Their CFGs must be isomorphic, +// and their values must correspond. +// Requires that values and predecessors are in the same order, even +// though Funcs could be equivalent when they are not. +// TODO(matloob): Allow values and predecessors to be in different +// orders if the CFG are otherwise equivalent. +func Equiv(f, g *Func) bool { + valcor := make(map[*Value]*Value) + var checkVal func(fv, gv *Value) bool + checkVal = func(fv, gv *Value) bool { + if fv == nil && gv == nil { + return true + } + if valcor[fv] == nil && valcor[gv] == nil { + valcor[fv] = gv + valcor[gv] = fv + // Ignore ids. Ops and Types are compared for equality. + // TODO(matloob): Make sure types are canonical and can + // be compared for equality. + if fv.Op != gv.Op || fv.Type != gv.Type || fv.AuxInt != gv.AuxInt { + return false + } + if !reflect.DeepEqual(fv.Aux, gv.Aux) { + // This makes the assumption that aux values can be compared + // using DeepEqual. + // TODO(matloob): Aux values may be *gc.Sym pointers in the near + // future. Make sure they are canonical. + return false + } + if len(fv.Args) != len(gv.Args) { + return false + } + for i := range fv.Args { + if !checkVal(fv.Args[i], gv.Args[i]) { + return false + } + } + } + return valcor[fv] == gv && valcor[gv] == fv + } + blkcor := make(map[*Block]*Block) + var checkBlk func(fb, gb *Block) bool + checkBlk = func(fb, gb *Block) bool { + if blkcor[fb] == nil && blkcor[gb] == nil { + blkcor[fb] = gb + blkcor[gb] = fb + // ignore ids + if fb.Kind != gb.Kind { + return false + } + if len(fb.Values) != len(gb.Values) { + return false + } + for i := range fb.Values { + if !checkVal(fb.Values[i], gb.Values[i]) { + return false + } + } + if len(fb.Succs) != len(gb.Succs) { + return false + } + for i := range fb.Succs { + if !checkBlk(fb.Succs[i].b, gb.Succs[i].b) { + return false + } + } + if len(fb.Preds) != len(gb.Preds) { + return false + } + for i := range fb.Preds { + if !checkBlk(fb.Preds[i].b, gb.Preds[i].b) { + return false + } + } + return true + + } + return blkcor[fb] == gb && blkcor[gb] == fb + } + + return checkBlk(f.Entry, g.Entry) +} + +// fun is the return type of Fun. It contains the created func +// itself as well as indexes from block and value names into the +// corresponding Blocks and Values. +type fun struct { + f *Func + blocks map[string]*Block + values map[string]*Value +} + +var emptyPass pass = pass{ + name: "empty pass", +} + +// AuxCallLSym returns an AuxCall initialized with an LSym that should pass "check" +// as the Aux of a static call. +func AuxCallLSym(name string) *AuxCall { + return &AuxCall{Fn: &obj.LSym{}} +} + +// Fun takes the name of an entry bloc and a series of Bloc calls, and +// returns a fun containing the composed Func. entry must be a name +// supplied to one of the Bloc functions. Each of the bloc names and +// valu names should be unique across the Fun. +func (c *Conf) Fun(entry string, blocs ...bloc) fun { + // TODO: Either mark some SSA tests as t.Parallel, + // or set up a shared Cache and Reset it between tests. + // But not both. + f := c.config.NewFunc(c.Frontend(), new(Cache)) + f.pass = &emptyPass + f.cachedLineStarts = newXposmap(map[int]lineRange{0: {0, 100}, 1: {0, 100}, 2: {0, 100}, 3: {0, 100}, 4: {0, 100}}) + + blocks := make(map[string]*Block) + values := make(map[string]*Value) + // Create all the blocks and values. + for _, bloc := range blocs { + b := f.NewBlock(bloc.control.kind) + blocks[bloc.name] = b + for _, valu := range bloc.valus { + // args are filled in the second pass. + values[valu.name] = b.NewValue0IA(src.NoXPos, valu.op, valu.t, valu.auxint, valu.aux) + } + } + // Connect the blocks together and specify control values. + f.Entry = blocks[entry] + for _, bloc := range blocs { + b := blocks[bloc.name] + c := bloc.control + // Specify control values. + if c.control != "" { + cval, ok := values[c.control] + if !ok { + f.Fatalf("control value for block %s missing", bloc.name) + } + b.SetControl(cval) + } + // Fill in args. + for _, valu := range bloc.valus { + v := values[valu.name] + for _, arg := range valu.args { + a, ok := values[arg] + if !ok { + b.Fatalf("arg %s missing for value %s in block %s", + arg, valu.name, bloc.name) + } + v.AddArg(a) + } + } + // Connect to successors. + for _, succ := range c.succs { + b.AddEdgeTo(blocks[succ]) + } + } + return fun{f, blocks, values} +} + +// Bloc defines a block for Fun. The bloc name should be unique +// across the containing Fun. entries should consist of calls to valu, +// as well as one call to Goto, If, or Exit to specify the block kind. +func Bloc(name string, entries ...any) bloc { + b := bloc{} + b.name = name + seenCtrl := false + for _, e := range entries { + switch v := e.(type) { + case ctrl: + // there should be exactly one Ctrl entry. + if seenCtrl { + panic(fmt.Sprintf("already seen control for block %s", name)) + } + b.control = v + seenCtrl = true + case valu: + b.valus = append(b.valus, v) + } + } + if !seenCtrl { + panic(fmt.Sprintf("block %s doesn't have control", b.name)) + } + return b +} + +// Valu defines a value in a block. +func Valu(name string, op Op, t *types.Type, auxint int64, aux Aux, args ...string) valu { + return valu{name, op, t, auxint, aux, args} +} + +// Goto specifies that this is a BlockPlain and names the single successor. +// TODO(matloob): choose a better name. +func Goto(succ string) ctrl { + return ctrl{BlockPlain, "", []string{succ}} +} + +// If specifies a BlockIf. +func If(cond, sub, alt string) ctrl { + return ctrl{BlockIf, cond, []string{sub, alt}} +} + +// Exit specifies a BlockExit. +func Exit(arg string) ctrl { + return ctrl{BlockExit, arg, []string{}} +} + +// Ret specifies a BlockRet. +func Ret(arg string) ctrl { + return ctrl{BlockRet, arg, []string{}} +} + +// Eq specifies a BlockAMD64EQ. +func Eq(cond, sub, alt string) ctrl { + return ctrl{BlockAMD64EQ, cond, []string{sub, alt}} +} + +// bloc, ctrl, and valu are internal structures used by Bloc, Valu, Goto, +// If, and Exit to help define blocks. + +type bloc struct { + name string + control ctrl + valus []valu +} + +type ctrl struct { + kind BlockKind + control string + succs []string +} + +type valu struct { + name string + op Op + t *types.Type + auxint int64 + aux Aux + args []string +} + +func TestArgs(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("a", OpConst64, c.config.Types.Int64, 14, nil), + Valu("b", OpConst64, c.config.Types.Int64, 26, nil), + Valu("sum", OpAdd64, c.config.Types.Int64, 0, nil, "a", "b"), + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Goto("exit")), + Bloc("exit", + Exit("mem"))) + sum := fun.values["sum"] + for i, name := range []string{"a", "b"} { + if sum.Args[i] != fun.values[name] { + t.Errorf("arg %d for sum is incorrect: want %s, got %s", + i, sum.Args[i], fun.values[name]) + } + } +} + +func TestEquiv(t *testing.T) { + cfg := testConfig(t) + equivalentCases := []struct{ f, g fun }{ + // simple case + { + cfg.Fun("entry", + Bloc("entry", + Valu("a", OpConst64, cfg.config.Types.Int64, 14, nil), + Valu("b", OpConst64, cfg.config.Types.Int64, 26, nil), + Valu("sum", OpAdd64, cfg.config.Types.Int64, 0, nil, "a", "b"), + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Goto("exit")), + Bloc("exit", + Exit("mem"))), + cfg.Fun("entry", + Bloc("entry", + Valu("a", OpConst64, cfg.config.Types.Int64, 14, nil), + Valu("b", OpConst64, cfg.config.Types.Int64, 26, nil), + Valu("sum", OpAdd64, cfg.config.Types.Int64, 0, nil, "a", "b"), + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Goto("exit")), + Bloc("exit", + Exit("mem"))), + }, + // block order changed + { + cfg.Fun("entry", + Bloc("entry", + Valu("a", OpConst64, cfg.config.Types.Int64, 14, nil), + Valu("b", OpConst64, cfg.config.Types.Int64, 26, nil), + Valu("sum", OpAdd64, cfg.config.Types.Int64, 0, nil, "a", "b"), + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Goto("exit")), + Bloc("exit", + Exit("mem"))), + cfg.Fun("entry", + Bloc("exit", + Exit("mem")), + Bloc("entry", + Valu("a", OpConst64, cfg.config.Types.Int64, 14, nil), + Valu("b", OpConst64, cfg.config.Types.Int64, 26, nil), + Valu("sum", OpAdd64, cfg.config.Types.Int64, 0, nil, "a", "b"), + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Goto("exit"))), + }, + } + for _, c := range equivalentCases { + if !Equiv(c.f.f, c.g.f) { + t.Error("expected equivalence. Func definitions:") + t.Error(c.f.f) + t.Error(c.g.f) + } + } + + differentCases := []struct{ f, g fun }{ + // different shape + { + cfg.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Goto("exit")), + Bloc("exit", + Exit("mem"))), + cfg.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Exit("mem"))), + }, + // value order changed + { + cfg.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("b", OpConst64, cfg.config.Types.Int64, 26, nil), + Valu("a", OpConst64, cfg.config.Types.Int64, 14, nil), + Exit("mem"))), + cfg.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("a", OpConst64, cfg.config.Types.Int64, 14, nil), + Valu("b", OpConst64, cfg.config.Types.Int64, 26, nil), + Exit("mem"))), + }, + // value auxint different + { + cfg.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("a", OpConst64, cfg.config.Types.Int64, 14, nil), + Exit("mem"))), + cfg.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("a", OpConst64, cfg.config.Types.Int64, 26, nil), + Exit("mem"))), + }, + // value aux different + { + cfg.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("a", OpConstString, cfg.config.Types.String, 0, StringToAux("foo")), + Exit("mem"))), + cfg.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("a", OpConstString, cfg.config.Types.String, 0, StringToAux("bar")), + Exit("mem"))), + }, + // value args different + { + cfg.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("a", OpConst64, cfg.config.Types.Int64, 14, nil), + Valu("b", OpConst64, cfg.config.Types.Int64, 26, nil), + Valu("sum", OpAdd64, cfg.config.Types.Int64, 0, nil, "a", "b"), + Exit("mem"))), + cfg.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("a", OpConst64, cfg.config.Types.Int64, 0, nil), + Valu("b", OpConst64, cfg.config.Types.Int64, 14, nil), + Valu("sum", OpAdd64, cfg.config.Types.Int64, 0, nil, "b", "a"), + Exit("mem"))), + }, + } + for _, c := range differentCases { + if Equiv(c.f.f, c.g.f) { + t.Error("expected difference. Func definitions:") + t.Error(c.f.f) + t.Error(c.g.f) + } + } +} + +// TestConstCache ensures that the cache will not return +// reused free'd values with a non-matching AuxInt +func TestConstCache(t *testing.T) { + c := testConfig(t) + f := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Exit("mem"))) + v1 := f.f.ConstBool(c.config.Types.Bool, false) + v2 := f.f.ConstBool(c.config.Types.Bool, true) + f.f.freeValue(v1) + f.f.freeValue(v2) + v3 := f.f.ConstBool(c.config.Types.Bool, false) + v4 := f.f.ConstBool(c.config.Types.Bool, true) + if v3.AuxInt != 0 { + t.Errorf("expected %s to have auxint of 0\n", v3.LongString()) + } + if v4.AuxInt != 1 { + t.Errorf("expected %s to have auxint of 1\n", v4.LongString()) + } + +} + +// opcodeMap returns a map from opcode to the number of times that opcode +// appears in the function. +func opcodeMap(f *Func) map[Op]int { + m := map[Op]int{} + for _, b := range f.Blocks { + for _, v := range b.Values { + m[v.Op]++ + } + } + return m +} + +// checkOpcodeCounts checks that the number of opcodes listed in m agree with the +// number of opcodes that appear in the function. +func checkOpcodeCounts(t *testing.T, f *Func, m map[Op]int) { + n := opcodeMap(f) + for op, cnt := range m { + if n[op] != cnt { + t.Errorf("%s appears %d times, want %d times", op, n[op], cnt) + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/fuse.go b/go/src/cmd/compile/internal/ssa/fuse.go new file mode 100644 index 0000000000000000000000000000000000000000..e95064c1df2eebee8cb2ff76f1d911f984637e1b --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/fuse.go @@ -0,0 +1,343 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/internal/src" + "fmt" +) + +// fuseEarly runs fuse(f, fuseTypePlain|fuseTypeIntInRange|fuseTypeNanCheck). +func fuseEarly(f *Func) { + fuse(f, fuseTypePlain|fuseTypeIntInRange|fuseTypeSingleBitDifference|fuseTypeNanCheck) +} + +// fuseLate runs fuse(f, fuseTypePlain|fuseTypeIf|fuseTypeBranchRedirect). +func fuseLate(f *Func) { fuse(f, fuseTypePlain|fuseTypeIf|fuseTypeBranchRedirect) } + +type fuseType uint8 + +const ( + fuseTypePlain fuseType = 1 << iota + fuseTypeIf + fuseTypeIntInRange + fuseTypeSingleBitDifference + fuseTypeNanCheck + fuseTypeBranchRedirect + fuseTypeShortCircuit +) + +// fuse simplifies control flow by joining basic blocks. +func fuse(f *Func, typ fuseType) { + for changed := true; changed; { + changed = false + // Be sure to avoid quadratic behavior in fuseBlockPlain. See issue 13554. + // Previously this was dealt with using backwards iteration, now fuseBlockPlain + // handles large runs of blocks. + for i := len(f.Blocks) - 1; i >= 0; i-- { + b := f.Blocks[i] + if typ&fuseTypeIf != 0 { + changed = fuseBlockIf(b) || changed + } + if typ&fuseTypeIntInRange != 0 { + changed = fuseIntInRange(b) || changed + } + if typ&fuseTypeSingleBitDifference != 0 { + changed = fuseSingleBitDifference(b) || changed + } + if typ&fuseTypeNanCheck != 0 { + changed = fuseNanCheck(b) || changed + } + if typ&fuseTypePlain != 0 { + changed = fuseBlockPlain(b) || changed + } + if typ&fuseTypeShortCircuit != 0 { + changed = shortcircuitBlock(b) || changed + } + } + + if typ&fuseTypeBranchRedirect != 0 { + changed = fuseBranchRedirect(f) || changed + } + if changed { + f.invalidateCFG() + } + } +} + +// fuseBlockIf handles the following cases where s0 and s1 are empty blocks. +// +// b b b b +// \ / \ / | \ / \ / | | | +// s0 s1 | s1 s0 | | | +// \ / | / \ | | | +// ss ss ss ss +// +// If all Phi ops in ss have identical variables for slots corresponding to +// s0, s1 and b then the branch can be dropped. +// This optimization often comes up in switch statements with multiple +// expressions in a case clause: +// +// switch n { +// case 1,2,3: return 4 +// } +// +// TODO: If ss doesn't contain any OpPhis, are s0 and s1 dead code anyway. +func fuseBlockIf(b *Block) bool { + if b.Kind != BlockIf { + return false + } + // It doesn't matter how much Preds does s0 or s1 have. + var ss0, ss1 *Block + s0 := b.Succs[0].b + i0 := b.Succs[0].i + if s0.Kind != BlockPlain || !isEmpty(s0) { + s0, ss0 = b, s0 + } else { + ss0 = s0.Succs[0].b + i0 = s0.Succs[0].i + } + s1 := b.Succs[1].b + i1 := b.Succs[1].i + if s1.Kind != BlockPlain || !isEmpty(s1) { + s1, ss1 = b, s1 + } else { + ss1 = s1.Succs[0].b + i1 = s1.Succs[0].i + } + if ss0 != ss1 { + if s0.Kind == BlockPlain && isEmpty(s0) && s1.Kind == BlockPlain && isEmpty(s1) { + // Two special cases where both s0, s1 and ss are empty blocks. + if s0 == ss1 { + s0, ss0 = b, ss1 + } else if ss0 == s1 { + s1, ss1 = b, ss0 + } else { + return false + } + } else { + return false + } + } + ss := ss0 + + // s0 and s1 are equal with b if the corresponding block is missing + // (2nd, 3rd and 4th case in the figure). + + for _, v := range ss.Values { + if v.Op == OpPhi && v.Uses > 0 && v.Args[i0] != v.Args[i1] { + return false + } + } + + // We do not need to redirect the Preds of s0 and s1 to ss, + // the following optimization will do this. + b.removeEdge(0) + if s0 != b && len(s0.Preds) == 0 { + s0.removeEdge(0) + // Move any (dead) values in s0 to b, + // where they will be eliminated by the next deadcode pass. + for _, v := range s0.Values { + v.Block = b + } + b.Values = append(b.Values, s0.Values...) + // Clear s0. + s0.Kind = BlockInvalid + s0.Values = nil + s0.Succs = nil + s0.Preds = nil + } + + b.Kind = BlockPlain + b.Likely = BranchUnknown + b.ResetControls() + // The values in b may be dead codes, and clearing them in time may + // obtain new optimization opportunities. + // First put dead values that can be deleted into a slice walkValues. + // Then put their arguments in walkValues before resetting the dead values + // in walkValues, because the arguments may also become dead values. + walkValues := []*Value{} + for _, v := range b.Values { + if v.Uses == 0 && v.removeable() { + walkValues = append(walkValues, v) + } + } + for len(walkValues) != 0 { + v := walkValues[len(walkValues)-1] + walkValues = walkValues[:len(walkValues)-1] + if v.Uses == 0 && v.removeable() { + walkValues = append(walkValues, v.Args...) + v.reset(OpInvalid) + } + } + return true +} + +// isEmpty reports whether b contains any live values. +// There may be false positives. +func isEmpty(b *Block) bool { + for _, v := range b.Values { + if v.Uses > 0 || v.Op.IsCall() || v.Op.HasSideEffects() || v.Type.IsVoid() || opcodeTable[v.Op].nilCheck { + return false + } + } + return true +} + +// fuseBlockPlain handles a run of blocks with length >= 2, +// whose interior has single predecessors and successors, +// b must be BlockPlain, allowing it to be any node except the +// last (multiple successors means not BlockPlain). +// Cycles are handled and merged into b's successor. +func fuseBlockPlain(b *Block) bool { + if b.Kind != BlockPlain { + return false + } + + c := b.Succs[0].b + if len(c.Preds) != 1 || c == b { // At least 2 distinct blocks. + return false + } + + // find earliest block in run. Avoid simple cycles. + for len(b.Preds) == 1 && b.Preds[0].b != c && b.Preds[0].b.Kind == BlockPlain { + b = b.Preds[0].b + } + + // find latest block in run. Still beware of simple cycles. + for { + if c.Kind != BlockPlain { + break + } // Has exactly 1 successor + cNext := c.Succs[0].b + if cNext == b { + break + } // not a cycle + if len(cNext.Preds) != 1 { + break + } // no other incoming edge + c = cNext + } + + // Try to preserve any statement marks on the ends of blocks; move values to C + var b_next *Block + for bx := b; bx != c; bx = b_next { + // For each bx with an end-of-block statement marker, + // try to move it to a value in the next block, + // or to the next block's end, if possible. + b_next = bx.Succs[0].b + if bx.Pos.IsStmt() == src.PosIsStmt { + l := bx.Pos.Line() // looking for another place to mark for line l + outOfOrder := false + for _, v := range b_next.Values { + if v.Pos.IsStmt() == src.PosNotStmt { + continue + } + if l == v.Pos.Line() { // Found a Value with same line, therefore done. + v.Pos = v.Pos.WithIsStmt() + l = 0 + break + } + if l < v.Pos.Line() { + // The order of values in a block is not specified so OOO in a block is not interesting, + // but they do all come before the end of the block, so this disqualifies attaching to end of b_next. + outOfOrder = true + } + } + if l != 0 && !outOfOrder && (b_next.Pos.Line() == l || b_next.Pos.IsStmt() != src.PosIsStmt) { + b_next.Pos = bx.Pos.WithIsStmt() + } + } + // move all of bx's values to c (note containing loop excludes c) + for _, v := range bx.Values { + v.Block = c + } + } + + // Compute the total number of values and find the largest value slice in the run, to maximize chance of storage reuse. + total := 0 + totalBeforeMax := 0 // number of elements preceding the maximum block (i.e. its position in the result). + max_b := b // block with maximum capacity + + for bx := b; ; bx = bx.Succs[0].b { + if cap(bx.Values) > cap(max_b.Values) { + totalBeforeMax = total + max_b = bx + } + total += len(bx.Values) + if bx == c { + break + } + } + + // Use c's storage if fused blocks will fit, else use the max if that will fit, else allocate new storage. + + // Take care to avoid c.Values pointing to b.valstorage. + // See golang.org/issue/18602. + + // It's important to keep the elements in the same order; maintenance of + // debugging information depends on the order of *Values in Blocks. + // This can also cause changes in the order (which may affect other + // optimizations and possibly compiler output) for 32-vs-64 bit compilation + // platforms (word size affects allocation bucket size affects slice capacity). + + // figure out what slice will hold the values, + // preposition the destination elements if not allocating new storage + var t []*Value + if total <= len(c.valstorage) { + t = c.valstorage[:total] + max_b = c + totalBeforeMax = total - len(c.Values) + copy(t[totalBeforeMax:], c.Values) + } else if total <= cap(max_b.Values) { // in place, somewhere + t = max_b.Values[0:total] + copy(t[totalBeforeMax:], max_b.Values) + } else { + t = make([]*Value, total) + max_b = nil + } + + // copy the values + copyTo := 0 + for bx := b; ; bx = bx.Succs[0].b { + if bx != max_b { + copy(t[copyTo:], bx.Values) + } else if copyTo != totalBeforeMax { // trust but verify. + panic(fmt.Errorf("totalBeforeMax (%d) != copyTo (%d), max_b=%v, b=%v, c=%v", totalBeforeMax, copyTo, max_b, b, c)) + } + if bx == c { + break + } + copyTo += len(bx.Values) + } + c.Values = t + + // replace b->c edge with preds(b) -> c + c.predstorage[0] = Edge{} + if len(b.Preds) > len(b.predstorage) { + c.Preds = b.Preds + } else { + c.Preds = append(c.predstorage[:0], b.Preds...) + } + for i, e := range c.Preds { + p := e.b + p.Succs[e.i] = Edge{c, i} + } + f := b.Func + if f.Entry == b { + f.Entry = c + } + + // trash b's fields, just in case + for bx := b; bx != c; bx = b_next { + b_next = bx.Succs[0].b + + bx.Kind = BlockInvalid + bx.Values = nil + bx.Preds = nil + bx.Succs = nil + } + return true +} diff --git a/go/src/cmd/compile/internal/ssa/fuse_branchredirect.go b/go/src/cmd/compile/internal/ssa/fuse_branchredirect.go new file mode 100644 index 0000000000000000000000000000000000000000..153c2a56b716b21eaaac2f37c50bb0fb249b2902 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/fuse_branchredirect.go @@ -0,0 +1,112 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// fuseBranchRedirect checks for a CFG in which the outbound branch +// of an If block can be derived from its predecessor If block, in +// some such cases, we can redirect the predecessor If block to the +// corresponding successor block directly. For example: +// +// p: +// v11 = Less64 v10 v8 +// If v11 goto b else u +// b: <- p ... +// v17 = Leq64 v10 v8 +// If v17 goto s else o +// +// We can redirect p to s directly. +// +// The implementation here borrows the framework of the prove pass. +// +// 1, Traverse all blocks of function f to find If blocks. +// 2, For any If block b, traverse all its predecessors to find If blocks. +// 3, For any If block predecessor p, update relationship p->b. +// 4, Traverse all successors of b. +// 5, For any successor s of b, try to update relationship b->s, if a +// contradiction is found then redirect p to another successor of b. +func fuseBranchRedirect(f *Func) bool { + ft := newFactsTable(f) + ft.checkpoint() + + changed := false + for i := len(f.Blocks) - 1; i >= 0; i-- { + b := f.Blocks[i] + if b.Kind != BlockIf { + continue + } + // b is either empty or only contains the control value. + // TODO: if b contains only OpCopy or OpNot related to b.Controls, + // such as Copy(Not(Copy(Less64(v1, v2)))), perhaps it can be optimized. + bCtl := b.Controls[0] + if bCtl.Block != b && len(b.Values) != 0 || (len(b.Values) != 1 || bCtl.Uses != 1) && bCtl.Block == b { + continue + } + + for k := 0; k < len(b.Preds); k++ { + pk := b.Preds[k] + p := pk.b + if p.Kind != BlockIf || p == b { + continue + } + pbranch := positive + if pk.i == 1 { + pbranch = negative + } + ft.checkpoint() + // Assume branch p->b is taken. + addBranchRestrictions(ft, p, pbranch) + // Check if any outgoing branch is unreachable based on the above condition. + parent := b + for j, bbranch := range [...]branch{positive, negative} { + ft.checkpoint() + // Try to update relationship b->child, and check if the contradiction occurs. + addBranchRestrictions(ft, parent, bbranch) + unsat := ft.unsat + ft.restore() + if !unsat { + continue + } + // This branch is impossible,so redirect p directly to another branch. + out := 1 ^ j + child := parent.Succs[out].b + if child == b { + continue + } + b.removePred(k) + p.Succs[pk.i] = Edge{child, len(child.Preds)} + // Fix up Phi value in b to have one less argument. + for _, v := range b.Values { + if v.Op != OpPhi { + continue + } + b.removePhiArg(v, k) + } + // Fix up child to have one more predecessor. + child.Preds = append(child.Preds, Edge{p, pk.i}) + ai := b.Succs[out].i + for _, v := range child.Values { + if v.Op != OpPhi { + continue + } + v.AddArg(v.Args[ai]) + } + if b.Func.pass.debug > 0 { + b.Func.Warnl(b.Controls[0].Pos, "Redirect %s based on %s", b.Controls[0].Op, p.Controls[0].Op) + } + changed = true + k-- + break + } + ft.restore() + } + if len(b.Preds) == 0 && b != f.Entry { + // Block is now dead. + b.Kind = BlockInvalid + } + } + ft.restore() + ft.cleanup(f) + return changed +} diff --git a/go/src/cmd/compile/internal/ssa/fuse_comparisons.go b/go/src/cmd/compile/internal/ssa/fuse_comparisons.go new file mode 100644 index 0000000000000000000000000000000000000000..898c0344853e3c833740c8df79a20817b09e6aa6 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/fuse_comparisons.go @@ -0,0 +1,276 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// fuseIntInRange transforms integer range checks to remove the short-circuit operator. For example, +// it would convert `if 1 <= x && x < 5 { ... }` into `if (1 <= x) & (x < 5) { ... }`. Rewrite rules +// can then optimize these into unsigned range checks, `if unsigned(x-1) < 4 { ... }` in this case. +func fuseIntInRange(b *Block) bool { + return fuseComparisons(b, canOptIntInRange) +} + +// fuseNanCheck replaces the short-circuit operators between NaN checks and comparisons with +// constants. For example, it would transform `if x != x || x > 1.0 { ... }` into +// `if (x != x) | (x > 1.0) { ... }`. Rewrite rules can then merge the NaN check with the comparison, +// in this case generating `if !(x <= 1.0) { ... }`. +func fuseNanCheck(b *Block) bool { + return fuseComparisons(b, canOptNanCheck) +} + +// fuseSingleBitDifference replaces the short-circuit operators between equality checks with +// constants that only differ by a single bit. For example, it would convert +// `if x == 4 || x == 6 { ... }` into `if (x == 4) | (x == 6) { ... }`. Rewrite rules can +// then optimize these using a bitwise operation, in this case generating `if x|2 == 6 { ... }`. +func fuseSingleBitDifference(b *Block) bool { + return fuseComparisons(b, canOptSingleBitDifference) +} + +// fuseComparisons looks for control graphs that match this pattern: +// +// p - predecessor +// |\ +// | b - block +// |/ \ +// s0 s1 - successors +// +// This pattern is typical for if statements such as `if x || y { ... }` and `if x && y { ... }`. +// +// If canOptControls returns true when passed the control values for p and b then fuseComparisons +// will try to convert p into a plain block with only one successor (b) and modify b's control +// value to include p's control value (effectively causing b to be speculatively executed). +// +// This transformation results in a control graph that will now look like this: +// +// p +// \ +// b +// / \ +// s0 s1 +// +// Later passes will then fuse p and b. +// +// In other words `if x || y { ... }` will become `if x | y { ... }` and `if x && y { ... }` will +// become `if x & y { ... }`. This is a useful transformation because we can then use rewrite +// rules to optimize `x | y` and `x & y`. +func fuseComparisons(b *Block, canOptControls func(a, b *Value, op Op) bool) bool { + if len(b.Preds) != 1 { + return false + } + p := b.Preds[0].Block() + if b.Kind != BlockIf || p.Kind != BlockIf { + return false + } + + // Don't merge control values if b is likely to be bypassed anyway. + if p.Likely == BranchLikely && p.Succs[0].Block() != b { + return false + } + if p.Likely == BranchUnlikely && p.Succs[1].Block() != b { + return false + } + + // If the first (true) successors match then we have a disjunction (||). + // If the second (false) successors match then we have a conjunction (&&). + for i, op := range [2]Op{OpOrB, OpAndB} { + if p.Succs[i].Block() != b.Succs[i].Block() { + continue + } + + // Check if the control values can be usefully combined. + bc := b.Controls[0] + pc := p.Controls[0] + if !canOptControls(bc, pc, op) { + return false + } + + // TODO(mundaym): should we also check the cost of executing b? + // Currently we might speculatively execute b even if b contains + // a lot of instructions. We could just check that len(b.Values) + // is lower than a fixed amount. Bear in mind however that the + // other optimization passes might yet reduce the cost of b + // significantly so we shouldn't be overly conservative. + if !canSpeculativelyExecute(b) { + return false + } + + // Logically combine the control values for p and b. + v := b.NewValue0(bc.Pos, op, bc.Type) + v.AddArg(pc) + v.AddArg(bc) + + // Set the combined control value as the control value for b. + b.SetControl(v) + + // Modify p so that it jumps directly to b. + p.removeEdge(i) + p.Kind = BlockPlain + p.Likely = BranchUnknown + p.ResetControls() + + return true + } + + // TODO: could negate condition(s) to merge controls. + return false +} + +// getConstIntArgIndex returns the index of the first argument that is a +// constant integer or -1 if no such argument exists. +func getConstIntArgIndex(v *Value) int { + for i, a := range v.Args { + switch a.Op { + case OpConst8, OpConst16, OpConst32, OpConst64: + return i + } + } + return -1 +} + +// isSignedInequality reports whether op represents the inequality < or ≤ +// in the signed domain. +func isSignedInequality(v *Value) bool { + switch v.Op { + case OpLess64, OpLess32, OpLess16, OpLess8, + OpLeq64, OpLeq32, OpLeq16, OpLeq8: + return true + } + return false +} + +// isUnsignedInequality reports whether op represents the inequality < or ≤ +// in the unsigned domain. +func isUnsignedInequality(v *Value) bool { + switch v.Op { + case OpLess64U, OpLess32U, OpLess16U, OpLess8U, + OpLeq64U, OpLeq32U, OpLeq16U, OpLeq8U: + return true + } + return false +} + +func canOptIntInRange(x, y *Value, op Op) bool { + // We need both inequalities to be either in the signed or unsigned domain. + // TODO(mundaym): it would also be good to merge when we have an Eq op that + // could be transformed into a Less/Leq. For example in the unsigned + // domain 'x == 0 || 3 < x' is equivalent to 'x <= 0 || 3 < x' + inequalityChecks := [...]func(*Value) bool{ + isSignedInequality, + isUnsignedInequality, + } + for _, f := range inequalityChecks { + if !f(x) || !f(y) { + continue + } + + // Check that both inequalities are comparisons with constants. + xi := getConstIntArgIndex(x) + if xi < 0 { + return false + } + yi := getConstIntArgIndex(y) + if yi < 0 { + return false + } + + // Check that the non-constant arguments to the inequalities + // are the same. + return x.Args[xi^1] == y.Args[yi^1] + } + return false +} + +// canOptNanCheck reports whether one of arguments is a NaN check and the other +// is a comparison with a constant that can be combined together. +// +// Examples (c must be a constant): +// +// v != v || v < c => !(c <= v) +// v != v || v <= c => !(c < v) +// v != v || c < v => !(v <= c) +// v != v || c <= v => !(v < c) +func canOptNanCheck(x, y *Value, op Op) bool { + if op != OpOrB { + return false + } + + for i := 0; i <= 1; i, x, y = i+1, y, x { + if len(x.Args) != 2 || x.Args[0] != x.Args[1] { + continue + } + v := x.Args[0] + switch x.Op { + case OpNeq64F: + if y.Op != OpLess64F && y.Op != OpLeq64F { + return false + } + for j := 0; j <= 1; j++ { + a, b := y.Args[j], y.Args[j^1] + if a.Op != OpConst64F { + continue + } + // Sign bit operations not affect NaN check results. This special case allows us + // to optimize statements like `if v != v || Abs(v) > c { ... }`. + if (b.Op == OpAbs || b.Op == OpNeg64F) && b.Args[0] == v { + return true + } + return b == v + } + case OpNeq32F: + if y.Op != OpLess32F && y.Op != OpLeq32F { + return false + } + for j := 0; j <= 1; j++ { + a, b := y.Args[j], y.Args[j^1] + if a.Op != OpConst32F { + continue + } + // Sign bit operations not affect NaN check results. This special case allows us + // to optimize statements like `if v != v || -v > c { ... }`. + if b.Op == OpNeg32F && b.Args[0] == v { + return true + } + return b == v + } + } + } + return false +} + +// canOptSingleBitDifference returns true if x op y matches either: +// +// v == c || v == d +// v != c && v != d +// +// Where c and d are constant values that differ by a single bit. +func canOptSingleBitDifference(x, y *Value, op Op) bool { + if x.Op != y.Op { + return false + } + switch x.Op { + case OpEq64, OpEq32, OpEq16, OpEq8: + if op != OpOrB { + return false + } + case OpNeq64, OpNeq32, OpNeq16, OpNeq8: + if op != OpAndB { + return false + } + default: + return false + } + + xi := getConstIntArgIndex(x) + if xi < 0 { + return false + } + yi := getConstIntArgIndex(y) + if yi < 0 { + return false + } + if x.Args[xi^1] != y.Args[yi^1] { + return false + } + return oneBit(x.Args[xi].AuxInt ^ y.Args[yi].AuxInt) +} diff --git a/go/src/cmd/compile/internal/ssa/fuse_test.go b/go/src/cmd/compile/internal/ssa/fuse_test.go new file mode 100644 index 0000000000000000000000000000000000000000..2f89938d1d92332955de60be0fbb3eefedd19b4d --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/fuse_test.go @@ -0,0 +1,305 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "fmt" + "strconv" + "testing" +) + +func TestFuseEliminatesOneBranch(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"), + Valu("nilptr", OpConstNil, ptrType, 0, nil), + Valu("bool1", OpNeqPtr, c.config.Types.Bool, 0, nil, "ptr1", "nilptr"), + If("bool1", "then", "exit")), + Bloc("then", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + fuseLate(fun.f) + + for _, b := range fun.f.Blocks { + if b == fun.blocks["then"] && b.Kind != BlockInvalid { + t.Errorf("then was not eliminated, but should have") + } + } +} + +func TestFuseEliminatesBothBranches(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"), + Valu("nilptr", OpConstNil, ptrType, 0, nil), + Valu("bool1", OpNeqPtr, c.config.Types.Bool, 0, nil, "ptr1", "nilptr"), + If("bool1", "then", "else")), + Bloc("then", + Goto("exit")), + Bloc("else", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + fuseLate(fun.f) + + for _, b := range fun.f.Blocks { + if b == fun.blocks["then"] && b.Kind != BlockInvalid { + t.Errorf("then was not eliminated, but should have") + } + if b == fun.blocks["else"] && b.Kind != BlockInvalid { + t.Errorf("else was not eliminated, but should have") + } + } +} + +func TestFuseHandlesPhis(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"), + Valu("nilptr", OpConstNil, ptrType, 0, nil), + Valu("bool1", OpNeqPtr, c.config.Types.Bool, 0, nil, "ptr1", "nilptr"), + If("bool1", "then", "else")), + Bloc("then", + Goto("exit")), + Bloc("else", + Goto("exit")), + Bloc("exit", + Valu("phi", OpPhi, ptrType, 0, nil, "ptr1", "ptr1"), + Exit("mem"))) + + CheckFunc(fun.f) + fuseLate(fun.f) + + for _, b := range fun.f.Blocks { + if b == fun.blocks["then"] && b.Kind != BlockInvalid { + t.Errorf("then was not eliminated, but should have") + } + if b == fun.blocks["else"] && b.Kind != BlockInvalid { + t.Errorf("else was not eliminated, but should have") + } + } +} + +func TestFuseEliminatesEmptyBlocks(t *testing.T) { + c := testConfig(t) + // Case 1, plain type empty blocks z0 ~ z3 will be eliminated. + // entry + // | + // z0 + // | + // z1 + // | + // z2 + // | + // z3 + // | + // exit + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("z0")), + Bloc("z1", + Goto("z2")), + Bloc("z3", + Goto("exit")), + Bloc("z2", + Goto("z3")), + Bloc("z0", + Goto("z1")), + Bloc("exit", + Exit("mem"), + )) + + CheckFunc(fun.f) + fuseLate(fun.f) + + for k, b := range fun.blocks { + if k[:1] == "z" && b.Kind != BlockInvalid { + t.Errorf("case1 %s was not eliminated, but should have", k) + } + } + + // Case 2, empty blocks with If branch, z0 and z1 will be eliminated. + // entry + // / \ + // z0 z1 + // \ / + // exit + fun = c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("c", OpArg, c.config.Types.Bool, 0, nil), + If("c", "z0", "z1")), + Bloc("z0", + Goto("exit")), + Bloc("z1", + Goto("exit")), + Bloc("exit", + Exit("mem"), + )) + + CheckFunc(fun.f) + fuseLate(fun.f) + + for k, b := range fun.blocks { + if k[:1] == "z" && b.Kind != BlockInvalid { + t.Errorf("case2 %s was not eliminated, but should have", k) + } + } + + // Case 3, empty blocks with multiple predecessors, z0 and z1 will be eliminated. + // entry + // | \ + // | b0 + // | / \ + // z0 z1 + // \ / + // exit + fun = c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("c1", OpArg, c.config.Types.Bool, 0, nil), + If("c1", "b0", "z0")), + Bloc("b0", + Valu("c2", OpArg, c.config.Types.Bool, 0, nil), + If("c2", "z1", "z0")), + Bloc("z0", + Goto("exit")), + Bloc("z1", + Goto("exit")), + Bloc("exit", + Exit("mem"), + )) + + CheckFunc(fun.f) + fuseLate(fun.f) + + for k, b := range fun.blocks { + if k[:1] == "z" && b.Kind != BlockInvalid { + t.Errorf("case3 %s was not eliminated, but should have", k) + } + } +} + +func TestFuseSideEffects(t *testing.T) { + c := testConfig(t) + // Case1, test that we don't fuse branches that have side effects but + // have no use (e.g. followed by infinite loop). + // See issue #36005. + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("b", OpArg, c.config.Types.Bool, 0, nil), + If("b", "then", "else")), + Bloc("then", + Valu("call1", OpStaticCall, types.TypeMem, 0, AuxCallLSym("_"), "mem"), + Goto("empty")), + Bloc("else", + Valu("call2", OpStaticCall, types.TypeMem, 0, AuxCallLSym("_"), "mem"), + Goto("empty")), + Bloc("empty", + Goto("loop")), + Bloc("loop", + Goto("loop"))) + + CheckFunc(fun.f) + fuseLate(fun.f) + + for _, b := range fun.f.Blocks { + if b == fun.blocks["then"] && b.Kind == BlockInvalid { + t.Errorf("then is eliminated, but should not") + } + if b == fun.blocks["else"] && b.Kind == BlockInvalid { + t.Errorf("else is eliminated, but should not") + } + } + + // Case2, z0 contains a value that has side effect, z0 shouldn't be eliminated. + // entry + // | \ + // | z0 + // | / + // exit + fun = c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("c1", OpArg, c.config.Types.Bool, 0, nil), + Valu("p", OpArg, c.config.Types.IntPtr, 0, nil), + If("c1", "z0", "exit")), + Bloc("z0", + Valu("nilcheck", OpNilCheck, c.config.Types.IntPtr, 0, nil, "p", "mem"), + Goto("exit")), + Bloc("exit", + Exit("mem"), + )) + CheckFunc(fun.f) + fuseLate(fun.f) + z0, ok := fun.blocks["z0"] + if !ok || z0.Kind == BlockInvalid { + t.Errorf("case2 z0 is eliminated, but should not") + } +} + +func BenchmarkFuse(b *testing.B) { + for _, n := range [...]int{1, 10, 100, 1000, 10000} { + b.Run(strconv.Itoa(n), func(b *testing.B) { + c := testConfig(b) + + blocks := make([]bloc, 0, 2*n+3) + blocks = append(blocks, + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("cond", OpArg, c.config.Types.Bool, 0, nil), + Valu("x", OpArg, c.config.Types.Int64, 0, nil), + Goto("exit"))) + + phiArgs := make([]string, 0, 2*n) + for i := 0; i < n; i++ { + cname := fmt.Sprintf("c%d", i) + blocks = append(blocks, + Bloc(fmt.Sprintf("b%d", i), If("cond", cname, "merge")), + Bloc(cname, Goto("merge"))) + phiArgs = append(phiArgs, "x", "x") + } + blocks = append(blocks, + Bloc("merge", + Valu("phi", OpPhi, types.TypeMem, 0, nil, phiArgs...), + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + b.ResetTimer() + for i := 0; i < b.N; i++ { + fun := c.Fun("entry", blocks...) + fuseLate(fun.f) + } + }) + } +} diff --git a/go/src/cmd/compile/internal/ssa/generate.go b/go/src/cmd/compile/internal/ssa/generate.go new file mode 100644 index 0000000000000000000000000000000000000000..74c5b318291f03ffa1d982114a5ffa7eb81bdefa --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/generate.go @@ -0,0 +1,9 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build generate + +package ssa + +//go:generate go run -C=_gen . diff --git a/go/src/cmd/compile/internal/ssa/generate_test.go b/go/src/cmd/compile/internal/ssa/generate_test.go new file mode 100644 index 0000000000000000000000000000000000000000..d65288c399996fc702ece9c97789fec04a700ecf --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/generate_test.go @@ -0,0 +1,135 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "bytes" + "fmt" + "internal/testenv" + "os" + "path/filepath" + "testing" +) + +const expectedHeader = "// Code generated from _gen/" // this is the common part + +// TestGeneratedFilesUpToDate regenerates all the rewrite and rewrite-related +// files defined in _gen into a temporary directory, +// checks that they match what appears in the source tree, +// verifies that they start with the prefix of a generated header, +// and checks that the only source files with that header were actually generated. +func TestGeneratedFilesUpToDate(t *testing.T) { + testenv.MustHaveGoRun(t) + wd, err := os.Getwd() + if err != nil { + t.Fatalf("Failed to get current working directory: %v", err) + } + genDir := filepath.Join(wd, "_gen") + if _, err := os.Stat(genDir); os.IsNotExist(err) { + t.Fatalf("_gen directory not found") + } + + tmpdir := t.TempDir() + + // Accumulate a list of all existing files that look generated. + // It's an error if this set does not match the set that are + // generated into tmpdir. + genFiles := make(map[string]bool) + genPrefix := []byte(expectedHeader) + ssaFiles, err := filepath.Glob(filepath.Join(wd, "*.go")) + if err != nil { + t.Fatalf("could not glob for .go files in ssa directory: %v", err) + } + for _, f := range ssaFiles { + contents, err := os.ReadFile(f) + if err != nil { + t.Fatalf("could not read source file from ssa directory: %v", err) + } + // verify that the generated file has the expected header + // (this should cause other failures later, but if this is + // the problem, diagnose it here to shorten the treasure hunt.) + if bytes.HasPrefix(contents, genPrefix) { + genFiles[filepath.Base(f)] = true + } + } + + goFiles, err := filepath.Glob(filepath.Join(genDir, "*.go")) + if err != nil { + t.Fatalf("could not glob for .go files in _gen: %v", err) + } + if len(goFiles) == 0 { + t.Fatal("no .go files found in _gen") + } + + // Construct the command line for "go run". + // Explicitly list the files, just to make it + // clear what is included (if the test is logging). + args := []string{"run", "-C", genDir} + for _, f := range goFiles { + args = append(args, filepath.Base(f)) + } + args = append(args, "-outdir", tmpdir) + + logArgs := fmt.Sprintf("%v", args) + logArgs = logArgs[1 : len(logArgs)-2] // strip '[' and ']' + t.Logf("%s %v", testenv.GoToolPath(t), logArgs) + output, err := testenv.Command(t, testenv.GoToolPath(t), args...).CombinedOutput() + + if err != nil { + t.Fatalf("go run in _gen failed: %v\n%s", err, output) + } + + // Compare generated files with existing files in the parent directory. + files, err := os.ReadDir(tmpdir) + if err != nil { + t.Fatalf("could not read tmpdir %s: %v", tmpdir, err) + } + + for _, file := range files { + if file.IsDir() { + continue + } + filename := file.Name() + + // filename must be in the generated set, + if !genFiles[filename] { + t.Errorf("%s does not start with the expected header '%s' (if the header was changed the test needs to be updated)", + filename, expectedHeader) + } + genFiles[filename] = false // remove from set + + generatedPath := filepath.Join(tmpdir, filename) + originalPath := filepath.Join(wd, filename) + + generatedData, err := os.ReadFile(generatedPath) + if err != nil { + t.Errorf("could not read generated file %s: %v", generatedPath, err) + continue + } + + // there should be a corresponding file in the ssa directory, + originalData, err := os.ReadFile(originalPath) + if err != nil { + if os.IsNotExist(err) { + t.Errorf("generated file %s was created, but does not exist in the ssa directory. It may need to be added to the repository.", filename) + } else { + t.Errorf("could not read original file %s: %v", originalPath, err) + } + continue + } + + // and the contents of that file should match. + if !bytes.Equal(originalData, generatedData) { + t.Errorf("%s is out of date. Please run 'go generate'.", filename) + } + } + + // the generated set should be empty now. + for file, notGenerated := range genFiles { + if notGenerated { + t.Errorf("%s has the header of a generated file but was not generated", file) + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/html.go b/go/src/cmd/compile/internal/ssa/html.go new file mode 100644 index 0000000000000000000000000000000000000000..7a6683e9f01542ae06241bf6fb880a34721e8e85 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/html.go @@ -0,0 +1,1314 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "bytes" + "cmd/internal/src" + "cmp" + "fmt" + "html" + "io" + "os" + "os/exec" + "path/filepath" + "strconv" + "strings" +) + +type HTMLWriter struct { + w io.WriteCloser + Func *Func + path string + dot *dotWriter + prevHash []byte + pendingPhases []string + pendingTitles []string +} + +func NewHTMLWriter(path string, f *Func, cfgMask string) *HTMLWriter { + path = strings.ReplaceAll(path, "/", string(filepath.Separator)) + out, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + if err != nil { + f.Fatalf("%v", err) + } + reportPath := path + if !filepath.IsAbs(reportPath) { + pwd, err := os.Getwd() + if err != nil { + f.Fatalf("%v", err) + } + reportPath = filepath.Join(pwd, path) + } + html := HTMLWriter{ + w: out, + Func: f, + path: reportPath, + dot: newDotWriter(cfgMask), + } + html.start() + return &html +} + +// Fatalf reports an error and exits. +func (w *HTMLWriter) Fatalf(msg string, args ...any) { + fe := w.Func.Frontend() + fe.Fatalf(src.NoXPos, msg, args...) +} + +// Logf calls the (w *HTMLWriter).Func's Logf method passing along a msg and args. +func (w *HTMLWriter) Logf(msg string, args ...any) { + w.Func.Logf(msg, args...) +} + +func (w *HTMLWriter) start() { + if w == nil { + return + } + w.WriteString("") + w.WriteString(` + + + + + +`) + w.WriteString("") + w.WriteString("

") + w.WriteString(html.EscapeString(w.Func.NameABI())) + w.WriteString("

") + w.WriteString(` +
help +
+ +

+Click on a value or block to toggle highlighting of that value/block +and its uses. (Values and blocks are highlighted by ID, and IDs of +dead items may be reused, so not all highlights necessarily correspond +to the clicked item.) +

+ +

+Faded out values and blocks are dead code that has not been eliminated. +

+ +

+Values printed in italics have a dependency cycle. +

+ +

+CFG: Dashed edge is for unlikely branches. Blue color is for backward edges. +Edge with a dot means that this edge follows the order in which blocks were laidout. +

+ +
+ + +`) + w.WriteString("") + w.WriteString("") +} + +func (w *HTMLWriter) Close() { + if w == nil { + return + } + io.WriteString(w.w, "") + io.WriteString(w.w, "
") + io.WriteString(w.w, "") + io.WriteString(w.w, "") + w.w.Close() + fmt.Printf("dumped SSA for %s to %v\n", w.Func.NameABI(), w.path) +} + +// WritePhase writes f in a column headed by title. +// phase is used for collapsing columns and should be unique across the table. +func (w *HTMLWriter) WritePhase(phase, title string) { + if w == nil { + return // avoid generating HTML just to discard it + } + hash := hashFunc(w.Func) + w.pendingPhases = append(w.pendingPhases, phase) + w.pendingTitles = append(w.pendingTitles, title) + if !bytes.Equal(hash, w.prevHash) { + w.flushPhases() + } + w.prevHash = hash +} + +// flushPhases collects any pending phases and titles, writes them to the html, and resets the pending slices. +func (w *HTMLWriter) flushPhases() { + phaseLen := len(w.pendingPhases) + if phaseLen == 0 { + return + } + phases := strings.Join(w.pendingPhases, " + ") + w.WriteMultiTitleColumn( + phases, + w.pendingTitles, + fmt.Sprintf("hash-%x", w.prevHash), + w.Func.HTML(w.pendingPhases[phaseLen-1], w.dot), + ) + w.pendingPhases = w.pendingPhases[:0] + w.pendingTitles = w.pendingTitles[:0] +} + +// FuncLines contains source code for a function to be displayed +// in sources column. +type FuncLines struct { + Filename string + StartLineno uint + Lines []string +} + +// ByTopoCmp sorts topologically: target function is on top, +// followed by inlined functions sorted by filename and line numbers. +func ByTopoCmp(a, b *FuncLines) int { + if r := strings.Compare(a.Filename, b.Filename); r != 0 { + return r + } + return cmp.Compare(a.StartLineno, b.StartLineno) +} + +// WriteSources writes lines as source code in a column headed by title. +// phase is used for collapsing columns and should be unique across the table. +func (w *HTMLWriter) WriteSources(phase string, all []*FuncLines) { + if w == nil { + return // avoid generating HTML just to discard it + } + var buf strings.Builder + fmt.Fprint(&buf, "
") + filename := "" + for _, fl := range all { + fmt.Fprint(&buf, "
 
") + if filename != fl.Filename { + fmt.Fprint(&buf, "
 
") + filename = fl.Filename + } + for i := range fl.Lines { + ln := int(fl.StartLineno) + i + fmt.Fprintf(&buf, "
%v
", ln, ln) + } + } + fmt.Fprint(&buf, "
")
+	filename = ""
+	for _, fl := range all {
+		fmt.Fprint(&buf, "
 
") + if filename != fl.Filename { + fmt.Fprintf(&buf, "
%v
", fl.Filename) + filename = fl.Filename + } + for i, line := range fl.Lines { + ln := int(fl.StartLineno) + i + var escaped string + if strings.TrimSpace(line) == "" { + escaped = " " + } else { + escaped = html.EscapeString(line) + } + fmt.Fprintf(&buf, "
%v
", ln, escaped) + } + } + fmt.Fprint(&buf, "
") + w.WriteColumn(phase, phase, "allow-x-scroll", buf.String()) +} + +func (w *HTMLWriter) WriteAST(phase string, buf *bytes.Buffer) { + if w == nil { + return // avoid generating HTML just to discard it + } + lines := strings.Split(buf.String(), "\n") + var out strings.Builder + + fmt.Fprint(&out, "
") + for _, l := range lines { + l = strings.TrimSpace(l) + var escaped string + var lineNo string + if l == "" { + escaped = " " + } else { + if strings.HasPrefix(l, "buildssa") { + escaped = fmt.Sprintf("%v", l) + } else { + // Parse the line number from the format file:line:col. + // See the implementation in ir/fmt.go:dumpNodeHeader. + sl := strings.Split(l, ":") + if len(sl) >= 3 { + if _, err := strconv.Atoi(sl[len(sl)-2]); err == nil { + lineNo = sl[len(sl)-2] + } + } + escaped = html.EscapeString(l) + } + } + if lineNo != "" { + fmt.Fprintf(&out, "
%v
", lineNo, escaped) + } else { + fmt.Fprintf(&out, "
%v
", escaped) + } + } + fmt.Fprint(&out, "
") + w.WriteColumn(phase, phase, "allow-x-scroll", out.String()) +} + +// WriteColumn writes raw HTML in a column headed by title. +// It is intended for pre- and post-compilation log output. +func (w *HTMLWriter) WriteColumn(phase, title, class, html string) { + w.WriteMultiTitleColumn(phase, []string{title}, class, html) +} + +func (w *HTMLWriter) WriteMultiTitleColumn(phase string, titles []string, class, html string) { + if w == nil { + return + } + id := strings.ReplaceAll(phase, " ", "-") + // collapsed column + w.Printf("
%v
", id, phase) + + if class == "" { + w.Printf("", id) + } else { + w.Printf("", id, class) + } + for _, title := range titles { + w.WriteString("

" + title + "

") + } + w.WriteString(html) + w.WriteString("\n") +} + +func (w *HTMLWriter) Printf(msg string, v ...any) { + if _, err := fmt.Fprintf(w.w, msg, v...); err != nil { + w.Fatalf("%v", err) + } +} + +func (w *HTMLWriter) WriteString(s string) { + if _, err := io.WriteString(w.w, s); err != nil { + w.Fatalf("%v", err) + } +} + +func (v *Value) HTML() string { + // TODO: Using the value ID as the class ignores the fact + // that value IDs get recycled and that some values + // are transmuted into other values. + s := v.String() + return fmt.Sprintf("%s", s, s) +} + +func (v *Value) LongHTML() string { + // TODO: Any intra-value formatting? + // I'm wary of adding too much visual noise, + // but a little bit might be valuable. + // We already have visual noise in the form of punctuation + // maybe we could replace some of that with formatting. + s := fmt.Sprintf("", v.String()) + + linenumber := "(?)" + if v.Pos.IsKnown() { + linenumber = fmt.Sprintf("(%s)", v.Pos.LineNumber(), v.Pos.LineNumberHTML()) + } + + s += fmt.Sprintf("%s %s = %s", v.HTML(), linenumber, v.Op.String()) + + s += " <" + html.EscapeString(v.Type.String()) + ">" + s += html.EscapeString(v.auxString()) + for _, a := range v.Args { + s += fmt.Sprintf(" %s", a.HTML()) + } + r := v.Block.Func.RegAlloc + if int(v.ID) < len(r) && r[v.ID] != nil { + s += " : " + html.EscapeString(r[v.ID].String()) + } + if reg := v.Block.Func.tempRegs[v.ID]; reg != nil { + s += " tmp=" + reg.String() + } + var names []string + for name, values := range v.Block.Func.NamedValues { + for _, value := range values { + if value == v { + names = append(names, name.String()) + break // drop duplicates. + } + } + } + if len(names) != 0 { + s += " (" + strings.Join(names, ", ") + ")" + } + + s += "" + return s +} + +func (b *Block) HTML() string { + // TODO: Using the value ID as the class ignores the fact + // that value IDs get recycled and that some values + // are transmuted into other values. + s := html.EscapeString(b.String()) + return fmt.Sprintf("%s", s, s) +} + +func (b *Block) LongHTML() string { + // TODO: improve this for HTML? + s := fmt.Sprintf("%s", html.EscapeString(b.String()), html.EscapeString(b.Kind.String())) + if b.Aux != nil { + s += html.EscapeString(fmt.Sprintf(" {%v}", b.Aux)) + } + if t := b.AuxIntString(); t != "" { + s += html.EscapeString(fmt.Sprintf(" [%v]", t)) + } + for _, c := range b.ControlValues() { + s += fmt.Sprintf(" %s", c.HTML()) + } + if len(b.Succs) > 0 { + s += " →" // right arrow + for _, e := range b.Succs { + c := e.b + s += " " + c.HTML() + } + } + switch b.Likely { + case BranchUnlikely: + s += " (unlikely)" + case BranchLikely: + s += " (likely)" + } + if b.Pos.IsKnown() { + // TODO does not begin to deal with the full complexity of line numbers. + // Maybe we want a string/slice instead, of outer-inner when inlining. + s += fmt.Sprintf(" (%s)", b.Pos.LineNumber(), b.Pos.LineNumberHTML()) + } + return s +} + +func (f *Func) HTML(phase string, dot *dotWriter) string { + buf := new(strings.Builder) + if dot != nil { + dot.writeFuncSVG(buf, phase, f) + } + fmt.Fprint(buf, "") + p := htmlFuncPrinter{w: buf} + fprintFunc(p, f) + + // fprintFunc(&buf, f) // TODO: HTML, not text,
for line breaks, etc. + fmt.Fprint(buf, "
") + return buf.String() +} + +func (d *dotWriter) writeFuncSVG(w io.Writer, phase string, f *Func) { + if d.broken { + return + } + if _, ok := d.phases[phase]; !ok { + return + } + cmd := exec.Command(d.path, "-Tsvg") + pipe, err := cmd.StdinPipe() + if err != nil { + d.broken = true + fmt.Println(err) + return + } + buf := new(bytes.Buffer) + cmd.Stdout = buf + bufErr := new(strings.Builder) + cmd.Stderr = bufErr + err = cmd.Start() + if err != nil { + d.broken = true + fmt.Println(err) + return + } + fmt.Fprint(pipe, `digraph "" { margin=0; ranksep=.2; `) + id := strings.ReplaceAll(phase, " ", "-") + fmt.Fprintf(pipe, `id="g_graph_%s";`, id) + fmt.Fprintf(pipe, `node [style=filled,fillcolor=white,fontsize=16,fontname="Menlo,Times,serif",margin="0.01,0.03"];`) + fmt.Fprintf(pipe, `edge [fontsize=16,fontname="Menlo,Times,serif"];`) + for i, b := range f.Blocks { + if b.Kind == BlockInvalid { + continue + } + layout := "" + if f.laidout { + layout = fmt.Sprintf(" #%d", i) + } + fmt.Fprintf(pipe, `%v [label="%v%s\n%v",id="graph_node_%v_%v",tooltip="%v"];`, b, b, layout, b.Kind.String(), id, b, b.LongString()) + } + indexOf := make([]int, f.NumBlocks()) + for i, b := range f.Blocks { + indexOf[b.ID] = i + } + layoutDrawn := make([]bool, f.NumBlocks()) + + ponums := make([]int32, f.NumBlocks()) + _ = postorderWithNumbering(f, ponums) + isBackEdge := func(from, to ID) bool { + return ponums[from] <= ponums[to] + } + + for _, b := range f.Blocks { + for i, s := range b.Succs { + style := "solid" + color := "black" + arrow := "vee" + if b.unlikelyIndex() == i { + style = "dashed" + } + if f.laidout && indexOf[s.b.ID] == indexOf[b.ID]+1 { + // Red color means ordered edge. It overrides other colors. + arrow = "dotvee" + layoutDrawn[s.b.ID] = true + } else if isBackEdge(b.ID, s.b.ID) { + color = "#2893ff" + } + fmt.Fprintf(pipe, `%v -> %v [label=" %d ",style="%s",color="%s",arrowhead="%s"];`, b, s.b, i, style, color, arrow) + } + } + if f.laidout { + fmt.Fprintln(pipe, `edge[constraint=false,color=gray,style=solid,arrowhead=dot];`) + colors := [...]string{"#eea24f", "#f38385", "#f4d164", "#ca89fc", "gray"} + ci := 0 + for i := 1; i < len(f.Blocks); i++ { + if layoutDrawn[f.Blocks[i].ID] { + continue + } + fmt.Fprintf(pipe, `%s -> %s [color="%s"];`, f.Blocks[i-1], f.Blocks[i], colors[ci]) + ci = (ci + 1) % len(colors) + } + } + fmt.Fprint(pipe, "}") + pipe.Close() + err = cmd.Wait() + if err != nil { + d.broken = true + fmt.Printf("dot: %v\n%v\n", err, bufErr.String()) + return + } + + svgID := "svg_graph_" + id + fmt.Fprintf(w, `
`, svgID, svgID) + // For now, an awful hack: edit the html as it passes through + // our fingers, finding '", b, dead) + fmt.Fprintf(p.w, "
  • %s:", b.HTML()) + if len(b.Preds) > 0 { + io.WriteString(p.w, " ←") // left arrow + for _, e := range b.Preds { + pred := e.b + fmt.Fprintf(p.w, " %s", pred.HTML()) + } + } + if len(b.Values) > 0 { + io.WriteString(p.w, ``) + } + io.WriteString(p.w, "
  • ") + if len(b.Values) > 0 { // start list of values + io.WriteString(p.w, "
  • ") + io.WriteString(p.w, "
      ") + } +} + +func (p htmlFuncPrinter) endBlock(b *Block, reachable bool) { + if len(b.Values) > 0 { // end list of values + io.WriteString(p.w, "
    ") + io.WriteString(p.w, "
  • ") + } + io.WriteString(p.w, "
  • ") + fmt.Fprint(p.w, b.LongHTML()) + io.WriteString(p.w, "
  • ") + io.WriteString(p.w, "") +} + +func (p htmlFuncPrinter) value(v *Value, live bool) { + var dead string + if !live { + dead = "dead-value" + } + fmt.Fprintf(p.w, "
  • ", dead) + fmt.Fprint(p.w, v.LongHTML()) + io.WriteString(p.w, "
  • ") +} + +func (p htmlFuncPrinter) startDepCycle() { + fmt.Fprintln(p.w, "") +} + +func (p htmlFuncPrinter) endDepCycle() { + fmt.Fprintln(p.w, "") +} + +func (p htmlFuncPrinter) named(n LocalSlot, vals []*Value) { + fmt.Fprintf(p.w, "
  • name %s: ", n) + for _, val := range vals { + fmt.Fprintf(p.w, "%s ", val.HTML()) + } + fmt.Fprintf(p.w, "
  • ") +} + +type dotWriter struct { + path string + broken bool + phases map[string]bool // keys specify phases with CFGs +} + +// newDotWriter returns non-nil value when mask is valid. +// dotWriter will generate SVGs only for the phases specified in the mask. +// mask can contain following patterns and combinations of them: +// * - all of them; +// x-y - x through y, inclusive; +// x,y - x and y, but not the passes between. +func newDotWriter(mask string) *dotWriter { + if mask == "" { + return nil + } + // User can specify phase name with _ instead of spaces. + mask = strings.ReplaceAll(mask, "_", " ") + ph := make(map[string]bool) + ranges := strings.Split(mask, ",") + for _, r := range ranges { + spl := strings.Split(r, "-") + if len(spl) > 2 { + fmt.Printf("range is not valid: %v\n", mask) + return nil + } + var first, last int + if mask == "*" { + first = 0 + last = len(passes) - 1 + } else { + first = passIdxByName(spl[0]) + last = passIdxByName(spl[len(spl)-1]) + } + if first < 0 || last < 0 || first > last { + fmt.Printf("range is not valid: %v\n", r) + return nil + } + for p := first; p <= last; p++ { + ph[passes[p].name] = true + } + } + + path, err := exec.LookPath("dot") + if err != nil { + fmt.Println(err) + return nil + } + return &dotWriter{path: path, phases: ph} +} + +func passIdxByName(name string) int { + for i, p := range passes { + if p.name == name { + return i + } + } + return -1 +} diff --git a/go/src/cmd/compile/internal/ssa/id.go b/go/src/cmd/compile/internal/ssa/id.go new file mode 100644 index 0000000000000000000000000000000000000000..725279e9fd8d7d1e8e7cd14b5b3332a1eabf18c8 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/id.go @@ -0,0 +1,28 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +type ID int32 + +// idAlloc provides an allocator for unique integers. +type idAlloc struct { + last ID +} + +// get allocates an ID and returns it. IDs are always > 0. +func (a *idAlloc) get() ID { + x := a.last + x++ + if x == 1<<31-1 { + panic("too many ids for this function") + } + a.last = x + return x +} + +// num returns the maximum ID ever returned + 1. +func (a *idAlloc) num() int { + return int(a.last + 1) +} diff --git a/go/src/cmd/compile/internal/ssa/layout.go b/go/src/cmd/compile/internal/ssa/layout.go new file mode 100644 index 0000000000000000000000000000000000000000..927287dc77ec410f851f1669a0f5b98c43e9f7e7 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/layout.go @@ -0,0 +1,185 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// layout orders basic blocks in f with the goal of minimizing control flow instructions. +// After this phase returns, the order of f.Blocks matters and is the order +// in which those blocks will appear in the assembly output. +func layout(f *Func) { + f.Blocks = layoutOrder(f) +} + +// Register allocation may use a different order which has constraints +// imposed by the linear-scan algorithm. +func layoutRegallocOrder(f *Func) []*Block { + // remnant of an experiment; perhaps there will be another. + return f.Blocks +} + +func layoutOrder(f *Func) []*Block { + order := make([]*Block, 0, f.NumBlocks()) + scheduled := f.Cache.allocBoolSlice(f.NumBlocks()) + defer f.Cache.freeBoolSlice(scheduled) + idToBlock := f.Cache.allocBlockSlice(f.NumBlocks()) + defer f.Cache.freeBlockSlice(idToBlock) + indegree := f.Cache.allocIntSlice(f.NumBlocks()) + defer f.Cache.freeIntSlice(indegree) + posdegree := f.newSparseSet(f.NumBlocks()) // blocks with positive remaining degree + defer f.retSparseSet(posdegree) + // blocks with zero remaining degree. Use slice to simulate a LIFO queue to implement + // the depth-first topology sorting algorithm. + var zerodegree []ID + // LIFO queue. Track the successor blocks of the scheduled block so that when we + // encounter loops, we choose to schedule the successor block of the most recently + // scheduled block. + var succs []ID + exit := f.newSparseSet(f.NumBlocks()) // exit blocks + defer f.retSparseSet(exit) + + // Populate idToBlock and find exit blocks. + for _, b := range f.Blocks { + idToBlock[b.ID] = b + if b.Kind == BlockExit { + exit.add(b.ID) + } + } + + // Expand exit to include blocks post-dominated by exit blocks. + for { + changed := false + for _, id := range exit.contents() { + b := idToBlock[id] + NextPred: + for _, pe := range b.Preds { + p := pe.b + if exit.contains(p.ID) { + continue + } + for _, s := range p.Succs { + if !exit.contains(s.b.ID) { + continue NextPred + } + } + // All Succs are in exit; add p. + exit.add(p.ID) + changed = true + } + } + if !changed { + break + } + } + + // Initialize indegree of each block + for _, b := range f.Blocks { + if exit.contains(b.ID) { + // exit blocks are always scheduled last + continue + } + indegree[b.ID] = len(b.Preds) + if len(b.Preds) == 0 { + // Push an element to the tail of the queue. + zerodegree = append(zerodegree, b.ID) + } else { + posdegree.add(b.ID) + } + } + + bid := f.Entry.ID +blockloop: + for { + // add block to schedule + b := idToBlock[bid] + order = append(order, b) + scheduled[bid] = true + if len(order) == len(f.Blocks) { + break + } + + // Here, the order of traversing the b.Succs affects the direction in which the topological + // sort advances in depth. Take the following cfg as an example, regardless of other factors. + // b1 + // 0/ \1 + // b2 b3 + // Traverse b.Succs in order, the right child node b3 will be scheduled immediately after + // b1, traverse b.Succs in reverse order, the left child node b2 will be scheduled + // immediately after b1. The test results show that reverse traversal performs a little + // better. + // Note: You need to consider both layout and register allocation when testing performance. + for i := len(b.Succs) - 1; i >= 0; i-- { + c := b.Succs[i].b + indegree[c.ID]-- + if indegree[c.ID] == 0 { + posdegree.remove(c.ID) + zerodegree = append(zerodegree, c.ID) + } else { + succs = append(succs, c.ID) + } + } + + // Pick the next block to schedule + // Pick among the successor blocks that have not been scheduled yet. + + // Use likely direction if we have it. + var likely *Block + switch b.Likely { + case BranchLikely: + likely = b.Succs[0].b + case BranchUnlikely: + likely = b.Succs[1].b + } + if likely != nil && !scheduled[likely.ID] { + bid = likely.ID + continue + } + + // Use degree for now. + bid = 0 + // TODO: improve this part + // No successor of the previously scheduled block works. + // Pick a zero-degree block if we can. + for len(zerodegree) > 0 { + // Pop an element from the tail of the queue. + cid := zerodegree[len(zerodegree)-1] + zerodegree = zerodegree[:len(zerodegree)-1] + if !scheduled[cid] { + bid = cid + continue blockloop + } + } + + // Still nothing, pick the unscheduled successor block encountered most recently. + for len(succs) > 0 { + // Pop an element from the tail of the queue. + cid := succs[len(succs)-1] + succs = succs[:len(succs)-1] + if !scheduled[cid] { + bid = cid + continue blockloop + } + } + + // Still nothing, pick any non-exit block. + for posdegree.size() > 0 { + cid := posdegree.pop() + if !scheduled[cid] { + bid = cid + continue blockloop + } + } + // Pick any exit block. + // TODO: Order these to minimize jump distances? + for { + cid := exit.pop() + if !scheduled[cid] { + bid = cid + continue blockloop + } + } + } + f.laidout = true + return order + //f.Blocks = order +} diff --git a/go/src/cmd/compile/internal/ssa/lca.go b/go/src/cmd/compile/internal/ssa/lca.go new file mode 100644 index 0000000000000000000000000000000000000000..6e7ad96d29d629162882ef5cfe7a5b4484f268c1 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/lca.go @@ -0,0 +1,127 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "math/bits" +) + +// Code to compute lowest common ancestors in the dominator tree. +// https://en.wikipedia.org/wiki/Lowest_common_ancestor +// https://en.wikipedia.org/wiki/Range_minimum_query#Solution_using_constant_time_and_linearithmic_space + +// lcaRange is a data structure that can compute lowest common ancestor queries +// in O(n lg n) precomputed space and O(1) time per query. +type lcaRange struct { + // Additional information about each block (indexed by block ID). + blocks []lcaRangeBlock + + // Data structure for range minimum queries. + // rangeMin[k][i] contains the ID of the minimum depth block + // in the Euler tour from positions i to i+1< 0 { + n := len(q) - 1 + bid := q[n].bid + cid := q[n].cid + q = q[:n] + + // Add block to tour. + blocks[bid].pos = int32(len(tour)) + tour = append(tour, bid) + + // Proceed down next child edge (if any). + if cid == 0 { + // This is our first visit to b. Set its depth. + blocks[bid].depth = blocks[blocks[bid].parent].depth + 1 + // Then explore its first child. + cid = blocks[bid].firstChild + } else { + // We've seen b before. Explore the next child. + cid = blocks[cid].sibling + } + if cid != 0 { + q = append(q, queueEntry{bid, cid}, queueEntry{cid, 0}) + } + } + + // Compute fast range-minimum query data structure + rangeMin := make([][]ID, 0, bits.Len64(uint64(len(tour)))) + rangeMin = append(rangeMin, tour) // 1-size windows are just the tour itself. + for logS, s := 1, 2; s < len(tour); logS, s = logS+1, s*2 { + r := make([]ID, len(tour)-s+1) + for i := 0; i < len(tour)-s+1; i++ { + bid := rangeMin[logS-1][i] + bid2 := rangeMin[logS-1][i+s/2] + if blocks[bid2].depth < blocks[bid].depth { + bid = bid2 + } + r[i] = bid + } + rangeMin = append(rangeMin, r) + } + + return &lcaRange{blocks: blocks, rangeMin: rangeMin} +} + +// find returns the lowest common ancestor of a and b. +func (lca *lcaRange) find(a, b *Block) *Block { + if a == b { + return a + } + // Find the positions of a and b in the Euler tour. + p1 := lca.blocks[a.ID].pos + p2 := lca.blocks[b.ID].pos + if p1 > p2 { + p1, p2 = p2, p1 + } + + // The lowest common ancestor is the minimum depth block + // on the tour from p1 to p2. We've precomputed minimum + // depth blocks for powers-of-two subsequences of the tour. + // Combine the right two precomputed values to get the answer. + logS := uint(log64(int64(p2 - p1))) + bid1 := lca.rangeMin[logS][p1] + bid2 := lca.rangeMin[logS][p2-1< db { + da-- + a = lca.parent[a.ID] + } + for da < db { + db-- + b = lca.parent[b.ID] + } + for a != b { + a = lca.parent[a.ID] + b = lca.parent[b.ID] + } + return a +} + +func (lca *lcaEasy) depth(b *Block) int { + n := 0 + for b != nil { + b = lca.parent[b.ID] + n++ + } + return n +} diff --git a/go/src/cmd/compile/internal/ssa/likelyadjust.go b/go/src/cmd/compile/internal/ssa/likelyadjust.go new file mode 100644 index 0000000000000000000000000000000000000000..06b9414a3f56619c567ce9e31194324d2936128a --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/likelyadjust.go @@ -0,0 +1,424 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "fmt" +) + +type loop struct { + header *Block // The header node of this (reducible) loop + outer *loop // loop containing this loop + + // Next three fields used by regalloc and/or + // aid in computation of inner-ness and list of blocks. + nBlocks int32 // Number of blocks in this loop but not within inner loops + depth int16 // Nesting depth of the loop; 1 is outermost. + isInner bool // True if never discovered to contain a loop + + // True if all paths through the loop have a call. + // Computed and used by regalloc; stored here for convenience. + containsUnavoidableCall bool +} + +// outerinner records that outer contains inner +func (sdom SparseTree) outerinner(outer, inner *loop) { + // There could be other outer loops found in some random order, + // locate the new outer loop appropriately among them. + + // Outer loop headers dominate inner loop headers. + // Use this to put the "new" "outer" loop in the right place. + oldouter := inner.outer + for oldouter != nil && sdom.isAncestor(outer.header, oldouter.header) { + inner = oldouter + oldouter = inner.outer + } + if outer == oldouter { + return + } + if oldouter != nil { + sdom.outerinner(oldouter, outer) + } + + inner.outer = outer + outer.isInner = false +} + +type loopnest struct { + f *Func + b2l []*loop + po []*Block + sdom SparseTree + loops []*loop + hasIrreducible bool // TODO current treatment of irreducible loops is very flaky, if accurate loops are needed, must punt at function level. +} + +const ( + blDEFAULT = 0 + blMin = blDEFAULT + blCALL = 1 + blRET = 2 + blEXIT = 3 +) + +var bllikelies = [4]string{"default", "call", "ret", "exit"} + +func describePredictionAgrees(b *Block, prediction BranchPrediction) string { + s := "" + if prediction == b.Likely { + s = " (agrees with previous)" + } else if b.Likely != BranchUnknown { + s = " (disagrees with previous, ignored)" + } + return s +} + +func describeBranchPrediction(f *Func, b *Block, likely, not int8, prediction BranchPrediction) { + f.Warnl(b.Pos, "Branch prediction rule %s < %s%s", + bllikelies[likely-blMin], bllikelies[not-blMin], describePredictionAgrees(b, prediction)) +} + +func likelyadjust(f *Func) { + // The values assigned to certain and local only matter + // in their rank order. 0 is default, more positive + // is less likely. It's possible to assign a negative + // unlikeliness (though not currently the case). + certain := f.Cache.allocInt8Slice(f.NumBlocks()) // In the long run, all outcomes are at least this bad. Mainly for Exit + defer f.Cache.freeInt8Slice(certain) + local := f.Cache.allocInt8Slice(f.NumBlocks()) // for our immediate predecessors. + defer f.Cache.freeInt8Slice(local) + + po := f.postorder() + nest := f.loopnest() + b2l := nest.b2l + + for _, b := range po { + switch b.Kind { + case BlockExit: + // Very unlikely. + local[b.ID] = blEXIT + certain[b.ID] = blEXIT + + // Ret, it depends. + case BlockRet, BlockRetJmp: + local[b.ID] = blRET + certain[b.ID] = blRET + + // Calls. TODO not all calls are equal, names give useful clues. + // Any name-based heuristics are only relative to other calls, + // and less influential than inferences from loop structure. + case BlockDefer: + local[b.ID] = blCALL + certain[b.ID] = max(blCALL, certain[b.Succs[0].b.ID]) + + default: + if len(b.Succs) == 1 { + certain[b.ID] = certain[b.Succs[0].b.ID] + } else if len(b.Succs) == 2 { + // If successor is an unvisited backedge, it's in loop and we don't care. + // Its default unlikely is also zero which is consistent with favoring loop edges. + // Notice that this can act like a "reset" on unlikeliness at loops; the + // default "everything returns" unlikeliness is erased by min with the + // backedge likeliness; however a loop with calls on every path will be + // tagged with call cost. Net effect is that loop entry is favored. + b0 := b.Succs[0].b.ID + b1 := b.Succs[1].b.ID + certain[b.ID] = min(certain[b0], certain[b1]) + + l := b2l[b.ID] + l0 := b2l[b0] + l1 := b2l[b1] + + prediction := b.Likely + // Weak loop heuristic -- both source and at least one dest are in loops, + // and there is a difference in the destinations. + // TODO what is best arrangement for nested loops? + if l != nil && l0 != l1 { + noprediction := false + switch { + // prefer not to exit loops + case l1 == nil: + prediction = BranchLikely + case l0 == nil: + prediction = BranchUnlikely + + // prefer to stay in loop, not exit to outer. + case l == l0: + prediction = BranchLikely + case l == l1: + prediction = BranchUnlikely + default: + noprediction = true + } + if f.pass.debug > 0 && !noprediction { + f.Warnl(b.Pos, "Branch prediction rule stay in loop%s", + describePredictionAgrees(b, prediction)) + } + + } else { + // Lacking loop structure, fall back on heuristics. + if certain[b1] > certain[b0] { + prediction = BranchLikely + if f.pass.debug > 0 { + describeBranchPrediction(f, b, certain[b0], certain[b1], prediction) + } + } else if certain[b0] > certain[b1] { + prediction = BranchUnlikely + if f.pass.debug > 0 { + describeBranchPrediction(f, b, certain[b1], certain[b0], prediction) + } + } else if local[b1] > local[b0] { + prediction = BranchLikely + if f.pass.debug > 0 { + describeBranchPrediction(f, b, local[b0], local[b1], prediction) + } + } else if local[b0] > local[b1] { + prediction = BranchUnlikely + if f.pass.debug > 0 { + describeBranchPrediction(f, b, local[b1], local[b0], prediction) + } + } + } + if b.Likely != prediction { + if b.Likely == BranchUnknown { + b.Likely = prediction + } + } + } + // Look for calls in the block. If there is one, make this block unlikely. + for _, v := range b.Values { + if opcodeTable[v.Op].call { + local[b.ID] = blCALL + certain[b.ID] = max(blCALL, certain[b.Succs[0].b.ID]) + break + } + } + } + if f.pass.debug > 2 { + f.Warnl(b.Pos, "BP: Block %s, local=%s, certain=%s", b, bllikelies[local[b.ID]-blMin], bllikelies[certain[b.ID]-blMin]) + } + + } +} + +func (l *loop) String() string { + return fmt.Sprintf("hdr:%s", l.header) +} + +func (l *loop) LongString() string { + i := "" + o := "" + if l.isInner { + i = ", INNER" + } + if l.outer != nil { + o = ", o=" + l.outer.header.String() + } + return fmt.Sprintf("hdr:%s%s%s", l.header, i, o) +} + +func (l *loop) isWithinOrEq(ll *loop) bool { + if ll == nil { // nil means whole program + return true + } + for ; l != nil; l = l.outer { + if l == ll { + return true + } + } + return false +} + +// nearestOuterLoop returns the outer loop of loop most nearly +// containing block b; the header must dominate b. loop itself +// is assumed to not be that loop. For acceptable performance, +// we're relying on loop nests to not be terribly deep. +func (l *loop) nearestOuterLoop(sdom SparseTree, b *Block) *loop { + var o *loop + for o = l.outer; o != nil && !sdom.IsAncestorEq(o.header, b); o = o.outer { + } + return o +} + +func loopnestfor(f *Func) *loopnest { + po := f.postorder() + sdom := f.Sdom() + b2l := make([]*loop, f.NumBlocks()) + loops := make([]*loop, 0) + visited := f.Cache.allocBoolSlice(f.NumBlocks()) + defer f.Cache.freeBoolSlice(visited) + sawIrred := false + + if f.pass.debug > 2 { + fmt.Printf("loop finding in %s\n", f.Name) + } + + // Reducible-loop-nest-finding. + for _, b := range po { + if f.pass != nil && f.pass.debug > 3 { + fmt.Printf("loop finding at %s\n", b) + } + + var innermost *loop // innermost header reachable from this block + + // IF any successor s of b is in a loop headed by h + // AND h dominates b + // THEN b is in the loop headed by h. + // + // Choose the first/innermost such h. + // + // IF s itself dominates b, then s is a loop header; + // and there may be more than one such s. + // Since there's at most 2 successors, the inner/outer ordering + // between them can be established with simple comparisons. + for _, e := range b.Succs { + bb := e.b + l := b2l[bb.ID] + + if sdom.IsAncestorEq(bb, b) { // Found a loop header + if f.pass != nil && f.pass.debug > 4 { + fmt.Printf("loop finding succ %s of %s is header\n", bb.String(), b.String()) + } + if l == nil { + l = &loop{header: bb, isInner: true} + loops = append(loops, l) + b2l[bb.ID] = l + } + } else if !visited[bb.ID] { // Found an irreducible loop + sawIrred = true + if f.pass != nil && f.pass.debug > 4 { + fmt.Printf("loop finding succ %s of %s is IRRED, in %s\n", bb.String(), b.String(), f.Name) + } + } else if l != nil { + // TODO handle case where l is irreducible. + // Perhaps a loop header is inherited. + // is there any loop containing our successor whose + // header dominates b? + if !sdom.IsAncestorEq(l.header, b) { + l = l.nearestOuterLoop(sdom, b) + } + if f.pass != nil && f.pass.debug > 4 { + if l == nil { + fmt.Printf("loop finding succ %s of %s has no loop\n", bb.String(), b.String()) + } else { + fmt.Printf("loop finding succ %s of %s provides loop with header %s\n", bb.String(), b.String(), l.header.String()) + } + } + } else { // No loop + if f.pass != nil && f.pass.debug > 4 { + fmt.Printf("loop finding succ %s of %s has no loop\n", bb.String(), b.String()) + } + + } + + if l == nil || innermost == l { + continue + } + + if innermost == nil { + innermost = l + continue + } + + if sdom.isAncestor(innermost.header, l.header) { + sdom.outerinner(innermost, l) + innermost = l + } else if sdom.isAncestor(l.header, innermost.header) { + sdom.outerinner(l, innermost) + } + } + + if innermost != nil { + b2l[b.ID] = innermost + innermost.nBlocks++ + } + visited[b.ID] = true + } + + // Compute depths. + for _, l := range loops { + if l.depth != 0 { + // Already computed because it is an ancestor of + // a previous loop. + continue + } + // Find depth by walking up the loop tree. + d := int16(0) + for x := l; x != nil; x = x.outer { + if x.depth != 0 { + d += x.depth + break + } + d++ + } + // Set depth for every ancestor. + for x := l; x != nil; x = x.outer { + if x.depth != 0 { + break + } + x.depth = d + d-- + } + } + // Double-check depths. + for _, l := range loops { + want := int16(1) + if l.outer != nil { + want = l.outer.depth + 1 + } + if l.depth != want { + l.header.Fatalf("bad depth calculation for loop %s: got %d want %d", l.header, l.depth, want) + } + } + + ln := &loopnest{f: f, b2l: b2l, po: po, sdom: sdom, loops: loops, hasIrreducible: sawIrred} + + // Curious about the loopiness? "-d=ssa/likelyadjust/stats" + if f.pass != nil && f.pass.stats > 0 && len(loops) > 0 { + + // Note stats for non-innermost loops are slightly flawed because + // they don't account for inner loop exits that span multiple levels. + + for _, l := range loops { + inner := 0 + if l.isInner { + inner++ + } + + f.LogStat("loopstats in "+f.Name+":", + l.depth, "depth", + inner, "is_inner", l.nBlocks, "n_blocks") + } + } + + if f.pass != nil && f.pass.debug > 1 && len(loops) > 0 { + fmt.Printf("Loops in %s:\n", f.Name) + for _, l := range loops { + fmt.Printf("%s, b=", l.LongString()) + for _, b := range f.Blocks { + if b2l[b.ID] == l { + fmt.Printf(" %s", b) + } + } + fmt.Print("\n") + } + fmt.Printf("Nonloop blocks in %s:", f.Name) + for _, b := range f.Blocks { + if b2l[b.ID] == nil { + fmt.Printf(" %s", b) + } + } + fmt.Print("\n") + } + return ln +} + +// depth returns the loop nesting level of block b. +func (ln *loopnest) depth(b ID) int16 { + if l := ln.b2l[b]; l != nil { + return l.depth + } + return 0 +} diff --git a/go/src/cmd/compile/internal/ssa/location.go b/go/src/cmd/compile/internal/ssa/location.go new file mode 100644 index 0000000000000000000000000000000000000000..24c5633deae2b112aa2bab276ca87ef03008337d --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/location.go @@ -0,0 +1,102 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "fmt" +) + +// A place that an ssa variable can reside. +type Location interface { + String() string // name to use in assembly templates: AX, 16(SP), ... +} + +// A Register is a machine register, like AX. +// They are numbered densely from 0 (for each architecture). +type Register struct { + num int32 // dense numbering + objNum int16 // register number from cmd/internal/obj/$ARCH + name string +} + +func (r *Register) String() string { + return r.name +} + +// ObjNum returns the register number from cmd/internal/obj/$ARCH that +// corresponds to this register. +func (r *Register) ObjNum() int16 { + return r.objNum +} + +// A LocalSlot is a location in the stack frame, which identifies and stores +// part or all of a PPARAM, PPARAMOUT, or PAUTO ONAME node. +// It can represent a whole variable, part of a larger stack slot, or part of a +// variable that has been decomposed into multiple stack slots. +// As an example, a string could have the following configurations: +// +// stack layout LocalSlots +// +// Optimizations are disabled. s is on the stack and represented in its entirety. +// [ ------- s string ---- ] { N: s, Type: string, Off: 0 } +// +// s was not decomposed, but the SSA operates on its parts individually, so +// there is a LocalSlot for each of its fields that points into the single stack slot. +// [ ------- s string ---- ] { N: s, Type: *uint8, Off: 0 }, {N: s, Type: int, Off: 8} +// +// s was decomposed. Each of its fields is in its own stack slot and has its own LocalSLot. +// [ ptr *uint8 ] [ len int] { N: ptr, Type: *uint8, Off: 0, SplitOf: parent, SplitOffset: 0}, +// { N: len, Type: int, Off: 0, SplitOf: parent, SplitOffset: 8} +// parent = &{N: s, Type: string} +type LocalSlot struct { + N *ir.Name // an ONAME *ir.Name representing a stack location. + Type *types.Type // type of slot + Off int64 // offset of slot in N + + SplitOf *LocalSlot // slot is a decomposition of SplitOf + SplitOffset int64 // .. at this offset. +} + +func (s LocalSlot) String() string { + if s.Off == 0 { + return fmt.Sprintf("%v[%v]", s.N, s.Type) + } + return fmt.Sprintf("%v+%d[%v]", s.N, s.Off, s.Type) +} + +type LocPair [2]Location + +func (t LocPair) String() string { + n0, n1 := "nil", "nil" + if t[0] != nil { + n0 = t[0].String() + } + if t[1] != nil { + n1 = t[1].String() + } + return fmt.Sprintf("<%s,%s>", n0, n1) +} + +type LocResults []Location + +func (t LocResults) String() string { + s := "" + a := "<" + for _, r := range t { + a += s + s = "," + a += r.String() + } + a += ">" + return a +} + +type Spill struct { + Type *types.Type + Offset int64 + Reg int16 +} diff --git a/go/src/cmd/compile/internal/ssa/loopbce.go b/go/src/cmd/compile/internal/ssa/loopbce.go new file mode 100644 index 0000000000000000000000000000000000000000..84811647cedcd1f31b581829028088084d2338e3 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/loopbce.go @@ -0,0 +1,472 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "fmt" +) + +type indVarFlags uint8 + +const ( + indVarMinExc indVarFlags = 1 << iota // minimum value is exclusive (default: inclusive) + indVarMaxInc // maximum value is inclusive (default: exclusive) + indVarCountDown // if set the iteration starts at max and count towards min (default: min towards max) +) + +type indVar struct { + ind *Value // induction variable + nxt *Value // the incremented variable + min *Value // minimum value, inclusive/exclusive depends on flags + max *Value // maximum value, inclusive/exclusive depends on flags + entry *Block // entry block in the loop. + flags indVarFlags + // Invariant: for all blocks strictly dominated by entry: + // min <= ind < max [if flags == 0] + // min < ind < max [if flags == indVarMinExc] + // min <= ind <= max [if flags == indVarMaxInc] + // min < ind <= max [if flags == indVarMinExc|indVarMaxInc] +} + +// parseIndVar checks whether the SSA value passed as argument is a valid induction +// variable, and, if so, extracts: +// - the minimum bound +// - the increment value +// - the "next" value (SSA value that is Phi'd into the induction variable every loop) +// - the header's edge returning from the body +// +// Currently, we detect induction variables that match (Phi min nxt), +// with nxt being (Add inc ind). +// If it can't parse the induction variable correctly, it returns (nil, nil, nil). +func parseIndVar(ind *Value) (min, inc, nxt *Value, loopReturn Edge) { + if ind.Op != OpPhi { + return + } + + if n := ind.Args[0]; (n.Op == OpAdd64 || n.Op == OpAdd32 || n.Op == OpAdd16 || n.Op == OpAdd8) && (n.Args[0] == ind || n.Args[1] == ind) { + min, nxt, loopReturn = ind.Args[1], n, ind.Block.Preds[0] + } else if n := ind.Args[1]; (n.Op == OpAdd64 || n.Op == OpAdd32 || n.Op == OpAdd16 || n.Op == OpAdd8) && (n.Args[0] == ind || n.Args[1] == ind) { + min, nxt, loopReturn = ind.Args[0], n, ind.Block.Preds[1] + } else { + // Not a recognized induction variable. + return + } + + if nxt.Args[0] == ind { // nxt = ind + inc + inc = nxt.Args[1] + } else if nxt.Args[1] == ind { // nxt = inc + ind + inc = nxt.Args[0] + } else { + panic("unreachable") // one of the cases must be true from the above. + } + + return +} + +// findIndVar finds induction variables in a function. +// +// Look for variables and blocks that satisfy the following +// +// loop: +// ind = (Phi min nxt), +// if ind < max +// then goto enter_loop +// else goto exit_loop +// +// enter_loop: +// do something +// nxt = inc + ind +// goto loop +// +// exit_loop: +func findIndVar(f *Func) []indVar { + var iv []indVar + sdom := f.Sdom() + + for _, b := range f.Blocks { + if b.Kind != BlockIf || len(b.Preds) != 2 { + continue + } + + var ind *Value // induction variable + var init *Value // starting value + var limit *Value // ending value + + // Check that the control if it either ind = 0; i-- + init, inc, nxt, loopReturn = parseIndVar(limit) + if init == nil { + // No recognized induction variable on either operand + continue + } + + // Ok, the arguments were reversed. Swap them, and remember that we're + // looking at an ind >/>= loop (so the induction must be decrementing). + ind, limit = limit, ind + less = false + } + + if ind.Block != b { + // TODO: Could be extended to include disjointed loop headers. + // I don't think this is causing missed optimizations in real world code often. + // See https://go.dev/issue/63955 + continue + } + + // Expect the increment to be a nonzero constant. + if !inc.isGenericIntConst() { + continue + } + step := inc.AuxInt + if step == 0 { + continue + } + // step == minInt64 cannot be safely negated below, because -step + // overflows back to minInt64. The later underflow checks need a + // positive magnitude, so reject this case here. + if step == minSignedValue(ind.Type) { + continue + } + + // startBody is the edge that eventually returns to the loop header. + var startBody Edge + switch { + case sdom.IsAncestorEq(b.Succs[0].b, loopReturn.b): + startBody = b.Succs[0] + case sdom.IsAncestorEq(b.Succs[1].b, loopReturn.b): + // if x { goto exit } else { goto entry } is identical to if !x { goto entry } else { goto exit } + startBody = b.Succs[1] + less = !less + inclusive = !inclusive + default: + continue + } + + // Increment sign must match comparison direction. + // When incrementing, the termination comparison must be ind />= limit. + // See issue 26116. + if step > 0 && !less { + continue + } + if step < 0 && less { + continue + } + + // Up to now we extracted the induction variable (ind), + // the increment delta (inc), the temporary sum (nxt), + // the initial value (init) and the limiting value (limit). + // + // We also know that ind has the form (Phi init nxt) where + // nxt is (Add inc nxt) which means: 1) inc dominates nxt + // and 2) there is a loop starting at inc and containing nxt. + // + // We need to prove that the induction variable is incremented + // only when it's smaller than the limiting value. + // Two conditions must happen listed below to accept ind + // as an induction variable. + + // First condition: loop entry has a single predecessor, which + // is the header block. This implies that b.Succs[0] is + // reached iff ind < limit. + if len(startBody.b.Preds) != 1 { + // the other successor must exit the loop. + continue + } + + // Second condition: startBody.b dominates nxt so that + // nxt is computed when inc < limit. + if !sdom.IsAncestorEq(startBody.b, nxt.Block) { + // inc+ind can only be reached through the branch that enters the loop. + continue + } + + // Check for overflow/underflow. We need to make sure that inc never causes + // the induction variable to wrap around. + // We use a function wrapper here for easy return true / return false / keep going logic. + // This function returns true if the increment will never overflow/underflow. + ok := func() bool { + if step > 0 { + if limit.isGenericIntConst() { + // Figure out the actual largest value. + v := limit.AuxInt + if !inclusive { + if v == minSignedValue(limit.Type) { + return false // < minint is never satisfiable. + } + v-- + } + if init.isGenericIntConst() { + // Use stride to compute a better lower limit. + if init.AuxInt > v { + return false + } + // TODO(1.27): investigate passing a smaller-magnitude overflow limit to addU + // for addWillOverflow. + v = addU(init.AuxInt, diff(v, init.AuxInt)/uint64(step)*uint64(step)) + } + if addWillOverflow(v, step, maxSignedValue(ind.Type)) { + return false + } + if inclusive && v != limit.AuxInt || !inclusive && v+1 != limit.AuxInt { + // We know a better limit than the programmer did. Use our limit instead. + limit = f.constVal(limit.Op, limit.Type, v, true) + inclusive = true + } + return true + } + if step == 1 && !inclusive { + // Can't overflow because maxint is never a possible value. + return true + } + // If the limit is not a constant, check to see if it is a + // negative offset from a known non-negative value. + knn, k := findKNN(limit) + if knn == nil || k < 0 { + return false + } + // limit == (something nonnegative) - k. That subtraction can't underflow, so + // we can trust it. + if inclusive { + // ind <= knn - k cannot overflow if step is at most k + return step <= k + } + // ind < knn - k cannot overflow if step is at most k+1 + return step <= k+1 && k != maxSignedValue(limit.Type) + } else { // step < 0 + if limit.isGenericIntConst() { + // Figure out the actual smallest value. + v := limit.AuxInt + if !inclusive { + if v == maxSignedValue(limit.Type) { + return false // > maxint is never satisfiable. + } + v++ + } + if init.isGenericIntConst() { + // Use stride to compute a better lower limit. + if init.AuxInt < v { + return false + } + // TODO(1.27): investigate passing a smaller-magnitude underflow limit to subU + // for subWillUnderflow. + v = subU(init.AuxInt, diff(init.AuxInt, v)/uint64(-step)*uint64(-step)) + } + if subWillUnderflow(v, -step, minSignedValue(ind.Type)) { + return false + } + if inclusive && v != limit.AuxInt || !inclusive && v-1 != limit.AuxInt { + // We know a better limit than the programmer did. Use our limit instead. + limit = f.constVal(limit.Op, limit.Type, v, true) + inclusive = true + } + return true + } + if step == -1 && !inclusive { + // Can't underflow because minint is never a possible value. + return true + } + } + return false + + } + + if ok() { + flags := indVarFlags(0) + var min, max *Value + if step > 0 { + min = init + max = limit + if inclusive { + flags |= indVarMaxInc + } + } else { + min = limit + max = init + flags |= indVarMaxInc + if !inclusive { + flags |= indVarMinExc + } + flags |= indVarCountDown + step = -step + } + if f.pass.debug >= 1 { + printIndVar(b, ind, min, max, step, flags) + } + + iv = append(iv, indVar{ + ind: ind, + nxt: nxt, + min: min, + max: max, + entry: startBody.b, + flags: flags, + }) + b.Logf("found induction variable %v (inc = %v, min = %v, max = %v)\n", ind, inc, min, max) + } + + // TODO: other unrolling idioms + // for i := 0; i < KNN - KNN % k ; i += k + // for i := 0; i < KNN&^(k-1) ; i += k // k a power of 2 + // for i := 0; i < KNN&(-k) ; i += k // k a power of 2 + } + + return iv +} + +// subWillUnderflow checks if x - y underflows the min value. +// y must be positive. +func subWillUnderflow(x, y int64, min int64) bool { + if y < 0 { + base.Fatalf("expecting positive value") + } + return x < min+y +} + +// addWillOverflow checks if x + y overflows the max value. +// y must be positive. +func addWillOverflow(x, y int64, max int64) bool { + if y < 0 { + base.Fatalf("expecting positive value") + } + return x > max-y +} + +// diff returns x-y as a uint64. Requires x>=y. +func diff(x, y int64) uint64 { + if x < y { + base.Fatalf("diff %d - %d underflowed", x, y) + } + return uint64(x - y) +} + +// addU returns x+y. Requires that x+y does not overflow an int64. +func addU(x int64, y uint64) int64 { + if y >= 1<<63 { + if x >= 0 { + base.Fatalf("addU overflowed %d + %d", x, y) + } + x += 1<<63 - 1 + x += 1 + y -= 1 << 63 + } + // TODO(1.27): investigate passing a smaller-magnitude overflow limit in here. + if addWillOverflow(x, int64(y), maxSignedValue(types.Types[types.TINT64])) { + base.Fatalf("addU overflowed %d + %d", x, y) + } + return x + int64(y) +} + +// subU returns x-y. Requires that x-y does not underflow an int64. +func subU(x int64, y uint64) int64 { + if y >= 1<<63 { + if x < 0 { + base.Fatalf("subU underflowed %d - %d", x, y) + } + x -= 1<<63 - 1 + x -= 1 + y -= 1 << 63 + } + // TODO(1.27): investigate passing a smaller-magnitude underflow limit in here. + if subWillUnderflow(x, int64(y), minSignedValue(types.Types[types.TINT64])) { + base.Fatalf("subU underflowed %d - %d", x, y) + } + return x - int64(y) +} + +// if v is known to be x - c, where x is known to be nonnegative and c is a +// constant, return x, c. Otherwise return nil, 0. +func findKNN(v *Value) (*Value, int64) { + var x, y *Value + x = v + switch v.Op { + case OpSub64, OpSub32, OpSub16, OpSub8: + x = v.Args[0] + y = v.Args[1] + + case OpAdd64, OpAdd32, OpAdd16, OpAdd8: + x = v.Args[0] + y = v.Args[1] + if x.isGenericIntConst() { + x, y = y, x + } + } + switch x.Op { + case OpSliceLen, OpStringLen, OpSliceCap: + default: + return nil, 0 + } + if y == nil { + return x, 0 + } + if !y.isGenericIntConst() { + return nil, 0 + } + if v.Op == OpAdd64 || v.Op == OpAdd32 || v.Op == OpAdd16 || v.Op == OpAdd8 { + return x, -y.AuxInt + } + return x, y.AuxInt +} + +func printIndVar(b *Block, i, min, max *Value, inc int64, flags indVarFlags) { + mb1, mb2 := "[", "]" + if flags&indVarMinExc != 0 { + mb1 = "(" + } + if flags&indVarMaxInc == 0 { + mb2 = ")" + } + + mlim1, mlim2 := fmt.Sprint(min.AuxInt), fmt.Sprint(max.AuxInt) + if !min.isGenericIntConst() { + if b.Func.pass.debug >= 2 { + mlim1 = fmt.Sprint(min) + } else { + mlim1 = "?" + } + } + if !max.isGenericIntConst() { + if b.Func.pass.debug >= 2 { + mlim2 = fmt.Sprint(max) + } else { + mlim2 = "?" + } + } + extra := "" + if b.Func.pass.debug >= 2 { + extra = fmt.Sprintf(" (%s)", i) + } + b.Func.Warnl(b.Pos, "Induction variable: limits %v%v,%v%v, increment %d%s", mb1, mlim1, mlim2, mb2, inc, extra) +} + +func minSignedValue(t *types.Type) int64 { + return -1 << (t.Size()*8 - 1) +} + +func maxSignedValue(t *types.Type) int64 { + return 1<<((t.Size()*8)-1) - 1 +} diff --git a/go/src/cmd/compile/internal/ssa/loopreschedchecks.go b/go/src/cmd/compile/internal/ssa/loopreschedchecks.go new file mode 100644 index 0000000000000000000000000000000000000000..125c468217dbf45bba4f85633205f0fd094919dc --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/loopreschedchecks.go @@ -0,0 +1,512 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "fmt" +) + +// an edgeMem records a backedge, together with the memory +// phi functions at the target of the backedge that must +// be updated when a rescheduling check replaces the backedge. +type edgeMem struct { + e Edge + m *Value // phi for memory at dest of e +} + +// a rewriteTarget is a value-argindex pair indicating +// where a rewrite is applied. Note that this is for values, +// not for block controls, because block controls are not targets +// for the rewrites performed in inserting rescheduling checks. +type rewriteTarget struct { + v *Value + i int +} + +type rewrite struct { + before, after *Value // before is the expected value before rewrite, after is the new value installed. + rewrites []rewriteTarget // all the targets for this rewrite. +} + +func (r *rewrite) String() string { + s := "\n\tbefore=" + r.before.String() + ", after=" + r.after.String() + for _, rw := range r.rewrites { + s += ", (i=" + fmt.Sprint(rw.i) + ", v=" + rw.v.LongString() + ")" + } + s += "\n" + return s +} + +// insertLoopReschedChecks inserts rescheduling checks on loop backedges. +func insertLoopReschedChecks(f *Func) { + // TODO: when split information is recorded in export data, insert checks only on backedges that can be reached on a split-call-free path. + + // Loop reschedule checks compare the stack pointer with + // the per-g stack bound. If the pointer appears invalid, + // that means a reschedule check is needed. + // + // Steps: + // 1. locate backedges. + // 2. Record memory definitions at block end so that + // the SSA graph for mem can be properly modified. + // 3. Ensure that phi functions that will-be-needed for mem + // are present in the graph, initially with trivial inputs. + // 4. Record all to-be-modified uses of mem; + // apply modifications (split into two steps to simplify and + // avoided nagging order-dependencies). + // 5. Rewrite backedges to include reschedule check, + // and modify destination phi function appropriately with new + // definitions for mem. + + if f.NoSplit { // nosplit functions don't reschedule. + return + } + + backedges := backedges(f) + if len(backedges) == 0 { // no backedges means no rescheduling checks. + return + } + + lastMems := findLastMems(f) + defer f.Cache.freeValueSlice(lastMems) + + idom := f.Idom() + po := f.postorder() + // The ordering in the dominator tree matters; it's important that + // the walk of the dominator tree also be a preorder (i.e., a node is + // visited only after all its non-backedge predecessors have been visited). + sdom := newSparseOrderedTree(f, idom, po) + + if f.pass.debug > 1 { + fmt.Printf("before %s = %s\n", f.Name, sdom.treestructure(f.Entry)) + } + + tofixBackedges := []edgeMem{} + + for _, e := range backedges { // TODO: could filter here by calls in loops, if declared and inferred nosplit are recorded in export data. + tofixBackedges = append(tofixBackedges, edgeMem{e, nil}) + } + + // It's possible that there is no memory state (no global/pointer loads/stores or calls) + if lastMems[f.Entry.ID] == nil { + lastMems[f.Entry.ID] = f.Entry.NewValue0(f.Entry.Pos, OpInitMem, types.TypeMem) + } + + memDefsAtBlockEnds := f.Cache.allocValueSlice(f.NumBlocks()) // For each block, the mem def seen at its bottom. Could be from earlier block. + defer f.Cache.freeValueSlice(memDefsAtBlockEnds) + + // Propagate last mem definitions forward through successor blocks. + for i := len(po) - 1; i >= 0; i-- { + b := po[i] + mem := lastMems[b.ID] + for j := 0; mem == nil; j++ { // if there's no def, then there's no phi, so the visible mem is identical in all predecessors. + // loop because there might be backedges that haven't been visited yet. + mem = memDefsAtBlockEnds[b.Preds[j].b.ID] + } + memDefsAtBlockEnds[b.ID] = mem + if f.pass.debug > 2 { + fmt.Printf("memDefsAtBlockEnds[%s] = %s\n", b, mem) + } + } + + // Maps from block to newly-inserted phi function in block. + newmemphis := make(map[*Block]rewrite) + + // Insert phi functions as necessary for future changes to flow graph. + for i, emc := range tofixBackedges { + e := emc.e + h := e.b + + // find the phi function for the memory input at "h", if there is one. + var headerMemPhi *Value // look for header mem phi + + for _, v := range h.Values { + if v.Op == OpPhi && v.Type.IsMemory() { + headerMemPhi = v + } + } + + if headerMemPhi == nil { + // if the header is nil, make a trivial phi from the dominator + mem0 := memDefsAtBlockEnds[idom[h.ID].ID] + headerMemPhi = newPhiFor(h, mem0) + newmemphis[h] = rewrite{before: mem0, after: headerMemPhi} + addDFphis(mem0, h, h, f, memDefsAtBlockEnds, newmemphis, sdom) + + } + tofixBackedges[i].m = headerMemPhi + + } + if f.pass.debug > 0 { + for b, r := range newmemphis { + fmt.Printf("before b=%s, rewrite=%s\n", b, r.String()) + } + } + + // dfPhiTargets notes inputs to phis in dominance frontiers that should not + // be rewritten as part of the dominated children of some outer rewrite. + dfPhiTargets := make(map[rewriteTarget]bool) + + rewriteNewPhis(f.Entry, f.Entry, f, memDefsAtBlockEnds, newmemphis, dfPhiTargets, sdom) + + if f.pass.debug > 0 { + for b, r := range newmemphis { + fmt.Printf("after b=%s, rewrite=%s\n", b, r.String()) + } + } + + // Apply collected rewrites. + for _, r := range newmemphis { + for _, rw := range r.rewrites { + rw.v.SetArg(rw.i, r.after) + } + } + + // Rewrite backedges to include reschedule checks. + for _, emc := range tofixBackedges { + e := emc.e + headerMemPhi := emc.m + h := e.b + i := e.i + p := h.Preds[i] + bb := p.b + mem0 := headerMemPhi.Args[i] + // bb e->p h, + // Because we're going to insert a rare-call, make sure the + // looping edge still looks likely. + likely := BranchLikely + if p.i != 0 { + likely = BranchUnlikely + } + if bb.Kind != BlockPlain { // backedges can be unconditional. e.g., if x { something; continue } + bb.Likely = likely + } + + // rewrite edge to include reschedule check + // existing edges: + // + // bb.Succs[p.i] == Edge{h, i} + // h.Preds[i] == p == Edge{bb,p.i} + // + // new block(s): + // test: + // if sp < g.limit { goto sched } + // goto join + // sched: + // mem1 := call resched (mem0) + // goto join + // join: + // mem2 := phi(mem0, mem1) + // goto h + // + // and correct arg i of headerMemPhi and headerCtrPhi + // + // EXCEPT: join block containing only phi functions is bad + // for the register allocator. Therefore, there is no + // join, and branches targeting join must instead target + // the header, and the other phi functions within header are + // adjusted for the additional input. + + test := f.NewBlock(BlockIf) + sched := f.NewBlock(BlockPlain) + + test.Pos = bb.Pos + sched.Pos = bb.Pos + + // if sp < g.limit { goto sched } + // goto header + + cfgtypes := &f.Config.Types + pt := cfgtypes.Uintptr + g := test.NewValue1(bb.Pos, OpGetG, pt, mem0) + sp := test.NewValue0(bb.Pos, OpSP, pt) + cmpOp := OpLess64U + if pt.Size() == 4 { + cmpOp = OpLess32U + } + limaddr := test.NewValue1I(bb.Pos, OpOffPtr, pt, 2*pt.Size(), g) + lim := test.NewValue2(bb.Pos, OpLoad, pt, limaddr, mem0) + cmp := test.NewValue2(bb.Pos, cmpOp, cfgtypes.Bool, sp, lim) + test.SetControl(cmp) + + // if true, goto sched + test.AddEdgeTo(sched) + + // if false, rewrite edge to header. + // do NOT remove+add, because that will perturb all the other phi functions + // as well as messing up other edges to the header. + test.Succs = append(test.Succs, Edge{h, i}) + h.Preds[i] = Edge{test, 1} + headerMemPhi.SetArg(i, mem0) + + test.Likely = BranchUnlikely + + // sched: + // mem1 := call resched (mem0) + // goto header + resched := f.fe.Syslook("goschedguarded") + call := sched.NewValue1A(bb.Pos, OpStaticCall, types.TypeResultMem, StaticAuxCall(resched, bb.Func.ABIDefault.ABIAnalyzeTypes(nil, nil)), mem0) + mem1 := sched.NewValue1I(bb.Pos, OpSelectN, types.TypeMem, 0, call) + sched.AddEdgeTo(h) + headerMemPhi.AddArg(mem1) + + bb.Succs[p.i] = Edge{test, 0} + test.Preds = append(test.Preds, Edge{bb, p.i}) + + // Must correct all the other phi functions in the header for new incoming edge. + // Except for mem phis, it will be the same value seen on the original + // backedge at index i. + for _, v := range h.Values { + if v.Op == OpPhi && v != headerMemPhi { + v.AddArg(v.Args[i]) + } + } + } + + f.invalidateCFG() + + if f.pass.debug > 1 { + sdom = newSparseTree(f, f.Idom()) + fmt.Printf("after %s = %s\n", f.Name, sdom.treestructure(f.Entry)) + } +} + +// newPhiFor inserts a new Phi function into b, +// with all inputs set to v. +func newPhiFor(b *Block, v *Value) *Value { + phiV := b.NewValue0(b.Pos, OpPhi, v.Type) + + for range b.Preds { + phiV.AddArg(v) + } + return phiV +} + +// rewriteNewPhis updates newphis[h] to record all places where the new phi function inserted +// in block h will replace a previous definition. Block b is the block currently being processed; +// if b has its own phi definition then it takes the place of h. +// defsForUses provides information about other definitions of the variable that are present +// (and if nil, indicates that the variable is no longer live) +// sdom must yield a preorder of the flow graph if recursively walked, root-to-children. +// The result of newSparseOrderedTree with order supplied by a dfs-postorder satisfies this +// requirement. +func rewriteNewPhis(h, b *Block, f *Func, defsForUses []*Value, newphis map[*Block]rewrite, dfPhiTargets map[rewriteTarget]bool, sdom SparseTree) { + // If b is a block with a new phi, then a new rewrite applies below it in the dominator tree. + if _, ok := newphis[b]; ok { + h = b + } + change := newphis[h] + x := change.before + y := change.after + + // Apply rewrites to this block + if x != nil { // don't waste time on the common case of no definition. + p := &change.rewrites + for _, v := range b.Values { + if v == y { // don't rewrite self -- phi inputs are handled below. + continue + } + for i, w := range v.Args { + if w != x { + continue + } + tgt := rewriteTarget{v, i} + + // It's possible dominated control flow will rewrite this instead. + // Visiting in preorder (a property of how sdom was constructed) + // ensures that these are seen in the proper order. + if dfPhiTargets[tgt] { + continue + } + *p = append(*p, tgt) + if f.pass.debug > 1 { + fmt.Printf("added block target for h=%v, b=%v, x=%v, y=%v, tgt.v=%s, tgt.i=%d\n", + h, b, x, y, v, i) + } + } + } + + // Rewrite appropriate inputs of phis reached in successors + // in dominance frontier, self, and dominated. + // If the variable def reaching uses in b is itself defined in b, then the new phi function + // does not reach the successors of b. (This assumes a bit about the structure of the + // phi use-def graph, but it's true for memory.) + if dfu := defsForUses[b.ID]; dfu != nil && dfu.Block != b { + for _, e := range b.Succs { + s := e.b + + for _, v := range s.Values { + if v.Op == OpPhi && v.Args[e.i] == x { + tgt := rewriteTarget{v, e.i} + *p = append(*p, tgt) + dfPhiTargets[tgt] = true + if f.pass.debug > 1 { + fmt.Printf("added phi target for h=%v, b=%v, s=%v, x=%v, y=%v, tgt.v=%s, tgt.i=%d\n", + h, b, s, x, y, v.LongString(), e.i) + } + break + } + } + } + } + newphis[h] = change + } + + for c := sdom[b.ID].child; c != nil; c = sdom[c.ID].sibling { + rewriteNewPhis(h, c, f, defsForUses, newphis, dfPhiTargets, sdom) // TODO: convert to explicit stack from recursion. + } +} + +// addDFphis creates new trivial phis that are necessary to correctly reflect (within SSA) +// a new definition for variable "x" inserted at h (usually but not necessarily a phi). +// These new phis can only occur at the dominance frontier of h; block s is in the dominance +// frontier of h if h does not strictly dominate s and if s is a successor of a block b where +// either b = h or h strictly dominates b. +// These newly created phis are themselves new definitions that may require addition of their +// own trivial phi functions in their own dominance frontier, and this is handled recursively. +func addDFphis(x *Value, h, b *Block, f *Func, defForUses []*Value, newphis map[*Block]rewrite, sdom SparseTree) { + oldv := defForUses[b.ID] + if oldv != x { // either a new definition replacing x, or nil if it is proven that there are no uses reachable from b + return + } + idom := f.Idom() +outer: + for _, e := range b.Succs { + s := e.b + // check phi functions in the dominance frontier + if sdom.isAncestor(h, s) { + continue // h dominates s, successor of b, therefore s is not in the frontier. + } + if _, ok := newphis[s]; ok { + continue // successor s of b already has a new phi function, so there is no need to add another. + } + if x != nil { + for _, v := range s.Values { + if v.Op == OpPhi && v.Args[e.i] == x { + continue outer // successor s of b has an old phi function, so there is no need to add another. + } + } + } + + old := defForUses[idom[s.ID].ID] // new phi function is correct-but-redundant, combining value "old" on all inputs. + headerPhi := newPhiFor(s, old) + // the new phi will replace "old" in block s and all blocks dominated by s. + newphis[s] = rewrite{before: old, after: headerPhi} // record new phi, to have inputs labeled "old" rewritten to "headerPhi" + addDFphis(old, s, s, f, defForUses, newphis, sdom) // the new definition may also create new phi functions. + } + for c := sdom[b.ID].child; c != nil; c = sdom[c.ID].sibling { + addDFphis(x, h, c, f, defForUses, newphis, sdom) // TODO: convert to explicit stack from recursion. + } +} + +// findLastMems maps block ids to last memory-output op in a block, if any. +func findLastMems(f *Func) []*Value { + + var stores []*Value + lastMems := f.Cache.allocValueSlice(f.NumBlocks()) + storeUse := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(storeUse) + for _, b := range f.Blocks { + // Find all the stores in this block. Categorize their uses: + // storeUse contains stores which are used by a subsequent store. + storeUse.clear() + stores = stores[:0] + var memPhi *Value + for _, v := range b.Values { + if v.Op == OpPhi { + if v.Type.IsMemory() { + memPhi = v + } + continue + } + if v.Type.IsMemory() { + stores = append(stores, v) + for _, a := range v.Args { + if a.Block == b && a.Type.IsMemory() { + storeUse.add(a.ID) + } + } + } + } + if len(stores) == 0 { + lastMems[b.ID] = memPhi + continue + } + + // find last store in the block + var last *Value + for _, v := range stores { + if storeUse.contains(v.ID) { + continue + } + if last != nil { + b.Fatalf("two final stores - simultaneous live stores %s %s", last, v) + } + last = v + } + if last == nil { + b.Fatalf("no last store found - cycle?") + } + + // If this is a tuple containing a mem, select just + // the mem. This will generate ops we don't need, but + // it's the easiest thing to do. + if last.Type.IsTuple() { + last = b.NewValue1(last.Pos, OpSelect1, types.TypeMem, last) + } else if last.Type.IsResults() { + last = b.NewValue1I(last.Pos, OpSelectN, types.TypeMem, int64(last.Type.NumFields()-1), last) + } + + lastMems[b.ID] = last + } + return lastMems +} + +// mark values +type markKind uint8 + +const ( + notFound markKind = iota // block has not been discovered yet + notExplored // discovered and in queue, outedges not processed yet + explored // discovered and in queue, outedges processed + done // all done, in output ordering +) + +type backedgesState struct { + b *Block + i int +} + +// backedges returns a slice of successor edges that are back +// edges. For reducible loops, edge.b is the header. +func backedges(f *Func) []Edge { + edges := []Edge{} + mark := make([]markKind, f.NumBlocks()) + stack := []backedgesState{} + + mark[f.Entry.ID] = notExplored + stack = append(stack, backedgesState{f.Entry, 0}) + + for len(stack) > 0 { + l := len(stack) + x := stack[l-1] + if x.i < len(x.b.Succs) { + e := x.b.Succs[x.i] + stack[l-1].i++ + s := e.b + if mark[s.ID] == notFound { + mark[s.ID] = notExplored + stack = append(stack, backedgesState{s, 0}) + } else if mark[s.ID] == notExplored { + edges = append(edges, e) + } + } else { + mark[x.b.ID] = done + stack = stack[0 : l-1] + } + } + return edges +} diff --git a/go/src/cmd/compile/internal/ssa/looprotate.go b/go/src/cmd/compile/internal/ssa/looprotate.go new file mode 100644 index 0000000000000000000000000000000000000000..e97321019bceb7543ac492ae8e9344ae56ec5774 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/looprotate.go @@ -0,0 +1,192 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "slices" +) + +// loopRotate converts loops with a check-loop-condition-at-beginning +// to loops with a check-loop-condition-at-end. +// This helps loops avoid extra unnecessary jumps. +// +// loop: +// CMPQ ... +// JGE exit +// ... +// JMP loop +// exit: +// +// JMP entry +// loop: +// ... +// entry: +// CMPQ ... +// JLT loop +func loopRotate(f *Func) { + loopnest := f.loopnest() + if loopnest.hasIrreducible { + return + } + if len(loopnest.loops) == 0 { + return + } + + idToIdx := f.Cache.allocIntSlice(f.NumBlocks()) + defer f.Cache.freeIntSlice(idToIdx) + for i, b := range f.Blocks { + idToIdx[b.ID] = i + } + + // Set of blocks we're moving, by ID. + move := map[ID]struct{}{} + + // Map from block ID to the moving blocks that should + // come right after it. + // If a block, which has its ID present in keys of the 'after' map, + // occurs in some other block's 'after' list, that represents whole + // nested loop, e.g. consider an inner loop I nested into an outer + // loop O. It and Ot are corresponding top block for these loops + // chosen by our algorithm, and It is in the Ot's 'after' list. + // + // Before: After: + // + // e e + // │ │ + // │ │Ot ◄───┐ + // ▼ ▼▼ │ + // ┌───Oh ◄────┐ ┌─┬─Oh │ + // │ │ │ │ │ │ + // │ │ │ │ │ It◄───┐ │ + // │ ▼ │ │ │ ▼ │ │ + // │ ┌─Ih◄───┐ │ │ └►Ih │ │ + // │ │ │ │ │ │ ┌─┤ │ │ + // │ │ ▼ │ │ │ │ ▼ │ │ + // │ │ Ib │ │ │ │ Ib │ │ + // │ │ └─►It─┘ │ │ │ └─────┘ │ + // │ │ │ │ │ │ + // │ └►Ie │ │ └►Ie │ + // │ └─►Ot───┘ │ └───────┘ + // │ │ + // └──►Oe └──►Oe + // + // We build the 'after' lists for each of the top blocks Ot and It: + // after[Ot]: Oh, It, Ie + // after[It]: Ih, Ib + after := map[ID][]*Block{} + + // Map from loop header ID to the new top block for the loop. + tops := map[ID]*Block{} + + // Order loops to rotate any child loop before adding its top block + // to the parent loop's 'after' list. + loopOrder := f.Cache.allocIntSlice(len(loopnest.loops)) + for i := range loopOrder { + loopOrder[i] = i + } + defer f.Cache.freeIntSlice(loopOrder) + slices.SortFunc(loopOrder, func(i, j int) int { + di := loopnest.loops[i].depth + dj := loopnest.loops[j].depth + switch { + case di > dj: + return -1 + case di < dj: + return 1 + default: + return 0 + } + }) + + // Check each loop header and decide if we want to move it. + for _, loopIdx := range loopOrder { + loop := loopnest.loops[loopIdx] + b := loop.header + var p *Block // b's in-loop predecessor + for _, e := range b.Preds { + if e.b.Kind != BlockPlain { + continue + } + if loopnest.b2l[e.b.ID] != loop { + continue + } + p = e.b + } + if p == nil { + continue + } + tops[loop.header.ID] = p + p.Hotness |= HotInitial + if f.IsPgoHot { + p.Hotness |= HotPgo + } + // blocks will be arranged so that p is ordered first, if it isn't already. + if p == b { // p is header, already first (and also, only block in the loop) + continue + } + p.Hotness |= HotNotFlowIn + + // the loop header b follows p + after[p.ID] = []*Block{b} + for { + nextIdx := idToIdx[b.ID] + 1 + if nextIdx >= len(f.Blocks) { // reached end of function (maybe impossible?) + break + } + nextb := f.Blocks[nextIdx] + if nextb == p { // original loop predecessor is next + break + } + if bloop := loopnest.b2l[nextb.ID]; bloop != nil { + if bloop == loop || bloop.outer == loop && tops[bloop.header.ID] == nextb { + after[p.ID] = append(after[p.ID], nextb) + } + } + b = nextb + } + // Swap b and p so that we'll handle p before b when moving blocks. + f.Blocks[idToIdx[loop.header.ID]] = p + f.Blocks[idToIdx[p.ID]] = loop.header + idToIdx[loop.header.ID], idToIdx[p.ID] = idToIdx[p.ID], idToIdx[loop.header.ID] + + // Place loop blocks after p. + for _, b := range after[p.ID] { + move[b.ID] = struct{}{} + } + } + + // Move blocks to their destinations in a single pass. + // We rely here on the fact that loop headers must come + // before the rest of the loop. And that relies on the + // fact that we only identify reducible loops. + j := 0 + // Some blocks that are not part of a loop may be placed + // between loop blocks. In order to avoid these blocks from + // being overwritten, use a temporary slice. + oldOrder := f.Cache.allocBlockSlice(len(f.Blocks)) + defer f.Cache.freeBlockSlice(oldOrder) + copy(oldOrder, f.Blocks) + var moveBlocks func(bs []*Block) + moveBlocks = func(blocks []*Block) { + for _, a := range blocks { + f.Blocks[j] = a + j++ + if nextBlocks, ok := after[a.ID]; ok { + moveBlocks(nextBlocks) + } + } + } + for _, b := range oldOrder { + if _, ok := move[b.ID]; ok { + continue + } + f.Blocks[j] = b + j++ + moveBlocks(after[b.ID]) + } + if j != len(oldOrder) { + f.Fatalf("bad reordering in looprotate") + } +} diff --git a/go/src/cmd/compile/internal/ssa/looprotate_test.go b/go/src/cmd/compile/internal/ssa/looprotate_test.go new file mode 100644 index 0000000000000000000000000000000000000000..8e7cfc343f5ec83a1e0725c5cfc22436bd7ceaac --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/looprotate_test.go @@ -0,0 +1,65 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "testing" +) + +func TestLoopRotateNested(t *testing.T) { + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("constTrue", OpConstBool, types.Types[types.TBOOL], 1, nil), + Goto("outerHeader")), + Bloc("outerHeader", + If("constTrue", "outerBody", "outerExit")), + Bloc("outerBody", + Goto("innerHeader")), + Bloc("innerHeader", + If("constTrue", "innerBody", "innerExit")), + Bloc("innerBody", + Goto("innerTop")), + Bloc("innerTop", + Goto("innerHeader")), + Bloc("innerExit", + Goto("outerTop")), + Bloc("outerTop", + Goto("outerHeader")), + Bloc("outerExit", + Exit("mem"))) + + blockName := make([]string, len(fun.f.Blocks)+1) + for name, block := range fun.blocks { + blockName[block.ID] = name + } + + CheckFunc(fun.f) + loopRotate(fun.f) + CheckFunc(fun.f) + + // Verify the resulting block order + expected := []string{ + "entry", + "outerTop", + "outerHeader", + "outerBody", + "innerTop", + "innerHeader", + "innerBody", + "innerExit", + "outerExit", + } + if len(expected) != len(fun.f.Blocks) { + t.Fatalf("expected %d blocks, found %d", len(expected), len(fun.f.Blocks)) + } + for i, b := range fun.f.Blocks { + if expected[i] != blockName[b.ID] { + t.Errorf("position %d: expected %s, found %s", i, expected[i], blockName[b.ID]) + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/lower.go b/go/src/cmd/compile/internal/ssa/lower.go new file mode 100644 index 0000000000000000000000000000000000000000..e4aac47cee116913163515c38e0c6e47b9832b3a --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/lower.go @@ -0,0 +1,52 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// convert to machine-dependent ops. +func lower(f *Func) { + // repeat rewrites until we find no more rewrites + applyRewrite(f, f.Config.lowerBlock, f.Config.lowerValue, removeDeadValues) +} + +// lateLower applies those rules that need to be run after the general lower rules. +func lateLower(f *Func) { + // repeat rewrites until we find no more rewrites + if f.Config.lateLowerValue != nil { + applyRewrite(f, f.Config.lateLowerBlock, f.Config.lateLowerValue, removeDeadValues) + } +} + +// checkLower checks for unlowered opcodes and fails if we find one. +func checkLower(f *Func) { + // Needs to be a separate phase because it must run after both + // lowering and a subsequent dead code elimination (because lowering + // rules may leave dead generic ops behind). + for _, b := range f.Blocks { + for _, v := range b.Values { + if !opcodeTable[v.Op].generic { + continue // lowered + } + switch v.Op { + case OpSP, OpSPanchored, OpSB, OpInitMem, OpArg, OpArgIntReg, OpArgFloatReg, OpPhi, OpVarDef, OpVarLive, OpKeepAlive, OpSelect0, OpSelect1, OpSelectN, OpConvert, OpInlMark, OpWBend: + continue // ok not to lower + case OpMakeResult: + if b.Controls[0] == v { + continue + } + case OpGetG: + if f.Config.hasGReg { + // has hardware g register, regalloc takes care of it + continue // ok not to lower + } + } + s := "not lowered: " + v.String() + ", " + v.Op.String() + " " + v.Type.SimpleString() + + for _, a := range v.Args { + s += " " + a.Type.SimpleString() + } + f.Fatalf("%s", s) + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/magic.go b/go/src/cmd/compile/internal/ssa/magic.go new file mode 100644 index 0000000000000000000000000000000000000000..29a57fb3cc3543218eddbcdfaec25e0f1a3d1c1c --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/magic.go @@ -0,0 +1,426 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "math/big" + "math/bits" +) + +// So you want to compute x / c for some constant c? +// Machine division instructions are slow, so we try to +// compute this division with a multiplication + a few +// other cheap instructions instead. +// (We assume here that c != 0, +/- 1, or +/- 2^i. Those +// cases are easy to handle in different ways). + +// Technique from https://gmplib.org/~tege/divcnst-pldi94.pdf + +// First consider unsigned division. +// Our strategy is to precompute 1/c then do +// ⎣x / c⎦ = ⎣x * (1/c)⎦. +// 1/c is less than 1, so we can't compute it directly in +// integer arithmetic. Let's instead compute 2^e/c +// for a value of e TBD (^ = exponentiation). Then +// ⎣x / c⎦ = ⎣x * (2^e/c) / 2^e⎦. +// Dividing by 2^e is easy. 2^e/c isn't an integer, unfortunately. +// So we must approximate it. Let's call its approximation m. +// We'll then compute +// ⎣x * m / 2^e⎦ +// Which we want to be equal to ⎣x / c⎦ for 0 <= x < 2^n-1 +// where n is the word size. +// Setting x = c gives us c * m >= 2^e. +// We'll chose m = ⎡2^e/c⎤ to satisfy that equation. +// What remains is to choose e. +// Let m = 2^e/c + delta, 0 <= delta < 1 +// ⎣x * (2^e/c + delta) / 2^e⎦ +// ⎣x / c + x * delta / 2^e⎦ +// We must have x * delta / 2^e < 1/c so that this +// additional term never rounds differently than ⎣x / c⎦ does. +// Rearranging, +// 2^e > x * delta * c +// x can be at most 2^n-1 and delta can be at most 1. +// So it is sufficient to have 2^e >= 2^n*c. +// So we'll choose e = n + s, with s = ⎡log2(c)⎤. +// +// An additional complication arises because m has n+1 bits in it. +// Hardware restricts us to n bit by n bit multiplies. +// We divide into 3 cases: +// +// Case 1: m is even. +// ⎣x / c⎦ = ⎣x * m / 2^(n+s)⎦ +// ⎣x / c⎦ = ⎣x * (m/2) / 2^(n+s-1)⎦ +// ⎣x / c⎦ = ⎣x * (m/2) / 2^n / 2^(s-1)⎦ +// ⎣x / c⎦ = ⎣⎣x * (m/2) / 2^n⎦ / 2^(s-1)⎦ +// multiply + shift +// +// Case 2: c is even. +// ⎣x / c⎦ = ⎣(x/2) / (c/2)⎦ +// ⎣x / c⎦ = ⎣⎣x/2⎦ / (c/2)⎦ +// This is just the original problem, with x' = ⎣x/2⎦, c' = c/2, n' = n-1. +// s' = s-1 +// m' = ⎡2^(n'+s')/c'⎤ +// = ⎡2^(n+s-1)/c⎤ +// = ⎡m/2⎤ +// ⎣x / c⎦ = ⎣x' * m' / 2^(n'+s')⎦ +// ⎣x / c⎦ = ⎣⎣x/2⎦ * ⎡m/2⎤ / 2^(n+s-2)⎦ +// ⎣x / c⎦ = ⎣⎣⎣x/2⎦ * ⎡m/2⎤ / 2^n⎦ / 2^(s-2)⎦ +// shift + multiply + shift +// +// Case 3: everything else +// let k = m - 2^n. k fits in n bits. +// ⎣x / c⎦ = ⎣x * m / 2^(n+s)⎦ +// ⎣x / c⎦ = ⎣x * (2^n + k) / 2^(n+s)⎦ +// ⎣x / c⎦ = ⎣(x + x * k / 2^n) / 2^s⎦ +// ⎣x / c⎦ = ⎣(x + ⎣x * k / 2^n⎦) / 2^s⎦ +// ⎣x / c⎦ = ⎣(x + ⎣x * k / 2^n⎦) / 2^s⎦ +// ⎣x / c⎦ = ⎣⎣(x + ⎣x * k / 2^n⎦) / 2⎦ / 2^(s-1)⎦ +// multiply + avg + shift +// +// These can be implemented in hardware using: +// ⎣a * b / 2^n⎦ - aka high n bits of an n-bit by n-bit multiply. +// ⎣(a+b) / 2⎦ - aka "average" of two n-bit numbers. +// (Not just a regular add & shift because the intermediate result +// a+b has n+1 bits in it. Nevertheless, can be done +// in 2 instructions on x86.) + +// umagicOK reports whether we should strength reduce a n-bit divide by c. +func umagicOK(n uint, c int64) bool { + // Convert from ConstX auxint values to the real uint64 constant they represent. + d := uint64(c) << (64 - n) >> (64 - n) + + // Doesn't work for 0. + // Don't use for powers of 2. + return d&(d-1) != 0 +} + +// umagicOKn reports whether we should strength reduce an unsigned n-bit divide by c. +// We can strength reduce when c != 0 and c is not a power of two. +func umagicOK8(c int8) bool { return c&(c-1) != 0 } +func umagicOK16(c int16) bool { return c&(c-1) != 0 } +func umagicOK32(c int32) bool { return c&(c-1) != 0 } +func umagicOK64(c int64) bool { return c&(c-1) != 0 } + +type umagicData struct { + s int64 // ⎡log2(c)⎤ + m uint64 // ⎡2^(n+s)/c⎤ - 2^n +} + +// umagic computes the constants needed to strength reduce unsigned n-bit divides by the constant uint64(c). +// The return values satisfy for all 0 <= x < 2^n +// +// floor(x / uint64(c)) = x * (m + 2^n) >> (n+s) +func umagic(n uint, c int64) umagicData { + // Convert from ConstX auxint values to the real uint64 constant they represent. + d := uint64(c) << (64 - n) >> (64 - n) + + C := new(big.Int).SetUint64(d) + s := C.BitLen() + M := big.NewInt(1) + M.Lsh(M, n+uint(s)) // 2^(n+s) + M.Add(M, C) // 2^(n+s)+c + M.Sub(M, big.NewInt(1)) // 2^(n+s)+c-1 + M.Div(M, C) // ⎡2^(n+s)/c⎤ + if M.Bit(int(n)) != 1 { + panic("n+1st bit isn't set") + } + M.SetBit(M, int(n), 0) + m := M.Uint64() + return umagicData{s: int64(s), m: m} +} + +func umagic8(c int8) umagicData { return umagic(8, int64(c)) } +func umagic16(c int16) umagicData { return umagic(16, int64(c)) } +func umagic32(c int32) umagicData { return umagic(32, int64(c)) } +func umagic64(c int64) umagicData { return umagic(64, c) } + +// For signed division, we use a similar strategy. +// First, we enforce a positive c. +// x / c = -(x / (-c)) +// This will require an additional Neg op for c<0. +// +// If x is positive we're in a very similar state +// to the unsigned case above. We define: +// s = ⎡log2(c)⎤-1 +// m = ⎡2^(n+s)/c⎤ +// Then +// ⎣x / c⎦ = ⎣x * m / 2^(n+s)⎦ +// If x is negative we have +// ⎡x / c⎤ = ⎣x * m / 2^(n+s)⎦ + 1 +// (TODO: derivation?) +// +// The multiply is a bit odd, as it is a signed n-bit value +// times an unsigned n-bit value. For n smaller than the +// word size, we can extend x and m appropriately and use the +// signed multiply instruction. For n == word size, +// we must use the signed multiply high and correct +// the result by adding x*2^n. +// +// Adding 1 if x<0 is done by subtracting x>>(n-1). + +func smagicOK(n uint, c int64) bool { + if c < 0 { + // Doesn't work for negative c. + return false + } + // Doesn't work for 0. + // Don't use it for powers of 2. + return c&(c-1) != 0 +} + +// smagicOKn reports whether we should strength reduce a signed n-bit divide by c. +func smagicOK8(c int8) bool { return smagicOK(8, int64(c)) } +func smagicOK16(c int16) bool { return smagicOK(16, int64(c)) } +func smagicOK32(c int32) bool { return smagicOK(32, int64(c)) } +func smagicOK64(c int64) bool { return smagicOK(64, c) } + +type smagicData struct { + s int64 // ⎡log2(c)⎤-1 + m uint64 // ⎡2^(n+s)/c⎤ +} + +// smagic computes the constants needed to strength reduce signed n-bit divides by the constant c. +// Must have c>0. +// The return values satisfy for all -2^(n-1) <= x < 2^(n-1) +// +// trunc(x / c) = x * m >> (n+s) + (x < 0 ? 1 : 0) +func smagic(n uint, c int64) smagicData { + C := new(big.Int).SetInt64(c) + s := C.BitLen() - 1 + M := big.NewInt(1) + M.Lsh(M, n+uint(s)) // 2^(n+s) + M.Add(M, C) // 2^(n+s)+c + M.Sub(M, big.NewInt(1)) // 2^(n+s)+c-1 + M.Div(M, C) // ⎡2^(n+s)/c⎤ + if M.Bit(int(n)) != 0 { + panic("n+1st bit is set") + } + if M.Bit(int(n-1)) == 0 { + panic("nth bit is not set") + } + m := M.Uint64() + return smagicData{s: int64(s), m: m} +} + +func smagic8(c int8) smagicData { return smagic(8, int64(c)) } +func smagic16(c int16) smagicData { return smagic(16, int64(c)) } +func smagic32(c int32) smagicData { return smagic(32, int64(c)) } +func smagic64(c int64) smagicData { return smagic(64, c) } + +// Divisibility x%c == 0 can be checked more efficiently than directly computing +// the modulus x%c and comparing against 0. +// +// The same "Division by invariant integers using multiplication" paper +// by Granlund and Montgomery referenced above briefly mentions this method +// and it is further elaborated in "Hacker's Delight" by Warren Section 10-17 +// +// The first thing to note is that for odd integers, exact division can be computed +// by using the modular inverse with respect to the word size 2^n. +// +// Given c, compute m such that (c * m) mod 2^n == 1 +// Then if c divides x (x%c ==0), the quotient is given by q = x/c == x*m mod 2^n +// +// x can range from 0, c, 2c, 3c, ... ⎣(2^n - 1)/c⎦ * c the maximum multiple +// Thus, x*m mod 2^n is 0, 1, 2, 3, ... ⎣(2^n - 1)/c⎦ +// i.e. the quotient takes all values from zero up to max = ⎣(2^n - 1)/c⎦ +// +// If x is not divisible by c, then x*m mod 2^n must take some larger value than max. +// +// This gives x*m mod 2^n <= ⎣(2^n - 1)/c⎦ as a test for divisibility +// involving one multiplication and compare. +// +// To extend this to even integers, consider c = d0 * 2^k where d0 is odd. +// We can test whether x is divisible by both d0 and 2^k. +// For d0, the test is the same as above. Let m be such that m*d0 mod 2^n == 1 +// Then x*m mod 2^n <= ⎣(2^n - 1)/d0⎦ is the first test. +// The test for divisibility by 2^k is a check for k trailing zeroes. +// Note that since d0 is odd, m is odd and thus x*m will have the same number of +// trailing zeroes as x. So the two tests are, +// +// x*m mod 2^n <= ⎣(2^n - 1)/d0⎦ +// and x*m ends in k zero bits +// +// These can be combined into a single comparison by the following +// (theorem ZRU in Hacker's Delight) for unsigned integers. +// +// x <= a and x ends in k zero bits if and only if RotRight(x ,k) <= ⎣a/(2^k)⎦ +// Where RotRight(x ,k) is right rotation of x by k bits. +// +// To prove the first direction, x <= a -> ⎣x/(2^k)⎦ <= ⎣a/(2^k)⎦ +// But since x ends in k zeroes all the rotated bits would be zero too. +// So RotRight(x, k) == ⎣x/(2^k)⎦ <= ⎣a/(2^k)⎦ +// +// If x does not end in k zero bits, then RotRight(x, k) +// has some non-zero bits in the k highest bits. +// ⎣x/(2^k)⎦ has all zeroes in the k highest bits, +// so RotRight(x, k) > ⎣x/(2^k)⎦ +// +// Finally, if x > a and has k trailing zero bits, then RotRight(x, k) == ⎣x/(2^k)⎦ +// and ⎣x/(2^k)⎦ must be greater than ⎣a/(2^k)⎦, that is the top n-k bits of x must +// be greater than the top n-k bits of a because the rest of x bits are zero. +// +// So the two conditions about can be replaced with the single test +// +// RotRight(x*m mod 2^n, k) <= ⎣(2^n - 1)/c⎦ +// +// Where d0*2^k was replaced by c on the right hand side. + +// udivisibleOK reports whether we should strength reduce an unsigned n-bit divisibility check by c. +func udivisibleOK(n uint, c int64) bool { + // Convert from ConstX auxint values to the real uint64 constant they represent. + d := uint64(c) << (64 - n) >> (64 - n) + + // Doesn't work for 0. + // Don't use for powers of 2. + return d&(d-1) != 0 +} + +func udivisibleOK8(c int8) bool { return udivisibleOK(8, int64(c)) } +func udivisibleOK16(c int16) bool { return udivisibleOK(16, int64(c)) } +func udivisibleOK32(c int32) bool { return udivisibleOK(32, int64(c)) } +func udivisibleOK64(c int64) bool { return udivisibleOK(64, c) } + +type udivisibleData struct { + k int64 // trailingZeros(c) + m uint64 // m * (c>>k) mod 2^n == 1 multiplicative inverse of odd portion modulo 2^n + max uint64 // ⎣(2^n - 1)/ c⎦ max value to for divisibility +} + +func udivisible(n uint, c int64) udivisibleData { + // Convert from ConstX auxint values to the real uint64 constant they represent. + d := uint64(c) << (64 - n) >> (64 - n) + + k := bits.TrailingZeros64(d) + d0 := d >> uint(k) // the odd portion of the divisor + + mask := ^uint64(0) >> (64 - n) + + // Calculate the multiplicative inverse via Newton's method. + // Quadratic convergence doubles the number of correct bits per iteration. + m := d0 // initial guess correct to 3-bits d0*d0 mod 8 == 1 + m = m * (2 - m*d0) // 6-bits + m = m * (2 - m*d0) // 12-bits + m = m * (2 - m*d0) // 24-bits + m = m * (2 - m*d0) // 48-bits + m = m * (2 - m*d0) // 96-bits >= 64-bits + m = m & mask + + max := mask / d + + return udivisibleData{ + k: int64(k), + m: m, + max: max, + } +} + +func udivisible8(c int8) udivisibleData { return udivisible(8, int64(c)) } +func udivisible16(c int16) udivisibleData { return udivisible(16, int64(c)) } +func udivisible32(c int32) udivisibleData { return udivisible(32, int64(c)) } +func udivisible64(c int64) udivisibleData { return udivisible(64, c) } + +// For signed integers, a similar method follows. +// +// Given c > 1 and odd, compute m such that (c * m) mod 2^n == 1 +// Then if c divides x (x%c ==0), the quotient is given by q = x/c == x*m mod 2^n +// +// x can range from ⎡-2^(n-1)/c⎤ * c, ... -c, 0, c, ... ⎣(2^(n-1) - 1)/c⎦ * c +// Thus, x*m mod 2^n is ⎡-2^(n-1)/c⎤, ... -2, -1, 0, 1, 2, ... ⎣(2^(n-1) - 1)/c⎦ +// +// So, x is a multiple of c if and only if: +// ⎡-2^(n-1)/c⎤ <= x*m mod 2^n <= ⎣(2^(n-1) - 1)/c⎦ +// +// Since c > 1 and odd, this can be simplified by +// ⎡-2^(n-1)/c⎤ == ⎡(-2^(n-1) + 1)/c⎤ == -⎣(2^(n-1) - 1)/c⎦ +// +// -⎣(2^(n-1) - 1)/c⎦ <= x*m mod 2^n <= ⎣(2^(n-1) - 1)/c⎦ +// +// To extend this to even integers, consider c = d0 * 2^k where d0 is odd. +// We can test whether x is divisible by both d0 and 2^k. +// +// Let m be such that (d0 * m) mod 2^n == 1. +// Let q = x*m mod 2^n. Then c divides x if: +// +// -⎣(2^(n-1) - 1)/d0⎦ <= q <= ⎣(2^(n-1) - 1)/d0⎦ and q ends in at least k 0-bits +// +// To transform this to a single comparison, we use the following theorem (ZRS in Hacker's Delight). +// +// For a >= 0 the following conditions are equivalent: +// 1) -a <= x <= a and x ends in at least k 0-bits +// 2) RotRight(x+a', k) <= ⎣2a'/2^k⎦ +// +// Where a' = a & -2^k (a with its right k bits set to zero) +// +// To see that 1 & 2 are equivalent, note that -a <= x <= a is equivalent to +// -a' <= x <= a' if and only if x ends in at least k 0-bits. Adding -a' to each side gives, +// 0 <= x + a' <= 2a' and x + a' ends in at least k 0-bits if and only if x does since a' has +// k 0-bits by definition. We can use theorem ZRU above with x -> x + a' and a -> 2a' giving 1) == 2). +// +// Let m be such that (d0 * m) mod 2^n == 1. +// Let q = x*m mod 2^n. +// Let a' = ⎣(2^(n-1) - 1)/d0⎦ & -2^k +// +// Then the divisibility test is: +// +// RotRight(q+a', k) <= ⎣2a'/2^k⎦ +// +// Note that the calculation is performed using unsigned integers. +// Since a' can have n-1 bits, 2a' may have n bits and there is no risk of overflow. + +// sdivisibleOK reports whether we should strength reduce a signed n-bit divisibility check by c. +func sdivisibleOK(n uint, c int64) bool { + if c < 0 { + // Doesn't work for negative c. + return false + } + // Doesn't work for 0. + // Don't use it for powers of 2. + return c&(c-1) != 0 +} + +func sdivisibleOK8(c int8) bool { return sdivisibleOK(8, int64(c)) } +func sdivisibleOK16(c int16) bool { return sdivisibleOK(16, int64(c)) } +func sdivisibleOK32(c int32) bool { return sdivisibleOK(32, int64(c)) } +func sdivisibleOK64(c int64) bool { return sdivisibleOK(64, c) } + +type sdivisibleData struct { + k int64 // trailingZeros(c) + m uint64 // m * (c>>k) mod 2^n == 1 multiplicative inverse of odd portion modulo 2^n + a uint64 // ⎣(2^(n-1) - 1)/ (c>>k)⎦ & -(1<> uint(k) // the odd portion of the divisor + + mask := ^uint64(0) >> (64 - n) + + // Calculate the multiplicative inverse via Newton's method. + // Quadratic convergence doubles the number of correct bits per iteration. + m := d0 // initial guess correct to 3-bits d0*d0 mod 8 == 1 + m = m * (2 - m*d0) // 6-bits + m = m * (2 - m*d0) // 12-bits + m = m * (2 - m*d0) // 24-bits + m = m * (2 - m*d0) // 48-bits + m = m * (2 - m*d0) // 96-bits >= 64-bits + m = m & mask + + a := ((mask >> 1) / d0) & -(1 << uint(k)) + max := (2 * a) >> uint(k) + + return sdivisibleData{ + k: int64(k), + m: m, + a: a, + max: max, + } +} + +func sdivisible8(c int8) sdivisibleData { return sdivisible(8, int64(c)) } +func sdivisible16(c int16) sdivisibleData { return sdivisible(16, int64(c)) } +func sdivisible32(c int32) sdivisibleData { return sdivisible(32, int64(c)) } +func sdivisible64(c int64) sdivisibleData { return sdivisible(64, c) } diff --git a/go/src/cmd/compile/internal/ssa/magic_test.go b/go/src/cmd/compile/internal/ssa/magic_test.go new file mode 100644 index 0000000000000000000000000000000000000000..44177d679e7e8ea84e1fbaa261bd3df058086f2c --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/magic_test.go @@ -0,0 +1,410 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "math/big" + "testing" +) + +func TestMagicExhaustive8(t *testing.T) { + testMagicExhaustive(t, 8) +} +func TestMagicExhaustive8U(t *testing.T) { + testMagicExhaustiveU(t, 8) +} +func TestMagicExhaustive16(t *testing.T) { + if testing.Short() { + t.Skip("slow test; skipping") + } + testMagicExhaustive(t, 16) +} +func TestMagicExhaustive16U(t *testing.T) { + if testing.Short() { + t.Skip("slow test; skipping") + } + testMagicExhaustiveU(t, 16) +} + +// exhaustive test of magic for n bits +func testMagicExhaustive(t *testing.T, n uint) { + min := -int64(1) << (n - 1) + max := int64(1) << (n - 1) + for c := int64(1); c < max; c++ { + if !smagicOK(n, c) { + continue + } + m := int64(smagic(n, c).m) + s := smagic(n, c).s + for i := min; i < max; i++ { + want := i / c + got := (i * m) >> (n + uint(s)) + if i < 0 { + got++ + } + if want != got { + t.Errorf("signed magic wrong for %d / %d: got %d, want %d (m=%d,s=%d)\n", i, c, got, want, m, s) + } + } + } +} +func testMagicExhaustiveU(t *testing.T, n uint) { + max := uint64(1) << n + for c := uint64(1); c < max; c++ { + if !umagicOK(n, int64(c)) { + continue + } + m := umagic(n, int64(c)).m + s := umagic(n, int64(c)).s + for i := uint64(0); i < max; i++ { + want := i / c + got := (i * (max + m)) >> (n + uint(s)) + if want != got { + t.Errorf("unsigned magic wrong for %d / %d: got %d, want %d (m=%d,s=%d)\n", i, c, got, want, m, s) + } + } + } +} + +func TestMagicUnsigned(t *testing.T) { + One := new(big.Int).SetUint64(1) + for _, n := range [...]uint{8, 16, 32, 64} { + TwoN := new(big.Int).Lsh(One, n) + Max := new(big.Int).Sub(TwoN, One) + for _, c := range [...]uint64{ + 3, + 5, + 6, + 7, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 17, + 1<<8 - 1, + 1<<8 + 1, + 1<<16 - 1, + 1<<16 + 1, + 1<<32 - 1, + 1<<32 + 1, + 1<<64 - 1, + } { + if c>>n != 0 { + continue // not appropriate for the given n. + } + if !umagicOK(n, int64(c)) { + t.Errorf("expected n=%d c=%d to pass\n", n, c) + } + m := umagic(n, int64(c)).m + s := umagic(n, int64(c)).s + + C := new(big.Int).SetUint64(c) + M := new(big.Int).SetUint64(m) + M.Add(M, TwoN) + + // Find largest multiple of c. + Mul := new(big.Int).Div(Max, C) + Mul.Mul(Mul, C) + mul := Mul.Uint64() + + // Try some input values, mostly around multiples of c. + for _, x := range [...]uint64{0, 1, + c - 1, c, c + 1, + 2*c - 1, 2 * c, 2*c + 1, + mul - 1, mul, mul + 1, + uint64(1)< 0 { + continue + } + Want := new(big.Int).Quo(X, C) + Got := new(big.Int).Mul(X, M) + Got.Rsh(Got, n+uint(s)) + if Want.Cmp(Got) != 0 { + t.Errorf("umagic for %d/%d n=%d doesn't work, got=%s, want %s\n", x, c, n, Got, Want) + } + } + } + } +} + +func TestMagicSigned(t *testing.T) { + One := new(big.Int).SetInt64(1) + for _, n := range [...]uint{8, 16, 32, 64} { + TwoNMinusOne := new(big.Int).Lsh(One, n-1) + Max := new(big.Int).Sub(TwoNMinusOne, One) + Min := new(big.Int).Neg(TwoNMinusOne) + for _, c := range [...]int64{ + 3, + 5, + 6, + 7, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 17, + 1<<7 - 1, + 1<<7 + 1, + 1<<15 - 1, + 1<<15 + 1, + 1<<31 - 1, + 1<<31 + 1, + 1<<63 - 1, + } { + if c>>(n-1) != 0 { + continue // not appropriate for the given n. + } + if !smagicOK(n, c) { + t.Errorf("expected n=%d c=%d to pass\n", n, c) + } + m := smagic(n, c).m + s := smagic(n, c).s + + C := new(big.Int).SetInt64(c) + M := new(big.Int).SetUint64(m) + + // Find largest multiple of c. + Mul := new(big.Int).Div(Max, C) + Mul.Mul(Mul, C) + mul := Mul.Int64() + + // Try some input values, mostly around multiples of c. + for _, x := range [...]int64{ + -1, 1, + -c - 1, -c, -c + 1, c - 1, c, c + 1, + -2*c - 1, -2 * c, -2*c + 1, 2*c - 1, 2 * c, 2*c + 1, + -mul - 1, -mul, -mul + 1, mul - 1, mul, mul + 1, + int64(1)<<(n-1) - 1, -int64(1) << (n - 1), + } { + X := new(big.Int).SetInt64(x) + if X.Cmp(Min) < 0 || X.Cmp(Max) > 0 { + continue + } + Want := new(big.Int).Quo(X, C) + Got := new(big.Int).Mul(X, M) + Got.Rsh(Got, n+uint(s)) + if x < 0 { + Got.Add(Got, One) + } + if Want.Cmp(Got) != 0 { + t.Errorf("smagic for %d/%d n=%d doesn't work, got=%s, want %s\n", x, c, n, Got, Want) + } + } + } + } +} + +func testDivisibleExhaustiveU(t *testing.T, n uint) { + maxU := uint64(1) << n + for c := uint64(1); c < maxU; c++ { + if !udivisibleOK(n, int64(c)) { + continue + } + k := udivisible(n, int64(c)).k + m := udivisible(n, int64(c)).m + max := udivisible(n, int64(c)).max + mask := ^uint64(0) >> (64 - n) + for i := uint64(0); i < maxU; i++ { + want := i%c == 0 + mul := (i * m) & mask + rot := (mul>>uint(k) | mul<<(n-uint(k))) & mask + got := rot <= max + if want != got { + t.Errorf("unsigned divisible wrong for %d %% %d == 0: got %v, want %v (k=%d,m=%d,max=%d)\n", i, c, got, want, k, m, max) + } + } + } +} + +func TestDivisibleExhaustive8U(t *testing.T) { + testDivisibleExhaustiveU(t, 8) +} + +func TestDivisibleExhaustive16U(t *testing.T) { + if testing.Short() { + t.Skip("slow test; skipping") + } + testDivisibleExhaustiveU(t, 16) +} + +func TestDivisibleUnsigned(t *testing.T) { + One := new(big.Int).SetUint64(1) + for _, n := range [...]uint{8, 16, 32, 64} { + TwoN := new(big.Int).Lsh(One, n) + Max := new(big.Int).Sub(TwoN, One) + for _, c := range [...]uint64{ + 3, + 5, + 6, + 7, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 17, + 1<<8 - 1, + 1<<8 + 1, + 1<<16 - 1, + 1<<16 + 1, + 1<<32 - 1, + 1<<32 + 1, + 1<<64 - 1, + } { + if c>>n != 0 { + continue // c too large for the given n. + } + if !udivisibleOK(n, int64(c)) { + t.Errorf("expected n=%d c=%d to pass\n", n, c) + } + k := udivisible(n, int64(c)).k + m := udivisible(n, int64(c)).m + max := udivisible(n, int64(c)).max + mask := ^uint64(0) >> (64 - n) + + C := new(big.Int).SetUint64(c) + + // Find largest multiple of c. + Mul := new(big.Int).Div(Max, C) + Mul.Mul(Mul, C) + mul := Mul.Uint64() + + // Try some input values, mostly around multiples of c. + for _, x := range [...]uint64{0, 1, + c - 1, c, c + 1, + 2*c - 1, 2 * c, 2*c + 1, + mul - 1, mul, mul + 1, + uint64(1)< 0 { + continue + } + want := x%c == 0 + mul := (x * m) & mask + rot := (mul>>uint(k) | mul<<(n-uint(k))) & mask + got := rot <= max + if want != got { + t.Errorf("unsigned divisible wrong for %d %% %d == 0: got %v, want %v (k=%d,m=%d,max=%d)\n", x, c, got, want, k, m, max) + } + } + } + } +} + +func testDivisibleExhaustive(t *testing.T, n uint) { + minI := -int64(1) << (n - 1) + maxI := int64(1) << (n - 1) + for c := int64(1); c < maxI; c++ { + if !sdivisibleOK(n, c) { + continue + } + k := sdivisible(n, c).k + m := sdivisible(n, c).m + a := sdivisible(n, c).a + max := sdivisible(n, c).max + mask := ^uint64(0) >> (64 - n) + for i := minI; i < maxI; i++ { + want := i%c == 0 + mul := (uint64(i)*m + a) & mask + rot := (mul>>uint(k) | mul<<(n-uint(k))) & mask + got := rot <= max + if want != got { + t.Errorf("signed divisible wrong for %d %% %d == 0: got %v, want %v (k=%d,m=%d,a=%d,max=%d)\n", i, c, got, want, k, m, a, max) + } + } + } +} + +func TestDivisibleExhaustive8(t *testing.T) { + testDivisibleExhaustive(t, 8) +} + +func TestDivisibleExhaustive16(t *testing.T) { + if testing.Short() { + t.Skip("slow test; skipping") + } + testDivisibleExhaustive(t, 16) +} + +func TestDivisibleSigned(t *testing.T) { + One := new(big.Int).SetInt64(1) + for _, n := range [...]uint{8, 16, 32, 64} { + TwoNMinusOne := new(big.Int).Lsh(One, n-1) + Max := new(big.Int).Sub(TwoNMinusOne, One) + Min := new(big.Int).Neg(TwoNMinusOne) + for _, c := range [...]int64{ + 3, + 5, + 6, + 7, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 17, + 1<<7 - 1, + 1<<7 + 1, + 1<<15 - 1, + 1<<15 + 1, + 1<<31 - 1, + 1<<31 + 1, + 1<<63 - 1, + } { + if c>>(n-1) != 0 { + continue // not appropriate for the given n. + } + if !sdivisibleOK(n, c) { + t.Errorf("expected n=%d c=%d to pass\n", n, c) + } + k := sdivisible(n, c).k + m := sdivisible(n, c).m + a := sdivisible(n, c).a + max := sdivisible(n, c).max + mask := ^uint64(0) >> (64 - n) + + C := new(big.Int).SetInt64(c) + + // Find largest multiple of c. + Mul := new(big.Int).Div(Max, C) + Mul.Mul(Mul, C) + mul := Mul.Int64() + + // Try some input values, mostly around multiples of c. + for _, x := range [...]int64{ + -1, 1, + -c - 1, -c, -c + 1, c - 1, c, c + 1, + -2*c - 1, -2 * c, -2*c + 1, 2*c - 1, 2 * c, 2*c + 1, + -mul - 1, -mul, -mul + 1, mul - 1, mul, mul + 1, + int64(1)<<(n-1) - 1, -int64(1) << (n - 1), + } { + X := new(big.Int).SetInt64(x) + if X.Cmp(Min) < 0 || X.Cmp(Max) > 0 { + continue + } + want := x%c == 0 + mul := (uint64(x)*m + a) & mask + rot := (mul>>uint(k) | mul<<(n-uint(k))) & mask + got := rot <= max + if want != got { + t.Errorf("signed divisible wrong for %d %% %d == 0: got %v, want %v (k=%d,m=%d,a=%d,max=%d)\n", x, c, got, want, k, m, a, max) + } + } + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/memcombine.go b/go/src/cmd/compile/internal/ssa/memcombine.go new file mode 100644 index 0000000000000000000000000000000000000000..6b1df7dc099e73aab8bcafd7713be4e0045bcdf5 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/memcombine.go @@ -0,0 +1,842 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmd/internal/src" + "cmp" + "slices" +) + +// memcombine combines smaller loads and stores into larger ones. +// We ensure this generates good code for encoding/binary operations. +// It may help other cases also. +func memcombine(f *Func) { + // This optimization requires that the architecture has + // unaligned loads and unaligned stores. + if !f.Config.unalignedOK { + return + } + + memcombineLoads(f) + memcombineStores(f) +} + +func memcombineLoads(f *Func) { + // Find "OR trees" to start with. + mark := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(mark) + var order []*Value + + // Mark all values that are the argument of an OR. + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op == OpOr16 || v.Op == OpOr32 || v.Op == OpOr64 { + mark.add(v.Args[0].ID) + mark.add(v.Args[1].ID) + } + } + } + for _, b := range f.Blocks { + order = order[:0] + for _, v := range b.Values { + if v.Op != OpOr16 && v.Op != OpOr32 && v.Op != OpOr64 { + continue + } + if mark.contains(v.ID) { + // marked - means it is not the root of an OR tree + continue + } + // Add the OR tree rooted at v to the order. + // We use BFS here, but any walk that puts roots before leaves would work. + i := len(order) + order = append(order, v) + for ; i < len(order); i++ { + x := order[i] + for j := 0; j < 2; j++ { + a := x.Args[j] + if a.Op == OpOr16 || a.Op == OpOr32 || a.Op == OpOr64 { + order = append(order, a) + } + } + } + } + for _, v := range order { + max := f.Config.RegSize + switch v.Op { + case OpOr64: + case OpOr32: + max = 4 + case OpOr16: + max = 2 + default: + continue + } + for n := max; n > 1; n /= 2 { + if combineLoads(v, n) { + break + } + } + } + } +} + +// A BaseAddress represents the address ptr+idx, where +// ptr is a pointer type and idx is an integer type. +// idx may be nil, in which case it is treated as 0. +type BaseAddress struct { + ptr *Value + idx *Value +} + +// splitPtr returns the base address of ptr and any +// constant offset from that base. +// BaseAddress{ptr,nil},0 is always a valid result, but splitPtr +// tries to peel away as many constants into off as possible. +func splitPtr(ptr *Value) (BaseAddress, int64) { + var idx *Value + var off int64 + for { + if ptr.Op == OpOffPtr { + off += ptr.AuxInt + ptr = ptr.Args[0] + } else if ptr.Op == OpAddPtr { + if idx != nil { + // We have two or more indexing values. + // Pick the first one we found. + return BaseAddress{ptr: ptr, idx: idx}, off + } + idx = ptr.Args[1] + if idx.Op == OpAdd32 || idx.Op == OpAdd64 { + if idx.Args[0].Op == OpConst32 || idx.Args[0].Op == OpConst64 { + off += idx.Args[0].AuxInt + idx = idx.Args[1] + } else if idx.Args[1].Op == OpConst32 || idx.Args[1].Op == OpConst64 { + off += idx.Args[1].AuxInt + idx = idx.Args[0] + } + } + ptr = ptr.Args[0] + } else { + return BaseAddress{ptr: ptr, idx: idx}, off + } + } +} + +func combineLoads(root *Value, n int64) bool { + orOp := root.Op + var shiftOp Op + switch orOp { + case OpOr64: + shiftOp = OpLsh64x64 + case OpOr32: + shiftOp = OpLsh32x64 + case OpOr16: + shiftOp = OpLsh16x64 + default: + return false + } + + // Find n values that are ORed together with the above op. + a := make([]*Value, 0, 8) + a = append(a, root) + for i := 0; i < len(a) && int64(len(a)) < n; i++ { + v := a[i] + if v.Uses != 1 && v != root { + // Something in this subtree is used somewhere else. + return false + } + if v.Op == orOp { + a[i] = v.Args[0] + a = append(a, v.Args[1]) + i-- + } + } + if int64(len(a)) != n { + return false + } + + // Check that the first entry to see what ops we're looking for. + // All the entries should be of the form shift(extend(load)), maybe with no shift. + v := a[0] + if v.Op == shiftOp { + v = v.Args[0] + } + var extOp Op + if orOp == OpOr64 && (v.Op == OpZeroExt8to64 || v.Op == OpZeroExt16to64 || v.Op == OpZeroExt32to64) || + orOp == OpOr32 && (v.Op == OpZeroExt8to32 || v.Op == OpZeroExt16to32) || + orOp == OpOr16 && v.Op == OpZeroExt8to16 { + extOp = v.Op + v = v.Args[0] + } else { + return false + } + if v.Op != OpLoad { + return false + } + base, _ := splitPtr(v.Args[0]) + mem := v.Args[1] + size := v.Type.Size() + + if root.Block.Func.Config.arch == "S390X" { + // s390x can't handle unaligned accesses to global variables. + if base.ptr.Op == OpAddr { + return false + } + } + + // Check all the entries, extract useful info. + type LoadRecord struct { + load *Value + offset int64 // offset of load address from base + shift int64 + } + r := make([]LoadRecord, n, 8) + for i := int64(0); i < n; i++ { + v := a[i] + if v.Uses != 1 { + return false + } + shift := int64(0) + if v.Op == shiftOp { + if v.Args[1].Op != OpConst64 { + return false + } + shift = v.Args[1].AuxInt + v = v.Args[0] + if v.Uses != 1 { + return false + } + } + if v.Op != extOp { + return false + } + load := v.Args[0] + if load.Op != OpLoad { + return false + } + if load.Uses != 1 { + return false + } + if load.Args[1] != mem { + return false + } + p, off := splitPtr(load.Args[0]) + if p != base { + return false + } + r[i] = LoadRecord{load: load, offset: off, shift: shift} + } + + // Sort in memory address order. + slices.SortFunc(r, func(a, b LoadRecord) int { + return cmp.Compare(a.offset, b.offset) + }) + + // Check that we have contiguous offsets. + for i := int64(0); i < n; i++ { + if r[i].offset != r[0].offset+i*size { + return false + } + } + + // Check for reads in little-endian or big-endian order. + shift0 := r[0].shift + isLittleEndian := true + for i := int64(0); i < n; i++ { + if r[i].shift != shift0+i*size*8 { + isLittleEndian = false + break + } + } + isBigEndian := true + for i := int64(0); i < n; i++ { + if r[i].shift != shift0-i*size*8 { + isBigEndian = false + break + } + } + if !isLittleEndian && !isBigEndian { + return false + } + + // Find a place to put the new load. + // This is tricky, because it has to be at a point where + // its memory argument is live. We can't just put it in root.Block. + // We use the block of the latest load. + loads := make([]*Value, n, 8) + for i := int64(0); i < n; i++ { + loads[i] = r[i].load + } + loadBlock := mergePoint(root.Block, loads...) + if loadBlock == nil { + return false + } + // Find a source position to use. + pos := src.NoXPos + for _, load := range loads { + if load.Block == loadBlock { + pos = load.Pos + break + } + } + if pos == src.NoXPos { + return false + } + + // Check to see if we need byte swap before storing. + needSwap := isLittleEndian && root.Block.Func.Config.BigEndian || + isBigEndian && !root.Block.Func.Config.BigEndian + if needSwap && (size != 1 || !root.Block.Func.Config.haveByteSwap(n)) { + return false + } + + // This is the commit point. + + // First, issue load at lowest address. + v = loadBlock.NewValue2(pos, OpLoad, sizeType(n*size), r[0].load.Args[0], mem) + + // Byte swap if needed, + if needSwap { + v = byteSwap(loadBlock, pos, v) + } + + // Extend if needed. + if n*size < root.Type.Size() { + v = zeroExtend(loadBlock, pos, v, n*size, root.Type.Size()) + } + + // Shift if needed. + if isLittleEndian && shift0 != 0 { + v = leftShift(loadBlock, pos, v, shift0) + } + if isBigEndian && shift0-(n-1)*size*8 != 0 { + v = leftShift(loadBlock, pos, v, shift0-(n-1)*size*8) + } + + // Install with (Copy v). + root.reset(OpCopy) + root.AddArg(v) + + // Clobber the loads, just to prevent additional work being done on + // subtrees (which are now unreachable). + for i := int64(0); i < n; i++ { + clobber(r[i].load) + } + return true +} + +func memcombineStores(f *Func) { + mark := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(mark) + var order []*Value + + for _, b := range f.Blocks { + // Mark all stores which are not last in a store sequence. + mark.clear() + for _, v := range b.Values { + if v.Op == OpStore { + mark.add(v.MemoryArg().ID) + } + } + + // pick an order for visiting stores such that + // later stores come earlier in the ordering. + order = order[:0] + for _, v := range b.Values { + if v.Op != OpStore { + continue + } + if mark.contains(v.ID) { + continue // not last in a chain of stores + } + for { + order = append(order, v) + v = v.Args[2] + if v.Block != b || v.Op != OpStore { + break + } + } + } + + // Look for combining opportunities at each store in queue order. + for _, v := range order { + if v.Op != OpStore { // already rewritten + continue + } + + size := v.Aux.(*types.Type).Size() + if size >= f.Config.RegSize || size == 0 { + continue + } + + combineStores(v) + } + } +} + +// combineStores tries to combine the stores ending in root. +func combineStores(root *Value) { + // Helper functions. + maxRegSize := root.Block.Func.Config.RegSize + type StoreRecord struct { + store *Value + offset int64 + size int64 + } + getShiftBase := func(a []StoreRecord) *Value { + x := a[0].store.Args[1] + y := a[1].store.Args[1] + switch x.Op { + case OpTrunc64to8, OpTrunc64to16, OpTrunc64to32, OpTrunc32to8, OpTrunc32to16, OpTrunc16to8: + x = x.Args[0] + default: + return nil + } + switch y.Op { + case OpTrunc64to8, OpTrunc64to16, OpTrunc64to32, OpTrunc32to8, OpTrunc32to16, OpTrunc16to8: + y = y.Args[0] + default: + return nil + } + var x2 *Value + switch x.Op { + case OpRsh64Ux64, OpRsh32Ux64, OpRsh16Ux64: + x2 = x.Args[0] + default: + } + var y2 *Value + switch y.Op { + case OpRsh64Ux64, OpRsh32Ux64, OpRsh16Ux64: + y2 = y.Args[0] + default: + } + if y2 == x { + // a shift of x and x itself. + return x + } + if x2 == y { + // a shift of y and y itself. + return y + } + if x2 == y2 { + // 2 shifts both of the same argument. + return x2 + } + return nil + } + isShiftBase := func(v, base *Value) bool { + val := v.Args[1] + switch val.Op { + case OpTrunc64to8, OpTrunc64to16, OpTrunc64to32, OpTrunc32to8, OpTrunc32to16, OpTrunc16to8: + val = val.Args[0] + default: + return false + } + if val == base { + return true + } + switch val.Op { + case OpRsh64Ux64, OpRsh32Ux64, OpRsh16Ux64: + val = val.Args[0] + default: + return false + } + return val == base + } + shift := func(v, base *Value) int64 { + val := v.Args[1] + switch val.Op { + case OpTrunc64to8, OpTrunc64to16, OpTrunc64to32, OpTrunc32to8, OpTrunc32to16, OpTrunc16to8: + val = val.Args[0] + default: + return -1 + } + if val == base { + return 0 + } + switch val.Op { + case OpRsh64Ux64, OpRsh32Ux64, OpRsh16Ux64: + val = val.Args[1] + default: + return -1 + } + if val.Op != OpConst64 { + return -1 + } + return val.AuxInt + } + + // Gather n stores to look at. Check easy conditions we require. + allMergeable := make([]StoreRecord, 0, 8) + rbase, roff := splitPtr(root.Args[0]) + if root.Block.Func.Config.arch == "S390X" { + // s390x can't handle unaligned accesses to global variables. + if rbase.ptr.Op == OpAddr { + return + } + } + allMergeable = append(allMergeable, StoreRecord{root, roff, root.Aux.(*types.Type).Size()}) + allMergeableSize := root.Aux.(*types.Type).Size() + // TODO: this loop strictly requires stores to chain together in memory. + // maybe we can break this constraint and match more patterns. + for i, x := 1, root.Args[2]; i < 8; i, x = i+1, x.Args[2] { + if x.Op != OpStore { + break + } + if x.Block != root.Block { + break + } + if x.Uses != 1 { // Note: root can have more than one use. + break + } + xSize := x.Aux.(*types.Type).Size() + if xSize == 0 { + break + } + if xSize > maxRegSize-allMergeableSize { + break + } + base, off := splitPtr(x.Args[0]) + if base != rbase { + break + } + allMergeable = append(allMergeable, StoreRecord{x, off, xSize}) + allMergeableSize += xSize + } + if len(allMergeable) <= 1 { + return + } + // Fit the combined total size to be one of the register size. + mergeableSet := map[int64][]StoreRecord{} + for i, size := 0, int64(0); i < len(allMergeable); i++ { + size += allMergeable[i].size + for _, bucketSize := range []int64{8, 4, 2} { + if size == bucketSize { + mergeableSet[size] = slices.Clone(allMergeable[:i+1]) + break + } + } + } + var a []StoreRecord + var aTotalSize int64 + var mem *Value + var pos src.XPos + // Pick the largest mergeable set. + for _, s := range []int64{8, 4, 2} { + candidate := mergeableSet[s] + // TODO: a refactoring might be more efficient: + // Find a bunch of stores that are all adjacent and then decide how big a chunk of + // those sequential stores to combine. + if len(candidate) >= 2 { + // Before we sort, grab the memory arg the result should have. + mem = candidate[len(candidate)-1].store.Args[2] + // Also grab position of first store (last in array = first in memory order). + pos = candidate[len(candidate)-1].store.Pos + // Sort stores in increasing address order. + slices.SortFunc(candidate, func(sr1, sr2 StoreRecord) int { + return cmp.Compare(sr1.offset, sr2.offset) + }) + // Check that everything is written to sequential locations. + sequential := true + for i := 1; i < len(candidate); i++ { + if candidate[i].offset != candidate[i-1].offset+candidate[i-1].size { + sequential = false + break + } + } + if sequential { + a = candidate + aTotalSize = s + break + } + } + } + if len(a) <= 1 { + return + } + // Memory location we're going to write at (the lowest one). + ptr := a[0].store.Args[0] + + // Check for constant stores + isConst := true + for i := range a { + switch a[i].store.Args[1].Op { + case OpConst32, OpConst16, OpConst8, OpConstBool: + default: + isConst = false + } + if !isConst { + break + } + } + if isConst { + // Modify root to do all the stores. + var c int64 + for i := range a { + mask := int64(1)<<(8*a[i].size) - 1 + s := 8 * (a[i].offset - a[0].offset) + if root.Block.Func.Config.BigEndian { + s = (aTotalSize-a[i].size)*8 - s + } + c |= (a[i].store.Args[1].AuxInt & mask) << s + } + var cv *Value + switch aTotalSize { + case 2: + cv = root.Block.Func.ConstInt16(types.Types[types.TUINT16], int16(c)) + case 4: + cv = root.Block.Func.ConstInt32(types.Types[types.TUINT32], int32(c)) + case 8: + cv = root.Block.Func.ConstInt64(types.Types[types.TUINT64], c) + } + + // Move all the stores to the root. + for i := range a { + v := a[i].store + if v == root { + v.Aux = cv.Type // widen store type + v.Pos = pos + v.SetArg(0, ptr) + v.SetArg(1, cv) + v.SetArg(2, mem) + } else { + clobber(v) + v.Type = types.Types[types.TBOOL] // erase memory type + } + } + return + } + + // Check for consecutive loads as the source of the stores. + var loadMem *Value + var loadBase BaseAddress + var loadIdx int64 + for i := range a { + load := a[i].store.Args[1] + if load.Op != OpLoad { + loadMem = nil + break + } + if load.Uses != 1 { + loadMem = nil + break + } + if load.Type.IsPtr() { + // Don't combine stores containing a pointer, as we need + // a write barrier for those. This can't currently happen, + // but might in the future if we ever have another + // 8-byte-reg/4-byte-ptr architecture like amd64p32. + loadMem = nil + break + } + mem := load.Args[1] + base, idx := splitPtr(load.Args[0]) + if loadMem == nil { + // First one we found + loadMem = mem + loadBase = base + loadIdx = idx + continue + } + if base != loadBase || mem != loadMem { + loadMem = nil + break + } + if idx != loadIdx+(a[i].offset-a[0].offset) { + loadMem = nil + break + } + } + if loadMem != nil { + // Modify the first load to do a larger load instead. + load := a[0].store.Args[1] + switch aTotalSize { + case 2: + load.Type = types.Types[types.TUINT16] + case 4: + load.Type = types.Types[types.TUINT32] + case 8: + load.Type = types.Types[types.TUINT64] + } + + // Modify root to do the store. + for i := range a { + v := a[i].store + if v == root { + v.Aux = load.Type // widen store type + v.Pos = pos + v.SetArg(0, ptr) + v.SetArg(1, load) + v.SetArg(2, mem) + } else { + clobber(v) + v.Type = types.Types[types.TBOOL] // erase memory type + } + } + return + } + + // Check that all the shift/trunc are of the same base value. + shiftBase := getShiftBase(a) + if shiftBase == nil { + return + } + for i := range a { + if !isShiftBase(a[i].store, shiftBase) { + return + } + } + + // Check for writes in little-endian or big-endian order. + isLittleEndian := true + shift0 := shift(a[0].store, shiftBase) + for i := 1; i < len(a); i++ { + if shift(a[i].store, shiftBase) != shift0+(a[i].offset-a[0].offset)*8 { + isLittleEndian = false + break + } + } + isBigEndian := true + shiftedSize := int64(0) + for i := 1; i < len(a); i++ { + shiftedSize += a[i].size + if shift(a[i].store, shiftBase) != shift0-shiftedSize*8 { + isBigEndian = false + break + } + } + if !isLittleEndian && !isBigEndian { + return + } + + // Check to see if we need byte swap before storing. + needSwap := isLittleEndian && root.Block.Func.Config.BigEndian || + isBigEndian && !root.Block.Func.Config.BigEndian + if needSwap && (int64(len(a)) != aTotalSize || !root.Block.Func.Config.haveByteSwap(aTotalSize)) { + return + } + + // This is the commit point. + + // Modify root to do all the stores. + sv := shiftBase + if isLittleEndian && shift0 != 0 { + sv = rightShift(root.Block, root.Pos, sv, shift0) + } + shiftedSize = aTotalSize - a[0].size + if isBigEndian && shift0-shiftedSize*8 != 0 { + sv = rightShift(root.Block, root.Pos, sv, shift0-shiftedSize*8) + } + if sv.Type.Size() > aTotalSize { + sv = truncate(root.Block, root.Pos, sv, sv.Type.Size(), aTotalSize) + } + if needSwap { + sv = byteSwap(root.Block, root.Pos, sv) + } + + // Move all the stores to the root. + for i := range a { + v := a[i].store + if v == root { + v.Aux = sv.Type // widen store type + v.Pos = pos + v.SetArg(0, ptr) + v.SetArg(1, sv) + v.SetArg(2, mem) + } else { + clobber(v) + v.Type = types.Types[types.TBOOL] // erase memory type + } + } +} + +func sizeType(size int64) *types.Type { + switch size { + case 8: + return types.Types[types.TUINT64] + case 4: + return types.Types[types.TUINT32] + case 2: + return types.Types[types.TUINT16] + default: + base.Fatalf("bad size %d\n", size) + return nil + } +} + +func truncate(b *Block, pos src.XPos, v *Value, from, to int64) *Value { + switch from*10 + to { + case 82: + return b.NewValue1(pos, OpTrunc64to16, types.Types[types.TUINT16], v) + case 84: + return b.NewValue1(pos, OpTrunc64to32, types.Types[types.TUINT32], v) + case 42: + return b.NewValue1(pos, OpTrunc32to16, types.Types[types.TUINT16], v) + default: + base.Fatalf("bad sizes %d %d\n", from, to) + return nil + } +} +func zeroExtend(b *Block, pos src.XPos, v *Value, from, to int64) *Value { + switch from*10 + to { + case 24: + return b.NewValue1(pos, OpZeroExt16to32, types.Types[types.TUINT32], v) + case 28: + return b.NewValue1(pos, OpZeroExt16to64, types.Types[types.TUINT64], v) + case 48: + return b.NewValue1(pos, OpZeroExt32to64, types.Types[types.TUINT64], v) + default: + base.Fatalf("bad sizes %d %d\n", from, to) + return nil + } +} + +func leftShift(b *Block, pos src.XPos, v *Value, shift int64) *Value { + s := b.Func.ConstInt64(types.Types[types.TUINT64], shift) + size := v.Type.Size() + switch size { + case 8: + return b.NewValue2(pos, OpLsh64x64, v.Type, v, s) + case 4: + return b.NewValue2(pos, OpLsh32x64, v.Type, v, s) + case 2: + return b.NewValue2(pos, OpLsh16x64, v.Type, v, s) + default: + base.Fatalf("bad size %d\n", size) + return nil + } +} +func rightShift(b *Block, pos src.XPos, v *Value, shift int64) *Value { + s := b.Func.ConstInt64(types.Types[types.TUINT64], shift) + size := v.Type.Size() + switch size { + case 8: + return b.NewValue2(pos, OpRsh64Ux64, v.Type, v, s) + case 4: + return b.NewValue2(pos, OpRsh32Ux64, v.Type, v, s) + case 2: + return b.NewValue2(pos, OpRsh16Ux64, v.Type, v, s) + default: + base.Fatalf("bad size %d\n", size) + return nil + } +} +func byteSwap(b *Block, pos src.XPos, v *Value) *Value { + switch v.Type.Size() { + case 8: + return b.NewValue1(pos, OpBswap64, v.Type, v) + case 4: + return b.NewValue1(pos, OpBswap32, v.Type, v) + case 2: + return b.NewValue1(pos, OpBswap16, v.Type, v) + + default: + v.Fatalf("bad size %d\n", v.Type.Size()) + return nil + } +} diff --git a/go/src/cmd/compile/internal/ssa/nilcheck.go b/go/src/cmd/compile/internal/ssa/nilcheck.go new file mode 100644 index 0000000000000000000000000000000000000000..467c7514eee5f2065d9a46ef9eb503e30147afdf --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/nilcheck.go @@ -0,0 +1,338 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/ir" + "cmd/internal/src" + "internal/buildcfg" +) + +// nilcheckelim eliminates unnecessary nil checks. +// runs on machine-independent code. +func nilcheckelim(f *Func) { + // A nil check is redundant if the same nil check was successful in a + // dominating block. The efficacy of this pass depends heavily on the + // efficacy of the cse pass. + sdom := f.Sdom() + + // TODO: Eliminate more nil checks. + // We can recursively remove any chain of fixed offset calculations, + // i.e. struct fields and array elements, even with non-constant + // indices: x is non-nil iff x.a.b[i].c is. + + type walkState int + const ( + Work walkState = iota // process nil checks and traverse to dominees + ClearPtr // forget the fact that ptr is nil + ) + + type bp struct { + block *Block // block, or nil in ClearPtr state + ptr *Value // if non-nil, ptr that is to be cleared in ClearPtr state + op walkState + } + + work := make([]bp, 0, 256) + work = append(work, bp{block: f.Entry}) + + // map from value ID to known non-nil version of that value ID + // (in the current dominator path being walked). This slice is updated by + // walkStates to maintain the known non-nil values. + // If there is extrinsic information about non-nil-ness, this map + // points a value to itself. If a value is known non-nil because we + // already did a nil check on it, it points to the nil check operation. + nonNilValues := f.Cache.allocValueSlice(f.NumValues()) + defer f.Cache.freeValueSlice(nonNilValues) + + // make an initial pass identifying any non-nil values + for _, b := range f.Blocks { + for _, v := range b.Values { + // a value resulting from taking the address of a + // value, or a value constructed from an offset of a + // non-nil ptr (OpAddPtr) implies it is non-nil + // We also assume unsafe pointer arithmetic generates non-nil pointers. See #27180. + // We assume that SlicePtr is non-nil because we do a bounds check + // before the slice access (and all cap>0 slices have a non-nil ptr). See #30366. + if v.Op == OpAddr || v.Op == OpLocalAddr || v.Op == OpAddPtr || v.Op == OpOffPtr || v.Op == OpAdd32 || v.Op == OpAdd64 || v.Op == OpSub32 || v.Op == OpSub64 || v.Op == OpSlicePtr { + nonNilValues[v.ID] = v + } + } + } + + for changed := true; changed; { + changed = false + for _, b := range f.Blocks { + for _, v := range b.Values { + // phis whose arguments are all non-nil + // are non-nil + if v.Op == OpPhi { + argsNonNil := true + for _, a := range v.Args { + if nonNilValues[a.ID] == nil { + argsNonNil = false + break + } + } + if argsNonNil { + if nonNilValues[v.ID] == nil { + changed = true + } + nonNilValues[v.ID] = v + } + } + } + } + } + + // allocate auxiliary date structures for computing store order + sset := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(sset) + storeNumber := f.Cache.allocInt32Slice(f.NumValues()) + defer f.Cache.freeInt32Slice(storeNumber) + + // perform a depth first walk of the dominee tree + for len(work) > 0 { + node := work[len(work)-1] + work = work[:len(work)-1] + + switch node.op { + case Work: + b := node.block + + // First, see if we're dominated by an explicit nil check. + if len(b.Preds) == 1 { + p := b.Preds[0].b + if p.Kind == BlockIf && p.Controls[0].Op == OpIsNonNil && p.Succs[0].b == b { + if ptr := p.Controls[0].Args[0]; nonNilValues[ptr.ID] == nil { + nonNilValues[ptr.ID] = ptr + work = append(work, bp{op: ClearPtr, ptr: ptr}) + } + } + } + + // Next, order values in the current block w.r.t. stores. + b.Values = storeOrder(b.Values, sset, storeNumber) + + pendingLines := f.cachedLineStarts // Holds statement boundaries that need to be moved to a new value/block + pendingLines.clear() + + // Next, process values in the block. + for _, v := range b.Values { + switch v.Op { + case OpIsNonNil: + ptr := v.Args[0] + if nonNilValues[ptr.ID] != nil { + if v.Pos.IsStmt() == src.PosIsStmt { // Boolean true is a terrible statement boundary. + pendingLines.add(v.Pos) + v.Pos = v.Pos.WithNotStmt() + } + // This is a redundant explicit nil check. + v.reset(OpConstBool) + v.AuxInt = 1 // true + } + case OpNilCheck: + ptr := v.Args[0] + if nilCheck := nonNilValues[ptr.ID]; nilCheck != nil { + // This is a redundant implicit nil check. + // Logging in the style of the former compiler -- and omit line 1, + // which is usually in generated code. + if f.fe.Debug_checknil() && v.Pos.Line() > 1 { + f.Warnl(v.Pos, "removed nil check") + } + if v.Pos.IsStmt() == src.PosIsStmt { // About to lose a statement boundary + pendingLines.add(v.Pos) + } + v.Op = OpCopy + v.SetArgs1(nilCheck) + continue + } + // Record the fact that we know ptr is non nil, and remember to + // undo that information when this dominator subtree is done. + nonNilValues[ptr.ID] = v + work = append(work, bp{op: ClearPtr, ptr: ptr}) + fallthrough // a non-eliminated nil check might be a good place for a statement boundary. + default: + if v.Pos.IsStmt() != src.PosNotStmt && !isPoorStatementOp(v.Op) && pendingLines.contains(v.Pos) { + v.Pos = v.Pos.WithIsStmt() + pendingLines.remove(v.Pos) + } + } + } + // This reduces the lost statement count in "go" by 5 (out of 500 total). + for j := range b.Values { // is this an ordering problem? + v := b.Values[j] + if v.Pos.IsStmt() != src.PosNotStmt && !isPoorStatementOp(v.Op) && pendingLines.contains(v.Pos) { + v.Pos = v.Pos.WithIsStmt() + pendingLines.remove(v.Pos) + } + } + if pendingLines.contains(b.Pos) { + b.Pos = b.Pos.WithIsStmt() + pendingLines.remove(b.Pos) + } + + // Add all dominated blocks to the work list. + for w := sdom[node.block.ID].child; w != nil; w = sdom[w.ID].sibling { + work = append(work, bp{op: Work, block: w}) + } + + case ClearPtr: + nonNilValues[node.ptr.ID] = nil + continue + } + } +} + +// All platforms are guaranteed to fault if we load/store to anything smaller than this address. +// +// This should agree with minLegalPointer in the runtime. +const minZeroPage = 4096 + +// faultOnLoad is true if a load to an address below minZeroPage will trigger a SIGSEGV. +var faultOnLoad = buildcfg.GOOS != "aix" + +// nilcheckelim2 eliminates unnecessary nil checks. +// Runs after lowering and scheduling. +func nilcheckelim2(f *Func) { + unnecessary := f.newSparseMap(f.NumValues()) // map from pointer that will be dereferenced to index of dereferencing value in b.Values[] + defer f.retSparseMap(unnecessary) + + pendingLines := f.cachedLineStarts // Holds statement boundaries that need to be moved to a new value/block + + for _, b := range f.Blocks { + // Walk the block backwards. Find instructions that will fault if their + // input pointer is nil. Remove nil checks on those pointers, as the + // faulting instruction effectively does the nil check for free. + unnecessary.clear() + pendingLines.clear() + // Optimization: keep track of removed nilcheck with smallest index + firstToRemove := len(b.Values) + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + if opcodeTable[v.Op].nilCheck && unnecessary.contains(v.Args[0].ID) { + if f.fe.Debug_checknil() && v.Pos.Line() > 1 { + f.Warnl(v.Pos, "removed nil check") + } + // For bug 33724, policy is that we might choose to bump an existing position + // off the faulting load in favor of the one from the nil check. + + // Iteration order means that first nilcheck in the chain wins, others + // are bumped into the ordinary statement preservation algorithm. + uid, _ := unnecessary.get(v.Args[0].ID) + u := b.Values[uid] + if !u.Type.IsMemory() && !u.Pos.SameFileAndLine(v.Pos) { + if u.Pos.IsStmt() == src.PosIsStmt { + pendingLines.add(u.Pos) + } + u.Pos = v.Pos + } else if v.Pos.IsStmt() == src.PosIsStmt { + pendingLines.add(v.Pos) + } + + v.reset(OpUnknown) + firstToRemove = i + continue + } + if v.Type.IsMemory() || v.Type.IsTuple() && v.Type.FieldType(1).IsMemory() { + if v.Op == OpVarLive || (v.Op == OpVarDef && !v.Aux.(*ir.Name).Type().HasPointers()) { + // These ops don't really change memory. + continue + // Note: OpVarDef requires that the defined variable not have pointers. + // We need to make sure that there's no possible faulting + // instruction between a VarDef and that variable being + // fully initialized. If there was, then anything scanning + // the stack during the handling of that fault will see + // a live but uninitialized pointer variable on the stack. + // + // If we have: + // + // NilCheck p + // VarDef x + // x = *p + // + // We can't rewrite that to + // + // VarDef x + // NilCheck p + // x = *p + // + // Particularly, even though *p faults on p==nil, we still + // have to do the explicit nil check before the VarDef. + // See issue #32288. + } + // This op changes memory. Any faulting instruction after v that + // we've recorded in the unnecessary map is now obsolete. + unnecessary.clear() + } + + // Find any pointers that this op is guaranteed to fault on if nil. + var ptrstore [2]*Value + ptrs := ptrstore[:0] + if opcodeTable[v.Op].faultOnNilArg0 && (faultOnLoad || v.Type.IsMemory()) { + // On AIX, only writing will fault. + ptrs = append(ptrs, v.Args[0]) + } + if opcodeTable[v.Op].faultOnNilArg1 && (faultOnLoad || (v.Type.IsMemory() && v.Op != OpPPC64LoweredMove)) { + // On AIX, only writing will fault. + // LoweredMove is a special case because it's considered as a "mem" as it stores on arg0 but arg1 is accessed as a load and should be checked. + ptrs = append(ptrs, v.Args[1]) + } + + for _, ptr := range ptrs { + // Check to make sure the offset is small. + switch opcodeTable[v.Op].auxType { + case auxSym: + if v.Aux != nil { + continue + } + case auxSymOff: + if v.Aux != nil || v.AuxInt < 0 || v.AuxInt >= minZeroPage { + continue + } + case auxSymValAndOff: + off := ValAndOff(v.AuxInt).Off() + if v.Aux != nil || off < 0 || off >= minZeroPage { + continue + } + case auxInt32: + // Mips uses this auxType for atomic add constant. It does not affect the effective address. + case auxInt64: + // ARM uses this auxType for duffcopy/duffzero/alignment info. + // It does not affect the effective address. + case auxNone: + // offset is zero. + default: + v.Fatalf("can't handle aux %s (type %d) yet\n", v.auxString(), int(opcodeTable[v.Op].auxType)) + } + // This instruction is guaranteed to fault if ptr is nil. + // Any previous nil check op is unnecessary. + unnecessary.set(ptr.ID, int32(i)) + } + } + // Remove values we've clobbered with OpUnknown. + i := firstToRemove + for j := i; j < len(b.Values); j++ { + v := b.Values[j] + if v.Op != OpUnknown { + if !notStmtBoundary(v.Op) && pendingLines.contains(v.Pos) { // Late in compilation, so any remaining NotStmt values are probably okay now. + v.Pos = v.Pos.WithIsStmt() + pendingLines.remove(v.Pos) + } + b.Values[i] = v + i++ + } + } + + if pendingLines.contains(b.Pos) { + b.Pos = b.Pos.WithIsStmt() + } + + b.truncateValues(i) + + // TODO: if b.Kind == BlockPlain, start the analysis in the subsequent block to find + // more unnecessary nil checks. Would fix test/nilptr3.go:159. + } +} diff --git a/go/src/cmd/compile/internal/ssa/nilcheck_test.go b/go/src/cmd/compile/internal/ssa/nilcheck_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6c89b1e18569f8fcbf6d2957d7f369063bd1a0f6 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/nilcheck_test.go @@ -0,0 +1,438 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "strconv" + "testing" +) + +func BenchmarkNilCheckDeep1(b *testing.B) { benchmarkNilCheckDeep(b, 1) } +func BenchmarkNilCheckDeep10(b *testing.B) { benchmarkNilCheckDeep(b, 10) } +func BenchmarkNilCheckDeep100(b *testing.B) { benchmarkNilCheckDeep(b, 100) } +func BenchmarkNilCheckDeep1000(b *testing.B) { benchmarkNilCheckDeep(b, 1000) } +func BenchmarkNilCheckDeep10000(b *testing.B) { benchmarkNilCheckDeep(b, 10000) } + +// benchmarkNilCheckDeep is a stress test of nilcheckelim. +// It uses the worst possible input: A linear string of +// nil checks, none of which can be eliminated. +// Run with multiple depths to observe big-O behavior. +func benchmarkNilCheckDeep(b *testing.B, depth int) { + c := testConfig(b) + ptrType := c.config.Types.BytePtr + + var blocs []bloc + blocs = append(blocs, + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto(blockn(0)), + ), + ) + for i := 0; i < depth; i++ { + blocs = append(blocs, + Bloc(blockn(i), + Valu(ptrn(i), OpAddr, ptrType, 0, nil, "sb"), + Valu(booln(i), OpIsNonNil, c.config.Types.Bool, 0, nil, ptrn(i)), + If(booln(i), blockn(i+1), "exit"), + ), + ) + } + blocs = append(blocs, + Bloc(blockn(depth), Goto("exit")), + Bloc("exit", Exit("mem")), + ) + + fun := c.Fun("entry", blocs...) + + CheckFunc(fun.f) + b.SetBytes(int64(depth)) // helps for eyeballing linearity + b.ResetTimer() + b.ReportAllocs() + + for i := 0; i < b.N; i++ { + nilcheckelim(fun.f) + } +} + +func blockn(n int) string { return "b" + strconv.Itoa(n) } +func ptrn(n int) string { return "p" + strconv.Itoa(n) } +func booln(n int) string { return "c" + strconv.Itoa(n) } + +func isNilCheck(b *Block) bool { + return b.Kind == BlockIf && b.Controls[0].Op == OpIsNonNil +} + +// TestNilcheckSimple verifies that a second repeated nilcheck is removed. +func TestNilcheckSimple(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"), + Valu("bool1", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool1", "secondCheck", "exit")), + Bloc("secondCheck", + Valu("bool2", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool2", "extra", "exit")), + Bloc("extra", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + nilcheckelim(fun.f) + + // clean up the removed nil check + fuse(fun.f, fuseTypePlain) + deadcode(fun.f) + + CheckFunc(fun.f) + for _, b := range fun.f.Blocks { + if b == fun.blocks["secondCheck"] && isNilCheck(b) { + t.Errorf("secondCheck was not eliminated") + } + } +} + +// TestNilcheckDomOrder ensures that the nil check elimination isn't dependent +// on the order of the dominees. +func TestNilcheckDomOrder(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"), + Valu("bool1", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool1", "secondCheck", "exit")), + Bloc("exit", + Exit("mem")), + Bloc("secondCheck", + Valu("bool2", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool2", "extra", "exit")), + Bloc("extra", + Goto("exit"))) + + CheckFunc(fun.f) + nilcheckelim(fun.f) + + // clean up the removed nil check + fuse(fun.f, fuseTypePlain) + deadcode(fun.f) + + CheckFunc(fun.f) + for _, b := range fun.f.Blocks { + if b == fun.blocks["secondCheck"] && isNilCheck(b) { + t.Errorf("secondCheck was not eliminated") + } + } +} + +// TestNilcheckAddr verifies that nilchecks of OpAddr constructed values are removed. +func TestNilcheckAddr(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("ptr1", OpAddr, ptrType, 0, nil, "sb"), + Valu("bool1", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool1", "extra", "exit")), + Bloc("extra", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + nilcheckelim(fun.f) + + // clean up the removed nil check + fuse(fun.f, fuseTypePlain) + deadcode(fun.f) + + CheckFunc(fun.f) + for _, b := range fun.f.Blocks { + if b == fun.blocks["checkPtr"] && isNilCheck(b) { + t.Errorf("checkPtr was not eliminated") + } + } +} + +// TestNilcheckAddPtr verifies that nilchecks of OpAddPtr constructed values are removed. +func TestNilcheckAddPtr(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("off", OpConst64, c.config.Types.Int64, 20, nil), + Valu("ptr1", OpAddPtr, ptrType, 0, nil, "sb", "off"), + Valu("bool1", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool1", "extra", "exit")), + Bloc("extra", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + nilcheckelim(fun.f) + + // clean up the removed nil check + fuse(fun.f, fuseTypePlain) + deadcode(fun.f) + + CheckFunc(fun.f) + for _, b := range fun.f.Blocks { + if b == fun.blocks["checkPtr"] && isNilCheck(b) { + t.Errorf("checkPtr was not eliminated") + } + } +} + +// TestNilcheckPhi tests that nil checks of phis, for which all values are known to be +// non-nil are removed. +func TestNilcheckPhi(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil), + Valu("baddr", OpLocalAddr, c.config.Types.Bool, 0, StringToAux("b"), "sp", "mem"), + Valu("bool1", OpLoad, c.config.Types.Bool, 0, nil, "baddr", "mem"), + If("bool1", "b1", "b2")), + Bloc("b1", + Valu("ptr1", OpAddr, ptrType, 0, nil, "sb"), + Goto("checkPtr")), + Bloc("b2", + Valu("ptr2", OpAddr, ptrType, 0, nil, "sb"), + Goto("checkPtr")), + // both ptr1 and ptr2 are guaranteed non-nil here + Bloc("checkPtr", + Valu("phi", OpPhi, ptrType, 0, nil, "ptr1", "ptr2"), + Valu("bool2", OpIsNonNil, c.config.Types.Bool, 0, nil, "phi"), + If("bool2", "extra", "exit")), + Bloc("extra", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + nilcheckelim(fun.f) + + // clean up the removed nil check + fuse(fun.f, fuseTypePlain) + deadcode(fun.f) + + CheckFunc(fun.f) + for _, b := range fun.f.Blocks { + if b == fun.blocks["checkPtr"] && isNilCheck(b) { + t.Errorf("checkPtr was not eliminated") + } + } +} + +// TestNilcheckKeepRemove verifies that duplicate checks of the same pointer +// are removed, but checks of different pointers are not. +func TestNilcheckKeepRemove(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"), + Valu("bool1", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool1", "differentCheck", "exit")), + Bloc("differentCheck", + Valu("ptr2", OpLoad, ptrType, 0, nil, "sb", "mem"), + Valu("bool2", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr2"), + If("bool2", "secondCheck", "exit")), + Bloc("secondCheck", + Valu("bool3", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool3", "extra", "exit")), + Bloc("extra", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + nilcheckelim(fun.f) + + // clean up the removed nil check + fuse(fun.f, fuseTypePlain) + deadcode(fun.f) + + CheckFunc(fun.f) + foundDifferentCheck := false + for _, b := range fun.f.Blocks { + if b == fun.blocks["secondCheck"] && isNilCheck(b) { + t.Errorf("secondCheck was not eliminated") + } + if b == fun.blocks["differentCheck"] && isNilCheck(b) { + foundDifferentCheck = true + } + } + if !foundDifferentCheck { + t.Errorf("removed differentCheck, but shouldn't have") + } +} + +// TestNilcheckInFalseBranch tests that nil checks in the false branch of a nilcheck +// block are *not* removed. +func TestNilcheckInFalseBranch(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"), + Valu("bool1", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool1", "extra", "secondCheck")), + Bloc("secondCheck", + Valu("bool2", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool2", "extra", "thirdCheck")), + Bloc("thirdCheck", + Valu("bool3", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool3", "extra", "exit")), + Bloc("extra", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + nilcheckelim(fun.f) + + // clean up the removed nil check + fuse(fun.f, fuseTypePlain) + deadcode(fun.f) + + CheckFunc(fun.f) + foundSecondCheck := false + foundThirdCheck := false + for _, b := range fun.f.Blocks { + if b == fun.blocks["secondCheck"] && isNilCheck(b) { + foundSecondCheck = true + } + if b == fun.blocks["thirdCheck"] && isNilCheck(b) { + foundThirdCheck = true + } + } + if !foundSecondCheck { + t.Errorf("removed secondCheck, but shouldn't have [false branch]") + } + if !foundThirdCheck { + t.Errorf("removed thirdCheck, but shouldn't have [false branch]") + } +} + +// TestNilcheckUser verifies that a user nil check that dominates a generated nil check +// wil remove the generated nil check. +func TestNilcheckUser(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"), + Valu("nilptr", OpConstNil, ptrType, 0, nil), + Valu("bool1", OpNeqPtr, c.config.Types.Bool, 0, nil, "ptr1", "nilptr"), + If("bool1", "secondCheck", "exit")), + Bloc("secondCheck", + Valu("bool2", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool2", "extra", "exit")), + Bloc("extra", + Goto("exit")), + Bloc("exit", + Exit("mem"))) + + CheckFunc(fun.f) + // we need the opt here to rewrite the user nilcheck + opt(fun.f) + nilcheckelim(fun.f) + + // clean up the removed nil check + fuse(fun.f, fuseTypePlain) + deadcode(fun.f) + + CheckFunc(fun.f) + for _, b := range fun.f.Blocks { + if b == fun.blocks["secondCheck"] && isNilCheck(b) { + t.Errorf("secondCheck was not eliminated") + } + } +} + +// TestNilcheckBug reproduces a bug in nilcheckelim found by compiling math/big +func TestNilcheckBug(t *testing.T) { + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Goto("checkPtr")), + Bloc("checkPtr", + Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"), + Valu("nilptr", OpConstNil, ptrType, 0, nil), + Valu("bool1", OpNeqPtr, c.config.Types.Bool, 0, nil, "ptr1", "nilptr"), + If("bool1", "secondCheck", "couldBeNil")), + Bloc("couldBeNil", + Goto("secondCheck")), + Bloc("secondCheck", + Valu("bool2", OpIsNonNil, c.config.Types.Bool, 0, nil, "ptr1"), + If("bool2", "extra", "exit")), + Bloc("extra", + // prevent fuse from eliminating this block + Valu("store", OpStore, types.TypeMem, 0, ptrType, "ptr1", "nilptr", "mem"), + Goto("exit")), + Bloc("exit", + Valu("phi", OpPhi, types.TypeMem, 0, nil, "mem", "store"), + Exit("phi"))) + + CheckFunc(fun.f) + // we need the opt here to rewrite the user nilcheck + opt(fun.f) + nilcheckelim(fun.f) + + // clean up the removed nil check + fuse(fun.f, fuseTypePlain) + deadcode(fun.f) + + CheckFunc(fun.f) + foundSecondCheck := false + for _, b := range fun.f.Blocks { + if b == fun.blocks["secondCheck"] && isNilCheck(b) { + foundSecondCheck = true + } + } + if !foundSecondCheck { + t.Errorf("secondCheck was eliminated, but shouldn't have") + } +} diff --git a/go/src/cmd/compile/internal/ssa/numberlines.go b/go/src/cmd/compile/internal/ssa/numberlines.go new file mode 100644 index 0000000000000000000000000000000000000000..bd7794042a280b072705035cbe5d259398e483d8 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/numberlines.go @@ -0,0 +1,262 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/internal/src" + "fmt" + "sort" +) + +func isPoorStatementOp(op Op) bool { + switch op { + // Note that Nilcheck often vanishes, but when it doesn't, you'd love to start the statement there + // so that a debugger-user sees the stop before the panic, and can examine the value. + case OpAddr, OpLocalAddr, OpOffPtr, OpStructSelect, OpPhi, OpITab, OpIData, + OpIMake, OpStringMake, OpSliceMake, OpStructMake, + OpConstBool, OpConst8, OpConst16, OpConst32, OpConst64, OpConst32F, OpConst64F, OpSB, OpSP, + OpArgIntReg, OpArgFloatReg: + return true + } + return false +} + +// nextGoodStatementIndex returns an index at i or later that is believed +// to be a good place to start the statement for b. This decision is +// based on v's Op, the possibility of a better later operation, and +// whether the values following i are the same line as v. +// If a better statement index isn't found, then i is returned. +func nextGoodStatementIndex(v *Value, i int, b *Block) int { + // If the value is the last one in the block, too bad, it will have to do + // (this assumes that the value ordering vaguely corresponds to the source + // program execution order, which tends to be true directly after ssa is + // first built). + if i >= len(b.Values)-1 { + return i + } + // Skip the likely-ephemeral/fragile opcodes expected to vanish in a rewrite. + if !isPoorStatementOp(v.Op) { + return i + } + // Look ahead to see what the line number is on the next thing that could be a boundary. + for j := i + 1; j < len(b.Values); j++ { + u := b.Values[j] + if u.Pos.IsStmt() == src.PosNotStmt { // ignore non-statements + continue + } + if u.Pos.SameFileAndLine(v.Pos) { + if isPoorStatementOp(u.Op) { + continue // Keep looking, this is also not a good statement op + } + return j + } + return i + } + return i +} + +// notStmtBoundary reports whether a value with opcode op can never be a statement +// boundary. Such values don't correspond to a user's understanding of a +// statement boundary. +func notStmtBoundary(op Op) bool { + switch op { + case OpCopy, OpPhi, OpVarDef, OpVarLive, OpUnknown, OpFwdRef, OpArg, OpArgIntReg, OpArgFloatReg: + return true + } + return false +} + +func (b *Block) FirstPossibleStmtValue() *Value { + for _, v := range b.Values { + if notStmtBoundary(v.Op) { + continue + } + return v + } + return nil +} + +func flc(p src.XPos) string { + if p == src.NoXPos { + return "none" + } + return fmt.Sprintf("(%d):%d:%d", p.FileIndex(), p.Line(), p.Col()) +} + +type fileAndPair struct { + f int32 + lp lineRange +} + +type fileAndPairs []fileAndPair + +func (fap fileAndPairs) Len() int { + return len(fap) +} +func (fap fileAndPairs) Less(i, j int) bool { + return fap[i].f < fap[j].f +} +func (fap fileAndPairs) Swap(i, j int) { + fap[i], fap[j] = fap[j], fap[i] +} + +// -d=ssa/number_lines/stats=1 (that bit) for line and file distribution statistics +// -d=ssa/number_lines/debug for information about why particular values are marked as statements. +func numberLines(f *Func) { + po := f.Postorder() + endlines := make(map[ID]src.XPos) + ranges := make(map[int]lineRange) + note := func(p src.XPos) { + line := uint32(p.Line()) + i := int(p.FileIndex()) + lp, found := ranges[i] + change := false + if line < lp.first || !found { + lp.first = line + change = true + } + if line > lp.last { + lp.last = line + change = true + } + if change { + ranges[i] = lp + } + } + + // Visit in reverse post order so that all non-loop predecessors come first. + for j := len(po) - 1; j >= 0; j-- { + b := po[j] + // Find the first interesting position and check to see if it differs from any predecessor + firstPos := src.NoXPos + firstPosIndex := -1 + if b.Pos.IsStmt() != src.PosNotStmt { + note(b.Pos) + } + for i := 0; i < len(b.Values); i++ { + v := b.Values[i] + if v.Pos.IsStmt() != src.PosNotStmt { + note(v.Pos) + // skip ahead to better instruction for this line if possible + i = nextGoodStatementIndex(v, i, b) + v = b.Values[i] + firstPosIndex = i + firstPos = v.Pos + v.Pos = firstPos.WithDefaultStmt() // default to default + break + } + } + + if firstPosIndex == -1 { // Effectively empty block, check block's own Pos, consider preds. + line := src.NoXPos + for _, p := range b.Preds { + pbi := p.Block().ID + if !endlines[pbi].SameFileAndLine(line) { + if line == src.NoXPos { + line = endlines[pbi] + continue + } else { + line = src.NoXPos + break + } + + } + } + // If the block has no statement itself and is effectively empty, tag it w/ predecessor(s) but not as a statement + if b.Pos.IsStmt() == src.PosNotStmt { + b.Pos = line + endlines[b.ID] = line + continue + } + // If the block differs from its predecessors, mark it as a statement + if line == src.NoXPos || !line.SameFileAndLine(b.Pos) { + b.Pos = b.Pos.WithIsStmt() + if f.pass.debug > 0 { + fmt.Printf("Mark stmt effectively-empty-block %s %s %s\n", f.Name, b, flc(b.Pos)) + } + } + endlines[b.ID] = b.Pos + continue + } + // check predecessors for any difference; if firstPos differs, then it is a boundary. + if len(b.Preds) == 0 { // Don't forget the entry block + b.Values[firstPosIndex].Pos = firstPos.WithIsStmt() + if f.pass.debug > 0 { + fmt.Printf("Mark stmt entry-block %s %s %s %s\n", f.Name, b, b.Values[firstPosIndex], flc(firstPos)) + } + } else { // differing pred + for _, p := range b.Preds { + pbi := p.Block().ID + if !endlines[pbi].SameFileAndLine(firstPos) { + b.Values[firstPosIndex].Pos = firstPos.WithIsStmt() + if f.pass.debug > 0 { + fmt.Printf("Mark stmt differing-pred %s %s %s %s, different=%s ending %s\n", + f.Name, b, b.Values[firstPosIndex], flc(firstPos), p.Block(), flc(endlines[pbi])) + } + break + } + } + } + // iterate forward setting each new (interesting) position as a statement boundary. + for i := firstPosIndex + 1; i < len(b.Values); i++ { + v := b.Values[i] + if v.Pos.IsStmt() == src.PosNotStmt { + continue + } + note(v.Pos) + // skip ahead if possible + i = nextGoodStatementIndex(v, i, b) + v = b.Values[i] + if !v.Pos.SameFileAndLine(firstPos) { + if f.pass.debug > 0 { + fmt.Printf("Mark stmt new line %s %s %s %s prev pos = %s\n", f.Name, b, v, flc(v.Pos), flc(firstPos)) + } + firstPos = v.Pos + v.Pos = v.Pos.WithIsStmt() + } else { + v.Pos = v.Pos.WithDefaultStmt() + } + } + if b.Pos.IsStmt() != src.PosNotStmt && !b.Pos.SameFileAndLine(firstPos) { + if f.pass.debug > 0 { + fmt.Printf("Mark stmt end of block differs %s %s %s prev pos = %s\n", f.Name, b, flc(b.Pos), flc(firstPos)) + } + b.Pos = b.Pos.WithIsStmt() + firstPos = b.Pos + } + endlines[b.ID] = firstPos + } + if f.pass.stats&1 != 0 { + // Report summary statistics on the shape of the sparse map about to be constructed + // TODO use this information to make sparse maps faster. + var entries fileAndPairs + for k, v := range ranges { + entries = append(entries, fileAndPair{int32(k), v}) + } + sort.Sort(entries) + total := uint64(0) // sum over files of maxline(file) - minline(file) + maxfile := int32(0) // max(file indices) + minline := uint32(0xffffffff) // min over files of minline(file) + maxline := uint32(0) // max over files of maxline(file) + for _, v := range entries { + if f.pass.stats > 1 { + f.LogStat("file", v.f, "low", v.lp.first, "high", v.lp.last) + } + total += uint64(v.lp.last - v.lp.first) + if maxfile < v.f { + maxfile = v.f + } + if minline > v.lp.first { + minline = v.lp.first + } + if maxline < v.lp.last { + maxline = v.lp.last + } + } + f.LogStat("SUM_LINE_RANGE", total, "MAXMIN_LINE_RANGE", maxline-minline, "MAXFILE", maxfile, "NFILES", len(entries)) + } + // cachedLineStarts is an empty sparse map for values that are included within ranges. + f.cachedLineStarts = newXposmap(ranges) +} diff --git a/go/src/cmd/compile/internal/ssa/op.go b/go/src/cmd/compile/internal/ssa/op.go new file mode 100644 index 0000000000000000000000000000000000000000..b279cf06bc05dd8ca983b260a0067b14b3cd5bd5 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/op.go @@ -0,0 +1,545 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/abi" + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/obj" + "fmt" + rtabi "internal/abi" + "strings" +) + +// An Op encodes the specific operation that a Value performs. +// Opcodes' semantics can be modified by the type and aux fields of the Value. +// For instance, OpAdd can be 32 or 64 bit, signed or unsigned, float or complex, depending on Value.Type. +// Semantics of each op are described in the opcode files in _gen/*Ops.go. +// There is one file for generic (architecture-independent) ops and one file +// for each architecture. +type Op int32 + +type opInfo struct { + name string + reg regInfo + auxType auxType + argLen int32 // the number of arguments, -1 if variable length + asm obj.As + generic bool // this is a generic (arch-independent) opcode + rematerializeable bool // this op is rematerializeable + commutative bool // this operation is commutative (e.g. addition) + resultInArg0 bool // (first, if a tuple) output of v and v.Args[0] must be allocated to the same register + resultNotInArgs bool // outputs must not be allocated to the same registers as inputs + clobberFlags bool // this op clobbers flags register + needIntTemp bool // need a temporary free integer register + call bool // is a function call + tailCall bool // is a tail call + nilCheck bool // this op is a nil check on arg0 + faultOnNilArg0 bool // this op will fault if arg0 is nil (and aux encodes a small offset) + faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset) + usesScratch bool // this op requires scratch memory space + hasSideEffects bool // for "reasons", not to be eliminated. E.g., atomic store, #19182. + zeroWidth bool // op never translates into any machine code. example: copy, which may sometimes translate to machine code, is not zero-width. + unsafePoint bool // this op is an unsafe point, i.e. not safe for async preemption + fixedReg bool // this op will be assigned a fixed register + symEffect SymEffect // effect this op has on symbol in aux + scale uint8 // amd64/386 indexed load scale +} + +type inputInfo struct { + idx int // index in Args array + regs regMask // allowed input registers +} + +type outputInfo struct { + idx int // index in output tuple + regs regMask // allowed output registers +} + +type regInfo struct { + // inputs encodes the register restrictions for an instruction's inputs. + // Each entry specifies an allowed register set for a particular input. + // They are listed in the order in which regalloc should pick a register + // from the register set (most constrained first). + // Inputs which do not need registers are not listed. + inputs []inputInfo + // clobbers encodes the set of registers that are overwritten by + // the instruction (other than the output registers). + clobbers regMask + // Instruction clobbers the register containing input 0. + clobbersArg0 bool + // Instruction clobbers the register containing input 1. + clobbersArg1 bool + // outputs is the same as inputs, but for the outputs of the instruction. + outputs []outputInfo +} + +func (r *regInfo) String() string { + s := "" + s += "INS:\n" + for _, i := range r.inputs { + mask := fmt.Sprintf("%64b", i.regs) + mask = strings.ReplaceAll(mask, "0", ".") + s += fmt.Sprintf("%2d |%s|\n", i.idx, mask) + } + s += "OUTS:\n" + for _, i := range r.outputs { + mask := fmt.Sprintf("%64b", i.regs) + mask = strings.ReplaceAll(mask, "0", ".") + s += fmt.Sprintf("%2d |%s|\n", i.idx, mask) + } + s += "CLOBBERS:\n" + mask := fmt.Sprintf("%64b", r.clobbers) + mask = strings.ReplaceAll(mask, "0", ".") + s += fmt.Sprintf(" |%s|\n", mask) + return s +} + +type auxType int8 + +type AuxNameOffset struct { + Name *ir.Name + Offset int64 +} + +func (a *AuxNameOffset) CanBeAnSSAAux() {} +func (a *AuxNameOffset) String() string { + return fmt.Sprintf("%s+%d", a.Name.Sym().Name, a.Offset) +} + +func (a *AuxNameOffset) FrameOffset() int64 { + return a.Name.FrameOffset() + a.Offset +} + +type AuxCall struct { + Fn *obj.LSym + reg *regInfo // regInfo for this call + abiInfo *abi.ABIParamResultInfo +} + +// Reg returns the regInfo for a given call, combining the derived in/out register masks +// with the machine-specific register information in the input i. (The machine-specific +// regInfo is much handier at the call site than it is when the AuxCall is being constructed, +// therefore do this lazily). +// +// TODO: there is a Clever Hack that allows pre-generation of a small-ish number of the slices +// of inputInfo and outputInfo used here, provided that we are willing to reorder the inputs +// and outputs from calls, so that all integer registers come first, then all floating registers. +// At this point (active development of register ABI) that is very premature, +// but if this turns out to be a cost, we could do it. +func (a *AuxCall) Reg(i *regInfo, c *Config) *regInfo { + if a.reg.clobbers != 0 { + // Already updated + return a.reg + } + if a.abiInfo.InRegistersUsed()+a.abiInfo.OutRegistersUsed() == 0 { + // Shortcut for zero case, also handles old ABI. + a.reg = i + return a.reg + } + + k := len(i.inputs) + for _, p := range a.abiInfo.InParams() { + for _, r := range p.Registers { + m := archRegForAbiReg(r, c) + a.reg.inputs = append(a.reg.inputs, inputInfo{idx: k, regs: (1 << m)}) + k++ + } + } + a.reg.inputs = append(a.reg.inputs, i.inputs...) // These are less constrained, thus should come last + k = len(i.outputs) + for _, p := range a.abiInfo.OutParams() { + for _, r := range p.Registers { + m := archRegForAbiReg(r, c) + a.reg.outputs = append(a.reg.outputs, outputInfo{idx: k, regs: (1 << m)}) + k++ + } + } + a.reg.outputs = append(a.reg.outputs, i.outputs...) + a.reg.clobbers = i.clobbers + return a.reg +} +func (a *AuxCall) ABI() *abi.ABIConfig { + return a.abiInfo.Config() +} +func (a *AuxCall) ABIInfo() *abi.ABIParamResultInfo { + return a.abiInfo +} +func (a *AuxCall) ResultReg(c *Config) *regInfo { + if a.abiInfo.OutRegistersUsed() == 0 { + return a.reg + } + if len(a.reg.inputs) > 0 { + return a.reg + } + k := 0 + for _, p := range a.abiInfo.OutParams() { + for _, r := range p.Registers { + m := archRegForAbiReg(r, c) + a.reg.inputs = append(a.reg.inputs, inputInfo{idx: k, regs: (1 << m)}) + k++ + } + } + return a.reg +} + +// For ABI register index r, returns the (dense) register number used in +// SSA backend. +func archRegForAbiReg(r abi.RegIndex, c *Config) uint8 { + var m int8 + if int(r) < len(c.intParamRegs) { + m = c.intParamRegs[r] + } else { + m = c.floatParamRegs[int(r)-len(c.intParamRegs)] + } + return uint8(m) +} + +// For ABI register index r, returns the register number used in the obj +// package (assembler). +func ObjRegForAbiReg(r abi.RegIndex, c *Config) int16 { + m := archRegForAbiReg(r, c) + return c.registers[m].objNum +} + +// ArgWidth returns the amount of stack needed for all the inputs +// and outputs of a function or method, including ABI-defined parameter +// slots and ABI-defined spill slots for register-resident parameters. +// +// The name is taken from the types package's ArgWidth(), +// which predated changes to the ABI; this version handles those changes. +func (a *AuxCall) ArgWidth() int64 { + return a.abiInfo.ArgWidth() +} + +// ParamAssignmentForResult returns the ABI Parameter assignment for result which (indexed 0, 1, etc). +func (a *AuxCall) ParamAssignmentForResult(which int64) *abi.ABIParamAssignment { + return a.abiInfo.OutParam(int(which)) +} + +// OffsetOfResult returns the SP offset of result which (indexed 0, 1, etc). +func (a *AuxCall) OffsetOfResult(which int64) int64 { + n := int64(a.abiInfo.OutParam(int(which)).Offset()) + return n +} + +// OffsetOfArg returns the SP offset of argument which (indexed 0, 1, etc). +// If the call is to a method, the receiver is the first argument (i.e., index 0) +func (a *AuxCall) OffsetOfArg(which int64) int64 { + n := int64(a.abiInfo.InParam(int(which)).Offset()) + return n +} + +// RegsOfResult returns the register(s) used for result which (indexed 0, 1, etc). +func (a *AuxCall) RegsOfResult(which int64) []abi.RegIndex { + return a.abiInfo.OutParam(int(which)).Registers +} + +// RegsOfArg returns the register(s) used for argument which (indexed 0, 1, etc). +// If the call is to a method, the receiver is the first argument (i.e., index 0) +func (a *AuxCall) RegsOfArg(which int64) []abi.RegIndex { + return a.abiInfo.InParam(int(which)).Registers +} + +// NameOfResult returns the ir.Name of result which (indexed 0, 1, etc). +func (a *AuxCall) NameOfResult(which int64) *ir.Name { + return a.abiInfo.OutParam(int(which)).Name +} + +// TypeOfResult returns the type of result which (indexed 0, 1, etc). +func (a *AuxCall) TypeOfResult(which int64) *types.Type { + return a.abiInfo.OutParam(int(which)).Type +} + +// TypeOfArg returns the type of argument which (indexed 0, 1, etc). +// If the call is to a method, the receiver is the first argument (i.e., index 0) +func (a *AuxCall) TypeOfArg(which int64) *types.Type { + return a.abiInfo.InParam(int(which)).Type +} + +// SizeOfResult returns the size of result which (indexed 0, 1, etc). +func (a *AuxCall) SizeOfResult(which int64) int64 { + return a.TypeOfResult(which).Size() +} + +// SizeOfArg returns the size of argument which (indexed 0, 1, etc). +// If the call is to a method, the receiver is the first argument (i.e., index 0) +func (a *AuxCall) SizeOfArg(which int64) int64 { + return a.TypeOfArg(which).Size() +} + +// NResults returns the number of results. +func (a *AuxCall) NResults() int64 { + return int64(len(a.abiInfo.OutParams())) +} + +// LateExpansionResultType returns the result type (including trailing mem) +// for a call that will be expanded later in the SSA phase. +func (a *AuxCall) LateExpansionResultType() *types.Type { + var tys []*types.Type + for i := int64(0); i < a.NResults(); i++ { + tys = append(tys, a.TypeOfResult(i)) + } + tys = append(tys, types.TypeMem) + return types.NewResults(tys) +} + +// NArgs returns the number of arguments (including receiver, if there is one). +func (a *AuxCall) NArgs() int64 { + return int64(len(a.abiInfo.InParams())) +} + +// String returns "AuxCall{}" +func (a *AuxCall) String() string { + var fn string + if a.Fn == nil { + fn = "AuxCall{nil" // could be interface/closure etc. + } else { + fn = fmt.Sprintf("AuxCall{%v", a.Fn) + } + // TODO how much of the ABI should be printed? + + return fn + "}" +} + +// StaticAuxCall returns an AuxCall for a static call. +func StaticAuxCall(sym *obj.LSym, paramResultInfo *abi.ABIParamResultInfo) *AuxCall { + if paramResultInfo == nil { + panic(fmt.Errorf("Nil paramResultInfo, sym=%v", sym)) + } + var reg *regInfo + if paramResultInfo.InRegistersUsed()+paramResultInfo.OutRegistersUsed() > 0 { + reg = ®Info{} + } + return &AuxCall{Fn: sym, abiInfo: paramResultInfo, reg: reg} +} + +// InterfaceAuxCall returns an AuxCall for an interface call. +func InterfaceAuxCall(paramResultInfo *abi.ABIParamResultInfo) *AuxCall { + var reg *regInfo + if paramResultInfo.InRegistersUsed()+paramResultInfo.OutRegistersUsed() > 0 { + reg = ®Info{} + } + return &AuxCall{Fn: nil, abiInfo: paramResultInfo, reg: reg} +} + +// ClosureAuxCall returns an AuxCall for a closure call. +func ClosureAuxCall(paramResultInfo *abi.ABIParamResultInfo) *AuxCall { + var reg *regInfo + if paramResultInfo.InRegistersUsed()+paramResultInfo.OutRegistersUsed() > 0 { + reg = ®Info{} + } + return &AuxCall{Fn: nil, abiInfo: paramResultInfo, reg: reg} +} + +func (*AuxCall) CanBeAnSSAAux() {} + +// OwnAuxCall returns a function's own AuxCall. +func OwnAuxCall(fn *obj.LSym, paramResultInfo *abi.ABIParamResultInfo) *AuxCall { + // TODO if this remains identical to ClosureAuxCall above after new ABI is done, should deduplicate. + var reg *regInfo + if paramResultInfo.InRegistersUsed()+paramResultInfo.OutRegistersUsed() > 0 { + reg = ®Info{} + } + return &AuxCall{Fn: fn, abiInfo: paramResultInfo, reg: reg} +} + +const ( + auxNone auxType = iota + auxBool // auxInt is 0/1 for false/true + auxInt8 // auxInt is an 8-bit integer + auxInt16 // auxInt is a 16-bit integer + auxInt32 // auxInt is a 32-bit integer + auxInt64 // auxInt is a 64-bit integer + auxInt128 // auxInt represents a 128-bit integer. Always 0. + auxUInt8 // auxInt is an 8-bit unsigned integer + auxFloat32 // auxInt is a float32 (encoded with math.Float64bits) + auxFloat64 // auxInt is a float64 (encoded with math.Float64bits) + auxFlagConstant // auxInt is a flagConstant + auxCCop // auxInt is a ssa.Op that represents a flags-to-bool conversion (e.g. LessThan) + auxNameOffsetInt8 // aux is a &struct{Name ir.Name, Offset int64}; auxInt is index in parameter registers array + auxString // aux is a string + auxSym // aux is a symbol (a *ir.Name for locals, an *obj.LSym for globals, or nil for none) + auxSymOff // aux is a symbol, auxInt is an offset + auxSymValAndOff // aux is a symbol, auxInt is a ValAndOff + auxTyp // aux is a type + auxTypSize // aux is a type, auxInt is a size, must have Aux.(Type).Size() == AuxInt + auxCall // aux is a *ssa.AuxCall + auxCallOff // aux is a *ssa.AuxCall, AuxInt is int64 param (in+out) size + + auxPanicBoundsC // constant for a bounds failure + auxPanicBoundsCC // two constants for a bounds failure + + // architecture specific aux types + auxARM64BitField // aux is an arm64 bitfield lsb and width packed into auxInt + auxARM64ConditionalParams // aux is a structure, which contains condition, NZCV flags and constant with indicator of using it + auxS390XRotateParams // aux is a s390x rotate parameters object encoding start bit, end bit and rotate amount + auxS390XCCMask // aux is a s390x 4-bit condition code mask + auxS390XCCMaskInt8 // aux is a s390x 4-bit condition code mask, auxInt is an int8 immediate + auxS390XCCMaskUint8 // aux is a s390x 4-bit condition code mask, auxInt is a uint8 immediate +) + +// A SymEffect describes the effect that an SSA Value has on the variable +// identified by the symbol in its Aux field. +type SymEffect int8 + +const ( + SymRead SymEffect = 1 << iota + SymWrite + SymAddr + + SymRdWr = SymRead | SymWrite + + SymNone SymEffect = 0 +) + +// A Sym represents a symbolic offset from a base register. +// Currently a Sym can be one of 3 things: +// - a *ir.Name, for an offset from SP (the stack pointer) +// - a *obj.LSym, for an offset from SB (the global pointer) +// - nil, for no offset +type Sym interface { + Aux + CanBeAnSSASym() +} + +// A ValAndOff is used by the several opcodes. It holds +// both a value and a pointer offset. +// A ValAndOff is intended to be encoded into an AuxInt field. +// The zero ValAndOff encodes a value of 0 and an offset of 0. +// The high 32 bits hold a value. +// The low 32 bits hold a pointer offset. +type ValAndOff int64 + +func (x ValAndOff) Val() int32 { return int32(int64(x) >> 32) } +func (x ValAndOff) Val64() int64 { return int64(x) >> 32 } +func (x ValAndOff) Val16() int16 { return int16(int64(x) >> 32) } +func (x ValAndOff) Val8() int8 { return int8(int64(x) >> 32) } + +func (x ValAndOff) Off64() int64 { return int64(int32(x)) } +func (x ValAndOff) Off() int32 { return int32(x) } + +func (x ValAndOff) String() string { + return fmt.Sprintf("val=%d,off=%d", x.Val(), x.Off()) +} + +// validVal reports whether the value can be used +// as an argument to makeValAndOff. +func validVal(val int64) bool { + return val == int64(int32(val)) +} + +func makeValAndOff(val, off int32) ValAndOff { + return ValAndOff(int64(val)<<32 + int64(uint32(off))) +} + +func (x ValAndOff) canAdd32(off int32) bool { + newoff := x.Off64() + int64(off) + return newoff == int64(int32(newoff)) +} +func (x ValAndOff) canAdd64(off int64) bool { + newoff := x.Off64() + off + return newoff == int64(int32(newoff)) +} + +func (x ValAndOff) addOffset32(off int32) ValAndOff { + if !x.canAdd32(off) { + panic("invalid ValAndOff.addOffset32") + } + return makeValAndOff(x.Val(), x.Off()+off) +} +func (x ValAndOff) addOffset64(off int64) ValAndOff { + if !x.canAdd64(off) { + panic("invalid ValAndOff.addOffset64") + } + return makeValAndOff(x.Val(), x.Off()+int32(off)) +} + +// int128 is a type that stores a 128-bit constant. +// The only allowed constant right now is 0, so we can cheat quite a bit. +type int128 int64 + +type BoundsKind uint8 + +const ( + BoundsIndex BoundsKind = iota // indexing operation, 0 <= idx < len failed + BoundsIndexU // ... with unsigned idx + BoundsSliceAlen // 2-arg slicing operation, 0 <= high <= len failed + BoundsSliceAlenU // ... with unsigned high + BoundsSliceAcap // 2-arg slicing operation, 0 <= high <= cap failed + BoundsSliceAcapU // ... with unsigned high + BoundsSliceB // 2-arg slicing operation, 0 <= low <= high failed + BoundsSliceBU // ... with unsigned low + BoundsSlice3Alen // 3-arg slicing operation, 0 <= max <= len failed + BoundsSlice3AlenU // ... with unsigned max + BoundsSlice3Acap // 3-arg slicing operation, 0 <= max <= cap failed + BoundsSlice3AcapU // ... with unsigned max + BoundsSlice3B // 3-arg slicing operation, 0 <= high <= max failed + BoundsSlice3BU // ... with unsigned high + BoundsSlice3C // 3-arg slicing operation, 0 <= low <= high failed + BoundsSlice3CU // ... with unsigned low + BoundsConvert // conversion to array pointer failed + BoundsKindCount +) + +// Returns the bounds error code needed by the runtime, and +// whether the x field is signed. +func (b BoundsKind) Code() (rtabi.BoundsErrorCode, bool) { + switch b { + case BoundsIndex: + return rtabi.BoundsIndex, true + case BoundsIndexU: + return rtabi.BoundsIndex, false + case BoundsSliceAlen: + return rtabi.BoundsSliceAlen, true + case BoundsSliceAlenU: + return rtabi.BoundsSliceAlen, false + case BoundsSliceAcap: + return rtabi.BoundsSliceAcap, true + case BoundsSliceAcapU: + return rtabi.BoundsSliceAcap, false + case BoundsSliceB: + return rtabi.BoundsSliceB, true + case BoundsSliceBU: + return rtabi.BoundsSliceB, false + case BoundsSlice3Alen: + return rtabi.BoundsSlice3Alen, true + case BoundsSlice3AlenU: + return rtabi.BoundsSlice3Alen, false + case BoundsSlice3Acap: + return rtabi.BoundsSlice3Acap, true + case BoundsSlice3AcapU: + return rtabi.BoundsSlice3Acap, false + case BoundsSlice3B: + return rtabi.BoundsSlice3B, true + case BoundsSlice3BU: + return rtabi.BoundsSlice3B, false + case BoundsSlice3C: + return rtabi.BoundsSlice3C, true + case BoundsSlice3CU: + return rtabi.BoundsSlice3C, false + case BoundsConvert: + return rtabi.BoundsConvert, false + default: + base.Fatalf("bad bounds kind %d", b) + return 0, false + } +} + +// arm64BitField is the GO type of ARM64BitField auxInt. +// if x is an ARM64BitField, then width=x&0xff, lsb=(x>>8)&0xff, and +// width+lsb<64 for 64-bit variant, width+lsb<32 for 32-bit variant. +// the meaning of width and lsb are instruction-dependent. +type arm64BitField int16 + +// arm64ConditionalParams is the GO type of ARM64ConditionalParams auxInt. +type arm64ConditionalParams struct { + cond Op // Condition code to evaluate + nzcv uint8 // Fallback NZCV flags value when condition is false + constValue uint8 // Immediate value for constant comparisons + ind bool // Constant comparison indicator +} diff --git a/go/src/cmd/compile/internal/ssa/opGen.go b/go/src/cmd/compile/internal/ssa/opGen.go new file mode 100644 index 0000000000000000000000000000000000000000..db0a152ae884d8dbbd2f8635c75ed393e6670a69 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/opGen.go @@ -0,0 +1,96689 @@ +// Code generated from _gen/*Ops.go using 'go generate'; DO NOT EDIT. + +package ssa + +import ( + "cmd/internal/obj" + "cmd/internal/obj/arm" + "cmd/internal/obj/arm64" + "cmd/internal/obj/loong64" + "cmd/internal/obj/mips" + "cmd/internal/obj/ppc64" + "cmd/internal/obj/riscv" + "cmd/internal/obj/s390x" + "cmd/internal/obj/wasm" + "cmd/internal/obj/x86" +) + +const ( + BlockInvalid BlockKind = iota + + Block386EQ + Block386NE + Block386LT + Block386LE + Block386GT + Block386GE + Block386OS + Block386OC + Block386ULT + Block386ULE + Block386UGT + Block386UGE + Block386EQF + Block386NEF + Block386ORD + Block386NAN + + BlockAMD64EQ + BlockAMD64NE + BlockAMD64LT + BlockAMD64LE + BlockAMD64GT + BlockAMD64GE + BlockAMD64OS + BlockAMD64OC + BlockAMD64ULT + BlockAMD64ULE + BlockAMD64UGT + BlockAMD64UGE + BlockAMD64EQF + BlockAMD64NEF + BlockAMD64ORD + BlockAMD64NAN + BlockAMD64JUMPTABLE + + BlockARMEQ + BlockARMNE + BlockARMLT + BlockARMLE + BlockARMGT + BlockARMGE + BlockARMULT + BlockARMULE + BlockARMUGT + BlockARMUGE + BlockARMLTnoov + BlockARMLEnoov + BlockARMGTnoov + BlockARMGEnoov + + BlockARM64EQ + BlockARM64NE + BlockARM64LT + BlockARM64LE + BlockARM64GT + BlockARM64GE + BlockARM64ULT + BlockARM64ULE + BlockARM64UGT + BlockARM64UGE + BlockARM64Z + BlockARM64NZ + BlockARM64ZW + BlockARM64NZW + BlockARM64TBZ + BlockARM64TBNZ + BlockARM64FLT + BlockARM64FLE + BlockARM64FGT + BlockARM64FGE + BlockARM64LTnoov + BlockARM64LEnoov + BlockARM64GTnoov + BlockARM64GEnoov + BlockARM64JUMPTABLE + + BlockLOONG64EQZ + BlockLOONG64NEZ + BlockLOONG64LTZ + BlockLOONG64LEZ + BlockLOONG64GTZ + BlockLOONG64GEZ + BlockLOONG64FPT + BlockLOONG64FPF + BlockLOONG64BEQ + BlockLOONG64BNE + BlockLOONG64BGE + BlockLOONG64BLT + BlockLOONG64BGEU + BlockLOONG64BLTU + BlockLOONG64JUMPTABLE + + BlockMIPSEQ + BlockMIPSNE + BlockMIPSLTZ + BlockMIPSLEZ + BlockMIPSGTZ + BlockMIPSGEZ + BlockMIPSFPT + BlockMIPSFPF + + BlockMIPS64EQ + BlockMIPS64NE + BlockMIPS64LTZ + BlockMIPS64LEZ + BlockMIPS64GTZ + BlockMIPS64GEZ + BlockMIPS64FPT + BlockMIPS64FPF + + BlockPPC64EQ + BlockPPC64NE + BlockPPC64LT + BlockPPC64LE + BlockPPC64GT + BlockPPC64GE + BlockPPC64FLT + BlockPPC64FLE + BlockPPC64FGT + BlockPPC64FGE + + BlockRISCV64BEQ + BlockRISCV64BNE + BlockRISCV64BLT + BlockRISCV64BGE + BlockRISCV64BLTU + BlockRISCV64BGEU + BlockRISCV64BEQZ + BlockRISCV64BNEZ + BlockRISCV64BLEZ + BlockRISCV64BGEZ + BlockRISCV64BLTZ + BlockRISCV64BGTZ + + BlockS390XBRC + BlockS390XCRJ + BlockS390XCGRJ + BlockS390XCLRJ + BlockS390XCLGRJ + BlockS390XCIJ + BlockS390XCGIJ + BlockS390XCLIJ + BlockS390XCLGIJ + + BlockPlain + BlockIf + BlockDefer + BlockRet + BlockRetJmp + BlockExit + BlockJumpTable + BlockFirst +) + +var blockString = [...]string{ + BlockInvalid: "BlockInvalid", + + Block386EQ: "EQ", + Block386NE: "NE", + Block386LT: "LT", + Block386LE: "LE", + Block386GT: "GT", + Block386GE: "GE", + Block386OS: "OS", + Block386OC: "OC", + Block386ULT: "ULT", + Block386ULE: "ULE", + Block386UGT: "UGT", + Block386UGE: "UGE", + Block386EQF: "EQF", + Block386NEF: "NEF", + Block386ORD: "ORD", + Block386NAN: "NAN", + + BlockAMD64EQ: "EQ", + BlockAMD64NE: "NE", + BlockAMD64LT: "LT", + BlockAMD64LE: "LE", + BlockAMD64GT: "GT", + BlockAMD64GE: "GE", + BlockAMD64OS: "OS", + BlockAMD64OC: "OC", + BlockAMD64ULT: "ULT", + BlockAMD64ULE: "ULE", + BlockAMD64UGT: "UGT", + BlockAMD64UGE: "UGE", + BlockAMD64EQF: "EQF", + BlockAMD64NEF: "NEF", + BlockAMD64ORD: "ORD", + BlockAMD64NAN: "NAN", + BlockAMD64JUMPTABLE: "JUMPTABLE", + + BlockARMEQ: "EQ", + BlockARMNE: "NE", + BlockARMLT: "LT", + BlockARMLE: "LE", + BlockARMGT: "GT", + BlockARMGE: "GE", + BlockARMULT: "ULT", + BlockARMULE: "ULE", + BlockARMUGT: "UGT", + BlockARMUGE: "UGE", + BlockARMLTnoov: "LTnoov", + BlockARMLEnoov: "LEnoov", + BlockARMGTnoov: "GTnoov", + BlockARMGEnoov: "GEnoov", + + BlockARM64EQ: "EQ", + BlockARM64NE: "NE", + BlockARM64LT: "LT", + BlockARM64LE: "LE", + BlockARM64GT: "GT", + BlockARM64GE: "GE", + BlockARM64ULT: "ULT", + BlockARM64ULE: "ULE", + BlockARM64UGT: "UGT", + BlockARM64UGE: "UGE", + BlockARM64Z: "Z", + BlockARM64NZ: "NZ", + BlockARM64ZW: "ZW", + BlockARM64NZW: "NZW", + BlockARM64TBZ: "TBZ", + BlockARM64TBNZ: "TBNZ", + BlockARM64FLT: "FLT", + BlockARM64FLE: "FLE", + BlockARM64FGT: "FGT", + BlockARM64FGE: "FGE", + BlockARM64LTnoov: "LTnoov", + BlockARM64LEnoov: "LEnoov", + BlockARM64GTnoov: "GTnoov", + BlockARM64GEnoov: "GEnoov", + BlockARM64JUMPTABLE: "JUMPTABLE", + + BlockLOONG64EQZ: "EQZ", + BlockLOONG64NEZ: "NEZ", + BlockLOONG64LTZ: "LTZ", + BlockLOONG64LEZ: "LEZ", + BlockLOONG64GTZ: "GTZ", + BlockLOONG64GEZ: "GEZ", + BlockLOONG64FPT: "FPT", + BlockLOONG64FPF: "FPF", + BlockLOONG64BEQ: "BEQ", + BlockLOONG64BNE: "BNE", + BlockLOONG64BGE: "BGE", + BlockLOONG64BLT: "BLT", + BlockLOONG64BGEU: "BGEU", + BlockLOONG64BLTU: "BLTU", + BlockLOONG64JUMPTABLE: "JUMPTABLE", + + BlockMIPSEQ: "EQ", + BlockMIPSNE: "NE", + BlockMIPSLTZ: "LTZ", + BlockMIPSLEZ: "LEZ", + BlockMIPSGTZ: "GTZ", + BlockMIPSGEZ: "GEZ", + BlockMIPSFPT: "FPT", + BlockMIPSFPF: "FPF", + + BlockMIPS64EQ: "EQ", + BlockMIPS64NE: "NE", + BlockMIPS64LTZ: "LTZ", + BlockMIPS64LEZ: "LEZ", + BlockMIPS64GTZ: "GTZ", + BlockMIPS64GEZ: "GEZ", + BlockMIPS64FPT: "FPT", + BlockMIPS64FPF: "FPF", + + BlockPPC64EQ: "EQ", + BlockPPC64NE: "NE", + BlockPPC64LT: "LT", + BlockPPC64LE: "LE", + BlockPPC64GT: "GT", + BlockPPC64GE: "GE", + BlockPPC64FLT: "FLT", + BlockPPC64FLE: "FLE", + BlockPPC64FGT: "FGT", + BlockPPC64FGE: "FGE", + + BlockRISCV64BEQ: "BEQ", + BlockRISCV64BNE: "BNE", + BlockRISCV64BLT: "BLT", + BlockRISCV64BGE: "BGE", + BlockRISCV64BLTU: "BLTU", + BlockRISCV64BGEU: "BGEU", + BlockRISCV64BEQZ: "BEQZ", + BlockRISCV64BNEZ: "BNEZ", + BlockRISCV64BLEZ: "BLEZ", + BlockRISCV64BGEZ: "BGEZ", + BlockRISCV64BLTZ: "BLTZ", + BlockRISCV64BGTZ: "BGTZ", + + BlockS390XBRC: "BRC", + BlockS390XCRJ: "CRJ", + BlockS390XCGRJ: "CGRJ", + BlockS390XCLRJ: "CLRJ", + BlockS390XCLGRJ: "CLGRJ", + BlockS390XCIJ: "CIJ", + BlockS390XCGIJ: "CGIJ", + BlockS390XCLIJ: "CLIJ", + BlockS390XCLGIJ: "CLGIJ", + + BlockPlain: "Plain", + BlockIf: "If", + BlockDefer: "Defer", + BlockRet: "Ret", + BlockRetJmp: "RetJmp", + BlockExit: "Exit", + BlockJumpTable: "JumpTable", + BlockFirst: "First", +} + +func (k BlockKind) String() string { return blockString[k] } +func (k BlockKind) AuxIntType() string { + switch k { + case BlockARM64TBZ: + return "int64" + case BlockARM64TBNZ: + return "int64" + case BlockS390XCIJ: + return "int8" + case BlockS390XCGIJ: + return "int8" + case BlockS390XCLIJ: + return "uint8" + case BlockS390XCLGIJ: + return "uint8" + } + return "" +} + +const ( + OpInvalid Op = iota + + Op386ADDSS + Op386ADDSD + Op386SUBSS + Op386SUBSD + Op386MULSS + Op386MULSD + Op386DIVSS + Op386DIVSD + Op386MOVSSload + Op386MOVSDload + Op386MOVSSconst + Op386MOVSDconst + Op386MOVSSloadidx1 + Op386MOVSSloadidx4 + Op386MOVSDloadidx1 + Op386MOVSDloadidx8 + Op386MOVSSstore + Op386MOVSDstore + Op386MOVSSstoreidx1 + Op386MOVSSstoreidx4 + Op386MOVSDstoreidx1 + Op386MOVSDstoreidx8 + Op386ADDSSload + Op386ADDSDload + Op386SUBSSload + Op386SUBSDload + Op386MULSSload + Op386MULSDload + Op386DIVSSload + Op386DIVSDload + Op386ADDL + Op386ADDLconst + Op386ADDLcarry + Op386ADDLconstcarry + Op386ADCL + Op386ADCLcarry + Op386ADCLconst + Op386SUBL + Op386SUBLconst + Op386SUBLcarry + Op386SUBLconstcarry + Op386SBBL + Op386SBBLconst + Op386MULL + Op386MULLconst + Op386MULLU + Op386HMULL + Op386HMULLU + Op386MULLQU + Op386AVGLU + Op386DIVL + Op386DIVW + Op386DIVLU + Op386DIVWU + Op386MODL + Op386MODW + Op386MODLU + Op386MODWU + Op386ANDL + Op386ANDLconst + Op386ORL + Op386ORLconst + Op386XORL + Op386XORLconst + Op386CMPL + Op386CMPW + Op386CMPB + Op386CMPLconst + Op386CMPWconst + Op386CMPBconst + Op386CMPLload + Op386CMPWload + Op386CMPBload + Op386CMPLconstload + Op386CMPWconstload + Op386CMPBconstload + Op386UCOMISS + Op386UCOMISD + Op386TESTL + Op386TESTW + Op386TESTB + Op386TESTLconst + Op386TESTWconst + Op386TESTBconst + Op386SHLL + Op386SHLLconst + Op386SHRL + Op386SHRW + Op386SHRB + Op386SHRLconst + Op386SHRWconst + Op386SHRBconst + Op386SARL + Op386SARW + Op386SARB + Op386SARLconst + Op386SARWconst + Op386SARBconst + Op386ROLL + Op386ROLW + Op386ROLB + Op386ROLLconst + Op386ROLWconst + Op386ROLBconst + Op386ADDLload + Op386SUBLload + Op386MULLload + Op386ANDLload + Op386ORLload + Op386XORLload + Op386ADDLloadidx4 + Op386SUBLloadidx4 + Op386MULLloadidx4 + Op386ANDLloadidx4 + Op386ORLloadidx4 + Op386XORLloadidx4 + Op386NEGL + Op386NOTL + Op386BSFL + Op386BSFW + Op386LoweredCtz32 + Op386LoweredCtz64 + Op386BSRL + Op386BSRW + Op386BSWAPL + Op386SQRTSD + Op386SQRTSS + Op386SBBLcarrymask + Op386SETEQ + Op386SETNE + Op386SETL + Op386SETLE + Op386SETG + Op386SETGE + Op386SETB + Op386SETBE + Op386SETA + Op386SETAE + Op386SETO + Op386SETEQF + Op386SETNEF + Op386SETORD + Op386SETNAN + Op386SETGF + Op386SETGEF + Op386MOVBLSX + Op386MOVBLZX + Op386MOVWLSX + Op386MOVWLZX + Op386MOVLconst + Op386CVTTSD2SL + Op386CVTTSS2SL + Op386CVTSL2SS + Op386CVTSL2SD + Op386CVTSD2SS + Op386CVTSS2SD + Op386PXOR + Op386LEAL + Op386LEAL1 + Op386LEAL2 + Op386LEAL4 + Op386LEAL8 + Op386MOVBload + Op386MOVBLSXload + Op386MOVWload + Op386MOVWLSXload + Op386MOVLload + Op386MOVBstore + Op386MOVWstore + Op386MOVLstore + Op386ADDLmodify + Op386SUBLmodify + Op386ANDLmodify + Op386ORLmodify + Op386XORLmodify + Op386ADDLmodifyidx4 + Op386SUBLmodifyidx4 + Op386ANDLmodifyidx4 + Op386ORLmodifyidx4 + Op386XORLmodifyidx4 + Op386ADDLconstmodify + Op386ANDLconstmodify + Op386ORLconstmodify + Op386XORLconstmodify + Op386ADDLconstmodifyidx4 + Op386ANDLconstmodifyidx4 + Op386ORLconstmodifyidx4 + Op386XORLconstmodifyidx4 + Op386MOVBloadidx1 + Op386MOVWloadidx1 + Op386MOVWloadidx2 + Op386MOVLloadidx1 + Op386MOVLloadidx4 + Op386MOVBstoreidx1 + Op386MOVWstoreidx1 + Op386MOVWstoreidx2 + Op386MOVLstoreidx1 + Op386MOVLstoreidx4 + Op386MOVBstoreconst + Op386MOVWstoreconst + Op386MOVLstoreconst + Op386MOVBstoreconstidx1 + Op386MOVWstoreconstidx1 + Op386MOVWstoreconstidx2 + Op386MOVLstoreconstidx1 + Op386MOVLstoreconstidx4 + Op386DUFFZERO + Op386REPSTOSL + Op386CALLstatic + Op386CALLtail + Op386CALLclosure + Op386CALLinter + Op386DUFFCOPY + Op386REPMOVSL + Op386InvertFlags + Op386LoweredGetG + Op386LoweredGetClosurePtr + Op386LoweredGetCallerPC + Op386LoweredGetCallerSP + Op386LoweredNilCheck + Op386LoweredWB + Op386LoweredPanicBoundsRR + Op386LoweredPanicBoundsRC + Op386LoweredPanicBoundsCR + Op386LoweredPanicBoundsCC + Op386LoweredPanicExtendRR + Op386LoweredPanicExtendRC + Op386FlagEQ + Op386FlagLT_ULT + Op386FlagLT_UGT + Op386FlagGT_UGT + Op386FlagGT_ULT + Op386MOVSSconst1 + Op386MOVSDconst1 + Op386MOVSSconst2 + Op386MOVSDconst2 + + OpAMD64ADDSS + OpAMD64ADDSD + OpAMD64SUBSS + OpAMD64SUBSD + OpAMD64MULSS + OpAMD64MULSD + OpAMD64DIVSS + OpAMD64DIVSD + OpAMD64MOVSSload + OpAMD64MOVSDload + OpAMD64MOVSSconst + OpAMD64MOVSDconst + OpAMD64MOVSSloadidx1 + OpAMD64MOVSSloadidx4 + OpAMD64MOVSDloadidx1 + OpAMD64MOVSDloadidx8 + OpAMD64MOVSSstore + OpAMD64MOVSDstore + OpAMD64MOVSSstoreidx1 + OpAMD64MOVSSstoreidx4 + OpAMD64MOVSDstoreidx1 + OpAMD64MOVSDstoreidx8 + OpAMD64ADDSSload + OpAMD64ADDSDload + OpAMD64SUBSSload + OpAMD64SUBSDload + OpAMD64MULSSload + OpAMD64MULSDload + OpAMD64DIVSSload + OpAMD64DIVSDload + OpAMD64ADDSSloadidx1 + OpAMD64ADDSSloadidx4 + OpAMD64ADDSDloadidx1 + OpAMD64ADDSDloadidx8 + OpAMD64SUBSSloadidx1 + OpAMD64SUBSSloadidx4 + OpAMD64SUBSDloadidx1 + OpAMD64SUBSDloadidx8 + OpAMD64MULSSloadidx1 + OpAMD64MULSSloadidx4 + OpAMD64MULSDloadidx1 + OpAMD64MULSDloadidx8 + OpAMD64DIVSSloadidx1 + OpAMD64DIVSSloadidx4 + OpAMD64DIVSDloadidx1 + OpAMD64DIVSDloadidx8 + OpAMD64ADDQ + OpAMD64ADDL + OpAMD64ADDQconst + OpAMD64ADDLconst + OpAMD64ADDQconstmodify + OpAMD64ADDLconstmodify + OpAMD64SUBQ + OpAMD64SUBL + OpAMD64SUBQconst + OpAMD64SUBLconst + OpAMD64MULQ + OpAMD64MULL + OpAMD64MULQconst + OpAMD64MULLconst + OpAMD64MULLU + OpAMD64MULQU + OpAMD64HMULQ + OpAMD64HMULL + OpAMD64HMULQU + OpAMD64HMULLU + OpAMD64AVGQU + OpAMD64DIVQ + OpAMD64DIVL + OpAMD64DIVW + OpAMD64DIVQU + OpAMD64DIVLU + OpAMD64DIVWU + OpAMD64NEGLflags + OpAMD64ADDQconstflags + OpAMD64ADDLconstflags + OpAMD64ADDQcarry + OpAMD64ADCQ + OpAMD64ADDQconstcarry + OpAMD64ADCQconst + OpAMD64SUBQborrow + OpAMD64SBBQ + OpAMD64SUBQconstborrow + OpAMD64SBBQconst + OpAMD64MULQU2 + OpAMD64DIVQU2 + OpAMD64ANDQ + OpAMD64ANDL + OpAMD64ANDQconst + OpAMD64ANDLconst + OpAMD64ANDQconstmodify + OpAMD64ANDLconstmodify + OpAMD64ORQ + OpAMD64ORL + OpAMD64ORQconst + OpAMD64ORLconst + OpAMD64ORQconstmodify + OpAMD64ORLconstmodify + OpAMD64XORQ + OpAMD64XORL + OpAMD64XORQconst + OpAMD64XORLconst + OpAMD64XORQconstmodify + OpAMD64XORLconstmodify + OpAMD64CMPQ + OpAMD64CMPL + OpAMD64CMPW + OpAMD64CMPB + OpAMD64CMPQconst + OpAMD64CMPLconst + OpAMD64CMPWconst + OpAMD64CMPBconst + OpAMD64CMPQload + OpAMD64CMPLload + OpAMD64CMPWload + OpAMD64CMPBload + OpAMD64CMPQconstload + OpAMD64CMPLconstload + OpAMD64CMPWconstload + OpAMD64CMPBconstload + OpAMD64CMPQloadidx8 + OpAMD64CMPQloadidx1 + OpAMD64CMPLloadidx4 + OpAMD64CMPLloadidx1 + OpAMD64CMPWloadidx2 + OpAMD64CMPWloadidx1 + OpAMD64CMPBloadidx1 + OpAMD64CMPQconstloadidx8 + OpAMD64CMPQconstloadidx1 + OpAMD64CMPLconstloadidx4 + OpAMD64CMPLconstloadidx1 + OpAMD64CMPWconstloadidx2 + OpAMD64CMPWconstloadidx1 + OpAMD64CMPBconstloadidx1 + OpAMD64UCOMISS + OpAMD64UCOMISD + OpAMD64BTL + OpAMD64BTQ + OpAMD64BTCL + OpAMD64BTCQ + OpAMD64BTRL + OpAMD64BTRQ + OpAMD64BTSL + OpAMD64BTSQ + OpAMD64BTLconst + OpAMD64BTQconst + OpAMD64BTCQconst + OpAMD64BTRQconst + OpAMD64BTSQconst + OpAMD64BTSQconstmodify + OpAMD64BTRQconstmodify + OpAMD64BTCQconstmodify + OpAMD64TESTQ + OpAMD64TESTL + OpAMD64TESTW + OpAMD64TESTB + OpAMD64TESTQconst + OpAMD64TESTLconst + OpAMD64TESTWconst + OpAMD64TESTBconst + OpAMD64SHLQ + OpAMD64SHLL + OpAMD64SHLQconst + OpAMD64SHLLconst + OpAMD64SHRQ + OpAMD64SHRL + OpAMD64SHRW + OpAMD64SHRB + OpAMD64SHRQconst + OpAMD64SHRLconst + OpAMD64SHRWconst + OpAMD64SHRBconst + OpAMD64SARQ + OpAMD64SARL + OpAMD64SARW + OpAMD64SARB + OpAMD64SARQconst + OpAMD64SARLconst + OpAMD64SARWconst + OpAMD64SARBconst + OpAMD64SHRDQ + OpAMD64SHLDQ + OpAMD64ROLQ + OpAMD64ROLL + OpAMD64ROLW + OpAMD64ROLB + OpAMD64RORQ + OpAMD64RORL + OpAMD64RORW + OpAMD64RORB + OpAMD64ROLQconst + OpAMD64ROLLconst + OpAMD64ROLWconst + OpAMD64ROLBconst + OpAMD64ADDLload + OpAMD64ADDQload + OpAMD64SUBQload + OpAMD64SUBLload + OpAMD64ANDLload + OpAMD64ANDQload + OpAMD64ORQload + OpAMD64ORLload + OpAMD64XORQload + OpAMD64XORLload + OpAMD64ADDLloadidx1 + OpAMD64ADDLloadidx4 + OpAMD64ADDLloadidx8 + OpAMD64ADDQloadidx1 + OpAMD64ADDQloadidx8 + OpAMD64SUBLloadidx1 + OpAMD64SUBLloadidx4 + OpAMD64SUBLloadidx8 + OpAMD64SUBQloadidx1 + OpAMD64SUBQloadidx8 + OpAMD64ANDLloadidx1 + OpAMD64ANDLloadidx4 + OpAMD64ANDLloadidx8 + OpAMD64ANDQloadidx1 + OpAMD64ANDQloadidx8 + OpAMD64ORLloadidx1 + OpAMD64ORLloadidx4 + OpAMD64ORLloadidx8 + OpAMD64ORQloadidx1 + OpAMD64ORQloadidx8 + OpAMD64XORLloadidx1 + OpAMD64XORLloadidx4 + OpAMD64XORLloadidx8 + OpAMD64XORQloadidx1 + OpAMD64XORQloadidx8 + OpAMD64ADDQmodify + OpAMD64SUBQmodify + OpAMD64ANDQmodify + OpAMD64ORQmodify + OpAMD64XORQmodify + OpAMD64ADDLmodify + OpAMD64SUBLmodify + OpAMD64ANDLmodify + OpAMD64ORLmodify + OpAMD64XORLmodify + OpAMD64ADDQmodifyidx1 + OpAMD64ADDQmodifyidx8 + OpAMD64SUBQmodifyidx1 + OpAMD64SUBQmodifyidx8 + OpAMD64ANDQmodifyidx1 + OpAMD64ANDQmodifyidx8 + OpAMD64ORQmodifyidx1 + OpAMD64ORQmodifyidx8 + OpAMD64XORQmodifyidx1 + OpAMD64XORQmodifyidx8 + OpAMD64ADDLmodifyidx1 + OpAMD64ADDLmodifyidx4 + OpAMD64ADDLmodifyidx8 + OpAMD64SUBLmodifyidx1 + OpAMD64SUBLmodifyidx4 + OpAMD64SUBLmodifyidx8 + OpAMD64ANDLmodifyidx1 + OpAMD64ANDLmodifyidx4 + OpAMD64ANDLmodifyidx8 + OpAMD64ORLmodifyidx1 + OpAMD64ORLmodifyidx4 + OpAMD64ORLmodifyidx8 + OpAMD64XORLmodifyidx1 + OpAMD64XORLmodifyidx4 + OpAMD64XORLmodifyidx8 + OpAMD64ADDQconstmodifyidx1 + OpAMD64ADDQconstmodifyidx8 + OpAMD64ANDQconstmodifyidx1 + OpAMD64ANDQconstmodifyidx8 + OpAMD64ORQconstmodifyidx1 + OpAMD64ORQconstmodifyidx8 + OpAMD64XORQconstmodifyidx1 + OpAMD64XORQconstmodifyidx8 + OpAMD64ADDLconstmodifyidx1 + OpAMD64ADDLconstmodifyidx4 + OpAMD64ADDLconstmodifyidx8 + OpAMD64ANDLconstmodifyidx1 + OpAMD64ANDLconstmodifyidx4 + OpAMD64ANDLconstmodifyidx8 + OpAMD64ORLconstmodifyidx1 + OpAMD64ORLconstmodifyidx4 + OpAMD64ORLconstmodifyidx8 + OpAMD64XORLconstmodifyidx1 + OpAMD64XORLconstmodifyidx4 + OpAMD64XORLconstmodifyidx8 + OpAMD64NEGQ + OpAMD64NEGL + OpAMD64NOTQ + OpAMD64NOTL + OpAMD64BSFQ + OpAMD64BSFL + OpAMD64BSRQ + OpAMD64BSRL + OpAMD64CMOVQEQ + OpAMD64CMOVQNE + OpAMD64CMOVQLT + OpAMD64CMOVQGT + OpAMD64CMOVQLE + OpAMD64CMOVQGE + OpAMD64CMOVQLS + OpAMD64CMOVQHI + OpAMD64CMOVQCC + OpAMD64CMOVQCS + OpAMD64CMOVLEQ + OpAMD64CMOVLNE + OpAMD64CMOVLLT + OpAMD64CMOVLGT + OpAMD64CMOVLLE + OpAMD64CMOVLGE + OpAMD64CMOVLLS + OpAMD64CMOVLHI + OpAMD64CMOVLCC + OpAMD64CMOVLCS + OpAMD64CMOVWEQ + OpAMD64CMOVWNE + OpAMD64CMOVWLT + OpAMD64CMOVWGT + OpAMD64CMOVWLE + OpAMD64CMOVWGE + OpAMD64CMOVWLS + OpAMD64CMOVWHI + OpAMD64CMOVWCC + OpAMD64CMOVWCS + OpAMD64CMOVQEQF + OpAMD64CMOVQNEF + OpAMD64CMOVQGTF + OpAMD64CMOVQGEF + OpAMD64CMOVLEQF + OpAMD64CMOVLNEF + OpAMD64CMOVLGTF + OpAMD64CMOVLGEF + OpAMD64CMOVWEQF + OpAMD64CMOVWNEF + OpAMD64CMOVWGTF + OpAMD64CMOVWGEF + OpAMD64BSWAPQ + OpAMD64BSWAPL + OpAMD64POPCNTQ + OpAMD64POPCNTL + OpAMD64SQRTSD + OpAMD64SQRTSS + OpAMD64ROUNDSD + OpAMD64LoweredRound32F + OpAMD64LoweredRound64F + OpAMD64VFMADD231SS + OpAMD64VFMADD231SD + OpAMD64MINSD + OpAMD64MINSS + OpAMD64SBBQcarrymask + OpAMD64SBBLcarrymask + OpAMD64SETEQ + OpAMD64SETNE + OpAMD64SETL + OpAMD64SETLE + OpAMD64SETG + OpAMD64SETGE + OpAMD64SETB + OpAMD64SETBE + OpAMD64SETA + OpAMD64SETAE + OpAMD64SETO + OpAMD64SETEQstore + OpAMD64SETNEstore + OpAMD64SETLstore + OpAMD64SETLEstore + OpAMD64SETGstore + OpAMD64SETGEstore + OpAMD64SETBstore + OpAMD64SETBEstore + OpAMD64SETAstore + OpAMD64SETAEstore + OpAMD64SETEQstoreidx1 + OpAMD64SETNEstoreidx1 + OpAMD64SETLstoreidx1 + OpAMD64SETLEstoreidx1 + OpAMD64SETGstoreidx1 + OpAMD64SETGEstoreidx1 + OpAMD64SETBstoreidx1 + OpAMD64SETBEstoreidx1 + OpAMD64SETAstoreidx1 + OpAMD64SETAEstoreidx1 + OpAMD64SETEQF + OpAMD64SETNEF + OpAMD64SETORD + OpAMD64SETNAN + OpAMD64SETGF + OpAMD64SETGEF + OpAMD64MOVBQSX + OpAMD64MOVBQZX + OpAMD64MOVWQSX + OpAMD64MOVWQZX + OpAMD64MOVLQSX + OpAMD64MOVLQZX + OpAMD64MOVLconst + OpAMD64MOVQconst + OpAMD64CVTTSD2SL + OpAMD64CVTTSD2SQ + OpAMD64CVTTSS2SL + OpAMD64CVTTSS2SQ + OpAMD64CVTSL2SS + OpAMD64CVTSL2SD + OpAMD64CVTSQ2SS + OpAMD64CVTSQ2SD + OpAMD64CVTSD2SS + OpAMD64CVTSS2SD + OpAMD64MOVQi2f + OpAMD64MOVQf2i + OpAMD64MOVLi2f + OpAMD64MOVLf2i + OpAMD64PXOR + OpAMD64POR + OpAMD64LEAQ + OpAMD64LEAL + OpAMD64LEAW + OpAMD64LEAQ1 + OpAMD64LEAL1 + OpAMD64LEAW1 + OpAMD64LEAQ2 + OpAMD64LEAL2 + OpAMD64LEAW2 + OpAMD64LEAQ4 + OpAMD64LEAL4 + OpAMD64LEAW4 + OpAMD64LEAQ8 + OpAMD64LEAL8 + OpAMD64LEAW8 + OpAMD64MOVBload + OpAMD64MOVBQSXload + OpAMD64MOVWload + OpAMD64MOVWQSXload + OpAMD64MOVLload + OpAMD64MOVLQSXload + OpAMD64MOVQload + OpAMD64MOVBstore + OpAMD64MOVWstore + OpAMD64MOVLstore + OpAMD64MOVQstore + OpAMD64MOVOload + OpAMD64MOVOstore + OpAMD64MOVBloadidx1 + OpAMD64MOVWloadidx1 + OpAMD64MOVWloadidx2 + OpAMD64MOVLloadidx1 + OpAMD64MOVLloadidx4 + OpAMD64MOVLloadidx8 + OpAMD64MOVQloadidx1 + OpAMD64MOVQloadidx8 + OpAMD64MOVBstoreidx1 + OpAMD64MOVWstoreidx1 + OpAMD64MOVWstoreidx2 + OpAMD64MOVLstoreidx1 + OpAMD64MOVLstoreidx4 + OpAMD64MOVLstoreidx8 + OpAMD64MOVQstoreidx1 + OpAMD64MOVQstoreidx8 + OpAMD64MOVBstoreconst + OpAMD64MOVWstoreconst + OpAMD64MOVLstoreconst + OpAMD64MOVQstoreconst + OpAMD64MOVOstoreconst + OpAMD64MOVBstoreconstidx1 + OpAMD64MOVWstoreconstidx1 + OpAMD64MOVWstoreconstidx2 + OpAMD64MOVLstoreconstidx1 + OpAMD64MOVLstoreconstidx4 + OpAMD64MOVQstoreconstidx1 + OpAMD64MOVQstoreconstidx8 + OpAMD64LoweredZero + OpAMD64LoweredZeroLoop + OpAMD64REPSTOSQ + OpAMD64CALLstatic + OpAMD64CALLtail + OpAMD64CALLclosure + OpAMD64CALLinter + OpAMD64LoweredMove + OpAMD64LoweredMoveLoop + OpAMD64REPMOVSQ + OpAMD64InvertFlags + OpAMD64LoweredGetG + OpAMD64LoweredGetClosurePtr + OpAMD64LoweredGetCallerPC + OpAMD64LoweredGetCallerSP + OpAMD64LoweredNilCheck + OpAMD64LoweredWB + OpAMD64LoweredHasCPUFeature + OpAMD64LoweredPanicBoundsRR + OpAMD64LoweredPanicBoundsRC + OpAMD64LoweredPanicBoundsCR + OpAMD64LoweredPanicBoundsCC + OpAMD64FlagEQ + OpAMD64FlagLT_ULT + OpAMD64FlagLT_UGT + OpAMD64FlagGT_UGT + OpAMD64FlagGT_ULT + OpAMD64MOVBatomicload + OpAMD64MOVLatomicload + OpAMD64MOVQatomicload + OpAMD64XCHGB + OpAMD64XCHGL + OpAMD64XCHGQ + OpAMD64XADDLlock + OpAMD64XADDQlock + OpAMD64AddTupleFirst32 + OpAMD64AddTupleFirst64 + OpAMD64CMPXCHGLlock + OpAMD64CMPXCHGQlock + OpAMD64ANDBlock + OpAMD64ANDLlock + OpAMD64ANDQlock + OpAMD64ORBlock + OpAMD64ORLlock + OpAMD64ORQlock + OpAMD64LoweredAtomicAnd64 + OpAMD64LoweredAtomicAnd32 + OpAMD64LoweredAtomicOr64 + OpAMD64LoweredAtomicOr32 + OpAMD64PrefetchT0 + OpAMD64PrefetchNTA + OpAMD64ANDNQ + OpAMD64ANDNL + OpAMD64BLSIQ + OpAMD64BLSIL + OpAMD64BLSMSKQ + OpAMD64BLSMSKL + OpAMD64BLSRQ + OpAMD64BLSRL + OpAMD64TZCNTQ + OpAMD64TZCNTL + OpAMD64LZCNTQ + OpAMD64LZCNTL + OpAMD64MOVBEWstore + OpAMD64MOVBELload + OpAMD64MOVBELstore + OpAMD64MOVBEQload + OpAMD64MOVBEQstore + OpAMD64MOVBELloadidx1 + OpAMD64MOVBELloadidx4 + OpAMD64MOVBELloadidx8 + OpAMD64MOVBEQloadidx1 + OpAMD64MOVBEQloadidx8 + OpAMD64MOVBEWstoreidx1 + OpAMD64MOVBEWstoreidx2 + OpAMD64MOVBELstoreidx1 + OpAMD64MOVBELstoreidx4 + OpAMD64MOVBELstoreidx8 + OpAMD64MOVBEQstoreidx1 + OpAMD64MOVBEQstoreidx8 + OpAMD64SARXQ + OpAMD64SARXL + OpAMD64SHLXQ + OpAMD64SHLXL + OpAMD64SHRXQ + OpAMD64SHRXL + OpAMD64SARXLload + OpAMD64SARXQload + OpAMD64SHLXLload + OpAMD64SHLXQload + OpAMD64SHRXLload + OpAMD64SHRXQload + OpAMD64SARXLloadidx1 + OpAMD64SARXLloadidx4 + OpAMD64SARXLloadidx8 + OpAMD64SARXQloadidx1 + OpAMD64SARXQloadidx8 + OpAMD64SHLXLloadidx1 + OpAMD64SHLXLloadidx4 + OpAMD64SHLXLloadidx8 + OpAMD64SHLXQloadidx1 + OpAMD64SHLXQloadidx8 + OpAMD64SHRXLloadidx1 + OpAMD64SHRXLloadidx4 + OpAMD64SHRXLloadidx8 + OpAMD64SHRXQloadidx1 + OpAMD64SHRXQloadidx8 + OpAMD64PUNPCKLBW + OpAMD64PSHUFLW + OpAMD64PSHUFBbroadcast + OpAMD64VPBROADCASTB + OpAMD64PSIGNB + OpAMD64PCMPEQB + OpAMD64PMOVMSKB + OpAMD64VMOVDQUload128 + OpAMD64VMOVDQUstore128 + OpAMD64VMOVDQUload256 + OpAMD64VMOVDQUstore256 + OpAMD64VMOVDQUload512 + OpAMD64VMOVDQUstore512 + OpAMD64VPMASK32load128 + OpAMD64VPMASK32store128 + OpAMD64VPMASK64load128 + OpAMD64VPMASK64store128 + OpAMD64VPMASK32load256 + OpAMD64VPMASK32store256 + OpAMD64VPMASK64load256 + OpAMD64VPMASK64store256 + OpAMD64VPMASK8load512 + OpAMD64VPMASK8store512 + OpAMD64VPMASK16load512 + OpAMD64VPMASK16store512 + OpAMD64VPMASK32load512 + OpAMD64VPMASK32store512 + OpAMD64VPMASK64load512 + OpAMD64VPMASK64store512 + OpAMD64VPMOVMToVec8x16 + OpAMD64VPMOVMToVec8x32 + OpAMD64VPMOVMToVec8x64 + OpAMD64VPMOVMToVec16x8 + OpAMD64VPMOVMToVec16x16 + OpAMD64VPMOVMToVec16x32 + OpAMD64VPMOVMToVec32x4 + OpAMD64VPMOVMToVec32x8 + OpAMD64VPMOVMToVec32x16 + OpAMD64VPMOVMToVec64x2 + OpAMD64VPMOVMToVec64x4 + OpAMD64VPMOVMToVec64x8 + OpAMD64VPMOVVec8x16ToM + OpAMD64VPMOVVec8x32ToM + OpAMD64VPMOVVec8x64ToM + OpAMD64VPMOVVec16x8ToM + OpAMD64VPMOVVec16x16ToM + OpAMD64VPMOVVec16x32ToM + OpAMD64VPMOVVec32x4ToM + OpAMD64VPMOVVec32x8ToM + OpAMD64VPMOVVec32x16ToM + OpAMD64VPMOVVec64x2ToM + OpAMD64VPMOVVec64x4ToM + OpAMD64VPMOVVec64x8ToM + OpAMD64VPMOVMSKB128 + OpAMD64VPMOVMSKB256 + OpAMD64VMOVMSKPS128 + OpAMD64VMOVMSKPS256 + OpAMD64VMOVMSKPD128 + OpAMD64VMOVMSKPD256 + OpAMD64Zero128 + OpAMD64Zero256 + OpAMD64Zero512 + OpAMD64VMOVSDf2v + OpAMD64VMOVSSf2v + OpAMD64VMOVQ + OpAMD64VMOVD + OpAMD64VMOVQload + OpAMD64VMOVDload + OpAMD64VMOVSSload + OpAMD64VMOVSDload + OpAMD64VMOVSSconst + OpAMD64VMOVSDconst + OpAMD64VZEROUPPER + OpAMD64VZEROALL + OpAMD64KMOVBload + OpAMD64KMOVWload + OpAMD64KMOVDload + OpAMD64KMOVQload + OpAMD64KMOVBstore + OpAMD64KMOVWstore + OpAMD64KMOVDstore + OpAMD64KMOVQstore + OpAMD64KMOVQk + OpAMD64KMOVDk + OpAMD64KMOVWk + OpAMD64KMOVBk + OpAMD64KMOVQi + OpAMD64KMOVDi + OpAMD64KMOVWi + OpAMD64KMOVBi + OpAMD64VPTEST + OpAMD64SHA1MSG1128 + OpAMD64SHA1MSG2128 + OpAMD64SHA1NEXTE128 + OpAMD64SHA256MSG1128 + OpAMD64SHA256MSG2128 + OpAMD64SHA256RNDS2128 + OpAMD64VADDPD128 + OpAMD64VADDPD256 + OpAMD64VADDPD512 + OpAMD64VADDPDMasked128 + OpAMD64VADDPDMasked256 + OpAMD64VADDPDMasked512 + OpAMD64VADDPS128 + OpAMD64VADDPS256 + OpAMD64VADDPS512 + OpAMD64VADDPSMasked128 + OpAMD64VADDPSMasked256 + OpAMD64VADDPSMasked512 + OpAMD64VADDSUBPD128 + OpAMD64VADDSUBPD256 + OpAMD64VADDSUBPS128 + OpAMD64VADDSUBPS256 + OpAMD64VAESDEC128 + OpAMD64VAESDEC256 + OpAMD64VAESDEC512 + OpAMD64VAESDECLAST128 + OpAMD64VAESDECLAST256 + OpAMD64VAESDECLAST512 + OpAMD64VAESENC128 + OpAMD64VAESENC256 + OpAMD64VAESENC512 + OpAMD64VAESENCLAST128 + OpAMD64VAESENCLAST256 + OpAMD64VAESENCLAST512 + OpAMD64VAESIMC128 + OpAMD64VBROADCASTSD256 + OpAMD64VBROADCASTSD512 + OpAMD64VBROADCASTSDMasked256 + OpAMD64VBROADCASTSDMasked512 + OpAMD64VBROADCASTSS128 + OpAMD64VBROADCASTSS256 + OpAMD64VBROADCASTSS512 + OpAMD64VBROADCASTSSMasked128 + OpAMD64VBROADCASTSSMasked256 + OpAMD64VBROADCASTSSMasked512 + OpAMD64VCOMPRESSPDMasked128 + OpAMD64VCOMPRESSPDMasked256 + OpAMD64VCOMPRESSPDMasked512 + OpAMD64VCOMPRESSPSMasked128 + OpAMD64VCOMPRESSPSMasked256 + OpAMD64VCOMPRESSPSMasked512 + OpAMD64VCVTDQ2PD256 + OpAMD64VCVTDQ2PD512 + OpAMD64VCVTDQ2PDMasked256 + OpAMD64VCVTDQ2PDMasked512 + OpAMD64VCVTDQ2PS128 + OpAMD64VCVTDQ2PS256 + OpAMD64VCVTDQ2PS512 + OpAMD64VCVTDQ2PSMasked128 + OpAMD64VCVTDQ2PSMasked256 + OpAMD64VCVTDQ2PSMasked512 + OpAMD64VCVTPD2PS256 + OpAMD64VCVTPD2PSMasked256 + OpAMD64VCVTPD2PSX128 + OpAMD64VCVTPD2PSXMasked128 + OpAMD64VCVTPD2PSY128 + OpAMD64VCVTPD2PSYMasked128 + OpAMD64VCVTPS2PD256 + OpAMD64VCVTPS2PD512 + OpAMD64VCVTPS2PDMasked256 + OpAMD64VCVTPS2PDMasked512 + OpAMD64VCVTQQ2PD128 + OpAMD64VCVTQQ2PD256 + OpAMD64VCVTQQ2PD512 + OpAMD64VCVTQQ2PDMasked128 + OpAMD64VCVTQQ2PDMasked256 + OpAMD64VCVTQQ2PDMasked512 + OpAMD64VCVTQQ2PS256 + OpAMD64VCVTQQ2PSMasked256 + OpAMD64VCVTQQ2PSX128 + OpAMD64VCVTQQ2PSXMasked128 + OpAMD64VCVTQQ2PSY128 + OpAMD64VCVTQQ2PSYMasked128 + OpAMD64VCVTTPD2DQ256 + OpAMD64VCVTTPD2DQMasked256 + OpAMD64VCVTTPD2DQX128 + OpAMD64VCVTTPD2DQXMasked128 + OpAMD64VCVTTPD2DQY128 + OpAMD64VCVTTPD2DQYMasked128 + OpAMD64VCVTTPD2QQ128 + OpAMD64VCVTTPD2QQ256 + OpAMD64VCVTTPD2QQ512 + OpAMD64VCVTTPD2QQMasked128 + OpAMD64VCVTTPD2QQMasked256 + OpAMD64VCVTTPD2QQMasked512 + OpAMD64VCVTTPD2UDQ256 + OpAMD64VCVTTPD2UDQMasked256 + OpAMD64VCVTTPD2UDQX128 + OpAMD64VCVTTPD2UDQXMasked128 + OpAMD64VCVTTPD2UDQY128 + OpAMD64VCVTTPD2UDQYMasked128 + OpAMD64VCVTTPD2UQQ128 + OpAMD64VCVTTPD2UQQ256 + OpAMD64VCVTTPD2UQQ512 + OpAMD64VCVTTPD2UQQMasked128 + OpAMD64VCVTTPD2UQQMasked256 + OpAMD64VCVTTPD2UQQMasked512 + OpAMD64VCVTTPS2DQ128 + OpAMD64VCVTTPS2DQ256 + OpAMD64VCVTTPS2DQ512 + OpAMD64VCVTTPS2DQMasked128 + OpAMD64VCVTTPS2DQMasked256 + OpAMD64VCVTTPS2DQMasked512 + OpAMD64VCVTTPS2QQ256 + OpAMD64VCVTTPS2QQ512 + OpAMD64VCVTTPS2QQMasked256 + OpAMD64VCVTTPS2QQMasked512 + OpAMD64VCVTTPS2UDQ128 + OpAMD64VCVTTPS2UDQ256 + OpAMD64VCVTTPS2UDQ512 + OpAMD64VCVTTPS2UDQMasked128 + OpAMD64VCVTTPS2UDQMasked256 + OpAMD64VCVTTPS2UDQMasked512 + OpAMD64VCVTTPS2UQQ256 + OpAMD64VCVTTPS2UQQ512 + OpAMD64VCVTTPS2UQQMasked256 + OpAMD64VCVTTPS2UQQMasked512 + OpAMD64VCVTUDQ2PD256 + OpAMD64VCVTUDQ2PD512 + OpAMD64VCVTUDQ2PDMasked256 + OpAMD64VCVTUDQ2PDMasked512 + OpAMD64VCVTUDQ2PS128 + OpAMD64VCVTUDQ2PS256 + OpAMD64VCVTUDQ2PS512 + OpAMD64VCVTUDQ2PSMasked128 + OpAMD64VCVTUDQ2PSMasked256 + OpAMD64VCVTUDQ2PSMasked512 + OpAMD64VCVTUQQ2PD128 + OpAMD64VCVTUQQ2PD256 + OpAMD64VCVTUQQ2PD512 + OpAMD64VCVTUQQ2PDMasked128 + OpAMD64VCVTUQQ2PDMasked256 + OpAMD64VCVTUQQ2PDMasked512 + OpAMD64VCVTUQQ2PS256 + OpAMD64VCVTUQQ2PSMasked256 + OpAMD64VCVTUQQ2PSX128 + OpAMD64VCVTUQQ2PSXMasked128 + OpAMD64VCVTUQQ2PSY128 + OpAMD64VCVTUQQ2PSYMasked128 + OpAMD64VDIVPD128 + OpAMD64VDIVPD256 + OpAMD64VDIVPD512 + OpAMD64VDIVPDMasked128 + OpAMD64VDIVPDMasked256 + OpAMD64VDIVPDMasked512 + OpAMD64VDIVPS128 + OpAMD64VDIVPS256 + OpAMD64VDIVPS512 + OpAMD64VDIVPSMasked128 + OpAMD64VDIVPSMasked256 + OpAMD64VDIVPSMasked512 + OpAMD64VEXPANDPDMasked128 + OpAMD64VEXPANDPDMasked256 + OpAMD64VEXPANDPDMasked512 + OpAMD64VEXPANDPSMasked128 + OpAMD64VEXPANDPSMasked256 + OpAMD64VEXPANDPSMasked512 + OpAMD64VFMADD213PD128 + OpAMD64VFMADD213PD256 + OpAMD64VFMADD213PD512 + OpAMD64VFMADD213PDMasked128 + OpAMD64VFMADD213PDMasked256 + OpAMD64VFMADD213PDMasked512 + OpAMD64VFMADD213PS128 + OpAMD64VFMADD213PS256 + OpAMD64VFMADD213PS512 + OpAMD64VFMADD213PSMasked128 + OpAMD64VFMADD213PSMasked256 + OpAMD64VFMADD213PSMasked512 + OpAMD64VFMADDSUB213PD128 + OpAMD64VFMADDSUB213PD256 + OpAMD64VFMADDSUB213PD512 + OpAMD64VFMADDSUB213PDMasked128 + OpAMD64VFMADDSUB213PDMasked256 + OpAMD64VFMADDSUB213PDMasked512 + OpAMD64VFMADDSUB213PS128 + OpAMD64VFMADDSUB213PS256 + OpAMD64VFMADDSUB213PS512 + OpAMD64VFMADDSUB213PSMasked128 + OpAMD64VFMADDSUB213PSMasked256 + OpAMD64VFMADDSUB213PSMasked512 + OpAMD64VFMSUBADD213PD128 + OpAMD64VFMSUBADD213PD256 + OpAMD64VFMSUBADD213PD512 + OpAMD64VFMSUBADD213PDMasked128 + OpAMD64VFMSUBADD213PDMasked256 + OpAMD64VFMSUBADD213PDMasked512 + OpAMD64VFMSUBADD213PS128 + OpAMD64VFMSUBADD213PS256 + OpAMD64VFMSUBADD213PS512 + OpAMD64VFMSUBADD213PSMasked128 + OpAMD64VFMSUBADD213PSMasked256 + OpAMD64VFMSUBADD213PSMasked512 + OpAMD64VGF2P8MULB128 + OpAMD64VGF2P8MULB256 + OpAMD64VGF2P8MULB512 + OpAMD64VGF2P8MULBMasked128 + OpAMD64VGF2P8MULBMasked256 + OpAMD64VGF2P8MULBMasked512 + OpAMD64VHADDPD128 + OpAMD64VHADDPD256 + OpAMD64VHADDPS128 + OpAMD64VHADDPS256 + OpAMD64VHSUBPD128 + OpAMD64VHSUBPD256 + OpAMD64VHSUBPS128 + OpAMD64VHSUBPS256 + OpAMD64VMAXPD128 + OpAMD64VMAXPD256 + OpAMD64VMAXPD512 + OpAMD64VMAXPDMasked128 + OpAMD64VMAXPDMasked256 + OpAMD64VMAXPDMasked512 + OpAMD64VMAXPS128 + OpAMD64VMAXPS256 + OpAMD64VMAXPS512 + OpAMD64VMAXPSMasked128 + OpAMD64VMAXPSMasked256 + OpAMD64VMAXPSMasked512 + OpAMD64VMINPD128 + OpAMD64VMINPD256 + OpAMD64VMINPD512 + OpAMD64VMINPDMasked128 + OpAMD64VMINPDMasked256 + OpAMD64VMINPDMasked512 + OpAMD64VMINPS128 + OpAMD64VMINPS256 + OpAMD64VMINPS512 + OpAMD64VMINPSMasked128 + OpAMD64VMINPSMasked256 + OpAMD64VMINPSMasked512 + OpAMD64VMOVDQU8Masked128 + OpAMD64VMOVDQU8Masked256 + OpAMD64VMOVDQU8Masked512 + OpAMD64VMOVDQU16Masked128 + OpAMD64VMOVDQU16Masked256 + OpAMD64VMOVDQU16Masked512 + OpAMD64VMOVDQU32Masked128 + OpAMD64VMOVDQU32Masked256 + OpAMD64VMOVDQU32Masked512 + OpAMD64VMOVDQU64Masked128 + OpAMD64VMOVDQU64Masked256 + OpAMD64VMOVDQU64Masked512 + OpAMD64VMULPD128 + OpAMD64VMULPD256 + OpAMD64VMULPD512 + OpAMD64VMULPDMasked128 + OpAMD64VMULPDMasked256 + OpAMD64VMULPDMasked512 + OpAMD64VMULPS128 + OpAMD64VMULPS256 + OpAMD64VMULPS512 + OpAMD64VMULPSMasked128 + OpAMD64VMULPSMasked256 + OpAMD64VMULPSMasked512 + OpAMD64VPABSB128 + OpAMD64VPABSB256 + OpAMD64VPABSB512 + OpAMD64VPABSBMasked128 + OpAMD64VPABSBMasked256 + OpAMD64VPABSBMasked512 + OpAMD64VPABSD128 + OpAMD64VPABSD256 + OpAMD64VPABSD512 + OpAMD64VPABSDMasked128 + OpAMD64VPABSDMasked256 + OpAMD64VPABSDMasked512 + OpAMD64VPABSQ128 + OpAMD64VPABSQ256 + OpAMD64VPABSQ512 + OpAMD64VPABSQMasked128 + OpAMD64VPABSQMasked256 + OpAMD64VPABSQMasked512 + OpAMD64VPABSW128 + OpAMD64VPABSW256 + OpAMD64VPABSW512 + OpAMD64VPABSWMasked128 + OpAMD64VPABSWMasked256 + OpAMD64VPABSWMasked512 + OpAMD64VPACKSSDW128 + OpAMD64VPACKSSDW256 + OpAMD64VPACKSSDW512 + OpAMD64VPACKSSDWMasked128 + OpAMD64VPACKSSDWMasked256 + OpAMD64VPACKSSDWMasked512 + OpAMD64VPACKUSDW128 + OpAMD64VPACKUSDW256 + OpAMD64VPACKUSDW512 + OpAMD64VPACKUSDWMasked128 + OpAMD64VPACKUSDWMasked256 + OpAMD64VPACKUSDWMasked512 + OpAMD64VPADDB128 + OpAMD64VPADDB256 + OpAMD64VPADDB512 + OpAMD64VPADDBMasked128 + OpAMD64VPADDBMasked256 + OpAMD64VPADDBMasked512 + OpAMD64VPADDD128 + OpAMD64VPADDD256 + OpAMD64VPADDD512 + OpAMD64VPADDDMasked128 + OpAMD64VPADDDMasked256 + OpAMD64VPADDDMasked512 + OpAMD64VPADDQ128 + OpAMD64VPADDQ256 + OpAMD64VPADDQ512 + OpAMD64VPADDQMasked128 + OpAMD64VPADDQMasked256 + OpAMD64VPADDQMasked512 + OpAMD64VPADDSB128 + OpAMD64VPADDSB256 + OpAMD64VPADDSB512 + OpAMD64VPADDSBMasked128 + OpAMD64VPADDSBMasked256 + OpAMD64VPADDSBMasked512 + OpAMD64VPADDSW128 + OpAMD64VPADDSW256 + OpAMD64VPADDSW512 + OpAMD64VPADDSWMasked128 + OpAMD64VPADDSWMasked256 + OpAMD64VPADDSWMasked512 + OpAMD64VPADDUSB128 + OpAMD64VPADDUSB256 + OpAMD64VPADDUSB512 + OpAMD64VPADDUSBMasked128 + OpAMD64VPADDUSBMasked256 + OpAMD64VPADDUSBMasked512 + OpAMD64VPADDUSW128 + OpAMD64VPADDUSW256 + OpAMD64VPADDUSW512 + OpAMD64VPADDUSWMasked128 + OpAMD64VPADDUSWMasked256 + OpAMD64VPADDUSWMasked512 + OpAMD64VPADDW128 + OpAMD64VPADDW256 + OpAMD64VPADDW512 + OpAMD64VPADDWMasked128 + OpAMD64VPADDWMasked256 + OpAMD64VPADDWMasked512 + OpAMD64VPAND128 + OpAMD64VPAND256 + OpAMD64VPANDD512 + OpAMD64VPANDDMasked128 + OpAMD64VPANDDMasked256 + OpAMD64VPANDDMasked512 + OpAMD64VPANDN128 + OpAMD64VPANDN256 + OpAMD64VPANDND512 + OpAMD64VPANDNDMasked128 + OpAMD64VPANDNDMasked256 + OpAMD64VPANDNDMasked512 + OpAMD64VPANDNQ512 + OpAMD64VPANDNQMasked128 + OpAMD64VPANDNQMasked256 + OpAMD64VPANDNQMasked512 + OpAMD64VPANDQ512 + OpAMD64VPANDQMasked128 + OpAMD64VPANDQMasked256 + OpAMD64VPANDQMasked512 + OpAMD64VPAVGB128 + OpAMD64VPAVGB256 + OpAMD64VPAVGB512 + OpAMD64VPAVGBMasked128 + OpAMD64VPAVGBMasked256 + OpAMD64VPAVGBMasked512 + OpAMD64VPAVGW128 + OpAMD64VPAVGW256 + OpAMD64VPAVGW512 + OpAMD64VPAVGWMasked128 + OpAMD64VPAVGWMasked256 + OpAMD64VPAVGWMasked512 + OpAMD64VPBLENDMBMasked512 + OpAMD64VPBLENDMDMasked512 + OpAMD64VPBLENDMQMasked512 + OpAMD64VPBLENDMWMasked512 + OpAMD64VPBLENDVB128 + OpAMD64VPBLENDVB256 + OpAMD64VPBROADCASTB128 + OpAMD64VPBROADCASTB256 + OpAMD64VPBROADCASTB512 + OpAMD64VPBROADCASTBMasked128 + OpAMD64VPBROADCASTBMasked256 + OpAMD64VPBROADCASTBMasked512 + OpAMD64VPBROADCASTD128 + OpAMD64VPBROADCASTD256 + OpAMD64VPBROADCASTD512 + OpAMD64VPBROADCASTDMasked128 + OpAMD64VPBROADCASTDMasked256 + OpAMD64VPBROADCASTDMasked512 + OpAMD64VPBROADCASTQ128 + OpAMD64VPBROADCASTQ256 + OpAMD64VPBROADCASTQ512 + OpAMD64VPBROADCASTQMasked128 + OpAMD64VPBROADCASTQMasked256 + OpAMD64VPBROADCASTQMasked512 + OpAMD64VPBROADCASTW128 + OpAMD64VPBROADCASTW256 + OpAMD64VPBROADCASTW512 + OpAMD64VPBROADCASTWMasked128 + OpAMD64VPBROADCASTWMasked256 + OpAMD64VPBROADCASTWMasked512 + OpAMD64VPCMPEQB128 + OpAMD64VPCMPEQB256 + OpAMD64VPCMPEQB512 + OpAMD64VPCMPEQD128 + OpAMD64VPCMPEQD256 + OpAMD64VPCMPEQD512 + OpAMD64VPCMPEQQ128 + OpAMD64VPCMPEQQ256 + OpAMD64VPCMPEQQ512 + OpAMD64VPCMPEQW128 + OpAMD64VPCMPEQW256 + OpAMD64VPCMPEQW512 + OpAMD64VPCMPGTB128 + OpAMD64VPCMPGTB256 + OpAMD64VPCMPGTB512 + OpAMD64VPCMPGTD128 + OpAMD64VPCMPGTD256 + OpAMD64VPCMPGTD512 + OpAMD64VPCMPGTQ128 + OpAMD64VPCMPGTQ256 + OpAMD64VPCMPGTQ512 + OpAMD64VPCMPGTW128 + OpAMD64VPCMPGTW256 + OpAMD64VPCMPGTW512 + OpAMD64VPCOMPRESSBMasked128 + OpAMD64VPCOMPRESSBMasked256 + OpAMD64VPCOMPRESSBMasked512 + OpAMD64VPCOMPRESSDMasked128 + OpAMD64VPCOMPRESSDMasked256 + OpAMD64VPCOMPRESSDMasked512 + OpAMD64VPCOMPRESSQMasked128 + OpAMD64VPCOMPRESSQMasked256 + OpAMD64VPCOMPRESSQMasked512 + OpAMD64VPCOMPRESSWMasked128 + OpAMD64VPCOMPRESSWMasked256 + OpAMD64VPCOMPRESSWMasked512 + OpAMD64VPDPWSSD128 + OpAMD64VPDPWSSD256 + OpAMD64VPDPWSSD512 + OpAMD64VPDPWSSDMasked128 + OpAMD64VPDPWSSDMasked256 + OpAMD64VPDPWSSDMasked512 + OpAMD64VPERMB128 + OpAMD64VPERMB256 + OpAMD64VPERMB512 + OpAMD64VPERMBMasked128 + OpAMD64VPERMBMasked256 + OpAMD64VPERMBMasked512 + OpAMD64VPERMD256 + OpAMD64VPERMD512 + OpAMD64VPERMDMasked256 + OpAMD64VPERMDMasked512 + OpAMD64VPERMI2B128 + OpAMD64VPERMI2B256 + OpAMD64VPERMI2B512 + OpAMD64VPERMI2BMasked128 + OpAMD64VPERMI2BMasked256 + OpAMD64VPERMI2BMasked512 + OpAMD64VPERMI2D128 + OpAMD64VPERMI2D256 + OpAMD64VPERMI2D512 + OpAMD64VPERMI2DMasked128 + OpAMD64VPERMI2DMasked256 + OpAMD64VPERMI2DMasked512 + OpAMD64VPERMI2PD128 + OpAMD64VPERMI2PD256 + OpAMD64VPERMI2PD512 + OpAMD64VPERMI2PDMasked128 + OpAMD64VPERMI2PDMasked256 + OpAMD64VPERMI2PDMasked512 + OpAMD64VPERMI2PS128 + OpAMD64VPERMI2PS256 + OpAMD64VPERMI2PS512 + OpAMD64VPERMI2PSMasked128 + OpAMD64VPERMI2PSMasked256 + OpAMD64VPERMI2PSMasked512 + OpAMD64VPERMI2Q128 + OpAMD64VPERMI2Q256 + OpAMD64VPERMI2Q512 + OpAMD64VPERMI2QMasked128 + OpAMD64VPERMI2QMasked256 + OpAMD64VPERMI2QMasked512 + OpAMD64VPERMI2W128 + OpAMD64VPERMI2W256 + OpAMD64VPERMI2W512 + OpAMD64VPERMI2WMasked128 + OpAMD64VPERMI2WMasked256 + OpAMD64VPERMI2WMasked512 + OpAMD64VPERMPD256 + OpAMD64VPERMPD512 + OpAMD64VPERMPDMasked256 + OpAMD64VPERMPDMasked512 + OpAMD64VPERMPS256 + OpAMD64VPERMPS512 + OpAMD64VPERMPSMasked256 + OpAMD64VPERMPSMasked512 + OpAMD64VPERMQ256 + OpAMD64VPERMQ512 + OpAMD64VPERMQMasked256 + OpAMD64VPERMQMasked512 + OpAMD64VPERMW128 + OpAMD64VPERMW256 + OpAMD64VPERMW512 + OpAMD64VPERMWMasked128 + OpAMD64VPERMWMasked256 + OpAMD64VPERMWMasked512 + OpAMD64VPEXPANDBMasked128 + OpAMD64VPEXPANDBMasked256 + OpAMD64VPEXPANDBMasked512 + OpAMD64VPEXPANDDMasked128 + OpAMD64VPEXPANDDMasked256 + OpAMD64VPEXPANDDMasked512 + OpAMD64VPEXPANDQMasked128 + OpAMD64VPEXPANDQMasked256 + OpAMD64VPEXPANDQMasked512 + OpAMD64VPEXPANDWMasked128 + OpAMD64VPEXPANDWMasked256 + OpAMD64VPEXPANDWMasked512 + OpAMD64VPHADDD128 + OpAMD64VPHADDD256 + OpAMD64VPHADDSW128 + OpAMD64VPHADDSW256 + OpAMD64VPHADDW128 + OpAMD64VPHADDW256 + OpAMD64VPHSUBD128 + OpAMD64VPHSUBD256 + OpAMD64VPHSUBSW128 + OpAMD64VPHSUBSW256 + OpAMD64VPHSUBW128 + OpAMD64VPHSUBW256 + OpAMD64VPLZCNTD128 + OpAMD64VPLZCNTD256 + OpAMD64VPLZCNTD512 + OpAMD64VPLZCNTDMasked128 + OpAMD64VPLZCNTDMasked256 + OpAMD64VPLZCNTDMasked512 + OpAMD64VPLZCNTQ128 + OpAMD64VPLZCNTQ256 + OpAMD64VPLZCNTQ512 + OpAMD64VPLZCNTQMasked128 + OpAMD64VPLZCNTQMasked256 + OpAMD64VPLZCNTQMasked512 + OpAMD64VPMADDUBSW128 + OpAMD64VPMADDUBSW256 + OpAMD64VPMADDUBSW512 + OpAMD64VPMADDUBSWMasked128 + OpAMD64VPMADDUBSWMasked256 + OpAMD64VPMADDUBSWMasked512 + OpAMD64VPMADDWD128 + OpAMD64VPMADDWD256 + OpAMD64VPMADDWD512 + OpAMD64VPMADDWDMasked128 + OpAMD64VPMADDWDMasked256 + OpAMD64VPMADDWDMasked512 + OpAMD64VPMAXSB128 + OpAMD64VPMAXSB256 + OpAMD64VPMAXSB512 + OpAMD64VPMAXSBMasked128 + OpAMD64VPMAXSBMasked256 + OpAMD64VPMAXSBMasked512 + OpAMD64VPMAXSD128 + OpAMD64VPMAXSD256 + OpAMD64VPMAXSD512 + OpAMD64VPMAXSDMasked128 + OpAMD64VPMAXSDMasked256 + OpAMD64VPMAXSDMasked512 + OpAMD64VPMAXSQ128 + OpAMD64VPMAXSQ256 + OpAMD64VPMAXSQ512 + OpAMD64VPMAXSQMasked128 + OpAMD64VPMAXSQMasked256 + OpAMD64VPMAXSQMasked512 + OpAMD64VPMAXSW128 + OpAMD64VPMAXSW256 + OpAMD64VPMAXSW512 + OpAMD64VPMAXSWMasked128 + OpAMD64VPMAXSWMasked256 + OpAMD64VPMAXSWMasked512 + OpAMD64VPMAXUB128 + OpAMD64VPMAXUB256 + OpAMD64VPMAXUB512 + OpAMD64VPMAXUBMasked128 + OpAMD64VPMAXUBMasked256 + OpAMD64VPMAXUBMasked512 + OpAMD64VPMAXUD128 + OpAMD64VPMAXUD256 + OpAMD64VPMAXUD512 + OpAMD64VPMAXUDMasked128 + OpAMD64VPMAXUDMasked256 + OpAMD64VPMAXUDMasked512 + OpAMD64VPMAXUQ128 + OpAMD64VPMAXUQ256 + OpAMD64VPMAXUQ512 + OpAMD64VPMAXUQMasked128 + OpAMD64VPMAXUQMasked256 + OpAMD64VPMAXUQMasked512 + OpAMD64VPMAXUW128 + OpAMD64VPMAXUW256 + OpAMD64VPMAXUW512 + OpAMD64VPMAXUWMasked128 + OpAMD64VPMAXUWMasked256 + OpAMD64VPMAXUWMasked512 + OpAMD64VPMINSB128 + OpAMD64VPMINSB256 + OpAMD64VPMINSB512 + OpAMD64VPMINSBMasked128 + OpAMD64VPMINSBMasked256 + OpAMD64VPMINSBMasked512 + OpAMD64VPMINSD128 + OpAMD64VPMINSD256 + OpAMD64VPMINSD512 + OpAMD64VPMINSDMasked128 + OpAMD64VPMINSDMasked256 + OpAMD64VPMINSDMasked512 + OpAMD64VPMINSQ128 + OpAMD64VPMINSQ256 + OpAMD64VPMINSQ512 + OpAMD64VPMINSQMasked128 + OpAMD64VPMINSQMasked256 + OpAMD64VPMINSQMasked512 + OpAMD64VPMINSW128 + OpAMD64VPMINSW256 + OpAMD64VPMINSW512 + OpAMD64VPMINSWMasked128 + OpAMD64VPMINSWMasked256 + OpAMD64VPMINSWMasked512 + OpAMD64VPMINUB128 + OpAMD64VPMINUB256 + OpAMD64VPMINUB512 + OpAMD64VPMINUBMasked128 + OpAMD64VPMINUBMasked256 + OpAMD64VPMINUBMasked512 + OpAMD64VPMINUD128 + OpAMD64VPMINUD256 + OpAMD64VPMINUD512 + OpAMD64VPMINUDMasked128 + OpAMD64VPMINUDMasked256 + OpAMD64VPMINUDMasked512 + OpAMD64VPMINUQ128 + OpAMD64VPMINUQ256 + OpAMD64VPMINUQ512 + OpAMD64VPMINUQMasked128 + OpAMD64VPMINUQMasked256 + OpAMD64VPMINUQMasked512 + OpAMD64VPMINUW128 + OpAMD64VPMINUW256 + OpAMD64VPMINUW512 + OpAMD64VPMINUWMasked128 + OpAMD64VPMINUWMasked256 + OpAMD64VPMINUWMasked512 + OpAMD64VPMOVDB128_128 + OpAMD64VPMOVDB128_256 + OpAMD64VPMOVDB128_512 + OpAMD64VPMOVDBMasked128_128 + OpAMD64VPMOVDBMasked128_256 + OpAMD64VPMOVDBMasked128_512 + OpAMD64VPMOVDW128_128 + OpAMD64VPMOVDW128_256 + OpAMD64VPMOVDW256 + OpAMD64VPMOVDWMasked128_128 + OpAMD64VPMOVDWMasked128_256 + OpAMD64VPMOVDWMasked256 + OpAMD64VPMOVQB128_128 + OpAMD64VPMOVQB128_256 + OpAMD64VPMOVQB128_512 + OpAMD64VPMOVQBMasked128_128 + OpAMD64VPMOVQBMasked128_256 + OpAMD64VPMOVQBMasked128_512 + OpAMD64VPMOVQD128_128 + OpAMD64VPMOVQD128_256 + OpAMD64VPMOVQD256 + OpAMD64VPMOVQDMasked128_128 + OpAMD64VPMOVQDMasked128_256 + OpAMD64VPMOVQDMasked256 + OpAMD64VPMOVQW128_128 + OpAMD64VPMOVQW128_256 + OpAMD64VPMOVQW128_512 + OpAMD64VPMOVQWMasked128_128 + OpAMD64VPMOVQWMasked128_256 + OpAMD64VPMOVQWMasked128_512 + OpAMD64VPMOVSDB128_128 + OpAMD64VPMOVSDB128_256 + OpAMD64VPMOVSDB128_512 + OpAMD64VPMOVSDBMasked128_128 + OpAMD64VPMOVSDBMasked128_256 + OpAMD64VPMOVSDBMasked128_512 + OpAMD64VPMOVSDW128_128 + OpAMD64VPMOVSDW128_256 + OpAMD64VPMOVSDW256 + OpAMD64VPMOVSDWMasked128_128 + OpAMD64VPMOVSDWMasked128_256 + OpAMD64VPMOVSDWMasked256 + OpAMD64VPMOVSQB128_128 + OpAMD64VPMOVSQB128_256 + OpAMD64VPMOVSQB128_512 + OpAMD64VPMOVSQBMasked128_128 + OpAMD64VPMOVSQBMasked128_256 + OpAMD64VPMOVSQBMasked128_512 + OpAMD64VPMOVSQD128_128 + OpAMD64VPMOVSQD128_256 + OpAMD64VPMOVSQD256 + OpAMD64VPMOVSQDMasked128_128 + OpAMD64VPMOVSQDMasked128_256 + OpAMD64VPMOVSQDMasked256 + OpAMD64VPMOVSQW128_128 + OpAMD64VPMOVSQW128_256 + OpAMD64VPMOVSQW128_512 + OpAMD64VPMOVSQWMasked128_128 + OpAMD64VPMOVSQWMasked128_256 + OpAMD64VPMOVSQWMasked128_512 + OpAMD64VPMOVSWB128_128 + OpAMD64VPMOVSWB128_256 + OpAMD64VPMOVSWB256 + OpAMD64VPMOVSWBMasked128_128 + OpAMD64VPMOVSWBMasked128_256 + OpAMD64VPMOVSWBMasked256 + OpAMD64VPMOVSXBD128 + OpAMD64VPMOVSXBD256 + OpAMD64VPMOVSXBD512 + OpAMD64VPMOVSXBDMasked128 + OpAMD64VPMOVSXBDMasked256 + OpAMD64VPMOVSXBDMasked512 + OpAMD64VPMOVSXBQ128 + OpAMD64VPMOVSXBQ256 + OpAMD64VPMOVSXBQ512 + OpAMD64VPMOVSXBQMasked128 + OpAMD64VPMOVSXBQMasked256 + OpAMD64VPMOVSXBQMasked512 + OpAMD64VPMOVSXBW128 + OpAMD64VPMOVSXBW256 + OpAMD64VPMOVSXBW512 + OpAMD64VPMOVSXBWMasked128 + OpAMD64VPMOVSXBWMasked256 + OpAMD64VPMOVSXBWMasked512 + OpAMD64VPMOVSXDQ128 + OpAMD64VPMOVSXDQ256 + OpAMD64VPMOVSXDQ512 + OpAMD64VPMOVSXDQMasked128 + OpAMD64VPMOVSXDQMasked256 + OpAMD64VPMOVSXDQMasked512 + OpAMD64VPMOVSXWD128 + OpAMD64VPMOVSXWD256 + OpAMD64VPMOVSXWD512 + OpAMD64VPMOVSXWDMasked128 + OpAMD64VPMOVSXWDMasked256 + OpAMD64VPMOVSXWDMasked512 + OpAMD64VPMOVSXWQ128 + OpAMD64VPMOVSXWQ256 + OpAMD64VPMOVSXWQ512 + OpAMD64VPMOVSXWQMasked128 + OpAMD64VPMOVSXWQMasked256 + OpAMD64VPMOVSXWQMasked512 + OpAMD64VPMOVUSDB128_128 + OpAMD64VPMOVUSDB128_256 + OpAMD64VPMOVUSDB128_512 + OpAMD64VPMOVUSDBMasked128_128 + OpAMD64VPMOVUSDBMasked128_256 + OpAMD64VPMOVUSDBMasked128_512 + OpAMD64VPMOVUSDW128_128 + OpAMD64VPMOVUSDW128_256 + OpAMD64VPMOVUSDW256 + OpAMD64VPMOVUSDWMasked128_128 + OpAMD64VPMOVUSDWMasked128_256 + OpAMD64VPMOVUSDWMasked256 + OpAMD64VPMOVUSQB128_128 + OpAMD64VPMOVUSQB128_256 + OpAMD64VPMOVUSQB128_512 + OpAMD64VPMOVUSQBMasked128_128 + OpAMD64VPMOVUSQBMasked128_256 + OpAMD64VPMOVUSQBMasked128_512 + OpAMD64VPMOVUSQD128_128 + OpAMD64VPMOVUSQD128_256 + OpAMD64VPMOVUSQD256 + OpAMD64VPMOVUSQDMasked128_128 + OpAMD64VPMOVUSQDMasked128_256 + OpAMD64VPMOVUSQDMasked256 + OpAMD64VPMOVUSQW128_128 + OpAMD64VPMOVUSQW128_256 + OpAMD64VPMOVUSQW128_512 + OpAMD64VPMOVUSQWMasked128_128 + OpAMD64VPMOVUSQWMasked128_256 + OpAMD64VPMOVUSQWMasked128_512 + OpAMD64VPMOVUSWB128_128 + OpAMD64VPMOVUSWB128_256 + OpAMD64VPMOVUSWB256 + OpAMD64VPMOVUSWBMasked128_128 + OpAMD64VPMOVUSWBMasked128_256 + OpAMD64VPMOVUSWBMasked256 + OpAMD64VPMOVWB128_128 + OpAMD64VPMOVWB128_256 + OpAMD64VPMOVWB256 + OpAMD64VPMOVWBMasked128_128 + OpAMD64VPMOVWBMasked128_256 + OpAMD64VPMOVWBMasked256 + OpAMD64VPMOVZXBD128 + OpAMD64VPMOVZXBD256 + OpAMD64VPMOVZXBD512 + OpAMD64VPMOVZXBDMasked128 + OpAMD64VPMOVZXBDMasked256 + OpAMD64VPMOVZXBDMasked512 + OpAMD64VPMOVZXBQ128 + OpAMD64VPMOVZXBQ256 + OpAMD64VPMOVZXBQ512 + OpAMD64VPMOVZXBQMasked128 + OpAMD64VPMOVZXBQMasked256 + OpAMD64VPMOVZXBQMasked512 + OpAMD64VPMOVZXBW128 + OpAMD64VPMOVZXBW256 + OpAMD64VPMOVZXBW512 + OpAMD64VPMOVZXBWMasked128 + OpAMD64VPMOVZXBWMasked256 + OpAMD64VPMOVZXBWMasked512 + OpAMD64VPMOVZXDQ128 + OpAMD64VPMOVZXDQ256 + OpAMD64VPMOVZXDQ512 + OpAMD64VPMOVZXDQMasked128 + OpAMD64VPMOVZXDQMasked256 + OpAMD64VPMOVZXDQMasked512 + OpAMD64VPMOVZXWD128 + OpAMD64VPMOVZXWD256 + OpAMD64VPMOVZXWD512 + OpAMD64VPMOVZXWDMasked128 + OpAMD64VPMOVZXWDMasked256 + OpAMD64VPMOVZXWDMasked512 + OpAMD64VPMOVZXWQ128 + OpAMD64VPMOVZXWQ256 + OpAMD64VPMOVZXWQ512 + OpAMD64VPMOVZXWQMasked128 + OpAMD64VPMOVZXWQMasked256 + OpAMD64VPMOVZXWQMasked512 + OpAMD64VPMULDQ128 + OpAMD64VPMULDQ256 + OpAMD64VPMULHUW128 + OpAMD64VPMULHUW256 + OpAMD64VPMULHUW512 + OpAMD64VPMULHUWMasked128 + OpAMD64VPMULHUWMasked256 + OpAMD64VPMULHUWMasked512 + OpAMD64VPMULHW128 + OpAMD64VPMULHW256 + OpAMD64VPMULHW512 + OpAMD64VPMULHWMasked128 + OpAMD64VPMULHWMasked256 + OpAMD64VPMULHWMasked512 + OpAMD64VPMULLD128 + OpAMD64VPMULLD256 + OpAMD64VPMULLD512 + OpAMD64VPMULLDMasked128 + OpAMD64VPMULLDMasked256 + OpAMD64VPMULLDMasked512 + OpAMD64VPMULLQ128 + OpAMD64VPMULLQ256 + OpAMD64VPMULLQ512 + OpAMD64VPMULLQMasked128 + OpAMD64VPMULLQMasked256 + OpAMD64VPMULLQMasked512 + OpAMD64VPMULLW128 + OpAMD64VPMULLW256 + OpAMD64VPMULLW512 + OpAMD64VPMULLWMasked128 + OpAMD64VPMULLWMasked256 + OpAMD64VPMULLWMasked512 + OpAMD64VPMULUDQ128 + OpAMD64VPMULUDQ256 + OpAMD64VPOPCNTB128 + OpAMD64VPOPCNTB256 + OpAMD64VPOPCNTB512 + OpAMD64VPOPCNTBMasked128 + OpAMD64VPOPCNTBMasked256 + OpAMD64VPOPCNTBMasked512 + OpAMD64VPOPCNTD128 + OpAMD64VPOPCNTD256 + OpAMD64VPOPCNTD512 + OpAMD64VPOPCNTDMasked128 + OpAMD64VPOPCNTDMasked256 + OpAMD64VPOPCNTDMasked512 + OpAMD64VPOPCNTQ128 + OpAMD64VPOPCNTQ256 + OpAMD64VPOPCNTQ512 + OpAMD64VPOPCNTQMasked128 + OpAMD64VPOPCNTQMasked256 + OpAMD64VPOPCNTQMasked512 + OpAMD64VPOPCNTW128 + OpAMD64VPOPCNTW256 + OpAMD64VPOPCNTW512 + OpAMD64VPOPCNTWMasked128 + OpAMD64VPOPCNTWMasked256 + OpAMD64VPOPCNTWMasked512 + OpAMD64VPOR128 + OpAMD64VPOR256 + OpAMD64VPORD512 + OpAMD64VPORDMasked128 + OpAMD64VPORDMasked256 + OpAMD64VPORDMasked512 + OpAMD64VPORQ512 + OpAMD64VPORQMasked128 + OpAMD64VPORQMasked256 + OpAMD64VPORQMasked512 + OpAMD64VPROLVD128 + OpAMD64VPROLVD256 + OpAMD64VPROLVD512 + OpAMD64VPROLVDMasked128 + OpAMD64VPROLVDMasked256 + OpAMD64VPROLVDMasked512 + OpAMD64VPROLVQ128 + OpAMD64VPROLVQ256 + OpAMD64VPROLVQ512 + OpAMD64VPROLVQMasked128 + OpAMD64VPROLVQMasked256 + OpAMD64VPROLVQMasked512 + OpAMD64VPRORVD128 + OpAMD64VPRORVD256 + OpAMD64VPRORVD512 + OpAMD64VPRORVDMasked128 + OpAMD64VPRORVDMasked256 + OpAMD64VPRORVDMasked512 + OpAMD64VPRORVQ128 + OpAMD64VPRORVQ256 + OpAMD64VPRORVQ512 + OpAMD64VPRORVQMasked128 + OpAMD64VPRORVQMasked256 + OpAMD64VPRORVQMasked512 + OpAMD64VPSADBW128 + OpAMD64VPSADBW256 + OpAMD64VPSADBW512 + OpAMD64VPSHLDVD128 + OpAMD64VPSHLDVD256 + OpAMD64VPSHLDVD512 + OpAMD64VPSHLDVDMasked128 + OpAMD64VPSHLDVDMasked256 + OpAMD64VPSHLDVDMasked512 + OpAMD64VPSHLDVQ128 + OpAMD64VPSHLDVQ256 + OpAMD64VPSHLDVQ512 + OpAMD64VPSHLDVQMasked128 + OpAMD64VPSHLDVQMasked256 + OpAMD64VPSHLDVQMasked512 + OpAMD64VPSHLDVW128 + OpAMD64VPSHLDVW256 + OpAMD64VPSHLDVW512 + OpAMD64VPSHLDVWMasked128 + OpAMD64VPSHLDVWMasked256 + OpAMD64VPSHLDVWMasked512 + OpAMD64VPSHRDVD128 + OpAMD64VPSHRDVD256 + OpAMD64VPSHRDVD512 + OpAMD64VPSHRDVDMasked128 + OpAMD64VPSHRDVDMasked256 + OpAMD64VPSHRDVDMasked512 + OpAMD64VPSHRDVQ128 + OpAMD64VPSHRDVQ256 + OpAMD64VPSHRDVQ512 + OpAMD64VPSHRDVQMasked128 + OpAMD64VPSHRDVQMasked256 + OpAMD64VPSHRDVQMasked512 + OpAMD64VPSHRDVW128 + OpAMD64VPSHRDVW256 + OpAMD64VPSHRDVW512 + OpAMD64VPSHRDVWMasked128 + OpAMD64VPSHRDVWMasked256 + OpAMD64VPSHRDVWMasked512 + OpAMD64VPSHUFB128 + OpAMD64VPSHUFB256 + OpAMD64VPSHUFB512 + OpAMD64VPSHUFBMasked128 + OpAMD64VPSHUFBMasked256 + OpAMD64VPSHUFBMasked512 + OpAMD64VPSIGNB128 + OpAMD64VPSIGNB256 + OpAMD64VPSIGND128 + OpAMD64VPSIGND256 + OpAMD64VPSIGNW128 + OpAMD64VPSIGNW256 + OpAMD64VPSLLD128 + OpAMD64VPSLLD256 + OpAMD64VPSLLD512 + OpAMD64VPSLLDMasked128 + OpAMD64VPSLLDMasked256 + OpAMD64VPSLLDMasked512 + OpAMD64VPSLLQ128 + OpAMD64VPSLLQ256 + OpAMD64VPSLLQ512 + OpAMD64VPSLLQMasked128 + OpAMD64VPSLLQMasked256 + OpAMD64VPSLLQMasked512 + OpAMD64VPSLLVD128 + OpAMD64VPSLLVD256 + OpAMD64VPSLLVD512 + OpAMD64VPSLLVDMasked128 + OpAMD64VPSLLVDMasked256 + OpAMD64VPSLLVDMasked512 + OpAMD64VPSLLVQ128 + OpAMD64VPSLLVQ256 + OpAMD64VPSLLVQ512 + OpAMD64VPSLLVQMasked128 + OpAMD64VPSLLVQMasked256 + OpAMD64VPSLLVQMasked512 + OpAMD64VPSLLVW128 + OpAMD64VPSLLVW256 + OpAMD64VPSLLVW512 + OpAMD64VPSLLVWMasked128 + OpAMD64VPSLLVWMasked256 + OpAMD64VPSLLVWMasked512 + OpAMD64VPSLLW128 + OpAMD64VPSLLW256 + OpAMD64VPSLLW512 + OpAMD64VPSLLWMasked128 + OpAMD64VPSLLWMasked256 + OpAMD64VPSLLWMasked512 + OpAMD64VPSRAD128 + OpAMD64VPSRAD256 + OpAMD64VPSRAD512 + OpAMD64VPSRADMasked128 + OpAMD64VPSRADMasked256 + OpAMD64VPSRADMasked512 + OpAMD64VPSRAQ128 + OpAMD64VPSRAQ256 + OpAMD64VPSRAQ512 + OpAMD64VPSRAQMasked128 + OpAMD64VPSRAQMasked256 + OpAMD64VPSRAQMasked512 + OpAMD64VPSRAVD128 + OpAMD64VPSRAVD256 + OpAMD64VPSRAVD512 + OpAMD64VPSRAVDMasked128 + OpAMD64VPSRAVDMasked256 + OpAMD64VPSRAVDMasked512 + OpAMD64VPSRAVQ128 + OpAMD64VPSRAVQ256 + OpAMD64VPSRAVQ512 + OpAMD64VPSRAVQMasked128 + OpAMD64VPSRAVQMasked256 + OpAMD64VPSRAVQMasked512 + OpAMD64VPSRAVW128 + OpAMD64VPSRAVW256 + OpAMD64VPSRAVW512 + OpAMD64VPSRAVWMasked128 + OpAMD64VPSRAVWMasked256 + OpAMD64VPSRAVWMasked512 + OpAMD64VPSRAW128 + OpAMD64VPSRAW256 + OpAMD64VPSRAW512 + OpAMD64VPSRAWMasked128 + OpAMD64VPSRAWMasked256 + OpAMD64VPSRAWMasked512 + OpAMD64VPSRLD128 + OpAMD64VPSRLD256 + OpAMD64VPSRLD512 + OpAMD64VPSRLDMasked128 + OpAMD64VPSRLDMasked256 + OpAMD64VPSRLDMasked512 + OpAMD64VPSRLQ128 + OpAMD64VPSRLQ256 + OpAMD64VPSRLQ512 + OpAMD64VPSRLQMasked128 + OpAMD64VPSRLQMasked256 + OpAMD64VPSRLQMasked512 + OpAMD64VPSRLVD128 + OpAMD64VPSRLVD256 + OpAMD64VPSRLVD512 + OpAMD64VPSRLVDMasked128 + OpAMD64VPSRLVDMasked256 + OpAMD64VPSRLVDMasked512 + OpAMD64VPSRLVQ128 + OpAMD64VPSRLVQ256 + OpAMD64VPSRLVQ512 + OpAMD64VPSRLVQMasked128 + OpAMD64VPSRLVQMasked256 + OpAMD64VPSRLVQMasked512 + OpAMD64VPSRLVW128 + OpAMD64VPSRLVW256 + OpAMD64VPSRLVW512 + OpAMD64VPSRLVWMasked128 + OpAMD64VPSRLVWMasked256 + OpAMD64VPSRLVWMasked512 + OpAMD64VPSRLW128 + OpAMD64VPSRLW256 + OpAMD64VPSRLW512 + OpAMD64VPSRLWMasked128 + OpAMD64VPSRLWMasked256 + OpAMD64VPSRLWMasked512 + OpAMD64VPSUBB128 + OpAMD64VPSUBB256 + OpAMD64VPSUBB512 + OpAMD64VPSUBBMasked128 + OpAMD64VPSUBBMasked256 + OpAMD64VPSUBBMasked512 + OpAMD64VPSUBD128 + OpAMD64VPSUBD256 + OpAMD64VPSUBD512 + OpAMD64VPSUBDMasked128 + OpAMD64VPSUBDMasked256 + OpAMD64VPSUBDMasked512 + OpAMD64VPSUBQ128 + OpAMD64VPSUBQ256 + OpAMD64VPSUBQ512 + OpAMD64VPSUBQMasked128 + OpAMD64VPSUBQMasked256 + OpAMD64VPSUBQMasked512 + OpAMD64VPSUBSB128 + OpAMD64VPSUBSB256 + OpAMD64VPSUBSB512 + OpAMD64VPSUBSBMasked128 + OpAMD64VPSUBSBMasked256 + OpAMD64VPSUBSBMasked512 + OpAMD64VPSUBSW128 + OpAMD64VPSUBSW256 + OpAMD64VPSUBSW512 + OpAMD64VPSUBSWMasked128 + OpAMD64VPSUBSWMasked256 + OpAMD64VPSUBSWMasked512 + OpAMD64VPSUBUSB128 + OpAMD64VPSUBUSB256 + OpAMD64VPSUBUSB512 + OpAMD64VPSUBUSBMasked128 + OpAMD64VPSUBUSBMasked256 + OpAMD64VPSUBUSBMasked512 + OpAMD64VPSUBUSW128 + OpAMD64VPSUBUSW256 + OpAMD64VPSUBUSW512 + OpAMD64VPSUBUSWMasked128 + OpAMD64VPSUBUSWMasked256 + OpAMD64VPSUBUSWMasked512 + OpAMD64VPSUBW128 + OpAMD64VPSUBW256 + OpAMD64VPSUBW512 + OpAMD64VPSUBWMasked128 + OpAMD64VPSUBWMasked256 + OpAMD64VPSUBWMasked512 + OpAMD64VPUNPCKHDQ128 + OpAMD64VPUNPCKHDQ256 + OpAMD64VPUNPCKHDQ512 + OpAMD64VPUNPCKHQDQ128 + OpAMD64VPUNPCKHQDQ256 + OpAMD64VPUNPCKHQDQ512 + OpAMD64VPUNPCKHWD128 + OpAMD64VPUNPCKHWD256 + OpAMD64VPUNPCKHWD512 + OpAMD64VPUNPCKLDQ128 + OpAMD64VPUNPCKLDQ256 + OpAMD64VPUNPCKLDQ512 + OpAMD64VPUNPCKLQDQ128 + OpAMD64VPUNPCKLQDQ256 + OpAMD64VPUNPCKLQDQ512 + OpAMD64VPUNPCKLWD128 + OpAMD64VPUNPCKLWD256 + OpAMD64VPUNPCKLWD512 + OpAMD64VPXOR128 + OpAMD64VPXOR256 + OpAMD64VPXORD512 + OpAMD64VPXORDMasked128 + OpAMD64VPXORDMasked256 + OpAMD64VPXORDMasked512 + OpAMD64VPXORQ512 + OpAMD64VPXORQMasked128 + OpAMD64VPXORQMasked256 + OpAMD64VPXORQMasked512 + OpAMD64VRCP14PD128 + OpAMD64VRCP14PD256 + OpAMD64VRCP14PD512 + OpAMD64VRCP14PDMasked128 + OpAMD64VRCP14PDMasked256 + OpAMD64VRCP14PDMasked512 + OpAMD64VRCP14PS512 + OpAMD64VRCP14PSMasked128 + OpAMD64VRCP14PSMasked256 + OpAMD64VRCP14PSMasked512 + OpAMD64VRCPPS128 + OpAMD64VRCPPS256 + OpAMD64VRSQRT14PD128 + OpAMD64VRSQRT14PD256 + OpAMD64VRSQRT14PD512 + OpAMD64VRSQRT14PDMasked128 + OpAMD64VRSQRT14PDMasked256 + OpAMD64VRSQRT14PDMasked512 + OpAMD64VRSQRT14PS512 + OpAMD64VRSQRT14PSMasked128 + OpAMD64VRSQRT14PSMasked256 + OpAMD64VRSQRT14PSMasked512 + OpAMD64VRSQRTPS128 + OpAMD64VRSQRTPS256 + OpAMD64VSCALEFPD128 + OpAMD64VSCALEFPD256 + OpAMD64VSCALEFPD512 + OpAMD64VSCALEFPDMasked128 + OpAMD64VSCALEFPDMasked256 + OpAMD64VSCALEFPDMasked512 + OpAMD64VSCALEFPS128 + OpAMD64VSCALEFPS256 + OpAMD64VSCALEFPS512 + OpAMD64VSCALEFPSMasked128 + OpAMD64VSCALEFPSMasked256 + OpAMD64VSCALEFPSMasked512 + OpAMD64VSQRTPD128 + OpAMD64VSQRTPD256 + OpAMD64VSQRTPD512 + OpAMD64VSQRTPDMasked128 + OpAMD64VSQRTPDMasked256 + OpAMD64VSQRTPDMasked512 + OpAMD64VSQRTPS128 + OpAMD64VSQRTPS256 + OpAMD64VSQRTPS512 + OpAMD64VSQRTPSMasked128 + OpAMD64VSQRTPSMasked256 + OpAMD64VSQRTPSMasked512 + OpAMD64VSUBPD128 + OpAMD64VSUBPD256 + OpAMD64VSUBPD512 + OpAMD64VSUBPDMasked128 + OpAMD64VSUBPDMasked256 + OpAMD64VSUBPDMasked512 + OpAMD64VSUBPS128 + OpAMD64VSUBPS256 + OpAMD64VSUBPS512 + OpAMD64VSUBPSMasked128 + OpAMD64VSUBPSMasked256 + OpAMD64VSUBPSMasked512 + OpAMD64SHA1RNDS4128 + OpAMD64VAESKEYGENASSIST128 + OpAMD64VCMPPD128 + OpAMD64VCMPPD256 + OpAMD64VCMPPD512 + OpAMD64VCMPPDMasked128 + OpAMD64VCMPPDMasked256 + OpAMD64VCMPPDMasked512 + OpAMD64VCMPPS128 + OpAMD64VCMPPS256 + OpAMD64VCMPPS512 + OpAMD64VCMPPSMasked128 + OpAMD64VCMPPSMasked256 + OpAMD64VCMPPSMasked512 + OpAMD64VEXTRACTF64X4256 + OpAMD64VEXTRACTF128128 + OpAMD64VEXTRACTI64X4256 + OpAMD64VEXTRACTI128128 + OpAMD64VGF2P8AFFINEINVQB128 + OpAMD64VGF2P8AFFINEINVQB256 + OpAMD64VGF2P8AFFINEINVQB512 + OpAMD64VGF2P8AFFINEINVQBMasked128 + OpAMD64VGF2P8AFFINEINVQBMasked256 + OpAMD64VGF2P8AFFINEINVQBMasked512 + OpAMD64VGF2P8AFFINEQB128 + OpAMD64VGF2P8AFFINEQB256 + OpAMD64VGF2P8AFFINEQB512 + OpAMD64VGF2P8AFFINEQBMasked128 + OpAMD64VGF2P8AFFINEQBMasked256 + OpAMD64VGF2P8AFFINEQBMasked512 + OpAMD64VINSERTF64X4512 + OpAMD64VINSERTF128256 + OpAMD64VINSERTI64X4512 + OpAMD64VINSERTI128256 + OpAMD64VPALIGNR128 + OpAMD64VPALIGNR256 + OpAMD64VPALIGNR512 + OpAMD64VPALIGNRMasked128 + OpAMD64VPALIGNRMasked256 + OpAMD64VPALIGNRMasked512 + OpAMD64VPCLMULQDQ128 + OpAMD64VPCLMULQDQ256 + OpAMD64VPCLMULQDQ512 + OpAMD64VPCMPB512 + OpAMD64VPCMPBMasked128 + OpAMD64VPCMPBMasked256 + OpAMD64VPCMPBMasked512 + OpAMD64VPCMPD512 + OpAMD64VPCMPDMasked128 + OpAMD64VPCMPDMasked256 + OpAMD64VPCMPDMasked512 + OpAMD64VPCMPQ512 + OpAMD64VPCMPQMasked128 + OpAMD64VPCMPQMasked256 + OpAMD64VPCMPQMasked512 + OpAMD64VPCMPUB512 + OpAMD64VPCMPUBMasked128 + OpAMD64VPCMPUBMasked256 + OpAMD64VPCMPUBMasked512 + OpAMD64VPCMPUD512 + OpAMD64VPCMPUDMasked128 + OpAMD64VPCMPUDMasked256 + OpAMD64VPCMPUDMasked512 + OpAMD64VPCMPUQ512 + OpAMD64VPCMPUQMasked128 + OpAMD64VPCMPUQMasked256 + OpAMD64VPCMPUQMasked512 + OpAMD64VPCMPUW512 + OpAMD64VPCMPUWMasked128 + OpAMD64VPCMPUWMasked256 + OpAMD64VPCMPUWMasked512 + OpAMD64VPCMPW512 + OpAMD64VPCMPWMasked128 + OpAMD64VPCMPWMasked256 + OpAMD64VPCMPWMasked512 + OpAMD64VPERM2F128256 + OpAMD64VPERM2I128256 + OpAMD64VPEXTRB128 + OpAMD64VPEXTRD128 + OpAMD64VPEXTRQ128 + OpAMD64VPEXTRW128 + OpAMD64VPINSRB128 + OpAMD64VPINSRD128 + OpAMD64VPINSRQ128 + OpAMD64VPINSRW128 + OpAMD64VPROLD128 + OpAMD64VPROLD256 + OpAMD64VPROLD512 + OpAMD64VPROLDMasked128 + OpAMD64VPROLDMasked256 + OpAMD64VPROLDMasked512 + OpAMD64VPROLQ128 + OpAMD64VPROLQ256 + OpAMD64VPROLQ512 + OpAMD64VPROLQMasked128 + OpAMD64VPROLQMasked256 + OpAMD64VPROLQMasked512 + OpAMD64VPRORD128 + OpAMD64VPRORD256 + OpAMD64VPRORD512 + OpAMD64VPRORDMasked128 + OpAMD64VPRORDMasked256 + OpAMD64VPRORDMasked512 + OpAMD64VPRORQ128 + OpAMD64VPRORQ256 + OpAMD64VPRORQ512 + OpAMD64VPRORQMasked128 + OpAMD64VPRORQMasked256 + OpAMD64VPRORQMasked512 + OpAMD64VPSHLDD128 + OpAMD64VPSHLDD256 + OpAMD64VPSHLDD512 + OpAMD64VPSHLDDMasked128 + OpAMD64VPSHLDDMasked256 + OpAMD64VPSHLDDMasked512 + OpAMD64VPSHLDQ128 + OpAMD64VPSHLDQ256 + OpAMD64VPSHLDQ512 + OpAMD64VPSHLDQMasked128 + OpAMD64VPSHLDQMasked256 + OpAMD64VPSHLDQMasked512 + OpAMD64VPSHLDW128 + OpAMD64VPSHLDW256 + OpAMD64VPSHLDW512 + OpAMD64VPSHLDWMasked128 + OpAMD64VPSHLDWMasked256 + OpAMD64VPSHLDWMasked512 + OpAMD64VPSHRDD128 + OpAMD64VPSHRDD256 + OpAMD64VPSHRDD512 + OpAMD64VPSHRDDMasked128 + OpAMD64VPSHRDDMasked256 + OpAMD64VPSHRDDMasked512 + OpAMD64VPSHRDQ128 + OpAMD64VPSHRDQ256 + OpAMD64VPSHRDQ512 + OpAMD64VPSHRDQMasked128 + OpAMD64VPSHRDQMasked256 + OpAMD64VPSHRDQMasked512 + OpAMD64VPSHRDW128 + OpAMD64VPSHRDW256 + OpAMD64VPSHRDW512 + OpAMD64VPSHRDWMasked128 + OpAMD64VPSHRDWMasked256 + OpAMD64VPSHRDWMasked512 + OpAMD64VPSHUFD128 + OpAMD64VPSHUFD256 + OpAMD64VPSHUFD512 + OpAMD64VPSHUFDMasked128 + OpAMD64VPSHUFDMasked256 + OpAMD64VPSHUFDMasked512 + OpAMD64VPSHUFHW128 + OpAMD64VPSHUFHW256 + OpAMD64VPSHUFHW512 + OpAMD64VPSHUFHWMasked128 + OpAMD64VPSHUFHWMasked256 + OpAMD64VPSHUFHWMasked512 + OpAMD64VPSHUFLW128 + OpAMD64VPSHUFLW256 + OpAMD64VPSHUFLW512 + OpAMD64VPSHUFLWMasked128 + OpAMD64VPSHUFLWMasked256 + OpAMD64VPSHUFLWMasked512 + OpAMD64VPSLLD128const + OpAMD64VPSLLD256const + OpAMD64VPSLLD512const + OpAMD64VPSLLDMasked128const + OpAMD64VPSLLDMasked256const + OpAMD64VPSLLDMasked512const + OpAMD64VPSLLQ128const + OpAMD64VPSLLQ256const + OpAMD64VPSLLQ512const + OpAMD64VPSLLQMasked128const + OpAMD64VPSLLQMasked256const + OpAMD64VPSLLQMasked512const + OpAMD64VPSLLW128const + OpAMD64VPSLLW256const + OpAMD64VPSLLW512const + OpAMD64VPSLLWMasked128const + OpAMD64VPSLLWMasked256const + OpAMD64VPSLLWMasked512const + OpAMD64VPSRAD128const + OpAMD64VPSRAD256const + OpAMD64VPSRAD512const + OpAMD64VPSRADMasked128const + OpAMD64VPSRADMasked256const + OpAMD64VPSRADMasked512const + OpAMD64VPSRAQ128const + OpAMD64VPSRAQ256const + OpAMD64VPSRAQ512const + OpAMD64VPSRAQMasked128const + OpAMD64VPSRAQMasked256const + OpAMD64VPSRAQMasked512const + OpAMD64VPSRAW128const + OpAMD64VPSRAW256const + OpAMD64VPSRAW512const + OpAMD64VPSRAWMasked128const + OpAMD64VPSRAWMasked256const + OpAMD64VPSRAWMasked512const + OpAMD64VPSRLD128const + OpAMD64VPSRLD256const + OpAMD64VPSRLD512const + OpAMD64VPSRLDMasked128const + OpAMD64VPSRLDMasked256const + OpAMD64VPSRLDMasked512const + OpAMD64VPSRLQ128const + OpAMD64VPSRLQ256const + OpAMD64VPSRLQ512const + OpAMD64VPSRLQMasked128const + OpAMD64VPSRLQMasked256const + OpAMD64VPSRLQMasked512const + OpAMD64VPSRLW128const + OpAMD64VPSRLW256const + OpAMD64VPSRLW512const + OpAMD64VPSRLWMasked128const + OpAMD64VPSRLWMasked256const + OpAMD64VPSRLWMasked512const + OpAMD64VPTERNLOGD128 + OpAMD64VPTERNLOGD256 + OpAMD64VPTERNLOGD512 + OpAMD64VPTERNLOGQ128 + OpAMD64VPTERNLOGQ256 + OpAMD64VPTERNLOGQ512 + OpAMD64VREDUCEPD128 + OpAMD64VREDUCEPD256 + OpAMD64VREDUCEPD512 + OpAMD64VREDUCEPDMasked128 + OpAMD64VREDUCEPDMasked256 + OpAMD64VREDUCEPDMasked512 + OpAMD64VREDUCEPS128 + OpAMD64VREDUCEPS256 + OpAMD64VREDUCEPS512 + OpAMD64VREDUCEPSMasked128 + OpAMD64VREDUCEPSMasked256 + OpAMD64VREDUCEPSMasked512 + OpAMD64VRNDSCALEPD128 + OpAMD64VRNDSCALEPD256 + OpAMD64VRNDSCALEPD512 + OpAMD64VRNDSCALEPDMasked128 + OpAMD64VRNDSCALEPDMasked256 + OpAMD64VRNDSCALEPDMasked512 + OpAMD64VRNDSCALEPS128 + OpAMD64VRNDSCALEPS256 + OpAMD64VRNDSCALEPS512 + OpAMD64VRNDSCALEPSMasked128 + OpAMD64VRNDSCALEPSMasked256 + OpAMD64VRNDSCALEPSMasked512 + OpAMD64VROUNDPD128 + OpAMD64VROUNDPD256 + OpAMD64VROUNDPS128 + OpAMD64VROUNDPS256 + OpAMD64VSHUFPD128 + OpAMD64VSHUFPD256 + OpAMD64VSHUFPD512 + OpAMD64VSHUFPS128 + OpAMD64VSHUFPS256 + OpAMD64VSHUFPS512 + OpAMD64VADDPD512load + OpAMD64VADDPDMasked128load + OpAMD64VADDPDMasked256load + OpAMD64VADDPDMasked512load + OpAMD64VADDPS512load + OpAMD64VADDPSMasked128load + OpAMD64VADDPSMasked256load + OpAMD64VADDPSMasked512load + OpAMD64VCVTDQ2PD512load + OpAMD64VCVTDQ2PDMasked256load + OpAMD64VCVTDQ2PDMasked512load + OpAMD64VCVTDQ2PS512load + OpAMD64VCVTDQ2PSMasked128load + OpAMD64VCVTDQ2PSMasked256load + OpAMD64VCVTDQ2PSMasked512load + OpAMD64VCVTPD2PS256load + OpAMD64VCVTPD2PSMasked256load + OpAMD64VCVTPD2PSXMasked128load + OpAMD64VCVTPD2PSYMasked128load + OpAMD64VCVTPS2PD512load + OpAMD64VCVTPS2PDMasked256load + OpAMD64VCVTPS2PDMasked512load + OpAMD64VCVTQQ2PD128load + OpAMD64VCVTQQ2PD256load + OpAMD64VCVTQQ2PD512load + OpAMD64VCVTQQ2PDMasked128load + OpAMD64VCVTQQ2PDMasked256load + OpAMD64VCVTQQ2PDMasked512load + OpAMD64VCVTQQ2PS256load + OpAMD64VCVTQQ2PSMasked256load + OpAMD64VCVTQQ2PSX128load + OpAMD64VCVTQQ2PSXMasked128load + OpAMD64VCVTQQ2PSY128load + OpAMD64VCVTQQ2PSYMasked128load + OpAMD64VCVTTPD2DQ256load + OpAMD64VCVTTPD2DQMasked256load + OpAMD64VCVTTPD2DQXMasked128load + OpAMD64VCVTTPD2DQYMasked128load + OpAMD64VCVTTPD2QQ128load + OpAMD64VCVTTPD2QQ256load + OpAMD64VCVTTPD2QQ512load + OpAMD64VCVTTPD2QQMasked128load + OpAMD64VCVTTPD2QQMasked256load + OpAMD64VCVTTPD2QQMasked512load + OpAMD64VCVTTPD2UDQ256load + OpAMD64VCVTTPD2UDQMasked256load + OpAMD64VCVTTPD2UDQX128load + OpAMD64VCVTTPD2UDQXMasked128load + OpAMD64VCVTTPD2UDQY128load + OpAMD64VCVTTPD2UDQYMasked128load + OpAMD64VCVTTPD2UQQ128load + OpAMD64VCVTTPD2UQQ256load + OpAMD64VCVTTPD2UQQ512load + OpAMD64VCVTTPD2UQQMasked128load + OpAMD64VCVTTPD2UQQMasked256load + OpAMD64VCVTTPD2UQQMasked512load + OpAMD64VCVTTPS2DQ512load + OpAMD64VCVTTPS2DQMasked128load + OpAMD64VCVTTPS2DQMasked256load + OpAMD64VCVTTPS2DQMasked512load + OpAMD64VCVTTPS2QQ256load + OpAMD64VCVTTPS2QQ512load + OpAMD64VCVTTPS2QQMasked256load + OpAMD64VCVTTPS2QQMasked512load + OpAMD64VCVTTPS2UDQ128load + OpAMD64VCVTTPS2UDQ256load + OpAMD64VCVTTPS2UDQ512load + OpAMD64VCVTTPS2UDQMasked128load + OpAMD64VCVTTPS2UDQMasked256load + OpAMD64VCVTTPS2UDQMasked512load + OpAMD64VCVTTPS2UQQ256load + OpAMD64VCVTTPS2UQQ512load + OpAMD64VCVTTPS2UQQMasked256load + OpAMD64VCVTTPS2UQQMasked512load + OpAMD64VCVTUDQ2PD256load + OpAMD64VCVTUDQ2PD512load + OpAMD64VCVTUDQ2PDMasked256load + OpAMD64VCVTUDQ2PDMasked512load + OpAMD64VCVTUDQ2PS128load + OpAMD64VCVTUDQ2PS256load + OpAMD64VCVTUDQ2PS512load + OpAMD64VCVTUDQ2PSMasked128load + OpAMD64VCVTUDQ2PSMasked256load + OpAMD64VCVTUDQ2PSMasked512load + OpAMD64VCVTUQQ2PD128load + OpAMD64VCVTUQQ2PD256load + OpAMD64VCVTUQQ2PD512load + OpAMD64VCVTUQQ2PDMasked128load + OpAMD64VCVTUQQ2PDMasked256load + OpAMD64VCVTUQQ2PDMasked512load + OpAMD64VCVTUQQ2PS256load + OpAMD64VCVTUQQ2PSMasked256load + OpAMD64VCVTUQQ2PSX128load + OpAMD64VCVTUQQ2PSXMasked128load + OpAMD64VCVTUQQ2PSY128load + OpAMD64VCVTUQQ2PSYMasked128load + OpAMD64VDIVPD512load + OpAMD64VDIVPDMasked128load + OpAMD64VDIVPDMasked256load + OpAMD64VDIVPDMasked512load + OpAMD64VDIVPS512load + OpAMD64VDIVPSMasked128load + OpAMD64VDIVPSMasked256load + OpAMD64VDIVPSMasked512load + OpAMD64VFMADD213PD512load + OpAMD64VFMADD213PDMasked128load + OpAMD64VFMADD213PDMasked256load + OpAMD64VFMADD213PDMasked512load + OpAMD64VFMADD213PS512load + OpAMD64VFMADD213PSMasked128load + OpAMD64VFMADD213PSMasked256load + OpAMD64VFMADD213PSMasked512load + OpAMD64VFMADDSUB213PD512load + OpAMD64VFMADDSUB213PDMasked128load + OpAMD64VFMADDSUB213PDMasked256load + OpAMD64VFMADDSUB213PDMasked512load + OpAMD64VFMADDSUB213PS512load + OpAMD64VFMADDSUB213PSMasked128load + OpAMD64VFMADDSUB213PSMasked256load + OpAMD64VFMADDSUB213PSMasked512load + OpAMD64VFMSUBADD213PD512load + OpAMD64VFMSUBADD213PDMasked128load + OpAMD64VFMSUBADD213PDMasked256load + OpAMD64VFMSUBADD213PDMasked512load + OpAMD64VFMSUBADD213PS512load + OpAMD64VFMSUBADD213PSMasked128load + OpAMD64VFMSUBADD213PSMasked256load + OpAMD64VFMSUBADD213PSMasked512load + OpAMD64VMAXPD512load + OpAMD64VMAXPDMasked128load + OpAMD64VMAXPDMasked256load + OpAMD64VMAXPDMasked512load + OpAMD64VMAXPS512load + OpAMD64VMAXPSMasked128load + OpAMD64VMAXPSMasked256load + OpAMD64VMAXPSMasked512load + OpAMD64VMINPD512load + OpAMD64VMINPDMasked128load + OpAMD64VMINPDMasked256load + OpAMD64VMINPDMasked512load + OpAMD64VMINPS512load + OpAMD64VMINPSMasked128load + OpAMD64VMINPSMasked256load + OpAMD64VMINPSMasked512load + OpAMD64VMULPD512load + OpAMD64VMULPDMasked128load + OpAMD64VMULPDMasked256load + OpAMD64VMULPDMasked512load + OpAMD64VMULPS512load + OpAMD64VMULPSMasked128load + OpAMD64VMULPSMasked256load + OpAMD64VMULPSMasked512load + OpAMD64VPABSD512load + OpAMD64VPABSDMasked128load + OpAMD64VPABSDMasked256load + OpAMD64VPABSDMasked512load + OpAMD64VPABSQ128load + OpAMD64VPABSQ256load + OpAMD64VPABSQ512load + OpAMD64VPABSQMasked128load + OpAMD64VPABSQMasked256load + OpAMD64VPABSQMasked512load + OpAMD64VPACKSSDW512load + OpAMD64VPACKSSDWMasked128load + OpAMD64VPACKSSDWMasked256load + OpAMD64VPACKSSDWMasked512load + OpAMD64VPACKUSDW512load + OpAMD64VPACKUSDWMasked128load + OpAMD64VPACKUSDWMasked256load + OpAMD64VPACKUSDWMasked512load + OpAMD64VPADDD512load + OpAMD64VPADDDMasked128load + OpAMD64VPADDDMasked256load + OpAMD64VPADDDMasked512load + OpAMD64VPADDQ512load + OpAMD64VPADDQMasked128load + OpAMD64VPADDQMasked256load + OpAMD64VPADDQMasked512load + OpAMD64VPANDD512load + OpAMD64VPANDDMasked128load + OpAMD64VPANDDMasked256load + OpAMD64VPANDDMasked512load + OpAMD64VPANDND512load + OpAMD64VPANDNDMasked128load + OpAMD64VPANDNDMasked256load + OpAMD64VPANDNDMasked512load + OpAMD64VPANDNQ512load + OpAMD64VPANDNQMasked128load + OpAMD64VPANDNQMasked256load + OpAMD64VPANDNQMasked512load + OpAMD64VPANDQ512load + OpAMD64VPANDQMasked128load + OpAMD64VPANDQMasked256load + OpAMD64VPANDQMasked512load + OpAMD64VPBLENDMDMasked512load + OpAMD64VPBLENDMQMasked512load + OpAMD64VPCMPEQD512load + OpAMD64VPCMPEQQ512load + OpAMD64VPCMPGTD512load + OpAMD64VPCMPGTQ512load + OpAMD64VPDPWSSD512load + OpAMD64VPDPWSSDMasked128load + OpAMD64VPDPWSSDMasked256load + OpAMD64VPDPWSSDMasked512load + OpAMD64VPERMD512load + OpAMD64VPERMDMasked256load + OpAMD64VPERMDMasked512load + OpAMD64VPERMI2D128load + OpAMD64VPERMI2D256load + OpAMD64VPERMI2D512load + OpAMD64VPERMI2DMasked128load + OpAMD64VPERMI2DMasked256load + OpAMD64VPERMI2DMasked512load + OpAMD64VPERMI2PD128load + OpAMD64VPERMI2PD256load + OpAMD64VPERMI2PD512load + OpAMD64VPERMI2PDMasked128load + OpAMD64VPERMI2PDMasked256load + OpAMD64VPERMI2PDMasked512load + OpAMD64VPERMI2PS128load + OpAMD64VPERMI2PS256load + OpAMD64VPERMI2PS512load + OpAMD64VPERMI2PSMasked128load + OpAMD64VPERMI2PSMasked256load + OpAMD64VPERMI2PSMasked512load + OpAMD64VPERMI2Q128load + OpAMD64VPERMI2Q256load + OpAMD64VPERMI2Q512load + OpAMD64VPERMI2QMasked128load + OpAMD64VPERMI2QMasked256load + OpAMD64VPERMI2QMasked512load + OpAMD64VPERMPD256load + OpAMD64VPERMPD512load + OpAMD64VPERMPDMasked256load + OpAMD64VPERMPDMasked512load + OpAMD64VPERMPS512load + OpAMD64VPERMPSMasked256load + OpAMD64VPERMPSMasked512load + OpAMD64VPERMQ256load + OpAMD64VPERMQ512load + OpAMD64VPERMQMasked256load + OpAMD64VPERMQMasked512load + OpAMD64VPLZCNTD128load + OpAMD64VPLZCNTD256load + OpAMD64VPLZCNTD512load + OpAMD64VPLZCNTDMasked128load + OpAMD64VPLZCNTDMasked256load + OpAMD64VPLZCNTDMasked512load + OpAMD64VPLZCNTQ128load + OpAMD64VPLZCNTQ256load + OpAMD64VPLZCNTQ512load + OpAMD64VPLZCNTQMasked128load + OpAMD64VPLZCNTQMasked256load + OpAMD64VPLZCNTQMasked512load + OpAMD64VPMAXSD512load + OpAMD64VPMAXSDMasked128load + OpAMD64VPMAXSDMasked256load + OpAMD64VPMAXSDMasked512load + OpAMD64VPMAXSQ128load + OpAMD64VPMAXSQ256load + OpAMD64VPMAXSQ512load + OpAMD64VPMAXSQMasked128load + OpAMD64VPMAXSQMasked256load + OpAMD64VPMAXSQMasked512load + OpAMD64VPMAXUD512load + OpAMD64VPMAXUDMasked128load + OpAMD64VPMAXUDMasked256load + OpAMD64VPMAXUDMasked512load + OpAMD64VPMAXUQ128load + OpAMD64VPMAXUQ256load + OpAMD64VPMAXUQ512load + OpAMD64VPMAXUQMasked128load + OpAMD64VPMAXUQMasked256load + OpAMD64VPMAXUQMasked512load + OpAMD64VPMINSD512load + OpAMD64VPMINSDMasked128load + OpAMD64VPMINSDMasked256load + OpAMD64VPMINSDMasked512load + OpAMD64VPMINSQ128load + OpAMD64VPMINSQ256load + OpAMD64VPMINSQ512load + OpAMD64VPMINSQMasked128load + OpAMD64VPMINSQMasked256load + OpAMD64VPMINSQMasked512load + OpAMD64VPMINUD512load + OpAMD64VPMINUDMasked128load + OpAMD64VPMINUDMasked256load + OpAMD64VPMINUDMasked512load + OpAMD64VPMINUQ128load + OpAMD64VPMINUQ256load + OpAMD64VPMINUQ512load + OpAMD64VPMINUQMasked128load + OpAMD64VPMINUQMasked256load + OpAMD64VPMINUQMasked512load + OpAMD64VPMULLD512load + OpAMD64VPMULLDMasked128load + OpAMD64VPMULLDMasked256load + OpAMD64VPMULLDMasked512load + OpAMD64VPMULLQ128load + OpAMD64VPMULLQ256load + OpAMD64VPMULLQ512load + OpAMD64VPMULLQMasked128load + OpAMD64VPMULLQMasked256load + OpAMD64VPMULLQMasked512load + OpAMD64VPOPCNTD128load + OpAMD64VPOPCNTD256load + OpAMD64VPOPCNTD512load + OpAMD64VPOPCNTDMasked128load + OpAMD64VPOPCNTDMasked256load + OpAMD64VPOPCNTDMasked512load + OpAMD64VPOPCNTQ128load + OpAMD64VPOPCNTQ256load + OpAMD64VPOPCNTQ512load + OpAMD64VPOPCNTQMasked128load + OpAMD64VPOPCNTQMasked256load + OpAMD64VPOPCNTQMasked512load + OpAMD64VPORD512load + OpAMD64VPORDMasked128load + OpAMD64VPORDMasked256load + OpAMD64VPORDMasked512load + OpAMD64VPORQ512load + OpAMD64VPORQMasked128load + OpAMD64VPORQMasked256load + OpAMD64VPORQMasked512load + OpAMD64VPROLVD128load + OpAMD64VPROLVD256load + OpAMD64VPROLVD512load + OpAMD64VPROLVDMasked128load + OpAMD64VPROLVDMasked256load + OpAMD64VPROLVDMasked512load + OpAMD64VPROLVQ128load + OpAMD64VPROLVQ256load + OpAMD64VPROLVQ512load + OpAMD64VPROLVQMasked128load + OpAMD64VPROLVQMasked256load + OpAMD64VPROLVQMasked512load + OpAMD64VPRORVD128load + OpAMD64VPRORVD256load + OpAMD64VPRORVD512load + OpAMD64VPRORVDMasked128load + OpAMD64VPRORVDMasked256load + OpAMD64VPRORVDMasked512load + OpAMD64VPRORVQ128load + OpAMD64VPRORVQ256load + OpAMD64VPRORVQ512load + OpAMD64VPRORVQMasked128load + OpAMD64VPRORVQMasked256load + OpAMD64VPRORVQMasked512load + OpAMD64VPSHLDVD128load + OpAMD64VPSHLDVD256load + OpAMD64VPSHLDVD512load + OpAMD64VPSHLDVDMasked128load + OpAMD64VPSHLDVDMasked256load + OpAMD64VPSHLDVDMasked512load + OpAMD64VPSHLDVQ128load + OpAMD64VPSHLDVQ256load + OpAMD64VPSHLDVQ512load + OpAMD64VPSHLDVQMasked128load + OpAMD64VPSHLDVQMasked256load + OpAMD64VPSHLDVQMasked512load + OpAMD64VPSHRDVD128load + OpAMD64VPSHRDVD256load + OpAMD64VPSHRDVD512load + OpAMD64VPSHRDVDMasked128load + OpAMD64VPSHRDVDMasked256load + OpAMD64VPSHRDVDMasked512load + OpAMD64VPSHRDVQ128load + OpAMD64VPSHRDVQ256load + OpAMD64VPSHRDVQ512load + OpAMD64VPSHRDVQMasked128load + OpAMD64VPSHRDVQMasked256load + OpAMD64VPSHRDVQMasked512load + OpAMD64VPSLLVD512load + OpAMD64VPSLLVDMasked128load + OpAMD64VPSLLVDMasked256load + OpAMD64VPSLLVDMasked512load + OpAMD64VPSLLVQ512load + OpAMD64VPSLLVQMasked128load + OpAMD64VPSLLVQMasked256load + OpAMD64VPSLLVQMasked512load + OpAMD64VPSRAVD512load + OpAMD64VPSRAVDMasked128load + OpAMD64VPSRAVDMasked256load + OpAMD64VPSRAVDMasked512load + OpAMD64VPSRAVQ128load + OpAMD64VPSRAVQ256load + OpAMD64VPSRAVQ512load + OpAMD64VPSRAVQMasked128load + OpAMD64VPSRAVQMasked256load + OpAMD64VPSRAVQMasked512load + OpAMD64VPSRLVD512load + OpAMD64VPSRLVDMasked128load + OpAMD64VPSRLVDMasked256load + OpAMD64VPSRLVDMasked512load + OpAMD64VPSRLVQ512load + OpAMD64VPSRLVQMasked128load + OpAMD64VPSRLVQMasked256load + OpAMD64VPSRLVQMasked512load + OpAMD64VPSUBD512load + OpAMD64VPSUBDMasked128load + OpAMD64VPSUBDMasked256load + OpAMD64VPSUBDMasked512load + OpAMD64VPSUBQ512load + OpAMD64VPSUBQMasked128load + OpAMD64VPSUBQMasked256load + OpAMD64VPSUBQMasked512load + OpAMD64VPUNPCKHDQ512load + OpAMD64VPUNPCKHQDQ512load + OpAMD64VPUNPCKLDQ512load + OpAMD64VPUNPCKLQDQ512load + OpAMD64VPXORD512load + OpAMD64VPXORDMasked128load + OpAMD64VPXORDMasked256load + OpAMD64VPXORDMasked512load + OpAMD64VPXORQ512load + OpAMD64VPXORQMasked128load + OpAMD64VPXORQMasked256load + OpAMD64VPXORQMasked512load + OpAMD64VRCP14PD128load + OpAMD64VRCP14PD256load + OpAMD64VRCP14PD512load + OpAMD64VRCP14PDMasked128load + OpAMD64VRCP14PDMasked256load + OpAMD64VRCP14PDMasked512load + OpAMD64VRCP14PS512load + OpAMD64VRCP14PSMasked128load + OpAMD64VRCP14PSMasked256load + OpAMD64VRCP14PSMasked512load + OpAMD64VRSQRT14PD128load + OpAMD64VRSQRT14PD256load + OpAMD64VRSQRT14PD512load + OpAMD64VRSQRT14PDMasked128load + OpAMD64VRSQRT14PDMasked256load + OpAMD64VRSQRT14PDMasked512load + OpAMD64VRSQRT14PS512load + OpAMD64VRSQRT14PSMasked128load + OpAMD64VRSQRT14PSMasked256load + OpAMD64VRSQRT14PSMasked512load + OpAMD64VSCALEFPD128load + OpAMD64VSCALEFPD256load + OpAMD64VSCALEFPD512load + OpAMD64VSCALEFPDMasked128load + OpAMD64VSCALEFPDMasked256load + OpAMD64VSCALEFPDMasked512load + OpAMD64VSCALEFPS128load + OpAMD64VSCALEFPS256load + OpAMD64VSCALEFPS512load + OpAMD64VSCALEFPSMasked128load + OpAMD64VSCALEFPSMasked256load + OpAMD64VSCALEFPSMasked512load + OpAMD64VSQRTPD512load + OpAMD64VSQRTPDMasked128load + OpAMD64VSQRTPDMasked256load + OpAMD64VSQRTPDMasked512load + OpAMD64VSQRTPS512load + OpAMD64VSQRTPSMasked128load + OpAMD64VSQRTPSMasked256load + OpAMD64VSQRTPSMasked512load + OpAMD64VSUBPD512load + OpAMD64VSUBPDMasked128load + OpAMD64VSUBPDMasked256load + OpAMD64VSUBPDMasked512load + OpAMD64VSUBPS512load + OpAMD64VSUBPSMasked128load + OpAMD64VSUBPSMasked256load + OpAMD64VSUBPSMasked512load + OpAMD64VCMPPD512load + OpAMD64VCMPPDMasked128load + OpAMD64VCMPPDMasked256load + OpAMD64VCMPPDMasked512load + OpAMD64VCMPPS512load + OpAMD64VCMPPSMasked128load + OpAMD64VCMPPSMasked256load + OpAMD64VCMPPSMasked512load + OpAMD64VGF2P8AFFINEINVQB128load + OpAMD64VGF2P8AFFINEINVQB256load + OpAMD64VGF2P8AFFINEINVQB512load + OpAMD64VGF2P8AFFINEINVQBMasked128load + OpAMD64VGF2P8AFFINEINVQBMasked256load + OpAMD64VGF2P8AFFINEINVQBMasked512load + OpAMD64VGF2P8AFFINEQB128load + OpAMD64VGF2P8AFFINEQB256load + OpAMD64VGF2P8AFFINEQB512load + OpAMD64VGF2P8AFFINEQBMasked128load + OpAMD64VGF2P8AFFINEQBMasked256load + OpAMD64VGF2P8AFFINEQBMasked512load + OpAMD64VPCMPD512load + OpAMD64VPCMPDMasked128load + OpAMD64VPCMPDMasked256load + OpAMD64VPCMPDMasked512load + OpAMD64VPCMPQ512load + OpAMD64VPCMPQMasked128load + OpAMD64VPCMPQMasked256load + OpAMD64VPCMPQMasked512load + OpAMD64VPCMPUD512load + OpAMD64VPCMPUDMasked128load + OpAMD64VPCMPUDMasked256load + OpAMD64VPCMPUDMasked512load + OpAMD64VPCMPUQ512load + OpAMD64VPCMPUQMasked128load + OpAMD64VPCMPUQMasked256load + OpAMD64VPCMPUQMasked512load + OpAMD64VPROLD128load + OpAMD64VPROLD256load + OpAMD64VPROLD512load + OpAMD64VPROLDMasked128load + OpAMD64VPROLDMasked256load + OpAMD64VPROLDMasked512load + OpAMD64VPROLQ128load + OpAMD64VPROLQ256load + OpAMD64VPROLQ512load + OpAMD64VPROLQMasked128load + OpAMD64VPROLQMasked256load + OpAMD64VPROLQMasked512load + OpAMD64VPRORD128load + OpAMD64VPRORD256load + OpAMD64VPRORD512load + OpAMD64VPRORDMasked128load + OpAMD64VPRORDMasked256load + OpAMD64VPRORDMasked512load + OpAMD64VPRORQ128load + OpAMD64VPRORQ256load + OpAMD64VPRORQ512load + OpAMD64VPRORQMasked128load + OpAMD64VPRORQMasked256load + OpAMD64VPRORQMasked512load + OpAMD64VPSHLDD128load + OpAMD64VPSHLDD256load + OpAMD64VPSHLDD512load + OpAMD64VPSHLDDMasked128load + OpAMD64VPSHLDDMasked256load + OpAMD64VPSHLDDMasked512load + OpAMD64VPSHLDQ128load + OpAMD64VPSHLDQ256load + OpAMD64VPSHLDQ512load + OpAMD64VPSHLDQMasked128load + OpAMD64VPSHLDQMasked256load + OpAMD64VPSHLDQMasked512load + OpAMD64VPSHRDD128load + OpAMD64VPSHRDD256load + OpAMD64VPSHRDD512load + OpAMD64VPSHRDDMasked128load + OpAMD64VPSHRDDMasked256load + OpAMD64VPSHRDDMasked512load + OpAMD64VPSHRDQ128load + OpAMD64VPSHRDQ256load + OpAMD64VPSHRDQ512load + OpAMD64VPSHRDQMasked128load + OpAMD64VPSHRDQMasked256load + OpAMD64VPSHRDQMasked512load + OpAMD64VPSHUFD512load + OpAMD64VPSHUFDMasked128load + OpAMD64VPSHUFDMasked256load + OpAMD64VPSHUFDMasked512load + OpAMD64VPSLLD512constload + OpAMD64VPSLLDMasked128constload + OpAMD64VPSLLDMasked256constload + OpAMD64VPSLLDMasked512constload + OpAMD64VPSLLQ512constload + OpAMD64VPSLLQMasked128constload + OpAMD64VPSLLQMasked256constload + OpAMD64VPSLLQMasked512constload + OpAMD64VPSRAD512constload + OpAMD64VPSRADMasked128constload + OpAMD64VPSRADMasked256constload + OpAMD64VPSRADMasked512constload + OpAMD64VPSRAQ128constload + OpAMD64VPSRAQ256constload + OpAMD64VPSRAQ512constload + OpAMD64VPSRAQMasked128constload + OpAMD64VPSRAQMasked256constload + OpAMD64VPSRAQMasked512constload + OpAMD64VPSRLD512constload + OpAMD64VPSRLDMasked128constload + OpAMD64VPSRLDMasked256constload + OpAMD64VPSRLDMasked512constload + OpAMD64VPSRLQ512constload + OpAMD64VPSRLQMasked128constload + OpAMD64VPSRLQMasked256constload + OpAMD64VPSRLQMasked512constload + OpAMD64VPTERNLOGD128load + OpAMD64VPTERNLOGD256load + OpAMD64VPTERNLOGD512load + OpAMD64VPTERNLOGQ128load + OpAMD64VPTERNLOGQ256load + OpAMD64VPTERNLOGQ512load + OpAMD64VREDUCEPD128load + OpAMD64VREDUCEPD256load + OpAMD64VREDUCEPD512load + OpAMD64VREDUCEPDMasked128load + OpAMD64VREDUCEPDMasked256load + OpAMD64VREDUCEPDMasked512load + OpAMD64VREDUCEPS128load + OpAMD64VREDUCEPS256load + OpAMD64VREDUCEPS512load + OpAMD64VREDUCEPSMasked128load + OpAMD64VREDUCEPSMasked256load + OpAMD64VREDUCEPSMasked512load + OpAMD64VRNDSCALEPD128load + OpAMD64VRNDSCALEPD256load + OpAMD64VRNDSCALEPD512load + OpAMD64VRNDSCALEPDMasked128load + OpAMD64VRNDSCALEPDMasked256load + OpAMD64VRNDSCALEPDMasked512load + OpAMD64VRNDSCALEPS128load + OpAMD64VRNDSCALEPS256load + OpAMD64VRNDSCALEPS512load + OpAMD64VRNDSCALEPSMasked128load + OpAMD64VRNDSCALEPSMasked256load + OpAMD64VRNDSCALEPSMasked512load + OpAMD64VSHUFPD512load + OpAMD64VSHUFPS512load + OpAMD64VADDPDMasked128Merging + OpAMD64VADDPDMasked256Merging + OpAMD64VADDPDMasked512Merging + OpAMD64VADDPSMasked128Merging + OpAMD64VADDPSMasked256Merging + OpAMD64VADDPSMasked512Merging + OpAMD64VBROADCASTSDMasked256Merging + OpAMD64VBROADCASTSDMasked512Merging + OpAMD64VBROADCASTSSMasked128Merging + OpAMD64VBROADCASTSSMasked256Merging + OpAMD64VBROADCASTSSMasked512Merging + OpAMD64VCVTDQ2PDMasked256Merging + OpAMD64VCVTDQ2PDMasked512Merging + OpAMD64VCVTDQ2PSMasked128Merging + OpAMD64VCVTDQ2PSMasked256Merging + OpAMD64VCVTDQ2PSMasked512Merging + OpAMD64VCVTPD2PSMasked256Merging + OpAMD64VCVTPD2PSXMasked128Merging + OpAMD64VCVTPD2PSYMasked128Merging + OpAMD64VCVTPS2PDMasked256Merging + OpAMD64VCVTPS2PDMasked512Merging + OpAMD64VCVTQQ2PDMasked128Merging + OpAMD64VCVTQQ2PDMasked256Merging + OpAMD64VCVTQQ2PDMasked512Merging + OpAMD64VCVTQQ2PSMasked256Merging + OpAMD64VCVTQQ2PSXMasked128Merging + OpAMD64VCVTQQ2PSYMasked128Merging + OpAMD64VCVTTPD2DQMasked256Merging + OpAMD64VCVTTPD2DQXMasked128Merging + OpAMD64VCVTTPD2DQYMasked128Merging + OpAMD64VCVTTPD2QQMasked128Merging + OpAMD64VCVTTPD2QQMasked256Merging + OpAMD64VCVTTPD2QQMasked512Merging + OpAMD64VCVTTPD2UDQMasked256Merging + OpAMD64VCVTTPD2UDQXMasked128Merging + OpAMD64VCVTTPD2UDQYMasked128Merging + OpAMD64VCVTTPD2UQQMasked128Merging + OpAMD64VCVTTPD2UQQMasked256Merging + OpAMD64VCVTTPD2UQQMasked512Merging + OpAMD64VCVTTPS2DQMasked128Merging + OpAMD64VCVTTPS2DQMasked256Merging + OpAMD64VCVTTPS2DQMasked512Merging + OpAMD64VCVTTPS2QQMasked256Merging + OpAMD64VCVTTPS2QQMasked512Merging + OpAMD64VCVTTPS2UDQMasked128Merging + OpAMD64VCVTTPS2UDQMasked256Merging + OpAMD64VCVTTPS2UDQMasked512Merging + OpAMD64VCVTTPS2UQQMasked256Merging + OpAMD64VCVTTPS2UQQMasked512Merging + OpAMD64VCVTUDQ2PDMasked256Merging + OpAMD64VCVTUDQ2PDMasked512Merging + OpAMD64VCVTUDQ2PSMasked128Merging + OpAMD64VCVTUDQ2PSMasked256Merging + OpAMD64VCVTUDQ2PSMasked512Merging + OpAMD64VCVTUQQ2PDMasked128Merging + OpAMD64VCVTUQQ2PDMasked256Merging + OpAMD64VCVTUQQ2PDMasked512Merging + OpAMD64VCVTUQQ2PSMasked256Merging + OpAMD64VCVTUQQ2PSXMasked128Merging + OpAMD64VCVTUQQ2PSYMasked128Merging + OpAMD64VDIVPDMasked128Merging + OpAMD64VDIVPDMasked256Merging + OpAMD64VDIVPDMasked512Merging + OpAMD64VDIVPSMasked128Merging + OpAMD64VDIVPSMasked256Merging + OpAMD64VDIVPSMasked512Merging + OpAMD64VGF2P8MULBMasked128Merging + OpAMD64VGF2P8MULBMasked256Merging + OpAMD64VGF2P8MULBMasked512Merging + OpAMD64VMAXPDMasked128Merging + OpAMD64VMAXPDMasked256Merging + OpAMD64VMAXPDMasked512Merging + OpAMD64VMAXPSMasked128Merging + OpAMD64VMAXPSMasked256Merging + OpAMD64VMAXPSMasked512Merging + OpAMD64VMINPDMasked128Merging + OpAMD64VMINPDMasked256Merging + OpAMD64VMINPDMasked512Merging + OpAMD64VMINPSMasked128Merging + OpAMD64VMINPSMasked256Merging + OpAMD64VMINPSMasked512Merging + OpAMD64VMULPDMasked128Merging + OpAMD64VMULPDMasked256Merging + OpAMD64VMULPDMasked512Merging + OpAMD64VMULPSMasked128Merging + OpAMD64VMULPSMasked256Merging + OpAMD64VMULPSMasked512Merging + OpAMD64VPABSBMasked128Merging + OpAMD64VPABSBMasked256Merging + OpAMD64VPABSBMasked512Merging + OpAMD64VPABSDMasked128Merging + OpAMD64VPABSDMasked256Merging + OpAMD64VPABSDMasked512Merging + OpAMD64VPABSQMasked128Merging + OpAMD64VPABSQMasked256Merging + OpAMD64VPABSQMasked512Merging + OpAMD64VPABSWMasked128Merging + OpAMD64VPABSWMasked256Merging + OpAMD64VPABSWMasked512Merging + OpAMD64VPACKSSDWMasked128Merging + OpAMD64VPACKSSDWMasked256Merging + OpAMD64VPACKSSDWMasked512Merging + OpAMD64VPACKUSDWMasked128Merging + OpAMD64VPACKUSDWMasked256Merging + OpAMD64VPACKUSDWMasked512Merging + OpAMD64VPADDBMasked128Merging + OpAMD64VPADDBMasked256Merging + OpAMD64VPADDBMasked512Merging + OpAMD64VPADDDMasked128Merging + OpAMD64VPADDDMasked256Merging + OpAMD64VPADDDMasked512Merging + OpAMD64VPADDQMasked128Merging + OpAMD64VPADDQMasked256Merging + OpAMD64VPADDQMasked512Merging + OpAMD64VPADDSBMasked128Merging + OpAMD64VPADDSBMasked256Merging + OpAMD64VPADDSBMasked512Merging + OpAMD64VPADDSWMasked128Merging + OpAMD64VPADDSWMasked256Merging + OpAMD64VPADDSWMasked512Merging + OpAMD64VPADDUSBMasked128Merging + OpAMD64VPADDUSBMasked256Merging + OpAMD64VPADDUSBMasked512Merging + OpAMD64VPADDUSWMasked128Merging + OpAMD64VPADDUSWMasked256Merging + OpAMD64VPADDUSWMasked512Merging + OpAMD64VPADDWMasked128Merging + OpAMD64VPADDWMasked256Merging + OpAMD64VPADDWMasked512Merging + OpAMD64VPANDDMasked128Merging + OpAMD64VPANDDMasked256Merging + OpAMD64VPANDDMasked512Merging + OpAMD64VPANDQMasked128Merging + OpAMD64VPANDQMasked256Merging + OpAMD64VPANDQMasked512Merging + OpAMD64VPAVGBMasked128Merging + OpAMD64VPAVGBMasked256Merging + OpAMD64VPAVGBMasked512Merging + OpAMD64VPAVGWMasked128Merging + OpAMD64VPAVGWMasked256Merging + OpAMD64VPAVGWMasked512Merging + OpAMD64VPBROADCASTBMasked128Merging + OpAMD64VPBROADCASTBMasked256Merging + OpAMD64VPBROADCASTBMasked512Merging + OpAMD64VPBROADCASTDMasked128Merging + OpAMD64VPBROADCASTDMasked256Merging + OpAMD64VPBROADCASTDMasked512Merging + OpAMD64VPBROADCASTQMasked128Merging + OpAMD64VPBROADCASTQMasked256Merging + OpAMD64VPBROADCASTQMasked512Merging + OpAMD64VPBROADCASTWMasked128Merging + OpAMD64VPBROADCASTWMasked256Merging + OpAMD64VPBROADCASTWMasked512Merging + OpAMD64VPLZCNTDMasked128Merging + OpAMD64VPLZCNTDMasked256Merging + OpAMD64VPLZCNTDMasked512Merging + OpAMD64VPLZCNTQMasked128Merging + OpAMD64VPLZCNTQMasked256Merging + OpAMD64VPLZCNTQMasked512Merging + OpAMD64VPMADDUBSWMasked128Merging + OpAMD64VPMADDUBSWMasked256Merging + OpAMD64VPMADDUBSWMasked512Merging + OpAMD64VPMADDWDMasked128Merging + OpAMD64VPMADDWDMasked256Merging + OpAMD64VPMADDWDMasked512Merging + OpAMD64VPMAXSBMasked128Merging + OpAMD64VPMAXSBMasked256Merging + OpAMD64VPMAXSBMasked512Merging + OpAMD64VPMAXSDMasked128Merging + OpAMD64VPMAXSDMasked256Merging + OpAMD64VPMAXSDMasked512Merging + OpAMD64VPMAXSQMasked128Merging + OpAMD64VPMAXSQMasked256Merging + OpAMD64VPMAXSQMasked512Merging + OpAMD64VPMAXSWMasked128Merging + OpAMD64VPMAXSWMasked256Merging + OpAMD64VPMAXSWMasked512Merging + OpAMD64VPMAXUBMasked128Merging + OpAMD64VPMAXUBMasked256Merging + OpAMD64VPMAXUBMasked512Merging + OpAMD64VPMAXUDMasked128Merging + OpAMD64VPMAXUDMasked256Merging + OpAMD64VPMAXUDMasked512Merging + OpAMD64VPMAXUQMasked128Merging + OpAMD64VPMAXUQMasked256Merging + OpAMD64VPMAXUQMasked512Merging + OpAMD64VPMAXUWMasked128Merging + OpAMD64VPMAXUWMasked256Merging + OpAMD64VPMAXUWMasked512Merging + OpAMD64VPMINSBMasked128Merging + OpAMD64VPMINSBMasked256Merging + OpAMD64VPMINSBMasked512Merging + OpAMD64VPMINSDMasked128Merging + OpAMD64VPMINSDMasked256Merging + OpAMD64VPMINSDMasked512Merging + OpAMD64VPMINSQMasked128Merging + OpAMD64VPMINSQMasked256Merging + OpAMD64VPMINSQMasked512Merging + OpAMD64VPMINSWMasked128Merging + OpAMD64VPMINSWMasked256Merging + OpAMD64VPMINSWMasked512Merging + OpAMD64VPMINUBMasked128Merging + OpAMD64VPMINUBMasked256Merging + OpAMD64VPMINUBMasked512Merging + OpAMD64VPMINUDMasked128Merging + OpAMD64VPMINUDMasked256Merging + OpAMD64VPMINUDMasked512Merging + OpAMD64VPMINUQMasked128Merging + OpAMD64VPMINUQMasked256Merging + OpAMD64VPMINUQMasked512Merging + OpAMD64VPMINUWMasked128Merging + OpAMD64VPMINUWMasked256Merging + OpAMD64VPMINUWMasked512Merging + OpAMD64VPMOVDBMasked128_128Merging + OpAMD64VPMOVDBMasked128_256Merging + OpAMD64VPMOVDBMasked128_512Merging + OpAMD64VPMOVDWMasked128_128Merging + OpAMD64VPMOVDWMasked128_256Merging + OpAMD64VPMOVDWMasked256Merging + OpAMD64VPMOVQBMasked128_128Merging + OpAMD64VPMOVQBMasked128_256Merging + OpAMD64VPMOVQBMasked128_512Merging + OpAMD64VPMOVQDMasked128_128Merging + OpAMD64VPMOVQDMasked128_256Merging + OpAMD64VPMOVQDMasked256Merging + OpAMD64VPMOVQWMasked128_128Merging + OpAMD64VPMOVQWMasked128_256Merging + OpAMD64VPMOVQWMasked128_512Merging + OpAMD64VPMOVSDBMasked128_128Merging + OpAMD64VPMOVSDBMasked128_256Merging + OpAMD64VPMOVSDBMasked128_512Merging + OpAMD64VPMOVSDWMasked128_128Merging + OpAMD64VPMOVSDWMasked128_256Merging + OpAMD64VPMOVSDWMasked256Merging + OpAMD64VPMOVSQBMasked128_128Merging + OpAMD64VPMOVSQBMasked128_256Merging + OpAMD64VPMOVSQBMasked128_512Merging + OpAMD64VPMOVSQDMasked128_128Merging + OpAMD64VPMOVSQDMasked128_256Merging + OpAMD64VPMOVSQDMasked256Merging + OpAMD64VPMOVSQWMasked128_128Merging + OpAMD64VPMOVSQWMasked128_256Merging + OpAMD64VPMOVSQWMasked128_512Merging + OpAMD64VPMOVSWBMasked128_128Merging + OpAMD64VPMOVSWBMasked128_256Merging + OpAMD64VPMOVSWBMasked256Merging + OpAMD64VPMOVSXBDMasked128Merging + OpAMD64VPMOVSXBDMasked256Merging + OpAMD64VPMOVSXBDMasked512Merging + OpAMD64VPMOVSXBQMasked128Merging + OpAMD64VPMOVSXBQMasked256Merging + OpAMD64VPMOVSXBQMasked512Merging + OpAMD64VPMOVSXBWMasked128Merging + OpAMD64VPMOVSXBWMasked256Merging + OpAMD64VPMOVSXBWMasked512Merging + OpAMD64VPMOVSXDQMasked128Merging + OpAMD64VPMOVSXDQMasked256Merging + OpAMD64VPMOVSXDQMasked512Merging + OpAMD64VPMOVSXWDMasked128Merging + OpAMD64VPMOVSXWDMasked256Merging + OpAMD64VPMOVSXWDMasked512Merging + OpAMD64VPMOVSXWQMasked128Merging + OpAMD64VPMOVSXWQMasked256Merging + OpAMD64VPMOVSXWQMasked512Merging + OpAMD64VPMOVUSDBMasked128_128Merging + OpAMD64VPMOVUSDBMasked128_256Merging + OpAMD64VPMOVUSDBMasked128_512Merging + OpAMD64VPMOVUSDWMasked128_128Merging + OpAMD64VPMOVUSDWMasked128_256Merging + OpAMD64VPMOVUSDWMasked256Merging + OpAMD64VPMOVUSQBMasked128_128Merging + OpAMD64VPMOVUSQBMasked128_256Merging + OpAMD64VPMOVUSQBMasked128_512Merging + OpAMD64VPMOVUSQDMasked128_128Merging + OpAMD64VPMOVUSQDMasked128_256Merging + OpAMD64VPMOVUSQDMasked256Merging + OpAMD64VPMOVUSQWMasked128_128Merging + OpAMD64VPMOVUSQWMasked128_256Merging + OpAMD64VPMOVUSQWMasked128_512Merging + OpAMD64VPMOVUSWBMasked128_128Merging + OpAMD64VPMOVUSWBMasked128_256Merging + OpAMD64VPMOVUSWBMasked256Merging + OpAMD64VPMOVWBMasked128_128Merging + OpAMD64VPMOVWBMasked128_256Merging + OpAMD64VPMOVWBMasked256Merging + OpAMD64VPMOVZXBDMasked128Merging + OpAMD64VPMOVZXBDMasked256Merging + OpAMD64VPMOVZXBDMasked512Merging + OpAMD64VPMOVZXBQMasked128Merging + OpAMD64VPMOVZXBQMasked256Merging + OpAMD64VPMOVZXBQMasked512Merging + OpAMD64VPMOVZXBWMasked128Merging + OpAMD64VPMOVZXBWMasked256Merging + OpAMD64VPMOVZXBWMasked512Merging + OpAMD64VPMOVZXDQMasked128Merging + OpAMD64VPMOVZXDQMasked256Merging + OpAMD64VPMOVZXDQMasked512Merging + OpAMD64VPMOVZXWDMasked128Merging + OpAMD64VPMOVZXWDMasked256Merging + OpAMD64VPMOVZXWDMasked512Merging + OpAMD64VPMOVZXWQMasked128Merging + OpAMD64VPMOVZXWQMasked256Merging + OpAMD64VPMOVZXWQMasked512Merging + OpAMD64VPMULHUWMasked128Merging + OpAMD64VPMULHUWMasked256Merging + OpAMD64VPMULHUWMasked512Merging + OpAMD64VPMULHWMasked128Merging + OpAMD64VPMULHWMasked256Merging + OpAMD64VPMULHWMasked512Merging + OpAMD64VPMULLDMasked128Merging + OpAMD64VPMULLDMasked256Merging + OpAMD64VPMULLDMasked512Merging + OpAMD64VPMULLQMasked128Merging + OpAMD64VPMULLQMasked256Merging + OpAMD64VPMULLQMasked512Merging + OpAMD64VPMULLWMasked128Merging + OpAMD64VPMULLWMasked256Merging + OpAMD64VPMULLWMasked512Merging + OpAMD64VPOPCNTBMasked128Merging + OpAMD64VPOPCNTBMasked256Merging + OpAMD64VPOPCNTBMasked512Merging + OpAMD64VPOPCNTDMasked128Merging + OpAMD64VPOPCNTDMasked256Merging + OpAMD64VPOPCNTDMasked512Merging + OpAMD64VPOPCNTQMasked128Merging + OpAMD64VPOPCNTQMasked256Merging + OpAMD64VPOPCNTQMasked512Merging + OpAMD64VPOPCNTWMasked128Merging + OpAMD64VPOPCNTWMasked256Merging + OpAMD64VPOPCNTWMasked512Merging + OpAMD64VPORDMasked128Merging + OpAMD64VPORDMasked256Merging + OpAMD64VPORDMasked512Merging + OpAMD64VPORQMasked128Merging + OpAMD64VPORQMasked256Merging + OpAMD64VPORQMasked512Merging + OpAMD64VPROLVDMasked128Merging + OpAMD64VPROLVDMasked256Merging + OpAMD64VPROLVDMasked512Merging + OpAMD64VPROLVQMasked128Merging + OpAMD64VPROLVQMasked256Merging + OpAMD64VPROLVQMasked512Merging + OpAMD64VPRORVDMasked128Merging + OpAMD64VPRORVDMasked256Merging + OpAMD64VPRORVDMasked512Merging + OpAMD64VPRORVQMasked128Merging + OpAMD64VPRORVQMasked256Merging + OpAMD64VPRORVQMasked512Merging + OpAMD64VPSHUFBMasked128Merging + OpAMD64VPSHUFBMasked256Merging + OpAMD64VPSHUFBMasked512Merging + OpAMD64VPSLLVDMasked128Merging + OpAMD64VPSLLVDMasked256Merging + OpAMD64VPSLLVDMasked512Merging + OpAMD64VPSLLVQMasked128Merging + OpAMD64VPSLLVQMasked256Merging + OpAMD64VPSLLVQMasked512Merging + OpAMD64VPSLLVWMasked128Merging + OpAMD64VPSLLVWMasked256Merging + OpAMD64VPSLLVWMasked512Merging + OpAMD64VPSRAVDMasked128Merging + OpAMD64VPSRAVDMasked256Merging + OpAMD64VPSRAVDMasked512Merging + OpAMD64VPSRAVQMasked128Merging + OpAMD64VPSRAVQMasked256Merging + OpAMD64VPSRAVQMasked512Merging + OpAMD64VPSRAVWMasked128Merging + OpAMD64VPSRAVWMasked256Merging + OpAMD64VPSRAVWMasked512Merging + OpAMD64VPSRLVDMasked128Merging + OpAMD64VPSRLVDMasked256Merging + OpAMD64VPSRLVDMasked512Merging + OpAMD64VPSRLVQMasked128Merging + OpAMD64VPSRLVQMasked256Merging + OpAMD64VPSRLVQMasked512Merging + OpAMD64VPSRLVWMasked128Merging + OpAMD64VPSRLVWMasked256Merging + OpAMD64VPSRLVWMasked512Merging + OpAMD64VPSUBBMasked128Merging + OpAMD64VPSUBBMasked256Merging + OpAMD64VPSUBBMasked512Merging + OpAMD64VPSUBDMasked128Merging + OpAMD64VPSUBDMasked256Merging + OpAMD64VPSUBDMasked512Merging + OpAMD64VPSUBQMasked128Merging + OpAMD64VPSUBQMasked256Merging + OpAMD64VPSUBQMasked512Merging + OpAMD64VPSUBSBMasked128Merging + OpAMD64VPSUBSBMasked256Merging + OpAMD64VPSUBSBMasked512Merging + OpAMD64VPSUBSWMasked128Merging + OpAMD64VPSUBSWMasked256Merging + OpAMD64VPSUBSWMasked512Merging + OpAMD64VPSUBUSBMasked128Merging + OpAMD64VPSUBUSBMasked256Merging + OpAMD64VPSUBUSBMasked512Merging + OpAMD64VPSUBUSWMasked128Merging + OpAMD64VPSUBUSWMasked256Merging + OpAMD64VPSUBUSWMasked512Merging + OpAMD64VPSUBWMasked128Merging + OpAMD64VPSUBWMasked256Merging + OpAMD64VPSUBWMasked512Merging + OpAMD64VPXORDMasked128Merging + OpAMD64VPXORDMasked256Merging + OpAMD64VPXORDMasked512Merging + OpAMD64VPXORQMasked128Merging + OpAMD64VPXORQMasked256Merging + OpAMD64VPXORQMasked512Merging + OpAMD64VRCP14PDMasked128Merging + OpAMD64VRCP14PDMasked256Merging + OpAMD64VRCP14PDMasked512Merging + OpAMD64VRCP14PSMasked128Merging + OpAMD64VRCP14PSMasked256Merging + OpAMD64VRCP14PSMasked512Merging + OpAMD64VRSQRT14PDMasked128Merging + OpAMD64VRSQRT14PDMasked256Merging + OpAMD64VRSQRT14PDMasked512Merging + OpAMD64VRSQRT14PSMasked128Merging + OpAMD64VRSQRT14PSMasked256Merging + OpAMD64VRSQRT14PSMasked512Merging + OpAMD64VSCALEFPDMasked128Merging + OpAMD64VSCALEFPDMasked256Merging + OpAMD64VSCALEFPDMasked512Merging + OpAMD64VSCALEFPSMasked128Merging + OpAMD64VSCALEFPSMasked256Merging + OpAMD64VSCALEFPSMasked512Merging + OpAMD64VSQRTPDMasked128Merging + OpAMD64VSQRTPDMasked256Merging + OpAMD64VSQRTPDMasked512Merging + OpAMD64VSQRTPSMasked128Merging + OpAMD64VSQRTPSMasked256Merging + OpAMD64VSQRTPSMasked512Merging + OpAMD64VSUBPDMasked128Merging + OpAMD64VSUBPDMasked256Merging + OpAMD64VSUBPDMasked512Merging + OpAMD64VSUBPSMasked128Merging + OpAMD64VSUBPSMasked256Merging + OpAMD64VSUBPSMasked512Merging + OpAMD64VPALIGNRMasked128Merging + OpAMD64VPALIGNRMasked256Merging + OpAMD64VPALIGNRMasked512Merging + OpAMD64VPROLDMasked128Merging + OpAMD64VPROLDMasked256Merging + OpAMD64VPROLDMasked512Merging + OpAMD64VPROLQMasked128Merging + OpAMD64VPROLQMasked256Merging + OpAMD64VPROLQMasked512Merging + OpAMD64VPRORDMasked128Merging + OpAMD64VPRORDMasked256Merging + OpAMD64VPRORDMasked512Merging + OpAMD64VPRORQMasked128Merging + OpAMD64VPRORQMasked256Merging + OpAMD64VPRORQMasked512Merging + OpAMD64VPSHLDDMasked128Merging + OpAMD64VPSHLDDMasked256Merging + OpAMD64VPSHLDDMasked512Merging + OpAMD64VPSHLDQMasked128Merging + OpAMD64VPSHLDQMasked256Merging + OpAMD64VPSHLDQMasked512Merging + OpAMD64VPSHLDWMasked128Merging + OpAMD64VPSHLDWMasked256Merging + OpAMD64VPSHLDWMasked512Merging + OpAMD64VPSHRDDMasked128Merging + OpAMD64VPSHRDDMasked256Merging + OpAMD64VPSHRDDMasked512Merging + OpAMD64VPSHRDQMasked128Merging + OpAMD64VPSHRDQMasked256Merging + OpAMD64VPSHRDQMasked512Merging + OpAMD64VPSHRDWMasked128Merging + OpAMD64VPSHRDWMasked256Merging + OpAMD64VPSHRDWMasked512Merging + OpAMD64VPSHUFDMasked128Merging + OpAMD64VPSHUFDMasked256Merging + OpAMD64VPSHUFDMasked512Merging + OpAMD64VPSHUFHWMasked128Merging + OpAMD64VPSHUFHWMasked256Merging + OpAMD64VPSHUFHWMasked512Merging + OpAMD64VPSHUFLWMasked128Merging + OpAMD64VPSHUFLWMasked256Merging + OpAMD64VPSHUFLWMasked512Merging + OpAMD64VPSLLDMasked128constMerging + OpAMD64VPSLLDMasked256constMerging + OpAMD64VPSLLDMasked512constMerging + OpAMD64VPSLLQMasked128constMerging + OpAMD64VPSLLQMasked256constMerging + OpAMD64VPSLLQMasked512constMerging + OpAMD64VPSLLWMasked128constMerging + OpAMD64VPSLLWMasked256constMerging + OpAMD64VPSLLWMasked512constMerging + OpAMD64VPSRADMasked128constMerging + OpAMD64VPSRADMasked256constMerging + OpAMD64VPSRADMasked512constMerging + OpAMD64VPSRAQMasked128constMerging + OpAMD64VPSRAQMasked256constMerging + OpAMD64VPSRAQMasked512constMerging + OpAMD64VPSRAWMasked128constMerging + OpAMD64VPSRAWMasked256constMerging + OpAMD64VPSRAWMasked512constMerging + OpAMD64VPSRLDMasked128constMerging + OpAMD64VPSRLDMasked256constMerging + OpAMD64VPSRLDMasked512constMerging + OpAMD64VPSRLQMasked128constMerging + OpAMD64VPSRLQMasked256constMerging + OpAMD64VPSRLQMasked512constMerging + OpAMD64VPSRLWMasked128constMerging + OpAMD64VPSRLWMasked256constMerging + OpAMD64VPSRLWMasked512constMerging + OpAMD64VREDUCEPDMasked128Merging + OpAMD64VREDUCEPDMasked256Merging + OpAMD64VREDUCEPDMasked512Merging + OpAMD64VREDUCEPSMasked128Merging + OpAMD64VREDUCEPSMasked256Merging + OpAMD64VREDUCEPSMasked512Merging + OpAMD64VRNDSCALEPDMasked128Merging + OpAMD64VRNDSCALEPDMasked256Merging + OpAMD64VRNDSCALEPDMasked512Merging + OpAMD64VRNDSCALEPSMasked128Merging + OpAMD64VRNDSCALEPSMasked256Merging + OpAMD64VRNDSCALEPSMasked512Merging + + OpARMADD + OpARMADDconst + OpARMSUB + OpARMSUBconst + OpARMRSB + OpARMRSBconst + OpARMMUL + OpARMHMUL + OpARMHMULU + OpARMCALLudiv + OpARMADDS + OpARMADDSconst + OpARMADC + OpARMADCconst + OpARMADCS + OpARMSUBS + OpARMSUBSconst + OpARMRSBSconst + OpARMSBC + OpARMSBCconst + OpARMRSCconst + OpARMMULLU + OpARMMULA + OpARMMULS + OpARMADDF + OpARMADDD + OpARMSUBF + OpARMSUBD + OpARMMULF + OpARMMULD + OpARMNMULF + OpARMNMULD + OpARMDIVF + OpARMDIVD + OpARMMULAF + OpARMMULAD + OpARMMULSF + OpARMMULSD + OpARMFMULAD + OpARMAND + OpARMANDconst + OpARMOR + OpARMORconst + OpARMXOR + OpARMXORconst + OpARMBIC + OpARMBICconst + OpARMBFX + OpARMBFXU + OpARMMVN + OpARMNEGF + OpARMNEGD + OpARMSQRTD + OpARMSQRTF + OpARMABSD + OpARMCLZ + OpARMREV + OpARMREV16 + OpARMRBIT + OpARMSLL + OpARMSLLconst + OpARMSRL + OpARMSRLconst + OpARMSRA + OpARMSRAconst + OpARMSRR + OpARMSRRconst + OpARMADDshiftLL + OpARMADDshiftRL + OpARMADDshiftRA + OpARMSUBshiftLL + OpARMSUBshiftRL + OpARMSUBshiftRA + OpARMRSBshiftLL + OpARMRSBshiftRL + OpARMRSBshiftRA + OpARMANDshiftLL + OpARMANDshiftRL + OpARMANDshiftRA + OpARMORshiftLL + OpARMORshiftRL + OpARMORshiftRA + OpARMXORshiftLL + OpARMXORshiftRL + OpARMXORshiftRA + OpARMXORshiftRR + OpARMBICshiftLL + OpARMBICshiftRL + OpARMBICshiftRA + OpARMMVNshiftLL + OpARMMVNshiftRL + OpARMMVNshiftRA + OpARMADCshiftLL + OpARMADCshiftRL + OpARMADCshiftRA + OpARMSBCshiftLL + OpARMSBCshiftRL + OpARMSBCshiftRA + OpARMRSCshiftLL + OpARMRSCshiftRL + OpARMRSCshiftRA + OpARMADDSshiftLL + OpARMADDSshiftRL + OpARMADDSshiftRA + OpARMSUBSshiftLL + OpARMSUBSshiftRL + OpARMSUBSshiftRA + OpARMRSBSshiftLL + OpARMRSBSshiftRL + OpARMRSBSshiftRA + OpARMADDshiftLLreg + OpARMADDshiftRLreg + OpARMADDshiftRAreg + OpARMSUBshiftLLreg + OpARMSUBshiftRLreg + OpARMSUBshiftRAreg + OpARMRSBshiftLLreg + OpARMRSBshiftRLreg + OpARMRSBshiftRAreg + OpARMANDshiftLLreg + OpARMANDshiftRLreg + OpARMANDshiftRAreg + OpARMORshiftLLreg + OpARMORshiftRLreg + OpARMORshiftRAreg + OpARMXORshiftLLreg + OpARMXORshiftRLreg + OpARMXORshiftRAreg + OpARMBICshiftLLreg + OpARMBICshiftRLreg + OpARMBICshiftRAreg + OpARMMVNshiftLLreg + OpARMMVNshiftRLreg + OpARMMVNshiftRAreg + OpARMADCshiftLLreg + OpARMADCshiftRLreg + OpARMADCshiftRAreg + OpARMSBCshiftLLreg + OpARMSBCshiftRLreg + OpARMSBCshiftRAreg + OpARMRSCshiftLLreg + OpARMRSCshiftRLreg + OpARMRSCshiftRAreg + OpARMADDSshiftLLreg + OpARMADDSshiftRLreg + OpARMADDSshiftRAreg + OpARMSUBSshiftLLreg + OpARMSUBSshiftRLreg + OpARMSUBSshiftRAreg + OpARMRSBSshiftLLreg + OpARMRSBSshiftRLreg + OpARMRSBSshiftRAreg + OpARMCMP + OpARMCMPconst + OpARMCMN + OpARMCMNconst + OpARMTST + OpARMTSTconst + OpARMTEQ + OpARMTEQconst + OpARMCMPF + OpARMCMPD + OpARMCMPshiftLL + OpARMCMPshiftRL + OpARMCMPshiftRA + OpARMCMNshiftLL + OpARMCMNshiftRL + OpARMCMNshiftRA + OpARMTSTshiftLL + OpARMTSTshiftRL + OpARMTSTshiftRA + OpARMTEQshiftLL + OpARMTEQshiftRL + OpARMTEQshiftRA + OpARMCMPshiftLLreg + OpARMCMPshiftRLreg + OpARMCMPshiftRAreg + OpARMCMNshiftLLreg + OpARMCMNshiftRLreg + OpARMCMNshiftRAreg + OpARMTSTshiftLLreg + OpARMTSTshiftRLreg + OpARMTSTshiftRAreg + OpARMTEQshiftLLreg + OpARMTEQshiftRLreg + OpARMTEQshiftRAreg + OpARMCMPF0 + OpARMCMPD0 + OpARMMOVWconst + OpARMMOVFconst + OpARMMOVDconst + OpARMMOVWaddr + OpARMMOVBload + OpARMMOVBUload + OpARMMOVHload + OpARMMOVHUload + OpARMMOVWload + OpARMMOVFload + OpARMMOVDload + OpARMMOVBstore + OpARMMOVHstore + OpARMMOVWstore + OpARMMOVFstore + OpARMMOVDstore + OpARMMOVWloadidx + OpARMMOVWloadshiftLL + OpARMMOVWloadshiftRL + OpARMMOVWloadshiftRA + OpARMMOVBUloadidx + OpARMMOVBloadidx + OpARMMOVHUloadidx + OpARMMOVHloadidx + OpARMMOVWstoreidx + OpARMMOVWstoreshiftLL + OpARMMOVWstoreshiftRL + OpARMMOVWstoreshiftRA + OpARMMOVBstoreidx + OpARMMOVHstoreidx + OpARMMOVBreg + OpARMMOVBUreg + OpARMMOVHreg + OpARMMOVHUreg + OpARMMOVWreg + OpARMMOVWnop + OpARMMOVWF + OpARMMOVWD + OpARMMOVWUF + OpARMMOVWUD + OpARMMOVFW + OpARMMOVDW + OpARMMOVFWU + OpARMMOVDWU + OpARMMOVFD + OpARMMOVDF + OpARMCMOVWHSconst + OpARMCMOVWLSconst + OpARMSRAcond + OpARMCALLstatic + OpARMCALLtail + OpARMCALLclosure + OpARMCALLinter + OpARMLoweredNilCheck + OpARMEqual + OpARMNotEqual + OpARMLessThan + OpARMLessEqual + OpARMGreaterThan + OpARMGreaterEqual + OpARMLessThanU + OpARMLessEqualU + OpARMGreaterThanU + OpARMGreaterEqualU + OpARMDUFFZERO + OpARMDUFFCOPY + OpARMLoweredZero + OpARMLoweredMove + OpARMLoweredGetClosurePtr + OpARMLoweredGetCallerSP + OpARMLoweredGetCallerPC + OpARMLoweredPanicBoundsRR + OpARMLoweredPanicBoundsRC + OpARMLoweredPanicBoundsCR + OpARMLoweredPanicBoundsCC + OpARMLoweredPanicExtendRR + OpARMLoweredPanicExtendRC + OpARMFlagConstant + OpARMInvertFlags + OpARMLoweredWB + + OpARM64ADCSflags + OpARM64ADCzerocarry + OpARM64ADD + OpARM64ADDconst + OpARM64ADDSconstflags + OpARM64ADDSflags + OpARM64SUB + OpARM64SUBconst + OpARM64SBCSflags + OpARM64SUBSflags + OpARM64MUL + OpARM64MULW + OpARM64MNEG + OpARM64MNEGW + OpARM64MULH + OpARM64UMULH + OpARM64MULL + OpARM64UMULL + OpARM64DIV + OpARM64UDIV + OpARM64DIVW + OpARM64UDIVW + OpARM64MOD + OpARM64UMOD + OpARM64MODW + OpARM64UMODW + OpARM64FADDS + OpARM64FADDD + OpARM64FSUBS + OpARM64FSUBD + OpARM64FMULS + OpARM64FMULD + OpARM64FNMULS + OpARM64FNMULD + OpARM64FDIVS + OpARM64FDIVD + OpARM64AND + OpARM64ANDconst + OpARM64OR + OpARM64ORconst + OpARM64XOR + OpARM64XORconst + OpARM64BIC + OpARM64EON + OpARM64ORN + OpARM64MVN + OpARM64NEG + OpARM64NEGSflags + OpARM64NGCzerocarry + OpARM64FABSD + OpARM64FNEGS + OpARM64FNEGD + OpARM64FSQRTD + OpARM64FSQRTS + OpARM64FMIND + OpARM64FMINS + OpARM64FMAXD + OpARM64FMAXS + OpARM64REV + OpARM64REVW + OpARM64REV16 + OpARM64REV16W + OpARM64RBIT + OpARM64RBITW + OpARM64CLZ + OpARM64CLZW + OpARM64VCNT + OpARM64VUADDLV + OpARM64LoweredRound32F + OpARM64LoweredRound64F + OpARM64FMADDS + OpARM64FMADDD + OpARM64FNMADDS + OpARM64FNMADDD + OpARM64FMSUBS + OpARM64FMSUBD + OpARM64FNMSUBS + OpARM64FNMSUBD + OpARM64MADD + OpARM64MADDW + OpARM64MSUB + OpARM64MSUBW + OpARM64SLL + OpARM64SLLconst + OpARM64SRL + OpARM64SRLconst + OpARM64SRA + OpARM64SRAconst + OpARM64ROR + OpARM64RORW + OpARM64RORconst + OpARM64RORWconst + OpARM64EXTRconst + OpARM64EXTRWconst + OpARM64CMP + OpARM64CMPconst + OpARM64CMPW + OpARM64CMPWconst + OpARM64CMN + OpARM64CMNconst + OpARM64CMNW + OpARM64CMNWconst + OpARM64TST + OpARM64TSTconst + OpARM64TSTW + OpARM64TSTWconst + OpARM64FCMPS + OpARM64FCMPD + OpARM64FCMPS0 + OpARM64FCMPD0 + OpARM64MVNshiftLL + OpARM64MVNshiftRL + OpARM64MVNshiftRA + OpARM64MVNshiftRO + OpARM64NEGshiftLL + OpARM64NEGshiftRL + OpARM64NEGshiftRA + OpARM64ADDshiftLL + OpARM64ADDshiftRL + OpARM64ADDshiftRA + OpARM64SUBshiftLL + OpARM64SUBshiftRL + OpARM64SUBshiftRA + OpARM64ANDshiftLL + OpARM64ANDshiftRL + OpARM64ANDshiftRA + OpARM64ANDshiftRO + OpARM64ORshiftLL + OpARM64ORshiftRL + OpARM64ORshiftRA + OpARM64ORshiftRO + OpARM64XORshiftLL + OpARM64XORshiftRL + OpARM64XORshiftRA + OpARM64XORshiftRO + OpARM64BICshiftLL + OpARM64BICshiftRL + OpARM64BICshiftRA + OpARM64BICshiftRO + OpARM64EONshiftLL + OpARM64EONshiftRL + OpARM64EONshiftRA + OpARM64EONshiftRO + OpARM64ORNshiftLL + OpARM64ORNshiftRL + OpARM64ORNshiftRA + OpARM64ORNshiftRO + OpARM64CMPshiftLL + OpARM64CMPshiftRL + OpARM64CMPshiftRA + OpARM64CMNshiftLL + OpARM64CMNshiftRL + OpARM64CMNshiftRA + OpARM64TSTshiftLL + OpARM64TSTshiftRL + OpARM64TSTshiftRA + OpARM64TSTshiftRO + OpARM64BFI + OpARM64BFXIL + OpARM64SBFIZ + OpARM64SBFX + OpARM64UBFIZ + OpARM64UBFX + OpARM64MOVDconst + OpARM64FMOVSconst + OpARM64FMOVDconst + OpARM64MOVDaddr + OpARM64MOVBload + OpARM64MOVBUload + OpARM64MOVHload + OpARM64MOVHUload + OpARM64MOVWload + OpARM64MOVWUload + OpARM64MOVDload + OpARM64FMOVSload + OpARM64FMOVDload + OpARM64LDP + OpARM64LDPW + OpARM64LDPSW + OpARM64FLDPD + OpARM64FLDPS + OpARM64MOVDloadidx + OpARM64MOVWloadidx + OpARM64MOVWUloadidx + OpARM64MOVHloadidx + OpARM64MOVHUloadidx + OpARM64MOVBloadidx + OpARM64MOVBUloadidx + OpARM64FMOVSloadidx + OpARM64FMOVDloadidx + OpARM64MOVHloadidx2 + OpARM64MOVHUloadidx2 + OpARM64MOVWloadidx4 + OpARM64MOVWUloadidx4 + OpARM64MOVDloadidx8 + OpARM64FMOVSloadidx4 + OpARM64FMOVDloadidx8 + OpARM64MOVBstore + OpARM64MOVHstore + OpARM64MOVWstore + OpARM64MOVDstore + OpARM64FMOVSstore + OpARM64FMOVDstore + OpARM64STP + OpARM64STPW + OpARM64FSTPD + OpARM64FSTPS + OpARM64MOVBstoreidx + OpARM64MOVHstoreidx + OpARM64MOVWstoreidx + OpARM64MOVDstoreidx + OpARM64FMOVSstoreidx + OpARM64FMOVDstoreidx + OpARM64MOVHstoreidx2 + OpARM64MOVWstoreidx4 + OpARM64MOVDstoreidx8 + OpARM64FMOVSstoreidx4 + OpARM64FMOVDstoreidx8 + OpARM64FMOVDgpfp + OpARM64FMOVDfpgp + OpARM64FMOVSgpfp + OpARM64FMOVSfpgp + OpARM64MOVBreg + OpARM64MOVBUreg + OpARM64MOVHreg + OpARM64MOVHUreg + OpARM64MOVWreg + OpARM64MOVWUreg + OpARM64MOVDreg + OpARM64MOVDnop + OpARM64SCVTFWS + OpARM64SCVTFWD + OpARM64UCVTFWS + OpARM64UCVTFWD + OpARM64SCVTFS + OpARM64SCVTFD + OpARM64UCVTFS + OpARM64UCVTFD + OpARM64FCVTZSSW + OpARM64FCVTZSDW + OpARM64FCVTZUSW + OpARM64FCVTZUDW + OpARM64FCVTZSS + OpARM64FCVTZSD + OpARM64FCVTZUS + OpARM64FCVTZUD + OpARM64FCVTSD + OpARM64FCVTDS + OpARM64FRINTAD + OpARM64FRINTMD + OpARM64FRINTND + OpARM64FRINTPD + OpARM64FRINTZD + OpARM64CSEL + OpARM64CSEL0 + OpARM64CSINC + OpARM64CSINV + OpARM64CSNEG + OpARM64CSETM + OpARM64CCMP + OpARM64CCMN + OpARM64CCMPconst + OpARM64CCMNconst + OpARM64CCMPW + OpARM64CCMNW + OpARM64CCMPWconst + OpARM64CCMNWconst + OpARM64CALLstatic + OpARM64CALLtail + OpARM64CALLclosure + OpARM64CALLinter + OpARM64LoweredNilCheck + OpARM64LoweredMemEq + OpARM64Equal + OpARM64NotEqual + OpARM64LessThan + OpARM64LessEqual + OpARM64GreaterThan + OpARM64GreaterEqual + OpARM64LessThanU + OpARM64LessEqualU + OpARM64GreaterThanU + OpARM64GreaterEqualU + OpARM64LessThanF + OpARM64LessEqualF + OpARM64GreaterThanF + OpARM64GreaterEqualF + OpARM64NotLessThanF + OpARM64NotLessEqualF + OpARM64NotGreaterThanF + OpARM64NotGreaterEqualF + OpARM64LessThanNoov + OpARM64GreaterEqualNoov + OpARM64LoweredZero + OpARM64LoweredZeroLoop + OpARM64LoweredMove + OpARM64LoweredMoveLoop + OpARM64LoweredGetClosurePtr + OpARM64LoweredGetCallerSP + OpARM64LoweredGetCallerPC + OpARM64FlagConstant + OpARM64InvertFlags + OpARM64LDAR + OpARM64LDARB + OpARM64LDARW + OpARM64STLRB + OpARM64STLR + OpARM64STLRW + OpARM64LoweredAtomicExchange64 + OpARM64LoweredAtomicExchange32 + OpARM64LoweredAtomicExchange8 + OpARM64LoweredAtomicExchange64Variant + OpARM64LoweredAtomicExchange32Variant + OpARM64LoweredAtomicExchange8Variant + OpARM64LoweredAtomicAdd64 + OpARM64LoweredAtomicAdd32 + OpARM64LoweredAtomicAdd64Variant + OpARM64LoweredAtomicAdd32Variant + OpARM64LoweredAtomicCas64 + OpARM64LoweredAtomicCas32 + OpARM64LoweredAtomicCas64Variant + OpARM64LoweredAtomicCas32Variant + OpARM64LoweredAtomicAnd8 + OpARM64LoweredAtomicOr8 + OpARM64LoweredAtomicAnd64 + OpARM64LoweredAtomicOr64 + OpARM64LoweredAtomicAnd32 + OpARM64LoweredAtomicOr32 + OpARM64LoweredAtomicAnd8Variant + OpARM64LoweredAtomicOr8Variant + OpARM64LoweredAtomicAnd64Variant + OpARM64LoweredAtomicOr64Variant + OpARM64LoweredAtomicAnd32Variant + OpARM64LoweredAtomicOr32Variant + OpARM64LoweredWB + OpARM64LoweredPanicBoundsRR + OpARM64LoweredPanicBoundsRC + OpARM64LoweredPanicBoundsCR + OpARM64LoweredPanicBoundsCC + OpARM64PRFM + OpARM64DMB + OpARM64ZERO + + OpLOONG64NEGV + OpLOONG64NEGF + OpLOONG64NEGD + OpLOONG64SQRTD + OpLOONG64SQRTF + OpLOONG64ABSD + OpLOONG64CLZW + OpLOONG64CLZV + OpLOONG64CTZW + OpLOONG64CTZV + OpLOONG64REVB2H + OpLOONG64REVB2W + OpLOONG64REVB4H + OpLOONG64REVBV + OpLOONG64BITREV4B + OpLOONG64BITREVW + OpLOONG64BITREVV + OpLOONG64VPCNT64 + OpLOONG64VPCNT32 + OpLOONG64VPCNT16 + OpLOONG64ADDV + OpLOONG64ADDVconst + OpLOONG64ADDV16const + OpLOONG64SUBV + OpLOONG64SUBVconst + OpLOONG64MULV + OpLOONG64MULHV + OpLOONG64MULHVU + OpLOONG64MULH + OpLOONG64MULHU + OpLOONG64DIVV + OpLOONG64DIVVU + OpLOONG64REMV + OpLOONG64REMVU + OpLOONG64MULWVW + OpLOONG64MULWVWU + OpLOONG64ADDF + OpLOONG64ADDD + OpLOONG64SUBF + OpLOONG64SUBD + OpLOONG64MULF + OpLOONG64MULD + OpLOONG64DIVF + OpLOONG64DIVD + OpLOONG64AND + OpLOONG64ANDconst + OpLOONG64OR + OpLOONG64ORconst + OpLOONG64XOR + OpLOONG64XORconst + OpLOONG64NOR + OpLOONG64NORconst + OpLOONG64ANDN + OpLOONG64ORN + OpLOONG64FMADDF + OpLOONG64FMADDD + OpLOONG64FMSUBF + OpLOONG64FMSUBD + OpLOONG64FNMADDF + OpLOONG64FNMADDD + OpLOONG64FNMSUBF + OpLOONG64FNMSUBD + OpLOONG64FMINF + OpLOONG64FMIND + OpLOONG64FMAXF + OpLOONG64FMAXD + OpLOONG64MASKEQZ + OpLOONG64MASKNEZ + OpLOONG64FCOPYSGD + OpLOONG64SLL + OpLOONG64SLLV + OpLOONG64SLLconst + OpLOONG64SLLVconst + OpLOONG64SRL + OpLOONG64SRLV + OpLOONG64SRLconst + OpLOONG64SRLVconst + OpLOONG64SRA + OpLOONG64SRAV + OpLOONG64SRAconst + OpLOONG64SRAVconst + OpLOONG64ROTR + OpLOONG64ROTRV + OpLOONG64ROTRconst + OpLOONG64ROTRVconst + OpLOONG64SGT + OpLOONG64SGTconst + OpLOONG64SGTU + OpLOONG64SGTUconst + OpLOONG64CMPEQF + OpLOONG64CMPEQD + OpLOONG64CMPGEF + OpLOONG64CMPGED + OpLOONG64CMPGTF + OpLOONG64CMPGTD + OpLOONG64BSTRPICKW + OpLOONG64BSTRPICKV + OpLOONG64MOVVconst + OpLOONG64MOVFconst + OpLOONG64MOVDconst + OpLOONG64MOVVaddr + OpLOONG64MOVBload + OpLOONG64MOVBUload + OpLOONG64MOVHload + OpLOONG64MOVHUload + OpLOONG64MOVWload + OpLOONG64MOVWUload + OpLOONG64MOVVload + OpLOONG64MOVFload + OpLOONG64MOVDload + OpLOONG64MOVVloadidx + OpLOONG64MOVWloadidx + OpLOONG64MOVWUloadidx + OpLOONG64MOVHloadidx + OpLOONG64MOVHUloadidx + OpLOONG64MOVBloadidx + OpLOONG64MOVBUloadidx + OpLOONG64MOVFloadidx + OpLOONG64MOVDloadidx + OpLOONG64MOVBstore + OpLOONG64MOVHstore + OpLOONG64MOVWstore + OpLOONG64MOVVstore + OpLOONG64MOVFstore + OpLOONG64MOVDstore + OpLOONG64MOVBstoreidx + OpLOONG64MOVHstoreidx + OpLOONG64MOVWstoreidx + OpLOONG64MOVVstoreidx + OpLOONG64MOVFstoreidx + OpLOONG64MOVDstoreidx + OpLOONG64MOVWfpgp + OpLOONG64MOVWgpfp + OpLOONG64MOVVfpgp + OpLOONG64MOVVgpfp + OpLOONG64MOVBreg + OpLOONG64MOVBUreg + OpLOONG64MOVHreg + OpLOONG64MOVHUreg + OpLOONG64MOVWreg + OpLOONG64MOVWUreg + OpLOONG64MOVVreg + OpLOONG64MOVVnop + OpLOONG64MOVWF + OpLOONG64MOVWD + OpLOONG64MOVVF + OpLOONG64MOVVD + OpLOONG64TRUNCFW + OpLOONG64TRUNCDW + OpLOONG64TRUNCFV + OpLOONG64TRUNCDV + OpLOONG64MOVFD + OpLOONG64MOVDF + OpLOONG64LoweredRound32F + OpLOONG64LoweredRound64F + OpLOONG64CALLstatic + OpLOONG64CALLtail + OpLOONG64CALLclosure + OpLOONG64CALLinter + OpLOONG64LoweredZero + OpLOONG64LoweredZeroLoop + OpLOONG64LoweredMove + OpLOONG64LoweredMoveLoop + OpLOONG64LoweredAtomicLoad8 + OpLOONG64LoweredAtomicLoad32 + OpLOONG64LoweredAtomicLoad64 + OpLOONG64LoweredAtomicStore8 + OpLOONG64LoweredAtomicStore32 + OpLOONG64LoweredAtomicStore64 + OpLOONG64LoweredAtomicStore8Variant + OpLOONG64LoweredAtomicStore32Variant + OpLOONG64LoweredAtomicStore64Variant + OpLOONG64LoweredAtomicExchange32 + OpLOONG64LoweredAtomicExchange64 + OpLOONG64LoweredAtomicExchange8Variant + OpLOONG64LoweredAtomicAdd32 + OpLOONG64LoweredAtomicAdd64 + OpLOONG64LoweredAtomicCas32 + OpLOONG64LoweredAtomicCas64 + OpLOONG64LoweredAtomicCas64Variant + OpLOONG64LoweredAtomicCas32Variant + OpLOONG64LoweredAtomicAnd32 + OpLOONG64LoweredAtomicOr32 + OpLOONG64LoweredAtomicAnd32value + OpLOONG64LoweredAtomicAnd64value + OpLOONG64LoweredAtomicOr32value + OpLOONG64LoweredAtomicOr64value + OpLOONG64LoweredNilCheck + OpLOONG64FPFlagTrue + OpLOONG64FPFlagFalse + OpLOONG64LoweredGetClosurePtr + OpLOONG64LoweredGetCallerSP + OpLOONG64LoweredGetCallerPC + OpLOONG64LoweredWB + OpLOONG64LoweredPubBarrier + OpLOONG64LoweredPanicBoundsRR + OpLOONG64LoweredPanicBoundsRC + OpLOONG64LoweredPanicBoundsCR + OpLOONG64LoweredPanicBoundsCC + OpLOONG64PRELD + OpLOONG64PRELDX + OpLOONG64ADDshiftLLV + OpLOONG64ZERO + + OpMIPSADD + OpMIPSADDconst + OpMIPSSUB + OpMIPSSUBconst + OpMIPSMUL + OpMIPSMULT + OpMIPSMULTU + OpMIPSDIV + OpMIPSDIVU + OpMIPSADDF + OpMIPSADDD + OpMIPSSUBF + OpMIPSSUBD + OpMIPSMULF + OpMIPSMULD + OpMIPSDIVF + OpMIPSDIVD + OpMIPSAND + OpMIPSANDconst + OpMIPSOR + OpMIPSORconst + OpMIPSXOR + OpMIPSXORconst + OpMIPSNOR + OpMIPSNORconst + OpMIPSNEG + OpMIPSNEGF + OpMIPSNEGD + OpMIPSABSD + OpMIPSSQRTD + OpMIPSSQRTF + OpMIPSSLL + OpMIPSSLLconst + OpMIPSSRL + OpMIPSSRLconst + OpMIPSSRA + OpMIPSSRAconst + OpMIPSCLZ + OpMIPSSGT + OpMIPSSGTconst + OpMIPSSGTzero + OpMIPSSGTU + OpMIPSSGTUconst + OpMIPSSGTUzero + OpMIPSCMPEQF + OpMIPSCMPEQD + OpMIPSCMPGEF + OpMIPSCMPGED + OpMIPSCMPGTF + OpMIPSCMPGTD + OpMIPSMOVWconst + OpMIPSMOVFconst + OpMIPSMOVDconst + OpMIPSMOVWaddr + OpMIPSMOVBload + OpMIPSMOVBUload + OpMIPSMOVHload + OpMIPSMOVHUload + OpMIPSMOVWload + OpMIPSMOVFload + OpMIPSMOVDload + OpMIPSMOVBstore + OpMIPSMOVHstore + OpMIPSMOVWstore + OpMIPSMOVFstore + OpMIPSMOVDstore + OpMIPSMOVBstorezero + OpMIPSMOVHstorezero + OpMIPSMOVWstorezero + OpMIPSMOVWfpgp + OpMIPSMOVWgpfp + OpMIPSMOVBreg + OpMIPSMOVBUreg + OpMIPSMOVHreg + OpMIPSMOVHUreg + OpMIPSMOVWreg + OpMIPSMOVWnop + OpMIPSCMOVZ + OpMIPSCMOVZzero + OpMIPSMOVWF + OpMIPSMOVWD + OpMIPSTRUNCFW + OpMIPSTRUNCDW + OpMIPSMOVFD + OpMIPSMOVDF + OpMIPSCALLstatic + OpMIPSCALLtail + OpMIPSCALLclosure + OpMIPSCALLinter + OpMIPSLoweredAtomicLoad8 + OpMIPSLoweredAtomicLoad32 + OpMIPSLoweredAtomicStore8 + OpMIPSLoweredAtomicStore32 + OpMIPSLoweredAtomicStorezero + OpMIPSLoweredAtomicExchange + OpMIPSLoweredAtomicAdd + OpMIPSLoweredAtomicAddconst + OpMIPSLoweredAtomicCas + OpMIPSLoweredAtomicAnd + OpMIPSLoweredAtomicOr + OpMIPSLoweredZero + OpMIPSLoweredMove + OpMIPSLoweredNilCheck + OpMIPSFPFlagTrue + OpMIPSFPFlagFalse + OpMIPSLoweredGetClosurePtr + OpMIPSLoweredGetCallerSP + OpMIPSLoweredGetCallerPC + OpMIPSLoweredWB + OpMIPSLoweredPubBarrier + OpMIPSLoweredPanicBoundsRR + OpMIPSLoweredPanicBoundsRC + OpMIPSLoweredPanicBoundsCR + OpMIPSLoweredPanicBoundsCC + OpMIPSLoweredPanicExtendRR + OpMIPSLoweredPanicExtendRC + + OpMIPS64ADDV + OpMIPS64ADDVconst + OpMIPS64SUBV + OpMIPS64SUBVconst + OpMIPS64MULV + OpMIPS64MULVU + OpMIPS64DIVV + OpMIPS64DIVVU + OpMIPS64ADDF + OpMIPS64ADDD + OpMIPS64SUBF + OpMIPS64SUBD + OpMIPS64MULF + OpMIPS64MULD + OpMIPS64DIVF + OpMIPS64DIVD + OpMIPS64AND + OpMIPS64ANDconst + OpMIPS64OR + OpMIPS64ORconst + OpMIPS64XOR + OpMIPS64XORconst + OpMIPS64NOR + OpMIPS64NORconst + OpMIPS64NEGV + OpMIPS64NEGF + OpMIPS64NEGD + OpMIPS64ABSD + OpMIPS64SQRTD + OpMIPS64SQRTF + OpMIPS64SLLV + OpMIPS64SLLVconst + OpMIPS64SRLV + OpMIPS64SRLVconst + OpMIPS64SRAV + OpMIPS64SRAVconst + OpMIPS64SGT + OpMIPS64SGTconst + OpMIPS64SGTU + OpMIPS64SGTUconst + OpMIPS64CMPEQF + OpMIPS64CMPEQD + OpMIPS64CMPGEF + OpMIPS64CMPGED + OpMIPS64CMPGTF + OpMIPS64CMPGTD + OpMIPS64MOVVconst + OpMIPS64MOVFconst + OpMIPS64MOVDconst + OpMIPS64MOVVaddr + OpMIPS64MOVBload + OpMIPS64MOVBUload + OpMIPS64MOVHload + OpMIPS64MOVHUload + OpMIPS64MOVWload + OpMIPS64MOVWUload + OpMIPS64MOVVload + OpMIPS64MOVFload + OpMIPS64MOVDload + OpMIPS64MOVBstore + OpMIPS64MOVHstore + OpMIPS64MOVWstore + OpMIPS64MOVVstore + OpMIPS64MOVFstore + OpMIPS64MOVDstore + OpMIPS64ZERO + OpMIPS64MOVWfpgp + OpMIPS64MOVWgpfp + OpMIPS64MOVVfpgp + OpMIPS64MOVVgpfp + OpMIPS64MOVBreg + OpMIPS64MOVBUreg + OpMIPS64MOVHreg + OpMIPS64MOVHUreg + OpMIPS64MOVWreg + OpMIPS64MOVWUreg + OpMIPS64MOVVreg + OpMIPS64MOVVnop + OpMIPS64MOVWF + OpMIPS64MOVWD + OpMIPS64MOVVF + OpMIPS64MOVVD + OpMIPS64TRUNCFW + OpMIPS64TRUNCDW + OpMIPS64TRUNCFV + OpMIPS64TRUNCDV + OpMIPS64MOVFD + OpMIPS64MOVDF + OpMIPS64CALLstatic + OpMIPS64CALLtail + OpMIPS64CALLclosure + OpMIPS64CALLinter + OpMIPS64DUFFZERO + OpMIPS64DUFFCOPY + OpMIPS64LoweredZero + OpMIPS64LoweredMove + OpMIPS64LoweredAtomicAnd32 + OpMIPS64LoweredAtomicOr32 + OpMIPS64LoweredAtomicLoad8 + OpMIPS64LoweredAtomicLoad32 + OpMIPS64LoweredAtomicLoad64 + OpMIPS64LoweredAtomicStore8 + OpMIPS64LoweredAtomicStore32 + OpMIPS64LoweredAtomicStore64 + OpMIPS64LoweredAtomicStorezero32 + OpMIPS64LoweredAtomicStorezero64 + OpMIPS64LoweredAtomicExchange32 + OpMIPS64LoweredAtomicExchange64 + OpMIPS64LoweredAtomicAdd32 + OpMIPS64LoweredAtomicAdd64 + OpMIPS64LoweredAtomicAddconst32 + OpMIPS64LoweredAtomicAddconst64 + OpMIPS64LoweredAtomicCas32 + OpMIPS64LoweredAtomicCas64 + OpMIPS64LoweredNilCheck + OpMIPS64FPFlagTrue + OpMIPS64FPFlagFalse + OpMIPS64LoweredGetClosurePtr + OpMIPS64LoweredGetCallerSP + OpMIPS64LoweredGetCallerPC + OpMIPS64LoweredWB + OpMIPS64LoweredPubBarrier + OpMIPS64LoweredPanicBoundsRR + OpMIPS64LoweredPanicBoundsRC + OpMIPS64LoweredPanicBoundsCR + OpMIPS64LoweredPanicBoundsCC + + OpPPC64ADD + OpPPC64ADDCC + OpPPC64ADDconst + OpPPC64ADDCCconst + OpPPC64FADD + OpPPC64FADDS + OpPPC64SUB + OpPPC64SUBCC + OpPPC64SUBFCconst + OpPPC64FSUB + OpPPC64FSUBS + OpPPC64XSMINJDP + OpPPC64XSMAXJDP + OpPPC64MULLD + OpPPC64MULLW + OpPPC64MULLDconst + OpPPC64MULLWconst + OpPPC64MADDLD + OpPPC64MULHD + OpPPC64MULHW + OpPPC64MULHDU + OpPPC64MULHDUCC + OpPPC64MULHWU + OpPPC64FMUL + OpPPC64FMULS + OpPPC64FMADD + OpPPC64FMADDS + OpPPC64FMSUB + OpPPC64FMSUBS + OpPPC64SRAD + OpPPC64SRAW + OpPPC64SRD + OpPPC64SRW + OpPPC64SLD + OpPPC64SLW + OpPPC64ROTL + OpPPC64ROTLW + OpPPC64CLRLSLWI + OpPPC64CLRLSLDI + OpPPC64ADDC + OpPPC64SUBC + OpPPC64ADDCconst + OpPPC64SUBCconst + OpPPC64ADDE + OpPPC64ADDZE + OpPPC64SUBE + OpPPC64ADDZEzero + OpPPC64SUBZEzero + OpPPC64SRADconst + OpPPC64SRAWconst + OpPPC64SRDconst + OpPPC64SRWconst + OpPPC64SLDconst + OpPPC64SLWconst + OpPPC64ROTLconst + OpPPC64ROTLWconst + OpPPC64EXTSWSLconst + OpPPC64RLWINM + OpPPC64RLWNM + OpPPC64RLWMI + OpPPC64RLDICL + OpPPC64RLDICLCC + OpPPC64RLDICR + OpPPC64CNTLZD + OpPPC64CNTLZDCC + OpPPC64CNTLZW + OpPPC64CNTTZD + OpPPC64CNTTZW + OpPPC64POPCNTD + OpPPC64POPCNTW + OpPPC64POPCNTB + OpPPC64FDIV + OpPPC64FDIVS + OpPPC64DIVD + OpPPC64DIVW + OpPPC64DIVDU + OpPPC64DIVWU + OpPPC64MODUD + OpPPC64MODSD + OpPPC64MODUW + OpPPC64MODSW + OpPPC64FCTIDZ + OpPPC64FCTIWZ + OpPPC64FCFID + OpPPC64FCFIDS + OpPPC64FRSP + OpPPC64MFVSRD + OpPPC64MTVSRD + OpPPC64AND + OpPPC64ANDN + OpPPC64ANDNCC + OpPPC64ANDCC + OpPPC64OR + OpPPC64ORN + OpPPC64ORCC + OpPPC64NOR + OpPPC64NORCC + OpPPC64XOR + OpPPC64XORCC + OpPPC64EQV + OpPPC64NEG + OpPPC64NEGCC + OpPPC64BRD + OpPPC64BRW + OpPPC64BRH + OpPPC64FNEG + OpPPC64FSQRT + OpPPC64FSQRTS + OpPPC64FFLOOR + OpPPC64FCEIL + OpPPC64FTRUNC + OpPPC64FROUND + OpPPC64FABS + OpPPC64FNABS + OpPPC64FCPSGN + OpPPC64ORconst + OpPPC64XORconst + OpPPC64ANDCCconst + OpPPC64ANDconst + OpPPC64MOVBreg + OpPPC64MOVBZreg + OpPPC64MOVHreg + OpPPC64MOVHZreg + OpPPC64MOVWreg + OpPPC64MOVWZreg + OpPPC64MOVBZload + OpPPC64MOVHload + OpPPC64MOVHZload + OpPPC64MOVWload + OpPPC64MOVWZload + OpPPC64MOVDload + OpPPC64MOVDBRload + OpPPC64MOVWBRload + OpPPC64MOVHBRload + OpPPC64MOVBZloadidx + OpPPC64MOVHloadidx + OpPPC64MOVHZloadidx + OpPPC64MOVWloadidx + OpPPC64MOVWZloadidx + OpPPC64MOVDloadidx + OpPPC64MOVHBRloadidx + OpPPC64MOVWBRloadidx + OpPPC64MOVDBRloadidx + OpPPC64FMOVDloadidx + OpPPC64FMOVSloadidx + OpPPC64DCBT + OpPPC64MOVDBRstore + OpPPC64MOVWBRstore + OpPPC64MOVHBRstore + OpPPC64FMOVDload + OpPPC64FMOVSload + OpPPC64MOVBstore + OpPPC64MOVHstore + OpPPC64MOVWstore + OpPPC64MOVDstore + OpPPC64FMOVDstore + OpPPC64FMOVSstore + OpPPC64MOVBstoreidx + OpPPC64MOVHstoreidx + OpPPC64MOVWstoreidx + OpPPC64MOVDstoreidx + OpPPC64FMOVDstoreidx + OpPPC64FMOVSstoreidx + OpPPC64MOVHBRstoreidx + OpPPC64MOVWBRstoreidx + OpPPC64MOVDBRstoreidx + OpPPC64MOVBstorezero + OpPPC64MOVHstorezero + OpPPC64MOVWstorezero + OpPPC64MOVDstorezero + OpPPC64MOVDaddr + OpPPC64MOVDconst + OpPPC64FMOVDconst + OpPPC64FMOVSconst + OpPPC64FCMPU + OpPPC64CMP + OpPPC64CMPU + OpPPC64CMPW + OpPPC64CMPWU + OpPPC64CMPconst + OpPPC64CMPUconst + OpPPC64CMPWconst + OpPPC64CMPWUconst + OpPPC64ISEL + OpPPC64ISELZ + OpPPC64SETBC + OpPPC64SETBCR + OpPPC64Equal + OpPPC64NotEqual + OpPPC64LessThan + OpPPC64FLessThan + OpPPC64LessEqual + OpPPC64FLessEqual + OpPPC64GreaterThan + OpPPC64FGreaterThan + OpPPC64GreaterEqual + OpPPC64FGreaterEqual + OpPPC64LoweredGetClosurePtr + OpPPC64LoweredGetCallerSP + OpPPC64LoweredGetCallerPC + OpPPC64LoweredNilCheck + OpPPC64LoweredRound32F + OpPPC64LoweredRound64F + OpPPC64CALLstatic + OpPPC64CALLtail + OpPPC64CALLclosure + OpPPC64CALLinter + OpPPC64LoweredZero + OpPPC64LoweredZeroShort + OpPPC64LoweredQuadZeroShort + OpPPC64LoweredQuadZero + OpPPC64LoweredMove + OpPPC64LoweredMoveShort + OpPPC64LoweredQuadMove + OpPPC64LoweredQuadMoveShort + OpPPC64LoweredAtomicStore8 + OpPPC64LoweredAtomicStore32 + OpPPC64LoweredAtomicStore64 + OpPPC64LoweredAtomicLoad8 + OpPPC64LoweredAtomicLoad32 + OpPPC64LoweredAtomicLoad64 + OpPPC64LoweredAtomicLoadPtr + OpPPC64LoweredAtomicAdd32 + OpPPC64LoweredAtomicAdd64 + OpPPC64LoweredAtomicExchange8 + OpPPC64LoweredAtomicExchange32 + OpPPC64LoweredAtomicExchange64 + OpPPC64LoweredAtomicCas64 + OpPPC64LoweredAtomicCas32 + OpPPC64LoweredAtomicAnd8 + OpPPC64LoweredAtomicAnd32 + OpPPC64LoweredAtomicOr8 + OpPPC64LoweredAtomicOr32 + OpPPC64LoweredWB + OpPPC64LoweredPubBarrier + OpPPC64LoweredPanicBoundsRR + OpPPC64LoweredPanicBoundsRC + OpPPC64LoweredPanicBoundsCR + OpPPC64LoweredPanicBoundsCC + OpPPC64InvertFlags + OpPPC64FlagEQ + OpPPC64FlagLT + OpPPC64FlagGT + + OpRISCV64ADD + OpRISCV64ADDI + OpRISCV64ADDIW + OpRISCV64NEG + OpRISCV64NEGW + OpRISCV64SUB + OpRISCV64SUBW + OpRISCV64MUL + OpRISCV64MULW + OpRISCV64MULH + OpRISCV64MULHU + OpRISCV64LoweredMuluhilo + OpRISCV64LoweredMuluover + OpRISCV64DIV + OpRISCV64DIVU + OpRISCV64DIVW + OpRISCV64DIVUW + OpRISCV64REM + OpRISCV64REMU + OpRISCV64REMW + OpRISCV64REMUW + OpRISCV64MOVaddr + OpRISCV64MOVDconst + OpRISCV64FMOVDconst + OpRISCV64FMOVFconst + OpRISCV64MOVBload + OpRISCV64MOVHload + OpRISCV64MOVWload + OpRISCV64MOVDload + OpRISCV64MOVBUload + OpRISCV64MOVHUload + OpRISCV64MOVWUload + OpRISCV64MOVBstore + OpRISCV64MOVHstore + OpRISCV64MOVWstore + OpRISCV64MOVDstore + OpRISCV64MOVBstorezero + OpRISCV64MOVHstorezero + OpRISCV64MOVWstorezero + OpRISCV64MOVDstorezero + OpRISCV64MOVBreg + OpRISCV64MOVHreg + OpRISCV64MOVWreg + OpRISCV64MOVDreg + OpRISCV64MOVBUreg + OpRISCV64MOVHUreg + OpRISCV64MOVWUreg + OpRISCV64MOVDnop + OpRISCV64SLL + OpRISCV64SLLW + OpRISCV64SRA + OpRISCV64SRAW + OpRISCV64SRL + OpRISCV64SRLW + OpRISCV64SLLI + OpRISCV64SLLIW + OpRISCV64SRAI + OpRISCV64SRAIW + OpRISCV64SRLI + OpRISCV64SRLIW + OpRISCV64SH1ADD + OpRISCV64SH2ADD + OpRISCV64SH3ADD + OpRISCV64AND + OpRISCV64ANDN + OpRISCV64ANDI + OpRISCV64CLZ + OpRISCV64CLZW + OpRISCV64CPOP + OpRISCV64CPOPW + OpRISCV64CTZ + OpRISCV64CTZW + OpRISCV64NOT + OpRISCV64OR + OpRISCV64ORN + OpRISCV64ORI + OpRISCV64REV8 + OpRISCV64ROL + OpRISCV64ROLW + OpRISCV64ROR + OpRISCV64RORI + OpRISCV64RORIW + OpRISCV64RORW + OpRISCV64XNOR + OpRISCV64XOR + OpRISCV64XORI + OpRISCV64MIN + OpRISCV64MAX + OpRISCV64MINU + OpRISCV64MAXU + OpRISCV64SEQZ + OpRISCV64SNEZ + OpRISCV64SLT + OpRISCV64SLTI + OpRISCV64SLTU + OpRISCV64SLTIU + OpRISCV64LoweredRound32F + OpRISCV64LoweredRound64F + OpRISCV64CALLstatic + OpRISCV64CALLtail + OpRISCV64CALLclosure + OpRISCV64CALLinter + OpRISCV64LoweredZero + OpRISCV64LoweredZeroLoop + OpRISCV64LoweredMove + OpRISCV64LoweredMoveLoop + OpRISCV64LoweredAtomicLoad8 + OpRISCV64LoweredAtomicLoad32 + OpRISCV64LoweredAtomicLoad64 + OpRISCV64LoweredAtomicStore8 + OpRISCV64LoweredAtomicStore32 + OpRISCV64LoweredAtomicStore64 + OpRISCV64LoweredAtomicExchange32 + OpRISCV64LoweredAtomicExchange64 + OpRISCV64LoweredAtomicAdd32 + OpRISCV64LoweredAtomicAdd64 + OpRISCV64LoweredAtomicCas32 + OpRISCV64LoweredAtomicCas64 + OpRISCV64LoweredAtomicAnd32 + OpRISCV64LoweredAtomicOr32 + OpRISCV64LoweredNilCheck + OpRISCV64LoweredGetClosurePtr + OpRISCV64LoweredGetCallerSP + OpRISCV64LoweredGetCallerPC + OpRISCV64LoweredWB + OpRISCV64LoweredPubBarrier + OpRISCV64LoweredPanicBoundsRR + OpRISCV64LoweredPanicBoundsRC + OpRISCV64LoweredPanicBoundsCR + OpRISCV64LoweredPanicBoundsCC + OpRISCV64FADDS + OpRISCV64FSUBS + OpRISCV64FMULS + OpRISCV64FDIVS + OpRISCV64FMADDS + OpRISCV64FMSUBS + OpRISCV64FNMADDS + OpRISCV64FNMSUBS + OpRISCV64FSQRTS + OpRISCV64FNEGS + OpRISCV64FMVSX + OpRISCV64FMVXS + OpRISCV64FCVTSW + OpRISCV64FCVTSL + OpRISCV64FCVTWS + OpRISCV64FCVTLS + OpRISCV64FMOVWload + OpRISCV64FMOVWstore + OpRISCV64FEQS + OpRISCV64FNES + OpRISCV64FLTS + OpRISCV64FLES + OpRISCV64LoweredFMAXS + OpRISCV64LoweredFMINS + OpRISCV64FADDD + OpRISCV64FSUBD + OpRISCV64FMULD + OpRISCV64FDIVD + OpRISCV64FMADDD + OpRISCV64FMSUBD + OpRISCV64FNMADDD + OpRISCV64FNMSUBD + OpRISCV64FSQRTD + OpRISCV64FNEGD + OpRISCV64FABSD + OpRISCV64FSGNJD + OpRISCV64FMVDX + OpRISCV64FMVXD + OpRISCV64FCVTDW + OpRISCV64FCVTDL + OpRISCV64FCVTWD + OpRISCV64FCVTLD + OpRISCV64FCVTDS + OpRISCV64FCVTSD + OpRISCV64FMOVDload + OpRISCV64FMOVDstore + OpRISCV64FEQD + OpRISCV64FNED + OpRISCV64FLTD + OpRISCV64FLED + OpRISCV64LoweredFMIND + OpRISCV64LoweredFMAXD + OpRISCV64FCLASSS + OpRISCV64FCLASSD + + OpS390XFADDS + OpS390XFADD + OpS390XFSUBS + OpS390XFSUB + OpS390XFMULS + OpS390XFMUL + OpS390XFDIVS + OpS390XFDIV + OpS390XFNEGS + OpS390XFNEG + OpS390XFMADDS + OpS390XFMADD + OpS390XFMSUBS + OpS390XFMSUB + OpS390XLPDFR + OpS390XLNDFR + OpS390XCPSDR + OpS390XWFMAXDB + OpS390XWFMAXSB + OpS390XWFMINDB + OpS390XWFMINSB + OpS390XFIDBR + OpS390XFMOVSload + OpS390XFMOVDload + OpS390XFMOVSconst + OpS390XFMOVDconst + OpS390XFMOVSloadidx + OpS390XFMOVDloadidx + OpS390XFMOVSstore + OpS390XFMOVDstore + OpS390XFMOVSstoreidx + OpS390XFMOVDstoreidx + OpS390XADD + OpS390XADDW + OpS390XADDconst + OpS390XADDWconst + OpS390XADDload + OpS390XADDWload + OpS390XSUB + OpS390XSUBW + OpS390XSUBconst + OpS390XSUBWconst + OpS390XSUBload + OpS390XSUBWload + OpS390XMULLD + OpS390XMULLW + OpS390XMULLDconst + OpS390XMULLWconst + OpS390XMULLDload + OpS390XMULLWload + OpS390XMULHD + OpS390XMULHDU + OpS390XDIVD + OpS390XDIVW + OpS390XDIVDU + OpS390XDIVWU + OpS390XMODD + OpS390XMODW + OpS390XMODDU + OpS390XMODWU + OpS390XAND + OpS390XANDW + OpS390XANDconst + OpS390XANDWconst + OpS390XANDload + OpS390XANDWload + OpS390XOR + OpS390XORW + OpS390XORconst + OpS390XORWconst + OpS390XORload + OpS390XORWload + OpS390XXOR + OpS390XXORW + OpS390XXORconst + OpS390XXORWconst + OpS390XXORload + OpS390XXORWload + OpS390XADDC + OpS390XADDCconst + OpS390XADDE + OpS390XSUBC + OpS390XSUBE + OpS390XCMP + OpS390XCMPW + OpS390XCMPU + OpS390XCMPWU + OpS390XCMPconst + OpS390XCMPWconst + OpS390XCMPUconst + OpS390XCMPWUconst + OpS390XFCMPS + OpS390XFCMP + OpS390XLTDBR + OpS390XLTEBR + OpS390XSLD + OpS390XSLW + OpS390XSLDconst + OpS390XSLWconst + OpS390XSRD + OpS390XSRW + OpS390XSRDconst + OpS390XSRWconst + OpS390XSRAD + OpS390XSRAW + OpS390XSRADconst + OpS390XSRAWconst + OpS390XRLLG + OpS390XRLL + OpS390XRLLconst + OpS390XRXSBG + OpS390XRISBGZ + OpS390XNEG + OpS390XNEGW + OpS390XNOT + OpS390XNOTW + OpS390XFSQRT + OpS390XFSQRTS + OpS390XLOCGR + OpS390XMOVBreg + OpS390XMOVBZreg + OpS390XMOVHreg + OpS390XMOVHZreg + OpS390XMOVWreg + OpS390XMOVWZreg + OpS390XMOVDconst + OpS390XLDGR + OpS390XLGDR + OpS390XCFDBRA + OpS390XCGDBRA + OpS390XCFEBRA + OpS390XCGEBRA + OpS390XCEFBRA + OpS390XCDFBRA + OpS390XCEGBRA + OpS390XCDGBRA + OpS390XCLFEBR + OpS390XCLFDBR + OpS390XCLGEBR + OpS390XCLGDBR + OpS390XCELFBR + OpS390XCDLFBR + OpS390XCELGBR + OpS390XCDLGBR + OpS390XLEDBR + OpS390XLDEBR + OpS390XMOVDaddr + OpS390XMOVDaddridx + OpS390XMOVBZload + OpS390XMOVBload + OpS390XMOVHZload + OpS390XMOVHload + OpS390XMOVWZload + OpS390XMOVWload + OpS390XMOVDload + OpS390XMOVWBR + OpS390XMOVDBR + OpS390XMOVHBRload + OpS390XMOVWBRload + OpS390XMOVDBRload + OpS390XMOVBstore + OpS390XMOVHstore + OpS390XMOVWstore + OpS390XMOVDstore + OpS390XMOVHBRstore + OpS390XMOVWBRstore + OpS390XMOVDBRstore + OpS390XMVC + OpS390XMOVBZloadidx + OpS390XMOVBloadidx + OpS390XMOVHZloadidx + OpS390XMOVHloadidx + OpS390XMOVWZloadidx + OpS390XMOVWloadidx + OpS390XMOVDloadidx + OpS390XMOVHBRloadidx + OpS390XMOVWBRloadidx + OpS390XMOVDBRloadidx + OpS390XMOVBstoreidx + OpS390XMOVHstoreidx + OpS390XMOVWstoreidx + OpS390XMOVDstoreidx + OpS390XMOVHBRstoreidx + OpS390XMOVWBRstoreidx + OpS390XMOVDBRstoreidx + OpS390XMOVBstoreconst + OpS390XMOVHstoreconst + OpS390XMOVWstoreconst + OpS390XMOVDstoreconst + OpS390XCLEAR + OpS390XCALLstatic + OpS390XCALLtail + OpS390XCALLclosure + OpS390XCALLinter + OpS390XInvertFlags + OpS390XLoweredGetG + OpS390XLoweredGetClosurePtr + OpS390XLoweredGetCallerSP + OpS390XLoweredGetCallerPC + OpS390XLoweredNilCheck + OpS390XLoweredRound32F + OpS390XLoweredRound64F + OpS390XLoweredWB + OpS390XLoweredPanicBoundsRR + OpS390XLoweredPanicBoundsRC + OpS390XLoweredPanicBoundsCR + OpS390XLoweredPanicBoundsCC + OpS390XFlagEQ + OpS390XFlagLT + OpS390XFlagGT + OpS390XFlagOV + OpS390XSYNC + OpS390XMOVBZatomicload + OpS390XMOVWZatomicload + OpS390XMOVDatomicload + OpS390XMOVBatomicstore + OpS390XMOVWatomicstore + OpS390XMOVDatomicstore + OpS390XLAA + OpS390XLAAG + OpS390XAddTupleFirst32 + OpS390XAddTupleFirst64 + OpS390XLAN + OpS390XLANfloor + OpS390XLAO + OpS390XLAOfloor + OpS390XLoweredAtomicCas32 + OpS390XLoweredAtomicCas64 + OpS390XLoweredAtomicExchange32 + OpS390XLoweredAtomicExchange64 + OpS390XFLOGR + OpS390XPOPCNT + OpS390XMLGR + OpS390XSumBytes2 + OpS390XSumBytes4 + OpS390XSumBytes8 + OpS390XSTMG2 + OpS390XSTMG3 + OpS390XSTMG4 + OpS390XSTM2 + OpS390XSTM3 + OpS390XSTM4 + OpS390XLoweredMove + OpS390XLoweredZero + + OpWasmLoweredStaticCall + OpWasmLoweredTailCall + OpWasmLoweredClosureCall + OpWasmLoweredInterCall + OpWasmLoweredAddr + OpWasmLoweredMove + OpWasmLoweredZero + OpWasmLoweredGetClosurePtr + OpWasmLoweredGetCallerPC + OpWasmLoweredGetCallerSP + OpWasmLoweredNilCheck + OpWasmLoweredWB + OpWasmLoweredConvert + OpWasmSelect + OpWasmI64Load8U + OpWasmI64Load8S + OpWasmI64Load16U + OpWasmI64Load16S + OpWasmI64Load32U + OpWasmI64Load32S + OpWasmI64Load + OpWasmI64Store8 + OpWasmI64Store16 + OpWasmI64Store32 + OpWasmI64Store + OpWasmF32Load + OpWasmF64Load + OpWasmF32Store + OpWasmF64Store + OpWasmI64Const + OpWasmF32Const + OpWasmF64Const + OpWasmI64Eqz + OpWasmI64Eq + OpWasmI64Ne + OpWasmI64LtS + OpWasmI64LtU + OpWasmI64GtS + OpWasmI64GtU + OpWasmI64LeS + OpWasmI64LeU + OpWasmI64GeS + OpWasmI64GeU + OpWasmF32Eq + OpWasmF32Ne + OpWasmF32Lt + OpWasmF32Gt + OpWasmF32Le + OpWasmF32Ge + OpWasmF64Eq + OpWasmF64Ne + OpWasmF64Lt + OpWasmF64Gt + OpWasmF64Le + OpWasmF64Ge + OpWasmI64Add + OpWasmI64AddConst + OpWasmI64Sub + OpWasmI64Mul + OpWasmI64DivS + OpWasmI64DivU + OpWasmI64RemS + OpWasmI64RemU + OpWasmI64And + OpWasmI64Or + OpWasmI64Xor + OpWasmI64Shl + OpWasmI64ShrS + OpWasmI64ShrU + OpWasmF32Neg + OpWasmF32Add + OpWasmF32Sub + OpWasmF32Mul + OpWasmF32Div + OpWasmF64Neg + OpWasmF64Add + OpWasmF64Sub + OpWasmF64Mul + OpWasmF64Div + OpWasmI64TruncSatF64S + OpWasmI64TruncSatF64U + OpWasmI64TruncSatF32S + OpWasmI64TruncSatF32U + OpWasmF32ConvertI64S + OpWasmF32ConvertI64U + OpWasmF64ConvertI64S + OpWasmF64ConvertI64U + OpWasmF32DemoteF64 + OpWasmF64PromoteF32 + OpWasmI64Extend8S + OpWasmI64Extend16S + OpWasmI64Extend32S + OpWasmF32Sqrt + OpWasmF32Trunc + OpWasmF32Ceil + OpWasmF32Floor + OpWasmF32Nearest + OpWasmF32Abs + OpWasmF32Copysign + OpWasmF64Sqrt + OpWasmF64Trunc + OpWasmF64Ceil + OpWasmF64Floor + OpWasmF64Nearest + OpWasmF64Abs + OpWasmF64Copysign + OpWasmI64Ctz + OpWasmI64Clz + OpWasmI32Rotl + OpWasmI64Rotl + OpWasmI64Popcnt + + OpLast + OpAdd8 + OpAdd16 + OpAdd32 + OpAdd64 + OpAddPtr + OpAdd32F + OpAdd64F + OpSub8 + OpSub16 + OpSub32 + OpSub64 + OpSubPtr + OpSub32F + OpSub64F + OpMul8 + OpMul16 + OpMul32 + OpMul64 + OpMul32F + OpMul64F + OpDiv32F + OpDiv64F + OpHmul32 + OpHmul32u + OpHmul64 + OpHmul64u + OpMul32uhilo + OpMul64uhilo + OpMul32uover + OpMul64uover + OpAvg32u + OpAvg64u + OpDiv8 + OpDiv8u + OpDiv16 + OpDiv16u + OpDiv32 + OpDiv32u + OpDiv64 + OpDiv64u + OpDiv128u + OpMod8 + OpMod8u + OpMod16 + OpMod16u + OpMod32 + OpMod32u + OpMod64 + OpMod64u + OpAnd8 + OpAnd16 + OpAnd32 + OpAnd64 + OpOr8 + OpOr16 + OpOr32 + OpOr64 + OpXor8 + OpXor16 + OpXor32 + OpXor64 + OpLsh8x8 + OpLsh8x16 + OpLsh8x32 + OpLsh8x64 + OpLsh16x8 + OpLsh16x16 + OpLsh16x32 + OpLsh16x64 + OpLsh32x8 + OpLsh32x16 + OpLsh32x32 + OpLsh32x64 + OpLsh64x8 + OpLsh64x16 + OpLsh64x32 + OpLsh64x64 + OpRsh8x8 + OpRsh8x16 + OpRsh8x32 + OpRsh8x64 + OpRsh16x8 + OpRsh16x16 + OpRsh16x32 + OpRsh16x64 + OpRsh32x8 + OpRsh32x16 + OpRsh32x32 + OpRsh32x64 + OpRsh64x8 + OpRsh64x16 + OpRsh64x32 + OpRsh64x64 + OpRsh8Ux8 + OpRsh8Ux16 + OpRsh8Ux32 + OpRsh8Ux64 + OpRsh16Ux8 + OpRsh16Ux16 + OpRsh16Ux32 + OpRsh16Ux64 + OpRsh32Ux8 + OpRsh32Ux16 + OpRsh32Ux32 + OpRsh32Ux64 + OpRsh64Ux8 + OpRsh64Ux16 + OpRsh64Ux32 + OpRsh64Ux64 + OpEq8 + OpEq16 + OpEq32 + OpEq64 + OpEqPtr + OpEqInter + OpEqSlice + OpEq32F + OpEq64F + OpNeq8 + OpNeq16 + OpNeq32 + OpNeq64 + OpNeqPtr + OpNeqInter + OpNeqSlice + OpNeq32F + OpNeq64F + OpLess8 + OpLess8U + OpLess16 + OpLess16U + OpLess32 + OpLess32U + OpLess64 + OpLess64U + OpLess32F + OpLess64F + OpLeq8 + OpLeq8U + OpLeq16 + OpLeq16U + OpLeq32 + OpLeq32U + OpLeq64 + OpLeq64U + OpLeq32F + OpLeq64F + OpCondSelect + OpAndB + OpOrB + OpEqB + OpNeqB + OpNot + OpNeg8 + OpNeg16 + OpNeg32 + OpNeg64 + OpNeg32F + OpNeg64F + OpCom8 + OpCom16 + OpCom32 + OpCom64 + OpCtz8 + OpCtz16 + OpCtz32 + OpCtz64 + OpCtz64On32 + OpCtz8NonZero + OpCtz16NonZero + OpCtz32NonZero + OpCtz64NonZero + OpBitLen8 + OpBitLen16 + OpBitLen32 + OpBitLen64 + OpBswap16 + OpBswap32 + OpBswap64 + OpBitRev8 + OpBitRev16 + OpBitRev32 + OpBitRev64 + OpPopCount8 + OpPopCount16 + OpPopCount32 + OpPopCount64 + OpRotateLeft64 + OpRotateLeft32 + OpRotateLeft16 + OpRotateLeft8 + OpSqrt + OpSqrt32 + OpFloor + OpCeil + OpTrunc + OpRound + OpRoundToEven + OpAbs + OpCopysign + OpMin64 + OpMax64 + OpMin64u + OpMax64u + OpMin64F + OpMin32F + OpMax64F + OpMax32F + OpFMA + OpPhi + OpCopy + OpConvert + OpConstBool + OpConstString + OpConstNil + OpConst8 + OpConst16 + OpConst32 + OpConst64 + OpConst32F + OpConst64F + OpConstInterface + OpConstSlice + OpInitMem + OpArg + OpArgIntReg + OpArgFloatReg + OpAddr + OpLocalAddr + OpSP + OpSB + OpSPanchored + OpLoad + OpDereference + OpStore + OpLoadMasked8 + OpLoadMasked16 + OpLoadMasked32 + OpLoadMasked64 + OpStoreMasked8 + OpStoreMasked16 + OpStoreMasked32 + OpStoreMasked64 + OpMove + OpZero + OpStoreWB + OpMoveWB + OpZeroWB + OpWBend + OpWB + OpHasCPUFeature + OpPanicBounds + OpPanicExtend + OpClosureCall + OpStaticCall + OpInterCall + OpTailCall + OpClosureLECall + OpStaticLECall + OpInterLECall + OpTailLECall + OpSignExt8to16 + OpSignExt8to32 + OpSignExt8to64 + OpSignExt16to32 + OpSignExt16to64 + OpSignExt32to64 + OpZeroExt8to16 + OpZeroExt8to32 + OpZeroExt8to64 + OpZeroExt16to32 + OpZeroExt16to64 + OpZeroExt32to64 + OpTrunc16to8 + OpTrunc32to8 + OpTrunc32to16 + OpTrunc64to8 + OpTrunc64to16 + OpTrunc64to32 + OpCvt32to32F + OpCvt32to64F + OpCvt64to32F + OpCvt64to64F + OpCvt32Fto32 + OpCvt32Fto64 + OpCvt64Fto32 + OpCvt64Fto64 + OpCvt32Fto64F + OpCvt64Fto32F + OpCvtBoolToUint8 + OpRound32F + OpRound64F + OpIsNonNil + OpIsInBounds + OpIsSliceInBounds + OpNilCheck + OpGetG + OpGetClosurePtr + OpGetCallerPC + OpGetCallerSP + OpPtrIndex + OpOffPtr + OpSliceMake + OpSlicePtr + OpSliceLen + OpSliceCap + OpSlicePtrUnchecked + OpComplexMake + OpComplexReal + OpComplexImag + OpStringMake + OpStringPtr + OpStringLen + OpIMake + OpITab + OpIData + OpStructMake + OpStructSelect + OpArrayMake1 + OpArraySelect + OpStoreReg + OpLoadReg + OpFwdRef + OpUnknown + OpVarDef + OpVarLive + OpKeepAlive + OpInlMark + OpInt64Make + OpInt64Hi + OpInt64Lo + OpAdd32carry + OpAdd32withcarry + OpAdd32carrywithcarry + OpSub32carry + OpSub32withcarry + OpAdd64carry + OpSub64borrow + OpSignmask + OpZeromask + OpSlicemask + OpSpectreIndex + OpSpectreSliceIndex + OpCvt32Uto32F + OpCvt32Uto64F + OpCvt32Fto32U + OpCvt64Fto32U + OpCvt64Uto32F + OpCvt64Uto64F + OpCvt32Fto64U + OpCvt64Fto64U + OpSelect0 + OpSelect1 + OpMakeTuple + OpSelectN + OpSelectNAddr + OpMakeResult + OpAtomicLoad8 + OpAtomicLoad32 + OpAtomicLoad64 + OpAtomicLoadPtr + OpAtomicLoadAcq32 + OpAtomicLoadAcq64 + OpAtomicStore8 + OpAtomicStore32 + OpAtomicStore64 + OpAtomicStorePtrNoWB + OpAtomicStoreRel32 + OpAtomicStoreRel64 + OpAtomicExchange8 + OpAtomicExchange32 + OpAtomicExchange64 + OpAtomicAdd32 + OpAtomicAdd64 + OpAtomicCompareAndSwap32 + OpAtomicCompareAndSwap64 + OpAtomicCompareAndSwapRel32 + OpAtomicAnd8 + OpAtomicOr8 + OpAtomicAnd32 + OpAtomicOr32 + OpAtomicAnd64value + OpAtomicAnd32value + OpAtomicAnd8value + OpAtomicOr64value + OpAtomicOr32value + OpAtomicOr8value + OpAtomicStore8Variant + OpAtomicStore32Variant + OpAtomicStore64Variant + OpAtomicAdd32Variant + OpAtomicAdd64Variant + OpAtomicExchange8Variant + OpAtomicExchange32Variant + OpAtomicExchange64Variant + OpAtomicCompareAndSwap32Variant + OpAtomicCompareAndSwap64Variant + OpAtomicAnd64valueVariant + OpAtomicOr64valueVariant + OpAtomicAnd32valueVariant + OpAtomicOr32valueVariant + OpAtomicAnd8valueVariant + OpAtomicOr8valueVariant + OpPubBarrier + OpClobber + OpClobberReg + OpPrefetchCache + OpPrefetchCacheStreamed + OpMemEq + OpEmpty + OpZeroSIMD + OpCvt16toMask8x16 + OpCvt32toMask8x32 + OpCvt64toMask8x64 + OpCvt8toMask16x8 + OpCvt16toMask16x16 + OpCvt32toMask16x32 + OpCvt8toMask32x4 + OpCvt8toMask32x8 + OpCvt16toMask32x16 + OpCvt8toMask64x2 + OpCvt8toMask64x4 + OpCvt8toMask64x8 + OpCvtMask8x16to16 + OpCvtMask8x32to32 + OpCvtMask8x64to64 + OpCvtMask16x8to8 + OpCvtMask16x16to16 + OpCvtMask16x32to32 + OpCvtMask32x4to8 + OpCvtMask32x8to8 + OpCvtMask32x16to16 + OpCvtMask64x2to8 + OpCvtMask64x4to8 + OpCvtMask64x8to8 + OpIsZeroVec + OpIsNaNFloat32x4 + OpIsNaNFloat32x8 + OpIsNaNFloat32x16 + OpIsNaNFloat64x2 + OpIsNaNFloat64x4 + OpIsNaNFloat64x8 + OpAESDecryptLastRoundUint8x16 + OpAESDecryptLastRoundUint8x32 + OpAESDecryptLastRoundUint8x64 + OpAESDecryptOneRoundUint8x16 + OpAESDecryptOneRoundUint8x32 + OpAESDecryptOneRoundUint8x64 + OpAESEncryptLastRoundUint8x16 + OpAESEncryptLastRoundUint8x32 + OpAESEncryptLastRoundUint8x64 + OpAESEncryptOneRoundUint8x16 + OpAESEncryptOneRoundUint8x32 + OpAESEncryptOneRoundUint8x64 + OpAESInvMixColumnsUint32x4 + OpAbsInt8x16 + OpAbsInt8x32 + OpAbsInt8x64 + OpAbsInt16x8 + OpAbsInt16x16 + OpAbsInt16x32 + OpAbsInt32x4 + OpAbsInt32x8 + OpAbsInt32x16 + OpAbsInt64x2 + OpAbsInt64x4 + OpAbsInt64x8 + OpAddFloat32x4 + OpAddFloat32x8 + OpAddFloat32x16 + OpAddFloat64x2 + OpAddFloat64x4 + OpAddFloat64x8 + OpAddInt8x16 + OpAddInt8x32 + OpAddInt8x64 + OpAddInt16x8 + OpAddInt16x16 + OpAddInt16x32 + OpAddInt32x4 + OpAddInt32x8 + OpAddInt32x16 + OpAddInt64x2 + OpAddInt64x4 + OpAddInt64x8 + OpAddPairsFloat32x4 + OpAddPairsFloat64x2 + OpAddPairsGroupedFloat32x8 + OpAddPairsGroupedFloat64x4 + OpAddPairsGroupedInt16x16 + OpAddPairsGroupedInt32x8 + OpAddPairsGroupedUint16x16 + OpAddPairsGroupedUint32x8 + OpAddPairsInt16x8 + OpAddPairsInt32x4 + OpAddPairsSaturatedGroupedInt16x16 + OpAddPairsSaturatedInt16x8 + OpAddPairsUint16x8 + OpAddPairsUint32x4 + OpAddSaturatedInt8x16 + OpAddSaturatedInt8x32 + OpAddSaturatedInt8x64 + OpAddSaturatedInt16x8 + OpAddSaturatedInt16x16 + OpAddSaturatedInt16x32 + OpAddSaturatedUint8x16 + OpAddSaturatedUint8x32 + OpAddSaturatedUint8x64 + OpAddSaturatedUint16x8 + OpAddSaturatedUint16x16 + OpAddSaturatedUint16x32 + OpAddSubFloat32x4 + OpAddSubFloat32x8 + OpAddSubFloat64x2 + OpAddSubFloat64x4 + OpAddUint8x16 + OpAddUint8x32 + OpAddUint8x64 + OpAddUint16x8 + OpAddUint16x16 + OpAddUint16x32 + OpAddUint32x4 + OpAddUint32x8 + OpAddUint32x16 + OpAddUint64x2 + OpAddUint64x4 + OpAddUint64x8 + OpAndInt8x16 + OpAndInt8x32 + OpAndInt8x64 + OpAndInt16x8 + OpAndInt16x16 + OpAndInt16x32 + OpAndInt32x4 + OpAndInt32x8 + OpAndInt32x16 + OpAndInt64x2 + OpAndInt64x4 + OpAndInt64x8 + OpAndNotInt8x16 + OpAndNotInt8x32 + OpAndNotInt8x64 + OpAndNotInt16x8 + OpAndNotInt16x16 + OpAndNotInt16x32 + OpAndNotInt32x4 + OpAndNotInt32x8 + OpAndNotInt32x16 + OpAndNotInt64x2 + OpAndNotInt64x4 + OpAndNotInt64x8 + OpAndNotUint8x16 + OpAndNotUint8x32 + OpAndNotUint8x64 + OpAndNotUint16x8 + OpAndNotUint16x16 + OpAndNotUint16x32 + OpAndNotUint32x4 + OpAndNotUint32x8 + OpAndNotUint32x16 + OpAndNotUint64x2 + OpAndNotUint64x4 + OpAndNotUint64x8 + OpAndUint8x16 + OpAndUint8x32 + OpAndUint8x64 + OpAndUint16x8 + OpAndUint16x16 + OpAndUint16x32 + OpAndUint32x4 + OpAndUint32x8 + OpAndUint32x16 + OpAndUint64x2 + OpAndUint64x4 + OpAndUint64x8 + OpAverageUint8x16 + OpAverageUint8x32 + OpAverageUint8x64 + OpAverageUint16x8 + OpAverageUint16x16 + OpAverageUint16x32 + OpBroadcast1To2Float64x2 + OpBroadcast1To2Int64x2 + OpBroadcast1To2Uint64x2 + OpBroadcast1To4Float32x4 + OpBroadcast1To4Float64x2 + OpBroadcast1To4Int32x4 + OpBroadcast1To4Int64x2 + OpBroadcast1To4Uint32x4 + OpBroadcast1To4Uint64x2 + OpBroadcast1To8Float32x4 + OpBroadcast1To8Float64x2 + OpBroadcast1To8Int16x8 + OpBroadcast1To8Int32x4 + OpBroadcast1To8Int64x2 + OpBroadcast1To8Uint16x8 + OpBroadcast1To8Uint32x4 + OpBroadcast1To8Uint64x2 + OpBroadcast1To16Float32x4 + OpBroadcast1To16Int8x16 + OpBroadcast1To16Int16x8 + OpBroadcast1To16Int32x4 + OpBroadcast1To16Uint8x16 + OpBroadcast1To16Uint16x8 + OpBroadcast1To16Uint32x4 + OpBroadcast1To32Int8x16 + OpBroadcast1To32Int16x8 + OpBroadcast1To32Uint8x16 + OpBroadcast1To32Uint16x8 + OpBroadcast1To64Int8x16 + OpBroadcast1To64Uint8x16 + OpCeilFloat32x4 + OpCeilFloat32x8 + OpCeilFloat64x2 + OpCeilFloat64x4 + OpCompressFloat32x4 + OpCompressFloat32x8 + OpCompressFloat32x16 + OpCompressFloat64x2 + OpCompressFloat64x4 + OpCompressFloat64x8 + OpCompressInt8x16 + OpCompressInt8x32 + OpCompressInt8x64 + OpCompressInt16x8 + OpCompressInt16x16 + OpCompressInt16x32 + OpCompressInt32x4 + OpCompressInt32x8 + OpCompressInt32x16 + OpCompressInt64x2 + OpCompressInt64x4 + OpCompressInt64x8 + OpCompressUint8x16 + OpCompressUint8x32 + OpCompressUint8x64 + OpCompressUint16x8 + OpCompressUint16x16 + OpCompressUint16x32 + OpCompressUint32x4 + OpCompressUint32x8 + OpCompressUint32x16 + OpCompressUint64x2 + OpCompressUint64x4 + OpCompressUint64x8 + OpConcatPermuteFloat32x4 + OpConcatPermuteFloat32x8 + OpConcatPermuteFloat32x16 + OpConcatPermuteFloat64x2 + OpConcatPermuteFloat64x4 + OpConcatPermuteFloat64x8 + OpConcatPermuteInt8x16 + OpConcatPermuteInt8x32 + OpConcatPermuteInt8x64 + OpConcatPermuteInt16x8 + OpConcatPermuteInt16x16 + OpConcatPermuteInt16x32 + OpConcatPermuteInt32x4 + OpConcatPermuteInt32x8 + OpConcatPermuteInt32x16 + OpConcatPermuteInt64x2 + OpConcatPermuteInt64x4 + OpConcatPermuteInt64x8 + OpConcatPermuteUint8x16 + OpConcatPermuteUint8x32 + OpConcatPermuteUint8x64 + OpConcatPermuteUint16x8 + OpConcatPermuteUint16x16 + OpConcatPermuteUint16x32 + OpConcatPermuteUint32x4 + OpConcatPermuteUint32x8 + OpConcatPermuteUint32x16 + OpConcatPermuteUint64x2 + OpConcatPermuteUint64x4 + OpConcatPermuteUint64x8 + OpConvertToFloat32Float64x2 + OpConvertToFloat32Float64x4 + OpConvertToFloat32Float64x8 + OpConvertToFloat32Int32x4 + OpConvertToFloat32Int32x8 + OpConvertToFloat32Int32x16 + OpConvertToFloat32Int64x2 + OpConvertToFloat32Int64x4 + OpConvertToFloat32Int64x8 + OpConvertToFloat32Uint32x4 + OpConvertToFloat32Uint32x8 + OpConvertToFloat32Uint32x16 + OpConvertToFloat32Uint64x2 + OpConvertToFloat32Uint64x4 + OpConvertToFloat32Uint64x8 + OpConvertToFloat64Float32x4 + OpConvertToFloat64Float32x8 + OpConvertToFloat64Int32x4 + OpConvertToFloat64Int32x8 + OpConvertToFloat64Int64x2 + OpConvertToFloat64Int64x4 + OpConvertToFloat64Int64x8 + OpConvertToFloat64Uint32x4 + OpConvertToFloat64Uint32x8 + OpConvertToFloat64Uint64x2 + OpConvertToFloat64Uint64x4 + OpConvertToFloat64Uint64x8 + OpConvertToInt32Float32x4 + OpConvertToInt32Float32x8 + OpConvertToInt32Float32x16 + OpConvertToInt32Float64x2 + OpConvertToInt32Float64x4 + OpConvertToInt32Float64x8 + OpConvertToInt64Float32x4 + OpConvertToInt64Float32x8 + OpConvertToInt64Float64x2 + OpConvertToInt64Float64x4 + OpConvertToInt64Float64x8 + OpConvertToUint32Float32x4 + OpConvertToUint32Float32x8 + OpConvertToUint32Float32x16 + OpConvertToUint32Float64x2 + OpConvertToUint32Float64x4 + OpConvertToUint32Float64x8 + OpConvertToUint64Float32x4 + OpConvertToUint64Float32x8 + OpConvertToUint64Float64x2 + OpConvertToUint64Float64x4 + OpConvertToUint64Float64x8 + OpCopySignInt8x16 + OpCopySignInt8x32 + OpCopySignInt16x8 + OpCopySignInt16x16 + OpCopySignInt32x4 + OpCopySignInt32x8 + OpDivFloat32x4 + OpDivFloat32x8 + OpDivFloat32x16 + OpDivFloat64x2 + OpDivFloat64x4 + OpDivFloat64x8 + OpDotProductPairsInt16x8 + OpDotProductPairsInt16x16 + OpDotProductPairsInt16x32 + OpDotProductPairsSaturatedUint8x16 + OpDotProductPairsSaturatedUint8x32 + OpDotProductPairsSaturatedUint8x64 + OpEqualFloat32x4 + OpEqualFloat32x8 + OpEqualFloat32x16 + OpEqualFloat64x2 + OpEqualFloat64x4 + OpEqualFloat64x8 + OpEqualInt8x16 + OpEqualInt8x32 + OpEqualInt8x64 + OpEqualInt16x8 + OpEqualInt16x16 + OpEqualInt16x32 + OpEqualInt32x4 + OpEqualInt32x8 + OpEqualInt32x16 + OpEqualInt64x2 + OpEqualInt64x4 + OpEqualInt64x8 + OpEqualUint8x16 + OpEqualUint8x32 + OpEqualUint8x64 + OpEqualUint16x8 + OpEqualUint16x16 + OpEqualUint16x32 + OpEqualUint32x4 + OpEqualUint32x8 + OpEqualUint32x16 + OpEqualUint64x2 + OpEqualUint64x4 + OpEqualUint64x8 + OpExpandFloat32x4 + OpExpandFloat32x8 + OpExpandFloat32x16 + OpExpandFloat64x2 + OpExpandFloat64x4 + OpExpandFloat64x8 + OpExpandInt8x16 + OpExpandInt8x32 + OpExpandInt8x64 + OpExpandInt16x8 + OpExpandInt16x16 + OpExpandInt16x32 + OpExpandInt32x4 + OpExpandInt32x8 + OpExpandInt32x16 + OpExpandInt64x2 + OpExpandInt64x4 + OpExpandInt64x8 + OpExpandUint8x16 + OpExpandUint8x32 + OpExpandUint8x64 + OpExpandUint16x8 + OpExpandUint16x16 + OpExpandUint16x32 + OpExpandUint32x4 + OpExpandUint32x8 + OpExpandUint32x16 + OpExpandUint64x2 + OpExpandUint64x4 + OpExpandUint64x8 + OpExtendLo2ToInt64Int8x16 + OpExtendLo2ToInt64Int16x8 + OpExtendLo2ToInt64Int32x4 + OpExtendLo2ToUint64Uint8x16 + OpExtendLo2ToUint64Uint16x8 + OpExtendLo2ToUint64Uint32x4 + OpExtendLo4ToInt32Int8x16 + OpExtendLo4ToInt32Int16x8 + OpExtendLo4ToInt64Int8x16 + OpExtendLo4ToInt64Int16x8 + OpExtendLo4ToUint32Uint8x16 + OpExtendLo4ToUint32Uint16x8 + OpExtendLo4ToUint64Uint8x16 + OpExtendLo4ToUint64Uint16x8 + OpExtendLo8ToInt16Int8x16 + OpExtendLo8ToInt32Int8x16 + OpExtendLo8ToInt64Int8x16 + OpExtendLo8ToUint16Uint8x16 + OpExtendLo8ToUint32Uint8x16 + OpExtendLo8ToUint64Uint8x16 + OpExtendToInt16Int8x16 + OpExtendToInt16Int8x32 + OpExtendToInt32Int8x16 + OpExtendToInt32Int16x8 + OpExtendToInt32Int16x16 + OpExtendToInt64Int16x8 + OpExtendToInt64Int32x4 + OpExtendToInt64Int32x8 + OpExtendToUint16Uint8x16 + OpExtendToUint16Uint8x32 + OpExtendToUint32Uint8x16 + OpExtendToUint32Uint16x8 + OpExtendToUint32Uint16x16 + OpExtendToUint64Uint16x8 + OpExtendToUint64Uint32x4 + OpExtendToUint64Uint32x8 + OpFloorFloat32x4 + OpFloorFloat32x8 + OpFloorFloat64x2 + OpFloorFloat64x4 + OpGaloisFieldMulUint8x16 + OpGaloisFieldMulUint8x32 + OpGaloisFieldMulUint8x64 + OpGetHiFloat32x8 + OpGetHiFloat32x16 + OpGetHiFloat64x4 + OpGetHiFloat64x8 + OpGetHiInt8x32 + OpGetHiInt8x64 + OpGetHiInt16x16 + OpGetHiInt16x32 + OpGetHiInt32x8 + OpGetHiInt32x16 + OpGetHiInt64x4 + OpGetHiInt64x8 + OpGetHiUint8x32 + OpGetHiUint8x64 + OpGetHiUint16x16 + OpGetHiUint16x32 + OpGetHiUint32x8 + OpGetHiUint32x16 + OpGetHiUint64x4 + OpGetHiUint64x8 + OpGetLoFloat32x8 + OpGetLoFloat32x16 + OpGetLoFloat64x4 + OpGetLoFloat64x8 + OpGetLoInt8x32 + OpGetLoInt8x64 + OpGetLoInt16x16 + OpGetLoInt16x32 + OpGetLoInt32x8 + OpGetLoInt32x16 + OpGetLoInt64x4 + OpGetLoInt64x8 + OpGetLoUint8x32 + OpGetLoUint8x64 + OpGetLoUint16x16 + OpGetLoUint16x32 + OpGetLoUint32x8 + OpGetLoUint32x16 + OpGetLoUint64x4 + OpGetLoUint64x8 + OpGreaterEqualFloat32x4 + OpGreaterEqualFloat32x8 + OpGreaterEqualFloat32x16 + OpGreaterEqualFloat64x2 + OpGreaterEqualFloat64x4 + OpGreaterEqualFloat64x8 + OpGreaterEqualInt8x64 + OpGreaterEqualInt16x32 + OpGreaterEqualInt32x16 + OpGreaterEqualInt64x8 + OpGreaterEqualUint8x64 + OpGreaterEqualUint16x32 + OpGreaterEqualUint32x16 + OpGreaterEqualUint64x8 + OpGreaterFloat32x4 + OpGreaterFloat32x8 + OpGreaterFloat32x16 + OpGreaterFloat64x2 + OpGreaterFloat64x4 + OpGreaterFloat64x8 + OpGreaterInt8x16 + OpGreaterInt8x32 + OpGreaterInt8x64 + OpGreaterInt16x8 + OpGreaterInt16x16 + OpGreaterInt16x32 + OpGreaterInt32x4 + OpGreaterInt32x8 + OpGreaterInt32x16 + OpGreaterInt64x2 + OpGreaterInt64x4 + OpGreaterInt64x8 + OpGreaterUint8x64 + OpGreaterUint16x32 + OpGreaterUint32x16 + OpGreaterUint64x8 + OpInterleaveHiGroupedInt16x16 + OpInterleaveHiGroupedInt16x32 + OpInterleaveHiGroupedInt32x8 + OpInterleaveHiGroupedInt32x16 + OpInterleaveHiGroupedInt64x4 + OpInterleaveHiGroupedInt64x8 + OpInterleaveHiGroupedUint16x16 + OpInterleaveHiGroupedUint16x32 + OpInterleaveHiGroupedUint32x8 + OpInterleaveHiGroupedUint32x16 + OpInterleaveHiGroupedUint64x4 + OpInterleaveHiGroupedUint64x8 + OpInterleaveHiInt16x8 + OpInterleaveHiInt32x4 + OpInterleaveHiInt64x2 + OpInterleaveHiUint16x8 + OpInterleaveHiUint32x4 + OpInterleaveHiUint64x2 + OpInterleaveLoGroupedInt16x16 + OpInterleaveLoGroupedInt16x32 + OpInterleaveLoGroupedInt32x8 + OpInterleaveLoGroupedInt32x16 + OpInterleaveLoGroupedInt64x4 + OpInterleaveLoGroupedInt64x8 + OpInterleaveLoGroupedUint16x16 + OpInterleaveLoGroupedUint16x32 + OpInterleaveLoGroupedUint32x8 + OpInterleaveLoGroupedUint32x16 + OpInterleaveLoGroupedUint64x4 + OpInterleaveLoGroupedUint64x8 + OpInterleaveLoInt16x8 + OpInterleaveLoInt32x4 + OpInterleaveLoInt64x2 + OpInterleaveLoUint16x8 + OpInterleaveLoUint32x4 + OpInterleaveLoUint64x2 + OpLeadingZerosInt32x4 + OpLeadingZerosInt32x8 + OpLeadingZerosInt32x16 + OpLeadingZerosInt64x2 + OpLeadingZerosInt64x4 + OpLeadingZerosInt64x8 + OpLeadingZerosUint32x4 + OpLeadingZerosUint32x8 + OpLeadingZerosUint32x16 + OpLeadingZerosUint64x2 + OpLeadingZerosUint64x4 + OpLeadingZerosUint64x8 + OpLessEqualFloat32x4 + OpLessEqualFloat32x8 + OpLessEqualFloat32x16 + OpLessEqualFloat64x2 + OpLessEqualFloat64x4 + OpLessEqualFloat64x8 + OpLessEqualInt8x64 + OpLessEqualInt16x32 + OpLessEqualInt32x16 + OpLessEqualInt64x8 + OpLessEqualUint8x64 + OpLessEqualUint16x32 + OpLessEqualUint32x16 + OpLessEqualUint64x8 + OpLessFloat32x4 + OpLessFloat32x8 + OpLessFloat32x16 + OpLessFloat64x2 + OpLessFloat64x4 + OpLessFloat64x8 + OpLessInt8x64 + OpLessInt16x32 + OpLessInt32x16 + OpLessInt64x8 + OpLessUint8x64 + OpLessUint16x32 + OpLessUint32x16 + OpLessUint64x8 + OpMaxFloat32x4 + OpMaxFloat32x8 + OpMaxFloat32x16 + OpMaxFloat64x2 + OpMaxFloat64x4 + OpMaxFloat64x8 + OpMaxInt8x16 + OpMaxInt8x32 + OpMaxInt8x64 + OpMaxInt16x8 + OpMaxInt16x16 + OpMaxInt16x32 + OpMaxInt32x4 + OpMaxInt32x8 + OpMaxInt32x16 + OpMaxInt64x2 + OpMaxInt64x4 + OpMaxInt64x8 + OpMaxUint8x16 + OpMaxUint8x32 + OpMaxUint8x64 + OpMaxUint16x8 + OpMaxUint16x16 + OpMaxUint16x32 + OpMaxUint32x4 + OpMaxUint32x8 + OpMaxUint32x16 + OpMaxUint64x2 + OpMaxUint64x4 + OpMaxUint64x8 + OpMinFloat32x4 + OpMinFloat32x8 + OpMinFloat32x16 + OpMinFloat64x2 + OpMinFloat64x4 + OpMinFloat64x8 + OpMinInt8x16 + OpMinInt8x32 + OpMinInt8x64 + OpMinInt16x8 + OpMinInt16x16 + OpMinInt16x32 + OpMinInt32x4 + OpMinInt32x8 + OpMinInt32x16 + OpMinInt64x2 + OpMinInt64x4 + OpMinInt64x8 + OpMinUint8x16 + OpMinUint8x32 + OpMinUint8x64 + OpMinUint16x8 + OpMinUint16x16 + OpMinUint16x32 + OpMinUint32x4 + OpMinUint32x8 + OpMinUint32x16 + OpMinUint64x2 + OpMinUint64x4 + OpMinUint64x8 + OpMulAddFloat32x4 + OpMulAddFloat32x8 + OpMulAddFloat32x16 + OpMulAddFloat64x2 + OpMulAddFloat64x4 + OpMulAddFloat64x8 + OpMulAddSubFloat32x4 + OpMulAddSubFloat32x8 + OpMulAddSubFloat32x16 + OpMulAddSubFloat64x2 + OpMulAddSubFloat64x4 + OpMulAddSubFloat64x8 + OpMulEvenWidenInt32x4 + OpMulEvenWidenInt32x8 + OpMulEvenWidenUint32x4 + OpMulEvenWidenUint32x8 + OpMulFloat32x4 + OpMulFloat32x8 + OpMulFloat32x16 + OpMulFloat64x2 + OpMulFloat64x4 + OpMulFloat64x8 + OpMulHighInt16x8 + OpMulHighInt16x16 + OpMulHighInt16x32 + OpMulHighUint16x8 + OpMulHighUint16x16 + OpMulHighUint16x32 + OpMulInt16x8 + OpMulInt16x16 + OpMulInt16x32 + OpMulInt32x4 + OpMulInt32x8 + OpMulInt32x16 + OpMulInt64x2 + OpMulInt64x4 + OpMulInt64x8 + OpMulSubAddFloat32x4 + OpMulSubAddFloat32x8 + OpMulSubAddFloat32x16 + OpMulSubAddFloat64x2 + OpMulSubAddFloat64x4 + OpMulSubAddFloat64x8 + OpMulUint16x8 + OpMulUint16x16 + OpMulUint16x32 + OpMulUint32x4 + OpMulUint32x8 + OpMulUint32x16 + OpMulUint64x2 + OpMulUint64x4 + OpMulUint64x8 + OpNotEqualFloat32x4 + OpNotEqualFloat32x8 + OpNotEqualFloat32x16 + OpNotEqualFloat64x2 + OpNotEqualFloat64x4 + OpNotEqualFloat64x8 + OpNotEqualInt8x64 + OpNotEqualInt16x32 + OpNotEqualInt32x16 + OpNotEqualInt64x8 + OpNotEqualUint8x64 + OpNotEqualUint16x32 + OpNotEqualUint32x16 + OpNotEqualUint64x8 + OpOnesCountInt8x16 + OpOnesCountInt8x32 + OpOnesCountInt8x64 + OpOnesCountInt16x8 + OpOnesCountInt16x16 + OpOnesCountInt16x32 + OpOnesCountInt32x4 + OpOnesCountInt32x8 + OpOnesCountInt32x16 + OpOnesCountInt64x2 + OpOnesCountInt64x4 + OpOnesCountInt64x8 + OpOnesCountUint8x16 + OpOnesCountUint8x32 + OpOnesCountUint8x64 + OpOnesCountUint16x8 + OpOnesCountUint16x16 + OpOnesCountUint16x32 + OpOnesCountUint32x4 + OpOnesCountUint32x8 + OpOnesCountUint32x16 + OpOnesCountUint64x2 + OpOnesCountUint64x4 + OpOnesCountUint64x8 + OpOrInt8x16 + OpOrInt8x32 + OpOrInt8x64 + OpOrInt16x8 + OpOrInt16x16 + OpOrInt16x32 + OpOrInt32x4 + OpOrInt32x8 + OpOrInt32x16 + OpOrInt64x2 + OpOrInt64x4 + OpOrInt64x8 + OpOrUint8x16 + OpOrUint8x32 + OpOrUint8x64 + OpOrUint16x8 + OpOrUint16x16 + OpOrUint16x32 + OpOrUint32x4 + OpOrUint32x8 + OpOrUint32x16 + OpOrUint64x2 + OpOrUint64x4 + OpOrUint64x8 + OpPermuteFloat32x8 + OpPermuteFloat32x16 + OpPermuteFloat64x4 + OpPermuteFloat64x8 + OpPermuteInt8x16 + OpPermuteInt8x32 + OpPermuteInt8x64 + OpPermuteInt16x8 + OpPermuteInt16x16 + OpPermuteInt16x32 + OpPermuteInt32x8 + OpPermuteInt32x16 + OpPermuteInt64x4 + OpPermuteInt64x8 + OpPermuteOrZeroGroupedInt8x32 + OpPermuteOrZeroGroupedInt8x64 + OpPermuteOrZeroGroupedUint8x32 + OpPermuteOrZeroGroupedUint8x64 + OpPermuteOrZeroInt8x16 + OpPermuteOrZeroUint8x16 + OpPermuteUint8x16 + OpPermuteUint8x32 + OpPermuteUint8x64 + OpPermuteUint16x8 + OpPermuteUint16x16 + OpPermuteUint16x32 + OpPermuteUint32x8 + OpPermuteUint32x16 + OpPermuteUint64x4 + OpPermuteUint64x8 + OpReciprocalFloat32x4 + OpReciprocalFloat32x8 + OpReciprocalFloat32x16 + OpReciprocalFloat64x2 + OpReciprocalFloat64x4 + OpReciprocalFloat64x8 + OpReciprocalSqrtFloat32x4 + OpReciprocalSqrtFloat32x8 + OpReciprocalSqrtFloat32x16 + OpReciprocalSqrtFloat64x2 + OpReciprocalSqrtFloat64x4 + OpReciprocalSqrtFloat64x8 + OpRotateLeftInt32x4 + OpRotateLeftInt32x8 + OpRotateLeftInt32x16 + OpRotateLeftInt64x2 + OpRotateLeftInt64x4 + OpRotateLeftInt64x8 + OpRotateLeftUint32x4 + OpRotateLeftUint32x8 + OpRotateLeftUint32x16 + OpRotateLeftUint64x2 + OpRotateLeftUint64x4 + OpRotateLeftUint64x8 + OpRotateRightInt32x4 + OpRotateRightInt32x8 + OpRotateRightInt32x16 + OpRotateRightInt64x2 + OpRotateRightInt64x4 + OpRotateRightInt64x8 + OpRotateRightUint32x4 + OpRotateRightUint32x8 + OpRotateRightUint32x16 + OpRotateRightUint64x2 + OpRotateRightUint64x4 + OpRotateRightUint64x8 + OpRoundToEvenFloat32x4 + OpRoundToEvenFloat32x8 + OpRoundToEvenFloat64x2 + OpRoundToEvenFloat64x4 + OpSHA1Message1Uint32x4 + OpSHA1Message2Uint32x4 + OpSHA1NextEUint32x4 + OpSHA256Message1Uint32x4 + OpSHA256Message2Uint32x4 + OpSHA256TwoRoundsUint32x4 + OpSaturateToInt8Int16x8 + OpSaturateToInt8Int16x16 + OpSaturateToInt8Int16x32 + OpSaturateToInt8Int32x4 + OpSaturateToInt8Int32x8 + OpSaturateToInt8Int32x16 + OpSaturateToInt8Int64x2 + OpSaturateToInt8Int64x4 + OpSaturateToInt8Int64x8 + OpSaturateToInt16ConcatGroupedInt32x8 + OpSaturateToInt16ConcatGroupedInt32x16 + OpSaturateToInt16ConcatInt32x4 + OpSaturateToInt16Int32x4 + OpSaturateToInt16Int32x8 + OpSaturateToInt16Int32x16 + OpSaturateToInt16Int64x2 + OpSaturateToInt16Int64x4 + OpSaturateToInt16Int64x8 + OpSaturateToInt32Int64x2 + OpSaturateToInt32Int64x4 + OpSaturateToInt32Int64x8 + OpSaturateToUint8Uint16x8 + OpSaturateToUint8Uint16x16 + OpSaturateToUint8Uint16x32 + OpSaturateToUint8Uint32x4 + OpSaturateToUint8Uint32x8 + OpSaturateToUint8Uint32x16 + OpSaturateToUint8Uint64x2 + OpSaturateToUint8Uint64x4 + OpSaturateToUint8Uint64x8 + OpSaturateToUint16ConcatGroupedInt32x8 + OpSaturateToUint16ConcatGroupedInt32x16 + OpSaturateToUint16ConcatInt32x4 + OpSaturateToUint16Uint32x4 + OpSaturateToUint16Uint32x8 + OpSaturateToUint16Uint32x16 + OpSaturateToUint16Uint64x2 + OpSaturateToUint16Uint64x4 + OpSaturateToUint16Uint64x8 + OpSaturateToUint32Uint64x2 + OpSaturateToUint32Uint64x4 + OpSaturateToUint32Uint64x8 + OpScaleFloat32x4 + OpScaleFloat32x8 + OpScaleFloat32x16 + OpScaleFloat64x2 + OpScaleFloat64x4 + OpScaleFloat64x8 + OpSetHiFloat32x8 + OpSetHiFloat32x16 + OpSetHiFloat64x4 + OpSetHiFloat64x8 + OpSetHiInt8x32 + OpSetHiInt8x64 + OpSetHiInt16x16 + OpSetHiInt16x32 + OpSetHiInt32x8 + OpSetHiInt32x16 + OpSetHiInt64x4 + OpSetHiInt64x8 + OpSetHiUint8x32 + OpSetHiUint8x64 + OpSetHiUint16x16 + OpSetHiUint16x32 + OpSetHiUint32x8 + OpSetHiUint32x16 + OpSetHiUint64x4 + OpSetHiUint64x8 + OpSetLoFloat32x8 + OpSetLoFloat32x16 + OpSetLoFloat64x4 + OpSetLoFloat64x8 + OpSetLoInt8x32 + OpSetLoInt8x64 + OpSetLoInt16x16 + OpSetLoInt16x32 + OpSetLoInt32x8 + OpSetLoInt32x16 + OpSetLoInt64x4 + OpSetLoInt64x8 + OpSetLoUint8x32 + OpSetLoUint8x64 + OpSetLoUint16x16 + OpSetLoUint16x32 + OpSetLoUint32x8 + OpSetLoUint32x16 + OpSetLoUint64x4 + OpSetLoUint64x8 + OpShiftAllLeftInt16x8 + OpShiftAllLeftInt16x16 + OpShiftAllLeftInt16x32 + OpShiftAllLeftInt32x4 + OpShiftAllLeftInt32x8 + OpShiftAllLeftInt32x16 + OpShiftAllLeftInt64x2 + OpShiftAllLeftInt64x4 + OpShiftAllLeftInt64x8 + OpShiftAllLeftUint16x8 + OpShiftAllLeftUint16x16 + OpShiftAllLeftUint16x32 + OpShiftAllLeftUint32x4 + OpShiftAllLeftUint32x8 + OpShiftAllLeftUint32x16 + OpShiftAllLeftUint64x2 + OpShiftAllLeftUint64x4 + OpShiftAllLeftUint64x8 + OpShiftAllRightInt16x8 + OpShiftAllRightInt16x16 + OpShiftAllRightInt16x32 + OpShiftAllRightInt32x4 + OpShiftAllRightInt32x8 + OpShiftAllRightInt32x16 + OpShiftAllRightInt64x2 + OpShiftAllRightInt64x4 + OpShiftAllRightInt64x8 + OpShiftAllRightUint16x8 + OpShiftAllRightUint16x16 + OpShiftAllRightUint16x32 + OpShiftAllRightUint32x4 + OpShiftAllRightUint32x8 + OpShiftAllRightUint32x16 + OpShiftAllRightUint64x2 + OpShiftAllRightUint64x4 + OpShiftAllRightUint64x8 + OpShiftLeftConcatInt16x8 + OpShiftLeftConcatInt16x16 + OpShiftLeftConcatInt16x32 + OpShiftLeftConcatInt32x4 + OpShiftLeftConcatInt32x8 + OpShiftLeftConcatInt32x16 + OpShiftLeftConcatInt64x2 + OpShiftLeftConcatInt64x4 + OpShiftLeftConcatInt64x8 + OpShiftLeftConcatUint16x8 + OpShiftLeftConcatUint16x16 + OpShiftLeftConcatUint16x32 + OpShiftLeftConcatUint32x4 + OpShiftLeftConcatUint32x8 + OpShiftLeftConcatUint32x16 + OpShiftLeftConcatUint64x2 + OpShiftLeftConcatUint64x4 + OpShiftLeftConcatUint64x8 + OpShiftLeftInt16x8 + OpShiftLeftInt16x16 + OpShiftLeftInt16x32 + OpShiftLeftInt32x4 + OpShiftLeftInt32x8 + OpShiftLeftInt32x16 + OpShiftLeftInt64x2 + OpShiftLeftInt64x4 + OpShiftLeftInt64x8 + OpShiftLeftUint16x8 + OpShiftLeftUint16x16 + OpShiftLeftUint16x32 + OpShiftLeftUint32x4 + OpShiftLeftUint32x8 + OpShiftLeftUint32x16 + OpShiftLeftUint64x2 + OpShiftLeftUint64x4 + OpShiftLeftUint64x8 + OpShiftRightConcatInt16x8 + OpShiftRightConcatInt16x16 + OpShiftRightConcatInt16x32 + OpShiftRightConcatInt32x4 + OpShiftRightConcatInt32x8 + OpShiftRightConcatInt32x16 + OpShiftRightConcatInt64x2 + OpShiftRightConcatInt64x4 + OpShiftRightConcatInt64x8 + OpShiftRightConcatUint16x8 + OpShiftRightConcatUint16x16 + OpShiftRightConcatUint16x32 + OpShiftRightConcatUint32x4 + OpShiftRightConcatUint32x8 + OpShiftRightConcatUint32x16 + OpShiftRightConcatUint64x2 + OpShiftRightConcatUint64x4 + OpShiftRightConcatUint64x8 + OpShiftRightInt16x8 + OpShiftRightInt16x16 + OpShiftRightInt16x32 + OpShiftRightInt32x4 + OpShiftRightInt32x8 + OpShiftRightInt32x16 + OpShiftRightInt64x2 + OpShiftRightInt64x4 + OpShiftRightInt64x8 + OpShiftRightUint16x8 + OpShiftRightUint16x16 + OpShiftRightUint16x32 + OpShiftRightUint32x4 + OpShiftRightUint32x8 + OpShiftRightUint32x16 + OpShiftRightUint64x2 + OpShiftRightUint64x4 + OpShiftRightUint64x8 + OpSqrtFloat32x4 + OpSqrtFloat32x8 + OpSqrtFloat32x16 + OpSqrtFloat64x2 + OpSqrtFloat64x4 + OpSqrtFloat64x8 + OpSubFloat32x4 + OpSubFloat32x8 + OpSubFloat32x16 + OpSubFloat64x2 + OpSubFloat64x4 + OpSubFloat64x8 + OpSubInt8x16 + OpSubInt8x32 + OpSubInt8x64 + OpSubInt16x8 + OpSubInt16x16 + OpSubInt16x32 + OpSubInt32x4 + OpSubInt32x8 + OpSubInt32x16 + OpSubInt64x2 + OpSubInt64x4 + OpSubInt64x8 + OpSubPairsFloat32x4 + OpSubPairsFloat64x2 + OpSubPairsGroupedFloat32x8 + OpSubPairsGroupedFloat64x4 + OpSubPairsGroupedInt16x16 + OpSubPairsGroupedInt32x8 + OpSubPairsGroupedUint16x16 + OpSubPairsGroupedUint32x8 + OpSubPairsInt16x8 + OpSubPairsInt32x4 + OpSubPairsSaturatedGroupedInt16x16 + OpSubPairsSaturatedInt16x8 + OpSubPairsUint16x8 + OpSubPairsUint32x4 + OpSubSaturatedInt8x16 + OpSubSaturatedInt8x32 + OpSubSaturatedInt8x64 + OpSubSaturatedInt16x8 + OpSubSaturatedInt16x16 + OpSubSaturatedInt16x32 + OpSubSaturatedUint8x16 + OpSubSaturatedUint8x32 + OpSubSaturatedUint8x64 + OpSubSaturatedUint16x8 + OpSubSaturatedUint16x16 + OpSubSaturatedUint16x32 + OpSubUint8x16 + OpSubUint8x32 + OpSubUint8x64 + OpSubUint16x8 + OpSubUint16x16 + OpSubUint16x32 + OpSubUint32x4 + OpSubUint32x8 + OpSubUint32x16 + OpSubUint64x2 + OpSubUint64x4 + OpSubUint64x8 + OpSumAbsDiffUint8x16 + OpSumAbsDiffUint8x32 + OpSumAbsDiffUint8x64 + OpTruncFloat32x4 + OpTruncFloat32x8 + OpTruncFloat64x2 + OpTruncFloat64x4 + OpTruncateToInt8Int16x8 + OpTruncateToInt8Int16x16 + OpTruncateToInt8Int16x32 + OpTruncateToInt8Int32x4 + OpTruncateToInt8Int32x8 + OpTruncateToInt8Int32x16 + OpTruncateToInt8Int64x2 + OpTruncateToInt8Int64x4 + OpTruncateToInt8Int64x8 + OpTruncateToInt16Int32x4 + OpTruncateToInt16Int32x8 + OpTruncateToInt16Int32x16 + OpTruncateToInt16Int64x2 + OpTruncateToInt16Int64x4 + OpTruncateToInt16Int64x8 + OpTruncateToInt32Int64x2 + OpTruncateToInt32Int64x4 + OpTruncateToInt32Int64x8 + OpTruncateToUint8Uint16x8 + OpTruncateToUint8Uint16x16 + OpTruncateToUint8Uint16x32 + OpTruncateToUint8Uint32x4 + OpTruncateToUint8Uint32x8 + OpTruncateToUint8Uint32x16 + OpTruncateToUint8Uint64x2 + OpTruncateToUint8Uint64x4 + OpTruncateToUint8Uint64x8 + OpTruncateToUint16Uint32x4 + OpTruncateToUint16Uint32x8 + OpTruncateToUint16Uint32x16 + OpTruncateToUint16Uint64x2 + OpTruncateToUint16Uint64x4 + OpTruncateToUint16Uint64x8 + OpTruncateToUint32Uint64x2 + OpTruncateToUint32Uint64x4 + OpTruncateToUint32Uint64x8 + OpXorInt8x16 + OpXorInt8x32 + OpXorInt8x64 + OpXorInt16x8 + OpXorInt16x16 + OpXorInt16x32 + OpXorInt32x4 + OpXorInt32x8 + OpXorInt32x16 + OpXorInt64x2 + OpXorInt64x4 + OpXorInt64x8 + OpXorUint8x16 + OpXorUint8x32 + OpXorUint8x64 + OpXorUint16x8 + OpXorUint16x16 + OpXorUint16x32 + OpXorUint32x4 + OpXorUint32x8 + OpXorUint32x16 + OpXorUint64x2 + OpXorUint64x4 + OpXorUint64x8 + OpblendInt8x16 + OpblendInt8x32 + OpblendMaskedInt8x64 + OpblendMaskedInt16x32 + OpblendMaskedInt32x16 + OpblendMaskedInt64x8 + OpAESRoundKeyGenAssistUint32x4 + OpCeilScaledFloat32x4 + OpCeilScaledFloat32x8 + OpCeilScaledFloat32x16 + OpCeilScaledFloat64x2 + OpCeilScaledFloat64x4 + OpCeilScaledFloat64x8 + OpCeilScaledResidueFloat32x4 + OpCeilScaledResidueFloat32x8 + OpCeilScaledResidueFloat32x16 + OpCeilScaledResidueFloat64x2 + OpCeilScaledResidueFloat64x4 + OpCeilScaledResidueFloat64x8 + OpConcatShiftBytesRightGroupedUint8x32 + OpConcatShiftBytesRightGroupedUint8x64 + OpConcatShiftBytesRightUint8x16 + OpFloorScaledFloat32x4 + OpFloorScaledFloat32x8 + OpFloorScaledFloat32x16 + OpFloorScaledFloat64x2 + OpFloorScaledFloat64x4 + OpFloorScaledFloat64x8 + OpFloorScaledResidueFloat32x4 + OpFloorScaledResidueFloat32x8 + OpFloorScaledResidueFloat32x16 + OpFloorScaledResidueFloat64x2 + OpFloorScaledResidueFloat64x4 + OpFloorScaledResidueFloat64x8 + OpGaloisFieldAffineTransformInverseUint8x16 + OpGaloisFieldAffineTransformInverseUint8x32 + OpGaloisFieldAffineTransformInverseUint8x64 + OpGaloisFieldAffineTransformUint8x16 + OpGaloisFieldAffineTransformUint8x32 + OpGaloisFieldAffineTransformUint8x64 + OpGetElemFloat32x4 + OpGetElemFloat64x2 + OpGetElemInt8x16 + OpGetElemInt16x8 + OpGetElemInt32x4 + OpGetElemInt64x2 + OpGetElemUint8x16 + OpGetElemUint16x8 + OpGetElemUint32x4 + OpGetElemUint64x2 + OpRotateAllLeftInt32x4 + OpRotateAllLeftInt32x8 + OpRotateAllLeftInt32x16 + OpRotateAllLeftInt64x2 + OpRotateAllLeftInt64x4 + OpRotateAllLeftInt64x8 + OpRotateAllLeftUint32x4 + OpRotateAllLeftUint32x8 + OpRotateAllLeftUint32x16 + OpRotateAllLeftUint64x2 + OpRotateAllLeftUint64x4 + OpRotateAllLeftUint64x8 + OpRotateAllRightInt32x4 + OpRotateAllRightInt32x8 + OpRotateAllRightInt32x16 + OpRotateAllRightInt64x2 + OpRotateAllRightInt64x4 + OpRotateAllRightInt64x8 + OpRotateAllRightUint32x4 + OpRotateAllRightUint32x8 + OpRotateAllRightUint32x16 + OpRotateAllRightUint64x2 + OpRotateAllRightUint64x4 + OpRotateAllRightUint64x8 + OpRoundToEvenScaledFloat32x4 + OpRoundToEvenScaledFloat32x8 + OpRoundToEvenScaledFloat32x16 + OpRoundToEvenScaledFloat64x2 + OpRoundToEvenScaledFloat64x4 + OpRoundToEvenScaledFloat64x8 + OpRoundToEvenScaledResidueFloat32x4 + OpRoundToEvenScaledResidueFloat32x8 + OpRoundToEvenScaledResidueFloat32x16 + OpRoundToEvenScaledResidueFloat64x2 + OpRoundToEvenScaledResidueFloat64x4 + OpRoundToEvenScaledResidueFloat64x8 + OpSHA1FourRoundsUint32x4 + OpSelect128FromPairFloat32x8 + OpSelect128FromPairFloat64x4 + OpSelect128FromPairInt8x32 + OpSelect128FromPairInt16x16 + OpSelect128FromPairInt32x8 + OpSelect128FromPairInt64x4 + OpSelect128FromPairUint8x32 + OpSelect128FromPairUint16x16 + OpSelect128FromPairUint32x8 + OpSelect128FromPairUint64x4 + OpSetElemFloat32x4 + OpSetElemFloat64x2 + OpSetElemInt8x16 + OpSetElemInt16x8 + OpSetElemInt32x4 + OpSetElemInt64x2 + OpSetElemUint8x16 + OpSetElemUint16x8 + OpSetElemUint32x4 + OpSetElemUint64x2 + OpShiftAllLeftConcatInt16x8 + OpShiftAllLeftConcatInt16x16 + OpShiftAllLeftConcatInt16x32 + OpShiftAllLeftConcatInt32x4 + OpShiftAllLeftConcatInt32x8 + OpShiftAllLeftConcatInt32x16 + OpShiftAllLeftConcatInt64x2 + OpShiftAllLeftConcatInt64x4 + OpShiftAllLeftConcatInt64x8 + OpShiftAllLeftConcatUint16x8 + OpShiftAllLeftConcatUint16x16 + OpShiftAllLeftConcatUint16x32 + OpShiftAllLeftConcatUint32x4 + OpShiftAllLeftConcatUint32x8 + OpShiftAllLeftConcatUint32x16 + OpShiftAllLeftConcatUint64x2 + OpShiftAllLeftConcatUint64x4 + OpShiftAllLeftConcatUint64x8 + OpShiftAllRightConcatInt16x8 + OpShiftAllRightConcatInt16x16 + OpShiftAllRightConcatInt16x32 + OpShiftAllRightConcatInt32x4 + OpShiftAllRightConcatInt32x8 + OpShiftAllRightConcatInt32x16 + OpShiftAllRightConcatInt64x2 + OpShiftAllRightConcatInt64x4 + OpShiftAllRightConcatInt64x8 + OpShiftAllRightConcatUint16x8 + OpShiftAllRightConcatUint16x16 + OpShiftAllRightConcatUint16x32 + OpShiftAllRightConcatUint32x4 + OpShiftAllRightConcatUint32x8 + OpShiftAllRightConcatUint32x16 + OpShiftAllRightConcatUint64x2 + OpShiftAllRightConcatUint64x4 + OpShiftAllRightConcatUint64x8 + OpTruncScaledFloat32x4 + OpTruncScaledFloat32x8 + OpTruncScaledFloat32x16 + OpTruncScaledFloat64x2 + OpTruncScaledFloat64x4 + OpTruncScaledFloat64x8 + OpTruncScaledResidueFloat32x4 + OpTruncScaledResidueFloat32x8 + OpTruncScaledResidueFloat32x16 + OpTruncScaledResidueFloat64x2 + OpTruncScaledResidueFloat64x4 + OpTruncScaledResidueFloat64x8 + OpcarrylessMultiplyUint64x2 + OpcarrylessMultiplyUint64x4 + OpcarrylessMultiplyUint64x8 + OpconcatSelectedConstantFloat32x4 + OpconcatSelectedConstantFloat64x2 + OpconcatSelectedConstantGroupedFloat32x8 + OpconcatSelectedConstantGroupedFloat32x16 + OpconcatSelectedConstantGroupedFloat64x4 + OpconcatSelectedConstantGroupedFloat64x8 + OpconcatSelectedConstantGroupedInt32x8 + OpconcatSelectedConstantGroupedInt32x16 + OpconcatSelectedConstantGroupedInt64x4 + OpconcatSelectedConstantGroupedInt64x8 + OpconcatSelectedConstantGroupedUint32x8 + OpconcatSelectedConstantGroupedUint32x16 + OpconcatSelectedConstantGroupedUint64x4 + OpconcatSelectedConstantGroupedUint64x8 + OpconcatSelectedConstantInt32x4 + OpconcatSelectedConstantInt64x2 + OpconcatSelectedConstantUint32x4 + OpconcatSelectedConstantUint64x2 + OppermuteScalarsGroupedInt32x8 + OppermuteScalarsGroupedInt32x16 + OppermuteScalarsGroupedUint32x8 + OppermuteScalarsGroupedUint32x16 + OppermuteScalarsHiGroupedInt16x16 + OppermuteScalarsHiGroupedInt16x32 + OppermuteScalarsHiGroupedUint16x16 + OppermuteScalarsHiGroupedUint16x32 + OppermuteScalarsHiInt16x8 + OppermuteScalarsHiUint16x8 + OppermuteScalarsInt32x4 + OppermuteScalarsLoGroupedInt16x16 + OppermuteScalarsLoGroupedInt16x32 + OppermuteScalarsLoGroupedUint16x16 + OppermuteScalarsLoGroupedUint16x32 + OppermuteScalarsLoInt16x8 + OppermuteScalarsLoUint16x8 + OppermuteScalarsUint32x4 + OpternInt32x4 + OpternInt32x8 + OpternInt32x16 + OpternInt64x2 + OpternInt64x4 + OpternInt64x8 + OpternUint32x4 + OpternUint32x8 + OpternUint32x16 + OpternUint64x2 + OpternUint64x4 + OpternUint64x8 +) + +var opcodeTable = [...]opInfo{ + {name: "OpInvalid"}, + + { + name: "ADDSS", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.AADDSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "ADDSD", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.AADDSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "SUBSS", + argLen: 2, + resultInArg0: true, + asm: x86.ASUBSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "SUBSD", + argLen: 2, + resultInArg0: true, + asm: x86.ASUBSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MULSS", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.AMULSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MULSD", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.AMULSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "DIVSS", + argLen: 2, + resultInArg0: true, + asm: x86.ADIVSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "DIVSD", + argLen: 2, + resultInArg0: true, + asm: x86.ADIVSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MOVSSload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MOVSDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MOVSSconst", + auxType: auxFloat32, + argLen: 0, + rematerializeable: true, + asm: x86.AMOVSS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MOVSDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: x86.AMOVSD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MOVSSloadidx1", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MOVSSloadidx4", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MOVSDloadidx1", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MOVSDloadidx8", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MOVSSstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVSDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVSSstoreidx1", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVSSstoreidx4", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVSDstoreidx1", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVSDstoreidx8", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ADDSSload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AADDSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "ADDSDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AADDSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "SUBSSload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ASUBSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "SUBSDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ASUBSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MULSSload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AMULSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MULSDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AMULSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "DIVSSload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ADIVSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "DIVSDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ADIVSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "ADDL", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 239}, // AX CX DX BX BP SI DI + {0, 255}, // AX CX DX BX SP BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ADDLconst", + auxType: auxInt32, + argLen: 1, + clobberFlags: true, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ADDLcarry", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {1, 0}, + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ADDLconstcarry", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {1, 0}, + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ADCL", + argLen: 3, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AADCL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ADCLcarry", + argLen: 3, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AADCL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {1, 0}, + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ADCLconst", + auxType: auxInt32, + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.AADCL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SUBL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SUBLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SUBLcarry", + argLen: 2, + resultInArg0: true, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {1, 0}, + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SUBLconstcarry", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {1, 0}, + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SBBL", + argLen: 3, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASBBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SBBLconst", + auxType: auxInt32, + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASBBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MULL", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AIMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MULLconst", + auxType: auxInt32, + argLen: 1, + clobberFlags: true, + asm: x86.AIMUL3L, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MULLU", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: x86.AMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 255}, // AX CX DX BX SP BP SI DI + }, + clobbers: 4, // DX + outputs: []outputInfo{ + {1, 0}, + {0, 1}, // AX + }, + }, + }, + { + name: "HMULL", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: x86.AIMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 255}, // AX CX DX BX SP BP SI DI + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "HMULLU", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: x86.AMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 255}, // AX CX DX BX SP BP SI DI + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "MULLQU", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: x86.AMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 255}, // AX CX DX BX SP BP SI DI + }, + outputs: []outputInfo{ + {0, 4}, // DX + {1, 1}, // AX + }, + }, + }, + { + name: "AVGLU", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "DIVL", + auxType: auxBool, + argLen: 2, + clobberFlags: true, + asm: x86.AIDIVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 251}, // AX CX BX SP BP SI DI + }, + clobbers: 4, // DX + outputs: []outputInfo{ + {0, 1}, // AX + }, + }, + }, + { + name: "DIVW", + auxType: auxBool, + argLen: 2, + clobberFlags: true, + asm: x86.AIDIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 251}, // AX CX BX SP BP SI DI + }, + clobbers: 4, // DX + outputs: []outputInfo{ + {0, 1}, // AX + }, + }, + }, + { + name: "DIVLU", + argLen: 2, + clobberFlags: true, + asm: x86.ADIVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 251}, // AX CX BX SP BP SI DI + }, + clobbers: 4, // DX + outputs: []outputInfo{ + {0, 1}, // AX + }, + }, + }, + { + name: "DIVWU", + argLen: 2, + clobberFlags: true, + asm: x86.ADIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 251}, // AX CX BX SP BP SI DI + }, + clobbers: 4, // DX + outputs: []outputInfo{ + {0, 1}, // AX + }, + }, + }, + { + name: "MODL", + auxType: auxBool, + argLen: 2, + clobberFlags: true, + asm: x86.AIDIVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 251}, // AX CX BX SP BP SI DI + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "MODW", + auxType: auxBool, + argLen: 2, + clobberFlags: true, + asm: x86.AIDIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 251}, // AX CX BX SP BP SI DI + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "MODLU", + argLen: 2, + clobberFlags: true, + asm: x86.ADIVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 251}, // AX CX BX SP BP SI DI + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "MODWU", + argLen: 2, + clobberFlags: true, + asm: x86.ADIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 251}, // AX CX BX SP BP SI DI + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "ANDL", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ANDLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ORL", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ORLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "XORL", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "XORLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "CMPL", + argLen: 2, + asm: x86.ACMPL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + {1, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "CMPW", + argLen: 2, + asm: x86.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + {1, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "CMPB", + argLen: 2, + asm: x86.ACMPB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + {1, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "CMPLconst", + auxType: auxInt32, + argLen: 1, + asm: x86.ACMPL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "CMPWconst", + auxType: auxInt16, + argLen: 1, + asm: x86.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "CMPBconst", + auxType: auxInt8, + argLen: 1, + asm: x86.ACMPB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "CMPLload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "CMPWload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "CMPBload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "CMPLconstload", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "CMPWconstload", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "CMPBconstload", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "UCOMISS", + argLen: 2, + asm: x86.AUCOMISS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "UCOMISD", + argLen: 2, + asm: x86.AUCOMISD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "TESTL", + argLen: 2, + commutative: true, + asm: x86.ATESTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + {1, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "TESTW", + argLen: 2, + commutative: true, + asm: x86.ATESTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + {1, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "TESTB", + argLen: 2, + commutative: true, + asm: x86.ATESTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + {1, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "TESTLconst", + auxType: auxInt32, + argLen: 1, + asm: x86.ATESTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "TESTWconst", + auxType: auxInt16, + argLen: 1, + asm: x86.ATESTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "TESTBconst", + auxType: auxInt8, + argLen: 1, + asm: x86.ATESTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "SHLL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHLL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SHLLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SHRL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SHRW", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SHRB", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SHRLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SHRWconst", + auxType: auxInt16, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SHRBconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SARL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SARW", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SARB", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SARLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SARWconst", + auxType: auxInt16, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SARBconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ROLL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ROLW", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ROLB", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ROLLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ROLWconst", + auxType: auxInt16, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ROLBconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ADDLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SUBLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MULLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AIMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ANDLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ORLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "XORLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ADDLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SUBLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MULLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AIMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ANDLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "ORLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "XORLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {1, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "NEGL", + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ANEGL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "NOTL", + argLen: 1, + resultInArg0: true, + asm: x86.ANOTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "BSFL", + argLen: 1, + clobberFlags: true, + asm: x86.ABSFL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "BSFW", + argLen: 1, + clobberFlags: true, + asm: x86.ABSFW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LoweredCtz32", + argLen: 1, + clobberFlags: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LoweredCtz64", + argLen: 2, + resultNotInArgs: true, + clobberFlags: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "BSRL", + argLen: 1, + clobberFlags: true, + asm: x86.ABSRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "BSRW", + argLen: 1, + clobberFlags: true, + asm: x86.ABSRW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "BSWAPL", + argLen: 1, + resultInArg0: true, + asm: x86.ABSWAPL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SQRTSD", + argLen: 1, + asm: x86.ASQRTSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "SQRTSS", + argLen: 1, + asm: x86.ASQRTSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "SBBLcarrymask", + argLen: 1, + asm: x86.ASBBL, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETEQ", + argLen: 1, + asm: x86.ASETEQ, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETNE", + argLen: 1, + asm: x86.ASETNE, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETL", + argLen: 1, + asm: x86.ASETLT, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETLE", + argLen: 1, + asm: x86.ASETLE, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETG", + argLen: 1, + asm: x86.ASETGT, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETGE", + argLen: 1, + asm: x86.ASETGE, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETB", + argLen: 1, + asm: x86.ASETCS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETBE", + argLen: 1, + asm: x86.ASETLS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETA", + argLen: 1, + asm: x86.ASETHI, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETAE", + argLen: 1, + asm: x86.ASETCC, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETO", + argLen: 1, + asm: x86.ASETOS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETEQF", + argLen: 1, + clobberFlags: true, + asm: x86.ASETEQ, + reg: regInfo{ + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 238}, // CX DX BX BP SI DI + }, + }, + }, + { + name: "SETNEF", + argLen: 1, + clobberFlags: true, + asm: x86.ASETNE, + reg: regInfo{ + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 238}, // CX DX BX BP SI DI + }, + }, + }, + { + name: "SETORD", + argLen: 1, + asm: x86.ASETPC, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETNAN", + argLen: 1, + asm: x86.ASETPS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETGF", + argLen: 1, + asm: x86.ASETHI, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "SETGEF", + argLen: 1, + asm: x86.ASETCC, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVBLSX", + argLen: 1, + asm: x86.AMOVBLSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVBLZX", + argLen: 1, + asm: x86.AMOVBLZX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVWLSX", + argLen: 1, + asm: x86.AMOVWLSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVWLZX", + argLen: 1, + asm: x86.AMOVWLZX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVLconst", + auxType: auxInt32, + argLen: 0, + rematerializeable: true, + asm: x86.AMOVL, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "CVTTSD2SL", + argLen: 1, + asm: x86.ACVTTSD2SL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "CVTTSS2SL", + argLen: 1, + asm: x86.ACVTTSS2SL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "CVTSL2SS", + argLen: 1, + asm: x86.ACVTSL2SS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "CVTSL2SD", + argLen: 1, + asm: x86.ACVTSL2SD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "CVTSD2SS", + argLen: 1, + asm: x86.ACVTSD2SS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "CVTSS2SD", + argLen: 1, + asm: x86.ACVTSS2SD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "PXOR", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.APXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + {1, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "LEAL", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LEAL1", + auxType: auxSymOff, + argLen: 2, + commutative: true, + symEffect: SymAddr, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LEAL2", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LEAL4", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LEAL8", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVBload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVBLZX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVBLSXload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVBLSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVWLZX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVWLSXload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVWLSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVLload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVLstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ADDLmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "SUBLmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ANDLmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ORLmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "XORLmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ADDLmodifyidx4", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "SUBLmodifyidx4", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ANDLmodifyidx4", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ORLmodifyidx4", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "XORLmodifyidx4", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ADDLconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ANDLconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ORLconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "XORLconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ADDLconstmodifyidx4", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ANDLconstmodifyidx4", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "ORLconstmodifyidx4", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "XORLconstmodifyidx4", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVBloadidx1", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.AMOVBLZX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVWloadidx1", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.AMOVWLZX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVWloadidx2", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVWLZX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVLloadidx1", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVLloadidx4", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVBstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVWstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVWstoreidx2", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVLstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVLstoreidx4", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {2, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVBstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVWstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVLstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVBstoreconstidx1", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymWrite, + asm: x86.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVWstoreconstidx1", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymWrite, + asm: x86.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVWstoreconstidx2", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymWrite, + asm: x86.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVLstoreconstidx1", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymWrite, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "MOVLstoreconstidx4", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymWrite, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 255}, // AX CX DX BX SP BP SI DI + {0, 65791}, // AX CX DX BX SP BP SI DI SB + }, + }, + }, + { + name: "DUFFZERO", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 128}, // DI + {1, 1}, // AX + }, + clobbers: 130, // CX DI + }, + }, + { + name: "REPSTOSL", + argLen: 4, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 128}, // DI + {1, 2}, // CX + {2, 1}, // AX + }, + clobbers: 130, // CX DI + }, + }, + { + name: "CALLstatic", + auxType: auxCallOff, + argLen: 1, + clobberFlags: true, + call: true, + reg: regInfo{ + clobbers: 65519, // AX CX DX BX BP SI DI X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + { + name: "CALLtail", + auxType: auxCallOff, + argLen: 1, + clobberFlags: true, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 65519, // AX CX DX BX BP SI DI X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + { + name: "CALLclosure", + auxType: auxCallOff, + argLen: 3, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 4}, // DX + {0, 255}, // AX CX DX BX SP BP SI DI + }, + clobbers: 65519, // AX CX DX BX BP SI DI X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + { + name: "CALLinter", + auxType: auxCallOff, + argLen: 2, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + clobbers: 65519, // AX CX DX BX BP SI DI X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + { + name: "DUFFCOPY", + auxType: auxInt64, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 128}, // DI + {1, 64}, // SI + }, + clobbers: 194, // CX SI DI + }, + }, + { + name: "REPMOVSL", + argLen: 4, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 128}, // DI + {1, 64}, // SI + {2, 2}, // CX + }, + clobbers: 194, // CX SI DI + }, + }, + { + name: "InvertFlags", + argLen: 1, + reg: regInfo{}, + }, + { + name: "LoweredGetG", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + zeroWidth: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + clobberFlags: true, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 255}, // AX CX DX BX SP BP SI DI + }, + }, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + reg: regInfo{ + clobbers: 65280, // X0 X1 X2 X3 X4 X5 X6 X7 + outputs: []outputInfo{ + {0, 128}, // DI + }, + }, + }, + { + name: "LoweredPanicBoundsRR", + auxType: auxInt64, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + {1, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LoweredPanicBoundsRC", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LoweredPanicBoundsCR", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LoweredPanicBoundsCC", + auxType: auxPanicBoundsCC, + argLen: 1, + call: true, + reg: regInfo{}, + }, + { + name: "LoweredPanicExtendRR", + auxType: auxInt64, + argLen: 4, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 15}, // AX CX DX BX + {1, 15}, // AX CX DX BX + {2, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "LoweredPanicExtendRC", + auxType: auxPanicBoundsC, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 15}, // AX CX DX BX + {1, 15}, // AX CX DX BX + }, + }, + }, + { + name: "FlagEQ", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagLT_ULT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagLT_UGT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagGT_UGT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagGT_ULT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "MOVSSconst1", + auxType: auxFloat32, + argLen: 0, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVSDconst1", + auxType: auxFloat64, + argLen: 0, + reg: regInfo{ + outputs: []outputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + }, + }, + { + name: "MOVSSconst2", + argLen: 1, + asm: x86.AMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + { + name: "MOVSDconst2", + argLen: 1, + asm: x86.AMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 239}, // AX CX DX BX BP SI DI + }, + outputs: []outputInfo{ + {0, 65280}, // X0 X1 X2 X3 X4 X5 X6 X7 + }, + }, + }, + + { + name: "ADDSS", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.AADDSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "ADDSD", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.AADDSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SUBSS", + argLen: 2, + resultInArg0: true, + asm: x86.ASUBSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SUBSD", + argLen: 2, + resultInArg0: true, + asm: x86.ASUBSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MULSS", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.AMULSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MULSD", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.AMULSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "DIVSS", + argLen: 2, + resultInArg0: true, + asm: x86.ADIVSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "DIVSD", + argLen: 2, + resultInArg0: true, + asm: x86.ADIVSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVSSload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVSDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVSSconst", + auxType: auxFloat32, + argLen: 0, + rematerializeable: true, + asm: x86.AMOVSS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVSDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: x86.AMOVSD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVSSloadidx1", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVSS, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVSSloadidx4", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVSS, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVSDloadidx1", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVSD, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVSDloadidx8", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVSD, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVSSstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "MOVSDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "MOVSSstoreidx1", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVSS, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "MOVSSstoreidx4", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVSS, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "MOVSDstoreidx1", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVSD, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "MOVSDstoreidx8", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVSD, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "ADDSSload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AADDSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "ADDSDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AADDSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SUBSSload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ASUBSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SUBSDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ASUBSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MULSSload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AMULSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MULSDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AMULSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "DIVSSload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ADIVSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "DIVSDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ADIVSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "ADDSSloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AADDSS, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "ADDSSloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AADDSS, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "ADDSDloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AADDSD, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "ADDSDloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AADDSD, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SUBSSloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.ASUBSS, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SUBSSloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.ASUBSS, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SUBSDloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.ASUBSD, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SUBSDloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.ASUBSD, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MULSSloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AMULSS, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MULSSloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AMULSS, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MULSDloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AMULSD, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MULSDloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AMULSD, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "DIVSSloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.ADIVSS, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "DIVSSloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.ADIVSS, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "DIVSDloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.ADIVSD, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "DIVSDloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.ADIVSD, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "ADDQ", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: x86.AADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDL", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDQconst", + auxType: auxInt32, + argLen: 1, + clobberFlags: true, + asm: x86.AADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDLconst", + auxType: auxInt32, + argLen: 1, + clobberFlags: true, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDQconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDLconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SUBQ", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBQconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MULQ", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AIMULQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MULL", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AIMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MULQconst", + auxType: auxInt32, + argLen: 1, + clobberFlags: true, + asm: x86.AIMUL3Q, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MULLconst", + auxType: auxInt32, + argLen: 1, + clobberFlags: true, + asm: x86.AIMUL3L, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MULLU", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: x86.AMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 4, // DX + outputs: []outputInfo{ + {1, 0}, + {0, 1}, // AX + }, + }, + }, + { + name: "MULQU", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: x86.AMULQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 4, // DX + outputs: []outputInfo{ + {1, 0}, + {0, 1}, // AX + }, + }, + }, + { + name: "HMULQ", + argLen: 2, + clobberFlags: true, + asm: x86.AIMULQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "HMULL", + argLen: 2, + clobberFlags: true, + asm: x86.AIMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "HMULQU", + argLen: 2, + clobberFlags: true, + asm: x86.AMULQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "HMULLU", + argLen: 2, + clobberFlags: true, + asm: x86.AMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "AVGQU", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "DIVQ", + auxType: auxBool, + argLen: 2, + clobberFlags: true, + asm: x86.AIDIVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49147}, // AX CX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 1}, // AX + {1, 4}, // DX + }, + }, + }, + { + name: "DIVL", + auxType: auxBool, + argLen: 2, + clobberFlags: true, + asm: x86.AIDIVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49147}, // AX CX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 1}, // AX + {1, 4}, // DX + }, + }, + }, + { + name: "DIVW", + auxType: auxBool, + argLen: 2, + clobberFlags: true, + asm: x86.AIDIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49147}, // AX CX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 1}, // AX + {1, 4}, // DX + }, + }, + }, + { + name: "DIVQU", + argLen: 2, + clobberFlags: true, + asm: x86.ADIVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49147}, // AX CX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 1}, // AX + {1, 4}, // DX + }, + }, + }, + { + name: "DIVLU", + argLen: 2, + clobberFlags: true, + asm: x86.ADIVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49147}, // AX CX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 1}, // AX + {1, 4}, // DX + }, + }, + }, + { + name: "DIVWU", + argLen: 2, + clobberFlags: true, + asm: x86.ADIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49147}, // AX CX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 1}, // AX + {1, 4}, // DX + }, + }, + }, + { + name: "NEGLflags", + argLen: 1, + resultInArg0: true, + asm: x86.ANEGL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDQconstflags", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + asm: x86.AADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDLconstflags", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDQcarry", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.AADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADCQ", + argLen: 3, + commutative: true, + resultInArg0: true, + asm: x86.AADCQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDQconstcarry", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + asm: x86.AADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADCQconst", + auxType: auxInt32, + argLen: 2, + resultInArg0: true, + asm: x86.AADCQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBQborrow", + argLen: 2, + resultInArg0: true, + asm: x86.ASUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SBBQ", + argLen: 3, + resultInArg0: true, + asm: x86.ASBBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBQconstborrow", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + asm: x86.ASUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SBBQconst", + auxType: auxInt32, + argLen: 2, + resultInArg0: true, + asm: x86.ASBBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MULQU2", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: x86.AMULQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // AX + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 4}, // DX + {1, 1}, // AX + }, + }, + }, + { + name: "DIVQU2", + argLen: 3, + clobberFlags: true, + asm: x86.ADIVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4}, // DX + {1, 1}, // AX + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 1}, // AX + {1, 4}, // DX + }, + }, + }, + { + name: "ANDQ", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDL", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDQconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDQconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDLconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORQ", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORL", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORQconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORQconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORLconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORQ", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORL", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORQconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORLconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORQconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORLconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPQ", + argLen: 2, + asm: x86.ACMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMPL", + argLen: 2, + asm: x86.ACMPL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMPW", + argLen: 2, + asm: x86.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMPB", + argLen: 2, + asm: x86.ACMPB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMPQconst", + auxType: auxInt32, + argLen: 1, + asm: x86.ACMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMPLconst", + auxType: auxInt32, + argLen: 1, + asm: x86.ACMPL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMPWconst", + auxType: auxInt16, + argLen: 1, + asm: x86.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMPBconst", + auxType: auxInt8, + argLen: 1, + asm: x86.ACMPB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMPQload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPLload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPWload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPBload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPQconstload", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPLconstload", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPWconstload", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPBconstload", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ACMPB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPQloadidx8", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.ACMPQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPQloadidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymRead, + asm: x86.ACMPQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPLloadidx4", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.ACMPL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPLloadidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymRead, + asm: x86.ACMPL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPWloadidx2", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.ACMPW, + scale: 2, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPWloadidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymRead, + asm: x86.ACMPW, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPBloadidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymRead, + asm: x86.ACMPB, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPQconstloadidx8", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.ACMPQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPQconstloadidx1", + auxType: auxSymValAndOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.ACMPQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPLconstloadidx4", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.ACMPL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPLconstloadidx1", + auxType: auxSymValAndOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.ACMPL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPWconstloadidx2", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.ACMPW, + scale: 2, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPWconstloadidx1", + auxType: auxSymValAndOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.ACMPW, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "CMPBconstloadidx1", + auxType: auxSymValAndOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.ACMPB, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "UCOMISS", + argLen: 2, + asm: x86.AUCOMISS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "UCOMISD", + argLen: 2, + asm: x86.AUCOMISD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "BTL", + argLen: 2, + asm: x86.ABTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTQ", + argLen: 2, + asm: x86.ABTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTCL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ABTCL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTCQ", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ABTCQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTRL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ABTRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTRQ", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ABTRQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTSL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ABTSL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTSQ", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ABTSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTLconst", + auxType: auxInt8, + argLen: 1, + asm: x86.ABTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTQconst", + auxType: auxInt8, + argLen: 1, + asm: x86.ABTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTCQconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ABTCQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTRQconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ABTRQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTSQconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ABTSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BTSQconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.ABTSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "BTRQconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.ABTRQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "BTCQconstmodify", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.ABTCQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "TESTQ", + argLen: 2, + commutative: true, + asm: x86.ATESTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "TESTL", + argLen: 2, + commutative: true, + asm: x86.ATESTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "TESTW", + argLen: 2, + commutative: true, + asm: x86.ATESTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "TESTB", + argLen: 2, + commutative: true, + asm: x86.ATESTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "TESTQconst", + auxType: auxInt32, + argLen: 1, + asm: x86.ATESTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "TESTLconst", + auxType: auxInt32, + argLen: 1, + asm: x86.ATESTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "TESTWconst", + auxType: auxInt16, + argLen: 1, + asm: x86.ATESTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "TESTBconst", + auxType: auxInt8, + argLen: 1, + asm: x86.ATESTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLQ", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHLL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLQconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLLconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRQ", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRW", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRB", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRQconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRLconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRWconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRBconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARQ", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARW", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARB", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARQconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARLconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARWconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARBconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASARB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRDQ", + argLen: 3, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHRQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLDQ", + argLen: 3, + resultInArg0: true, + clobberFlags: true, + asm: x86.ASHLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ROLQ", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ROLL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ROLW", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ROLB", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "RORQ", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ARORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "RORL", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ARORL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "RORW", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ARORW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "RORB", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: x86.ARORB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // CX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ROLQconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ROLLconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ROLWconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ROLBconst", + auxType: auxInt8, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.AROLB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDQload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBQload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ASUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDQload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORQload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORQload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORLload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDLloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AADDL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AADDL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDLloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AADDL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDQloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AADDQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDQloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AADDQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBLloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.ASUBL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.ASUBL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBLloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.ASUBL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBQloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.ASUBQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SUBQloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.ASUBQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDLloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AANDL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AANDL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDLloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AANDL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDQloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AANDQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDQloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AANDQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORLloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AORL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AORL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORLloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AORL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORQloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AORQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ORQloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AORQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORLloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AXORL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORLloadidx4", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AXORL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORLloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AXORL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORQloadidx1", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AXORQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XORQloadidx8", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + clobberFlags: true, + symEffect: SymRead, + asm: x86.AXORQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ADDQmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SUBQmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.ASUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDQmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORQmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORQmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDLmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SUBLmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.ASUBL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDLmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORLmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORLmodify", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDQmodifyidx1", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDQmodifyidx8", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SUBQmodifyidx1", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.ASUBQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SUBQmodifyidx8", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.ASUBQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDQmodifyidx1", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDQmodifyidx8", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORQmodifyidx1", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORQmodifyidx8", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORQmodifyidx1", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORQmodifyidx8", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDLmodifyidx1", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDLmodifyidx4", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDLmodifyidx8", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SUBLmodifyidx1", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.ASUBL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SUBLmodifyidx4", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.ASUBL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SUBLmodifyidx8", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.ASUBL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDLmodifyidx1", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDLmodifyidx4", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDLmodifyidx8", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORLmodifyidx1", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORLmodifyidx4", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORLmodifyidx8", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORLmodifyidx1", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORLmodifyidx4", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORLmodifyidx8", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDQconstmodifyidx1", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDQconstmodifyidx8", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDQconstmodifyidx1", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDQconstmodifyidx8", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORQconstmodifyidx1", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORQconstmodifyidx8", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORQconstmodifyidx1", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORQconstmodifyidx8", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDLconstmodifyidx1", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDLconstmodifyidx4", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ADDLconstmodifyidx8", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AADDL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDLconstmodifyidx1", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDLconstmodifyidx4", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDLconstmodifyidx8", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AANDL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORLconstmodifyidx1", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORLconstmodifyidx4", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORLconstmodifyidx8", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AORL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORLconstmodifyidx1", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORLconstmodifyidx4", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "XORLconstmodifyidx8", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + symEffect: SymRead | SymWrite, + asm: x86.AXORL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "NEGQ", + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ANEGQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "NEGL", + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: x86.ANEGL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "NOTQ", + argLen: 1, + resultInArg0: true, + asm: x86.ANOTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "NOTL", + argLen: 1, + resultInArg0: true, + asm: x86.ANOTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BSFQ", + argLen: 1, + asm: x86.ABSFQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BSFL", + argLen: 1, + clobberFlags: true, + asm: x86.ABSFL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BSRQ", + argLen: 1, + asm: x86.ABSRQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BSRL", + argLen: 1, + clobberFlags: true, + asm: x86.ABSRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQEQ", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQNE", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQNE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQLT", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQLT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQGT", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQLE", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQLE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQGE", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQGE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQLS", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQLS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQHI", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQHI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQCC", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQCS", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQCS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLEQ", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLNE", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLNE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLLT", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLLT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLGT", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLLE", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLLE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLGE", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLGE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLLS", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLLS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLHI", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLHI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLCC", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLCS", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLCS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWEQ", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWNE", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWNE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWLT", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWLT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWGT", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWLE", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWLE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWGE", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWGE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWLS", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWLS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWHI", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWHI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWCC", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWCS", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWCS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQEQF", + argLen: 3, + resultInArg0: true, + needIntTemp: true, + asm: x86.ACMOVQNE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQNEF", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQNE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQGTF", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQHI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVQGEF", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVQCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLEQF", + argLen: 3, + resultInArg0: true, + needIntTemp: true, + asm: x86.ACMOVLNE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLNEF", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLNE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLGTF", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLHI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVLGEF", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVLCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWEQF", + argLen: 3, + resultInArg0: true, + needIntTemp: true, + asm: x86.ACMOVWNE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWNEF", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWNE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWGTF", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWHI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMOVWGEF", + argLen: 3, + resultInArg0: true, + asm: x86.ACMOVWCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BSWAPQ", + argLen: 1, + resultInArg0: true, + asm: x86.ABSWAPQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BSWAPL", + argLen: 1, + resultInArg0: true, + asm: x86.ABSWAPL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "POPCNTQ", + argLen: 1, + clobberFlags: true, + asm: x86.APOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "POPCNTL", + argLen: 1, + clobberFlags: true, + asm: x86.APOPCNTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SQRTSD", + argLen: 1, + asm: x86.ASQRTSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SQRTSS", + argLen: 1, + asm: x86.ASQRTSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "ROUNDSD", + auxType: auxInt8, + argLen: 1, + asm: x86.AROUNDSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "LoweredRound32F", + argLen: 1, + resultInArg0: true, + zeroWidth: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "LoweredRound64F", + argLen: 1, + resultInArg0: true, + zeroWidth: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMADD231SS", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADD231SS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMADD231SD", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADD231SD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MINSD", + argLen: 2, + resultInArg0: true, + asm: x86.AMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MINSS", + argLen: 2, + resultInArg0: true, + asm: x86.AMINSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SBBQcarrymask", + argLen: 1, + asm: x86.ASBBQ, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SBBLcarrymask", + argLen: 1, + asm: x86.ASBBL, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETEQ", + argLen: 1, + asm: x86.ASETEQ, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETNE", + argLen: 1, + asm: x86.ASETNE, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETL", + argLen: 1, + asm: x86.ASETLT, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETLE", + argLen: 1, + asm: x86.ASETLE, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETG", + argLen: 1, + asm: x86.ASETGT, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETGE", + argLen: 1, + asm: x86.ASETGE, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETB", + argLen: 1, + asm: x86.ASETCS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETBE", + argLen: 1, + asm: x86.ASETLS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETA", + argLen: 1, + asm: x86.ASETHI, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETAE", + argLen: 1, + asm: x86.ASETCC, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETO", + argLen: 1, + asm: x86.ASETOS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETEQstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.ASETEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETNEstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.ASETNE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETLstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.ASETLT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETLEstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.ASETLE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETGstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.ASETGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETGEstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.ASETGE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.ASETCS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETBEstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.ASETLS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETAstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.ASETHI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETAEstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.ASETCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETEQstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.ASETEQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETNEstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.ASETNE, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETLstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.ASETLT, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETLEstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.ASETLE, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETGstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.ASETGT, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETGEstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.ASETGE, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETBstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.ASETCS, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETBEstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.ASETLS, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETAstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.ASETHI, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETAEstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.ASETCC, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SETEQF", + argLen: 1, + clobberFlags: true, + needIntTemp: true, + asm: x86.ASETEQ, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETNEF", + argLen: 1, + clobberFlags: true, + needIntTemp: true, + asm: x86.ASETNE, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETORD", + argLen: 1, + asm: x86.ASETPC, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETNAN", + argLen: 1, + asm: x86.ASETPS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETGF", + argLen: 1, + asm: x86.ASETHI, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SETGEF", + argLen: 1, + asm: x86.ASETCC, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBQSX", + argLen: 1, + asm: x86.AMOVBQSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBQZX", + argLen: 1, + asm: x86.AMOVBLZX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVWQSX", + argLen: 1, + asm: x86.AMOVWQSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVWQZX", + argLen: 1, + asm: x86.AMOVWLZX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVLQSX", + argLen: 1, + asm: x86.AMOVLQSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVLQZX", + argLen: 1, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVLconst", + auxType: auxInt32, + argLen: 0, + rematerializeable: true, + asm: x86.AMOVL, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVQconst", + auxType: auxInt64, + argLen: 0, + rematerializeable: true, + asm: x86.AMOVQ, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CVTTSD2SL", + argLen: 1, + asm: x86.ACVTTSD2SL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CVTTSD2SQ", + argLen: 1, + asm: x86.ACVTTSD2SQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CVTTSS2SL", + argLen: 1, + asm: x86.ACVTTSS2SL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CVTTSS2SQ", + argLen: 1, + asm: x86.ACVTTSS2SQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CVTSL2SS", + argLen: 1, + asm: x86.ACVTSL2SS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "CVTSL2SD", + argLen: 1, + asm: x86.ACVTSL2SD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "CVTSQ2SS", + argLen: 1, + asm: x86.ACVTSQ2SS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "CVTSQ2SD", + argLen: 1, + asm: x86.ACVTSQ2SD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "CVTSD2SS", + argLen: 1, + asm: x86.ACVTSD2SS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "CVTSS2SD", + argLen: 1, + asm: x86.ACVTSS2SD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVQi2f", + argLen: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVQf2i", + argLen: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVLi2f", + argLen: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVLf2i", + argLen: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "PXOR", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.APXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "POR", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.APOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "LEAQ", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + asm: x86.ALEAQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAL", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + asm: x86.ALEAL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAW", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + asm: x86.ALEAW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAQ1", + auxType: auxSymOff, + argLen: 2, + commutative: true, + symEffect: SymAddr, + asm: x86.ALEAQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAL1", + auxType: auxSymOff, + argLen: 2, + commutative: true, + symEffect: SymAddr, + asm: x86.ALEAL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAW1", + auxType: auxSymOff, + argLen: 2, + commutative: true, + symEffect: SymAddr, + asm: x86.ALEAW, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAQ2", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + asm: x86.ALEAQ, + scale: 2, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAL2", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + asm: x86.ALEAL, + scale: 2, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAW2", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + asm: x86.ALEAW, + scale: 2, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAQ4", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + asm: x86.ALEAQ, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAL4", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + asm: x86.ALEAL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAW4", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + asm: x86.ALEAW, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAQ8", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + asm: x86.ALEAQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAL8", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + asm: x86.ALEAL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LEAW8", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + asm: x86.ALEAW, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVBLZX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBQSXload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVBQSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVWLZX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVWQSXload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVWQSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVLload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVLQSXload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVLQSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVQload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVLstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVQstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVOload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVUPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "MOVOstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVUPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "MOVBloadidx1", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.AMOVBLZX, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVWloadidx1", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.AMOVWLZX, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVWloadidx2", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVWLZX, + scale: 2, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVLloadidx1", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.AMOVL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVLloadidx4", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVLloadidx8", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVQloadidx1", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.AMOVQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVQloadidx8", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVB, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVWstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVW, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVWstoreidx2", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVW, + scale: 2, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVLstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVLstoreidx4", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVLstoreidx8", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVQstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVQstoreidx8", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVWstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVLstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVQstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVOstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVUPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBstoreconstidx1", + auxType: auxSymValAndOff, + argLen: 3, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVB, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVWstoreconstidx1", + auxType: auxSymValAndOff, + argLen: 3, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVW, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVWstoreconstidx2", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymWrite, + asm: x86.AMOVW, + scale: 2, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVLstoreconstidx1", + auxType: auxSymValAndOff, + argLen: 3, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVLstoreconstidx4", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymWrite, + asm: x86.AMOVL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVQstoreconstidx1", + auxType: auxSymValAndOff, + argLen: 3, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVQstoreconstidx8", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymWrite, + asm: x86.AMOVQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "LoweredZero", + auxType: auxInt64, + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LoweredZeroLoop", + auxType: auxInt64, + argLen: 2, + clobberFlags: true, + needIntTemp: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbersArg0: true, + }, + }, + { + name: "REPSTOSQ", + argLen: 4, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 128}, // DI + {1, 2}, // CX + {2, 1}, // AX + }, + clobbers: 130, // CX DI + }, + }, + { + name: "CALLstatic", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + clobbers: 2147483631, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 g R15 X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + { + name: "CALLtail", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 2147483631, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 g R15 X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + { + name: "CALLclosure", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 4}, // DX + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 2147483631, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 g R15 X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + { + name: "CALLinter", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 2147483631, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 g R15 X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + { + name: "LoweredMove", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 1073741824, // X14 + }, + }, + { + name: "LoweredMoveLoop", + auxType: auxInt64, + argLen: 3, + clobberFlags: true, + needIntTemp: true, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 1073741824, // X14 + clobbersArg0: true, + clobbersArg1: true, + }, + }, + { + name: "REPMOVSQ", + argLen: 4, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 128}, // DI + {1, 64}, // SI + {2, 2}, // CX + }, + clobbers: 194, // CX SI DI + }, + }, + { + name: "InvertFlags", + argLen: 1, + reg: regInfo{}, + }, + { + name: "LoweredGetG", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + zeroWidth: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4}, // DX + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + clobberFlags: true, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + reg: regInfo{ + clobbers: 2147418112, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + outputs: []outputInfo{ + {0, 2048}, // R11 + }, + }, + }, + { + name: "LoweredHasCPUFeature", + auxType: auxSym, + argLen: 0, + rematerializeable: true, + symEffect: SymNone, + reg: regInfo{ + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LoweredPanicBoundsRR", + auxType: auxInt64, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LoweredPanicBoundsRC", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LoweredPanicBoundsCR", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LoweredPanicBoundsCC", + auxType: auxPanicBoundsCC, + argLen: 1, + call: true, + reg: regInfo{}, + }, + { + name: "FlagEQ", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagLT_ULT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagLT_UGT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagGT_UGT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagGT_ULT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "MOVBatomicload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVLatomicload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVQatomicload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XCHGB", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AXCHGB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XCHGL", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AXCHGL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XCHGQ", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + faultOnNilArg1: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AXCHGQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XADDLlock", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AXADDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "XADDQlock", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AXADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "AddTupleFirst32", + argLen: 2, + reg: regInfo{}, + }, + { + name: "AddTupleFirst64", + argLen: 2, + reg: regInfo{}, + }, + { + name: "CMPXCHGLlock", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.ACMPXCHGL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1}, // AX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "CMPXCHGQlock", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.ACMPXCHGQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1}, // AX + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + clobbers: 1, // AX + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDBlock", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AANDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDLlock", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDQlock", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORBlock", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AORB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORLlock", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ORQlock", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: x86.AORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "LoweredAtomicAnd64", + auxType: auxSymOff, + argLen: 3, + resultNotInArgs: true, + clobberFlags: true, + needIntTemp: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + symEffect: SymRdWr, + asm: x86.AANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49134}, // CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49134}, // CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 1}, // AX + }, + }, + }, + { + name: "LoweredAtomicAnd32", + auxType: auxSymOff, + argLen: 3, + resultNotInArgs: true, + clobberFlags: true, + needIntTemp: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + symEffect: SymRdWr, + asm: x86.AANDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49134}, // CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49134}, // CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 1}, // AX + }, + }, + }, + { + name: "LoweredAtomicOr64", + auxType: auxSymOff, + argLen: 3, + resultNotInArgs: true, + clobberFlags: true, + needIntTemp: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + symEffect: SymRdWr, + asm: x86.AORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49134}, // CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49134}, // CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 1}, // AX + }, + }, + }, + { + name: "LoweredAtomicOr32", + auxType: auxSymOff, + argLen: 3, + resultNotInArgs: true, + clobberFlags: true, + needIntTemp: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + symEffect: SymRdWr, + asm: x86.AORL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49134}, // CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49134}, // CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 1}, // AX + }, + }, + }, + { + name: "PrefetchT0", + argLen: 2, + hasSideEffects: true, + asm: x86.APREFETCHT0, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "PrefetchNTA", + argLen: 2, + hasSideEffects: true, + asm: x86.APREFETCHNTA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "ANDNQ", + argLen: 2, + clobberFlags: true, + asm: x86.AANDNQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "ANDNL", + argLen: 2, + clobberFlags: true, + asm: x86.AANDNL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BLSIQ", + argLen: 1, + clobberFlags: true, + asm: x86.ABLSIQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BLSIL", + argLen: 1, + clobberFlags: true, + asm: x86.ABLSIL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BLSMSKQ", + argLen: 1, + clobberFlags: true, + asm: x86.ABLSMSKQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BLSMSKL", + argLen: 1, + clobberFlags: true, + asm: x86.ABLSMSKL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BLSRQ", + argLen: 1, + asm: x86.ABLSRQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "BLSRL", + argLen: 1, + asm: x86.ABLSRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "TZCNTQ", + argLen: 1, + clobberFlags: true, + asm: x86.ATZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "TZCNTL", + argLen: 1, + clobberFlags: true, + asm: x86.ATZCNTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LZCNTQ", + argLen: 1, + clobberFlags: true, + asm: x86.ALZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "LZCNTL", + argLen: 1, + clobberFlags: true, + asm: x86.ALZCNTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBEWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVBEW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBELload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVBEL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBELstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVBEL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBEQload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AMOVBEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBEQstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AMOVBEQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBELloadidx1", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.AMOVBEL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBELloadidx4", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVBEL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBELloadidx8", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVBEL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBEQloadidx1", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: x86.AMOVBEQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBEQloadidx8", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AMOVBEQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "MOVBEWstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVBEW, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBEWstoreidx2", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVBEW, + scale: 2, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBELstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVBEL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBELstoreidx4", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVBEL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBELstoreidx8", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVBEL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBEQstoreidx1", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: x86.AMOVBEQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "MOVBEQstoreidx8", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: x86.AMOVBEQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {2, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + }, + }, + { + name: "SARXQ", + argLen: 2, + asm: x86.ASARXQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARXL", + argLen: 2, + asm: x86.ASARXL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLXQ", + argLen: 2, + asm: x86.ASHLXQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLXL", + argLen: 2, + asm: x86.ASHLXL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRXQ", + argLen: 2, + asm: x86.ASHRXQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRXL", + argLen: 2, + asm: x86.ASHRXL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARXLload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASARXL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARXQload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASARXQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLXLload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHLXL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLXQload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHLXQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRXLload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHRXL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRXQload", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHRXQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARXLloadidx1", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASARXL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARXLloadidx4", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASARXL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARXLloadidx8", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASARXL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARXQloadidx1", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASARXQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SARXQloadidx8", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASARXQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLXLloadidx1", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHLXL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLXLloadidx4", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHLXL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLXLloadidx8", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHLXL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLXQloadidx1", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHLXQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHLXQloadidx8", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHLXQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRXLloadidx1", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHRXL, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRXLloadidx4", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHRXL, + scale: 4, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRXLloadidx8", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHRXL, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRXQloadidx1", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHRXQ, + scale: 1, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "SHRXQloadidx8", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.ASHRXQ, + scale: 8, + reg: regInfo{ + inputs: []inputInfo{ + {2, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {1, 49151}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 72057594037993471}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 g R15 SB + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "PUNPCKLBW", + argLen: 2, + resultInArg0: true, + asm: x86.APUNPCKLBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "PSHUFLW", + auxType: auxInt8, + argLen: 1, + asm: x86.APSHUFLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "PSHUFBbroadcast", + argLen: 1, + resultInArg0: true, + asm: x86.APSHUFB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBROADCASTB", + argLen: 1, + asm: x86.AVPBROADCASTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "PSIGNB", + argLen: 2, + resultInArg0: true, + asm: x86.APSIGNB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "PCMPEQB", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: x86.APCMPEQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "PMOVMSKB", + argLen: 1, + asm: x86.APMOVMSKB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VMOVDQUload128", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVDQU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVDQUstore128", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVMOVDQU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VMOVDQUload256", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVDQU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVDQUstore256", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVMOVDQU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VMOVDQUload512", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVDQU64, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVDQUstore512", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVMOVDQU64, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VPMASK32load128", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVPMASKMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMASK32store128", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVPMASKMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VPMASK64load128", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVPMASKMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMASK64store128", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVPMASKMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VPMASK32load256", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVPMASKMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMASK32store256", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVPMASKMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VPMASK64load256", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVPMASKMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMASK64store256", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVPMASKMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VPMASK8load512", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVDQU8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMASK8store512", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVMOVDQU8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VPMASK16load512", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVDQU16, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMASK16store512", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVMOVDQU16, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VPMASK32load512", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVDQU32, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMASK32store512", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVMOVDQU32, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VPMASK64load512", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVDQU64, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMASK64store512", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AVMOVDQU64, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "VPMOVMToVec8x16", + argLen: 1, + asm: x86.AVPMOVM2B, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVMToVec8x32", + argLen: 1, + asm: x86.AVPMOVM2B, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVMToVec8x64", + argLen: 1, + asm: x86.AVPMOVM2B, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVMToVec16x8", + argLen: 1, + asm: x86.AVPMOVM2W, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVMToVec16x16", + argLen: 1, + asm: x86.AVPMOVM2W, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVMToVec16x32", + argLen: 1, + asm: x86.AVPMOVM2W, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVMToVec32x4", + argLen: 1, + asm: x86.AVPMOVM2D, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVMToVec32x8", + argLen: 1, + asm: x86.AVPMOVM2D, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVMToVec32x16", + argLen: 1, + asm: x86.AVPMOVM2D, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVMToVec64x2", + argLen: 1, + asm: x86.AVPMOVM2Q, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVMToVec64x4", + argLen: 1, + asm: x86.AVPMOVM2Q, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVMToVec64x8", + argLen: 1, + asm: x86.AVPMOVM2Q, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVVec8x16ToM", + argLen: 1, + asm: x86.AVPMOVB2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec8x32ToM", + argLen: 1, + asm: x86.AVPMOVB2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec8x64ToM", + argLen: 1, + asm: x86.AVPMOVB2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec16x8ToM", + argLen: 1, + asm: x86.AVPMOVW2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec16x16ToM", + argLen: 1, + asm: x86.AVPMOVW2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec16x32ToM", + argLen: 1, + asm: x86.AVPMOVW2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec32x4ToM", + argLen: 1, + asm: x86.AVPMOVD2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec32x8ToM", + argLen: 1, + asm: x86.AVPMOVD2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec32x16ToM", + argLen: 1, + asm: x86.AVPMOVD2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec64x2ToM", + argLen: 1, + asm: x86.AVPMOVQ2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec64x4ToM", + argLen: 1, + asm: x86.AVPMOVQ2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVVec64x8ToM", + argLen: 1, + asm: x86.AVPMOVQ2M, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPMOVMSKB128", + argLen: 1, + asm: x86.AVPMOVMSKB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VPMOVMSKB256", + argLen: 1, + asm: x86.AVPMOVMSKB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VMOVMSKPS128", + argLen: 1, + asm: x86.AVMOVMSKPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VMOVMSKPS256", + argLen: 1, + asm: x86.AVMOVMSKPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VMOVMSKPD128", + argLen: 1, + asm: x86.AVMOVMSKPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VMOVMSKPD256", + argLen: 1, + asm: x86.AVMOVMSKPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "Zero128", + argLen: 0, + zeroWidth: true, + fixedReg: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 2147483648}, // X15 + }, + }, + }, + { + name: "Zero256", + argLen: 0, + asm: x86.AVPXOR, + reg: regInfo{ + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "Zero512", + argLen: 0, + asm: x86.AVPXORQ, + reg: regInfo{ + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVSDf2v", + argLen: 1, + asm: x86.AVMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVSSf2v", + argLen: 1, + asm: x86.AVMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVQ", + argLen: 1, + asm: x86.AVMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVD", + argLen: 1, + asm: x86.AVMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVQload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVSSload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVSDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AVMOVSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVSSconst", + auxType: auxFloat32, + argLen: 0, + rematerializeable: true, + asm: x86.AVMOVSS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMOVSDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: x86.AVMOVSD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VZEROUPPER", + argLen: 1, + asm: x86.AVZEROUPPER, + reg: regInfo{ + clobbers: 2147418112, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + { + name: "VZEROALL", + argLen: 1, + asm: x86.AVZEROALL, + reg: regInfo{ + clobbers: 2147418112, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + { + name: "KMOVBload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AKMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "KMOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AKMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "KMOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AKMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "KMOVQload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: x86.AKMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "KMOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AKMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "KMOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AKMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "KMOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AKMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "KMOVQstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: x86.AKMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + }, + }, + { + name: "KMOVQk", + argLen: 1, + asm: x86.AKMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "KMOVDk", + argLen: 1, + asm: x86.AKMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "KMOVWk", + argLen: 1, + asm: x86.AKMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "KMOVBk", + argLen: 1, + asm: x86.AKMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "KMOVQi", + argLen: 1, + asm: x86.AKMOVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "KMOVDi", + argLen: 1, + asm: x86.AKMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "KMOVWi", + argLen: 1, + asm: x86.AKMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "KMOVBi", + argLen: 1, + asm: x86.AKMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VPTEST", + argLen: 2, + clobberFlags: true, + asm: x86.AVPTEST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + }, + }, + { + name: "SHA1MSG1128", + argLen: 2, + resultInArg0: true, + asm: x86.ASHA1MSG1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SHA1MSG2128", + argLen: 2, + resultInArg0: true, + asm: x86.ASHA1MSG2, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SHA1NEXTE128", + argLen: 2, + resultInArg0: true, + asm: x86.ASHA1NEXTE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SHA256MSG1128", + argLen: 2, + resultInArg0: true, + asm: x86.ASHA256MSG1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SHA256MSG2128", + argLen: 2, + resultInArg0: true, + asm: x86.ASHA256MSG2, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "SHA256RNDS2128", + argLen: 3, + resultInArg0: true, + asm: x86.ASHA256RNDS2, + reg: regInfo{ + inputs: []inputInfo{ + {2, 65536}, // X0 + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VADDPD128", + argLen: 2, + commutative: true, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VADDPD256", + argLen: 2, + commutative: true, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VADDPD512", + argLen: 2, + commutative: true, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPS128", + argLen: 2, + commutative: true, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VADDPS256", + argLen: 2, + commutative: true, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VADDPS512", + argLen: 2, + commutative: true, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPSMasked128", + argLen: 3, + commutative: true, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPSMasked256", + argLen: 3, + commutative: true, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPSMasked512", + argLen: 3, + commutative: true, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDSUBPD128", + argLen: 2, + asm: x86.AVADDSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VADDSUBPD256", + argLen: 2, + asm: x86.AVADDSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VADDSUBPS128", + argLen: 2, + asm: x86.AVADDSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VADDSUBPS256", + argLen: 2, + asm: x86.AVADDSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VAESDEC128", + argLen: 2, + asm: x86.AVAESDEC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VAESDEC256", + argLen: 2, + asm: x86.AVAESDEC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VAESDEC512", + argLen: 2, + asm: x86.AVAESDEC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VAESDECLAST128", + argLen: 2, + asm: x86.AVAESDECLAST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VAESDECLAST256", + argLen: 2, + asm: x86.AVAESDECLAST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VAESDECLAST512", + argLen: 2, + asm: x86.AVAESDECLAST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VAESENC128", + argLen: 2, + asm: x86.AVAESENC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VAESENC256", + argLen: 2, + asm: x86.AVAESENC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VAESENC512", + argLen: 2, + asm: x86.AVAESENC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VAESENCLAST128", + argLen: 2, + asm: x86.AVAESENCLAST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VAESENCLAST256", + argLen: 2, + asm: x86.AVAESENCLAST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VAESENCLAST512", + argLen: 2, + asm: x86.AVAESENCLAST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VAESIMC128", + argLen: 1, + asm: x86.AVAESIMC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VBROADCASTSD256", + argLen: 1, + asm: x86.AVBROADCASTSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VBROADCASTSD512", + argLen: 1, + asm: x86.AVBROADCASTSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSDMasked256", + argLen: 2, + asm: x86.AVBROADCASTSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSDMasked512", + argLen: 2, + asm: x86.AVBROADCASTSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSS128", + argLen: 1, + asm: x86.AVBROADCASTSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VBROADCASTSS256", + argLen: 1, + asm: x86.AVBROADCASTSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VBROADCASTSS512", + argLen: 1, + asm: x86.AVBROADCASTSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSSMasked128", + argLen: 2, + asm: x86.AVBROADCASTSS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSSMasked256", + argLen: 2, + asm: x86.AVBROADCASTSS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSSMasked512", + argLen: 2, + asm: x86.AVBROADCASTSS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCOMPRESSPDMasked128", + argLen: 2, + asm: x86.AVCOMPRESSPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCOMPRESSPDMasked256", + argLen: 2, + asm: x86.AVCOMPRESSPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCOMPRESSPDMasked512", + argLen: 2, + asm: x86.AVCOMPRESSPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCOMPRESSPSMasked128", + argLen: 2, + asm: x86.AVCOMPRESSPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCOMPRESSPSMasked256", + argLen: 2, + asm: x86.AVCOMPRESSPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCOMPRESSPSMasked512", + argLen: 2, + asm: x86.AVCOMPRESSPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PD256", + argLen: 1, + asm: x86.AVCVTDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCVTDQ2PD512", + argLen: 1, + asm: x86.AVCVTDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PDMasked256", + argLen: 2, + asm: x86.AVCVTDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PDMasked512", + argLen: 2, + asm: x86.AVCVTDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PS128", + argLen: 1, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCVTDQ2PS256", + argLen: 1, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCVTDQ2PS512", + argLen: 1, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PSMasked128", + argLen: 2, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PSMasked256", + argLen: 2, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PSMasked512", + argLen: 2, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PS256", + argLen: 1, + asm: x86.AVCVTPD2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PSMasked256", + argLen: 2, + asm: x86.AVCVTPD2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PSX128", + argLen: 1, + asm: x86.AVCVTPD2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCVTPD2PSXMasked128", + argLen: 2, + asm: x86.AVCVTPD2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PSY128", + argLen: 1, + asm: x86.AVCVTPD2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCVTPD2PSYMasked128", + argLen: 2, + asm: x86.AVCVTPD2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPS2PD256", + argLen: 1, + asm: x86.AVCVTPS2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCVTPS2PD512", + argLen: 1, + asm: x86.AVCVTPS2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPS2PDMasked256", + argLen: 2, + asm: x86.AVCVTPS2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPS2PDMasked512", + argLen: 2, + asm: x86.AVCVTPS2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PD128", + argLen: 1, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PD256", + argLen: 1, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PD512", + argLen: 1, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PDMasked128", + argLen: 2, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PDMasked256", + argLen: 2, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PDMasked512", + argLen: 2, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PS256", + argLen: 1, + asm: x86.AVCVTQQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSMasked256", + argLen: 2, + asm: x86.AVCVTQQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSX128", + argLen: 1, + asm: x86.AVCVTQQ2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSXMasked128", + argLen: 2, + asm: x86.AVCVTQQ2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSY128", + argLen: 1, + asm: x86.AVCVTQQ2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSYMasked128", + argLen: 2, + asm: x86.AVCVTQQ2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQ256", + argLen: 1, + asm: x86.AVCVTTPD2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQMasked256", + argLen: 2, + asm: x86.AVCVTTPD2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQX128", + argLen: 1, + asm: x86.AVCVTTPD2DQX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCVTTPD2DQXMasked128", + argLen: 2, + asm: x86.AVCVTTPD2DQX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQY128", + argLen: 1, + asm: x86.AVCVTTPD2DQY, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCVTTPD2DQYMasked128", + argLen: 2, + asm: x86.AVCVTTPD2DQY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQ128", + argLen: 1, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQ256", + argLen: 1, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQ512", + argLen: 1, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQMasked128", + argLen: 2, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQMasked256", + argLen: 2, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQMasked512", + argLen: 2, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQ256", + argLen: 1, + asm: x86.AVCVTTPD2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQMasked256", + argLen: 2, + asm: x86.AVCVTTPD2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQX128", + argLen: 1, + asm: x86.AVCVTTPD2UDQX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQXMasked128", + argLen: 2, + asm: x86.AVCVTTPD2UDQX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQY128", + argLen: 1, + asm: x86.AVCVTTPD2UDQY, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQYMasked128", + argLen: 2, + asm: x86.AVCVTTPD2UDQY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQ128", + argLen: 1, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQ256", + argLen: 1, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQ512", + argLen: 1, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQMasked128", + argLen: 2, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQMasked256", + argLen: 2, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQMasked512", + argLen: 2, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQ128", + argLen: 1, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCVTTPS2DQ256", + argLen: 1, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCVTTPS2DQ512", + argLen: 1, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQMasked128", + argLen: 2, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQMasked256", + argLen: 2, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQMasked512", + argLen: 2, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2QQ256", + argLen: 1, + asm: x86.AVCVTTPS2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2QQ512", + argLen: 1, + asm: x86.AVCVTTPS2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2QQMasked256", + argLen: 2, + asm: x86.AVCVTTPS2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2QQMasked512", + argLen: 2, + asm: x86.AVCVTTPS2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQ128", + argLen: 1, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQ256", + argLen: 1, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQ512", + argLen: 1, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQMasked128", + argLen: 2, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQMasked256", + argLen: 2, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQMasked512", + argLen: 2, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UQQ256", + argLen: 1, + asm: x86.AVCVTTPS2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UQQ512", + argLen: 1, + asm: x86.AVCVTTPS2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UQQMasked256", + argLen: 2, + asm: x86.AVCVTTPS2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UQQMasked512", + argLen: 2, + asm: x86.AVCVTTPS2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PD256", + argLen: 1, + asm: x86.AVCVTUDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PD512", + argLen: 1, + asm: x86.AVCVTUDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PDMasked256", + argLen: 2, + asm: x86.AVCVTUDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PDMasked512", + argLen: 2, + asm: x86.AVCVTUDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PS128", + argLen: 1, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PS256", + argLen: 1, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PS512", + argLen: 1, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PSMasked128", + argLen: 2, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PSMasked256", + argLen: 2, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PSMasked512", + argLen: 2, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PD128", + argLen: 1, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PD256", + argLen: 1, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PD512", + argLen: 1, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PDMasked128", + argLen: 2, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PDMasked256", + argLen: 2, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PDMasked512", + argLen: 2, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PS256", + argLen: 1, + asm: x86.AVCVTUQQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSMasked256", + argLen: 2, + asm: x86.AVCVTUQQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSX128", + argLen: 1, + asm: x86.AVCVTUQQ2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSXMasked128", + argLen: 2, + asm: x86.AVCVTUQQ2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSY128", + argLen: 1, + asm: x86.AVCVTUQQ2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSYMasked128", + argLen: 2, + asm: x86.AVCVTUQQ2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPD128", + argLen: 2, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VDIVPD256", + argLen: 2, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VDIVPD512", + argLen: 2, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPDMasked128", + argLen: 3, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPDMasked256", + argLen: 3, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPDMasked512", + argLen: 3, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPS128", + argLen: 2, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VDIVPS256", + argLen: 2, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VDIVPS512", + argLen: 2, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPSMasked128", + argLen: 3, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPSMasked256", + argLen: 3, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPSMasked512", + argLen: 3, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VEXPANDPDMasked128", + argLen: 2, + asm: x86.AVEXPANDPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VEXPANDPDMasked256", + argLen: 2, + asm: x86.AVEXPANDPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VEXPANDPDMasked512", + argLen: 2, + asm: x86.AVEXPANDPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VEXPANDPSMasked128", + argLen: 2, + asm: x86.AVEXPANDPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VEXPANDPSMasked256", + argLen: 2, + asm: x86.AVEXPANDPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VEXPANDPSMasked512", + argLen: 2, + asm: x86.AVEXPANDPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PD128", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMADD213PD256", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMADD213PD512", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PDMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PDMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PDMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PS128", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMADD213PS256", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMADD213PS512", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PSMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PSMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PSMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PD128", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADDSUB213PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMADDSUB213PD256", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADDSUB213PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMADDSUB213PD512", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADDSUB213PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PDMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADDSUB213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PDMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADDSUB213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PDMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADDSUB213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PS128", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADDSUB213PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMADDSUB213PS256", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADDSUB213PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMADDSUB213PS512", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMADDSUB213PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PSMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADDSUB213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PSMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADDSUB213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PSMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMADDSUB213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PD128", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMSUBADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMSUBADD213PD256", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMSUBADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMSUBADD213PD512", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMSUBADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PDMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMSUBADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PDMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMSUBADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PDMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMSUBADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PS128", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMSUBADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMSUBADD213PS256", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMSUBADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VFMSUBADD213PS512", + argLen: 3, + resultInArg0: true, + asm: x86.AVFMSUBADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PSMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMSUBADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PSMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMSUBADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PSMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVFMSUBADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8MULB128", + argLen: 2, + asm: x86.AVGF2P8MULB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8MULB256", + argLen: 2, + asm: x86.AVGF2P8MULB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8MULB512", + argLen: 2, + asm: x86.AVGF2P8MULB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8MULBMasked128", + argLen: 3, + asm: x86.AVGF2P8MULB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8MULBMasked256", + argLen: 3, + asm: x86.AVGF2P8MULB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8MULBMasked512", + argLen: 3, + asm: x86.AVGF2P8MULB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VHADDPD128", + argLen: 2, + asm: x86.AVHADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VHADDPD256", + argLen: 2, + asm: x86.AVHADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VHADDPS128", + argLen: 2, + asm: x86.AVHADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VHADDPS256", + argLen: 2, + asm: x86.AVHADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VHSUBPD128", + argLen: 2, + asm: x86.AVHSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VHSUBPD256", + argLen: 2, + asm: x86.AVHSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VHSUBPS128", + argLen: 2, + asm: x86.AVHSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VHSUBPS256", + argLen: 2, + asm: x86.AVHSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMAXPD128", + argLen: 2, + commutative: true, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMAXPD256", + argLen: 2, + commutative: true, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMAXPD512", + argLen: 2, + commutative: true, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPS128", + argLen: 2, + commutative: true, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMAXPS256", + argLen: 2, + commutative: true, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMAXPS512", + argLen: 2, + commutative: true, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPSMasked128", + argLen: 3, + commutative: true, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPSMasked256", + argLen: 3, + commutative: true, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPSMasked512", + argLen: 3, + commutative: true, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPD128", + argLen: 2, + commutative: true, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMINPD256", + argLen: 2, + commutative: true, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMINPD512", + argLen: 2, + commutative: true, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPS128", + argLen: 2, + commutative: true, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMINPS256", + argLen: 2, + commutative: true, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMINPS512", + argLen: 2, + commutative: true, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPSMasked128", + argLen: 3, + commutative: true, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPSMasked256", + argLen: 3, + commutative: true, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPSMasked512", + argLen: 3, + commutative: true, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU8Masked128", + argLen: 2, + asm: x86.AVMOVDQU8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU8Masked256", + argLen: 2, + asm: x86.AVMOVDQU8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU8Masked512", + argLen: 2, + asm: x86.AVMOVDQU8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU16Masked128", + argLen: 2, + asm: x86.AVMOVDQU16, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU16Masked256", + argLen: 2, + asm: x86.AVMOVDQU16, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU16Masked512", + argLen: 2, + asm: x86.AVMOVDQU16, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU32Masked128", + argLen: 2, + asm: x86.AVMOVDQU32, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU32Masked256", + argLen: 2, + asm: x86.AVMOVDQU32, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU32Masked512", + argLen: 2, + asm: x86.AVMOVDQU32, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU64Masked128", + argLen: 2, + asm: x86.AVMOVDQU64, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU64Masked256", + argLen: 2, + asm: x86.AVMOVDQU64, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMOVDQU64Masked512", + argLen: 2, + asm: x86.AVMOVDQU64, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPD128", + argLen: 2, + commutative: true, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMULPD256", + argLen: 2, + commutative: true, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMULPD512", + argLen: 2, + commutative: true, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPS128", + argLen: 2, + commutative: true, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMULPS256", + argLen: 2, + commutative: true, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VMULPS512", + argLen: 2, + commutative: true, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPSMasked128", + argLen: 3, + commutative: true, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPSMasked256", + argLen: 3, + commutative: true, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPSMasked512", + argLen: 3, + commutative: true, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSB128", + argLen: 1, + asm: x86.AVPABSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPABSB256", + argLen: 1, + asm: x86.AVPABSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPABSB512", + argLen: 1, + asm: x86.AVPABSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSBMasked128", + argLen: 2, + asm: x86.AVPABSB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSBMasked256", + argLen: 2, + asm: x86.AVPABSB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSBMasked512", + argLen: 2, + asm: x86.AVPABSB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSD128", + argLen: 1, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPABSD256", + argLen: 1, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPABSD512", + argLen: 1, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSDMasked128", + argLen: 2, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSDMasked256", + argLen: 2, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSDMasked512", + argLen: 2, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQ128", + argLen: 1, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQ256", + argLen: 1, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQ512", + argLen: 1, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQMasked128", + argLen: 2, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQMasked256", + argLen: 2, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQMasked512", + argLen: 2, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSW128", + argLen: 1, + asm: x86.AVPABSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPABSW256", + argLen: 1, + asm: x86.AVPABSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPABSW512", + argLen: 1, + asm: x86.AVPABSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSWMasked128", + argLen: 2, + asm: x86.AVPABSW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSWMasked256", + argLen: 2, + asm: x86.AVPABSW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSWMasked512", + argLen: 2, + asm: x86.AVPABSW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDW128", + argLen: 2, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPACKSSDW256", + argLen: 2, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPACKSSDW512", + argLen: 2, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDWMasked128", + argLen: 3, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDWMasked256", + argLen: 3, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDWMasked512", + argLen: 3, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDW128", + argLen: 2, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPACKUSDW256", + argLen: 2, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPACKUSDW512", + argLen: 2, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDWMasked128", + argLen: 3, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDWMasked256", + argLen: 3, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDWMasked512", + argLen: 3, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDB128", + argLen: 2, + commutative: true, + asm: x86.AVPADDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDB256", + argLen: 2, + commutative: true, + asm: x86.AVPADDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDB512", + argLen: 2, + commutative: true, + asm: x86.AVPADDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDBMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPADDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDBMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPADDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDBMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPADDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDD128", + argLen: 2, + commutative: true, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDD256", + argLen: 2, + commutative: true, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDD512", + argLen: 2, + commutative: true, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQ128", + argLen: 2, + commutative: true, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDQ256", + argLen: 2, + commutative: true, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDQ512", + argLen: 2, + commutative: true, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSB128", + argLen: 2, + commutative: true, + asm: x86.AVPADDSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDSB256", + argLen: 2, + commutative: true, + asm: x86.AVPADDSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDSB512", + argLen: 2, + commutative: true, + asm: x86.AVPADDSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSBMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPADDSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSBMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPADDSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSBMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPADDSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSW128", + argLen: 2, + commutative: true, + asm: x86.AVPADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDSW256", + argLen: 2, + commutative: true, + asm: x86.AVPADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDSW512", + argLen: 2, + commutative: true, + asm: x86.AVPADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSB128", + argLen: 2, + commutative: true, + asm: x86.AVPADDUSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDUSB256", + argLen: 2, + commutative: true, + asm: x86.AVPADDUSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDUSB512", + argLen: 2, + commutative: true, + asm: x86.AVPADDUSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSBMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPADDUSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSBMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPADDUSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSBMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPADDUSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSW128", + argLen: 2, + commutative: true, + asm: x86.AVPADDUSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDUSW256", + argLen: 2, + commutative: true, + asm: x86.AVPADDUSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDUSW512", + argLen: 2, + commutative: true, + asm: x86.AVPADDUSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPADDUSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPADDUSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPADDUSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDW128", + argLen: 2, + commutative: true, + asm: x86.AVPADDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDW256", + argLen: 2, + commutative: true, + asm: x86.AVPADDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPADDW512", + argLen: 2, + commutative: true, + asm: x86.AVPADDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPADDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPADDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPADDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAND128", + argLen: 2, + commutative: true, + asm: x86.AVPAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPAND256", + argLen: 2, + commutative: true, + asm: x86.AVPAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPANDD512", + argLen: 2, + commutative: true, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDN128", + argLen: 2, + asm: x86.AVPANDN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPANDN256", + argLen: 2, + asm: x86.AVPANDN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPANDND512", + argLen: 2, + asm: x86.AVPANDND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNDMasked128", + argLen: 3, + asm: x86.AVPANDND, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNDMasked256", + argLen: 3, + asm: x86.AVPANDND, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNDMasked512", + argLen: 3, + asm: x86.AVPANDND, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNQ512", + argLen: 2, + asm: x86.AVPANDNQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNQMasked128", + argLen: 3, + asm: x86.AVPANDNQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNQMasked256", + argLen: 3, + asm: x86.AVPANDNQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNQMasked512", + argLen: 3, + asm: x86.AVPANDNQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQ512", + argLen: 2, + commutative: true, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGB128", + argLen: 2, + commutative: true, + asm: x86.AVPAVGB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPAVGB256", + argLen: 2, + commutative: true, + asm: x86.AVPAVGB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPAVGB512", + argLen: 2, + commutative: true, + asm: x86.AVPAVGB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGBMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPAVGB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGBMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPAVGB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGBMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPAVGB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGW128", + argLen: 2, + commutative: true, + asm: x86.AVPAVGW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPAVGW256", + argLen: 2, + commutative: true, + asm: x86.AVPAVGW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPAVGW512", + argLen: 2, + commutative: true, + asm: x86.AVPAVGW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPAVGW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPAVGW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPAVGW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBLENDMBMasked512", + argLen: 3, + asm: x86.AVPBLENDMB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBLENDMDMasked512", + argLen: 3, + asm: x86.AVPBLENDMD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBLENDMQMasked512", + argLen: 3, + asm: x86.AVPBLENDMQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBLENDMWMasked512", + argLen: 3, + asm: x86.AVPBLENDMW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBLENDVB128", + argLen: 3, + asm: x86.AVPBLENDVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBLENDVB256", + argLen: 3, + asm: x86.AVPBLENDVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBROADCASTB128", + argLen: 1, + asm: x86.AVPBROADCASTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBROADCASTB256", + argLen: 1, + asm: x86.AVPBROADCASTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBROADCASTB512", + argLen: 1, + asm: x86.AVPBROADCASTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTBMasked128", + argLen: 2, + asm: x86.AVPBROADCASTB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTBMasked256", + argLen: 2, + asm: x86.AVPBROADCASTB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTBMasked512", + argLen: 2, + asm: x86.AVPBROADCASTB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTD128", + argLen: 1, + asm: x86.AVPBROADCASTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBROADCASTD256", + argLen: 1, + asm: x86.AVPBROADCASTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBROADCASTD512", + argLen: 1, + asm: x86.AVPBROADCASTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTDMasked128", + argLen: 2, + asm: x86.AVPBROADCASTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTDMasked256", + argLen: 2, + asm: x86.AVPBROADCASTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTDMasked512", + argLen: 2, + asm: x86.AVPBROADCASTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTQ128", + argLen: 1, + asm: x86.AVPBROADCASTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBROADCASTQ256", + argLen: 1, + asm: x86.AVPBROADCASTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBROADCASTQ512", + argLen: 1, + asm: x86.AVPBROADCASTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTQMasked128", + argLen: 2, + asm: x86.AVPBROADCASTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTQMasked256", + argLen: 2, + asm: x86.AVPBROADCASTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTQMasked512", + argLen: 2, + asm: x86.AVPBROADCASTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTW128", + argLen: 1, + asm: x86.AVPBROADCASTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBROADCASTW256", + argLen: 1, + asm: x86.AVPBROADCASTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPBROADCASTW512", + argLen: 1, + asm: x86.AVPBROADCASTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTWMasked128", + argLen: 2, + asm: x86.AVPBROADCASTW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTWMasked256", + argLen: 2, + asm: x86.AVPBROADCASTW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTWMasked512", + argLen: 2, + asm: x86.AVPBROADCASTW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCMPEQB128", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPEQB256", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPEQB512", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPEQD128", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPEQD256", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPEQD512", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPEQQ128", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPEQQ256", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPEQQ512", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPEQW128", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPEQW256", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPEQW512", + argLen: 2, + commutative: true, + asm: x86.AVPCMPEQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPGTB128", + argLen: 2, + asm: x86.AVPCMPGTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPGTB256", + argLen: 2, + asm: x86.AVPCMPGTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPGTB512", + argLen: 2, + asm: x86.AVPCMPGTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPGTD128", + argLen: 2, + asm: x86.AVPCMPGTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPGTD256", + argLen: 2, + asm: x86.AVPCMPGTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPGTD512", + argLen: 2, + asm: x86.AVPCMPGTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPGTQ128", + argLen: 2, + asm: x86.AVPCMPGTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPGTQ256", + argLen: 2, + asm: x86.AVPCMPGTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPGTQ512", + argLen: 2, + asm: x86.AVPCMPGTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPGTW128", + argLen: 2, + asm: x86.AVPCMPGTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPGTW256", + argLen: 2, + asm: x86.AVPCMPGTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCMPGTW512", + argLen: 2, + asm: x86.AVPCMPGTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCOMPRESSBMasked128", + argLen: 2, + asm: x86.AVPCOMPRESSB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSBMasked256", + argLen: 2, + asm: x86.AVPCOMPRESSB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSBMasked512", + argLen: 2, + asm: x86.AVPCOMPRESSB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSDMasked128", + argLen: 2, + asm: x86.AVPCOMPRESSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSDMasked256", + argLen: 2, + asm: x86.AVPCOMPRESSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSDMasked512", + argLen: 2, + asm: x86.AVPCOMPRESSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSQMasked128", + argLen: 2, + asm: x86.AVPCOMPRESSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSQMasked256", + argLen: 2, + asm: x86.AVPCOMPRESSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSQMasked512", + argLen: 2, + asm: x86.AVPCOMPRESSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSWMasked128", + argLen: 2, + asm: x86.AVPCOMPRESSW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSWMasked256", + argLen: 2, + asm: x86.AVPCOMPRESSW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCOMPRESSWMasked512", + argLen: 2, + asm: x86.AVPCOMPRESSW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPDPWSSD128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPDPWSSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPDPWSSD256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPDPWSSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + {2, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPDPWSSD512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPDPWSSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPDPWSSDMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPDPWSSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPDPWSSDMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPDPWSSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPDPWSSDMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPDPWSSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMB128", + argLen: 2, + asm: x86.AVPERMB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMB256", + argLen: 2, + asm: x86.AVPERMB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMB512", + argLen: 2, + asm: x86.AVPERMB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMBMasked128", + argLen: 3, + asm: x86.AVPERMB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMBMasked256", + argLen: 3, + asm: x86.AVPERMB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMBMasked512", + argLen: 3, + asm: x86.AVPERMB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMD256", + argLen: 2, + asm: x86.AVPERMD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPERMD512", + argLen: 2, + asm: x86.AVPERMD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMDMasked256", + argLen: 3, + asm: x86.AVPERMD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMDMasked512", + argLen: 3, + asm: x86.AVPERMD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2B128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2B, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2B256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2B, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2B512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2B, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2BMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2B, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2BMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2B, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2BMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2B, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2D128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2D256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2D512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2DMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2DMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2DMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PD128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PD256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PD512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PDMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PDMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PDMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PS128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PS256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PS512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PSMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PSMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PSMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2Q128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2Q256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2Q512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2QMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2QMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2QMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2W128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2W, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2W256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2W, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2W512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPERMI2W, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2WMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2W, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2WMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2W, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2WMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPERMI2W, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPD256", + argLen: 2, + asm: x86.AVPERMPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPD512", + argLen: 2, + asm: x86.AVPERMPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPDMasked256", + argLen: 3, + asm: x86.AVPERMPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPDMasked512", + argLen: 3, + asm: x86.AVPERMPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPS256", + argLen: 2, + asm: x86.AVPERMPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPERMPS512", + argLen: 2, + asm: x86.AVPERMPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPSMasked256", + argLen: 3, + asm: x86.AVPERMPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPSMasked512", + argLen: 3, + asm: x86.AVPERMPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMQ256", + argLen: 2, + asm: x86.AVPERMQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMQ512", + argLen: 2, + asm: x86.AVPERMQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMQMasked256", + argLen: 3, + asm: x86.AVPERMQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMQMasked512", + argLen: 3, + asm: x86.AVPERMQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMW128", + argLen: 2, + asm: x86.AVPERMW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMW256", + argLen: 2, + asm: x86.AVPERMW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMW512", + argLen: 2, + asm: x86.AVPERMW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMWMasked128", + argLen: 3, + asm: x86.AVPERMW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMWMasked256", + argLen: 3, + asm: x86.AVPERMW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMWMasked512", + argLen: 3, + asm: x86.AVPERMW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDBMasked128", + argLen: 2, + asm: x86.AVPEXPANDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDBMasked256", + argLen: 2, + asm: x86.AVPEXPANDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDBMasked512", + argLen: 2, + asm: x86.AVPEXPANDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDDMasked128", + argLen: 2, + asm: x86.AVPEXPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDDMasked256", + argLen: 2, + asm: x86.AVPEXPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDDMasked512", + argLen: 2, + asm: x86.AVPEXPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDQMasked128", + argLen: 2, + asm: x86.AVPEXPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDQMasked256", + argLen: 2, + asm: x86.AVPEXPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDQMasked512", + argLen: 2, + asm: x86.AVPEXPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDWMasked128", + argLen: 2, + asm: x86.AVPEXPANDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDWMasked256", + argLen: 2, + asm: x86.AVPEXPANDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPEXPANDWMasked512", + argLen: 2, + asm: x86.AVPEXPANDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPHADDD128", + argLen: 2, + asm: x86.AVPHADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHADDD256", + argLen: 2, + asm: x86.AVPHADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHADDSW128", + argLen: 2, + asm: x86.AVPHADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHADDSW256", + argLen: 2, + asm: x86.AVPHADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHADDW128", + argLen: 2, + asm: x86.AVPHADDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHADDW256", + argLen: 2, + asm: x86.AVPHADDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHSUBD128", + argLen: 2, + asm: x86.AVPHSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHSUBD256", + argLen: 2, + asm: x86.AVPHSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHSUBSW128", + argLen: 2, + asm: x86.AVPHSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHSUBSW256", + argLen: 2, + asm: x86.AVPHSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHSUBW128", + argLen: 2, + asm: x86.AVPHSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPHSUBW256", + argLen: 2, + asm: x86.AVPHSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPLZCNTD128", + argLen: 1, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTD256", + argLen: 1, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTD512", + argLen: 1, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTDMasked128", + argLen: 2, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTDMasked256", + argLen: 2, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTDMasked512", + argLen: 2, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQ128", + argLen: 1, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQ256", + argLen: 1, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQ512", + argLen: 1, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQMasked128", + argLen: 2, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQMasked256", + argLen: 2, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQMasked512", + argLen: 2, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDUBSW128", + argLen: 2, + asm: x86.AVPMADDUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMADDUBSW256", + argLen: 2, + asm: x86.AVPMADDUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMADDUBSW512", + argLen: 2, + asm: x86.AVPMADDUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDUBSWMasked128", + argLen: 3, + asm: x86.AVPMADDUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDUBSWMasked256", + argLen: 3, + asm: x86.AVPMADDUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDUBSWMasked512", + argLen: 3, + asm: x86.AVPMADDUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDWD128", + argLen: 2, + asm: x86.AVPMADDWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMADDWD256", + argLen: 2, + asm: x86.AVPMADDWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMADDWD512", + argLen: 2, + asm: x86.AVPMADDWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDWDMasked128", + argLen: 3, + asm: x86.AVPMADDWD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDWDMasked256", + argLen: 3, + asm: x86.AVPMADDWD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDWDMasked512", + argLen: 3, + asm: x86.AVPMADDWD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSB128", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXSB256", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXSB512", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSBMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSBMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSBMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSD128", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXSD256", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXSD512", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQ128", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQ256", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQ512", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSW128", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXSW256", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXSW512", + argLen: 2, + commutative: true, + asm: x86.AVPMAXSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMAXSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUB128", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXUB256", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXUB512", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUBMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUBMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUBMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUD128", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXUD256", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXUD512", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQ128", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQ256", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQ512", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUW128", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXUW256", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMAXUW512", + argLen: 2, + commutative: true, + asm: x86.AVPMAXUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMAXUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSB128", + argLen: 2, + commutative: true, + asm: x86.AVPMINSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINSB256", + argLen: 2, + commutative: true, + asm: x86.AVPMINSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINSB512", + argLen: 2, + commutative: true, + asm: x86.AVPMINSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSBMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMINSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSBMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMINSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSBMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMINSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSD128", + argLen: 2, + commutative: true, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINSD256", + argLen: 2, + commutative: true, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINSD512", + argLen: 2, + commutative: true, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQ128", + argLen: 2, + commutative: true, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQ256", + argLen: 2, + commutative: true, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQ512", + argLen: 2, + commutative: true, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSW128", + argLen: 2, + commutative: true, + asm: x86.AVPMINSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINSW256", + argLen: 2, + commutative: true, + asm: x86.AVPMINSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINSW512", + argLen: 2, + commutative: true, + asm: x86.AVPMINSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMINSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMINSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMINSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUB128", + argLen: 2, + commutative: true, + asm: x86.AVPMINUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINUB256", + argLen: 2, + commutative: true, + asm: x86.AVPMINUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINUB512", + argLen: 2, + commutative: true, + asm: x86.AVPMINUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUBMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMINUB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUBMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMINUB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUBMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMINUB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUD128", + argLen: 2, + commutative: true, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINUD256", + argLen: 2, + commutative: true, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINUD512", + argLen: 2, + commutative: true, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQ128", + argLen: 2, + commutative: true, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQ256", + argLen: 2, + commutative: true, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQ512", + argLen: 2, + commutative: true, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUW128", + argLen: 2, + commutative: true, + asm: x86.AVPMINUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINUW256", + argLen: 2, + commutative: true, + asm: x86.AVPMINUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMINUW512", + argLen: 2, + commutative: true, + asm: x86.AVPMINUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMINUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMINUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMINUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDB128_128", + argLen: 1, + asm: x86.AVPMOVDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDB128_256", + argLen: 1, + asm: x86.AVPMOVDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDB128_512", + argLen: 1, + asm: x86.AVPMOVDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDBMasked128_128", + argLen: 2, + asm: x86.AVPMOVDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDBMasked128_256", + argLen: 2, + asm: x86.AVPMOVDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDBMasked128_512", + argLen: 2, + asm: x86.AVPMOVDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDW128_128", + argLen: 1, + asm: x86.AVPMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDW128_256", + argLen: 1, + asm: x86.AVPMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDW256", + argLen: 1, + asm: x86.AVPMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDWMasked128_128", + argLen: 2, + asm: x86.AVPMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDWMasked128_256", + argLen: 2, + asm: x86.AVPMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDWMasked256", + argLen: 2, + asm: x86.AVPMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQB128_128", + argLen: 1, + asm: x86.AVPMOVQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQB128_256", + argLen: 1, + asm: x86.AVPMOVQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQB128_512", + argLen: 1, + asm: x86.AVPMOVQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQBMasked128_128", + argLen: 2, + asm: x86.AVPMOVQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQBMasked128_256", + argLen: 2, + asm: x86.AVPMOVQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQBMasked128_512", + argLen: 2, + asm: x86.AVPMOVQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQD128_128", + argLen: 1, + asm: x86.AVPMOVQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQD128_256", + argLen: 1, + asm: x86.AVPMOVQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQD256", + argLen: 1, + asm: x86.AVPMOVQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQDMasked128_128", + argLen: 2, + asm: x86.AVPMOVQD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQDMasked128_256", + argLen: 2, + asm: x86.AVPMOVQD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQDMasked256", + argLen: 2, + asm: x86.AVPMOVQD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQW128_128", + argLen: 1, + asm: x86.AVPMOVQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQW128_256", + argLen: 1, + asm: x86.AVPMOVQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQW128_512", + argLen: 1, + asm: x86.AVPMOVQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQWMasked128_128", + argLen: 2, + asm: x86.AVPMOVQW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQWMasked128_256", + argLen: 2, + asm: x86.AVPMOVQW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQWMasked128_512", + argLen: 2, + asm: x86.AVPMOVQW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDB128_128", + argLen: 1, + asm: x86.AVPMOVSDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDB128_256", + argLen: 1, + asm: x86.AVPMOVSDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDB128_512", + argLen: 1, + asm: x86.AVPMOVSDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDBMasked128_128", + argLen: 2, + asm: x86.AVPMOVSDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDBMasked128_256", + argLen: 2, + asm: x86.AVPMOVSDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDBMasked128_512", + argLen: 2, + asm: x86.AVPMOVSDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDW128_128", + argLen: 1, + asm: x86.AVPMOVSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDW128_256", + argLen: 1, + asm: x86.AVPMOVSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDW256", + argLen: 1, + asm: x86.AVPMOVSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDWMasked128_128", + argLen: 2, + asm: x86.AVPMOVSDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDWMasked128_256", + argLen: 2, + asm: x86.AVPMOVSDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDWMasked256", + argLen: 2, + asm: x86.AVPMOVSDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQB128_128", + argLen: 1, + asm: x86.AVPMOVSQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQB128_256", + argLen: 1, + asm: x86.AVPMOVSQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQB128_512", + argLen: 1, + asm: x86.AVPMOVSQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQBMasked128_128", + argLen: 2, + asm: x86.AVPMOVSQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQBMasked128_256", + argLen: 2, + asm: x86.AVPMOVSQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQBMasked128_512", + argLen: 2, + asm: x86.AVPMOVSQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQD128_128", + argLen: 1, + asm: x86.AVPMOVSQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQD128_256", + argLen: 1, + asm: x86.AVPMOVSQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQD256", + argLen: 1, + asm: x86.AVPMOVSQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQDMasked128_128", + argLen: 2, + asm: x86.AVPMOVSQD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQDMasked128_256", + argLen: 2, + asm: x86.AVPMOVSQD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQDMasked256", + argLen: 2, + asm: x86.AVPMOVSQD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQW128_128", + argLen: 1, + asm: x86.AVPMOVSQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQW128_256", + argLen: 1, + asm: x86.AVPMOVSQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQW128_512", + argLen: 1, + asm: x86.AVPMOVSQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQWMasked128_128", + argLen: 2, + asm: x86.AVPMOVSQW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQWMasked128_256", + argLen: 2, + asm: x86.AVPMOVSQW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQWMasked128_512", + argLen: 2, + asm: x86.AVPMOVSQW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSWB128_128", + argLen: 1, + asm: x86.AVPMOVSWB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSWB128_256", + argLen: 1, + asm: x86.AVPMOVSWB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSWB256", + argLen: 1, + asm: x86.AVPMOVSWB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSWBMasked128_128", + argLen: 2, + asm: x86.AVPMOVSWB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSWBMasked128_256", + argLen: 2, + asm: x86.AVPMOVSWB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSWBMasked256", + argLen: 2, + asm: x86.AVPMOVSWB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBD128", + argLen: 1, + asm: x86.AVPMOVSXBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXBD256", + argLen: 1, + asm: x86.AVPMOVSXBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXBD512", + argLen: 1, + asm: x86.AVPMOVSXBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBDMasked128", + argLen: 2, + asm: x86.AVPMOVSXBD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBDMasked256", + argLen: 2, + asm: x86.AVPMOVSXBD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBDMasked512", + argLen: 2, + asm: x86.AVPMOVSXBD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBQ128", + argLen: 1, + asm: x86.AVPMOVSXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXBQ256", + argLen: 1, + asm: x86.AVPMOVSXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXBQ512", + argLen: 1, + asm: x86.AVPMOVSXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBQMasked128", + argLen: 2, + asm: x86.AVPMOVSXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBQMasked256", + argLen: 2, + asm: x86.AVPMOVSXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBQMasked512", + argLen: 2, + asm: x86.AVPMOVSXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBW128", + argLen: 1, + asm: x86.AVPMOVSXBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXBW256", + argLen: 1, + asm: x86.AVPMOVSXBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXBW512", + argLen: 1, + asm: x86.AVPMOVSXBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBWMasked128", + argLen: 2, + asm: x86.AVPMOVSXBW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBWMasked256", + argLen: 2, + asm: x86.AVPMOVSXBW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBWMasked512", + argLen: 2, + asm: x86.AVPMOVSXBW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXDQ128", + argLen: 1, + asm: x86.AVPMOVSXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXDQ256", + argLen: 1, + asm: x86.AVPMOVSXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXDQ512", + argLen: 1, + asm: x86.AVPMOVSXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXDQMasked128", + argLen: 2, + asm: x86.AVPMOVSXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXDQMasked256", + argLen: 2, + asm: x86.AVPMOVSXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXDQMasked512", + argLen: 2, + asm: x86.AVPMOVSXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWD128", + argLen: 1, + asm: x86.AVPMOVSXWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXWD256", + argLen: 1, + asm: x86.AVPMOVSXWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXWD512", + argLen: 1, + asm: x86.AVPMOVSXWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWDMasked128", + argLen: 2, + asm: x86.AVPMOVSXWD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWDMasked256", + argLen: 2, + asm: x86.AVPMOVSXWD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWDMasked512", + argLen: 2, + asm: x86.AVPMOVSXWD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWQ128", + argLen: 1, + asm: x86.AVPMOVSXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXWQ256", + argLen: 1, + asm: x86.AVPMOVSXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVSXWQ512", + argLen: 1, + asm: x86.AVPMOVSXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWQMasked128", + argLen: 2, + asm: x86.AVPMOVSXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWQMasked256", + argLen: 2, + asm: x86.AVPMOVSXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWQMasked512", + argLen: 2, + asm: x86.AVPMOVSXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDB128_128", + argLen: 1, + asm: x86.AVPMOVUSDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDB128_256", + argLen: 1, + asm: x86.AVPMOVUSDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDB128_512", + argLen: 1, + asm: x86.AVPMOVUSDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDBMasked128_128", + argLen: 2, + asm: x86.AVPMOVUSDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDBMasked128_256", + argLen: 2, + asm: x86.AVPMOVUSDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDBMasked128_512", + argLen: 2, + asm: x86.AVPMOVUSDB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDW128_128", + argLen: 1, + asm: x86.AVPMOVUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDW128_256", + argLen: 1, + asm: x86.AVPMOVUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDW256", + argLen: 1, + asm: x86.AVPMOVUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDWMasked128_128", + argLen: 2, + asm: x86.AVPMOVUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDWMasked128_256", + argLen: 2, + asm: x86.AVPMOVUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDWMasked256", + argLen: 2, + asm: x86.AVPMOVUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQB128_128", + argLen: 1, + asm: x86.AVPMOVUSQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQB128_256", + argLen: 1, + asm: x86.AVPMOVUSQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQB128_512", + argLen: 1, + asm: x86.AVPMOVUSQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQBMasked128_128", + argLen: 2, + asm: x86.AVPMOVUSQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQBMasked128_256", + argLen: 2, + asm: x86.AVPMOVUSQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQBMasked128_512", + argLen: 2, + asm: x86.AVPMOVUSQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQD128_128", + argLen: 1, + asm: x86.AVPMOVUSQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQD128_256", + argLen: 1, + asm: x86.AVPMOVUSQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQD256", + argLen: 1, + asm: x86.AVPMOVUSQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQDMasked128_128", + argLen: 2, + asm: x86.AVPMOVUSQD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQDMasked128_256", + argLen: 2, + asm: x86.AVPMOVUSQD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQDMasked256", + argLen: 2, + asm: x86.AVPMOVUSQD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQW128_128", + argLen: 1, + asm: x86.AVPMOVUSQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQW128_256", + argLen: 1, + asm: x86.AVPMOVUSQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQW128_512", + argLen: 1, + asm: x86.AVPMOVUSQW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQWMasked128_128", + argLen: 2, + asm: x86.AVPMOVUSQW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQWMasked128_256", + argLen: 2, + asm: x86.AVPMOVUSQW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQWMasked128_512", + argLen: 2, + asm: x86.AVPMOVUSQW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSWB128_128", + argLen: 1, + asm: x86.AVPMOVUSWB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSWB128_256", + argLen: 1, + asm: x86.AVPMOVUSWB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSWB256", + argLen: 1, + asm: x86.AVPMOVUSWB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSWBMasked128_128", + argLen: 2, + asm: x86.AVPMOVUSWB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSWBMasked128_256", + argLen: 2, + asm: x86.AVPMOVUSWB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSWBMasked256", + argLen: 2, + asm: x86.AVPMOVUSWB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVWB128_128", + argLen: 1, + asm: x86.AVPMOVWB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVWB128_256", + argLen: 1, + asm: x86.AVPMOVWB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVWB256", + argLen: 1, + asm: x86.AVPMOVWB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVWBMasked128_128", + argLen: 2, + asm: x86.AVPMOVWB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVWBMasked128_256", + argLen: 2, + asm: x86.AVPMOVWB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVWBMasked256", + argLen: 2, + asm: x86.AVPMOVWB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBD128", + argLen: 1, + asm: x86.AVPMOVZXBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXBD256", + argLen: 1, + asm: x86.AVPMOVZXBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXBD512", + argLen: 1, + asm: x86.AVPMOVZXBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBDMasked128", + argLen: 2, + asm: x86.AVPMOVZXBD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBDMasked256", + argLen: 2, + asm: x86.AVPMOVZXBD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBDMasked512", + argLen: 2, + asm: x86.AVPMOVZXBD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBQ128", + argLen: 1, + asm: x86.AVPMOVZXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXBQ256", + argLen: 1, + asm: x86.AVPMOVZXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXBQ512", + argLen: 1, + asm: x86.AVPMOVZXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBQMasked128", + argLen: 2, + asm: x86.AVPMOVZXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBQMasked256", + argLen: 2, + asm: x86.AVPMOVZXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBQMasked512", + argLen: 2, + asm: x86.AVPMOVZXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBW128", + argLen: 1, + asm: x86.AVPMOVZXBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXBW256", + argLen: 1, + asm: x86.AVPMOVZXBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXBW512", + argLen: 1, + asm: x86.AVPMOVZXBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBWMasked128", + argLen: 2, + asm: x86.AVPMOVZXBW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBWMasked256", + argLen: 2, + asm: x86.AVPMOVZXBW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBWMasked512", + argLen: 2, + asm: x86.AVPMOVZXBW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXDQ128", + argLen: 1, + asm: x86.AVPMOVZXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXDQ256", + argLen: 1, + asm: x86.AVPMOVZXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXDQ512", + argLen: 1, + asm: x86.AVPMOVZXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXDQMasked128", + argLen: 2, + asm: x86.AVPMOVZXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXDQMasked256", + argLen: 2, + asm: x86.AVPMOVZXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXDQMasked512", + argLen: 2, + asm: x86.AVPMOVZXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWD128", + argLen: 1, + asm: x86.AVPMOVZXWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXWD256", + argLen: 1, + asm: x86.AVPMOVZXWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXWD512", + argLen: 1, + asm: x86.AVPMOVZXWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWDMasked128", + argLen: 2, + asm: x86.AVPMOVZXWD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWDMasked256", + argLen: 2, + asm: x86.AVPMOVZXWD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWDMasked512", + argLen: 2, + asm: x86.AVPMOVZXWD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWQ128", + argLen: 1, + asm: x86.AVPMOVZXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXWQ256", + argLen: 1, + asm: x86.AVPMOVZXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMOVZXWQ512", + argLen: 1, + asm: x86.AVPMOVZXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWQMasked128", + argLen: 2, + asm: x86.AVPMOVZXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWQMasked256", + argLen: 2, + asm: x86.AVPMOVZXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWQMasked512", + argLen: 2, + asm: x86.AVPMOVZXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULDQ128", + argLen: 2, + commutative: true, + asm: x86.AVPMULDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULDQ256", + argLen: 2, + commutative: true, + asm: x86.AVPMULDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULHUW128", + argLen: 2, + commutative: true, + asm: x86.AVPMULHUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULHUW256", + argLen: 2, + commutative: true, + asm: x86.AVPMULHUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULHUW512", + argLen: 2, + commutative: true, + asm: x86.AVPMULHUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHUWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMULHUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHUWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMULHUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHUWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMULHUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHW128", + argLen: 2, + commutative: true, + asm: x86.AVPMULHW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULHW256", + argLen: 2, + commutative: true, + asm: x86.AVPMULHW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULHW512", + argLen: 2, + commutative: true, + asm: x86.AVPMULHW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMULHW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMULHW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMULHW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLD128", + argLen: 2, + commutative: true, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULLD256", + argLen: 2, + commutative: true, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULLD512", + argLen: 2, + commutative: true, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQ128", + argLen: 2, + commutative: true, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQ256", + argLen: 2, + commutative: true, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQ512", + argLen: 2, + commutative: true, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLW128", + argLen: 2, + commutative: true, + asm: x86.AVPMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULLW256", + argLen: 2, + commutative: true, + asm: x86.AVPMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULLW512", + argLen: 2, + commutative: true, + asm: x86.AVPMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLWMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLWMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLWMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULUDQ128", + argLen: 2, + commutative: true, + asm: x86.AVPMULUDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPMULUDQ256", + argLen: 2, + commutative: true, + asm: x86.AVPMULUDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPOPCNTB128", + argLen: 1, + asm: x86.AVPOPCNTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTB256", + argLen: 1, + asm: x86.AVPOPCNTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTB512", + argLen: 1, + asm: x86.AVPOPCNTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTBMasked128", + argLen: 2, + asm: x86.AVPOPCNTB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTBMasked256", + argLen: 2, + asm: x86.AVPOPCNTB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTBMasked512", + argLen: 2, + asm: x86.AVPOPCNTB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTD128", + argLen: 1, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTD256", + argLen: 1, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTD512", + argLen: 1, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTDMasked128", + argLen: 2, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTDMasked256", + argLen: 2, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTDMasked512", + argLen: 2, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQ128", + argLen: 1, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQ256", + argLen: 1, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQ512", + argLen: 1, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQMasked128", + argLen: 2, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQMasked256", + argLen: 2, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQMasked512", + argLen: 2, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTW128", + argLen: 1, + asm: x86.AVPOPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTW256", + argLen: 1, + asm: x86.AVPOPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTW512", + argLen: 1, + asm: x86.AVPOPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTWMasked128", + argLen: 2, + asm: x86.AVPOPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTWMasked256", + argLen: 2, + asm: x86.AVPOPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTWMasked512", + argLen: 2, + asm: x86.AVPOPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOR128", + argLen: 2, + commutative: true, + asm: x86.AVPOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPOR256", + argLen: 2, + commutative: true, + asm: x86.AVPOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPORD512", + argLen: 2, + commutative: true, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQ512", + argLen: 2, + commutative: true, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVD128", + argLen: 2, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVD256", + argLen: 2, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVD512", + argLen: 2, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVDMasked128", + argLen: 3, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVDMasked256", + argLen: 3, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVDMasked512", + argLen: 3, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQ128", + argLen: 2, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQ256", + argLen: 2, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQ512", + argLen: 2, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQMasked128", + argLen: 3, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQMasked256", + argLen: 3, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQMasked512", + argLen: 3, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVD128", + argLen: 2, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVD256", + argLen: 2, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVD512", + argLen: 2, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVDMasked128", + argLen: 3, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVDMasked256", + argLen: 3, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVDMasked512", + argLen: 3, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQ128", + argLen: 2, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQ256", + argLen: 2, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQ512", + argLen: 2, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQMasked128", + argLen: 3, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQMasked256", + argLen: 3, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQMasked512", + argLen: 3, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSADBW128", + argLen: 2, + asm: x86.AVPSADBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSADBW256", + argLen: 2, + asm: x86.AVPSADBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSADBW512", + argLen: 2, + asm: x86.AVPSADBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVD128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVD256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVD512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVDMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVDMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVDMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQ128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQ256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQ512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVW128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHLDVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVW256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHLDVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVW512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHLDVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVWMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVWMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVWMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVD128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVD256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVD512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVDMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVDMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVDMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQ128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQ256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQ512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVW128", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHRDVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVW256", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHRDVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVW512", + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHRDVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVWMasked128", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVWMasked256", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVWMasked512", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFB128", + argLen: 2, + asm: x86.AVPSHUFB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSHUFB256", + argLen: 2, + asm: x86.AVPSHUFB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSHUFB512", + argLen: 2, + asm: x86.AVPSHUFB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFBMasked128", + argLen: 3, + asm: x86.AVPSHUFB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFBMasked256", + argLen: 3, + asm: x86.AVPSHUFB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFBMasked512", + argLen: 3, + asm: x86.AVPSHUFB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSIGNB128", + argLen: 2, + asm: x86.AVPSIGNB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSIGNB256", + argLen: 2, + asm: x86.AVPSIGNB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSIGND128", + argLen: 2, + asm: x86.AVPSIGND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSIGND256", + argLen: 2, + asm: x86.AVPSIGND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSIGNW128", + argLen: 2, + asm: x86.AVPSIGNW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSIGNW256", + argLen: 2, + asm: x86.AVPSIGNW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLD128", + argLen: 2, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLD256", + argLen: 2, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLD512", + argLen: 2, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked128", + argLen: 3, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked256", + argLen: 3, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked512", + argLen: 3, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQ128", + argLen: 2, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLQ256", + argLen: 2, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLQ512", + argLen: 2, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked128", + argLen: 3, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked256", + argLen: 3, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked512", + argLen: 3, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVD128", + argLen: 2, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLVD256", + argLen: 2, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLVD512", + argLen: 2, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVDMasked128", + argLen: 3, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVDMasked256", + argLen: 3, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVDMasked512", + argLen: 3, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQ128", + argLen: 2, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLVQ256", + argLen: 2, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLVQ512", + argLen: 2, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQMasked128", + argLen: 3, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQMasked256", + argLen: 3, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQMasked512", + argLen: 3, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVW128", + argLen: 2, + asm: x86.AVPSLLVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVW256", + argLen: 2, + asm: x86.AVPSLLVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVW512", + argLen: 2, + asm: x86.AVPSLLVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVWMasked128", + argLen: 3, + asm: x86.AVPSLLVW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVWMasked256", + argLen: 3, + asm: x86.AVPSLLVW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVWMasked512", + argLen: 3, + asm: x86.AVPSLLVW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLW128", + argLen: 2, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLW256", + argLen: 2, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLW512", + argLen: 2, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLWMasked128", + argLen: 3, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLWMasked256", + argLen: 3, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLWMasked512", + argLen: 3, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAD128", + argLen: 2, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRAD256", + argLen: 2, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRAD512", + argLen: 2, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked128", + argLen: 3, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked256", + argLen: 3, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked512", + argLen: 3, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQ128", + argLen: 2, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQ256", + argLen: 2, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQ512", + argLen: 2, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked128", + argLen: 3, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked256", + argLen: 3, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked512", + argLen: 3, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVD128", + argLen: 2, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRAVD256", + argLen: 2, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRAVD512", + argLen: 2, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVDMasked128", + argLen: 3, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVDMasked256", + argLen: 3, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVDMasked512", + argLen: 3, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQ128", + argLen: 2, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQ256", + argLen: 2, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQ512", + argLen: 2, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQMasked128", + argLen: 3, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQMasked256", + argLen: 3, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQMasked512", + argLen: 3, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVW128", + argLen: 2, + asm: x86.AVPSRAVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVW256", + argLen: 2, + asm: x86.AVPSRAVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVW512", + argLen: 2, + asm: x86.AVPSRAVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVWMasked128", + argLen: 3, + asm: x86.AVPSRAVW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVWMasked256", + argLen: 3, + asm: x86.AVPSRAVW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVWMasked512", + argLen: 3, + asm: x86.AVPSRAVW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAW128", + argLen: 2, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRAW256", + argLen: 2, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRAW512", + argLen: 2, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAWMasked128", + argLen: 3, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAWMasked256", + argLen: 3, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAWMasked512", + argLen: 3, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLD128", + argLen: 2, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLD256", + argLen: 2, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLD512", + argLen: 2, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked128", + argLen: 3, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked256", + argLen: 3, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked512", + argLen: 3, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQ128", + argLen: 2, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLQ256", + argLen: 2, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLQ512", + argLen: 2, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked128", + argLen: 3, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked256", + argLen: 3, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked512", + argLen: 3, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVD128", + argLen: 2, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLVD256", + argLen: 2, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLVD512", + argLen: 2, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVDMasked128", + argLen: 3, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVDMasked256", + argLen: 3, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVDMasked512", + argLen: 3, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQ128", + argLen: 2, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLVQ256", + argLen: 2, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLVQ512", + argLen: 2, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQMasked128", + argLen: 3, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQMasked256", + argLen: 3, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQMasked512", + argLen: 3, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVW128", + argLen: 2, + asm: x86.AVPSRLVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVW256", + argLen: 2, + asm: x86.AVPSRLVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVW512", + argLen: 2, + asm: x86.AVPSRLVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVWMasked128", + argLen: 3, + asm: x86.AVPSRLVW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVWMasked256", + argLen: 3, + asm: x86.AVPSRLVW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVWMasked512", + argLen: 3, + asm: x86.AVPSRLVW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLW128", + argLen: 2, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLW256", + argLen: 2, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLW512", + argLen: 2, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLWMasked128", + argLen: 3, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLWMasked256", + argLen: 3, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLWMasked512", + argLen: 3, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBB128", + argLen: 2, + asm: x86.AVPSUBB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBB256", + argLen: 2, + asm: x86.AVPSUBB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBB512", + argLen: 2, + asm: x86.AVPSUBB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBBMasked128", + argLen: 3, + asm: x86.AVPSUBB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBBMasked256", + argLen: 3, + asm: x86.AVPSUBB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBBMasked512", + argLen: 3, + asm: x86.AVPSUBB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBD128", + argLen: 2, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBD256", + argLen: 2, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBD512", + argLen: 2, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBDMasked128", + argLen: 3, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBDMasked256", + argLen: 3, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBDMasked512", + argLen: 3, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQ128", + argLen: 2, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBQ256", + argLen: 2, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBQ512", + argLen: 2, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQMasked128", + argLen: 3, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQMasked256", + argLen: 3, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQMasked512", + argLen: 3, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSB128", + argLen: 2, + asm: x86.AVPSUBSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBSB256", + argLen: 2, + asm: x86.AVPSUBSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBSB512", + argLen: 2, + asm: x86.AVPSUBSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSBMasked128", + argLen: 3, + asm: x86.AVPSUBSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSBMasked256", + argLen: 3, + asm: x86.AVPSUBSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSBMasked512", + argLen: 3, + asm: x86.AVPSUBSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSW128", + argLen: 2, + asm: x86.AVPSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBSW256", + argLen: 2, + asm: x86.AVPSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBSW512", + argLen: 2, + asm: x86.AVPSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSWMasked128", + argLen: 3, + asm: x86.AVPSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSWMasked256", + argLen: 3, + asm: x86.AVPSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSWMasked512", + argLen: 3, + asm: x86.AVPSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSB128", + argLen: 2, + asm: x86.AVPSUBUSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBUSB256", + argLen: 2, + asm: x86.AVPSUBUSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBUSB512", + argLen: 2, + asm: x86.AVPSUBUSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSBMasked128", + argLen: 3, + asm: x86.AVPSUBUSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSBMasked256", + argLen: 3, + asm: x86.AVPSUBUSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSBMasked512", + argLen: 3, + asm: x86.AVPSUBUSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSW128", + argLen: 2, + asm: x86.AVPSUBUSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBUSW256", + argLen: 2, + asm: x86.AVPSUBUSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBUSW512", + argLen: 2, + asm: x86.AVPSUBUSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSWMasked128", + argLen: 3, + asm: x86.AVPSUBUSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSWMasked256", + argLen: 3, + asm: x86.AVPSUBUSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSWMasked512", + argLen: 3, + asm: x86.AVPSUBUSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBW128", + argLen: 2, + asm: x86.AVPSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBW256", + argLen: 2, + asm: x86.AVPSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSUBW512", + argLen: 2, + asm: x86.AVPSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBWMasked128", + argLen: 3, + asm: x86.AVPSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBWMasked256", + argLen: 3, + asm: x86.AVPSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBWMasked512", + argLen: 3, + asm: x86.AVPSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPUNPCKHDQ128", + argLen: 2, + asm: x86.AVPUNPCKHDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKHDQ256", + argLen: 2, + asm: x86.AVPUNPCKHDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKHDQ512", + argLen: 2, + asm: x86.AVPUNPCKHDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPUNPCKHQDQ128", + argLen: 2, + asm: x86.AVPUNPCKHQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKHQDQ256", + argLen: 2, + asm: x86.AVPUNPCKHQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKHQDQ512", + argLen: 2, + asm: x86.AVPUNPCKHQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPUNPCKHWD128", + argLen: 2, + asm: x86.AVPUNPCKHWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKHWD256", + argLen: 2, + asm: x86.AVPUNPCKHWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKHWD512", + argLen: 2, + asm: x86.AVPUNPCKHWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPUNPCKLDQ128", + argLen: 2, + asm: x86.AVPUNPCKLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKLDQ256", + argLen: 2, + asm: x86.AVPUNPCKLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKLDQ512", + argLen: 2, + asm: x86.AVPUNPCKLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPUNPCKLQDQ128", + argLen: 2, + asm: x86.AVPUNPCKLQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKLQDQ256", + argLen: 2, + asm: x86.AVPUNPCKLQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKLQDQ512", + argLen: 2, + asm: x86.AVPUNPCKLQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPUNPCKLWD128", + argLen: 2, + asm: x86.AVPUNPCKLWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKLWD256", + argLen: 2, + asm: x86.AVPUNPCKLWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPUNPCKLWD512", + argLen: 2, + asm: x86.AVPUNPCKLWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXOR128", + argLen: 2, + commutative: true, + asm: x86.AVPXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPXOR256", + argLen: 2, + commutative: true, + asm: x86.AVPXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPXORD512", + argLen: 2, + commutative: true, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORDMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORDMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORDMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQ512", + argLen: 2, + commutative: true, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQMasked128", + argLen: 3, + commutative: true, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQMasked256", + argLen: 3, + commutative: true, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQMasked512", + argLen: 3, + commutative: true, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PD128", + argLen: 1, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PD256", + argLen: 1, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PD512", + argLen: 1, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PDMasked128", + argLen: 2, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PDMasked256", + argLen: 2, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PDMasked512", + argLen: 2, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PS512", + argLen: 1, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PSMasked128", + argLen: 2, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PSMasked256", + argLen: 2, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PSMasked512", + argLen: 2, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCPPS128", + argLen: 1, + asm: x86.AVRCPPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VRCPPS256", + argLen: 1, + asm: x86.AVRCPPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VRSQRT14PD128", + argLen: 1, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PD256", + argLen: 1, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PD512", + argLen: 1, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PDMasked128", + argLen: 2, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PDMasked256", + argLen: 2, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PDMasked512", + argLen: 2, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PS512", + argLen: 1, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PSMasked128", + argLen: 2, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PSMasked256", + argLen: 2, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PSMasked512", + argLen: 2, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRTPS128", + argLen: 1, + asm: x86.AVRSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VRSQRTPS256", + argLen: 1, + asm: x86.AVRSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSCALEFPD128", + argLen: 2, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPD256", + argLen: 2, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPD512", + argLen: 2, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPDMasked128", + argLen: 3, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPDMasked256", + argLen: 3, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPDMasked512", + argLen: 3, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPS128", + argLen: 2, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPS256", + argLen: 2, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPS512", + argLen: 2, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPSMasked128", + argLen: 3, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPSMasked256", + argLen: 3, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPSMasked512", + argLen: 3, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPD128", + argLen: 1, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSQRTPD256", + argLen: 1, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSQRTPD512", + argLen: 1, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPDMasked128", + argLen: 2, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPDMasked256", + argLen: 2, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPDMasked512", + argLen: 2, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPS128", + argLen: 1, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSQRTPS256", + argLen: 1, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSQRTPS512", + argLen: 1, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPSMasked128", + argLen: 2, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPSMasked256", + argLen: 2, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPSMasked512", + argLen: 2, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPD128", + argLen: 2, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSUBPD256", + argLen: 2, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSUBPD512", + argLen: 2, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPDMasked128", + argLen: 3, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPDMasked256", + argLen: 3, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPDMasked512", + argLen: 3, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPS128", + argLen: 2, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSUBPS256", + argLen: 2, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSUBPS512", + argLen: 2, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPSMasked128", + argLen: 3, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPSMasked256", + argLen: 3, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPSMasked512", + argLen: 3, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "SHA1RNDS4128", + auxType: auxUInt8, + argLen: 2, + resultInArg0: true, + asm: x86.ASHA1RNDS4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VAESKEYGENASSIST128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVAESKEYGENASSIST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCMPPD128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVCMPPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCMPPD256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVCMPPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCMPPD512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVCMPPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPDMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVCMPPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPDMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVCMPPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPDMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVCMPPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPS128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVCMPPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCMPPS256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVCMPPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VCMPPS512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVCMPPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPSMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVCMPPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPSMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVCMPPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPSMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVCMPPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VEXTRACTF64X4256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVEXTRACTF64X4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VEXTRACTF128128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVEXTRACTF128, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VEXTRACTI64X4256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVEXTRACTI64X4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VEXTRACTI128128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVEXTRACTI128, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQB128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQB256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQB512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQBMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQBMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQBMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQB128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQB256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQB512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQBMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQBMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQBMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VINSERTF64X4512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVINSERTF64X4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VINSERTF128256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVINSERTF128, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VINSERTI64X4512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVINSERTI64X4, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VINSERTI128256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVINSERTI128, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPALIGNR128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPALIGNR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPALIGNR256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPALIGNR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPALIGNR512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPALIGNR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPALIGNRMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPALIGNR, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPALIGNRMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPALIGNR, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPALIGNRMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPALIGNR, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCLMULQDQ128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCLMULQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPCLMULQDQ256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCLMULQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCLMULQDQ512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCLMULQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCMPB512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCMPB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPBMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPBMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPBMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPD512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCMPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPDMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPDMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPDMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPQ512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPQMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPQMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPQMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUB512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCMPUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUBMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUBMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUBMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUD512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCMPUD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUDMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUDMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUDMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUQ512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCMPUQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUQMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUQMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUQMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUW512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCMPUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUWMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUWMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUWMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPUW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPW512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPCMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPWMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPWMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPWMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPCMPW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPERM2F128256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPERM2F128, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPERM2I128256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPERM2I128, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPEXTRB128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPEXTRB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VPEXTRD128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPEXTRD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VPEXTRQ128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPEXTRQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VPEXTRW128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPEXTRW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + }, + }, + }, + { + name: "VPINSRB128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPINSRB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPINSRD128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPINSRD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPINSRQ128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPINSRQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPINSRW128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPINSRW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 49135}, // AX CX DX BX BP SI DI R8 R9 R10 R11 R12 R13 R15 + {0, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPROLD128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLD256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLD512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLDMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLDMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLDMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQ128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQ256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQ512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORD128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORD256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORD512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORDMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORDMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORDMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQ128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQ256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQ512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDD128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDD256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDD512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDDMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDDMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDDMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQ128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQ256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQ512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDW128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHLDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDW256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHLDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDW512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHLDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDWMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHLDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDWMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHLDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDWMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHLDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDD128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDD256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDD512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDDMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDDMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDDMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQ128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQ256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQ512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDW128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHRDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDW256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHRDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDW512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHRDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDWMasked128", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHRDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDWMasked256", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHRDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDWMasked512", + auxType: auxUInt8, + argLen: 3, + asm: x86.AVPSHRDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFD128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSHUFD256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSHUFD512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFDMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFDMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFDMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFHW128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSHUFHW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFHW256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSHUFHW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSHUFHW512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSHUFHW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFHWMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHUFHW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFHWMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHUFHW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFHWMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHUFHW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFLW128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSHUFLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFLW256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSHUFLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSHUFLW512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSHUFLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFLWMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHUFLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFLWMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHUFLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFLWMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSHUFLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLD128const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLD256const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLD512const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked128const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked256const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked512const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQ128const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLQ256const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLQ512const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked128const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked256const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked512const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLW128const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLW256const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSLLW512const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLWMasked128const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLWMasked256const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLWMasked512const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAD128const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRAD256const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRAD512const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked128const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked256const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked512const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQ128const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQ256const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQ512const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked128const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked256const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked512const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAW128const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRAW256const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRAW512const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAWMasked128const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAWMasked256const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAWMasked512const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLD128const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLD256const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLD512const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked128const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked256const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked512const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQ128const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLQ256const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLQ512const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked128const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked256const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked512const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLW128const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLW256const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VPSRLW512const", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLWMasked128const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLWMasked256const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLWMasked512const", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGD128", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPTERNLOGD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGD256", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPTERNLOGD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGD512", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPTERNLOGD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGQ128", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPTERNLOGQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGQ256", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPTERNLOGQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGQ512", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPTERNLOGQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPD128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPD256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPD512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPDMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPDMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPDMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPS128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPS256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPS512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPSMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPSMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPSMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPD128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPD256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPD512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPDMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPDMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPDMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPS128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPS256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPS512", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPSMasked128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPSMasked256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPSMasked512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VROUNDPD128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVROUNDPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VROUNDPD256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVROUNDPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VROUNDPS128", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVROUNDPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VROUNDPS256", + auxType: auxUInt8, + argLen: 1, + asm: x86.AVROUNDPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSHUFPD128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVSHUFPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSHUFPD256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVSHUFPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSHUFPD512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVSHUFPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSHUFPS128", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVSHUFPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSHUFPS256", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVSHUFPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + {1, 4294901760}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 + }, + outputs: []outputInfo{ + {0, 2147418112}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 + }, + }, + }, + { + name: "VSHUFPS512", + auxType: auxUInt8, + argLen: 2, + asm: x86.AVSHUFPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPS512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPSMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPSMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPSMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PS512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PSMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PSMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PSMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PS256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTPD2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PSMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTPD2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PSXMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTPD2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PSYMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTPD2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPS2PD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTPS2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPS2PDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTPS2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPS2PDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTPS2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PD128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PD256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PDMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PS256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTQQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTQQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSX128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTQQ2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSXMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTQQ2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSY128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTQQ2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSYMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTQQ2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQ256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPD2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQXMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2DQX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQYMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2DQY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQ128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQ256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQ512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQ256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPD2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQX128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPD2UDQX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQXMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2UDQX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQY128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPD2UDQY, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQYMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2UDQY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQ128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQ256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQ512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQ512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2QQ256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPS2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2QQ512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPS2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2QQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPS2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2QQMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPS2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQ128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQ256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQ512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UQQ256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPS2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UQQ512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTTPS2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UQQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPS2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UQQMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTTPS2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PD256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PS128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PS256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PS512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PSMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PSMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PSMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PD128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PD256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PDMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PS256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSX128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSXMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSY128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSYMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCVTUQQ2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPS512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPSMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPSMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPSMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PD512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PDMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PDMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PDMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PS512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PSMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PSMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADD213PSMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PD512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADDSUB213PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PDMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADDSUB213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PDMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADDSUB213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PDMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADDSUB213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PS512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADDSUB213PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PSMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADDSUB213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PSMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADDSUB213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMADDSUB213PSMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMADDSUB213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PD512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMSUBADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PDMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMSUBADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PDMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMSUBADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PDMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMSUBADD213PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PS512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMSUBADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PSMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMSUBADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PSMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMSUBADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VFMSUBADD213PSMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVFMSUBADD213PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPS512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPSMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPSMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPSMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPS512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPSMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPSMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPSMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPS512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPSMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPSMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPSMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSDMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQ128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQ256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQ512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDW512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDWMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDWMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDWMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDW512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDWMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDWMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDWMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDND512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPANDND, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDND, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDND, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDND, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPANDNQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDNQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDNQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDNQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDNQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBLENDMDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPBLENDMD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBLENDMQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPBLENDMQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCMPEQD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPCMPEQD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPEQQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPCMPEQQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPGTD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPCMPGTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPGTQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPCMPGTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPDPWSSD512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPDPWSSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPDPWSSDMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPDPWSSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPDPWSSDMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPDPWSSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPDPWSSDMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPDPWSSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPERMD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPERMD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPERMD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2D128load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2D256load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2D512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2DMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2DMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2DMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2D, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PD128load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PD256load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PD512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PDMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PDMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PDMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PS128load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PS256load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PS512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PSMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PSMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2PSMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2PS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2Q128load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2Q256load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2Q512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2QMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2QMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMI2QMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPERMI2Q, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPD256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPERMPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPERMPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPERMPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPERMPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPS512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPERMPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPSMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPERMPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMPSMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPERMPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMQ256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPERMQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPERMQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPERMQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPERMQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPERMQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTD128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTD256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTDMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQ128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQ256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQ512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQ128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQ256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQ128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQ256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQ128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQ256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQ128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQ256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQ128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQ256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTD128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTD256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTDMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQ128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQ256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQ512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVD128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVD256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQ128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQ256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVD128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVD256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQ128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQ256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVD128load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVD256load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVD512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVDMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVDMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVDMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQ128load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQ256load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQ512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDVQMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHLDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVD128load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVD256load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVD512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVDMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVDMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVDMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQ128load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQ256load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQ512load", + auxType: auxSymOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQMasked128load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQMasked256load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDVQMasked512load", + auxType: auxSymOff, + argLen: 5, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPSHRDVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQ128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQ256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPUNPCKHDQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPUNPCKHDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPUNPCKHQDQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPUNPCKHQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPUNPCKLDQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPUNPCKLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPUNPCKLQDQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPUNPCKLQDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQ512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PD128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PD256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PDMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PS512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PSMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PSMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PSMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PD128load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PD256load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PDMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PS512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PSMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PSMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PSMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPD128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPD256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPS128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPS256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPS512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPSMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPSMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPSMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPD512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPDMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPDMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPDMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPS512load", + auxType: auxSymOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPSMasked128load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPSMasked256load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPSMasked512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPD512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPDMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPDMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPDMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPS512load", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPSMasked128load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPSMasked256load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPSMasked512load", + auxType: auxSymOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCMPPD512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCMPPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPDMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVCMPPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPDMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVCMPPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPDMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVCMPPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPS512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVCMPPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPSMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVCMPPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPSMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVCMPPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VCMPPSMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVCMPPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQB128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQB256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQB512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQBMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQBMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEINVQBMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEINVQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQB128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQB256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQB512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQBMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQBMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8AFFINEQBMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVGF2P8AFFINEQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPCMPD512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPCMPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPDMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPDMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPDMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPQ512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPCMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPQMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPQMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPQMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUD512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPCMPUD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUDMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUDMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUDMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPUD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUQ512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPCMPUQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUQMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUQMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPCMPUQMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPCMPUQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + }, + }, + }, + { + name: "VPROLD128load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLD256load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLD512load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLDMasked128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLDMasked256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLDMasked512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQ128load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQ256load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQ512load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQMasked128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQMasked256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQMasked512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORD128load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORD256load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORD512load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORDMasked128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORDMasked256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORDMasked512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQ128load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQ256load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQ512load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQMasked128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQMasked256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQMasked512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDD128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDD256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDD512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDDMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDDMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDDMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQ128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQ256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQ512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDD128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDD256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDD512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDDMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDDMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDDMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQ128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQ256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQ512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQMasked128load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQMasked256load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQMasked512load", + auxType: auxSymValAndOff, + argLen: 4, + symEffect: SymRead, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFD512load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFDMasked128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFDMasked256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFDMasked512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLD512constload", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked128constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked256constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked512constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQ512constload", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked128constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked256constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked512constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAD512constload", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked128constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked256constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked512constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQ128constload", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQ256constload", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQ512constload", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked128constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked256constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked512constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLD512constload", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked128constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked256constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked512constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQ512constload", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked128constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked256constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked512constload", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGD128load", + auxType: auxSymValAndOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPTERNLOGD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGD256load", + auxType: auxSymValAndOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPTERNLOGD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGD512load", + auxType: auxSymValAndOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPTERNLOGD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGQ128load", + auxType: auxSymValAndOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPTERNLOGQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGQ256load", + auxType: auxSymValAndOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPTERNLOGQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPTERNLOGQ512load", + auxType: auxSymValAndOff, + argLen: 4, + resultInArg0: true, + symEffect: SymRead, + asm: x86.AVPTERNLOGQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPD128load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPD256load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPD512load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPDMasked128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPDMasked256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPDMasked512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPS128load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPS256load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPS512load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPSMasked128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPSMasked256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPSMasked512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPD128load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPD256load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPD512load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPDMasked128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPDMasked256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPDMasked512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPS128load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPS256load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPS512load", + auxType: auxSymValAndOff, + argLen: 2, + symEffect: SymRead, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPSMasked128load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPSMasked256load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPSMasked512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSHUFPD512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSHUFPD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSHUFPS512load", + auxType: auxSymValAndOff, + argLen: 3, + symEffect: SymRead, + asm: x86.AVSHUFPS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 72057594037977087}, // AX CX DX BX SP BP SI DI R8 R9 R10 R11 R12 R13 R15 SB + {0, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVADDPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPSMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPSMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VADDPSMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVADDPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVBROADCASTSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVBROADCASTSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSSMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVBROADCASTSS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSSMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVBROADCASTSS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VBROADCASTSSMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVBROADCASTSS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PSMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PSMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTDQ2PSMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PSMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTPD2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PSXMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTPD2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPD2PSYMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTPD2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPS2PDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTPS2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTPS2PDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTPS2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTQQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSXMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTQQ2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTQQ2PSYMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTQQ2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQXMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2DQX, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2DQYMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2DQY, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2QQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQXMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2UDQX, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UDQYMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2UDQY, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPD2UQQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPD2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2DQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPS2DQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2QQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPS2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2QQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPS2QQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UDQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPS2UDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UQQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPS2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTTPS2UQQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTTPS2UQQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUDQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PSMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PSMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUDQ2PSMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUDQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUQQ2PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUQQ2PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSXMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUQQ2PSX, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VCVTUQQ2PSYMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVCVTUQQ2PSY, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVDIVPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPSMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPSMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VDIVPSMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVDIVPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8MULBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVGF2P8MULB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8MULBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVGF2P8MULB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VGF2P8MULBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVGF2P8MULB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMAXPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPSMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPSMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMAXPSMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMAXPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMINPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPSMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPSMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMINPSMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMINPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMULPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPSMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPSMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VMULPSMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVMULPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSBMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSBMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSBMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSWMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSWMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPABSWMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPABSW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKSSDWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPACKSSDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPACKUSDWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPACKUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDSWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDUSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDUSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDUSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDUSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDUSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDUSWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDUSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPADDWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPADDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPANDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPANDQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPANDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPAVGB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPAVGB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPAVGB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPAVGW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPAVGW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPAVGWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPAVGW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTBMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTBMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTBMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTWMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTWMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPBROADCASTWMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPBROADCASTW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPLZCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPLZCNTQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPLZCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDUBSWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMADDUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDUBSWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMADDUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDUBSWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMADDUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDWDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMADDWD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDWDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMADDWD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMADDWDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMADDWD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXSWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMAXUWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMAXUW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINSWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMINUWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMINUW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDBMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDBMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDBMasked128_512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDWMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDWMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVDWMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQBMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQBMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQBMasked128_512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQDMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVQD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQDMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVQD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVQD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQWMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVQW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQWMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVQW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVQWMasked128_512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVQW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDBMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDBMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDBMasked128_512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDWMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDWMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSDWMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQBMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQBMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQBMasked128_512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQDMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSQD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQDMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSQD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSQD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQWMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSQW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQWMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSQW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSQWMasked128_512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSQW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSWBMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSWB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSWBMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSWB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSWBMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSWB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBWMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXBW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBWMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXBW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXBWMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXBW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXDQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXDQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXDQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXWD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXWD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXWD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVSXWQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVSXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDBMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDBMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDBMasked128_512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSDB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDWMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDWMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSDWMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSDW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQBMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQBMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQBMasked128_512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSQB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQDMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSQD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQDMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSQD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSQD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQWMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSQW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQWMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSQW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSQWMasked128_512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSQW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSWBMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSWB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSWBMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSWB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVUSWBMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVUSWB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVWBMasked128_128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVWB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVWBMasked128_256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVWB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVWBMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVWB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXBD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXBQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBWMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXBW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBWMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXBW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXBWMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXBW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXDQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXDQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXDQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXDQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXWD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXWD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXWD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMOVZXWQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPMOVZXWQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHUWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULHUW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHUWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULHUW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHUWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULHUW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULHW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULHW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULHWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULHW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULLQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPMULLWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTBMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTBMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTBMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTB, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTQMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTWMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTWMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPOPCNTWMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVPOPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPORD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPORQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPORQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPROLVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLVQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPROLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPRORVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORVQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPRORVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHUFB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHUFB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHUFB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSLLVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSLLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSLLVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSLLVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLVWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSLLVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRAVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRAVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRAVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRAVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAVWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRAVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRLVD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRLVQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRLVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRLVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLVWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSRLVW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBSWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSBMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBUSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSBMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBUSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSBMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBUSB, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBUSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBUSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBUSWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBUSW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBWMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBWMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSUBWMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPXORD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPXORQMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVPXORQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRCP14PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PSMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PSMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRCP14PSMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRCP14PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRSQRT14PD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PSMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PSMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRSQRT14PSMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVRSQRT14PS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSCALEFPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPSMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPSMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSCALEFPSMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSCALEFPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPDMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPDMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPDMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVSQRTPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPSMasked128Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPSMasked256Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSQRTPSMasked512Merging", + argLen: 3, + resultInArg0: true, + asm: x86.AVSQRTPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPDMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPDMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPDMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSUBPD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPSMasked128Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPSMasked256Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VSUBPSMasked512Merging", + argLen: 4, + resultInArg0: true, + asm: x86.AVSUBPS, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPALIGNRMasked128Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPALIGNR, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPALIGNRMasked256Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPALIGNR, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPALIGNRMasked512Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPALIGNR, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLDMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLDMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLDMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPROLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPROLQMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPROLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORDMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORDMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORDMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPRORD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPRORQMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPRORQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDDMasked128Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDDMasked256Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDDMasked512Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQMasked128Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQMasked256Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDQMasked512Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDWMasked128Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDWMasked256Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHLDWMasked512Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHLDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDDMasked128Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDDMasked256Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDDMasked512Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDD, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQMasked128Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQMasked256Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDQMasked512Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDQ, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDWMasked128Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDWMasked256Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHRDWMasked512Merging", + auxType: auxUInt8, + argLen: 4, + resultInArg0: true, + asm: x86.AVPSHRDW, + reg: regInfo{ + inputs: []inputInfo{ + {3, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {2, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFDMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFDMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFDMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHUFD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFHWMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHUFHW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFHWMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHUFHW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFHWMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHUFHW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFLWMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHUFLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFLWMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHUFLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSHUFLWMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSHUFLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked128constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked256constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLDMasked512constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSLLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked128constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked256constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLQMasked512constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSLLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLWMasked128constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLWMasked256constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSLLWMasked512constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSLLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked128constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked256constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRADMasked512constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRAD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked128constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked256constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAQMasked512constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRAQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAWMasked128constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAWMasked256constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRAWMasked512constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRAW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked128constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked256constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLDMasked512constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRLD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked128constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked256constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLQMasked512constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRLQ, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLWMasked128constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLWMasked256constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VPSRLWMasked512constMerging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVPSRLW, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPDMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPDMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPDMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVREDUCEPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPSMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPSMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VREDUCEPSMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVREDUCEPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPDMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPDMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPDMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVRNDSCALEPD, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPSMasked128Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPSMasked256Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + { + name: "VRNDSCALEPSMasked512Merging", + auxType: auxUInt8, + argLen: 3, + resultInArg0: true, + asm: x86.AVRNDSCALEPS, + reg: regInfo{ + inputs: []inputInfo{ + {2, 71494644084506624}, // K1 K2 K3 K4 K5 K6 K7 + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + {1, 281474976645120}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + outputs: []outputInfo{ + {0, 281472829161472}, // X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 + }, + }, + }, + + { + name: "ADD", + argLen: 2, + commutative: true, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDconst", + auxType: auxInt32, + argLen: 1, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 30719}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUB", + argLen: 2, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSB", + argLen: 2, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MUL", + argLen: 2, + commutative: true, + asm: arm.AMUL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "HMUL", + argLen: 2, + commutative: true, + asm: arm.AMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "HMULU", + argLen: 2, + commutative: true, + asm: arm.AMULLU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "CALLudiv", + argLen: 2, + clobberFlags: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2}, // R1 + {1, 1}, // R0 + }, + clobbers: 20492, // R2 R3 R12 R14 + outputs: []outputInfo{ + {0, 1}, // R0 + {1, 2}, // R1 + }, + }, + }, + { + name: "ADDS", + argLen: 2, + commutative: true, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDSconst", + auxType: auxInt32, + argLen: 1, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADC", + argLen: 3, + commutative: true, + asm: arm.AADC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADCconst", + auxType: auxInt32, + argLen: 2, + asm: arm.AADC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADCS", + argLen: 3, + commutative: true, + asm: arm.AADC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBS", + argLen: 2, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBSconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBSconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SBC", + argLen: 3, + asm: arm.ASBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SBCconst", + auxType: auxInt32, + argLen: 2, + asm: arm.ASBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSCconst", + auxType: auxInt32, + argLen: 2, + asm: arm.ARSC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MULLU", + argLen: 2, + commutative: true, + asm: arm.AMULLU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MULA", + argLen: 3, + asm: arm.AMULA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MULS", + argLen: 3, + asm: arm.AMULS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDF", + argLen: 2, + commutative: true, + asm: arm.AADDF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "ADDD", + argLen: 2, + commutative: true, + asm: arm.AADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "SUBF", + argLen: 2, + asm: arm.ASUBF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "SUBD", + argLen: 2, + asm: arm.ASUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MULF", + argLen: 2, + commutative: true, + asm: arm.AMULF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MULD", + argLen: 2, + commutative: true, + asm: arm.AMULD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "NMULF", + argLen: 2, + commutative: true, + asm: arm.ANMULF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "NMULD", + argLen: 2, + commutative: true, + asm: arm.ANMULD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "DIVF", + argLen: 2, + asm: arm.ADIVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "DIVD", + argLen: 2, + asm: arm.ADIVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MULAF", + argLen: 3, + resultInArg0: true, + asm: arm.AMULAF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MULAD", + argLen: 3, + resultInArg0: true, + asm: arm.AMULAD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MULSF", + argLen: 3, + resultInArg0: true, + asm: arm.AMULSF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MULSD", + argLen: 3, + resultInArg0: true, + asm: arm.AMULSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMULAD", + argLen: 3, + resultInArg0: true, + asm: arm.AFMULAD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "AND", + argLen: 2, + commutative: true, + asm: arm.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ANDconst", + auxType: auxInt32, + argLen: 1, + asm: arm.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "OR", + argLen: 2, + commutative: true, + asm: arm.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ORconst", + auxType: auxInt32, + argLen: 1, + asm: arm.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "XOR", + argLen: 2, + commutative: true, + asm: arm.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "XORconst", + auxType: auxInt32, + argLen: 1, + asm: arm.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "BIC", + argLen: 2, + asm: arm.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "BICconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "BFX", + auxType: auxInt32, + argLen: 1, + asm: arm.ABFX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "BFXU", + auxType: auxInt32, + argLen: 1, + asm: arm.ABFXU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MVN", + argLen: 1, + asm: arm.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "NEGF", + argLen: 1, + asm: arm.ANEGF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "NEGD", + argLen: 1, + asm: arm.ANEGD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "SQRTD", + argLen: 1, + asm: arm.ASQRTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "SQRTF", + argLen: 1, + asm: arm.ASQRTF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "ABSD", + argLen: 1, + asm: arm.AABSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CLZ", + argLen: 1, + asm: arm.ACLZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "REV", + argLen: 1, + asm: arm.AREV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "REV16", + argLen: 1, + asm: arm.AREV16, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RBIT", + argLen: 1, + asm: arm.ARBIT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SLL", + argLen: 2, + asm: arm.ASLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SLLconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ASLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SRL", + argLen: 2, + asm: arm.ASRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SRLconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ASRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SRA", + argLen: 2, + asm: arm.ASRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SRAconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ASRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SRR", + argLen: 2, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SRRconst", + auxType: auxInt32, + argLen: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ANDshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ANDshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ANDshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ORshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ORshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ORshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "XORshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "XORshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "XORshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "XORshiftRR", + auxType: auxInt32, + argLen: 2, + asm: arm.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "BICshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "BICshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "BICshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MVNshiftLL", + auxType: auxInt32, + argLen: 1, + asm: arm.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MVNshiftRL", + auxType: auxInt32, + argLen: 1, + asm: arm.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MVNshiftRA", + auxType: auxInt32, + argLen: 1, + asm: arm.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADCshiftLL", + auxType: auxInt32, + argLen: 3, + asm: arm.AADC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADCshiftRL", + auxType: auxInt32, + argLen: 3, + asm: arm.AADC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADCshiftRA", + auxType: auxInt32, + argLen: 3, + asm: arm.AADC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SBCshiftLL", + auxType: auxInt32, + argLen: 3, + asm: arm.ASBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SBCshiftRL", + auxType: auxInt32, + argLen: 3, + asm: arm.ASBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SBCshiftRA", + auxType: auxInt32, + argLen: 3, + asm: arm.ASBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSCshiftLL", + auxType: auxInt32, + argLen: 3, + asm: arm.ARSC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSCshiftRL", + auxType: auxInt32, + argLen: 3, + asm: arm.ARSC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSCshiftRA", + auxType: auxInt32, + argLen: 3, + asm: arm.ARSC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDSshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDSshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDSshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBSshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBSshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBSshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBSshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBSshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBSshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDshiftLLreg", + argLen: 3, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDshiftRLreg", + argLen: 3, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDshiftRAreg", + argLen: 3, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBshiftLLreg", + argLen: 3, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBshiftRLreg", + argLen: 3, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBshiftRAreg", + argLen: 3, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBshiftLLreg", + argLen: 3, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBshiftRLreg", + argLen: 3, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBshiftRAreg", + argLen: 3, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ANDshiftLLreg", + argLen: 3, + asm: arm.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ANDshiftRLreg", + argLen: 3, + asm: arm.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ANDshiftRAreg", + argLen: 3, + asm: arm.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ORshiftLLreg", + argLen: 3, + asm: arm.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ORshiftRLreg", + argLen: 3, + asm: arm.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ORshiftRAreg", + argLen: 3, + asm: arm.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "XORshiftLLreg", + argLen: 3, + asm: arm.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "XORshiftRLreg", + argLen: 3, + asm: arm.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "XORshiftRAreg", + argLen: 3, + asm: arm.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "BICshiftLLreg", + argLen: 3, + asm: arm.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "BICshiftRLreg", + argLen: 3, + asm: arm.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "BICshiftRAreg", + argLen: 3, + asm: arm.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MVNshiftLLreg", + argLen: 2, + asm: arm.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MVNshiftRLreg", + argLen: 2, + asm: arm.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MVNshiftRAreg", + argLen: 2, + asm: arm.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADCshiftLLreg", + argLen: 4, + asm: arm.AADC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADCshiftRLreg", + argLen: 4, + asm: arm.AADC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADCshiftRAreg", + argLen: 4, + asm: arm.AADC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SBCshiftLLreg", + argLen: 4, + asm: arm.ASBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SBCshiftRLreg", + argLen: 4, + asm: arm.ASBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SBCshiftRAreg", + argLen: 4, + asm: arm.ASBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSCshiftLLreg", + argLen: 4, + asm: arm.ARSC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSCshiftRLreg", + argLen: 4, + asm: arm.ARSC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSCshiftRAreg", + argLen: 4, + asm: arm.ARSC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDSshiftLLreg", + argLen: 3, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDSshiftRLreg", + argLen: 3, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "ADDSshiftRAreg", + argLen: 3, + asm: arm.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBSshiftLLreg", + argLen: 3, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBSshiftRLreg", + argLen: 3, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SUBSshiftRAreg", + argLen: 3, + asm: arm.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBSshiftLLreg", + argLen: 3, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBSshiftRLreg", + argLen: 3, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "RSBSshiftRAreg", + argLen: 3, + asm: arm.ARSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "CMP", + argLen: 2, + asm: arm.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "CMPconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "CMN", + argLen: 2, + commutative: true, + asm: arm.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "CMNconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "TST", + argLen: 2, + commutative: true, + asm: arm.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "TSTconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "TEQ", + argLen: 2, + commutative: true, + asm: arm.ATEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "TEQconst", + auxType: auxInt32, + argLen: 1, + asm: arm.ATEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "CMPF", + argLen: 2, + asm: arm.ACMPF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CMPD", + argLen: 2, + asm: arm.ACMPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CMPshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "CMPshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "CMPshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "CMNshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "CMNshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "CMNshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "TSTshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "TSTshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "TSTshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "TEQshiftLL", + auxType: auxInt32, + argLen: 2, + asm: arm.ATEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "TEQshiftRL", + auxType: auxInt32, + argLen: 2, + asm: arm.ATEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "TEQshiftRA", + auxType: auxInt32, + argLen: 2, + asm: arm.ATEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "CMPshiftLLreg", + argLen: 3, + asm: arm.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "CMPshiftRLreg", + argLen: 3, + asm: arm.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "CMPshiftRAreg", + argLen: 3, + asm: arm.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "CMNshiftLLreg", + argLen: 3, + asm: arm.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "CMNshiftRLreg", + argLen: 3, + asm: arm.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "CMNshiftRAreg", + argLen: 3, + asm: arm.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "TSTshiftLLreg", + argLen: 3, + asm: arm.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "TSTshiftRLreg", + argLen: 3, + asm: arm.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "TSTshiftRAreg", + argLen: 3, + asm: arm.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "TEQshiftLLreg", + argLen: 3, + asm: arm.ATEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "TEQshiftRLreg", + argLen: 3, + asm: arm.ATEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "TEQshiftRAreg", + argLen: 3, + asm: arm.ATEQ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "CMPF0", + argLen: 1, + asm: arm.ACMPF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CMPD0", + argLen: 1, + asm: arm.ACMPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVWconst", + auxType: auxInt32, + argLen: 0, + rematerializeable: true, + asm: arm.AMOVW, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVFconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: arm.AMOVF, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: arm.AMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVWaddr", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294975488}, // SP SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVBload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVBUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVHload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVHUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVFload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + }, + }, + { + name: "MOVHstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + }, + }, + { + name: "MOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + }, + }, + { + name: "MOVFstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVWloadidx", + argLen: 3, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVWloadshiftLL", + auxType: auxInt32, + argLen: 3, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVWloadshiftRL", + auxType: auxInt32, + argLen: 3, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVWloadshiftRA", + auxType: auxInt32, + argLen: 3, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVBUloadidx", + argLen: 3, + asm: arm.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVBloadidx", + argLen: 3, + asm: arm.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVHUloadidx", + argLen: 3, + asm: arm.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVHloadidx", + argLen: 3, + asm: arm.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVWstoreidx", + argLen: 4, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {2, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + }, + }, + { + name: "MOVWstoreshiftLL", + auxType: auxInt32, + argLen: 4, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {2, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + }, + }, + { + name: "MOVWstoreshiftRL", + auxType: auxInt32, + argLen: 4, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {2, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + }, + }, + { + name: "MOVWstoreshiftRA", + auxType: auxInt32, + argLen: 4, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {2, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + }, + }, + { + name: "MOVBstoreidx", + argLen: 4, + asm: arm.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {2, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + }, + }, + { + name: "MOVHstoreidx", + argLen: 4, + asm: arm.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {2, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + {0, 4294998015}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 SP R14 SB + }, + }, + }, + { + name: "MOVBreg", + argLen: 1, + asm: arm.AMOVBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVBUreg", + argLen: 1, + asm: arm.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVHreg", + argLen: 1, + asm: arm.AMOVHS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVHUreg", + argLen: 1, + asm: arm.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVWreg", + argLen: 1, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVWnop", + argLen: 1, + resultInArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVWF", + argLen: 1, + asm: arm.AMOVWF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2147483648, // F15 + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVWD", + argLen: 1, + asm: arm.AMOVWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2147483648, // F15 + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVWUF", + argLen: 1, + asm: arm.AMOVWF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2147483648, // F15 + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVWUD", + argLen: 1, + asm: arm.AMOVWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2147483648, // F15 + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVFW", + argLen: 1, + asm: arm.AMOVFW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + clobbers: 2147483648, // F15 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVDW", + argLen: 1, + asm: arm.AMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + clobbers: 2147483648, // F15 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVFWU", + argLen: 1, + asm: arm.AMOVFW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + clobbers: 2147483648, // F15 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVDWU", + argLen: 1, + asm: arm.AMOVDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + clobbers: 2147483648, // F15 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MOVFD", + argLen: 1, + asm: arm.AMOVFD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVDF", + argLen: 1, + asm: arm.AMOVDF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CMOVWHSconst", + auxType: auxInt32, + argLen: 2, + resultInArg0: true, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "CMOVWLSconst", + auxType: auxInt32, + argLen: 2, + resultInArg0: true, + asm: arm.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "SRAcond", + argLen: 3, + asm: arm.ASRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "CALLstatic", + auxType: auxCallOff, + argLen: 1, + clobberFlags: true, + call: true, + reg: regInfo{ + clobbers: 4294924287, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + { + name: "CALLtail", + auxType: auxCallOff, + argLen: 1, + clobberFlags: true, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 4294924287, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + { + name: "CALLclosure", + auxType: auxCallOff, + argLen: 3, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 128}, // R7 + {0, 29695}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 SP R14 + }, + clobbers: 4294924287, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + { + name: "CALLinter", + auxType: auxCallOff, + argLen: 2, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 4294924287, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 22527}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 g R12 R14 + }, + }, + }, + { + name: "Equal", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "NotEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "LessThan", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "LessEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "GreaterThan", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "GreaterEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "LessThanU", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "LessEqualU", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "GreaterThanU", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "GreaterEqualU", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "DUFFZERO", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2}, // R1 + {1, 1}, // R0 + }, + clobbers: 20482, // R1 R12 R14 + }, + }, + { + name: "DUFFCOPY", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4}, // R2 + {1, 2}, // R1 + }, + clobbers: 20487, // R0 R1 R2 R12 R14 + }, + }, + { + name: "LoweredZero", + auxType: auxInt64, + argLen: 4, + clobberFlags: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2}, // R1 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2, // R1 + }, + }, + { + name: "LoweredMove", + auxType: auxInt64, + argLen: 4, + clobberFlags: true, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4}, // R2 + {1, 2}, // R1 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 6, // R1 R2 + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + zeroWidth: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 128}, // R7 + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "LoweredPanicBoundsRR", + auxType: auxInt64, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 5119}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 + {1, 5119}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 + }, + }, + }, + { + name: "LoweredPanicBoundsRC", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 5119}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 + }, + }, + }, + { + name: "LoweredPanicBoundsCR", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 5119}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 + }, + }, + }, + { + name: "LoweredPanicBoundsCC", + auxType: auxPanicBoundsCC, + argLen: 1, + call: true, + reg: regInfo{}, + }, + { + name: "LoweredPanicExtendRR", + auxType: auxInt64, + argLen: 4, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 15}, // R0 R1 R2 R3 + {1, 15}, // R0 R1 R2 R3 + {2, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "LoweredPanicExtendRC", + auxType: auxPanicBoundsC, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 15}, // R0 R1 R2 R3 + {1, 15}, // R0 R1 R2 R3 + }, + }, + }, + { + name: "FlagConstant", + auxType: auxFlagConstant, + argLen: 0, + reg: regInfo{}, + }, + { + name: "InvertFlags", + argLen: 1, + reg: regInfo{}, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + reg: regInfo{ + clobbers: 4294922240, // R12 R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + outputs: []outputInfo{ + {0, 256}, // R8 + }, + }, + }, + + { + name: "ADCSflags", + argLen: 3, + commutative: true, + asm: arm64.AADCS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + {1, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ADCzerocarry", + argLen: 1, + asm: arm64.AADC, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ADD", + argLen: 2, + commutative: true, + asm: arm64.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ADDconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1476395007}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ADDSconstflags", + auxType: auxInt64, + argLen: 1, + asm: arm64.AADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ADDSflags", + argLen: 2, + commutative: true, + asm: arm64.AADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + {1, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SUB", + argLen: 2, + asm: arm64.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SUBconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SBCSflags", + argLen: 3, + asm: arm64.ASBCS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + {1, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SUBSflags", + argLen: 2, + asm: arm64.ASUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + {1, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MUL", + argLen: 2, + commutative: true, + asm: arm64.AMUL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MULW", + argLen: 2, + commutative: true, + asm: arm64.AMULW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MNEG", + argLen: 2, + commutative: true, + asm: arm64.AMNEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MNEGW", + argLen: 2, + commutative: true, + asm: arm64.AMNEGW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MULH", + argLen: 2, + commutative: true, + asm: arm64.ASMULH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "UMULH", + argLen: 2, + commutative: true, + asm: arm64.AUMULH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MULL", + argLen: 2, + commutative: true, + asm: arm64.ASMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "UMULL", + argLen: 2, + commutative: true, + asm: arm64.AUMULL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "DIV", + argLen: 2, + asm: arm64.ASDIV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "UDIV", + argLen: 2, + asm: arm64.AUDIV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "DIVW", + argLen: 2, + asm: arm64.ASDIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "UDIVW", + argLen: 2, + asm: arm64.AUDIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOD", + argLen: 2, + asm: arm64.AREM, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "UMOD", + argLen: 2, + asm: arm64.AUREM, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MODW", + argLen: 2, + asm: arm64.AREMW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "UMODW", + argLen: 2, + asm: arm64.AUREMW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FADDS", + argLen: 2, + commutative: true, + asm: arm64.AFADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FADDD", + argLen: 2, + commutative: true, + asm: arm64.AFADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FSUBS", + argLen: 2, + asm: arm64.AFSUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FSUBD", + argLen: 2, + asm: arm64.AFSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMULS", + argLen: 2, + commutative: true, + asm: arm64.AFMULS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMULD", + argLen: 2, + commutative: true, + asm: arm64.AFMULD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNMULS", + argLen: 2, + commutative: true, + asm: arm64.AFNMULS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNMULD", + argLen: 2, + commutative: true, + asm: arm64.AFNMULD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FDIVS", + argLen: 2, + asm: arm64.AFDIVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FDIVD", + argLen: 2, + asm: arm64.AFDIVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "AND", + argLen: 2, + commutative: true, + asm: arm64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ANDconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "OR", + argLen: 2, + commutative: true, + asm: arm64.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ORconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "XOR", + argLen: 2, + commutative: true, + asm: arm64.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "XORconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "BIC", + argLen: 2, + asm: arm64.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "EON", + argLen: 2, + asm: arm64.AEON, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ORN", + argLen: 2, + asm: arm64.AORN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MVN", + argLen: 1, + asm: arm64.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NEG", + argLen: 1, + asm: arm64.ANEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NEGSflags", + argLen: 1, + asm: arm64.ANEGS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {1, 0}, + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NGCzerocarry", + argLen: 1, + asm: arm64.ANGC, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FABSD", + argLen: 1, + asm: arm64.AFABSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNEGS", + argLen: 1, + asm: arm64.AFNEGS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNEGD", + argLen: 1, + asm: arm64.AFNEGD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FSQRTD", + argLen: 1, + asm: arm64.AFSQRTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FSQRTS", + argLen: 1, + asm: arm64.AFSQRTS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMIND", + argLen: 2, + asm: arm64.AFMIND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMINS", + argLen: 2, + asm: arm64.AFMINS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMAXD", + argLen: 2, + asm: arm64.AFMAXD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMAXS", + argLen: 2, + asm: arm64.AFMAXS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "REV", + argLen: 1, + asm: arm64.AREV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "REVW", + argLen: 1, + asm: arm64.AREVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "REV16", + argLen: 1, + asm: arm64.AREV16, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "REV16W", + argLen: 1, + asm: arm64.AREV16W, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "RBIT", + argLen: 1, + asm: arm64.ARBIT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "RBITW", + argLen: 1, + asm: arm64.ARBITW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "CLZ", + argLen: 1, + asm: arm64.ACLZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "CLZW", + argLen: 1, + asm: arm64.ACLZW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "VCNT", + argLen: 1, + asm: arm64.AVCNT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "VUADDLV", + argLen: 1, + asm: arm64.AVUADDLV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "LoweredRound32F", + argLen: 1, + resultInArg0: true, + zeroWidth: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "LoweredRound64F", + argLen: 1, + resultInArg0: true, + zeroWidth: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMADDS", + argLen: 3, + asm: arm64.AFMADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMADDD", + argLen: 3, + asm: arm64.AFMADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNMADDS", + argLen: 3, + asm: arm64.AFNMADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNMADDD", + argLen: 3, + asm: arm64.AFNMADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMSUBS", + argLen: 3, + asm: arm64.AFMSUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMSUBD", + argLen: 3, + asm: arm64.AFMSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNMSUBS", + argLen: 3, + asm: arm64.AFNMSUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNMSUBD", + argLen: 3, + asm: arm64.AFNMSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "MADD", + argLen: 3, + asm: arm64.AMADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {2, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MADDW", + argLen: 3, + asm: arm64.AMADDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {2, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MSUB", + argLen: 3, + asm: arm64.AMSUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {2, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MSUBW", + argLen: 3, + asm: arm64.AMSUBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {2, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SLL", + argLen: 2, + asm: arm64.ALSL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SLLconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.ALSL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SRL", + argLen: 2, + asm: arm64.ALSR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SRLconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.ALSR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SRA", + argLen: 2, + asm: arm64.AASR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SRAconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.AASR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ROR", + argLen: 2, + asm: arm64.AROR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "RORW", + argLen: 2, + asm: arm64.ARORW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "RORconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.AROR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "RORWconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.ARORW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "EXTRconst", + auxType: auxInt64, + argLen: 2, + asm: arm64.AEXTR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "EXTRWconst", + auxType: auxInt64, + argLen: 2, + asm: arm64.AEXTRW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "CMP", + argLen: 2, + asm: arm64.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMPconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMPW", + argLen: 2, + asm: arm64.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMPWconst", + auxType: auxInt32, + argLen: 1, + asm: arm64.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMN", + argLen: 2, + commutative: true, + asm: arm64.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMNconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMNW", + argLen: 2, + commutative: true, + asm: arm64.ACMNW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMNWconst", + auxType: auxInt32, + argLen: 1, + asm: arm64.ACMNW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "TST", + argLen: 2, + commutative: true, + asm: arm64.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "TSTconst", + auxType: auxInt64, + argLen: 1, + asm: arm64.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "TSTW", + argLen: 2, + commutative: true, + asm: arm64.ATSTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "TSTWconst", + auxType: auxInt32, + argLen: 1, + asm: arm64.ATSTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "FCMPS", + argLen: 2, + asm: arm64.AFCMPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCMPD", + argLen: 2, + asm: arm64.AFCMPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCMPS0", + argLen: 1, + asm: arm64.AFCMPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCMPD0", + argLen: 1, + asm: arm64.AFCMPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "MVNshiftLL", + auxType: auxInt64, + argLen: 1, + asm: arm64.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MVNshiftRL", + auxType: auxInt64, + argLen: 1, + asm: arm64.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MVNshiftRA", + auxType: auxInt64, + argLen: 1, + asm: arm64.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MVNshiftRO", + auxType: auxInt64, + argLen: 1, + asm: arm64.AMVN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NEGshiftLL", + auxType: auxInt64, + argLen: 1, + asm: arm64.ANEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NEGshiftRL", + auxType: auxInt64, + argLen: 1, + asm: arm64.ANEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NEGshiftRA", + auxType: auxInt64, + argLen: 1, + asm: arm64.ANEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ADDshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ADDshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ADDshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SUBshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SUBshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SUBshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ANDshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ANDshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ANDshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ANDshiftRO", + auxType: auxInt64, + argLen: 2, + asm: arm64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ORshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ORshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ORshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ORshiftRO", + auxType: auxInt64, + argLen: 2, + asm: arm64.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "XORshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "XORshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "XORshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "XORshiftRO", + auxType: auxInt64, + argLen: 2, + asm: arm64.AEOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "BICshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "BICshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "BICshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "BICshiftRO", + auxType: auxInt64, + argLen: 2, + asm: arm64.ABIC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "EONshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AEON, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "EONshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AEON, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "EONshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.AEON, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "EONshiftRO", + auxType: auxInt64, + argLen: 2, + asm: arm64.AEON, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ORNshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AORN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ORNshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.AORN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ORNshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.AORN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "ORNshiftRO", + auxType: auxInt64, + argLen: 2, + asm: arm64.AORN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "CMPshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMPshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMPshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMNshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMNshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CMNshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.ACMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "TSTshiftLL", + auxType: auxInt64, + argLen: 2, + asm: arm64.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "TSTshiftRL", + auxType: auxInt64, + argLen: 2, + asm: arm64.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "TSTshiftRA", + auxType: auxInt64, + argLen: 2, + asm: arm64.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "TSTshiftRO", + auxType: auxInt64, + argLen: 2, + asm: arm64.ATST, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "BFI", + auxType: auxARM64BitField, + argLen: 2, + resultInArg0: true, + asm: arm64.ABFI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + {1, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "BFXIL", + auxType: auxARM64BitField, + argLen: 2, + resultInArg0: true, + asm: arm64.ABFXIL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + {1, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SBFIZ", + auxType: auxARM64BitField, + argLen: 1, + asm: arm64.ASBFIZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SBFX", + auxType: auxARM64BitField, + argLen: 1, + asm: arm64.ASBFX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "UBFIZ", + auxType: auxARM64BitField, + argLen: 1, + asm: arm64.AUBFIZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "UBFX", + auxType: auxARM64BitField, + argLen: 1, + asm: arm64.AUBFX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVDconst", + auxType: auxInt64, + argLen: 0, + rematerializeable: true, + asm: arm64.AMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FMOVSconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: arm64.AFMOVS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: arm64.AFMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "MOVDaddr", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + asm: arm64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037928517632}, // SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVBload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVBUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVHload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVHUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVWUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FMOVSload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "LDP", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.ALDP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "LDPW", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.ALDPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "LDPSW", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.ALDPSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "FLDPD", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AFLDPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FLDPS", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: arm64.AFLDPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "MOVDloadidx", + argLen: 3, + asm: arm64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVWloadidx", + argLen: 3, + asm: arm64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVWUloadidx", + argLen: 3, + asm: arm64.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVHloadidx", + argLen: 3, + asm: arm64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVHUloadidx", + argLen: 3, + asm: arm64.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVBloadidx", + argLen: 3, + asm: arm64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVBUloadidx", + argLen: 3, + asm: arm64.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FMOVSloadidx", + argLen: 3, + asm: arm64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDloadidx", + argLen: 3, + asm: arm64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "MOVHloadidx2", + argLen: 3, + asm: arm64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVHUloadidx2", + argLen: 3, + asm: arm64.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVWloadidx4", + argLen: 3, + asm: arm64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVWUloadidx4", + argLen: 3, + asm: arm64.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVDloadidx8", + argLen: 3, + asm: arm64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FMOVSloadidx4", + argLen: 3, + asm: arm64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDloadidx8", + argLen: 3, + asm: arm64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "MOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "MOVHstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "MOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "MOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "FMOVSstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + {1, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + {1, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "STP", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm64.ASTP, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "STPW", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm64.ASTPW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "FSTPD", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm64.AFSTPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FSTPS", + auxType: auxSymOff, + argLen: 4, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: arm64.AFSTPS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "MOVBstoreidx", + argLen: 4, + asm: arm64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "MOVHstoreidx", + argLen: 4, + asm: arm64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "MOVWstoreidx", + argLen: 4, + asm: arm64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "MOVDstoreidx", + argLen: 4, + asm: arm64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "FMOVSstoreidx", + argLen: 4, + asm: arm64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + {2, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDstoreidx", + argLen: 4, + asm: arm64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + {2, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "MOVHstoreidx2", + argLen: 4, + asm: arm64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "MOVWstoreidx4", + argLen: 4, + asm: arm64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "MOVDstoreidx8", + argLen: 4, + asm: arm64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "FMOVSstoreidx4", + argLen: 4, + asm: arm64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + {2, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDstoreidx8", + argLen: 4, + asm: arm64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + {2, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDgpfp", + argLen: 1, + asm: arm64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDfpgp", + argLen: 1, + asm: arm64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FMOVSgpfp", + argLen: 1, + asm: arm64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVSfpgp", + argLen: 1, + asm: arm64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVBreg", + argLen: 1, + asm: arm64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVBUreg", + argLen: 1, + asm: arm64.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVHreg", + argLen: 1, + asm: arm64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVHUreg", + argLen: 1, + asm: arm64.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVWreg", + argLen: 1, + asm: arm64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVWUreg", + argLen: 1, + asm: arm64.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVDreg", + argLen: 1, + asm: arm64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "MOVDnop", + argLen: 1, + resultInArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "SCVTFWS", + argLen: 1, + asm: arm64.ASCVTFWS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "SCVTFWD", + argLen: 1, + asm: arm64.ASCVTFWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "UCVTFWS", + argLen: 1, + asm: arm64.AUCVTFWS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "UCVTFWD", + argLen: 1, + asm: arm64.AUCVTFWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "SCVTFS", + argLen: 1, + asm: arm64.ASCVTFS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "SCVTFD", + argLen: 1, + asm: arm64.ASCVTFD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "UCVTFS", + argLen: 1, + asm: arm64.AUCVTFS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "UCVTFD", + argLen: 1, + asm: arm64.AUCVTFD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCVTZSSW", + argLen: 1, + asm: arm64.AFCVTZSSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FCVTZSDW", + argLen: 1, + asm: arm64.AFCVTZSDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FCVTZUSW", + argLen: 1, + asm: arm64.AFCVTZUSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FCVTZUDW", + argLen: 1, + asm: arm64.AFCVTZUDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FCVTZSS", + argLen: 1, + asm: arm64.AFCVTZSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FCVTZSD", + argLen: 1, + asm: arm64.AFCVTZSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FCVTZUS", + argLen: 1, + asm: arm64.AFCVTZUS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FCVTZUD", + argLen: 1, + asm: arm64.AFCVTZUD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FCVTSD", + argLen: 1, + asm: arm64.AFCVTSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCVTDS", + argLen: 1, + asm: arm64.AFCVTDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FRINTAD", + argLen: 1, + asm: arm64.AFRINTAD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FRINTMD", + argLen: 1, + asm: arm64.AFRINTMD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FRINTND", + argLen: 1, + asm: arm64.AFRINTND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FRINTPD", + argLen: 1, + asm: arm64.AFRINTPD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FRINTZD", + argLen: 1, + asm: arm64.AFRINTZD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "CSEL", + auxType: auxCCop, + argLen: 3, + asm: arm64.ACSEL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + {1, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "CSEL0", + auxType: auxCCop, + argLen: 2, + asm: arm64.ACSEL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "CSINC", + auxType: auxCCop, + argLen: 3, + asm: arm64.ACSINC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + {1, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "CSINV", + auxType: auxCCop, + argLen: 3, + asm: arm64.ACSINV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + {1, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "CSNEG", + auxType: auxCCop, + argLen: 3, + asm: arm64.ACSNEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + {1, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "CSETM", + auxType: auxCCop, + argLen: 1, + asm: arm64.ACSETM, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "CCMP", + auxType: auxARM64ConditionalParams, + argLen: 3, + asm: arm64.ACCMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CCMN", + auxType: auxARM64ConditionalParams, + argLen: 3, + asm: arm64.ACCMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CCMPconst", + auxType: auxARM64ConditionalParams, + argLen: 2, + asm: arm64.ACCMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CCMNconst", + auxType: auxARM64ConditionalParams, + argLen: 2, + asm: arm64.ACCMN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CCMPW", + auxType: auxARM64ConditionalParams, + argLen: 3, + asm: arm64.ACCMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CCMNW", + auxType: auxARM64ConditionalParams, + argLen: 3, + asm: arm64.ACCMNW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + {1, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CCMPWconst", + auxType: auxARM64ConditionalParams, + argLen: 2, + asm: arm64.ACCMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CCMNWconst", + auxType: auxARM64ConditionalParams, + argLen: 2, + asm: arm64.ACCMNW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "CALLstatic", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + clobbers: 9223372035109945343, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 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 + }, + }, + { + name: "CALLtail", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 9223372035109945343, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 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 + }, + }, + { + name: "CALLclosure", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 33554432}, // R26 + {0, 1409286143}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 SP + }, + clobbers: 9223372035109945343, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 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 + }, + }, + { + name: "CALLinter", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + clobbers: 9223372035109945343, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 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 + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 402653183}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 + }, + }, + }, + { + name: "LoweredMemEq", + argLen: 4, + clobberFlags: true, + call: true, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1}, // R0 + {1, 2}, // R1 + {2, 4}, // R2 + }, + clobbers: 9223372035109945343, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 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 + outputs: []outputInfo{ + {0, 1}, // R0 + }, + }, + }, + { + name: "Equal", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NotEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LessThan", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LessEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "GreaterThan", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "GreaterEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LessThanU", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LessEqualU", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "GreaterThanU", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "GreaterEqualU", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LessThanF", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LessEqualF", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "GreaterThanF", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "GreaterEqualF", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NotLessThanF", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NotLessEqualF", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NotGreaterThanF", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "NotGreaterEqualF", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LessThanNoov", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "GreaterEqualNoov", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredZero", + auxType: auxInt64, + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredZeroLoop", + auxType: auxInt64, + argLen: 2, + needIntTemp: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + clobbersArg0: true, + }, + }, + { + name: "LoweredMove", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 318767103}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R26 R30 + {1, 318767103}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R26 R30 + }, + clobbers: 422212481843200, // R25 F16 F17 + }, + }, + { + name: "LoweredMoveLoop", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 310378495}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R26 R30 + {1, 310378495}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R26 R30 + }, + clobbers: 422212490231808, // R24 R25 F16 F17 + clobbersArg0: true, + clobbersArg1: true, + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + zeroWidth: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 33554432}, // R26 + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "FlagConstant", + auxType: auxFlagConstant, + argLen: 0, + reg: regInfo{}, + }, + { + name: "InvertFlags", + argLen: 1, + reg: regInfo{}, + }, + { + name: "LDAR", + argLen: 2, + faultOnNilArg0: true, + asm: arm64.ALDAR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LDARB", + argLen: 2, + faultOnNilArg0: true, + asm: arm64.ALDARB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LDARW", + argLen: 2, + faultOnNilArg0: true, + asm: arm64.ALDARW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "STLRB", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + asm: arm64.ASTLRB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "STLR", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + asm: arm64.ASTLR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "STLRW", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + asm: arm64.ASTLRW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "LoweredAtomicExchange64", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicExchange32", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicExchange8", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicExchange64Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicExchange32Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicExchange8Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicAdd64", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicAdd32", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicAdd64Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicAdd32Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicCas64", + argLen: 4, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicCas32", + argLen: 4, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicCas64Variant", + argLen: 4, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicCas32Variant", + argLen: 4, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {2, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicAnd8", + argLen: 3, + resultNotInArgs: true, + needIntTemp: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + asm: arm64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicOr8", + argLen: 3, + resultNotInArgs: true, + needIntTemp: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + asm: arm64.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicAnd64", + argLen: 3, + resultNotInArgs: true, + needIntTemp: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + asm: arm64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicOr64", + argLen: 3, + resultNotInArgs: true, + needIntTemp: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + asm: arm64.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicAnd32", + argLen: 3, + resultNotInArgs: true, + needIntTemp: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + asm: arm64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicOr32", + argLen: 3, + resultNotInArgs: true, + needIntTemp: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + asm: arm64.AORR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicAnd8Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicOr8Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicAnd64Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicOr64Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicAnd32Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredAtomicOr32Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 939524095}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 ZERO + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + outputs: []outputInfo{ + {0, 335544319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 R30 + }, + }, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + reg: regInfo{ + clobbers: 9223372034975924224, // R16 R17 R30 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 + outputs: []outputInfo{ + {0, 16777216}, // R25 + }, + }, + }, + { + name: "LoweredPanicBoundsRR", + auxType: auxInt64, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + {1, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredPanicBoundsRC", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredPanicBoundsCR", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredPanicBoundsCC", + auxType: auxPanicBoundsCC, + argLen: 1, + call: true, + reg: regInfo{}, + }, + { + name: "PRFM", + auxType: auxInt64, + argLen: 2, + hasSideEffects: true, + asm: arm64.APRFM, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372038331170815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R19 R20 R21 R22 R23 R24 R25 R26 g R30 SP SB + }, + }, + }, + { + name: "DMB", + auxType: auxInt64, + argLen: 1, + hasSideEffects: true, + asm: arm64.ADMB, + reg: regInfo{}, + }, + { + name: "ZERO", + argLen: 0, + zeroWidth: true, + fixedReg: true, + reg: regInfo{}, + }, + + { + name: "NEGV", + argLen: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "NEGF", + argLen: 1, + asm: loong64.ANEGF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "NEGD", + argLen: 1, + asm: loong64.ANEGD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "SQRTD", + argLen: 1, + asm: loong64.ASQRTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "SQRTF", + argLen: 1, + asm: loong64.ASQRTF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "ABSD", + argLen: 1, + asm: loong64.AABSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "CLZW", + argLen: 1, + asm: loong64.ACLZW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "CLZV", + argLen: 1, + asm: loong64.ACLZV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "CTZW", + argLen: 1, + asm: loong64.ACTZW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "CTZV", + argLen: 1, + asm: loong64.ACTZV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "REVB2H", + argLen: 1, + asm: loong64.AREVB2H, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "REVB2W", + argLen: 1, + asm: loong64.AREVB2W, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "REVB4H", + argLen: 1, + asm: loong64.AREVB4H, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "REVBV", + argLen: 1, + asm: loong64.AREVBV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "BITREV4B", + argLen: 1, + asm: loong64.ABITREV4B, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "BITREVW", + argLen: 1, + asm: loong64.ABITREVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "BITREVV", + argLen: 1, + asm: loong64.ABITREVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "VPCNT64", + argLen: 1, + asm: loong64.AVPCNTV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "VPCNT32", + argLen: 1, + asm: loong64.AVPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "VPCNT16", + argLen: 1, + asm: loong64.AVPCNTH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "ADDV", + argLen: 2, + commutative: true, + asm: loong64.AADDVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ADDVconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.AADDVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741820}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ADDV16const", + auxType: auxInt64, + argLen: 1, + asm: loong64.AADDV16, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741820}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SUBV", + argLen: 2, + asm: loong64.ASUBVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SUBVconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.ASUBVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MULV", + argLen: 2, + commutative: true, + asm: loong64.AMULV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MULHV", + argLen: 2, + commutative: true, + asm: loong64.AMULHV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MULHVU", + argLen: 2, + commutative: true, + asm: loong64.AMULHVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MULH", + argLen: 2, + commutative: true, + asm: loong64.AMULH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MULHU", + argLen: 2, + commutative: true, + asm: loong64.AMULHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "DIVV", + argLen: 2, + asm: loong64.ADIVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "DIVVU", + argLen: 2, + asm: loong64.ADIVVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "REMV", + argLen: 2, + asm: loong64.AREMV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "REMVU", + argLen: 2, + asm: loong64.AREMVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MULWVW", + argLen: 2, + commutative: true, + asm: loong64.AMULWVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MULWVWU", + argLen: 2, + commutative: true, + asm: loong64.AMULWVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ADDF", + argLen: 2, + commutative: true, + asm: loong64.AADDF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "ADDD", + argLen: 2, + commutative: true, + asm: loong64.AADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "SUBF", + argLen: 2, + asm: loong64.ASUBF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "SUBD", + argLen: 2, + asm: loong64.ASUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MULF", + argLen: 2, + commutative: true, + asm: loong64.AMULF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MULD", + argLen: 2, + commutative: true, + asm: loong64.AMULD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "DIVF", + argLen: 2, + asm: loong64.ADIVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "DIVD", + argLen: 2, + asm: loong64.ADIVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "AND", + argLen: 2, + commutative: true, + asm: loong64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ANDconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "OR", + argLen: 2, + commutative: true, + asm: loong64.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ORconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "XOR", + argLen: 2, + commutative: true, + asm: loong64.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "XORconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "NOR", + argLen: 2, + commutative: true, + asm: loong64.ANOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "NORconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.ANOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ANDN", + argLen: 2, + asm: loong64.AANDN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ORN", + argLen: 2, + asm: loong64.AORN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "FMADDF", + argLen: 3, + commutative: true, + asm: loong64.AFMADDF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + {2, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FMADDD", + argLen: 3, + commutative: true, + asm: loong64.AFMADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + {2, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FMSUBF", + argLen: 3, + commutative: true, + asm: loong64.AFMSUBF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + {2, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FMSUBD", + argLen: 3, + commutative: true, + asm: loong64.AFMSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + {2, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FNMADDF", + argLen: 3, + commutative: true, + asm: loong64.AFNMADDF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + {2, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FNMADDD", + argLen: 3, + commutative: true, + asm: loong64.AFNMADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + {2, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FNMSUBF", + argLen: 3, + commutative: true, + asm: loong64.AFNMSUBF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + {2, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FNMSUBD", + argLen: 3, + commutative: true, + asm: loong64.AFNMSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + {2, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FMINF", + argLen: 2, + commutative: true, + resultNotInArgs: true, + asm: loong64.AFMINF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FMIND", + argLen: 2, + commutative: true, + resultNotInArgs: true, + asm: loong64.AFMIND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FMAXF", + argLen: 2, + commutative: true, + resultNotInArgs: true, + asm: loong64.AFMAXF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "FMAXD", + argLen: 2, + commutative: true, + resultNotInArgs: true, + asm: loong64.AFMAXD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MASKEQZ", + argLen: 2, + asm: loong64.AMASKEQZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MASKNEZ", + argLen: 2, + asm: loong64.AMASKNEZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "FCOPYSGD", + argLen: 2, + asm: loong64.AFCOPYSGD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "SLL", + argLen: 2, + asm: loong64.ASLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SLLV", + argLen: 2, + asm: loong64.ASLLV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SLLconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.ASLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SLLVconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.ASLLV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SRL", + argLen: 2, + asm: loong64.ASRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SRLV", + argLen: 2, + asm: loong64.ASRLV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SRLconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.ASRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SRLVconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.ASRLV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SRA", + argLen: 2, + asm: loong64.ASRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SRAV", + argLen: 2, + asm: loong64.ASRAV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SRAconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.ASRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SRAVconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.ASRAV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ROTR", + argLen: 2, + asm: loong64.AROTR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ROTRV", + argLen: 2, + asm: loong64.AROTRV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ROTRconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.AROTR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ROTRVconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.AROTRV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SGT", + argLen: 2, + asm: loong64.ASGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SGTconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.ASGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SGTU", + argLen: 2, + asm: loong64.ASGTU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "SGTUconst", + auxType: auxInt64, + argLen: 1, + asm: loong64.ASGTU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "CMPEQF", + argLen: 2, + asm: loong64.ACMPEQF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "CMPEQD", + argLen: 2, + asm: loong64.ACMPEQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "CMPGEF", + argLen: 2, + asm: loong64.ACMPGEF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "CMPGED", + argLen: 2, + asm: loong64.ACMPGED, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "CMPGTF", + argLen: 2, + asm: loong64.ACMPGTF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "CMPGTD", + argLen: 2, + asm: loong64.ACMPGTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + {1, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "BSTRPICKW", + auxType: auxInt64, + argLen: 1, + asm: loong64.ABSTRPICKW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "BSTRPICKV", + auxType: auxInt64, + argLen: 1, + asm: loong64.ABSTRPICKV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVVconst", + auxType: auxInt64, + argLen: 0, + rematerializeable: true, + asm: loong64.AMOVV, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVFconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: loong64.AMOVF, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: loong64.AMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVVaddr", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + asm: loong64.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018427387908}, // SP SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVBload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: loong64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVBUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: loong64.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVHload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: loong64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVHUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: loong64.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: loong64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVWUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: loong64.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVVload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: loong64.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVFload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: loong64.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: loong64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVVloadidx", + argLen: 3, + asm: loong64.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVWloadidx", + argLen: 3, + asm: loong64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVWUloadidx", + argLen: 3, + asm: loong64.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVHloadidx", + argLen: 3, + asm: loong64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVHUloadidx", + argLen: 3, + asm: loong64.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVBloadidx", + argLen: 3, + asm: loong64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVBUloadidx", + argLen: 3, + asm: loong64.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVFloadidx", + argLen: 3, + asm: loong64.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVDloadidx", + argLen: 3, + asm: loong64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: loong64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "MOVHstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: loong64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "MOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: loong64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "MOVVstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: loong64.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "MOVFstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: loong64.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + {1, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: loong64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + {1, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVBstoreidx", + argLen: 4, + asm: loong64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {2, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "MOVHstoreidx", + argLen: 4, + asm: loong64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {2, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "MOVWstoreidx", + argLen: 4, + asm: loong64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {2, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "MOVVstoreidx", + argLen: 4, + asm: loong64.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {2, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "MOVFstoreidx", + argLen: 4, + asm: loong64.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + {2, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVDstoreidx", + argLen: 4, + asm: loong64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + {2, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVWfpgp", + argLen: 1, + asm: loong64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVWgpfp", + argLen: 1, + asm: loong64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVVfpgp", + argLen: 1, + asm: loong64.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVVgpfp", + argLen: 1, + asm: loong64.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVBreg", + argLen: 1, + asm: loong64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVBUreg", + argLen: 1, + asm: loong64.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVHreg", + argLen: 1, + asm: loong64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVHUreg", + argLen: 1, + asm: loong64.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVWreg", + argLen: 1, + asm: loong64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVWUreg", + argLen: 1, + asm: loong64.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVVreg", + argLen: 1, + asm: loong64.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVVnop", + argLen: 1, + resultInArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "MOVWF", + argLen: 1, + asm: loong64.AMOVWF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVWD", + argLen: 1, + asm: loong64.AMOVWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVVF", + argLen: 1, + asm: loong64.AMOVVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVVD", + argLen: 1, + asm: loong64.AMOVVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "TRUNCFW", + argLen: 1, + asm: loong64.ATRUNCFW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "TRUNCDW", + argLen: 1, + asm: loong64.ATRUNCDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "TRUNCFV", + argLen: 1, + asm: loong64.ATRUNCFV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "TRUNCDV", + argLen: 1, + asm: loong64.ATRUNCDV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVFD", + argLen: 1, + asm: loong64.AMOVFD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "MOVDF", + argLen: 1, + asm: loong64.AMOVDF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "LoweredRound32F", + argLen: 1, + resultInArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "LoweredRound64F", + argLen: 1, + resultInArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686017353646080}, // 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 + }, + outputs: []outputInfo{ + {0, 4611686017353646080}, // 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 + }, + }, + }, + { + name: "CALLstatic", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + clobbers: 4611686018427387896, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 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 + }, + }, + { + name: "CALLtail", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 4611686018427387896, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 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 + }, + }, + { + name: "CALLclosure", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 268435456}, // R29 + {0, 1071644668}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + clobbers: 4611686018427387896, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 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 + }, + }, + { + name: "CALLinter", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + clobbers: 4611686018427387896, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 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 + }, + }, + { + name: "LoweredZero", + auxType: auxInt64, + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredZeroLoop", + auxType: auxInt64, + argLen: 2, + needIntTemp: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + clobbers: 2305843009213693952, // F31 + clobbersArg0: true, + }, + }, + { + name: "LoweredMove", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1071120376}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R21 R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1071120376}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + clobbers: 524288, // R20 + }, + }, + { + name: "LoweredMoveLoop", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1070071800}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1070071800}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R23 R24 R25 R26 R27 R28 R29 R31 + }, + clobbers: 1572864, // R20 R21 + clobbersArg0: true, + clobbersArg1: true, + }, + }, + { + name: "LoweredAtomicLoad8", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicLoad32", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicLoad64", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicStore8", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "LoweredAtomicStore32", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "LoweredAtomicStore64", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "LoweredAtomicStore8Variant", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "LoweredAtomicStore32Variant", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "LoweredAtomicStore64Variant", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "LoweredAtomicExchange32", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicExchange64", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicExchange8Variant", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicAdd32", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicAdd64", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicCas32", + argLen: 4, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {2, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicCas64", + argLen: 4, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {2, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicCas64Variant", + argLen: 4, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {2, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicCas32Variant", + argLen: 4, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {2, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicAnd32", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + asm: loong64.AAMANDDBW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "LoweredAtomicOr32", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + asm: loong64.AAMORDBW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + }, + }, + { + name: "LoweredAtomicAnd32value", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + asm: loong64.AAMANDDBW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicAnd64value", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + asm: loong64.AAMANDDBV, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicOr32value", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + asm: loong64.AAMORDBW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredAtomicOr64value", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + asm: loong64.AAMORDBV, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {0, 4611686019501129724}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 SB + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "FPFlagTrue", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "FPFlagFalse", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + zeroWidth: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 268435456}, // R29 + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + reg: regInfo{ + clobbers: 4611686017353646082, // R1 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 + outputs: []outputInfo{ + {0, 268435456}, // R29 + }, + }, + }, + { + name: "LoweredPubBarrier", + argLen: 1, + hasSideEffects: true, + asm: loong64.ADBAR, + reg: regInfo{}, + }, + { + name: "LoweredPanicBoundsRR", + auxType: auxInt64, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 524280}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 + {1, 524280}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 + }, + }, + }, + { + name: "LoweredPanicBoundsRC", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 524280}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 + }, + }, + }, + { + name: "LoweredPanicBoundsCR", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 524280}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 + }, + }, + }, + { + name: "LoweredPanicBoundsCC", + auxType: auxPanicBoundsCC, + argLen: 1, + call: true, + reg: regInfo{}, + }, + { + name: "PRELD", + auxType: auxInt64, + argLen: 2, + hasSideEffects: true, + asm: loong64.APRELD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741820}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "PRELDX", + auxType: auxInt64, + argLen: 2, + hasSideEffects: true, + asm: loong64.APRELDX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741820}, // SP R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ADDshiftLLV", + auxType: auxInt64, + argLen: 2, + asm: loong64.AALSLV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073741816}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + {1, 1073741817}, // ZERO R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 g R23 R24 R25 R26 R27 R28 R29 R31 + }, + outputs: []outputInfo{ + {0, 1071644664}, // R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R23 R24 R25 R26 R27 R28 R29 R31 + }, + }, + }, + { + name: "ZERO", + argLen: 0, + zeroWidth: true, + fixedReg: true, + reg: regInfo{}, + }, + + { + name: "ADD", + argLen: 2, + commutative: true, + asm: mips.AADDU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "ADDconst", + auxType: auxInt32, + argLen: 1, + asm: mips.AADDU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 536870910}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SUB", + argLen: 2, + asm: mips.ASUBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SUBconst", + auxType: auxInt32, + argLen: 1, + asm: mips.ASUBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MUL", + argLen: 2, + commutative: true, + asm: mips.AMUL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + clobbers: 105553116266496, // HI LO + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MULT", + argLen: 2, + commutative: true, + asm: mips.AMUL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 35184372088832}, // HI + {1, 70368744177664}, // LO + }, + }, + }, + { + name: "MULTU", + argLen: 2, + commutative: true, + asm: mips.AMULU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 35184372088832}, // HI + {1, 70368744177664}, // LO + }, + }, + }, + { + name: "DIV", + argLen: 2, + asm: mips.ADIV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 35184372088832}, // HI + {1, 70368744177664}, // LO + }, + }, + }, + { + name: "DIVU", + argLen: 2, + asm: mips.ADIVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 35184372088832}, // HI + {1, 70368744177664}, // LO + }, + }, + }, + { + name: "ADDF", + argLen: 2, + commutative: true, + asm: mips.AADDF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "ADDD", + argLen: 2, + commutative: true, + asm: mips.AADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "SUBF", + argLen: 2, + asm: mips.ASUBF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "SUBD", + argLen: 2, + asm: mips.ASUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MULF", + argLen: 2, + commutative: true, + asm: mips.AMULF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MULD", + argLen: 2, + commutative: true, + asm: mips.AMULD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "DIVF", + argLen: 2, + asm: mips.ADIVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "DIVD", + argLen: 2, + asm: mips.ADIVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "AND", + argLen: 2, + commutative: true, + asm: mips.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "ANDconst", + auxType: auxInt32, + argLen: 1, + asm: mips.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "OR", + argLen: 2, + commutative: true, + asm: mips.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "ORconst", + auxType: auxInt32, + argLen: 1, + asm: mips.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "XOR", + argLen: 2, + commutative: true, + asm: mips.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "XORconst", + auxType: auxInt32, + argLen: 1, + asm: mips.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "NOR", + argLen: 2, + commutative: true, + asm: mips.ANOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "NORconst", + auxType: auxInt32, + argLen: 1, + asm: mips.ANOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "NEG", + argLen: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "NEGF", + argLen: 1, + asm: mips.ANEGF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "NEGD", + argLen: 1, + asm: mips.ANEGD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "ABSD", + argLen: 1, + asm: mips.AABSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "SQRTD", + argLen: 1, + asm: mips.ASQRTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "SQRTF", + argLen: 1, + asm: mips.ASQRTF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "SLL", + argLen: 2, + asm: mips.ASLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SLLconst", + auxType: auxInt32, + argLen: 1, + asm: mips.ASLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SRL", + argLen: 2, + asm: mips.ASRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SRLconst", + auxType: auxInt32, + argLen: 1, + asm: mips.ASRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SRA", + argLen: 2, + asm: mips.ASRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SRAconst", + auxType: auxInt32, + argLen: 1, + asm: mips.ASRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "CLZ", + argLen: 1, + asm: mips.ACLZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SGT", + argLen: 2, + asm: mips.ASGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SGTconst", + auxType: auxInt32, + argLen: 1, + asm: mips.ASGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SGTzero", + argLen: 1, + asm: mips.ASGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SGTU", + argLen: 2, + asm: mips.ASGTU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SGTUconst", + auxType: auxInt32, + argLen: 1, + asm: mips.ASGTU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "SGTUzero", + argLen: 1, + asm: mips.ASGTU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "CMPEQF", + argLen: 2, + asm: mips.ACMPEQF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "CMPEQD", + argLen: 2, + asm: mips.ACMPEQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "CMPGEF", + argLen: 2, + asm: mips.ACMPGEF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "CMPGED", + argLen: 2, + asm: mips.ACMPGED, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "CMPGTF", + argLen: 2, + asm: mips.ACMPGTF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "CMPGTD", + argLen: 2, + asm: mips.ACMPGTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MOVWconst", + auxType: auxInt32, + argLen: 0, + rematerializeable: true, + asm: mips.AMOVW, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVFconst", + auxType: auxFloat32, + argLen: 0, + rematerializeable: true, + asm: mips.AMOVF, + reg: regInfo{ + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MOVDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: mips.AMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MOVWaddr", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140737555464192}, // SP SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVBload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVBUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVHload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVHUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVFload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "MOVHstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "MOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "MOVFstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "MOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "MOVBstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "MOVHstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "MOVWstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "MOVWfpgp", + argLen: 1, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVWgpfp", + argLen: 1, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MOVBreg", + argLen: 1, + asm: mips.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVBUreg", + argLen: 1, + asm: mips.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVHreg", + argLen: 1, + asm: mips.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVHUreg", + argLen: 1, + asm: mips.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVWreg", + argLen: 1, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVWnop", + argLen: 1, + resultInArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "CMOVZ", + argLen: 3, + resultInArg0: true, + asm: mips.ACMOVZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + {1, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + {2, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "CMOVZzero", + argLen: 2, + resultInArg0: true, + asm: mips.ACMOVZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "MOVWF", + argLen: 1, + asm: mips.AMOVWF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MOVWD", + argLen: 1, + asm: mips.AMOVWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "TRUNCFW", + argLen: 1, + asm: mips.ATRUNCFW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "TRUNCDW", + argLen: 1, + asm: mips.ATRUNCDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MOVFD", + argLen: 1, + asm: mips.AMOVFD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "MOVDF", + argLen: 1, + asm: mips.AMOVDF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + outputs: []outputInfo{ + {0, 35183835217920}, // F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 + }, + }, + }, + { + name: "CALLstatic", + auxType: auxCallOff, + argLen: 1, + clobberFlags: true, + call: true, + reg: regInfo{ + clobbers: 140737421246462, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 HI LO + }, + }, + { + name: "CALLtail", + auxType: auxCallOff, + argLen: 1, + clobberFlags: true, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 140737421246462, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 HI LO + }, + }, + { + name: "CALLclosure", + auxType: auxCallOff, + argLen: 3, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 4194304}, // R22 + {0, 402653182}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP R31 + }, + clobbers: 140737421246462, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 HI LO + }, + }, + { + name: "CALLinter", + auxType: auxCallOff, + argLen: 2, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + clobbers: 140737421246462, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 HI LO + }, + }, + { + name: "LoweredAtomicLoad8", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "LoweredAtomicLoad32", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "LoweredAtomicStore8", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicStore32", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicStorezero", + argLen: 2, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicExchange", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "LoweredAtomicAdd", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "LoweredAtomicAddconst", + auxType: auxInt32, + argLen: 2, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "LoweredAtomicCas", + argLen: 4, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {2, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "LoweredAtomicAnd", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + asm: mips.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicOr", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + asm: mips.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + {0, 140738025226238}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 SP g R31 SB + }, + }, + }, + { + name: "LoweredZero", + auxType: auxInt32, + argLen: 3, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2}, // R1 + {1, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + clobbers: 2, // R1 + }, + }, + { + name: "LoweredMove", + auxType: auxInt32, + argLen: 4, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4}, // R2 + {1, 2}, // R1 + {2, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + clobbers: 6, // R1 R2 + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 469762046}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 g R31 + }, + }, + }, + { + name: "FPFlagTrue", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "FPFlagFalse", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + zeroWidth: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4194304}, // R22 + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31 + }, + }, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + reg: regInfo{ + clobbers: 140737219919872, // R31 F0 F2 F4 F6 F8 F10 F12 F14 F16 F18 F20 F22 F24 F26 F28 F30 HI LO + outputs: []outputInfo{ + {0, 16777216}, // R25 + }, + }, + }, + { + name: "LoweredPubBarrier", + argLen: 1, + hasSideEffects: true, + asm: mips.ASYNC, + reg: regInfo{}, + }, + { + name: "LoweredPanicBoundsRR", + auxType: auxInt64, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 131070}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 + {1, 131070}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 + }, + }, + }, + { + name: "LoweredPanicBoundsRC", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 131070}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 + }, + }, + }, + { + name: "LoweredPanicBoundsCR", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 131070}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 + }, + }, + }, + { + name: "LoweredPanicBoundsCC", + auxType: auxPanicBoundsCC, + argLen: 1, + call: true, + reg: regInfo{}, + }, + { + name: "LoweredPanicExtendRR", + auxType: auxInt64, + argLen: 4, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 30}, // R1 R2 R3 R4 + {1, 30}, // R1 R2 R3 R4 + {2, 131070}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 + }, + }, + }, + { + name: "LoweredPanicExtendRC", + auxType: auxPanicBoundsC, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 30}, // R1 R2 R3 R4 + {1, 30}, // R1 R2 R3 R4 + }, + }, + }, + + { + name: "ADDV", + argLen: 2, + commutative: true, + asm: mips.AADDVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "ADDVconst", + auxType: auxInt64, + argLen: 1, + asm: mips.AADDVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 268435454}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SUBV", + argLen: 2, + asm: mips.ASUBVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SUBVconst", + auxType: auxInt64, + argLen: 1, + asm: mips.ASUBVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MULV", + argLen: 2, + commutative: true, + asm: mips.AMULV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 1152921504606846976}, // HI + {1, 2305843009213693952}, // LO + }, + }, + }, + { + name: "MULVU", + argLen: 2, + commutative: true, + asm: mips.AMULVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 1152921504606846976}, // HI + {1, 2305843009213693952}, // LO + }, + }, + }, + { + name: "DIVV", + argLen: 2, + asm: mips.ADIVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 1152921504606846976}, // HI + {1, 2305843009213693952}, // LO + }, + }, + }, + { + name: "DIVVU", + argLen: 2, + asm: mips.ADIVVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 1152921504606846976}, // HI + {1, 2305843009213693952}, // LO + }, + }, + }, + { + name: "ADDF", + argLen: 2, + commutative: true, + asm: mips.AADDF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "ADDD", + argLen: 2, + commutative: true, + asm: mips.AADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "SUBF", + argLen: 2, + asm: mips.ASUBF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "SUBD", + argLen: 2, + asm: mips.ASUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MULF", + argLen: 2, + commutative: true, + asm: mips.AMULF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MULD", + argLen: 2, + commutative: true, + asm: mips.AMULD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "DIVF", + argLen: 2, + asm: mips.ADIVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "DIVD", + argLen: 2, + asm: mips.ADIVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "AND", + argLen: 2, + commutative: true, + asm: mips.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "ANDconst", + auxType: auxInt64, + argLen: 1, + asm: mips.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "OR", + argLen: 2, + commutative: true, + asm: mips.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "ORconst", + auxType: auxInt64, + argLen: 1, + asm: mips.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "XOR", + argLen: 2, + commutative: true, + asm: mips.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "XORconst", + auxType: auxInt64, + argLen: 1, + asm: mips.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "NOR", + argLen: 2, + commutative: true, + asm: mips.ANOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "NORconst", + auxType: auxInt64, + argLen: 1, + asm: mips.ANOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "NEGV", + argLen: 1, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "NEGF", + argLen: 1, + asm: mips.ANEGF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "NEGD", + argLen: 1, + asm: mips.ANEGD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "ABSD", + argLen: 1, + asm: mips.AABSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "SQRTD", + argLen: 1, + asm: mips.ASQRTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "SQRTF", + argLen: 1, + asm: mips.ASQRTF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "SLLV", + argLen: 2, + asm: mips.ASLLV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SLLVconst", + auxType: auxInt64, + argLen: 1, + asm: mips.ASLLV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SRLV", + argLen: 2, + asm: mips.ASRLV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SRLVconst", + auxType: auxInt64, + argLen: 1, + asm: mips.ASRLV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SRAV", + argLen: 2, + asm: mips.ASRAV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SRAVconst", + auxType: auxInt64, + argLen: 1, + asm: mips.ASRAV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SGT", + argLen: 2, + asm: mips.ASGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SGTconst", + auxType: auxInt64, + argLen: 1, + asm: mips.ASGT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SGTU", + argLen: 2, + asm: mips.ASGTU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "SGTUconst", + auxType: auxInt64, + argLen: 1, + asm: mips.ASGTU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "CMPEQF", + argLen: 2, + asm: mips.ACMPEQF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "CMPEQD", + argLen: 2, + asm: mips.ACMPEQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "CMPGEF", + argLen: 2, + asm: mips.ACMPGEF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "CMPGED", + argLen: 2, + asm: mips.ACMPGED, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "CMPGTF", + argLen: 2, + asm: mips.ACMPGTF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "CMPGTD", + argLen: 2, + asm: mips.ACMPGTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + {1, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVVconst", + auxType: auxInt64, + argLen: 0, + rematerializeable: true, + asm: mips.AMOVV, + reg: regInfo{ + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVFconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: mips.AMOVF, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: mips.AMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVVaddr", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + asm: mips.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018460942336}, // SP SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVBload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVBUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVHload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVHUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVWUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVVload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVFload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: mips.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "MOVHstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "MOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "MOVVstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "MOVFstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + {1, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: mips.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + {1, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "ZERO", + argLen: 0, + zeroWidth: true, + fixedReg: true, + reg: regInfo{}, + }, + { + name: "MOVWfpgp", + argLen: 1, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVWgpfp", + argLen: 1, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVVfpgp", + argLen: 1, + asm: mips.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVVgpfp", + argLen: 1, + asm: mips.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVBreg", + argLen: 1, + asm: mips.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVBUreg", + argLen: 1, + asm: mips.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVHreg", + argLen: 1, + asm: mips.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVHUreg", + argLen: 1, + asm: mips.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVWreg", + argLen: 1, + asm: mips.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVWUreg", + argLen: 1, + asm: mips.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVVreg", + argLen: 1, + asm: mips.AMOVV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVVnop", + argLen: 1, + resultInArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "MOVWF", + argLen: 1, + asm: mips.AMOVWF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVWD", + argLen: 1, + asm: mips.AMOVWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVVF", + argLen: 1, + asm: mips.AMOVVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVVD", + argLen: 1, + asm: mips.AMOVVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "TRUNCFW", + argLen: 1, + asm: mips.ATRUNCFW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "TRUNCDW", + argLen: 1, + asm: mips.ATRUNCDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "TRUNCFV", + argLen: 1, + asm: mips.ATRUNCFV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "TRUNCDV", + argLen: 1, + asm: mips.ATRUNCDV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVFD", + argLen: 1, + asm: mips.AMOVFD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "MOVDF", + argLen: 1, + asm: mips.AMOVDF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1152921504338411520}, // 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 + }, + outputs: []outputInfo{ + {0, 1152921504338411520}, // 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 + }, + }, + }, + { + name: "CALLstatic", + auxType: auxCallOff, + argLen: 1, + clobberFlags: true, + call: true, + reg: regInfo{ + clobbers: 4611686018393833470, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 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 HI LO + }, + }, + { + name: "CALLtail", + auxType: auxCallOff, + argLen: 1, + clobberFlags: true, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 4611686018393833470, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 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 HI LO + }, + }, + { + name: "CALLclosure", + auxType: auxCallOff, + argLen: 3, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 4194304}, // R22 + {0, 201326590}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP R31 + }, + clobbers: 4611686018393833470, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 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 HI LO + }, + }, + { + name: "CALLinter", + auxType: auxCallOff, + argLen: 2, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + clobbers: 4611686018393833470, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 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 HI LO + }, + }, + { + name: "DUFFZERO", + auxType: auxInt64, + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + clobbers: 134217730, // R1 R31 + }, + }, + { + name: "DUFFCOPY", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4}, // R2 + {1, 2}, // R1 + }, + clobbers: 134217734, // R1 R2 R31 + }, + }, + { + name: "LoweredZero", + auxType: auxInt64, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2}, // R1 + {1, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + clobbers: 2, // R1 + }, + }, + { + name: "LoweredMove", + auxType: auxInt64, + argLen: 4, + clobberFlags: true, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4}, // R2 + {1, 2}, // R1 + {2, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + clobbers: 6, // R1 R2 + }, + }, + { + name: "LoweredAtomicAnd32", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + asm: mips.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicOr32", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + asm: mips.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicLoad8", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredAtomicLoad32", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredAtomicLoad64", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredAtomicStore8", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicStore32", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicStore64", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881023}, // ZERO R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicStorezero32", + argLen: 2, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicStorezero64", + argLen: 2, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + }, + }, + { + name: "LoweredAtomicExchange32", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredAtomicExchange64", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredAtomicAdd32", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredAtomicAdd64", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredAtomicAddconst32", + auxType: auxInt32, + argLen: 2, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredAtomicAddconst64", + auxType: auxInt64, + argLen: 2, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredAtomicCas32", + argLen: 4, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {2, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredAtomicCas64", + argLen: 4, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {2, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + {0, 4611686018695823358}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 SP g R31 SB + }, + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 234881022}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 g R31 + }, + }, + }, + { + name: "FPFlagTrue", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "FPFlagFalse", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + zeroWidth: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4194304}, // R22 + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31 + }, + }, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + reg: regInfo{ + clobbers: 4611686018293170176, // R31 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 HI LO + outputs: []outputInfo{ + {0, 16777216}, // R25 + }, + }, + }, + { + name: "LoweredPubBarrier", + argLen: 1, + hasSideEffects: true, + asm: mips.ASYNC, + reg: regInfo{}, + }, + { + name: "LoweredPanicBoundsRR", + auxType: auxInt64, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 131070}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 + {1, 131070}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 + }, + }, + }, + { + name: "LoweredPanicBoundsRC", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 131070}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 + }, + }, + }, + { + name: "LoweredPanicBoundsCR", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 131070}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 + }, + }, + }, + { + name: "LoweredPanicBoundsCC", + auxType: auxPanicBoundsCC, + argLen: 1, + call: true, + reg: regInfo{}, + }, + + { + name: "ADD", + argLen: 2, + commutative: true, + asm: ppc64.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ADDCC", + argLen: 2, + commutative: true, + asm: ppc64.AADDCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ADDconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ADDCCconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.AADDCCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FADD", + argLen: 2, + commutative: true, + asm: ppc64.AFADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FADDS", + argLen: 2, + commutative: true, + asm: ppc64.AFADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "SUB", + argLen: 2, + asm: ppc64.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SUBCC", + argLen: 2, + asm: ppc64.ASUBCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SUBFCconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ASUBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FSUB", + argLen: 2, + asm: ppc64.AFSUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FSUBS", + argLen: 2, + asm: ppc64.AFSUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "XSMINJDP", + argLen: 2, + asm: ppc64.AXSMINJDP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "XSMAXJDP", + argLen: 2, + asm: ppc64.AXSMAXJDP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "MULLD", + argLen: 2, + commutative: true, + asm: ppc64.AMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MULLW", + argLen: 2, + commutative: true, + asm: ppc64.AMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MULLDconst", + auxType: auxInt32, + argLen: 1, + asm: ppc64.AMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MULLWconst", + auxType: auxInt32, + argLen: 1, + asm: ppc64.AMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MADDLD", + argLen: 3, + asm: ppc64.AMADDLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MULHD", + argLen: 2, + commutative: true, + asm: ppc64.AMULHD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MULHW", + argLen: 2, + commutative: true, + asm: ppc64.AMULHW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MULHDU", + argLen: 2, + commutative: true, + asm: ppc64.AMULHDU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MULHDUCC", + argLen: 2, + commutative: true, + asm: ppc64.AMULHDUCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MULHWU", + argLen: 2, + commutative: true, + asm: ppc64.AMULHWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FMUL", + argLen: 2, + commutative: true, + asm: ppc64.AFMUL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FMULS", + argLen: 2, + commutative: true, + asm: ppc64.AFMULS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FMADD", + argLen: 3, + asm: ppc64.AFMADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + {2, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FMADDS", + argLen: 3, + asm: ppc64.AFMADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + {2, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FMSUB", + argLen: 3, + asm: ppc64.AFMSUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + {2, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FMSUBS", + argLen: 3, + asm: ppc64.AFMSUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + {2, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "SRAD", + argLen: 2, + asm: ppc64.ASRAD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SRAW", + argLen: 2, + asm: ppc64.ASRAW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SRD", + argLen: 2, + asm: ppc64.ASRD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SRW", + argLen: 2, + asm: ppc64.ASRW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SLD", + argLen: 2, + asm: ppc64.ASLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SLW", + argLen: 2, + asm: ppc64.ASLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ROTL", + argLen: 2, + asm: ppc64.AROTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ROTLW", + argLen: 2, + asm: ppc64.AROTLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CLRLSLWI", + auxType: auxInt32, + argLen: 1, + asm: ppc64.ACLRLSLWI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CLRLSLDI", + auxType: auxInt32, + argLen: 1, + asm: ppc64.ACLRLSLDI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ADDC", + argLen: 2, + commutative: true, + asm: ppc64.AADDC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {1, 9223372036854775808}, // XER + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SUBC", + argLen: 2, + asm: ppc64.ASUBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {1, 9223372036854775808}, // XER + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ADDCconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.AADDC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {1, 9223372036854775808}, // XER + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SUBCconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ASUBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {1, 9223372036854775808}, // XER + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ADDE", + argLen: 3, + commutative: true, + asm: ppc64.AADDE, + reg: regInfo{ + inputs: []inputInfo{ + {2, 9223372036854775808}, // XER + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {1, 9223372036854775808}, // XER + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ADDZE", + argLen: 2, + asm: ppc64.AADDZE, + reg: regInfo{ + inputs: []inputInfo{ + {1, 9223372036854775808}, // XER + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {1, 9223372036854775808}, // XER + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SUBE", + argLen: 3, + asm: ppc64.ASUBE, + reg: regInfo{ + inputs: []inputInfo{ + {2, 9223372036854775808}, // XER + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {1, 9223372036854775808}, // XER + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ADDZEzero", + argLen: 1, + asm: ppc64.AADDZE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372036854775808}, // XER + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SUBZEzero", + argLen: 1, + asm: ppc64.ASUBZE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372036854775808}, // XER + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SRADconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ASRAD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SRAWconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ASRAW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 9223372036854775808, // XER + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SRDconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ASRD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SRWconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ASRW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SLDconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ASLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SLWconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ASLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ROTLconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.AROTL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ROTLWconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.AROTLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "EXTSWSLconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.AEXTSWSLI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "RLWINM", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ARLWNM, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "RLWNM", + auxType: auxInt64, + argLen: 2, + asm: ppc64.ARLWNM, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "RLWMI", + auxType: auxInt64, + argLen: 2, + resultInArg0: true, + asm: ppc64.ARLWMI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "RLDICL", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ARLDICL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "RLDICLCC", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ARLDICLCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "RLDICR", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ARLDICR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CNTLZD", + argLen: 1, + asm: ppc64.ACNTLZD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CNTLZDCC", + argLen: 1, + asm: ppc64.ACNTLZDCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CNTLZW", + argLen: 1, + asm: ppc64.ACNTLZW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CNTTZD", + argLen: 1, + asm: ppc64.ACNTTZD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CNTTZW", + argLen: 1, + asm: ppc64.ACNTTZW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "POPCNTD", + argLen: 1, + asm: ppc64.APOPCNTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "POPCNTW", + argLen: 1, + asm: ppc64.APOPCNTW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "POPCNTB", + argLen: 1, + asm: ppc64.APOPCNTB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FDIV", + argLen: 2, + asm: ppc64.AFDIV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FDIVS", + argLen: 2, + asm: ppc64.AFDIVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "DIVD", + argLen: 2, + asm: ppc64.ADIVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "DIVW", + argLen: 2, + asm: ppc64.ADIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "DIVDU", + argLen: 2, + asm: ppc64.ADIVDU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "DIVWU", + argLen: 2, + asm: ppc64.ADIVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MODUD", + argLen: 2, + asm: ppc64.AMODUD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MODSD", + argLen: 2, + asm: ppc64.AMODSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MODUW", + argLen: 2, + asm: ppc64.AMODUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MODSW", + argLen: 2, + asm: ppc64.AMODSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FCTIDZ", + argLen: 1, + asm: ppc64.AFCTIDZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FCTIWZ", + argLen: 1, + asm: ppc64.AFCTIWZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FCFID", + argLen: 1, + asm: ppc64.AFCFID, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FCFIDS", + argLen: 1, + asm: ppc64.AFCFIDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FRSP", + argLen: 1, + asm: ppc64.AFRSP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "MFVSRD", + argLen: 1, + asm: ppc64.AMFVSRD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MTVSRD", + argLen: 1, + asm: ppc64.AMTVSRD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "AND", + argLen: 2, + commutative: true, + asm: ppc64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ANDN", + argLen: 2, + asm: ppc64.AANDN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ANDNCC", + argLen: 2, + asm: ppc64.AANDNCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ANDCC", + argLen: 2, + commutative: true, + asm: ppc64.AANDCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "OR", + argLen: 2, + commutative: true, + asm: ppc64.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ORN", + argLen: 2, + asm: ppc64.AORN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ORCC", + argLen: 2, + commutative: true, + asm: ppc64.AORCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "NOR", + argLen: 2, + commutative: true, + asm: ppc64.ANOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "NORCC", + argLen: 2, + commutative: true, + asm: ppc64.ANORCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "XOR", + argLen: 2, + commutative: true, + asm: ppc64.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "XORCC", + argLen: 2, + commutative: true, + asm: ppc64.AXORCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "EQV", + argLen: 2, + commutative: true, + asm: ppc64.AEQV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "NEG", + argLen: 1, + asm: ppc64.ANEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "NEGCC", + argLen: 1, + asm: ppc64.ANEGCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "BRD", + argLen: 1, + asm: ppc64.ABRD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "BRW", + argLen: 1, + asm: ppc64.ABRW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "BRH", + argLen: 1, + asm: ppc64.ABRH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FNEG", + argLen: 1, + asm: ppc64.AFNEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FSQRT", + argLen: 1, + asm: ppc64.AFSQRT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FSQRTS", + argLen: 1, + asm: ppc64.AFSQRTS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FFLOOR", + argLen: 1, + asm: ppc64.AFRIM, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FCEIL", + argLen: 1, + asm: ppc64.AFRIP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FTRUNC", + argLen: 1, + asm: ppc64.AFRIZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FROUND", + argLen: 1, + asm: ppc64.AFRIN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FABS", + argLen: 1, + asm: ppc64.AFABS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FNABS", + argLen: 1, + asm: ppc64.AFNABS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FCPSGN", + argLen: 2, + asm: ppc64.AFCPSGN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "ORconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "XORconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ANDCCconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.AANDCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ANDconst", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + asm: ppc64.AANDCC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVBreg", + argLen: 1, + asm: ppc64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVBZreg", + argLen: 1, + asm: ppc64.AMOVBZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHreg", + argLen: 1, + asm: ppc64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHZreg", + argLen: 1, + asm: ppc64.AMOVHZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWreg", + argLen: 1, + asm: ppc64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWZreg", + argLen: 1, + asm: ppc64.AMOVWZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVBZload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: ppc64.AMOVBZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: ppc64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHZload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: ppc64.AMOVHZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: ppc64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWZload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: ppc64.AMOVWZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: ppc64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDBRload", + argLen: 2, + faultOnNilArg0: true, + asm: ppc64.AMOVDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWBRload", + argLen: 2, + faultOnNilArg0: true, + asm: ppc64.AMOVWBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHBRload", + argLen: 2, + faultOnNilArg0: true, + asm: ppc64.AMOVHBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVBZloadidx", + argLen: 3, + asm: ppc64.AMOVBZ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHloadidx", + argLen: 3, + asm: ppc64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHZloadidx", + argLen: 3, + asm: ppc64.AMOVHZ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWloadidx", + argLen: 3, + asm: ppc64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWZloadidx", + argLen: 3, + asm: ppc64.AMOVWZ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDloadidx", + argLen: 3, + asm: ppc64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHBRloadidx", + argLen: 3, + asm: ppc64.AMOVHBR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWBRloadidx", + argLen: 3, + asm: ppc64.AMOVWBR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDBRloadidx", + argLen: 3, + asm: ppc64.AMOVDBR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FMOVDloadidx", + argLen: 3, + asm: ppc64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FMOVSloadidx", + argLen: 3, + asm: ppc64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "DCBT", + auxType: auxInt64, + argLen: 2, + hasSideEffects: true, + asm: ppc64.ADCBT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDBRstore", + argLen: 3, + faultOnNilArg0: true, + asm: ppc64.AMOVDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWBRstore", + argLen: 3, + faultOnNilArg0: true, + asm: ppc64.AMOVWBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHBRstore", + argLen: 3, + faultOnNilArg0: true, + asm: ppc64.AMOVHBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FMOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: ppc64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FMOVSload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: ppc64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "MOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: ppc64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: ppc64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: ppc64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: ppc64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FMOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: ppc64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FMOVSstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: ppc64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "MOVBstoreidx", + argLen: 4, + asm: ppc64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHstoreidx", + argLen: 4, + asm: ppc64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWstoreidx", + argLen: 4, + asm: ppc64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDstoreidx", + argLen: 4, + asm: ppc64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FMOVDstoreidx", + argLen: 4, + asm: ppc64.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FMOVSstoreidx", + argLen: 4, + asm: ppc64.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "MOVHBRstoreidx", + argLen: 4, + asm: ppc64.AMOVHBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWBRstoreidx", + argLen: 4, + asm: ppc64.AMOVWBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDBRstoreidx", + argLen: 4, + asm: ppc64.AMOVDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVBstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: ppc64.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVHstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: ppc64.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVWstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: ppc64.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: ppc64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDaddr", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + asm: ppc64.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "MOVDconst", + auxType: auxInt64, + argLen: 0, + rematerializeable: true, + asm: ppc64.AMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FMOVDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: ppc64.AFMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FMOVSconst", + auxType: auxFloat32, + argLen: 0, + rematerializeable: true, + asm: ppc64.AFMOVS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "FCMPU", + argLen: 2, + asm: ppc64.AFCMPU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + {1, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "CMP", + argLen: 2, + asm: ppc64.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CMPU", + argLen: 2, + asm: ppc64.ACMPU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CMPW", + argLen: 2, + asm: ppc64.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CMPWU", + argLen: 2, + asm: ppc64.ACMPWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CMPconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CMPUconst", + auxType: auxInt64, + argLen: 1, + asm: ppc64.ACMPU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CMPWconst", + auxType: auxInt32, + argLen: 1, + asm: ppc64.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "CMPWUconst", + auxType: auxInt32, + argLen: 1, + asm: ppc64.ACMPWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ISEL", + auxType: auxInt32, + argLen: 3, + asm: ppc64.AISEL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "ISELZ", + auxType: auxInt32, + argLen: 2, + asm: ppc64.AISEL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SETBC", + auxType: auxInt32, + argLen: 1, + asm: ppc64.ASETBC, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "SETBCR", + auxType: auxInt32, + argLen: 1, + asm: ppc64.ASETBCR, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "Equal", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "NotEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LessThan", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FLessThan", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LessEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FLessEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "GreaterThan", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FGreaterThan", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "GreaterEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "FGreaterEqual", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + zeroWidth: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 2048}, // R11 + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + clobberFlags: true, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + clobbers: 2147483648, // R31 + }, + }, + { + name: "LoweredRound32F", + argLen: 1, + resultInArg0: true, + zeroWidth: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "LoweredRound64F", + argLen: 1, + resultInArg0: true, + zeroWidth: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372032559808512}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372032559808512}, // 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 + }, + }, + }, + { + name: "CALLstatic", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + clobbers: 18446744071562059768, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 g 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 XER + }, + }, + { + name: "CALLtail", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 18446744071562059768, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 g 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 XER + }, + }, + { + name: "CALLclosure", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4096}, // R12 + {1, 2048}, // R11 + }, + clobbers: 18446744071562059768, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 g 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 XER + }, + }, + { + name: "CALLinter", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4096}, // R12 + }, + clobbers: 18446744071562059768, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 g 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 XER + }, + }, + { + name: "LoweredZero", + auxType: auxInt64, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1048576}, // R20 + }, + clobbers: 1048576, // R20 + }, + }, + { + name: "LoweredZeroShort", + auxType: auxInt64, + argLen: 2, + faultOnNilArg0: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredQuadZeroShort", + auxType: auxInt64, + argLen: 2, + faultOnNilArg0: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredQuadZero", + auxType: auxInt64, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1048576}, // R20 + }, + clobbers: 1048576, // R20 + }, + }, + { + name: "LoweredMove", + auxType: auxInt64, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + faultOnNilArg1: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1048576}, // R20 + {1, 2097152}, // R21 + }, + clobbers: 3145728, // R20 R21 + }, + }, + { + name: "LoweredMoveShort", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredQuadMove", + auxType: auxInt64, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + faultOnNilArg1: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1048576}, // R20 + {1, 2097152}, // R21 + }, + clobbers: 3145728, // R20 R21 + }, + }, + { + name: "LoweredQuadMoveShort", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicStore8", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicStore32", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicStore64", + auxType: auxInt64, + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicLoad8", + auxType: auxInt64, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicLoad32", + auxType: auxInt64, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicLoad64", + auxType: auxInt64, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicLoadPtr", + auxType: auxInt64, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicAdd32", + argLen: 3, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicAdd64", + argLen: 3, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicExchange8", + argLen: 3, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicExchange32", + argLen: 3, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicExchange64", + argLen: 3, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicCas64", + auxType: auxInt64, + argLen: 4, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicCas32", + auxType: auxInt64, + argLen: 4, + resultNotInArgs: true, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {2, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + outputs: []outputInfo{ + {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicAnd8", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + asm: ppc64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicAnd32", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + asm: ppc64.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicOr8", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + asm: ppc64.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredAtomicOr32", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + asm: ppc64.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + {1, 1073733630}, // SP SB R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 + }, + }, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + reg: regInfo{ + clobbers: 18446744072632408064, // R11 R12 R18 R19 R22 R23 R24 R25 R26 R27 R28 R29 R31 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 XER + outputs: []outputInfo{ + {0, 536870912}, // R29 + }, + }, + }, + { + name: "LoweredPubBarrier", + argLen: 1, + hasSideEffects: true, + asm: ppc64.ALWSYNC, + reg: regInfo{}, + }, + { + name: "LoweredPanicBoundsRR", + auxType: auxInt64, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1016}, // R3 R4 R5 R6 R7 R8 R9 + {1, 1016}, // R3 R4 R5 R6 R7 R8 R9 + }, + }, + }, + { + name: "LoweredPanicBoundsRC", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1016}, // R3 R4 R5 R6 R7 R8 R9 + }, + }, + }, + { + name: "LoweredPanicBoundsCR", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1016}, // R3 R4 R5 R6 R7 R8 R9 + }, + }, + }, + { + name: "LoweredPanicBoundsCC", + auxType: auxPanicBoundsCC, + argLen: 1, + call: true, + reg: regInfo{}, + }, + { + name: "InvertFlags", + argLen: 1, + reg: regInfo{}, + }, + { + name: "FlagEQ", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagLT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagGT", + argLen: 0, + reg: regInfo{}, + }, + + { + name: "ADD", + argLen: 2, + commutative: true, + asm: riscv.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "ADDI", + auxType: auxInt64, + argLen: 1, + asm: riscv.AADDI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "ADDIW", + auxType: auxInt64, + argLen: 1, + asm: riscv.AADDIW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "NEG", + argLen: 1, + asm: riscv.ANEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "NEGW", + argLen: 1, + asm: riscv.ANEGW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SUB", + argLen: 2, + asm: riscv.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SUBW", + argLen: 2, + asm: riscv.ASUBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MUL", + argLen: 2, + commutative: true, + asm: riscv.AMUL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MULW", + argLen: 2, + commutative: true, + asm: riscv.AMULW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MULH", + argLen: 2, + commutative: true, + asm: riscv.AMULH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MULHU", + argLen: 2, + commutative: true, + asm: riscv.AMULHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredMuluhilo", + argLen: 2, + resultNotInArgs: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredMuluover", + argLen: 2, + resultNotInArgs: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "DIV", + argLen: 2, + asm: riscv.ADIV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "DIVU", + argLen: 2, + asm: riscv.ADIVU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "DIVW", + argLen: 2, + asm: riscv.ADIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "DIVUW", + argLen: 2, + asm: riscv.ADIVUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "REM", + argLen: 2, + asm: riscv.AREM, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "REMU", + argLen: 2, + asm: riscv.AREMU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "REMW", + argLen: 2, + asm: riscv.AREMW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "REMUW", + argLen: 2, + asm: riscv.AREMUW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVaddr", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + asm: riscv.AMOV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVDconst", + auxType: auxInt64, + argLen: 0, + rematerializeable: true, + asm: riscv.AMOV, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FMOVDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: riscv.AMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVFconst", + auxType: auxFloat32, + argLen: 0, + rematerializeable: true, + asm: riscv.AMOVF, + reg: regInfo{ + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "MOVBload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: riscv.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVHload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: riscv.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: riscv.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: riscv.AMOV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVBUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: riscv.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVHUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: riscv.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVWUload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: riscv.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: riscv.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "MOVHstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: riscv.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "MOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: riscv.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "MOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: riscv.AMOV, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "MOVBstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: riscv.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "MOVHstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: riscv.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "MOVWstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: riscv.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "MOVDstorezero", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: riscv.AMOV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "MOVBreg", + argLen: 1, + asm: riscv.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVHreg", + argLen: 1, + asm: riscv.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVWreg", + argLen: 1, + asm: riscv.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVDreg", + argLen: 1, + asm: riscv.AMOV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVBUreg", + argLen: 1, + asm: riscv.AMOVBU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVHUreg", + argLen: 1, + asm: riscv.AMOVHU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVWUreg", + argLen: 1, + asm: riscv.AMOVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MOVDnop", + argLen: 1, + resultInArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SLL", + argLen: 2, + asm: riscv.ASLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SLLW", + argLen: 2, + asm: riscv.ASLLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SRA", + argLen: 2, + asm: riscv.ASRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SRAW", + argLen: 2, + asm: riscv.ASRAW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SRL", + argLen: 2, + asm: riscv.ASRL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SRLW", + argLen: 2, + asm: riscv.ASRLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SLLI", + auxType: auxInt64, + argLen: 1, + asm: riscv.ASLLI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SLLIW", + auxType: auxInt64, + argLen: 1, + asm: riscv.ASLLIW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SRAI", + auxType: auxInt64, + argLen: 1, + asm: riscv.ASRAI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SRAIW", + auxType: auxInt64, + argLen: 1, + asm: riscv.ASRAIW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SRLI", + auxType: auxInt64, + argLen: 1, + asm: riscv.ASRLI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SRLIW", + auxType: auxInt64, + argLen: 1, + asm: riscv.ASRLIW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SH1ADD", + argLen: 2, + asm: riscv.ASH1ADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SH2ADD", + argLen: 2, + asm: riscv.ASH2ADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SH3ADD", + argLen: 2, + asm: riscv.ASH3ADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "AND", + argLen: 2, + commutative: true, + asm: riscv.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "ANDN", + argLen: 2, + asm: riscv.AANDN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "ANDI", + auxType: auxInt64, + argLen: 1, + asm: riscv.AANDI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "CLZ", + argLen: 1, + asm: riscv.ACLZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "CLZW", + argLen: 1, + asm: riscv.ACLZW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "CPOP", + argLen: 1, + asm: riscv.ACPOP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "CPOPW", + argLen: 1, + asm: riscv.ACPOPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "CTZ", + argLen: 1, + asm: riscv.ACTZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "CTZW", + argLen: 1, + asm: riscv.ACTZW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "NOT", + argLen: 1, + asm: riscv.ANOT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "OR", + argLen: 2, + commutative: true, + asm: riscv.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "ORN", + argLen: 2, + asm: riscv.AORN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "ORI", + auxType: auxInt64, + argLen: 1, + asm: riscv.AORI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "REV8", + argLen: 1, + asm: riscv.AREV8, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "ROL", + argLen: 2, + asm: riscv.AROL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "ROLW", + argLen: 2, + asm: riscv.AROLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "ROR", + argLen: 2, + asm: riscv.AROR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "RORI", + auxType: auxInt64, + argLen: 1, + asm: riscv.ARORI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "RORIW", + auxType: auxInt64, + argLen: 1, + asm: riscv.ARORIW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "RORW", + argLen: 2, + asm: riscv.ARORW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "XNOR", + argLen: 2, + commutative: true, + asm: riscv.AXNOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "XOR", + argLen: 2, + commutative: true, + asm: riscv.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "XORI", + auxType: auxInt64, + argLen: 1, + asm: riscv.AXORI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MIN", + argLen: 2, + commutative: true, + asm: riscv.AMIN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MAX", + argLen: 2, + commutative: true, + asm: riscv.AMAX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MINU", + argLen: 2, + commutative: true, + asm: riscv.AMINU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "MAXU", + argLen: 2, + commutative: true, + asm: riscv.AMAXU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SEQZ", + argLen: 1, + asm: riscv.ASEQZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SNEZ", + argLen: 1, + asm: riscv.ASNEZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SLT", + argLen: 2, + asm: riscv.ASLT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SLTI", + auxType: auxInt64, + argLen: 1, + asm: riscv.ASLTI, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SLTU", + argLen: 2, + asm: riscv.ASLTU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "SLTIU", + auxType: auxInt64, + argLen: 1, + asm: riscv.ASLTIU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredRound32F", + argLen: 1, + resultInArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "LoweredRound64F", + argLen: 1, + resultInArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "CALLstatic", + auxType: auxCallOff, + argLen: -1, + call: true, + reg: regInfo{ + clobbers: 9223372035781033968, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 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 + }, + }, + { + name: "CALLtail", + auxType: auxCallOff, + argLen: -1, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 9223372035781033968, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 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 + }, + }, + { + name: "CALLclosure", + auxType: auxCallOff, + argLen: -1, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 33554432}, // X26 + {0, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + clobbers: 9223372035781033968, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 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 + }, + }, + { + name: "CALLinter", + auxType: auxCallOff, + argLen: -1, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + clobbers: 9223372035781033968, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 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 + }, + }, + { + name: "LoweredZero", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredZeroLoop", + auxType: auxSymValAndOff, + argLen: 2, + needIntTemp: true, + faultOnNilArg0: true, + symEffect: SymWrite, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + clobbersArg0: true, + }, + }, + { + name: "LoweredMove", + auxType: auxSymValAndOff, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + symEffect: SymWrite, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632928}, // X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632928}, // X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + clobbers: 16, // X5 + }, + }, + { + name: "LoweredMoveLoop", + auxType: auxSymValAndOff, + argLen: 3, + faultOnNilArg0: true, + faultOnNilArg1: true, + symEffect: SymWrite, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632896}, // X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {1, 1006632896}, // X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + clobbers: 48, // X5 X6 + clobbersArg0: true, + clobbersArg1: true, + }, + }, + { + name: "LoweredAtomicLoad8", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredAtomicLoad32", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredAtomicLoad64", + argLen: 2, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredAtomicStore8", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "LoweredAtomicStore32", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "LoweredAtomicStore64", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + }, + }, + { + name: "LoweredAtomicExchange32", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredAtomicExchange64", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredAtomicAdd32", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredAtomicAdd64", + argLen: 3, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredAtomicCas32", + argLen: 4, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {2, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredAtomicCas64", + argLen: 4, + resultNotInArgs: true, + faultOnNilArg0: true, + hasSideEffects: true, + unsafePoint: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {2, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredAtomicAnd32", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + asm: riscv.AAMOANDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + }, + }, + }, + { + name: "LoweredAtomicOr32", + argLen: 3, + faultOnNilArg0: true, + hasSideEffects: true, + asm: riscv.AAMOORW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1073741808}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 + {0, 9223372037928517618}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 g X28 X29 X30 SB + }, + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632946}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + reg: regInfo{ + outputs: []outputInfo{ + {0, 33554432}, // X26 + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + reg: regInfo{ + clobbers: 9223372034707292160, // 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 + outputs: []outputInfo{ + {0, 8388608}, // X24 + }, + }, + }, + { + name: "LoweredPubBarrier", + argLen: 1, + hasSideEffects: true, + asm: riscv.AFENCE, + reg: regInfo{}, + }, + { + name: "LoweredPanicBoundsRR", + auxType: auxInt64, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1048560}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 + {1, 1048560}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 + }, + }, + }, + { + name: "LoweredPanicBoundsRC", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1048560}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 + }, + }, + }, + { + name: "LoweredPanicBoundsCR", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1048560}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 + }, + }, + }, + { + name: "LoweredPanicBoundsCC", + auxType: auxPanicBoundsCC, + argLen: 1, + call: true, + reg: regInfo{}, + }, + { + name: "FADDS", + argLen: 2, + commutative: true, + asm: riscv.AFADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FSUBS", + argLen: 2, + asm: riscv.AFSUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMULS", + argLen: 2, + commutative: true, + asm: riscv.AFMULS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FDIVS", + argLen: 2, + asm: riscv.AFDIVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMADDS", + argLen: 3, + commutative: true, + asm: riscv.AFMADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMSUBS", + argLen: 3, + commutative: true, + asm: riscv.AFMSUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNMADDS", + argLen: 3, + commutative: true, + asm: riscv.AFNMADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNMSUBS", + argLen: 3, + commutative: true, + asm: riscv.AFNMSUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FSQRTS", + argLen: 1, + asm: riscv.AFSQRTS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNEGS", + argLen: 1, + asm: riscv.AFNEGS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMVSX", + argLen: 1, + asm: riscv.AFMVSX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMVXS", + argLen: 1, + asm: riscv.AFMVXS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FCVTSW", + argLen: 1, + asm: riscv.AFCVTSW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCVTSL", + argLen: 1, + asm: riscv.AFCVTSL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCVTWS", + argLen: 1, + asm: riscv.AFCVTWS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FCVTLS", + argLen: 1, + asm: riscv.AFCVTLS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FMOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: riscv.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: riscv.AMOVF, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {1, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FEQS", + argLen: 2, + commutative: true, + asm: riscv.AFEQS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FNES", + argLen: 2, + commutative: true, + asm: riscv.AFNES, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FLTS", + argLen: 2, + asm: riscv.AFLTS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FLES", + argLen: 2, + asm: riscv.AFLES, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredFMAXS", + argLen: 2, + commutative: true, + resultNotInArgs: true, + asm: riscv.AFMAXS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "LoweredFMINS", + argLen: 2, + commutative: true, + resultNotInArgs: true, + asm: riscv.AFMINS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FADDD", + argLen: 2, + commutative: true, + asm: riscv.AFADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FSUBD", + argLen: 2, + asm: riscv.AFSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMULD", + argLen: 2, + commutative: true, + asm: riscv.AFMULD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FDIVD", + argLen: 2, + asm: riscv.AFDIVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMADDD", + argLen: 3, + commutative: true, + asm: riscv.AFMADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMSUBD", + argLen: 3, + commutative: true, + asm: riscv.AFMSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNMADDD", + argLen: 3, + commutative: true, + asm: riscv.AFNMADDD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNMSUBD", + argLen: 3, + commutative: true, + asm: riscv.AFNMSUBD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + {2, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FSQRTD", + argLen: 1, + asm: riscv.AFSQRTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FNEGD", + argLen: 1, + asm: riscv.AFNEGD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FABSD", + argLen: 1, + asm: riscv.AFABSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FSGNJD", + argLen: 2, + asm: riscv.AFSGNJD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMVDX", + argLen: 1, + asm: riscv.AFMVDX, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMVXD", + argLen: 1, + asm: riscv.AFMVXD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FCVTDW", + argLen: 1, + asm: riscv.AFCVTDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCVTDL", + argLen: 1, + asm: riscv.AFCVTDL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCVTWD", + argLen: 1, + asm: riscv.AFCVTWD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FCVTLD", + argLen: 1, + asm: riscv.AFCVTLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FCVTDS", + argLen: 1, + asm: riscv.AFCVTDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCVTSD", + argLen: 1, + asm: riscv.AFCVTSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: riscv.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FMOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: riscv.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372037861408754}, // SP X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 SB + {1, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FEQD", + argLen: 2, + commutative: true, + asm: riscv.AFEQD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FNED", + argLen: 2, + commutative: true, + asm: riscv.AFNED, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FLTD", + argLen: 2, + asm: riscv.AFLTD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FLED", + argLen: 2, + asm: riscv.AFLED, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "LoweredFMIND", + argLen: 2, + commutative: true, + resultNotInArgs: true, + asm: riscv.AFMIND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "LoweredFMAXD", + argLen: 2, + commutative: true, + resultNotInArgs: true, + asm: riscv.AFMAXD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + {1, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 9223372034707292160}, // 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 + }, + }, + }, + { + name: "FCLASSS", + argLen: 1, + asm: riscv.AFCLASSS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + { + name: "FCLASSD", + argLen: 1, + asm: riscv.AFCLASSD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 9223372034707292160}, // 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 + }, + outputs: []outputInfo{ + {0, 1006632944}, // X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X28 X29 X30 + }, + }, + }, + + { + name: "FADDS", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: s390x.AFADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FADD", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: s390x.AFADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FSUBS", + argLen: 2, + resultInArg0: true, + asm: s390x.AFSUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FSUB", + argLen: 2, + resultInArg0: true, + asm: s390x.AFSUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMULS", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: s390x.AFMULS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMUL", + argLen: 2, + commutative: true, + resultInArg0: true, + asm: s390x.AFMUL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FDIVS", + argLen: 2, + resultInArg0: true, + asm: s390x.AFDIVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FDIV", + argLen: 2, + resultInArg0: true, + asm: s390x.AFDIV, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FNEGS", + argLen: 1, + clobberFlags: true, + asm: s390x.AFNEGS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FNEG", + argLen: 1, + clobberFlags: true, + asm: s390x.AFNEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMADDS", + argLen: 3, + resultInArg0: true, + asm: s390x.AFMADDS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMADD", + argLen: 3, + resultInArg0: true, + asm: s390x.AFMADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMSUBS", + argLen: 3, + resultInArg0: true, + asm: s390x.AFMSUBS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMSUB", + argLen: 3, + resultInArg0: true, + asm: s390x.AFMSUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "LPDFR", + argLen: 1, + asm: s390x.ALPDFR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "LNDFR", + argLen: 1, + asm: s390x.ALNDFR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CPSDR", + argLen: 2, + asm: s390x.ACPSDR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "WFMAXDB", + argLen: 2, + asm: s390x.AWFMAXDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "WFMAXSB", + argLen: 2, + asm: s390x.AWFMAXSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "WFMINDB", + argLen: 2, + asm: s390x.AWFMINDB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "WFMINSB", + argLen: 2, + asm: s390x.AWFMINSB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FIDBR", + auxType: auxInt8, + argLen: 1, + asm: s390x.AFIDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMOVSload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMOVSconst", + auxType: auxFloat32, + argLen: 0, + rematerializeable: true, + asm: s390x.AFMOVS, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMOVDconst", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + asm: s390x.AFMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMOVSloadidx", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: s390x.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMOVDloadidx", + auxType: auxSymOff, + argLen: 3, + symEffect: SymRead, + asm: s390x.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMOVSstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMOVSstoreidx", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: s390x.AFMOVS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FMOVDstoreidx", + auxType: auxSymOff, + argLen: 4, + symEffect: SymWrite, + asm: s390x.AFMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "ADD", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: s390x.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ADDW", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: s390x.AADDW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ADDconst", + auxType: auxInt32, + argLen: 1, + clobberFlags: true, + asm: s390x.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ADDWconst", + auxType: auxInt32, + argLen: 1, + clobberFlags: true, + asm: s390x.AADDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ADDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.AADD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ADDWload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.AADDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SUB", + argLen: 2, + clobberFlags: true, + asm: s390x.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SUBW", + argLen: 2, + clobberFlags: true, + asm: s390x.ASUBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SUBconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: s390x.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SUBWconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: s390x.ASUBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SUBload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.ASUB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SUBWload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.ASUBW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MULLD", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MULLW", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MULLDconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MULLWconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MULLDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.AMULLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MULLWload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.AMULLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MULHD", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AMULHD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2048, // R11 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MULHDU", + argLen: 2, + commutative: true, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AMULHDU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2048, // R11 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "DIVD", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: s390x.ADIVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2048, // R11 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "DIVW", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: s390x.ADIVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2048, // R11 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "DIVDU", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: s390x.ADIVDU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2048, // R11 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "DIVWU", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: s390x.ADIVWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2048, // R11 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MODD", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AMODD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2048, // R11 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MODW", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AMODW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2048, // R11 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MODDU", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AMODDU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2048, // R11 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "MODWU", + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AMODWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + {1, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + clobbers: 2048, // R11 + outputs: []outputInfo{ + {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14 + }, + }, + }, + { + name: "AND", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: s390x.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ANDW", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: s390x.AANDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ANDconst", + auxType: auxInt64, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ANDWconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AANDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ANDload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.AAND, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ANDWload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.AANDW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "OR", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: s390x.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ORW", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: s390x.AORW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ORconst", + auxType: auxInt64, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ORWconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AORW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ORload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.AOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ORWload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.AORW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "XOR", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: s390x.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "XORW", + argLen: 2, + commutative: true, + clobberFlags: true, + asm: s390x.AXORW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "XORconst", + auxType: auxInt64, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "XORWconst", + auxType: auxInt32, + argLen: 1, + resultInArg0: true, + clobberFlags: true, + asm: s390x.AXORW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "XORload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.AXOR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "XORWload", + auxType: auxSymOff, + argLen: 3, + resultInArg0: true, + clobberFlags: true, + faultOnNilArg1: true, + symEffect: SymRead, + asm: s390x.AXORW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ADDC", + argLen: 2, + commutative: true, + asm: s390x.AADDC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ADDCconst", + auxType: auxInt16, + argLen: 1, + asm: s390x.AADDC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "ADDE", + argLen: 3, + commutative: true, + resultInArg0: true, + asm: s390x.AADDE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SUBC", + argLen: 2, + asm: s390x.ASUBC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SUBE", + argLen: 3, + resultInArg0: true, + asm: s390x.ASUBE, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CMP", + argLen: 2, + asm: s390x.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "CMPW", + argLen: 2, + asm: s390x.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "CMPU", + argLen: 2, + asm: s390x.ACMPU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "CMPWU", + argLen: 2, + asm: s390x.ACMPWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "CMPconst", + auxType: auxInt32, + argLen: 1, + asm: s390x.ACMP, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "CMPWconst", + auxType: auxInt32, + argLen: 1, + asm: s390x.ACMPW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "CMPUconst", + auxType: auxInt32, + argLen: 1, + asm: s390x.ACMPU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "CMPWUconst", + auxType: auxInt32, + argLen: 1, + asm: s390x.ACMPWU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "FCMPS", + argLen: 2, + asm: s390x.ACEBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FCMP", + argLen: 2, + asm: s390x.AFCMPU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "LTDBR", + argLen: 1, + asm: s390x.ALTDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "LTEBR", + argLen: 1, + asm: s390x.ALTEBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "SLD", + argLen: 2, + asm: s390x.ASLD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 23550}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SLW", + argLen: 2, + asm: s390x.ASLW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 23550}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SLDconst", + auxType: auxUInt8, + argLen: 1, + asm: s390x.ASLD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SLWconst", + auxType: auxUInt8, + argLen: 1, + asm: s390x.ASLW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SRD", + argLen: 2, + asm: s390x.ASRD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 23550}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SRW", + argLen: 2, + asm: s390x.ASRW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 23550}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SRDconst", + auxType: auxUInt8, + argLen: 1, + asm: s390x.ASRD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SRWconst", + auxType: auxUInt8, + argLen: 1, + asm: s390x.ASRW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SRAD", + argLen: 2, + clobberFlags: true, + asm: s390x.ASRAD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 23550}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SRAW", + argLen: 2, + clobberFlags: true, + asm: s390x.ASRAW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 23550}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SRADconst", + auxType: auxUInt8, + argLen: 1, + clobberFlags: true, + asm: s390x.ASRAD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "SRAWconst", + auxType: auxUInt8, + argLen: 1, + clobberFlags: true, + asm: s390x.ASRAW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "RLLG", + argLen: 2, + asm: s390x.ARLLG, + reg: regInfo{ + inputs: []inputInfo{ + {1, 23550}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "RLL", + argLen: 2, + asm: s390x.ARLL, + reg: regInfo{ + inputs: []inputInfo{ + {1, 23550}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "RLLconst", + auxType: auxUInt8, + argLen: 1, + asm: s390x.ARLL, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "RXSBG", + auxType: auxS390XRotateParams, + argLen: 2, + resultInArg0: true, + clobberFlags: true, + asm: s390x.ARXSBG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "RISBGZ", + auxType: auxS390XRotateParams, + argLen: 1, + clobberFlags: true, + asm: s390x.ARISBGZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "NEG", + argLen: 1, + clobberFlags: true, + asm: s390x.ANEG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "NEGW", + argLen: 1, + clobberFlags: true, + asm: s390x.ANEGW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "NOT", + argLen: 1, + resultInArg0: true, + clobberFlags: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "NOTW", + argLen: 1, + resultInArg0: true, + clobberFlags: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "FSQRT", + argLen: 1, + asm: s390x.AFSQRT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "FSQRTS", + argLen: 1, + asm: s390x.AFSQRTS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "LOCGR", + auxType: auxS390XCCMask, + argLen: 3, + resultInArg0: true, + asm: s390x.ALOCGR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + {1, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVBreg", + argLen: 1, + asm: s390x.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVBZreg", + argLen: 1, + asm: s390x.AMOVBZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVHreg", + argLen: 1, + asm: s390x.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVHZreg", + argLen: 1, + asm: s390x.AMOVHZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVWreg", + argLen: 1, + asm: s390x.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVWZreg", + argLen: 1, + asm: s390x.AMOVWZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVDconst", + auxType: auxInt64, + argLen: 0, + rematerializeable: true, + asm: s390x.AMOVD, + reg: regInfo{ + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "LDGR", + argLen: 1, + asm: s390x.ALDGR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "LGDR", + argLen: 1, + asm: s390x.ALGDR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CFDBRA", + argLen: 1, + clobberFlags: true, + asm: s390x.ACFDBRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CGDBRA", + argLen: 1, + clobberFlags: true, + asm: s390x.ACGDBRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CFEBRA", + argLen: 1, + clobberFlags: true, + asm: s390x.ACFEBRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CGEBRA", + argLen: 1, + clobberFlags: true, + asm: s390x.ACGEBRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CEFBRA", + argLen: 1, + clobberFlags: true, + asm: s390x.ACEFBRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CDFBRA", + argLen: 1, + clobberFlags: true, + asm: s390x.ACDFBRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CEGBRA", + argLen: 1, + clobberFlags: true, + asm: s390x.ACEGBRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CDGBRA", + argLen: 1, + clobberFlags: true, + asm: s390x.ACDGBRA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CLFEBR", + argLen: 1, + clobberFlags: true, + asm: s390x.ACLFEBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CLFDBR", + argLen: 1, + clobberFlags: true, + asm: s390x.ACLFDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CLGEBR", + argLen: 1, + clobberFlags: true, + asm: s390x.ACLGEBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CLGDBR", + argLen: 1, + clobberFlags: true, + asm: s390x.ACLGDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CELFBR", + argLen: 1, + clobberFlags: true, + asm: s390x.ACELFBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CDLFBR", + argLen: 1, + clobberFlags: true, + asm: s390x.ACDLFBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CELGBR", + argLen: 1, + clobberFlags: true, + asm: s390x.ACELGBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "CDLGBR", + argLen: 1, + clobberFlags: true, + asm: s390x.ACDLGBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "LEDBR", + argLen: 1, + asm: s390x.ALEDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "LDEBR", + argLen: 1, + asm: s390x.ALDEBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "MOVDaddr", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295000064}, // SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVDaddridx", + auxType: auxSymOff, + argLen: 2, + symEffect: SymAddr, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295000064}, // SP SB + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVBZload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVBZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVBload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVHZload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVHZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVHload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVWZload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVWZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVWload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVDload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVWBR", + argLen: 1, + asm: s390x.AMOVWBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVDBR", + argLen: 1, + asm: s390x.AMOVDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVHBRload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVHBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVWBRload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVWBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVDBRload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVBstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVHstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVWstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVDstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVHBRstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVHBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVWBRstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVWBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVDBRstore", + auxType: auxSymOff, + argLen: 3, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MVC", + auxType: auxSymValAndOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + faultOnNilArg1: true, + symEffect: SymNone, + asm: s390x.AMVC, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVBZloadidx", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: s390x.AMOVBZ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVBloadidx", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: s390x.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVHZloadidx", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: s390x.AMOVHZ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVHloadidx", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: s390x.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVWZloadidx", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: s390x.AMOVWZ, + reg: regInfo{ + inputs: []inputInfo{ + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVWloadidx", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: s390x.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVDloadidx", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: s390x.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVHBRloadidx", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: s390x.AMOVHBR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVWBRloadidx", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: s390x.AMOVWBR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVDBRloadidx", + auxType: auxSymOff, + argLen: 3, + commutative: true, + symEffect: SymRead, + asm: s390x.AMOVDBR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVBstoreidx", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: s390x.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVHstoreidx", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: s390x.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVWstoreidx", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: s390x.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVDstoreidx", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: s390x.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVHBRstoreidx", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: s390x.AMOVHBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVWBRstoreidx", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: s390x.AMOVWBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVDBRstoreidx", + auxType: auxSymOff, + argLen: 4, + commutative: true, + symEffect: SymWrite, + asm: s390x.AMOVDBR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVBstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + }, + }, + { + name: "MOVHstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVH, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + }, + }, + { + name: "MOVWstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + }, + }, + { + name: "MOVDstoreconst", + auxType: auxSymValAndOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + }, + }, + { + name: "CLEAR", + auxType: auxSymValAndOff, + argLen: 2, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.ACLEAR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23550}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "CALLstatic", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + clobbers: 4294933503, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 g R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + { + name: "CALLtail", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 4294933503, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 g R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + { + name: "CALLclosure", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {1, 4096}, // R12 + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + clobbers: 4294933503, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 g R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + { + name: "CALLinter", + auxType: auxCallOff, + argLen: -1, + clobberFlags: true, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23550}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + clobbers: 4294933503, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 g R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + { + name: "InvertFlags", + argLen: 1, + reg: regInfo{}, + }, + { + name: "LoweredGetG", + argLen: 1, + reg: regInfo{ + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + zeroWidth: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4096}, // R12 + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + clobberFlags: true, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "LoweredRound32F", + argLen: 1, + resultInArg0: true, + zeroWidth: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "LoweredRound64F", + argLen: 1, + resultInArg0: true, + zeroWidth: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + clobberFlags: true, + reg: regInfo{ + clobbers: 4294918146, // R1 R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + outputs: []outputInfo{ + {0, 512}, // R9 + }, + }, + }, + { + name: "LoweredPanicBoundsRR", + auxType: auxInt64, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 7167}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 + {1, 7167}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 + }, + }, + }, + { + name: "LoweredPanicBoundsRC", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 7167}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 + }, + }, + }, + { + name: "LoweredPanicBoundsCR", + auxType: auxPanicBoundsC, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 7167}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 + }, + }, + }, + { + name: "LoweredPanicBoundsCC", + auxType: auxPanicBoundsCC, + argLen: 1, + call: true, + reg: regInfo{}, + }, + { + name: "FlagEQ", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagLT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagGT", + argLen: 0, + reg: regInfo{}, + }, + { + name: "FlagOV", + argLen: 0, + reg: regInfo{}, + }, + { + name: "SYNC", + argLen: 1, + asm: s390x.ASYNC, + reg: regInfo{}, + }, + { + name: "MOVBZatomicload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVBZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVWZatomicload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVWZ, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVDatomicload", + auxType: auxSymOff, + argLen: 2, + faultOnNilArg0: true, + symEffect: SymRead, + asm: s390x.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MOVBatomicstore", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymWrite, + asm: s390x.AMOVB, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVWatomicstore", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymWrite, + asm: s390x.AMOVW, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "MOVDatomicstore", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymWrite, + asm: s390x.AMOVD, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "LAA", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: s390x.ALAA, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "LAAG", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: s390x.ALAAG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "AddTupleFirst32", + argLen: 2, + reg: regInfo{}, + }, + { + name: "AddTupleFirst64", + argLen: 2, + reg: regInfo{}, + }, + { + name: "LAN", + argLen: 3, + clobberFlags: true, + hasSideEffects: true, + asm: s390x.ALAN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "LANfloor", + argLen: 3, + clobberFlags: true, + hasSideEffects: true, + asm: s390x.ALAN, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2}, // R1 + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + clobbers: 2, // R1 + }, + }, + { + name: "LAO", + argLen: 3, + clobberFlags: true, + hasSideEffects: true, + asm: s390x.ALAO, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4295023614}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP SB + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "LAOfloor", + argLen: 3, + clobberFlags: true, + hasSideEffects: true, + asm: s390x.ALAO, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2}, // R1 + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + clobbers: 2, // R1 + }, + }, + { + name: "LoweredAtomicCas32", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: s390x.ACS, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1}, // R0 + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + clobbers: 1, // R0 + outputs: []outputInfo{ + {1, 0}, + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "LoweredAtomicCas64", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: s390x.ACSG, + reg: regInfo{ + inputs: []inputInfo{ + {1, 1}, // R0 + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {2, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + clobbers: 1, // R0 + outputs: []outputInfo{ + {1, 0}, + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "LoweredAtomicExchange32", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: s390x.ACS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {1, 0}, + {0, 1}, // R0 + }, + }, + }, + { + name: "LoweredAtomicExchange64", + auxType: auxSymOff, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + hasSideEffects: true, + symEffect: SymRdWr, + asm: s390x.ACSG, + reg: regInfo{ + inputs: []inputInfo{ + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + {1, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + outputs: []outputInfo{ + {1, 0}, + {0, 1}, // R0 + }, + }, + }, + { + name: "FLOGR", + argLen: 1, + clobberFlags: true, + asm: s390x.AFLOGR, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + clobbers: 2, // R1 + outputs: []outputInfo{ + {0, 1}, // R0 + }, + }, + }, + { + name: "POPCNT", + argLen: 1, + clobberFlags: true, + asm: s390x.APOPCNT, + reg: regInfo{ + inputs: []inputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + }, + }, + { + name: "MLGR", + argLen: 2, + asm: s390x.AMLGR, + reg: regInfo{ + inputs: []inputInfo{ + {1, 8}, // R3 + {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 + }, + outputs: []outputInfo{ + {0, 4}, // R2 + {1, 8}, // R3 + }, + }, + }, + { + name: "SumBytes2", + argLen: 1, + reg: regInfo{}, + }, + { + name: "SumBytes4", + argLen: 1, + reg: regInfo{}, + }, + { + name: "SumBytes8", + argLen: 1, + reg: regInfo{}, + }, + { + name: "STMG2", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.ASTMG, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // R1 + {2, 4}, // R2 + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "STMG3", + auxType: auxSymOff, + argLen: 5, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.ASTMG, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // R1 + {2, 4}, // R2 + {3, 8}, // R3 + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "STMG4", + auxType: auxSymOff, + argLen: 6, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.ASTMG, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // R1 + {2, 4}, // R2 + {3, 8}, // R3 + {4, 16}, // R4 + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "STM2", + auxType: auxSymOff, + argLen: 4, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.ASTMY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // R1 + {2, 4}, // R2 + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "STM3", + auxType: auxSymOff, + argLen: 5, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.ASTMY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // R1 + {2, 4}, // R2 + {3, 8}, // R3 + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "STM4", + auxType: auxSymOff, + argLen: 6, + clobberFlags: true, + faultOnNilArg0: true, + symEffect: SymWrite, + asm: s390x.ASTMY, + reg: regInfo{ + inputs: []inputInfo{ + {1, 2}, // R1 + {2, 4}, // R2 + {3, 8}, // R3 + {4, 16}, // R4 + {0, 56318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + }, + }, + { + name: "LoweredMove", + auxType: auxInt64, + argLen: 4, + clobberFlags: true, + faultOnNilArg0: true, + faultOnNilArg1: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2}, // R1 + {1, 4}, // R2 + {2, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + clobbers: 6, // R1 R2 + }, + }, + { + name: "LoweredZero", + auxType: auxInt64, + argLen: 3, + clobberFlags: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 2}, // R1 + {1, 56319}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14 SP + }, + clobbers: 2, // R1 + }, + }, + + { + name: "LoweredStaticCall", + auxType: auxCallOff, + argLen: 1, + call: true, + reg: regInfo{ + clobbers: 844424930131967, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 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 g + }, + }, + { + name: "LoweredTailCall", + auxType: auxCallOff, + argLen: 1, + call: true, + tailCall: true, + reg: regInfo{ + clobbers: 844424930131967, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 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 g + }, + }, + { + name: "LoweredClosureCall", + auxType: auxCallOff, + argLen: 3, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + {1, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + clobbers: 844424930131967, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 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 g + }, + }, + { + name: "LoweredInterCall", + auxType: auxCallOff, + argLen: 2, + call: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + clobbers: 844424930131967, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 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 g + }, + }, + { + name: "LoweredAddr", + auxType: auxSymOff, + argLen: 1, + rematerializeable: true, + symEffect: SymAddr, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredMove", + auxType: auxInt64, + argLen: 3, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + {1, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredZero", + auxType: auxInt64, + argLen: 2, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredGetClosurePtr", + argLen: 0, + reg: regInfo{ + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredGetCallerPC", + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredGetCallerSP", + argLen: 1, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredNilCheck", + argLen: 2, + nilCheck: true, + faultOnNilArg0: true, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredWB", + auxType: auxInt64, + argLen: 1, + reg: regInfo{ + clobbers: 844424930131967, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 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 g + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "LoweredConvert", + argLen: 2, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "Select", + argLen: 3, + asm: wasm.ASelect, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {2, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Load8U", + auxType: auxInt64, + argLen: 2, + asm: wasm.AI64Load8U, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Load8S", + auxType: auxInt64, + argLen: 2, + asm: wasm.AI64Load8S, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Load16U", + auxType: auxInt64, + argLen: 2, + asm: wasm.AI64Load16U, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Load16S", + auxType: auxInt64, + argLen: 2, + asm: wasm.AI64Load16S, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Load32U", + auxType: auxInt64, + argLen: 2, + asm: wasm.AI64Load32U, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Load32S", + auxType: auxInt64, + argLen: 2, + asm: wasm.AI64Load32S, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Load", + auxType: auxInt64, + argLen: 2, + asm: wasm.AI64Load, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Store8", + auxType: auxInt64, + argLen: 3, + asm: wasm.AI64Store8, + reg: regInfo{ + inputs: []inputInfo{ + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + }, + }, + { + name: "I64Store16", + auxType: auxInt64, + argLen: 3, + asm: wasm.AI64Store16, + reg: regInfo{ + inputs: []inputInfo{ + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + }, + }, + { + name: "I64Store32", + auxType: auxInt64, + argLen: 3, + asm: wasm.AI64Store32, + reg: regInfo{ + inputs: []inputInfo{ + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + }, + }, + { + name: "I64Store", + auxType: auxInt64, + argLen: 3, + asm: wasm.AI64Store, + reg: regInfo{ + inputs: []inputInfo{ + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + }, + }, + { + name: "F32Load", + auxType: auxInt64, + argLen: 2, + asm: wasm.AF32Load, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F64Load", + auxType: auxInt64, + argLen: 2, + asm: wasm.AF64Load, + reg: regInfo{ + inputs: []inputInfo{ + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F32Store", + auxType: auxInt64, + argLen: 3, + asm: wasm.AF32Store, + reg: regInfo{ + inputs: []inputInfo{ + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + }, + }, + { + name: "F64Store", + auxType: auxInt64, + argLen: 3, + asm: wasm.AF64Store, + reg: regInfo{ + inputs: []inputInfo{ + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {0, 1407374883618815}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP SB + }, + }, + }, + { + name: "I64Const", + auxType: auxInt64, + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F32Const", + auxType: auxFloat32, + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F64Const", + auxType: auxFloat64, + argLen: 0, + rematerializeable: true, + reg: regInfo{ + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "I64Eqz", + argLen: 1, + asm: wasm.AI64Eqz, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Eq", + argLen: 2, + asm: wasm.AI64Eq, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Ne", + argLen: 2, + asm: wasm.AI64Ne, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64LtS", + argLen: 2, + asm: wasm.AI64LtS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64LtU", + argLen: 2, + asm: wasm.AI64LtU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64GtS", + argLen: 2, + asm: wasm.AI64GtS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64GtU", + argLen: 2, + asm: wasm.AI64GtU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64LeS", + argLen: 2, + asm: wasm.AI64LeS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64LeU", + argLen: 2, + asm: wasm.AI64LeU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64GeS", + argLen: 2, + asm: wasm.AI64GeS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64GeU", + argLen: 2, + asm: wasm.AI64GeU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F32Eq", + argLen: 2, + asm: wasm.AF32Eq, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F32Ne", + argLen: 2, + asm: wasm.AF32Ne, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F32Lt", + argLen: 2, + asm: wasm.AF32Lt, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F32Gt", + argLen: 2, + asm: wasm.AF32Gt, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F32Le", + argLen: 2, + asm: wasm.AF32Le, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F32Ge", + argLen: 2, + asm: wasm.AF32Ge, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F64Eq", + argLen: 2, + asm: wasm.AF64Eq, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F64Ne", + argLen: 2, + asm: wasm.AF64Ne, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F64Lt", + argLen: 2, + asm: wasm.AF64Lt, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F64Gt", + argLen: 2, + asm: wasm.AF64Gt, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F64Le", + argLen: 2, + asm: wasm.AF64Le, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F64Ge", + argLen: 2, + asm: wasm.AF64Ge, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Add", + argLen: 2, + asm: wasm.AI64Add, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64AddConst", + auxType: auxInt64, + argLen: 1, + asm: wasm.AI64Add, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Sub", + argLen: 2, + asm: wasm.AI64Sub, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Mul", + argLen: 2, + asm: wasm.AI64Mul, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64DivS", + argLen: 2, + asm: wasm.AI64DivS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64DivU", + argLen: 2, + asm: wasm.AI64DivU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64RemS", + argLen: 2, + asm: wasm.AI64RemS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64RemU", + argLen: 2, + asm: wasm.AI64RemU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64And", + argLen: 2, + asm: wasm.AI64And, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Or", + argLen: 2, + asm: wasm.AI64Or, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Xor", + argLen: 2, + asm: wasm.AI64Xor, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Shl", + argLen: 2, + asm: wasm.AI64Shl, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64ShrS", + argLen: 2, + asm: wasm.AI64ShrS, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64ShrU", + argLen: 2, + asm: wasm.AI64ShrU, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F32Neg", + argLen: 1, + asm: wasm.AF32Neg, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32Add", + argLen: 2, + asm: wasm.AF32Add, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32Sub", + argLen: 2, + asm: wasm.AF32Sub, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32Mul", + argLen: 2, + asm: wasm.AF32Mul, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32Div", + argLen: 2, + asm: wasm.AF32Div, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F64Neg", + argLen: 1, + asm: wasm.AF64Neg, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64Add", + argLen: 2, + asm: wasm.AF64Add, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64Sub", + argLen: 2, + asm: wasm.AF64Sub, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64Mul", + argLen: 2, + asm: wasm.AF64Mul, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64Div", + argLen: 2, + asm: wasm.AF64Div, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "I64TruncSatF64S", + argLen: 1, + asm: wasm.AI64TruncSatF64S, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64TruncSatF64U", + argLen: 1, + asm: wasm.AI64TruncSatF64U, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64TruncSatF32S", + argLen: 1, + asm: wasm.AI64TruncSatF32S, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64TruncSatF32U", + argLen: 1, + asm: wasm.AI64TruncSatF32U, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F32ConvertI64S", + argLen: 1, + asm: wasm.AF32ConvertI64S, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32ConvertI64U", + argLen: 1, + asm: wasm.AF32ConvertI64U, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F64ConvertI64S", + argLen: 1, + asm: wasm.AF64ConvertI64S, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64ConvertI64U", + argLen: 1, + asm: wasm.AF64ConvertI64U, + reg: regInfo{ + inputs: []inputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F32DemoteF64", + argLen: 1, + asm: wasm.AF32DemoteF64, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F64PromoteF32", + argLen: 1, + asm: wasm.AF64PromoteF32, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "I64Extend8S", + argLen: 1, + asm: wasm.AI64Extend8S, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Extend16S", + argLen: 1, + asm: wasm.AI64Extend16S, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Extend32S", + argLen: 1, + asm: wasm.AI64Extend32S, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "F32Sqrt", + argLen: 1, + asm: wasm.AF32Sqrt, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32Trunc", + argLen: 1, + asm: wasm.AF32Trunc, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32Ceil", + argLen: 1, + asm: wasm.AF32Ceil, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32Floor", + argLen: 1, + asm: wasm.AF32Floor, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32Nearest", + argLen: 1, + asm: wasm.AF32Nearest, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32Abs", + argLen: 1, + asm: wasm.AF32Abs, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F32Copysign", + argLen: 2, + asm: wasm.AF32Copysign, + reg: regInfo{ + inputs: []inputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + {1, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + outputs: []outputInfo{ + {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 + }, + }, + }, + { + name: "F64Sqrt", + argLen: 1, + asm: wasm.AF64Sqrt, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64Trunc", + argLen: 1, + asm: wasm.AF64Trunc, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64Ceil", + argLen: 1, + asm: wasm.AF64Ceil, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64Floor", + argLen: 1, + asm: wasm.AF64Floor, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64Nearest", + argLen: 1, + asm: wasm.AF64Nearest, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64Abs", + argLen: 1, + asm: wasm.AF64Abs, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "F64Copysign", + argLen: 2, + asm: wasm.AF64Copysign, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + {1, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + outputs: []outputInfo{ + {0, 281470681743360}, // F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 + }, + }, + }, + { + name: "I64Ctz", + argLen: 1, + asm: wasm.AI64Ctz, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Clz", + argLen: 1, + asm: wasm.AI64Clz, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I32Rotl", + argLen: 2, + asm: wasm.AI32Rotl, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Rotl", + argLen: 2, + asm: wasm.AI64Rotl, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + {1, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + { + name: "I64Popcnt", + argLen: 1, + asm: wasm.AI64Popcnt, + reg: regInfo{ + inputs: []inputInfo{ + {0, 281474976776191}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 SP + }, + outputs: []outputInfo{ + {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 + }, + }, + }, + + { + name: "Last", + argLen: -1, + generic: true, + }, + { + name: "Add8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Add16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Add32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Add64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddPtr", + argLen: 2, + generic: true, + }, + { + name: "Add32F", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Add64F", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Sub8", + argLen: 2, + generic: true, + }, + { + name: "Sub16", + argLen: 2, + generic: true, + }, + { + name: "Sub32", + argLen: 2, + generic: true, + }, + { + name: "Sub64", + argLen: 2, + generic: true, + }, + { + name: "SubPtr", + argLen: 2, + generic: true, + }, + { + name: "Sub32F", + argLen: 2, + generic: true, + }, + { + name: "Sub64F", + argLen: 2, + generic: true, + }, + { + name: "Mul8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Mul16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Mul32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Mul64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Mul32F", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Mul64F", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Div32F", + argLen: 2, + generic: true, + }, + { + name: "Div64F", + argLen: 2, + generic: true, + }, + { + name: "Hmul32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Hmul32u", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Hmul64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Hmul64u", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Mul32uhilo", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Mul64uhilo", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Mul32uover", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Mul64uover", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Avg32u", + argLen: 2, + generic: true, + }, + { + name: "Avg64u", + argLen: 2, + generic: true, + }, + { + name: "Div8", + argLen: 2, + generic: true, + }, + { + name: "Div8u", + argLen: 2, + generic: true, + }, + { + name: "Div16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Div16u", + argLen: 2, + generic: true, + }, + { + name: "Div32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Div32u", + argLen: 2, + generic: true, + }, + { + name: "Div64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Div64u", + argLen: 2, + generic: true, + }, + { + name: "Div128u", + argLen: 3, + generic: true, + }, + { + name: "Mod8", + argLen: 2, + generic: true, + }, + { + name: "Mod8u", + argLen: 2, + generic: true, + }, + { + name: "Mod16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Mod16u", + argLen: 2, + generic: true, + }, + { + name: "Mod32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Mod32u", + argLen: 2, + generic: true, + }, + { + name: "Mod64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Mod64u", + argLen: 2, + generic: true, + }, + { + name: "And8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "And16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "And32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "And64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Or8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Or16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Or32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Or64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Xor8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Xor16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Xor32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Xor64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Lsh8x8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh8x16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh8x32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh8x64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh16x8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh16x16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh16x32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh16x64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh32x8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh32x16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh32x32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh32x64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh64x8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh64x16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh64x32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Lsh64x64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh8x8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh8x16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh8x32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh8x64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh16x8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh16x16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh16x32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh16x64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh32x8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh32x16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh32x32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh32x64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh64x8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh64x16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh64x32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh64x64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh8Ux8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh8Ux16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh8Ux32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh8Ux64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh16Ux8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh16Ux16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh16Ux32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh16Ux64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh32Ux8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh32Ux16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh32Ux32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh32Ux64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh64Ux8", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh64Ux16", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh64Ux32", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Rsh64Ux64", + auxType: auxBool, + argLen: 2, + generic: true, + }, + { + name: "Eq8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Eq16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Eq32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Eq64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqPtr", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqInter", + argLen: 2, + generic: true, + }, + { + name: "EqSlice", + argLen: 2, + generic: true, + }, + { + name: "Eq32F", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Eq64F", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Neq8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Neq16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Neq32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Neq64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NeqPtr", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NeqInter", + argLen: 2, + generic: true, + }, + { + name: "NeqSlice", + argLen: 2, + generic: true, + }, + { + name: "Neq32F", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Neq64F", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Less8", + argLen: 2, + generic: true, + }, + { + name: "Less8U", + argLen: 2, + generic: true, + }, + { + name: "Less16", + argLen: 2, + generic: true, + }, + { + name: "Less16U", + argLen: 2, + generic: true, + }, + { + name: "Less32", + argLen: 2, + generic: true, + }, + { + name: "Less32U", + argLen: 2, + generic: true, + }, + { + name: "Less64", + argLen: 2, + generic: true, + }, + { + name: "Less64U", + argLen: 2, + generic: true, + }, + { + name: "Less32F", + argLen: 2, + generic: true, + }, + { + name: "Less64F", + argLen: 2, + generic: true, + }, + { + name: "Leq8", + argLen: 2, + generic: true, + }, + { + name: "Leq8U", + argLen: 2, + generic: true, + }, + { + name: "Leq16", + argLen: 2, + generic: true, + }, + { + name: "Leq16U", + argLen: 2, + generic: true, + }, + { + name: "Leq32", + argLen: 2, + generic: true, + }, + { + name: "Leq32U", + argLen: 2, + generic: true, + }, + { + name: "Leq64", + argLen: 2, + generic: true, + }, + { + name: "Leq64U", + argLen: 2, + generic: true, + }, + { + name: "Leq32F", + argLen: 2, + generic: true, + }, + { + name: "Leq64F", + argLen: 2, + generic: true, + }, + { + name: "CondSelect", + argLen: 3, + generic: true, + }, + { + name: "AndB", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrB", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqB", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NeqB", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Not", + argLen: 1, + generic: true, + }, + { + name: "Neg8", + argLen: 1, + generic: true, + }, + { + name: "Neg16", + argLen: 1, + generic: true, + }, + { + name: "Neg32", + argLen: 1, + generic: true, + }, + { + name: "Neg64", + argLen: 1, + generic: true, + }, + { + name: "Neg32F", + argLen: 1, + generic: true, + }, + { + name: "Neg64F", + argLen: 1, + generic: true, + }, + { + name: "Com8", + argLen: 1, + generic: true, + }, + { + name: "Com16", + argLen: 1, + generic: true, + }, + { + name: "Com32", + argLen: 1, + generic: true, + }, + { + name: "Com64", + argLen: 1, + generic: true, + }, + { + name: "Ctz8", + argLen: 1, + generic: true, + }, + { + name: "Ctz16", + argLen: 1, + generic: true, + }, + { + name: "Ctz32", + argLen: 1, + generic: true, + }, + { + name: "Ctz64", + argLen: 1, + generic: true, + }, + { + name: "Ctz64On32", + argLen: 2, + generic: true, + }, + { + name: "Ctz8NonZero", + argLen: 1, + generic: true, + }, + { + name: "Ctz16NonZero", + argLen: 1, + generic: true, + }, + { + name: "Ctz32NonZero", + argLen: 1, + generic: true, + }, + { + name: "Ctz64NonZero", + argLen: 1, + generic: true, + }, + { + name: "BitLen8", + argLen: 1, + generic: true, + }, + { + name: "BitLen16", + argLen: 1, + generic: true, + }, + { + name: "BitLen32", + argLen: 1, + generic: true, + }, + { + name: "BitLen64", + argLen: 1, + generic: true, + }, + { + name: "Bswap16", + argLen: 1, + generic: true, + }, + { + name: "Bswap32", + argLen: 1, + generic: true, + }, + { + name: "Bswap64", + argLen: 1, + generic: true, + }, + { + name: "BitRev8", + argLen: 1, + generic: true, + }, + { + name: "BitRev16", + argLen: 1, + generic: true, + }, + { + name: "BitRev32", + argLen: 1, + generic: true, + }, + { + name: "BitRev64", + argLen: 1, + generic: true, + }, + { + name: "PopCount8", + argLen: 1, + generic: true, + }, + { + name: "PopCount16", + argLen: 1, + generic: true, + }, + { + name: "PopCount32", + argLen: 1, + generic: true, + }, + { + name: "PopCount64", + argLen: 1, + generic: true, + }, + { + name: "RotateLeft64", + argLen: 2, + generic: true, + }, + { + name: "RotateLeft32", + argLen: 2, + generic: true, + }, + { + name: "RotateLeft16", + argLen: 2, + generic: true, + }, + { + name: "RotateLeft8", + argLen: 2, + generic: true, + }, + { + name: "Sqrt", + argLen: 1, + generic: true, + }, + { + name: "Sqrt32", + argLen: 1, + generic: true, + }, + { + name: "Floor", + argLen: 1, + generic: true, + }, + { + name: "Ceil", + argLen: 1, + generic: true, + }, + { + name: "Trunc", + argLen: 1, + generic: true, + }, + { + name: "Round", + argLen: 1, + generic: true, + }, + { + name: "RoundToEven", + argLen: 1, + generic: true, + }, + { + name: "Abs", + argLen: 1, + generic: true, + }, + { + name: "Copysign", + argLen: 2, + generic: true, + }, + { + name: "Min64", + argLen: 2, + generic: true, + }, + { + name: "Max64", + argLen: 2, + generic: true, + }, + { + name: "Min64u", + argLen: 2, + generic: true, + }, + { + name: "Max64u", + argLen: 2, + generic: true, + }, + { + name: "Min64F", + argLen: 2, + generic: true, + }, + { + name: "Min32F", + argLen: 2, + generic: true, + }, + { + name: "Max64F", + argLen: 2, + generic: true, + }, + { + name: "Max32F", + argLen: 2, + generic: true, + }, + { + name: "FMA", + argLen: 3, + generic: true, + }, + { + name: "Phi", + argLen: -1, + zeroWidth: true, + generic: true, + }, + { + name: "Copy", + argLen: 1, + generic: true, + }, + { + name: "Convert", + argLen: 2, + resultInArg0: true, + zeroWidth: true, + generic: true, + }, + { + name: "ConstBool", + auxType: auxBool, + argLen: 0, + generic: true, + }, + { + name: "ConstString", + auxType: auxString, + argLen: 0, + generic: true, + }, + { + name: "ConstNil", + argLen: 0, + generic: true, + }, + { + name: "Const8", + auxType: auxInt8, + argLen: 0, + generic: true, + }, + { + name: "Const16", + auxType: auxInt16, + argLen: 0, + generic: true, + }, + { + name: "Const32", + auxType: auxInt32, + argLen: 0, + generic: true, + }, + { + name: "Const64", + auxType: auxInt64, + argLen: 0, + generic: true, + }, + { + name: "Const32F", + auxType: auxFloat32, + argLen: 0, + generic: true, + }, + { + name: "Const64F", + auxType: auxFloat64, + argLen: 0, + generic: true, + }, + { + name: "ConstInterface", + argLen: 0, + generic: true, + }, + { + name: "ConstSlice", + argLen: 0, + generic: true, + }, + { + name: "InitMem", + argLen: 0, + zeroWidth: true, + generic: true, + }, + { + name: "Arg", + auxType: auxSymOff, + argLen: 0, + zeroWidth: true, + symEffect: SymRead, + generic: true, + }, + { + name: "ArgIntReg", + auxType: auxNameOffsetInt8, + argLen: 0, + zeroWidth: true, + generic: true, + }, + { + name: "ArgFloatReg", + auxType: auxNameOffsetInt8, + argLen: 0, + zeroWidth: true, + generic: true, + }, + { + name: "Addr", + auxType: auxSym, + argLen: 1, + symEffect: SymAddr, + generic: true, + }, + { + name: "LocalAddr", + auxType: auxSym, + argLen: 2, + symEffect: SymAddr, + generic: true, + }, + { + name: "SP", + argLen: 0, + zeroWidth: true, + fixedReg: true, + generic: true, + }, + { + name: "SB", + argLen: 0, + zeroWidth: true, + fixedReg: true, + generic: true, + }, + { + name: "SPanchored", + argLen: 2, + zeroWidth: true, + generic: true, + }, + { + name: "Load", + argLen: 2, + generic: true, + }, + { + name: "Dereference", + argLen: 2, + generic: true, + }, + { + name: "Store", + auxType: auxTyp, + argLen: 3, + generic: true, + }, + { + name: "LoadMasked8", + argLen: 3, + generic: true, + }, + { + name: "LoadMasked16", + argLen: 3, + generic: true, + }, + { + name: "LoadMasked32", + argLen: 3, + generic: true, + }, + { + name: "LoadMasked64", + argLen: 3, + generic: true, + }, + { + name: "StoreMasked8", + auxType: auxTyp, + argLen: 4, + generic: true, + }, + { + name: "StoreMasked16", + auxType: auxTyp, + argLen: 4, + generic: true, + }, + { + name: "StoreMasked32", + auxType: auxTyp, + argLen: 4, + generic: true, + }, + { + name: "StoreMasked64", + auxType: auxTyp, + argLen: 4, + generic: true, + }, + { + name: "Move", + auxType: auxTypSize, + argLen: 3, + generic: true, + }, + { + name: "Zero", + auxType: auxTypSize, + argLen: 2, + generic: true, + }, + { + name: "StoreWB", + auxType: auxTyp, + argLen: 3, + generic: true, + }, + { + name: "MoveWB", + auxType: auxTypSize, + argLen: 3, + generic: true, + }, + { + name: "ZeroWB", + auxType: auxTypSize, + argLen: 2, + generic: true, + }, + { + name: "WBend", + argLen: 1, + generic: true, + }, + { + name: "WB", + auxType: auxInt64, + argLen: 1, + generic: true, + }, + { + name: "HasCPUFeature", + auxType: auxSym, + argLen: 0, + symEffect: SymNone, + generic: true, + }, + { + name: "PanicBounds", + auxType: auxInt64, + argLen: 3, + call: true, + generic: true, + }, + { + name: "PanicExtend", + auxType: auxInt64, + argLen: 4, + call: true, + generic: true, + }, + { + name: "ClosureCall", + auxType: auxCallOff, + argLen: -1, + call: true, + generic: true, + }, + { + name: "StaticCall", + auxType: auxCallOff, + argLen: -1, + call: true, + generic: true, + }, + { + name: "InterCall", + auxType: auxCallOff, + argLen: -1, + call: true, + generic: true, + }, + { + name: "TailCall", + auxType: auxCallOff, + argLen: -1, + call: true, + generic: true, + }, + { + name: "ClosureLECall", + auxType: auxCallOff, + argLen: -1, + call: true, + generic: true, + }, + { + name: "StaticLECall", + auxType: auxCallOff, + argLen: -1, + call: true, + generic: true, + }, + { + name: "InterLECall", + auxType: auxCallOff, + argLen: -1, + call: true, + generic: true, + }, + { + name: "TailLECall", + auxType: auxCallOff, + argLen: -1, + call: true, + generic: true, + }, + { + name: "SignExt8to16", + argLen: 1, + generic: true, + }, + { + name: "SignExt8to32", + argLen: 1, + generic: true, + }, + { + name: "SignExt8to64", + argLen: 1, + generic: true, + }, + { + name: "SignExt16to32", + argLen: 1, + generic: true, + }, + { + name: "SignExt16to64", + argLen: 1, + generic: true, + }, + { + name: "SignExt32to64", + argLen: 1, + generic: true, + }, + { + name: "ZeroExt8to16", + argLen: 1, + generic: true, + }, + { + name: "ZeroExt8to32", + argLen: 1, + generic: true, + }, + { + name: "ZeroExt8to64", + argLen: 1, + generic: true, + }, + { + name: "ZeroExt16to32", + argLen: 1, + generic: true, + }, + { + name: "ZeroExt16to64", + argLen: 1, + generic: true, + }, + { + name: "ZeroExt32to64", + argLen: 1, + generic: true, + }, + { + name: "Trunc16to8", + argLen: 1, + generic: true, + }, + { + name: "Trunc32to8", + argLen: 1, + generic: true, + }, + { + name: "Trunc32to16", + argLen: 1, + generic: true, + }, + { + name: "Trunc64to8", + argLen: 1, + generic: true, + }, + { + name: "Trunc64to16", + argLen: 1, + generic: true, + }, + { + name: "Trunc64to32", + argLen: 1, + generic: true, + }, + { + name: "Cvt32to32F", + argLen: 1, + generic: true, + }, + { + name: "Cvt32to64F", + argLen: 1, + generic: true, + }, + { + name: "Cvt64to32F", + argLen: 1, + generic: true, + }, + { + name: "Cvt64to64F", + argLen: 1, + generic: true, + }, + { + name: "Cvt32Fto32", + argLen: 1, + generic: true, + }, + { + name: "Cvt32Fto64", + argLen: 1, + generic: true, + }, + { + name: "Cvt64Fto32", + argLen: 1, + generic: true, + }, + { + name: "Cvt64Fto64", + argLen: 1, + generic: true, + }, + { + name: "Cvt32Fto64F", + argLen: 1, + generic: true, + }, + { + name: "Cvt64Fto32F", + argLen: 1, + generic: true, + }, + { + name: "CvtBoolToUint8", + argLen: 1, + generic: true, + }, + { + name: "Round32F", + argLen: 1, + generic: true, + }, + { + name: "Round64F", + argLen: 1, + generic: true, + }, + { + name: "IsNonNil", + argLen: 1, + generic: true, + }, + { + name: "IsInBounds", + argLen: 2, + generic: true, + }, + { + name: "IsSliceInBounds", + argLen: 2, + generic: true, + }, + { + name: "NilCheck", + argLen: 2, + nilCheck: true, + generic: true, + }, + { + name: "GetG", + argLen: 1, + zeroWidth: true, + generic: true, + }, + { + name: "GetClosurePtr", + argLen: 0, + generic: true, + }, + { + name: "GetCallerPC", + argLen: 0, + generic: true, + }, + { + name: "GetCallerSP", + argLen: 1, + generic: true, + }, + { + name: "PtrIndex", + argLen: 2, + generic: true, + }, + { + name: "OffPtr", + auxType: auxInt64, + argLen: 1, + generic: true, + }, + { + name: "SliceMake", + argLen: 3, + generic: true, + }, + { + name: "SlicePtr", + argLen: 1, + generic: true, + }, + { + name: "SliceLen", + argLen: 1, + generic: true, + }, + { + name: "SliceCap", + argLen: 1, + generic: true, + }, + { + name: "SlicePtrUnchecked", + argLen: 1, + generic: true, + }, + { + name: "ComplexMake", + argLen: 2, + generic: true, + }, + { + name: "ComplexReal", + argLen: 1, + generic: true, + }, + { + name: "ComplexImag", + argLen: 1, + generic: true, + }, + { + name: "StringMake", + argLen: 2, + generic: true, + }, + { + name: "StringPtr", + argLen: 1, + generic: true, + }, + { + name: "StringLen", + argLen: 1, + generic: true, + }, + { + name: "IMake", + argLen: 2, + generic: true, + }, + { + name: "ITab", + argLen: 1, + generic: true, + }, + { + name: "IData", + argLen: 1, + generic: true, + }, + { + name: "StructMake", + argLen: -1, + generic: true, + }, + { + name: "StructSelect", + auxType: auxInt64, + argLen: 1, + generic: true, + }, + { + name: "ArrayMake1", + argLen: 1, + generic: true, + }, + { + name: "ArraySelect", + auxType: auxInt64, + argLen: 1, + generic: true, + }, + { + name: "StoreReg", + argLen: 1, + generic: true, + }, + { + name: "LoadReg", + argLen: 1, + generic: true, + }, + { + name: "FwdRef", + auxType: auxSym, + argLen: 0, + symEffect: SymNone, + generic: true, + }, + { + name: "Unknown", + argLen: 0, + generic: true, + }, + { + name: "VarDef", + auxType: auxSym, + argLen: 1, + zeroWidth: true, + symEffect: SymNone, + generic: true, + }, + { + name: "VarLive", + auxType: auxSym, + argLen: 1, + zeroWidth: true, + symEffect: SymRead, + generic: true, + }, + { + name: "KeepAlive", + argLen: 2, + zeroWidth: true, + generic: true, + }, + { + name: "InlMark", + auxType: auxInt32, + argLen: 1, + generic: true, + }, + { + name: "Int64Make", + argLen: 2, + generic: true, + }, + { + name: "Int64Hi", + argLen: 1, + generic: true, + }, + { + name: "Int64Lo", + argLen: 1, + generic: true, + }, + { + name: "Add32carry", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Add32withcarry", + argLen: 3, + commutative: true, + generic: true, + }, + { + name: "Add32carrywithcarry", + argLen: 3, + commutative: true, + generic: true, + }, + { + name: "Sub32carry", + argLen: 2, + generic: true, + }, + { + name: "Sub32withcarry", + argLen: 3, + generic: true, + }, + { + name: "Add64carry", + argLen: 3, + commutative: true, + generic: true, + }, + { + name: "Sub64borrow", + argLen: 3, + generic: true, + }, + { + name: "Signmask", + argLen: 1, + generic: true, + }, + { + name: "Zeromask", + argLen: 1, + generic: true, + }, + { + name: "Slicemask", + argLen: 1, + generic: true, + }, + { + name: "SpectreIndex", + argLen: 2, + generic: true, + }, + { + name: "SpectreSliceIndex", + argLen: 2, + generic: true, + }, + { + name: "Cvt32Uto32F", + argLen: 1, + generic: true, + }, + { + name: "Cvt32Uto64F", + argLen: 1, + generic: true, + }, + { + name: "Cvt32Fto32U", + argLen: 1, + generic: true, + }, + { + name: "Cvt64Fto32U", + argLen: 1, + generic: true, + }, + { + name: "Cvt64Uto32F", + argLen: 1, + generic: true, + }, + { + name: "Cvt64Uto64F", + argLen: 1, + generic: true, + }, + { + name: "Cvt32Fto64U", + argLen: 1, + generic: true, + }, + { + name: "Cvt64Fto64U", + argLen: 1, + generic: true, + }, + { + name: "Select0", + argLen: 1, + zeroWidth: true, + generic: true, + }, + { + name: "Select1", + argLen: 1, + zeroWidth: true, + generic: true, + }, + { + name: "MakeTuple", + argLen: 2, + generic: true, + }, + { + name: "SelectN", + auxType: auxInt64, + argLen: 1, + generic: true, + }, + { + name: "SelectNAddr", + auxType: auxInt64, + argLen: 1, + generic: true, + }, + { + name: "MakeResult", + argLen: -1, + generic: true, + }, + { + name: "AtomicLoad8", + argLen: 2, + generic: true, + }, + { + name: "AtomicLoad32", + argLen: 2, + generic: true, + }, + { + name: "AtomicLoad64", + argLen: 2, + generic: true, + }, + { + name: "AtomicLoadPtr", + argLen: 2, + generic: true, + }, + { + name: "AtomicLoadAcq32", + argLen: 2, + generic: true, + }, + { + name: "AtomicLoadAcq64", + argLen: 2, + generic: true, + }, + { + name: "AtomicStore8", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicStore32", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicStore64", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicStorePtrNoWB", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicStoreRel32", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicStoreRel64", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicExchange8", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicExchange32", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicExchange64", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAdd32", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAdd64", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicCompareAndSwap32", + argLen: 4, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicCompareAndSwap64", + argLen: 4, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicCompareAndSwapRel32", + argLen: 4, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAnd8", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicOr8", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAnd32", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicOr32", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAnd64value", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAnd32value", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAnd8value", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicOr64value", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicOr32value", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicOr8value", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicStore8Variant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicStore32Variant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicStore64Variant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAdd32Variant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAdd64Variant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicExchange8Variant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicExchange32Variant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicExchange64Variant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicCompareAndSwap32Variant", + argLen: 4, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicCompareAndSwap64Variant", + argLen: 4, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAnd64valueVariant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicOr64valueVariant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAnd32valueVariant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicOr32valueVariant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicAnd8valueVariant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "AtomicOr8valueVariant", + argLen: 3, + hasSideEffects: true, + generic: true, + }, + { + name: "PubBarrier", + argLen: 1, + hasSideEffects: true, + generic: true, + }, + { + name: "Clobber", + auxType: auxSymOff, + argLen: 0, + symEffect: SymNone, + generic: true, + }, + { + name: "ClobberReg", + argLen: 0, + generic: true, + }, + { + name: "PrefetchCache", + argLen: 2, + hasSideEffects: true, + generic: true, + }, + { + name: "PrefetchCacheStreamed", + argLen: 2, + hasSideEffects: true, + generic: true, + }, + { + name: "MemEq", + argLen: 4, + commutative: true, + generic: true, + }, + { + name: "Empty", + argLen: 0, + generic: true, + }, + { + name: "ZeroSIMD", + argLen: 0, + generic: true, + }, + { + name: "Cvt16toMask8x16", + argLen: 1, + generic: true, + }, + { + name: "Cvt32toMask8x32", + argLen: 1, + generic: true, + }, + { + name: "Cvt64toMask8x64", + argLen: 1, + generic: true, + }, + { + name: "Cvt8toMask16x8", + argLen: 1, + generic: true, + }, + { + name: "Cvt16toMask16x16", + argLen: 1, + generic: true, + }, + { + name: "Cvt32toMask16x32", + argLen: 1, + generic: true, + }, + { + name: "Cvt8toMask32x4", + argLen: 1, + generic: true, + }, + { + name: "Cvt8toMask32x8", + argLen: 1, + generic: true, + }, + { + name: "Cvt16toMask32x16", + argLen: 1, + generic: true, + }, + { + name: "Cvt8toMask64x2", + argLen: 1, + generic: true, + }, + { + name: "Cvt8toMask64x4", + argLen: 1, + generic: true, + }, + { + name: "Cvt8toMask64x8", + argLen: 1, + generic: true, + }, + { + name: "CvtMask8x16to16", + argLen: 1, + generic: true, + }, + { + name: "CvtMask8x32to32", + argLen: 1, + generic: true, + }, + { + name: "CvtMask8x64to64", + argLen: 1, + generic: true, + }, + { + name: "CvtMask16x8to8", + argLen: 1, + generic: true, + }, + { + name: "CvtMask16x16to16", + argLen: 1, + generic: true, + }, + { + name: "CvtMask16x32to32", + argLen: 1, + generic: true, + }, + { + name: "CvtMask32x4to8", + argLen: 1, + generic: true, + }, + { + name: "CvtMask32x8to8", + argLen: 1, + generic: true, + }, + { + name: "CvtMask32x16to16", + argLen: 1, + generic: true, + }, + { + name: "CvtMask64x2to8", + argLen: 1, + generic: true, + }, + { + name: "CvtMask64x4to8", + argLen: 1, + generic: true, + }, + { + name: "CvtMask64x8to8", + argLen: 1, + generic: true, + }, + { + name: "IsZeroVec", + argLen: 1, + generic: true, + }, + { + name: "IsNaNFloat32x4", + argLen: 1, + generic: true, + }, + { + name: "IsNaNFloat32x8", + argLen: 1, + generic: true, + }, + { + name: "IsNaNFloat32x16", + argLen: 1, + generic: true, + }, + { + name: "IsNaNFloat64x2", + argLen: 1, + generic: true, + }, + { + name: "IsNaNFloat64x4", + argLen: 1, + generic: true, + }, + { + name: "IsNaNFloat64x8", + argLen: 1, + generic: true, + }, + { + name: "AESDecryptLastRoundUint8x16", + argLen: 2, + generic: true, + }, + { + name: "AESDecryptLastRoundUint8x32", + argLen: 2, + generic: true, + }, + { + name: "AESDecryptLastRoundUint8x64", + argLen: 2, + generic: true, + }, + { + name: "AESDecryptOneRoundUint8x16", + argLen: 2, + generic: true, + }, + { + name: "AESDecryptOneRoundUint8x32", + argLen: 2, + generic: true, + }, + { + name: "AESDecryptOneRoundUint8x64", + argLen: 2, + generic: true, + }, + { + name: "AESEncryptLastRoundUint8x16", + argLen: 2, + generic: true, + }, + { + name: "AESEncryptLastRoundUint8x32", + argLen: 2, + generic: true, + }, + { + name: "AESEncryptLastRoundUint8x64", + argLen: 2, + generic: true, + }, + { + name: "AESEncryptOneRoundUint8x16", + argLen: 2, + generic: true, + }, + { + name: "AESEncryptOneRoundUint8x32", + argLen: 2, + generic: true, + }, + { + name: "AESEncryptOneRoundUint8x64", + argLen: 2, + generic: true, + }, + { + name: "AESInvMixColumnsUint32x4", + argLen: 1, + generic: true, + }, + { + name: "AbsInt8x16", + argLen: 1, + generic: true, + }, + { + name: "AbsInt8x32", + argLen: 1, + generic: true, + }, + { + name: "AbsInt8x64", + argLen: 1, + generic: true, + }, + { + name: "AbsInt16x8", + argLen: 1, + generic: true, + }, + { + name: "AbsInt16x16", + argLen: 1, + generic: true, + }, + { + name: "AbsInt16x32", + argLen: 1, + generic: true, + }, + { + name: "AbsInt32x4", + argLen: 1, + generic: true, + }, + { + name: "AbsInt32x8", + argLen: 1, + generic: true, + }, + { + name: "AbsInt32x16", + argLen: 1, + generic: true, + }, + { + name: "AbsInt64x2", + argLen: 1, + generic: true, + }, + { + name: "AbsInt64x4", + argLen: 1, + generic: true, + }, + { + name: "AbsInt64x8", + argLen: 1, + generic: true, + }, + { + name: "AddFloat32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddFloat32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddFloat32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddFloat64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddFloat64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddFloat64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddInt64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddPairsFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "AddPairsFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "AddPairsGroupedFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "AddPairsGroupedFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "AddPairsGroupedInt16x16", + argLen: 2, + generic: true, + }, + { + name: "AddPairsGroupedInt32x8", + argLen: 2, + generic: true, + }, + { + name: "AddPairsGroupedUint16x16", + argLen: 2, + generic: true, + }, + { + name: "AddPairsGroupedUint32x8", + argLen: 2, + generic: true, + }, + { + name: "AddPairsInt16x8", + argLen: 2, + generic: true, + }, + { + name: "AddPairsInt32x4", + argLen: 2, + generic: true, + }, + { + name: "AddPairsSaturatedGroupedInt16x16", + argLen: 2, + generic: true, + }, + { + name: "AddPairsSaturatedInt16x8", + argLen: 2, + generic: true, + }, + { + name: "AddPairsUint16x8", + argLen: 2, + generic: true, + }, + { + name: "AddPairsUint32x4", + argLen: 2, + generic: true, + }, + { + name: "AddSaturatedInt8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedInt8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedInt8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedInt16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedInt16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedUint8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedUint8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedUint8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSaturatedUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddSubFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "AddSubFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "AddSubFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "AddSubFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "AddUint8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AddUint64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndInt64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndNotInt8x16", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt8x32", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt8x64", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt16x8", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt16x16", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt16x32", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt32x4", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt32x8", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt32x16", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt64x2", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt64x4", + argLen: 2, + generic: true, + }, + { + name: "AndNotInt64x8", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint8x16", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint8x32", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint8x64", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint16x8", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint16x16", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint16x32", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint32x4", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint32x8", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint32x16", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint64x2", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint64x4", + argLen: 2, + generic: true, + }, + { + name: "AndNotUint64x8", + argLen: 2, + generic: true, + }, + { + name: "AndUint8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AndUint64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AverageUint8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AverageUint8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AverageUint8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AverageUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AverageUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "AverageUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "Broadcast1To2Float64x2", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To2Int64x2", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To2Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To4Float32x4", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To4Float64x2", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To4Int32x4", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To4Int64x2", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To4Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To4Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To8Float32x4", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To8Float64x2", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To8Int16x8", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To8Int32x4", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To8Int64x2", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To8Uint16x8", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To8Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To8Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To16Float32x4", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To16Int8x16", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To16Int16x8", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To16Int32x4", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To16Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To16Uint16x8", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To16Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To32Int8x16", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To32Int16x8", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To32Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To32Uint16x8", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To64Int8x16", + argLen: 1, + generic: true, + }, + { + name: "Broadcast1To64Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "CeilFloat32x4", + argLen: 1, + generic: true, + }, + { + name: "CeilFloat32x8", + argLen: 1, + generic: true, + }, + { + name: "CeilFloat64x2", + argLen: 1, + generic: true, + }, + { + name: "CeilFloat64x4", + argLen: 1, + generic: true, + }, + { + name: "CompressFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "CompressFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "CompressFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "CompressFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "CompressFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "CompressFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "CompressInt8x16", + argLen: 2, + generic: true, + }, + { + name: "CompressInt8x32", + argLen: 2, + generic: true, + }, + { + name: "CompressInt8x64", + argLen: 2, + generic: true, + }, + { + name: "CompressInt16x8", + argLen: 2, + generic: true, + }, + { + name: "CompressInt16x16", + argLen: 2, + generic: true, + }, + { + name: "CompressInt16x32", + argLen: 2, + generic: true, + }, + { + name: "CompressInt32x4", + argLen: 2, + generic: true, + }, + { + name: "CompressInt32x8", + argLen: 2, + generic: true, + }, + { + name: "CompressInt32x16", + argLen: 2, + generic: true, + }, + { + name: "CompressInt64x2", + argLen: 2, + generic: true, + }, + { + name: "CompressInt64x4", + argLen: 2, + generic: true, + }, + { + name: "CompressInt64x8", + argLen: 2, + generic: true, + }, + { + name: "CompressUint8x16", + argLen: 2, + generic: true, + }, + { + name: "CompressUint8x32", + argLen: 2, + generic: true, + }, + { + name: "CompressUint8x64", + argLen: 2, + generic: true, + }, + { + name: "CompressUint16x8", + argLen: 2, + generic: true, + }, + { + name: "CompressUint16x16", + argLen: 2, + generic: true, + }, + { + name: "CompressUint16x32", + argLen: 2, + generic: true, + }, + { + name: "CompressUint32x4", + argLen: 2, + generic: true, + }, + { + name: "CompressUint32x8", + argLen: 2, + generic: true, + }, + { + name: "CompressUint32x16", + argLen: 2, + generic: true, + }, + { + name: "CompressUint64x2", + argLen: 2, + generic: true, + }, + { + name: "CompressUint64x4", + argLen: 2, + generic: true, + }, + { + name: "CompressUint64x8", + argLen: 2, + generic: true, + }, + { + name: "ConcatPermuteFloat32x4", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteFloat32x8", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteFloat32x16", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteFloat64x2", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteFloat64x4", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteFloat64x8", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt8x16", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt8x32", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt8x64", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt16x8", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt16x16", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt16x32", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt32x4", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt32x8", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt32x16", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt64x2", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt64x4", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteInt64x8", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint8x16", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint8x32", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint8x64", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint16x8", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint16x16", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint16x32", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint32x4", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint32x8", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint32x16", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint64x2", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint64x4", + argLen: 3, + generic: true, + }, + { + name: "ConcatPermuteUint64x8", + argLen: 3, + generic: true, + }, + { + name: "ConvertToFloat32Float64x2", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Float64x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Float64x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Int32x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Int32x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Int32x16", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Int64x2", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Int64x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Int64x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Uint32x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Uint32x16", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Uint64x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat32Uint64x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Float32x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Float32x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Int32x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Int32x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Int64x2", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Int64x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Int64x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Uint32x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Uint64x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToFloat64Uint64x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt32Float32x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt32Float32x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt32Float32x16", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt32Float64x2", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt32Float64x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt32Float64x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt64Float32x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt64Float32x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt64Float64x2", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt64Float64x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToInt64Float64x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint32Float32x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint32Float32x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint32Float32x16", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint32Float64x2", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint32Float64x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint32Float64x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint64Float32x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint64Float32x8", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint64Float64x2", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint64Float64x4", + argLen: 1, + generic: true, + }, + { + name: "ConvertToUint64Float64x8", + argLen: 1, + generic: true, + }, + { + name: "CopySignInt8x16", + argLen: 2, + generic: true, + }, + { + name: "CopySignInt8x32", + argLen: 2, + generic: true, + }, + { + name: "CopySignInt16x8", + argLen: 2, + generic: true, + }, + { + name: "CopySignInt16x16", + argLen: 2, + generic: true, + }, + { + name: "CopySignInt32x4", + argLen: 2, + generic: true, + }, + { + name: "CopySignInt32x8", + argLen: 2, + generic: true, + }, + { + name: "DivFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "DivFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "DivFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "DivFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "DivFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "DivFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "DotProductPairsInt16x8", + argLen: 2, + generic: true, + }, + { + name: "DotProductPairsInt16x16", + argLen: 2, + generic: true, + }, + { + name: "DotProductPairsInt16x32", + argLen: 2, + generic: true, + }, + { + name: "DotProductPairsSaturatedUint8x16", + argLen: 2, + generic: true, + }, + { + name: "DotProductPairsSaturatedUint8x32", + argLen: 2, + generic: true, + }, + { + name: "DotProductPairsSaturatedUint8x64", + argLen: 2, + generic: true, + }, + { + name: "EqualFloat32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualFloat32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualFloat32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualFloat64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualFloat64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualFloat64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualInt64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "EqualUint64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "ExpandFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "ExpandFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "ExpandFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "ExpandFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "ExpandFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "ExpandFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt8x16", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt8x32", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt8x64", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt16x8", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt16x16", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt16x32", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt32x4", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt32x8", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt32x16", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt64x2", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt64x4", + argLen: 2, + generic: true, + }, + { + name: "ExpandInt64x8", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint8x16", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint8x32", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint8x64", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint16x8", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint16x16", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint16x32", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint32x4", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint32x8", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint32x16", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint64x2", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint64x4", + argLen: 2, + generic: true, + }, + { + name: "ExpandUint64x8", + argLen: 2, + generic: true, + }, + { + name: "ExtendLo2ToInt64Int8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo2ToInt64Int16x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo2ToInt64Int32x4", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo2ToUint64Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo2ToUint64Uint16x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo2ToUint64Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo4ToInt32Int8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo4ToInt32Int16x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo4ToInt64Int8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo4ToInt64Int16x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo4ToUint32Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo4ToUint32Uint16x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo4ToUint64Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo4ToUint64Uint16x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo8ToInt16Int8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo8ToInt32Int8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo8ToInt64Int8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo8ToUint16Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo8ToUint32Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendLo8ToUint64Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendToInt16Int8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendToInt16Int8x32", + argLen: 1, + generic: true, + }, + { + name: "ExtendToInt32Int8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendToInt32Int16x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendToInt32Int16x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendToInt64Int16x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendToInt64Int32x4", + argLen: 1, + generic: true, + }, + { + name: "ExtendToInt64Int32x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendToUint16Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendToUint16Uint8x32", + argLen: 1, + generic: true, + }, + { + name: "ExtendToUint32Uint8x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendToUint32Uint16x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendToUint32Uint16x16", + argLen: 1, + generic: true, + }, + { + name: "ExtendToUint64Uint16x8", + argLen: 1, + generic: true, + }, + { + name: "ExtendToUint64Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "ExtendToUint64Uint32x8", + argLen: 1, + generic: true, + }, + { + name: "FloorFloat32x4", + argLen: 1, + generic: true, + }, + { + name: "FloorFloat32x8", + argLen: 1, + generic: true, + }, + { + name: "FloorFloat64x2", + argLen: 1, + generic: true, + }, + { + name: "FloorFloat64x4", + argLen: 1, + generic: true, + }, + { + name: "GaloisFieldMulUint8x16", + argLen: 2, + generic: true, + }, + { + name: "GaloisFieldMulUint8x32", + argLen: 2, + generic: true, + }, + { + name: "GaloisFieldMulUint8x64", + argLen: 2, + generic: true, + }, + { + name: "GetHiFloat32x8", + argLen: 1, + generic: true, + }, + { + name: "GetHiFloat32x16", + argLen: 1, + generic: true, + }, + { + name: "GetHiFloat64x4", + argLen: 1, + generic: true, + }, + { + name: "GetHiFloat64x8", + argLen: 1, + generic: true, + }, + { + name: "GetHiInt8x32", + argLen: 1, + generic: true, + }, + { + name: "GetHiInt8x64", + argLen: 1, + generic: true, + }, + { + name: "GetHiInt16x16", + argLen: 1, + generic: true, + }, + { + name: "GetHiInt16x32", + argLen: 1, + generic: true, + }, + { + name: "GetHiInt32x8", + argLen: 1, + generic: true, + }, + { + name: "GetHiInt32x16", + argLen: 1, + generic: true, + }, + { + name: "GetHiInt64x4", + argLen: 1, + generic: true, + }, + { + name: "GetHiInt64x8", + argLen: 1, + generic: true, + }, + { + name: "GetHiUint8x32", + argLen: 1, + generic: true, + }, + { + name: "GetHiUint8x64", + argLen: 1, + generic: true, + }, + { + name: "GetHiUint16x16", + argLen: 1, + generic: true, + }, + { + name: "GetHiUint16x32", + argLen: 1, + generic: true, + }, + { + name: "GetHiUint32x8", + argLen: 1, + generic: true, + }, + { + name: "GetHiUint32x16", + argLen: 1, + generic: true, + }, + { + name: "GetHiUint64x4", + argLen: 1, + generic: true, + }, + { + name: "GetHiUint64x8", + argLen: 1, + generic: true, + }, + { + name: "GetLoFloat32x8", + argLen: 1, + generic: true, + }, + { + name: "GetLoFloat32x16", + argLen: 1, + generic: true, + }, + { + name: "GetLoFloat64x4", + argLen: 1, + generic: true, + }, + { + name: "GetLoFloat64x8", + argLen: 1, + generic: true, + }, + { + name: "GetLoInt8x32", + argLen: 1, + generic: true, + }, + { + name: "GetLoInt8x64", + argLen: 1, + generic: true, + }, + { + name: "GetLoInt16x16", + argLen: 1, + generic: true, + }, + { + name: "GetLoInt16x32", + argLen: 1, + generic: true, + }, + { + name: "GetLoInt32x8", + argLen: 1, + generic: true, + }, + { + name: "GetLoInt32x16", + argLen: 1, + generic: true, + }, + { + name: "GetLoInt64x4", + argLen: 1, + generic: true, + }, + { + name: "GetLoInt64x8", + argLen: 1, + generic: true, + }, + { + name: "GetLoUint8x32", + argLen: 1, + generic: true, + }, + { + name: "GetLoUint8x64", + argLen: 1, + generic: true, + }, + { + name: "GetLoUint16x16", + argLen: 1, + generic: true, + }, + { + name: "GetLoUint16x32", + argLen: 1, + generic: true, + }, + { + name: "GetLoUint32x8", + argLen: 1, + generic: true, + }, + { + name: "GetLoUint32x16", + argLen: 1, + generic: true, + }, + { + name: "GetLoUint64x4", + argLen: 1, + generic: true, + }, + { + name: "GetLoUint64x8", + argLen: 1, + generic: true, + }, + { + name: "GreaterEqualFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualInt8x64", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualInt16x32", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualInt32x16", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualInt64x8", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualUint8x64", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualUint16x32", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualUint32x16", + argLen: 2, + generic: true, + }, + { + name: "GreaterEqualUint64x8", + argLen: 2, + generic: true, + }, + { + name: "GreaterFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "GreaterFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "GreaterFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "GreaterFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "GreaterFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "GreaterFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt8x16", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt8x32", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt8x64", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt16x8", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt16x16", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt16x32", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt32x4", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt32x8", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt32x16", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt64x2", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt64x4", + argLen: 2, + generic: true, + }, + { + name: "GreaterInt64x8", + argLen: 2, + generic: true, + }, + { + name: "GreaterUint8x64", + argLen: 2, + generic: true, + }, + { + name: "GreaterUint16x32", + argLen: 2, + generic: true, + }, + { + name: "GreaterUint32x16", + argLen: 2, + generic: true, + }, + { + name: "GreaterUint64x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedInt16x16", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedInt16x32", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedInt32x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedInt32x16", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedInt64x4", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedInt64x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedUint16x16", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedUint16x32", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedUint32x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedUint32x16", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedUint64x4", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiGroupedUint64x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiInt16x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiInt32x4", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiInt64x2", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiUint16x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiUint32x4", + argLen: 2, + generic: true, + }, + { + name: "InterleaveHiUint64x2", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedInt16x16", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedInt16x32", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedInt32x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedInt32x16", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedInt64x4", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedInt64x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedUint16x16", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedUint16x32", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedUint32x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedUint32x16", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedUint64x4", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoGroupedUint64x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoInt16x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoInt32x4", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoInt64x2", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoUint16x8", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoUint32x4", + argLen: 2, + generic: true, + }, + { + name: "InterleaveLoUint64x2", + argLen: 2, + generic: true, + }, + { + name: "LeadingZerosInt32x4", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosInt32x8", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosInt32x16", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosInt64x2", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosInt64x4", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosInt64x8", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosUint32x4", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosUint32x8", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosUint32x16", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosUint64x2", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosUint64x4", + argLen: 1, + generic: true, + }, + { + name: "LeadingZerosUint64x8", + argLen: 1, + generic: true, + }, + { + name: "LessEqualFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "LessEqualFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "LessEqualFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "LessEqualFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "LessEqualFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "LessEqualFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "LessEqualInt8x64", + argLen: 2, + generic: true, + }, + { + name: "LessEqualInt16x32", + argLen: 2, + generic: true, + }, + { + name: "LessEqualInt32x16", + argLen: 2, + generic: true, + }, + { + name: "LessEqualInt64x8", + argLen: 2, + generic: true, + }, + { + name: "LessEqualUint8x64", + argLen: 2, + generic: true, + }, + { + name: "LessEqualUint16x32", + argLen: 2, + generic: true, + }, + { + name: "LessEqualUint32x16", + argLen: 2, + generic: true, + }, + { + name: "LessEqualUint64x8", + argLen: 2, + generic: true, + }, + { + name: "LessFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "LessFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "LessFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "LessFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "LessFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "LessFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "LessInt8x64", + argLen: 2, + generic: true, + }, + { + name: "LessInt16x32", + argLen: 2, + generic: true, + }, + { + name: "LessInt32x16", + argLen: 2, + generic: true, + }, + { + name: "LessInt64x8", + argLen: 2, + generic: true, + }, + { + name: "LessUint8x64", + argLen: 2, + generic: true, + }, + { + name: "LessUint16x32", + argLen: 2, + generic: true, + }, + { + name: "LessUint32x16", + argLen: 2, + generic: true, + }, + { + name: "LessUint64x8", + argLen: 2, + generic: true, + }, + { + name: "MaxFloat32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxFloat32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxFloat32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxFloat64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxFloat64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxFloat64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxInt64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MaxUint64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinFloat32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinFloat32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinFloat32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinFloat64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinFloat64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinFloat64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinInt64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MinUint64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulAddFloat32x4", + argLen: 3, + generic: true, + }, + { + name: "MulAddFloat32x8", + argLen: 3, + generic: true, + }, + { + name: "MulAddFloat32x16", + argLen: 3, + generic: true, + }, + { + name: "MulAddFloat64x2", + argLen: 3, + generic: true, + }, + { + name: "MulAddFloat64x4", + argLen: 3, + generic: true, + }, + { + name: "MulAddFloat64x8", + argLen: 3, + generic: true, + }, + { + name: "MulAddSubFloat32x4", + argLen: 3, + generic: true, + }, + { + name: "MulAddSubFloat32x8", + argLen: 3, + generic: true, + }, + { + name: "MulAddSubFloat32x16", + argLen: 3, + generic: true, + }, + { + name: "MulAddSubFloat64x2", + argLen: 3, + generic: true, + }, + { + name: "MulAddSubFloat64x4", + argLen: 3, + generic: true, + }, + { + name: "MulAddSubFloat64x8", + argLen: 3, + generic: true, + }, + { + name: "MulEvenWidenInt32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulEvenWidenInt32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulEvenWidenUint32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulEvenWidenUint32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulFloat32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulFloat32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulFloat32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulFloat64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulFloat64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulFloat64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulHighInt16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulHighInt16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulHighInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulHighUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulHighUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulHighUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulInt16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulInt16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulInt32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulInt32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulInt32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulInt64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulInt64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulInt64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulSubAddFloat32x4", + argLen: 3, + generic: true, + }, + { + name: "MulSubAddFloat32x8", + argLen: 3, + generic: true, + }, + { + name: "MulSubAddFloat32x16", + argLen: 3, + generic: true, + }, + { + name: "MulSubAddFloat64x2", + argLen: 3, + generic: true, + }, + { + name: "MulSubAddFloat64x4", + argLen: 3, + generic: true, + }, + { + name: "MulSubAddFloat64x8", + argLen: 3, + generic: true, + }, + { + name: "MulUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulUint32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulUint32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulUint32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulUint64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulUint64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "MulUint64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualFloat32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualFloat32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualFloat32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualFloat64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualFloat64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualFloat64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualInt8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualInt32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualInt64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualUint8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualUint32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "NotEqualUint64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OnesCountInt8x16", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt8x32", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt8x64", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt16x8", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt16x16", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt16x32", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt32x4", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt32x8", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt32x16", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt64x2", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt64x4", + argLen: 1, + generic: true, + }, + { + name: "OnesCountInt64x8", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint8x16", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint8x32", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint8x64", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint16x8", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint16x16", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint16x32", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint32x4", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint32x8", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint32x16", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint64x2", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint64x4", + argLen: 1, + generic: true, + }, + { + name: "OnesCountUint64x8", + argLen: 1, + generic: true, + }, + { + name: "OrInt8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrInt64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "OrUint64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "PermuteFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "PermuteFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "PermuteFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "PermuteFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "PermuteInt8x16", + argLen: 2, + generic: true, + }, + { + name: "PermuteInt8x32", + argLen: 2, + generic: true, + }, + { + name: "PermuteInt8x64", + argLen: 2, + generic: true, + }, + { + name: "PermuteInt16x8", + argLen: 2, + generic: true, + }, + { + name: "PermuteInt16x16", + argLen: 2, + generic: true, + }, + { + name: "PermuteInt16x32", + argLen: 2, + generic: true, + }, + { + name: "PermuteInt32x8", + argLen: 2, + generic: true, + }, + { + name: "PermuteInt32x16", + argLen: 2, + generic: true, + }, + { + name: "PermuteInt64x4", + argLen: 2, + generic: true, + }, + { + name: "PermuteInt64x8", + argLen: 2, + generic: true, + }, + { + name: "PermuteOrZeroGroupedInt8x32", + argLen: 2, + generic: true, + }, + { + name: "PermuteOrZeroGroupedInt8x64", + argLen: 2, + generic: true, + }, + { + name: "PermuteOrZeroGroupedUint8x32", + argLen: 2, + generic: true, + }, + { + name: "PermuteOrZeroGroupedUint8x64", + argLen: 2, + generic: true, + }, + { + name: "PermuteOrZeroInt8x16", + argLen: 2, + generic: true, + }, + { + name: "PermuteOrZeroUint8x16", + argLen: 2, + generic: true, + }, + { + name: "PermuteUint8x16", + argLen: 2, + generic: true, + }, + { + name: "PermuteUint8x32", + argLen: 2, + generic: true, + }, + { + name: "PermuteUint8x64", + argLen: 2, + generic: true, + }, + { + name: "PermuteUint16x8", + argLen: 2, + generic: true, + }, + { + name: "PermuteUint16x16", + argLen: 2, + generic: true, + }, + { + name: "PermuteUint16x32", + argLen: 2, + generic: true, + }, + { + name: "PermuteUint32x8", + argLen: 2, + generic: true, + }, + { + name: "PermuteUint32x16", + argLen: 2, + generic: true, + }, + { + name: "PermuteUint64x4", + argLen: 2, + generic: true, + }, + { + name: "PermuteUint64x8", + argLen: 2, + generic: true, + }, + { + name: "ReciprocalFloat32x4", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalFloat32x8", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalFloat32x16", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalFloat64x2", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalFloat64x4", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalFloat64x8", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalSqrtFloat32x4", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalSqrtFloat32x8", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalSqrtFloat32x16", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalSqrtFloat64x2", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalSqrtFloat64x4", + argLen: 1, + generic: true, + }, + { + name: "ReciprocalSqrtFloat64x8", + argLen: 1, + generic: true, + }, + { + name: "RotateLeftInt32x4", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftInt32x8", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftInt32x16", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftInt64x2", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftInt64x4", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftInt64x8", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftUint32x4", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftUint32x8", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftUint32x16", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftUint64x2", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftUint64x4", + argLen: 2, + generic: true, + }, + { + name: "RotateLeftUint64x8", + argLen: 2, + generic: true, + }, + { + name: "RotateRightInt32x4", + argLen: 2, + generic: true, + }, + { + name: "RotateRightInt32x8", + argLen: 2, + generic: true, + }, + { + name: "RotateRightInt32x16", + argLen: 2, + generic: true, + }, + { + name: "RotateRightInt64x2", + argLen: 2, + generic: true, + }, + { + name: "RotateRightInt64x4", + argLen: 2, + generic: true, + }, + { + name: "RotateRightInt64x8", + argLen: 2, + generic: true, + }, + { + name: "RotateRightUint32x4", + argLen: 2, + generic: true, + }, + { + name: "RotateRightUint32x8", + argLen: 2, + generic: true, + }, + { + name: "RotateRightUint32x16", + argLen: 2, + generic: true, + }, + { + name: "RotateRightUint64x2", + argLen: 2, + generic: true, + }, + { + name: "RotateRightUint64x4", + argLen: 2, + generic: true, + }, + { + name: "RotateRightUint64x8", + argLen: 2, + generic: true, + }, + { + name: "RoundToEvenFloat32x4", + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenFloat32x8", + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenFloat64x2", + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenFloat64x4", + argLen: 1, + generic: true, + }, + { + name: "SHA1Message1Uint32x4", + argLen: 2, + generic: true, + }, + { + name: "SHA1Message2Uint32x4", + argLen: 2, + generic: true, + }, + { + name: "SHA1NextEUint32x4", + argLen: 2, + generic: true, + }, + { + name: "SHA256Message1Uint32x4", + argLen: 2, + generic: true, + }, + { + name: "SHA256Message2Uint32x4", + argLen: 2, + generic: true, + }, + { + name: "SHA256TwoRoundsUint32x4", + argLen: 3, + generic: true, + }, + { + name: "SaturateToInt8Int16x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt8Int16x16", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt8Int16x32", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt8Int32x4", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt8Int32x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt8Int32x16", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt8Int64x2", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt8Int64x4", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt8Int64x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt16ConcatGroupedInt32x8", + argLen: 2, + generic: true, + }, + { + name: "SaturateToInt16ConcatGroupedInt32x16", + argLen: 2, + generic: true, + }, + { + name: "SaturateToInt16ConcatInt32x4", + argLen: 2, + generic: true, + }, + { + name: "SaturateToInt16Int32x4", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt16Int32x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt16Int32x16", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt16Int64x2", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt16Int64x4", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt16Int64x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt32Int64x2", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt32Int64x4", + argLen: 1, + generic: true, + }, + { + name: "SaturateToInt32Int64x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint8Uint16x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint8Uint16x16", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint8Uint16x32", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint8Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint8Uint32x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint8Uint32x16", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint8Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint8Uint64x4", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint8Uint64x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint16ConcatGroupedInt32x8", + argLen: 2, + generic: true, + }, + { + name: "SaturateToUint16ConcatGroupedInt32x16", + argLen: 2, + generic: true, + }, + { + name: "SaturateToUint16ConcatInt32x4", + argLen: 2, + generic: true, + }, + { + name: "SaturateToUint16Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint16Uint32x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint16Uint32x16", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint16Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint16Uint64x4", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint16Uint64x8", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint32Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint32Uint64x4", + argLen: 1, + generic: true, + }, + { + name: "SaturateToUint32Uint64x8", + argLen: 1, + generic: true, + }, + { + name: "ScaleFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "ScaleFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "ScaleFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "ScaleFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "ScaleFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "ScaleFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "SetHiFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "SetHiFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "SetHiFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "SetHiFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "SetHiInt8x32", + argLen: 2, + generic: true, + }, + { + name: "SetHiInt8x64", + argLen: 2, + generic: true, + }, + { + name: "SetHiInt16x16", + argLen: 2, + generic: true, + }, + { + name: "SetHiInt16x32", + argLen: 2, + generic: true, + }, + { + name: "SetHiInt32x8", + argLen: 2, + generic: true, + }, + { + name: "SetHiInt32x16", + argLen: 2, + generic: true, + }, + { + name: "SetHiInt64x4", + argLen: 2, + generic: true, + }, + { + name: "SetHiInt64x8", + argLen: 2, + generic: true, + }, + { + name: "SetHiUint8x32", + argLen: 2, + generic: true, + }, + { + name: "SetHiUint8x64", + argLen: 2, + generic: true, + }, + { + name: "SetHiUint16x16", + argLen: 2, + generic: true, + }, + { + name: "SetHiUint16x32", + argLen: 2, + generic: true, + }, + { + name: "SetHiUint32x8", + argLen: 2, + generic: true, + }, + { + name: "SetHiUint32x16", + argLen: 2, + generic: true, + }, + { + name: "SetHiUint64x4", + argLen: 2, + generic: true, + }, + { + name: "SetHiUint64x8", + argLen: 2, + generic: true, + }, + { + name: "SetLoFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "SetLoFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "SetLoFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "SetLoFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "SetLoInt8x32", + argLen: 2, + generic: true, + }, + { + name: "SetLoInt8x64", + argLen: 2, + generic: true, + }, + { + name: "SetLoInt16x16", + argLen: 2, + generic: true, + }, + { + name: "SetLoInt16x32", + argLen: 2, + generic: true, + }, + { + name: "SetLoInt32x8", + argLen: 2, + generic: true, + }, + { + name: "SetLoInt32x16", + argLen: 2, + generic: true, + }, + { + name: "SetLoInt64x4", + argLen: 2, + generic: true, + }, + { + name: "SetLoInt64x8", + argLen: 2, + generic: true, + }, + { + name: "SetLoUint8x32", + argLen: 2, + generic: true, + }, + { + name: "SetLoUint8x64", + argLen: 2, + generic: true, + }, + { + name: "SetLoUint16x16", + argLen: 2, + generic: true, + }, + { + name: "SetLoUint16x32", + argLen: 2, + generic: true, + }, + { + name: "SetLoUint32x8", + argLen: 2, + generic: true, + }, + { + name: "SetLoUint32x16", + argLen: 2, + generic: true, + }, + { + name: "SetLoUint64x4", + argLen: 2, + generic: true, + }, + { + name: "SetLoUint64x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftInt16x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftInt16x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftInt16x32", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftInt32x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftInt32x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftInt32x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftInt64x2", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftInt64x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftInt64x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftUint16x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftUint16x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftUint16x32", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftUint32x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftUint32x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftUint32x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftUint64x2", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftUint64x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftUint64x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightInt16x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightInt16x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightInt16x32", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightInt32x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightInt32x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightInt32x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightInt64x2", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightInt64x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightInt64x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightUint16x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightUint16x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightUint16x32", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightUint32x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightUint32x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightUint32x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightUint64x2", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightUint64x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightUint64x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftConcatInt16x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatInt16x16", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatInt16x32", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatInt32x4", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatInt32x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatInt32x16", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatInt64x2", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatInt64x4", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatInt64x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatUint16x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatUint16x16", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatUint16x32", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatUint32x4", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatUint32x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatUint32x16", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatUint64x2", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatUint64x4", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftConcatUint64x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftLeftInt16x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftInt16x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftInt16x32", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftInt32x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftInt32x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftInt32x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftInt64x2", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftInt64x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftInt64x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftUint16x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftUint16x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftUint16x32", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftUint32x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftUint32x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftUint32x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftUint64x2", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftUint64x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftLeftUint64x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightConcatInt16x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatInt16x16", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatInt16x32", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatInt32x4", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatInt32x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatInt32x16", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatInt64x2", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatInt64x4", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatInt64x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatUint16x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatUint16x16", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatUint16x32", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatUint32x4", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatUint32x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatUint32x16", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatUint64x2", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatUint64x4", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightConcatUint64x8", + argLen: 3, + generic: true, + }, + { + name: "ShiftRightInt16x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightInt16x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightInt16x32", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightInt32x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightInt32x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightInt32x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightInt64x2", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightInt64x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightInt64x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightUint16x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightUint16x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightUint16x32", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightUint32x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightUint32x8", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightUint32x16", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightUint64x2", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightUint64x4", + argLen: 2, + generic: true, + }, + { + name: "ShiftRightUint64x8", + argLen: 2, + generic: true, + }, + { + name: "SqrtFloat32x4", + argLen: 1, + generic: true, + }, + { + name: "SqrtFloat32x8", + argLen: 1, + generic: true, + }, + { + name: "SqrtFloat32x16", + argLen: 1, + generic: true, + }, + { + name: "SqrtFloat64x2", + argLen: 1, + generic: true, + }, + { + name: "SqrtFloat64x4", + argLen: 1, + generic: true, + }, + { + name: "SqrtFloat64x8", + argLen: 1, + generic: true, + }, + { + name: "SubFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "SubFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "SubFloat32x16", + argLen: 2, + generic: true, + }, + { + name: "SubFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "SubFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "SubFloat64x8", + argLen: 2, + generic: true, + }, + { + name: "SubInt8x16", + argLen: 2, + generic: true, + }, + { + name: "SubInt8x32", + argLen: 2, + generic: true, + }, + { + name: "SubInt8x64", + argLen: 2, + generic: true, + }, + { + name: "SubInt16x8", + argLen: 2, + generic: true, + }, + { + name: "SubInt16x16", + argLen: 2, + generic: true, + }, + { + name: "SubInt16x32", + argLen: 2, + generic: true, + }, + { + name: "SubInt32x4", + argLen: 2, + generic: true, + }, + { + name: "SubInt32x8", + argLen: 2, + generic: true, + }, + { + name: "SubInt32x16", + argLen: 2, + generic: true, + }, + { + name: "SubInt64x2", + argLen: 2, + generic: true, + }, + { + name: "SubInt64x4", + argLen: 2, + generic: true, + }, + { + name: "SubInt64x8", + argLen: 2, + generic: true, + }, + { + name: "SubPairsFloat32x4", + argLen: 2, + generic: true, + }, + { + name: "SubPairsFloat64x2", + argLen: 2, + generic: true, + }, + { + name: "SubPairsGroupedFloat32x8", + argLen: 2, + generic: true, + }, + { + name: "SubPairsGroupedFloat64x4", + argLen: 2, + generic: true, + }, + { + name: "SubPairsGroupedInt16x16", + argLen: 2, + generic: true, + }, + { + name: "SubPairsGroupedInt32x8", + argLen: 2, + generic: true, + }, + { + name: "SubPairsGroupedUint16x16", + argLen: 2, + generic: true, + }, + { + name: "SubPairsGroupedUint32x8", + argLen: 2, + generic: true, + }, + { + name: "SubPairsInt16x8", + argLen: 2, + generic: true, + }, + { + name: "SubPairsInt32x4", + argLen: 2, + generic: true, + }, + { + name: "SubPairsSaturatedGroupedInt16x16", + argLen: 2, + generic: true, + }, + { + name: "SubPairsSaturatedInt16x8", + argLen: 2, + generic: true, + }, + { + name: "SubPairsUint16x8", + argLen: 2, + generic: true, + }, + { + name: "SubPairsUint32x4", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedInt8x16", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedInt8x32", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedInt8x64", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedInt16x8", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedInt16x16", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedInt16x32", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedUint8x16", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedUint8x32", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedUint8x64", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedUint16x8", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedUint16x16", + argLen: 2, + generic: true, + }, + { + name: "SubSaturatedUint16x32", + argLen: 2, + generic: true, + }, + { + name: "SubUint8x16", + argLen: 2, + generic: true, + }, + { + name: "SubUint8x32", + argLen: 2, + generic: true, + }, + { + name: "SubUint8x64", + argLen: 2, + generic: true, + }, + { + name: "SubUint16x8", + argLen: 2, + generic: true, + }, + { + name: "SubUint16x16", + argLen: 2, + generic: true, + }, + { + name: "SubUint16x32", + argLen: 2, + generic: true, + }, + { + name: "SubUint32x4", + argLen: 2, + generic: true, + }, + { + name: "SubUint32x8", + argLen: 2, + generic: true, + }, + { + name: "SubUint32x16", + argLen: 2, + generic: true, + }, + { + name: "SubUint64x2", + argLen: 2, + generic: true, + }, + { + name: "SubUint64x4", + argLen: 2, + generic: true, + }, + { + name: "SubUint64x8", + argLen: 2, + generic: true, + }, + { + name: "SumAbsDiffUint8x16", + argLen: 2, + generic: true, + }, + { + name: "SumAbsDiffUint8x32", + argLen: 2, + generic: true, + }, + { + name: "SumAbsDiffUint8x64", + argLen: 2, + generic: true, + }, + { + name: "TruncFloat32x4", + argLen: 1, + generic: true, + }, + { + name: "TruncFloat32x8", + argLen: 1, + generic: true, + }, + { + name: "TruncFloat64x2", + argLen: 1, + generic: true, + }, + { + name: "TruncFloat64x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt8Int16x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt8Int16x16", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt8Int16x32", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt8Int32x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt8Int32x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt8Int32x16", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt8Int64x2", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt8Int64x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt8Int64x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt16Int32x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt16Int32x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt16Int32x16", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt16Int64x2", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt16Int64x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt16Int64x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt32Int64x2", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt32Int64x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToInt32Int64x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint8Uint16x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint8Uint16x16", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint8Uint16x32", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint8Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint8Uint32x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint8Uint32x16", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint8Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint8Uint64x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint8Uint64x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint16Uint32x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint16Uint32x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint16Uint32x16", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint16Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint16Uint64x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint16Uint64x8", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint32Uint64x2", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint32Uint64x4", + argLen: 1, + generic: true, + }, + { + name: "TruncateToUint32Uint64x8", + argLen: 1, + generic: true, + }, + { + name: "XorInt8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorInt64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint8x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint8x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint8x64", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint16x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint16x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint16x32", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint32x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint32x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint32x16", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint64x2", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint64x4", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "XorUint64x8", + argLen: 2, + commutative: true, + generic: true, + }, + { + name: "blendInt8x16", + argLen: 3, + generic: true, + }, + { + name: "blendInt8x32", + argLen: 3, + generic: true, + }, + { + name: "blendMaskedInt8x64", + argLen: 3, + generic: true, + }, + { + name: "blendMaskedInt16x32", + argLen: 3, + generic: true, + }, + { + name: "blendMaskedInt32x16", + argLen: 3, + generic: true, + }, + { + name: "blendMaskedInt64x8", + argLen: 3, + generic: true, + }, + { + name: "AESRoundKeyGenAssistUint32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledFloat32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledFloat32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledFloat32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledFloat64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledFloat64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledFloat64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledResidueFloat32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledResidueFloat32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledResidueFloat32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledResidueFloat64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledResidueFloat64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "CeilScaledResidueFloat64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "ConcatShiftBytesRightGroupedUint8x32", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ConcatShiftBytesRightGroupedUint8x64", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ConcatShiftBytesRightUint8x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "FloorScaledFloat32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledFloat32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledFloat32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledFloat64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledFloat64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledFloat64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledResidueFloat32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledResidueFloat32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledResidueFloat32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledResidueFloat64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledResidueFloat64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "FloorScaledResidueFloat64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "GaloisFieldAffineTransformInverseUint8x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "GaloisFieldAffineTransformInverseUint8x32", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "GaloisFieldAffineTransformInverseUint8x64", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "GaloisFieldAffineTransformUint8x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "GaloisFieldAffineTransformUint8x32", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "GaloisFieldAffineTransformUint8x64", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "GetElemFloat32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "GetElemFloat64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "GetElemInt8x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "GetElemInt16x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "GetElemInt32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "GetElemInt64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "GetElemUint8x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "GetElemUint16x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "GetElemUint32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "GetElemUint64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftInt32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftInt32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftInt32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftInt64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftInt64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftInt64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftUint32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftUint32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftUint32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftUint64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftUint64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllLeftUint64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightInt32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightInt32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightInt32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightInt64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightInt64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightInt64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightUint32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightUint32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightUint32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightUint64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightUint64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RotateAllRightUint64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledFloat32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledFloat32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledFloat32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledFloat64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledFloat64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledFloat64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledResidueFloat32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledResidueFloat32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledResidueFloat32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledResidueFloat64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledResidueFloat64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "RoundToEvenScaledResidueFloat64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "SHA1FourRoundsUint32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "Select128FromPairFloat32x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "Select128FromPairFloat64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "Select128FromPairInt8x32", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "Select128FromPairInt16x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "Select128FromPairInt32x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "Select128FromPairInt64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "Select128FromPairUint8x32", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "Select128FromPairUint16x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "Select128FromPairUint32x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "Select128FromPairUint64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "SetElemFloat32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "SetElemFloat64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "SetElemInt8x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "SetElemInt16x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "SetElemInt32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "SetElemInt64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "SetElemUint8x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "SetElemUint16x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "SetElemUint32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "SetElemUint64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatInt16x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatInt16x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatInt16x32", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatInt32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatInt32x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatInt32x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatInt64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatInt64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatInt64x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatUint16x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatUint16x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatUint16x32", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatUint32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatUint32x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatUint32x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatUint64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatUint64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllLeftConcatUint64x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatInt16x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatInt16x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatInt16x32", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatInt32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatInt32x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatInt32x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatInt64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatInt64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatInt64x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatUint16x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatUint16x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatUint16x32", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatUint32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatUint32x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatUint32x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatUint64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatUint64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "ShiftAllRightConcatUint64x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "TruncScaledFloat32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledFloat32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledFloat32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledFloat64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledFloat64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledFloat64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledResidueFloat32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledResidueFloat32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledResidueFloat32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledResidueFloat64x2", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledResidueFloat64x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "TruncScaledResidueFloat64x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "carrylessMultiplyUint64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "carrylessMultiplyUint64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "carrylessMultiplyUint64x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantFloat32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantFloat64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedFloat32x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedFloat32x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedFloat64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedFloat64x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedInt32x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedInt32x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedInt64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedInt64x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedUint32x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedUint32x16", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedUint64x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantGroupedUint64x8", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantInt32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantInt64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantUint32x4", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "concatSelectedConstantUint64x2", + auxType: auxUInt8, + argLen: 2, + generic: true, + }, + { + name: "permuteScalarsGroupedInt32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsGroupedInt32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsGroupedUint32x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsGroupedUint32x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsHiGroupedInt16x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsHiGroupedInt16x32", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsHiGroupedUint16x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsHiGroupedUint16x32", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsHiInt16x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsHiUint16x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsInt32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsLoGroupedInt16x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsLoGroupedInt16x32", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsLoGroupedUint16x16", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsLoGroupedUint16x32", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsLoInt16x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsLoUint16x8", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "permuteScalarsUint32x4", + auxType: auxUInt8, + argLen: 1, + generic: true, + }, + { + name: "ternInt32x4", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternInt32x8", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternInt32x16", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternInt64x2", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternInt64x4", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternInt64x8", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternUint32x4", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternUint32x8", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternUint32x16", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternUint64x2", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternUint64x4", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, + { + name: "ternUint64x8", + auxType: auxUInt8, + argLen: 3, + generic: true, + }, +} + +func (o Op) Asm() obj.As { return opcodeTable[o].asm } +func (o Op) Scale() int16 { return int16(opcodeTable[o].scale) } +func (o Op) String() string { return opcodeTable[o].name } +func (o Op) SymEffect() SymEffect { return opcodeTable[o].symEffect } +func (o Op) IsCall() bool { return opcodeTable[o].call } +func (o Op) IsTailCall() bool { return opcodeTable[o].tailCall } +func (o Op) HasSideEffects() bool { return opcodeTable[o].hasSideEffects } +func (o Op) UnsafePoint() bool { return opcodeTable[o].unsafePoint } +func (o Op) ResultInArg0() bool { return opcodeTable[o].resultInArg0 } + +var registers386 = [...]Register{ + {0, x86.REG_AX, "AX"}, + {1, x86.REG_CX, "CX"}, + {2, x86.REG_DX, "DX"}, + {3, x86.REG_BX, "BX"}, + {4, x86.REGSP, "SP"}, + {5, x86.REG_BP, "BP"}, + {6, x86.REG_SI, "SI"}, + {7, x86.REG_DI, "DI"}, + {8, x86.REG_X0, "X0"}, + {9, x86.REG_X1, "X1"}, + {10, x86.REG_X2, "X2"}, + {11, x86.REG_X3, "X3"}, + {12, x86.REG_X4, "X4"}, + {13, x86.REG_X5, "X5"}, + {14, x86.REG_X6, "X6"}, + {15, x86.REG_X7, "X7"}, + {16, 0, "SB"}, +} +var paramIntReg386 = []int8(nil) +var paramFloatReg386 = []int8(nil) +var gpRegMask386 = regMask(239) +var fpRegMask386 = regMask(65280) +var specialRegMask386 = regMask(0) +var framepointerReg386 = int8(5) +var linkReg386 = int8(-1) +var registersAMD64 = [...]Register{ + {0, x86.REG_AX, "AX"}, + {1, x86.REG_CX, "CX"}, + {2, x86.REG_DX, "DX"}, + {3, x86.REG_BX, "BX"}, + {4, x86.REGSP, "SP"}, + {5, x86.REG_BP, "BP"}, + {6, x86.REG_SI, "SI"}, + {7, x86.REG_DI, "DI"}, + {8, x86.REG_R8, "R8"}, + {9, x86.REG_R9, "R9"}, + {10, x86.REG_R10, "R10"}, + {11, x86.REG_R11, "R11"}, + {12, x86.REG_R12, "R12"}, + {13, x86.REG_R13, "R13"}, + {14, x86.REGG, "g"}, + {15, x86.REG_R15, "R15"}, + {16, x86.REG_X0, "X0"}, + {17, x86.REG_X1, "X1"}, + {18, x86.REG_X2, "X2"}, + {19, x86.REG_X3, "X3"}, + {20, x86.REG_X4, "X4"}, + {21, x86.REG_X5, "X5"}, + {22, x86.REG_X6, "X6"}, + {23, x86.REG_X7, "X7"}, + {24, x86.REG_X8, "X8"}, + {25, x86.REG_X9, "X9"}, + {26, x86.REG_X10, "X10"}, + {27, x86.REG_X11, "X11"}, + {28, x86.REG_X12, "X12"}, + {29, x86.REG_X13, "X13"}, + {30, x86.REG_X14, "X14"}, + {31, x86.REG_X15, "X15"}, + {32, x86.REG_X16, "X16"}, + {33, x86.REG_X17, "X17"}, + {34, x86.REG_X18, "X18"}, + {35, x86.REG_X19, "X19"}, + {36, x86.REG_X20, "X20"}, + {37, x86.REG_X21, "X21"}, + {38, x86.REG_X22, "X22"}, + {39, x86.REG_X23, "X23"}, + {40, x86.REG_X24, "X24"}, + {41, x86.REG_X25, "X25"}, + {42, x86.REG_X26, "X26"}, + {43, x86.REG_X27, "X27"}, + {44, x86.REG_X28, "X28"}, + {45, x86.REG_X29, "X29"}, + {46, x86.REG_X30, "X30"}, + {47, x86.REG_X31, "X31"}, + {48, x86.REG_K0, "K0"}, + {49, x86.REG_K1, "K1"}, + {50, x86.REG_K2, "K2"}, + {51, x86.REG_K3, "K3"}, + {52, x86.REG_K4, "K4"}, + {53, x86.REG_K5, "K5"}, + {54, x86.REG_K6, "K6"}, + {55, x86.REG_K7, "K7"}, + {56, 0, "SB"}, +} +var paramIntRegAMD64 = []int8{0, 3, 1, 7, 6, 8, 9, 10, 11} +var paramFloatRegAMD64 = []int8{16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30} +var gpRegMaskAMD64 = regMask(49135) +var fpRegMaskAMD64 = regMask(2147418112) +var specialRegMaskAMD64 = regMask(71494644084506624) +var framepointerRegAMD64 = int8(5) +var linkRegAMD64 = int8(-1) +var registersARM = [...]Register{ + {0, arm.REG_R0, "R0"}, + {1, arm.REG_R1, "R1"}, + {2, arm.REG_R2, "R2"}, + {3, arm.REG_R3, "R3"}, + {4, arm.REG_R4, "R4"}, + {5, arm.REG_R5, "R5"}, + {6, arm.REG_R6, "R6"}, + {7, arm.REG_R7, "R7"}, + {8, arm.REG_R8, "R8"}, + {9, arm.REG_R9, "R9"}, + {10, arm.REGG, "g"}, + {11, arm.REG_R11, "R11"}, + {12, arm.REG_R12, "R12"}, + {13, arm.REGSP, "SP"}, + {14, arm.REG_R14, "R14"}, + {15, arm.REG_R15, "R15"}, + {16, arm.REG_F0, "F0"}, + {17, arm.REG_F1, "F1"}, + {18, arm.REG_F2, "F2"}, + {19, arm.REG_F3, "F3"}, + {20, arm.REG_F4, "F4"}, + {21, arm.REG_F5, "F5"}, + {22, arm.REG_F6, "F6"}, + {23, arm.REG_F7, "F7"}, + {24, arm.REG_F8, "F8"}, + {25, arm.REG_F9, "F9"}, + {26, arm.REG_F10, "F10"}, + {27, arm.REG_F11, "F11"}, + {28, arm.REG_F12, "F12"}, + {29, arm.REG_F13, "F13"}, + {30, arm.REG_F14, "F14"}, + {31, arm.REG_F15, "F15"}, + {32, 0, "SB"}, +} +var paramIntRegARM = []int8(nil) +var paramFloatRegARM = []int8(nil) +var gpRegMaskARM = regMask(21503) +var fpRegMaskARM = regMask(4294901760) +var specialRegMaskARM = regMask(0) +var framepointerRegARM = int8(-1) +var linkRegARM = int8(14) +var registersARM64 = [...]Register{ + {0, arm64.REG_R0, "R0"}, + {1, arm64.REG_R1, "R1"}, + {2, arm64.REG_R2, "R2"}, + {3, arm64.REG_R3, "R3"}, + {4, arm64.REG_R4, "R4"}, + {5, arm64.REG_R5, "R5"}, + {6, arm64.REG_R6, "R6"}, + {7, arm64.REG_R7, "R7"}, + {8, arm64.REG_R8, "R8"}, + {9, arm64.REG_R9, "R9"}, + {10, arm64.REG_R10, "R10"}, + {11, arm64.REG_R11, "R11"}, + {12, arm64.REG_R12, "R12"}, + {13, arm64.REG_R13, "R13"}, + {14, arm64.REG_R14, "R14"}, + {15, arm64.REG_R15, "R15"}, + {16, arm64.REG_R16, "R16"}, + {17, arm64.REG_R17, "R17"}, + {18, arm64.REG_R19, "R19"}, + {19, arm64.REG_R20, "R20"}, + {20, arm64.REG_R21, "R21"}, + {21, arm64.REG_R22, "R22"}, + {22, arm64.REG_R23, "R23"}, + {23, arm64.REG_R24, "R24"}, + {24, arm64.REG_R25, "R25"}, + {25, arm64.REG_R26, "R26"}, + {26, arm64.REGG, "g"}, + {27, arm64.REG_R29, "R29"}, + {28, arm64.REG_R30, "R30"}, + {29, arm64.REGZERO, "ZERO"}, + {30, arm64.REGSP, "SP"}, + {31, arm64.REG_F0, "F0"}, + {32, arm64.REG_F1, "F1"}, + {33, arm64.REG_F2, "F2"}, + {34, arm64.REG_F3, "F3"}, + {35, arm64.REG_F4, "F4"}, + {36, arm64.REG_F5, "F5"}, + {37, arm64.REG_F6, "F6"}, + {38, arm64.REG_F7, "F7"}, + {39, arm64.REG_F8, "F8"}, + {40, arm64.REG_F9, "F9"}, + {41, arm64.REG_F10, "F10"}, + {42, arm64.REG_F11, "F11"}, + {43, arm64.REG_F12, "F12"}, + {44, arm64.REG_F13, "F13"}, + {45, arm64.REG_F14, "F14"}, + {46, arm64.REG_F15, "F15"}, + {47, arm64.REG_F16, "F16"}, + {48, arm64.REG_F17, "F17"}, + {49, arm64.REG_F18, "F18"}, + {50, arm64.REG_F19, "F19"}, + {51, arm64.REG_F20, "F20"}, + {52, arm64.REG_F21, "F21"}, + {53, arm64.REG_F22, "F22"}, + {54, arm64.REG_F23, "F23"}, + {55, arm64.REG_F24, "F24"}, + {56, arm64.REG_F25, "F25"}, + {57, arm64.REG_F26, "F26"}, + {58, arm64.REG_F27, "F27"}, + {59, arm64.REG_F28, "F28"}, + {60, arm64.REG_F29, "F29"}, + {61, arm64.REG_F30, "F30"}, + {62, arm64.REG_F31, "F31"}, + {63, 0, "SB"}, +} +var paramIntRegARM64 = []int8{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} +var paramFloatRegARM64 = []int8{31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46} +var gpRegMaskARM64 = regMask(335544319) +var fpRegMaskARM64 = regMask(9223372034707292160) +var specialRegMaskARM64 = regMask(0) +var framepointerRegARM64 = int8(-1) +var linkRegARM64 = int8(28) +var registersLOONG64 = [...]Register{ + {0, loong64.REGZERO, "ZERO"}, + {1, loong64.REG_R1, "R1"}, + {2, loong64.REGSP, "SP"}, + {3, loong64.REG_R4, "R4"}, + {4, loong64.REG_R5, "R5"}, + {5, loong64.REG_R6, "R6"}, + {6, loong64.REG_R7, "R7"}, + {7, loong64.REG_R8, "R8"}, + {8, loong64.REG_R9, "R9"}, + {9, loong64.REG_R10, "R10"}, + {10, loong64.REG_R11, "R11"}, + {11, loong64.REG_R12, "R12"}, + {12, loong64.REG_R13, "R13"}, + {13, loong64.REG_R14, "R14"}, + {14, loong64.REG_R15, "R15"}, + {15, loong64.REG_R16, "R16"}, + {16, loong64.REG_R17, "R17"}, + {17, loong64.REG_R18, "R18"}, + {18, loong64.REG_R19, "R19"}, + {19, loong64.REG_R20, "R20"}, + {20, loong64.REG_R21, "R21"}, + {21, loong64.REGG, "g"}, + {22, loong64.REG_R23, "R23"}, + {23, loong64.REG_R24, "R24"}, + {24, loong64.REG_R25, "R25"}, + {25, loong64.REG_R26, "R26"}, + {26, loong64.REG_R27, "R27"}, + {27, loong64.REG_R28, "R28"}, + {28, loong64.REG_R29, "R29"}, + {29, loong64.REG_R31, "R31"}, + {30, loong64.REG_F0, "F0"}, + {31, loong64.REG_F1, "F1"}, + {32, loong64.REG_F2, "F2"}, + {33, loong64.REG_F3, "F3"}, + {34, loong64.REG_F4, "F4"}, + {35, loong64.REG_F5, "F5"}, + {36, loong64.REG_F6, "F6"}, + {37, loong64.REG_F7, "F7"}, + {38, loong64.REG_F8, "F8"}, + {39, loong64.REG_F9, "F9"}, + {40, loong64.REG_F10, "F10"}, + {41, loong64.REG_F11, "F11"}, + {42, loong64.REG_F12, "F12"}, + {43, loong64.REG_F13, "F13"}, + {44, loong64.REG_F14, "F14"}, + {45, loong64.REG_F15, "F15"}, + {46, loong64.REG_F16, "F16"}, + {47, loong64.REG_F17, "F17"}, + {48, loong64.REG_F18, "F18"}, + {49, loong64.REG_F19, "F19"}, + {50, loong64.REG_F20, "F20"}, + {51, loong64.REG_F21, "F21"}, + {52, loong64.REG_F22, "F22"}, + {53, loong64.REG_F23, "F23"}, + {54, loong64.REG_F24, "F24"}, + {55, loong64.REG_F25, "F25"}, + {56, loong64.REG_F26, "F26"}, + {57, loong64.REG_F27, "F27"}, + {58, loong64.REG_F28, "F28"}, + {59, loong64.REG_F29, "F29"}, + {60, loong64.REG_F30, "F30"}, + {61, loong64.REG_F31, "F31"}, + {62, 0, "SB"}, +} +var paramIntRegLOONG64 = []int8{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18} +var paramFloatRegLOONG64 = []int8{30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45} +var gpRegMaskLOONG64 = regMask(1071644664) +var fpRegMaskLOONG64 = regMask(4611686017353646080) +var specialRegMaskLOONG64 = regMask(0) +var framepointerRegLOONG64 = int8(-1) +var linkRegLOONG64 = int8(1) +var registersMIPS = [...]Register{ + {0, mips.REG_R0, "R0"}, + {1, mips.REG_R1, "R1"}, + {2, mips.REG_R2, "R2"}, + {3, mips.REG_R3, "R3"}, + {4, mips.REG_R4, "R4"}, + {5, mips.REG_R5, "R5"}, + {6, mips.REG_R6, "R6"}, + {7, mips.REG_R7, "R7"}, + {8, mips.REG_R8, "R8"}, + {9, mips.REG_R9, "R9"}, + {10, mips.REG_R10, "R10"}, + {11, mips.REG_R11, "R11"}, + {12, mips.REG_R12, "R12"}, + {13, mips.REG_R13, "R13"}, + {14, mips.REG_R14, "R14"}, + {15, mips.REG_R15, "R15"}, + {16, mips.REG_R16, "R16"}, + {17, mips.REG_R17, "R17"}, + {18, mips.REG_R18, "R18"}, + {19, mips.REG_R19, "R19"}, + {20, mips.REG_R20, "R20"}, + {21, mips.REG_R21, "R21"}, + {22, mips.REG_R22, "R22"}, + {23, mips.REG_R24, "R24"}, + {24, mips.REG_R25, "R25"}, + {25, mips.REG_R28, "R28"}, + {26, mips.REGSP, "SP"}, + {27, mips.REGG, "g"}, + {28, mips.REG_R31, "R31"}, + {29, mips.REG_F0, "F0"}, + {30, mips.REG_F2, "F2"}, + {31, mips.REG_F4, "F4"}, + {32, mips.REG_F6, "F6"}, + {33, mips.REG_F8, "F8"}, + {34, mips.REG_F10, "F10"}, + {35, mips.REG_F12, "F12"}, + {36, mips.REG_F14, "F14"}, + {37, mips.REG_F16, "F16"}, + {38, mips.REG_F18, "F18"}, + {39, mips.REG_F20, "F20"}, + {40, mips.REG_F22, "F22"}, + {41, mips.REG_F24, "F24"}, + {42, mips.REG_F26, "F26"}, + {43, mips.REG_F28, "F28"}, + {44, mips.REG_F30, "F30"}, + {45, mips.REG_HI, "HI"}, + {46, mips.REG_LO, "LO"}, + {47, 0, "SB"}, +} +var paramIntRegMIPS = []int8(nil) +var paramFloatRegMIPS = []int8(nil) +var gpRegMaskMIPS = regMask(335544318) +var fpRegMaskMIPS = regMask(35183835217920) +var specialRegMaskMIPS = regMask(105553116266496) +var framepointerRegMIPS = int8(-1) +var linkRegMIPS = int8(28) +var registersMIPS64 = [...]Register{ + {0, mips.REGZERO, "ZERO"}, + {1, mips.REG_R1, "R1"}, + {2, mips.REG_R2, "R2"}, + {3, mips.REG_R3, "R3"}, + {4, mips.REG_R4, "R4"}, + {5, mips.REG_R5, "R5"}, + {6, mips.REG_R6, "R6"}, + {7, mips.REG_R7, "R7"}, + {8, mips.REG_R8, "R8"}, + {9, mips.REG_R9, "R9"}, + {10, mips.REG_R10, "R10"}, + {11, mips.REG_R11, "R11"}, + {12, mips.REG_R12, "R12"}, + {13, mips.REG_R13, "R13"}, + {14, mips.REG_R14, "R14"}, + {15, mips.REG_R15, "R15"}, + {16, mips.REG_R16, "R16"}, + {17, mips.REG_R17, "R17"}, + {18, mips.REG_R18, "R18"}, + {19, mips.REG_R19, "R19"}, + {20, mips.REG_R20, "R20"}, + {21, mips.REG_R21, "R21"}, + {22, mips.REG_R22, "R22"}, + {23, mips.REG_R24, "R24"}, + {24, mips.REG_R25, "R25"}, + {25, mips.REGSP, "SP"}, + {26, mips.REGG, "g"}, + {27, mips.REG_R31, "R31"}, + {28, mips.REG_F0, "F0"}, + {29, mips.REG_F1, "F1"}, + {30, mips.REG_F2, "F2"}, + {31, mips.REG_F3, "F3"}, + {32, mips.REG_F4, "F4"}, + {33, mips.REG_F5, "F5"}, + {34, mips.REG_F6, "F6"}, + {35, mips.REG_F7, "F7"}, + {36, mips.REG_F8, "F8"}, + {37, mips.REG_F9, "F9"}, + {38, mips.REG_F10, "F10"}, + {39, mips.REG_F11, "F11"}, + {40, mips.REG_F12, "F12"}, + {41, mips.REG_F13, "F13"}, + {42, mips.REG_F14, "F14"}, + {43, mips.REG_F15, "F15"}, + {44, mips.REG_F16, "F16"}, + {45, mips.REG_F17, "F17"}, + {46, mips.REG_F18, "F18"}, + {47, mips.REG_F19, "F19"}, + {48, mips.REG_F20, "F20"}, + {49, mips.REG_F21, "F21"}, + {50, mips.REG_F22, "F22"}, + {51, mips.REG_F23, "F23"}, + {52, mips.REG_F24, "F24"}, + {53, mips.REG_F25, "F25"}, + {54, mips.REG_F26, "F26"}, + {55, mips.REG_F27, "F27"}, + {56, mips.REG_F28, "F28"}, + {57, mips.REG_F29, "F29"}, + {58, mips.REG_F30, "F30"}, + {59, mips.REG_F31, "F31"}, + {60, mips.REG_HI, "HI"}, + {61, mips.REG_LO, "LO"}, + {62, 0, "SB"}, +} +var paramIntRegMIPS64 = []int8(nil) +var paramFloatRegMIPS64 = []int8(nil) +var gpRegMaskMIPS64 = regMask(167772158) +var fpRegMaskMIPS64 = regMask(1152921504338411520) +var specialRegMaskMIPS64 = regMask(3458764513820540928) +var framepointerRegMIPS64 = int8(-1) +var linkRegMIPS64 = int8(27) +var registersPPC64 = [...]Register{ + {0, ppc64.REG_R0, "R0"}, + {1, ppc64.REGSP, "SP"}, + {2, 0, "SB"}, + {3, ppc64.REG_R3, "R3"}, + {4, ppc64.REG_R4, "R4"}, + {5, ppc64.REG_R5, "R5"}, + {6, ppc64.REG_R6, "R6"}, + {7, ppc64.REG_R7, "R7"}, + {8, ppc64.REG_R8, "R8"}, + {9, ppc64.REG_R9, "R9"}, + {10, ppc64.REG_R10, "R10"}, + {11, ppc64.REG_R11, "R11"}, + {12, ppc64.REG_R12, "R12"}, + {13, ppc64.REG_R13, "R13"}, + {14, ppc64.REG_R14, "R14"}, + {15, ppc64.REG_R15, "R15"}, + {16, ppc64.REG_R16, "R16"}, + {17, ppc64.REG_R17, "R17"}, + {18, ppc64.REG_R18, "R18"}, + {19, ppc64.REG_R19, "R19"}, + {20, ppc64.REG_R20, "R20"}, + {21, ppc64.REG_R21, "R21"}, + {22, ppc64.REG_R22, "R22"}, + {23, ppc64.REG_R23, "R23"}, + {24, ppc64.REG_R24, "R24"}, + {25, ppc64.REG_R25, "R25"}, + {26, ppc64.REG_R26, "R26"}, + {27, ppc64.REG_R27, "R27"}, + {28, ppc64.REG_R28, "R28"}, + {29, ppc64.REG_R29, "R29"}, + {30, ppc64.REGG, "g"}, + {31, ppc64.REG_R31, "R31"}, + {32, ppc64.REG_F0, "F0"}, + {33, ppc64.REG_F1, "F1"}, + {34, ppc64.REG_F2, "F2"}, + {35, ppc64.REG_F3, "F3"}, + {36, ppc64.REG_F4, "F4"}, + {37, ppc64.REG_F5, "F5"}, + {38, ppc64.REG_F6, "F6"}, + {39, ppc64.REG_F7, "F7"}, + {40, ppc64.REG_F8, "F8"}, + {41, ppc64.REG_F9, "F9"}, + {42, ppc64.REG_F10, "F10"}, + {43, ppc64.REG_F11, "F11"}, + {44, ppc64.REG_F12, "F12"}, + {45, ppc64.REG_F13, "F13"}, + {46, ppc64.REG_F14, "F14"}, + {47, ppc64.REG_F15, "F15"}, + {48, ppc64.REG_F16, "F16"}, + {49, ppc64.REG_F17, "F17"}, + {50, ppc64.REG_F18, "F18"}, + {51, ppc64.REG_F19, "F19"}, + {52, ppc64.REG_F20, "F20"}, + {53, ppc64.REG_F21, "F21"}, + {54, ppc64.REG_F22, "F22"}, + {55, ppc64.REG_F23, "F23"}, + {56, ppc64.REG_F24, "F24"}, + {57, ppc64.REG_F25, "F25"}, + {58, ppc64.REG_F26, "F26"}, + {59, ppc64.REG_F27, "F27"}, + {60, ppc64.REG_F28, "F28"}, + {61, ppc64.REG_F29, "F29"}, + {62, ppc64.REG_F30, "F30"}, + {63, ppc64.REG_XER, "XER"}, +} +var paramIntRegPPC64 = []int8{3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16, 17} +var paramFloatRegPPC64 = []int8{33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44} +var gpRegMaskPPC64 = regMask(1073733624) +var fpRegMaskPPC64 = regMask(9223372032559808512) +var specialRegMaskPPC64 = regMask(9223372036854775808) +var framepointerRegPPC64 = int8(-1) +var linkRegPPC64 = int8(-1) +var registersRISCV64 = [...]Register{ + {0, riscv.REG_X0, "X0"}, + {1, riscv.REGSP, "SP"}, + {2, riscv.REG_X3, "X3"}, + {3, riscv.REG_X4, "X4"}, + {4, riscv.REG_X5, "X5"}, + {5, riscv.REG_X6, "X6"}, + {6, riscv.REG_X7, "X7"}, + {7, riscv.REG_X8, "X8"}, + {8, riscv.REG_X9, "X9"}, + {9, riscv.REG_X10, "X10"}, + {10, riscv.REG_X11, "X11"}, + {11, riscv.REG_X12, "X12"}, + {12, riscv.REG_X13, "X13"}, + {13, riscv.REG_X14, "X14"}, + {14, riscv.REG_X15, "X15"}, + {15, riscv.REG_X16, "X16"}, + {16, riscv.REG_X17, "X17"}, + {17, riscv.REG_X18, "X18"}, + {18, riscv.REG_X19, "X19"}, + {19, riscv.REG_X20, "X20"}, + {20, riscv.REG_X21, "X21"}, + {21, riscv.REG_X22, "X22"}, + {22, riscv.REG_X23, "X23"}, + {23, riscv.REG_X24, "X24"}, + {24, riscv.REG_X25, "X25"}, + {25, riscv.REG_X26, "X26"}, + {26, riscv.REGG, "g"}, + {27, riscv.REG_X28, "X28"}, + {28, riscv.REG_X29, "X29"}, + {29, riscv.REG_X30, "X30"}, + {30, riscv.REG_X31, "X31"}, + {31, riscv.REG_F0, "F0"}, + {32, riscv.REG_F1, "F1"}, + {33, riscv.REG_F2, "F2"}, + {34, riscv.REG_F3, "F3"}, + {35, riscv.REG_F4, "F4"}, + {36, riscv.REG_F5, "F5"}, + {37, riscv.REG_F6, "F6"}, + {38, riscv.REG_F7, "F7"}, + {39, riscv.REG_F8, "F8"}, + {40, riscv.REG_F9, "F9"}, + {41, riscv.REG_F10, "F10"}, + {42, riscv.REG_F11, "F11"}, + {43, riscv.REG_F12, "F12"}, + {44, riscv.REG_F13, "F13"}, + {45, riscv.REG_F14, "F14"}, + {46, riscv.REG_F15, "F15"}, + {47, riscv.REG_F16, "F16"}, + {48, riscv.REG_F17, "F17"}, + {49, riscv.REG_F18, "F18"}, + {50, riscv.REG_F19, "F19"}, + {51, riscv.REG_F20, "F20"}, + {52, riscv.REG_F21, "F21"}, + {53, riscv.REG_F22, "F22"}, + {54, riscv.REG_F23, "F23"}, + {55, riscv.REG_F24, "F24"}, + {56, riscv.REG_F25, "F25"}, + {57, riscv.REG_F26, "F26"}, + {58, riscv.REG_F27, "F27"}, + {59, riscv.REG_F28, "F28"}, + {60, riscv.REG_F29, "F29"}, + {61, riscv.REG_F30, "F30"}, + {62, riscv.REG_F31, "F31"}, + {63, 0, "SB"}, +} +var paramIntRegRISCV64 = []int8{9, 10, 11, 12, 13, 14, 15, 16, 7, 8, 17, 18, 19, 20, 21, 22} +var paramFloatRegRISCV64 = []int8{41, 42, 43, 44, 45, 46, 47, 48, 39, 40, 49, 50, 51, 52, 53, 54} +var gpRegMaskRISCV64 = regMask(1006632944) +var fpRegMaskRISCV64 = regMask(9223372034707292160) +var specialRegMaskRISCV64 = regMask(0) +var framepointerRegRISCV64 = int8(-1) +var linkRegRISCV64 = int8(0) +var registersS390X = [...]Register{ + {0, s390x.REG_R0, "R0"}, + {1, s390x.REG_R1, "R1"}, + {2, s390x.REG_R2, "R2"}, + {3, s390x.REG_R3, "R3"}, + {4, s390x.REG_R4, "R4"}, + {5, s390x.REG_R5, "R5"}, + {6, s390x.REG_R6, "R6"}, + {7, s390x.REG_R7, "R7"}, + {8, s390x.REG_R8, "R8"}, + {9, s390x.REG_R9, "R9"}, + {10, s390x.REG_R10, "R10"}, + {11, s390x.REG_R11, "R11"}, + {12, s390x.REG_R12, "R12"}, + {13, s390x.REGG, "g"}, + {14, s390x.REG_R14, "R14"}, + {15, s390x.REGSP, "SP"}, + {16, s390x.REG_F0, "F0"}, + {17, s390x.REG_F1, "F1"}, + {18, s390x.REG_F2, "F2"}, + {19, s390x.REG_F3, "F3"}, + {20, s390x.REG_F4, "F4"}, + {21, s390x.REG_F5, "F5"}, + {22, s390x.REG_F6, "F6"}, + {23, s390x.REG_F7, "F7"}, + {24, s390x.REG_F8, "F8"}, + {25, s390x.REG_F9, "F9"}, + {26, s390x.REG_F10, "F10"}, + {27, s390x.REG_F11, "F11"}, + {28, s390x.REG_F12, "F12"}, + {29, s390x.REG_F13, "F13"}, + {30, s390x.REG_F14, "F14"}, + {31, s390x.REG_F15, "F15"}, + {32, 0, "SB"}, +} +var paramIntRegS390X = []int8{2, 3, 4, 5, 6, 7, 8, 9} +var paramFloatRegS390X = []int8{16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31} +var gpRegMaskS390X = regMask(23551) +var fpRegMaskS390X = regMask(4294901760) +var specialRegMaskS390X = regMask(0) +var framepointerRegS390X = int8(-1) +var linkRegS390X = int8(14) +var registersWasm = [...]Register{ + {0, wasm.REG_R0, "R0"}, + {1, wasm.REG_R1, "R1"}, + {2, wasm.REG_R2, "R2"}, + {3, wasm.REG_R3, "R3"}, + {4, wasm.REG_R4, "R4"}, + {5, wasm.REG_R5, "R5"}, + {6, wasm.REG_R6, "R6"}, + {7, wasm.REG_R7, "R7"}, + {8, wasm.REG_R8, "R8"}, + {9, wasm.REG_R9, "R9"}, + {10, wasm.REG_R10, "R10"}, + {11, wasm.REG_R11, "R11"}, + {12, wasm.REG_R12, "R12"}, + {13, wasm.REG_R13, "R13"}, + {14, wasm.REG_R14, "R14"}, + {15, wasm.REG_R15, "R15"}, + {16, wasm.REG_F0, "F0"}, + {17, wasm.REG_F1, "F1"}, + {18, wasm.REG_F2, "F2"}, + {19, wasm.REG_F3, "F3"}, + {20, wasm.REG_F4, "F4"}, + {21, wasm.REG_F5, "F5"}, + {22, wasm.REG_F6, "F6"}, + {23, wasm.REG_F7, "F7"}, + {24, wasm.REG_F8, "F8"}, + {25, wasm.REG_F9, "F9"}, + {26, wasm.REG_F10, "F10"}, + {27, wasm.REG_F11, "F11"}, + {28, wasm.REG_F12, "F12"}, + {29, wasm.REG_F13, "F13"}, + {30, wasm.REG_F14, "F14"}, + {31, wasm.REG_F15, "F15"}, + {32, wasm.REG_F16, "F16"}, + {33, wasm.REG_F17, "F17"}, + {34, wasm.REG_F18, "F18"}, + {35, wasm.REG_F19, "F19"}, + {36, wasm.REG_F20, "F20"}, + {37, wasm.REG_F21, "F21"}, + {38, wasm.REG_F22, "F22"}, + {39, wasm.REG_F23, "F23"}, + {40, wasm.REG_F24, "F24"}, + {41, wasm.REG_F25, "F25"}, + {42, wasm.REG_F26, "F26"}, + {43, wasm.REG_F27, "F27"}, + {44, wasm.REG_F28, "F28"}, + {45, wasm.REG_F29, "F29"}, + {46, wasm.REG_F30, "F30"}, + {47, wasm.REG_F31, "F31"}, + {48, wasm.REGSP, "SP"}, + {49, wasm.REGG, "g"}, + {50, 0, "SB"}, +} +var paramIntRegWasm = []int8(nil) +var paramFloatRegWasm = []int8(nil) +var gpRegMaskWasm = regMask(65535) +var fpRegMaskWasm = regMask(281474976645120) +var fp32RegMaskWasm = regMask(4294901760) +var fp64RegMaskWasm = regMask(281470681743360) +var specialRegMaskWasm = regMask(0) +var framepointerRegWasm = int8(-1) +var linkRegWasm = int8(-1) diff --git a/go/src/cmd/compile/internal/ssa/opt.go b/go/src/cmd/compile/internal/ssa/opt.go new file mode 100644 index 0000000000000000000000000000000000000000..9f155e6179b7e6b5f9465e3f9da08cfdafe24591 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/opt.go @@ -0,0 +1,18 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// machine-independent optimization. +func opt(f *Func) { + applyRewrite(f, rewriteBlockgeneric, rewriteValuegeneric, removeDeadValues) +} + +func divisible(f *Func) { + applyRewrite(f, rewriteBlockdivisible, rewriteValuedivisible, removeDeadValues) +} + +func divmod(f *Func) { + applyRewrite(f, rewriteBlockdivmod, rewriteValuedivmod, removeDeadValues) +} diff --git a/go/src/cmd/compile/internal/ssa/pair.go b/go/src/cmd/compile/internal/ssa/pair.go new file mode 100644 index 0000000000000000000000000000000000000000..83d7e476dd9c20712568715f1b8297a040881602 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/pair.go @@ -0,0 +1,359 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "slices" +) + +// The pair pass finds memory operations that can be paired up +// into single 2-register memory instructions. +func pair(f *Func) { + // Only arm64 for now. This pass is fairly arch-specific. + switch f.Config.arch { + case "arm64": + default: + return + } + pairLoads(f) + pairStores(f) +} + +type pairableLoadInfo struct { + width int64 // width of one element in the pair, in bytes + pair Op +} + +// All pairableLoad ops must take 2 arguments, a pointer and a memory. +// They must also take an offset in Aux/AuxInt. +var pairableLoads = map[Op]pairableLoadInfo{ + OpARM64MOVDload: {8, OpARM64LDP}, + OpARM64MOVWUload: {4, OpARM64LDPW}, + OpARM64MOVWload: {4, OpARM64LDPSW}, + // TODO: conceivably we could pair a signed and unsigned load + // if we knew the upper bits of one of them weren't being used. + OpARM64FMOVDload: {8, OpARM64FLDPD}, + OpARM64FMOVSload: {4, OpARM64FLDPS}, +} + +type pairableStoreInfo struct { + width int64 // width of one element in the pair, in bytes + pair Op +} + +// All pairableStore keys must take 3 arguments, a pointer, a value, and a memory. +// All pairableStore values must take 4 arguments, a pointer, 2 values, and a memory. +// They must also take an offset in Aux/AuxInt. +var pairableStores = map[Op]pairableStoreInfo{ + OpARM64MOVDstore: {8, OpARM64STP}, + OpARM64MOVWstore: {4, OpARM64STPW}, + OpARM64FMOVDstore: {8, OpARM64FSTPD}, + OpARM64FMOVSstore: {4, OpARM64FSTPS}, +} + +// offsetOk returns true if a pair instruction should be used +// for the offset Aux+off, when the data width (of the +// unpaired instructions) is width. +// This function is best-effort. The compiled function must +// still work if offsetOk always returns true. +// TODO: this is currently arm64-specific. +func offsetOk(aux Aux, off, width int64) bool { + if true { + // Seems to generate slightly smaller code if we just + // always allow this rewrite. + // + // Without pairing, we have 2 load instructions, like: + // LDR 88(R0), R1 + // LDR 96(R0), R2 + // with pairing we have, best case: + // LDP 88(R0), R1, R2 + // but maybe we need an adjuster if out of range or unaligned: + // ADD R0, $88, R27 + // LDP (R27), R1, R2 + // Even with the adjuster, it is at least no worse. + // + // A similar situation occurs when accessing globals. + // Two loads from globals requires 4 instructions, + // two ADRP and two LDR. With pairing, we need + // ADRP+ADD+LDP, three instructions. + // + // With pairing, it looks like the critical path might + // be a little bit longer. But it should never be more + // instructions. + // TODO: see if that longer critical path causes any + // regressions. + return true + } + if aux != nil { + if _, ok := aux.(*ir.Name); !ok { + // Offset is probably too big (globals). + return false + } + // We let *ir.Names pass here, as + // they are probably small offsets from SP. + // There's no guarantee that we're in range + // in that case though (we don't know the + // stack frame size yet), so the assembler + // might need to issue fixup instructions. + // Assume some small frame size. + if off >= 0 { + off += 120 + } + // TODO: figure out how often this helps vs. hurts. + } + switch width { + case 4: + if off >= -256 && off <= 252 && off%4 == 0 { + return true + } + case 8: + if off >= -512 && off <= 504 && off%8 == 0 { + return true + } + } + return false +} + +func pairLoads(f *Func) { + var loads []*Value + + // Registry of aux values for sorting. + auxIDs := map[Aux]int{} + auxID := func(aux Aux) int { + id, ok := auxIDs[aux] + if !ok { + id = len(auxIDs) + auxIDs[aux] = id + } + return id + } + + for _, b := range f.Blocks { + // Find loads. + loads = loads[:0] + clear(auxIDs) + for _, v := range b.Values { + info := pairableLoads[v.Op] + if info.width == 0 { + continue // not pairable + } + if !offsetOk(v.Aux, v.AuxInt, info.width) { + continue // not advisable + } + loads = append(loads, v) + } + if len(loads) < 2 { + continue + } + + // Sort to put pairable loads together. + slices.SortFunc(loads, func(x, y *Value) int { + // First sort by op, ptr, and memory arg. + if x.Op != y.Op { + return int(x.Op - y.Op) + } + if x.Args[0].ID != y.Args[0].ID { + return int(x.Args[0].ID - y.Args[0].ID) + } + if x.Args[1].ID != y.Args[1].ID { + return int(x.Args[1].ID - y.Args[1].ID) + } + // Then sort by aux. (nil first, then by aux ID) + if x.Aux != nil { + if y.Aux == nil { + return 1 + } + a, b := auxID(x.Aux), auxID(y.Aux) + if a != b { + return a - b + } + } else if y.Aux != nil { + return -1 + } + // Then sort by offset, low to high. + return int(x.AuxInt - y.AuxInt) + }) + + // Look for pairable loads. + for i := 0; i < len(loads)-1; i++ { + x := loads[i] + y := loads[i+1] + if x.Op != y.Op || x.Args[0] != y.Args[0] || x.Args[1] != y.Args[1] { + continue + } + if x.Aux != y.Aux { + continue + } + if x.AuxInt+pairableLoads[x.Op].width != y.AuxInt { + continue + } + + // Commit point. + + // Make the 2-register load. + load := b.NewValue2IA(x.Pos, pairableLoads[x.Op].pair, types.NewTuple(x.Type, y.Type), x.AuxInt, x.Aux, x.Args[0], x.Args[1]) + + // Modify x to be (Select0 load). Similar for y. + x.reset(OpSelect0) + x.SetArgs1(load) + y.reset(OpSelect1) + y.SetArgs1(load) + + i++ // Skip y next time around the loop. + } + } +} + +func pairStores(f *Func) { + last := f.Cache.allocBoolSlice(f.NumValues()) + defer f.Cache.freeBoolSlice(last) + + // prevStore returns the previous store in the + // same block, or nil if there are none. + prevStore := func(v *Value) *Value { + if v.Op == OpInitMem || v.Op == OpPhi { + return nil + } + m := v.MemoryArg() + if m.Block != v.Block { + return nil + } + return m + } + + for _, b := range f.Blocks { + // Find last store in block, so we can + // walk the stores last to first. + // Last to first helps ensure that the rewrites we + // perform do not get in the way of subsequent rewrites. + for _, v := range b.Values { + if v.Type.IsMemory() { + last[v.ID] = true + } + } + for _, v := range b.Values { + if v.Type.IsMemory() { + if m := prevStore(v); m != nil { + last[m.ID] = false + } + } + } + var lastMem *Value + for _, v := range b.Values { + if last[v.ID] { + lastMem = v + break + } + } + + // Check all stores, from last to first. + memCheck: + for v := lastMem; v != nil; v = prevStore(v) { + info := pairableStores[v.Op] + if info.width == 0 { + continue // Not pairable. + } + if !offsetOk(v.Aux, v.AuxInt, info.width) { + continue // Not advisable to pair. + } + ptr := v.Args[0] + val := v.Args[1] + mem := v.Args[2] + off := v.AuxInt + aux := v.Aux + + // Look for earlier store we can combine with. + lowerOk := true + higherOk := true + count := 10 // max lookback distance + for w := prevStore(v); w != nil; w = prevStore(w) { + if w.Uses != 1 { + // We can't combine stores if the earlier + // store has any use besides the next one + // in the store chain. + // (Unless we could check the aliasing of + // all those other uses.) + continue memCheck + } + if w.Op == v.Op && + w.Args[0] == ptr && + w.Aux == aux && + (lowerOk && w.AuxInt == off-info.width || higherOk && w.AuxInt == off+info.width) { + // This op is mergeable with v. + + // Commit point. + + // ptr val1 val2 mem + args := []*Value{ptr, val, w.Args[1], mem} + if w.AuxInt == off-info.width { + args[1], args[2] = args[2], args[1] + off -= info.width + } + v.reset(info.pair) + v.AddArgs(args...) + v.Aux = aux + v.AuxInt = off + v.Pos = w.Pos // take position of earlier of the two stores (TODO: not really working?) + + // Make w just a memory copy. + wmem := w.MemoryArg() + w.reset(OpCopy) + w.SetArgs1(wmem) + continue memCheck + } + if count--; count == 0 { + // Only look back so far. + // This keeps us in O(n) territory, and it + // also prevents us from keeping values + // in registers for too long (and thus + // needing to spill them). + continue memCheck + } + // We're now looking at a store w which is currently + // between the store v that we're intending to merge into, + // and the store we'll eventually find to merge with it. + // Make sure this store doesn't alias with the one + // we'll be moving. + var width int64 + switch w.Op { + case OpARM64MOVDstore, OpARM64FMOVDstore: + width = 8 + case OpARM64MOVWstore, OpARM64FMOVSstore: + width = 4 + case OpARM64MOVHstore: + width = 2 + case OpARM64MOVBstore: + width = 1 + case OpCopy: + continue // this was a store we merged earlier + default: + // Can't reorder with any other memory operations. + // (atomics, calls, ...) + continue memCheck + } + + // We only allow reordering with respect to other + // writes to the same pointer and aux, so we can + // compute the exact the aliasing relationship. + if w.Args[0] != ptr || w.Aux != aux { + continue memCheck + } + if overlap(w.AuxInt, width, off-info.width, info.width) { + // Aliases with slot before v's location. + lowerOk = false + } + if overlap(w.AuxInt, width, off+info.width, info.width) { + // Aliases with slot after v's location. + higherOk = false + } + if !higherOk && !lowerOk { + continue memCheck + } + } + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/passbm_test.go b/go/src/cmd/compile/internal/ssa/passbm_test.go new file mode 100644 index 0000000000000000000000000000000000000000..239d31a40b888f15b85734e4bd4e53c67ecb3b4d --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/passbm_test.go @@ -0,0 +1,101 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "fmt" + "testing" +) + +const ( + blockCount = 1000 + passCount = 15000 +) + +type passFunc func(*Func) + +func BenchmarkDSEPass(b *testing.B) { benchFnPass(b, dse, blockCount, genFunction) } +func BenchmarkDSEPassBlock(b *testing.B) { benchFnBlock(b, dse, genFunction) } +func BenchmarkCSEPass(b *testing.B) { benchFnPass(b, cse, blockCount, genFunction) } +func BenchmarkCSEPassBlock(b *testing.B) { benchFnBlock(b, cse, genFunction) } +func BenchmarkDeadcodePass(b *testing.B) { benchFnPass(b, deadcode, blockCount, genFunction) } +func BenchmarkDeadcodePassBlock(b *testing.B) { benchFnBlock(b, deadcode, genFunction) } + +func multi(f *Func) { + cse(f) + dse(f) + deadcode(f) +} +func BenchmarkMultiPass(b *testing.B) { benchFnPass(b, multi, blockCount, genFunction) } +func BenchmarkMultiPassBlock(b *testing.B) { benchFnBlock(b, multi, genFunction) } + +// benchFnPass runs passFunc b.N times across a single function. +func benchFnPass(b *testing.B, fn passFunc, size int, bg blockGen) { + b.ReportAllocs() + c := testConfig(b) + fun := c.Fun("entry", bg(size)...) + CheckFunc(fun.f) + b.ResetTimer() + for i := 0; i < b.N; i++ { + fn(fun.f) + b.StopTimer() + CheckFunc(fun.f) + b.StartTimer() + } +} + +// benchFnBlock runs passFunc across a function with b.N blocks. +func benchFnBlock(b *testing.B, fn passFunc, bg blockGen) { + b.ReportAllocs() + c := testConfig(b) + fun := c.Fun("entry", bg(b.N)...) + CheckFunc(fun.f) + b.ResetTimer() + for i := 0; i < passCount; i++ { + fn(fun.f) + } + b.StopTimer() +} + +func genFunction(size int) []bloc { + var blocs []bloc + elemType := types.Types[types.TINT64] + ptrType := elemType.PtrTo() + + valn := func(s string, m, n int) string { return fmt.Sprintf("%s%d-%d", s, m, n) } + blocs = append(blocs, + Bloc("entry", + Valu(valn("store", 0, 4), OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, types.Types[types.TUINTPTR], 0, nil), + Goto(blockn(1)), + ), + ) + for i := 1; i < size+1; i++ { + blocs = append(blocs, Bloc(blockn(i), + Valu(valn("v", i, 0), OpConstBool, types.Types[types.TBOOL], 1, nil), + Valu(valn("addr", i, 1), OpAddr, ptrType, 0, nil, "sb"), + Valu(valn("addr", i, 2), OpAddr, ptrType, 0, nil, "sb"), + Valu(valn("addr", i, 3), OpAddr, ptrType, 0, nil, "sb"), + Valu(valn("zero", i, 1), OpZero, types.TypeMem, 8, elemType, valn("addr", i, 3), + valn("store", i-1, 4)), + Valu(valn("store", i, 1), OpStore, types.TypeMem, 0, elemType, valn("addr", i, 1), + valn("v", i, 0), valn("zero", i, 1)), + Valu(valn("store", i, 2), OpStore, types.TypeMem, 0, elemType, valn("addr", i, 2), + valn("v", i, 0), valn("store", i, 1)), + Valu(valn("store", i, 3), OpStore, types.TypeMem, 0, elemType, valn("addr", i, 1), + valn("v", i, 0), valn("store", i, 2)), + Valu(valn("store", i, 4), OpStore, types.TypeMem, 0, elemType, valn("addr", i, 3), + valn("v", i, 0), valn("store", i, 3)), + Goto(blockn(i+1)))) + } + + blocs = append(blocs, + Bloc(blockn(size+1), Goto("exit")), + Bloc("exit", Exit("store0-4")), + ) + + return blocs +} diff --git a/go/src/cmd/compile/internal/ssa/phiopt.go b/go/src/cmd/compile/internal/ssa/phiopt.go new file mode 100644 index 0000000000000000000000000000000000000000..034ee4c661046b2ffe63137a1b6c3e4776f2ec0b --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/phiopt.go @@ -0,0 +1,352 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// phiopt eliminates boolean Phis based on the previous if. +// +// Main use case is to transform: +// +// x := false +// if b { +// x = true +// } +// +// into x = b. +// +// In SSA code this appears as +// +// b0 +// If b -> b1 b2 +// b1 +// Plain -> b2 +// b2 +// x = (OpPhi (ConstBool [true]) (ConstBool [false])) +// +// In this case we can replace x with a copy of b. +func phiopt(f *Func) { + sdom := f.Sdom() + for _, b := range f.Blocks { + if len(b.Preds) != 2 || len(b.Values) == 0 { + // TODO: handle more than 2 predecessors, e.g. a || b || c. + continue + } + + pb0, b0 := b, b.Preds[0].b + for len(b0.Succs) == 1 && len(b0.Preds) == 1 { + pb0, b0 = b0, b0.Preds[0].b + } + if b0.Kind != BlockIf { + continue + } + pb1, b1 := b, b.Preds[1].b + for len(b1.Succs) == 1 && len(b1.Preds) == 1 { + pb1, b1 = b1, b1.Preds[0].b + } + if b1 != b0 { + continue + } + // b0 is the if block giving the boolean value. + // reverse is the predecessor from which the truth value comes. + var reverse int + if b0.Succs[0].b == pb0 && b0.Succs[1].b == pb1 { + reverse = 0 + } else if b0.Succs[0].b == pb1 && b0.Succs[1].b == pb0 { + reverse = 1 + } else { + b.Fatalf("invalid predecessors\n") + } + + for _, v := range b.Values { + if v.Op != OpPhi { + continue + } + + // Look for conversions from bool to 0/1. + if v.Type.IsInteger() { + phioptint(v, b0, reverse) + } + + if !v.Type.IsBoolean() { + continue + } + + // Replaces + // if a { x = true } else { x = false } with x = a + // and + // if a { x = false } else { x = true } with x = !a + if v.Args[0].Op == OpConstBool && v.Args[1].Op == OpConstBool { + if v.Args[reverse].AuxInt != v.Args[1-reverse].AuxInt { + ops := [2]Op{OpNot, OpCopy} + v.reset(ops[v.Args[reverse].AuxInt]) + v.AddArg(b0.Controls[0]) + if f.pass.debug > 0 { + f.Warnl(b.Pos, "converted OpPhi to %v", v.Op) + } + continue + } + } + + // Replaces + // if a { x = true } else { x = value } with x = a || value. + // Requires that value dominates x, meaning that regardless of a, + // value is always computed. This guarantees that the side effects + // of value are not seen if a is false. + if v.Args[reverse].Op == OpConstBool && v.Args[reverse].AuxInt == 1 { + if tmp := v.Args[1-reverse]; sdom.IsAncestorEq(tmp.Block, b) { + v.reset(OpOrB) + v.SetArgs2(b0.Controls[0], tmp) + if f.pass.debug > 0 { + f.Warnl(b.Pos, "converted OpPhi to %v", v.Op) + } + continue + } + } + + // Replaces + // if a { x = value } else { x = false } with x = a && value. + // Requires that value dominates x, meaning that regardless of a, + // value is always computed. This guarantees that the side effects + // of value are not seen if a is false. + if v.Args[1-reverse].Op == OpConstBool && v.Args[1-reverse].AuxInt == 0 { + if tmp := v.Args[reverse]; sdom.IsAncestorEq(tmp.Block, b) { + v.reset(OpAndB) + v.SetArgs2(b0.Controls[0], tmp) + if f.pass.debug > 0 { + f.Warnl(b.Pos, "converted OpPhi to %v", v.Op) + } + continue + } + } + // Replaces + // if a { x = value } else { x = a } with x = a && value. + // Requires that value dominates x. + if v.Args[1-reverse] == b0.Controls[0] { + if tmp := v.Args[reverse]; sdom.IsAncestorEq(tmp.Block, b) { + v.reset(OpAndB) + v.SetArgs2(b0.Controls[0], tmp) + if f.pass.debug > 0 { + f.Warnl(b.Pos, "converted OpPhi to %v", v.Op) + } + continue + } + } + + // Replaces + // if a { x = a } else { x = value } with x = a || value. + // Requires that value dominates x. + if v.Args[reverse] == b0.Controls[0] { + if tmp := v.Args[1-reverse]; sdom.IsAncestorEq(tmp.Block, b) { + v.reset(OpOrB) + v.SetArgs2(b0.Controls[0], tmp) + if f.pass.debug > 0 { + f.Warnl(b.Pos, "converted OpPhi to %v", v.Op) + } + continue + } + } + } + } + // strengthen phi optimization. + // Main use case is to transform: + // x := false + // if c { + // x = true + // ... + // } + // into + // x := c + // if x { ... } + // + // For example, in SSA code a case appears as + // b0 + // If c -> b, sb0 + // sb0 + // If d -> sd0, sd1 + // sd1 + // ... + // sd0 + // Plain -> b + // b + // x = (OpPhi (ConstBool [true]) (ConstBool [false])) + // + // In this case we can also replace x with a copy of c. + // + // The optimization idea: + // 1. block b has a phi value x, x = OpPhi (ConstBool [true]) (ConstBool [false]), + // and len(b.Preds) is equal to 2. + // 2. find the common dominator(b0) of the predecessors(pb0, pb1) of block b, and the + // dominator(b0) is a If block. + // Special case: one of the predecessors(pb0 or pb1) is the dominator(b0). + // 3. the successors(sb0, sb1) of the dominator need to dominate the predecessors(pb0, pb1) + // of block b respectively. + // 4. replace this boolean Phi based on dominator block. + // + // b0(pb0) b0(pb1) b0 + // | \ / | / \ + // | sb1 sb0 | sb0 sb1 + // | ... ... | ... ... + // | pb1 pb0 | pb0 pb1 + // | / \ | \ / + // b b b + // + var lca *lcaRange + for _, b := range f.Blocks { + if len(b.Preds) != 2 || len(b.Values) == 0 { + // TODO: handle more than 2 predecessors, e.g. a || b || c. + continue + } + + for _, v := range b.Values { + // find a phi value v = OpPhi (ConstBool [true]) (ConstBool [false]). + // TODO: v = OpPhi (ConstBool [true]) (Arg {value}) + if v.Op != OpPhi { + continue + } + if v.Args[0].Op != OpConstBool || v.Args[1].Op != OpConstBool { + continue + } + if v.Args[0].AuxInt == v.Args[1].AuxInt { + continue + } + + pb0 := b.Preds[0].b + pb1 := b.Preds[1].b + if pb0.Kind == BlockIf && pb0 == sdom.Parent(b) { + // special case: pb0 is the dominator block b0. + // b0(pb0) + // | \ + // | sb1 + // | ... + // | pb1 + // | / + // b + // if another successor sb1 of b0(pb0) dominates pb1, do replace. + ei := b.Preds[0].i + sb1 := pb0.Succs[1-ei].b + if sdom.IsAncestorEq(sb1, pb1) { + convertPhi(pb0, v, ei) + break + } + } else if pb1.Kind == BlockIf && pb1 == sdom.Parent(b) { + // special case: pb1 is the dominator block b0. + // b0(pb1) + // / | + // sb0 | + // ... | + // pb0 | + // \ | + // b + // if another successor sb0 of b0(pb0) dominates pb0, do replace. + ei := b.Preds[1].i + sb0 := pb1.Succs[1-ei].b + if sdom.IsAncestorEq(sb0, pb0) { + convertPhi(pb1, v, 1-ei) + break + } + } else { + // b0 + // / \ + // sb0 sb1 + // ... ... + // pb0 pb1 + // \ / + // b + // + // Build data structure for fast least-common-ancestor queries. + if lca == nil { + lca = makeLCArange(f) + } + b0 := lca.find(pb0, pb1) + if b0.Kind != BlockIf { + break + } + sb0 := b0.Succs[0].b + sb1 := b0.Succs[1].b + var reverse int + if sdom.IsAncestorEq(sb0, pb0) && sdom.IsAncestorEq(sb1, pb1) { + reverse = 0 + } else if sdom.IsAncestorEq(sb1, pb0) && sdom.IsAncestorEq(sb0, pb1) { + reverse = 1 + } else { + break + } + if len(sb0.Preds) != 1 || len(sb1.Preds) != 1 { + // we can not replace phi value x in the following case. + // if gp == nil || sp < lo { x = true} + // if a || b { x = true } + // so the if statement can only have one condition. + break + } + convertPhi(b0, v, reverse) + } + } + } +} + +func phioptint(v *Value, b0 *Block, reverse int) { + a0 := v.Args[0] + a1 := v.Args[1] + if a0.Op != a1.Op { + return + } + + switch a0.Op { + case OpConst8, OpConst16, OpConst32, OpConst64: + default: + return + } + + negate := false + switch { + case a0.AuxInt == 0 && a1.AuxInt == 1: + negate = true + case a0.AuxInt == 1 && a1.AuxInt == 0: + default: + return + } + + if reverse == 1 { + negate = !negate + } + + a := b0.Controls[0] + if negate { + a = v.Block.NewValue1(v.Pos, OpNot, a.Type, a) + } + v.AddArg(a) + + cvt := v.Block.NewValue1(v.Pos, OpCvtBoolToUint8, v.Block.Func.Config.Types.UInt8, a) + switch v.Type.Size() { + case 1: + v.reset(OpCopy) + case 2: + v.reset(OpZeroExt8to16) + case 4: + v.reset(OpZeroExt8to32) + case 8: + v.reset(OpZeroExt8to64) + default: + v.Fatalf("bad int size %d", v.Type.Size()) + } + v.AddArg(cvt) + + f := b0.Func + if f.pass.debug > 0 { + f.Warnl(v.Block.Pos, "converted OpPhi bool -> int%d", v.Type.Size()*8) + } +} + +// b is the If block giving the boolean value. +// v is the phi value v = (OpPhi (ConstBool [true]) (ConstBool [false])). +// reverse is the predecessor from which the truth value comes. +func convertPhi(b *Block, v *Value, reverse int) { + f := b.Func + ops := [2]Op{OpNot, OpCopy} + v.reset(ops[v.Args[reverse].AuxInt]) + v.AddArg(b.Controls[0]) + if f.pass.debug > 0 { + f.Warnl(b.Pos, "converted OpPhi to %v", v.Op) + } +} diff --git a/go/src/cmd/compile/internal/ssa/poset.go b/go/src/cmd/compile/internal/ssa/poset.go new file mode 100644 index 0000000000000000000000000000000000000000..f4f75fbe09d8c713e777628fd5ef12732d956620 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/poset.go @@ -0,0 +1,1139 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "fmt" + "os" + "slices" +) + +// If true, check poset integrity after every mutation +var debugPoset = false + +const uintSize = 32 << (^uint(0) >> 63) // 32 or 64 + +// bitset is a bit array for dense indexes. +type bitset []uint + +func newBitset(n int) bitset { + return make(bitset, (n+uintSize-1)/uintSize) +} + +func (bs bitset) Reset() { + clear(bs) +} + +func (bs bitset) Set(idx uint32) { + bs[idx/uintSize] |= 1 << (idx % uintSize) +} + +func (bs bitset) Clear(idx uint32) { + bs[idx/uintSize] &^= 1 << (idx % uintSize) +} + +func (bs bitset) Test(idx uint32) bool { + return bs[idx/uintSize]&(1<<(idx%uintSize)) != 0 +} + +type undoType uint8 + +const ( + undoInvalid undoType = iota + undoCheckpoint // a checkpoint to group undo passes + undoSetChl // change back left child of undo.idx to undo.edge + undoSetChr // change back right child of undo.idx to undo.edge + undoNonEqual // forget that SSA value undo.ID is non-equal to undo.idx (another ID) + undoNewNode // remove new node created for SSA value undo.ID + undoAliasNode // unalias SSA value undo.ID so that it points back to node index undo.idx + undoNewRoot // remove node undo.idx from root list + undoChangeRoot // remove node undo.idx from root list, and put back undo.edge.Target instead + undoMergeRoot // remove node undo.idx from root list, and put back its children instead +) + +// posetUndo represents an undo pass to be performed. +// It's a union of fields that can be used to store information, +// and typ is the discriminant, that specifies which kind +// of operation must be performed. Not all fields are always used. +type posetUndo struct { + typ undoType + idx uint32 + ID ID + edge posetEdge +} + +const ( + // Make poset handle values as unsigned numbers. + // (TODO: remove?) + posetFlagUnsigned = 1 << iota +) + +// A poset edge. The zero value is the null/empty edge. +// Packs target node index (31 bits) and strict flag (1 bit). +type posetEdge uint32 + +func newedge(t uint32, strict bool) posetEdge { + s := uint32(0) + if strict { + s = 1 + } + return posetEdge(t<<1 | s) +} +func (e posetEdge) Target() uint32 { return uint32(e) >> 1 } +func (e posetEdge) Strict() bool { return uint32(e)&1 != 0 } +func (e posetEdge) String() string { + s := fmt.Sprint(e.Target()) + if e.Strict() { + s += "*" + } + return s +} + +// posetNode is a node of a DAG within the poset. +type posetNode struct { + l, r posetEdge +} + +// poset is a union-find data structure that can represent a partially ordered set +// of SSA values. Given a binary relation that creates a partial order (eg: '<'), +// clients can record relations between SSA values using SetOrder, and later +// check relations (in the transitive closure) with Ordered. For instance, +// if SetOrder is called to record that A 0 { + i := open[len(open)-1] + open = open[:len(open)-1] + + // Don't visit the same node twice. Notice that all nodes + // across non-strict paths are still visited at least once, so + // a non-strict path can never obscure a strict path to the + // same node. + if !closed.Test(i) { + closed.Set(i) + + l, r := po.children(i) + if l != 0 { + if l.Strict() { + next = append(next, l.Target()) + } else { + open = append(open, l.Target()) + } + } + if r != 0 { + if r.Strict() { + next = append(next, r.Target()) + } else { + open = append(open, r.Target()) + } + } + } + } + open = next + closed.Reset() + } + + for len(open) > 0 { + i := open[len(open)-1] + open = open[:len(open)-1] + + if !closed.Test(i) { + if f(i) { + return true + } + closed.Set(i) + l, r := po.children(i) + if l != 0 { + open = append(open, l.Target()) + } + if r != 0 { + open = append(open, r.Target()) + } + } + } + return false +} + +// Returns true if there is a path from i1 to i2. +// If strict == true: if the function returns true, then i1 < i2. +// If strict == false: if the function returns true, then i1 <= i2. +// If the function returns false, no relation is known. +func (po *poset) reaches(i1, i2 uint32, strict bool) bool { + return po.dfs(i1, strict, func(n uint32) bool { + return n == i2 + }) +} + +// findroot finds i's root, that is which DAG contains i. +// Returns the root; if i is itself a root, it is returned. +// Panic if i is not in any DAG. +func (po *poset) findroot(i uint32) uint32 { + // TODO(rasky): if needed, a way to speed up this search is + // storing a bitset for each root using it as a mini bloom filter + // of nodes present under that root. + for _, r := range po.roots { + if po.reaches(r, i, false) { + return r + } + } + panic("findroot didn't find any root") +} + +// mergeroot merges two DAGs into one DAG by creating a new extra root +func (po *poset) mergeroot(r1, r2 uint32) uint32 { + r := po.newnode(nil) + po.setchl(r, newedge(r1, false)) + po.setchr(r, newedge(r2, false)) + po.changeroot(r1, r) + po.removeroot(r2) + po.upush(undoMergeRoot, r, 0) + return r +} + +// collapsepath marks n1 and n2 as equal and collapses as equal all +// nodes across all paths between n1 and n2. If a strict edge is +// found, the function does not modify the DAG and returns false. +// Complexity is O(n). +func (po *poset) collapsepath(n1, n2 *Value) bool { + i1, i2 := po.values[n1.ID], po.values[n2.ID] + if po.reaches(i1, i2, true) { + return false + } + + // Find all the paths from i1 to i2 + paths := po.findpaths(i1, i2) + // Mark all nodes in all the paths as aliases of n1 + // (excluding n1 itself) + paths.Clear(i1) + po.aliasnodes(n1, paths) + return true +} + +// findpaths is a recursive function that calculates all paths from cur to dst +// and return them as a bitset (the index of a node is set in the bitset if +// that node is on at least one path from cur to dst). +// We do a DFS from cur (stopping going deep any time we reach dst, if ever), +// and mark as part of the paths any node that has a children which is already +// part of the path (or is dst itself). +func (po *poset) findpaths(cur, dst uint32) bitset { + seen := newBitset(int(po.lastidx + 1)) + path := newBitset(int(po.lastidx + 1)) + path.Set(dst) + po.findpaths1(cur, dst, seen, path) + return path +} + +func (po *poset) findpaths1(cur, dst uint32, seen bitset, path bitset) { + if cur == dst { + return + } + seen.Set(cur) + l, r := po.chl(cur), po.chr(cur) + if !seen.Test(l) { + po.findpaths1(l, dst, seen, path) + } + if !seen.Test(r) { + po.findpaths1(r, dst, seen, path) + } + if path.Test(l) || path.Test(r) { + path.Set(cur) + } +} + +// Check whether it is recorded that i1!=i2 +func (po *poset) isnoneq(i1, i2 uint32) bool { + if i1 == i2 { + return false + } + if i1 < i2 { + i1, i2 = i2, i1 + } + + // Check if we recorded a non-equal relation before + if bs, ok := po.noneq[i1]; ok && bs.Test(i2) { + return true + } + return false +} + +// Record that i1!=i2 +func (po *poset) setnoneq(n1, n2 *Value) { + i1, f1 := po.lookup(n1) + i2, f2 := po.lookup(n2) + + // If any of the nodes do not exist in the poset, allocate them. Since + // we don't know any relation (in the partial order) about them, they must + // become independent roots. + if !f1 { + i1 = po.newnode(n1) + po.roots = append(po.roots, i1) + po.upush(undoNewRoot, i1, 0) + } + if !f2 { + i2 = po.newnode(n2) + po.roots = append(po.roots, i2) + po.upush(undoNewRoot, i2, 0) + } + + if i1 == i2 { + panic("setnoneq on same node") + } + if i1 < i2 { + i1, i2 = i2, i1 + } + bs := po.noneq[i1] + if bs == nil { + // Given that we record non-equality relations using the + // higher index as a key, the bitsize will never change size. + // TODO(rasky): if memory is a problem, consider allocating + // a small bitset and lazily grow it when higher indices arrive. + bs = newBitset(int(i1)) + po.noneq[i1] = bs + } else if bs.Test(i2) { + // Already recorded + return + } + bs.Set(i2) + po.upushneq(i1, i2) +} + +// CheckIntegrity verifies internal integrity of a poset. It is intended +// for debugging purposes. +func (po *poset) CheckIntegrity() { + // Verify that each node appears in a single DAG + seen := newBitset(int(po.lastidx + 1)) + for _, r := range po.roots { + if r == 0 { + panic("empty root") + } + + po.dfs(r, false, func(i uint32) bool { + if seen.Test(i) { + panic("duplicate node") + } + seen.Set(i) + return false + }) + } + + // Verify that values contain the minimum set + for id, idx := range po.values { + if !seen.Test(idx) { + panic(fmt.Errorf("spurious value [%d]=%d", id, idx)) + } + } + + // Verify that only existing nodes have non-zero children + for i, n := range po.nodes { + if n.l|n.r != 0 { + if !seen.Test(uint32(i)) { + panic(fmt.Errorf("children of unknown node %d->%v", i, n)) + } + if n.l.Target() == uint32(i) || n.r.Target() == uint32(i) { + panic(fmt.Errorf("self-loop on node %d", i)) + } + } + } +} + +// CheckEmpty checks that a poset is completely empty. +// It can be used for debugging purposes, as a poset is supposed to +// be empty after it's fully rolled back through Undo. +func (po *poset) CheckEmpty() error { + if len(po.nodes) != 1 { + return fmt.Errorf("non-empty nodes list: %v", po.nodes) + } + if len(po.values) != 0 { + return fmt.Errorf("non-empty value map: %v", po.values) + } + if len(po.roots) != 0 { + return fmt.Errorf("non-empty root list: %v", po.roots) + } + if len(po.undo) != 0 { + return fmt.Errorf("non-empty undo list: %v", po.undo) + } + if po.lastidx != 0 { + return fmt.Errorf("lastidx index is not zero: %v", po.lastidx) + } + for _, bs := range po.noneq { + for _, x := range bs { + if x != 0 { + return fmt.Errorf("non-empty noneq map") + } + } + } + return nil +} + +// DotDump dumps the poset in graphviz format to file fn, with the specified title. +func (po *poset) DotDump(fn string, title string) error { + f, err := os.Create(fn) + if err != nil { + return err + } + defer f.Close() + + // Create reverse index mapping (taking aliases into account) + names := make(map[uint32]string) + for id, i := range po.values { + s := names[i] + if s == "" { + s = fmt.Sprintf("v%d", id) + } else { + s += fmt.Sprintf(", v%d", id) + } + names[i] = s + } + + fmt.Fprintf(f, "digraph poset {\n") + fmt.Fprintf(f, "\tedge [ fontsize=10 ]\n") + for ridx, r := range po.roots { + fmt.Fprintf(f, "\tsubgraph root%d {\n", ridx) + po.dfs(r, false, func(i uint32) bool { + fmt.Fprintf(f, "\t\tnode%d [label=<%s [%d]>]\n", i, names[i], i) + chl, chr := po.children(i) + for _, ch := range []posetEdge{chl, chr} { + if ch != 0 { + if ch.Strict() { + fmt.Fprintf(f, "\t\tnode%d -> node%d [label=\" <\" color=\"red\"]\n", i, ch.Target()) + } else { + fmt.Fprintf(f, "\t\tnode%d -> node%d [label=\" <=\" color=\"green\"]\n", i, ch.Target()) + } + } + } + return false + }) + fmt.Fprintf(f, "\t}\n") + } + fmt.Fprintf(f, "\tlabelloc=\"t\"\n") + fmt.Fprintf(f, "\tlabeldistance=\"3.0\"\n") + fmt.Fprintf(f, "\tlabel=%q\n", title) + fmt.Fprintf(f, "}\n") + return nil +} + +// Ordered reports whether n1 r i1 + // i2 \ / + // i2 + // + extra := po.newnode(nil) + po.changeroot(r, extra) + po.upush(undoChangeRoot, extra, newedge(r, false)) + po.addchild(extra, r, false) + po.addchild(extra, i1, false) + po.addchild(i1, i2, strict) + + case f1 && f2: + // If the nodes are aliased, fail only if we're setting a strict order + // (that is, we cannot set n1 0 { + pass := po.undo[len(po.undo)-1] + po.undo = po.undo[:len(po.undo)-1] + + switch pass.typ { + case undoCheckpoint: + return + + case undoSetChl: + po.setchl(pass.idx, pass.edge) + + case undoSetChr: + po.setchr(pass.idx, pass.edge) + + case undoNonEqual: + po.noneq[uint32(pass.ID)].Clear(pass.idx) + + case undoNewNode: + if pass.idx != po.lastidx { + panic("invalid newnode index") + } + if pass.ID != 0 { + if po.values[pass.ID] != pass.idx { + panic("invalid newnode undo pass") + } + delete(po.values, pass.ID) + } + po.setchl(pass.idx, 0) + po.setchr(pass.idx, 0) + po.nodes = po.nodes[:pass.idx] + po.lastidx-- + + case undoAliasNode: + ID, prev := pass.ID, pass.idx + cur := po.values[ID] + if prev == 0 { + // Born as an alias, die as an alias + delete(po.values, ID) + } else { + if cur == prev { + panic("invalid aliasnode undo pass") + } + // Give it back previous value + po.values[ID] = prev + } + + case undoNewRoot: + i := pass.idx + l, r := po.children(i) + if l|r != 0 { + panic("non-empty root in undo newroot") + } + po.removeroot(i) + + case undoChangeRoot: + i := pass.idx + l, r := po.children(i) + if l|r != 0 { + panic("non-empty root in undo changeroot") + } + po.changeroot(i, pass.edge.Target()) + + case undoMergeRoot: + i := pass.idx + l, r := po.children(i) + po.changeroot(i, l.Target()) + po.roots = append(po.roots, r.Target()) + + default: + panic(pass.typ) + } + } + + if debugPoset && po.CheckEmpty() != nil { + panic("poset not empty at the end of undo") + } +} diff --git a/go/src/cmd/compile/internal/ssa/poset_test.go b/go/src/cmd/compile/internal/ssa/poset_test.go new file mode 100644 index 0000000000000000000000000000000000000000..17918f2550063b69ed0ca43b9f58781dfe17b5a2 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/poset_test.go @@ -0,0 +1,668 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "fmt" + "testing" +) + +const ( + SetOrder = "SetOrder" + SetOrder_Fail = "SetOrder_Fail" + SetOrderOrEqual = "SetOrderOrEqual" + SetOrderOrEqual_Fail = "SetOrderOrEqual_Fail" + Ordered = "Ordered" + Ordered_Fail = "Ordered_Fail" + OrderedOrEqual = "OrderedOrEqual" + OrderedOrEqual_Fail = "OrderedOrEqual_Fail" + SetEqual = "SetEqual" + SetEqual_Fail = "SetEqual_Fail" + Equal = "Equal" + Equal_Fail = "Equal_Fail" + SetNonEqual = "SetNonEqual" + SetNonEqual_Fail = "SetNonEqual_Fail" + NonEqual = "NonEqual" + NonEqual_Fail = "NonEqual_Fail" + Checkpoint = "Checkpoint" + Undo = "Undo" +) + +type posetTestOp struct { + typ string + a, b int +} + +func vconst(i int) int { + if i < -128 || i >= 128 { + panic("invalid const") + } + return 1000 + 128 + i +} + +func testPosetOps(t *testing.T, unsigned bool, ops []posetTestOp) { + var v [1512]*Value + for i := range v { + v[i] = new(Value) + v[i].ID = ID(i) + if i >= 1000 && i < 1256 { + v[i].Op = OpConst64 + v[i].AuxInt = int64(i - 1000 - 128) + } + } + + po := newPoset() + po.SetUnsigned(unsigned) + for idx, op := range ops { + t.Logf("op%d%v", idx, op) + switch op.typ { + case SetOrder: + if !po.SetOrder(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v failed", idx, op) + } + case SetOrder_Fail: + if po.SetOrder(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v passed", idx, op) + } + case SetOrderOrEqual: + if !po.SetOrderOrEqual(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v failed", idx, op) + } + case SetOrderOrEqual_Fail: + if po.SetOrderOrEqual(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v passed", idx, op) + } + case Ordered: + if !po.Ordered(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v failed", idx, op) + } + case Ordered_Fail: + if po.Ordered(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v passed", idx, op) + } + case OrderedOrEqual: + if !po.OrderedOrEqual(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v failed", idx, op) + } + case OrderedOrEqual_Fail: + if po.OrderedOrEqual(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v passed", idx, op) + } + case SetEqual: + if !po.SetEqual(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v failed", idx, op) + } + case SetEqual_Fail: + if po.SetEqual(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v passed", idx, op) + } + case Equal: + if !po.Equal(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v failed", idx, op) + } + case Equal_Fail: + if po.Equal(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v passed", idx, op) + } + case SetNonEqual: + if !po.SetNonEqual(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v failed", idx, op) + } + case SetNonEqual_Fail: + if po.SetNonEqual(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v passed", idx, op) + } + case NonEqual: + if !po.NonEqual(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v failed", idx, op) + } + case NonEqual_Fail: + if po.NonEqual(v[op.a], v[op.b]) { + t.Errorf("FAILED: op%d%v passed", idx, op) + } + case Checkpoint: + po.Checkpoint() + case Undo: + t.Log("Undo stack", po.undo) + po.Undo() + default: + panic("unimplemented") + } + + if false { + po.DotDump(fmt.Sprintf("op%d.dot", idx), fmt.Sprintf("Last op: %v", op)) + } + + po.CheckIntegrity() + } + + // Check that the poset is completely empty + if err := po.CheckEmpty(); err != nil { + t.Error(err) + } +} + +func TestPoset(t *testing.T) { + testPosetOps(t, false, []posetTestOp{ + {Ordered_Fail, 123, 124}, + + // Dag #0: 100<101 + {Checkpoint, 0, 0}, + {SetOrder, 100, 101}, + {Ordered, 100, 101}, + {Ordered_Fail, 101, 100}, + {SetOrder_Fail, 101, 100}, + {SetOrder, 100, 101}, // repeat + {NonEqual, 100, 101}, + {NonEqual, 101, 100}, + {SetEqual_Fail, 100, 101}, + + // Dag #1: 4<=7<12 + {Checkpoint, 0, 0}, + {SetOrderOrEqual, 4, 7}, + {OrderedOrEqual, 4, 7}, + {SetOrder, 7, 12}, + {Ordered, 7, 12}, + {Ordered, 4, 12}, + {Ordered_Fail, 12, 4}, + {NonEqual, 4, 12}, + {NonEqual, 12, 4}, + {NonEqual_Fail, 4, 100}, + {OrderedOrEqual, 4, 12}, + {OrderedOrEqual_Fail, 12, 4}, + {OrderedOrEqual, 4, 7}, + {OrderedOrEqual_Fail, 7, 4}, + + // Dag #1: 1<4<=7<12 + {Checkpoint, 0, 0}, + {SetOrder, 1, 4}, + {Ordered, 1, 4}, + {Ordered, 1, 12}, + {Ordered_Fail, 12, 1}, + + // Dag #1: 1<4<=7<12, 6<7 + {Checkpoint, 0, 0}, + {SetOrder, 6, 7}, + {Ordered, 6, 7}, + {Ordered, 6, 12}, + {SetOrder_Fail, 7, 4}, + {SetOrder_Fail, 7, 6}, + {SetOrder_Fail, 7, 1}, + + // Dag #1: 1<4<=7<12, 1<6<7 + {Checkpoint, 0, 0}, + {Ordered_Fail, 1, 6}, + {SetOrder, 1, 6}, + {Ordered, 1, 6}, + {SetOrder_Fail, 6, 1}, + + // Dag #1: 1<4<=7<12, 1<4<6<7 + {Checkpoint, 0, 0}, + {Ordered_Fail, 4, 6}, + {Ordered_Fail, 4, 7}, + {SetOrder, 4, 6}, + {Ordered, 4, 6}, + {OrderedOrEqual, 4, 6}, + {Ordered, 4, 7}, + {OrderedOrEqual, 4, 7}, + {SetOrder_Fail, 6, 4}, + {Ordered_Fail, 7, 6}, + {Ordered_Fail, 7, 4}, + {OrderedOrEqual_Fail, 7, 6}, + {OrderedOrEqual_Fail, 7, 4}, + + // Merge: 1<4<6, 4<=7<12, 6<101 + {Checkpoint, 0, 0}, + {Ordered_Fail, 6, 101}, + {SetOrder, 6, 101}, + {Ordered, 6, 101}, + {Ordered, 1, 101}, + + // Merge: 1<4<6, 4<=7<12, 6<100<101 + {Checkpoint, 0, 0}, + {Ordered_Fail, 6, 100}, + {SetOrder, 6, 100}, + {Ordered, 1, 100}, + + // Undo: 1<4<6<7<12, 6<101 + {Ordered, 100, 101}, + {Undo, 0, 0}, + {Ordered, 100, 101}, + {Ordered_Fail, 6, 100}, + {Ordered, 6, 101}, + {Ordered, 1, 101}, + + // Undo: 1<4<6<7<12, 100<101 + {Undo, 0, 0}, + {Ordered_Fail, 1, 100}, + {Ordered_Fail, 1, 101}, + {Ordered_Fail, 6, 100}, + {Ordered_Fail, 6, 101}, + + // Merge: 1<4<6<7<12, 6<100<101 + {Checkpoint, 0, 0}, + {Ordered, 100, 101}, + {SetOrder, 6, 100}, + {Ordered, 6, 100}, + {Ordered, 6, 101}, + {Ordered, 1, 101}, + + // Undo 2 times: 1<4<7<12, 1<6<7 + {Undo, 0, 0}, + {Undo, 0, 0}, + {Ordered, 1, 6}, + {Ordered, 4, 12}, + {Ordered_Fail, 4, 6}, + {SetOrder_Fail, 6, 1}, + + // Undo 2 times: 1<4<7<12 + {Undo, 0, 0}, + {Undo, 0, 0}, + {Ordered, 1, 12}, + {Ordered, 7, 12}, + {Ordered_Fail, 1, 6}, + {Ordered_Fail, 6, 7}, + {Ordered, 100, 101}, + {Ordered_Fail, 1, 101}, + + // Undo: 4<7<12 + {Undo, 0, 0}, + {Ordered_Fail, 1, 12}, + {Ordered_Fail, 1, 4}, + {Ordered, 4, 12}, + {Ordered, 100, 101}, + + // Undo: 100<101 + {Undo, 0, 0}, + {Ordered_Fail, 4, 7}, + {Ordered_Fail, 7, 12}, + {Ordered, 100, 101}, + + // Recreated DAG #1 from scratch, reusing same nodes. + // This also stresses that Undo has done its job correctly. + // DAG: 1<2<(5|6), 101<102<(105|106<107) + {Checkpoint, 0, 0}, + {SetOrder, 101, 102}, + {SetOrder, 102, 105}, + {SetOrder, 102, 106}, + {SetOrder, 106, 107}, + {SetOrder, 1, 2}, + {SetOrder, 2, 5}, + {SetOrder, 2, 6}, + {SetEqual_Fail, 1, 6}, + {SetEqual_Fail, 107, 102}, + + // Now Set 2 == 102 + // New DAG: (1|101)<2==102<(5|6|105|106<107) + {Checkpoint, 0, 0}, + {SetEqual, 2, 102}, + {Equal, 2, 102}, + {SetEqual, 2, 102}, // trivially pass + {SetNonEqual_Fail, 2, 102}, // trivially fail + {Ordered, 1, 107}, + {Ordered, 101, 6}, + {Ordered, 101, 105}, + {Ordered, 2, 106}, + {Ordered, 102, 6}, + + // Undo SetEqual + {Undo, 0, 0}, + {Equal_Fail, 2, 102}, + {Ordered_Fail, 2, 102}, + {Ordered_Fail, 1, 107}, + {Ordered_Fail, 101, 6}, + {Checkpoint, 0, 0}, + {SetEqual, 2, 100}, + {Ordered, 1, 107}, + {Ordered, 100, 6}, + + // SetEqual with new node + {Undo, 0, 0}, + {Checkpoint, 0, 0}, + {SetEqual, 2, 400}, + {SetEqual, 401, 2}, + {Equal, 400, 401}, + {Ordered, 1, 400}, + {Ordered, 400, 6}, + {Ordered, 1, 401}, + {Ordered, 401, 6}, + {Ordered_Fail, 2, 401}, + + // SetEqual unseen nodes and then connect + {Checkpoint, 0, 0}, + {SetEqual, 500, 501}, + {SetEqual, 102, 501}, + {Equal, 500, 102}, + {Ordered, 501, 106}, + {Ordered, 100, 500}, + {SetEqual, 500, 501}, + {Ordered_Fail, 500, 501}, + {Ordered_Fail, 102, 501}, + + // SetNonEqual relations + {Undo, 0, 0}, + {Checkpoint, 0, 0}, + {SetNonEqual, 600, 601}, + {NonEqual, 600, 601}, + {SetNonEqual, 601, 602}, + {NonEqual, 601, 602}, + {NonEqual_Fail, 600, 602}, // non-transitive + {SetEqual_Fail, 601, 602}, + + // Undo back to beginning, leave the poset empty + {Undo, 0, 0}, + {Undo, 0, 0}, + {Undo, 0, 0}, + {Undo, 0, 0}, + }) +} + +func TestPosetStrict(t *testing.T) { + + testPosetOps(t, false, []posetTestOp{ + {Checkpoint, 0, 0}, + // Build: 20!=30, 10<20<=30<40. The 20<=30 will become 20<30. + {SetNonEqual, 20, 30}, + {SetOrder, 10, 20}, + {SetOrderOrEqual, 20, 30}, // this is affected by 20!=30 + {SetOrder, 30, 40}, + + {Ordered, 10, 30}, + {Ordered, 20, 30}, + {Ordered, 10, 40}, + {OrderedOrEqual, 10, 30}, + {OrderedOrEqual, 20, 30}, + {OrderedOrEqual, 10, 40}, + + {Undo, 0, 0}, + + // Now do the opposite: first build the DAG and then learn non-equality + {Checkpoint, 0, 0}, + {SetOrder, 10, 20}, + {SetOrderOrEqual, 20, 30}, // this is affected by 20!=30 + {SetOrder, 30, 40}, + + {Ordered, 10, 30}, + {Ordered_Fail, 20, 30}, + {Ordered, 10, 40}, + {OrderedOrEqual, 10, 30}, + {OrderedOrEqual, 20, 30}, + {OrderedOrEqual, 10, 40}, + + {Checkpoint, 0, 0}, + {SetNonEqual, 20, 30}, + {Ordered, 10, 30}, + {Ordered, 20, 30}, + {Ordered, 10, 40}, + {OrderedOrEqual, 10, 30}, + {OrderedOrEqual, 20, 30}, + {OrderedOrEqual, 10, 40}, + {Undo, 0, 0}, + + {Checkpoint, 0, 0}, + {SetOrderOrEqual, 30, 35}, + {OrderedOrEqual, 20, 35}, + {Ordered_Fail, 20, 35}, + {SetNonEqual, 20, 35}, + {Ordered, 20, 35}, + {Undo, 0, 0}, + + // Learn <= and >= + {Checkpoint, 0, 0}, + {SetOrderOrEqual, 50, 60}, + {SetOrderOrEqual, 60, 50}, + {OrderedOrEqual, 50, 60}, + {OrderedOrEqual, 60, 50}, + {Ordered_Fail, 50, 60}, + {Ordered_Fail, 60, 50}, + {Equal, 50, 60}, + {Equal, 60, 50}, + {NonEqual_Fail, 50, 60}, + {NonEqual_Fail, 60, 50}, + {Undo, 0, 0}, + + {Undo, 0, 0}, + }) +} + +func TestPosetCollapse(t *testing.T) { + testPosetOps(t, false, []posetTestOp{ + {Checkpoint, 0, 0}, + // Create a complex graph of <= relations among nodes between 10 and 25. + {SetOrderOrEqual, 10, 15}, + {SetOrderOrEqual, 15, 20}, + {SetOrderOrEqual, 20, vconst(20)}, + {SetOrderOrEqual, vconst(20), 25}, + {SetOrderOrEqual, 10, 12}, + {SetOrderOrEqual, 12, 16}, + {SetOrderOrEqual, 16, vconst(20)}, + {SetOrderOrEqual, 10, 17}, + {SetOrderOrEqual, 17, 25}, + {SetOrderOrEqual, 15, 18}, + {SetOrderOrEqual, 18, vconst(20)}, + {SetOrderOrEqual, 15, 19}, + {SetOrderOrEqual, 19, 25}, + + // These are other paths not part of the main collapsing path + {SetOrderOrEqual, 10, 11}, + {SetOrderOrEqual, 11, 26}, + {SetOrderOrEqual, 13, 25}, + {SetOrderOrEqual, 100, 25}, + {SetOrderOrEqual, 101, 15}, + {SetOrderOrEqual, 102, 10}, + {SetOrderOrEqual, 25, 103}, + {SetOrderOrEqual, 20, 104}, + + {Checkpoint, 0, 0}, + // Collapse everything by setting 10 >= 25: this should make everything equal + {SetOrderOrEqual, 25, 10}, + + // Check that all nodes are pairwise equal now + {Equal, 10, 12}, + {Equal, 10, 15}, + {Equal, 10, 16}, + {Equal, 10, 17}, + {Equal, 10, 18}, + {Equal, 10, 19}, + {Equal, 10, vconst(20)}, + {Equal, 10, 25}, + + {Equal, 12, 15}, + {Equal, 12, 16}, + {Equal, 12, 17}, + {Equal, 12, 18}, + {Equal, 12, 19}, + {Equal, 12, vconst(20)}, + {Equal, 12, 25}, + + {Equal, 15, 16}, + {Equal, 15, 17}, + {Equal, 15, 18}, + {Equal, 15, 19}, + {Equal, 15, vconst(20)}, + {Equal, 15, 25}, + + {Equal, 16, 17}, + {Equal, 16, 18}, + {Equal, 16, 19}, + {Equal, 16, vconst(20)}, + {Equal, 16, 25}, + + {Equal, 17, 18}, + {Equal, 17, 19}, + {Equal, 17, vconst(20)}, + {Equal, 17, 25}, + + {Equal, 18, 19}, + {Equal, 18, vconst(20)}, + {Equal, 18, 25}, + + {Equal, 19, vconst(20)}, + {Equal, 19, 25}, + + {Equal, vconst(20), 25}, + + // ... but not 11/26/100/101/102, which were on a different path + {Equal_Fail, 10, 11}, + {Equal_Fail, 10, 26}, + {Equal_Fail, 10, 100}, + {Equal_Fail, 10, 101}, + {Equal_Fail, 10, 102}, + {OrderedOrEqual, 10, 26}, + {OrderedOrEqual, 25, 26}, + {OrderedOrEqual, 13, 25}, + {OrderedOrEqual, 13, 10}, + + {Undo, 0, 0}, + {OrderedOrEqual, 10, 25}, + {Equal_Fail, 10, 12}, + {Equal_Fail, 10, 15}, + {Equal_Fail, 10, 25}, + + {Undo, 0, 0}, + }) + + testPosetOps(t, false, []posetTestOp{ + {Checkpoint, 0, 0}, + {SetOrderOrEqual, 10, 15}, + {SetOrderOrEqual, 15, 20}, + {SetOrderOrEqual, 20, 25}, + {SetOrder, 10, 16}, + {SetOrderOrEqual, 16, 20}, + // Check that we cannot collapse here because of the strict relation 10<16 + {SetOrderOrEqual_Fail, 20, 10}, + {Undo, 0, 0}, + }) +} + +func TestPosetSetEqual(t *testing.T) { + testPosetOps(t, false, []posetTestOp{ + // 10<=20<=30<40, 20<=100<110 + {Checkpoint, 0, 0}, + {SetOrderOrEqual, 10, 20}, + {SetOrderOrEqual, 20, 30}, + {SetOrder, 30, 40}, + {SetOrderOrEqual, 20, 100}, + {SetOrder, 100, 110}, + {OrderedOrEqual, 10, 30}, + {OrderedOrEqual_Fail, 30, 10}, + {Ordered_Fail, 10, 30}, + {Ordered_Fail, 30, 10}, + {Ordered, 10, 40}, + {Ordered_Fail, 40, 10}, + + // Try learning 10==20. + {Checkpoint, 0, 0}, + {SetEqual, 10, 20}, + {OrderedOrEqual, 10, 20}, + {Ordered_Fail, 10, 20}, + {Equal, 10, 20}, + {SetOrderOrEqual, 10, 20}, + {SetOrderOrEqual, 20, 10}, + {SetOrder_Fail, 10, 20}, + {SetOrder_Fail, 20, 10}, + {Undo, 0, 0}, + + // Try learning 20==10. + {Checkpoint, 0, 0}, + {SetEqual, 20, 10}, + {OrderedOrEqual, 10, 20}, + {Ordered_Fail, 10, 20}, + {Equal, 10, 20}, + {Undo, 0, 0}, + + // Try learning 10==40 or 30==40 or 10==110. + {Checkpoint, 0, 0}, + {SetEqual_Fail, 10, 40}, + {SetEqual_Fail, 40, 10}, + {SetEqual_Fail, 30, 40}, + {SetEqual_Fail, 40, 30}, + {SetEqual_Fail, 10, 110}, + {SetEqual_Fail, 110, 10}, + {Undo, 0, 0}, + + // Try learning 40==110, and then 10==40 or 10=110 + {Checkpoint, 0, 0}, + {SetEqual, 40, 110}, + {SetEqual_Fail, 10, 40}, + {SetEqual_Fail, 40, 10}, + {SetEqual_Fail, 10, 110}, + {SetEqual_Fail, 110, 10}, + {Undo, 0, 0}, + + // Try learning 40<20 or 30<20 or 110<10 + {Checkpoint, 0, 0}, + {SetOrder_Fail, 40, 20}, + {SetOrder_Fail, 30, 20}, + {SetOrder_Fail, 110, 10}, + {Undo, 0, 0}, + + // Try learning 30<=20 + {Checkpoint, 0, 0}, + {SetOrderOrEqual, 30, 20}, + {Equal, 30, 20}, + {OrderedOrEqual, 30, 100}, + {Ordered, 30, 110}, + {Undo, 0, 0}, + + {Undo, 0, 0}, + }) +} + +func TestPosetNonEqual(t *testing.T) { + testPosetOps(t, false, []posetTestOp{ + {Equal_Fail, 10, 20}, + {NonEqual_Fail, 10, 20}, + + // Learn 10!=20 + {Checkpoint, 0, 0}, + {SetNonEqual, 10, 20}, + {Equal_Fail, 10, 20}, + {NonEqual, 10, 20}, + {SetEqual_Fail, 10, 20}, + + // Learn again 10!=20 + {Checkpoint, 0, 0}, + {SetNonEqual, 10, 20}, + {Equal_Fail, 10, 20}, + {NonEqual, 10, 20}, + + // Undo. We still know 10!=20 + {Undo, 0, 0}, + {Equal_Fail, 10, 20}, + {NonEqual, 10, 20}, + {SetEqual_Fail, 10, 20}, + + // Undo again. Now we know nothing + {Undo, 0, 0}, + {Equal_Fail, 10, 20}, + {NonEqual_Fail, 10, 20}, + + // Learn 10==20 + {Checkpoint, 0, 0}, + {SetEqual, 10, 20}, + {Equal, 10, 20}, + {NonEqual_Fail, 10, 20}, + {SetNonEqual_Fail, 10, 20}, + + // Learn again 10==20 + {Checkpoint, 0, 0}, + {SetEqual, 10, 20}, + {Equal, 10, 20}, + {NonEqual_Fail, 10, 20}, + {SetNonEqual_Fail, 10, 20}, + + // Undo. We still know 10==20 + {Undo, 0, 0}, + {Equal, 10, 20}, + {NonEqual_Fail, 10, 20}, + {SetNonEqual_Fail, 10, 20}, + + // Undo. We know nothing + {Undo, 0, 0}, + {Equal_Fail, 10, 20}, + {NonEqual_Fail, 10, 20}, + }) +} diff --git a/go/src/cmd/compile/internal/ssa/print.go b/go/src/cmd/compile/internal/ssa/print.go new file mode 100644 index 0000000000000000000000000000000000000000..ed7f1542497cf317621d3291b225b82b90b28e14 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/print.go @@ -0,0 +1,192 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "fmt" + "io" + "strings" + + "cmd/internal/hash" + "cmd/internal/src" +) + +func printFunc(f *Func) { + f.Logf("%s", f) +} + +func hashFunc(f *Func) []byte { + h := hash.New32() + p := stringFuncPrinter{w: h, printDead: true} + fprintFunc(p, f) + return h.Sum(nil) +} + +func (f *Func) String() string { + var buf strings.Builder + p := stringFuncPrinter{w: &buf, printDead: true} + fprintFunc(p, f) + return buf.String() +} + +// rewriteHash returns a hash of f suitable for detecting rewrite cycles. +func (f *Func) rewriteHash() string { + h := hash.New32() + p := stringFuncPrinter{w: h, printDead: false} + fprintFunc(p, f) + return fmt.Sprintf("%x", h.Sum(nil)) +} + +type funcPrinter interface { + header(f *Func) + startBlock(b *Block, reachable bool) + endBlock(b *Block, reachable bool) + value(v *Value, live bool) + startDepCycle() + endDepCycle() + named(n LocalSlot, vals []*Value) +} + +type stringFuncPrinter struct { + w io.Writer + printDead bool +} + +func (p stringFuncPrinter) header(f *Func) { + fmt.Fprint(p.w, f.Name) + fmt.Fprint(p.w, " ") + fmt.Fprintln(p.w, f.Type) +} + +func (p stringFuncPrinter) startBlock(b *Block, reachable bool) { + if !p.printDead && !reachable { + return + } + fmt.Fprintf(p.w, " b%d:", b.ID) + if len(b.Preds) > 0 { + io.WriteString(p.w, " <-") + for _, e := range b.Preds { + pred := e.b + fmt.Fprintf(p.w, " b%d", pred.ID) + } + } + if !reachable { + fmt.Fprint(p.w, " DEAD") + } + io.WriteString(p.w, "\n") +} + +func (p stringFuncPrinter) endBlock(b *Block, reachable bool) { + if !p.printDead && !reachable { + return + } + fmt.Fprintln(p.w, " "+b.LongString()) +} + +func StmtString(p src.XPos) string { + linenumber := "(?) " + if p.IsKnown() { + pfx := "" + if p.IsStmt() == src.PosIsStmt { + pfx = "+" + } + if p.IsStmt() == src.PosNotStmt { + pfx = "-" + } + linenumber = fmt.Sprintf("(%s%d) ", pfx, p.Line()) + } + return linenumber +} + +func (p stringFuncPrinter) value(v *Value, live bool) { + if !p.printDead && !live { + return + } + fmt.Fprintf(p.w, " %s", StmtString(v.Pos)) + fmt.Fprint(p.w, v.LongString()) + if !live { + fmt.Fprint(p.w, " DEAD") + } + fmt.Fprintln(p.w) +} + +func (p stringFuncPrinter) startDepCycle() { + fmt.Fprintln(p.w, "dependency cycle!") +} + +func (p stringFuncPrinter) endDepCycle() {} + +func (p stringFuncPrinter) named(n LocalSlot, vals []*Value) { + fmt.Fprintf(p.w, "name %s: %v\n", n, vals) +} + +func fprintFunc(p funcPrinter, f *Func) { + reachable, live := findlive(f) + defer f.Cache.freeBoolSlice(live) + p.header(f) + printed := make([]bool, f.NumValues()) + for _, b := range f.Blocks { + p.startBlock(b, reachable[b.ID]) + + if f.scheduled { + // Order of Values has been decided - print in that order. + for _, v := range b.Values { + p.value(v, live[v.ID]) + printed[v.ID] = true + } + p.endBlock(b, reachable[b.ID]) + continue + } + + // print phis first since all value cycles contain a phi + n := 0 + for _, v := range b.Values { + if v.Op != OpPhi { + continue + } + p.value(v, live[v.ID]) + printed[v.ID] = true + n++ + } + + // print rest of values in dependency order + for n < len(b.Values) { + m := n + outer: + for _, v := range b.Values { + if printed[v.ID] { + continue + } + for _, w := range v.Args { + // w == nil shouldn't happen, but if it does, + // don't panic; we'll get a better diagnosis later. + if w != nil && w.Block == b && !printed[w.ID] { + continue outer + } + } + p.value(v, live[v.ID]) + printed[v.ID] = true + n++ + } + if m == n { + p.startDepCycle() + for _, v := range b.Values { + if printed[v.ID] { + continue + } + p.value(v, live[v.ID]) + printed[v.ID] = true + n++ + } + p.endDepCycle() + } + } + + p.endBlock(b, reachable[b.ID]) + } + for _, name := range f.Names { + p.named(*name, f.NamedValues[*name]) + } +} diff --git a/go/src/cmd/compile/internal/ssa/prove.go b/go/src/cmd/compile/internal/ssa/prove.go new file mode 100644 index 0000000000000000000000000000000000000000..27afa8e33a628f336d4e64c613c0c5394e54e4d9 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/prove.go @@ -0,0 +1,3024 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "cmd/internal/src" + "cmp" + "fmt" + "math" + "math/bits" + "slices" + "strings" +) + +type branch int + +const ( + unknown branch = iota + positive + negative + // The outedges from a jump table are jumpTable0, + // jumpTable0+1, jumpTable0+2, etc. There could be an + // arbitrary number so we can't list them all here. + jumpTable0 +) + +func (b branch) String() string { + switch b { + case unknown: + return "unk" + case positive: + return "pos" + case negative: + return "neg" + default: + return fmt.Sprintf("jmp%d", b-jumpTable0) + } +} + +// relation represents the set of possible relations between +// pairs of variables (v, w). Without a priori knowledge the +// mask is lt | eq | gt meaning v can be less than, equal to or +// greater than w. When the execution path branches on the condition +// `v op w` the set of relations is updated to exclude any +// relation not possible due to `v op w` being true (or false). +// +// E.g. +// +// r := relation(...) +// +// if v < w { +// newR := r & lt +// } +// if v >= w { +// newR := r & (eq|gt) +// } +// if v != w { +// newR := r & (lt|gt) +// } +type relation uint + +const ( + lt relation = 1 << iota + eq + gt +) + +var relationStrings = [...]string{ + 0: "none", lt: "<", eq: "==", lt | eq: "<=", + gt: ">", gt | lt: "!=", gt | eq: ">=", gt | eq | lt: "any", +} + +func (r relation) String() string { + if r < relation(len(relationStrings)) { + return relationStrings[r] + } + return fmt.Sprintf("relation(%d)", uint(r)) +} + +// domain represents the domain of a variable pair in which a set +// of relations is known. For example, relations learned for unsigned +// pairs cannot be transferred to signed pairs because the same bit +// representation can mean something else. +type domain uint + +const ( + signed domain = 1 << iota + unsigned + pointer + boolean +) + +var domainStrings = [...]string{ + "signed", "unsigned", "pointer", "boolean", +} + +func (d domain) String() string { + s := "" + for i, ds := range domainStrings { + if d&(1<max or umin>umax, then this limit is +// called "unsatisfiable". When we encounter such a limit, we +// know that any code for which that limit applies is unreachable. +// We don't particularly care how unsatisfiable limits propagate, +// including becoming satisfiable, because any optimization +// decisions based on those limits only apply to unreachable code. +type limit struct { + min, max int64 // min <= value <= max, signed + umin, umax uint64 // umin <= value <= umax, unsigned + // For booleans, we use 0==false, 1==true for both ranges + // For pointers, we use 0,0,0,0 for nil and minInt64,maxInt64,1,maxUint64 for nonnil +} + +func (l limit) String() string { + return fmt.Sprintf("sm,SM=%d,%d um,UM=%d,%d", l.min, l.max, l.umin, l.umax) +} + +func (l limit) intersect(l2 limit) limit { + l.min = max(l.min, l2.min) + l.umin = max(l.umin, l2.umin) + l.max = min(l.max, l2.max) + l.umax = min(l.umax, l2.umax) + return l +} + +func (l limit) signedMin(m int64) limit { + l.min = max(l.min, m) + return l +} + +func (l limit) signedMinMax(minimum, maximum int64) limit { + l.min = max(l.min, minimum) + l.max = min(l.max, maximum) + return l +} + +func (l limit) unsignedMin(m uint64) limit { + l.umin = max(l.umin, m) + return l +} +func (l limit) unsignedMax(m uint64) limit { + l.umax = min(l.umax, m) + return l +} +func (l limit) unsignedMinMax(minimum, maximum uint64) limit { + l.umin = max(l.umin, minimum) + l.umax = min(l.umax, maximum) + return l +} + +func (l limit) nonzero() bool { + return l.min > 0 || l.umin > 0 || l.max < 0 +} +func (l limit) maybeZero() bool { + return !l.nonzero() +} +func (l limit) nonnegative() bool { + return l.min >= 0 +} +func (l limit) unsat() bool { + return l.min > l.max || l.umin > l.umax +} + +// If x and y can add without overflow or underflow +// (using b bits), safeAdd returns x+y, true. +// Otherwise, returns 0, false. +func safeAdd(x, y int64, b uint) (int64, bool) { + s := x + y + if x >= 0 && y >= 0 && s < 0 { + return 0, false // 64-bit overflow + } + if x < 0 && y < 0 && s >= 0 { + return 0, false // 64-bit underflow + } + if !fitsInBits(s, b) { + return 0, false + } + return s, true +} + +// same as safeAdd for unsigned arithmetic. +func safeAddU(x, y uint64, b uint) (uint64, bool) { + s := x + y + if s < x || s < y { + return 0, false // 64-bit overflow + } + if !fitsInBitsU(s, b) { + return 0, false + } + return s, true +} + +// same as safeAdd but for subtraction. +func safeSub(x, y int64, b uint) (int64, bool) { + if y == math.MinInt64 { + if x == math.MaxInt64 { + return 0, false // 64-bit overflow + } + x++ + y++ + } + return safeAdd(x, -y, b) +} + +// same as safeAddU but for subtraction. +func safeSubU(x, y uint64, b uint) (uint64, bool) { + if x < y { + return 0, false // 64-bit underflow + } + s := x - y + if !fitsInBitsU(s, b) { + return 0, false + } + return s, true +} + +// fitsInBits reports whether x fits in b bits (signed). +func fitsInBits(x int64, b uint) bool { + if b == 64 { + return true + } + m := int64(-1) << (b - 1) + M := -m - 1 + return x >= m && x <= M +} + +// fitsInBitsU reports whether x fits in b bits (unsigned). +func fitsInBitsU(x uint64, b uint) bool { + return x>>b == 0 +} + +func noLimitForBitsize(bitsize uint) limit { + return limit{min: -(1 << (bitsize - 1)), max: 1<<(bitsize-1) - 1, umin: 0, umax: 1<umax, and this + // multiply may overflow. But that's ok for + // unreachable code. If this code is reachable, we + // know umin<=umax, so this multiply will not overflow + // because the max multiply didn't. + } + // Signed is harder, so don't bother. The only useful + // case is when we know both multiplicands are nonnegative, + // but that case is handled above because we would have then + // previously propagated signed info to the unsigned domain, + // and will propagate it back after the multiply. + return r +} + +// Similar to add, but compute 1 << l if it fits without overflow in b bits. +func (l limit) exp2(b uint) limit { + r := noLimit + if l.umax < uint64(b) { + r.umin = 1 << l.umin + r.umax = 1 << l.umax + // Same as above in mul, signed<->unsigned propagation + // will handle the signed case for us. + } + return r +} + +// Similar to add, but computes the complement of the limit for bitsize b. +func (l limit) com(b uint) limit { + switch b { + case 64: + return limit{ + min: ^l.max, + max: ^l.min, + umin: ^l.umax, + umax: ^l.umin, + } + case 32: + return limit{ + min: int64(^int32(l.max)), + max: int64(^int32(l.min)), + umin: uint64(^uint32(l.umax)), + umax: uint64(^uint32(l.umin)), + } + case 16: + return limit{ + min: int64(^int16(l.max)), + max: int64(^int16(l.min)), + umin: uint64(^uint16(l.umax)), + umax: uint64(^uint16(l.umin)), + } + case 8: + return limit{ + min: int64(^int8(l.max)), + max: int64(^int8(l.min)), + umin: uint64(^uint8(l.umax)), + umax: uint64(^uint8(l.umin)), + } + default: + panic("unreachable") + } +} + +// Similar to add, but computes the negation of the limit for bitsize b. +func (l limit) neg(b uint) limit { + return l.com(b).add(limit{min: 1, max: 1, umin: 1, umax: 1}, b) +} + +var noLimit = limit{math.MinInt64, math.MaxInt64, 0, math.MaxUint64} + +// a limitFact is a limit known for a particular value. +type limitFact struct { + vid ID + limit limit +} + +// An ordering encodes facts like v < w. +type ordering struct { + next *ordering // linked list of all known orderings for v. + // Note: v is implicit here, determined by which linked list it is in. + w *Value + d domain + r relation // one of ==,!=,<,<=,>,>= + // if d is boolean or pointer, r can only be ==, != +} + +// factsTable keeps track of relations between pairs of values. +// +// The fact table logic is sound, but incomplete. Outside of a few +// special cases, it performs no deduction or arithmetic. While there +// are known decision procedures for this, the ad hoc approach taken +// by the facts table is effective for real code while remaining very +// efficient. +type factsTable struct { + // unsat is true if facts contains a contradiction. + // + // Note that the factsTable logic is incomplete, so if unsat + // is false, the assertions in factsTable could be satisfiable + // *or* unsatisfiable. + unsat bool // true if facts contains a contradiction + unsatDepth int // number of unsat checkpoints + + // order* is a couple of partial order sets that record information + // about relations between SSA values in the signed and unsigned + // domain. + orderS *poset + orderU *poset + + // orderings contains a list of known orderings between values. + // These lists are indexed by v.ID. + // We do not record transitive orderings. Only explicitly learned + // orderings are recorded. Transitive orderings can be obtained + // by walking along the individual orderings. + orderings map[ID]*ordering + // stack of IDs which have had an entry added in orderings. + // In addition, ID==0 are checkpoint markers. + orderingsStack []ID + orderingCache *ordering // unused ordering records + + // known lower and upper constant bounds on individual values. + limits []limit // indexed by value ID + limitStack []limitFact // previous entries + recurseCheck []bool // recursion detector for limit propagation + + // For each slice s, a map from s to a len(s)/cap(s) value (if any) + // TODO: check if there are cases that matter where we have + // more than one len(s) for a slice. We could keep a list if necessary. + lens map[ID]*Value + caps map[ID]*Value + + // reusedTopoSortScoresTable recycle allocations for topo-sort + reusedTopoSortScoresTable []uint +} + +// checkpointBound is an invalid value used for checkpointing +// and restoring factsTable. +var checkpointBound = limitFact{} + +func newFactsTable(f *Func) *factsTable { + ft := &factsTable{} + ft.orderS = f.newPoset() + ft.orderU = f.newPoset() + ft.orderS.SetUnsigned(false) + ft.orderU.SetUnsigned(true) + ft.orderings = make(map[ID]*ordering) + ft.limits = f.Cache.allocLimitSlice(f.NumValues()) + for _, b := range f.Blocks { + for _, v := range b.Values { + ft.limits[v.ID] = initLimit(v) + } + } + ft.limitStack = make([]limitFact, 4) + ft.recurseCheck = f.Cache.allocBoolSlice(f.NumValues()) + return ft +} + +// initLimitForNewValue initializes the limits for newly created values, +// possibly needing to expand the limits slice. Currently used by +// simplifyBlock when certain provably constant results are folded. +func (ft *factsTable) initLimitForNewValue(v *Value) { + if int(v.ID) >= len(ft.limits) { + f := v.Block.Func + n := f.NumValues() + if cap(ft.limits) >= n { + ft.limits = ft.limits[:n] + } else { + old := ft.limits + ft.limits = f.Cache.allocLimitSlice(n) + copy(ft.limits, old) + f.Cache.freeLimitSlice(old) + } + } + ft.limits[v.ID] = initLimit(v) +} + +// signedMin records the fact that we know v is at least +// min in the signed domain. +func (ft *factsTable) signedMin(v *Value, min int64) { + ft.newLimit(v, limit{min: min, max: math.MaxInt64, umin: 0, umax: math.MaxUint64}) +} + +// signedMax records the fact that we know v is at most +// max in the signed domain. +func (ft *factsTable) signedMax(v *Value, max int64) { + ft.newLimit(v, limit{min: math.MinInt64, max: max, umin: 0, umax: math.MaxUint64}) +} +func (ft *factsTable) signedMinMax(v *Value, min, max int64) { + ft.newLimit(v, limit{min: min, max: max, umin: 0, umax: math.MaxUint64}) +} + +// setNonNegative records the fact that v is known to be non-negative. +func (ft *factsTable) setNonNegative(v *Value) { + ft.signedMin(v, 0) +} + +// unsignedMin records the fact that we know v is at least +// min in the unsigned domain. +func (ft *factsTable) unsignedMin(v *Value, min uint64) { + ft.newLimit(v, limit{min: math.MinInt64, max: math.MaxInt64, umin: min, umax: math.MaxUint64}) +} + +// unsignedMax records the fact that we know v is at most +// max in the unsigned domain. +func (ft *factsTable) unsignedMax(v *Value, max uint64) { + ft.newLimit(v, limit{min: math.MinInt64, max: math.MaxInt64, umin: 0, umax: max}) +} +func (ft *factsTable) unsignedMinMax(v *Value, min, max uint64) { + ft.newLimit(v, limit{min: math.MinInt64, max: math.MaxInt64, umin: min, umax: max}) +} + +func (ft *factsTable) booleanFalse(v *Value) { + ft.newLimit(v, limit{min: 0, max: 0, umin: 0, umax: 0}) +} +func (ft *factsTable) booleanTrue(v *Value) { + ft.newLimit(v, limit{min: 1, max: 1, umin: 1, umax: 1}) +} +func (ft *factsTable) pointerNil(v *Value) { + ft.newLimit(v, limit{min: 0, max: 0, umin: 0, umax: 0}) +} +func (ft *factsTable) pointerNonNil(v *Value) { + l := noLimit + l.umin = 1 + ft.newLimit(v, l) +} + +// newLimit adds new limiting information for v. +func (ft *factsTable) newLimit(v *Value, newLim limit) { + oldLim := ft.limits[v.ID] + + // Merge old and new information. + lim := oldLim.intersect(newLim) + + // signed <-> unsigned propagation + if lim.min >= 0 { + lim = lim.unsignedMinMax(uint64(lim.min), uint64(lim.max)) + } + if fitsInBitsU(lim.umax, uint(8*v.Type.Size()-1)) { + lim = lim.signedMinMax(int64(lim.umin), int64(lim.umax)) + } + + if lim == oldLim { + return // nothing new to record + } + + if lim.unsat() { + ft.unsat = true + return + } + + // Check for recursion. This normally happens because in unsatisfiable + // cases we have a < b < a, and every update to a's limits returns + // here again with the limit increased by 2. + // Normally this is caught early by the orderS/orderU posets, but in + // cases where the comparisons jump between signed and unsigned domains, + // the posets will not notice. + if ft.recurseCheck[v.ID] { + // This should only happen for unsatisfiable cases. TODO: check + return + } + ft.recurseCheck[v.ID] = true + defer func() { + ft.recurseCheck[v.ID] = false + }() + + // Record undo information. + ft.limitStack = append(ft.limitStack, limitFact{v.ID, oldLim}) + // Record new information. + ft.limits[v.ID] = lim + if v.Block.Func.pass.debug > 2 { + // TODO: pos is probably wrong. This is the position where v is defined, + // not the position where we learned the fact about it (which was + // probably some subsequent compare+branch). + v.Block.Func.Warnl(v.Pos, "new limit %s %s unsat=%v", v, lim.String(), ft.unsat) + } + + // Propagate this new constant range to other values + // that we know are ordered with respect to this one. + // Note overflow/underflow in the arithmetic below is ok, + // it will just lead to imprecision (undetected unsatisfiability). + for o := ft.orderings[v.ID]; o != nil; o = o.next { + switch o.d { + case signed: + switch o.r { + case eq: // v == w + ft.signedMinMax(o.w, lim.min, lim.max) + case lt | eq: // v <= w + ft.signedMin(o.w, lim.min) + case lt: // v < w + ft.signedMin(o.w, lim.min+1) + case gt | eq: // v >= w + ft.signedMax(o.w, lim.max) + case gt: // v > w + ft.signedMax(o.w, lim.max-1) + case lt | gt: // v != w + if lim.min == lim.max { // v is a constant + c := lim.min + if ft.limits[o.w.ID].min == c { + ft.signedMin(o.w, c+1) + } + if ft.limits[o.w.ID].max == c { + ft.signedMax(o.w, c-1) + } + } + } + case unsigned: + switch o.r { + case eq: // v == w + ft.unsignedMinMax(o.w, lim.umin, lim.umax) + case lt | eq: // v <= w + ft.unsignedMin(o.w, lim.umin) + case lt: // v < w + ft.unsignedMin(o.w, lim.umin+1) + case gt | eq: // v >= w + ft.unsignedMax(o.w, lim.umax) + case gt: // v > w + ft.unsignedMax(o.w, lim.umax-1) + case lt | gt: // v != w + if lim.umin == lim.umax { // v is a constant + c := lim.umin + if ft.limits[o.w.ID].umin == c { + ft.unsignedMin(o.w, c+1) + } + if ft.limits[o.w.ID].umax == c { + ft.unsignedMax(o.w, c-1) + } + } + } + case boolean: + switch o.r { + case eq: + if lim.min == 0 && lim.max == 0 { // constant false + ft.booleanFalse(o.w) + } + if lim.min == 1 && lim.max == 1 { // constant true + ft.booleanTrue(o.w) + } + case lt | gt: + if lim.min == 0 && lim.max == 0 { // constant false + ft.booleanTrue(o.w) + } + if lim.min == 1 && lim.max == 1 { // constant true + ft.booleanFalse(o.w) + } + } + case pointer: + switch o.r { + case eq: + if lim.umax == 0 { // nil + ft.pointerNil(o.w) + } + if lim.umin > 0 { // non-nil + ft.pointerNonNil(o.w) + } + case lt | gt: + if lim.umax == 0 { // nil + ft.pointerNonNil(o.w) + } + // note: not equal to non-nil doesn't tell us anything. + } + } + } + + // If this is new known constant for a boolean value, + // extract relation between its args. For example, if + // We learn v is false, and v is defined as a=b. + if v.Type.IsBoolean() { + // If we reach here, it is because we have a more restrictive + // value for v than the default. The only two such values + // are constant true or constant false. + if lim.min != lim.max { + v.Block.Func.Fatalf("boolean not constant %v", v) + } + isTrue := lim.min == 1 + if dr, ok := domainRelationTable[v.Op]; ok && v.Op != OpIsInBounds && v.Op != OpIsSliceInBounds { + d := dr.d + r := dr.r + if d == signed && ft.isNonNegative(v.Args[0]) && ft.isNonNegative(v.Args[1]) { + d |= unsigned + } + if !isTrue { + r ^= lt | gt | eq + } + // TODO: v.Block is wrong? + addRestrictions(v.Block, ft, d, v.Args[0], v.Args[1], r) + } + switch v.Op { + case OpIsNonNil: + if isTrue { + ft.pointerNonNil(v.Args[0]) + } else { + ft.pointerNil(v.Args[0]) + } + case OpIsInBounds, OpIsSliceInBounds: + // 0 <= a0 < a1 (or 0 <= a0 <= a1) + r := lt + if v.Op == OpIsSliceInBounds { + r |= eq + } + if isTrue { + // On the positive branch, we learn: + // signed: 0 <= a0 < a1 (or 0 <= a0 <= a1) + // unsigned: a0 < a1 (or a0 <= a1) + ft.setNonNegative(v.Args[0]) + ft.update(v.Block, v.Args[0], v.Args[1], signed, r) + ft.update(v.Block, v.Args[0], v.Args[1], unsigned, r) + } else { + // On the negative branch, we learn (0 > a0 || + // a0 >= a1). In the unsigned domain, this is + // simply a0 >= a1 (which is the reverse of the + // positive branch, so nothing surprising). + // But in the signed domain, we can't express the || + // condition, so check if a0 is non-negative instead, + // to be able to learn something. + r ^= lt | gt | eq // >= (index) or > (slice) + if ft.isNonNegative(v.Args[0]) { + ft.update(v.Block, v.Args[0], v.Args[1], signed, r) + } + ft.update(v.Block, v.Args[0], v.Args[1], unsigned, r) + // TODO: v.Block is wrong here + } + } + } +} + +func (ft *factsTable) addOrdering(v, w *Value, d domain, r relation) { + o := ft.orderingCache + if o == nil { + o = &ordering{} + } else { + ft.orderingCache = o.next + } + o.w = w + o.d = d + o.r = r + o.next = ft.orderings[v.ID] + ft.orderings[v.ID] = o + ft.orderingsStack = append(ft.orderingsStack, v.ID) +} + +// update updates the set of relations between v and w in domain d +// restricting it to r. +func (ft *factsTable) update(parent *Block, v, w *Value, d domain, r relation) { + if parent.Func.pass.debug > 2 { + parent.Func.Warnl(parent.Pos, "parent=%s, update %s %s %s", parent, v, w, r) + } + // No need to do anything else if we already found unsat. + if ft.unsat { + return + } + + // Self-fact. It's wasteful to register it into the facts + // table, so just note whether it's satisfiable + if v == w { + if r&eq == 0 { + ft.unsat = true + } + return + } + + if d == signed || d == unsigned { + var ok bool + order := ft.orderS + if d == unsigned { + order = ft.orderU + } + switch r { + case lt: + ok = order.SetOrder(v, w) + case gt: + ok = order.SetOrder(w, v) + case lt | eq: + ok = order.SetOrderOrEqual(v, w) + case gt | eq: + ok = order.SetOrderOrEqual(w, v) + case eq: + ok = order.SetEqual(v, w) + case lt | gt: + ok = order.SetNonEqual(v, w) + default: + panic("unknown relation") + } + ft.addOrdering(v, w, d, r) + ft.addOrdering(w, v, d, reverseBits[r]) + + if !ok { + if parent.Func.pass.debug > 2 { + parent.Func.Warnl(parent.Pos, "unsat %s %s %s", v, w, r) + } + ft.unsat = true + return + } + } + if d == boolean || d == pointer { + for o := ft.orderings[v.ID]; o != nil; o = o.next { + if o.d == d && o.w == w { + // We already know a relationship between v and w. + // Either it is a duplicate, or it is a contradiction, + // as we only allow eq and lt|gt for these domains, + if o.r != r { + ft.unsat = true + } + return + } + } + // TODO: this does not do transitive equality. + // We could use a poset like above, but somewhat degenerate (==,!= only). + ft.addOrdering(v, w, d, r) + ft.addOrdering(w, v, d, r) // note: reverseBits unnecessary for eq and lt|gt. + } + + // Extract new constant limits based on the comparison. + vLimit := ft.limits[v.ID] + wLimit := ft.limits[w.ID] + // Note: all the +1/-1 below could overflow/underflow. Either will + // still generate correct results, it will just lead to imprecision. + // In fact if there is overflow/underflow, the corresponding + // code is unreachable because the known range is outside the range + // of the value's type. + switch d { + case signed: + switch r { + case eq: // v == w + ft.signedMinMax(v, wLimit.min, wLimit.max) + ft.signedMinMax(w, vLimit.min, vLimit.max) + case lt: // v < w + ft.signedMax(v, wLimit.max-1) + ft.signedMin(w, vLimit.min+1) + case lt | eq: // v <= w + ft.signedMax(v, wLimit.max) + ft.signedMin(w, vLimit.min) + case gt: // v > w + ft.signedMin(v, wLimit.min+1) + ft.signedMax(w, vLimit.max-1) + case gt | eq: // v >= w + ft.signedMin(v, wLimit.min) + ft.signedMax(w, vLimit.max) + case lt | gt: // v != w + if vLimit.min == vLimit.max { // v is a constant + c := vLimit.min + if wLimit.min == c { + ft.signedMin(w, c+1) + } + if wLimit.max == c { + ft.signedMax(w, c-1) + } + } + if wLimit.min == wLimit.max { // w is a constant + c := wLimit.min + if vLimit.min == c { + ft.signedMin(v, c+1) + } + if vLimit.max == c { + ft.signedMax(v, c-1) + } + } + } + case unsigned: + switch r { + case eq: // v == w + ft.unsignedMinMax(v, wLimit.umin, wLimit.umax) + ft.unsignedMinMax(w, vLimit.umin, vLimit.umax) + case lt: // v < w + ft.unsignedMax(v, wLimit.umax-1) + ft.unsignedMin(w, vLimit.umin+1) + case lt | eq: // v <= w + ft.unsignedMax(v, wLimit.umax) + ft.unsignedMin(w, vLimit.umin) + case gt: // v > w + ft.unsignedMin(v, wLimit.umin+1) + ft.unsignedMax(w, vLimit.umax-1) + case gt | eq: // v >= w + ft.unsignedMin(v, wLimit.umin) + ft.unsignedMax(w, vLimit.umax) + case lt | gt: // v != w + if vLimit.umin == vLimit.umax { // v is a constant + c := vLimit.umin + if wLimit.umin == c { + ft.unsignedMin(w, c+1) + } + if wLimit.umax == c { + ft.unsignedMax(w, c-1) + } + } + if wLimit.umin == wLimit.umax { // w is a constant + c := wLimit.umin + if vLimit.umin == c { + ft.unsignedMin(v, c+1) + } + if vLimit.umax == c { + ft.unsignedMax(v, c-1) + } + } + } + case boolean: + switch r { + case eq: // v == w + if vLimit.min == 1 { // v is true + ft.booleanTrue(w) + } + if vLimit.max == 0 { // v is false + ft.booleanFalse(w) + } + if wLimit.min == 1 { // w is true + ft.booleanTrue(v) + } + if wLimit.max == 0 { // w is false + ft.booleanFalse(v) + } + case lt | gt: // v != w + if vLimit.min == 1 { // v is true + ft.booleanFalse(w) + } + if vLimit.max == 0 { // v is false + ft.booleanTrue(w) + } + if wLimit.min == 1 { // w is true + ft.booleanFalse(v) + } + if wLimit.max == 0 { // w is false + ft.booleanTrue(v) + } + } + case pointer: + switch r { + case eq: // v == w + if vLimit.umax == 0 { // v is nil + ft.pointerNil(w) + } + if vLimit.umin > 0 { // v is non-nil + ft.pointerNonNil(w) + } + if wLimit.umax == 0 { // w is nil + ft.pointerNil(v) + } + if wLimit.umin > 0 { // w is non-nil + ft.pointerNonNil(v) + } + case lt | gt: // v != w + if vLimit.umax == 0 { // v is nil + ft.pointerNonNil(w) + } + if wLimit.umax == 0 { // w is nil + ft.pointerNonNil(v) + } + // Note: the other direction doesn't work. + // Being not equal to a non-nil pointer doesn't + // make you (necessarily) a nil pointer. + } + } + + // Derived facts below here are only about numbers. + if d != signed && d != unsigned { + return + } + + // Additional facts we know given the relationship between len and cap. + // + // TODO: Since prove now derives transitive relations, it + // should be sufficient to learn that len(w) <= cap(w) at the + // beginning of prove where we look for all len/cap ops. + if v.Op == OpSliceLen && r< == 0 && ft.caps[v.Args[0].ID] != nil { + // len(s) > w implies cap(s) > w + // len(s) >= w implies cap(s) >= w + // len(s) == w implies cap(s) >= w + ft.update(parent, ft.caps[v.Args[0].ID], w, d, r|gt) + } + if w.Op == OpSliceLen && r> == 0 && ft.caps[w.Args[0].ID] != nil { + // same, length on the RHS. + ft.update(parent, v, ft.caps[w.Args[0].ID], d, r|lt) + } + if v.Op == OpSliceCap && r> == 0 && ft.lens[v.Args[0].ID] != nil { + // cap(s) < w implies len(s) < w + // cap(s) <= w implies len(s) <= w + // cap(s) == w implies len(s) <= w + ft.update(parent, ft.lens[v.Args[0].ID], w, d, r|lt) + } + if w.Op == OpSliceCap && r< == 0 && ft.lens[w.Args[0].ID] != nil { + // same, capacity on the RHS. + ft.update(parent, v, ft.lens[w.Args[0].ID], d, r|gt) + } + + // Process fence-post implications. + // + // First, make the condition > or >=. + if r == lt || r == lt|eq { + v, w = w, v + r = reverseBits[r] + } + switch r { + case gt: + if x, delta := isConstDelta(v); x != nil && delta == 1 { + // x+1 > w ⇒ x >= w + // + // This is useful for eliminating the + // growslice branch of append. + ft.update(parent, x, w, d, gt|eq) + } else if x, delta := isConstDelta(w); x != nil && delta == -1 { + // v > x-1 ⇒ v >= x + ft.update(parent, v, x, d, gt|eq) + } + case gt | eq: + if x, delta := isConstDelta(v); x != nil && delta == -1 { + // x-1 >= w && x > min ⇒ x > w + // + // Useful for i > 0; s[i-1]. + lim := ft.limits[x.ID] + if (d == signed && lim.min > opMin[v.Op]) || (d == unsigned && lim.umin > 0) { + ft.update(parent, x, w, d, gt) + } + } else if x, delta := isConstDelta(w); x != nil && delta == 1 { + // v >= x+1 && x < max ⇒ v > x + lim := ft.limits[x.ID] + if (d == signed && lim.max < opMax[w.Op]) || (d == unsigned && lim.umax < opUMax[w.Op]) { + ft.update(parent, v, x, d, gt) + } + } + } + + // Process: x+delta > w (with delta constant) + // Only signed domain for now (useful for accesses to slices in loops). + if r == gt || r == gt|eq { + if x, delta := isConstDelta(v); x != nil && d == signed { + if parent.Func.pass.debug > 1 { + parent.Func.Warnl(parent.Pos, "x+d %s w; x:%v %v delta:%v w:%v d:%v", r, x, parent.String(), delta, w.AuxInt, d) + } + underflow := true + if delta < 0 { + l := ft.limits[x.ID] + if (x.Type.Size() == 8 && l.min >= math.MinInt64-delta) || + (x.Type.Size() == 4 && l.min >= math.MinInt32-delta) { + underflow = false + } + } + if delta < 0 && !underflow { + // If delta < 0 and x+delta cannot underflow then x > x+delta (that is, x > v) + ft.update(parent, x, v, signed, gt) + } + if !w.isGenericIntConst() { + // If we know that x+delta > w but w is not constant, we can derive: + // if delta < 0 and x+delta cannot underflow, then x > w + // This is useful for loops with bounds "len(slice)-K" (delta = -K) + if delta < 0 && !underflow { + ft.update(parent, x, w, signed, r) + } + } else { + // With w,delta constants, we want to derive: x+delta > w ⇒ x > w-delta + // + // We compute (using integers of the correct size): + // min = w - delta + // max = MaxInt - delta + // + // And we prove that: + // if minmax: min < x OR x <= max + // + // This is always correct, even in case of overflow. + // + // If the initial fact is x+delta >= w instead, the derived conditions are: + // if minmax: min <= x OR x <= max + // + // Notice the conditions for max are still <=, as they handle overflows. + var min, max int64 + switch x.Type.Size() { + case 8: + min = w.AuxInt - delta + max = int64(^uint64(0)>>1) - delta + case 4: + min = int64(int32(w.AuxInt) - int32(delta)) + max = int64(int32(^uint32(0)>>1) - int32(delta)) + case 2: + min = int64(int16(w.AuxInt) - int16(delta)) + max = int64(int16(^uint16(0)>>1) - int16(delta)) + case 1: + min = int64(int8(w.AuxInt) - int8(delta)) + max = int64(int8(^uint8(0)>>1) - int8(delta)) + default: + panic("unimplemented") + } + + if min < max { + // Record that x > min and max >= x + if r == gt { + min++ + } + ft.signedMinMax(x, min, max) + } else { + // We know that either x>min OR x<=max. factsTable cannot record OR conditions, + // so let's see if we can already prove that one of them is false, in which case + // the other must be true + l := ft.limits[x.ID] + if l.max <= min { + if r&eq == 0 || l.max < min { + // x>min (x>=min) is impossible, so it must be x<=max + ft.signedMax(x, max) + } + } else if l.min > max { + // x<=max is impossible, so it must be x>min + if r == gt { + min++ + } + ft.signedMin(x, min) + } + } + } + } + } + + // Look through value-preserving extensions. + // If the domain is appropriate for the pre-extension Type, + // repeat the update with the pre-extension Value. + if isCleanExt(v) { + switch { + case d == signed && v.Args[0].Type.IsSigned(): + fallthrough + case d == unsigned && !v.Args[0].Type.IsSigned(): + ft.update(parent, v.Args[0], w, d, r) + } + } + if isCleanExt(w) { + switch { + case d == signed && w.Args[0].Type.IsSigned(): + fallthrough + case d == unsigned && !w.Args[0].Type.IsSigned(): + ft.update(parent, v, w.Args[0], d, r) + } + } +} + +var opMin = map[Op]int64{ + OpAdd64: math.MinInt64, OpSub64: math.MinInt64, + OpAdd32: math.MinInt32, OpSub32: math.MinInt32, +} + +var opMax = map[Op]int64{ + OpAdd64: math.MaxInt64, OpSub64: math.MaxInt64, + OpAdd32: math.MaxInt32, OpSub32: math.MaxInt32, +} + +var opUMax = map[Op]uint64{ + OpAdd64: math.MaxUint64, OpSub64: math.MaxUint64, + OpAdd32: math.MaxUint32, OpSub32: math.MaxUint32, +} + +// isNonNegative reports whether v is known to be non-negative. +func (ft *factsTable) isNonNegative(v *Value) bool { + return ft.limits[v.ID].min >= 0 +} + +// checkpoint saves the current state of known relations. +// Called when descending on a branch. +func (ft *factsTable) checkpoint() { + if ft.unsat { + ft.unsatDepth++ + } + ft.limitStack = append(ft.limitStack, checkpointBound) + ft.orderS.Checkpoint() + ft.orderU.Checkpoint() + ft.orderingsStack = append(ft.orderingsStack, 0) +} + +// restore restores known relation to the state just +// before the previous checkpoint. +// Called when backing up on a branch. +func (ft *factsTable) restore() { + if ft.unsatDepth > 0 { + ft.unsatDepth-- + } else { + ft.unsat = false + } + for { + old := ft.limitStack[len(ft.limitStack)-1] + ft.limitStack = ft.limitStack[:len(ft.limitStack)-1] + if old.vid == 0 { // checkpointBound + break + } + ft.limits[old.vid] = old.limit + } + ft.orderS.Undo() + ft.orderU.Undo() + for { + id := ft.orderingsStack[len(ft.orderingsStack)-1] + ft.orderingsStack = ft.orderingsStack[:len(ft.orderingsStack)-1] + if id == 0 { // checkpoint marker + break + } + o := ft.orderings[id] + ft.orderings[id] = o.next + o.next = ft.orderingCache + ft.orderingCache = o + } +} + +var ( + reverseBits = [...]relation{0, 4, 2, 6, 1, 5, 3, 7} + + // maps what we learn when the positive branch is taken. + // For example: + // OpLess8: {signed, lt}, + // v1 = (OpLess8 v2 v3). + // If we learn that v1 is true, then we can deduce that v2 0 { + f.Cache.freeUintSlice(ft.reusedTopoSortScoresTable) + } +} + +// addSlicesOfSameLen finds the slices that are in the same block and whose Op +// is OpPhi and always have the same length, then add the equality relationship +// between them to ft. If two slices start out with the same length and decrease +// in length by the same amount on each round of the loop (or in the if block), +// then we think their lengths are always equal. +// +// See https://go.dev/issues/75144 +// +// In fact, we are just propagating the equality +// +// if len(a) == len(b) { // from here +// for len(a) > 4 { +// a = a[4:] +// b = b[4:] +// } +// if len(a) == len(b) { // to here +// return true +// } +// } +// +// or change the for to if: +// +// if len(a) == len(b) { // from here +// if len(a) > 4 { +// a = a[4:] +// b = b[4:] +// } +// if len(a) == len(b) { // to here +// return true +// } +// } +func addSlicesOfSameLen(ft *factsTable, b *Block) { + // Let w points to the first value we're interested in, and then we + // only process those values ​​that appear to be the same length as w, + // looping only once. This should be enough in most cases. And u is + // similar to w, see comment for predIndex. + var u, w *Value + var i, j, k sliceInfo + isInterested := func(v *Value) bool { + j = getSliceInfo(v) + return j.sliceWhere != sliceUnknown + } + for _, v := range b.Values { + if v.Uses == 0 { + continue + } + if v.Op == OpPhi && len(v.Args) == 2 && ft.lens[v.ID] != nil && isInterested(v) { + if j.predIndex == 1 && ft.lens[v.Args[0].ID] != nil { + // found v = (Phi x (SliceMake _ (Add64 (Const64 [n]) (SliceLen x)) _))) or + // v = (Phi x (SliceMake _ (Add64 (Const64 [n]) (SliceLen v)) _))) + if w == nil { + k = j + w = v + continue + } + // propagate the equality + if j == k && ft.orderS.Equal(ft.lens[v.Args[0].ID], ft.lens[w.Args[0].ID]) { + ft.update(b, ft.lens[v.ID], ft.lens[w.ID], signed, eq) + } + } else if j.predIndex == 0 && ft.lens[v.Args[1].ID] != nil { + // found v = (Phi (SliceMake _ (Add64 (Const64 [n]) (SliceLen x)) _)) x) or + // v = (Phi (SliceMake _ (Add64 (Const64 [n]) (SliceLen v)) _)) x) + if u == nil { + i = j + u = v + continue + } + // propagate the equality + if j == i && ft.orderS.Equal(ft.lens[v.Args[1].ID], ft.lens[u.Args[1].ID]) { + ft.update(b, ft.lens[v.ID], ft.lens[u.ID], signed, eq) + } + } + } + } +} + +type sliceWhere int + +const ( + sliceUnknown sliceWhere = iota + sliceInFor + sliceInIf +) + +// predIndex is used to indicate the branch represented by the predecessor +// block in which the slicing operation occurs. +type predIndex int + +type sliceInfo struct { + lengthDiff int64 + sliceWhere + predIndex +} + +// getSliceInfo returns the negative increment of the slice length in a slice +// operation by examine the Phi node at the merge block. So, we only interest +// in the slice operation if it is inside a for block or an if block. +// Otherwise it returns sliceInfo{0, sliceUnknown, 0}. +// +// For the following for block: +// +// for len(a) > 4 { +// a = a[4:] +// } +// +// vp = (Phi v3 v9) +// v5 = (SliceLen vp) +// v7 = (Add64 (Const64 [-4]) v5) +// v9 = (SliceMake _ v7 _) +// +// returns sliceInfo{-4, sliceInFor, 1} +// +// For a subsequent merge block after an if block: +// +// if len(a) > 4 { +// a = a[4:] +// } +// a // here +// +// vp = (Phi v3 v9) +// v5 = (SliceLen v3) +// v7 = (Add64 (Const64 [-4]) v5) +// v9 = (SliceMake _ v7 _) +// +// returns sliceInfo{-4, sliceInIf, 1} +// +// Returns sliceInfo{0, sliceUnknown, 0} if it is not the slice +// operation we are interested in. +func getSliceInfo(vp *Value) (inf sliceInfo) { + if vp.Op != OpPhi || len(vp.Args) != 2 { + return + } + var i predIndex + var l *Value // length for OpSliceMake + if vp.Args[0].Op != OpSliceMake && vp.Args[1].Op == OpSliceMake { + l = vp.Args[1].Args[1] + i = 1 + } else if vp.Args[0].Op == OpSliceMake && vp.Args[1].Op != OpSliceMake { + l = vp.Args[0].Args[1] + i = 0 + } else { + return + } + var op Op + switch l.Op { + case OpAdd64: + op = OpConst64 + case OpAdd32: + op = OpConst32 + default: + return + } + if l.Args[0].Op == op && l.Args[1].Op == OpSliceLen && l.Args[1].Args[0] == vp { + return sliceInfo{l.Args[0].AuxInt, sliceInFor, i} + } + if l.Args[1].Op == op && l.Args[0].Op == OpSliceLen && l.Args[0].Args[0] == vp { + return sliceInfo{l.Args[1].AuxInt, sliceInFor, i} + } + if l.Args[0].Op == op && l.Args[1].Op == OpSliceLen && l.Args[1].Args[0] == vp.Args[1-i] { + return sliceInfo{l.Args[0].AuxInt, sliceInIf, i} + } + if l.Args[1].Op == op && l.Args[0].Op == OpSliceLen && l.Args[0].Args[0] == vp.Args[1-i] { + return sliceInfo{l.Args[1].AuxInt, sliceInIf, i} + } + return +} + +// prove removes redundant BlockIf branches that can be inferred +// from previous dominating comparisons. +// +// By far, the most common redundant pair are generated by bounds checking. +// For example for the code: +// +// a[i] = 4 +// foo(a[i]) +// +// The compiler will generate the following code: +// +// if i >= len(a) { +// panic("not in bounds") +// } +// a[i] = 4 +// if i >= len(a) { +// panic("not in bounds") +// } +// foo(a[i]) +// +// The second comparison i >= len(a) is clearly redundant because if the +// else branch of the first comparison is executed, we already know that i < len(a). +// The code for the second panic can be removed. +// +// prove works by finding contradictions and trimming branches whose +// conditions are unsatisfiable given the branches leading up to them. +// It tracks a "fact table" of branch conditions. For each branching +// block, it asserts the branch conditions that uniquely dominate that +// block, and then separately asserts the block's branch condition and +// its negation. If either leads to a contradiction, it can trim that +// successor. +func prove(f *Func) { + // Find induction variables. Currently, findIndVars + // is limited to one induction variable per block. + var indVars map[*Block]indVar + for _, v := range findIndVar(f) { + ind := v.ind + if len(ind.Args) != 2 { + // the rewrite code assumes there is only ever two parents to loops + panic("unexpected induction with too many parents") + } + + nxt := v.nxt + if !(ind.Uses == 2 && // 2 used by comparison and next + nxt.Uses == 1) { // 1 used by induction + // ind or nxt is used inside the loop, add it for the facts table + if indVars == nil { + indVars = make(map[*Block]indVar) + } + indVars[v.entry] = v + continue + } else { + // Since this induction variable is not used for anything but counting the iterations, + // no point in putting it into the facts table. + } + } + + ft := newFactsTable(f) + ft.checkpoint() + + // Find length and capacity ops. + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Uses == 0 { + // We don't care about dead values. + // (There can be some that are CSEd but not removed yet.) + continue + } + switch v.Op { + case OpSliceLen: + if ft.lens == nil { + ft.lens = map[ID]*Value{} + } + // Set all len Values for the same slice as equal in the poset. + // The poset handles transitive relations, so Values related to + // any OpSliceLen for this slice will be correctly related to others. + if l, ok := ft.lens[v.Args[0].ID]; ok { + ft.update(b, v, l, signed, eq) + } else { + ft.lens[v.Args[0].ID] = v + } + case OpSliceCap: + if ft.caps == nil { + ft.caps = map[ID]*Value{} + } + // Same as case OpSliceLen above, but for slice cap. + if c, ok := ft.caps[v.Args[0].ID]; ok { + ft.update(b, v, c, signed, eq) + } else { + ft.caps[v.Args[0].ID] = v + } + } + } + } + + // current node state + type walkState int + const ( + descend walkState = iota + simplify + ) + // work maintains the DFS stack. + type bp struct { + block *Block // current handled block + state walkState // what's to do + } + work := make([]bp, 0, 256) + work = append(work, bp{ + block: f.Entry, + state: descend, + }) + + idom := f.Idom() + sdom := f.Sdom() + + // DFS on the dominator tree. + // + // For efficiency, we consider only the dominator tree rather + // than the entire flow graph. On the way down, we consider + // incoming branches and accumulate conditions that uniquely + // dominate the current block. If we discover a contradiction, + // we can eliminate the entire block and all of its children. + // On the way back up, we consider outgoing branches that + // haven't already been considered. This way we consider each + // branch condition only once. + for len(work) > 0 { + node := work[len(work)-1] + work = work[:len(work)-1] + parent := idom[node.block.ID] + branch := getBranch(sdom, parent, node.block) + + switch node.state { + case descend: + ft.checkpoint() + + // Entering the block, add facts about the induction variable + // that is bound to this block. + if iv, ok := indVars[node.block]; ok { + addIndVarRestrictions(ft, parent, iv) + } + + // Add results of reaching this block via a branch from + // its immediate dominator (if any). + if branch != unknown { + addBranchRestrictions(ft, parent, branch) + } + + // Add slices of the same length start from current block. + addSlicesOfSameLen(ft, node.block) + + if ft.unsat { + // node.block is unreachable. + // Remove it and don't visit + // its children. + removeBranch(parent, branch) + ft.restore() + break + } + // Otherwise, we can now commit to + // taking this branch. We'll restore + // ft when we unwind. + + // Add facts about the values in the current block. + addLocalFacts(ft, node.block) + + work = append(work, bp{ + block: node.block, + state: simplify, + }) + for s := sdom.Child(node.block); s != nil; s = sdom.Sibling(s) { + work = append(work, bp{ + block: s, + state: descend, + }) + } + + case simplify: + simplifyBlock(sdom, ft, node.block) + ft.restore() + } + } + + ft.restore() + + ft.cleanup(f) +} + +// initLimit sets initial constant limit for v. This limit is based +// only on the operation itself, not any of its input arguments. This +// method is only used in two places, once when the prove pass startup +// and the other when a new ssa value is created, both for init. (unlike +// flowLimit, below, which computes additional constraints based on +// ranges of opcode arguments). +func initLimit(v *Value) limit { + if v.Type.IsBoolean() { + switch v.Op { + case OpConstBool: + b := v.AuxInt + return limit{min: b, max: b, umin: uint64(b), umax: uint64(b)} + default: + return limit{min: 0, max: 1, umin: 0, umax: 1} + } + } + if v.Type.IsPtrShaped() { // These are the types that EqPtr/NeqPtr operate on, except uintptr. + switch v.Op { + case OpConstNil: + return limit{min: 0, max: 0, umin: 0, umax: 0} + case OpAddr, OpLocalAddr: // TODO: others? + l := noLimit + l.umin = 1 + return l + default: + return noLimit + } + } + if !v.Type.IsInteger() { + return noLimit + } + + // Default limits based on type. + lim := noLimitForBitsize(uint(v.Type.Size()) * 8) + + // Tighter limits on some opcodes. + switch v.Op { + // constants + case OpConst64: + lim = limit{min: v.AuxInt, max: v.AuxInt, umin: uint64(v.AuxInt), umax: uint64(v.AuxInt)} + case OpConst32: + lim = limit{min: v.AuxInt, max: v.AuxInt, umin: uint64(uint32(v.AuxInt)), umax: uint64(uint32(v.AuxInt))} + case OpConst16: + lim = limit{min: v.AuxInt, max: v.AuxInt, umin: uint64(uint16(v.AuxInt)), umax: uint64(uint16(v.AuxInt))} + case OpConst8: + lim = limit{min: v.AuxInt, max: v.AuxInt, umin: uint64(uint8(v.AuxInt)), umax: uint64(uint8(v.AuxInt))} + + // extensions + case OpZeroExt8to64, OpZeroExt8to32, OpZeroExt8to16: + lim = lim.signedMinMax(0, 1<<8-1) + lim = lim.unsignedMax(1<<8 - 1) + case OpZeroExt16to64, OpZeroExt16to32: + lim = lim.signedMinMax(0, 1<<16-1) + lim = lim.unsignedMax(1<<16 - 1) + case OpZeroExt32to64: + lim = lim.signedMinMax(0, 1<<32-1) + lim = lim.unsignedMax(1<<32 - 1) + case OpSignExt8to64, OpSignExt8to32, OpSignExt8to16: + lim = lim.signedMinMax(math.MinInt8, math.MaxInt8) + case OpSignExt16to64, OpSignExt16to32: + lim = lim.signedMinMax(math.MinInt16, math.MaxInt16) + case OpSignExt32to64: + lim = lim.signedMinMax(math.MinInt32, math.MaxInt32) + + // math/bits intrinsics + case OpCtz64, OpBitLen64, OpPopCount64, + OpCtz32, OpBitLen32, OpPopCount32, + OpCtz16, OpBitLen16, OpPopCount16, + OpCtz8, OpBitLen8, OpPopCount8: + lim = lim.unsignedMax(uint64(v.Args[0].Type.Size() * 8)) + + // bool to uint8 conversion + case OpCvtBoolToUint8: + lim = lim.unsignedMax(1) + + // length operations + case OpSliceLen, OpSliceCap: + f := v.Block.Func + elemSize := uint64(v.Args[0].Type.Elem().Size()) + if elemSize > 0 { + heapSize := uint64(1)<<(uint64(f.Config.PtrSize)*8) - 1 + maximumElementsFittingInHeap := heapSize / elemSize + lim = lim.unsignedMax(maximumElementsFittingInHeap) + } + fallthrough + case OpStringLen: + lim = lim.signedMin(0) + } + + // signed <-> unsigned propagation + if lim.min >= 0 { + lim = lim.unsignedMinMax(uint64(lim.min), uint64(lim.max)) + } + if fitsInBitsU(lim.umax, uint(8*v.Type.Size()-1)) { + lim = lim.signedMinMax(int64(lim.umin), int64(lim.umax)) + } + + return lim +} + +// flowLimit updates the known limits of v in ft. +// flowLimit can use the ranges of input arguments. +// +// Note: this calculation only happens at the point the value is defined. We do not reevaluate +// it later. So for example: +// +// v := x + y +// if 0 <= x && x < 5 && 0 <= y && y < 5 { ... use v ... } +// +// we don't discover that the range of v is bounded in the conditioned +// block. We could recompute the range of v once we enter the block so +// we know that it is 0 <= v <= 8, but we don't have a mechanism to do +// that right now. +func (ft *factsTable) flowLimit(v *Value) { + if !v.Type.IsInteger() { + // TODO: boolean? + return + } + + // Additional limits based on opcode and argument. + // No need to repeat things here already done in initLimit. + switch v.Op { + + // extensions + case OpZeroExt8to64, OpZeroExt8to32, OpZeroExt8to16, OpZeroExt16to64, OpZeroExt16to32, OpZeroExt32to64: + a := ft.limits[v.Args[0].ID] + ft.unsignedMinMax(v, a.umin, a.umax) + case OpSignExt8to64, OpSignExt8to32, OpSignExt8to16, OpSignExt16to64, OpSignExt16to32, OpSignExt32to64: + a := ft.limits[v.Args[0].ID] + ft.signedMinMax(v, a.min, a.max) + case OpTrunc64to8, OpTrunc64to16, OpTrunc64to32, OpTrunc32to8, OpTrunc32to16, OpTrunc16to8: + a := ft.limits[v.Args[0].ID] + if a.umax <= 1<<(uint64(v.Type.Size())*8)-1 { + ft.unsignedMinMax(v, a.umin, a.umax) + } + + // math/bits + case OpCtz64: + a := ft.limits[v.Args[0].ID] + if a.nonzero() { + ft.unsignedMax(v, uint64(bits.Len64(a.umax)-1)) + } + case OpCtz32: + a := ft.limits[v.Args[0].ID] + if a.nonzero() { + ft.unsignedMax(v, uint64(bits.Len32(uint32(a.umax))-1)) + } + case OpCtz16: + a := ft.limits[v.Args[0].ID] + if a.nonzero() { + ft.unsignedMax(v, uint64(bits.Len16(uint16(a.umax))-1)) + } + case OpCtz8: + a := ft.limits[v.Args[0].ID] + if a.nonzero() { + ft.unsignedMax(v, uint64(bits.Len8(uint8(a.umax))-1)) + } + + case OpPopCount64, OpPopCount32, OpPopCount16, OpPopCount8: + a := ft.limits[v.Args[0].ID] + changingBitsCount := uint64(bits.Len64(a.umax ^ a.umin)) + sharedLeadingMask := ^(uint64(1)<= 0 { + // Shift of negative makes a value closer to 0 (greater), + // so if a.min is negative, v.min is a.min>>b.min instead of a.min>>b.max, + // and similarly if a.max is negative, v.max is a.max>>b.max. + // Easier to compute min and max of both than to write sign logic. + vmin := min(a.min>>b.min, a.min>>b.max) + vmax := max(a.max>>b.min, a.max>>b.max) + ft.signedMinMax(v, vmin, vmax) + } + case OpRsh64Ux64, OpRsh64Ux32, OpRsh64Ux16, OpRsh64Ux8, + OpRsh32Ux64, OpRsh32Ux32, OpRsh32Ux16, OpRsh32Ux8, + OpRsh16Ux64, OpRsh16Ux32, OpRsh16Ux16, OpRsh16Ux8, + OpRsh8Ux64, OpRsh8Ux32, OpRsh8Ux16, OpRsh8Ux8: + a := ft.limits[v.Args[0].ID] + b := ft.limits[v.Args[1].ID] + if b.min >= 0 { + ft.unsignedMinMax(v, a.umin>>b.max, a.umax>>b.min) + } + case OpDiv64, OpDiv32, OpDiv16, OpDiv8: + a := ft.limits[v.Args[0].ID] + b := ft.limits[v.Args[1].ID] + if !(a.nonnegative() && b.nonnegative()) { + // TODO: we could handle signed limits but I didn't bother. + break + } + fallthrough + case OpDiv64u, OpDiv32u, OpDiv16u, OpDiv8u: + a := ft.limits[v.Args[0].ID] + b := ft.limits[v.Args[1].ID] + lim := noLimit + if b.umax > 0 { + lim = lim.unsignedMin(a.umin / b.umax) + } + if b.umin > 0 { + lim = lim.unsignedMax(a.umax / b.umin) + } + ft.newLimit(v, lim) + case OpMod64, OpMod32, OpMod16, OpMod8: + ft.modLimit(true, v, v.Args[0], v.Args[1]) + case OpMod64u, OpMod32u, OpMod16u, OpMod8u: + ft.modLimit(false, v, v.Args[0], v.Args[1]) + + case OpPhi: + // Compute the union of all the input phis. + // Often this will convey no information, because the block + // is not dominated by its predecessors and hence the + // phi arguments might not have been processed yet. But if + // the values are declared earlier, it may help. e.g., for + // v = phi(c3, c5) + // where c3 = OpConst [3] and c5 = OpConst [5] are + // defined in the entry block, we can derive [3,5] + // as the limit for v. + l := ft.limits[v.Args[0].ID] + for _, a := range v.Args[1:] { + l2 := ft.limits[a.ID] + l.min = min(l.min, l2.min) + l.max = max(l.max, l2.max) + l.umin = min(l.umin, l2.umin) + l.umax = max(l.umax, l2.umax) + } + ft.newLimit(v, l) + } +} + +// detectSliceLenRelation matches the pattern where +// 1. v := slicelen - index, OR v := slicecap - index +// AND +// 2. index <= slicelen - K +// THEN +// +// slicecap - index >= slicelen - index >= K +// +// Note that "index" is not used for indexing in this pattern, but +// in the motivating example (chunked slice iteration) it is. +func (ft *factsTable) detectSliceLenRelation(v *Value) { + if v.Op != OpSub64 { + return + } + + if !(v.Args[0].Op == OpSliceLen || v.Args[0].Op == OpStringLen || v.Args[0].Op == OpSliceCap) { + return + } + + index := v.Args[1] + if !ft.isNonNegative(index) { + return + } + slice := v.Args[0].Args[0] + + for o := ft.orderings[index.ID]; o != nil; o = o.next { + if o.d != signed { + continue + } + or := o.r + if or != lt && or != lt|eq { + continue + } + ow := o.w + if ow.Op != OpAdd64 && ow.Op != OpSub64 { + continue + } + var lenOffset *Value + if bound := ow.Args[0]; (bound.Op == OpSliceLen || bound.Op == OpStringLen) && bound.Args[0] == slice { + lenOffset = ow.Args[1] + } else if bound := ow.Args[1]; (bound.Op == OpSliceLen || bound.Op == OpStringLen) && bound.Args[0] == slice { + // Do not infer K - slicelen, see issue #76709. + if ow.Op == OpAdd64 { + lenOffset = ow.Args[0] + } + } + if lenOffset == nil || lenOffset.Op != OpConst64 { + continue + } + K := lenOffset.AuxInt + if ow.Op == OpAdd64 { + K = -K + } + if K < 0 { + continue + } + if or == lt { + K++ + } + if K < 0 { // We hate thinking about overflow + continue + } + ft.signedMin(v, K) + } +} + +// v must be Sub{64,32,16,8}. +func (ft *factsTable) detectSubRelations(v *Value) { + // v = x-y + x := v.Args[0] + y := v.Args[1] + if x == y { + ft.signedMinMax(v, 0, 0) + return + } + xLim := ft.limits[x.ID] + yLim := ft.limits[y.ID] + + // Check if we might wrap around. If so, give up. + width := uint(v.Type.Size()) * 8 + if _, ok := safeSub(xLim.min, yLim.max, width); !ok { + return // x-y might underflow + } + if _, ok := safeSub(xLim.max, yLim.min, width); !ok { + return // x-y might overflow + } + + // Subtracting a positive number only makes + // things smaller. + if yLim.min >= 0 { + ft.update(v.Block, v, x, signed, lt|eq) + // TODO: is this worth it? + //if yLim.min > 0 { + // ft.update(v.Block, v, x, signed, lt) + //} + } + + // Subtracting a number from a bigger one + // can't go below 0. + if ft.orderS.OrderedOrEqual(y, x) { + ft.setNonNegative(v) + // TODO: is this worth it? + //if ft.orderS.Ordered(y, x) { + // ft.signedMin(v, 1) + //} + } +} + +// x%d has been rewritten to x - (x/d)*d. +func (ft *factsTable) detectMod(v *Value) { + var opDiv, opDivU, opMul, opConst Op + switch v.Op { + case OpSub64: + opDiv = OpDiv64 + opDivU = OpDiv64u + opMul = OpMul64 + opConst = OpConst64 + case OpSub32: + opDiv = OpDiv32 + opDivU = OpDiv32u + opMul = OpMul32 + opConst = OpConst32 + case OpSub16: + opDiv = OpDiv16 + opDivU = OpDiv16u + opMul = OpMul16 + opConst = OpConst16 + case OpSub8: + opDiv = OpDiv8 + opDivU = OpDiv8u + opMul = OpMul8 + opConst = OpConst8 + } + + mul := v.Args[1] + if mul.Op != opMul { + return + } + div, con := mul.Args[0], mul.Args[1] + if div.Op == opConst { + div, con = con, div + } + if con.Op != opConst || (div.Op != opDiv && div.Op != opDivU) || div.Args[0] != v.Args[0] || div.Args[1].Op != opConst || div.Args[1].AuxInt != con.AuxInt { + return + } + ft.modLimit(div.Op == opDiv, v, v.Args[0], con) +} + +// modLimit sets v with facts derived from v = p % q. +func (ft *factsTable) modLimit(signed bool, v, p, q *Value) { + a := ft.limits[p.ID] + b := ft.limits[q.ID] + if signed { + if a.min < 0 && b.min > 0 { + ft.signedMinMax(v, -(b.max - 1), b.max-1) + return + } + if !(a.nonnegative() && b.nonnegative()) { + // TODO: we could handle signed limits but I didn't bother. + return + } + if a.min >= 0 && b.min > 0 { + ft.setNonNegative(v) + } + } + // Underflow in the arithmetic below is ok, it gives to MaxUint64 which does nothing to the limit. + ft.unsignedMax(v, min(a.umax, b.umax-1)) +} + +// getBranch returns the range restrictions added by p +// when reaching b. p is the immediate dominator of b. +func getBranch(sdom SparseTree, p *Block, b *Block) branch { + if p == nil { + return unknown + } + switch p.Kind { + case BlockIf: + // If p and p.Succs[0] are dominators it means that every path + // from entry to b passes through p and p.Succs[0]. We care that + // no path from entry to b passes through p.Succs[1]. If p.Succs[0] + // has one predecessor then (apart from the degenerate case), + // there is no path from entry that can reach b through p.Succs[1]. + // TODO: how about p->yes->b->yes, i.e. a loop in yes. + if sdom.IsAncestorEq(p.Succs[0].b, b) && len(p.Succs[0].b.Preds) == 1 { + return positive + } + if sdom.IsAncestorEq(p.Succs[1].b, b) && len(p.Succs[1].b.Preds) == 1 { + return negative + } + case BlockJumpTable: + // TODO: this loop can lead to quadratic behavior, as + // getBranch can be called len(p.Succs) times. + for i, e := range p.Succs { + if sdom.IsAncestorEq(e.b, b) && len(e.b.Preds) == 1 { + return jumpTable0 + branch(i) + } + } + } + return unknown +} + +// addIndVarRestrictions updates the factsTables ft with the facts +// learned from the induction variable indVar which drives the loop +// starting in Block b. +func addIndVarRestrictions(ft *factsTable, b *Block, iv indVar) { + d := signed + if ft.isNonNegative(iv.min) && ft.isNonNegative(iv.max) { + d |= unsigned + } + + if iv.flags&indVarMinExc == 0 { + addRestrictions(b, ft, d, iv.min, iv.ind, lt|eq) + } else { + addRestrictions(b, ft, d, iv.min, iv.ind, lt) + } + + if iv.flags&indVarMaxInc == 0 { + addRestrictions(b, ft, d, iv.ind, iv.max, lt) + } else { + addRestrictions(b, ft, d, iv.ind, iv.max, lt|eq) + } +} + +// addBranchRestrictions updates the factsTables ft with the facts learned when +// branching from Block b in direction br. +func addBranchRestrictions(ft *factsTable, b *Block, br branch) { + c := b.Controls[0] + switch { + case br == negative: + ft.booleanFalse(c) + case br == positive: + ft.booleanTrue(c) + case br >= jumpTable0: + idx := br - jumpTable0 + val := int64(idx) + if v, off := isConstDelta(c); v != nil { + // Establish the bound on the underlying value we're switching on, + // not on the offset-ed value used as the jump table index. + c = v + val -= off + } + ft.newLimit(c, limit{min: val, max: val, umin: uint64(val), umax: uint64(val)}) + default: + panic("unknown branch") + } +} + +// addRestrictions updates restrictions from the immediate +// dominating block (p) using r. +func addRestrictions(parent *Block, ft *factsTable, t domain, v, w *Value, r relation) { + if t == 0 { + // Trivial case: nothing to do. + // Should not happen, but just in case. + return + } + for i := domain(1); i <= t; i <<= 1 { + if t&i == 0 { + continue + } + ft.update(parent, v, w, i, r) + } +} + +func unsignedAddOverflows(a, b uint64, t *types.Type) bool { + switch t.Size() { + case 8: + return a+b < a + case 4: + return a+b > math.MaxUint32 + case 2: + return a+b > math.MaxUint16 + case 1: + return a+b > math.MaxUint8 + default: + panic("unreachable") + } +} + +func signedAddOverflowsOrUnderflows(a, b int64, t *types.Type) bool { + r := a + b + switch t.Size() { + case 8: + return (a >= 0 && b >= 0 && r < 0) || (a < 0 && b < 0 && r >= 0) + case 4: + return r < math.MinInt32 || math.MaxInt32 < r + case 2: + return r < math.MinInt16 || math.MaxInt16 < r + case 1: + return r < math.MinInt8 || math.MaxInt8 < r + default: + panic("unreachable") + } +} + +func unsignedSubUnderflows(a, b uint64) bool { + return a < b +} + +// checkForChunkedIndexBounds looks for index expressions of the form +// A[i+delta] where delta < K and i <= len(A)-K. That is, this is a chunked +// iteration where the index is not directly compared to the length. +// if isReslice, then delta can be equal to K. +func checkForChunkedIndexBounds(ft *factsTable, b *Block, index, bound *Value, isReslice bool) bool { + if bound.Op != OpSliceLen && bound.Op != OpStringLen && bound.Op != OpSliceCap { + return false + } + + // this is a slice bounds check against len or capacity, + // and refers back to a prior check against length, which + // will also work for the cap since that is not smaller + // than the length. + + slice := bound.Args[0] + lim := ft.limits[index.ID] + if lim.min < 0 { + return false + } + i, delta := isConstDelta(index) + if i == nil { + return false + } + if delta < 0 { + return false + } + // special case for blocked iteration over a slice. + // slicelen > i + delta && <==== if clauses above + // && index >= 0 <==== if clause above + // delta >= 0 && <==== if clause above + // slicelen-K >/>= x <==== checked below + // && K >=/> delta <==== checked below + // then v > w + // example: i <=/< len - 4/3 means i+{0,1,2,3} are legal indices + for o := ft.orderings[i.ID]; o != nil; o = o.next { + if o.d != signed { + continue + } + if ow := o.w; ow.Op == OpAdd64 { + var lenOffset *Value + if bound := ow.Args[0]; (bound.Op == OpSliceLen || bound.Op == OpStringLen) && bound.Args[0] == slice { + lenOffset = ow.Args[1] + } else if bound := ow.Args[1]; (bound.Op == OpSliceLen || bound.Op == OpStringLen) && bound.Args[0] == slice { + lenOffset = ow.Args[0] + } + if lenOffset == nil || lenOffset.Op != OpConst64 { + continue + } + if K := -lenOffset.AuxInt; K >= 0 { + or := o.r + if isReslice { + K++ + } + if or == lt { + or = lt | eq + K++ + } + if K < 0 { // We hate thinking about overflow + continue + } + + if delta < K && or == lt|eq { + return true + } + } + } + } + return false +} + +func addLocalFacts(ft *factsTable, b *Block) { + ft.topoSortValuesInBlock(b) + + for _, v := range b.Values { + // Propagate constant ranges before relative relations to get + // the most up-to-date constant bounds for isNonNegative calls. + ft.flowLimit(v) + + switch v.Op { + case OpAdd64, OpAdd32, OpAdd16, OpAdd8: + x := ft.limits[v.Args[0].ID] + y := ft.limits[v.Args[1].ID] + if !unsignedAddOverflows(x.umax, y.umax, v.Type) { + r := gt + if x.maybeZero() { + r |= eq + } + ft.update(b, v, v.Args[1], unsigned, r) + r = gt + if y.maybeZero() { + r |= eq + } + ft.update(b, v, v.Args[0], unsigned, r) + } + if x.min >= 0 && !signedAddOverflowsOrUnderflows(x.max, y.max, v.Type) { + r := gt + if x.maybeZero() { + r |= eq + } + ft.update(b, v, v.Args[1], signed, r) + } + if y.min >= 0 && !signedAddOverflowsOrUnderflows(x.max, y.max, v.Type) { + r := gt + if y.maybeZero() { + r |= eq + } + ft.update(b, v, v.Args[0], signed, r) + } + if x.max <= 0 && !signedAddOverflowsOrUnderflows(x.min, y.min, v.Type) { + r := lt + if x.maybeZero() { + r |= eq + } + ft.update(b, v, v.Args[1], signed, r) + } + if y.max <= 0 && !signedAddOverflowsOrUnderflows(x.min, y.min, v.Type) { + r := lt + if y.maybeZero() { + r |= eq + } + ft.update(b, v, v.Args[0], signed, r) + } + case OpSub64, OpSub32, OpSub16, OpSub8: + x := ft.limits[v.Args[0].ID] + y := ft.limits[v.Args[1].ID] + if !unsignedSubUnderflows(x.umin, y.umax) { + r := lt + if y.maybeZero() { + r |= eq + } + ft.update(b, v, v.Args[0], unsigned, r) + } + // FIXME: we could also do signed facts but the overflow checks are much trickier and I don't need it yet. + case OpAnd64, OpAnd32, OpAnd16, OpAnd8: + ft.update(b, v, v.Args[0], unsigned, lt|eq) + ft.update(b, v, v.Args[1], unsigned, lt|eq) + if ft.isNonNegative(v.Args[0]) { + ft.update(b, v, v.Args[0], signed, lt|eq) + } + if ft.isNonNegative(v.Args[1]) { + ft.update(b, v, v.Args[1], signed, lt|eq) + } + case OpOr64, OpOr32, OpOr16, OpOr8: + // TODO: investigate how to always add facts without much slowdown, see issue #57959 + //ft.update(b, v, v.Args[0], unsigned, gt|eq) + //ft.update(b, v, v.Args[1], unsigned, gt|eq) + case OpDiv64, OpDiv32, OpDiv16, OpDiv8: + if !ft.isNonNegative(v.Args[1]) { + break + } + fallthrough + case OpRsh8x64, OpRsh8x32, OpRsh8x16, OpRsh8x8, + OpRsh16x64, OpRsh16x32, OpRsh16x16, OpRsh16x8, + OpRsh32x64, OpRsh32x32, OpRsh32x16, OpRsh32x8, + OpRsh64x64, OpRsh64x32, OpRsh64x16, OpRsh64x8: + if !ft.isNonNegative(v.Args[0]) { + break + } + fallthrough + case OpDiv64u, OpDiv32u, OpDiv16u, OpDiv8u, + OpRsh8Ux64, OpRsh8Ux32, OpRsh8Ux16, OpRsh8Ux8, + OpRsh16Ux64, OpRsh16Ux32, OpRsh16Ux16, OpRsh16Ux8, + OpRsh32Ux64, OpRsh32Ux32, OpRsh32Ux16, OpRsh32Ux8, + OpRsh64Ux64, OpRsh64Ux32, OpRsh64Ux16, OpRsh64Ux8: + switch add := v.Args[0]; add.Op { + // round-up division pattern; given: + // v = (x + y) / z + // if y < z then v <= x + case OpAdd64, OpAdd32, OpAdd16, OpAdd8: + z := v.Args[1] + zl := ft.limits[z.ID] + var uminDivisor uint64 + switch v.Op { + case OpDiv64u, OpDiv32u, OpDiv16u, OpDiv8u, + OpDiv64, OpDiv32, OpDiv16, OpDiv8: + uminDivisor = zl.umin + case OpRsh8Ux64, OpRsh8Ux32, OpRsh8Ux16, OpRsh8Ux8, + OpRsh16Ux64, OpRsh16Ux32, OpRsh16Ux16, OpRsh16Ux8, + OpRsh32Ux64, OpRsh32Ux32, OpRsh32Ux16, OpRsh32Ux8, + OpRsh64Ux64, OpRsh64Ux32, OpRsh64Ux16, OpRsh64Ux8, + OpRsh8x64, OpRsh8x32, OpRsh8x16, OpRsh8x8, + OpRsh16x64, OpRsh16x32, OpRsh16x16, OpRsh16x8, + OpRsh32x64, OpRsh32x32, OpRsh32x16, OpRsh32x8, + OpRsh64x64, OpRsh64x32, OpRsh64x16, OpRsh64x8: + uminDivisor = 1 << zl.umin + default: + panic("unreachable") + } + + x := add.Args[0] + xl := ft.limits[x.ID] + y := add.Args[1] + yl := ft.limits[y.ID] + if !unsignedAddOverflows(xl.umax, yl.umax, add.Type) { + if xl.umax < uminDivisor { + ft.update(b, v, y, unsigned, lt|eq) + } + if yl.umax < uminDivisor { + ft.update(b, v, x, unsigned, lt|eq) + } + } + } + ft.update(b, v, v.Args[0], unsigned, lt|eq) + case OpMod64, OpMod32, OpMod16, OpMod8: + if !ft.isNonNegative(v.Args[0]) || !ft.isNonNegative(v.Args[1]) { + break + } + fallthrough + case OpMod64u, OpMod32u, OpMod16u, OpMod8u: + ft.update(b, v, v.Args[0], unsigned, lt|eq) + // Note: we have to be careful that this doesn't imply + // that the modulus is >0, which isn't true until *after* + // the mod instruction executes (and thus panics if the + // modulus is 0). See issue 67625. + ft.update(b, v, v.Args[1], unsigned, lt) + case OpStringLen: + if v.Args[0].Op == OpStringMake { + ft.update(b, v, v.Args[0].Args[1], signed, eq) + } + case OpSliceLen: + if v.Args[0].Op == OpSliceMake { + ft.update(b, v, v.Args[0].Args[1], signed, eq) + } + case OpSliceCap: + if v.Args[0].Op == OpSliceMake { + ft.update(b, v, v.Args[0].Args[2], signed, eq) + } + case OpIsInBounds: + if checkForChunkedIndexBounds(ft, b, v.Args[0], v.Args[1], false) { + if b.Func.pass.debug > 0 { + b.Func.Warnl(v.Pos, "Proved %s for blocked indexing", v.Op) + } + ft.booleanTrue(v) + } + case OpIsSliceInBounds: + if checkForChunkedIndexBounds(ft, b, v.Args[0], v.Args[1], true) { + if b.Func.pass.debug > 0 { + b.Func.Warnl(v.Pos, "Proved %s for blocked reslicing", v.Op) + } + ft.booleanTrue(v) + } + case OpPhi: + addLocalFactsPhi(ft, v) + } + } +} + +func addLocalFactsPhi(ft *factsTable, v *Value) { + // Look for phis that implement min/max. + // z: + // c = Less64 x y (or other Less/Leq operation) + // If c -> bx by + // bx: <- z + // -> b ... + // by: <- z + // -> b ... + // b: <- bx by + // v = Phi x y + // Then v is either min or max of x,y. + // If it is the min, then we deduce v <= x && v <= y. + // If it is the max, then we deduce v >= x && v >= y. + // The min case is useful for the copy builtin, see issue 16833. + if len(v.Args) != 2 { + return + } + b := v.Block + x := v.Args[0] + y := v.Args[1] + bx := b.Preds[0].b + by := b.Preds[1].b + var z *Block // branch point + switch { + case bx == by: // bx == by == z case + z = bx + case by.uniquePred() == bx: // bx == z case + z = bx + case bx.uniquePred() == by: // by == z case + z = by + case bx.uniquePred() == by.uniquePred(): + z = bx.uniquePred() + } + if z == nil || z.Kind != BlockIf { + return + } + c := z.Controls[0] + if len(c.Args) != 2 { + return + } + var isMin bool // if c, a less-than comparison, is true, phi chooses x. + if bx == z { + isMin = b.Preds[0].i == 0 + } else { + isMin = bx.Preds[0].i == 0 + } + if c.Args[0] == x && c.Args[1] == y { + // ok + } else if c.Args[0] == y && c.Args[1] == x { + // Comparison is reversed from how the values are listed in the Phi. + isMin = !isMin + } else { + // Not comparing x and y. + return + } + var dom domain + switch c.Op { + case OpLess64, OpLess32, OpLess16, OpLess8, OpLeq64, OpLeq32, OpLeq16, OpLeq8: + dom = signed + case OpLess64U, OpLess32U, OpLess16U, OpLess8U, OpLeq64U, OpLeq32U, OpLeq16U, OpLeq8U: + dom = unsigned + default: + return + } + var rel relation + if isMin { + rel = lt | eq + } else { + rel = gt | eq + } + ft.update(b, v, x, dom, rel) + ft.update(b, v, y, dom, rel) +} + +var ctzNonZeroOp = map[Op]Op{ + OpCtz8: OpCtz8NonZero, + OpCtz16: OpCtz16NonZero, + OpCtz32: OpCtz32NonZero, + OpCtz64: OpCtz64NonZero, +} +var mostNegativeDividend = map[Op]int64{ + OpDiv16: -1 << 15, + OpMod16: -1 << 15, + OpDiv32: -1 << 31, + OpMod32: -1 << 31, + OpDiv64: -1 << 63, + OpMod64: -1 << 63, +} +var unsignedOp = map[Op]Op{ + OpDiv8: OpDiv8u, + OpDiv16: OpDiv16u, + OpDiv32: OpDiv32u, + OpDiv64: OpDiv64u, + OpMod8: OpMod8u, + OpMod16: OpMod16u, + OpMod32: OpMod32u, + OpMod64: OpMod64u, + OpRsh8x8: OpRsh8Ux8, + OpRsh8x16: OpRsh8Ux16, + OpRsh8x32: OpRsh8Ux32, + OpRsh8x64: OpRsh8Ux64, + OpRsh16x8: OpRsh16Ux8, + OpRsh16x16: OpRsh16Ux16, + OpRsh16x32: OpRsh16Ux32, + OpRsh16x64: OpRsh16Ux64, + OpRsh32x8: OpRsh32Ux8, + OpRsh32x16: OpRsh32Ux16, + OpRsh32x32: OpRsh32Ux32, + OpRsh32x64: OpRsh32Ux64, + OpRsh64x8: OpRsh64Ux8, + OpRsh64x16: OpRsh64Ux16, + OpRsh64x32: OpRsh64Ux32, + OpRsh64x64: OpRsh64Ux64, +} + +var bytesizeToConst = [...]Op{ + 8 / 8: OpConst8, + 16 / 8: OpConst16, + 32 / 8: OpConst32, + 64 / 8: OpConst64, +} +var bytesizeToNeq = [...]Op{ + 8 / 8: OpNeq8, + 16 / 8: OpNeq16, + 32 / 8: OpNeq32, + 64 / 8: OpNeq64, +} +var bytesizeToAnd = [...]Op{ + 8 / 8: OpAnd8, + 16 / 8: OpAnd16, + 32 / 8: OpAnd32, + 64 / 8: OpAnd64, +} + +// simplifyBlock simplifies some constant values in b and evaluates +// branches to non-uniquely dominated successors of b. +func simplifyBlock(sdom SparseTree, ft *factsTable, b *Block) { + for iv, v := range b.Values { + switch v.Op { + case OpStaticLECall: + if b.Func.pass.debug > 0 && len(v.Args) == 2 { + fn := auxToCall(v.Aux).Fn + if fn != nil && strings.Contains(fn.String(), "prove") { + // Print bounds of any argument to single-arg function with "prove" in name, + // for debugging and especially for test/prove.go. + // (v.Args[1] is mem). + x := v.Args[0] + b.Func.Warnl(v.Pos, "Proved %v (%v)", ft.limits[x.ID], x) + } + } + case OpSlicemask: + // Replace OpSlicemask operations in b with constants where possible. + cap := v.Args[0] + x, delta := isConstDelta(cap) + if x != nil { + // slicemask(x + y) + // if x is larger than -y (y is negative), then slicemask is -1. + lim := ft.limits[x.ID] + if lim.umin > uint64(-delta) { + if cap.Op == OpAdd64 { + v.reset(OpConst64) + } else { + v.reset(OpConst32) + } + if b.Func.pass.debug > 0 { + b.Func.Warnl(v.Pos, "Proved slicemask not needed") + } + v.AuxInt = -1 + } + break + } + lim := ft.limits[cap.ID] + if lim.umin > 0 { + if cap.Type.Size() == 8 { + v.reset(OpConst64) + } else { + v.reset(OpConst32) + } + if b.Func.pass.debug > 0 { + b.Func.Warnl(v.Pos, "Proved slicemask not needed (by limit)") + } + v.AuxInt = -1 + } + + case OpCtz8, OpCtz16, OpCtz32, OpCtz64: + // On some architectures, notably amd64, we can generate much better + // code for CtzNN if we know that the argument is non-zero. + // Capture that information here for use in arch-specific optimizations. + x := v.Args[0] + lim := ft.limits[x.ID] + if lim.umin > 0 || lim.min > 0 || lim.max < 0 { + if b.Func.pass.debug > 0 { + b.Func.Warnl(v.Pos, "Proved %v non-zero", v.Op) + } + v.Op = ctzNonZeroOp[v.Op] + } + case OpRsh8x8, OpRsh8x16, OpRsh8x32, OpRsh8x64, + OpRsh16x8, OpRsh16x16, OpRsh16x32, OpRsh16x64, + OpRsh32x8, OpRsh32x16, OpRsh32x32, OpRsh32x64, + OpRsh64x8, OpRsh64x16, OpRsh64x32, OpRsh64x64: + if ft.isNonNegative(v.Args[0]) { + if b.Func.pass.debug > 0 { + b.Func.Warnl(v.Pos, "Proved %v is unsigned", v.Op) + } + v.Op = unsignedOp[v.Op] + } + fallthrough + case OpLsh8x8, OpLsh8x16, OpLsh8x32, OpLsh8x64, + OpLsh16x8, OpLsh16x16, OpLsh16x32, OpLsh16x64, + OpLsh32x8, OpLsh32x16, OpLsh32x32, OpLsh32x64, + OpLsh64x8, OpLsh64x16, OpLsh64x32, OpLsh64x64, + OpRsh8Ux8, OpRsh8Ux16, OpRsh8Ux32, OpRsh8Ux64, + OpRsh16Ux8, OpRsh16Ux16, OpRsh16Ux32, OpRsh16Ux64, + OpRsh32Ux8, OpRsh32Ux16, OpRsh32Ux32, OpRsh32Ux64, + OpRsh64Ux8, OpRsh64Ux16, OpRsh64Ux32, OpRsh64Ux64: + // Check whether, for a << b, we know that b + // is strictly less than the number of bits in a. + by := v.Args[1] + lim := ft.limits[by.ID] + bits := 8 * v.Args[0].Type.Size() + if lim.umax < uint64(bits) || (lim.max < bits && ft.isNonNegative(by)) { + v.AuxInt = 1 // see shiftIsBounded + if b.Func.pass.debug > 0 && !by.isGenericIntConst() { + b.Func.Warnl(v.Pos, "Proved %v bounded", v.Op) + } + } + case OpDiv8, OpDiv16, OpDiv32, OpDiv64, OpMod8, OpMod16, OpMod32, OpMod64: + p, q := ft.limits[v.Args[0].ID], ft.limits[v.Args[1].ID] // p/q + if p.nonnegative() && q.nonnegative() { + if b.Func.pass.debug > 0 { + b.Func.Warnl(v.Pos, "Proved %v is unsigned", v.Op) + } + v.Op = unsignedOp[v.Op] + v.AuxInt = 0 + break + } + // Fixup code can be avoided on x86 if we know + // the divisor is not -1 or the dividend > MinIntNN. + if v.Op != OpDiv8 && v.Op != OpMod8 && (q.max < -1 || q.min > -1 || p.min > mostNegativeDividend[v.Op]) { + // See DivisionNeedsFixUp in rewrite.go. + // v.AuxInt = 1 means we have proved that the divisor is not -1 + // or that the dividend is not the most negative integer, + // so we do not need to add fix-up code. + if b.Func.pass.debug > 0 { + b.Func.Warnl(v.Pos, "Proved %v does not need fix-up", v.Op) + } + // Only usable on amd64 and 386, and only for ≥ 16-bit ops. + // Don't modify AuxInt on other architectures, as that can interfere with CSE. + // (Print the debug info above always, so that test/prove.go can be + // checked on non-x86 systems.) + // TODO: add other architectures? + if b.Func.Config.arch == "386" || b.Func.Config.arch == "amd64" { + v.AuxInt = 1 + } + } + case OpMul64, OpMul32, OpMul16, OpMul8: + if vl := ft.limits[v.ID]; vl.min == vl.max || vl.umin == vl.umax { + // v is going to be constant folded away; don't "optimize" it. + break + } + x := v.Args[0] + xl := ft.limits[x.ID] + y := v.Args[1] + yl := ft.limits[y.ID] + if xl.umin == xl.umax && isUnsignedPowerOfTwo(xl.umin) || + xl.min == xl.max && isPowerOfTwo(xl.min) || + yl.umin == yl.umax && isUnsignedPowerOfTwo(yl.umin) || + yl.min == yl.max && isPowerOfTwo(yl.min) { + // 0,1 * a power of two is better done as a shift + break + } + switch xOne, yOne := xl.umax <= 1, yl.umax <= 1; { + case xOne && yOne: + v.Op = bytesizeToAnd[v.Type.Size()] + if b.Func.pass.debug > 0 { + b.Func.Warnl(v.Pos, "Rewrote Mul %v into And", v) + } + case yOne && b.Func.Config.haveCondSelect: + x, y = y, x + fallthrough + case xOne && b.Func.Config.haveCondSelect: + if !canCondSelect(v, b.Func.Config.arch, nil) { + break + } + zero := b.Func.constVal(bytesizeToConst[v.Type.Size()], v.Type, 0, true) + ft.initLimitForNewValue(zero) + check := b.NewValue2(v.Pos, bytesizeToNeq[v.Type.Size()], types.Types[types.TBOOL], zero, x) + ft.initLimitForNewValue(check) + v.reset(OpCondSelect) + v.AddArg3(y, zero, check) + + // FIXME: workaround for go.dev/issues/76060 + // we need to schedule the Neq before the CondSelect even tho + // scheduling is meaningless until we reach the schedule pass. + if b.Values[len(b.Values)-1] != check { + panic("unreachable; failed sanity check, new value isn't at the end of the block") + } + b.Values[iv], b.Values[len(b.Values)-1] = b.Values[len(b.Values)-1], b.Values[iv] + + if b.Func.pass.debug > 0 { + b.Func.Warnl(v.Pos, "Rewrote Mul %v into CondSelect; %v is bool", v, x) + } + } + } + + // Fold provable constant results. + // Helps in cases where we reuse a value after branching on its equality. + for i, arg := range v.Args { + lim := ft.limits[arg.ID] + var constValue int64 + switch { + case lim.min == lim.max: + constValue = lim.min + case lim.umin == lim.umax: + constValue = int64(lim.umin) + default: + continue + } + switch arg.Op { + case OpConst64, OpConst32, OpConst16, OpConst8, OpConstBool, OpConstNil: + continue + } + typ := arg.Type + f := b.Func + var c *Value + switch { + case typ.IsBoolean(): + c = f.ConstBool(typ, constValue != 0) + case typ.IsInteger() && typ.Size() == 1: + c = f.ConstInt8(typ, int8(constValue)) + case typ.IsInteger() && typ.Size() == 2: + c = f.ConstInt16(typ, int16(constValue)) + case typ.IsInteger() && typ.Size() == 4: + c = f.ConstInt32(typ, int32(constValue)) + case typ.IsInteger() && typ.Size() == 8: + c = f.ConstInt64(typ, constValue) + case typ.IsPtrShaped(): + if constValue == 0 { + c = f.ConstNil(typ) + } else { + // Not sure how this might happen, but if it + // does, just skip it. + continue + } + default: + // Not sure how this might happen, but if it + // does, just skip it. + continue + } + v.SetArg(i, c) + ft.initLimitForNewValue(c) + if b.Func.pass.debug > 1 { + b.Func.Warnl(v.Pos, "Proved %v's arg %d (%v) is constant %d", v, i, arg, constValue) + } + } + } + + if b.Kind != BlockIf { + return + } + + // Consider outgoing edges from this block. + parent := b + for i, branch := range [...]branch{positive, negative} { + child := parent.Succs[i].b + if getBranch(sdom, parent, child) != unknown { + // For edges to uniquely dominated blocks, we + // already did this when we visited the child. + continue + } + // For edges to other blocks, this can trim a branch + // even if we couldn't get rid of the child itself. + ft.checkpoint() + addBranchRestrictions(ft, parent, branch) + unsat := ft.unsat + ft.restore() + if unsat { + // This branch is impossible, so remove it + // from the block. + removeBranch(parent, branch) + // No point in considering the other branch. + // (It *is* possible for both to be + // unsatisfiable since the fact table is + // incomplete. We could turn this into a + // BlockExit, but it doesn't seem worth it.) + break + } + } +} + +func removeBranch(b *Block, branch branch) { + c := b.Controls[0] + if b.Func.pass.debug > 0 { + verb := "Proved" + if branch == positive { + verb = "Disproved" + } + if b.Func.pass.debug > 1 { + b.Func.Warnl(b.Pos, "%s %s (%s)", verb, c.Op, c) + } else { + b.Func.Warnl(b.Pos, "%s %s", verb, c.Op) + } + } + if c != nil && c.Pos.IsStmt() == src.PosIsStmt && c.Pos.SameFileAndLine(b.Pos) { + // attempt to preserve statement marker. + b.Pos = b.Pos.WithIsStmt() + } + if branch == positive || branch == negative { + b.Kind = BlockFirst + b.ResetControls() + if branch == positive { + b.swapSuccessors() + } + } else { + // TODO: figure out how to remove an entry from a jump table + } +} + +// isConstDelta returns non-nil if v is equivalent to w+delta (signed). +func isConstDelta(v *Value) (w *Value, delta int64) { + cop := OpConst64 + switch v.Op { + case OpAdd32, OpSub32: + cop = OpConst32 + case OpAdd16, OpSub16: + cop = OpConst16 + case OpAdd8, OpSub8: + cop = OpConst8 + } + switch v.Op { + case OpAdd64, OpAdd32, OpAdd16, OpAdd8: + if v.Args[0].Op == cop { + return v.Args[1], v.Args[0].AuxInt + } + if v.Args[1].Op == cop { + return v.Args[0], v.Args[1].AuxInt + } + case OpSub64, OpSub32, OpSub16, OpSub8: + if v.Args[1].Op == cop { + aux := v.Args[1].AuxInt + if aux != -aux { // Overflow; too bad + return v.Args[0], -aux + } + } + } + return nil, 0 +} + +// isCleanExt reports whether v is the result of a value-preserving +// sign or zero extension. +func isCleanExt(v *Value) bool { + switch v.Op { + case OpSignExt8to16, OpSignExt8to32, OpSignExt8to64, + OpSignExt16to32, OpSignExt16to64, OpSignExt32to64: + // signed -> signed is the only value-preserving sign extension + return v.Args[0].Type.IsSigned() && v.Type.IsSigned() + + case OpZeroExt8to16, OpZeroExt8to32, OpZeroExt8to64, + OpZeroExt16to32, OpZeroExt16to64, OpZeroExt32to64: + // unsigned -> signed/unsigned are value-preserving zero extensions + return !v.Args[0].Type.IsSigned() + } + return false +} + +func getDependencyScore(scores []uint, v *Value) (score uint) { + if score = scores[v.ID]; score != 0 { + return score + } + defer func() { + scores[v.ID] = score + }() + if v.Op == OpPhi { + return 1 + } + score = 2 // NIT(@Jorropo): always order phis first to make GOSSAFUNC pretty. + for _, a := range v.Args { + if a.Block != v.Block { + continue + } + score = max(score, getDependencyScore(scores, a)+1) + } + return score +} + +// topoSortValuesInBlock ensure ranging over b.Values visit values before they are being used. +// It does not consider dependencies with other blocks; thus Phi nodes are considered to not have any dependecies. +// The result is always determistic and does not depend on the previous slice ordering. +func (ft *factsTable) topoSortValuesInBlock(b *Block) { + f := b.Func + want := f.NumValues() + + scores := ft.reusedTopoSortScoresTable + if want <= cap(scores) { + scores = scores[:want] + } else { + if cap(scores) > 0 { + f.Cache.freeUintSlice(scores) + } + scores = f.Cache.allocUintSlice(want) + ft.reusedTopoSortScoresTable = scores + } + + for _, v := range b.Values { + scores[v.ID] = 0 // sentinel + } + + slices.SortFunc(b.Values, func(a, b *Value) int { + dependencyScoreA := getDependencyScore(scores, a) + dependencyScoreB := getDependencyScore(scores, b) + if dependencyScoreA != dependencyScoreB { + return cmp.Compare(dependencyScoreA, dependencyScoreB) + } + return cmp.Compare(a.ID, b.ID) + }) +} diff --git a/go/src/cmd/compile/internal/ssa/prove_test.go b/go/src/cmd/compile/internal/ssa/prove_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6315049870aa59ed0ccb85cd0ed1af88d8619ea7 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/prove_test.go @@ -0,0 +1,76 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "math" + "testing" +) + +func testLimitUnaryOpSigned8(t *testing.T, opName string, op func(l limit, bitsize uint) limit, opImpl func(int8) int8) { + sizeLimit := noLimitForBitsize(8) + for min := math.MinInt8; min <= math.MaxInt8; min++ { + for max := min; max <= math.MaxInt8; max++ { + realSmallest, realBiggest := int8(math.MaxInt8), int8(math.MinInt8) + for i := min; i <= max; i++ { + result := opImpl(int8(i)) + if result < realSmallest { + realSmallest = result + } + if result > realBiggest { + realBiggest = result + } + } + + l := limit{int64(min), int64(max), 0, math.MaxUint64} + l = op(l, 8) + l = l.intersect(sizeLimit) // We assume this is gonna be used by newLimit which is seeded by the op size already. + + if l.min != int64(realSmallest) || l.max != int64(realBiggest) { + t.Errorf("%s(%d..%d) = %d..%d; want %d..%d", opName, min, max, l.min, l.max, realSmallest, realBiggest) + } + } + } +} + +func testLimitUnaryOpUnsigned8(t *testing.T, opName string, op func(l limit, bitsize uint) limit, opImpl func(uint8) uint8) { + sizeLimit := noLimitForBitsize(8) + for min := 0; min <= math.MaxUint8; min++ { + for max := min; max <= math.MaxUint8; max++ { + realSmallest, realBiggest := uint8(math.MaxUint8), uint8(0) + for i := min; i <= max; i++ { + result := opImpl(uint8(i)) + if result < realSmallest { + realSmallest = result + } + if result > realBiggest { + realBiggest = result + } + } + + l := limit{math.MinInt64, math.MaxInt64, uint64(min), uint64(max)} + l = op(l, 8) + l = l.intersect(sizeLimit) // We assume this is gonna be used by newLimit which is seeded by the op size already. + + if l.umin != uint64(realSmallest) || l.umax != uint64(realBiggest) { + t.Errorf("%s(%d..%d) = %d..%d; want %d..%d", opName, min, max, l.umin, l.umax, realSmallest, realBiggest) + } + } + } +} + +func TestLimitNegSigned(t *testing.T) { + testLimitUnaryOpSigned8(t, "neg", limit.neg, func(x int8) int8 { return -x }) +} +func TestLimitNegUnsigned(t *testing.T) { + testLimitUnaryOpUnsigned8(t, "neg", limit.neg, func(x uint8) uint8 { return -x }) +} + +func TestLimitComSigned(t *testing.T) { + testLimitUnaryOpSigned8(t, "com", limit.com, func(x int8) int8 { return ^x }) +} +func TestLimitComUnsigned(t *testing.T) { + testLimitUnaryOpUnsigned8(t, "com", limit.com, func(x uint8) uint8 { return ^x }) +} diff --git a/go/src/cmd/compile/internal/ssa/regalloc.go b/go/src/cmd/compile/internal/ssa/regalloc.go new file mode 100644 index 0000000000000000000000000000000000000000..861cf7e01141cc000a5f5d06aebbf7ca7f61b9da --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/regalloc.go @@ -0,0 +1,3462 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Register allocation. +// +// We use a version of a linear scan register allocator. We treat the +// whole function as a single long basic block and run through +// it using a greedy register allocator. Then all merge edges +// (those targeting a block with len(Preds)>1) are processed to +// shuffle data into the place that the target of the edge expects. +// +// The greedy allocator moves values into registers just before they +// are used, spills registers only when necessary, and spills the +// value whose next use is farthest in the future. +// +// The register allocator requires that a block is not scheduled until +// at least one of its predecessors have been scheduled. The most recent +// such predecessor provides the starting register state for a block. +// +// It also requires that there are no critical edges (critical = +// comes from a block with >1 successor and goes to a block with >1 +// predecessor). This makes it easy to add fixup code on merge edges - +// the source of a merge edge has only one successor, so we can add +// fixup code to the end of that block. + +// Spilling +// +// During the normal course of the allocator, we might throw a still-live +// value out of all registers. When that value is subsequently used, we must +// load it from a slot on the stack. We must also issue an instruction to +// initialize that stack location with a copy of v. +// +// pre-regalloc: +// (1) v = Op ... +// (2) x = Op ... +// (3) ... = Op v ... +// +// post-regalloc: +// (1) v = Op ... : AX // computes v, store result in AX +// s = StoreReg v // spill v to a stack slot +// (2) x = Op ... : AX // some other op uses AX +// c = LoadReg s : CX // restore v from stack slot +// (3) ... = Op c ... // use the restored value +// +// Allocation occurs normally until we reach (3) and we realize we have +// a use of v and it isn't in any register. At that point, we allocate +// a spill (a StoreReg) for v. We can't determine the correct place for +// the spill at this point, so we allocate the spill as blockless initially. +// The restore is then generated to load v back into a register so it can +// be used. Subsequent uses of v will use the restored value c instead. +// +// What remains is the question of where to schedule the spill. +// During allocation, we keep track of the dominator of all restores of v. +// The spill of v must dominate that block. The spill must also be issued at +// a point where v is still in a register. +// +// To find the right place, start at b, the block which dominates all restores. +// - If b is v.Block, then issue the spill right after v. +// It is known to be in a register at that point, and dominates any restores. +// - Otherwise, if v is in a register at the start of b, +// put the spill of v at the start of b. +// - Otherwise, set b = immediate dominator of b, and repeat. +// +// Phi values are special, as always. We define two kinds of phis, those +// where the merge happens in a register (a "register" phi) and those where +// the merge happens in a stack location (a "stack" phi). +// +// A register phi must have the phi and all of its inputs allocated to the +// same register. Register phis are spilled similarly to regular ops. +// +// A stack phi must have the phi and all of its inputs allocated to the same +// stack location. Stack phis start out life already spilled - each phi +// input must be a store (using StoreReg) at the end of the corresponding +// predecessor block. +// b1: y = ... : AX b2: z = ... : BX +// y2 = StoreReg y z2 = StoreReg z +// goto b3 goto b3 +// b3: x = phi(y2, z2) +// The stack allocator knows that StoreReg args of stack-allocated phis +// must be allocated to the same stack slot as the phi that uses them. +// x is now a spilled value and a restore must appear before its first use. + +// TODO + +// Use an affinity graph to mark two values which should use the +// same register. This affinity graph will be used to prefer certain +// registers for allocation. This affinity helps eliminate moves that +// are required for phi implementations and helps generate allocations +// for 2-register architectures. + +// Note: regalloc generates a not-quite-SSA output. If we have: +// +// b1: x = ... : AX +// x2 = StoreReg x +// ... AX gets reused for something else ... +// if ... goto b3 else b4 +// +// b3: x3 = LoadReg x2 : BX b4: x4 = LoadReg x2 : CX +// ... use x3 ... ... use x4 ... +// +// b2: ... use x3 ... +// +// If b3 is the primary predecessor of b2, then we use x3 in b2 and +// add a x4:CX->BX copy at the end of b4. +// But the definition of x3 doesn't dominate b2. We should really +// insert an extra phi at the start of b2 (x5=phi(x3,x4):BX) to keep +// SSA form. For now, we ignore this problem as remaining in strict +// SSA form isn't needed after regalloc. We'll just leave the use +// of x3 not dominated by the definition of x3, and the CX->BX copy +// will have no use (so don't run deadcode after regalloc!). +// TODO: maybe we should introduce these extra phis? + +package ssa + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" + "cmd/internal/sys" + "cmp" + "fmt" + "internal/buildcfg" + "math" + "math/bits" + "slices" + "unsafe" +) + +const ( + moveSpills = iota + logSpills + regDebug + stackDebug +) + +// distance is a measure of how far into the future values are used. +// distance is measured in units of instructions. +const ( + likelyDistance = 1 + normalDistance = 10 + unlikelyDistance = 100 +) + +// regalloc performs register allocation on f. It sets f.RegAlloc +// to the resulting allocation. +func regalloc(f *Func) { + var s regAllocState + s.init(f) + s.regalloc(f) + s.close() +} + +type register uint8 + +const noRegister register = 255 + +// For bulk initializing +var noRegisters [32]register = [32]register{ + noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, + noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, + noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, + noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, noRegister, +} + +// A regMask encodes a set of machine registers. +// TODO: regMask -> regSet? +type regMask uint64 + +func (m regMask) String() string { + s := "" + for r := register(0); m != 0; r++ { + if m>>r&1 == 0 { + continue + } + m &^= regMask(1) << r + if s != "" { + s += " " + } + s += fmt.Sprintf("r%d", r) + } + return s +} + +func (m regMask) contains(r register) bool { + return m>>r&1 != 0 +} + +func (s *regAllocState) RegMaskString(m regMask) string { + str := "" + for r := register(0); m != 0; r++ { + if m>>r&1 == 0 { + continue + } + m &^= regMask(1) << r + if str != "" { + str += " " + } + str += s.registers[r].String() + } + return str +} + +// countRegs returns the number of set bits in the register mask. +func countRegs(r regMask) int { + return bits.OnesCount64(uint64(r)) +} + +// pickReg picks an arbitrary register from the register mask. +func pickReg(r regMask) register { + if r == 0 { + panic("can't pick a register from an empty set") + } + // pick the lowest one + return register(bits.TrailingZeros64(uint64(r))) +} + +type use struct { + // distance from start of the block to a use of a value + // dist == 0 used by first instruction in block + // dist == len(b.Values)-1 used by last instruction in block + // dist == len(b.Values) used by block's control value + // dist > len(b.Values) used by a subsequent block + dist int32 + pos src.XPos // source position of the use + next *use // linked list of uses of a value in nondecreasing dist order +} + +// A valState records the register allocation state for a (pre-regalloc) value. +type valState struct { + regs regMask // the set of registers holding a Value (usually just one) + uses *use // list of uses in this block + spill *Value // spilled copy of the Value (if any) + restoreMin int32 // minimum of all restores' blocks' sdom.entry + restoreMax int32 // maximum of all restores' blocks' sdom.exit + needReg bool // cached value of !v.Type.IsMemory() && !v.Type.IsVoid() && !.v.Type.IsFlags() + rematerializeable bool // cached value of v.rematerializeable() +} + +type regState struct { + v *Value // Original (preregalloc) Value stored in this register. + c *Value // A Value equal to v which is currently in a register. Might be v or a copy of it. + // If a register is unused, v==c==nil +} + +type regAllocState struct { + f *Func + + sdom SparseTree + registers []Register + numRegs register + SPReg register + SBReg register + GReg register + ZeroIntReg register + allocatable regMask + + // live values at the end of each block. live[b.ID] is a list of value IDs + // which are live at the end of b, together with a count of how many instructions + // forward to the next use. + live [][]liveInfo + // desired register assignments at the end of each block. + // Note that this is a static map computed before allocation occurs. Dynamic + // register desires (from partially completed allocations) will trump + // this information. + desired []desiredState + + // current state of each (preregalloc) Value + values []valState + + // ID of SP, SB values + sp, sb ID + + // For each Value, map from its value ID back to the + // preregalloc Value it was derived from. + orig []*Value + + // current state of each register. + // Includes only registers in allocatable. + regs []regState + + // registers that contain values which can't be kicked out + nospill regMask + + // mask of registers currently in use + used regMask + + // mask of registers used since the start of the current block + usedSinceBlockStart regMask + + // mask of registers used in the current instruction + tmpused regMask + + // current block we're working on + curBlock *Block + + // cache of use records + freeUseRecords *use + + // endRegs[blockid] is the register state at the end of each block. + // encoded as a set of endReg records. + endRegs [][]endReg + + // startRegs[blockid] is the register state at the start of merge blocks. + // saved state does not include the state of phi ops in the block. + startRegs [][]startReg + + // startRegsMask is a mask of the registers in startRegs[curBlock.ID]. + // Registers dropped from startRegsMask are later synchronoized back to + // startRegs by dropping from there as well. + startRegsMask regMask + + // spillLive[blockid] is the set of live spills at the end of each block + spillLive [][]ID + + // a set of copies we generated to move things around, and + // whether it is used in shuffle. Unused copies will be deleted. + copies map[*Value]bool + + loopnest *loopnest + + // choose a good order in which to visit blocks for allocation purposes. + visitOrder []*Block + + // blockOrder[b.ID] corresponds to the index of block b in visitOrder. + blockOrder []int32 + + // whether to insert instructions that clobber dead registers at call sites + doClobber bool + + // For each instruction index in a basic block, the index of the next call + // at or after that instruction index. + // If there is no next call, returns maxInt32. + // nextCall for a call instruction points to itself. + // (Indexes and results are pre-regalloc.) + nextCall []int32 + + // Index of the instruction we're currently working on. + // Index is expressed in terms of the pre-regalloc b.Values list. + curIdx int +} + +type endReg struct { + r register + v *Value // pre-regalloc value held in this register (TODO: can we use ID here?) + c *Value // cached version of the value +} + +type startReg struct { + r register + v *Value // pre-regalloc value needed in this register + c *Value // cached version of the value + pos src.XPos // source position of use of this register +} + +// freeReg frees up register r. Any current user of r is kicked out. +func (s *regAllocState) freeReg(r register) { + if !s.allocatable.contains(r) && !s.isGReg(r) { + return + } + v := s.regs[r].v + if v == nil { + s.f.Fatalf("tried to free an already free register %d\n", r) + } + + // Mark r as unused. + if s.f.pass.debug > regDebug { + fmt.Printf("freeReg %s (dump %s/%s)\n", &s.registers[r], v, s.regs[r].c) + } + s.regs[r] = regState{} + s.values[v.ID].regs &^= regMask(1) << r + s.used &^= regMask(1) << r +} + +// freeRegs frees up all registers listed in m. +func (s *regAllocState) freeRegs(m regMask) { + for m&s.used != 0 { + s.freeReg(pickReg(m & s.used)) + } +} + +// clobberRegs inserts instructions that clobber registers listed in m. +func (s *regAllocState) clobberRegs(m regMask) { + m &= s.allocatable & s.f.Config.gpRegMask // only integer register can contain pointers, only clobber them + for m != 0 { + r := pickReg(m) + m &^= 1 << r + x := s.curBlock.NewValue0(src.NoXPos, OpClobberReg, types.TypeVoid) + s.f.setHome(x, &s.registers[r]) + } +} + +// setOrig records that c's original value is the same as +// v's original value. +func (s *regAllocState) setOrig(c *Value, v *Value) { + if int(c.ID) >= cap(s.orig) { + x := s.f.Cache.allocValueSlice(int(c.ID) + 1) + copy(x, s.orig) + s.f.Cache.freeValueSlice(s.orig) + s.orig = x + } + for int(c.ID) >= len(s.orig) { + s.orig = append(s.orig, nil) + } + if s.orig[c.ID] != nil { + s.f.Fatalf("orig value set twice %s %s", c, v) + } + s.orig[c.ID] = s.orig[v.ID] +} + +// assignReg assigns register r to hold c, a copy of v. +// r must be unused. +func (s *regAllocState) assignReg(r register, v *Value, c *Value) { + if s.f.pass.debug > regDebug { + fmt.Printf("assignReg %s %s/%s\n", &s.registers[r], v, c) + } + // Allocate v to r. + s.values[v.ID].regs |= regMask(1) << r + s.f.setHome(c, &s.registers[r]) + + // Allocate r to v. + if !s.allocatable.contains(r) && !s.isGReg(r) { + return + } + if s.regs[r].v != nil { + s.f.Fatalf("tried to assign register %d to %s/%s but it is already used by %s", r, v, c, s.regs[r].v) + } + s.regs[r] = regState{v, c} + s.used |= regMask(1) << r +} + +// allocReg chooses a register from the set of registers in mask. +// If there is no unused register, a Value will be kicked out of +// a register to make room. +func (s *regAllocState) allocReg(mask regMask, v *Value) register { + if v.OnWasmStack { + return noRegister + } + + mask &= s.allocatable + mask &^= s.nospill + if mask == 0 { + s.f.Fatalf("no register available for %s", v.LongString()) + } + + // Pick an unused register if one is available. + if mask&^s.used != 0 { + r := pickReg(mask &^ s.used) + s.usedSinceBlockStart |= regMask(1) << r + return r + } + + // Pick a value to spill. Spill the value with the + // farthest-in-the-future use. + // TODO: Prefer registers with already spilled Values? + // TODO: Modify preference using affinity graph. + // TODO: if a single value is in multiple registers, spill one of them + // before spilling a value in just a single register. + + // Find a register to spill. We spill the register containing the value + // whose next use is as far in the future as possible. + // https://en.wikipedia.org/wiki/Page_replacement_algorithm#The_theoretically_optimal_page_replacement_algorithm + var r register + maxuse := int32(-1) + for t := register(0); t < s.numRegs; t++ { + if mask>>t&1 == 0 { + continue + } + v := s.regs[t].v + if n := s.values[v.ID].uses.dist; n > maxuse { + // v's next use is farther in the future than any value + // we've seen so far. A new best spill candidate. + r = t + maxuse = n + } + } + if maxuse == -1 { + s.f.Fatalf("couldn't find register to spill") + } + + if s.f.Config.ctxt.Arch.Arch == sys.ArchWasm { + // TODO(neelance): In theory this should never happen, because all wasm registers are equal. + // So if there is still a free register, the allocation should have picked that one in the first place instead of + // trying to kick some other value out. In practice, this case does happen and it breaks the stack optimization. + s.freeReg(r) + return r + } + + // Try to move it around before kicking out, if there is a free register. + // We generate a Copy and record it. It will be deleted if never used. + v2 := s.regs[r].v + m := s.compatRegs(v2.Type) &^ s.used &^ s.tmpused &^ (regMask(1) << r) + if m != 0 && !s.values[v2.ID].rematerializeable && countRegs(s.values[v2.ID].regs) == 1 { + s.usedSinceBlockStart |= regMask(1) << r + r2 := pickReg(m) + c := s.curBlock.NewValue1(v2.Pos, OpCopy, v2.Type, s.regs[r].c) + s.copies[c] = false + if s.f.pass.debug > regDebug { + fmt.Printf("copy %s to %s : %s\n", v2, c, &s.registers[r2]) + } + s.setOrig(c, v2) + s.assignReg(r2, v2, c) + } + + // If the evicted register isn't used between the start of the block + // and now then there is no reason to even request it on entry. We can + // drop from startRegs in that case. + if s.usedSinceBlockStart&(regMask(1)< regDebug { + fmt.Printf("dropped from startRegs: %s\n", &s.registers[r]) + } + s.startRegsMask &^= regMask(1) << r + } + } + + s.freeReg(r) + s.usedSinceBlockStart |= regMask(1) << r + return r +} + +// makeSpill returns a Value which represents the spilled value of v. +// b is the block in which the spill is used. +func (s *regAllocState) makeSpill(v *Value, b *Block) *Value { + vi := &s.values[v.ID] + if vi.spill != nil { + // Final block not known - keep track of subtree where restores reside. + vi.restoreMin = min(vi.restoreMin, s.sdom[b.ID].entry) + vi.restoreMax = max(vi.restoreMax, s.sdom[b.ID].exit) + return vi.spill + } + // Make a spill for v. We don't know where we want + // to put it yet, so we leave it blockless for now. + spill := s.f.newValueNoBlock(OpStoreReg, v.Type, v.Pos) + // We also don't know what the spill's arg will be. + // Leave it argless for now. + s.setOrig(spill, v) + vi.spill = spill + vi.restoreMin = s.sdom[b.ID].entry + vi.restoreMax = s.sdom[b.ID].exit + return spill +} + +// allocValToReg allocates v to a register selected from regMask and +// returns the register copy of v. Any previous user is kicked out and spilled +// (if necessary). Load code is added at the current pc. If nospill is set the +// allocated register is marked nospill so the assignment cannot be +// undone until the caller allows it by clearing nospill. Returns a +// *Value which is either v or a copy of v allocated to the chosen register. +func (s *regAllocState) allocValToReg(v *Value, mask regMask, nospill bool, pos src.XPos) *Value { + if s.f.Config.ctxt.Arch.Arch == sys.ArchWasm && v.rematerializeable() { + c := v.copyIntoWithXPos(s.curBlock, pos) + c.OnWasmStack = true + s.setOrig(c, v) + return c + } + if v.OnWasmStack { + return v + } + + vi := &s.values[v.ID] + pos = pos.WithNotStmt() + // Check if v is already in a requested register. + if mask&vi.regs != 0 { + mask &= vi.regs + r := pickReg(mask) + if mask.contains(s.SPReg) { + // Prefer the stack pointer if it is allowed. + // (Needed because the op might have an Aux symbol + // that needs SP as its base.) + r = s.SPReg + } + if !s.allocatable.contains(r) { + return v // v is in a fixed register + } + if s.regs[r].v != v || s.regs[r].c == nil { + panic("bad register state") + } + if nospill { + s.nospill |= regMask(1) << r + } + s.usedSinceBlockStart |= regMask(1) << r + return s.regs[r].c + } + + var r register + // If nospill is set, the value is used immediately, so it can live on the WebAssembly stack. + onWasmStack := nospill && s.f.Config.ctxt.Arch.Arch == sys.ArchWasm + if !onWasmStack { + // Allocate a register. + r = s.allocReg(mask, v) + } + + // Allocate v to the new register. + var c *Value + if vi.regs != 0 { + // Copy from a register that v is already in. + var current *Value + if vi.regs&^s.allocatable != 0 { + // v is in a fixed register, prefer that + current = v + } else { + r2 := pickReg(vi.regs) + if s.regs[r2].v != v { + panic("bad register state") + } + current = s.regs[r2].c + s.usedSinceBlockStart |= regMask(1) << r2 + } + c = s.curBlock.NewValue1(pos, OpCopy, v.Type, current) + } else if v.rematerializeable() { + // Rematerialize instead of loading from the spill location. + c = v.copyIntoWithXPos(s.curBlock, pos) + // We need to consider its output mask and potentially issue a Copy + // if there are register mask conflicts. + // This currently happens for the SIMD package only between GP and FP + // register. Because Intel's vector extension can put integer value into + // FP, which is seen as a vector. Example instruction: VPSLL[BWDQ] + // Because GP and FP masks do not overlap, mask & outputMask == 0 + // detects this situation thoroughly. + sourceMask := s.regspec(c).outputs[0].regs + if mask&sourceMask == 0 && !onWasmStack { + s.setOrig(c, v) + s.assignReg(s.allocReg(sourceMask, v), v, c) + // v.Type for the new OpCopy is likely wrong and it might delay the problem + // until ssa to asm lowering, which might need the types to generate the right + // assembly for OpCopy. For Intel's GP to FP move, it happens to be that + // MOV instruction has such a variant so it happens to be right. + // But it's unclear for other architectures or situations, and the problem + // might be exposed when the assembler sees illegal instructions. + // Right now make we still pick v.Type, because at least its size should be correct + // for the rematerialization case the amd64 SIMD package exposed. + // TODO: We might need to figure out a way to find the correct type or make + // the asm lowering use reg info only for OpCopy. + c = s.curBlock.NewValue1(pos, OpCopy, v.Type, c) + } + } else { + // Load v from its spill location. + spill := s.makeSpill(v, s.curBlock) + if s.f.pass.debug > logSpills { + s.f.Warnl(vi.spill.Pos, "load spill for %v from %v", v, spill) + } + c = s.curBlock.NewValue1(pos, OpLoadReg, v.Type, spill) + } + + s.setOrig(c, v) + + if onWasmStack { + c.OnWasmStack = true + return c + } + + s.assignReg(r, v, c) + if c.Op == OpLoadReg && s.isGReg(r) { + s.f.Fatalf("allocValToReg.OpLoadReg targeting g: " + c.LongString()) + } + if nospill { + s.nospill |= regMask(1) << r + } + return c +} + +// isLeaf reports whether f performs any calls. +func isLeaf(f *Func) bool { + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op.IsCall() && !v.Op.IsTailCall() { + // tail call is not counted as it does not save the return PC or need a frame + return false + } + } + } + return true +} + +// needRegister reports whether v needs a register. +func (v *Value) needRegister() bool { + return !v.Type.IsMemory() && !v.Type.IsVoid() && !v.Type.IsFlags() && !v.Type.IsTuple() +} + +func (s *regAllocState) init(f *Func) { + s.f = f + s.f.RegAlloc = s.f.Cache.locs[:0] + s.registers = f.Config.registers + if nr := len(s.registers); nr == 0 || nr > int(noRegister) || nr > int(unsafe.Sizeof(regMask(0))*8) { + s.f.Fatalf("bad number of registers: %d", nr) + } else { + s.numRegs = register(nr) + } + // Locate SP, SB, and g registers. + s.SPReg = noRegister + s.SBReg = noRegister + s.GReg = noRegister + s.ZeroIntReg = noRegister + for r := register(0); r < s.numRegs; r++ { + switch s.registers[r].String() { + case "SP": + s.SPReg = r + case "SB": + s.SBReg = r + case "g": + s.GReg = r + case "ZERO": // TODO: arch-specific? + s.ZeroIntReg = r + } + } + // Make sure we found all required registers. + switch noRegister { + case s.SPReg: + s.f.Fatalf("no SP register found") + case s.SBReg: + s.f.Fatalf("no SB register found") + case s.GReg: + if f.Config.hasGReg { + s.f.Fatalf("no g register found") + } + } + + // Figure out which registers we're allowed to use. + s.allocatable = s.f.Config.gpRegMask | s.f.Config.fpRegMask | s.f.Config.specialRegMask + s.allocatable &^= 1 << s.SPReg + s.allocatable &^= 1 << s.SBReg + if s.f.Config.hasGReg { + s.allocatable &^= 1 << s.GReg + } + if s.ZeroIntReg != noRegister { + s.allocatable &^= 1 << s.ZeroIntReg + } + if buildcfg.FramePointerEnabled && s.f.Config.FPReg >= 0 { + s.allocatable &^= 1 << uint(s.f.Config.FPReg) + } + if s.f.Config.LinkReg != -1 { + if isLeaf(f) { + // Leaf functions don't save/restore the link register. + s.allocatable &^= 1 << uint(s.f.Config.LinkReg) + } + } + if s.f.Config.ctxt.Flag_dynlink { + switch s.f.Config.arch { + case "386": + // nothing to do. + // Note that for Flag_shared (position independent code) + // we do need to be careful, but that carefulness is hidden + // in the rewrite rules so we always have a free register + // available for global load/stores. See _gen/386.rules (search for Flag_shared). + case "amd64": + s.allocatable &^= 1 << 15 // R15 + case "arm": + s.allocatable &^= 1 << 9 // R9 + case "arm64": + // nothing to do + case "loong64": // R2 (aka TP) already reserved. + // nothing to do + case "ppc64le": // R2 already reserved. + // nothing to do + case "riscv64": // X3 (aka GP) and X4 (aka TP) already reserved. + // nothing to do + case "s390x": + s.allocatable &^= 1 << 11 // R11 + default: + s.f.fe.Fatalf(src.NoXPos, "arch %s not implemented", s.f.Config.arch) + } + } + + // Linear scan register allocation can be influenced by the order in which blocks appear. + // Decouple the register allocation order from the generated block order. + // This also creates an opportunity for experiments to find a better order. + s.visitOrder = layoutRegallocOrder(f) + + // Compute block order. This array allows us to distinguish forward edges + // from backward edges and compute how far they go. + s.blockOrder = make([]int32, f.NumBlocks()) + for i, b := range s.visitOrder { + s.blockOrder[b.ID] = int32(i) + } + + s.regs = make([]regState, s.numRegs) + nv := f.NumValues() + if cap(s.f.Cache.regallocValues) >= nv { + s.f.Cache.regallocValues = s.f.Cache.regallocValues[:nv] + } else { + s.f.Cache.regallocValues = make([]valState, nv) + } + s.values = s.f.Cache.regallocValues + s.orig = s.f.Cache.allocValueSlice(nv) + s.copies = make(map[*Value]bool) + for _, b := range s.visitOrder { + for _, v := range b.Values { + if v.needRegister() { + s.values[v.ID].needReg = true + s.values[v.ID].rematerializeable = v.rematerializeable() + s.orig[v.ID] = v + } + // Note: needReg is false for values returning Tuple types. + // Instead, we mark the corresponding Selects as needReg. + } + } + s.computeLive() + + s.endRegs = make([][]endReg, f.NumBlocks()) + s.startRegs = make([][]startReg, f.NumBlocks()) + s.spillLive = make([][]ID, f.NumBlocks()) + s.sdom = f.Sdom() + + // wasm: Mark instructions that can be optimized to have their values only on the WebAssembly stack. + if f.Config.ctxt.Arch.Arch == sys.ArchWasm { + canLiveOnStack := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(canLiveOnStack) + for _, b := range f.Blocks { + // New block. Clear candidate set. + canLiveOnStack.clear() + for _, c := range b.ControlValues() { + if c.Uses == 1 && !opcodeTable[c.Op].generic { + canLiveOnStack.add(c.ID) + } + } + // Walking backwards. + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + if canLiveOnStack.contains(v.ID) { + v.OnWasmStack = true + } else { + // Value can not live on stack. Values are not allowed to be reordered, so clear candidate set. + canLiveOnStack.clear() + } + for _, arg := range v.Args { + // Value can live on the stack if: + // - it is only used once + // - it is used in the same basic block + // - it is not a "mem" value + // - it is a WebAssembly op + if arg.Uses == 1 && arg.Block == v.Block && !arg.Type.IsMemory() && !opcodeTable[arg.Op].generic { + canLiveOnStack.add(arg.ID) + } + } + } + } + } + + // The clobberdeadreg experiment inserts code to clobber dead registers + // at call sites. + // Ignore huge functions to avoid doing too much work. + if base.Flag.ClobberDeadReg && len(s.f.Blocks) <= 10000 { + // TODO: honor GOCLOBBERDEADHASH, or maybe GOSSAHASH. + s.doClobber = true + } +} + +func (s *regAllocState) close() { + s.f.Cache.freeValueSlice(s.orig) +} + +// Adds a use record for id at distance dist from the start of the block. +// All calls to addUse must happen with nonincreasing dist. +func (s *regAllocState) addUse(id ID, dist int32, pos src.XPos) { + r := s.freeUseRecords + if r != nil { + s.freeUseRecords = r.next + } else { + r = &use{} + } + r.dist = dist + r.pos = pos + r.next = s.values[id].uses + s.values[id].uses = r + if r.next != nil && dist > r.next.dist { + s.f.Fatalf("uses added in wrong order") + } +} + +// advanceUses advances the uses of v's args from the state before v to the state after v. +// Any values which have no more uses are deallocated from registers. +func (s *regAllocState) advanceUses(v *Value) { + for _, a := range v.Args { + if !s.values[a.ID].needReg { + continue + } + ai := &s.values[a.ID] + r := ai.uses + ai.uses = r.next + if r.next == nil || (!opcodeTable[a.Op].fixedReg && r.next.dist > s.nextCall[s.curIdx]) { + // Value is dead (or is not used again until after a call), free all registers that hold it. + s.freeRegs(ai.regs) + } + r.next = s.freeUseRecords + s.freeUseRecords = r + } + s.dropIfUnused(v) +} + +// Drop v from registers if it isn't used again, or its only uses are after +// a call instruction. +func (s *regAllocState) dropIfUnused(v *Value) { + if !s.values[v.ID].needReg { + return + } + vi := &s.values[v.ID] + r := vi.uses + nextCall := s.nextCall[s.curIdx] + if opcodeTable[v.Op].call { + if s.curIdx == len(s.nextCall)-1 { + nextCall = math.MaxInt32 + } else { + nextCall = s.nextCall[s.curIdx+1] + } + } + if r == nil || (!opcodeTable[v.Op].fixedReg && r.dist > nextCall) { + s.freeRegs(vi.regs) + } +} + +// liveAfterCurrentInstruction reports whether v is live after +// the current instruction is completed. v must be used by the +// current instruction. +func (s *regAllocState) liveAfterCurrentInstruction(v *Value) bool { + u := s.values[v.ID].uses + if u == nil { + panic(fmt.Errorf("u is nil, v = %s, s.values[v.ID] = %v", v.LongString(), s.values[v.ID])) + } + d := u.dist + for u != nil && u.dist == d { + u = u.next + } + return u != nil && u.dist > d +} + +// Sets the state of the registers to that encoded in regs. +func (s *regAllocState) setState(regs []endReg) { + s.freeRegs(s.used) + for _, x := range regs { + s.assignReg(x.r, x.v, x.c) + } +} + +// compatRegs returns the set of registers which can store a type t. +func (s *regAllocState) compatRegs(t *types.Type) regMask { + var m regMask + if t.IsTuple() || t.IsFlags() { + return 0 + } + if t.IsSIMD() { + if t.Size() > 8 { + return s.f.Config.fpRegMask & s.allocatable + } else { + // K mask + return s.f.Config.gpRegMask & s.allocatable + } + } + if t.IsFloat() || t == types.TypeInt128 { + if t.Kind() == types.TFLOAT32 && s.f.Config.fp32RegMask != 0 { + m = s.f.Config.fp32RegMask + } else if t.Kind() == types.TFLOAT64 && s.f.Config.fp64RegMask != 0 { + m = s.f.Config.fp64RegMask + } else { + m = s.f.Config.fpRegMask + } + } else { + m = s.f.Config.gpRegMask + } + return m & s.allocatable +} + +// regspec returns the regInfo for operation op. +func (s *regAllocState) regspec(v *Value) regInfo { + op := v.Op + if op == OpConvert { + // OpConvert is a generic op, so it doesn't have a + // register set in the static table. It can use any + // allocatable integer register. + m := s.allocatable & s.f.Config.gpRegMask + return regInfo{inputs: []inputInfo{{regs: m}}, outputs: []outputInfo{{regs: m}}} + } + if op == OpArgIntReg { + reg := v.Block.Func.Config.intParamRegs[v.AuxInt8()] + return regInfo{outputs: []outputInfo{{regs: 1 << uint(reg)}}} + } + if op == OpArgFloatReg { + reg := v.Block.Func.Config.floatParamRegs[v.AuxInt8()] + return regInfo{outputs: []outputInfo{{regs: 1 << uint(reg)}}} + } + if op.IsCall() { + if ac, ok := v.Aux.(*AuxCall); ok && ac.reg != nil { + return *ac.Reg(&opcodeTable[op].reg, s.f.Config) + } + } + if op == OpMakeResult && s.f.OwnAux.reg != nil { + return *s.f.OwnAux.ResultReg(s.f.Config) + } + return opcodeTable[op].reg +} + +func (s *regAllocState) isGReg(r register) bool { + return s.f.Config.hasGReg && s.GReg == r +} + +// Dummy value used to represent the value being held in a temporary register. +var tmpVal Value + +func (s *regAllocState) regalloc(f *Func) { + regValLiveSet := f.newSparseSet(f.NumValues()) // set of values that may be live in register + defer f.retSparseSet(regValLiveSet) + var oldSched []*Value + var phis []*Value + var phiRegs []register + var args []*Value + + // Data structure used for computing desired registers. + var desired desiredState + desiredSecondReg := map[ID][4]register{} // desired register allocation for 2nd part of a tuple + + // Desired registers for inputs & outputs for each instruction in the block. + type dentry struct { + out [4]register // desired output registers + in [3][4]register // desired input registers (for inputs 0,1, and 2) + } + var dinfo []dentry + + if f.Entry != f.Blocks[0] { + f.Fatalf("entry block must be first") + } + + for _, b := range s.visitOrder { + if s.f.pass.debug > regDebug { + fmt.Printf("Begin processing block %v\n", b) + } + s.curBlock = b + s.startRegsMask = 0 + s.usedSinceBlockStart = 0 + clear(desiredSecondReg) + + // Initialize regValLiveSet and uses fields for this block. + // Walk backwards through the block doing liveness analysis. + regValLiveSet.clear() + if s.live != nil { + for _, e := range s.live[b.ID] { + s.addUse(e.ID, int32(len(b.Values))+e.dist, e.pos) // pseudo-uses from beyond end of block + regValLiveSet.add(e.ID) + } + } + for _, v := range b.ControlValues() { + if s.values[v.ID].needReg { + s.addUse(v.ID, int32(len(b.Values)), b.Pos) // pseudo-use by control values + regValLiveSet.add(v.ID) + } + } + if cap(s.nextCall) < len(b.Values) { + c := cap(s.nextCall) + s.nextCall = append(s.nextCall[:c], make([]int32, len(b.Values)-c)...) + } else { + s.nextCall = s.nextCall[:len(b.Values)] + } + var nextCall int32 = math.MaxInt32 + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + regValLiveSet.remove(v.ID) + if v.Op == OpPhi { + // Remove v from the live set, but don't add + // any inputs. This is the state the len(b.Preds)>1 + // case below desires; it wants to process phis specially. + s.nextCall[i] = nextCall + continue + } + if opcodeTable[v.Op].call { + // Function call clobbers all the registers but SP and SB. + regValLiveSet.clear() + if s.sp != 0 && s.values[s.sp].uses != nil { + regValLiveSet.add(s.sp) + } + if s.sb != 0 && s.values[s.sb].uses != nil { + regValLiveSet.add(s.sb) + } + nextCall = int32(i) + } + for _, a := range v.Args { + if !s.values[a.ID].needReg { + continue + } + s.addUse(a.ID, int32(i), v.Pos) + regValLiveSet.add(a.ID) + } + s.nextCall[i] = nextCall + } + if s.f.pass.debug > regDebug { + fmt.Printf("use distances for %s\n", b) + for i := range s.values { + vi := &s.values[i] + u := vi.uses + if u == nil { + continue + } + fmt.Printf(" v%d:", i) + for u != nil { + fmt.Printf(" %d", u.dist) + u = u.next + } + fmt.Println() + } + } + + // Make a copy of the block schedule so we can generate a new one in place. + // We make a separate copy for phis and regular values. + nphi := 0 + for _, v := range b.Values { + if v.Op != OpPhi { + break + } + nphi++ + } + phis = append(phis[:0], b.Values[:nphi]...) + oldSched = append(oldSched[:0], b.Values[nphi:]...) + b.Values = b.Values[:0] + + // Initialize start state of block. + if b == f.Entry { + // Regalloc state is empty to start. + if nphi > 0 { + f.Fatalf("phis in entry block") + } + } else if len(b.Preds) == 1 { + // Start regalloc state with the end state of the previous block. + s.setState(s.endRegs[b.Preds[0].b.ID]) + if nphi > 0 { + f.Fatalf("phis in single-predecessor block") + } + // Drop any values which are no longer live. + // This may happen because at the end of p, a value may be + // live but only used by some other successor of p. + for r := register(0); r < s.numRegs; r++ { + v := s.regs[r].v + if v != nil && !regValLiveSet.contains(v.ID) { + s.freeReg(r) + } + } + } else { + // This is the complicated case. We have more than one predecessor, + // which means we may have Phi ops. + + // Start with the final register state of the predecessor with least spill values. + // This is based on the following points: + // 1, The less spill value indicates that the register pressure of this path is smaller, + // so the values of this block are more likely to be allocated to registers. + // 2, Avoid the predecessor that contains the function call, because the predecessor that + // contains the function call usually generates a lot of spills and lose the previous + // allocation state. + // TODO: Improve this part. At least the size of endRegs of the predecessor also has + // an impact on the code size and compiler speed. But it is not easy to find a simple + // and efficient method that combines multiple factors. + idx := -1 + for i, p := range b.Preds { + // If the predecessor has not been visited yet, skip it because its end state + // (redRegs and spillLive) has not been computed yet. + pb := p.b + if s.blockOrder[pb.ID] >= s.blockOrder[b.ID] { + continue + } + if idx == -1 { + idx = i + continue + } + pSel := b.Preds[idx].b + if len(s.spillLive[pb.ID]) < len(s.spillLive[pSel.ID]) { + idx = i + } else if len(s.spillLive[pb.ID]) == len(s.spillLive[pSel.ID]) { + // Use a bit of likely information. After critical pass, pb and pSel must + // be plain blocks, so check edge pb->pb.Preds instead of edge pb->b. + // TODO: improve the prediction of the likely predecessor. The following + // method is only suitable for the simplest cases. For complex cases, + // the prediction may be inaccurate, but this does not affect the + // correctness of the program. + // According to the layout algorithm, the predecessor with the + // smaller blockOrder is the true branch, and the test results show + // that it is better to choose the predecessor with a smaller + // blockOrder than no choice. + if pb.likelyBranch() && !pSel.likelyBranch() || s.blockOrder[pb.ID] < s.blockOrder[pSel.ID] { + idx = i + } + } + } + if idx < 0 { + f.Fatalf("bad visitOrder, no predecessor of %s has been visited before it", b) + } + p := b.Preds[idx].b + s.setState(s.endRegs[p.ID]) + + if s.f.pass.debug > regDebug { + fmt.Printf("starting merge block %s with end state of %s:\n", b, p) + for _, x := range s.endRegs[p.ID] { + fmt.Printf(" %s: orig:%s cache:%s\n", &s.registers[x.r], x.v, x.c) + } + } + + // Decide on registers for phi ops. Use the registers determined + // by the primary predecessor if we can. + // TODO: pick best of (already processed) predecessors? + // Majority vote? Deepest nesting level? + phiRegs = phiRegs[:0] + var phiUsed regMask + + for _, v := range phis { + if !s.values[v.ID].needReg { + phiRegs = append(phiRegs, noRegister) + continue + } + a := v.Args[idx] + // Some instructions target not-allocatable registers. + // They're not suitable for further (phi-function) allocation. + m := s.values[a.ID].regs &^ phiUsed & s.allocatable + if m != 0 { + r := pickReg(m) + phiUsed |= regMask(1) << r + phiRegs = append(phiRegs, r) + } else { + phiRegs = append(phiRegs, noRegister) + } + } + + // Second pass - deallocate all in-register phi inputs. + for i, v := range phis { + if !s.values[v.ID].needReg { + continue + } + a := v.Args[idx] + r := phiRegs[i] + if r == noRegister { + continue + } + if regValLiveSet.contains(a.ID) { + // Input value is still live (it is used by something other than Phi). + // Try to move it around before kicking out, if there is a free register. + // We generate a Copy in the predecessor block and record it. It will be + // deleted later if never used. + // + // Pick a free register. At this point some registers used in the predecessor + // block may have been deallocated. Those are the ones used for Phis. Exclude + // them (and they are not going to be helpful anyway). + m := s.compatRegs(a.Type) &^ s.used &^ phiUsed + if m != 0 && !s.values[a.ID].rematerializeable && countRegs(s.values[a.ID].regs) == 1 { + r2 := pickReg(m) + c := p.NewValue1(a.Pos, OpCopy, a.Type, s.regs[r].c) + s.copies[c] = false + if s.f.pass.debug > regDebug { + fmt.Printf("copy %s to %s : %s\n", a, c, &s.registers[r2]) + } + s.setOrig(c, a) + s.assignReg(r2, a, c) + s.endRegs[p.ID] = append(s.endRegs[p.ID], endReg{r2, a, c}) + } + } + s.freeReg(r) + } + + // Copy phi ops into new schedule. + b.Values = append(b.Values, phis...) + + // Third pass - pick registers for phis whose input + // was not in a register in the primary predecessor. + for i, v := range phis { + if !s.values[v.ID].needReg { + continue + } + if phiRegs[i] != noRegister { + continue + } + m := s.compatRegs(v.Type) &^ phiUsed &^ s.used + // If one of the other inputs of v is in a register, and the register is available, + // select this register, which can save some unnecessary copies. + for i, pe := range b.Preds { + if i == idx { + continue + } + ri := noRegister + for _, er := range s.endRegs[pe.b.ID] { + if er.v == s.orig[v.Args[i].ID] { + ri = er.r + break + } + } + if ri != noRegister && m>>ri&1 != 0 { + m = regMask(1) << ri + break + } + } + if m != 0 { + r := pickReg(m) + phiRegs[i] = r + phiUsed |= regMask(1) << r + } + } + + // Set registers for phis. Add phi spill code. + for i, v := range phis { + if !s.values[v.ID].needReg { + continue + } + r := phiRegs[i] + if r == noRegister { + // stack-based phi + // Spills will be inserted in all the predecessors below. + s.values[v.ID].spill = v // v starts life spilled + continue + } + // register-based phi + s.assignReg(r, v, v) + } + + // Deallocate any values which are no longer live. Phis are excluded. + for r := register(0); r < s.numRegs; r++ { + if phiUsed>>r&1 != 0 { + continue + } + v := s.regs[r].v + if v != nil && !regValLiveSet.contains(v.ID) { + s.freeReg(r) + } + } + + // Save the starting state for use by merge edges. + // We append to a stack allocated variable that we'll + // later copy into s.startRegs in one fell swoop, to save + // on allocations. + regList := make([]startReg, 0, 32) + for r := register(0); r < s.numRegs; r++ { + v := s.regs[r].v + if v == nil { + continue + } + if phiUsed>>r&1 != 0 { + // Skip registers that phis used, we'll handle those + // specially during merge edge processing. + continue + } + regList = append(regList, startReg{r, v, s.regs[r].c, s.values[v.ID].uses.pos}) + s.startRegsMask |= regMask(1) << r + } + s.startRegs[b.ID] = make([]startReg, len(regList)) + copy(s.startRegs[b.ID], regList) + + if s.f.pass.debug > regDebug { + fmt.Printf("after phis\n") + for _, x := range s.startRegs[b.ID] { + fmt.Printf(" %s: v%d\n", &s.registers[x.r], x.v.ID) + } + } + } + + // Drop phis from registers if they immediately go dead. + for i, v := range phis { + s.curIdx = i + s.dropIfUnused(v) + } + + // Allocate space to record the desired registers for each value. + if l := len(oldSched); cap(dinfo) < l { + dinfo = make([]dentry, l) + } else { + dinfo = dinfo[:l] + clear(dinfo) + } + + // Load static desired register info at the end of the block. + if s.desired != nil { + desired.copy(&s.desired[b.ID]) + } + + // Check actual assigned registers at the start of the next block(s). + // Dynamically assigned registers will trump the static + // desired registers computed during liveness analysis. + // Note that we do this phase after startRegs is set above, so that + // we get the right behavior for a block which branches to itself. + for _, e := range b.Succs { + succ := e.b + // TODO: prioritize likely successor? + for _, x := range s.startRegs[succ.ID] { + desired.add(x.v.ID, x.r) + } + // Process phi ops in succ. + pidx := e.i + for _, v := range succ.Values { + if v.Op != OpPhi { + break + } + if !s.values[v.ID].needReg { + continue + } + rp, ok := s.f.getHome(v.ID).(*Register) + if !ok { + // If v is not assigned a register, pick a register assigned to one of v's inputs. + // Hopefully v will get assigned that register later. + // If the inputs have allocated register information, add it to desired, + // which may reduce spill or copy operations when the register is available. + for _, a := range v.Args { + rp, ok = s.f.getHome(a.ID).(*Register) + if ok { + break + } + } + if !ok { + continue + } + } + desired.add(v.Args[pidx].ID, register(rp.num)) + } + } + // Walk values backwards computing desired register info. + // See computeDesired for more comments. + for i := len(oldSched) - 1; i >= 0; i-- { + v := oldSched[i] + prefs := desired.remove(v.ID) + regspec := s.regspec(v) + desired.clobber(regspec.clobbers) + for _, j := range regspec.inputs { + if countRegs(j.regs) != 1 { + continue + } + desired.clobber(j.regs) + desired.add(v.Args[j.idx].ID, pickReg(j.regs)) + } + if opcodeTable[v.Op].resultInArg0 || v.Op == OpAMD64ADDQconst || v.Op == OpAMD64ADDLconst || v.Op == OpSelect0 { + if opcodeTable[v.Op].commutative { + desired.addList(v.Args[1].ID, prefs) + } + desired.addList(v.Args[0].ID, prefs) + } + // Save desired registers for this value. + dinfo[i].out = prefs + for j, a := range v.Args { + if j >= len(dinfo[i].in) { + break + } + dinfo[i].in[j] = desired.get(a.ID) + } + if v.Op == OpSelect1 && prefs[0] != noRegister { + // Save desired registers of select1 for + // use by the tuple generating instruction. + desiredSecondReg[v.Args[0].ID] = prefs + } + } + + // Process all the non-phi values. + for idx, v := range oldSched { + s.curIdx = nphi + idx + tmpReg := noRegister + if s.f.pass.debug > regDebug { + fmt.Printf(" processing %s\n", v.LongString()) + } + regspec := s.regspec(v) + if v.Op == OpPhi { + f.Fatalf("phi %s not at start of block", v) + } + if opcodeTable[v.Op].fixedReg { + switch v.Op { + case OpSP: + s.assignReg(s.SPReg, v, v) + s.sp = v.ID + case OpSB: + s.assignReg(s.SBReg, v, v) + s.sb = v.ID + case OpARM64ZERO, OpLOONG64ZERO, OpMIPS64ZERO: + s.assignReg(s.ZeroIntReg, v, v) + case OpAMD64Zero128, OpAMD64Zero256, OpAMD64Zero512: + regspec := s.regspec(v) + m := regspec.outputs[0].regs + if countRegs(m) != 1 { + f.Fatalf("bad fixed-register op %s", v) + } + s.assignReg(pickReg(m), v, v) + default: + f.Fatalf("unknown fixed-register op %s", v) + } + b.Values = append(b.Values, v) + s.advanceUses(v) + continue + } + if v.Op == OpSelect0 || v.Op == OpSelect1 || v.Op == OpSelectN { + if s.values[v.ID].needReg { + if v.Op == OpSelectN { + s.assignReg(register(s.f.getHome(v.Args[0].ID).(LocResults)[int(v.AuxInt)].(*Register).num), v, v) + } else { + var i = 0 + if v.Op == OpSelect1 { + i = 1 + } + s.assignReg(register(s.f.getHome(v.Args[0].ID).(LocPair)[i].(*Register).num), v, v) + } + } + b.Values = append(b.Values, v) + s.advanceUses(v) + continue + } + if v.Op == OpGetG && s.f.Config.hasGReg { + // use hardware g register + if s.regs[s.GReg].v != nil { + s.freeReg(s.GReg) // kick out the old value + } + s.assignReg(s.GReg, v, v) + b.Values = append(b.Values, v) + s.advanceUses(v) + continue + } + if v.Op == OpArg { + // Args are "pre-spilled" values. We don't allocate + // any register here. We just set up the spill pointer to + // point at itself and any later user will restore it to use it. + s.values[v.ID].spill = v + b.Values = append(b.Values, v) + s.advanceUses(v) + continue + } + if v.Op == OpKeepAlive { + // Make sure the argument to v is still live here. + s.advanceUses(v) + a := v.Args[0] + vi := &s.values[a.ID] + if vi.regs == 0 && !vi.rematerializeable { + // Use the spill location. + // This forces later liveness analysis to make the + // value live at this point. + v.SetArg(0, s.makeSpill(a, b)) + } else if _, ok := a.Aux.(*ir.Name); ok && vi.rematerializeable { + // Rematerializeable value with a *ir.Name. This is the address of + // a stack object (e.g. an LEAQ). Keep the object live. + // Change it to VarLive, which is what plive expects for locals. + v.Op = OpVarLive + v.SetArgs1(v.Args[1]) + v.Aux = a.Aux + } else { + // In-register and rematerializeable values are already live. + // These are typically rematerializeable constants like nil, + // or values of a variable that were modified since the last call. + v.Op = OpCopy + v.SetArgs1(v.Args[1]) + } + b.Values = append(b.Values, v) + continue + } + if len(regspec.inputs) == 0 && len(regspec.outputs) == 0 { + // No register allocation required (or none specified yet) + if s.doClobber && v.Op.IsCall() { + s.clobberRegs(regspec.clobbers) + } + s.freeRegs(regspec.clobbers) + b.Values = append(b.Values, v) + s.advanceUses(v) + continue + } + + if s.values[v.ID].rematerializeable { + // Value is rematerializeable, don't issue it here. + // It will get issued just before each use (see + // allocValueToReg). + for _, a := range v.Args { + a.Uses-- + } + s.advanceUses(v) + continue + } + + if s.f.pass.debug > regDebug { + fmt.Printf("value %s\n", v.LongString()) + fmt.Printf(" out:") + for _, r := range dinfo[idx].out { + if r != noRegister { + fmt.Printf(" %s", &s.registers[r]) + } + } + fmt.Println() + for i := 0; i < len(v.Args) && i < 3; i++ { + fmt.Printf(" in%d:", i) + for _, r := range dinfo[idx].in[i] { + if r != noRegister { + fmt.Printf(" %s", &s.registers[r]) + } + } + fmt.Println() + } + } + + // Move arguments to registers. + // First, if an arg must be in a specific register and it is already + // in place, keep it. + args = append(args[:0], make([]*Value, len(v.Args))...) + for i, a := range v.Args { + if !s.values[a.ID].needReg { + args[i] = a + } + } + for _, i := range regspec.inputs { + mask := i.regs + if countRegs(mask) == 1 && mask&s.values[v.Args[i.idx].ID].regs != 0 { + args[i.idx] = s.allocValToReg(v.Args[i.idx], mask, true, v.Pos) + } + } + // Then, if an arg must be in a specific register and that + // register is free, allocate that one. Otherwise when processing + // another input we may kick a value into the free register, which + // then will be kicked out again. + // This is a common case for passing-in-register arguments for + // function calls. + for { + freed := false + for _, i := range regspec.inputs { + if args[i.idx] != nil { + continue // already allocated + } + mask := i.regs + if countRegs(mask) == 1 && mask&^s.used != 0 { + args[i.idx] = s.allocValToReg(v.Args[i.idx], mask, true, v.Pos) + // If the input is in other registers that will be clobbered by v, + // or the input is dead, free the registers. This may make room + // for other inputs. + oldregs := s.values[v.Args[i.idx].ID].regs + if oldregs&^regspec.clobbers == 0 || !s.liveAfterCurrentInstruction(v.Args[i.idx]) { + s.freeRegs(oldregs &^ mask &^ s.nospill) + freed = true + } + } + } + if !freed { + break + } + } + // Last, allocate remaining ones, in an ordering defined + // by the register specification (most constrained first). + for _, i := range regspec.inputs { + if args[i.idx] != nil { + continue // already allocated + } + mask := i.regs + if mask&s.values[v.Args[i.idx].ID].regs == 0 { + // Need a new register for the input. + mask &= s.allocatable + mask &^= s.nospill + // Used desired register if available. + if i.idx < 3 { + for _, r := range dinfo[idx].in[i.idx] { + if r != noRegister && (mask&^s.used)>>r&1 != 0 { + // Desired register is allowed and unused. + mask = regMask(1) << r + break + } + } + } + // Avoid registers we're saving for other values. + if mask&^desired.avoid != 0 { + mask &^= desired.avoid + } + } + if mask&s.values[v.Args[i.idx].ID].regs&(1<= 2 { + // we have at least 2 copies of arg0. We can afford to clobber one. + goto ok + } + if opcodeTable[v.Op].commutative && countRegs(s.values[v.Args[1].ID].regs) >= 2 { + args[0], args[1] = args[1], args[0] + goto ok + } + + // We can't overwrite arg0 (or arg1, if commutative). So we + // need to make a copy of an input so we have a register we can modify. + + // Possible new registers to copy into. + m = s.compatRegs(v.Args[0].Type) &^ s.used + if m == 0 { + // No free registers. In this case we'll just clobber + // an input and future uses of that input must use a restore. + // TODO(khr): We should really do this like allocReg does it, + // spilling the value with the most distant next use. + goto ok + } + + // Try to move an input to the desired output, if allowed. + for _, r := range dinfo[idx].out { + if r != noRegister && (m®spec.outputs[0].regs)>>r&1 != 0 { + m = regMask(1) << r + args[0] = s.allocValToReg(v.Args[0], m, true, v.Pos) + // Note: we update args[0] so the instruction will + // use the register copy we just made. + goto ok + } + } + // Try to copy input to its desired location & use its old + // location as the result register. + for _, r := range dinfo[idx].in[0] { + if r != noRegister && m>>r&1 != 0 { + m = regMask(1) << r + c := s.allocValToReg(v.Args[0], m, true, v.Pos) + s.copies[c] = false + // Note: no update to args[0] so the instruction will + // use the original copy. + goto ok + } + } + if opcodeTable[v.Op].commutative { + for _, r := range dinfo[idx].in[1] { + if r != noRegister && m>>r&1 != 0 { + m = regMask(1) << r + c := s.allocValToReg(v.Args[1], m, true, v.Pos) + s.copies[c] = false + args[0], args[1] = args[1], args[0] + goto ok + } + } + } + + // Avoid future fixed uses if we can. + if m&^desired.avoid != 0 { + m &^= desired.avoid + } + // Save input 0 to a new register so we can clobber it. + c := s.allocValToReg(v.Args[0], m, true, v.Pos) + s.copies[c] = false + + // Normally we use the register of the old copy of input 0 as the target. + // However, if input 0 is already in its desired register then we use + // the register of the new copy instead. + if regspec.outputs[0].regs>>s.f.getHome(c.ID).(*Register).num&1 != 0 { + if rp, ok := s.f.getHome(args[0].ID).(*Register); ok { + r := register(rp.num) + for _, r2 := range dinfo[idx].in[0] { + if r == r2 { + args[0] = c + break + } + } + } + } + } + ok: + for i := 0; i < 2; i++ { + if !(i == 0 && regspec.clobbersArg0 || i == 1 && regspec.clobbersArg1) { + continue + } + if !s.liveAfterCurrentInstruction(v.Args[i]) { + // arg is dead. We can clobber its register. + continue + } + if s.values[v.Args[i].ID].rematerializeable { + // We can rematerialize the input, don't worry about clobbering it. + continue + } + if countRegs(s.values[v.Args[i].ID].regs) >= 2 { + // We have at least 2 copies of arg. We can afford to clobber one. + continue + } + // Possible new registers to copy into. + m := s.compatRegs(v.Args[i].Type) &^ s.used + if m == 0 { + // No free registers. In this case we'll just clobber the + // input and future uses of that input must use a restore. + // TODO(khr): We should really do this like allocReg does it, + // spilling the value with the most distant next use. + continue + } + // Copy input to a different register that won't be clobbered. + c := s.allocValToReg(v.Args[i], m, true, v.Pos) + s.copies[c] = false + } + + // Pick a temporary register if needed. + // It should be distinct from all the input registers, so we + // allocate it after all the input registers, but before + // the input registers are freed via advanceUses below. + // (Not all instructions need that distinct part, but it is conservative.) + // We also ensure it is not any of the single-choice output registers. + if opcodeTable[v.Op].needIntTemp { + m := s.allocatable & s.f.Config.gpRegMask + for _, out := range regspec.outputs { + if countRegs(out.regs) == 1 { + m &^= out.regs + } + } + if m&^desired.avoid&^s.nospill != 0 { + m &^= desired.avoid + } + tmpReg = s.allocReg(m, &tmpVal) + s.nospill |= regMask(1) << tmpReg + s.tmpused |= regMask(1) << tmpReg + } + + if regspec.clobbersArg0 { + s.freeReg(register(s.f.getHome(args[0].ID).(*Register).num)) + } + if regspec.clobbersArg1 && !(regspec.clobbersArg0 && s.f.getHome(args[0].ID) == s.f.getHome(args[1].ID)) { + s.freeReg(register(s.f.getHome(args[1].ID).(*Register).num)) + } + + // Now that all args are in regs, we're ready to issue the value itself. + // Before we pick a register for the output value, allow input registers + // to be deallocated. We do this here so that the output can use the + // same register as a dying input. + if !opcodeTable[v.Op].resultNotInArgs { + s.tmpused = s.nospill + s.nospill = 0 + s.advanceUses(v) // frees any registers holding args that are no longer live + } + + // Dump any registers which will be clobbered + if s.doClobber && v.Op.IsCall() { + // clobber registers that are marked as clobber in regmask, but + // don't clobber inputs. + s.clobberRegs(regspec.clobbers &^ s.tmpused &^ s.nospill) + } + s.freeRegs(regspec.clobbers) + s.tmpused |= regspec.clobbers + + // Pick registers for outputs. + { + outRegs := noRegisters // TODO if this is costly, hoist and clear incrementally below. + maxOutIdx := -1 + var used regMask + if tmpReg != noRegister { + // Ensure output registers are distinct from the temporary register. + // (Not all instructions need that distinct part, but it is conservative.) + used |= regMask(1) << tmpReg + } + for _, out := range regspec.outputs { + if out.regs == 0 { + continue + } + mask := out.regs & s.allocatable &^ used + if mask == 0 { + s.f.Fatalf("can't find any output register %s", v.LongString()) + } + if opcodeTable[v.Op].resultInArg0 && out.idx == 0 { + if !opcodeTable[v.Op].commutative { + // Output must use the same register as input 0. + r := register(s.f.getHome(args[0].ID).(*Register).num) + if mask>>r&1 == 0 { + s.f.Fatalf("resultInArg0 value's input %v cannot be an output of %s", s.f.getHome(args[0].ID).(*Register), v.LongString()) + } + mask = regMask(1) << r + } else { + // Output must use the same register as input 0 or 1. + r0 := register(s.f.getHome(args[0].ID).(*Register).num) + r1 := register(s.f.getHome(args[1].ID).(*Register).num) + // Check r0 and r1 for desired output register. + found := false + for _, r := range dinfo[idx].out { + if (r == r0 || r == r1) && (mask&^s.used)>>r&1 != 0 { + mask = regMask(1) << r + found = true + if r == r1 { + args[0], args[1] = args[1], args[0] + } + break + } + } + if !found { + // Neither are desired, pick r0. + mask = regMask(1) << r0 + } + } + } + if out.idx == 0 { // desired registers only apply to the first element of a tuple result + for _, r := range dinfo[idx].out { + if r != noRegister && (mask&^s.used)>>r&1 != 0 { + // Desired register is allowed and unused. + mask = regMask(1) << r + break + } + } + } + if out.idx == 1 { + if prefs, ok := desiredSecondReg[v.ID]; ok { + for _, r := range prefs { + if r != noRegister && (mask&^s.used)>>r&1 != 0 { + // Desired register is allowed and unused. + mask = regMask(1) << r + break + } + } + } + } + // Avoid registers we're saving for other values. + if mask&^desired.avoid&^s.nospill&^s.used != 0 { + mask &^= desired.avoid + } + r := s.allocReg(mask, v) + if out.idx > maxOutIdx { + maxOutIdx = out.idx + } + outRegs[out.idx] = r + used |= regMask(1) << r + s.tmpused |= regMask(1) << r + } + // Record register choices + if v.Type.IsTuple() { + var outLocs LocPair + if r := outRegs[0]; r != noRegister { + outLocs[0] = &s.registers[r] + } + if r := outRegs[1]; r != noRegister { + outLocs[1] = &s.registers[r] + } + s.f.setHome(v, outLocs) + // Note that subsequent SelectX instructions will do the assignReg calls. + } else if v.Type.IsResults() { + // preallocate outLocs to the right size, which is maxOutIdx+1 + outLocs := make(LocResults, maxOutIdx+1, maxOutIdx+1) + for i := 0; i <= maxOutIdx; i++ { + if r := outRegs[i]; r != noRegister { + outLocs[i] = &s.registers[r] + } + } + s.f.setHome(v, outLocs) + } else { + if r := outRegs[0]; r != noRegister { + s.assignReg(r, v, v) + } + } + if tmpReg != noRegister { + // Remember the temp register allocation, if any. + if s.f.tempRegs == nil { + s.f.tempRegs = map[ID]*Register{} + } + s.f.tempRegs[v.ID] = &s.registers[tmpReg] + } + } + + // deallocate dead args, if we have not done so + if opcodeTable[v.Op].resultNotInArgs { + s.nospill = 0 + s.advanceUses(v) // frees any registers holding args that are no longer live + } + s.tmpused = 0 + + // Issue the Value itself. + for i, a := range args { + v.SetArg(i, a) // use register version of arguments + } + b.Values = append(b.Values, v) + s.dropIfUnused(v) + } + + // Copy the control values - we need this so we can reduce the + // uses property of these values later. + controls := append(make([]*Value, 0, 2), b.ControlValues()...) + + // Load control values into registers. + for i, v := range b.ControlValues() { + if !s.values[v.ID].needReg { + continue + } + if s.f.pass.debug > regDebug { + fmt.Printf(" processing control %s\n", v.LongString()) + } + // We assume that a control input can be passed in any + // type-compatible register. If this turns out not to be true, + // we'll need to introduce a regspec for a block's control value. + b.ReplaceControl(i, s.allocValToReg(v, s.compatRegs(v.Type), false, b.Pos)) + } + + // Reduce the uses of the control values once registers have been loaded. + // This loop is equivalent to the advanceUses method. + for _, v := range controls { + vi := &s.values[v.ID] + if !vi.needReg { + continue + } + // Remove this use from the uses list. + u := vi.uses + vi.uses = u.next + if u.next == nil { + s.freeRegs(vi.regs) // value is dead + } + u.next = s.freeUseRecords + s.freeUseRecords = u + } + + // If we are approaching a merge point and we are the primary + // predecessor of it, find live values that we use soon after + // the merge point and promote them to registers now. + if len(b.Succs) == 1 { + if s.f.Config.hasGReg && s.regs[s.GReg].v != nil { + s.freeReg(s.GReg) // Spill value in G register before any merge. + } + if s.blockOrder[b.ID] > s.blockOrder[b.Succs[0].b.ID] { + // No point if we've already regalloc'd the destination. + goto badloop + } + // For this to be worthwhile, the loop must have no calls in it. + top := b.Succs[0].b + loop := s.loopnest.b2l[top.ID] + if loop == nil || loop.header != top || loop.containsUnavoidableCall { + goto badloop + } + + // TODO: sort by distance, pick the closest ones? + for _, live := range s.live[b.ID] { + if live.dist >= unlikelyDistance { + // Don't preload anything live after the loop. + continue + } + vid := live.ID + vi := &s.values[vid] + if vi.regs != 0 { + continue + } + if vi.rematerializeable { + continue + } + v := s.orig[vid] + m := s.compatRegs(v.Type) &^ s.used + // Used desired register if available. + outerloop: + for _, e := range desired.entries { + if e.ID != v.ID { + continue + } + for _, r := range e.regs { + if r != noRegister && m>>r&1 != 0 { + m = regMask(1) << r + break outerloop + } + } + } + if m&^desired.avoid != 0 { + m &^= desired.avoid + } + if m != 0 { + s.allocValToReg(v, m, false, b.Pos) + } + } + } + badloop: + ; + + // Save end-of-block register state. + // First count how many, this cuts allocations in half. + k := 0 + for r := register(0); r < s.numRegs; r++ { + v := s.regs[r].v + if v == nil { + continue + } + k++ + } + regList := make([]endReg, 0, k) + for r := register(0); r < s.numRegs; r++ { + v := s.regs[r].v + if v == nil { + continue + } + regList = append(regList, endReg{r, v, s.regs[r].c}) + } + s.endRegs[b.ID] = regList + + if checkEnabled { + regValLiveSet.clear() + if s.live != nil { + for _, x := range s.live[b.ID] { + regValLiveSet.add(x.ID) + } + } + for r := register(0); r < s.numRegs; r++ { + v := s.regs[r].v + if v == nil { + continue + } + if !regValLiveSet.contains(v.ID) { + s.f.Fatalf("val %s is in reg but not live at end of %s", v, b) + } + } + } + + // If a value is live at the end of the block and + // isn't in a register, generate a use for the spill location. + // We need to remember this information so that + // the liveness analysis in stackalloc is correct. + if s.live != nil { + for _, e := range s.live[b.ID] { + vi := &s.values[e.ID] + if vi.regs != 0 { + // in a register, we'll use that source for the merge. + continue + } + if vi.rematerializeable { + // we'll rematerialize during the merge. + continue + } + if s.f.pass.debug > regDebug { + fmt.Printf("live-at-end spill for %s at %s\n", s.orig[e.ID], b) + } + spill := s.makeSpill(s.orig[e.ID], b) + s.spillLive[b.ID] = append(s.spillLive[b.ID], spill.ID) + } + + // Clear any final uses. + // All that is left should be the pseudo-uses added for values which + // are live at the end of b. + for _, e := range s.live[b.ID] { + u := s.values[e.ID].uses + if u == nil { + f.Fatalf("live at end, no uses v%d", e.ID) + } + if u.next != nil { + f.Fatalf("live at end, too many uses v%d", e.ID) + } + s.values[e.ID].uses = nil + u.next = s.freeUseRecords + s.freeUseRecords = u + } + } + + // allocReg may have dropped registers from startRegsMask that + // aren't actually needed in startRegs. Synchronize back to + // startRegs. + // + // This must be done before placing spills, which will look at + // startRegs to decide if a block is a valid block for a spill. + if c := countRegs(s.startRegsMask); c != len(s.startRegs[b.ID]) { + regs := make([]startReg, 0, c) + for _, sr := range s.startRegs[b.ID] { + if s.startRegsMask&(regMask(1)< regDebug { + fmt.Printf("delete copied value %s\n", c.LongString()) + } + c.resetArgs() + f.freeValue(c) + delete(s.copies, c) + progress = true + } + } + if !progress { + break + } + } + + for _, b := range s.visitOrder { + i := 0 + for _, v := range b.Values { + if v.Op == OpInvalid { + continue + } + b.Values[i] = v + i++ + } + b.Values = b.Values[:i] + } +} + +func (s *regAllocState) placeSpills() { + mustBeFirst := func(op Op) bool { + return op.isLoweredGetClosurePtr() || op == OpPhi || op == OpArgIntReg || op == OpArgFloatReg + } + + // Start maps block IDs to the list of spills + // that go at the start of the block (but after any phis). + start := map[ID][]*Value{} + // After maps value IDs to the list of spills + // that go immediately after that value ID. + after := map[ID][]*Value{} + + for i := range s.values { + vi := s.values[i] + spill := vi.spill + if spill == nil { + continue + } + if spill.Block != nil { + // Some spills are already fully set up, + // like OpArgs and stack-based phis. + continue + } + v := s.orig[i] + + // Walk down the dominator tree looking for a good place to + // put the spill of v. At the start "best" is the best place + // we have found so far. + // TODO: find a way to make this O(1) without arbitrary cutoffs. + if v == nil { + panic(fmt.Errorf("nil v, s.orig[%d], vi = %v, spill = %s", i, vi, spill.LongString())) + } + best := v.Block + bestArg := v + var bestDepth int16 + if s.loopnest != nil && s.loopnest.b2l[best.ID] != nil { + bestDepth = s.loopnest.b2l[best.ID].depth + } + b := best + const maxSpillSearch = 100 + for i := 0; i < maxSpillSearch; i++ { + // Find the child of b in the dominator tree which + // dominates all restores. + p := b + b = nil + for c := s.sdom.Child(p); c != nil && i < maxSpillSearch; c, i = s.sdom.Sibling(c), i+1 { + if s.sdom[c.ID].entry <= vi.restoreMin && s.sdom[c.ID].exit >= vi.restoreMax { + // c also dominates all restores. Walk down into c. + b = c + break + } + } + if b == nil { + // Ran out of blocks which dominate all restores. + break + } + + var depth int16 + if s.loopnest != nil && s.loopnest.b2l[b.ID] != nil { + depth = s.loopnest.b2l[b.ID].depth + } + if depth > bestDepth { + // Don't push the spill into a deeper loop. + continue + } + + // If v is in a register at the start of b, we can + // place the spill here (after the phis). + if len(b.Preds) == 1 { + for _, e := range s.endRegs[b.Preds[0].b.ID] { + if e.v == v { + // Found a better spot for the spill. + best = b + bestArg = e.c + bestDepth = depth + break + } + } + } else { + for _, e := range s.startRegs[b.ID] { + if e.v == v { + // Found a better spot for the spill. + best = b + bestArg = e.c + bestDepth = depth + break + } + } + } + } + + // Put the spill in the best block we found. + spill.Block = best + spill.AddArg(bestArg) + if best == v.Block && !mustBeFirst(v.Op) { + // Place immediately after v. + after[v.ID] = append(after[v.ID], spill) + } else { + // Place at the start of best block. + start[best.ID] = append(start[best.ID], spill) + } + } + + // Insert spill instructions into the block schedules. + var oldSched []*Value + for _, b := range s.visitOrder { + nfirst := 0 + for _, v := range b.Values { + if !mustBeFirst(v.Op) { + break + } + nfirst++ + } + oldSched = append(oldSched[:0], b.Values[nfirst:]...) + b.Values = b.Values[:nfirst] + b.Values = append(b.Values, start[b.ID]...) + for _, v := range oldSched { + b.Values = append(b.Values, v) + b.Values = append(b.Values, after[v.ID]...) + } + } +} + +// shuffle fixes up all the merge edges (those going into blocks of indegree > 1). +func (s *regAllocState) shuffle(stacklive [][]ID) { + var e edgeState + e.s = s + e.cache = map[ID][]*Value{} + e.contents = map[Location]contentRecord{} + if s.f.pass.debug > regDebug { + fmt.Printf("shuffle %s\n", s.f.Name) + fmt.Println(s.f.String()) + } + + for _, b := range s.visitOrder { + if len(b.Preds) <= 1 { + continue + } + e.b = b + for i, edge := range b.Preds { + p := edge.b + e.p = p + e.setup(i, s.endRegs[p.ID], s.startRegs[b.ID], stacklive[p.ID]) + e.process() + } + } + + if s.f.pass.debug > regDebug { + fmt.Printf("post shuffle %s\n", s.f.Name) + fmt.Println(s.f.String()) + } +} + +type edgeState struct { + s *regAllocState + p, b *Block // edge goes from p->b. + + // for each pre-regalloc value, a list of equivalent cached values + cache map[ID][]*Value + cachedVals []ID // (superset of) keys of the above map, for deterministic iteration + + // map from location to the value it contains + contents map[Location]contentRecord + + // desired destination locations + destinations []dstRecord + extra []dstRecord + + usedRegs regMask // registers currently holding something + uniqueRegs regMask // registers holding the only copy of a value + finalRegs regMask // registers holding final target + rematerializeableRegs regMask // registers that hold rematerializeable values +} + +type contentRecord struct { + vid ID // pre-regalloc value + c *Value // cached value + final bool // this is a satisfied destination + pos src.XPos // source position of use of the value +} + +type dstRecord struct { + loc Location // register or stack slot + vid ID // pre-regalloc value it should contain + splice **Value // place to store reference to the generating instruction + pos src.XPos // source position of use of this location +} + +// setup initializes the edge state for shuffling. +func (e *edgeState) setup(idx int, srcReg []endReg, dstReg []startReg, stacklive []ID) { + if e.s.f.pass.debug > regDebug { + fmt.Printf("edge %s->%s\n", e.p, e.b) + } + + // Clear state. + clear(e.cache) + e.cachedVals = e.cachedVals[:0] + clear(e.contents) + e.usedRegs = 0 + e.uniqueRegs = 0 + e.finalRegs = 0 + e.rematerializeableRegs = 0 + + // Live registers can be sources. + for _, x := range srcReg { + e.set(&e.s.registers[x.r], x.v.ID, x.c, false, src.NoXPos) // don't care the position of the source + } + // So can all of the spill locations. + for _, spillID := range stacklive { + v := e.s.orig[spillID] + spill := e.s.values[v.ID].spill + if !e.s.sdom.IsAncestorEq(spill.Block, e.p) { + // Spills were placed that only dominate the uses found + // during the first regalloc pass. The edge fixup code + // can't use a spill location if the spill doesn't dominate + // the edge. + // We are guaranteed that if the spill doesn't dominate this edge, + // then the value is available in a register (because we called + // makeSpill for every value not in a register at the start + // of an edge). + continue + } + e.set(e.s.f.getHome(spillID), v.ID, spill, false, src.NoXPos) // don't care the position of the source + } + + // Figure out all the destinations we need. + dsts := e.destinations[:0] + for _, x := range dstReg { + dsts = append(dsts, dstRecord{&e.s.registers[x.r], x.v.ID, nil, x.pos}) + } + // Phis need their args to end up in a specific location. + for _, v := range e.b.Values { + if v.Op != OpPhi { + break + } + loc := e.s.f.getHome(v.ID) + if loc == nil { + continue + } + dsts = append(dsts, dstRecord{loc, v.Args[idx].ID, &v.Args[idx], v.Pos}) + } + e.destinations = dsts + + if e.s.f.pass.debug > regDebug { + for _, vid := range e.cachedVals { + a := e.cache[vid] + for _, c := range a { + fmt.Printf("src %s: v%d cache=%s\n", e.s.f.getHome(c.ID), vid, c) + } + } + for _, d := range e.destinations { + fmt.Printf("dst %s: v%d\n", d.loc, d.vid) + } + } +} + +// process generates code to move all the values to the right destination locations. +func (e *edgeState) process() { + dsts := e.destinations + + // Process the destinations until they are all satisfied. + for len(dsts) > 0 { + i := 0 + for _, d := range dsts { + if !e.processDest(d.loc, d.vid, d.splice, d.pos) { + // Failed - save for next iteration. + dsts[i] = d + i++ + } + } + if i < len(dsts) { + // Made some progress. Go around again. + dsts = dsts[:i] + + // Append any extras destinations we generated. + dsts = append(dsts, e.extra...) + e.extra = e.extra[:0] + continue + } + + // We made no progress. That means that any + // remaining unsatisfied moves are in simple cycles. + // For example, A -> B -> C -> D -> A. + // A ----> B + // ^ | + // | | + // | v + // D <---- C + + // To break the cycle, we pick an unused register, say R, + // and put a copy of B there. + // A ----> B + // ^ | + // | | + // | v + // D <---- C <---- R=copyofB + // When we resume the outer loop, the A->B move can now proceed, + // and eventually the whole cycle completes. + + // Copy any cycle location to a temp register. This duplicates + // one of the cycle entries, allowing the just duplicated value + // to be overwritten and the cycle to proceed. + d := dsts[0] + loc := d.loc + vid := e.contents[loc].vid + c := e.contents[loc].c + r := e.findRegFor(c.Type) + if e.s.f.pass.debug > regDebug { + fmt.Printf("breaking cycle with v%d in %s:%s\n", vid, loc, c) + } + e.erase(r) + pos := d.pos.WithNotStmt() + if _, isReg := loc.(*Register); isReg { + c = e.p.NewValue1(pos, OpCopy, c.Type, c) + } else { + c = e.p.NewValue1(pos, OpLoadReg, c.Type, c) + } + e.set(r, vid, c, false, pos) + if c.Op == OpLoadReg && e.s.isGReg(register(r.(*Register).num)) { + e.s.f.Fatalf("process.OpLoadReg targeting g: " + c.LongString()) + } + } +} + +// processDest generates code to put value vid into location loc. Returns true +// if progress was made. +func (e *edgeState) processDest(loc Location, vid ID, splice **Value, pos src.XPos) bool { + pos = pos.WithNotStmt() + occupant := e.contents[loc] + if occupant.vid == vid { + // Value is already in the correct place. + e.contents[loc] = contentRecord{vid, occupant.c, true, pos} + if splice != nil { + (*splice).Uses-- + *splice = occupant.c + occupant.c.Uses++ + } + // Note: if splice==nil then c will appear dead. This is + // non-SSA formed code, so be careful after this pass not to run + // deadcode elimination. + if _, ok := e.s.copies[occupant.c]; ok { + // The copy at occupant.c was used to avoid spill. + e.s.copies[occupant.c] = true + } + return true + } + + // Check if we're allowed to clobber the destination location. + if len(e.cache[occupant.vid]) == 1 && !e.s.values[occupant.vid].rematerializeable && !opcodeTable[e.s.orig[occupant.vid].Op].fixedReg { + // We can't overwrite the last copy + // of a value that needs to survive. + return false + } + + // Copy from a source of v, register preferred. + v := e.s.orig[vid] + var c *Value + var src Location + if e.s.f.pass.debug > regDebug { + fmt.Printf("moving v%d to %s\n", vid, loc) + fmt.Printf("sources of v%d:", vid) + } + if opcodeTable[v.Op].fixedReg { + c = v + src = e.s.f.getHome(v.ID) + } else { + for _, w := range e.cache[vid] { + h := e.s.f.getHome(w.ID) + if e.s.f.pass.debug > regDebug { + fmt.Printf(" %s:%s", h, w) + } + _, isreg := h.(*Register) + if src == nil || isreg { + c = w + src = h + } + } + } + if e.s.f.pass.debug > regDebug { + if src != nil { + fmt.Printf(" [use %s]\n", src) + } else { + fmt.Printf(" [no source]\n") + } + } + _, dstReg := loc.(*Register) + + // Pre-clobber destination. This avoids the + // following situation: + // - v is currently held in R0 and stacktmp0. + // - We want to copy stacktmp1 to stacktmp0. + // - We choose R0 as the temporary register. + // During the copy, both R0 and stacktmp0 are + // clobbered, losing both copies of v. Oops! + // Erasing the destination early means R0 will not + // be chosen as the temp register, as it will then + // be the last copy of v. + e.erase(loc) + var x *Value + if c == nil || e.s.values[vid].rematerializeable { + if !e.s.values[vid].rematerializeable { + e.s.f.Fatalf("can't find source for %s->%s: %s\n", e.p, e.b, v.LongString()) + } + if dstReg { + // We want to rematerialize v into a register that is incompatible with v's op's register mask. + // Instead of setting the wrong register for the rematerialized v, we should find the right register + // for it and emit an additional copy to move to the desired register. + // For #70451. + if e.s.regspec(v).outputs[0].regs®Mask(1<mem. Use temp register. + r := e.findRegFor(c.Type) + e.erase(r) + t := e.p.NewValue1(pos, OpLoadReg, c.Type, c) + e.set(r, vid, t, false, pos) + x = e.p.NewValue1(pos, OpStoreReg, loc.(LocalSlot).Type, t) + } + } + } + e.set(loc, vid, x, true, pos) + if x.Op == OpLoadReg && e.s.isGReg(register(loc.(*Register).num)) { + e.s.f.Fatalf("processDest.OpLoadReg targeting g: " + x.LongString()) + } + if splice != nil { + (*splice).Uses-- + *splice = x + x.Uses++ + } + return true +} + +// set changes the contents of location loc to hold the given value and its cached representative. +func (e *edgeState) set(loc Location, vid ID, c *Value, final bool, pos src.XPos) { + e.s.f.setHome(c, loc) + e.contents[loc] = contentRecord{vid, c, final, pos} + a := e.cache[vid] + if len(a) == 0 { + e.cachedVals = append(e.cachedVals, vid) + } + a = append(a, c) + e.cache[vid] = a + if r, ok := loc.(*Register); ok { + if e.usedRegs&(regMask(1)< regDebug { + fmt.Printf("%s\n", c.LongString()) + fmt.Printf("v%d now available in %s:%s\n", vid, loc, c) + } +} + +// erase removes any user of loc. +func (e *edgeState) erase(loc Location) { + cr := e.contents[loc] + if cr.c == nil { + return + } + vid := cr.vid + + if cr.final { + // Add a destination to move this value back into place. + // Make sure it gets added to the tail of the destination queue + // so we make progress on other moves first. + e.extra = append(e.extra, dstRecord{loc, cr.vid, nil, cr.pos}) + } + + // Remove c from the list of cached values. + a := e.cache[vid] + for i, c := range a { + if e.s.f.getHome(c.ID) == loc { + if e.s.f.pass.debug > regDebug { + fmt.Printf("v%d no longer available in %s:%s\n", vid, loc, c) + } + a[i], a = a[len(a)-1], a[:len(a)-1] + break + } + } + e.cache[vid] = a + + // Update register masks. + if r, ok := loc.(*Register); ok { + e.usedRegs &^= regMask(1) << uint(r.num) + if cr.final { + e.finalRegs &^= regMask(1) << uint(r.num) + } + e.rematerializeableRegs &^= regMask(1) << uint(r.num) + } + if len(a) == 1 { + if r, ok := e.s.f.getHome(a[0].ID).(*Register); ok { + e.uniqueRegs |= regMask(1) << uint(r.num) + } + } +} + +// findRegFor finds a register we can use to make a temp copy of type typ. +func (e *edgeState) findRegFor(typ *types.Type) Location { + // Which registers are possibilities. + m := e.s.compatRegs(typ) + + // Pick a register. In priority order: + // 1) an unused register + // 2) a non-unique register not holding a final value + // 3) a non-unique register + // 4) a register holding a rematerializeable value + x := m &^ e.usedRegs + if x != 0 { + return &e.s.registers[pickReg(x)] + } + x = m &^ e.uniqueRegs &^ e.finalRegs + if x != 0 { + return &e.s.registers[pickReg(x)] + } + x = m &^ e.uniqueRegs + if x != 0 { + return &e.s.registers[pickReg(x)] + } + x = m & e.rematerializeableRegs + if x != 0 { + return &e.s.registers[pickReg(x)] + } + + // No register is available. + // Pick a register to spill. + for _, vid := range e.cachedVals { + a := e.cache[vid] + for _, c := range a { + if r, ok := e.s.f.getHome(c.ID).(*Register); ok && m>>uint(r.num)&1 != 0 { + if !c.rematerializeable() { + x := e.p.NewValue1(c.Pos, OpStoreReg, c.Type, c) + // Allocate a temp location to spill a register to. + t := LocalSlot{N: e.s.f.NewLocal(c.Pos, c.Type), Type: c.Type} + // TODO: reuse these slots. They'll need to be erased first. + e.set(t, vid, x, false, c.Pos) + if e.s.f.pass.debug > regDebug { + fmt.Printf(" SPILL %s->%s %s\n", r, t, x.LongString()) + } + } + // r will now be overwritten by the caller. At some point + // later, the newly saved value will be moved back to its + // final destination in processDest. + return r + } + } + } + + fmt.Printf("m:%d unique:%d final:%d rematerializable:%d\n", m, e.uniqueRegs, e.finalRegs, e.rematerializeableRegs) + for _, vid := range e.cachedVals { + a := e.cache[vid] + for _, c := range a { + fmt.Printf("v%d: %s %s\n", vid, c, e.s.f.getHome(c.ID)) + } + } + e.s.f.Fatalf("can't find empty register on edge %s->%s", e.p, e.b) + return nil +} + +// rematerializeable reports whether the register allocator should recompute +// a value instead of spilling/restoring it. +func (v *Value) rematerializeable() bool { + if !opcodeTable[v.Op].rematerializeable { + return false + } + for _, a := range v.Args { + // Fixed-register allocations (SP, SB, etc.) are always available. + // Any other argument of an opcode makes it not rematerializeable. + if !opcodeTable[a.Op].fixedReg { + return false + } + } + return true +} + +type liveInfo struct { + ID ID // ID of value + dist int32 // # of instructions before next use + pos src.XPos // source position of next use +} + +// computeLive computes a map from block ID to a list of value IDs live at the end +// of that block. Together with the value ID is a count of how many instructions +// to the next use of that value. The resulting map is stored in s.live. +func (s *regAllocState) computeLive() { + f := s.f + // single block functions do not have variables that are live across + // branches + if len(f.Blocks) == 1 { + return + } + po := f.postorder() + s.live = make([][]liveInfo, f.NumBlocks()) + s.desired = make([]desiredState, f.NumBlocks()) + s.loopnest = f.loopnest() + + rematIDs := make([]ID, 0, 64) + + live := f.newSparseMapPos(f.NumValues()) + defer f.retSparseMapPos(live) + t := f.newSparseMapPos(f.NumValues()) + defer f.retSparseMapPos(t) + + s.loopnest.computeUnavoidableCalls() + + // Liveness analysis. + // This is an adapted version of the algorithm described in chapter 2.4.2 + // of Fabrice Rastello's On Sparse Intermediate Representations. + // https://web.archive.org/web/20240417212122if_/https://inria.hal.science/hal-00761555/file/habilitation.pdf#section.50 + // + // For our implementation, we fall back to a traditional iterative algorithm when we encounter + // Irreducible CFGs. They are very uncommon in Go code because they need to be constructed with + // gotos and our current loopnest definition does not compute all the information that + // we'd need to compute the loop ancestors for that step of the algorithm. + // + // Additionally, instead of only considering non-loop successors in the initial DFS phase, + // we compute the liveout as the union of all successors. This larger liveout set is a subset + // of the final liveout for the block and adding this information in the DFS phase means that + // we get slightly more accurate distance information. + var loopLiveIn map[*loop][]liveInfo + var numCalls []int32 + if len(s.loopnest.loops) > 0 && !s.loopnest.hasIrreducible { + loopLiveIn = make(map[*loop][]liveInfo) + numCalls = f.Cache.allocInt32Slice(f.NumBlocks()) + defer f.Cache.freeInt32Slice(numCalls) + } + + for { + changed := false + + for _, b := range po { + // Start with known live values at the end of the block. + live.clear() + for _, e := range s.live[b.ID] { + live.set(e.ID, e.dist, e.pos) + } + update := false + // arguments to phi nodes are live at this blocks out + for _, e := range b.Succs { + succ := e.b + delta := branchDistance(b, succ) + for _, v := range succ.Values { + if v.Op != OpPhi { + break + } + arg := v.Args[e.i] + if s.values[arg.ID].needReg && (!live.contains(arg.ID) || delta < live.get(arg.ID)) { + live.set(arg.ID, delta, v.Pos) + update = true + } + } + } + if update { + s.live[b.ID] = updateLive(live, s.live[b.ID]) + } + // Add len(b.Values) to adjust from end-of-block distance + // to beginning-of-block distance. + c := live.contents() + for i := range c { + c[i].val += int32(len(b.Values)) + } + + // Mark control values as live + for _, c := range b.ControlValues() { + if s.values[c.ID].needReg { + live.set(c.ID, int32(len(b.Values)), b.Pos) + } + } + + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + live.remove(v.ID) + if v.Op == OpPhi { + continue + } + if opcodeTable[v.Op].call { + if numCalls != nil { + numCalls[b.ID]++ + } + rematIDs = rematIDs[:0] + c := live.contents() + for i := range c { + c[i].val += unlikelyDistance + vid := c[i].key + if s.values[vid].rematerializeable { + rematIDs = append(rematIDs, vid) + } + } + // We don't spill rematerializeable values, and assuming they + // are live across a call would only force shuffle to add some + // (dead) constant rematerialization. Remove them. + for _, r := range rematIDs { + live.remove(r) + } + } + for _, a := range v.Args { + if s.values[a.ID].needReg { + live.set(a.ID, int32(i), v.Pos) + } + } + } + // This is a loop header, save our live-in so that + // we can use it to fill in the loop bodies later + if loopLiveIn != nil { + loop := s.loopnest.b2l[b.ID] + if loop != nil && loop.header.ID == b.ID { + loopLiveIn[loop] = updateLive(live, nil) + } + } + // For each predecessor of b, expand its list of live-at-end values. + // invariant: live contains the values live at the start of b + for _, e := range b.Preds { + p := e.b + delta := branchDistance(p, b) + + // Start t off with the previously known live values at the end of p. + t.clear() + for _, e := range s.live[p.ID] { + t.set(e.ID, e.dist, e.pos) + } + update := false + + // Add new live values from scanning this block. + for _, e := range live.contents() { + d := e.val + delta + if !t.contains(e.key) || d < t.get(e.key) { + update = true + t.set(e.key, d, e.pos) + } + } + + if !update { + continue + } + s.live[p.ID] = updateLive(t, s.live[p.ID]) + changed = true + } + } + + // Doing a traditional iterative algorithm and have run + // out of changes + if !changed { + break + } + + // Doing a pre-pass and will fill in the liveness information + // later + if loopLiveIn != nil { + break + } + // For loopless code, we have full liveness info after a single + // iteration + if len(s.loopnest.loops) == 0 { + break + } + } + if f.pass.debug > regDebug { + s.debugPrintLive("after dfs walk", f, s.live, s.desired) + } + + // irreducible CFGs and functions without loops are already + // done, compute their desired registers and return + if loopLiveIn == nil { + s.computeDesired() + return + } + + // Walk the loopnest from outer to inner, adding + // all live-in values from their parent. Instead of + // a recursive algorithm, iterate in depth order. + // TODO(dmo): can we permute the loopnest? can we avoid this copy? + loops := slices.Clone(s.loopnest.loops) + slices.SortFunc(loops, func(a, b *loop) int { + return cmp.Compare(a.depth, b.depth) + }) + + loopset := f.newSparseMapPos(f.NumValues()) + defer f.retSparseMapPos(loopset) + for _, loop := range loops { + if loop.outer == nil { + continue + } + livein := loopLiveIn[loop] + loopset.clear() + for _, l := range livein { + loopset.set(l.ID, l.dist, l.pos) + } + update := false + for _, l := range loopLiveIn[loop.outer] { + if !loopset.contains(l.ID) { + loopset.set(l.ID, l.dist, l.pos) + update = true + } + } + if update { + loopLiveIn[loop] = updateLive(loopset, livein) + } + } + // unknownDistance is a sentinel value for when we know a variable + // is live at any given block, but we do not yet know how far until it's next + // use. The distance will be computed later. + const unknownDistance = -1 + + // add live-in values of the loop headers to their children. + // This includes the loop headers themselves, since they can have values + // that die in the middle of the block and aren't live-out + for _, b := range po { + loop := s.loopnest.b2l[b.ID] + if loop == nil { + continue + } + headerLive := loopLiveIn[loop] + loopset.clear() + for _, l := range s.live[b.ID] { + loopset.set(l.ID, l.dist, l.pos) + } + update := false + for _, l := range headerLive { + if !loopset.contains(l.ID) { + loopset.set(l.ID, unknownDistance, src.NoXPos) + update = true + } + } + if update { + s.live[b.ID] = updateLive(loopset, s.live[b.ID]) + } + } + if f.pass.debug > regDebug { + s.debugPrintLive("after live loop prop", f, s.live, s.desired) + } + // Filling in liveness from loops leaves some blocks with no distance information + // Run over them and fill in the information from their successors. + // To stabilize faster, we quit when no block has missing values and we only + // look at blocks that still have missing values in subsequent iterations + unfinishedBlocks := f.Cache.allocBlockSlice(len(po)) + defer f.Cache.freeBlockSlice(unfinishedBlocks) + copy(unfinishedBlocks, po) + + for len(unfinishedBlocks) > 0 { + n := 0 + for _, b := range unfinishedBlocks { + live.clear() + unfinishedValues := 0 + for _, l := range s.live[b.ID] { + if l.dist == unknownDistance { + unfinishedValues++ + } + live.set(l.ID, l.dist, l.pos) + } + update := false + for _, e := range b.Succs { + succ := e.b + for _, l := range s.live[succ.ID] { + if !live.contains(l.ID) || l.dist == unknownDistance { + continue + } + dist := int32(len(succ.Values)) + l.dist + branchDistance(b, succ) + dist += numCalls[succ.ID] * unlikelyDistance + val := live.get(l.ID) + switch { + case val == unknownDistance: + unfinishedValues-- + fallthrough + case dist < val: + update = true + live.set(l.ID, dist, l.pos) + } + } + } + if update { + s.live[b.ID] = updateLive(live, s.live[b.ID]) + } + if unfinishedValues > 0 { + unfinishedBlocks[n] = b + n++ + } + } + unfinishedBlocks = unfinishedBlocks[:n] + } + + s.computeDesired() + + if f.pass.debug > regDebug { + s.debugPrintLive("final", f, s.live, s.desired) + } +} + +// computeDesired computes the desired register information at the end of each block. +// It is essentially a liveness analysis on machine registers instead of SSA values +// The desired register information is stored in s.desired. +func (s *regAllocState) computeDesired() { + + // TODO: Can we speed this up using the liveness information we have already + // from computeLive? + // TODO: Since we don't propagate information through phi nodes, can we do + // this as a single dominator tree walk instead of the iterative solution? + var desired desiredState + f := s.f + po := f.postorder() + for { + changed := false + for _, b := range po { + desired.copy(&s.desired[b.ID]) + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + prefs := desired.remove(v.ID) + if v.Op == OpPhi { + // TODO: if v is a phi, save desired register for phi inputs. + // For now, we just drop it and don't propagate + // desired registers back though phi nodes. + continue + } + regspec := s.regspec(v) + // Cancel desired registers if they get clobbered. + desired.clobber(regspec.clobbers) + // Update desired registers if there are any fixed register inputs. + for _, j := range regspec.inputs { + if countRegs(j.regs) != 1 { + continue + } + desired.clobber(j.regs) + desired.add(v.Args[j.idx].ID, pickReg(j.regs)) + } + // Set desired register of input 0 if this is a 2-operand instruction. + if opcodeTable[v.Op].resultInArg0 || v.Op == OpAMD64ADDQconst || v.Op == OpAMD64ADDLconst || v.Op == OpSelect0 { + // ADDQconst is added here because we want to treat it as resultInArg0 for + // the purposes of desired registers, even though it is not an absolute requirement. + // This is because we'd rather implement it as ADDQ instead of LEAQ. + // Same for ADDLconst + // Select0 is added here to propagate the desired register to the tuple-generating instruction. + if opcodeTable[v.Op].commutative { + desired.addList(v.Args[1].ID, prefs) + } + desired.addList(v.Args[0].ID, prefs) + } + } + for _, e := range b.Preds { + p := e.b + changed = s.desired[p.ID].merge(&desired) || changed + } + } + if !changed || (!s.loopnest.hasIrreducible && len(s.loopnest.loops) == 0) { + break + } + } +} + +// updateLive updates a given liveInfo slice with the contents of t +func updateLive(t *sparseMapPos, live []liveInfo) []liveInfo { + live = live[:0] + if cap(live) < t.size() { + live = make([]liveInfo, 0, t.size()) + } + for _, e := range t.contents() { + live = append(live, liveInfo{e.key, e.val, e.pos}) + } + return live +} + +// branchDistance calculates the distance between a block and a +// successor in pseudo-instructions. This is used to indicate +// likeliness +func branchDistance(b *Block, s *Block) int32 { + if len(b.Succs) == 2 { + if b.Succs[0].b == s && b.Likely == BranchLikely || + b.Succs[1].b == s && b.Likely == BranchUnlikely { + return likelyDistance + } + if b.Succs[0].b == s && b.Likely == BranchUnlikely || + b.Succs[1].b == s && b.Likely == BranchLikely { + return unlikelyDistance + } + } + // Note: the branch distance must be at least 1 to distinguish the control + // value use from the first user in a successor block. + return normalDistance +} + +func (s *regAllocState) debugPrintLive(stage string, f *Func, live [][]liveInfo, desired []desiredState) { + fmt.Printf("%s: live values at end of each block: %s\n", stage, f.Name) + for _, b := range f.Blocks { + s.debugPrintLiveBlock(b, live[b.ID], &desired[b.ID]) + } +} + +func (s *regAllocState) debugPrintLiveBlock(b *Block, live []liveInfo, desired *desiredState) { + fmt.Printf(" %s:", b) + slices.SortFunc(live, func(a, b liveInfo) int { + return cmp.Compare(a.ID, b.ID) + }) + for _, x := range live { + fmt.Printf(" v%d(%d)", x.ID, x.dist) + for _, e := range desired.entries { + if e.ID != x.ID { + continue + } + fmt.Printf("[") + first := true + for _, r := range e.regs { + if r == noRegister { + continue + } + if !first { + fmt.Printf(",") + } + fmt.Print(&s.registers[r]) + first = false + } + fmt.Printf("]") + } + } + if avoid := desired.avoid; avoid != 0 { + fmt.Printf(" avoid=%v", s.RegMaskString(avoid)) + } + fmt.Println() +} + +// A desiredState represents desired register assignments. +type desiredState struct { + // Desired assignments will be small, so we just use a list + // of valueID+registers entries. + entries []desiredStateEntry + // Registers that other values want to be in. This value will + // contain at least the union of the regs fields of entries, but + // may contain additional entries for values that were once in + // this data structure but are no longer. + avoid regMask +} +type desiredStateEntry struct { + // (pre-regalloc) value + ID ID + // Registers it would like to be in, in priority order. + // Unused slots are filled with noRegister. + // For opcodes that return tuples, we track desired registers only + // for the first element of the tuple (see desiredSecondReg for + // tracking the desired register for second part of a tuple). + regs [4]register +} + +// get returns a list of desired registers for value vid. +func (d *desiredState) get(vid ID) [4]register { + for _, e := range d.entries { + if e.ID == vid { + return e.regs + } + } + return [4]register{noRegister, noRegister, noRegister, noRegister} +} + +// add records that we'd like value vid to be in register r. +func (d *desiredState) add(vid ID, r register) { + d.avoid |= regMask(1) << r + for i := range d.entries { + e := &d.entries[i] + if e.ID != vid { + continue + } + if e.regs[0] == r { + // Already known and highest priority + return + } + for j := 1; j < len(e.regs); j++ { + if e.regs[j] == r { + // Move from lower priority to top priority + copy(e.regs[1:], e.regs[:j]) + e.regs[0] = r + return + } + } + copy(e.regs[1:], e.regs[:]) + e.regs[0] = r + return + } + d.entries = append(d.entries, desiredStateEntry{vid, [4]register{r, noRegister, noRegister, noRegister}}) +} + +func (d *desiredState) addList(vid ID, regs [4]register) { + // regs is in priority order, so iterate in reverse order. + for i := len(regs) - 1; i >= 0; i-- { + r := regs[i] + if r != noRegister { + d.add(vid, r) + } + } +} + +// clobber erases any desired registers in the set m. +func (d *desiredState) clobber(m regMask) { + for i := 0; i < len(d.entries); { + e := &d.entries[i] + j := 0 + for _, r := range e.regs { + if r != noRegister && m>>r&1 == 0 { + e.regs[j] = r + j++ + } + } + if j == 0 { + // No more desired registers for this value. + d.entries[i] = d.entries[len(d.entries)-1] + d.entries = d.entries[:len(d.entries)-1] + continue + } + for ; j < len(e.regs); j++ { + e.regs[j] = noRegister + } + i++ + } + d.avoid &^= m +} + +// copy copies a desired state from another desiredState x. +func (d *desiredState) copy(x *desiredState) { + d.entries = append(d.entries[:0], x.entries...) + d.avoid = x.avoid +} + +// remove removes the desired registers for vid and returns them. +func (d *desiredState) remove(vid ID) [4]register { + for i := range d.entries { + if d.entries[i].ID == vid { + regs := d.entries[i].regs + d.entries[i] = d.entries[len(d.entries)-1] + d.entries = d.entries[:len(d.entries)-1] + return regs + } + } + return [4]register{noRegister, noRegister, noRegister, noRegister} +} + +// merge merges another desired state x into d. Returns whether the set has +// changed +func (d *desiredState) merge(x *desiredState) bool { + oldAvoid := d.avoid + d.avoid |= x.avoid + // There should only be a few desired registers, so + // linear insert is ok. + for _, e := range x.entries { + d.addList(e.ID, e.regs) + } + return oldAvoid != d.avoid +} + +// computeUnavoidableCalls computes the containsUnavoidableCall fields in the loop nest. +func (loopnest *loopnest) computeUnavoidableCalls() { + f := loopnest.f + + hasCall := f.Cache.allocBoolSlice(f.NumBlocks()) + defer f.Cache.freeBoolSlice(hasCall) + for _, b := range f.Blocks { + if b.containsCall() { + hasCall[b.ID] = true + } + } + found := f.Cache.allocSparseSet(f.NumBlocks()) + defer f.Cache.freeSparseSet(found) + // Run dfs to find path through the loop that avoids all calls. + // Such path either escapes the loop or returns back to the header. + // It isn't enough to have exit not dominated by any call, for example: + // ... some loop + // call1 call2 + // \ / + // block + // ... + // block is not dominated by any single call, but we don't have call-free path to it. +loopLoop: + for _, l := range loopnest.loops { + found.clear() + tovisit := make([]*Block, 0, 8) + tovisit = append(tovisit, l.header) + for len(tovisit) > 0 { + cur := tovisit[len(tovisit)-1] + tovisit = tovisit[:len(tovisit)-1] + if hasCall[cur.ID] { + continue + } + for _, s := range cur.Succs { + nb := s.Block() + if nb == l.header { + // Found a call-free path around the loop. + continue loopLoop + } + if found.contains(nb.ID) { + // Already found via another path. + continue + } + nl := loopnest.b2l[nb.ID] + if nl == nil || (nl.depth <= l.depth && nl != l) { + // Left the loop. + continue + } + tovisit = append(tovisit, nb) + found.add(nb.ID) + } + } + // No call-free path was found. + l.containsUnavoidableCall = true + } +} + +func (b *Block) containsCall() bool { + if b.Kind == BlockDefer { + return true + } + for _, v := range b.Values { + if opcodeTable[v.Op].call { + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/regalloc_test.go b/go/src/cmd/compile/internal/ssa/regalloc_test.go new file mode 100644 index 0000000000000000000000000000000000000000..12f5820f1ff81d97efc3424dc1a19c9e00260c21 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/regalloc_test.go @@ -0,0 +1,348 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "cmd/internal/obj/x86" + "fmt" + "testing" +) + +func TestLiveControlOps(t *testing.T) { + c := testConfig(t) + f := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("x", OpAMD64MOVLconst, c.config.Types.Int8, 1, nil), + Valu("y", OpAMD64MOVLconst, c.config.Types.Int8, 2, nil), + Valu("a", OpAMD64TESTB, types.TypeFlags, 0, nil, "x", "y"), + Valu("b", OpAMD64TESTB, types.TypeFlags, 0, nil, "y", "x"), + Eq("a", "if", "exit"), + ), + Bloc("if", + Eq("b", "plain", "exit"), + ), + Bloc("plain", + Goto("exit"), + ), + Bloc("exit", + Exit("mem"), + ), + ) + flagalloc(f.f) + regalloc(f.f) + checkFunc(f.f) +} + +// Test to make sure G register is never reloaded from spill (spill of G is okay) +// See #25504 +func TestNoGetgLoadReg(t *testing.T) { + /* + Original: + func fff3(i int) *g { + gee := getg() + if i == 0 { + fff() + } + return gee // here + } + */ + c := testConfigARM64(t) + f := c.Fun("b1", + Bloc("b1", + Valu("v1", OpInitMem, types.TypeMem, 0, nil), + Valu("v6", OpArg, c.config.Types.Int64, 0, c.Temp(c.config.Types.Int64)), + Valu("v8", OpGetG, c.config.Types.Int64.PtrTo(), 0, nil, "v1"), + Valu("v11", OpARM64CMPconst, types.TypeFlags, 0, nil, "v6"), + Eq("v11", "b2", "b4"), + ), + Bloc("b4", + Goto("b3"), + ), + Bloc("b3", + Valu("v14", OpPhi, types.TypeMem, 0, nil, "v1", "v12"), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("v16", OpARM64MOVDstore, types.TypeMem, 0, nil, "v8", "sb", "v14"), + Exit("v16"), + ), + Bloc("b2", + Valu("v12", OpARM64CALLstatic, types.TypeMem, 0, AuxCallLSym("_"), "v1"), + Goto("b3"), + ), + ) + regalloc(f.f) + checkFunc(f.f) + // Double-check that we never restore to the G register. Regalloc should catch it, but check again anyway. + r := f.f.RegAlloc + for _, b := range f.blocks { + for _, v := range b.Values { + if v.Op == OpLoadReg && r[v.ID].String() == "g" { + t.Errorf("Saw OpLoadReg targeting g register: %s", v.LongString()) + } + } + } +} + +// Test to make sure we don't push spills into loops. +// See issue #19595. +func TestSpillWithLoop(t *testing.T) { + c := testConfig(t) + f := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("ptr", OpArg, c.config.Types.Int64.PtrTo(), 0, c.Temp(c.config.Types.Int64)), + Valu("cond", OpArg, c.config.Types.Bool, 0, c.Temp(c.config.Types.Bool)), + Valu("ld", OpAMD64MOVQload, c.config.Types.Int64, 0, nil, "ptr", "mem"), // this value needs a spill + Goto("loop"), + ), + Bloc("loop", + Valu("memphi", OpPhi, types.TypeMem, 0, nil, "mem", "call"), + Valu("call", OpAMD64CALLstatic, types.TypeMem, 0, AuxCallLSym("_"), "memphi"), + Valu("test", OpAMD64CMPBconst, types.TypeFlags, 0, nil, "cond"), + Eq("test", "next", "exit"), + ), + Bloc("next", + Goto("loop"), + ), + Bloc("exit", + Valu("store", OpAMD64MOVQstore, types.TypeMem, 0, nil, "ptr", "ld", "call"), + Exit("store"), + ), + ) + regalloc(f.f) + checkFunc(f.f) + for _, v := range f.blocks["loop"].Values { + if v.Op == OpStoreReg { + t.Errorf("spill inside loop %s", v.LongString()) + } + } +} + +func TestSpillMove1(t *testing.T) { + c := testConfig(t) + f := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("x", OpArg, c.config.Types.Int64, 0, c.Temp(c.config.Types.Int64)), + Valu("p", OpArg, c.config.Types.Int64.PtrTo(), 0, c.Temp(c.config.Types.Int64.PtrTo())), + Valu("a", OpAMD64TESTQ, types.TypeFlags, 0, nil, "x", "x"), + Goto("loop1"), + ), + Bloc("loop1", + Valu("y", OpAMD64MULQ, c.config.Types.Int64, 0, nil, "x", "x"), + Eq("a", "loop2", "exit1"), + ), + Bloc("loop2", + Eq("a", "loop1", "exit2"), + ), + Bloc("exit1", + // store before call, y is available in a register + Valu("mem2", OpAMD64MOVQstore, types.TypeMem, 0, nil, "p", "y", "mem"), + Valu("mem3", OpAMD64CALLstatic, types.TypeMem, 0, AuxCallLSym("_"), "mem2"), + Exit("mem3"), + ), + Bloc("exit2", + // store after call, y must be loaded from a spill location + Valu("mem4", OpAMD64CALLstatic, types.TypeMem, 0, AuxCallLSym("_"), "mem"), + Valu("mem5", OpAMD64MOVQstore, types.TypeMem, 0, nil, "p", "y", "mem4"), + Exit("mem5"), + ), + ) + flagalloc(f.f) + regalloc(f.f) + checkFunc(f.f) + // Spill should be moved to exit2. + if numSpills(f.blocks["loop1"]) != 0 { + t.Errorf("spill present from loop1") + } + if numSpills(f.blocks["loop2"]) != 0 { + t.Errorf("spill present in loop2") + } + if numSpills(f.blocks["exit1"]) != 0 { + t.Errorf("spill present in exit1") + } + if numSpills(f.blocks["exit2"]) != 1 { + t.Errorf("spill missing in exit2") + } + +} + +func TestSpillMove2(t *testing.T) { + c := testConfig(t) + f := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("x", OpArg, c.config.Types.Int64, 0, c.Temp(c.config.Types.Int64)), + Valu("p", OpArg, c.config.Types.Int64.PtrTo(), 0, c.Temp(c.config.Types.Int64.PtrTo())), + Valu("a", OpAMD64TESTQ, types.TypeFlags, 0, nil, "x", "x"), + Goto("loop1"), + ), + Bloc("loop1", + Valu("y", OpAMD64MULQ, c.config.Types.Int64, 0, nil, "x", "x"), + Eq("a", "loop2", "exit1"), + ), + Bloc("loop2", + Eq("a", "loop1", "exit2"), + ), + Bloc("exit1", + // store after call, y must be loaded from a spill location + Valu("mem2", OpAMD64CALLstatic, types.TypeMem, 0, AuxCallLSym("_"), "mem"), + Valu("mem3", OpAMD64MOVQstore, types.TypeMem, 0, nil, "p", "y", "mem2"), + Exit("mem3"), + ), + Bloc("exit2", + // store after call, y must be loaded from a spill location + Valu("mem4", OpAMD64CALLstatic, types.TypeMem, 0, AuxCallLSym("_"), "mem"), + Valu("mem5", OpAMD64MOVQstore, types.TypeMem, 0, nil, "p", "y", "mem4"), + Exit("mem5"), + ), + ) + flagalloc(f.f) + regalloc(f.f) + checkFunc(f.f) + // There should be a spill in loop1, and nowhere else. + // TODO: resurrect moving spills out of loops? We could put spills at the start of both exit1 and exit2. + if numSpills(f.blocks["loop1"]) != 1 { + t.Errorf("spill missing from loop1") + } + if numSpills(f.blocks["loop2"]) != 0 { + t.Errorf("spill present in loop2") + } + if numSpills(f.blocks["exit1"]) != 0 { + t.Errorf("spill present in exit1") + } + if numSpills(f.blocks["exit2"]) != 0 { + t.Errorf("spill present in exit2") + } + +} + +func TestClobbersArg0(t *testing.T) { + c := testConfig(t) + f := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("ptr", OpArg, c.config.Types.Int64.PtrTo(), 0, c.Temp(c.config.Types.Int64.PtrTo())), + Valu("dst", OpArg, c.config.Types.Int64.PtrTo().PtrTo(), 0, c.Temp(c.config.Types.Int64.PtrTo().PtrTo())), + Valu("zero", OpAMD64LoweredZeroLoop, types.TypeMem, 256, nil, "ptr", "mem"), + Valu("store", OpAMD64MOVQstore, types.TypeMem, 0, nil, "dst", "ptr", "zero"), + Exit("store"))) + flagalloc(f.f) + regalloc(f.f) + checkFunc(f.f) + // LoweredZeroLoop clobbers its argument, so there must be a copy of "ptr" somewhere + // so we still have that value available at "store". + if n := numCopies(f.blocks["entry"]); n != 1 { + fmt.Printf("%s\n", f.f.String()) + t.Errorf("got %d copies, want 1", n) + } +} + +func TestClobbersArg1(t *testing.T) { + c := testConfig(t) + f := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("src", OpArg, c.config.Types.Int64.PtrTo(), 0, c.Temp(c.config.Types.Int64.PtrTo())), + Valu("dst", OpArg, c.config.Types.Int64.PtrTo(), 0, c.Temp(c.config.Types.Int64.PtrTo())), + Valu("use1", OpArg, c.config.Types.Int64.PtrTo().PtrTo(), 0, c.Temp(c.config.Types.Int64.PtrTo().PtrTo())), + Valu("use2", OpArg, c.config.Types.Int64.PtrTo().PtrTo(), 0, c.Temp(c.config.Types.Int64.PtrTo().PtrTo())), + Valu("move", OpAMD64LoweredMoveLoop, types.TypeMem, 256, nil, "dst", "src", "mem"), + Valu("store1", OpAMD64MOVQstore, types.TypeMem, 0, nil, "use1", "src", "move"), + Valu("store2", OpAMD64MOVQstore, types.TypeMem, 0, nil, "use2", "dst", "store1"), + Exit("store2"))) + flagalloc(f.f) + regalloc(f.f) + checkFunc(f.f) + // LoweredMoveLoop clobbers its arguments, so there must be a copy of "src" and "dst" somewhere + // so we still have that value available at the stores. + if n := numCopies(f.blocks["entry"]); n != 2 { + fmt.Printf("%s\n", f.f.String()) + t.Errorf("got %d copies, want 2", n) + } +} + +func TestNoRematerializeDeadConstant(t *testing.T) { + c := testConfigARM64(t) + f := c.Fun("b1", + Bloc("b1", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("addr", OpArg, c.config.Types.Int32.PtrTo(), 0, c.Temp(c.config.Types.Int32.PtrTo())), + Valu("const", OpARM64MOVDconst, c.config.Types.Int32, -1, nil), // Original constant + Valu("cmp", OpARM64CMPconst, types.TypeFlags, 0, nil, "const"), + Goto("b2"), + ), + Bloc("b2", + Valu("phi_mem", OpPhi, types.TypeMem, 0, nil, "mem", "callmem"), + Eq("cmp", "b6", "b3"), + ), + Bloc("b3", + Valu("call", OpARM64CALLstatic, types.TypeMem, 0, AuxCallLSym("_"), "phi_mem"), + Valu("callmem", OpSelectN, types.TypeMem, 0, nil, "call"), + Eq("cmp", "b5", "b4"), + ), + Bloc("b4", // A block where we don't really need to rematerialize the constant -1 + Goto("b2"), + ), + Bloc("b5", + Valu("user", OpAMD64MOVQstore, types.TypeMem, 0, nil, "addr", "const", "callmem"), + Exit("user"), + ), + Bloc("b6", + Exit("phi_mem"), + ), + ) + + regalloc(f.f) + checkFunc(f.f) + + // Check that in block b4, there's no dead rematerialization of the constant -1 + for _, v := range f.blocks["b4"].Values { + if v.Op == OpARM64MOVDconst && v.AuxInt == -1 { + t.Errorf("constant -1 rematerialized in loop block b4: %s", v.LongString()) + } + } +} + +func numSpills(b *Block) int { + return numOps(b, OpStoreReg) +} +func numCopies(b *Block) int { + return numOps(b, OpCopy) +} +func numOps(b *Block, op Op) int { + n := 0 + for _, v := range b.Values { + if v.Op == op { + n++ + } + } + return n +} + +func TestRematerializeableRegCompatible(t *testing.T) { + c := testConfig(t) + f := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("x", OpAMD64MOVLconst, c.config.Types.Int32, 1, nil), + Valu("a", OpAMD64POR, c.config.Types.Float32, 0, nil, "x", "x"), + Valu("res", OpMakeResult, types.NewResults([]*types.Type{c.config.Types.Float32, types.TypeMem}), 0, nil, "a", "mem"), + Ret("res"), + ), + ) + regalloc(f.f) + checkFunc(f.f) + moveFound := false + for _, v := range f.f.Blocks[0].Values { + if v.Op == OpCopy && x86.REG_X0 <= v.Reg() && v.Reg() <= x86.REG_X31 { + moveFound = true + } + } + if !moveFound { + t.Errorf("Expects an Copy to be issued, but got: %+v", f.f) + } +} diff --git a/go/src/cmd/compile/internal/ssa/rewrite.go b/go/src/cmd/compile/internal/ssa/rewrite.go new file mode 100644 index 0000000000000000000000000000000000000000..29222ffc89276e9a0e2a33253a9ed0f32941d7d7 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewrite.go @@ -0,0 +1,2788 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/logopt" + "cmd/compile/internal/reflectdata" + "cmd/compile/internal/rttype" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/s390x" + "cmd/internal/objabi" + "cmd/internal/src" + "encoding/binary" + "fmt" + "internal/buildcfg" + "io" + "math" + "math/bits" + "os" + "path/filepath" + "strings" +) + +type deadValueChoice bool + +const ( + leaveDeadValues deadValueChoice = false + removeDeadValues = true + + repZeroThreshold = 1408 // size beyond which we use REP STOS for zeroing + repMoveThreshold = 1408 // size beyond which we use REP MOVS for copying +) + +// deadcode indicates whether rewrite should try to remove any values that become dead. +func applyRewrite(f *Func, rb blockRewriter, rv valueRewriter, deadcode deadValueChoice) { + // repeat rewrites until we find no more rewrites + pendingLines := f.cachedLineStarts // Holds statement boundaries that need to be moved to a new value/block + pendingLines.clear() + debug := f.pass.debug + if debug > 1 { + fmt.Printf("%s: rewriting for %s\n", f.pass.name, f.Name) + } + // if the number of rewrite iterations reaches itersLimit we will + // at that point turn on cycle detection. Instead of a fixed limit, + // size the limit according to func size to allow for cases such + // as the one in issue #66773. + itersLimit := f.NumBlocks() + if itersLimit < 20 { + itersLimit = 20 + } + var iters int + var states map[string]bool + for { + if debug > 1 { + fmt.Printf("%s: iter %d\n", f.pass.name, iters) + } + change := false + deadChange := false + for _, b := range f.Blocks { + var b0 *Block + if debug > 1 { + fmt.Printf("%s: start block\n", f.pass.name) + b0 = new(Block) + *b0 = *b + b0.Succs = append([]Edge{}, b.Succs...) // make a new copy, not aliasing + } + for i, c := range b.ControlValues() { + for c.Op == OpCopy { + c = c.Args[0] + b.ReplaceControl(i, c) + } + } + if rb(b) { + change = true + if debug > 1 { + fmt.Printf("rewriting %s -> %s\n", b0.LongString(), b.LongString()) + } + } + for j, v := range b.Values { + if debug > 1 { + fmt.Printf("%s: consider %v\n", f.pass.name, v.LongString()) + } + var v0 *Value + if debug > 1 { + v0 = new(Value) + *v0 = *v + v0.Args = append([]*Value{}, v.Args...) // make a new copy, not aliasing + } + if v.Uses == 0 && v.removeable() { + if v.Op != OpInvalid && deadcode == removeDeadValues { + // Reset any values that are now unused, so that we decrement + // the use count of all of its arguments. + // Not quite a deadcode pass, because it does not handle cycles. + // But it should help Uses==1 rules to fire. + v.reset(OpInvalid) + deadChange = true + } + // No point rewriting values which aren't used. + continue + } + + vchange := phielimValue(v) + if vchange && debug > 1 { + fmt.Printf("rewriting %s -> %s\n", v0.LongString(), v.LongString()) + } + + // Eliminate copy inputs. + // If any copy input becomes unused, mark it + // as invalid and discard its argument. Repeat + // recursively on the discarded argument. + // This phase helps remove phantom "dead copy" uses + // of a value so that a x.Uses==1 rule condition + // fires reliably. + for i, a := range v.Args { + if a.Op != OpCopy { + continue + } + aa := copySource(a) + v.SetArg(i, aa) + // If a, a copy, has a line boundary indicator, attempt to find a new value + // to hold it. The first candidate is the value that will replace a (aa), + // if it shares the same block and line and is eligible. + // The second option is v, which has a as an input. Because aa is earlier in + // the data flow, it is the better choice. + if a.Pos.IsStmt() == src.PosIsStmt { + if aa.Block == a.Block && aa.Pos.Line() == a.Pos.Line() && aa.Pos.IsStmt() != src.PosNotStmt { + aa.Pos = aa.Pos.WithIsStmt() + } else if v.Block == a.Block && v.Pos.Line() == a.Pos.Line() && v.Pos.IsStmt() != src.PosNotStmt { + v.Pos = v.Pos.WithIsStmt() + } else { + // Record the lost line and look for a new home after all rewrites are complete. + // TODO: it's possible (in FOR loops, in particular) for statement boundaries for the same + // line to appear in more than one block, but only one block is stored, so if both end + // up here, then one will be lost. + pendingLines.set(a.Pos, int32(a.Block.ID)) + } + a.Pos = a.Pos.WithNotStmt() + } + vchange = true + for a.Uses == 0 { + b := a.Args[0] + a.reset(OpInvalid) + a = b + } + } + if vchange && debug > 1 { + fmt.Printf("rewriting %s -> %s\n", v0.LongString(), v.LongString()) + } + + // apply rewrite function + if rv(v) { + vchange = true + // If value changed to a poor choice for a statement boundary, move the boundary + if v.Pos.IsStmt() == src.PosIsStmt { + if k := nextGoodStatementIndex(v, j, b); k != j { + v.Pos = v.Pos.WithNotStmt() + b.Values[k].Pos = b.Values[k].Pos.WithIsStmt() + } + } + } + + change = change || vchange + if vchange && debug > 1 { + fmt.Printf("rewriting %s -> %s\n", v0.LongString(), v.LongString()) + } + } + } + if !change && !deadChange { + break + } + iters++ + if (iters > itersLimit || debug >= 2) && change { + // We've done a suspiciously large number of rewrites (or we're in debug mode). + // As of Sep 2021, 90% of rewrites complete in 4 iterations or fewer + // and the maximum value encountered during make.bash is 12. + // Start checking for cycles. (This is too expensive to do routinely.) + // Note: we avoid this path for deadChange-only iterations, to fix #51639. + if states == nil { + states = make(map[string]bool) + } + h := f.rewriteHash() + if _, ok := states[h]; ok { + // We've found a cycle. + // To diagnose it, set debug to 2 and start again, + // so that we'll print all rules applied until we complete another cycle. + // If debug is already >= 2, we've already done that, so it's time to crash. + if debug < 2 { + debug = 2 + states = make(map[string]bool) + } else { + f.Fatalf("rewrite cycle detected") + } + } + states[h] = true + } + } + // remove clobbered values + for _, b := range f.Blocks { + j := 0 + for i, v := range b.Values { + vl := v.Pos + if v.Op == OpInvalid { + if v.Pos.IsStmt() == src.PosIsStmt { + pendingLines.set(vl, int32(b.ID)) + } + f.freeValue(v) + continue + } + if v.Pos.IsStmt() != src.PosNotStmt && !notStmtBoundary(v.Op) { + if pl, ok := pendingLines.get(vl); ok && pl == int32(b.ID) { + pendingLines.remove(vl) + v.Pos = v.Pos.WithIsStmt() + } + } + if i != j { + b.Values[j] = v + } + j++ + } + if pl, ok := pendingLines.get(b.Pos); ok && pl == int32(b.ID) { + b.Pos = b.Pos.WithIsStmt() + pendingLines.remove(b.Pos) + } + b.truncateValues(j) + } +} + +// Common functions called from rewriting rules + +func is64BitFloat(t *types.Type) bool { + return t.Size() == 8 && t.IsFloat() +} + +func is32BitFloat(t *types.Type) bool { + return t.Size() == 4 && t.IsFloat() +} + +func is64BitInt(t *types.Type) bool { + return t.Size() == 8 && t.IsInteger() +} + +func is32BitInt(t *types.Type) bool { + return t.Size() == 4 && t.IsInteger() +} + +func is16BitInt(t *types.Type) bool { + return t.Size() == 2 && t.IsInteger() +} + +func is8BitInt(t *types.Type) bool { + return t.Size() == 1 && t.IsInteger() +} + +func isPtr(t *types.Type) bool { + return t.IsPtrShaped() +} + +func copyCompatibleType(t1, t2 *types.Type) bool { + if t1.Size() != t2.Size() { + return false + } + if t1.IsInteger() { + return t2.IsInteger() + } + if isPtr(t1) { + return isPtr(t2) + } + return t1.Compare(t2) == types.CMPeq +} + +// mergeSym merges two symbolic offsets. There is no real merging of +// offsets, we just pick the non-nil one. +func mergeSym(x, y Sym) Sym { + if x == nil { + return y + } + if y == nil { + return x + } + panic(fmt.Sprintf("mergeSym with two non-nil syms %v %v", x, y)) +} + +func canMergeSym(x, y Sym) bool { + return x == nil || y == nil +} + +// canMergeLoadClobber reports whether the load can be merged into target without +// invalidating the schedule. +// It also checks that the other non-load argument x is something we +// are ok with clobbering. +func canMergeLoadClobber(target, load, x *Value) bool { + // The register containing x is going to get clobbered. + // Don't merge if we still need the value of x. + // We don't have liveness information here, but we can + // approximate x dying with: + // 1) target is x's only use. + // 2) target is not in a deeper loop than x. + switch { + case x.Uses == 2 && x.Op == OpPhi && len(x.Args) == 2 && (x.Args[0] == target || x.Args[1] == target) && target.Uses == 1: + // This is a simple detector to determine that x is probably + // not live after target. (It does not need to be perfect, + // regalloc will issue a reg-reg move to save it if we are wrong.) + // We have: + // x = Phi(?, target) + // target = Op(load, x) + // Because target has only one use as a Phi argument, we can schedule it + // very late. Hopefully, later than the other use of x. (The other use died + // between x and target, or exists on another branch entirely). + case x.Uses > 1: + return false + } + loopnest := x.Block.Func.loopnest() + if loopnest.depth(target.Block.ID) > loopnest.depth(x.Block.ID) { + return false + } + return canMergeLoad(target, load) +} + +// canMergeLoad reports whether the load can be merged into target without +// invalidating the schedule. +func canMergeLoad(target, load *Value) bool { + if target.Block.ID != load.Block.ID { + // If the load is in a different block do not merge it. + return false + } + + // We can't merge the load into the target if the load + // has more than one use. + if load.Uses != 1 { + return false + } + + mem := load.MemoryArg() + + // We need the load's memory arg to still be alive at target. That + // can't be the case if one of target's args depends on a memory + // state that is a successor of load's memory arg. + // + // For example, it would be invalid to merge load into target in + // the following situation because newmem has killed oldmem + // before target is reached: + // load = read ... oldmem + // newmem = write ... oldmem + // arg0 = read ... newmem + // target = add arg0 load + // + // If the argument comes from a different block then we can exclude + // it immediately because it must dominate load (which is in the + // same block as target). + var args []*Value + for _, a := range target.Args { + if a != load && a.Block.ID == target.Block.ID { + args = append(args, a) + } + } + + // memPreds contains memory states known to be predecessors of load's + // memory state. It is lazily initialized. + var memPreds map[*Value]bool + for i := 0; len(args) > 0; i++ { + const limit = 100 + if i >= limit { + // Give up if we have done a lot of iterations. + return false + } + v := args[len(args)-1] + args = args[:len(args)-1] + if target.Block.ID != v.Block.ID { + // Since target and load are in the same block + // we can stop searching when we leave the block. + continue + } + if v.Op == OpPhi { + // A Phi implies we have reached the top of the block. + // The memory phi, if it exists, is always + // the first logical store in the block. + continue + } + if v.Type.IsTuple() && v.Type.FieldType(1).IsMemory() { + // We could handle this situation however it is likely + // to be very rare. + return false + } + if v.Op.SymEffect()&SymAddr != 0 { + // This case prevents an operation that calculates the + // address of a local variable from being forced to schedule + // before its corresponding VarDef. + // See issue 28445. + // v1 = LOAD ... + // v2 = VARDEF + // v3 = LEAQ + // v4 = CMPQ v1 v3 + // We don't want to combine the CMPQ with the load, because + // that would force the CMPQ to schedule before the VARDEF, which + // in turn requires the LEAQ to schedule before the VARDEF. + return false + } + if v.Type.IsMemory() { + if memPreds == nil { + // Initialise a map containing memory states + // known to be predecessors of load's memory + // state. + memPreds = make(map[*Value]bool) + m := mem + const limit = 50 + for i := 0; i < limit; i++ { + if m.Op == OpPhi { + // The memory phi, if it exists, is always + // the first logical store in the block. + break + } + if m.Block.ID != target.Block.ID { + break + } + if !m.Type.IsMemory() { + break + } + memPreds[m] = true + if len(m.Args) == 0 { + break + } + m = m.MemoryArg() + } + } + + // We can merge if v is a predecessor of mem. + // + // For example, we can merge load into target in the + // following scenario: + // x = read ... v + // mem = write ... v + // load = read ... mem + // target = add x load + if memPreds[v] { + continue + } + return false + } + if len(v.Args) > 0 && v.Args[len(v.Args)-1] == mem { + // If v takes mem as an input then we know mem + // is valid at this point. + continue + } + for _, a := range v.Args { + if target.Block.ID == a.Block.ID { + args = append(args, a) + } + } + } + + return true +} + +// isSameCall reports whether aux is the same as the given named symbol. +func isSameCall(aux Aux, name string) bool { + fn := aux.(*AuxCall).Fn + return fn != nil && fn.String() == name +} + +func isMalloc(aux Aux) bool { + return isNewObject(aux) || isSpecializedMalloc(aux) +} + +func isNewObject(aux Aux) bool { + fn := aux.(*AuxCall).Fn + return fn != nil && fn.String() == "runtime.newobject" +} + +func isSpecializedMalloc(aux Aux) bool { + fn := aux.(*AuxCall).Fn + if fn == nil { + return false + } + name := fn.String() + return strings.HasPrefix(name, "runtime.mallocgcSmallNoScanSC") || + strings.HasPrefix(name, "runtime.mallocgcSmallScanNoHeaderSC") || + strings.HasPrefix(name, "runtime.mallocgcTinySize") +} + +// canLoadUnaligned reports if the architecture supports unaligned load operations. +func canLoadUnaligned(c *Config) bool { + return c.ctxt.Arch.Alignment == 1 +} + +// nlzX returns the number of leading zeros. +func nlz64(x int64) int { return bits.LeadingZeros64(uint64(x)) } +func nlz32(x int32) int { return bits.LeadingZeros32(uint32(x)) } +func nlz16(x int16) int { return bits.LeadingZeros16(uint16(x)) } +func nlz8(x int8) int { return bits.LeadingZeros8(uint8(x)) } + +// ntzX returns the number of trailing zeros. +func ntz64(x int64) int { return bits.TrailingZeros64(uint64(x)) } +func ntz32(x int32) int { return bits.TrailingZeros32(uint32(x)) } +func ntz16(x int16) int { return bits.TrailingZeros16(uint16(x)) } +func ntz8(x int8) int { return bits.TrailingZeros8(uint8(x)) } + +// oneBit reports whether x contains exactly one set bit. +func oneBit[T int8 | int16 | int32 | int64](x T) bool { + return x&(x-1) == 0 && x != 0 +} + +// nto returns the number of trailing ones. +func nto(x int64) int64 { + return int64(ntz64(^x)) +} + +// logX returns logarithm of n base 2. +// n must be a positive power of 2 (isPowerOfTwoX returns true). +func log8(n int8) int64 { return log8u(uint8(n)) } +func log16(n int16) int64 { return log16u(uint16(n)) } +func log32(n int32) int64 { return log32u(uint32(n)) } +func log64(n int64) int64 { return log64u(uint64(n)) } + +// logXu returns the logarithm of n base 2. +// n must be a power of 2 (isUnsignedPowerOfTwo returns true) +func log8u(n uint8) int64 { return int64(bits.Len8(n)) - 1 } +func log16u(n uint16) int64 { return int64(bits.Len16(n)) - 1 } +func log32u(n uint32) int64 { return int64(bits.Len32(n)) - 1 } +func log64u(n uint64) int64 { return int64(bits.Len64(n)) - 1 } + +// isPowerOfTwoX functions report whether n is a power of 2. +func isPowerOfTwo[T int8 | int16 | int32 | int64](n T) bool { + return n > 0 && n&(n-1) == 0 +} + +// isUnsignedPowerOfTwo reports whether n is an unsigned power of 2. +func isUnsignedPowerOfTwo[T uint8 | uint16 | uint32 | uint64](n T) bool { + return n != 0 && n&(n-1) == 0 +} + +// is32Bit reports whether n can be represented as a signed 32 bit integer. +func is32Bit(n int64) bool { + return n == int64(int32(n)) +} + +// is16Bit reports whether n can be represented as a signed 16 bit integer. +func is16Bit(n int64) bool { + return n == int64(int16(n)) +} + +// is8Bit reports whether n can be represented as a signed 8 bit integer. +func is8Bit(n int64) bool { + return n == int64(int8(n)) +} + +// isU8Bit reports whether n can be represented as an unsigned 8 bit integer. +func isU8Bit(n int64) bool { + return n == int64(uint8(n)) +} + +// is12Bit reports whether n can be represented as a signed 12 bit integer. +func is12Bit(n int64) bool { + return -(1<<11) <= n && n < (1<<11) +} + +// isU12Bit reports whether n can be represented as an unsigned 12 bit integer. +func isU12Bit(n int64) bool { + return 0 <= n && n < (1<<12) +} + +// isU16Bit reports whether n can be represented as an unsigned 16 bit integer. +func isU16Bit(n int64) bool { + return n == int64(uint16(n)) +} + +// isU32Bit reports whether n can be represented as an unsigned 32 bit integer. +func isU32Bit(n int64) bool { + return n == int64(uint32(n)) +} + +// is20Bit reports whether n can be represented as a signed 20 bit integer. +func is20Bit(n int64) bool { + return -(1<<19) <= n && n < (1<<19) +} + +// b2i translates a boolean value to 0 or 1 for assigning to auxInt. +func b2i(b bool) int64 { + if b { + return 1 + } + return 0 +} + +// b2i32 translates a boolean value to 0 or 1. +func b2i32(b bool) int32 { + if b { + return 1 + } + return 0 +} + +func canMulStrengthReduce(config *Config, x int64) bool { + _, ok := config.mulRecipes[x] + return ok +} +func canMulStrengthReduce32(config *Config, x int32) bool { + _, ok := config.mulRecipes[int64(x)] + return ok +} + +// mulStrengthReduce returns v*x evaluated at the location +// (block and source position) of m. +// canMulStrengthReduce must have returned true. +func mulStrengthReduce(m *Value, v *Value, x int64) *Value { + return v.Block.Func.Config.mulRecipes[x].build(m, v) +} + +// mulStrengthReduce32 returns v*x evaluated at the location +// (block and source position) of m. +// canMulStrengthReduce32 must have returned true. +// The upper 32 bits of m might be set to junk. +func mulStrengthReduce32(m *Value, v *Value, x int32) *Value { + return v.Block.Func.Config.mulRecipes[int64(x)].build(m, v) +} + +// shiftIsBounded reports whether (left/right) shift Value v is known to be bounded. +// A shift is bounded if it is shifting by less than the width of the shifted value. +func shiftIsBounded(v *Value) bool { + return v.AuxInt != 0 +} + +// canonLessThan returns whether x is "ordered" less than y, for purposes of normalizing +// generated code as much as possible. +func canonLessThan(x, y *Value) bool { + if x.Op != y.Op { + return x.Op < y.Op + } + if !x.Pos.SameFileAndLine(y.Pos) { + return x.Pos.Before(y.Pos) + } + return x.ID < y.ID +} + +// truncate64Fto32F converts a float64 value to a float32 preserving the bit pattern +// of the mantissa. It will panic if the truncation results in lost information. +func truncate64Fto32F(f float64) float32 { + if !isExactFloat32(f) { + panic("truncate64Fto32F: truncation is not exact") + } + if !math.IsNaN(f) { + return float32(f) + } + // NaN bit patterns aren't necessarily preserved across conversion + // instructions so we need to do the conversion manually. + b := math.Float64bits(f) + m := b & ((1 << 52) - 1) // mantissa (a.k.a. significand) + // | sign | exponent | mantissa | + r := uint32(((b >> 32) & (1 << 31)) | 0x7f800000 | (m >> (52 - 23))) + return math.Float32frombits(r) +} + +// DivisionNeedsFixUp reports whether the division needs fix-up code. +func DivisionNeedsFixUp(v *Value) bool { + return v.AuxInt == 0 +} + +// auxTo32F decodes a float32 from the AuxInt value provided. +func auxTo32F(i int64) float32 { + return truncate64Fto32F(math.Float64frombits(uint64(i))) +} + +func auxIntToBool(i int64) bool { + if i == 0 { + return false + } + return true +} +func auxIntToInt8(i int64) int8 { + return int8(i) +} +func auxIntToInt16(i int64) int16 { + return int16(i) +} +func auxIntToInt32(i int64) int32 { + return int32(i) +} +func auxIntToInt64(i int64) int64 { + return i +} +func auxIntToUint8(i int64) uint8 { + return uint8(i) +} +func auxIntToFloat32(i int64) float32 { + return float32(math.Float64frombits(uint64(i))) +} +func auxIntToFloat64(i int64) float64 { + return math.Float64frombits(uint64(i)) +} +func auxIntToValAndOff(i int64) ValAndOff { + return ValAndOff(i) +} +func auxIntToArm64BitField(i int64) arm64BitField { + return arm64BitField(i) +} +func auxIntToArm64ConditionalParams(i int64) arm64ConditionalParams { + var params arm64ConditionalParams + params.cond = Op(i & 0xffff) + i >>= 16 + params.nzcv = uint8(i & 0x0f) + i >>= 4 + params.constValue = uint8(i & 0x1f) + i >>= 5 + params.ind = i == 1 + return params +} +func auxIntToFlagConstant(x int64) flagConstant { + return flagConstant(x) +} + +func auxIntToOp(cc int64) Op { + return Op(cc) +} + +func boolToAuxInt(b bool) int64 { + if b { + return 1 + } + return 0 +} +func int8ToAuxInt(i int8) int64 { + return int64(i) +} +func int16ToAuxInt(i int16) int64 { + return int64(i) +} +func int32ToAuxInt(i int32) int64 { + return int64(i) +} +func int64ToAuxInt(i int64) int64 { + return i +} +func uint8ToAuxInt(i uint8) int64 { + return int64(int8(i)) +} +func float32ToAuxInt(f float32) int64 { + return int64(math.Float64bits(float64(f))) +} +func float64ToAuxInt(f float64) int64 { + return int64(math.Float64bits(f)) +} +func valAndOffToAuxInt(v ValAndOff) int64 { + return int64(v) +} +func arm64BitFieldToAuxInt(v arm64BitField) int64 { + return int64(v) +} +func arm64ConditionalParamsToAuxInt(v arm64ConditionalParams) int64 { + if v.cond&^0xffff != 0 { + panic("condition value exceeds 16 bits") + } + + var i int64 + if v.ind { + i = 1 << 25 + } + i |= int64(v.constValue) << 20 + i |= int64(v.nzcv) << 16 + i |= int64(v.cond) + return i +} + +func flagConstantToAuxInt(x flagConstant) int64 { + return int64(x) +} + +func opToAuxInt(o Op) int64 { + return int64(o) +} + +// Aux is an interface to hold miscellaneous data in Blocks and Values. +type Aux interface { + CanBeAnSSAAux() +} + +// for now only used to mark moves that need to avoid clobbering flags +type auxMark bool + +func (auxMark) CanBeAnSSAAux() {} + +var AuxMark auxMark + +// stringAux wraps string values for use in Aux. +type stringAux string + +func (stringAux) CanBeAnSSAAux() {} + +func auxToString(i Aux) string { + return string(i.(stringAux)) +} +func auxToSym(i Aux) Sym { + // TODO: kind of a hack - allows nil interface through + s, _ := i.(Sym) + return s +} +func auxToType(i Aux) *types.Type { + return i.(*types.Type) +} +func auxToCall(i Aux) *AuxCall { + return i.(*AuxCall) +} +func auxToS390xCCMask(i Aux) s390x.CCMask { + return i.(s390x.CCMask) +} +func auxToS390xRotateParams(i Aux) s390x.RotateParams { + return i.(s390x.RotateParams) +} + +func StringToAux(s string) Aux { + return stringAux(s) +} +func symToAux(s Sym) Aux { + return s +} +func callToAux(s *AuxCall) Aux { + return s +} +func typeToAux(t *types.Type) Aux { + return t +} +func s390xCCMaskToAux(c s390x.CCMask) Aux { + return c +} +func s390xRotateParamsToAux(r s390x.RotateParams) Aux { + return r +} + +// uaddOvf reports whether unsigned a+b would overflow. +func uaddOvf(a, b int64) bool { + return uint64(a)+uint64(b) < uint64(a) +} + +func devirtLECall(v *Value, sym *obj.LSym) *Value { + v.Op = OpStaticLECall + auxcall := v.Aux.(*AuxCall) + auxcall.Fn = sym + // Remove first arg + v.Args[0].Uses-- + copy(v.Args[0:], v.Args[1:]) + v.Args[len(v.Args)-1] = nil // aid GC + v.Args = v.Args[:len(v.Args)-1] + if f := v.Block.Func; f.pass.debug > 0 { + f.Warnl(v.Pos, "de-virtualizing call") + } + return v +} + +// isSamePtr reports whether p1 and p2 point to the same address. +func isSamePtr(p1, p2 *Value) bool { + if p1 == p2 { + return true + } + if p1.Op != p2.Op { + for p1.Op == OpOffPtr && p1.AuxInt == 0 { + p1 = p1.Args[0] + } + for p2.Op == OpOffPtr && p2.AuxInt == 0 { + p2 = p2.Args[0] + } + if p1 == p2 { + return true + } + if p1.Op != p2.Op { + return false + } + } + switch p1.Op { + case OpOffPtr: + return p1.AuxInt == p2.AuxInt && isSamePtr(p1.Args[0], p2.Args[0]) + case OpAddr, OpLocalAddr: + return p1.Aux == p2.Aux + case OpAddPtr: + return p1.Args[1] == p2.Args[1] && isSamePtr(p1.Args[0], p2.Args[0]) + } + return false +} + +func isStackPtr(v *Value) bool { + for v.Op == OpOffPtr || v.Op == OpAddPtr { + v = v.Args[0] + } + return v.Op == OpSP || v.Op == OpLocalAddr +} + +// disjoint reports whether the memory region specified by [p1:p1+n1) +// does not overlap with [p2:p2+n2). +// A return value of false does not imply the regions overlap. +func disjoint(p1 *Value, n1 int64, p2 *Value, n2 int64) bool { + if n1 == 0 || n2 == 0 { + return true + } + if p1 == p2 { + return false + } + baseAndOffset := func(ptr *Value) (base *Value, offset int64) { + base, offset = ptr, 0 + for base.Op == OpOffPtr { + offset += base.AuxInt + base = base.Args[0] + } + if opcodeTable[base.Op].nilCheck { + base = base.Args[0] + } + return base, offset + } + + // Run types-based analysis + if disjointTypes(p1.Type, p2.Type) { + return true + } + + p1, off1 := baseAndOffset(p1) + p2, off2 := baseAndOffset(p2) + if isSamePtr(p1, p2) { + return !overlap(off1, n1, off2, n2) + } + // p1 and p2 are not the same, so if they are both OpAddrs then + // they point to different variables. + // If one pointer is on the stack and the other is an argument + // then they can't overlap. + switch p1.Op { + case OpAddr, OpLocalAddr: + if p2.Op == OpAddr || p2.Op == OpLocalAddr || p2.Op == OpSP { + return true + } + return (p2.Op == OpArg || p2.Op == OpArgIntReg) && p1.Args[0].Op == OpSP + case OpArg, OpArgIntReg: + if p2.Op == OpSP || p2.Op == OpLocalAddr { + return true + } + case OpSP: + return p2.Op == OpAddr || p2.Op == OpLocalAddr || p2.Op == OpArg || p2.Op == OpArgIntReg || p2.Op == OpSP + } + return false +} + +// disjointTypes reports whether a memory region pointed to by a pointer of type +// t1 does not overlap with a memory region pointed to by a pointer of type t2 -- +// based on type aliasing rules. +func disjointTypes(t1 *types.Type, t2 *types.Type) bool { + // Unsafe pointer can alias with anything. + if t1.IsUnsafePtr() || t2.IsUnsafePtr() { + return false + } + + if !t1.IsPtr() || !t2.IsPtr() { + panic("disjointTypes: one of arguments is not a pointer") + } + + t1 = t1.Elem() + t2 = t2.Elem() + + // Not-in-heap types are not supported -- they are rare and non-important; also, + // type.HasPointers check doesn't work for them correctly. + if t1.NotInHeap() || t2.NotInHeap() { + return false + } + + isPtrShaped := func(t *types.Type) bool { return int(t.Size()) == types.PtrSize && t.HasPointers() } + + // Pointers and non-pointers are disjoint (https://pkg.go.dev/unsafe#Pointer). + if (isPtrShaped(t1) && !t2.HasPointers()) || + (isPtrShaped(t2) && !t1.HasPointers()) { + return true + } + + return false +} + +// moveSize returns the number of bytes an aligned MOV instruction moves. +func moveSize(align int64, c *Config) int64 { + switch { + case align%8 == 0 && c.PtrSize == 8: + return 8 + case align%4 == 0: + return 4 + case align%2 == 0: + return 2 + } + return 1 +} + +// mergePoint finds a block among a's blocks which dominates b and is itself +// dominated by all of a's blocks. Returns nil if it can't find one. +// Might return nil even if one does exist. +func mergePoint(b *Block, a ...*Value) *Block { + // Walk backward from b looking for one of the a's blocks. + + // Max distance + d := 100 + + for d > 0 { + for _, x := range a { + if b == x.Block { + goto found + } + } + if len(b.Preds) > 1 { + // Don't know which way to go back. Abort. + return nil + } + b = b.Preds[0].b + d-- + } + return nil // too far away +found: + // At this point, r is the first value in a that we find by walking backwards. + // if we return anything, r will be it. + r := b + + // Keep going, counting the other a's that we find. They must all dominate r. + na := 0 + for d > 0 { + for _, x := range a { + if b == x.Block { + na++ + } + } + if na == len(a) { + // Found all of a in a backwards walk. We can return r. + return r + } + if len(b.Preds) > 1 { + return nil + } + b = b.Preds[0].b + d-- + + } + return nil // too far away +} + +// clobber invalidates values. Returns true. +// clobber is used by rewrite rules to: +// +// A) make sure the values are really dead and never used again. +// B) decrement use counts of the values' args. +func clobber(vv ...*Value) bool { + for _, v := range vv { + v.reset(OpInvalid) + // Note: leave v.Block intact. The Block field is used after clobber. + } + return true +} + +// resetCopy resets v to be a copy of arg. +// Always returns true. +func resetCopy(v *Value, arg *Value) bool { + v.reset(OpCopy) + v.AddArg(arg) + return true +} + +// clobberIfDead resets v when use count is 1. Returns true. +// clobberIfDead is used by rewrite rules to decrement +// use counts of v's args when v is dead and never used. +func clobberIfDead(v *Value) bool { + if v.Uses == 1 { + v.reset(OpInvalid) + } + // Note: leave v.Block intact. The Block field is used after clobberIfDead. + return true +} + +// noteRule is an easy way to track if a rule is matched when writing +// new ones. Make the rule of interest also conditional on +// +// noteRule("note to self: rule of interest matched") +// +// and that message will print when the rule matches. +func noteRule(s string) bool { + fmt.Println(s) + return true +} + +// countRule increments Func.ruleMatches[key]. +// If Func.ruleMatches is non-nil at the end +// of compilation, it will be printed to stdout. +// This is intended to make it easier to find which functions +// which contain lots of rules matches when developing new rules. +func countRule(v *Value, key string) bool { + f := v.Block.Func + if f.ruleMatches == nil { + f.ruleMatches = make(map[string]int) + } + f.ruleMatches[key]++ + return true +} + +// warnRule generates compiler debug output with string s when +// v is not in autogenerated code, cond is true and the rule has fired. +func warnRule(cond bool, v *Value, s string) bool { + if pos := v.Pos; pos.Line() > 1 && cond { + v.Block.Func.Warnl(pos, s) + } + return true +} + +// for a pseudo-op like (LessThan x), extract x. +func flagArg(v *Value) *Value { + if len(v.Args) != 1 || !v.Args[0].Type.IsFlags() { + return nil + } + return v.Args[0] +} + +// arm64Negate finds the complement to an ARM64 condition code, +// for example !Equal -> NotEqual or !LessThan -> GreaterEqual +// +// For floating point, it's more subtle because NaN is unordered. We do +// !LessThanF -> NotLessThanF, the latter takes care of NaNs. +func arm64Negate(op Op) Op { + switch op { + case OpARM64LessThan: + return OpARM64GreaterEqual + case OpARM64LessThanU: + return OpARM64GreaterEqualU + case OpARM64GreaterThan: + return OpARM64LessEqual + case OpARM64GreaterThanU: + return OpARM64LessEqualU + case OpARM64LessEqual: + return OpARM64GreaterThan + case OpARM64LessEqualU: + return OpARM64GreaterThanU + case OpARM64GreaterEqual: + return OpARM64LessThan + case OpARM64GreaterEqualU: + return OpARM64LessThanU + case OpARM64Equal: + return OpARM64NotEqual + case OpARM64NotEqual: + return OpARM64Equal + case OpARM64LessThanF: + return OpARM64NotLessThanF + case OpARM64NotLessThanF: + return OpARM64LessThanF + case OpARM64LessEqualF: + return OpARM64NotLessEqualF + case OpARM64NotLessEqualF: + return OpARM64LessEqualF + case OpARM64GreaterThanF: + return OpARM64NotGreaterThanF + case OpARM64NotGreaterThanF: + return OpARM64GreaterThanF + case OpARM64GreaterEqualF: + return OpARM64NotGreaterEqualF + case OpARM64NotGreaterEqualF: + return OpARM64GreaterEqualF + default: + panic("unreachable") + } +} + +// arm64Invert evaluates (InvertFlags op), which +// is the same as altering the condition codes such +// that the same result would be produced if the arguments +// to the flag-generating instruction were reversed, e.g. +// (InvertFlags (CMP x y)) -> (CMP y x) +func arm64Invert(op Op) Op { + switch op { + case OpARM64LessThan: + return OpARM64GreaterThan + case OpARM64LessThanU: + return OpARM64GreaterThanU + case OpARM64GreaterThan: + return OpARM64LessThan + case OpARM64GreaterThanU: + return OpARM64LessThanU + case OpARM64LessEqual: + return OpARM64GreaterEqual + case OpARM64LessEqualU: + return OpARM64GreaterEqualU + case OpARM64GreaterEqual: + return OpARM64LessEqual + case OpARM64GreaterEqualU: + return OpARM64LessEqualU + case OpARM64Equal, OpARM64NotEqual: + return op + case OpARM64LessThanF: + return OpARM64GreaterThanF + case OpARM64GreaterThanF: + return OpARM64LessThanF + case OpARM64LessEqualF: + return OpARM64GreaterEqualF + case OpARM64GreaterEqualF: + return OpARM64LessEqualF + case OpARM64NotLessThanF: + return OpARM64NotGreaterThanF + case OpARM64NotGreaterThanF: + return OpARM64NotLessThanF + case OpARM64NotLessEqualF: + return OpARM64NotGreaterEqualF + case OpARM64NotGreaterEqualF: + return OpARM64NotLessEqualF + default: + panic("unreachable") + } +} + +// evaluate an ARM64 op against a flags value +// that is potentially constant; return 1 for true, +// -1 for false, and 0 for not constant. +func ccARM64Eval(op Op, flags *Value) int { + fop := flags.Op + if fop == OpARM64InvertFlags { + return -ccARM64Eval(op, flags.Args[0]) + } + if fop != OpARM64FlagConstant { + return 0 + } + fc := flagConstant(flags.AuxInt) + b2i := func(b bool) int { + if b { + return 1 + } + return -1 + } + switch op { + case OpARM64Equal: + return b2i(fc.eq()) + case OpARM64NotEqual: + return b2i(fc.ne()) + case OpARM64LessThan: + return b2i(fc.lt()) + case OpARM64LessThanU: + return b2i(fc.ult()) + case OpARM64GreaterThan: + return b2i(fc.gt()) + case OpARM64GreaterThanU: + return b2i(fc.ugt()) + case OpARM64LessEqual: + return b2i(fc.le()) + case OpARM64LessEqualU: + return b2i(fc.ule()) + case OpARM64GreaterEqual: + return b2i(fc.ge()) + case OpARM64GreaterEqualU: + return b2i(fc.uge()) + } + return 0 +} + +// logRule logs the use of the rule s. This will only be enabled if +// rewrite rules were generated with the -log option, see _gen/rulegen.go. +func logRule(s string) { + if ruleFile == nil { + // Open a log file to write log to. We open in append + // mode because all.bash runs the compiler lots of times, + // and we want the concatenation of all of those logs. + // This means, of course, that users need to rm the old log + // to get fresh data. + // TODO: all.bash runs compilers in parallel. Need to synchronize logging somehow? + w, err := os.OpenFile(filepath.Join(os.Getenv("GOROOT"), "src", "rulelog"), + os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) + if err != nil { + panic(err) + } + ruleFile = w + } + // Ignore errors in case of multiple processes fighting over the file. + fmt.Fprintln(ruleFile, s) +} + +var ruleFile io.Writer + +func isConstZero(v *Value) bool { + switch v.Op { + case OpConstNil: + return true + case OpConst64, OpConst32, OpConst16, OpConst8, OpConstBool, OpConst32F, OpConst64F: + return v.AuxInt == 0 + case OpStringMake, OpIMake, OpComplexMake: + return isConstZero(v.Args[0]) && isConstZero(v.Args[1]) + case OpSliceMake: + return isConstZero(v.Args[0]) && isConstZero(v.Args[1]) && isConstZero(v.Args[2]) + case OpStringPtr, OpStringLen, OpSlicePtr, OpSliceLen, OpSliceCap, OpITab, OpIData, OpComplexReal, OpComplexImag: + return isConstZero(v.Args[0]) + } + return false +} + +// reciprocalExact64 reports whether 1/c is exactly representable. +func reciprocalExact64(c float64) bool { + b := math.Float64bits(c) + man := b & (1<<52 - 1) + if man != 0 { + return false // not a power of 2, denormal, or NaN + } + exp := b >> 52 & (1<<11 - 1) + // exponent bias is 0x3ff. So taking the reciprocal of a number + // changes the exponent to 0x7fe-exp. + switch exp { + case 0: + return false // ±0 + case 0x7ff: + return false // ±inf + case 0x7fe: + return false // exponent is not representable + default: + return true + } +} + +// reciprocalExact32 reports whether 1/c is exactly representable. +func reciprocalExact32(c float32) bool { + b := math.Float32bits(c) + man := b & (1<<23 - 1) + if man != 0 { + return false // not a power of 2, denormal, or NaN + } + exp := b >> 23 & (1<<8 - 1) + // exponent bias is 0x7f. So taking the reciprocal of a number + // changes the exponent to 0xfe-exp. + switch exp { + case 0: + return false // ±0 + case 0xff: + return false // ±inf + case 0xfe: + return false // exponent is not representable + default: + return true + } +} + +// check if an immediate can be directly encoded into an ARM's instruction. +func isARMImmRot(v uint32) bool { + for i := 0; i < 16; i++ { + if v&^0xff == 0 { + return true + } + v = v<<2 | v>>30 + } + + return false +} + +// overlap reports whether the ranges given by the given offset and +// size pairs overlap. +func overlap(offset1, size1, offset2, size2 int64) bool { + if offset1 >= offset2 && offset2+size2 > offset1 { + return true + } + if offset2 >= offset1 && offset1+size1 > offset2 { + return true + } + return false +} + +// check if value zeroes out upper 32-bit of 64-bit register. +// depth limits recursion depth. In AMD64.rules 3 is used as limit, +// because it catches same amount of cases as 4. +func zeroUpper32Bits(x *Value, depth int) bool { + if x.Type.IsSigned() && x.Type.Size() < 8 { + // If the value is signed, it might get re-sign-extended + // during spill and restore. See issue 68227. + return false + } + switch x.Op { + case OpAMD64MOVLconst, OpAMD64MOVLload, OpAMD64MOVLQZX, OpAMD64MOVLloadidx1, + OpAMD64MOVWload, OpAMD64MOVWloadidx1, OpAMD64MOVBload, OpAMD64MOVBloadidx1, + OpAMD64MOVLloadidx4, OpAMD64ADDLload, OpAMD64SUBLload, OpAMD64ANDLload, + OpAMD64ORLload, OpAMD64XORLload, OpAMD64CVTTSD2SL, + OpAMD64ADDL, OpAMD64ADDLconst, OpAMD64SUBL, OpAMD64SUBLconst, + OpAMD64ANDL, OpAMD64ANDLconst, OpAMD64ORL, OpAMD64ORLconst, + OpAMD64XORL, OpAMD64XORLconst, OpAMD64NEGL, OpAMD64NOTL, + OpAMD64SHRL, OpAMD64SHRLconst, OpAMD64SARL, OpAMD64SARLconst, + OpAMD64SHLL, OpAMD64SHLLconst: + return true + case OpARM64REV16W, OpARM64REVW, OpARM64RBITW, OpARM64CLZW, OpARM64EXTRWconst, + OpARM64MULW, OpARM64MNEGW, OpARM64UDIVW, OpARM64DIVW, OpARM64UMODW, + OpARM64MADDW, OpARM64MSUBW, OpARM64RORW, OpARM64RORWconst: + return true + case OpArg: // note: but not ArgIntReg + // amd64 always loads args from the stack unsigned. + // most other architectures load them sign/zero extended based on the type. + return x.Type.Size() == 4 && x.Block.Func.Config.arch == "amd64" + case OpPhi, OpSelect0, OpSelect1: + // Phis can use each-other as an arguments, instead of tracking visited values, + // just limit recursion depth. + if depth <= 0 { + return false + } + for i := range x.Args { + if !zeroUpper32Bits(x.Args[i], depth-1) { + return false + } + } + return true + + } + return false +} + +// zeroUpper48Bits is similar to zeroUpper32Bits, but for upper 48 bits. +func zeroUpper48Bits(x *Value, depth int) bool { + if x.Type.IsSigned() && x.Type.Size() < 8 { + return false + } + switch x.Op { + case OpAMD64MOVWQZX, OpAMD64MOVWload, OpAMD64MOVWloadidx1, OpAMD64MOVWloadidx2: + return true + case OpArg: // note: but not ArgIntReg + return x.Type.Size() == 2 && x.Block.Func.Config.arch == "amd64" + case OpPhi, OpSelect0, OpSelect1: + // Phis can use each-other as an arguments, instead of tracking visited values, + // just limit recursion depth. + if depth <= 0 { + return false + } + for i := range x.Args { + if !zeroUpper48Bits(x.Args[i], depth-1) { + return false + } + } + return true + + } + return false +} + +// zeroUpper56Bits is similar to zeroUpper32Bits, but for upper 56 bits. +func zeroUpper56Bits(x *Value, depth int) bool { + if x.Type.IsSigned() && x.Type.Size() < 8 { + return false + } + switch x.Op { + case OpAMD64MOVBQZX, OpAMD64MOVBload, OpAMD64MOVBloadidx1: + return true + case OpArg: // note: but not ArgIntReg + return x.Type.Size() == 1 && x.Block.Func.Config.arch == "amd64" + case OpPhi, OpSelect0, OpSelect1: + // Phis can use each-other as an arguments, instead of tracking visited values, + // just limit recursion depth. + if depth <= 0 { + return false + } + for i := range x.Args { + if !zeroUpper56Bits(x.Args[i], depth-1) { + return false + } + } + return true + + } + return false +} + +func isInlinableMemclr(c *Config, sz int64) bool { + if sz < 0 { + return false + } + // TODO: expand this check to allow other architectures + // see CL 454255 and issue 56997 + switch c.arch { + case "amd64", "arm64": + return true + case "ppc64le", "ppc64", "loong64": + return sz < 512 + } + return false +} + +// isInlinableMemmove reports whether the given arch performs a Move of the given size +// faster than memmove. It will only return true if replacing the memmove with a Move is +// safe, either because Move will do all of its loads before any of its stores, or +// because the arguments are known to be disjoint. +// This is used as a check for replacing memmove with Move ops. +func isInlinableMemmove(dst, src *Value, sz int64, c *Config) bool { + // It is always safe to convert memmove into Move when its arguments are disjoint. + // Move ops may or may not be faster for large sizes depending on how the platform + // lowers them, so we only perform this optimization on platforms that we know to + // have fast Move ops. + switch c.arch { + case "amd64": + return sz <= 16 || (sz < 1024 && disjoint(dst, sz, src, sz)) + case "arm64": + return sz <= 64 || (sz <= 1024 && disjoint(dst, sz, src, sz)) + case "386": + return sz <= 8 + case "s390x", "ppc64", "ppc64le": + return sz <= 8 || disjoint(dst, sz, src, sz) + case "arm", "loong64", "mips", "mips64", "mipsle", "mips64le": + return sz <= 4 + } + return false +} +func IsInlinableMemmove(dst, src *Value, sz int64, c *Config) bool { + return isInlinableMemmove(dst, src, sz, c) +} + +// logLargeCopy logs the occurrence of a large copy. +// The best place to do this is in the rewrite rules where the size of the move is easy to find. +// "Large" is arbitrarily chosen to be 128 bytes; this may change. +func logLargeCopy(v *Value, s int64) bool { + if s < 128 { + return true + } + if logopt.Enabled() { + logopt.LogOpt(v.Pos, "copy", "lower", v.Block.Func.Name, fmt.Sprintf("%d bytes", s)) + } + return true +} +func LogLargeCopy(funcName string, pos src.XPos, s int64) { + if s < 128 { + return + } + if logopt.Enabled() { + logopt.LogOpt(pos, "copy", "lower", funcName, fmt.Sprintf("%d bytes", s)) + } +} + +// hasSmallRotate reports whether the architecture has rotate instructions +// for sizes < 32-bit. This is used to decide whether to promote some rotations. +func hasSmallRotate(c *Config) bool { + switch c.arch { + case "amd64", "386": + return true + default: + return false + } +} + +func supportsPPC64PCRel() bool { + // PCRel is currently supported for >= power10, linux only + // Internal and external linking supports this on ppc64le; internal linking on ppc64. + return buildcfg.GOPPC64 >= 10 && buildcfg.GOOS == "linux" +} + +func newPPC64ShiftAuxInt(sh, mb, me, sz int64) int32 { + if sh < 0 || sh >= sz { + panic("PPC64 shift arg sh out of range") + } + if mb < 0 || mb >= sz { + panic("PPC64 shift arg mb out of range") + } + if me < 0 || me >= sz { + panic("PPC64 shift arg me out of range") + } + return int32(sh<<16 | mb<<8 | me) +} + +func GetPPC64Shiftsh(auxint int64) int64 { + return int64(int8(auxint >> 16)) +} + +func GetPPC64Shiftmb(auxint int64) int64 { + return int64(int8(auxint >> 8)) +} + +// Test if this value can encoded as a mask for a rlwinm like +// operation. Masks can also extend from the msb and wrap to +// the lsb too. That is, the valid masks are 32 bit strings +// of the form: 0..01..10..0 or 1..10..01..1 or 1...1 +// +// Note: This ignores the upper 32 bits of the input. When a +// zero extended result is desired (e.g a 64 bit result), the +// user must verify the upper 32 bits are 0 and the mask is +// contiguous (that is, non-wrapping). +func isPPC64WordRotateMask(v64 int64) bool { + // Isolate rightmost 1 (if none 0) and add. + v := uint32(v64) + vp := (v & -v) + v + // Likewise, for the wrapping case. + vn := ^v + vpn := (vn & -vn) + vn + return (v&vp == 0 || vn&vpn == 0) && v != 0 +} + +// Test if this mask is a valid, contiguous bitmask which can be +// represented by a RLWNM mask and also clears the upper 32 bits +// of the register. +func isPPC64WordRotateMaskNonWrapping(v64 int64) bool { + // Isolate rightmost 1 (if none 0) and add. + v := uint32(v64) + vp := (v & -v) + v + return (v&vp == 0) && v != 0 && uint64(uint32(v64)) == uint64(v64) +} + +// Compress mask and shift into single value of the form +// me | mb<<8 | rotate<<16 | nbits<<24 where me and mb can +// be used to regenerate the input mask. +func encodePPC64RotateMask(rotate, mask, nbits int64) int64 { + var mb, me, mbn, men int + + // Determine boundaries and then decode them + if mask == 0 || ^mask == 0 || rotate >= nbits { + panic(fmt.Sprintf("invalid PPC64 rotate mask: %x %d %d", uint64(mask), rotate, nbits)) + } else if nbits == 32 { + mb = bits.LeadingZeros32(uint32(mask)) + me = 32 - bits.TrailingZeros32(uint32(mask)) + mbn = bits.LeadingZeros32(^uint32(mask)) + men = 32 - bits.TrailingZeros32(^uint32(mask)) + } else { + mb = bits.LeadingZeros64(uint64(mask)) + me = 64 - bits.TrailingZeros64(uint64(mask)) + mbn = bits.LeadingZeros64(^uint64(mask)) + men = 64 - bits.TrailingZeros64(^uint64(mask)) + } + // Check for a wrapping mask (e.g bits at 0 and 63) + if mb == 0 && me == int(nbits) { + // swap the inverted values + mb, me = men, mbn + } + + return int64(me) | int64(mb<<8) | rotate<<16 | nbits<<24 +} + +// Merge (RLDICL [encoded] (SRDconst [s] x)) into (RLDICL [new_encoded] x) +// SRDconst on PPC64 is an extended mnemonic of RLDICL. If the input to an +// RLDICL is an SRDconst, and the RLDICL does not rotate its value, the two +// operations can be combined. This functions assumes the two opcodes can +// be merged, and returns an encoded rotate+mask value of the combined RLDICL. +func mergePPC64RLDICLandSRDconst(encoded, s int64) int64 { + mb := s + r := 64 - s + // A larger mb is a smaller mask. + if (encoded>>8)&0xFF < mb { + encoded = (encoded &^ 0xFF00) | mb<<8 + } + // The rotate is expected to be 0. + if (encoded & 0xFF0000) != 0 { + panic("non-zero rotate") + } + return encoded | r<<16 +} + +// DecodePPC64RotateMask is the inverse operation of encodePPC64RotateMask. The values returned as +// mb and me satisfy the POWER ISA definition of MASK(x,y) where MASK(mb,me) = mask. +func DecodePPC64RotateMask(sauxint int64) (rotate, mb, me int64, mask uint64) { + auxint := uint64(sauxint) + rotate = int64((auxint >> 16) & 0xFF) + mb = int64((auxint >> 8) & 0xFF) + me = int64((auxint >> 0) & 0xFF) + nbits := int64((auxint >> 24) & 0xFF) + mask = ((1 << uint(nbits-mb)) - 1) ^ ((1 << uint(nbits-me)) - 1) + if mb > me { + mask = ^mask + } + if nbits == 32 { + mask = uint64(uint32(mask)) + } + + // Fixup ME to match ISA definition. The second argument to MASK(..,me) + // is inclusive. + me = (me - 1) & (nbits - 1) + return +} + +// This verifies that the mask is a set of +// consecutive bits including the least +// significant bit. +func isPPC64ValidShiftMask(v int64) bool { + if (v != 0) && ((v+1)&v) == 0 { + return true + } + return false +} + +func getPPC64ShiftMaskLength(v int64) int64 { + return int64(bits.Len64(uint64(v))) +} + +// Decompose a shift right into an equivalent rotate/mask, +// and return mask & m. +func mergePPC64RShiftMask(m, s, nbits int64) int64 { + smask := uint64((1<> uint(s) + return m & int64(smask) +} + +// Combine (ANDconst [m] (SRWconst [s])) into (RLWINM [y]) or return 0 +func mergePPC64AndSrwi(m, s int64) int64 { + mask := mergePPC64RShiftMask(m, s, 32) + if !isPPC64WordRotateMask(mask) { + return 0 + } + return encodePPC64RotateMask((32-s)&31, mask, 32) +} + +// Combine (ANDconst [m] (SRDconst [s])) into (RLWINM [y]) or return 0 +func mergePPC64AndSrdi(m, s int64) int64 { + mask := mergePPC64RShiftMask(m, s, 64) + + // Verify the rotate and mask result only uses the lower 32 bits. + rv := bits.RotateLeft64(0xFFFFFFFF00000000, -int(s)) + if rv&uint64(mask) != 0 { + return 0 + } + if !isPPC64WordRotateMaskNonWrapping(mask) { + return 0 + } + return encodePPC64RotateMask((32-s)&31, mask, 32) +} + +// Combine (ANDconst [m] (SLDconst [s])) into (RLWINM [y]) or return 0 +func mergePPC64AndSldi(m, s int64) int64 { + mask := -1 << s & m + + // Verify the rotate and mask result only uses the lower 32 bits. + rv := bits.RotateLeft64(0xFFFFFFFF00000000, int(s)) + if rv&uint64(mask) != 0 { + return 0 + } + if !isPPC64WordRotateMaskNonWrapping(mask) { + return 0 + } + return encodePPC64RotateMask(s&31, mask, 32) +} + +// Test if a word shift right feeding into a CLRLSLDI can be merged into RLWINM. +// Return the encoded RLWINM constant, or 0 if they cannot be merged. +func mergePPC64ClrlsldiSrw(sld, srw int64) int64 { + mask_1 := uint64(0xFFFFFFFF >> uint(srw)) + // for CLRLSLDI, it's more convenient to think of it as a mask left bits then rotate left. + mask_2 := uint64(0xFFFFFFFFFFFFFFFF) >> uint(GetPPC64Shiftmb(sld)) + + // Rewrite mask to apply after the final left shift. + mask_3 := (mask_1 & mask_2) << uint(GetPPC64Shiftsh(sld)) + + r_1 := 32 - srw + r_2 := GetPPC64Shiftsh(sld) + r_3 := (r_1 + r_2) & 31 // This can wrap. + + if uint64(uint32(mask_3)) != mask_3 || mask_3 == 0 { + return 0 + } + return encodePPC64RotateMask(r_3, int64(mask_3), 32) +} + +// Test if a doubleword shift right feeding into a CLRLSLDI can be merged into RLWINM. +// Return the encoded RLWINM constant, or 0 if they cannot be merged. +func mergePPC64ClrlsldiSrd(sld, srd int64) int64 { + mask_1 := uint64(0xFFFFFFFFFFFFFFFF) >> uint(srd) + // for CLRLSLDI, it's more convenient to think of it as a mask left bits then rotate left. + mask_2 := uint64(0xFFFFFFFFFFFFFFFF) >> uint(GetPPC64Shiftmb(sld)) + + // Rewrite mask to apply after the final left shift. + mask_3 := (mask_1 & mask_2) << uint(GetPPC64Shiftsh(sld)) + + r_1 := 64 - srd + r_2 := GetPPC64Shiftsh(sld) + r_3 := (r_1 + r_2) & 63 // This can wrap. + + if uint64(uint32(mask_3)) != mask_3 || mask_3 == 0 { + return 0 + } + // This combine only works when selecting and shifting the lower 32 bits. + v1 := bits.RotateLeft64(0xFFFFFFFF00000000, int(r_3)) + if v1&mask_3 != 0 { + return 0 + } + return encodePPC64RotateMask(r_3&31, int64(mask_3), 32) +} + +// Test if a RLWINM feeding into a CLRLSLDI can be merged into RLWINM. Return +// the encoded RLWINM constant, or 0 if they cannot be merged. +func mergePPC64ClrlsldiRlwinm(sld int32, rlw int64) int64 { + r_1, _, _, mask_1 := DecodePPC64RotateMask(rlw) + // for CLRLSLDI, it's more convenient to think of it as a mask left bits then rotate left. + mask_2 := uint64(0xFFFFFFFFFFFFFFFF) >> uint(GetPPC64Shiftmb(int64(sld))) + + // combine the masks, and adjust for the final left shift. + mask_3 := (mask_1 & mask_2) << uint(GetPPC64Shiftsh(int64(sld))) + r_2 := GetPPC64Shiftsh(int64(sld)) + r_3 := (r_1 + r_2) & 31 // This can wrap. + + // Verify the result is still a valid bitmask of <= 32 bits. + if !isPPC64WordRotateMask(int64(mask_3)) || uint64(uint32(mask_3)) != mask_3 { + return 0 + } + return encodePPC64RotateMask(r_3, int64(mask_3), 32) +} + +// Test if RLWINM feeding into an ANDconst can be merged. Return the encoded RLWINM constant, +// or 0 if they cannot be merged. +func mergePPC64AndRlwinm(mask uint32, rlw int64) int64 { + r, _, _, mask_rlw := DecodePPC64RotateMask(rlw) + mask_out := (mask_rlw & uint64(mask)) + + // Verify the result is still a valid bitmask of <= 32 bits. + if !isPPC64WordRotateMask(int64(mask_out)) { + return 0 + } + return encodePPC64RotateMask(r, int64(mask_out), 32) +} + +// Test if RLWINM opcode rlw clears the upper 32 bits of the +// result. Return rlw if it does, 0 otherwise. +func mergePPC64MovwzregRlwinm(rlw int64) int64 { + _, mb, me, _ := DecodePPC64RotateMask(rlw) + if mb > me { + return 0 + } + return rlw +} + +// Test if AND feeding into an ANDconst can be merged. Return the encoded RLWINM constant, +// or 0 if they cannot be merged. +func mergePPC64RlwinmAnd(rlw int64, mask uint32) int64 { + r, _, _, mask_rlw := DecodePPC64RotateMask(rlw) + + // Rotate the input mask, combine with the rlwnm mask, and test if it is still a valid rlwinm mask. + r_mask := bits.RotateLeft32(mask, int(r)) + + mask_out := (mask_rlw & uint64(r_mask)) + + // Verify the result is still a valid bitmask of <= 32 bits. + if !isPPC64WordRotateMask(int64(mask_out)) { + return 0 + } + return encodePPC64RotateMask(r, int64(mask_out), 32) +} + +// Test if RLWINM feeding into SRDconst can be merged. Return the encoded RLIWNM constant, +// or 0 if they cannot be merged. +func mergePPC64SldiRlwinm(sldi, rlw int64) int64 { + r_1, mb, me, mask_1 := DecodePPC64RotateMask(rlw) + if mb > me || mb < sldi { + // Wrapping masks cannot be merged as the upper 32 bits are effectively undefined in this case. + // Likewise, if mb is less than the shift amount, it cannot be merged. + return 0 + } + // combine the masks, and adjust for the final left shift. + mask_3 := mask_1 << sldi + r_3 := (r_1 + sldi) & 31 // This can wrap. + + // Verify the result is still a valid bitmask of <= 32 bits. + if uint64(uint32(mask_3)) != mask_3 { + return 0 + } + return encodePPC64RotateMask(r_3, int64(mask_3), 32) +} + +// Compute the encoded RLWINM constant from combining (SLDconst [sld] (SRWconst [srw] x)), +// or return 0 if they cannot be combined. +func mergePPC64SldiSrw(sld, srw int64) int64 { + if sld > srw || srw >= 32 { + return 0 + } + mask_r := uint32(0xFFFFFFFF) >> uint(srw) + mask_l := uint32(0xFFFFFFFF) >> uint(sld) + mask := (mask_r & mask_l) << uint(sld) + return encodePPC64RotateMask((32-srw+sld)&31, int64(mask), 32) +} + +// Convert a PPC64 opcode from the Op to OpCC form. This converts (op x y) +// to (Select0 (opCC x y)) without having to explicitly fixup every user +// of op. +// +// E.g consider the case: +// a = (ADD x y) +// b = (CMPconst [0] a) +// c = (OR a z) +// +// A rule like (CMPconst [0] (ADD x y)) => (CMPconst [0] (Select0 (ADDCC x y))) +// would produce: +// a = (ADD x y) +// a' = (ADDCC x y) +// a” = (Select0 a') +// b = (CMPconst [0] a”) +// c = (OR a z) +// +// which makes it impossible to rewrite the second user. Instead the result +// of this conversion is: +// a' = (ADDCC x y) +// a = (Select0 a') +// b = (CMPconst [0] a) +// c = (OR a z) +// +// Which makes it trivial to rewrite b using a lowering rule. +func convertPPC64OpToOpCC(op *Value) *Value { + ccOpMap := map[Op]Op{ + OpPPC64ADD: OpPPC64ADDCC, + OpPPC64ADDconst: OpPPC64ADDCCconst, + OpPPC64AND: OpPPC64ANDCC, + OpPPC64ANDN: OpPPC64ANDNCC, + OpPPC64ANDconst: OpPPC64ANDCCconst, + OpPPC64CNTLZD: OpPPC64CNTLZDCC, + OpPPC64MULHDU: OpPPC64MULHDUCC, + OpPPC64NEG: OpPPC64NEGCC, + OpPPC64NOR: OpPPC64NORCC, + OpPPC64OR: OpPPC64ORCC, + OpPPC64RLDICL: OpPPC64RLDICLCC, + OpPPC64SUB: OpPPC64SUBCC, + OpPPC64XOR: OpPPC64XORCC, + } + b := op.Block + opCC := b.NewValue0I(op.Pos, ccOpMap[op.Op], types.NewTuple(op.Type, types.TypeFlags), op.AuxInt) + opCC.AddArgs(op.Args...) + op.reset(OpSelect0) + op.AddArgs(opCC) + return op +} + +// Try converting a RLDICL to ANDCC. If successful, return the mask otherwise 0. +func convertPPC64RldiclAndccconst(sauxint int64) int64 { + r, _, _, mask := DecodePPC64RotateMask(sauxint) + if r != 0 || mask&0xFFFF != mask { + return 0 + } + return int64(mask) +} + +// Convenience function to rotate a 32 bit constant value by another constant. +func rotateLeft32(v, rotate int64) int64 { + return int64(bits.RotateLeft32(uint32(v), int(rotate))) +} + +func rotateRight64(v, rotate int64) int64 { + return int64(bits.RotateLeft64(uint64(v), int(-rotate))) +} + +// encodes the lsb and width for arm(64) bitfield ops into the expected auxInt format. +func armBFAuxInt(lsb, width int64) arm64BitField { + if lsb < 0 || lsb > 63 { + panic("ARM(64) bit field lsb constant out of range") + } + if width < 1 || lsb+width > 64 { + panic("ARM(64) bit field width constant out of range") + } + return arm64BitField(width | lsb<<8) +} + +// returns the lsb part of the auxInt field of arm64 bitfield ops. +func (bfc arm64BitField) lsb() int64 { + return int64(uint64(bfc) >> 8) +} + +// returns the width part of the auxInt field of arm64 bitfield ops. +func (bfc arm64BitField) width() int64 { + return int64(bfc) & 0xff +} + +// checks if mask >> rshift applied at lsb is a valid arm64 bitfield op mask. +func isARM64BFMask(lsb, mask, rshift int64) bool { + shiftedMask := int64(uint64(mask) >> uint64(rshift)) + return shiftedMask != 0 && isPowerOfTwo(shiftedMask+1) && nto(shiftedMask)+lsb < 64 +} + +// returns the bitfield width of mask >> rshift for arm64 bitfield ops. +func arm64BFWidth(mask, rshift int64) int64 { + shiftedMask := int64(uint64(mask) >> uint64(rshift)) + if shiftedMask == 0 { + panic("ARM64 BF mask is zero") + } + return nto(shiftedMask) +} + +// encodes condition code and NZCV flags into auxint. +func arm64ConditionalParamsAuxInt(cond Op, nzcv uint8) arm64ConditionalParams { + if cond < OpARM64Equal || cond > OpARM64GreaterEqualU { + panic("Wrong conditional operation") + } + if nzcv&0x0f != nzcv { + panic("Wrong value of NZCV flag") + } + return arm64ConditionalParams{cond, nzcv, 0, false} +} + +// encodes condition code, NZCV flags and constant value into auxint. +func arm64ConditionalParamsAuxIntWithValue(cond Op, nzcv uint8, value uint8) arm64ConditionalParams { + if value&0x1f != value { + panic("Wrong value of constant") + } + params := arm64ConditionalParamsAuxInt(cond, nzcv) + params.constValue = value + params.ind = true + return params +} + +// extracts condition code from auxint. +func (condParams arm64ConditionalParams) Cond() Op { + return condParams.cond +} + +// extracts NZCV flags from auxint. +func (condParams arm64ConditionalParams) Nzcv() int64 { + return int64(condParams.nzcv) +} + +// extracts constant value from auxint if present. +func (condParams arm64ConditionalParams) ConstValue() (int64, bool) { + return int64(condParams.constValue), condParams.ind +} + +// registerizable reports whether t is a primitive type that fits in +// a register. It assumes float64 values will always fit into registers +// even if that isn't strictly true. +func registerizable(b *Block, typ *types.Type) bool { + if typ.IsPtrShaped() || typ.IsFloat() || typ.IsBoolean() { + return true + } + if typ.IsInteger() { + return typ.Size() <= b.Func.Config.RegSize + } + return false +} + +// needRaceCleanup reports whether this call to racefuncenter/exit isn't needed. +func needRaceCleanup(sym *AuxCall, v *Value) bool { + f := v.Block.Func + if !f.Config.Race { + return false + } + if !isSameCall(sym, "runtime.racefuncenter") && !isSameCall(sym, "runtime.racefuncexit") { + return false + } + for _, b := range f.Blocks { + for _, v := range b.Values { + switch v.Op { + case OpStaticCall, OpStaticLECall: + // Check for racefuncenter will encounter racefuncexit and vice versa. + // Allow calls to panic* + s := v.Aux.(*AuxCall).Fn.String() + switch s { + case "runtime.racefuncenter", "runtime.racefuncexit", + "runtime.panicdivide", "runtime.panicwrap", + "runtime.panicshift": + continue + } + // If we encountered any call, we need to keep racefunc*, + // for accurate stacktraces. + return false + case OpPanicBounds, OpPanicExtend: + // Note: these are panic generators that are ok (like the static calls above). + case OpClosureCall, OpInterCall, OpClosureLECall, OpInterLECall: + // We must keep the race functions if there are any other call types. + return false + } + } + } + if isSameCall(sym, "runtime.racefuncenter") { + // TODO REGISTER ABI this needs to be cleaned up. + // If we're removing racefuncenter, remove its argument as well. + if v.Args[0].Op != OpStore { + if v.Op == OpStaticLECall { + // there is no store, yet. + return true + } + return false + } + mem := v.Args[0].Args[2] + v.Args[0].reset(OpCopy) + v.Args[0].AddArg(mem) + } + return true +} + +// symIsRO reports whether sym is a read-only global. +func symIsRO(sym Sym) bool { + lsym := sym.(*obj.LSym) + return lsym.Type == objabi.SRODATA && len(lsym.R) == 0 +} + +// symIsROZero reports whether sym is a read-only global whose data contains all zeros. +func symIsROZero(sym Sym) bool { + lsym := sym.(*obj.LSym) + if lsym.Type != objabi.SRODATA || len(lsym.R) != 0 { + return false + } + for _, b := range lsym.P { + if b != 0 { + return false + } + } + return true +} + +// isFixedLoad returns true if the load can be resolved to fixed address or constant, +// and can be rewritten by rewriteFixedLoad. +func isFixedLoad(v *Value, sym Sym, off int64) bool { + lsym := sym.(*obj.LSym) + if (v.Type.IsPtrShaped() || v.Type.IsUintptr()) && lsym.Type == objabi.SRODATA { + for _, r := range lsym.R { + if (r.Type == objabi.R_ADDR || r.Type == objabi.R_WEAKADDR) && int64(r.Off) == off && r.Add == 0 { + return true + } + } + return false + } + + if ti := lsym.TypeInfo(); ti != nil { + // Type symbols do not contain information about their fields, unlike the cases above. + // Hand-implement field accesses. + // TODO: can this be replaced with reflectdata.writeType and just use the code above? + + t := ti.Type.(*types.Type) + + for _, f := range rttype.Type.Fields() { + if f.Offset == off && copyCompatibleType(v.Type, f.Type) { + switch f.Sym.Name { + case "Size_", "PtrBytes", "Hash", "Kind_", "GCData": + return true + default: + // fmt.Println("unknown field", f.Sym.Name) + return false + } + } + } + + if t.IsPtr() && off == rttype.PtrType.OffsetOf("Elem") { + return true + } + + return false + } + + return false +} + +// rewriteFixedLoad rewrites a load to a fixed address or constant, if isFixedLoad returns true. +func rewriteFixedLoad(v *Value, sym Sym, sb *Value, off int64) *Value { + b := v.Block + f := b.Func + + lsym := sym.(*obj.LSym) + if (v.Type.IsPtrShaped() || v.Type.IsUintptr()) && lsym.Type == objabi.SRODATA { + for _, r := range lsym.R { + if (r.Type == objabi.R_ADDR || r.Type == objabi.R_WEAKADDR) && int64(r.Off) == off && r.Add == 0 { + if strings.HasPrefix(r.Sym.Name, "type:") { + // In case we're loading a type out of a dictionary, we need to record + // that the containing function might put that type in an interface. + // That information is currently recorded in relocations in the dictionary, + // but if we perform this load at compile time then the dictionary + // might be dead. + reflectdata.MarkTypeSymUsedInInterface(r.Sym, f.fe.Func().Linksym()) + } else if strings.HasPrefix(r.Sym.Name, "go:itab") { + // Same, but if we're using an itab we need to record that the + // itab._type might be put in an interface. + reflectdata.MarkTypeSymUsedInInterface(r.Sym, f.fe.Func().Linksym()) + } + v.reset(OpAddr) + v.Aux = symToAux(r.Sym) + v.AddArg(sb) + return v + } + } + base.Fatalf("fixedLoad data not known for %s:%d", sym, off) + } + + if ti := lsym.TypeInfo(); ti != nil { + // Type symbols do not contain information about their fields, unlike the cases above. + // Hand-implement field accesses. + // TODO: can this be replaced with reflectdata.writeType and just use the code above? + + t := ti.Type.(*types.Type) + + ptrSizedOpConst := OpConst64 + if f.Config.PtrSize == 4 { + ptrSizedOpConst = OpConst32 + } + + for _, f := range rttype.Type.Fields() { + if f.Offset == off && copyCompatibleType(v.Type, f.Type) { + switch f.Sym.Name { + case "Size_": + v.reset(ptrSizedOpConst) + v.AuxInt = t.Size() + return v + case "PtrBytes": + v.reset(ptrSizedOpConst) + v.AuxInt = types.PtrDataSize(t) + return v + case "Hash": + v.reset(OpConst32) + v.AuxInt = int64(int32(types.TypeHash(t))) + return v + case "Kind_": + v.reset(OpConst8) + v.AuxInt = int64(int8(reflectdata.ABIKindOfType(t))) + return v + case "GCData": + gcdata, _ := reflectdata.GCSym(t, true) + v.reset(OpAddr) + v.Aux = symToAux(gcdata) + v.AddArg(sb) + return v + default: + base.Fatalf("unknown field %s for fixedLoad of %s at offset %d", f.Sym.Name, lsym.Name, off) + } + } + } + + if t.IsPtr() && off == rttype.PtrType.OffsetOf("Elem") { + elemSym := reflectdata.TypeLinksym(t.Elem()) + reflectdata.MarkTypeSymUsedInInterface(elemSym, f.fe.Func().Linksym()) + v.reset(OpAddr) + v.Aux = symToAux(elemSym) + v.AddArg(sb) + return v + } + + base.Fatalf("fixedLoad data not known for %s:%d", sym, off) + } + + base.Fatalf("fixedLoad data not known for %s:%d", sym, off) + return nil +} + +// read8 reads one byte from the read-only global sym at offset off. +func read8(sym Sym, off int64) uint8 { + lsym := sym.(*obj.LSym) + if off >= int64(len(lsym.P)) || off < 0 { + // Invalid index into the global sym. + // This can happen in dead code, so we don't want to panic. + // Just return any value, it will eventually get ignored. + // See issue 29215. + return 0 + } + return lsym.P[off] +} + +// read16 reads two bytes from the read-only global sym at offset off. +func read16(sym Sym, off int64, byteorder binary.ByteOrder) uint16 { + lsym := sym.(*obj.LSym) + // lsym.P is written lazily. + // Bytes requested after the end of lsym.P are 0. + var src []byte + if 0 <= off && off < int64(len(lsym.P)) { + src = lsym.P[off:] + } + buf := make([]byte, 2) + copy(buf, src) + return byteorder.Uint16(buf) +} + +// read32 reads four bytes from the read-only global sym at offset off. +func read32(sym Sym, off int64, byteorder binary.ByteOrder) uint32 { + lsym := sym.(*obj.LSym) + var src []byte + if 0 <= off && off < int64(len(lsym.P)) { + src = lsym.P[off:] + } + buf := make([]byte, 4) + copy(buf, src) + return byteorder.Uint32(buf) +} + +// read64 reads eight bytes from the read-only global sym at offset off. +func read64(sym Sym, off int64, byteorder binary.ByteOrder) uint64 { + lsym := sym.(*obj.LSym) + var src []byte + if 0 <= off && off < int64(len(lsym.P)) { + src = lsym.P[off:] + } + buf := make([]byte, 8) + copy(buf, src) + return byteorder.Uint64(buf) +} + +// sequentialAddresses reports true if it can prove that x + n == y +func sequentialAddresses(x, y *Value, n int64) bool { + if x == y && n == 0 { + return true + } + if x.Op == Op386ADDL && y.Op == Op386LEAL1 && y.AuxInt == n && y.Aux == nil && + (x.Args[0] == y.Args[0] && x.Args[1] == y.Args[1] || + x.Args[0] == y.Args[1] && x.Args[1] == y.Args[0]) { + return true + } + if x.Op == Op386LEAL1 && y.Op == Op386LEAL1 && y.AuxInt == x.AuxInt+n && x.Aux == y.Aux && + (x.Args[0] == y.Args[0] && x.Args[1] == y.Args[1] || + x.Args[0] == y.Args[1] && x.Args[1] == y.Args[0]) { + return true + } + if x.Op == OpAMD64ADDQ && y.Op == OpAMD64LEAQ1 && y.AuxInt == n && y.Aux == nil && + (x.Args[0] == y.Args[0] && x.Args[1] == y.Args[1] || + x.Args[0] == y.Args[1] && x.Args[1] == y.Args[0]) { + return true + } + if x.Op == OpAMD64LEAQ1 && y.Op == OpAMD64LEAQ1 && y.AuxInt == x.AuxInt+n && x.Aux == y.Aux && + (x.Args[0] == y.Args[0] && x.Args[1] == y.Args[1] || + x.Args[0] == y.Args[1] && x.Args[1] == y.Args[0]) { + return true + } + return false +} + +// flagConstant represents the result of a compile-time comparison. +// The sense of these flags does not necessarily represent the hardware's notion +// of a flags register - these are just a compile-time construct. +// We happen to match the semantics to those of arm/arm64. +// Note that these semantics differ from x86: the carry flag has the opposite +// sense on a subtraction! +// +// On amd64, C=1 represents a borrow, e.g. SBB on amd64 does x - y - C. +// On arm64, C=0 represents a borrow, e.g. SBC on arm64 does x - y - ^C. +// (because it does x + ^y + C). +// +// See https://en.wikipedia.org/wiki/Carry_flag#Vs._borrow_flag +type flagConstant uint8 + +// N reports whether the result of an operation is negative (high bit set). +func (fc flagConstant) N() bool { + return fc&1 != 0 +} + +// Z reports whether the result of an operation is 0. +func (fc flagConstant) Z() bool { + return fc&2 != 0 +} + +// C reports whether an unsigned add overflowed (carry), or an +// unsigned subtract did not underflow (borrow). +func (fc flagConstant) C() bool { + return fc&4 != 0 +} + +// V reports whether a signed operation overflowed or underflowed. +func (fc flagConstant) V() bool { + return fc&8 != 0 +} + +func (fc flagConstant) eq() bool { + return fc.Z() +} +func (fc flagConstant) ne() bool { + return !fc.Z() +} +func (fc flagConstant) lt() bool { + return fc.N() != fc.V() +} +func (fc flagConstant) le() bool { + return fc.Z() || fc.lt() +} +func (fc flagConstant) gt() bool { + return !fc.Z() && fc.ge() +} +func (fc flagConstant) ge() bool { + return fc.N() == fc.V() +} +func (fc flagConstant) ult() bool { + return !fc.C() +} +func (fc flagConstant) ule() bool { + return fc.Z() || fc.ult() +} +func (fc flagConstant) ugt() bool { + return !fc.Z() && fc.uge() +} +func (fc flagConstant) uge() bool { + return fc.C() +} + +func (fc flagConstant) ltNoov() bool { + return fc.lt() && !fc.V() +} +func (fc flagConstant) leNoov() bool { + return fc.le() && !fc.V() +} +func (fc flagConstant) gtNoov() bool { + return fc.gt() && !fc.V() +} +func (fc flagConstant) geNoov() bool { + return fc.ge() && !fc.V() +} + +func (fc flagConstant) String() string { + return fmt.Sprintf("N=%v,Z=%v,C=%v,V=%v", fc.N(), fc.Z(), fc.C(), fc.V()) +} + +type flagConstantBuilder struct { + N bool + Z bool + C bool + V bool +} + +func (fcs flagConstantBuilder) encode() flagConstant { + var fc flagConstant + if fcs.N { + fc |= 1 + } + if fcs.Z { + fc |= 2 + } + if fcs.C { + fc |= 4 + } + if fcs.V { + fc |= 8 + } + return fc +} + +// Note: addFlags(x,y) != subFlags(x,-y) in some situations: +// - the results of the C flag are different +// - the results of the V flag when y==minint are different + +// addFlags64 returns the flags that would be set from computing x+y. +func addFlags64(x, y int64) flagConstant { + var fcb flagConstantBuilder + fcb.Z = x+y == 0 + fcb.N = x+y < 0 + fcb.C = uint64(x+y) < uint64(x) + fcb.V = x >= 0 && y >= 0 && x+y < 0 || x < 0 && y < 0 && x+y >= 0 + return fcb.encode() +} + +// subFlags64 returns the flags that would be set from computing x-y. +func subFlags64(x, y int64) flagConstant { + var fcb flagConstantBuilder + fcb.Z = x-y == 0 + fcb.N = x-y < 0 + fcb.C = uint64(y) <= uint64(x) // This code follows the arm carry flag model. + fcb.V = x >= 0 && y < 0 && x-y < 0 || x < 0 && y >= 0 && x-y >= 0 + return fcb.encode() +} + +// addFlags32 returns the flags that would be set from computing x+y. +func addFlags32(x, y int32) flagConstant { + var fcb flagConstantBuilder + fcb.Z = x+y == 0 + fcb.N = x+y < 0 + fcb.C = uint32(x+y) < uint32(x) + fcb.V = x >= 0 && y >= 0 && x+y < 0 || x < 0 && y < 0 && x+y >= 0 + return fcb.encode() +} + +// subFlags32 returns the flags that would be set from computing x-y. +func subFlags32(x, y int32) flagConstant { + var fcb flagConstantBuilder + fcb.Z = x-y == 0 + fcb.N = x-y < 0 + fcb.C = uint32(y) <= uint32(x) // This code follows the arm carry flag model. + fcb.V = x >= 0 && y < 0 && x-y < 0 || x < 0 && y >= 0 && x-y >= 0 + return fcb.encode() +} + +// logicFlags64 returns flags set to the sign/zeroness of x. +// C and V are set to false. +func logicFlags64(x int64) flagConstant { + var fcb flagConstantBuilder + fcb.Z = x == 0 + fcb.N = x < 0 + return fcb.encode() +} + +// logicFlags32 returns flags set to the sign/zeroness of x. +// C and V are set to false. +func logicFlags32(x int32) flagConstant { + var fcb flagConstantBuilder + fcb.Z = x == 0 + fcb.N = x < 0 + return fcb.encode() +} + +func makeJumpTableSym(b *Block) *obj.LSym { + s := base.Ctxt.Lookup(fmt.Sprintf("%s.jump%d", b.Func.fe.Func().LSym.Name, b.ID)) + // The jump table symbol is accessed only from the function symbol. + s.Set(obj.AttrStatic, true) + return s +} + +// canRotate reports whether the architecture supports +// rotates of integer registers with the given number of bits. +func canRotate(c *Config, bits int64) bool { + if bits > c.PtrSize*8 { + // Don't rewrite to rotates bigger than the machine word. + return false + } + switch c.arch { + case "386", "amd64", "arm64", "loong64", "riscv64": + return true + case "arm", "s390x", "ppc64", "ppc64le", "wasm": + return bits >= 32 + default: + return false + } +} + +// isARM64bitcon reports whether a constant can be encoded into a logical instruction. +func isARM64bitcon(x uint64) bool { + if x == 1<<64-1 || x == 0 { + return false + } + // determine the period and sign-extend a unit to 64 bits + switch { + case x != x>>32|x<<32: + // period is 64 + // nothing to do + case x != x>>16|x<<48: + // period is 32 + x = uint64(int64(int32(x))) + case x != x>>8|x<<56: + // period is 16 + x = uint64(int64(int16(x))) + case x != x>>4|x<<60: + // period is 8 + x = uint64(int64(int8(x))) + default: + // period is 4 or 2, always true + // 0001, 0010, 0100, 1000 -- 0001 rotate + // 0011, 0110, 1100, 1001 -- 0011 rotate + // 0111, 1011, 1101, 1110 -- 0111 rotate + // 0101, 1010 -- 01 rotate, repeat + return true + } + return sequenceOfOnes(x) || sequenceOfOnes(^x) +} + +// sequenceOfOnes tests whether a constant is a sequence of ones in binary, with leading and trailing zeros. +func sequenceOfOnes(x uint64) bool { + y := x & -x // lowest set bit of x. x is good iff x+y is a power of 2 + y += x + return (y-1)&y == 0 +} + +// isARM64addcon reports whether x can be encoded as the immediate value in an ADD or SUB instruction. +func isARM64addcon(v int64) bool { + /* uimm12 or uimm24? */ + if v < 0 { + return false + } + if (v & 0xFFF) == 0 { + v >>= 12 + } + return v <= 0xFFF +} + +// setPos sets the position of v to pos, then returns true. +// Useful for setting the result of a rewrite's position to +// something other than the default. +func setPos(v *Value, pos src.XPos) bool { + v.Pos = pos + return true +} + +// isNonNegative reports whether v is known to be greater or equal to zero. +// Note that this is pretty simplistic. The prove pass generates more detailed +// nonnegative information about values. +func isNonNegative(v *Value) bool { + if !v.Type.IsInteger() { + v.Fatalf("isNonNegative bad type: %v", v.Type) + } + // TODO: return true if !v.Type.IsSigned() + // SSA isn't type-safe enough to do that now (issue 37753). + // The checks below depend only on the pattern of bits. + + switch v.Op { + case OpConst64: + return v.AuxInt >= 0 + + case OpConst32: + return int32(v.AuxInt) >= 0 + + case OpConst16: + return int16(v.AuxInt) >= 0 + + case OpConst8: + return int8(v.AuxInt) >= 0 + + case OpStringLen, OpSliceLen, OpSliceCap, + OpZeroExt8to64, OpZeroExt16to64, OpZeroExt32to64, + OpZeroExt8to32, OpZeroExt16to32, OpZeroExt8to16, + OpCtz64, OpCtz32, OpCtz16, OpCtz8, + OpCtz64NonZero, OpCtz32NonZero, OpCtz16NonZero, OpCtz8NonZero, + OpBitLen64, OpBitLen32, OpBitLen16, OpBitLen8: + return true + + case OpRsh64Ux64, OpRsh32Ux64: + by := v.Args[1] + return by.Op == OpConst64 && by.AuxInt > 0 + + case OpRsh64x64, OpRsh32x64, OpRsh8x64, OpRsh16x64, OpRsh32x32, OpRsh64x32, + OpSignExt32to64, OpSignExt16to64, OpSignExt8to64, OpSignExt16to32, OpSignExt8to32: + return isNonNegative(v.Args[0]) + + case OpAnd64, OpAnd32, OpAnd16, OpAnd8: + return isNonNegative(v.Args[0]) || isNonNegative(v.Args[1]) + + case OpMod64, OpMod32, OpMod16, OpMod8, + OpDiv64, OpDiv32, OpDiv16, OpDiv8, + OpOr64, OpOr32, OpOr16, OpOr8, + OpXor64, OpXor32, OpXor16, OpXor8: + return isNonNegative(v.Args[0]) && isNonNegative(v.Args[1]) + + // We could handle OpPhi here, but the improvements from doing + // so are very minor, and it is neither simple nor cheap. + } + return false +} + +func rewriteStructLoad(v *Value) *Value { + b := v.Block + ptr := v.Args[0] + mem := v.Args[1] + + t := v.Type + args := make([]*Value, t.NumFields()) + for i := range args { + ft := t.FieldType(i) + addr := b.NewValue1I(v.Pos, OpOffPtr, ft.PtrTo(), t.FieldOff(i), ptr) + args[i] = b.NewValue2(v.Pos, OpLoad, ft, addr, mem) + } + + v.reset(OpStructMake) + v.AddArgs(args...) + return v +} + +func rewriteStructStore(v *Value) *Value { + b := v.Block + dst := v.Args[0] + x := v.Args[1] + if x.Op != OpStructMake { + base.Fatalf("invalid struct store: %v", x) + } + mem := v.Args[2] + + t := x.Type + for i, arg := range x.Args { + ft := t.FieldType(i) + + addr := b.NewValue1I(v.Pos, OpOffPtr, ft.PtrTo(), t.FieldOff(i), dst) + mem = b.NewValue3A(v.Pos, OpStore, types.TypeMem, typeToAux(ft), addr, arg, mem) + } + + return mem +} + +// isDirectAndComparableType reports whether v represents a type +// (a *runtime._type) whose value is stored directly in an +// interface (i.e., is pointer or pointer-like) and is comparable. +func isDirectAndComparableType(v *Value) bool { + return isDirectAndComparableType1(v) +} + +// v is a type +func isDirectAndComparableType1(v *Value) bool { + switch v.Op { + case OpITab: + return isDirectAndComparableType2(v.Args[0]) + case OpAddr: + lsym := v.Aux.(*obj.LSym) + if ti := lsym.TypeInfo(); ti != nil { + t := ti.Type.(*types.Type) + return types.IsDirectIface(t) && types.IsComparable(t) + } + } + return false +} + +// v is an empty interface +func isDirectAndComparableType2(v *Value) bool { + switch v.Op { + case OpIMake: + return isDirectAndComparableType1(v.Args[0]) + } + return false +} + +// isDirectAndComparableIface reports whether v represents an itab +// (a *runtime._itab) for a type whose value is stored directly +// in an interface (i.e., is pointer or pointer-like) and is comparable. +func isDirectAndComparableIface(v *Value) bool { + return isDirectAndComparableIface1(v, 9) +} + +// v is an itab +func isDirectAndComparableIface1(v *Value, depth int) bool { + if depth == 0 { + return false + } + switch v.Op { + case OpITab: + return isDirectAndComparableIface2(v.Args[0], depth-1) + case OpAddr: + lsym := v.Aux.(*obj.LSym) + if ii := lsym.ItabInfo(); ii != nil { + t := ii.Type.(*types.Type) + return types.IsDirectIface(t) && types.IsComparable(t) + } + case OpConstNil: + // We can treat this as direct, because if the itab is + // nil, the data field must be nil also. + return true + } + return false +} + +// v is an interface +func isDirectAndComparableIface2(v *Value, depth int) bool { + if depth == 0 { + return false + } + switch v.Op { + case OpIMake: + return isDirectAndComparableIface1(v.Args[0], depth-1) + case OpPhi: + for _, a := range v.Args { + if !isDirectAndComparableIface2(a, depth-1) { + return false + } + } + return true + } + return false +} + +func bitsAdd64(x, y, carry int64) (r struct{ sum, carry int64 }) { + s, c := bits.Add64(uint64(x), uint64(y), uint64(carry)) + r.sum, r.carry = int64(s), int64(c) + return +} + +func bitsMulU64(x, y int64) (r struct{ hi, lo int64 }) { + hi, lo := bits.Mul64(uint64(x), uint64(y)) + r.hi, r.lo = int64(hi), int64(lo) + return +} +func bitsMulU32(x, y int32) (r struct{ hi, lo int32 }) { + hi, lo := bits.Mul32(uint32(x), uint32(y)) + r.hi, r.lo = int32(hi), int32(lo) + return +} + +// flagify rewrites v which is (X ...) to (Select0 (Xflags ...)). +func flagify(v *Value) bool { + var flagVersion Op + switch v.Op { + case OpAMD64ADDQconst: + flagVersion = OpAMD64ADDQconstflags + case OpAMD64ADDLconst: + flagVersion = OpAMD64ADDLconstflags + default: + base.Fatalf("can't flagify op %s", v.Op) + } + inner := v.copyInto(v.Block) + inner.Op = flagVersion + inner.Type = types.NewTuple(v.Type, types.TypeFlags) + v.reset(OpSelect0) + v.AddArg(inner) + return true +} + +// PanicBoundsC contains a constant for a bounds failure. +type PanicBoundsC struct { + C int64 +} + +// PanicBoundsCC contains 2 constants for a bounds failure. +type PanicBoundsCC struct { + Cx int64 + Cy int64 +} + +func (p PanicBoundsC) CanBeAnSSAAux() { +} +func (p PanicBoundsCC) CanBeAnSSAAux() { +} + +func auxToPanicBoundsC(i Aux) PanicBoundsC { + return i.(PanicBoundsC) +} +func auxToPanicBoundsCC(i Aux) PanicBoundsCC { + return i.(PanicBoundsCC) +} +func panicBoundsCToAux(p PanicBoundsC) Aux { + return p +} +func panicBoundsCCToAux(p PanicBoundsCC) Aux { + return p +} + +func isDictArgSym(sym Sym) bool { + return sym.(*ir.Name).Sym().Name == typecheck.LocalDictName +} + +// When v is (IMake typ (StructMake ...)), convert to +// (IMake typ arg) where arg is the pointer-y argument to +// the StructMake (there must be exactly one). +func imakeOfStructMake(v *Value) *Value { + var arg *Value + for _, a := range v.Args[1].Args { + if a.Type.Size() > 0 { + arg = a + break + } + } + return v.Block.NewValue2(v.Pos, OpIMake, v.Type, v.Args[0], arg) +} diff --git a/go/src/cmd/compile/internal/ssa/rewrite386.go b/go/src/cmd/compile/internal/ssa/rewrite386.go new file mode 100644 index 0000000000000000000000000000000000000000..be88dd3cddadf721e9ce8e69239ef1a248adca5d --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewrite386.go @@ -0,0 +1,11659 @@ +// Code generated from _gen/386.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "math" +import "cmd/compile/internal/types" + +func rewriteValue386(v *Value) bool { + switch v.Op { + case Op386ADCL: + return rewriteValue386_Op386ADCL(v) + case Op386ADDL: + return rewriteValue386_Op386ADDL(v) + case Op386ADDLcarry: + return rewriteValue386_Op386ADDLcarry(v) + case Op386ADDLconst: + return rewriteValue386_Op386ADDLconst(v) + case Op386ADDLconstmodify: + return rewriteValue386_Op386ADDLconstmodify(v) + case Op386ADDLload: + return rewriteValue386_Op386ADDLload(v) + case Op386ADDLmodify: + return rewriteValue386_Op386ADDLmodify(v) + case Op386ADDSD: + return rewriteValue386_Op386ADDSD(v) + case Op386ADDSDload: + return rewriteValue386_Op386ADDSDload(v) + case Op386ADDSS: + return rewriteValue386_Op386ADDSS(v) + case Op386ADDSSload: + return rewriteValue386_Op386ADDSSload(v) + case Op386ANDL: + return rewriteValue386_Op386ANDL(v) + case Op386ANDLconst: + return rewriteValue386_Op386ANDLconst(v) + case Op386ANDLconstmodify: + return rewriteValue386_Op386ANDLconstmodify(v) + case Op386ANDLload: + return rewriteValue386_Op386ANDLload(v) + case Op386ANDLmodify: + return rewriteValue386_Op386ANDLmodify(v) + case Op386CMPB: + return rewriteValue386_Op386CMPB(v) + case Op386CMPBconst: + return rewriteValue386_Op386CMPBconst(v) + case Op386CMPBload: + return rewriteValue386_Op386CMPBload(v) + case Op386CMPL: + return rewriteValue386_Op386CMPL(v) + case Op386CMPLconst: + return rewriteValue386_Op386CMPLconst(v) + case Op386CMPLload: + return rewriteValue386_Op386CMPLload(v) + case Op386CMPW: + return rewriteValue386_Op386CMPW(v) + case Op386CMPWconst: + return rewriteValue386_Op386CMPWconst(v) + case Op386CMPWload: + return rewriteValue386_Op386CMPWload(v) + case Op386DIVSD: + return rewriteValue386_Op386DIVSD(v) + case Op386DIVSDload: + return rewriteValue386_Op386DIVSDload(v) + case Op386DIVSS: + return rewriteValue386_Op386DIVSS(v) + case Op386DIVSSload: + return rewriteValue386_Op386DIVSSload(v) + case Op386LEAL: + return rewriteValue386_Op386LEAL(v) + case Op386LEAL1: + return rewriteValue386_Op386LEAL1(v) + case Op386LEAL2: + return rewriteValue386_Op386LEAL2(v) + case Op386LEAL4: + return rewriteValue386_Op386LEAL4(v) + case Op386LEAL8: + return rewriteValue386_Op386LEAL8(v) + case Op386LoweredPanicBoundsRC: + return rewriteValue386_Op386LoweredPanicBoundsRC(v) + case Op386LoweredPanicBoundsRR: + return rewriteValue386_Op386LoweredPanicBoundsRR(v) + case Op386LoweredPanicExtendRC: + return rewriteValue386_Op386LoweredPanicExtendRC(v) + case Op386LoweredPanicExtendRR: + return rewriteValue386_Op386LoweredPanicExtendRR(v) + case Op386MOVBLSX: + return rewriteValue386_Op386MOVBLSX(v) + case Op386MOVBLSXload: + return rewriteValue386_Op386MOVBLSXload(v) + case Op386MOVBLZX: + return rewriteValue386_Op386MOVBLZX(v) + case Op386MOVBload: + return rewriteValue386_Op386MOVBload(v) + case Op386MOVBstore: + return rewriteValue386_Op386MOVBstore(v) + case Op386MOVBstoreconst: + return rewriteValue386_Op386MOVBstoreconst(v) + case Op386MOVLload: + return rewriteValue386_Op386MOVLload(v) + case Op386MOVLstore: + return rewriteValue386_Op386MOVLstore(v) + case Op386MOVLstoreconst: + return rewriteValue386_Op386MOVLstoreconst(v) + case Op386MOVSDconst: + return rewriteValue386_Op386MOVSDconst(v) + case Op386MOVSDload: + return rewriteValue386_Op386MOVSDload(v) + case Op386MOVSDstore: + return rewriteValue386_Op386MOVSDstore(v) + case Op386MOVSSconst: + return rewriteValue386_Op386MOVSSconst(v) + case Op386MOVSSload: + return rewriteValue386_Op386MOVSSload(v) + case Op386MOVSSstore: + return rewriteValue386_Op386MOVSSstore(v) + case Op386MOVWLSX: + return rewriteValue386_Op386MOVWLSX(v) + case Op386MOVWLSXload: + return rewriteValue386_Op386MOVWLSXload(v) + case Op386MOVWLZX: + return rewriteValue386_Op386MOVWLZX(v) + case Op386MOVWload: + return rewriteValue386_Op386MOVWload(v) + case Op386MOVWstore: + return rewriteValue386_Op386MOVWstore(v) + case Op386MOVWstoreconst: + return rewriteValue386_Op386MOVWstoreconst(v) + case Op386MULL: + return rewriteValue386_Op386MULL(v) + case Op386MULLconst: + return rewriteValue386_Op386MULLconst(v) + case Op386MULLload: + return rewriteValue386_Op386MULLload(v) + case Op386MULSD: + return rewriteValue386_Op386MULSD(v) + case Op386MULSDload: + return rewriteValue386_Op386MULSDload(v) + case Op386MULSS: + return rewriteValue386_Op386MULSS(v) + case Op386MULSSload: + return rewriteValue386_Op386MULSSload(v) + case Op386NEGL: + return rewriteValue386_Op386NEGL(v) + case Op386NOTL: + return rewriteValue386_Op386NOTL(v) + case Op386ORL: + return rewriteValue386_Op386ORL(v) + case Op386ORLconst: + return rewriteValue386_Op386ORLconst(v) + case Op386ORLconstmodify: + return rewriteValue386_Op386ORLconstmodify(v) + case Op386ORLload: + return rewriteValue386_Op386ORLload(v) + case Op386ORLmodify: + return rewriteValue386_Op386ORLmodify(v) + case Op386ROLB: + return rewriteValue386_Op386ROLB(v) + case Op386ROLBconst: + return rewriteValue386_Op386ROLBconst(v) + case Op386ROLL: + return rewriteValue386_Op386ROLL(v) + case Op386ROLLconst: + return rewriteValue386_Op386ROLLconst(v) + case Op386ROLW: + return rewriteValue386_Op386ROLW(v) + case Op386ROLWconst: + return rewriteValue386_Op386ROLWconst(v) + case Op386SARB: + return rewriteValue386_Op386SARB(v) + case Op386SARBconst: + return rewriteValue386_Op386SARBconst(v) + case Op386SARL: + return rewriteValue386_Op386SARL(v) + case Op386SARLconst: + return rewriteValue386_Op386SARLconst(v) + case Op386SARW: + return rewriteValue386_Op386SARW(v) + case Op386SARWconst: + return rewriteValue386_Op386SARWconst(v) + case Op386SBBL: + return rewriteValue386_Op386SBBL(v) + case Op386SBBLcarrymask: + return rewriteValue386_Op386SBBLcarrymask(v) + case Op386SETA: + return rewriteValue386_Op386SETA(v) + case Op386SETAE: + return rewriteValue386_Op386SETAE(v) + case Op386SETB: + return rewriteValue386_Op386SETB(v) + case Op386SETBE: + return rewriteValue386_Op386SETBE(v) + case Op386SETEQ: + return rewriteValue386_Op386SETEQ(v) + case Op386SETG: + return rewriteValue386_Op386SETG(v) + case Op386SETGE: + return rewriteValue386_Op386SETGE(v) + case Op386SETL: + return rewriteValue386_Op386SETL(v) + case Op386SETLE: + return rewriteValue386_Op386SETLE(v) + case Op386SETNE: + return rewriteValue386_Op386SETNE(v) + case Op386SHLL: + return rewriteValue386_Op386SHLL(v) + case Op386SHLLconst: + return rewriteValue386_Op386SHLLconst(v) + case Op386SHRB: + return rewriteValue386_Op386SHRB(v) + case Op386SHRBconst: + return rewriteValue386_Op386SHRBconst(v) + case Op386SHRL: + return rewriteValue386_Op386SHRL(v) + case Op386SHRLconst: + return rewriteValue386_Op386SHRLconst(v) + case Op386SHRW: + return rewriteValue386_Op386SHRW(v) + case Op386SHRWconst: + return rewriteValue386_Op386SHRWconst(v) + case Op386SUBL: + return rewriteValue386_Op386SUBL(v) + case Op386SUBLcarry: + return rewriteValue386_Op386SUBLcarry(v) + case Op386SUBLconst: + return rewriteValue386_Op386SUBLconst(v) + case Op386SUBLload: + return rewriteValue386_Op386SUBLload(v) + case Op386SUBLmodify: + return rewriteValue386_Op386SUBLmodify(v) + case Op386SUBSD: + return rewriteValue386_Op386SUBSD(v) + case Op386SUBSDload: + return rewriteValue386_Op386SUBSDload(v) + case Op386SUBSS: + return rewriteValue386_Op386SUBSS(v) + case Op386SUBSSload: + return rewriteValue386_Op386SUBSSload(v) + case Op386XORL: + return rewriteValue386_Op386XORL(v) + case Op386XORLconst: + return rewriteValue386_Op386XORLconst(v) + case Op386XORLconstmodify: + return rewriteValue386_Op386XORLconstmodify(v) + case Op386XORLload: + return rewriteValue386_Op386XORLload(v) + case Op386XORLmodify: + return rewriteValue386_Op386XORLmodify(v) + case OpAdd16: + v.Op = Op386ADDL + return true + case OpAdd32: + v.Op = Op386ADDL + return true + case OpAdd32F: + v.Op = Op386ADDSS + return true + case OpAdd32carry: + v.Op = Op386ADDLcarry + return true + case OpAdd32carrywithcarry: + v.Op = Op386ADCLcarry + return true + case OpAdd32withcarry: + v.Op = Op386ADCL + return true + case OpAdd64F: + v.Op = Op386ADDSD + return true + case OpAdd8: + v.Op = Op386ADDL + return true + case OpAddPtr: + v.Op = Op386ADDL + return true + case OpAddr: + return rewriteValue386_OpAddr(v) + case OpAnd16: + v.Op = Op386ANDL + return true + case OpAnd32: + v.Op = Op386ANDL + return true + case OpAnd8: + v.Op = Op386ANDL + return true + case OpAndB: + v.Op = Op386ANDL + return true + case OpAvg32u: + v.Op = Op386AVGLU + return true + case OpBswap16: + return rewriteValue386_OpBswap16(v) + case OpBswap32: + v.Op = Op386BSWAPL + return true + case OpClosureCall: + v.Op = Op386CALLclosure + return true + case OpCom16: + v.Op = Op386NOTL + return true + case OpCom32: + v.Op = Op386NOTL + return true + case OpCom8: + v.Op = Op386NOTL + return true + case OpConst16: + return rewriteValue386_OpConst16(v) + case OpConst32: + v.Op = Op386MOVLconst + return true + case OpConst32F: + v.Op = Op386MOVSSconst + return true + case OpConst64F: + v.Op = Op386MOVSDconst + return true + case OpConst8: + return rewriteValue386_OpConst8(v) + case OpConstBool: + return rewriteValue386_OpConstBool(v) + case OpConstNil: + return rewriteValue386_OpConstNil(v) + case OpCtz16: + return rewriteValue386_OpCtz16(v) + case OpCtz16NonZero: + v.Op = Op386BSFL + return true + case OpCtz32: + v.Op = Op386LoweredCtz32 + return true + case OpCtz32NonZero: + v.Op = Op386BSFL + return true + case OpCtz64On32: + v.Op = Op386LoweredCtz64 + return true + case OpCtz8: + return rewriteValue386_OpCtz8(v) + case OpCtz8NonZero: + v.Op = Op386BSFL + return true + case OpCvt32Fto32: + v.Op = Op386CVTTSS2SL + return true + case OpCvt32Fto64F: + v.Op = Op386CVTSS2SD + return true + case OpCvt32to32F: + v.Op = Op386CVTSL2SS + return true + case OpCvt32to64F: + v.Op = Op386CVTSL2SD + return true + case OpCvt64Fto32: + v.Op = Op386CVTTSD2SL + return true + case OpCvt64Fto32F: + v.Op = Op386CVTSD2SS + return true + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpDiv16: + v.Op = Op386DIVW + return true + case OpDiv16u: + v.Op = Op386DIVWU + return true + case OpDiv32: + v.Op = Op386DIVL + return true + case OpDiv32F: + v.Op = Op386DIVSS + return true + case OpDiv32u: + v.Op = Op386DIVLU + return true + case OpDiv64F: + v.Op = Op386DIVSD + return true + case OpDiv8: + return rewriteValue386_OpDiv8(v) + case OpDiv8u: + return rewriteValue386_OpDiv8u(v) + case OpEq16: + return rewriteValue386_OpEq16(v) + case OpEq32: + return rewriteValue386_OpEq32(v) + case OpEq32F: + return rewriteValue386_OpEq32F(v) + case OpEq64F: + return rewriteValue386_OpEq64F(v) + case OpEq8: + return rewriteValue386_OpEq8(v) + case OpEqB: + return rewriteValue386_OpEqB(v) + case OpEqPtr: + return rewriteValue386_OpEqPtr(v) + case OpGetCallerPC: + v.Op = Op386LoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = Op386LoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = Op386LoweredGetClosurePtr + return true + case OpGetG: + v.Op = Op386LoweredGetG + return true + case OpHmul32: + v.Op = Op386HMULL + return true + case OpHmul32u: + v.Op = Op386HMULLU + return true + case OpInterCall: + v.Op = Op386CALLinter + return true + case OpIsInBounds: + return rewriteValue386_OpIsInBounds(v) + case OpIsNonNil: + return rewriteValue386_OpIsNonNil(v) + case OpIsSliceInBounds: + return rewriteValue386_OpIsSliceInBounds(v) + case OpLeq16: + return rewriteValue386_OpLeq16(v) + case OpLeq16U: + return rewriteValue386_OpLeq16U(v) + case OpLeq32: + return rewriteValue386_OpLeq32(v) + case OpLeq32F: + return rewriteValue386_OpLeq32F(v) + case OpLeq32U: + return rewriteValue386_OpLeq32U(v) + case OpLeq64F: + return rewriteValue386_OpLeq64F(v) + case OpLeq8: + return rewriteValue386_OpLeq8(v) + case OpLeq8U: + return rewriteValue386_OpLeq8U(v) + case OpLess16: + return rewriteValue386_OpLess16(v) + case OpLess16U: + return rewriteValue386_OpLess16U(v) + case OpLess32: + return rewriteValue386_OpLess32(v) + case OpLess32F: + return rewriteValue386_OpLess32F(v) + case OpLess32U: + return rewriteValue386_OpLess32U(v) + case OpLess64F: + return rewriteValue386_OpLess64F(v) + case OpLess8: + return rewriteValue386_OpLess8(v) + case OpLess8U: + return rewriteValue386_OpLess8U(v) + case OpLoad: + return rewriteValue386_OpLoad(v) + case OpLocalAddr: + return rewriteValue386_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValue386_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValue386_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValue386_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValue386_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValue386_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValue386_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValue386_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValue386_OpLsh32x8(v) + case OpLsh8x16: + return rewriteValue386_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValue386_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValue386_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValue386_OpLsh8x8(v) + case OpMod16: + v.Op = Op386MODW + return true + case OpMod16u: + v.Op = Op386MODWU + return true + case OpMod32: + v.Op = Op386MODL + return true + case OpMod32u: + v.Op = Op386MODLU + return true + case OpMod8: + return rewriteValue386_OpMod8(v) + case OpMod8u: + return rewriteValue386_OpMod8u(v) + case OpMove: + return rewriteValue386_OpMove(v) + case OpMul16: + v.Op = Op386MULL + return true + case OpMul32: + v.Op = Op386MULL + return true + case OpMul32F: + v.Op = Op386MULSS + return true + case OpMul32uhilo: + v.Op = Op386MULLQU + return true + case OpMul64F: + v.Op = Op386MULSD + return true + case OpMul8: + v.Op = Op386MULL + return true + case OpNeg16: + v.Op = Op386NEGL + return true + case OpNeg32: + v.Op = Op386NEGL + return true + case OpNeg32F: + return rewriteValue386_OpNeg32F(v) + case OpNeg64F: + return rewriteValue386_OpNeg64F(v) + case OpNeg8: + v.Op = Op386NEGL + return true + case OpNeq16: + return rewriteValue386_OpNeq16(v) + case OpNeq32: + return rewriteValue386_OpNeq32(v) + case OpNeq32F: + return rewriteValue386_OpNeq32F(v) + case OpNeq64F: + return rewriteValue386_OpNeq64F(v) + case OpNeq8: + return rewriteValue386_OpNeq8(v) + case OpNeqB: + return rewriteValue386_OpNeqB(v) + case OpNeqPtr: + return rewriteValue386_OpNeqPtr(v) + case OpNilCheck: + v.Op = Op386LoweredNilCheck + return true + case OpNot: + return rewriteValue386_OpNot(v) + case OpOffPtr: + return rewriteValue386_OpOffPtr(v) + case OpOr16: + v.Op = Op386ORL + return true + case OpOr32: + v.Op = Op386ORL + return true + case OpOr8: + v.Op = Op386ORL + return true + case OpOrB: + v.Op = Op386ORL + return true + case OpPanicBounds: + v.Op = Op386LoweredPanicBoundsRR + return true + case OpPanicExtend: + v.Op = Op386LoweredPanicExtendRR + return true + case OpRotateLeft16: + v.Op = Op386ROLW + return true + case OpRotateLeft32: + v.Op = Op386ROLL + return true + case OpRotateLeft8: + v.Op = Op386ROLB + return true + case OpRound32F: + v.Op = OpCopy + return true + case OpRound64F: + v.Op = OpCopy + return true + case OpRsh16Ux16: + return rewriteValue386_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValue386_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValue386_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValue386_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValue386_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValue386_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValue386_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValue386_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValue386_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValue386_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValue386_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValue386_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValue386_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValue386_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValue386_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValue386_OpRsh32x8(v) + case OpRsh8Ux16: + return rewriteValue386_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValue386_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValue386_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValue386_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValue386_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValue386_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValue386_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValue386_OpRsh8x8(v) + case OpSelect0: + return rewriteValue386_OpSelect0(v) + case OpSelect1: + return rewriteValue386_OpSelect1(v) + case OpSignExt16to32: + v.Op = Op386MOVWLSX + return true + case OpSignExt8to16: + v.Op = Op386MOVBLSX + return true + case OpSignExt8to32: + v.Op = Op386MOVBLSX + return true + case OpSignmask: + return rewriteValue386_OpSignmask(v) + case OpSlicemask: + return rewriteValue386_OpSlicemask(v) + case OpSqrt: + v.Op = Op386SQRTSD + return true + case OpSqrt32: + v.Op = Op386SQRTSS + return true + case OpStaticCall: + v.Op = Op386CALLstatic + return true + case OpStore: + return rewriteValue386_OpStore(v) + case OpSub16: + v.Op = Op386SUBL + return true + case OpSub32: + v.Op = Op386SUBL + return true + case OpSub32F: + v.Op = Op386SUBSS + return true + case OpSub32carry: + v.Op = Op386SUBLcarry + return true + case OpSub32withcarry: + v.Op = Op386SBBL + return true + case OpSub64F: + v.Op = Op386SUBSD + return true + case OpSub8: + v.Op = Op386SUBL + return true + case OpSubPtr: + v.Op = Op386SUBL + return true + case OpTailCall: + v.Op = Op386CALLtail + return true + case OpTrunc16to8: + v.Op = OpCopy + return true + case OpTrunc32to16: + v.Op = OpCopy + return true + case OpTrunc32to8: + v.Op = OpCopy + return true + case OpWB: + v.Op = Op386LoweredWB + return true + case OpXor16: + v.Op = Op386XORL + return true + case OpXor32: + v.Op = Op386XORL + return true + case OpXor8: + v.Op = Op386XORL + return true + case OpZero: + return rewriteValue386_OpZero(v) + case OpZeroExt16to32: + v.Op = Op386MOVWLZX + return true + case OpZeroExt8to16: + v.Op = Op386MOVBLZX + return true + case OpZeroExt8to32: + v.Op = Op386MOVBLZX + return true + case OpZeromask: + return rewriteValue386_OpZeromask(v) + } + return false +} +func rewriteValue386_Op386ADCL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADCL x (MOVLconst [c]) f) + // result: (ADCLconst [c] x f) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + f := v_2 + v.reset(Op386ADCLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, f) + return true + } + break + } + return false +} +func rewriteValue386_Op386ADDL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDL x (MOVLconst [c])) + // cond: !t.IsPtr() + // result: (ADDLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386MOVLconst { + continue + } + t := v_1.Type + c := auxIntToInt32(v_1.AuxInt) + if !(!t.IsPtr()) { + continue + } + v.reset(Op386ADDLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ADDL x (SHLLconst [3] y)) + // result: (LEAL8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386SHLLconst || auxIntToInt32(v_1.AuxInt) != 3 { + continue + } + y := v_1.Args[0] + v.reset(Op386LEAL8) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x (SHLLconst [2] y)) + // result: (LEAL4 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386SHLLconst || auxIntToInt32(v_1.AuxInt) != 2 { + continue + } + y := v_1.Args[0] + v.reset(Op386LEAL4) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x (SHLLconst [1] y)) + // result: (LEAL2 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386SHLLconst || auxIntToInt32(v_1.AuxInt) != 1 { + continue + } + y := v_1.Args[0] + v.reset(Op386LEAL2) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x (ADDL y y)) + // result: (LEAL2 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386ADDL { + continue + } + y := v_1.Args[1] + if y != v_1.Args[0] { + continue + } + v.reset(Op386LEAL2) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x (ADDL x y)) + // result: (LEAL2 y x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386ADDL { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(Op386LEAL2) + v.AddArg2(y, x) + return true + } + } + break + } + // match: (ADDL (ADDLconst [c] x) y) + // result: (LEAL1 [c] x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != Op386ADDLconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + v.reset(Op386LEAL1) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x (LEAL [c] {s} y)) + // cond: x.Op != OpSB && y.Op != OpSB + // result: (LEAL1 [c] {s} x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386LEAL { + continue + } + c := auxIntToInt32(v_1.AuxInt) + s := auxToSym(v_1.Aux) + y := v_1.Args[0] + if !(x.Op != OpSB && y.Op != OpSB) { + continue + } + v.reset(Op386LEAL1) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ADDLload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != Op386MOVLload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(Op386ADDLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (ADDL x (NEGL y)) + // result: (SUBL x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386NEGL { + continue + } + y := v_1.Args[0] + v.reset(Op386SUBL) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValue386_Op386ADDLcarry(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDLcarry x (MOVLconst [c])) + // result: (ADDLconstcarry [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386ADDLconstcarry) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValue386_Op386ADDLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDLconst [c] (ADDL x y)) + // result: (LEAL1 [c] x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386ADDL { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(Op386LEAL1) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (ADDLconst [c] (LEAL [d] {s} x)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL [c+d] {s} x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386LEAL { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(Op386LEAL) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg(x) + return true + } + // match: (ADDLconst [c] x:(SP)) + // result: (LEAL [c] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if x.Op != OpSP { + break + } + v.reset(Op386LEAL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (ADDLconst [c] (LEAL1 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL1 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386LEAL1 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(Op386LEAL1) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDLconst [c] (LEAL2 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL2 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386LEAL2 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(Op386LEAL2) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDLconst [c] (LEAL4 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL4 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386LEAL4 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(Op386LEAL4) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDLconst [c] (LEAL8 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL8 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386LEAL8 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(Op386LEAL8) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDLconst [c] x) + // cond: c==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c == 0) { + break + } + v.copyOf(x) + return true + } + // match: (ADDLconst [c] (MOVLconst [d])) + // result: (MOVLconst [c+d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(c + d) + return true + } + // match: (ADDLconst [c] (ADDLconst [d] x)) + // result: (ADDLconst [c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386ADDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(Op386ADDLconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386ADDLconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ADDLconstmodify [valoff1] {sym} (ADDLconst [off2] base) mem) + // cond: valoff1.canAdd32(off2) + // result: (ADDLconstmodify [valoff1.addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(valoff1.canAdd32(off2)) { + break + } + v.reset(Op386ADDLconstmodify) + v.AuxInt = valAndOffToAuxInt(valoff1.addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (ADDLconstmodify [valoff1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: valoff1.canAdd32(off2) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ADDLconstmodify [valoff1.addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(valoff1.canAdd32(off2) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ADDLconstmodify) + v.AuxInt = valAndOffToAuxInt(valoff1.addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValue386_Op386ADDLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ADDLload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ADDLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386ADDLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDLload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ADDLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ADDLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386ADDLmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ADDLmodify [off1] {sym} (ADDLconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ADDLmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386ADDLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (ADDLmodify [off1] {sym1} (LEAL [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ADDLmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ADDLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValue386_Op386ADDSD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDSD x l:(MOVSDload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ADDSDload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != Op386MOVSDload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(Op386ADDSDload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValue386_Op386ADDSDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ADDSDload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ADDSDload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386ADDSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDSDload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ADDSDload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ADDSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386ADDSS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDSS x l:(MOVSSload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ADDSSload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != Op386MOVSSload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(Op386ADDSSload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValue386_Op386ADDSSload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ADDSSload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ADDSSload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386ADDSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDSSload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ADDSSload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ADDSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386ANDL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ANDL x (MOVLconst [c])) + // result: (ANDLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386ANDLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ANDL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ANDLload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != Op386MOVLload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(Op386ANDLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (ANDL x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValue386_Op386ANDLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDLconst [c] (ANDLconst [d] x)) + // result: (ANDLconst [c & d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386ANDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(Op386ANDLconst) + v.AuxInt = int32ToAuxInt(c & d) + v.AddArg(x) + return true + } + // match: (ANDLconst [c] _) + // cond: c==0 + // result: (MOVLconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if !(c == 0) { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (ANDLconst [c] x) + // cond: c==-1 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c == -1) { + break + } + v.copyOf(x) + return true + } + // match: (ANDLconst [c] (MOVLconst [d])) + // result: (MOVLconst [c&d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(c & d) + return true + } + return false +} +func rewriteValue386_Op386ANDLconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ANDLconstmodify [valoff1] {sym} (ADDLconst [off2] base) mem) + // cond: valoff1.canAdd32(off2) + // result: (ANDLconstmodify [valoff1.addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(valoff1.canAdd32(off2)) { + break + } + v.reset(Op386ANDLconstmodify) + v.AuxInt = valAndOffToAuxInt(valoff1.addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (ANDLconstmodify [valoff1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: valoff1.canAdd32(off2) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ANDLconstmodify [valoff1.addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(valoff1.canAdd32(off2) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ANDLconstmodify) + v.AuxInt = valAndOffToAuxInt(valoff1.addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValue386_Op386ANDLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ANDLload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ANDLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386ANDLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ANDLload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ANDLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ANDLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386ANDLmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ANDLmodify [off1] {sym} (ADDLconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ANDLmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386ANDLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (ANDLmodify [off1] {sym1} (LEAL [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ANDLmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ANDLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValue386_Op386CMPB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPB x (MOVLconst [c])) + // result: (CMPBconst x [int8(c)]) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386CMPBconst) + v.AuxInt = int8ToAuxInt(int8(c)) + v.AddArg(x) + return true + } + // match: (CMPB (MOVLconst [c]) x) + // result: (InvertFlags (CMPBconst x [int8(c)])) + for { + if v_0.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(Op386InvertFlags) + v0 := b.NewValue0(v.Pos, Op386CMPBconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMPB x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPB y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(Op386InvertFlags) + v0 := b.NewValue0(v.Pos, Op386CMPB, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + // match: (CMPB l:(MOVBload {sym} [off] ptr mem) x) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (CMPBload {sym} [off] ptr x mem) + for { + l := v_0 + if l.Op != Op386MOVBload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(Op386CMPBload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (CMPB x l:(MOVBload {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (InvertFlags (CMPBload {sym} [off] ptr x mem)) + for { + x := v_0 + l := v_1 + if l.Op != Op386MOVBload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(Op386InvertFlags) + v0 := b.NewValue0(l.Pos, Op386CMPBload, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, x, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValue386_Op386CMPBconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CMPBconst (MOVLconst [x]) [y]) + // cond: int8(x)==y + // result: (FlagEQ) + for { + y := auxIntToInt8(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(int8(x) == y) { + break + } + v.reset(Op386FlagEQ) + return true + } + // match: (CMPBconst (MOVLconst [x]) [y]) + // cond: int8(x)uint8(y) + // result: (FlagLT_UGT) + for { + y := auxIntToInt8(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(int8(x) < y && uint8(x) > uint8(y)) { + break + } + v.reset(Op386FlagLT_UGT) + return true + } + // match: (CMPBconst (MOVLconst [x]) [y]) + // cond: int8(x)>y && uint8(x) y && uint8(x) < uint8(y)) { + break + } + v.reset(Op386FlagGT_ULT) + return true + } + // match: (CMPBconst (MOVLconst [x]) [y]) + // cond: int8(x)>y && uint8(x)>uint8(y) + // result: (FlagGT_UGT) + for { + y := auxIntToInt8(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(int8(x) > y && uint8(x) > uint8(y)) { + break + } + v.reset(Op386FlagGT_UGT) + return true + } + // match: (CMPBconst (ANDLconst _ [m]) [n]) + // cond: 0 <= int8(m) && int8(m) < n + // result: (FlagLT_ULT) + for { + n := auxIntToInt8(v.AuxInt) + if v_0.Op != Op386ANDLconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + if !(0 <= int8(m) && int8(m) < n) { + break + } + v.reset(Op386FlagLT_ULT) + return true + } + // match: (CMPBconst l:(ANDL x y) [0]) + // cond: l.Uses==1 + // result: (TESTB x y) + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + l := v_0 + if l.Op != Op386ANDL { + break + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v.reset(Op386TESTB) + v.AddArg2(x, y) + return true + } + // match: (CMPBconst l:(ANDLconst [c] x) [0]) + // cond: l.Uses==1 + // result: (TESTBconst [int8(c)] x) + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + l := v_0 + if l.Op != Op386ANDLconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v.reset(Op386TESTBconst) + v.AuxInt = int8ToAuxInt(int8(c)) + v.AddArg(x) + return true + } + // match: (CMPBconst x [0]) + // result: (TESTB x x) + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.reset(Op386TESTB) + v.AddArg2(x, x) + return true + } + // match: (CMPBconst l:(MOVBload {sym} [off] ptr mem) [c]) + // cond: l.Uses == 1 && clobber(l) + // result: @l.Block (CMPBconstload {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + c := auxIntToInt8(v.AuxInt) + l := v_0 + if l.Op != Op386MOVBload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(l.Uses == 1 && clobber(l)) { + break + } + b = l.Block + v0 := b.NewValue0(l.Pos, Op386CMPBconstload, types.TypeFlags) + v.copyOf(v0) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386CMPBload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMPBload {sym} [off] ptr (MOVLconst [c]) mem) + // result: (CMPBconstload {sym} [makeValAndOff(int32(int8(c)),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(Op386CMPBconstload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(int8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386CMPL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPL x (MOVLconst [c])) + // result: (CMPLconst x [c]) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386CMPLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPL (MOVLconst [c]) x) + // result: (InvertFlags (CMPLconst x [c])) + for { + if v_0.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(Op386InvertFlags) + v0 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMPL x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPL y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(Op386InvertFlags) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + // match: (CMPL l:(MOVLload {sym} [off] ptr mem) x) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (CMPLload {sym} [off] ptr x mem) + for { + l := v_0 + if l.Op != Op386MOVLload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(Op386CMPLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (CMPL x l:(MOVLload {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (InvertFlags (CMPLload {sym} [off] ptr x mem)) + for { + x := v_0 + l := v_1 + if l.Op != Op386MOVLload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(Op386InvertFlags) + v0 := b.NewValue0(l.Pos, Op386CMPLload, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, x, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValue386_Op386CMPLconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CMPLconst (MOVLconst [x]) [y]) + // cond: x==y + // result: (FlagEQ) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(x == y) { + break + } + v.reset(Op386FlagEQ) + return true + } + // match: (CMPLconst (MOVLconst [x]) [y]) + // cond: xuint32(y) + // result: (FlagLT_UGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(x < y && uint32(x) > uint32(y)) { + break + } + v.reset(Op386FlagLT_UGT) + return true + } + // match: (CMPLconst (MOVLconst [x]) [y]) + // cond: x>y && uint32(x) y && uint32(x) < uint32(y)) { + break + } + v.reset(Op386FlagGT_ULT) + return true + } + // match: (CMPLconst (MOVLconst [x]) [y]) + // cond: x>y && uint32(x)>uint32(y) + // result: (FlagGT_UGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(x > y && uint32(x) > uint32(y)) { + break + } + v.reset(Op386FlagGT_UGT) + return true + } + // match: (CMPLconst (SHRLconst _ [c]) [n]) + // cond: 0 <= n && 0 < c && c <= 32 && (1<uint16(y) + // result: (FlagLT_UGT) + for { + y := auxIntToInt16(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(int16(x) < y && uint16(x) > uint16(y)) { + break + } + v.reset(Op386FlagLT_UGT) + return true + } + // match: (CMPWconst (MOVLconst [x]) [y]) + // cond: int16(x)>y && uint16(x) y && uint16(x) < uint16(y)) { + break + } + v.reset(Op386FlagGT_ULT) + return true + } + // match: (CMPWconst (MOVLconst [x]) [y]) + // cond: int16(x)>y && uint16(x)>uint16(y) + // result: (FlagGT_UGT) + for { + y := auxIntToInt16(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(int16(x) > y && uint16(x) > uint16(y)) { + break + } + v.reset(Op386FlagGT_UGT) + return true + } + // match: (CMPWconst (ANDLconst _ [m]) [n]) + // cond: 0 <= int16(m) && int16(m) < n + // result: (FlagLT_ULT) + for { + n := auxIntToInt16(v.AuxInt) + if v_0.Op != Op386ANDLconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + if !(0 <= int16(m) && int16(m) < n) { + break + } + v.reset(Op386FlagLT_ULT) + return true + } + // match: (CMPWconst l:(ANDL x y) [0]) + // cond: l.Uses==1 + // result: (TESTW x y) + for { + if auxIntToInt16(v.AuxInt) != 0 { + break + } + l := v_0 + if l.Op != Op386ANDL { + break + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v.reset(Op386TESTW) + v.AddArg2(x, y) + return true + } + // match: (CMPWconst l:(ANDLconst [c] x) [0]) + // cond: l.Uses==1 + // result: (TESTWconst [int16(c)] x) + for { + if auxIntToInt16(v.AuxInt) != 0 { + break + } + l := v_0 + if l.Op != Op386ANDLconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v.reset(Op386TESTWconst) + v.AuxInt = int16ToAuxInt(int16(c)) + v.AddArg(x) + return true + } + // match: (CMPWconst x [0]) + // result: (TESTW x x) + for { + if auxIntToInt16(v.AuxInt) != 0 { + break + } + x := v_0 + v.reset(Op386TESTW) + v.AddArg2(x, x) + return true + } + // match: (CMPWconst l:(MOVWload {sym} [off] ptr mem) [c]) + // cond: l.Uses == 1 && clobber(l) + // result: @l.Block (CMPWconstload {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + c := auxIntToInt16(v.AuxInt) + l := v_0 + if l.Op != Op386MOVWload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(l.Uses == 1 && clobber(l)) { + break + } + b = l.Block + v0 := b.NewValue0(l.Pos, Op386CMPWconstload, types.TypeFlags) + v.copyOf(v0) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386CMPWload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMPWload {sym} [off] ptr (MOVLconst [c]) mem) + // result: (CMPWconstload {sym} [makeValAndOff(int32(int16(c)),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(Op386CMPWconstload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(int16(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386DIVSD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (DIVSD x l:(MOVSDload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (DIVSDload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != Op386MOVSDload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(Op386DIVSDload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386DIVSDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (DIVSDload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (DIVSDload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386DIVSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (DIVSDload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (DIVSDload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386DIVSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386DIVSS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (DIVSS x l:(MOVSSload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (DIVSSload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != Op386MOVSSload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(Op386DIVSSload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386DIVSSload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (DIVSSload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (DIVSSload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386DIVSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (DIVSSload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (DIVSSload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386DIVSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386LEAL(v *Value) bool { + v_0 := v.Args[0] + // match: (LEAL [c] {s} (ADDLconst [d] x)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL [c+d] {s} x) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(Op386LEAL) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg(x) + return true + } + // match: (LEAL [c] {s} (ADDL x y)) + // cond: x.Op != OpSB && y.Op != OpSB + // result: (LEAL1 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != Op386ADDL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if !(x.Op != OpSB && y.Op != OpSB) { + continue + } + v.reset(Op386LEAL1) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAL [off1] {sym1} (LEAL [off2] {sym2} x)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAL [off1+off2] {mergeSym(sym1,sym2)} x) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(Op386LEAL) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg(x) + return true + } + // match: (LEAL [off1] {sym1} (LEAL1 [off2] {sym2} x y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAL1 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL1 { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(Op386LEAL1) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAL [off1] {sym1} (LEAL2 [off2] {sym2} x y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAL2 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL2 { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(Op386LEAL2) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAL [off1] {sym1} (LEAL4 [off2] {sym2} x y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAL4 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL4 { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(Op386LEAL4) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAL [off1] {sym1} (LEAL8 [off2] {sym2} x y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAL8 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL8 { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(Op386LEAL8) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_Op386LEAL1(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAL1 [c] {s} (ADDLconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAL1 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != Op386ADDLconst { + continue + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + continue + } + v.reset(Op386LEAL1) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAL1 [c] {s} x (SHLLconst [1] y)) + // result: (LEAL2 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386SHLLconst || auxIntToInt32(v_1.AuxInt) != 1 { + continue + } + y := v_1.Args[0] + v.reset(Op386LEAL2) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAL1 [c] {s} x (SHLLconst [2] y)) + // result: (LEAL4 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386SHLLconst || auxIntToInt32(v_1.AuxInt) != 2 { + continue + } + y := v_1.Args[0] + v.reset(Op386LEAL4) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAL1 [c] {s} x (SHLLconst [3] y)) + // result: (LEAL8 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386SHLLconst || auxIntToInt32(v_1.AuxInt) != 3 { + continue + } + y := v_1.Args[0] + v.reset(Op386LEAL8) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAL1 [off1] {sym1} (LEAL [off2] {sym2} x) y) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB + // result: (LEAL1 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != Op386LEAL { + continue + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB) { + continue + } + v.reset(Op386LEAL1) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAL1 [off1] {sym1} x (LEAL1 [off2] {sym2} y y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAL2 [off1+off2] {mergeSym(sym1, sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386LEAL1 { + continue + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + y := v_1.Args[1] + if y != v_1.Args[0] || !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + continue + } + v.reset(Op386LEAL2) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAL1 [off1] {sym1} x (LEAL1 [off2] {sym2} x y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAL2 [off1+off2] {mergeSym(sym1, sym2)} y x) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386LEAL1 { + continue + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + continue + } + v.reset(Op386LEAL2) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(y, x) + return true + } + } + break + } + // match: (LEAL1 [0] {nil} x y) + // result: (ADDL x y) + for { + if auxIntToInt32(v.AuxInt) != 0 || auxToSym(v.Aux) != nil { + break + } + x := v_0 + y := v_1 + v.reset(Op386ADDL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_Op386LEAL2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAL2 [c] {s} (ADDLconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAL2 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + break + } + v.reset(Op386LEAL2) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL2 [c] {s} x (ADDLconst [d] y)) + // cond: is32Bit(int64(c)+2*int64(d)) && y.Op != OpSB + // result: (LEAL2 [c+2*d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != Op386ADDLconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(is32Bit(int64(c)+2*int64(d)) && y.Op != OpSB) { + break + } + v.reset(Op386LEAL2) + v.AuxInt = int32ToAuxInt(c + 2*d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL2 [c] {s} x (SHLLconst [1] y)) + // result: (LEAL4 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != Op386SHLLconst || auxIntToInt32(v_1.AuxInt) != 1 { + break + } + y := v_1.Args[0] + v.reset(Op386LEAL4) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL2 [c] {s} x (SHLLconst [2] y)) + // result: (LEAL8 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != Op386SHLLconst || auxIntToInt32(v_1.AuxInt) != 2 { + break + } + y := v_1.Args[0] + v.reset(Op386LEAL8) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL2 [off1] {sym1} (LEAL [off2] {sym2} x) y) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB + // result: (LEAL2 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB) { + break + } + v.reset(Op386LEAL2) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAL2 [off1] {sym} x (LEAL1 [off2] {nil} y y)) + // cond: is32Bit(int64(off1)+2*int64(off2)) + // result: (LEAL4 [off1+2*off2] {sym} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != Op386LEAL1 { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + if auxToSym(v_1.Aux) != nil { + break + } + y := v_1.Args[1] + if y != v_1.Args[0] || !(is32Bit(int64(off1) + 2*int64(off2))) { + break + } + v.reset(Op386LEAL4) + v.AuxInt = int32ToAuxInt(off1 + 2*off2) + v.Aux = symToAux(sym) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_Op386LEAL4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAL4 [c] {s} (ADDLconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAL4 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + break + } + v.reset(Op386LEAL4) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL4 [c] {s} x (ADDLconst [d] y)) + // cond: is32Bit(int64(c)+4*int64(d)) && y.Op != OpSB + // result: (LEAL4 [c+4*d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != Op386ADDLconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(is32Bit(int64(c)+4*int64(d)) && y.Op != OpSB) { + break + } + v.reset(Op386LEAL4) + v.AuxInt = int32ToAuxInt(c + 4*d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL4 [c] {s} x (SHLLconst [1] y)) + // result: (LEAL8 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != Op386SHLLconst || auxIntToInt32(v_1.AuxInt) != 1 { + break + } + y := v_1.Args[0] + v.reset(Op386LEAL8) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL4 [off1] {sym1} (LEAL [off2] {sym2} x) y) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB + // result: (LEAL4 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB) { + break + } + v.reset(Op386LEAL4) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAL4 [off1] {sym} x (LEAL1 [off2] {nil} y y)) + // cond: is32Bit(int64(off1)+4*int64(off2)) + // result: (LEAL8 [off1+4*off2] {sym} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != Op386LEAL1 { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + if auxToSym(v_1.Aux) != nil { + break + } + y := v_1.Args[1] + if y != v_1.Args[0] || !(is32Bit(int64(off1) + 4*int64(off2))) { + break + } + v.reset(Op386LEAL8) + v.AuxInt = int32ToAuxInt(off1 + 4*off2) + v.Aux = symToAux(sym) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_Op386LEAL8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAL8 [c] {s} (ADDLconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAL8 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + break + } + v.reset(Op386LEAL8) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL8 [c] {s} x (ADDLconst [d] y)) + // cond: is32Bit(int64(c)+8*int64(d)) && y.Op != OpSB + // result: (LEAL8 [c+8*d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != Op386ADDLconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(is32Bit(int64(c)+8*int64(d)) && y.Op != OpSB) { + break + } + v.reset(Op386LEAL8) + v.AuxInt = int32ToAuxInt(c + 8*d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL8 [off1] {sym1} (LEAL [off2] {sym2} x) y) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB + // result: (LEAL8 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB) { + break + } + v.reset(Op386LEAL8) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_Op386LoweredPanicBoundsRC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRC [kind] {p} (MOVLconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:int64(c), Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + mem := v_1 + v.reset(Op386LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: int64(c), Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValue386_Op386LoweredPanicBoundsRR(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRR [kind] x (MOVLconst [c]) mem) + // result: (LoweredPanicBoundsRC [kind] x {PanicBoundsC{C:int64(c)}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(Op386LoweredPanicBoundsRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(c)}) + v.AddArg2(x, mem) + return true + } + // match: (LoweredPanicBoundsRR [kind] (MOVLconst [c]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:int64(c)}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_1 + mem := v_2 + v.reset(Op386LoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(c)}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValue386_Op386LoweredPanicExtendRC(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicExtendRC [kind] {p} (MOVLconst [hi]) (MOVLconst [lo]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:int64(hi)<<32+int64(uint32(lo)), Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != Op386MOVLconst { + break + } + hi := auxIntToInt32(v_0.AuxInt) + if v_1.Op != Op386MOVLconst { + break + } + lo := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(Op386LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: int64(hi)<<32 + int64(uint32(lo)), Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValue386_Op386LoweredPanicExtendRR(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicExtendRR [kind] hi lo (MOVLconst [c]) mem) + // result: (LoweredPanicExtendRC [kind] hi lo {PanicBoundsC{C:int64(c)}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + hi := v_0 + lo := v_1 + if v_2.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + mem := v_3 + v.reset(Op386LoweredPanicExtendRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(c)}) + v.AddArg3(hi, lo, mem) + return true + } + // match: (LoweredPanicExtendRR [kind] (MOVLconst [hi]) (MOVLconst [lo]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:int64(hi)<<32 + int64(uint32(lo))}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + hi := auxIntToInt32(v_0.AuxInt) + if v_1.Op != Op386MOVLconst { + break + } + lo := auxIntToInt32(v_1.AuxInt) + y := v_2 + mem := v_3 + v.reset(Op386LoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(hi)<<32 + int64(uint32(lo))}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValue386_Op386MOVBLSX(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVBLSX x:(MOVBload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBLSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != Op386MOVBload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, Op386MOVBLSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBLSX (ANDLconst [c] x)) + // cond: c & 0x80 == 0 + // result: (ANDLconst [c & 0x7f] x) + for { + if v_0.Op != Op386ANDLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(c&0x80 == 0) { + break + } + v.reset(Op386ANDLconst) + v.AuxInt = int32ToAuxInt(c & 0x7f) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386MOVBLSXload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBLSXload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVBLSX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVBstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(Op386MOVBLSX) + v.AddArg(x) + return true + } + // match: (MOVBLSXload [off1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVBLSXload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVBLSXload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVBLSXload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVLconst [int32(int8(read8(sym, int64(off))))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(int32(int8(read8(sym, int64(off))))) + return true + } + return false +} +func rewriteValue386_Op386MOVBLZX(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVBLZX x:(MOVBload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != Op386MOVBload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, Op386MOVBload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBLZX (ANDLconst [c] x)) + // result: (ANDLconst [c & 0xff] x) + for { + if v_0.Op != Op386ANDLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(Op386ANDLconst) + v.AuxInt = int32ToAuxInt(c & 0xff) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386MOVBload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVBLZX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVBstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(Op386MOVBLZX) + v.AddArg(x) + return true + } + // match: (MOVBload [off1] {sym} (ADDLconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVBload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVBload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVBload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVLconst [int32(read8(sym, int64(off)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(int32(read8(sym, int64(off)))) + return true + } + return false +} +func rewriteValue386_Op386MOVBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBstore [off] {sym} ptr (MOVBLSX x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVBLSX { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(Op386MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBLZX x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVBLZX { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(Op386MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off1] {sym} (ADDLconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVBstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVLconst [c]) mem) + // result: (MOVBstoreconst [makeValAndOff(c,off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(Op386MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(c, off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstore [off1] {sym1} (LEAL [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValue386_Op386MOVBstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBstoreconst [sc] {s} (ADDLconst [off] ptr) mem) + // cond: sc.canAdd32(off) + // result: (MOVBstoreconst [sc.addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(sc.canAdd32(off)) { + break + } + v.reset(Op386MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstoreconst [sc] {sym1} (LEAL [off] {sym2} ptr) mem) + // cond: canMergeSym(sym1, sym2) && sc.canAdd32(off) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVBstoreconst [sc.addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && sc.canAdd32(off) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386MOVLload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVLload [off] {sym} ptr (MOVLstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVLstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + // match: (MOVLload [off1] {sym} (ADDLconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVLload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MOVLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLload [off1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVLload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVLload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVLconst [int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValue386_Op386MOVLstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVLstore [off1] {sym} (ADDLconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVLstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MOVLstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVLstore [off] {sym} ptr (MOVLconst [c]) mem) + // result: (MOVLstoreconst [makeValAndOff(c,off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(Op386MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(c, off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstore [off1] {sym1} (LEAL [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVLstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVLstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ADDLload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (ADDLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386ADDLload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(Op386ADDLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ANDLload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (ANDLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386ANDLload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(Op386ANDLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ORLload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (ORLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386ORLload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(Op386ORLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(XORLload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (XORLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386XORLload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(Op386XORLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ADDL l:(MOVLload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ADDLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386ADDL { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != Op386MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(Op386ADDLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVLstore {sym} [off] ptr y:(SUBL l:(MOVLload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (SUBLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386SUBL { + break + } + x := y.Args[1] + l := y.Args[0] + if l.Op != Op386MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + if ptr != l.Args[0] || mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + break + } + v.reset(Op386SUBLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ANDL l:(MOVLload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ANDLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386ANDL { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != Op386MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(Op386ANDLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVLstore {sym} [off] ptr y:(ORL l:(MOVLload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ORLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386ORL { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != Op386MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(Op386ORLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVLstore {sym} [off] ptr y:(XORL l:(MOVLload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (XORLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386XORL { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != Op386MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(Op386XORLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVLstore {sym} [off] ptr y:(ADDLconst [c] l:(MOVLload [off] {sym} ptr mem)) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ADDLconstmodify [makeValAndOff(c,off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386ADDLconst { + break + } + c := auxIntToInt32(y.AuxInt) + l := y.Args[0] + if l.Op != Op386MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + if ptr != l.Args[0] || mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + break + } + v.reset(Op386ADDLconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(c, off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ANDLconst [c] l:(MOVLload [off] {sym} ptr mem)) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ANDLconstmodify [makeValAndOff(c,off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386ANDLconst { + break + } + c := auxIntToInt32(y.AuxInt) + l := y.Args[0] + if l.Op != Op386MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + if ptr != l.Args[0] || mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + break + } + v.reset(Op386ANDLconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(c, off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ORLconst [c] l:(MOVLload [off] {sym} ptr mem)) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ORLconstmodify [makeValAndOff(c,off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386ORLconst { + break + } + c := auxIntToInt32(y.AuxInt) + l := y.Args[0] + if l.Op != Op386MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + if ptr != l.Args[0] || mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + break + } + v.reset(Op386ORLconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(c, off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(XORLconst [c] l:(MOVLload [off] {sym} ptr mem)) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (XORLconstmodify [makeValAndOff(c,off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != Op386XORLconst { + break + } + c := auxIntToInt32(y.AuxInt) + l := y.Args[0] + if l.Op != Op386MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + if ptr != l.Args[0] || mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + break + } + v.reset(Op386XORLconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(c, off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386MOVLstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVLstoreconst [sc] {s} (ADDLconst [off] ptr) mem) + // cond: sc.canAdd32(off) + // result: (MOVLstoreconst [sc.addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(sc.canAdd32(off)) { + break + } + v.reset(Op386MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstoreconst [sc] {sym1} (LEAL [off] {sym2} ptr) mem) + // cond: canMergeSym(sym1, sym2) && sc.canAdd32(off) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVLstoreconst [sc.addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && sc.canAdd32(off) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386MOVSDconst(v *Value) bool { + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVSDconst [c]) + // cond: config.ctxt.Flag_shared + // result: (MOVSDconst2 (MOVSDconst1 [c])) + for { + c := auxIntToFloat64(v.AuxInt) + if !(config.ctxt.Flag_shared) { + break + } + v.reset(Op386MOVSDconst2) + v0 := b.NewValue0(v.Pos, Op386MOVSDconst1, typ.UInt32) + v0.AuxInt = float64ToAuxInt(c) + v.AddArg(v0) + return true + } + return false +} +func rewriteValue386_Op386MOVSDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVSDload [off1] {sym} (ADDLconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVSDload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MOVSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVSDload [off1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVSDload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValue386_Op386MOVSDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVSDstore [off1] {sym} (ADDLconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVSDstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MOVSDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVSDstore [off1] {sym1} (LEAL [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVSDstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVSDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValue386_Op386MOVSSconst(v *Value) bool { + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVSSconst [c]) + // cond: config.ctxt.Flag_shared + // result: (MOVSSconst2 (MOVSSconst1 [c])) + for { + c := auxIntToFloat32(v.AuxInt) + if !(config.ctxt.Flag_shared) { + break + } + v.reset(Op386MOVSSconst2) + v0 := b.NewValue0(v.Pos, Op386MOVSSconst1, typ.UInt32) + v0.AuxInt = float32ToAuxInt(c) + v.AddArg(v0) + return true + } + return false +} +func rewriteValue386_Op386MOVSSload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVSSload [off1] {sym} (ADDLconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVSSload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MOVSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVSSload [off1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVSSload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValue386_Op386MOVSSstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVSSstore [off1] {sym} (ADDLconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVSSstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MOVSSstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVSSstore [off1] {sym1} (LEAL [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVSSstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVSSstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValue386_Op386MOVWLSX(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVWLSX x:(MOVWload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWLSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != Op386MOVWload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, Op386MOVWLSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVWLSX (ANDLconst [c] x)) + // cond: c & 0x8000 == 0 + // result: (ANDLconst [c & 0x7fff] x) + for { + if v_0.Op != Op386ANDLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(c&0x8000 == 0) { + break + } + v.reset(Op386ANDLconst) + v.AuxInt = int32ToAuxInt(c & 0x7fff) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386MOVWLSXload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWLSXload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVWLSX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVWstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(Op386MOVWLSX) + v.AddArg(x) + return true + } + // match: (MOVWLSXload [off1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVWLSXload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVWLSXload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVWLSXload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVLconst [int32(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(int32(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValue386_Op386MOVWLZX(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVWLZX x:(MOVWload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != Op386MOVWload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, Op386MOVWload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVWLZX (ANDLconst [c] x)) + // result: (ANDLconst [c & 0xffff] x) + for { + if v_0.Op != Op386ANDLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(Op386ANDLconst) + v.AuxInt = int32ToAuxInt(c & 0xffff) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386MOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVWLZX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVWstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(Op386MOVWLZX) + v.AddArg(x) + return true + } + // match: (MOVWload [off1] {sym} (ADDLconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVWload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVWload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVWload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVLconst [int32(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(int32(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValue386_Op386MOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWstore [off] {sym} ptr (MOVWLSX x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVWLSX { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(Op386MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWLZX x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVWLZX { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(Op386MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off1] {sym} (ADDLconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVWstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVLconst [c]) mem) + // result: (MOVWstoreconst [makeValAndOff(c,off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(Op386MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(c, off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstore [off1] {sym1} (LEAL [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValue386_Op386MOVWstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWstoreconst [sc] {s} (ADDLconst [off] ptr) mem) + // cond: sc.canAdd32(off) + // result: (MOVWstoreconst [sc.addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(sc.canAdd32(off)) { + break + } + v.reset(Op386MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstoreconst [sc] {sym1} (LEAL [off] {sym2} ptr) mem) + // cond: canMergeSym(sym1, sym2) && sc.canAdd32(off) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVWstoreconst [sc.addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && sc.canAdd32(off) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386MULL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULL x (MOVLconst [c])) + // result: (MULLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386MULLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (MULL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (MULLload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != Op386MOVLload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(Op386MULLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValue386_Op386MULLconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MULLconst [c] (MULLconst [d] x)) + // result: (MULLconst [c * d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386MULLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(Op386MULLconst) + v.AuxInt = int32ToAuxInt(c * d) + v.AddArg(x) + return true + } + // match: (MULLconst [-9] x) + // result: (NEGL (LEAL8 x x)) + for { + if auxIntToInt32(v.AuxInt) != -9 { + break + } + x := v_0 + v.reset(Op386NEGL) + v0 := b.NewValue0(v.Pos, Op386LEAL8, v.Type) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + // match: (MULLconst [-5] x) + // result: (NEGL (LEAL4 x x)) + for { + if auxIntToInt32(v.AuxInt) != -5 { + break + } + x := v_0 + v.reset(Op386NEGL) + v0 := b.NewValue0(v.Pos, Op386LEAL4, v.Type) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + // match: (MULLconst [-3] x) + // result: (NEGL (LEAL2 x x)) + for { + if auxIntToInt32(v.AuxInt) != -3 { + break + } + x := v_0 + v.reset(Op386NEGL) + v0 := b.NewValue0(v.Pos, Op386LEAL2, v.Type) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + // match: (MULLconst [-1] x) + // result: (NEGL x) + for { + if auxIntToInt32(v.AuxInt) != -1 { + break + } + x := v_0 + v.reset(Op386NEGL) + v.AddArg(x) + return true + } + // match: (MULLconst [0] _) + // result: (MOVLconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (MULLconst [1] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 1 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (MULLconst [3] x) + // result: (LEAL2 x x) + for { + if auxIntToInt32(v.AuxInt) != 3 { + break + } + x := v_0 + v.reset(Op386LEAL2) + v.AddArg2(x, x) + return true + } + // match: (MULLconst [5] x) + // result: (LEAL4 x x) + for { + if auxIntToInt32(v.AuxInt) != 5 { + break + } + x := v_0 + v.reset(Op386LEAL4) + v.AddArg2(x, x) + return true + } + // match: (MULLconst [7] x) + // result: (LEAL2 x (LEAL2 x x)) + for { + if auxIntToInt32(v.AuxInt) != 7 { + break + } + x := v_0 + v.reset(Op386LEAL2) + v0 := b.NewValue0(v.Pos, Op386LEAL2, v.Type) + v0.AddArg2(x, x) + v.AddArg2(x, v0) + return true + } + // match: (MULLconst [9] x) + // result: (LEAL8 x x) + for { + if auxIntToInt32(v.AuxInt) != 9 { + break + } + x := v_0 + v.reset(Op386LEAL8) + v.AddArg2(x, x) + return true + } + // match: (MULLconst [11] x) + // result: (LEAL2 x (LEAL4 x x)) + for { + if auxIntToInt32(v.AuxInt) != 11 { + break + } + x := v_0 + v.reset(Op386LEAL2) + v0 := b.NewValue0(v.Pos, Op386LEAL4, v.Type) + v0.AddArg2(x, x) + v.AddArg2(x, v0) + return true + } + // match: (MULLconst [13] x) + // result: (LEAL4 x (LEAL2 x x)) + for { + if auxIntToInt32(v.AuxInt) != 13 { + break + } + x := v_0 + v.reset(Op386LEAL4) + v0 := b.NewValue0(v.Pos, Op386LEAL2, v.Type) + v0.AddArg2(x, x) + v.AddArg2(x, v0) + return true + } + // match: (MULLconst [19] x) + // result: (LEAL2 x (LEAL8 x x)) + for { + if auxIntToInt32(v.AuxInt) != 19 { + break + } + x := v_0 + v.reset(Op386LEAL2) + v0 := b.NewValue0(v.Pos, Op386LEAL8, v.Type) + v0.AddArg2(x, x) + v.AddArg2(x, v0) + return true + } + // match: (MULLconst [21] x) + // result: (LEAL4 x (LEAL4 x x)) + for { + if auxIntToInt32(v.AuxInt) != 21 { + break + } + x := v_0 + v.reset(Op386LEAL4) + v0 := b.NewValue0(v.Pos, Op386LEAL4, v.Type) + v0.AddArg2(x, x) + v.AddArg2(x, v0) + return true + } + // match: (MULLconst [25] x) + // result: (LEAL8 x (LEAL2 x x)) + for { + if auxIntToInt32(v.AuxInt) != 25 { + break + } + x := v_0 + v.reset(Op386LEAL8) + v0 := b.NewValue0(v.Pos, Op386LEAL2, v.Type) + v0.AddArg2(x, x) + v.AddArg2(x, v0) + return true + } + // match: (MULLconst [27] x) + // result: (LEAL8 (LEAL2 x x) (LEAL2 x x)) + for { + if auxIntToInt32(v.AuxInt) != 27 { + break + } + x := v_0 + v.reset(Op386LEAL8) + v0 := b.NewValue0(v.Pos, Op386LEAL2, v.Type) + v0.AddArg2(x, x) + v.AddArg2(v0, v0) + return true + } + // match: (MULLconst [37] x) + // result: (LEAL4 x (LEAL8 x x)) + for { + if auxIntToInt32(v.AuxInt) != 37 { + break + } + x := v_0 + v.reset(Op386LEAL4) + v0 := b.NewValue0(v.Pos, Op386LEAL8, v.Type) + v0.AddArg2(x, x) + v.AddArg2(x, v0) + return true + } + // match: (MULLconst [41] x) + // result: (LEAL8 x (LEAL4 x x)) + for { + if auxIntToInt32(v.AuxInt) != 41 { + break + } + x := v_0 + v.reset(Op386LEAL8) + v0 := b.NewValue0(v.Pos, Op386LEAL4, v.Type) + v0.AddArg2(x, x) + v.AddArg2(x, v0) + return true + } + // match: (MULLconst [45] x) + // result: (LEAL8 (LEAL4 x x) (LEAL4 x x)) + for { + if auxIntToInt32(v.AuxInt) != 45 { + break + } + x := v_0 + v.reset(Op386LEAL8) + v0 := b.NewValue0(v.Pos, Op386LEAL4, v.Type) + v0.AddArg2(x, x) + v.AddArg2(v0, v0) + return true + } + // match: (MULLconst [73] x) + // result: (LEAL8 x (LEAL8 x x)) + for { + if auxIntToInt32(v.AuxInt) != 73 { + break + } + x := v_0 + v.reset(Op386LEAL8) + v0 := b.NewValue0(v.Pos, Op386LEAL8, v.Type) + v0.AddArg2(x, x) + v.AddArg2(x, v0) + return true + } + // match: (MULLconst [81] x) + // result: (LEAL8 (LEAL8 x x) (LEAL8 x x)) + for { + if auxIntToInt32(v.AuxInt) != 81 { + break + } + x := v_0 + v.reset(Op386LEAL8) + v0 := b.NewValue0(v.Pos, Op386LEAL8, v.Type) + v0.AddArg2(x, x) + v.AddArg2(v0, v0) + return true + } + // match: (MULLconst [c] x) + // cond: isPowerOfTwo(c+1) && c >= 15 + // result: (SUBL (SHLLconst [int32(log32(c+1))] x) x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(c+1) && c >= 15) { + break + } + v.reset(Op386SUBL) + v0 := b.NewValue0(v.Pos, Op386SHLLconst, v.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c + 1))) + v0.AddArg(x) + v.AddArg2(v0, x) + return true + } + // match: (MULLconst [c] x) + // cond: isPowerOfTwo(c-1) && c >= 17 + // result: (LEAL1 (SHLLconst [int32(log32(c-1))] x) x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(c-1) && c >= 17) { + break + } + v.reset(Op386LEAL1) + v0 := b.NewValue0(v.Pos, Op386SHLLconst, v.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c - 1))) + v0.AddArg(x) + v.AddArg2(v0, x) + return true + } + // match: (MULLconst [c] x) + // cond: isPowerOfTwo(c-2) && c >= 34 + // result: (LEAL2 (SHLLconst [int32(log32(c-2))] x) x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(c-2) && c >= 34) { + break + } + v.reset(Op386LEAL2) + v0 := b.NewValue0(v.Pos, Op386SHLLconst, v.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c - 2))) + v0.AddArg(x) + v.AddArg2(v0, x) + return true + } + // match: (MULLconst [c] x) + // cond: isPowerOfTwo(c-4) && c >= 68 + // result: (LEAL4 (SHLLconst [int32(log32(c-4))] x) x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(c-4) && c >= 68) { + break + } + v.reset(Op386LEAL4) + v0 := b.NewValue0(v.Pos, Op386SHLLconst, v.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c - 4))) + v0.AddArg(x) + v.AddArg2(v0, x) + return true + } + // match: (MULLconst [c] x) + // cond: isPowerOfTwo(c-8) && c >= 136 + // result: (LEAL8 (SHLLconst [int32(log32(c-8))] x) x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(c-8) && c >= 136) { + break + } + v.reset(Op386LEAL8) + v0 := b.NewValue0(v.Pos, Op386SHLLconst, v.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c - 8))) + v0.AddArg(x) + v.AddArg2(v0, x) + return true + } + // match: (MULLconst [c] x) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (SHLLconst [int32(log32(c/3))] (LEAL2 x x)) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + break + } + v.reset(Op386SHLLconst) + v.AuxInt = int32ToAuxInt(int32(log32(c / 3))) + v0 := b.NewValue0(v.Pos, Op386LEAL2, v.Type) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + // match: (MULLconst [c] x) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (SHLLconst [int32(log32(c/5))] (LEAL4 x x)) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + break + } + v.reset(Op386SHLLconst) + v.AuxInt = int32ToAuxInt(int32(log32(c / 5))) + v0 := b.NewValue0(v.Pos, Op386LEAL4, v.Type) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + // match: (MULLconst [c] x) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (SHLLconst [int32(log32(c/9))] (LEAL8 x x)) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + break + } + v.reset(Op386SHLLconst) + v.AuxInt = int32ToAuxInt(int32(log32(c / 9))) + v0 := b.NewValue0(v.Pos, Op386LEAL8, v.Type) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + // match: (MULLconst [c] (MOVLconst [d])) + // result: (MOVLconst [c*d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(c * d) + return true + } + return false +} +func rewriteValue386_Op386MULLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MULLload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MULLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MULLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (MULLload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MULLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MULLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386MULSD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULSD x l:(MOVSDload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (MULSDload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != Op386MOVSDload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(Op386MULSDload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValue386_Op386MULSDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MULSDload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MULSDload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MULSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (MULSDload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MULSDload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MULSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386MULSS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULSS x l:(MOVSSload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (MULSSload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != Op386MOVSSload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(Op386MULSSload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValue386_Op386MULSSload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MULSSload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MULSSload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386MULSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (MULSSload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MULSSload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386MULSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386NEGL(v *Value) bool { + v_0 := v.Args[0] + // match: (NEGL (MOVLconst [c])) + // result: (MOVLconst [-c]) + for { + if v_0.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(-c) + return true + } + return false +} +func rewriteValue386_Op386NOTL(v *Value) bool { + v_0 := v.Args[0] + // match: (NOTL (MOVLconst [c])) + // result: (MOVLconst [^c]) + for { + if v_0.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(^c) + return true + } + return false +} +func rewriteValue386_Op386ORL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORL x (MOVLconst [c])) + // result: (ORLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386ORLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ORL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ORLload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != Op386MOVLload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(Op386ORLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (ORL x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValue386_Op386ORLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORLconst [c] x) + // cond: c==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c == 0) { + break + } + v.copyOf(x) + return true + } + // match: (ORLconst [c] _) + // cond: c==-1 + // result: (MOVLconst [-1]) + for { + c := auxIntToInt32(v.AuxInt) + if !(c == -1) { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(-1) + return true + } + // match: (ORLconst [c] (MOVLconst [d])) + // result: (MOVLconst [c|d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(c | d) + return true + } + return false +} +func rewriteValue386_Op386ORLconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ORLconstmodify [valoff1] {sym} (ADDLconst [off2] base) mem) + // cond: valoff1.canAdd32(off2) + // result: (ORLconstmodify [valoff1.addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(valoff1.canAdd32(off2)) { + break + } + v.reset(Op386ORLconstmodify) + v.AuxInt = valAndOffToAuxInt(valoff1.addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (ORLconstmodify [valoff1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: valoff1.canAdd32(off2) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ORLconstmodify [valoff1.addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(valoff1.canAdd32(off2) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ORLconstmodify) + v.AuxInt = valAndOffToAuxInt(valoff1.addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValue386_Op386ORLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ORLload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ORLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386ORLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ORLload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ORLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ORLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386ORLmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (ORLmodify [off1] {sym} (ADDLconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ORLmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386ORLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (ORLmodify [off1] {sym1} (LEAL [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (ORLmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386ORLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValue386_Op386ROLB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROLB x (MOVLconst [c])) + // result: (ROLBconst [int8(c&7)] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386ROLBconst) + v.AuxInt = int8ToAuxInt(int8(c & 7)) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386ROLBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ROLBconst [0] x) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValue386_Op386ROLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROLL x (MOVLconst [c])) + // result: (ROLLconst [c&31] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386ROLLconst) + v.AuxInt = int32ToAuxInt(c & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386ROLLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ROLLconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValue386_Op386ROLW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROLW x (MOVLconst [c])) + // result: (ROLWconst [int16(c&15)] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386ROLWconst) + v.AuxInt = int16ToAuxInt(int16(c & 15)) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386ROLWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ROLWconst [0] x) + // result: x + for { + if auxIntToInt16(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValue386_Op386SARB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SARB x (MOVLconst [c])) + // result: (SARBconst [int8(min(int64(c&31),7))] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386SARBconst) + v.AuxInt = int8ToAuxInt(int8(min(int64(c&31), 7))) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386SARBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SARBconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SARBconst [c] (MOVLconst [d])) + // result: (MOVLconst [d>>uint64(c)]) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(d >> uint64(c)) + return true + } + return false +} +func rewriteValue386_Op386SARL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SARL x (MOVLconst [c])) + // result: (SARLconst [c&31] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386SARLconst) + v.AuxInt = int32ToAuxInt(c & 31) + v.AddArg(x) + return true + } + // match: (SARL x (ANDLconst [31] y)) + // result: (SARL x y) + for { + x := v_0 + if v_1.Op != Op386ANDLconst || auxIntToInt32(v_1.AuxInt) != 31 { + break + } + y := v_1.Args[0] + v.reset(Op386SARL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_Op386SARLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SARLconst x [0]) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SARLconst [c] (MOVLconst [d])) + // result: (MOVLconst [d>>uint64(c)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(d >> uint64(c)) + return true + } + return false +} +func rewriteValue386_Op386SARW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SARW x (MOVLconst [c])) + // result: (SARWconst [int16(min(int64(c&31),15))] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386SARWconst) + v.AuxInt = int16ToAuxInt(int16(min(int64(c&31), 15))) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386SARWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SARWconst x [0]) + // result: x + for { + if auxIntToInt16(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SARWconst [c] (MOVLconst [d])) + // result: (MOVLconst [d>>uint64(c)]) + for { + c := auxIntToInt16(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(d >> uint64(c)) + return true + } + return false +} +func rewriteValue386_Op386SBBL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SBBL x (MOVLconst [c]) f) + // result: (SBBLconst [c] x f) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + f := v_2 + v.reset(Op386SBBLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, f) + return true + } + return false +} +func rewriteValue386_Op386SBBLcarrymask(v *Value) bool { + v_0 := v.Args[0] + // match: (SBBLcarrymask (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SBBLcarrymask (FlagLT_ULT)) + // result: (MOVLconst [-1]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(-1) + return true + } + // match: (SBBLcarrymask (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SBBLcarrymask (FlagGT_ULT)) + // result: (MOVLconst [-1]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(-1) + return true + } + // match: (SBBLcarrymask (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_Op386SETA(v *Value) bool { + v_0 := v.Args[0] + // match: (SETA (InvertFlags x)) + // result: (SETB x) + for { + if v_0.Op != Op386InvertFlags { + break + } + x := v_0.Args[0] + v.reset(Op386SETB) + v.AddArg(x) + return true + } + // match: (SETA (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETA (FlagLT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETA (FlagLT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETA (FlagGT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETA (FlagGT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValue386_Op386SETAE(v *Value) bool { + v_0 := v.Args[0] + // match: (SETAE (InvertFlags x)) + // result: (SETBE x) + for { + if v_0.Op != Op386InvertFlags { + break + } + x := v_0.Args[0] + v.reset(Op386SETBE) + v.AddArg(x) + return true + } + // match: (SETAE (FlagEQ)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETAE (FlagLT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETAE (FlagLT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETAE (FlagGT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETAE (FlagGT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValue386_Op386SETB(v *Value) bool { + v_0 := v.Args[0] + // match: (SETB (InvertFlags x)) + // result: (SETA x) + for { + if v_0.Op != Op386InvertFlags { + break + } + x := v_0.Args[0] + v.reset(Op386SETA) + v.AddArg(x) + return true + } + // match: (SETB (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETB (FlagLT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETB (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETB (FlagGT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETB (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_Op386SETBE(v *Value) bool { + v_0 := v.Args[0] + // match: (SETBE (InvertFlags x)) + // result: (SETAE x) + for { + if v_0.Op != Op386InvertFlags { + break + } + x := v_0.Args[0] + v.reset(Op386SETAE) + v.AddArg(x) + return true + } + // match: (SETBE (FlagEQ)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETBE (FlagLT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETBE (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETBE (FlagGT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETBE (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_Op386SETEQ(v *Value) bool { + v_0 := v.Args[0] + // match: (SETEQ (InvertFlags x)) + // result: (SETEQ x) + for { + if v_0.Op != Op386InvertFlags { + break + } + x := v_0.Args[0] + v.reset(Op386SETEQ) + v.AddArg(x) + return true + } + // match: (SETEQ (FlagEQ)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETEQ (FlagLT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETEQ (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETEQ (FlagGT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETEQ (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_Op386SETG(v *Value) bool { + v_0 := v.Args[0] + // match: (SETG (InvertFlags x)) + // result: (SETL x) + for { + if v_0.Op != Op386InvertFlags { + break + } + x := v_0.Args[0] + v.reset(Op386SETL) + v.AddArg(x) + return true + } + // match: (SETG (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETG (FlagLT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETG (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETG (FlagGT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETG (FlagGT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValue386_Op386SETGE(v *Value) bool { + v_0 := v.Args[0] + // match: (SETGE (InvertFlags x)) + // result: (SETLE x) + for { + if v_0.Op != Op386InvertFlags { + break + } + x := v_0.Args[0] + v.reset(Op386SETLE) + v.AddArg(x) + return true + } + // match: (SETGE (FlagEQ)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETGE (FlagLT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETGE (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETGE (FlagGT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETGE (FlagGT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValue386_Op386SETL(v *Value) bool { + v_0 := v.Args[0] + // match: (SETL (InvertFlags x)) + // result: (SETG x) + for { + if v_0.Op != Op386InvertFlags { + break + } + x := v_0.Args[0] + v.reset(Op386SETG) + v.AddArg(x) + return true + } + // match: (SETL (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETL (FlagLT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETL (FlagLT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETL (FlagGT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETL (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_Op386SETLE(v *Value) bool { + v_0 := v.Args[0] + // match: (SETLE (InvertFlags x)) + // result: (SETGE x) + for { + if v_0.Op != Op386InvertFlags { + break + } + x := v_0.Args[0] + v.reset(Op386SETGE) + v.AddArg(x) + return true + } + // match: (SETLE (FlagEQ)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETLE (FlagLT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETLE (FlagLT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETLE (FlagGT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETLE (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_Op386SETNE(v *Value) bool { + v_0 := v.Args[0] + // match: (SETNE (InvertFlags x)) + // result: (SETNE x) + for { + if v_0.Op != Op386InvertFlags { + break + } + x := v_0.Args[0] + v.reset(Op386SETNE) + v.AddArg(x) + return true + } + // match: (SETNE (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != Op386FlagEQ { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETNE (FlagLT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagLT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETNE (FlagLT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagLT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETNE (FlagGT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagGT_ULT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETNE (FlagGT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != Op386FlagGT_UGT { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValue386_Op386SHLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SHLL x (MOVLconst [c])) + // result: (SHLLconst [c&31] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386SHLLconst) + v.AuxInt = int32ToAuxInt(c & 31) + v.AddArg(x) + return true + } + // match: (SHLL x (ANDLconst [31] y)) + // result: (SHLL x y) + for { + x := v_0 + if v_1.Op != Op386ANDLconst || auxIntToInt32(v_1.AuxInt) != 31 { + break + } + y := v_1.Args[0] + v.reset(Op386SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_Op386SHLLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SHLLconst x [0]) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValue386_Op386SHRB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SHRB x (MOVLconst [c])) + // cond: c&31 < 8 + // result: (SHRBconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c&31 < 8) { + break + } + v.reset(Op386SHRBconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SHRB _ (MOVLconst [c])) + // cond: c&31 >= 8 + // result: (MOVLconst [0]) + for { + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c&31 >= 8) { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_Op386SHRBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SHRBconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValue386_Op386SHRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SHRL x (MOVLconst [c])) + // result: (SHRLconst [c&31] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386SHRLconst) + v.AuxInt = int32ToAuxInt(c & 31) + v.AddArg(x) + return true + } + // match: (SHRL x (ANDLconst [31] y)) + // result: (SHRL x y) + for { + x := v_0 + if v_1.Op != Op386ANDLconst || auxIntToInt32(v_1.AuxInt) != 31 { + break + } + y := v_1.Args[0] + v.reset(Op386SHRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_Op386SHRLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SHRLconst x [0]) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValue386_Op386SHRW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SHRW x (MOVLconst [c])) + // cond: c&31 < 16 + // result: (SHRWconst [int16(c&31)] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c&31 < 16) { + break + } + v.reset(Op386SHRWconst) + v.AuxInt = int16ToAuxInt(int16(c & 31)) + v.AddArg(x) + return true + } + // match: (SHRW _ (MOVLconst [c])) + // cond: c&31 >= 16 + // result: (MOVLconst [0]) + for { + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c&31 >= 16) { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_Op386SHRWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SHRWconst x [0]) + // result: x + for { + if auxIntToInt16(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValue386_Op386SUBL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBL x (MOVLconst [c])) + // result: (SUBLconst x [c]) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386SUBLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SUBL (MOVLconst [c]) x) + // result: (NEGL (SUBLconst x [c])) + for { + if v_0.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(Op386NEGL) + v0 := b.NewValue0(v.Pos, Op386SUBLconst, v.Type) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUBL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (SUBLload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != Op386MOVLload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(Op386SUBLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (SUBL x x) + // result: (MOVLconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_Op386SUBLcarry(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBLcarry x (MOVLconst [c])) + // result: (SUBLconstcarry [c] x) + for { + x := v_0 + if v_1.Op != Op386MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386SUBLconstcarry) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_Op386SUBLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBLconst [c] x) + // cond: c==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c == 0) { + break + } + v.copyOf(x) + return true + } + // match: (SUBLconst [c] x) + // result: (ADDLconst [-c] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + v.reset(Op386ADDLconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } +} +func rewriteValue386_Op386SUBLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (SUBLload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SUBLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386SUBLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBLload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (SUBLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386SUBLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386SUBLmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (SUBLmodify [off1] {sym} (ADDLconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SUBLmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386SUBLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SUBLmodify [off1] {sym1} (LEAL [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (SUBLmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386SUBLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValue386_Op386SUBSD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBSD x l:(MOVSDload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (SUBSDload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != Op386MOVSDload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(Op386SUBSDload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386SUBSDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (SUBSDload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SUBSDload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386SUBSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBSDload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (SUBSDload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386SUBSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386SUBSS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBSS x l:(MOVSSload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (SUBSSload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != Op386MOVSSload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(Op386SUBSSload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValue386_Op386SUBSSload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (SUBSSload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SUBSSload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386SUBSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBSSload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (SUBSSload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386SUBSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386XORL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XORL x (MOVLconst [c])) + // result: (XORLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != Op386MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(Op386XORLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (XORL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (XORLload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != Op386MOVLload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(Op386XORLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (XORL x x) + // result: (MOVLconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_Op386XORLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORLconst [c] (XORLconst [d] x)) + // result: (XORLconst [c ^ d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386XORLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(Op386XORLconst) + v.AuxInt = int32ToAuxInt(c ^ d) + v.AddArg(x) + return true + } + // match: (XORLconst [c] x) + // cond: c==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c == 0) { + break + } + v.copyOf(x) + return true + } + // match: (XORLconst [c] (MOVLconst [d])) + // result: (MOVLconst [c^d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != Op386MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(c ^ d) + return true + } + return false +} +func rewriteValue386_Op386XORLconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (XORLconstmodify [valoff1] {sym} (ADDLconst [off2] base) mem) + // cond: valoff1.canAdd32(off2) + // result: (XORLconstmodify [valoff1.addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(valoff1.canAdd32(off2)) { + break + } + v.reset(Op386XORLconstmodify) + v.AuxInt = valAndOffToAuxInt(valoff1.addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (XORLconstmodify [valoff1] {sym1} (LEAL [off2] {sym2} base) mem) + // cond: valoff1.canAdd32(off2) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (XORLconstmodify [valoff1.addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(valoff1.canAdd32(off2) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386XORLconstmodify) + v.AuxInt = valAndOffToAuxInt(valoff1.addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValue386_Op386XORLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (XORLload [off1] {sym} val (ADDLconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (XORLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386XORLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (XORLload [off1] {sym1} val (LEAL [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (XORLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386XORLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValue386_Op386XORLmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (XORLmodify [off1] {sym} (ADDLconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (XORLmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != Op386ADDLconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(Op386XORLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (XORLmodify [off1] {sym1} (LEAL [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared) + // result: (XORLmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != Op386LEAL { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(Op386XORLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValue386_OpAddr(v *Value) bool { + v_0 := v.Args[0] + // match: (Addr {sym} base) + // result: (LEAL {sym} base) + for { + sym := auxToSym(v.Aux) + base := v_0 + v.reset(Op386LEAL) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } +} +func rewriteValue386_OpBswap16(v *Value) bool { + v_0 := v.Args[0] + // match: (Bswap16 x) + // result: (ROLWconst [8] x) + for { + x := v_0 + v.reset(Op386ROLWconst) + v.AuxInt = int16ToAuxInt(8) + v.AddArg(x) + return true + } +} +func rewriteValue386_OpConst16(v *Value) bool { + // match: (Const16 [c]) + // result: (MOVLconst [int32(c)]) + for { + c := auxIntToInt16(v.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + return true + } +} +func rewriteValue386_OpConst8(v *Value) bool { + // match: (Const8 [c]) + // result: (MOVLconst [int32(c)]) + for { + c := auxIntToInt8(v.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + return true + } +} +func rewriteValue386_OpConstBool(v *Value) bool { + // match: (ConstBool [c]) + // result: (MOVLconst [b2i32(c)]) + for { + c := auxIntToBool(v.AuxInt) + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(b2i32(c)) + return true + } +} +func rewriteValue386_OpConstNil(v *Value) bool { + // match: (ConstNil) + // result: (MOVLconst [0]) + for { + v.reset(Op386MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } +} +func rewriteValue386_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz16 x) + // result: (BSFL (ORLconst [0x10000] x)) + for { + x := v_0 + v.reset(Op386BSFL) + v0 := b.NewValue0(v.Pos, Op386ORLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0x10000) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz8 x) + // result: (BSFL (ORLconst [0x100] x)) + for { + x := v_0 + v.reset(Op386BSFL) + v0 := b.NewValue0(v.Pos, Op386ORLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0x100) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (DIVW (SignExt8to16 x) (SignExt8to16 y)) + for { + x := v_0 + y := v_1 + v.reset(Op386DIVW) + v0 := b.NewValue0(v.Pos, OpSignExt8to16, typ.Int16) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to16, typ.Int16) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValue386_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (DIVWU (ZeroExt8to16 x) (ZeroExt8to16 y)) + for { + x := v_0 + y := v_1 + v.reset(Op386DIVWU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to16, typ.UInt16) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to16, typ.UInt16) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValue386_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq16 x y) + // result: (SETEQ (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETEQ) + v0 := b.NewValue0(v.Pos, Op386CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32 x y) + // result: (SETEQ (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETEQ) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpEq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32F x y) + // result: (SETEQF (UCOMISS x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETEQF) + v0 := b.NewValue0(v.Pos, Op386UCOMISS, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpEq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64F x y) + // result: (SETEQF (UCOMISD x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETEQF) + v0 := b.NewValue0(v.Pos, Op386UCOMISD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq8 x y) + // result: (SETEQ (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETEQ) + v0 := b.NewValue0(v.Pos, Op386CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (EqB x y) + // result: (SETEQ (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETEQ) + v0 := b.NewValue0(v.Pos, Op386CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (EqPtr x y) + // result: (SETEQ (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETEQ) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpIsInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (IsInBounds idx len) + // result: (SETB (CMPL idx len)) + for { + idx := v_0 + len := v_1 + v.reset(Op386SETB) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpIsNonNil(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (IsNonNil p) + // result: (SETNE (TESTL p p)) + for { + p := v_0 + v.reset(Op386SETNE) + v0 := b.NewValue0(v.Pos, Op386TESTL, types.TypeFlags) + v0.AddArg2(p, p) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpIsSliceInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (IsSliceInBounds idx len) + // result: (SETBE (CMPL idx len)) + for { + idx := v_0 + len := v_1 + v.reset(Op386SETBE) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq16 x y) + // result: (SETLE (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETLE) + v0 := b.NewValue0(v.Pos, Op386CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq16U x y) + // result: (SETBE (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETBE) + v0 := b.NewValue0(v.Pos, Op386CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32 x y) + // result: (SETLE (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETLE) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32F x y) + // result: (SETGEF (UCOMISS y x)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETGEF) + v0 := b.NewValue0(v.Pos, Op386UCOMISS, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32U x y) + // result: (SETBE (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETBE) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64F x y) + // result: (SETGEF (UCOMISD y x)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETGEF) + v0 := b.NewValue0(v.Pos, Op386UCOMISD, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq8 x y) + // result: (SETLE (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETLE) + v0 := b.NewValue0(v.Pos, Op386CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq8U x y) + // result: (SETBE (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETBE) + v0 := b.NewValue0(v.Pos, Op386CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less16 x y) + // result: (SETL (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETL) + v0 := b.NewValue0(v.Pos, Op386CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less16U x y) + // result: (SETB (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETB) + v0 := b.NewValue0(v.Pos, Op386CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32 x y) + // result: (SETL (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETL) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLess32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32F x y) + // result: (SETGF (UCOMISS y x)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETGF) + v0 := b.NewValue0(v.Pos, Op386UCOMISS, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32U x y) + // result: (SETB (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETB) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLess64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64F x y) + // result: (SETGF (UCOMISD y x)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETGF) + v0 := b.NewValue0(v.Pos, Op386UCOMISD, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less8 x y) + // result: (SETL (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETL) + v0 := b.NewValue0(v.Pos, Op386CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less8U x y) + // result: (SETB (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETB) + v0 := b.NewValue0(v.Pos, Op386CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Load ptr mem) + // cond: (is32BitInt(t) || isPtr(t)) + // result: (MOVLload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) || isPtr(t)) { + break + } + v.reset(Op386MOVLload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is16BitInt(t) + // result: (MOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t)) { + break + } + v.reset(Op386MOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (t.IsBoolean() || is8BitInt(t)) + // result: (MOVBload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsBoolean() || is8BitInt(t)) { + break + } + v.reset(Op386MOVBload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (MOVSSload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(Op386MOVSSload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (MOVSDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(Op386MOVSDload) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValue386_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (LEAL {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(Op386LEAL) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (LEAL {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(Op386LEAL) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValue386_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPWconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHLL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPLconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHLL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Lsh16x64 x (Const64 [c])) + // cond: uint64(c) < 16 + // result: (SHLLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 16) { + break + } + v.reset(Op386SHLLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Lsh16x64 _ (Const64 [c])) + // cond: uint64(c) >= 16 + // result: (Const16 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 16) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPBconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHLL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPWconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHLL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPLconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHLL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Lsh32x64 x (Const64 [c])) + // cond: uint64(c) < 32 + // result: (SHLLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 32) { + break + } + v.reset(Op386SHLLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Lsh32x64 _ (Const64 [c])) + // cond: uint64(c) >= 32 + // result: (Const32 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPBconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHLL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPWconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHLL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPLconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHLL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Lsh8x64 x (Const64 [c])) + // cond: uint64(c) < 8 + // result: (SHLLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 8) { + break + } + v.reset(Op386SHLLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Lsh8x64 _ (Const64 [c])) + // cond: uint64(c) >= 8 + // result: (Const8 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 8) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPBconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHLL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (MODW (SignExt8to16 x) (SignExt8to16 y)) + for { + x := v_0 + y := v_1 + v.reset(Op386MODW) + v0 := b.NewValue0(v.Pos, OpSignExt8to16, typ.Int16) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to16, typ.Int16) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValue386_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (MODWU (ZeroExt8to16 x) (ZeroExt8to16 y)) + for { + x := v_0 + y := v_1 + v.reset(Op386MODWU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to16, typ.UInt16) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to16, typ.UInt16) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValue386_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (MOVBstore dst (MOVBload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(Op386MOVBstore) + v0 := b.NewValue0(v.Pos, Op386MOVBload, typ.UInt8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (MOVWstore dst (MOVWload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(Op386MOVWstore) + v0 := b.NewValue0(v.Pos, Op386MOVWload, typ.UInt16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [4] dst src mem) + // result: (MOVLstore dst (MOVLload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(Op386MOVLstore) + v0 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [3] dst src mem) + // result: (MOVBstore [2] dst (MOVBload [2] src mem) (MOVWstore dst (MOVWload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(Op386MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, Op386MOVBload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, Op386MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, Op386MOVWload, typ.UInt16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [5] dst src mem) + // result: (MOVBstore [4] dst (MOVBload [4] src mem) (MOVLstore dst (MOVLload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(Op386MOVBstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, Op386MOVBload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, Op386MOVLstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [6] dst src mem) + // result: (MOVWstore [4] dst (MOVWload [4] src mem) (MOVLstore dst (MOVLload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(Op386MOVWstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, Op386MOVWload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, Op386MOVLstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [7] dst src mem) + // result: (MOVLstore [3] dst (MOVLload [3] src mem) (MOVLstore dst (MOVLload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(Op386MOVLstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, Op386MOVLstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [8] dst src mem) + // result: (MOVLstore [4] dst (MOVLload [4] src mem) (MOVLstore dst (MOVLload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(Op386MOVLstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, Op386MOVLstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 8 && s%4 != 0 + // result: (Move [s-s%4] (ADDLconst dst [int32(s%4)]) (ADDLconst src [int32(s%4)]) (MOVLstore dst (MOVLload src mem) mem)) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 8 && s%4 != 0) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(s - s%4) + v0 := b.NewValue0(v.Pos, Op386ADDLconst, dst.Type) + v0.AuxInt = int32ToAuxInt(int32(s % 4)) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, Op386ADDLconst, src.Type) + v1.AuxInt = int32ToAuxInt(int32(s % 4)) + v1.AddArg(src) + v2 := b.NewValue0(v.Pos, Op386MOVLstore, types.TypeMem) + v3 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32) + v3.AddArg2(src, mem) + v2.AddArg3(dst, v3, mem) + v.AddArg3(v0, v1, v2) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 8 && s <= 4*128 && s%4 == 0 && logLargeCopy(v, s) + // result: (DUFFCOPY [10*(128-s/4)] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 8 && s <= 4*128 && s%4 == 0 && logLargeCopy(v, s)) { + break + } + v.reset(Op386DUFFCOPY) + v.AuxInt = int64ToAuxInt(10 * (128 - s/4)) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 4*128 && s%4 == 0 && logLargeCopy(v, s) + // result: (REPMOVSL dst src (MOVLconst [int32(s/4)]) mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 4*128 && s%4 == 0 && logLargeCopy(v, s)) { + break + } + v.reset(Op386REPMOVSL) + v0 := b.NewValue0(v.Pos, Op386MOVLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(s / 4)) + v.AddArg4(dst, src, v0, mem) + return true + } + return false +} +func rewriteValue386_OpNeg32F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neg32F x) + // result: (PXOR x (MOVSSconst [float32(math.Copysign(0, -1))])) + for { + x := v_0 + v.reset(Op386PXOR) + v0 := b.NewValue0(v.Pos, Op386MOVSSconst, typ.Float32) + v0.AuxInt = float32ToAuxInt(float32(math.Copysign(0, -1))) + v.AddArg2(x, v0) + return true + } +} +func rewriteValue386_OpNeg64F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neg64F x) + // result: (PXOR x (MOVSDconst [math.Copysign(0, -1)])) + for { + x := v_0 + v.reset(Op386PXOR) + v0 := b.NewValue0(v.Pos, Op386MOVSDconst, typ.Float64) + v0.AuxInt = float64ToAuxInt(math.Copysign(0, -1)) + v.AddArg2(x, v0) + return true + } +} +func rewriteValue386_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq16 x y) + // result: (SETNE (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETNE) + v0 := b.NewValue0(v.Pos, Op386CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32 x y) + // result: (SETNE (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETNE) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpNeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32F x y) + // result: (SETNEF (UCOMISS x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETNEF) + v0 := b.NewValue0(v.Pos, Op386UCOMISS, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpNeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64F x y) + // result: (SETNEF (UCOMISD x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETNEF) + v0 := b.NewValue0(v.Pos, Op386UCOMISD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq8 x y) + // result: (SETNE (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETNE) + v0 := b.NewValue0(v.Pos, Op386CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpNeqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (NeqB x y) + // result: (SETNE (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETNE) + v0 := b.NewValue0(v.Pos, Op386CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (NeqPtr x y) + // result: (SETNE (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(Op386SETNE) + v0 := b.NewValue0(v.Pos, Op386CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpNot(v *Value) bool { + v_0 := v.Args[0] + // match: (Not x) + // result: (XORLconst [1] x) + for { + x := v_0 + v.reset(Op386XORLconst) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValue386_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + // match: (OffPtr [off] ptr) + // result: (ADDLconst [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + v.reset(Op386ADDLconst) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } +} +func rewriteValue386_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRW x y) (SBBLcarrymask (CMPWconst y [16]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(16) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SHRW x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHRW) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRW x y) (SBBLcarrymask (CMPLconst y [16]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(16) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SHRW x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHRW) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Rsh16Ux64 x (Const64 [c])) + // cond: uint64(c) < 16 + // result: (SHRWconst x [int16(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 16) { + break + } + v.reset(Op386SHRWconst) + v.AuxInt = int16ToAuxInt(int16(c)) + v.AddArg(x) + return true + } + // match: (Rsh16Ux64 _ (Const64 [c])) + // cond: uint64(c) >= 16 + // result: (Const16 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 16) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRW x y) (SBBLcarrymask (CMPBconst y [16]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(16) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SHRW x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHRW) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16x16 x y) + // cond: !shiftIsBounded(v) + // result: (SARW x (ORL y (NOTL (SBBLcarrymask (CMPWconst y [16]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386SARW) + v.Type = t + v0 := b.NewValue0(v.Pos, Op386ORL, y.Type) + v1 := b.NewValue0(v.Pos, Op386NOTL, y.Type) + v2 := b.NewValue0(v.Pos, Op386SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, Op386CMPWconst, types.TypeFlags) + v3.AuxInt = int16ToAuxInt(16) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SARW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SARW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16x32 x y) + // cond: !shiftIsBounded(v) + // result: (SARW x (ORL y (NOTL (SBBLcarrymask (CMPLconst y [16]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386SARW) + v.Type = t + v0 := b.NewValue0(v.Pos, Op386ORL, y.Type) + v1 := b.NewValue0(v.Pos, Op386NOTL, y.Type) + v2 := b.NewValue0(v.Pos, Op386SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(16) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SARW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SARW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Rsh16x64 x (Const64 [c])) + // cond: uint64(c) < 16 + // result: (SARWconst x [int16(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 16) { + break + } + v.reset(Op386SARWconst) + v.AuxInt = int16ToAuxInt(int16(c)) + v.AddArg(x) + return true + } + // match: (Rsh16x64 x (Const64 [c])) + // cond: uint64(c) >= 16 + // result: (SARWconst x [15]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 16) { + break + } + v.reset(Op386SARWconst) + v.AuxInt = int16ToAuxInt(15) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16x8 x y) + // cond: !shiftIsBounded(v) + // result: (SARW x (ORL y (NOTL (SBBLcarrymask (CMPBconst y [16]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386SARW) + v.Type = t + v0 := b.NewValue0(v.Pos, Op386ORL, y.Type) + v1 := b.NewValue0(v.Pos, Op386NOTL, y.Type) + v2 := b.NewValue0(v.Pos, Op386SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, Op386CMPBconst, types.TypeFlags) + v3.AuxInt = int8ToAuxInt(16) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SARW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SARW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRL x y) (SBBLcarrymask (CMPWconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SHRL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHRL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRL x y) (SBBLcarrymask (CMPLconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SHRL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHRL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Rsh32Ux64 x (Const64 [c])) + // cond: uint64(c) < 32 + // result: (SHRLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 32) { + break + } + v.reset(Op386SHRLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Rsh32Ux64 _ (Const64 [c])) + // cond: uint64(c) >= 32 + // result: (Const32 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRL x y) (SBBLcarrymask (CMPBconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SHRL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHRL) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x16 x y) + // cond: !shiftIsBounded(v) + // result: (SARL x (ORL y (NOTL (SBBLcarrymask (CMPWconst y [32]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386SARL) + v.Type = t + v0 := b.NewValue0(v.Pos, Op386ORL, y.Type) + v1 := b.NewValue0(v.Pos, Op386NOTL, y.Type) + v2 := b.NewValue0(v.Pos, Op386SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, Op386CMPWconst, types.TypeFlags) + v3.AuxInt = int16ToAuxInt(32) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SARL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SARL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x32 x y) + // cond: !shiftIsBounded(v) + // result: (SARL x (ORL y (NOTL (SBBLcarrymask (CMPLconst y [32]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386SARL) + v.Type = t + v0 := b.NewValue0(v.Pos, Op386ORL, y.Type) + v1 := b.NewValue0(v.Pos, Op386NOTL, y.Type) + v2 := b.NewValue0(v.Pos, Op386SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SARL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SARL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Rsh32x64 x (Const64 [c])) + // cond: uint64(c) < 32 + // result: (SARLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 32) { + break + } + v.reset(Op386SARLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Rsh32x64 x (Const64 [c])) + // cond: uint64(c) >= 32 + // result: (SARLconst x [31]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(Op386SARLconst) + v.AuxInt = int32ToAuxInt(31) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x8 x y) + // cond: !shiftIsBounded(v) + // result: (SARL x (ORL y (NOTL (SBBLcarrymask (CMPBconst y [32]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386SARL) + v.Type = t + v0 := b.NewValue0(v.Pos, Op386ORL, y.Type) + v1 := b.NewValue0(v.Pos, Op386NOTL, y.Type) + v2 := b.NewValue0(v.Pos, Op386SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, Op386CMPBconst, types.TypeFlags) + v3.AuxInt = int8ToAuxInt(32) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SARL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SARL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRB x y) (SBBLcarrymask (CMPWconst y [8]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHRB, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(8) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SHRB x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHRB) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRB x y) (SBBLcarrymask (CMPLconst y [8]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHRB, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(8) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SHRB x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHRB) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Rsh8Ux64 x (Const64 [c])) + // cond: uint64(c) < 8 + // result: (SHRBconst x [int8(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 8) { + break + } + v.reset(Op386SHRBconst) + v.AuxInt = int8ToAuxInt(int8(c)) + v.AddArg(x) + return true + } + // match: (Rsh8Ux64 _ (Const64 [c])) + // cond: uint64(c) >= 8 + // result: (Const8 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 8) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + return false +} +func rewriteValue386_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRB x y) (SBBLcarrymask (CMPBconst y [8]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386ANDL) + v0 := b.NewValue0(v.Pos, Op386SHRB, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, Op386CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(8) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SHRB x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SHRB) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x16 x y) + // cond: !shiftIsBounded(v) + // result: (SARB x (ORL y (NOTL (SBBLcarrymask (CMPWconst y [8]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386SARB) + v.Type = t + v0 := b.NewValue0(v.Pos, Op386ORL, y.Type) + v1 := b.NewValue0(v.Pos, Op386NOTL, y.Type) + v2 := b.NewValue0(v.Pos, Op386SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, Op386CMPWconst, types.TypeFlags) + v3.AuxInt = int16ToAuxInt(8) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SARB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SARB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x32 x y) + // cond: !shiftIsBounded(v) + // result: (SARB x (ORL y (NOTL (SBBLcarrymask (CMPLconst y [8]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386SARB) + v.Type = t + v0 := b.NewValue0(v.Pos, Op386ORL, y.Type) + v1 := b.NewValue0(v.Pos, Op386NOTL, y.Type) + v2 := b.NewValue0(v.Pos, Op386SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(8) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SARB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SARB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Rsh8x64 x (Const64 [c])) + // cond: uint64(c) < 8 + // result: (SARBconst x [int8(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 8) { + break + } + v.reset(Op386SARBconst) + v.AuxInt = int8ToAuxInt(int8(c)) + v.AddArg(x) + return true + } + // match: (Rsh8x64 x (Const64 [c])) + // cond: uint64(c) >= 8 + // result: (SARBconst x [7]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 8) { + break + } + v.reset(Op386SARBconst) + v.AuxInt = int8ToAuxInt(7) + v.AddArg(x) + return true + } + return false +} +func rewriteValue386_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x8 x y) + // cond: !shiftIsBounded(v) + // result: (SARB x (ORL y (NOTL (SBBLcarrymask (CMPBconst y [8]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(Op386SARB) + v.Type = t + v0 := b.NewValue0(v.Pos, Op386ORL, y.Type) + v1 := b.NewValue0(v.Pos, Op386NOTL, y.Type) + v2 := b.NewValue0(v.Pos, Op386SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, Op386CMPBconst, types.TypeFlags) + v3.AuxInt = int8ToAuxInt(8) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SARB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(Op386SARB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValue386_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select0 (Mul32uover x y)) + // result: (Select0 (MULLU x y)) + for { + if v_0.Op != OpMul32uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpSelect0) + v.Type = typ.UInt32 + v0 := b.NewValue0(v.Pos, Op386MULLU, types.NewTuple(typ.UInt32, types.TypeFlags)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + return false +} +func rewriteValue386_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select1 (Mul32uover x y)) + // result: (SETO (Select1 (MULLU x y))) + for { + if v_0.Op != OpMul32uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(Op386SETO) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v.Pos, Op386MULLU, types.NewTuple(typ.UInt32, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValue386_OpSignmask(v *Value) bool { + v_0 := v.Args[0] + // match: (Signmask x) + // result: (SARLconst x [31]) + for { + x := v_0 + v.reset(Op386SARLconst) + v.AuxInt = int32ToAuxInt(31) + v.AddArg(x) + return true + } +} +func rewriteValue386_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Slicemask x) + // result: (SARLconst (NEGL x) [31]) + for { + t := v.Type + x := v_0 + v.reset(Op386SARLconst) + v.AuxInt = int32ToAuxInt(31) + v0 := b.NewValue0(v.Pos, Op386NEGL, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValue386_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && t.IsFloat() + // result: (MOVSDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && t.IsFloat()) { + break + } + v.reset(Op386MOVSDstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && t.IsFloat() + // result: (MOVSSstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && t.IsFloat()) { + break + } + v.reset(Op386MOVSSstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && !t.IsFloat() + // result: (MOVLstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && !t.IsFloat()) { + break + } + v.reset(Op386MOVLstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (MOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(Op386MOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (MOVBstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(Op386MOVBstore) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValue386_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] destptr mem) + // result: (MOVBstoreconst [0] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + destptr := v_0 + mem := v_1 + v.reset(Op386MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(0) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [2] destptr mem) + // result: (MOVWstoreconst [0] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + destptr := v_0 + mem := v_1 + v.reset(Op386MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(0) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [4] destptr mem) + // result: (MOVLstoreconst [0] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + destptr := v_0 + mem := v_1 + v.reset(Op386MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(0) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [3] destptr mem) + // result: (MOVBstoreconst [makeValAndOff(0,2)] destptr (MOVWstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + destptr := v_0 + mem := v_1 + v.reset(Op386MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 2)) + v0 := b.NewValue0(v.Pos, Op386MOVWstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [5] destptr mem) + // result: (MOVBstoreconst [makeValAndOff(0,4)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + destptr := v_0 + mem := v_1 + v.reset(Op386MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 4)) + v0 := b.NewValue0(v.Pos, Op386MOVLstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [6] destptr mem) + // result: (MOVWstoreconst [makeValAndOff(0,4)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + destptr := v_0 + mem := v_1 + v.reset(Op386MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 4)) + v0 := b.NewValue0(v.Pos, Op386MOVLstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [7] destptr mem) + // result: (MOVLstoreconst [makeValAndOff(0,3)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + destptr := v_0 + mem := v_1 + v.reset(Op386MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 3)) + v0 := b.NewValue0(v.Pos, Op386MOVLstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [s] destptr mem) + // cond: s%4 != 0 && s > 4 + // result: (Zero [s-s%4] (ADDLconst destptr [int32(s%4)]) (MOVLstoreconst [0] destptr mem)) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s%4 != 0 && s > 4) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(s - s%4) + v0 := b.NewValue0(v.Pos, Op386ADDLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(s % 4)) + v0.AddArg(destptr) + v1 := b.NewValue0(v.Pos, Op386MOVLstoreconst, types.TypeMem) + v1.AuxInt = valAndOffToAuxInt(0) + v1.AddArg2(destptr, mem) + v.AddArg2(v0, v1) + return true + } + // match: (Zero [8] destptr mem) + // result: (MOVLstoreconst [makeValAndOff(0,4)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + destptr := v_0 + mem := v_1 + v.reset(Op386MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 4)) + v0 := b.NewValue0(v.Pos, Op386MOVLstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [12] destptr mem) + // result: (MOVLstoreconst [makeValAndOff(0,8)] destptr (MOVLstoreconst [makeValAndOff(0,4)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem))) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + destptr := v_0 + mem := v_1 + v.reset(Op386MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 8)) + v0 := b.NewValue0(v.Pos, Op386MOVLstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 4)) + v1 := b.NewValue0(v.Pos, Op386MOVLstoreconst, types.TypeMem) + v1.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v1.AddArg2(destptr, mem) + v0.AddArg2(destptr, v1) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [16] destptr mem) + // result: (MOVLstoreconst [makeValAndOff(0,12)] destptr (MOVLstoreconst [makeValAndOff(0,8)] destptr (MOVLstoreconst [makeValAndOff(0,4)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)))) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + destptr := v_0 + mem := v_1 + v.reset(Op386MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 12)) + v0 := b.NewValue0(v.Pos, Op386MOVLstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 8)) + v1 := b.NewValue0(v.Pos, Op386MOVLstoreconst, types.TypeMem) + v1.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 4)) + v2 := b.NewValue0(v.Pos, Op386MOVLstoreconst, types.TypeMem) + v2.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v2.AddArg2(destptr, mem) + v1.AddArg2(destptr, v2) + v0.AddArg2(destptr, v1) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [s] destptr mem) + // cond: s > 16 && s <= 4*128 && s%4 == 0 + // result: (DUFFZERO [1*(128-s/4)] destptr (MOVLconst [0]) mem) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s > 16 && s <= 4*128 && s%4 == 0) { + break + } + v.reset(Op386DUFFZERO) + v.AuxInt = int64ToAuxInt(1 * (128 - s/4)) + v0 := b.NewValue0(v.Pos, Op386MOVLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(destptr, v0, mem) + return true + } + // match: (Zero [s] destptr mem) + // cond: s > 4*128 && s%4 == 0 + // result: (REPSTOSL destptr (MOVLconst [int32(s/4)]) (MOVLconst [0]) mem) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s > 4*128 && s%4 == 0) { + break + } + v.reset(Op386REPSTOSL) + v0 := b.NewValue0(v.Pos, Op386MOVLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(s / 4)) + v1 := b.NewValue0(v.Pos, Op386MOVLconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0) + v.AddArg4(destptr, v0, v1, mem) + return true + } + return false +} +func rewriteValue386_OpZeromask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Zeromask x) + // result: (XORLconst [-1] (SBBLcarrymask (CMPLconst x [1]))) + for { + t := v.Type + x := v_0 + v.reset(Op386XORLconst) + v.AuxInt = int32ToAuxInt(-1) + v0 := b.NewValue0(v.Pos, Op386SBBLcarrymask, t) + v1 := b.NewValue0(v.Pos, Op386CMPLconst, types.TypeFlags) + v1.AuxInt = int32ToAuxInt(1) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteBlock386(b *Block) bool { + switch b.Kind { + case Block386EQ: + // match: (EQ (InvertFlags cmp) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == Op386InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386EQ, cmp) + return true + } + // match: (EQ (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (EQ (FlagLT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagLT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (FlagLT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagLT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (FlagGT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagGT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (FlagGT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagGT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case Block386GE: + // match: (GE (InvertFlags cmp) yes no) + // result: (LE cmp yes no) + for b.Controls[0].Op == Op386InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386LE, cmp) + return true + } + // match: (GE (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (GE (FlagLT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagLT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GE (FlagLT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagLT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GE (FlagGT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagGT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (GE (FlagGT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagGT_UGT { + b.Reset(BlockFirst) + return true + } + case Block386GT: + // match: (GT (InvertFlags cmp) yes no) + // result: (LT cmp yes no) + for b.Controls[0].Op == Op386InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386LT, cmp) + return true + } + // match: (GT (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GT (FlagLT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagLT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GT (FlagLT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagLT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GT (FlagGT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagGT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (GT (FlagGT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagGT_UGT { + b.Reset(BlockFirst) + return true + } + case BlockIf: + // match: (If (SETL cmp) yes no) + // result: (LT cmp yes no) + for b.Controls[0].Op == Op386SETL { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386LT, cmp) + return true + } + // match: (If (SETLE cmp) yes no) + // result: (LE cmp yes no) + for b.Controls[0].Op == Op386SETLE { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386LE, cmp) + return true + } + // match: (If (SETG cmp) yes no) + // result: (GT cmp yes no) + for b.Controls[0].Op == Op386SETG { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386GT, cmp) + return true + } + // match: (If (SETGE cmp) yes no) + // result: (GE cmp yes no) + for b.Controls[0].Op == Op386SETGE { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386GE, cmp) + return true + } + // match: (If (SETEQ cmp) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == Op386SETEQ { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386EQ, cmp) + return true + } + // match: (If (SETNE cmp) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == Op386SETNE { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386NE, cmp) + return true + } + // match: (If (SETB cmp) yes no) + // result: (ULT cmp yes no) + for b.Controls[0].Op == Op386SETB { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386ULT, cmp) + return true + } + // match: (If (SETBE cmp) yes no) + // result: (ULE cmp yes no) + for b.Controls[0].Op == Op386SETBE { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386ULE, cmp) + return true + } + // match: (If (SETA cmp) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == Op386SETA { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386UGT, cmp) + return true + } + // match: (If (SETAE cmp) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == Op386SETAE { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386UGE, cmp) + return true + } + // match: (If (SETO cmp) yes no) + // result: (OS cmp yes no) + for b.Controls[0].Op == Op386SETO { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386OS, cmp) + return true + } + // match: (If (SETGF cmp) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == Op386SETGF { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386UGT, cmp) + return true + } + // match: (If (SETGEF cmp) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == Op386SETGEF { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386UGE, cmp) + return true + } + // match: (If (SETEQF cmp) yes no) + // result: (EQF cmp yes no) + for b.Controls[0].Op == Op386SETEQF { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386EQF, cmp) + return true + } + // match: (If (SETNEF cmp) yes no) + // result: (NEF cmp yes no) + for b.Controls[0].Op == Op386SETNEF { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386NEF, cmp) + return true + } + // match: (If cond yes no) + // result: (NE (TESTB cond cond) yes no) + for { + cond := b.Controls[0] + v0 := b.NewValue0(cond.Pos, Op386TESTB, types.TypeFlags) + v0.AddArg2(cond, cond) + b.resetWithControl(Block386NE, v0) + return true + } + case Block386LE: + // match: (LE (InvertFlags cmp) yes no) + // result: (GE cmp yes no) + for b.Controls[0].Op == Op386InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386GE, cmp) + return true + } + // match: (LE (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (LE (FlagLT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagLT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (LE (FlagLT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagLT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (LE (FlagGT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagGT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LE (FlagGT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagGT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case Block386LT: + // match: (LT (InvertFlags cmp) yes no) + // result: (GT cmp yes no) + for b.Controls[0].Op == Op386InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386GT, cmp) + return true + } + // match: (LT (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LT (FlagLT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagLT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (LT (FlagLT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagLT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (LT (FlagGT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagGT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LT (FlagGT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagGT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case Block386NE: + // match: (NE (TESTB (SETL cmp) (SETL cmp)) yes no) + // result: (LT cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETL { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETL || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386LT, cmp) + return true + } + // match: (NE (TESTB (SETLE cmp) (SETLE cmp)) yes no) + // result: (LE cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETLE { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETLE || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386LE, cmp) + return true + } + // match: (NE (TESTB (SETG cmp) (SETG cmp)) yes no) + // result: (GT cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETG { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETG || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386GT, cmp) + return true + } + // match: (NE (TESTB (SETGE cmp) (SETGE cmp)) yes no) + // result: (GE cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETGE { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETGE || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386GE, cmp) + return true + } + // match: (NE (TESTB (SETEQ cmp) (SETEQ cmp)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETEQ { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETEQ || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386EQ, cmp) + return true + } + // match: (NE (TESTB (SETNE cmp) (SETNE cmp)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETNE { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETNE || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386NE, cmp) + return true + } + // match: (NE (TESTB (SETB cmp) (SETB cmp)) yes no) + // result: (ULT cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETB { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETB || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386ULT, cmp) + return true + } + // match: (NE (TESTB (SETBE cmp) (SETBE cmp)) yes no) + // result: (ULE cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETBE { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETBE || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386ULE, cmp) + return true + } + // match: (NE (TESTB (SETA cmp) (SETA cmp)) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETA { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETA || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386UGT, cmp) + return true + } + // match: (NE (TESTB (SETAE cmp) (SETAE cmp)) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETAE { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETAE || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386UGE, cmp) + return true + } + // match: (NE (TESTB (SETO cmp) (SETO cmp)) yes no) + // result: (OS cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETO { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETO || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386OS, cmp) + return true + } + // match: (NE (TESTB (SETGF cmp) (SETGF cmp)) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETGF { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETGF || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386UGT, cmp) + return true + } + // match: (NE (TESTB (SETGEF cmp) (SETGEF cmp)) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETGEF { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETGEF || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386UGE, cmp) + return true + } + // match: (NE (TESTB (SETEQF cmp) (SETEQF cmp)) yes no) + // result: (EQF cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETEQF { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETEQF || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386EQF, cmp) + return true + } + // match: (NE (TESTB (SETNEF cmp) (SETNEF cmp)) yes no) + // result: (NEF cmp yes no) + for b.Controls[0].Op == Op386TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != Op386SETNEF { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != Op386SETNEF || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(Block386NEF, cmp) + return true + } + // match: (NE (InvertFlags cmp) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == Op386InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386NE, cmp) + return true + } + // match: (NE (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (NE (FlagLT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagLT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (NE (FlagLT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagLT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (NE (FlagGT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagGT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (NE (FlagGT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagGT_UGT { + b.Reset(BlockFirst) + return true + } + case Block386UGE: + // match: (UGE (InvertFlags cmp) yes no) + // result: (ULE cmp yes no) + for b.Controls[0].Op == Op386InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386ULE, cmp) + return true + } + // match: (UGE (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (UGE (FlagLT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagLT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGE (FlagLT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagLT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (UGE (FlagGT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagGT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGE (FlagGT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagGT_UGT { + b.Reset(BlockFirst) + return true + } + case Block386UGT: + // match: (UGT (InvertFlags cmp) yes no) + // result: (ULT cmp yes no) + for b.Controls[0].Op == Op386InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386ULT, cmp) + return true + } + // match: (UGT (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGT (FlagLT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagLT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGT (FlagLT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagLT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (UGT (FlagGT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagGT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGT (FlagGT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagGT_UGT { + b.Reset(BlockFirst) + return true + } + case Block386ULE: + // match: (ULE (InvertFlags cmp) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == Op386InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386UGE, cmp) + return true + } + // match: (ULE (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (ULE (FlagLT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagLT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (ULE (FlagLT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagLT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULE (FlagGT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagGT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (ULE (FlagGT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagGT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case Block386ULT: + // match: (ULT (InvertFlags cmp) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == Op386InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(Block386UGT, cmp) + return true + } + // match: (ULT (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULT (FlagLT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagLT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (ULT (FlagLT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagLT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULT (FlagGT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == Op386FlagGT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (ULT (FlagGT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == Op386FlagGT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewrite386splitload.go b/go/src/cmd/compile/internal/ssa/rewrite386splitload.go new file mode 100644 index 0000000000000000000000000000000000000000..a8bd6aaff443e3e94a9c0e155377856321f28c23 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewrite386splitload.go @@ -0,0 +1,159 @@ +// Code generated from _gen/386splitload.rules using 'go generate'; DO NOT EDIT. + +package ssa + +func rewriteValue386splitload(v *Value) bool { + switch v.Op { + case Op386CMPBconstload: + return rewriteValue386splitload_Op386CMPBconstload(v) + case Op386CMPBload: + return rewriteValue386splitload_Op386CMPBload(v) + case Op386CMPLconstload: + return rewriteValue386splitload_Op386CMPLconstload(v) + case Op386CMPLload: + return rewriteValue386splitload_Op386CMPLload(v) + case Op386CMPWconstload: + return rewriteValue386splitload_Op386CMPWconstload(v) + case Op386CMPWload: + return rewriteValue386splitload_Op386CMPWload(v) + } + return false +} +func rewriteValue386splitload_Op386CMPBconstload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPBconstload {sym} [vo] ptr mem) + // result: (CMPBconst (MOVBload {sym} [vo.Off()] ptr mem) [vo.Val8()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + v.reset(Op386CMPBconst) + v.AuxInt = int8ToAuxInt(vo.Val8()) + v0 := b.NewValue0(v.Pos, Op386MOVBload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } +} +func rewriteValue386splitload_Op386CMPBload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPBload {sym} [off] ptr x mem) + // result: (CMPB (MOVBload {sym} [off] ptr mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + x := v_1 + mem := v_2 + v.reset(Op386CMPB) + v0 := b.NewValue0(v.Pos, Op386MOVBload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValue386splitload_Op386CMPLconstload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPLconstload {sym} [vo] ptr mem) + // result: (CMPLconst (MOVLload {sym} [vo.Off()] ptr mem) [vo.Val()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + v.reset(Op386CMPLconst) + v.AuxInt = int32ToAuxInt(vo.Val()) + v0 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } +} +func rewriteValue386splitload_Op386CMPLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPLload {sym} [off] ptr x mem) + // result: (CMPL (MOVLload {sym} [off] ptr mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + x := v_1 + mem := v_2 + v.reset(Op386CMPL) + v0 := b.NewValue0(v.Pos, Op386MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValue386splitload_Op386CMPWconstload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPWconstload {sym} [vo] ptr mem) + // result: (CMPWconst (MOVWload {sym} [vo.Off()] ptr mem) [vo.Val16()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + v.reset(Op386CMPWconst) + v.AuxInt = int16ToAuxInt(vo.Val16()) + v0 := b.NewValue0(v.Pos, Op386MOVWload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } +} +func rewriteValue386splitload_Op386CMPWload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPWload {sym} [off] ptr x mem) + // result: (CMPW (MOVWload {sym} [off] ptr mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + x := v_1 + mem := v_2 + v.reset(Op386CMPW) + v0 := b.NewValue0(v.Pos, Op386MOVWload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteBlock386splitload(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteAMD64.go b/go/src/cmd/compile/internal/ssa/rewriteAMD64.go new file mode 100644 index 0000000000000000000000000000000000000000..d005b15a5752640cd919512a742e076236be04d1 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteAMD64.go @@ -0,0 +1,79016 @@ +// Code generated from _gen/AMD64.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "internal/buildcfg" +import "math" +import "cmd/internal/obj" +import "cmd/compile/internal/base" +import "cmd/compile/internal/types" + +func rewriteValueAMD64(v *Value) bool { + switch v.Op { + case OpAESDecryptLastRoundUint8x16: + v.Op = OpAMD64VAESDECLAST128 + return true + case OpAESDecryptLastRoundUint8x32: + v.Op = OpAMD64VAESDECLAST256 + return true + case OpAESDecryptLastRoundUint8x64: + v.Op = OpAMD64VAESDECLAST512 + return true + case OpAESDecryptOneRoundUint8x16: + v.Op = OpAMD64VAESDEC128 + return true + case OpAESDecryptOneRoundUint8x32: + v.Op = OpAMD64VAESDEC256 + return true + case OpAESDecryptOneRoundUint8x64: + v.Op = OpAMD64VAESDEC512 + return true + case OpAESEncryptLastRoundUint8x16: + v.Op = OpAMD64VAESENCLAST128 + return true + case OpAESEncryptLastRoundUint8x32: + v.Op = OpAMD64VAESENCLAST256 + return true + case OpAESEncryptLastRoundUint8x64: + v.Op = OpAMD64VAESENCLAST512 + return true + case OpAESEncryptOneRoundUint8x16: + v.Op = OpAMD64VAESENC128 + return true + case OpAESEncryptOneRoundUint8x32: + v.Op = OpAMD64VAESENC256 + return true + case OpAESEncryptOneRoundUint8x64: + v.Op = OpAMD64VAESENC512 + return true + case OpAESInvMixColumnsUint32x4: + v.Op = OpAMD64VAESIMC128 + return true + case OpAESRoundKeyGenAssistUint32x4: + v.Op = OpAMD64VAESKEYGENASSIST128 + return true + case OpAMD64ADCQ: + return rewriteValueAMD64_OpAMD64ADCQ(v) + case OpAMD64ADCQconst: + return rewriteValueAMD64_OpAMD64ADCQconst(v) + case OpAMD64ADDL: + return rewriteValueAMD64_OpAMD64ADDL(v) + case OpAMD64ADDLconst: + return rewriteValueAMD64_OpAMD64ADDLconst(v) + case OpAMD64ADDLconstmodify: + return rewriteValueAMD64_OpAMD64ADDLconstmodify(v) + case OpAMD64ADDLload: + return rewriteValueAMD64_OpAMD64ADDLload(v) + case OpAMD64ADDLmodify: + return rewriteValueAMD64_OpAMD64ADDLmodify(v) + case OpAMD64ADDQ: + return rewriteValueAMD64_OpAMD64ADDQ(v) + case OpAMD64ADDQcarry: + return rewriteValueAMD64_OpAMD64ADDQcarry(v) + case OpAMD64ADDQconst: + return rewriteValueAMD64_OpAMD64ADDQconst(v) + case OpAMD64ADDQconstmodify: + return rewriteValueAMD64_OpAMD64ADDQconstmodify(v) + case OpAMD64ADDQload: + return rewriteValueAMD64_OpAMD64ADDQload(v) + case OpAMD64ADDQmodify: + return rewriteValueAMD64_OpAMD64ADDQmodify(v) + case OpAMD64ADDSD: + return rewriteValueAMD64_OpAMD64ADDSD(v) + case OpAMD64ADDSDload: + return rewriteValueAMD64_OpAMD64ADDSDload(v) + case OpAMD64ADDSS: + return rewriteValueAMD64_OpAMD64ADDSS(v) + case OpAMD64ADDSSload: + return rewriteValueAMD64_OpAMD64ADDSSload(v) + case OpAMD64ANDL: + return rewriteValueAMD64_OpAMD64ANDL(v) + case OpAMD64ANDLconst: + return rewriteValueAMD64_OpAMD64ANDLconst(v) + case OpAMD64ANDLconstmodify: + return rewriteValueAMD64_OpAMD64ANDLconstmodify(v) + case OpAMD64ANDLload: + return rewriteValueAMD64_OpAMD64ANDLload(v) + case OpAMD64ANDLmodify: + return rewriteValueAMD64_OpAMD64ANDLmodify(v) + case OpAMD64ANDNL: + return rewriteValueAMD64_OpAMD64ANDNL(v) + case OpAMD64ANDNQ: + return rewriteValueAMD64_OpAMD64ANDNQ(v) + case OpAMD64ANDQ: + return rewriteValueAMD64_OpAMD64ANDQ(v) + case OpAMD64ANDQconst: + return rewriteValueAMD64_OpAMD64ANDQconst(v) + case OpAMD64ANDQconstmodify: + return rewriteValueAMD64_OpAMD64ANDQconstmodify(v) + case OpAMD64ANDQload: + return rewriteValueAMD64_OpAMD64ANDQload(v) + case OpAMD64ANDQmodify: + return rewriteValueAMD64_OpAMD64ANDQmodify(v) + case OpAMD64BSFQ: + return rewriteValueAMD64_OpAMD64BSFQ(v) + case OpAMD64BSWAPL: + return rewriteValueAMD64_OpAMD64BSWAPL(v) + case OpAMD64BSWAPQ: + return rewriteValueAMD64_OpAMD64BSWAPQ(v) + case OpAMD64BTCQconst: + return rewriteValueAMD64_OpAMD64BTCQconst(v) + case OpAMD64BTLconst: + return rewriteValueAMD64_OpAMD64BTLconst(v) + case OpAMD64BTQconst: + return rewriteValueAMD64_OpAMD64BTQconst(v) + case OpAMD64BTRQconst: + return rewriteValueAMD64_OpAMD64BTRQconst(v) + case OpAMD64BTSQconst: + return rewriteValueAMD64_OpAMD64BTSQconst(v) + case OpAMD64CMOVLCC: + return rewriteValueAMD64_OpAMD64CMOVLCC(v) + case OpAMD64CMOVLCS: + return rewriteValueAMD64_OpAMD64CMOVLCS(v) + case OpAMD64CMOVLEQ: + return rewriteValueAMD64_OpAMD64CMOVLEQ(v) + case OpAMD64CMOVLGE: + return rewriteValueAMD64_OpAMD64CMOVLGE(v) + case OpAMD64CMOVLGT: + return rewriteValueAMD64_OpAMD64CMOVLGT(v) + case OpAMD64CMOVLHI: + return rewriteValueAMD64_OpAMD64CMOVLHI(v) + case OpAMD64CMOVLLE: + return rewriteValueAMD64_OpAMD64CMOVLLE(v) + case OpAMD64CMOVLLS: + return rewriteValueAMD64_OpAMD64CMOVLLS(v) + case OpAMD64CMOVLLT: + return rewriteValueAMD64_OpAMD64CMOVLLT(v) + case OpAMD64CMOVLNE: + return rewriteValueAMD64_OpAMD64CMOVLNE(v) + case OpAMD64CMOVQCC: + return rewriteValueAMD64_OpAMD64CMOVQCC(v) + case OpAMD64CMOVQCS: + return rewriteValueAMD64_OpAMD64CMOVQCS(v) + case OpAMD64CMOVQEQ: + return rewriteValueAMD64_OpAMD64CMOVQEQ(v) + case OpAMD64CMOVQGE: + return rewriteValueAMD64_OpAMD64CMOVQGE(v) + case OpAMD64CMOVQGT: + return rewriteValueAMD64_OpAMD64CMOVQGT(v) + case OpAMD64CMOVQHI: + return rewriteValueAMD64_OpAMD64CMOVQHI(v) + case OpAMD64CMOVQLE: + return rewriteValueAMD64_OpAMD64CMOVQLE(v) + case OpAMD64CMOVQLS: + return rewriteValueAMD64_OpAMD64CMOVQLS(v) + case OpAMD64CMOVQLT: + return rewriteValueAMD64_OpAMD64CMOVQLT(v) + case OpAMD64CMOVQNE: + return rewriteValueAMD64_OpAMD64CMOVQNE(v) + case OpAMD64CMOVWCC: + return rewriteValueAMD64_OpAMD64CMOVWCC(v) + case OpAMD64CMOVWCS: + return rewriteValueAMD64_OpAMD64CMOVWCS(v) + case OpAMD64CMOVWEQ: + return rewriteValueAMD64_OpAMD64CMOVWEQ(v) + case OpAMD64CMOVWGE: + return rewriteValueAMD64_OpAMD64CMOVWGE(v) + case OpAMD64CMOVWGT: + return rewriteValueAMD64_OpAMD64CMOVWGT(v) + case OpAMD64CMOVWHI: + return rewriteValueAMD64_OpAMD64CMOVWHI(v) + case OpAMD64CMOVWLE: + return rewriteValueAMD64_OpAMD64CMOVWLE(v) + case OpAMD64CMOVWLS: + return rewriteValueAMD64_OpAMD64CMOVWLS(v) + case OpAMD64CMOVWLT: + return rewriteValueAMD64_OpAMD64CMOVWLT(v) + case OpAMD64CMOVWNE: + return rewriteValueAMD64_OpAMD64CMOVWNE(v) + case OpAMD64CMPB: + return rewriteValueAMD64_OpAMD64CMPB(v) + case OpAMD64CMPBconst: + return rewriteValueAMD64_OpAMD64CMPBconst(v) + case OpAMD64CMPBconstload: + return rewriteValueAMD64_OpAMD64CMPBconstload(v) + case OpAMD64CMPBload: + return rewriteValueAMD64_OpAMD64CMPBload(v) + case OpAMD64CMPL: + return rewriteValueAMD64_OpAMD64CMPL(v) + case OpAMD64CMPLconst: + return rewriteValueAMD64_OpAMD64CMPLconst(v) + case OpAMD64CMPLconstload: + return rewriteValueAMD64_OpAMD64CMPLconstload(v) + case OpAMD64CMPLload: + return rewriteValueAMD64_OpAMD64CMPLload(v) + case OpAMD64CMPQ: + return rewriteValueAMD64_OpAMD64CMPQ(v) + case OpAMD64CMPQconst: + return rewriteValueAMD64_OpAMD64CMPQconst(v) + case OpAMD64CMPQconstload: + return rewriteValueAMD64_OpAMD64CMPQconstload(v) + case OpAMD64CMPQload: + return rewriteValueAMD64_OpAMD64CMPQload(v) + case OpAMD64CMPW: + return rewriteValueAMD64_OpAMD64CMPW(v) + case OpAMD64CMPWconst: + return rewriteValueAMD64_OpAMD64CMPWconst(v) + case OpAMD64CMPWconstload: + return rewriteValueAMD64_OpAMD64CMPWconstload(v) + case OpAMD64CMPWload: + return rewriteValueAMD64_OpAMD64CMPWload(v) + case OpAMD64CMPXCHGLlock: + return rewriteValueAMD64_OpAMD64CMPXCHGLlock(v) + case OpAMD64CMPXCHGQlock: + return rewriteValueAMD64_OpAMD64CMPXCHGQlock(v) + case OpAMD64DIVSD: + return rewriteValueAMD64_OpAMD64DIVSD(v) + case OpAMD64DIVSDload: + return rewriteValueAMD64_OpAMD64DIVSDload(v) + case OpAMD64DIVSS: + return rewriteValueAMD64_OpAMD64DIVSS(v) + case OpAMD64DIVSSload: + return rewriteValueAMD64_OpAMD64DIVSSload(v) + case OpAMD64HMULL: + return rewriteValueAMD64_OpAMD64HMULL(v) + case OpAMD64HMULLU: + return rewriteValueAMD64_OpAMD64HMULLU(v) + case OpAMD64HMULQ: + return rewriteValueAMD64_OpAMD64HMULQ(v) + case OpAMD64HMULQU: + return rewriteValueAMD64_OpAMD64HMULQU(v) + case OpAMD64KMOVBk: + return rewriteValueAMD64_OpAMD64KMOVBk(v) + case OpAMD64KMOVDk: + return rewriteValueAMD64_OpAMD64KMOVDk(v) + case OpAMD64KMOVQk: + return rewriteValueAMD64_OpAMD64KMOVQk(v) + case OpAMD64KMOVWk: + return rewriteValueAMD64_OpAMD64KMOVWk(v) + case OpAMD64LEAL: + return rewriteValueAMD64_OpAMD64LEAL(v) + case OpAMD64LEAL1: + return rewriteValueAMD64_OpAMD64LEAL1(v) + case OpAMD64LEAL2: + return rewriteValueAMD64_OpAMD64LEAL2(v) + case OpAMD64LEAL4: + return rewriteValueAMD64_OpAMD64LEAL4(v) + case OpAMD64LEAL8: + return rewriteValueAMD64_OpAMD64LEAL8(v) + case OpAMD64LEAQ: + return rewriteValueAMD64_OpAMD64LEAQ(v) + case OpAMD64LEAQ1: + return rewriteValueAMD64_OpAMD64LEAQ1(v) + case OpAMD64LEAQ2: + return rewriteValueAMD64_OpAMD64LEAQ2(v) + case OpAMD64LEAQ4: + return rewriteValueAMD64_OpAMD64LEAQ4(v) + case OpAMD64LEAQ8: + return rewriteValueAMD64_OpAMD64LEAQ8(v) + case OpAMD64LoweredPanicBoundsCR: + return rewriteValueAMD64_OpAMD64LoweredPanicBoundsCR(v) + case OpAMD64LoweredPanicBoundsRC: + return rewriteValueAMD64_OpAMD64LoweredPanicBoundsRC(v) + case OpAMD64LoweredPanicBoundsRR: + return rewriteValueAMD64_OpAMD64LoweredPanicBoundsRR(v) + case OpAMD64MOVBELstore: + return rewriteValueAMD64_OpAMD64MOVBELstore(v) + case OpAMD64MOVBEQstore: + return rewriteValueAMD64_OpAMD64MOVBEQstore(v) + case OpAMD64MOVBEWstore: + return rewriteValueAMD64_OpAMD64MOVBEWstore(v) + case OpAMD64MOVBQSX: + return rewriteValueAMD64_OpAMD64MOVBQSX(v) + case OpAMD64MOVBQSXload: + return rewriteValueAMD64_OpAMD64MOVBQSXload(v) + case OpAMD64MOVBQZX: + return rewriteValueAMD64_OpAMD64MOVBQZX(v) + case OpAMD64MOVBatomicload: + return rewriteValueAMD64_OpAMD64MOVBatomicload(v) + case OpAMD64MOVBload: + return rewriteValueAMD64_OpAMD64MOVBload(v) + case OpAMD64MOVBstore: + return rewriteValueAMD64_OpAMD64MOVBstore(v) + case OpAMD64MOVBstoreconst: + return rewriteValueAMD64_OpAMD64MOVBstoreconst(v) + case OpAMD64MOVLQSX: + return rewriteValueAMD64_OpAMD64MOVLQSX(v) + case OpAMD64MOVLQSXload: + return rewriteValueAMD64_OpAMD64MOVLQSXload(v) + case OpAMD64MOVLQZX: + return rewriteValueAMD64_OpAMD64MOVLQZX(v) + case OpAMD64MOVLatomicload: + return rewriteValueAMD64_OpAMD64MOVLatomicload(v) + case OpAMD64MOVLf2i: + return rewriteValueAMD64_OpAMD64MOVLf2i(v) + case OpAMD64MOVLi2f: + return rewriteValueAMD64_OpAMD64MOVLi2f(v) + case OpAMD64MOVLload: + return rewriteValueAMD64_OpAMD64MOVLload(v) + case OpAMD64MOVLstore: + return rewriteValueAMD64_OpAMD64MOVLstore(v) + case OpAMD64MOVLstoreconst: + return rewriteValueAMD64_OpAMD64MOVLstoreconst(v) + case OpAMD64MOVOload: + return rewriteValueAMD64_OpAMD64MOVOload(v) + case OpAMD64MOVOstore: + return rewriteValueAMD64_OpAMD64MOVOstore(v) + case OpAMD64MOVOstoreconst: + return rewriteValueAMD64_OpAMD64MOVOstoreconst(v) + case OpAMD64MOVQatomicload: + return rewriteValueAMD64_OpAMD64MOVQatomicload(v) + case OpAMD64MOVQf2i: + return rewriteValueAMD64_OpAMD64MOVQf2i(v) + case OpAMD64MOVQi2f: + return rewriteValueAMD64_OpAMD64MOVQi2f(v) + case OpAMD64MOVQload: + return rewriteValueAMD64_OpAMD64MOVQload(v) + case OpAMD64MOVQstore: + return rewriteValueAMD64_OpAMD64MOVQstore(v) + case OpAMD64MOVQstoreconst: + return rewriteValueAMD64_OpAMD64MOVQstoreconst(v) + case OpAMD64MOVSDload: + return rewriteValueAMD64_OpAMD64MOVSDload(v) + case OpAMD64MOVSDstore: + return rewriteValueAMD64_OpAMD64MOVSDstore(v) + case OpAMD64MOVSSload: + return rewriteValueAMD64_OpAMD64MOVSSload(v) + case OpAMD64MOVSSstore: + return rewriteValueAMD64_OpAMD64MOVSSstore(v) + case OpAMD64MOVWQSX: + return rewriteValueAMD64_OpAMD64MOVWQSX(v) + case OpAMD64MOVWQSXload: + return rewriteValueAMD64_OpAMD64MOVWQSXload(v) + case OpAMD64MOVWQZX: + return rewriteValueAMD64_OpAMD64MOVWQZX(v) + case OpAMD64MOVWload: + return rewriteValueAMD64_OpAMD64MOVWload(v) + case OpAMD64MOVWstore: + return rewriteValueAMD64_OpAMD64MOVWstore(v) + case OpAMD64MOVWstoreconst: + return rewriteValueAMD64_OpAMD64MOVWstoreconst(v) + case OpAMD64MULL: + return rewriteValueAMD64_OpAMD64MULL(v) + case OpAMD64MULLconst: + return rewriteValueAMD64_OpAMD64MULLconst(v) + case OpAMD64MULQ: + return rewriteValueAMD64_OpAMD64MULQ(v) + case OpAMD64MULQconst: + return rewriteValueAMD64_OpAMD64MULQconst(v) + case OpAMD64MULSD: + return rewriteValueAMD64_OpAMD64MULSD(v) + case OpAMD64MULSDload: + return rewriteValueAMD64_OpAMD64MULSDload(v) + case OpAMD64MULSS: + return rewriteValueAMD64_OpAMD64MULSS(v) + case OpAMD64MULSSload: + return rewriteValueAMD64_OpAMD64MULSSload(v) + case OpAMD64NEGL: + return rewriteValueAMD64_OpAMD64NEGL(v) + case OpAMD64NEGQ: + return rewriteValueAMD64_OpAMD64NEGQ(v) + case OpAMD64NOTL: + return rewriteValueAMD64_OpAMD64NOTL(v) + case OpAMD64NOTQ: + return rewriteValueAMD64_OpAMD64NOTQ(v) + case OpAMD64ORL: + return rewriteValueAMD64_OpAMD64ORL(v) + case OpAMD64ORLconst: + return rewriteValueAMD64_OpAMD64ORLconst(v) + case OpAMD64ORLconstmodify: + return rewriteValueAMD64_OpAMD64ORLconstmodify(v) + case OpAMD64ORLload: + return rewriteValueAMD64_OpAMD64ORLload(v) + case OpAMD64ORLmodify: + return rewriteValueAMD64_OpAMD64ORLmodify(v) + case OpAMD64ORQ: + return rewriteValueAMD64_OpAMD64ORQ(v) + case OpAMD64ORQconst: + return rewriteValueAMD64_OpAMD64ORQconst(v) + case OpAMD64ORQconstmodify: + return rewriteValueAMD64_OpAMD64ORQconstmodify(v) + case OpAMD64ORQload: + return rewriteValueAMD64_OpAMD64ORQload(v) + case OpAMD64ORQmodify: + return rewriteValueAMD64_OpAMD64ORQmodify(v) + case OpAMD64ROLB: + return rewriteValueAMD64_OpAMD64ROLB(v) + case OpAMD64ROLBconst: + return rewriteValueAMD64_OpAMD64ROLBconst(v) + case OpAMD64ROLL: + return rewriteValueAMD64_OpAMD64ROLL(v) + case OpAMD64ROLLconst: + return rewriteValueAMD64_OpAMD64ROLLconst(v) + case OpAMD64ROLQ: + return rewriteValueAMD64_OpAMD64ROLQ(v) + case OpAMD64ROLQconst: + return rewriteValueAMD64_OpAMD64ROLQconst(v) + case OpAMD64ROLW: + return rewriteValueAMD64_OpAMD64ROLW(v) + case OpAMD64ROLWconst: + return rewriteValueAMD64_OpAMD64ROLWconst(v) + case OpAMD64RORB: + return rewriteValueAMD64_OpAMD64RORB(v) + case OpAMD64RORL: + return rewriteValueAMD64_OpAMD64RORL(v) + case OpAMD64RORQ: + return rewriteValueAMD64_OpAMD64RORQ(v) + case OpAMD64RORW: + return rewriteValueAMD64_OpAMD64RORW(v) + case OpAMD64SARB: + return rewriteValueAMD64_OpAMD64SARB(v) + case OpAMD64SARBconst: + return rewriteValueAMD64_OpAMD64SARBconst(v) + case OpAMD64SARL: + return rewriteValueAMD64_OpAMD64SARL(v) + case OpAMD64SARLconst: + return rewriteValueAMD64_OpAMD64SARLconst(v) + case OpAMD64SARQ: + return rewriteValueAMD64_OpAMD64SARQ(v) + case OpAMD64SARQconst: + return rewriteValueAMD64_OpAMD64SARQconst(v) + case OpAMD64SARW: + return rewriteValueAMD64_OpAMD64SARW(v) + case OpAMD64SARWconst: + return rewriteValueAMD64_OpAMD64SARWconst(v) + case OpAMD64SARXLload: + return rewriteValueAMD64_OpAMD64SARXLload(v) + case OpAMD64SARXQload: + return rewriteValueAMD64_OpAMD64SARXQload(v) + case OpAMD64SBBLcarrymask: + return rewriteValueAMD64_OpAMD64SBBLcarrymask(v) + case OpAMD64SBBQ: + return rewriteValueAMD64_OpAMD64SBBQ(v) + case OpAMD64SBBQcarrymask: + return rewriteValueAMD64_OpAMD64SBBQcarrymask(v) + case OpAMD64SBBQconst: + return rewriteValueAMD64_OpAMD64SBBQconst(v) + case OpAMD64SETA: + return rewriteValueAMD64_OpAMD64SETA(v) + case OpAMD64SETAE: + return rewriteValueAMD64_OpAMD64SETAE(v) + case OpAMD64SETAEstore: + return rewriteValueAMD64_OpAMD64SETAEstore(v) + case OpAMD64SETAstore: + return rewriteValueAMD64_OpAMD64SETAstore(v) + case OpAMD64SETB: + return rewriteValueAMD64_OpAMD64SETB(v) + case OpAMD64SETBE: + return rewriteValueAMD64_OpAMD64SETBE(v) + case OpAMD64SETBEstore: + return rewriteValueAMD64_OpAMD64SETBEstore(v) + case OpAMD64SETBstore: + return rewriteValueAMD64_OpAMD64SETBstore(v) + case OpAMD64SETEQ: + return rewriteValueAMD64_OpAMD64SETEQ(v) + case OpAMD64SETEQstore: + return rewriteValueAMD64_OpAMD64SETEQstore(v) + case OpAMD64SETG: + return rewriteValueAMD64_OpAMD64SETG(v) + case OpAMD64SETGE: + return rewriteValueAMD64_OpAMD64SETGE(v) + case OpAMD64SETGEstore: + return rewriteValueAMD64_OpAMD64SETGEstore(v) + case OpAMD64SETGstore: + return rewriteValueAMD64_OpAMD64SETGstore(v) + case OpAMD64SETL: + return rewriteValueAMD64_OpAMD64SETL(v) + case OpAMD64SETLE: + return rewriteValueAMD64_OpAMD64SETLE(v) + case OpAMD64SETLEstore: + return rewriteValueAMD64_OpAMD64SETLEstore(v) + case OpAMD64SETLstore: + return rewriteValueAMD64_OpAMD64SETLstore(v) + case OpAMD64SETNE: + return rewriteValueAMD64_OpAMD64SETNE(v) + case OpAMD64SETNEstore: + return rewriteValueAMD64_OpAMD64SETNEstore(v) + case OpAMD64SHLL: + return rewriteValueAMD64_OpAMD64SHLL(v) + case OpAMD64SHLLconst: + return rewriteValueAMD64_OpAMD64SHLLconst(v) + case OpAMD64SHLQ: + return rewriteValueAMD64_OpAMD64SHLQ(v) + case OpAMD64SHLQconst: + return rewriteValueAMD64_OpAMD64SHLQconst(v) + case OpAMD64SHLXLload: + return rewriteValueAMD64_OpAMD64SHLXLload(v) + case OpAMD64SHLXQload: + return rewriteValueAMD64_OpAMD64SHLXQload(v) + case OpAMD64SHRB: + return rewriteValueAMD64_OpAMD64SHRB(v) + case OpAMD64SHRBconst: + return rewriteValueAMD64_OpAMD64SHRBconst(v) + case OpAMD64SHRL: + return rewriteValueAMD64_OpAMD64SHRL(v) + case OpAMD64SHRLconst: + return rewriteValueAMD64_OpAMD64SHRLconst(v) + case OpAMD64SHRQ: + return rewriteValueAMD64_OpAMD64SHRQ(v) + case OpAMD64SHRQconst: + return rewriteValueAMD64_OpAMD64SHRQconst(v) + case OpAMD64SHRW: + return rewriteValueAMD64_OpAMD64SHRW(v) + case OpAMD64SHRWconst: + return rewriteValueAMD64_OpAMD64SHRWconst(v) + case OpAMD64SHRXLload: + return rewriteValueAMD64_OpAMD64SHRXLload(v) + case OpAMD64SHRXQload: + return rewriteValueAMD64_OpAMD64SHRXQload(v) + case OpAMD64SUBL: + return rewriteValueAMD64_OpAMD64SUBL(v) + case OpAMD64SUBLconst: + return rewriteValueAMD64_OpAMD64SUBLconst(v) + case OpAMD64SUBLload: + return rewriteValueAMD64_OpAMD64SUBLload(v) + case OpAMD64SUBLmodify: + return rewriteValueAMD64_OpAMD64SUBLmodify(v) + case OpAMD64SUBQ: + return rewriteValueAMD64_OpAMD64SUBQ(v) + case OpAMD64SUBQborrow: + return rewriteValueAMD64_OpAMD64SUBQborrow(v) + case OpAMD64SUBQconst: + return rewriteValueAMD64_OpAMD64SUBQconst(v) + case OpAMD64SUBQload: + return rewriteValueAMD64_OpAMD64SUBQload(v) + case OpAMD64SUBQmodify: + return rewriteValueAMD64_OpAMD64SUBQmodify(v) + case OpAMD64SUBSD: + return rewriteValueAMD64_OpAMD64SUBSD(v) + case OpAMD64SUBSDload: + return rewriteValueAMD64_OpAMD64SUBSDload(v) + case OpAMD64SUBSS: + return rewriteValueAMD64_OpAMD64SUBSS(v) + case OpAMD64SUBSSload: + return rewriteValueAMD64_OpAMD64SUBSSload(v) + case OpAMD64TESTB: + return rewriteValueAMD64_OpAMD64TESTB(v) + case OpAMD64TESTBconst: + return rewriteValueAMD64_OpAMD64TESTBconst(v) + case OpAMD64TESTL: + return rewriteValueAMD64_OpAMD64TESTL(v) + case OpAMD64TESTLconst: + return rewriteValueAMD64_OpAMD64TESTLconst(v) + case OpAMD64TESTQ: + return rewriteValueAMD64_OpAMD64TESTQ(v) + case OpAMD64TESTQconst: + return rewriteValueAMD64_OpAMD64TESTQconst(v) + case OpAMD64TESTW: + return rewriteValueAMD64_OpAMD64TESTW(v) + case OpAMD64TESTWconst: + return rewriteValueAMD64_OpAMD64TESTWconst(v) + case OpAMD64VADDPD512: + return rewriteValueAMD64_OpAMD64VADDPD512(v) + case OpAMD64VADDPDMasked128: + return rewriteValueAMD64_OpAMD64VADDPDMasked128(v) + case OpAMD64VADDPDMasked256: + return rewriteValueAMD64_OpAMD64VADDPDMasked256(v) + case OpAMD64VADDPDMasked512: + return rewriteValueAMD64_OpAMD64VADDPDMasked512(v) + case OpAMD64VADDPS512: + return rewriteValueAMD64_OpAMD64VADDPS512(v) + case OpAMD64VADDPSMasked128: + return rewriteValueAMD64_OpAMD64VADDPSMasked128(v) + case OpAMD64VADDPSMasked256: + return rewriteValueAMD64_OpAMD64VADDPSMasked256(v) + case OpAMD64VADDPSMasked512: + return rewriteValueAMD64_OpAMD64VADDPSMasked512(v) + case OpAMD64VCMPPD512: + return rewriteValueAMD64_OpAMD64VCMPPD512(v) + case OpAMD64VCMPPDMasked128: + return rewriteValueAMD64_OpAMD64VCMPPDMasked128(v) + case OpAMD64VCMPPDMasked256: + return rewriteValueAMD64_OpAMD64VCMPPDMasked256(v) + case OpAMD64VCMPPDMasked512: + return rewriteValueAMD64_OpAMD64VCMPPDMasked512(v) + case OpAMD64VCMPPS512: + return rewriteValueAMD64_OpAMD64VCMPPS512(v) + case OpAMD64VCMPPSMasked128: + return rewriteValueAMD64_OpAMD64VCMPPSMasked128(v) + case OpAMD64VCMPPSMasked256: + return rewriteValueAMD64_OpAMD64VCMPPSMasked256(v) + case OpAMD64VCMPPSMasked512: + return rewriteValueAMD64_OpAMD64VCMPPSMasked512(v) + case OpAMD64VCVTDQ2PD512: + return rewriteValueAMD64_OpAMD64VCVTDQ2PD512(v) + case OpAMD64VCVTDQ2PDMasked256: + return rewriteValueAMD64_OpAMD64VCVTDQ2PDMasked256(v) + case OpAMD64VCVTDQ2PDMasked512: + return rewriteValueAMD64_OpAMD64VCVTDQ2PDMasked512(v) + case OpAMD64VCVTDQ2PS512: + return rewriteValueAMD64_OpAMD64VCVTDQ2PS512(v) + case OpAMD64VCVTDQ2PSMasked128: + return rewriteValueAMD64_OpAMD64VCVTDQ2PSMasked128(v) + case OpAMD64VCVTDQ2PSMasked256: + return rewriteValueAMD64_OpAMD64VCVTDQ2PSMasked256(v) + case OpAMD64VCVTDQ2PSMasked512: + return rewriteValueAMD64_OpAMD64VCVTDQ2PSMasked512(v) + case OpAMD64VCVTPD2PS256: + return rewriteValueAMD64_OpAMD64VCVTPD2PS256(v) + case OpAMD64VCVTPD2PSMasked256: + return rewriteValueAMD64_OpAMD64VCVTPD2PSMasked256(v) + case OpAMD64VCVTPD2PSXMasked128: + return rewriteValueAMD64_OpAMD64VCVTPD2PSXMasked128(v) + case OpAMD64VCVTPD2PSYMasked128: + return rewriteValueAMD64_OpAMD64VCVTPD2PSYMasked128(v) + case OpAMD64VCVTPS2PD512: + return rewriteValueAMD64_OpAMD64VCVTPS2PD512(v) + case OpAMD64VCVTPS2PDMasked256: + return rewriteValueAMD64_OpAMD64VCVTPS2PDMasked256(v) + case OpAMD64VCVTPS2PDMasked512: + return rewriteValueAMD64_OpAMD64VCVTPS2PDMasked512(v) + case OpAMD64VCVTQQ2PD128: + return rewriteValueAMD64_OpAMD64VCVTQQ2PD128(v) + case OpAMD64VCVTQQ2PD256: + return rewriteValueAMD64_OpAMD64VCVTQQ2PD256(v) + case OpAMD64VCVTQQ2PD512: + return rewriteValueAMD64_OpAMD64VCVTQQ2PD512(v) + case OpAMD64VCVTQQ2PDMasked128: + return rewriteValueAMD64_OpAMD64VCVTQQ2PDMasked128(v) + case OpAMD64VCVTQQ2PDMasked256: + return rewriteValueAMD64_OpAMD64VCVTQQ2PDMasked256(v) + case OpAMD64VCVTQQ2PDMasked512: + return rewriteValueAMD64_OpAMD64VCVTQQ2PDMasked512(v) + case OpAMD64VCVTQQ2PS256: + return rewriteValueAMD64_OpAMD64VCVTQQ2PS256(v) + case OpAMD64VCVTQQ2PSMasked256: + return rewriteValueAMD64_OpAMD64VCVTQQ2PSMasked256(v) + case OpAMD64VCVTQQ2PSX128: + return rewriteValueAMD64_OpAMD64VCVTQQ2PSX128(v) + case OpAMD64VCVTQQ2PSXMasked128: + return rewriteValueAMD64_OpAMD64VCVTQQ2PSXMasked128(v) + case OpAMD64VCVTQQ2PSY128: + return rewriteValueAMD64_OpAMD64VCVTQQ2PSY128(v) + case OpAMD64VCVTQQ2PSYMasked128: + return rewriteValueAMD64_OpAMD64VCVTQQ2PSYMasked128(v) + case OpAMD64VCVTTPD2DQ256: + return rewriteValueAMD64_OpAMD64VCVTTPD2DQ256(v) + case OpAMD64VCVTTPD2DQMasked256: + return rewriteValueAMD64_OpAMD64VCVTTPD2DQMasked256(v) + case OpAMD64VCVTTPD2DQXMasked128: + return rewriteValueAMD64_OpAMD64VCVTTPD2DQXMasked128(v) + case OpAMD64VCVTTPD2DQYMasked128: + return rewriteValueAMD64_OpAMD64VCVTTPD2DQYMasked128(v) + case OpAMD64VCVTTPD2QQ128: + return rewriteValueAMD64_OpAMD64VCVTTPD2QQ128(v) + case OpAMD64VCVTTPD2QQ256: + return rewriteValueAMD64_OpAMD64VCVTTPD2QQ256(v) + case OpAMD64VCVTTPD2QQ512: + return rewriteValueAMD64_OpAMD64VCVTTPD2QQ512(v) + case OpAMD64VCVTTPD2QQMasked128: + return rewriteValueAMD64_OpAMD64VCVTTPD2QQMasked128(v) + case OpAMD64VCVTTPD2QQMasked256: + return rewriteValueAMD64_OpAMD64VCVTTPD2QQMasked256(v) + case OpAMD64VCVTTPD2QQMasked512: + return rewriteValueAMD64_OpAMD64VCVTTPD2QQMasked512(v) + case OpAMD64VCVTTPD2UDQ256: + return rewriteValueAMD64_OpAMD64VCVTTPD2UDQ256(v) + case OpAMD64VCVTTPD2UDQMasked256: + return rewriteValueAMD64_OpAMD64VCVTTPD2UDQMasked256(v) + case OpAMD64VCVTTPD2UDQX128: + return rewriteValueAMD64_OpAMD64VCVTTPD2UDQX128(v) + case OpAMD64VCVTTPD2UDQXMasked128: + return rewriteValueAMD64_OpAMD64VCVTTPD2UDQXMasked128(v) + case OpAMD64VCVTTPD2UDQY128: + return rewriteValueAMD64_OpAMD64VCVTTPD2UDQY128(v) + case OpAMD64VCVTTPD2UDQYMasked128: + return rewriteValueAMD64_OpAMD64VCVTTPD2UDQYMasked128(v) + case OpAMD64VCVTTPD2UQQ128: + return rewriteValueAMD64_OpAMD64VCVTTPD2UQQ128(v) + case OpAMD64VCVTTPD2UQQ256: + return rewriteValueAMD64_OpAMD64VCVTTPD2UQQ256(v) + case OpAMD64VCVTTPD2UQQ512: + return rewriteValueAMD64_OpAMD64VCVTTPD2UQQ512(v) + case OpAMD64VCVTTPD2UQQMasked128: + return rewriteValueAMD64_OpAMD64VCVTTPD2UQQMasked128(v) + case OpAMD64VCVTTPD2UQQMasked256: + return rewriteValueAMD64_OpAMD64VCVTTPD2UQQMasked256(v) + case OpAMD64VCVTTPD2UQQMasked512: + return rewriteValueAMD64_OpAMD64VCVTTPD2UQQMasked512(v) + case OpAMD64VCVTTPS2DQ512: + return rewriteValueAMD64_OpAMD64VCVTTPS2DQ512(v) + case OpAMD64VCVTTPS2DQMasked128: + return rewriteValueAMD64_OpAMD64VCVTTPS2DQMasked128(v) + case OpAMD64VCVTTPS2DQMasked256: + return rewriteValueAMD64_OpAMD64VCVTTPS2DQMasked256(v) + case OpAMD64VCVTTPS2DQMasked512: + return rewriteValueAMD64_OpAMD64VCVTTPS2DQMasked512(v) + case OpAMD64VCVTTPS2QQ256: + return rewriteValueAMD64_OpAMD64VCVTTPS2QQ256(v) + case OpAMD64VCVTTPS2QQ512: + return rewriteValueAMD64_OpAMD64VCVTTPS2QQ512(v) + case OpAMD64VCVTTPS2QQMasked256: + return rewriteValueAMD64_OpAMD64VCVTTPS2QQMasked256(v) + case OpAMD64VCVTTPS2QQMasked512: + return rewriteValueAMD64_OpAMD64VCVTTPS2QQMasked512(v) + case OpAMD64VCVTTPS2UDQ128: + return rewriteValueAMD64_OpAMD64VCVTTPS2UDQ128(v) + case OpAMD64VCVTTPS2UDQ256: + return rewriteValueAMD64_OpAMD64VCVTTPS2UDQ256(v) + case OpAMD64VCVTTPS2UDQ512: + return rewriteValueAMD64_OpAMD64VCVTTPS2UDQ512(v) + case OpAMD64VCVTTPS2UDQMasked128: + return rewriteValueAMD64_OpAMD64VCVTTPS2UDQMasked128(v) + case OpAMD64VCVTTPS2UDQMasked256: + return rewriteValueAMD64_OpAMD64VCVTTPS2UDQMasked256(v) + case OpAMD64VCVTTPS2UDQMasked512: + return rewriteValueAMD64_OpAMD64VCVTTPS2UDQMasked512(v) + case OpAMD64VCVTTPS2UQQ256: + return rewriteValueAMD64_OpAMD64VCVTTPS2UQQ256(v) + case OpAMD64VCVTTPS2UQQ512: + return rewriteValueAMD64_OpAMD64VCVTTPS2UQQ512(v) + case OpAMD64VCVTTPS2UQQMasked256: + return rewriteValueAMD64_OpAMD64VCVTTPS2UQQMasked256(v) + case OpAMD64VCVTTPS2UQQMasked512: + return rewriteValueAMD64_OpAMD64VCVTTPS2UQQMasked512(v) + case OpAMD64VCVTUDQ2PD256: + return rewriteValueAMD64_OpAMD64VCVTUDQ2PD256(v) + case OpAMD64VCVTUDQ2PD512: + return rewriteValueAMD64_OpAMD64VCVTUDQ2PD512(v) + case OpAMD64VCVTUDQ2PDMasked256: + return rewriteValueAMD64_OpAMD64VCVTUDQ2PDMasked256(v) + case OpAMD64VCVTUDQ2PDMasked512: + return rewriteValueAMD64_OpAMD64VCVTUDQ2PDMasked512(v) + case OpAMD64VCVTUDQ2PS128: + return rewriteValueAMD64_OpAMD64VCVTUDQ2PS128(v) + case OpAMD64VCVTUDQ2PS256: + return rewriteValueAMD64_OpAMD64VCVTUDQ2PS256(v) + case OpAMD64VCVTUDQ2PS512: + return rewriteValueAMD64_OpAMD64VCVTUDQ2PS512(v) + case OpAMD64VCVTUDQ2PSMasked128: + return rewriteValueAMD64_OpAMD64VCVTUDQ2PSMasked128(v) + case OpAMD64VCVTUDQ2PSMasked256: + return rewriteValueAMD64_OpAMD64VCVTUDQ2PSMasked256(v) + case OpAMD64VCVTUDQ2PSMasked512: + return rewriteValueAMD64_OpAMD64VCVTUDQ2PSMasked512(v) + case OpAMD64VCVTUQQ2PD128: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PD128(v) + case OpAMD64VCVTUQQ2PD256: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PD256(v) + case OpAMD64VCVTUQQ2PD512: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PD512(v) + case OpAMD64VCVTUQQ2PDMasked128: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PDMasked128(v) + case OpAMD64VCVTUQQ2PDMasked256: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PDMasked256(v) + case OpAMD64VCVTUQQ2PDMasked512: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PDMasked512(v) + case OpAMD64VCVTUQQ2PS256: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PS256(v) + case OpAMD64VCVTUQQ2PSMasked256: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PSMasked256(v) + case OpAMD64VCVTUQQ2PSX128: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PSX128(v) + case OpAMD64VCVTUQQ2PSXMasked128: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PSXMasked128(v) + case OpAMD64VCVTUQQ2PSY128: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PSY128(v) + case OpAMD64VCVTUQQ2PSYMasked128: + return rewriteValueAMD64_OpAMD64VCVTUQQ2PSYMasked128(v) + case OpAMD64VDIVPD512: + return rewriteValueAMD64_OpAMD64VDIVPD512(v) + case OpAMD64VDIVPDMasked128: + return rewriteValueAMD64_OpAMD64VDIVPDMasked128(v) + case OpAMD64VDIVPDMasked256: + return rewriteValueAMD64_OpAMD64VDIVPDMasked256(v) + case OpAMD64VDIVPDMasked512: + return rewriteValueAMD64_OpAMD64VDIVPDMasked512(v) + case OpAMD64VDIVPS512: + return rewriteValueAMD64_OpAMD64VDIVPS512(v) + case OpAMD64VDIVPSMasked128: + return rewriteValueAMD64_OpAMD64VDIVPSMasked128(v) + case OpAMD64VDIVPSMasked256: + return rewriteValueAMD64_OpAMD64VDIVPSMasked256(v) + case OpAMD64VDIVPSMasked512: + return rewriteValueAMD64_OpAMD64VDIVPSMasked512(v) + case OpAMD64VFMADD213PD512: + return rewriteValueAMD64_OpAMD64VFMADD213PD512(v) + case OpAMD64VFMADD213PDMasked128: + return rewriteValueAMD64_OpAMD64VFMADD213PDMasked128(v) + case OpAMD64VFMADD213PDMasked256: + return rewriteValueAMD64_OpAMD64VFMADD213PDMasked256(v) + case OpAMD64VFMADD213PDMasked512: + return rewriteValueAMD64_OpAMD64VFMADD213PDMasked512(v) + case OpAMD64VFMADD213PS512: + return rewriteValueAMD64_OpAMD64VFMADD213PS512(v) + case OpAMD64VFMADD213PSMasked128: + return rewriteValueAMD64_OpAMD64VFMADD213PSMasked128(v) + case OpAMD64VFMADD213PSMasked256: + return rewriteValueAMD64_OpAMD64VFMADD213PSMasked256(v) + case OpAMD64VFMADD213PSMasked512: + return rewriteValueAMD64_OpAMD64VFMADD213PSMasked512(v) + case OpAMD64VFMADDSUB213PD512: + return rewriteValueAMD64_OpAMD64VFMADDSUB213PD512(v) + case OpAMD64VFMADDSUB213PDMasked128: + return rewriteValueAMD64_OpAMD64VFMADDSUB213PDMasked128(v) + case OpAMD64VFMADDSUB213PDMasked256: + return rewriteValueAMD64_OpAMD64VFMADDSUB213PDMasked256(v) + case OpAMD64VFMADDSUB213PDMasked512: + return rewriteValueAMD64_OpAMD64VFMADDSUB213PDMasked512(v) + case OpAMD64VFMADDSUB213PS512: + return rewriteValueAMD64_OpAMD64VFMADDSUB213PS512(v) + case OpAMD64VFMADDSUB213PSMasked128: + return rewriteValueAMD64_OpAMD64VFMADDSUB213PSMasked128(v) + case OpAMD64VFMADDSUB213PSMasked256: + return rewriteValueAMD64_OpAMD64VFMADDSUB213PSMasked256(v) + case OpAMD64VFMADDSUB213PSMasked512: + return rewriteValueAMD64_OpAMD64VFMADDSUB213PSMasked512(v) + case OpAMD64VFMSUBADD213PD512: + return rewriteValueAMD64_OpAMD64VFMSUBADD213PD512(v) + case OpAMD64VFMSUBADD213PDMasked128: + return rewriteValueAMD64_OpAMD64VFMSUBADD213PDMasked128(v) + case OpAMD64VFMSUBADD213PDMasked256: + return rewriteValueAMD64_OpAMD64VFMSUBADD213PDMasked256(v) + case OpAMD64VFMSUBADD213PDMasked512: + return rewriteValueAMD64_OpAMD64VFMSUBADD213PDMasked512(v) + case OpAMD64VFMSUBADD213PS512: + return rewriteValueAMD64_OpAMD64VFMSUBADD213PS512(v) + case OpAMD64VFMSUBADD213PSMasked128: + return rewriteValueAMD64_OpAMD64VFMSUBADD213PSMasked128(v) + case OpAMD64VFMSUBADD213PSMasked256: + return rewriteValueAMD64_OpAMD64VFMSUBADD213PSMasked256(v) + case OpAMD64VFMSUBADD213PSMasked512: + return rewriteValueAMD64_OpAMD64VFMSUBADD213PSMasked512(v) + case OpAMD64VGF2P8AFFINEINVQB128: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQB128(v) + case OpAMD64VGF2P8AFFINEINVQB256: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQB256(v) + case OpAMD64VGF2P8AFFINEINVQB512: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQB512(v) + case OpAMD64VGF2P8AFFINEINVQBMasked128: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQBMasked128(v) + case OpAMD64VGF2P8AFFINEINVQBMasked256: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQBMasked256(v) + case OpAMD64VGF2P8AFFINEINVQBMasked512: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQBMasked512(v) + case OpAMD64VGF2P8AFFINEQB128: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEQB128(v) + case OpAMD64VGF2P8AFFINEQB256: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEQB256(v) + case OpAMD64VGF2P8AFFINEQB512: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEQB512(v) + case OpAMD64VGF2P8AFFINEQBMasked128: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEQBMasked128(v) + case OpAMD64VGF2P8AFFINEQBMasked256: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEQBMasked256(v) + case OpAMD64VGF2P8AFFINEQBMasked512: + return rewriteValueAMD64_OpAMD64VGF2P8AFFINEQBMasked512(v) + case OpAMD64VMAXPD512: + return rewriteValueAMD64_OpAMD64VMAXPD512(v) + case OpAMD64VMAXPDMasked128: + return rewriteValueAMD64_OpAMD64VMAXPDMasked128(v) + case OpAMD64VMAXPDMasked256: + return rewriteValueAMD64_OpAMD64VMAXPDMasked256(v) + case OpAMD64VMAXPDMasked512: + return rewriteValueAMD64_OpAMD64VMAXPDMasked512(v) + case OpAMD64VMAXPS512: + return rewriteValueAMD64_OpAMD64VMAXPS512(v) + case OpAMD64VMAXPSMasked128: + return rewriteValueAMD64_OpAMD64VMAXPSMasked128(v) + case OpAMD64VMAXPSMasked256: + return rewriteValueAMD64_OpAMD64VMAXPSMasked256(v) + case OpAMD64VMAXPSMasked512: + return rewriteValueAMD64_OpAMD64VMAXPSMasked512(v) + case OpAMD64VMINPD512: + return rewriteValueAMD64_OpAMD64VMINPD512(v) + case OpAMD64VMINPDMasked128: + return rewriteValueAMD64_OpAMD64VMINPDMasked128(v) + case OpAMD64VMINPDMasked256: + return rewriteValueAMD64_OpAMD64VMINPDMasked256(v) + case OpAMD64VMINPDMasked512: + return rewriteValueAMD64_OpAMD64VMINPDMasked512(v) + case OpAMD64VMINPS512: + return rewriteValueAMD64_OpAMD64VMINPS512(v) + case OpAMD64VMINPSMasked128: + return rewriteValueAMD64_OpAMD64VMINPSMasked128(v) + case OpAMD64VMINPSMasked256: + return rewriteValueAMD64_OpAMD64VMINPSMasked256(v) + case OpAMD64VMINPSMasked512: + return rewriteValueAMD64_OpAMD64VMINPSMasked512(v) + case OpAMD64VMOVD: + return rewriteValueAMD64_OpAMD64VMOVD(v) + case OpAMD64VMOVDQU16Masked128: + return rewriteValueAMD64_OpAMD64VMOVDQU16Masked128(v) + case OpAMD64VMOVDQU16Masked256: + return rewriteValueAMD64_OpAMD64VMOVDQU16Masked256(v) + case OpAMD64VMOVDQU16Masked512: + return rewriteValueAMD64_OpAMD64VMOVDQU16Masked512(v) + case OpAMD64VMOVDQU32Masked128: + return rewriteValueAMD64_OpAMD64VMOVDQU32Masked128(v) + case OpAMD64VMOVDQU32Masked256: + return rewriteValueAMD64_OpAMD64VMOVDQU32Masked256(v) + case OpAMD64VMOVDQU32Masked512: + return rewriteValueAMD64_OpAMD64VMOVDQU32Masked512(v) + case OpAMD64VMOVDQU64Masked128: + return rewriteValueAMD64_OpAMD64VMOVDQU64Masked128(v) + case OpAMD64VMOVDQU64Masked256: + return rewriteValueAMD64_OpAMD64VMOVDQU64Masked256(v) + case OpAMD64VMOVDQU64Masked512: + return rewriteValueAMD64_OpAMD64VMOVDQU64Masked512(v) + case OpAMD64VMOVDQU8Masked128: + return rewriteValueAMD64_OpAMD64VMOVDQU8Masked128(v) + case OpAMD64VMOVDQU8Masked256: + return rewriteValueAMD64_OpAMD64VMOVDQU8Masked256(v) + case OpAMD64VMOVDQU8Masked512: + return rewriteValueAMD64_OpAMD64VMOVDQU8Masked512(v) + case OpAMD64VMOVDQUload128: + return rewriteValueAMD64_OpAMD64VMOVDQUload128(v) + case OpAMD64VMOVDQUload256: + return rewriteValueAMD64_OpAMD64VMOVDQUload256(v) + case OpAMD64VMOVDQUload512: + return rewriteValueAMD64_OpAMD64VMOVDQUload512(v) + case OpAMD64VMOVDQUstore128: + return rewriteValueAMD64_OpAMD64VMOVDQUstore128(v) + case OpAMD64VMOVDQUstore256: + return rewriteValueAMD64_OpAMD64VMOVDQUstore256(v) + case OpAMD64VMOVDQUstore512: + return rewriteValueAMD64_OpAMD64VMOVDQUstore512(v) + case OpAMD64VMOVQ: + return rewriteValueAMD64_OpAMD64VMOVQ(v) + case OpAMD64VMOVSDf2v: + return rewriteValueAMD64_OpAMD64VMOVSDf2v(v) + case OpAMD64VMOVSSf2v: + return rewriteValueAMD64_OpAMD64VMOVSSf2v(v) + case OpAMD64VMULPD512: + return rewriteValueAMD64_OpAMD64VMULPD512(v) + case OpAMD64VMULPDMasked128: + return rewriteValueAMD64_OpAMD64VMULPDMasked128(v) + case OpAMD64VMULPDMasked256: + return rewriteValueAMD64_OpAMD64VMULPDMasked256(v) + case OpAMD64VMULPDMasked512: + return rewriteValueAMD64_OpAMD64VMULPDMasked512(v) + case OpAMD64VMULPS512: + return rewriteValueAMD64_OpAMD64VMULPS512(v) + case OpAMD64VMULPSMasked128: + return rewriteValueAMD64_OpAMD64VMULPSMasked128(v) + case OpAMD64VMULPSMasked256: + return rewriteValueAMD64_OpAMD64VMULPSMasked256(v) + case OpAMD64VMULPSMasked512: + return rewriteValueAMD64_OpAMD64VMULPSMasked512(v) + case OpAMD64VPABSD512: + return rewriteValueAMD64_OpAMD64VPABSD512(v) + case OpAMD64VPABSDMasked128: + return rewriteValueAMD64_OpAMD64VPABSDMasked128(v) + case OpAMD64VPABSDMasked256: + return rewriteValueAMD64_OpAMD64VPABSDMasked256(v) + case OpAMD64VPABSDMasked512: + return rewriteValueAMD64_OpAMD64VPABSDMasked512(v) + case OpAMD64VPABSQ128: + return rewriteValueAMD64_OpAMD64VPABSQ128(v) + case OpAMD64VPABSQ256: + return rewriteValueAMD64_OpAMD64VPABSQ256(v) + case OpAMD64VPABSQ512: + return rewriteValueAMD64_OpAMD64VPABSQ512(v) + case OpAMD64VPABSQMasked128: + return rewriteValueAMD64_OpAMD64VPABSQMasked128(v) + case OpAMD64VPABSQMasked256: + return rewriteValueAMD64_OpAMD64VPABSQMasked256(v) + case OpAMD64VPABSQMasked512: + return rewriteValueAMD64_OpAMD64VPABSQMasked512(v) + case OpAMD64VPACKSSDW512: + return rewriteValueAMD64_OpAMD64VPACKSSDW512(v) + case OpAMD64VPACKSSDWMasked128: + return rewriteValueAMD64_OpAMD64VPACKSSDWMasked128(v) + case OpAMD64VPACKSSDWMasked256: + return rewriteValueAMD64_OpAMD64VPACKSSDWMasked256(v) + case OpAMD64VPACKSSDWMasked512: + return rewriteValueAMD64_OpAMD64VPACKSSDWMasked512(v) + case OpAMD64VPACKUSDW512: + return rewriteValueAMD64_OpAMD64VPACKUSDW512(v) + case OpAMD64VPACKUSDWMasked128: + return rewriteValueAMD64_OpAMD64VPACKUSDWMasked128(v) + case OpAMD64VPACKUSDWMasked256: + return rewriteValueAMD64_OpAMD64VPACKUSDWMasked256(v) + case OpAMD64VPACKUSDWMasked512: + return rewriteValueAMD64_OpAMD64VPACKUSDWMasked512(v) + case OpAMD64VPADDD512: + return rewriteValueAMD64_OpAMD64VPADDD512(v) + case OpAMD64VPADDDMasked128: + return rewriteValueAMD64_OpAMD64VPADDDMasked128(v) + case OpAMD64VPADDDMasked256: + return rewriteValueAMD64_OpAMD64VPADDDMasked256(v) + case OpAMD64VPADDDMasked512: + return rewriteValueAMD64_OpAMD64VPADDDMasked512(v) + case OpAMD64VPADDQ512: + return rewriteValueAMD64_OpAMD64VPADDQ512(v) + case OpAMD64VPADDQMasked128: + return rewriteValueAMD64_OpAMD64VPADDQMasked128(v) + case OpAMD64VPADDQMasked256: + return rewriteValueAMD64_OpAMD64VPADDQMasked256(v) + case OpAMD64VPADDQMasked512: + return rewriteValueAMD64_OpAMD64VPADDQMasked512(v) + case OpAMD64VPAND128: + return rewriteValueAMD64_OpAMD64VPAND128(v) + case OpAMD64VPAND256: + return rewriteValueAMD64_OpAMD64VPAND256(v) + case OpAMD64VPANDD512: + return rewriteValueAMD64_OpAMD64VPANDD512(v) + case OpAMD64VPANDDMasked128: + return rewriteValueAMD64_OpAMD64VPANDDMasked128(v) + case OpAMD64VPANDDMasked256: + return rewriteValueAMD64_OpAMD64VPANDDMasked256(v) + case OpAMD64VPANDDMasked512: + return rewriteValueAMD64_OpAMD64VPANDDMasked512(v) + case OpAMD64VPANDND512: + return rewriteValueAMD64_OpAMD64VPANDND512(v) + case OpAMD64VPANDNDMasked128: + return rewriteValueAMD64_OpAMD64VPANDNDMasked128(v) + case OpAMD64VPANDNDMasked256: + return rewriteValueAMD64_OpAMD64VPANDNDMasked256(v) + case OpAMD64VPANDNDMasked512: + return rewriteValueAMD64_OpAMD64VPANDNDMasked512(v) + case OpAMD64VPANDNQ512: + return rewriteValueAMD64_OpAMD64VPANDNQ512(v) + case OpAMD64VPANDNQMasked128: + return rewriteValueAMD64_OpAMD64VPANDNQMasked128(v) + case OpAMD64VPANDNQMasked256: + return rewriteValueAMD64_OpAMD64VPANDNQMasked256(v) + case OpAMD64VPANDNQMasked512: + return rewriteValueAMD64_OpAMD64VPANDNQMasked512(v) + case OpAMD64VPANDQ512: + return rewriteValueAMD64_OpAMD64VPANDQ512(v) + case OpAMD64VPANDQMasked128: + return rewriteValueAMD64_OpAMD64VPANDQMasked128(v) + case OpAMD64VPANDQMasked256: + return rewriteValueAMD64_OpAMD64VPANDQMasked256(v) + case OpAMD64VPANDQMasked512: + return rewriteValueAMD64_OpAMD64VPANDQMasked512(v) + case OpAMD64VPBLENDMBMasked512: + return rewriteValueAMD64_OpAMD64VPBLENDMBMasked512(v) + case OpAMD64VPBLENDMDMasked512: + return rewriteValueAMD64_OpAMD64VPBLENDMDMasked512(v) + case OpAMD64VPBLENDMQMasked512: + return rewriteValueAMD64_OpAMD64VPBLENDMQMasked512(v) + case OpAMD64VPBLENDMWMasked512: + return rewriteValueAMD64_OpAMD64VPBLENDMWMasked512(v) + case OpAMD64VPBLENDVB128: + return rewriteValueAMD64_OpAMD64VPBLENDVB128(v) + case OpAMD64VPBLENDVB256: + return rewriteValueAMD64_OpAMD64VPBLENDVB256(v) + case OpAMD64VPBROADCASTB128: + return rewriteValueAMD64_OpAMD64VPBROADCASTB128(v) + case OpAMD64VPBROADCASTB256: + return rewriteValueAMD64_OpAMD64VPBROADCASTB256(v) + case OpAMD64VPBROADCASTB512: + return rewriteValueAMD64_OpAMD64VPBROADCASTB512(v) + case OpAMD64VPBROADCASTW128: + return rewriteValueAMD64_OpAMD64VPBROADCASTW128(v) + case OpAMD64VPBROADCASTW256: + return rewriteValueAMD64_OpAMD64VPBROADCASTW256(v) + case OpAMD64VPBROADCASTW512: + return rewriteValueAMD64_OpAMD64VPBROADCASTW512(v) + case OpAMD64VPCMPD512: + return rewriteValueAMD64_OpAMD64VPCMPD512(v) + case OpAMD64VPCMPDMasked128: + return rewriteValueAMD64_OpAMD64VPCMPDMasked128(v) + case OpAMD64VPCMPDMasked256: + return rewriteValueAMD64_OpAMD64VPCMPDMasked256(v) + case OpAMD64VPCMPDMasked512: + return rewriteValueAMD64_OpAMD64VPCMPDMasked512(v) + case OpAMD64VPCMPEQD512: + return rewriteValueAMD64_OpAMD64VPCMPEQD512(v) + case OpAMD64VPCMPEQQ512: + return rewriteValueAMD64_OpAMD64VPCMPEQQ512(v) + case OpAMD64VPCMPGTD512: + return rewriteValueAMD64_OpAMD64VPCMPGTD512(v) + case OpAMD64VPCMPGTQ512: + return rewriteValueAMD64_OpAMD64VPCMPGTQ512(v) + case OpAMD64VPCMPQ512: + return rewriteValueAMD64_OpAMD64VPCMPQ512(v) + case OpAMD64VPCMPQMasked128: + return rewriteValueAMD64_OpAMD64VPCMPQMasked128(v) + case OpAMD64VPCMPQMasked256: + return rewriteValueAMD64_OpAMD64VPCMPQMasked256(v) + case OpAMD64VPCMPQMasked512: + return rewriteValueAMD64_OpAMD64VPCMPQMasked512(v) + case OpAMD64VPCMPUD512: + return rewriteValueAMD64_OpAMD64VPCMPUD512(v) + case OpAMD64VPCMPUDMasked128: + return rewriteValueAMD64_OpAMD64VPCMPUDMasked128(v) + case OpAMD64VPCMPUDMasked256: + return rewriteValueAMD64_OpAMD64VPCMPUDMasked256(v) + case OpAMD64VPCMPUDMasked512: + return rewriteValueAMD64_OpAMD64VPCMPUDMasked512(v) + case OpAMD64VPCMPUQ512: + return rewriteValueAMD64_OpAMD64VPCMPUQ512(v) + case OpAMD64VPCMPUQMasked128: + return rewriteValueAMD64_OpAMD64VPCMPUQMasked128(v) + case OpAMD64VPCMPUQMasked256: + return rewriteValueAMD64_OpAMD64VPCMPUQMasked256(v) + case OpAMD64VPCMPUQMasked512: + return rewriteValueAMD64_OpAMD64VPCMPUQMasked512(v) + case OpAMD64VPDPWSSD512: + return rewriteValueAMD64_OpAMD64VPDPWSSD512(v) + case OpAMD64VPDPWSSDMasked128: + return rewriteValueAMD64_OpAMD64VPDPWSSDMasked128(v) + case OpAMD64VPDPWSSDMasked256: + return rewriteValueAMD64_OpAMD64VPDPWSSDMasked256(v) + case OpAMD64VPDPWSSDMasked512: + return rewriteValueAMD64_OpAMD64VPDPWSSDMasked512(v) + case OpAMD64VPERMD512: + return rewriteValueAMD64_OpAMD64VPERMD512(v) + case OpAMD64VPERMDMasked256: + return rewriteValueAMD64_OpAMD64VPERMDMasked256(v) + case OpAMD64VPERMDMasked512: + return rewriteValueAMD64_OpAMD64VPERMDMasked512(v) + case OpAMD64VPERMI2D128: + return rewriteValueAMD64_OpAMD64VPERMI2D128(v) + case OpAMD64VPERMI2D256: + return rewriteValueAMD64_OpAMD64VPERMI2D256(v) + case OpAMD64VPERMI2D512: + return rewriteValueAMD64_OpAMD64VPERMI2D512(v) + case OpAMD64VPERMI2DMasked128: + return rewriteValueAMD64_OpAMD64VPERMI2DMasked128(v) + case OpAMD64VPERMI2DMasked256: + return rewriteValueAMD64_OpAMD64VPERMI2DMasked256(v) + case OpAMD64VPERMI2DMasked512: + return rewriteValueAMD64_OpAMD64VPERMI2DMasked512(v) + case OpAMD64VPERMI2PD128: + return rewriteValueAMD64_OpAMD64VPERMI2PD128(v) + case OpAMD64VPERMI2PD256: + return rewriteValueAMD64_OpAMD64VPERMI2PD256(v) + case OpAMD64VPERMI2PD512: + return rewriteValueAMD64_OpAMD64VPERMI2PD512(v) + case OpAMD64VPERMI2PDMasked128: + return rewriteValueAMD64_OpAMD64VPERMI2PDMasked128(v) + case OpAMD64VPERMI2PDMasked256: + return rewriteValueAMD64_OpAMD64VPERMI2PDMasked256(v) + case OpAMD64VPERMI2PDMasked512: + return rewriteValueAMD64_OpAMD64VPERMI2PDMasked512(v) + case OpAMD64VPERMI2PS128: + return rewriteValueAMD64_OpAMD64VPERMI2PS128(v) + case OpAMD64VPERMI2PS256: + return rewriteValueAMD64_OpAMD64VPERMI2PS256(v) + case OpAMD64VPERMI2PS512: + return rewriteValueAMD64_OpAMD64VPERMI2PS512(v) + case OpAMD64VPERMI2PSMasked128: + return rewriteValueAMD64_OpAMD64VPERMI2PSMasked128(v) + case OpAMD64VPERMI2PSMasked256: + return rewriteValueAMD64_OpAMD64VPERMI2PSMasked256(v) + case OpAMD64VPERMI2PSMasked512: + return rewriteValueAMD64_OpAMD64VPERMI2PSMasked512(v) + case OpAMD64VPERMI2Q128: + return rewriteValueAMD64_OpAMD64VPERMI2Q128(v) + case OpAMD64VPERMI2Q256: + return rewriteValueAMD64_OpAMD64VPERMI2Q256(v) + case OpAMD64VPERMI2Q512: + return rewriteValueAMD64_OpAMD64VPERMI2Q512(v) + case OpAMD64VPERMI2QMasked128: + return rewriteValueAMD64_OpAMD64VPERMI2QMasked128(v) + case OpAMD64VPERMI2QMasked256: + return rewriteValueAMD64_OpAMD64VPERMI2QMasked256(v) + case OpAMD64VPERMI2QMasked512: + return rewriteValueAMD64_OpAMD64VPERMI2QMasked512(v) + case OpAMD64VPERMPD256: + return rewriteValueAMD64_OpAMD64VPERMPD256(v) + case OpAMD64VPERMPD512: + return rewriteValueAMD64_OpAMD64VPERMPD512(v) + case OpAMD64VPERMPDMasked256: + return rewriteValueAMD64_OpAMD64VPERMPDMasked256(v) + case OpAMD64VPERMPDMasked512: + return rewriteValueAMD64_OpAMD64VPERMPDMasked512(v) + case OpAMD64VPERMPS512: + return rewriteValueAMD64_OpAMD64VPERMPS512(v) + case OpAMD64VPERMPSMasked256: + return rewriteValueAMD64_OpAMD64VPERMPSMasked256(v) + case OpAMD64VPERMPSMasked512: + return rewriteValueAMD64_OpAMD64VPERMPSMasked512(v) + case OpAMD64VPERMQ256: + return rewriteValueAMD64_OpAMD64VPERMQ256(v) + case OpAMD64VPERMQ512: + return rewriteValueAMD64_OpAMD64VPERMQ512(v) + case OpAMD64VPERMQMasked256: + return rewriteValueAMD64_OpAMD64VPERMQMasked256(v) + case OpAMD64VPERMQMasked512: + return rewriteValueAMD64_OpAMD64VPERMQMasked512(v) + case OpAMD64VPINSRD128: + return rewriteValueAMD64_OpAMD64VPINSRD128(v) + case OpAMD64VPINSRQ128: + return rewriteValueAMD64_OpAMD64VPINSRQ128(v) + case OpAMD64VPLZCNTD128: + return rewriteValueAMD64_OpAMD64VPLZCNTD128(v) + case OpAMD64VPLZCNTD256: + return rewriteValueAMD64_OpAMD64VPLZCNTD256(v) + case OpAMD64VPLZCNTD512: + return rewriteValueAMD64_OpAMD64VPLZCNTD512(v) + case OpAMD64VPLZCNTDMasked128: + return rewriteValueAMD64_OpAMD64VPLZCNTDMasked128(v) + case OpAMD64VPLZCNTDMasked256: + return rewriteValueAMD64_OpAMD64VPLZCNTDMasked256(v) + case OpAMD64VPLZCNTDMasked512: + return rewriteValueAMD64_OpAMD64VPLZCNTDMasked512(v) + case OpAMD64VPLZCNTQ128: + return rewriteValueAMD64_OpAMD64VPLZCNTQ128(v) + case OpAMD64VPLZCNTQ256: + return rewriteValueAMD64_OpAMD64VPLZCNTQ256(v) + case OpAMD64VPLZCNTQ512: + return rewriteValueAMD64_OpAMD64VPLZCNTQ512(v) + case OpAMD64VPLZCNTQMasked128: + return rewriteValueAMD64_OpAMD64VPLZCNTQMasked128(v) + case OpAMD64VPLZCNTQMasked256: + return rewriteValueAMD64_OpAMD64VPLZCNTQMasked256(v) + case OpAMD64VPLZCNTQMasked512: + return rewriteValueAMD64_OpAMD64VPLZCNTQMasked512(v) + case OpAMD64VPMAXSD512: + return rewriteValueAMD64_OpAMD64VPMAXSD512(v) + case OpAMD64VPMAXSDMasked128: + return rewriteValueAMD64_OpAMD64VPMAXSDMasked128(v) + case OpAMD64VPMAXSDMasked256: + return rewriteValueAMD64_OpAMD64VPMAXSDMasked256(v) + case OpAMD64VPMAXSDMasked512: + return rewriteValueAMD64_OpAMD64VPMAXSDMasked512(v) + case OpAMD64VPMAXSQ128: + return rewriteValueAMD64_OpAMD64VPMAXSQ128(v) + case OpAMD64VPMAXSQ256: + return rewriteValueAMD64_OpAMD64VPMAXSQ256(v) + case OpAMD64VPMAXSQ512: + return rewriteValueAMD64_OpAMD64VPMAXSQ512(v) + case OpAMD64VPMAXSQMasked128: + return rewriteValueAMD64_OpAMD64VPMAXSQMasked128(v) + case OpAMD64VPMAXSQMasked256: + return rewriteValueAMD64_OpAMD64VPMAXSQMasked256(v) + case OpAMD64VPMAXSQMasked512: + return rewriteValueAMD64_OpAMD64VPMAXSQMasked512(v) + case OpAMD64VPMAXUD512: + return rewriteValueAMD64_OpAMD64VPMAXUD512(v) + case OpAMD64VPMAXUDMasked128: + return rewriteValueAMD64_OpAMD64VPMAXUDMasked128(v) + case OpAMD64VPMAXUDMasked256: + return rewriteValueAMD64_OpAMD64VPMAXUDMasked256(v) + case OpAMD64VPMAXUDMasked512: + return rewriteValueAMD64_OpAMD64VPMAXUDMasked512(v) + case OpAMD64VPMAXUQ128: + return rewriteValueAMD64_OpAMD64VPMAXUQ128(v) + case OpAMD64VPMAXUQ256: + return rewriteValueAMD64_OpAMD64VPMAXUQ256(v) + case OpAMD64VPMAXUQ512: + return rewriteValueAMD64_OpAMD64VPMAXUQ512(v) + case OpAMD64VPMAXUQMasked128: + return rewriteValueAMD64_OpAMD64VPMAXUQMasked128(v) + case OpAMD64VPMAXUQMasked256: + return rewriteValueAMD64_OpAMD64VPMAXUQMasked256(v) + case OpAMD64VPMAXUQMasked512: + return rewriteValueAMD64_OpAMD64VPMAXUQMasked512(v) + case OpAMD64VPMINSD512: + return rewriteValueAMD64_OpAMD64VPMINSD512(v) + case OpAMD64VPMINSDMasked128: + return rewriteValueAMD64_OpAMD64VPMINSDMasked128(v) + case OpAMD64VPMINSDMasked256: + return rewriteValueAMD64_OpAMD64VPMINSDMasked256(v) + case OpAMD64VPMINSDMasked512: + return rewriteValueAMD64_OpAMD64VPMINSDMasked512(v) + case OpAMD64VPMINSQ128: + return rewriteValueAMD64_OpAMD64VPMINSQ128(v) + case OpAMD64VPMINSQ256: + return rewriteValueAMD64_OpAMD64VPMINSQ256(v) + case OpAMD64VPMINSQ512: + return rewriteValueAMD64_OpAMD64VPMINSQ512(v) + case OpAMD64VPMINSQMasked128: + return rewriteValueAMD64_OpAMD64VPMINSQMasked128(v) + case OpAMD64VPMINSQMasked256: + return rewriteValueAMD64_OpAMD64VPMINSQMasked256(v) + case OpAMD64VPMINSQMasked512: + return rewriteValueAMD64_OpAMD64VPMINSQMasked512(v) + case OpAMD64VPMINUD512: + return rewriteValueAMD64_OpAMD64VPMINUD512(v) + case OpAMD64VPMINUDMasked128: + return rewriteValueAMD64_OpAMD64VPMINUDMasked128(v) + case OpAMD64VPMINUDMasked256: + return rewriteValueAMD64_OpAMD64VPMINUDMasked256(v) + case OpAMD64VPMINUDMasked512: + return rewriteValueAMD64_OpAMD64VPMINUDMasked512(v) + case OpAMD64VPMINUQ128: + return rewriteValueAMD64_OpAMD64VPMINUQ128(v) + case OpAMD64VPMINUQ256: + return rewriteValueAMD64_OpAMD64VPMINUQ256(v) + case OpAMD64VPMINUQ512: + return rewriteValueAMD64_OpAMD64VPMINUQ512(v) + case OpAMD64VPMINUQMasked128: + return rewriteValueAMD64_OpAMD64VPMINUQMasked128(v) + case OpAMD64VPMINUQMasked256: + return rewriteValueAMD64_OpAMD64VPMINUQMasked256(v) + case OpAMD64VPMINUQMasked512: + return rewriteValueAMD64_OpAMD64VPMINUQMasked512(v) + case OpAMD64VPMOVVec16x16ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec16x16ToM(v) + case OpAMD64VPMOVVec16x32ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec16x32ToM(v) + case OpAMD64VPMOVVec16x8ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec16x8ToM(v) + case OpAMD64VPMOVVec32x16ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec32x16ToM(v) + case OpAMD64VPMOVVec32x4ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec32x4ToM(v) + case OpAMD64VPMOVVec32x8ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec32x8ToM(v) + case OpAMD64VPMOVVec64x2ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec64x2ToM(v) + case OpAMD64VPMOVVec64x4ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec64x4ToM(v) + case OpAMD64VPMOVVec64x8ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec64x8ToM(v) + case OpAMD64VPMOVVec8x16ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec8x16ToM(v) + case OpAMD64VPMOVVec8x32ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec8x32ToM(v) + case OpAMD64VPMOVVec8x64ToM: + return rewriteValueAMD64_OpAMD64VPMOVVec8x64ToM(v) + case OpAMD64VPMULLD512: + return rewriteValueAMD64_OpAMD64VPMULLD512(v) + case OpAMD64VPMULLDMasked128: + return rewriteValueAMD64_OpAMD64VPMULLDMasked128(v) + case OpAMD64VPMULLDMasked256: + return rewriteValueAMD64_OpAMD64VPMULLDMasked256(v) + case OpAMD64VPMULLDMasked512: + return rewriteValueAMD64_OpAMD64VPMULLDMasked512(v) + case OpAMD64VPMULLQ128: + return rewriteValueAMD64_OpAMD64VPMULLQ128(v) + case OpAMD64VPMULLQ256: + return rewriteValueAMD64_OpAMD64VPMULLQ256(v) + case OpAMD64VPMULLQ512: + return rewriteValueAMD64_OpAMD64VPMULLQ512(v) + case OpAMD64VPMULLQMasked128: + return rewriteValueAMD64_OpAMD64VPMULLQMasked128(v) + case OpAMD64VPMULLQMasked256: + return rewriteValueAMD64_OpAMD64VPMULLQMasked256(v) + case OpAMD64VPMULLQMasked512: + return rewriteValueAMD64_OpAMD64VPMULLQMasked512(v) + case OpAMD64VPOPCNTD128: + return rewriteValueAMD64_OpAMD64VPOPCNTD128(v) + case OpAMD64VPOPCNTD256: + return rewriteValueAMD64_OpAMD64VPOPCNTD256(v) + case OpAMD64VPOPCNTD512: + return rewriteValueAMD64_OpAMD64VPOPCNTD512(v) + case OpAMD64VPOPCNTDMasked128: + return rewriteValueAMD64_OpAMD64VPOPCNTDMasked128(v) + case OpAMD64VPOPCNTDMasked256: + return rewriteValueAMD64_OpAMD64VPOPCNTDMasked256(v) + case OpAMD64VPOPCNTDMasked512: + return rewriteValueAMD64_OpAMD64VPOPCNTDMasked512(v) + case OpAMD64VPOPCNTQ128: + return rewriteValueAMD64_OpAMD64VPOPCNTQ128(v) + case OpAMD64VPOPCNTQ256: + return rewriteValueAMD64_OpAMD64VPOPCNTQ256(v) + case OpAMD64VPOPCNTQ512: + return rewriteValueAMD64_OpAMD64VPOPCNTQ512(v) + case OpAMD64VPOPCNTQMasked128: + return rewriteValueAMD64_OpAMD64VPOPCNTQMasked128(v) + case OpAMD64VPOPCNTQMasked256: + return rewriteValueAMD64_OpAMD64VPOPCNTQMasked256(v) + case OpAMD64VPOPCNTQMasked512: + return rewriteValueAMD64_OpAMD64VPOPCNTQMasked512(v) + case OpAMD64VPOR128: + return rewriteValueAMD64_OpAMD64VPOR128(v) + case OpAMD64VPOR256: + return rewriteValueAMD64_OpAMD64VPOR256(v) + case OpAMD64VPORD512: + return rewriteValueAMD64_OpAMD64VPORD512(v) + case OpAMD64VPORDMasked128: + return rewriteValueAMD64_OpAMD64VPORDMasked128(v) + case OpAMD64VPORDMasked256: + return rewriteValueAMD64_OpAMD64VPORDMasked256(v) + case OpAMD64VPORDMasked512: + return rewriteValueAMD64_OpAMD64VPORDMasked512(v) + case OpAMD64VPORQ512: + return rewriteValueAMD64_OpAMD64VPORQ512(v) + case OpAMD64VPORQMasked128: + return rewriteValueAMD64_OpAMD64VPORQMasked128(v) + case OpAMD64VPORQMasked256: + return rewriteValueAMD64_OpAMD64VPORQMasked256(v) + case OpAMD64VPORQMasked512: + return rewriteValueAMD64_OpAMD64VPORQMasked512(v) + case OpAMD64VPROLD128: + return rewriteValueAMD64_OpAMD64VPROLD128(v) + case OpAMD64VPROLD256: + return rewriteValueAMD64_OpAMD64VPROLD256(v) + case OpAMD64VPROLD512: + return rewriteValueAMD64_OpAMD64VPROLD512(v) + case OpAMD64VPROLDMasked128: + return rewriteValueAMD64_OpAMD64VPROLDMasked128(v) + case OpAMD64VPROLDMasked256: + return rewriteValueAMD64_OpAMD64VPROLDMasked256(v) + case OpAMD64VPROLDMasked512: + return rewriteValueAMD64_OpAMD64VPROLDMasked512(v) + case OpAMD64VPROLQ128: + return rewriteValueAMD64_OpAMD64VPROLQ128(v) + case OpAMD64VPROLQ256: + return rewriteValueAMD64_OpAMD64VPROLQ256(v) + case OpAMD64VPROLQ512: + return rewriteValueAMD64_OpAMD64VPROLQ512(v) + case OpAMD64VPROLQMasked128: + return rewriteValueAMD64_OpAMD64VPROLQMasked128(v) + case OpAMD64VPROLQMasked256: + return rewriteValueAMD64_OpAMD64VPROLQMasked256(v) + case OpAMD64VPROLQMasked512: + return rewriteValueAMD64_OpAMD64VPROLQMasked512(v) + case OpAMD64VPROLVD128: + return rewriteValueAMD64_OpAMD64VPROLVD128(v) + case OpAMD64VPROLVD256: + return rewriteValueAMD64_OpAMD64VPROLVD256(v) + case OpAMD64VPROLVD512: + return rewriteValueAMD64_OpAMD64VPROLVD512(v) + case OpAMD64VPROLVDMasked128: + return rewriteValueAMD64_OpAMD64VPROLVDMasked128(v) + case OpAMD64VPROLVDMasked256: + return rewriteValueAMD64_OpAMD64VPROLVDMasked256(v) + case OpAMD64VPROLVDMasked512: + return rewriteValueAMD64_OpAMD64VPROLVDMasked512(v) + case OpAMD64VPROLVQ128: + return rewriteValueAMD64_OpAMD64VPROLVQ128(v) + case OpAMD64VPROLVQ256: + return rewriteValueAMD64_OpAMD64VPROLVQ256(v) + case OpAMD64VPROLVQ512: + return rewriteValueAMD64_OpAMD64VPROLVQ512(v) + case OpAMD64VPROLVQMasked128: + return rewriteValueAMD64_OpAMD64VPROLVQMasked128(v) + case OpAMD64VPROLVQMasked256: + return rewriteValueAMD64_OpAMD64VPROLVQMasked256(v) + case OpAMD64VPROLVQMasked512: + return rewriteValueAMD64_OpAMD64VPROLVQMasked512(v) + case OpAMD64VPRORD128: + return rewriteValueAMD64_OpAMD64VPRORD128(v) + case OpAMD64VPRORD256: + return rewriteValueAMD64_OpAMD64VPRORD256(v) + case OpAMD64VPRORD512: + return rewriteValueAMD64_OpAMD64VPRORD512(v) + case OpAMD64VPRORDMasked128: + return rewriteValueAMD64_OpAMD64VPRORDMasked128(v) + case OpAMD64VPRORDMasked256: + return rewriteValueAMD64_OpAMD64VPRORDMasked256(v) + case OpAMD64VPRORDMasked512: + return rewriteValueAMD64_OpAMD64VPRORDMasked512(v) + case OpAMD64VPRORQ128: + return rewriteValueAMD64_OpAMD64VPRORQ128(v) + case OpAMD64VPRORQ256: + return rewriteValueAMD64_OpAMD64VPRORQ256(v) + case OpAMD64VPRORQ512: + return rewriteValueAMD64_OpAMD64VPRORQ512(v) + case OpAMD64VPRORQMasked128: + return rewriteValueAMD64_OpAMD64VPRORQMasked128(v) + case OpAMD64VPRORQMasked256: + return rewriteValueAMD64_OpAMD64VPRORQMasked256(v) + case OpAMD64VPRORQMasked512: + return rewriteValueAMD64_OpAMD64VPRORQMasked512(v) + case OpAMD64VPRORVD128: + return rewriteValueAMD64_OpAMD64VPRORVD128(v) + case OpAMD64VPRORVD256: + return rewriteValueAMD64_OpAMD64VPRORVD256(v) + case OpAMD64VPRORVD512: + return rewriteValueAMD64_OpAMD64VPRORVD512(v) + case OpAMD64VPRORVDMasked128: + return rewriteValueAMD64_OpAMD64VPRORVDMasked128(v) + case OpAMD64VPRORVDMasked256: + return rewriteValueAMD64_OpAMD64VPRORVDMasked256(v) + case OpAMD64VPRORVDMasked512: + return rewriteValueAMD64_OpAMD64VPRORVDMasked512(v) + case OpAMD64VPRORVQ128: + return rewriteValueAMD64_OpAMD64VPRORVQ128(v) + case OpAMD64VPRORVQ256: + return rewriteValueAMD64_OpAMD64VPRORVQ256(v) + case OpAMD64VPRORVQ512: + return rewriteValueAMD64_OpAMD64VPRORVQ512(v) + case OpAMD64VPRORVQMasked128: + return rewriteValueAMD64_OpAMD64VPRORVQMasked128(v) + case OpAMD64VPRORVQMasked256: + return rewriteValueAMD64_OpAMD64VPRORVQMasked256(v) + case OpAMD64VPRORVQMasked512: + return rewriteValueAMD64_OpAMD64VPRORVQMasked512(v) + case OpAMD64VPSHLDD128: + return rewriteValueAMD64_OpAMD64VPSHLDD128(v) + case OpAMD64VPSHLDD256: + return rewriteValueAMD64_OpAMD64VPSHLDD256(v) + case OpAMD64VPSHLDD512: + return rewriteValueAMD64_OpAMD64VPSHLDD512(v) + case OpAMD64VPSHLDDMasked128: + return rewriteValueAMD64_OpAMD64VPSHLDDMasked128(v) + case OpAMD64VPSHLDDMasked256: + return rewriteValueAMD64_OpAMD64VPSHLDDMasked256(v) + case OpAMD64VPSHLDDMasked512: + return rewriteValueAMD64_OpAMD64VPSHLDDMasked512(v) + case OpAMD64VPSHLDQ128: + return rewriteValueAMD64_OpAMD64VPSHLDQ128(v) + case OpAMD64VPSHLDQ256: + return rewriteValueAMD64_OpAMD64VPSHLDQ256(v) + case OpAMD64VPSHLDQ512: + return rewriteValueAMD64_OpAMD64VPSHLDQ512(v) + case OpAMD64VPSHLDQMasked128: + return rewriteValueAMD64_OpAMD64VPSHLDQMasked128(v) + case OpAMD64VPSHLDQMasked256: + return rewriteValueAMD64_OpAMD64VPSHLDQMasked256(v) + case OpAMD64VPSHLDQMasked512: + return rewriteValueAMD64_OpAMD64VPSHLDQMasked512(v) + case OpAMD64VPSHLDVD128: + return rewriteValueAMD64_OpAMD64VPSHLDVD128(v) + case OpAMD64VPSHLDVD256: + return rewriteValueAMD64_OpAMD64VPSHLDVD256(v) + case OpAMD64VPSHLDVD512: + return rewriteValueAMD64_OpAMD64VPSHLDVD512(v) + case OpAMD64VPSHLDVDMasked128: + return rewriteValueAMD64_OpAMD64VPSHLDVDMasked128(v) + case OpAMD64VPSHLDVDMasked256: + return rewriteValueAMD64_OpAMD64VPSHLDVDMasked256(v) + case OpAMD64VPSHLDVDMasked512: + return rewriteValueAMD64_OpAMD64VPSHLDVDMasked512(v) + case OpAMD64VPSHLDVQ128: + return rewriteValueAMD64_OpAMD64VPSHLDVQ128(v) + case OpAMD64VPSHLDVQ256: + return rewriteValueAMD64_OpAMD64VPSHLDVQ256(v) + case OpAMD64VPSHLDVQ512: + return rewriteValueAMD64_OpAMD64VPSHLDVQ512(v) + case OpAMD64VPSHLDVQMasked128: + return rewriteValueAMD64_OpAMD64VPSHLDVQMasked128(v) + case OpAMD64VPSHLDVQMasked256: + return rewriteValueAMD64_OpAMD64VPSHLDVQMasked256(v) + case OpAMD64VPSHLDVQMasked512: + return rewriteValueAMD64_OpAMD64VPSHLDVQMasked512(v) + case OpAMD64VPSHRDD128: + return rewriteValueAMD64_OpAMD64VPSHRDD128(v) + case OpAMD64VPSHRDD256: + return rewriteValueAMD64_OpAMD64VPSHRDD256(v) + case OpAMD64VPSHRDD512: + return rewriteValueAMD64_OpAMD64VPSHRDD512(v) + case OpAMD64VPSHRDDMasked128: + return rewriteValueAMD64_OpAMD64VPSHRDDMasked128(v) + case OpAMD64VPSHRDDMasked256: + return rewriteValueAMD64_OpAMD64VPSHRDDMasked256(v) + case OpAMD64VPSHRDDMasked512: + return rewriteValueAMD64_OpAMD64VPSHRDDMasked512(v) + case OpAMD64VPSHRDQ128: + return rewriteValueAMD64_OpAMD64VPSHRDQ128(v) + case OpAMD64VPSHRDQ256: + return rewriteValueAMD64_OpAMD64VPSHRDQ256(v) + case OpAMD64VPSHRDQ512: + return rewriteValueAMD64_OpAMD64VPSHRDQ512(v) + case OpAMD64VPSHRDQMasked128: + return rewriteValueAMD64_OpAMD64VPSHRDQMasked128(v) + case OpAMD64VPSHRDQMasked256: + return rewriteValueAMD64_OpAMD64VPSHRDQMasked256(v) + case OpAMD64VPSHRDQMasked512: + return rewriteValueAMD64_OpAMD64VPSHRDQMasked512(v) + case OpAMD64VPSHRDVD128: + return rewriteValueAMD64_OpAMD64VPSHRDVD128(v) + case OpAMD64VPSHRDVD256: + return rewriteValueAMD64_OpAMD64VPSHRDVD256(v) + case OpAMD64VPSHRDVD512: + return rewriteValueAMD64_OpAMD64VPSHRDVD512(v) + case OpAMD64VPSHRDVDMasked128: + return rewriteValueAMD64_OpAMD64VPSHRDVDMasked128(v) + case OpAMD64VPSHRDVDMasked256: + return rewriteValueAMD64_OpAMD64VPSHRDVDMasked256(v) + case OpAMD64VPSHRDVDMasked512: + return rewriteValueAMD64_OpAMD64VPSHRDVDMasked512(v) + case OpAMD64VPSHRDVQ128: + return rewriteValueAMD64_OpAMD64VPSHRDVQ128(v) + case OpAMD64VPSHRDVQ256: + return rewriteValueAMD64_OpAMD64VPSHRDVQ256(v) + case OpAMD64VPSHRDVQ512: + return rewriteValueAMD64_OpAMD64VPSHRDVQ512(v) + case OpAMD64VPSHRDVQMasked128: + return rewriteValueAMD64_OpAMD64VPSHRDVQMasked128(v) + case OpAMD64VPSHRDVQMasked256: + return rewriteValueAMD64_OpAMD64VPSHRDVQMasked256(v) + case OpAMD64VPSHRDVQMasked512: + return rewriteValueAMD64_OpAMD64VPSHRDVQMasked512(v) + case OpAMD64VPSHUFD512: + return rewriteValueAMD64_OpAMD64VPSHUFD512(v) + case OpAMD64VPSHUFDMasked128: + return rewriteValueAMD64_OpAMD64VPSHUFDMasked128(v) + case OpAMD64VPSHUFDMasked256: + return rewriteValueAMD64_OpAMD64VPSHUFDMasked256(v) + case OpAMD64VPSHUFDMasked512: + return rewriteValueAMD64_OpAMD64VPSHUFDMasked512(v) + case OpAMD64VPSLLD128: + return rewriteValueAMD64_OpAMD64VPSLLD128(v) + case OpAMD64VPSLLD256: + return rewriteValueAMD64_OpAMD64VPSLLD256(v) + case OpAMD64VPSLLD512: + return rewriteValueAMD64_OpAMD64VPSLLD512(v) + case OpAMD64VPSLLD512const: + return rewriteValueAMD64_OpAMD64VPSLLD512const(v) + case OpAMD64VPSLLDMasked128: + return rewriteValueAMD64_OpAMD64VPSLLDMasked128(v) + case OpAMD64VPSLLDMasked128const: + return rewriteValueAMD64_OpAMD64VPSLLDMasked128const(v) + case OpAMD64VPSLLDMasked256: + return rewriteValueAMD64_OpAMD64VPSLLDMasked256(v) + case OpAMD64VPSLLDMasked256const: + return rewriteValueAMD64_OpAMD64VPSLLDMasked256const(v) + case OpAMD64VPSLLDMasked512: + return rewriteValueAMD64_OpAMD64VPSLLDMasked512(v) + case OpAMD64VPSLLDMasked512const: + return rewriteValueAMD64_OpAMD64VPSLLDMasked512const(v) + case OpAMD64VPSLLQ128: + return rewriteValueAMD64_OpAMD64VPSLLQ128(v) + case OpAMD64VPSLLQ256: + return rewriteValueAMD64_OpAMD64VPSLLQ256(v) + case OpAMD64VPSLLQ512: + return rewriteValueAMD64_OpAMD64VPSLLQ512(v) + case OpAMD64VPSLLQ512const: + return rewriteValueAMD64_OpAMD64VPSLLQ512const(v) + case OpAMD64VPSLLQMasked128: + return rewriteValueAMD64_OpAMD64VPSLLQMasked128(v) + case OpAMD64VPSLLQMasked128const: + return rewriteValueAMD64_OpAMD64VPSLLQMasked128const(v) + case OpAMD64VPSLLQMasked256: + return rewriteValueAMD64_OpAMD64VPSLLQMasked256(v) + case OpAMD64VPSLLQMasked256const: + return rewriteValueAMD64_OpAMD64VPSLLQMasked256const(v) + case OpAMD64VPSLLQMasked512: + return rewriteValueAMD64_OpAMD64VPSLLQMasked512(v) + case OpAMD64VPSLLQMasked512const: + return rewriteValueAMD64_OpAMD64VPSLLQMasked512const(v) + case OpAMD64VPSLLVD512: + return rewriteValueAMD64_OpAMD64VPSLLVD512(v) + case OpAMD64VPSLLVDMasked128: + return rewriteValueAMD64_OpAMD64VPSLLVDMasked128(v) + case OpAMD64VPSLLVDMasked256: + return rewriteValueAMD64_OpAMD64VPSLLVDMasked256(v) + case OpAMD64VPSLLVDMasked512: + return rewriteValueAMD64_OpAMD64VPSLLVDMasked512(v) + case OpAMD64VPSLLVQ512: + return rewriteValueAMD64_OpAMD64VPSLLVQ512(v) + case OpAMD64VPSLLVQMasked128: + return rewriteValueAMD64_OpAMD64VPSLLVQMasked128(v) + case OpAMD64VPSLLVQMasked256: + return rewriteValueAMD64_OpAMD64VPSLLVQMasked256(v) + case OpAMD64VPSLLVQMasked512: + return rewriteValueAMD64_OpAMD64VPSLLVQMasked512(v) + case OpAMD64VPSLLW128: + return rewriteValueAMD64_OpAMD64VPSLLW128(v) + case OpAMD64VPSLLW256: + return rewriteValueAMD64_OpAMD64VPSLLW256(v) + case OpAMD64VPSLLW512: + return rewriteValueAMD64_OpAMD64VPSLLW512(v) + case OpAMD64VPSLLWMasked128: + return rewriteValueAMD64_OpAMD64VPSLLWMasked128(v) + case OpAMD64VPSLLWMasked256: + return rewriteValueAMD64_OpAMD64VPSLLWMasked256(v) + case OpAMD64VPSLLWMasked512: + return rewriteValueAMD64_OpAMD64VPSLLWMasked512(v) + case OpAMD64VPSRAD128: + return rewriteValueAMD64_OpAMD64VPSRAD128(v) + case OpAMD64VPSRAD256: + return rewriteValueAMD64_OpAMD64VPSRAD256(v) + case OpAMD64VPSRAD512: + return rewriteValueAMD64_OpAMD64VPSRAD512(v) + case OpAMD64VPSRAD512const: + return rewriteValueAMD64_OpAMD64VPSRAD512const(v) + case OpAMD64VPSRADMasked128: + return rewriteValueAMD64_OpAMD64VPSRADMasked128(v) + case OpAMD64VPSRADMasked128const: + return rewriteValueAMD64_OpAMD64VPSRADMasked128const(v) + case OpAMD64VPSRADMasked256: + return rewriteValueAMD64_OpAMD64VPSRADMasked256(v) + case OpAMD64VPSRADMasked256const: + return rewriteValueAMD64_OpAMD64VPSRADMasked256const(v) + case OpAMD64VPSRADMasked512: + return rewriteValueAMD64_OpAMD64VPSRADMasked512(v) + case OpAMD64VPSRADMasked512const: + return rewriteValueAMD64_OpAMD64VPSRADMasked512const(v) + case OpAMD64VPSRAQ128: + return rewriteValueAMD64_OpAMD64VPSRAQ128(v) + case OpAMD64VPSRAQ128const: + return rewriteValueAMD64_OpAMD64VPSRAQ128const(v) + case OpAMD64VPSRAQ256: + return rewriteValueAMD64_OpAMD64VPSRAQ256(v) + case OpAMD64VPSRAQ256const: + return rewriteValueAMD64_OpAMD64VPSRAQ256const(v) + case OpAMD64VPSRAQ512: + return rewriteValueAMD64_OpAMD64VPSRAQ512(v) + case OpAMD64VPSRAQ512const: + return rewriteValueAMD64_OpAMD64VPSRAQ512const(v) + case OpAMD64VPSRAQMasked128: + return rewriteValueAMD64_OpAMD64VPSRAQMasked128(v) + case OpAMD64VPSRAQMasked128const: + return rewriteValueAMD64_OpAMD64VPSRAQMasked128const(v) + case OpAMD64VPSRAQMasked256: + return rewriteValueAMD64_OpAMD64VPSRAQMasked256(v) + case OpAMD64VPSRAQMasked256const: + return rewriteValueAMD64_OpAMD64VPSRAQMasked256const(v) + case OpAMD64VPSRAQMasked512: + return rewriteValueAMD64_OpAMD64VPSRAQMasked512(v) + case OpAMD64VPSRAQMasked512const: + return rewriteValueAMD64_OpAMD64VPSRAQMasked512const(v) + case OpAMD64VPSRAVD512: + return rewriteValueAMD64_OpAMD64VPSRAVD512(v) + case OpAMD64VPSRAVDMasked128: + return rewriteValueAMD64_OpAMD64VPSRAVDMasked128(v) + case OpAMD64VPSRAVDMasked256: + return rewriteValueAMD64_OpAMD64VPSRAVDMasked256(v) + case OpAMD64VPSRAVDMasked512: + return rewriteValueAMD64_OpAMD64VPSRAVDMasked512(v) + case OpAMD64VPSRAVQ128: + return rewriteValueAMD64_OpAMD64VPSRAVQ128(v) + case OpAMD64VPSRAVQ256: + return rewriteValueAMD64_OpAMD64VPSRAVQ256(v) + case OpAMD64VPSRAVQ512: + return rewriteValueAMD64_OpAMD64VPSRAVQ512(v) + case OpAMD64VPSRAVQMasked128: + return rewriteValueAMD64_OpAMD64VPSRAVQMasked128(v) + case OpAMD64VPSRAVQMasked256: + return rewriteValueAMD64_OpAMD64VPSRAVQMasked256(v) + case OpAMD64VPSRAVQMasked512: + return rewriteValueAMD64_OpAMD64VPSRAVQMasked512(v) + case OpAMD64VPSRAW128: + return rewriteValueAMD64_OpAMD64VPSRAW128(v) + case OpAMD64VPSRAW256: + return rewriteValueAMD64_OpAMD64VPSRAW256(v) + case OpAMD64VPSRAW512: + return rewriteValueAMD64_OpAMD64VPSRAW512(v) + case OpAMD64VPSRAWMasked128: + return rewriteValueAMD64_OpAMD64VPSRAWMasked128(v) + case OpAMD64VPSRAWMasked256: + return rewriteValueAMD64_OpAMD64VPSRAWMasked256(v) + case OpAMD64VPSRAWMasked512: + return rewriteValueAMD64_OpAMD64VPSRAWMasked512(v) + case OpAMD64VPSRLD512const: + return rewriteValueAMD64_OpAMD64VPSRLD512const(v) + case OpAMD64VPSRLDMasked128const: + return rewriteValueAMD64_OpAMD64VPSRLDMasked128const(v) + case OpAMD64VPSRLDMasked256const: + return rewriteValueAMD64_OpAMD64VPSRLDMasked256const(v) + case OpAMD64VPSRLDMasked512const: + return rewriteValueAMD64_OpAMD64VPSRLDMasked512const(v) + case OpAMD64VPSRLQ512const: + return rewriteValueAMD64_OpAMD64VPSRLQ512const(v) + case OpAMD64VPSRLQMasked128const: + return rewriteValueAMD64_OpAMD64VPSRLQMasked128const(v) + case OpAMD64VPSRLQMasked256const: + return rewriteValueAMD64_OpAMD64VPSRLQMasked256const(v) + case OpAMD64VPSRLQMasked512const: + return rewriteValueAMD64_OpAMD64VPSRLQMasked512const(v) + case OpAMD64VPSRLVD512: + return rewriteValueAMD64_OpAMD64VPSRLVD512(v) + case OpAMD64VPSRLVDMasked128: + return rewriteValueAMD64_OpAMD64VPSRLVDMasked128(v) + case OpAMD64VPSRLVDMasked256: + return rewriteValueAMD64_OpAMD64VPSRLVDMasked256(v) + case OpAMD64VPSRLVDMasked512: + return rewriteValueAMD64_OpAMD64VPSRLVDMasked512(v) + case OpAMD64VPSRLVQ512: + return rewriteValueAMD64_OpAMD64VPSRLVQ512(v) + case OpAMD64VPSRLVQMasked128: + return rewriteValueAMD64_OpAMD64VPSRLVQMasked128(v) + case OpAMD64VPSRLVQMasked256: + return rewriteValueAMD64_OpAMD64VPSRLVQMasked256(v) + case OpAMD64VPSRLVQMasked512: + return rewriteValueAMD64_OpAMD64VPSRLVQMasked512(v) + case OpAMD64VPSUBD512: + return rewriteValueAMD64_OpAMD64VPSUBD512(v) + case OpAMD64VPSUBDMasked128: + return rewriteValueAMD64_OpAMD64VPSUBDMasked128(v) + case OpAMD64VPSUBDMasked256: + return rewriteValueAMD64_OpAMD64VPSUBDMasked256(v) + case OpAMD64VPSUBDMasked512: + return rewriteValueAMD64_OpAMD64VPSUBDMasked512(v) + case OpAMD64VPSUBQ512: + return rewriteValueAMD64_OpAMD64VPSUBQ512(v) + case OpAMD64VPSUBQMasked128: + return rewriteValueAMD64_OpAMD64VPSUBQMasked128(v) + case OpAMD64VPSUBQMasked256: + return rewriteValueAMD64_OpAMD64VPSUBQMasked256(v) + case OpAMD64VPSUBQMasked512: + return rewriteValueAMD64_OpAMD64VPSUBQMasked512(v) + case OpAMD64VPTERNLOGD128: + return rewriteValueAMD64_OpAMD64VPTERNLOGD128(v) + case OpAMD64VPTERNLOGD256: + return rewriteValueAMD64_OpAMD64VPTERNLOGD256(v) + case OpAMD64VPTERNLOGD512: + return rewriteValueAMD64_OpAMD64VPTERNLOGD512(v) + case OpAMD64VPTERNLOGQ128: + return rewriteValueAMD64_OpAMD64VPTERNLOGQ128(v) + case OpAMD64VPTERNLOGQ256: + return rewriteValueAMD64_OpAMD64VPTERNLOGQ256(v) + case OpAMD64VPTERNLOGQ512: + return rewriteValueAMD64_OpAMD64VPTERNLOGQ512(v) + case OpAMD64VPUNPCKHDQ512: + return rewriteValueAMD64_OpAMD64VPUNPCKHDQ512(v) + case OpAMD64VPUNPCKHQDQ512: + return rewriteValueAMD64_OpAMD64VPUNPCKHQDQ512(v) + case OpAMD64VPUNPCKLDQ512: + return rewriteValueAMD64_OpAMD64VPUNPCKLDQ512(v) + case OpAMD64VPUNPCKLQDQ512: + return rewriteValueAMD64_OpAMD64VPUNPCKLQDQ512(v) + case OpAMD64VPXORD512: + return rewriteValueAMD64_OpAMD64VPXORD512(v) + case OpAMD64VPXORDMasked128: + return rewriteValueAMD64_OpAMD64VPXORDMasked128(v) + case OpAMD64VPXORDMasked256: + return rewriteValueAMD64_OpAMD64VPXORDMasked256(v) + case OpAMD64VPXORDMasked512: + return rewriteValueAMD64_OpAMD64VPXORDMasked512(v) + case OpAMD64VPXORQ512: + return rewriteValueAMD64_OpAMD64VPXORQ512(v) + case OpAMD64VPXORQMasked128: + return rewriteValueAMD64_OpAMD64VPXORQMasked128(v) + case OpAMD64VPXORQMasked256: + return rewriteValueAMD64_OpAMD64VPXORQMasked256(v) + case OpAMD64VPXORQMasked512: + return rewriteValueAMD64_OpAMD64VPXORQMasked512(v) + case OpAMD64VRCP14PD128: + return rewriteValueAMD64_OpAMD64VRCP14PD128(v) + case OpAMD64VRCP14PD256: + return rewriteValueAMD64_OpAMD64VRCP14PD256(v) + case OpAMD64VRCP14PD512: + return rewriteValueAMD64_OpAMD64VRCP14PD512(v) + case OpAMD64VRCP14PDMasked128: + return rewriteValueAMD64_OpAMD64VRCP14PDMasked128(v) + case OpAMD64VRCP14PDMasked256: + return rewriteValueAMD64_OpAMD64VRCP14PDMasked256(v) + case OpAMD64VRCP14PDMasked512: + return rewriteValueAMD64_OpAMD64VRCP14PDMasked512(v) + case OpAMD64VRCP14PS512: + return rewriteValueAMD64_OpAMD64VRCP14PS512(v) + case OpAMD64VRCP14PSMasked128: + return rewriteValueAMD64_OpAMD64VRCP14PSMasked128(v) + case OpAMD64VRCP14PSMasked256: + return rewriteValueAMD64_OpAMD64VRCP14PSMasked256(v) + case OpAMD64VRCP14PSMasked512: + return rewriteValueAMD64_OpAMD64VRCP14PSMasked512(v) + case OpAMD64VREDUCEPD128: + return rewriteValueAMD64_OpAMD64VREDUCEPD128(v) + case OpAMD64VREDUCEPD256: + return rewriteValueAMD64_OpAMD64VREDUCEPD256(v) + case OpAMD64VREDUCEPD512: + return rewriteValueAMD64_OpAMD64VREDUCEPD512(v) + case OpAMD64VREDUCEPDMasked128: + return rewriteValueAMD64_OpAMD64VREDUCEPDMasked128(v) + case OpAMD64VREDUCEPDMasked256: + return rewriteValueAMD64_OpAMD64VREDUCEPDMasked256(v) + case OpAMD64VREDUCEPDMasked512: + return rewriteValueAMD64_OpAMD64VREDUCEPDMasked512(v) + case OpAMD64VREDUCEPS128: + return rewriteValueAMD64_OpAMD64VREDUCEPS128(v) + case OpAMD64VREDUCEPS256: + return rewriteValueAMD64_OpAMD64VREDUCEPS256(v) + case OpAMD64VREDUCEPS512: + return rewriteValueAMD64_OpAMD64VREDUCEPS512(v) + case OpAMD64VREDUCEPSMasked128: + return rewriteValueAMD64_OpAMD64VREDUCEPSMasked128(v) + case OpAMD64VREDUCEPSMasked256: + return rewriteValueAMD64_OpAMD64VREDUCEPSMasked256(v) + case OpAMD64VREDUCEPSMasked512: + return rewriteValueAMD64_OpAMD64VREDUCEPSMasked512(v) + case OpAMD64VRNDSCALEPD128: + return rewriteValueAMD64_OpAMD64VRNDSCALEPD128(v) + case OpAMD64VRNDSCALEPD256: + return rewriteValueAMD64_OpAMD64VRNDSCALEPD256(v) + case OpAMD64VRNDSCALEPD512: + return rewriteValueAMD64_OpAMD64VRNDSCALEPD512(v) + case OpAMD64VRNDSCALEPDMasked128: + return rewriteValueAMD64_OpAMD64VRNDSCALEPDMasked128(v) + case OpAMD64VRNDSCALEPDMasked256: + return rewriteValueAMD64_OpAMD64VRNDSCALEPDMasked256(v) + case OpAMD64VRNDSCALEPDMasked512: + return rewriteValueAMD64_OpAMD64VRNDSCALEPDMasked512(v) + case OpAMD64VRNDSCALEPS128: + return rewriteValueAMD64_OpAMD64VRNDSCALEPS128(v) + case OpAMD64VRNDSCALEPS256: + return rewriteValueAMD64_OpAMD64VRNDSCALEPS256(v) + case OpAMD64VRNDSCALEPS512: + return rewriteValueAMD64_OpAMD64VRNDSCALEPS512(v) + case OpAMD64VRNDSCALEPSMasked128: + return rewriteValueAMD64_OpAMD64VRNDSCALEPSMasked128(v) + case OpAMD64VRNDSCALEPSMasked256: + return rewriteValueAMD64_OpAMD64VRNDSCALEPSMasked256(v) + case OpAMD64VRNDSCALEPSMasked512: + return rewriteValueAMD64_OpAMD64VRNDSCALEPSMasked512(v) + case OpAMD64VRSQRT14PD128: + return rewriteValueAMD64_OpAMD64VRSQRT14PD128(v) + case OpAMD64VRSQRT14PD256: + return rewriteValueAMD64_OpAMD64VRSQRT14PD256(v) + case OpAMD64VRSQRT14PD512: + return rewriteValueAMD64_OpAMD64VRSQRT14PD512(v) + case OpAMD64VRSQRT14PDMasked128: + return rewriteValueAMD64_OpAMD64VRSQRT14PDMasked128(v) + case OpAMD64VRSQRT14PDMasked256: + return rewriteValueAMD64_OpAMD64VRSQRT14PDMasked256(v) + case OpAMD64VRSQRT14PDMasked512: + return rewriteValueAMD64_OpAMD64VRSQRT14PDMasked512(v) + case OpAMD64VRSQRT14PS512: + return rewriteValueAMD64_OpAMD64VRSQRT14PS512(v) + case OpAMD64VRSQRT14PSMasked128: + return rewriteValueAMD64_OpAMD64VRSQRT14PSMasked128(v) + case OpAMD64VRSQRT14PSMasked256: + return rewriteValueAMD64_OpAMD64VRSQRT14PSMasked256(v) + case OpAMD64VRSQRT14PSMasked512: + return rewriteValueAMD64_OpAMD64VRSQRT14PSMasked512(v) + case OpAMD64VSCALEFPD128: + return rewriteValueAMD64_OpAMD64VSCALEFPD128(v) + case OpAMD64VSCALEFPD256: + return rewriteValueAMD64_OpAMD64VSCALEFPD256(v) + case OpAMD64VSCALEFPD512: + return rewriteValueAMD64_OpAMD64VSCALEFPD512(v) + case OpAMD64VSCALEFPDMasked128: + return rewriteValueAMD64_OpAMD64VSCALEFPDMasked128(v) + case OpAMD64VSCALEFPDMasked256: + return rewriteValueAMD64_OpAMD64VSCALEFPDMasked256(v) + case OpAMD64VSCALEFPDMasked512: + return rewriteValueAMD64_OpAMD64VSCALEFPDMasked512(v) + case OpAMD64VSCALEFPS128: + return rewriteValueAMD64_OpAMD64VSCALEFPS128(v) + case OpAMD64VSCALEFPS256: + return rewriteValueAMD64_OpAMD64VSCALEFPS256(v) + case OpAMD64VSCALEFPS512: + return rewriteValueAMD64_OpAMD64VSCALEFPS512(v) + case OpAMD64VSCALEFPSMasked128: + return rewriteValueAMD64_OpAMD64VSCALEFPSMasked128(v) + case OpAMD64VSCALEFPSMasked256: + return rewriteValueAMD64_OpAMD64VSCALEFPSMasked256(v) + case OpAMD64VSCALEFPSMasked512: + return rewriteValueAMD64_OpAMD64VSCALEFPSMasked512(v) + case OpAMD64VSHUFPD512: + return rewriteValueAMD64_OpAMD64VSHUFPD512(v) + case OpAMD64VSHUFPS512: + return rewriteValueAMD64_OpAMD64VSHUFPS512(v) + case OpAMD64VSQRTPD512: + return rewriteValueAMD64_OpAMD64VSQRTPD512(v) + case OpAMD64VSQRTPDMasked128: + return rewriteValueAMD64_OpAMD64VSQRTPDMasked128(v) + case OpAMD64VSQRTPDMasked256: + return rewriteValueAMD64_OpAMD64VSQRTPDMasked256(v) + case OpAMD64VSQRTPDMasked512: + return rewriteValueAMD64_OpAMD64VSQRTPDMasked512(v) + case OpAMD64VSQRTPS512: + return rewriteValueAMD64_OpAMD64VSQRTPS512(v) + case OpAMD64VSQRTPSMasked128: + return rewriteValueAMD64_OpAMD64VSQRTPSMasked128(v) + case OpAMD64VSQRTPSMasked256: + return rewriteValueAMD64_OpAMD64VSQRTPSMasked256(v) + case OpAMD64VSQRTPSMasked512: + return rewriteValueAMD64_OpAMD64VSQRTPSMasked512(v) + case OpAMD64VSUBPD512: + return rewriteValueAMD64_OpAMD64VSUBPD512(v) + case OpAMD64VSUBPDMasked128: + return rewriteValueAMD64_OpAMD64VSUBPDMasked128(v) + case OpAMD64VSUBPDMasked256: + return rewriteValueAMD64_OpAMD64VSUBPDMasked256(v) + case OpAMD64VSUBPDMasked512: + return rewriteValueAMD64_OpAMD64VSUBPDMasked512(v) + case OpAMD64VSUBPS512: + return rewriteValueAMD64_OpAMD64VSUBPS512(v) + case OpAMD64VSUBPSMasked128: + return rewriteValueAMD64_OpAMD64VSUBPSMasked128(v) + case OpAMD64VSUBPSMasked256: + return rewriteValueAMD64_OpAMD64VSUBPSMasked256(v) + case OpAMD64VSUBPSMasked512: + return rewriteValueAMD64_OpAMD64VSUBPSMasked512(v) + case OpAMD64XADDLlock: + return rewriteValueAMD64_OpAMD64XADDLlock(v) + case OpAMD64XADDQlock: + return rewriteValueAMD64_OpAMD64XADDQlock(v) + case OpAMD64XCHGL: + return rewriteValueAMD64_OpAMD64XCHGL(v) + case OpAMD64XCHGQ: + return rewriteValueAMD64_OpAMD64XCHGQ(v) + case OpAMD64XORL: + return rewriteValueAMD64_OpAMD64XORL(v) + case OpAMD64XORLconst: + return rewriteValueAMD64_OpAMD64XORLconst(v) + case OpAMD64XORLconstmodify: + return rewriteValueAMD64_OpAMD64XORLconstmodify(v) + case OpAMD64XORLload: + return rewriteValueAMD64_OpAMD64XORLload(v) + case OpAMD64XORLmodify: + return rewriteValueAMD64_OpAMD64XORLmodify(v) + case OpAMD64XORQ: + return rewriteValueAMD64_OpAMD64XORQ(v) + case OpAMD64XORQconst: + return rewriteValueAMD64_OpAMD64XORQconst(v) + case OpAMD64XORQconstmodify: + return rewriteValueAMD64_OpAMD64XORQconstmodify(v) + case OpAMD64XORQload: + return rewriteValueAMD64_OpAMD64XORQload(v) + case OpAMD64XORQmodify: + return rewriteValueAMD64_OpAMD64XORQmodify(v) + case OpAbsInt16x16: + v.Op = OpAMD64VPABSW256 + return true + case OpAbsInt16x32: + v.Op = OpAMD64VPABSW512 + return true + case OpAbsInt16x8: + v.Op = OpAMD64VPABSW128 + return true + case OpAbsInt32x16: + v.Op = OpAMD64VPABSD512 + return true + case OpAbsInt32x4: + v.Op = OpAMD64VPABSD128 + return true + case OpAbsInt32x8: + v.Op = OpAMD64VPABSD256 + return true + case OpAbsInt64x2: + v.Op = OpAMD64VPABSQ128 + return true + case OpAbsInt64x4: + v.Op = OpAMD64VPABSQ256 + return true + case OpAbsInt64x8: + v.Op = OpAMD64VPABSQ512 + return true + case OpAbsInt8x16: + v.Op = OpAMD64VPABSB128 + return true + case OpAbsInt8x32: + v.Op = OpAMD64VPABSB256 + return true + case OpAbsInt8x64: + v.Op = OpAMD64VPABSB512 + return true + case OpAdd16: + v.Op = OpAMD64ADDL + return true + case OpAdd32: + v.Op = OpAMD64ADDL + return true + case OpAdd32F: + v.Op = OpAMD64ADDSS + return true + case OpAdd64: + v.Op = OpAMD64ADDQ + return true + case OpAdd64F: + v.Op = OpAMD64ADDSD + return true + case OpAdd8: + v.Op = OpAMD64ADDL + return true + case OpAddFloat32x16: + v.Op = OpAMD64VADDPS512 + return true + case OpAddFloat32x4: + v.Op = OpAMD64VADDPS128 + return true + case OpAddFloat32x8: + v.Op = OpAMD64VADDPS256 + return true + case OpAddFloat64x2: + v.Op = OpAMD64VADDPD128 + return true + case OpAddFloat64x4: + v.Op = OpAMD64VADDPD256 + return true + case OpAddFloat64x8: + v.Op = OpAMD64VADDPD512 + return true + case OpAddInt16x16: + v.Op = OpAMD64VPADDW256 + return true + case OpAddInt16x32: + v.Op = OpAMD64VPADDW512 + return true + case OpAddInt16x8: + v.Op = OpAMD64VPADDW128 + return true + case OpAddInt32x16: + v.Op = OpAMD64VPADDD512 + return true + case OpAddInt32x4: + v.Op = OpAMD64VPADDD128 + return true + case OpAddInt32x8: + v.Op = OpAMD64VPADDD256 + return true + case OpAddInt64x2: + v.Op = OpAMD64VPADDQ128 + return true + case OpAddInt64x4: + v.Op = OpAMD64VPADDQ256 + return true + case OpAddInt64x8: + v.Op = OpAMD64VPADDQ512 + return true + case OpAddInt8x16: + v.Op = OpAMD64VPADDB128 + return true + case OpAddInt8x32: + v.Op = OpAMD64VPADDB256 + return true + case OpAddInt8x64: + v.Op = OpAMD64VPADDB512 + return true + case OpAddPairsFloat32x4: + v.Op = OpAMD64VHADDPS128 + return true + case OpAddPairsFloat64x2: + v.Op = OpAMD64VHADDPD128 + return true + case OpAddPairsGroupedFloat32x8: + v.Op = OpAMD64VHADDPS256 + return true + case OpAddPairsGroupedFloat64x4: + v.Op = OpAMD64VHADDPD256 + return true + case OpAddPairsGroupedInt16x16: + v.Op = OpAMD64VPHADDW256 + return true + case OpAddPairsGroupedInt32x8: + v.Op = OpAMD64VPHADDD256 + return true + case OpAddPairsGroupedUint16x16: + v.Op = OpAMD64VPHADDW256 + return true + case OpAddPairsGroupedUint32x8: + v.Op = OpAMD64VPHADDD256 + return true + case OpAddPairsInt16x8: + v.Op = OpAMD64VPHADDW128 + return true + case OpAddPairsInt32x4: + v.Op = OpAMD64VPHADDD128 + return true + case OpAddPairsSaturatedGroupedInt16x16: + v.Op = OpAMD64VPHADDSW256 + return true + case OpAddPairsSaturatedInt16x8: + v.Op = OpAMD64VPHADDSW128 + return true + case OpAddPairsUint16x8: + v.Op = OpAMD64VPHADDW128 + return true + case OpAddPairsUint32x4: + v.Op = OpAMD64VPHADDD128 + return true + case OpAddPtr: + v.Op = OpAMD64ADDQ + return true + case OpAddSaturatedInt16x16: + v.Op = OpAMD64VPADDSW256 + return true + case OpAddSaturatedInt16x32: + v.Op = OpAMD64VPADDSW512 + return true + case OpAddSaturatedInt16x8: + v.Op = OpAMD64VPADDSW128 + return true + case OpAddSaturatedInt8x16: + v.Op = OpAMD64VPADDSB128 + return true + case OpAddSaturatedInt8x32: + v.Op = OpAMD64VPADDSB256 + return true + case OpAddSaturatedInt8x64: + v.Op = OpAMD64VPADDSB512 + return true + case OpAddSaturatedUint16x16: + v.Op = OpAMD64VPADDUSW256 + return true + case OpAddSaturatedUint16x32: + v.Op = OpAMD64VPADDUSW512 + return true + case OpAddSaturatedUint16x8: + v.Op = OpAMD64VPADDUSW128 + return true + case OpAddSaturatedUint8x16: + v.Op = OpAMD64VPADDUSB128 + return true + case OpAddSaturatedUint8x32: + v.Op = OpAMD64VPADDUSB256 + return true + case OpAddSaturatedUint8x64: + v.Op = OpAMD64VPADDUSB512 + return true + case OpAddSubFloat32x4: + v.Op = OpAMD64VADDSUBPS128 + return true + case OpAddSubFloat32x8: + v.Op = OpAMD64VADDSUBPS256 + return true + case OpAddSubFloat64x2: + v.Op = OpAMD64VADDSUBPD128 + return true + case OpAddSubFloat64x4: + v.Op = OpAMD64VADDSUBPD256 + return true + case OpAddUint16x16: + v.Op = OpAMD64VPADDW256 + return true + case OpAddUint16x32: + v.Op = OpAMD64VPADDW512 + return true + case OpAddUint16x8: + v.Op = OpAMD64VPADDW128 + return true + case OpAddUint32x16: + v.Op = OpAMD64VPADDD512 + return true + case OpAddUint32x4: + v.Op = OpAMD64VPADDD128 + return true + case OpAddUint32x8: + v.Op = OpAMD64VPADDD256 + return true + case OpAddUint64x2: + v.Op = OpAMD64VPADDQ128 + return true + case OpAddUint64x4: + v.Op = OpAMD64VPADDQ256 + return true + case OpAddUint64x8: + v.Op = OpAMD64VPADDQ512 + return true + case OpAddUint8x16: + v.Op = OpAMD64VPADDB128 + return true + case OpAddUint8x32: + v.Op = OpAMD64VPADDB256 + return true + case OpAddUint8x64: + v.Op = OpAMD64VPADDB512 + return true + case OpAddr: + return rewriteValueAMD64_OpAddr(v) + case OpAnd16: + v.Op = OpAMD64ANDL + return true + case OpAnd32: + v.Op = OpAMD64ANDL + return true + case OpAnd64: + v.Op = OpAMD64ANDQ + return true + case OpAnd8: + v.Op = OpAMD64ANDL + return true + case OpAndB: + v.Op = OpAMD64ANDL + return true + case OpAndInt16x16: + v.Op = OpAMD64VPAND256 + return true + case OpAndInt16x32: + v.Op = OpAMD64VPANDD512 + return true + case OpAndInt16x8: + v.Op = OpAMD64VPAND128 + return true + case OpAndInt32x16: + v.Op = OpAMD64VPANDD512 + return true + case OpAndInt32x4: + v.Op = OpAMD64VPAND128 + return true + case OpAndInt32x8: + v.Op = OpAMD64VPAND256 + return true + case OpAndInt64x2: + v.Op = OpAMD64VPAND128 + return true + case OpAndInt64x4: + v.Op = OpAMD64VPAND256 + return true + case OpAndInt64x8: + v.Op = OpAMD64VPANDQ512 + return true + case OpAndInt8x16: + v.Op = OpAMD64VPAND128 + return true + case OpAndInt8x32: + v.Op = OpAMD64VPAND256 + return true + case OpAndInt8x64: + v.Op = OpAMD64VPANDD512 + return true + case OpAndNotInt16x16: + v.Op = OpAMD64VPANDN256 + return true + case OpAndNotInt16x32: + v.Op = OpAMD64VPANDND512 + return true + case OpAndNotInt16x8: + v.Op = OpAMD64VPANDN128 + return true + case OpAndNotInt32x16: + v.Op = OpAMD64VPANDND512 + return true + case OpAndNotInt32x4: + v.Op = OpAMD64VPANDN128 + return true + case OpAndNotInt32x8: + v.Op = OpAMD64VPANDN256 + return true + case OpAndNotInt64x2: + v.Op = OpAMD64VPANDN128 + return true + case OpAndNotInt64x4: + v.Op = OpAMD64VPANDN256 + return true + case OpAndNotInt64x8: + v.Op = OpAMD64VPANDNQ512 + return true + case OpAndNotInt8x16: + v.Op = OpAMD64VPANDN128 + return true + case OpAndNotInt8x32: + v.Op = OpAMD64VPANDN256 + return true + case OpAndNotInt8x64: + v.Op = OpAMD64VPANDND512 + return true + case OpAndNotUint16x16: + v.Op = OpAMD64VPANDN256 + return true + case OpAndNotUint16x32: + v.Op = OpAMD64VPANDND512 + return true + case OpAndNotUint16x8: + v.Op = OpAMD64VPANDN128 + return true + case OpAndNotUint32x16: + v.Op = OpAMD64VPANDND512 + return true + case OpAndNotUint32x4: + v.Op = OpAMD64VPANDN128 + return true + case OpAndNotUint32x8: + v.Op = OpAMD64VPANDN256 + return true + case OpAndNotUint64x2: + v.Op = OpAMD64VPANDN128 + return true + case OpAndNotUint64x4: + v.Op = OpAMD64VPANDN256 + return true + case OpAndNotUint64x8: + v.Op = OpAMD64VPANDNQ512 + return true + case OpAndNotUint8x16: + v.Op = OpAMD64VPANDN128 + return true + case OpAndNotUint8x32: + v.Op = OpAMD64VPANDN256 + return true + case OpAndNotUint8x64: + v.Op = OpAMD64VPANDND512 + return true + case OpAndUint16x16: + v.Op = OpAMD64VPAND256 + return true + case OpAndUint16x32: + v.Op = OpAMD64VPANDD512 + return true + case OpAndUint16x8: + v.Op = OpAMD64VPAND128 + return true + case OpAndUint32x16: + v.Op = OpAMD64VPANDD512 + return true + case OpAndUint32x4: + v.Op = OpAMD64VPAND128 + return true + case OpAndUint32x8: + v.Op = OpAMD64VPAND256 + return true + case OpAndUint64x2: + v.Op = OpAMD64VPAND128 + return true + case OpAndUint64x4: + v.Op = OpAMD64VPAND256 + return true + case OpAndUint64x8: + v.Op = OpAMD64VPANDQ512 + return true + case OpAndUint8x16: + v.Op = OpAMD64VPAND128 + return true + case OpAndUint8x32: + v.Op = OpAMD64VPAND256 + return true + case OpAndUint8x64: + v.Op = OpAMD64VPANDD512 + return true + case OpAtomicAdd32: + return rewriteValueAMD64_OpAtomicAdd32(v) + case OpAtomicAdd64: + return rewriteValueAMD64_OpAtomicAdd64(v) + case OpAtomicAnd32: + return rewriteValueAMD64_OpAtomicAnd32(v) + case OpAtomicAnd32value: + return rewriteValueAMD64_OpAtomicAnd32value(v) + case OpAtomicAnd64value: + return rewriteValueAMD64_OpAtomicAnd64value(v) + case OpAtomicAnd8: + return rewriteValueAMD64_OpAtomicAnd8(v) + case OpAtomicCompareAndSwap32: + return rewriteValueAMD64_OpAtomicCompareAndSwap32(v) + case OpAtomicCompareAndSwap64: + return rewriteValueAMD64_OpAtomicCompareAndSwap64(v) + case OpAtomicExchange32: + return rewriteValueAMD64_OpAtomicExchange32(v) + case OpAtomicExchange64: + return rewriteValueAMD64_OpAtomicExchange64(v) + case OpAtomicExchange8: + return rewriteValueAMD64_OpAtomicExchange8(v) + case OpAtomicLoad32: + return rewriteValueAMD64_OpAtomicLoad32(v) + case OpAtomicLoad64: + return rewriteValueAMD64_OpAtomicLoad64(v) + case OpAtomicLoad8: + return rewriteValueAMD64_OpAtomicLoad8(v) + case OpAtomicLoadPtr: + return rewriteValueAMD64_OpAtomicLoadPtr(v) + case OpAtomicOr32: + return rewriteValueAMD64_OpAtomicOr32(v) + case OpAtomicOr32value: + return rewriteValueAMD64_OpAtomicOr32value(v) + case OpAtomicOr64value: + return rewriteValueAMD64_OpAtomicOr64value(v) + case OpAtomicOr8: + return rewriteValueAMD64_OpAtomicOr8(v) + case OpAtomicStore32: + return rewriteValueAMD64_OpAtomicStore32(v) + case OpAtomicStore64: + return rewriteValueAMD64_OpAtomicStore64(v) + case OpAtomicStore8: + return rewriteValueAMD64_OpAtomicStore8(v) + case OpAtomicStorePtrNoWB: + return rewriteValueAMD64_OpAtomicStorePtrNoWB(v) + case OpAverageUint16x16: + v.Op = OpAMD64VPAVGW256 + return true + case OpAverageUint16x32: + v.Op = OpAMD64VPAVGW512 + return true + case OpAverageUint16x8: + v.Op = OpAMD64VPAVGW128 + return true + case OpAverageUint8x16: + v.Op = OpAMD64VPAVGB128 + return true + case OpAverageUint8x32: + v.Op = OpAMD64VPAVGB256 + return true + case OpAverageUint8x64: + v.Op = OpAMD64VPAVGB512 + return true + case OpAvg64u: + v.Op = OpAMD64AVGQU + return true + case OpBitLen16: + return rewriteValueAMD64_OpBitLen16(v) + case OpBitLen32: + return rewriteValueAMD64_OpBitLen32(v) + case OpBitLen64: + return rewriteValueAMD64_OpBitLen64(v) + case OpBitLen8: + return rewriteValueAMD64_OpBitLen8(v) + case OpBroadcast1To16Float32x4: + v.Op = OpAMD64VBROADCASTSS512 + return true + case OpBroadcast1To16Int16x8: + v.Op = OpAMD64VPBROADCASTW256 + return true + case OpBroadcast1To16Int32x4: + v.Op = OpAMD64VPBROADCASTD512 + return true + case OpBroadcast1To16Int8x16: + v.Op = OpAMD64VPBROADCASTB128 + return true + case OpBroadcast1To16Uint16x8: + v.Op = OpAMD64VPBROADCASTW256 + return true + case OpBroadcast1To16Uint32x4: + v.Op = OpAMD64VPBROADCASTD512 + return true + case OpBroadcast1To16Uint8x16: + v.Op = OpAMD64VPBROADCASTB128 + return true + case OpBroadcast1To2Float64x2: + v.Op = OpAMD64VPBROADCASTQ128 + return true + case OpBroadcast1To2Int64x2: + v.Op = OpAMD64VPBROADCASTQ128 + return true + case OpBroadcast1To2Uint64x2: + v.Op = OpAMD64VPBROADCASTQ128 + return true + case OpBroadcast1To32Int16x8: + v.Op = OpAMD64VPBROADCASTW512 + return true + case OpBroadcast1To32Int8x16: + v.Op = OpAMD64VPBROADCASTB256 + return true + case OpBroadcast1To32Uint16x8: + v.Op = OpAMD64VPBROADCASTW512 + return true + case OpBroadcast1To32Uint8x16: + v.Op = OpAMD64VPBROADCASTB256 + return true + case OpBroadcast1To4Float32x4: + v.Op = OpAMD64VBROADCASTSS128 + return true + case OpBroadcast1To4Float64x2: + v.Op = OpAMD64VBROADCASTSD256 + return true + case OpBroadcast1To4Int32x4: + v.Op = OpAMD64VPBROADCASTD128 + return true + case OpBroadcast1To4Int64x2: + v.Op = OpAMD64VPBROADCASTQ256 + return true + case OpBroadcast1To4Uint32x4: + v.Op = OpAMD64VPBROADCASTD128 + return true + case OpBroadcast1To4Uint64x2: + v.Op = OpAMD64VPBROADCASTQ256 + return true + case OpBroadcast1To64Int8x16: + v.Op = OpAMD64VPBROADCASTB512 + return true + case OpBroadcast1To64Uint8x16: + v.Op = OpAMD64VPBROADCASTB512 + return true + case OpBroadcast1To8Float32x4: + v.Op = OpAMD64VBROADCASTSS256 + return true + case OpBroadcast1To8Float64x2: + v.Op = OpAMD64VBROADCASTSD512 + return true + case OpBroadcast1To8Int16x8: + v.Op = OpAMD64VPBROADCASTW128 + return true + case OpBroadcast1To8Int32x4: + v.Op = OpAMD64VPBROADCASTD256 + return true + case OpBroadcast1To8Int64x2: + v.Op = OpAMD64VPBROADCASTQ512 + return true + case OpBroadcast1To8Uint16x8: + v.Op = OpAMD64VPBROADCASTW128 + return true + case OpBroadcast1To8Uint32x4: + v.Op = OpAMD64VPBROADCASTD256 + return true + case OpBroadcast1To8Uint64x2: + v.Op = OpAMD64VPBROADCASTQ512 + return true + case OpBswap16: + return rewriteValueAMD64_OpBswap16(v) + case OpBswap32: + v.Op = OpAMD64BSWAPL + return true + case OpBswap64: + v.Op = OpAMD64BSWAPQ + return true + case OpCeil: + return rewriteValueAMD64_OpCeil(v) + case OpCeilFloat32x4: + return rewriteValueAMD64_OpCeilFloat32x4(v) + case OpCeilFloat32x8: + return rewriteValueAMD64_OpCeilFloat32x8(v) + case OpCeilFloat64x2: + return rewriteValueAMD64_OpCeilFloat64x2(v) + case OpCeilFloat64x4: + return rewriteValueAMD64_OpCeilFloat64x4(v) + case OpCeilScaledFloat32x16: + return rewriteValueAMD64_OpCeilScaledFloat32x16(v) + case OpCeilScaledFloat32x4: + return rewriteValueAMD64_OpCeilScaledFloat32x4(v) + case OpCeilScaledFloat32x8: + return rewriteValueAMD64_OpCeilScaledFloat32x8(v) + case OpCeilScaledFloat64x2: + return rewriteValueAMD64_OpCeilScaledFloat64x2(v) + case OpCeilScaledFloat64x4: + return rewriteValueAMD64_OpCeilScaledFloat64x4(v) + case OpCeilScaledFloat64x8: + return rewriteValueAMD64_OpCeilScaledFloat64x8(v) + case OpCeilScaledResidueFloat32x16: + return rewriteValueAMD64_OpCeilScaledResidueFloat32x16(v) + case OpCeilScaledResidueFloat32x4: + return rewriteValueAMD64_OpCeilScaledResidueFloat32x4(v) + case OpCeilScaledResidueFloat32x8: + return rewriteValueAMD64_OpCeilScaledResidueFloat32x8(v) + case OpCeilScaledResidueFloat64x2: + return rewriteValueAMD64_OpCeilScaledResidueFloat64x2(v) + case OpCeilScaledResidueFloat64x4: + return rewriteValueAMD64_OpCeilScaledResidueFloat64x4(v) + case OpCeilScaledResidueFloat64x8: + return rewriteValueAMD64_OpCeilScaledResidueFloat64x8(v) + case OpClosureCall: + v.Op = OpAMD64CALLclosure + return true + case OpCom16: + v.Op = OpAMD64NOTL + return true + case OpCom32: + v.Op = OpAMD64NOTL + return true + case OpCom64: + v.Op = OpAMD64NOTQ + return true + case OpCom8: + v.Op = OpAMD64NOTL + return true + case OpCompressFloat32x16: + return rewriteValueAMD64_OpCompressFloat32x16(v) + case OpCompressFloat32x4: + return rewriteValueAMD64_OpCompressFloat32x4(v) + case OpCompressFloat32x8: + return rewriteValueAMD64_OpCompressFloat32x8(v) + case OpCompressFloat64x2: + return rewriteValueAMD64_OpCompressFloat64x2(v) + case OpCompressFloat64x4: + return rewriteValueAMD64_OpCompressFloat64x4(v) + case OpCompressFloat64x8: + return rewriteValueAMD64_OpCompressFloat64x8(v) + case OpCompressInt16x16: + return rewriteValueAMD64_OpCompressInt16x16(v) + case OpCompressInt16x32: + return rewriteValueAMD64_OpCompressInt16x32(v) + case OpCompressInt16x8: + return rewriteValueAMD64_OpCompressInt16x8(v) + case OpCompressInt32x16: + return rewriteValueAMD64_OpCompressInt32x16(v) + case OpCompressInt32x4: + return rewriteValueAMD64_OpCompressInt32x4(v) + case OpCompressInt32x8: + return rewriteValueAMD64_OpCompressInt32x8(v) + case OpCompressInt64x2: + return rewriteValueAMD64_OpCompressInt64x2(v) + case OpCompressInt64x4: + return rewriteValueAMD64_OpCompressInt64x4(v) + case OpCompressInt64x8: + return rewriteValueAMD64_OpCompressInt64x8(v) + case OpCompressInt8x16: + return rewriteValueAMD64_OpCompressInt8x16(v) + case OpCompressInt8x32: + return rewriteValueAMD64_OpCompressInt8x32(v) + case OpCompressInt8x64: + return rewriteValueAMD64_OpCompressInt8x64(v) + case OpCompressUint16x16: + return rewriteValueAMD64_OpCompressUint16x16(v) + case OpCompressUint16x32: + return rewriteValueAMD64_OpCompressUint16x32(v) + case OpCompressUint16x8: + return rewriteValueAMD64_OpCompressUint16x8(v) + case OpCompressUint32x16: + return rewriteValueAMD64_OpCompressUint32x16(v) + case OpCompressUint32x4: + return rewriteValueAMD64_OpCompressUint32x4(v) + case OpCompressUint32x8: + return rewriteValueAMD64_OpCompressUint32x8(v) + case OpCompressUint64x2: + return rewriteValueAMD64_OpCompressUint64x2(v) + case OpCompressUint64x4: + return rewriteValueAMD64_OpCompressUint64x4(v) + case OpCompressUint64x8: + return rewriteValueAMD64_OpCompressUint64x8(v) + case OpCompressUint8x16: + return rewriteValueAMD64_OpCompressUint8x16(v) + case OpCompressUint8x32: + return rewriteValueAMD64_OpCompressUint8x32(v) + case OpCompressUint8x64: + return rewriteValueAMD64_OpCompressUint8x64(v) + case OpConcatPermuteFloat32x16: + v.Op = OpAMD64VPERMI2PS512 + return true + case OpConcatPermuteFloat32x4: + v.Op = OpAMD64VPERMI2PS128 + return true + case OpConcatPermuteFloat32x8: + v.Op = OpAMD64VPERMI2PS256 + return true + case OpConcatPermuteFloat64x2: + v.Op = OpAMD64VPERMI2PD128 + return true + case OpConcatPermuteFloat64x4: + v.Op = OpAMD64VPERMI2PD256 + return true + case OpConcatPermuteFloat64x8: + v.Op = OpAMD64VPERMI2PD512 + return true + case OpConcatPermuteInt16x16: + v.Op = OpAMD64VPERMI2W256 + return true + case OpConcatPermuteInt16x32: + v.Op = OpAMD64VPERMI2W512 + return true + case OpConcatPermuteInt16x8: + v.Op = OpAMD64VPERMI2W128 + return true + case OpConcatPermuteInt32x16: + v.Op = OpAMD64VPERMI2D512 + return true + case OpConcatPermuteInt32x4: + v.Op = OpAMD64VPERMI2D128 + return true + case OpConcatPermuteInt32x8: + v.Op = OpAMD64VPERMI2D256 + return true + case OpConcatPermuteInt64x2: + v.Op = OpAMD64VPERMI2Q128 + return true + case OpConcatPermuteInt64x4: + v.Op = OpAMD64VPERMI2Q256 + return true + case OpConcatPermuteInt64x8: + v.Op = OpAMD64VPERMI2Q512 + return true + case OpConcatPermuteInt8x16: + v.Op = OpAMD64VPERMI2B128 + return true + case OpConcatPermuteInt8x32: + v.Op = OpAMD64VPERMI2B256 + return true + case OpConcatPermuteInt8x64: + v.Op = OpAMD64VPERMI2B512 + return true + case OpConcatPermuteUint16x16: + v.Op = OpAMD64VPERMI2W256 + return true + case OpConcatPermuteUint16x32: + v.Op = OpAMD64VPERMI2W512 + return true + case OpConcatPermuteUint16x8: + v.Op = OpAMD64VPERMI2W128 + return true + case OpConcatPermuteUint32x16: + v.Op = OpAMD64VPERMI2D512 + return true + case OpConcatPermuteUint32x4: + v.Op = OpAMD64VPERMI2D128 + return true + case OpConcatPermuteUint32x8: + v.Op = OpAMD64VPERMI2D256 + return true + case OpConcatPermuteUint64x2: + v.Op = OpAMD64VPERMI2Q128 + return true + case OpConcatPermuteUint64x4: + v.Op = OpAMD64VPERMI2Q256 + return true + case OpConcatPermuteUint64x8: + v.Op = OpAMD64VPERMI2Q512 + return true + case OpConcatPermuteUint8x16: + v.Op = OpAMD64VPERMI2B128 + return true + case OpConcatPermuteUint8x32: + v.Op = OpAMD64VPERMI2B256 + return true + case OpConcatPermuteUint8x64: + v.Op = OpAMD64VPERMI2B512 + return true + case OpConcatShiftBytesRightGroupedUint8x32: + v.Op = OpAMD64VPALIGNR256 + return true + case OpConcatShiftBytesRightGroupedUint8x64: + v.Op = OpAMD64VPALIGNR512 + return true + case OpConcatShiftBytesRightUint8x16: + v.Op = OpAMD64VPALIGNR128 + return true + case OpCondSelect: + return rewriteValueAMD64_OpCondSelect(v) + case OpConst16: + return rewriteValueAMD64_OpConst16(v) + case OpConst32: + v.Op = OpAMD64MOVLconst + return true + case OpConst32F: + v.Op = OpAMD64MOVSSconst + return true + case OpConst64: + v.Op = OpAMD64MOVQconst + return true + case OpConst64F: + v.Op = OpAMD64MOVSDconst + return true + case OpConst8: + return rewriteValueAMD64_OpConst8(v) + case OpConstBool: + return rewriteValueAMD64_OpConstBool(v) + case OpConstNil: + return rewriteValueAMD64_OpConstNil(v) + case OpConvertToFloat32Float64x2: + v.Op = OpAMD64VCVTPD2PSX128 + return true + case OpConvertToFloat32Float64x4: + v.Op = OpAMD64VCVTPD2PSY128 + return true + case OpConvertToFloat32Float64x8: + v.Op = OpAMD64VCVTPD2PS256 + return true + case OpConvertToFloat32Int32x16: + v.Op = OpAMD64VCVTDQ2PS512 + return true + case OpConvertToFloat32Int32x4: + v.Op = OpAMD64VCVTDQ2PS128 + return true + case OpConvertToFloat32Int32x8: + v.Op = OpAMD64VCVTDQ2PS256 + return true + case OpConvertToFloat32Int64x2: + v.Op = OpAMD64VCVTQQ2PSX128 + return true + case OpConvertToFloat32Int64x4: + v.Op = OpAMD64VCVTQQ2PSY128 + return true + case OpConvertToFloat32Int64x8: + v.Op = OpAMD64VCVTQQ2PS256 + return true + case OpConvertToFloat32Uint32x16: + v.Op = OpAMD64VCVTUDQ2PS512 + return true + case OpConvertToFloat32Uint32x4: + v.Op = OpAMD64VCVTUDQ2PS128 + return true + case OpConvertToFloat32Uint32x8: + v.Op = OpAMD64VCVTUDQ2PS256 + return true + case OpConvertToFloat32Uint64x2: + v.Op = OpAMD64VCVTUQQ2PSX128 + return true + case OpConvertToFloat32Uint64x4: + v.Op = OpAMD64VCVTUQQ2PSY128 + return true + case OpConvertToFloat32Uint64x8: + v.Op = OpAMD64VCVTUQQ2PS256 + return true + case OpConvertToFloat64Float32x4: + v.Op = OpAMD64VCVTPS2PD256 + return true + case OpConvertToFloat64Float32x8: + v.Op = OpAMD64VCVTPS2PD512 + return true + case OpConvertToFloat64Int32x4: + v.Op = OpAMD64VCVTDQ2PD256 + return true + case OpConvertToFloat64Int32x8: + v.Op = OpAMD64VCVTDQ2PD512 + return true + case OpConvertToFloat64Int64x2: + v.Op = OpAMD64VCVTQQ2PD128 + return true + case OpConvertToFloat64Int64x4: + v.Op = OpAMD64VCVTQQ2PD256 + return true + case OpConvertToFloat64Int64x8: + v.Op = OpAMD64VCVTQQ2PD512 + return true + case OpConvertToFloat64Uint32x4: + v.Op = OpAMD64VCVTUDQ2PD256 + return true + case OpConvertToFloat64Uint32x8: + v.Op = OpAMD64VCVTUDQ2PD512 + return true + case OpConvertToFloat64Uint64x2: + v.Op = OpAMD64VCVTUQQ2PD128 + return true + case OpConvertToFloat64Uint64x4: + v.Op = OpAMD64VCVTUQQ2PD256 + return true + case OpConvertToFloat64Uint64x8: + v.Op = OpAMD64VCVTUQQ2PD512 + return true + case OpConvertToInt32Float32x16: + v.Op = OpAMD64VCVTTPS2DQ512 + return true + case OpConvertToInt32Float32x4: + v.Op = OpAMD64VCVTTPS2DQ128 + return true + case OpConvertToInt32Float32x8: + v.Op = OpAMD64VCVTTPS2DQ256 + return true + case OpConvertToInt32Float64x2: + v.Op = OpAMD64VCVTTPD2DQX128 + return true + case OpConvertToInt32Float64x4: + v.Op = OpAMD64VCVTTPD2DQY128 + return true + case OpConvertToInt32Float64x8: + v.Op = OpAMD64VCVTTPD2DQ256 + return true + case OpConvertToInt64Float32x4: + v.Op = OpAMD64VCVTTPS2QQ256 + return true + case OpConvertToInt64Float32x8: + v.Op = OpAMD64VCVTTPS2QQ512 + return true + case OpConvertToInt64Float64x2: + v.Op = OpAMD64VCVTTPD2QQ128 + return true + case OpConvertToInt64Float64x4: + v.Op = OpAMD64VCVTTPD2QQ256 + return true + case OpConvertToInt64Float64x8: + v.Op = OpAMD64VCVTTPD2QQ512 + return true + case OpConvertToUint32Float32x16: + v.Op = OpAMD64VCVTTPS2UDQ512 + return true + case OpConvertToUint32Float32x4: + v.Op = OpAMD64VCVTTPS2UDQ128 + return true + case OpConvertToUint32Float32x8: + v.Op = OpAMD64VCVTTPS2UDQ256 + return true + case OpConvertToUint32Float64x2: + v.Op = OpAMD64VCVTTPD2UDQX128 + return true + case OpConvertToUint32Float64x4: + v.Op = OpAMD64VCVTTPD2UDQY128 + return true + case OpConvertToUint32Float64x8: + v.Op = OpAMD64VCVTTPD2UDQ256 + return true + case OpConvertToUint64Float32x4: + v.Op = OpAMD64VCVTTPS2UQQ256 + return true + case OpConvertToUint64Float32x8: + v.Op = OpAMD64VCVTTPS2UQQ512 + return true + case OpConvertToUint64Float64x2: + v.Op = OpAMD64VCVTTPD2UQQ128 + return true + case OpConvertToUint64Float64x4: + v.Op = OpAMD64VCVTTPD2UQQ256 + return true + case OpConvertToUint64Float64x8: + v.Op = OpAMD64VCVTTPD2UQQ512 + return true + case OpCopySignInt16x16: + v.Op = OpAMD64VPSIGNW256 + return true + case OpCopySignInt16x8: + v.Op = OpAMD64VPSIGNW128 + return true + case OpCopySignInt32x4: + v.Op = OpAMD64VPSIGND128 + return true + case OpCopySignInt32x8: + v.Op = OpAMD64VPSIGND256 + return true + case OpCopySignInt8x16: + v.Op = OpAMD64VPSIGNB128 + return true + case OpCopySignInt8x32: + v.Op = OpAMD64VPSIGNB256 + return true + case OpCtz16: + return rewriteValueAMD64_OpCtz16(v) + case OpCtz16NonZero: + return rewriteValueAMD64_OpCtz16NonZero(v) + case OpCtz32: + return rewriteValueAMD64_OpCtz32(v) + case OpCtz32NonZero: + return rewriteValueAMD64_OpCtz32NonZero(v) + case OpCtz64: + return rewriteValueAMD64_OpCtz64(v) + case OpCtz64NonZero: + return rewriteValueAMD64_OpCtz64NonZero(v) + case OpCtz8: + return rewriteValueAMD64_OpCtz8(v) + case OpCtz8NonZero: + return rewriteValueAMD64_OpCtz8NonZero(v) + case OpCvt16toMask16x16: + return rewriteValueAMD64_OpCvt16toMask16x16(v) + case OpCvt16toMask32x16: + return rewriteValueAMD64_OpCvt16toMask32x16(v) + case OpCvt16toMask8x16: + return rewriteValueAMD64_OpCvt16toMask8x16(v) + case OpCvt32Fto32: + return rewriteValueAMD64_OpCvt32Fto32(v) + case OpCvt32Fto64: + return rewriteValueAMD64_OpCvt32Fto64(v) + case OpCvt32Fto64F: + v.Op = OpAMD64CVTSS2SD + return true + case OpCvt32to32F: + v.Op = OpAMD64CVTSL2SS + return true + case OpCvt32to64F: + v.Op = OpAMD64CVTSL2SD + return true + case OpCvt32toMask16x32: + return rewriteValueAMD64_OpCvt32toMask16x32(v) + case OpCvt32toMask8x32: + return rewriteValueAMD64_OpCvt32toMask8x32(v) + case OpCvt64Fto32: + return rewriteValueAMD64_OpCvt64Fto32(v) + case OpCvt64Fto32F: + v.Op = OpAMD64CVTSD2SS + return true + case OpCvt64Fto64: + return rewriteValueAMD64_OpCvt64Fto64(v) + case OpCvt64to32F: + v.Op = OpAMD64CVTSQ2SS + return true + case OpCvt64to64F: + v.Op = OpAMD64CVTSQ2SD + return true + case OpCvt64toMask8x64: + return rewriteValueAMD64_OpCvt64toMask8x64(v) + case OpCvt8toMask16x8: + return rewriteValueAMD64_OpCvt8toMask16x8(v) + case OpCvt8toMask32x4: + return rewriteValueAMD64_OpCvt8toMask32x4(v) + case OpCvt8toMask32x8: + return rewriteValueAMD64_OpCvt8toMask32x8(v) + case OpCvt8toMask64x2: + return rewriteValueAMD64_OpCvt8toMask64x2(v) + case OpCvt8toMask64x4: + return rewriteValueAMD64_OpCvt8toMask64x4(v) + case OpCvt8toMask64x8: + return rewriteValueAMD64_OpCvt8toMask64x8(v) + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpCvtMask16x16to16: + return rewriteValueAMD64_OpCvtMask16x16to16(v) + case OpCvtMask16x32to32: + return rewriteValueAMD64_OpCvtMask16x32to32(v) + case OpCvtMask16x8to8: + return rewriteValueAMD64_OpCvtMask16x8to8(v) + case OpCvtMask32x16to16: + return rewriteValueAMD64_OpCvtMask32x16to16(v) + case OpCvtMask32x4to8: + v.Op = OpAMD64VMOVMSKPS128 + return true + case OpCvtMask32x8to8: + v.Op = OpAMD64VMOVMSKPS256 + return true + case OpCvtMask64x2to8: + v.Op = OpAMD64VMOVMSKPD128 + return true + case OpCvtMask64x4to8: + v.Op = OpAMD64VMOVMSKPD256 + return true + case OpCvtMask64x8to8: + return rewriteValueAMD64_OpCvtMask64x8to8(v) + case OpCvtMask8x16to16: + v.Op = OpAMD64VPMOVMSKB128 + return true + case OpCvtMask8x32to32: + v.Op = OpAMD64VPMOVMSKB256 + return true + case OpCvtMask8x64to64: + return rewriteValueAMD64_OpCvtMask8x64to64(v) + case OpDiv128u: + v.Op = OpAMD64DIVQU2 + return true + case OpDiv16: + return rewriteValueAMD64_OpDiv16(v) + case OpDiv16u: + return rewriteValueAMD64_OpDiv16u(v) + case OpDiv32: + return rewriteValueAMD64_OpDiv32(v) + case OpDiv32F: + v.Op = OpAMD64DIVSS + return true + case OpDiv32u: + return rewriteValueAMD64_OpDiv32u(v) + case OpDiv64: + return rewriteValueAMD64_OpDiv64(v) + case OpDiv64F: + v.Op = OpAMD64DIVSD + return true + case OpDiv64u: + return rewriteValueAMD64_OpDiv64u(v) + case OpDiv8: + return rewriteValueAMD64_OpDiv8(v) + case OpDiv8u: + return rewriteValueAMD64_OpDiv8u(v) + case OpDivFloat32x16: + v.Op = OpAMD64VDIVPS512 + return true + case OpDivFloat32x4: + v.Op = OpAMD64VDIVPS128 + return true + case OpDivFloat32x8: + v.Op = OpAMD64VDIVPS256 + return true + case OpDivFloat64x2: + v.Op = OpAMD64VDIVPD128 + return true + case OpDivFloat64x4: + v.Op = OpAMD64VDIVPD256 + return true + case OpDivFloat64x8: + v.Op = OpAMD64VDIVPD512 + return true + case OpDotProductPairsInt16x16: + v.Op = OpAMD64VPMADDWD256 + return true + case OpDotProductPairsInt16x32: + v.Op = OpAMD64VPMADDWD512 + return true + case OpDotProductPairsInt16x8: + v.Op = OpAMD64VPMADDWD128 + return true + case OpDotProductPairsSaturatedUint8x16: + v.Op = OpAMD64VPMADDUBSW128 + return true + case OpDotProductPairsSaturatedUint8x32: + v.Op = OpAMD64VPMADDUBSW256 + return true + case OpDotProductPairsSaturatedUint8x64: + v.Op = OpAMD64VPMADDUBSW512 + return true + case OpEq16: + return rewriteValueAMD64_OpEq16(v) + case OpEq32: + return rewriteValueAMD64_OpEq32(v) + case OpEq32F: + return rewriteValueAMD64_OpEq32F(v) + case OpEq64: + return rewriteValueAMD64_OpEq64(v) + case OpEq64F: + return rewriteValueAMD64_OpEq64F(v) + case OpEq8: + return rewriteValueAMD64_OpEq8(v) + case OpEqB: + return rewriteValueAMD64_OpEqB(v) + case OpEqPtr: + return rewriteValueAMD64_OpEqPtr(v) + case OpEqualFloat32x16: + return rewriteValueAMD64_OpEqualFloat32x16(v) + case OpEqualFloat32x4: + return rewriteValueAMD64_OpEqualFloat32x4(v) + case OpEqualFloat32x8: + return rewriteValueAMD64_OpEqualFloat32x8(v) + case OpEqualFloat64x2: + return rewriteValueAMD64_OpEqualFloat64x2(v) + case OpEqualFloat64x4: + return rewriteValueAMD64_OpEqualFloat64x4(v) + case OpEqualFloat64x8: + return rewriteValueAMD64_OpEqualFloat64x8(v) + case OpEqualInt16x16: + v.Op = OpAMD64VPCMPEQW256 + return true + case OpEqualInt16x32: + return rewriteValueAMD64_OpEqualInt16x32(v) + case OpEqualInt16x8: + v.Op = OpAMD64VPCMPEQW128 + return true + case OpEqualInt32x16: + return rewriteValueAMD64_OpEqualInt32x16(v) + case OpEqualInt32x4: + v.Op = OpAMD64VPCMPEQD128 + return true + case OpEqualInt32x8: + v.Op = OpAMD64VPCMPEQD256 + return true + case OpEqualInt64x2: + v.Op = OpAMD64VPCMPEQQ128 + return true + case OpEqualInt64x4: + v.Op = OpAMD64VPCMPEQQ256 + return true + case OpEqualInt64x8: + return rewriteValueAMD64_OpEqualInt64x8(v) + case OpEqualInt8x16: + v.Op = OpAMD64VPCMPEQB128 + return true + case OpEqualInt8x32: + v.Op = OpAMD64VPCMPEQB256 + return true + case OpEqualInt8x64: + return rewriteValueAMD64_OpEqualInt8x64(v) + case OpEqualUint16x16: + v.Op = OpAMD64VPCMPEQW256 + return true + case OpEqualUint16x32: + return rewriteValueAMD64_OpEqualUint16x32(v) + case OpEqualUint16x8: + v.Op = OpAMD64VPCMPEQW128 + return true + case OpEqualUint32x16: + return rewriteValueAMD64_OpEqualUint32x16(v) + case OpEqualUint32x4: + v.Op = OpAMD64VPCMPEQD128 + return true + case OpEqualUint32x8: + v.Op = OpAMD64VPCMPEQD256 + return true + case OpEqualUint64x2: + v.Op = OpAMD64VPCMPEQQ128 + return true + case OpEqualUint64x4: + v.Op = OpAMD64VPCMPEQQ256 + return true + case OpEqualUint64x8: + return rewriteValueAMD64_OpEqualUint64x8(v) + case OpEqualUint8x16: + v.Op = OpAMD64VPCMPEQB128 + return true + case OpEqualUint8x32: + v.Op = OpAMD64VPCMPEQB256 + return true + case OpEqualUint8x64: + return rewriteValueAMD64_OpEqualUint8x64(v) + case OpExpandFloat32x16: + return rewriteValueAMD64_OpExpandFloat32x16(v) + case OpExpandFloat32x4: + return rewriteValueAMD64_OpExpandFloat32x4(v) + case OpExpandFloat32x8: + return rewriteValueAMD64_OpExpandFloat32x8(v) + case OpExpandFloat64x2: + return rewriteValueAMD64_OpExpandFloat64x2(v) + case OpExpandFloat64x4: + return rewriteValueAMD64_OpExpandFloat64x4(v) + case OpExpandFloat64x8: + return rewriteValueAMD64_OpExpandFloat64x8(v) + case OpExpandInt16x16: + return rewriteValueAMD64_OpExpandInt16x16(v) + case OpExpandInt16x32: + return rewriteValueAMD64_OpExpandInt16x32(v) + case OpExpandInt16x8: + return rewriteValueAMD64_OpExpandInt16x8(v) + case OpExpandInt32x16: + return rewriteValueAMD64_OpExpandInt32x16(v) + case OpExpandInt32x4: + return rewriteValueAMD64_OpExpandInt32x4(v) + case OpExpandInt32x8: + return rewriteValueAMD64_OpExpandInt32x8(v) + case OpExpandInt64x2: + return rewriteValueAMD64_OpExpandInt64x2(v) + case OpExpandInt64x4: + return rewriteValueAMD64_OpExpandInt64x4(v) + case OpExpandInt64x8: + return rewriteValueAMD64_OpExpandInt64x8(v) + case OpExpandInt8x16: + return rewriteValueAMD64_OpExpandInt8x16(v) + case OpExpandInt8x32: + return rewriteValueAMD64_OpExpandInt8x32(v) + case OpExpandInt8x64: + return rewriteValueAMD64_OpExpandInt8x64(v) + case OpExpandUint16x16: + return rewriteValueAMD64_OpExpandUint16x16(v) + case OpExpandUint16x32: + return rewriteValueAMD64_OpExpandUint16x32(v) + case OpExpandUint16x8: + return rewriteValueAMD64_OpExpandUint16x8(v) + case OpExpandUint32x16: + return rewriteValueAMD64_OpExpandUint32x16(v) + case OpExpandUint32x4: + return rewriteValueAMD64_OpExpandUint32x4(v) + case OpExpandUint32x8: + return rewriteValueAMD64_OpExpandUint32x8(v) + case OpExpandUint64x2: + return rewriteValueAMD64_OpExpandUint64x2(v) + case OpExpandUint64x4: + return rewriteValueAMD64_OpExpandUint64x4(v) + case OpExpandUint64x8: + return rewriteValueAMD64_OpExpandUint64x8(v) + case OpExpandUint8x16: + return rewriteValueAMD64_OpExpandUint8x16(v) + case OpExpandUint8x32: + return rewriteValueAMD64_OpExpandUint8x32(v) + case OpExpandUint8x64: + return rewriteValueAMD64_OpExpandUint8x64(v) + case OpExtendLo2ToInt64Int16x8: + v.Op = OpAMD64VPMOVSXWQ128 + return true + case OpExtendLo2ToInt64Int32x4: + v.Op = OpAMD64VPMOVSXDQ128 + return true + case OpExtendLo2ToInt64Int8x16: + v.Op = OpAMD64VPMOVSXBQ128 + return true + case OpExtendLo2ToUint64Uint16x8: + v.Op = OpAMD64VPMOVZXWQ128 + return true + case OpExtendLo2ToUint64Uint32x4: + v.Op = OpAMD64VPMOVZXDQ128 + return true + case OpExtendLo2ToUint64Uint8x16: + v.Op = OpAMD64VPMOVZXBQ128 + return true + case OpExtendLo4ToInt32Int16x8: + v.Op = OpAMD64VPMOVSXWD128 + return true + case OpExtendLo4ToInt32Int8x16: + v.Op = OpAMD64VPMOVSXBD128 + return true + case OpExtendLo4ToInt64Int16x8: + v.Op = OpAMD64VPMOVSXWQ256 + return true + case OpExtendLo4ToInt64Int8x16: + v.Op = OpAMD64VPMOVSXBQ256 + return true + case OpExtendLo4ToUint32Uint16x8: + v.Op = OpAMD64VPMOVZXWD128 + return true + case OpExtendLo4ToUint32Uint8x16: + v.Op = OpAMD64VPMOVZXBD128 + return true + case OpExtendLo4ToUint64Uint16x8: + v.Op = OpAMD64VPMOVZXWQ256 + return true + case OpExtendLo4ToUint64Uint8x16: + v.Op = OpAMD64VPMOVZXBQ256 + return true + case OpExtendLo8ToInt16Int8x16: + v.Op = OpAMD64VPMOVSXBW128 + return true + case OpExtendLo8ToInt32Int8x16: + v.Op = OpAMD64VPMOVSXBD256 + return true + case OpExtendLo8ToInt64Int8x16: + v.Op = OpAMD64VPMOVSXBQ512 + return true + case OpExtendLo8ToUint16Uint8x16: + v.Op = OpAMD64VPMOVZXBW128 + return true + case OpExtendLo8ToUint32Uint8x16: + v.Op = OpAMD64VPMOVZXBD256 + return true + case OpExtendLo8ToUint64Uint8x16: + v.Op = OpAMD64VPMOVZXBQ512 + return true + case OpExtendToInt16Int8x16: + v.Op = OpAMD64VPMOVSXBW256 + return true + case OpExtendToInt16Int8x32: + v.Op = OpAMD64VPMOVSXBW512 + return true + case OpExtendToInt32Int16x16: + v.Op = OpAMD64VPMOVSXWD512 + return true + case OpExtendToInt32Int16x8: + v.Op = OpAMD64VPMOVSXWD256 + return true + case OpExtendToInt32Int8x16: + v.Op = OpAMD64VPMOVSXBD512 + return true + case OpExtendToInt64Int16x8: + v.Op = OpAMD64VPMOVSXWQ512 + return true + case OpExtendToInt64Int32x4: + v.Op = OpAMD64VPMOVSXDQ256 + return true + case OpExtendToInt64Int32x8: + v.Op = OpAMD64VPMOVSXDQ512 + return true + case OpExtendToUint16Uint8x16: + v.Op = OpAMD64VPMOVZXBW256 + return true + case OpExtendToUint16Uint8x32: + v.Op = OpAMD64VPMOVZXBW512 + return true + case OpExtendToUint32Uint16x16: + v.Op = OpAMD64VPMOVZXWD512 + return true + case OpExtendToUint32Uint16x8: + v.Op = OpAMD64VPMOVZXWD256 + return true + case OpExtendToUint32Uint8x16: + v.Op = OpAMD64VPMOVZXBD512 + return true + case OpExtendToUint64Uint16x8: + v.Op = OpAMD64VPMOVZXWQ512 + return true + case OpExtendToUint64Uint32x4: + v.Op = OpAMD64VPMOVZXDQ256 + return true + case OpExtendToUint64Uint32x8: + v.Op = OpAMD64VPMOVZXDQ512 + return true + case OpFMA: + return rewriteValueAMD64_OpFMA(v) + case OpFloor: + return rewriteValueAMD64_OpFloor(v) + case OpFloorFloat32x4: + return rewriteValueAMD64_OpFloorFloat32x4(v) + case OpFloorFloat32x8: + return rewriteValueAMD64_OpFloorFloat32x8(v) + case OpFloorFloat64x2: + return rewriteValueAMD64_OpFloorFloat64x2(v) + case OpFloorFloat64x4: + return rewriteValueAMD64_OpFloorFloat64x4(v) + case OpFloorScaledFloat32x16: + return rewriteValueAMD64_OpFloorScaledFloat32x16(v) + case OpFloorScaledFloat32x4: + return rewriteValueAMD64_OpFloorScaledFloat32x4(v) + case OpFloorScaledFloat32x8: + return rewriteValueAMD64_OpFloorScaledFloat32x8(v) + case OpFloorScaledFloat64x2: + return rewriteValueAMD64_OpFloorScaledFloat64x2(v) + case OpFloorScaledFloat64x4: + return rewriteValueAMD64_OpFloorScaledFloat64x4(v) + case OpFloorScaledFloat64x8: + return rewriteValueAMD64_OpFloorScaledFloat64x8(v) + case OpFloorScaledResidueFloat32x16: + return rewriteValueAMD64_OpFloorScaledResidueFloat32x16(v) + case OpFloorScaledResidueFloat32x4: + return rewriteValueAMD64_OpFloorScaledResidueFloat32x4(v) + case OpFloorScaledResidueFloat32x8: + return rewriteValueAMD64_OpFloorScaledResidueFloat32x8(v) + case OpFloorScaledResidueFloat64x2: + return rewriteValueAMD64_OpFloorScaledResidueFloat64x2(v) + case OpFloorScaledResidueFloat64x4: + return rewriteValueAMD64_OpFloorScaledResidueFloat64x4(v) + case OpFloorScaledResidueFloat64x8: + return rewriteValueAMD64_OpFloorScaledResidueFloat64x8(v) + case OpGaloisFieldAffineTransformInverseUint8x16: + v.Op = OpAMD64VGF2P8AFFINEINVQB128 + return true + case OpGaloisFieldAffineTransformInverseUint8x32: + v.Op = OpAMD64VGF2P8AFFINEINVQB256 + return true + case OpGaloisFieldAffineTransformInverseUint8x64: + v.Op = OpAMD64VGF2P8AFFINEINVQB512 + return true + case OpGaloisFieldAffineTransformUint8x16: + v.Op = OpAMD64VGF2P8AFFINEQB128 + return true + case OpGaloisFieldAffineTransformUint8x32: + v.Op = OpAMD64VGF2P8AFFINEQB256 + return true + case OpGaloisFieldAffineTransformUint8x64: + v.Op = OpAMD64VGF2P8AFFINEQB512 + return true + case OpGaloisFieldMulUint8x16: + v.Op = OpAMD64VGF2P8MULB128 + return true + case OpGaloisFieldMulUint8x32: + v.Op = OpAMD64VGF2P8MULB256 + return true + case OpGaloisFieldMulUint8x64: + v.Op = OpAMD64VGF2P8MULB512 + return true + case OpGetCallerPC: + v.Op = OpAMD64LoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = OpAMD64LoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = OpAMD64LoweredGetClosurePtr + return true + case OpGetElemFloat32x4: + v.Op = OpAMD64VPEXTRD128 + return true + case OpGetElemFloat64x2: + v.Op = OpAMD64VPEXTRQ128 + return true + case OpGetElemInt16x8: + v.Op = OpAMD64VPEXTRW128 + return true + case OpGetElemInt32x4: + v.Op = OpAMD64VPEXTRD128 + return true + case OpGetElemInt64x2: + v.Op = OpAMD64VPEXTRQ128 + return true + case OpGetElemInt8x16: + v.Op = OpAMD64VPEXTRB128 + return true + case OpGetElemUint16x8: + v.Op = OpAMD64VPEXTRW128 + return true + case OpGetElemUint32x4: + v.Op = OpAMD64VPEXTRD128 + return true + case OpGetElemUint64x2: + v.Op = OpAMD64VPEXTRQ128 + return true + case OpGetElemUint8x16: + v.Op = OpAMD64VPEXTRB128 + return true + case OpGetG: + return rewriteValueAMD64_OpGetG(v) + case OpGetHiFloat32x16: + return rewriteValueAMD64_OpGetHiFloat32x16(v) + case OpGetHiFloat32x8: + return rewriteValueAMD64_OpGetHiFloat32x8(v) + case OpGetHiFloat64x4: + return rewriteValueAMD64_OpGetHiFloat64x4(v) + case OpGetHiFloat64x8: + return rewriteValueAMD64_OpGetHiFloat64x8(v) + case OpGetHiInt16x16: + return rewriteValueAMD64_OpGetHiInt16x16(v) + case OpGetHiInt16x32: + return rewriteValueAMD64_OpGetHiInt16x32(v) + case OpGetHiInt32x16: + return rewriteValueAMD64_OpGetHiInt32x16(v) + case OpGetHiInt32x8: + return rewriteValueAMD64_OpGetHiInt32x8(v) + case OpGetHiInt64x4: + return rewriteValueAMD64_OpGetHiInt64x4(v) + case OpGetHiInt64x8: + return rewriteValueAMD64_OpGetHiInt64x8(v) + case OpGetHiInt8x32: + return rewriteValueAMD64_OpGetHiInt8x32(v) + case OpGetHiInt8x64: + return rewriteValueAMD64_OpGetHiInt8x64(v) + case OpGetHiUint16x16: + return rewriteValueAMD64_OpGetHiUint16x16(v) + case OpGetHiUint16x32: + return rewriteValueAMD64_OpGetHiUint16x32(v) + case OpGetHiUint32x16: + return rewriteValueAMD64_OpGetHiUint32x16(v) + case OpGetHiUint32x8: + return rewriteValueAMD64_OpGetHiUint32x8(v) + case OpGetHiUint64x4: + return rewriteValueAMD64_OpGetHiUint64x4(v) + case OpGetHiUint64x8: + return rewriteValueAMD64_OpGetHiUint64x8(v) + case OpGetHiUint8x32: + return rewriteValueAMD64_OpGetHiUint8x32(v) + case OpGetHiUint8x64: + return rewriteValueAMD64_OpGetHiUint8x64(v) + case OpGetLoFloat32x16: + return rewriteValueAMD64_OpGetLoFloat32x16(v) + case OpGetLoFloat32x8: + return rewriteValueAMD64_OpGetLoFloat32x8(v) + case OpGetLoFloat64x4: + return rewriteValueAMD64_OpGetLoFloat64x4(v) + case OpGetLoFloat64x8: + return rewriteValueAMD64_OpGetLoFloat64x8(v) + case OpGetLoInt16x16: + return rewriteValueAMD64_OpGetLoInt16x16(v) + case OpGetLoInt16x32: + return rewriteValueAMD64_OpGetLoInt16x32(v) + case OpGetLoInt32x16: + return rewriteValueAMD64_OpGetLoInt32x16(v) + case OpGetLoInt32x8: + return rewriteValueAMD64_OpGetLoInt32x8(v) + case OpGetLoInt64x4: + return rewriteValueAMD64_OpGetLoInt64x4(v) + case OpGetLoInt64x8: + return rewriteValueAMD64_OpGetLoInt64x8(v) + case OpGetLoInt8x32: + return rewriteValueAMD64_OpGetLoInt8x32(v) + case OpGetLoInt8x64: + return rewriteValueAMD64_OpGetLoInt8x64(v) + case OpGetLoUint16x16: + return rewriteValueAMD64_OpGetLoUint16x16(v) + case OpGetLoUint16x32: + return rewriteValueAMD64_OpGetLoUint16x32(v) + case OpGetLoUint32x16: + return rewriteValueAMD64_OpGetLoUint32x16(v) + case OpGetLoUint32x8: + return rewriteValueAMD64_OpGetLoUint32x8(v) + case OpGetLoUint64x4: + return rewriteValueAMD64_OpGetLoUint64x4(v) + case OpGetLoUint64x8: + return rewriteValueAMD64_OpGetLoUint64x8(v) + case OpGetLoUint8x32: + return rewriteValueAMD64_OpGetLoUint8x32(v) + case OpGetLoUint8x64: + return rewriteValueAMD64_OpGetLoUint8x64(v) + case OpGreaterEqualFloat32x16: + return rewriteValueAMD64_OpGreaterEqualFloat32x16(v) + case OpGreaterEqualFloat32x4: + return rewriteValueAMD64_OpGreaterEqualFloat32x4(v) + case OpGreaterEqualFloat32x8: + return rewriteValueAMD64_OpGreaterEqualFloat32x8(v) + case OpGreaterEqualFloat64x2: + return rewriteValueAMD64_OpGreaterEqualFloat64x2(v) + case OpGreaterEqualFloat64x4: + return rewriteValueAMD64_OpGreaterEqualFloat64x4(v) + case OpGreaterEqualFloat64x8: + return rewriteValueAMD64_OpGreaterEqualFloat64x8(v) + case OpGreaterEqualInt16x32: + return rewriteValueAMD64_OpGreaterEqualInt16x32(v) + case OpGreaterEqualInt32x16: + return rewriteValueAMD64_OpGreaterEqualInt32x16(v) + case OpGreaterEqualInt64x8: + return rewriteValueAMD64_OpGreaterEqualInt64x8(v) + case OpGreaterEqualInt8x64: + return rewriteValueAMD64_OpGreaterEqualInt8x64(v) + case OpGreaterEqualUint16x32: + return rewriteValueAMD64_OpGreaterEqualUint16x32(v) + case OpGreaterEqualUint32x16: + return rewriteValueAMD64_OpGreaterEqualUint32x16(v) + case OpGreaterEqualUint64x8: + return rewriteValueAMD64_OpGreaterEqualUint64x8(v) + case OpGreaterEqualUint8x64: + return rewriteValueAMD64_OpGreaterEqualUint8x64(v) + case OpGreaterFloat32x16: + return rewriteValueAMD64_OpGreaterFloat32x16(v) + case OpGreaterFloat32x4: + return rewriteValueAMD64_OpGreaterFloat32x4(v) + case OpGreaterFloat32x8: + return rewriteValueAMD64_OpGreaterFloat32x8(v) + case OpGreaterFloat64x2: + return rewriteValueAMD64_OpGreaterFloat64x2(v) + case OpGreaterFloat64x4: + return rewriteValueAMD64_OpGreaterFloat64x4(v) + case OpGreaterFloat64x8: + return rewriteValueAMD64_OpGreaterFloat64x8(v) + case OpGreaterInt16x16: + v.Op = OpAMD64VPCMPGTW256 + return true + case OpGreaterInt16x32: + return rewriteValueAMD64_OpGreaterInt16x32(v) + case OpGreaterInt16x8: + v.Op = OpAMD64VPCMPGTW128 + return true + case OpGreaterInt32x16: + return rewriteValueAMD64_OpGreaterInt32x16(v) + case OpGreaterInt32x4: + v.Op = OpAMD64VPCMPGTD128 + return true + case OpGreaterInt32x8: + v.Op = OpAMD64VPCMPGTD256 + return true + case OpGreaterInt64x2: + v.Op = OpAMD64VPCMPGTQ128 + return true + case OpGreaterInt64x4: + v.Op = OpAMD64VPCMPGTQ256 + return true + case OpGreaterInt64x8: + return rewriteValueAMD64_OpGreaterInt64x8(v) + case OpGreaterInt8x16: + v.Op = OpAMD64VPCMPGTB128 + return true + case OpGreaterInt8x32: + v.Op = OpAMD64VPCMPGTB256 + return true + case OpGreaterInt8x64: + return rewriteValueAMD64_OpGreaterInt8x64(v) + case OpGreaterUint16x32: + return rewriteValueAMD64_OpGreaterUint16x32(v) + case OpGreaterUint32x16: + return rewriteValueAMD64_OpGreaterUint32x16(v) + case OpGreaterUint64x8: + return rewriteValueAMD64_OpGreaterUint64x8(v) + case OpGreaterUint8x64: + return rewriteValueAMD64_OpGreaterUint8x64(v) + case OpHasCPUFeature: + return rewriteValueAMD64_OpHasCPUFeature(v) + case OpHmul32: + v.Op = OpAMD64HMULL + return true + case OpHmul32u: + v.Op = OpAMD64HMULLU + return true + case OpHmul64: + v.Op = OpAMD64HMULQ + return true + case OpHmul64u: + v.Op = OpAMD64HMULQU + return true + case OpInterCall: + v.Op = OpAMD64CALLinter + return true + case OpInterleaveHiGroupedInt16x16: + v.Op = OpAMD64VPUNPCKHWD256 + return true + case OpInterleaveHiGroupedInt16x32: + v.Op = OpAMD64VPUNPCKHWD512 + return true + case OpInterleaveHiGroupedInt32x16: + v.Op = OpAMD64VPUNPCKHDQ512 + return true + case OpInterleaveHiGroupedInt32x8: + v.Op = OpAMD64VPUNPCKHDQ256 + return true + case OpInterleaveHiGroupedInt64x4: + v.Op = OpAMD64VPUNPCKHQDQ256 + return true + case OpInterleaveHiGroupedInt64x8: + v.Op = OpAMD64VPUNPCKHQDQ512 + return true + case OpInterleaveHiGroupedUint16x16: + v.Op = OpAMD64VPUNPCKHWD256 + return true + case OpInterleaveHiGroupedUint16x32: + v.Op = OpAMD64VPUNPCKHWD512 + return true + case OpInterleaveHiGroupedUint32x16: + v.Op = OpAMD64VPUNPCKHDQ512 + return true + case OpInterleaveHiGroupedUint32x8: + v.Op = OpAMD64VPUNPCKHDQ256 + return true + case OpInterleaveHiGroupedUint64x4: + v.Op = OpAMD64VPUNPCKHQDQ256 + return true + case OpInterleaveHiGroupedUint64x8: + v.Op = OpAMD64VPUNPCKHQDQ512 + return true + case OpInterleaveHiInt16x8: + v.Op = OpAMD64VPUNPCKHWD128 + return true + case OpInterleaveHiInt32x4: + v.Op = OpAMD64VPUNPCKHDQ128 + return true + case OpInterleaveHiInt64x2: + v.Op = OpAMD64VPUNPCKHQDQ128 + return true + case OpInterleaveHiUint16x8: + v.Op = OpAMD64VPUNPCKHWD128 + return true + case OpInterleaveHiUint32x4: + v.Op = OpAMD64VPUNPCKHDQ128 + return true + case OpInterleaveHiUint64x2: + v.Op = OpAMD64VPUNPCKHQDQ128 + return true + case OpInterleaveLoGroupedInt16x16: + v.Op = OpAMD64VPUNPCKLWD256 + return true + case OpInterleaveLoGroupedInt16x32: + v.Op = OpAMD64VPUNPCKLWD512 + return true + case OpInterleaveLoGroupedInt32x16: + v.Op = OpAMD64VPUNPCKLDQ512 + return true + case OpInterleaveLoGroupedInt32x8: + v.Op = OpAMD64VPUNPCKLDQ256 + return true + case OpInterleaveLoGroupedInt64x4: + v.Op = OpAMD64VPUNPCKLQDQ256 + return true + case OpInterleaveLoGroupedInt64x8: + v.Op = OpAMD64VPUNPCKLQDQ512 + return true + case OpInterleaveLoGroupedUint16x16: + v.Op = OpAMD64VPUNPCKLWD256 + return true + case OpInterleaveLoGroupedUint16x32: + v.Op = OpAMD64VPUNPCKLWD512 + return true + case OpInterleaveLoGroupedUint32x16: + v.Op = OpAMD64VPUNPCKLDQ512 + return true + case OpInterleaveLoGroupedUint32x8: + v.Op = OpAMD64VPUNPCKLDQ256 + return true + case OpInterleaveLoGroupedUint64x4: + v.Op = OpAMD64VPUNPCKLQDQ256 + return true + case OpInterleaveLoGroupedUint64x8: + v.Op = OpAMD64VPUNPCKLQDQ512 + return true + case OpInterleaveLoInt16x8: + v.Op = OpAMD64VPUNPCKLWD128 + return true + case OpInterleaveLoInt32x4: + v.Op = OpAMD64VPUNPCKLDQ128 + return true + case OpInterleaveLoInt64x2: + v.Op = OpAMD64VPUNPCKLQDQ128 + return true + case OpInterleaveLoUint16x8: + v.Op = OpAMD64VPUNPCKLWD128 + return true + case OpInterleaveLoUint32x4: + v.Op = OpAMD64VPUNPCKLDQ128 + return true + case OpInterleaveLoUint64x2: + v.Op = OpAMD64VPUNPCKLQDQ128 + return true + case OpIsInBounds: + return rewriteValueAMD64_OpIsInBounds(v) + case OpIsNaNFloat32x16: + return rewriteValueAMD64_OpIsNaNFloat32x16(v) + case OpIsNaNFloat32x4: + return rewriteValueAMD64_OpIsNaNFloat32x4(v) + case OpIsNaNFloat32x8: + return rewriteValueAMD64_OpIsNaNFloat32x8(v) + case OpIsNaNFloat64x2: + return rewriteValueAMD64_OpIsNaNFloat64x2(v) + case OpIsNaNFloat64x4: + return rewriteValueAMD64_OpIsNaNFloat64x4(v) + case OpIsNaNFloat64x8: + return rewriteValueAMD64_OpIsNaNFloat64x8(v) + case OpIsNonNil: + return rewriteValueAMD64_OpIsNonNil(v) + case OpIsSliceInBounds: + return rewriteValueAMD64_OpIsSliceInBounds(v) + case OpIsZeroVec: + return rewriteValueAMD64_OpIsZeroVec(v) + case OpLeadingZerosInt32x16: + v.Op = OpAMD64VPLZCNTD512 + return true + case OpLeadingZerosInt32x4: + v.Op = OpAMD64VPLZCNTD128 + return true + case OpLeadingZerosInt32x8: + v.Op = OpAMD64VPLZCNTD256 + return true + case OpLeadingZerosInt64x2: + v.Op = OpAMD64VPLZCNTQ128 + return true + case OpLeadingZerosInt64x4: + v.Op = OpAMD64VPLZCNTQ256 + return true + case OpLeadingZerosInt64x8: + v.Op = OpAMD64VPLZCNTQ512 + return true + case OpLeadingZerosUint32x16: + v.Op = OpAMD64VPLZCNTD512 + return true + case OpLeadingZerosUint32x4: + v.Op = OpAMD64VPLZCNTD128 + return true + case OpLeadingZerosUint32x8: + v.Op = OpAMD64VPLZCNTD256 + return true + case OpLeadingZerosUint64x2: + v.Op = OpAMD64VPLZCNTQ128 + return true + case OpLeadingZerosUint64x4: + v.Op = OpAMD64VPLZCNTQ256 + return true + case OpLeadingZerosUint64x8: + v.Op = OpAMD64VPLZCNTQ512 + return true + case OpLeq16: + return rewriteValueAMD64_OpLeq16(v) + case OpLeq16U: + return rewriteValueAMD64_OpLeq16U(v) + case OpLeq32: + return rewriteValueAMD64_OpLeq32(v) + case OpLeq32F: + return rewriteValueAMD64_OpLeq32F(v) + case OpLeq32U: + return rewriteValueAMD64_OpLeq32U(v) + case OpLeq64: + return rewriteValueAMD64_OpLeq64(v) + case OpLeq64F: + return rewriteValueAMD64_OpLeq64F(v) + case OpLeq64U: + return rewriteValueAMD64_OpLeq64U(v) + case OpLeq8: + return rewriteValueAMD64_OpLeq8(v) + case OpLeq8U: + return rewriteValueAMD64_OpLeq8U(v) + case OpLess16: + return rewriteValueAMD64_OpLess16(v) + case OpLess16U: + return rewriteValueAMD64_OpLess16U(v) + case OpLess32: + return rewriteValueAMD64_OpLess32(v) + case OpLess32F: + return rewriteValueAMD64_OpLess32F(v) + case OpLess32U: + return rewriteValueAMD64_OpLess32U(v) + case OpLess64: + return rewriteValueAMD64_OpLess64(v) + case OpLess64F: + return rewriteValueAMD64_OpLess64F(v) + case OpLess64U: + return rewriteValueAMD64_OpLess64U(v) + case OpLess8: + return rewriteValueAMD64_OpLess8(v) + case OpLess8U: + return rewriteValueAMD64_OpLess8U(v) + case OpLessEqualFloat32x16: + return rewriteValueAMD64_OpLessEqualFloat32x16(v) + case OpLessEqualFloat32x4: + return rewriteValueAMD64_OpLessEqualFloat32x4(v) + case OpLessEqualFloat32x8: + return rewriteValueAMD64_OpLessEqualFloat32x8(v) + case OpLessEqualFloat64x2: + return rewriteValueAMD64_OpLessEqualFloat64x2(v) + case OpLessEqualFloat64x4: + return rewriteValueAMD64_OpLessEqualFloat64x4(v) + case OpLessEqualFloat64x8: + return rewriteValueAMD64_OpLessEqualFloat64x8(v) + case OpLessEqualInt16x32: + return rewriteValueAMD64_OpLessEqualInt16x32(v) + case OpLessEqualInt32x16: + return rewriteValueAMD64_OpLessEqualInt32x16(v) + case OpLessEqualInt64x8: + return rewriteValueAMD64_OpLessEqualInt64x8(v) + case OpLessEqualInt8x64: + return rewriteValueAMD64_OpLessEqualInt8x64(v) + case OpLessEqualUint16x32: + return rewriteValueAMD64_OpLessEqualUint16x32(v) + case OpLessEqualUint32x16: + return rewriteValueAMD64_OpLessEqualUint32x16(v) + case OpLessEqualUint64x8: + return rewriteValueAMD64_OpLessEqualUint64x8(v) + case OpLessEqualUint8x64: + return rewriteValueAMD64_OpLessEqualUint8x64(v) + case OpLessFloat32x16: + return rewriteValueAMD64_OpLessFloat32x16(v) + case OpLessFloat32x4: + return rewriteValueAMD64_OpLessFloat32x4(v) + case OpLessFloat32x8: + return rewriteValueAMD64_OpLessFloat32x8(v) + case OpLessFloat64x2: + return rewriteValueAMD64_OpLessFloat64x2(v) + case OpLessFloat64x4: + return rewriteValueAMD64_OpLessFloat64x4(v) + case OpLessFloat64x8: + return rewriteValueAMD64_OpLessFloat64x8(v) + case OpLessInt16x32: + return rewriteValueAMD64_OpLessInt16x32(v) + case OpLessInt32x16: + return rewriteValueAMD64_OpLessInt32x16(v) + case OpLessInt64x8: + return rewriteValueAMD64_OpLessInt64x8(v) + case OpLessInt8x64: + return rewriteValueAMD64_OpLessInt8x64(v) + case OpLessUint16x32: + return rewriteValueAMD64_OpLessUint16x32(v) + case OpLessUint32x16: + return rewriteValueAMD64_OpLessUint32x16(v) + case OpLessUint64x8: + return rewriteValueAMD64_OpLessUint64x8(v) + case OpLessUint8x64: + return rewriteValueAMD64_OpLessUint8x64(v) + case OpLoad: + return rewriteValueAMD64_OpLoad(v) + case OpLoadMasked16: + return rewriteValueAMD64_OpLoadMasked16(v) + case OpLoadMasked32: + return rewriteValueAMD64_OpLoadMasked32(v) + case OpLoadMasked64: + return rewriteValueAMD64_OpLoadMasked64(v) + case OpLoadMasked8: + return rewriteValueAMD64_OpLoadMasked8(v) + case OpLocalAddr: + return rewriteValueAMD64_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValueAMD64_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValueAMD64_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValueAMD64_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValueAMD64_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValueAMD64_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValueAMD64_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValueAMD64_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValueAMD64_OpLsh32x8(v) + case OpLsh64x16: + return rewriteValueAMD64_OpLsh64x16(v) + case OpLsh64x32: + return rewriteValueAMD64_OpLsh64x32(v) + case OpLsh64x64: + return rewriteValueAMD64_OpLsh64x64(v) + case OpLsh64x8: + return rewriteValueAMD64_OpLsh64x8(v) + case OpLsh8x16: + return rewriteValueAMD64_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValueAMD64_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValueAMD64_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValueAMD64_OpLsh8x8(v) + case OpMax32F: + return rewriteValueAMD64_OpMax32F(v) + case OpMax64F: + return rewriteValueAMD64_OpMax64F(v) + case OpMaxFloat32x16: + v.Op = OpAMD64VMAXPS512 + return true + case OpMaxFloat32x4: + v.Op = OpAMD64VMAXPS128 + return true + case OpMaxFloat32x8: + v.Op = OpAMD64VMAXPS256 + return true + case OpMaxFloat64x2: + v.Op = OpAMD64VMAXPD128 + return true + case OpMaxFloat64x4: + v.Op = OpAMD64VMAXPD256 + return true + case OpMaxFloat64x8: + v.Op = OpAMD64VMAXPD512 + return true + case OpMaxInt16x16: + v.Op = OpAMD64VPMAXSW256 + return true + case OpMaxInt16x32: + v.Op = OpAMD64VPMAXSW512 + return true + case OpMaxInt16x8: + v.Op = OpAMD64VPMAXSW128 + return true + case OpMaxInt32x16: + v.Op = OpAMD64VPMAXSD512 + return true + case OpMaxInt32x4: + v.Op = OpAMD64VPMAXSD128 + return true + case OpMaxInt32x8: + v.Op = OpAMD64VPMAXSD256 + return true + case OpMaxInt64x2: + v.Op = OpAMD64VPMAXSQ128 + return true + case OpMaxInt64x4: + v.Op = OpAMD64VPMAXSQ256 + return true + case OpMaxInt64x8: + v.Op = OpAMD64VPMAXSQ512 + return true + case OpMaxInt8x16: + v.Op = OpAMD64VPMAXSB128 + return true + case OpMaxInt8x32: + v.Op = OpAMD64VPMAXSB256 + return true + case OpMaxInt8x64: + v.Op = OpAMD64VPMAXSB512 + return true + case OpMaxUint16x16: + v.Op = OpAMD64VPMAXUW256 + return true + case OpMaxUint16x32: + v.Op = OpAMD64VPMAXUW512 + return true + case OpMaxUint16x8: + v.Op = OpAMD64VPMAXUW128 + return true + case OpMaxUint32x16: + v.Op = OpAMD64VPMAXUD512 + return true + case OpMaxUint32x4: + v.Op = OpAMD64VPMAXUD128 + return true + case OpMaxUint32x8: + v.Op = OpAMD64VPMAXUD256 + return true + case OpMaxUint64x2: + v.Op = OpAMD64VPMAXUQ128 + return true + case OpMaxUint64x4: + v.Op = OpAMD64VPMAXUQ256 + return true + case OpMaxUint64x8: + v.Op = OpAMD64VPMAXUQ512 + return true + case OpMaxUint8x16: + v.Op = OpAMD64VPMAXUB128 + return true + case OpMaxUint8x32: + v.Op = OpAMD64VPMAXUB256 + return true + case OpMaxUint8x64: + v.Op = OpAMD64VPMAXUB512 + return true + case OpMin32F: + return rewriteValueAMD64_OpMin32F(v) + case OpMin64F: + return rewriteValueAMD64_OpMin64F(v) + case OpMinFloat32x16: + v.Op = OpAMD64VMINPS512 + return true + case OpMinFloat32x4: + v.Op = OpAMD64VMINPS128 + return true + case OpMinFloat32x8: + v.Op = OpAMD64VMINPS256 + return true + case OpMinFloat64x2: + v.Op = OpAMD64VMINPD128 + return true + case OpMinFloat64x4: + v.Op = OpAMD64VMINPD256 + return true + case OpMinFloat64x8: + v.Op = OpAMD64VMINPD512 + return true + case OpMinInt16x16: + v.Op = OpAMD64VPMINSW256 + return true + case OpMinInt16x32: + v.Op = OpAMD64VPMINSW512 + return true + case OpMinInt16x8: + v.Op = OpAMD64VPMINSW128 + return true + case OpMinInt32x16: + v.Op = OpAMD64VPMINSD512 + return true + case OpMinInt32x4: + v.Op = OpAMD64VPMINSD128 + return true + case OpMinInt32x8: + v.Op = OpAMD64VPMINSD256 + return true + case OpMinInt64x2: + v.Op = OpAMD64VPMINSQ128 + return true + case OpMinInt64x4: + v.Op = OpAMD64VPMINSQ256 + return true + case OpMinInt64x8: + v.Op = OpAMD64VPMINSQ512 + return true + case OpMinInt8x16: + v.Op = OpAMD64VPMINSB128 + return true + case OpMinInt8x32: + v.Op = OpAMD64VPMINSB256 + return true + case OpMinInt8x64: + v.Op = OpAMD64VPMINSB512 + return true + case OpMinUint16x16: + v.Op = OpAMD64VPMINUW256 + return true + case OpMinUint16x32: + v.Op = OpAMD64VPMINUW512 + return true + case OpMinUint16x8: + v.Op = OpAMD64VPMINUW128 + return true + case OpMinUint32x16: + v.Op = OpAMD64VPMINUD512 + return true + case OpMinUint32x4: + v.Op = OpAMD64VPMINUD128 + return true + case OpMinUint32x8: + v.Op = OpAMD64VPMINUD256 + return true + case OpMinUint64x2: + v.Op = OpAMD64VPMINUQ128 + return true + case OpMinUint64x4: + v.Op = OpAMD64VPMINUQ256 + return true + case OpMinUint64x8: + v.Op = OpAMD64VPMINUQ512 + return true + case OpMinUint8x16: + v.Op = OpAMD64VPMINUB128 + return true + case OpMinUint8x32: + v.Op = OpAMD64VPMINUB256 + return true + case OpMinUint8x64: + v.Op = OpAMD64VPMINUB512 + return true + case OpMod16: + return rewriteValueAMD64_OpMod16(v) + case OpMod16u: + return rewriteValueAMD64_OpMod16u(v) + case OpMod32: + return rewriteValueAMD64_OpMod32(v) + case OpMod32u: + return rewriteValueAMD64_OpMod32u(v) + case OpMod64: + return rewriteValueAMD64_OpMod64(v) + case OpMod64u: + return rewriteValueAMD64_OpMod64u(v) + case OpMod8: + return rewriteValueAMD64_OpMod8(v) + case OpMod8u: + return rewriteValueAMD64_OpMod8u(v) + case OpMove: + return rewriteValueAMD64_OpMove(v) + case OpMul16: + v.Op = OpAMD64MULL + return true + case OpMul32: + v.Op = OpAMD64MULL + return true + case OpMul32F: + v.Op = OpAMD64MULSS + return true + case OpMul64: + v.Op = OpAMD64MULQ + return true + case OpMul64F: + v.Op = OpAMD64MULSD + return true + case OpMul64uhilo: + v.Op = OpAMD64MULQU2 + return true + case OpMul8: + v.Op = OpAMD64MULL + return true + case OpMulAddFloat32x16: + v.Op = OpAMD64VFMADD213PS512 + return true + case OpMulAddFloat32x4: + v.Op = OpAMD64VFMADD213PS128 + return true + case OpMulAddFloat32x8: + v.Op = OpAMD64VFMADD213PS256 + return true + case OpMulAddFloat64x2: + v.Op = OpAMD64VFMADD213PD128 + return true + case OpMulAddFloat64x4: + v.Op = OpAMD64VFMADD213PD256 + return true + case OpMulAddFloat64x8: + v.Op = OpAMD64VFMADD213PD512 + return true + case OpMulAddSubFloat32x16: + v.Op = OpAMD64VFMADDSUB213PS512 + return true + case OpMulAddSubFloat32x4: + v.Op = OpAMD64VFMADDSUB213PS128 + return true + case OpMulAddSubFloat32x8: + v.Op = OpAMD64VFMADDSUB213PS256 + return true + case OpMulAddSubFloat64x2: + v.Op = OpAMD64VFMADDSUB213PD128 + return true + case OpMulAddSubFloat64x4: + v.Op = OpAMD64VFMADDSUB213PD256 + return true + case OpMulAddSubFloat64x8: + v.Op = OpAMD64VFMADDSUB213PD512 + return true + case OpMulEvenWidenInt32x4: + v.Op = OpAMD64VPMULDQ128 + return true + case OpMulEvenWidenInt32x8: + v.Op = OpAMD64VPMULDQ256 + return true + case OpMulEvenWidenUint32x4: + v.Op = OpAMD64VPMULUDQ128 + return true + case OpMulEvenWidenUint32x8: + v.Op = OpAMD64VPMULUDQ256 + return true + case OpMulFloat32x16: + v.Op = OpAMD64VMULPS512 + return true + case OpMulFloat32x4: + v.Op = OpAMD64VMULPS128 + return true + case OpMulFloat32x8: + v.Op = OpAMD64VMULPS256 + return true + case OpMulFloat64x2: + v.Op = OpAMD64VMULPD128 + return true + case OpMulFloat64x4: + v.Op = OpAMD64VMULPD256 + return true + case OpMulFloat64x8: + v.Op = OpAMD64VMULPD512 + return true + case OpMulHighInt16x16: + v.Op = OpAMD64VPMULHW256 + return true + case OpMulHighInt16x32: + v.Op = OpAMD64VPMULHW512 + return true + case OpMulHighInt16x8: + v.Op = OpAMD64VPMULHW128 + return true + case OpMulHighUint16x16: + v.Op = OpAMD64VPMULHUW256 + return true + case OpMulHighUint16x32: + v.Op = OpAMD64VPMULHUW512 + return true + case OpMulHighUint16x8: + v.Op = OpAMD64VPMULHUW128 + return true + case OpMulInt16x16: + v.Op = OpAMD64VPMULLW256 + return true + case OpMulInt16x32: + v.Op = OpAMD64VPMULLW512 + return true + case OpMulInt16x8: + v.Op = OpAMD64VPMULLW128 + return true + case OpMulInt32x16: + v.Op = OpAMD64VPMULLD512 + return true + case OpMulInt32x4: + v.Op = OpAMD64VPMULLD128 + return true + case OpMulInt32x8: + v.Op = OpAMD64VPMULLD256 + return true + case OpMulInt64x2: + v.Op = OpAMD64VPMULLQ128 + return true + case OpMulInt64x4: + v.Op = OpAMD64VPMULLQ256 + return true + case OpMulInt64x8: + v.Op = OpAMD64VPMULLQ512 + return true + case OpMulSubAddFloat32x16: + v.Op = OpAMD64VFMSUBADD213PS512 + return true + case OpMulSubAddFloat32x4: + v.Op = OpAMD64VFMSUBADD213PS128 + return true + case OpMulSubAddFloat32x8: + v.Op = OpAMD64VFMSUBADD213PS256 + return true + case OpMulSubAddFloat64x2: + v.Op = OpAMD64VFMSUBADD213PD128 + return true + case OpMulSubAddFloat64x4: + v.Op = OpAMD64VFMSUBADD213PD256 + return true + case OpMulSubAddFloat64x8: + v.Op = OpAMD64VFMSUBADD213PD512 + return true + case OpMulUint16x16: + v.Op = OpAMD64VPMULLW256 + return true + case OpMulUint16x32: + v.Op = OpAMD64VPMULLW512 + return true + case OpMulUint16x8: + v.Op = OpAMD64VPMULLW128 + return true + case OpMulUint32x16: + v.Op = OpAMD64VPMULLD512 + return true + case OpMulUint32x4: + v.Op = OpAMD64VPMULLD128 + return true + case OpMulUint32x8: + v.Op = OpAMD64VPMULLD256 + return true + case OpMulUint64x2: + v.Op = OpAMD64VPMULLQ128 + return true + case OpMulUint64x4: + v.Op = OpAMD64VPMULLQ256 + return true + case OpMulUint64x8: + v.Op = OpAMD64VPMULLQ512 + return true + case OpNeg16: + v.Op = OpAMD64NEGL + return true + case OpNeg32: + v.Op = OpAMD64NEGL + return true + case OpNeg32F: + return rewriteValueAMD64_OpNeg32F(v) + case OpNeg64: + v.Op = OpAMD64NEGQ + return true + case OpNeg64F: + return rewriteValueAMD64_OpNeg64F(v) + case OpNeg8: + v.Op = OpAMD64NEGL + return true + case OpNeq16: + return rewriteValueAMD64_OpNeq16(v) + case OpNeq32: + return rewriteValueAMD64_OpNeq32(v) + case OpNeq32F: + return rewriteValueAMD64_OpNeq32F(v) + case OpNeq64: + return rewriteValueAMD64_OpNeq64(v) + case OpNeq64F: + return rewriteValueAMD64_OpNeq64F(v) + case OpNeq8: + return rewriteValueAMD64_OpNeq8(v) + case OpNeqB: + return rewriteValueAMD64_OpNeqB(v) + case OpNeqPtr: + return rewriteValueAMD64_OpNeqPtr(v) + case OpNilCheck: + v.Op = OpAMD64LoweredNilCheck + return true + case OpNot: + return rewriteValueAMD64_OpNot(v) + case OpNotEqualFloat32x16: + return rewriteValueAMD64_OpNotEqualFloat32x16(v) + case OpNotEqualFloat32x4: + return rewriteValueAMD64_OpNotEqualFloat32x4(v) + case OpNotEqualFloat32x8: + return rewriteValueAMD64_OpNotEqualFloat32x8(v) + case OpNotEqualFloat64x2: + return rewriteValueAMD64_OpNotEqualFloat64x2(v) + case OpNotEqualFloat64x4: + return rewriteValueAMD64_OpNotEqualFloat64x4(v) + case OpNotEqualFloat64x8: + return rewriteValueAMD64_OpNotEqualFloat64x8(v) + case OpNotEqualInt16x32: + return rewriteValueAMD64_OpNotEqualInt16x32(v) + case OpNotEqualInt32x16: + return rewriteValueAMD64_OpNotEqualInt32x16(v) + case OpNotEqualInt64x8: + return rewriteValueAMD64_OpNotEqualInt64x8(v) + case OpNotEqualInt8x64: + return rewriteValueAMD64_OpNotEqualInt8x64(v) + case OpNotEqualUint16x32: + return rewriteValueAMD64_OpNotEqualUint16x32(v) + case OpNotEqualUint32x16: + return rewriteValueAMD64_OpNotEqualUint32x16(v) + case OpNotEqualUint64x8: + return rewriteValueAMD64_OpNotEqualUint64x8(v) + case OpNotEqualUint8x64: + return rewriteValueAMD64_OpNotEqualUint8x64(v) + case OpOffPtr: + return rewriteValueAMD64_OpOffPtr(v) + case OpOnesCountInt16x16: + v.Op = OpAMD64VPOPCNTW256 + return true + case OpOnesCountInt16x32: + v.Op = OpAMD64VPOPCNTW512 + return true + case OpOnesCountInt16x8: + v.Op = OpAMD64VPOPCNTW128 + return true + case OpOnesCountInt32x16: + v.Op = OpAMD64VPOPCNTD512 + return true + case OpOnesCountInt32x4: + v.Op = OpAMD64VPOPCNTD128 + return true + case OpOnesCountInt32x8: + v.Op = OpAMD64VPOPCNTD256 + return true + case OpOnesCountInt64x2: + v.Op = OpAMD64VPOPCNTQ128 + return true + case OpOnesCountInt64x4: + v.Op = OpAMD64VPOPCNTQ256 + return true + case OpOnesCountInt64x8: + v.Op = OpAMD64VPOPCNTQ512 + return true + case OpOnesCountInt8x16: + v.Op = OpAMD64VPOPCNTB128 + return true + case OpOnesCountInt8x32: + v.Op = OpAMD64VPOPCNTB256 + return true + case OpOnesCountInt8x64: + v.Op = OpAMD64VPOPCNTB512 + return true + case OpOnesCountUint16x16: + v.Op = OpAMD64VPOPCNTW256 + return true + case OpOnesCountUint16x32: + v.Op = OpAMD64VPOPCNTW512 + return true + case OpOnesCountUint16x8: + v.Op = OpAMD64VPOPCNTW128 + return true + case OpOnesCountUint32x16: + v.Op = OpAMD64VPOPCNTD512 + return true + case OpOnesCountUint32x4: + v.Op = OpAMD64VPOPCNTD128 + return true + case OpOnesCountUint32x8: + v.Op = OpAMD64VPOPCNTD256 + return true + case OpOnesCountUint64x2: + v.Op = OpAMD64VPOPCNTQ128 + return true + case OpOnesCountUint64x4: + v.Op = OpAMD64VPOPCNTQ256 + return true + case OpOnesCountUint64x8: + v.Op = OpAMD64VPOPCNTQ512 + return true + case OpOnesCountUint8x16: + v.Op = OpAMD64VPOPCNTB128 + return true + case OpOnesCountUint8x32: + v.Op = OpAMD64VPOPCNTB256 + return true + case OpOnesCountUint8x64: + v.Op = OpAMD64VPOPCNTB512 + return true + case OpOr16: + v.Op = OpAMD64ORL + return true + case OpOr32: + v.Op = OpAMD64ORL + return true + case OpOr64: + v.Op = OpAMD64ORQ + return true + case OpOr8: + v.Op = OpAMD64ORL + return true + case OpOrB: + v.Op = OpAMD64ORL + return true + case OpOrInt16x16: + v.Op = OpAMD64VPOR256 + return true + case OpOrInt16x32: + v.Op = OpAMD64VPORD512 + return true + case OpOrInt16x8: + v.Op = OpAMD64VPOR128 + return true + case OpOrInt32x16: + v.Op = OpAMD64VPORD512 + return true + case OpOrInt32x4: + v.Op = OpAMD64VPOR128 + return true + case OpOrInt32x8: + v.Op = OpAMD64VPOR256 + return true + case OpOrInt64x2: + v.Op = OpAMD64VPOR128 + return true + case OpOrInt64x4: + v.Op = OpAMD64VPOR256 + return true + case OpOrInt64x8: + v.Op = OpAMD64VPORQ512 + return true + case OpOrInt8x16: + v.Op = OpAMD64VPOR128 + return true + case OpOrInt8x32: + v.Op = OpAMD64VPOR256 + return true + case OpOrInt8x64: + v.Op = OpAMD64VPORD512 + return true + case OpOrUint16x16: + v.Op = OpAMD64VPOR256 + return true + case OpOrUint16x32: + v.Op = OpAMD64VPORD512 + return true + case OpOrUint16x8: + v.Op = OpAMD64VPOR128 + return true + case OpOrUint32x16: + v.Op = OpAMD64VPORD512 + return true + case OpOrUint32x4: + v.Op = OpAMD64VPOR128 + return true + case OpOrUint32x8: + v.Op = OpAMD64VPOR256 + return true + case OpOrUint64x2: + v.Op = OpAMD64VPOR128 + return true + case OpOrUint64x4: + v.Op = OpAMD64VPOR256 + return true + case OpOrUint64x8: + v.Op = OpAMD64VPORQ512 + return true + case OpOrUint8x16: + v.Op = OpAMD64VPOR128 + return true + case OpOrUint8x32: + v.Op = OpAMD64VPOR256 + return true + case OpOrUint8x64: + v.Op = OpAMD64VPORD512 + return true + case OpPanicBounds: + v.Op = OpAMD64LoweredPanicBoundsRR + return true + case OpPermuteFloat32x16: + v.Op = OpAMD64VPERMPS512 + return true + case OpPermuteFloat32x8: + v.Op = OpAMD64VPERMPS256 + return true + case OpPermuteFloat64x4: + v.Op = OpAMD64VPERMPD256 + return true + case OpPermuteFloat64x8: + v.Op = OpAMD64VPERMPD512 + return true + case OpPermuteInt16x16: + v.Op = OpAMD64VPERMW256 + return true + case OpPermuteInt16x32: + v.Op = OpAMD64VPERMW512 + return true + case OpPermuteInt16x8: + v.Op = OpAMD64VPERMW128 + return true + case OpPermuteInt32x16: + v.Op = OpAMD64VPERMD512 + return true + case OpPermuteInt32x8: + v.Op = OpAMD64VPERMD256 + return true + case OpPermuteInt64x4: + v.Op = OpAMD64VPERMQ256 + return true + case OpPermuteInt64x8: + v.Op = OpAMD64VPERMQ512 + return true + case OpPermuteInt8x16: + v.Op = OpAMD64VPERMB128 + return true + case OpPermuteInt8x32: + v.Op = OpAMD64VPERMB256 + return true + case OpPermuteInt8x64: + v.Op = OpAMD64VPERMB512 + return true + case OpPermuteOrZeroGroupedInt8x32: + v.Op = OpAMD64VPSHUFB256 + return true + case OpPermuteOrZeroGroupedInt8x64: + v.Op = OpAMD64VPSHUFB512 + return true + case OpPermuteOrZeroGroupedUint8x32: + v.Op = OpAMD64VPSHUFB256 + return true + case OpPermuteOrZeroGroupedUint8x64: + v.Op = OpAMD64VPSHUFB512 + return true + case OpPermuteOrZeroInt8x16: + v.Op = OpAMD64VPSHUFB128 + return true + case OpPermuteOrZeroUint8x16: + v.Op = OpAMD64VPSHUFB128 + return true + case OpPermuteUint16x16: + v.Op = OpAMD64VPERMW256 + return true + case OpPermuteUint16x32: + v.Op = OpAMD64VPERMW512 + return true + case OpPermuteUint16x8: + v.Op = OpAMD64VPERMW128 + return true + case OpPermuteUint32x16: + v.Op = OpAMD64VPERMD512 + return true + case OpPermuteUint32x8: + v.Op = OpAMD64VPERMD256 + return true + case OpPermuteUint64x4: + v.Op = OpAMD64VPERMQ256 + return true + case OpPermuteUint64x8: + v.Op = OpAMD64VPERMQ512 + return true + case OpPermuteUint8x16: + v.Op = OpAMD64VPERMB128 + return true + case OpPermuteUint8x32: + v.Op = OpAMD64VPERMB256 + return true + case OpPermuteUint8x64: + v.Op = OpAMD64VPERMB512 + return true + case OpPopCount16: + return rewriteValueAMD64_OpPopCount16(v) + case OpPopCount32: + v.Op = OpAMD64POPCNTL + return true + case OpPopCount64: + v.Op = OpAMD64POPCNTQ + return true + case OpPopCount8: + return rewriteValueAMD64_OpPopCount8(v) + case OpPrefetchCache: + v.Op = OpAMD64PrefetchT0 + return true + case OpPrefetchCacheStreamed: + v.Op = OpAMD64PrefetchNTA + return true + case OpReciprocalFloat32x16: + v.Op = OpAMD64VRCP14PS512 + return true + case OpReciprocalFloat32x4: + v.Op = OpAMD64VRCPPS128 + return true + case OpReciprocalFloat32x8: + v.Op = OpAMD64VRCPPS256 + return true + case OpReciprocalFloat64x2: + v.Op = OpAMD64VRCP14PD128 + return true + case OpReciprocalFloat64x4: + v.Op = OpAMD64VRCP14PD256 + return true + case OpReciprocalFloat64x8: + v.Op = OpAMD64VRCP14PD512 + return true + case OpReciprocalSqrtFloat32x16: + v.Op = OpAMD64VRSQRT14PS512 + return true + case OpReciprocalSqrtFloat32x4: + v.Op = OpAMD64VRSQRTPS128 + return true + case OpReciprocalSqrtFloat32x8: + v.Op = OpAMD64VRSQRTPS256 + return true + case OpReciprocalSqrtFloat64x2: + v.Op = OpAMD64VRSQRT14PD128 + return true + case OpReciprocalSqrtFloat64x4: + v.Op = OpAMD64VRSQRT14PD256 + return true + case OpReciprocalSqrtFloat64x8: + v.Op = OpAMD64VRSQRT14PD512 + return true + case OpRotateAllLeftInt32x16: + v.Op = OpAMD64VPROLD512 + return true + case OpRotateAllLeftInt32x4: + v.Op = OpAMD64VPROLD128 + return true + case OpRotateAllLeftInt32x8: + v.Op = OpAMD64VPROLD256 + return true + case OpRotateAllLeftInt64x2: + v.Op = OpAMD64VPROLQ128 + return true + case OpRotateAllLeftInt64x4: + v.Op = OpAMD64VPROLQ256 + return true + case OpRotateAllLeftInt64x8: + v.Op = OpAMD64VPROLQ512 + return true + case OpRotateAllLeftUint32x16: + v.Op = OpAMD64VPROLD512 + return true + case OpRotateAllLeftUint32x4: + v.Op = OpAMD64VPROLD128 + return true + case OpRotateAllLeftUint32x8: + v.Op = OpAMD64VPROLD256 + return true + case OpRotateAllLeftUint64x2: + v.Op = OpAMD64VPROLQ128 + return true + case OpRotateAllLeftUint64x4: + v.Op = OpAMD64VPROLQ256 + return true + case OpRotateAllLeftUint64x8: + v.Op = OpAMD64VPROLQ512 + return true + case OpRotateAllRightInt32x16: + v.Op = OpAMD64VPRORD512 + return true + case OpRotateAllRightInt32x4: + v.Op = OpAMD64VPRORD128 + return true + case OpRotateAllRightInt32x8: + v.Op = OpAMD64VPRORD256 + return true + case OpRotateAllRightInt64x2: + v.Op = OpAMD64VPRORQ128 + return true + case OpRotateAllRightInt64x4: + v.Op = OpAMD64VPRORQ256 + return true + case OpRotateAllRightInt64x8: + v.Op = OpAMD64VPRORQ512 + return true + case OpRotateAllRightUint32x16: + v.Op = OpAMD64VPRORD512 + return true + case OpRotateAllRightUint32x4: + v.Op = OpAMD64VPRORD128 + return true + case OpRotateAllRightUint32x8: + v.Op = OpAMD64VPRORD256 + return true + case OpRotateAllRightUint64x2: + v.Op = OpAMD64VPRORQ128 + return true + case OpRotateAllRightUint64x4: + v.Op = OpAMD64VPRORQ256 + return true + case OpRotateAllRightUint64x8: + v.Op = OpAMD64VPRORQ512 + return true + case OpRotateLeft16: + v.Op = OpAMD64ROLW + return true + case OpRotateLeft32: + v.Op = OpAMD64ROLL + return true + case OpRotateLeft64: + v.Op = OpAMD64ROLQ + return true + case OpRotateLeft8: + v.Op = OpAMD64ROLB + return true + case OpRotateLeftInt32x16: + v.Op = OpAMD64VPROLVD512 + return true + case OpRotateLeftInt32x4: + v.Op = OpAMD64VPROLVD128 + return true + case OpRotateLeftInt32x8: + v.Op = OpAMD64VPROLVD256 + return true + case OpRotateLeftInt64x2: + v.Op = OpAMD64VPROLVQ128 + return true + case OpRotateLeftInt64x4: + v.Op = OpAMD64VPROLVQ256 + return true + case OpRotateLeftInt64x8: + v.Op = OpAMD64VPROLVQ512 + return true + case OpRotateLeftUint32x16: + v.Op = OpAMD64VPROLVD512 + return true + case OpRotateLeftUint32x4: + v.Op = OpAMD64VPROLVD128 + return true + case OpRotateLeftUint32x8: + v.Op = OpAMD64VPROLVD256 + return true + case OpRotateLeftUint64x2: + v.Op = OpAMD64VPROLVQ128 + return true + case OpRotateLeftUint64x4: + v.Op = OpAMD64VPROLVQ256 + return true + case OpRotateLeftUint64x8: + v.Op = OpAMD64VPROLVQ512 + return true + case OpRotateRightInt32x16: + v.Op = OpAMD64VPRORVD512 + return true + case OpRotateRightInt32x4: + v.Op = OpAMD64VPRORVD128 + return true + case OpRotateRightInt32x8: + v.Op = OpAMD64VPRORVD256 + return true + case OpRotateRightInt64x2: + v.Op = OpAMD64VPRORVQ128 + return true + case OpRotateRightInt64x4: + v.Op = OpAMD64VPRORVQ256 + return true + case OpRotateRightInt64x8: + v.Op = OpAMD64VPRORVQ512 + return true + case OpRotateRightUint32x16: + v.Op = OpAMD64VPRORVD512 + return true + case OpRotateRightUint32x4: + v.Op = OpAMD64VPRORVD128 + return true + case OpRotateRightUint32x8: + v.Op = OpAMD64VPRORVD256 + return true + case OpRotateRightUint64x2: + v.Op = OpAMD64VPRORVQ128 + return true + case OpRotateRightUint64x4: + v.Op = OpAMD64VPRORVQ256 + return true + case OpRotateRightUint64x8: + v.Op = OpAMD64VPRORVQ512 + return true + case OpRound32F: + v.Op = OpAMD64LoweredRound32F + return true + case OpRound64F: + v.Op = OpAMD64LoweredRound64F + return true + case OpRoundToEven: + return rewriteValueAMD64_OpRoundToEven(v) + case OpRoundToEvenFloat32x4: + return rewriteValueAMD64_OpRoundToEvenFloat32x4(v) + case OpRoundToEvenFloat32x8: + return rewriteValueAMD64_OpRoundToEvenFloat32x8(v) + case OpRoundToEvenFloat64x2: + return rewriteValueAMD64_OpRoundToEvenFloat64x2(v) + case OpRoundToEvenFloat64x4: + return rewriteValueAMD64_OpRoundToEvenFloat64x4(v) + case OpRoundToEvenScaledFloat32x16: + return rewriteValueAMD64_OpRoundToEvenScaledFloat32x16(v) + case OpRoundToEvenScaledFloat32x4: + return rewriteValueAMD64_OpRoundToEvenScaledFloat32x4(v) + case OpRoundToEvenScaledFloat32x8: + return rewriteValueAMD64_OpRoundToEvenScaledFloat32x8(v) + case OpRoundToEvenScaledFloat64x2: + return rewriteValueAMD64_OpRoundToEvenScaledFloat64x2(v) + case OpRoundToEvenScaledFloat64x4: + return rewriteValueAMD64_OpRoundToEvenScaledFloat64x4(v) + case OpRoundToEvenScaledFloat64x8: + return rewriteValueAMD64_OpRoundToEvenScaledFloat64x8(v) + case OpRoundToEvenScaledResidueFloat32x16: + return rewriteValueAMD64_OpRoundToEvenScaledResidueFloat32x16(v) + case OpRoundToEvenScaledResidueFloat32x4: + return rewriteValueAMD64_OpRoundToEvenScaledResidueFloat32x4(v) + case OpRoundToEvenScaledResidueFloat32x8: + return rewriteValueAMD64_OpRoundToEvenScaledResidueFloat32x8(v) + case OpRoundToEvenScaledResidueFloat64x2: + return rewriteValueAMD64_OpRoundToEvenScaledResidueFloat64x2(v) + case OpRoundToEvenScaledResidueFloat64x4: + return rewriteValueAMD64_OpRoundToEvenScaledResidueFloat64x4(v) + case OpRoundToEvenScaledResidueFloat64x8: + return rewriteValueAMD64_OpRoundToEvenScaledResidueFloat64x8(v) + case OpRsh16Ux16: + return rewriteValueAMD64_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValueAMD64_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValueAMD64_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValueAMD64_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValueAMD64_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValueAMD64_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValueAMD64_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValueAMD64_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValueAMD64_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValueAMD64_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValueAMD64_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValueAMD64_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValueAMD64_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValueAMD64_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValueAMD64_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValueAMD64_OpRsh32x8(v) + case OpRsh64Ux16: + return rewriteValueAMD64_OpRsh64Ux16(v) + case OpRsh64Ux32: + return rewriteValueAMD64_OpRsh64Ux32(v) + case OpRsh64Ux64: + return rewriteValueAMD64_OpRsh64Ux64(v) + case OpRsh64Ux8: + return rewriteValueAMD64_OpRsh64Ux8(v) + case OpRsh64x16: + return rewriteValueAMD64_OpRsh64x16(v) + case OpRsh64x32: + return rewriteValueAMD64_OpRsh64x32(v) + case OpRsh64x64: + return rewriteValueAMD64_OpRsh64x64(v) + case OpRsh64x8: + return rewriteValueAMD64_OpRsh64x8(v) + case OpRsh8Ux16: + return rewriteValueAMD64_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValueAMD64_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValueAMD64_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValueAMD64_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValueAMD64_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValueAMD64_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValueAMD64_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValueAMD64_OpRsh8x8(v) + case OpSHA1FourRoundsUint32x4: + v.Op = OpAMD64SHA1RNDS4128 + return true + case OpSHA1Message1Uint32x4: + v.Op = OpAMD64SHA1MSG1128 + return true + case OpSHA1Message2Uint32x4: + v.Op = OpAMD64SHA1MSG2128 + return true + case OpSHA1NextEUint32x4: + v.Op = OpAMD64SHA1NEXTE128 + return true + case OpSHA256Message1Uint32x4: + v.Op = OpAMD64SHA256MSG1128 + return true + case OpSHA256Message2Uint32x4: + v.Op = OpAMD64SHA256MSG2128 + return true + case OpSHA256TwoRoundsUint32x4: + v.Op = OpAMD64SHA256RNDS2128 + return true + case OpSaturateToInt16ConcatGroupedInt32x16: + v.Op = OpAMD64VPACKSSDW512 + return true + case OpSaturateToInt16ConcatGroupedInt32x8: + v.Op = OpAMD64VPACKSSDW256 + return true + case OpSaturateToInt16ConcatInt32x4: + v.Op = OpAMD64VPACKSSDW128 + return true + case OpSaturateToInt16Int32x16: + v.Op = OpAMD64VPMOVSDW256 + return true + case OpSaturateToInt16Int32x4: + v.Op = OpAMD64VPMOVSDW128_128 + return true + case OpSaturateToInt16Int32x8: + v.Op = OpAMD64VPMOVSDW128_256 + return true + case OpSaturateToInt16Int64x2: + v.Op = OpAMD64VPMOVSQW128_128 + return true + case OpSaturateToInt16Int64x4: + v.Op = OpAMD64VPMOVSQW128_256 + return true + case OpSaturateToInt16Int64x8: + v.Op = OpAMD64VPMOVSQW128_512 + return true + case OpSaturateToInt32Int64x2: + v.Op = OpAMD64VPMOVSQD128_128 + return true + case OpSaturateToInt32Int64x4: + v.Op = OpAMD64VPMOVSQD128_256 + return true + case OpSaturateToInt32Int64x8: + v.Op = OpAMD64VPMOVSQD256 + return true + case OpSaturateToInt8Int16x16: + v.Op = OpAMD64VPMOVSWB128_256 + return true + case OpSaturateToInt8Int16x32: + v.Op = OpAMD64VPMOVSWB256 + return true + case OpSaturateToInt8Int16x8: + v.Op = OpAMD64VPMOVSWB128_128 + return true + case OpSaturateToInt8Int32x16: + v.Op = OpAMD64VPMOVSDB128_512 + return true + case OpSaturateToInt8Int32x4: + v.Op = OpAMD64VPMOVSDB128_128 + return true + case OpSaturateToInt8Int32x8: + v.Op = OpAMD64VPMOVSDB128_256 + return true + case OpSaturateToInt8Int64x2: + v.Op = OpAMD64VPMOVSQB128_128 + return true + case OpSaturateToInt8Int64x4: + v.Op = OpAMD64VPMOVSQB128_256 + return true + case OpSaturateToInt8Int64x8: + v.Op = OpAMD64VPMOVSQB128_512 + return true + case OpSaturateToUint16ConcatGroupedInt32x16: + v.Op = OpAMD64VPACKUSDW512 + return true + case OpSaturateToUint16ConcatGroupedInt32x8: + v.Op = OpAMD64VPACKUSDW256 + return true + case OpSaturateToUint16ConcatInt32x4: + v.Op = OpAMD64VPACKUSDW128 + return true + case OpSaturateToUint16Uint32x16: + v.Op = OpAMD64VPMOVUSDW256 + return true + case OpSaturateToUint16Uint32x4: + v.Op = OpAMD64VPMOVUSDW128_128 + return true + case OpSaturateToUint16Uint32x8: + v.Op = OpAMD64VPMOVUSDW128_256 + return true + case OpSaturateToUint16Uint64x2: + v.Op = OpAMD64VPMOVUSQW128_128 + return true + case OpSaturateToUint16Uint64x4: + v.Op = OpAMD64VPMOVUSQW128_256 + return true + case OpSaturateToUint16Uint64x8: + v.Op = OpAMD64VPMOVUSQW128_512 + return true + case OpSaturateToUint32Uint64x2: + v.Op = OpAMD64VPMOVUSQD128_128 + return true + case OpSaturateToUint32Uint64x4: + v.Op = OpAMD64VPMOVUSQD128_256 + return true + case OpSaturateToUint32Uint64x8: + v.Op = OpAMD64VPMOVUSQD256 + return true + case OpSaturateToUint8Uint16x16: + v.Op = OpAMD64VPMOVUSWB128_256 + return true + case OpSaturateToUint8Uint16x32: + v.Op = OpAMD64VPMOVUSWB256 + return true + case OpSaturateToUint8Uint16x8: + v.Op = OpAMD64VPMOVUSWB128_128 + return true + case OpSaturateToUint8Uint32x16: + v.Op = OpAMD64VPMOVUSDB128_512 + return true + case OpSaturateToUint8Uint32x4: + v.Op = OpAMD64VPMOVUSDB128_128 + return true + case OpSaturateToUint8Uint32x8: + v.Op = OpAMD64VPMOVUSDB128_256 + return true + case OpSaturateToUint8Uint64x2: + v.Op = OpAMD64VPMOVUSQB128_128 + return true + case OpSaturateToUint8Uint64x4: + v.Op = OpAMD64VPMOVUSQB128_256 + return true + case OpSaturateToUint8Uint64x8: + v.Op = OpAMD64VPMOVUSQB128_512 + return true + case OpScaleFloat32x16: + v.Op = OpAMD64VSCALEFPS512 + return true + case OpScaleFloat32x4: + v.Op = OpAMD64VSCALEFPS128 + return true + case OpScaleFloat32x8: + v.Op = OpAMD64VSCALEFPS256 + return true + case OpScaleFloat64x2: + v.Op = OpAMD64VSCALEFPD128 + return true + case OpScaleFloat64x4: + v.Op = OpAMD64VSCALEFPD256 + return true + case OpScaleFloat64x8: + v.Op = OpAMD64VSCALEFPD512 + return true + case OpSelect0: + return rewriteValueAMD64_OpSelect0(v) + case OpSelect1: + return rewriteValueAMD64_OpSelect1(v) + case OpSelect128FromPairFloat32x8: + v.Op = OpAMD64VPERM2F128256 + return true + case OpSelect128FromPairFloat64x4: + v.Op = OpAMD64VPERM2F128256 + return true + case OpSelect128FromPairInt16x16: + v.Op = OpAMD64VPERM2I128256 + return true + case OpSelect128FromPairInt32x8: + v.Op = OpAMD64VPERM2I128256 + return true + case OpSelect128FromPairInt64x4: + v.Op = OpAMD64VPERM2I128256 + return true + case OpSelect128FromPairInt8x32: + v.Op = OpAMD64VPERM2I128256 + return true + case OpSelect128FromPairUint16x16: + v.Op = OpAMD64VPERM2I128256 + return true + case OpSelect128FromPairUint32x8: + v.Op = OpAMD64VPERM2I128256 + return true + case OpSelect128FromPairUint64x4: + v.Op = OpAMD64VPERM2I128256 + return true + case OpSelect128FromPairUint8x32: + v.Op = OpAMD64VPERM2I128256 + return true + case OpSelectN: + return rewriteValueAMD64_OpSelectN(v) + case OpSetElemFloat32x4: + v.Op = OpAMD64VPINSRD128 + return true + case OpSetElemFloat64x2: + v.Op = OpAMD64VPINSRQ128 + return true + case OpSetElemInt16x8: + v.Op = OpAMD64VPINSRW128 + return true + case OpSetElemInt32x4: + v.Op = OpAMD64VPINSRD128 + return true + case OpSetElemInt64x2: + v.Op = OpAMD64VPINSRQ128 + return true + case OpSetElemInt8x16: + v.Op = OpAMD64VPINSRB128 + return true + case OpSetElemUint16x8: + v.Op = OpAMD64VPINSRW128 + return true + case OpSetElemUint32x4: + v.Op = OpAMD64VPINSRD128 + return true + case OpSetElemUint64x2: + v.Op = OpAMD64VPINSRQ128 + return true + case OpSetElemUint8x16: + v.Op = OpAMD64VPINSRB128 + return true + case OpSetHiFloat32x16: + return rewriteValueAMD64_OpSetHiFloat32x16(v) + case OpSetHiFloat32x8: + return rewriteValueAMD64_OpSetHiFloat32x8(v) + case OpSetHiFloat64x4: + return rewriteValueAMD64_OpSetHiFloat64x4(v) + case OpSetHiFloat64x8: + return rewriteValueAMD64_OpSetHiFloat64x8(v) + case OpSetHiInt16x16: + return rewriteValueAMD64_OpSetHiInt16x16(v) + case OpSetHiInt16x32: + return rewriteValueAMD64_OpSetHiInt16x32(v) + case OpSetHiInt32x16: + return rewriteValueAMD64_OpSetHiInt32x16(v) + case OpSetHiInt32x8: + return rewriteValueAMD64_OpSetHiInt32x8(v) + case OpSetHiInt64x4: + return rewriteValueAMD64_OpSetHiInt64x4(v) + case OpSetHiInt64x8: + return rewriteValueAMD64_OpSetHiInt64x8(v) + case OpSetHiInt8x32: + return rewriteValueAMD64_OpSetHiInt8x32(v) + case OpSetHiInt8x64: + return rewriteValueAMD64_OpSetHiInt8x64(v) + case OpSetHiUint16x16: + return rewriteValueAMD64_OpSetHiUint16x16(v) + case OpSetHiUint16x32: + return rewriteValueAMD64_OpSetHiUint16x32(v) + case OpSetHiUint32x16: + return rewriteValueAMD64_OpSetHiUint32x16(v) + case OpSetHiUint32x8: + return rewriteValueAMD64_OpSetHiUint32x8(v) + case OpSetHiUint64x4: + return rewriteValueAMD64_OpSetHiUint64x4(v) + case OpSetHiUint64x8: + return rewriteValueAMD64_OpSetHiUint64x8(v) + case OpSetHiUint8x32: + return rewriteValueAMD64_OpSetHiUint8x32(v) + case OpSetHiUint8x64: + return rewriteValueAMD64_OpSetHiUint8x64(v) + case OpSetLoFloat32x16: + return rewriteValueAMD64_OpSetLoFloat32x16(v) + case OpSetLoFloat32x8: + return rewriteValueAMD64_OpSetLoFloat32x8(v) + case OpSetLoFloat64x4: + return rewriteValueAMD64_OpSetLoFloat64x4(v) + case OpSetLoFloat64x8: + return rewriteValueAMD64_OpSetLoFloat64x8(v) + case OpSetLoInt16x16: + return rewriteValueAMD64_OpSetLoInt16x16(v) + case OpSetLoInt16x32: + return rewriteValueAMD64_OpSetLoInt16x32(v) + case OpSetLoInt32x16: + return rewriteValueAMD64_OpSetLoInt32x16(v) + case OpSetLoInt32x8: + return rewriteValueAMD64_OpSetLoInt32x8(v) + case OpSetLoInt64x4: + return rewriteValueAMD64_OpSetLoInt64x4(v) + case OpSetLoInt64x8: + return rewriteValueAMD64_OpSetLoInt64x8(v) + case OpSetLoInt8x32: + return rewriteValueAMD64_OpSetLoInt8x32(v) + case OpSetLoInt8x64: + return rewriteValueAMD64_OpSetLoInt8x64(v) + case OpSetLoUint16x16: + return rewriteValueAMD64_OpSetLoUint16x16(v) + case OpSetLoUint16x32: + return rewriteValueAMD64_OpSetLoUint16x32(v) + case OpSetLoUint32x16: + return rewriteValueAMD64_OpSetLoUint32x16(v) + case OpSetLoUint32x8: + return rewriteValueAMD64_OpSetLoUint32x8(v) + case OpSetLoUint64x4: + return rewriteValueAMD64_OpSetLoUint64x4(v) + case OpSetLoUint64x8: + return rewriteValueAMD64_OpSetLoUint64x8(v) + case OpSetLoUint8x32: + return rewriteValueAMD64_OpSetLoUint8x32(v) + case OpSetLoUint8x64: + return rewriteValueAMD64_OpSetLoUint8x64(v) + case OpShiftAllLeftConcatInt16x16: + v.Op = OpAMD64VPSHLDW256 + return true + case OpShiftAllLeftConcatInt16x32: + v.Op = OpAMD64VPSHLDW512 + return true + case OpShiftAllLeftConcatInt16x8: + v.Op = OpAMD64VPSHLDW128 + return true + case OpShiftAllLeftConcatInt32x16: + v.Op = OpAMD64VPSHLDD512 + return true + case OpShiftAllLeftConcatInt32x4: + v.Op = OpAMD64VPSHLDD128 + return true + case OpShiftAllLeftConcatInt32x8: + v.Op = OpAMD64VPSHLDD256 + return true + case OpShiftAllLeftConcatInt64x2: + v.Op = OpAMD64VPSHLDQ128 + return true + case OpShiftAllLeftConcatInt64x4: + v.Op = OpAMD64VPSHLDQ256 + return true + case OpShiftAllLeftConcatInt64x8: + v.Op = OpAMD64VPSHLDQ512 + return true + case OpShiftAllLeftConcatUint16x16: + v.Op = OpAMD64VPSHLDW256 + return true + case OpShiftAllLeftConcatUint16x32: + v.Op = OpAMD64VPSHLDW512 + return true + case OpShiftAllLeftConcatUint16x8: + v.Op = OpAMD64VPSHLDW128 + return true + case OpShiftAllLeftConcatUint32x16: + v.Op = OpAMD64VPSHLDD512 + return true + case OpShiftAllLeftConcatUint32x4: + v.Op = OpAMD64VPSHLDD128 + return true + case OpShiftAllLeftConcatUint32x8: + v.Op = OpAMD64VPSHLDD256 + return true + case OpShiftAllLeftConcatUint64x2: + v.Op = OpAMD64VPSHLDQ128 + return true + case OpShiftAllLeftConcatUint64x4: + v.Op = OpAMD64VPSHLDQ256 + return true + case OpShiftAllLeftConcatUint64x8: + v.Op = OpAMD64VPSHLDQ512 + return true + case OpShiftAllLeftInt16x16: + v.Op = OpAMD64VPSLLW256 + return true + case OpShiftAllLeftInt16x32: + v.Op = OpAMD64VPSLLW512 + return true + case OpShiftAllLeftInt16x8: + v.Op = OpAMD64VPSLLW128 + return true + case OpShiftAllLeftInt32x16: + v.Op = OpAMD64VPSLLD512 + return true + case OpShiftAllLeftInt32x4: + v.Op = OpAMD64VPSLLD128 + return true + case OpShiftAllLeftInt32x8: + v.Op = OpAMD64VPSLLD256 + return true + case OpShiftAllLeftInt64x2: + v.Op = OpAMD64VPSLLQ128 + return true + case OpShiftAllLeftInt64x4: + v.Op = OpAMD64VPSLLQ256 + return true + case OpShiftAllLeftInt64x8: + v.Op = OpAMD64VPSLLQ512 + return true + case OpShiftAllLeftUint16x16: + v.Op = OpAMD64VPSLLW256 + return true + case OpShiftAllLeftUint16x32: + v.Op = OpAMD64VPSLLW512 + return true + case OpShiftAllLeftUint16x8: + v.Op = OpAMD64VPSLLW128 + return true + case OpShiftAllLeftUint32x16: + v.Op = OpAMD64VPSLLD512 + return true + case OpShiftAllLeftUint32x4: + v.Op = OpAMD64VPSLLD128 + return true + case OpShiftAllLeftUint32x8: + v.Op = OpAMD64VPSLLD256 + return true + case OpShiftAllLeftUint64x2: + v.Op = OpAMD64VPSLLQ128 + return true + case OpShiftAllLeftUint64x4: + v.Op = OpAMD64VPSLLQ256 + return true + case OpShiftAllLeftUint64x8: + v.Op = OpAMD64VPSLLQ512 + return true + case OpShiftAllRightConcatInt16x16: + v.Op = OpAMD64VPSHRDW256 + return true + case OpShiftAllRightConcatInt16x32: + v.Op = OpAMD64VPSHRDW512 + return true + case OpShiftAllRightConcatInt16x8: + v.Op = OpAMD64VPSHRDW128 + return true + case OpShiftAllRightConcatInt32x16: + v.Op = OpAMD64VPSHRDD512 + return true + case OpShiftAllRightConcatInt32x4: + v.Op = OpAMD64VPSHRDD128 + return true + case OpShiftAllRightConcatInt32x8: + v.Op = OpAMD64VPSHRDD256 + return true + case OpShiftAllRightConcatInt64x2: + v.Op = OpAMD64VPSHRDQ128 + return true + case OpShiftAllRightConcatInt64x4: + v.Op = OpAMD64VPSHRDQ256 + return true + case OpShiftAllRightConcatInt64x8: + v.Op = OpAMD64VPSHRDQ512 + return true + case OpShiftAllRightConcatUint16x16: + v.Op = OpAMD64VPSHRDW256 + return true + case OpShiftAllRightConcatUint16x32: + v.Op = OpAMD64VPSHRDW512 + return true + case OpShiftAllRightConcatUint16x8: + v.Op = OpAMD64VPSHRDW128 + return true + case OpShiftAllRightConcatUint32x16: + v.Op = OpAMD64VPSHRDD512 + return true + case OpShiftAllRightConcatUint32x4: + v.Op = OpAMD64VPSHRDD128 + return true + case OpShiftAllRightConcatUint32x8: + v.Op = OpAMD64VPSHRDD256 + return true + case OpShiftAllRightConcatUint64x2: + v.Op = OpAMD64VPSHRDQ128 + return true + case OpShiftAllRightConcatUint64x4: + v.Op = OpAMD64VPSHRDQ256 + return true + case OpShiftAllRightConcatUint64x8: + v.Op = OpAMD64VPSHRDQ512 + return true + case OpShiftAllRightInt16x16: + v.Op = OpAMD64VPSRAW256 + return true + case OpShiftAllRightInt16x32: + v.Op = OpAMD64VPSRAW512 + return true + case OpShiftAllRightInt16x8: + v.Op = OpAMD64VPSRAW128 + return true + case OpShiftAllRightInt32x16: + v.Op = OpAMD64VPSRAD512 + return true + case OpShiftAllRightInt32x4: + v.Op = OpAMD64VPSRAD128 + return true + case OpShiftAllRightInt32x8: + v.Op = OpAMD64VPSRAD256 + return true + case OpShiftAllRightInt64x2: + v.Op = OpAMD64VPSRAQ128 + return true + case OpShiftAllRightInt64x4: + v.Op = OpAMD64VPSRAQ256 + return true + case OpShiftAllRightInt64x8: + v.Op = OpAMD64VPSRAQ512 + return true + case OpShiftAllRightUint16x16: + v.Op = OpAMD64VPSRLW256 + return true + case OpShiftAllRightUint16x32: + v.Op = OpAMD64VPSRLW512 + return true + case OpShiftAllRightUint16x8: + v.Op = OpAMD64VPSRLW128 + return true + case OpShiftAllRightUint32x16: + v.Op = OpAMD64VPSRLD512 + return true + case OpShiftAllRightUint32x4: + v.Op = OpAMD64VPSRLD128 + return true + case OpShiftAllRightUint32x8: + v.Op = OpAMD64VPSRLD256 + return true + case OpShiftAllRightUint64x2: + v.Op = OpAMD64VPSRLQ128 + return true + case OpShiftAllRightUint64x4: + v.Op = OpAMD64VPSRLQ256 + return true + case OpShiftAllRightUint64x8: + v.Op = OpAMD64VPSRLQ512 + return true + case OpShiftLeftConcatInt16x16: + v.Op = OpAMD64VPSHLDVW256 + return true + case OpShiftLeftConcatInt16x32: + v.Op = OpAMD64VPSHLDVW512 + return true + case OpShiftLeftConcatInt16x8: + v.Op = OpAMD64VPSHLDVW128 + return true + case OpShiftLeftConcatInt32x16: + v.Op = OpAMD64VPSHLDVD512 + return true + case OpShiftLeftConcatInt32x4: + v.Op = OpAMD64VPSHLDVD128 + return true + case OpShiftLeftConcatInt32x8: + v.Op = OpAMD64VPSHLDVD256 + return true + case OpShiftLeftConcatInt64x2: + v.Op = OpAMD64VPSHLDVQ128 + return true + case OpShiftLeftConcatInt64x4: + v.Op = OpAMD64VPSHLDVQ256 + return true + case OpShiftLeftConcatInt64x8: + v.Op = OpAMD64VPSHLDVQ512 + return true + case OpShiftLeftConcatUint16x16: + v.Op = OpAMD64VPSHLDVW256 + return true + case OpShiftLeftConcatUint16x32: + v.Op = OpAMD64VPSHLDVW512 + return true + case OpShiftLeftConcatUint16x8: + v.Op = OpAMD64VPSHLDVW128 + return true + case OpShiftLeftConcatUint32x16: + v.Op = OpAMD64VPSHLDVD512 + return true + case OpShiftLeftConcatUint32x4: + v.Op = OpAMD64VPSHLDVD128 + return true + case OpShiftLeftConcatUint32x8: + v.Op = OpAMD64VPSHLDVD256 + return true + case OpShiftLeftConcatUint64x2: + v.Op = OpAMD64VPSHLDVQ128 + return true + case OpShiftLeftConcatUint64x4: + v.Op = OpAMD64VPSHLDVQ256 + return true + case OpShiftLeftConcatUint64x8: + v.Op = OpAMD64VPSHLDVQ512 + return true + case OpShiftLeftInt16x16: + v.Op = OpAMD64VPSLLVW256 + return true + case OpShiftLeftInt16x32: + v.Op = OpAMD64VPSLLVW512 + return true + case OpShiftLeftInt16x8: + v.Op = OpAMD64VPSLLVW128 + return true + case OpShiftLeftInt32x16: + v.Op = OpAMD64VPSLLVD512 + return true + case OpShiftLeftInt32x4: + v.Op = OpAMD64VPSLLVD128 + return true + case OpShiftLeftInt32x8: + v.Op = OpAMD64VPSLLVD256 + return true + case OpShiftLeftInt64x2: + v.Op = OpAMD64VPSLLVQ128 + return true + case OpShiftLeftInt64x4: + v.Op = OpAMD64VPSLLVQ256 + return true + case OpShiftLeftInt64x8: + v.Op = OpAMD64VPSLLVQ512 + return true + case OpShiftLeftUint16x16: + v.Op = OpAMD64VPSLLVW256 + return true + case OpShiftLeftUint16x32: + v.Op = OpAMD64VPSLLVW512 + return true + case OpShiftLeftUint16x8: + v.Op = OpAMD64VPSLLVW128 + return true + case OpShiftLeftUint32x16: + v.Op = OpAMD64VPSLLVD512 + return true + case OpShiftLeftUint32x4: + v.Op = OpAMD64VPSLLVD128 + return true + case OpShiftLeftUint32x8: + v.Op = OpAMD64VPSLLVD256 + return true + case OpShiftLeftUint64x2: + v.Op = OpAMD64VPSLLVQ128 + return true + case OpShiftLeftUint64x4: + v.Op = OpAMD64VPSLLVQ256 + return true + case OpShiftLeftUint64x8: + v.Op = OpAMD64VPSLLVQ512 + return true + case OpShiftRightConcatInt16x16: + v.Op = OpAMD64VPSHRDVW256 + return true + case OpShiftRightConcatInt16x32: + v.Op = OpAMD64VPSHRDVW512 + return true + case OpShiftRightConcatInt16x8: + v.Op = OpAMD64VPSHRDVW128 + return true + case OpShiftRightConcatInt32x16: + v.Op = OpAMD64VPSHRDVD512 + return true + case OpShiftRightConcatInt32x4: + v.Op = OpAMD64VPSHRDVD128 + return true + case OpShiftRightConcatInt32x8: + v.Op = OpAMD64VPSHRDVD256 + return true + case OpShiftRightConcatInt64x2: + v.Op = OpAMD64VPSHRDVQ128 + return true + case OpShiftRightConcatInt64x4: + v.Op = OpAMD64VPSHRDVQ256 + return true + case OpShiftRightConcatInt64x8: + v.Op = OpAMD64VPSHRDVQ512 + return true + case OpShiftRightConcatUint16x16: + v.Op = OpAMD64VPSHRDVW256 + return true + case OpShiftRightConcatUint16x32: + v.Op = OpAMD64VPSHRDVW512 + return true + case OpShiftRightConcatUint16x8: + v.Op = OpAMD64VPSHRDVW128 + return true + case OpShiftRightConcatUint32x16: + v.Op = OpAMD64VPSHRDVD512 + return true + case OpShiftRightConcatUint32x4: + v.Op = OpAMD64VPSHRDVD128 + return true + case OpShiftRightConcatUint32x8: + v.Op = OpAMD64VPSHRDVD256 + return true + case OpShiftRightConcatUint64x2: + v.Op = OpAMD64VPSHRDVQ128 + return true + case OpShiftRightConcatUint64x4: + v.Op = OpAMD64VPSHRDVQ256 + return true + case OpShiftRightConcatUint64x8: + v.Op = OpAMD64VPSHRDVQ512 + return true + case OpShiftRightInt16x16: + v.Op = OpAMD64VPSRAVW256 + return true + case OpShiftRightInt16x32: + v.Op = OpAMD64VPSRAVW512 + return true + case OpShiftRightInt16x8: + v.Op = OpAMD64VPSRAVW128 + return true + case OpShiftRightInt32x16: + v.Op = OpAMD64VPSRAVD512 + return true + case OpShiftRightInt32x4: + v.Op = OpAMD64VPSRAVD128 + return true + case OpShiftRightInt32x8: + v.Op = OpAMD64VPSRAVD256 + return true + case OpShiftRightInt64x2: + v.Op = OpAMD64VPSRAVQ128 + return true + case OpShiftRightInt64x4: + v.Op = OpAMD64VPSRAVQ256 + return true + case OpShiftRightInt64x8: + v.Op = OpAMD64VPSRAVQ512 + return true + case OpShiftRightUint16x16: + v.Op = OpAMD64VPSRLVW256 + return true + case OpShiftRightUint16x32: + v.Op = OpAMD64VPSRLVW512 + return true + case OpShiftRightUint16x8: + v.Op = OpAMD64VPSRLVW128 + return true + case OpShiftRightUint32x16: + v.Op = OpAMD64VPSRLVD512 + return true + case OpShiftRightUint32x4: + v.Op = OpAMD64VPSRLVD128 + return true + case OpShiftRightUint32x8: + v.Op = OpAMD64VPSRLVD256 + return true + case OpShiftRightUint64x2: + v.Op = OpAMD64VPSRLVQ128 + return true + case OpShiftRightUint64x4: + v.Op = OpAMD64VPSRLVQ256 + return true + case OpShiftRightUint64x8: + v.Op = OpAMD64VPSRLVQ512 + return true + case OpSignExt16to32: + v.Op = OpAMD64MOVWQSX + return true + case OpSignExt16to64: + v.Op = OpAMD64MOVWQSX + return true + case OpSignExt32to64: + v.Op = OpAMD64MOVLQSX + return true + case OpSignExt8to16: + v.Op = OpAMD64MOVBQSX + return true + case OpSignExt8to32: + v.Op = OpAMD64MOVBQSX + return true + case OpSignExt8to64: + v.Op = OpAMD64MOVBQSX + return true + case OpSlicemask: + return rewriteValueAMD64_OpSlicemask(v) + case OpSpectreIndex: + return rewriteValueAMD64_OpSpectreIndex(v) + case OpSpectreSliceIndex: + return rewriteValueAMD64_OpSpectreSliceIndex(v) + case OpSqrt: + v.Op = OpAMD64SQRTSD + return true + case OpSqrt32: + v.Op = OpAMD64SQRTSS + return true + case OpSqrtFloat32x16: + v.Op = OpAMD64VSQRTPS512 + return true + case OpSqrtFloat32x4: + v.Op = OpAMD64VSQRTPS128 + return true + case OpSqrtFloat32x8: + v.Op = OpAMD64VSQRTPS256 + return true + case OpSqrtFloat64x2: + v.Op = OpAMD64VSQRTPD128 + return true + case OpSqrtFloat64x4: + v.Op = OpAMD64VSQRTPD256 + return true + case OpSqrtFloat64x8: + v.Op = OpAMD64VSQRTPD512 + return true + case OpStaticCall: + v.Op = OpAMD64CALLstatic + return true + case OpStore: + return rewriteValueAMD64_OpStore(v) + case OpStoreMasked16: + return rewriteValueAMD64_OpStoreMasked16(v) + case OpStoreMasked32: + return rewriteValueAMD64_OpStoreMasked32(v) + case OpStoreMasked64: + return rewriteValueAMD64_OpStoreMasked64(v) + case OpStoreMasked8: + return rewriteValueAMD64_OpStoreMasked8(v) + case OpSub16: + v.Op = OpAMD64SUBL + return true + case OpSub32: + v.Op = OpAMD64SUBL + return true + case OpSub32F: + v.Op = OpAMD64SUBSS + return true + case OpSub64: + v.Op = OpAMD64SUBQ + return true + case OpSub64F: + v.Op = OpAMD64SUBSD + return true + case OpSub8: + v.Op = OpAMD64SUBL + return true + case OpSubFloat32x16: + v.Op = OpAMD64VSUBPS512 + return true + case OpSubFloat32x4: + v.Op = OpAMD64VSUBPS128 + return true + case OpSubFloat32x8: + v.Op = OpAMD64VSUBPS256 + return true + case OpSubFloat64x2: + v.Op = OpAMD64VSUBPD128 + return true + case OpSubFloat64x4: + v.Op = OpAMD64VSUBPD256 + return true + case OpSubFloat64x8: + v.Op = OpAMD64VSUBPD512 + return true + case OpSubInt16x16: + v.Op = OpAMD64VPSUBW256 + return true + case OpSubInt16x32: + v.Op = OpAMD64VPSUBW512 + return true + case OpSubInt16x8: + v.Op = OpAMD64VPSUBW128 + return true + case OpSubInt32x16: + v.Op = OpAMD64VPSUBD512 + return true + case OpSubInt32x4: + v.Op = OpAMD64VPSUBD128 + return true + case OpSubInt32x8: + v.Op = OpAMD64VPSUBD256 + return true + case OpSubInt64x2: + v.Op = OpAMD64VPSUBQ128 + return true + case OpSubInt64x4: + v.Op = OpAMD64VPSUBQ256 + return true + case OpSubInt64x8: + v.Op = OpAMD64VPSUBQ512 + return true + case OpSubInt8x16: + v.Op = OpAMD64VPSUBB128 + return true + case OpSubInt8x32: + v.Op = OpAMD64VPSUBB256 + return true + case OpSubInt8x64: + v.Op = OpAMD64VPSUBB512 + return true + case OpSubPairsFloat32x4: + v.Op = OpAMD64VHSUBPS128 + return true + case OpSubPairsFloat64x2: + v.Op = OpAMD64VHSUBPD128 + return true + case OpSubPairsGroupedFloat32x8: + v.Op = OpAMD64VHSUBPS256 + return true + case OpSubPairsGroupedFloat64x4: + v.Op = OpAMD64VHSUBPD256 + return true + case OpSubPairsGroupedInt16x16: + v.Op = OpAMD64VPHSUBW256 + return true + case OpSubPairsGroupedInt32x8: + v.Op = OpAMD64VPHSUBD256 + return true + case OpSubPairsGroupedUint16x16: + v.Op = OpAMD64VPHSUBW256 + return true + case OpSubPairsGroupedUint32x8: + v.Op = OpAMD64VPHSUBD256 + return true + case OpSubPairsInt16x8: + v.Op = OpAMD64VPHSUBW128 + return true + case OpSubPairsInt32x4: + v.Op = OpAMD64VPHSUBD128 + return true + case OpSubPairsSaturatedGroupedInt16x16: + v.Op = OpAMD64VPHSUBSW256 + return true + case OpSubPairsSaturatedInt16x8: + v.Op = OpAMD64VPHSUBSW128 + return true + case OpSubPairsUint16x8: + v.Op = OpAMD64VPHSUBW128 + return true + case OpSubPairsUint32x4: + v.Op = OpAMD64VPHSUBD128 + return true + case OpSubPtr: + v.Op = OpAMD64SUBQ + return true + case OpSubSaturatedInt16x16: + v.Op = OpAMD64VPSUBSW256 + return true + case OpSubSaturatedInt16x32: + v.Op = OpAMD64VPSUBSW512 + return true + case OpSubSaturatedInt16x8: + v.Op = OpAMD64VPSUBSW128 + return true + case OpSubSaturatedInt8x16: + v.Op = OpAMD64VPSUBSB128 + return true + case OpSubSaturatedInt8x32: + v.Op = OpAMD64VPSUBSB256 + return true + case OpSubSaturatedInt8x64: + v.Op = OpAMD64VPSUBSB512 + return true + case OpSubSaturatedUint16x16: + v.Op = OpAMD64VPSUBUSW256 + return true + case OpSubSaturatedUint16x32: + v.Op = OpAMD64VPSUBUSW512 + return true + case OpSubSaturatedUint16x8: + v.Op = OpAMD64VPSUBUSW128 + return true + case OpSubSaturatedUint8x16: + v.Op = OpAMD64VPSUBUSB128 + return true + case OpSubSaturatedUint8x32: + v.Op = OpAMD64VPSUBUSB256 + return true + case OpSubSaturatedUint8x64: + v.Op = OpAMD64VPSUBUSB512 + return true + case OpSubUint16x16: + v.Op = OpAMD64VPSUBW256 + return true + case OpSubUint16x32: + v.Op = OpAMD64VPSUBW512 + return true + case OpSubUint16x8: + v.Op = OpAMD64VPSUBW128 + return true + case OpSubUint32x16: + v.Op = OpAMD64VPSUBD512 + return true + case OpSubUint32x4: + v.Op = OpAMD64VPSUBD128 + return true + case OpSubUint32x8: + v.Op = OpAMD64VPSUBD256 + return true + case OpSubUint64x2: + v.Op = OpAMD64VPSUBQ128 + return true + case OpSubUint64x4: + v.Op = OpAMD64VPSUBQ256 + return true + case OpSubUint64x8: + v.Op = OpAMD64VPSUBQ512 + return true + case OpSubUint8x16: + v.Op = OpAMD64VPSUBB128 + return true + case OpSubUint8x32: + v.Op = OpAMD64VPSUBB256 + return true + case OpSubUint8x64: + v.Op = OpAMD64VPSUBB512 + return true + case OpSumAbsDiffUint8x16: + v.Op = OpAMD64VPSADBW128 + return true + case OpSumAbsDiffUint8x32: + v.Op = OpAMD64VPSADBW256 + return true + case OpSumAbsDiffUint8x64: + v.Op = OpAMD64VPSADBW512 + return true + case OpTailCall: + v.Op = OpAMD64CALLtail + return true + case OpTrunc: + return rewriteValueAMD64_OpTrunc(v) + case OpTrunc16to8: + v.Op = OpCopy + return true + case OpTrunc32to16: + v.Op = OpCopy + return true + case OpTrunc32to8: + v.Op = OpCopy + return true + case OpTrunc64to16: + v.Op = OpCopy + return true + case OpTrunc64to32: + v.Op = OpCopy + return true + case OpTrunc64to8: + v.Op = OpCopy + return true + case OpTruncFloat32x4: + return rewriteValueAMD64_OpTruncFloat32x4(v) + case OpTruncFloat32x8: + return rewriteValueAMD64_OpTruncFloat32x8(v) + case OpTruncFloat64x2: + return rewriteValueAMD64_OpTruncFloat64x2(v) + case OpTruncFloat64x4: + return rewriteValueAMD64_OpTruncFloat64x4(v) + case OpTruncScaledFloat32x16: + return rewriteValueAMD64_OpTruncScaledFloat32x16(v) + case OpTruncScaledFloat32x4: + return rewriteValueAMD64_OpTruncScaledFloat32x4(v) + case OpTruncScaledFloat32x8: + return rewriteValueAMD64_OpTruncScaledFloat32x8(v) + case OpTruncScaledFloat64x2: + return rewriteValueAMD64_OpTruncScaledFloat64x2(v) + case OpTruncScaledFloat64x4: + return rewriteValueAMD64_OpTruncScaledFloat64x4(v) + case OpTruncScaledFloat64x8: + return rewriteValueAMD64_OpTruncScaledFloat64x8(v) + case OpTruncScaledResidueFloat32x16: + return rewriteValueAMD64_OpTruncScaledResidueFloat32x16(v) + case OpTruncScaledResidueFloat32x4: + return rewriteValueAMD64_OpTruncScaledResidueFloat32x4(v) + case OpTruncScaledResidueFloat32x8: + return rewriteValueAMD64_OpTruncScaledResidueFloat32x8(v) + case OpTruncScaledResidueFloat64x2: + return rewriteValueAMD64_OpTruncScaledResidueFloat64x2(v) + case OpTruncScaledResidueFloat64x4: + return rewriteValueAMD64_OpTruncScaledResidueFloat64x4(v) + case OpTruncScaledResidueFloat64x8: + return rewriteValueAMD64_OpTruncScaledResidueFloat64x8(v) + case OpTruncateToInt16Int32x16: + v.Op = OpAMD64VPMOVDW256 + return true + case OpTruncateToInt16Int32x4: + v.Op = OpAMD64VPMOVDW128_128 + return true + case OpTruncateToInt16Int32x8: + v.Op = OpAMD64VPMOVDW128_256 + return true + case OpTruncateToInt16Int64x2: + v.Op = OpAMD64VPMOVQW128_128 + return true + case OpTruncateToInt16Int64x4: + v.Op = OpAMD64VPMOVQW128_256 + return true + case OpTruncateToInt16Int64x8: + v.Op = OpAMD64VPMOVQW128_512 + return true + case OpTruncateToInt32Int64x2: + v.Op = OpAMD64VPMOVQD128_128 + return true + case OpTruncateToInt32Int64x4: + v.Op = OpAMD64VPMOVQD128_256 + return true + case OpTruncateToInt32Int64x8: + v.Op = OpAMD64VPMOVQD256 + return true + case OpTruncateToInt8Int16x16: + v.Op = OpAMD64VPMOVWB128_256 + return true + case OpTruncateToInt8Int16x32: + v.Op = OpAMD64VPMOVWB256 + return true + case OpTruncateToInt8Int16x8: + v.Op = OpAMD64VPMOVWB128_128 + return true + case OpTruncateToInt8Int32x16: + v.Op = OpAMD64VPMOVDB128_512 + return true + case OpTruncateToInt8Int32x4: + v.Op = OpAMD64VPMOVDB128_128 + return true + case OpTruncateToInt8Int32x8: + v.Op = OpAMD64VPMOVDB128_256 + return true + case OpTruncateToInt8Int64x2: + v.Op = OpAMD64VPMOVQB128_128 + return true + case OpTruncateToInt8Int64x4: + v.Op = OpAMD64VPMOVQB128_256 + return true + case OpTruncateToInt8Int64x8: + v.Op = OpAMD64VPMOVQB128_512 + return true + case OpTruncateToUint16Uint32x16: + v.Op = OpAMD64VPMOVDW256 + return true + case OpTruncateToUint16Uint32x4: + v.Op = OpAMD64VPMOVDW128_128 + return true + case OpTruncateToUint16Uint32x8: + v.Op = OpAMD64VPMOVDW128_256 + return true + case OpTruncateToUint16Uint64x2: + v.Op = OpAMD64VPMOVQW128_128 + return true + case OpTruncateToUint16Uint64x4: + v.Op = OpAMD64VPMOVQW128_256 + return true + case OpTruncateToUint16Uint64x8: + v.Op = OpAMD64VPMOVQW128_512 + return true + case OpTruncateToUint32Uint64x2: + v.Op = OpAMD64VPMOVQD128_128 + return true + case OpTruncateToUint32Uint64x4: + v.Op = OpAMD64VPMOVQD128_256 + return true + case OpTruncateToUint32Uint64x8: + v.Op = OpAMD64VPMOVQD256 + return true + case OpTruncateToUint8Uint16x16: + v.Op = OpAMD64VPMOVWB128_256 + return true + case OpTruncateToUint8Uint16x32: + v.Op = OpAMD64VPMOVWB256 + return true + case OpTruncateToUint8Uint16x8: + v.Op = OpAMD64VPMOVWB128_128 + return true + case OpTruncateToUint8Uint32x16: + v.Op = OpAMD64VPMOVDB128_512 + return true + case OpTruncateToUint8Uint32x4: + v.Op = OpAMD64VPMOVDB128_128 + return true + case OpTruncateToUint8Uint32x8: + v.Op = OpAMD64VPMOVDB128_256 + return true + case OpTruncateToUint8Uint64x2: + v.Op = OpAMD64VPMOVQB128_128 + return true + case OpTruncateToUint8Uint64x4: + v.Op = OpAMD64VPMOVQB128_256 + return true + case OpTruncateToUint8Uint64x8: + v.Op = OpAMD64VPMOVQB128_512 + return true + case OpWB: + v.Op = OpAMD64LoweredWB + return true + case OpXor16: + v.Op = OpAMD64XORL + return true + case OpXor32: + v.Op = OpAMD64XORL + return true + case OpXor64: + v.Op = OpAMD64XORQ + return true + case OpXor8: + v.Op = OpAMD64XORL + return true + case OpXorInt16x16: + v.Op = OpAMD64VPXOR256 + return true + case OpXorInt16x32: + v.Op = OpAMD64VPXORD512 + return true + case OpXorInt16x8: + v.Op = OpAMD64VPXOR128 + return true + case OpXorInt32x16: + v.Op = OpAMD64VPXORD512 + return true + case OpXorInt32x4: + v.Op = OpAMD64VPXOR128 + return true + case OpXorInt32x8: + v.Op = OpAMD64VPXOR256 + return true + case OpXorInt64x2: + v.Op = OpAMD64VPXOR128 + return true + case OpXorInt64x4: + v.Op = OpAMD64VPXOR256 + return true + case OpXorInt64x8: + v.Op = OpAMD64VPXORQ512 + return true + case OpXorInt8x16: + v.Op = OpAMD64VPXOR128 + return true + case OpXorInt8x32: + v.Op = OpAMD64VPXOR256 + return true + case OpXorInt8x64: + v.Op = OpAMD64VPXORD512 + return true + case OpXorUint16x16: + v.Op = OpAMD64VPXOR256 + return true + case OpXorUint16x32: + v.Op = OpAMD64VPXORD512 + return true + case OpXorUint16x8: + v.Op = OpAMD64VPXOR128 + return true + case OpXorUint32x16: + v.Op = OpAMD64VPXORD512 + return true + case OpXorUint32x4: + v.Op = OpAMD64VPXOR128 + return true + case OpXorUint32x8: + v.Op = OpAMD64VPXOR256 + return true + case OpXorUint64x2: + v.Op = OpAMD64VPXOR128 + return true + case OpXorUint64x4: + v.Op = OpAMD64VPXOR256 + return true + case OpXorUint64x8: + v.Op = OpAMD64VPXORQ512 + return true + case OpXorUint8x16: + v.Op = OpAMD64VPXOR128 + return true + case OpXorUint8x32: + v.Op = OpAMD64VPXOR256 + return true + case OpXorUint8x64: + v.Op = OpAMD64VPXORD512 + return true + case OpZero: + return rewriteValueAMD64_OpZero(v) + case OpZeroExt16to32: + v.Op = OpAMD64MOVWQZX + return true + case OpZeroExt16to64: + v.Op = OpAMD64MOVWQZX + return true + case OpZeroExt32to64: + v.Op = OpAMD64MOVLQZX + return true + case OpZeroExt8to16: + v.Op = OpAMD64MOVBQZX + return true + case OpZeroExt8to32: + v.Op = OpAMD64MOVBQZX + return true + case OpZeroExt8to64: + v.Op = OpAMD64MOVBQZX + return true + case OpZeroSIMD: + return rewriteValueAMD64_OpZeroSIMD(v) + case OpblendInt8x16: + v.Op = OpAMD64VPBLENDVB128 + return true + case OpblendInt8x32: + v.Op = OpAMD64VPBLENDVB256 + return true + case OpblendMaskedInt16x32: + return rewriteValueAMD64_OpblendMaskedInt16x32(v) + case OpblendMaskedInt32x16: + return rewriteValueAMD64_OpblendMaskedInt32x16(v) + case OpblendMaskedInt64x8: + return rewriteValueAMD64_OpblendMaskedInt64x8(v) + case OpblendMaskedInt8x64: + return rewriteValueAMD64_OpblendMaskedInt8x64(v) + case OpcarrylessMultiplyUint64x2: + v.Op = OpAMD64VPCLMULQDQ128 + return true + case OpcarrylessMultiplyUint64x4: + v.Op = OpAMD64VPCLMULQDQ256 + return true + case OpcarrylessMultiplyUint64x8: + v.Op = OpAMD64VPCLMULQDQ512 + return true + case OpconcatSelectedConstantFloat32x4: + v.Op = OpAMD64VSHUFPS128 + return true + case OpconcatSelectedConstantFloat64x2: + v.Op = OpAMD64VSHUFPD128 + return true + case OpconcatSelectedConstantGroupedFloat32x16: + v.Op = OpAMD64VSHUFPS512 + return true + case OpconcatSelectedConstantGroupedFloat32x8: + v.Op = OpAMD64VSHUFPS256 + return true + case OpconcatSelectedConstantGroupedFloat64x4: + v.Op = OpAMD64VSHUFPD256 + return true + case OpconcatSelectedConstantGroupedFloat64x8: + v.Op = OpAMD64VSHUFPD512 + return true + case OpconcatSelectedConstantGroupedInt32x16: + v.Op = OpAMD64VSHUFPS512 + return true + case OpconcatSelectedConstantGroupedInt32x8: + v.Op = OpAMD64VSHUFPS256 + return true + case OpconcatSelectedConstantGroupedInt64x4: + v.Op = OpAMD64VSHUFPD256 + return true + case OpconcatSelectedConstantGroupedInt64x8: + v.Op = OpAMD64VSHUFPD512 + return true + case OpconcatSelectedConstantGroupedUint32x16: + v.Op = OpAMD64VSHUFPS512 + return true + case OpconcatSelectedConstantGroupedUint32x8: + v.Op = OpAMD64VSHUFPS256 + return true + case OpconcatSelectedConstantGroupedUint64x4: + v.Op = OpAMD64VSHUFPD256 + return true + case OpconcatSelectedConstantGroupedUint64x8: + v.Op = OpAMD64VSHUFPD512 + return true + case OpconcatSelectedConstantInt32x4: + v.Op = OpAMD64VSHUFPS128 + return true + case OpconcatSelectedConstantInt64x2: + v.Op = OpAMD64VSHUFPD128 + return true + case OpconcatSelectedConstantUint32x4: + v.Op = OpAMD64VSHUFPS128 + return true + case OpconcatSelectedConstantUint64x2: + v.Op = OpAMD64VSHUFPD128 + return true + case OppermuteScalarsGroupedInt32x16: + v.Op = OpAMD64VPSHUFD512 + return true + case OppermuteScalarsGroupedInt32x8: + v.Op = OpAMD64VPSHUFD256 + return true + case OppermuteScalarsGroupedUint32x16: + v.Op = OpAMD64VPSHUFD512 + return true + case OppermuteScalarsGroupedUint32x8: + v.Op = OpAMD64VPSHUFD256 + return true + case OppermuteScalarsHiGroupedInt16x16: + v.Op = OpAMD64VPSHUFHW256 + return true + case OppermuteScalarsHiGroupedInt16x32: + v.Op = OpAMD64VPSHUFHW512 + return true + case OppermuteScalarsHiGroupedUint16x16: + v.Op = OpAMD64VPSHUFHW256 + return true + case OppermuteScalarsHiGroupedUint16x32: + v.Op = OpAMD64VPSHUFHW512 + return true + case OppermuteScalarsHiInt16x8: + v.Op = OpAMD64VPSHUFHW128 + return true + case OppermuteScalarsHiUint16x8: + v.Op = OpAMD64VPSHUFHW128 + return true + case OppermuteScalarsInt32x4: + v.Op = OpAMD64VPSHUFD128 + return true + case OppermuteScalarsLoGroupedInt16x16: + v.Op = OpAMD64VPSHUFLW256 + return true + case OppermuteScalarsLoGroupedInt16x32: + v.Op = OpAMD64VPSHUFLW512 + return true + case OppermuteScalarsLoGroupedUint16x16: + v.Op = OpAMD64VPSHUFLW256 + return true + case OppermuteScalarsLoGroupedUint16x32: + v.Op = OpAMD64VPSHUFLW512 + return true + case OppermuteScalarsLoInt16x8: + v.Op = OpAMD64VPSHUFLW128 + return true + case OppermuteScalarsLoUint16x8: + v.Op = OpAMD64VPSHUFLW128 + return true + case OppermuteScalarsUint32x4: + v.Op = OpAMD64VPSHUFD128 + return true + case OpternInt32x16: + v.Op = OpAMD64VPTERNLOGD512 + return true + case OpternInt32x4: + v.Op = OpAMD64VPTERNLOGD128 + return true + case OpternInt32x8: + v.Op = OpAMD64VPTERNLOGD256 + return true + case OpternInt64x2: + v.Op = OpAMD64VPTERNLOGQ128 + return true + case OpternInt64x4: + v.Op = OpAMD64VPTERNLOGQ256 + return true + case OpternInt64x8: + v.Op = OpAMD64VPTERNLOGQ512 + return true + case OpternUint32x16: + v.Op = OpAMD64VPTERNLOGD512 + return true + case OpternUint32x4: + v.Op = OpAMD64VPTERNLOGD128 + return true + case OpternUint32x8: + v.Op = OpAMD64VPTERNLOGD256 + return true + case OpternUint64x2: + v.Op = OpAMD64VPTERNLOGQ128 + return true + case OpternUint64x4: + v.Op = OpAMD64VPTERNLOGQ256 + return true + case OpternUint64x8: + v.Op = OpAMD64VPTERNLOGQ512 + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADCQ(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADCQ x (MOVQconst [c]) carry) + // cond: is32Bit(c) + // result: (ADCQconst x [int32(c)] carry) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + carry := v_2 + if !(is32Bit(c)) { + continue + } + v.reset(OpAMD64ADCQconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(x, carry) + return true + } + break + } + // match: (ADCQ x y (FlagEQ)) + // result: (ADDQcarry x y) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64ADDQcarry) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADCQconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADCQconst x [c] (FlagEQ)) + // result: (ADDQconstcarry x [c]) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64ADDQconstcarry) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADDL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDL (SHRLconst [1] x) (SHRLconst [1] x)) + // result: (ANDLconst [-2] x) + for { + if v_0.Op != OpAMD64SHRLconst || auxIntToInt8(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + if v_1.Op != OpAMD64SHRLconst || auxIntToInt8(v_1.AuxInt) != 1 || x != v_1.Args[0] { + break + } + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(-2) + v.AddArg(x) + return true + } + // match: (ADDL x (MOVLconst [c])) + // result: (ADDLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ADDLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ADDL x (SHLLconst [3] y)) + // result: (LEAL8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64SHLLconst || auxIntToInt8(v_1.AuxInt) != 3 { + continue + } + y := v_1.Args[0] + v.reset(OpAMD64LEAL8) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x (SHLLconst [2] y)) + // result: (LEAL4 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64SHLLconst || auxIntToInt8(v_1.AuxInt) != 2 { + continue + } + y := v_1.Args[0] + v.reset(OpAMD64LEAL4) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x (ADDL y y)) + // result: (LEAL2 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64ADDL { + continue + } + y := v_1.Args[1] + if y != v_1.Args[0] { + continue + } + v.reset(OpAMD64LEAL2) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x (ADDL x y)) + // result: (LEAL2 y x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64ADDL { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpAMD64LEAL2) + v.AddArg2(y, x) + return true + } + } + break + } + // match: (ADDL (ADDLconst [c] x) y) + // result: (LEAL1 [c] x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64ADDLconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + v.reset(OpAMD64LEAL1) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x (LEAL [c] {s} y)) + // cond: x.Op != OpSB && y.Op != OpSB + // result: (LEAL1 [c] {s} x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64LEAL { + continue + } + c := auxIntToInt32(v_1.AuxInt) + s := auxToSym(v_1.Aux) + y := v_1.Args[0] + if !(x.Op != OpSB && y.Op != OpSB) { + continue + } + v.reset(OpAMD64LEAL1) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x (NEGL y)) + // result: (SUBL x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64NEGL { + continue + } + y := v_1.Args[0] + v.reset(OpAMD64SUBL) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ADDLload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVLload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64ADDLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64ADDLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDLconst [c] (ADDL x y)) + // result: (LEAL1 [c] x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64ADDL { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpAMD64LEAL1) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (ADDLconst [c] (ADDL x x)) + // result: (LEAL1 [c] x x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64ADDL { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpAMD64LEAL1) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, x) + return true + } + // match: (ADDLconst [c] (LEAL [d] {s} x)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL [c+d] {s} x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64LEAL { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAL) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg(x) + return true + } + // match: (ADDLconst [c] (LEAL1 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL1 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64LEAL1 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAL1) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDLconst [c] (LEAL2 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL2 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64LEAL2 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAL2) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDLconst [c] (LEAL4 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL4 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64LEAL4 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAL4) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDLconst [c] (LEAL8 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL8 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64LEAL8 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAL8) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDLconst [c] x) + // cond: c==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c == 0) { + break + } + v.copyOf(x) + return true + } + // match: (ADDLconst [c] (MOVLconst [d])) + // result: (MOVLconst [c+d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(c + d) + return true + } + // match: (ADDLconst [c] (ADDLconst [d] x)) + // result: (ADDLconst [c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64ADDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64ADDLconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg(x) + return true + } + // match: (ADDLconst [off] x:(SP)) + // result: (LEAL [off] x) + for { + off := auxIntToInt32(v.AuxInt) + x := v_0 + if x.Op != OpSP { + break + } + v.reset(OpAMD64LEAL) + v.AuxInt = int32ToAuxInt(off) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADDLconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDLconstmodify [valoff1] {sym} (ADDQconst [off2] base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) + // result: (ADDLconstmodify [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2)) { + break + } + v.reset(OpAMD64ADDLconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (ADDLconstmodify [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) + // result: (ADDLconstmodify [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ADDLconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADDLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADDLload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ADDLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ADDLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDLload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ADDLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ADDLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDLload x [off] {sym} ptr (MOVSSstore [off] {sym} ptr y _)) + // result: (ADDL x (MOVLf2i y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVSSstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64ADDL) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVLf2i, typ.UInt32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADDLmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDLmodify [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ADDLmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ADDLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (ADDLmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ADDLmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ADDLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADDQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDQ (SHRQconst [1] x) (SHRQconst [1] x)) + // result: (ANDQconst [-2] x) + for { + if v_0.Op != OpAMD64SHRQconst || auxIntToInt8(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + if v_1.Op != OpAMD64SHRQconst || auxIntToInt8(v_1.AuxInt) != 1 || x != v_1.Args[0] { + break + } + v.reset(OpAMD64ANDQconst) + v.AuxInt = int32ToAuxInt(-2) + v.AddArg(x) + return true + } + // match: (ADDQ x (MOVQconst [c])) + // cond: is32Bit(c) && !t.IsPtr() + // result: (ADDQconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + continue + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c) && !t.IsPtr()) { + continue + } + v.reset(OpAMD64ADDQconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (ADDQ x (MOVLconst [c])) + // result: (ADDQconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ADDQconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ADDQ x (SHLQconst [3] y)) + // result: (LEAQ8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64SHLQconst || auxIntToInt8(v_1.AuxInt) != 3 { + continue + } + y := v_1.Args[0] + v.reset(OpAMD64LEAQ8) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDQ x (SHLQconst [2] y)) + // result: (LEAQ4 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64SHLQconst || auxIntToInt8(v_1.AuxInt) != 2 { + continue + } + y := v_1.Args[0] + v.reset(OpAMD64LEAQ4) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDQ x (ADDQ y y)) + // result: (LEAQ2 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64ADDQ { + continue + } + y := v_1.Args[1] + if y != v_1.Args[0] { + continue + } + v.reset(OpAMD64LEAQ2) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDQ x (ADDQ x y)) + // result: (LEAQ2 y x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64ADDQ { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpAMD64LEAQ2) + v.AddArg2(y, x) + return true + } + } + break + } + // match: (ADDQ (ADDQconst [c] x) y) + // result: (LEAQ1 [c] x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64ADDQconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + v.reset(OpAMD64LEAQ1) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDQ x (LEAQ [c] {s} y)) + // cond: x.Op != OpSB && y.Op != OpSB + // result: (LEAQ1 [c] {s} x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64LEAQ { + continue + } + c := auxIntToInt32(v_1.AuxInt) + s := auxToSym(v_1.Aux) + y := v_1.Args[0] + if !(x.Op != OpSB && y.Op != OpSB) { + continue + } + v.reset(OpAMD64LEAQ1) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDQ x (NEGQ y)) + // result: (SUBQ x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + continue + } + y := v_1.Args[0] + v.reset(OpAMD64SUBQ) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDQ x l:(MOVQload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ADDQload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVQload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64ADDQload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64ADDQcarry(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDQcarry x (MOVQconst [c])) + // cond: is32Bit(c) + // result: (ADDQconstcarry x [int32(c)]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpAMD64ADDQconstcarry) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64ADDQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDQconst [c] (ADDQ x y)) + // result: (LEAQ1 [c] x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64ADDQ { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpAMD64LEAQ1) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (ADDQconst [c] (ADDQ x x)) + // result: (LEAQ1 [c] x x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64ADDQ { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpAMD64LEAQ1) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, x) + return true + } + // match: (ADDQconst [c] (LEAQ [d] {s} x)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAQ [c+d] {s} x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64LEAQ { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAQ) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg(x) + return true + } + // match: (ADDQconst [c] (LEAQ1 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAQ1 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64LEAQ1 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAQ1) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDQconst [c] (LEAQ2 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAQ2 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64LEAQ2 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAQ2) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDQconst [c] (LEAQ4 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAQ4 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64LEAQ4 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAQ4) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDQconst [c] (LEAQ8 [d] {s} x y)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAQ8 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64LEAQ8 { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAQ8) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDQconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ADDQconst [c] (MOVQconst [d])) + // result: (MOVQconst [int64(c)+d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(c) + d) + return true + } + // match: (ADDQconst [c] (ADDQconst [d] x)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (ADDQconst [c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64ADDQconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64ADDQconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg(x) + return true + } + // match: (ADDQconst [off] x:(SP)) + // result: (LEAQ [off] x) + for { + off := auxIntToInt32(v.AuxInt) + x := v_0 + if x.Op != OpSP { + break + } + v.reset(OpAMD64LEAQ) + v.AuxInt = int32ToAuxInt(off) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADDQconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDQconstmodify [valoff1] {sym} (ADDQconst [off2] base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) + // result: (ADDQconstmodify [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2)) { + break + } + v.reset(OpAMD64ADDQconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (ADDQconstmodify [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) + // result: (ADDQconstmodify [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ADDQconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADDQload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADDQload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ADDQload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ADDQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDQload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ADDQload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ADDQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDQload x [off] {sym} ptr (MOVSDstore [off] {sym} ptr y _)) + // result: (ADDQ x (MOVQf2i y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVSDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64ADDQ) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVQf2i, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADDQmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDQmodify [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ADDQmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ADDQmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (ADDQmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ADDQmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ADDQmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADDSD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDSD x l:(MOVSDload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ADDSDload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVSDload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64ADDSDload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (ADDSD (MULSD x y) z) + // cond: buildcfg.GOAMD64 >= 3 && z.Block.Func.useFMA(v) + // result: (VFMADD231SD z x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64MULSD { + continue + } + y := v_0.Args[1] + x := v_0.Args[0] + z := v_1 + if !(buildcfg.GOAMD64 >= 3 && z.Block.Func.useFMA(v)) { + continue + } + v.reset(OpAMD64VFMADD231SD) + v.AddArg3(z, x, y) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64ADDSDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADDSDload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ADDSDload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ADDSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDSDload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ADDSDload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ADDSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDSDload x [off] {sym} ptr (MOVQstore [off] {sym} ptr y _)) + // result: (ADDSD x (MOVQi2f y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVQstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64ADDSD) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVQi2f, typ.Float64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ADDSS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDSS x l:(MOVSSload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ADDSSload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVSSload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64ADDSSload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (ADDSS (MULSS x y) z) + // cond: buildcfg.GOAMD64 >= 3 && z.Block.Func.useFMA(v) + // result: (VFMADD231SS z x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64MULSS { + continue + } + y := v_0.Args[1] + x := v_0.Args[0] + z := v_1 + if !(buildcfg.GOAMD64 >= 3 && z.Block.Func.useFMA(v)) { + continue + } + v.reset(OpAMD64VFMADD231SS) + v.AddArg3(z, x, y) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64ADDSSload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADDSSload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ADDSSload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ADDSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDSSload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ADDSSload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ADDSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (ADDSSload x [off] {sym} ptr (MOVLstore [off] {sym} ptr y _)) + // result: (ADDSS x (MOVLi2f y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVLstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64ADDSS) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVLi2f, typ.Float32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ANDL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ANDL (NOTL (SHLL (MOVLconst [1]) y)) x) + // result: (BTRL x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64NOTL { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SHLL { + continue + } + y := v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_0_0_0.AuxInt) != 1 { + continue + } + x := v_1 + v.reset(OpAMD64BTRL) + v.AddArg2(x, y) + return true + } + break + } + // match: (ANDL x (MOVLconst [c])) + // result: (ANDLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ANDL x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (ANDL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ANDLload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVLload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64ANDLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (ANDL x (NOTL y)) + // cond: buildcfg.GOAMD64 >= 3 + // result: (ANDNL x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64NOTL { + continue + } + y := v_1.Args[0] + if !(buildcfg.GOAMD64 >= 3) { + continue + } + v.reset(OpAMD64ANDNL) + v.AddArg2(x, y) + return true + } + break + } + // match: (ANDL x (NEGL x)) + // cond: buildcfg.GOAMD64 >= 3 + // result: (BLSIL x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64NEGL || x != v_1.Args[0] || !(buildcfg.GOAMD64 >= 3) { + continue + } + v.reset(OpAMD64BLSIL) + v.AddArg(x) + return true + } + break + } + // match: (ANDL x (ADDLconst [-1] x)) + // cond: buildcfg.GOAMD64 >= 3 + // result: (Select0 (BLSRL x)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64ADDLconst || auxIntToInt32(v_1.AuxInt) != -1 || x != v_1.Args[0] || !(buildcfg.GOAMD64 >= 3) { + continue + } + v.reset(OpSelect0) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64BLSRL, types.NewTuple(typ.UInt32, types.TypeFlags)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64ANDLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDLconst [c] (ANDLconst [d] x)) + // result: (ANDLconst [c & d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64ANDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(c & d) + v.AddArg(x) + return true + } + // match: (ANDLconst [ 0xFF] x) + // result: (MOVBQZX x) + for { + if auxIntToInt32(v.AuxInt) != 0xFF { + break + } + x := v_0 + v.reset(OpAMD64MOVBQZX) + v.AddArg(x) + return true + } + // match: (ANDLconst [0xFFFF] x) + // result: (MOVWQZX x) + for { + if auxIntToInt32(v.AuxInt) != 0xFFFF { + break + } + x := v_0 + v.reset(OpAMD64MOVWQZX) + v.AddArg(x) + return true + } + // match: (ANDLconst [c] _) + // cond: c==0 + // result: (MOVLconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if !(c == 0) { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (ANDLconst [c] x) + // cond: c==-1 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c == -1) { + break + } + v.copyOf(x) + return true + } + // match: (ANDLconst [c] (MOVLconst [d])) + // result: (MOVLconst [c&d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(c & d) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ANDLconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ANDLconstmodify [valoff1] {sym} (ADDQconst [off2] base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) + // result: (ANDLconstmodify [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2)) { + break + } + v.reset(OpAMD64ANDLconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (ANDLconstmodify [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) + // result: (ANDLconstmodify [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ANDLconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ANDLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ANDLload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ANDLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ANDLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ANDLload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ANDLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ANDLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (ANDLload x [off] {sym} ptr (MOVSSstore [off] {sym} ptr y _)) + // result: (ANDL x (MOVLf2i y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVSSstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVLf2i, typ.UInt32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ANDLmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ANDLmodify [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ANDLmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ANDLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (ANDLmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ANDLmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ANDLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ANDNL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ANDNL x (SHLL (MOVLconst [1]) y)) + // result: (BTRL x y) + for { + x := v_0 + if v_1.Op != OpAMD64SHLL { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_1_0.AuxInt) != 1 { + break + } + v.reset(OpAMD64BTRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ANDNQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ANDNQ x (SHLQ (MOVQconst [1]) y)) + // result: (BTRQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64SHLQ { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_1_0.AuxInt) != 1 { + break + } + v.reset(OpAMD64BTRQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ANDQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ANDQ (NOTQ (SHLQ (MOVQconst [1]) y)) x) + // result: (BTRQ x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64NOTQ { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SHLQ { + continue + } + y := v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_0_0_0.AuxInt) != 1 { + continue + } + x := v_1 + v.reset(OpAMD64BTRQ) + v.AddArg2(x, y) + return true + } + break + } + // match: (ANDQ (MOVQconst [c]) x) + // cond: isUnsignedPowerOfTwo(uint64(^c)) && uint64(^c) >= 1<<31 + // result: (BTRQconst [int8(log64u(uint64(^c)))] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(isUnsignedPowerOfTwo(uint64(^c)) && uint64(^c) >= 1<<31) { + continue + } + v.reset(OpAMD64BTRQconst) + v.AuxInt = int8ToAuxInt(int8(log64u(uint64(^c)))) + v.AddArg(x) + return true + } + break + } + // match: (ANDQ x (MOVQconst [c])) + // cond: is32Bit(c) + // result: (ANDQconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpAMD64ANDQconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (ANDQ x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (ANDQ x l:(MOVQload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ANDQload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVQload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64ANDQload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (ANDQ x (NOTQ y)) + // cond: buildcfg.GOAMD64 >= 3 + // result: (ANDNQ x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64NOTQ { + continue + } + y := v_1.Args[0] + if !(buildcfg.GOAMD64 >= 3) { + continue + } + v.reset(OpAMD64ANDNQ) + v.AddArg2(x, y) + return true + } + break + } + // match: (ANDQ x (NEGQ x)) + // cond: buildcfg.GOAMD64 >= 3 + // result: (BLSIQ x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64NEGQ || x != v_1.Args[0] || !(buildcfg.GOAMD64 >= 3) { + continue + } + v.reset(OpAMD64BLSIQ) + v.AddArg(x) + return true + } + break + } + // match: (ANDQ x (ADDQconst [-1] x)) + // cond: buildcfg.GOAMD64 >= 3 + // result: (Select0 (BLSRQ x)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64ADDQconst || auxIntToInt32(v_1.AuxInt) != -1 || x != v_1.Args[0] || !(buildcfg.GOAMD64 >= 3) { + continue + } + v.reset(OpSelect0) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64BLSRQ, types.NewTuple(typ.UInt64, types.TypeFlags)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64ANDQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDQconst [c] (ANDQconst [d] x)) + // result: (ANDQconst [c & d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64ANDQconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64ANDQconst) + v.AuxInt = int32ToAuxInt(c & d) + v.AddArg(x) + return true + } + // match: (ANDQconst [ 0xFF] x) + // result: (MOVBQZX x) + for { + if auxIntToInt32(v.AuxInt) != 0xFF { + break + } + x := v_0 + v.reset(OpAMD64MOVBQZX) + v.AddArg(x) + return true + } + // match: (ANDQconst [0xFFFF] x) + // result: (MOVWQZX x) + for { + if auxIntToInt32(v.AuxInt) != 0xFFFF { + break + } + x := v_0 + v.reset(OpAMD64MOVWQZX) + v.AddArg(x) + return true + } + // match: (ANDQconst [0] _) + // result: (MOVQconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (ANDQconst [-1] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != -1 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ANDQconst [c] (MOVQconst [d])) + // result: (MOVQconst [int64(c)&d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(c) & d) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ANDQconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ANDQconstmodify [valoff1] {sym} (ADDQconst [off2] base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) + // result: (ANDQconstmodify [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2)) { + break + } + v.reset(OpAMD64ANDQconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (ANDQconstmodify [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) + // result: (ANDQconstmodify [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ANDQconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ANDQload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ANDQload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ANDQload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ANDQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ANDQload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ANDQload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ANDQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (ANDQload x [off] {sym} ptr (MOVSDstore [off] {sym} ptr y _)) + // result: (ANDQ x (MOVQf2i y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVSDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64ANDQ) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVQf2i, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ANDQmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ANDQmodify [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ANDQmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ANDQmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (ANDQmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ANDQmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ANDQmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64BSFQ(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (BSFQ (ORQconst [1<<8] (MOVBQZX x))) + // result: (BSFQ (ORQconst [1<<8] x)) + for { + if v_0.Op != OpAMD64ORQconst { + break + } + t := v_0.Type + if auxIntToInt32(v_0.AuxInt) != 1<<8 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64MOVBQZX { + break + } + x := v_0_0.Args[0] + v.reset(OpAMD64BSFQ) + v0 := b.NewValue0(v.Pos, OpAMD64ORQconst, t) + v0.AuxInt = int32ToAuxInt(1 << 8) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (BSFQ (ORQconst [1<<16] (MOVWQZX x))) + // result: (BSFQ (ORQconst [1<<16] x)) + for { + if v_0.Op != OpAMD64ORQconst { + break + } + t := v_0.Type + if auxIntToInt32(v_0.AuxInt) != 1<<16 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64MOVWQZX { + break + } + x := v_0_0.Args[0] + v.reset(OpAMD64BSFQ) + v0 := b.NewValue0(v.Pos, OpAMD64ORQconst, t) + v0.AuxInt = int32ToAuxInt(1 << 16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64BSWAPL(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BSWAPL (BSWAPL p)) + // result: p + for { + if v_0.Op != OpAMD64BSWAPL { + break + } + p := v_0.Args[0] + v.copyOf(p) + return true + } + // match: (BSWAPL x:(MOVLload [i] {s} p mem)) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: @x.Block (MOVBELload [i] {s} p mem) + for { + x := v_0 + if x.Op != OpAMD64MOVLload { + break + } + i := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVBELload, typ.UInt32) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(i) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + // match: (BSWAPL x:(MOVBELload [i] {s} p mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVLload [i] {s} p mem) + for { + x := v_0 + if x.Op != OpAMD64MOVBELload { + break + } + i := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVLload, typ.UInt32) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(i) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64BSWAPQ(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BSWAPQ (BSWAPQ p)) + // result: p + for { + if v_0.Op != OpAMD64BSWAPQ { + break + } + p := v_0.Args[0] + v.copyOf(p) + return true + } + // match: (BSWAPQ x:(MOVQload [i] {s} p mem)) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: @x.Block (MOVBEQload [i] {s} p mem) + for { + x := v_0 + if x.Op != OpAMD64MOVQload { + break + } + i := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVBEQload, typ.UInt64) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(i) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + // match: (BSWAPQ x:(MOVBEQload [i] {s} p mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVQload [i] {s} p mem) + for { + x := v_0 + if x.Op != OpAMD64MOVBEQload { + break + } + i := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVQload, typ.UInt64) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(i) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64BTCQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (BTCQconst [c] (MOVQconst [d])) + // result: (MOVQconst [d^(1<1 + // result: (BTLconst [c-1] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64ADDQ { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || !(c > 1) { + break + } + v.reset(OpAMD64BTLconst) + v.AuxInt = int8ToAuxInt(c - 1) + v.AddArg(x) + return true + } + // match: (BTLconst [c] (SHLQconst [d] x)) + // cond: c>d + // result: (BTLconst [c-d] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64SHLQconst { + break + } + d := auxIntToInt8(v_0.AuxInt) + x := v_0.Args[0] + if !(c > d) { + break + } + v.reset(OpAMD64BTLconst) + v.AuxInt = int8ToAuxInt(c - d) + v.AddArg(x) + return true + } + // match: (BTLconst [0] s:(SHRQ x y)) + // result: (BTQ y x) + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + s := v_0 + if s.Op != OpAMD64SHRQ { + break + } + y := s.Args[1] + x := s.Args[0] + v.reset(OpAMD64BTQ) + v.AddArg2(y, x) + return true + } + // match: (BTLconst [c] (SHRLconst [d] x)) + // cond: (c+d)<32 + // result: (BTLconst [c+d] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64SHRLconst { + break + } + d := auxIntToInt8(v_0.AuxInt) + x := v_0.Args[0] + if !((c + d) < 32) { + break + } + v.reset(OpAMD64BTLconst) + v.AuxInt = int8ToAuxInt(c + d) + v.AddArg(x) + return true + } + // match: (BTLconst [c] (ADDL x x)) + // cond: c>1 + // result: (BTLconst [c-1] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64ADDL { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || !(c > 1) { + break + } + v.reset(OpAMD64BTLconst) + v.AuxInt = int8ToAuxInt(c - 1) + v.AddArg(x) + return true + } + // match: (BTLconst [c] (SHLLconst [d] x)) + // cond: c>d + // result: (BTLconst [c-d] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64SHLLconst { + break + } + d := auxIntToInt8(v_0.AuxInt) + x := v_0.Args[0] + if !(c > d) { + break + } + v.reset(OpAMD64BTLconst) + v.AuxInt = int8ToAuxInt(c - d) + v.AddArg(x) + return true + } + // match: (BTLconst [0] s:(SHRL x y)) + // result: (BTL y x) + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + s := v_0 + if s.Op != OpAMD64SHRL { + break + } + y := s.Args[1] + x := s.Args[0] + v.reset(OpAMD64BTL) + v.AddArg2(y, x) + return true + } + // match: (BTLconst [0] s:(SHRXL x y)) + // result: (BTL y x) + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + s := v_0 + if s.Op != OpAMD64SHRXL { + break + } + y := s.Args[1] + x := s.Args[0] + v.reset(OpAMD64BTL) + v.AddArg2(y, x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64BTQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (BTQconst [c] (SHRQconst [d] x)) + // cond: (c+d)<64 + // result: (BTQconst [c+d] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64SHRQconst { + break + } + d := auxIntToInt8(v_0.AuxInt) + x := v_0.Args[0] + if !((c + d) < 64) { + break + } + v.reset(OpAMD64BTQconst) + v.AuxInt = int8ToAuxInt(c + d) + v.AddArg(x) + return true + } + // match: (BTQconst [c] (ADDQ x x)) + // cond: c>1 + // result: (BTQconst [c-1] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64ADDQ { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || !(c > 1) { + break + } + v.reset(OpAMD64BTQconst) + v.AuxInt = int8ToAuxInt(c - 1) + v.AddArg(x) + return true + } + // match: (BTQconst [c] (SHLQconst [d] x)) + // cond: c>d + // result: (BTQconst [c-d] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64SHLQconst { + break + } + d := auxIntToInt8(v_0.AuxInt) + x := v_0.Args[0] + if !(c > d) { + break + } + v.reset(OpAMD64BTQconst) + v.AuxInt = int8ToAuxInt(c - d) + v.AddArg(x) + return true + } + // match: (BTQconst [0] s:(SHRQ x y)) + // result: (BTQ y x) + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + s := v_0 + if s.Op != OpAMD64SHRQ { + break + } + y := s.Args[1] + x := s.Args[0] + v.reset(OpAMD64BTQ) + v.AddArg2(y, x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64BTRQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (BTRQconst [c] (BTSQconst [c] x)) + // result: (BTRQconst [c] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64BTSQconst || auxIntToInt8(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + v.reset(OpAMD64BTRQconst) + v.AuxInt = int8ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (BTRQconst [c] (BTCQconst [c] x)) + // result: (BTRQconst [c] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64BTCQconst || auxIntToInt8(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + v.reset(OpAMD64BTRQconst) + v.AuxInt = int8ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (BTRQconst [c] (MOVQconst [d])) + // result: (MOVQconst [d&^(1< blsr)) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64TESTQ { + break + } + _ = v_2.Args[1] + v_2_0 := v_2.Args[0] + v_2_1 := v_2.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_2_0, v_2_1 = _i0+1, v_2_1, v_2_0 { + s := v_2_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRQ || s != v_2_1 { + continue + } + v.reset(OpAMD64CMOVLEQ) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg3(x, y, v0) + return true + } + break + } + // match: (CMOVLEQ x y (TESTL s:(Select0 blsr:(BLSRL _)) s)) + // result: (CMOVLEQ x y (Select1 blsr)) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64TESTL { + break + } + _ = v_2.Args[1] + v_2_0 := v_2.Args[0] + v_2_1 := v_2.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_2_0, v_2_1 = _i0+1, v_2_1, v_2_0 { + s := v_2_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRL || s != v_2_1 { + continue + } + v.reset(OpAMD64CMOVLEQ) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg3(x, y, v0) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVLGE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMOVLGE x y (InvertFlags cond)) + // result: (CMOVLLE x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVLLE) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVLGE _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLGE _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLGE _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLGE y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLGE y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLGE x y c:(CMPQconst [128] z)) + // cond: c.Uses == 1 + // result: (CMOVLGT x y (CMPQconst [127] z)) + for { + x := v_0 + y := v_1 + c := v_2 + if c.Op != OpAMD64CMPQconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64CMOVLGT) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + v.AddArg3(x, y, v0) + return true + } + // match: (CMOVLGE x y c:(CMPLconst [128] z)) + // cond: c.Uses == 1 + // result: (CMOVLGT x y (CMPLconst [127] z)) + for { + x := v_0 + y := v_1 + c := v_2 + if c.Op != OpAMD64CMPLconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64CMOVLGT) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + v.AddArg3(x, y, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVLGT(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVLGT x y (InvertFlags cond)) + // result: (CMOVLLT x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVLLT) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVLGT y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLGT _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLGT _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLGT y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLGT y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVLHI(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVLHI x y (InvertFlags cond)) + // result: (CMOVLCS x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVLCS) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVLHI y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLHI _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLHI y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLHI y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLHI _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVLLE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVLLE x y (InvertFlags cond)) + // result: (CMOVLGE x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVLGE) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVLLE _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLLE y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLLE y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLLE _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLLE _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVLLS(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVLLS x y (InvertFlags cond)) + // result: (CMOVLCC x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVLCC) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVLLS _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLLS y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLLS _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLLS _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLLS y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVLLT(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMOVLLT x y (InvertFlags cond)) + // result: (CMOVLGT x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVLGT) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVLLT y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLLT y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLLT y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLLT _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLLT _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLLT x y c:(CMPQconst [128] z)) + // cond: c.Uses == 1 + // result: (CMOVLLE x y (CMPQconst [127] z)) + for { + x := v_0 + y := v_1 + c := v_2 + if c.Op != OpAMD64CMPQconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64CMOVLLE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + v.AddArg3(x, y, v0) + return true + } + // match: (CMOVLLT x y c:(CMPLconst [128] z)) + // cond: c.Uses == 1 + // result: (CMOVLLE x y (CMPLconst [127] z)) + for { + x := v_0 + y := v_1 + c := v_2 + if c.Op != OpAMD64CMPLconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64CMOVLLE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + v.AddArg3(x, y, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVLNE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMOVLNE x y (InvertFlags cond)) + // result: (CMOVLNE x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVLNE) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVLNE y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVLNE _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLNE _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLNE _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLNE _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVLNE x y (TESTQ s:(Select0 blsr:(BLSRQ _)) s)) + // result: (CMOVLNE x y (Select1 blsr)) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64TESTQ { + break + } + _ = v_2.Args[1] + v_2_0 := v_2.Args[0] + v_2_1 := v_2.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_2_0, v_2_1 = _i0+1, v_2_1, v_2_0 { + s := v_2_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRQ || s != v_2_1 { + continue + } + v.reset(OpAMD64CMOVLNE) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg3(x, y, v0) + return true + } + break + } + // match: (CMOVLNE x y (TESTL s:(Select0 blsr:(BLSRL _)) s)) + // result: (CMOVLNE x y (Select1 blsr)) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64TESTL { + break + } + _ = v_2.Args[1] + v_2_0 := v_2.Args[0] + v_2_1 := v_2.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_2_0, v_2_1 = _i0+1, v_2_1, v_2_0 { + s := v_2_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRL || s != v_2_1 { + continue + } + v.reset(OpAMD64CMOVLNE) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg3(x, y, v0) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVQCC(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVQCC x y (InvertFlags cond)) + // result: (CMOVQLS x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVQLS) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVQCC _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQCC _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQCC y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQCC y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQCC _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVQCS(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVQCS x y (InvertFlags cond)) + // result: (CMOVQHI x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVQHI) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVQCS y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQCS y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQCS _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQCS _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQCS y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVQEQ(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMOVQEQ x y (InvertFlags cond)) + // result: (CMOVQEQ x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVQEQ) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVQEQ _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQEQ y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQEQ y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQEQ y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQEQ y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQEQ x _ (Select1 (BSFQ (ORQconst [c] _)))) + // cond: c != 0 + // result: x + for { + x := v_0 + if v_2.Op != OpSelect1 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpAMD64BSFQ { + break + } + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpAMD64ORQconst { + break + } + c := auxIntToInt32(v_2_0_0.AuxInt) + if !(c != 0) { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQEQ x _ (Select1 (BSRQ (ORQconst [c] _)))) + // cond: c != 0 + // result: x + for { + x := v_0 + if v_2.Op != OpSelect1 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpAMD64BSRQ { + break + } + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpAMD64ORQconst { + break + } + c := auxIntToInt32(v_2_0_0.AuxInt) + if !(c != 0) { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQEQ x y (TESTQ s:(Select0 blsr:(BLSRQ _)) s)) + // result: (CMOVQEQ x y (Select1 blsr)) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64TESTQ { + break + } + _ = v_2.Args[1] + v_2_0 := v_2.Args[0] + v_2_1 := v_2.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_2_0, v_2_1 = _i0+1, v_2_1, v_2_0 { + s := v_2_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRQ || s != v_2_1 { + continue + } + v.reset(OpAMD64CMOVQEQ) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg3(x, y, v0) + return true + } + break + } + // match: (CMOVQEQ x y (TESTL s:(Select0 blsr:(BLSRL _)) s)) + // result: (CMOVQEQ x y (Select1 blsr)) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64TESTL { + break + } + _ = v_2.Args[1] + v_2_0 := v_2.Args[0] + v_2_1 := v_2.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_2_0, v_2_1 = _i0+1, v_2_1, v_2_0 { + s := v_2_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRL || s != v_2_1 { + continue + } + v.reset(OpAMD64CMOVQEQ) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg3(x, y, v0) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVQGE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMOVQGE x y (InvertFlags cond)) + // result: (CMOVQLE x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVQLE) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVQGE _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQGE _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQGE _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQGE y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQGE y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQGE x y c:(CMPQconst [128] z)) + // cond: c.Uses == 1 + // result: (CMOVQGT x y (CMPQconst [127] z)) + for { + x := v_0 + y := v_1 + c := v_2 + if c.Op != OpAMD64CMPQconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64CMOVQGT) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + v.AddArg3(x, y, v0) + return true + } + // match: (CMOVQGE x y c:(CMPLconst [128] z)) + // cond: c.Uses == 1 + // result: (CMOVQGT x y (CMPLconst [127] z)) + for { + x := v_0 + y := v_1 + c := v_2 + if c.Op != OpAMD64CMPLconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64CMOVQGT) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + v.AddArg3(x, y, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVQGT(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVQGT x y (InvertFlags cond)) + // result: (CMOVQLT x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVQLT) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVQGT y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQGT _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQGT _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQGT y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQGT y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVQHI(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVQHI x y (InvertFlags cond)) + // result: (CMOVQCS x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVQCS) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVQHI y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQHI _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQHI y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQHI y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQHI _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVQLE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVQLE x y (InvertFlags cond)) + // result: (CMOVQGE x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVQGE) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVQLE _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQLE y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQLE y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQLE _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQLE _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVQLS(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVQLS x y (InvertFlags cond)) + // result: (CMOVQCC x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVQCC) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVQLS _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQLS y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQLS _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQLS _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQLS y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVQLT(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMOVQLT x y (InvertFlags cond)) + // result: (CMOVQGT x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVQGT) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVQLT y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQLT y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQLT y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQLT _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQLT _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQLT x y c:(CMPQconst [128] z)) + // cond: c.Uses == 1 + // result: (CMOVQLE x y (CMPQconst [127] z)) + for { + x := v_0 + y := v_1 + c := v_2 + if c.Op != OpAMD64CMPQconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64CMOVQLE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + v.AddArg3(x, y, v0) + return true + } + // match: (CMOVQLT x y c:(CMPLconst [128] z)) + // cond: c.Uses == 1 + // result: (CMOVQLE x y (CMPLconst [127] z)) + for { + x := v_0 + y := v_1 + c := v_2 + if c.Op != OpAMD64CMPLconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64CMOVQLE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + v.AddArg3(x, y, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVQNE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMOVQNE x y (InvertFlags cond)) + // result: (CMOVQNE x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVQNE) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVQNE y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVQNE _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQNE _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQNE _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQNE _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVQNE x y (TESTQ s:(Select0 blsr:(BLSRQ _)) s)) + // result: (CMOVQNE x y (Select1 blsr)) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64TESTQ { + break + } + _ = v_2.Args[1] + v_2_0 := v_2.Args[0] + v_2_1 := v_2.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_2_0, v_2_1 = _i0+1, v_2_1, v_2_0 { + s := v_2_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRQ || s != v_2_1 { + continue + } + v.reset(OpAMD64CMOVQNE) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg3(x, y, v0) + return true + } + break + } + // match: (CMOVQNE x y (TESTL s:(Select0 blsr:(BLSRL _)) s)) + // result: (CMOVQNE x y (Select1 blsr)) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64TESTL { + break + } + _ = v_2.Args[1] + v_2_0 := v_2.Args[0] + v_2_1 := v_2.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_2_0, v_2_1 = _i0+1, v_2_1, v_2_0 { + s := v_2_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRL || s != v_2_1 { + continue + } + v.reset(OpAMD64CMOVQNE) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg3(x, y, v0) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVWCC(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWCC x y (InvertFlags cond)) + // result: (CMOVWLS x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVWLS) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVWCC _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWCC _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWCC y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWCC y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWCC _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVWCS(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWCS x y (InvertFlags cond)) + // result: (CMOVWHI x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVWHI) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVWCS y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWCS y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWCS _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWCS _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWCS y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVWEQ(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWEQ x y (InvertFlags cond)) + // result: (CMOVWEQ x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVWEQ) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVWEQ _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWEQ y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWEQ y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWEQ y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWEQ y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVWGE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWGE x y (InvertFlags cond)) + // result: (CMOVWLE x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVWLE) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVWGE _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWGE _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWGE _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWGE y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWGE y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVWGT(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWGT x y (InvertFlags cond)) + // result: (CMOVWLT x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVWLT) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVWGT y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWGT _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWGT _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWGT y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWGT y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVWHI(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWHI x y (InvertFlags cond)) + // result: (CMOVWCS x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVWCS) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVWHI y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWHI _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWHI y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWHI y _ (FlagLT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWHI _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVWLE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWLE x y (InvertFlags cond)) + // result: (CMOVWGE x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVWGE) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVWLE _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWLE y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWLE y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWLE _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWLE _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVWLS(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWLS x y (InvertFlags cond)) + // result: (CMOVWCC x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVWCC) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVWLS _ x (FlagEQ)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWLS y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWLS _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWLS _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWLS y _ (FlagLT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVWLT(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWLT x y (InvertFlags cond)) + // result: (CMOVWGT x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVWGT) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVWLT y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWLT y _ (FlagGT_UGT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWLT y _ (FlagGT_ULT)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWLT _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWLT _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMOVWNE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWNE x y (InvertFlags cond)) + // result: (CMOVWNE x y cond) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64InvertFlags { + break + } + cond := v_2.Args[0] + v.reset(OpAMD64CMOVWNE) + v.AddArg3(x, y, cond) + return true + } + // match: (CMOVWNE y _ (FlagEQ)) + // result: y + for { + y := v_0 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (CMOVWNE _ x (FlagGT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_UGT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWNE _ x (FlagGT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagGT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWNE _ x (FlagLT_ULT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_ULT { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWNE _ x (FlagLT_UGT)) + // result: x + for { + x := v_1 + if v_2.Op != OpAMD64FlagLT_UGT { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPB x (MOVLconst [c])) + // result: (CMPBconst x [int8(c)]) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64CMPBconst) + v.AuxInt = int8ToAuxInt(int8(c)) + v.AddArg(x) + return true + } + // match: (CMPB (MOVLconst [c]) x) + // result: (InvertFlags (CMPBconst x [int8(c)])) + for { + if v_0.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpAMD64InvertFlags) + v0 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMPB x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPB y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpAMD64InvertFlags) + v0 := b.NewValue0(v.Pos, OpAMD64CMPB, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + // match: (CMPB l:(MOVBload {sym} [off] ptr mem) x) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (CMPBload {sym} [off] ptr x mem) + for { + l := v_0 + if l.Op != OpAMD64MOVBload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64CMPBload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (CMPB x l:(MOVBload {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (InvertFlags (CMPBload {sym} [off] ptr x mem)) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVBload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64InvertFlags) + v0 := b.NewValue0(l.Pos, OpAMD64CMPBload, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, x, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPBconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CMPBconst (MOVLconst [x]) [y]) + // cond: int8(x)==y + // result: (FlagEQ) + for { + y := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(int8(x) == y) { + break + } + v.reset(OpAMD64FlagEQ) + return true + } + // match: (CMPBconst (MOVLconst [x]) [y]) + // cond: int8(x)uint8(y) + // result: (FlagLT_UGT) + for { + y := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(int8(x) < y && uint8(x) > uint8(y)) { + break + } + v.reset(OpAMD64FlagLT_UGT) + return true + } + // match: (CMPBconst (MOVLconst [x]) [y]) + // cond: int8(x)>y && uint8(x) y && uint8(x) < uint8(y)) { + break + } + v.reset(OpAMD64FlagGT_ULT) + return true + } + // match: (CMPBconst (MOVLconst [x]) [y]) + // cond: int8(x)>y && uint8(x)>uint8(y) + // result: (FlagGT_UGT) + for { + y := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(int8(x) > y && uint8(x) > uint8(y)) { + break + } + v.reset(OpAMD64FlagGT_UGT) + return true + } + // match: (CMPBconst (ANDLconst _ [m]) [n]) + // cond: 0 <= int8(m) && int8(m) < n + // result: (FlagLT_ULT) + for { + n := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64ANDLconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + if !(0 <= int8(m) && int8(m) < n) { + break + } + v.reset(OpAMD64FlagLT_ULT) + return true + } + // match: (CMPBconst a:(ANDL x y) [0]) + // cond: a.Uses == 1 + // result: (TESTB x y) + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + a := v_0 + if a.Op != OpAMD64ANDL { + break + } + y := a.Args[1] + x := a.Args[0] + if !(a.Uses == 1) { + break + } + v.reset(OpAMD64TESTB) + v.AddArg2(x, y) + return true + } + // match: (CMPBconst a:(ANDLconst [c] x) [0]) + // cond: a.Uses == 1 + // result: (TESTBconst [int8(c)] x) + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + a := v_0 + if a.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(a.AuxInt) + x := a.Args[0] + if !(a.Uses == 1) { + break + } + v.reset(OpAMD64TESTBconst) + v.AuxInt = int8ToAuxInt(int8(c)) + v.AddArg(x) + return true + } + // match: (CMPBconst x [0]) + // result: (TESTB x x) + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.reset(OpAMD64TESTB) + v.AddArg2(x, x) + return true + } + // match: (CMPBconst l:(MOVBload {sym} [off] ptr mem) [c]) + // cond: l.Uses == 1 && clobber(l) + // result: @l.Block (CMPBconstload {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + c := auxIntToInt8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64MOVBload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(l.Uses == 1 && clobber(l)) { + break + } + b = l.Block + v0 := b.NewValue0(l.Pos, OpAMD64CMPBconstload, types.TypeFlags) + v.copyOf(v0) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPBconstload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMPBconstload [valoff1] {sym} (ADDQconst [off2] base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) + // result: (CMPBconstload [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2)) { + break + } + v.reset(OpAMD64CMPBconstload) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (CMPBconstload [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) + // result: (CMPBconstload [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64CMPBconstload) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPBload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMPBload [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (CMPBload [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64CMPBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (CMPBload [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (CMPBload [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64CMPBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (CMPBload {sym} [off] ptr (MOVLconst [c]) mem) + // result: (CMPBconstload {sym} [makeValAndOff(int32(int8(c)),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64CMPBconstload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(int8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPL x (MOVLconst [c])) + // result: (CMPLconst x [c]) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64CMPLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPL (MOVLconst [c]) x) + // result: (InvertFlags (CMPLconst x [c])) + for { + if v_0.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpAMD64InvertFlags) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMPL x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPL y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpAMD64InvertFlags) + v0 := b.NewValue0(v.Pos, OpAMD64CMPL, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + // match: (CMPL l:(MOVLload {sym} [off] ptr mem) x) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (CMPLload {sym} [off] ptr x mem) + for { + l := v_0 + if l.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64CMPLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (CMPL x l:(MOVLload {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (InvertFlags (CMPLload {sym} [off] ptr x mem)) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64InvertFlags) + v0 := b.NewValue0(l.Pos, OpAMD64CMPLload, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, x, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPLconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CMPLconst (MOVLconst [x]) [y]) + // cond: x==y + // result: (FlagEQ) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(x == y) { + break + } + v.reset(OpAMD64FlagEQ) + return true + } + // match: (CMPLconst (MOVLconst [x]) [y]) + // cond: xuint32(y) + // result: (FlagLT_UGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(x < y && uint32(x) > uint32(y)) { + break + } + v.reset(OpAMD64FlagLT_UGT) + return true + } + // match: (CMPLconst (MOVLconst [x]) [y]) + // cond: x>y && uint32(x) y && uint32(x) < uint32(y)) { + break + } + v.reset(OpAMD64FlagGT_ULT) + return true + } + // match: (CMPLconst (MOVLconst [x]) [y]) + // cond: x>y && uint32(x)>uint32(y) + // result: (FlagGT_UGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(x > y && uint32(x) > uint32(y)) { + break + } + v.reset(OpAMD64FlagGT_UGT) + return true + } + // match: (CMPLconst (SHRLconst _ [c]) [n]) + // cond: 0 <= n && 0 < c && c <= 32 && (1<uint64(y) + // result: (FlagLT_UGT) + for { + if v_0.Op != OpAMD64MOVQconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpAMD64MOVQconst { + break + } + y := auxIntToInt64(v_1.AuxInt) + if !(x < y && uint64(x) > uint64(y)) { + break + } + v.reset(OpAMD64FlagLT_UGT) + return true + } + // match: (CMPQ (MOVQconst [x]) (MOVQconst [y])) + // cond: x>y && uint64(x) y && uint64(x) < uint64(y)) { + break + } + v.reset(OpAMD64FlagGT_ULT) + return true + } + // match: (CMPQ (MOVQconst [x]) (MOVQconst [y])) + // cond: x>y && uint64(x)>uint64(y) + // result: (FlagGT_UGT) + for { + if v_0.Op != OpAMD64MOVQconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpAMD64MOVQconst { + break + } + y := auxIntToInt64(v_1.AuxInt) + if !(x > y && uint64(x) > uint64(y)) { + break + } + v.reset(OpAMD64FlagGT_UGT) + return true + } + // match: (CMPQ l:(MOVQload {sym} [off] ptr mem) x) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (CMPQload {sym} [off] ptr x mem) + for { + l := v_0 + if l.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64CMPQload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (CMPQ x l:(MOVQload {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (InvertFlags (CMPQload {sym} [off] ptr x mem)) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64InvertFlags) + v0 := b.NewValue0(l.Pos, OpAMD64CMPQload, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, x, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPQconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CMPQconst (MOVQconst [x]) [y]) + // cond: x==int64(y) + // result: (FlagEQ) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(x == int64(y)) { + break + } + v.reset(OpAMD64FlagEQ) + return true + } + // match: (CMPQconst (MOVQconst [x]) [y]) + // cond: xuint64(int64(y)) + // result: (FlagLT_UGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(x < int64(y) && uint64(x) > uint64(int64(y))) { + break + } + v.reset(OpAMD64FlagLT_UGT) + return true + } + // match: (CMPQconst (MOVQconst [x]) [y]) + // cond: x>int64(y) && uint64(x) int64(y) && uint64(x) < uint64(int64(y))) { + break + } + v.reset(OpAMD64FlagGT_ULT) + return true + } + // match: (CMPQconst (MOVQconst [x]) [y]) + // cond: x>int64(y) && uint64(x)>uint64(int64(y)) + // result: (FlagGT_UGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(x > int64(y) && uint64(x) > uint64(int64(y))) { + break + } + v.reset(OpAMD64FlagGT_UGT) + return true + } + // match: (CMPQconst (MOVBQZX _) [c]) + // cond: 0xFF < c + // result: (FlagLT_ULT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVBQZX || !(0xFF < c) { + break + } + v.reset(OpAMD64FlagLT_ULT) + return true + } + // match: (CMPQconst (MOVWQZX _) [c]) + // cond: 0xFFFF < c + // result: (FlagLT_ULT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVWQZX || !(0xFFFF < c) { + break + } + v.reset(OpAMD64FlagLT_ULT) + return true + } + // match: (CMPQconst (SHRQconst _ [c]) [n]) + // cond: 0 <= n && 0 < c && c <= 64 && (1<uint16(y) + // result: (FlagLT_UGT) + for { + y := auxIntToInt16(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(int16(x) < y && uint16(x) > uint16(y)) { + break + } + v.reset(OpAMD64FlagLT_UGT) + return true + } + // match: (CMPWconst (MOVLconst [x]) [y]) + // cond: int16(x)>y && uint16(x) y && uint16(x) < uint16(y)) { + break + } + v.reset(OpAMD64FlagGT_ULT) + return true + } + // match: (CMPWconst (MOVLconst [x]) [y]) + // cond: int16(x)>y && uint16(x)>uint16(y) + // result: (FlagGT_UGT) + for { + y := auxIntToInt16(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(int16(x) > y && uint16(x) > uint16(y)) { + break + } + v.reset(OpAMD64FlagGT_UGT) + return true + } + // match: (CMPWconst (ANDLconst _ [m]) [n]) + // cond: 0 <= int16(m) && int16(m) < n + // result: (FlagLT_ULT) + for { + n := auxIntToInt16(v.AuxInt) + if v_0.Op != OpAMD64ANDLconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + if !(0 <= int16(m) && int16(m) < n) { + break + } + v.reset(OpAMD64FlagLT_ULT) + return true + } + // match: (CMPWconst a:(ANDL x y) [0]) + // cond: a.Uses == 1 + // result: (TESTW x y) + for { + if auxIntToInt16(v.AuxInt) != 0 { + break + } + a := v_0 + if a.Op != OpAMD64ANDL { + break + } + y := a.Args[1] + x := a.Args[0] + if !(a.Uses == 1) { + break + } + v.reset(OpAMD64TESTW) + v.AddArg2(x, y) + return true + } + // match: (CMPWconst a:(ANDLconst [c] x) [0]) + // cond: a.Uses == 1 + // result: (TESTWconst [int16(c)] x) + for { + if auxIntToInt16(v.AuxInt) != 0 { + break + } + a := v_0 + if a.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(a.AuxInt) + x := a.Args[0] + if !(a.Uses == 1) { + break + } + v.reset(OpAMD64TESTWconst) + v.AuxInt = int16ToAuxInt(int16(c)) + v.AddArg(x) + return true + } + // match: (CMPWconst x [0]) + // result: (TESTW x x) + for { + if auxIntToInt16(v.AuxInt) != 0 { + break + } + x := v_0 + v.reset(OpAMD64TESTW) + v.AddArg2(x, x) + return true + } + // match: (CMPWconst l:(MOVWload {sym} [off] ptr mem) [c]) + // cond: l.Uses == 1 && clobber(l) + // result: @l.Block (CMPWconstload {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + c := auxIntToInt16(v.AuxInt) + l := v_0 + if l.Op != OpAMD64MOVWload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(l.Uses == 1 && clobber(l)) { + break + } + b = l.Block + v0 := b.NewValue0(l.Pos, OpAMD64CMPWconstload, types.TypeFlags) + v.copyOf(v0) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPWconstload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMPWconstload [valoff1] {sym} (ADDQconst [off2] base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) + // result: (CMPWconstload [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2)) { + break + } + v.reset(OpAMD64CMPWconstload) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (CMPWconstload [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) + // result: (CMPWconstload [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64CMPWconstload) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPWload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMPWload [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (CMPWload [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64CMPWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (CMPWload [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (CMPWload [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64CMPWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (CMPWload {sym} [off] ptr (MOVLconst [c]) mem) + // result: (CMPWconstload {sym} [makeValAndOff(int32(int16(c)),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64CMPWconstload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(int16(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPXCHGLlock(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMPXCHGLlock [off1] {sym} (ADDQconst [off2] ptr) old new_ mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (CMPXCHGLlock [off1+off2] {sym} ptr old new_ mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + old := v_1 + new_ := v_2 + mem := v_3 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64CMPXCHGLlock) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg4(ptr, old, new_, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64CMPXCHGQlock(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMPXCHGQlock [off1] {sym} (ADDQconst [off2] ptr) old new_ mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (CMPXCHGQlock [off1+off2] {sym} ptr old new_ mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + old := v_1 + new_ := v_2 + mem := v_3 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64CMPXCHGQlock) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg4(ptr, old, new_, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64DIVSD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (DIVSD x l:(MOVSDload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (DIVSDload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVSDload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(OpAMD64DIVSDload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64DIVSDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (DIVSDload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (DIVSDload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64DIVSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (DIVSDload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (DIVSDload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64DIVSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64DIVSS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (DIVSS x l:(MOVSSload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (DIVSSload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVSSload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(OpAMD64DIVSSload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64DIVSSload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (DIVSSload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (DIVSSload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64DIVSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (DIVSSload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (DIVSSload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64DIVSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64HMULL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (HMULL x y) + // cond: !x.rematerializeable() && y.rematerializeable() + // result: (HMULL y x) + for { + x := v_0 + y := v_1 + if !(!x.rematerializeable() && y.rematerializeable()) { + break + } + v.reset(OpAMD64HMULL) + v.AddArg2(y, x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64HMULLU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (HMULLU x y) + // cond: !x.rematerializeable() && y.rematerializeable() + // result: (HMULLU y x) + for { + x := v_0 + y := v_1 + if !(!x.rematerializeable() && y.rematerializeable()) { + break + } + v.reset(OpAMD64HMULLU) + v.AddArg2(y, x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64HMULQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (HMULQ x y) + // cond: !x.rematerializeable() && y.rematerializeable() + // result: (HMULQ y x) + for { + x := v_0 + y := v_1 + if !(!x.rematerializeable() && y.rematerializeable()) { + break + } + v.reset(OpAMD64HMULQ) + v.AddArg2(y, x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64HMULQU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (HMULQU x y) + // cond: !x.rematerializeable() && y.rematerializeable() + // result: (HMULQU y x) + for { + x := v_0 + y := v_1 + if !(!x.rematerializeable() && y.rematerializeable()) { + break + } + v.reset(OpAMD64HMULQU) + v.AddArg2(y, x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64KMOVBk(v *Value) bool { + v_0 := v.Args[0] + // match: (KMOVBk l:(MOVBload [off] {sym} ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (KMOVBload [off] {sym} ptr mem) + for { + l := v_0 + if l.Op != OpAMD64MOVBload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64KMOVBload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64KMOVDk(v *Value) bool { + v_0 := v.Args[0] + // match: (KMOVDk l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (KMOVDload [off] {sym} ptr mem) + for { + l := v_0 + if l.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64KMOVDload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64KMOVQk(v *Value) bool { + v_0 := v.Args[0] + // match: (KMOVQk l:(MOVQload [off] {sym} ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (KMOVQload [off] {sym} ptr mem) + for { + l := v_0 + if l.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64KMOVQload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64KMOVWk(v *Value) bool { + v_0 := v.Args[0] + // match: (KMOVWk l:(MOVWload [off] {sym} ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (KMOVWload [off] {sym} ptr mem) + for { + l := v_0 + if l.Op != OpAMD64MOVWload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64KMOVWload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LEAL(v *Value) bool { + v_0 := v.Args[0] + // match: (LEAL [c] {s} (ADDLconst [d] x)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAL [c+d] {s} x) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAL) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg(x) + return true + } + // match: (LEAL [c] {s} (ADDL x y)) + // cond: x.Op != OpSB && y.Op != OpSB + // result: (LEAL1 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if !(x.Op != OpSB && y.Op != OpSB) { + continue + } + v.reset(OpAMD64LEAL1) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64LEAL1(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAL1 [c] {s} (ADDLconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAL1 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64ADDLconst { + continue + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + continue + } + v.reset(OpAMD64LEAL1) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAL1 [c] {s} x z:(ADDL y y)) + // cond: x != z + // result: (LEAL2 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + z := v_1 + if z.Op != OpAMD64ADDL { + continue + } + y := z.Args[1] + if y != z.Args[0] || !(x != z) { + continue + } + v.reset(OpAMD64LEAL2) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAL1 [c] {s} x (SHLLconst [2] y)) + // result: (LEAL4 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64SHLLconst || auxIntToInt8(v_1.AuxInt) != 2 { + continue + } + y := v_1.Args[0] + v.reset(OpAMD64LEAL4) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAL1 [c] {s} x (SHLLconst [3] y)) + // result: (LEAL8 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64SHLLconst || auxIntToInt8(v_1.AuxInt) != 3 { + continue + } + y := v_1.Args[0] + v.reset(OpAMD64LEAL8) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64LEAL2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAL2 [c] {s} (ADDLconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAL2 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + break + } + v.reset(OpAMD64LEAL2) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL2 [c] {s} x (ADDLconst [d] y)) + // cond: is32Bit(int64(c)+2*int64(d)) && y.Op != OpSB + // result: (LEAL2 [c+2*d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64ADDLconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(is32Bit(int64(c)+2*int64(d)) && y.Op != OpSB) { + break + } + v.reset(OpAMD64LEAL2) + v.AuxInt = int32ToAuxInt(c + 2*d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL2 [c] {s} x z:(ADDL y y)) + // cond: x != z + // result: (LEAL4 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + z := v_1 + if z.Op != OpAMD64ADDL { + break + } + y := z.Args[1] + if y != z.Args[0] || !(x != z) { + break + } + v.reset(OpAMD64LEAL4) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL2 [c] {s} x (SHLLconst [2] y)) + // result: (LEAL8 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64SHLLconst || auxIntToInt8(v_1.AuxInt) != 2 { + break + } + y := v_1.Args[0] + v.reset(OpAMD64LEAL8) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL2 [0] {s} (ADDL x x) x) + // cond: s == nil + // result: (SHLLconst [2] x) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDL { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || x != v_1 || !(s == nil) { + break + } + v.reset(OpAMD64SHLLconst) + v.AuxInt = int8ToAuxInt(2) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LEAL4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAL4 [c] {s} (ADDLconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAL4 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + break + } + v.reset(OpAMD64LEAL4) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL4 [c] {s} x (ADDLconst [d] y)) + // cond: is32Bit(int64(c)+4*int64(d)) && y.Op != OpSB + // result: (LEAL4 [c+4*d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64ADDLconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(is32Bit(int64(c)+4*int64(d)) && y.Op != OpSB) { + break + } + v.reset(OpAMD64LEAL4) + v.AuxInt = int32ToAuxInt(c + 4*d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL4 [c] {s} x z:(ADDL y y)) + // cond: x != z + // result: (LEAL8 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + z := v_1 + if z.Op != OpAMD64ADDL { + break + } + y := z.Args[1] + if y != z.Args[0] || !(x != z) { + break + } + v.reset(OpAMD64LEAL8) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LEAL8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAL8 [c] {s} (ADDLconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAL8 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + break + } + v.reset(OpAMD64LEAL8) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAL8 [c] {s} x (ADDLconst [d] y)) + // cond: is32Bit(int64(c)+8*int64(d)) && y.Op != OpSB + // result: (LEAL8 [c+8*d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64ADDLconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(is32Bit(int64(c)+8*int64(d)) && y.Op != OpSB) { + break + } + v.reset(OpAMD64LEAL8) + v.AuxInt = int32ToAuxInt(c + 8*d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LEAQ(v *Value) bool { + v_0 := v.Args[0] + // match: (LEAQ [c] {s} (ADDQconst [d] x)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (LEAQ [c+d] {s} x) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpAMD64LEAQ) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg(x) + return true + } + // match: (LEAQ [c] {s} (ADDQ x y)) + // cond: x.Op != OpSB && y.Op != OpSB + // result: (LEAQ1 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if !(x.Op != OpSB && y.Op != OpSB) { + continue + } + v.reset(OpAMD64LEAQ1) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAQ [off1] {sym1} (LEAQ [off2] {sym2} x)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAQ [off1+off2] {mergeSym(sym1,sym2)} x) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64LEAQ) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg(x) + return true + } + // match: (LEAQ [off1] {sym1} (LEAQ1 [off2] {sym2} x y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAQ1 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ1 { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64LEAQ1) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAQ [off1] {sym1} (LEAQ2 [off2] {sym2} x y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAQ2 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ2 { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64LEAQ2) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAQ [off1] {sym1} (LEAQ4 [off2] {sym2} x y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAQ4 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ4 { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64LEAQ4) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAQ [off1] {sym1} (LEAQ8 [off2] {sym2} x y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAQ8 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ8 { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64LEAQ8) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LEAQ1(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAQ1 [c] {s} (ADDQconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAQ1 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64ADDQconst { + continue + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + continue + } + v.reset(OpAMD64LEAQ1) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAQ1 [c] {s} x z:(ADDQ y y)) + // cond: x != z + // result: (LEAQ2 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + z := v_1 + if z.Op != OpAMD64ADDQ { + continue + } + y := z.Args[1] + if y != z.Args[0] || !(x != z) { + continue + } + v.reset(OpAMD64LEAQ2) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAQ1 [c] {s} x (SHLQconst [2] y)) + // result: (LEAQ4 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64SHLQconst || auxIntToInt8(v_1.AuxInt) != 2 { + continue + } + y := v_1.Args[0] + v.reset(OpAMD64LEAQ4) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAQ1 [c] {s} x (SHLQconst [3] y)) + // result: (LEAQ8 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64SHLQconst || auxIntToInt8(v_1.AuxInt) != 3 { + continue + } + y := v_1.Args[0] + v.reset(OpAMD64LEAQ8) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAQ1 [off1] {sym1} (LEAQ [off2] {sym2} x) y) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB + // result: (LEAQ1 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64LEAQ { + continue + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB) { + continue + } + v.reset(OpAMD64LEAQ1) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAQ1 [off1] {sym1} x (LEAQ1 [off2] {sym2} y y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAQ2 [off1+off2] {mergeSym(sym1, sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64LEAQ1 { + continue + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + y := v_1.Args[1] + if y != v_1.Args[0] || !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + continue + } + v.reset(OpAMD64LEAQ2) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + break + } + // match: (LEAQ1 [off1] {sym1} x (LEAQ1 [off2] {sym2} x y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (LEAQ2 [off1+off2] {mergeSym(sym1, sym2)} y x) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64LEAQ1 { + continue + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + continue + } + v.reset(OpAMD64LEAQ2) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(y, x) + return true + } + } + break + } + // match: (LEAQ1 [0] x y) + // cond: v.Aux == nil + // result: (ADDQ x y) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + y := v_1 + if !(v.Aux == nil) { + break + } + v.reset(OpAMD64ADDQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LEAQ2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAQ2 [c] {s} (ADDQconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAQ2 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + break + } + v.reset(OpAMD64LEAQ2) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAQ2 [c] {s} x (ADDQconst [d] y)) + // cond: is32Bit(int64(c)+2*int64(d)) && y.Op != OpSB + // result: (LEAQ2 [c+2*d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(is32Bit(int64(c)+2*int64(d)) && y.Op != OpSB) { + break + } + v.reset(OpAMD64LEAQ2) + v.AuxInt = int32ToAuxInt(c + 2*d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAQ2 [c] {s} x z:(ADDQ y y)) + // cond: x != z + // result: (LEAQ4 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + z := v_1 + if z.Op != OpAMD64ADDQ { + break + } + y := z.Args[1] + if y != z.Args[0] || !(x != z) { + break + } + v.reset(OpAMD64LEAQ4) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAQ2 [c] {s} x (SHLQconst [2] y)) + // result: (LEAQ8 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64SHLQconst || auxIntToInt8(v_1.AuxInt) != 2 { + break + } + y := v_1.Args[0] + v.reset(OpAMD64LEAQ8) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAQ2 [0] {s} (ADDQ x x) x) + // cond: s == nil + // result: (SHLQconst [2] x) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQ { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || x != v_1 || !(s == nil) { + break + } + v.reset(OpAMD64SHLQconst) + v.AuxInt = int8ToAuxInt(2) + v.AddArg(x) + return true + } + // match: (LEAQ2 [off1] {sym1} (LEAQ [off2] {sym2} x) y) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB + // result: (LEAQ2 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB) { + break + } + v.reset(OpAMD64LEAQ2) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAQ2 [off1] {sym1} x (LEAQ1 [off2] {sym2} y y)) + // cond: is32Bit(int64(off1)+2*int64(off2)) && sym2 == nil + // result: (LEAQ4 [off1+2*off2] {sym1} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64LEAQ1 { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + y := v_1.Args[1] + if y != v_1.Args[0] || !(is32Bit(int64(off1)+2*int64(off2)) && sym2 == nil) { + break + } + v.reset(OpAMD64LEAQ4) + v.AuxInt = int32ToAuxInt(off1 + 2*off2) + v.Aux = symToAux(sym1) + v.AddArg2(x, y) + return true + } + // match: (LEAQ2 [off] {sym} x (MOVQconst [scale])) + // cond: is32Bit(int64(off)+int64(scale)*2) + // result: (LEAQ [off+int32(scale)*2] {sym} x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + scale := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(int64(off) + int64(scale)*2)) { + break + } + v.reset(OpAMD64LEAQ) + v.AuxInt = int32ToAuxInt(off + int32(scale)*2) + v.Aux = symToAux(sym) + v.AddArg(x) + return true + } + // match: (LEAQ2 [off] {sym} x (MOVLconst [scale])) + // cond: is32Bit(int64(off)+int64(scale)*2) + // result: (LEAQ [off+int32(scale)*2] {sym} x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + scale := auxIntToInt32(v_1.AuxInt) + if !(is32Bit(int64(off) + int64(scale)*2)) { + break + } + v.reset(OpAMD64LEAQ) + v.AuxInt = int32ToAuxInt(off + int32(scale)*2) + v.Aux = symToAux(sym) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LEAQ4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAQ4 [c] {s} (ADDQconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAQ4 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + break + } + v.reset(OpAMD64LEAQ4) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAQ4 [c] {s} x (ADDQconst [d] y)) + // cond: is32Bit(int64(c)+4*int64(d)) && y.Op != OpSB + // result: (LEAQ4 [c+4*d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(is32Bit(int64(c)+4*int64(d)) && y.Op != OpSB) { + break + } + v.reset(OpAMD64LEAQ4) + v.AuxInt = int32ToAuxInt(c + 4*d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAQ4 [c] {s} x z:(ADDQ y y)) + // cond: x != z + // result: (LEAQ8 [c] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + z := v_1 + if z.Op != OpAMD64ADDQ { + break + } + y := z.Args[1] + if y != z.Args[0] || !(x != z) { + break + } + v.reset(OpAMD64LEAQ8) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAQ4 [off1] {sym1} (LEAQ [off2] {sym2} x) y) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB + // result: (LEAQ4 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB) { + break + } + v.reset(OpAMD64LEAQ4) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAQ4 [off1] {sym1} x (LEAQ1 [off2] {sym2} y y)) + // cond: is32Bit(int64(off1)+4*int64(off2)) && sym2 == nil + // result: (LEAQ8 [off1+4*off2] {sym1} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64LEAQ1 { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + y := v_1.Args[1] + if y != v_1.Args[0] || !(is32Bit(int64(off1)+4*int64(off2)) && sym2 == nil) { + break + } + v.reset(OpAMD64LEAQ8) + v.AuxInt = int32ToAuxInt(off1 + 4*off2) + v.Aux = symToAux(sym1) + v.AddArg2(x, y) + return true + } + // match: (LEAQ4 [off] {sym} x (MOVQconst [scale])) + // cond: is32Bit(int64(off)+int64(scale)*4) + // result: (LEAQ [off+int32(scale)*4] {sym} x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + scale := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(int64(off) + int64(scale)*4)) { + break + } + v.reset(OpAMD64LEAQ) + v.AuxInt = int32ToAuxInt(off + int32(scale)*4) + v.Aux = symToAux(sym) + v.AddArg(x) + return true + } + // match: (LEAQ4 [off] {sym} x (MOVLconst [scale])) + // cond: is32Bit(int64(off)+int64(scale)*4) + // result: (LEAQ [off+int32(scale)*4] {sym} x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + scale := auxIntToInt32(v_1.AuxInt) + if !(is32Bit(int64(off) + int64(scale)*4)) { + break + } + v.reset(OpAMD64LEAQ) + v.AuxInt = int32ToAuxInt(off + int32(scale)*4) + v.Aux = symToAux(sym) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LEAQ8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LEAQ8 [c] {s} (ADDQconst [d] x) y) + // cond: is32Bit(int64(c)+int64(d)) && x.Op != OpSB + // result: (LEAQ8 [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(c)+int64(d)) && x.Op != OpSB) { + break + } + v.reset(OpAMD64LEAQ8) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAQ8 [c] {s} x (ADDQconst [d] y)) + // cond: is32Bit(int64(c)+8*int64(d)) && y.Op != OpSB + // result: (LEAQ8 [c+8*d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(is32Bit(int64(c)+8*int64(d)) && y.Op != OpSB) { + break + } + v.reset(OpAMD64LEAQ8) + v.AuxInt = int32ToAuxInt(c + 8*d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (LEAQ8 [off1] {sym1} (LEAQ [off2] {sym2} x) y) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB + // result: (LEAQ8 [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB) { + break + } + v.reset(OpAMD64LEAQ8) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (LEAQ8 [off] {sym} x (MOVQconst [scale])) + // cond: is32Bit(int64(off)+int64(scale)*8) + // result: (LEAQ [off+int32(scale)*8] {sym} x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + scale := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(int64(off) + int64(scale)*8)) { + break + } + v.reset(OpAMD64LEAQ) + v.AuxInt = int32ToAuxInt(off + int32(scale)*8) + v.Aux = symToAux(sym) + v.AddArg(x) + return true + } + // match: (LEAQ8 [off] {sym} x (MOVLconst [scale])) + // cond: is32Bit(int64(off)+int64(scale)*8) + // result: (LEAQ [off+int32(scale)*8] {sym} x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + scale := auxIntToInt32(v_1.AuxInt) + if !(is32Bit(int64(off) + int64(scale)*8)) { + break + } + v.reset(OpAMD64LEAQ) + v.AuxInt = int32ToAuxInt(off + int32(scale)*8) + v.Aux = symToAux(sym) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LoweredPanicBoundsCR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsCR [kind] {p} (MOVQconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:p.C, Cy:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpAMD64LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: p.C, Cy: c}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LoweredPanicBoundsRC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRC [kind] {p} (MOVQconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:c, Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpAMD64LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: c, Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64LoweredPanicBoundsRR(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRR [kind] x (MOVQconst [c]) mem) + // result: (LoweredPanicBoundsRC [kind] x {PanicBoundsC{C:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64LoweredPanicBoundsRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(x, mem) + return true + } + // match: (LoweredPanicBoundsRR [kind] (MOVQconst [c]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:c}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + mem := v_2 + v.reset(OpAMD64LoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBELstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBELstore [i] {s} p x:(BSWAPL w) mem) + // cond: x.Uses == 1 + // result: (MOVLstore [i] {s} p w mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + x := v_1 + if x.Op != OpAMD64BSWAPL { + break + } + w := x.Args[0] + mem := v_2 + if !(x.Uses == 1) { + break + } + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, w, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBEQstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBEQstore [i] {s} p x:(BSWAPQ w) mem) + // cond: x.Uses == 1 + // result: (MOVQstore [i] {s} p w mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + x := v_1 + if x.Op != OpAMD64BSWAPQ { + break + } + w := x.Args[0] + mem := v_2 + if !(x.Uses == 1) { + break + } + v.reset(OpAMD64MOVQstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, w, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBEWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBEWstore [i] {s} p x:(ROLWconst [8] w) mem) + // cond: x.Uses == 1 + // result: (MOVWstore [i] {s} p w mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + x := v_1 + if x.Op != OpAMD64ROLWconst || auxIntToInt8(x.AuxInt) != 8 { + break + } + w := x.Args[0] + mem := v_2 + if !(x.Uses == 1) { + break + } + v.reset(OpAMD64MOVWstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, w, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBQSX(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVBQSX x:(MOVBload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBQSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVBload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVBQSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBQSX x:(MOVWload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBQSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVWload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVBQSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBQSX x:(MOVLload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBQSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVBQSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBQSX x:(MOVQload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBQSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVBQSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBQSX (ANDLconst [c] x)) + // cond: c & 0x80 == 0 + // result: (ANDLconst [c & 0x7f] x) + for { + if v_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(c&0x80 == 0) { + break + } + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(c & 0x7f) + v.AddArg(x) + return true + } + // match: (MOVBQSX (MOVBQSX x)) + // result: (MOVBQSX x) + for { + if v_0.Op != OpAMD64MOVBQSX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVBQSX) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBQSXload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBQSXload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVBQSX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVBstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpAMD64MOVBQSX) + v.AddArg(x) + return true + } + // match: (MOVBQSXload [off1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVBQSXload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVBQSXload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVBQSXload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVQconst [int64(int8(read8(sym, int64(off))))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(int8(read8(sym, int64(off))))) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBQZX(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVBQZX x:(MOVBload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVBload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVBload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBQZX x:(MOVWload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVWload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVBload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBQZX x:(MOVLload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVBload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBQZX x:(MOVQload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVBload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBQZX (ANDLconst [c] x)) + // result: (ANDLconst [c & 0xff] x) + for { + if v_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(c & 0xff) + v.AddArg(x) + return true + } + // match: (MOVBQZX (MOVBQZX x)) + // result: (MOVBQZX x) + for { + if v_0.Op != OpAMD64MOVBQZX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVBQZX) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBatomicload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBatomicload [off1] {sym} (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVBatomicload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVBatomicload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBatomicload [off1] {sym1} (LEAQ [off2] {sym2} ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVBatomicload [off1+off2] {mergeSym(sym1, sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVBatomicload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVBQZX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVBstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpAMD64MOVBQZX) + v.AddArg(x) + return true + } + // match: (MOVBload [off1] {sym} (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVBload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVBload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVBload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVLconst [int32(read8(sym, int64(off)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(int32(read8(sym, int64(off)))) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstore [off] {sym} ptr y:(SETL x) mem) + // cond: y.Uses == 1 + // result: (SETLstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SETL { + break + } + x := y.Args[0] + mem := v_2 + if !(y.Uses == 1) { + break + } + v.reset(OpAMD64SETLstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr y:(SETLE x) mem) + // cond: y.Uses == 1 + // result: (SETLEstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SETLE { + break + } + x := y.Args[0] + mem := v_2 + if !(y.Uses == 1) { + break + } + v.reset(OpAMD64SETLEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr y:(SETG x) mem) + // cond: y.Uses == 1 + // result: (SETGstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SETG { + break + } + x := y.Args[0] + mem := v_2 + if !(y.Uses == 1) { + break + } + v.reset(OpAMD64SETGstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr y:(SETGE x) mem) + // cond: y.Uses == 1 + // result: (SETGEstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SETGE { + break + } + x := y.Args[0] + mem := v_2 + if !(y.Uses == 1) { + break + } + v.reset(OpAMD64SETGEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr y:(SETEQ x) mem) + // cond: y.Uses == 1 + // result: (SETEQstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SETEQ { + break + } + x := y.Args[0] + mem := v_2 + if !(y.Uses == 1) { + break + } + v.reset(OpAMD64SETEQstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr y:(SETNE x) mem) + // cond: y.Uses == 1 + // result: (SETNEstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SETNE { + break + } + x := y.Args[0] + mem := v_2 + if !(y.Uses == 1) { + break + } + v.reset(OpAMD64SETNEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr y:(SETB x) mem) + // cond: y.Uses == 1 + // result: (SETBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SETB { + break + } + x := y.Args[0] + mem := v_2 + if !(y.Uses == 1) { + break + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr y:(SETBE x) mem) + // cond: y.Uses == 1 + // result: (SETBEstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SETBE { + break + } + x := y.Args[0] + mem := v_2 + if !(y.Uses == 1) { + break + } + v.reset(OpAMD64SETBEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr y:(SETA x) mem) + // cond: y.Uses == 1 + // result: (SETAstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SETA { + break + } + x := y.Args[0] + mem := v_2 + if !(y.Uses == 1) { + break + } + v.reset(OpAMD64SETAstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr y:(SETAE x) mem) + // cond: y.Uses == 1 + // result: (SETAEstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SETAE { + break + } + x := y.Args[0] + mem := v_2 + if !(y.Uses == 1) { + break + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBQSX x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVBQSX { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBQZX x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVBQZX { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off1] {sym} (ADDQconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVBstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVLconst [c]) mem) + // result: (MOVBstoreconst [makeValAndOff(int32(int8(c)),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(int8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVQconst [c]) mem) + // result: (MOVBstoreconst [makeValAndOff(int32(int8(c)),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(int8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (KMOVBi mask) mem) + // result: (KMOVBstore [off] {sym} ptr mask mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64KMOVBi { + break + } + mask := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64KMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVBstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstoreconst [sc] {s} (ADDQconst [off] ptr) mem) + // cond: ValAndOff(sc).canAdd32(off) + // result: (MOVBstoreconst [ValAndOff(sc).addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(ValAndOff(sc).canAdd32(off)) { + break + } + v.reset(OpAMD64MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(ValAndOff(sc).addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstoreconst [sc] {sym1} (LEAQ [off] {sym2} ptr) mem) + // cond: canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off) + // result: (MOVBstoreconst [ValAndOff(sc).addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off)) { + break + } + v.reset(OpAMD64MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(ValAndOff(sc).addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVLQSX(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVLQSX x:(MOVLload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVLQSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVLQSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVLQSX x:(MOVQload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVLQSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVLQSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVLQSX (ANDLconst [c] x)) + // cond: uint32(c) & 0x80000000 == 0 + // result: (ANDLconst [c & 0x7fffffff] x) + for { + if v_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(uint32(c)&0x80000000 == 0) { + break + } + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(c & 0x7fffffff) + v.AddArg(x) + return true + } + // match: (MOVLQSX (MOVLQSX x)) + // result: (MOVLQSX x) + for { + if v_0.Op != OpAMD64MOVLQSX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVLQSX) + v.AddArg(x) + return true + } + // match: (MOVLQSX (MOVWQSX x)) + // result: (MOVWQSX x) + for { + if v_0.Op != OpAMD64MOVWQSX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVWQSX) + v.AddArg(x) + return true + } + // match: (MOVLQSX (MOVBQSX x)) + // result: (MOVBQSX x) + for { + if v_0.Op != OpAMD64MOVBQSX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVBQSX) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVLQSXload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVLQSXload [off] {sym} ptr (MOVLstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVLQSX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpAMD64MOVLQSX) + v.AddArg(x) + return true + } + // match: (MOVLQSXload [off1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVLQSXload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVLQSXload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVLQSXload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVQconst [int64(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVLQZX(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVLQZX x:(MOVLload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVLload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVLload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVLQZX x:(MOVQload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVLload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVLload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVLQZX (ANDLconst [c] x)) + // result: (ANDLconst [c] x) + for { + if v_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVLQZX (MOVLQZX x)) + // result: (MOVLQZX x) + for { + if v_0.Op != OpAMD64MOVLQZX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVLQZX) + v.AddArg(x) + return true + } + // match: (MOVLQZX (MOVWQZX x)) + // result: (MOVWQZX x) + for { + if v_0.Op != OpAMD64MOVWQZX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVWQZX) + v.AddArg(x) + return true + } + // match: (MOVLQZX (MOVBQZX x)) + // result: (MOVBQZX x) + for { + if v_0.Op != OpAMD64MOVBQZX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVBQZX) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVLatomicload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVLatomicload [off1] {sym} (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVLatomicload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVLatomicload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLatomicload [off1] {sym1} (LEAQ [off2] {sym2} ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVLatomicload [off1+off2] {mergeSym(sym1, sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVLatomicload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVLf2i(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVLf2i (Arg [off] {sym})) + // cond: t.Size() == u.Size() + // result: @b.Func.Entry (Arg [off] {sym}) + for { + t := v.Type + if v_0.Op != OpArg { + break + } + u := v_0.Type + off := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + if !(t.Size() == u.Size()) { + break + } + b = b.Func.Entry + v0 := b.NewValue0(v.Pos, OpArg, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVLi2f(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVLi2f (Arg [off] {sym})) + // cond: t.Size() == u.Size() + // result: @b.Func.Entry (Arg [off] {sym}) + for { + t := v.Type + if v_0.Op != OpArg { + break + } + u := v_0.Type + off := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + if !(t.Size() == u.Size()) { + break + } + b = b.Func.Entry + v0 := b.NewValue0(v.Pos, OpArg, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVLload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVLload [off] {sym} ptr (MOVLstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVLQZX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpAMD64MOVLQZX) + v.AddArg(x) + return true + } + // match: (MOVLload [off1] {sym} (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVLload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLload [off1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVLload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVLload [off] {sym} ptr (MOVSSstore [off] {sym} ptr val _)) + // result: (MOVLf2i val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVSSstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpAMD64MOVLf2i) + v.AddArg(val) + return true + } + // match: (MOVLload [off] {sym} (SB) _) + // cond: symIsRO(sym) && is32BitInt(t) + // result: (MOVLconst [int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + t := v.Type + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym) && is32BitInt(t)) { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + // match: (MOVLload [off] {sym} (SB) _) + // cond: symIsRO(sym) && is64BitInt(t) + // result: (MOVQconst [int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + t := v.Type + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym) && is64BitInt(t)) { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVLstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVLstore [off] {sym} ptr (MOVLQSX x) mem) + // result: (MOVLstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLQSX { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore [off] {sym} ptr (MOVLQZX x) mem) + // result: (MOVLstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLQZX { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore [off1] {sym} (ADDQconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVLstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVLstore [off] {sym} ptr (MOVLconst [c]) mem) + // result: (MOVLstoreconst [makeValAndOff(int32(c),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstore [off] {sym} ptr (MOVQconst [c]) mem) + // result: (MOVLstoreconst [makeValAndOff(int32(c),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVLstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ADDLload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (ADDLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ADDLload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(OpAMD64ADDLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ANDLload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (ANDLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ANDLload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(OpAMD64ANDLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ORLload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (ORLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ORLload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(OpAMD64ORLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(XORLload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (XORLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64XORLload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(OpAMD64XORLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ADDL l:(MOVLload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ADDLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ADDL { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != OpAMD64MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(OpAMD64ADDLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVLstore {sym} [off] ptr y:(SUBL l:(MOVLload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (SUBLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SUBL { + break + } + x := y.Args[1] + l := y.Args[0] + if l.Op != OpAMD64MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + if ptr != l.Args[0] || mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + break + } + v.reset(OpAMD64SUBLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVLstore {sym} [off] ptr y:(ANDL l:(MOVLload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ANDLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ANDL { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != OpAMD64MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(OpAMD64ANDLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVLstore {sym} [off] ptr y:(ORL l:(MOVLload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ORLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ORL { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != OpAMD64MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(OpAMD64ORLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVLstore {sym} [off] ptr y:(XORL l:(MOVLload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (XORLmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64XORL { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != OpAMD64MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(OpAMD64XORLmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVLstore [off] {sym} ptr a:(ADDLconst [c] l:(MOVLload [off] {sym} ptr2 mem)) mem) + // cond: isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a) + // result: (ADDLconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + a := v_1 + if a.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(a.AuxInt) + l := a.Args[0] + if l.Op != OpAMD64MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + ptr2 := l.Args[0] + if mem != v_2 || !(isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a)) { + break + } + v.reset(OpAMD64ADDLconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstore [off] {sym} ptr a:(ANDLconst [c] l:(MOVLload [off] {sym} ptr2 mem)) mem) + // cond: isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a) + // result: (ANDLconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + a := v_1 + if a.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(a.AuxInt) + l := a.Args[0] + if l.Op != OpAMD64MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + ptr2 := l.Args[0] + if mem != v_2 || !(isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a)) { + break + } + v.reset(OpAMD64ANDLconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstore [off] {sym} ptr a:(ORLconst [c] l:(MOVLload [off] {sym} ptr2 mem)) mem) + // cond: isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a) + // result: (ORLconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + a := v_1 + if a.Op != OpAMD64ORLconst { + break + } + c := auxIntToInt32(a.AuxInt) + l := a.Args[0] + if l.Op != OpAMD64MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + ptr2 := l.Args[0] + if mem != v_2 || !(isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a)) { + break + } + v.reset(OpAMD64ORLconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstore [off] {sym} ptr a:(XORLconst [c] l:(MOVLload [off] {sym} ptr2 mem)) mem) + // cond: isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a) + // result: (XORLconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + a := v_1 + if a.Op != OpAMD64XORLconst { + break + } + c := auxIntToInt32(a.AuxInt) + l := a.Args[0] + if l.Op != OpAMD64MOVLload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + ptr2 := l.Args[0] + if mem != v_2 || !(isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a)) { + break + } + v.reset(OpAMD64XORLconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstore [off] {sym} ptr (MOVLf2i val) mem) + // result: (MOVSSstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLf2i { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64MOVSSstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVLstore [i] {s} p x:(BSWAPL w) mem) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBELstore [i] {s} p w mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + x := v_1 + if x.Op != OpAMD64BSWAPL { + break + } + w := x.Args[0] + mem := v_2 + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBELstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, w, mem) + return true + } + // match: (MOVLstore [off] {sym} ptr (KMOVDi mask) mem) + // result: (KMOVDstore [off] {sym} ptr mask mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64KMOVDi { + break + } + mask := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64KMOVDstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVLstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVLstoreconst [sc] {s} (ADDQconst [off] ptr) mem) + // cond: ValAndOff(sc).canAdd32(off) + // result: (MOVLstoreconst [ValAndOff(sc).addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(ValAndOff(sc).canAdd32(off)) { + break + } + v.reset(OpAMD64MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(ValAndOff(sc).addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVLstoreconst [sc] {sym1} (LEAQ [off] {sym2} ptr) mem) + // cond: canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off) + // result: (MOVLstoreconst [ValAndOff(sc).addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off)) { + break + } + v.reset(OpAMD64MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(ValAndOff(sc).addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVOload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVOload [off1] {sym} (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVOload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVOload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVOload [off1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVOload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVOload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVOstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVOstore [off1] {sym} (ADDQconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVOstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVOstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVOstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVOstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVOstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVOstore [dstOff] {dstSym} ptr (MOVOload [srcOff] {srcSym} (SB) _) mem) + // cond: symIsRO(srcSym) + // result: (MOVQstore [dstOff+8] {dstSym} ptr (MOVQconst [int64(read64(srcSym, int64(srcOff)+8, config.ctxt.Arch.ByteOrder))]) (MOVQstore [dstOff] {dstSym} ptr (MOVQconst [int64(read64(srcSym, int64(srcOff), config.ctxt.Arch.ByteOrder))]) mem)) + for { + dstOff := auxIntToInt32(v.AuxInt) + dstSym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVOload { + break + } + srcOff := auxIntToInt32(v_1.AuxInt) + srcSym := auxToSym(v_1.Aux) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpSB { + break + } + mem := v_2 + if !(symIsRO(srcSym)) { + break + } + v.reset(OpAMD64MOVQstore) + v.AuxInt = int32ToAuxInt(dstOff + 8) + v.Aux = symToAux(dstSym) + v0 := b.NewValue0(v_1.Pos, OpAMD64MOVQconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(int64(read64(srcSym, int64(srcOff)+8, config.ctxt.Arch.ByteOrder))) + v1 := b.NewValue0(v_1.Pos, OpAMD64MOVQstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(dstOff) + v1.Aux = symToAux(dstSym) + v2 := b.NewValue0(v_1.Pos, OpAMD64MOVQconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(int64(read64(srcSym, int64(srcOff), config.ctxt.Arch.ByteOrder))) + v1.AddArg3(ptr, v2, mem) + v.AddArg3(ptr, v0, v1) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVOstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVOstoreconst [sc] {s} (ADDQconst [off] ptr) mem) + // cond: ValAndOff(sc).canAdd32(off) + // result: (MOVOstoreconst [ValAndOff(sc).addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(ValAndOff(sc).canAdd32(off)) { + break + } + v.reset(OpAMD64MOVOstoreconst) + v.AuxInt = valAndOffToAuxInt(ValAndOff(sc).addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVOstoreconst [sc] {sym1} (LEAQ [off] {sym2} ptr) mem) + // cond: canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off) + // result: (MOVOstoreconst [ValAndOff(sc).addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off)) { + break + } + v.reset(OpAMD64MOVOstoreconst) + v.AuxInt = valAndOffToAuxInt(ValAndOff(sc).addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVQatomicload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVQatomicload [off1] {sym} (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVQatomicload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVQatomicload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQatomicload [off1] {sym1} (LEAQ [off2] {sym2} ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVQatomicload [off1+off2] {mergeSym(sym1, sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVQatomicload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVQf2i(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVQf2i (Arg [off] {sym})) + // cond: t.Size() == u.Size() + // result: @b.Func.Entry (Arg [off] {sym}) + for { + t := v.Type + if v_0.Op != OpArg { + break + } + u := v_0.Type + off := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + if !(t.Size() == u.Size()) { + break + } + b = b.Func.Entry + v0 := b.NewValue0(v.Pos, OpArg, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVQi2f(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVQi2f (Arg [off] {sym})) + // cond: t.Size() == u.Size() + // result: @b.Func.Entry (Arg [off] {sym}) + for { + t := v.Type + if v_0.Op != OpArg { + break + } + u := v_0.Type + off := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + if !(t.Size() == u.Size()) { + break + } + b = b.Func.Entry + v0 := b.NewValue0(v.Pos, OpArg, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVQload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVQload [off] {sym} ptr (MOVQstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + // match: (MOVQload [off1] {sym} (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVQload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQload [off1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVQload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVQload [off] {sym} ptr (MOVSDstore [off] {sym} ptr val _)) + // result: (MOVQf2i val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVSDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpAMD64MOVQf2i) + v.AddArg(val) + return true + } + // match: (MOVQload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVQconst [int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVQstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVQstore [off1] {sym} (ADDQconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVQstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVQstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVQstore [off] {sym} ptr (MOVQconst [c]) mem) + // cond: validVal(c) + // result: (MOVQstoreconst [makeValAndOff(int32(c),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(validVal(c)) { + break + } + v.reset(OpAMD64MOVQstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVQstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVQstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVQstore {sym} [off] ptr y:(ADDQload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (ADDQmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ADDQload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(OpAMD64ADDQmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVQstore {sym} [off] ptr y:(ANDQload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (ANDQmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ANDQload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(OpAMD64ANDQmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVQstore {sym} [off] ptr y:(ORQload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (ORQmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ORQload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(OpAMD64ORQmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVQstore {sym} [off] ptr y:(XORQload x [off] {sym} ptr mem) mem) + // cond: y.Uses==1 && clobber(y) + // result: (XORQmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64XORQload || auxIntToInt32(y.AuxInt) != off || auxToSym(y.Aux) != sym { + break + } + mem := y.Args[2] + x := y.Args[0] + if ptr != y.Args[1] || mem != v_2 || !(y.Uses == 1 && clobber(y)) { + break + } + v.reset(OpAMD64XORQmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVQstore {sym} [off] ptr y:(ADDQ l:(MOVQload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ADDQmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ADDQ { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(OpAMD64ADDQmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVQstore {sym} [off] ptr y:(SUBQ l:(MOVQload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (SUBQmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64SUBQ { + break + } + x := y.Args[1] + l := y.Args[0] + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + if ptr != l.Args[0] || mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + break + } + v.reset(OpAMD64SUBQmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVQstore {sym} [off] ptr y:(ANDQ l:(MOVQload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ANDQmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ANDQ { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(OpAMD64ANDQmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVQstore {sym} [off] ptr y:(ORQ l:(MOVQload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (ORQmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64ORQ { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(OpAMD64ORQmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVQstore {sym} [off] ptr y:(XORQ l:(MOVQload [off] {sym} ptr mem) x) mem) + // cond: y.Uses==1 && l.Uses==1 && clobber(y, l) + // result: (XORQmodify [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + y := v_1 + if y.Op != OpAMD64XORQ { + break + } + _ = y.Args[1] + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + l := y_0 + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + continue + } + mem := l.Args[1] + if ptr != l.Args[0] { + continue + } + x := y_1 + if mem != v_2 || !(y.Uses == 1 && l.Uses == 1 && clobber(y, l)) { + continue + } + v.reset(OpAMD64XORQmodify) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + break + } + // match: (MOVQstore {sym} [off] ptr x:(BTSQconst [c] l:(MOVQload {sym} [off] ptr mem)) mem) + // cond: x.Uses == 1 && l.Uses == 1 && clobber(x, l) + // result: (BTSQconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + x := v_1 + if x.Op != OpAMD64BTSQconst { + break + } + c := auxIntToInt8(x.AuxInt) + l := x.Args[0] + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + if ptr != l.Args[0] || mem != v_2 || !(x.Uses == 1 && l.Uses == 1 && clobber(x, l)) { + break + } + v.reset(OpAMD64BTSQconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQstore {sym} [off] ptr x:(BTRQconst [c] l:(MOVQload {sym} [off] ptr mem)) mem) + // cond: x.Uses == 1 && l.Uses == 1 && clobber(x, l) + // result: (BTRQconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + x := v_1 + if x.Op != OpAMD64BTRQconst { + break + } + c := auxIntToInt8(x.AuxInt) + l := x.Args[0] + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + if ptr != l.Args[0] || mem != v_2 || !(x.Uses == 1 && l.Uses == 1 && clobber(x, l)) { + break + } + v.reset(OpAMD64BTRQconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQstore {sym} [off] ptr x:(BTCQconst [c] l:(MOVQload {sym} [off] ptr mem)) mem) + // cond: x.Uses == 1 && l.Uses == 1 && clobber(x, l) + // result: (BTCQconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + x := v_1 + if x.Op != OpAMD64BTCQconst { + break + } + c := auxIntToInt8(x.AuxInt) + l := x.Args[0] + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + if ptr != l.Args[0] || mem != v_2 || !(x.Uses == 1 && l.Uses == 1 && clobber(x, l)) { + break + } + v.reset(OpAMD64BTCQconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQstore [off] {sym} ptr a:(ADDQconst [c] l:(MOVQload [off] {sym} ptr2 mem)) mem) + // cond: isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a) + // result: (ADDQconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + a := v_1 + if a.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(a.AuxInt) + l := a.Args[0] + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + ptr2 := l.Args[0] + if mem != v_2 || !(isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a)) { + break + } + v.reset(OpAMD64ADDQconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQstore [off] {sym} ptr a:(ANDQconst [c] l:(MOVQload [off] {sym} ptr2 mem)) mem) + // cond: isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a) + // result: (ANDQconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + a := v_1 + if a.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(a.AuxInt) + l := a.Args[0] + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + ptr2 := l.Args[0] + if mem != v_2 || !(isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a)) { + break + } + v.reset(OpAMD64ANDQconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQstore [off] {sym} ptr a:(ORQconst [c] l:(MOVQload [off] {sym} ptr2 mem)) mem) + // cond: isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a) + // result: (ORQconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + a := v_1 + if a.Op != OpAMD64ORQconst { + break + } + c := auxIntToInt32(a.AuxInt) + l := a.Args[0] + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + ptr2 := l.Args[0] + if mem != v_2 || !(isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a)) { + break + } + v.reset(OpAMD64ORQconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQstore [off] {sym} ptr a:(XORQconst [c] l:(MOVQload [off] {sym} ptr2 mem)) mem) + // cond: isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a) + // result: (XORQconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + a := v_1 + if a.Op != OpAMD64XORQconst { + break + } + c := auxIntToInt32(a.AuxInt) + l := a.Args[0] + if l.Op != OpAMD64MOVQload || auxIntToInt32(l.AuxInt) != off || auxToSym(l.Aux) != sym { + break + } + mem := l.Args[1] + ptr2 := l.Args[0] + if mem != v_2 || !(isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a)) { + break + } + v.reset(OpAMD64XORQconstmodify) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQstore [off] {sym} ptr (MOVQf2i val) mem) + // result: (MOVSDstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQf2i { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64MOVSDstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVQstore [i] {s} p x:(BSWAPQ w) mem) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBEQstore [i] {s} p w mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + x := v_1 + if x.Op != OpAMD64BSWAPQ { + break + } + w := x.Args[0] + mem := v_2 + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBEQstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, w, mem) + return true + } + // match: (MOVQstore [off] {sym} ptr (KMOVQi mask) mem) + // result: (KMOVQstore [off] {sym} ptr mask mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64KMOVQi { + break + } + mask := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64KMOVQstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVQstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVQstoreconst [sc] {s} (ADDQconst [off] ptr) mem) + // cond: ValAndOff(sc).canAdd32(off) + // result: (MOVQstoreconst [ValAndOff(sc).addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(ValAndOff(sc).canAdd32(off)) { + break + } + v.reset(OpAMD64MOVQstoreconst) + v.AuxInt = valAndOffToAuxInt(ValAndOff(sc).addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQstoreconst [sc] {sym1} (LEAQ [off] {sym2} ptr) mem) + // cond: canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off) + // result: (MOVQstoreconst [ValAndOff(sc).addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off)) { + break + } + v.reset(OpAMD64MOVQstoreconst) + v.AuxInt = valAndOffToAuxInt(ValAndOff(sc).addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVQstoreconst [c] {s} p1 x:(MOVQstoreconst [a] {s} p0 mem)) + // cond: x.Uses == 1 && sequentialAddresses(p0, p1, int64(a.Off()+8-c.Off())) && a.Val() == 0 && c.Val() == 0 && setPos(v, x.Pos) && clobber(x) + // result: (MOVOstoreconst [makeValAndOff(0,a.Off())] {s} p0 mem) + for { + c := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + p1 := v_0 + x := v_1 + if x.Op != OpAMD64MOVQstoreconst { + break + } + a := auxIntToValAndOff(x.AuxInt) + if auxToSym(x.Aux) != s { + break + } + mem := x.Args[1] + p0 := x.Args[0] + if !(x.Uses == 1 && sequentialAddresses(p0, p1, int64(a.Off()+8-c.Off())) && a.Val() == 0 && c.Val() == 0 && setPos(v, x.Pos) && clobber(x)) { + break + } + v.reset(OpAMD64MOVOstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, a.Off())) + v.Aux = symToAux(s) + v.AddArg2(p0, mem) + return true + } + // match: (MOVQstoreconst [a] {s} p0 x:(MOVQstoreconst [c] {s} p1 mem)) + // cond: x.Uses == 1 && sequentialAddresses(p0, p1, int64(a.Off()+8-c.Off())) && a.Val() == 0 && c.Val() == 0 && setPos(v, x.Pos) && clobber(x) + // result: (MOVOstoreconst [makeValAndOff(0,a.Off())] {s} p0 mem) + for { + a := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + p0 := v_0 + x := v_1 + if x.Op != OpAMD64MOVQstoreconst { + break + } + c := auxIntToValAndOff(x.AuxInt) + if auxToSym(x.Aux) != s { + break + } + mem := x.Args[1] + p1 := x.Args[0] + if !(x.Uses == 1 && sequentialAddresses(p0, p1, int64(a.Off()+8-c.Off())) && a.Val() == 0 && c.Val() == 0 && setPos(v, x.Pos) && clobber(x)) { + break + } + v.reset(OpAMD64MOVOstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, a.Off())) + v.Aux = symToAux(s) + v.AddArg2(p0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVSDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVSDload [off1] {sym} (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVSDload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVSDload [off1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVSDload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVSDload [off] {sym} ptr (MOVQstore [off] {sym} ptr val _)) + // result: (MOVQi2f val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpAMD64MOVQi2f) + v.AddArg(val) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVSDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVSDstore [off1] {sym} (ADDQconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVSDstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVSDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVSDstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVSDstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVSDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVSDstore [off] {sym} ptr (MOVQi2f val) mem) + // result: (MOVQstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQi2f { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64MOVQstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVSDstore [off] {sym} ptr (MOVSDconst [f]) mem) + // cond: f == f + // result: (MOVQstore [off] {sym} ptr (MOVQconst [int64(math.Float64bits(f))]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVSDconst { + break + } + f := auxIntToFloat64(v_1.AuxInt) + mem := v_2 + if !(f == f) { + break + } + v.reset(OpAMD64MOVQstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(int64(math.Float64bits(f))) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVSSload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVSSload [off1] {sym} (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVSSload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVSSload [off1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVSSload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVSSload [off] {sym} ptr (MOVLstore [off] {sym} ptr val _)) + // result: (MOVLi2f val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpAMD64MOVLi2f) + v.AddArg(val) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVSSstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVSSstore [off1] {sym} (ADDQconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVSSstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVSSstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVSSstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVSSstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVSSstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVSSstore [off] {sym} ptr (MOVLi2f val) mem) + // result: (MOVLstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLi2f { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVSSstore [off] {sym} ptr (MOVSSconst [f]) mem) + // cond: f == f + // result: (MOVLstore [off] {sym} ptr (MOVLconst [int32(math.Float32bits(f))]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVSSconst { + break + } + f := auxIntToFloat32(v_1.AuxInt) + mem := v_2 + if !(f == f) { + break + } + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(math.Float32bits(f))) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVWQSX(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVWQSX x:(MOVWload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWQSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVWload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVWQSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVWQSX x:(MOVLload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWQSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVWQSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVWQSX x:(MOVQload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWQSXload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVWQSXload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVWQSX (ANDLconst [c] x)) + // cond: c & 0x8000 == 0 + // result: (ANDLconst [c & 0x7fff] x) + for { + if v_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(c&0x8000 == 0) { + break + } + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(c & 0x7fff) + v.AddArg(x) + return true + } + // match: (MOVWQSX (MOVWQSX x)) + // result: (MOVWQSX x) + for { + if v_0.Op != OpAMD64MOVWQSX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVWQSX) + v.AddArg(x) + return true + } + // match: (MOVWQSX (MOVBQSX x)) + // result: (MOVBQSX x) + for { + if v_0.Op != OpAMD64MOVBQSX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVBQSX) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVWQSXload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWQSXload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVWQSX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVWstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpAMD64MOVWQSX) + v.AddArg(x) + return true + } + // match: (MOVWQSXload [off1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVWQSXload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVWQSXload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVWQSXload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVQconst [int64(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVWQZX(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVWQZX x:(MOVWload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVWload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVWload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVWQZX x:(MOVLload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVWload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVWQZX x:(MOVQload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64MOVWload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVWQZX (ANDLconst [c] x)) + // result: (ANDLconst [c & 0xffff] x) + for { + if v_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(c & 0xffff) + v.AddArg(x) + return true + } + // match: (MOVWQZX (MOVWQZX x)) + // result: (MOVWQZX x) + for { + if v_0.Op != OpAMD64MOVWQZX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVWQZX) + v.AddArg(x) + return true + } + // match: (MOVWQZX (MOVBQZX x)) + // result: (MOVBQZX x) + for { + if v_0.Op != OpAMD64MOVBQZX { + break + } + x := v_0.Args[0] + v.reset(OpAMD64MOVBQZX) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVWQZX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVWstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpAMD64MOVWQZX) + v.AddArg(x) + return true + } + // match: (MOVWload [off1] {sym} (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVWload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVWload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVWload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVLconst [int32(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(int32(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstore [off] {sym} ptr (MOVWQSX x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVWQSX { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWQZX x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVWQZX { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off1] {sym} (ADDQconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MOVWstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVLconst [c]) mem) + // result: (MOVWstoreconst [makeValAndOff(int32(int16(c)),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(int16(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVQconst [c]) mem) + // result: (MOVWstoreconst [makeValAndOff(int32(int16(c)),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(int16(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVWstore [i] {s} p x:(ROLWconst [8] w) mem) + // cond: x.Uses == 1 && buildcfg.GOAMD64 >= 3 + // result: (MOVBEWstore [i] {s} p w mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + x := v_1 + if x.Op != OpAMD64ROLWconst || auxIntToInt8(x.AuxInt) != 8 { + break + } + w := x.Args[0] + mem := v_2 + if !(x.Uses == 1 && buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64MOVBEWstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, w, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (KMOVWi mask) mem) + // result: (KMOVWstore [off] {sym} ptr mask mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64KMOVWi { + break + } + mask := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64KMOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MOVWstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstoreconst [sc] {s} (ADDQconst [off] ptr) mem) + // cond: ValAndOff(sc).canAdd32(off) + // result: (MOVWstoreconst [ValAndOff(sc).addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(ValAndOff(sc).canAdd32(off)) { + break + } + v.reset(OpAMD64MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(ValAndOff(sc).addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstoreconst [sc] {sym1} (LEAQ [off] {sym2} ptr) mem) + // cond: canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off) + // result: (MOVWstoreconst [ValAndOff(sc).addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off)) { + break + } + v.reset(OpAMD64MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(ValAndOff(sc).addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MULL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULL x (MOVLconst [c])) + // result: (MULLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64MULLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64MULLconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MULLconst [c] (MULLconst [d] x)) + // result: (MULLconst [c * d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MULLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64MULLconst) + v.AuxInt = int32ToAuxInt(c * d) + v.AddArg(x) + return true + } + // match: (MULLconst [ 0] _) + // result: (MOVLconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (MULLconst [ 1] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 1 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (MULLconst [c] x) + // cond: v.Type.Size() <= 4 && canMulStrengthReduce32(config, c) + // result: {mulStrengthReduce32(v, x, c)} + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(v.Type.Size() <= 4 && canMulStrengthReduce32(config, c)) { + break + } + v.copyOf(mulStrengthReduce32(v, x, c)) + return true + } + // match: (MULLconst [c] (MOVLconst [d])) + // result: (MOVLconst [c*d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(c * d) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MULQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULQ x (MOVQconst [c])) + // cond: is32Bit(c) + // result: (MULQconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpAMD64MULQconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64MULQconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MULQconst [c] (MULQconst [d] x)) + // cond: is32Bit(int64(c)*int64(d)) + // result: (MULQconst [c * d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MULQconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(int64(c) * int64(d))) { + break + } + v.reset(OpAMD64MULQconst) + v.AuxInt = int32ToAuxInt(c * d) + v.AddArg(x) + return true + } + // match: (MULQconst [ 0] _) + // result: (MOVQconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (MULQconst [ 1] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 1 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (MULQconst [c] x) + // cond: canMulStrengthReduce(config, int64(c)) + // result: {mulStrengthReduce(v, x, int64(c))} + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(canMulStrengthReduce(config, int64(c))) { + break + } + v.copyOf(mulStrengthReduce(v, x, int64(c))) + return true + } + // match: (MULQconst [c] (MOVQconst [d])) + // result: (MOVQconst [int64(c)*d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(c) * d) + return true + } + // match: (MULQconst [c] (NEGQ x)) + // cond: c != -(1<<31) + // result: (MULQconst [-c] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64NEGQ { + break + } + x := v_0.Args[0] + if !(c != -(1 << 31)) { + break + } + v.reset(OpAMD64MULQconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MULSD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULSD x l:(MOVSDload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (MULSDload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVSDload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64MULSDload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64MULSDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MULSDload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MULSDload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MULSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (MULSDload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MULSDload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MULSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (MULSDload x [off] {sym} ptr (MOVQstore [off] {sym} ptr y _)) + // result: (MULSD x (MOVQi2f y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVQstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64MULSD) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVQi2f, typ.Float64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64MULSS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULSS x l:(MOVSSload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (MULSSload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVSSload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64MULSSload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64MULSSload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MULSSload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (MULSSload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64MULSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (MULSSload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MULSSload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64MULSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (MULSSload x [off] {sym} ptr (MOVLstore [off] {sym} ptr y _)) + // result: (MULSS x (MOVLi2f y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVLstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64MULSS) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVLi2f, typ.Float32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64NEGL(v *Value) bool { + v_0 := v.Args[0] + // match: (NEGL (NEGL x)) + // result: x + for { + if v_0.Op != OpAMD64NEGL { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (NEGL s:(SUBL x y)) + // cond: s.Uses == 1 + // result: (SUBL y x) + for { + s := v_0 + if s.Op != OpAMD64SUBL { + break + } + y := s.Args[1] + x := s.Args[0] + if !(s.Uses == 1) { + break + } + v.reset(OpAMD64SUBL) + v.AddArg2(y, x) + return true + } + // match: (NEGL (MOVLconst [c])) + // result: (MOVLconst [-c]) + for { + if v_0.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(-c) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64NEGQ(v *Value) bool { + v_0 := v.Args[0] + // match: (NEGQ (NEGQ x)) + // result: x + for { + if v_0.Op != OpAMD64NEGQ { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (NEGQ s:(SUBQ x y)) + // cond: s.Uses == 1 + // result: (SUBQ y x) + for { + s := v_0 + if s.Op != OpAMD64SUBQ { + break + } + y := s.Args[1] + x := s.Args[0] + if !(s.Uses == 1) { + break + } + v.reset(OpAMD64SUBQ) + v.AddArg2(y, x) + return true + } + // match: (NEGQ (MOVQconst [c])) + // result: (MOVQconst [-c]) + for { + if v_0.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(-c) + return true + } + // match: (NEGQ (ADDQconst [c] (NEGQ x))) + // cond: c != -(1<<31) + // result: (ADDQconst [-c] x) + for { + if v_0.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64NEGQ { + break + } + x := v_0_0.Args[0] + if !(c != -(1 << 31)) { + break + } + v.reset(OpAMD64ADDQconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64NOTL(v *Value) bool { + v_0 := v.Args[0] + // match: (NOTL (MOVLconst [c])) + // result: (MOVLconst [^c]) + for { + if v_0.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(^c) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64NOTQ(v *Value) bool { + v_0 := v.Args[0] + // match: (NOTQ (MOVQconst [c])) + // result: (MOVQconst [^c]) + for { + if v_0.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(^c) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ORL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORL (SHLL (MOVLconst [1]) y) x) + // result: (BTSL x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64SHLL { + continue + } + y := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_0_0.AuxInt) != 1 { + continue + } + x := v_1 + v.reset(OpAMD64BTSL) + v.AddArg2(x, y) + return true + } + break + } + // match: (ORL x (MOVLconst [c])) + // result: (ORLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ORLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ORL x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (ORL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ORLload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVLload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64ORLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64ORLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORLconst [c] (ORLconst [d] x)) + // result: (ORLconst [c | d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64ORLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64ORLconst) + v.AuxInt = int32ToAuxInt(c | d) + v.AddArg(x) + return true + } + // match: (ORLconst [c] x) + // cond: c==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c == 0) { + break + } + v.copyOf(x) + return true + } + // match: (ORLconst [c] _) + // cond: c==-1 + // result: (MOVLconst [-1]) + for { + c := auxIntToInt32(v.AuxInt) + if !(c == -1) { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(-1) + return true + } + // match: (ORLconst [c] (MOVLconst [d])) + // result: (MOVLconst [c|d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(c | d) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ORLconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORLconstmodify [valoff1] {sym} (ADDQconst [off2] base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) + // result: (ORLconstmodify [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2)) { + break + } + v.reset(OpAMD64ORLconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (ORLconstmodify [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) + // result: (ORLconstmodify [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ORLconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ORLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ORLload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ORLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ORLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ORLload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ORLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ORLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: ( ORLload x [off] {sym} ptr (MOVSSstore [off] {sym} ptr y _)) + // result: ( ORL x (MOVLf2i y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVSSstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64ORL) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVLf2i, typ.UInt32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ORLmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORLmodify [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ORLmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ORLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (ORLmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ORLmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ORLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ORQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORQ (SHLQ (MOVQconst [1]) y) x) + // result: (BTSQ x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64SHLQ { + continue + } + y := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + continue + } + x := v_1 + v.reset(OpAMD64BTSQ) + v.AddArg2(x, y) + return true + } + break + } + // match: (ORQ (MOVQconst [c]) x) + // cond: isUnsignedPowerOfTwo(uint64(c)) && uint64(c) >= 1<<31 + // result: (BTSQconst [int8(log64u(uint64(c)))] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(isUnsignedPowerOfTwo(uint64(c)) && uint64(c) >= 1<<31) { + continue + } + v.reset(OpAMD64BTSQconst) + v.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) + v.AddArg(x) + return true + } + break + } + // match: (ORQ x (MOVQconst [c])) + // cond: is32Bit(c) + // result: (ORQconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpAMD64ORQconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (ORQ x (MOVLconst [c])) + // result: (ORQconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ORQconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ORQ (SHRQ lo bits) (SHLQ hi (NEGQ bits))) + // result: (SHRDQ lo hi bits) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64SHRQ { + continue + } + bits := v_0.Args[1] + lo := v_0.Args[0] + if v_1.Op != OpAMD64SHLQ { + continue + } + _ = v_1.Args[1] + hi := v_1.Args[0] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpAMD64NEGQ || bits != v_1_1.Args[0] { + continue + } + v.reset(OpAMD64SHRDQ) + v.AddArg3(lo, hi, bits) + return true + } + break + } + // match: (ORQ (SHLQ lo bits) (SHRQ hi (NEGQ bits))) + // result: (SHLDQ lo hi bits) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64SHLQ { + continue + } + bits := v_0.Args[1] + lo := v_0.Args[0] + if v_1.Op != OpAMD64SHRQ { + continue + } + _ = v_1.Args[1] + hi := v_1.Args[0] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpAMD64NEGQ || bits != v_1_1.Args[0] { + continue + } + v.reset(OpAMD64SHLDQ) + v.AddArg3(lo, hi, bits) + return true + } + break + } + // match: (ORQ (SHRXQ lo bits) (SHLXQ hi (NEGQ bits))) + // result: (SHRDQ lo hi bits) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64SHRXQ { + continue + } + bits := v_0.Args[1] + lo := v_0.Args[0] + if v_1.Op != OpAMD64SHLXQ { + continue + } + _ = v_1.Args[1] + hi := v_1.Args[0] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpAMD64NEGQ || bits != v_1_1.Args[0] { + continue + } + v.reset(OpAMD64SHRDQ) + v.AddArg3(lo, hi, bits) + return true + } + break + } + // match: (ORQ (SHLXQ lo bits) (SHRXQ hi (NEGQ bits))) + // result: (SHLDQ lo hi bits) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64SHLXQ { + continue + } + bits := v_0.Args[1] + lo := v_0.Args[0] + if v_1.Op != OpAMD64SHRXQ { + continue + } + _ = v_1.Args[1] + hi := v_1.Args[0] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpAMD64NEGQ || bits != v_1_1.Args[0] { + continue + } + v.reset(OpAMD64SHLDQ) + v.AddArg3(lo, hi, bits) + return true + } + break + } + // match: (ORQ (MOVQconst [c]) (MOVQconst [d])) + // result: (MOVQconst [c|d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpAMD64MOVQconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(c | d) + return true + } + break + } + // match: (ORQ x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (ORQ x l:(MOVQload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (ORQload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVQload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64ORQload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64ORQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORQconst [c] (ORQconst [d] x)) + // result: (ORQconst [c | d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64ORQconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64ORQconst) + v.AuxInt = int32ToAuxInt(c | d) + v.AddArg(x) + return true + } + // match: (ORQconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ORQconst [-1] _) + // result: (MOVQconst [-1]) + for { + if auxIntToInt32(v.AuxInt) != -1 { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (ORQconst [c] (MOVQconst [d])) + // result: (MOVQconst [int64(c)|d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(c) | d) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ORQconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORQconstmodify [valoff1] {sym} (ADDQconst [off2] base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) + // result: (ORQconstmodify [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2)) { + break + } + v.reset(OpAMD64ORQconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (ORQconstmodify [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) + // result: (ORQconstmodify [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ORQconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ORQload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ORQload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ORQload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ORQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (ORQload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ORQload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ORQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: ( ORQload x [off] {sym} ptr (MOVSDstore [off] {sym} ptr y _)) + // result: ( ORQ x (MOVQf2i y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVSDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64ORQ) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVQf2i, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ORQmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORQmodify [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (ORQmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64ORQmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (ORQmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (ORQmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64ORQmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ROLB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROLB x (NEGQ y)) + // result: (RORB x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + y := v_1.Args[0] + v.reset(OpAMD64RORB) + v.AddArg2(x, y) + return true + } + // match: (ROLB x (NEGL y)) + // result: (RORB x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + y := v_1.Args[0] + v.reset(OpAMD64RORB) + v.AddArg2(x, y) + return true + } + // match: (ROLB x (MOVQconst [c])) + // result: (ROLBconst [int8(c&7) ] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64ROLBconst) + v.AuxInt = int8ToAuxInt(int8(c & 7)) + v.AddArg(x) + return true + } + // match: (ROLB x (MOVLconst [c])) + // result: (ROLBconst [int8(c&7) ] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ROLBconst) + v.AuxInt = int8ToAuxInt(int8(c & 7)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ROLBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ROLBconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ROLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROLL x (NEGQ y)) + // result: (RORL x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + y := v_1.Args[0] + v.reset(OpAMD64RORL) + v.AddArg2(x, y) + return true + } + // match: (ROLL x (NEGL y)) + // result: (RORL x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + y := v_1.Args[0] + v.reset(OpAMD64RORL) + v.AddArg2(x, y) + return true + } + // match: (ROLL x (MOVQconst [c])) + // result: (ROLLconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64ROLLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (ROLL x (MOVLconst [c])) + // result: (ROLLconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ROLLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ROLLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ROLLconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ROLQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROLQ x (NEGQ y)) + // result: (RORQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + y := v_1.Args[0] + v.reset(OpAMD64RORQ) + v.AddArg2(x, y) + return true + } + // match: (ROLQ x (NEGL y)) + // result: (RORQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + y := v_1.Args[0] + v.reset(OpAMD64RORQ) + v.AddArg2(x, y) + return true + } + // match: (ROLQ x (MOVQconst [c])) + // result: (ROLQconst [int8(c&63)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64ROLQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v.AddArg(x) + return true + } + // match: (ROLQ x (MOVLconst [c])) + // result: (ROLQconst [int8(c&63)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ROLQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ROLQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ROLQconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ROLW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROLW x (NEGQ y)) + // result: (RORW x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + y := v_1.Args[0] + v.reset(OpAMD64RORW) + v.AddArg2(x, y) + return true + } + // match: (ROLW x (NEGL y)) + // result: (RORW x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + y := v_1.Args[0] + v.reset(OpAMD64RORW) + v.AddArg2(x, y) + return true + } + // match: (ROLW x (MOVQconst [c])) + // result: (ROLWconst [int8(c&15)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64ROLWconst) + v.AuxInt = int8ToAuxInt(int8(c & 15)) + v.AddArg(x) + return true + } + // match: (ROLW x (MOVLconst [c])) + // result: (ROLWconst [int8(c&15)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ROLWconst) + v.AuxInt = int8ToAuxInt(int8(c & 15)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64ROLWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ROLWconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64RORB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RORB x (NEGQ y)) + // result: (ROLB x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + y := v_1.Args[0] + v.reset(OpAMD64ROLB) + v.AddArg2(x, y) + return true + } + // match: (RORB x (NEGL y)) + // result: (ROLB x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + y := v_1.Args[0] + v.reset(OpAMD64ROLB) + v.AddArg2(x, y) + return true + } + // match: (RORB x (MOVQconst [c])) + // result: (ROLBconst [int8((-c)&7) ] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64ROLBconst) + v.AuxInt = int8ToAuxInt(int8((-c) & 7)) + v.AddArg(x) + return true + } + // match: (RORB x (MOVLconst [c])) + // result: (ROLBconst [int8((-c)&7) ] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ROLBconst) + v.AuxInt = int8ToAuxInt(int8((-c) & 7)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64RORL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RORL x (NEGQ y)) + // result: (ROLL x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + y := v_1.Args[0] + v.reset(OpAMD64ROLL) + v.AddArg2(x, y) + return true + } + // match: (RORL x (NEGL y)) + // result: (ROLL x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + y := v_1.Args[0] + v.reset(OpAMD64ROLL) + v.AddArg2(x, y) + return true + } + // match: (RORL x (MOVQconst [c])) + // result: (ROLLconst [int8((-c)&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64ROLLconst) + v.AuxInt = int8ToAuxInt(int8((-c) & 31)) + v.AddArg(x) + return true + } + // match: (RORL x (MOVLconst [c])) + // result: (ROLLconst [int8((-c)&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ROLLconst) + v.AuxInt = int8ToAuxInt(int8((-c) & 31)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64RORQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RORQ x (NEGQ y)) + // result: (ROLQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + y := v_1.Args[0] + v.reset(OpAMD64ROLQ) + v.AddArg2(x, y) + return true + } + // match: (RORQ x (NEGL y)) + // result: (ROLQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + y := v_1.Args[0] + v.reset(OpAMD64ROLQ) + v.AddArg2(x, y) + return true + } + // match: (RORQ x (MOVQconst [c])) + // result: (ROLQconst [int8((-c)&63)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64ROLQconst) + v.AuxInt = int8ToAuxInt(int8((-c) & 63)) + v.AddArg(x) + return true + } + // match: (RORQ x (MOVLconst [c])) + // result: (ROLQconst [int8((-c)&63)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ROLQconst) + v.AuxInt = int8ToAuxInt(int8((-c) & 63)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64RORW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RORW x (NEGQ y)) + // result: (ROLW x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + y := v_1.Args[0] + v.reset(OpAMD64ROLW) + v.AddArg2(x, y) + return true + } + // match: (RORW x (NEGL y)) + // result: (ROLW x y) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + y := v_1.Args[0] + v.reset(OpAMD64ROLW) + v.AddArg2(x, y) + return true + } + // match: (RORW x (MOVQconst [c])) + // result: (ROLWconst [int8((-c)&15)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64ROLWconst) + v.AuxInt = int8ToAuxInt(int8((-c) & 15)) + v.AddArg(x) + return true + } + // match: (RORW x (MOVLconst [c])) + // result: (ROLWconst [int8((-c)&15)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64ROLWconst) + v.AuxInt = int8ToAuxInt(int8((-c) & 15)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SARB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SARB x (MOVQconst [c])) + // result: (SARBconst [int8(min(int64(c)&31,7))] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64SARBconst) + v.AuxInt = int8ToAuxInt(int8(min(int64(c)&31, 7))) + v.AddArg(x) + return true + } + // match: (SARB x (MOVLconst [c])) + // result: (SARBconst [int8(min(int64(c)&31,7))] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64SARBconst) + v.AuxInt = int8ToAuxInt(int8(min(int64(c)&31, 7))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SARBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SARBconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SARBconst [c] (MOVQconst [d])) + // result: (MOVQconst [int64(int8(d))>>uint64(c)]) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(int8(d)) >> uint64(c)) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SARL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SARL x (MOVQconst [c])) + // result: (SARLconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64SARLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SARL x (MOVLconst [c])) + // result: (SARLconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64SARLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SARL x (ADDQconst [c] y)) + // cond: c & 31 == 0 + // result: (SARL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SARL) + v.AddArg2(x, y) + return true + } + // match: (SARL x (NEGQ (ADDQconst [c] y))) + // cond: c & 31 == 0 + // result: (SARL x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SARL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SARL x (ANDQconst [c] y)) + // cond: c & 31 == 31 + // result: (SARL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SARL) + v.AddArg2(x, y) + return true + } + // match: (SARL x (NEGQ (ANDQconst [c] y))) + // cond: c & 31 == 31 + // result: (SARL x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SARL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SARL x (ADDLconst [c] y)) + // cond: c & 31 == 0 + // result: (SARL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SARL) + v.AddArg2(x, y) + return true + } + // match: (SARL x (NEGL (ADDLconst [c] y))) + // cond: c & 31 == 0 + // result: (SARL x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SARL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SARL x (ANDLconst [c] y)) + // cond: c & 31 == 31 + // result: (SARL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SARL) + v.AddArg2(x, y) + return true + } + // match: (SARL x (NEGL (ANDLconst [c] y))) + // cond: c & 31 == 31 + // result: (SARL x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SARL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SARL l:(MOVLload [off] {sym} ptr mem) x) + // cond: buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l) + // result: (SARXLload [off] {sym} ptr x mem) + for { + l := v_0 + if l.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64SARXLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SARLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SARLconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SARLconst [c] (MOVQconst [d])) + // result: (MOVQconst [int64(int32(d))>>uint64(c)]) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(int32(d)) >> uint64(c)) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SARQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SARQ x (MOVQconst [c])) + // result: (SARQconst [int8(c&63)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64SARQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v.AddArg(x) + return true + } + // match: (SARQ x (MOVLconst [c])) + // result: (SARQconst [int8(c&63)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64SARQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v.AddArg(x) + return true + } + // match: (SARQ x (ADDQconst [c] y)) + // cond: c & 63 == 0 + // result: (SARQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SARQ) + v.AddArg2(x, y) + return true + } + // match: (SARQ x (NEGQ (ADDQconst [c] y))) + // cond: c & 63 == 0 + // result: (SARQ x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SARQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SARQ x (ANDQconst [c] y)) + // cond: c & 63 == 63 + // result: (SARQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SARQ) + v.AddArg2(x, y) + return true + } + // match: (SARQ x (NEGQ (ANDQconst [c] y))) + // cond: c & 63 == 63 + // result: (SARQ x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SARQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SARQ x (ADDLconst [c] y)) + // cond: c & 63 == 0 + // result: (SARQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SARQ) + v.AddArg2(x, y) + return true + } + // match: (SARQ x (NEGL (ADDLconst [c] y))) + // cond: c & 63 == 0 + // result: (SARQ x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SARQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SARQ x (ANDLconst [c] y)) + // cond: c & 63 == 63 + // result: (SARQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SARQ) + v.AddArg2(x, y) + return true + } + // match: (SARQ x (NEGL (ANDLconst [c] y))) + // cond: c & 63 == 63 + // result: (SARQ x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SARQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SARQ l:(MOVQload [off] {sym} ptr mem) x) + // cond: buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l) + // result: (SARXQload [off] {sym} ptr x mem) + for { + l := v_0 + if l.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64SARXQload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SARQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SARQconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SARQconst [c] (MOVQconst [d])) + // result: (MOVQconst [d>>uint64(c)]) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(d >> uint64(c)) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SARW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SARW x (MOVQconst [c])) + // result: (SARWconst [int8(min(int64(c)&31,15))] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64SARWconst) + v.AuxInt = int8ToAuxInt(int8(min(int64(c)&31, 15))) + v.AddArg(x) + return true + } + // match: (SARW x (MOVLconst [c])) + // result: (SARWconst [int8(min(int64(c)&31,15))] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64SARWconst) + v.AuxInt = int8ToAuxInt(int8(min(int64(c)&31, 15))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SARWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SARWconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SARWconst [c] (MOVQconst [d])) + // result: (MOVQconst [int64(int16(d))>>uint64(c)]) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(int16(d)) >> uint64(c)) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SARXLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SARXLload [off] {sym} ptr (MOVLconst [c]) mem) + // result: (SARLconst [int8(c&31)] (MOVLload [off] {sym} ptr mem)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64SARLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SARXQload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SARXQload [off] {sym} ptr (MOVQconst [c]) mem) + // result: (SARQconst [int8(c&63)] (MOVQload [off] {sym} ptr mem)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64SARQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + // match: (SARXQload [off] {sym} ptr (MOVLconst [c]) mem) + // result: (SARQconst [int8(c&63)] (MOVQload [off] {sym} ptr mem)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64SARQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SBBLcarrymask(v *Value) bool { + v_0 := v.Args[0] + // match: (SBBLcarrymask (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SBBLcarrymask (FlagLT_ULT)) + // result: (MOVLconst [-1]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(-1) + return true + } + // match: (SBBLcarrymask (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SBBLcarrymask (FlagGT_ULT)) + // result: (MOVLconst [-1]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(-1) + return true + } + // match: (SBBLcarrymask (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SBBQ(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SBBQ x (MOVQconst [c]) borrow) + // cond: is32Bit(c) + // result: (SBBQconst x [int32(c)] borrow) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + borrow := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpAMD64SBBQconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(x, borrow) + return true + } + // match: (SBBQ x y (FlagEQ)) + // result: (SUBQborrow x y) + for { + x := v_0 + y := v_1 + if v_2.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64SUBQborrow) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SBBQcarrymask(v *Value) bool { + v_0 := v.Args[0] + // match: (SBBQcarrymask (FlagEQ)) + // result: (MOVQconst [0]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SBBQcarrymask (FlagLT_ULT)) + // result: (MOVQconst [-1]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (SBBQcarrymask (FlagLT_UGT)) + // result: (MOVQconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SBBQcarrymask (FlagGT_ULT)) + // result: (MOVQconst [-1]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (SBBQcarrymask (FlagGT_UGT)) + // result: (MOVQconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SBBQconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SBBQconst x [c] (FlagEQ)) + // result: (SUBQconstborrow x [c]) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64SUBQconstborrow) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETA(v *Value) bool { + v_0 := v.Args[0] + // match: (SETA (InvertFlags x)) + // result: (SETB x) + for { + if v_0.Op != OpAMD64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETB) + v.AddArg(x) + return true + } + // match: (SETA (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETA (FlagLT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETA (FlagLT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETA (FlagGT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETA (FlagGT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETAE(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETAE (TESTQ x x)) + // result: (ConstBool [true]) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (SETAE (TESTL x x)) + // result: (ConstBool [true]) + for { + if v_0.Op != OpAMD64TESTL { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (SETAE (TESTW x x)) + // result: (ConstBool [true]) + for { + if v_0.Op != OpAMD64TESTW { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (SETAE (TESTB x x)) + // result: (ConstBool [true]) + for { + if v_0.Op != OpAMD64TESTB { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (SETAE (BTLconst [0] x)) + // result: (XORLconst [1] (ANDLconst [1] x)) + for { + if v_0.Op != OpAMD64BTLconst || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + v.reset(OpAMD64XORLconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpAMD64ANDLconst, typ.Bool) + v0.AuxInt = int32ToAuxInt(1) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETAE (BTQconst [0] x)) + // result: (XORLconst [1] (ANDLconst [1] x)) + for { + if v_0.Op != OpAMD64BTQconst || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + v.reset(OpAMD64XORLconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpAMD64ANDLconst, typ.Bool) + v0.AuxInt = int32ToAuxInt(1) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETAE c:(CMPQconst [128] x)) + // cond: c.Uses == 1 + // result: (SETA (CMPQconst [127] x)) + for { + c := v_0 + if c.Op != OpAMD64CMPQconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + x := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64SETA) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETAE c:(CMPLconst [128] x)) + // cond: c.Uses == 1 + // result: (SETA (CMPLconst [127] x)) + for { + c := v_0 + if c.Op != OpAMD64CMPLconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + x := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64SETA) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETAE (InvertFlags x)) + // result: (SETBE x) + for { + if v_0.Op != OpAMD64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETBE) + v.AddArg(x) + return true + } + // match: (SETAE (FlagEQ)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETAE (FlagLT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETAE (FlagLT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETAE (FlagGT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETAE (FlagGT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETAEstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETAEstore [off] {sym} ptr (InvertFlags x) mem) + // result: (SETBEstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64InvertFlags { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64SETBEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (SETAEstore [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SETAEstore [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SETAEstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SETAEstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (SETAEstore [off] {sym} ptr (FlagEQ) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETAEstore [off] {sym} ptr (FlagLT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETAEstore [off] {sym} ptr (FlagLT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETAEstore [off] {sym} ptr (FlagGT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETAEstore [off] {sym} ptr (FlagGT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETAstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETAstore [off] {sym} ptr (InvertFlags x) mem) + // result: (SETBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64InvertFlags { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (SETAstore [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SETAstore [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SETAstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SETAstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SETAstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SETAstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (SETAstore [off] {sym} ptr (FlagEQ) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETAstore [off] {sym} ptr (FlagLT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETAstore [off] {sym} ptr (FlagLT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETAstore [off] {sym} ptr (FlagGT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETAstore [off] {sym} ptr (FlagGT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETB(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (SETB (TESTQ x x)) + // result: (ConstBool [false]) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (SETB (TESTL x x)) + // result: (ConstBool [false]) + for { + if v_0.Op != OpAMD64TESTL { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (SETB (TESTW x x)) + // result: (ConstBool [false]) + for { + if v_0.Op != OpAMD64TESTW { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (SETB (TESTB x x)) + // result: (ConstBool [false]) + for { + if v_0.Op != OpAMD64TESTB { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (SETB (BTLconst [0] x)) + // result: (ANDLconst [1] x) + for { + if v_0.Op != OpAMD64BTLconst || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(x) + return true + } + // match: (SETB (BTQconst [0] x)) + // result: (ANDQconst [1] x) + for { + if v_0.Op != OpAMD64BTQconst || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + v.reset(OpAMD64ANDQconst) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(x) + return true + } + // match: (SETB c:(CMPQconst [128] x)) + // cond: c.Uses == 1 + // result: (SETBE (CMPQconst [127] x)) + for { + c := v_0 + if c.Op != OpAMD64CMPQconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + x := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64SETBE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETB c:(CMPLconst [128] x)) + // cond: c.Uses == 1 + // result: (SETBE (CMPLconst [127] x)) + for { + c := v_0 + if c.Op != OpAMD64CMPLconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + x := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64SETBE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETB (InvertFlags x)) + // result: (SETA x) + for { + if v_0.Op != OpAMD64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETA) + v.AddArg(x) + return true + } + // match: (SETB (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETB (FlagLT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETB (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETB (FlagGT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETB (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETBE(v *Value) bool { + v_0 := v.Args[0] + // match: (SETBE (InvertFlags x)) + // result: (SETAE x) + for { + if v_0.Op != OpAMD64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETAE) + v.AddArg(x) + return true + } + // match: (SETBE (FlagEQ)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETBE (FlagLT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETBE (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETBE (FlagGT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETBE (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETBEstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETBEstore [off] {sym} ptr (InvertFlags x) mem) + // result: (SETAEstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64InvertFlags { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (SETBEstore [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SETBEstore [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SETBEstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SETBEstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SETBEstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SETBEstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (SETBEstore [off] {sym} ptr (FlagEQ) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETBEstore [off] {sym} ptr (FlagLT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETBEstore [off] {sym} ptr (FlagLT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETBEstore [off] {sym} ptr (FlagGT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETBEstore [off] {sym} ptr (FlagGT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETBstore [off] {sym} ptr (InvertFlags x) mem) + // result: (SETAstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64InvertFlags { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64SETAstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (SETBstore [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SETBstore [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SETBstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SETBstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (SETBstore [off] {sym} ptr (FlagEQ) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETBstore [off] {sym} ptr (FlagLT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETBstore [off] {sym} ptr (FlagLT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETBstore [off] {sym} ptr (FlagGT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETBstore [off] {sym} ptr (FlagGT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETEQ(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (SETEQ (TESTL (SHLL (MOVLconst [1]) x) y)) + // result: (SETAE (BTL x y)) + for { + if v_0.Op != OpAMD64TESTL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64SHLL { + continue + } + x := v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_0_0_0.AuxInt) != 1 { + continue + } + y := v_0_1 + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (TESTQ (SHLQ (MOVQconst [1]) x) y)) + // result: (SETAE (BTQ x y)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64SHLQ { + continue + } + x := v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_0_0_0.AuxInt) != 1 { + continue + } + y := v_0_1 + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (TESTLconst [c] x)) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SETAE (BTLconst [int8(log32u(uint32(c)))] x)) + for { + if v_0.Op != OpAMD64TESTLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(isUnsignedPowerOfTwo(uint32(c))) { + break + } + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETEQ (TESTQconst [c] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETAE (BTQconst [int8(log32u(uint32(c)))] x)) + for { + if v_0.Op != OpAMD64TESTQconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(isUnsignedPowerOfTwo(uint64(c))) { + break + } + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETEQ (TESTQ (MOVQconst [c]) x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETAE (BTQconst [int8(log64u(uint64(c)))] x)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + x := v_0_1 + if !(isUnsignedPowerOfTwo(uint64(c))) { + continue + } + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (CMPLconst [1] s:(ANDLconst [1] _))) + // result: (SETNE (CMPLconst [0] s)) + for { + if v_0.Op != OpAMD64CMPLconst || auxIntToInt32(v_0.AuxInt) != 1 { + break + } + s := v_0.Args[0] + if s.Op != OpAMD64ANDLconst || auxIntToInt32(s.AuxInt) != 1 { + break + } + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(s) + v.AddArg(v0) + return true + } + // match: (SETEQ (CMPQconst [1] s:(ANDQconst [1] _))) + // result: (SETNE (CMPQconst [0] s)) + for { + if v_0.Op != OpAMD64CMPQconst || auxIntToInt32(v_0.AuxInt) != 1 { + break + } + s := v_0.Args[0] + if s.Op != OpAMD64ANDQconst || auxIntToInt32(s.AuxInt) != 1 { + break + } + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(s) + v.AddArg(v0) + return true + } + // match: (SETEQ (TESTQ z1:(SHLQconst [63] (SHRQconst [63] x)) z2)) + // cond: z1==z2 + // result: (SETAE (BTQconst [63] x)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHLQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (TESTL z1:(SHLLconst [31] (SHRQconst [31] x)) z2)) + // cond: z1==z2 + // result: (SETAE (BTQconst [31] x)) + for { + if v_0.Op != OpAMD64TESTL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHLLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRQconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (TESTQ z1:(SHRQconst [63] (SHLQconst [63] x)) z2)) + // cond: z1==z2 + // result: (SETAE (BTQconst [0] x)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (TESTL z1:(SHRLconst [31] (SHLLconst [31] x)) z2)) + // cond: z1==z2 + // result: (SETAE (BTLconst [0] x)) + for { + if v_0.Op != OpAMD64TESTL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLLconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (TESTQ z1:(SHRQconst [63] x) z2)) + // cond: z1==z2 + // result: (SETAE (BTQconst [63] x)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + x := z1.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (TESTL z1:(SHRLconst [31] x) z2)) + // cond: z1==z2 + // result: (SETAE (BTLconst [31] x)) + for { + if v_0.Op != OpAMD64TESTL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + x := z1.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAE) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (InvertFlags x)) + // result: (SETEQ x) + for { + if v_0.Op != OpAMD64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETEQ) + v.AddArg(x) + return true + } + // match: (SETEQ (FlagEQ)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETEQ (FlagLT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETEQ (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETEQ (FlagGT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETEQ (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETEQ (TESTQ s:(Select0 blsr:(BLSRQ _)) s)) + // result: (SETEQ (Select1 blsr)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + s := v_0_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRQ || s != v_0_1 { + continue + } + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (TESTL s:(Select0 blsr:(BLSRL _)) s)) + // result: (SETEQ (Select1 blsr)) + for { + if v_0.Op != OpAMD64TESTL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + s := v_0_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRL || s != v_0_1 { + continue + } + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg(v0) + return true + } + break + } + // match: (SETEQ (VPTEST x:(VPAND128 j k) y)) + // cond: x == y && x.Uses == 2 + // result: (SETEQ (VPTEST j k)) + for { + if v_0.Op != OpAMD64VPTEST { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPAND128 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(j, k) + v.AddArg(v0) + return true + } + // match: (SETEQ (VPTEST x:(VPAND256 j k) y)) + // cond: x == y && x.Uses == 2 + // result: (SETEQ (VPTEST j k)) + for { + if v_0.Op != OpAMD64VPTEST { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPAND256 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(j, k) + v.AddArg(v0) + return true + } + // match: (SETEQ (VPTEST x:(VPANDD512 j k) y)) + // cond: x == y && x.Uses == 2 + // result: (SETEQ (VPTEST j k)) + for { + if v_0.Op != OpAMD64VPTEST { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDD512 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(j, k) + v.AddArg(v0) + return true + } + // match: (SETEQ (VPTEST x:(VPANDQ512 j k) y)) + // cond: x == y && x.Uses == 2 + // result: (SETEQ (VPTEST j k)) + for { + if v_0.Op != OpAMD64VPTEST { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDQ512 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(j, k) + v.AddArg(v0) + return true + } + // match: (SETEQ (VPTEST x:(VPANDN128 j k) y)) + // cond: x == y && x.Uses == 2 + // result: (SETB (VPTEST k j)) + for { + if v_0.Op != OpAMD64VPTEST { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDN128 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(k, j) + v.AddArg(v0) + return true + } + // match: (SETEQ (VPTEST x:(VPANDN256 j k) y)) + // cond: x == y && x.Uses == 2 + // result: (SETB (VPTEST k j)) + for { + if v_0.Op != OpAMD64VPTEST { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDN256 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(k, j) + v.AddArg(v0) + return true + } + // match: (SETEQ (VPTEST x:(VPANDND512 j k) y)) + // cond: x == y && x.Uses == 2 + // result: (SETB (VPTEST k j)) + for { + if v_0.Op != OpAMD64VPTEST { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDND512 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(k, j) + v.AddArg(v0) + return true + } + // match: (SETEQ (VPTEST x:(VPANDNQ512 j k) y)) + // cond: x == y && x.Uses == 2 + // result: (SETB (VPTEST k j)) + for { + if v_0.Op != OpAMD64VPTEST { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDNQ512 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(k, j) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETEQstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETEQstore [off] {sym} ptr (TESTL (SHLL (MOVLconst [1]) x) y) mem) + // result: (SETAEstore [off] {sym} ptr (BTL x y) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTL { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpAMD64SHLL { + continue + } + x := v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + if v_1_0_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_1_0_0.AuxInt) != 1 { + continue + } + y := v_1_1 + mem := v_2 + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETEQstore [off] {sym} ptr (TESTQ (SHLQ (MOVQconst [1]) x) y) mem) + // result: (SETAEstore [off] {sym} ptr (BTQ x y) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQ { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpAMD64SHLQ { + continue + } + x := v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + if v_1_0_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_1_0_0.AuxInt) != 1 { + continue + } + y := v_1_1 + mem := v_2 + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETEQstore [off] {sym} ptr (TESTLconst [c] x) mem) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SETAEstore [off] {sym} ptr (BTLconst [int8(log32u(uint32(c)))] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + x := v_1.Args[0] + mem := v_2 + if !(isUnsignedPowerOfTwo(uint32(c))) { + break + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETEQstore [off] {sym} ptr (TESTQconst [c] x) mem) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETAEstore [off] {sym} ptr (BTQconst [int8(log32u(uint32(c)))] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + x := v_1.Args[0] + mem := v_2 + if !(isUnsignedPowerOfTwo(uint64(c))) { + break + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETEQstore [off] {sym} ptr (TESTQ (MOVQconst [c]) x) mem) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETAEstore [off] {sym} ptr (BTQconst [int8(log64u(uint64(c)))] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQ { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + mem := v_2 + if !(isUnsignedPowerOfTwo(uint64(c))) { + continue + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETEQstore [off] {sym} ptr (CMPLconst [1] s:(ANDLconst [1] _)) mem) + // result: (SETNEstore [off] {sym} ptr (CMPLconst [0] s) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64CMPLconst || auxIntToInt32(v_1.AuxInt) != 1 { + break + } + s := v_1.Args[0] + if s.Op != OpAMD64ANDLconst || auxIntToInt32(s.AuxInt) != 1 { + break + } + mem := v_2 + v.reset(OpAMD64SETNEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(s) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETEQstore [off] {sym} ptr (CMPQconst [1] s:(ANDQconst [1] _)) mem) + // result: (SETNEstore [off] {sym} ptr (CMPQconst [0] s) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64CMPQconst || auxIntToInt32(v_1.AuxInt) != 1 { + break + } + s := v_1.Args[0] + if s.Op != OpAMD64ANDQconst || auxIntToInt32(s.AuxInt) != 1 { + break + } + mem := v_2 + v.reset(OpAMD64SETNEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(s) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETEQstore [off] {sym} ptr (TESTQ z1:(SHLQconst [63] (SHRQconst [63] x)) z2) mem) + // cond: z1==z2 + // result: (SETAEstore [off] {sym} ptr (BTQconst [63] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQ { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHLQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETEQstore [off] {sym} ptr (TESTL z1:(SHLLconst [31] (SHRLconst [31] x)) z2) mem) + // cond: z1==z2 + // result: (SETAEstore [off] {sym} ptr (BTLconst [31] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTL { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHLLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRLconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETEQstore [off] {sym} ptr (TESTQ z1:(SHRQconst [63] (SHLQconst [63] x)) z2) mem) + // cond: z1==z2 + // result: (SETAEstore [off] {sym} ptr (BTQconst [0] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQ { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETEQstore [off] {sym} ptr (TESTL z1:(SHRLconst [31] (SHLLconst [31] x)) z2) mem) + // cond: z1==z2 + // result: (SETAEstore [off] {sym} ptr (BTLconst [0] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTL { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLLconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETEQstore [off] {sym} ptr (TESTQ z1:(SHRQconst [63] x) z2) mem) + // cond: z1==z2 + // result: (SETAEstore [off] {sym} ptr (BTQconst [63] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQ { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + x := z1.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETEQstore [off] {sym} ptr (TESTL z1:(SHRLconst [31] x) z2) mem) + // cond: z1==z2 + // result: (SETAEstore [off] {sym} ptr (BTLconst [31] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTL { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + x := z1.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETAEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETEQstore [off] {sym} ptr (InvertFlags x) mem) + // result: (SETEQstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64InvertFlags { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64SETEQstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (SETEQstore [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SETEQstore [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SETEQstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SETEQstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SETEQstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SETEQstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (SETEQstore [off] {sym} ptr (FlagEQ) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETEQstore [off] {sym} ptr (FlagLT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETEQstore [off] {sym} ptr (FlagLT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETEQstore [off] {sym} ptr (FlagGT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETEQstore [off] {sym} ptr (FlagGT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETG(v *Value) bool { + v_0 := v.Args[0] + // match: (SETG (InvertFlags x)) + // result: (SETL x) + for { + if v_0.Op != OpAMD64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETL) + v.AddArg(x) + return true + } + // match: (SETG (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETG (FlagLT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETG (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETG (FlagGT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETG (FlagGT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETGE(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (SETGE c:(CMPQconst [128] x)) + // cond: c.Uses == 1 + // result: (SETG (CMPQconst [127] x)) + for { + c := v_0 + if c.Op != OpAMD64CMPQconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + x := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64SETG) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETGE c:(CMPLconst [128] x)) + // cond: c.Uses == 1 + // result: (SETG (CMPLconst [127] x)) + for { + c := v_0 + if c.Op != OpAMD64CMPLconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + x := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64SETG) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETGE (InvertFlags x)) + // result: (SETLE x) + for { + if v_0.Op != OpAMD64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETLE) + v.AddArg(x) + return true + } + // match: (SETGE (FlagEQ)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETGE (FlagLT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETGE (FlagLT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETGE (FlagGT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETGE (FlagGT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETGEstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETGEstore [off] {sym} ptr (InvertFlags x) mem) + // result: (SETLEstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64InvertFlags { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64SETLEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (SETGEstore [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SETGEstore [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SETGEstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SETGEstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SETGEstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SETGEstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (SETGEstore [off] {sym} ptr (FlagEQ) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETGEstore [off] {sym} ptr (FlagLT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETGEstore [off] {sym} ptr (FlagLT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETGEstore [off] {sym} ptr (FlagGT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETGEstore [off] {sym} ptr (FlagGT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETGstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETGstore [off] {sym} ptr (InvertFlags x) mem) + // result: (SETLstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64InvertFlags { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64SETLstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (SETGstore [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SETGstore [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SETGstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SETGstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SETGstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SETGstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (SETGstore [off] {sym} ptr (FlagEQ) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETGstore [off] {sym} ptr (FlagLT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETGstore [off] {sym} ptr (FlagLT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETGstore [off] {sym} ptr (FlagGT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETGstore [off] {sym} ptr (FlagGT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETL(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (SETL c:(CMPQconst [128] x)) + // cond: c.Uses == 1 + // result: (SETLE (CMPQconst [127] x)) + for { + c := v_0 + if c.Op != OpAMD64CMPQconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + x := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64SETLE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETL c:(CMPLconst [128] x)) + // cond: c.Uses == 1 + // result: (SETLE (CMPLconst [127] x)) + for { + c := v_0 + if c.Op != OpAMD64CMPLconst || auxIntToInt32(c.AuxInt) != 128 { + break + } + x := c.Args[0] + if !(c.Uses == 1) { + break + } + v.reset(OpAMD64SETLE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETL (InvertFlags x)) + // result: (SETG x) + for { + if v_0.Op != OpAMD64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETG) + v.AddArg(x) + return true + } + // match: (SETL (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETL (FlagLT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETL (FlagLT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETL (FlagGT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETL (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETLE(v *Value) bool { + v_0 := v.Args[0] + // match: (SETLE (InvertFlags x)) + // result: (SETGE x) + for { + if v_0.Op != OpAMD64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETGE) + v.AddArg(x) + return true + } + // match: (SETLE (FlagEQ)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETLE (FlagLT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETLE (FlagLT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETLE (FlagGT_ULT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETLE (FlagGT_UGT)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETLEstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETLEstore [off] {sym} ptr (InvertFlags x) mem) + // result: (SETGEstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64InvertFlags { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64SETGEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (SETLEstore [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SETLEstore [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SETLEstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SETLEstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SETLEstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SETLEstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (SETLEstore [off] {sym} ptr (FlagEQ) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETLEstore [off] {sym} ptr (FlagLT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETLEstore [off] {sym} ptr (FlagLT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETLEstore [off] {sym} ptr (FlagGT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETLEstore [off] {sym} ptr (FlagGT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETLstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETLstore [off] {sym} ptr (InvertFlags x) mem) + // result: (SETGstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64InvertFlags { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64SETGstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (SETLstore [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SETLstore [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SETLstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SETLstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SETLstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SETLstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (SETLstore [off] {sym} ptr (FlagEQ) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETLstore [off] {sym} ptr (FlagLT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETLstore [off] {sym} ptr (FlagLT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETLstore [off] {sym} ptr (FlagGT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETLstore [off] {sym} ptr (FlagGT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SETNE(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (SETNE (TESTBconst [1] x)) + // result: (ANDLconst [1] x) + for { + if v_0.Op != OpAMD64TESTBconst || auxIntToInt8(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(x) + return true + } + // match: (SETNE (TESTWconst [1] x)) + // result: (ANDLconst [1] x) + for { + if v_0.Op != OpAMD64TESTWconst || auxIntToInt16(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(x) + return true + } + // match: (SETNE (TESTL (SHLL (MOVLconst [1]) x) y)) + // result: (SETB (BTL x y)) + for { + if v_0.Op != OpAMD64TESTL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64SHLL { + continue + } + x := v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_0_0_0.AuxInt) != 1 { + continue + } + y := v_0_1 + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (SETNE (TESTQ (SHLQ (MOVQconst [1]) x) y)) + // result: (SETB (BTQ x y)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64SHLQ { + continue + } + x := v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_0_0_0.AuxInt) != 1 { + continue + } + y := v_0_1 + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (SETNE (TESTLconst [c] x)) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SETB (BTLconst [int8(log32u(uint32(c)))] x)) + for { + if v_0.Op != OpAMD64TESTLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(isUnsignedPowerOfTwo(uint32(c))) { + break + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETNE (TESTQconst [c] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETB (BTQconst [int8(log32u(uint32(c)))] x)) + for { + if v_0.Op != OpAMD64TESTQconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(isUnsignedPowerOfTwo(uint64(c))) { + break + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SETNE (TESTQ (MOVQconst [c]) x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETB (BTQconst [int8(log64u(uint64(c)))] x)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + x := v_0_1 + if !(isUnsignedPowerOfTwo(uint64(c))) { + continue + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETNE (CMPLconst [1] s:(ANDLconst [1] _))) + // result: (SETEQ (CMPLconst [0] s)) + for { + if v_0.Op != OpAMD64CMPLconst || auxIntToInt32(v_0.AuxInt) != 1 { + break + } + s := v_0.Args[0] + if s.Op != OpAMD64ANDLconst || auxIntToInt32(s.AuxInt) != 1 { + break + } + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(s) + v.AddArg(v0) + return true + } + // match: (SETNE (CMPQconst [1] s:(ANDQconst [1] _))) + // result: (SETEQ (CMPQconst [0] s)) + for { + if v_0.Op != OpAMD64CMPQconst || auxIntToInt32(v_0.AuxInt) != 1 { + break + } + s := v_0.Args[0] + if s.Op != OpAMD64ANDQconst || auxIntToInt32(s.AuxInt) != 1 { + break + } + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(s) + v.AddArg(v0) + return true + } + // match: (SETNE (TESTQ z1:(SHLQconst [63] (SHRQconst [63] x)) z2)) + // cond: z1==z2 + // result: (SETB (BTQconst [63] x)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHLQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETNE (TESTL z1:(SHLLconst [31] (SHRQconst [31] x)) z2)) + // cond: z1==z2 + // result: (SETB (BTQconst [31] x)) + for { + if v_0.Op != OpAMD64TESTL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHLLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRQconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETNE (TESTQ z1:(SHRQconst [63] (SHLQconst [63] x)) z2)) + // cond: z1==z2 + // result: (SETB (BTQconst [0] x)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETNE (TESTL z1:(SHRLconst [31] (SHLLconst [31] x)) z2)) + // cond: z1==z2 + // result: (SETB (BTLconst [0] x)) + for { + if v_0.Op != OpAMD64TESTL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLLconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETNE (TESTQ z1:(SHRQconst [63] x) z2)) + // cond: z1==z2 + // result: (SETB (BTQconst [63] x)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + x := z1.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETNE (TESTL z1:(SHRLconst [31] x) z2)) + // cond: z1==z2 + // result: (SETB (BTLconst [31] x)) + for { + if v_0.Op != OpAMD64TESTL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + x := z1.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (SETNE (InvertFlags x)) + // result: (SETNE x) + for { + if v_0.Op != OpAMD64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETNE) + v.AddArg(x) + return true + } + // match: (SETNE (FlagEQ)) + // result: (MOVLconst [0]) + for { + if v_0.Op != OpAMD64FlagEQ { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SETNE (FlagLT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagLT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETNE (FlagLT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagLT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETNE (FlagGT_ULT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagGT_ULT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETNE (FlagGT_UGT)) + // result: (MOVLconst [1]) + for { + if v_0.Op != OpAMD64FlagGT_UGT { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SETNE (TESTQ s:(Select0 blsr:(BLSRQ _)) s)) + // result: (SETNE (Select1 blsr)) + for { + if v_0.Op != OpAMD64TESTQ { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + s := v_0_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRQ || s != v_0_1 { + continue + } + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg(v0) + return true + } + break + } + // match: (SETNE (TESTL s:(Select0 blsr:(BLSRL _)) s)) + // result: (SETNE (Select1 blsr)) + for { + if v_0.Op != OpAMD64TESTL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + s := v_0_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRL || s != v_0_1 { + continue + } + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + v.AddArg(v0) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64SETNEstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETNEstore [off] {sym} ptr (TESTL (SHLL (MOVLconst [1]) x) y) mem) + // result: (SETBstore [off] {sym} ptr (BTL x y) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTL { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpAMD64SHLL { + continue + } + x := v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + if v_1_0_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_1_0_0.AuxInt) != 1 { + continue + } + y := v_1_1 + mem := v_2 + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETNEstore [off] {sym} ptr (TESTQ (SHLQ (MOVQconst [1]) x) y) mem) + // result: (SETBstore [off] {sym} ptr (BTQ x y) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQ { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpAMD64SHLQ { + continue + } + x := v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + if v_1_0_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_1_0_0.AuxInt) != 1 { + continue + } + y := v_1_1 + mem := v_2 + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETNEstore [off] {sym} ptr (TESTLconst [c] x) mem) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SETBstore [off] {sym} ptr (BTLconst [int8(log32u(uint32(c)))] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + x := v_1.Args[0] + mem := v_2 + if !(isUnsignedPowerOfTwo(uint32(c))) { + break + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETNEstore [off] {sym} ptr (TESTQconst [c] x) mem) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETBstore [off] {sym} ptr (BTQconst [int8(log32u(uint32(c)))] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + x := v_1.Args[0] + mem := v_2 + if !(isUnsignedPowerOfTwo(uint64(c))) { + break + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETNEstore [off] {sym} ptr (TESTQ (MOVQconst [c]) x) mem) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (SETBstore [off] {sym} ptr (BTQconst [int8(log64u(uint64(c)))] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQ { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + mem := v_2 + if !(isUnsignedPowerOfTwo(uint64(c))) { + continue + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETNEstore [off] {sym} ptr (CMPLconst [1] s:(ANDLconst [1] _)) mem) + // result: (SETEQstore [off] {sym} ptr (CMPLconst [0] s) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64CMPLconst || auxIntToInt32(v_1.AuxInt) != 1 { + break + } + s := v_1.Args[0] + if s.Op != OpAMD64ANDLconst || auxIntToInt32(s.AuxInt) != 1 { + break + } + mem := v_2 + v.reset(OpAMD64SETEQstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(s) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETNEstore [off] {sym} ptr (CMPQconst [1] s:(ANDQconst [1] _)) mem) + // result: (SETEQstore [off] {sym} ptr (CMPQconst [0] s) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64CMPQconst || auxIntToInt32(v_1.AuxInt) != 1 { + break + } + s := v_1.Args[0] + if s.Op != OpAMD64ANDQconst || auxIntToInt32(s.AuxInt) != 1 { + break + } + mem := v_2 + v.reset(OpAMD64SETEQstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(s) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETNEstore [off] {sym} ptr (TESTQ z1:(SHLQconst [63] (SHRQconst [63] x)) z2) mem) + // cond: z1==z2 + // result: (SETBstore [off] {sym} ptr (BTQconst [63] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQ { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHLQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETNEstore [off] {sym} ptr (TESTL z1:(SHLLconst [31] (SHRLconst [31] x)) z2) mem) + // cond: z1==z2 + // result: (SETBstore [off] {sym} ptr (BTLconst [31] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTL { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHLLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRLconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETNEstore [off] {sym} ptr (TESTQ z1:(SHRQconst [63] (SHLQconst [63] x)) z2) mem) + // cond: z1==z2 + // result: (SETBstore [off] {sym} ptr (BTQconst [0] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQ { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETNEstore [off] {sym} ptr (TESTL z1:(SHRLconst [31] (SHLLconst [31] x)) z2) mem) + // cond: z1==z2 + // result: (SETBstore [off] {sym} ptr (BTLconst [0] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTL { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLLconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETNEstore [off] {sym} ptr (TESTQ z1:(SHRQconst [63] x) z2) mem) + // cond: z1==z2 + // result: (SETBstore [off] {sym} ptr (BTQconst [63] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTQ { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + x := z1.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETNEstore [off] {sym} ptr (TESTL z1:(SHRLconst [31] x) z2) mem) + // cond: z1==z2 + // result: (SETBstore [off] {sym} ptr (BTLconst [31] x) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64TESTL { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z1 := v_1_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + x := z1.Args[0] + z2 := v_1_1 + mem := v_2 + if !(z1 == z2) { + continue + } + v.reset(OpAMD64SETBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + break + } + // match: (SETNEstore [off] {sym} ptr (InvertFlags x) mem) + // result: (SETNEstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64InvertFlags { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpAMD64SETNEstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (SETNEstore [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SETNEstore [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SETNEstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SETNEstore [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SETNEstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SETNEstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (SETNEstore [off] {sym} ptr (FlagEQ) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [0]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagEQ { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETNEstore [off] {sym} ptr (FlagLT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETNEstore [off] {sym} ptr (FlagLT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagLT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETNEstore [off] {sym} ptr (FlagGT_ULT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_ULT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (SETNEstore [off] {sym} ptr (FlagGT_UGT) mem) + // result: (MOVBstore [off] {sym} ptr (MOVLconst [1]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64FlagGT_UGT { + break + } + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLconst, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SHLL x (MOVQconst [c])) + // result: (SHLLconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64SHLLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SHLL x (MOVLconst [c])) + // result: (SHLLconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64SHLLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SHLL x (ADDQconst [c] y)) + // cond: c & 31 == 0 + // result: (SHLL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + // match: (SHLL x (NEGQ (ADDQconst [c] y))) + // cond: c & 31 == 0 + // result: (SHLL x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SHLL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHLL x (ANDQconst [c] y)) + // cond: c & 31 == 31 + // result: (SHLL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + // match: (SHLL x (NEGQ (ANDQconst [c] y))) + // cond: c & 31 == 31 + // result: (SHLL x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SHLL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHLL x (ADDLconst [c] y)) + // cond: c & 31 == 0 + // result: (SHLL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + // match: (SHLL x (NEGL (ADDLconst [c] y))) + // cond: c & 31 == 0 + // result: (SHLL x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SHLL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHLL x (ANDLconst [c] y)) + // cond: c & 31 == 31 + // result: (SHLL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + // match: (SHLL x (NEGL (ANDLconst [c] y))) + // cond: c & 31 == 31 + // result: (SHLL x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SHLL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHLL l:(MOVLload [off] {sym} ptr mem) x) + // cond: buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l) + // result: (SHLXLload [off] {sym} ptr x mem) + for { + l := v_0 + if l.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64SHLXLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHLLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SHLLconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SHLLconst [1] x) + // result: (ADDL x x) + for { + if auxIntToInt8(v.AuxInt) != 1 { + break + } + x := v_0 + v.reset(OpAMD64ADDL) + v.AddArg2(x, x) + return true + } + // match: (SHLLconst [c] (ADDL x x)) + // result: (SHLLconst [c+1] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64ADDL { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpAMD64SHLLconst) + v.AuxInt = int8ToAuxInt(c + 1) + v.AddArg(x) + return true + } + // match: (SHLLconst [d] (MOVLconst [c])) + // result: (MOVLconst [c << uint64(d)]) + for { + d := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(c << uint64(d)) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHLQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SHLQ x (MOVQconst [c])) + // result: (SHLQconst [int8(c&63)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64SHLQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v.AddArg(x) + return true + } + // match: (SHLQ x (MOVLconst [c])) + // result: (SHLQconst [int8(c&63)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64SHLQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v.AddArg(x) + return true + } + // match: (SHLQ x (ADDQconst [c] y)) + // cond: c & 63 == 0 + // result: (SHLQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SHLQ) + v.AddArg2(x, y) + return true + } + // match: (SHLQ x (NEGQ (ADDQconst [c] y))) + // cond: c & 63 == 0 + // result: (SHLQ x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SHLQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHLQ x (ANDQconst [c] y)) + // cond: c & 63 == 63 + // result: (SHLQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SHLQ) + v.AddArg2(x, y) + return true + } + // match: (SHLQ x (NEGQ (ANDQconst [c] y))) + // cond: c & 63 == 63 + // result: (SHLQ x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SHLQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHLQ x (ADDLconst [c] y)) + // cond: c & 63 == 0 + // result: (SHLQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SHLQ) + v.AddArg2(x, y) + return true + } + // match: (SHLQ x (NEGL (ADDLconst [c] y))) + // cond: c & 63 == 0 + // result: (SHLQ x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SHLQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHLQ x (ANDLconst [c] y)) + // cond: c & 63 == 63 + // result: (SHLQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SHLQ) + v.AddArg2(x, y) + return true + } + // match: (SHLQ x (NEGL (ANDLconst [c] y))) + // cond: c & 63 == 63 + // result: (SHLQ x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SHLQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHLQ l:(MOVQload [off] {sym} ptr mem) x) + // cond: buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l) + // result: (SHLXQload [off] {sym} ptr x mem) + for { + l := v_0 + if l.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64SHLXQload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHLQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SHLQconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SHLQconst [1] x) + // result: (ADDQ x x) + for { + if auxIntToInt8(v.AuxInt) != 1 { + break + } + x := v_0 + v.reset(OpAMD64ADDQ) + v.AddArg2(x, x) + return true + } + // match: (SHLQconst [c] (ADDQ x x)) + // result: (SHLQconst [c+1] x) + for { + c := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64ADDQ { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpAMD64SHLQconst) + v.AuxInt = int8ToAuxInt(c + 1) + v.AddArg(x) + return true + } + // match: (SHLQconst [d] (MOVQconst [c])) + // result: (MOVQconst [c << uint64(d)]) + for { + d := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(c << uint64(d)) + return true + } + // match: (SHLQconst [d] (MOVLconst [c])) + // result: (MOVQconst [int64(c) << uint64(d)]) + for { + d := auxIntToInt8(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(c) << uint64(d)) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHLXLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SHLXLload [off] {sym} ptr (MOVLconst [c]) mem) + // result: (SHLLconst [int8(c&31)] (MOVLload [off] {sym} ptr mem)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64SHLLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHLXQload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SHLXQload [off] {sym} ptr (MOVQconst [c]) mem) + // result: (SHLQconst [int8(c&63)] (MOVQload [off] {sym} ptr mem)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64SHLQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + // match: (SHLXQload [off] {sym} ptr (MOVLconst [c]) mem) + // result: (SHLQconst [int8(c&63)] (MOVQload [off] {sym} ptr mem)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64SHLQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHRB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SHRB x (MOVQconst [c])) + // cond: c&31 < 8 + // result: (SHRBconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&31 < 8) { + break + } + v.reset(OpAMD64SHRBconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SHRB x (MOVLconst [c])) + // cond: c&31 < 8 + // result: (SHRBconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c&31 < 8) { + break + } + v.reset(OpAMD64SHRBconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SHRB _ (MOVQconst [c])) + // cond: c&31 >= 8 + // result: (MOVLconst [0]) + for { + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&31 >= 8) { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SHRB _ (MOVLconst [c])) + // cond: c&31 >= 8 + // result: (MOVLconst [0]) + for { + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c&31 >= 8) { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHRBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SHRBconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SHRL x (MOVQconst [c])) + // result: (SHRLconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64SHRLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SHRL x (MOVLconst [c])) + // result: (SHRLconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64SHRLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SHRL x (ADDQconst [c] y)) + // cond: c & 31 == 0 + // result: (SHRL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SHRL) + v.AddArg2(x, y) + return true + } + // match: (SHRL x (NEGQ (ADDQconst [c] y))) + // cond: c & 31 == 0 + // result: (SHRL x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SHRL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHRL x (ANDQconst [c] y)) + // cond: c & 31 == 31 + // result: (SHRL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SHRL) + v.AddArg2(x, y) + return true + } + // match: (SHRL x (NEGQ (ANDQconst [c] y))) + // cond: c & 31 == 31 + // result: (SHRL x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SHRL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHRL x (ADDLconst [c] y)) + // cond: c & 31 == 0 + // result: (SHRL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SHRL) + v.AddArg2(x, y) + return true + } + // match: (SHRL x (NEGL (ADDLconst [c] y))) + // cond: c & 31 == 0 + // result: (SHRL x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 0) { + break + } + v.reset(OpAMD64SHRL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHRL x (ANDLconst [c] y)) + // cond: c & 31 == 31 + // result: (SHRL x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SHRL) + v.AddArg2(x, y) + return true + } + // match: (SHRL x (NEGL (ANDLconst [c] y))) + // cond: c & 31 == 31 + // result: (SHRL x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&31 == 31) { + break + } + v.reset(OpAMD64SHRL) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHRL l:(MOVLload [off] {sym} ptr mem) x) + // cond: buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l) + // result: (SHRXLload [off] {sym} ptr x mem) + for { + l := v_0 + if l.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64SHRXLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHRLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SHRLconst [1] (ADDL x x)) + // result: (ANDLconst [0x7fffffff] x) + for { + if auxIntToInt8(v.AuxInt) != 1 || v_0.Op != OpAMD64ADDL { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpAMD64ANDLconst) + v.AuxInt = int32ToAuxInt(0x7fffffff) + v.AddArg(x) + return true + } + // match: (SHRLconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHRQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SHRQ x (MOVQconst [c])) + // result: (SHRQconst [int8(c&63)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64SHRQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v.AddArg(x) + return true + } + // match: (SHRQ x (MOVLconst [c])) + // result: (SHRQconst [int8(c&63)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64SHRQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v.AddArg(x) + return true + } + // match: (SHRQ x (ADDQconst [c] y)) + // cond: c & 63 == 0 + // result: (SHRQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SHRQ) + v.AddArg2(x, y) + return true + } + // match: (SHRQ x (NEGQ (ADDQconst [c] y))) + // cond: c & 63 == 0 + // result: (SHRQ x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SHRQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHRQ x (ANDQconst [c] y)) + // cond: c & 63 == 63 + // result: (SHRQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SHRQ) + v.AddArg2(x, y) + return true + } + // match: (SHRQ x (NEGQ (ANDQconst [c] y))) + // cond: c & 63 == 63 + // result: (SHRQ x (NEGQ y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGQ { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDQconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SHRQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHRQ x (ADDLconst [c] y)) + // cond: c & 63 == 0 + // result: (SHRQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SHRQ) + v.AddArg2(x, y) + return true + } + // match: (SHRQ x (NEGL (ADDLconst [c] y))) + // cond: c & 63 == 0 + // result: (SHRQ x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ADDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 0) { + break + } + v.reset(OpAMD64SHRQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHRQ x (ANDLconst [c] y)) + // cond: c & 63 == 63 + // result: (SHRQ x y) + for { + x := v_0 + if v_1.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SHRQ) + v.AddArg2(x, y) + return true + } + // match: (SHRQ x (NEGL (ANDLconst [c] y))) + // cond: c & 63 == 63 + // result: (SHRQ x (NEGL y)) + for { + x := v_0 + if v_1.Op != OpAMD64NEGL { + break + } + t := v_1.Type + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64ANDLconst { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + y := v_1_0.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpAMD64SHRQ) + v0 := b.NewValue0(v.Pos, OpAMD64NEGL, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SHRQ l:(MOVQload [off] {sym} ptr mem) x) + // cond: buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l) + // result: (SHRXQload [off] {sym} ptr x mem) + for { + l := v_0 + if l.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + x := v_1 + if !(buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64SHRXQload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHRQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SHRQconst [1] (ADDQ x x)) + // result: (BTRQconst [63] x) + for { + if auxIntToInt8(v.AuxInt) != 1 || v_0.Op != OpAMD64ADDQ { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + v.reset(OpAMD64BTRQconst) + v.AuxInt = int8ToAuxInt(63) + v.AddArg(x) + return true + } + // match: (SHRQconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHRW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SHRW x (MOVQconst [c])) + // cond: c&31 < 16 + // result: (SHRWconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&31 < 16) { + break + } + v.reset(OpAMD64SHRWconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SHRW x (MOVLconst [c])) + // cond: c&31 < 16 + // result: (SHRWconst [int8(c&31)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c&31 < 16) { + break + } + v.reset(OpAMD64SHRWconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v.AddArg(x) + return true + } + // match: (SHRW _ (MOVQconst [c])) + // cond: c&31 >= 16 + // result: (MOVLconst [0]) + for { + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&31 >= 16) { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SHRW _ (MOVLconst [c])) + // cond: c&31 >= 16 + // result: (MOVLconst [0]) + for { + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c&31 >= 16) { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHRWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SHRWconst x [0]) + // result: x + for { + if auxIntToInt8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHRXLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SHRXLload [off] {sym} ptr (MOVLconst [c]) mem) + // result: (SHRLconst [int8(c&31)] (MOVLload [off] {sym} ptr mem)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64SHRLconst) + v.AuxInt = int8ToAuxInt(int8(c & 31)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SHRXQload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SHRXQload [off] {sym} ptr (MOVQconst [c]) mem) + // result: (SHRQconst [int8(c&63)] (MOVQload [off] {sym} ptr mem)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64SHRQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + // match: (SHRXQload [off] {sym} ptr (MOVLconst [c]) mem) + // result: (SHRQconst [int8(c&63)] (MOVQload [off] {sym} ptr mem)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpAMD64SHRQconst) + v.AuxInt = int8ToAuxInt(int8(c & 63)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBL x (MOVLconst [c])) + // result: (SUBLconst x [c]) + for { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64SUBLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SUBL (MOVLconst [c]) x) + // result: (NEGL (SUBLconst x [c])) + for { + if v_0.Op != OpAMD64MOVLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpAMD64NEGL) + v0 := b.NewValue0(v.Pos, OpAMD64SUBLconst, v.Type) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUBL x x) + // result: (MOVLconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SUBL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (SUBLload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(OpAMD64SUBLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBLconst [c] x) + // cond: c==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c == 0) { + break + } + v.copyOf(x) + return true + } + // match: (SUBLconst [c] x) + // result: (ADDLconst [-c] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + v.reset(OpAMD64ADDLconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpAMD64SUBLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SUBLload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SUBLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SUBLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBLload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SUBLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SUBLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBLload x [off] {sym} ptr (MOVSSstore [off] {sym} ptr y _)) + // result: (SUBL x (MOVLf2i y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVSSstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64SUBL) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVLf2i, typ.UInt32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBLmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBLmodify [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SUBLmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SUBLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SUBLmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SUBLmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SUBLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBQ x (MOVQconst [c])) + // cond: is32Bit(c) + // result: (SUBQconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + break + } + v.reset(OpAMD64SUBQconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (SUBQ (MOVQconst [c]) x) + // cond: is32Bit(c) + // result: (NEGQ (SUBQconst x [int32(c)])) + for { + if v_0.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(c)) { + break + } + v.reset(OpAMD64NEGQ) + v0 := b.NewValue0(v.Pos, OpAMD64SUBQconst, v.Type) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUBQ x x) + // result: (MOVQconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SUBQ x l:(MOVQload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (SUBQload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(OpAMD64SUBQload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBQborrow(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBQborrow x (MOVQconst [c])) + // cond: is32Bit(c) + // result: (SUBQconstborrow x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + break + } + v.reset(OpAMD64SUBQconstborrow) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBQconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SUBQconst [c] x) + // cond: c != -(1<<31) + // result: (ADDQconst [-c] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c != -(1 << 31)) { + break + } + v.reset(OpAMD64ADDQconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } + // match: (SUBQconst (MOVQconst [d]) [c]) + // result: (MOVQconst [d-int64(c)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(d - int64(c)) + return true + } + // match: (SUBQconst (SUBQconst x [d]) [c]) + // cond: is32Bit(int64(-c)-int64(d)) + // result: (ADDQconst [-c-d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64SUBQconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(int64(-c) - int64(d))) { + break + } + v.reset(OpAMD64ADDQconst) + v.AuxInt = int32ToAuxInt(-c - d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBQload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SUBQload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SUBQload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SUBQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBQload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SUBQload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SUBQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBQload x [off] {sym} ptr (MOVSDstore [off] {sym} ptr y _)) + // result: (SUBQ x (MOVQf2i y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVSDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64SUBQ) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVQf2i, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBQmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBQmodify [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SUBQmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SUBQmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (SUBQmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SUBQmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SUBQmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBSD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBSD x l:(MOVSDload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (SUBSDload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVSDload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(OpAMD64SUBSDload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBSDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SUBSDload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SUBSDload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SUBSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBSDload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SUBSDload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SUBSDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBSDload x [off] {sym} ptr (MOVQstore [off] {sym} ptr y _)) + // result: (SUBSD x (MOVQi2f y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVQstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64SUBSD) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVQi2f, typ.Float64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBSS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBSS x l:(MOVSSload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (SUBSSload x [off] {sym} ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVSSload { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + break + } + v.reset(OpAMD64SUBSSload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64SUBSSload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SUBSSload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (SUBSSload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64SUBSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBSSload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (SUBSSload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64SUBSSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (SUBSSload x [off] {sym} ptr (MOVLstore [off] {sym} ptr y _)) + // result: (SUBSS x (MOVLi2f y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVLstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64SUBSS) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVLi2f, typ.Float32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64TESTB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TESTB (MOVLconst [c]) x) + // result: (TESTBconst [int8(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64MOVLconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpAMD64TESTBconst) + v.AuxInt = int8ToAuxInt(int8(c)) + v.AddArg(x) + return true + } + break + } + // match: (TESTB l:(MOVBload {sym} [off] ptr mem) l2) + // cond: l == l2 && l.Uses == 2 && clobber(l) + // result: @l.Block (CMPBconstload {sym} [makeValAndOff(0, off)] ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + l := v_0 + if l.Op != OpAMD64MOVBload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + l2 := v_1 + if !(l == l2 && l.Uses == 2 && clobber(l)) { + continue + } + b = l.Block + v0 := b.NewValue0(l.Pos, OpAMD64CMPBconstload, types.TypeFlags) + v.copyOf(v0) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, off)) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64TESTBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (TESTBconst [-1] x) + // cond: x.Op != OpAMD64MOVLconst + // result: (TESTB x x) + for { + if auxIntToInt8(v.AuxInt) != -1 { + break + } + x := v_0 + if !(x.Op != OpAMD64MOVLconst) { + break + } + v.reset(OpAMD64TESTB) + v.AddArg2(x, x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64TESTL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TESTL (MOVLconst [c]) x) + // result: (TESTLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64MOVLconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpAMD64TESTLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (TESTL l:(MOVLload {sym} [off] ptr mem) l2) + // cond: l == l2 && l.Uses == 2 && clobber(l) + // result: @l.Block (CMPLconstload {sym} [makeValAndOff(0, off)] ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + l := v_0 + if l.Op != OpAMD64MOVLload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + l2 := v_1 + if !(l == l2 && l.Uses == 2 && clobber(l)) { + continue + } + b = l.Block + v0 := b.NewValue0(l.Pos, OpAMD64CMPLconstload, types.TypeFlags) + v.copyOf(v0) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, off)) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + break + } + // match: (TESTL a:(ANDLload [off] {sym} x ptr mem) a) + // cond: a.Uses == 2 && a.Block == v.Block && clobber(a) + // result: (TESTL (MOVLload [off] {sym} ptr mem) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if a.Op != OpAMD64ANDLload { + continue + } + off := auxIntToInt32(a.AuxInt) + sym := auxToSym(a.Aux) + mem := a.Args[2] + x := a.Args[0] + ptr := a.Args[1] + if a != v_1 || !(a.Uses == 2 && a.Block == v.Block && clobber(a)) { + continue + } + v.reset(OpAMD64TESTL) + v0 := b.NewValue0(a.Pos, OpAMD64MOVLload, a.Type) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg2(v0, x) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64TESTLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (TESTLconst [c] (MOVLconst [c])) + // cond: c == 0 + // result: (FlagEQ) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_0.AuxInt) != c || !(c == 0) { + break + } + v.reset(OpAMD64FlagEQ) + return true + } + // match: (TESTLconst [c] (MOVLconst [c])) + // cond: c < 0 + // result: (FlagLT_UGT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_0.AuxInt) != c || !(c < 0) { + break + } + v.reset(OpAMD64FlagLT_UGT) + return true + } + // match: (TESTLconst [c] (MOVLconst [c])) + // cond: c > 0 + // result: (FlagGT_UGT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_0.AuxInt) != c || !(c > 0) { + break + } + v.reset(OpAMD64FlagGT_UGT) + return true + } + // match: (TESTLconst [-1] x) + // cond: x.Op != OpAMD64MOVLconst + // result: (TESTL x x) + for { + if auxIntToInt32(v.AuxInt) != -1 { + break + } + x := v_0 + if !(x.Op != OpAMD64MOVLconst) { + break + } + v.reset(OpAMD64TESTL) + v.AddArg2(x, x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64TESTQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TESTQ (MOVQconst [c]) x) + // cond: is32Bit(c) + // result: (TESTQconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(c)) { + continue + } + v.reset(OpAMD64TESTQconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (TESTQ l:(MOVQload {sym} [off] ptr mem) l2) + // cond: l == l2 && l.Uses == 2 && clobber(l) + // result: @l.Block (CMPQconstload {sym} [makeValAndOff(0, off)] ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + l := v_0 + if l.Op != OpAMD64MOVQload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + l2 := v_1 + if !(l == l2 && l.Uses == 2 && clobber(l)) { + continue + } + b = l.Block + v0 := b.NewValue0(l.Pos, OpAMD64CMPQconstload, types.TypeFlags) + v.copyOf(v0) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, off)) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + break + } + // match: (TESTQ a:(ANDQload [off] {sym} x ptr mem) a) + // cond: a.Uses == 2 && a.Block == v.Block && clobber(a) + // result: (TESTQ (MOVQload [off] {sym} ptr mem) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if a.Op != OpAMD64ANDQload { + continue + } + off := auxIntToInt32(a.AuxInt) + sym := auxToSym(a.Aux) + mem := a.Args[2] + x := a.Args[0] + ptr := a.Args[1] + if a != v_1 || !(a.Uses == 2 && a.Block == v.Block && clobber(a)) { + continue + } + v.reset(OpAMD64TESTQ) + v0 := b.NewValue0(a.Pos, OpAMD64MOVQload, a.Type) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg2(v0, x) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64TESTQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (TESTQconst [c] (MOVQconst [d])) + // cond: int64(c) == d && c == 0 + // result: (FlagEQ) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(int64(c) == d && c == 0) { + break + } + v.reset(OpAMD64FlagEQ) + return true + } + // match: (TESTQconst [c] (MOVQconst [d])) + // cond: int64(c) == d && c < 0 + // result: (FlagLT_UGT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(int64(c) == d && c < 0) { + break + } + v.reset(OpAMD64FlagLT_UGT) + return true + } + // match: (TESTQconst [c] (MOVQconst [d])) + // cond: int64(c) == d && c > 0 + // result: (FlagGT_UGT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(int64(c) == d && c > 0) { + break + } + v.reset(OpAMD64FlagGT_UGT) + return true + } + // match: (TESTQconst [-1] x) + // cond: x.Op != OpAMD64MOVQconst + // result: (TESTQ x x) + for { + if auxIntToInt32(v.AuxInt) != -1 { + break + } + x := v_0 + if !(x.Op != OpAMD64MOVQconst) { + break + } + v.reset(OpAMD64TESTQ) + v.AddArg2(x, x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64TESTW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TESTW (MOVLconst [c]) x) + // result: (TESTWconst [int16(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64MOVLconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpAMD64TESTWconst) + v.AuxInt = int16ToAuxInt(int16(c)) + v.AddArg(x) + return true + } + break + } + // match: (TESTW l:(MOVWload {sym} [off] ptr mem) l2) + // cond: l == l2 && l.Uses == 2 && clobber(l) + // result: @l.Block (CMPWconstload {sym} [makeValAndOff(0, off)] ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + l := v_0 + if l.Op != OpAMD64MOVWload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + l2 := v_1 + if !(l == l2 && l.Uses == 2 && clobber(l)) { + continue + } + b = l.Block + v0 := b.NewValue0(l.Pos, OpAMD64CMPWconstload, types.TypeFlags) + v.copyOf(v0) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, off)) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64TESTWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (TESTWconst [-1] x) + // cond: x.Op != OpAMD64MOVLconst + // result: (TESTW x x) + for { + if auxIntToInt16(v.AuxInt) != -1 { + break + } + x := v_0 + if !(x.Op != OpAMD64MOVLconst) { + break + } + v.reset(OpAMD64TESTW) + v.AddArg2(x, x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VADDPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VADDPD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VADDPD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VADDPD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VADDPDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VADDPDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VADDPDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VADDPDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VADDPDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VADDPDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VADDPDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VADDPDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VADDPDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VADDPDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VADDPDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VADDPDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VADDPS512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VADDPS512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VADDPS512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VADDPS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VADDPSMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VADDPSMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VADDPSMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VADDPSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VADDPSMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VADDPSMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VADDPSMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VADDPSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VADDPSMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VADDPSMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VADDPSMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VADDPSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VCMPPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCMPPD512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCMPPD512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCMPPD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCMPPDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCMPPDMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCMPPDMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCMPPDMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCMPPDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCMPPDMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCMPPDMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCMPPDMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCMPPDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCMPPDMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCMPPDMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCMPPDMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCMPPS512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCMPPS512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCMPPS512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCMPPS512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCMPPSMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCMPPSMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCMPPSMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCMPPSMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCMPPSMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCMPPSMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCMPPSMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCMPPSMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCMPPSMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCMPPSMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCMPPSMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCMPPSMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTDQ2PD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTDQ2PD512 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTDQ2PD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTDQ2PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTDQ2PDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTDQ2PDMasked256 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTDQ2PDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTDQ2PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTDQ2PDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTDQ2PDMasked512 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTDQ2PDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTDQ2PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTDQ2PS512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTDQ2PS512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTDQ2PS512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTDQ2PS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTDQ2PSMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTDQ2PSMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTDQ2PSMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTDQ2PSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTDQ2PSMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTDQ2PSMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTDQ2PSMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTDQ2PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTDQ2PSMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTDQ2PSMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTDQ2PSMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTDQ2PSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTPD2PS256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTPD2PS256 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTPD2PS256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTPD2PS256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTPD2PSMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTPD2PSMasked256 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTPD2PSMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTPD2PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTPD2PSXMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTPD2PSXMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTPD2PSXMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTPD2PSXMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTPD2PSYMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTPD2PSYMasked128 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTPD2PSYMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTPD2PSYMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTPS2PD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTPS2PD512 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTPS2PD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTPS2PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTPS2PDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTPS2PDMasked256 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTPS2PDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTPS2PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTPS2PDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTPS2PDMasked512 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTPS2PDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTPS2PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PD128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTQQ2PD128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PD128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTQQ2PD256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PD256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTQQ2PD512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTQQ2PDMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PDMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTQQ2PDMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTQQ2PDMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PS256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTQQ2PS256 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PS256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PS256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PSMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTQQ2PSMasked256 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PSMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PSX128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTQQ2PSX128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PSX128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PSX128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PSXMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTQQ2PSXMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PSXMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PSXMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PSY128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTQQ2PSY128 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PSY128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PSY128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTQQ2PSYMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTQQ2PSYMasked128 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTQQ2PSYMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTQQ2PSYMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2DQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPD2DQ256 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2DQ256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2DQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2DQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2DQMasked256 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2DQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2DQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2DQXMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2DQXMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2DQXMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2DQXMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2DQYMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2DQYMasked128 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2DQYMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2DQYMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2QQ128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPD2QQ128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2QQ128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2QQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2QQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPD2QQ256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2QQ256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2QQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2QQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPD2QQ512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2QQ512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2QQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2QQMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2QQMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2QQMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2QQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2QQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2QQMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2QQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2QQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2QQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2QQMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2QQMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2QQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UDQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPD2UDQ256 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UDQ256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UDQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UDQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2UDQMasked256 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UDQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UDQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UDQX128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPD2UDQX128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UDQX128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UDQX128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UDQXMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2UDQXMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UDQXMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UDQXMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UDQY128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPD2UDQY128 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UDQY128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UDQY128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UDQYMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2UDQYMasked128 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UDQYMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UDQYMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UQQ128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPD2UQQ128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UQQ128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UQQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UQQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPD2UQQ256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UQQ256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UQQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UQQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPD2UQQ512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UQQ512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UQQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UQQMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2UQQMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UQQMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UQQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UQQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2UQQMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UQQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UQQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPD2UQQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPD2UQQMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPD2UQQMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPD2UQQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2DQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPS2DQ512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2DQ512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2DQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2DQMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPS2DQMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2DQMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2DQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2DQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPS2DQMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2DQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2DQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2DQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPS2DQMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2DQMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2DQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2QQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPS2QQ256 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2QQ256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2QQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2QQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPS2QQ512 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2QQ512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2QQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2QQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPS2QQMasked256 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2QQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2QQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2QQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPS2QQMasked512 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2QQMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2QQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2UDQ128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPS2UDQ128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2UDQ128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2UDQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2UDQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPS2UDQ256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2UDQ256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2UDQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2UDQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPS2UDQ512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2UDQ512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2UDQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2UDQMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPS2UDQMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2UDQMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2UDQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2UDQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPS2UDQMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2UDQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2UDQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2UDQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPS2UDQMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2UDQMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2UDQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2UQQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPS2UQQ256 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2UQQ256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2UQQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2UQQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTTPS2UQQ512 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2UQQ512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2UQQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2UQQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPS2UQQMasked256 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2UQQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2UQQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTTPS2UQQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTTPS2UQQMasked512 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTTPS2UQQMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTTPS2UQQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUDQ2PD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUDQ2PD256 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUDQ2PD256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUDQ2PD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUDQ2PD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUDQ2PD512 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUDQ2PD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUDQ2PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUDQ2PDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUDQ2PDMasked256 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUDQ2PDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUDQ2PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUDQ2PDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUDQ2PDMasked512 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUDQ2PDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUDQ2PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUDQ2PS128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUDQ2PS128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUDQ2PS128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUDQ2PS128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUDQ2PS256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUDQ2PS256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUDQ2PS256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUDQ2PS256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUDQ2PS512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUDQ2PS512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUDQ2PS512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUDQ2PS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUDQ2PSMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUDQ2PSMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUDQ2PSMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUDQ2PSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUDQ2PSMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUDQ2PSMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUDQ2PSMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUDQ2PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUDQ2PSMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUDQ2PSMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUDQ2PSMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUDQ2PSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PD128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUQQ2PD128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PD128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUQQ2PD256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PD256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUQQ2PD512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUQQ2PDMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PDMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUQQ2PDMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUQQ2PDMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PS256(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUQQ2PS256 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PS256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PS256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PSMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUQQ2PSMasked256 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PSMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PSX128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUQQ2PSX128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PSX128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PSX128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PSXMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUQQ2PSXMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PSXMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PSXMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PSY128(v *Value) bool { + v_0 := v.Args[0] + // match: (VCVTUQQ2PSY128 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PSY128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PSY128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VCVTUQQ2PSYMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VCVTUQQ2PSYMasked128 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VCVTUQQ2PSYMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VCVTUQQ2PSYMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VDIVPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VDIVPD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VDIVPD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VDIVPD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VDIVPDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VDIVPDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VDIVPDMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VDIVPDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VDIVPDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VDIVPDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VDIVPDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VDIVPDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VDIVPDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VDIVPDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VDIVPDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VDIVPDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VDIVPS512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VDIVPS512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VDIVPS512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VDIVPS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VDIVPSMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VDIVPSMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VDIVPSMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VDIVPSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VDIVPSMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VDIVPSMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VDIVPSMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VDIVPSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VDIVPSMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VDIVPSMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VDIVPSMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VDIVPSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADD213PD512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADD213PD512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADD213PD512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADD213PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADD213PDMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADD213PDMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADD213PDMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADD213PDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADD213PDMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADD213PDMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADD213PDMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADD213PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADD213PDMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADD213PDMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADD213PDMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADD213PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADD213PS512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADD213PS512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADD213PS512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADD213PS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADD213PSMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADD213PSMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADD213PSMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADD213PSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADD213PSMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADD213PSMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADD213PSMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADD213PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADD213PSMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADD213PSMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADD213PSMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADD213PSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADDSUB213PD512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADDSUB213PD512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADDSUB213PD512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADDSUB213PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADDSUB213PDMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADDSUB213PDMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADDSUB213PDMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADDSUB213PDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADDSUB213PDMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADDSUB213PDMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADDSUB213PDMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADDSUB213PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADDSUB213PDMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADDSUB213PDMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADDSUB213PDMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADDSUB213PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADDSUB213PS512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADDSUB213PS512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADDSUB213PS512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADDSUB213PS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADDSUB213PSMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADDSUB213PSMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADDSUB213PSMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADDSUB213PSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADDSUB213PSMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADDSUB213PSMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADDSUB213PSMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADDSUB213PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMADDSUB213PSMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMADDSUB213PSMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMADDSUB213PSMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMADDSUB213PSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMSUBADD213PD512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMSUBADD213PD512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMSUBADD213PD512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMSUBADD213PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMSUBADD213PDMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMSUBADD213PDMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMSUBADD213PDMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMSUBADD213PDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMSUBADD213PDMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMSUBADD213PDMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMSUBADD213PDMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMSUBADD213PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMSUBADD213PDMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMSUBADD213PDMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMSUBADD213PDMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMSUBADD213PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMSUBADD213PS512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMSUBADD213PS512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMSUBADD213PS512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMSUBADD213PS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMSUBADD213PSMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMSUBADD213PSMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMSUBADD213PSMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMSUBADD213PSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMSUBADD213PSMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMSUBADD213PSMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMSUBADD213PSMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMSUBADD213PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VFMSUBADD213PSMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VFMSUBADD213PSMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VFMSUBADD213PSMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VFMSUBADD213PSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQB128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEINVQB128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEINVQB128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEINVQB128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQB256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEINVQB256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEINVQB256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEINVQB256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQB512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEINVQB512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEINVQB512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEINVQB512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQBMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEINVQBMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEINVQBMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEINVQBMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQBMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEINVQBMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEINVQBMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEINVQBMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEINVQBMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEINVQBMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEINVQBMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEINVQBMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEQB128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEQB128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEQB128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEQB128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEQB256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEQB256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEQB256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEQB256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEQB512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEQB512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEQB512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEQB512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEQBMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEQBMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEQBMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEQBMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEQBMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEQBMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEQBMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEQBMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VGF2P8AFFINEQBMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VGF2P8AFFINEQBMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VGF2P8AFFINEQBMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VGF2P8AFFINEQBMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMAXPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMAXPD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMAXPD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMAXPD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMAXPDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMAXPDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMAXPDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMAXPDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMAXPDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMAXPDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMAXPDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMAXPDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMAXPDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMAXPDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMAXPDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMAXPDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMAXPS512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMAXPS512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMAXPS512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMAXPS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMAXPSMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMAXPSMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMAXPSMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMAXPSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMAXPSMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMAXPSMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMAXPSMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMAXPSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMAXPSMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMAXPSMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMAXPSMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMAXPSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMINPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMINPD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMINPD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMINPD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMINPDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMINPDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMINPDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMINPDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMINPDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMINPDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMINPDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMINPDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMINPDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMINPDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMINPDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMINPDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMINPS512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMINPS512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMINPS512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMINPS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMINPSMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMINPSMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMINPSMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMINPSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMINPSMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMINPSMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMINPSMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMINPSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMINPSMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMINPSMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMINPSMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMINPSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVD(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (VMOVD x:(MOVLload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (VMOVDload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVLload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64VMOVDload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU16Masked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU16Masked128 (VPABSW128 x) mask) + // result: (VPABSWMasked128 x mask) + for { + if v_0.Op != OpAMD64VPABSW128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSWMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPADDW128 x y) mask) + // result: (VPADDWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPADDW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPADDSW128 x y) mask) + // result: (VPADDSWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPADDSW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDSWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPADDUSW128 x y) mask) + // result: (VPADDUSWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPADDUSW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDUSWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPAVGW128 x y) mask) + // result: (VPAVGWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPAVGW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPAVGWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPBROADCASTW128 x) mask) + // result: (VPBROADCASTWMasked128 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTW128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTWMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPERMI2W128 x y z) mask) + // result: (VPERMI2WMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2W128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2WMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMADDWD128 x y) mask) + // result: (VPMADDWDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMADDWD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMADDWDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMADDUBSW128 x y) mask) + // result: (VPMADDUBSWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMADDUBSW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMADDUBSWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMOVSXWQ128 x) mask) + // result: (VPMOVSXWQMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXWQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXWQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMOVZXWQ128 x) mask) + // result: (VPMOVZXWQMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXWQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXWQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMOVSXWD128 x) mask) + // result: (VPMOVSXWDMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXWD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXWDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMOVZXWD128 x) mask) + // result: (VPMOVZXWDMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXWD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXWDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMAXSW128 x y) mask) + // result: (VPMAXSWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMAXUW128 x y) mask) + // result: (VPMAXUWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMINSW128 x y) mask) + // result: (VPMINSWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMINSW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMINUW128 x y) mask) + // result: (VPMINUWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMINUW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMULHW128 x y) mask) + // result: (VPMULHWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMULHW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULHWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMULHUW128 x y) mask) + // result: (VPMULHUWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMULHUW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULHUWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMULLW128 x y) mask) + // result: (VPMULLWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMULLW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULLWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPOPCNTW128 x) mask) + // result: (VPOPCNTWMasked128 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTW128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTWMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPERMW128 x y) mask) + // result: (VPERMWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPERMW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMOVSWB128_128 x) mask) + // result: (VPMOVSWBMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSWB128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSWBMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMOVUSWB128_128 x) mask) + // result: (VPMOVUSWBMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSWB128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSWBMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSHLDW128 [a] x y) mask) + // result: (VPSHLDWMasked128 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHLDW128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHLDWMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSLLW128 x y) mask) + // result: (VPSLLWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSLLW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSHRDW128 [a] x y) mask) + // result: (VPSHRDWMasked128 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHRDW128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHRDWMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSRAW128 x y) mask) + // result: (VPSRAWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRAW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSRLW128 x y) mask) + // result: (VPSRLWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRLW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSHLDVW128 x y z) mask) + // result: (VPSHLDVWMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPSHLDVW128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHLDVWMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSLLVW128 x y) mask) + // result: (VPSLLVWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSLLVW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLVWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSHRDVW128 x y z) mask) + // result: (VPSHRDVWMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPSHRDVW128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHRDVWMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSRAVW128 x y) mask) + // result: (VPSRAVWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRAVW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAVWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSRLVW128 x y) mask) + // result: (VPSRLVWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRLVW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLVWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSUBW128 x y) mask) + // result: (VPSUBWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSUBW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSUBSW128 x y) mask) + // result: (VPSUBSWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSUBSW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBSWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSUBUSW128 x y) mask) + // result: (VPSUBUSWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSUBUSW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBUSWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPMOVWB128_128 x) mask) + // result: (VPMOVWBMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVWB128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVWBMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSHUFHW128 [a] x) mask) + // result: (VPSHUFHWMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VPSHUFHW128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFHWMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSHUFLW128 [a] x) mask) + // result: (VPSHUFLWMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VPSHUFLW128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFLWMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSLLW128const [a] x) mask) + // result: (VPSLLWMasked128const [a] x mask) + for { + if v_0.Op != OpAMD64VPSLLW128const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLWMasked128const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked128 (VPSRAW128const [a] x) mask) + // result: (VPSRAWMasked128const [a] x mask) + for { + if v_0.Op != OpAMD64VPSRAW128const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAWMasked128const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU16Masked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU16Masked256 (VPABSW256 x) mask) + // result: (VPABSWMasked256 x mask) + for { + if v_0.Op != OpAMD64VPABSW256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSWMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPADDW256 x y) mask) + // result: (VPADDWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPADDW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPADDSW256 x y) mask) + // result: (VPADDSWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPADDSW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDSWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPADDUSW256 x y) mask) + // result: (VPADDUSWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPADDUSW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDUSWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPAVGW256 x y) mask) + // result: (VPAVGWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPAVGW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPAVGWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPBROADCASTW256 x) mask) + // result: (VPBROADCASTWMasked256 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTW256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTWMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPERMI2W256 x y z) mask) + // result: (VPERMI2WMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2W256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2WMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMADDWD256 x y) mask) + // result: (VPMADDWDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMADDWD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMADDWDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMADDUBSW256 x y) mask) + // result: (VPMADDUBSWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMADDUBSW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMADDUBSWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMOVSXWQ256 x) mask) + // result: (VPMOVSXWQMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXWQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXWQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMOVZXWQ256 x) mask) + // result: (VPMOVZXWQMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXWQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXWQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMOVSXWD256 x) mask) + // result: (VPMOVSXWDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXWD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXWDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMOVZXWD256 x) mask) + // result: (VPMOVZXWDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXWD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXWDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMAXSW256 x y) mask) + // result: (VPMAXSWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMAXUW256 x y) mask) + // result: (VPMAXUWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMINSW256 x y) mask) + // result: (VPMINSWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMINSW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMINUW256 x y) mask) + // result: (VPMINUWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMINUW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMULHW256 x y) mask) + // result: (VPMULHWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMULHW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULHWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMULHUW256 x y) mask) + // result: (VPMULHUWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMULHUW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULHUWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMULLW256 x y) mask) + // result: (VPMULLWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMULLW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULLWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPOPCNTW256 x) mask) + // result: (VPOPCNTWMasked256 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTW256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTWMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPERMW256 x y) mask) + // result: (VPERMWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPERMW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMOVSWB128_256 x) mask) + // result: (VPMOVSWBMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSWB128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSWBMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMOVSWB256 x) mask) + // result: (VPMOVSWBMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSWB256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSWBMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMOVUSWB128_256 x) mask) + // result: (VPMOVUSWBMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSWB128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSWBMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMOVUSWB256 x) mask) + // result: (VPMOVUSWBMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSWB256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSWBMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSHLDW256 [a] x y) mask) + // result: (VPSHLDWMasked256 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHLDW256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHLDWMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSLLW256 x y) mask) + // result: (VPSLLWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSLLW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSHRDW256 [a] x y) mask) + // result: (VPSHRDWMasked256 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHRDW256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHRDWMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSRAW256 x y) mask) + // result: (VPSRAWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRAW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSRLW256 x y) mask) + // result: (VPSRLWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRLW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSHLDVW256 x y z) mask) + // result: (VPSHLDVWMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPSHLDVW256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHLDVWMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSLLVW256 x y) mask) + // result: (VPSLLVWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSLLVW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLVWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSHRDVW256 x y z) mask) + // result: (VPSHRDVWMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPSHRDVW256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHRDVWMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSRAVW256 x y) mask) + // result: (VPSRAVWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRAVW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAVWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSRLVW256 x y) mask) + // result: (VPSRLVWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRLVW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLVWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSUBW256 x y) mask) + // result: (VPSUBWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSUBW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSUBSW256 x y) mask) + // result: (VPSUBSWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSUBSW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBSWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSUBUSW256 x y) mask) + // result: (VPSUBUSWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSUBUSW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBUSWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMOVWB128_256 x) mask) + // result: (VPMOVWBMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVWB128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVWBMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPMOVWB256 x) mask) + // result: (VPMOVWBMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVWB256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVWBMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSHUFHW256 [a] x) mask) + // result: (VPSHUFHWMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VPSHUFHW256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFHWMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSHUFLW256 [a] x) mask) + // result: (VPSHUFLWMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VPSHUFLW256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFLWMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSLLW256const [a] x) mask) + // result: (VPSLLWMasked256const [a] x mask) + for { + if v_0.Op != OpAMD64VPSLLW256const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLWMasked256const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked256 (VPSRAW256const [a] x) mask) + // result: (VPSRAWMasked256const [a] x mask) + for { + if v_0.Op != OpAMD64VPSRAW256const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAWMasked256const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU16Masked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU16Masked512 (VPABSW512 x) mask) + // result: (VPABSWMasked512 x mask) + for { + if v_0.Op != OpAMD64VPABSW512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSWMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPADDW512 x y) mask) + // result: (VPADDWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPADDW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPADDSW512 x y) mask) + // result: (VPADDSWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPADDSW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDSWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPADDUSW512 x y) mask) + // result: (VPADDUSWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPADDUSW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDUSWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPAVGW512 x y) mask) + // result: (VPAVGWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPAVGW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPAVGWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPBROADCASTW512 x) mask) + // result: (VPBROADCASTWMasked512 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTW512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTWMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPERMI2W512 x y z) mask) + // result: (VPERMI2WMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2W512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2WMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMADDWD512 x y) mask) + // result: (VPMADDWDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMADDWD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMADDWDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMADDUBSW512 x y) mask) + // result: (VPMADDUBSWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMADDUBSW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMADDUBSWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMOVSXWD512 x) mask) + // result: (VPMOVSXWDMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXWD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXWDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMOVSXWQ512 x) mask) + // result: (VPMOVSXWQMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXWQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXWQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMOVZXWD512 x) mask) + // result: (VPMOVZXWDMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXWD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXWDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMOVZXWQ512 x) mask) + // result: (VPMOVZXWQMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXWQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXWQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMAXSW512 x y) mask) + // result: (VPMAXSWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMAXUW512 x y) mask) + // result: (VPMAXUWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMINSW512 x y) mask) + // result: (VPMINSWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMINSW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMINUW512 x y) mask) + // result: (VPMINUWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMINUW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMULHW512 x y) mask) + // result: (VPMULHWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMULHW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULHWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMULHUW512 x y) mask) + // result: (VPMULHUWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMULHUW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULHUWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPMULLW512 x y) mask) + // result: (VPMULLWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMULLW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULLWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPOPCNTW512 x) mask) + // result: (VPOPCNTWMasked512 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTW512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTWMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPERMW512 x y) mask) + // result: (VPERMWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPERMW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSHLDW512 [a] x y) mask) + // result: (VPSHLDWMasked512 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHLDW512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHLDWMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSLLW512 x y) mask) + // result: (VPSLLWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSLLW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSHRDW512 [a] x y) mask) + // result: (VPSHRDWMasked512 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHRDW512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHRDWMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSRAW512 x y) mask) + // result: (VPSRAWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRAW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSRLW512 x y) mask) + // result: (VPSRLWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRLW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSHLDVW512 x y z) mask) + // result: (VPSHLDVWMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPSHLDVW512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHLDVWMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSLLVW512 x y) mask) + // result: (VPSLLVWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSLLVW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLVWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSHRDVW512 x y z) mask) + // result: (VPSHRDVWMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPSHRDVW512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHRDVWMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSRAVW512 x y) mask) + // result: (VPSRAVWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRAVW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAVWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSRLVW512 x y) mask) + // result: (VPSRLVWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRLVW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLVWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSUBW512 x y) mask) + // result: (VPSUBWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSUBW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSUBSW512 x y) mask) + // result: (VPSUBSWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSUBSW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBSWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSUBUSW512 x y) mask) + // result: (VPSUBUSWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSUBUSW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBUSWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSHUFHW512 [a] x) mask) + // result: (VPSHUFHWMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VPSHUFHW512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFHWMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSHUFLW512 [a] x) mask) + // result: (VPSHUFLWMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VPSHUFLW512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFLWMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSLLW512const [a] x) mask) + // result: (VPSLLWMasked512const [a] x mask) + for { + if v_0.Op != OpAMD64VPSLLW512const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLWMasked512const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU16Masked512 (VPSRAW512const [a] x) mask) + // result: (VPSRAWMasked512const [a] x mask) + for { + if v_0.Op != OpAMD64VPSRAW512const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAWMasked512const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU32Masked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU32Masked128 (VPABSD128 x) mask) + // result: (VPABSDMasked128 x mask) + for { + if v_0.Op != OpAMD64VPABSD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VADDPS128 x y) mask) + // result: (VADDPSMasked128 x y mask) + for { + if v_0.Op != OpAMD64VADDPS128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VADDPSMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPADDD128 x y) mask) + // result: (VPADDDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPADDD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VBROADCASTSS128 x) mask) + // result: (VBROADCASTSSMasked128 x mask) + for { + if v_0.Op != OpAMD64VBROADCASTSS128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VBROADCASTSSMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPBROADCASTD128 x) mask) + // result: (VPBROADCASTDMasked128 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VRNDSCALEPS128 [a] x) mask) + // result: (VRNDSCALEPSMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VRNDSCALEPS128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRNDSCALEPSMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VREDUCEPS128 [a] x) mask) + // result: (VREDUCEPSMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VREDUCEPS128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VREDUCEPSMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPERMI2PS128 x y z) mask) + // result: (VPERMI2PSMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2PS128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2PSMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPERMI2D128 x y z) mask) + // result: (VPERMI2DMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2D128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2DMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked128 (VCVTDQ2PS128 x) mask) + // result: (VCVTDQ2PSMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTDQ2PS128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTDQ2PSMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VCVTUDQ2PS128 x) mask) + // result: (VCVTUDQ2PSMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTUDQ2PS128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUDQ2PSMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VCVTTPS2DQ128 x) mask) + // result: (VCVTTPS2DQMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTTPS2DQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPS2DQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VCVTTPS2UDQ128 x) mask) + // result: (VCVTTPS2UDQMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTTPS2UDQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPS2UDQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VDIVPS128 x y) mask) + // result: (VDIVPSMasked128 x y mask) + for { + if v_0.Op != OpAMD64VDIVPS128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VDIVPSMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMOVSXDQ128 x) mask) + // result: (VPMOVSXDQMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXDQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXDQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMOVZXDQ128 x) mask) + // result: (VPMOVZXDQMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXDQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXDQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPLZCNTD128 x) mask) + // result: (VPLZCNTDMasked128 x mask) + for { + if v_0.Op != OpAMD64VPLZCNTD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPLZCNTDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VMAXPS128 x y) mask) + // result: (VMAXPSMasked128 x y mask) + for { + if v_0.Op != OpAMD64VMAXPS128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMAXPSMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMAXSD128 x y) mask) + // result: (VPMAXSDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMAXUD128 x y) mask) + // result: (VPMAXUDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VMINPS128 x y) mask) + // result: (VMINPSMasked128 x y mask) + for { + if v_0.Op != OpAMD64VMINPS128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMINPSMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMINSD128 x y) mask) + // result: (VPMINSDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMINSD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMINUD128 x y) mask) + // result: (VPMINUDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMINUD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VFMADD213PS128 x y z) mask) + // result: (VFMADD213PSMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VFMADD213PS128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADD213PSMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked128 (VFMADDSUB213PS128 x y z) mask) + // result: (VFMADDSUB213PSMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VFMADDSUB213PS128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADDSUB213PSMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked128 (VMULPS128 x y) mask) + // result: (VMULPSMasked128 x y mask) + for { + if v_0.Op != OpAMD64VMULPS128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMULPSMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMULLD128 x y) mask) + // result: (VPMULLDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMULLD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULLDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VFMSUBADD213PS128 x y z) mask) + // result: (VFMSUBADD213PSMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VFMSUBADD213PS128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMSUBADD213PSMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPOPCNTD128 x) mask) + // result: (VPOPCNTDMasked128 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPROLD128 [a] x) mask) + // result: (VPROLDMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VPROLD128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLDMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPRORD128 [a] x) mask) + // result: (VPRORDMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VPRORD128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORDMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPROLVD128 x y) mask) + // result: (VPROLVDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPROLVD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLVDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPRORVD128 x y) mask) + // result: (VPRORVDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPRORVD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORVDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMOVSDB128_128 x) mask) + // result: (VPMOVSDBMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSDB128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSDBMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPACKSSDW128 x y) mask) + // result: (VPACKSSDWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPACKSSDW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPACKSSDWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMOVSDW128_128 x) mask) + // result: (VPMOVSDWMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSDW128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSDWMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMOVUSDB128_128 x) mask) + // result: (VPMOVUSDBMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSDB128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSDBMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPACKUSDW128 x y) mask) + // result: (VPACKUSDWMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPACKUSDW128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPACKUSDWMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMOVUSDW128_128 x) mask) + // result: (VPMOVUSDWMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSDW128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSDWMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VSCALEFPS128 x y) mask) + // result: (VSCALEFPSMasked128 x y mask) + for { + if v_0.Op != OpAMD64VSCALEFPS128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSCALEFPSMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSHLDD128 [a] x y) mask) + // result: (VPSHLDDMasked128 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHLDD128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHLDDMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSLLD128 x y) mask) + // result: (VPSLLDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSLLD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSHRDD128 [a] x y) mask) + // result: (VPSHRDDMasked128 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHRDD128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHRDDMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSRAD128 x y) mask) + // result: (VPSRADMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRAD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRADMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSRLD128 x y) mask) + // result: (VPSRLDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRLD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSHLDVD128 x y z) mask) + // result: (VPSHLDVDMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPSHLDVD128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHLDVDMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSLLVD128 x y) mask) + // result: (VPSLLVDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSLLVD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLVDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSHRDVD128 x y z) mask) + // result: (VPSHRDVDMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPSHRDVD128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHRDVDMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSRAVD128 x y) mask) + // result: (VPSRAVDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRAVD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAVDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSRLVD128 x y) mask) + // result: (VPSRLVDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRLVD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLVDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VSQRTPS128 x) mask) + // result: (VSQRTPSMasked128 x mask) + for { + if v_0.Op != OpAMD64VSQRTPS128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSQRTPSMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VSUBPS128 x y) mask) + // result: (VSUBPSMasked128 x y mask) + for { + if v_0.Op != OpAMD64VSUBPS128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSUBPSMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSUBD128 x y) mask) + // result: (VPSUBDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSUBD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMOVDB128_128 x) mask) + // result: (VPMOVDBMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVDB128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVDBMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPMOVDW128_128 x) mask) + // result: (VPMOVDWMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVDW128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVDWMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSHUFD128 [a] x) mask) + // result: (VPSHUFDMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VPSHUFD128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFDMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSLLD128const [a] x) mask) + // result: (VPSLLDMasked128const [a] x mask) + for { + if v_0.Op != OpAMD64VPSLLD128const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLDMasked128const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked128 (VPSRAD128const [a] x) mask) + // result: (VPSRADMasked128const [a] x mask) + for { + if v_0.Op != OpAMD64VPSRAD128const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRADMasked128const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU32Masked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU32Masked256 (VPABSD256 x) mask) + // result: (VPABSDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPABSD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VADDPS256 x y) mask) + // result: (VADDPSMasked256 x y mask) + for { + if v_0.Op != OpAMD64VADDPS256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VADDPSMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPADDD256 x y) mask) + // result: (VPADDDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPADDD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VBROADCASTSS256 x) mask) + // result: (VBROADCASTSSMasked256 x mask) + for { + if v_0.Op != OpAMD64VBROADCASTSS256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VBROADCASTSSMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPBROADCASTD256 x) mask) + // result: (VPBROADCASTDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VRNDSCALEPS256 [a] x) mask) + // result: (VRNDSCALEPSMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VRNDSCALEPS256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRNDSCALEPSMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VREDUCEPS256 [a] x) mask) + // result: (VREDUCEPSMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VREDUCEPS256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VREDUCEPSMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPERMI2PS256 x y z) mask) + // result: (VPERMI2PSMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2PS256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2PSMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPERMI2D256 x y z) mask) + // result: (VPERMI2DMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2D256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2DMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked256 (VCVTDQ2PS256 x) mask) + // result: (VCVTDQ2PSMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTDQ2PS256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTDQ2PSMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VCVTUDQ2PS256 x) mask) + // result: (VCVTUDQ2PSMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTUDQ2PS256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUDQ2PSMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VCVTPS2PD256 x) mask) + // result: (VCVTPS2PDMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTPS2PD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTPS2PDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VCVTDQ2PD256 x) mask) + // result: (VCVTDQ2PDMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTDQ2PD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTDQ2PDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VCVTUDQ2PD256 x) mask) + // result: (VCVTUDQ2PDMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTUDQ2PD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUDQ2PDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VCVTTPS2DQ256 x) mask) + // result: (VCVTTPS2DQMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTTPS2DQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPS2DQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VCVTTPS2QQ256 x) mask) + // result: (VCVTTPS2QQMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTTPS2QQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPS2QQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VCVTTPS2UDQ256 x) mask) + // result: (VCVTTPS2UDQMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTTPS2UDQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPS2UDQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VCVTTPS2UQQ256 x) mask) + // result: (VCVTTPS2UQQMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTTPS2UQQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPS2UQQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VDIVPS256 x y) mask) + // result: (VDIVPSMasked256 x y mask) + for { + if v_0.Op != OpAMD64VDIVPS256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VDIVPSMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVSXDQ256 x) mask) + // result: (VPMOVSXDQMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXDQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXDQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVZXDQ256 x) mask) + // result: (VPMOVZXDQMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXDQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXDQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPLZCNTD256 x) mask) + // result: (VPLZCNTDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPLZCNTD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPLZCNTDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VMAXPS256 x y) mask) + // result: (VMAXPSMasked256 x y mask) + for { + if v_0.Op != OpAMD64VMAXPS256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMAXPSMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMAXSD256 x y) mask) + // result: (VPMAXSDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMAXUD256 x y) mask) + // result: (VPMAXUDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VMINPS256 x y) mask) + // result: (VMINPSMasked256 x y mask) + for { + if v_0.Op != OpAMD64VMINPS256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMINPSMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMINSD256 x y) mask) + // result: (VPMINSDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMINSD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMINUD256 x y) mask) + // result: (VPMINUDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMINUD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VFMADD213PS256 x y z) mask) + // result: (VFMADD213PSMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VFMADD213PS256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADD213PSMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked256 (VFMADDSUB213PS256 x y z) mask) + // result: (VFMADDSUB213PSMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VFMADDSUB213PS256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADDSUB213PSMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked256 (VMULPS256 x y) mask) + // result: (VMULPSMasked256 x y mask) + for { + if v_0.Op != OpAMD64VMULPS256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMULPSMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMULLD256 x y) mask) + // result: (VPMULLDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMULLD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULLDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VFMSUBADD213PS256 x y z) mask) + // result: (VFMSUBADD213PSMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VFMSUBADD213PS256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMSUBADD213PSMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPOPCNTD256 x) mask) + // result: (VPOPCNTDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPERMPS256 x y) mask) + // result: (VPERMPSMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPERMPS256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMPSMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPERMD256 x y) mask) + // result: (VPERMDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPERMD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPROLD256 [a] x) mask) + // result: (VPROLDMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VPROLD256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLDMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPRORD256 [a] x) mask) + // result: (VPRORDMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VPRORD256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORDMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPROLVD256 x y) mask) + // result: (VPROLVDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPROLVD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLVDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPRORVD256 x y) mask) + // result: (VPRORVDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPRORVD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORVDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVSDB128_256 x) mask) + // result: (VPMOVSDBMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSDB128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSDBMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPACKSSDW256 x y) mask) + // result: (VPACKSSDWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPACKSSDW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPACKSSDWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVSDW128_256 x) mask) + // result: (VPMOVSDWMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSDW128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSDWMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVSDW256 x) mask) + // result: (VPMOVSDWMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSDW256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSDWMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVUSDB128_256 x) mask) + // result: (VPMOVUSDBMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSDB128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSDBMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPACKUSDW256 x y) mask) + // result: (VPACKUSDWMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPACKUSDW256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPACKUSDWMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVUSDW128_256 x) mask) + // result: (VPMOVUSDWMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSDW128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSDWMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVUSDW256 x) mask) + // result: (VPMOVUSDWMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSDW256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSDWMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VSCALEFPS256 x y) mask) + // result: (VSCALEFPSMasked256 x y mask) + for { + if v_0.Op != OpAMD64VSCALEFPS256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSCALEFPSMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSHLDD256 [a] x y) mask) + // result: (VPSHLDDMasked256 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHLDD256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHLDDMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSLLD256 x y) mask) + // result: (VPSLLDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSLLD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSHRDD256 [a] x y) mask) + // result: (VPSHRDDMasked256 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHRDD256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHRDDMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSRAD256 x y) mask) + // result: (VPSRADMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRAD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRADMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSRLD256 x y) mask) + // result: (VPSRLDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRLD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSHLDVD256 x y z) mask) + // result: (VPSHLDVDMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPSHLDVD256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHLDVDMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSLLVD256 x y) mask) + // result: (VPSLLVDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSLLVD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLVDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSHRDVD256 x y z) mask) + // result: (VPSHRDVDMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPSHRDVD256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHRDVDMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSRAVD256 x y) mask) + // result: (VPSRAVDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRAVD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAVDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSRLVD256 x y) mask) + // result: (VPSRLVDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRLVD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLVDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VSQRTPS256 x) mask) + // result: (VSQRTPSMasked256 x mask) + for { + if v_0.Op != OpAMD64VSQRTPS256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSQRTPSMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VSUBPS256 x y) mask) + // result: (VSUBPSMasked256 x y mask) + for { + if v_0.Op != OpAMD64VSUBPS256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSUBPSMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSUBD256 x y) mask) + // result: (VPSUBDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSUBD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVDB128_256 x) mask) + // result: (VPMOVDBMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVDB128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVDBMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVDW128_256 x) mask) + // result: (VPMOVDWMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVDW128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVDWMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPMOVDW256 x) mask) + // result: (VPMOVDWMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVDW256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVDWMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSHUFD256 [a] x) mask) + // result: (VPSHUFDMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VPSHUFD256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFDMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSLLD256const [a] x) mask) + // result: (VPSLLDMasked256const [a] x mask) + for { + if v_0.Op != OpAMD64VPSLLD256const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLDMasked256const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked256 (VPSRAD256const [a] x) mask) + // result: (VPSRADMasked256const [a] x mask) + for { + if v_0.Op != OpAMD64VPSRAD256const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRADMasked256const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU32Masked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU32Masked512 (VPABSD512 x) mask) + // result: (VPABSDMasked512 x mask) + for { + if v_0.Op != OpAMD64VPABSD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VADDPS512 x y) mask) + // result: (VADDPSMasked512 x y mask) + for { + if v_0.Op != OpAMD64VADDPS512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VADDPSMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPADDD512 x y) mask) + // result: (VPADDDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPADDD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPANDD512 x y) mask) + // result: (VPANDDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPANDD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPANDDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPANDND512 x y) mask) + // result: (VPANDNDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPANDND512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPANDNDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VBROADCASTSS512 x) mask) + // result: (VBROADCASTSSMasked512 x mask) + for { + if v_0.Op != OpAMD64VBROADCASTSS512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VBROADCASTSSMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPBROADCASTD512 x) mask) + // result: (VPBROADCASTDMasked512 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VRNDSCALEPS512 [a] x) mask) + // result: (VRNDSCALEPSMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VRNDSCALEPS512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRNDSCALEPSMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VREDUCEPS512 [a] x) mask) + // result: (VREDUCEPSMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VREDUCEPS512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VREDUCEPSMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPERMI2PS512 x y z) mask) + // result: (VPERMI2PSMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2PS512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2PSMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPERMI2D512 x y z) mask) + // result: (VPERMI2DMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2D512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2DMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked512 (VCVTDQ2PS512 x) mask) + // result: (VCVTDQ2PSMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTDQ2PS512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTDQ2PSMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VCVTUDQ2PS512 x) mask) + // result: (VCVTUDQ2PSMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTUDQ2PS512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUDQ2PSMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VCVTPS2PD512 x) mask) + // result: (VCVTPS2PDMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTPS2PD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTPS2PDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VCVTDQ2PD512 x) mask) + // result: (VCVTDQ2PDMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTDQ2PD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTDQ2PDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VCVTUDQ2PD512 x) mask) + // result: (VCVTUDQ2PDMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTUDQ2PD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUDQ2PDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VCVTTPS2DQ512 x) mask) + // result: (VCVTTPS2DQMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTTPS2DQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPS2DQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VCVTTPS2QQ512 x) mask) + // result: (VCVTTPS2QQMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTTPS2QQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPS2QQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VCVTTPS2UDQ512 x) mask) + // result: (VCVTTPS2UDQMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTTPS2UDQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPS2UDQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VCVTTPS2UQQ512 x) mask) + // result: (VCVTTPS2UQQMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTTPS2UQQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPS2UQQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VDIVPS512 x y) mask) + // result: (VDIVPSMasked512 x y mask) + for { + if v_0.Op != OpAMD64VDIVPS512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VDIVPSMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPMOVSXDQ512 x) mask) + // result: (VPMOVSXDQMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXDQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXDQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPMOVZXDQ512 x) mask) + // result: (VPMOVZXDQMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXDQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXDQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPLZCNTD512 x) mask) + // result: (VPLZCNTDMasked512 x mask) + for { + if v_0.Op != OpAMD64VPLZCNTD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPLZCNTDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VMAXPS512 x y) mask) + // result: (VMAXPSMasked512 x y mask) + for { + if v_0.Op != OpAMD64VMAXPS512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMAXPSMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPMAXSD512 x y) mask) + // result: (VPMAXSDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPMAXUD512 x y) mask) + // result: (VPMAXUDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VMINPS512 x y) mask) + // result: (VMINPSMasked512 x y mask) + for { + if v_0.Op != OpAMD64VMINPS512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMINPSMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPMINSD512 x y) mask) + // result: (VPMINSDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMINSD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPMINUD512 x y) mask) + // result: (VPMINUDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMINUD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VFMADD213PS512 x y z) mask) + // result: (VFMADD213PSMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VFMADD213PS512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADD213PSMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked512 (VFMADDSUB213PS512 x y z) mask) + // result: (VFMADDSUB213PSMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VFMADDSUB213PS512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADDSUB213PSMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked512 (VMULPS512 x y) mask) + // result: (VMULPSMasked512 x y mask) + for { + if v_0.Op != OpAMD64VMULPS512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMULPSMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPMULLD512 x y) mask) + // result: (VPMULLDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMULLD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULLDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VFMSUBADD213PS512 x y z) mask) + // result: (VFMSUBADD213PSMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VFMSUBADD213PS512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMSUBADD213PSMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPOPCNTD512 x) mask) + // result: (VPOPCNTDMasked512 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPORD512 x y) mask) + // result: (VPORDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPORD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPORDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPERMPS512 x y) mask) + // result: (VPERMPSMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPERMPS512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMPSMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPERMD512 x y) mask) + // result: (VPERMDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPERMD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VRCP14PS512 x) mask) + // result: (VRCP14PSMasked512 x mask) + for { + if v_0.Op != OpAMD64VRCP14PS512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRCP14PSMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VRSQRT14PS512 x) mask) + // result: (VRSQRT14PSMasked512 x mask) + for { + if v_0.Op != OpAMD64VRSQRT14PS512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRSQRT14PSMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPROLD512 [a] x) mask) + // result: (VPROLDMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VPROLD512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLDMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPRORD512 [a] x) mask) + // result: (VPRORDMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VPRORD512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORDMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPROLVD512 x y) mask) + // result: (VPROLVDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPROLVD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLVDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPRORVD512 x y) mask) + // result: (VPRORVDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPRORVD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORVDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPMOVSDB128_512 x) mask) + // result: (VPMOVSDBMasked128_512 x mask) + for { + if v_0.Op != OpAMD64VPMOVSDB128_512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSDBMasked128_512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPACKSSDW512 x y) mask) + // result: (VPACKSSDWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPACKSSDW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPACKSSDWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPMOVUSDB128_512 x) mask) + // result: (VPMOVUSDBMasked128_512 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSDB128_512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSDBMasked128_512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPACKUSDW512 x y) mask) + // result: (VPACKUSDWMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPACKUSDW512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPACKUSDWMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VSCALEFPS512 x y) mask) + // result: (VSCALEFPSMasked512 x y mask) + for { + if v_0.Op != OpAMD64VSCALEFPS512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSCALEFPSMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSHLDD512 [a] x y) mask) + // result: (VPSHLDDMasked512 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHLDD512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHLDDMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSLLD512 x y) mask) + // result: (VPSLLDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSLLD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSHRDD512 [a] x y) mask) + // result: (VPSHRDDMasked512 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHRDD512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHRDDMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSRAD512 x y) mask) + // result: (VPSRADMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRAD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRADMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSRLD512 x y) mask) + // result: (VPSRLDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRLD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSHLDVD512 x y z) mask) + // result: (VPSHLDVDMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPSHLDVD512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHLDVDMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSLLVD512 x y) mask) + // result: (VPSLLVDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSLLVD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLVDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSHRDVD512 x y z) mask) + // result: (VPSHRDVDMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPSHRDVD512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHRDVDMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSRAVD512 x y) mask) + // result: (VPSRAVDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRAVD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAVDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSRLVD512 x y) mask) + // result: (VPSRLVDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRLVD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLVDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VSQRTPS512 x) mask) + // result: (VSQRTPSMasked512 x mask) + for { + if v_0.Op != OpAMD64VSQRTPS512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSQRTPSMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VSUBPS512 x y) mask) + // result: (VSUBPSMasked512 x y mask) + for { + if v_0.Op != OpAMD64VSUBPS512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSUBPSMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSUBD512 x y) mask) + // result: (VPSUBDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSUBD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPMOVDB128_512 x) mask) + // result: (VPMOVDBMasked128_512 x mask) + for { + if v_0.Op != OpAMD64VPMOVDB128_512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVDBMasked128_512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPXORD512 x y) mask) + // result: (VPXORDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPXORD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPXORDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSHUFD512 [a] x) mask) + // result: (VPSHUFDMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VPSHUFD512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFDMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSLLD512const [a] x) mask) + // result: (VPSLLDMasked512const [a] x mask) + for { + if v_0.Op != OpAMD64VPSLLD512const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLDMasked512const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU32Masked512 (VPSRAD512const [a] x) mask) + // result: (VPSRADMasked512const [a] x mask) + for { + if v_0.Op != OpAMD64VPSRAD512const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRADMasked512const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU64Masked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU64Masked128 (VPABSQ128 x) mask) + // result: (VPABSQMasked128 x mask) + for { + if v_0.Op != OpAMD64VPABSQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VADDPD128 x y) mask) + // result: (VADDPDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VADDPD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VADDPDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPADDQ128 x y) mask) + // result: (VPADDQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPADDQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPBROADCASTQ128 x) mask) + // result: (VPBROADCASTQMasked128 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VRNDSCALEPD128 [a] x) mask) + // result: (VRNDSCALEPDMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VRNDSCALEPD128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRNDSCALEPDMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VREDUCEPD128 [a] x) mask) + // result: (VREDUCEPDMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VREDUCEPD128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VREDUCEPDMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPERMI2PD128 x y z) mask) + // result: (VPERMI2PDMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2PD128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2PDMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPERMI2Q128 x y z) mask) + // result: (VPERMI2QMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2Q128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2QMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTPD2PSX128 x) mask) + // result: (VCVTPD2PSXMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTPD2PSX128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTPD2PSXMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTPD2PSY128 x) mask) + // result: (VCVTPD2PSYMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTPD2PSY128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTPD2PSYMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTQQ2PSX128 x) mask) + // result: (VCVTQQ2PSXMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTQQ2PSX128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTQQ2PSXMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTQQ2PSY128 x) mask) + // result: (VCVTQQ2PSYMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTQQ2PSY128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTQQ2PSYMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTUQQ2PSX128 x) mask) + // result: (VCVTUQQ2PSXMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTUQQ2PSX128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUQQ2PSXMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTUQQ2PSY128 x) mask) + // result: (VCVTUQQ2PSYMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTUQQ2PSY128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUQQ2PSYMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTQQ2PD128 x) mask) + // result: (VCVTQQ2PDMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTQQ2PD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTQQ2PDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTUQQ2PD128 x) mask) + // result: (VCVTUQQ2PDMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTUQQ2PD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUQQ2PDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTTPD2DQX128 x) mask) + // result: (VCVTTPD2DQXMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2DQX128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2DQXMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTTPD2DQY128 x) mask) + // result: (VCVTTPD2DQYMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2DQY128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2DQYMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTTPD2QQ128 x) mask) + // result: (VCVTTPD2QQMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2QQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2QQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTTPD2UDQX128 x) mask) + // result: (VCVTTPD2UDQXMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2UDQX128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2UDQXMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTTPD2UDQY128 x) mask) + // result: (VCVTTPD2UDQYMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2UDQY128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2UDQYMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VCVTTPD2UQQ128 x) mask) + // result: (VCVTTPD2UQQMasked128 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2UQQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2UQQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VDIVPD128 x y) mask) + // result: (VDIVPDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VDIVPD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VDIVPDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPLZCNTQ128 x) mask) + // result: (VPLZCNTQMasked128 x mask) + for { + if v_0.Op != OpAMD64VPLZCNTQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPLZCNTQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VMAXPD128 x y) mask) + // result: (VMAXPDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VMAXPD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMAXPDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMAXSQ128 x y) mask) + // result: (VPMAXSQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMAXUQ128 x y) mask) + // result: (VPMAXUQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VMINPD128 x y) mask) + // result: (VMINPDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VMINPD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMINPDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMINSQ128 x y) mask) + // result: (VPMINSQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMINSQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMINUQ128 x y) mask) + // result: (VPMINUQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMINUQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VFMADD213PD128 x y z) mask) + // result: (VFMADD213PDMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VFMADD213PD128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADD213PDMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked128 (VFMADDSUB213PD128 x y z) mask) + // result: (VFMADDSUB213PDMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VFMADDSUB213PD128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADDSUB213PDMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked128 (VMULPD128 x y) mask) + // result: (VMULPDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VMULPD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMULPDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMULLQ128 x y) mask) + // result: (VPMULLQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMULLQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULLQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VFMSUBADD213PD128 x y z) mask) + // result: (VFMSUBADD213PDMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VFMSUBADD213PD128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMSUBADD213PDMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPOPCNTQ128 x) mask) + // result: (VPOPCNTQMasked128 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VRCP14PD128 x) mask) + // result: (VRCP14PDMasked128 x mask) + for { + if v_0.Op != OpAMD64VRCP14PD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRCP14PDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VRSQRT14PD128 x) mask) + // result: (VRSQRT14PDMasked128 x mask) + for { + if v_0.Op != OpAMD64VRSQRT14PD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRSQRT14PDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPROLQ128 [a] x) mask) + // result: (VPROLQMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VPROLQ128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLQMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPRORQ128 [a] x) mask) + // result: (VPRORQMasked128 [a] x mask) + for { + if v_0.Op != OpAMD64VPRORQ128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORQMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPROLVQ128 x y) mask) + // result: (VPROLVQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPROLVQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLVQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPRORVQ128 x y) mask) + // result: (VPRORVQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPRORVQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORVQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMOVSQB128_128 x) mask) + // result: (VPMOVSQBMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSQB128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSQBMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMOVSQW128_128 x) mask) + // result: (VPMOVSQWMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSQW128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSQWMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMOVSQD128_128 x) mask) + // result: (VPMOVSQDMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSQD128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSQDMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMOVUSQB128_128 x) mask) + // result: (VPMOVUSQBMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSQB128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSQBMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMOVUSQW128_128 x) mask) + // result: (VPMOVUSQWMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSQW128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSQWMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMOVUSQD128_128 x) mask) + // result: (VPMOVUSQDMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSQD128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSQDMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VSCALEFPD128 x y) mask) + // result: (VSCALEFPDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VSCALEFPD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSCALEFPDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSHLDQ128 [a] x y) mask) + // result: (VPSHLDQMasked128 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHLDQ128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHLDQMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSLLQ128 x y) mask) + // result: (VPSLLQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSLLQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSHRDQ128 [a] x y) mask) + // result: (VPSHRDQMasked128 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHRDQ128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHRDQMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSRAQ128 x y) mask) + // result: (VPSRAQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRAQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSRLQ128 x y) mask) + // result: (VPSRLQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRLQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSHLDVQ128 x y z) mask) + // result: (VPSHLDVQMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPSHLDVQ128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHLDVQMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSLLVQ128 x y) mask) + // result: (VPSLLVQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSLLVQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLVQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSHRDVQ128 x y z) mask) + // result: (VPSHRDVQMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPSHRDVQ128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHRDVQMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSRAVQ128 x y) mask) + // result: (VPSRAVQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRAVQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAVQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSRLVQ128 x y) mask) + // result: (VPSRLVQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSRLVQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLVQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VSQRTPD128 x) mask) + // result: (VSQRTPDMasked128 x mask) + for { + if v_0.Op != OpAMD64VSQRTPD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSQRTPDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VSUBPD128 x y) mask) + // result: (VSUBPDMasked128 x y mask) + for { + if v_0.Op != OpAMD64VSUBPD128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSUBPDMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSUBQ128 x y) mask) + // result: (VPSUBQMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSUBQ128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBQMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMOVQB128_128 x) mask) + // result: (VPMOVQBMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVQB128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVQBMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMOVQW128_128 x) mask) + // result: (VPMOVQWMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVQW128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVQWMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPMOVQD128_128 x) mask) + // result: (VPMOVQDMasked128_128 x mask) + for { + if v_0.Op != OpAMD64VPMOVQD128_128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVQDMasked128_128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSLLQ128const [a] x) mask) + // result: (VPSLLQMasked128const [a] x mask) + for { + if v_0.Op != OpAMD64VPSLLQ128const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLQMasked128const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked128 (VPSRAQ128const [a] x) mask) + // result: (VPSRAQMasked128const [a] x mask) + for { + if v_0.Op != OpAMD64VPSRAQ128const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAQMasked128const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU64Masked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU64Masked256 (VPABSQ256 x) mask) + // result: (VPABSQMasked256 x mask) + for { + if v_0.Op != OpAMD64VPABSQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VADDPD256 x y) mask) + // result: (VADDPDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VADDPD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VADDPDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPADDQ256 x y) mask) + // result: (VPADDQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPADDQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VBROADCASTSD256 x) mask) + // result: (VBROADCASTSDMasked256 x mask) + for { + if v_0.Op != OpAMD64VBROADCASTSD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VBROADCASTSDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPBROADCASTQ256 x) mask) + // result: (VPBROADCASTQMasked256 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VRNDSCALEPD256 [a] x) mask) + // result: (VRNDSCALEPDMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VRNDSCALEPD256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRNDSCALEPDMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VREDUCEPD256 [a] x) mask) + // result: (VREDUCEPDMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VREDUCEPD256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VREDUCEPDMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPERMI2PD256 x y z) mask) + // result: (VPERMI2PDMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2PD256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2PDMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPERMI2Q256 x y z) mask) + // result: (VPERMI2QMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2Q256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2QMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked256 (VCVTPD2PS256 x) mask) + // result: (VCVTPD2PSMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTPD2PS256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTPD2PSMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VCVTQQ2PS256 x) mask) + // result: (VCVTQQ2PSMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTQQ2PS256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTQQ2PSMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VCVTUQQ2PS256 x) mask) + // result: (VCVTUQQ2PSMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTUQQ2PS256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUQQ2PSMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VCVTQQ2PD256 x) mask) + // result: (VCVTQQ2PDMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTQQ2PD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTQQ2PDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VCVTUQQ2PD256 x) mask) + // result: (VCVTUQQ2PDMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTUQQ2PD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUQQ2PDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VCVTTPD2DQ256 x) mask) + // result: (VCVTTPD2DQMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2DQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2DQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VCVTTPD2QQ256 x) mask) + // result: (VCVTTPD2QQMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2QQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2QQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VCVTTPD2UDQ256 x) mask) + // result: (VCVTTPD2UDQMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2UDQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2UDQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VCVTTPD2UQQ256 x) mask) + // result: (VCVTTPD2UQQMasked256 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2UQQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2UQQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VDIVPD256 x y) mask) + // result: (VDIVPDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VDIVPD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VDIVPDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPLZCNTQ256 x) mask) + // result: (VPLZCNTQMasked256 x mask) + for { + if v_0.Op != OpAMD64VPLZCNTQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPLZCNTQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VMAXPD256 x y) mask) + // result: (VMAXPDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VMAXPD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMAXPDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMAXSQ256 x y) mask) + // result: (VPMAXSQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMAXUQ256 x y) mask) + // result: (VPMAXUQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VMINPD256 x y) mask) + // result: (VMINPDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VMINPD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMINPDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMINSQ256 x y) mask) + // result: (VPMINSQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMINSQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMINUQ256 x y) mask) + // result: (VPMINUQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMINUQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VFMADD213PD256 x y z) mask) + // result: (VFMADD213PDMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VFMADD213PD256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADD213PDMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked256 (VFMADDSUB213PD256 x y z) mask) + // result: (VFMADDSUB213PDMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VFMADDSUB213PD256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADDSUB213PDMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked256 (VMULPD256 x y) mask) + // result: (VMULPDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VMULPD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMULPDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMULLQ256 x y) mask) + // result: (VPMULLQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMULLQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULLQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VFMSUBADD213PD256 x y z) mask) + // result: (VFMSUBADD213PDMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VFMSUBADD213PD256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMSUBADD213PDMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPOPCNTQ256 x) mask) + // result: (VPOPCNTQMasked256 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPERMPD256 x y) mask) + // result: (VPERMPDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPERMPD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMPDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPERMQ256 x y) mask) + // result: (VPERMQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPERMQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VRCP14PD256 x) mask) + // result: (VRCP14PDMasked256 x mask) + for { + if v_0.Op != OpAMD64VRCP14PD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRCP14PDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VRSQRT14PD256 x) mask) + // result: (VRSQRT14PDMasked256 x mask) + for { + if v_0.Op != OpAMD64VRSQRT14PD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRSQRT14PDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPROLQ256 [a] x) mask) + // result: (VPROLQMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VPROLQ256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLQMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPRORQ256 [a] x) mask) + // result: (VPRORQMasked256 [a] x mask) + for { + if v_0.Op != OpAMD64VPRORQ256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORQMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPROLVQ256 x y) mask) + // result: (VPROLVQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPROLVQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLVQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPRORVQ256 x y) mask) + // result: (VPRORVQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPRORVQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORVQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVSQB128_256 x) mask) + // result: (VPMOVSQBMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSQB128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSQBMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVSQW128_256 x) mask) + // result: (VPMOVSQWMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSQW128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSQWMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVSQD128_256 x) mask) + // result: (VPMOVSQDMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSQD128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSQDMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVSQD256 x) mask) + // result: (VPMOVSQDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSQD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSQDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVUSQB128_256 x) mask) + // result: (VPMOVUSQBMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSQB128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSQBMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVUSQW128_256 x) mask) + // result: (VPMOVUSQWMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSQW128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSQWMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVUSQD128_256 x) mask) + // result: (VPMOVUSQDMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSQD128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSQDMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVUSQD256 x) mask) + // result: (VPMOVUSQDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSQD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSQDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VSCALEFPD256 x y) mask) + // result: (VSCALEFPDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VSCALEFPD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSCALEFPDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSHLDQ256 [a] x y) mask) + // result: (VPSHLDQMasked256 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHLDQ256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHLDQMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSLLQ256 x y) mask) + // result: (VPSLLQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSLLQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSHRDQ256 [a] x y) mask) + // result: (VPSHRDQMasked256 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHRDQ256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHRDQMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSRAQ256 x y) mask) + // result: (VPSRAQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRAQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSRLQ256 x y) mask) + // result: (VPSRLQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRLQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSHLDVQ256 x y z) mask) + // result: (VPSHLDVQMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPSHLDVQ256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHLDVQMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSLLVQ256 x y) mask) + // result: (VPSLLVQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSLLVQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLVQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSHRDVQ256 x y z) mask) + // result: (VPSHRDVQMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPSHRDVQ256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHRDVQMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSRAVQ256 x y) mask) + // result: (VPSRAVQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRAVQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAVQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSRLVQ256 x y) mask) + // result: (VPSRLVQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSRLVQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLVQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VSQRTPD256 x) mask) + // result: (VSQRTPDMasked256 x mask) + for { + if v_0.Op != OpAMD64VSQRTPD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSQRTPDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VSUBPD256 x y) mask) + // result: (VSUBPDMasked256 x y mask) + for { + if v_0.Op != OpAMD64VSUBPD256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSUBPDMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSUBQ256 x y) mask) + // result: (VPSUBQMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSUBQ256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBQMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVQB128_256 x) mask) + // result: (VPMOVQBMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVQB128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVQBMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVQW128_256 x) mask) + // result: (VPMOVQWMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVQW128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVQWMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVQD128_256 x) mask) + // result: (VPMOVQDMasked128_256 x mask) + for { + if v_0.Op != OpAMD64VPMOVQD128_256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVQDMasked128_256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPMOVQD256 x) mask) + // result: (VPMOVQDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVQD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVQDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSLLQ256const [a] x) mask) + // result: (VPSLLQMasked256const [a] x mask) + for { + if v_0.Op != OpAMD64VPSLLQ256const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLQMasked256const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked256 (VPSRAQ256const [a] x) mask) + // result: (VPSRAQMasked256const [a] x mask) + for { + if v_0.Op != OpAMD64VPSRAQ256const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAQMasked256const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU64Masked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU64Masked512 (VPABSQ512 x) mask) + // result: (VPABSQMasked512 x mask) + for { + if v_0.Op != OpAMD64VPABSQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VADDPD512 x y) mask) + // result: (VADDPDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VADDPD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VADDPDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPADDQ512 x y) mask) + // result: (VPADDQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPADDQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPANDQ512 x y) mask) + // result: (VPANDQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPANDQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPANDQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPANDNQ512 x y) mask) + // result: (VPANDNQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPANDNQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPANDNQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VBROADCASTSD512 x) mask) + // result: (VBROADCASTSDMasked512 x mask) + for { + if v_0.Op != OpAMD64VBROADCASTSD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VBROADCASTSDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPBROADCASTQ512 x) mask) + // result: (VPBROADCASTQMasked512 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VRNDSCALEPD512 [a] x) mask) + // result: (VRNDSCALEPDMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VRNDSCALEPD512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRNDSCALEPDMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VREDUCEPD512 [a] x) mask) + // result: (VREDUCEPDMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VREDUCEPD512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VREDUCEPDMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPERMI2PD512 x y z) mask) + // result: (VPERMI2PDMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2PD512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2PDMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPERMI2Q512 x y z) mask) + // result: (VPERMI2QMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2Q512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2QMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked512 (VCVTQQ2PD512 x) mask) + // result: (VCVTQQ2PDMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTQQ2PD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTQQ2PDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VCVTUQQ2PD512 x) mask) + // result: (VCVTUQQ2PDMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTUQQ2PD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTUQQ2PDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VCVTTPD2QQ512 x) mask) + // result: (VCVTTPD2QQMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2QQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2QQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VCVTTPD2UQQ512 x) mask) + // result: (VCVTTPD2UQQMasked512 x mask) + for { + if v_0.Op != OpAMD64VCVTTPD2UQQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VCVTTPD2UQQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VDIVPD512 x y) mask) + // result: (VDIVPDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VDIVPD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VDIVPDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPLZCNTQ512 x) mask) + // result: (VPLZCNTQMasked512 x mask) + for { + if v_0.Op != OpAMD64VPLZCNTQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPLZCNTQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VMAXPD512 x y) mask) + // result: (VMAXPDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VMAXPD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMAXPDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMAXSQ512 x y) mask) + // result: (VPMAXSQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMAXUQ512 x y) mask) + // result: (VPMAXUQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VMINPD512 x y) mask) + // result: (VMINPDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VMINPD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMINPDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMINSQ512 x y) mask) + // result: (VPMINSQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMINSQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMINUQ512 x y) mask) + // result: (VPMINUQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMINUQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VFMADD213PD512 x y z) mask) + // result: (VFMADD213PDMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VFMADD213PD512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADD213PDMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked512 (VFMADDSUB213PD512 x y z) mask) + // result: (VFMADDSUB213PDMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VFMADDSUB213PD512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMADDSUB213PDMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked512 (VMULPD512 x y) mask) + // result: (VMULPDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VMULPD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VMULPDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMULLQ512 x y) mask) + // result: (VPMULLQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMULLQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMULLQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VFMSUBADD213PD512 x y z) mask) + // result: (VFMSUBADD213PDMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VFMSUBADD213PD512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VFMSUBADD213PDMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPOPCNTQ512 x) mask) + // result: (VPOPCNTQMasked512 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPORQ512 x y) mask) + // result: (VPORQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPORQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPORQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPERMPD512 x y) mask) + // result: (VPERMPDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPERMPD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMPDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPERMQ512 x y) mask) + // result: (VPERMQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPERMQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VRCP14PD512 x) mask) + // result: (VRCP14PDMasked512 x mask) + for { + if v_0.Op != OpAMD64VRCP14PD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRCP14PDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VRSQRT14PD512 x) mask) + // result: (VRSQRT14PDMasked512 x mask) + for { + if v_0.Op != OpAMD64VRSQRT14PD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VRSQRT14PDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPROLQ512 [a] x) mask) + // result: (VPROLQMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VPROLQ512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLQMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPRORQ512 [a] x) mask) + // result: (VPRORQMasked512 [a] x mask) + for { + if v_0.Op != OpAMD64VPRORQ512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORQMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPROLVQ512 x y) mask) + // result: (VPROLVQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPROLVQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPROLVQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPRORVQ512 x y) mask) + // result: (VPRORVQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPRORVQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPRORVQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMOVSQB128_512 x) mask) + // result: (VPMOVSQBMasked128_512 x mask) + for { + if v_0.Op != OpAMD64VPMOVSQB128_512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSQBMasked128_512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMOVSQW128_512 x) mask) + // result: (VPMOVSQWMasked128_512 x mask) + for { + if v_0.Op != OpAMD64VPMOVSQW128_512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSQWMasked128_512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMOVUSQB128_512 x) mask) + // result: (VPMOVUSQBMasked128_512 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSQB128_512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSQBMasked128_512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMOVUSQW128_512 x) mask) + // result: (VPMOVUSQWMasked128_512 x mask) + for { + if v_0.Op != OpAMD64VPMOVUSQW128_512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVUSQWMasked128_512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VSCALEFPD512 x y) mask) + // result: (VSCALEFPDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VSCALEFPD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSCALEFPDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSHLDQ512 [a] x y) mask) + // result: (VPSHLDQMasked512 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHLDQ512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHLDQMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSLLQ512 x y) mask) + // result: (VPSLLQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSLLQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSHRDQ512 [a] x y) mask) + // result: (VPSHRDQMasked512 [a] x y mask) + for { + if v_0.Op != OpAMD64VPSHRDQ512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHRDQMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSRAQ512 x y) mask) + // result: (VPSRAQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRAQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSRLQ512 x y) mask) + // result: (VPSRLQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRLQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSHLDVQ512 x y z) mask) + // result: (VPSHLDVQMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPSHLDVQ512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHLDVQMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSLLVQ512 x y) mask) + // result: (VPSLLVQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSLLVQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLVQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSHRDVQ512 x y z) mask) + // result: (VPSHRDVQMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPSHRDVQ512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPSHRDVQMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSRAVQ512 x y) mask) + // result: (VPSRAVQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRAVQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAVQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSRLVQ512 x y) mask) + // result: (VPSRLVQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSRLVQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRLVQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VSQRTPD512 x) mask) + // result: (VSQRTPDMasked512 x mask) + for { + if v_0.Op != OpAMD64VSQRTPD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSQRTPDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VSUBPD512 x y) mask) + // result: (VSUBPDMasked512 x y mask) + for { + if v_0.Op != OpAMD64VSUBPD512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VSUBPDMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSUBQ512 x y) mask) + // result: (VPSUBQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSUBQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMOVQB128_512 x) mask) + // result: (VPMOVQBMasked128_512 x mask) + for { + if v_0.Op != OpAMD64VPMOVQB128_512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVQBMasked128_512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPMOVQW128_512 x) mask) + // result: (VPMOVQWMasked128_512 x mask) + for { + if v_0.Op != OpAMD64VPMOVQW128_512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVQWMasked128_512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPXORQ512 x y) mask) + // result: (VPXORQMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPXORQ512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPXORQMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSLLQ512const [a] x) mask) + // result: (VPSLLQMasked512const [a] x mask) + for { + if v_0.Op != OpAMD64VPSLLQ512const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSLLQMasked512const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU64Masked512 (VPSRAQ512const [a] x) mask) + // result: (VPSRAQMasked512const [a] x mask) + for { + if v_0.Op != OpAMD64VPSRAQ512const { + break + } + a := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSRAQMasked512const) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU8Masked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU8Masked128 (VPABSB128 x) mask) + // result: (VPABSBMasked128 x mask) + for { + if v_0.Op != OpAMD64VPABSB128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSBMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPADDB128 x y) mask) + // result: (VPADDBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPADDB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPADDSB128 x y) mask) + // result: (VPADDSBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPADDSB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDSBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPADDUSB128 x y) mask) + // result: (VPADDUSBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPADDUSB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDUSBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPAVGB128 x y) mask) + // result: (VPAVGBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPAVGB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPAVGBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPBROADCASTB128 x) mask) + // result: (VPBROADCASTBMasked128 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTB128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTBMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPERMI2B128 x y z) mask) + // result: (VPERMI2BMasked128 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2B128 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2BMasked128) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPALIGNR128 [a] x y) mask) + // result: (VPALIGNRMasked128 [a] x y mask) + for { + if v_0.Op != OpAMD64VPALIGNR128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPALIGNRMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPMOVSXBQ128 x) mask) + // result: (VPMOVSXBQMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXBQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXBQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPMOVZXBQ128 x) mask) + // result: (VPMOVZXBQMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXBQ128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXBQMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPMOVSXBD128 x) mask) + // result: (VPMOVSXBDMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXBD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXBDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPMOVZXBD128 x) mask) + // result: (VPMOVZXBDMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXBD128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXBDMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPMOVSXBW128 x) mask) + // result: (VPMOVSXBWMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXBW128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXBWMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPMOVZXBW128 x) mask) + // result: (VPMOVZXBWMasked128 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXBW128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXBWMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked128 (VGF2P8AFFINEINVQB128 [a] x y) mask) + // result: (VGF2P8AFFINEINVQBMasked128 [a] x y mask) + for { + if v_0.Op != OpAMD64VGF2P8AFFINEINVQB128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VGF2P8AFFINEINVQBMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VGF2P8AFFINEQB128 [a] x y) mask) + // result: (VGF2P8AFFINEQBMasked128 [a] x y mask) + for { + if v_0.Op != OpAMD64VGF2P8AFFINEQB128 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VGF2P8AFFINEQBMasked128) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VGF2P8MULB128 x y) mask) + // result: (VGF2P8MULBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VGF2P8MULB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VGF2P8MULBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPMAXSB128 x y) mask) + // result: (VPMAXSBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPMAXUB128 x y) mask) + // result: (VPMAXUBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPMINSB128 x y) mask) + // result: (VPMINSBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMINSB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPMINUB128 x y) mask) + // result: (VPMINUBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPMINUB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPOPCNTB128 x) mask) + // result: (VPOPCNTBMasked128 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTB128 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTBMasked128) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPERMB128 x y) mask) + // result: (VPERMBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPERMB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPSHUFB128 x y) mask) + // result: (VPSHUFBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSHUFB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPSUBB128 x y) mask) + // result: (VPSUBBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSUBB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPSUBSB128 x y) mask) + // result: (VPSUBSBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSUBSB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBSBMasked128) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked128 (VPSUBUSB128 x y) mask) + // result: (VPSUBUSBMasked128 x y mask) + for { + if v_0.Op != OpAMD64VPSUBUSB128 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBUSBMasked128) + v.AddArg3(x, y, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU8Masked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU8Masked256 (VPABSB256 x) mask) + // result: (VPABSBMasked256 x mask) + for { + if v_0.Op != OpAMD64VPABSB256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSBMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPADDB256 x y) mask) + // result: (VPADDBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPADDB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPADDSB256 x y) mask) + // result: (VPADDSBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPADDSB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDSBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPADDUSB256 x y) mask) + // result: (VPADDUSBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPADDUSB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDUSBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPAVGB256 x y) mask) + // result: (VPAVGBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPAVGB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPAVGBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPBROADCASTB256 x) mask) + // result: (VPBROADCASTBMasked256 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTB256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTBMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPERMI2B256 x y z) mask) + // result: (VPERMI2BMasked256 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2B256 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2BMasked256) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPALIGNR256 [a] x y) mask) + // result: (VPALIGNRMasked256 [a] x y mask) + for { + if v_0.Op != OpAMD64VPALIGNR256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPALIGNRMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPMOVSXBQ256 x) mask) + // result: (VPMOVSXBQMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXBQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXBQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPMOVZXBQ256 x) mask) + // result: (VPMOVZXBQMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXBQ256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXBQMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPMOVSXBD256 x) mask) + // result: (VPMOVSXBDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXBD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXBDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPMOVZXBD256 x) mask) + // result: (VPMOVZXBDMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXBD256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXBDMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPMOVSXBW256 x) mask) + // result: (VPMOVSXBWMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXBW256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXBWMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPMOVZXBW256 x) mask) + // result: (VPMOVZXBWMasked256 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXBW256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXBWMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked256 (VGF2P8AFFINEINVQB256 [a] x y) mask) + // result: (VGF2P8AFFINEINVQBMasked256 [a] x y mask) + for { + if v_0.Op != OpAMD64VGF2P8AFFINEINVQB256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VGF2P8AFFINEINVQBMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VGF2P8AFFINEQB256 [a] x y) mask) + // result: (VGF2P8AFFINEQBMasked256 [a] x y mask) + for { + if v_0.Op != OpAMD64VGF2P8AFFINEQB256 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VGF2P8AFFINEQBMasked256) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VGF2P8MULB256 x y) mask) + // result: (VGF2P8MULBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VGF2P8MULB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VGF2P8MULBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPMAXSB256 x y) mask) + // result: (VPMAXSBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPMAXUB256 x y) mask) + // result: (VPMAXUBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPMINSB256 x y) mask) + // result: (VPMINSBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMINSB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPMINUB256 x y) mask) + // result: (VPMINUBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPMINUB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPOPCNTB256 x) mask) + // result: (VPOPCNTBMasked256 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTB256 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTBMasked256) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPERMB256 x y) mask) + // result: (VPERMBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPERMB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPSHUFB256 x y) mask) + // result: (VPSHUFBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSHUFB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPSUBB256 x y) mask) + // result: (VPSUBBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSUBB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPSUBSB256 x y) mask) + // result: (VPSUBSBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSUBSB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBSBMasked256) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked256 (VPSUBUSB256 x y) mask) + // result: (VPSUBUSBMasked256 x y mask) + for { + if v_0.Op != OpAMD64VPSUBUSB256 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBUSBMasked256) + v.AddArg3(x, y, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQU8Masked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQU8Masked512 (VPABSB512 x) mask) + // result: (VPABSBMasked512 x mask) + for { + if v_0.Op != OpAMD64VPABSB512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPABSBMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPADDB512 x y) mask) + // result: (VPADDBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPADDB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPADDSB512 x y) mask) + // result: (VPADDSBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPADDSB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDSBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPADDUSB512 x y) mask) + // result: (VPADDUSBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPADDUSB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPADDUSBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPAVGB512 x y) mask) + // result: (VPAVGBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPAVGB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPAVGBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPBROADCASTB512 x) mask) + // result: (VPBROADCASTBMasked512 x mask) + for { + if v_0.Op != OpAMD64VPBROADCASTB512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPBROADCASTBMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPERMI2B512 x y z) mask) + // result: (VPERMI2BMasked512 x y z mask) + for { + if v_0.Op != OpAMD64VPERMI2B512 { + break + } + z := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + mask := v_1 + v.reset(OpAMD64VPERMI2BMasked512) + v.AddArg4(x, y, z, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPALIGNR512 [a] x y) mask) + // result: (VPALIGNRMasked512 [a] x y mask) + for { + if v_0.Op != OpAMD64VPALIGNR512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPALIGNRMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPMOVSXBQ512 x) mask) + // result: (VPMOVSXBQMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXBQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXBQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPMOVZXBQ512 x) mask) + // result: (VPMOVZXBQMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXBQ512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXBQMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPMOVSXBW512 x) mask) + // result: (VPMOVSXBWMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXBW512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXBWMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPMOVSXBD512 x) mask) + // result: (VPMOVSXBDMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVSXBD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVSXBDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPMOVZXBW512 x) mask) + // result: (VPMOVZXBWMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXBW512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXBWMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPMOVZXBD512 x) mask) + // result: (VPMOVZXBDMasked512 x mask) + for { + if v_0.Op != OpAMD64VPMOVZXBD512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMOVZXBDMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked512 (VGF2P8AFFINEINVQB512 [a] x y) mask) + // result: (VGF2P8AFFINEINVQBMasked512 [a] x y mask) + for { + if v_0.Op != OpAMD64VGF2P8AFFINEINVQB512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VGF2P8AFFINEINVQBMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VGF2P8AFFINEQB512 [a] x y) mask) + // result: (VGF2P8AFFINEQBMasked512 [a] x y mask) + for { + if v_0.Op != OpAMD64VGF2P8AFFINEQB512 { + break + } + a := auxIntToUint8(v_0.AuxInt) + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VGF2P8AFFINEQBMasked512) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VGF2P8MULB512 x y) mask) + // result: (VGF2P8MULBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VGF2P8MULB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VGF2P8MULBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPMAXSB512 x y) mask) + // result: (VPMAXSBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMAXSB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXSBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPMAXUB512 x y) mask) + // result: (VPMAXUBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMAXUB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMAXUBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPMINSB512 x y) mask) + // result: (VPMINSBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMINSB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINSBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPMINUB512 x y) mask) + // result: (VPMINUBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPMINUB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPMINUBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPOPCNTB512 x) mask) + // result: (VPOPCNTBMasked512 x mask) + for { + if v_0.Op != OpAMD64VPOPCNTB512 { + break + } + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPOPCNTBMasked512) + v.AddArg2(x, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPERMB512 x y) mask) + // result: (VPERMBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPERMB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPERMBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPSHUFB512 x y) mask) + // result: (VPSHUFBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSHUFB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSHUFBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPSUBB512 x y) mask) + // result: (VPSUBBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSUBB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPSUBSB512 x y) mask) + // result: (VPSUBSBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSUBSB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBSBMasked512) + v.AddArg3(x, y, mask) + return true + } + // match: (VMOVDQU8Masked512 (VPSUBUSB512 x y) mask) + // result: (VPSUBUSBMasked512 x y mask) + for { + if v_0.Op != OpAMD64VPSUBUSB512 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + mask := v_1 + v.reset(OpAMD64VPSUBUSBMasked512) + v.AddArg3(x, y, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQUload128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQUload128 [off1] {sym} x:(ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (VMOVDQUload128 [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64VMOVDQUload128) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (VMOVDQUload128 [off1] {sym1} x:(LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (VMOVDQUload128 [off1+off2] {mergeSym(sym1, sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(x.AuxInt) + sym2 := auxToSym(x.Aux) + base := x.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64VMOVDQUload128) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQUload256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQUload256 [off1] {sym} x:(ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (VMOVDQUload256 [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64VMOVDQUload256) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (VMOVDQUload256 [off1] {sym1} x:(LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (VMOVDQUload256 [off1+off2] {mergeSym(sym1, sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(x.AuxInt) + sym2 := auxToSym(x.Aux) + base := x.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64VMOVDQUload256) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQUload512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQUload512 [off1] {sym} x:(ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (VMOVDQUload512 [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64VMOVDQUload512) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (VMOVDQUload512 [off1] {sym1} x:(LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (VMOVDQUload512 [off1+off2] {mergeSym(sym1, sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(x.AuxInt) + sym2 := auxToSym(x.Aux) + base := x.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64VMOVDQUload512) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQUstore128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQUstore128 [off1] {sym} x:(ADDQconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (VMOVDQUstore128 [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64VMOVDQUstore128) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (VMOVDQUstore128 [off1] {sym1} x:(LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (VMOVDQUstore128 [off1+off2] {mergeSym(sym1, sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(x.AuxInt) + sym2 := auxToSym(x.Aux) + base := x.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64VMOVDQUstore128) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQUstore256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQUstore256 [off1] {sym} x:(ADDQconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (VMOVDQUstore256 [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64VMOVDQUstore256) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (VMOVDQUstore256 [off1] {sym1} x:(LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (VMOVDQUstore256 [off1+off2] {mergeSym(sym1, sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(x.AuxInt) + sym2 := auxToSym(x.Aux) + base := x.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64VMOVDQUstore256) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVDQUstore512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMOVDQUstore512 [off1] {sym} x:(ADDQconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (VMOVDQUstore512 [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64VMOVDQUstore512) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (VMOVDQUstore512 [off1] {sym1} x:(LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (VMOVDQUstore512 [off1+off2] {mergeSym(sym1, sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + x := v_0 + if x.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(x.AuxInt) + sym2 := auxToSym(x.Aux) + base := x.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64VMOVDQUstore512) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVQ(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (VMOVQ x:(MOVQload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (VMOVQload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVQload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64VMOVQload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVSDf2v(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (VMOVSDf2v x:(MOVSDload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (VMOVSDload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVSDload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64VMOVSDload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (VMOVSDf2v x:(MOVSDconst [c] )) + // result: (VMOVSDconst [c] ) + for { + x := v_0 + if x.Op != OpAMD64MOVSDconst { + break + } + c := auxIntToFloat64(x.AuxInt) + v.reset(OpAMD64VMOVSDconst) + v.AuxInt = float64ToAuxInt(c) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMOVSSf2v(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (VMOVSSf2v x:(MOVSSload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (VMOVSSload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpAMD64MOVSSload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpAMD64VMOVSSload, v.Type) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (VMOVSSf2v x:(MOVSSconst [c] )) + // result: (VMOVSSconst [c] ) + for { + x := v_0 + if x.Op != OpAMD64MOVSSconst { + break + } + c := auxIntToFloat32(x.AuxInt) + v.reset(OpAMD64VMOVSSconst) + v.AuxInt = float32ToAuxInt(c) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VMULPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMULPD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMULPD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMULPD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMULPDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMULPDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMULPDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMULPDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMULPDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMULPDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMULPDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMULPDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMULPDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMULPDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMULPDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMULPDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMULPS512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMULPS512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMULPS512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMULPS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMULPSMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMULPSMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMULPSMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMULPSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMULPSMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMULPSMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMULPSMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMULPSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VMULPSMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VMULPSMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VMULPSMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VMULPSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPABSD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPABSD512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPABSD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPABSD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPABSDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPABSDMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPABSDMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPABSDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPABSDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPABSDMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPABSDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPABSDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPABSDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPABSDMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPABSDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPABSDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPABSQ128(v *Value) bool { + v_0 := v.Args[0] + // match: (VPABSQ128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPABSQ128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPABSQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPABSQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VPABSQ256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPABSQ256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPABSQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPABSQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPABSQ512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPABSQ512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPABSQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPABSQMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPABSQMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPABSQMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPABSQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPABSQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPABSQMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPABSQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPABSQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPABSQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPABSQMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPABSQMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPABSQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPACKSSDW512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPACKSSDW512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPACKSSDW512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPACKSSDW512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPACKSSDWMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPACKSSDWMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPACKSSDWMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPACKSSDWMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPACKSSDWMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPACKSSDWMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPACKSSDWMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPACKSSDWMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPACKSSDWMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPACKSSDWMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPACKSSDWMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPACKSSDWMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPACKUSDW512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPACKUSDW512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPACKUSDW512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPACKUSDW512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPACKUSDWMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPACKUSDWMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPACKUSDWMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPACKUSDWMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPACKUSDWMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPACKUSDWMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPACKUSDWMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPACKUSDWMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPACKUSDWMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPACKUSDWMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPACKUSDWMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPACKUSDWMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPADDD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPADDD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPADDD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPADDD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPADDDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPADDDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPADDDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPADDDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPADDDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPADDDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPADDDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPADDDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPADDDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPADDDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPADDDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPADDDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPADDQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPADDQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPADDQ512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPADDQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPADDQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPADDQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPADDQMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPADDQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPADDQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPADDQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPADDQMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPADDQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPADDQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPADDQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPADDQMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPADDQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPAND128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPAND128 x (VPMOVMToVec8x16 k)) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMOVDQU8Masked128 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec8x16 { + continue + } + k := v_1.Args[0] + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + continue + } + v.reset(OpAMD64VMOVDQU8Masked128) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPAND128 x (VPMOVMToVec16x8 k)) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMOVDQU16Masked128 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec16x8 { + continue + } + k := v_1.Args[0] + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + continue + } + v.reset(OpAMD64VMOVDQU16Masked128) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPAND128 x (VPMOVMToVec32x4 k)) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMOVDQU32Masked128 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec32x4 { + continue + } + k := v_1.Args[0] + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + continue + } + v.reset(OpAMD64VMOVDQU32Masked128) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPAND128 x (VPMOVMToVec64x2 k)) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMOVDQU64Masked128 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec64x2 { + continue + } + k := v_1.Args[0] + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + continue + } + v.reset(OpAMD64VMOVDQU64Masked128) + v.AddArg2(x, k) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPAND256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPAND256 x (VPMOVMToVec8x32 k)) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMOVDQU8Masked256 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec8x32 { + continue + } + k := v_1.Args[0] + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + continue + } + v.reset(OpAMD64VMOVDQU8Masked256) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPAND256 x (VPMOVMToVec16x16 k)) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMOVDQU16Masked256 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec16x16 { + continue + } + k := v_1.Args[0] + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + continue + } + v.reset(OpAMD64VMOVDQU16Masked256) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPAND256 x (VPMOVMToVec32x8 k)) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMOVDQU32Masked256 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec32x8 { + continue + } + k := v_1.Args[0] + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + continue + } + v.reset(OpAMD64VMOVDQU32Masked256) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPAND256 x (VPMOVMToVec64x4 k)) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMOVDQU64Masked256 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec64x4 { + continue + } + k := v_1.Args[0] + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + continue + } + v.reset(OpAMD64VMOVDQU64Masked256) + v.AddArg2(x, k) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDD512 x (VPMOVMToVec64x8 k)) + // result: (VMOVDQU64Masked512 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec64x8 { + continue + } + k := v_1.Args[0] + v.reset(OpAMD64VMOVDQU64Masked512) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPANDD512 x (VPMOVMToVec32x16 k)) + // result: (VMOVDQU32Masked512 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec32x16 { + continue + } + k := v_1.Args[0] + v.reset(OpAMD64VMOVDQU32Masked512) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPANDD512 x (VPMOVMToVec16x32 k)) + // result: (VMOVDQU16Masked512 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec16x32 { + continue + } + k := v_1.Args[0] + v.reset(OpAMD64VMOVDQU16Masked512) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPANDD512 x (VPMOVMToVec8x64 k)) + // result: (VMOVDQU8Masked512 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec8x64 { + continue + } + k := v_1.Args[0] + v.reset(OpAMD64VMOVDQU8Masked512) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPANDD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPANDD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPANDDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPANDDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPANDDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDND512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDND512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDND512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPANDND512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDNDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDNDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDNDMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPANDNDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDNDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDNDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDNDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPANDNDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDNDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDNDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDNDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPANDNDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDNQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDNQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDNQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPANDNQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDNQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDNQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDNQMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPANDNQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDNQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDNQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDNQMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPANDNQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDNQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDNQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDNQMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPANDNQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDQ512 x (VPMOVMToVec64x8 k)) + // result: (VMOVDQU64Masked512 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec64x8 { + continue + } + k := v_1.Args[0] + v.reset(OpAMD64VMOVDQU64Masked512) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPANDQ512 x (VPMOVMToVec32x16 k)) + // result: (VMOVDQU32Masked512 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec32x16 { + continue + } + k := v_1.Args[0] + v.reset(OpAMD64VMOVDQU32Masked512) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPANDQ512 x (VPMOVMToVec16x32 k)) + // result: (VMOVDQU16Masked512 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec16x32 { + continue + } + k := v_1.Args[0] + v.reset(OpAMD64VMOVDQU16Masked512) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPANDQ512 x (VPMOVMToVec8x64 k)) + // result: (VMOVDQU8Masked512 x k) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64VPMOVMToVec8x64 { + continue + } + k := v_1.Args[0] + v.reset(OpAMD64VMOVDQU8Masked512) + v.AddArg2(x, k) + return true + } + break + } + // match: (VPANDQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDQ512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPANDQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDQMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPANDQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDQMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPANDQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPANDQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPANDQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPANDQMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPANDQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPBLENDMBMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPBLENDMBMasked512 dst (VGF2P8MULB512 x y) mask) + // result: (VGF2P8MULBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VGF2P8MULB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VGF2P8MULBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPABSB512 x) mask) + // result: (VPABSBMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSB512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPABSBMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPADDB512 x y) mask) + // result: (VPADDBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPADDBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPADDSB512 x y) mask) + // result: (VPADDSBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDSB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPADDSBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPADDUSB512 x y) mask) + // result: (VPADDUSBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDUSB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPADDUSBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPALIGNR512 [a] x y) mask) + // result: (VPALIGNRMasked512Merging dst [a] x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPALIGNR512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPALIGNRMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPAVGB512 x y) mask) + // result: (VPAVGBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPAVGB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPAVGBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPMAXSB512 x y) mask) + // result: (VPMAXSBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMAXSBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPMAXUB512 x y) mask) + // result: (VPMAXUBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMAXUBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPMINSB512 x y) mask) + // result: (VPMINSBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMINSBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPMINUB512 x y) mask) + // result: (VPMINUBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMINUBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPOPCNTB512 x) mask) + // result: (VPOPCNTBMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTB512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPOPCNTBMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPSHUFB512 x y) mask) + // result: (VPSHUFBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSHUFBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPSUBB512 x y) mask) + // result: (VPSUBBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSUBBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPSUBSB512 x y) mask) + // result: (VPSUBSBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBSB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSUBSBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMBMasked512 dst (VPSUBUSB512 x y) mask) + // result: (VPSUBUSBMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBUSB512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSUBUSBMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBLENDMDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPBLENDMDMasked512 dst (VADDPS512 x y) mask) + // result: (VADDPSMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VADDPS512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VADDPSMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VCVTDQ2PS512 x) mask) + // result: (VCVTDQ2PSMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTDQ2PS512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTDQ2PSMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VCVTTPS2DQ512 x) mask) + // result: (VCVTTPS2DQMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPS2DQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTTPS2DQMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VCVTTPS2UDQ512 x) mask) + // result: (VCVTTPS2UDQMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPS2UDQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTTPS2UDQMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VCVTUDQ2PS512 x) mask) + // result: (VCVTUDQ2PSMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUDQ2PS512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTUDQ2PSMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VDIVPS512 x y) mask) + // result: (VDIVPSMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VDIVPS512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VDIVPSMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VMAXPS512 x y) mask) + // result: (VMAXPSMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VMAXPS512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VMAXPSMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VMINPS512 x y) mask) + // result: (VMINPSMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VMINPS512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VMINPSMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VMULPS512 x y) mask) + // result: (VMULPSMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VMULPS512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VMULPSMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPABSD512 x) mask) + // result: (VPABSDMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSD512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPABSDMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPACKSSDW512 x y) mask) + // result: (VPACKSSDWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPACKSSDW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPACKSSDWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPACKUSDW512 x y) mask) + // result: (VPACKUSDWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPACKUSDW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPACKUSDWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPADDD512 x y) mask) + // result: (VPADDDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPADDDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPANDD512 x y) mask) + // result: (VPANDDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPANDD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPANDDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPLZCNTD512 x) mask) + // result: (VPLZCNTDMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPLZCNTD512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPLZCNTDMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMAXSD512 x y) mask) + // result: (VPMAXSDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMAXSDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMAXUD512 x y) mask) + // result: (VPMAXUDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMAXUDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMINSD512 x y) mask) + // result: (VPMINSDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMINSDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMINUD512 x y) mask) + // result: (VPMINUDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMINUDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMOVDB128_512 x) mask) + // result: (VPMOVDBMasked128_512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVDB128_512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVDBMasked128_512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMOVDW256 x) mask) + // result: (VPMOVDWMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVDW256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVDWMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMOVSDB128_512 x) mask) + // result: (VPMOVSDBMasked128_512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSDB128_512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVSDBMasked128_512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMOVSDW256 x) mask) + // result: (VPMOVSDWMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSDW256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVSDWMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMOVUSDB128_512 x) mask) + // result: (VPMOVUSDBMasked128_512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSDB128_512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVUSDBMasked128_512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMOVUSDW256 x) mask) + // result: (VPMOVUSDWMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSDW256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVUSDWMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPMULLD512 x y) mask) + // result: (VPMULLDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULLD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMULLDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPOPCNTD512 x) mask) + // result: (VPOPCNTDMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTD512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPOPCNTDMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPORD512 x y) mask) + // result: (VPORDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPORD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPORDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPROLD512 [a] x) mask) + // result: (VPROLDMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLD512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPROLDMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPROLVD512 x y) mask) + // result: (VPROLVDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLVD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPROLVDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPRORD512 [a] x) mask) + // result: (VPRORDMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORD512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPRORDMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPRORVD512 x y) mask) + // result: (VPRORVDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORVD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPRORVDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPSHLDD512 [a] x y) mask) + // result: (VPSHLDDMasked512Merging dst [a] x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHLDD512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSHLDDMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPSHRDD512 [a] x y) mask) + // result: (VPSHRDDMasked512Merging dst [a] x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHRDD512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSHRDDMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPSHUFD512 [a] x) mask) + // result: (VPSHUFDMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFD512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSHUFDMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPSLLD512const [a] x) mask) + // result: (VPSLLDMasked512constMerging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLD512const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSLLDMasked512constMerging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPSLLVD512 x y) mask) + // result: (VPSLLVDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLVD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSLLVDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPSRAD512const [a] x) mask) + // result: (VPSRADMasked512constMerging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAD512const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSRADMasked512constMerging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPSRAVD512 x y) mask) + // result: (VPSRAVDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAVD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSRAVDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPSRLVD512 x y) mask) + // result: (VPSRLVDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRLVD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSRLVDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPSUBD512 x y) mask) + // result: (VPSUBDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSUBDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VPXORD512 x y) mask) + // result: (VPXORDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPXORD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPXORDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VRCP14PS512 x) mask) + // result: (VRCP14PSMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VRCP14PS512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VRCP14PSMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VREDUCEPS512 [a] x) mask) + // result: (VREDUCEPSMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VREDUCEPS512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VREDUCEPSMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VRNDSCALEPS512 [a] x) mask) + // result: (VRNDSCALEPSMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VRNDSCALEPS512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VRNDSCALEPSMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VRSQRT14PS512 x) mask) + // result: (VRSQRT14PSMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VRSQRT14PS512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VRSQRT14PSMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VSCALEFPS512 x y) mask) + // result: (VSCALEFPSMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VSCALEFPS512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VSCALEFPSMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VSQRTPS512 x) mask) + // result: (VSQRTPSMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VSQRTPS512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VSQRTPSMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMDMasked512 dst (VSUBPS512 x y) mask) + // result: (VSUBPSMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VSUBPS512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VSUBPSMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPBLENDMDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPBLENDMDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBLENDMQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPBLENDMQMasked512 dst (VADDPD512 x y) mask) + // result: (VADDPDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VADDPD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VADDPDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VCVTPD2PS256 x) mask) + // result: (VCVTPD2PSMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTPD2PS256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTPD2PSMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VCVTQQ2PD512 x) mask) + // result: (VCVTQQ2PDMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTQQ2PD512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTQQ2PDMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VCVTQQ2PS256 x) mask) + // result: (VCVTQQ2PSMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTQQ2PS256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTQQ2PSMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VCVTTPD2DQ256 x) mask) + // result: (VCVTTPD2DQMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2DQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTTPD2DQMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VCVTTPD2QQ512 x) mask) + // result: (VCVTTPD2QQMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2QQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTTPD2QQMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VCVTTPD2UDQ256 x) mask) + // result: (VCVTTPD2UDQMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2UDQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTTPD2UDQMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VCVTTPD2UQQ512 x) mask) + // result: (VCVTTPD2UQQMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2UQQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTTPD2UQQMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VCVTUQQ2PD512 x) mask) + // result: (VCVTUQQ2PDMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUQQ2PD512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTUQQ2PDMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VCVTUQQ2PS256 x) mask) + // result: (VCVTUQQ2PSMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUQQ2PS256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VCVTUQQ2PSMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VDIVPD512 x y) mask) + // result: (VDIVPDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VDIVPD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VDIVPDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VMAXPD512 x y) mask) + // result: (VMAXPDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VMAXPD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VMAXPDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VMINPD512 x y) mask) + // result: (VMINPDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VMINPD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VMINPDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VMULPD512 x y) mask) + // result: (VMULPDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VMULPD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VMULPDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPABSQ512 x) mask) + // result: (VPABSQMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPABSQMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPADDQ512 x y) mask) + // result: (VPADDQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPADDQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPANDQ512 x y) mask) + // result: (VPANDQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPANDQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPANDQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPLZCNTQ512 x) mask) + // result: (VPLZCNTQMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPLZCNTQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPLZCNTQMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMAXSQ512 x y) mask) + // result: (VPMAXSQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMAXSQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMAXUQ512 x y) mask) + // result: (VPMAXUQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMAXUQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMINSQ512 x y) mask) + // result: (VPMINSQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMINSQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMINUQ512 x y) mask) + // result: (VPMINUQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMINUQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMOVQB128_512 x) mask) + // result: (VPMOVQBMasked128_512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVQB128_512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVQBMasked128_512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMOVQD256 x) mask) + // result: (VPMOVQDMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVQD256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVQDMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMOVQW128_512 x) mask) + // result: (VPMOVQWMasked128_512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVQW128_512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVQWMasked128_512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMOVSQB128_512 x) mask) + // result: (VPMOVSQBMasked128_512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSQB128_512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVSQBMasked128_512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMOVSQD256 x) mask) + // result: (VPMOVSQDMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSQD256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVSQDMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMOVSQW128_512 x) mask) + // result: (VPMOVSQWMasked128_512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSQW128_512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVSQWMasked128_512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMOVUSQB128_512 x) mask) + // result: (VPMOVUSQBMasked128_512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSQB128_512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVUSQBMasked128_512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMOVUSQD256 x) mask) + // result: (VPMOVUSQDMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSQD256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVUSQDMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMOVUSQW128_512 x) mask) + // result: (VPMOVUSQWMasked128_512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSQW128_512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVUSQWMasked128_512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPMULLQ512 x y) mask) + // result: (VPMULLQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULLQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMULLQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPOPCNTQ512 x) mask) + // result: (VPOPCNTQMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPOPCNTQMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPORQ512 x y) mask) + // result: (VPORQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPORQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPORQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPROLQ512 [a] x) mask) + // result: (VPROLQMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLQ512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPROLQMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPROLVQ512 x y) mask) + // result: (VPROLVQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLVQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPROLVQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPRORQ512 [a] x) mask) + // result: (VPRORQMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORQ512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPRORQMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPRORVQ512 x y) mask) + // result: (VPRORVQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORVQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPRORVQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPSHLDQ512 [a] x y) mask) + // result: (VPSHLDQMasked512Merging dst [a] x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHLDQ512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSHLDQMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPSHRDQ512 [a] x y) mask) + // result: (VPSHRDQMasked512Merging dst [a] x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHRDQ512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSHRDQMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPSLLQ512const [a] x) mask) + // result: (VPSLLQMasked512constMerging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLQ512const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSLLQMasked512constMerging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPSLLVQ512 x y) mask) + // result: (VPSLLVQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLVQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSLLVQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPSRAQ512const [a] x) mask) + // result: (VPSRAQMasked512constMerging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAQ512const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSRAQMasked512constMerging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPSRAVQ512 x y) mask) + // result: (VPSRAVQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAVQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSRAVQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPSRLVQ512 x y) mask) + // result: (VPSRLVQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRLVQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSRLVQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPSUBQ512 x y) mask) + // result: (VPSUBQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSUBQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VPXORQ512 x y) mask) + // result: (VPXORQMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPXORQ512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPXORQMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VRCP14PD512 x) mask) + // result: (VRCP14PDMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VRCP14PD512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VRCP14PDMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VREDUCEPD512 [a] x) mask) + // result: (VREDUCEPDMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VREDUCEPD512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VREDUCEPDMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VRNDSCALEPD512 [a] x) mask) + // result: (VRNDSCALEPDMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VRNDSCALEPD512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VRNDSCALEPDMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VRSQRT14PD512 x) mask) + // result: (VRSQRT14PDMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VRSQRT14PD512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VRSQRT14PDMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VSCALEFPD512 x y) mask) + // result: (VSCALEFPDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VSCALEFPD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VSCALEFPDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VSQRTPD512 x) mask) + // result: (VSQRTPDMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VSQRTPD512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VSQRTPDMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMQMasked512 dst (VSUBPD512 x y) mask) + // result: (VSUBPDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VSUBPD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VSUBPDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPBLENDMQMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPBLENDMQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBLENDMWMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPBLENDMWMasked512 dst (VPABSW512 x) mask) + // result: (VPABSWMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSW512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPABSWMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPADDSW512 x y) mask) + // result: (VPADDSWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDSW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPADDSWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPADDUSW512 x y) mask) + // result: (VPADDUSWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDUSW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPADDUSWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPADDW512 x y) mask) + // result: (VPADDWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPADDWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPAVGW512 x y) mask) + // result: (VPAVGWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPAVGW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPAVGWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMADDUBSW512 x y) mask) + // result: (VPMADDUBSWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMADDUBSW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMADDUBSWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMADDWD512 x y) mask) + // result: (VPMADDWDMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMADDWD512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMADDWDMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMAXSW512 x y) mask) + // result: (VPMAXSWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMAXSWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMAXUW512 x y) mask) + // result: (VPMAXUWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMAXUWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMINSW512 x y) mask) + // result: (VPMINSWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMINSWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMINUW512 x y) mask) + // result: (VPMINUWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMINUWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMOVSWB256 x) mask) + // result: (VPMOVSWBMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSWB256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVSWBMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMOVUSWB256 x) mask) + // result: (VPMOVUSWBMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSWB256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVUSWBMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMOVWB256 x) mask) + // result: (VPMOVWBMasked256Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVWB256 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMOVWBMasked256Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMULHUW512 x y) mask) + // result: (VPMULHUWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULHUW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMULHUWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMULHW512 x y) mask) + // result: (VPMULHWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULHW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMULHWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPMULLW512 x y) mask) + // result: (VPMULLWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULLW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPMULLWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPOPCNTW512 x) mask) + // result: (VPOPCNTWMasked512Merging dst x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTW512 { + break + } + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPOPCNTWMasked512Merging) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSHLDW512 [a] x y) mask) + // result: (VPSHLDWMasked512Merging dst [a] x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHLDW512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSHLDWMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSHRDW512 [a] x y) mask) + // result: (VPSHRDWMasked512Merging dst [a] x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHRDW512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSHRDWMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSHUFHW512 [a] x) mask) + // result: (VPSHUFHWMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFHW512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSHUFHWMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSHUFLW512 [a] x) mask) + // result: (VPSHUFLWMasked512Merging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFLW512 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSHUFLWMasked512Merging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSLLVW512 x y) mask) + // result: (VPSLLVWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLVW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSLLVWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSLLW512const [a] x) mask) + // result: (VPSLLWMasked512constMerging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLW512const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSLLWMasked512constMerging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSRAVW512 x y) mask) + // result: (VPSRAVWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAVW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSRAVWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSRAW512const [a] x) mask) + // result: (VPSRAWMasked512constMerging dst [a] x mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAW512const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSRAWMasked512constMerging) + v.AuxInt = uint8ToAuxInt(a) + v.AddArg3(dst, x, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSRLVW512 x y) mask) + // result: (VPSRLVWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRLVW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSRLVWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSUBSW512 x y) mask) + // result: (VPSUBSWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBSW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSUBSWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSUBUSW512 x y) mask) + // result: (VPSUBUSWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBUSW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSUBUSWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + // match: (VPBLENDMWMasked512 dst (VPSUBW512 x y) mask) + // result: (VPSUBWMasked512Merging dst x y mask) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBW512 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + v.reset(OpAMD64VPSUBWMasked512Merging) + v.AddArg4(dst, x, y, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBLENDVB128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (VPBLENDVB128 dst (VADDPD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VADDPDMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VADDPD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VADDPDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VADDPS128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VADDPSMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VADDPS128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VADDPSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VBROADCASTSD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VBROADCASTSDMasked256Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VBROADCASTSD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VBROADCASTSDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VBROADCASTSD512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VBROADCASTSDMasked512Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VBROADCASTSD512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VBROADCASTSDMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VBROADCASTSS128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VBROADCASTSSMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VBROADCASTSS128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VBROADCASTSSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VBROADCASTSS256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VBROADCASTSSMasked256Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VBROADCASTSS256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VBROADCASTSSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VBROADCASTSS512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VBROADCASTSSMasked512Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VBROADCASTSS512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VBROADCASTSSMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTDQ2PD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTDQ2PDMasked256Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTDQ2PD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTDQ2PDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTDQ2PS128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTDQ2PSMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTDQ2PS128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTDQ2PSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTPD2PSX128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTPD2PSXMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTPD2PSX128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTPD2PSXMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTPS2PD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTPS2PDMasked256Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTPS2PD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTPS2PDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTQQ2PD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTQQ2PDMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTQQ2PD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTQQ2PDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTQQ2PSX128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTQQ2PSXMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTQQ2PSX128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTQQ2PSXMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTTPD2DQX128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPD2DQXMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2DQX128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPD2DQXMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTTPD2QQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPD2QQMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2QQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPD2QQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTTPD2UDQX128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPD2UDQXMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2UDQX128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPD2UDQXMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTTPD2UQQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPD2UQQMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2UQQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPD2UQQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTTPS2DQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPS2DQMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPS2DQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPS2DQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTTPS2QQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPS2QQMasked256Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPS2QQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPS2QQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTTPS2UDQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPS2UDQMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPS2UDQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPS2UDQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTTPS2UQQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPS2UQQMasked256Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPS2UQQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPS2UQQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTUDQ2PD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTUDQ2PDMasked256Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUDQ2PD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTUDQ2PDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTUDQ2PS128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTUDQ2PSMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUDQ2PS128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTUDQ2PSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTUQQ2PD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTUQQ2PDMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUQQ2PD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTUQQ2PDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VCVTUQQ2PSX128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTUQQ2PSXMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUQQ2PSX128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTUQQ2PSXMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VDIVPD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VDIVPDMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VDIVPD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VDIVPDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VDIVPS128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VDIVPSMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VDIVPS128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VDIVPSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VGF2P8MULB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VGF2P8MULBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VGF2P8MULB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VGF2P8MULBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VMAXPD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMAXPDMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMAXPD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMAXPDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VMAXPS128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMAXPSMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMAXPS128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMAXPSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VMINPD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMINPDMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMINPD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMINPDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VMINPS128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMINPSMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMINPS128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMINPSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VMULPD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMULPDMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMULPD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMULPDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VMULPS128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMULPSMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMULPS128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMULPSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPABSB128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPABSBMasked128Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSB128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPABSBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPABSD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPABSDMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPABSDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPABSQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPABSQMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPABSQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPABSW128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPABSWMasked128Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSW128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPABSWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPACKSSDW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPACKSSDWMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPACKSSDW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPACKSSDWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPACKUSDW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPACKUSDWMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPACKUSDW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPACKUSDWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPADDB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPADDD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPADDQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPADDSB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDSBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDSB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDSBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPADDSW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDSWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDSW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDSWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPADDUSB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDUSBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDUSB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDUSBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPADDUSW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDUSWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDUSW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDUSWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPADDW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPALIGNR128 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPALIGNRMasked128Merging dst [a] x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPALIGNR128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPALIGNRMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPAVGB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPAVGBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPAVGB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPAVGBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPAVGW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPAVGWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPAVGW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPAVGWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTB128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTBMasked128Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTB128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTB256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTBMasked256Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTB256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTB512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTBMasked512Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTB512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTBMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTDMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTDMasked256Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTD512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTDMasked512Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTD512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTDMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTQMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTQMasked256Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTQ512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTQMasked512Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTQMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTW128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTWMasked128Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTW128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTW256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTWMasked256Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTW256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPBROADCASTW512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPBROADCASTWMasked512Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPBROADCASTW512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPBROADCASTWMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPLZCNTD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPLZCNTDMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPLZCNTD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPLZCNTDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPLZCNTQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPLZCNTQMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPLZCNTQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPLZCNTQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMADDUBSW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMADDUBSWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMADDUBSW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMADDUBSWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMADDWD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMADDWDMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMADDWD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMADDWDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMAXSB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXSBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXSBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMAXSD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXSDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXSDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMAXSQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXSQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXSQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMAXSW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXSWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXSWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMAXUB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXUBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXUBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMAXUD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXUDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXUDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMAXUQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXUQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXUQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMAXUW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXUWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXUWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMINSB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINSBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINSBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMINSD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINSDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINSDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMINSQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINSQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINSQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMINSW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINSWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINSWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMINUB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINUBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINUBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMINUD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINUDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINUDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMINUQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINUQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINUQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMINUW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINUWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINUWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVDB128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVDBMasked128_128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVDB128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVDBMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVDW128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVDWMasked128_128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVDW128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVDWMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVQB128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVQBMasked128_128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVQB128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVQBMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVQD128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVQDMasked128_128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVQD128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVQDMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVQW128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVQWMasked128_128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVQW128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVQWMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSDB128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSDBMasked128_128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSDB128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSDBMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSDW128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSDWMasked128_128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSDW128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSDWMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSQB128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSQBMasked128_128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSQB128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSQBMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSQD128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSQDMasked128_128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSQD128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSQDMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSQW128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSQWMasked128_128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSQW128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSQWMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSWB128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSWBMasked128_128Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSWB128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSWBMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXBD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXBDMasked128Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXBD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXBDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXBD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXBDMasked256Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXBD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXBDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXBD512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXBDMasked512Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXBD512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXBDMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXBQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXBQMasked128Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXBQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXBQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXBQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXBQMasked256Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXBQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXBQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXBQ512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXBQMasked512Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXBQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXBQMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXBW128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXBWMasked128Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXBW128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXBWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXBW256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXBWMasked256Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXBW256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXBWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXDQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXDQMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXDQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXDQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXDQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXDQMasked256Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXDQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXDQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXWD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXWDMasked128Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXWD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXWDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXWD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXWDMasked256Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXWD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXWDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXWQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXWQMasked128Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXWQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXWQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXWQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXWQMasked256Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXWQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXWQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVSXWQ512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXWQMasked512Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXWQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXWQMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVUSDB128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSDBMasked128_128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSDB128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSDBMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVUSDW128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSDWMasked128_128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSDW128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSDWMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVUSQB128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSQBMasked128_128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSQB128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSQBMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVUSQD128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSQDMasked128_128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSQD128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSQDMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVUSQW128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSQWMasked128_128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSQW128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSQWMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVUSWB128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSWBMasked128_128Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSWB128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSWBMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVWB128_128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVWBMasked128_128Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVWB128_128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVWBMasked128_128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXBD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXBDMasked128Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXBD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXBDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXBD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXBDMasked256Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXBD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXBDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXBD512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXBDMasked512Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXBD512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXBDMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXBQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXBQMasked128Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXBQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXBQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXBQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXBQMasked256Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXBQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXBQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXBQ512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXBQMasked512Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXBQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXBQMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXBW128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXBWMasked128Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXBW128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXBWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXBW256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXBWMasked256Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXBW256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXBWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXDQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXDQMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXDQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXDQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXDQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXDQMasked256Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXDQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXDQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXWD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXWDMasked128Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXWD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXWDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXWD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXWDMasked256Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXWD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXWDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXWQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXWQMasked128Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXWQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXWQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXWQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXWQMasked256Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXWQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXWQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMOVZXWQ512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXWQMasked512Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXWQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXWQMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMULHUW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMULHUWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULHUW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMULHUWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMULHW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMULHWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULHW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMULHWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMULLD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMULLDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULLD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMULLDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMULLQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMULLQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULLQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMULLQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPMULLW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMULLWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULLW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMULLWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPOPCNTB128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPOPCNTBMasked128Merging dst x (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTB128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPOPCNTBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPOPCNTD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPOPCNTDMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPOPCNTDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPOPCNTQ128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPOPCNTQMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTQ128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPOPCNTQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPOPCNTW128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPOPCNTWMasked128Merging dst x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTW128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPOPCNTWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPROLD128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPROLDMasked128Merging dst [a] x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLD128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPROLDMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPROLQ128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPROLQMasked128Merging dst [a] x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLQ128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPROLQMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPROLVD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPROLVDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLVD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPROLVDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPROLVQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPROLVQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLVQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPROLVQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPRORD128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPRORDMasked128Merging dst [a] x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORD128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPRORDMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPRORQ128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPRORQMasked128Merging dst [a] x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORQ128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPRORQMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPRORVD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPRORVDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORVD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPRORVDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPRORVQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPRORVQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORVQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPRORVQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSHLDD128 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHLDDMasked128Merging dst [a] x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHLDD128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHLDDMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSHLDQ128 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHLDQMasked128Merging dst [a] x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHLDQ128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHLDQMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSHLDW128 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHLDWMasked128Merging dst [a] x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHLDW128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHLDWMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSHRDD128 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHRDDMasked128Merging dst [a] x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHRDD128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHRDDMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSHRDQ128 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHRDQMasked128Merging dst [a] x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHRDQ128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHRDQMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSHRDW128 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHRDWMasked128Merging dst [a] x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHRDW128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHRDWMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSHUFB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHUFBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHUFBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSHUFD128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHUFDMasked128Merging dst [a] x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFD128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHUFDMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSHUFHW128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHUFHWMasked128Merging dst [a] x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFHW128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHUFHWMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSHUFLW128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHUFLWMasked128Merging dst [a] x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFLW128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHUFLWMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSLLD128const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLDMasked128constMerging dst [a] x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLD128const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLDMasked128constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSLLQ128const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLQMasked128constMerging dst [a] x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLQ128const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLQMasked128constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSLLVD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLVDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLVD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLVDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSLLVQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLVQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLVQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLVQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSLLVW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLVWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLVW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLVWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSLLW128const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLWMasked128constMerging dst [a] x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLW128const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLWMasked128constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSRAD128const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRADMasked128constMerging dst [a] x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAD128const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRADMasked128constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSRAQ128const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRAQMasked128constMerging dst [a] x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAQ128const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRAQMasked128constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSRAVD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRAVDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAVD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRAVDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSRAVQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRAVQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAVQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRAVQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSRAVW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRAVWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAVW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRAVWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSRAW128const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRAWMasked128constMerging dst [a] x (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAW128const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRAWMasked128constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSRLVD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRLVDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRLVD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRLVDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSRLVQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRLVQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRLVQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRLVQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSRLVW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRLVWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRLVW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRLVWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSUBB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSUBD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBDMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSUBQ128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBQMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBQ128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBQMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSUBSB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBSBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBSB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBSBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSUBSW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBSWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBSW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBSWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSUBUSB128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBUSBMasked128Merging dst x y (VPMOVVec8x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBUSB128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBUSBMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSUBUSW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBUSWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBUSW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBUSWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VPSUBW128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBWMasked128Merging dst x y (VPMOVVec16x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBW128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBWMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VRCP14PD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VRCP14PDMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VRCP14PD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VRCP14PDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VREDUCEPD128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VREDUCEPDMasked128Merging dst [a] x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VREDUCEPD128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VREDUCEPDMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VREDUCEPS128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VREDUCEPSMasked128Merging dst [a] x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VREDUCEPS128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VREDUCEPSMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VRNDSCALEPD128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VRNDSCALEPDMasked128Merging dst [a] x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VRNDSCALEPD128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VRNDSCALEPDMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VRNDSCALEPS128 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VRNDSCALEPSMasked128Merging dst [a] x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VRNDSCALEPS128 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VRNDSCALEPSMasked128Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VRSQRT14PD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VRSQRT14PDMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VRSQRT14PD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VRSQRT14PDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VSCALEFPD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSCALEFPDMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSCALEFPD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSCALEFPDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VSCALEFPS128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSCALEFPSMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSCALEFPS128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSCALEFPSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VSQRTPD128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSQRTPDMasked128Merging dst x (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSQRTPD128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSQRTPDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VSQRTPS128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSQRTPSMasked128Merging dst x (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSQRTPS128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSQRTPSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB128 dst (VSUBPD128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSUBPDMasked128Merging dst x y (VPMOVVec64x2ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSUBPD128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSUBPDMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB128 dst (VSUBPS128 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSUBPSMasked128Merging dst x y (VPMOVVec32x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSUBPS128 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSUBPSMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBLENDVB256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (VPBLENDVB256 dst (VADDPD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VADDPDMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VADDPD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VADDPDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VADDPS256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VADDPSMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VADDPS256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VADDPSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTDQ2PD512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTDQ2PDMasked512Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTDQ2PD512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTDQ2PDMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTDQ2PS256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTDQ2PSMasked256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTDQ2PS256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTDQ2PSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTPD2PSY128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTPD2PSYMasked128Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTPD2PSY128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTPD2PSYMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTPS2PD512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTPS2PDMasked512Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTPS2PD512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTPS2PDMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTQQ2PD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTQQ2PDMasked256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTQQ2PD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTQQ2PDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTQQ2PSY128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTQQ2PSYMasked128Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTQQ2PSY128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTQQ2PSYMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTTPD2DQY128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPD2DQYMasked128Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2DQY128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPD2DQYMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTTPD2QQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPD2QQMasked256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2QQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPD2QQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTTPD2UDQY128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPD2UDQYMasked128Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2UDQY128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPD2UDQYMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTTPD2UQQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPD2UQQMasked256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPD2UQQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPD2UQQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTTPS2DQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPS2DQMasked256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPS2DQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPS2DQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTTPS2QQ512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPS2QQMasked512Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPS2QQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPS2QQMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTTPS2UDQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPS2UDQMasked256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPS2UDQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPS2UDQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTTPS2UQQ512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTTPS2UQQMasked512Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTTPS2UQQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTTPS2UQQMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTUDQ2PD512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTUDQ2PDMasked512Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUDQ2PD512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTUDQ2PDMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTUDQ2PS256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTUDQ2PSMasked256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUDQ2PS256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTUDQ2PSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTUQQ2PD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTUQQ2PDMasked256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUQQ2PD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTUQQ2PDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VCVTUQQ2PSY128 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VCVTUQQ2PSYMasked128Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VCVTUQQ2PSY128 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VCVTUQQ2PSYMasked128Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VDIVPD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VDIVPDMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VDIVPD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VDIVPDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VDIVPS256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VDIVPSMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VDIVPS256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VDIVPSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VGF2P8MULB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VGF2P8MULBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VGF2P8MULB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VGF2P8MULBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VMAXPD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMAXPDMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMAXPD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMAXPDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VMAXPS256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMAXPSMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMAXPS256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMAXPSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VMINPD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMINPDMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMINPD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMINPDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VMINPS256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMINPSMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMINPS256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMINPSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VMULPD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMULPDMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMULPD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMULPDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VMULPS256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VMULPSMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VMULPS256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VMULPSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPABSB256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPABSBMasked256Merging dst x (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSB256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPABSBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPABSD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPABSDMasked256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPABSDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPABSQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPABSQMasked256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPABSQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPABSW256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPABSWMasked256Merging dst x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPABSW256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPABSWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPACKSSDW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPACKSSDWMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPACKSSDW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPACKSSDWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPACKUSDW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPACKUSDWMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPACKUSDW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPACKUSDWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPADDB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPADDD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPADDQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPADDSB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDSBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDSB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDSBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPADDSW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDSWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDSW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDSWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPADDUSB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDUSBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDUSB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDUSBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPADDUSW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDUSWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDUSW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDUSWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPADDW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPADDWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPADDW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPADDWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPALIGNR256 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPALIGNRMasked256Merging dst [a] x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPALIGNR256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPALIGNRMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPAVGB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPAVGBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPAVGB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPAVGBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPAVGW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPAVGWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPAVGW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPAVGWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPLZCNTD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPLZCNTDMasked256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPLZCNTD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPLZCNTDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPLZCNTQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPLZCNTQMasked256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPLZCNTQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPLZCNTQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMADDUBSW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMADDUBSWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMADDUBSW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMADDUBSWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMADDWD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMADDWDMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMADDWD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMADDWDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMAXSB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXSBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXSBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMAXSD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXSDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXSDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMAXSQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXSQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXSQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMAXSW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXSWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXSW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXSWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMAXUB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXUBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXUBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMAXUD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXUDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXUDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMAXUQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXUQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXUQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMAXUW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMAXUWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMAXUW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMAXUWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMINSB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINSBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINSBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMINSD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINSDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINSDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMINSQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINSQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINSQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMINSW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINSWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINSW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINSWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMINUB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINUBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINUBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMINUD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINUDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINUDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMINUQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINUQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINUQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMINUW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMINUWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMINUW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMINUWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVDB128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVDBMasked128_256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVDB128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVDBMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVDW128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVDWMasked128_256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVDW128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVDWMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVQB128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVQBMasked128_256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVQB128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVQBMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVQD128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVQDMasked128_256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVQD128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVQDMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVQW128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVQWMasked128_256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVQW128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVQWMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVSDB128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSDBMasked128_256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSDB128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSDBMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVSDW128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSDWMasked128_256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSDW128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSDWMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVSQB128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSQBMasked128_256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSQB128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSQBMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVSQD128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSQDMasked128_256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSQD128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSQDMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVSQW128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSQWMasked128_256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSQW128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSQWMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVSWB128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSWBMasked128_256Merging dst x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSWB128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSWBMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVSXBW512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXBWMasked512Merging dst x (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXBW512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXBWMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVSXDQ512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXDQMasked512Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXDQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXDQMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVSXWD512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVSXWDMasked512Merging dst x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVSXWD512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVSXWDMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVUSDB128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSDBMasked128_256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSDB128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSDBMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVUSDW128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSDWMasked128_256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSDW128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSDWMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVUSQB128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSQBMasked128_256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSQB128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSQBMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVUSQD128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSQDMasked128_256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSQD128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSQDMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVUSQW128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSQWMasked128_256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSQW128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSQWMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVUSWB128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVUSWBMasked128_256Merging dst x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVUSWB128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVUSWBMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVWB128_256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVWBMasked128_256Merging dst x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVWB128_256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVWBMasked128_256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVZXBW512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXBWMasked512Merging dst x (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXBW512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXBWMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVZXDQ512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXDQMasked512Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXDQ512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXDQMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMOVZXWD512 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMOVZXWDMasked512Merging dst x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMOVZXWD512 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMOVZXWDMasked512Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMULHUW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMULHUWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULHUW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMULHUWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMULHW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMULHWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULHW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMULHWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMULLD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMULLDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULLD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMULLDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMULLQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMULLQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULLQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMULLQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPMULLW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPMULLWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPMULLW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPMULLWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPOPCNTB256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPOPCNTBMasked256Merging dst x (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTB256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPOPCNTBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPOPCNTD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPOPCNTDMasked256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPOPCNTDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPOPCNTQ256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPOPCNTQMasked256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTQ256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPOPCNTQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPOPCNTW256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPOPCNTWMasked256Merging dst x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPOPCNTW256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPOPCNTWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPROLD256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPROLDMasked256Merging dst [a] x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLD256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPROLDMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPROLQ256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPROLQMasked256Merging dst [a] x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLQ256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPROLQMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPROLVD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPROLVDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLVD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPROLVDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPROLVQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPROLVQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPROLVQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPROLVQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPRORD256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPRORDMasked256Merging dst [a] x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORD256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPRORDMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPRORQ256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPRORQMasked256Merging dst [a] x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORQ256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPRORQMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPRORVD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPRORVDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORVD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPRORVDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPRORVQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPRORVQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPRORVQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPRORVQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSHLDD256 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHLDDMasked256Merging dst [a] x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHLDD256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHLDDMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSHLDQ256 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHLDQMasked256Merging dst [a] x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHLDQ256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHLDQMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSHLDW256 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHLDWMasked256Merging dst [a] x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHLDW256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHLDWMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSHRDD256 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHRDDMasked256Merging dst [a] x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHRDD256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHRDDMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSHRDQ256 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHRDQMasked256Merging dst [a] x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHRDQ256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHRDQMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSHRDW256 [a] x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHRDWMasked256Merging dst [a] x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHRDW256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHRDWMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSHUFB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHUFBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHUFBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSHUFD256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHUFDMasked256Merging dst [a] x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFD256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHUFDMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSHUFHW256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHUFHWMasked256Merging dst [a] x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFHW256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHUFHWMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSHUFLW256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSHUFLWMasked256Merging dst [a] x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSHUFLW256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSHUFLWMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSLLD256const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLDMasked256constMerging dst [a] x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLD256const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLDMasked256constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSLLQ256const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLQMasked256constMerging dst [a] x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLQ256const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLQMasked256constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSLLVD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLVDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLVD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLVDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSLLVQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLVQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLVQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLVQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSLLVW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLVWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLVW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLVWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSLLW256const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSLLWMasked256constMerging dst [a] x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSLLW256const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSLLWMasked256constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSRAD256const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRADMasked256constMerging dst [a] x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAD256const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRADMasked256constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSRAQ256const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRAQMasked256constMerging dst [a] x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAQ256const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRAQMasked256constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSRAVD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRAVDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAVD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRAVDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSRAVQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRAVQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAVQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRAVQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSRAVW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRAVWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAVW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRAVWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSRAW256const [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRAWMasked256constMerging dst [a] x (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRAW256const { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRAWMasked256constMerging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSRLVD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRLVDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRLVD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRLVDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSRLVQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRLVQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRLVQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRLVQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSRLVW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSRLVWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSRLVW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSRLVWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSUBB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSUBD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBDMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSUBQ256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBQMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBQ256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBQMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSUBSB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBSBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBSB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBSBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSUBSW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBSWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBSW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBSWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSUBUSB256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBUSBMasked256Merging dst x y (VPMOVVec8x32ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBUSB256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBUSBMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSUBUSW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBUSWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBUSW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBUSWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VPSUBW256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VPSUBWMasked256Merging dst x y (VPMOVVec16x16ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VPSUBW256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VPSUBWMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VRCP14PD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VRCP14PDMasked256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VRCP14PD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VRCP14PDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VREDUCEPD256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VREDUCEPDMasked256Merging dst [a] x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VREDUCEPD256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VREDUCEPDMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VREDUCEPS256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VREDUCEPSMasked256Merging dst [a] x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VREDUCEPS256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VREDUCEPSMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VRNDSCALEPD256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VRNDSCALEPDMasked256Merging dst [a] x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VRNDSCALEPD256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VRNDSCALEPDMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VRNDSCALEPS256 [a] x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VRNDSCALEPSMasked256Merging dst [a] x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VRNDSCALEPS256 { + break + } + a := auxIntToUint8(v_1.AuxInt) + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VRNDSCALEPSMasked256Merging) + v.AuxInt = uint8ToAuxInt(a) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VRSQRT14PD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VRSQRT14PDMasked256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VRSQRT14PD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VRSQRT14PDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VSCALEFPD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSCALEFPDMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSCALEFPD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSCALEFPDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VSCALEFPS256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSCALEFPSMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSCALEFPS256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSCALEFPSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VSQRTPD256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSQRTPDMasked256Merging dst x (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSQRTPD256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSQRTPDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VSQRTPS256 x) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSQRTPSMasked256Merging dst x (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSQRTPS256 { + break + } + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSQRTPSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(dst, x, v0) + return true + } + // match: (VPBLENDVB256 dst (VSUBPD256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSUBPDMasked256Merging dst x y (VPMOVVec64x4ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSUBPD256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSUBPDMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + // match: (VPBLENDVB256 dst (VSUBPS256 x y) mask) + // cond: v.Block.CPUfeatures.hasFeature(CPUavx512) + // result: (VSUBPSMasked256Merging dst x y (VPMOVVec32x8ToM mask)) + for { + dst := v_0 + if v_1.Op != OpAMD64VSUBPS256 { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + mask := v_2 + if !(v.Block.CPUfeatures.hasFeature(CPUavx512)) { + break + } + v.reset(OpAMD64VSUBPSMasked256Merging) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(dst, x, y, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBROADCASTB128(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (VPBROADCASTB128 x:(VPINSRB128 [0] (Zero128 ) y)) + // cond: x.Uses == 1 + // result: (VPBROADCASTB128 (VMOVQ y)) + for { + x := v_0 + if x.Op != OpAMD64VPINSRB128 || auxIntToUint8(x.AuxInt) != 0 { + break + } + y := x.Args[1] + x_0 := x.Args[0] + if x_0.Op != OpAMD64Zero128 { + break + } + if !(x.Uses == 1) { + break + } + v.reset(OpAMD64VPBROADCASTB128) + v0 := b.NewValue0(v.Pos, OpAMD64VMOVQ, types.TypeVec128) + v0.AddArg(y) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBROADCASTB256(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (VPBROADCASTB256 x:(VPINSRB128 [0] (Zero128 ) y)) + // cond: x.Uses == 1 + // result: (VPBROADCASTB256 (VMOVQ y)) + for { + x := v_0 + if x.Op != OpAMD64VPINSRB128 || auxIntToUint8(x.AuxInt) != 0 { + break + } + y := x.Args[1] + x_0 := x.Args[0] + if x_0.Op != OpAMD64Zero128 { + break + } + if !(x.Uses == 1) { + break + } + v.reset(OpAMD64VPBROADCASTB256) + v0 := b.NewValue0(v.Pos, OpAMD64VMOVQ, types.TypeVec128) + v0.AddArg(y) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBROADCASTB512(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (VPBROADCASTB512 x:(VPINSRB128 [0] (Zero128 ) y)) + // cond: x.Uses == 1 + // result: (VPBROADCASTB512 (VMOVQ y)) + for { + x := v_0 + if x.Op != OpAMD64VPINSRB128 || auxIntToUint8(x.AuxInt) != 0 { + break + } + y := x.Args[1] + x_0 := x.Args[0] + if x_0.Op != OpAMD64Zero128 { + break + } + if !(x.Uses == 1) { + break + } + v.reset(OpAMD64VPBROADCASTB512) + v0 := b.NewValue0(v.Pos, OpAMD64VMOVQ, types.TypeVec128) + v0.AddArg(y) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBROADCASTW128(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (VPBROADCASTW128 x:(VPINSRW128 [0] (Zero128 ) y)) + // cond: x.Uses == 1 + // result: (VPBROADCASTW128 (VMOVQ y)) + for { + x := v_0 + if x.Op != OpAMD64VPINSRW128 || auxIntToUint8(x.AuxInt) != 0 { + break + } + y := x.Args[1] + x_0 := x.Args[0] + if x_0.Op != OpAMD64Zero128 { + break + } + if !(x.Uses == 1) { + break + } + v.reset(OpAMD64VPBROADCASTW128) + v0 := b.NewValue0(v.Pos, OpAMD64VMOVQ, types.TypeVec128) + v0.AddArg(y) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBROADCASTW256(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (VPBROADCASTW256 x:(VPINSRW128 [0] (Zero128 ) y)) + // cond: x.Uses == 1 + // result: (VPBROADCASTW256 (VMOVQ y)) + for { + x := v_0 + if x.Op != OpAMD64VPINSRW128 || auxIntToUint8(x.AuxInt) != 0 { + break + } + y := x.Args[1] + x_0 := x.Args[0] + if x_0.Op != OpAMD64Zero128 { + break + } + if !(x.Uses == 1) { + break + } + v.reset(OpAMD64VPBROADCASTW256) + v0 := b.NewValue0(v.Pos, OpAMD64VMOVQ, types.TypeVec128) + v0.AddArg(y) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPBROADCASTW512(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (VPBROADCASTW512 x:(VPINSRW128 [0] (Zero128 ) y)) + // cond: x.Uses == 1 + // result: (VPBROADCASTW512 (VMOVQ y)) + for { + x := v_0 + if x.Op != OpAMD64VPINSRW128 || auxIntToUint8(x.AuxInt) != 0 { + break + } + y := x.Args[1] + x_0 := x.Args[0] + if x_0.Op != OpAMD64Zero128 { + break + } + if !(x.Uses == 1) { + break + } + v.reset(OpAMD64VPBROADCASTW512) + v0 := b.NewValue0(v.Pos, OpAMD64VMOVQ, types.TypeVec128) + v0.AddArg(y) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPD512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPD512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPDMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPDMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPDMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPDMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPDMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPDMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPDMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPDMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPDMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPEQD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPEQD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPEQD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPCMPEQD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPEQQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPEQQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPEQQ512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPCMPEQQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPGTD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPGTD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPGTD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPGTD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPGTQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPGTQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPGTQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPGTQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPQ512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPQ512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPQ512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPQMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPQMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPQMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPQMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPQMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPQMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPQMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPQMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPQMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPUD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPUD512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPUD512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPUD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPUDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPUDMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPUDMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPUDMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPUDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPUDMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPUDMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPUDMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPUDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPUDMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPUDMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPUDMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPUQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPUQ512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPUQ512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPUQ512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPUQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPUQMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPUQMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPUQMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPUQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPUQMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPUQMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPUQMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPCMPUQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPCMPUQMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPCMPUQMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPCMPUQMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPDPWSSD512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPDPWSSD512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPDPWSSD512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPDPWSSD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPDPWSSDMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPDPWSSDMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPDPWSSDMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPDPWSSDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPDPWSSDMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPDPWSSDMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPDPWSSDMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPDPWSSDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPDPWSSDMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPDPWSSDMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPDPWSSDMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPDPWSSDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2D128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2D128 x y l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2D128load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2D128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2D256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2D256 x y l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2D256load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2D256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2D512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2D512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2D512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2D512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2DMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2DMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2DMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2DMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2DMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2DMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2DMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2DMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2DMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2DMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2DMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2DMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PD128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PD128 x y l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PD128load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PD256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PD256 x y l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PD256load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PD512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PD512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PD512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PDMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PDMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PDMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PDMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PDMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PDMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PDMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PDMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PDMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PS128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PS128 x y l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PS128load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PS128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PS256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PS256 x y l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PS256load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PS256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PS512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PS512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PS512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PSMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PSMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PSMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PSMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PSMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PSMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2PSMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2PSMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2PSMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2PSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2Q128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2Q128 x y l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2Q128load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2Q128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2Q256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2Q256 x y l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2Q256load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2Q256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2Q512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2Q512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2Q512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2Q512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2QMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2QMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2QMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2QMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2QMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2QMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2QMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2QMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMI2QMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMI2QMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMI2QMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMI2QMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMPD256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMPD256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMPD256load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMPD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMPD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMPD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMPD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMPDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMPDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMPDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMPDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMPDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMPDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMPDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMPDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMPS512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMPS512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMPS512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMPS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMPSMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMPSMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMPSMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMPSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMPSMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMPSMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMPSMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMPSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMQ256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMQ256load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMQMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPERMQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPERMQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPERMQMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPERMQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPINSRD128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPINSRD128 [0] (Zero128 ) y) + // cond: y.Type.IsFloat() + // result: (VMOVSSf2v y) + for { + if auxIntToUint8(v.AuxInt) != 0 || v_0.Op != OpAMD64Zero128 { + break + } + y := v_1 + if !(y.Type.IsFloat()) { + break + } + v.reset(OpAMD64VMOVSSf2v) + v.Type = types.TypeVec128 + v.AddArg(y) + return true + } + // match: (VPINSRD128 [0] (Zero128 ) y) + // cond: !y.Type.IsFloat() + // result: (VMOVD y) + for { + if auxIntToUint8(v.AuxInt) != 0 || v_0.Op != OpAMD64Zero128 { + break + } + y := v_1 + if !(!y.Type.IsFloat()) { + break + } + v.reset(OpAMD64VMOVD) + v.Type = types.TypeVec128 + v.AddArg(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPINSRQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPINSRQ128 [0] (Zero128 ) y) + // cond: y.Type.IsFloat() + // result: (VMOVSDf2v y) + for { + if auxIntToUint8(v.AuxInt) != 0 || v_0.Op != OpAMD64Zero128 { + break + } + y := v_1 + if !(y.Type.IsFloat()) { + break + } + v.reset(OpAMD64VMOVSDf2v) + v.Type = types.TypeVec128 + v.AddArg(y) + return true + } + // match: (VPINSRQ128 [0] (Zero128 ) y) + // cond: !y.Type.IsFloat() + // result: (VMOVQ y) + for { + if auxIntToUint8(v.AuxInt) != 0 || v_0.Op != OpAMD64Zero128 { + break + } + y := v_1 + if !(!y.Type.IsFloat()) { + break + } + v.reset(OpAMD64VMOVQ) + v.Type = types.TypeVec128 + v.AddArg(y) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTD128(v *Value) bool { + v_0 := v.Args[0] + // match: (VPLZCNTD128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTD128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VPLZCNTD256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTD256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPLZCNTD512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPLZCNTDMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTDMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPLZCNTDMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPLZCNTDMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTQ128(v *Value) bool { + v_0 := v.Args[0] + // match: (VPLZCNTQ128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTQ128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VPLZCNTQ256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTQ256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPLZCNTQ512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTQ512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTQMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPLZCNTQMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTQMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPLZCNTQMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPLZCNTQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPLZCNTQMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPLZCNTQMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPLZCNTQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXSD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXSD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXSD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXSD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXSDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXSDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXSDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXSDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXSDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXSDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXSDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXSDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXSDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXSDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXSDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXSDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXSQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXSQ128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXSQ128load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXSQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXSQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXSQ256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXSQ256load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXSQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXSQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXSQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXSQ512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXSQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXSQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXSQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXSQMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXSQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXSQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXSQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXSQMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXSQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXSQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXSQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXSQMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXSQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXUD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXUD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXUD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXUD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXUDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXUDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXUDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXUDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXUDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXUDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXUDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXUDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXUDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXUDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXUDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXUDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXUQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXUQ128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXUQ128load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXUQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXUQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXUQ256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXUQ256load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXUQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXUQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXUQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXUQ512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXUQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXUQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXUQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXUQMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXUQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXUQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXUQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXUQMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXUQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMAXUQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMAXUQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMAXUQMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMAXUQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINSD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINSD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINSD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINSD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINSDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINSDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINSDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINSDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINSDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINSDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINSDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINSDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINSDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINSDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINSDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINSDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINSQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINSQ128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINSQ128load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINSQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINSQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINSQ256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINSQ256load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINSQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINSQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINSQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINSQ512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINSQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINSQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINSQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINSQMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINSQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINSQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINSQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINSQMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINSQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINSQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINSQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINSQMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINSQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINUD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINUD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINUD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINUD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINUDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINUDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINUDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINUDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINUDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINUDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINUDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINUDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINUDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINUDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINUDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINUDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINUQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINUQ128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINUQ128load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINUQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINUQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINUQ256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINUQ256load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINUQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINUQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINUQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINUQ512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINUQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINUQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINUQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINUQMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINUQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINUQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINUQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINUQMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINUQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMINUQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMINUQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMINUQMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMINUQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec16x16ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec16x16ToM (VPMOVMToVec16x16 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec16x16 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec16x32ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec16x32ToM (VPMOVMToVec16x32 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec16x32 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec16x8ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec16x8ToM (VPMOVMToVec16x8 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec16x8 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec32x16ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec32x16ToM (VPMOVMToVec32x16 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec32x16 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec32x4ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec32x4ToM (VPMOVMToVec32x4 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec32x4 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec32x8ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec32x8ToM (VPMOVMToVec32x8 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec32x8 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec64x2ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec64x2ToM (VPMOVMToVec64x2 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec64x2 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec64x4ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec64x4ToM (VPMOVMToVec64x4 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec64x4 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec64x8ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec64x8ToM (VPMOVMToVec64x8 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec64x8 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec8x16ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec8x16ToM (VPMOVMToVec8x16 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec8x16 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec8x32ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec8x32ToM (VPMOVMToVec8x32 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec8x32 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMOVVec8x64ToM(v *Value) bool { + v_0 := v.Args[0] + // match: (VPMOVVec8x64ToM (VPMOVMToVec8x64 x)) + // result: x + for { + if v_0.Op != OpAMD64VPMOVMToVec8x64 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPMULLD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMULLD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMULLD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMULLD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMULLDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMULLDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMULLDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMULLDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMULLDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMULLDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMULLDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMULLDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMULLDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMULLDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMULLDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMULLDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMULLQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMULLQ128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMULLQ128load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMULLQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMULLQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMULLQ256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMULLQ256load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMULLQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMULLQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMULLQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMULLQ512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMULLQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMULLQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMULLQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMULLQMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMULLQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMULLQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMULLQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMULLQMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMULLQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPMULLQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPMULLQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPMULLQMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPMULLQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTD128(v *Value) bool { + v_0 := v.Args[0] + // match: (VPOPCNTD128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTD128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VPOPCNTD256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTD256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPOPCNTD512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPOPCNTDMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTDMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPOPCNTDMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPOPCNTDMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTQ128(v *Value) bool { + v_0 := v.Args[0] + // match: (VPOPCNTQ128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTQ128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VPOPCNTQ256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTQ256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPOPCNTQ512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTQ512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTQMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPOPCNTQMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTQMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPOPCNTQMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTQMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOPCNTQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPOPCNTQMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPOPCNTQMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPOPCNTQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPOR128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPOR128 (VCMPPS128 [3] x x) (VCMPPS128 [3] y y)) + // result: (VCMPPS128 [3] x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64VCMPPS128 || auxIntToUint8(v_0.AuxInt) != 3 { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpAMD64VCMPPS128 || auxIntToUint8(v_1.AuxInt) != 3 { + continue + } + y := v_1.Args[1] + if y != v_1.Args[0] { + continue + } + v.reset(OpAMD64VCMPPS128) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg2(x, y) + return true + } + break + } + // match: (VPOR128 (VCMPPD128 [3] x x) (VCMPPD128 [3] y y)) + // result: (VCMPPD128 [3] x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64VCMPPD128 || auxIntToUint8(v_0.AuxInt) != 3 { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpAMD64VCMPPD128 || auxIntToUint8(v_1.AuxInt) != 3 { + continue + } + y := v_1.Args[1] + if y != v_1.Args[0] { + continue + } + v.reset(OpAMD64VCMPPD128) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPOR256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPOR256 (VCMPPS256 [3] x x) (VCMPPS256 [3] y y)) + // result: (VCMPPS256 [3] x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64VCMPPS256 || auxIntToUint8(v_0.AuxInt) != 3 { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpAMD64VCMPPS256 || auxIntToUint8(v_1.AuxInt) != 3 { + continue + } + y := v_1.Args[1] + if y != v_1.Args[0] { + continue + } + v.reset(OpAMD64VCMPPS256) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg2(x, y) + return true + } + break + } + // match: (VPOR256 (VCMPPD256 [3] x x) (VCMPPD256 [3] y y)) + // result: (VCMPPD256 [3] x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64VCMPPD256 || auxIntToUint8(v_0.AuxInt) != 3 { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpAMD64VCMPPD256 || auxIntToUint8(v_1.AuxInt) != 3 { + continue + } + y := v_1.Args[1] + if y != v_1.Args[0] { + continue + } + v.reset(OpAMD64VCMPPD256) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPORD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (VPORD512 (VPMOVMToVec32x16 (VCMPPS512 [3] x x)) (VPMOVMToVec32x16 (VCMPPS512 [3] y y))) + // result: (VPMOVMToVec32x16 (VCMPPS512 [3] x y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64VPMOVMToVec32x16 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64VCMPPS512 || auxIntToUint8(v_0_0.AuxInt) != 3 { + continue + } + x := v_0_0.Args[1] + if x != v_0_0.Args[0] || v_1.Op != OpAMD64VPMOVMToVec32x16 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64VCMPPS512 || auxIntToUint8(v_1_0.AuxInt) != 3 { + continue + } + y := v_1_0.Args[1] + if y != v_1_0.Args[0] { + continue + } + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPS512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(3) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (VPORD512 (VPMOVMToVec64x8 (VCMPPD512 [3] x x)) (VPMOVMToVec64x8 (VCMPPD512 [3] y y))) + // result: (VPMOVMToVec64x8 (VCMPPD512 [3] x y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64VPMOVMToVec64x8 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64VCMPPD512 || auxIntToUint8(v_0_0.AuxInt) != 3 { + continue + } + x := v_0_0.Args[1] + if x != v_0_0.Args[0] || v_1.Op != OpAMD64VPMOVMToVec64x8 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAMD64VCMPPD512 || auxIntToUint8(v_1_0.AuxInt) != 3 { + continue + } + y := v_1_0.Args[1] + if y != v_1_0.Args[0] { + continue + } + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(3) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (VPORD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPORD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPORD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPORDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPORDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPORDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPORDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPORDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPORDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPORDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPORDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPORDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPORDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPORDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPORDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPORQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPORQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPORQ512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPORQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPORQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPORQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPORQMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPORQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPORQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPORQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPORQMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPORQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPORQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPORQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPORQMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPORQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLD128(v *Value) bool { + v_0 := v.Args[0] + // match: (VPROLD128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLD128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLD128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VPROLD256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLD256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLD256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPROLD512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLD512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLDMasked128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLDMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLDMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLDMasked256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLDMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLDMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLDMasked512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLDMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLDMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLQ128(v *Value) bool { + v_0 := v.Args[0] + // match: (VPROLQ128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLQ128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLQ128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VPROLQ256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLQ256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLQ256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPROLQ512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLQ512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLQ512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLQMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLQMasked128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLQMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLQMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLQMasked256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLQMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLQMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLQMasked512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLQMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLQMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVD128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVD128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVD128load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVD256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVD256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVD256load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVDMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVQ128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVQ128load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVQ256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVQ256load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVQMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVQMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPROLVQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPROLVQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPROLVQMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPROLVQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORD128(v *Value) bool { + v_0 := v.Args[0] + // match: (VPRORD128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORD128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORD128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VPRORD256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORD256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORD256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPRORD512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORD512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORDMasked128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORDMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORDMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORDMasked256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORDMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORDMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORDMasked512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORDMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORDMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORQ128(v *Value) bool { + v_0 := v.Args[0] + // match: (VPRORQ128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORQ128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORQ128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORQ256(v *Value) bool { + v_0 := v.Args[0] + // match: (VPRORQ256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORQ256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORQ256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORQ512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPRORQ512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORQ512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORQ512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORQMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORQMasked128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORQMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORQMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORQMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORQMasked256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORQMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORQMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORQMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORQMasked512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORQMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORQMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVD128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVD128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVD128load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVD256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVD256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVD256load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVDMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVQ128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVQ128load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVQ256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVQ256load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVQMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVQMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPRORVQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPRORVQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPRORVQMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPRORVQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDD128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDD128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDD128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDD128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDD256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDD256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDD256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDD256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDD512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDD512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDDMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDDMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDDMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDDMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDDMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDDMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDDMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDDMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDDMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDQ128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDQ128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDQ128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDQ256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDQ256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDQ256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDQ512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDQ512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDQ512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDQMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDQMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDQMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDQMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDQMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDQMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDQMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDQMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDQMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVD128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVD128 x y l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVD128load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVD256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVD256 x y l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVD256load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVD512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVD512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVD512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVDMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVDMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVDMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVDMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVDMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVDMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVDMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVDMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVDMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVQ128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVQ128 x y l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVQ128load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVQ256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVQ256 x y l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVQ256load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVQ512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVQ512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVQ512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVQMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVQMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVQMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVQMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVQMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVQMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHLDVQMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHLDVQMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHLDVQMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHLDVQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDD128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDD128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDD128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDD128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDD256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDD256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDD256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDD256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDD512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDD512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDDMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDDMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDDMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDDMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDDMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDDMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDDMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDDMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDDMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDQ128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDQ128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDQ128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDQ256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDQ256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDQ256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDQ512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDQ512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDQ512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDQMasked128 [c] x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDQMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDQMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDQMasked256 [c] x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDQMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDQMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDQMasked512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDQMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDQMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVD128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVD128 x y l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVD128load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVD256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVD256 x y l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVD256load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVD512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVD512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVD512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVDMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVDMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVDMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVDMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVDMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVDMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVDMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVDMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVDMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVQ128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVQ128 x y l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVQ128load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVQ256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVQ256 x y l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVQ256load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVQ512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVQ512 x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVQ512load {sym} [off] x y ptr mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVQMasked128(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVQMasked128 x y l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVQMasked128load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVQMasked256(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVQMasked256 x y l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVQMasked256load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHRDVQMasked512(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHRDVQMasked512 x y l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHRDVQMasked512load {sym} [off] x y ptr mask mem) + for { + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_3 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHRDVQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg5(x, y, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHUFD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VPSHUFD512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHUFD512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHUFD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHUFDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHUFDMasked128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHUFDMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHUFDMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHUFDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHUFDMasked256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHUFDMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHUFDMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSHUFDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSHUFDMasked512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSHUFDMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSHUFDMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLD128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLD128 x (MOVQconst [c])) + // result: (VPSLLD128const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSLLD128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLD256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLD256 x (MOVQconst [c])) + // result: (VPSLLD256const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSLLD256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLD512 x (MOVQconst [c])) + // result: (VPSLLD512const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSLLD512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLD512const(v *Value) bool { + v_0 := v.Args[0] + // match: (VPSLLD512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLD512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLD512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLDMasked128 x (MOVQconst [c]) mask) + // result: (VPSLLDMasked128const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSLLDMasked128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLDMasked128const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLDMasked128const [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLDMasked128constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLDMasked128constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLDMasked256 x (MOVQconst [c]) mask) + // result: (VPSLLDMasked256const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSLLDMasked256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLDMasked256const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLDMasked256const [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLDMasked256constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLDMasked256constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLDMasked512 x (MOVQconst [c]) mask) + // result: (VPSLLDMasked512const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSLLDMasked512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLDMasked512const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLDMasked512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLDMasked512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLDMasked512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLQ128 x (MOVQconst [c])) + // result: (VPSLLQ128const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSLLQ128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLQ256 x (MOVQconst [c])) + // result: (VPSLLQ256const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSLLQ256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLQ512 x (MOVQconst [c])) + // result: (VPSLLQ512const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSLLQ512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLQ512const(v *Value) bool { + v_0 := v.Args[0] + // match: (VPSLLQ512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLQ512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLQ512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLQMasked128 x (MOVQconst [c]) mask) + // result: (VPSLLQMasked128const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSLLQMasked128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLQMasked128const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLQMasked128const [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLQMasked128constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLQMasked128constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLQMasked256 x (MOVQconst [c]) mask) + // result: (VPSLLQMasked256const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSLLQMasked256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLQMasked256const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLQMasked256const [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLQMasked256constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLQMasked256constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLQMasked512 x (MOVQconst [c]) mask) + // result: (VPSLLQMasked512const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSLLQMasked512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLQMasked512const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLQMasked512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLQMasked512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLQMasked512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLVD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLVD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLVD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLVD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLVDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLVDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLVDMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLVDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLVDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLVDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLVDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLVDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLVDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLVDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLVDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLVDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLVQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLVQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLVQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLVQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLVQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLVQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLVQMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLVQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLVQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLVQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLVQMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLVQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLVQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLVQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSLLVQMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSLLVQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLW128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLW128 x (MOVQconst [c])) + // result: (VPSLLW128const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSLLW128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLW256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLW256 x (MOVQconst [c])) + // result: (VPSLLW256const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSLLW256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLW512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLW512 x (MOVQconst [c])) + // result: (VPSLLW512const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSLLW512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLWMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLWMasked128 x (MOVQconst [c]) mask) + // result: (VPSLLWMasked128const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSLLWMasked128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLWMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLWMasked256 x (MOVQconst [c]) mask) + // result: (VPSLLWMasked256const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSLLWMasked256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSLLWMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSLLWMasked512 x (MOVQconst [c]) mask) + // result: (VPSLLWMasked512const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSLLWMasked512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAD128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAD128 x (MOVQconst [c])) + // result: (VPSRAD128const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSRAD128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAD256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAD256 x (MOVQconst [c])) + // result: (VPSRAD256const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSRAD256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAD512 x (MOVQconst [c])) + // result: (VPSRAD512const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSRAD512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAD512const(v *Value) bool { + v_0 := v.Args[0] + // match: (VPSRAD512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAD512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAD512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRADMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRADMasked128 x (MOVQconst [c]) mask) + // result: (VPSRADMasked128const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSRADMasked128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRADMasked128const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRADMasked128const [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRADMasked128constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRADMasked128constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRADMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRADMasked256 x (MOVQconst [c]) mask) + // result: (VPSRADMasked256const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSRADMasked256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRADMasked256const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRADMasked256const [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRADMasked256constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRADMasked256constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRADMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRADMasked512 x (MOVQconst [c]) mask) + // result: (VPSRADMasked512const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSRADMasked512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRADMasked512const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRADMasked512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRADMasked512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRADMasked512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAQ128 x (MOVQconst [c])) + // result: (VPSRAQ128const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSRAQ128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQ128const(v *Value) bool { + v_0 := v.Args[0] + // match: (VPSRAQ128const [c] l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAQ128constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAQ128constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAQ256 x (MOVQconst [c])) + // result: (VPSRAQ256const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSRAQ256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQ256const(v *Value) bool { + v_0 := v.Args[0] + // match: (VPSRAQ256const [c] l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAQ256constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAQ256constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAQ512 x (MOVQconst [c])) + // result: (VPSRAQ512const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSRAQ512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQ512const(v *Value) bool { + v_0 := v.Args[0] + // match: (VPSRAQ512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAQ512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAQ512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAQMasked128 x (MOVQconst [c]) mask) + // result: (VPSRAQMasked128const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSRAQMasked128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQMasked128const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAQMasked128const [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAQMasked128constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAQMasked128constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAQMasked256 x (MOVQconst [c]) mask) + // result: (VPSRAQMasked256const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSRAQMasked256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQMasked256const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAQMasked256const [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAQMasked256constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAQMasked256constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAQMasked512 x (MOVQconst [c]) mask) + // result: (VPSRAQMasked512const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSRAQMasked512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAQMasked512const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAQMasked512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAQMasked512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAQMasked512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAVD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAVD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAVD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAVD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAVDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAVDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAVDMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAVDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAVDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAVDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAVDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAVDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAVDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAVDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAVDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAVDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAVQ128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAVQ128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAVQ128load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAVQ128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAVQ256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAVQ256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAVQ256load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAVQ256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAVQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAVQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAVQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAVQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAVQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAVQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAVQMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAVQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAVQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAVQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAVQMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAVQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAVQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAVQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRAVQMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRAVQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAW128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAW128 x (MOVQconst [c])) + // result: (VPSRAW128const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSRAW128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAW256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAW256 x (MOVQconst [c])) + // result: (VPSRAW256const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSRAW256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAW512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAW512 x (MOVQconst [c])) + // result: (VPSRAW512const [uint8(c)] x) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpAMD64VPSRAW512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAWMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAWMasked128 x (MOVQconst [c]) mask) + // result: (VPSRAWMasked128const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSRAWMasked128const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAWMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAWMasked256 x (MOVQconst [c]) mask) + // result: (VPSRAWMasked256const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSRAWMasked256const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRAWMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRAWMasked512 x (MOVQconst [c]) mask) + // result: (VPSRAWMasked512const [uint8(c)] x mask) + for { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mask := v_2 + v.reset(OpAMD64VPSRAWMasked512const) + v.AuxInt = uint8ToAuxInt(uint8(c)) + v.AddArg2(x, mask) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLD512const(v *Value) bool { + v_0 := v.Args[0] + // match: (VPSRLD512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLD512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLD512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLDMasked128const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLDMasked128const [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLDMasked128constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLDMasked128constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLDMasked256const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLDMasked256const [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLDMasked256constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLDMasked256constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLDMasked512const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLDMasked512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLDMasked512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLDMasked512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLQ512const(v *Value) bool { + v_0 := v.Args[0] + // match: (VPSRLQ512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLQ512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLQ512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLQMasked128const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLQMasked128const [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLQMasked128constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLQMasked128constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLQMasked256const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLQMasked256const [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLQMasked256constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLQMasked256constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLQMasked512const(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLQMasked512const [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLQMasked512constload {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLQMasked512constload) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLVD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLVD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLVD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLVD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLVDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLVDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLVDMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLVDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLVDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLVDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLVDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLVDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLVDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLVDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLVDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLVDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLVQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLVQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLVQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLVQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLVQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLVQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLVQMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLVQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLVQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLVQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLVQMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLVQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSRLVQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSRLVQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSRLVQMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSRLVQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSUBD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSUBD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSUBD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSUBD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSUBDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSUBDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSUBDMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSUBDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSUBDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSUBDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSUBDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSUBDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSUBDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSUBDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSUBDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSUBDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSUBQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSUBQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSUBQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSUBQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSUBQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSUBQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSUBQMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSUBQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSUBQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSUBQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSUBQMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSUBQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPSUBQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPSUBQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPSUBQMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPSUBQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPTERNLOGD128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPTERNLOGD128 [c] x y l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPTERNLOGD128load {sym} [makeValAndOff(int32(uint8(c)),off)] x y ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPTERNLOGD128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPTERNLOGD256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPTERNLOGD256 [c] x y l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPTERNLOGD256load {sym} [makeValAndOff(int32(uint8(c)),off)] x y ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPTERNLOGD256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPTERNLOGD512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPTERNLOGD512 [c] x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPTERNLOGD512load {sym} [makeValAndOff(int32(uint8(c)),off)] x y ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPTERNLOGD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPTERNLOGQ128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPTERNLOGQ128 [c] x y l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPTERNLOGQ128load {sym} [makeValAndOff(int32(uint8(c)),off)] x y ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPTERNLOGQ128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPTERNLOGQ256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPTERNLOGQ256 [c] x y l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPTERNLOGQ256load {sym} [makeValAndOff(int32(uint8(c)),off)] x y ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPTERNLOGQ256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPTERNLOGQ512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPTERNLOGQ512 [c] x y l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPTERNLOGQ512load {sym} [makeValAndOff(int32(uint8(c)),off)] x y ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + y := v_1 + l := v_2 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPTERNLOGQ512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg4(x, y, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPUNPCKHDQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPUNPCKHDQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPUNPCKHDQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPUNPCKHDQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPUNPCKHQDQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPUNPCKHQDQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPUNPCKHQDQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPUNPCKHQDQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPUNPCKLDQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPUNPCKLDQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPUNPCKLDQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPUNPCKLDQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPUNPCKLQDQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPUNPCKLQDQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPUNPCKLQDQ512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VPUNPCKLQDQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VPXORD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPXORD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPXORD512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPXORD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPXORDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPXORDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPXORDMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPXORDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPXORDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPXORDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPXORDMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPXORDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPXORDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPXORDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPXORDMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPXORDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPXORQ512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPXORQ512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPXORQ512load {sym} [off] x ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPXORQ512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPXORQMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPXORQMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPXORQMasked128load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPXORQMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPXORQMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPXORQMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPXORQMasked256load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPXORQMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VPXORQMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VPXORQMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VPXORQMasked512load {sym} [off] x ptr mask mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + continue + } + v.reset(OpAMD64VPXORQMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64VRCP14PD128(v *Value) bool { + v_0 := v.Args[0] + // match: (VRCP14PD128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRCP14PD128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRCP14PD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRCP14PD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VRCP14PD256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRCP14PD256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRCP14PD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRCP14PD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VRCP14PD512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRCP14PD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRCP14PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRCP14PDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRCP14PDMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRCP14PDMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRCP14PDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRCP14PDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRCP14PDMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRCP14PDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRCP14PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRCP14PDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRCP14PDMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRCP14PDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRCP14PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRCP14PS512(v *Value) bool { + v_0 := v.Args[0] + // match: (VRCP14PS512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRCP14PS512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRCP14PS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRCP14PSMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRCP14PSMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRCP14PSMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRCP14PSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRCP14PSMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRCP14PSMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRCP14PSMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRCP14PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRCP14PSMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRCP14PSMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRCP14PSMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRCP14PSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPD128(v *Value) bool { + v_0 := v.Args[0] + // match: (VREDUCEPD128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPD128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPD128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VREDUCEPD256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPD256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPD256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VREDUCEPD512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPD512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VREDUCEPDMasked128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPDMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPDMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VREDUCEPDMasked256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPDMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPDMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VREDUCEPDMasked512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPDMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPDMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPS128(v *Value) bool { + v_0 := v.Args[0] + // match: (VREDUCEPS128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPS128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPS128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPS256(v *Value) bool { + v_0 := v.Args[0] + // match: (VREDUCEPS256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPS256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPS256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPS512(v *Value) bool { + v_0 := v.Args[0] + // match: (VREDUCEPS512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPS512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPS512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPSMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VREDUCEPSMasked128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPSMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPSMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPSMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VREDUCEPSMasked256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPSMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPSMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VREDUCEPSMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VREDUCEPSMasked512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VREDUCEPSMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VREDUCEPSMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPD128(v *Value) bool { + v_0 := v.Args[0] + // match: (VRNDSCALEPD128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPD128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPD128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VRNDSCALEPD256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPD256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPD256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VRNDSCALEPD512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPD512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRNDSCALEPDMasked128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPDMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPDMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRNDSCALEPDMasked256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPDMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPDMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRNDSCALEPDMasked512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPDMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPDMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPS128(v *Value) bool { + v_0 := v.Args[0] + // match: (VRNDSCALEPS128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPS128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPS128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPS256(v *Value) bool { + v_0 := v.Args[0] + // match: (VRNDSCALEPS256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPS256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPS256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPS512(v *Value) bool { + v_0 := v.Args[0] + // match: (VRNDSCALEPS512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPS512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPS512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPSMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRNDSCALEPSMasked128 [c] l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPSMasked128load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPSMasked128load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPSMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRNDSCALEPSMasked256 [c] l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPSMasked256load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPSMasked256load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRNDSCALEPSMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRNDSCALEPSMasked512 [c] l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRNDSCALEPSMasked512load {sym} [makeValAndOff(int32(uint8(c)),off)] ptr mask mem) + for { + c := auxIntToUint8(v.AuxInt) + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRNDSCALEPSMasked512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRSQRT14PD128(v *Value) bool { + v_0 := v.Args[0] + // match: (VRSQRT14PD128 l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRSQRT14PD128load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRSQRT14PD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRSQRT14PD256(v *Value) bool { + v_0 := v.Args[0] + // match: (VRSQRT14PD256 l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRSQRT14PD256load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRSQRT14PD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRSQRT14PD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VRSQRT14PD512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRSQRT14PD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRSQRT14PD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRSQRT14PDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRSQRT14PDMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRSQRT14PDMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRSQRT14PDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRSQRT14PDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRSQRT14PDMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRSQRT14PDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRSQRT14PDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRSQRT14PDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRSQRT14PDMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRSQRT14PDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRSQRT14PDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRSQRT14PS512(v *Value) bool { + v_0 := v.Args[0] + // match: (VRSQRT14PS512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRSQRT14PS512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRSQRT14PS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRSQRT14PSMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRSQRT14PSMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRSQRT14PSMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRSQRT14PSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRSQRT14PSMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRSQRT14PSMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRSQRT14PSMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRSQRT14PSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VRSQRT14PSMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VRSQRT14PSMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VRSQRT14PSMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VRSQRT14PSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPD128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPD128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPD128load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPD128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPD256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPD256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPD256load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPD256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPDMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPS128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPS128 x l:(VMOVDQUload128 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPS128load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPS128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPS256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPS256 x l:(VMOVDQUload256 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPS256load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPS256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPS512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPS512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPS512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPSMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPSMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPSMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPSMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPSMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPSMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSCALEFPSMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSCALEFPSMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSCALEFPSMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSCALEFPSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSHUFPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSHUFPD512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSHUFPD512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSHUFPD512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSHUFPS512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSHUFPS512 [c] x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSHUFPS512load {sym} [makeValAndOff(int32(uint8(c)),off)] x ptr mem) + for { + c := auxIntToUint8(v.AuxInt) + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSHUFPS512load) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(uint8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSQRTPD512(v *Value) bool { + v_0 := v.Args[0] + // match: (VSQRTPD512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSQRTPD512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSQRTPD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSQRTPDMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSQRTPDMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSQRTPDMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSQRTPDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSQRTPDMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSQRTPDMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSQRTPDMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSQRTPDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSQRTPDMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSQRTPDMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSQRTPDMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSQRTPDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSQRTPS512(v *Value) bool { + v_0 := v.Args[0] + // match: (VSQRTPS512 l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSQRTPS512load {sym} [off] ptr mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSQRTPS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSQRTPSMasked128(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSQRTPSMasked128 l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSQRTPSMasked128load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSQRTPSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSQRTPSMasked256(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSQRTPSMasked256 l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSQRTPSMasked256load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSQRTPSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSQRTPSMasked512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSQRTPSMasked512 l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSQRTPSMasked512load {sym} [off] ptr mask mem) + for { + l := v_0 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_1 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSQRTPSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSUBPD512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSUBPD512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSUBPD512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSUBPD512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSUBPDMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSUBPDMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSUBPDMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSUBPDMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSUBPDMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSUBPDMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSUBPDMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSUBPDMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSUBPDMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSUBPDMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSUBPDMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSUBPDMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSUBPS512(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSUBPS512 x l:(VMOVDQUload512 {sym} [off] ptr mem)) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSUBPS512load {sym} [off] x ptr mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSUBPS512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSUBPSMasked128(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSUBPSMasked128 x l:(VMOVDQUload128 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSUBPSMasked128load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload128 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSUBPSMasked128load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSUBPSMasked256(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSUBPSMasked256 x l:(VMOVDQUload256 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSUBPSMasked256load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload256 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSUBPSMasked256load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64VSUBPSMasked512(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (VSUBPSMasked512 x l:(VMOVDQUload512 {sym} [off] ptr mem) mask) + // cond: canMergeLoad(v, l) && clobber(l) + // result: (VSUBPSMasked512load {sym} [off] x ptr mask mem) + for { + x := v_0 + l := v_1 + if l.Op != OpAMD64VMOVDQUload512 { + break + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + mask := v_2 + if !(canMergeLoad(v, l) && clobber(l)) { + break + } + v.reset(OpAMD64VSUBPSMasked512load) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(x, ptr, mask, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XADDLlock(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XADDLlock [off1] {sym} val (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (XADDLlock [off1+off2] {sym} val ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64XADDLlock) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XADDQlock(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XADDQlock [off1] {sym} val (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (XADDQlock [off1+off2] {sym} val ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64XADDQlock) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XCHGL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XCHGL [off1] {sym} val (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (XCHGL [off1+off2] {sym} val ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64XCHGL) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, ptr, mem) + return true + } + // match: (XCHGL [off1] {sym1} val (LEAQ [off2] {sym2} ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && ptr.Op != OpSB + // result: (XCHGL [off1+off2] {mergeSym(sym1,sym2)} val ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && ptr.Op != OpSB) { + break + } + v.reset(OpAMD64XCHGL) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XCHGQ(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XCHGQ [off1] {sym} val (ADDQconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (XCHGQ [off1+off2] {sym} val ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64XCHGQ) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, ptr, mem) + return true + } + // match: (XCHGQ [off1] {sym1} val (LEAQ [off2] {sym2} ptr) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && ptr.Op != OpSB + // result: (XCHGQ [off1+off2] {mergeSym(sym1,sym2)} val ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && ptr.Op != OpSB) { + break + } + v.reset(OpAMD64XCHGQ) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XORL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XORL (SHLL (MOVLconst [1]) y) x) + // result: (BTCL x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64SHLL { + continue + } + y := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_0_0.AuxInt) != 1 { + continue + } + x := v_1 + v.reset(OpAMD64BTCL) + v.AddArg2(x, y) + return true + } + break + } + // match: (XORL x (MOVLconst [c])) + // result: (XORLconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpAMD64XORLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (XORL x x) + // result: (MOVLconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (XORL x l:(MOVLload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (XORLload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVLload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64XORLload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (XORL x (ADDLconst [-1] x)) + // cond: buildcfg.GOAMD64 >= 3 + // result: (BLSMSKL x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64ADDLconst || auxIntToInt32(v_1.AuxInt) != -1 || x != v_1.Args[0] || !(buildcfg.GOAMD64 >= 3) { + continue + } + v.reset(OpAMD64BLSMSKL) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64XORLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORLconst [1] (SETNE x)) + // result: (SETEQ x) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpAMD64SETNE { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETEQ) + v.AddArg(x) + return true + } + // match: (XORLconst [1] (SETEQ x)) + // result: (SETNE x) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpAMD64SETEQ { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETNE) + v.AddArg(x) + return true + } + // match: (XORLconst [1] (SETL x)) + // result: (SETGE x) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpAMD64SETL { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETGE) + v.AddArg(x) + return true + } + // match: (XORLconst [1] (SETGE x)) + // result: (SETL x) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpAMD64SETGE { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETL) + v.AddArg(x) + return true + } + // match: (XORLconst [1] (SETLE x)) + // result: (SETG x) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpAMD64SETLE { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETG) + v.AddArg(x) + return true + } + // match: (XORLconst [1] (SETG x)) + // result: (SETLE x) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpAMD64SETG { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETLE) + v.AddArg(x) + return true + } + // match: (XORLconst [1] (SETB x)) + // result: (SETAE x) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpAMD64SETB { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETAE) + v.AddArg(x) + return true + } + // match: (XORLconst [1] (SETAE x)) + // result: (SETB x) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpAMD64SETAE { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETB) + v.AddArg(x) + return true + } + // match: (XORLconst [1] (SETBE x)) + // result: (SETA x) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpAMD64SETBE { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETA) + v.AddArg(x) + return true + } + // match: (XORLconst [1] (SETA x)) + // result: (SETBE x) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpAMD64SETA { + break + } + x := v_0.Args[0] + v.reset(OpAMD64SETBE) + v.AddArg(x) + return true + } + // match: (XORLconst [c] (XORLconst [d] x)) + // result: (XORLconst [c ^ d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64XORLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64XORLconst) + v.AuxInt = int32ToAuxInt(c ^ d) + v.AddArg(x) + return true + } + // match: (XORLconst [c] x) + // cond: c==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c == 0) { + break + } + v.copyOf(x) + return true + } + // match: (XORLconst [c] (MOVLconst [d])) + // result: (MOVLconst [c^d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(c ^ d) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XORLconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XORLconstmodify [valoff1] {sym} (ADDQconst [off2] base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) + // result: (XORLconstmodify [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2)) { + break + } + v.reset(OpAMD64XORLconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (XORLconstmodify [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) + // result: (XORLconstmodify [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64XORLconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XORLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (XORLload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (XORLload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64XORLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (XORLload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (XORLload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64XORLload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (XORLload x [off] {sym} ptr (MOVSSstore [off] {sym} ptr y _)) + // result: (XORL x (MOVLf2i y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVSSstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64XORL) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVLf2i, typ.UInt32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XORLmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XORLmodify [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (XORLmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64XORLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (XORLmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (XORLmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64XORLmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XORQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XORQ (SHLQ (MOVQconst [1]) y) x) + // result: (BTCQ x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64SHLQ { + continue + } + y := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + continue + } + x := v_1 + v.reset(OpAMD64BTCQ) + v.AddArg2(x, y) + return true + } + break + } + // match: (XORQ (MOVQconst [c]) x) + // cond: isUnsignedPowerOfTwo(uint64(c)) && uint64(c) >= 1<<31 + // result: (BTCQconst [int8(log64u(uint64(c)))] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(isUnsignedPowerOfTwo(uint64(c)) && uint64(c) >= 1<<31) { + continue + } + v.reset(OpAMD64BTCQconst) + v.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) + v.AddArg(x) + return true + } + break + } + // match: (XORQ x (MOVQconst [c])) + // cond: is32Bit(c) + // result: (XORQconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpAMD64XORQconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (XORQ x x) + // result: (MOVQconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (XORQ x l:(MOVQload [off] {sym} ptr mem)) + // cond: canMergeLoadClobber(v, l, x) && clobber(l) + // result: (XORQload x [off] {sym} ptr mem) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + l := v_1 + if l.Op != OpAMD64MOVQload { + continue + } + off := auxIntToInt32(l.AuxInt) + sym := auxToSym(l.Aux) + mem := l.Args[1] + ptr := l.Args[0] + if !(canMergeLoadClobber(v, l, x) && clobber(l)) { + continue + } + v.reset(OpAMD64XORQload) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (XORQ x (ADDQconst [-1] x)) + // cond: buildcfg.GOAMD64 >= 3 + // result: (BLSMSKQ x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAMD64ADDQconst || auxIntToInt32(v_1.AuxInt) != -1 || x != v_1.Args[0] || !(buildcfg.GOAMD64 >= 3) { + continue + } + v.reset(OpAMD64BLSMSKQ) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueAMD64_OpAMD64XORQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORQconst [c] (XORQconst [d] x)) + // result: (XORQconst [c ^ d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64XORQconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpAMD64XORQconst) + v.AuxInt = int32ToAuxInt(c ^ d) + v.AddArg(x) + return true + } + // match: (XORQconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (XORQconst [c] (MOVQconst [d])) + // result: (MOVQconst [int64(c)^d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpAMD64MOVQconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(int64(c) ^ d) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XORQconstmodify(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XORQconstmodify [valoff1] {sym} (ADDQconst [off2] base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) + // result: (XORQconstmodify [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2)) { + break + } + v.reset(OpAMD64XORQconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (XORQconstmodify [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) + // cond: ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) + // result: (XORQconstmodify [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) + for { + valoff1 := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64XORQconstmodify) + v.AuxInt = valAndOffToAuxInt(ValAndOff(valoff1).addOffset32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XORQload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (XORQload [off1] {sym} val (ADDQconst [off2] base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (XORQload [off1+off2] {sym} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64XORQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(val, base, mem) + return true + } + // match: (XORQload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (XORQload [off1+off2] {mergeSym(sym1,sym2)} val base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + val := v_0 + if v_1.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + base := v_1.Args[0] + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64XORQload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(val, base, mem) + return true + } + // match: (XORQload x [off] {sym} ptr (MOVSDstore [off] {sym} ptr y _)) + // result: (XORQ x (MOVQf2i y)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr := v_1 + if v_2.Op != OpAMD64MOVSDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + if ptr != v_2.Args[0] { + break + } + v.reset(OpAMD64XORQ) + v0 := b.NewValue0(v_2.Pos, OpAMD64MOVQf2i, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpAMD64XORQmodify(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XORQmodify [off1] {sym} (ADDQconst [off2] base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) + // result: (XORQmodify [off1+off2] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpAMD64ADDQconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpAMD64XORQmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (XORQmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (XORQmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpAMD64LEAQ { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpAMD64XORQmodify) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpAddr(v *Value) bool { + v_0 := v.Args[0] + // match: (Addr {sym} base) + // result: (LEAQ {sym} base) + for { + sym := auxToSym(v.Aux) + base := v_0 + v.reset(OpAMD64LEAQ) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } +} +func rewriteValueAMD64_OpAtomicAdd32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicAdd32 ptr val mem) + // result: (AddTupleFirst32 val (XADDLlock val ptr mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64AddTupleFirst32) + v0 := b.NewValue0(v.Pos, OpAMD64XADDLlock, types.NewTuple(typ.UInt32, types.TypeMem)) + v0.AddArg3(val, ptr, mem) + v.AddArg2(val, v0) + return true + } +} +func rewriteValueAMD64_OpAtomicAdd64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicAdd64 ptr val mem) + // result: (AddTupleFirst64 val (XADDQlock val ptr mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64AddTupleFirst64) + v0 := b.NewValue0(v.Pos, OpAMD64XADDQlock, types.NewTuple(typ.UInt64, types.TypeMem)) + v0.AddArg3(val, ptr, mem) + v.AddArg2(val, v0) + return true + } +} +func rewriteValueAMD64_OpAtomicAnd32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicAnd32 ptr val mem) + // result: (ANDLlock ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64ANDLlock) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicAnd32value(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicAnd32value ptr val mem) + // result: (LoweredAtomicAnd32 ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64LoweredAtomicAnd32) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicAnd64value(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicAnd64value ptr val mem) + // result: (LoweredAtomicAnd64 ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64LoweredAtomicAnd64) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicAnd8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicAnd8 ptr val mem) + // result: (ANDBlock ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64ANDBlock) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicCompareAndSwap32(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicCompareAndSwap32 ptr old new_ mem) + // result: (CMPXCHGLlock ptr old new_ mem) + for { + ptr := v_0 + old := v_1 + new_ := v_2 + mem := v_3 + v.reset(OpAMD64CMPXCHGLlock) + v.AddArg4(ptr, old, new_, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicCompareAndSwap64(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicCompareAndSwap64 ptr old new_ mem) + // result: (CMPXCHGQlock ptr old new_ mem) + for { + ptr := v_0 + old := v_1 + new_ := v_2 + mem := v_3 + v.reset(OpAMD64CMPXCHGQlock) + v.AddArg4(ptr, old, new_, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicExchange32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicExchange32 ptr val mem) + // result: (XCHGL val ptr mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64XCHGL) + v.AddArg3(val, ptr, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicExchange64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicExchange64 ptr val mem) + // result: (XCHGQ val ptr mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64XCHGQ) + v.AddArg3(val, ptr, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicExchange8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicExchange8 ptr val mem) + // result: (XCHGB val ptr mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64XCHGB) + v.AddArg3(val, ptr, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicLoad32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoad32 ptr mem) + // result: (MOVLatomicload ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVLatomicload) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicLoad64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoad64 ptr mem) + // result: (MOVQatomicload ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVQatomicload) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicLoad8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoad8 ptr mem) + // result: (MOVBatomicload ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVBatomicload) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicLoadPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoadPtr ptr mem) + // result: (MOVQatomicload ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVQatomicload) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicOr32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicOr32 ptr val mem) + // result: (ORLlock ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64ORLlock) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicOr32value(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicOr32value ptr val mem) + // result: (LoweredAtomicOr32 ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64LoweredAtomicOr32) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicOr64value(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicOr64value ptr val mem) + // result: (LoweredAtomicOr64 ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64LoweredAtomicOr64) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicOr8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicOr8 ptr val mem) + // result: (ORBlock ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpAMD64ORBlock) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueAMD64_OpAtomicStore32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicStore32 ptr val mem) + // result: (Select1 (XCHGL val ptr mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64XCHGL, types.NewTuple(typ.UInt32, types.TypeMem)) + v0.AddArg3(val, ptr, mem) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpAtomicStore64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicStore64 ptr val mem) + // result: (Select1 (XCHGQ val ptr mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64XCHGQ, types.NewTuple(typ.UInt64, types.TypeMem)) + v0.AddArg3(val, ptr, mem) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpAtomicStore8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicStore8 ptr val mem) + // result: (Select1 (XCHGB val ptr mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64XCHGB, types.NewTuple(typ.UInt8, types.TypeMem)) + v0.AddArg3(val, ptr, mem) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpAtomicStorePtrNoWB(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicStorePtrNoWB ptr val mem) + // result: (Select1 (XCHGQ val ptr mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64XCHGQ, types.NewTuple(typ.BytePtr, types.TypeMem)) + v0.AddArg3(val, ptr, mem) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpBitLen16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen16 x) + // cond: buildcfg.GOAMD64 < 3 + // result: (BSRL (LEAL1 [1] (MOVWQZX x) (MOVWQZX x))) + for { + x := v_0 + if !(buildcfg.GOAMD64 < 3) { + break + } + v.reset(OpAMD64BSRL) + v0 := b.NewValue0(v.Pos, OpAMD64LEAL1, typ.UInt32) + v0.AuxInt = int32ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpAMD64MOVWQZX, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, v1) + v.AddArg(v0) + return true + } + // match: (BitLen16 x) + // cond: buildcfg.GOAMD64 >= 3 + // result: (NEGQ (ADDQconst [-32] (LZCNTL (MOVWQZX x)))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64NEGQ) + v0 := b.NewValue0(v.Pos, OpAMD64ADDQconst, t) + v0.AuxInt = int32ToAuxInt(-32) + v1 := b.NewValue0(v.Pos, OpAMD64LZCNTL, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpAMD64MOVWQZX, x.Type) + v2.AddArg(x) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpBitLen32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen32 x) + // cond: buildcfg.GOAMD64 < 3 + // result: (Select0 (BSRQ (LEAQ1 [1] (MOVLQZX x) (MOVLQZX x)))) + for { + x := v_0 + if !(buildcfg.GOAMD64 < 3) { + break + } + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64BSRQ, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1 := b.NewValue0(v.Pos, OpAMD64LEAQ1, typ.UInt64) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpAMD64MOVLQZX, typ.UInt64) + v2.AddArg(x) + v1.AddArg2(v2, v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (BitLen32 x) + // cond: buildcfg.GOAMD64 >= 3 + // result: (NEGQ (ADDQconst [-32] (LZCNTL x))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64NEGQ) + v0 := b.NewValue0(v.Pos, OpAMD64ADDQconst, t) + v0.AuxInt = int32ToAuxInt(-32) + v1 := b.NewValue0(v.Pos, OpAMD64LZCNTL, typ.UInt32) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpBitLen64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen64 x) + // cond: buildcfg.GOAMD64 < 3 + // result: (ADDQconst [1] (CMOVQEQ (Select0 (BSRQ x)) (MOVQconst [-1]) (Select1 (BSRQ x)))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOAMD64 < 3) { + break + } + v.reset(OpAMD64ADDQconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpAMD64CMOVQEQ, t) + v1 := b.NewValue0(v.Pos, OpSelect0, t) + v2 := b.NewValue0(v.Pos, OpAMD64BSRQ, types.NewTuple(typ.UInt64, types.TypeFlags)) + v2.AddArg(x) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpAMD64MOVQconst, t) + v3.AuxInt = int64ToAuxInt(-1) + v4 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v4.AddArg(v2) + v0.AddArg3(v1, v3, v4) + v.AddArg(v0) + return true + } + // match: (BitLen64 x) + // cond: buildcfg.GOAMD64 >= 3 + // result: (NEGQ (ADDQconst [-64] (LZCNTQ x))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64NEGQ) + v0 := b.NewValue0(v.Pos, OpAMD64ADDQconst, t) + v0.AuxInt = int32ToAuxInt(-64) + v1 := b.NewValue0(v.Pos, OpAMD64LZCNTQ, typ.UInt64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpBitLen8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen8 x) + // cond: buildcfg.GOAMD64 < 3 + // result: (BSRL (LEAL1 [1] (MOVBQZX x) (MOVBQZX x))) + for { + x := v_0 + if !(buildcfg.GOAMD64 < 3) { + break + } + v.reset(OpAMD64BSRL) + v0 := b.NewValue0(v.Pos, OpAMD64LEAL1, typ.UInt32) + v0.AuxInt = int32ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpAMD64MOVBQZX, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, v1) + v.AddArg(v0) + return true + } + // match: (BitLen8 x) + // cond: buildcfg.GOAMD64 >= 3 + // result: (NEGQ (ADDQconst [-32] (LZCNTL (MOVBQZX x)))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64NEGQ) + v0 := b.NewValue0(v.Pos, OpAMD64ADDQconst, t) + v0.AuxInt = int32ToAuxInt(-32) + v1 := b.NewValue0(v.Pos, OpAMD64LZCNTL, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpAMD64MOVBQZX, x.Type) + v2.AddArg(x) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpBswap16(v *Value) bool { + v_0 := v.Args[0] + // match: (Bswap16 x) + // result: (ROLWconst [8] x) + for { + x := v_0 + v.reset(OpAMD64ROLWconst) + v.AuxInt = int8ToAuxInt(8) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeil(v *Value) bool { + v_0 := v.Args[0] + // match: (Ceil x) + // result: (ROUNDSD [2] x) + for { + x := v_0 + v.reset(OpAMD64ROUNDSD) + v.AuxInt = int8ToAuxInt(2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilFloat32x4 x) + // result: (VROUNDPS128 [2] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPS128) + v.AuxInt = uint8ToAuxInt(2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilFloat32x8 x) + // result: (VROUNDPS256 [2] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPS256) + v.AuxInt = uint8ToAuxInt(2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilFloat64x2 x) + // result: (VROUNDPD128 [2] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPD128) + v.AuxInt = uint8ToAuxInt(2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilFloat64x4 x) + // result: (VROUNDPD256 [2] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPD256) + v.AuxInt = uint8ToAuxInt(2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledFloat32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledFloat32x16 [a] x) + // result: (VRNDSCALEPS512 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS512) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledFloat32x4 [a] x) + // result: (VRNDSCALEPS128 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS128) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledFloat32x8 [a] x) + // result: (VRNDSCALEPS256 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS256) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledFloat64x2 [a] x) + // result: (VRNDSCALEPD128 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD128) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledFloat64x4 [a] x) + // result: (VRNDSCALEPD256 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD256) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledFloat64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledFloat64x8 [a] x) + // result: (VRNDSCALEPD512 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD512) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledResidueFloat32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledResidueFloat32x16 [a] x) + // result: (VREDUCEPS512 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS512) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledResidueFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledResidueFloat32x4 [a] x) + // result: (VREDUCEPS128 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS128) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledResidueFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledResidueFloat32x8 [a] x) + // result: (VREDUCEPS256 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS256) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledResidueFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledResidueFloat64x2 [a] x) + // result: (VREDUCEPD128 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD128) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledResidueFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledResidueFloat64x4 [a] x) + // result: (VREDUCEPD256 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD256) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCeilScaledResidueFloat64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (CeilScaledResidueFloat64x8 [a] x) + // result: (VREDUCEPD512 [a+2] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD512) + v.AuxInt = uint8ToAuxInt(a + 2) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpCompressFloat32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressFloat32x16 x mask) + // result: (VCOMPRESSPSMasked512 x (VPMOVVec32x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VCOMPRESSPSMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressFloat32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressFloat32x4 x mask) + // result: (VCOMPRESSPSMasked128 x (VPMOVVec32x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VCOMPRESSPSMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressFloat32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressFloat32x8 x mask) + // result: (VCOMPRESSPSMasked256 x (VPMOVVec32x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VCOMPRESSPSMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressFloat64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressFloat64x2 x mask) + // result: (VCOMPRESSPDMasked128 x (VPMOVVec64x2ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VCOMPRESSPDMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressFloat64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressFloat64x4 x mask) + // result: (VCOMPRESSPDMasked256 x (VPMOVVec64x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VCOMPRESSPDMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressFloat64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressFloat64x8 x mask) + // result: (VCOMPRESSPDMasked512 x (VPMOVVec64x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VCOMPRESSPDMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt16x16 x mask) + // result: (VPCOMPRESSWMasked256 x (VPMOVVec16x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSWMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt16x32 x mask) + // result: (VPCOMPRESSWMasked512 x (VPMOVVec16x32ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSWMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt16x8 x mask) + // result: (VPCOMPRESSWMasked128 x (VPMOVVec16x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSWMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt32x16 x mask) + // result: (VPCOMPRESSDMasked512 x (VPMOVVec32x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSDMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt32x4 x mask) + // result: (VPCOMPRESSDMasked128 x (VPMOVVec32x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSDMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt32x8 x mask) + // result: (VPCOMPRESSDMasked256 x (VPMOVVec32x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSDMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt64x2 x mask) + // result: (VPCOMPRESSQMasked128 x (VPMOVVec64x2ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSQMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt64x4 x mask) + // result: (VPCOMPRESSQMasked256 x (VPMOVVec64x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSQMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt64x8 x mask) + // result: (VPCOMPRESSQMasked512 x (VPMOVVec64x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSQMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt8x16 x mask) + // result: (VPCOMPRESSBMasked128 x (VPMOVVec8x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSBMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt8x32 x mask) + // result: (VPCOMPRESSBMasked256 x (VPMOVVec8x32ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSBMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressInt8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressInt8x64 x mask) + // result: (VPCOMPRESSBMasked512 x (VPMOVVec8x64ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSBMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x64ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint16x16 x mask) + // result: (VPCOMPRESSWMasked256 x (VPMOVVec16x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSWMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint16x32 x mask) + // result: (VPCOMPRESSWMasked512 x (VPMOVVec16x32ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSWMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint16x8 x mask) + // result: (VPCOMPRESSWMasked128 x (VPMOVVec16x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSWMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint32x16 x mask) + // result: (VPCOMPRESSDMasked512 x (VPMOVVec32x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSDMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint32x4 x mask) + // result: (VPCOMPRESSDMasked128 x (VPMOVVec32x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSDMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint32x8 x mask) + // result: (VPCOMPRESSDMasked256 x (VPMOVVec32x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSDMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint64x2 x mask) + // result: (VPCOMPRESSQMasked128 x (VPMOVVec64x2ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSQMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint64x4 x mask) + // result: (VPCOMPRESSQMasked256 x (VPMOVVec64x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSQMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint64x8 x mask) + // result: (VPCOMPRESSQMasked512 x (VPMOVVec64x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSQMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint8x16 x mask) + // result: (VPCOMPRESSBMasked128 x (VPMOVVec8x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSBMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint8x32 x mask) + // result: (VPCOMPRESSBMasked256 x (VPMOVVec8x32ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSBMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCompressUint8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CompressUint8x64 x mask) + // result: (VPCOMPRESSBMasked512 x (VPMOVVec8x64ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPCOMPRESSBMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x64ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpCondSelect(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CondSelect x y (SETEQ cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQEQ y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETEQ { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQEQ) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETNE cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQNE y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETNE { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQNE) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETL cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQLT y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETL { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQLT) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETG cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQGT y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETG { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQGT) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETLE cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQLE y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETLE { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQLE) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETGE cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQGE y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETGE { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQGE) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETA cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQHI y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETA { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQHI) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETB cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQCS y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETB { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQCS) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETAE cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQCC y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETAE { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQCC) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETBE cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQLS y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETBE { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQLS) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETEQF cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQEQF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETEQF { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQEQF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETNEF cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQNEF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETNEF { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQNEF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETGF cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQGTF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETGF { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQGTF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETGEF cond)) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (CMOVQGEF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETGEF { + break + } + cond := v_2.Args[0] + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64CMOVQGEF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETEQ cond)) + // cond: is32BitInt(t) + // result: (CMOVLEQ y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETEQ { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLEQ) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETNE cond)) + // cond: is32BitInt(t) + // result: (CMOVLNE y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETNE { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLNE) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETL cond)) + // cond: is32BitInt(t) + // result: (CMOVLLT y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETL { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLLT) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETG cond)) + // cond: is32BitInt(t) + // result: (CMOVLGT y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETG { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLGT) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETLE cond)) + // cond: is32BitInt(t) + // result: (CMOVLLE y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETLE { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLLE) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETGE cond)) + // cond: is32BitInt(t) + // result: (CMOVLGE y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETGE { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLGE) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETA cond)) + // cond: is32BitInt(t) + // result: (CMOVLHI y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETA { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLHI) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETB cond)) + // cond: is32BitInt(t) + // result: (CMOVLCS y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETB { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLCS) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETAE cond)) + // cond: is32BitInt(t) + // result: (CMOVLCC y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETAE { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLCC) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETBE cond)) + // cond: is32BitInt(t) + // result: (CMOVLLS y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETBE { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLLS) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETEQF cond)) + // cond: is32BitInt(t) + // result: (CMOVLEQF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETEQF { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLEQF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETNEF cond)) + // cond: is32BitInt(t) + // result: (CMOVLNEF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETNEF { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLNEF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETGF cond)) + // cond: is32BitInt(t) + // result: (CMOVLGTF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETGF { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLGTF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETGEF cond)) + // cond: is32BitInt(t) + // result: (CMOVLGEF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETGEF { + break + } + cond := v_2.Args[0] + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLGEF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETEQ cond)) + // cond: is16BitInt(t) + // result: (CMOVWEQ y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETEQ { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWEQ) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETNE cond)) + // cond: is16BitInt(t) + // result: (CMOVWNE y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETNE { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWNE) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETL cond)) + // cond: is16BitInt(t) + // result: (CMOVWLT y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETL { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWLT) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETG cond)) + // cond: is16BitInt(t) + // result: (CMOVWGT y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETG { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWGT) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETLE cond)) + // cond: is16BitInt(t) + // result: (CMOVWLE y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETLE { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWLE) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETGE cond)) + // cond: is16BitInt(t) + // result: (CMOVWGE y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETGE { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWGE) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETA cond)) + // cond: is16BitInt(t) + // result: (CMOVWHI y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETA { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWHI) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETB cond)) + // cond: is16BitInt(t) + // result: (CMOVWCS y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETB { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWCS) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETAE cond)) + // cond: is16BitInt(t) + // result: (CMOVWCC y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETAE { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWCC) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETBE cond)) + // cond: is16BitInt(t) + // result: (CMOVWLS y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETBE { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWLS) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETEQF cond)) + // cond: is16BitInt(t) + // result: (CMOVWEQF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETEQF { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWEQF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETNEF cond)) + // cond: is16BitInt(t) + // result: (CMOVWNEF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETNEF { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWNEF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETGF cond)) + // cond: is16BitInt(t) + // result: (CMOVWGTF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETGF { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWGTF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y (SETGEF cond)) + // cond: is16BitInt(t) + // result: (CMOVWGEF y x cond) + for { + t := v.Type + x := v_0 + y := v_1 + if v_2.Op != OpAMD64SETGEF { + break + } + cond := v_2.Args[0] + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWGEF) + v.AddArg3(y, x, cond) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 8 && (is64BitInt(t) || isPtr(t)) + // result: (CMOVQNE y x (CMPQconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 8 && (is64BitInt(t) || isPtr(t))) { + break + } + v.reset(OpAMD64CMOVQNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 8 && is32BitInt(t) + // result: (CMOVLNE y x (CMPQconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 8 && is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 8 && is16BitInt(t) + // result: (CMOVWNE y x (CMPQconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 8 && is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 4 && (is64BitInt(t) || isPtr(t)) + // result: (CMOVQNE y x (CMPLconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 4 && (is64BitInt(t) || isPtr(t))) { + break + } + v.reset(OpAMD64CMOVQNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 4 && is32BitInt(t) + // result: (CMOVLNE y x (CMPLconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 4 && is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 4 && is16BitInt(t) + // result: (CMOVWNE y x (CMPLconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 4 && is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 2 && (is64BitInt(t) || isPtr(t)) + // result: (CMOVQNE y x (CMPWconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 2 && (is64BitInt(t) || isPtr(t))) { + break + } + v.reset(OpAMD64CMOVQNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v0.AuxInt = int16ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 2 && is32BitInt(t) + // result: (CMOVLNE y x (CMPWconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 2 && is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v0.AuxInt = int16ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 2 && is16BitInt(t) + // result: (CMOVWNE y x (CMPWconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 2 && is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v0.AuxInt = int16ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 1 && (is64BitInt(t) || isPtr(t)) + // result: (CMOVQNE y x (CMPBconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 1 && (is64BitInt(t) || isPtr(t))) { + break + } + v.reset(OpAMD64CMOVQNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 1 && is32BitInt(t) + // result: (CMOVLNE y x (CMPBconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 1 && is32BitInt(t)) { + break + } + v.reset(OpAMD64CMOVLNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + // match: (CondSelect x y check) + // cond: !check.Type.IsFlags() && check.Type.Size() == 1 && is16BitInt(t) + // result: (CMOVWNE y x (CMPBconst [0] check)) + for { + t := v.Type + x := v_0 + y := v_1 + check := v_2 + if !(!check.Type.IsFlags() && check.Type.Size() == 1 && is16BitInt(t)) { + break + } + v.reset(OpAMD64CMOVWNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(check) + v.AddArg3(y, x, v0) + return true + } + return false +} +func rewriteValueAMD64_OpConst16(v *Value) bool { + // match: (Const16 [c]) + // result: (MOVLconst [int32(c)]) + for { + c := auxIntToInt16(v.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + return true + } +} +func rewriteValueAMD64_OpConst8(v *Value) bool { + // match: (Const8 [c]) + // result: (MOVLconst [int32(c)]) + for { + c := auxIntToInt8(v.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + return true + } +} +func rewriteValueAMD64_OpConstBool(v *Value) bool { + // match: (ConstBool [c]) + // result: (MOVLconst [b2i32(c)]) + for { + c := auxIntToBool(v.AuxInt) + v.reset(OpAMD64MOVLconst) + v.AuxInt = int32ToAuxInt(b2i32(c)) + return true + } +} +func rewriteValueAMD64_OpConstNil(v *Value) bool { + // match: (ConstNil ) + // result: (MOVQconst [0]) + for { + v.reset(OpAMD64MOVQconst) + v.AuxInt = int64ToAuxInt(0) + return true + } +} +func rewriteValueAMD64_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz16 x) + // result: (BSFL (ORLconst [1<<16] x)) + for { + x := v_0 + v.reset(OpAMD64BSFL) + v0 := b.NewValue0(v.Pos, OpAMD64ORLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(1 << 16) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCtz16NonZero(v *Value) bool { + v_0 := v.Args[0] + // match: (Ctz16NonZero x) + // cond: buildcfg.GOAMD64 >= 3 + // result: (TZCNTL x) + for { + x := v_0 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64TZCNTL) + v.AddArg(x) + return true + } + // match: (Ctz16NonZero x) + // cond: buildcfg.GOAMD64 < 3 + // result: (BSFL x) + for { + x := v_0 + if !(buildcfg.GOAMD64 < 3) { + break + } + v.reset(OpAMD64BSFL) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpCtz32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz32 x) + // cond: buildcfg.GOAMD64 >= 3 + // result: (TZCNTL x) + for { + x := v_0 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64TZCNTL) + v.AddArg(x) + return true + } + // match: (Ctz32 x) + // cond: buildcfg.GOAMD64 < 3 + // result: (Select0 (BSFQ (BTSQconst [32] x))) + for { + x := v_0 + if !(buildcfg.GOAMD64 < 3) { + break + } + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64BSFQ, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1 := b.NewValue0(v.Pos, OpAMD64BTSQconst, typ.UInt64) + v1.AuxInt = int8ToAuxInt(32) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpCtz32NonZero(v *Value) bool { + v_0 := v.Args[0] + // match: (Ctz32NonZero x) + // cond: buildcfg.GOAMD64 >= 3 + // result: (TZCNTL x) + for { + x := v_0 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64TZCNTL) + v.AddArg(x) + return true + } + // match: (Ctz32NonZero x) + // cond: buildcfg.GOAMD64 < 3 + // result: (BSFL x) + for { + x := v_0 + if !(buildcfg.GOAMD64 < 3) { + break + } + v.reset(OpAMD64BSFL) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpCtz64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz64 x) + // cond: buildcfg.GOAMD64 >= 3 + // result: (TZCNTQ x) + for { + x := v_0 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64TZCNTQ) + v.AddArg(x) + return true + } + // match: (Ctz64 x) + // cond: buildcfg.GOAMD64 < 3 + // result: (CMOVQEQ (Select0 (BSFQ x)) (MOVQconst [64]) (Select1 (BSFQ x))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOAMD64 < 3) { + break + } + v.reset(OpAMD64CMOVQEQ) + v0 := b.NewValue0(v.Pos, OpSelect0, t) + v1 := b.NewValue0(v.Pos, OpAMD64BSFQ, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1.AddArg(x) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpAMD64MOVQconst, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v3.AddArg(v1) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueAMD64_OpCtz64NonZero(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz64NonZero x) + // cond: buildcfg.GOAMD64 >= 3 + // result: (TZCNTQ x) + for { + x := v_0 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64TZCNTQ) + v.AddArg(x) + return true + } + // match: (Ctz64NonZero x) + // cond: buildcfg.GOAMD64 < 3 + // result: (Select0 (BSFQ x)) + for { + x := v_0 + if !(buildcfg.GOAMD64 < 3) { + break + } + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64BSFQ, types.NewTuple(typ.UInt64, types.TypeFlags)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz8 x) + // result: (BSFL (ORLconst [1<<8 ] x)) + for { + x := v_0 + v.reset(OpAMD64BSFL) + v0 := b.NewValue0(v.Pos, OpAMD64ORLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(1 << 8) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCtz8NonZero(v *Value) bool { + v_0 := v.Args[0] + // match: (Ctz8NonZero x) + // cond: buildcfg.GOAMD64 >= 3 + // result: (TZCNTL x) + for { + x := v_0 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64TZCNTL) + v.AddArg(x) + return true + } + // match: (Ctz8NonZero x) + // cond: buildcfg.GOAMD64 < 3 + // result: (BSFL x) + for { + x := v_0 + if !(buildcfg.GOAMD64 < 3) { + break + } + v.reset(OpAMD64BSFL) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpCvt16toMask16x16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt16toMask16x16 x) + // result: (VPMOVMToVec16x16 (KMOVWk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec16x16) + v.Type = types.TypeVec256 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVWk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt16toMask32x16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt16toMask32x16 x) + // result: (VPMOVMToVec32x16 (KMOVWk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec32x16) + v.Type = types.TypeVec512 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVWk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt16toMask8x16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt16toMask8x16 x) + // result: (VPMOVMToVec8x16 (KMOVWk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec8x16) + v.Type = types.TypeVec128 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVWk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt32Fto32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt32Fto32 x) + // cond: base.ConvertHash.MatchPos(v.Pos, nil) + // result: (XORL y (SARLconst [31] (ANDL y:(CVTTSS2SL x) (NOTL (MOVLf2i x))))) + for { + t := v.Type + x := v_0 + if !(base.ConvertHash.MatchPos(v.Pos, nil)) { + break + } + v.reset(OpAMD64XORL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64SARLconst, t) + v0.AuxInt = int8ToAuxInt(31) + v1 := b.NewValue0(v.Pos, OpAMD64ANDL, t) + y := b.NewValue0(v.Pos, OpAMD64CVTTSS2SL, t) + y.AddArg(x) + v3 := b.NewValue0(v.Pos, OpAMD64NOTL, typ.Int32) + v4 := b.NewValue0(v.Pos, OpAMD64MOVLf2i, typ.UInt32) + v4.AddArg(x) + v3.AddArg(v4) + v1.AddArg2(y, v3) + v0.AddArg(v1) + v.AddArg2(y, v0) + return true + } + // match: (Cvt32Fto32 x) + // cond: !base.ConvertHash.MatchPos(v.Pos, nil) + // result: (CVTTSS2SL x) + for { + t := v.Type + x := v_0 + if !(!base.ConvertHash.MatchPos(v.Pos, nil)) { + break + } + v.reset(OpAMD64CVTTSS2SL) + v.Type = t + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpCvt32Fto64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt32Fto64 x) + // cond: base.ConvertHash.MatchPos(v.Pos, nil) + // result: (XORQ y (SARQconst [63] (ANDQ y:(CVTTSS2SQ x) (NOTQ (MOVQf2i (CVTSS2SD x))) ))) + for { + t := v.Type + x := v_0 + if !(base.ConvertHash.MatchPos(v.Pos, nil)) { + break + } + v.reset(OpAMD64XORQ) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64SARQconst, t) + v0.AuxInt = int8ToAuxInt(63) + v1 := b.NewValue0(v.Pos, OpAMD64ANDQ, t) + y := b.NewValue0(v.Pos, OpAMD64CVTTSS2SQ, t) + y.AddArg(x) + v3 := b.NewValue0(v.Pos, OpAMD64NOTQ, typ.Int64) + v4 := b.NewValue0(v.Pos, OpAMD64MOVQf2i, typ.UInt64) + v5 := b.NewValue0(v.Pos, OpAMD64CVTSS2SD, typ.Float64) + v5.AddArg(x) + v4.AddArg(v5) + v3.AddArg(v4) + v1.AddArg2(y, v3) + v0.AddArg(v1) + v.AddArg2(y, v0) + return true + } + // match: (Cvt32Fto64 x) + // cond: !base.ConvertHash.MatchPos(v.Pos, nil) + // result: (CVTTSS2SQ x) + for { + t := v.Type + x := v_0 + if !(!base.ConvertHash.MatchPos(v.Pos, nil)) { + break + } + v.reset(OpAMD64CVTTSS2SQ) + v.Type = t + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpCvt32toMask16x32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt32toMask16x32 x) + // result: (VPMOVMToVec16x32 (KMOVDk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec16x32) + v.Type = types.TypeVec512 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVDk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt32toMask8x32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt32toMask8x32 x) + // result: (VPMOVMToVec8x32 (KMOVDk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec8x32) + v.Type = types.TypeVec256 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVDk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt64Fto32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt64Fto32 x) + // cond: base.ConvertHash.MatchPos(v.Pos, nil) + // result: (XORL y (SARLconst [31] (ANDL y:(CVTTSD2SL x) (NOTL (MOVLf2i (CVTSD2SS x)))))) + for { + t := v.Type + x := v_0 + if !(base.ConvertHash.MatchPos(v.Pos, nil)) { + break + } + v.reset(OpAMD64XORL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64SARLconst, t) + v0.AuxInt = int8ToAuxInt(31) + v1 := b.NewValue0(v.Pos, OpAMD64ANDL, t) + y := b.NewValue0(v.Pos, OpAMD64CVTTSD2SL, t) + y.AddArg(x) + v3 := b.NewValue0(v.Pos, OpAMD64NOTL, typ.Int32) + v4 := b.NewValue0(v.Pos, OpAMD64MOVLf2i, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpAMD64CVTSD2SS, typ.Float32) + v5.AddArg(x) + v4.AddArg(v5) + v3.AddArg(v4) + v1.AddArg2(y, v3) + v0.AddArg(v1) + v.AddArg2(y, v0) + return true + } + // match: (Cvt64Fto32 x) + // cond: !base.ConvertHash.MatchPos(v.Pos, nil) + // result: (CVTTSD2SL x) + for { + t := v.Type + x := v_0 + if !(!base.ConvertHash.MatchPos(v.Pos, nil)) { + break + } + v.reset(OpAMD64CVTTSD2SL) + v.Type = t + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpCvt64Fto64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt64Fto64 x) + // cond: base.ConvertHash.MatchPos(v.Pos, nil) + // result: (XORQ y (SARQconst [63] (ANDQ y:(CVTTSD2SQ x) (NOTQ (MOVQf2i x))))) + for { + t := v.Type + x := v_0 + if !(base.ConvertHash.MatchPos(v.Pos, nil)) { + break + } + v.reset(OpAMD64XORQ) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64SARQconst, t) + v0.AuxInt = int8ToAuxInt(63) + v1 := b.NewValue0(v.Pos, OpAMD64ANDQ, t) + y := b.NewValue0(v.Pos, OpAMD64CVTTSD2SQ, t) + y.AddArg(x) + v3 := b.NewValue0(v.Pos, OpAMD64NOTQ, typ.Int64) + v4 := b.NewValue0(v.Pos, OpAMD64MOVQf2i, typ.UInt64) + v4.AddArg(x) + v3.AddArg(v4) + v1.AddArg2(y, v3) + v0.AddArg(v1) + v.AddArg2(y, v0) + return true + } + // match: (Cvt64Fto64 x) + // cond: !base.ConvertHash.MatchPos(v.Pos, nil) + // result: (CVTTSD2SQ x) + for { + t := v.Type + x := v_0 + if !(!base.ConvertHash.MatchPos(v.Pos, nil)) { + break + } + v.reset(OpAMD64CVTTSD2SQ) + v.Type = t + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpCvt64toMask8x64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt64toMask8x64 x) + // result: (VPMOVMToVec8x64 (KMOVQk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec8x64) + v.Type = types.TypeVec512 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVQk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt8toMask16x8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt8toMask16x8 x) + // result: (VPMOVMToVec16x8 (KMOVBk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec16x8) + v.Type = types.TypeVec128 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVBk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt8toMask32x4(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt8toMask32x4 x) + // result: (VPMOVMToVec32x4 (KMOVBk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec32x4) + v.Type = types.TypeVec128 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVBk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt8toMask32x8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt8toMask32x8 x) + // result: (VPMOVMToVec32x8 (KMOVBk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec32x8) + v.Type = types.TypeVec256 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVBk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt8toMask64x2(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt8toMask64x2 x) + // result: (VPMOVMToVec64x2 (KMOVBk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec64x2) + v.Type = types.TypeVec128 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVBk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt8toMask64x4(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt8toMask64x4 x) + // result: (VPMOVMToVec64x4 (KMOVBk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec64x4) + v.Type = types.TypeVec256 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVBk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvt8toMask64x8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Cvt8toMask64x8 x) + // result: (VPMOVMToVec64x8 (KMOVBk x)) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64VPMOVMToVec64x8) + v.Type = types.TypeVec512 + v0 := b.NewValue0(v.Pos, OpAMD64KMOVBk, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvtMask16x16to16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CvtMask16x16to16 x) + // result: (KMOVWi (VPMOVVec16x16ToM x)) + for { + x := v_0 + v.reset(OpAMD64KMOVWi) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvtMask16x32to32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CvtMask16x32to32 x) + // result: (KMOVDi (VPMOVVec16x32ToM x)) + for { + x := v_0 + v.reset(OpAMD64KMOVDi) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x32ToM, types.TypeMask) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvtMask16x8to8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CvtMask16x8to8 x) + // result: (KMOVBi (VPMOVVec16x8ToM x)) + for { + x := v_0 + v.reset(OpAMD64KMOVBi) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvtMask32x16to16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CvtMask32x16to16 x) + // result: (KMOVWi (VPMOVVec32x16ToM x)) + for { + x := v_0 + v.reset(OpAMD64KMOVWi) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x16ToM, types.TypeMask) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvtMask64x8to8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CvtMask64x8to8 x) + // result: (KMOVBi (VPMOVVec64x8ToM x)) + for { + x := v_0 + v.reset(OpAMD64KMOVBi) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x8ToM, types.TypeMask) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpCvtMask8x64to64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (CvtMask8x64to64 x) + // result: (KMOVQi (VPMOVVec8x64ToM x)) + for { + x := v_0 + v.reset(OpAMD64KMOVQi) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x64ToM, types.TypeMask) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 [a] x y) + // result: (Select0 (DIVW [a] x y)) + for { + a := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64DIVW, types.NewTuple(typ.Int16, typ.Int16)) + v0.AuxInt = boolToAuxInt(a) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u x y) + // result: (Select0 (DIVWU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64DIVWU, types.NewTuple(typ.UInt16, typ.UInt16)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32 [a] x y) + // result: (Select0 (DIVL [a] x y)) + for { + a := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64DIVL, types.NewTuple(typ.Int32, typ.Int32)) + v0.AuxInt = boolToAuxInt(a) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpDiv32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32u x y) + // result: (Select0 (DIVLU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64DIVLU, types.NewTuple(typ.UInt32, typ.UInt32)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpDiv64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div64 [a] x y) + // result: (Select0 (DIVQ [a] x y)) + for { + a := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64DIVQ, types.NewTuple(typ.Int64, typ.Int64)) + v0.AuxInt = boolToAuxInt(a) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpDiv64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div64u x y) + // result: (Select0 (DIVQU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64DIVQU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (Select0 (DIVW (SignExt8to16 x) (SignExt8to16 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64DIVW, types.NewTuple(typ.Int16, typ.Int16)) + v1 := b.NewValue0(v.Pos, OpSignExt8to16, typ.Int16) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to16, typ.Int16) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (Select0 (DIVWU (ZeroExt8to16 x) (ZeroExt8to16 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpAMD64DIVWU, types.NewTuple(typ.UInt16, typ.UInt16)) + v1 := b.NewValue0(v.Pos, OpZeroExt8to16, typ.UInt16) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to16, typ.UInt16) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq16 x y) + // result: (SETEQ (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32 x y) + // result: (SETEQ (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32F x y) + // result: (SETEQF (UCOMISS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETEQF) + v0 := b.NewValue0(v.Pos, OpAMD64UCOMISS, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64 x y) + // result: (SETEQ (CMPQ x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64F x y) + // result: (SETEQF (UCOMISD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETEQF) + v0 := b.NewValue0(v.Pos, OpAMD64UCOMISD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq8 x y) + // result: (SETEQ (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (EqB x y) + // result: (SETEQ (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (EqPtr x y) + // result: (SETEQ (CMPQ x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqualFloat32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqualFloat32x16 x y) + // result: (VPMOVMToVec32x16 (VCMPPS512 [0] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPS512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(0) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqualFloat32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (EqualFloat32x4 x y) + // result: (VCMPPS128 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpEqualFloat32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (EqualFloat32x8 x y) + // result: (VCMPPS256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpEqualFloat64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (EqualFloat64x2 x y) + // result: (VCMPPD128 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpEqualFloat64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (EqualFloat64x4 x y) + // result: (VCMPPD256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpEqualFloat64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqualFloat64x8 x y) + // result: (VPMOVMToVec64x8 (VCMPPD512 [0] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(0) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqualInt16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqualInt16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPEQW512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPEQW512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqualInt32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqualInt32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPEQD512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPEQD512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqualInt64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqualInt64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPEQQ512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPEQQ512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqualInt8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqualInt8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPEQB512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPEQB512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqualUint16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqualUint16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPEQW512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPEQW512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqualUint32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqualUint32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPEQD512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPEQD512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqualUint64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqualUint64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPEQQ512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPEQQ512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpEqualUint8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqualUint8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPEQB512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPEQB512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpExpandFloat32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandFloat32x16 x mask) + // result: (VEXPANDPSMasked512 x (VPMOVVec32x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VEXPANDPSMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandFloat32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandFloat32x4 x mask) + // result: (VEXPANDPSMasked128 x (VPMOVVec32x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VEXPANDPSMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandFloat32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandFloat32x8 x mask) + // result: (VEXPANDPSMasked256 x (VPMOVVec32x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VEXPANDPSMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandFloat64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandFloat64x2 x mask) + // result: (VEXPANDPDMasked128 x (VPMOVVec64x2ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VEXPANDPDMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandFloat64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandFloat64x4 x mask) + // result: (VEXPANDPDMasked256 x (VPMOVVec64x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VEXPANDPDMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandFloat64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandFloat64x8 x mask) + // result: (VEXPANDPDMasked512 x (VPMOVVec64x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VEXPANDPDMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt16x16 x mask) + // result: (VPEXPANDWMasked256 x (VPMOVVec16x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDWMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt16x32 x mask) + // result: (VPEXPANDWMasked512 x (VPMOVVec16x32ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDWMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt16x8 x mask) + // result: (VPEXPANDWMasked128 x (VPMOVVec16x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDWMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt32x16 x mask) + // result: (VPEXPANDDMasked512 x (VPMOVVec32x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDDMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt32x4 x mask) + // result: (VPEXPANDDMasked128 x (VPMOVVec32x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDDMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt32x8 x mask) + // result: (VPEXPANDDMasked256 x (VPMOVVec32x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDDMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt64x2 x mask) + // result: (VPEXPANDQMasked128 x (VPMOVVec64x2ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDQMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt64x4 x mask) + // result: (VPEXPANDQMasked256 x (VPMOVVec64x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDQMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt64x8 x mask) + // result: (VPEXPANDQMasked512 x (VPMOVVec64x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDQMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt8x16 x mask) + // result: (VPEXPANDBMasked128 x (VPMOVVec8x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDBMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt8x32 x mask) + // result: (VPEXPANDBMasked256 x (VPMOVVec8x32ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDBMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandInt8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandInt8x64 x mask) + // result: (VPEXPANDBMasked512 x (VPMOVVec8x64ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDBMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x64ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint16x16 x mask) + // result: (VPEXPANDWMasked256 x (VPMOVVec16x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDWMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint16x32 x mask) + // result: (VPEXPANDWMasked512 x (VPMOVVec16x32ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDWMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint16x8 x mask) + // result: (VPEXPANDWMasked128 x (VPMOVVec16x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDWMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint32x16 x mask) + // result: (VPEXPANDDMasked512 x (VPMOVVec32x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDDMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint32x4 x mask) + // result: (VPEXPANDDMasked128 x (VPMOVVec32x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDDMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint32x8 x mask) + // result: (VPEXPANDDMasked256 x (VPMOVVec32x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDDMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint64x2 x mask) + // result: (VPEXPANDQMasked128 x (VPMOVVec64x2ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDQMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x2ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint64x4 x mask) + // result: (VPEXPANDQMasked256 x (VPMOVVec64x4ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDQMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x4ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint64x8 x mask) + // result: (VPEXPANDQMasked512 x (VPMOVVec64x8ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDQMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint8x16 x mask) + // result: (VPEXPANDBMasked128 x (VPMOVVec8x16ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDBMasked128) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint8x32 x mask) + // result: (VPEXPANDBMasked256 x (VPMOVVec8x32ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDBMasked256) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpExpandUint8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ExpandUint8x64 x mask) + // result: (VPEXPANDBMasked512 x (VPMOVVec8x64ToM mask)) + for { + x := v_0 + mask := v_1 + v.reset(OpAMD64VPEXPANDBMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x64ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpFMA(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMA x y z) + // result: (VFMADD231SD z x y) + for { + x := v_0 + y := v_1 + z := v_2 + v.reset(OpAMD64VFMADD231SD) + v.AddArg3(z, x, y) + return true + } +} +func rewriteValueAMD64_OpFloor(v *Value) bool { + v_0 := v.Args[0] + // match: (Floor x) + // result: (ROUNDSD [1] x) + for { + x := v_0 + v.reset(OpAMD64ROUNDSD) + v.AuxInt = int8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorFloat32x4 x) + // result: (VROUNDPS128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPS128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorFloat32x8 x) + // result: (VROUNDPS256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPS256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorFloat64x2 x) + // result: (VROUNDPD128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPD128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorFloat64x4 x) + // result: (VROUNDPD256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPD256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledFloat32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledFloat32x16 [a] x) + // result: (VRNDSCALEPS512 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS512) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledFloat32x4 [a] x) + // result: (VRNDSCALEPS128 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS128) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledFloat32x8 [a] x) + // result: (VRNDSCALEPS256 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS256) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledFloat64x2 [a] x) + // result: (VRNDSCALEPD128 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD128) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledFloat64x4 [a] x) + // result: (VRNDSCALEPD256 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD256) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledFloat64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledFloat64x8 [a] x) + // result: (VRNDSCALEPD512 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD512) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledResidueFloat32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledResidueFloat32x16 [a] x) + // result: (VREDUCEPS512 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS512) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledResidueFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledResidueFloat32x4 [a] x) + // result: (VREDUCEPS128 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS128) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledResidueFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledResidueFloat32x8 [a] x) + // result: (VREDUCEPS256 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS256) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledResidueFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledResidueFloat64x2 [a] x) + // result: (VREDUCEPD128 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD128) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledResidueFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledResidueFloat64x4 [a] x) + // result: (VREDUCEPD256 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD256) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpFloorScaledResidueFloat64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (FloorScaledResidueFloat64x8 [a] x) + // result: (VREDUCEPD512 [a+1] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD512) + v.AuxInt = uint8ToAuxInt(a + 1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetG(v *Value) bool { + v_0 := v.Args[0] + // match: (GetG mem) + // cond: v.Block.Func.OwnAux.Fn.ABI() != obj.ABIInternal + // result: (LoweredGetG mem) + for { + mem := v_0 + if !(v.Block.Func.OwnAux.Fn.ABI() != obj.ABIInternal) { + break + } + v.reset(OpAMD64LoweredGetG) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueAMD64_OpGetHiFloat32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiFloat32x16 x) + // result: (VEXTRACTF64X4256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTF64X4256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiFloat32x8 x) + // result: (VEXTRACTF128128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTF128128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiFloat64x4 x) + // result: (VEXTRACTF128128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTF128128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiFloat64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiFloat64x8 x) + // result: (VEXTRACTF64X4256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTF64X4256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiInt16x16(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiInt16x16 x) + // result: (VEXTRACTI128128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiInt16x32(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiInt16x32 x) + // result: (VEXTRACTI64X4256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiInt32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiInt32x16 x) + // result: (VEXTRACTI64X4256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiInt32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiInt32x8 x) + // result: (VEXTRACTI128128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiInt64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiInt64x4 x) + // result: (VEXTRACTI128128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiInt64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiInt64x8 x) + // result: (VEXTRACTI64X4256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiInt8x32(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiInt8x32 x) + // result: (VEXTRACTI128128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiInt8x64(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiInt8x64 x) + // result: (VEXTRACTI64X4256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiUint16x16(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiUint16x16 x) + // result: (VEXTRACTI128128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiUint16x32(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiUint16x32 x) + // result: (VEXTRACTI64X4256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiUint32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiUint32x16 x) + // result: (VEXTRACTI64X4256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiUint32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiUint32x8 x) + // result: (VEXTRACTI128128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiUint64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiUint64x4 x) + // result: (VEXTRACTI128128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiUint64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiUint64x8 x) + // result: (VEXTRACTI64X4256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiUint8x32(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiUint8x32 x) + // result: (VEXTRACTI128128 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetHiUint8x64(v *Value) bool { + v_0 := v.Args[0] + // match: (GetHiUint8x64 x) + // result: (VEXTRACTI64X4256 [1] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoFloat32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoFloat32x16 x) + // result: (VEXTRACTF64X4256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTF64X4256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoFloat32x8 x) + // result: (VEXTRACTF128128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTF128128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoFloat64x4 x) + // result: (VEXTRACTF128128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTF128128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoFloat64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoFloat64x8 x) + // result: (VEXTRACTF64X4256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTF64X4256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoInt16x16(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoInt16x16 x) + // result: (VEXTRACTI128128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoInt16x32(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoInt16x32 x) + // result: (VEXTRACTI64X4256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoInt32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoInt32x16 x) + // result: (VEXTRACTI64X4256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoInt32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoInt32x8 x) + // result: (VEXTRACTI128128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoInt64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoInt64x4 x) + // result: (VEXTRACTI128128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoInt64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoInt64x8 x) + // result: (VEXTRACTI64X4256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoInt8x32(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoInt8x32 x) + // result: (VEXTRACTI128128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoInt8x64(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoInt8x64 x) + // result: (VEXTRACTI64X4256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoUint16x16(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoUint16x16 x) + // result: (VEXTRACTI128128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoUint16x32(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoUint16x32 x) + // result: (VEXTRACTI64X4256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoUint32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoUint32x16 x) + // result: (VEXTRACTI64X4256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoUint32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoUint32x8 x) + // result: (VEXTRACTI128128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoUint64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoUint64x4 x) + // result: (VEXTRACTI128128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoUint64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoUint64x8 x) + // result: (VEXTRACTI64X4256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoUint8x32(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoUint8x32 x) + // result: (VEXTRACTI128128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI128128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGetLoUint8x64(v *Value) bool { + v_0 := v.Args[0] + // match: (GetLoUint8x64 x) + // result: (VEXTRACTI64X4256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VEXTRACTI64X4256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualFloat32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualFloat32x16 x y) + // result: (VPMOVMToVec32x16 (VCMPPS512 [13] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPS512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(13) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualFloat32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (GreaterEqualFloat32x4 x y) + // result: (VCMPPS128 [13] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS128) + v.AuxInt = uint8ToAuxInt(13) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualFloat32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (GreaterEqualFloat32x8 x y) + // result: (VCMPPS256 [13] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS256) + v.AuxInt = uint8ToAuxInt(13) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualFloat64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (GreaterEqualFloat64x2 x y) + // result: (VCMPPD128 [13] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD128) + v.AuxInt = uint8ToAuxInt(13) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualFloat64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (GreaterEqualFloat64x4 x y) + // result: (VCMPPD256 [13] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD256) + v.AuxInt = uint8ToAuxInt(13) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualFloat64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualFloat64x8 x y) + // result: (VPMOVMToVec64x8 (VCMPPD512 [13] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(13) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualInt16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualInt16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPW512 [13] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPW512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(13) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualInt32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualInt32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPD512 [13] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(13) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualInt64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualInt64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPQ512 [13] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPQ512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(13) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualInt8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualInt8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPB512 [13] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPB512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(13) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualUint16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualUint16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPUW512 [13] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUW512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(13) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualUint32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualUint32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPUD512 [13] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(13) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualUint64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualUint64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPUQ512 [13] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUQ512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(13) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterEqualUint8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualUint8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPUB512 [13] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUB512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(13) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterFloat32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterFloat32x16 x y) + // result: (VPMOVMToVec32x16 (VCMPPS512 [14] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPS512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(14) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterFloat32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (GreaterFloat32x4 x y) + // result: (VCMPPS128 [14] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS128) + v.AuxInt = uint8ToAuxInt(14) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpGreaterFloat32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (GreaterFloat32x8 x y) + // result: (VCMPPS256 [14] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS256) + v.AuxInt = uint8ToAuxInt(14) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpGreaterFloat64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (GreaterFloat64x2 x y) + // result: (VCMPPD128 [14] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD128) + v.AuxInt = uint8ToAuxInt(14) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpGreaterFloat64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (GreaterFloat64x4 x y) + // result: (VCMPPD256 [14] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD256) + v.AuxInt = uint8ToAuxInt(14) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpGreaterFloat64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterFloat64x8 x y) + // result: (VPMOVMToVec64x8 (VCMPPD512 [14] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(14) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterInt16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterInt16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPGTW512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPGTW512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterInt32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterInt32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPGTD512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPGTD512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterInt64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterInt64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPGTQ512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPGTQ512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterInt8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterInt8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPGTB512 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPGTB512, typ.Mask) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterUint16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterUint16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPUW512 [14] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUW512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(14) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterUint32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterUint32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPUD512 [14] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(14) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterUint64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterUint64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPUQ512 [14] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUQ512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(14) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpGreaterUint8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterUint8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPUB512 [14] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUB512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(14) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpHasCPUFeature(v *Value) bool { + b := v.Block + typ := &b.Func.Config.Types + // match: (HasCPUFeature {s}) + // result: (SETNE (CMPLconst [0] (LoweredHasCPUFeature {s}))) + for { + s := auxToSym(v.Aux) + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpAMD64LoweredHasCPUFeature, typ.UInt64) + v1.Aux = symToAux(s) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpIsInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (IsInBounds idx len) + // result: (SETB (CMPQ idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpIsNaNFloat32x16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsNaNFloat32x16 x) + // result: (VPMOVMToVec32x16 (VCMPPS512 [3] x x)) + for { + x := v_0 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPS512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpIsNaNFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (IsNaNFloat32x4 x) + // result: (VCMPPS128 [3] x x) + for { + x := v_0 + v.reset(OpAMD64VCMPPS128) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg2(x, x) + return true + } +} +func rewriteValueAMD64_OpIsNaNFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (IsNaNFloat32x8 x) + // result: (VCMPPS256 [3] x x) + for { + x := v_0 + v.reset(OpAMD64VCMPPS256) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg2(x, x) + return true + } +} +func rewriteValueAMD64_OpIsNaNFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (IsNaNFloat64x2 x) + // result: (VCMPPD128 [3] x x) + for { + x := v_0 + v.reset(OpAMD64VCMPPD128) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg2(x, x) + return true + } +} +func rewriteValueAMD64_OpIsNaNFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (IsNaNFloat64x4 x) + // result: (VCMPPD256 [3] x x) + for { + x := v_0 + v.reset(OpAMD64VCMPPD256) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg2(x, x) + return true + } +} +func rewriteValueAMD64_OpIsNaNFloat64x8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsNaNFloat64x8 x) + // result: (VPMOVMToVec64x8 (VCMPPD512 [3] x x)) + for { + x := v_0 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpIsNonNil(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (IsNonNil p) + // result: (SETNE (TESTQ p p)) + for { + p := v_0 + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpAMD64TESTQ, types.TypeFlags) + v0.AddArg2(p, p) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpIsSliceInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (IsSliceInBounds idx len) + // result: (SETBE (CMPQ idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpAMD64SETBE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpIsZeroVec(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (IsZeroVec x) + // result: (SETEQ (VPTEST x x)) + for { + x := v_0 + v.reset(OpAMD64SETEQ) + v0 := b.NewValue0(v.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq16 x y) + // result: (SETLE (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETLE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq16U x y) + // result: (SETBE (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETBE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32 x y) + // result: (SETLE (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETLE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32F x y) + // result: (SETGEF (UCOMISS y x)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETGEF) + v0 := b.NewValue0(v.Pos, OpAMD64UCOMISS, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32U x y) + // result: (SETBE (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETBE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64 x y) + // result: (SETLE (CMPQ x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETLE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64F x y) + // result: (SETGEF (UCOMISD y x)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETGEF) + v0 := b.NewValue0(v.Pos, OpAMD64UCOMISD, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLeq64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64U x y) + // result: (SETBE (CMPQ x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETBE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq8 x y) + // result: (SETLE (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETLE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq8U x y) + // result: (SETBE (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETBE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less16 x y) + // result: (SETL (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETL) + v0 := b.NewValue0(v.Pos, OpAMD64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less16U x y) + // result: (SETB (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32 x y) + // result: (SETL (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETL) + v0 := b.NewValue0(v.Pos, OpAMD64CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLess32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32F x y) + // result: (SETGF (UCOMISS y x)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETGF) + v0 := b.NewValue0(v.Pos, OpAMD64UCOMISS, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32U x y) + // result: (SETB (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLess64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64 x y) + // result: (SETL (CMPQ x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETL) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLess64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64F x y) + // result: (SETGF (UCOMISD y x)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETGF) + v0 := b.NewValue0(v.Pos, OpAMD64UCOMISD, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLess64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64U x y) + // result: (SETB (CMPQ x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less8 x y) + // result: (SETL (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETL) + v0 := b.NewValue0(v.Pos, OpAMD64CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less8U x y) + // result: (SETB (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETB) + v0 := b.NewValue0(v.Pos, OpAMD64CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessEqualFloat32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessEqualFloat32x16 x y) + // result: (VPMOVMToVec32x16 (VCMPPS512 [2] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPS512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(2) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessEqualFloat32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LessEqualFloat32x4 x y) + // result: (VCMPPS128 [2] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS128) + v.AuxInt = uint8ToAuxInt(2) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpLessEqualFloat32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LessEqualFloat32x8 x y) + // result: (VCMPPS256 [2] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS256) + v.AuxInt = uint8ToAuxInt(2) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpLessEqualFloat64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LessEqualFloat64x2 x y) + // result: (VCMPPD128 [2] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD128) + v.AuxInt = uint8ToAuxInt(2) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpLessEqualFloat64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LessEqualFloat64x4 x y) + // result: (VCMPPD256 [2] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD256) + v.AuxInt = uint8ToAuxInt(2) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpLessEqualFloat64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessEqualFloat64x8 x y) + // result: (VPMOVMToVec64x8 (VCMPPD512 [2] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(2) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessEqualInt16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessEqualInt16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPW512 [2] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPW512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(2) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessEqualInt32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessEqualInt32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPD512 [2] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(2) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessEqualInt64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessEqualInt64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPQ512 [2] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPQ512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(2) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessEqualInt8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessEqualInt8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPB512 [2] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPB512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(2) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessEqualUint16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessEqualUint16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPUW512 [2] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUW512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(2) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessEqualUint32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessEqualUint32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPUD512 [2] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(2) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessEqualUint64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessEqualUint64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPUQ512 [2] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUQ512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(2) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessEqualUint8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessEqualUint8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPUB512 [2] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUB512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(2) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessFloat32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessFloat32x16 x y) + // result: (VPMOVMToVec32x16 (VCMPPS512 [1] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPS512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(1) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessFloat32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LessFloat32x4 x y) + // result: (VCMPPS128 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpLessFloat32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LessFloat32x8 x y) + // result: (VCMPPS256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpLessFloat64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LessFloat64x2 x y) + // result: (VCMPPD128 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD128) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpLessFloat64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LessFloat64x4 x y) + // result: (VCMPPD256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpLessFloat64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessFloat64x8 x y) + // result: (VPMOVMToVec64x8 (VCMPPD512 [1] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(1) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessInt16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessInt16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPW512 [1] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPW512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(1) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessInt32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessInt32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPD512 [1] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(1) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessInt64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessInt64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPQ512 [1] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPQ512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(1) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessInt8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessInt8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPB512 [1] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPB512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(1) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessUint16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessUint16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPUW512 [1] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUW512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(1) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessUint32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessUint32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPUD512 [1] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(1) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessUint64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessUint64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPUQ512 [1] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUQ512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(1) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLessUint8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessUint8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPUB512 [1] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUB512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(1) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Load ptr mem) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (MOVQload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpAMD64MOVQload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitInt(t) + // result: (MOVLload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t)) { + break + } + v.reset(OpAMD64MOVLload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is16BitInt(t) + // result: (MOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t)) { + break + } + v.reset(OpAMD64MOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (t.IsBoolean() || is8BitInt(t)) + // result: (MOVBload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsBoolean() || is8BitInt(t)) { + break + } + v.reset(OpAMD64MOVBload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (MOVSSload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(OpAMD64MOVSSload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (MOVSDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(OpAMD64MOVSDload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.Size() == 16 + // result: (VMOVDQUload128 ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.Size() == 16) { + break + } + v.reset(OpAMD64VMOVDQUload128) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.Size() == 32 + // result: (VMOVDQUload256 ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.Size() == 32) { + break + } + v.reset(OpAMD64VMOVDQUload256) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.Size() == 64 + // result: (VMOVDQUload512 ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64VMOVDQUload512) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueAMD64_OpLoadMasked16(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (LoadMasked16 ptr mask mem) + // cond: t.Size() == 64 + // result: (VPMASK16load512 ptr (VPMOVVec16x32ToM mask) mem) + for { + t := v.Type + ptr := v_0 + mask := v_1 + mem := v_2 + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64VPMASK16load512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpLoadMasked32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (LoadMasked32 ptr mask mem) + // cond: t.Size() == 16 + // result: (VPMASK32load128 ptr mask mem) + for { + t := v.Type + ptr := v_0 + mask := v_1 + mem := v_2 + if !(t.Size() == 16) { + break + } + v.reset(OpAMD64VPMASK32load128) + v.AddArg3(ptr, mask, mem) + return true + } + // match: (LoadMasked32 ptr mask mem) + // cond: t.Size() == 32 + // result: (VPMASK32load256 ptr mask mem) + for { + t := v.Type + ptr := v_0 + mask := v_1 + mem := v_2 + if !(t.Size() == 32) { + break + } + v.reset(OpAMD64VPMASK32load256) + v.AddArg3(ptr, mask, mem) + return true + } + // match: (LoadMasked32 ptr mask mem) + // cond: t.Size() == 64 + // result: (VPMASK32load512 ptr (VPMOVVec32x16ToM mask) mem) + for { + t := v.Type + ptr := v_0 + mask := v_1 + mem := v_2 + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64VPMASK32load512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpLoadMasked64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (LoadMasked64 ptr mask mem) + // cond: t.Size() == 16 + // result: (VPMASK64load128 ptr mask mem) + for { + t := v.Type + ptr := v_0 + mask := v_1 + mem := v_2 + if !(t.Size() == 16) { + break + } + v.reset(OpAMD64VPMASK64load128) + v.AddArg3(ptr, mask, mem) + return true + } + // match: (LoadMasked64 ptr mask mem) + // cond: t.Size() == 32 + // result: (VPMASK64load256 ptr mask mem) + for { + t := v.Type + ptr := v_0 + mask := v_1 + mem := v_2 + if !(t.Size() == 32) { + break + } + v.reset(OpAMD64VPMASK64load256) + v.AddArg3(ptr, mask, mem) + return true + } + // match: (LoadMasked64 ptr mask mem) + // cond: t.Size() == 64 + // result: (VPMASK64load512 ptr (VPMOVVec64x8ToM mask) mem) + for { + t := v.Type + ptr := v_0 + mask := v_1 + mem := v_2 + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64VPMASK64load512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpLoadMasked8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (LoadMasked8 ptr mask mem) + // cond: t.Size() == 64 + // result: (VPMASK8load512 ptr (VPMOVVec8x64ToM mask) mem) + for { + t := v.Type + ptr := v_0 + mask := v_1 + mem := v_2 + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64VPMASK8load512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x64ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (LEAQ {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(OpAMD64LEAQ) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (LEAQ {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(OpAMD64LEAQ) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValueAMD64_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPWconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPLconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x64 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPQconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPBconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPWconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPLconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x64 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPQconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPBconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh64x16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDQ (SHLQ x y) (SBBQcarrymask (CMPWconst y [64]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDQ) + v0 := b.NewValue0(v.Pos, OpAMD64SHLQ, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SHLQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh64x32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDQ (SHLQ x y) (SBBQcarrymask (CMPLconst y [64]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDQ) + v0 := b.NewValue0(v.Pos, OpAMD64SHLQ, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SHLQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh64x64 x y) + // cond: !shiftIsBounded(v) + // result: (ANDQ (SHLQ x y) (SBBQcarrymask (CMPQconst y [64]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDQ) + v0 := b.NewValue0(v.Pos, OpAMD64SHLQ, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SHLQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh64x8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDQ (SHLQ x y) (SBBQcarrymask (CMPBconst y [64]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDQ) + v0 := b.NewValue0(v.Pos, OpAMD64SHLQ, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SHLQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPWconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPLconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x64 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPQconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHLL x y) (SBBLcarrymask (CMPBconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SHLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpMax32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Max32F x y) + // result: (Neg32F (Min32F (Neg32F x) (Neg32F y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpNeg32F) + v.Type = t + v0 := b.NewValue0(v.Pos, OpMin32F, t) + v1 := b.NewValue0(v.Pos, OpNeg32F, t) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpNeg32F, t) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpMax64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Max64F x y) + // result: (Neg64F (Min64F (Neg64F x) (Neg64F y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpNeg64F) + v.Type = t + v0 := b.NewValue0(v.Pos, OpMin64F, t) + v1 := b.NewValue0(v.Pos, OpNeg64F, t) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpNeg64F, t) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpMin32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Min32F x y) + // result: (POR (MINSS (MINSS x y) x) (MINSS x y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpAMD64POR) + v0 := b.NewValue0(v.Pos, OpAMD64MINSS, t) + v1 := b.NewValue0(v.Pos, OpAMD64MINSS, t) + v1.AddArg2(x, y) + v0.AddArg2(v1, x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueAMD64_OpMin64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Min64F x y) + // result: (POR (MINSD (MINSD x y) x) (MINSD x y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpAMD64POR) + v0 := b.NewValue0(v.Pos, OpAMD64MINSD, t) + v1 := b.NewValue0(v.Pos, OpAMD64MINSD, t) + v1.AddArg2(x, y) + v0.AddArg2(v1, x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueAMD64_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16 [a] x y) + // result: (Select1 (DIVW [a] x y)) + for { + a := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64DIVW, types.NewTuple(typ.Int16, typ.Int16)) + v0.AuxInt = boolToAuxInt(a) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16u x y) + // result: (Select1 (DIVWU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64DIVWU, types.NewTuple(typ.UInt16, typ.UInt16)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32 [a] x y) + // result: (Select1 (DIVL [a] x y)) + for { + a := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64DIVL, types.NewTuple(typ.Int32, typ.Int32)) + v0.AuxInt = boolToAuxInt(a) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpMod32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32u x y) + // result: (Select1 (DIVLU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64DIVLU, types.NewTuple(typ.UInt32, typ.UInt32)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpMod64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod64 [a] x y) + // result: (Select1 (DIVQ [a] x y)) + for { + a := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64DIVQ, types.NewTuple(typ.Int64, typ.Int64)) + v0.AuxInt = boolToAuxInt(a) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpMod64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod64u x y) + // result: (Select1 (DIVQU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64DIVQU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (Select1 (DIVW (SignExt8to16 x) (SignExt8to16 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64DIVW, types.NewTuple(typ.Int16, typ.Int16)) + v1 := b.NewValue0(v.Pos, OpSignExt8to16, typ.Int16) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to16, typ.Int16) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (Select1 (DIVWU (ZeroExt8to16 x) (ZeroExt8to16 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpAMD64DIVWU, types.NewTuple(typ.UInt16, typ.UInt16)) + v1 := b.NewValue0(v.Pos, OpZeroExt8to16, typ.UInt16) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to16, typ.UInt16) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (MOVBstore dst (MOVBload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVBstore) + v0 := b.NewValue0(v.Pos, OpAMD64MOVBload, typ.UInt8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (MOVWstore dst (MOVWload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVWstore) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWload, typ.UInt16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [4] dst src mem) + // result: (MOVLstore dst (MOVLload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVLstore) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [8] dst src mem) + // result: (MOVQstore dst (MOVQload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVQstore) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [16] dst src mem) + // result: (MOVOstore dst (MOVOload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVOstore) + v0 := b.NewValue0(v.Pos, OpAMD64MOVOload, types.TypeInt128) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [3] dst src mem) + // result: (MOVBstore [2] dst (MOVBload [2] src mem) (MOVWstore dst (MOVWload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpAMD64MOVBload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpAMD64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpAMD64MOVWload, typ.UInt16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [5] dst src mem) + // result: (MOVBstore [4] dst (MOVBload [4] src mem) (MOVLstore dst (MOVLload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpAMD64MOVBload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpAMD64MOVLstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [6] dst src mem) + // result: (MOVWstore [4] dst (MOVWload [4] src mem) (MOVLstore dst (MOVLload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVWstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpAMD64MOVLstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [7] dst src mem) + // result: (MOVLstore [3] dst (MOVLload [3] src mem) (MOVLstore dst (MOVLload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpAMD64MOVLstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [9] dst src mem) + // result: (MOVBstore [8] dst (MOVBload [8] src mem) (MOVQstore dst (MOVQload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 9 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVBstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpAMD64MOVBload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpAMD64MOVQstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [10] dst src mem) + // result: (MOVWstore [8] dst (MOVWload [8] src mem) (MOVQstore dst (MOVQload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 10 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVWstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpAMD64MOVQstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [11] dst src mem) + // result: (MOVLstore [7] dst (MOVLload [7] src mem) (MOVQstore dst (MOVQload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 11 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(7) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(7) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpAMD64MOVQstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [12] dst src mem) + // result: (MOVLstore [8] dst (MOVLload [8] src mem) (MOVQstore dst (MOVQload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpAMD64MOVLstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpAMD64MOVQstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: s >= 13 && s <= 15 + // result: (MOVQstore [int32(s-8)] dst (MOVQload [int32(s-8)] src mem) (MOVQstore dst (MOVQload src mem) mem)) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s >= 13 && s <= 15) { + break + } + v.reset(OpAMD64MOVQstore) + v.AuxInt = int32ToAuxInt(int32(s - 8)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(int32(s - 8)) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpAMD64MOVQstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 16 && s < 192 && logLargeCopy(v, s) + // result: (LoweredMove [s] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 16 && s < 192 && logLargeCopy(v, s)) { + break + } + v.reset(OpAMD64LoweredMove) + v.AuxInt = int64ToAuxInt(s) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] dst src mem) + // cond: s >= 192 && s <= repMoveThreshold && logLargeCopy(v, s) + // result: (LoweredMoveLoop [s] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s >= 192 && s <= repMoveThreshold && logLargeCopy(v, s)) { + break + } + v.reset(OpAMD64LoweredMoveLoop) + v.AuxInt = int64ToAuxInt(s) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] dst src mem) + // cond: s > repMoveThreshold && s%8 != 0 + // result: (Move [s-s%8] (OffPtr dst [s%8]) (OffPtr src [s%8]) (MOVQstore dst (MOVQload src mem) mem)) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > repMoveThreshold && s%8 != 0) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(s - s%8) + v0 := b.NewValue0(v.Pos, OpOffPtr, dst.Type) + v0.AuxInt = int64ToAuxInt(s % 8) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpOffPtr, src.Type) + v1.AuxInt = int64ToAuxInt(s % 8) + v1.AddArg(src) + v2 := b.NewValue0(v.Pos, OpAMD64MOVQstore, types.TypeMem) + v3 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v3.AddArg2(src, mem) + v2.AddArg3(dst, v3, mem) + v.AddArg3(v0, v1, v2) + return true + } + // match: (Move [s] dst src mem) + // cond: s > repMoveThreshold && s%8 == 0 && logLargeCopy(v, s) + // result: (REPMOVSQ dst src (MOVQconst [s/8]) mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > repMoveThreshold && s%8 == 0 && logLargeCopy(v, s)) { + break + } + v.reset(OpAMD64REPMOVSQ) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(s / 8) + v.AddArg4(dst, src, v0, mem) + return true + } + return false +} +func rewriteValueAMD64_OpNeg32F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neg32F x) + // result: (PXOR x (MOVSSconst [float32(math.Copysign(0, -1))])) + for { + x := v_0 + v.reset(OpAMD64PXOR) + v0 := b.NewValue0(v.Pos, OpAMD64MOVSSconst, typ.Float32) + v0.AuxInt = float32ToAuxInt(float32(math.Copysign(0, -1))) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpNeg64F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neg64F x) + // result: (PXOR x (MOVSDconst [math.Copysign(0, -1)])) + for { + x := v_0 + v.reset(OpAMD64PXOR) + v0 := b.NewValue0(v.Pos, OpAMD64MOVSDconst, typ.Float64) + v0.AuxInt = float64ToAuxInt(math.Copysign(0, -1)) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueAMD64_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq16 x y) + // result: (SETNE (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32 x y) + // result: (SETNE (CMPL x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPL, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32F x y) + // result: (SETNEF (UCOMISS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETNEF) + v0 := b.NewValue0(v.Pos, OpAMD64UCOMISS, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64 x y) + // result: (SETNE (CMPQ x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64F x y) + // result: (SETNEF (UCOMISD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETNEF) + v0 := b.NewValue0(v.Pos, OpAMD64UCOMISD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq8 x y) + // result: (SETNE (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNeqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (NeqB x y) + // result: (SETNE (CMPB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPB, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (NeqPtr x y) + // result: (SETNE (CMPQ x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64SETNE) + v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNot(v *Value) bool { + v_0 := v.Args[0] + // match: (Not x) + // result: (XORLconst [1] x) + for { + x := v_0 + v.reset(OpAMD64XORLconst) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpNotEqualFloat32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NotEqualFloat32x16 x y) + // result: (VPMOVMToVec32x16 (VCMPPS512 [4] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPS512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(4) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNotEqualFloat32x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NotEqualFloat32x4 x y) + // result: (VCMPPS128 [4] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS128) + v.AuxInt = uint8ToAuxInt(4) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpNotEqualFloat32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NotEqualFloat32x8 x y) + // result: (VCMPPS256 [4] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPS256) + v.AuxInt = uint8ToAuxInt(4) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpNotEqualFloat64x2(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NotEqualFloat64x2 x y) + // result: (VCMPPD128 [4] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD128) + v.AuxInt = uint8ToAuxInt(4) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpNotEqualFloat64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NotEqualFloat64x4 x y) + // result: (VCMPPD256 [4] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VCMPPD256) + v.AuxInt = uint8ToAuxInt(4) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpNotEqualFloat64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NotEqualFloat64x8 x y) + // result: (VPMOVMToVec64x8 (VCMPPD512 [4] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VCMPPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(4) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNotEqualInt16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NotEqualInt16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPW512 [4] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPW512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(4) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNotEqualInt32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NotEqualInt32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPD512 [4] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(4) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNotEqualInt64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NotEqualInt64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPQ512 [4] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPQ512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(4) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNotEqualInt8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NotEqualInt8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPB512 [4] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPB512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(4) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNotEqualUint16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NotEqualUint16x32 x y) + // result: (VPMOVMToVec16x32 (VPCMPUW512 [4] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec16x32) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUW512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(4) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNotEqualUint32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NotEqualUint32x16 x y) + // result: (VPMOVMToVec32x16 (VPCMPUD512 [4] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec32x16) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUD512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(4) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNotEqualUint64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NotEqualUint64x8 x y) + // result: (VPMOVMToVec64x8 (VPCMPUQ512 [4] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec64x8) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUQ512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(4) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpNotEqualUint8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NotEqualUint8x64 x y) + // result: (VPMOVMToVec8x64 (VPCMPUB512 [4] x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VPMOVMToVec8x64) + v0 := b.NewValue0(v.Pos, OpAMD64VPCMPUB512, typ.Mask) + v0.AuxInt = uint8ToAuxInt(4) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (OffPtr [off] ptr) + // cond: is32Bit(off) + // result: (ADDQconst [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + if !(is32Bit(off)) { + break + } + v.reset(OpAMD64ADDQconst) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } + // match: (OffPtr [off] ptr) + // result: (ADDQ (MOVQconst [off]) ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + v.reset(OpAMD64ADDQ) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(off) + v.AddArg2(v0, ptr) + return true + } +} +func rewriteValueAMD64_OpPopCount16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount16 x) + // result: (POPCNTL (MOVWQZX x)) + for { + x := v_0 + v.reset(OpAMD64POPCNTL) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWQZX, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpPopCount8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount8 x) + // result: (POPCNTL (MOVBQZX x)) + for { + x := v_0 + v.reset(OpAMD64POPCNTL) + v0 := b.NewValue0(v.Pos, OpAMD64MOVBQZX, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpRoundToEven(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEven x) + // result: (ROUNDSD [0] x) + for { + x := v_0 + v.reset(OpAMD64ROUNDSD) + v.AuxInt = int8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenFloat32x4 x) + // result: (VROUNDPS128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPS128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenFloat32x8 x) + // result: (VROUNDPS256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPS256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenFloat64x2 x) + // result: (VROUNDPD128 [0] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPD128) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenFloat64x4 x) + // result: (VROUNDPD256 [0] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPD256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledFloat32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledFloat32x16 [a] x) + // result: (VRNDSCALEPS512 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS512) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledFloat32x4 [a] x) + // result: (VRNDSCALEPS128 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS128) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledFloat32x8 [a] x) + // result: (VRNDSCALEPS256 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS256) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledFloat64x2 [a] x) + // result: (VRNDSCALEPD128 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD128) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledFloat64x4 [a] x) + // result: (VRNDSCALEPD256 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD256) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledFloat64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledFloat64x8 [a] x) + // result: (VRNDSCALEPD512 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD512) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledResidueFloat32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledResidueFloat32x16 [a] x) + // result: (VREDUCEPS512 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS512) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledResidueFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledResidueFloat32x4 [a] x) + // result: (VREDUCEPS128 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS128) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledResidueFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledResidueFloat32x8 [a] x) + // result: (VREDUCEPS256 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS256) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledResidueFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledResidueFloat64x2 [a] x) + // result: (VREDUCEPD128 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD128) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledResidueFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledResidueFloat64x4 [a] x) + // result: (VREDUCEPD256 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD256) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRoundToEvenScaledResidueFloat64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEvenScaledResidueFloat64x8 [a] x) + // result: (VREDUCEPD512 [a+0] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD512) + v.AuxInt = uint8ToAuxInt(a + 0) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRW x y) (SBBLcarrymask (CMPWconst y [16]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(16) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SHRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRW x y) (SBBLcarrymask (CMPLconst y [16]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(16) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SHRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRW x y) (SBBLcarrymask (CMPQconst y [16]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(16) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SHRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRW x y) (SBBLcarrymask (CMPBconst y [16]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(16) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SHRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16x16 x y) + // cond: !shiftIsBounded(v) + // result: (SARW x (ORL y (NOTL (SBBLcarrymask (CMPWconst y [16]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v3.AuxInt = int16ToAuxInt(16) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SARW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16x32 x y) + // cond: !shiftIsBounded(v) + // result: (SARW x (ORL y (NOTL (SBBLcarrymask (CMPLconst y [16]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(16) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SARW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16x64 x y) + // cond: !shiftIsBounded(v) + // result: (SARW x (ORQ y (NOTQ (SBBQcarrymask (CMPQconst y [16]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORQ, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTQ, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(16) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SARW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16x8 x y) + // cond: !shiftIsBounded(v) + // result: (SARW x (ORL y (NOTL (SBBLcarrymask (CMPBconst y [16]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v3.AuxInt = int8ToAuxInt(16) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SARW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRL x y) (SBBLcarrymask (CMPWconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SHRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRL x y) (SBBLcarrymask (CMPLconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SHRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRL x y) (SBBLcarrymask (CMPQconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SHRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRL x y) (SBBLcarrymask (CMPBconst y [32]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SHRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x16 x y) + // cond: !shiftIsBounded(v) + // result: (SARL x (ORL y (NOTL (SBBLcarrymask (CMPWconst y [32]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v3.AuxInt = int16ToAuxInt(32) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SARL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x32 x y) + // cond: !shiftIsBounded(v) + // result: (SARL x (ORL y (NOTL (SBBLcarrymask (CMPLconst y [32]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SARL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x64 x y) + // cond: !shiftIsBounded(v) + // result: (SARL x (ORQ y (NOTQ (SBBQcarrymask (CMPQconst y [32]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORQ, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTQ, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SARL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x8 x y) + // cond: !shiftIsBounded(v) + // result: (SARL x (ORL y (NOTL (SBBLcarrymask (CMPBconst y [32]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v3.AuxInt = int8ToAuxInt(32) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SARL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh64Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDQ (SHRQ x y) (SBBQcarrymask (CMPWconst y [64]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDQ) + v0 := b.NewValue0(v.Pos, OpAMD64SHRQ, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh64Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SHRQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh64Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDQ (SHRQ x y) (SBBQcarrymask (CMPLconst y [64]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDQ) + v0 := b.NewValue0(v.Pos, OpAMD64SHRQ, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh64Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SHRQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh64Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (ANDQ (SHRQ x y) (SBBQcarrymask (CMPQconst y [64]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDQ) + v0 := b.NewValue0(v.Pos, OpAMD64SHRQ, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh64Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SHRQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh64Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDQ (SHRQ x y) (SBBQcarrymask (CMPBconst y [64]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDQ) + v0 := b.NewValue0(v.Pos, OpAMD64SHRQ, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh64Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SHRQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x16 x y) + // cond: !shiftIsBounded(v) + // result: (SARQ x (ORL y (NOTL (SBBLcarrymask (CMPWconst y [64]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARQ) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v3.AuxInt = int16ToAuxInt(64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SARQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x32 x y) + // cond: !shiftIsBounded(v) + // result: (SARQ x (ORL y (NOTL (SBBLcarrymask (CMPLconst y [64]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARQ) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SARQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x64 x y) + // cond: !shiftIsBounded(v) + // result: (SARQ x (ORQ y (NOTQ (SBBQcarrymask (CMPQconst y [64]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARQ) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORQ, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTQ, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SARQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x8 x y) + // cond: !shiftIsBounded(v) + // result: (SARQ x (ORL y (NOTL (SBBLcarrymask (CMPBconst y [64]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARQ) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v3.AuxInt = int8ToAuxInt(64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SARQ x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRB x y) (SBBLcarrymask (CMPWconst y [8]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRB, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v2.AuxInt = int16ToAuxInt(8) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SHRB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRB x y) (SBBLcarrymask (CMPLconst y [8]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRB, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(8) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SHRB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRB x y) (SBBLcarrymask (CMPQconst y [8]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRB, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(8) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SHRB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (ANDL (SHRB x y) (SBBLcarrymask (CMPBconst y [8]))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64ANDL) + v0 := b.NewValue0(v.Pos, OpAMD64SHRB, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, t) + v2 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v2.AuxInt = int8ToAuxInt(8) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SHRB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SHRB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x16 x y) + // cond: !shiftIsBounded(v) + // result: (SARB x (ORL y (NOTL (SBBLcarrymask (CMPWconst y [8]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARB) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPWconst, types.TypeFlags) + v3.AuxInt = int16ToAuxInt(8) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SARB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x32 x y) + // cond: !shiftIsBounded(v) + // result: (SARB x (ORL y (NOTL (SBBLcarrymask (CMPLconst y [8]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARB) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPLconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(8) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SARB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x64 x y) + // cond: !shiftIsBounded(v) + // result: (SARB x (ORQ y (NOTQ (SBBQcarrymask (CMPQconst y [8]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARB) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORQ, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTQ, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPQconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(8) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SARB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x8 x y) + // cond: !shiftIsBounded(v) + // result: (SARB x (ORL y (NOTL (SBBLcarrymask (CMPBconst y [8]))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARB) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAMD64ORL, y.Type) + v1 := b.NewValue0(v.Pos, OpAMD64NOTL, y.Type) + v2 := b.NewValue0(v.Pos, OpAMD64SBBLcarrymask, y.Type) + v3 := b.NewValue0(v.Pos, OpAMD64CMPBconst, types.TypeFlags) + v3.AuxInt = int8ToAuxInt(8) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SARB x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpAMD64SARB) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select0 (Mul64uover x y)) + // result: (Select0 (MULQU x y)) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpSelect0) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpAMD64MULQU, types.NewTuple(typ.UInt64, types.TypeFlags)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (Select0 (Mul32uover x y)) + // result: (Select0 (MULLU x y)) + for { + if v_0.Op != OpMul32uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpSelect0) + v.Type = typ.UInt32 + v0 := b.NewValue0(v.Pos, OpAMD64MULLU, types.NewTuple(typ.UInt32, types.TypeFlags)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (Select0 (Add64carry x y c)) + // result: (Select0 (ADCQ x y (Select1 (NEGLflags c)))) + for { + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpSelect0) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpAMD64ADCQ, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v2 := b.NewValue0(v.Pos, OpAMD64NEGLflags, types.NewTuple(typ.UInt32, types.TypeFlags)) + v2.AddArg(c) + v1.AddArg(v2) + v0.AddArg3(x, y, v1) + v.AddArg(v0) + return true + } + // match: (Select0 (Sub64borrow x y c)) + // result: (Select0 (SBBQ x y (Select1 (NEGLflags c)))) + for { + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpSelect0) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpAMD64SBBQ, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v2 := b.NewValue0(v.Pos, OpAMD64NEGLflags, types.NewTuple(typ.UInt32, types.TypeFlags)) + v2.AddArg(c) + v1.AddArg(v2) + v0.AddArg3(x, y, v1) + v.AddArg(v0) + return true + } + // match: (Select0 (AddTupleFirst32 val tuple)) + // result: (ADDL val (Select0 tuple)) + for { + t := v.Type + if v_0.Op != OpAMD64AddTupleFirst32 { + break + } + tuple := v_0.Args[1] + val := v_0.Args[0] + v.reset(OpAMD64ADDL) + v0 := b.NewValue0(v.Pos, OpSelect0, t) + v0.AddArg(tuple) + v.AddArg2(val, v0) + return true + } + // match: (Select0 (AddTupleFirst64 val tuple)) + // result: (ADDQ val (Select0 tuple)) + for { + t := v.Type + if v_0.Op != OpAMD64AddTupleFirst64 { + break + } + tuple := v_0.Args[1] + val := v_0.Args[0] + v.reset(OpAMD64ADDQ) + v0 := b.NewValue0(v.Pos, OpSelect0, t) + v0.AddArg(tuple) + v.AddArg2(val, v0) + return true + } + // match: (Select0 a:(ADDQconstflags [c] x)) + // cond: a.Uses == 1 + // result: (ADDQconst [c] x) + for { + a := v_0 + if a.Op != OpAMD64ADDQconstflags { + break + } + c := auxIntToInt32(a.AuxInt) + x := a.Args[0] + if !(a.Uses == 1) { + break + } + v.reset(OpAMD64ADDQconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (Select0 a:(ADDLconstflags [c] x)) + // cond: a.Uses == 1 + // result: (ADDLconst [c] x) + for { + a := v_0 + if a.Op != OpAMD64ADDLconstflags { + break + } + c := auxIntToInt32(a.AuxInt) + x := a.Args[0] + if !(a.Uses == 1) { + break + } + v.reset(OpAMD64ADDLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueAMD64_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select1 (Mul64uover x y)) + // result: (SETO (Select1 (MULQU x y))) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpAMD64SETO) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpAMD64MULQU, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Select1 (Mul32uover x y)) + // result: (SETO (Select1 (MULLU x y))) + for { + if v_0.Op != OpMul32uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpAMD64SETO) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpAMD64MULLU, types.NewTuple(typ.UInt32, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Select1 (Add64carry x y c)) + // result: (NEGQ (SBBQcarrymask (Select1 (ADCQ x y (Select1 (NEGLflags c)))))) + for { + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpAMD64NEGQ) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v2 := b.NewValue0(v.Pos, OpAMD64ADCQ, types.NewTuple(typ.UInt64, types.TypeFlags)) + v3 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v4 := b.NewValue0(v.Pos, OpAMD64NEGLflags, types.NewTuple(typ.UInt32, types.TypeFlags)) + v4.AddArg(c) + v3.AddArg(v4) + v2.AddArg3(x, y, v3) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Select1 (Sub64borrow x y c)) + // result: (NEGQ (SBBQcarrymask (Select1 (SBBQ x y (Select1 (NEGLflags c)))))) + for { + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpAMD64NEGQ) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpAMD64SBBQcarrymask, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v2 := b.NewValue0(v.Pos, OpAMD64SBBQ, types.NewTuple(typ.UInt64, types.TypeFlags)) + v3 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v4 := b.NewValue0(v.Pos, OpAMD64NEGLflags, types.NewTuple(typ.UInt32, types.TypeFlags)) + v4.AddArg(c) + v3.AddArg(v4) + v2.AddArg3(x, y, v3) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Select1 (NEGLflags (MOVQconst [0]))) + // result: (FlagEQ) + for { + if v_0.Op != OpAMD64NEGLflags { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_0_0.AuxInt) != 0 { + break + } + v.reset(OpAMD64FlagEQ) + return true + } + // match: (Select1 (NEGLflags (NEGQ (SBBQcarrymask x)))) + // result: x + for { + if v_0.Op != OpAMD64NEGLflags { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64NEGQ { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64SBBQcarrymask { + break + } + x := v_0_0_0.Args[0] + v.copyOf(x) + return true + } + // match: (Select1 (AddTupleFirst32 _ tuple)) + // result: (Select1 tuple) + for { + if v_0.Op != OpAMD64AddTupleFirst32 { + break + } + tuple := v_0.Args[1] + v.reset(OpSelect1) + v.AddArg(tuple) + return true + } + // match: (Select1 (AddTupleFirst64 _ tuple)) + // result: (Select1 tuple) + for { + if v_0.Op != OpAMD64AddTupleFirst64 { + break + } + tuple := v_0.Args[1] + v.reset(OpSelect1) + v.AddArg(tuple) + return true + } + // match: (Select1 a:(LoweredAtomicAnd64 ptr val mem)) + // cond: a.Uses == 1 && clobber(a) + // result: (ANDQlock ptr val mem) + for { + a := v_0 + if a.Op != OpAMD64LoweredAtomicAnd64 { + break + } + mem := a.Args[2] + ptr := a.Args[0] + val := a.Args[1] + if !(a.Uses == 1 && clobber(a)) { + break + } + v.reset(OpAMD64ANDQlock) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Select1 a:(LoweredAtomicAnd32 ptr val mem)) + // cond: a.Uses == 1 && clobber(a) + // result: (ANDLlock ptr val mem) + for { + a := v_0 + if a.Op != OpAMD64LoweredAtomicAnd32 { + break + } + mem := a.Args[2] + ptr := a.Args[0] + val := a.Args[1] + if !(a.Uses == 1 && clobber(a)) { + break + } + v.reset(OpAMD64ANDLlock) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Select1 a:(LoweredAtomicOr64 ptr val mem)) + // cond: a.Uses == 1 && clobber(a) + // result: (ORQlock ptr val mem) + for { + a := v_0 + if a.Op != OpAMD64LoweredAtomicOr64 { + break + } + mem := a.Args[2] + ptr := a.Args[0] + val := a.Args[1] + if !(a.Uses == 1 && clobber(a)) { + break + } + v.reset(OpAMD64ORQlock) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Select1 a:(LoweredAtomicOr32 ptr val mem)) + // cond: a.Uses == 1 && clobber(a) + // result: (ORLlock ptr val mem) + for { + a := v_0 + if a.Op != OpAMD64LoweredAtomicOr32 { + break + } + mem := a.Args[2] + ptr := a.Args[0] + val := a.Args[1] + if !(a.Uses == 1 && clobber(a)) { + break + } + v.reset(OpAMD64ORLlock) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpSelectN(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (SelectN [0] call:(CALLstatic {sym} s1:(MOVQstoreconst _ [sc] s2:(MOVQstore _ src s3:(MOVQstore _ dst mem))))) + // cond: sc.Val64() >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, sc.Val64(), config) && clobber(s1, s2, s3, call) + // result: (Move [sc.Val64()] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpAMD64CALLstatic || len(call.Args) != 1 { + break + } + sym := auxToCall(call.Aux) + s1 := call.Args[0] + if s1.Op != OpAMD64MOVQstoreconst { + break + } + sc := auxIntToValAndOff(s1.AuxInt) + _ = s1.Args[1] + s2 := s1.Args[1] + if s2.Op != OpAMD64MOVQstore { + break + } + _ = s2.Args[2] + src := s2.Args[1] + s3 := s2.Args[2] + if s3.Op != OpAMD64MOVQstore { + break + } + mem := s3.Args[2] + dst := s3.Args[1] + if !(sc.Val64() >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, sc.Val64(), config) && clobber(s1, s2, s3, call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(sc.Val64()) + v.AddArg3(dst, src, mem) + return true + } + // match: (SelectN [0] call:(CALLstatic {sym} dst src (MOVQconst [sz]) mem)) + // cond: sz >= 0 && isSameCall(sym, "runtime.memmove") && call.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(call) + // result: (Move [sz] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpAMD64CALLstatic || len(call.Args) != 4 { + break + } + sym := auxToCall(call.Aux) + mem := call.Args[3] + dst := call.Args[0] + src := call.Args[1] + call_2 := call.Args[2] + if call_2.Op != OpAMD64MOVQconst { + break + } + sz := auxIntToInt64(call_2.AuxInt) + if !(sz >= 0 && isSameCall(sym, "runtime.memmove") && call.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(sz) + v.AddArg3(dst, src, mem) + return true + } + return false +} +func rewriteValueAMD64_OpSetHiFloat32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiFloat32x16 x y) + // result: (VINSERTF64X4512 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTF64X4512) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiFloat32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiFloat32x8 x y) + // result: (VINSERTF128256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTF128256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiFloat64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiFloat64x4 x y) + // result: (VINSERTF128256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTF128256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiFloat64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiFloat64x8 x y) + // result: (VINSERTF64X4512 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTF64X4512) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiInt16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiInt16x16 x y) + // result: (VINSERTI128256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiInt16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiInt16x32 x y) + // result: (VINSERTI64X4512 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiInt32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiInt32x16 x y) + // result: (VINSERTI64X4512 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiInt32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiInt32x8 x y) + // result: (VINSERTI128256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiInt64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiInt64x4 x y) + // result: (VINSERTI128256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiInt64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiInt64x8 x y) + // result: (VINSERTI64X4512 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiInt8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiInt8x32 x y) + // result: (VINSERTI128256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiInt8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiInt8x64 x y) + // result: (VINSERTI64X4512 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiUint16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiUint16x16 x y) + // result: (VINSERTI128256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiUint16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiUint16x32 x y) + // result: (VINSERTI64X4512 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiUint32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiUint32x16 x y) + // result: (VINSERTI64X4512 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiUint32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiUint32x8 x y) + // result: (VINSERTI128256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiUint64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiUint64x4 x y) + // result: (VINSERTI128256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiUint64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiUint64x8 x y) + // result: (VINSERTI64X4512 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiUint8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiUint8x32 x y) + // result: (VINSERTI128256 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetHiUint8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetHiUint8x64 x y) + // result: (VINSERTI64X4512 [1] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(1) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoFloat32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoFloat32x16 x y) + // result: (VINSERTF64X4512 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTF64X4512) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoFloat32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoFloat32x8 x y) + // result: (VINSERTF128256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTF128256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoFloat64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoFloat64x4 x y) + // result: (VINSERTF128256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTF128256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoFloat64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoFloat64x8 x y) + // result: (VINSERTF64X4512 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTF64X4512) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoInt16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoInt16x16 x y) + // result: (VINSERTI128256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoInt16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoInt16x32 x y) + // result: (VINSERTI64X4512 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoInt32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoInt32x16 x y) + // result: (VINSERTI64X4512 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoInt32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoInt32x8 x y) + // result: (VINSERTI128256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoInt64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoInt64x4 x y) + // result: (VINSERTI128256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoInt64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoInt64x8 x y) + // result: (VINSERTI64X4512 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoInt8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoInt8x32 x y) + // result: (VINSERTI128256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoInt8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoInt8x64 x y) + // result: (VINSERTI64X4512 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoUint16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoUint16x16 x y) + // result: (VINSERTI128256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoUint16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoUint16x32 x y) + // result: (VINSERTI64X4512 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoUint32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoUint32x16 x y) + // result: (VINSERTI64X4512 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoUint32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoUint32x8 x y) + // result: (VINSERTI128256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoUint64x4(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoUint64x4 x y) + // result: (VINSERTI128256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoUint64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoUint64x8 x y) + // result: (VINSERTI64X4512 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoUint8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoUint8x32 x y) + // result: (VINSERTI128256 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI128256) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSetLoUint8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SetLoUint8x64 x y) + // result: (VINSERTI64X4512 [0] x y) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64VINSERTI64X4512) + v.AuxInt = uint8ToAuxInt(0) + v.AddArg2(x, y) + return true + } +} +func rewriteValueAMD64_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Slicemask x) + // result: (SARQconst (NEGQ x) [63]) + for { + t := v.Type + x := v_0 + v.reset(OpAMD64SARQconst) + v.AuxInt = int8ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpAMD64NEGQ, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueAMD64_OpSpectreIndex(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SpectreIndex x y) + // result: (CMOVQCC x (MOVQconst [0]) (CMPQ x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64CMOVQCC) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v1.AddArg2(x, y) + v.AddArg3(x, v0, v1) + return true + } +} +func rewriteValueAMD64_OpSpectreSliceIndex(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SpectreSliceIndex x y) + // result: (CMOVQHI x (MOVQconst [0]) (CMPQ x y)) + for { + x := v_0 + y := v_1 + v.reset(OpAMD64CMOVQHI) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags) + v1.AddArg2(x, y) + v.AddArg3(x, v0, v1) + return true + } +} +func rewriteValueAMD64_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && t.IsFloat() + // result: (MOVSDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && t.IsFloat()) { + break + } + v.reset(OpAMD64MOVSDstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && t.IsFloat() + // result: (MOVSSstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && t.IsFloat()) { + break + } + v.reset(OpAMD64MOVSSstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && !t.IsFloat() + // result: (MOVQstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && !t.IsFloat()) { + break + } + v.reset(OpAMD64MOVQstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && !t.IsFloat() + // result: (MOVLstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && !t.IsFloat()) { + break + } + v.reset(OpAMD64MOVLstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (MOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(OpAMD64MOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (MOVBstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(OpAMD64MOVBstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 16 + // result: (VMOVDQUstore128 ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 16) { + break + } + v.reset(OpAMD64VMOVDQUstore128) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 32 + // result: (VMOVDQUstore256 ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 32) { + break + } + v.reset(OpAMD64VMOVDQUstore256) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 64 + // result: (VMOVDQUstore512 ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64VMOVDQUstore512) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpStoreMasked16(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (StoreMasked16 {t} ptr mask val mem) + // cond: t.Size() == 64 + // result: (VPMASK16store512 ptr (VPMOVVec16x32ToM mask) val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + mask := v_1 + val := v_2 + mem := v_3 + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64VPMASK16store512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(ptr, v0, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpStoreMasked32(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (StoreMasked32 {t} ptr mask val mem) + // cond: t.Size() == 16 + // result: (VPMASK32store128 ptr mask val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + mask := v_1 + val := v_2 + mem := v_3 + if !(t.Size() == 16) { + break + } + v.reset(OpAMD64VPMASK32store128) + v.AddArg4(ptr, mask, val, mem) + return true + } + // match: (StoreMasked32 {t} ptr mask val mem) + // cond: t.Size() == 32 + // result: (VPMASK32store256 ptr mask val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + mask := v_1 + val := v_2 + mem := v_3 + if !(t.Size() == 32) { + break + } + v.reset(OpAMD64VPMASK32store256) + v.AddArg4(ptr, mask, val, mem) + return true + } + // match: (StoreMasked32 {t} ptr mask val mem) + // cond: t.Size() == 64 + // result: (VPMASK32store512 ptr (VPMOVVec32x16ToM mask) val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + mask := v_1 + val := v_2 + mem := v_3 + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64VPMASK32store512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(ptr, v0, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpStoreMasked64(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (StoreMasked64 {t} ptr mask val mem) + // cond: t.Size() == 16 + // result: (VPMASK64store128 ptr mask val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + mask := v_1 + val := v_2 + mem := v_3 + if !(t.Size() == 16) { + break + } + v.reset(OpAMD64VPMASK64store128) + v.AddArg4(ptr, mask, val, mem) + return true + } + // match: (StoreMasked64 {t} ptr mask val mem) + // cond: t.Size() == 32 + // result: (VPMASK64store256 ptr mask val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + mask := v_1 + val := v_2 + mem := v_3 + if !(t.Size() == 32) { + break + } + v.reset(OpAMD64VPMASK64store256) + v.AddArg4(ptr, mask, val, mem) + return true + } + // match: (StoreMasked64 {t} ptr mask val mem) + // cond: t.Size() == 64 + // result: (VPMASK64store512 ptr (VPMOVVec64x8ToM mask) val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + mask := v_1 + val := v_2 + mem := v_3 + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64VPMASK64store512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(ptr, v0, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpStoreMasked8(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (StoreMasked8 {t} ptr mask val mem) + // cond: t.Size() == 64 + // result: (VPMASK8store512 ptr (VPMOVVec8x64ToM mask) val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + mask := v_1 + val := v_2 + mem := v_3 + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64VPMASK8store512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x64ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg4(ptr, v0, val, mem) + return true + } + return false +} +func rewriteValueAMD64_OpTrunc(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc x) + // result: (ROUNDSD [3] x) + for { + x := v_0 + v.reset(OpAMD64ROUNDSD) + v.AuxInt = int8ToAuxInt(3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncFloat32x4 x) + // result: (VROUNDPS128 [3] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPS128) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncFloat32x8 x) + // result: (VROUNDPS256 [3] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPS256) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncFloat64x2 x) + // result: (VROUNDPD128 [3] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPD128) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncFloat64x4 x) + // result: (VROUNDPD256 [3] x) + for { + x := v_0 + v.reset(OpAMD64VROUNDPD256) + v.AuxInt = uint8ToAuxInt(3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledFloat32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledFloat32x16 [a] x) + // result: (VRNDSCALEPS512 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS512) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledFloat32x4 [a] x) + // result: (VRNDSCALEPS128 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS128) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledFloat32x8 [a] x) + // result: (VRNDSCALEPS256 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPS256) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledFloat64x2 [a] x) + // result: (VRNDSCALEPD128 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD128) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledFloat64x4 [a] x) + // result: (VRNDSCALEPD256 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD256) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledFloat64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledFloat64x8 [a] x) + // result: (VRNDSCALEPD512 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VRNDSCALEPD512) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledResidueFloat32x16(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledResidueFloat32x16 [a] x) + // result: (VREDUCEPS512 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS512) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledResidueFloat32x4(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledResidueFloat32x4 [a] x) + // result: (VREDUCEPS128 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS128) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledResidueFloat32x8(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledResidueFloat32x8 [a] x) + // result: (VREDUCEPS256 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPS256) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledResidueFloat64x2(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledResidueFloat64x2 [a] x) + // result: (VREDUCEPD128 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD128) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledResidueFloat64x4(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledResidueFloat64x4 [a] x) + // result: (VREDUCEPD256 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD256) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpTruncScaledResidueFloat64x8(v *Value) bool { + v_0 := v.Args[0] + // match: (TruncScaledResidueFloat64x8 [a] x) + // result: (VREDUCEPD512 [a+3] x) + for { + a := auxIntToUint8(v.AuxInt) + x := v_0 + v.reset(OpAMD64VREDUCEPD512) + v.AuxInt = uint8ToAuxInt(a + 3) + v.AddArg(x) + return true + } +} +func rewriteValueAMD64_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] destptr mem) + // result: (MOVBstoreconst [makeValAndOff(0,0)] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [2] destptr mem) + // result: (MOVWstoreconst [makeValAndOff(0,0)] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [4] destptr mem) + // result: (MOVLstoreconst [makeValAndOff(0,0)] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [8] destptr mem) + // result: (MOVQstoreconst [makeValAndOff(0,0)] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVQstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [3] destptr mem) + // result: (MOVBstoreconst [makeValAndOff(0,2)] destptr (MOVWstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 2)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [5] destptr mem) + // result: (MOVBstoreconst [makeValAndOff(0,4)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 4)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [6] destptr mem) + // result: (MOVWstoreconst [makeValAndOff(0,4)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 4)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [7] destptr mem) + // result: (MOVLstoreconst [makeValAndOff(0,3)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 3)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [9] destptr mem) + // result: (MOVBstoreconst [makeValAndOff(0,8)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 9 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 8)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [10] destptr mem) + // result: (MOVWstoreconst [makeValAndOff(0,8)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 10 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 8)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [11] destptr mem) + // result: (MOVLstoreconst [makeValAndOff(0,7)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 11 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 7)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [12] destptr mem) + // result: (MOVLstoreconst [makeValAndOff(0,8)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpAMD64MOVLstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 8)) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [s] destptr mem) + // cond: s > 12 && s < 16 + // result: (MOVQstoreconst [makeValAndOff(0,int32(s-8))] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s > 12 && s < 16) { + break + } + v.reset(OpAMD64MOVQstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, int32(s-8))) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [s] destptr mem) + // cond: s >= 16 && s < 192 + // result: (LoweredZero [s] destptr mem) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s >= 16 && s < 192) { + break + } + v.reset(OpAMD64LoweredZero) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [s] destptr mem) + // cond: s >= 192 && s <= repZeroThreshold + // result: (LoweredZeroLoop [s] destptr mem) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s >= 192 && s <= repZeroThreshold) { + break + } + v.reset(OpAMD64LoweredZeroLoop) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [s] destptr mem) + // cond: s > repZeroThreshold && s%8 != 0 + // result: (Zero [s-s%8] (OffPtr destptr [s%8]) (MOVOstoreconst [makeValAndOff(0,0)] destptr mem)) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s > repZeroThreshold && s%8 != 0) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(s - s%8) + v0 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) + v0.AuxInt = int64ToAuxInt(s % 8) + v0.AddArg(destptr) + v1 := b.NewValue0(v.Pos, OpAMD64MOVOstoreconst, types.TypeMem) + v1.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 0)) + v1.AddArg2(destptr, mem) + v.AddArg2(v0, v1) + return true + } + // match: (Zero [s] destptr mem) + // cond: s > repZeroThreshold && s%8 == 0 + // result: (REPSTOSQ destptr (MOVQconst [s/8]) (MOVQconst [0]) mem) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s > repZeroThreshold && s%8 == 0) { + break + } + v.reset(OpAMD64REPSTOSQ) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(s / 8) + v1 := b.NewValue0(v.Pos, OpAMD64MOVQconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v.AddArg4(destptr, v0, v1, mem) + return true + } + return false +} +func rewriteValueAMD64_OpZeroSIMD(v *Value) bool { + // match: (ZeroSIMD ) + // cond: t.Size() == 16 + // result: (Zero128 ) + for { + t := v.Type + if !(t.Size() == 16) { + break + } + v.reset(OpAMD64Zero128) + v.Type = t + return true + } + // match: (ZeroSIMD ) + // cond: t.Size() == 32 + // result: (Zero256 ) + for { + t := v.Type + if !(t.Size() == 32) { + break + } + v.reset(OpAMD64Zero256) + v.Type = t + return true + } + // match: (ZeroSIMD ) + // cond: t.Size() == 64 + // result: (Zero512 ) + for { + t := v.Type + if !(t.Size() == 64) { + break + } + v.reset(OpAMD64Zero512) + v.Type = t + return true + } + return false +} +func rewriteValueAMD64_OpblendMaskedInt16x32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (blendMaskedInt16x32 x y mask) + // result: (VPBLENDMWMasked512 x y (VPMOVVec16x32ToM mask)) + for { + x := v_0 + y := v_1 + mask := v_2 + v.reset(OpAMD64VPBLENDMWMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec16x32ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(x, y, v0) + return true + } +} +func rewriteValueAMD64_OpblendMaskedInt32x16(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (blendMaskedInt32x16 x y mask) + // result: (VPBLENDMDMasked512 x y (VPMOVVec32x16ToM mask)) + for { + x := v_0 + y := v_1 + mask := v_2 + v.reset(OpAMD64VPBLENDMDMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec32x16ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(x, y, v0) + return true + } +} +func rewriteValueAMD64_OpblendMaskedInt64x8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (blendMaskedInt64x8 x y mask) + // result: (VPBLENDMQMasked512 x y (VPMOVVec64x8ToM mask)) + for { + x := v_0 + y := v_1 + mask := v_2 + v.reset(OpAMD64VPBLENDMQMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec64x8ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(x, y, v0) + return true + } +} +func rewriteValueAMD64_OpblendMaskedInt8x64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (blendMaskedInt8x64 x y mask) + // result: (VPBLENDMBMasked512 x y (VPMOVVec8x64ToM mask)) + for { + x := v_0 + y := v_1 + mask := v_2 + v.reset(OpAMD64VPBLENDMBMasked512) + v0 := b.NewValue0(v.Pos, OpAMD64VPMOVVec8x64ToM, types.TypeMask) + v0.AddArg(mask) + v.AddArg3(x, y, v0) + return true + } +} +func rewriteBlockAMD64(b *Block) bool { + typ := &b.Func.Config.Types + switch b.Kind { + case BlockAMD64EQ: + // match: (EQ (TESTL (SHLL (MOVLconst [1]) x) y)) + // result: (UGE (BTL x y)) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64SHLL { + continue + } + x := v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_0_0_0.AuxInt) != 1 { + continue + } + y := v_0_1 + v0 := b.NewValue0(v_0.Pos, OpAMD64BTL, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + break + } + // match: (EQ (TESTQ (SHLQ (MOVQconst [1]) x) y)) + // result: (UGE (BTQ x y)) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64SHLQ { + continue + } + x := v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_0_0_0.AuxInt) != 1 { + continue + } + y := v_0_1 + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQ, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + break + } + // match: (EQ (TESTLconst [c] x)) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (UGE (BTLconst [int8(log32u(uint32(c)))] x)) + for b.Controls[0].Op == OpAMD64TESTLconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(isUnsignedPowerOfTwo(uint32(c))) { + break + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + // match: (EQ (TESTQconst [c] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (UGE (BTQconst [int8(log32u(uint32(c)))] x)) + for b.Controls[0].Op == OpAMD64TESTQconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(isUnsignedPowerOfTwo(uint64(c))) { + break + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + // match: (EQ (TESTQ (MOVQconst [c]) x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (UGE (BTQconst [int8(log64u(uint64(c)))] x)) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + x := v_0_1 + if !(isUnsignedPowerOfTwo(uint64(c))) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) + v0.AddArg(x) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + break + } + // match: (EQ (TESTQ z1:(SHLQconst [63] (SHRQconst [63] x)) z2)) + // cond: z1==z2 + // result: (UGE (BTQconst [63] x)) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHLQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + break + } + // match: (EQ (TESTL z1:(SHLLconst [31] (SHRQconst [31] x)) z2)) + // cond: z1==z2 + // result: (UGE (BTQconst [31] x)) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHLLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRQconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + break + } + // match: (EQ (TESTQ z1:(SHRQconst [63] (SHLQconst [63] x)) z2)) + // cond: z1==z2 + // result: (UGE (BTQconst [0] x)) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + break + } + // match: (EQ (TESTL z1:(SHRLconst [31] (SHLLconst [31] x)) z2)) + // cond: z1==z2 + // result: (UGE (BTLconst [0] x)) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLLconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + break + } + // match: (EQ (TESTQ z1:(SHRQconst [63] x) z2)) + // cond: z1==z2 + // result: (UGE (BTQconst [63] x)) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + x := z1.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + break + } + // match: (EQ (TESTL z1:(SHRLconst [31] x) z2)) + // cond: z1==z2 + // result: (UGE (BTLconst [31] x)) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + x := z1.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + b.resetWithControl(BlockAMD64UGE, v0) + return true + } + break + } + // match: (EQ (InvertFlags cmp) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpAMD64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64EQ, cmp) + return true + } + // match: (EQ (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (EQ (FlagLT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagLT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (FlagLT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagLT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (FlagGT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagGT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (FlagGT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagGT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (TESTQ s:(Select0 blsr:(BLSRQ _)) s) yes no) + // result: (EQ (Select1 blsr) yes no) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + s := v_0_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRQ || s != v_0_1 { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + b.resetWithControl(BlockAMD64EQ, v0) + return true + } + break + } + // match: (EQ (TESTL s:(Select0 blsr:(BLSRL _)) s) yes no) + // result: (EQ (Select1 blsr) yes no) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + s := v_0_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRL || s != v_0_1 { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + b.resetWithControl(BlockAMD64EQ, v0) + return true + } + break + } + // match: (EQ t:(TESTQ a:(ADDQconst [c] x) a)) + // cond: t.Uses == 1 && flagify(a) + // result: (EQ (Select1 a.Args[0])) + for b.Controls[0].Op == OpAMD64TESTQ { + t := b.Controls[0] + _ = t.Args[1] + t_0 := t.Args[0] + t_1 := t.Args[1] + for _i0 := 0; _i0 <= 1; _i0, t_0, t_1 = _i0+1, t_1, t_0 { + a := t_0 + if a.Op != OpAMD64ADDQconst { + continue + } + if a != t_1 || !(t.Uses == 1 && flagify(a)) { + continue + } + v0 := b.NewValue0(t.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(a.Args[0]) + b.resetWithControl(BlockAMD64EQ, v0) + return true + } + break + } + // match: (EQ t:(TESTL a:(ADDLconst [c] x) a)) + // cond: t.Uses == 1 && flagify(a) + // result: (EQ (Select1 a.Args[0])) + for b.Controls[0].Op == OpAMD64TESTL { + t := b.Controls[0] + _ = t.Args[1] + t_0 := t.Args[0] + t_1 := t.Args[1] + for _i0 := 0; _i0 <= 1; _i0, t_0, t_1 = _i0+1, t_1, t_0 { + a := t_0 + if a.Op != OpAMD64ADDLconst { + continue + } + if a != t_1 || !(t.Uses == 1 && flagify(a)) { + continue + } + v0 := b.NewValue0(t.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(a.Args[0]) + b.resetWithControl(BlockAMD64EQ, v0) + return true + } + break + } + // match: (EQ (VPTEST x:(VPAND128 j k) y) yes no) + // cond: x == y && x.Uses == 2 + // result: (EQ (VPTEST j k) yes no) + for b.Controls[0].Op == OpAMD64VPTEST { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPAND128 { + break + } + _ = x.Args[1] + x_0 := x.Args[0] + x_1 := x.Args[1] + for _i0 := 0; _i0 <= 1; _i0, x_0, x_1 = _i0+1, x_1, x_0 { + j := x_0 + k := x_1 + if !(x == y && x.Uses == 2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(j, k) + b.resetWithControl(BlockAMD64EQ, v0) + return true + } + break + } + // match: (EQ (VPTEST x:(VPAND256 j k) y) yes no) + // cond: x == y && x.Uses == 2 + // result: (EQ (VPTEST j k) yes no) + for b.Controls[0].Op == OpAMD64VPTEST { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPAND256 { + break + } + _ = x.Args[1] + x_0 := x.Args[0] + x_1 := x.Args[1] + for _i0 := 0; _i0 <= 1; _i0, x_0, x_1 = _i0+1, x_1, x_0 { + j := x_0 + k := x_1 + if !(x == y && x.Uses == 2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(j, k) + b.resetWithControl(BlockAMD64EQ, v0) + return true + } + break + } + // match: (EQ (VPTEST x:(VPANDD512 j k) y) yes no) + // cond: x == y && x.Uses == 2 + // result: (EQ (VPTEST j k) yes no) + for b.Controls[0].Op == OpAMD64VPTEST { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDD512 { + break + } + _ = x.Args[1] + x_0 := x.Args[0] + x_1 := x.Args[1] + for _i0 := 0; _i0 <= 1; _i0, x_0, x_1 = _i0+1, x_1, x_0 { + j := x_0 + k := x_1 + if !(x == y && x.Uses == 2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(j, k) + b.resetWithControl(BlockAMD64EQ, v0) + return true + } + break + } + // match: (EQ (VPTEST x:(VPANDQ512 j k) y) yes no) + // cond: x == y && x.Uses == 2 + // result: (EQ (VPTEST j k) yes no) + for b.Controls[0].Op == OpAMD64VPTEST { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDQ512 { + break + } + _ = x.Args[1] + x_0 := x.Args[0] + x_1 := x.Args[1] + for _i0 := 0; _i0 <= 1; _i0, x_0, x_1 = _i0+1, x_1, x_0 { + j := x_0 + k := x_1 + if !(x == y && x.Uses == 2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(j, k) + b.resetWithControl(BlockAMD64EQ, v0) + return true + } + break + } + // match: (EQ (VPTEST x:(VPANDN128 j k) y) yes no) + // cond: x == y && x.Uses == 2 + // result: (ULT (VPTEST k j) yes no) + for b.Controls[0].Op == OpAMD64VPTEST { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDN128 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v0 := b.NewValue0(v_0.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(k, j) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + // match: (EQ (VPTEST x:(VPANDN256 j k) y) yes no) + // cond: x == y && x.Uses == 2 + // result: (ULT (VPTEST k j) yes no) + for b.Controls[0].Op == OpAMD64VPTEST { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDN256 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v0 := b.NewValue0(v_0.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(k, j) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + // match: (EQ (VPTEST x:(VPANDND512 j k) y) yes no) + // cond: x == y && x.Uses == 2 + // result: (ULT (VPTEST k j) yes no) + for b.Controls[0].Op == OpAMD64VPTEST { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDND512 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v0 := b.NewValue0(v_0.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(k, j) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + // match: (EQ (VPTEST x:(VPANDNQ512 j k) y) yes no) + // cond: x == y && x.Uses == 2 + // result: (ULT (VPTEST k j) yes no) + for b.Controls[0].Op == OpAMD64VPTEST { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + if x.Op != OpAMD64VPANDNQ512 { + break + } + k := x.Args[1] + j := x.Args[0] + if !(x == y && x.Uses == 2) { + break + } + v0 := b.NewValue0(v_0.Pos, OpAMD64VPTEST, types.TypeFlags) + v0.AddArg2(k, j) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + case BlockAMD64GE: + // match: (GE c:(CMPQconst [128] z) yes no) + // cond: c.Uses == 1 + // result: (GT (CMPQconst [127] z) yes no) + for b.Controls[0].Op == OpAMD64CMPQconst { + c := b.Controls[0] + if auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v0 := b.NewValue0(c.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + b.resetWithControl(BlockAMD64GT, v0) + return true + } + // match: (GE c:(CMPLconst [128] z) yes no) + // cond: c.Uses == 1 + // result: (GT (CMPLconst [127] z) yes no) + for b.Controls[0].Op == OpAMD64CMPLconst { + c := b.Controls[0] + if auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v0 := b.NewValue0(c.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + b.resetWithControl(BlockAMD64GT, v0) + return true + } + // match: (GE (InvertFlags cmp) yes no) + // result: (LE cmp yes no) + for b.Controls[0].Op == OpAMD64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64LE, cmp) + return true + } + // match: (GE (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (GE (FlagLT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagLT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GE (FlagLT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagLT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GE (FlagGT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagGT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (GE (FlagGT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagGT_UGT { + b.Reset(BlockFirst) + return true + } + case BlockAMD64GT: + // match: (GT (InvertFlags cmp) yes no) + // result: (LT cmp yes no) + for b.Controls[0].Op == OpAMD64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64LT, cmp) + return true + } + // match: (GT (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GT (FlagLT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagLT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GT (FlagLT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagLT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GT (FlagGT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagGT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (GT (FlagGT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagGT_UGT { + b.Reset(BlockFirst) + return true + } + case BlockIf: + // match: (If (SETL cmp) yes no) + // result: (LT cmp yes no) + for b.Controls[0].Op == OpAMD64SETL { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64LT, cmp) + return true + } + // match: (If (SETLE cmp) yes no) + // result: (LE cmp yes no) + for b.Controls[0].Op == OpAMD64SETLE { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64LE, cmp) + return true + } + // match: (If (SETG cmp) yes no) + // result: (GT cmp yes no) + for b.Controls[0].Op == OpAMD64SETG { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64GT, cmp) + return true + } + // match: (If (SETGE cmp) yes no) + // result: (GE cmp yes no) + for b.Controls[0].Op == OpAMD64SETGE { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64GE, cmp) + return true + } + // match: (If (SETEQ cmp) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpAMD64SETEQ { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64EQ, cmp) + return true + } + // match: (If (SETNE cmp) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpAMD64SETNE { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64NE, cmp) + return true + } + // match: (If (SETB cmp) yes no) + // result: (ULT cmp yes no) + for b.Controls[0].Op == OpAMD64SETB { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64ULT, cmp) + return true + } + // match: (If (SETBE cmp) yes no) + // result: (ULE cmp yes no) + for b.Controls[0].Op == OpAMD64SETBE { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64ULE, cmp) + return true + } + // match: (If (SETA cmp) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == OpAMD64SETA { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64UGT, cmp) + return true + } + // match: (If (SETAE cmp) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == OpAMD64SETAE { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64UGE, cmp) + return true + } + // match: (If (SETO cmp) yes no) + // result: (OS cmp yes no) + for b.Controls[0].Op == OpAMD64SETO { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64OS, cmp) + return true + } + // match: (If (SETGF cmp) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == OpAMD64SETGF { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64UGT, cmp) + return true + } + // match: (If (SETGEF cmp) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == OpAMD64SETGEF { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64UGE, cmp) + return true + } + // match: (If (SETEQF cmp) yes no) + // result: (EQF cmp yes no) + for b.Controls[0].Op == OpAMD64SETEQF { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64EQF, cmp) + return true + } + // match: (If (SETNEF cmp) yes no) + // result: (NEF cmp yes no) + for b.Controls[0].Op == OpAMD64SETNEF { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64NEF, cmp) + return true + } + // match: (If cond yes no) + // result: (NE (TESTB cond cond) yes no) + for { + cond := b.Controls[0] + v0 := b.NewValue0(cond.Pos, OpAMD64TESTB, types.TypeFlags) + v0.AddArg2(cond, cond) + b.resetWithControl(BlockAMD64NE, v0) + return true + } + case BlockJumpTable: + // match: (JumpTable idx) + // result: (JUMPTABLE {makeJumpTableSym(b)} idx (LEAQ {makeJumpTableSym(b)} (SB))) + for { + idx := b.Controls[0] + v0 := b.NewValue0(b.Pos, OpAMD64LEAQ, typ.Uintptr) + v0.Aux = symToAux(makeJumpTableSym(b)) + v1 := b.NewValue0(b.Pos, OpSB, typ.Uintptr) + v0.AddArg(v1) + b.resetWithControl2(BlockAMD64JUMPTABLE, idx, v0) + b.Aux = symToAux(makeJumpTableSym(b)) + return true + } + case BlockAMD64LE: + // match: (LE (InvertFlags cmp) yes no) + // result: (GE cmp yes no) + for b.Controls[0].Op == OpAMD64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64GE, cmp) + return true + } + // match: (LE (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (LE (FlagLT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagLT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (LE (FlagLT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagLT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (LE (FlagGT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagGT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LE (FlagGT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagGT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockAMD64LT: + // match: (LT c:(CMPQconst [128] z) yes no) + // cond: c.Uses == 1 + // result: (LE (CMPQconst [127] z) yes no) + for b.Controls[0].Op == OpAMD64CMPQconst { + c := b.Controls[0] + if auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v0 := b.NewValue0(c.Pos, OpAMD64CMPQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + b.resetWithControl(BlockAMD64LE, v0) + return true + } + // match: (LT c:(CMPLconst [128] z) yes no) + // cond: c.Uses == 1 + // result: (LE (CMPLconst [127] z) yes no) + for b.Controls[0].Op == OpAMD64CMPLconst { + c := b.Controls[0] + if auxIntToInt32(c.AuxInt) != 128 { + break + } + z := c.Args[0] + if !(c.Uses == 1) { + break + } + v0 := b.NewValue0(c.Pos, OpAMD64CMPLconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(127) + v0.AddArg(z) + b.resetWithControl(BlockAMD64LE, v0) + return true + } + // match: (LT (InvertFlags cmp) yes no) + // result: (GT cmp yes no) + for b.Controls[0].Op == OpAMD64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64GT, cmp) + return true + } + // match: (LT (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LT (FlagLT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagLT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (LT (FlagLT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagLT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (LT (FlagGT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagGT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LT (FlagGT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagGT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockAMD64NE: + // match: (NE (TESTB (SETL cmp) (SETL cmp)) yes no) + // result: (LT cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETL { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETL || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64LT, cmp) + return true + } + // match: (NE (TESTB (SETLE cmp) (SETLE cmp)) yes no) + // result: (LE cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETLE { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETLE || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64LE, cmp) + return true + } + // match: (NE (TESTB (SETG cmp) (SETG cmp)) yes no) + // result: (GT cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETG { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETG || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64GT, cmp) + return true + } + // match: (NE (TESTB (SETGE cmp) (SETGE cmp)) yes no) + // result: (GE cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETGE { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETGE || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64GE, cmp) + return true + } + // match: (NE (TESTB (SETEQ cmp) (SETEQ cmp)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETEQ { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETEQ || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64EQ, cmp) + return true + } + // match: (NE (TESTB (SETNE cmp) (SETNE cmp)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETNE { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETNE || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64NE, cmp) + return true + } + // match: (NE (TESTB (SETB cmp) (SETB cmp)) yes no) + // result: (ULT cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETB { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETB || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64ULT, cmp) + return true + } + // match: (NE (TESTB (SETBE cmp) (SETBE cmp)) yes no) + // result: (ULE cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETBE { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETBE || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64ULE, cmp) + return true + } + // match: (NE (TESTB (SETA cmp) (SETA cmp)) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETA { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETA || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64UGT, cmp) + return true + } + // match: (NE (TESTB (SETAE cmp) (SETAE cmp)) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETAE { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETAE || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64UGE, cmp) + return true + } + // match: (NE (TESTB (SETO cmp) (SETO cmp)) yes no) + // result: (OS cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETO { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETO || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64OS, cmp) + return true + } + // match: (NE (TESTL (SHLL (MOVLconst [1]) x) y)) + // result: (ULT (BTL x y)) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64SHLL { + continue + } + x := v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64MOVLconst || auxIntToInt32(v_0_0_0.AuxInt) != 1 { + continue + } + y := v_0_1 + v0 := b.NewValue0(v_0.Pos, OpAMD64BTL, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + break + } + // match: (NE (TESTQ (SHLQ (MOVQconst [1]) x) y)) + // result: (ULT (BTQ x y)) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64SHLQ { + continue + } + x := v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAMD64MOVQconst || auxIntToInt64(v_0_0_0.AuxInt) != 1 { + continue + } + y := v_0_1 + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQ, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + break + } + // match: (NE (TESTLconst [c] x)) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (ULT (BTLconst [int8(log32u(uint32(c)))] x)) + for b.Controls[0].Op == OpAMD64TESTLconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(isUnsignedPowerOfTwo(uint32(c))) { + break + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + // match: (NE (TESTQconst [c] x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (ULT (BTQconst [int8(log32u(uint32(c)))] x)) + for b.Controls[0].Op == OpAMD64TESTQconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(isUnsignedPowerOfTwo(uint64(c))) { + break + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log32u(uint32(c)))) + v0.AddArg(x) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + // match: (NE (TESTQ (MOVQconst [c]) x)) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (ULT (BTQconst [int8(log64u(uint64(c)))] x)) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpAMD64MOVQconst { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + x := v_0_1 + if !(isUnsignedPowerOfTwo(uint64(c))) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(int8(log64u(uint64(c)))) + v0.AddArg(x) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + break + } + // match: (NE (TESTQ z1:(SHLQconst [63] (SHRQconst [63] x)) z2)) + // cond: z1==z2 + // result: (ULT (BTQconst [63] x)) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHLQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + break + } + // match: (NE (TESTL z1:(SHLLconst [31] (SHRQconst [31] x)) z2)) + // cond: z1==z2 + // result: (ULT (BTQconst [31] x)) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHLLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHRQconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + break + } + // match: (NE (TESTQ z1:(SHRQconst [63] (SHLQconst [63] x)) z2)) + // cond: z1==z2 + // result: (ULT (BTQconst [0] x)) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLQconst || auxIntToInt8(z1_0.AuxInt) != 63 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + break + } + // match: (NE (TESTL z1:(SHRLconst [31] (SHLLconst [31] x)) z2)) + // cond: z1==z2 + // result: (ULT (BTLconst [0] x)) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + z1_0 := z1.Args[0] + if z1_0.Op != OpAMD64SHLLconst || auxIntToInt8(z1_0.AuxInt) != 31 { + continue + } + x := z1_0.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(0) + v0.AddArg(x) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + break + } + // match: (NE (TESTQ z1:(SHRQconst [63] x) z2)) + // cond: z1==z2 + // result: (ULT (BTQconst [63] x)) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRQconst || auxIntToInt8(z1.AuxInt) != 63 { + continue + } + x := z1.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTQconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(63) + v0.AddArg(x) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + break + } + // match: (NE (TESTL z1:(SHRLconst [31] x) z2)) + // cond: z1==z2 + // result: (ULT (BTLconst [31] x)) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z1 := v_0_0 + if z1.Op != OpAMD64SHRLconst || auxIntToInt8(z1.AuxInt) != 31 { + continue + } + x := z1.Args[0] + z2 := v_0_1 + if !(z1 == z2) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpAMD64BTLconst, types.TypeFlags) + v0.AuxInt = int8ToAuxInt(31) + v0.AddArg(x) + b.resetWithControl(BlockAMD64ULT, v0) + return true + } + break + } + // match: (NE (TESTB (SETGF cmp) (SETGF cmp)) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETGF { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETGF || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64UGT, cmp) + return true + } + // match: (NE (TESTB (SETGEF cmp) (SETGEF cmp)) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETGEF { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETGEF || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64UGE, cmp) + return true + } + // match: (NE (TESTB (SETEQF cmp) (SETEQF cmp)) yes no) + // result: (EQF cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETEQF { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETEQF || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64EQF, cmp) + return true + } + // match: (NE (TESTB (SETNEF cmp) (SETNEF cmp)) yes no) + // result: (NEF cmp yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAMD64SETNEF { + break + } + cmp := v_0_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAMD64SETNEF || cmp != v_0_1.Args[0] { + break + } + b.resetWithControl(BlockAMD64NEF, cmp) + return true + } + // match: (NE (InvertFlags cmp) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpAMD64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64NE, cmp) + return true + } + // match: (NE (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (NE (FlagLT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagLT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (NE (FlagLT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagLT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (NE (FlagGT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagGT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (NE (FlagGT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagGT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (NE (TESTQ s:(Select0 blsr:(BLSRQ _)) s) yes no) + // result: (NE (Select1 blsr) yes no) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + s := v_0_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRQ || s != v_0_1 { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + b.resetWithControl(BlockAMD64NE, v0) + return true + } + break + } + // match: (NE (TESTL s:(Select0 blsr:(BLSRL _)) s) yes no) + // result: (NE (Select1 blsr) yes no) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + s := v_0_0 + if s.Op != OpSelect0 { + continue + } + blsr := s.Args[0] + if blsr.Op != OpAMD64BLSRL || s != v_0_1 { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(blsr) + b.resetWithControl(BlockAMD64NE, v0) + return true + } + break + } + // match: (NE t:(TESTQ a:(ADDQconst [c] x) a)) + // cond: t.Uses == 1 && flagify(a) + // result: (NE (Select1 a.Args[0])) + for b.Controls[0].Op == OpAMD64TESTQ { + t := b.Controls[0] + _ = t.Args[1] + t_0 := t.Args[0] + t_1 := t.Args[1] + for _i0 := 0; _i0 <= 1; _i0, t_0, t_1 = _i0+1, t_1, t_0 { + a := t_0 + if a.Op != OpAMD64ADDQconst { + continue + } + if a != t_1 || !(t.Uses == 1 && flagify(a)) { + continue + } + v0 := b.NewValue0(t.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(a.Args[0]) + b.resetWithControl(BlockAMD64NE, v0) + return true + } + break + } + // match: (NE t:(TESTL a:(ADDLconst [c] x) a)) + // cond: t.Uses == 1 && flagify(a) + // result: (NE (Select1 a.Args[0])) + for b.Controls[0].Op == OpAMD64TESTL { + t := b.Controls[0] + _ = t.Args[1] + t_0 := t.Args[0] + t_1 := t.Args[1] + for _i0 := 0; _i0 <= 1; _i0, t_0, t_1 = _i0+1, t_1, t_0 { + a := t_0 + if a.Op != OpAMD64ADDLconst { + continue + } + if a != t_1 || !(t.Uses == 1 && flagify(a)) { + continue + } + v0 := b.NewValue0(t.Pos, OpSelect1, types.TypeFlags) + v0.AddArg(a.Args[0]) + b.resetWithControl(BlockAMD64NE, v0) + return true + } + break + } + case BlockAMD64UGE: + // match: (UGE (TESTQ x x) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + b.Reset(BlockFirst) + return true + } + // match: (UGE (TESTL x x) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + b.Reset(BlockFirst) + return true + } + // match: (UGE (TESTW x x) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64TESTW { + v_0 := b.Controls[0] + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + b.Reset(BlockFirst) + return true + } + // match: (UGE (TESTB x x) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + b.Reset(BlockFirst) + return true + } + // match: (UGE (InvertFlags cmp) yes no) + // result: (ULE cmp yes no) + for b.Controls[0].Op == OpAMD64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64ULE, cmp) + return true + } + // match: (UGE (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (UGE (FlagLT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagLT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGE (FlagLT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagLT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (UGE (FlagGT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagGT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGE (FlagGT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagGT_UGT { + b.Reset(BlockFirst) + return true + } + case BlockAMD64UGT: + // match: (UGT (InvertFlags cmp) yes no) + // result: (ULT cmp yes no) + for b.Controls[0].Op == OpAMD64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64ULT, cmp) + return true + } + // match: (UGT (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGT (FlagLT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagLT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGT (FlagLT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagLT_UGT { + b.Reset(BlockFirst) + return true + } + // match: (UGT (FlagGT_ULT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagGT_ULT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGT (FlagGT_UGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagGT_UGT { + b.Reset(BlockFirst) + return true + } + case BlockAMD64ULE: + // match: (ULE (InvertFlags cmp) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == OpAMD64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64UGE, cmp) + return true + } + // match: (ULE (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (ULE (FlagLT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagLT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (ULE (FlagLT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagLT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULE (FlagGT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagGT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (ULE (FlagGT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagGT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockAMD64ULT: + // match: (ULT (TESTQ x x) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64TESTQ { + v_0 := b.Controls[0] + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULT (TESTL x x) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64TESTL { + v_0 := b.Controls[0] + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULT (TESTW x x) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64TESTW { + v_0 := b.Controls[0] + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULT (TESTB x x) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64TESTB { + v_0 := b.Controls[0] + x := v_0.Args[1] + if x != v_0.Args[0] { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULT (InvertFlags cmp) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == OpAMD64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockAMD64UGT, cmp) + return true + } + // match: (ULT (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULT (FlagLT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagLT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (ULT (FlagLT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagLT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULT (FlagGT_ULT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpAMD64FlagGT_ULT { + b.Reset(BlockFirst) + return true + } + // match: (ULT (FlagGT_UGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpAMD64FlagGT_UGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteAMD64latelower.go b/go/src/cmd/compile/internal/ssa/rewriteAMD64latelower.go new file mode 100644 index 0000000000000000000000000000000000000000..11ecb0b285a22cb6effe8df9188d4374546e48aa --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteAMD64latelower.go @@ -0,0 +1,185 @@ +// Code generated from _gen/AMD64latelower.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "internal/buildcfg" + +func rewriteValueAMD64latelower(v *Value) bool { + switch v.Op { + case OpAMD64MOVBQZX: + return rewriteValueAMD64latelower_OpAMD64MOVBQZX(v) + case OpAMD64MOVLQZX: + return rewriteValueAMD64latelower_OpAMD64MOVLQZX(v) + case OpAMD64MOVWQZX: + return rewriteValueAMD64latelower_OpAMD64MOVWQZX(v) + case OpAMD64SARL: + return rewriteValueAMD64latelower_OpAMD64SARL(v) + case OpAMD64SARQ: + return rewriteValueAMD64latelower_OpAMD64SARQ(v) + case OpAMD64SHLL: + return rewriteValueAMD64latelower_OpAMD64SHLL(v) + case OpAMD64SHLQ: + return rewriteValueAMD64latelower_OpAMD64SHLQ(v) + case OpAMD64SHRL: + return rewriteValueAMD64latelower_OpAMD64SHRL(v) + case OpAMD64SHRQ: + return rewriteValueAMD64latelower_OpAMD64SHRQ(v) + } + return false +} +func rewriteValueAMD64latelower_OpAMD64MOVBQZX(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBQZX x) + // cond: zeroUpper56Bits(x,3) + // result: x + for { + x := v_0 + if !(zeroUpper56Bits(x, 3)) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64latelower_OpAMD64MOVLQZX(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVLQZX x) + // cond: zeroUpper32Bits(x,3) + // result: x + for { + x := v_0 + if !(zeroUpper32Bits(x, 3)) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64latelower_OpAMD64MOVWQZX(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWQZX x) + // cond: zeroUpper48Bits(x,3) + // result: x + for { + x := v_0 + if !(zeroUpper48Bits(x, 3)) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueAMD64latelower_OpAMD64SARL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SARL x y) + // cond: buildcfg.GOAMD64 >= 3 + // result: (SARXL x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64SARXL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64latelower_OpAMD64SARQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SARQ x y) + // cond: buildcfg.GOAMD64 >= 3 + // result: (SARXQ x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64SARXQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64latelower_OpAMD64SHLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SHLL x y) + // cond: buildcfg.GOAMD64 >= 3 + // result: (SHLXL x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64SHLXL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64latelower_OpAMD64SHLQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SHLQ x y) + // cond: buildcfg.GOAMD64 >= 3 + // result: (SHLXQ x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64SHLXQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64latelower_OpAMD64SHRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SHRL x y) + // cond: buildcfg.GOAMD64 >= 3 + // result: (SHRXL x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64SHRXL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueAMD64latelower_OpAMD64SHRQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SHRQ x y) + // cond: buildcfg.GOAMD64 >= 3 + // result: (SHRXQ x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOAMD64 >= 3) { + break + } + v.reset(OpAMD64SHRXQ) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteBlockAMD64latelower(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteAMD64splitload.go b/go/src/cmd/compile/internal/ssa/rewriteAMD64splitload.go new file mode 100644 index 0000000000000000000000000000000000000000..0dcb1b460f962732de57ad55b71f1d6e4ce386b8 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteAMD64splitload.go @@ -0,0 +1,850 @@ +// Code generated from _gen/AMD64splitload.rules using 'go generate'; DO NOT EDIT. + +package ssa + +func rewriteValueAMD64splitload(v *Value) bool { + switch v.Op { + case OpAMD64CMPBconstload: + return rewriteValueAMD64splitload_OpAMD64CMPBconstload(v) + case OpAMD64CMPBconstloadidx1: + return rewriteValueAMD64splitload_OpAMD64CMPBconstloadidx1(v) + case OpAMD64CMPBload: + return rewriteValueAMD64splitload_OpAMD64CMPBload(v) + case OpAMD64CMPBloadidx1: + return rewriteValueAMD64splitload_OpAMD64CMPBloadidx1(v) + case OpAMD64CMPLconstload: + return rewriteValueAMD64splitload_OpAMD64CMPLconstload(v) + case OpAMD64CMPLconstloadidx1: + return rewriteValueAMD64splitload_OpAMD64CMPLconstloadidx1(v) + case OpAMD64CMPLconstloadidx4: + return rewriteValueAMD64splitload_OpAMD64CMPLconstloadidx4(v) + case OpAMD64CMPLload: + return rewriteValueAMD64splitload_OpAMD64CMPLload(v) + case OpAMD64CMPLloadidx1: + return rewriteValueAMD64splitload_OpAMD64CMPLloadidx1(v) + case OpAMD64CMPLloadidx4: + return rewriteValueAMD64splitload_OpAMD64CMPLloadidx4(v) + case OpAMD64CMPQconstload: + return rewriteValueAMD64splitload_OpAMD64CMPQconstload(v) + case OpAMD64CMPQconstloadidx1: + return rewriteValueAMD64splitload_OpAMD64CMPQconstloadidx1(v) + case OpAMD64CMPQconstloadidx8: + return rewriteValueAMD64splitload_OpAMD64CMPQconstloadidx8(v) + case OpAMD64CMPQload: + return rewriteValueAMD64splitload_OpAMD64CMPQload(v) + case OpAMD64CMPQloadidx1: + return rewriteValueAMD64splitload_OpAMD64CMPQloadidx1(v) + case OpAMD64CMPQloadidx8: + return rewriteValueAMD64splitload_OpAMD64CMPQloadidx8(v) + case OpAMD64CMPWconstload: + return rewriteValueAMD64splitload_OpAMD64CMPWconstload(v) + case OpAMD64CMPWconstloadidx1: + return rewriteValueAMD64splitload_OpAMD64CMPWconstloadidx1(v) + case OpAMD64CMPWconstloadidx2: + return rewriteValueAMD64splitload_OpAMD64CMPWconstloadidx2(v) + case OpAMD64CMPWload: + return rewriteValueAMD64splitload_OpAMD64CMPWload(v) + case OpAMD64CMPWloadidx1: + return rewriteValueAMD64splitload_OpAMD64CMPWloadidx1(v) + case OpAMD64CMPWloadidx2: + return rewriteValueAMD64splitload_OpAMD64CMPWloadidx2(v) + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPBconstload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPBconstload {sym} [vo] ptr mem) + // cond: vo.Val() == 0 + // result: (TESTB x:(MOVBload {sym} [vo.Off()] ptr mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTB) + x := b.NewValue0(v.Pos, OpAMD64MOVBload, typ.UInt8) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg2(ptr, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPBconstload {sym} [vo] ptr mem) + // cond: vo.Val() != 0 + // result: (CMPBconst (MOVBload {sym} [vo.Off()] ptr mem) [vo.Val8()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPBconst) + v.AuxInt = int8ToAuxInt(vo.Val8()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVBload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPBconstloadidx1(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPBconstloadidx1 {sym} [vo] ptr idx mem) + // cond: vo.Val() == 0 + // result: (TESTB x:(MOVBloadidx1 {sym} [vo.Off()] ptr idx mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTB) + x := b.NewValue0(v.Pos, OpAMD64MOVBloadidx1, typ.UInt8) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg3(ptr, idx, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPBconstloadidx1 {sym} [vo] ptr idx mem) + // cond: vo.Val() != 0 + // result: (CMPBconst (MOVBloadidx1 {sym} [vo.Off()] ptr idx mem) [vo.Val8()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPBconst) + v.AuxInt = int8ToAuxInt(vo.Val8()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVBloadidx1, typ.UInt8) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPBload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPBload {sym} [off] ptr x mem) + // result: (CMPB (MOVBload {sym} [off] ptr mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + x := v_1 + mem := v_2 + v.reset(OpAMD64CMPB) + v0 := b.NewValue0(v.Pos, OpAMD64MOVBload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueAMD64splitload_OpAMD64CMPBloadidx1(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPBloadidx1 {sym} [off] ptr idx x mem) + // result: (CMPB (MOVBloadidx1 {sym} [off] ptr idx mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + x := v_2 + mem := v_3 + v.reset(OpAMD64CMPB) + v0 := b.NewValue0(v.Pos, OpAMD64MOVBloadidx1, typ.UInt8) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueAMD64splitload_OpAMD64CMPLconstload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPLconstload {sym} [vo] ptr mem) + // cond: vo.Val() == 0 + // result: (TESTL x:(MOVLload {sym} [vo.Off()] ptr mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTL) + x := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg2(ptr, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPLconstload {sym} [vo] ptr mem) + // cond: vo.Val() != 0 + // result: (CMPLconst (MOVLload {sym} [vo.Off()] ptr mem) [vo.Val()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPLconst) + v.AuxInt = int32ToAuxInt(vo.Val()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPLconstloadidx1(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPLconstloadidx1 {sym} [vo] ptr idx mem) + // cond: vo.Val() == 0 + // result: (TESTL x:(MOVLloadidx1 {sym} [vo.Off()] ptr idx mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTL) + x := b.NewValue0(v.Pos, OpAMD64MOVLloadidx1, typ.UInt32) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg3(ptr, idx, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPLconstloadidx1 {sym} [vo] ptr idx mem) + // cond: vo.Val() != 0 + // result: (CMPLconst (MOVLloadidx1 {sym} [vo.Off()] ptr idx mem) [vo.Val()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPLconst) + v.AuxInt = int32ToAuxInt(vo.Val()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLloadidx1, typ.UInt32) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPLconstloadidx4(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPLconstloadidx4 {sym} [vo] ptr idx mem) + // cond: vo.Val() == 0 + // result: (TESTL x:(MOVLloadidx4 {sym} [vo.Off()] ptr idx mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTL) + x := b.NewValue0(v.Pos, OpAMD64MOVLloadidx4, typ.UInt32) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg3(ptr, idx, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPLconstloadidx4 {sym} [vo] ptr idx mem) + // cond: vo.Val() != 0 + // result: (CMPLconst (MOVLloadidx4 {sym} [vo.Off()] ptr idx mem) [vo.Val()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPLconst) + v.AuxInt = int32ToAuxInt(vo.Val()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLloadidx4, typ.UInt32) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPLload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPLload {sym} [off] ptr x mem) + // result: (CMPL (MOVLload {sym} [off] ptr mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + x := v_1 + mem := v_2 + v.reset(OpAMD64CMPL) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueAMD64splitload_OpAMD64CMPLloadidx1(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPLloadidx1 {sym} [off] ptr idx x mem) + // result: (CMPL (MOVLloadidx1 {sym} [off] ptr idx mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + x := v_2 + mem := v_3 + v.reset(OpAMD64CMPL) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLloadidx1, typ.UInt32) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueAMD64splitload_OpAMD64CMPLloadidx4(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPLloadidx4 {sym} [off] ptr idx x mem) + // result: (CMPL (MOVLloadidx4 {sym} [off] ptr idx mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + x := v_2 + mem := v_3 + v.reset(OpAMD64CMPL) + v0 := b.NewValue0(v.Pos, OpAMD64MOVLloadidx4, typ.UInt32) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueAMD64splitload_OpAMD64CMPQconstload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPQconstload {sym} [vo] ptr mem) + // cond: vo.Val() == 0 + // result: (TESTQ x:(MOVQload {sym} [vo.Off()] ptr mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTQ) + x := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg2(ptr, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPQconstload {sym} [vo] ptr mem) + // cond: vo.Val() != 0 + // result: (CMPQconst (MOVQload {sym} [vo.Off()] ptr mem) [vo.Val()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPQconst) + v.AuxInt = int32ToAuxInt(vo.Val()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPQconstloadidx1(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPQconstloadidx1 {sym} [vo] ptr idx mem) + // cond: vo.Val() == 0 + // result: (TESTQ x:(MOVQloadidx1 {sym} [vo.Off()] ptr idx mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTQ) + x := b.NewValue0(v.Pos, OpAMD64MOVQloadidx1, typ.UInt64) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg3(ptr, idx, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPQconstloadidx1 {sym} [vo] ptr idx mem) + // cond: vo.Val() != 0 + // result: (CMPQconst (MOVQloadidx1 {sym} [vo.Off()] ptr idx mem) [vo.Val()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPQconst) + v.AuxInt = int32ToAuxInt(vo.Val()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQloadidx1, typ.UInt64) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPQconstloadidx8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPQconstloadidx8 {sym} [vo] ptr idx mem) + // cond: vo.Val() == 0 + // result: (TESTQ x:(MOVQloadidx8 {sym} [vo.Off()] ptr idx mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTQ) + x := b.NewValue0(v.Pos, OpAMD64MOVQloadidx8, typ.UInt64) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg3(ptr, idx, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPQconstloadidx8 {sym} [vo] ptr idx mem) + // cond: vo.Val() != 0 + // result: (CMPQconst (MOVQloadidx8 {sym} [vo.Off()] ptr idx mem) [vo.Val()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPQconst) + v.AuxInt = int32ToAuxInt(vo.Val()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQloadidx8, typ.UInt64) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPQload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPQload {sym} [off] ptr x mem) + // result: (CMPQ (MOVQload {sym} [off] ptr mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + x := v_1 + mem := v_2 + v.reset(OpAMD64CMPQ) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueAMD64splitload_OpAMD64CMPQloadidx1(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPQloadidx1 {sym} [off] ptr idx x mem) + // result: (CMPQ (MOVQloadidx1 {sym} [off] ptr idx mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + x := v_2 + mem := v_3 + v.reset(OpAMD64CMPQ) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQloadidx1, typ.UInt64) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueAMD64splitload_OpAMD64CMPQloadidx8(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPQloadidx8 {sym} [off] ptr idx x mem) + // result: (CMPQ (MOVQloadidx8 {sym} [off] ptr idx mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + x := v_2 + mem := v_3 + v.reset(OpAMD64CMPQ) + v0 := b.NewValue0(v.Pos, OpAMD64MOVQloadidx8, typ.UInt64) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueAMD64splitload_OpAMD64CMPWconstload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPWconstload {sym} [vo] ptr mem) + // cond: vo.Val() == 0 + // result: (TESTW x:(MOVWload {sym} [vo.Off()] ptr mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTW) + x := b.NewValue0(v.Pos, OpAMD64MOVWload, typ.UInt16) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg2(ptr, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPWconstload {sym} [vo] ptr mem) + // cond: vo.Val() != 0 + // result: (CMPWconst (MOVWload {sym} [vo.Off()] ptr mem) [vo.Val16()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + mem := v_1 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPWconst) + v.AuxInt = int16ToAuxInt(vo.Val16()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPWconstloadidx1(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPWconstloadidx1 {sym} [vo] ptr idx mem) + // cond: vo.Val() == 0 + // result: (TESTW x:(MOVWloadidx1 {sym} [vo.Off()] ptr idx mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTW) + x := b.NewValue0(v.Pos, OpAMD64MOVWloadidx1, typ.UInt16) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg3(ptr, idx, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPWconstloadidx1 {sym} [vo] ptr idx mem) + // cond: vo.Val() != 0 + // result: (CMPWconst (MOVWloadidx1 {sym} [vo.Off()] ptr idx mem) [vo.Val16()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPWconst) + v.AuxInt = int16ToAuxInt(vo.Val16()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWloadidx1, typ.UInt16) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPWconstloadidx2(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPWconstloadidx2 {sym} [vo] ptr idx mem) + // cond: vo.Val() == 0 + // result: (TESTW x:(MOVWloadidx2 {sym} [vo.Off()] ptr idx mem) x) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() == 0) { + break + } + v.reset(OpAMD64TESTW) + x := b.NewValue0(v.Pos, OpAMD64MOVWloadidx2, typ.UInt16) + x.AuxInt = int32ToAuxInt(vo.Off()) + x.Aux = symToAux(sym) + x.AddArg3(ptr, idx, mem) + v.AddArg2(x, x) + return true + } + // match: (CMPWconstloadidx2 {sym} [vo] ptr idx mem) + // cond: vo.Val() != 0 + // result: (CMPWconst (MOVWloadidx2 {sym} [vo.Off()] ptr idx mem) [vo.Val16()]) + for { + vo := auxIntToValAndOff(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + mem := v_2 + if !(vo.Val() != 0) { + break + } + v.reset(OpAMD64CMPWconst) + v.AuxInt = int16ToAuxInt(vo.Val16()) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWloadidx2, typ.UInt16) + v0.AuxInt = int32ToAuxInt(vo.Off()) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueAMD64splitload_OpAMD64CMPWload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPWload {sym} [off] ptr x mem) + // result: (CMPW (MOVWload {sym} [off] ptr mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + x := v_1 + mem := v_2 + v.reset(OpAMD64CMPW) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueAMD64splitload_OpAMD64CMPWloadidx1(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPWloadidx1 {sym} [off] ptr idx x mem) + // result: (CMPW (MOVWloadidx1 {sym} [off] ptr idx mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + x := v_2 + mem := v_3 + v.reset(OpAMD64CMPW) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWloadidx1, typ.UInt16) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueAMD64splitload_OpAMD64CMPWloadidx2(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPWloadidx2 {sym} [off] ptr idx x mem) + // result: (CMPW (MOVWloadidx2 {sym} [off] ptr idx mem) x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + x := v_2 + mem := v_3 + v.reset(OpAMD64CMPW) + v0 := b.NewValue0(v.Pos, OpAMD64MOVWloadidx2, typ.UInt16) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + v.AddArg2(v0, x) + return true + } +} +func rewriteBlockAMD64splitload(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteARM.go b/go/src/cmd/compile/internal/ssa/rewriteARM.go new file mode 100644 index 0000000000000000000000000000000000000000..2a90e7b433bd6e0336192701fc622319cd9189af --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteARM.go @@ -0,0 +1,21930 @@ +// Code generated from _gen/ARM.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "internal/buildcfg" +import "cmd/compile/internal/types" + +func rewriteValueARM(v *Value) bool { + switch v.Op { + case OpARMADC: + return rewriteValueARM_OpARMADC(v) + case OpARMADCconst: + return rewriteValueARM_OpARMADCconst(v) + case OpARMADCshiftLL: + return rewriteValueARM_OpARMADCshiftLL(v) + case OpARMADCshiftLLreg: + return rewriteValueARM_OpARMADCshiftLLreg(v) + case OpARMADCshiftRA: + return rewriteValueARM_OpARMADCshiftRA(v) + case OpARMADCshiftRAreg: + return rewriteValueARM_OpARMADCshiftRAreg(v) + case OpARMADCshiftRL: + return rewriteValueARM_OpARMADCshiftRL(v) + case OpARMADCshiftRLreg: + return rewriteValueARM_OpARMADCshiftRLreg(v) + case OpARMADD: + return rewriteValueARM_OpARMADD(v) + case OpARMADDD: + return rewriteValueARM_OpARMADDD(v) + case OpARMADDF: + return rewriteValueARM_OpARMADDF(v) + case OpARMADDS: + return rewriteValueARM_OpARMADDS(v) + case OpARMADDSshiftLL: + return rewriteValueARM_OpARMADDSshiftLL(v) + case OpARMADDSshiftLLreg: + return rewriteValueARM_OpARMADDSshiftLLreg(v) + case OpARMADDSshiftRA: + return rewriteValueARM_OpARMADDSshiftRA(v) + case OpARMADDSshiftRAreg: + return rewriteValueARM_OpARMADDSshiftRAreg(v) + case OpARMADDSshiftRL: + return rewriteValueARM_OpARMADDSshiftRL(v) + case OpARMADDSshiftRLreg: + return rewriteValueARM_OpARMADDSshiftRLreg(v) + case OpARMADDconst: + return rewriteValueARM_OpARMADDconst(v) + case OpARMADDshiftLL: + return rewriteValueARM_OpARMADDshiftLL(v) + case OpARMADDshiftLLreg: + return rewriteValueARM_OpARMADDshiftLLreg(v) + case OpARMADDshiftRA: + return rewriteValueARM_OpARMADDshiftRA(v) + case OpARMADDshiftRAreg: + return rewriteValueARM_OpARMADDshiftRAreg(v) + case OpARMADDshiftRL: + return rewriteValueARM_OpARMADDshiftRL(v) + case OpARMADDshiftRLreg: + return rewriteValueARM_OpARMADDshiftRLreg(v) + case OpARMAND: + return rewriteValueARM_OpARMAND(v) + case OpARMANDconst: + return rewriteValueARM_OpARMANDconst(v) + case OpARMANDshiftLL: + return rewriteValueARM_OpARMANDshiftLL(v) + case OpARMANDshiftLLreg: + return rewriteValueARM_OpARMANDshiftLLreg(v) + case OpARMANDshiftRA: + return rewriteValueARM_OpARMANDshiftRA(v) + case OpARMANDshiftRAreg: + return rewriteValueARM_OpARMANDshiftRAreg(v) + case OpARMANDshiftRL: + return rewriteValueARM_OpARMANDshiftRL(v) + case OpARMANDshiftRLreg: + return rewriteValueARM_OpARMANDshiftRLreg(v) + case OpARMBFX: + return rewriteValueARM_OpARMBFX(v) + case OpARMBFXU: + return rewriteValueARM_OpARMBFXU(v) + case OpARMBIC: + return rewriteValueARM_OpARMBIC(v) + case OpARMBICconst: + return rewriteValueARM_OpARMBICconst(v) + case OpARMBICshiftLL: + return rewriteValueARM_OpARMBICshiftLL(v) + case OpARMBICshiftLLreg: + return rewriteValueARM_OpARMBICshiftLLreg(v) + case OpARMBICshiftRA: + return rewriteValueARM_OpARMBICshiftRA(v) + case OpARMBICshiftRAreg: + return rewriteValueARM_OpARMBICshiftRAreg(v) + case OpARMBICshiftRL: + return rewriteValueARM_OpARMBICshiftRL(v) + case OpARMBICshiftRLreg: + return rewriteValueARM_OpARMBICshiftRLreg(v) + case OpARMCMN: + return rewriteValueARM_OpARMCMN(v) + case OpARMCMNconst: + return rewriteValueARM_OpARMCMNconst(v) + case OpARMCMNshiftLL: + return rewriteValueARM_OpARMCMNshiftLL(v) + case OpARMCMNshiftLLreg: + return rewriteValueARM_OpARMCMNshiftLLreg(v) + case OpARMCMNshiftRA: + return rewriteValueARM_OpARMCMNshiftRA(v) + case OpARMCMNshiftRAreg: + return rewriteValueARM_OpARMCMNshiftRAreg(v) + case OpARMCMNshiftRL: + return rewriteValueARM_OpARMCMNshiftRL(v) + case OpARMCMNshiftRLreg: + return rewriteValueARM_OpARMCMNshiftRLreg(v) + case OpARMCMOVWHSconst: + return rewriteValueARM_OpARMCMOVWHSconst(v) + case OpARMCMOVWLSconst: + return rewriteValueARM_OpARMCMOVWLSconst(v) + case OpARMCMP: + return rewriteValueARM_OpARMCMP(v) + case OpARMCMPD: + return rewriteValueARM_OpARMCMPD(v) + case OpARMCMPF: + return rewriteValueARM_OpARMCMPF(v) + case OpARMCMPconst: + return rewriteValueARM_OpARMCMPconst(v) + case OpARMCMPshiftLL: + return rewriteValueARM_OpARMCMPshiftLL(v) + case OpARMCMPshiftLLreg: + return rewriteValueARM_OpARMCMPshiftLLreg(v) + case OpARMCMPshiftRA: + return rewriteValueARM_OpARMCMPshiftRA(v) + case OpARMCMPshiftRAreg: + return rewriteValueARM_OpARMCMPshiftRAreg(v) + case OpARMCMPshiftRL: + return rewriteValueARM_OpARMCMPshiftRL(v) + case OpARMCMPshiftRLreg: + return rewriteValueARM_OpARMCMPshiftRLreg(v) + case OpARMEqual: + return rewriteValueARM_OpARMEqual(v) + case OpARMGreaterEqual: + return rewriteValueARM_OpARMGreaterEqual(v) + case OpARMGreaterEqualU: + return rewriteValueARM_OpARMGreaterEqualU(v) + case OpARMGreaterThan: + return rewriteValueARM_OpARMGreaterThan(v) + case OpARMGreaterThanU: + return rewriteValueARM_OpARMGreaterThanU(v) + case OpARMLessEqual: + return rewriteValueARM_OpARMLessEqual(v) + case OpARMLessEqualU: + return rewriteValueARM_OpARMLessEqualU(v) + case OpARMLessThan: + return rewriteValueARM_OpARMLessThan(v) + case OpARMLessThanU: + return rewriteValueARM_OpARMLessThanU(v) + case OpARMLoweredPanicBoundsRC: + return rewriteValueARM_OpARMLoweredPanicBoundsRC(v) + case OpARMLoweredPanicBoundsRR: + return rewriteValueARM_OpARMLoweredPanicBoundsRR(v) + case OpARMLoweredPanicExtendRC: + return rewriteValueARM_OpARMLoweredPanicExtendRC(v) + case OpARMLoweredPanicExtendRR: + return rewriteValueARM_OpARMLoweredPanicExtendRR(v) + case OpARMMOVBUload: + return rewriteValueARM_OpARMMOVBUload(v) + case OpARMMOVBUloadidx: + return rewriteValueARM_OpARMMOVBUloadidx(v) + case OpARMMOVBUreg: + return rewriteValueARM_OpARMMOVBUreg(v) + case OpARMMOVBload: + return rewriteValueARM_OpARMMOVBload(v) + case OpARMMOVBloadidx: + return rewriteValueARM_OpARMMOVBloadidx(v) + case OpARMMOVBreg: + return rewriteValueARM_OpARMMOVBreg(v) + case OpARMMOVBstore: + return rewriteValueARM_OpARMMOVBstore(v) + case OpARMMOVBstoreidx: + return rewriteValueARM_OpARMMOVBstoreidx(v) + case OpARMMOVDload: + return rewriteValueARM_OpARMMOVDload(v) + case OpARMMOVDstore: + return rewriteValueARM_OpARMMOVDstore(v) + case OpARMMOVFload: + return rewriteValueARM_OpARMMOVFload(v) + case OpARMMOVFstore: + return rewriteValueARM_OpARMMOVFstore(v) + case OpARMMOVHUload: + return rewriteValueARM_OpARMMOVHUload(v) + case OpARMMOVHUloadidx: + return rewriteValueARM_OpARMMOVHUloadidx(v) + case OpARMMOVHUreg: + return rewriteValueARM_OpARMMOVHUreg(v) + case OpARMMOVHload: + return rewriteValueARM_OpARMMOVHload(v) + case OpARMMOVHloadidx: + return rewriteValueARM_OpARMMOVHloadidx(v) + case OpARMMOVHreg: + return rewriteValueARM_OpARMMOVHreg(v) + case OpARMMOVHstore: + return rewriteValueARM_OpARMMOVHstore(v) + case OpARMMOVHstoreidx: + return rewriteValueARM_OpARMMOVHstoreidx(v) + case OpARMMOVWload: + return rewriteValueARM_OpARMMOVWload(v) + case OpARMMOVWloadidx: + return rewriteValueARM_OpARMMOVWloadidx(v) + case OpARMMOVWloadshiftLL: + return rewriteValueARM_OpARMMOVWloadshiftLL(v) + case OpARMMOVWloadshiftRA: + return rewriteValueARM_OpARMMOVWloadshiftRA(v) + case OpARMMOVWloadshiftRL: + return rewriteValueARM_OpARMMOVWloadshiftRL(v) + case OpARMMOVWnop: + return rewriteValueARM_OpARMMOVWnop(v) + case OpARMMOVWreg: + return rewriteValueARM_OpARMMOVWreg(v) + case OpARMMOVWstore: + return rewriteValueARM_OpARMMOVWstore(v) + case OpARMMOVWstoreidx: + return rewriteValueARM_OpARMMOVWstoreidx(v) + case OpARMMOVWstoreshiftLL: + return rewriteValueARM_OpARMMOVWstoreshiftLL(v) + case OpARMMOVWstoreshiftRA: + return rewriteValueARM_OpARMMOVWstoreshiftRA(v) + case OpARMMOVWstoreshiftRL: + return rewriteValueARM_OpARMMOVWstoreshiftRL(v) + case OpARMMUL: + return rewriteValueARM_OpARMMUL(v) + case OpARMMULA: + return rewriteValueARM_OpARMMULA(v) + case OpARMMULD: + return rewriteValueARM_OpARMMULD(v) + case OpARMMULF: + return rewriteValueARM_OpARMMULF(v) + case OpARMMULS: + return rewriteValueARM_OpARMMULS(v) + case OpARMMVN: + return rewriteValueARM_OpARMMVN(v) + case OpARMMVNshiftLL: + return rewriteValueARM_OpARMMVNshiftLL(v) + case OpARMMVNshiftLLreg: + return rewriteValueARM_OpARMMVNshiftLLreg(v) + case OpARMMVNshiftRA: + return rewriteValueARM_OpARMMVNshiftRA(v) + case OpARMMVNshiftRAreg: + return rewriteValueARM_OpARMMVNshiftRAreg(v) + case OpARMMVNshiftRL: + return rewriteValueARM_OpARMMVNshiftRL(v) + case OpARMMVNshiftRLreg: + return rewriteValueARM_OpARMMVNshiftRLreg(v) + case OpARMNEGD: + return rewriteValueARM_OpARMNEGD(v) + case OpARMNEGF: + return rewriteValueARM_OpARMNEGF(v) + case OpARMNMULD: + return rewriteValueARM_OpARMNMULD(v) + case OpARMNMULF: + return rewriteValueARM_OpARMNMULF(v) + case OpARMNotEqual: + return rewriteValueARM_OpARMNotEqual(v) + case OpARMOR: + return rewriteValueARM_OpARMOR(v) + case OpARMORconst: + return rewriteValueARM_OpARMORconst(v) + case OpARMORshiftLL: + return rewriteValueARM_OpARMORshiftLL(v) + case OpARMORshiftLLreg: + return rewriteValueARM_OpARMORshiftLLreg(v) + case OpARMORshiftRA: + return rewriteValueARM_OpARMORshiftRA(v) + case OpARMORshiftRAreg: + return rewriteValueARM_OpARMORshiftRAreg(v) + case OpARMORshiftRL: + return rewriteValueARM_OpARMORshiftRL(v) + case OpARMORshiftRLreg: + return rewriteValueARM_OpARMORshiftRLreg(v) + case OpARMRSB: + return rewriteValueARM_OpARMRSB(v) + case OpARMRSBSshiftLL: + return rewriteValueARM_OpARMRSBSshiftLL(v) + case OpARMRSBSshiftLLreg: + return rewriteValueARM_OpARMRSBSshiftLLreg(v) + case OpARMRSBSshiftRA: + return rewriteValueARM_OpARMRSBSshiftRA(v) + case OpARMRSBSshiftRAreg: + return rewriteValueARM_OpARMRSBSshiftRAreg(v) + case OpARMRSBSshiftRL: + return rewriteValueARM_OpARMRSBSshiftRL(v) + case OpARMRSBSshiftRLreg: + return rewriteValueARM_OpARMRSBSshiftRLreg(v) + case OpARMRSBconst: + return rewriteValueARM_OpARMRSBconst(v) + case OpARMRSBshiftLL: + return rewriteValueARM_OpARMRSBshiftLL(v) + case OpARMRSBshiftLLreg: + return rewriteValueARM_OpARMRSBshiftLLreg(v) + case OpARMRSBshiftRA: + return rewriteValueARM_OpARMRSBshiftRA(v) + case OpARMRSBshiftRAreg: + return rewriteValueARM_OpARMRSBshiftRAreg(v) + case OpARMRSBshiftRL: + return rewriteValueARM_OpARMRSBshiftRL(v) + case OpARMRSBshiftRLreg: + return rewriteValueARM_OpARMRSBshiftRLreg(v) + case OpARMRSCconst: + return rewriteValueARM_OpARMRSCconst(v) + case OpARMRSCshiftLL: + return rewriteValueARM_OpARMRSCshiftLL(v) + case OpARMRSCshiftLLreg: + return rewriteValueARM_OpARMRSCshiftLLreg(v) + case OpARMRSCshiftRA: + return rewriteValueARM_OpARMRSCshiftRA(v) + case OpARMRSCshiftRAreg: + return rewriteValueARM_OpARMRSCshiftRAreg(v) + case OpARMRSCshiftRL: + return rewriteValueARM_OpARMRSCshiftRL(v) + case OpARMRSCshiftRLreg: + return rewriteValueARM_OpARMRSCshiftRLreg(v) + case OpARMSBC: + return rewriteValueARM_OpARMSBC(v) + case OpARMSBCconst: + return rewriteValueARM_OpARMSBCconst(v) + case OpARMSBCshiftLL: + return rewriteValueARM_OpARMSBCshiftLL(v) + case OpARMSBCshiftLLreg: + return rewriteValueARM_OpARMSBCshiftLLreg(v) + case OpARMSBCshiftRA: + return rewriteValueARM_OpARMSBCshiftRA(v) + case OpARMSBCshiftRAreg: + return rewriteValueARM_OpARMSBCshiftRAreg(v) + case OpARMSBCshiftRL: + return rewriteValueARM_OpARMSBCshiftRL(v) + case OpARMSBCshiftRLreg: + return rewriteValueARM_OpARMSBCshiftRLreg(v) + case OpARMSLL: + return rewriteValueARM_OpARMSLL(v) + case OpARMSLLconst: + return rewriteValueARM_OpARMSLLconst(v) + case OpARMSRA: + return rewriteValueARM_OpARMSRA(v) + case OpARMSRAcond: + return rewriteValueARM_OpARMSRAcond(v) + case OpARMSRAconst: + return rewriteValueARM_OpARMSRAconst(v) + case OpARMSRL: + return rewriteValueARM_OpARMSRL(v) + case OpARMSRLconst: + return rewriteValueARM_OpARMSRLconst(v) + case OpARMSRR: + return rewriteValueARM_OpARMSRR(v) + case OpARMSUB: + return rewriteValueARM_OpARMSUB(v) + case OpARMSUBD: + return rewriteValueARM_OpARMSUBD(v) + case OpARMSUBF: + return rewriteValueARM_OpARMSUBF(v) + case OpARMSUBS: + return rewriteValueARM_OpARMSUBS(v) + case OpARMSUBSshiftLL: + return rewriteValueARM_OpARMSUBSshiftLL(v) + case OpARMSUBSshiftLLreg: + return rewriteValueARM_OpARMSUBSshiftLLreg(v) + case OpARMSUBSshiftRA: + return rewriteValueARM_OpARMSUBSshiftRA(v) + case OpARMSUBSshiftRAreg: + return rewriteValueARM_OpARMSUBSshiftRAreg(v) + case OpARMSUBSshiftRL: + return rewriteValueARM_OpARMSUBSshiftRL(v) + case OpARMSUBSshiftRLreg: + return rewriteValueARM_OpARMSUBSshiftRLreg(v) + case OpARMSUBconst: + return rewriteValueARM_OpARMSUBconst(v) + case OpARMSUBshiftLL: + return rewriteValueARM_OpARMSUBshiftLL(v) + case OpARMSUBshiftLLreg: + return rewriteValueARM_OpARMSUBshiftLLreg(v) + case OpARMSUBshiftRA: + return rewriteValueARM_OpARMSUBshiftRA(v) + case OpARMSUBshiftRAreg: + return rewriteValueARM_OpARMSUBshiftRAreg(v) + case OpARMSUBshiftRL: + return rewriteValueARM_OpARMSUBshiftRL(v) + case OpARMSUBshiftRLreg: + return rewriteValueARM_OpARMSUBshiftRLreg(v) + case OpARMTEQ: + return rewriteValueARM_OpARMTEQ(v) + case OpARMTEQconst: + return rewriteValueARM_OpARMTEQconst(v) + case OpARMTEQshiftLL: + return rewriteValueARM_OpARMTEQshiftLL(v) + case OpARMTEQshiftLLreg: + return rewriteValueARM_OpARMTEQshiftLLreg(v) + case OpARMTEQshiftRA: + return rewriteValueARM_OpARMTEQshiftRA(v) + case OpARMTEQshiftRAreg: + return rewriteValueARM_OpARMTEQshiftRAreg(v) + case OpARMTEQshiftRL: + return rewriteValueARM_OpARMTEQshiftRL(v) + case OpARMTEQshiftRLreg: + return rewriteValueARM_OpARMTEQshiftRLreg(v) + case OpARMTST: + return rewriteValueARM_OpARMTST(v) + case OpARMTSTconst: + return rewriteValueARM_OpARMTSTconst(v) + case OpARMTSTshiftLL: + return rewriteValueARM_OpARMTSTshiftLL(v) + case OpARMTSTshiftLLreg: + return rewriteValueARM_OpARMTSTshiftLLreg(v) + case OpARMTSTshiftRA: + return rewriteValueARM_OpARMTSTshiftRA(v) + case OpARMTSTshiftRAreg: + return rewriteValueARM_OpARMTSTshiftRAreg(v) + case OpARMTSTshiftRL: + return rewriteValueARM_OpARMTSTshiftRL(v) + case OpARMTSTshiftRLreg: + return rewriteValueARM_OpARMTSTshiftRLreg(v) + case OpARMXOR: + return rewriteValueARM_OpARMXOR(v) + case OpARMXORconst: + return rewriteValueARM_OpARMXORconst(v) + case OpARMXORshiftLL: + return rewriteValueARM_OpARMXORshiftLL(v) + case OpARMXORshiftLLreg: + return rewriteValueARM_OpARMXORshiftLLreg(v) + case OpARMXORshiftRA: + return rewriteValueARM_OpARMXORshiftRA(v) + case OpARMXORshiftRAreg: + return rewriteValueARM_OpARMXORshiftRAreg(v) + case OpARMXORshiftRL: + return rewriteValueARM_OpARMXORshiftRL(v) + case OpARMXORshiftRLreg: + return rewriteValueARM_OpARMXORshiftRLreg(v) + case OpARMXORshiftRR: + return rewriteValueARM_OpARMXORshiftRR(v) + case OpAbs: + v.Op = OpARMABSD + return true + case OpAdd16: + v.Op = OpARMADD + return true + case OpAdd32: + v.Op = OpARMADD + return true + case OpAdd32F: + v.Op = OpARMADDF + return true + case OpAdd32carry: + v.Op = OpARMADDS + return true + case OpAdd32carrywithcarry: + v.Op = OpARMADCS + return true + case OpAdd32withcarry: + v.Op = OpARMADC + return true + case OpAdd64F: + v.Op = OpARMADDD + return true + case OpAdd8: + v.Op = OpARMADD + return true + case OpAddPtr: + v.Op = OpARMADD + return true + case OpAddr: + return rewriteValueARM_OpAddr(v) + case OpAnd16: + v.Op = OpARMAND + return true + case OpAnd32: + v.Op = OpARMAND + return true + case OpAnd8: + v.Op = OpARMAND + return true + case OpAndB: + v.Op = OpARMAND + return true + case OpAvg32u: + return rewriteValueARM_OpAvg32u(v) + case OpBitLen16: + return rewriteValueARM_OpBitLen16(v) + case OpBitLen32: + return rewriteValueARM_OpBitLen32(v) + case OpBitLen8: + return rewriteValueARM_OpBitLen8(v) + case OpBswap32: + return rewriteValueARM_OpBswap32(v) + case OpClosureCall: + v.Op = OpARMCALLclosure + return true + case OpCom16: + v.Op = OpARMMVN + return true + case OpCom32: + v.Op = OpARMMVN + return true + case OpCom8: + v.Op = OpARMMVN + return true + case OpConst16: + return rewriteValueARM_OpConst16(v) + case OpConst32: + return rewriteValueARM_OpConst32(v) + case OpConst32F: + return rewriteValueARM_OpConst32F(v) + case OpConst64F: + return rewriteValueARM_OpConst64F(v) + case OpConst8: + return rewriteValueARM_OpConst8(v) + case OpConstBool: + return rewriteValueARM_OpConstBool(v) + case OpConstNil: + return rewriteValueARM_OpConstNil(v) + case OpCtz16: + return rewriteValueARM_OpCtz16(v) + case OpCtz16NonZero: + v.Op = OpCtz32 + return true + case OpCtz32: + return rewriteValueARM_OpCtz32(v) + case OpCtz32NonZero: + v.Op = OpCtz32 + return true + case OpCtz8: + return rewriteValueARM_OpCtz8(v) + case OpCtz8NonZero: + v.Op = OpCtz32 + return true + case OpCvt32Fto32: + v.Op = OpARMMOVFW + return true + case OpCvt32Fto32U: + v.Op = OpARMMOVFWU + return true + case OpCvt32Fto64F: + v.Op = OpARMMOVFD + return true + case OpCvt32Uto32F: + v.Op = OpARMMOVWUF + return true + case OpCvt32Uto64F: + v.Op = OpARMMOVWUD + return true + case OpCvt32to32F: + v.Op = OpARMMOVWF + return true + case OpCvt32to64F: + v.Op = OpARMMOVWD + return true + case OpCvt64Fto32: + v.Op = OpARMMOVDW + return true + case OpCvt64Fto32F: + v.Op = OpARMMOVDF + return true + case OpCvt64Fto32U: + v.Op = OpARMMOVDWU + return true + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpDiv16: + return rewriteValueARM_OpDiv16(v) + case OpDiv16u: + return rewriteValueARM_OpDiv16u(v) + case OpDiv32: + return rewriteValueARM_OpDiv32(v) + case OpDiv32F: + v.Op = OpARMDIVF + return true + case OpDiv32u: + return rewriteValueARM_OpDiv32u(v) + case OpDiv64F: + v.Op = OpARMDIVD + return true + case OpDiv8: + return rewriteValueARM_OpDiv8(v) + case OpDiv8u: + return rewriteValueARM_OpDiv8u(v) + case OpEq16: + return rewriteValueARM_OpEq16(v) + case OpEq32: + return rewriteValueARM_OpEq32(v) + case OpEq32F: + return rewriteValueARM_OpEq32F(v) + case OpEq64F: + return rewriteValueARM_OpEq64F(v) + case OpEq8: + return rewriteValueARM_OpEq8(v) + case OpEqB: + return rewriteValueARM_OpEqB(v) + case OpEqPtr: + return rewriteValueARM_OpEqPtr(v) + case OpFMA: + return rewriteValueARM_OpFMA(v) + case OpGetCallerPC: + v.Op = OpARMLoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = OpARMLoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = OpARMLoweredGetClosurePtr + return true + case OpHmul32: + v.Op = OpARMHMUL + return true + case OpHmul32u: + v.Op = OpARMHMULU + return true + case OpInterCall: + v.Op = OpARMCALLinter + return true + case OpIsInBounds: + return rewriteValueARM_OpIsInBounds(v) + case OpIsNonNil: + return rewriteValueARM_OpIsNonNil(v) + case OpIsSliceInBounds: + return rewriteValueARM_OpIsSliceInBounds(v) + case OpLeq16: + return rewriteValueARM_OpLeq16(v) + case OpLeq16U: + return rewriteValueARM_OpLeq16U(v) + case OpLeq32: + return rewriteValueARM_OpLeq32(v) + case OpLeq32F: + return rewriteValueARM_OpLeq32F(v) + case OpLeq32U: + return rewriteValueARM_OpLeq32U(v) + case OpLeq64F: + return rewriteValueARM_OpLeq64F(v) + case OpLeq8: + return rewriteValueARM_OpLeq8(v) + case OpLeq8U: + return rewriteValueARM_OpLeq8U(v) + case OpLess16: + return rewriteValueARM_OpLess16(v) + case OpLess16U: + return rewriteValueARM_OpLess16U(v) + case OpLess32: + return rewriteValueARM_OpLess32(v) + case OpLess32F: + return rewriteValueARM_OpLess32F(v) + case OpLess32U: + return rewriteValueARM_OpLess32U(v) + case OpLess64F: + return rewriteValueARM_OpLess64F(v) + case OpLess8: + return rewriteValueARM_OpLess8(v) + case OpLess8U: + return rewriteValueARM_OpLess8U(v) + case OpLoad: + return rewriteValueARM_OpLoad(v) + case OpLocalAddr: + return rewriteValueARM_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValueARM_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValueARM_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValueARM_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValueARM_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValueARM_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValueARM_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValueARM_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValueARM_OpLsh32x8(v) + case OpLsh8x16: + return rewriteValueARM_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValueARM_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValueARM_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValueARM_OpLsh8x8(v) + case OpMod16: + return rewriteValueARM_OpMod16(v) + case OpMod16u: + return rewriteValueARM_OpMod16u(v) + case OpMod32: + return rewriteValueARM_OpMod32(v) + case OpMod32u: + return rewriteValueARM_OpMod32u(v) + case OpMod8: + return rewriteValueARM_OpMod8(v) + case OpMod8u: + return rewriteValueARM_OpMod8u(v) + case OpMove: + return rewriteValueARM_OpMove(v) + case OpMul16: + v.Op = OpARMMUL + return true + case OpMul32: + v.Op = OpARMMUL + return true + case OpMul32F: + v.Op = OpARMMULF + return true + case OpMul32uhilo: + v.Op = OpARMMULLU + return true + case OpMul64F: + v.Op = OpARMMULD + return true + case OpMul8: + v.Op = OpARMMUL + return true + case OpNeg16: + return rewriteValueARM_OpNeg16(v) + case OpNeg32: + return rewriteValueARM_OpNeg32(v) + case OpNeg32F: + v.Op = OpARMNEGF + return true + case OpNeg64F: + v.Op = OpARMNEGD + return true + case OpNeg8: + return rewriteValueARM_OpNeg8(v) + case OpNeq16: + return rewriteValueARM_OpNeq16(v) + case OpNeq32: + return rewriteValueARM_OpNeq32(v) + case OpNeq32F: + return rewriteValueARM_OpNeq32F(v) + case OpNeq64F: + return rewriteValueARM_OpNeq64F(v) + case OpNeq8: + return rewriteValueARM_OpNeq8(v) + case OpNeqB: + v.Op = OpARMXOR + return true + case OpNeqPtr: + return rewriteValueARM_OpNeqPtr(v) + case OpNilCheck: + v.Op = OpARMLoweredNilCheck + return true + case OpNot: + return rewriteValueARM_OpNot(v) + case OpOffPtr: + return rewriteValueARM_OpOffPtr(v) + case OpOr16: + v.Op = OpARMOR + return true + case OpOr32: + v.Op = OpARMOR + return true + case OpOr8: + v.Op = OpARMOR + return true + case OpOrB: + v.Op = OpARMOR + return true + case OpPanicBounds: + v.Op = OpARMLoweredPanicBoundsRR + return true + case OpPanicExtend: + v.Op = OpARMLoweredPanicExtendRR + return true + case OpRotateLeft16: + return rewriteValueARM_OpRotateLeft16(v) + case OpRotateLeft32: + return rewriteValueARM_OpRotateLeft32(v) + case OpRotateLeft8: + return rewriteValueARM_OpRotateLeft8(v) + case OpRound32F: + v.Op = OpCopy + return true + case OpRound64F: + v.Op = OpCopy + return true + case OpRsh16Ux16: + return rewriteValueARM_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValueARM_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValueARM_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValueARM_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValueARM_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValueARM_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValueARM_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValueARM_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValueARM_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValueARM_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValueARM_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValueARM_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValueARM_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValueARM_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValueARM_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValueARM_OpRsh32x8(v) + case OpRsh8Ux16: + return rewriteValueARM_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValueARM_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValueARM_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValueARM_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValueARM_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValueARM_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValueARM_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValueARM_OpRsh8x8(v) + case OpSelect0: + return rewriteValueARM_OpSelect0(v) + case OpSelect1: + return rewriteValueARM_OpSelect1(v) + case OpSignExt16to32: + v.Op = OpARMMOVHreg + return true + case OpSignExt8to16: + v.Op = OpARMMOVBreg + return true + case OpSignExt8to32: + v.Op = OpARMMOVBreg + return true + case OpSignmask: + return rewriteValueARM_OpSignmask(v) + case OpSlicemask: + return rewriteValueARM_OpSlicemask(v) + case OpSqrt: + v.Op = OpARMSQRTD + return true + case OpSqrt32: + v.Op = OpARMSQRTF + return true + case OpStaticCall: + v.Op = OpARMCALLstatic + return true + case OpStore: + return rewriteValueARM_OpStore(v) + case OpSub16: + v.Op = OpARMSUB + return true + case OpSub32: + v.Op = OpARMSUB + return true + case OpSub32F: + v.Op = OpARMSUBF + return true + case OpSub32carry: + v.Op = OpARMSUBS + return true + case OpSub32withcarry: + v.Op = OpARMSBC + return true + case OpSub64F: + v.Op = OpARMSUBD + return true + case OpSub8: + v.Op = OpARMSUB + return true + case OpSubPtr: + v.Op = OpARMSUB + return true + case OpTailCall: + v.Op = OpARMCALLtail + return true + case OpTrunc16to8: + v.Op = OpCopy + return true + case OpTrunc32to16: + v.Op = OpCopy + return true + case OpTrunc32to8: + v.Op = OpCopy + return true + case OpWB: + v.Op = OpARMLoweredWB + return true + case OpXor16: + v.Op = OpARMXOR + return true + case OpXor32: + v.Op = OpARMXOR + return true + case OpXor8: + v.Op = OpARMXOR + return true + case OpZero: + return rewriteValueARM_OpZero(v) + case OpZeroExt16to32: + v.Op = OpARMMOVHUreg + return true + case OpZeroExt8to16: + v.Op = OpARMMOVBUreg + return true + case OpZeroExt8to32: + v.Op = OpARMMOVBUreg + return true + case OpZeromask: + return rewriteValueARM_OpZeromask(v) + } + return false +} +func rewriteValueARM_OpARMADC(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADC (MOVWconst [c]) x flags) + // result: (ADCconst [c] x flags) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, flags) + return true + } + break + } + // match: (ADC x (SLLconst [c] y) flags) + // result: (ADCshiftLL x y [c] flags) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMADCshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + break + } + // match: (ADC x (SRLconst [c] y) flags) + // result: (ADCshiftRL x y [c] flags) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMADCshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + break + } + // match: (ADC x (SRAconst [c] y) flags) + // result: (ADCshiftRA x y [c] flags) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRAconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMADCshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + break + } + // match: (ADC x (SLL y z) flags) + // result: (ADCshiftLLreg x y z flags) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMADCshiftLLreg) + v.AddArg4(x, y, z, flags) + return true + } + break + } + // match: (ADC x (SRL y z) flags) + // result: (ADCshiftRLreg x y z flags) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMADCshiftRLreg) + v.AddArg4(x, y, z, flags) + return true + } + break + } + // match: (ADC x (SRA y z) flags) + // result: (ADCshiftRAreg x y z flags) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRA { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMADCshiftRAreg) + v.AddArg4(x, y, z, flags) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMADCconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADCconst [c] (ADDconst [d] x) flags) + // result: (ADCconst [c+d] x flags) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMADDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + flags := v_1 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg2(x, flags) + return true + } + // match: (ADCconst [c] (SUBconst [d] x) flags) + // result: (ADCconst [c-d] x flags) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSUBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + flags := v_1 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(c - d) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMADCshiftLL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADCshiftLL (MOVWconst [c]) x [d] flags) + // result: (ADCconst [c] (SLLconst x [d]) flags) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg2(v0, flags) + return true + } + // match: (ADCshiftLL x (MOVWconst [c]) [d] flags) + // result: (ADCconst x [c< x y) flags) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + flags := v_3 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg2(v0, flags) + return true + } + // match: (ADCshiftLLreg x y (MOVWconst [c]) flags) + // cond: 0 <= c && c < 32 + // result: (ADCshiftLL x y [c] flags) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + flags := v_3 + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMADCshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + return false +} +func rewriteValueARM_OpARMADCshiftRA(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADCshiftRA (MOVWconst [c]) x [d] flags) + // result: (ADCconst [c] (SRAconst x [d]) flags) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg2(v0, flags) + return true + } + // match: (ADCshiftRA x (MOVWconst [c]) [d] flags) + // result: (ADCconst x [c>>uint64(d)] flags) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + flags := v_2 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMADCshiftRAreg(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADCshiftRAreg (MOVWconst [c]) x y flags) + // result: (ADCconst [c] (SRA x y) flags) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + flags := v_3 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg2(v0, flags) + return true + } + // match: (ADCshiftRAreg x y (MOVWconst [c]) flags) + // cond: 0 <= c && c < 32 + // result: (ADCshiftRA x y [c] flags) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + flags := v_3 + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMADCshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + return false +} +func rewriteValueARM_OpARMADCshiftRL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADCshiftRL (MOVWconst [c]) x [d] flags) + // result: (ADCconst [c] (SRLconst x [d]) flags) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg2(v0, flags) + return true + } + // match: (ADCshiftRL x (MOVWconst [c]) [d] flags) + // result: (ADCconst x [int32(uint32(c)>>uint64(d))] flags) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + flags := v_2 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMADCshiftRLreg(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADCshiftRLreg (MOVWconst [c]) x y flags) + // result: (ADCconst [c] (SRL x y) flags) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + flags := v_3 + v.reset(OpARMADCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg2(v0, flags) + return true + } + // match: (ADCshiftRLreg x y (MOVWconst [c]) flags) + // cond: 0 <= c && c < 32 + // result: (ADCshiftRL x y [c] flags) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + flags := v_3 + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMADCshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + return false +} +func rewriteValueARM_OpARMADD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADD x (MOVWconst [c])) + // cond: !t.IsPtr() + // result: (ADDconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + t := v_1.Type + c := auxIntToInt32(v_1.AuxInt) + if !(!t.IsPtr()) { + continue + } + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ADD x (SLLconst [c] y)) + // result: (ADDshiftLL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMADDshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADD x (SRLconst [c] y)) + // result: (ADDshiftRL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMADDshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADD x (SRAconst [c] y)) + // result: (ADDshiftRA x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRAconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMADDshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADD x (SLL y z)) + // result: (ADDshiftLLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMADDshiftLLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (ADD x (SRL y z)) + // result: (ADDshiftRLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMADDshiftRLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (ADD x (SRA y z)) + // result: (ADDshiftRAreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRA { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMADDshiftRAreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (ADD x (RSBconst [0] y)) + // result: (SUB x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMRSBconst || auxIntToInt32(v_1.AuxInt) != 0 { + continue + } + y := v_1.Args[0] + v.reset(OpARMSUB) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADD (RSBconst [c] x) (RSBconst [d] y)) + // result: (RSBconst [c+d] (ADD x y)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARMRSBconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if v_1.Op != OpARMRSBconst { + continue + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c + d) + v0 := b.NewValue0(v.Pos, OpARMADD, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (ADD (MUL x y) a) + // result: (MULA x y a) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARMMUL { + continue + } + y := v_0.Args[1] + x := v_0.Args[0] + a := v_1 + v.reset(OpARMMULA) + v.AddArg3(x, y, a) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMADDD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDD a (MULD x y)) + // cond: a.Uses == 1 && buildcfg.GOARM.Version >= 6 + // result: (MULAD a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if v_1.Op != OpARMMULD { + continue + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Uses == 1 && buildcfg.GOARM.Version >= 6) { + continue + } + v.reset(OpARMMULAD) + v.AddArg3(a, x, y) + return true + } + break + } + // match: (ADDD a (NMULD x y)) + // cond: a.Uses == 1 && buildcfg.GOARM.Version >= 6 + // result: (MULSD a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if v_1.Op != OpARMNMULD { + continue + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Uses == 1 && buildcfg.GOARM.Version >= 6) { + continue + } + v.reset(OpARMMULSD) + v.AddArg3(a, x, y) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMADDF(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDF a (MULF x y)) + // cond: a.Uses == 1 && buildcfg.GOARM.Version >= 6 + // result: (MULAF a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if v_1.Op != OpARMMULF { + continue + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Uses == 1 && buildcfg.GOARM.Version >= 6) { + continue + } + v.reset(OpARMMULAF) + v.AddArg3(a, x, y) + return true + } + break + } + // match: (ADDF a (NMULF x y)) + // cond: a.Uses == 1 && buildcfg.GOARM.Version >= 6 + // result: (MULSF a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if v_1.Op != OpARMNMULF { + continue + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Uses == 1 && buildcfg.GOARM.Version >= 6) { + continue + } + v.reset(OpARMMULSF) + v.AddArg3(a, x, y) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMADDS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDS x (MOVWconst [c])) + // result: (ADDSconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMADDSconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ADDS x (SLLconst [c] y)) + // result: (ADDSshiftLL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMADDSshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDS x (SRLconst [c] y)) + // result: (ADDSshiftRL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMADDSshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDS x (SRAconst [c] y)) + // result: (ADDSshiftRA x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRAconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMADDSshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDS x (SLL y z)) + // result: (ADDSshiftLLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMADDSshiftLLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (ADDS x (SRL y z)) + // result: (ADDSshiftRLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMADDSshiftRLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (ADDS x (SRA y z)) + // result: (ADDSshiftRAreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRA { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMADDSshiftRAreg) + v.AddArg3(x, y, z) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMADDSshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDSshiftLL (MOVWconst [c]) x [d]) + // result: (ADDSconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMADDSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ADDSshiftLL x (MOVWconst [c]) [d]) + // result: (ADDSconst x [c< x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMADDSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ADDSshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ADDSshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMADDSshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMADDSshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDSshiftRA (MOVWconst [c]) x [d]) + // result: (ADDSconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMADDSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ADDSshiftRA x (MOVWconst [c]) [d]) + // result: (ADDSconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMADDSconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMADDSshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDSshiftRAreg (MOVWconst [c]) x y) + // result: (ADDSconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMADDSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ADDSshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ADDSshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMADDSshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMADDSshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDSshiftRL (MOVWconst [c]) x [d]) + // result: (ADDSconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMADDSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ADDSshiftRL x (MOVWconst [c]) [d]) + // result: (ADDSconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMADDSconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMADDSshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDSshiftRLreg (MOVWconst [c]) x y) + // result: (ADDSconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMADDSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ADDSshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ADDSshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMADDSshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMADDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDconst [off1] (MOVWaddr [off2] {sym} ptr)) + // result: (MOVWaddr [off1+off2] {sym} ptr) + for { + off1 := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + v.reset(OpARMMOVWaddr) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg(ptr) + return true + } + // match: (ADDconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ADDconst [c] x) + // cond: !isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c)) + // result: (SUBconst [-c] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(!isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c))) { + break + } + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } + // match: (ADDconst [c] x) + // cond: buildcfg.GOARM.Version==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff + // result: (SUBconst [-c] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(buildcfg.GOARM.Version == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && uint32(-c) <= 0xffff) { + break + } + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } + // match: (ADDconst [c] (MOVWconst [d])) + // result: (MOVWconst [c+d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(c + d) + return true + } + // match: (ADDconst [c] (ADDconst [d] x)) + // result: (ADDconst [c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMADDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg(x) + return true + } + // match: (ADDconst [c] (SUBconst [d] x)) + // result: (ADDconst [c-d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSUBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c - d) + v.AddArg(x) + return true + } + // match: (ADDconst [c] (RSBconst [d] x)) + // result: (RSBconst [c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMRSBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMADDshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADDshiftLL (MOVWconst [c]) x [d]) + // result: (ADDconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ADDshiftLL x (MOVWconst [c]) [d]) + // result: (ADDconst x [c< [8] (BFXU [int32(armBFAuxInt(8, 8))] x) x) + // result: (REV16 x) + for { + if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMBFXU || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != int32(armBFAuxInt(8, 8)) { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMREV16) + v.AddArg(x) + return true + } + // match: (ADDshiftLL [8] (SRLconst [24] (SLLconst [16] x)) x) + // cond: buildcfg.GOARM.Version>=6 + // result: (REV16 x) + for { + if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMSRLconst || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != 24 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMSLLconst || auxIntToInt32(v_0_0.AuxInt) != 16 { + break + } + x := v_0_0.Args[0] + if x != v_1 || !(buildcfg.GOARM.Version >= 6) { + break + } + v.reset(OpARMREV16) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMADDshiftLLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDshiftLLreg (MOVWconst [c]) x y) + // result: (ADDconst [c] (SLL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ADDshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ADDshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMADDshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMADDshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDshiftRA (MOVWconst [c]) x [d]) + // result: (ADDconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ADDshiftRA x (MOVWconst [c]) [d]) + // result: (ADDconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMADDshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDshiftRAreg (MOVWconst [c]) x y) + // result: (ADDconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ADDshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ADDshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMADDshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMADDshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDshiftRL (MOVWconst [c]) x [d]) + // result: (ADDconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ADDshiftRL x (MOVWconst [c]) [d]) + // result: (ADDconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMADDshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDshiftRLreg (MOVWconst [c]) x y) + // result: (ADDconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ADDshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ADDshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMADDshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMAND(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AND x (MOVWconst [c])) + // result: (ANDconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (AND x (SLLconst [c] y)) + // result: (ANDshiftLL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMANDshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (AND x (SRLconst [c] y)) + // result: (ANDshiftRL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMANDshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (AND x (SRAconst [c] y)) + // result: (ANDshiftRA x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRAconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMANDshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (AND x (SLL y z)) + // result: (ANDshiftLLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMANDshiftLLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (AND x (SRL y z)) + // result: (ANDshiftRLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMANDshiftRLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (AND x (SRA y z)) + // result: (ANDshiftRAreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRA { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMANDshiftRAreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (AND x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (AND x (MVN y)) + // result: (BIC x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMVN { + continue + } + y := v_1.Args[0] + v.reset(OpARMBIC) + v.AddArg2(x, y) + return true + } + break + } + // match: (AND x (MVNshiftLL y [c])) + // result: (BICshiftLL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMVNshiftLL { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMBICshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (AND x (MVNshiftRL y [c])) + // result: (BICshiftRL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMVNshiftRL { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMBICshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (AND x (MVNshiftRA y [c])) + // result: (BICshiftRA x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMVNshiftRA { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMBICshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMANDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDconst [0] _) + // result: (MOVWconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (ANDconst [c] x) + // cond: int32(c)==-1 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(int32(c) == -1) { + break + } + v.copyOf(x) + return true + } + // match: (ANDconst [c] x) + // cond: !isARMImmRot(uint32(c)) && isARMImmRot(^uint32(c)) + // result: (BICconst [int32(^uint32(c))] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(!isARMImmRot(uint32(c)) && isARMImmRot(^uint32(c))) { + break + } + v.reset(OpARMBICconst) + v.AuxInt = int32ToAuxInt(int32(^uint32(c))) + v.AddArg(x) + return true + } + // match: (ANDconst [c] x) + // cond: buildcfg.GOARM.Version==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff + // result: (BICconst [int32(^uint32(c))] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(buildcfg.GOARM.Version == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && ^uint32(c) <= 0xffff) { + break + } + v.reset(OpARMBICconst) + v.AuxInt = int32ToAuxInt(int32(^uint32(c))) + v.AddArg(x) + return true + } + // match: (ANDconst [c] (MOVWconst [d])) + // result: (MOVWconst [c&d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(c & d) + return true + } + // match: (ANDconst [c] (ANDconst [d] x)) + // result: (ANDconst [c&d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMANDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c & d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMANDshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ANDshiftLL (MOVWconst [c]) x [d]) + // result: (ANDconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ANDshiftLL x (MOVWconst [c]) [d]) + // result: (ANDconst x [c< x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ANDshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ANDshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMANDshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMANDshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ANDshiftRA (MOVWconst [c]) x [d]) + // result: (ANDconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ANDshiftRA x (MOVWconst [c]) [d]) + // result: (ANDconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + // match: (ANDshiftRA y:(SRAconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt32(v.AuxInt) + y := v_0 + if y.Op != OpARMSRAconst || auxIntToInt32(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueARM_OpARMANDshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ANDshiftRAreg (MOVWconst [c]) x y) + // result: (ANDconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ANDshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ANDshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMANDshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMANDshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ANDshiftRL (MOVWconst [c]) x [d]) + // result: (ANDconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ANDshiftRL x (MOVWconst [c]) [d]) + // result: (ANDconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (ANDshiftRL y:(SRLconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt32(v.AuxInt) + y := v_0 + if y.Op != OpARMSRLconst || auxIntToInt32(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueARM_OpARMANDshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ANDshiftRLreg (MOVWconst [c]) x y) + // result: (ANDconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ANDshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ANDshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMANDshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMBFX(v *Value) bool { + v_0 := v.Args[0] + // match: (BFX [c] (MOVWconst [d])) + // result: (MOVWconst [d<<(32-uint32(c&0xff)-uint32(c>>8))>>(32-uint32(c>>8))]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(d << (32 - uint32(c&0xff) - uint32(c>>8)) >> (32 - uint32(c>>8))) + return true + } + return false +} +func rewriteValueARM_OpARMBFXU(v *Value) bool { + v_0 := v.Args[0] + // match: (BFXU [c] (MOVWconst [d])) + // result: (MOVWconst [int32(uint32(d)<<(32-uint32(c&0xff)-uint32(c>>8))>>(32-uint32(c>>8)))]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint32(d) << (32 - uint32(c&0xff) - uint32(c>>8)) >> (32 - uint32(c>>8)))) + return true + } + return false +} +func rewriteValueARM_OpARMBIC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (BIC x (MOVWconst [c])) + // result: (BICconst [c] x) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMBICconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (BIC x (SLLconst [c] y)) + // result: (BICshiftLL x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMBICshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (BIC x (SRLconst [c] y)) + // result: (BICshiftRL x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMBICshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (BIC x (SRAconst [c] y)) + // result: (BICshiftRA x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMBICshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (BIC x (SLL y z)) + // result: (BICshiftLLreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSLL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMBICshiftLLreg) + v.AddArg3(x, y, z) + return true + } + // match: (BIC x (SRL y z)) + // result: (BICshiftRLreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSRL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMBICshiftRLreg) + v.AddArg3(x, y, z) + return true + } + // match: (BIC x (SRA y z)) + // result: (BICshiftRAreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSRA { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMBICshiftRAreg) + v.AddArg3(x, y, z) + return true + } + // match: (BIC x x) + // result: (MOVWconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMBICconst(v *Value) bool { + v_0 := v.Args[0] + // match: (BICconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (BICconst [c] _) + // cond: int32(c)==-1 + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if !(int32(c) == -1) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (BICconst [c] x) + // cond: !isARMImmRot(uint32(c)) && isARMImmRot(^uint32(c)) + // result: (ANDconst [int32(^uint32(c))] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(!isARMImmRot(uint32(c)) && isARMImmRot(^uint32(c))) { + break + } + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(int32(^uint32(c))) + v.AddArg(x) + return true + } + // match: (BICconst [c] x) + // cond: buildcfg.GOARM.Version==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff + // result: (ANDconst [int32(^uint32(c))] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(buildcfg.GOARM.Version == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && ^uint32(c) <= 0xffff) { + break + } + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(int32(^uint32(c))) + v.AddArg(x) + return true + } + // match: (BICconst [c] (MOVWconst [d])) + // result: (MOVWconst [d&^c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(d &^ c) + return true + } + // match: (BICconst [c] (BICconst [d] x)) + // result: (BICconst [c|d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMBICconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMBICconst) + v.AuxInt = int32ToAuxInt(c | d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMBICshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (BICshiftLL x (MOVWconst [c]) [d]) + // result: (BICconst x [c<>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMBICconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + // match: (BICshiftRA (SRAconst x [c]) x [c]) + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSRAconst || auxIntToInt32(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMBICshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (BICshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (BICshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMBICshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMBICshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (BICshiftRL x (MOVWconst [c]) [d]) + // result: (BICconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMBICconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (BICshiftRL (SRLconst x [c]) x [c]) + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSRLconst || auxIntToInt32(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMBICshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (BICshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (BICshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMBICshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMCMN(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMN x (MOVWconst [c])) + // result: (CMNconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMCMNconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (CMN x (SLLconst [c] y)) + // result: (CMNshiftLL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMCMNshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (CMN x (SRLconst [c] y)) + // result: (CMNshiftRL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMCMNshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (CMN x (SRAconst [c] y)) + // result: (CMNshiftRA x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRAconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMCMNshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (CMN x (SLL y z)) + // result: (CMNshiftLLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMCMNshiftLLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (CMN x (SRL y z)) + // result: (CMNshiftRLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMCMNshiftRLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (CMN x (SRA y z)) + // result: (CMNshiftRAreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRA { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMCMNshiftRAreg) + v.AddArg3(x, y, z) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMCMNconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMNconst (MOVWconst [x]) [y]) + // result: (FlagConstant [addFlags32(x,y)]) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMFlagConstant) + v.AuxInt = flagConstantToAuxInt(addFlags32(x, y)) + return true + } + return false +} +func rewriteValueARM_OpARMCMNshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMNshiftLL (MOVWconst [c]) x [d]) + // result: (CMNconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMCMNconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMNshiftLL x (MOVWconst [c]) [d]) + // result: (CMNconst x [c< x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMCMNconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (CMNshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (CMNshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMCMNshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMCMNshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMNshiftRA (MOVWconst [c]) x [d]) + // result: (CMNconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMCMNconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMNshiftRA x (MOVWconst [c]) [d]) + // result: (CMNconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMCMNconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMCMNshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMNshiftRAreg (MOVWconst [c]) x y) + // result: (CMNconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMCMNconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (CMNshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (CMNshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMCMNshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMCMNshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMNshiftRL (MOVWconst [c]) x [d]) + // result: (CMNconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMCMNconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMNshiftRL x (MOVWconst [c]) [d]) + // result: (CMNconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMCMNconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMCMNshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMNshiftRLreg (MOVWconst [c]) x y) + // result: (CMNconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMCMNconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (CMNshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (CMNshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMCMNshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMCMOVWHSconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWHSconst _ (FlagConstant [fc]) [c]) + // cond: fc.uge() + // result: (MOVWconst [c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_1.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_1.AuxInt) + if !(fc.uge()) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(c) + return true + } + // match: (CMOVWHSconst x (FlagConstant [fc]) [c]) + // cond: fc.ult() + // result: x + for { + x := v_0 + if v_1.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_1.AuxInt) + if !(fc.ult()) { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWHSconst x (InvertFlags flags) [c]) + // result: (CMOVWLSconst x flags [c]) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMInvertFlags { + break + } + flags := v_1.Args[0] + v.reset(OpARMCMOVWLSconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMCMOVWLSconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVWLSconst _ (FlagConstant [fc]) [c]) + // cond: fc.ule() + // result: (MOVWconst [c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_1.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_1.AuxInt) + if !(fc.ule()) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(c) + return true + } + // match: (CMOVWLSconst x (FlagConstant [fc]) [c]) + // cond: fc.ugt() + // result: x + for { + x := v_0 + if v_1.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_1.AuxInt) + if !(fc.ugt()) { + break + } + v.copyOf(x) + return true + } + // match: (CMOVWLSconst x (InvertFlags flags) [c]) + // result: (CMOVWHSconst x flags [c]) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMInvertFlags { + break + } + flags := v_1.Args[0] + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMCMP(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMP x (MOVWconst [c])) + // result: (CMPconst [c] x) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMCMPconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMP (MOVWconst [c]) x) + // result: (InvertFlags (CMPconst [c] x)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMP x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMP y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + // match: (CMP x (SLLconst [c] y)) + // result: (CMPshiftLL x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMCMPshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (CMP (SLLconst [c] y) x) + // result: (InvertFlags (CMPshiftLL x y [c])) + for { + if v_0.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (CMP x (SRLconst [c] y)) + // result: (CMPshiftRL x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMCMPshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (CMP (SRLconst [c] y) x) + // result: (InvertFlags (CMPshiftRL x y [c])) + for { + if v_0.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (CMP x (SRAconst [c] y)) + // result: (CMPshiftRA x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMCMPshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (CMP (SRAconst [c] y) x) + // result: (InvertFlags (CMPshiftRA x y [c])) + for { + if v_0.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (CMP x (SLL y z)) + // result: (CMPshiftLLreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSLL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMCMPshiftLLreg) + v.AddArg3(x, y, z) + return true + } + // match: (CMP (SLL y z) x) + // result: (InvertFlags (CMPshiftLLreg x y z)) + for { + if v_0.Op != OpARMSLL { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + v.AddArg(v0) + return true + } + // match: (CMP x (SRL y z)) + // result: (CMPshiftRLreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSRL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMCMPshiftRLreg) + v.AddArg3(x, y, z) + return true + } + // match: (CMP (SRL y z) x) + // result: (InvertFlags (CMPshiftRLreg x y z)) + for { + if v_0.Op != OpARMSRL { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + v.AddArg(v0) + return true + } + // match: (CMP x (SRA y z)) + // result: (CMPshiftRAreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSRA { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMCMPshiftRAreg) + v.AddArg3(x, y, z) + return true + } + // match: (CMP (SRA y z) x) + // result: (InvertFlags (CMPshiftRAreg x y z)) + for { + if v_0.Op != OpARMSRA { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM_OpARMCMPD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMPD x (MOVDconst [0])) + // result: (CMPD0 x) + for { + x := v_0 + if v_1.Op != OpARMMOVDconst || auxIntToFloat64(v_1.AuxInt) != 0 { + break + } + v.reset(OpARMCMPD0) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMCMPF(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMPF x (MOVFconst [0])) + // result: (CMPF0 x) + for { + x := v_0 + if v_1.Op != OpARMMOVFconst || auxIntToFloat64(v_1.AuxInt) != 0 { + break + } + v.reset(OpARMCMPF0) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMCMPconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPconst (MOVWconst [x]) [y]) + // result: (FlagConstant [subFlags32(x,y)]) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMFlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags32(x, y)) + return true + } + // match: (CMPconst (MOVBUreg _) [c]) + // cond: 0xff < c + // result: (FlagConstant [subFlags32(0, 1)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVBUreg || !(0xff < c) { + break + } + v.reset(OpARMFlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags32(0, 1)) + return true + } + // match: (CMPconst (MOVHUreg _) [c]) + // cond: 0xffff < c + // result: (FlagConstant [subFlags32(0, 1)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVHUreg || !(0xffff < c) { + break + } + v.reset(OpARMFlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags32(0, 1)) + return true + } + // match: (CMPconst (ANDconst _ [m]) [n]) + // cond: 0 <= m && m < n + // result: (FlagConstant [subFlags32(0, 1)]) + for { + n := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMANDconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + if !(0 <= m && m < n) { + break + } + v.reset(OpARMFlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags32(0, 1)) + return true + } + // match: (CMPconst (SRLconst _ [c]) [n]) + // cond: 0 <= n && 0 < c && c <= 32 && (1< x [d]))) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v1.AuxInt = int32ToAuxInt(d) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (CMPshiftLL x (MOVWconst [c]) [d]) + // result: (CMPconst x [c< x y))) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (CMPshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (CMPshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMCMPshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMCMPshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPshiftRA (MOVWconst [c]) x [d]) + // result: (InvertFlags (CMPconst [c] (SRAconst x [d]))) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v1.AuxInt = int32ToAuxInt(d) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (CMPshiftRA x (MOVWconst [c]) [d]) + // result: (CMPconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMCMPconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMCMPshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPshiftRAreg (MOVWconst [c]) x y) + // result: (InvertFlags (CMPconst [c] (SRA x y))) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (CMPshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (CMPshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMCMPshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMCMPshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPshiftRL (MOVWconst [c]) x [d]) + // result: (InvertFlags (CMPconst [c] (SRLconst x [d]))) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v1.AuxInt = int32ToAuxInt(d) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (CMPshiftRL x (MOVWconst [c]) [d]) + // result: (CMPconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMCMPconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMCMPshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPshiftRLreg (MOVWconst [c]) x y) + // result: (InvertFlags (CMPconst [c] (SRL x y))) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMInvertFlags) + v0 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (CMPshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (CMPshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMCMPshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMEqual(v *Value) bool { + v_0 := v.Args[0] + // match: (Equal (FlagConstant [fc])) + // result: (MOVWconst [b2i32(fc.eq())]) + for { + if v_0.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(fc.eq())) + return true + } + // match: (Equal (InvertFlags x)) + // result: (Equal x) + for { + if v_0.Op != OpARMInvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARMEqual) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMGreaterEqual(v *Value) bool { + v_0 := v.Args[0] + // match: (GreaterEqual (FlagConstant [fc])) + // result: (MOVWconst [b2i32(fc.ge())]) + for { + if v_0.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(fc.ge())) + return true + } + // match: (GreaterEqual (InvertFlags x)) + // result: (LessEqual x) + for { + if v_0.Op != OpARMInvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARMLessEqual) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMGreaterEqualU(v *Value) bool { + v_0 := v.Args[0] + // match: (GreaterEqualU (FlagConstant [fc])) + // result: (MOVWconst [b2i32(fc.uge())]) + for { + if v_0.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(fc.uge())) + return true + } + // match: (GreaterEqualU (InvertFlags x)) + // result: (LessEqualU x) + for { + if v_0.Op != OpARMInvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARMLessEqualU) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMGreaterThan(v *Value) bool { + v_0 := v.Args[0] + // match: (GreaterThan (FlagConstant [fc])) + // result: (MOVWconst [b2i32(fc.gt())]) + for { + if v_0.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(fc.gt())) + return true + } + // match: (GreaterThan (InvertFlags x)) + // result: (LessThan x) + for { + if v_0.Op != OpARMInvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARMLessThan) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMGreaterThanU(v *Value) bool { + v_0 := v.Args[0] + // match: (GreaterThanU (FlagConstant [fc])) + // result: (MOVWconst [b2i32(fc.ugt())]) + for { + if v_0.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(fc.ugt())) + return true + } + // match: (GreaterThanU (InvertFlags x)) + // result: (LessThanU x) + for { + if v_0.Op != OpARMInvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARMLessThanU) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMLessEqual(v *Value) bool { + v_0 := v.Args[0] + // match: (LessEqual (FlagConstant [fc])) + // result: (MOVWconst [b2i32(fc.le())]) + for { + if v_0.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(fc.le())) + return true + } + // match: (LessEqual (InvertFlags x)) + // result: (GreaterEqual x) + for { + if v_0.Op != OpARMInvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARMGreaterEqual) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMLessEqualU(v *Value) bool { + v_0 := v.Args[0] + // match: (LessEqualU (FlagConstant [fc])) + // result: (MOVWconst [b2i32(fc.ule())]) + for { + if v_0.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(fc.ule())) + return true + } + // match: (LessEqualU (InvertFlags x)) + // result: (GreaterEqualU x) + for { + if v_0.Op != OpARMInvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARMGreaterEqualU) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMLessThan(v *Value) bool { + v_0 := v.Args[0] + // match: (LessThan (FlagConstant [fc])) + // result: (MOVWconst [b2i32(fc.lt())]) + for { + if v_0.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(fc.lt())) + return true + } + // match: (LessThan (InvertFlags x)) + // result: (GreaterThan x) + for { + if v_0.Op != OpARMInvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARMGreaterThan) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMLessThanU(v *Value) bool { + v_0 := v.Args[0] + // match: (LessThanU (FlagConstant [fc])) + // result: (MOVWconst [b2i32(fc.ult())]) + for { + if v_0.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(fc.ult())) + return true + } + // match: (LessThanU (InvertFlags x)) + // result: (GreaterThanU x) + for { + if v_0.Op != OpARMInvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARMGreaterThanU) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMLoweredPanicBoundsRC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRC [kind] {p} (MOVWconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:int64(c), Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + mem := v_1 + v.reset(OpARMLoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: int64(c), Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueARM_OpARMLoweredPanicBoundsRR(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRR [kind] x (MOVWconst [c]) mem) + // result: (LoweredPanicBoundsRC [kind] x {PanicBoundsC{C:int64(c)}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpARMLoweredPanicBoundsRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(c)}) + v.AddArg2(x, mem) + return true + } + // match: (LoweredPanicBoundsRR [kind] (MOVWconst [c]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:int64(c)}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_1 + mem := v_2 + v.reset(OpARMLoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(c)}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValueARM_OpARMLoweredPanicExtendRC(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicExtendRC [kind] {p} (MOVWconst [hi]) (MOVWconst [lo]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:int64(hi)<<32+int64(uint32(lo)), Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpARMMOVWconst { + break + } + hi := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpARMMOVWconst { + break + } + lo := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpARMLoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: int64(hi)<<32 + int64(uint32(lo)), Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueARM_OpARMLoweredPanicExtendRR(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicExtendRR [kind] hi lo (MOVWconst [c]) mem) + // result: (LoweredPanicExtendRC [kind] hi lo {PanicBoundsC{C:int64(c)}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + hi := v_0 + lo := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + mem := v_3 + v.reset(OpARMLoweredPanicExtendRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(c)}) + v.AddArg3(hi, lo, mem) + return true + } + // match: (LoweredPanicExtendRR [kind] (MOVWconst [hi]) (MOVWconst [lo]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:int64(hi)<<32 + int64(uint32(lo))}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + hi := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpARMMOVWconst { + break + } + lo := auxIntToInt32(v_1.AuxInt) + y := v_2 + mem := v_3 + v.reset(OpARMLoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(hi)<<32 + int64(uint32(lo))}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVBUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBUload [off1] {sym} (ADDconst [off2] ptr) mem) + // result: (MOVBUload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVBUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUload [off1] {sym} (SUBconst [off2] ptr) mem) + // result: (MOVBUload [off1-off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVBUload) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVBUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVBUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVBUreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVBstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpARMMOVBUreg) + v.AddArg(x) + return true + } + // match: (MOVBUload [0] {sym} (ADD ptr idx) mem) + // cond: sym == nil + // result: (MOVBUloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(sym == nil) { + break + } + v.reset(OpARMMOVBUloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVBUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVWconst [int32(read8(sym, int64(off)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(read8(sym, int64(off)))) + return true + } + return false +} +func rewriteValueARM_OpARMMOVBUloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBUloadidx ptr idx (MOVBstoreidx ptr2 idx x _)) + // cond: isSamePtr(ptr, ptr2) + // result: (MOVBUreg x) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARMMOVBstoreidx { + break + } + x := v_2.Args[2] + ptr2 := v_2.Args[0] + if idx != v_2.Args[1] || !(isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpARMMOVBUreg) + v.AddArg(x) + return true + } + // match: (MOVBUloadidx ptr (MOVWconst [c]) mem) + // result: (MOVBUload [c] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpARMMOVBUload) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUloadidx (MOVWconst [c]) ptr mem) + // result: (MOVBUload [c] ptr mem) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + ptr := v_1 + mem := v_2 + v.reset(OpARMMOVBUload) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVBUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBUreg x:(MOVBUload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVBUload { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg (ANDconst [c] x)) + // result: (ANDconst [c&0xff] x) + for { + if v_0.Op != OpARMANDconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c & 0xff) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(MOVBUreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVBUreg { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg (MOVWconst [c])) + // result: (MOVWconst [int32(uint8(c))]) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint8(c))) + return true + } + return false +} +func rewriteValueARM_OpARMMOVBload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBload [off1] {sym} (ADDconst [off2] ptr) mem) + // result: (MOVBload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off1] {sym} (SUBconst [off2] ptr) mem) + // result: (MOVBload [off1-off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVBload) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVBload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVBreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVBstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpARMMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBload [0] {sym} (ADD ptr idx) mem) + // cond: sym == nil + // result: (MOVBloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(sym == nil) { + break + } + v.reset(OpARMMOVBloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVBload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVWconst [int32(int8(read8(sym, int64(off))))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(int8(read8(sym, int64(off))))) + return true + } + return false +} +func rewriteValueARM_OpARMMOVBloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBloadidx ptr idx (MOVBstoreidx ptr2 idx x _)) + // cond: isSamePtr(ptr, ptr2) + // result: (MOVBreg x) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARMMOVBstoreidx { + break + } + x := v_2.Args[2] + ptr2 := v_2.Args[0] + if idx != v_2.Args[1] || !(isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpARMMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBloadidx ptr (MOVWconst [c]) mem) + // result: (MOVBload [c] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpARMMOVBload) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBloadidx (MOVWconst [c]) ptr mem) + // result: (MOVBload [c] ptr mem) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + ptr := v_1 + mem := v_2 + v.reset(OpARMMOVBload) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVBreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBreg x:(MOVBload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVBload { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVBreg (ANDconst [c] x)) + // cond: c & 0x80 == 0 + // result: (ANDconst [c&0x7f] x) + for { + if v_0.Op != OpARMANDconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(c&0x80 == 0) { + break + } + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c & 0x7f) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVBreg { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVBreg (MOVWconst [c])) + // result: (MOVWconst [int32(int8(c))]) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(int8(c))) + return true + } + return false +} +func rewriteValueARM_OpARMMOVBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // result: (MOVBstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off1] {sym} (SUBconst [off2] ptr) val mem) + // result: (MOVBstore [off1-off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVBreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVBUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [0] {sym} (ADD ptr idx) val mem) + // cond: sym == nil + // result: (MOVBstoreidx ptr idx val mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(sym == nil) { + break + } + v.reset(OpARMMOVBstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVBstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstoreidx ptr (MOVWconst [c]) val mem) + // result: (MOVBstore [c] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + val := v_2 + mem := v_3 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstoreidx (MOVWconst [c]) ptr val mem) + // result: (MOVBstore [c] ptr val mem) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDload [off1] {sym} (ADDconst [off2] ptr) mem) + // result: (MOVDload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off1] {sym} (SUBconst [off2] ptr) mem) + // result: (MOVDload [off1-off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVDload) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off] {sym} ptr (MOVDstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVDstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueARM_OpARMMOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // result: (MOVDstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + v.reset(OpARMMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off1] {sym} (SUBconst [off2] ptr) val mem) + // result: (MOVDstore [off1-off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + v.reset(OpARMMOVDstore) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVFload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVFload [off1] {sym} (ADDconst [off2] ptr) mem) + // result: (MOVFload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVFload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVFload [off1] {sym} (SUBconst [off2] ptr) mem) + // result: (MOVFload [off1-off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVFload) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVFload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVFload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVFload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVFload [off] {sym} ptr (MOVFstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVFstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueARM_OpARMMOVFstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVFstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // result: (MOVFstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + v.reset(OpARMMOVFstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVFstore [off1] {sym} (SUBconst [off2] ptr) val mem) + // result: (MOVFstore [off1-off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + v.reset(OpARMMOVFstore) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVFstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVFstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVFstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVHUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHUload [off1] {sym} (ADDconst [off2] ptr) mem) + // result: (MOVHUload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVHUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off1] {sym} (SUBconst [off2] ptr) mem) + // result: (MOVHUload [off1-off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVHUload) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVHUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVHUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVHUreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVHstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpARMMOVHUreg) + v.AddArg(x) + return true + } + // match: (MOVHUload [0] {sym} (ADD ptr idx) mem) + // cond: sym == nil + // result: (MOVHUloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(sym == nil) { + break + } + v.reset(OpARMMOVHUloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVWconst [int32(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueARM_OpARMMOVHUloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHUloadidx ptr idx (MOVHstoreidx ptr2 idx x _)) + // cond: isSamePtr(ptr, ptr2) + // result: (MOVHUreg x) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARMMOVHstoreidx { + break + } + x := v_2.Args[2] + ptr2 := v_2.Args[0] + if idx != v_2.Args[1] || !(isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpARMMOVHUreg) + v.AddArg(x) + return true + } + // match: (MOVHUloadidx ptr (MOVWconst [c]) mem) + // result: (MOVHUload [c] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpARMMOVHUload) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUloadidx (MOVWconst [c]) ptr mem) + // result: (MOVHUload [c] ptr mem) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + ptr := v_1 + mem := v_2 + v.reset(OpARMMOVHUload) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVHUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVHUreg x:(MOVBUload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVBUload { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVHUload { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg (ANDconst [c] x)) + // result: (ANDconst [c&0xffff] x) + for { + if v_0.Op != OpARMANDconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c & 0xffff) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVBUreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVBUreg { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVHUreg { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg (MOVWconst [c])) + // result: (MOVWconst [int32(uint16(c))]) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint16(c))) + return true + } + return false +} +func rewriteValueARM_OpARMMOVHload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHload [off1] {sym} (ADDconst [off2] ptr) mem) + // result: (MOVHload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVHload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off1] {sym} (SUBconst [off2] ptr) mem) + // result: (MOVHload [off1-off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVHload) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVHload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVHload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVHreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVHstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpARMMOVHreg) + v.AddArg(x) + return true + } + // match: (MOVHload [0] {sym} (ADD ptr idx) mem) + // cond: sym == nil + // result: (MOVHloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(sym == nil) { + break + } + v.reset(OpARMMOVHloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVWconst [int32(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueARM_OpARMMOVHloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHloadidx ptr idx (MOVHstoreidx ptr2 idx x _)) + // cond: isSamePtr(ptr, ptr2) + // result: (MOVHreg x) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARMMOVHstoreidx { + break + } + x := v_2.Args[2] + ptr2 := v_2.Args[0] + if idx != v_2.Args[1] || !(isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpARMMOVHreg) + v.AddArg(x) + return true + } + // match: (MOVHloadidx ptr (MOVWconst [c]) mem) + // result: (MOVHload [c] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpARMMOVHload) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHloadidx (MOVWconst [c]) ptr mem) + // result: (MOVHload [c] ptr mem) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + ptr := v_1 + mem := v_2 + v.reset(OpARMMOVHload) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVHreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVHreg x:(MOVBload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVBload { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVBUload { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVHload { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg (ANDconst [c] x)) + // cond: c & 0x8000 == 0 + // result: (ANDconst [c&0x7fff] x) + for { + if v_0.Op != OpARMANDconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(c&0x8000 == 0) { + break + } + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c & 0x7fff) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVBreg { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVBUreg { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpARMMOVHreg { + break + } + v.reset(OpARMMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg (MOVWconst [c])) + // result: (MOVWconst [int32(int16(c))]) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(int16(c))) + return true + } + return false +} +func rewriteValueARM_OpARMMOVHstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // result: (MOVHstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + v.reset(OpARMMOVHstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off1] {sym} (SUBconst [off2] ptr) val mem) + // result: (MOVHstore [off1-off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + v.reset(OpARMMOVHstore) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVHstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVHstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARMMOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARMMOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [0] {sym} (ADD ptr idx) val mem) + // cond: sym == nil + // result: (MOVHstoreidx ptr idx val mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(sym == nil) { + break + } + v.reset(OpARMMOVHstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVHstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstoreidx ptr (MOVWconst [c]) val mem) + // result: (MOVHstore [c] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + val := v_2 + mem := v_3 + v.reset(OpARMMOVHstore) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstoreidx (MOVWconst [c]) ptr val mem) + // result: (MOVHstore [c] ptr val mem) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARMMOVHstore) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWload [off1] {sym} (ADDconst [off2] ptr) mem) + // result: (MOVWload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off1] {sym} (SUBconst [off2] ptr) mem) + // result: (MOVWload [off1-off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + v.reset(OpARMMOVWload) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVWload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARMMOVWstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWload [0] {sym} (ADD ptr idx) mem) + // cond: sym == nil + // result: (MOVWloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(sym == nil) { + break + } + v.reset(OpARMMOVWloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWload [0] {sym} (ADDshiftLL ptr idx [c]) mem) + // cond: sym == nil + // result: (MOVWloadshiftLL ptr idx [c] mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDshiftLL { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(sym == nil) { + break + } + v.reset(OpARMMOVWloadshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWload [0] {sym} (ADDshiftRL ptr idx [c]) mem) + // cond: sym == nil + // result: (MOVWloadshiftRL ptr idx [c] mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDshiftRL { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(sym == nil) { + break + } + v.reset(OpARMMOVWloadshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWload [0] {sym} (ADDshiftRA ptr idx [c]) mem) + // cond: sym == nil + // result: (MOVWloadshiftRA ptr idx [c] mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDshiftRA { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(sym == nil) { + break + } + v.reset(OpARMMOVWloadshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVWconst [int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueARM_OpARMMOVWloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWloadidx ptr idx (MOVWstoreidx ptr2 idx x _)) + // cond: isSamePtr(ptr, ptr2) + // result: x + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARMMOVWstoreidx { + break + } + x := v_2.Args[2] + ptr2 := v_2.Args[0] + if idx != v_2.Args[1] || !(isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWloadidx ptr (MOVWconst [c]) mem) + // result: (MOVWload [c] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpARMMOVWload) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWloadidx (MOVWconst [c]) ptr mem) + // result: (MOVWload [c] ptr mem) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + ptr := v_1 + mem := v_2 + v.reset(OpARMMOVWload) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWloadidx ptr (SLLconst idx [c]) mem) + // result: (MOVWloadshiftLL ptr idx [c] mem) + for { + ptr := v_0 + if v_1.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + idx := v_1.Args[0] + mem := v_2 + v.reset(OpARMMOVWloadshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWloadidx (SLLconst idx [c]) ptr mem) + // result: (MOVWloadshiftLL ptr idx [c] mem) + for { + if v_0.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[0] + ptr := v_1 + mem := v_2 + v.reset(OpARMMOVWloadshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWloadidx ptr (SRLconst idx [c]) mem) + // result: (MOVWloadshiftRL ptr idx [c] mem) + for { + ptr := v_0 + if v_1.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + idx := v_1.Args[0] + mem := v_2 + v.reset(OpARMMOVWloadshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWloadidx (SRLconst idx [c]) ptr mem) + // result: (MOVWloadshiftRL ptr idx [c] mem) + for { + if v_0.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[0] + ptr := v_1 + mem := v_2 + v.reset(OpARMMOVWloadshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWloadidx ptr (SRAconst idx [c]) mem) + // result: (MOVWloadshiftRA ptr idx [c] mem) + for { + ptr := v_0 + if v_1.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + idx := v_1.Args[0] + mem := v_2 + v.reset(OpARMMOVWloadshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWloadidx (SRAconst idx [c]) ptr mem) + // result: (MOVWloadshiftRA ptr idx [c] mem) + for { + if v_0.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[0] + ptr := v_1 + mem := v_2 + v.reset(OpARMMOVWloadshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVWloadshiftLL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWloadshiftLL ptr idx [c] (MOVWstoreshiftLL ptr2 idx [d] x _)) + // cond: c==d && isSamePtr(ptr, ptr2) + // result: x + for { + c := auxIntToInt32(v.AuxInt) + ptr := v_0 + idx := v_1 + if v_2.Op != OpARMMOVWstoreshiftLL { + break + } + d := auxIntToInt32(v_2.AuxInt) + x := v_2.Args[2] + ptr2 := v_2.Args[0] + if idx != v_2.Args[1] || !(c == d && isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWloadshiftLL ptr (MOVWconst [c]) [d] mem) + // result: (MOVWload [int32(uint32(c)<>uint64(d)] ptr mem) + for { + d := auxIntToInt32(v.AuxInt) + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpARMMOVWload) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVWloadshiftRL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWloadshiftRL ptr idx [c] (MOVWstoreshiftRL ptr2 idx [d] x _)) + // cond: c==d && isSamePtr(ptr, ptr2) + // result: x + for { + c := auxIntToInt32(v.AuxInt) + ptr := v_0 + idx := v_1 + if v_2.Op != OpARMMOVWstoreshiftRL { + break + } + d := auxIntToInt32(v_2.AuxInt) + x := v_2.Args[2] + ptr2 := v_2.Args[0] + if idx != v_2.Args[1] || !(c == d && isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWloadshiftRL ptr (MOVWconst [c]) [d] mem) + // result: (MOVWload [int32(uint32(c)>>uint64(d))] ptr mem) + for { + d := auxIntToInt32(v.AuxInt) + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpARMMOVWload) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVWnop(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWnop (MOVWconst [c])) + // result: (MOVWconst [c]) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(c) + return true + } + return false +} +func rewriteValueARM_OpARMMOVWreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWreg x) + // cond: x.Uses == 1 + // result: (MOVWnop x) + for { + x := v_0 + if !(x.Uses == 1) { + break + } + v.reset(OpARMMOVWnop) + v.AddArg(x) + return true + } + // match: (MOVWreg (MOVWconst [c])) + // result: (MOVWconst [c]) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(c) + return true + } + return false +} +func rewriteValueARM_OpARMMOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // result: (MOVWstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + v.reset(OpARMMOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off1] {sym} (SUBconst [off2] ptr) val mem) + // result: (MOVWstore [off1-off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARMSUBconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + v.reset(OpARMMOVWstore) + v.AuxInt = int32ToAuxInt(off1 - off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpARMMOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [0] {sym} (ADD ptr idx) val mem) + // cond: sym == nil + // result: (MOVWstoreidx ptr idx val mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(sym == nil) { + break + } + v.reset(OpARMMOVWstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstore [0] {sym} (ADDshiftLL ptr idx [c]) val mem) + // cond: sym == nil + // result: (MOVWstoreshiftLL ptr idx [c] val mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDshiftLL { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(sym == nil) { + break + } + v.reset(OpARMMOVWstoreshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstore [0] {sym} (ADDshiftRL ptr idx [c]) val mem) + // cond: sym == nil + // result: (MOVWstoreshiftRL ptr idx [c] val mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDshiftRL { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(sym == nil) { + break + } + v.reset(OpARMMOVWstoreshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstore [0] {sym} (ADDshiftRA ptr idx [c]) val mem) + // cond: sym == nil + // result: (MOVWstoreshiftRA ptr idx [c] val mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + if v_0.Op != OpARMADDshiftRA { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(sym == nil) { + break + } + v.reset(OpARMMOVWstoreshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVWstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstoreidx ptr (MOVWconst [c]) val mem) + // result: (MOVWstore [c] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + val := v_2 + mem := v_3 + v.reset(OpARMMOVWstore) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstoreidx (MOVWconst [c]) ptr val mem) + // result: (MOVWstore [c] ptr val mem) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARMMOVWstore) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstoreidx ptr (SLLconst idx [c]) val mem) + // result: (MOVWstoreshiftLL ptr idx [c] val mem) + for { + ptr := v_0 + if v_1.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + idx := v_1.Args[0] + val := v_2 + mem := v_3 + v.reset(OpARMMOVWstoreshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstoreidx (SLLconst idx [c]) ptr val mem) + // result: (MOVWstoreshiftLL ptr idx [c] val mem) + for { + if v_0.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[0] + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARMMOVWstoreshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstoreidx ptr (SRLconst idx [c]) val mem) + // result: (MOVWstoreshiftRL ptr idx [c] val mem) + for { + ptr := v_0 + if v_1.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + idx := v_1.Args[0] + val := v_2 + mem := v_3 + v.reset(OpARMMOVWstoreshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstoreidx (SRLconst idx [c]) ptr val mem) + // result: (MOVWstoreshiftRL ptr idx [c] val mem) + for { + if v_0.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[0] + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARMMOVWstoreshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstoreidx ptr (SRAconst idx [c]) val mem) + // result: (MOVWstoreshiftRA ptr idx [c] val mem) + for { + ptr := v_0 + if v_1.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + idx := v_1.Args[0] + val := v_2 + mem := v_3 + v.reset(OpARMMOVWstoreshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstoreidx (SRAconst idx [c]) ptr val mem) + // result: (MOVWstoreshiftRA ptr idx [c] val mem) + for { + if v_0.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + idx := v_0.Args[0] + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARMMOVWstoreshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVWstoreshiftLL(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstoreshiftLL ptr (MOVWconst [c]) [d] val mem) + // result: (MOVWstore [int32(uint32(c)<>uint64(d)] ptr val mem) + for { + d := auxIntToInt32(v.AuxInt) + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + val := v_2 + mem := v_3 + v.reset(OpARMMOVWstore) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMOVWstoreshiftRL(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstoreshiftRL ptr (MOVWconst [c]) [d] val mem) + // result: (MOVWstore [int32(uint32(c)>>uint64(d))] ptr val mem) + for { + d := auxIntToInt32(v.AuxInt) + ptr := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + val := v_2 + mem := v_3 + v.reset(OpARMMOVWstore) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM_OpARMMUL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MUL x (MOVWconst [c])) + // cond: int32(c) == -1 + // result: (RSBconst [0] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + if !(int32(c) == -1) { + continue + } + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(x) + return true + } + break + } + // match: (MUL _ (MOVWconst [0])) + // result: (MOVWconst [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_1.Op != OpARMMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + continue + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + break + } + // match: (MUL x (MOVWconst [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst || auxIntToInt32(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (MUL x (MOVWconst [c])) + // cond: isPowerOfTwo(c) + // result: (SLLconst [int32(log32(c))] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + if !(isPowerOfTwo(c)) { + continue + } + v.reset(OpARMSLLconst) + v.AuxInt = int32ToAuxInt(int32(log32(c))) + v.AddArg(x) + return true + } + break + } + // match: (MUL x (MOVWconst [c])) + // cond: isPowerOfTwo(c-1) && c >= 3 + // result: (ADDshiftLL x x [int32(log32(c-1))]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + if !(isPowerOfTwo(c-1) && c >= 3) { + continue + } + v.reset(OpARMADDshiftLL) + v.AuxInt = int32ToAuxInt(int32(log32(c - 1))) + v.AddArg2(x, x) + return true + } + break + } + // match: (MUL x (MOVWconst [c])) + // cond: isPowerOfTwo(c+1) && c >= 7 + // result: (RSBshiftLL x x [int32(log32(c+1))]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + if !(isPowerOfTwo(c+1) && c >= 7) { + continue + } + v.reset(OpARMRSBshiftLL) + v.AuxInt = int32ToAuxInt(int32(log32(c + 1))) + v.AddArg2(x, x) + return true + } + break + } + // match: (MUL x (MOVWconst [c])) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (SLLconst [int32(log32(c/3))] (ADDshiftLL x x [1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + continue + } + v.reset(OpARMSLLconst) + v.AuxInt = int32ToAuxInt(int32(log32(c / 3))) + v0 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(1) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + break + } + // match: (MUL x (MOVWconst [c])) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (SLLconst [int32(log32(c/5))] (ADDshiftLL x x [2])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + continue + } + v.reset(OpARMSLLconst) + v.AuxInt = int32ToAuxInt(int32(log32(c / 5))) + v0 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + break + } + // match: (MUL x (MOVWconst [c])) + // cond: c%7 == 0 && isPowerOfTwo(c/7) + // result: (SLLconst [int32(log32(c/7))] (RSBshiftLL x x [3])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + if !(c%7 == 0 && isPowerOfTwo(c/7)) { + continue + } + v.reset(OpARMSLLconst) + v.AuxInt = int32ToAuxInt(int32(log32(c / 7))) + v0 := b.NewValue0(v.Pos, OpARMRSBshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + break + } + // match: (MUL x (MOVWconst [c])) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (SLLconst [int32(log32(c/9))] (ADDshiftLL x x [3])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + continue + } + v.reset(OpARMSLLconst) + v.AuxInt = int32ToAuxInt(int32(log32(c / 9))) + v0 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + break + } + // match: (MUL (MOVWconst [c]) (MOVWconst [d])) + // result: (MOVWconst [c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpARMMOVWconst { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(c * d) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMMULA(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MULA x (MOVWconst [c]) a) + // cond: c == -1 + // result: (SUB a x) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(c == -1) { + break + } + v.reset(OpARMSUB) + v.AddArg2(a, x) + return true + } + // match: (MULA _ (MOVWconst [0]) a) + // result: a + for { + if v_1.Op != OpARMMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + a := v_2 + v.copyOf(a) + return true + } + // match: (MULA x (MOVWconst [1]) a) + // result: (ADD x a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst || auxIntToInt32(v_1.AuxInt) != 1 { + break + } + a := v_2 + v.reset(OpARMADD) + v.AddArg2(x, a) + return true + } + // match: (MULA x (MOVWconst [c]) a) + // cond: isPowerOfTwo(c) + // result: (ADD (SLLconst [int32(log32(c))] x) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c))) + v0.AddArg(x) + v.AddArg2(v0, a) + return true + } + // match: (MULA x (MOVWconst [c]) a) + // cond: isPowerOfTwo(c-1) && c >= 3 + // result: (ADD (ADDshiftLL x x [int32(log32(c-1))]) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(isPowerOfTwo(c-1) && c >= 3) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c - 1))) + v0.AddArg2(x, x) + v.AddArg2(v0, a) + return true + } + // match: (MULA x (MOVWconst [c]) a) + // cond: isPowerOfTwo(c+1) && c >= 7 + // result: (ADD (RSBshiftLL x x [int32(log32(c+1))]) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(isPowerOfTwo(c+1) && c >= 7) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMRSBshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c + 1))) + v0.AddArg2(x, x) + v.AddArg2(v0, a) + return true + } + // match: (MULA x (MOVWconst [c]) a) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (ADD (SLLconst [int32(log32(c/3))] (ADDshiftLL x x [1])) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 3))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(1) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULA x (MOVWconst [c]) a) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (ADD (SLLconst [int32(log32(c/5))] (ADDshiftLL x x [2])) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 5))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULA x (MOVWconst [c]) a) + // cond: c%7 == 0 && isPowerOfTwo(c/7) + // result: (ADD (SLLconst [int32(log32(c/7))] (RSBshiftLL x x [3])) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(c%7 == 0 && isPowerOfTwo(c/7)) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 7))) + v1 := b.NewValue0(v.Pos, OpARMRSBshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULA x (MOVWconst [c]) a) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (ADD (SLLconst [int32(log32(c/9))] (ADDshiftLL x x [3])) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 9))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULA (MOVWconst [c]) x a) + // cond: c == -1 + // result: (SUB a x) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(c == -1) { + break + } + v.reset(OpARMSUB) + v.AddArg2(a, x) + return true + } + // match: (MULA (MOVWconst [0]) _ a) + // result: a + for { + if v_0.Op != OpARMMOVWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + a := v_2 + v.copyOf(a) + return true + } + // match: (MULA (MOVWconst [1]) x a) + // result: (ADD x a) + for { + if v_0.Op != OpARMMOVWconst || auxIntToInt32(v_0.AuxInt) != 1 { + break + } + x := v_1 + a := v_2 + v.reset(OpARMADD) + v.AddArg2(x, a) + return true + } + // match: (MULA (MOVWconst [c]) x a) + // cond: isPowerOfTwo(c) + // result: (ADD (SLLconst [int32(log32(c))] x) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c))) + v0.AddArg(x) + v.AddArg2(v0, a) + return true + } + // match: (MULA (MOVWconst [c]) x a) + // cond: isPowerOfTwo(c-1) && c >= 3 + // result: (ADD (ADDshiftLL x x [int32(log32(c-1))]) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(isPowerOfTwo(c-1) && c >= 3) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c - 1))) + v0.AddArg2(x, x) + v.AddArg2(v0, a) + return true + } + // match: (MULA (MOVWconst [c]) x a) + // cond: isPowerOfTwo(c+1) && c >= 7 + // result: (ADD (RSBshiftLL x x [int32(log32(c+1))]) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(isPowerOfTwo(c+1) && c >= 7) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMRSBshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c + 1))) + v0.AddArg2(x, x) + v.AddArg2(v0, a) + return true + } + // match: (MULA (MOVWconst [c]) x a) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (ADD (SLLconst [int32(log32(c/3))] (ADDshiftLL x x [1])) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 3))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(1) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULA (MOVWconst [c]) x a) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (ADD (SLLconst [int32(log32(c/5))] (ADDshiftLL x x [2])) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 5))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULA (MOVWconst [c]) x a) + // cond: c%7 == 0 && isPowerOfTwo(c/7) + // result: (ADD (SLLconst [int32(log32(c/7))] (RSBshiftLL x x [3])) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(c%7 == 0 && isPowerOfTwo(c/7)) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 7))) + v1 := b.NewValue0(v.Pos, OpARMRSBshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULA (MOVWconst [c]) x a) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (ADD (SLLconst [int32(log32(c/9))] (ADDshiftLL x x [3])) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + break + } + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 9))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULA (MOVWconst [c]) (MOVWconst [d]) a) + // result: (ADDconst [c*d] a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + a := v_2 + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c * d) + v.AddArg(a) + return true + } + return false +} +func rewriteValueARM_OpARMMULD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULD (NEGD x) y) + // cond: buildcfg.GOARM.Version >= 6 + // result: (NMULD x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARMNEGD { + continue + } + x := v_0.Args[0] + y := v_1 + if !(buildcfg.GOARM.Version >= 6) { + continue + } + v.reset(OpARMNMULD) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMMULF(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULF (NEGF x) y) + // cond: buildcfg.GOARM.Version >= 6 + // result: (NMULF x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARMNEGF { + continue + } + x := v_0.Args[0] + y := v_1 + if !(buildcfg.GOARM.Version >= 6) { + continue + } + v.reset(OpARMNMULF) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMMULS(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MULS x (MOVWconst [c]) a) + // cond: c == -1 + // result: (ADD a x) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(c == -1) { + break + } + v.reset(OpARMADD) + v.AddArg2(a, x) + return true + } + // match: (MULS _ (MOVWconst [0]) a) + // result: a + for { + if v_1.Op != OpARMMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + a := v_2 + v.copyOf(a) + return true + } + // match: (MULS x (MOVWconst [1]) a) + // result: (RSB x a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst || auxIntToInt32(v_1.AuxInt) != 1 { + break + } + a := v_2 + v.reset(OpARMRSB) + v.AddArg2(x, a) + return true + } + // match: (MULS x (MOVWconst [c]) a) + // cond: isPowerOfTwo(c) + // result: (RSB (SLLconst [int32(log32(c))] x) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c))) + v0.AddArg(x) + v.AddArg2(v0, a) + return true + } + // match: (MULS x (MOVWconst [c]) a) + // cond: isPowerOfTwo(c-1) && c >= 3 + // result: (RSB (ADDshiftLL x x [int32(log32(c-1))]) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(isPowerOfTwo(c-1) && c >= 3) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c - 1))) + v0.AddArg2(x, x) + v.AddArg2(v0, a) + return true + } + // match: (MULS x (MOVWconst [c]) a) + // cond: isPowerOfTwo(c+1) && c >= 7 + // result: (RSB (RSBshiftLL x x [int32(log32(c+1))]) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(isPowerOfTwo(c+1) && c >= 7) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMRSBshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c + 1))) + v0.AddArg2(x, x) + v.AddArg2(v0, a) + return true + } + // match: (MULS x (MOVWconst [c]) a) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (RSB (SLLconst [int32(log32(c/3))] (ADDshiftLL x x [1])) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 3))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(1) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULS x (MOVWconst [c]) a) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (RSB (SLLconst [int32(log32(c/5))] (ADDshiftLL x x [2])) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 5))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULS x (MOVWconst [c]) a) + // cond: c%7 == 0 && isPowerOfTwo(c/7) + // result: (RSB (SLLconst [int32(log32(c/7))] (RSBshiftLL x x [3])) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(c%7 == 0 && isPowerOfTwo(c/7)) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 7))) + v1 := b.NewValue0(v.Pos, OpARMRSBshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULS x (MOVWconst [c]) a) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (RSB (SLLconst [int32(log32(c/9))] (ADDshiftLL x x [3])) a) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + a := v_2 + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 9))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULS (MOVWconst [c]) x a) + // cond: c == -1 + // result: (ADD a x) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(c == -1) { + break + } + v.reset(OpARMADD) + v.AddArg2(a, x) + return true + } + // match: (MULS (MOVWconst [0]) _ a) + // result: a + for { + if v_0.Op != OpARMMOVWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + a := v_2 + v.copyOf(a) + return true + } + // match: (MULS (MOVWconst [1]) x a) + // result: (RSB x a) + for { + if v_0.Op != OpARMMOVWconst || auxIntToInt32(v_0.AuxInt) != 1 { + break + } + x := v_1 + a := v_2 + v.reset(OpARMRSB) + v.AddArg2(x, a) + return true + } + // match: (MULS (MOVWconst [c]) x a) + // cond: isPowerOfTwo(c) + // result: (RSB (SLLconst [int32(log32(c))] x) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c))) + v0.AddArg(x) + v.AddArg2(v0, a) + return true + } + // match: (MULS (MOVWconst [c]) x a) + // cond: isPowerOfTwo(c-1) && c >= 3 + // result: (RSB (ADDshiftLL x x [int32(log32(c-1))]) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(isPowerOfTwo(c-1) && c >= 3) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c - 1))) + v0.AddArg2(x, x) + v.AddArg2(v0, a) + return true + } + // match: (MULS (MOVWconst [c]) x a) + // cond: isPowerOfTwo(c+1) && c >= 7 + // result: (RSB (RSBshiftLL x x [int32(log32(c+1))]) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(isPowerOfTwo(c+1) && c >= 7) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMRSBshiftLL, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c + 1))) + v0.AddArg2(x, x) + v.AddArg2(v0, a) + return true + } + // match: (MULS (MOVWconst [c]) x a) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (RSB (SLLconst [int32(log32(c/3))] (ADDshiftLL x x [1])) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 3))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(1) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULS (MOVWconst [c]) x a) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (RSB (SLLconst [int32(log32(c/5))] (ADDshiftLL x x [2])) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 5))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULS (MOVWconst [c]) x a) + // cond: c%7 == 0 && isPowerOfTwo(c/7) + // result: (RSB (SLLconst [int32(log32(c/7))] (RSBshiftLL x x [3])) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(c%7 == 0 && isPowerOfTwo(c/7)) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 7))) + v1 := b.NewValue0(v.Pos, OpARMRSBshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULS (MOVWconst [c]) x a) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (RSB (SLLconst [int32(log32(c/9))] (ADDshiftLL x x [3])) a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + a := v_2 + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + break + } + v.reset(OpARMRSB) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(int32(log32(c / 9))) + v1 := b.NewValue0(v.Pos, OpARMADDshiftLL, x.Type) + v1.AuxInt = int32ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg2(v0, a) + return true + } + // match: (MULS (MOVWconst [c]) (MOVWconst [d]) a) + // result: (SUBconst [c*d] a) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + a := v_2 + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(c * d) + v.AddArg(a) + return true + } + return false +} +func rewriteValueARM_OpARMMVN(v *Value) bool { + v_0 := v.Args[0] + // match: (MVN (MOVWconst [c])) + // result: (MOVWconst [^c]) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(^c) + return true + } + // match: (MVN (SLLconst [c] x)) + // result: (MVNshiftLL x [c]) + for { + if v_0.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMMVNshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MVN (SRLconst [c] x)) + // result: (MVNshiftRL x [c]) + for { + if v_0.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMMVNshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MVN (SRAconst [c] x)) + // result: (MVNshiftRA x [c]) + for { + if v_0.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMMVNshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MVN (SLL x y)) + // result: (MVNshiftLLreg x y) + for { + if v_0.Op != OpARMSLL { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARMMVNshiftLLreg) + v.AddArg2(x, y) + return true + } + // match: (MVN (SRL x y)) + // result: (MVNshiftRLreg x y) + for { + if v_0.Op != OpARMSRL { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARMMVNshiftRLreg) + v.AddArg2(x, y) + return true + } + // match: (MVN (SRA x y)) + // result: (MVNshiftRAreg x y) + for { + if v_0.Op != OpARMSRA { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARMMVNshiftRAreg) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMMVNshiftLL(v *Value) bool { + v_0 := v.Args[0] + // match: (MVNshiftLL (MOVWconst [c]) [d]) + // result: (MOVWconst [^(c<>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(c) >> uint64(d)) + return true + } + return false +} +func rewriteValueARM_OpARMMVNshiftRAreg(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MVNshiftRAreg x (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (MVNshiftRA x [c]) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMMVNshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMMVNshiftRL(v *Value) bool { + v_0 := v.Args[0] + // match: (MVNshiftRL (MOVWconst [c]) [d]) + // result: (MOVWconst [^int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(^int32(uint32(c) >> uint64(d))) + return true + } + return false +} +func rewriteValueARM_OpARMMVNshiftRLreg(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MVNshiftRLreg x (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (MVNshiftRL x [c]) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMMVNshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMNEGD(v *Value) bool { + v_0 := v.Args[0] + // match: (NEGD (MULD x y)) + // cond: buildcfg.GOARM.Version >= 6 + // result: (NMULD x y) + for { + if v_0.Op != OpARMMULD { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if !(buildcfg.GOARM.Version >= 6) { + break + } + v.reset(OpARMNMULD) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMNEGF(v *Value) bool { + v_0 := v.Args[0] + // match: (NEGF (MULF x y)) + // cond: buildcfg.GOARM.Version >= 6 + // result: (NMULF x y) + for { + if v_0.Op != OpARMMULF { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if !(buildcfg.GOARM.Version >= 6) { + break + } + v.reset(OpARMNMULF) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMNMULD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NMULD (NEGD x) y) + // result: (MULD x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARMNEGD { + continue + } + x := v_0.Args[0] + y := v_1 + v.reset(OpARMMULD) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMNMULF(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NMULF (NEGF x) y) + // result: (MULF x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARMNEGF { + continue + } + x := v_0.Args[0] + y := v_1 + v.reset(OpARMMULF) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMNotEqual(v *Value) bool { + v_0 := v.Args[0] + // match: (NotEqual (FlagConstant [fc])) + // result: (MOVWconst [b2i32(fc.ne())]) + for { + if v_0.Op != OpARMFlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(fc.ne())) + return true + } + // match: (NotEqual (InvertFlags x)) + // result: (NotEqual x) + for { + if v_0.Op != OpARMInvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARMNotEqual) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (OR x (MOVWconst [c])) + // result: (ORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMORconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (OR x (SLLconst [c] y)) + // result: (ORshiftLL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMORshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (OR x (SRLconst [c] y)) + // result: (ORshiftRL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMORshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (OR x (SRAconst [c] y)) + // result: (ORshiftRA x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRAconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMORshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (OR x (SLL y z)) + // result: (ORshiftLLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMORshiftLLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (OR x (SRL y z)) + // result: (ORshiftRLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMORshiftRLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (OR x (SRA y z)) + // result: (ORshiftRAreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRA { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMORshiftRAreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (OR x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueARM_OpARMORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ORconst [c] _) + // cond: int32(c)==-1 + // result: (MOVWconst [-1]) + for { + c := auxIntToInt32(v.AuxInt) + if !(int32(c) == -1) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(-1) + return true + } + // match: (ORconst [c] (MOVWconst [d])) + // result: (MOVWconst [c|d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(c | d) + return true + } + // match: (ORconst [c] (ORconst [d] x)) + // result: (ORconst [c|d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMORconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMORconst) + v.AuxInt = int32ToAuxInt(c | d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMORshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ORshiftLL (MOVWconst [c]) x [d]) + // result: (ORconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ORshiftLL x (MOVWconst [c]) [d]) + // result: (ORconst x [c< [8] (BFXU [int32(armBFAuxInt(8, 8))] x) x) + // result: (REV16 x) + for { + if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMBFXU || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != int32(armBFAuxInt(8, 8)) { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMREV16) + v.AddArg(x) + return true + } + // match: (ORshiftLL [8] (SRLconst [24] (SLLconst [16] x)) x) + // cond: buildcfg.GOARM.Version>=6 + // result: (REV16 x) + for { + if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMSRLconst || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != 24 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMSLLconst || auxIntToInt32(v_0_0.AuxInt) != 16 { + break + } + x := v_0_0.Args[0] + if x != v_1 || !(buildcfg.GOARM.Version >= 6) { + break + } + v.reset(OpARMREV16) + v.AddArg(x) + return true + } + // match: (ORshiftLL y:(SLLconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt32(v.AuxInt) + y := v_0 + if y.Op != OpARMSLLconst || auxIntToInt32(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueARM_OpARMORshiftLLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ORshiftLLreg (MOVWconst [c]) x y) + // result: (ORconst [c] (SLL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ORshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ORshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMORshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMORshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ORshiftRA (MOVWconst [c]) x [d]) + // result: (ORconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ORshiftRA x (MOVWconst [c]) [d]) + // result: (ORconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMORconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + // match: (ORshiftRA y:(SRAconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt32(v.AuxInt) + y := v_0 + if y.Op != OpARMSRAconst || auxIntToInt32(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueARM_OpARMORshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ORshiftRAreg (MOVWconst [c]) x y) + // result: (ORconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ORshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ORshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMORshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMORshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ORshiftRL (MOVWconst [c]) x [d]) + // result: (ORconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ORshiftRL x (MOVWconst [c]) [d]) + // result: (ORconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMORconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (ORshiftRL y:(SRLconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt32(v.AuxInt) + y := v_0 + if y.Op != OpARMSRLconst || auxIntToInt32(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueARM_OpARMORshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ORshiftRLreg (MOVWconst [c]) x y) + // result: (ORconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (ORshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (ORshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMORshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMRSB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RSB (MOVWconst [c]) x) + // result: (SUBconst [c] x) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (RSB x (MOVWconst [c])) + // result: (RSBconst [c] x) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (RSB x (SLLconst [c] y)) + // result: (RSBshiftLL x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMRSBshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (RSB (SLLconst [c] y) x) + // result: (SUBshiftLL x y [c]) + for { + if v_0.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMSUBshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (RSB x (SRLconst [c] y)) + // result: (RSBshiftRL x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMRSBshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (RSB (SRLconst [c] y) x) + // result: (SUBshiftRL x y [c]) + for { + if v_0.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMSUBshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (RSB x (SRAconst [c] y)) + // result: (RSBshiftRA x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMRSBshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (RSB (SRAconst [c] y) x) + // result: (SUBshiftRA x y [c]) + for { + if v_0.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMSUBshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (RSB x (SLL y z)) + // result: (RSBshiftLLreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSLL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMRSBshiftLLreg) + v.AddArg3(x, y, z) + return true + } + // match: (RSB (SLL y z) x) + // result: (SUBshiftLLreg x y z) + for { + if v_0.Op != OpARMSLL { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMSUBshiftLLreg) + v.AddArg3(x, y, z) + return true + } + // match: (RSB x (SRL y z)) + // result: (RSBshiftRLreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSRL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMRSBshiftRLreg) + v.AddArg3(x, y, z) + return true + } + // match: (RSB (SRL y z) x) + // result: (SUBshiftRLreg x y z) + for { + if v_0.Op != OpARMSRL { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMSUBshiftRLreg) + v.AddArg3(x, y, z) + return true + } + // match: (RSB x (SRA y z)) + // result: (RSBshiftRAreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSRA { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMRSBshiftRAreg) + v.AddArg3(x, y, z) + return true + } + // match: (RSB (SRA y z) x) + // result: (SUBshiftRAreg x y z) + for { + if v_0.Op != OpARMSRA { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMSUBshiftRAreg) + v.AddArg3(x, y, z) + return true + } + // match: (RSB x x) + // result: (MOVWconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (RSB (MUL x y) a) + // cond: buildcfg.GOARM.Version == 7 + // result: (MULS x y a) + for { + if v_0.Op != OpARMMUL { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + a := v_1 + if !(buildcfg.GOARM.Version == 7) { + break + } + v.reset(OpARMMULS) + v.AddArg3(x, y, a) + return true + } + return false +} +func rewriteValueARM_OpARMRSBSshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSBSshiftLL (MOVWconst [c]) x [d]) + // result: (SUBSconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMSUBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (RSBSshiftLL x (MOVWconst [c]) [d]) + // result: (RSBSconst x [c< x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMSUBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (RSBSshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (RSBSshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMRSBSshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMRSBSshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSBSshiftRA (MOVWconst [c]) x [d]) + // result: (SUBSconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMSUBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (RSBSshiftRA x (MOVWconst [c]) [d]) + // result: (RSBSconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMRSBSconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMRSBSshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSBSshiftRAreg (MOVWconst [c]) x y) + // result: (SUBSconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMSUBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (RSBSshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (RSBSshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMRSBSshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMRSBSshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSBSshiftRL (MOVWconst [c]) x [d]) + // result: (SUBSconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMSUBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (RSBSshiftRL x (MOVWconst [c]) [d]) + // result: (RSBSconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMRSBSconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMRSBSshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSBSshiftRLreg (MOVWconst [c]) x y) + // result: (SUBSconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMSUBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (RSBSshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (RSBSshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMRSBSshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMRSBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (RSBconst [c] (MOVWconst [d])) + // result: (MOVWconst [c-d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(c - d) + return true + } + // match: (RSBconst [c] (RSBconst [d] x)) + // result: (ADDconst [c-d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMRSBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(c - d) + v.AddArg(x) + return true + } + // match: (RSBconst [c] (ADDconst [d] x)) + // result: (RSBconst [c-d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMADDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c - d) + v.AddArg(x) + return true + } + // match: (RSBconst [c] (SUBconst [d] x)) + // result: (RSBconst [c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSUBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMRSBshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSBshiftLL (MOVWconst [c]) x [d]) + // result: (SUBconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (RSBshiftLL x (MOVWconst [c]) [d]) + // result: (RSBconst x [c< x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (RSBshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (RSBshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMRSBshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMRSBshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSBshiftRA (MOVWconst [c]) x [d]) + // result: (SUBconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (RSBshiftRA x (MOVWconst [c]) [d]) + // result: (RSBconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + // match: (RSBshiftRA (SRAconst x [c]) x [c]) + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSRAconst || auxIntToInt32(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMRSBshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSBshiftRAreg (MOVWconst [c]) x y) + // result: (SUBconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (RSBshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (RSBshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMRSBshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMRSBshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSBshiftRL (MOVWconst [c]) x [d]) + // result: (SUBconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (RSBshiftRL x (MOVWconst [c]) [d]) + // result: (RSBconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (RSBshiftRL (SRLconst x [c]) x [c]) + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSRLconst || auxIntToInt32(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMRSBshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSBshiftRLreg (MOVWconst [c]) x y) + // result: (SUBconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (RSBshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (RSBshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMRSBshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMRSCconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RSCconst [c] (ADDconst [d] x) flags) + // result: (RSCconst [c-d] x flags) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMADDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + flags := v_1 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(c - d) + v.AddArg2(x, flags) + return true + } + // match: (RSCconst [c] (SUBconst [d] x) flags) + // result: (RSCconst [c+d] x flags) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSUBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + flags := v_1 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMRSCshiftLL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSCshiftLL (MOVWconst [c]) x [d] flags) + // result: (SBCconst [c] (SLLconst x [d]) flags) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg2(v0, flags) + return true + } + // match: (RSCshiftLL x (MOVWconst [c]) [d] flags) + // result: (RSCconst x [c< x y) flags) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + flags := v_3 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg2(v0, flags) + return true + } + // match: (RSCshiftLLreg x y (MOVWconst [c]) flags) + // cond: 0 <= c && c < 32 + // result: (RSCshiftLL x y [c] flags) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + flags := v_3 + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMRSCshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + return false +} +func rewriteValueARM_OpARMRSCshiftRA(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSCshiftRA (MOVWconst [c]) x [d] flags) + // result: (SBCconst [c] (SRAconst x [d]) flags) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg2(v0, flags) + return true + } + // match: (RSCshiftRA x (MOVWconst [c]) [d] flags) + // result: (RSCconst x [c>>uint64(d)] flags) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + flags := v_2 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMRSCshiftRAreg(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSCshiftRAreg (MOVWconst [c]) x y flags) + // result: (SBCconst [c] (SRA x y) flags) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + flags := v_3 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg2(v0, flags) + return true + } + // match: (RSCshiftRAreg x y (MOVWconst [c]) flags) + // cond: 0 <= c && c < 32 + // result: (RSCshiftRA x y [c] flags) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + flags := v_3 + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMRSCshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + return false +} +func rewriteValueARM_OpARMRSCshiftRL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSCshiftRL (MOVWconst [c]) x [d] flags) + // result: (SBCconst [c] (SRLconst x [d]) flags) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg2(v0, flags) + return true + } + // match: (RSCshiftRL x (MOVWconst [c]) [d] flags) + // result: (RSCconst x [int32(uint32(c)>>uint64(d))] flags) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + flags := v_2 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMRSCshiftRLreg(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RSCshiftRLreg (MOVWconst [c]) x y flags) + // result: (SBCconst [c] (SRL x y) flags) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + flags := v_3 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg2(v0, flags) + return true + } + // match: (RSCshiftRLreg x y (MOVWconst [c]) flags) + // cond: 0 <= c && c < 32 + // result: (RSCshiftRL x y [c] flags) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + flags := v_3 + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMRSCshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + return false +} +func rewriteValueARM_OpARMSBC(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SBC (MOVWconst [c]) x flags) + // result: (RSCconst [c] x flags) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, flags) + return true + } + // match: (SBC x (MOVWconst [c]) flags) + // result: (SBCconst [c] x flags) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + flags := v_2 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, flags) + return true + } + // match: (SBC x (SLLconst [c] y) flags) + // result: (SBCshiftLL x y [c] flags) + for { + x := v_0 + if v_1.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMSBCshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + // match: (SBC (SLLconst [c] y) x flags) + // result: (RSCshiftLL x y [c] flags) + for { + if v_0.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + flags := v_2 + v.reset(OpARMRSCshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + // match: (SBC x (SRLconst [c] y) flags) + // result: (SBCshiftRL x y [c] flags) + for { + x := v_0 + if v_1.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMSBCshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + // match: (SBC (SRLconst [c] y) x flags) + // result: (RSCshiftRL x y [c] flags) + for { + if v_0.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + flags := v_2 + v.reset(OpARMRSCshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + // match: (SBC x (SRAconst [c] y) flags) + // result: (SBCshiftRA x y [c] flags) + for { + x := v_0 + if v_1.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMSBCshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + // match: (SBC (SRAconst [c] y) x flags) + // result: (RSCshiftRA x y [c] flags) + for { + if v_0.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + flags := v_2 + v.reset(OpARMRSCshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + // match: (SBC x (SLL y z) flags) + // result: (SBCshiftLLreg x y z flags) + for { + x := v_0 + if v_1.Op != OpARMSLL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMSBCshiftLLreg) + v.AddArg4(x, y, z, flags) + return true + } + // match: (SBC (SLL y z) x flags) + // result: (RSCshiftLLreg x y z flags) + for { + if v_0.Op != OpARMSLL { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + flags := v_2 + v.reset(OpARMRSCshiftLLreg) + v.AddArg4(x, y, z, flags) + return true + } + // match: (SBC x (SRL y z) flags) + // result: (SBCshiftRLreg x y z flags) + for { + x := v_0 + if v_1.Op != OpARMSRL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMSBCshiftRLreg) + v.AddArg4(x, y, z, flags) + return true + } + // match: (SBC (SRL y z) x flags) + // result: (RSCshiftRLreg x y z flags) + for { + if v_0.Op != OpARMSRL { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + flags := v_2 + v.reset(OpARMRSCshiftRLreg) + v.AddArg4(x, y, z, flags) + return true + } + // match: (SBC x (SRA y z) flags) + // result: (SBCshiftRAreg x y z flags) + for { + x := v_0 + if v_1.Op != OpARMSRA { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + flags := v_2 + v.reset(OpARMSBCshiftRAreg) + v.AddArg4(x, y, z, flags) + return true + } + // match: (SBC (SRA y z) x flags) + // result: (RSCshiftRAreg x y z flags) + for { + if v_0.Op != OpARMSRA { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + flags := v_2 + v.reset(OpARMRSCshiftRAreg) + v.AddArg4(x, y, z, flags) + return true + } + return false +} +func rewriteValueARM_OpARMSBCconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SBCconst [c] (ADDconst [d] x) flags) + // result: (SBCconst [c-d] x flags) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMADDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + flags := v_1 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(c - d) + v.AddArg2(x, flags) + return true + } + // match: (SBCconst [c] (SUBconst [d] x) flags) + // result: (SBCconst [c+d] x flags) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSUBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + flags := v_1 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMSBCshiftLL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SBCshiftLL (MOVWconst [c]) x [d] flags) + // result: (RSCconst [c] (SLLconst x [d]) flags) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg2(v0, flags) + return true + } + // match: (SBCshiftLL x (MOVWconst [c]) [d] flags) + // result: (SBCconst x [c< x y) flags) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + flags := v_3 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg2(v0, flags) + return true + } + // match: (SBCshiftLLreg x y (MOVWconst [c]) flags) + // cond: 0 <= c && c < 32 + // result: (SBCshiftLL x y [c] flags) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + flags := v_3 + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSBCshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + return false +} +func rewriteValueARM_OpARMSBCshiftRA(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SBCshiftRA (MOVWconst [c]) x [d] flags) + // result: (RSCconst [c] (SRAconst x [d]) flags) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg2(v0, flags) + return true + } + // match: (SBCshiftRA x (MOVWconst [c]) [d] flags) + // result: (SBCconst x [c>>uint64(d)] flags) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + flags := v_2 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMSBCshiftRAreg(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SBCshiftRAreg (MOVWconst [c]) x y flags) + // result: (RSCconst [c] (SRA x y) flags) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + flags := v_3 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg2(v0, flags) + return true + } + // match: (SBCshiftRAreg x y (MOVWconst [c]) flags) + // cond: 0 <= c && c < 32 + // result: (SBCshiftRA x y [c] flags) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + flags := v_3 + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSBCshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + return false +} +func rewriteValueARM_OpARMSBCshiftRL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SBCshiftRL (MOVWconst [c]) x [d] flags) + // result: (RSCconst [c] (SRLconst x [d]) flags) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + flags := v_2 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg2(v0, flags) + return true + } + // match: (SBCshiftRL x (MOVWconst [c]) [d] flags) + // result: (SBCconst x [int32(uint32(c)>>uint64(d))] flags) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + flags := v_2 + v.reset(OpARMSBCconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg2(x, flags) + return true + } + return false +} +func rewriteValueARM_OpARMSBCshiftRLreg(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SBCshiftRLreg (MOVWconst [c]) x y flags) + // result: (RSCconst [c] (SRL x y) flags) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + flags := v_3 + v.reset(OpARMRSCconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg2(v0, flags) + return true + } + // match: (SBCshiftRLreg x y (MOVWconst [c]) flags) + // cond: 0 <= c && c < 32 + // result: (SBCshiftRL x y [c] flags) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + flags := v_3 + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSBCshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, flags) + return true + } + return false +} +func rewriteValueARM_OpARMSLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLL x (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (SLLconst x [c]) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSLLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMSLLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLLconst [c] (MOVWconst [d])) + // result: (MOVWconst [d<>uint64(c)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(d >> uint64(c)) + return true + } + // match: (SRAconst (SLLconst x [c]) [d]) + // cond: buildcfg.GOARM.Version==7 && uint64(d)>=uint64(c) && uint64(d)<=31 + // result: (BFX [(d-c)|(32-d)<<8] x) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(buildcfg.GOARM.Version == 7 && uint64(d) >= uint64(c) && uint64(d) <= 31) { + break + } + v.reset(OpARMBFX) + v.AuxInt = int32ToAuxInt((d - c) | (32-d)<<8) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMSRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRL x (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (SRLconst x [c]) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSRLconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMSRLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRLconst [c] (MOVWconst [d])) + // result: (MOVWconst [int32(uint32(d)>>uint64(c))]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint32(d) >> uint64(c))) + return true + } + // match: (SRLconst (SLLconst x [c]) [d]) + // cond: buildcfg.GOARM.Version==7 && uint64(d)>=uint64(c) && uint64(d)<=31 + // result: (BFXU [(d-c)|(32-d)<<8] x) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(buildcfg.GOARM.Version == 7 && uint64(d) >= uint64(c) && uint64(d) <= 31) { + break + } + v.reset(OpARMBFXU) + v.AuxInt = int32ToAuxInt((d - c) | (32-d)<<8) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMSRR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRR x (MOVWconst [c])) + // result: (SRRconst x [c&31]) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMSRRconst) + v.AuxInt = int32ToAuxInt(c & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMSUB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUB (MOVWconst [c]) x) + // result: (RSBconst [c] x) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SUB x (MOVWconst [c])) + // result: (SUBconst [c] x) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SUB x (SLLconst [c] y)) + // result: (SUBshiftLL x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMSUBshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUB (SLLconst [c] y) x) + // result: (RSBshiftLL x y [c]) + for { + if v_0.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUB x (SRLconst [c] y)) + // result: (SUBshiftRL x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMSUBshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUB (SRLconst [c] y) x) + // result: (RSBshiftRL x y [c]) + for { + if v_0.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUB x (SRAconst [c] y)) + // result: (SUBshiftRA x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMSUBshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUB (SRAconst [c] y) x) + // result: (RSBshiftRA x y [c]) + for { + if v_0.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUB x (SLL y z)) + // result: (SUBshiftLLreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSLL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMSUBshiftLLreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUB (SLL y z) x) + // result: (RSBshiftLLreg x y z) + for { + if v_0.Op != OpARMSLL { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBshiftLLreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUB x (SRL y z)) + // result: (SUBshiftRLreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSRL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMSUBshiftRLreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUB (SRL y z) x) + // result: (RSBshiftRLreg x y z) + for { + if v_0.Op != OpARMSRL { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBshiftRLreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUB x (SRA y z)) + // result: (SUBshiftRAreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSRA { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMSUBshiftRAreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUB (SRA y z) x) + // result: (RSBshiftRAreg x y z) + for { + if v_0.Op != OpARMSRA { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBshiftRAreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUB x x) + // result: (MOVWconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SUB a (MUL x y)) + // cond: buildcfg.GOARM.Version == 7 + // result: (MULS x y a) + for { + a := v_0 + if v_1.Op != OpARMMUL { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(buildcfg.GOARM.Version == 7) { + break + } + v.reset(OpARMMULS) + v.AddArg3(x, y, a) + return true + } + return false +} +func rewriteValueARM_OpARMSUBD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBD a (MULD x y)) + // cond: a.Uses == 1 && buildcfg.GOARM.Version >= 6 + // result: (MULSD a x y) + for { + a := v_0 + if v_1.Op != OpARMMULD { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Uses == 1 && buildcfg.GOARM.Version >= 6) { + break + } + v.reset(OpARMMULSD) + v.AddArg3(a, x, y) + return true + } + // match: (SUBD a (NMULD x y)) + // cond: a.Uses == 1 && buildcfg.GOARM.Version >= 6 + // result: (MULAD a x y) + for { + a := v_0 + if v_1.Op != OpARMNMULD { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Uses == 1 && buildcfg.GOARM.Version >= 6) { + break + } + v.reset(OpARMMULAD) + v.AddArg3(a, x, y) + return true + } + return false +} +func rewriteValueARM_OpARMSUBF(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBF a (MULF x y)) + // cond: a.Uses == 1 && buildcfg.GOARM.Version >= 6 + // result: (MULSF a x y) + for { + a := v_0 + if v_1.Op != OpARMMULF { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Uses == 1 && buildcfg.GOARM.Version >= 6) { + break + } + v.reset(OpARMMULSF) + v.AddArg3(a, x, y) + return true + } + // match: (SUBF a (NMULF x y)) + // cond: a.Uses == 1 && buildcfg.GOARM.Version >= 6 + // result: (MULAF a x y) + for { + a := v_0 + if v_1.Op != OpARMNMULF { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Uses == 1 && buildcfg.GOARM.Version >= 6) { + break + } + v.reset(OpARMMULAF) + v.AddArg3(a, x, y) + return true + } + return false +} +func rewriteValueARM_OpARMSUBS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBS x (MOVWconst [c])) + // result: (SUBSconst [c] x) + for { + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMSUBSconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SUBS x (SLLconst [c] y)) + // result: (SUBSshiftLL x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMSUBSshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUBS (SLLconst [c] y) x) + // result: (RSBSshiftLL x y [c]) + for { + if v_0.Op != OpARMSLLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBSshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUBS x (SRLconst [c] y)) + // result: (SUBSshiftRL x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMSUBSshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUBS (SRLconst [c] y) x) + // result: (RSBSshiftRL x y [c]) + for { + if v_0.Op != OpARMSRLconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBSshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUBS x (SRAconst [c] y)) + // result: (SUBSshiftRA x y [c]) + for { + x := v_0 + if v_1.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMSUBSshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUBS (SRAconst [c] y) x) + // result: (RSBSshiftRA x y [c]) + for { + if v_0.Op != OpARMSRAconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBSshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + // match: (SUBS x (SLL y z)) + // result: (SUBSshiftLLreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSLL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMSUBSshiftLLreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUBS (SLL y z) x) + // result: (RSBSshiftLLreg x y z) + for { + if v_0.Op != OpARMSLL { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBSshiftLLreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUBS x (SRL y z)) + // result: (SUBSshiftRLreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSRL { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMSUBSshiftRLreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUBS (SRL y z) x) + // result: (RSBSshiftRLreg x y z) + for { + if v_0.Op != OpARMSRL { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBSshiftRLreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUBS x (SRA y z)) + // result: (SUBSshiftRAreg x y z) + for { + x := v_0 + if v_1.Op != OpARMSRA { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMSUBSshiftRAreg) + v.AddArg3(x, y, z) + return true + } + // match: (SUBS (SRA y z) x) + // result: (RSBSshiftRAreg x y z) + for { + if v_0.Op != OpARMSRA { + break + } + z := v_0.Args[1] + y := v_0.Args[0] + x := v_1 + v.reset(OpARMRSBSshiftRAreg) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueARM_OpARMSUBSshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBSshiftLL (MOVWconst [c]) x [d]) + // result: (RSBSconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMRSBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUBSshiftLL x (MOVWconst [c]) [d]) + // result: (SUBSconst x [c< x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMRSBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (SUBSshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (SUBSshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSUBSshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMSUBSshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBSshiftRA (MOVWconst [c]) x [d]) + // result: (RSBSconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMRSBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUBSshiftRA x (MOVWconst [c]) [d]) + // result: (SUBSconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMSUBSconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMSUBSshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBSshiftRAreg (MOVWconst [c]) x y) + // result: (RSBSconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMRSBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (SUBSshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (SUBSshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSUBSshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMSUBSshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBSshiftRL (MOVWconst [c]) x [d]) + // result: (RSBSconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMRSBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUBSshiftRL x (MOVWconst [c]) [d]) + // result: (SUBSconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMSUBSconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMSUBSshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBSshiftRLreg (MOVWconst [c]) x y) + // result: (RSBSconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMRSBSconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (SUBSshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (SUBSshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSUBSshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMSUBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBconst [off1] (MOVWaddr [off2] {sym} ptr)) + // result: (MOVWaddr [off2-off1] {sym} ptr) + for { + off1 := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + v.reset(OpARMMOVWaddr) + v.AuxInt = int32ToAuxInt(off2 - off1) + v.Aux = symToAux(sym) + v.AddArg(ptr) + return true + } + // match: (SUBconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SUBconst [c] x) + // cond: !isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c)) + // result: (ADDconst [-c] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(!isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c))) { + break + } + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } + // match: (SUBconst [c] x) + // cond: buildcfg.GOARM.Version==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff + // result: (ADDconst [-c] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(buildcfg.GOARM.Version == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && uint32(-c) <= 0xffff) { + break + } + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } + // match: (SUBconst [c] (MOVWconst [d])) + // result: (MOVWconst [d-c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(d - c) + return true + } + // match: (SUBconst [c] (SUBconst [d] x)) + // result: (ADDconst [-c-d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSUBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(-c - d) + v.AddArg(x) + return true + } + // match: (SUBconst [c] (ADDconst [d] x)) + // result: (ADDconst [-c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMADDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(-c + d) + v.AddArg(x) + return true + } + // match: (SUBconst [c] (RSBconst [d] x)) + // result: (RSBconst [-c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMRSBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(-c + d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMSUBshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBshiftLL (MOVWconst [c]) x [d]) + // result: (RSBconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUBshiftLL x (MOVWconst [c]) [d]) + // result: (SUBconst x [c< x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (SUBshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (SUBshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSUBshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMSUBshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBshiftRA (MOVWconst [c]) x [d]) + // result: (RSBconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUBshiftRA x (MOVWconst [c]) [d]) + // result: (SUBconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + // match: (SUBshiftRA (SRAconst x [c]) x [c]) + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSRAconst || auxIntToInt32(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMSUBshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBshiftRAreg (MOVWconst [c]) x y) + // result: (RSBconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (SUBshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (SUBshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSUBshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMSUBshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBshiftRL (MOVWconst [c]) x [d]) + // result: (RSBconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUBshiftRL x (MOVWconst [c]) [d]) + // result: (SUBconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMSUBconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (SUBshiftRL (SRLconst x [c]) x [c]) + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSRLconst || auxIntToInt32(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMSUBshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBshiftRLreg (MOVWconst [c]) x y) + // result: (RSBconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (SUBshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (SUBshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMSUBshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMTEQ(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (TEQ x (MOVWconst [c])) + // result: (TEQconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMTEQconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (TEQ x (SLLconst [c] y)) + // result: (TEQshiftLL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMTEQshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (TEQ x (SRLconst [c] y)) + // result: (TEQshiftRL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMTEQshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (TEQ x (SRAconst [c] y)) + // result: (TEQshiftRA x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRAconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMTEQshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (TEQ x (SLL y z)) + // result: (TEQshiftLLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMTEQshiftLLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (TEQ x (SRL y z)) + // result: (TEQshiftRLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMTEQshiftRLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (TEQ x (SRA y z)) + // result: (TEQshiftRAreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRA { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMTEQshiftRAreg) + v.AddArg3(x, y, z) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMTEQconst(v *Value) bool { + v_0 := v.Args[0] + // match: (TEQconst (MOVWconst [x]) [y]) + // result: (FlagConstant [logicFlags32(x^y)]) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMFlagConstant) + v.AuxInt = flagConstantToAuxInt(logicFlags32(x ^ y)) + return true + } + return false +} +func rewriteValueARM_OpARMTEQshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TEQshiftLL (MOVWconst [c]) x [d]) + // result: (TEQconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMTEQconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (TEQshiftLL x (MOVWconst [c]) [d]) + // result: (TEQconst x [c< x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMTEQconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (TEQshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (TEQshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMTEQshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMTEQshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TEQshiftRA (MOVWconst [c]) x [d]) + // result: (TEQconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMTEQconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (TEQshiftRA x (MOVWconst [c]) [d]) + // result: (TEQconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMTEQconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMTEQshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TEQshiftRAreg (MOVWconst [c]) x y) + // result: (TEQconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMTEQconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (TEQshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (TEQshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMTEQshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMTEQshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TEQshiftRL (MOVWconst [c]) x [d]) + // result: (TEQconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMTEQconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (TEQshiftRL x (MOVWconst [c]) [d]) + // result: (TEQconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMTEQconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMTEQshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TEQshiftRLreg (MOVWconst [c]) x y) + // result: (TEQconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMTEQconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (TEQshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (TEQshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMTEQshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMTST(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (TST x (MOVWconst [c])) + // result: (TSTconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMTSTconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (TST x (SLLconst [c] y)) + // result: (TSTshiftLL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMTSTshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (TST x (SRLconst [c] y)) + // result: (TSTshiftRL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMTSTshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (TST x (SRAconst [c] y)) + // result: (TSTshiftRA x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRAconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMTSTshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (TST x (SLL y z)) + // result: (TSTshiftLLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMTSTshiftLLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (TST x (SRL y z)) + // result: (TSTshiftRLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMTSTshiftRLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (TST x (SRA y z)) + // result: (TSTshiftRAreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRA { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMTSTshiftRAreg) + v.AddArg3(x, y, z) + return true + } + break + } + return false +} +func rewriteValueARM_OpARMTSTconst(v *Value) bool { + v_0 := v.Args[0] + // match: (TSTconst (MOVWconst [x]) [y]) + // result: (FlagConstant [logicFlags32(x&y)]) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + x := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMFlagConstant) + v.AuxInt = flagConstantToAuxInt(logicFlags32(x & y)) + return true + } + return false +} +func rewriteValueARM_OpARMTSTshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TSTshiftLL (MOVWconst [c]) x [d]) + // result: (TSTconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMTSTconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (TSTshiftLL x (MOVWconst [c]) [d]) + // result: (TSTconst x [c< x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMTSTconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (TSTshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (TSTshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMTSTshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMTSTshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TSTshiftRA (MOVWconst [c]) x [d]) + // result: (TSTconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMTSTconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (TSTshiftRA x (MOVWconst [c]) [d]) + // result: (TSTconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMTSTconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMTSTshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TSTshiftRAreg (MOVWconst [c]) x y) + // result: (TSTconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMTSTconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (TSTshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (TSTshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMTSTshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMTSTshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TSTshiftRL (MOVWconst [c]) x [d]) + // result: (TSTconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMTSTconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (TSTshiftRL x (MOVWconst [c]) [d]) + // result: (TSTconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMTSTconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMTSTshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TSTshiftRLreg (MOVWconst [c]) x y) + // result: (TSTconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMTSTconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (TSTshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (TSTshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMTSTshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMXOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XOR x (MOVWconst [c])) + // result: (XORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (XOR x (SLLconst [c] y)) + // result: (XORshiftLL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMXORshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (XOR x (SRLconst [c] y)) + // result: (XORshiftRL x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRLconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMXORshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (XOR x (SRAconst [c] y)) + // result: (XORshiftRA x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRAconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMXORshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (XOR x (SRRconst [c] y)) + // result: (XORshiftRR x y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRRconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + v.reset(OpARMXORshiftRR) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + break + } + // match: (XOR x (SLL y z)) + // result: (XORshiftLLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSLL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMXORshiftLLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (XOR x (SRL y z)) + // result: (XORshiftRLreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRL { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMXORshiftRLreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (XOR x (SRA y z)) + // result: (XORshiftRAreg x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARMSRA { + continue + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARMXORshiftRAreg) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (XOR x x) + // result: (MOVWconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMXORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (XORconst [c] (MOVWconst [d])) + // result: (MOVWconst [c^d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(c ^ d) + return true + } + // match: (XORconst [c] (XORconst [d] x)) + // result: (XORconst [c^d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMXORconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(c ^ d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpARMXORshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (XORshiftLL (MOVWconst [c]) x [d]) + // result: (XORconst [c] (SLLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (XORshiftLL x (MOVWconst [c]) [d]) + // result: (XORconst x [c< [8] (BFXU [int32(armBFAuxInt(8, 8))] x) x) + // result: (REV16 x) + for { + if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMBFXU || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != int32(armBFAuxInt(8, 8)) { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMREV16) + v.AddArg(x) + return true + } + // match: (XORshiftLL [8] (SRLconst [24] (SLLconst [16] x)) x) + // cond: buildcfg.GOARM.Version>=6 + // result: (REV16 x) + for { + if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMSRLconst || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != 24 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMSLLconst || auxIntToInt32(v_0_0.AuxInt) != 16 { + break + } + x := v_0_0.Args[0] + if x != v_1 || !(buildcfg.GOARM.Version >= 6) { + break + } + v.reset(OpARMREV16) + v.AddArg(x) + return true + } + // match: (XORshiftLL (SLLconst x [c]) x [c]) + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSLLconst || auxIntToInt32(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMXORshiftLLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (XORshiftLLreg (MOVWconst [c]) x y) + // result: (XORconst [c] (SLL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (XORshiftLLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (XORshiftLL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMXORshiftLL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMXORshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (XORshiftRA (MOVWconst [c]) x [d]) + // result: (XORconst [c] (SRAconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRAconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (XORshiftRA x (MOVWconst [c]) [d]) + // result: (XORconst x [c>>uint64(d)]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + // match: (XORshiftRA (SRAconst x [c]) x [c]) + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSRAconst || auxIntToInt32(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMXORshiftRAreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (XORshiftRAreg (MOVWconst [c]) x y) + // result: (XORconst [c] (SRA x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRA, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (XORshiftRAreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (XORshiftRA x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMXORshiftRA) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMXORshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (XORshiftRL (MOVWconst [c]) x [d]) + // result: (XORconst [c] (SRLconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (XORshiftRL x (MOVWconst [c]) [d]) + // result: (XORconst x [int32(uint32(c)>>uint64(d))]) + for { + d := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (XORshiftRL (SRLconst x [c]) x [c]) + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMSRLconst || auxIntToInt32(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpARMXORshiftRLreg(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (XORshiftRLreg (MOVWconst [c]) x y) + // result: (XORconst [c] (SRL x y)) + for { + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (XORshiftRLreg x y (MOVWconst [c])) + // cond: 0 <= c && c < 32 + // result: (XORshiftRL x y [c]) + for { + x := v_0 + y := v_1 + if v_2.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(0 <= c && c < 32) { + break + } + v.reset(OpARMXORshiftRL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM_OpARMXORshiftRR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (XORshiftRR (MOVWconst [c]) x [d]) + // result: (XORconst [c] (SRRconst x [d])) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARMSRRconst, x.Type) + v0.AuxInt = int32ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (XORshiftRR x (MOVWconst [c]) [d]) + // result: (XORconst x [int32(uint32(c)>>uint64(d)|uint32(c)<>uint64(d) | uint32(c)< x y) + // result: (ADD (SRLconst (SUB x y) [1]) y) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpARMADD) + v0 := b.NewValue0(v.Pos, OpARMSRLconst, t) + v0.AuxInt = int32ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpARMSUB, t) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueARM_OpBitLen16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen16 x) + // result: (BitLen32 (ZeroExt16to32 x)) + for { + x := v_0 + v.reset(OpBitLen32) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpBitLen32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (BitLen32 x) + // result: (RSBconst [32] (CLZ x)) + for { + t := v.Type + x := v_0 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpARMCLZ, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpBitLen8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen8 x) + // result: (BitLen32 (ZeroExt8to32 x)) + for { + x := v_0 + v.reset(OpBitLen32) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpBswap32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Bswap32 x) + // cond: buildcfg.GOARM.Version==5 + // result: (XOR (SRLconst (BICconst (XOR x (SRRconst [16] x)) [0xff0000]) [8]) (SRRconst x [8])) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOARM.Version == 5) { + break + } + v.reset(OpARMXOR) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARMSRLconst, t) + v0.AuxInt = int32ToAuxInt(8) + v1 := b.NewValue0(v.Pos, OpARMBICconst, t) + v1.AuxInt = int32ToAuxInt(0xff0000) + v2 := b.NewValue0(v.Pos, OpARMXOR, t) + v3 := b.NewValue0(v.Pos, OpARMSRRconst, t) + v3.AuxInt = int32ToAuxInt(16) + v3.AddArg(x) + v2.AddArg2(x, v3) + v1.AddArg(v2) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpARMSRRconst, t) + v4.AuxInt = int32ToAuxInt(8) + v4.AddArg(x) + v.AddArg2(v0, v4) + return true + } + // match: (Bswap32 x) + // cond: buildcfg.GOARM.Version>=6 + // result: (REV x) + for { + x := v_0 + if !(buildcfg.GOARM.Version >= 6) { + break + } + v.reset(OpARMREV) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpConst16(v *Value) bool { + // match: (Const16 [val]) + // result: (MOVWconst [int32(val)]) + for { + val := auxIntToInt16(v.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(val)) + return true + } +} +func rewriteValueARM_OpConst32(v *Value) bool { + // match: (Const32 [val]) + // result: (MOVWconst [int32(val)]) + for { + val := auxIntToInt32(v.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(val)) + return true + } +} +func rewriteValueARM_OpConst32F(v *Value) bool { + // match: (Const32F [val]) + // result: (MOVFconst [float64(val)]) + for { + val := auxIntToFloat32(v.AuxInt) + v.reset(OpARMMOVFconst) + v.AuxInt = float64ToAuxInt(float64(val)) + return true + } +} +func rewriteValueARM_OpConst64F(v *Value) bool { + // match: (Const64F [val]) + // result: (MOVDconst [float64(val)]) + for { + val := auxIntToFloat64(v.AuxInt) + v.reset(OpARMMOVDconst) + v.AuxInt = float64ToAuxInt(float64(val)) + return true + } +} +func rewriteValueARM_OpConst8(v *Value) bool { + // match: (Const8 [val]) + // result: (MOVWconst [int32(val)]) + for { + val := auxIntToInt8(v.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(val)) + return true + } +} +func rewriteValueARM_OpConstBool(v *Value) bool { + // match: (ConstBool [t]) + // result: (MOVWconst [b2i32(t)]) + for { + t := auxIntToBool(v.AuxInt) + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(t)) + return true + } +} +func rewriteValueARM_OpConstNil(v *Value) bool { + // match: (ConstNil) + // result: (MOVWconst [0]) + for { + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } +} +func rewriteValueARM_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz16 x) + // cond: buildcfg.GOARM.Version<=6 + // result: (RSBconst [32] (CLZ (SUBconst (AND (ORconst [0x10000] x) (RSBconst [0] (ORconst [0x10000] x))) [1]))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOARM.Version <= 6) { + break + } + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpARMCLZ, t) + v1 := b.NewValue0(v.Pos, OpARMSUBconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpARMAND, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpARMORconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(0x10000) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpARMRSBconst, typ.UInt32) + v4.AuxInt = int32ToAuxInt(0) + v4.AddArg(v3) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Ctz16 x) + // cond: buildcfg.GOARM.Version==7 + // result: (CLZ (RBIT (ORconst [0x10000] x))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOARM.Version == 7) { + break + } + v.reset(OpARMCLZ) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARMRBIT, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpARMORconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0x10000) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM_OpCtz32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Ctz32 x) + // cond: buildcfg.GOARM.Version<=6 + // result: (RSBconst [32] (CLZ (SUBconst (AND x (RSBconst [0] x)) [1]))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOARM.Version <= 6) { + break + } + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpARMCLZ, t) + v1 := b.NewValue0(v.Pos, OpARMSUBconst, t) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpARMAND, t) + v3 := b.NewValue0(v.Pos, OpARMRSBconst, t) + v3.AuxInt = int32ToAuxInt(0) + v3.AddArg(x) + v2.AddArg2(x, v3) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Ctz32 x) + // cond: buildcfg.GOARM.Version==7 + // result: (CLZ (RBIT x)) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOARM.Version == 7) { + break + } + v.reset(OpARMCLZ) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARMRBIT, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz8 x) + // cond: buildcfg.GOARM.Version<=6 + // result: (RSBconst [32] (CLZ (SUBconst (AND (ORconst [0x100] x) (RSBconst [0] (ORconst [0x100] x))) [1]))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOARM.Version <= 6) { + break + } + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpARMCLZ, t) + v1 := b.NewValue0(v.Pos, OpARMSUBconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpARMAND, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpARMORconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(0x100) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpARMRSBconst, typ.UInt32) + v4.AuxInt = int32ToAuxInt(0) + v4.AddArg(v3) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Ctz8 x) + // cond: buildcfg.GOARM.Version==7 + // result: (CLZ (RBIT (ORconst [0x100] x))) + for { + t := v.Type + x := v_0 + if !(buildcfg.GOARM.Version == 7) { + break + } + v.reset(OpARMCLZ) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARMRBIT, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpARMORconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0x100) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 x y) + // result: (Div32 (SignExt16to32 x) (SignExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpDiv32) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u x y) + // result: (Div32u (ZeroExt16to32 x) (ZeroExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpDiv32u) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32 x y) + // result: (SUB (XOR (Select0 (CALLudiv (SUB (XOR x (Signmask x)) (Signmask x)) (SUB (XOR y (Signmask y)) (Signmask y)))) (Signmask (XOR x y))) (Signmask (XOR x y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMSUB) + v0 := b.NewValue0(v.Pos, OpARMXOR, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpARMCALLudiv, types.NewTuple(typ.UInt32, typ.UInt32)) + v3 := b.NewValue0(v.Pos, OpARMSUB, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpARMXOR, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpSignmask, typ.Int32) + v5.AddArg(x) + v4.AddArg2(x, v5) + v3.AddArg2(v4, v5) + v6 := b.NewValue0(v.Pos, OpARMSUB, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpARMXOR, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpSignmask, typ.Int32) + v8.AddArg(y) + v7.AddArg2(y, v8) + v6.AddArg2(v7, v8) + v2.AddArg2(v3, v6) + v1.AddArg(v2) + v9 := b.NewValue0(v.Pos, OpSignmask, typ.Int32) + v10 := b.NewValue0(v.Pos, OpARMXOR, typ.UInt32) + v10.AddArg2(x, y) + v9.AddArg(v10) + v0.AddArg2(v1, v9) + v.AddArg2(v0, v9) + return true + } +} +func rewriteValueARM_OpDiv32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32u x y) + // result: (Select0 (CALLudiv x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v.Type = typ.UInt32 + v0 := b.NewValue0(v.Pos, OpARMCALLudiv, types.NewTuple(typ.UInt32, typ.UInt32)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (Div32 (SignExt8to32 x) (SignExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpDiv32) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (Div32u (ZeroExt8to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpDiv32u) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq16 x y) + // result: (Equal (CMP (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32 x y) + // result: (Equal (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpEq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32F x y) + // result: (Equal (CMPF x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMEqual) + v0 := b.NewValue0(v.Pos, OpARMCMPF, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpEq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64F x y) + // result: (Equal (CMPD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMEqual) + v0 := b.NewValue0(v.Pos, OpARMCMPD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq8 x y) + // result: (Equal (CMP (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqB x y) + // result: (XORconst [1] (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpARMXOR, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (EqPtr x y) + // result: (Equal (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpFMA(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMA x y z) + // result: (FMULAD z x y) + for { + x := v_0 + y := v_1 + z := v_2 + v.reset(OpARMFMULAD) + v.AddArg3(z, x, y) + return true + } +} +func rewriteValueARM_OpIsInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (IsInBounds idx len) + // result: (LessThanU (CMP idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpARMLessThanU) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpIsNonNil(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (IsNonNil ptr) + // result: (NotEqual (CMPconst [0] ptr)) + for { + ptr := v_0 + v.reset(OpARMNotEqual) + v0 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(ptr) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpIsSliceInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (IsSliceInBounds idx len) + // result: (LessEqualU (CMP idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpARMLessEqualU) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16 x y) + // result: (LessEqual (CMP (SignExt16to32 x) (SignExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16U x y) + // result: (LessEqualU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessEqualU) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32 x y) + // result: (LessEqual (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32F x y) + // result: (GreaterEqual (CMPF y x)) + for { + x := v_0 + y := v_1 + v.reset(OpARMGreaterEqual) + v0 := b.NewValue0(v.Pos, OpARMCMPF, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32U x y) + // result: (LessEqualU (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessEqualU) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64F x y) + // result: (GreaterEqual (CMPD y x)) + for { + x := v_0 + y := v_1 + v.reset(OpARMGreaterEqual) + v0 := b.NewValue0(v.Pos, OpARMCMPD, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8 x y) + // result: (LessEqual (CMP (SignExt8to32 x) (SignExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8U x y) + // result: (LessEqualU (CMP (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessEqualU) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16 x y) + // result: (LessThan (CMP (SignExt16to32 x) (SignExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessThan) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16U x y) + // result: (LessThanU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessThanU) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32 x y) + // result: (LessThan (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessThan) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLess32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32F x y) + // result: (GreaterThan (CMPF y x)) + for { + x := v_0 + y := v_1 + v.reset(OpARMGreaterThan) + v0 := b.NewValue0(v.Pos, OpARMCMPF, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32U x y) + // result: (LessThanU (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessThanU) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLess64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64F x y) + // result: (GreaterThan (CMPD y x)) + for { + x := v_0 + y := v_1 + v.reset(OpARMGreaterThan) + v0 := b.NewValue0(v.Pos, OpARMCMPD, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8 x y) + // result: (LessThan (CMP (SignExt8to32 x) (SignExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessThan) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8U x y) + // result: (LessThanU (CMP (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMLessThanU) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Load ptr mem) + // cond: t.IsBoolean() + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsBoolean()) { + break + } + v.reset(OpARMMOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is8BitInt(t) && t.IsSigned()) + // result: (MOVBload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpARMMOVBload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is8BitInt(t) && !t.IsSigned()) + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpARMMOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && t.IsSigned()) + // result: (MOVHload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpARMMOVHload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && !t.IsSigned()) + // result: (MOVHUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpARMMOVHUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is32BitInt(t) || isPtr(t)) + // result: (MOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) || isPtr(t)) { + break + } + v.reset(OpARMMOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (MOVFload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(OpARMMOVFload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (MOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(OpARMMOVDload) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (MOVWaddr {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(OpARMMOVWaddr) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (MOVWaddr {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(OpARMMOVWaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValueARM_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x16 x y) + // result: (CMOVWHSconst (SLL x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(256) + v2.AddArg(v1) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueARM_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x32 x y) + // result: (CMOVWHSconst (SLL x y) (CMPconst [256] y) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v1.AuxInt = int32ToAuxInt(256) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Lsh16x64 x (Const64 [c])) + // cond: uint64(c) < 16 + // result: (SLLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 16) { + break + } + v.reset(OpARMSLLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Lsh16x64 _ (Const64 [c])) + // cond: uint64(c) >= 16 + // result: (Const16 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 16) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x8 x y) + // result: (SLL x (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSLL) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueARM_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x16 x y) + // result: (CMOVWHSconst (SLL x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(256) + v2.AddArg(v1) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueARM_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x32 x y) + // result: (CMOVWHSconst (SLL x y) (CMPconst [256] y) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v1.AuxInt = int32ToAuxInt(256) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Lsh32x64 x (Const64 [c])) + // cond: uint64(c) < 32 + // result: (SLLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 32) { + break + } + v.reset(OpARMSLLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Lsh32x64 _ (Const64 [c])) + // cond: uint64(c) >= 32 + // result: (Const32 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x8 x y) + // result: (SLL x (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSLL) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueARM_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x16 x y) + // result: (CMOVWHSconst (SLL x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(256) + v2.AddArg(v1) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueARM_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x32 x y) + // result: (CMOVWHSconst (SLL x y) (CMPconst [256] y) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSLL, x.Type) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v1.AuxInt = int32ToAuxInt(256) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Lsh8x64 x (Const64 [c])) + // cond: uint64(c) < 8 + // result: (SLLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 8) { + break + } + v.reset(OpARMSLLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Lsh8x64 _ (Const64 [c])) + // cond: uint64(c) >= 8 + // result: (Const8 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 8) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x8 x y) + // result: (SLL x (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSLL) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueARM_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16 x y) + // result: (Mod32 (SignExt16to32 x) (SignExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpMod32) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16u x y) + // result: (Mod32u (ZeroExt16to32 x) (ZeroExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpMod32u) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32 x y) + // result: (SUB (XOR (Select1 (CALLudiv (SUB (XOR x (Signmask x)) (Signmask x)) (SUB (XOR y (Signmask y)) (Signmask y)))) (Signmask x)) (Signmask x)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSUB) + v0 := b.NewValue0(v.Pos, OpARMXOR, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpSelect1, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpARMCALLudiv, types.NewTuple(typ.UInt32, typ.UInt32)) + v3 := b.NewValue0(v.Pos, OpARMSUB, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpARMXOR, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpSignmask, typ.Int32) + v5.AddArg(x) + v4.AddArg2(x, v5) + v3.AddArg2(v4, v5) + v6 := b.NewValue0(v.Pos, OpARMSUB, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpARMXOR, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpSignmask, typ.Int32) + v8.AddArg(y) + v7.AddArg2(y, v8) + v6.AddArg2(v7, v8) + v2.AddArg2(v3, v6) + v1.AddArg(v2) + v0.AddArg2(v1, v5) + v.AddArg2(v0, v5) + return true + } +} +func rewriteValueARM_OpMod32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32u x y) + // result: (Select1 (CALLudiv x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v.Type = typ.UInt32 + v0 := b.NewValue0(v.Pos, OpARMCALLudiv, types.NewTuple(typ.UInt32, typ.UInt32)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (Mod32 (SignExt8to32 x) (SignExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpMod32) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (Mod32u (ZeroExt8to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpMod32u) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (MOVBstore dst (MOVBUload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARMMOVBstore) + v0 := b.NewValue0(v.Pos, OpARMMOVBUload, typ.UInt8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore dst (MOVHUload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpARMMOVHstore) + v0 := b.NewValue0(v.Pos, OpARMMOVHUload, typ.UInt16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (MOVBstore [1] dst (MOVBUload [1] src mem) (MOVBstore dst (MOVBUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpARMMOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARMMOVBUload, typ.UInt8) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [4] {t} dst src mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore dst (MOVWload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpARMMOVWstore) + v0 := b.NewValue0(v.Pos, OpARMMOVWload, typ.UInt32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [4] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [2] dst (MOVHUload [2] src mem) (MOVHstore dst (MOVHUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpARMMOVHstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpARMMOVHUload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARMMOVHstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARMMOVHUload, typ.UInt16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [4] dst src mem) + // result: (MOVBstore [3] dst (MOVBUload [3] src mem) (MOVBstore [2] dst (MOVBUload [2] src mem) (MOVBstore [1] dst (MOVBUload [1] src mem) (MOVBstore dst (MOVBUload src mem) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpARMMOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpARMMOVBUload, typ.UInt8) + v2.AuxInt = int32ToAuxInt(2) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(1) + v4 := b.NewValue0(v.Pos, OpARMMOVBUload, typ.UInt8) + v4.AuxInt = int32ToAuxInt(1) + v4.AddArg2(src, mem) + v5 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v6 := b.NewValue0(v.Pos, OpARMMOVBUload, typ.UInt8) + v6.AddArg2(src, mem) + v5.AddArg3(dst, v6, mem) + v3.AddArg3(dst, v4, v5) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [3] dst src mem) + // result: (MOVBstore [2] dst (MOVBUload [2] src mem) (MOVBstore [1] dst (MOVBUload [1] src mem) (MOVBstore dst (MOVBUload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpARMMOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpARMMOVBUload, typ.UInt8) + v2.AuxInt = int32ToAuxInt(1) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpARMMOVBUload, typ.UInt8) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] {t} dst src mem) + // cond: s%4 == 0 && s > 4 && s <= 512 && t.Alignment()%4 == 0 && logLargeCopy(v, s) + // result: (DUFFCOPY [8 * (128 - s/4)] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(s%4 == 0 && s > 4 && s <= 512 && t.Alignment()%4 == 0 && logLargeCopy(v, s)) { + break + } + v.reset(OpARMDUFFCOPY) + v.AuxInt = int64ToAuxInt(8 * (128 - s/4)) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] {t} dst src mem) + // cond: (s > 512 || t.Alignment()%4 != 0) && logLargeCopy(v, s) + // result: (LoweredMove [t.Alignment()] dst src (ADDconst src [int32(s-moveSize(t.Alignment(), config))]) mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !((s > 512 || t.Alignment()%4 != 0) && logLargeCopy(v, s)) { + break + } + v.reset(OpARMLoweredMove) + v.AuxInt = int64ToAuxInt(t.Alignment()) + v0 := b.NewValue0(v.Pos, OpARMADDconst, src.Type) + v0.AuxInt = int32ToAuxInt(int32(s - moveSize(t.Alignment(), config))) + v0.AddArg(src) + v.AddArg4(dst, src, v0, mem) + return true + } + return false +} +func rewriteValueARM_OpNeg16(v *Value) bool { + v_0 := v.Args[0] + // match: (Neg16 x) + // result: (RSBconst [0] x) + for { + x := v_0 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueARM_OpNeg32(v *Value) bool { + v_0 := v.Args[0] + // match: (Neg32 x) + // result: (RSBconst [0] x) + for { + x := v_0 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueARM_OpNeg8(v *Value) bool { + v_0 := v.Args[0] + // match: (Neg8 x) + // result: (RSBconst [0] x) + for { + x := v_0 + v.reset(OpARMRSBconst) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueARM_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq16 x y) + // result: (NotEqual (CMP (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMNotEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32 x y) + // result: (NotEqual (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMNotEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpNeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32F x y) + // result: (NotEqual (CMPF x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMNotEqual) + v0 := b.NewValue0(v.Pos, OpARMCMPF, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpNeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64F x y) + // result: (NotEqual (CMPD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMNotEqual) + v0 := b.NewValue0(v.Pos, OpARMCMPD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq8 x y) + // result: (NotEqual (CMP (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMNotEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (NeqPtr x y) + // result: (NotEqual (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMNotEqual) + v0 := b.NewValue0(v.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpNot(v *Value) bool { + v_0 := v.Args[0] + // match: (Not x) + // result: (XORconst [1] x) + for { + x := v_0 + v.reset(OpARMXORconst) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueARM_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + // match: (OffPtr [off] ptr:(SP)) + // result: (MOVWaddr [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + if ptr.Op != OpSP { + break + } + v.reset(OpARMMOVWaddr) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } + // match: (OffPtr [off] ptr) + // result: (ADDconst [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + v.reset(OpARMADDconst) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } +} +func rewriteValueARM_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft16 x (MOVWconst [c])) + // result: (Or16 (Lsh16x32 x (MOVWconst [c&15])) (Rsh16Ux32 x (MOVWconst [-c&15]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpLsh16x32, t) + v1 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(c & 15) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh16Ux32, t) + v3 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(-c & 15) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueARM_OpRotateLeft32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RotateLeft32 x y) + // result: (SRR x (RSBconst [0] y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRR) + v0 := b.NewValue0(v.Pos, OpARMRSBconst, y.Type) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueARM_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft8 x (MOVWconst [c])) + // result: (Or8 (Lsh8x32 x (MOVWconst [c&7])) (Rsh8Ux32 x (MOVWconst [-c&7]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpLsh8x32, t) + v1 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(c & 7) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh8Ux32, t) + v3 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(-c & 7) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueARM_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux16 x y) + // result: (CMOVWHSconst (SRL (ZeroExt16to32 x) (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(256) + v3.AddArg(v2) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueARM_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux32 x y) + // result: (CMOVWHSconst (SRL (ZeroExt16to32 x) y) (CMPconst [256] y) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(256) + v2.AddArg(y) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueARM_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 x (Const64 [c])) + // cond: uint64(c) < 16 + // result: (SRLconst (SLLconst x [16]) [int32(c+16)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 16) { + break + } + v.reset(OpARMSRLconst) + v.AuxInt = int32ToAuxInt(int32(c + 16)) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh16Ux64 _ (Const64 [c])) + // cond: uint64(c) >= 16 + // result: (Const16 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 16) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux8 x y) + // result: (SRL (ZeroExt16to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRL) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x16 x y) + // result: (SRAcond (SignExt16to32 x) (ZeroExt16to32 y) (CMPconst [256] (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRAcond) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v2 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(256) + v2.AddArg(v1) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueARM_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x32 x y) + // result: (SRAcond (SignExt16to32 x) y (CMPconst [256] y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRAcond) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v1.AuxInt = int32ToAuxInt(256) + v1.AddArg(y) + v.AddArg3(v0, y, v1) + return true + } +} +func rewriteValueARM_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 x (Const64 [c])) + // cond: uint64(c) < 16 + // result: (SRAconst (SLLconst x [16]) [int32(c+16)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 16) { + break + } + v.reset(OpARMSRAconst) + v.AuxInt = int32ToAuxInt(int32(c + 16)) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh16x64 x (Const64 [c])) + // cond: uint64(c) >= 16 + // result: (SRAconst (SLLconst x [16]) [31]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 16) { + break + } + v.reset(OpARMSRAconst) + v.AuxInt = int32ToAuxInt(31) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x8 x y) + // result: (SRA (SignExt16to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux16 x y) + // result: (CMOVWHSconst (SRL x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(256) + v2.AddArg(v1) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueARM_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux32 x y) + // result: (CMOVWHSconst (SRL x y) (CMPconst [256] y) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v1.AuxInt = int32ToAuxInt(256) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Rsh32Ux64 x (Const64 [c])) + // cond: uint64(c) < 32 + // result: (SRLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 32) { + break + } + v.reset(OpARMSRLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Rsh32Ux64 _ (Const64 [c])) + // cond: uint64(c) >= 32 + // result: (Const32 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux8 x y) + // result: (SRL x (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRL) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueARM_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x16 x y) + // result: (SRAcond x (ZeroExt16to32 y) (CMPconst [256] (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRAcond) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v1.AuxInt = int32ToAuxInt(256) + v1.AddArg(v0) + v.AddArg3(x, v0, v1) + return true + } +} +func rewriteValueARM_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x32 x y) + // result: (SRAcond x y (CMPconst [256] y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRAcond) + v0 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(256) + v0.AddArg(y) + v.AddArg3(x, y, v0) + return true + } +} +func rewriteValueARM_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Rsh32x64 x (Const64 [c])) + // cond: uint64(c) < 32 + // result: (SRAconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 32) { + break + } + v.reset(OpARMSRAconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Rsh32x64 x (Const64 [c])) + // cond: uint64(c) >= 32 + // result: (SRAconst x [31]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpARMSRAconst) + v.AuxInt = int32ToAuxInt(31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x8 x y) + // result: (SRA x (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRA) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueARM_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux16 x y) + // result: (CMOVWHSconst (SRL (ZeroExt8to32 x) (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(256) + v3.AddArg(v2) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueARM_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux32 x y) + // result: (CMOVWHSconst (SRL (ZeroExt8to32 x) y) (CMPconst [256] y) [0]) + for { + x := v_0 + y := v_1 + v.reset(OpARMCMOVWHSconst) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARMSRL, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(256) + v2.AddArg(y) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueARM_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 x (Const64 [c])) + // cond: uint64(c) < 8 + // result: (SRLconst (SLLconst x [24]) [int32(c+24)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 8) { + break + } + v.reset(OpARMSRLconst) + v.AuxInt = int32ToAuxInt(int32(c + 24)) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(24) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh8Ux64 _ (Const64 [c])) + // cond: uint64(c) >= 8 + // result: (Const8 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 8) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux8 x y) + // result: (SRL (ZeroExt8to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRL) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x16 x y) + // result: (SRAcond (SignExt8to32 x) (ZeroExt16to32 y) (CMPconst [256] (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRAcond) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v2 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(256) + v2.AddArg(v1) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueARM_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x32 x y) + // result: (SRAcond (SignExt8to32 x) y (CMPconst [256] y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRAcond) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARMCMPconst, types.TypeFlags) + v1.AuxInt = int32ToAuxInt(256) + v1.AddArg(y) + v.AddArg3(v0, y, v1) + return true + } +} +func rewriteValueARM_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x64 x (Const64 [c])) + // cond: uint64(c) < 8 + // result: (SRAconst (SLLconst x [24]) [int32(c+24)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 8) { + break + } + v.reset(OpARMSRAconst) + v.AuxInt = int32ToAuxInt(int32(c + 24)) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(24) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh8x64 x (Const64 [c])) + // cond: uint64(c) >= 8 + // result: (SRAconst (SLLconst x [24]) [31]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 8) { + break + } + v.reset(OpARMSRAconst) + v.AuxInt = int32ToAuxInt(31) + v0 := b.NewValue0(v.Pos, OpARMSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(24) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x8 x y) + // result: (SRA (SignExt8to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARMSRA) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + // match: (Select0 (CALLudiv x (MOVWconst [1]))) + // result: x + for { + if v_0.Op != OpARMCALLudiv { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpARMMOVWconst || auxIntToInt32(v_0_1.AuxInt) != 1 { + break + } + v.copyOf(x) + return true + } + // match: (Select0 (CALLudiv x (MOVWconst [c]))) + // cond: isPowerOfTwo(c) + // result: (SRLconst [int32(log32(c))] x) + for { + if v_0.Op != OpARMCALLudiv { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARMSRLconst) + v.AuxInt = int32ToAuxInt(int32(log32(c))) + v.AddArg(x) + return true + } + // match: (Select0 (CALLudiv (MOVWconst [c]) (MOVWconst [d]))) + // cond: d != 0 + // result: (MOVWconst [int32(uint32(c)/uint32(d))]) + for { + if v_0.Op != OpARMCALLudiv { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) / uint32(d))) + return true + } + return false +} +func rewriteValueARM_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + // match: (Select1 (CALLudiv _ (MOVWconst [1]))) + // result: (MOVWconst [0]) + for { + if v_0.Op != OpARMCALLudiv { + break + } + _ = v_0.Args[1] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpARMMOVWconst || auxIntToInt32(v_0_1.AuxInt) != 1 { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Select1 (CALLudiv x (MOVWconst [c]))) + // cond: isPowerOfTwo(c) + // result: (ANDconst [c-1] x) + for { + if v_0.Op != OpARMCALLudiv { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARMANDconst) + v.AuxInt = int32ToAuxInt(c - 1) + v.AddArg(x) + return true + } + // match: (Select1 (CALLudiv (MOVWconst [c]) (MOVWconst [d]))) + // cond: d != 0 + // result: (MOVWconst [int32(uint32(c)%uint32(d))]) + for { + if v_0.Op != OpARMCALLudiv { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMMOVWconst { + break + } + c := auxIntToInt32(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpARMMOVWconst { + break + } + d := auxIntToInt32(v_0_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpARMMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) % uint32(d))) + return true + } + return false +} +func rewriteValueARM_OpSignmask(v *Value) bool { + v_0 := v.Args[0] + // match: (Signmask x) + // result: (SRAconst x [31]) + for { + x := v_0 + v.reset(OpARMSRAconst) + v.AuxInt = int32ToAuxInt(31) + v.AddArg(x) + return true + } +} +func rewriteValueARM_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Slicemask x) + // result: (SRAconst (RSBconst [0] x) [31]) + for { + t := v.Type + x := v_0 + v.reset(OpARMSRAconst) + v.AuxInt = int32ToAuxInt(31) + v0 := b.NewValue0(v.Pos, OpARMRSBconst, t) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (MOVBstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(OpARMMOVBstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (MOVHstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(OpARMMOVHstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && !t.IsFloat() + // result: (MOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && !t.IsFloat()) { + break + } + v.reset(OpARMMOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && t.IsFloat() + // result: (MOVFstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && t.IsFloat()) { + break + } + v.reset(OpARMMOVFstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && t.IsFloat() + // result: (MOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && t.IsFloat()) { + break + } + v.reset(OpARMMOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] ptr mem) + // result: (MOVBstore ptr (MOVWconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARMMOVBstore) + v0 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [2] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore ptr (MOVWconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpARMMOVHstore) + v0 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [2] ptr mem) + // result: (MOVBstore [1] ptr (MOVWconst [0]) (MOVBstore [0] ptr (MOVWconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [4] {t} ptr mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore ptr (MOVWconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpARMMOVWstore) + v0 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [4] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [2] ptr (MOVWconst [0]) (MOVHstore [0] ptr (MOVWconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpARMMOVHstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARMMOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [4] ptr mem) + // result: (MOVBstore [3] ptr (MOVWconst [0]) (MOVBstore [2] ptr (MOVWconst [0]) (MOVBstore [1] ptr (MOVWconst [0]) (MOVBstore [0] ptr (MOVWconst [0]) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(1) + v3 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(0) + v3.AddArg3(ptr, v0, mem) + v2.AddArg3(ptr, v0, v3) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [3] ptr mem) + // result: (MOVBstore [2] ptr (MOVWconst [0]) (MOVBstore [1] ptr (MOVWconst [0]) (MOVBstore [0] ptr (MOVWconst [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARMMOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpARMMOVBstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(0) + v2.AddArg3(ptr, v0, mem) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [s] {t} ptr mem) + // cond: s%4 == 0 && s > 4 && s <= 512 && t.Alignment()%4 == 0 + // result: (DUFFZERO [4 * (128 - s/4)] ptr (MOVWconst [0]) mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(s%4 == 0 && s > 4 && s <= 512 && t.Alignment()%4 == 0) { + break + } + v.reset(OpARMDUFFZERO) + v.AuxInt = int64ToAuxInt(4 * (128 - s/4)) + v0 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [s] {t} ptr mem) + // cond: s > 512 || t.Alignment()%4 != 0 + // result: (LoweredZero [t.Alignment()] ptr (ADDconst ptr [int32(s-moveSize(t.Alignment(), config))]) (MOVWconst [0]) mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(s > 512 || t.Alignment()%4 != 0) { + break + } + v.reset(OpARMLoweredZero) + v.AuxInt = int64ToAuxInt(t.Alignment()) + v0 := b.NewValue0(v.Pos, OpARMADDconst, ptr.Type) + v0.AuxInt = int32ToAuxInt(int32(s - moveSize(t.Alignment(), config))) + v0.AddArg(ptr) + v1 := b.NewValue0(v.Pos, OpARMMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0) + v.AddArg4(ptr, v0, v1, mem) + return true + } + return false +} +func rewriteValueARM_OpZeromask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Zeromask x) + // result: (SRAconst (RSBshiftRL x x [1]) [31]) + for { + x := v_0 + v.reset(OpARMSRAconst) + v.AuxInt = int32ToAuxInt(31) + v0 := b.NewValue0(v.Pos, OpARMRSBshiftRL, typ.Int32) + v0.AuxInt = int32ToAuxInt(1) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } +} +func rewriteBlockARM(b *Block) bool { + switch b.Kind { + case BlockARMEQ: + // match: (EQ (FlagConstant [fc]) yes no) + // cond: fc.eq() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.eq()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (EQ (FlagConstant [fc]) yes no) + // cond: !fc.eq() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.eq()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (InvertFlags cmp) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMEQ, cmp) + return true + } + // match: (EQ (CMP x (RSBconst [0] y))) + // result: (EQ (CMN x y)) + for b.Controls[0].Op == OpARMCMP { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpARMRSBconst || auxIntToInt32(v_0_1.AuxInt) != 0 { + break + } + y := v_0_1.Args[0] + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMN x (RSBconst [0] y))) + // result: (EQ (CMP x y)) + for b.Controls[0].Op == OpARMCMN { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpARMRSBconst || auxIntToInt32(v_0_1.AuxInt) != 0 { + continue + } + y := v_0_1.Args[0] + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + break + } + // match: (EQ (CMPconst [0] l:(SUB x y)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMP x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUB { + break + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(MULS x y a)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULS { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(SUBconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMPconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (CMPshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (CMPshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (CMPshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMPshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMPshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMPshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ADD x y)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMN x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADD { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + break + } + // match: (EQ (CMPconst [0] l:(MULA x y a)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULA { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ADDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMNconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (CMNshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (CMNshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (CMNshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMNshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMNshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (CMNshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(AND x y)) yes no) + // cond: l.Uses==1 + // result: (EQ (TST x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMAND { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + break + } + // match: (EQ (CMPconst [0] l:(ANDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (EQ (TSTconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (TSTshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (TSTshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (TSTshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (TSTshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (TSTshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (TSTshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(XOR x y)) yes no) + // cond: l.Uses==1 + // result: (EQ (TEQ x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXOR { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + break + } + // match: (EQ (CMPconst [0] l:(XORconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (EQ (TEQconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(XORshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (TEQshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(XORshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (TEQshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(XORshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (EQ (TEQshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (TEQshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (TEQshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + // match: (EQ (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (EQ (TEQshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMEQ, v0) + return true + } + case BlockARMGE: + // match: (GE (FlagConstant [fc]) yes no) + // cond: fc.ge() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ge()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GE (FlagConstant [fc]) yes no) + // cond: !fc.ge() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ge()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GE (InvertFlags cmp) yes no) + // result: (LE cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMLE, cmp) + return true + } + // match: (GE (CMPconst [0] l:(SUB x y)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMP x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUB { + break + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(MULS x y a)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULS { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(SUBconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMPconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMPshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMPshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMPshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMPshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMPshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMPshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ADD x y)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMN x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADD { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + break + } + // match: (GE (CMPconst [0] l:(MULA x y a)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULA { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ADDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMNconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMNshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMNshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMNshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMNshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMNshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (CMNshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(AND x y)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TST x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMAND { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + break + } + // match: (GE (CMPconst [0] l:(ANDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TSTconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TSTshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TSTshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TSTshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TSTshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TSTshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TSTshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(XOR x y)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TEQ x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXOR { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + break + } + // match: (GE (CMPconst [0] l:(XORconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TEQconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TEQshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TEQshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TEQshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TEQshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TEQshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + // match: (GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GEnoov (TEQshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGEnoov, v0) + return true + } + case BlockARMGEnoov: + // match: (GEnoov (FlagConstant [fc]) yes no) + // cond: fc.geNoov() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.geNoov()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GEnoov (FlagConstant [fc]) yes no) + // cond: !fc.geNoov() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.geNoov()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GEnoov (InvertFlags cmp) yes no) + // result: (LEnoov cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMLEnoov, cmp) + return true + } + case BlockARMGT: + // match: (GT (FlagConstant [fc]) yes no) + // cond: fc.gt() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.gt()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GT (FlagConstant [fc]) yes no) + // cond: !fc.gt() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.gt()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GT (InvertFlags cmp) yes no) + // result: (LT cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMLT, cmp) + return true + } + // match: (GT (CMPconst [0] l:(SUB x y)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMP x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUB { + break + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(MULS x y a)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULS { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(SUBconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMPconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMPshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMPshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMPshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMPshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMPshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMPshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ADD x y)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMN x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADD { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + break + } + // match: (GT (CMPconst [0] l:(ADDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMNconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMNshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMNshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMNshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMNshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMNshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMNshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(MULA x y a)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULA { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(AND x y)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TST x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMAND { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + break + } + // match: (GT (CMPconst [0] l:(ANDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TSTconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TSTshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TSTshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TSTshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TSTshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TSTshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TSTshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(XOR x y)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TEQ x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXOR { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + break + } + // match: (GT (CMPconst [0] l:(XORconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TEQconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TEQshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TEQshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TEQshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TEQshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TEQshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + // match: (GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (GTnoov (TEQshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMGTnoov, v0) + return true + } + case BlockARMGTnoov: + // match: (GTnoov (FlagConstant [fc]) yes no) + // cond: fc.gtNoov() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.gtNoov()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GTnoov (FlagConstant [fc]) yes no) + // cond: !fc.gtNoov() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.gtNoov()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GTnoov (InvertFlags cmp) yes no) + // result: (LTnoov cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMLTnoov, cmp) + return true + } + case BlockIf: + // match: (If (Equal cc) yes no) + // result: (EQ cc yes no) + for b.Controls[0].Op == OpARMEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARMEQ, cc) + return true + } + // match: (If (NotEqual cc) yes no) + // result: (NE cc yes no) + for b.Controls[0].Op == OpARMNotEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARMNE, cc) + return true + } + // match: (If (LessThan cc) yes no) + // result: (LT cc yes no) + for b.Controls[0].Op == OpARMLessThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARMLT, cc) + return true + } + // match: (If (LessThanU cc) yes no) + // result: (ULT cc yes no) + for b.Controls[0].Op == OpARMLessThanU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARMULT, cc) + return true + } + // match: (If (LessEqual cc) yes no) + // result: (LE cc yes no) + for b.Controls[0].Op == OpARMLessEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARMLE, cc) + return true + } + // match: (If (LessEqualU cc) yes no) + // result: (ULE cc yes no) + for b.Controls[0].Op == OpARMLessEqualU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARMULE, cc) + return true + } + // match: (If (GreaterThan cc) yes no) + // result: (GT cc yes no) + for b.Controls[0].Op == OpARMGreaterThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARMGT, cc) + return true + } + // match: (If (GreaterThanU cc) yes no) + // result: (UGT cc yes no) + for b.Controls[0].Op == OpARMGreaterThanU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARMUGT, cc) + return true + } + // match: (If (GreaterEqual cc) yes no) + // result: (GE cc yes no) + for b.Controls[0].Op == OpARMGreaterEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARMGE, cc) + return true + } + // match: (If (GreaterEqualU cc) yes no) + // result: (UGE cc yes no) + for b.Controls[0].Op == OpARMGreaterEqualU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARMUGE, cc) + return true + } + // match: (If cond yes no) + // result: (NE (CMPconst [0] cond) yes no) + for { + cond := b.Controls[0] + v0 := b.NewValue0(cond.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(cond) + b.resetWithControl(BlockARMNE, v0) + return true + } + case BlockARMLE: + // match: (LE (FlagConstant [fc]) yes no) + // cond: fc.le() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.le()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LE (FlagConstant [fc]) yes no) + // cond: !fc.le() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.le()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LE (InvertFlags cmp) yes no) + // result: (GE cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMGE, cmp) + return true + } + // match: (LE (CMPconst [0] l:(SUB x y)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMP x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUB { + break + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(MULS x y a)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULS { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(SUBconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMPconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMPshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMPshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMPshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMPshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMPshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMPshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ADD x y)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMN x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADD { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + break + } + // match: (LE (CMPconst [0] l:(MULA x y a)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULA { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ADDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMNconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMNshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMNshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMNshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMNshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMNshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (CMNshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(AND x y)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TST x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMAND { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + break + } + // match: (LE (CMPconst [0] l:(ANDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TSTconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TSTshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TSTshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TSTshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TSTshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TSTshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TSTshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(XOR x y)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TEQ x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXOR { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + break + } + // match: (LE (CMPconst [0] l:(XORconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TEQconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TEQshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TEQshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TEQshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TEQshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TEQshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + // match: (LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LEnoov (TEQshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLEnoov, v0) + return true + } + case BlockARMLEnoov: + // match: (LEnoov (FlagConstant [fc]) yes no) + // cond: fc.leNoov() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.leNoov()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LEnoov (FlagConstant [fc]) yes no) + // cond: !fc.leNoov() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.leNoov()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LEnoov (InvertFlags cmp) yes no) + // result: (GEnoov cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMGEnoov, cmp) + return true + } + case BlockARMLT: + // match: (LT (FlagConstant [fc]) yes no) + // cond: fc.lt() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.lt()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LT (FlagConstant [fc]) yes no) + // cond: !fc.lt() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.lt()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LT (InvertFlags cmp) yes no) + // result: (GT cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMGT, cmp) + return true + } + // match: (LT (CMPconst [0] l:(SUB x y)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMP x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUB { + break + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(MULS x y a)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULS { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(SUBconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMPconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMPshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMPshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMPshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMPshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMPshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMPshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ADD x y)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMN x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADD { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + break + } + // match: (LT (CMPconst [0] l:(MULA x y a)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULA { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ADDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMNconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMNshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMNshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMNshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMNshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMNshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (CMNshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(AND x y)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TST x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMAND { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + break + } + // match: (LT (CMPconst [0] l:(ANDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TSTconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TSTshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TSTshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TSTshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TSTshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TSTshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TSTshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(XOR x y)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TEQ x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXOR { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + break + } + // match: (LT (CMPconst [0] l:(XORconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TEQconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TEQshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TEQshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TEQshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TEQshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TEQshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + // match: (LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (LTnoov (TEQshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMLTnoov, v0) + return true + } + case BlockARMLTnoov: + // match: (LTnoov (FlagConstant [fc]) yes no) + // cond: fc.ltNoov() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ltNoov()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LTnoov (FlagConstant [fc]) yes no) + // cond: !fc.ltNoov() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ltNoov()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LTnoov (InvertFlags cmp) yes no) + // result: (GTnoov cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMGTnoov, cmp) + return true + } + case BlockARMNE: + // match: (NE (CMPconst [0] (Equal cc)) yes no) + // result: (EQ cc yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMEqual { + break + } + cc := v_0_0.Args[0] + b.resetWithControl(BlockARMEQ, cc) + return true + } + // match: (NE (CMPconst [0] (NotEqual cc)) yes no) + // result: (NE cc yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMNotEqual { + break + } + cc := v_0_0.Args[0] + b.resetWithControl(BlockARMNE, cc) + return true + } + // match: (NE (CMPconst [0] (LessThan cc)) yes no) + // result: (LT cc yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMLessThan { + break + } + cc := v_0_0.Args[0] + b.resetWithControl(BlockARMLT, cc) + return true + } + // match: (NE (CMPconst [0] (LessThanU cc)) yes no) + // result: (ULT cc yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMLessThanU { + break + } + cc := v_0_0.Args[0] + b.resetWithControl(BlockARMULT, cc) + return true + } + // match: (NE (CMPconst [0] (LessEqual cc)) yes no) + // result: (LE cc yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMLessEqual { + break + } + cc := v_0_0.Args[0] + b.resetWithControl(BlockARMLE, cc) + return true + } + // match: (NE (CMPconst [0] (LessEqualU cc)) yes no) + // result: (ULE cc yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMLessEqualU { + break + } + cc := v_0_0.Args[0] + b.resetWithControl(BlockARMULE, cc) + return true + } + // match: (NE (CMPconst [0] (GreaterThan cc)) yes no) + // result: (GT cc yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMGreaterThan { + break + } + cc := v_0_0.Args[0] + b.resetWithControl(BlockARMGT, cc) + return true + } + // match: (NE (CMPconst [0] (GreaterThanU cc)) yes no) + // result: (UGT cc yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMGreaterThanU { + break + } + cc := v_0_0.Args[0] + b.resetWithControl(BlockARMUGT, cc) + return true + } + // match: (NE (CMPconst [0] (GreaterEqual cc)) yes no) + // result: (GE cc yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMGreaterEqual { + break + } + cc := v_0_0.Args[0] + b.resetWithControl(BlockARMGE, cc) + return true + } + // match: (NE (CMPconst [0] (GreaterEqualU cc)) yes no) + // result: (UGE cc yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARMGreaterEqualU { + break + } + cc := v_0_0.Args[0] + b.resetWithControl(BlockARMUGE, cc) + return true + } + // match: (NE (FlagConstant [fc]) yes no) + // cond: fc.ne() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ne()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (NE (FlagConstant [fc]) yes no) + // cond: !fc.ne() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ne()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (NE (InvertFlags cmp) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMNE, cmp) + return true + } + // match: (NE (CMP x (RSBconst [0] y))) + // result: (NE (CMN x y)) + for b.Controls[0].Op == OpARMCMP { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpARMRSBconst || auxIntToInt32(v_0_1.AuxInt) != 0 { + break + } + y := v_0_1.Args[0] + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMN x (RSBconst [0] y))) + // result: (NE (CMP x y)) + for b.Controls[0].Op == OpARMCMN { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpARMRSBconst || auxIntToInt32(v_0_1.AuxInt) != 0 { + continue + } + y := v_0_1.Args[0] + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + break + } + // match: (NE (CMPconst [0] l:(SUB x y)) yes no) + // cond: l.Uses==1 + // result: (NE (CMP x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUB { + break + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(MULS x y a)) yes no) + // cond: l.Uses==1 + // result: (NE (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULS { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(SUBconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (NE (CMPconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (CMPshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (CMPshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (CMPshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (CMPshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (CMPshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (CMPshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMSUBshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMPshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ADD x y)) yes no) + // cond: l.Uses==1 + // result: (NE (CMN x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADD { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + break + } + // match: (NE (CMPconst [0] l:(MULA x y a)) yes no) + // cond: l.Uses==1 + // result: (NE (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMMULA { + break + } + a := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ADDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (NE (CMNconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (CMNshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (CMNshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (CMNshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (CMNshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (CMNshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (CMNshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMADDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMCMNshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(AND x y)) yes no) + // cond: l.Uses==1 + // result: (NE (TST x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMAND { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + break + } + // match: (NE (CMPconst [0] l:(ANDconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (NE (TSTconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (TSTshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (TSTshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (TSTshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (TSTshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (TSTshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (TSTshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMANDshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(XOR x y)) yes no) + // cond: l.Uses==1 + // result: (NE (TEQ x y) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXOR { + break + } + _ = l.Args[1] + l_0 := l.Args[0] + l_1 := l.Args[1] + for _i0 := 0; _i0 <= 1; _i0, l_0, l_1 = _i0+1, l_1, l_0 { + x := l_0 + y := l_1 + if !(l.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + break + } + // match: (NE (CMPconst [0] l:(XORconst [c] x)) yes no) + // cond: l.Uses==1 + // result: (NE (TEQconst [c] x) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORconst { + break + } + c := auxIntToInt32(l.AuxInt) + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg(x) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (TEQshiftLL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (TEQshiftRL x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRL { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) + // cond: l.Uses==1 + // result: (NE (TEQshiftRA x y [c]) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRA { + break + } + c := auxIntToInt32(l.AuxInt) + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, y) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (TEQshiftLLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftLLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (TEQshiftRLreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRLreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + // match: (NE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) + // cond: l.Uses==1 + // result: (NE (TEQshiftRAreg x y z) yes no) + for b.Controls[0].Op == OpARMCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + l := v_0.Args[0] + if l.Op != OpARMXORshiftRAreg { + break + } + z := l.Args[2] + x := l.Args[0] + y := l.Args[1] + if !(l.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags) + v0.AddArg3(x, y, z) + b.resetWithControl(BlockARMNE, v0) + return true + } + case BlockARMUGE: + // match: (UGE (FlagConstant [fc]) yes no) + // cond: fc.uge() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.uge()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (UGE (FlagConstant [fc]) yes no) + // cond: !fc.uge() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.uge()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGE (InvertFlags cmp) yes no) + // result: (ULE cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMULE, cmp) + return true + } + case BlockARMUGT: + // match: (UGT (FlagConstant [fc]) yes no) + // cond: fc.ugt() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ugt()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (UGT (FlagConstant [fc]) yes no) + // cond: !fc.ugt() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ugt()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGT (InvertFlags cmp) yes no) + // result: (ULT cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMULT, cmp) + return true + } + case BlockARMULE: + // match: (ULE (FlagConstant [fc]) yes no) + // cond: fc.ule() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ule()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (ULE (FlagConstant [fc]) yes no) + // cond: !fc.ule() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ule()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULE (InvertFlags cmp) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMUGE, cmp) + return true + } + case BlockARMULT: + // match: (ULT (FlagConstant [fc]) yes no) + // cond: fc.ult() + // result: (First yes no) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ult()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (ULT (FlagConstant [fc]) yes no) + // cond: !fc.ult() + // result: (First no yes) + for b.Controls[0].Op == OpARMFlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ult()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULT (InvertFlags cmp) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == OpARMInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARMUGT, cmp) + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteARM64.go b/go/src/cmd/compile/internal/ssa/rewriteARM64.go new file mode 100644 index 0000000000000000000000000000000000000000..25a1c9c0fc1e8d190d9d2e451e85a06606996995 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteARM64.go @@ -0,0 +1,25692 @@ +// Code generated from _gen/ARM64.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "cmd/compile/internal/types" + +func rewriteValueARM64(v *Value) bool { + switch v.Op { + case OpARM64ADCSflags: + return rewriteValueARM64_OpARM64ADCSflags(v) + case OpARM64ADD: + return rewriteValueARM64_OpARM64ADD(v) + case OpARM64ADDSflags: + return rewriteValueARM64_OpARM64ADDSflags(v) + case OpARM64ADDconst: + return rewriteValueARM64_OpARM64ADDconst(v) + case OpARM64ADDshiftLL: + return rewriteValueARM64_OpARM64ADDshiftLL(v) + case OpARM64ADDshiftRA: + return rewriteValueARM64_OpARM64ADDshiftRA(v) + case OpARM64ADDshiftRL: + return rewriteValueARM64_OpARM64ADDshiftRL(v) + case OpARM64AND: + return rewriteValueARM64_OpARM64AND(v) + case OpARM64ANDconst: + return rewriteValueARM64_OpARM64ANDconst(v) + case OpARM64ANDshiftLL: + return rewriteValueARM64_OpARM64ANDshiftLL(v) + case OpARM64ANDshiftRA: + return rewriteValueARM64_OpARM64ANDshiftRA(v) + case OpARM64ANDshiftRL: + return rewriteValueARM64_OpARM64ANDshiftRL(v) + case OpARM64ANDshiftRO: + return rewriteValueARM64_OpARM64ANDshiftRO(v) + case OpARM64BIC: + return rewriteValueARM64_OpARM64BIC(v) + case OpARM64BICshiftLL: + return rewriteValueARM64_OpARM64BICshiftLL(v) + case OpARM64BICshiftRA: + return rewriteValueARM64_OpARM64BICshiftRA(v) + case OpARM64BICshiftRL: + return rewriteValueARM64_OpARM64BICshiftRL(v) + case OpARM64BICshiftRO: + return rewriteValueARM64_OpARM64BICshiftRO(v) + case OpARM64CMN: + return rewriteValueARM64_OpARM64CMN(v) + case OpARM64CMNW: + return rewriteValueARM64_OpARM64CMNW(v) + case OpARM64CMNWconst: + return rewriteValueARM64_OpARM64CMNWconst(v) + case OpARM64CMNconst: + return rewriteValueARM64_OpARM64CMNconst(v) + case OpARM64CMNshiftLL: + return rewriteValueARM64_OpARM64CMNshiftLL(v) + case OpARM64CMNshiftRA: + return rewriteValueARM64_OpARM64CMNshiftRA(v) + case OpARM64CMNshiftRL: + return rewriteValueARM64_OpARM64CMNshiftRL(v) + case OpARM64CMP: + return rewriteValueARM64_OpARM64CMP(v) + case OpARM64CMPW: + return rewriteValueARM64_OpARM64CMPW(v) + case OpARM64CMPWconst: + return rewriteValueARM64_OpARM64CMPWconst(v) + case OpARM64CMPconst: + return rewriteValueARM64_OpARM64CMPconst(v) + case OpARM64CMPshiftLL: + return rewriteValueARM64_OpARM64CMPshiftLL(v) + case OpARM64CMPshiftRA: + return rewriteValueARM64_OpARM64CMPshiftRA(v) + case OpARM64CMPshiftRL: + return rewriteValueARM64_OpARM64CMPshiftRL(v) + case OpARM64CSEL: + return rewriteValueARM64_OpARM64CSEL(v) + case OpARM64CSEL0: + return rewriteValueARM64_OpARM64CSEL0(v) + case OpARM64CSETM: + return rewriteValueARM64_OpARM64CSETM(v) + case OpARM64CSINC: + return rewriteValueARM64_OpARM64CSINC(v) + case OpARM64CSINV: + return rewriteValueARM64_OpARM64CSINV(v) + case OpARM64CSNEG: + return rewriteValueARM64_OpARM64CSNEG(v) + case OpARM64DIV: + return rewriteValueARM64_OpARM64DIV(v) + case OpARM64DIVW: + return rewriteValueARM64_OpARM64DIVW(v) + case OpARM64EON: + return rewriteValueARM64_OpARM64EON(v) + case OpARM64EONshiftLL: + return rewriteValueARM64_OpARM64EONshiftLL(v) + case OpARM64EONshiftRA: + return rewriteValueARM64_OpARM64EONshiftRA(v) + case OpARM64EONshiftRL: + return rewriteValueARM64_OpARM64EONshiftRL(v) + case OpARM64EONshiftRO: + return rewriteValueARM64_OpARM64EONshiftRO(v) + case OpARM64Equal: + return rewriteValueARM64_OpARM64Equal(v) + case OpARM64FADDD: + return rewriteValueARM64_OpARM64FADDD(v) + case OpARM64FADDS: + return rewriteValueARM64_OpARM64FADDS(v) + case OpARM64FCMPD: + return rewriteValueARM64_OpARM64FCMPD(v) + case OpARM64FCMPS: + return rewriteValueARM64_OpARM64FCMPS(v) + case OpARM64FMOVDfpgp: + return rewriteValueARM64_OpARM64FMOVDfpgp(v) + case OpARM64FMOVDgpfp: + return rewriteValueARM64_OpARM64FMOVDgpfp(v) + case OpARM64FMOVDload: + return rewriteValueARM64_OpARM64FMOVDload(v) + case OpARM64FMOVDloadidx: + return rewriteValueARM64_OpARM64FMOVDloadidx(v) + case OpARM64FMOVDloadidx8: + return rewriteValueARM64_OpARM64FMOVDloadidx8(v) + case OpARM64FMOVDstore: + return rewriteValueARM64_OpARM64FMOVDstore(v) + case OpARM64FMOVDstoreidx: + return rewriteValueARM64_OpARM64FMOVDstoreidx(v) + case OpARM64FMOVDstoreidx8: + return rewriteValueARM64_OpARM64FMOVDstoreidx8(v) + case OpARM64FMOVSload: + return rewriteValueARM64_OpARM64FMOVSload(v) + case OpARM64FMOVSloadidx: + return rewriteValueARM64_OpARM64FMOVSloadidx(v) + case OpARM64FMOVSloadidx4: + return rewriteValueARM64_OpARM64FMOVSloadidx4(v) + case OpARM64FMOVSstore: + return rewriteValueARM64_OpARM64FMOVSstore(v) + case OpARM64FMOVSstoreidx: + return rewriteValueARM64_OpARM64FMOVSstoreidx(v) + case OpARM64FMOVSstoreidx4: + return rewriteValueARM64_OpARM64FMOVSstoreidx4(v) + case OpARM64FMULD: + return rewriteValueARM64_OpARM64FMULD(v) + case OpARM64FMULS: + return rewriteValueARM64_OpARM64FMULS(v) + case OpARM64FNEGD: + return rewriteValueARM64_OpARM64FNEGD(v) + case OpARM64FNEGS: + return rewriteValueARM64_OpARM64FNEGS(v) + case OpARM64FNMULD: + return rewriteValueARM64_OpARM64FNMULD(v) + case OpARM64FNMULS: + return rewriteValueARM64_OpARM64FNMULS(v) + case OpARM64FSUBD: + return rewriteValueARM64_OpARM64FSUBD(v) + case OpARM64FSUBS: + return rewriteValueARM64_OpARM64FSUBS(v) + case OpARM64GreaterEqual: + return rewriteValueARM64_OpARM64GreaterEqual(v) + case OpARM64GreaterEqualF: + return rewriteValueARM64_OpARM64GreaterEqualF(v) + case OpARM64GreaterEqualNoov: + return rewriteValueARM64_OpARM64GreaterEqualNoov(v) + case OpARM64GreaterEqualU: + return rewriteValueARM64_OpARM64GreaterEqualU(v) + case OpARM64GreaterThan: + return rewriteValueARM64_OpARM64GreaterThan(v) + case OpARM64GreaterThanF: + return rewriteValueARM64_OpARM64GreaterThanF(v) + case OpARM64GreaterThanU: + return rewriteValueARM64_OpARM64GreaterThanU(v) + case OpARM64LDP: + return rewriteValueARM64_OpARM64LDP(v) + case OpARM64LessEqual: + return rewriteValueARM64_OpARM64LessEqual(v) + case OpARM64LessEqualF: + return rewriteValueARM64_OpARM64LessEqualF(v) + case OpARM64LessEqualU: + return rewriteValueARM64_OpARM64LessEqualU(v) + case OpARM64LessThan: + return rewriteValueARM64_OpARM64LessThan(v) + case OpARM64LessThanF: + return rewriteValueARM64_OpARM64LessThanF(v) + case OpARM64LessThanNoov: + return rewriteValueARM64_OpARM64LessThanNoov(v) + case OpARM64LessThanU: + return rewriteValueARM64_OpARM64LessThanU(v) + case OpARM64LoweredPanicBoundsCR: + return rewriteValueARM64_OpARM64LoweredPanicBoundsCR(v) + case OpARM64LoweredPanicBoundsRC: + return rewriteValueARM64_OpARM64LoweredPanicBoundsRC(v) + case OpARM64LoweredPanicBoundsRR: + return rewriteValueARM64_OpARM64LoweredPanicBoundsRR(v) + case OpARM64MADD: + return rewriteValueARM64_OpARM64MADD(v) + case OpARM64MADDW: + return rewriteValueARM64_OpARM64MADDW(v) + case OpARM64MNEG: + return rewriteValueARM64_OpARM64MNEG(v) + case OpARM64MNEGW: + return rewriteValueARM64_OpARM64MNEGW(v) + case OpARM64MOD: + return rewriteValueARM64_OpARM64MOD(v) + case OpARM64MODW: + return rewriteValueARM64_OpARM64MODW(v) + case OpARM64MOVBUload: + return rewriteValueARM64_OpARM64MOVBUload(v) + case OpARM64MOVBUloadidx: + return rewriteValueARM64_OpARM64MOVBUloadidx(v) + case OpARM64MOVBUreg: + return rewriteValueARM64_OpARM64MOVBUreg(v) + case OpARM64MOVBload: + return rewriteValueARM64_OpARM64MOVBload(v) + case OpARM64MOVBloadidx: + return rewriteValueARM64_OpARM64MOVBloadidx(v) + case OpARM64MOVBreg: + return rewriteValueARM64_OpARM64MOVBreg(v) + case OpARM64MOVBstore: + return rewriteValueARM64_OpARM64MOVBstore(v) + case OpARM64MOVBstoreidx: + return rewriteValueARM64_OpARM64MOVBstoreidx(v) + case OpARM64MOVDload: + return rewriteValueARM64_OpARM64MOVDload(v) + case OpARM64MOVDloadidx: + return rewriteValueARM64_OpARM64MOVDloadidx(v) + case OpARM64MOVDloadidx8: + return rewriteValueARM64_OpARM64MOVDloadidx8(v) + case OpARM64MOVDnop: + return rewriteValueARM64_OpARM64MOVDnop(v) + case OpARM64MOVDreg: + return rewriteValueARM64_OpARM64MOVDreg(v) + case OpARM64MOVDstore: + return rewriteValueARM64_OpARM64MOVDstore(v) + case OpARM64MOVDstoreidx: + return rewriteValueARM64_OpARM64MOVDstoreidx(v) + case OpARM64MOVDstoreidx8: + return rewriteValueARM64_OpARM64MOVDstoreidx8(v) + case OpARM64MOVHUload: + return rewriteValueARM64_OpARM64MOVHUload(v) + case OpARM64MOVHUloadidx: + return rewriteValueARM64_OpARM64MOVHUloadidx(v) + case OpARM64MOVHUloadidx2: + return rewriteValueARM64_OpARM64MOVHUloadidx2(v) + case OpARM64MOVHUreg: + return rewriteValueARM64_OpARM64MOVHUreg(v) + case OpARM64MOVHload: + return rewriteValueARM64_OpARM64MOVHload(v) + case OpARM64MOVHloadidx: + return rewriteValueARM64_OpARM64MOVHloadidx(v) + case OpARM64MOVHloadidx2: + return rewriteValueARM64_OpARM64MOVHloadidx2(v) + case OpARM64MOVHreg: + return rewriteValueARM64_OpARM64MOVHreg(v) + case OpARM64MOVHstore: + return rewriteValueARM64_OpARM64MOVHstore(v) + case OpARM64MOVHstoreidx: + return rewriteValueARM64_OpARM64MOVHstoreidx(v) + case OpARM64MOVHstoreidx2: + return rewriteValueARM64_OpARM64MOVHstoreidx2(v) + case OpARM64MOVWUload: + return rewriteValueARM64_OpARM64MOVWUload(v) + case OpARM64MOVWUloadidx: + return rewriteValueARM64_OpARM64MOVWUloadidx(v) + case OpARM64MOVWUloadidx4: + return rewriteValueARM64_OpARM64MOVWUloadidx4(v) + case OpARM64MOVWUreg: + return rewriteValueARM64_OpARM64MOVWUreg(v) + case OpARM64MOVWload: + return rewriteValueARM64_OpARM64MOVWload(v) + case OpARM64MOVWloadidx: + return rewriteValueARM64_OpARM64MOVWloadidx(v) + case OpARM64MOVWloadidx4: + return rewriteValueARM64_OpARM64MOVWloadidx4(v) + case OpARM64MOVWreg: + return rewriteValueARM64_OpARM64MOVWreg(v) + case OpARM64MOVWstore: + return rewriteValueARM64_OpARM64MOVWstore(v) + case OpARM64MOVWstoreidx: + return rewriteValueARM64_OpARM64MOVWstoreidx(v) + case OpARM64MOVWstoreidx4: + return rewriteValueARM64_OpARM64MOVWstoreidx4(v) + case OpARM64MSUB: + return rewriteValueARM64_OpARM64MSUB(v) + case OpARM64MSUBW: + return rewriteValueARM64_OpARM64MSUBW(v) + case OpARM64MUL: + return rewriteValueARM64_OpARM64MUL(v) + case OpARM64MULW: + return rewriteValueARM64_OpARM64MULW(v) + case OpARM64MVN: + return rewriteValueARM64_OpARM64MVN(v) + case OpARM64MVNshiftLL: + return rewriteValueARM64_OpARM64MVNshiftLL(v) + case OpARM64MVNshiftRA: + return rewriteValueARM64_OpARM64MVNshiftRA(v) + case OpARM64MVNshiftRL: + return rewriteValueARM64_OpARM64MVNshiftRL(v) + case OpARM64MVNshiftRO: + return rewriteValueARM64_OpARM64MVNshiftRO(v) + case OpARM64NEG: + return rewriteValueARM64_OpARM64NEG(v) + case OpARM64NEGshiftLL: + return rewriteValueARM64_OpARM64NEGshiftLL(v) + case OpARM64NEGshiftRA: + return rewriteValueARM64_OpARM64NEGshiftRA(v) + case OpARM64NEGshiftRL: + return rewriteValueARM64_OpARM64NEGshiftRL(v) + case OpARM64NotEqual: + return rewriteValueARM64_OpARM64NotEqual(v) + case OpARM64OR: + return rewriteValueARM64_OpARM64OR(v) + case OpARM64ORN: + return rewriteValueARM64_OpARM64ORN(v) + case OpARM64ORNshiftLL: + return rewriteValueARM64_OpARM64ORNshiftLL(v) + case OpARM64ORNshiftRA: + return rewriteValueARM64_OpARM64ORNshiftRA(v) + case OpARM64ORNshiftRL: + return rewriteValueARM64_OpARM64ORNshiftRL(v) + case OpARM64ORNshiftRO: + return rewriteValueARM64_OpARM64ORNshiftRO(v) + case OpARM64ORconst: + return rewriteValueARM64_OpARM64ORconst(v) + case OpARM64ORshiftLL: + return rewriteValueARM64_OpARM64ORshiftLL(v) + case OpARM64ORshiftRA: + return rewriteValueARM64_OpARM64ORshiftRA(v) + case OpARM64ORshiftRL: + return rewriteValueARM64_OpARM64ORshiftRL(v) + case OpARM64ORshiftRO: + return rewriteValueARM64_OpARM64ORshiftRO(v) + case OpARM64REV: + return rewriteValueARM64_OpARM64REV(v) + case OpARM64REVW: + return rewriteValueARM64_OpARM64REVW(v) + case OpARM64ROR: + return rewriteValueARM64_OpARM64ROR(v) + case OpARM64RORW: + return rewriteValueARM64_OpARM64RORW(v) + case OpARM64SBCSflags: + return rewriteValueARM64_OpARM64SBCSflags(v) + case OpARM64SBFX: + return rewriteValueARM64_OpARM64SBFX(v) + case OpARM64SLL: + return rewriteValueARM64_OpARM64SLL(v) + case OpARM64SLLconst: + return rewriteValueARM64_OpARM64SLLconst(v) + case OpARM64SRA: + return rewriteValueARM64_OpARM64SRA(v) + case OpARM64SRAconst: + return rewriteValueARM64_OpARM64SRAconst(v) + case OpARM64SRL: + return rewriteValueARM64_OpARM64SRL(v) + case OpARM64SRLconst: + return rewriteValueARM64_OpARM64SRLconst(v) + case OpARM64STP: + return rewriteValueARM64_OpARM64STP(v) + case OpARM64SUB: + return rewriteValueARM64_OpARM64SUB(v) + case OpARM64SUBconst: + return rewriteValueARM64_OpARM64SUBconst(v) + case OpARM64SUBshiftLL: + return rewriteValueARM64_OpARM64SUBshiftLL(v) + case OpARM64SUBshiftRA: + return rewriteValueARM64_OpARM64SUBshiftRA(v) + case OpARM64SUBshiftRL: + return rewriteValueARM64_OpARM64SUBshiftRL(v) + case OpARM64TST: + return rewriteValueARM64_OpARM64TST(v) + case OpARM64TSTW: + return rewriteValueARM64_OpARM64TSTW(v) + case OpARM64TSTWconst: + return rewriteValueARM64_OpARM64TSTWconst(v) + case OpARM64TSTconst: + return rewriteValueARM64_OpARM64TSTconst(v) + case OpARM64TSTshiftLL: + return rewriteValueARM64_OpARM64TSTshiftLL(v) + case OpARM64TSTshiftRA: + return rewriteValueARM64_OpARM64TSTshiftRA(v) + case OpARM64TSTshiftRL: + return rewriteValueARM64_OpARM64TSTshiftRL(v) + case OpARM64TSTshiftRO: + return rewriteValueARM64_OpARM64TSTshiftRO(v) + case OpARM64UBFIZ: + return rewriteValueARM64_OpARM64UBFIZ(v) + case OpARM64UBFX: + return rewriteValueARM64_OpARM64UBFX(v) + case OpARM64UDIV: + return rewriteValueARM64_OpARM64UDIV(v) + case OpARM64UDIVW: + return rewriteValueARM64_OpARM64UDIVW(v) + case OpARM64UMOD: + return rewriteValueARM64_OpARM64UMOD(v) + case OpARM64UMODW: + return rewriteValueARM64_OpARM64UMODW(v) + case OpARM64XOR: + return rewriteValueARM64_OpARM64XOR(v) + case OpARM64XORconst: + return rewriteValueARM64_OpARM64XORconst(v) + case OpARM64XORshiftLL: + return rewriteValueARM64_OpARM64XORshiftLL(v) + case OpARM64XORshiftRA: + return rewriteValueARM64_OpARM64XORshiftRA(v) + case OpARM64XORshiftRL: + return rewriteValueARM64_OpARM64XORshiftRL(v) + case OpARM64XORshiftRO: + return rewriteValueARM64_OpARM64XORshiftRO(v) + case OpAbs: + v.Op = OpARM64FABSD + return true + case OpAdd16: + v.Op = OpARM64ADD + return true + case OpAdd32: + v.Op = OpARM64ADD + return true + case OpAdd32F: + v.Op = OpARM64FADDS + return true + case OpAdd64: + v.Op = OpARM64ADD + return true + case OpAdd64F: + v.Op = OpARM64FADDD + return true + case OpAdd8: + v.Op = OpARM64ADD + return true + case OpAddPtr: + v.Op = OpARM64ADD + return true + case OpAddr: + return rewriteValueARM64_OpAddr(v) + case OpAnd16: + v.Op = OpARM64AND + return true + case OpAnd32: + v.Op = OpARM64AND + return true + case OpAnd64: + v.Op = OpARM64AND + return true + case OpAnd8: + v.Op = OpARM64AND + return true + case OpAndB: + v.Op = OpARM64AND + return true + case OpAtomicAdd32: + v.Op = OpARM64LoweredAtomicAdd32 + return true + case OpAtomicAdd32Variant: + v.Op = OpARM64LoweredAtomicAdd32Variant + return true + case OpAtomicAdd64: + v.Op = OpARM64LoweredAtomicAdd64 + return true + case OpAtomicAdd64Variant: + v.Op = OpARM64LoweredAtomicAdd64Variant + return true + case OpAtomicAnd32value: + v.Op = OpARM64LoweredAtomicAnd32 + return true + case OpAtomicAnd32valueVariant: + v.Op = OpARM64LoweredAtomicAnd32Variant + return true + case OpAtomicAnd64value: + v.Op = OpARM64LoweredAtomicAnd64 + return true + case OpAtomicAnd64valueVariant: + v.Op = OpARM64LoweredAtomicAnd64Variant + return true + case OpAtomicAnd8value: + v.Op = OpARM64LoweredAtomicAnd8 + return true + case OpAtomicAnd8valueVariant: + v.Op = OpARM64LoweredAtomicAnd8Variant + return true + case OpAtomicCompareAndSwap32: + v.Op = OpARM64LoweredAtomicCas32 + return true + case OpAtomicCompareAndSwap32Variant: + v.Op = OpARM64LoweredAtomicCas32Variant + return true + case OpAtomicCompareAndSwap64: + v.Op = OpARM64LoweredAtomicCas64 + return true + case OpAtomicCompareAndSwap64Variant: + v.Op = OpARM64LoweredAtomicCas64Variant + return true + case OpAtomicExchange32: + v.Op = OpARM64LoweredAtomicExchange32 + return true + case OpAtomicExchange32Variant: + v.Op = OpARM64LoweredAtomicExchange32Variant + return true + case OpAtomicExchange64: + v.Op = OpARM64LoweredAtomicExchange64 + return true + case OpAtomicExchange64Variant: + v.Op = OpARM64LoweredAtomicExchange64Variant + return true + case OpAtomicExchange8: + v.Op = OpARM64LoweredAtomicExchange8 + return true + case OpAtomicExchange8Variant: + v.Op = OpARM64LoweredAtomicExchange8Variant + return true + case OpAtomicLoad32: + v.Op = OpARM64LDARW + return true + case OpAtomicLoad64: + v.Op = OpARM64LDAR + return true + case OpAtomicLoad8: + v.Op = OpARM64LDARB + return true + case OpAtomicLoadPtr: + v.Op = OpARM64LDAR + return true + case OpAtomicOr32value: + v.Op = OpARM64LoweredAtomicOr32 + return true + case OpAtomicOr32valueVariant: + v.Op = OpARM64LoweredAtomicOr32Variant + return true + case OpAtomicOr64value: + v.Op = OpARM64LoweredAtomicOr64 + return true + case OpAtomicOr64valueVariant: + v.Op = OpARM64LoweredAtomicOr64Variant + return true + case OpAtomicOr8value: + v.Op = OpARM64LoweredAtomicOr8 + return true + case OpAtomicOr8valueVariant: + v.Op = OpARM64LoweredAtomicOr8Variant + return true + case OpAtomicStore32: + v.Op = OpARM64STLRW + return true + case OpAtomicStore64: + v.Op = OpARM64STLR + return true + case OpAtomicStore8: + v.Op = OpARM64STLRB + return true + case OpAtomicStorePtrNoWB: + v.Op = OpARM64STLR + return true + case OpAvg64u: + return rewriteValueARM64_OpAvg64u(v) + case OpBitLen16: + return rewriteValueARM64_OpBitLen16(v) + case OpBitLen32: + return rewriteValueARM64_OpBitLen32(v) + case OpBitLen64: + return rewriteValueARM64_OpBitLen64(v) + case OpBitLen8: + return rewriteValueARM64_OpBitLen8(v) + case OpBitRev16: + return rewriteValueARM64_OpBitRev16(v) + case OpBitRev32: + v.Op = OpARM64RBITW + return true + case OpBitRev64: + v.Op = OpARM64RBIT + return true + case OpBitRev8: + return rewriteValueARM64_OpBitRev8(v) + case OpBswap16: + v.Op = OpARM64REV16W + return true + case OpBswap32: + v.Op = OpARM64REVW + return true + case OpBswap64: + v.Op = OpARM64REV + return true + case OpCeil: + v.Op = OpARM64FRINTPD + return true + case OpClosureCall: + v.Op = OpARM64CALLclosure + return true + case OpCom16: + v.Op = OpARM64MVN + return true + case OpCom32: + v.Op = OpARM64MVN + return true + case OpCom64: + v.Op = OpARM64MVN + return true + case OpCom8: + v.Op = OpARM64MVN + return true + case OpCondSelect: + return rewriteValueARM64_OpCondSelect(v) + case OpConst16: + return rewriteValueARM64_OpConst16(v) + case OpConst32: + return rewriteValueARM64_OpConst32(v) + case OpConst32F: + return rewriteValueARM64_OpConst32F(v) + case OpConst64: + return rewriteValueARM64_OpConst64(v) + case OpConst64F: + return rewriteValueARM64_OpConst64F(v) + case OpConst8: + return rewriteValueARM64_OpConst8(v) + case OpConstBool: + return rewriteValueARM64_OpConstBool(v) + case OpConstNil: + return rewriteValueARM64_OpConstNil(v) + case OpCtz16: + return rewriteValueARM64_OpCtz16(v) + case OpCtz16NonZero: + v.Op = OpCtz32 + return true + case OpCtz32: + return rewriteValueARM64_OpCtz32(v) + case OpCtz32NonZero: + v.Op = OpCtz32 + return true + case OpCtz64: + return rewriteValueARM64_OpCtz64(v) + case OpCtz64NonZero: + v.Op = OpCtz64 + return true + case OpCtz8: + return rewriteValueARM64_OpCtz8(v) + case OpCtz8NonZero: + v.Op = OpCtz32 + return true + case OpCvt32Fto32: + v.Op = OpARM64FCVTZSSW + return true + case OpCvt32Fto32U: + v.Op = OpARM64FCVTZUSW + return true + case OpCvt32Fto64: + v.Op = OpARM64FCVTZSS + return true + case OpCvt32Fto64F: + v.Op = OpARM64FCVTSD + return true + case OpCvt32Fto64U: + v.Op = OpARM64FCVTZUS + return true + case OpCvt32Uto32F: + v.Op = OpARM64UCVTFWS + return true + case OpCvt32Uto64F: + v.Op = OpARM64UCVTFWD + return true + case OpCvt32to32F: + v.Op = OpARM64SCVTFWS + return true + case OpCvt32to64F: + v.Op = OpARM64SCVTFWD + return true + case OpCvt64Fto32: + v.Op = OpARM64FCVTZSDW + return true + case OpCvt64Fto32F: + v.Op = OpARM64FCVTDS + return true + case OpCvt64Fto32U: + v.Op = OpARM64FCVTZUDW + return true + case OpCvt64Fto64: + v.Op = OpARM64FCVTZSD + return true + case OpCvt64Fto64U: + v.Op = OpARM64FCVTZUD + return true + case OpCvt64Uto32F: + v.Op = OpARM64UCVTFS + return true + case OpCvt64Uto64F: + v.Op = OpARM64UCVTFD + return true + case OpCvt64to32F: + v.Op = OpARM64SCVTFS + return true + case OpCvt64to64F: + v.Op = OpARM64SCVTFD + return true + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpDiv16: + return rewriteValueARM64_OpDiv16(v) + case OpDiv16u: + return rewriteValueARM64_OpDiv16u(v) + case OpDiv32: + return rewriteValueARM64_OpDiv32(v) + case OpDiv32F: + v.Op = OpARM64FDIVS + return true + case OpDiv32u: + v.Op = OpARM64UDIVW + return true + case OpDiv64: + return rewriteValueARM64_OpDiv64(v) + case OpDiv64F: + v.Op = OpARM64FDIVD + return true + case OpDiv64u: + v.Op = OpARM64UDIV + return true + case OpDiv8: + return rewriteValueARM64_OpDiv8(v) + case OpDiv8u: + return rewriteValueARM64_OpDiv8u(v) + case OpEq16: + return rewriteValueARM64_OpEq16(v) + case OpEq32: + return rewriteValueARM64_OpEq32(v) + case OpEq32F: + return rewriteValueARM64_OpEq32F(v) + case OpEq64: + return rewriteValueARM64_OpEq64(v) + case OpEq64F: + return rewriteValueARM64_OpEq64F(v) + case OpEq8: + return rewriteValueARM64_OpEq8(v) + case OpEqB: + return rewriteValueARM64_OpEqB(v) + case OpEqPtr: + return rewriteValueARM64_OpEqPtr(v) + case OpFMA: + return rewriteValueARM64_OpFMA(v) + case OpFloor: + v.Op = OpARM64FRINTMD + return true + case OpGetCallerPC: + v.Op = OpARM64LoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = OpARM64LoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = OpARM64LoweredGetClosurePtr + return true + case OpHmul32: + return rewriteValueARM64_OpHmul32(v) + case OpHmul32u: + return rewriteValueARM64_OpHmul32u(v) + case OpHmul64: + v.Op = OpARM64MULH + return true + case OpHmul64u: + v.Op = OpARM64UMULH + return true + case OpInterCall: + v.Op = OpARM64CALLinter + return true + case OpIsInBounds: + return rewriteValueARM64_OpIsInBounds(v) + case OpIsNonNil: + return rewriteValueARM64_OpIsNonNil(v) + case OpIsSliceInBounds: + return rewriteValueARM64_OpIsSliceInBounds(v) + case OpLeq16: + return rewriteValueARM64_OpLeq16(v) + case OpLeq16U: + return rewriteValueARM64_OpLeq16U(v) + case OpLeq32: + return rewriteValueARM64_OpLeq32(v) + case OpLeq32F: + return rewriteValueARM64_OpLeq32F(v) + case OpLeq32U: + return rewriteValueARM64_OpLeq32U(v) + case OpLeq64: + return rewriteValueARM64_OpLeq64(v) + case OpLeq64F: + return rewriteValueARM64_OpLeq64F(v) + case OpLeq64U: + return rewriteValueARM64_OpLeq64U(v) + case OpLeq8: + return rewriteValueARM64_OpLeq8(v) + case OpLeq8U: + return rewriteValueARM64_OpLeq8U(v) + case OpLess16: + return rewriteValueARM64_OpLess16(v) + case OpLess16U: + return rewriteValueARM64_OpLess16U(v) + case OpLess32: + return rewriteValueARM64_OpLess32(v) + case OpLess32F: + return rewriteValueARM64_OpLess32F(v) + case OpLess32U: + return rewriteValueARM64_OpLess32U(v) + case OpLess64: + return rewriteValueARM64_OpLess64(v) + case OpLess64F: + return rewriteValueARM64_OpLess64F(v) + case OpLess64U: + return rewriteValueARM64_OpLess64U(v) + case OpLess8: + return rewriteValueARM64_OpLess8(v) + case OpLess8U: + return rewriteValueARM64_OpLess8U(v) + case OpLoad: + return rewriteValueARM64_OpLoad(v) + case OpLocalAddr: + return rewriteValueARM64_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValueARM64_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValueARM64_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValueARM64_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValueARM64_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValueARM64_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValueARM64_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValueARM64_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValueARM64_OpLsh32x8(v) + case OpLsh64x16: + return rewriteValueARM64_OpLsh64x16(v) + case OpLsh64x32: + return rewriteValueARM64_OpLsh64x32(v) + case OpLsh64x64: + return rewriteValueARM64_OpLsh64x64(v) + case OpLsh64x8: + return rewriteValueARM64_OpLsh64x8(v) + case OpLsh8x16: + return rewriteValueARM64_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValueARM64_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValueARM64_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValueARM64_OpLsh8x8(v) + case OpMax32F: + v.Op = OpARM64FMAXS + return true + case OpMax64F: + v.Op = OpARM64FMAXD + return true + case OpMemEq: + v.Op = OpARM64LoweredMemEq + return true + case OpMin32F: + v.Op = OpARM64FMINS + return true + case OpMin64F: + v.Op = OpARM64FMIND + return true + case OpMod16: + return rewriteValueARM64_OpMod16(v) + case OpMod16u: + return rewriteValueARM64_OpMod16u(v) + case OpMod32: + return rewriteValueARM64_OpMod32(v) + case OpMod32u: + v.Op = OpARM64UMODW + return true + case OpMod64: + return rewriteValueARM64_OpMod64(v) + case OpMod64u: + v.Op = OpARM64UMOD + return true + case OpMod8: + return rewriteValueARM64_OpMod8(v) + case OpMod8u: + return rewriteValueARM64_OpMod8u(v) + case OpMove: + return rewriteValueARM64_OpMove(v) + case OpMul16: + v.Op = OpARM64MULW + return true + case OpMul32: + v.Op = OpARM64MULW + return true + case OpMul32F: + v.Op = OpARM64FMULS + return true + case OpMul64: + v.Op = OpARM64MUL + return true + case OpMul64F: + v.Op = OpARM64FMULD + return true + case OpMul8: + v.Op = OpARM64MULW + return true + case OpNeg16: + v.Op = OpARM64NEG + return true + case OpNeg32: + v.Op = OpARM64NEG + return true + case OpNeg32F: + v.Op = OpARM64FNEGS + return true + case OpNeg64: + v.Op = OpARM64NEG + return true + case OpNeg64F: + v.Op = OpARM64FNEGD + return true + case OpNeg8: + v.Op = OpARM64NEG + return true + case OpNeq16: + return rewriteValueARM64_OpNeq16(v) + case OpNeq32: + return rewriteValueARM64_OpNeq32(v) + case OpNeq32F: + return rewriteValueARM64_OpNeq32F(v) + case OpNeq64: + return rewriteValueARM64_OpNeq64(v) + case OpNeq64F: + return rewriteValueARM64_OpNeq64F(v) + case OpNeq8: + return rewriteValueARM64_OpNeq8(v) + case OpNeqB: + v.Op = OpARM64XOR + return true + case OpNeqPtr: + return rewriteValueARM64_OpNeqPtr(v) + case OpNilCheck: + v.Op = OpARM64LoweredNilCheck + return true + case OpNot: + return rewriteValueARM64_OpNot(v) + case OpOffPtr: + return rewriteValueARM64_OpOffPtr(v) + case OpOr16: + v.Op = OpARM64OR + return true + case OpOr32: + v.Op = OpARM64OR + return true + case OpOr64: + v.Op = OpARM64OR + return true + case OpOr8: + v.Op = OpARM64OR + return true + case OpOrB: + v.Op = OpARM64OR + return true + case OpPanicBounds: + v.Op = OpARM64LoweredPanicBoundsRR + return true + case OpPopCount16: + return rewriteValueARM64_OpPopCount16(v) + case OpPopCount32: + return rewriteValueARM64_OpPopCount32(v) + case OpPopCount64: + return rewriteValueARM64_OpPopCount64(v) + case OpPrefetchCache: + return rewriteValueARM64_OpPrefetchCache(v) + case OpPrefetchCacheStreamed: + return rewriteValueARM64_OpPrefetchCacheStreamed(v) + case OpPubBarrier: + return rewriteValueARM64_OpPubBarrier(v) + case OpRotateLeft16: + return rewriteValueARM64_OpRotateLeft16(v) + case OpRotateLeft32: + return rewriteValueARM64_OpRotateLeft32(v) + case OpRotateLeft64: + return rewriteValueARM64_OpRotateLeft64(v) + case OpRotateLeft8: + return rewriteValueARM64_OpRotateLeft8(v) + case OpRound: + v.Op = OpARM64FRINTAD + return true + case OpRound32F: + v.Op = OpARM64LoweredRound32F + return true + case OpRound64F: + v.Op = OpARM64LoweredRound64F + return true + case OpRoundToEven: + v.Op = OpARM64FRINTND + return true + case OpRsh16Ux16: + return rewriteValueARM64_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValueARM64_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValueARM64_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValueARM64_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValueARM64_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValueARM64_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValueARM64_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValueARM64_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValueARM64_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValueARM64_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValueARM64_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValueARM64_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValueARM64_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValueARM64_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValueARM64_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValueARM64_OpRsh32x8(v) + case OpRsh64Ux16: + return rewriteValueARM64_OpRsh64Ux16(v) + case OpRsh64Ux32: + return rewriteValueARM64_OpRsh64Ux32(v) + case OpRsh64Ux64: + return rewriteValueARM64_OpRsh64Ux64(v) + case OpRsh64Ux8: + return rewriteValueARM64_OpRsh64Ux8(v) + case OpRsh64x16: + return rewriteValueARM64_OpRsh64x16(v) + case OpRsh64x32: + return rewriteValueARM64_OpRsh64x32(v) + case OpRsh64x64: + return rewriteValueARM64_OpRsh64x64(v) + case OpRsh64x8: + return rewriteValueARM64_OpRsh64x8(v) + case OpRsh8Ux16: + return rewriteValueARM64_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValueARM64_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValueARM64_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValueARM64_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValueARM64_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValueARM64_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValueARM64_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValueARM64_OpRsh8x8(v) + case OpSelect0: + return rewriteValueARM64_OpSelect0(v) + case OpSelect1: + return rewriteValueARM64_OpSelect1(v) + case OpSelectN: + return rewriteValueARM64_OpSelectN(v) + case OpSignExt16to32: + v.Op = OpARM64MOVHreg + return true + case OpSignExt16to64: + v.Op = OpARM64MOVHreg + return true + case OpSignExt32to64: + v.Op = OpARM64MOVWreg + return true + case OpSignExt8to16: + v.Op = OpARM64MOVBreg + return true + case OpSignExt8to32: + v.Op = OpARM64MOVBreg + return true + case OpSignExt8to64: + v.Op = OpARM64MOVBreg + return true + case OpSlicemask: + return rewriteValueARM64_OpSlicemask(v) + case OpSqrt: + v.Op = OpARM64FSQRTD + return true + case OpSqrt32: + v.Op = OpARM64FSQRTS + return true + case OpStaticCall: + v.Op = OpARM64CALLstatic + return true + case OpStore: + return rewriteValueARM64_OpStore(v) + case OpSub16: + v.Op = OpARM64SUB + return true + case OpSub32: + v.Op = OpARM64SUB + return true + case OpSub32F: + v.Op = OpARM64FSUBS + return true + case OpSub64: + v.Op = OpARM64SUB + return true + case OpSub64F: + v.Op = OpARM64FSUBD + return true + case OpSub8: + v.Op = OpARM64SUB + return true + case OpSubPtr: + v.Op = OpARM64SUB + return true + case OpTailCall: + v.Op = OpARM64CALLtail + return true + case OpTrunc: + v.Op = OpARM64FRINTZD + return true + case OpTrunc16to8: + v.Op = OpCopy + return true + case OpTrunc32to16: + v.Op = OpCopy + return true + case OpTrunc32to8: + v.Op = OpCopy + return true + case OpTrunc64to16: + v.Op = OpCopy + return true + case OpTrunc64to32: + v.Op = OpCopy + return true + case OpTrunc64to8: + v.Op = OpCopy + return true + case OpWB: + v.Op = OpARM64LoweredWB + return true + case OpXor16: + v.Op = OpARM64XOR + return true + case OpXor32: + v.Op = OpARM64XOR + return true + case OpXor64: + v.Op = OpARM64XOR + return true + case OpXor8: + v.Op = OpARM64XOR + return true + case OpZero: + return rewriteValueARM64_OpZero(v) + case OpZeroExt16to32: + v.Op = OpARM64MOVHUreg + return true + case OpZeroExt16to64: + v.Op = OpARM64MOVHUreg + return true + case OpZeroExt32to64: + v.Op = OpARM64MOVWUreg + return true + case OpZeroExt8to16: + v.Op = OpARM64MOVBUreg + return true + case OpZeroExt8to32: + v.Op = OpARM64MOVBUreg + return true + case OpZeroExt8to64: + v.Op = OpARM64MOVBUreg + return true + } + return false +} +func rewriteValueARM64_OpARM64ADCSflags(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADCSflags x y (Select1 (ADDSconstflags [-1] (ADCzerocarry c)))) + // result: (ADCSflags x y c) + for { + x := v_0 + y := v_1 + if v_2.Op != OpSelect1 || v_2.Type != types.TypeFlags { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpARM64ADDSconstflags || auxIntToInt64(v_2_0.AuxInt) != -1 { + break + } + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpARM64ADCzerocarry || v_2_0_0.Type != typ.UInt64 { + break + } + c := v_2_0_0.Args[0] + v.reset(OpARM64ADCSflags) + v.AddArg3(x, y, c) + return true + } + // match: (ADCSflags x y (Select1 (ADDSconstflags [-1] (MOVDconst [0])))) + // result: (ADDSflags x y) + for { + x := v_0 + y := v_1 + if v_2.Op != OpSelect1 || v_2.Type != types.TypeFlags { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpARM64ADDSconstflags || auxIntToInt64(v_2_0.AuxInt) != -1 { + break + } + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpARM64MOVDconst || auxIntToInt64(v_2_0_0.AuxInt) != 0 { + break + } + v.reset(OpARM64ADDSflags) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64ADD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADD x (MOVDconst [c])) + // cond: !t.IsPtr() + // result: (ADDconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(!t.IsPtr()) { + continue + } + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ADD a l:(MUL x y)) + // cond: l.Uses==1 && clobber(l) + // result: (MADD a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + l := v_1 + if l.Op != OpARM64MUL { + continue + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1 && clobber(l)) { + continue + } + v.reset(OpARM64MADD) + v.AddArg3(a, x, y) + return true + } + break + } + // match: (ADD a l:(MNEG x y)) + // cond: l.Uses==1 && clobber(l) + // result: (MSUB a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + l := v_1 + if l.Op != OpARM64MNEG { + continue + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1 && clobber(l)) { + continue + } + v.reset(OpARM64MSUB) + v.AddArg3(a, x, y) + return true + } + break + } + // match: (ADD a l:(MULW x y)) + // cond: v.Type.Size() <= 4 && l.Uses==1 && clobber(l) + // result: (MADDW a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + l := v_1 + if l.Op != OpARM64MULW { + continue + } + y := l.Args[1] + x := l.Args[0] + if !(v.Type.Size() <= 4 && l.Uses == 1 && clobber(l)) { + continue + } + v.reset(OpARM64MADDW) + v.AddArg3(a, x, y) + return true + } + break + } + // match: (ADD a l:(MNEGW x y)) + // cond: v.Type.Size() <= 4 && l.Uses==1 && clobber(l) + // result: (MSUBW a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + l := v_1 + if l.Op != OpARM64MNEGW { + continue + } + y := l.Args[1] + x := l.Args[0] + if !(v.Type.Size() <= 4 && l.Uses == 1 && clobber(l)) { + continue + } + v.reset(OpARM64MSUBW) + v.AddArg3(a, x, y) + return true + } + break + } + // match: (ADD a p:(ADDconst [c] m:(MUL _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (ADDconst [c] (ADD a m)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + p := v_1 + if p.Op != OpARM64ADDconst { + continue + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MUL || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + continue + } + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64ADD, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + break + } + // match: (ADD a p:(ADDconst [c] m:(MULW _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (ADDconst [c] (ADD a m)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + p := v_1 + if p.Op != OpARM64ADDconst { + continue + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MULW || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + continue + } + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64ADD, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + break + } + // match: (ADD a p:(ADDconst [c] m:(MNEG _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (ADDconst [c] (ADD a m)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + p := v_1 + if p.Op != OpARM64ADDconst { + continue + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MNEG || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + continue + } + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64ADD, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + break + } + // match: (ADD a p:(ADDconst [c] m:(MNEGW _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (ADDconst [c] (ADD a m)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + p := v_1 + if p.Op != OpARM64ADDconst { + continue + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MNEGW || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + continue + } + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64ADD, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + break + } + // match: (ADD a p:(SUBconst [c] m:(MUL _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (SUBconst [c] (ADD a m)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + p := v_1 + if p.Op != OpARM64SUBconst { + continue + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MUL || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + continue + } + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64ADD, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + break + } + // match: (ADD a p:(SUBconst [c] m:(MULW _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (SUBconst [c] (ADD a m)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + p := v_1 + if p.Op != OpARM64SUBconst { + continue + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MULW || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + continue + } + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64ADD, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + break + } + // match: (ADD a p:(SUBconst [c] m:(MNEG _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (SUBconst [c] (ADD a m)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + p := v_1 + if p.Op != OpARM64SUBconst { + continue + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MNEG || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + continue + } + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64ADD, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + break + } + // match: (ADD a p:(SUBconst [c] m:(MNEGW _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (SUBconst [c] (ADD a m)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + p := v_1 + if p.Op != OpARM64SUBconst { + continue + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MNEGW || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + continue + } + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64ADD, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + break + } + // match: (ADD x (NEG y)) + // result: (SUB x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64NEG { + continue + } + y := v_1.Args[0] + v.reset(OpARM64SUB) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADD x0 x1:(SLLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ADDshiftLL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SLLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (ADD x0 x1:(SRLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ADDshiftRL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ADDshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (ADD x0 x1:(SRAconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ADDshiftRA x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRAconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ADDshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (ADD x0 x1:(ANDshiftRA x2:(SLLconst [sl] y) z [63])) + // cond: x1.Uses == 1 && x2.Uses == 1 + // result: (ADDshiftLL x0 (ANDshiftRA y z [63]) [sl]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64ANDshiftRA || auxIntToInt64(x1.AuxInt) != 63 { + continue + } + z := x1.Args[1] + x2 := x1.Args[0] + if x2.Op != OpARM64SLLconst { + continue + } + sl := auxIntToInt64(x2.AuxInt) + y := x2.Args[0] + if !(x1.Uses == 1 && x2.Uses == 1) { + continue + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(sl) + v0 := b.NewValue0(v.Pos, OpARM64ANDshiftRA, y.Type) + v0.AuxInt = int64ToAuxInt(63) + v0.AddArg2(y, z) + v.AddArg2(x0, v0) + return true + } + break + } + // match: (ADD x0 x1:(ANDshiftLL x2:(SRAconst [63] z) y [sl])) + // cond: x1.Uses == 1 && x2.Uses == 1 + // result: (ADDshiftLL x0 (ANDshiftRA y z [63]) [sl]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64ANDshiftLL { + continue + } + sl := auxIntToInt64(x1.AuxInt) + y := x1.Args[1] + x2 := x1.Args[0] + if x2.Op != OpARM64SRAconst || auxIntToInt64(x2.AuxInt) != 63 { + continue + } + z := x2.Args[0] + if !(x1.Uses == 1 && x2.Uses == 1) { + continue + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(sl) + v0 := b.NewValue0(v.Pos, OpARM64ANDshiftRA, y.Type) + v0.AuxInt = int64ToAuxInt(63) + v0.AddArg2(y, z) + v.AddArg2(x0, v0) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64ADDSflags(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDSflags x (MOVDconst [c])) + // result: (ADDSconstflags [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ADDSconstflags) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64ADDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDconst [off1] (MOVDaddr [off2] {sym} ptr)) + // cond: is32Bit(off1+int64(off2)) + // result: (MOVDaddr [int32(off1)+off2] {sym} ptr) + for { + off1 := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + if !(is32Bit(off1 + int64(off2))) { + break + } + v.reset(OpARM64MOVDaddr) + v.AuxInt = int32ToAuxInt(int32(off1) + off2) + v.Aux = symToAux(sym) + v.AddArg(ptr) + return true + } + // match: (ADDconst [c] y) + // cond: c < 0 + // result: (SUBconst [-c] y) + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if !(c < 0) { + break + } + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(-c) + v.AddArg(y) + return true + } + // match: (ADDconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ADDconst [c] (MOVDconst [d])) + // result: (MOVDconst [c+d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(c + d) + return true + } + // match: (ADDconst [c] (ADDconst [d] x)) + // result: (ADDconst [c+d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64ADDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c + d) + v.AddArg(x) + return true + } + // match: (ADDconst [c] (SUBconst [d] x)) + // result: (ADDconst [c-d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SUBconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c - d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64ADDshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADDshiftLL (MOVDconst [c]) x [d]) + // result: (ADDconst [c] (SLLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ADDshiftLL x (MOVDconst [c]) [d]) + // result: (ADDconst x [int64(uint64(c)< [8] (UBFX [armBFAuxInt(8, 8)] x) x) + // result: (REV16W x) + for { + if v.Type != typ.UInt16 || auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64UBFX || v_0.Type != typ.UInt16 || auxIntToArm64BitField(v_0.AuxInt) != armBFAuxInt(8, 8) { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64REV16W) + v.AddArg(x) + return true + } + // match: (ADDshiftLL [8] (UBFX [armBFAuxInt(8, 24)] (ANDconst [c1] x)) (ANDconst [c2] x)) + // cond: uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff + // result: (REV16W x) + for { + if auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64UBFX || auxIntToArm64BitField(v_0.AuxInt) != armBFAuxInt(8, 24) { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARM64ANDconst { + break + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpARM64ANDconst { + break + } + c2 := auxIntToInt64(v_1.AuxInt) + if x != v_1.Args[0] || !(uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff) { + break + } + v.reset(OpARM64REV16W) + v.AddArg(x) + return true + } + // match: (ADDshiftLL [8] (SRLconst [8] (ANDconst [c1] x)) (ANDconst [c2] x)) + // cond: (uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff) + // result: (REV16 x) + for { + if auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != 8 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARM64ANDconst { + break + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpARM64ANDconst { + break + } + c2 := auxIntToInt64(v_1.AuxInt) + if x != v_1.Args[0] || !(uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff) { + break + } + v.reset(OpARM64REV16) + v.AddArg(x) + return true + } + // match: (ADDshiftLL [8] (SRLconst [8] (ANDconst [c1] x)) (ANDconst [c2] x)) + // cond: (uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff) + // result: (REV16 (ANDconst [0xffffffff] x)) + for { + if auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != 8 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARM64ANDconst { + break + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpARM64ANDconst { + break + } + c2 := auxIntToInt64(v_1.AuxInt) + if x != v_1.Args[0] || !(uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff) { + break + } + v.reset(OpARM64REV16) + v0 := b.NewValue0(v.Pos, OpARM64ANDconst, x.Type) + v0.AuxInt = int64ToAuxInt(0xffffffff) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ADDshiftLL [c] (SRLconst x [64-c]) x2) + // result: (EXTRconst [64-c] x2 x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != 64-c { + break + } + x := v_0.Args[0] + x2 := v_1 + v.reset(OpARM64EXTRconst) + v.AuxInt = int64ToAuxInt(64 - c) + v.AddArg2(x2, x) + return true + } + // match: (ADDshiftLL [c] (UBFX [bfc] x) x2) + // cond: c < 32 && t.Size() == 4 && bfc == armBFAuxInt(32-c, c) + // result: (EXTRWconst [32-c] x2 x) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64UBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + x2 := v_1 + if !(c < 32 && t.Size() == 4 && bfc == armBFAuxInt(32-c, c)) { + break + } + v.reset(OpARM64EXTRWconst) + v.AuxInt = int64ToAuxInt(32 - c) + v.AddArg2(x2, x) + return true + } + return false +} +func rewriteValueARM64_OpARM64ADDshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDshiftRA (MOVDconst [c]) x [d]) + // result: (ADDconst [c] (SRAconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRAconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ADDshiftRA x (MOVDconst [c]) [d]) + // result: (ADDconst x [c>>uint64(d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64ADDshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDshiftRL (MOVDconst [c]) x [d]) + // result: (ADDconst [c] (SRLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ADDshiftRL x (MOVDconst [c]) [d]) + // result: (ADDconst x [int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64AND(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AND x (MOVDconst [c])) + // result: (ANDconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (AND x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (AND x (MVN y)) + // result: (BIC x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MVN { + continue + } + y := v_1.Args[0] + v.reset(OpARM64BIC) + v.AddArg2(x, y) + return true + } + break + } + // match: (AND x0 x1:(SLLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ANDshiftLL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SLLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ANDshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (AND x0 x1:(SRLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ANDshiftRL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ANDshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (AND x0 x1:(SRAconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ANDshiftRA x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRAconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ANDshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (AND x0 x1:(RORconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ANDshiftRO x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64RORconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ANDshiftRO) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64ANDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDconst [0] _) + // result: (MOVDconst [0]) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (ANDconst [-1] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ANDconst [c] (MOVDconst [d])) + // result: (MOVDconst [c&d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(c & d) + return true + } + // match: (ANDconst [c] (ANDconst [d] x)) + // result: (ANDconst [c&d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64ANDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c & d) + v.AddArg(x) + return true + } + // match: (ANDconst [c] (MOVWUreg x)) + // result: (ANDconst [c&(1<<32-1)] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVWUreg { + break + } + x := v_0.Args[0] + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c & (1<<32 - 1)) + v.AddArg(x) + return true + } + // match: (ANDconst [c] (MOVHUreg x)) + // result: (ANDconst [c&(1<<16-1)] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVHUreg { + break + } + x := v_0.Args[0] + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c & (1<<16 - 1)) + v.AddArg(x) + return true + } + // match: (ANDconst [c] (MOVBUreg x)) + // result: (ANDconst [c&(1<<8-1)] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVBUreg { + break + } + x := v_0.Args[0] + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c & (1<<8 - 1)) + v.AddArg(x) + return true + } + // match: (ANDconst [ac] (SLLconst [sc] x)) + // cond: isARM64BFMask(sc, ac, sc) + // result: (UBFIZ [armBFAuxInt(sc, arm64BFWidth(ac, sc))] x) + for { + ac := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SLLconst { + break + } + sc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(isARM64BFMask(sc, ac, sc)) { + break + } + v.reset(OpARM64UBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(sc, arm64BFWidth(ac, sc))) + v.AddArg(x) + return true + } + // match: (ANDconst [ac] (SRLconst [sc] x)) + // cond: isARM64BFMask(sc, ac, 0) + // result: (UBFX [armBFAuxInt(sc, arm64BFWidth(ac, 0))] x) + for { + ac := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRLconst { + break + } + sc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(isARM64BFMask(sc, ac, 0)) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(sc, arm64BFWidth(ac, 0))) + v.AddArg(x) + return true + } + // match: (ANDconst [c] (UBFX [bfc] x)) + // cond: isARM64BFMask(0, c, 0) + // result: (UBFX [armBFAuxInt(bfc.lsb(), min(bfc.width(), arm64BFWidth(c, 0)))] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64UBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(isARM64BFMask(0, c, 0)) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(bfc.lsb(), min(bfc.width(), arm64BFWidth(c, 0)))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64ANDshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ANDshiftLL (MOVDconst [c]) x [d]) + // result: (ANDconst [c] (SLLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ANDshiftLL x (MOVDconst [c]) [d]) + // result: (ANDconst x [int64(uint64(c)< x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRAconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ANDshiftRA x (MOVDconst [c]) [d]) + // result: (ANDconst x [c>>uint64(d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + // match: (ANDshiftRA y:(SRAconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if y.Op != OpARM64SRAconst || auxIntToInt64(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueARM64_OpARM64ANDshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ANDshiftRL (MOVDconst [c]) x [d]) + // result: (ANDconst [c] (SRLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ANDshiftRL x (MOVDconst [c]) [d]) + // result: (ANDconst x [int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (ANDshiftRL y:(SRLconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if y.Op != OpARM64SRLconst || auxIntToInt64(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueARM64_OpARM64ANDshiftRO(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ANDshiftRO (MOVDconst [c]) x [d]) + // result: (ANDconst [c] (RORconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64RORconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ANDshiftRO x (MOVDconst [c]) [d]) + // result: (ANDconst x [rotateRight64(c, d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(rotateRight64(c, d)) + v.AddArg(x) + return true + } + // match: (ANDshiftRO y:(RORconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if y.Op != OpARM64RORconst || auxIntToInt64(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueARM64_OpARM64BIC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (BIC x (MOVDconst [c])) + // result: (ANDconst [^c] x) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(^c) + v.AddArg(x) + return true + } + // match: (BIC x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (BIC x0 x1:(SLLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (BICshiftLL x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SLLconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64BICshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (BIC x0 x1:(SRLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (BICshiftRL x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRLconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64BICshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (BIC x0 x1:(SRAconst [c] y)) + // cond: clobberIfDead(x1) + // result: (BICshiftRA x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRAconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64BICshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (BIC x0 x1:(RORconst [c] y)) + // cond: clobberIfDead(x1) + // result: (BICshiftRO x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64RORconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64BICshiftRO) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64BICshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (BICshiftLL x (MOVDconst [c]) [d]) + // result: (ANDconst x [^int64(uint64(c)<>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(^(c >> uint64(d))) + v.AddArg(x) + return true + } + // match: (BICshiftRA (SRAconst x [c]) x [c]) + // result: (MOVDconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRAconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM64_OpARM64BICshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (BICshiftRL x (MOVDconst [c]) [d]) + // result: (ANDconst x [^int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(^int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (BICshiftRL (SRLconst x [c]) x [c]) + // result: (MOVDconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM64_OpARM64BICshiftRO(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (BICshiftRO x (MOVDconst [c]) [d]) + // result: (ANDconst x [^rotateRight64(c, d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(^rotateRight64(c, d)) + v.AddArg(x) + return true + } + // match: (BICshiftRO (RORconst x [c]) x [c]) + // result: (MOVDconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64RORconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM64_OpARM64CMN(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMN x (MOVDconst [c])) + // result: (CMNconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64CMNconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (CMN x0 x1:(SLLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (CMNshiftLL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SLLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64CMNshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (CMN x0 x1:(SRLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (CMNshiftRL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64CMNshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (CMN x0 x1:(SRAconst [c] y)) + // cond: clobberIfDead(x1) + // result: (CMNshiftRA x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRAconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64CMNshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64CMNW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMNW x (MOVDconst [c])) + // result: (CMNWconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64CMNWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64CMNWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMNWconst [c] y) + // cond: c < 0 && c != -1<<31 + // result: (CMPWconst [-c] y) + for { + c := auxIntToInt32(v.AuxInt) + y := v_0 + if !(c < 0 && c != -1<<31) { + break + } + v.reset(OpARM64CMPWconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(y) + return true + } + // match: (CMNWconst (MOVDconst [x]) [y]) + // result: (FlagConstant [addFlags32(int32(x),y)]) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(addFlags32(int32(x), y)) + return true + } + return false +} +func rewriteValueARM64_OpARM64CMNconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMNconst [c] y) + // cond: c < 0 && c != -1<<63 + // result: (CMPconst [-c] y) + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if !(c < 0 && c != -1<<63) { + break + } + v.reset(OpARM64CMPconst) + v.AuxInt = int64ToAuxInt(-c) + v.AddArg(y) + return true + } + // match: (CMNconst (MOVDconst [x]) [y]) + // result: (FlagConstant [addFlags64(x,y)]) + for { + y := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(addFlags64(x, y)) + return true + } + return false +} +func rewriteValueARM64_OpARM64CMNshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMNshiftLL (MOVDconst [c]) x [d]) + // result: (CMNconst [c] (SLLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64CMNconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMNshiftLL x (MOVDconst [c]) [d]) + // result: (CMNconst x [int64(uint64(c)< x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64CMNconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRAconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMNshiftRA x (MOVDconst [c]) [d]) + // result: (CMNconst x [c>>uint64(d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64CMNconst) + v.AuxInt = int64ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64CMNshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMNshiftRL (MOVDconst [c]) x [d]) + // result: (CMNconst [c] (SRLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64CMNconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMNshiftRL x (MOVDconst [c]) [d]) + // result: (CMNconst x [int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64CMNconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64CMP(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMP x (MOVDconst [c])) + // result: (CMPconst [c] x) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64CMPconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMP (MOVDconst [c]) x) + // result: (InvertFlags (CMPconst [c] x)) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMP x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMP y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + // match: (CMP x0 x1:(SLLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (CMPshiftLL x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SLLconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64CMPshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (CMP x0:(SLLconst [c] y) x1) + // cond: clobberIfDead(x0) + // result: (InvertFlags (CMPshiftLL x1 y [c])) + for { + x0 := v_0 + if x0.Op != OpARM64SLLconst { + break + } + c := auxIntToInt64(x0.AuxInt) + y := x0.Args[0] + x1 := v_1 + if !(clobberIfDead(x0)) { + break + } + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64CMPshiftLL, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg2(x1, y) + v.AddArg(v0) + return true + } + // match: (CMP x0 x1:(SRLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (CMPshiftRL x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRLconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64CMPshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (CMP x0:(SRLconst [c] y) x1) + // cond: clobberIfDead(x0) + // result: (InvertFlags (CMPshiftRL x1 y [c])) + for { + x0 := v_0 + if x0.Op != OpARM64SRLconst { + break + } + c := auxIntToInt64(x0.AuxInt) + y := x0.Args[0] + x1 := v_1 + if !(clobberIfDead(x0)) { + break + } + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64CMPshiftRL, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg2(x1, y) + v.AddArg(v0) + return true + } + // match: (CMP x0 x1:(SRAconst [c] y)) + // cond: clobberIfDead(x1) + // result: (CMPshiftRA x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRAconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64CMPshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (CMP x0:(SRAconst [c] y) x1) + // cond: clobberIfDead(x0) + // result: (InvertFlags (CMPshiftRA x1 y [c])) + for { + x0 := v_0 + if x0.Op != OpARM64SRAconst { + break + } + c := auxIntToInt64(x0.AuxInt) + y := x0.Args[0] + x1 := v_1 + if !(clobberIfDead(x0)) { + break + } + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64CMPshiftRA, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg2(x1, y) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM64_OpARM64CMPW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPW x (MOVDconst [c])) + // result: (CMPWconst [int32(c)] x) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64CMPWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (CMPW (MOVDconst [c]) x) + // result: (InvertFlags (CMPWconst [int32(c)] x)) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64CMPWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMPW x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPW y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM64_OpARM64CMPWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPWconst [c] y) + // cond: c < 0 && c != -1<<31 + // result: (CMNWconst [-c] y) + for { + c := auxIntToInt32(v.AuxInt) + y := v_0 + if !(c < 0 && c != -1<<31) { + break + } + v.reset(OpARM64CMNWconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(y) + return true + } + // match: (CMPWconst (MOVDconst [x]) [y]) + // result: (FlagConstant [subFlags32(int32(x),y)]) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags32(int32(x), y)) + return true + } + // match: (CMPWconst (MOVBUreg _) [c]) + // cond: 0xff < c + // result: (FlagConstant [subFlags64(0,1)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARM64MOVBUreg || !(0xff < c) { + break + } + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags64(0, 1)) + return true + } + // match: (CMPWconst (MOVHUreg _) [c]) + // cond: 0xffff < c + // result: (FlagConstant [subFlags64(0,1)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARM64MOVHUreg || !(0xffff < c) { + break + } + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags64(0, 1)) + return true + } + return false +} +func rewriteValueARM64_OpARM64CMPconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPconst [c] y) + // cond: c < 0 && c != -1<<63 + // result: (CMNconst [-c] y) + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if !(c < 0 && c != -1<<63) { + break + } + v.reset(OpARM64CMNconst) + v.AuxInt = int64ToAuxInt(-c) + v.AddArg(y) + return true + } + // match: (CMPconst (MOVDconst [x]) [y]) + // result: (FlagConstant [subFlags64(x,y)]) + for { + y := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags64(x, y)) + return true + } + // match: (CMPconst (MOVBUreg _) [c]) + // cond: 0xff < c + // result: (FlagConstant [subFlags64(0,1)]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVBUreg || !(0xff < c) { + break + } + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags64(0, 1)) + return true + } + // match: (CMPconst (MOVHUreg _) [c]) + // cond: 0xffff < c + // result: (FlagConstant [subFlags64(0,1)]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVHUreg || !(0xffff < c) { + break + } + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags64(0, 1)) + return true + } + // match: (CMPconst (MOVWUreg _) [c]) + // cond: 0xffffffff < c + // result: (FlagConstant [subFlags64(0,1)]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVWUreg || !(0xffffffff < c) { + break + } + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags64(0, 1)) + return true + } + // match: (CMPconst (ANDconst _ [m]) [n]) + // cond: 0 <= m && m < n + // result: (FlagConstant [subFlags64(0,1)]) + for { + n := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64ANDconst { + break + } + m := auxIntToInt64(v_0.AuxInt) + if !(0 <= m && m < n) { + break + } + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(subFlags64(0, 1)) + return true + } + // match: (CMPconst (SRLconst _ [c]) [n]) + // cond: 0 <= n && 0 < c && c <= 63 && (1< x [d]))) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v1.AuxInt = int64ToAuxInt(d) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (CMPshiftLL x (MOVDconst [c]) [d]) + // result: (CMPconst x [int64(uint64(c)< x [d]))) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARM64SRAconst, x.Type) + v1.AuxInt = int64ToAuxInt(d) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (CMPshiftRA x (MOVDconst [c]) [d]) + // result: (CMPconst x [c>>uint64(d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64CMPconst) + v.AuxInt = int64ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64CMPshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPshiftRL (MOVDconst [c]) x [d]) + // result: (InvertFlags (CMPconst [c] (SRLconst x [d]))) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARM64SRLconst, x.Type) + v1.AuxInt = int64ToAuxInt(d) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (CMPshiftRL x (MOVDconst [c]) [d]) + // result: (CMPconst x [int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64CMPconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64CSEL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CSEL [cc] (MOVDconst [-1]) (MOVDconst [0]) flag) + // result: (CSETM [cc] flag) + for { + cc := auxIntToOp(v.AuxInt) + if v_0.Op != OpARM64MOVDconst || auxIntToInt64(v_0.AuxInt) != -1 || v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + flag := v_2 + v.reset(OpARM64CSETM) + v.AuxInt = opToAuxInt(cc) + v.AddArg(flag) + return true + } + // match: (CSEL [cc] (MOVDconst [0]) (MOVDconst [-1]) flag) + // result: (CSETM [arm64Negate(cc)] flag) + for { + cc := auxIntToOp(v.AuxInt) + if v_0.Op != OpARM64MOVDconst || auxIntToInt64(v_0.AuxInt) != 0 || v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != -1 { + break + } + flag := v_2 + v.reset(OpARM64CSETM) + v.AuxInt = opToAuxInt(arm64Negate(cc)) + v.AddArg(flag) + return true + } + // match: (CSEL [cc] x (MOVDconst [0]) flag) + // result: (CSEL0 [cc] x flag) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + flag := v_2 + v.reset(OpARM64CSEL0) + v.AuxInt = opToAuxInt(cc) + v.AddArg2(x, flag) + return true + } + // match: (CSEL [cc] (MOVDconst [0]) y flag) + // result: (CSEL0 [arm64Negate(cc)] y flag) + for { + cc := auxIntToOp(v.AuxInt) + if v_0.Op != OpARM64MOVDconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + y := v_1 + flag := v_2 + v.reset(OpARM64CSEL0) + v.AuxInt = opToAuxInt(arm64Negate(cc)) + v.AddArg2(y, flag) + return true + } + // match: (CSEL [cc] x (ADDconst [1] a) flag) + // result: (CSINC [cc] x a flag) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64ADDconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + a := v_1.Args[0] + flag := v_2 + v.reset(OpARM64CSINC) + v.AuxInt = opToAuxInt(cc) + v.AddArg3(x, a, flag) + return true + } + // match: (CSEL [cc] (ADDconst [1] a) x flag) + // result: (CSINC [arm64Negate(cc)] x a flag) + for { + cc := auxIntToOp(v.AuxInt) + if v_0.Op != OpARM64ADDconst || auxIntToInt64(v_0.AuxInt) != 1 { + break + } + a := v_0.Args[0] + x := v_1 + flag := v_2 + v.reset(OpARM64CSINC) + v.AuxInt = opToAuxInt(arm64Negate(cc)) + v.AddArg3(x, a, flag) + return true + } + // match: (CSEL [cc] x (MVN a) flag) + // result: (CSINV [cc] x a flag) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MVN { + break + } + a := v_1.Args[0] + flag := v_2 + v.reset(OpARM64CSINV) + v.AuxInt = opToAuxInt(cc) + v.AddArg3(x, a, flag) + return true + } + // match: (CSEL [cc] (MVN a) x flag) + // result: (CSINV [arm64Negate(cc)] x a flag) + for { + cc := auxIntToOp(v.AuxInt) + if v_0.Op != OpARM64MVN { + break + } + a := v_0.Args[0] + x := v_1 + flag := v_2 + v.reset(OpARM64CSINV) + v.AuxInt = opToAuxInt(arm64Negate(cc)) + v.AddArg3(x, a, flag) + return true + } + // match: (CSEL [cc] x (NEG a) flag) + // result: (CSNEG [cc] x a flag) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64NEG { + break + } + a := v_1.Args[0] + flag := v_2 + v.reset(OpARM64CSNEG) + v.AuxInt = opToAuxInt(cc) + v.AddArg3(x, a, flag) + return true + } + // match: (CSEL [cc] (NEG a) x flag) + // result: (CSNEG [arm64Negate(cc)] x a flag) + for { + cc := auxIntToOp(v.AuxInt) + if v_0.Op != OpARM64NEG { + break + } + a := v_0.Args[0] + x := v_1 + flag := v_2 + v.reset(OpARM64CSNEG) + v.AuxInt = opToAuxInt(arm64Negate(cc)) + v.AddArg3(x, a, flag) + return true + } + // match: (CSEL [cc] x y (InvertFlags cmp)) + // result: (CSEL [arm64Invert(cc)] x y cmp) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + y := v_1 + if v_2.Op != OpARM64InvertFlags { + break + } + cmp := v_2.Args[0] + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(arm64Invert(cc)) + v.AddArg3(x, y, cmp) + return true + } + // match: (CSEL [cc] x _ flag) + // cond: ccARM64Eval(cc, flag) > 0 + // result: x + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + flag := v_2 + if !(ccARM64Eval(cc, flag) > 0) { + break + } + v.copyOf(x) + return true + } + // match: (CSEL [cc] _ y flag) + // cond: ccARM64Eval(cc, flag) < 0 + // result: y + for { + cc := auxIntToOp(v.AuxInt) + y := v_1 + flag := v_2 + if !(ccARM64Eval(cc, flag) < 0) { + break + } + v.copyOf(y) + return true + } + // match: (CSEL [cc] x y (CMPWconst [0] boolval)) + // cond: cc == OpARM64NotEqual && flagArg(boolval) != nil + // result: (CSEL [boolval.Op] x y flagArg(boolval)) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + y := v_1 + if v_2.Op != OpARM64CMPWconst || auxIntToInt32(v_2.AuxInt) != 0 { + break + } + boolval := v_2.Args[0] + if !(cc == OpARM64NotEqual && flagArg(boolval) != nil) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(boolval.Op) + v.AddArg3(x, y, flagArg(boolval)) + return true + } + // match: (CSEL [cc] x y (CMPWconst [0] boolval)) + // cond: cc == OpARM64Equal && flagArg(boolval) != nil + // result: (CSEL [arm64Negate(boolval.Op)] x y flagArg(boolval)) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + y := v_1 + if v_2.Op != OpARM64CMPWconst || auxIntToInt32(v_2.AuxInt) != 0 { + break + } + boolval := v_2.Args[0] + if !(cc == OpARM64Equal && flagArg(boolval) != nil) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(arm64Negate(boolval.Op)) + v.AddArg3(x, y, flagArg(boolval)) + return true + } + return false +} +func rewriteValueARM64_OpARM64CSEL0(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CSEL0 [cc] x (InvertFlags cmp)) + // result: (CSEL0 [arm64Invert(cc)] x cmp) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64InvertFlags { + break + } + cmp := v_1.Args[0] + v.reset(OpARM64CSEL0) + v.AuxInt = opToAuxInt(arm64Invert(cc)) + v.AddArg2(x, cmp) + return true + } + // match: (CSEL0 [cc] x flag) + // cond: ccARM64Eval(cc, flag) > 0 + // result: x + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + flag := v_1 + if !(ccARM64Eval(cc, flag) > 0) { + break + } + v.copyOf(x) + return true + } + // match: (CSEL0 [cc] _ flag) + // cond: ccARM64Eval(cc, flag) < 0 + // result: (MOVDconst [0]) + for { + cc := auxIntToOp(v.AuxInt) + flag := v_1 + if !(ccARM64Eval(cc, flag) < 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (CSEL0 [cc] x (CMPWconst [0] boolval)) + // cond: cc == OpARM64NotEqual && flagArg(boolval) != nil + // result: (CSEL0 [boolval.Op] x flagArg(boolval)) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64CMPWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + boolval := v_1.Args[0] + if !(cc == OpARM64NotEqual && flagArg(boolval) != nil) { + break + } + v.reset(OpARM64CSEL0) + v.AuxInt = opToAuxInt(boolval.Op) + v.AddArg2(x, flagArg(boolval)) + return true + } + // match: (CSEL0 [cc] x (CMPWconst [0] boolval)) + // cond: cc == OpARM64Equal && flagArg(boolval) != nil + // result: (CSEL0 [arm64Negate(boolval.Op)] x flagArg(boolval)) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64CMPWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + boolval := v_1.Args[0] + if !(cc == OpARM64Equal && flagArg(boolval) != nil) { + break + } + v.reset(OpARM64CSEL0) + v.AuxInt = opToAuxInt(arm64Negate(boolval.Op)) + v.AddArg2(x, flagArg(boolval)) + return true + } + return false +} +func rewriteValueARM64_OpARM64CSETM(v *Value) bool { + v_0 := v.Args[0] + // match: (CSETM [cc] (InvertFlags cmp)) + // result: (CSETM [arm64Invert(cc)] cmp) + for { + cc := auxIntToOp(v.AuxInt) + if v_0.Op != OpARM64InvertFlags { + break + } + cmp := v_0.Args[0] + v.reset(OpARM64CSETM) + v.AuxInt = opToAuxInt(arm64Invert(cc)) + v.AddArg(cmp) + return true + } + // match: (CSETM [cc] flag) + // cond: ccARM64Eval(cc, flag) > 0 + // result: (MOVDconst [-1]) + for { + cc := auxIntToOp(v.AuxInt) + flag := v_0 + if !(ccARM64Eval(cc, flag) > 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (CSETM [cc] flag) + // cond: ccARM64Eval(cc, flag) < 0 + // result: (MOVDconst [0]) + for { + cc := auxIntToOp(v.AuxInt) + flag := v_0 + if !(ccARM64Eval(cc, flag) < 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM64_OpARM64CSINC(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CSINC [cc] x y (InvertFlags cmp)) + // result: (CSINC [arm64Invert(cc)] x y cmp) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + y := v_1 + if v_2.Op != OpARM64InvertFlags { + break + } + cmp := v_2.Args[0] + v.reset(OpARM64CSINC) + v.AuxInt = opToAuxInt(arm64Invert(cc)) + v.AddArg3(x, y, cmp) + return true + } + // match: (CSINC [cc] x _ flag) + // cond: ccARM64Eval(cc, flag) > 0 + // result: x + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + flag := v_2 + if !(ccARM64Eval(cc, flag) > 0) { + break + } + v.copyOf(x) + return true + } + // match: (CSINC [cc] _ y flag) + // cond: ccARM64Eval(cc, flag) < 0 + // result: (ADDconst [1] y) + for { + cc := auxIntToOp(v.AuxInt) + y := v_1 + flag := v_2 + if !(ccARM64Eval(cc, flag) < 0) { + break + } + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(1) + v.AddArg(y) + return true + } + return false +} +func rewriteValueARM64_OpARM64CSINV(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CSINV [cc] x y (InvertFlags cmp)) + // result: (CSINV [arm64Invert(cc)] x y cmp) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + y := v_1 + if v_2.Op != OpARM64InvertFlags { + break + } + cmp := v_2.Args[0] + v.reset(OpARM64CSINV) + v.AuxInt = opToAuxInt(arm64Invert(cc)) + v.AddArg3(x, y, cmp) + return true + } + // match: (CSINV [cc] x _ flag) + // cond: ccARM64Eval(cc, flag) > 0 + // result: x + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + flag := v_2 + if !(ccARM64Eval(cc, flag) > 0) { + break + } + v.copyOf(x) + return true + } + // match: (CSINV [cc] _ y flag) + // cond: ccARM64Eval(cc, flag) < 0 + // result: (Not y) + for { + cc := auxIntToOp(v.AuxInt) + y := v_1 + flag := v_2 + if !(ccARM64Eval(cc, flag) < 0) { + break + } + v.reset(OpNot) + v.AddArg(y) + return true + } + return false +} +func rewriteValueARM64_OpARM64CSNEG(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CSNEG [cc] x y (InvertFlags cmp)) + // result: (CSNEG [arm64Invert(cc)] x y cmp) + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + y := v_1 + if v_2.Op != OpARM64InvertFlags { + break + } + cmp := v_2.Args[0] + v.reset(OpARM64CSNEG) + v.AuxInt = opToAuxInt(arm64Invert(cc)) + v.AddArg3(x, y, cmp) + return true + } + // match: (CSNEG [cc] x _ flag) + // cond: ccARM64Eval(cc, flag) > 0 + // result: x + for { + cc := auxIntToOp(v.AuxInt) + x := v_0 + flag := v_2 + if !(ccARM64Eval(cc, flag) > 0) { + break + } + v.copyOf(x) + return true + } + // match: (CSNEG [cc] _ y flag) + // cond: ccARM64Eval(cc, flag) < 0 + // result: (NEG y) + for { + cc := auxIntToOp(v.AuxInt) + y := v_1 + flag := v_2 + if !(ccARM64Eval(cc, flag) < 0) { + break + } + v.reset(OpARM64NEG) + v.AddArg(y) + return true + } + return false +} +func rewriteValueARM64_OpARM64DIV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (DIV (MOVDconst [c]) (MOVDconst [d])) + // cond: d != 0 + // result: (MOVDconst [c/d]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(c / d) + return true + } + return false +} +func rewriteValueARM64_OpARM64DIVW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (DIVW (MOVDconst [c]) (MOVDconst [d])) + // cond: d != 0 + // result: (MOVDconst [int64(uint32(int32(c)/int32(d)))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint32(int32(c) / int32(d)))) + return true + } + return false +} +func rewriteValueARM64_OpARM64EON(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (EON x (MOVDconst [c])) + // result: (XORconst [^c] x) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(^c) + v.AddArg(x) + return true + } + // match: (EON x x) + // result: (MOVDconst [-1]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (EON x0 x1:(SLLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (EONshiftLL x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SLLconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64EONshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (EON x0 x1:(SRLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (EONshiftRL x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRLconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64EONshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (EON x0 x1:(SRAconst [c] y)) + // cond: clobberIfDead(x1) + // result: (EONshiftRA x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRAconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64EONshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (EON x0 x1:(RORconst [c] y)) + // cond: clobberIfDead(x1) + // result: (EONshiftRO x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64RORconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64EONshiftRO) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64EONshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (EONshiftLL x (MOVDconst [c]) [d]) + // result: (XORconst x [^int64(uint64(c)<>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(^(c >> uint64(d))) + v.AddArg(x) + return true + } + // match: (EONshiftRA (SRAconst x [c]) x [c]) + // result: (MOVDconst [-1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRAconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + return false +} +func rewriteValueARM64_OpARM64EONshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (EONshiftRL x (MOVDconst [c]) [d]) + // result: (XORconst x [^int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(^int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (EONshiftRL (SRLconst x [c]) x [c]) + // result: (MOVDconst [-1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + return false +} +func rewriteValueARM64_OpARM64EONshiftRO(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (EONshiftRO x (MOVDconst [c]) [d]) + // result: (XORconst x [^rotateRight64(c, d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(^rotateRight64(c, d)) + v.AddArg(x) + return true + } + // match: (EONshiftRO (RORconst x [c]) x [c]) + // result: (MOVDconst [-1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64RORconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + return false +} +func rewriteValueARM64_OpARM64Equal(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Equal (CMPconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (Equal (TST x y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (Equal (CMPWconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (Equal (TSTWconst [int32(c)] y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (Equal (CMPWconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (Equal (TSTW x y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (Equal (CMPconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (Equal (TSTconst [c] y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (Equal (CMP x z:(NEG y))) + // cond: z.Uses == 1 + // result: (Equal (CMN x y)) + for { + if v_0.Op != OpARM64CMP { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpARM64NEG { + break + } + y := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (Equal (CMPW x z:(NEG y))) + // cond: z.Uses == 1 + // result: (Equal (CMNW x y)) + for { + if v_0.Op != OpARM64CMPW { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpARM64NEG { + break + } + y := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (Equal (CMPconst [0] x:(ADDconst [c] y))) + // cond: x.Uses == 1 + // result: (Equal (CMNconst [c] y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMNconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (Equal (CMPWconst [0] x:(ADDconst [c] y))) + // cond: x.Uses == 1 + // result: (Equal (CMNWconst [int32(c)] y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMNWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (Equal (CMPconst [0] z:(ADD x y))) + // cond: z.Uses == 1 + // result: (Equal (CMN x y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (Equal (CMPWconst [0] z:(ADD x y))) + // cond: z.Uses == 1 + // result: (Equal (CMNW x y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (Equal (CMPconst [0] z:(MADD a x y))) + // cond: z.Uses == 1 + // result: (Equal (CMN a (MUL x y))) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADD { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMN, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (Equal (CMPconst [0] z:(MSUB a x y))) + // cond: z.Uses == 1 + // result: (Equal (CMP a (MUL x y))) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUB { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (Equal (CMPWconst [0] z:(MADDW a x y))) + // cond: z.Uses == 1 + // result: (Equal (CMNW a (MULW x y))) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADDW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMNW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (Equal (CMPWconst [0] z:(MSUBW a x y))) + // cond: z.Uses == 1 + // result: (Equal (CMPW a (MULW x y))) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUBW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (Equal (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.eq())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.eq())) + return true + } + // match: (Equal (InvertFlags x)) + // result: (Equal x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64Equal) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64FADDD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FADDD a (FMULD x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FMADDD a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if v_1.Op != OpARM64FMULD { + continue + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + continue + } + v.reset(OpARM64FMADDD) + v.AddArg3(a, x, y) + return true + } + break + } + // match: (FADDD a (FNMULD x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FMSUBD a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if v_1.Op != OpARM64FNMULD { + continue + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + continue + } + v.reset(OpARM64FMSUBD) + v.AddArg3(a, x, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64FADDS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FADDS a (FMULS x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FMADDS a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if v_1.Op != OpARM64FMULS { + continue + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + continue + } + v.reset(OpARM64FMADDS) + v.AddArg3(a, x, y) + return true + } + break + } + // match: (FADDS a (FNMULS x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FMSUBS a x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if v_1.Op != OpARM64FNMULS { + continue + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + continue + } + v.reset(OpARM64FMSUBS) + v.AddArg3(a, x, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64FCMPD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (FCMPD x (FMOVDconst [0])) + // result: (FCMPD0 x) + for { + x := v_0 + if v_1.Op != OpARM64FMOVDconst || auxIntToFloat64(v_1.AuxInt) != 0 { + break + } + v.reset(OpARM64FCMPD0) + v.AddArg(x) + return true + } + // match: (FCMPD (FMOVDconst [0]) x) + // result: (InvertFlags (FCMPD0 x)) + for { + if v_0.Op != OpARM64FMOVDconst || auxIntToFloat64(v_0.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64FCMPD0, types.TypeFlags) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM64_OpARM64FCMPS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (FCMPS x (FMOVSconst [0])) + // result: (FCMPS0 x) + for { + x := v_0 + if v_1.Op != OpARM64FMOVSconst || auxIntToFloat64(v_1.AuxInt) != 0 { + break + } + v.reset(OpARM64FCMPS0) + v.AddArg(x) + return true + } + // match: (FCMPS (FMOVSconst [0]) x) + // result: (InvertFlags (FCMPS0 x)) + for { + if v_0.Op != OpARM64FMOVSconst || auxIntToFloat64(v_0.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpARM64InvertFlags) + v0 := b.NewValue0(v.Pos, OpARM64FCMPS0, types.TypeFlags) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVDfpgp(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (FMOVDfpgp (Arg [off] {sym})) + // result: @b.Func.Entry (Arg [off] {sym}) + for { + t := v.Type + if v_0.Op != OpArg { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + b = b.Func.Entry + v0 := b.NewValue0(v.Pos, OpArg, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVDgpfp(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (FMOVDgpfp (Arg [off] {sym})) + // result: @b.Func.Entry (Arg [off] {sym}) + for { + t := v.Type + if v_0.Op != OpArg { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + b = b.Func.Entry + v0 := b.NewValue0(v.Pos, OpArg, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (FMOVDload [off] {sym} ptr (MOVDstore [off] {sym} ptr val _)) + // result: (FMOVDgpfp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpARM64FMOVDgpfp) + v.AddArg(val) + return true + } + // match: (FMOVDload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVDload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64FMOVDload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (FMOVDload [off] {sym} (ADD ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (FMOVDloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64FMOVDloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (FMOVDload [off] {sym} (ADDshiftLL [3] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (FMOVDloadidx8 ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 3 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64FMOVDloadidx8) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (FMOVDload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64FMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVDloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVDloadidx ptr (MOVDconst [c]) mem) + // cond: is32Bit(c) + // result: (FMOVDload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64FMOVDload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (FMOVDloadidx (MOVDconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (FMOVDload [int32(c)] ptr mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64FMOVDload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (FMOVDloadidx ptr (SLLconst [3] idx) mem) + // result: (FMOVDloadidx8 ptr idx mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 3 { + break + } + idx := v_1.Args[0] + mem := v_2 + v.reset(OpARM64FMOVDloadidx8) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (FMOVDloadidx (SLLconst [3] idx) ptr mem) + // result: (FMOVDloadidx8 ptr idx mem) + for { + if v_0.Op != OpARM64SLLconst || auxIntToInt64(v_0.AuxInt) != 3 { + break + } + idx := v_0.Args[0] + ptr := v_1 + mem := v_2 + v.reset(OpARM64FMOVDloadidx8) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVDloadidx8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVDloadidx8 ptr (MOVDconst [c]) mem) + // cond: is32Bit(c<<3) + // result: (FMOVDload ptr [int32(c)<<3] mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c << 3)) { + break + } + v.reset(OpARM64FMOVDload) + v.AuxInt = int32ToAuxInt(int32(c) << 3) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (FMOVDstore [off] {sym} ptr (FMOVDgpfp val) mem) + // result: (MOVDstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64FMOVDgpfp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (FMOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVDstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64FMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (FMOVDstore [off] {sym} (ADD ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (FMOVDstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64FMOVDstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (FMOVDstore [off] {sym} (ADDshiftLL [3] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (FMOVDstoreidx8 ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 3 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64FMOVDstoreidx8) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (FMOVDstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64FMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVDstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVDstoreidx ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c) + // result: (FMOVDstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64FMOVDstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (FMOVDstoreidx (MOVDconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (FMOVDstore [int32(c)] idx val mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64FMOVDstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + // match: (FMOVDstoreidx ptr (SLLconst [3] idx) val mem) + // result: (FMOVDstoreidx8 ptr idx val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 3 { + break + } + idx := v_1.Args[0] + val := v_2 + mem := v_3 + v.reset(OpARM64FMOVDstoreidx8) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (FMOVDstoreidx (SLLconst [3] idx) ptr val mem) + // result: (FMOVDstoreidx8 ptr idx val mem) + for { + if v_0.Op != OpARM64SLLconst || auxIntToInt64(v_0.AuxInt) != 3 { + break + } + idx := v_0.Args[0] + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARM64FMOVDstoreidx8) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVDstoreidx8(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVDstoreidx8 ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c<<3) + // result: (FMOVDstore [int32(c)<<3] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c << 3)) { + break + } + v.reset(OpARM64FMOVDstore) + v.AuxInt = int32ToAuxInt(int32(c) << 3) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVSload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (FMOVSload [off] {sym} ptr (MOVWstore [off] {sym} ptr val _)) + // result: (FMOVSgpfp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpARM64FMOVSgpfp) + v.AddArg(val) + return true + } + // match: (FMOVSload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVSload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64FMOVSload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (FMOVSload [off] {sym} (ADD ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (FMOVSloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64FMOVSloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (FMOVSload [off] {sym} (ADDshiftLL [2] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (FMOVSloadidx4 ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 2 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64FMOVSloadidx4) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (FMOVSload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVSload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64FMOVSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVSloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVSloadidx ptr (MOVDconst [c]) mem) + // cond: is32Bit(c) + // result: (FMOVSload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64FMOVSload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (FMOVSloadidx (MOVDconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (FMOVSload [int32(c)] ptr mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64FMOVSload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (FMOVSloadidx ptr (SLLconst [2] idx) mem) + // result: (FMOVSloadidx4 ptr idx mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 2 { + break + } + idx := v_1.Args[0] + mem := v_2 + v.reset(OpARM64FMOVSloadidx4) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (FMOVSloadidx (SLLconst [2] idx) ptr mem) + // result: (FMOVSloadidx4 ptr idx mem) + for { + if v_0.Op != OpARM64SLLconst || auxIntToInt64(v_0.AuxInt) != 2 { + break + } + idx := v_0.Args[0] + ptr := v_1 + mem := v_2 + v.reset(OpARM64FMOVSloadidx4) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVSloadidx4(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVSloadidx4 ptr (MOVDconst [c]) mem) + // cond: is32Bit(c<<2) + // result: (FMOVSload ptr [int32(c)<<2] mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c << 2)) { + break + } + v.reset(OpARM64FMOVSload) + v.AuxInt = int32ToAuxInt(int32(c) << 2) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVSstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (FMOVSstore [off] {sym} ptr (FMOVSgpfp val) mem) + // result: (MOVWstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64FMOVSgpfp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (FMOVSstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVSstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64FMOVSstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (FMOVSstore [off] {sym} (ADD ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (FMOVSstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64FMOVSstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (FMOVSstore [off] {sym} (ADDshiftLL [2] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (FMOVSstoreidx4 ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 2 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64FMOVSstoreidx4) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (FMOVSstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVSstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64FMOVSstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVSstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVSstoreidx ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c) + // result: (FMOVSstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64FMOVSstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (FMOVSstoreidx (MOVDconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (FMOVSstore [int32(c)] idx val mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64FMOVSstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + // match: (FMOVSstoreidx ptr (SLLconst [2] idx) val mem) + // result: (FMOVSstoreidx4 ptr idx val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 2 { + break + } + idx := v_1.Args[0] + val := v_2 + mem := v_3 + v.reset(OpARM64FMOVSstoreidx4) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (FMOVSstoreidx (SLLconst [2] idx) ptr val mem) + // result: (FMOVSstoreidx4 ptr idx val mem) + for { + if v_0.Op != OpARM64SLLconst || auxIntToInt64(v_0.AuxInt) != 2 { + break + } + idx := v_0.Args[0] + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARM64FMOVSstoreidx4) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMOVSstoreidx4(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVSstoreidx4 ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c<<2) + // result: (FMOVSstore [int32(c)<<2] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c << 2)) { + break + } + v.reset(OpARM64FMOVSstore) + v.AuxInt = int32ToAuxInt(int32(c) << 2) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64FMULD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMULD (FNEGD x) y) + // result: (FNMULD x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARM64FNEGD { + continue + } + x := v_0.Args[0] + y := v_1 + v.reset(OpARM64FNMULD) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64FMULS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMULS (FNEGS x) y) + // result: (FNMULS x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARM64FNEGS { + continue + } + x := v_0.Args[0] + y := v_1 + v.reset(OpARM64FNMULS) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64FNEGD(v *Value) bool { + v_0 := v.Args[0] + // match: (FNEGD (FMULD x y)) + // result: (FNMULD x y) + for { + if v_0.Op != OpARM64FMULD { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64FNMULD) + v.AddArg2(x, y) + return true + } + // match: (FNEGD (FNMULD x y)) + // result: (FMULD x y) + for { + if v_0.Op != OpARM64FNMULD { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64FMULD) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64FNEGS(v *Value) bool { + v_0 := v.Args[0] + // match: (FNEGS (FMULS x y)) + // result: (FNMULS x y) + for { + if v_0.Op != OpARM64FMULS { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64FNMULS) + v.AddArg2(x, y) + return true + } + // match: (FNEGS (FNMULS x y)) + // result: (FMULS x y) + for { + if v_0.Op != OpARM64FNMULS { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64FMULS) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64FNMULD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FNMULD (FNEGD x) y) + // result: (FMULD x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARM64FNEGD { + continue + } + x := v_0.Args[0] + y := v_1 + v.reset(OpARM64FMULD) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64FNMULS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FNMULS (FNEGS x) y) + // result: (FMULS x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARM64FNEGS { + continue + } + x := v_0.Args[0] + y := v_1 + v.reset(OpARM64FMULS) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64FSUBD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FSUBD a (FMULD x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FMSUBD a x y) + for { + a := v_0 + if v_1.Op != OpARM64FMULD { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpARM64FMSUBD) + v.AddArg3(a, x, y) + return true + } + // match: (FSUBD (FMULD x y) a) + // cond: a.Block.Func.useFMA(v) + // result: (FNMSUBD a x y) + for { + if v_0.Op != OpARM64FMULD { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + a := v_1 + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpARM64FNMSUBD) + v.AddArg3(a, x, y) + return true + } + // match: (FSUBD a (FNMULD x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FMADDD a x y) + for { + a := v_0 + if v_1.Op != OpARM64FNMULD { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpARM64FMADDD) + v.AddArg3(a, x, y) + return true + } + // match: (FSUBD (FNMULD x y) a) + // cond: a.Block.Func.useFMA(v) + // result: (FNMADDD a x y) + for { + if v_0.Op != OpARM64FNMULD { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + a := v_1 + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpARM64FNMADDD) + v.AddArg3(a, x, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64FSUBS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FSUBS a (FMULS x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FMSUBS a x y) + for { + a := v_0 + if v_1.Op != OpARM64FMULS { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpARM64FMSUBS) + v.AddArg3(a, x, y) + return true + } + // match: (FSUBS (FMULS x y) a) + // cond: a.Block.Func.useFMA(v) + // result: (FNMSUBS a x y) + for { + if v_0.Op != OpARM64FMULS { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + a := v_1 + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpARM64FNMSUBS) + v.AddArg3(a, x, y) + return true + } + // match: (FSUBS a (FNMULS x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FMADDS a x y) + for { + a := v_0 + if v_1.Op != OpARM64FNMULS { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpARM64FMADDS) + v.AddArg3(a, x, y) + return true + } + // match: (FSUBS (FNMULS x y) a) + // cond: a.Block.Func.useFMA(v) + // result: (FNMADDS a x y) + for { + if v_0.Op != OpARM64FNMULS { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + a := v_1 + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpARM64FNMADDS) + v.AddArg3(a, x, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64GreaterEqual(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (GreaterEqual (CMPconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (GreaterEqual (TST x y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqual) + v0 := b.NewValue0(v.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPWconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (GreaterEqual (TSTWconst [int32(c)] y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqual) + v0 := b.NewValue0(v.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPWconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (GreaterEqual (TSTW x y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqual) + v0 := b.NewValue0(v.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (GreaterEqual (TSTconst [c] y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqual) + v0 := b.NewValue0(v.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPconst [0] x:(ADDconst [c] y))) + // cond: x.Uses == 1 + // result: (GreaterEqualNoov (CMNconst [c] y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqualNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMNconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPWconst [0] x:(ADDconst [c] y))) + // cond: x.Uses == 1 + // result: (GreaterEqualNoov (CMNWconst [int32(c)] y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqualNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMNWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPconst [0] z:(ADD x y))) + // cond: z.Uses == 1 + // result: (GreaterEqualNoov (CMN x y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqualNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPWconst [0] z:(ADD x y))) + // cond: z.Uses == 1 + // result: (GreaterEqualNoov (CMNW x y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqualNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPconst [0] z:(MADD a x y))) + // cond: z.Uses == 1 + // result: (GreaterEqualNoov (CMN a (MUL x y))) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADD { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqualNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMN, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPconst [0] z:(MSUB a x y))) + // cond: z.Uses == 1 + // result: (GreaterEqualNoov (CMP a (MUL x y))) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUB { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqualNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPWconst [0] z:(MADDW a x y))) + // cond: z.Uses == 1 + // result: (GreaterEqualNoov (CMNW a (MULW x y))) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADDW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqualNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMNW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (CMPWconst [0] z:(MSUBW a x y))) + // cond: z.Uses == 1 + // result: (GreaterEqualNoov (CMPW a (MULW x y))) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUBW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64GreaterEqualNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (GreaterEqual (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.ge())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.ge())) + return true + } + // match: (GreaterEqual (InvertFlags x)) + // result: (LessEqual x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64LessEqual) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64GreaterEqualF(v *Value) bool { + v_0 := v.Args[0] + // match: (GreaterEqualF (InvertFlags x)) + // result: (LessEqualF x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64LessEqualF) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64GreaterEqualNoov(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (GreaterEqualNoov (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.geNoov())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.geNoov())) + return true + } + // match: (GreaterEqualNoov (InvertFlags x)) + // result: (CSINC [OpARM64NotEqual] (LessThanNoov x) (MOVDconst [0]) x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64CSINC) + v.AuxInt = opToAuxInt(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64LessThanNoov, typ.Bool) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v.AddArg3(v0, v1, x) + return true + } + return false +} +func rewriteValueARM64_OpARM64GreaterEqualU(v *Value) bool { + v_0 := v.Args[0] + // match: (GreaterEqualU (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.uge())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.uge())) + return true + } + // match: (GreaterEqualU (InvertFlags x)) + // result: (LessEqualU x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64LessEqualU) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64GreaterThan(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (GreaterThan (CMPconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (GreaterThan (TST x y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64GreaterThan) + v0 := b.NewValue0(v.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (GreaterThan (CMPWconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (GreaterThan (TSTWconst [int32(c)] y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64GreaterThan) + v0 := b.NewValue0(v.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (GreaterThan (CMPWconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (GreaterThan (TSTW x y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64GreaterThan) + v0 := b.NewValue0(v.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (GreaterThan (CMPconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (GreaterThan (TSTconst [c] y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64GreaterThan) + v0 := b.NewValue0(v.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (GreaterThan (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.gt())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.gt())) + return true + } + // match: (GreaterThan (InvertFlags x)) + // result: (LessThan x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64LessThan) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64GreaterThanF(v *Value) bool { + v_0 := v.Args[0] + // match: (GreaterThanF (InvertFlags x)) + // result: (LessThanF x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64LessThanF) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64GreaterThanU(v *Value) bool { + v_0 := v.Args[0] + // match: (GreaterThanU (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.ugt())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.ugt())) + return true + } + // match: (GreaterThanU (InvertFlags x)) + // result: (LessThanU x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64LessThanU) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64LDP(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (LDP [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (LDP [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64LDP) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (LDP [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (LDP [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64LDP) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64LessEqual(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (LessEqual (CMPconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (LessEqual (TST x y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64LessEqual) + v0 := b.NewValue0(v.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (LessEqual (CMPWconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (LessEqual (TSTWconst [int32(c)] y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64LessEqual) + v0 := b.NewValue0(v.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (LessEqual (CMPWconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (LessEqual (TSTW x y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64LessEqual) + v0 := b.NewValue0(v.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (LessEqual (CMPconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (LessEqual (TSTconst [c] y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64LessEqual) + v0 := b.NewValue0(v.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (LessEqual (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.le())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.le())) + return true + } + // match: (LessEqual (InvertFlags x)) + // result: (GreaterEqual x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64GreaterEqual) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64LessEqualF(v *Value) bool { + v_0 := v.Args[0] + // match: (LessEqualF (InvertFlags x)) + // result: (GreaterEqualF x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64GreaterEqualF) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64LessEqualU(v *Value) bool { + v_0 := v.Args[0] + // match: (LessEqualU (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.ule())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.ule())) + return true + } + // match: (LessEqualU (InvertFlags x)) + // result: (GreaterEqualU x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64GreaterEqualU) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64LessThan(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (LessThan (CMPconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (LessThan (TST x y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64LessThan) + v0 := b.NewValue0(v.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPWconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (LessThan (TSTWconst [int32(c)] y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64LessThan) + v0 := b.NewValue0(v.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPWconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (LessThan (TSTW x y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64LessThan) + v0 := b.NewValue0(v.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (LessThan (TSTconst [c] y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64LessThan) + v0 := b.NewValue0(v.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPconst [0] x:(ADDconst [c] y))) + // cond: x.Uses == 1 + // result: (LessThanNoov (CMNconst [c] y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64LessThanNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMNconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPWconst [0] x:(ADDconst [c] y))) + // cond: x.Uses == 1 + // result: (LessThanNoov (CMNWconst [int32(c)] y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64LessThanNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMNWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPconst [0] z:(ADD x y))) + // cond: z.Uses == 1 + // result: (LessThanNoov (CMN x y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64LessThanNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPWconst [0] z:(ADD x y))) + // cond: z.Uses == 1 + // result: (LessThanNoov (CMNW x y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64LessThanNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPconst [0] z:(MADD a x y))) + // cond: z.Uses == 1 + // result: (LessThanNoov (CMN a (MUL x y))) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADD { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64LessThanNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMN, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPconst [0] z:(MSUB a x y))) + // cond: z.Uses == 1 + // result: (LessThanNoov (CMP a (MUL x y))) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUB { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64LessThanNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPWconst [0] z:(MADDW a x y))) + // cond: z.Uses == 1 + // result: (LessThanNoov (CMNW a (MULW x y))) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADDW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64LessThanNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMNW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (LessThan (CMPWconst [0] z:(MSUBW a x y))) + // cond: z.Uses == 1 + // result: (LessThanNoov (CMPW a (MULW x y))) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUBW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64LessThanNoov) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (LessThan (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.lt())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.lt())) + return true + } + // match: (LessThan (InvertFlags x)) + // result: (GreaterThan x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64GreaterThan) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64LessThanF(v *Value) bool { + v_0 := v.Args[0] + // match: (LessThanF (InvertFlags x)) + // result: (GreaterThanF x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64GreaterThanF) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64LessThanNoov(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LessThanNoov (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.ltNoov())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.ltNoov())) + return true + } + // match: (LessThanNoov (InvertFlags x)) + // result: (CSEL0 [OpARM64NotEqual] (GreaterEqualNoov x) x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64CSEL0) + v.AuxInt = opToAuxInt(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64GreaterEqualNoov, typ.Bool) + v0.AddArg(x) + v.AddArg2(v0, x) + return true + } + return false +} +func rewriteValueARM64_OpARM64LessThanU(v *Value) bool { + v_0 := v.Args[0] + // match: (LessThanU (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.ult())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.ult())) + return true + } + // match: (LessThanU (InvertFlags x)) + // result: (GreaterThanU x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64GreaterThanU) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64LoweredPanicBoundsCR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsCR [kind] {p} (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:p.C, Cy:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpARM64LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: p.C, Cy: c}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64LoweredPanicBoundsRC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRC [kind] {p} (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:c, Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpARM64LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: c, Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64LoweredPanicBoundsRR(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRR [kind] x (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsRC [kind] x {PanicBoundsC{C:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpARM64LoweredPanicBoundsRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(x, mem) + return true + } + // match: (LoweredPanicBoundsRR [kind] (MOVDconst [c]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:c}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + mem := v_2 + v.reset(OpARM64LoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MADD(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MADD a x (MOVDconst [-1])) + // result: (SUB a x) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst || auxIntToInt64(v_2.AuxInt) != -1 { + break + } + v.reset(OpARM64SUB) + v.AddArg2(a, x) + return true + } + // match: (MADD a _ (MOVDconst [0])) + // result: a + for { + a := v_0 + if v_2.Op != OpARM64MOVDconst || auxIntToInt64(v_2.AuxInt) != 0 { + break + } + v.copyOf(a) + return true + } + // match: (MADD a x (MOVDconst [1])) + // result: (ADD a x) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst || auxIntToInt64(v_2.AuxInt) != 1 { + break + } + v.reset(OpARM64ADD) + v.AddArg2(a, x) + return true + } + // match: (MADD a x (MOVDconst [c])) + // cond: isPowerOfTwo(c) + // result: (ADDshiftLL a x [log64(c)]) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(log64(c)) + v.AddArg2(a, x) + return true + } + // match: (MADD a x (MOVDconst [c])) + // cond: isPowerOfTwo(c-1) && c>=3 + // result: (ADD a (ADDshiftLL x x [log64(c-1)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c-1) && c >= 3) { + break + } + v.reset(OpARM64ADD) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c - 1)) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a x (MOVDconst [c])) + // cond: isPowerOfTwo(c+1) && c>=7 + // result: (SUB a (SUBshiftLL x x [log64(c+1)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c+1) && c >= 7) { + break + } + v.reset(OpARM64SUB) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c + 1)) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a x (MOVDconst [c])) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (SUBshiftLL a (SUBshiftLL x x [2]) [log64(c/3)]) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 3)) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(2) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a x (MOVDconst [c])) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (ADDshiftLL a (ADDshiftLL x x [2]) [log64(c/5)]) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + break + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 5)) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(2) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a x (MOVDconst [c])) + // cond: c%7 == 0 && isPowerOfTwo(c/7) + // result: (SUBshiftLL a (SUBshiftLL x x [3]) [log64(c/7)]) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%7 == 0 && isPowerOfTwo(c/7)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 7)) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a x (MOVDconst [c])) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (ADDshiftLL a (ADDshiftLL x x [3]) [log64(c/9)]) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + break + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 9)) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a (MOVDconst [-1]) x) + // result: (SUB a x) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != -1 { + break + } + x := v_2 + v.reset(OpARM64SUB) + v.AddArg2(a, x) + return true + } + // match: (MADD a (MOVDconst [0]) _) + // result: a + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(a) + return true + } + // match: (MADD a (MOVDconst [1]) x) + // result: (ADD a x) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + x := v_2 + v.reset(OpARM64ADD) + v.AddArg2(a, x) + return true + } + // match: (MADD a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c) + // result: (ADDshiftLL a x [log64(c)]) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(log64(c)) + v.AddArg2(a, x) + return true + } + // match: (MADD a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c-1) && c>=3 + // result: (ADD a (ADDshiftLL x x [log64(c-1)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c-1) && c >= 3) { + break + } + v.reset(OpARM64ADD) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c - 1)) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c+1) && c>=7 + // result: (SUB a (SUBshiftLL x x [log64(c+1)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c+1) && c >= 7) { + break + } + v.reset(OpARM64SUB) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c + 1)) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a (MOVDconst [c]) x) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (SUBshiftLL a (SUBshiftLL x x [2]) [log64(c/3)]) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 3)) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(2) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a (MOVDconst [c]) x) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (ADDshiftLL a (ADDshiftLL x x [2]) [log64(c/5)]) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + break + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 5)) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(2) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a (MOVDconst [c]) x) + // cond: c%7 == 0 && isPowerOfTwo(c/7) + // result: (SUBshiftLL a (SUBshiftLL x x [3]) [log64(c/7)]) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%7 == 0 && isPowerOfTwo(c/7)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 7)) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD a (MOVDconst [c]) x) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (ADDshiftLL a (ADDshiftLL x x [3]) [log64(c/9)]) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + break + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 9)) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MADD (MOVDconst [c]) x y) + // result: (ADDconst [c] (MUL x y)) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64MUL, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (MADD a (MOVDconst [c]) (MOVDconst [d])) + // result: (ADDconst [c*d] a) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if v_2.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_2.AuxInt) + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c * d) + v.AddArg(a) + return true + } + return false +} +func rewriteValueARM64_OpARM64MADDW(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MADDW a x (MOVDconst [c])) + // cond: int32(c)==-1 + // result: (MOVWUreg (SUB a x)) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(int32(c) == -1) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUB, a.Type) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MADDW a _ (MOVDconst [c])) + // cond: int32(c)==0 + // result: (MOVWUreg a) + for { + a := v_0 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(int32(c) == 0) { + break + } + v.reset(OpARM64MOVWUreg) + v.AddArg(a) + return true + } + // match: (MADDW a x (MOVDconst [c])) + // cond: int32(c)==1 + // result: (MOVWUreg (ADD a x)) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(int32(c) == 1) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADD, a.Type) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MADDW a x (MOVDconst [c])) + // cond: isPowerOfTwo(c) + // result: (MOVWUreg (ADDshiftLL a x [log64(c)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c)) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MADDW a x (MOVDconst [c])) + // cond: isPowerOfTwo(c-1) && int32(c)>=3 + // result: (MOVWUreg (ADD a (ADDshiftLL x x [log64(c-1)]))) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c-1) && int32(c) >= 3) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADD, a.Type) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c - 1)) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a x (MOVDconst [c])) + // cond: isPowerOfTwo(c+1) && int32(c)>=7 + // result: (MOVWUreg (SUB a (SUBshiftLL x x [log64(c+1)]))) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c+1) && int32(c) >= 7) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUB, a.Type) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c + 1)) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a x (MOVDconst [c])) + // cond: c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) + // result: (MOVWUreg (SUBshiftLL a (SUBshiftLL x x [2]) [log64(c/3)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 3)) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a x (MOVDconst [c])) + // cond: c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) + // result: (MOVWUreg (ADDshiftLL a (ADDshiftLL x x [2]) [log64(c/5)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 5)) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a x (MOVDconst [c])) + // cond: c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) + // result: (MOVWUreg (SUBshiftLL a (SUBshiftLL x x [3]) [log64(c/7)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 7)) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a x (MOVDconst [c])) + // cond: c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) + // result: (MOVWUreg (ADDshiftLL a (ADDshiftLL x x [3]) [log64(c/9)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 9)) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a (MOVDconst [c]) x) + // cond: int32(c)==-1 + // result: (MOVWUreg (SUB a x)) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(int32(c) == -1) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUB, a.Type) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MADDW a (MOVDconst [c]) _) + // cond: int32(c)==0 + // result: (MOVWUreg a) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(int32(c) == 0) { + break + } + v.reset(OpARM64MOVWUreg) + v.AddArg(a) + return true + } + // match: (MADDW a (MOVDconst [c]) x) + // cond: int32(c)==1 + // result: (MOVWUreg (ADD a x)) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(int32(c) == 1) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADD, a.Type) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MADDW a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c) + // result: (MOVWUreg (ADDshiftLL a x [log64(c)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c)) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MADDW a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c-1) && int32(c)>=3 + // result: (MOVWUreg (ADD a (ADDshiftLL x x [log64(c-1)]))) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c-1) && int32(c) >= 3) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADD, a.Type) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c - 1)) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c+1) && int32(c)>=7 + // result: (MOVWUreg (SUB a (SUBshiftLL x x [log64(c+1)]))) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c+1) && int32(c) >= 7) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUB, a.Type) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c + 1)) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a (MOVDconst [c]) x) + // cond: c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) + // result: (MOVWUreg (SUBshiftLL a (SUBshiftLL x x [2]) [log64(c/3)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 3)) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a (MOVDconst [c]) x) + // cond: c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) + // result: (MOVWUreg (ADDshiftLL a (ADDshiftLL x x [2]) [log64(c/5)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 5)) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a (MOVDconst [c]) x) + // cond: c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) + // result: (MOVWUreg (SUBshiftLL a (SUBshiftLL x x [3]) [log64(c/7)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 7)) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW a (MOVDconst [c]) x) + // cond: c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) + // result: (MOVWUreg (ADDshiftLL a (ADDshiftLL x x [3]) [log64(c/9)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 9)) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MADDW (MOVDconst [c]) x y) + // result: (MOVWUreg (ADDconst [c] (MULW x y))) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDconst, x.Type) + v0.AuxInt = int64ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (MADDW a (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVWUreg (ADDconst [c*d] a)) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if v_2.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_2.AuxInt) + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDconst, a.Type) + v0.AuxInt = int64ToAuxInt(c * d) + v0.AddArg(a) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM64_OpARM64MNEG(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MNEG x (MOVDconst [-1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != -1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (MNEG _ (MOVDconst [0])) + // result: (MOVDconst [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + continue + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (MNEG x (MOVDconst [1])) + // result: (NEG x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 1 { + continue + } + v.reset(OpARM64NEG) + v.AddArg(x) + return true + } + break + } + // match: (MNEG x (MOVDconst [c])) + // cond: isPowerOfTwo(c) + // result: (NEG (SLLconst [log64(c)] x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c)) { + continue + } + v.reset(OpARM64NEG) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (MNEG x (MOVDconst [c])) + // cond: isPowerOfTwo(c-1) && c >= 3 + // result: (NEG (ADDshiftLL x x [log64(c-1)])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c-1) && c >= 3) { + continue + } + v.reset(OpARM64NEG) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c - 1)) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + break + } + // match: (MNEG x (MOVDconst [c])) + // cond: isPowerOfTwo(c+1) && c >= 7 + // result: (NEG (ADDshiftLL (NEG x) x [log64(c+1)])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c+1) && c >= 7) { + continue + } + v.reset(OpARM64NEG) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c + 1)) + v1 := b.NewValue0(v.Pos, OpARM64NEG, x.Type) + v1.AddArg(x) + v0.AddArg2(v1, x) + v.AddArg(v0) + return true + } + break + } + // match: (MNEG x (MOVDconst [c])) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (SLLconst [log64(c/3)] (SUBshiftLL x x [2])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + continue + } + v.reset(OpARM64SLLconst) + v.Type = x.Type + v.AuxInt = int64ToAuxInt(log64(c / 3)) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(2) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + break + } + // match: (MNEG x (MOVDconst [c])) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (NEG (SLLconst [log64(c/5)] (ADDshiftLL x x [2]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + continue + } + v.reset(OpARM64NEG) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 5)) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + // match: (MNEG x (MOVDconst [c])) + // cond: c%7 == 0 && isPowerOfTwo(c/7) + // result: (SLLconst [log64(c/7)] (SUBshiftLL x x [3])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(c%7 == 0 && isPowerOfTwo(c/7)) { + continue + } + v.reset(OpARM64SLLconst) + v.Type = x.Type + v.AuxInt = int64ToAuxInt(log64(c / 7)) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg(v0) + return true + } + break + } + // match: (MNEG x (MOVDconst [c])) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (NEG (SLLconst [log64(c/9)] (ADDshiftLL x x [3]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + continue + } + v.reset(OpARM64NEG) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 9)) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + // match: (MNEG (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [-c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-c * d) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64MNEGW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MNEGW x (MOVDconst [c])) + // cond: int32(c)==-1 + // result: (MOVWUreg x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(int32(c) == -1) { + continue + } + v.reset(OpARM64MOVWUreg) + v.AddArg(x) + return true + } + break + } + // match: (MNEGW _ (MOVDconst [c])) + // cond: int32(c)==0 + // result: (MOVDconst [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(int32(c) == 0) { + continue + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (MNEGW x (MOVDconst [c])) + // cond: int32(c)==1 + // result: (MOVWUreg (NEG x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(int32(c) == 1) { + continue + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64NEG, x.Type) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (MNEGW x (MOVDconst [c])) + // cond: isPowerOfTwo(c) + // result: (NEG (SLLconst [log64(c)] x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c)) { + continue + } + v.reset(OpARM64NEG) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (MNEGW x (MOVDconst [c])) + // cond: isPowerOfTwo(c-1) && int32(c) >= 3 + // result: (MOVWUreg (NEG (ADDshiftLL x x [log64(c-1)]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c-1) && int32(c) >= 3) { + continue + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64NEG, x.Type) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c - 1)) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + // match: (MNEGW x (MOVDconst [c])) + // cond: isPowerOfTwo(c+1) && int32(c) >= 7 + // result: (MOVWUreg (NEG (ADDshiftLL (NEG x) x [log64(c+1)]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c+1) && int32(c) >= 7) { + continue + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64NEG, x.Type) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c + 1)) + v2 := b.NewValue0(v.Pos, OpARM64NEG, x.Type) + v2.AddArg(x) + v1.AddArg2(v2, x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + // match: (MNEGW x (MOVDconst [c])) + // cond: c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) + // result: (MOVWUreg (SLLconst [log64(c/3)] (SUBshiftLL x x [2]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c)) { + continue + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 3)) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + // match: (MNEGW x (MOVDconst [c])) + // cond: c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) + // result: (MOVWUreg (NEG (SLLconst [log64(c/5)] (ADDshiftLL x x [2])))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c)) { + continue + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64NEG, x.Type) + v1 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c / 5)) + v2 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v2.AuxInt = int64ToAuxInt(2) + v2.AddArg2(x, x) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + // match: (MNEGW x (MOVDconst [c])) + // cond: c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) + // result: (MOVWUreg (SLLconst [log64(c/7)] (SUBshiftLL x x [3]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c)) { + continue + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 7)) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + // match: (MNEGW x (MOVDconst [c])) + // cond: c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) + // result: (MOVWUreg (NEG (SLLconst [log64(c/9)] (ADDshiftLL x x [3])))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c)) { + continue + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64NEG, x.Type) + v1 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c / 9)) + v2 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v2.AuxInt = int64ToAuxInt(3) + v2.AddArg2(x, x) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + // match: (MNEGW (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [int64(uint32(-c*d))]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint32(-c * d))) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64MOD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOD (MOVDconst [c]) (MOVDconst [d])) + // cond: d != 0 + // result: (MOVDconst [c%d]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(c % d) + return true + } + return false +} +func rewriteValueARM64_OpARM64MODW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MODW (MOVDconst [c]) (MOVDconst [d])) + // cond: d != 0 + // result: (MOVDconst [int64(uint32(int32(c)%int32(d)))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint32(int32(c) % int32(d)))) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVBUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBUload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBUload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVBUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUload [off] {sym} (ADD ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVBUloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVBUloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVBUload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVBUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVDconst [int64(read8(sym, int64(off)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(read8(sym, int64(off)))) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVBUloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBUloadidx ptr (MOVDconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVBUload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVBUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUloadidx (MOVDconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVBUload [int32(c)] ptr mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVBUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVBUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBUreg (ANDconst [c] x)) + // result: (ANDconst [c&(1<<8-1)] x) + for { + if v_0.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c & (1<<8 - 1)) + v.AddArg(x) + return true + } + // match: (MOVBUreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint8(c))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint8(c))) + return true + } + // match: (MOVBUreg x) + // cond: v.Type.Size() <= 1 + // result: x + for { + x := v_0 + if !(v.Type.Size() <= 1) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg (SLLconst [lc] x)) + // cond: lc >= 8 + // result: (MOVDconst [0]) + for { + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + if !(lc >= 8) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (MOVBUreg (SLLconst [lc] x)) + // cond: lc < 8 + // result: (UBFIZ [armBFAuxInt(lc, 8-lc)] x) + for { + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc < 8) { + break + } + v.reset(OpARM64UBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(lc, 8-lc)) + v.AddArg(x) + return true + } + // match: (MOVBUreg (SRLconst [rc] x)) + // cond: rc < 8 + // result: (UBFX [armBFAuxInt(rc, 8)] x) + for { + if v_0.Op != OpARM64SRLconst { + break + } + rc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(rc < 8) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc, 8)) + v.AddArg(x) + return true + } + // match: (MOVBUreg (UBFX [bfc] x)) + // cond: bfc.width() <= 8 + // result: (UBFX [bfc] x) + for { + if v_0.Op != OpARM64UBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(bfc.width() <= 8) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(bfc) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVBload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVBload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off] {sym} (ADD ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVBloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVBloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVBload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVDconst [int64(int8(read8(sym, int64(off))))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int8(read8(sym, int64(off))))) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVBloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBloadidx ptr (MOVDconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVBload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVBload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBloadidx (MOVDconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVBload [int32(c)] ptr mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVBload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVBreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBreg (MOVDconst [c])) + // result: (MOVDconst [int64(int8(c))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int8(c))) + return true + } + // match: (MOVBreg x) + // cond: v.Type.Size() <= 1 + // result: x + for { + x := v_0 + if !(v.Type.Size() <= 1) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBreg (ANDconst x [c])) + // cond: uint64(c) & uint64(0xffffffffffffff80) == 0 + // result: (ANDconst x [c]) + for { + t := v.Type + if v_0.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(uint64(c)&uint64(0xffffffffffffff80) == 0) { + break + } + v.reset(OpARM64ANDconst) + v.Type = t + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBreg (SLLconst [lc] x)) + // cond: lc < 8 + // result: (SBFIZ [armBFAuxInt(lc, 8-lc)] x) + for { + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc < 8) { + break + } + v.reset(OpARM64SBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(lc, 8-lc)) + v.AddArg(x) + return true + } + // match: (MOVBreg (SBFX [bfc] x)) + // cond: bfc.width() <= 8 + // result: (SBFX [bfc] x) + for { + if v_0.Op != OpARM64SBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(bfc.width() <= 8) { + break + } + v.reset(OpARM64SBFX) + v.AuxInt = arm64BitFieldToAuxInt(bfc) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off] {sym} (ADD ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVBstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVBstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVBstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVBreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVBUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVBstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstoreidx ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c) + // result: (MOVBstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstoreidx (MOVDconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (MOVBstore [int32(c)] idx val mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVBreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVBreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVBUreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVBUreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVHreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVHreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVHUreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVHUreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVWreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVWreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVWUreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVWUreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVDload [off] {sym} ptr (FMOVDstore [off] {sym} ptr val _)) + // result: (FMOVDfpgp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64FMOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpARM64FMOVDfpgp) + v.AddArg(val) + return true + } + // match: (MOVDload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVDload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off] {sym} (ADD ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVDloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVDloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVDload [off] {sym} (ADDshiftLL [3] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVDloadidx8 ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 3 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVDloadidx8) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVDload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVDconst [int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVDloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDloadidx ptr (MOVDconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVDload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVDload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDloadidx (MOVDconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVDload [int32(c)] ptr mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVDload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDloadidx ptr (SLLconst [3] idx) mem) + // result: (MOVDloadidx8 ptr idx mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 3 { + break + } + idx := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVDloadidx8) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVDloadidx (SLLconst [3] idx) ptr mem) + // result: (MOVDloadidx8 ptr idx mem) + for { + if v_0.Op != OpARM64SLLconst || auxIntToInt64(v_0.AuxInt) != 3 { + break + } + idx := v_0.Args[0] + ptr := v_1 + mem := v_2 + v.reset(OpARM64MOVDloadidx8) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVDloadidx8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDloadidx8 ptr (MOVDconst [c]) mem) + // cond: is32Bit(c<<3) + // result: (MOVDload [int32(c)<<3] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c << 3)) { + break + } + v.reset(OpARM64MOVDload) + v.AuxInt = int32ToAuxInt(int32(c) << 3) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVDnop(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVDnop (MOVDconst [c])) + // result: (MOVDconst [c]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(c) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVDreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVDreg x) + // cond: x.Uses == 1 + // result: (MOVDnop x) + for { + x := v_0 + if !(x.Uses == 1) { + break + } + v.reset(OpARM64MOVDnop) + v.AddArg(x) + return true + } + // match: (MOVDreg (MOVDconst [c])) + // result: (MOVDconst [c]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(c) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVDstore [off] {sym} ptr (FMOVDfpgp val) mem) + // result: (FMOVDstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64FMOVDfpgp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpARM64FMOVDstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off] {sym} (ADD ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVDstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVDstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVDstore [off] {sym} (ADDshiftLL [3] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVDstoreidx8 ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 3 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVDstoreidx8) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVDstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVDstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDstoreidx ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c) + // result: (MOVDstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstoreidx (MOVDconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (MOVDstore [int32(c)] idx val mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + // match: (MOVDstoreidx ptr (SLLconst [3] idx) val mem) + // result: (MOVDstoreidx8 ptr idx val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 3 { + break + } + idx := v_1.Args[0] + val := v_2 + mem := v_3 + v.reset(OpARM64MOVDstoreidx8) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVDstoreidx (SLLconst [3] idx) ptr val mem) + // result: (MOVDstoreidx8 ptr idx val mem) + for { + if v_0.Op != OpARM64SLLconst || auxIntToInt64(v_0.AuxInt) != 3 { + break + } + idx := v_0.Args[0] + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARM64MOVDstoreidx8) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVDstoreidx8(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDstoreidx8 ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c<<3) + // result: (MOVDstore [int32(c)<<3] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c << 3)) { + break + } + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(int32(c) << 3) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHUload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHUload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVHUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off] {sym} (ADD ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVHUloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVHUloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHUload [off] {sym} (ADDshiftLL [1] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVHUloadidx2 ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 1 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVHUloadidx2) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHUload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVHUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVDconst [int64(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHUloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHUloadidx ptr (MOVDconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVHUload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVHUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUloadidx (MOVDconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVHUload [int32(c)] ptr mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVHUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUloadidx ptr (SLLconst [1] idx) mem) + // result: (MOVHUloadidx2 ptr idx mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + idx := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVHUloadidx2) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHUloadidx ptr (ADD idx idx) mem) + // result: (MOVHUloadidx2 ptr idx mem) + for { + ptr := v_0 + if v_1.Op != OpARM64ADD { + break + } + idx := v_1.Args[1] + if idx != v_1.Args[0] { + break + } + mem := v_2 + v.reset(OpARM64MOVHUloadidx2) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHUloadidx (ADD idx idx) ptr mem) + // result: (MOVHUloadidx2 ptr idx mem) + for { + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + if idx != v_0.Args[0] { + break + } + ptr := v_1 + mem := v_2 + v.reset(OpARM64MOVHUloadidx2) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHUloadidx2(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHUloadidx2 ptr (MOVDconst [c]) mem) + // cond: is32Bit(c<<1) + // result: (MOVHUload [int32(c)<<1] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c << 1)) { + break + } + v.reset(OpARM64MOVHUload) + v.AuxInt = int32ToAuxInt(int32(c) << 1) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVHUreg (ANDconst [c] x)) + // result: (ANDconst [c&(1<<16-1)] x) + for { + if v_0.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c & (1<<16 - 1)) + v.AddArg(x) + return true + } + // match: (MOVHUreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint16(c))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint16(c))) + return true + } + // match: (MOVHUreg x) + // cond: v.Type.Size() <= 2 + // result: x + for { + x := v_0 + if !(v.Type.Size() <= 2) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHUreg (SLLconst [lc] x)) + // cond: lc >= 16 + // result: (MOVDconst [0]) + for { + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + if !(lc >= 16) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (MOVHUreg (SLLconst [lc] x)) + // cond: lc < 16 + // result: (UBFIZ [armBFAuxInt(lc, 16-lc)] x) + for { + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc < 16) { + break + } + v.reset(OpARM64UBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(lc, 16-lc)) + v.AddArg(x) + return true + } + // match: (MOVHUreg (SRLconst [rc] x)) + // cond: rc < 16 + // result: (UBFX [armBFAuxInt(rc, 16)] x) + for { + if v_0.Op != OpARM64SRLconst { + break + } + rc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(rc < 16) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc, 16)) + v.AddArg(x) + return true + } + // match: (MOVHUreg (UBFX [bfc] x)) + // cond: bfc.width() <= 16 + // result: (UBFX [bfc] x) + for { + if v_0.Op != OpARM64UBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(bfc.width() <= 16) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(bfc) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVHload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off] {sym} (ADD ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVHloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVHloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHload [off] {sym} (ADDshiftLL [1] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVHloadidx2 ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 1 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVHloadidx2) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVHload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVDconst [int64(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHloadidx ptr (MOVDconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVHload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVHload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHloadidx (MOVDconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVHload [int32(c)] ptr mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVHload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHloadidx ptr (SLLconst [1] idx) mem) + // result: (MOVHloadidx2 ptr idx mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + idx := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVHloadidx2) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHloadidx ptr (ADD idx idx) mem) + // result: (MOVHloadidx2 ptr idx mem) + for { + ptr := v_0 + if v_1.Op != OpARM64ADD { + break + } + idx := v_1.Args[1] + if idx != v_1.Args[0] { + break + } + mem := v_2 + v.reset(OpARM64MOVHloadidx2) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHloadidx (ADD idx idx) ptr mem) + // result: (MOVHloadidx2 ptr idx mem) + for { + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + if idx != v_0.Args[0] { + break + } + ptr := v_1 + mem := v_2 + v.reset(OpARM64MOVHloadidx2) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHloadidx2(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHloadidx2 ptr (MOVDconst [c]) mem) + // cond: is32Bit(c<<1) + // result: (MOVHload [int32(c)<<1] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c << 1)) { + break + } + v.reset(OpARM64MOVHload) + v.AuxInt = int32ToAuxInt(int32(c) << 1) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVHreg (MOVDconst [c])) + // result: (MOVDconst [int64(int16(c))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int16(c))) + return true + } + // match: (MOVHreg x) + // cond: v.Type.Size() <= 2 + // result: x + for { + x := v_0 + if !(v.Type.Size() <= 2) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHreg (ANDconst x [c])) + // cond: uint64(c) & uint64(0xffffffffffff8000) == 0 + // result: (ANDconst x [c]) + for { + t := v.Type + if v_0.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(uint64(c)&uint64(0xffffffffffff8000) == 0) { + break + } + v.reset(OpARM64ANDconst) + v.Type = t + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHreg (SLLconst [lc] x)) + // cond: lc < 16 + // result: (SBFIZ [armBFAuxInt(lc, 16-lc)] x) + for { + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc < 16) { + break + } + v.reset(OpARM64SBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(lc, 16-lc)) + v.AddArg(x) + return true + } + // match: (MOVHreg (SBFX [bfc] x)) + // cond: bfc.width() <= 16 + // result: (SBFX [bfc] x) + for { + if v_0.Op != OpARM64SBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(bfc.width() <= 16) { + break + } + v.reset(OpARM64SBFX) + v.AuxInt = arm64BitFieldToAuxInt(bfc) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off] {sym} (ADD ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVHstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVHstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVHstore [off] {sym} (ADDshiftLL [1] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVHstoreidx2 ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 1 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVHstoreidx2) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVHstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstoreidx ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c) + // result: (MOVHstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstoreidx (MOVDconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (MOVHstore [int32(c)] idx val mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + // match: (MOVHstoreidx ptr (SLLconst [1] idx) val mem) + // result: (MOVHstoreidx2 ptr idx val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + idx := v_1.Args[0] + val := v_2 + mem := v_3 + v.reset(OpARM64MOVHstoreidx2) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVHstoreidx ptr (ADD idx idx) val mem) + // result: (MOVHstoreidx2 ptr idx val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64ADD { + break + } + idx := v_1.Args[1] + if idx != v_1.Args[0] { + break + } + val := v_2 + mem := v_3 + v.reset(OpARM64MOVHstoreidx2) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVHstoreidx (SLLconst [1] idx) ptr val mem) + // result: (MOVHstoreidx2 ptr idx val mem) + for { + if v_0.Op != OpARM64SLLconst || auxIntToInt64(v_0.AuxInt) != 1 { + break + } + idx := v_0.Args[0] + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARM64MOVHstoreidx2) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVHstoreidx (ADD idx idx) ptr val mem) + // result: (MOVHstoreidx2 ptr idx val mem) + for { + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + if idx != v_0.Args[0] { + break + } + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARM64MOVHstoreidx2) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVHstoreidx ptr idx (MOVHreg x) mem) + // result: (MOVHstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVHreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVHstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVHstoreidx ptr idx (MOVHUreg x) mem) + // result: (MOVHstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVHUreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVHstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVHstoreidx ptr idx (MOVWreg x) mem) + // result: (MOVHstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVWreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVHstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVHstoreidx ptr idx (MOVWUreg x) mem) + // result: (MOVHstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVWUreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVHstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVHstoreidx2(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstoreidx2 ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c<<1) + // result: (MOVHstore [int32(c)<<1] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c << 1)) { + break + } + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(int32(c) << 1) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstoreidx2 ptr idx (MOVHreg x) mem) + // result: (MOVHstoreidx2 ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVHreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVHstoreidx2) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVHstoreidx2 ptr idx (MOVHUreg x) mem) + // result: (MOVHstoreidx2 ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVHUreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVHstoreidx2) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVHstoreidx2 ptr idx (MOVWreg x) mem) + // result: (MOVHstoreidx2 ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVWreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVHstoreidx2) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVHstoreidx2 ptr idx (MOVWUreg x) mem) + // result: (MOVHstoreidx2 ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVWUreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVHstoreidx2) + v.AddArg4(ptr, idx, x, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWUload [off] {sym} ptr (FMOVSstore [off] {sym} ptr val _)) + // result: (FMOVSfpgp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64FMOVSstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpARM64FMOVSfpgp) + v.AddArg(val) + return true + } + // match: (MOVWUload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWUload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVWUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWUload [off] {sym} (ADD ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVWUloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVWUloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWUload [off] {sym} (ADDshiftLL [2] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVWUloadidx4 ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 2 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVWUloadidx4) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWUload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVWUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVDconst [int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWUloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWUloadidx ptr (MOVDconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVWUload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWUloadidx (MOVDconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVWUload [int32(c)] ptr mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWUloadidx ptr (SLLconst [2] idx) mem) + // result: (MOVWUloadidx4 ptr idx mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 2 { + break + } + idx := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVWUloadidx4) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWUloadidx (SLLconst [2] idx) ptr mem) + // result: (MOVWUloadidx4 ptr idx mem) + for { + if v_0.Op != OpARM64SLLconst || auxIntToInt64(v_0.AuxInt) != 2 { + break + } + idx := v_0.Args[0] + ptr := v_1 + mem := v_2 + v.reset(OpARM64MOVWUloadidx4) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWUloadidx4(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWUloadidx4 ptr (MOVDconst [c]) mem) + // cond: is32Bit(c<<2) + // result: (MOVWUload [int32(c)<<2] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c << 2)) { + break + } + v.reset(OpARM64MOVWUload) + v.AuxInt = int32ToAuxInt(int32(c) << 2) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWUreg (ANDconst [c] x)) + // result: (ANDconst [c&(1<<32-1)] x) + for { + if v_0.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c & (1<<32 - 1)) + v.AddArg(x) + return true + } + // match: (MOVWUreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint32(c))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint32(c))) + return true + } + // match: (MOVWUreg x) + // cond: v.Type.Size() <= 4 + // result: x + for { + x := v_0 + if !(v.Type.Size() <= 4) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWUreg (SLLconst [lc] x)) + // cond: lc >= 32 + // result: (MOVDconst [0]) + for { + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + if !(lc >= 32) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (MOVWUreg (SLLconst [lc] x)) + // cond: lc < 32 + // result: (UBFIZ [armBFAuxInt(lc, 32-lc)] x) + for { + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc < 32) { + break + } + v.reset(OpARM64UBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(lc, 32-lc)) + v.AddArg(x) + return true + } + // match: (MOVWUreg (SRLconst [rc] x)) + // cond: rc < 32 + // result: (UBFX [armBFAuxInt(rc, 32)] x) + for { + if v_0.Op != OpARM64SRLconst { + break + } + rc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(rc < 32) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc, 32)) + v.AddArg(x) + return true + } + // match: (MOVWUreg (UBFX [bfc] x)) + // cond: bfc.width() <= 32 + // result: (UBFX [bfc] x) + for { + if v_0.Op != OpARM64UBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(bfc.width() <= 32) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(bfc) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off] {sym} (ADD ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVWloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVWloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWload [off] {sym} (ADDshiftLL [2] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVWloadidx4 ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 2 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVWloadidx4) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVDconst [int64(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWloadidx ptr (MOVDconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVWload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVWload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWloadidx (MOVDconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVWload [int32(c)] ptr mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVWload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWloadidx ptr (SLLconst [2] idx) mem) + // result: (MOVWloadidx4 ptr idx mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 2 { + break + } + idx := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVWloadidx4) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWloadidx (SLLconst [2] idx) ptr mem) + // result: (MOVWloadidx4 ptr idx mem) + for { + if v_0.Op != OpARM64SLLconst || auxIntToInt64(v_0.AuxInt) != 2 { + break + } + idx := v_0.Args[0] + ptr := v_1 + mem := v_2 + v.reset(OpARM64MOVWloadidx4) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWloadidx4(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWloadidx4 ptr (MOVDconst [c]) mem) + // cond: is32Bit(c<<2) + // result: (MOVWload [int32(c)<<2] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c << 2)) { + break + } + v.reset(OpARM64MOVWload) + v.AuxInt = int32ToAuxInt(int32(c) << 2) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWreg (MOVDconst [c])) + // result: (MOVDconst [int64(int32(c))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int32(c))) + return true + } + // match: (MOVWreg x) + // cond: v.Type.Size() <= 4 + // result: x + for { + x := v_0 + if !(v.Type.Size() <= 4) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg (ANDconst x [c])) + // cond: uint64(c) & uint64(0xffffffff80000000) == 0 + // result: (ANDconst x [c]) + for { + t := v.Type + if v_0.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(uint64(c)&uint64(0xffffffff80000000) == 0) { + break + } + v.reset(OpARM64ANDconst) + v.Type = t + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVWreg (SLLconst [lc] x)) + // cond: lc < 32 + // result: (SBFIZ [armBFAuxInt(lc, 32-lc)] x) + for { + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc < 32) { + break + } + v.reset(OpARM64SBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(lc, 32-lc)) + v.AddArg(x) + return true + } + // match: (MOVWreg (SBFX [bfc] x)) + // cond: bfc.width() <= 32 + // result: (SBFX [bfc] x) + for { + if v_0.Op != OpARM64SBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(bfc.width() <= 32) { + break + } + v.reset(OpARM64SBFX) + v.AuxInt = arm64BitFieldToAuxInt(bfc) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWstore [off] {sym} ptr (FMOVSfpgp val) mem) + // result: (FMOVSstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64FMOVSfpgp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpARM64FMOVSstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off] {sym} (ADD ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVWstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADD { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVWstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstore [off] {sym} (ADDshiftLL [2] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVWstoreidx4 ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDshiftLL || auxIntToInt64(v_0.AuxInt) != 2 { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpARM64MOVWstoreidx4) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpARM64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstoreidx ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c) + // result: (MOVWstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstoreidx (MOVDconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (MOVWstore [int32(c)] idx val mem) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + // match: (MOVWstoreidx ptr (SLLconst [2] idx) val mem) + // result: (MOVWstoreidx4 ptr idx val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64SLLconst || auxIntToInt64(v_1.AuxInt) != 2 { + break + } + idx := v_1.Args[0] + val := v_2 + mem := v_3 + v.reset(OpARM64MOVWstoreidx4) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstoreidx (SLLconst [2] idx) ptr val mem) + // result: (MOVWstoreidx4 ptr idx val mem) + for { + if v_0.Op != OpARM64SLLconst || auxIntToInt64(v_0.AuxInt) != 2 { + break + } + idx := v_0.Args[0] + ptr := v_1 + val := v_2 + mem := v_3 + v.reset(OpARM64MOVWstoreidx4) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstoreidx ptr idx (MOVWreg x) mem) + // result: (MOVWstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVWreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVWstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVWstoreidx ptr idx (MOVWUreg x) mem) + // result: (MOVWstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVWUreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVWstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MOVWstoreidx4(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstoreidx4 ptr (MOVDconst [c]) val mem) + // cond: is32Bit(c<<2) + // result: (MOVWstore [int32(c)<<2] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c << 2)) { + break + } + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(int32(c) << 2) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstoreidx4 ptr idx (MOVWreg x) mem) + // result: (MOVWstoreidx4 ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVWreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVWstoreidx4) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVWstoreidx4 ptr idx (MOVWUreg x) mem) + // result: (MOVWstoreidx4 ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpARM64MOVWUreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpARM64MOVWstoreidx4) + v.AddArg4(ptr, idx, x, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64MSUB(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MSUB a x (MOVDconst [-1])) + // result: (ADD a x) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst || auxIntToInt64(v_2.AuxInt) != -1 { + break + } + v.reset(OpARM64ADD) + v.AddArg2(a, x) + return true + } + // match: (MSUB a _ (MOVDconst [0])) + // result: a + for { + a := v_0 + if v_2.Op != OpARM64MOVDconst || auxIntToInt64(v_2.AuxInt) != 0 { + break + } + v.copyOf(a) + return true + } + // match: (MSUB a x (MOVDconst [1])) + // result: (SUB a x) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst || auxIntToInt64(v_2.AuxInt) != 1 { + break + } + v.reset(OpARM64SUB) + v.AddArg2(a, x) + return true + } + // match: (MSUB a x (MOVDconst [c])) + // cond: isPowerOfTwo(c) + // result: (SUBshiftLL a x [log64(c)]) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(log64(c)) + v.AddArg2(a, x) + return true + } + // match: (MSUB a x (MOVDconst [c])) + // cond: isPowerOfTwo(c-1) && c>=3 + // result: (SUB a (ADDshiftLL x x [log64(c-1)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c-1) && c >= 3) { + break + } + v.reset(OpARM64SUB) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c - 1)) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a x (MOVDconst [c])) + // cond: isPowerOfTwo(c+1) && c>=7 + // result: (ADD a (SUBshiftLL x x [log64(c+1)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c+1) && c >= 7) { + break + } + v.reset(OpARM64ADD) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c + 1)) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a x (MOVDconst [c])) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (ADDshiftLL a (SUBshiftLL x x [2]) [log64(c/3)]) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + break + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 3)) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(2) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a x (MOVDconst [c])) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (SUBshiftLL a (ADDshiftLL x x [2]) [log64(c/5)]) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 5)) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(2) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a x (MOVDconst [c])) + // cond: c%7 == 0 && isPowerOfTwo(c/7) + // result: (ADDshiftLL a (SUBshiftLL x x [3]) [log64(c/7)]) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%7 == 0 && isPowerOfTwo(c/7)) { + break + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 7)) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a x (MOVDconst [c])) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (SUBshiftLL a (ADDshiftLL x x [3]) [log64(c/9)]) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 9)) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a (MOVDconst [-1]) x) + // result: (ADD a x) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != -1 { + break + } + x := v_2 + v.reset(OpARM64ADD) + v.AddArg2(a, x) + return true + } + // match: (MSUB a (MOVDconst [0]) _) + // result: a + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(a) + return true + } + // match: (MSUB a (MOVDconst [1]) x) + // result: (SUB a x) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + x := v_2 + v.reset(OpARM64SUB) + v.AddArg2(a, x) + return true + } + // match: (MSUB a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c) + // result: (SUBshiftLL a x [log64(c)]) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(log64(c)) + v.AddArg2(a, x) + return true + } + // match: (MSUB a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c-1) && c>=3 + // result: (SUB a (ADDshiftLL x x [log64(c-1)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c-1) && c >= 3) { + break + } + v.reset(OpARM64SUB) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c - 1)) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c+1) && c>=7 + // result: (ADD a (SUBshiftLL x x [log64(c+1)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c+1) && c >= 7) { + break + } + v.reset(OpARM64ADD) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(log64(c + 1)) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a (MOVDconst [c]) x) + // cond: c%3 == 0 && isPowerOfTwo(c/3) + // result: (ADDshiftLL a (SUBshiftLL x x [2]) [log64(c/3)]) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%3 == 0 && isPowerOfTwo(c/3)) { + break + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 3)) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(2) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a (MOVDconst [c]) x) + // cond: c%5 == 0 && isPowerOfTwo(c/5) + // result: (SUBshiftLL a (ADDshiftLL x x [2]) [log64(c/5)]) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%5 == 0 && isPowerOfTwo(c/5)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 5)) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(2) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a (MOVDconst [c]) x) + // cond: c%7 == 0 && isPowerOfTwo(c/7) + // result: (ADDshiftLL a (SUBshiftLL x x [3]) [log64(c/7)]) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%7 == 0 && isPowerOfTwo(c/7)) { + break + } + v.reset(OpARM64ADDshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 7)) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB a (MOVDconst [c]) x) + // cond: c%9 == 0 && isPowerOfTwo(c/9) + // result: (SUBshiftLL a (ADDshiftLL x x [3]) [log64(c/9)]) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%9 == 0 && isPowerOfTwo(c/9)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(log64(c / 9)) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v0.AuxInt = int64ToAuxInt(3) + v0.AddArg2(x, x) + v.AddArg2(a, v0) + return true + } + // match: (MSUB (MOVDconst [c]) x y) + // result: (ADDconst [c] (MNEG x y)) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64MNEG, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (MSUB a (MOVDconst [c]) (MOVDconst [d])) + // result: (SUBconst [c*d] a) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if v_2.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_2.AuxInt) + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c * d) + v.AddArg(a) + return true + } + return false +} +func rewriteValueARM64_OpARM64MSUBW(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MSUBW a x (MOVDconst [c])) + // cond: int32(c)==-1 + // result: (MOVWUreg (ADD a x)) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(int32(c) == -1) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADD, a.Type) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MSUBW a _ (MOVDconst [c])) + // cond: int32(c)==0 + // result: (MOVWUreg a) + for { + a := v_0 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(int32(c) == 0) { + break + } + v.reset(OpARM64MOVWUreg) + v.AddArg(a) + return true + } + // match: (MSUBW a x (MOVDconst [c])) + // cond: int32(c)==1 + // result: (MOVWUreg (SUB a x)) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(int32(c) == 1) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUB, a.Type) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MSUBW a x (MOVDconst [c])) + // cond: isPowerOfTwo(c) + // result: (MOVWUreg (SUBshiftLL a x [log64(c)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c)) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MSUBW a x (MOVDconst [c])) + // cond: isPowerOfTwo(c-1) && int32(c)>=3 + // result: (MOVWUreg (SUB a (ADDshiftLL x x [log64(c-1)]))) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c-1) && int32(c) >= 3) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUB, a.Type) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c - 1)) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a x (MOVDconst [c])) + // cond: isPowerOfTwo(c+1) && int32(c)>=7 + // result: (MOVWUreg (ADD a (SUBshiftLL x x [log64(c+1)]))) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(isPowerOfTwo(c+1) && int32(c) >= 7) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADD, a.Type) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c + 1)) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a x (MOVDconst [c])) + // cond: c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) + // result: (MOVWUreg (ADDshiftLL a (SUBshiftLL x x [2]) [log64(c/3)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 3)) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a x (MOVDconst [c])) + // cond: c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) + // result: (MOVWUreg (SUBshiftLL a (ADDshiftLL x x [2]) [log64(c/5)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 5)) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a x (MOVDconst [c])) + // cond: c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) + // result: (MOVWUreg (ADDshiftLL a (SUBshiftLL x x [3]) [log64(c/7)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 7)) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a x (MOVDconst [c])) + // cond: c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) + // result: (MOVWUreg (SUBshiftLL a (ADDshiftLL x x [3]) [log64(c/9)])) + for { + a := v_0 + x := v_1 + if v_2.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + if !(c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 9)) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a (MOVDconst [c]) x) + // cond: int32(c)==-1 + // result: (MOVWUreg (ADD a x)) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(int32(c) == -1) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADD, a.Type) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MSUBW a (MOVDconst [c]) _) + // cond: int32(c)==0 + // result: (MOVWUreg a) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(int32(c) == 0) { + break + } + v.reset(OpARM64MOVWUreg) + v.AddArg(a) + return true + } + // match: (MSUBW a (MOVDconst [c]) x) + // cond: int32(c)==1 + // result: (MOVWUreg (SUB a x)) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(int32(c) == 1) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUB, a.Type) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MSUBW a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c) + // result: (MOVWUreg (SUBshiftLL a x [log64(c)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c)) + v0.AddArg2(a, x) + v.AddArg(v0) + return true + } + // match: (MSUBW a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c-1) && int32(c)>=3 + // result: (MOVWUreg (SUB a (ADDshiftLL x x [log64(c-1)]))) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c-1) && int32(c) >= 3) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUB, a.Type) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c - 1)) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a (MOVDconst [c]) x) + // cond: isPowerOfTwo(c+1) && int32(c)>=7 + // result: (MOVWUreg (ADD a (SUBshiftLL x x [log64(c+1)]))) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(isPowerOfTwo(c+1) && int32(c) >= 7) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADD, a.Type) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(log64(c + 1)) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a (MOVDconst [c]) x) + // cond: c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) + // result: (MOVWUreg (ADDshiftLL a (SUBshiftLL x x [2]) [log64(c/3)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 3)) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a (MOVDconst [c]) x) + // cond: c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) + // result: (MOVWUreg (SUBshiftLL a (ADDshiftLL x x [2]) [log64(c/5)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 5)) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(2) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a (MOVDconst [c]) x) + // cond: c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) + // result: (MOVWUreg (ADDshiftLL a (SUBshiftLL x x [3]) [log64(c/7)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 7)) + v1 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a (MOVDconst [c]) x) + // cond: c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) + // result: (MOVWUreg (SUBshiftLL a (ADDshiftLL x x [3]) [log64(c/9)])) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + x := v_2 + if !(c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c)) { + break + } + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBshiftLL, a.Type) + v0.AuxInt = int64ToAuxInt(log64(c / 9)) + v1 := b.NewValue0(v.Pos, OpARM64ADDshiftLL, x.Type) + v1.AuxInt = int64ToAuxInt(3) + v1.AddArg2(x, x) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (MSUBW (MOVDconst [c]) x y) + // result: (MOVWUreg (ADDconst [c] (MNEGW x y))) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + y := v_2 + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64ADDconst, x.Type) + v0.AuxInt = int64ToAuxInt(c) + v1 := b.NewValue0(v.Pos, OpARM64MNEGW, x.Type) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (MSUBW a (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVWUreg (SUBconst [c*d] a)) + for { + a := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if v_2.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_2.AuxInt) + v.reset(OpARM64MOVWUreg) + v0 := b.NewValue0(v.Pos, OpARM64SUBconst, a.Type) + v0.AuxInt = int64ToAuxInt(c * d) + v0.AddArg(a) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM64_OpARM64MUL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MUL (NEG x) y) + // result: (MNEG x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARM64NEG { + continue + } + x := v_0.Args[0] + y := v_1 + v.reset(OpARM64MNEG) + v.AddArg2(x, y) + return true + } + break + } + // match: (MUL _ (MOVDconst [0])) + // result: (MOVDconst [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + continue + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (MUL x (MOVDconst [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (MUL x (MOVDconst [c])) + // cond: canMulStrengthReduce(config, c) + // result: {mulStrengthReduce(v, x, c)} + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(canMulStrengthReduce(config, c)) { + continue + } + v.copyOf(mulStrengthReduce(v, x, c)) + return true + } + break + } + // match: (MUL (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(c * d) + return true + } + break + } + // match: (MUL r:(MOVWUreg x) s:(MOVWUreg y)) + // cond: r.Uses == 1 && s.Uses == 1 + // result: (UMULL x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + r := v_0 + if r.Op != OpARM64MOVWUreg { + continue + } + x := r.Args[0] + s := v_1 + if s.Op != OpARM64MOVWUreg { + continue + } + y := s.Args[0] + if !(r.Uses == 1 && s.Uses == 1) { + continue + } + v.reset(OpARM64UMULL) + v.AddArg2(x, y) + return true + } + break + } + // match: (MUL r:(MOVWreg x) s:(MOVWreg y)) + // cond: r.Uses == 1 && s.Uses == 1 + // result: (MULL x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + r := v_0 + if r.Op != OpARM64MOVWreg { + continue + } + x := r.Args[0] + s := v_1 + if s.Op != OpARM64MOVWreg { + continue + } + y := s.Args[0] + if !(r.Uses == 1 && s.Uses == 1) { + continue + } + v.reset(OpARM64MULL) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64MULW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MULW (NEG x) y) + // result: (MNEGW x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARM64NEG { + continue + } + x := v_0.Args[0] + y := v_1 + v.reset(OpARM64MNEGW) + v.AddArg2(x, y) + return true + } + break + } + // match: (MULW _ (MOVDconst [c])) + // cond: int32(c)==0 + // result: (MOVDconst [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(int32(c) == 0) { + continue + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (MULW x (MOVDconst [c])) + // cond: int32(c)==1 + // result: (MOVWUreg x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(int32(c) == 1) { + continue + } + v.reset(OpARM64MOVWUreg) + v.AddArg(x) + return true + } + break + } + // match: (MULW x (MOVDconst [c])) + // cond: v.Type.Size() <= 4 && canMulStrengthReduce32(config, int32(c)) + // result: {mulStrengthReduce32(v, x, int32(c))} + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(v.Type.Size() <= 4 && canMulStrengthReduce32(config, int32(c))) { + continue + } + v.copyOf(mulStrengthReduce32(v, x, int32(c))) + return true + } + break + } + // match: (MULW (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [int64(uint32(c*d))]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint32(c * d))) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64MVN(v *Value) bool { + v_0 := v.Args[0] + // match: (MVN (XOR x y)) + // result: (EON x y) + for { + if v_0.Op != OpARM64XOR { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64EON) + v.AddArg2(x, y) + return true + } + // match: (MVN (MOVDconst [c])) + // result: (MOVDconst [^c]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(^c) + return true + } + // match: (MVN x:(SLLconst [c] y)) + // cond: clobberIfDead(x) + // result: (MVNshiftLL [c] y) + for { + x := v_0 + if x.Op != OpARM64SLLconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(clobberIfDead(x)) { + break + } + v.reset(OpARM64MVNshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(y) + return true + } + // match: (MVN x:(SRLconst [c] y)) + // cond: clobberIfDead(x) + // result: (MVNshiftRL [c] y) + for { + x := v_0 + if x.Op != OpARM64SRLconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(clobberIfDead(x)) { + break + } + v.reset(OpARM64MVNshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(y) + return true + } + // match: (MVN x:(SRAconst [c] y)) + // cond: clobberIfDead(x) + // result: (MVNshiftRA [c] y) + for { + x := v_0 + if x.Op != OpARM64SRAconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(clobberIfDead(x)) { + break + } + v.reset(OpARM64MVNshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(y) + return true + } + // match: (MVN x:(RORconst [c] y)) + // cond: clobberIfDead(x) + // result: (MVNshiftRO [c] y) + for { + x := v_0 + if x.Op != OpARM64RORconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(clobberIfDead(x)) { + break + } + v.reset(OpARM64MVNshiftRO) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(y) + return true + } + return false +} +func rewriteValueARM64_OpARM64MVNshiftLL(v *Value) bool { + v_0 := v.Args[0] + // match: (MVNshiftLL (MOVDconst [c]) [d]) + // result: (MOVDconst [^int64(uint64(c)<>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(^(c >> uint64(d))) + return true + } + return false +} +func rewriteValueARM64_OpARM64MVNshiftRL(v *Value) bool { + v_0 := v.Args[0] + // match: (MVNshiftRL (MOVDconst [c]) [d]) + // result: (MOVDconst [^int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(^int64(uint64(c) >> uint64(d))) + return true + } + return false +} +func rewriteValueARM64_OpARM64MVNshiftRO(v *Value) bool { + v_0 := v.Args[0] + // match: (MVNshiftRO (MOVDconst [c]) [d]) + // result: (MOVDconst [^rotateRight64(c, d)]) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(^rotateRight64(c, d)) + return true + } + return false +} +func rewriteValueARM64_OpARM64NEG(v *Value) bool { + v_0 := v.Args[0] + // match: (NEG (MUL x y)) + // result: (MNEG x y) + for { + if v_0.Op != OpARM64MUL { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64MNEG) + v.AddArg2(x, y) + return true + } + // match: (NEG (MULW x y)) + // cond: v.Type.Size() <= 4 + // result: (MNEGW x y) + for { + if v_0.Op != OpARM64MULW { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if !(v.Type.Size() <= 4) { + break + } + v.reset(OpARM64MNEGW) + v.AddArg2(x, y) + return true + } + // match: (NEG (SUB x y)) + // result: (SUB y x) + for { + if v_0.Op != OpARM64SUB { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64SUB) + v.AddArg2(y, x) + return true + } + // match: (NEG (NEG x)) + // result: x + for { + if v_0.Op != OpARM64NEG { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (NEG (MOVDconst [c])) + // result: (MOVDconst [-c]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-c) + return true + } + // match: (NEG x:(SLLconst [c] y)) + // cond: clobberIfDead(x) + // result: (NEGshiftLL [c] y) + for { + x := v_0 + if x.Op != OpARM64SLLconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(clobberIfDead(x)) { + break + } + v.reset(OpARM64NEGshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(y) + return true + } + // match: (NEG x:(SRLconst [c] y)) + // cond: clobberIfDead(x) + // result: (NEGshiftRL [c] y) + for { + x := v_0 + if x.Op != OpARM64SRLconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(clobberIfDead(x)) { + break + } + v.reset(OpARM64NEGshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(y) + return true + } + // match: (NEG x:(SRAconst [c] y)) + // cond: clobberIfDead(x) + // result: (NEGshiftRA [c] y) + for { + x := v_0 + if x.Op != OpARM64SRAconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(clobberIfDead(x)) { + break + } + v.reset(OpARM64NEGshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(y) + return true + } + return false +} +func rewriteValueARM64_OpARM64NEGshiftLL(v *Value) bool { + v_0 := v.Args[0] + // match: (NEGshiftLL (MOVDconst [c]) [d]) + // result: (MOVDconst [-int64(uint64(c)<>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-(c >> uint64(d))) + return true + } + return false +} +func rewriteValueARM64_OpARM64NEGshiftRL(v *Value) bool { + v_0 := v.Args[0] + // match: (NEGshiftRL (MOVDconst [c]) [d]) + // result: (MOVDconst [-int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-int64(uint64(c) >> uint64(d))) + return true + } + return false +} +func rewriteValueARM64_OpARM64NotEqual(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (NotEqual (CMPconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (NotEqual (TST x y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPWconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (NotEqual (TSTWconst [int32(c)] y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPWconst [0] z:(AND x y))) + // cond: z.Uses == 1 + // result: (NotEqual (TSTW x y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPconst [0] x:(ANDconst [c] y))) + // cond: x.Uses == 1 + // result: (NotEqual (TSTconst [c] y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMP x z:(NEG y))) + // cond: z.Uses == 1 + // result: (NotEqual (CMN x y)) + for { + if v_0.Op != OpARM64CMP { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpARM64NEG { + break + } + y := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPW x z:(NEG y))) + // cond: z.Uses == 1 + // result: (NotEqual (CMNW x y)) + for { + if v_0.Op != OpARM64CMPW { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpARM64NEG { + break + } + y := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPconst [0] x:(ADDconst [c] y))) + // cond: x.Uses == 1 + // result: (NotEqual (CMNconst [c] y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMNconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPWconst [0] x:(ADDconst [c] y))) + // cond: x.Uses == 1 + // result: (NotEqual (CMNWconst [int32(c)] y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMNWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPconst [0] z:(ADD x y))) + // cond: z.Uses == 1 + // result: (NotEqual (CMN x y)) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPWconst [0] z:(ADD x y))) + // cond: z.Uses == 1 + // result: (NotEqual (CMNW x y)) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + y := z.Args[1] + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPconst [0] z:(MADD a x y))) + // cond: z.Uses == 1 + // result: (NotEqual (CMN a (MUL x y))) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADD { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMN, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPconst [0] z:(MSUB a x y))) + // cond: z.Uses == 1 + // result: (NotEqual (CMP a (MUL x y))) + for { + if v_0.Op != OpARM64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUB { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPWconst [0] z:(MADDW a x y))) + // cond: z.Uses == 1 + // result: (NotEqual (CMNW a (MULW x y))) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADDW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMNW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (NotEqual (CMPWconst [0] z:(MSUBW a x y))) + // cond: z.Uses == 1 + // result: (NotEqual (CMPW a (MULW x y))) + for { + if v_0.Op != OpARM64CMPWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUBW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + v.AddArg(v0) + return true + } + // match: (NotEqual (FlagConstant [fc])) + // result: (MOVDconst [b2i(fc.ne())]) + for { + if v_0.Op != OpARM64FlagConstant { + break + } + fc := auxIntToFlagConstant(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(fc.ne())) + return true + } + // match: (NotEqual (InvertFlags x)) + // result: (NotEqual x) + for { + if v_0.Op != OpARM64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpARM64NotEqual) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64OR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (OR x (MOVDconst [c])) + // result: (ORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (OR x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (OR x (MVN y)) + // result: (ORN x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MVN { + continue + } + y := v_1.Args[0] + v.reset(OpARM64ORN) + v.AddArg2(x, y) + return true + } + break + } + // match: (OR x0 x1:(SLLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ORshiftLL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SLLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ORshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (OR x0 x1:(SRLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ORshiftRL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ORshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (OR x0 x1:(SRAconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ORshiftRA x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRAconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ORshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (OR x0 x1:(RORconst [c] y)) + // cond: clobberIfDead(x1) + // result: (ORshiftRO x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64RORconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64ORshiftRO) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (OR (UBFIZ [bfc] x) (ANDconst [ac] y)) + // cond: ac == ^((1<>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(^(c >> uint64(d))) + v.AddArg(x) + return true + } + // match: (ORNshiftRA (SRAconst x [c]) x [c]) + // result: (MOVDconst [-1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRAconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + return false +} +func rewriteValueARM64_OpARM64ORNshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORNshiftRL x (MOVDconst [c]) [d]) + // result: (ORconst x [^int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(^int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (ORNshiftRL (SRLconst x [c]) x [c]) + // result: (MOVDconst [-1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + return false +} +func rewriteValueARM64_OpARM64ORNshiftRO(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORNshiftRO x (MOVDconst [c]) [d]) + // result: (ORconst x [^rotateRight64(c, d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(^rotateRight64(c, d)) + v.AddArg(x) + return true + } + // match: (ORNshiftRO (RORconst x [c]) x [c]) + // result: (MOVDconst [-1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64RORconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + return false +} +func rewriteValueARM64_OpARM64ORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ORconst [-1] _) + // result: (MOVDconst [-1]) + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (ORconst [c] (MOVDconst [d])) + // result: (MOVDconst [c|d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(c | d) + return true + } + // match: (ORconst [c] (ORconst [d] x)) + // result: (ORconst [c|d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64ORconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(c | d) + v.AddArg(x) + return true + } + // match: (ORconst [c1] (ANDconst [c2] x)) + // cond: c2|c1 == ^0 + // result: (ORconst [c1] x) + for { + c1 := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64ANDconst { + break + } + c2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c2|c1 == ^0) { + break + } + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(c1) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64ORshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ORshiftLL (MOVDconst [c]) x [d]) + // result: (ORconst [c] (SLLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ORshiftLL x (MOVDconst [c]) [d]) + // result: (ORconst x [int64(uint64(c)< [8] (UBFX [armBFAuxInt(8, 8)] x) x) + // result: (REV16W x) + for { + if v.Type != typ.UInt16 || auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64UBFX || v_0.Type != typ.UInt16 || auxIntToArm64BitField(v_0.AuxInt) != armBFAuxInt(8, 8) { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64REV16W) + v.AddArg(x) + return true + } + // match: (ORshiftLL [8] (UBFX [armBFAuxInt(8, 24)] (ANDconst [c1] x)) (ANDconst [c2] x)) + // cond: uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff + // result: (REV16W x) + for { + if auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64UBFX || auxIntToArm64BitField(v_0.AuxInt) != armBFAuxInt(8, 24) { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARM64ANDconst { + break + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpARM64ANDconst { + break + } + c2 := auxIntToInt64(v_1.AuxInt) + if x != v_1.Args[0] || !(uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff) { + break + } + v.reset(OpARM64REV16W) + v.AddArg(x) + return true + } + // match: (ORshiftLL [8] (SRLconst [8] (ANDconst [c1] x)) (ANDconst [c2] x)) + // cond: (uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff) + // result: (REV16 x) + for { + if auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != 8 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARM64ANDconst { + break + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpARM64ANDconst { + break + } + c2 := auxIntToInt64(v_1.AuxInt) + if x != v_1.Args[0] || !(uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff) { + break + } + v.reset(OpARM64REV16) + v.AddArg(x) + return true + } + // match: (ORshiftLL [8] (SRLconst [8] (ANDconst [c1] x)) (ANDconst [c2] x)) + // cond: (uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff) + // result: (REV16 (ANDconst [0xffffffff] x)) + for { + if auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != 8 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARM64ANDconst { + break + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpARM64ANDconst { + break + } + c2 := auxIntToInt64(v_1.AuxInt) + if x != v_1.Args[0] || !(uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff) { + break + } + v.reset(OpARM64REV16) + v0 := b.NewValue0(v.Pos, OpARM64ANDconst, x.Type) + v0.AuxInt = int64ToAuxInt(0xffffffff) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: ( ORshiftLL [c] (SRLconst x [64-c]) x2) + // result: (EXTRconst [64-c] x2 x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != 64-c { + break + } + x := v_0.Args[0] + x2 := v_1 + v.reset(OpARM64EXTRconst) + v.AuxInt = int64ToAuxInt(64 - c) + v.AddArg2(x2, x) + return true + } + // match: ( ORshiftLL [c] (UBFX [bfc] x) x2) + // cond: c < 32 && t.Size() == 4 && bfc == armBFAuxInt(32-c, c) + // result: (EXTRWconst [32-c] x2 x) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64UBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + x2 := v_1 + if !(c < 32 && t.Size() == 4 && bfc == armBFAuxInt(32-c, c)) { + break + } + v.reset(OpARM64EXTRWconst) + v.AuxInt = int64ToAuxInt(32 - c) + v.AddArg2(x2, x) + return true + } + // match: (ORshiftLL [s] (ANDconst [xc] x) (ANDconst [yc] y)) + // cond: xc == ^(yc << s) && yc & (yc+1) == 0 && yc > 0 && s+log64(yc+1) <= 64 + // result: (BFI [armBFAuxInt(s, log64(yc+1))] x y) + for { + s := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64ANDconst { + break + } + xc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if v_1.Op != OpARM64ANDconst { + break + } + yc := auxIntToInt64(v_1.AuxInt) + y := v_1.Args[0] + if !(xc == ^(yc< 0 && s+log64(yc+1) <= 64) { + break + } + v.reset(OpARM64BFI) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(s, log64(yc+1))) + v.AddArg2(x, y) + return true + } + // match: (ORshiftLL [sc] (UBFX [bfc] x) (SRLconst [sc] y)) + // cond: sc == bfc.width() + // result: (BFXIL [bfc] y x) + for { + sc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64UBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if v_1.Op != OpARM64SRLconst || auxIntToInt64(v_1.AuxInt) != sc { + break + } + y := v_1.Args[0] + if !(sc == bfc.width()) { + break + } + v.reset(OpARM64BFXIL) + v.AuxInt = arm64BitFieldToAuxInt(bfc) + v.AddArg2(y, x) + return true + } + return false +} +func rewriteValueARM64_OpARM64ORshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ORshiftRA (MOVDconst [c]) x [d]) + // result: (ORconst [c] (SRAconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRAconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ORshiftRA x (MOVDconst [c]) [d]) + // result: (ORconst x [c>>uint64(d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + // match: (ORshiftRA y:(SRAconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if y.Op != OpARM64SRAconst || auxIntToInt64(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueARM64_OpARM64ORshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ORshiftRL (MOVDconst [c]) x [d]) + // result: (ORconst [c] (SRLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ORshiftRL x (MOVDconst [c]) [d]) + // result: (ORconst x [int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (ORshiftRL y:(SRLconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if y.Op != OpARM64SRLconst || auxIntToInt64(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + // match: (ORshiftRL [rc] (ANDconst [ac] x) (SLLconst [lc] y)) + // cond: lc > rc && ac == ^((1< rc && ac == ^((1< x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64RORconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (ORshiftRO x (MOVDconst [c]) [d]) + // result: (ORconst x [rotateRight64(c, d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64ORconst) + v.AuxInt = int64ToAuxInt(rotateRight64(c, d)) + v.AddArg(x) + return true + } + // match: (ORshiftRO y:(RORconst x [c]) x [c]) + // result: y + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if y.Op != OpARM64RORconst || auxIntToInt64(y.AuxInt) != c { + break + } + x := y.Args[0] + if x != v_1 { + break + } + v.copyOf(y) + return true + } + return false +} +func rewriteValueARM64_OpARM64REV(v *Value) bool { + v_0 := v.Args[0] + // match: (REV (REV p)) + // result: p + for { + if v_0.Op != OpARM64REV { + break + } + p := v_0.Args[0] + v.copyOf(p) + return true + } + return false +} +func rewriteValueARM64_OpARM64REVW(v *Value) bool { + v_0 := v.Args[0] + // match: (REVW (REVW p)) + // result: p + for { + if v_0.Op != OpARM64REVW { + break + } + p := v_0.Args[0] + v.copyOf(p) + return true + } + return false +} +func rewriteValueARM64_OpARM64ROR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROR x (MOVDconst [c])) + // result: (RORconst x [c&63]) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64RORconst) + v.AuxInt = int64ToAuxInt(c & 63) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64RORW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RORW x (MOVDconst [c])) + // result: (RORWconst x [c&31]) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64RORWconst) + v.AuxInt = int64ToAuxInt(c & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64SBCSflags(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SBCSflags x y (Select1 (NEGSflags (NEG (NGCzerocarry bo))))) + // result: (SBCSflags x y bo) + for { + x := v_0 + y := v_1 + if v_2.Op != OpSelect1 || v_2.Type != types.TypeFlags { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpARM64NEGSflags { + break + } + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpARM64NEG || v_2_0_0.Type != typ.UInt64 { + break + } + v_2_0_0_0 := v_2_0_0.Args[0] + if v_2_0_0_0.Op != OpARM64NGCzerocarry || v_2_0_0_0.Type != typ.UInt64 { + break + } + bo := v_2_0_0_0.Args[0] + v.reset(OpARM64SBCSflags) + v.AddArg3(x, y, bo) + return true + } + // match: (SBCSflags x y (Select1 (NEGSflags (MOVDconst [0])))) + // result: (SUBSflags x y) + for { + x := v_0 + y := v_1 + if v_2.Op != OpSelect1 || v_2.Type != types.TypeFlags { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpARM64NEGSflags { + break + } + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpARM64MOVDconst || auxIntToInt64(v_2_0_0.AuxInt) != 0 { + break + } + v.reset(OpARM64SUBSflags) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64SBFX(v *Value) bool { + v_0 := v.Args[0] + // match: (SBFX [bfc] s:(SLLconst [sc] x)) + // cond: s.Uses == 1 && sc <= bfc.lsb() + // result: (SBFX [armBFAuxInt(bfc.lsb() - sc, bfc.width())] x) + for { + bfc := auxIntToArm64BitField(v.AuxInt) + s := v_0 + if s.Op != OpARM64SLLconst { + break + } + sc := auxIntToInt64(s.AuxInt) + x := s.Args[0] + if !(s.Uses == 1 && sc <= bfc.lsb()) { + break + } + v.reset(OpARM64SBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(bfc.lsb()-sc, bfc.width())) + v.AddArg(x) + return true + } + // match: (SBFX [bfc] s:(SLLconst [sc] x)) + // cond: s.Uses == 1 && sc > bfc.lsb() + // result: (SBFIZ [armBFAuxInt(sc - bfc.lsb(), bfc.width() - (sc-bfc.lsb()))] x) + for { + bfc := auxIntToArm64BitField(v.AuxInt) + s := v_0 + if s.Op != OpARM64SLLconst { + break + } + sc := auxIntToInt64(s.AuxInt) + x := s.Args[0] + if !(s.Uses == 1 && sc > bfc.lsb()) { + break + } + v.reset(OpARM64SBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(sc-bfc.lsb(), bfc.width()-(sc-bfc.lsb()))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64SLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLL x (MOVDconst [c])) + // result: (SLLconst x [c&63]) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64SLLconst) + v.AuxInt = int64ToAuxInt(c & 63) + v.AddArg(x) + return true + } + // match: (SLL x (ANDconst [63] y)) + // result: (SLL x y) + for { + x := v_0 + if v_1.Op != OpARM64ANDconst || auxIntToInt64(v_1.AuxInt) != 63 { + break + } + y := v_1.Args[0] + v.reset(OpARM64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64SLLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLLconst [c] (MOVDconst [d])) + // result: (MOVDconst [d<>uint64(c)]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(d >> uint64(c)) + return true + } + // match: (SRAconst [rc] (SLLconst [lc] x)) + // cond: lc > rc + // result: (SBFIZ [armBFAuxInt(lc-rc, 64-lc)] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc > rc) { + break + } + v.reset(OpARM64SBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(lc-rc, 64-lc)) + v.AddArg(x) + return true + } + // match: (SRAconst [rc] (SLLconst [lc] x)) + // cond: lc <= rc + // result: (SBFX [armBFAuxInt(rc-lc, 64-rc)] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc <= rc) { + break + } + v.reset(OpARM64SBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc-lc, 64-rc)) + v.AddArg(x) + return true + } + // match: (SRAconst [rc] (MOVWreg x)) + // cond: rc < 32 + // result: (SBFX [armBFAuxInt(rc, 32-rc)] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVWreg { + break + } + x := v_0.Args[0] + if !(rc < 32) { + break + } + v.reset(OpARM64SBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc, 32-rc)) + v.AddArg(x) + return true + } + // match: (SRAconst [rc] (MOVHreg x)) + // cond: rc < 16 + // result: (SBFX [armBFAuxInt(rc, 16-rc)] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVHreg { + break + } + x := v_0.Args[0] + if !(rc < 16) { + break + } + v.reset(OpARM64SBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc, 16-rc)) + v.AddArg(x) + return true + } + // match: (SRAconst [rc] (MOVBreg x)) + // cond: rc < 8 + // result: (SBFX [armBFAuxInt(rc, 8-rc)] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVBreg { + break + } + x := v_0.Args[0] + if !(rc < 8) { + break + } + v.reset(OpARM64SBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc, 8-rc)) + v.AddArg(x) + return true + } + // match: (SRAconst [sc] (SBFIZ [bfc] x)) + // cond: sc < bfc.lsb() + // result: (SBFIZ [armBFAuxInt(bfc.lsb()-sc, bfc.width())] x) + for { + sc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SBFIZ { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(sc < bfc.lsb()) { + break + } + v.reset(OpARM64SBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(bfc.lsb()-sc, bfc.width())) + v.AddArg(x) + return true + } + // match: (SRAconst [sc] (SBFIZ [bfc] x)) + // cond: sc >= bfc.lsb() && sc < bfc.lsb()+bfc.width() + // result: (SBFX [armBFAuxInt(sc-bfc.lsb(), bfc.lsb()+bfc.width()-sc)] x) + for { + sc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SBFIZ { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(sc >= bfc.lsb() && sc < bfc.lsb()+bfc.width()) { + break + } + v.reset(OpARM64SBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(sc-bfc.lsb(), bfc.lsb()+bfc.width()-sc)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64SRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRL x (MOVDconst [c])) + // result: (SRLconst x [c&63]) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64SRLconst) + v.AuxInt = int64ToAuxInt(c & 63) + v.AddArg(x) + return true + } + // match: (SRL x (ANDconst [63] y)) + // result: (SRL x y) + for { + x := v_0 + if v_1.Op != OpARM64ANDconst || auxIntToInt64(v_1.AuxInt) != 63 { + break + } + y := v_1.Args[0] + v.reset(OpARM64SRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64SRLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRLconst [c] (MOVDconst [d])) + // result: (MOVDconst [int64(uint64(d)>>uint64(c))]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint64(d) >> uint64(c))) + return true + } + // match: (SRLconst [c] (SLLconst [c] x)) + // cond: 0 < c && c < 64 + // result: (ANDconst [1<= 32 + // result: (MOVDconst [0]) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVWUreg { + break + } + if !(rc >= 32) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLconst [rc] (MOVHUreg x)) + // cond: rc >= 16 + // result: (MOVDconst [0]) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVHUreg { + break + } + if !(rc >= 16) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLconst [rc] (MOVBUreg x)) + // cond: rc >= 8 + // result: (MOVDconst [0]) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVBUreg { + break + } + if !(rc >= 8) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLconst [rc] (SLLconst [lc] x)) + // cond: lc > rc + // result: (UBFIZ [armBFAuxInt(lc-rc, 64-lc)] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc > rc) { + break + } + v.reset(OpARM64UBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(lc-rc, 64-lc)) + v.AddArg(x) + return true + } + // match: (SRLconst [rc] (SLLconst [lc] x)) + // cond: lc < rc + // result: (UBFX [armBFAuxInt(rc-lc, 64-rc)] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SLLconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc < rc) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc-lc, 64-rc)) + v.AddArg(x) + return true + } + // match: (SRLconst [rc] (MOVWUreg x)) + // cond: rc < 32 + // result: (UBFX [armBFAuxInt(rc, 32-rc)] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVWUreg { + break + } + x := v_0.Args[0] + if !(rc < 32) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc, 32-rc)) + v.AddArg(x) + return true + } + // match: (SRLconst [rc] (MOVHUreg x)) + // cond: rc < 16 + // result: (UBFX [armBFAuxInt(rc, 16-rc)] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVHUreg { + break + } + x := v_0.Args[0] + if !(rc < 16) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc, 16-rc)) + v.AddArg(x) + return true + } + // match: (SRLconst [rc] (MOVBUreg x)) + // cond: rc < 8 + // result: (UBFX [armBFAuxInt(rc, 8-rc)] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVBUreg { + break + } + x := v_0.Args[0] + if !(rc < 8) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(rc, 8-rc)) + v.AddArg(x) + return true + } + // match: (SRLconst [sc] (ANDconst [ac] x)) + // cond: isARM64BFMask(sc, ac, sc) + // result: (UBFX [armBFAuxInt(sc, arm64BFWidth(ac, sc))] x) + for { + sc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64ANDconst { + break + } + ac := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(isARM64BFMask(sc, ac, sc)) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(sc, arm64BFWidth(ac, sc))) + v.AddArg(x) + return true + } + // match: (SRLconst [sc] (UBFX [bfc] x)) + // cond: sc < bfc.width() + // result: (UBFX [armBFAuxInt(bfc.lsb()+sc, bfc.width()-sc)] x) + for { + sc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64UBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(sc < bfc.width()) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(bfc.lsb()+sc, bfc.width()-sc)) + v.AddArg(x) + return true + } + // match: (SRLconst [sc] (UBFIZ [bfc] x)) + // cond: sc == bfc.lsb() + // result: (ANDconst [1< bfc.lsb() && sc < bfc.lsb()+bfc.width() + // result: (UBFX [armBFAuxInt(sc-bfc.lsb(), bfc.lsb()+bfc.width()-sc)] x) + for { + sc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64UBFIZ { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + if !(sc > bfc.lsb() && sc < bfc.lsb()+bfc.width()) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(sc-bfc.lsb(), bfc.lsb()+bfc.width()-sc)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64STP(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (STP [off1] {sym} (ADDconst [off2] ptr) val1 val2 mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (STP [off1+int32(off2)] {sym} ptr val1 val2 mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpARM64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val1 := v_1 + val2 := v_2 + mem := v_3 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64STP) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg4(ptr, val1, val2, mem) + return true + } + // match: (STP [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val1 val2 mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (STP [off1+off2] {mergeSym(sym1,sym2)} ptr val1 val2 mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpARM64MOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val1 := v_1 + val2 := v_2 + mem := v_3 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpARM64STP) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg4(ptr, val1, val2, mem) + return true + } + return false +} +func rewriteValueARM64_OpARM64SUB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUB x (MOVDconst [c])) + // result: (SUBconst [c] x) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SUB a l:(MUL x y)) + // cond: l.Uses==1 && clobber(l) + // result: (MSUB a x y) + for { + a := v_0 + l := v_1 + if l.Op != OpARM64MUL { + break + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1 && clobber(l)) { + break + } + v.reset(OpARM64MSUB) + v.AddArg3(a, x, y) + return true + } + // match: (SUB a l:(MNEG x y)) + // cond: l.Uses==1 && clobber(l) + // result: (MADD a x y) + for { + a := v_0 + l := v_1 + if l.Op != OpARM64MNEG { + break + } + y := l.Args[1] + x := l.Args[0] + if !(l.Uses == 1 && clobber(l)) { + break + } + v.reset(OpARM64MADD) + v.AddArg3(a, x, y) + return true + } + // match: (SUB a l:(MULW x y)) + // cond: v.Type.Size() <= 4 && l.Uses==1 && clobber(l) + // result: (MSUBW a x y) + for { + a := v_0 + l := v_1 + if l.Op != OpARM64MULW { + break + } + y := l.Args[1] + x := l.Args[0] + if !(v.Type.Size() <= 4 && l.Uses == 1 && clobber(l)) { + break + } + v.reset(OpARM64MSUBW) + v.AddArg3(a, x, y) + return true + } + // match: (SUB a l:(MNEGW x y)) + // cond: v.Type.Size() <= 4 && l.Uses==1 && clobber(l) + // result: (MADDW a x y) + for { + a := v_0 + l := v_1 + if l.Op != OpARM64MNEGW { + break + } + y := l.Args[1] + x := l.Args[0] + if !(v.Type.Size() <= 4 && l.Uses == 1 && clobber(l)) { + break + } + v.reset(OpARM64MADDW) + v.AddArg3(a, x, y) + return true + } + // match: (SUB a p:(ADDconst [c] m:(MUL _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (SUBconst [c] (SUB a m)) + for { + t := v.Type + a := v_0 + p := v_1 + if p.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MUL || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + break + } + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SUB, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + // match: (SUB a p:(ADDconst [c] m:(MULW _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (SUBconst [c] (SUB a m)) + for { + t := v.Type + a := v_0 + p := v_1 + if p.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MULW || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + break + } + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SUB, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + // match: (SUB a p:(ADDconst [c] m:(MNEG _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (SUBconst [c] (SUB a m)) + for { + t := v.Type + a := v_0 + p := v_1 + if p.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MNEG || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + break + } + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SUB, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + // match: (SUB a p:(ADDconst [c] m:(MNEGW _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (SUBconst [c] (SUB a m)) + for { + t := v.Type + a := v_0 + p := v_1 + if p.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MNEGW || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + break + } + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SUB, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + // match: (SUB a p:(SUBconst [c] m:(MUL _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (ADDconst [c] (SUB a m)) + for { + t := v.Type + a := v_0 + p := v_1 + if p.Op != OpARM64SUBconst { + break + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MUL || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + break + } + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SUB, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + // match: (SUB a p:(SUBconst [c] m:(MULW _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (ADDconst [c] (SUB a m)) + for { + t := v.Type + a := v_0 + p := v_1 + if p.Op != OpARM64SUBconst { + break + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MULW || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + break + } + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SUB, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + // match: (SUB a p:(SUBconst [c] m:(MNEG _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (ADDconst [c] (SUB a m)) + for { + t := v.Type + a := v_0 + p := v_1 + if p.Op != OpARM64SUBconst { + break + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MNEG || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + break + } + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SUB, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + // match: (SUB a p:(SUBconst [c] m:(MNEGW _ _))) + // cond: p.Uses==1 && m.Uses==1 && !t.IsPtrShaped() + // result: (ADDconst [c] (SUB a m)) + for { + t := v.Type + a := v_0 + p := v_1 + if p.Op != OpARM64SUBconst { + break + } + c := auxIntToInt64(p.AuxInt) + m := p.Args[0] + if m.Op != OpARM64MNEGW || !(p.Uses == 1 && m.Uses == 1 && !t.IsPtrShaped()) { + break + } + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SUB, v.Type) + v0.AddArg2(a, m) + v.AddArg(v0) + return true + } + // match: (SUB x (NEG y)) + // result: (ADD x y) + for { + x := v_0 + if v_1.Op != OpARM64NEG { + break + } + y := v_1.Args[0] + v.reset(OpARM64ADD) + v.AddArg2(x, y) + return true + } + // match: (SUB x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SUB x (SUB y z)) + // result: (SUB (ADD x z) y) + for { + x := v_0 + if v_1.Op != OpARM64SUB { + break + } + z := v_1.Args[1] + y := v_1.Args[0] + v.reset(OpARM64SUB) + v0 := b.NewValue0(v.Pos, OpARM64ADD, v.Type) + v0.AddArg2(x, z) + v.AddArg2(v0, y) + return true + } + // match: (SUB (SUB x y) z) + // result: (SUB x (ADD y z)) + for { + if v_0.Op != OpARM64SUB { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + z := v_1 + v.reset(OpARM64SUB) + v0 := b.NewValue0(v.Pos, OpARM64ADD, y.Type) + v0.AddArg2(y, z) + v.AddArg2(x, v0) + return true + } + // match: (SUB x0 x1:(SLLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (SUBshiftLL x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SLLconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64SUBshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (SUB x0 x1:(SRLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (SUBshiftRL x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRLconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64SUBshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + // match: (SUB x0 x1:(SRAconst [c] y)) + // cond: clobberIfDead(x1) + // result: (SUBshiftRA x0 y [c]) + for { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRAconst { + break + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + break + } + v.reset(OpARM64SUBshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + return false +} +func rewriteValueARM64_OpARM64SUBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SUBconst [c] (MOVDconst [d])) + // result: (MOVDconst [d-c]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(d - c) + return true + } + // match: (SUBconst [c] (SUBconst [d] x)) + // result: (ADDconst [-c-d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SUBconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(-c - d) + v.AddArg(x) + return true + } + // match: (SUBconst [c] (ADDconst [d] x)) + // result: (ADDconst [-c+d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64ADDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(-c + d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64SUBshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBshiftLL x (MOVDconst [c]) [d]) + // result: (SUBconst x [int64(uint64(c)<>uint64(d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + // match: (SUBshiftRA (SRAconst x [c]) x [c]) + // result: (MOVDconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRAconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM64_OpARM64SUBshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBshiftRL x (MOVDconst [c]) [d]) + // result: (SUBconst x [int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64SUBconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (SUBshiftRL (SRLconst x [c]) x [c]) + // result: (MOVDconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM64_OpARM64TST(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (TST x (MOVDconst [c])) + // result: (TSTconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64TSTconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (TST x0 x1:(SLLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (TSTshiftLL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SLLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64TSTshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (TST x0 x1:(SRLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (TSTshiftRL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64TSTshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (TST x0 x1:(SRAconst [c] y)) + // cond: clobberIfDead(x1) + // result: (TSTshiftRA x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRAconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64TSTshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (TST x0 x1:(RORconst [c] y)) + // cond: clobberIfDead(x1) + // result: (TSTshiftRO x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64RORconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64TSTshiftRO) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64TSTW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (TSTW x (MOVDconst [c])) + // result: (TSTWconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64TSTWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64TSTWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (TSTWconst (MOVDconst [x]) [y]) + // result: (FlagConstant [logicFlags32(int32(x)&y)]) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(logicFlags32(int32(x) & y)) + return true + } + return false +} +func rewriteValueARM64_OpARM64TSTconst(v *Value) bool { + v_0 := v.Args[0] + // match: (TSTconst (MOVDconst [x]) [y]) + // result: (FlagConstant [logicFlags64(x&y)]) + for { + y := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64FlagConstant) + v.AuxInt = flagConstantToAuxInt(logicFlags64(x & y)) + return true + } + return false +} +func rewriteValueARM64_OpARM64TSTshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TSTshiftLL (MOVDconst [c]) x [d]) + // result: (TSTconst [c] (SLLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64TSTconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (TSTshiftLL x (MOVDconst [c]) [d]) + // result: (TSTconst x [int64(uint64(c)< x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64TSTconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRAconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (TSTshiftRA x (MOVDconst [c]) [d]) + // result: (TSTconst x [c>>uint64(d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64TSTconst) + v.AuxInt = int64ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64TSTshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TSTshiftRL (MOVDconst [c]) x [d]) + // result: (TSTconst [c] (SRLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64TSTconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (TSTshiftRL x (MOVDconst [c]) [d]) + // result: (TSTconst x [int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64TSTconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64TSTshiftRO(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (TSTshiftRO (MOVDconst [c]) x [d]) + // result: (TSTconst [c] (RORconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64TSTconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64RORconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (TSTshiftRO x (MOVDconst [c]) [d]) + // result: (TSTconst x [rotateRight64(c, d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64TSTconst) + v.AuxInt = int64ToAuxInt(rotateRight64(c, d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64UBFIZ(v *Value) bool { + v_0 := v.Args[0] + // match: (UBFIZ [bfc] (SLLconst [sc] x)) + // cond: sc < bfc.width() + // result: (UBFIZ [armBFAuxInt(bfc.lsb()+sc, bfc.width()-sc)] x) + for { + bfc := auxIntToArm64BitField(v.AuxInt) + if v_0.Op != OpARM64SLLconst { + break + } + sc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(sc < bfc.width()) { + break + } + v.reset(OpARM64UBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(bfc.lsb()+sc, bfc.width()-sc)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64UBFX(v *Value) bool { + v_0 := v.Args[0] + // match: (UBFX [bfc] (ANDconst [c] x)) + // cond: isARM64BFMask(0, c, 0) && bfc.lsb() + bfc.width() <= arm64BFWidth(c, 0) + // result: (UBFX [bfc] x) + for { + bfc := auxIntToArm64BitField(v.AuxInt) + if v_0.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(isARM64BFMask(0, c, 0) && bfc.lsb()+bfc.width() <= arm64BFWidth(c, 0)) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(bfc) + v.AddArg(x) + return true + } + // match: (UBFX [bfc] e:(MOVWUreg x)) + // cond: e.Uses == 1 && bfc.lsb() < 32 + // result: (UBFX [armBFAuxInt(bfc.lsb(), min(bfc.width(), 32-bfc.lsb()))] x) + for { + bfc := auxIntToArm64BitField(v.AuxInt) + e := v_0 + if e.Op != OpARM64MOVWUreg { + break + } + x := e.Args[0] + if !(e.Uses == 1 && bfc.lsb() < 32) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(bfc.lsb(), min(bfc.width(), 32-bfc.lsb()))) + v.AddArg(x) + return true + } + // match: (UBFX [bfc] e:(MOVHUreg x)) + // cond: e.Uses == 1 && bfc.lsb() < 16 + // result: (UBFX [armBFAuxInt(bfc.lsb(), min(bfc.width(), 16-bfc.lsb()))] x) + for { + bfc := auxIntToArm64BitField(v.AuxInt) + e := v_0 + if e.Op != OpARM64MOVHUreg { + break + } + x := e.Args[0] + if !(e.Uses == 1 && bfc.lsb() < 16) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(bfc.lsb(), min(bfc.width(), 16-bfc.lsb()))) + v.AddArg(x) + return true + } + // match: (UBFX [bfc] e:(MOVBUreg x)) + // cond: e.Uses == 1 && bfc.lsb() < 8 + // result: (UBFX [armBFAuxInt(bfc.lsb(), min(bfc.width(), 8-bfc.lsb()))] x) + for { + bfc := auxIntToArm64BitField(v.AuxInt) + e := v_0 + if e.Op != OpARM64MOVBUreg { + break + } + x := e.Args[0] + if !(e.Uses == 1 && bfc.lsb() < 8) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(bfc.lsb(), min(bfc.width(), 8-bfc.lsb()))) + v.AddArg(x) + return true + } + // match: (UBFX [bfc] (SRLconst [sc] x)) + // cond: sc+bfc.width()+bfc.lsb() < 64 + // result: (UBFX [armBFAuxInt(bfc.lsb()+sc, bfc.width())] x) + for { + bfc := auxIntToArm64BitField(v.AuxInt) + if v_0.Op != OpARM64SRLconst { + break + } + sc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(sc+bfc.width()+bfc.lsb() < 64) { + break + } + v.reset(OpARM64UBFX) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(bfc.lsb()+sc, bfc.width())) + v.AddArg(x) + return true + } + // match: (UBFX [bfc] (SLLconst [sc] x)) + // cond: sc == bfc.lsb() + // result: (ANDconst [1< bfc.lsb() && sc < bfc.lsb()+bfc.width() + // result: (UBFIZ [armBFAuxInt(sc-bfc.lsb(), bfc.lsb()+bfc.width()-sc)] x) + for { + bfc := auxIntToArm64BitField(v.AuxInt) + if v_0.Op != OpARM64SLLconst { + break + } + sc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(sc > bfc.lsb() && sc < bfc.lsb()+bfc.width()) { + break + } + v.reset(OpARM64UBFIZ) + v.AuxInt = arm64BitFieldToAuxInt(armBFAuxInt(sc-bfc.lsb(), bfc.lsb()+bfc.width()-sc)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64UDIV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (UDIV x (MOVDconst [1])) + // result: x + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.copyOf(x) + return true + } + // match: (UDIV x (MOVDconst [c])) + // cond: isPowerOfTwo(c) + // result: (SRLconst [log64(c)] x) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARM64SRLconst) + v.AuxInt = int64ToAuxInt(log64(c)) + v.AddArg(x) + return true + } + // match: (UDIV (MOVDconst [c]) (MOVDconst [d])) + // cond: d != 0 + // result: (MOVDconst [int64(uint64(c)/uint64(d))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) / uint64(d))) + return true + } + return false +} +func rewriteValueARM64_OpARM64UDIVW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (UDIVW x (MOVDconst [c])) + // cond: uint32(c)==1 + // result: (MOVWUreg x) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) == 1) { + break + } + v.reset(OpARM64MOVWUreg) + v.AddArg(x) + return true + } + // match: (UDIVW x (MOVDconst [c])) + // cond: isPowerOfTwo(c) && is32Bit(c) + // result: (SRLconst [log64(c)] (MOVWUreg x)) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c) && is32Bit(c)) { + break + } + v.reset(OpARM64SRLconst) + v.AuxInt = int64ToAuxInt(log64(c)) + v0 := b.NewValue0(v.Pos, OpARM64MOVWUreg, v.Type) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (UDIVW (MOVDconst [c]) (MOVDconst [d])) + // cond: d != 0 + // result: (MOVDconst [int64(uint32(c)/uint32(d))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint32(c) / uint32(d))) + return true + } + return false +} +func rewriteValueARM64_OpARM64UMOD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (UMOD x y) + // result: (MSUB x y (UDIV x y)) + for { + if v.Type != typ.UInt64 { + break + } + x := v_0 + y := v_1 + v.reset(OpARM64MSUB) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpARM64UDIV, typ.UInt64) + v0.AddArg2(x, y) + v.AddArg3(x, y, v0) + return true + } + // match: (UMOD _ (MOVDconst [1])) + // result: (MOVDconst [0]) + for { + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (UMOD x (MOVDconst [c])) + // cond: isPowerOfTwo(c) + // result: (ANDconst [c-1] x) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c - 1) + v.AddArg(x) + return true + } + // match: (UMOD (MOVDconst [c]) (MOVDconst [d])) + // cond: d != 0 + // result: (MOVDconst [int64(uint64(c)%uint64(d))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) % uint64(d))) + return true + } + return false +} +func rewriteValueARM64_OpARM64UMODW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (UMODW x y) + // result: (MSUBW x y (UDIVW x y)) + for { + if v.Type != typ.UInt32 { + break + } + x := v_0 + y := v_1 + v.reset(OpARM64MSUBW) + v.Type = typ.UInt32 + v0 := b.NewValue0(v.Pos, OpARM64UDIVW, typ.UInt32) + v0.AddArg2(x, y) + v.AddArg3(x, y, v0) + return true + } + // match: (UMODW _ (MOVDconst [c])) + // cond: uint32(c)==1 + // result: (MOVDconst [0]) + for { + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) == 1) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (UMODW x (MOVDconst [c])) + // cond: isPowerOfTwo(c) && is32Bit(c) + // result: (ANDconst [c-1] x) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c) && is32Bit(c)) { + break + } + v.reset(OpARM64ANDconst) + v.AuxInt = int64ToAuxInt(c - 1) + v.AddArg(x) + return true + } + // match: (UMODW (MOVDconst [c]) (MOVDconst [d])) + // cond: d != 0 + // result: (MOVDconst [int64(uint32(c)%uint32(d))]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint32(c) % uint32(d))) + return true + } + return false +} +func rewriteValueARM64_OpARM64XOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XOR x (MOVDconst [c])) + // result: (XORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (XOR x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (XOR x (MVN y)) + // result: (EON x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpARM64MVN { + continue + } + y := v_1.Args[0] + v.reset(OpARM64EON) + v.AddArg2(x, y) + return true + } + break + } + // match: (XOR x0 x1:(SLLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (XORshiftLL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SLLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64XORshiftLL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (XOR x0 x1:(SRLconst [c] y)) + // cond: clobberIfDead(x1) + // result: (XORshiftRL x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRLconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64XORshiftRL) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (XOR x0 x1:(SRAconst [c] y)) + // cond: clobberIfDead(x1) + // result: (XORshiftRA x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64SRAconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64XORshiftRA) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (XOR x0 x1:(RORconst [c] y)) + // cond: clobberIfDead(x1) + // result: (XORshiftRO x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpARM64RORconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(clobberIfDead(x1)) { + continue + } + v.reset(OpARM64XORshiftRO) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + return false +} +func rewriteValueARM64_OpARM64XORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (XORconst [-1] x) + // result: (MVN x) + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + x := v_0 + v.reset(OpARM64MVN) + v.AddArg(x) + return true + } + // match: (XORconst [c] (MOVDconst [d])) + // result: (MOVDconst [c^d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(c ^ d) + return true + } + // match: (XORconst [c] (XORconst [d] x)) + // result: (XORconst [c^d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64XORconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(c ^ d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64_OpARM64XORshiftLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (XORshiftLL (MOVDconst [c]) x [d]) + // result: (XORconst [c] (SLLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SLLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (XORshiftLL x (MOVDconst [c]) [d]) + // result: (XORconst x [int64(uint64(c)< [8] (UBFX [armBFAuxInt(8, 8)] x) x) + // result: (REV16W x) + for { + if v.Type != typ.UInt16 || auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64UBFX || v_0.Type != typ.UInt16 || auxIntToArm64BitField(v_0.AuxInt) != armBFAuxInt(8, 8) { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64REV16W) + v.AddArg(x) + return true + } + // match: (XORshiftLL [8] (UBFX [armBFAuxInt(8, 24)] (ANDconst [c1] x)) (ANDconst [c2] x)) + // cond: uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff + // result: (REV16W x) + for { + if auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64UBFX || auxIntToArm64BitField(v_0.AuxInt) != armBFAuxInt(8, 24) { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARM64ANDconst { + break + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpARM64ANDconst { + break + } + c2 := auxIntToInt64(v_1.AuxInt) + if x != v_1.Args[0] || !(uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff) { + break + } + v.reset(OpARM64REV16W) + v.AddArg(x) + return true + } + // match: (XORshiftLL [8] (SRLconst [8] (ANDconst [c1] x)) (ANDconst [c2] x)) + // cond: (uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff) + // result: (REV16 x) + for { + if auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != 8 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARM64ANDconst { + break + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpARM64ANDconst { + break + } + c2 := auxIntToInt64(v_1.AuxInt) + if x != v_1.Args[0] || !(uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff) { + break + } + v.reset(OpARM64REV16) + v.AddArg(x) + return true + } + // match: (XORshiftLL [8] (SRLconst [8] (ANDconst [c1] x)) (ANDconst [c2] x)) + // cond: (uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff) + // result: (REV16 (ANDconst [0xffffffff] x)) + for { + if auxIntToInt64(v.AuxInt) != 8 || v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != 8 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpARM64ANDconst { + break + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpARM64ANDconst { + break + } + c2 := auxIntToInt64(v_1.AuxInt) + if x != v_1.Args[0] || !(uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff) { + break + } + v.reset(OpARM64REV16) + v0 := b.NewValue0(v.Pos, OpARM64ANDconst, x.Type) + v0.AuxInt = int64ToAuxInt(0xffffffff) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (XORshiftLL [c] (SRLconst x [64-c]) x2) + // result: (EXTRconst [64-c] x2 x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != 64-c { + break + } + x := v_0.Args[0] + x2 := v_1 + v.reset(OpARM64EXTRconst) + v.AuxInt = int64ToAuxInt(64 - c) + v.AddArg2(x2, x) + return true + } + // match: (XORshiftLL [c] (UBFX [bfc] x) x2) + // cond: c < 32 && t.Size() == 4 && bfc == armBFAuxInt(32-c, c) + // result: (EXTRWconst [32-c] x2 x) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64UBFX { + break + } + bfc := auxIntToArm64BitField(v_0.AuxInt) + x := v_0.Args[0] + x2 := v_1 + if !(c < 32 && t.Size() == 4 && bfc == armBFAuxInt(32-c, c)) { + break + } + v.reset(OpARM64EXTRWconst) + v.AuxInt = int64ToAuxInt(32 - c) + v.AddArg2(x2, x) + return true + } + return false +} +func rewriteValueARM64_OpARM64XORshiftRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (XORshiftRA (MOVDconst [c]) x [d]) + // result: (XORconst [c] (SRAconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRAconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (XORshiftRA x (MOVDconst [c]) [d]) + // result: (XORconst x [c>>uint64(d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(c >> uint64(d)) + v.AddArg(x) + return true + } + // match: (XORshiftRA (SRAconst x [c]) x [c]) + // result: (MOVDconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRAconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM64_OpARM64XORshiftRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (XORshiftRL (MOVDconst [c]) x [d]) + // result: (XORconst [c] (SRLconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64SRLconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (XORshiftRL x (MOVDconst [c]) [d]) + // result: (XORconst x [int64(uint64(c)>>uint64(d))]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) >> uint64(d))) + v.AddArg(x) + return true + } + // match: (XORshiftRL (SRLconst x [c]) x [c]) + // result: (MOVDconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64SRLconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM64_OpARM64XORshiftRO(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (XORshiftRO (MOVDconst [c]) x [d]) + // result: (XORconst [c] (RORconst x [d])) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpARM64RORconst, x.Type) + v0.AuxInt = int64ToAuxInt(d) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (XORshiftRO x (MOVDconst [c]) [d]) + // result: (XORconst x [rotateRight64(c, d)]) + for { + d := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpARM64XORconst) + v.AuxInt = int64ToAuxInt(rotateRight64(c, d)) + v.AddArg(x) + return true + } + // match: (XORshiftRO (RORconst x [c]) x [c]) + // result: (MOVDconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpARM64RORconst || auxIntToInt64(v_0.AuxInt) != c { + break + } + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueARM64_OpAddr(v *Value) bool { + v_0 := v.Args[0] + // match: (Addr {sym} base) + // result: (MOVDaddr {sym} base) + for { + sym := auxToSym(v.Aux) + base := v_0 + v.reset(OpARM64MOVDaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } +} +func rewriteValueARM64_OpAvg64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Avg64u x y) + // result: (ADD (SRLconst (SUB x y) [1]) y) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpARM64ADD) + v0 := b.NewValue0(v.Pos, OpARM64SRLconst, t) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpARM64SUB, t) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueARM64_OpBitLen16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen16 x) + // result: (BitLen64 (ZeroExt16to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpBitLen32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen32 x) + // result: (SUB (MOVDconst [32]) (CLZW x)) + for { + x := v_0 + v.reset(OpARM64SUB) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(32) + v1 := b.NewValue0(v.Pos, OpARM64CLZW, typ.Int) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM64_OpBitLen64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen64 x) + // result: (SUB (MOVDconst [64]) (CLZ x)) + for { + x := v_0 + v.reset(OpARM64SUB) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(64) + v1 := b.NewValue0(v.Pos, OpARM64CLZ, typ.Int) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM64_OpBitLen8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen8 x) + // result: (BitLen64 (ZeroExt8to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpBitRev16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitRev16 x) + // result: (SRLconst [48] (RBIT x)) + for { + x := v_0 + v.reset(OpARM64SRLconst) + v.AuxInt = int64ToAuxInt(48) + v0 := b.NewValue0(v.Pos, OpARM64RBIT, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpBitRev8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitRev8 x) + // result: (SRLconst [56] (RBIT x)) + for { + x := v_0 + v.reset(OpARM64SRLconst) + v.AuxInt = int64ToAuxInt(56) + v0 := b.NewValue0(v.Pos, OpARM64RBIT, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpCondSelect(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CondSelect x y boolval) + // cond: flagArg(boolval) != nil + // result: (CSEL [boolval.Op] x y flagArg(boolval)) + for { + x := v_0 + y := v_1 + boolval := v_2 + if !(flagArg(boolval) != nil) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(boolval.Op) + v.AddArg3(x, y, flagArg(boolval)) + return true + } + // match: (CondSelect x y boolval) + // cond: flagArg(boolval) == nil + // result: (CSEL [OpARM64NotEqual] x y (TSTWconst [1] boolval)) + for { + x := v_0 + y := v_1 + boolval := v_2 + if !(flagArg(boolval) == nil) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(1) + v0.AddArg(boolval) + v.AddArg3(x, y, v0) + return true + } + return false +} +func rewriteValueARM64_OpConst16(v *Value) bool { + // match: (Const16 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt16(v.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueARM64_OpConst32(v *Value) bool { + // match: (Const32 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt32(v.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueARM64_OpConst32F(v *Value) bool { + // match: (Const32F [val]) + // result: (FMOVSconst [float64(val)]) + for { + val := auxIntToFloat32(v.AuxInt) + v.reset(OpARM64FMOVSconst) + v.AuxInt = float64ToAuxInt(float64(val)) + return true + } +} +func rewriteValueARM64_OpConst64(v *Value) bool { + // match: (Const64 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt64(v.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueARM64_OpConst64F(v *Value) bool { + // match: (Const64F [val]) + // result: (FMOVDconst [float64(val)]) + for { + val := auxIntToFloat64(v.AuxInt) + v.reset(OpARM64FMOVDconst) + v.AuxInt = float64ToAuxInt(float64(val)) + return true + } +} +func rewriteValueARM64_OpConst8(v *Value) bool { + // match: (Const8 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt8(v.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueARM64_OpConstBool(v *Value) bool { + // match: (ConstBool [t]) + // result: (MOVDconst [b2i(t)]) + for { + t := auxIntToBool(v.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(t)) + return true + } +} +func rewriteValueARM64_OpConstNil(v *Value) bool { + // match: (ConstNil) + // result: (MOVDconst [0]) + for { + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } +} +func rewriteValueARM64_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz16 x) + // result: (CLZW (RBITW (ORconst [0x10000] x))) + for { + t := v.Type + x := v_0 + v.reset(OpARM64CLZW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARM64RBITW, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpARM64ORconst, typ.UInt32) + v1.AuxInt = int64ToAuxInt(0x10000) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpCtz32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Ctz32 x) + // result: (CLZW (RBITW x)) + for { + t := v.Type + x := v_0 + v.reset(OpARM64CLZW) + v0 := b.NewValue0(v.Pos, OpARM64RBITW, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpCtz64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Ctz64 x) + // result: (CLZ (RBIT x)) + for { + t := v.Type + x := v_0 + v.reset(OpARM64CLZ) + v0 := b.NewValue0(v.Pos, OpARM64RBIT, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz8 x) + // result: (CLZW (RBITW (ORconst [0x100] x))) + for { + t := v.Type + x := v_0 + v.reset(OpARM64CLZW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARM64RBITW, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpARM64ORconst, typ.UInt32) + v1.AuxInt = int64ToAuxInt(0x100) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 [false] x y) + // result: (DIVW (SignExt16to32 x) (SignExt16to32 y)) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpARM64DIVW) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u x y) + // result: (UDIVW (ZeroExt16to32 x) (ZeroExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64UDIVW) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM64_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Div32 [false] x y) + // result: (DIVW x y) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpARM64DIVW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM64_OpDiv64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Div64 [false] x y) + // result: (DIV x y) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpARM64DIV) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM64_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (DIVW (SignExt8to32 x) (SignExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64DIVW) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM64_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (UDIVW (ZeroExt8to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64UDIVW) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM64_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq16 x y) + // result: (Equal (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32 x y) + // result: (Equal (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpEq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32F x y) + // result: (Equal (FCMPS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64FCMPS, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpEq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64 x y) + // result: (Equal (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpEq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64F x y) + // result: (Equal (FCMPD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64FCMPD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq8 x y) + // result: (Equal (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqB x y) + // result: (XOR (MOVDconst [1]) (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64XOR) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpARM64XOR, typ.Bool) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM64_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (EqPtr x y) + // result: (Equal (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64Equal) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpFMA(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMA x y z) + // result: (FMADDD z x y) + for { + x := v_0 + y := v_1 + z := v_2 + v.reset(OpARM64FMADDD) + v.AddArg3(z, x, y) + return true + } +} +func rewriteValueARM64_OpHmul32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul32 x y) + // result: (SRAconst (MULL x y) [32]) + for { + x := v_0 + y := v_1 + v.reset(OpARM64SRAconst) + v.AuxInt = int64ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpARM64MULL, typ.Int64) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpHmul32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul32u x y) + // result: (SRAconst (UMULL x y) [32]) + for { + x := v_0 + y := v_1 + v.reset(OpARM64SRAconst) + v.AuxInt = int64ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpARM64UMULL, typ.UInt64) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpIsInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (IsInBounds idx len) + // result: (LessThanU (CMP idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpIsNonNil(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (IsNonNil ptr) + // result: (NotEqual (CMPconst [0] ptr)) + for { + ptr := v_0 + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(0) + v0.AddArg(ptr) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpIsSliceInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (IsSliceInBounds idx len) + // result: (LessEqualU (CMP idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpARM64LessEqualU) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16 x y) + // result: (LessEqual (CMPW (SignExt16to32 x) (SignExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16U x zero:(MOVDconst [0])) + // result: (Eq16 x zero) + for { + x := v_0 + zero := v_1 + if zero.Op != OpARM64MOVDconst || auxIntToInt64(zero.AuxInt) != 0 { + break + } + v.reset(OpEq16) + v.AddArg2(x, zero) + return true + } + // match: (Leq16U (MOVDconst [1]) x) + // result: (Neq16 (MOVDconst [0]) x) + for { + if v_0.Op != OpARM64MOVDconst || auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpNeq16) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq16U x y) + // result: (LessEqualU (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessEqualU) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32 x y) + // result: (LessEqual (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32F x y) + // result: (LessEqualF (FCMPS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessEqualF) + v0 := b.NewValue0(v.Pos, OpARM64FCMPS, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32U x zero:(MOVDconst [0])) + // result: (Eq32 x zero) + for { + x := v_0 + zero := v_1 + if zero.Op != OpARM64MOVDconst || auxIntToInt64(zero.AuxInt) != 0 { + break + } + v.reset(OpEq32) + v.AddArg2(x, zero) + return true + } + // match: (Leq32U (MOVDconst [1]) x) + // result: (Neq32 (MOVDconst [0]) x) + for { + if v_0.Op != OpARM64MOVDconst || auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpNeq32) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq32U x y) + // result: (LessEqualU (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessEqualU) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64 x y) + // result: (LessEqual (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64F x y) + // result: (LessEqualF (FCMPD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessEqualF) + v0 := b.NewValue0(v.Pos, OpARM64FCMPD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLeq64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64U x zero:(MOVDconst [0])) + // result: (Eq64 x zero) + for { + x := v_0 + zero := v_1 + if zero.Op != OpARM64MOVDconst || auxIntToInt64(zero.AuxInt) != 0 { + break + } + v.reset(OpEq64) + v.AddArg2(x, zero) + return true + } + // match: (Leq64U (MOVDconst [1]) x) + // result: (Neq64 (MOVDconst [0]) x) + for { + if v_0.Op != OpARM64MOVDconst || auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpNeq64) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq64U x y) + // result: (LessEqualU (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessEqualU) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8 x y) + // result: (LessEqual (CMPW (SignExt8to32 x) (SignExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8U x zero:(MOVDconst [0])) + // result: (Eq8 x zero) + for { + x := v_0 + zero := v_1 + if zero.Op != OpARM64MOVDconst || auxIntToInt64(zero.AuxInt) != 0 { + break + } + v.reset(OpEq8) + v.AddArg2(x, zero) + return true + } + // match: (Leq8U (MOVDconst [1]) x) + // result: (Neq8 (MOVDconst [0]) x) + for { + if v_0.Op != OpARM64MOVDconst || auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpNeq8) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq8U x y) + // result: (LessEqualU (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessEqualU) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16 x y) + // result: (LessThan (CMPW (SignExt16to32 x) (SignExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessThan) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16U zero:(MOVDconst [0]) x) + // result: (Neq16 zero x) + for { + zero := v_0 + if zero.Op != OpARM64MOVDconst || auxIntToInt64(zero.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpNeq16) + v.AddArg2(zero, x) + return true + } + // match: (Less16U x (MOVDconst [1])) + // result: (Eq16 x (MOVDconst [0])) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less16U x y) + // result: (LessThanU (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32 x y) + // result: (LessThan (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessThan) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLess32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32F x y) + // result: (LessThanF (FCMPS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessThanF) + v0 := b.NewValue0(v.Pos, OpARM64FCMPS, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32U zero:(MOVDconst [0]) x) + // result: (Neq32 zero x) + for { + zero := v_0 + if zero.Op != OpARM64MOVDconst || auxIntToInt64(zero.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpNeq32) + v.AddArg2(zero, x) + return true + } + // match: (Less32U x (MOVDconst [1])) + // result: (Eq32 x (MOVDconst [0])) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less32U x y) + // result: (LessThanU (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLess64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64 x y) + // result: (LessThan (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessThan) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLess64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64F x y) + // result: (LessThanF (FCMPD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessThanF) + v0 := b.NewValue0(v.Pos, OpARM64FCMPD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLess64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less64U zero:(MOVDconst [0]) x) + // result: (Neq64 zero x) + for { + zero := v_0 + if zero.Op != OpARM64MOVDconst || auxIntToInt64(zero.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpNeq64) + v.AddArg2(zero, x) + return true + } + // match: (Less64U x (MOVDconst [1])) + // result: (Eq64 x (MOVDconst [0])) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less64U x y) + // result: (LessThanU (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8 x y) + // result: (LessThan (CMPW (SignExt8to32 x) (SignExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessThan) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8U zero:(MOVDconst [0]) x) + // result: (Neq8 zero x) + for { + zero := v_0 + if zero.Op != OpARM64MOVDconst || auxIntToInt64(zero.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpNeq8) + v.AddArg2(zero, x) + return true + } + // match: (Less8U x (MOVDconst [1])) + // result: (Eq8 x (MOVDconst [0])) + for { + x := v_0 + if v_1.Op != OpARM64MOVDconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less8U x y) + // result: (LessThanU (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Load ptr mem) + // cond: t.IsBoolean() + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsBoolean()) { + break + } + v.reset(OpARM64MOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is8BitInt(t) && t.IsSigned()) + // result: (MOVBload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpARM64MOVBload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is8BitInt(t) && !t.IsSigned()) + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpARM64MOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && t.IsSigned()) + // result: (MOVHload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpARM64MOVHload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && !t.IsSigned()) + // result: (MOVHUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpARM64MOVHUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is32BitInt(t) && t.IsSigned()) + // result: (MOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpARM64MOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is32BitInt(t) && !t.IsSigned()) + // result: (MOVWUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpARM64MOVWUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (MOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpARM64MOVDload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (FMOVSload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(OpARM64FMOVSload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (FMOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(OpARM64FMOVDload) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueARM64_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (MOVDaddr {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(OpARM64MOVDaddr) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (MOVDaddr {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(OpARM64MOVDaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValueARM64_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh16x16 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh16x32 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh16x64 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh16x8 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh32x16 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh32x32 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh32x64 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh32x8 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh64x16 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh64x32 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh64x64 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh64x8 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh8x16 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh8x32 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh8x64 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SLL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Lsh8x8 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SLL x y) (Const64 [0]) (CMPconst [64] (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16 x y) + // result: (MODW (SignExt16to32 x) (SignExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64MODW) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM64_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16u x y) + // result: (UMODW (ZeroExt16to32 x) (ZeroExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64UMODW) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM64_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Mod32 x y) + // result: (MODW x y) + for { + x := v_0 + y := v_1 + v.reset(OpARM64MODW) + v.AddArg2(x, y) + return true + } +} +func rewriteValueARM64_OpMod64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Mod64 x y) + // result: (MOD x y) + for { + x := v_0 + y := v_1 + v.reset(OpARM64MOD) + v.AddArg2(x, y) + return true + } +} +func rewriteValueARM64_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (MODW (SignExt8to32 x) (SignExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64MODW) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM64_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (UMODW (ZeroExt8to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64UMODW) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueARM64_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (MOVBstore dst (MOVBUload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVBstore) + v0 := b.NewValue0(v.Pos, OpARM64MOVBUload, typ.UInt8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (MOVHstore dst (MOVHUload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVHstore) + v0 := b.NewValue0(v.Pos, OpARM64MOVHUload, typ.UInt16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [3] dst src mem) + // result: (MOVBstore [2] dst (MOVBUload [2] src mem) (MOVHstore dst (MOVHUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpARM64MOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVHstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVHUload, typ.UInt16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [4] dst src mem) + // result: (MOVWstore dst (MOVWUload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVWstore) + v0 := b.NewValue0(v.Pos, OpARM64MOVWUload, typ.UInt32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [5] dst src mem) + // result: (MOVBstore [4] dst (MOVBUload [4] src mem) (MOVWstore dst (MOVWUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpARM64MOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVWUload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [6] dst src mem) + // result: (MOVHstore [4] dst (MOVHUload [4] src mem) (MOVWstore dst (MOVWUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpARM64MOVHUload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVWUload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [7] dst src mem) + // result: (MOVWstore [3] dst (MOVWUload [3] src mem) (MOVWstore dst (MOVWUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpARM64MOVWUload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVWUload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [8] dst src mem) + // result: (MOVDstore dst (MOVDload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVDstore) + v0 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [9] dst src mem) + // result: (MOVBstore [8] dst (MOVBUload [8] src mem) (MOVDstore dst (MOVDload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 9 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpARM64MOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [10] dst src mem) + // result: (MOVHstore [8] dst (MOVHUload [8] src mem) (MOVDstore dst (MOVDload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 10 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpARM64MOVHUload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [11] dst src mem) + // result: (MOVDstore [3] dst (MOVDload [3] src mem) (MOVDstore dst (MOVDload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 11 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [12] dst src mem) + // result: (MOVWstore [8] dst (MOVWUload [8] src mem) (MOVDstore dst (MOVDload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpARM64MOVWUload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [13] dst src mem) + // result: (MOVDstore [5] dst (MOVDload [5] src mem) (MOVDstore dst (MOVDload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 13 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(5) + v0 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(5) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [14] dst src mem) + // result: (MOVDstore [6] dst (MOVDload [6] src mem) (MOVDstore dst (MOVDload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 14 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(6) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [15] dst src mem) + // result: (MOVDstore [7] dst (MOVDload [7] src mem) (MOVDstore dst (MOVDload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 15 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(7) + v0 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(7) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [16] dst src mem) + // result: (STP dst (Select0 (LDP src mem)) (Select1 (LDP src mem)) mem) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpARM64STP) + v0 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v1.AddArg2(src, mem) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v2.AddArg(v1) + v.AddArg4(dst, v0, v2, mem) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 16 && s <= 24 + // result: (MOVDstore [int32(s-8)] dst (MOVDload [int32(s-8)] src mem) (STP dst (Select0 (LDP src mem)) (Select1 (LDP src mem)) mem)) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 16 && s <= 24) { + break + } + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(int32(s - 8)) + v0 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(int32(s - 8)) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v3.AddArg2(src, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v4.AddArg(v3) + v1.AddArg4(dst, v2, v4, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 24 && s <= 32 + // result: (STP [int32(s-16)] dst (Select0 (LDP [int32(s-16)] src mem)) (Select1 (LDP [int32(s-16)] src mem)) (STP dst (Select0 (LDP src mem)) (Select1 (LDP src mem)) mem)) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 24 && s <= 32) { + break + } + v.reset(OpARM64STP) + v.AuxInt = int32ToAuxInt(int32(s - 16)) + v0 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v1.AuxInt = int32ToAuxInt(int32(s - 16)) + v1.AddArg2(src, mem) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v5 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v5.AddArg2(src, mem) + v4.AddArg(v5) + v6 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v6.AddArg(v5) + v3.AddArg4(dst, v4, v6, mem) + v.AddArg4(dst, v0, v2, v3) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 32 && s <= 40 + // result: (MOVDstore [int32(s-8)] dst (MOVDload [int32(s-8)] src mem) (STP [16] dst (Select0 (LDP [16] src mem)) (Select1 (LDP [16] src mem)) (STP dst (Select0 (LDP src mem)) (Select1 (LDP src mem)) mem))) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 32 && s <= 40) { + break + } + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(int32(s - 8)) + v0 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(int32(s - 8)) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v1.AuxInt = int32ToAuxInt(16) + v2 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v3.AuxInt = int32ToAuxInt(16) + v3.AddArg2(src, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v4.AddArg(v3) + v5 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v6 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v7 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v7.AddArg2(src, mem) + v6.AddArg(v7) + v8 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v8.AddArg(v7) + v5.AddArg4(dst, v6, v8, mem) + v1.AddArg4(dst, v2, v4, v5) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 40 && s <= 48 + // result: (STP [int32(s-16)] dst (Select0 (LDP [int32(s-16)] src mem)) (Select1 (LDP [int32(s-16)] src mem)) (STP [16] dst (Select0 (LDP [16] src mem)) (Select1 (LDP [16] src mem)) (STP dst (Select0 (LDP src mem)) (Select1 (LDP src mem)) mem))) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 40 && s <= 48) { + break + } + v.reset(OpARM64STP) + v.AuxInt = int32ToAuxInt(int32(s - 16)) + v0 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v1.AuxInt = int32ToAuxInt(int32(s - 16)) + v1.AddArg2(src, mem) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v3.AuxInt = int32ToAuxInt(16) + v4 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v5 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v5.AuxInt = int32ToAuxInt(16) + v5.AddArg2(src, mem) + v4.AddArg(v5) + v6 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v6.AddArg(v5) + v7 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v8 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v9 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v9.AddArg2(src, mem) + v8.AddArg(v9) + v10 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v10.AddArg(v9) + v7.AddArg4(dst, v8, v10, mem) + v3.AddArg4(dst, v4, v6, v7) + v.AddArg4(dst, v0, v2, v3) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 48 && s <= 56 + // result: (MOVDstore [int32(s-8)] dst (MOVDload [int32(s-8)] src mem) (STP [32] dst (Select0 (LDP [32] src mem)) (Select1 (LDP [32] src mem)) (STP [16] dst (Select0 (LDP [16] src mem)) (Select1 (LDP [16] src mem)) (STP dst (Select0 (LDP src mem)) (Select1 (LDP src mem)) mem)))) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 48 && s <= 56) { + break + } + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(int32(s - 8)) + v0 := b.NewValue0(v.Pos, OpARM64MOVDload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(int32(s - 8)) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v1.AuxInt = int32ToAuxInt(32) + v2 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg2(src, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v4.AddArg(v3) + v5 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v5.AuxInt = int32ToAuxInt(16) + v6 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v7 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v7.AuxInt = int32ToAuxInt(16) + v7.AddArg2(src, mem) + v6.AddArg(v7) + v8 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v8.AddArg(v7) + v9 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v10 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v11 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v11.AddArg2(src, mem) + v10.AddArg(v11) + v12 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v12.AddArg(v11) + v9.AddArg4(dst, v10, v12, mem) + v5.AddArg4(dst, v6, v8, v9) + v1.AddArg4(dst, v2, v4, v5) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 56 && s <= 64 + // result: (STP [int32(s-16)] dst (Select0 (LDP [int32(s-16)] src mem)) (Select1 (LDP [int32(s-16)] src mem)) (STP [32] dst (Select0 (LDP [32] src mem)) (Select1 (LDP [32] src mem)) (STP [16] dst (Select0 (LDP [16] src mem)) (Select1 (LDP [16] src mem)) (STP dst (Select0 (LDP src mem)) (Select1 (LDP src mem)) mem)))) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 56 && s <= 64) { + break + } + v.reset(OpARM64STP) + v.AuxInt = int32ToAuxInt(int32(s - 16)) + v0 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v1.AuxInt = int32ToAuxInt(int32(s - 16)) + v1.AddArg2(src, mem) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v3.AuxInt = int32ToAuxInt(32) + v4 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v5 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v5.AuxInt = int32ToAuxInt(32) + v5.AddArg2(src, mem) + v4.AddArg(v5) + v6 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v6.AddArg(v5) + v7 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v7.AuxInt = int32ToAuxInt(16) + v8 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v9 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v9.AuxInt = int32ToAuxInt(16) + v9.AddArg2(src, mem) + v8.AddArg(v9) + v10 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v10.AddArg(v9) + v11 := b.NewValue0(v.Pos, OpARM64STP, types.TypeMem) + v12 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v13 := b.NewValue0(v.Pos, OpARM64LDP, types.NewTuple(typ.UInt64, typ.UInt64)) + v13.AddArg2(src, mem) + v12.AddArg(v13) + v14 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v14.AddArg(v13) + v11.AddArg4(dst, v12, v14, mem) + v7.AddArg4(dst, v8, v10, v11) + v3.AddArg4(dst, v4, v6, v7) + v.AddArg4(dst, v0, v2, v3) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 64 && s < 192 && logLargeCopy(v, s) + // result: (LoweredMove [s] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 64 && s < 192 && logLargeCopy(v, s)) { + break + } + v.reset(OpARM64LoweredMove) + v.AuxInt = int64ToAuxInt(s) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] dst src mem) + // cond: s >= 192 && logLargeCopy(v, s) + // result: (LoweredMoveLoop [s] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s >= 192 && logLargeCopy(v, s)) { + break + } + v.reset(OpARM64LoweredMoveLoop) + v.AuxInt = int64ToAuxInt(s) + v.AddArg3(dst, src, mem) + return true + } + return false +} +func rewriteValueARM64_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq16 x y) + // result: (NotEqual (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32 x y) + // result: (NotEqual (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpNeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32F x y) + // result: (NotEqual (FCMPS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64FCMPS, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpNeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64 x y) + // result: (NotEqual (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpNeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64F x y) + // result: (NotEqual (FCMPD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64FCMPD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq8 x y) + // result: (NotEqual (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (NeqPtr x y) + // result: (NotEqual (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpNot(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Not x) + // result: (XOR (MOVDconst [1]) x) + for { + x := v_0 + v.reset(OpARM64XOR) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueARM64_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + // match: (OffPtr [off] ptr:(SP)) + // cond: is32Bit(off) + // result: (MOVDaddr [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + if ptr.Op != OpSP || !(is32Bit(off)) { + break + } + v.reset(OpARM64MOVDaddr) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } + // match: (OffPtr [off] ptr) + // result: (ADDconst [off] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + v.reset(OpARM64ADDconst) + v.AuxInt = int64ToAuxInt(off) + v.AddArg(ptr) + return true + } +} +func rewriteValueARM64_OpPopCount16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount16 x) + // result: (FMOVDfpgp (VUADDLV (VCNT (FMOVDgpfp (ZeroExt16to64 x))))) + for { + t := v.Type + x := v_0 + v.reset(OpARM64FMOVDfpgp) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARM64VUADDLV, typ.Float64) + v1 := b.NewValue0(v.Pos, OpARM64VCNT, typ.Float64) + v2 := b.NewValue0(v.Pos, OpARM64FMOVDgpfp, typ.Float64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(x) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpPopCount32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount32 x) + // result: (FMOVDfpgp (VUADDLV (VCNT (FMOVDgpfp (ZeroExt32to64 x))))) + for { + t := v.Type + x := v_0 + v.reset(OpARM64FMOVDfpgp) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARM64VUADDLV, typ.Float64) + v1 := b.NewValue0(v.Pos, OpARM64VCNT, typ.Float64) + v2 := b.NewValue0(v.Pos, OpARM64FMOVDgpfp, typ.Float64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(x) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpPopCount64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount64 x) + // result: (FMOVDfpgp (VUADDLV (VCNT (FMOVDgpfp x)))) + for { + t := v.Type + x := v_0 + v.reset(OpARM64FMOVDfpgp) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARM64VUADDLV, typ.Float64) + v1 := b.NewValue0(v.Pos, OpARM64VCNT, typ.Float64) + v2 := b.NewValue0(v.Pos, OpARM64FMOVDgpfp, typ.Float64) + v2.AddArg(x) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpPrefetchCache(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (PrefetchCache addr mem) + // result: (PRFM [0] addr mem) + for { + addr := v_0 + mem := v_1 + v.reset(OpARM64PRFM) + v.AuxInt = int64ToAuxInt(0) + v.AddArg2(addr, mem) + return true + } +} +func rewriteValueARM64_OpPrefetchCacheStreamed(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (PrefetchCacheStreamed addr mem) + // result: (PRFM [1] addr mem) + for { + addr := v_0 + mem := v_1 + v.reset(OpARM64PRFM) + v.AuxInt = int64ToAuxInt(1) + v.AddArg2(addr, mem) + return true + } +} +func rewriteValueARM64_OpPubBarrier(v *Value) bool { + v_0 := v.Args[0] + // match: (PubBarrier mem) + // result: (DMB [0xe] mem) + for { + mem := v_0 + v.reset(OpARM64DMB) + v.AuxInt = int64ToAuxInt(0xe) + v.AddArg(mem) + return true + } +} +func rewriteValueARM64_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft16 x (MOVDconst [c])) + // result: (Or16 (Lsh16x64 x (MOVDconst [c&15])) (Rsh16Ux64 x (MOVDconst [-c&15]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpLsh16x64, t) + v1 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(c & 15) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh16Ux64, t) + v3 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(-c & 15) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + // match: (RotateLeft16 x y) + // result: (RORW (ORshiftLL (ZeroExt16to32 x) (ZeroExt16to32 x) [16]) (NEG y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpARM64RORW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARM64ORshiftLL, typ.UInt32) + v0.AuxInt = int64ToAuxInt(16) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, v1) + v2 := b.NewValue0(v.Pos, OpARM64NEG, typ.Int64) + v2.AddArg(y) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueARM64_OpRotateLeft32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RotateLeft32 x y) + // result: (RORW x (NEG y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64RORW) + v0 := b.NewValue0(v.Pos, OpARM64NEG, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueARM64_OpRotateLeft64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RotateLeft64 x y) + // result: (ROR x (NEG y)) + for { + x := v_0 + y := v_1 + v.reset(OpARM64ROR) + v0 := b.NewValue0(v.Pos, OpARM64NEG, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueARM64_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft8 x (MOVDconst [c])) + // result: (Or8 (Lsh8x64 x (MOVDconst [c&7])) (Rsh8Ux64 x (MOVDconst [-c&7]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpLsh8x64, t) + v1 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(c & 7) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh8Ux64, t) + v3 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(-c & 7) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + // match: (RotateLeft8 x y) + // result: (OR (SLL x (ANDconst [7] y)) (SRL (ZeroExt8to64 x) (ANDconst [7] (NEG y)))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpARM64OR) + v.Type = t + v0 := b.NewValue0(v.Pos, OpARM64SLL, t) + v1 := b.NewValue0(v.Pos, OpARM64ANDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(7) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpARM64SRL, t) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpARM64ANDconst, typ.Int64) + v4.AuxInt = int64ToAuxInt(7) + v5 := b.NewValue0(v.Pos, OpARM64NEG, typ.Int64) + v5.AddArg(y) + v4.AddArg(v5) + v2.AddArg2(v3, v4) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueARM64_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt16to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt16to64 x) y) (Const64 [0]) (CMPconst [64] (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt16to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt16to64 x) y) (Const64 [0]) (CMPconst [64] (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt16to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt16to64 x) y) (Const64 [0]) (CMPconst [64] y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt16to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt16to64 x) y) (Const64 [0]) (CMPconst [64] (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt16to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt32to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] y))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v3.AddArg(y) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt8to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt32to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh32Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt32to64 x) y) (Const64 [0]) (CMPconst [64] (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt32to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh32Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt32to64 x) y) (Const64 [0]) (CMPconst [64] (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt32to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh32Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt32to64 x) y) (Const64 [0]) (CMPconst [64] y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt32to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh32Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt32to64 x) y) (Const64 [0]) (CMPconst [64] (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt32to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh32x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt32to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt16to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt32to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh32x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt32to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt32to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt32to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh32x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt32to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] y))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v3.AddArg(y) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt32to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh32x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt32to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt8to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh64Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL x y) (Const64 [0]) (CMPconst [64] (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpRsh64Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL x y) (Const64 [0]) (CMPconst [64] (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpRsh64Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL x y) (Const64 [0]) (CMPconst [64] y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpRsh64Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL x y) (Const64 [0]) (CMPconst [64] (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } + return false +} +func rewriteValueARM64_OpRsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Rsh64x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt16to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v0.AuxInt = opToAuxInt(OpARM64LessThanU) + v1 := b.NewValue0(v.Pos, OpConst64, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64_OpRsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Rsh64x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt32to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v0.AuxInt = opToAuxInt(OpARM64LessThanU) + v1 := b.NewValue0(v.Pos, OpConst64, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64_OpRsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Rsh64x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] y))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v0.AuxInt = opToAuxInt(OpARM64LessThanU) + v1 := b.NewValue0(v.Pos, OpConst64, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64_OpRsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v.AddArg2(x, y) + return true + } + // match: (Rsh64x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt8to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v0.AuxInt = opToAuxInt(OpARM64LessThanU) + v1 := b.NewValue0(v.Pos, OpConst64, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt8to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt8to64 x) y) (Const64 [0]) (CMPconst [64] (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt8to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt8to64 x) y) (Const64 [0]) (CMPconst [64] (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt8to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt8to64 x) y) (Const64 [0]) (CMPconst [64] y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt8to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRL) + v.Type = t + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (CSEL [OpARM64LessThanU] (SRL (ZeroExt8to64 x) y) (Const64 [0]) (CMPconst [64] (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64CSEL) + v.AuxInt = opToAuxInt(OpARM64LessThanU) + v0 := b.NewValue0(v.Pos, OpARM64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } + return false +} +func rewriteValueARM64_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt16to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt32to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] y))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v3.AddArg(y) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) y) + for { + t := v.Type + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) (CSEL [OpARM64LessThanU] y (Const64 [63]) (CMPconst [64] (ZeroExt8to64 y)))) + for { + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpARM64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpARM64CSEL, y.Type) + v1.AuxInt = opToAuxInt(OpARM64LessThanU) + v2 := b.NewValue0(v.Pos, OpConst64, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueARM64_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select0 (Mul64uhilo x y)) + // result: (UMULH x y) + for { + if v_0.Op != OpMul64uhilo { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64UMULH) + v.AddArg2(x, y) + return true + } + // match: (Select0 (Add64carry x y c)) + // result: (Select0 (ADCSflags x y (Select1 (ADDSconstflags [-1] c)))) + for { + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpSelect0) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpARM64ADCSflags, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v2 := b.NewValue0(v.Pos, OpARM64ADDSconstflags, types.NewTuple(typ.UInt64, types.TypeFlags)) + v2.AuxInt = int64ToAuxInt(-1) + v2.AddArg(c) + v1.AddArg(v2) + v0.AddArg3(x, y, v1) + v.AddArg(v0) + return true + } + // match: (Select0 (Sub64borrow x y bo)) + // result: (Select0 (SBCSflags x y (Select1 (NEGSflags bo)))) + for { + if v_0.Op != OpSub64borrow { + break + } + bo := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpSelect0) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpARM64SBCSflags, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v2 := b.NewValue0(v.Pos, OpARM64NEGSflags, types.NewTuple(typ.UInt64, types.TypeFlags)) + v2.AddArg(bo) + v1.AddArg(v2) + v0.AddArg3(x, y, v1) + v.AddArg(v0) + return true + } + // match: (Select0 (Mul64uover x y)) + // result: (MUL x y) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64MUL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueARM64_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select1 (Mul64uhilo x y)) + // result: (MUL x y) + for { + if v_0.Op != OpMul64uhilo { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64MUL) + v.AddArg2(x, y) + return true + } + // match: (Select1 (Add64carry x y c)) + // result: (ADCzerocarry (Select1 (ADCSflags x y (Select1 (ADDSconstflags [-1] c))))) + for { + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpARM64ADCzerocarry) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpARM64ADCSflags, types.NewTuple(typ.UInt64, types.TypeFlags)) + v2 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpARM64ADDSconstflags, types.NewTuple(typ.UInt64, types.TypeFlags)) + v3.AuxInt = int64ToAuxInt(-1) + v3.AddArg(c) + v2.AddArg(v3) + v1.AddArg3(x, y, v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Select1 (Sub64borrow x y bo)) + // result: (NEG (NGCzerocarry (Select1 (SBCSflags x y (Select1 (NEGSflags bo)))))) + for { + if v_0.Op != OpSub64borrow { + break + } + bo := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpARM64NEG) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpARM64NGCzerocarry, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v2 := b.NewValue0(v.Pos, OpARM64SBCSflags, types.NewTuple(typ.UInt64, types.TypeFlags)) + v3 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v4 := b.NewValue0(v.Pos, OpARM64NEGSflags, types.NewTuple(typ.UInt64, types.TypeFlags)) + v4.AddArg(bo) + v3.AddArg(v4) + v2.AddArg3(x, y, v3) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Select1 (Mul64uover x y)) + // result: (NotEqual (CMPconst (UMULH x y) [0])) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpARM64NotEqual) + v0 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64UMULH, typ.UInt64) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueARM64_OpSelectN(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (SelectN [0] call:(CALLstatic {sym} s1:(MOVDstore _ (MOVDconst [sz]) s2:(MOVDstore _ src s3:(MOVDstore {t} _ dst mem))))) + // cond: sz >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(s1, s2, s3, call) + // result: (Move [sz] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpARM64CALLstatic || len(call.Args) != 1 { + break + } + sym := auxToCall(call.Aux) + s1 := call.Args[0] + if s1.Op != OpARM64MOVDstore { + break + } + _ = s1.Args[2] + s1_1 := s1.Args[1] + if s1_1.Op != OpARM64MOVDconst { + break + } + sz := auxIntToInt64(s1_1.AuxInt) + s2 := s1.Args[2] + if s2.Op != OpARM64MOVDstore { + break + } + _ = s2.Args[2] + src := s2.Args[1] + s3 := s2.Args[2] + if s3.Op != OpARM64MOVDstore { + break + } + mem := s3.Args[2] + dst := s3.Args[1] + if !(sz >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(s1, s2, s3, call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(sz) + v.AddArg3(dst, src, mem) + return true + } + // match: (SelectN [0] call:(CALLstatic {sym} dst src (MOVDconst [sz]) mem)) + // cond: sz >= 0 && isSameCall(sym, "runtime.memmove") && call.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(call) + // result: (Move [sz] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpARM64CALLstatic || len(call.Args) != 4 { + break + } + sym := auxToCall(call.Aux) + mem := call.Args[3] + dst := call.Args[0] + src := call.Args[1] + call_2 := call.Args[2] + if call_2.Op != OpARM64MOVDconst { + break + } + sz := auxIntToInt64(call_2.AuxInt) + if !(sz >= 0 && isSameCall(sym, "runtime.memmove") && call.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(sz) + v.AddArg3(dst, src, mem) + return true + } + return false +} +func rewriteValueARM64_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Slicemask x) + // result: (SRAconst (NEG x) [63]) + for { + t := v.Type + x := v_0 + v.reset(OpARM64SRAconst) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpARM64NEG, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueARM64_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (MOVBstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(OpARM64MOVBstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (MOVHstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(OpARM64MOVHstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && !t.IsFloat() + // result: (MOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && !t.IsFloat()) { + break + } + v.reset(OpARM64MOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && !t.IsFloat() + // result: (MOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && !t.IsFloat()) { + break + } + v.reset(OpARM64MOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && t.IsFloat() + // result: (FMOVSstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && t.IsFloat()) { + break + } + v.reset(OpARM64FMOVSstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && t.IsFloat() + // result: (FMOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && t.IsFloat()) { + break + } + v.reset(OpARM64FMOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueARM64_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] ptr mem) + // result: (MOVBstore ptr (MOVDconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVBstore) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [2] ptr mem) + // result: (MOVHstore ptr (MOVDconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVHstore) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [4] ptr mem) + // result: (MOVWstore ptr (MOVDconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVWstore) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [3] ptr mem) + // result: (MOVBstore [2] ptr (MOVDconst [0]) (MOVHstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVHstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [5] ptr mem) + // result: (MOVBstore [4] ptr (MOVDconst [0]) (MOVWstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVWstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [6] ptr mem) + // result: (MOVHstore [4] ptr (MOVDconst [0]) (MOVWstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVWstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [7] ptr mem) + // result: (MOVWstore [3] ptr (MOVDconst [0]) (MOVWstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVWstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [8] ptr mem) + // result: (MOVDstore ptr (MOVDconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVDstore) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [9] ptr mem) + // result: (MOVBstore [8] ptr (MOVDconst [0]) (MOVDstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 9 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVBstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [10] ptr mem) + // result: (MOVHstore [8] ptr (MOVDconst [0]) (MOVDstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 10 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVHstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [11] ptr mem) + // result: (MOVDstore [3] ptr (MOVDconst [0]) (MOVDstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 11 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [12] ptr mem) + // result: (MOVWstore [8] ptr (MOVDconst [0]) (MOVDstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVWstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [13] ptr mem) + // result: (MOVDstore [5] ptr (MOVDconst [0]) (MOVDstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 13 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(5) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [14] ptr mem) + // result: (MOVDstore [6] ptr (MOVDconst [0]) (MOVDstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 14 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [15] ptr mem) + // result: (MOVDstore [7] ptr (MOVDconst [0]) (MOVDstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 15 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64MOVDstore) + v.AuxInt = int32ToAuxInt(7) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpARM64MOVDstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [16] ptr mem) + // result: (STP [0] ptr (MOVDconst [0]) (MOVDconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpARM64STP) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg4(ptr, v0, v0, mem) + return true + } + // match: (Zero [s] ptr mem) + // cond: s > 16 && s < 192 + // result: (LoweredZero [s] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + ptr := v_0 + mem := v_1 + if !(s > 16 && s < 192) { + break + } + v.reset(OpARM64LoweredZero) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(ptr, mem) + return true + } + // match: (Zero [s] ptr mem) + // cond: s >= 192 + // result: (LoweredZeroLoop [s] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + ptr := v_0 + mem := v_1 + if !(s >= 192) { + break + } + v.reset(OpARM64LoweredZeroLoop) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteBlockARM64(b *Block) bool { + typ := &b.Func.Config.Types + switch b.Kind { + case BlockARM64EQ: + // match: (EQ (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (EQ (TST x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + break + } + // match: (EQ (CMPconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (EQ (TSTconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (EQ (CMPWconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (EQ (TSTW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + break + } + // match: (EQ (CMPWconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (EQ (TSTWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (EQ (CMPconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (EQ (CMNconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (EQ (CMPWconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (EQ (CMNWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (EQ (CMPconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (EQ (CMN x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + break + } + // match: (EQ (CMPWconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (EQ (CMNW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + break + } + // match: (EQ (CMP x z:(NEG y)) yes no) + // cond: z.Uses == 1 + // result: (EQ (CMN x y) yes no) + for b.Controls[0].Op == OpARM64CMP { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpARM64NEG { + break + } + y := z.Args[0] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (EQ (CMPW x z:(NEG y)) yes no) + // cond: z.Uses == 1 + // result: (EQ (CMNW x y) yes no) + for b.Controls[0].Op == OpARM64CMPW { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpARM64NEG { + break + } + y := z.Args[0] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (EQ (CMPconst [0] x) yes no) + // result: (Z x yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockARM64Z, x) + return true + } + // match: (EQ (CMPWconst [0] x) yes no) + // result: (ZW x yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockARM64ZW, x) + return true + } + // match: (EQ (CMPconst [0] z:(MADD a x y)) yes no) + // cond: z.Uses==1 + // result: (EQ (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADD { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (EQ (CMPconst [0] z:(MSUB a x y)) yes no) + // cond: z.Uses==1 + // result: (EQ (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUB { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (EQ (CMPWconst [0] z:(MADDW a x y)) yes no) + // cond: z.Uses==1 + // result: (EQ (CMNW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADDW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (EQ (CMPWconst [0] z:(MSUBW a x y)) yes no) + // cond: z.Uses==1 + // result: (EQ (CMPW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUBW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (EQ (TSTconst [c] x) yes no) + // cond: oneBit(c) + // result: (TBZ [int64(ntz64(c))] x yes no) + for b.Controls[0].Op == OpARM64TSTconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(oneBit(c)) { + break + } + b.resetWithControl(BlockARM64TBZ, x) + b.AuxInt = int64ToAuxInt(int64(ntz64(c))) + return true + } + // match: (EQ (TSTWconst [c] x) yes no) + // cond: oneBit(int64(uint32(c))) + // result: (TBZ [int64(ntz64(int64(uint32(c))))] x yes no) + for b.Controls[0].Op == OpARM64TSTWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(oneBit(int64(uint32(c)))) { + break + } + b.resetWithControl(BlockARM64TBZ, x) + b.AuxInt = int64ToAuxInt(int64(ntz64(int64(uint32(c))))) + return true + } + // match: (EQ (FlagConstant [fc]) yes no) + // cond: fc.eq() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.eq()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (EQ (FlagConstant [fc]) yes no) + // cond: !fc.eq() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.eq()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (InvertFlags cmp) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64EQ, cmp) + return true + } + case BlockARM64FGE: + // match: (FGE (InvertFlags cmp) yes no) + // result: (FLE cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64FLE, cmp) + return true + } + case BlockARM64FGT: + // match: (FGT (InvertFlags cmp) yes no) + // result: (FLT cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64FLT, cmp) + return true + } + case BlockARM64FLE: + // match: (FLE (InvertFlags cmp) yes no) + // result: (FGE cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64FGE, cmp) + return true + } + case BlockARM64FLT: + // match: (FLT (InvertFlags cmp) yes no) + // result: (FGT cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64FGT, cmp) + return true + } + case BlockARM64GE: + // match: (GE (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (GE (TST x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64GE, v0) + return true + } + break + } + // match: (GE (CMPconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (GE (TSTconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64GE, v0) + return true + } + // match: (GE (CMPWconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (GE (TSTW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64GE, v0) + return true + } + break + } + // match: (GE (CMPWconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (GE (TSTWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64GE, v0) + return true + } + // match: (GE (CMPconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (GEnoov (CMNconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64GEnoov, v0) + return true + } + // match: (GE (CMPWconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (GEnoov (CMNWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64GEnoov, v0) + return true + } + // match: (GE (CMPconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (GEnoov (CMN x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64GEnoov, v0) + return true + } + break + } + // match: (GE (CMPWconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (GEnoov (CMNW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64GEnoov, v0) + return true + } + break + } + // match: (GE (CMPconst [0] z:(MADD a x y)) yes no) + // cond: z.Uses==1 + // result: (GEnoov (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADD { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64GEnoov, v0) + return true + } + // match: (GE (CMPconst [0] z:(MSUB a x y)) yes no) + // cond: z.Uses==1 + // result: (GEnoov (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUB { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64GEnoov, v0) + return true + } + // match: (GE (CMPWconst [0] z:(MADDW a x y)) yes no) + // cond: z.Uses==1 + // result: (GEnoov (CMNW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADDW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64GEnoov, v0) + return true + } + // match: (GE (CMPWconst [0] z:(MSUBW a x y)) yes no) + // cond: z.Uses==1 + // result: (GEnoov (CMPW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUBW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64GEnoov, v0) + return true + } + // match: (GE (CMPWconst [0] x) yes no) + // result: (TBZ [31] x yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockARM64TBZ, x) + b.AuxInt = int64ToAuxInt(31) + return true + } + // match: (GE (CMPconst [0] x) yes no) + // result: (TBZ [63] x yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockARM64TBZ, x) + b.AuxInt = int64ToAuxInt(63) + return true + } + // match: (GE (FlagConstant [fc]) yes no) + // cond: fc.ge() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ge()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GE (FlagConstant [fc]) yes no) + // cond: !fc.ge() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ge()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GE (InvertFlags cmp) yes no) + // result: (LE cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64LE, cmp) + return true + } + case BlockARM64GEnoov: + // match: (GEnoov (FlagConstant [fc]) yes no) + // cond: fc.geNoov() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.geNoov()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GEnoov (FlagConstant [fc]) yes no) + // cond: !fc.geNoov() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.geNoov()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GEnoov (InvertFlags cmp) yes no) + // result: (LEnoov cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64LEnoov, cmp) + return true + } + case BlockARM64GT: + // match: (GT (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (GT (TST x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64GT, v0) + return true + } + break + } + // match: (GT (CMPconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (GT (TSTconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64GT, v0) + return true + } + // match: (GT (CMPWconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (GT (TSTW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64GT, v0) + return true + } + break + } + // match: (GT (CMPWconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (GT (TSTWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64GT, v0) + return true + } + // match: (GT (CMPconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (GTnoov (CMNconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64GTnoov, v0) + return true + } + // match: (GT (CMPWconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (GTnoov (CMNWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64GTnoov, v0) + return true + } + // match: (GT (CMPconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (GTnoov (CMN x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64GTnoov, v0) + return true + } + break + } + // match: (GT (CMPWconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (GTnoov (CMNW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64GTnoov, v0) + return true + } + break + } + // match: (GT (CMPconst [0] z:(MADD a x y)) yes no) + // cond: z.Uses==1 + // result: (GTnoov (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADD { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64GTnoov, v0) + return true + } + // match: (GT (CMPconst [0] z:(MSUB a x y)) yes no) + // cond: z.Uses==1 + // result: (GTnoov (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUB { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64GTnoov, v0) + return true + } + // match: (GT (CMPWconst [0] z:(MADDW a x y)) yes no) + // cond: z.Uses==1 + // result: (GTnoov (CMNW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADDW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64GTnoov, v0) + return true + } + // match: (GT (CMPWconst [0] z:(MSUBW a x y)) yes no) + // cond: z.Uses==1 + // result: (GTnoov (CMPW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUBW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64GTnoov, v0) + return true + } + // match: (GT (FlagConstant [fc]) yes no) + // cond: fc.gt() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.gt()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GT (FlagConstant [fc]) yes no) + // cond: !fc.gt() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.gt()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GT (InvertFlags cmp) yes no) + // result: (LT cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64LT, cmp) + return true + } + case BlockARM64GTnoov: + // match: (GTnoov (FlagConstant [fc]) yes no) + // cond: fc.gtNoov() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.gtNoov()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GTnoov (FlagConstant [fc]) yes no) + // cond: !fc.gtNoov() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.gtNoov()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GTnoov (InvertFlags cmp) yes no) + // result: (LTnoov cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64LTnoov, cmp) + return true + } + case BlockIf: + // match: (If (Equal cc) yes no) + // result: (EQ cc yes no) + for b.Controls[0].Op == OpARM64Equal { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64EQ, cc) + return true + } + // match: (If (NotEqual cc) yes no) + // result: (NE cc yes no) + for b.Controls[0].Op == OpARM64NotEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64NE, cc) + return true + } + // match: (If (LessThan cc) yes no) + // result: (LT cc yes no) + for b.Controls[0].Op == OpARM64LessThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64LT, cc) + return true + } + // match: (If (LessThanU cc) yes no) + // result: (ULT cc yes no) + for b.Controls[0].Op == OpARM64LessThanU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64ULT, cc) + return true + } + // match: (If (LessEqual cc) yes no) + // result: (LE cc yes no) + for b.Controls[0].Op == OpARM64LessEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64LE, cc) + return true + } + // match: (If (LessEqualU cc) yes no) + // result: (ULE cc yes no) + for b.Controls[0].Op == OpARM64LessEqualU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64ULE, cc) + return true + } + // match: (If (GreaterThan cc) yes no) + // result: (GT cc yes no) + for b.Controls[0].Op == OpARM64GreaterThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64GT, cc) + return true + } + // match: (If (GreaterThanU cc) yes no) + // result: (UGT cc yes no) + for b.Controls[0].Op == OpARM64GreaterThanU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64UGT, cc) + return true + } + // match: (If (GreaterEqual cc) yes no) + // result: (GE cc yes no) + for b.Controls[0].Op == OpARM64GreaterEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64GE, cc) + return true + } + // match: (If (GreaterEqualU cc) yes no) + // result: (UGE cc yes no) + for b.Controls[0].Op == OpARM64GreaterEqualU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64UGE, cc) + return true + } + // match: (If (LessThanF cc) yes no) + // result: (FLT cc yes no) + for b.Controls[0].Op == OpARM64LessThanF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64FLT, cc) + return true + } + // match: (If (LessEqualF cc) yes no) + // result: (FLE cc yes no) + for b.Controls[0].Op == OpARM64LessEqualF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64FLE, cc) + return true + } + // match: (If (GreaterThanF cc) yes no) + // result: (FGT cc yes no) + for b.Controls[0].Op == OpARM64GreaterThanF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64FGT, cc) + return true + } + // match: (If (GreaterEqualF cc) yes no) + // result: (FGE cc yes no) + for b.Controls[0].Op == OpARM64GreaterEqualF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64FGE, cc) + return true + } + // match: (If cond yes no) + // result: (TBNZ [0] cond yes no) + for { + cond := b.Controls[0] + b.resetWithControl(BlockARM64TBNZ, cond) + b.AuxInt = int64ToAuxInt(0) + return true + } + case BlockJumpTable: + // match: (JumpTable idx) + // result: (JUMPTABLE {makeJumpTableSym(b)} idx (MOVDaddr {makeJumpTableSym(b)} (SB))) + for { + idx := b.Controls[0] + v0 := b.NewValue0(b.Pos, OpARM64MOVDaddr, typ.Uintptr) + v0.Aux = symToAux(makeJumpTableSym(b)) + v1 := b.NewValue0(b.Pos, OpSB, typ.Uintptr) + v0.AddArg(v1) + b.resetWithControl2(BlockARM64JUMPTABLE, idx, v0) + b.Aux = symToAux(makeJumpTableSym(b)) + return true + } + case BlockARM64LE: + // match: (LE (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (LE (TST x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64LE, v0) + return true + } + break + } + // match: (LE (CMPconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (LE (TSTconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64LE, v0) + return true + } + // match: (LE (CMPWconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (LE (TSTW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64LE, v0) + return true + } + break + } + // match: (LE (CMPWconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (LE (TSTWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64LE, v0) + return true + } + // match: (LE (CMPconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (LEnoov (CMNconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64LEnoov, v0) + return true + } + // match: (LE (CMPWconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (LEnoov (CMNWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64LEnoov, v0) + return true + } + // match: (LE (CMPconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (LEnoov (CMN x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64LEnoov, v0) + return true + } + break + } + // match: (LE (CMPWconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (LEnoov (CMNW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64LEnoov, v0) + return true + } + break + } + // match: (LE (CMPconst [0] z:(MADD a x y)) yes no) + // cond: z.Uses==1 + // result: (LEnoov (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADD { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64LEnoov, v0) + return true + } + // match: (LE (CMPconst [0] z:(MSUB a x y)) yes no) + // cond: z.Uses==1 + // result: (LEnoov (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUB { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64LEnoov, v0) + return true + } + // match: (LE (CMPWconst [0] z:(MADDW a x y)) yes no) + // cond: z.Uses==1 + // result: (LEnoov (CMNW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADDW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64LEnoov, v0) + return true + } + // match: (LE (CMPWconst [0] z:(MSUBW a x y)) yes no) + // cond: z.Uses==1 + // result: (LEnoov (CMPW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUBW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64LEnoov, v0) + return true + } + // match: (LE (FlagConstant [fc]) yes no) + // cond: fc.le() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.le()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LE (FlagConstant [fc]) yes no) + // cond: !fc.le() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.le()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LE (InvertFlags cmp) yes no) + // result: (GE cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64GE, cmp) + return true + } + case BlockARM64LEnoov: + // match: (LEnoov (FlagConstant [fc]) yes no) + // cond: fc.leNoov() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.leNoov()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LEnoov (FlagConstant [fc]) yes no) + // cond: !fc.leNoov() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.leNoov()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LEnoov (InvertFlags cmp) yes no) + // result: (GEnoov cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64GEnoov, cmp) + return true + } + case BlockARM64LT: + // match: (LT (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (LT (TST x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64LT, v0) + return true + } + break + } + // match: (LT (CMPconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (LT (TSTconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64LT, v0) + return true + } + // match: (LT (CMPWconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (LT (TSTW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64LT, v0) + return true + } + break + } + // match: (LT (CMPWconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (LT (TSTWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64LT, v0) + return true + } + // match: (LT (CMPconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (LTnoov (CMNconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64LTnoov, v0) + return true + } + // match: (LT (CMPWconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (LTnoov (CMNWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64LTnoov, v0) + return true + } + // match: (LT (CMPconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (LTnoov (CMN x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64LTnoov, v0) + return true + } + break + } + // match: (LT (CMPWconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (LTnoov (CMNW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64LTnoov, v0) + return true + } + break + } + // match: (LT (CMPconst [0] z:(MADD a x y)) yes no) + // cond: z.Uses==1 + // result: (LTnoov (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADD { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64LTnoov, v0) + return true + } + // match: (LT (CMPconst [0] z:(MSUB a x y)) yes no) + // cond: z.Uses==1 + // result: (LTnoov (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUB { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64LTnoov, v0) + return true + } + // match: (LT (CMPWconst [0] z:(MADDW a x y)) yes no) + // cond: z.Uses==1 + // result: (LTnoov (CMNW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADDW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64LTnoov, v0) + return true + } + // match: (LT (CMPWconst [0] z:(MSUBW a x y)) yes no) + // cond: z.Uses==1 + // result: (LTnoov (CMPW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUBW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64LTnoov, v0) + return true + } + // match: (LT (CMPWconst [0] x) yes no) + // result: (TBNZ [31] x yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockARM64TBNZ, x) + b.AuxInt = int64ToAuxInt(31) + return true + } + // match: (LT (CMPconst [0] x) yes no) + // result: (TBNZ [63] x yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockARM64TBNZ, x) + b.AuxInt = int64ToAuxInt(63) + return true + } + // match: (LT (FlagConstant [fc]) yes no) + // cond: fc.lt() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.lt()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LT (FlagConstant [fc]) yes no) + // cond: !fc.lt() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.lt()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LT (InvertFlags cmp) yes no) + // result: (GT cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64GT, cmp) + return true + } + case BlockARM64LTnoov: + // match: (LTnoov (FlagConstant [fc]) yes no) + // cond: fc.ltNoov() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ltNoov()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LTnoov (FlagConstant [fc]) yes no) + // cond: !fc.ltNoov() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ltNoov()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LTnoov (InvertFlags cmp) yes no) + // result: (GTnoov cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64GTnoov, cmp) + return true + } + case BlockARM64NE: + // match: (NE (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (NE (TST x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TST, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + break + } + // match: (NE (CMPconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (NE (TSTconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NE (CMPWconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (NE (TSTW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + break + } + // match: (NE (CMPWconst [0] x:(ANDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (NE (TSTWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64TSTWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NE (CMPconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (NE (CMNconst [c] y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NE (CMPWconst [0] x:(ADDconst [c] y)) yes no) + // cond: x.Uses == 1 + // result: (NE (CMNWconst [int32(c)] y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + if x.Op != OpARM64ADDconst { + break + } + c := auxIntToInt64(x.AuxInt) + y := x.Args[0] + if !(x.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NE (CMPconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (NE (CMN x y) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + break + } + // match: (NE (CMPWconst [0] z:(ADD x y)) yes no) + // cond: z.Uses == 1 + // result: (NE (CMNW x y) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64ADD { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + break + } + // match: (NE (CMP x z:(NEG y)) yes no) + // cond: z.Uses == 1 + // result: (NE (CMN x y) yes no) + for b.Controls[0].Op == OpARM64CMP { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpARM64NEG { + break + } + y := z.Args[0] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NE (CMPW x z:(NEG y)) yes no) + // cond: z.Uses == 1 + // result: (NE (CMNW x y) yes no) + for b.Controls[0].Op == OpARM64CMPW { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpARM64NEG { + break + } + y := z.Args[0] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NE (CMPconst [0] x) yes no) + // result: (NZ x yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockARM64NZ, x) + return true + } + // match: (NE (CMPWconst [0] x) yes no) + // result: (NZW x yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockARM64NZW, x) + return true + } + // match: (NE (CMPconst [0] z:(MADD a x y)) yes no) + // cond: z.Uses==1 + // result: (NE (CMN a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADD { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMN, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NE (CMPconst [0] z:(MSUB a x y)) yes no) + // cond: z.Uses==1 + // result: (NE (CMP a (MUL x y)) yes no) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUB { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMP, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MUL, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NE (CMPWconst [0] z:(MADDW a x y)) yes no) + // cond: z.Uses==1 + // result: (NE (CMNW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MADDW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMNW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NE (CMPWconst [0] z:(MSUBW a x y)) yes no) + // cond: z.Uses==1 + // result: (NE (CMPW a (MULW x y)) yes no) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpARM64MSUBW { + break + } + y := z.Args[2] + a := z.Args[0] + x := z.Args[1] + if !(z.Uses == 1) { + break + } + v0 := b.NewValue0(v_0.Pos, OpARM64CMPW, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpARM64MULW, x.Type) + v1.AddArg2(x, y) + v0.AddArg2(a, v1) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NE (TSTconst [c] x) yes no) + // cond: oneBit(c) + // result: (TBNZ [int64(ntz64(c))] x yes no) + for b.Controls[0].Op == OpARM64TSTconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(oneBit(c)) { + break + } + b.resetWithControl(BlockARM64TBNZ, x) + b.AuxInt = int64ToAuxInt(int64(ntz64(c))) + return true + } + // match: (NE (TSTWconst [c] x) yes no) + // cond: oneBit(int64(uint32(c))) + // result: (TBNZ [int64(ntz64(int64(uint32(c))))] x yes no) + for b.Controls[0].Op == OpARM64TSTWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(oneBit(int64(uint32(c)))) { + break + } + b.resetWithControl(BlockARM64TBNZ, x) + b.AuxInt = int64ToAuxInt(int64(ntz64(int64(uint32(c))))) + return true + } + // match: (NE (FlagConstant [fc]) yes no) + // cond: fc.ne() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ne()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (NE (FlagConstant [fc]) yes no) + // cond: !fc.ne() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ne()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (NE (InvertFlags cmp) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64NE, cmp) + return true + } + case BlockARM64NZ: + // match: (NZ (Equal cc) yes no) + // result: (EQ cc yes no) + for b.Controls[0].Op == OpARM64Equal { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64EQ, cc) + return true + } + // match: (NZ (NotEqual cc) yes no) + // result: (NE cc yes no) + for b.Controls[0].Op == OpARM64NotEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64NE, cc) + return true + } + // match: (NZ (LessThan cc) yes no) + // result: (LT cc yes no) + for b.Controls[0].Op == OpARM64LessThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64LT, cc) + return true + } + // match: (NZ (LessThanU cc) yes no) + // result: (ULT cc yes no) + for b.Controls[0].Op == OpARM64LessThanU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64ULT, cc) + return true + } + // match: (NZ (LessEqual cc) yes no) + // result: (LE cc yes no) + for b.Controls[0].Op == OpARM64LessEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64LE, cc) + return true + } + // match: (NZ (LessEqualU cc) yes no) + // result: (ULE cc yes no) + for b.Controls[0].Op == OpARM64LessEqualU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64ULE, cc) + return true + } + // match: (NZ (GreaterThan cc) yes no) + // result: (GT cc yes no) + for b.Controls[0].Op == OpARM64GreaterThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64GT, cc) + return true + } + // match: (NZ (GreaterThanU cc) yes no) + // result: (UGT cc yes no) + for b.Controls[0].Op == OpARM64GreaterThanU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64UGT, cc) + return true + } + // match: (NZ (GreaterEqual cc) yes no) + // result: (GE cc yes no) + for b.Controls[0].Op == OpARM64GreaterEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64GE, cc) + return true + } + // match: (NZ (GreaterEqualU cc) yes no) + // result: (UGE cc yes no) + for b.Controls[0].Op == OpARM64GreaterEqualU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64UGE, cc) + return true + } + // match: (NZ (LessThanF cc) yes no) + // result: (FLT cc yes no) + for b.Controls[0].Op == OpARM64LessThanF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64FLT, cc) + return true + } + // match: (NZ (LessEqualF cc) yes no) + // result: (FLE cc yes no) + for b.Controls[0].Op == OpARM64LessEqualF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64FLE, cc) + return true + } + // match: (NZ (GreaterThanF cc) yes no) + // result: (FGT cc yes no) + for b.Controls[0].Op == OpARM64GreaterThanF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64FGT, cc) + return true + } + // match: (NZ (GreaterEqualF cc) yes no) + // result: (FGE cc yes no) + for b.Controls[0].Op == OpARM64GreaterEqualF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockARM64FGE, cc) + return true + } + // match: (NZ sub:(SUB x y)) + // cond: sub.Uses == 1 + // result: (NE (CMP x y)) + for b.Controls[0].Op == OpARM64SUB { + sub := b.Controls[0] + y := sub.Args[1] + x := sub.Args[0] + if !(sub.Uses == 1) { + break + } + v0 := b.NewValue0(sub.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NZ sub:(SUBconst [c] y)) + // cond: sub.Uses == 1 + // result: (NE (CMPconst [c] y)) + for b.Controls[0].Op == OpARM64SUBconst { + sub := b.Controls[0] + c := auxIntToInt64(sub.AuxInt) + y := sub.Args[0] + if !(sub.Uses == 1) { + break + } + v0 := b.NewValue0(sub.Pos, OpARM64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NZ (ANDconst [c] x) yes no) + // cond: oneBit(c) + // result: (TBNZ [int64(ntz64(c))] x yes no) + for b.Controls[0].Op == OpARM64ANDconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(oneBit(c)) { + break + } + b.resetWithControl(BlockARM64TBNZ, x) + b.AuxInt = int64ToAuxInt(int64(ntz64(c))) + return true + } + // match: (NZ (MOVDconst [0]) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpARM64MOVDconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (NZ (MOVDconst [c]) yes no) + // cond: c != 0 + // result: (First yes no) + for b.Controls[0].Op == OpARM64MOVDconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c != 0) { + break + } + b.Reset(BlockFirst) + return true + } + case BlockARM64NZW: + // match: (NZW sub:(SUB x y)) + // cond: sub.Uses == 1 + // result: (NE (CMPW x y)) + for b.Controls[0].Op == OpARM64SUB { + sub := b.Controls[0] + y := sub.Args[1] + x := sub.Args[0] + if !(sub.Uses == 1) { + break + } + v0 := b.NewValue0(sub.Pos, OpARM64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NZW sub:(SUBconst [c] y)) + // cond: sub.Uses == 1 + // result: (NE (CMPWconst [int32(c)] y)) + for b.Controls[0].Op == OpARM64SUBconst { + sub := b.Controls[0] + c := auxIntToInt64(sub.AuxInt) + y := sub.Args[0] + if !(sub.Uses == 1) { + break + } + v0 := b.NewValue0(sub.Pos, OpARM64CMPWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (NZW (ANDconst [c] x) yes no) + // cond: oneBit(int64(uint32(c))) + // result: (TBNZ [int64(ntz64(int64(uint32(c))))] x yes no) + for b.Controls[0].Op == OpARM64ANDconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(oneBit(int64(uint32(c)))) { + break + } + b.resetWithControl(BlockARM64TBNZ, x) + b.AuxInt = int64ToAuxInt(int64(ntz64(int64(uint32(c))))) + return true + } + // match: (NZW (MOVDconst [c]) yes no) + // cond: int32(c) == 0 + // result: (First no yes) + for b.Controls[0].Op == OpARM64MOVDconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(int32(c) == 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (NZW (MOVDconst [c]) yes no) + // cond: int32(c) != 0 + // result: (First yes no) + for b.Controls[0].Op == OpARM64MOVDconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(int32(c) != 0) { + break + } + b.Reset(BlockFirst) + return true + } + case BlockARM64TBNZ: + // match: (TBNZ [0] (Equal cc) yes no) + // result: (EQ cc yes no) + for b.Controls[0].Op == OpARM64Equal { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64EQ, cc) + return true + } + // match: (TBNZ [0] (NotEqual cc) yes no) + // result: (NE cc yes no) + for b.Controls[0].Op == OpARM64NotEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64NE, cc) + return true + } + // match: (TBNZ [0] (LessThan cc) yes no) + // result: (LT cc yes no) + for b.Controls[0].Op == OpARM64LessThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64LT, cc) + return true + } + // match: (TBNZ [0] (LessThanU cc) yes no) + // result: (ULT cc yes no) + for b.Controls[0].Op == OpARM64LessThanU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64ULT, cc) + return true + } + // match: (TBNZ [0] (LessEqual cc) yes no) + // result: (LE cc yes no) + for b.Controls[0].Op == OpARM64LessEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64LE, cc) + return true + } + // match: (TBNZ [0] (LessEqualU cc) yes no) + // result: (ULE cc yes no) + for b.Controls[0].Op == OpARM64LessEqualU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64ULE, cc) + return true + } + // match: (TBNZ [0] (GreaterThan cc) yes no) + // result: (GT cc yes no) + for b.Controls[0].Op == OpARM64GreaterThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64GT, cc) + return true + } + // match: (TBNZ [0] (GreaterThanU cc) yes no) + // result: (UGT cc yes no) + for b.Controls[0].Op == OpARM64GreaterThanU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64UGT, cc) + return true + } + // match: (TBNZ [0] (GreaterEqual cc) yes no) + // result: (GE cc yes no) + for b.Controls[0].Op == OpARM64GreaterEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64GE, cc) + return true + } + // match: (TBNZ [0] (GreaterEqualU cc) yes no) + // result: (UGE cc yes no) + for b.Controls[0].Op == OpARM64GreaterEqualU { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64UGE, cc) + return true + } + // match: (TBNZ [0] (LessThanF cc) yes no) + // result: (FLT cc yes no) + for b.Controls[0].Op == OpARM64LessThanF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64FLT, cc) + return true + } + // match: (TBNZ [0] (LessEqualF cc) yes no) + // result: (FLE cc yes no) + for b.Controls[0].Op == OpARM64LessEqualF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64FLE, cc) + return true + } + // match: (TBNZ [0] (GreaterThanF cc) yes no) + // result: (FGT cc yes no) + for b.Controls[0].Op == OpARM64GreaterThanF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64FGT, cc) + return true + } + // match: (TBNZ [0] (GreaterEqualF cc) yes no) + // result: (FGE cc yes no) + for b.Controls[0].Op == OpARM64GreaterEqualF { + v_0 := b.Controls[0] + cc := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64FGE, cc) + return true + } + // match: (TBNZ [0] (XORconst [1] x) yes no) + // result: (TBZ [0] x yes no) + for b.Controls[0].Op == OpARM64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64TBZ, x) + b.AuxInt = int64ToAuxInt(0) + return true + } + case BlockARM64TBZ: + // match: (TBZ [0] (XORconst [1] x) yes no) + // result: (TBNZ [0] x yes no) + for b.Controls[0].Op == OpARM64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + if auxIntToInt64(b.AuxInt) != 0 { + break + } + b.resetWithControl(BlockARM64TBNZ, x) + b.AuxInt = int64ToAuxInt(0) + return true + } + case BlockARM64UGE: + // match: (UGE (FlagConstant [fc]) yes no) + // cond: fc.uge() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.uge()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (UGE (FlagConstant [fc]) yes no) + // cond: !fc.uge() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.uge()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGE (InvertFlags cmp) yes no) + // result: (ULE cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64ULE, cmp) + return true + } + case BlockARM64UGT: + // match: (UGT (CMPconst [0] x)) + // result: (NE (CMPconst [0] x)) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + v0 := b.NewValue0(v_0.Pos, OpARM64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(0) + v0.AddArg(x) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (UGT (CMPWconst [0] x)) + // result: (NE (CMPWconst [0] x)) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + v0 := b.NewValue0(v_0.Pos, OpARM64CMPWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(x) + b.resetWithControl(BlockARM64NE, v0) + return true + } + // match: (UGT (FlagConstant [fc]) yes no) + // cond: fc.ugt() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ugt()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (UGT (FlagConstant [fc]) yes no) + // cond: !fc.ugt() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ugt()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (UGT (InvertFlags cmp) yes no) + // result: (ULT cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64ULT, cmp) + return true + } + case BlockARM64ULE: + // match: (ULE (CMPconst [0] x)) + // result: (EQ (CMPconst [0] x)) + for b.Controls[0].Op == OpARM64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + v0 := b.NewValue0(v_0.Pos, OpARM64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(0) + v0.AddArg(x) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (ULE (CMPWconst [0] x)) + // result: (EQ (CMPWconst [0] x)) + for b.Controls[0].Op == OpARM64CMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + v0 := b.NewValue0(v_0.Pos, OpARM64CMPWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg(x) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (ULE (FlagConstant [fc]) yes no) + // cond: fc.ule() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ule()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (ULE (FlagConstant [fc]) yes no) + // cond: !fc.ule() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ule()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULE (InvertFlags cmp) yes no) + // result: (UGE cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64UGE, cmp) + return true + } + case BlockARM64ULT: + // match: (ULT (FlagConstant [fc]) yes no) + // cond: fc.ult() + // result: (First yes no) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(fc.ult()) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (ULT (FlagConstant [fc]) yes no) + // cond: !fc.ult() + // result: (First no yes) + for b.Controls[0].Op == OpARM64FlagConstant { + v_0 := b.Controls[0] + fc := auxIntToFlagConstant(v_0.AuxInt) + if !(!fc.ult()) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (ULT (InvertFlags cmp) yes no) + // result: (UGT cmp yes no) + for b.Controls[0].Op == OpARM64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockARM64UGT, cmp) + return true + } + case BlockARM64Z: + // match: (Z sub:(SUB x y)) + // cond: sub.Uses == 1 + // result: (EQ (CMP x y)) + for b.Controls[0].Op == OpARM64SUB { + sub := b.Controls[0] + y := sub.Args[1] + x := sub.Args[0] + if !(sub.Uses == 1) { + break + } + v0 := b.NewValue0(sub.Pos, OpARM64CMP, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (Z sub:(SUBconst [c] y)) + // cond: sub.Uses == 1 + // result: (EQ (CMPconst [c] y)) + for b.Controls[0].Op == OpARM64SUBconst { + sub := b.Controls[0] + c := auxIntToInt64(sub.AuxInt) + y := sub.Args[0] + if !(sub.Uses == 1) { + break + } + v0 := b.NewValue0(sub.Pos, OpARM64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (Z (ANDconst [c] x) yes no) + // cond: oneBit(c) + // result: (TBZ [int64(ntz64(c))] x yes no) + for b.Controls[0].Op == OpARM64ANDconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(oneBit(c)) { + break + } + b.resetWithControl(BlockARM64TBZ, x) + b.AuxInt = int64ToAuxInt(int64(ntz64(c))) + return true + } + // match: (Z (MOVDconst [0]) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpARM64MOVDconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + b.Reset(BlockFirst) + return true + } + // match: (Z (MOVDconst [c]) yes no) + // cond: c != 0 + // result: (First no yes) + for b.Controls[0].Op == OpARM64MOVDconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c != 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockARM64ZW: + // match: (ZW sub:(SUB x y)) + // cond: sub.Uses == 1 + // result: (EQ (CMPW x y)) + for b.Controls[0].Op == OpARM64SUB { + sub := b.Controls[0] + y := sub.Args[1] + x := sub.Args[0] + if !(sub.Uses == 1) { + break + } + v0 := b.NewValue0(sub.Pos, OpARM64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (ZW sub:(SUBconst [c] y)) + // cond: sub.Uses == 1 + // result: (EQ (CMPWconst [int32(c)] y)) + for b.Controls[0].Op == OpARM64SUBconst { + sub := b.Controls[0] + c := auxIntToInt64(sub.AuxInt) + y := sub.Args[0] + if !(sub.Uses == 1) { + break + } + v0 := b.NewValue0(sub.Pos, OpARM64CMPWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + b.resetWithControl(BlockARM64EQ, v0) + return true + } + // match: (ZW (ANDconst [c] x) yes no) + // cond: oneBit(int64(uint32(c))) + // result: (TBZ [int64(ntz64(int64(uint32(c))))] x yes no) + for b.Controls[0].Op == OpARM64ANDconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(oneBit(int64(uint32(c)))) { + break + } + b.resetWithControl(BlockARM64TBZ, x) + b.AuxInt = int64ToAuxInt(int64(ntz64(int64(uint32(c))))) + return true + } + // match: (ZW (MOVDconst [c]) yes no) + // cond: int32(c) == 0 + // result: (First yes no) + for b.Controls[0].Op == OpARM64MOVDconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(int32(c) == 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (ZW (MOVDconst [c]) yes no) + // cond: int32(c) != 0 + // result: (First no yes) + for b.Controls[0].Op == OpARM64MOVDconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(int32(c) != 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteARM64latelower.go b/go/src/cmd/compile/internal/ssa/rewriteARM64latelower.go new file mode 100644 index 0000000000000000000000000000000000000000..0fa5e26e93d0f97fbb864b2ca083bf7f786fa550 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteARM64latelower.go @@ -0,0 +1,1102 @@ +// Code generated from _gen/ARM64latelower.rules using 'go generate'; DO NOT EDIT. + +package ssa + +func rewriteValueARM64latelower(v *Value) bool { + switch v.Op { + case OpARM64ADDSconstflags: + return rewriteValueARM64latelower_OpARM64ADDSconstflags(v) + case OpARM64ADDconst: + return rewriteValueARM64latelower_OpARM64ADDconst(v) + case OpARM64ANDconst: + return rewriteValueARM64latelower_OpARM64ANDconst(v) + case OpARM64CMNWconst: + return rewriteValueARM64latelower_OpARM64CMNWconst(v) + case OpARM64CMNconst: + return rewriteValueARM64latelower_OpARM64CMNconst(v) + case OpARM64CMPWconst: + return rewriteValueARM64latelower_OpARM64CMPWconst(v) + case OpARM64CMPconst: + return rewriteValueARM64latelower_OpARM64CMPconst(v) + case OpARM64MOVBUreg: + return rewriteValueARM64latelower_OpARM64MOVBUreg(v) + case OpARM64MOVBreg: + return rewriteValueARM64latelower_OpARM64MOVBreg(v) + case OpARM64MOVDconst: + return rewriteValueARM64latelower_OpARM64MOVDconst(v) + case OpARM64MOVDnop: + return rewriteValueARM64latelower_OpARM64MOVDnop(v) + case OpARM64MOVDreg: + return rewriteValueARM64latelower_OpARM64MOVDreg(v) + case OpARM64MOVHUreg: + return rewriteValueARM64latelower_OpARM64MOVHUreg(v) + case OpARM64MOVHreg: + return rewriteValueARM64latelower_OpARM64MOVHreg(v) + case OpARM64MOVWUreg: + return rewriteValueARM64latelower_OpARM64MOVWUreg(v) + case OpARM64MOVWreg: + return rewriteValueARM64latelower_OpARM64MOVWreg(v) + case OpARM64ORconst: + return rewriteValueARM64latelower_OpARM64ORconst(v) + case OpARM64SLLconst: + return rewriteValueARM64latelower_OpARM64SLLconst(v) + case OpARM64SUBconst: + return rewriteValueARM64latelower_OpARM64SUBconst(v) + case OpARM64TSTWconst: + return rewriteValueARM64latelower_OpARM64TSTWconst(v) + case OpARM64TSTconst: + return rewriteValueARM64latelower_OpARM64TSTconst(v) + case OpARM64XORconst: + return rewriteValueARM64latelower_OpARM64XORconst(v) + } + return false +} +func rewriteValueARM64latelower_OpARM64ADDSconstflags(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADDSconstflags [c] x) + // cond: !isARM64addcon(c) + // result: (ADDSflags x (MOVDconst [c])) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if !(!isARM64addcon(c)) { + break + } + v.reset(OpARM64ADDSflags) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64ADDconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADDconst [c] x) + // cond: !isARM64addcon(c) + // result: (ADD x (MOVDconst [c])) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if !(!isARM64addcon(c)) { + break + } + v.reset(OpARM64ADD) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64ANDconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ANDconst [c] x) + // cond: !isARM64bitcon(uint64(c)) + // result: (AND x (MOVDconst [c])) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if !(!isARM64bitcon(uint64(c))) { + break + } + v.reset(OpARM64AND) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64CMNWconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMNWconst [c] x) + // cond: !isARM64addcon(int64(c)) + // result: (CMNW x (MOVDconst [int64(c)])) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(!isARM64addcon(int64(c))) { + break + } + v.reset(OpARM64CMNW) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(int64(c)) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64CMNconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMNconst [c] x) + // cond: !isARM64addcon(c) + // result: (CMN x (MOVDconst [c])) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if !(!isARM64addcon(c)) { + break + } + v.reset(OpARM64CMN) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64CMPWconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPWconst [c] x) + // cond: !isARM64addcon(int64(c)) + // result: (CMPW x (MOVDconst [int64(c)])) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(!isARM64addcon(int64(c))) { + break + } + v.reset(OpARM64CMPW) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(int64(c)) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64CMPconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CMPconst [c] x) + // cond: !isARM64addcon(c) + // result: (CMP x (MOVDconst [c])) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if !(!isARM64addcon(c)) { + break + } + v.reset(OpARM64CMP) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64MOVBUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBUreg x:(Equal _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64Equal { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(NotEqual _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64NotEqual { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(LessThan _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64LessThan { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(LessThanU _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64LessThanU { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(LessThanF _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64LessThanF { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(LessEqual _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64LessEqual { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(LessEqualU _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64LessEqualU { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(LessEqualF _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64LessEqualF { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(GreaterThan _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64GreaterThan { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(GreaterThanU _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64GreaterThanU { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(GreaterThanF _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64GreaterThanF { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(GreaterEqual _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64GreaterEqual { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(GreaterEqualU _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64GreaterEqualU { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(GreaterEqualF _)) + // result: x + for { + x := v_0 + if x.Op != OpARM64GreaterEqualF { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(MOVBUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(MOVBUloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(MOVBUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64MOVBreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBreg x:(MOVBload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64MOVDconst(v *Value) bool { + // match: (MOVDconst [0]) + // result: (ZERO) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + v.reset(OpARM64ZERO) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64MOVDnop(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVDnop (MOVDconst [c])) + // result: (MOVDconst [c]) + for { + if v_0.Op != OpARM64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpARM64MOVDconst) + v.AuxInt = int64ToAuxInt(c) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64MOVDreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVDreg x) + // cond: x.Uses == 1 + // result: (MOVDnop x) + for { + x := v_0 + if !(x.Uses == 1) { + break + } + v.reset(OpARM64MOVDnop) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64MOVHUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVHUreg x:(MOVBUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVBUloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUloadidx2 _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUloadidx2 { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVBUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64MOVHreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVHreg x:(MOVBload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHloadidx2 _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHloadidx2 { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64MOVWUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWUreg x) + // cond: zeroUpper32Bits(x, 3) + // result: x + for { + x := v_0 + if !(zeroUpper32Bits(x, 3)) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWUreg x:(MOVBUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVWUload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVBUloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVWUloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUloadidx2 _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUloadidx2 { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUloadidx4 _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVWUloadidx4 { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVBUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVWUreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64MOVWreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWreg x:(MOVBload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVWload { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBUloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHUloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWloadidx _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVWloadidx { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHloadidx2 _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHloadidx2 { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHUloadidx2 _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHUloadidx2 { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWloadidx4 _ _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVWloadidx4 { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVBUreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVHreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpARM64MOVWreg { + break + } + v.reset(OpARM64MOVDreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64ORconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ORconst [c] x) + // cond: !isARM64bitcon(uint64(c)) + // result: (OR x (MOVDconst [c])) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if !(!isARM64bitcon(uint64(c))) { + break + } + v.reset(OpARM64OR) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64SLLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLLconst [1] x) + // result: (ADD x x) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + x := v_0 + v.reset(OpARM64ADD) + v.AddArg2(x, x) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64SUBconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SUBconst [c] x) + // cond: !isARM64addcon(c) + // result: (SUB x (MOVDconst [c])) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if !(!isARM64addcon(c)) { + break + } + v.reset(OpARM64SUB) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64TSTWconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (TSTWconst [c] x) + // cond: !isARM64bitcon(uint64(c)|uint64(c)<<32) + // result: (TSTW x (MOVDconst [int64(c)])) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(!isARM64bitcon(uint64(c) | uint64(c)<<32)) { + break + } + v.reset(OpARM64TSTW) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(int64(c)) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64TSTconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (TSTconst [c] x) + // cond: !isARM64bitcon(uint64(c)) + // result: (TST x (MOVDconst [c])) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if !(!isARM64bitcon(uint64(c))) { + break + } + v.reset(OpARM64TST) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueARM64latelower_OpARM64XORconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (XORconst [c] x) + // cond: !isARM64bitcon(uint64(c)) + // result: (XOR x (MOVDconst [c])) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if !(!isARM64bitcon(uint64(c))) { + break + } + v.reset(OpARM64XOR) + v0 := b.NewValue0(v.Pos, OpARM64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteBlockARM64latelower(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteCond_test.go b/go/src/cmd/compile/internal/ssa/rewriteCond_test.go new file mode 100644 index 0000000000000000000000000000000000000000..eb5c1de6de735be5082411731ef9b130e4ccea26 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteCond_test.go @@ -0,0 +1,635 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "math" + "math/rand" + "testing" +) + +var ( + x64 int64 = math.MaxInt64 - 2 + x64b int64 = math.MaxInt64 - 2 + x64c int64 = math.MaxInt64 - 2 + y64 int64 = math.MinInt64 + 1 + x32 int32 = math.MaxInt32 - 2 + x32b int32 = math.MaxInt32 - 2 + x32c int32 = math.MaxInt32 - 2 + y32 int32 = math.MinInt32 + 1 + one64 int64 = 1 + one32 int32 = 1 + v64 int64 = 11 // ensure it's not 2**n +/- 1 + v64_n int64 = -11 + v32 int32 = 11 + v32_n int32 = -11 + uv32 uint32 = 19 + uz uint8 = 1 // for lowering to SLL/SRL/SRA +) + +var crTests = []struct { + name string + tf func(t *testing.T) +}{ + {"AddConst64", testAddConst64}, + {"AddConst32", testAddConst32}, + {"AddVar64", testAddVar64}, + {"AddVar64Cset", testAddVar64Cset}, + {"AddVar32", testAddVar32}, + {"MAddVar64", testMAddVar64}, + {"MAddVar32", testMAddVar32}, + {"MSubVar64", testMSubVar64}, + {"MSubVar32", testMSubVar32}, + {"AddShift32", testAddShift32}, + {"SubShift32", testSubShift32}, +} + +var crBenches = []struct { + name string + bf func(b *testing.B) +}{ + {"SoloJump", benchSoloJump}, + {"CombJump", benchCombJump}, +} + +// Test int32/int64's add/sub/madd/msub operations with boundary values to +// ensure the optimization to 'comparing to zero' expressions of if-statements +// yield expected results. +// 32 rewriting rules are covered. At least two scenarios for "Canonicalize +// the order of arguments to comparisons", which helps with CSE, are covered. +// The tedious if-else structures are necessary to ensure all concerned rules +// and machine code sequences are covered. +// It's for arm64 initially, please see https://github.com/golang/go/issues/38740 +func TestCondRewrite(t *testing.T) { + for _, test := range crTests { + t.Run(test.name, test.tf) + } +} + +// Profile the aforementioned optimization from two angles: +// +// SoloJump: generated branching code has one 'jump', for '<' and '>=' +// CombJump: generated branching code has two consecutive 'jump', for '<=' and '>' +// +// We expect that 'CombJump' is generally on par with the non-optimized code, and +// 'SoloJump' demonstrates some improvement. +// It's for arm64 initially, please see https://github.com/golang/go/issues/38740 +func BenchmarkCondRewrite(b *testing.B) { + for _, bench := range crBenches { + b.Run(bench.name, bench.bf) + } +} + +// var +/- const +func testAddConst64(t *testing.T) { + if x64+11 < 0 { + } else { + t.Errorf("'%#x + 11 < 0' failed", x64) + } + + if x64+13 <= 0 { + } else { + t.Errorf("'%#x + 13 <= 0' failed", x64) + } + + if y64-11 > 0 { + } else { + t.Errorf("'%#x - 11 > 0' failed", y64) + } + + if y64-13 >= 0 { + } else { + t.Errorf("'%#x - 13 >= 0' failed", y64) + } + + if x64+19 > 0 { + t.Errorf("'%#x + 19 > 0' failed", x64) + } + + if x64+23 >= 0 { + t.Errorf("'%#x + 23 >= 0' failed", x64) + } + + if y64-19 < 0 { + t.Errorf("'%#x - 19 < 0' failed", y64) + } + + if y64-23 <= 0 { + t.Errorf("'%#x - 23 <= 0' failed", y64) + } +} + +// 32-bit var +/- const +func testAddConst32(t *testing.T) { + if x32+11 < 0 { + } else { + t.Errorf("'%#x + 11 < 0' failed", x32) + } + + if x32+13 <= 0 { + } else { + t.Errorf("'%#x + 13 <= 0' failed", x32) + } + + if y32-11 > 0 { + } else { + t.Errorf("'%#x - 11 > 0' failed", y32) + } + + if y32-13 >= 0 { + } else { + t.Errorf("'%#x - 13 >= 0' failed", y32) + } + + if x32+19 > 0 { + t.Errorf("'%#x + 19 > 0' failed", x32) + } + + if x32+23 >= 0 { + t.Errorf("'%#x + 23 >= 0' failed", x32) + } + + if y32-19 < 0 { + t.Errorf("'%#x - 19 < 0' failed", y32) + } + + if y32-23 <= 0 { + t.Errorf("'%#x - 23 <= 0' failed", y32) + } +} + +// var + var +func testAddVar64(t *testing.T) { + if x64+v64 < 0 { + } else { + t.Errorf("'%#x + %#x < 0' failed", x64, v64) + } + + if x64+v64 <= 0 { + } else { + t.Errorf("'%#x + %#x <= 0' failed", x64, v64) + } + + if y64+v64_n > 0 { + } else { + t.Errorf("'%#x + %#x > 0' failed", y64, v64_n) + } + + if y64+v64_n >= 0 { + } else { + t.Errorf("'%#x + %#x >= 0' failed", y64, v64_n) + } + + if x64+v64 > 0 { + t.Errorf("'%#x + %#x > 0' failed", x64, v64) + } + + if x64+v64 >= 0 { + t.Errorf("'%#x + %#x >= 0' failed", x64, v64) + } + + if y64+v64_n < 0 { + t.Errorf("'%#x + %#x < 0' failed", y64, v64_n) + } + + if y64+v64_n <= 0 { + t.Errorf("'%#x + %#x <= 0' failed", y64, v64_n) + } +} + +// var + var, cset +func testAddVar64Cset(t *testing.T) { + var a int + if x64+v64 < 0 { + a = 1 + } + if a != 1 { + t.Errorf("'%#x + %#x < 0' failed", x64, v64) + } + + a = 0 + if y64+v64_n >= 0 { + a = 1 + } + if a != 1 { + t.Errorf("'%#x + %#x >= 0' failed", y64, v64_n) + } + + a = 1 + if x64+v64 >= 0 { + a = 0 + } + if a == 0 { + t.Errorf("'%#x + %#x >= 0' failed", x64, v64) + } + + a = 1 + if y64+v64_n < 0 { + a = 0 + } + if a == 0 { + t.Errorf("'%#x + %#x < 0' failed", y64, v64_n) + } +} + +// 32-bit var+var +func testAddVar32(t *testing.T) { + if x32+v32 < 0 { + } else { + t.Errorf("'%#x + %#x < 0' failed", x32, v32) + } + + if x32+v32 <= 0 { + } else { + t.Errorf("'%#x + %#x <= 0' failed", x32, v32) + } + + if y32+v32_n > 0 { + } else { + t.Errorf("'%#x + %#x > 0' failed", y32, v32_n) + } + + if y32+v32_n >= 0 { + } else { + t.Errorf("'%#x + %#x >= 0' failed", y32, v32_n) + } + + if x32+v32 > 0 { + t.Errorf("'%#x + %#x > 0' failed", x32, v32) + } + + if x32+v32 >= 0 { + t.Errorf("'%#x + %#x >= 0' failed", x32, v32) + } + + if y32+v32_n < 0 { + t.Errorf("'%#x + %#x < 0' failed", y32, v32_n) + } + + if y32+v32_n <= 0 { + t.Errorf("'%#x + %#x <= 0' failed", y32, v32_n) + } +} + +// multiply-add +func testMAddVar64(t *testing.T) { + if x64+v64*one64 < 0 { + } else { + t.Errorf("'%#x + %#x*1 < 0' failed", x64, v64) + } + + if x64+v64*one64 <= 0 { + } else { + t.Errorf("'%#x + %#x*1 <= 0' failed", x64, v64) + } + + if y64+v64_n*one64 > 0 { + } else { + t.Errorf("'%#x + %#x*1 > 0' failed", y64, v64_n) + } + + if y64+v64_n*one64 >= 0 { + } else { + t.Errorf("'%#x + %#x*1 >= 0' failed", y64, v64_n) + } + + if x64+v64*one64 > 0 { + t.Errorf("'%#x + %#x*1 > 0' failed", x64, v64) + } + + if x64+v64*one64 >= 0 { + t.Errorf("'%#x + %#x*1 >= 0' failed", x64, v64) + } + + if y64+v64_n*one64 < 0 { + t.Errorf("'%#x + %#x*1 < 0' failed", y64, v64_n) + } + + if y64+v64_n*one64 <= 0 { + t.Errorf("'%#x + %#x*1 <= 0' failed", y64, v64_n) + } +} + +// 32-bit multiply-add +func testMAddVar32(t *testing.T) { + if x32+v32*one32 < 0 { + } else { + t.Errorf("'%#x + %#x*1 < 0' failed", x32, v32) + } + + if x32+v32*one32 <= 0 { + } else { + t.Errorf("'%#x + %#x*1 <= 0' failed", x32, v32) + } + + if y32+v32_n*one32 > 0 { + } else { + t.Errorf("'%#x + %#x*1 > 0' failed", y32, v32_n) + } + + if y32+v32_n*one32 >= 0 { + } else { + t.Errorf("'%#x + %#x*1 >= 0' failed", y32, v32_n) + } + + if x32+v32*one32 > 0 { + t.Errorf("'%#x + %#x*1 > 0' failed", x32, v32) + } + + if x32+v32*one32 >= 0 { + t.Errorf("'%#x + %#x*1 >= 0' failed", x32, v32) + } + + if y32+v32_n*one32 < 0 { + t.Errorf("'%#x + %#x*1 < 0' failed", y32, v32_n) + } + + if y32+v32_n*one32 <= 0 { + t.Errorf("'%#x + %#x*1 <= 0' failed", y32, v32_n) + } +} + +// multiply-sub +func testMSubVar64(t *testing.T) { + if x64-v64_n*one64 < 0 { + } else { + t.Errorf("'%#x - %#x*1 < 0' failed", x64, v64_n) + } + + if x64-v64_n*one64 <= 0 { + } else { + t.Errorf("'%#x - %#x*1 <= 0' failed", x64, v64_n) + } + + if y64-v64*one64 > 0 { + } else { + t.Errorf("'%#x - %#x*1 > 0' failed", y64, v64) + } + + if y64-v64*one64 >= 0 { + } else { + t.Errorf("'%#x - %#x*1 >= 0' failed", y64, v64) + } + + if x64-v64_n*one64 > 0 { + t.Errorf("'%#x - %#x*1 > 0' failed", x64, v64_n) + } + + if x64-v64_n*one64 >= 0 { + t.Errorf("'%#x - %#x*1 >= 0' failed", x64, v64_n) + } + + if y64-v64*one64 < 0 { + t.Errorf("'%#x - %#x*1 < 0' failed", y64, v64) + } + + if y64-v64*one64 <= 0 { + t.Errorf("'%#x - %#x*1 <= 0' failed", y64, v64) + } + + if x64-x64b*one64 < 0 { + t.Errorf("'%#x - %#x*1 < 0' failed", x64, x64b) + } + + if x64-x64b*one64 >= 0 { + } else { + t.Errorf("'%#x - %#x*1 >= 0' failed", x64, x64b) + } +} + +// 32-bit multiply-sub +func testMSubVar32(t *testing.T) { + if x32-v32_n*one32 < 0 { + } else { + t.Errorf("'%#x - %#x*1 < 0' failed", x32, v32_n) + } + + if x32-v32_n*one32 <= 0 { + } else { + t.Errorf("'%#x - %#x*1 <= 0' failed", x32, v32_n) + } + + if y32-v32*one32 > 0 { + } else { + t.Errorf("'%#x - %#x*1 > 0' failed", y32, v32) + } + + if y32-v32*one32 >= 0 { + } else { + t.Errorf("'%#x - %#x*1 >= 0' failed", y32, v32) + } + + if x32-v32_n*one32 > 0 { + t.Errorf("'%#x - %#x*1 > 0' failed", x32, v32_n) + } + + if x32-v32_n*one32 >= 0 { + t.Errorf("'%#x - %#x*1 >= 0' failed", x32, v32_n) + } + + if y32-v32*one32 < 0 { + t.Errorf("'%#x - %#x*1 < 0' failed", y32, v32) + } + + if y32-v32*one32 <= 0 { + t.Errorf("'%#x - %#x*1 <= 0' failed", y32, v32) + } + + if x32-x32b*one32 < 0 { + t.Errorf("'%#x - %#x*1 < 0' failed", x32, x32b) + } + + if x32-x32b*one32 >= 0 { + } else { + t.Errorf("'%#x - %#x*1 >= 0' failed", x32, x32b) + } +} + +// 32-bit ADDshift, pick up 1~2 scenarios randomly for each condition +func testAddShift32(t *testing.T) { + if x32+v32<<1 < 0 { + } else { + t.Errorf("'%#x + %#x<<%#x < 0' failed", x32, v32, 1) + } + + if x32+v32>>1 <= 0 { + } else { + t.Errorf("'%#x + %#x>>%#x <= 0' failed", x32, v32, 1) + } + + if x32+int32(uv32>>1) > 0 { + t.Errorf("'%#x + int32(%#x>>%#x) > 0' failed", x32, uv32, 1) + } + + if x32+v32<= 0 { + t.Errorf("'%#x + %#x<<%#x >= 0' failed", x32, v32, uz) + } + + if x32+v32>>uz > 0 { + t.Errorf("'%#x + %#x>>%#x > 0' failed", x32, v32, uz) + } + + if x32+int32(uv32>>uz) < 0 { + } else { + t.Errorf("'%#x + int32(%#x>>%#x) < 0' failed", x32, uv32, uz) + } +} + +// 32-bit SUBshift, pick up 1~2 scenarios randomly for each condition +func testSubShift32(t *testing.T) { + if y32-v32<<1 > 0 { + } else { + t.Errorf("'%#x - %#x<<%#x > 0' failed", y32, v32, 1) + } + + if y32-v32>>1 < 0 { + t.Errorf("'%#x - %#x>>%#x < 0' failed", y32, v32, 1) + } + + if y32-int32(uv32>>1) >= 0 { + } else { + t.Errorf("'%#x - int32(%#x>>%#x) >= 0' failed", y32, uv32, 1) + } + + if y32-v32<>uz >= 0 { + } else { + t.Errorf("'%#x - %#x>>%#x >= 0' failed", y32, v32, uz) + } + + if y32-int32(uv32>>uz) <= 0 { + t.Errorf("'%#x - int32(%#x>>%#x) <= 0' failed", y32, uv32, uz) + } +} + +var rnd = rand.New(rand.NewSource(0)) +var sink int64 + +func benchSoloJump(b *testing.B) { + r1 := x64 + r2 := x64b + r3 := x64c + r4 := y64 + d := rnd.Int63n(10) + + // 6 out 10 conditions evaluate to true + for i := 0; i < b.N; i++ { + if r1+r2 < 0 { + d *= 2 + d /= 2 + } + + if r1+r3 >= 0 { + d *= 2 + d /= 2 + } + + if r1+r2*one64 < 0 { + d *= 2 + d /= 2 + } + + if r2+r3*one64 >= 0 { + d *= 2 + d /= 2 + } + + if r1-r2*v64 >= 0 { + d *= 2 + d /= 2 + } + + if r3-r4*v64 < 0 { + d *= 2 + d /= 2 + } + + if r1+11 < 0 { + d *= 2 + d /= 2 + } + + if r1+13 >= 0 { + d *= 2 + d /= 2 + } + + if r4-17 < 0 { + d *= 2 + d /= 2 + } + + if r4-19 >= 0 { + d *= 2 + d /= 2 + } + } + sink = d +} + +func benchCombJump(b *testing.B) { + r1 := x64 + r2 := x64b + r3 := x64c + r4 := y64 + d := rnd.Int63n(10) + + // 6 out 10 conditions evaluate to true + for i := 0; i < b.N; i++ { + if r1+r2 <= 0 { + d *= 2 + d /= 2 + } + + if r1+r3 > 0 { + d *= 2 + d /= 2 + } + + if r1+r2*one64 <= 0 { + d *= 2 + d /= 2 + } + + if r2+r3*one64 > 0 { + d *= 2 + d /= 2 + } + + if r1-r2*v64 > 0 { + d *= 2 + d /= 2 + } + + if r3-r4*v64 <= 0 { + d *= 2 + d /= 2 + } + + if r1+11 <= 0 { + d *= 2 + d /= 2 + } + + if r1+13 > 0 { + d *= 2 + d /= 2 + } + + if r4-17 <= 0 { + d *= 2 + d /= 2 + } + + if r4-19 > 0 { + d *= 2 + d /= 2 + } + } + sink = d +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteLOONG64.go b/go/src/cmd/compile/internal/ssa/rewriteLOONG64.go new file mode 100644 index 0000000000000000000000000000000000000000..30ce419d40a428965faa0d9863d2ffa1ffc204bb --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteLOONG64.go @@ -0,0 +1,12813 @@ +// Code generated from _gen/LOONG64.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "cmd/compile/internal/types" + +func rewriteValueLOONG64(v *Value) bool { + switch v.Op { + case OpAbs: + v.Op = OpLOONG64ABSD + return true + case OpAdd16: + v.Op = OpLOONG64ADDV + return true + case OpAdd32: + v.Op = OpLOONG64ADDV + return true + case OpAdd32F: + v.Op = OpLOONG64ADDF + return true + case OpAdd64: + v.Op = OpLOONG64ADDV + return true + case OpAdd64F: + v.Op = OpLOONG64ADDD + return true + case OpAdd8: + v.Op = OpLOONG64ADDV + return true + case OpAddPtr: + v.Op = OpLOONG64ADDV + return true + case OpAddr: + return rewriteValueLOONG64_OpAddr(v) + case OpAnd16: + v.Op = OpLOONG64AND + return true + case OpAnd32: + v.Op = OpLOONG64AND + return true + case OpAnd64: + v.Op = OpLOONG64AND + return true + case OpAnd8: + v.Op = OpLOONG64AND + return true + case OpAndB: + v.Op = OpLOONG64AND + return true + case OpAtomicAdd32: + v.Op = OpLOONG64LoweredAtomicAdd32 + return true + case OpAtomicAdd64: + v.Op = OpLOONG64LoweredAtomicAdd64 + return true + case OpAtomicAnd32: + v.Op = OpLOONG64LoweredAtomicAnd32 + return true + case OpAtomicAnd32value: + v.Op = OpLOONG64LoweredAtomicAnd32value + return true + case OpAtomicAnd64value: + v.Op = OpLOONG64LoweredAtomicAnd64value + return true + case OpAtomicAnd8: + return rewriteValueLOONG64_OpAtomicAnd8(v) + case OpAtomicCompareAndSwap32: + return rewriteValueLOONG64_OpAtomicCompareAndSwap32(v) + case OpAtomicCompareAndSwap32Variant: + return rewriteValueLOONG64_OpAtomicCompareAndSwap32Variant(v) + case OpAtomicCompareAndSwap64: + v.Op = OpLOONG64LoweredAtomicCas64 + return true + case OpAtomicCompareAndSwap64Variant: + v.Op = OpLOONG64LoweredAtomicCas64Variant + return true + case OpAtomicExchange32: + v.Op = OpLOONG64LoweredAtomicExchange32 + return true + case OpAtomicExchange64: + v.Op = OpLOONG64LoweredAtomicExchange64 + return true + case OpAtomicExchange8Variant: + v.Op = OpLOONG64LoweredAtomicExchange8Variant + return true + case OpAtomicLoad32: + v.Op = OpLOONG64LoweredAtomicLoad32 + return true + case OpAtomicLoad64: + v.Op = OpLOONG64LoweredAtomicLoad64 + return true + case OpAtomicLoad8: + v.Op = OpLOONG64LoweredAtomicLoad8 + return true + case OpAtomicLoadPtr: + v.Op = OpLOONG64LoweredAtomicLoad64 + return true + case OpAtomicOr32: + v.Op = OpLOONG64LoweredAtomicOr32 + return true + case OpAtomicOr32value: + v.Op = OpLOONG64LoweredAtomicOr32value + return true + case OpAtomicOr64value: + v.Op = OpLOONG64LoweredAtomicOr64value + return true + case OpAtomicOr8: + return rewriteValueLOONG64_OpAtomicOr8(v) + case OpAtomicStore32: + v.Op = OpLOONG64LoweredAtomicStore32 + return true + case OpAtomicStore32Variant: + v.Op = OpLOONG64LoweredAtomicStore32Variant + return true + case OpAtomicStore64: + v.Op = OpLOONG64LoweredAtomicStore64 + return true + case OpAtomicStore64Variant: + v.Op = OpLOONG64LoweredAtomicStore64Variant + return true + case OpAtomicStore8: + v.Op = OpLOONG64LoweredAtomicStore8 + return true + case OpAtomicStore8Variant: + v.Op = OpLOONG64LoweredAtomicStore8Variant + return true + case OpAtomicStorePtrNoWB: + v.Op = OpLOONG64LoweredAtomicStore64 + return true + case OpAvg64u: + return rewriteValueLOONG64_OpAvg64u(v) + case OpBitLen16: + return rewriteValueLOONG64_OpBitLen16(v) + case OpBitLen32: + return rewriteValueLOONG64_OpBitLen32(v) + case OpBitLen64: + return rewriteValueLOONG64_OpBitLen64(v) + case OpBitLen8: + return rewriteValueLOONG64_OpBitLen8(v) + case OpBitRev16: + return rewriteValueLOONG64_OpBitRev16(v) + case OpBitRev32: + v.Op = OpLOONG64BITREVW + return true + case OpBitRev64: + v.Op = OpLOONG64BITREVV + return true + case OpBitRev8: + v.Op = OpLOONG64BITREV4B + return true + case OpBswap16: + v.Op = OpLOONG64REVB2H + return true + case OpBswap32: + v.Op = OpLOONG64REVB2W + return true + case OpBswap64: + v.Op = OpLOONG64REVBV + return true + case OpClosureCall: + v.Op = OpLOONG64CALLclosure + return true + case OpCom16: + return rewriteValueLOONG64_OpCom16(v) + case OpCom32: + return rewriteValueLOONG64_OpCom32(v) + case OpCom64: + return rewriteValueLOONG64_OpCom64(v) + case OpCom8: + return rewriteValueLOONG64_OpCom8(v) + case OpCondSelect: + return rewriteValueLOONG64_OpCondSelect(v) + case OpConst16: + return rewriteValueLOONG64_OpConst16(v) + case OpConst32: + return rewriteValueLOONG64_OpConst32(v) + case OpConst32F: + return rewriteValueLOONG64_OpConst32F(v) + case OpConst64: + return rewriteValueLOONG64_OpConst64(v) + case OpConst64F: + return rewriteValueLOONG64_OpConst64F(v) + case OpConst8: + return rewriteValueLOONG64_OpConst8(v) + case OpConstBool: + return rewriteValueLOONG64_OpConstBool(v) + case OpConstNil: + return rewriteValueLOONG64_OpConstNil(v) + case OpCopysign: + v.Op = OpLOONG64FCOPYSGD + return true + case OpCtz16: + return rewriteValueLOONG64_OpCtz16(v) + case OpCtz16NonZero: + v.Op = OpCtz64 + return true + case OpCtz32: + v.Op = OpLOONG64CTZW + return true + case OpCtz32NonZero: + v.Op = OpCtz64 + return true + case OpCtz64: + v.Op = OpLOONG64CTZV + return true + case OpCtz64NonZero: + v.Op = OpCtz64 + return true + case OpCtz8: + return rewriteValueLOONG64_OpCtz8(v) + case OpCtz8NonZero: + v.Op = OpCtz64 + return true + case OpCvt32Fto32: + v.Op = OpLOONG64TRUNCFW + return true + case OpCvt32Fto64: + v.Op = OpLOONG64TRUNCFV + return true + case OpCvt32Fto64F: + v.Op = OpLOONG64MOVFD + return true + case OpCvt32to32F: + v.Op = OpLOONG64MOVWF + return true + case OpCvt32to64F: + v.Op = OpLOONG64MOVWD + return true + case OpCvt64Fto32: + v.Op = OpLOONG64TRUNCDW + return true + case OpCvt64Fto32F: + v.Op = OpLOONG64MOVDF + return true + case OpCvt64Fto64: + v.Op = OpLOONG64TRUNCDV + return true + case OpCvt64to32F: + v.Op = OpLOONG64MOVVF + return true + case OpCvt64to64F: + v.Op = OpLOONG64MOVVD + return true + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpDiv16: + return rewriteValueLOONG64_OpDiv16(v) + case OpDiv16u: + return rewriteValueLOONG64_OpDiv16u(v) + case OpDiv32: + return rewriteValueLOONG64_OpDiv32(v) + case OpDiv32F: + v.Op = OpLOONG64DIVF + return true + case OpDiv32u: + return rewriteValueLOONG64_OpDiv32u(v) + case OpDiv64: + return rewriteValueLOONG64_OpDiv64(v) + case OpDiv64F: + v.Op = OpLOONG64DIVD + return true + case OpDiv64u: + v.Op = OpLOONG64DIVVU + return true + case OpDiv8: + return rewriteValueLOONG64_OpDiv8(v) + case OpDiv8u: + return rewriteValueLOONG64_OpDiv8u(v) + case OpEq16: + return rewriteValueLOONG64_OpEq16(v) + case OpEq32: + return rewriteValueLOONG64_OpEq32(v) + case OpEq32F: + return rewriteValueLOONG64_OpEq32F(v) + case OpEq64: + return rewriteValueLOONG64_OpEq64(v) + case OpEq64F: + return rewriteValueLOONG64_OpEq64F(v) + case OpEq8: + return rewriteValueLOONG64_OpEq8(v) + case OpEqB: + return rewriteValueLOONG64_OpEqB(v) + case OpEqPtr: + return rewriteValueLOONG64_OpEqPtr(v) + case OpFMA: + v.Op = OpLOONG64FMADDD + return true + case OpGetCallerPC: + v.Op = OpLOONG64LoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = OpLOONG64LoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = OpLOONG64LoweredGetClosurePtr + return true + case OpHmul32: + v.Op = OpLOONG64MULH + return true + case OpHmul32u: + v.Op = OpLOONG64MULHU + return true + case OpHmul64: + v.Op = OpLOONG64MULHV + return true + case OpHmul64u: + v.Op = OpLOONG64MULHVU + return true + case OpInterCall: + v.Op = OpLOONG64CALLinter + return true + case OpIsInBounds: + return rewriteValueLOONG64_OpIsInBounds(v) + case OpIsNonNil: + return rewriteValueLOONG64_OpIsNonNil(v) + case OpIsSliceInBounds: + return rewriteValueLOONG64_OpIsSliceInBounds(v) + case OpLOONG64ADDD: + return rewriteValueLOONG64_OpLOONG64ADDD(v) + case OpLOONG64ADDF: + return rewriteValueLOONG64_OpLOONG64ADDF(v) + case OpLOONG64ADDV: + return rewriteValueLOONG64_OpLOONG64ADDV(v) + case OpLOONG64ADDVconst: + return rewriteValueLOONG64_OpLOONG64ADDVconst(v) + case OpLOONG64ADDshiftLLV: + return rewriteValueLOONG64_OpLOONG64ADDshiftLLV(v) + case OpLOONG64AND: + return rewriteValueLOONG64_OpLOONG64AND(v) + case OpLOONG64ANDconst: + return rewriteValueLOONG64_OpLOONG64ANDconst(v) + case OpLOONG64DIVV: + return rewriteValueLOONG64_OpLOONG64DIVV(v) + case OpLOONG64DIVVU: + return rewriteValueLOONG64_OpLOONG64DIVVU(v) + case OpLOONG64LoweredPanicBoundsCR: + return rewriteValueLOONG64_OpLOONG64LoweredPanicBoundsCR(v) + case OpLOONG64LoweredPanicBoundsRC: + return rewriteValueLOONG64_OpLOONG64LoweredPanicBoundsRC(v) + case OpLOONG64LoweredPanicBoundsRR: + return rewriteValueLOONG64_OpLOONG64LoweredPanicBoundsRR(v) + case OpLOONG64MASKEQZ: + return rewriteValueLOONG64_OpLOONG64MASKEQZ(v) + case OpLOONG64MASKNEZ: + return rewriteValueLOONG64_OpLOONG64MASKNEZ(v) + case OpLOONG64MOVBUload: + return rewriteValueLOONG64_OpLOONG64MOVBUload(v) + case OpLOONG64MOVBUloadidx: + return rewriteValueLOONG64_OpLOONG64MOVBUloadidx(v) + case OpLOONG64MOVBUreg: + return rewriteValueLOONG64_OpLOONG64MOVBUreg(v) + case OpLOONG64MOVBload: + return rewriteValueLOONG64_OpLOONG64MOVBload(v) + case OpLOONG64MOVBloadidx: + return rewriteValueLOONG64_OpLOONG64MOVBloadidx(v) + case OpLOONG64MOVBreg: + return rewriteValueLOONG64_OpLOONG64MOVBreg(v) + case OpLOONG64MOVBstore: + return rewriteValueLOONG64_OpLOONG64MOVBstore(v) + case OpLOONG64MOVBstoreidx: + return rewriteValueLOONG64_OpLOONG64MOVBstoreidx(v) + case OpLOONG64MOVDload: + return rewriteValueLOONG64_OpLOONG64MOVDload(v) + case OpLOONG64MOVDloadidx: + return rewriteValueLOONG64_OpLOONG64MOVDloadidx(v) + case OpLOONG64MOVDstore: + return rewriteValueLOONG64_OpLOONG64MOVDstore(v) + case OpLOONG64MOVDstoreidx: + return rewriteValueLOONG64_OpLOONG64MOVDstoreidx(v) + case OpLOONG64MOVFload: + return rewriteValueLOONG64_OpLOONG64MOVFload(v) + case OpLOONG64MOVFloadidx: + return rewriteValueLOONG64_OpLOONG64MOVFloadidx(v) + case OpLOONG64MOVFstore: + return rewriteValueLOONG64_OpLOONG64MOVFstore(v) + case OpLOONG64MOVFstoreidx: + return rewriteValueLOONG64_OpLOONG64MOVFstoreidx(v) + case OpLOONG64MOVHUload: + return rewriteValueLOONG64_OpLOONG64MOVHUload(v) + case OpLOONG64MOVHUloadidx: + return rewriteValueLOONG64_OpLOONG64MOVHUloadidx(v) + case OpLOONG64MOVHUreg: + return rewriteValueLOONG64_OpLOONG64MOVHUreg(v) + case OpLOONG64MOVHload: + return rewriteValueLOONG64_OpLOONG64MOVHload(v) + case OpLOONG64MOVHloadidx: + return rewriteValueLOONG64_OpLOONG64MOVHloadidx(v) + case OpLOONG64MOVHreg: + return rewriteValueLOONG64_OpLOONG64MOVHreg(v) + case OpLOONG64MOVHstore: + return rewriteValueLOONG64_OpLOONG64MOVHstore(v) + case OpLOONG64MOVHstoreidx: + return rewriteValueLOONG64_OpLOONG64MOVHstoreidx(v) + case OpLOONG64MOVVload: + return rewriteValueLOONG64_OpLOONG64MOVVload(v) + case OpLOONG64MOVVloadidx: + return rewriteValueLOONG64_OpLOONG64MOVVloadidx(v) + case OpLOONG64MOVVnop: + return rewriteValueLOONG64_OpLOONG64MOVVnop(v) + case OpLOONG64MOVVreg: + return rewriteValueLOONG64_OpLOONG64MOVVreg(v) + case OpLOONG64MOVVstore: + return rewriteValueLOONG64_OpLOONG64MOVVstore(v) + case OpLOONG64MOVVstoreidx: + return rewriteValueLOONG64_OpLOONG64MOVVstoreidx(v) + case OpLOONG64MOVWUload: + return rewriteValueLOONG64_OpLOONG64MOVWUload(v) + case OpLOONG64MOVWUloadidx: + return rewriteValueLOONG64_OpLOONG64MOVWUloadidx(v) + case OpLOONG64MOVWUreg: + return rewriteValueLOONG64_OpLOONG64MOVWUreg(v) + case OpLOONG64MOVWload: + return rewriteValueLOONG64_OpLOONG64MOVWload(v) + case OpLOONG64MOVWloadidx: + return rewriteValueLOONG64_OpLOONG64MOVWloadidx(v) + case OpLOONG64MOVWreg: + return rewriteValueLOONG64_OpLOONG64MOVWreg(v) + case OpLOONG64MOVWstore: + return rewriteValueLOONG64_OpLOONG64MOVWstore(v) + case OpLOONG64MOVWstoreidx: + return rewriteValueLOONG64_OpLOONG64MOVWstoreidx(v) + case OpLOONG64MULV: + return rewriteValueLOONG64_OpLOONG64MULV(v) + case OpLOONG64NEGV: + return rewriteValueLOONG64_OpLOONG64NEGV(v) + case OpLOONG64NOR: + return rewriteValueLOONG64_OpLOONG64NOR(v) + case OpLOONG64NORconst: + return rewriteValueLOONG64_OpLOONG64NORconst(v) + case OpLOONG64OR: + return rewriteValueLOONG64_OpLOONG64OR(v) + case OpLOONG64ORN: + return rewriteValueLOONG64_OpLOONG64ORN(v) + case OpLOONG64ORconst: + return rewriteValueLOONG64_OpLOONG64ORconst(v) + case OpLOONG64REMV: + return rewriteValueLOONG64_OpLOONG64REMV(v) + case OpLOONG64REMVU: + return rewriteValueLOONG64_OpLOONG64REMVU(v) + case OpLOONG64ROTR: + return rewriteValueLOONG64_OpLOONG64ROTR(v) + case OpLOONG64ROTRV: + return rewriteValueLOONG64_OpLOONG64ROTRV(v) + case OpLOONG64SGT: + return rewriteValueLOONG64_OpLOONG64SGT(v) + case OpLOONG64SGTU: + return rewriteValueLOONG64_OpLOONG64SGTU(v) + case OpLOONG64SGTUconst: + return rewriteValueLOONG64_OpLOONG64SGTUconst(v) + case OpLOONG64SGTconst: + return rewriteValueLOONG64_OpLOONG64SGTconst(v) + case OpLOONG64SLL: + return rewriteValueLOONG64_OpLOONG64SLL(v) + case OpLOONG64SLLV: + return rewriteValueLOONG64_OpLOONG64SLLV(v) + case OpLOONG64SLLVconst: + return rewriteValueLOONG64_OpLOONG64SLLVconst(v) + case OpLOONG64SLLconst: + return rewriteValueLOONG64_OpLOONG64SLLconst(v) + case OpLOONG64SRA: + return rewriteValueLOONG64_OpLOONG64SRA(v) + case OpLOONG64SRAV: + return rewriteValueLOONG64_OpLOONG64SRAV(v) + case OpLOONG64SRAVconst: + return rewriteValueLOONG64_OpLOONG64SRAVconst(v) + case OpLOONG64SRL: + return rewriteValueLOONG64_OpLOONG64SRL(v) + case OpLOONG64SRLV: + return rewriteValueLOONG64_OpLOONG64SRLV(v) + case OpLOONG64SRLVconst: + return rewriteValueLOONG64_OpLOONG64SRLVconst(v) + case OpLOONG64SUBD: + return rewriteValueLOONG64_OpLOONG64SUBD(v) + case OpLOONG64SUBF: + return rewriteValueLOONG64_OpLOONG64SUBF(v) + case OpLOONG64SUBV: + return rewriteValueLOONG64_OpLOONG64SUBV(v) + case OpLOONG64SUBVconst: + return rewriteValueLOONG64_OpLOONG64SUBVconst(v) + case OpLOONG64XOR: + return rewriteValueLOONG64_OpLOONG64XOR(v) + case OpLOONG64XORconst: + return rewriteValueLOONG64_OpLOONG64XORconst(v) + case OpLeq16: + return rewriteValueLOONG64_OpLeq16(v) + case OpLeq16U: + return rewriteValueLOONG64_OpLeq16U(v) + case OpLeq32: + return rewriteValueLOONG64_OpLeq32(v) + case OpLeq32F: + return rewriteValueLOONG64_OpLeq32F(v) + case OpLeq32U: + return rewriteValueLOONG64_OpLeq32U(v) + case OpLeq64: + return rewriteValueLOONG64_OpLeq64(v) + case OpLeq64F: + return rewriteValueLOONG64_OpLeq64F(v) + case OpLeq64U: + return rewriteValueLOONG64_OpLeq64U(v) + case OpLeq8: + return rewriteValueLOONG64_OpLeq8(v) + case OpLeq8U: + return rewriteValueLOONG64_OpLeq8U(v) + case OpLess16: + return rewriteValueLOONG64_OpLess16(v) + case OpLess16U: + return rewriteValueLOONG64_OpLess16U(v) + case OpLess32: + return rewriteValueLOONG64_OpLess32(v) + case OpLess32F: + return rewriteValueLOONG64_OpLess32F(v) + case OpLess32U: + return rewriteValueLOONG64_OpLess32U(v) + case OpLess64: + return rewriteValueLOONG64_OpLess64(v) + case OpLess64F: + return rewriteValueLOONG64_OpLess64F(v) + case OpLess64U: + return rewriteValueLOONG64_OpLess64U(v) + case OpLess8: + return rewriteValueLOONG64_OpLess8(v) + case OpLess8U: + return rewriteValueLOONG64_OpLess8U(v) + case OpLoad: + return rewriteValueLOONG64_OpLoad(v) + case OpLocalAddr: + return rewriteValueLOONG64_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValueLOONG64_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValueLOONG64_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValueLOONG64_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValueLOONG64_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValueLOONG64_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValueLOONG64_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValueLOONG64_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValueLOONG64_OpLsh32x8(v) + case OpLsh64x16: + return rewriteValueLOONG64_OpLsh64x16(v) + case OpLsh64x32: + return rewriteValueLOONG64_OpLsh64x32(v) + case OpLsh64x64: + return rewriteValueLOONG64_OpLsh64x64(v) + case OpLsh64x8: + return rewriteValueLOONG64_OpLsh64x8(v) + case OpLsh8x16: + return rewriteValueLOONG64_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValueLOONG64_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValueLOONG64_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValueLOONG64_OpLsh8x8(v) + case OpMax32F: + v.Op = OpLOONG64FMAXF + return true + case OpMax64F: + v.Op = OpLOONG64FMAXD + return true + case OpMin32F: + v.Op = OpLOONG64FMINF + return true + case OpMin64F: + v.Op = OpLOONG64FMIND + return true + case OpMod16: + return rewriteValueLOONG64_OpMod16(v) + case OpMod16u: + return rewriteValueLOONG64_OpMod16u(v) + case OpMod32: + return rewriteValueLOONG64_OpMod32(v) + case OpMod32u: + return rewriteValueLOONG64_OpMod32u(v) + case OpMod64: + return rewriteValueLOONG64_OpMod64(v) + case OpMod64u: + v.Op = OpLOONG64REMVU + return true + case OpMod8: + return rewriteValueLOONG64_OpMod8(v) + case OpMod8u: + return rewriteValueLOONG64_OpMod8u(v) + case OpMove: + return rewriteValueLOONG64_OpMove(v) + case OpMul16: + v.Op = OpLOONG64MULV + return true + case OpMul32: + v.Op = OpLOONG64MULV + return true + case OpMul32F: + v.Op = OpLOONG64MULF + return true + case OpMul64: + v.Op = OpLOONG64MULV + return true + case OpMul64F: + v.Op = OpLOONG64MULD + return true + case OpMul8: + v.Op = OpLOONG64MULV + return true + case OpNeg16: + v.Op = OpLOONG64NEGV + return true + case OpNeg32: + v.Op = OpLOONG64NEGV + return true + case OpNeg32F: + v.Op = OpLOONG64NEGF + return true + case OpNeg64: + v.Op = OpLOONG64NEGV + return true + case OpNeg64F: + v.Op = OpLOONG64NEGD + return true + case OpNeg8: + v.Op = OpLOONG64NEGV + return true + case OpNeq16: + return rewriteValueLOONG64_OpNeq16(v) + case OpNeq32: + return rewriteValueLOONG64_OpNeq32(v) + case OpNeq32F: + return rewriteValueLOONG64_OpNeq32F(v) + case OpNeq64: + return rewriteValueLOONG64_OpNeq64(v) + case OpNeq64F: + return rewriteValueLOONG64_OpNeq64F(v) + case OpNeq8: + return rewriteValueLOONG64_OpNeq8(v) + case OpNeqB: + v.Op = OpLOONG64XOR + return true + case OpNeqPtr: + return rewriteValueLOONG64_OpNeqPtr(v) + case OpNilCheck: + v.Op = OpLOONG64LoweredNilCheck + return true + case OpNot: + return rewriteValueLOONG64_OpNot(v) + case OpOffPtr: + return rewriteValueLOONG64_OpOffPtr(v) + case OpOr16: + v.Op = OpLOONG64OR + return true + case OpOr32: + v.Op = OpLOONG64OR + return true + case OpOr64: + v.Op = OpLOONG64OR + return true + case OpOr8: + v.Op = OpLOONG64OR + return true + case OpOrB: + v.Op = OpLOONG64OR + return true + case OpPanicBounds: + v.Op = OpLOONG64LoweredPanicBoundsRR + return true + case OpPopCount16: + return rewriteValueLOONG64_OpPopCount16(v) + case OpPopCount32: + return rewriteValueLOONG64_OpPopCount32(v) + case OpPopCount64: + return rewriteValueLOONG64_OpPopCount64(v) + case OpPrefetchCache: + return rewriteValueLOONG64_OpPrefetchCache(v) + case OpPrefetchCacheStreamed: + return rewriteValueLOONG64_OpPrefetchCacheStreamed(v) + case OpPubBarrier: + v.Op = OpLOONG64LoweredPubBarrier + return true + case OpRotateLeft16: + return rewriteValueLOONG64_OpRotateLeft16(v) + case OpRotateLeft32: + return rewriteValueLOONG64_OpRotateLeft32(v) + case OpRotateLeft64: + return rewriteValueLOONG64_OpRotateLeft64(v) + case OpRotateLeft8: + return rewriteValueLOONG64_OpRotateLeft8(v) + case OpRound32F: + v.Op = OpLOONG64LoweredRound32F + return true + case OpRound64F: + v.Op = OpLOONG64LoweredRound64F + return true + case OpRsh16Ux16: + return rewriteValueLOONG64_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValueLOONG64_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValueLOONG64_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValueLOONG64_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValueLOONG64_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValueLOONG64_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValueLOONG64_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValueLOONG64_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValueLOONG64_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValueLOONG64_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValueLOONG64_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValueLOONG64_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValueLOONG64_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValueLOONG64_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValueLOONG64_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValueLOONG64_OpRsh32x8(v) + case OpRsh64Ux16: + return rewriteValueLOONG64_OpRsh64Ux16(v) + case OpRsh64Ux32: + return rewriteValueLOONG64_OpRsh64Ux32(v) + case OpRsh64Ux64: + return rewriteValueLOONG64_OpRsh64Ux64(v) + case OpRsh64Ux8: + return rewriteValueLOONG64_OpRsh64Ux8(v) + case OpRsh64x16: + return rewriteValueLOONG64_OpRsh64x16(v) + case OpRsh64x32: + return rewriteValueLOONG64_OpRsh64x32(v) + case OpRsh64x64: + return rewriteValueLOONG64_OpRsh64x64(v) + case OpRsh64x8: + return rewriteValueLOONG64_OpRsh64x8(v) + case OpRsh8Ux16: + return rewriteValueLOONG64_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValueLOONG64_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValueLOONG64_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValueLOONG64_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValueLOONG64_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValueLOONG64_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValueLOONG64_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValueLOONG64_OpRsh8x8(v) + case OpSelect0: + return rewriteValueLOONG64_OpSelect0(v) + case OpSelect1: + return rewriteValueLOONG64_OpSelect1(v) + case OpSelectN: + return rewriteValueLOONG64_OpSelectN(v) + case OpSignExt16to32: + v.Op = OpLOONG64MOVHreg + return true + case OpSignExt16to64: + v.Op = OpLOONG64MOVHreg + return true + case OpSignExt32to64: + v.Op = OpLOONG64MOVWreg + return true + case OpSignExt8to16: + v.Op = OpLOONG64MOVBreg + return true + case OpSignExt8to32: + v.Op = OpLOONG64MOVBreg + return true + case OpSignExt8to64: + v.Op = OpLOONG64MOVBreg + return true + case OpSlicemask: + return rewriteValueLOONG64_OpSlicemask(v) + case OpSqrt: + v.Op = OpLOONG64SQRTD + return true + case OpSqrt32: + v.Op = OpLOONG64SQRTF + return true + case OpStaticCall: + v.Op = OpLOONG64CALLstatic + return true + case OpStore: + return rewriteValueLOONG64_OpStore(v) + case OpSub16: + v.Op = OpLOONG64SUBV + return true + case OpSub32: + v.Op = OpLOONG64SUBV + return true + case OpSub32F: + v.Op = OpLOONG64SUBF + return true + case OpSub64: + v.Op = OpLOONG64SUBV + return true + case OpSub64F: + v.Op = OpLOONG64SUBD + return true + case OpSub8: + v.Op = OpLOONG64SUBV + return true + case OpSubPtr: + v.Op = OpLOONG64SUBV + return true + case OpTailCall: + v.Op = OpLOONG64CALLtail + return true + case OpTrunc16to8: + v.Op = OpCopy + return true + case OpTrunc32to16: + v.Op = OpCopy + return true + case OpTrunc32to8: + v.Op = OpCopy + return true + case OpTrunc64to16: + v.Op = OpCopy + return true + case OpTrunc64to32: + v.Op = OpCopy + return true + case OpTrunc64to8: + v.Op = OpCopy + return true + case OpWB: + v.Op = OpLOONG64LoweredWB + return true + case OpXor16: + v.Op = OpLOONG64XOR + return true + case OpXor32: + v.Op = OpLOONG64XOR + return true + case OpXor64: + v.Op = OpLOONG64XOR + return true + case OpXor8: + v.Op = OpLOONG64XOR + return true + case OpZero: + return rewriteValueLOONG64_OpZero(v) + case OpZeroExt16to32: + v.Op = OpLOONG64MOVHUreg + return true + case OpZeroExt16to64: + v.Op = OpLOONG64MOVHUreg + return true + case OpZeroExt32to64: + v.Op = OpLOONG64MOVWUreg + return true + case OpZeroExt8to16: + v.Op = OpLOONG64MOVBUreg + return true + case OpZeroExt8to32: + v.Op = OpLOONG64MOVBUreg + return true + case OpZeroExt8to64: + v.Op = OpLOONG64MOVBUreg + return true + } + return false +} +func rewriteValueLOONG64_OpAddr(v *Value) bool { + v_0 := v.Args[0] + // match: (Addr {sym} base) + // result: (MOVVaddr {sym} base) + for { + sym := auxToSym(v.Aux) + base := v_0 + v.reset(OpLOONG64MOVVaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } +} +func rewriteValueLOONG64_OpAtomicAnd8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicAnd8 ptr val mem) + // result: (LoweredAtomicAnd32 (AND (MOVVconst [^3]) ptr) (NORconst [0] (SLLV (XORconst [0xff] (ZeroExt8to32 val)) (SLLVconst [3] (ANDconst [3] ptr)))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpLOONG64LoweredAtomicAnd32) + v0 := b.NewValue0(v.Pos, OpLOONG64AND, typ.Uintptr) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(^3) + v0.AddArg2(v1, ptr) + v2 := b.NewValue0(v.Pos, OpLOONG64NORconst, typ.UInt32) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpLOONG64SLLV, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpLOONG64XORconst, typ.UInt32) + v4.AuxInt = int64ToAuxInt(0xff) + v5 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v5.AddArg(val) + v4.AddArg(v5) + v6 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.UInt64) + v6.AuxInt = int64ToAuxInt(3) + v7 := b.NewValue0(v.Pos, OpLOONG64ANDconst, typ.UInt64) + v7.AuxInt = int64ToAuxInt(3) + v7.AddArg(ptr) + v6.AddArg(v7) + v3.AddArg2(v4, v6) + v2.AddArg(v3) + v.AddArg3(v0, v2, mem) + return true + } +} +func rewriteValueLOONG64_OpAtomicCompareAndSwap32(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicCompareAndSwap32 ptr old new mem) + // result: (LoweredAtomicCas32 ptr (SignExt32to64 old) new mem) + for { + ptr := v_0 + old := v_1 + new := v_2 + mem := v_3 + v.reset(OpLOONG64LoweredAtomicCas32) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(old) + v.AddArg4(ptr, v0, new, mem) + return true + } +} +func rewriteValueLOONG64_OpAtomicCompareAndSwap32Variant(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicCompareAndSwap32Variant ptr old new mem) + // result: (LoweredAtomicCas32Variant ptr (SignExt32to64 old) new mem) + for { + ptr := v_0 + old := v_1 + new := v_2 + mem := v_3 + v.reset(OpLOONG64LoweredAtomicCas32Variant) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(old) + v.AddArg4(ptr, v0, new, mem) + return true + } +} +func rewriteValueLOONG64_OpAtomicOr8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicOr8 ptr val mem) + // result: (LoweredAtomicOr32 (AND (MOVVconst [^3]) ptr) (SLLV (ZeroExt8to32 val) (SLLVconst [3] (ANDconst [3] ptr))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpLOONG64LoweredAtomicOr32) + v0 := b.NewValue0(v.Pos, OpLOONG64AND, typ.Uintptr) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(^3) + v0.AddArg2(v1, ptr) + v2 := b.NewValue0(v.Pos, OpLOONG64SLLV, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v3.AddArg(val) + v4 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(3) + v5 := b.NewValue0(v.Pos, OpLOONG64ANDconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(3) + v5.AddArg(ptr) + v4.AddArg(v5) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v2, mem) + return true + } +} +func rewriteValueLOONG64_OpAvg64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Avg64u x y) + // result: (ADDV (SRLVconst (SUBV x y) [1]) y) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpLOONG64ADDV) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLVconst, t) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64SUBV, t) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueLOONG64_OpBitLen16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen16 x) + // result: (BitLen64 (ZeroExt16to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpBitLen32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (BitLen32 x) + // result: (NEGV (SUBVconst [32] (CLZW x))) + for { + t := v.Type + x := v_0 + v.reset(OpLOONG64NEGV) + v.Type = t + v0 := b.NewValue0(v.Pos, OpLOONG64SUBVconst, t) + v0.AuxInt = int64ToAuxInt(32) + v1 := b.NewValue0(v.Pos, OpLOONG64CLZW, t) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpBitLen64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (BitLen64 x) + // result: (NEGV (SUBVconst [64] (CLZV x))) + for { + t := v.Type + x := v_0 + v.reset(OpLOONG64NEGV) + v.Type = t + v0 := b.NewValue0(v.Pos, OpLOONG64SUBVconst, t) + v0.AuxInt = int64ToAuxInt(64) + v1 := b.NewValue0(v.Pos, OpLOONG64CLZV, t) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpBitLen8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen8 x) + // result: (BitLen64 (ZeroExt8to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpBitRev16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (BitRev16 x) + // result: (REVB2H (BITREV4B x)) + for { + t := v.Type + x := v_0 + v.reset(OpLOONG64REVB2H) + v0 := b.NewValue0(v.Pos, OpLOONG64BITREV4B, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpCom16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com16 x) + // result: (NOR (MOVVconst [0]) x) + for { + x := v_0 + v.reset(OpLOONG64NOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueLOONG64_OpCom32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com32 x) + // result: (NOR (MOVVconst [0]) x) + for { + x := v_0 + v.reset(OpLOONG64NOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueLOONG64_OpCom64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com64 x) + // result: (NOR (MOVVconst [0]) x) + for { + x := v_0 + v.reset(OpLOONG64NOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueLOONG64_OpCom8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com8 x) + // result: (NOR (MOVVconst [0]) x) + for { + x := v_0 + v.reset(OpLOONG64NOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueLOONG64_OpCondSelect(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CondSelect x y cond) + // result: (OR (MASKEQZ x cond) (MASKNEZ y cond)) + for { + t := v.Type + x := v_0 + y := v_1 + cond := v_2 + v.reset(OpLOONG64OR) + v0 := b.NewValue0(v.Pos, OpLOONG64MASKEQZ, t) + v0.AddArg2(x, cond) + v1 := b.NewValue0(v.Pos, OpLOONG64MASKNEZ, t) + v1.AddArg2(y, cond) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpConst16(v *Value) bool { + // match: (Const16 [val]) + // result: (MOVVconst [int64(val)]) + for { + val := auxIntToInt16(v.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueLOONG64_OpConst32(v *Value) bool { + // match: (Const32 [val]) + // result: (MOVVconst [int64(val)]) + for { + val := auxIntToInt32(v.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueLOONG64_OpConst32F(v *Value) bool { + // match: (Const32F [val]) + // result: (MOVFconst [float64(val)]) + for { + val := auxIntToFloat32(v.AuxInt) + v.reset(OpLOONG64MOVFconst) + v.AuxInt = float64ToAuxInt(float64(val)) + return true + } +} +func rewriteValueLOONG64_OpConst64(v *Value) bool { + // match: (Const64 [val]) + // result: (MOVVconst [int64(val)]) + for { + val := auxIntToInt64(v.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueLOONG64_OpConst64F(v *Value) bool { + // match: (Const64F [val]) + // result: (MOVDconst [float64(val)]) + for { + val := auxIntToFloat64(v.AuxInt) + v.reset(OpLOONG64MOVDconst) + v.AuxInt = float64ToAuxInt(float64(val)) + return true + } +} +func rewriteValueLOONG64_OpConst8(v *Value) bool { + // match: (Const8 [val]) + // result: (MOVVconst [int64(val)]) + for { + val := auxIntToInt8(v.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueLOONG64_OpConstBool(v *Value) bool { + // match: (ConstBool [t]) + // result: (MOVVconst [int64(b2i(t))]) + for { + t := auxIntToBool(v.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(b2i(t))) + return true + } +} +func rewriteValueLOONG64_OpConstNil(v *Value) bool { + // match: (ConstNil) + // result: (MOVVconst [0]) + for { + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } +} +func rewriteValueLOONG64_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz16 x) + // result: (CTZV (OR x (MOVVconst [1<<16]))) + for { + x := v_0 + v.reset(OpLOONG64CTZV) + v0 := b.NewValue0(v.Pos, OpLOONG64OR, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1 << 16) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz8 x) + // result: (CTZV (OR x (MOVVconst [1<<8]))) + for { + x := v_0 + v.reset(OpLOONG64CTZV) + v0 := b.NewValue0(v.Pos, OpLOONG64OR, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1 << 8) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 x y) + // result: (DIVV (SignExt16to64 x) (SignExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64DIVV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u x y) + // result: (DIVVU (ZeroExt16to64 x) (ZeroExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64DIVVU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32 x y) + // result: (DIVV (SignExt32to64 x) (SignExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64DIVV) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpDiv32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32u x y) + // result: (DIVVU (ZeroExt32to64 x) (ZeroExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64DIVVU) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpDiv64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Div64 x y) + // result: (DIVV x y) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64DIVV) + v.AddArg2(x, y) + return true + } +} +func rewriteValueLOONG64_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (DIVV (SignExt8to64 x) (SignExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64DIVV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (DIVVU (ZeroExt8to64 x) (ZeroExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64DIVVU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq16 x y) + // result: (SGTU (MOVVconst [1]) (XOR (ZeroExt16to64 x) (ZeroExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq32 x y) + // result: (SGTU (MOVVconst [1]) (XOR (ZeroExt32to64 x) (ZeroExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpEq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32F x y) + // result: (FPFlagTrue (CMPEQF x y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpLOONG64CMPEQF, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpEq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq64 x y) + // result: (SGTU (MOVVconst [1]) (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.UInt64) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpEq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64F x y) + // result: (FPFlagTrue (CMPEQD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpLOONG64CMPEQD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq8 x y) + // result: (SGTU (MOVVconst [1]) (XOR (ZeroExt8to64 x) (ZeroExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqB x y) + // result: (XOR (MOVVconst [1]) (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64XOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.Bool) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqPtr x y) + // result: (SGTU (MOVVconst [1]) (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.UInt64) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpIsInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (IsInBounds idx len) + // result: (SGTU len idx) + for { + idx := v_0 + len := v_1 + v.reset(OpLOONG64SGTU) + v.AddArg2(len, idx) + return true + } +} +func rewriteValueLOONG64_OpIsNonNil(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsNonNil ptr) + // result: (SGTU ptr (MOVVconst [0])) + for { + ptr := v_0 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(ptr, v0) + return true + } +} +func rewriteValueLOONG64_OpIsSliceInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsSliceInBounds idx len) + // result: (XOR (MOVVconst [1]) (SGTU idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpLOONG64XOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v1.AddArg2(idx, len) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLOONG64ADDD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDD (MULD x y) z) + // cond: z.Block.Func.useFMA(v) + // result: (FMADDD x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64MULD { + continue + } + y := v_0.Args[1] + x := v_0.Args[0] + z := v_1 + if !(z.Block.Func.useFMA(v)) { + continue + } + v.reset(OpLOONG64FMADDD) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (ADDD z (NEGD (MULD x y))) + // cond: z.Block.Func.useFMA(v) + // result: (FNMSUBD x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + z := v_0 + if v_1.Op != OpLOONG64NEGD { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64MULD { + continue + } + y := v_1_0.Args[1] + x := v_1_0.Args[0] + if !(z.Block.Func.useFMA(v)) { + continue + } + v.reset(OpLOONG64FNMSUBD) + v.AddArg3(x, y, z) + return true + } + break + } + return false +} +func rewriteValueLOONG64_OpLOONG64ADDF(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDF (MULF x y) z) + // cond: z.Block.Func.useFMA(v) + // result: (FMADDF x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64MULF { + continue + } + y := v_0.Args[1] + x := v_0.Args[0] + z := v_1 + if !(z.Block.Func.useFMA(v)) { + continue + } + v.reset(OpLOONG64FMADDF) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (ADDF z (NEGF (MULF x y))) + // cond: z.Block.Func.useFMA(v) + // result: (FNMSUBF x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + z := v_0 + if v_1.Op != OpLOONG64NEGF { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64MULF { + continue + } + y := v_1_0.Args[1] + x := v_1_0.Args[0] + if !(z.Block.Func.useFMA(v)) { + continue + } + v.reset(OpLOONG64FNMSUBF) + v.AddArg3(x, y, z) + return true + } + break + } + return false +} +func rewriteValueLOONG64_OpLOONG64ADDV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADDV (SRLVconst [8] x) (SLLVconst [8] x)) + // result: (REVB2H x) + for { + if v.Type != typ.UInt16 { + break + } + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLVconst || v_0.Type != typ.UInt16 || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpLOONG64SLLVconst || v_1.Type != typ.UInt16 || auxIntToInt64(v_1.AuxInt) != 8 || x != v_1.Args[0] { + continue + } + v.reset(OpLOONG64REVB2H) + v.AddArg(x) + return true + } + break + } + // match: (ADDV (SRLconst [8] (ANDconst [c1] x)) (SLLconst [8] (ANDconst [c2] x))) + // cond: uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff + // result: (REVB2H x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLconst || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64ANDconst { + continue + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpLOONG64SLLconst || auxIntToInt64(v_1.AuxInt) != 8 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64ANDconst { + continue + } + c2 := auxIntToInt64(v_1_0.AuxInt) + if x != v_1_0.Args[0] || !(uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff) { + continue + } + v.reset(OpLOONG64REVB2H) + v.AddArg(x) + return true + } + break + } + // match: (ADDV (SRLVconst [8] (AND (MOVVconst [c1]) x)) (SLLVconst [8] (AND (MOVVconst [c2]) x))) + // cond: uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff + // result: (REVB4H x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLVconst || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64AND { + continue + } + _ = v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0_0, v_0_0_1 = _i1+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpLOONG64MOVVconst { + continue + } + c1 := auxIntToInt64(v_0_0_0.AuxInt) + x := v_0_0_1 + if v_1.Op != OpLOONG64SLLVconst || auxIntToInt64(v_1.AuxInt) != 8 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64AND { + continue + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0_0, v_1_0_1 = _i2+1, v_1_0_1, v_1_0_0 { + if v_1_0_0.Op != OpLOONG64MOVVconst { + continue + } + c2 := auxIntToInt64(v_1_0_0.AuxInt) + if x != v_1_0_1 || !(uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff) { + continue + } + v.reset(OpLOONG64REVB4H) + v.AddArg(x) + return true + } + } + } + break + } + // match: (ADDV (SRLVconst [8] (AND (MOVVconst [c1]) x)) (SLLVconst [8] (ANDconst [c2] x))) + // cond: uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff + // result: (REVB4H (ANDconst [0xffffffff] x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLVconst || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64AND { + continue + } + _ = v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0_0, v_0_0_1 = _i1+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpLOONG64MOVVconst { + continue + } + c1 := auxIntToInt64(v_0_0_0.AuxInt) + x := v_0_0_1 + if v_1.Op != OpLOONG64SLLVconst || auxIntToInt64(v_1.AuxInt) != 8 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64ANDconst { + continue + } + c2 := auxIntToInt64(v_1_0.AuxInt) + if x != v_1_0.Args[0] || !(uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff) { + continue + } + v.reset(OpLOONG64REVB4H) + v0 := b.NewValue0(v.Pos, OpLOONG64ANDconst, x.Type) + v0.AuxInt = int64ToAuxInt(0xffffffff) + v0.AddArg(x) + v.AddArg(v0) + return true + } + } + break + } + // match: (ADDV x (MOVVconst [c])) + // cond: is32Bit(c) && !t.IsPtr() + // result: (ADDVconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + continue + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c) && !t.IsPtr()) { + continue + } + v.reset(OpLOONG64ADDVconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ADDV x0 x1:(SLLVconst [c] y)) + // cond: x1.Uses == 1 && c > 0 && c <= 4 + // result: (ADDshiftLLV x0 y [c]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x0 := v_0 + x1 := v_1 + if x1.Op != OpLOONG64SLLVconst { + continue + } + c := auxIntToInt64(x1.AuxInt) + y := x1.Args[0] + if !(x1.Uses == 1 && c > 0 && c <= 4) { + continue + } + v.reset(OpLOONG64ADDshiftLLV) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(x0, y) + return true + } + break + } + // match: (ADDV x (NEGV y)) + // result: (SUBV x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpLOONG64NEGV { + continue + } + y := v_1.Args[0] + v.reset(OpLOONG64SUBV) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueLOONG64_OpLOONG64ADDVconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDVconst [off1] (MOVVaddr [off2] {sym} ptr)) + // cond: is32Bit(off1+int64(off2)) + // result: (MOVVaddr [int32(off1)+int32(off2)] {sym} ptr) + for { + off1 := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + if !(is32Bit(off1 + int64(off2))) { + break + } + v.reset(OpLOONG64MOVVaddr) + v.AuxInt = int32ToAuxInt(int32(off1) + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg(ptr) + return true + } + // match: (ADDVconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ADDVconst [c] (MOVVconst [d])) + // result: (MOVVconst [c+d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(c + d) + return true + } + // match: (ADDVconst [c] (ADDVconst [d] x)) + // cond: is32Bit(c+d) + // result: (ADDVconst [c+d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64ADDVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c + d)) { + break + } + v.reset(OpLOONG64ADDVconst) + v.AuxInt = int64ToAuxInt(c + d) + v.AddArg(x) + return true + } + // match: (ADDVconst [c] (SUBVconst [d] x)) + // cond: is32Bit(c-d) + // result: (ADDVconst [c-d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64SUBVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c - d)) { + break + } + v.reset(OpLOONG64ADDVconst) + v.AuxInt = int64ToAuxInt(c - d) + v.AddArg(x) + return true + } + // match: (ADDVconst [c] x) + // cond: is32Bit(c) && c&0xffff == 0 && c != 0 + // result: (ADDV16const [c] x) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if !(is32Bit(c) && c&0xffff == 0 && c != 0) { + break + } + v.reset(OpLOONG64ADDV16const) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64ADDshiftLLV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDshiftLLV x (MOVVconst [c]) [d]) + // cond: is12Bit(c< [shift] idx) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVBUloadidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (MOVBUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(read8(sym, int64(off)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(read8(sym, int64(off)))) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVBUloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBUloadidx ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVBUload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVBUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUloadidx (MOVVconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVBUload [int32(c)] ptr mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVBUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVBUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBUreg (SRLVconst [rc] x)) + // cond: rc < 8 + // result: (BSTRPICKV [rc + (7+rc)<<6] x) + for { + if v_0.Op != OpLOONG64SRLVconst { + break + } + rc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(rc < 8) { + break + } + v.reset(OpLOONG64BSTRPICKV) + v.AuxInt = int64ToAuxInt(rc + (7+rc)<<6) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(SGT _ _)) + // result: x + for { + x := v_0 + if x.Op != OpLOONG64SGT { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(SGTU _ _)) + // result: x + for { + x := v_0 + if x.Op != OpLOONG64SGTU { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(XOR (MOVVconst [1]) (SGT _ _))) + // result: x + for { + x := v_0 + if x.Op != OpLOONG64XOR { + break + } + _ = x.Args[1] + x_0 := x.Args[0] + x_1 := x.Args[1] + for _i0 := 0; _i0 <= 1; _i0, x_0, x_1 = _i0+1, x_1, x_0 { + if x_0.Op != OpLOONG64MOVVconst || auxIntToInt64(x_0.AuxInt) != 1 || x_1.Op != OpLOONG64SGT { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (MOVBUreg x:(XOR (MOVVconst [1]) (SGTU _ _))) + // result: x + for { + x := v_0 + if x.Op != OpLOONG64XOR { + break + } + _ = x.Args[1] + x_0 := x.Args[0] + x_1 := x.Args[1] + for _i0 := 0; _i0 <= 1; _i0, x_0, x_1 = _i0+1, x_1, x_0 { + if x_0.Op != OpLOONG64MOVVconst || auxIntToInt64(x_0.AuxInt) != 1 || x_1.Op != OpLOONG64SGTU { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (MOVBUreg x:(MOVBUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(MOVBUloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(MOVBUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg (SLLVconst [lc] x)) + // cond: lc >= 8 + // result: (MOVVconst [0]) + for { + if v_0.Op != OpLOONG64SLLVconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + if !(lc >= 8) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (MOVBUreg (MOVVconst [c])) + // result: (MOVVconst [int64(uint8(c))]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint8(c))) + return true + } + // match: (MOVBUreg (ANDconst [c] x)) + // result: (ANDconst [c&0xff] x) + for { + if v_0.Op != OpLOONG64ANDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpLOONG64ANDconst) + v.AuxInt = int64ToAuxInt(c & 0xff) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(ANDconst [c] y)) + // cond: c >= 0 && int64(uint8(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpLOONG64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(uint8(c)) == c) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVBload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVBload [off] {sym} ptr (MOVBstore [off] {sym} ptr x _)) + // result: (MOVBreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVBstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpLOONG64MOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVBload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVBload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off] {sym} (ADDV ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVBloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVBloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVBload [off] {sym} (ADDshiftLLV [shift] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVBloadidx ptr (SLLVconst [shift] idx) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVBloadidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (MOVBload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(int8(read8(sym, int64(off))))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int8(read8(sym, int64(off))))) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVBloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBloadidx ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVBload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVBload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBloadidx (MOVVconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVBload [int32(c)] ptr mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVBload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVBreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBreg x:(MOVBload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVBreg (MOVVconst [c])) + // result: (MOVVconst [int64(int8(c))]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int8(c))) + return true + } + // match: (MOVBreg x:(ANDconst [c] y)) + // cond: c >= 0 && int64(int8(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpLOONG64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(int8(c)) == c) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVBstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVBreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVBUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} (ADDV ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVBstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVBstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVBstore [off] {sym} (ADDshiftLLV [shift] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVBstoreidx ptr (SLLVconst [shift] idx) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVBstoreidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg4(ptr, v0, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVBstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstoreidx ptr (MOVVconst [c]) val mem) + // cond: is32Bit(c) + // result: (MOVBstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstoreidx (MOVVconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (MOVBstore [int32(c)] idx val mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVDload [off] {sym} ptr (MOVVstore [off] {sym} ptr val _)) + // result: (MOVVgpfp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVVstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpLOONG64MOVVgpfp) + v.AddArg(val) + return true + } + // match: (MOVDload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVDload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVDload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off] {sym} (ADDV ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVDloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVDloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVDload [off] {sym} (ADDshiftLLV [shift] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVDloadidx ptr (SLLVconst [shift] idx) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVDloadidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVDloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDloadidx ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVDload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVDload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDloadidx (MOVVconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVDload [int32(c)] ptr mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVDload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVDstore [off] {sym} ptr (MOVVgpfp val) mem) + // result: (MOVVstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVVgpfp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVDstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVDstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off] {sym} (ADDV ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVDstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVDstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVDstore [off] {sym} (ADDshiftLLV [shift] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVDstoreidx ptr (SLLVconst [shift] idx) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVDstoreidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg4(ptr, v0, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVDstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDstoreidx ptr (MOVVconst [c]) val mem) + // cond: is32Bit(c) + // result: (MOVDstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVDstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstoreidx (MOVVconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (MOVDstore [int32(c)] idx val mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVDstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVFload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVFload [off] {sym} ptr (MOVWstore [off] {sym} ptr val _)) + // result: (MOVWgpfp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpLOONG64MOVWgpfp) + v.AddArg(val) + return true + } + // match: (MOVFload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVFload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVFload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVFload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVFload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVFload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVFload [off] {sym} (ADDV ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVFloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVFloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVFload [off] {sym} (ADDshiftLLV [shift] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVFloadidx ptr (SLLVconst [shift] idx) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVFloadidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVFloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVFloadidx ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVFload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVFload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVFloadidx (MOVVconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVFload [int32(c)] ptr mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVFload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVFstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVFstore [off] {sym} ptr (MOVWgpfp val) mem) + // result: (MOVWstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWgpfp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVFstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVFstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVFstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVFstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVFstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVFstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVFstore [off] {sym} (ADDV ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVFstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVFstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVFstore [off] {sym} (ADDshiftLLV [shift] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVFstoreidx ptr (SLLVconst [shift] idx) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVFstoreidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg4(ptr, v0, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVFstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVFstoreidx ptr (MOVVconst [c]) val mem) + // cond: is32Bit(c) + // result: (MOVFstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVFstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVFstoreidx (MOVVconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (MOVFstore [int32(c)] idx val mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVFstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVHUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVHUload [off] {sym} ptr (MOVHstore [off] {sym} ptr x _)) + // result: (MOVHUreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVHstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpLOONG64MOVHUreg) + v.AddArg(x) + return true + } + // match: (MOVHUload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHUload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVHUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVHUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off] {sym} (ADDV ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVHUloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVHUloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHUload [off] {sym} (ADDshiftLLV [shift] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVHUloadidx ptr (SLLVconst [shift] idx) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVHUloadidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (MOVHUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVHUloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHUloadidx ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVHUload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVHUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUloadidx (MOVVconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVHUload [int32(c)] ptr mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVHUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVHUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVHUreg (SRLVconst [rc] x)) + // cond: rc < 16 + // result: (BSTRPICKV [rc + (15+rc)<<6] x) + for { + if v_0.Op != OpLOONG64SRLVconst { + break + } + rc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(rc < 16) { + break + } + v.reset(OpLOONG64BSTRPICKV) + v.AuxInt = int64ToAuxInt(rc + (15+rc)<<6) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVBUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHUload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVBUloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHUloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVBUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHUreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg (SLLVconst [lc] x)) + // cond: lc >= 16 + // result: (MOVVconst [0]) + for { + if v_0.Op != OpLOONG64SLLVconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + if !(lc >= 16) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (MOVHUreg (MOVVconst [c])) + // result: (MOVVconst [int64(uint16(c))]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint16(c))) + return true + } + // match: (MOVHUreg x:(ANDconst [c] y)) + // cond: c >= 0 && int64(uint16(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpLOONG64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(uint16(c)) == c) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVHload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVHload [off] {sym} ptr (MOVHstore [off] {sym} ptr x _)) + // result: (MOVHreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVHstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpLOONG64MOVHreg) + v.AddArg(x) + return true + } + // match: (MOVHload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVHload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVHload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off] {sym} (ADDV ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVHloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVHloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVHload [off] {sym} (ADDshiftLLV [shift] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVHloadidx ptr (SLLVconst [shift] idx) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVHloadidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (MOVHload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVHloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHloadidx ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVHload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVHload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHloadidx (MOVVconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVHload [int32(c)] ptr mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVHload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVHreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVHreg x:(MOVBload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg (MOVVconst [c])) + // result: (MOVVconst [int64(int16(c))]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int16(c))) + return true + } + // match: (MOVHreg x:(ANDconst [c] y)) + // cond: c >= 0 && int64(int16(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpLOONG64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(int16(c)) == c) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVHstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVHstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} (ADDV ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVHstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVHstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVHstore [off] {sym} (ADDshiftLLV [shift] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVHstoreidx ptr (SLLVconst [shift] idx) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVHstoreidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg4(ptr, v0, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVHstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstoreidx ptr (MOVVconst [c]) val mem) + // cond: is32Bit(c) + // result: (MOVHstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstoreidx (MOVVconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (MOVHstore [int32(c)] idx val mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVVload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVVload [off] {sym} ptr (MOVDstore [off] {sym} ptr val _)) + // result: (MOVVfpgp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpLOONG64MOVVfpgp) + v.AddArg(val) + return true + } + // match: (MOVVload [off] {sym} ptr (MOVVstore [off] {sym} ptr x _)) + // result: (MOVVreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVVstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVVload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVVload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVVload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVVload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVVload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVVload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVVload [off] {sym} (ADDV ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVVloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVVloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVVload [off] {sym} (ADDshiftLLV [shift] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVVloadidx ptr (SLLVconst [shift] idx) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVVloadidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (MOVVload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVVloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVVloadidx ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVVload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVVload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVVloadidx (MOVVconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVVload [int32(c)] ptr mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVVload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVVnop(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVVnop (MOVVconst [c])) + // result: (MOVVconst [c]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(c) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVVreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVVreg x) + // cond: x.Uses == 1 + // result: (MOVVnop x) + for { + x := v_0 + if !(x.Uses == 1) { + break + } + v.reset(OpLOONG64MOVVnop) + v.AddArg(x) + return true + } + // match: (MOVVreg (MOVVconst [c])) + // result: (MOVVconst [c]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(c) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVVstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVVstore [off] {sym} ptr (MOVVfpgp val) mem) + // result: (MOVDstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVVfpgp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVDstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVVstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVVstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVVstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVVstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVVstore [off] {sym} (ADDV ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVVstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVVstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVVstore [off] {sym} (ADDshiftLLV [shift] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVVstoreidx ptr (SLLVconst [shift] idx) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVVstoreidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg4(ptr, v0, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVVstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVVstoreidx ptr (MOVVconst [c]) val mem) + // cond: is32Bit(c) + // result: (MOVVstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVVstoreidx (MOVVconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (MOVVstore [int32(c)] idx val mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVWUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVWUload [off] {sym} ptr (MOVFstore [off] {sym} ptr val _)) + // result: (ZeroExt32to64 (MOVWfpgp val)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVFstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpZeroExt32to64) + v0 := b.NewValue0(v_1.Pos, OpLOONG64MOVWfpgp, typ.Float32) + v0.AddArg(val) + v.AddArg(v0) + return true + } + // match: (MOVWUload [off] {sym} ptr (MOVWstore [off] {sym} ptr x _)) + // result: (MOVWUreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpLOONG64MOVWUreg) + v.AddArg(x) + return true + } + // match: (MOVWUload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWUload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVWUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVWUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWUload [off] {sym} (ADDV ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVWUloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVWUloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWUload [off] {sym} (ADDshiftLLV [shift] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVWUloadidx ptr (SLLVconst [shift] idx) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVWUloadidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (MOVWUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVWUloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWUloadidx ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVWUload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVWUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWUloadidx (MOVVconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVWUload [int32(c)] ptr mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVWUload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVWUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWUreg (SRLVconst [rc] x)) + // cond: rc < 32 + // result: (BSTRPICKV [rc + (31+rc)<<6] x) + for { + if v_0.Op != OpLOONG64SRLVconst { + break + } + rc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(rc < 32) { + break + } + v.reset(OpLOONG64BSTRPICKV) + v.AuxInt = int64ToAuxInt(rc + (31+rc)<<6) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVBUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHUload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVWUload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVBUloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHUloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVWUloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVBUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHUreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVWUreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg (SLLVconst [lc] x)) + // cond: lc >= 32 + // result: (MOVVconst [0]) + for { + if v_0.Op != OpLOONG64SLLVconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + if !(lc >= 32) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (MOVWUreg (MOVVconst [c])) + // result: (MOVVconst [int64(uint32(c))]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint32(c))) + return true + } + // match: (MOVWUreg x:(ANDconst [c] y)) + // cond: c >= 0 && int64(uint32(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpLOONG64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(uint32(c)) == c) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVWload [off] {sym} ptr (MOVWstore [off] {sym} ptr x _)) + // result: (MOVWreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpLOONG64MOVWreg) + v.AddArg(x) + return true + } + // match: (MOVWload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off] {sym} (ADDV ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVWloadidx ptr idx mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVWloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + // match: (MOVWload [off] {sym} (ADDshiftLLV [shift] ptr idx) mem) + // cond: off == 0 && sym == nil + // result: (MOVWloadidx ptr (SLLVconst [shift] idx) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + mem := v_1 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVWloadidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (MOVWload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVWloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWloadidx ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (MOVWload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVWload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWloadidx (MOVVconst [c]) ptr mem) + // cond: is32Bit(c) + // result: (MOVWload [int32(c)] ptr mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVWload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVWreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWreg x:(MOVBload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHUload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVWload { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBUloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHUloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHUloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWloadidx _ _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVWloadidx { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVBUreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVHreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpLOONG64MOVWreg { + break + } + v.reset(OpLOONG64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg (MOVVconst [c])) + // result: (MOVVconst [int64(int32(c))]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int32(c))) + return true + } + // match: (MOVWreg x:(ANDconst [c] y)) + // cond: c >= 0 && int64(int32(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpLOONG64ANDconst { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(int32(c)) == c) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVWstore [off] {sym} ptr (MOVWfpgp val) mem) + // result: (MOVFstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWfpgp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVFstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpLOONG64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpLOONG64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off] {sym} (ADDV ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVWstoreidx ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDV { + break + } + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVWstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstore [off] {sym} (ADDshiftLLV [shift] ptr idx) val mem) + // cond: off == 0 && sym == nil + // result: (MOVWstoreidx ptr (SLLVconst [shift] idx) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpLOONG64ADDshiftLLV { + break + } + shift := auxIntToInt64(v_0.AuxInt) + idx := v_0.Args[1] + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(off == 0 && sym == nil) { + break + } + v.reset(OpLOONG64MOVWstoreidx) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(shift) + v0.AddArg(idx) + v.AddArg4(ptr, v0, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MOVWstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstoreidx ptr (MOVVconst [c]) val mem) + // cond: is32Bit(c) + // result: (MOVWstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstoreidx (MOVVconst [c]) idx val mem) + // cond: is32Bit(c) + // result: (MOVWstore [int32(c)] idx val mem) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + idx := v_1 + val := v_2 + mem := v_3 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(idx, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64MULV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MULV r:(MOVWUreg x) s:(MOVWUreg y)) + // cond: r.Uses == 1 && s.Uses == 1 + // result: (MULWVWU x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + r := v_0 + if r.Op != OpLOONG64MOVWUreg { + continue + } + x := r.Args[0] + s := v_1 + if s.Op != OpLOONG64MOVWUreg { + continue + } + y := s.Args[0] + if !(r.Uses == 1 && s.Uses == 1) { + continue + } + v.reset(OpLOONG64MULWVWU) + v.AddArg2(x, y) + return true + } + break + } + // match: (MULV r:(MOVWreg x) s:(MOVWreg y)) + // cond: r.Uses == 1 && s.Uses == 1 + // result: (MULWVW x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + r := v_0 + if r.Op != OpLOONG64MOVWreg { + continue + } + x := r.Args[0] + s := v_1 + if s.Op != OpLOONG64MOVWreg { + continue + } + y := s.Args[0] + if !(r.Uses == 1 && s.Uses == 1) { + continue + } + v.reset(OpLOONG64MULWVW) + v.AddArg2(x, y) + return true + } + break + } + // match: (MULV _ (MOVVconst [0])) + // result: (MOVVconst [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_1.AuxInt) != 0 { + continue + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (MULV x (MOVVconst [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (MULV x (MOVVconst [c])) + // cond: canMulStrengthReduce(config, c) + // result: {mulStrengthReduce(v, x, c)} + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(canMulStrengthReduce(config, c)) { + continue + } + v.copyOf(mulStrengthReduce(v, x, c)) + return true + } + break + } + // match: (MULV (MOVVconst [c]) (MOVVconst [d])) + // result: (MOVVconst [c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64MOVVconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpLOONG64MOVVconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(c * d) + return true + } + break + } + return false +} +func rewriteValueLOONG64_OpLOONG64NEGV(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (NEGV (SUBV x y)) + // result: (SUBV y x) + for { + if v_0.Op != OpLOONG64SUBV { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLOONG64SUBV) + v.AddArg2(y, x) + return true + } + // match: (NEGV s:(ADDVconst [c] (SUBV x y))) + // cond: s.Uses == 1 && is12Bit(-c) + // result: (ADDVconst [-c] (SUBV y x)) + for { + t := v.Type + s := v_0 + if s.Op != OpLOONG64ADDVconst { + break + } + c := auxIntToInt64(s.AuxInt) + s_0 := s.Args[0] + if s_0.Op != OpLOONG64SUBV { + break + } + y := s_0.Args[1] + x := s_0.Args[0] + if !(s.Uses == 1 && is12Bit(-c)) { + break + } + v.reset(OpLOONG64ADDVconst) + v.AuxInt = int64ToAuxInt(-c) + v0 := b.NewValue0(v.Pos, OpLOONG64SUBV, t) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + // match: (NEGV (NEGV x)) + // result: x + for { + if v_0.Op != OpLOONG64NEGV { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (NEGV s:(ADDVconst [c] (NEGV x))) + // cond: s.Uses == 1 && is12Bit(-c) + // result: (ADDVconst [-c] x) + for { + s := v_0 + if s.Op != OpLOONG64ADDVconst { + break + } + c := auxIntToInt64(s.AuxInt) + s_0 := s.Args[0] + if s_0.Op != OpLOONG64NEGV { + break + } + x := s_0.Args[0] + if !(s.Uses == 1 && is12Bit(-c)) { + break + } + v.reset(OpLOONG64ADDVconst) + v.AuxInt = int64ToAuxInt(-c) + v.AddArg(x) + return true + } + // match: (NEGV (MOVVconst [c])) + // result: (MOVVconst [-c]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(-c) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64NOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NOR x (MOVVconst [c])) + // cond: is32Bit(c) + // result: (NORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpLOONG64NORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueLOONG64_OpLOONG64NORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (NORconst [c] (MOVVconst [d])) + // result: (MOVVconst [^(c|d)]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(^(c | d)) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64OR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (OR (SRLVconst [8] x) (SLLVconst [8] x)) + // result: (REVB2H x) + for { + if v.Type != typ.UInt16 { + break + } + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLVconst || v_0.Type != typ.UInt16 || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpLOONG64SLLVconst || v_1.Type != typ.UInt16 || auxIntToInt64(v_1.AuxInt) != 8 || x != v_1.Args[0] { + continue + } + v.reset(OpLOONG64REVB2H) + v.AddArg(x) + return true + } + break + } + // match: (OR (SRLconst [8] (ANDconst [c1] x)) (SLLconst [8] (ANDconst [c2] x))) + // cond: uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff + // result: (REVB2H x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLconst || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64ANDconst { + continue + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpLOONG64SLLconst || auxIntToInt64(v_1.AuxInt) != 8 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64ANDconst { + continue + } + c2 := auxIntToInt64(v_1_0.AuxInt) + if x != v_1_0.Args[0] || !(uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff) { + continue + } + v.reset(OpLOONG64REVB2H) + v.AddArg(x) + return true + } + break + } + // match: (OR (SRLVconst [8] (AND (MOVVconst [c1]) x)) (SLLVconst [8] (AND (MOVVconst [c2]) x))) + // cond: uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff + // result: (REVB4H x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLVconst || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64AND { + continue + } + _ = v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0_0, v_0_0_1 = _i1+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpLOONG64MOVVconst { + continue + } + c1 := auxIntToInt64(v_0_0_0.AuxInt) + x := v_0_0_1 + if v_1.Op != OpLOONG64SLLVconst || auxIntToInt64(v_1.AuxInt) != 8 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64AND { + continue + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0_0, v_1_0_1 = _i2+1, v_1_0_1, v_1_0_0 { + if v_1_0_0.Op != OpLOONG64MOVVconst { + continue + } + c2 := auxIntToInt64(v_1_0_0.AuxInt) + if x != v_1_0_1 || !(uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff) { + continue + } + v.reset(OpLOONG64REVB4H) + v.AddArg(x) + return true + } + } + } + break + } + // match: (OR (SRLVconst [8] (AND (MOVVconst [c1]) x)) (SLLVconst [8] (ANDconst [c2] x))) + // cond: uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff + // result: (REVB4H (ANDconst [0xffffffff] x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLVconst || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64AND { + continue + } + _ = v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0_0, v_0_0_1 = _i1+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpLOONG64MOVVconst { + continue + } + c1 := auxIntToInt64(v_0_0_0.AuxInt) + x := v_0_0_1 + if v_1.Op != OpLOONG64SLLVconst || auxIntToInt64(v_1.AuxInt) != 8 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64ANDconst { + continue + } + c2 := auxIntToInt64(v_1_0.AuxInt) + if x != v_1_0.Args[0] || !(uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff) { + continue + } + v.reset(OpLOONG64REVB4H) + v0 := b.NewValue0(v.Pos, OpLOONG64ANDconst, x.Type) + v0.AuxInt = int64ToAuxInt(0xffffffff) + v0.AddArg(x) + v.AddArg(v0) + return true + } + } + break + } + // match: (OR x (MOVVconst [c])) + // cond: is32Bit(c) + // result: (ORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpLOONG64ORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (OR x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (OR x (NORconst [0] y)) + // result: (ORN x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpLOONG64NORconst || auxIntToInt64(v_1.AuxInt) != 0 { + continue + } + y := v_1.Args[0] + v.reset(OpLOONG64ORN) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueLOONG64_OpLOONG64ORN(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORN x (MOVVconst [-1])) + // result: x + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_1.AuxInt) != -1 { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64ORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ORconst [-1] _) + // result: (MOVVconst [-1]) + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (ORconst [c] (MOVVconst [d])) + // result: (MOVVconst [c|d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(c | d) + return true + } + // match: (ORconst [c] (ORconst [d] x)) + // cond: is32Bit(c|d) + // result: (ORconst [c|d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64ORconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c | d)) { + break + } + v.reset(OpLOONG64ORconst) + v.AuxInt = int64ToAuxInt(c | d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64REMV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (REMV (MOVVconst [c]) (MOVVconst [d])) + // cond: d != 0 + // result: (MOVVconst [c%d]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(c % d) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64REMVU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (REMVU _ (MOVVconst [1])) + // result: (MOVVconst [0]) + for { + if v_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (REMVU x (MOVVconst [c])) + // cond: isPowerOfTwo(c) + // result: (ANDconst [c-1] x) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpLOONG64ANDconst) + v.AuxInt = int64ToAuxInt(c - 1) + v.AddArg(x) + return true + } + // match: (REMVU (MOVVconst [c]) (MOVVconst [d])) + // cond: d != 0 + // result: (MOVVconst [int64(uint64(c)%uint64(d))]) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) % uint64(d))) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64ROTR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROTR x (MOVVconst [c])) + // result: (ROTRconst x [c&31]) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpLOONG64ROTRconst) + v.AuxInt = int64ToAuxInt(c & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64ROTRV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROTRV x (MOVVconst [c])) + // result: (ROTRVconst x [c&63]) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpLOONG64ROTRVconst) + v.AuxInt = int64ToAuxInt(c & 63) + v.AddArg(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SGT(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SGT (MOVVconst [c]) (NEGV (SUBVconst [d] x))) + // cond: is32Bit(d-c) + // result: (SGT x (MOVVconst [d-c])) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpLOONG64NEGV { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64SUBVconst { + break + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_0.Args[0] + if !(is32Bit(d - c)) { + break + } + v.reset(OpLOONG64SGT) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(d - c) + v.AddArg2(x, v0) + return true + } + // match: (SGT (MOVVconst [c]) x) + // cond: is32Bit(c) + // result: (SGTconst [c] x) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64SGTconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SGT x x) + // result: (MOVVconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SGTU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SGTU (MOVVconst [c]) x) + // cond: is32Bit(c) + // result: (SGTUconst [c] x) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64SGTUconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SGTU x x) + // result: (MOVVconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SGTUconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SGTUconst [c] (MOVVconst [d])) + // cond: uint64(c)>uint64(d) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(uint64(c) > uint64(d)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (MOVVconst [d])) + // cond: uint64(c)<=uint64(d) + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(uint64(c) <= uint64(d)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTUconst [c] (MOVBUreg _)) + // cond: 0xff < uint64(c) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVBUreg || !(0xff < uint64(c)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (MOVHUreg _)) + // cond: 0xffff < uint64(c) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVHUreg || !(0xffff < uint64(c)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (ANDconst [m] _)) + // cond: uint64(m) < uint64(c) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64ANDconst { + break + } + m := auxIntToInt64(v_0.AuxInt) + if !(uint64(m) < uint64(c)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (SRLVconst _ [d])) + // cond: 0 < d && d <= 63 && 0xffffffffffffffff>>uint64(d) < uint64(c) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64SRLVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(0 < d && d <= 63 && 0xffffffffffffffff>>uint64(d) < uint64(c)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SGTconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SGTconst [c] (MOVVconst [d])) + // cond: c>d + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(c > d) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVVconst [d])) + // cond: c<=d + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(c <= d) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVBreg _)) + // cond: 0x7f < c + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVBreg || !(0x7f < c) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVBreg _)) + // cond: c <= -0x80 + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVBreg || !(c <= -0x80) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVBUreg _)) + // cond: 0xff < c + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVBUreg || !(0xff < c) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVBUreg _)) + // cond: c < 0 + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVBUreg || !(c < 0) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVHreg _)) + // cond: 0x7fff < c + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVHreg || !(0x7fff < c) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVHreg _)) + // cond: c <= -0x8000 + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVHreg || !(c <= -0x8000) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVHUreg _)) + // cond: 0xffff < c + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVHUreg || !(0xffff < c) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVHUreg _)) + // cond: c < 0 + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVHUreg || !(c < 0) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVWUreg _)) + // cond: c < 0 + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVWUreg || !(c < 0) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (ANDconst [m] _)) + // cond: 0 <= m && m < c + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64ANDconst { + break + } + m := auxIntToInt64(v_0.AuxInt) + if !(0 <= m && m < c) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (SRLVconst _ [d])) + // cond: 0 <= c && 0 < d && d <= 63 && 0xffffffffffffffff>>uint64(d) < uint64(c) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64SRLVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(0 <= c && 0 < d && d <= 63 && 0xffffffffffffffff>>uint64(d) < uint64(c)) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLL _ (MOVVconst [c])) + // cond: uint64(c)>=32 + // result: (MOVVconst [0]) + for { + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SLL x (MOVVconst [c])) + // cond: uint64(c) >=0 && uint64(c) <=31 + // result: (SLLconst x [c]) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 0 && uint64(c) <= 31) { + break + } + v.reset(OpLOONG64SLLconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SLL x (ANDconst [31] y)) + // result: (SLL x y) + for { + x := v_0 + if v_1.Op != OpLOONG64ANDconst || auxIntToInt64(v_1.AuxInt) != 31 { + break + } + y := v_1.Args[0] + v.reset(OpLOONG64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SLLV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLLV _ (MOVVconst [c])) + // cond: uint64(c)>=64 + // result: (MOVVconst [0]) + for { + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SLLV x (MOVVconst [c])) + // result: (SLLVconst x [c]) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpLOONG64SLLVconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SLLV x (ANDconst [63] y)) + // result: (SLLV x y) + for { + x := v_0 + if v_1.Op != OpLOONG64ANDconst || auxIntToInt64(v_1.AuxInt) != 63 { + break + } + y := v_1.Args[0] + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SLLVconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLLVconst [c] (ADDV x x)) + // cond: c < t.Size() * 8 - 1 + // result: (SLLVconst [c+1] x) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64ADDV { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || !(c < t.Size()*8-1) { + break + } + v.reset(OpLOONG64SLLVconst) + v.AuxInt = int64ToAuxInt(c + 1) + v.AddArg(x) + return true + } + // match: (SLLVconst [c] (ADDV x x)) + // cond: c >= t.Size() * 8 - 1 + // result: (MOVVconst [0]) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64ADDV { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || !(c >= t.Size()*8-1) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SLLVconst [c] (MOVVconst [d])) + // result: (MOVVconst [d< [c] (ADDV x x)) + // cond: c < t.Size() * 8 - 1 + // result: (SLLconst [c+1] x) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64ADDV { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || !(c < t.Size()*8-1) { + break + } + v.reset(OpLOONG64SLLconst) + v.AuxInt = int64ToAuxInt(c + 1) + v.AddArg(x) + return true + } + // match: (SLLconst [c] (ADDV x x)) + // cond: c >= t.Size() * 8 - 1 + // result: (MOVVconst [0]) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64ADDV { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || !(c >= t.Size()*8-1) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRA x (MOVVconst [c])) + // cond: uint64(c)>=32 + // result: (SRAconst x [31]) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpLOONG64SRAconst) + v.AuxInt = int64ToAuxInt(31) + v.AddArg(x) + return true + } + // match: (SRA x (MOVVconst [c])) + // cond: uint64(c) >=0 && uint64(c) <=31 + // result: (SRAconst x [c]) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 0 && uint64(c) <= 31) { + break + } + v.reset(OpLOONG64SRAconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SRA x (ANDconst [31] y)) + // result: (SRA x y) + for { + x := v_0 + if v_1.Op != OpLOONG64ANDconst || auxIntToInt64(v_1.AuxInt) != 31 { + break + } + y := v_1.Args[0] + v.reset(OpLOONG64SRA) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SRAV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRAV x (MOVVconst [c])) + // cond: uint64(c)>=64 + // result: (SRAVconst x [63]) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpLOONG64SRAVconst) + v.AuxInt = int64ToAuxInt(63) + v.AddArg(x) + return true + } + // match: (SRAV x (MOVVconst [c])) + // result: (SRAVconst x [c]) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpLOONG64SRAVconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SRAV x (ANDconst [63] y)) + // result: (SRAV x y) + for { + x := v_0 + if v_1.Op != OpLOONG64ANDconst || auxIntToInt64(v_1.AuxInt) != 63 { + break + } + y := v_1.Args[0] + v.reset(OpLOONG64SRAV) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SRAVconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (SRAVconst [rc] (MOVWreg y)) + // cond: rc >= 0 && rc <= 31 + // result: (SRAconst [int64(rc)] y) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVWreg { + break + } + y := v_0.Args[0] + if !(rc >= 0 && rc <= 31) { + break + } + v.reset(OpLOONG64SRAconst) + v.AuxInt = int64ToAuxInt(int64(rc)) + v.AddArg(y) + return true + } + // match: (SRAVconst [rc] (MOVBreg y)) + // cond: rc >= 8 + // result: (SRAVconst [63] (SLLVconst [56] y)) + for { + t := v.Type + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVBreg { + break + } + y := v_0.Args[0] + if !(rc >= 8) { + break + } + v.reset(OpLOONG64SRAVconst) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, t) + v0.AuxInt = int64ToAuxInt(56) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (SRAVconst [rc] (MOVHreg y)) + // cond: rc >= 16 + // result: (SRAVconst [63] (SLLVconst [48] y)) + for { + t := v.Type + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVHreg { + break + } + y := v_0.Args[0] + if !(rc >= 16) { + break + } + v.reset(OpLOONG64SRAVconst) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, t) + v0.AuxInt = int64ToAuxInt(48) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (SRAVconst [rc] (MOVWreg y)) + // cond: rc >= 32 + // result: (SRAconst [31] y) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVWreg { + break + } + y := v_0.Args[0] + if !(rc >= 32) { + break + } + v.reset(OpLOONG64SRAconst) + v.AuxInt = int64ToAuxInt(31) + v.AddArg(y) + return true + } + // match: (SRAVconst [c] (MOVVconst [d])) + // result: (MOVVconst [d>>uint64(c)]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(d >> uint64(c)) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRL _ (MOVVconst [c])) + // cond: uint64(c)>=32 + // result: (MOVVconst [0]) + for { + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRL x (MOVVconst [c])) + // cond: uint64(c) >=0 && uint64(c) <=31 + // result: (SRLconst x [c]) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 0 && uint64(c) <= 31) { + break + } + v.reset(OpLOONG64SRLconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SRL x (ANDconst [31] y)) + // result: (SRL x y) + for { + x := v_0 + if v_1.Op != OpLOONG64ANDconst || auxIntToInt64(v_1.AuxInt) != 31 { + break + } + y := v_1.Args[0] + v.reset(OpLOONG64SRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SRLV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRLV _ (MOVVconst [c])) + // cond: uint64(c)>=64 + // result: (MOVVconst [0]) + for { + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLV x (MOVVconst [c])) + // result: (SRLVconst x [c]) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpLOONG64SRLVconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SRLV x (ANDconst [63] y)) + // result: (SRLV x y) + for { + x := v_0 + if v_1.Op != OpLOONG64ANDconst || auxIntToInt64(v_1.AuxInt) != 63 { + break + } + y := v_1.Args[0] + v.reset(OpLOONG64SRLV) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SRLVconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRLVconst [rc] (SLLVconst [lc] x)) + // cond: lc <= rc + // result: (BSTRPICKV [rc-lc + ((64-lc)-1)<<6] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64SLLVconst { + break + } + lc := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(lc <= rc) { + break + } + v.reset(OpLOONG64BSTRPICKV) + v.AuxInt = int64ToAuxInt(rc - lc + ((64-lc)-1)<<6) + v.AddArg(x) + return true + } + // match: (SRLVconst [rc] (MOVWUreg x)) + // cond: rc < 32 + // result: (BSTRPICKV [rc + 31<<6] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVWUreg { + break + } + x := v_0.Args[0] + if !(rc < 32) { + break + } + v.reset(OpLOONG64BSTRPICKV) + v.AuxInt = int64ToAuxInt(rc + 31<<6) + v.AddArg(x) + return true + } + // match: (SRLVconst [rc] (MOVHUreg x)) + // cond: rc < 16 + // result: (BSTRPICKV [rc + 15<<6] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVHUreg { + break + } + x := v_0.Args[0] + if !(rc < 16) { + break + } + v.reset(OpLOONG64BSTRPICKV) + v.AuxInt = int64ToAuxInt(rc + 15<<6) + v.AddArg(x) + return true + } + // match: (SRLVconst [rc] (MOVBUreg x)) + // cond: rc < 8 + // result: (BSTRPICKV [rc + 7<<6] x) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVBUreg { + break + } + x := v_0.Args[0] + if !(rc < 8) { + break + } + v.reset(OpLOONG64BSTRPICKV) + v.AuxInt = int64ToAuxInt(rc + 7<<6) + v.AddArg(x) + return true + } + // match: (SRLVconst [rc] (MOVWUreg y)) + // cond: rc >= 0 && rc <= 31 + // result: (SRLconst [int64(rc)] y) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVWUreg { + break + } + y := v_0.Args[0] + if !(rc >= 0 && rc <= 31) { + break + } + v.reset(OpLOONG64SRLconst) + v.AuxInt = int64ToAuxInt(int64(rc)) + v.AddArg(y) + return true + } + // match: (SRLVconst [rc] (MOVWUreg x)) + // cond: rc >= 32 + // result: (MOVVconst [0]) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVWUreg { + break + } + if !(rc >= 32) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLVconst [rc] (MOVHUreg x)) + // cond: rc >= 16 + // result: (MOVVconst [0]) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVHUreg { + break + } + if !(rc >= 16) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLVconst [rc] (MOVBUreg x)) + // cond: rc >= 8 + // result: (MOVVconst [0]) + for { + rc := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVBUreg { + break + } + if !(rc >= 8) { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLVconst [c] (MOVVconst [d])) + // result: (MOVVconst [int64(uint64(d)>>uint64(c))]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint64(d) >> uint64(c))) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SUBD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBD (MULD x y) z) + // cond: z.Block.Func.useFMA(v) + // result: (FMSUBD x y z) + for { + if v_0.Op != OpLOONG64MULD { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + z := v_1 + if !(z.Block.Func.useFMA(v)) { + break + } + v.reset(OpLOONG64FMSUBD) + v.AddArg3(x, y, z) + return true + } + // match: (SUBD z (MULD x y)) + // cond: z.Block.Func.useFMA(v) + // result: (FNMSUBD x y z) + for { + z := v_0 + if v_1.Op != OpLOONG64MULD { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(z.Block.Func.useFMA(v)) { + break + } + v.reset(OpLOONG64FNMSUBD) + v.AddArg3(x, y, z) + return true + } + // match: (SUBD z (NEGD (MULD x y))) + // cond: z.Block.Func.useFMA(v) + // result: (FMADDD x y z) + for { + z := v_0 + if v_1.Op != OpLOONG64NEGD { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64MULD { + break + } + y := v_1_0.Args[1] + x := v_1_0.Args[0] + if !(z.Block.Func.useFMA(v)) { + break + } + v.reset(OpLOONG64FMADDD) + v.AddArg3(x, y, z) + return true + } + // match: (SUBD (NEGD (MULD x y)) z) + // cond: z.Block.Func.useFMA(v) + // result: (FNMADDD x y z) + for { + if v_0.Op != OpLOONG64NEGD { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64MULD { + break + } + y := v_0_0.Args[1] + x := v_0_0.Args[0] + z := v_1 + if !(z.Block.Func.useFMA(v)) { + break + } + v.reset(OpLOONG64FNMADDD) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SUBF(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBF (MULF x y) z) + // cond: z.Block.Func.useFMA(v) + // result: (FMSUBF x y z) + for { + if v_0.Op != OpLOONG64MULF { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + z := v_1 + if !(z.Block.Func.useFMA(v)) { + break + } + v.reset(OpLOONG64FMSUBF) + v.AddArg3(x, y, z) + return true + } + // match: (SUBF z (MULF x y)) + // cond: z.Block.Func.useFMA(v) + // result: (FNMSUBF x y z) + for { + z := v_0 + if v_1.Op != OpLOONG64MULF { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(z.Block.Func.useFMA(v)) { + break + } + v.reset(OpLOONG64FNMSUBF) + v.AddArg3(x, y, z) + return true + } + // match: (SUBF z (NEGF (MULF x y))) + // cond: z.Block.Func.useFMA(v) + // result: (FMADDF x y z) + for { + z := v_0 + if v_1.Op != OpLOONG64NEGF { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64MULF { + break + } + y := v_1_0.Args[1] + x := v_1_0.Args[0] + if !(z.Block.Func.useFMA(v)) { + break + } + v.reset(OpLOONG64FMADDF) + v.AddArg3(x, y, z) + return true + } + // match: (SUBF (NEGF (MULF x y)) z) + // cond: z.Block.Func.useFMA(v) + // result: (FNMADDF x y z) + for { + if v_0.Op != OpLOONG64NEGF { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64MULF { + break + } + y := v_0_0.Args[1] + x := v_0_0.Args[0] + z := v_1 + if !(z.Block.Func.useFMA(v)) { + break + } + v.reset(OpLOONG64FNMADDF) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SUBV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBV x (MOVVconst [c])) + // cond: is32Bit(c) + // result: (SUBVconst [c] x) + for { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + break + } + v.reset(OpLOONG64SUBVconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SUBV x (NEGV y)) + // result: (ADDV x y) + for { + x := v_0 + if v_1.Op != OpLOONG64NEGV { + break + } + y := v_1.Args[0] + v.reset(OpLOONG64ADDV) + v.AddArg2(x, y) + return true + } + // match: (SUBV x x) + // result: (MOVVconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SUBV (MOVVconst [0]) x) + // result: (NEGV x) + for { + if v_0.Op != OpLOONG64MOVVconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpLOONG64NEGV) + v.AddArg(x) + return true + } + // match: (SUBV (MOVVconst [c]) (NEGV (SUBVconst [d] x))) + // result: (ADDVconst [c-d] x) + for { + if v_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpLOONG64NEGV { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64SUBVconst { + break + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_0.Args[0] + v.reset(OpLOONG64ADDVconst) + v.AuxInt = int64ToAuxInt(c - d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64SUBVconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBVconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SUBVconst [c] (MOVVconst [d])) + // result: (MOVVconst [d-c]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(d - c) + return true + } + // match: (SUBVconst [c] (SUBVconst [d] x)) + // cond: is32Bit(-c-d) + // result: (ADDVconst [-c-d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64SUBVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(-c - d)) { + break + } + v.reset(OpLOONG64ADDVconst) + v.AuxInt = int64ToAuxInt(-c - d) + v.AddArg(x) + return true + } + // match: (SUBVconst [c] (ADDVconst [d] x)) + // cond: is32Bit(-c+d) + // result: (ADDVconst [-c+d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64ADDVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(-c + d)) { + break + } + v.reset(OpLOONG64ADDVconst) + v.AuxInt = int64ToAuxInt(-c + d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64XOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (XOR (SRLVconst [8] x) (SLLVconst [8] x)) + // result: (REVB2H x) + for { + if v.Type != typ.UInt16 { + break + } + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLVconst || v_0.Type != typ.UInt16 || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpLOONG64SLLVconst || v_1.Type != typ.UInt16 || auxIntToInt64(v_1.AuxInt) != 8 || x != v_1.Args[0] { + continue + } + v.reset(OpLOONG64REVB2H) + v.AddArg(x) + return true + } + break + } + // match: (XOR (SRLconst [8] (ANDconst [c1] x)) (SLLconst [8] (ANDconst [c2] x))) + // cond: uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff + // result: (REVB2H x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLconst || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64ANDconst { + continue + } + c1 := auxIntToInt64(v_0_0.AuxInt) + x := v_0_0.Args[0] + if v_1.Op != OpLOONG64SLLconst || auxIntToInt64(v_1.AuxInt) != 8 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64ANDconst { + continue + } + c2 := auxIntToInt64(v_1_0.AuxInt) + if x != v_1_0.Args[0] || !(uint32(c1) == 0xff00ff00 && uint32(c2) == 0x00ff00ff) { + continue + } + v.reset(OpLOONG64REVB2H) + v.AddArg(x) + return true + } + break + } + // match: (XOR (SRLVconst [8] (AND (MOVVconst [c1]) x)) (SLLVconst [8] (AND (MOVVconst [c2]) x))) + // cond: uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff + // result: (REVB4H x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLVconst || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64AND { + continue + } + _ = v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0_0, v_0_0_1 = _i1+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpLOONG64MOVVconst { + continue + } + c1 := auxIntToInt64(v_0_0_0.AuxInt) + x := v_0_0_1 + if v_1.Op != OpLOONG64SLLVconst || auxIntToInt64(v_1.AuxInt) != 8 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64AND { + continue + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0_0, v_1_0_1 = _i2+1, v_1_0_1, v_1_0_0 { + if v_1_0_0.Op != OpLOONG64MOVVconst { + continue + } + c2 := auxIntToInt64(v_1_0_0.AuxInt) + if x != v_1_0_1 || !(uint64(c1) == 0xff00ff00ff00ff00 && uint64(c2) == 0x00ff00ff00ff00ff) { + continue + } + v.reset(OpLOONG64REVB4H) + v.AddArg(x) + return true + } + } + } + break + } + // match: (XOR (SRLVconst [8] (AND (MOVVconst [c1]) x)) (SLLVconst [8] (ANDconst [c2] x))) + // cond: uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff + // result: (REVB4H (ANDconst [0xffffffff] x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLOONG64SRLVconst || auxIntToInt64(v_0.AuxInt) != 8 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64AND { + continue + } + _ = v_0_0.Args[1] + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0_0, v_0_0_1 = _i1+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpLOONG64MOVVconst { + continue + } + c1 := auxIntToInt64(v_0_0_0.AuxInt) + x := v_0_0_1 + if v_1.Op != OpLOONG64SLLVconst || auxIntToInt64(v_1.AuxInt) != 8 { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLOONG64ANDconst { + continue + } + c2 := auxIntToInt64(v_1_0.AuxInt) + if x != v_1_0.Args[0] || !(uint64(c1) == 0xff00ff00 && uint64(c2) == 0x00ff00ff) { + continue + } + v.reset(OpLOONG64REVB4H) + v0 := b.NewValue0(v.Pos, OpLOONG64ANDconst, x.Type) + v0.AuxInt = int64ToAuxInt(0xffffffff) + v0.AddArg(x) + v.AddArg(v0) + return true + } + } + break + } + // match: (XOR x (MOVVconst [c])) + // cond: is32Bit(c) + // result: (XORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpLOONG64XORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (XOR x x) + // result: (MOVVconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueLOONG64_OpLOONG64XORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (XORconst [-1] x) + // result: (NORconst [0] x) + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + x := v_0 + v.reset(OpLOONG64NORconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(x) + return true + } + // match: (XORconst [c] (MOVVconst [d])) + // result: (MOVVconst [c^d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpLOONG64MOVVconst) + v.AuxInt = int64ToAuxInt(c ^ d) + return true + } + // match: (XORconst [c] (XORconst [d] x)) + // cond: is32Bit(c^d) + // result: (XORconst [c^d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpLOONG64XORconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c ^ d)) { + break + } + v.reset(OpLOONG64XORconst) + v.AuxInt = int64ToAuxInt(c ^ d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueLOONG64_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16 x y) + // result: (XOR (MOVVconst [1]) (SGT (SignExt16to64 x) (SignExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64XOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64SGT, typ.Bool) + v2 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16U x y) + // result: (XOR (MOVVconst [1]) (SGTU (ZeroExt16to64 x) (ZeroExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64XOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32 x y) + // result: (XOR (MOVVconst [1]) (SGT (SignExt32to64 x) (SignExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64XOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64SGT, typ.Bool) + v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32F x y) + // result: (FPFlagTrue (CMPGEF y x)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpLOONG64CMPGEF, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32U x y) + // result: (XOR (MOVVconst [1]) (SGTU (ZeroExt32to64 x) (ZeroExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64XOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64 x y) + // result: (XOR (MOVVconst [1]) (SGT x y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64XOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64SGT, typ.Bool) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64F x y) + // result: (FPFlagTrue (CMPGED y x)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpLOONG64CMPGED, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpLeq64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64U x y) + // result: (XOR (MOVVconst [1]) (SGTU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64XOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8 x y) + // result: (XOR (MOVVconst [1]) (SGT (SignExt8to64 x) (SignExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64XOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64SGT, typ.Bool) + v2 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8U x y) + // result: (XOR (MOVVconst [1]) (SGTU (ZeroExt8to64 x) (ZeroExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64XOR) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16 x y) + // result: (SGT (SignExt16to64 y) (SignExt16to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGT) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16U x y) + // result: (SGTU (ZeroExt16to64 y) (ZeroExt16to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32 x y) + // result: (SGT (SignExt32to64 y) (SignExt32to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGT) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLess32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32F x y) + // result: (FPFlagTrue (CMPGTF y x)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpLOONG64CMPGTF, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32U x y) + // result: (SGTU (ZeroExt32to64 y) (ZeroExt32to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLess64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Less64 x y) + // result: (SGT y x) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGT) + v.AddArg2(y, x) + return true + } +} +func rewriteValueLOONG64_OpLess64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64F x y) + // result: (FPFlagTrue (CMPGTD y x)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpLOONG64CMPGTD, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpLess64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Less64U x y) + // result: (SGTU y x) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v.AddArg2(y, x) + return true + } +} +func rewriteValueLOONG64_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8 x y) + // result: (SGT (SignExt8to64 y) (SignExt8to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGT) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8U x y) + // result: (SGTU (ZeroExt8to64 y) (ZeroExt8to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Load ptr mem) + // cond: t.IsBoolean() + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsBoolean()) { + break + } + v.reset(OpLOONG64MOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is8BitInt(t) && t.IsSigned()) + // result: (MOVBload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpLOONG64MOVBload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is8BitInt(t) && !t.IsSigned()) + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpLOONG64MOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && t.IsSigned()) + // result: (MOVHload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpLOONG64MOVHload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && !t.IsSigned()) + // result: (MOVHUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpLOONG64MOVHUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is32BitInt(t) && t.IsSigned()) + // result: (MOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpLOONG64MOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is32BitInt(t) && !t.IsSigned()) + // result: (MOVWUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpLOONG64MOVWUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (MOVVload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpLOONG64MOVVload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (MOVFload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(OpLOONG64MOVFload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (MOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(OpLOONG64MOVDload) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (MOVVaddr {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(OpLOONG64MOVVaddr) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (MOVVaddr {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(OpLOONG64MOVVaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x16 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x (ZeroExt16to64 y)) (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x32 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x (ZeroExt32to64 y)) (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x64 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x y) (SGTU (MOVVconst [64]) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x8 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x (ZeroExt8to64 y)) (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLL) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x16 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLL x (ZeroExt16to64 y)) (SGTU (MOVVconst [32]) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(32) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLL) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x32 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLL x (ZeroExt32to64 y)) (SGTU (MOVVconst [32]) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(32) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLL) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x64 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLL x y) (SGTU (MOVVconst [32]) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(32) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLL) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x8 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLL x (ZeroExt8to64 y)) (SGTU (MOVVconst [32]) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(32) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x16 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x (ZeroExt16to64 y)) (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x32 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x (ZeroExt32to64 y)) (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x64 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x y) (SGTU (MOVVconst [64]) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x8 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x (ZeroExt8to64 y)) (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x16 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x (ZeroExt16to64 y)) (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x32 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x (ZeroExt32to64 y)) (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x64 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x y) (SGTU (MOVVconst [64]) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SLLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SLLV) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x8 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SLLV x (ZeroExt8to64 y)) (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16 x y) + // result: (REMV (SignExt16to64 x) (SignExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64REMV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16u x y) + // result: (REMVU (ZeroExt16to64 x) (ZeroExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64REMVU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32 x y) + // result: (REMV (SignExt32to64 x) (SignExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64REMV) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpMod32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32u x y) + // result: (REMVU (ZeroExt32to64 x) (ZeroExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64REMVU) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpMod64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Mod64 x y) + // result: (REMV x y) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64REMV) + v.AddArg2(x, y) + return true + } +} +func rewriteValueLOONG64_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (REMV (SignExt8to64 x) (SignExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64REMV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (REMVU (ZeroExt8to64 x) (ZeroExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64REMVU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (MOVBstore dst (MOVBUload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVBstore) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVBUload, typ.UInt8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (MOVHstore dst (MOVHUload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVHstore) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVHUload, typ.UInt16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [3] dst src mem) + // result: (MOVBstore [2] dst (MOVBUload [2] src mem) (MOVHstore dst (MOVHUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVHstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVHUload, typ.UInt16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [4] dst src mem) + // result: (MOVWstore dst (MOVWUload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVWstore) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVWUload, typ.UInt32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [5] dst src mem) + // result: (MOVBstore [4] dst (MOVBUload [4] src mem) (MOVWstore dst (MOVWUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVWUload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [6] dst src mem) + // result: (MOVHstore [4] dst (MOVHUload [4] src mem) (MOVWstore dst (MOVWUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVHUload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVWUload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [7] dst src mem) + // result: (MOVWstore [3] dst (MOVWUload [3] src mem) (MOVWstore dst (MOVWUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVWUload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVWUload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [8] dst src mem) + // result: (MOVVstore dst (MOVVload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVVstore) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [9] dst src mem) + // result: (MOVBstore [8] dst (MOVBUload [8] src mem) (MOVVstore dst (MOVVload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 9 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [10] dst src mem) + // result: (MOVHstore [8] dst (MOVHUload [8] src mem) (MOVVstore dst (MOVVload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 10 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVHUload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [11] dst src mem) + // result: (MOVWstore [7] dst (MOVWload [7] src mem) (MOVVstore dst (MOVVload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 11 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(7) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVWload, typ.Int32) + v0.AuxInt = int32ToAuxInt(7) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [12] dst src mem) + // result: (MOVWstore [8] dst (MOVWUload [8] src mem) (MOVVstore dst (MOVVload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVWUload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [13] dst src mem) + // result: (MOVVstore [5] dst (MOVVload [5] src mem) (MOVVstore dst (MOVVload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 13 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(5) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(5) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [14] dst src mem) + // result: (MOVVstore [6] dst (MOVVload [6] src mem) (MOVVstore dst (MOVVload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 14 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(6) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [15] dst src mem) + // result: (MOVVstore [7] dst (MOVVload [7] src mem) (MOVVstore dst (MOVVload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 15 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(7) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(7) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [16] dst src mem) + // result: (MOVVstore [8] dst (MOVVload [8] src mem) (MOVVstore dst (MOVVload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 16 && s < 192 && logLargeCopy(v, s) + // result: (LoweredMove [s] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 16 && s < 192 && logLargeCopy(v, s)) { + break + } + v.reset(OpLOONG64LoweredMove) + v.AuxInt = int64ToAuxInt(s) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] dst src mem) + // cond: s >= 192 && logLargeCopy(v, s) + // result: (LoweredMoveLoop [s] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s >= 192 && logLargeCopy(v, s)) { + break + } + v.reset(OpLOONG64LoweredMoveLoop) + v.AuxInt = int64ToAuxInt(s) + v.AddArg3(dst, src, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq16 x y) + // result: (SGTU (XOR (ZeroExt16to32 x) (ZeroExt16to64 y)) (MOVVconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueLOONG64_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq32 x y) + // result: (SGTU (XOR (ZeroExt32to64 x) (ZeroExt32to64 y)) (MOVVconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueLOONG64_OpNeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32F x y) + // result: (FPFlagFalse (CMPEQF x y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64FPFlagFalse) + v0 := b.NewValue0(v.Pos, OpLOONG64CMPEQF, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpNeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq64 x y) + // result: (SGTU (XOR x y) (MOVVconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.UInt64) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpNeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64F x y) + // result: (FPFlagFalse (CMPEQD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64FPFlagFalse) + v0 := b.NewValue0(v.Pos, OpLOONG64CMPEQD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq8 x y) + // result: (SGTU (XOR (ZeroExt8to64 x) (ZeroExt8to64 y)) (MOVVconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueLOONG64_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NeqPtr x y) + // result: (SGTU (XOR x y) (MOVVconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64SGTU) + v0 := b.NewValue0(v.Pos, OpLOONG64XOR, typ.UInt64) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueLOONG64_OpNot(v *Value) bool { + v_0 := v.Args[0] + // match: (Not x) + // result: (XORconst [1] x) + for { + x := v_0 + v.reset(OpLOONG64XORconst) + v.AuxInt = int64ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueLOONG64_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + // match: (OffPtr [off] ptr:(SP)) + // result: (MOVVaddr [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + if ptr.Op != OpSP { + break + } + v.reset(OpLOONG64MOVVaddr) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } + // match: (OffPtr [off] ptr) + // result: (ADDVconst [off] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + v.reset(OpLOONG64ADDVconst) + v.AuxInt = int64ToAuxInt(off) + v.AddArg(ptr) + return true + } +} +func rewriteValueLOONG64_OpPopCount16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount16 x) + // result: (MOVWfpgp (VPCNT16 (MOVWgpfp (ZeroExt16to32 x)))) + for { + t := v.Type + x := v_0 + v.reset(OpLOONG64MOVWfpgp) + v.Type = t + v0 := b.NewValue0(v.Pos, OpLOONG64VPCNT16, typ.Float32) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVWgpfp, typ.Float32) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(x) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpPopCount32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount32 x) + // result: (MOVWfpgp (VPCNT32 (MOVWgpfp x))) + for { + t := v.Type + x := v_0 + v.reset(OpLOONG64MOVWfpgp) + v.Type = t + v0 := b.NewValue0(v.Pos, OpLOONG64VPCNT32, typ.Float32) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVWgpfp, typ.Float32) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpPopCount64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount64 x) + // result: (MOVVfpgp (VPCNT64 (MOVVgpfp x))) + for { + t := v.Type + x := v_0 + v.reset(OpLOONG64MOVVfpgp) + v.Type = t + v0 := b.NewValue0(v.Pos, OpLOONG64VPCNT64, typ.Float64) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVgpfp, typ.Float64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpPrefetchCache(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (PrefetchCache addr mem) + // result: (PRELD addr mem [0]) + for { + addr := v_0 + mem := v_1 + v.reset(OpLOONG64PRELD) + v.AuxInt = int64ToAuxInt(0) + v.AddArg2(addr, mem) + return true + } +} +func rewriteValueLOONG64_OpPrefetchCacheStreamed(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (PrefetchCacheStreamed addr mem) + // result: (PRELDX addr mem [(((512 << 1) + (1 << 12)) << 5) + 2]) + for { + addr := v_0 + mem := v_1 + v.reset(OpLOONG64PRELDX) + v.AuxInt = int64ToAuxInt((((512 << 1) + (1 << 12)) << 5) + 2) + v.AddArg2(addr, mem) + return true + } +} +func rewriteValueLOONG64_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft16 x (MOVVconst [c])) + // result: (Or16 (Lsh16x64 x (MOVVconst [c&15])) (Rsh16Ux64 x (MOVVconst [-c&15]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpLsh16x64, t) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(c & 15) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh16Ux64, t) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(-c & 15) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + // match: (RotateLeft16 x y) + // result: (ROTR (OR (ZeroExt16to32 x) (SLLVconst (ZeroExt16to32 x) [16])) (NEGV y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpLOONG64ROTR) + v.Type = t + v0 := b.NewValue0(v.Pos, OpLOONG64OR, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpLOONG64SLLVconst, t) + v2.AuxInt = int64ToAuxInt(16) + v2.AddArg(v1) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpLOONG64NEGV, typ.Int64) + v3.AddArg(y) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueLOONG64_OpRotateLeft32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RotateLeft32 x y) + // result: (ROTR x (NEGV y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64ROTR) + v0 := b.NewValue0(v.Pos, OpLOONG64NEGV, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueLOONG64_OpRotateLeft64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (RotateLeft64 x y) + // result: (ROTRV x (NEGV y)) + for { + x := v_0 + y := v_1 + v.reset(OpLOONG64ROTRV) + v0 := b.NewValue0(v.Pos, OpLOONG64NEGV, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueLOONG64_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft8 x (MOVVconst [c])) + // result: (Or8 (Lsh8x64 x (MOVVconst [c&7])) (Rsh8Ux64 x (MOVVconst [-c&7]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpLsh8x64, t) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(c & 7) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh8Ux64, t) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(-c & 7) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + // match: (RotateLeft8 x y) + // result: (OR (SLLV x (ANDconst [7] y)) (SRLV (ZeroExt8to64 x) (ANDconst [7] (NEGV y)))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpLOONG64OR) + v.Type = t + v0 := b.NewValue0(v.Pos, OpLOONG64SLLV, t) + v1 := b.NewValue0(v.Pos, OpLOONG64ANDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(7) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpLOONG64ANDconst, typ.Int64) + v4.AuxInt = int64ToAuxInt(7) + v5 := b.NewValue0(v.Pos, OpLOONG64NEGV, typ.Int64) + v5.AddArg(y) + v4.AddArg(v5) + v2.AddArg2(v3, v4) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueLOONG64_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRLV (ZeroExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV (ZeroExt16to64 x) (ZeroExt16to64 y)) (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(64) + v3.AddArg2(v4, v2) + v.AddArg2(v0, v3) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRLV (ZeroExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV (ZeroExt16to64 x) (ZeroExt32to64 y)) (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(64) + v3.AddArg2(v4, v2) + v.AddArg2(v0, v3) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRLV (ZeroExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV (ZeroExt16to64 x) y) (SGTU (MOVVconst [64]) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, y) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRLV (ZeroExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV (ZeroExt16to64 x) (ZeroExt8to64 y)) (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(64) + v3.AddArg2(v4, v2) + v.AddArg2(v0, v3) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAV (SignExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV (SignExt16to64 x) (OR (NEGV (SGTU (ZeroExt16to64 y) (MOVVconst [63]))) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v2 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAV (SignExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV (SignExt16to64 x) (OR (NEGV (SGTU (ZeroExt32to64 y) (MOVVconst [63]))) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v2 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAV (SignExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV (SignExt16to64 x) (OR (NEGV (SGTU y (MOVVconst [63]))) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v2 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v3.AddArg2(y, v4) + v2.AddArg(v3) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAV (SignExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV (SignExt16to64 x) (OR (NEGV (SGTU (ZeroExt8to64 y) (MOVVconst [63]))) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v2 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRL) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRL x (ZeroExt16to64 y)) (SGTU (MOVVconst [32]) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(32) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRL) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRL x (ZeroExt32to64 y)) (SGTU (MOVVconst [32]) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(32) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRL) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRL x y) (SGTU (MOVVconst [32]) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(32) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRL) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRL x (ZeroExt8to64 y)) (SGTU (MOVVconst [32]) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(32) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRA) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (OR (NEGV (SGTU (ZeroExt16to64 y) (MOVVconst [31]))) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRA) + v0 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v1 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(31) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRA) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (OR (NEGV (SGTU (ZeroExt32to64 y) (MOVVconst [31]))) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRA) + v0 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v1 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(31) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRA) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (OR (NEGV (SGTU y (MOVVconst [31]))) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRA) + v0 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v1 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(31) + v2.AddArg2(y, v3) + v1.AddArg(v2) + v0.AddArg2(v1, y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRA) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (OR (NEGV (SGTU (ZeroExt8to64 y) (MOVVconst [31]))) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRA) + v0 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v1 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(31) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh64Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV x (ZeroExt16to64 y)) (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh64Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV x (ZeroExt32to64 y)) (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh64Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV x y) (SGTU (MOVVconst [64]) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh64Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRLV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV x (ZeroExt8to64 y)) (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, v1) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV x (OR (NEGV (SGTU (ZeroExt16to64 y) (MOVVconst [63]))) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v1 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV x (OR (NEGV (SGTU (ZeroExt32to64 y) (MOVVconst [63]))) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v1 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV x (OR (NEGV (SGTU y (MOVVconst [63]))) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v1 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(63) + v2.AddArg2(y, v3) + v1.AddArg(v2) + v0.AddArg2(v1, y) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAV x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV x (OR (NEGV (SGTU (ZeroExt8to64 y) (MOVVconst [63]))) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v1 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRLV (ZeroExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV (ZeroExt8to64 x) (ZeroExt16to64 y)) (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(64) + v3.AddArg2(v4, v2) + v.AddArg2(v0, v3) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRLV (ZeroExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV (ZeroExt8to64 x) (ZeroExt32to64 y)) (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(64) + v3.AddArg2(v4, v2) + v.AddArg2(v0, v3) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRLV (ZeroExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV (ZeroExt8to64 x) y) (SGTU (MOVVconst [64]) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(v3, y) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRLV (ZeroExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRLV) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (MASKEQZ (SRLV (ZeroExt8to64 x) (ZeroExt8to64 y)) (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64MASKEQZ) + v0 := b.NewValue0(v.Pos, OpLOONG64SRLV, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(64) + v3.AddArg2(v4, v2) + v.AddArg2(v0, v3) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAV (SignExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV (SignExt8to64 x) (OR (NEGV (SGTU (ZeroExt16to64 y) (MOVVconst [63]))) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v2 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAV (SignExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV (SignExt8to64 x) (OR (NEGV (SGTU (ZeroExt32to64 y) (MOVVconst [63]))) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v2 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAV (SignExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV (SignExt8to64 x) (OR (NEGV (SGTU y (MOVVconst [63]))) y)) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v2 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v3.AddArg2(y, v4) + v2.AddArg(v3) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAV (SignExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRAV (SignExt8to64 x) (OR (NEGV (SGTU (ZeroExt8to64 y) (MOVVconst [63]))) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpLOONG64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpLOONG64OR, t) + v2 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v3 := b.NewValue0(v.Pos, OpLOONG64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueLOONG64_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Select0 (Mul64uhilo x y)) + // result: (MULHVU x y) + for { + if v_0.Op != OpMul64uhilo { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLOONG64MULHVU) + v.AddArg2(x, y) + return true + } + // match: (Select0 (Mul64uover x y)) + // result: (MULV x y) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLOONG64MULV) + v.AddArg2(x, y) + return true + } + // match: (Select0 (Add64carry x y c)) + // result: (ADDV (ADDV x y) c) + for { + t := v.Type + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpLOONG64ADDV) + v0 := b.NewValue0(v.Pos, OpLOONG64ADDV, t) + v0.AddArg2(x, y) + v.AddArg2(v0, c) + return true + } + // match: (Select0 (Sub64borrow x y c)) + // result: (SUBV (SUBV x y) c) + for { + t := v.Type + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpLOONG64SUBV) + v0 := b.NewValue0(v.Pos, OpLOONG64SUBV, t) + v0.AddArg2(x, y) + v.AddArg2(v0, c) + return true + } + return false +} +func rewriteValueLOONG64_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select1 (Mul64uhilo x y)) + // result: (MULV x y) + for { + if v_0.Op != OpMul64uhilo { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLOONG64MULV) + v.AddArg2(x, y) + return true + } + // match: (Select1 (Mul64uover x y)) + // result: (SGTU (MULHVU x y) (MOVVconst [0])) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLOONG64SGTU) + v.Type = typ.Bool + v0 := b.NewValue0(v.Pos, OpLOONG64MULHVU, typ.UInt64) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v1) + return true + } + // match: (Select1 (Add64carry x y c)) + // result: (OR (SGTU x s:(ADDV x y)) (SGTU s (ADDV s c))) + for { + t := v.Type + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpLOONG64OR) + v0 := b.NewValue0(v.Pos, OpLOONG64SGTU, t) + s := b.NewValue0(v.Pos, OpLOONG64ADDV, t) + s.AddArg2(x, y) + v0.AddArg2(x, s) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, t) + v3 := b.NewValue0(v.Pos, OpLOONG64ADDV, t) + v3.AddArg2(s, c) + v2.AddArg2(s, v3) + v.AddArg2(v0, v2) + return true + } + // match: (Select1 (Sub64borrow x y c)) + // result: (OR (SGTU s:(SUBV x y) x) (SGTU (SUBV s c) s)) + for { + t := v.Type + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpLOONG64OR) + v0 := b.NewValue0(v.Pos, OpLOONG64SGTU, t) + s := b.NewValue0(v.Pos, OpLOONG64SUBV, t) + s.AddArg2(x, y) + v0.AddArg2(s, x) + v2 := b.NewValue0(v.Pos, OpLOONG64SGTU, t) + v3 := b.NewValue0(v.Pos, OpLOONG64SUBV, t) + v3.AddArg2(s, c) + v2.AddArg2(v3, s) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueLOONG64_OpSelectN(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (SelectN [0] call:(CALLstatic {sym} dst src (MOVVconst [sz]) mem)) + // cond: sz >= 0 && isSameCall(sym, "runtime.memmove") && call.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(call) + // result: (Move [sz] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpLOONG64CALLstatic || len(call.Args) != 4 { + break + } + sym := auxToCall(call.Aux) + mem := call.Args[3] + dst := call.Args[0] + src := call.Args[1] + call_2 := call.Args[2] + if call_2.Op != OpLOONG64MOVVconst { + break + } + sz := auxIntToInt64(call_2.AuxInt) + if !(sz >= 0 && isSameCall(sym, "runtime.memmove") && call.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(sz) + v.AddArg3(dst, src, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Slicemask x) + // result: (SRAVconst (NEGV x) [63]) + for { + t := v.Type + x := v_0 + v.reset(OpLOONG64SRAVconst) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpLOONG64NEGV, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueLOONG64_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (MOVBstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(OpLOONG64MOVBstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (MOVHstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(OpLOONG64MOVHstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && !t.IsFloat() + // result: (MOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && !t.IsFloat()) { + break + } + v.reset(OpLOONG64MOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && !t.IsFloat() + // result: (MOVVstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && !t.IsFloat()) { + break + } + v.reset(OpLOONG64MOVVstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && t.IsFloat() + // result: (MOVFstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && t.IsFloat()) { + break + } + v.reset(OpLOONG64MOVFstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && t.IsFloat() + // result: (MOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && t.IsFloat()) { + break + } + v.reset(OpLOONG64MOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueLOONG64_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] ptr mem) + // result: (MOVBstore ptr (MOVVconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVBstore) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [2] ptr mem) + // result: (MOVHstore ptr (MOVVconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVHstore) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [3] ptr mem) + // result: (MOVBstore [2] ptr (MOVVconst [0]) (MOVHstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVHstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [4] {t} ptr mem) + // result: (MOVWstore ptr (MOVVconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVWstore) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [5] ptr mem) + // result: (MOVBstore [4] ptr (MOVVconst [0]) (MOVWstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVWstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [6] ptr mem) + // result: (MOVHstore [4] ptr (MOVVconst [0]) (MOVWstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVWstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [7] ptr mem) + // result: (MOVWstore [3] ptr (MOVVconst [0]) (MOVWstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVWstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [8] {t} ptr mem) + // result: (MOVVstore ptr (MOVVconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVVstore) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [9] ptr mem) + // result: (MOVBstore [8] ptr (MOVVconst [0]) (MOVVstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 9 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVBstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [10] ptr mem) + // result: (MOVHstore [8] ptr (MOVVconst [0]) (MOVVstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 10 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVHstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [11] ptr mem) + // result: (MOVWstore [7] ptr (MOVVconst [0]) (MOVVstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 11 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(7) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [12] ptr mem) + // result: (MOVWstore [8] ptr (MOVVconst [0]) (MOVVstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVWstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [13] ptr mem) + // result: (MOVVstore [5] ptr (MOVVconst [0]) (MOVVstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 13 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(5) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [14] ptr mem) + // result: (MOVVstore [6] ptr (MOVVconst [0]) (MOVVstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 14 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [15] ptr mem) + // result: (MOVVstore [7] ptr (MOVVconst [0]) (MOVVstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 15 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(7) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [16] ptr mem) + // result: (MOVVstore [8] ptr (MOVVconst [0]) (MOVVstore ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpLOONG64MOVVstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpLOONG64MOVVstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [s] ptr mem) + // cond: s > 16 && s < 192 + // result: (LoweredZero [s] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + ptr := v_0 + mem := v_1 + if !(s > 16 && s < 192) { + break + } + v.reset(OpLOONG64LoweredZero) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(ptr, mem) + return true + } + // match: (Zero [s] ptr mem) + // cond: s >= 192 + // result: (LoweredZeroLoop [s] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + ptr := v_0 + mem := v_1 + if !(s >= 192) { + break + } + v.reset(OpLOONG64LoweredZeroLoop) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteBlockLOONG64(b *Block) bool { + typ := &b.Func.Config.Types + switch b.Kind { + case BlockLOONG64BEQ: + // match: (BEQ (MOVVconst [0]) cond yes no) + // result: (EQZ cond yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockLOONG64EQZ, cond) + return true + } + // match: (BEQ cond (MOVVconst [0]) yes no) + // result: (EQZ cond yes no) + for b.Controls[1].Op == OpLOONG64MOVVconst { + cond := b.Controls[0] + v_1 := b.Controls[1] + if auxIntToInt64(v_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockLOONG64EQZ, cond) + return true + } + case BlockLOONG64BGE: + // match: (BGE (MOVVconst [0]) cond yes no) + // result: (LEZ cond yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockLOONG64LEZ, cond) + return true + } + // match: (BGE cond (MOVVconst [0]) yes no) + // result: (GEZ cond yes no) + for b.Controls[1].Op == OpLOONG64MOVVconst { + cond := b.Controls[0] + v_1 := b.Controls[1] + if auxIntToInt64(v_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockLOONG64GEZ, cond) + return true + } + case BlockLOONG64BGEU: + // match: (BGEU (MOVVconst [0]) cond yes no) + // result: (EQZ cond yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockLOONG64EQZ, cond) + return true + } + case BlockLOONG64BLT: + // match: (BLT (MOVVconst [0]) cond yes no) + // result: (GTZ cond yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockLOONG64GTZ, cond) + return true + } + // match: (BLT cond (MOVVconst [0]) yes no) + // result: (LTZ cond yes no) + for b.Controls[1].Op == OpLOONG64MOVVconst { + cond := b.Controls[0] + v_1 := b.Controls[1] + if auxIntToInt64(v_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockLOONG64LTZ, cond) + return true + } + case BlockLOONG64BLTU: + // match: (BLTU (MOVVconst [0]) cond yes no) + // result: (NEZ cond yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockLOONG64NEZ, cond) + return true + } + case BlockLOONG64BNE: + // match: (BNE (MOVVconst [0]) cond yes no) + // result: (NEZ cond yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockLOONG64NEZ, cond) + return true + } + // match: (BNE cond (MOVVconst [0]) yes no) + // result: (NEZ cond yes no) + for b.Controls[1].Op == OpLOONG64MOVVconst { + cond := b.Controls[0] + v_1 := b.Controls[1] + if auxIntToInt64(v_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockLOONG64NEZ, cond) + return true + } + case BlockLOONG64EQZ: + // match: (EQZ (FPFlagTrue cmp) yes no) + // result: (FPF cmp yes no) + for b.Controls[0].Op == OpLOONG64FPFlagTrue { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockLOONG64FPF, cmp) + return true + } + // match: (EQZ (FPFlagFalse cmp) yes no) + // result: (FPT cmp yes no) + for b.Controls[0].Op == OpLOONG64FPFlagFalse { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockLOONG64FPT, cmp) + return true + } + // match: (EQZ (XORconst [1] cmp:(SGT _ _)) yes no) + // result: (NEZ cmp yes no) + for b.Controls[0].Op == OpLOONG64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpLOONG64SGT { + break + } + b.resetWithControl(BlockLOONG64NEZ, cmp) + return true + } + // match: (EQZ (XORconst [1] cmp:(SGTU _ _)) yes no) + // result: (NEZ cmp yes no) + for b.Controls[0].Op == OpLOONG64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpLOONG64SGTU { + break + } + b.resetWithControl(BlockLOONG64NEZ, cmp) + return true + } + // match: (EQZ (XORconst [1] cmp:(SGTconst _)) yes no) + // result: (NEZ cmp yes no) + for b.Controls[0].Op == OpLOONG64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpLOONG64SGTconst { + break + } + b.resetWithControl(BlockLOONG64NEZ, cmp) + return true + } + // match: (EQZ (XORconst [1] cmp:(SGTUconst _)) yes no) + // result: (NEZ cmp yes no) + for b.Controls[0].Op == OpLOONG64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpLOONG64SGTUconst { + break + } + b.resetWithControl(BlockLOONG64NEZ, cmp) + return true + } + // match: (EQZ (SGTUconst [1] x) yes no) + // result: (NEZ x yes no) + for b.Controls[0].Op == OpLOONG64SGTUconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockLOONG64NEZ, x) + return true + } + // match: (EQZ (SGTU x (MOVVconst [0])) yes no) + // result: (EQZ x yes no) + for b.Controls[0].Op == OpLOONG64SGTU { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockLOONG64EQZ, x) + return true + } + // match: (EQZ (SGTconst [0] x) yes no) + // result: (GEZ x yes no) + for b.Controls[0].Op == OpLOONG64SGTconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockLOONG64GEZ, x) + return true + } + // match: (EQZ (SGT x (MOVVconst [0])) yes no) + // result: (LEZ x yes no) + for b.Controls[0].Op == OpLOONG64SGT { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockLOONG64LEZ, x) + return true + } + // match: (EQZ (SGTU (MOVVconst [c]) y) yes no) + // cond: c >= -2048 && c <= 2047 + // result: (EQZ (SGTUconst [c] y) yes no) + for b.Controls[0].Op == OpLOONG64SGTU { + v_0 := b.Controls[0] + y := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + if !(c >= -2048 && c <= 2047) { + break + } + v0 := b.NewValue0(v_0.Pos, OpLOONG64SGTUconst, typ.Bool) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockLOONG64EQZ, v0) + return true + } + // match: (EQZ (SUBV x y) yes no) + // result: (BEQ x y yes no) + for b.Controls[0].Op == OpLOONG64SUBV { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockLOONG64BEQ, x, y) + return true + } + // match: (EQZ (SGT x y) yes no) + // result: (BGE y x yes no) + for b.Controls[0].Op == OpLOONG64SGT { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockLOONG64BGE, y, x) + return true + } + // match: (EQZ (SGTU x y) yes no) + // result: (BGEU y x yes no) + for b.Controls[0].Op == OpLOONG64SGTU { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockLOONG64BGEU, y, x) + return true + } + // match: (EQZ (SGTconst [c] y) yes no) + // result: (BGE y (MOVVconst [c]) yes no) + for b.Controls[0].Op == OpLOONG64SGTconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + v0 := b.NewValue0(b.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + b.resetWithControl2(BlockLOONG64BGE, y, v0) + return true + } + // match: (EQZ (SGTUconst [c] y) yes no) + // result: (BGEU y (MOVVconst [c]) yes no) + for b.Controls[0].Op == OpLOONG64SGTUconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + v0 := b.NewValue0(b.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + b.resetWithControl2(BlockLOONG64BGEU, y, v0) + return true + } + // match: (EQZ (MOVVconst [0]) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + b.Reset(BlockFirst) + return true + } + // match: (EQZ (MOVVconst [c]) yes no) + // cond: c != 0 + // result: (First no yes) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c != 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQZ (NEGV x) yes no) + // result: (EQZ x yes no) + for b.Controls[0].Op == OpLOONG64NEGV { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockLOONG64EQZ, x) + return true + } + case BlockLOONG64GEZ: + // match: (GEZ (MOVVconst [c]) yes no) + // cond: c >= 0 + // result: (First yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c >= 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GEZ (MOVVconst [c]) yes no) + // cond: c < 0 + // result: (First no yes) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c < 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockLOONG64GTZ: + // match: (GTZ (MOVVconst [c]) yes no) + // cond: c > 0 + // result: (First yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c > 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GTZ (MOVVconst [c]) yes no) + // cond: c <= 0 + // result: (First no yes) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c <= 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockIf: + // match: (If cond yes no) + // result: (NEZ (MOVBUreg cond) yes no) + for { + cond := b.Controls[0] + v0 := b.NewValue0(cond.Pos, OpLOONG64MOVBUreg, typ.UInt64) + v0.AddArg(cond) + b.resetWithControl(BlockLOONG64NEZ, v0) + return true + } + case BlockJumpTable: + // match: (JumpTable idx) + // result: (JUMPTABLE {makeJumpTableSym(b)} idx (MOVVaddr {makeJumpTableSym(b)} (SB))) + for { + idx := b.Controls[0] + v0 := b.NewValue0(b.Pos, OpLOONG64MOVVaddr, typ.Uintptr) + v0.Aux = symToAux(makeJumpTableSym(b)) + v1 := b.NewValue0(b.Pos, OpSB, typ.Uintptr) + v0.AddArg(v1) + b.resetWithControl2(BlockLOONG64JUMPTABLE, idx, v0) + b.Aux = symToAux(makeJumpTableSym(b)) + return true + } + case BlockLOONG64LEZ: + // match: (LEZ (MOVVconst [c]) yes no) + // cond: c <= 0 + // result: (First yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c <= 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LEZ (MOVVconst [c]) yes no) + // cond: c > 0 + // result: (First no yes) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c > 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockLOONG64LTZ: + // match: (LTZ (MOVVconst [c]) yes no) + // cond: c < 0 + // result: (First yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c < 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LTZ (MOVVconst [c]) yes no) + // cond: c >= 0 + // result: (First no yes) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c >= 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockLOONG64NEZ: + // match: (NEZ (FPFlagTrue cmp) yes no) + // result: (FPT cmp yes no) + for b.Controls[0].Op == OpLOONG64FPFlagTrue { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockLOONG64FPT, cmp) + return true + } + // match: (NEZ (FPFlagFalse cmp) yes no) + // result: (FPF cmp yes no) + for b.Controls[0].Op == OpLOONG64FPFlagFalse { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockLOONG64FPF, cmp) + return true + } + // match: (NEZ (XORconst [1] cmp:(SGT _ _)) yes no) + // result: (EQZ cmp yes no) + for b.Controls[0].Op == OpLOONG64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpLOONG64SGT { + break + } + b.resetWithControl(BlockLOONG64EQZ, cmp) + return true + } + // match: (NEZ (XORconst [1] cmp:(SGTU _ _)) yes no) + // result: (EQZ cmp yes no) + for b.Controls[0].Op == OpLOONG64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpLOONG64SGTU { + break + } + b.resetWithControl(BlockLOONG64EQZ, cmp) + return true + } + // match: (NEZ (XORconst [1] cmp:(SGTconst _)) yes no) + // result: (EQZ cmp yes no) + for b.Controls[0].Op == OpLOONG64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpLOONG64SGTconst { + break + } + b.resetWithControl(BlockLOONG64EQZ, cmp) + return true + } + // match: (NEZ (XORconst [1] cmp:(SGTUconst _)) yes no) + // result: (EQZ cmp yes no) + for b.Controls[0].Op == OpLOONG64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpLOONG64SGTUconst { + break + } + b.resetWithControl(BlockLOONG64EQZ, cmp) + return true + } + // match: (NEZ (SGTUconst [1] x) yes no) + // result: (EQZ x yes no) + for b.Controls[0].Op == OpLOONG64SGTUconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockLOONG64EQZ, x) + return true + } + // match: (NEZ (SGTU x (MOVVconst [0])) yes no) + // result: (NEZ x yes no) + for b.Controls[0].Op == OpLOONG64SGTU { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockLOONG64NEZ, x) + return true + } + // match: (NEZ (SGTconst [0] x) yes no) + // result: (LTZ x yes no) + for b.Controls[0].Op == OpLOONG64SGTconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockLOONG64LTZ, x) + return true + } + // match: (NEZ (SGT x (MOVVconst [0])) yes no) + // result: (GTZ x yes no) + for b.Controls[0].Op == OpLOONG64SGT { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpLOONG64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockLOONG64GTZ, x) + return true + } + // match: (NEZ (SGTU (MOVVconst [c]) y) yes no) + // cond: c >= -2048 && c <= 2047 + // result: (NEZ (SGTUconst [c] y) yes no) + for b.Controls[0].Op == OpLOONG64SGTU { + v_0 := b.Controls[0] + y := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLOONG64MOVVconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + if !(c >= -2048 && c <= 2047) { + break + } + v0 := b.NewValue0(v_0.Pos, OpLOONG64SGTUconst, typ.Bool) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + b.resetWithControl(BlockLOONG64NEZ, v0) + return true + } + // match: (NEZ (SUBV x y) yes no) + // result: (BNE x y yes no) + for b.Controls[0].Op == OpLOONG64SUBV { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockLOONG64BNE, x, y) + return true + } + // match: (NEZ (SGT x y) yes no) + // result: (BLT y x yes no) + for b.Controls[0].Op == OpLOONG64SGT { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockLOONG64BLT, y, x) + return true + } + // match: (NEZ (SGTU x y) yes no) + // result: (BLTU y x yes no) + for b.Controls[0].Op == OpLOONG64SGTU { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockLOONG64BLTU, y, x) + return true + } + // match: (NEZ (SGTconst [c] y) yes no) + // result: (BLT y (MOVVconst [c]) yes no) + for b.Controls[0].Op == OpLOONG64SGTconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + v0 := b.NewValue0(b.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + b.resetWithControl2(BlockLOONG64BLT, y, v0) + return true + } + // match: (NEZ (SGTUconst [c] y) yes no) + // result: (BLTU y (MOVVconst [c]) yes no) + for b.Controls[0].Op == OpLOONG64SGTUconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + v0 := b.NewValue0(b.Pos, OpLOONG64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c) + b.resetWithControl2(BlockLOONG64BLTU, y, v0) + return true + } + // match: (NEZ (MOVVconst [0]) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (NEZ (MOVVconst [c]) yes no) + // cond: c != 0 + // result: (First yes no) + for b.Controls[0].Op == OpLOONG64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c != 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (NEZ (NEGV x) yes no) + // result: (NEZ x yes no) + for b.Controls[0].Op == OpLOONG64NEGV { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockLOONG64NEZ, x) + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteLOONG64latelower.go b/go/src/cmd/compile/internal/ssa/rewriteLOONG64latelower.go new file mode 100644 index 0000000000000000000000000000000000000000..02930e5e834bae5ffe270b87cee029f02e684325 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteLOONG64latelower.go @@ -0,0 +1,75 @@ +// Code generated from _gen/LOONG64latelower.rules using 'go generate'; DO NOT EDIT. + +package ssa + +func rewriteValueLOONG64latelower(v *Value) bool { + switch v.Op { + case OpLOONG64MOVVconst: + return rewriteValueLOONG64latelower_OpLOONG64MOVVconst(v) + case OpLOONG64SLLVconst: + return rewriteValueLOONG64latelower_OpLOONG64SLLVconst(v) + } + return false +} +func rewriteValueLOONG64latelower_OpLOONG64MOVVconst(v *Value) bool { + // match: (MOVVconst [0]) + // result: (ZERO) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + v.reset(OpLOONG64ZERO) + return true + } + return false +} +func rewriteValueLOONG64latelower_OpLOONG64SLLVconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLLVconst [1] x) + // result: (ADDV x x) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + x := v_0 + v.reset(OpLOONG64ADDV) + v.AddArg2(x, x) + return true + } + return false +} +func rewriteBlockLOONG64latelower(b *Block) bool { + switch b.Kind { + case BlockLOONG64EQZ: + // match: (EQZ (XOR x y) yes no) + // result: (BEQ x y yes no) + for b.Controls[0].Op == OpLOONG64XOR { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + b.resetWithControl2(BlockLOONG64BEQ, x, y) + return true + } + } + case BlockLOONG64NEZ: + // match: (NEZ (XOR x y) yes no) + // result: (BNE x y yes no) + for b.Controls[0].Op == OpLOONG64XOR { + v_0 := b.Controls[0] + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + b.resetWithControl2(BlockLOONG64BNE, x, y) + return true + } + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteMIPS.go b/go/src/cmd/compile/internal/ssa/rewriteMIPS.go new file mode 100644 index 0000000000000000000000000000000000000000..ff696337ef82990bf5d553a07470c33929407e23 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteMIPS.go @@ -0,0 +1,7842 @@ +// Code generated from _gen/MIPS.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "cmd/compile/internal/types" + +func rewriteValueMIPS(v *Value) bool { + switch v.Op { + case OpAbs: + v.Op = OpMIPSABSD + return true + case OpAdd16: + v.Op = OpMIPSADD + return true + case OpAdd32: + v.Op = OpMIPSADD + return true + case OpAdd32F: + v.Op = OpMIPSADDF + return true + case OpAdd32withcarry: + return rewriteValueMIPS_OpAdd32withcarry(v) + case OpAdd64F: + v.Op = OpMIPSADDD + return true + case OpAdd8: + v.Op = OpMIPSADD + return true + case OpAddPtr: + v.Op = OpMIPSADD + return true + case OpAddr: + return rewriteValueMIPS_OpAddr(v) + case OpAnd16: + v.Op = OpMIPSAND + return true + case OpAnd32: + v.Op = OpMIPSAND + return true + case OpAnd8: + v.Op = OpMIPSAND + return true + case OpAndB: + v.Op = OpMIPSAND + return true + case OpAtomicAdd32: + v.Op = OpMIPSLoweredAtomicAdd + return true + case OpAtomicAnd32: + v.Op = OpMIPSLoweredAtomicAnd + return true + case OpAtomicAnd8: + return rewriteValueMIPS_OpAtomicAnd8(v) + case OpAtomicCompareAndSwap32: + v.Op = OpMIPSLoweredAtomicCas + return true + case OpAtomicExchange32: + v.Op = OpMIPSLoweredAtomicExchange + return true + case OpAtomicLoad32: + v.Op = OpMIPSLoweredAtomicLoad32 + return true + case OpAtomicLoad8: + v.Op = OpMIPSLoweredAtomicLoad8 + return true + case OpAtomicLoadPtr: + v.Op = OpMIPSLoweredAtomicLoad32 + return true + case OpAtomicOr32: + v.Op = OpMIPSLoweredAtomicOr + return true + case OpAtomicOr8: + return rewriteValueMIPS_OpAtomicOr8(v) + case OpAtomicStore32: + v.Op = OpMIPSLoweredAtomicStore32 + return true + case OpAtomicStore8: + v.Op = OpMIPSLoweredAtomicStore8 + return true + case OpAtomicStorePtrNoWB: + v.Op = OpMIPSLoweredAtomicStore32 + return true + case OpAvg32u: + return rewriteValueMIPS_OpAvg32u(v) + case OpBitLen16: + return rewriteValueMIPS_OpBitLen16(v) + case OpBitLen32: + return rewriteValueMIPS_OpBitLen32(v) + case OpBitLen8: + return rewriteValueMIPS_OpBitLen8(v) + case OpClosureCall: + v.Op = OpMIPSCALLclosure + return true + case OpCom16: + return rewriteValueMIPS_OpCom16(v) + case OpCom32: + return rewriteValueMIPS_OpCom32(v) + case OpCom8: + return rewriteValueMIPS_OpCom8(v) + case OpConst16: + return rewriteValueMIPS_OpConst16(v) + case OpConst32: + return rewriteValueMIPS_OpConst32(v) + case OpConst32F: + v.Op = OpMIPSMOVFconst + return true + case OpConst64F: + v.Op = OpMIPSMOVDconst + return true + case OpConst8: + return rewriteValueMIPS_OpConst8(v) + case OpConstBool: + return rewriteValueMIPS_OpConstBool(v) + case OpConstNil: + return rewriteValueMIPS_OpConstNil(v) + case OpCtz16: + return rewriteValueMIPS_OpCtz16(v) + case OpCtz16NonZero: + v.Op = OpCtz32 + return true + case OpCtz32: + return rewriteValueMIPS_OpCtz32(v) + case OpCtz32NonZero: + v.Op = OpCtz32 + return true + case OpCtz8: + return rewriteValueMIPS_OpCtz8(v) + case OpCtz8NonZero: + v.Op = OpCtz32 + return true + case OpCvt32Fto32: + v.Op = OpMIPSTRUNCFW + return true + case OpCvt32Fto64F: + v.Op = OpMIPSMOVFD + return true + case OpCvt32to32F: + v.Op = OpMIPSMOVWF + return true + case OpCvt32to64F: + v.Op = OpMIPSMOVWD + return true + case OpCvt64Fto32: + v.Op = OpMIPSTRUNCDW + return true + case OpCvt64Fto32F: + v.Op = OpMIPSMOVDF + return true + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpDiv16: + return rewriteValueMIPS_OpDiv16(v) + case OpDiv16u: + return rewriteValueMIPS_OpDiv16u(v) + case OpDiv32: + return rewriteValueMIPS_OpDiv32(v) + case OpDiv32F: + v.Op = OpMIPSDIVF + return true + case OpDiv32u: + return rewriteValueMIPS_OpDiv32u(v) + case OpDiv64F: + v.Op = OpMIPSDIVD + return true + case OpDiv8: + return rewriteValueMIPS_OpDiv8(v) + case OpDiv8u: + return rewriteValueMIPS_OpDiv8u(v) + case OpEq16: + return rewriteValueMIPS_OpEq16(v) + case OpEq32: + return rewriteValueMIPS_OpEq32(v) + case OpEq32F: + return rewriteValueMIPS_OpEq32F(v) + case OpEq64F: + return rewriteValueMIPS_OpEq64F(v) + case OpEq8: + return rewriteValueMIPS_OpEq8(v) + case OpEqB: + return rewriteValueMIPS_OpEqB(v) + case OpEqPtr: + return rewriteValueMIPS_OpEqPtr(v) + case OpGetCallerPC: + v.Op = OpMIPSLoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = OpMIPSLoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = OpMIPSLoweredGetClosurePtr + return true + case OpHmul32: + return rewriteValueMIPS_OpHmul32(v) + case OpHmul32u: + return rewriteValueMIPS_OpHmul32u(v) + case OpInterCall: + v.Op = OpMIPSCALLinter + return true + case OpIsInBounds: + return rewriteValueMIPS_OpIsInBounds(v) + case OpIsNonNil: + return rewriteValueMIPS_OpIsNonNil(v) + case OpIsSliceInBounds: + return rewriteValueMIPS_OpIsSliceInBounds(v) + case OpLeq16: + return rewriteValueMIPS_OpLeq16(v) + case OpLeq16U: + return rewriteValueMIPS_OpLeq16U(v) + case OpLeq32: + return rewriteValueMIPS_OpLeq32(v) + case OpLeq32F: + return rewriteValueMIPS_OpLeq32F(v) + case OpLeq32U: + return rewriteValueMIPS_OpLeq32U(v) + case OpLeq64F: + return rewriteValueMIPS_OpLeq64F(v) + case OpLeq8: + return rewriteValueMIPS_OpLeq8(v) + case OpLeq8U: + return rewriteValueMIPS_OpLeq8U(v) + case OpLess16: + return rewriteValueMIPS_OpLess16(v) + case OpLess16U: + return rewriteValueMIPS_OpLess16U(v) + case OpLess32: + return rewriteValueMIPS_OpLess32(v) + case OpLess32F: + return rewriteValueMIPS_OpLess32F(v) + case OpLess32U: + return rewriteValueMIPS_OpLess32U(v) + case OpLess64F: + return rewriteValueMIPS_OpLess64F(v) + case OpLess8: + return rewriteValueMIPS_OpLess8(v) + case OpLess8U: + return rewriteValueMIPS_OpLess8U(v) + case OpLoad: + return rewriteValueMIPS_OpLoad(v) + case OpLocalAddr: + return rewriteValueMIPS_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValueMIPS_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValueMIPS_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValueMIPS_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValueMIPS_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValueMIPS_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValueMIPS_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValueMIPS_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValueMIPS_OpLsh32x8(v) + case OpLsh8x16: + return rewriteValueMIPS_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValueMIPS_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValueMIPS_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValueMIPS_OpLsh8x8(v) + case OpMIPSADD: + return rewriteValueMIPS_OpMIPSADD(v) + case OpMIPSADDconst: + return rewriteValueMIPS_OpMIPSADDconst(v) + case OpMIPSAND: + return rewriteValueMIPS_OpMIPSAND(v) + case OpMIPSANDconst: + return rewriteValueMIPS_OpMIPSANDconst(v) + case OpMIPSCMOVZ: + return rewriteValueMIPS_OpMIPSCMOVZ(v) + case OpMIPSCMOVZzero: + return rewriteValueMIPS_OpMIPSCMOVZzero(v) + case OpMIPSLoweredAtomicAdd: + return rewriteValueMIPS_OpMIPSLoweredAtomicAdd(v) + case OpMIPSLoweredAtomicStore32: + return rewriteValueMIPS_OpMIPSLoweredAtomicStore32(v) + case OpMIPSLoweredPanicBoundsRC: + return rewriteValueMIPS_OpMIPSLoweredPanicBoundsRC(v) + case OpMIPSLoweredPanicBoundsRR: + return rewriteValueMIPS_OpMIPSLoweredPanicBoundsRR(v) + case OpMIPSLoweredPanicExtendRC: + return rewriteValueMIPS_OpMIPSLoweredPanicExtendRC(v) + case OpMIPSLoweredPanicExtendRR: + return rewriteValueMIPS_OpMIPSLoweredPanicExtendRR(v) + case OpMIPSMOVBUload: + return rewriteValueMIPS_OpMIPSMOVBUload(v) + case OpMIPSMOVBUreg: + return rewriteValueMIPS_OpMIPSMOVBUreg(v) + case OpMIPSMOVBload: + return rewriteValueMIPS_OpMIPSMOVBload(v) + case OpMIPSMOVBreg: + return rewriteValueMIPS_OpMIPSMOVBreg(v) + case OpMIPSMOVBstore: + return rewriteValueMIPS_OpMIPSMOVBstore(v) + case OpMIPSMOVBstorezero: + return rewriteValueMIPS_OpMIPSMOVBstorezero(v) + case OpMIPSMOVDload: + return rewriteValueMIPS_OpMIPSMOVDload(v) + case OpMIPSMOVDstore: + return rewriteValueMIPS_OpMIPSMOVDstore(v) + case OpMIPSMOVFload: + return rewriteValueMIPS_OpMIPSMOVFload(v) + case OpMIPSMOVFstore: + return rewriteValueMIPS_OpMIPSMOVFstore(v) + case OpMIPSMOVHUload: + return rewriteValueMIPS_OpMIPSMOVHUload(v) + case OpMIPSMOVHUreg: + return rewriteValueMIPS_OpMIPSMOVHUreg(v) + case OpMIPSMOVHload: + return rewriteValueMIPS_OpMIPSMOVHload(v) + case OpMIPSMOVHreg: + return rewriteValueMIPS_OpMIPSMOVHreg(v) + case OpMIPSMOVHstore: + return rewriteValueMIPS_OpMIPSMOVHstore(v) + case OpMIPSMOVHstorezero: + return rewriteValueMIPS_OpMIPSMOVHstorezero(v) + case OpMIPSMOVWload: + return rewriteValueMIPS_OpMIPSMOVWload(v) + case OpMIPSMOVWnop: + return rewriteValueMIPS_OpMIPSMOVWnop(v) + case OpMIPSMOVWreg: + return rewriteValueMIPS_OpMIPSMOVWreg(v) + case OpMIPSMOVWstore: + return rewriteValueMIPS_OpMIPSMOVWstore(v) + case OpMIPSMOVWstorezero: + return rewriteValueMIPS_OpMIPSMOVWstorezero(v) + case OpMIPSMUL: + return rewriteValueMIPS_OpMIPSMUL(v) + case OpMIPSNEG: + return rewriteValueMIPS_OpMIPSNEG(v) + case OpMIPSNOR: + return rewriteValueMIPS_OpMIPSNOR(v) + case OpMIPSNORconst: + return rewriteValueMIPS_OpMIPSNORconst(v) + case OpMIPSOR: + return rewriteValueMIPS_OpMIPSOR(v) + case OpMIPSORconst: + return rewriteValueMIPS_OpMIPSORconst(v) + case OpMIPSSGT: + return rewriteValueMIPS_OpMIPSSGT(v) + case OpMIPSSGTU: + return rewriteValueMIPS_OpMIPSSGTU(v) + case OpMIPSSGTUconst: + return rewriteValueMIPS_OpMIPSSGTUconst(v) + case OpMIPSSGTUzero: + return rewriteValueMIPS_OpMIPSSGTUzero(v) + case OpMIPSSGTconst: + return rewriteValueMIPS_OpMIPSSGTconst(v) + case OpMIPSSGTzero: + return rewriteValueMIPS_OpMIPSSGTzero(v) + case OpMIPSSLL: + return rewriteValueMIPS_OpMIPSSLL(v) + case OpMIPSSLLconst: + return rewriteValueMIPS_OpMIPSSLLconst(v) + case OpMIPSSRA: + return rewriteValueMIPS_OpMIPSSRA(v) + case OpMIPSSRAconst: + return rewriteValueMIPS_OpMIPSSRAconst(v) + case OpMIPSSRL: + return rewriteValueMIPS_OpMIPSSRL(v) + case OpMIPSSRLconst: + return rewriteValueMIPS_OpMIPSSRLconst(v) + case OpMIPSSUB: + return rewriteValueMIPS_OpMIPSSUB(v) + case OpMIPSSUBconst: + return rewriteValueMIPS_OpMIPSSUBconst(v) + case OpMIPSXOR: + return rewriteValueMIPS_OpMIPSXOR(v) + case OpMIPSXORconst: + return rewriteValueMIPS_OpMIPSXORconst(v) + case OpMod16: + return rewriteValueMIPS_OpMod16(v) + case OpMod16u: + return rewriteValueMIPS_OpMod16u(v) + case OpMod32: + return rewriteValueMIPS_OpMod32(v) + case OpMod32u: + return rewriteValueMIPS_OpMod32u(v) + case OpMod8: + return rewriteValueMIPS_OpMod8(v) + case OpMod8u: + return rewriteValueMIPS_OpMod8u(v) + case OpMove: + return rewriteValueMIPS_OpMove(v) + case OpMul16: + v.Op = OpMIPSMUL + return true + case OpMul32: + v.Op = OpMIPSMUL + return true + case OpMul32F: + v.Op = OpMIPSMULF + return true + case OpMul32uhilo: + v.Op = OpMIPSMULTU + return true + case OpMul64F: + v.Op = OpMIPSMULD + return true + case OpMul8: + v.Op = OpMIPSMUL + return true + case OpNeg16: + v.Op = OpMIPSNEG + return true + case OpNeg32: + v.Op = OpMIPSNEG + return true + case OpNeg32F: + v.Op = OpMIPSNEGF + return true + case OpNeg64F: + v.Op = OpMIPSNEGD + return true + case OpNeg8: + v.Op = OpMIPSNEG + return true + case OpNeq16: + return rewriteValueMIPS_OpNeq16(v) + case OpNeq32: + return rewriteValueMIPS_OpNeq32(v) + case OpNeq32F: + return rewriteValueMIPS_OpNeq32F(v) + case OpNeq64F: + return rewriteValueMIPS_OpNeq64F(v) + case OpNeq8: + return rewriteValueMIPS_OpNeq8(v) + case OpNeqB: + v.Op = OpMIPSXOR + return true + case OpNeqPtr: + return rewriteValueMIPS_OpNeqPtr(v) + case OpNilCheck: + v.Op = OpMIPSLoweredNilCheck + return true + case OpNot: + return rewriteValueMIPS_OpNot(v) + case OpOffPtr: + return rewriteValueMIPS_OpOffPtr(v) + case OpOr16: + v.Op = OpMIPSOR + return true + case OpOr32: + v.Op = OpMIPSOR + return true + case OpOr8: + v.Op = OpMIPSOR + return true + case OpOrB: + v.Op = OpMIPSOR + return true + case OpPanicBounds: + v.Op = OpMIPSLoweredPanicBoundsRR + return true + case OpPanicExtend: + v.Op = OpMIPSLoweredPanicExtendRR + return true + case OpPubBarrier: + v.Op = OpMIPSLoweredPubBarrier + return true + case OpRotateLeft16: + return rewriteValueMIPS_OpRotateLeft16(v) + case OpRotateLeft32: + return rewriteValueMIPS_OpRotateLeft32(v) + case OpRotateLeft64: + return rewriteValueMIPS_OpRotateLeft64(v) + case OpRotateLeft8: + return rewriteValueMIPS_OpRotateLeft8(v) + case OpRound32F: + v.Op = OpCopy + return true + case OpRound64F: + v.Op = OpCopy + return true + case OpRsh16Ux16: + return rewriteValueMIPS_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValueMIPS_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValueMIPS_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValueMIPS_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValueMIPS_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValueMIPS_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValueMIPS_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValueMIPS_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValueMIPS_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValueMIPS_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValueMIPS_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValueMIPS_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValueMIPS_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValueMIPS_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValueMIPS_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValueMIPS_OpRsh32x8(v) + case OpRsh8Ux16: + return rewriteValueMIPS_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValueMIPS_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValueMIPS_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValueMIPS_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValueMIPS_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValueMIPS_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValueMIPS_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValueMIPS_OpRsh8x8(v) + case OpSelect0: + return rewriteValueMIPS_OpSelect0(v) + case OpSelect1: + return rewriteValueMIPS_OpSelect1(v) + case OpSignExt16to32: + v.Op = OpMIPSMOVHreg + return true + case OpSignExt8to16: + v.Op = OpMIPSMOVBreg + return true + case OpSignExt8to32: + v.Op = OpMIPSMOVBreg + return true + case OpSignmask: + return rewriteValueMIPS_OpSignmask(v) + case OpSlicemask: + return rewriteValueMIPS_OpSlicemask(v) + case OpSqrt: + v.Op = OpMIPSSQRTD + return true + case OpSqrt32: + v.Op = OpMIPSSQRTF + return true + case OpStaticCall: + v.Op = OpMIPSCALLstatic + return true + case OpStore: + return rewriteValueMIPS_OpStore(v) + case OpSub16: + v.Op = OpMIPSSUB + return true + case OpSub32: + v.Op = OpMIPSSUB + return true + case OpSub32F: + v.Op = OpMIPSSUBF + return true + case OpSub32withcarry: + return rewriteValueMIPS_OpSub32withcarry(v) + case OpSub64F: + v.Op = OpMIPSSUBD + return true + case OpSub8: + v.Op = OpMIPSSUB + return true + case OpSubPtr: + v.Op = OpMIPSSUB + return true + case OpTailCall: + v.Op = OpMIPSCALLtail + return true + case OpTrunc16to8: + v.Op = OpCopy + return true + case OpTrunc32to16: + v.Op = OpCopy + return true + case OpTrunc32to8: + v.Op = OpCopy + return true + case OpWB: + v.Op = OpMIPSLoweredWB + return true + case OpXor16: + v.Op = OpMIPSXOR + return true + case OpXor32: + v.Op = OpMIPSXOR + return true + case OpXor8: + v.Op = OpMIPSXOR + return true + case OpZero: + return rewriteValueMIPS_OpZero(v) + case OpZeroExt16to32: + v.Op = OpMIPSMOVHUreg + return true + case OpZeroExt8to16: + v.Op = OpMIPSMOVBUreg + return true + case OpZeroExt8to32: + v.Op = OpMIPSMOVBUreg + return true + case OpZeromask: + return rewriteValueMIPS_OpZeromask(v) + } + return false +} +func rewriteValueMIPS_OpAdd32withcarry(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Add32withcarry x y c) + // result: (ADD c (ADD x y)) + for { + t := v.Type + x := v_0 + y := v_1 + c := v_2 + v.reset(OpMIPSADD) + v0 := b.NewValue0(v.Pos, OpMIPSADD, t) + v0.AddArg2(x, y) + v.AddArg2(c, v0) + return true + } +} +func rewriteValueMIPS_OpAddr(v *Value) bool { + v_0 := v.Args[0] + // match: (Addr {sym} base) + // result: (MOVWaddr {sym} base) + for { + sym := auxToSym(v.Aux) + base := v_0 + v.reset(OpMIPSMOVWaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } +} +func rewriteValueMIPS_OpAtomicAnd8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (AtomicAnd8 ptr val mem) + // cond: !config.BigEndian + // result: (LoweredAtomicAnd (AND (MOVWconst [^3]) ptr) (OR (SLL (ZeroExt8to32 val) (SLLconst [3] (ANDconst [3] ptr))) (NORconst [0] (SLL (MOVWconst [0xff]) (SLLconst [3] (ANDconst [3] ptr))))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + if !(!config.BigEndian) { + break + } + v.reset(OpMIPSLoweredAtomicAnd) + v0 := b.NewValue0(v.Pos, OpMIPSAND, typ.UInt32Ptr) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(^3) + v0.AddArg2(v1, ptr) + v2 := b.NewValue0(v.Pos, OpMIPSOR, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpMIPSSLL, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v4.AddArg(val) + v5 := b.NewValue0(v.Pos, OpMIPSSLLconst, typ.UInt32) + v5.AuxInt = int32ToAuxInt(3) + v6 := b.NewValue0(v.Pos, OpMIPSANDconst, typ.UInt32) + v6.AuxInt = int32ToAuxInt(3) + v6.AddArg(ptr) + v5.AddArg(v6) + v3.AddArg2(v4, v5) + v7 := b.NewValue0(v.Pos, OpMIPSNORconst, typ.UInt32) + v7.AuxInt = int32ToAuxInt(0) + v8 := b.NewValue0(v.Pos, OpMIPSSLL, typ.UInt32) + v9 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v9.AuxInt = int32ToAuxInt(0xff) + v8.AddArg2(v9, v5) + v7.AddArg(v8) + v2.AddArg2(v3, v7) + v.AddArg3(v0, v2, mem) + return true + } + // match: (AtomicAnd8 ptr val mem) + // cond: config.BigEndian + // result: (LoweredAtomicAnd (AND (MOVWconst [^3]) ptr) (OR (SLL (ZeroExt8to32 val) (SLLconst [3] (ANDconst [3] (XORconst [3] ptr)))) (NORconst [0] (SLL (MOVWconst [0xff]) (SLLconst [3] (ANDconst [3] (XORconst [3] ptr)))))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + if !(config.BigEndian) { + break + } + v.reset(OpMIPSLoweredAtomicAnd) + v0 := b.NewValue0(v.Pos, OpMIPSAND, typ.UInt32Ptr) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(^3) + v0.AddArg2(v1, ptr) + v2 := b.NewValue0(v.Pos, OpMIPSOR, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpMIPSSLL, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v4.AddArg(val) + v5 := b.NewValue0(v.Pos, OpMIPSSLLconst, typ.UInt32) + v5.AuxInt = int32ToAuxInt(3) + v6 := b.NewValue0(v.Pos, OpMIPSANDconst, typ.UInt32) + v6.AuxInt = int32ToAuxInt(3) + v7 := b.NewValue0(v.Pos, OpMIPSXORconst, typ.UInt32) + v7.AuxInt = int32ToAuxInt(3) + v7.AddArg(ptr) + v6.AddArg(v7) + v5.AddArg(v6) + v3.AddArg2(v4, v5) + v8 := b.NewValue0(v.Pos, OpMIPSNORconst, typ.UInt32) + v8.AuxInt = int32ToAuxInt(0) + v9 := b.NewValue0(v.Pos, OpMIPSSLL, typ.UInt32) + v10 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v10.AuxInt = int32ToAuxInt(0xff) + v9.AddArg2(v10, v5) + v8.AddArg(v9) + v2.AddArg2(v3, v8) + v.AddArg3(v0, v2, mem) + return true + } + return false +} +func rewriteValueMIPS_OpAtomicOr8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (AtomicOr8 ptr val mem) + // cond: !config.BigEndian + // result: (LoweredAtomicOr (AND (MOVWconst [^3]) ptr) (SLL (ZeroExt8to32 val) (SLLconst [3] (ANDconst [3] ptr))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + if !(!config.BigEndian) { + break + } + v.reset(OpMIPSLoweredAtomicOr) + v0 := b.NewValue0(v.Pos, OpMIPSAND, typ.UInt32Ptr) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(^3) + v0.AddArg2(v1, ptr) + v2 := b.NewValue0(v.Pos, OpMIPSSLL, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v3.AddArg(val) + v4 := b.NewValue0(v.Pos, OpMIPSSLLconst, typ.UInt32) + v4.AuxInt = int32ToAuxInt(3) + v5 := b.NewValue0(v.Pos, OpMIPSANDconst, typ.UInt32) + v5.AuxInt = int32ToAuxInt(3) + v5.AddArg(ptr) + v4.AddArg(v5) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v2, mem) + return true + } + // match: (AtomicOr8 ptr val mem) + // cond: config.BigEndian + // result: (LoweredAtomicOr (AND (MOVWconst [^3]) ptr) (SLL (ZeroExt8to32 val) (SLLconst [3] (ANDconst [3] (XORconst [3] ptr)))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + if !(config.BigEndian) { + break + } + v.reset(OpMIPSLoweredAtomicOr) + v0 := b.NewValue0(v.Pos, OpMIPSAND, typ.UInt32Ptr) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(^3) + v0.AddArg2(v1, ptr) + v2 := b.NewValue0(v.Pos, OpMIPSSLL, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v3.AddArg(val) + v4 := b.NewValue0(v.Pos, OpMIPSSLLconst, typ.UInt32) + v4.AuxInt = int32ToAuxInt(3) + v5 := b.NewValue0(v.Pos, OpMIPSANDconst, typ.UInt32) + v5.AuxInt = int32ToAuxInt(3) + v6 := b.NewValue0(v.Pos, OpMIPSXORconst, typ.UInt32) + v6.AuxInt = int32ToAuxInt(3) + v6.AddArg(ptr) + v5.AddArg(v6) + v4.AddArg(v5) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v2, mem) + return true + } + return false +} +func rewriteValueMIPS_OpAvg32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Avg32u x y) + // result: (ADD (SRLconst (SUB x y) [1]) y) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSADD) + v0 := b.NewValue0(v.Pos, OpMIPSSRLconst, t) + v0.AuxInt = int32ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPSSUB, t) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueMIPS_OpBitLen16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen16 x) + // result: (BitLen32 (ZeroExt16to32 x)) + for { + x := v_0 + v.reset(OpBitLen32) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpBitLen32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen32 x) + // result: (SUB (MOVWconst [32]) (CLZ x)) + for { + t := v.Type + x := v_0 + v.reset(OpMIPSSUB) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(32) + v1 := b.NewValue0(v.Pos, OpMIPSCLZ, t) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpBitLen8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen8 x) + // result: (BitLen32 (ZeroExt8to32 x)) + for { + x := v_0 + v.reset(OpBitLen32) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpCom16(v *Value) bool { + v_0 := v.Args[0] + // match: (Com16 x) + // result: (NORconst [0] x) + for { + x := v_0 + v.reset(OpMIPSNORconst) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueMIPS_OpCom32(v *Value) bool { + v_0 := v.Args[0] + // match: (Com32 x) + // result: (NORconst [0] x) + for { + x := v_0 + v.reset(OpMIPSNORconst) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueMIPS_OpCom8(v *Value) bool { + v_0 := v.Args[0] + // match: (Com8 x) + // result: (NORconst [0] x) + for { + x := v_0 + v.reset(OpMIPSNORconst) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(x) + return true + } +} +func rewriteValueMIPS_OpConst16(v *Value) bool { + // match: (Const16 [val]) + // result: (MOVWconst [int32(val)]) + for { + val := auxIntToInt16(v.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(val)) + return true + } +} +func rewriteValueMIPS_OpConst32(v *Value) bool { + // match: (Const32 [val]) + // result: (MOVWconst [int32(val)]) + for { + val := auxIntToInt32(v.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(val)) + return true + } +} +func rewriteValueMIPS_OpConst8(v *Value) bool { + // match: (Const8 [val]) + // result: (MOVWconst [int32(val)]) + for { + val := auxIntToInt8(v.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(val)) + return true + } +} +func rewriteValueMIPS_OpConstBool(v *Value) bool { + // match: (ConstBool [t]) + // result: (MOVWconst [b2i32(t)]) + for { + t := auxIntToBool(v.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(b2i32(t)) + return true + } +} +func rewriteValueMIPS_OpConstNil(v *Value) bool { + // match: (ConstNil) + // result: (MOVWconst [0]) + for { + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } +} +func rewriteValueMIPS_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz16 x) + // result: (Ctz32 (Or32 x (MOVWconst [1<<16]))) + for { + x := v_0 + v.reset(OpCtz32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(1 << 16) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpCtz32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz32 x) + // result: (SUB (MOVWconst [32]) (CLZ (SUBconst [1] (AND x (NEG x))))) + for { + t := v.Type + x := v_0 + v.reset(OpMIPSSUB) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(32) + v1 := b.NewValue0(v.Pos, OpMIPSCLZ, t) + v2 := b.NewValue0(v.Pos, OpMIPSSUBconst, t) + v2.AuxInt = int32ToAuxInt(1) + v3 := b.NewValue0(v.Pos, OpMIPSAND, t) + v4 := b.NewValue0(v.Pos, OpMIPSNEG, t) + v4.AddArg(x) + v3.AddArg2(x, v4) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz8 x) + // result: (Ctz32 (Or32 x (MOVWconst [1<<8]))) + for { + x := v_0 + v.reset(OpCtz32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(1 << 8) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 x y) + // result: (Select1 (DIV (SignExt16to32 x) (SignExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPSDIV, types.NewTuple(typ.Int32, typ.Int32)) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u x y) + // result: (Select1 (DIVU (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPSDIVU, types.NewTuple(typ.UInt32, typ.UInt32)) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32 x y) + // result: (Select1 (DIV x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPSDIV, types.NewTuple(typ.Int32, typ.Int32)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpDiv32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32u x y) + // result: (Select1 (DIVU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPSDIVU, types.NewTuple(typ.UInt32, typ.UInt32)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (Select1 (DIV (SignExt8to32 x) (SignExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPSDIV, types.NewTuple(typ.Int32, typ.Int32)) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (Select1 (DIVU (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPSDIVU, types.NewTuple(typ.UInt32, typ.UInt32)) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq16 x y) + // result: (SGTUconst [1] (XOR (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTUconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSXOR, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq32 x y) + // result: (SGTUconst [1] (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTUconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSXOR, typ.UInt32) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpEq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32F x y) + // result: (FPFlagTrue (CMPEQF x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSFPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPSCMPEQF, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpEq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64F x y) + // result: (FPFlagTrue (CMPEQD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSFPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPSCMPEQD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq8 x y) + // result: (SGTUconst [1] (XOR (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTUconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSXOR, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqB x y) + // result: (XORconst [1] (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSXOR, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqPtr x y) + // result: (SGTUconst [1] (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTUconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSXOR, typ.UInt32) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpHmul32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul32 x y) + // result: (Select0 (MULT x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPSMULT, types.NewTuple(typ.Int32, typ.Int32)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpHmul32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul32u x y) + // result: (Select0 (MULTU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPSMULTU, types.NewTuple(typ.UInt32, typ.UInt32)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpIsInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (IsInBounds idx len) + // result: (SGTU len idx) + for { + idx := v_0 + len := v_1 + v.reset(OpMIPSSGTU) + v.AddArg2(len, idx) + return true + } +} +func rewriteValueMIPS_OpIsNonNil(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsNonNil ptr) + // result: (SGTU ptr (MOVWconst [0])) + for { + ptr := v_0 + v.reset(OpMIPSSGTU) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(ptr, v0) + return true + } +} +func rewriteValueMIPS_OpIsSliceInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsSliceInBounds idx len) + // result: (XORconst [1] (SGTU idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSSGTU, typ.Bool) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16 x y) + // result: (XORconst [1] (SGT (SignExt16to32 x) (SignExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSSGT, typ.Bool) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16U x y) + // result: (XORconst [1] (SGTU (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSSGTU, typ.Bool) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32 x y) + // result: (XORconst [1] (SGT x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSSGT, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32F x y) + // result: (FPFlagTrue (CMPGEF y x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSFPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPSCMPGEF, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32U x y) + // result: (XORconst [1] (SGTU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSSGTU, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64F x y) + // result: (FPFlagTrue (CMPGED y x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSFPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPSCMPGED, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8 x y) + // result: (XORconst [1] (SGT (SignExt8to32 x) (SignExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSSGT, typ.Bool) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8U x y) + // result: (XORconst [1] (SGTU (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSSGTU, typ.Bool) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16 x y) + // result: (SGT (SignExt16to32 y) (SignExt16to32 x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGT) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16U x y) + // result: (SGTU (ZeroExt16to32 y) (ZeroExt16to32 x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Less32 x y) + // result: (SGT y x) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGT) + v.AddArg2(y, x) + return true + } +} +func rewriteValueMIPS_OpLess32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32F x y) + // result: (FPFlagTrue (CMPGTF y x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSFPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPSCMPGTF, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Less32U x y) + // result: (SGTU y x) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTU) + v.AddArg2(y, x) + return true + } +} +func rewriteValueMIPS_OpLess64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64F x y) + // result: (FPFlagTrue (CMPGTD y x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSFPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPSCMPGTD, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8 x y) + // result: (SGT (SignExt8to32 y) (SignExt8to32 x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGT) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8U x y) + // result: (SGTU (ZeroExt8to32 y) (ZeroExt8to32 x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Load ptr mem) + // cond: t.IsBoolean() + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsBoolean()) { + break + } + v.reset(OpMIPSMOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is8BitInt(t) && t.IsSigned()) + // result: (MOVBload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpMIPSMOVBload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is8BitInt(t) && !t.IsSigned()) + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpMIPSMOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && t.IsSigned()) + // result: (MOVHload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpMIPSMOVHload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && !t.IsSigned()) + // result: (MOVHUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpMIPSMOVHUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is32BitInt(t) || isPtr(t)) + // result: (MOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) || isPtr(t)) { + break + } + v.reset(OpMIPSMOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (MOVFload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(OpMIPSMOVFload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (MOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(OpMIPSMOVDload) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (MOVWaddr {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(OpMIPSMOVWaddr) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (MOVWaddr {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(OpMIPSMOVWaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValueMIPS_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x16 x y) + // result: (CMOVZ (SLL x (ZeroExt16to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt16to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSLL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(v1) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueMIPS_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x32 x y) + // result: (CMOVZ (SLL x y) (MOVWconst [0]) (SGTUconst [32] y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueMIPS_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Lsh16x64 x (Const64 [c])) + // cond: uint32(c) < 16 + // result: (SLLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) < 16) { + break + } + v.reset(OpMIPSSLLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Lsh16x64 _ (Const64 [c])) + // cond: uint32(c) >= 16 + // result: (MOVWconst [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) >= 16) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x8 x y) + // result: (CMOVZ (SLL x (ZeroExt8to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt8to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSLL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(v1) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueMIPS_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x16 x y) + // result: (CMOVZ (SLL x (ZeroExt16to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt16to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSLL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(v1) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueMIPS_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x32 x y) + // result: (CMOVZ (SLL x y) (MOVWconst [0]) (SGTUconst [32] y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueMIPS_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Lsh32x64 x (Const64 [c])) + // cond: uint32(c) < 32 + // result: (SLLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) < 32) { + break + } + v.reset(OpMIPSSLLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Lsh32x64 _ (Const64 [c])) + // cond: uint32(c) >= 32 + // result: (MOVWconst [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) >= 32) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x8 x y) + // result: (CMOVZ (SLL x (ZeroExt8to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt8to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSLL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(v1) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueMIPS_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x16 x y) + // result: (CMOVZ (SLL x (ZeroExt16to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt16to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSLL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(v1) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueMIPS_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x32 x y) + // result: (CMOVZ (SLL x y) (MOVWconst [0]) (SGTUconst [32] y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueMIPS_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Lsh8x64 x (Const64 [c])) + // cond: uint32(c) < 8 + // result: (SLLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) < 8) { + break + } + v.reset(OpMIPSSLLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Lsh8x64 _ (Const64 [c])) + // cond: uint32(c) >= 8 + // result: (MOVWconst [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) >= 8) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x8 x y) + // result: (CMOVZ (SLL x (ZeroExt8to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt8to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSLL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(v1) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueMIPS_OpMIPSADD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADD x (MOVWconst [c])) + // cond: !t.IsPtr() + // result: (ADDconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + continue + } + t := v_1.Type + c := auxIntToInt32(v_1.AuxInt) + if !(!t.IsPtr()) { + continue + } + v.reset(OpMIPSADDconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ADD x (NEG y)) + // result: (SUB x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPSNEG { + continue + } + y := v_1.Args[0] + v.reset(OpMIPSSUB) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueMIPS_OpMIPSADDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDconst [off1] (MOVWaddr [off2] {sym} ptr)) + // result: (MOVWaddr [off1+off2] {sym} ptr) + for { + off1 := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + v.reset(OpMIPSMOVWaddr) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg(ptr) + return true + } + // match: (ADDconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ADDconst [c] (MOVWconst [d])) + // result: (MOVWconst [int32(c+d)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(c + d)) + return true + } + // match: (ADDconst [c] (ADDconst [d] x)) + // result: (ADDconst [c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSADDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpMIPSADDconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg(x) + return true + } + // match: (ADDconst [c] (SUBconst [d] x)) + // result: (ADDconst [c-d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSSUBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpMIPSADDconst) + v.AuxInt = int32ToAuxInt(c - d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSAND(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (AND x (MOVWconst [c])) + // result: (ANDconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpMIPSANDconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (AND x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (AND (SGTUconst [1] x) (SGTUconst [1] y)) + // result: (SGTUconst [1] (OR x y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMIPSSGTUconst || auxIntToInt32(v_0.AuxInt) != 1 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpMIPSSGTUconst || auxIntToInt32(v_1.AuxInt) != 1 { + continue + } + y := v_1.Args[0] + v.reset(OpMIPSSGTUconst) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSOR, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + return false +} +func rewriteValueMIPS_OpMIPSANDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDconst [0] _) + // result: (MOVWconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (ANDconst [-1] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != -1 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ANDconst [c] (MOVWconst [d])) + // result: (MOVWconst [c&d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(c & d) + return true + } + // match: (ANDconst [c] (ANDconst [d] x)) + // result: (ANDconst [c&d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSANDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpMIPSANDconst) + v.AuxInt = int32ToAuxInt(c & d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSCMOVZ(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVZ _ f (MOVWconst [0])) + // result: f + for { + f := v_1 + if v_2.Op != OpMIPSMOVWconst || auxIntToInt32(v_2.AuxInt) != 0 { + break + } + v.copyOf(f) + return true + } + // match: (CMOVZ a _ (MOVWconst [c])) + // cond: c!=0 + // result: a + for { + a := v_0 + if v_2.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + if !(c != 0) { + break + } + v.copyOf(a) + return true + } + // match: (CMOVZ a (MOVWconst [0]) c) + // result: (CMOVZzero a c) + for { + a := v_0 + if v_1.Op != OpMIPSMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + c := v_2 + v.reset(OpMIPSCMOVZzero) + v.AddArg2(a, c) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSCMOVZzero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CMOVZzero _ (MOVWconst [0])) + // result: (MOVWconst [0]) + for { + if v_1.Op != OpMIPSMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (CMOVZzero a (MOVWconst [c])) + // cond: c!=0 + // result: a + for { + a := v_0 + if v_1.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c != 0) { + break + } + v.copyOf(a) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSLoweredAtomicAdd(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredAtomicAdd ptr (MOVWconst [c]) mem) + // cond: is16Bit(int64(c)) + // result: (LoweredAtomicAddconst [c] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + if !(is16Bit(int64(c))) { + break + } + v.reset(OpMIPSLoweredAtomicAddconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSLoweredAtomicStore32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredAtomicStore32 ptr (MOVWconst [0]) mem) + // result: (LoweredAtomicStorezero ptr mem) + for { + ptr := v_0 + if v_1.Op != OpMIPSMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpMIPSLoweredAtomicStorezero) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSLoweredPanicBoundsRC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRC [kind] {p} (MOVWconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:int64(c), Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + mem := v_1 + v.reset(OpMIPSLoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: int64(c), Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSLoweredPanicBoundsRR(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRR [kind] x (MOVWconst [c]) mem) + // result: (LoweredPanicBoundsRC [kind] x {PanicBoundsC{C:int64(c)}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpMIPSLoweredPanicBoundsRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(c)}) + v.AddArg2(x, mem) + return true + } + // match: (LoweredPanicBoundsRR [kind] (MOVWconst [c]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:int64(c)}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + y := v_1 + mem := v_2 + v.reset(OpMIPSLoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(c)}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSLoweredPanicExtendRC(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicExtendRC [kind] {p} (MOVWconst [hi]) (MOVWconst [lo]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:int64(hi)<<32+int64(uint32(lo)), Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpMIPSMOVWconst { + break + } + hi := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpMIPSMOVWconst { + break + } + lo := auxIntToInt32(v_1.AuxInt) + mem := v_2 + v.reset(OpMIPSLoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: int64(hi)<<32 + int64(uint32(lo)), Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSLoweredPanicExtendRR(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicExtendRR [kind] hi lo (MOVWconst [c]) mem) + // result: (LoweredPanicExtendRC [kind] hi lo {PanicBoundsC{C:int64(c)}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + hi := v_0 + lo := v_1 + if v_2.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_2.AuxInt) + mem := v_3 + v.reset(OpMIPSLoweredPanicExtendRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(c)}) + v.AddArg3(hi, lo, mem) + return true + } + // match: (LoweredPanicExtendRR [kind] (MOVWconst [hi]) (MOVWconst [lo]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:int64(hi)<<32 + int64(uint32(lo))}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + hi := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpMIPSMOVWconst { + break + } + lo := auxIntToInt32(v_1.AuxInt) + y := v_2 + mem := v_3 + v.reset(OpMIPSLoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: int64(hi)<<32 + int64(uint32(lo))}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVBUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBUload [off1] {sym} x:(ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVBUload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVBUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVBUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVBUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVBUreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVBstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpMIPSMOVBUreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVBUreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVBUreg x:(MOVBUload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVBUload { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(MOVBUreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVBUreg { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(MOVBload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBUload [off] {sym} ptr mem) + for { + t := v.Type + x := v_0 + if x.Op != OpMIPSMOVBload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpMIPSMOVBUload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBUreg (ANDconst [c] x)) + // result: (ANDconst [c&0xff] x) + for { + if v_0.Op != OpMIPSANDconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpMIPSANDconst) + v.AuxInt = int32ToAuxInt(c & 0xff) + v.AddArg(x) + return true + } + // match: (MOVBUreg (MOVWconst [c])) + // result: (MOVWconst [int32(uint8(c))]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint8(c))) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVBload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBload [off1] {sym} x:(ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVBload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVBload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVBreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVBstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpMIPSMOVBreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVBreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVBreg x:(MOVBload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVBload { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVBreg { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBUload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBload [off] {sym} ptr mem) + for { + t := v.Type + x := v_0 + if x.Op != OpMIPSMOVBUload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpMIPSMOVBload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVBreg (ANDconst [c] x)) + // cond: c & 0x80 == 0 + // result: (ANDconst [c&0x7f] x) + for { + if v_0.Op != OpMIPSANDconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(c&0x80 == 0) { + break + } + v.reset(OpMIPSANDconst) + v.AuxInt = int32ToAuxInt(c & 0x7f) + v.AddArg(x) + return true + } + // match: (MOVBreg (MOVWconst [c])) + // result: (MOVWconst [int32(int8(c))]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(int8(c))) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstore [off1] {sym} x:(ADDconst [off2] ptr) val mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVBstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWconst [0]) mem) + // result: (MOVBstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpMIPSMOVBstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVBreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVBUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVBstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstorezero [off1] {sym} x:(ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVBstorezero [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVBstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstorezero [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVBstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVBstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDload [off1] {sym} x:(ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVDload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off] {sym} ptr (MOVDstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVDstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDstore [off1] {sym} x:(ADDconst [off2] ptr) val mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVDstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVFload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVFload [off] {sym} ptr (MOVWstore [off] {sym} ptr val _)) + // result: (MOVWgpfp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpMIPSMOVWgpfp) + v.AddArg(val) + return true + } + // match: (MOVFload [off1] {sym} x:(ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVFload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVFload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVFload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVFload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVFload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVFload [off] {sym} ptr (MOVFstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVFstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVFstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVFstore [off] {sym} ptr (MOVWgpfp val) mem) + // result: (MOVWstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVWgpfp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVFstore [off1] {sym} x:(ADDconst [off2] ptr) val mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVFstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVFstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVFstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVFstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVFstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVHUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHUload [off1] {sym} x:(ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVHUload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVHUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVHUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVHUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVHUreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVHstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpMIPSMOVHUreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVHUreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVHUreg x:(MOVBUload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVBUload { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVHUload { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVBUreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVBUreg { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVHUreg { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVHUload [off] {sym} ptr mem) + for { + t := v.Type + x := v_0 + if x.Op != OpMIPSMOVHload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpMIPSMOVHUload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVHUreg (ANDconst [c] x)) + // result: (ANDconst [c&0xffff] x) + for { + if v_0.Op != OpMIPSANDconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpMIPSANDconst) + v.AuxInt = int32ToAuxInt(c & 0xffff) + v.AddArg(x) + return true + } + // match: (MOVHUreg (MOVWconst [c])) + // result: (MOVWconst [int32(uint16(c))]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint16(c))) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVHload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHload [off1] {sym} x:(ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVHload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVHload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVHload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVHload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: (MOVHreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVHstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.reset(OpMIPSMOVHreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVHreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVHreg x:(MOVBload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVBload { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVBUload { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHload _ _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVHload { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVBreg { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVBUreg { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHreg _)) + // result: (MOVWreg x) + for { + x := v_0 + if x.Op != OpMIPSMOVHreg { + break + } + v.reset(OpMIPSMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHUload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVHload [off] {sym} ptr mem) + for { + t := v.Type + x := v_0 + if x.Op != OpMIPSMOVHUload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpMIPSMOVHload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVHreg (ANDconst [c] x)) + // cond: c & 0x8000 == 0 + // result: (ANDconst [c&0x7fff] x) + for { + if v_0.Op != OpMIPSANDconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(c&0x8000 == 0) { + break + } + v.reset(OpMIPSANDconst) + v.AuxInt = int32ToAuxInt(c & 0x7fff) + v.AddArg(x) + return true + } + // match: (MOVHreg (MOVWconst [c])) + // result: (MOVWconst [int32(int16(c))]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(int16(c))) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVHstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstore [off1] {sym} x:(ADDconst [off2] ptr) val mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVHstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVHstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVHstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVHstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWconst [0]) mem) + // result: (MOVHstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpMIPSMOVHstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVHstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstorezero [off1] {sym} x:(ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVHstorezero [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVHstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHstorezero [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVHstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVHstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWload [off] {sym} ptr (MOVFstore [off] {sym} ptr val _)) + // result: (MOVWfpgp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVFstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpMIPSMOVWfpgp) + v.AddArg(val) + return true + } + // match: (MOVWload [off1] {sym} x:(ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVWload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVWload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) + // cond: sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVWstore { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(sym == sym2 && off == off2 && isSamePtr(ptr, ptr2)) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVWnop(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWnop (MOVWconst [c])) + // result: (MOVWconst [c]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(c) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVWreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWreg x) + // cond: x.Uses == 1 + // result: (MOVWnop x) + for { + x := v_0 + if !(x.Uses == 1) { + break + } + v.reset(OpMIPSMOVWnop) + v.AddArg(x) + return true + } + // match: (MOVWreg (MOVWconst [c])) + // result: (MOVWconst [c]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(c) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstore [off] {sym} ptr (MOVWfpgp val) mem) + // result: (MOVFstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVWfpgp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVFstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off1] {sym} x:(ADDconst [off2] ptr) val mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVWstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWconst [0]) mem) + // result: (MOVWstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpMIPSMOVWstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPSMOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPSMOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMOVWstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstorezero [off1] {sym} x:(ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1+off2)) || x.Uses == 1) + // result: (MOVWstorezero [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if x.Op != OpMIPSADDconst { + break + } + off2 := auxIntToInt32(x.AuxInt) + ptr := x.Args[0] + mem := v_1 + if !(is16Bit(int64(off1+off2)) || x.Uses == 1) { + break + } + v.reset(OpMIPSMOVWstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstorezero [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) + // result: (MOVWstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPSMOVWaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2)) { + break + } + v.reset(OpMIPSMOVWstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSMUL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MUL (MOVWconst [0]) _ ) + // result: (MOVWconst [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMIPSMOVWconst || auxIntToInt32(v_0.AuxInt) != 0 { + continue + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + break + } + // match: (MUL (MOVWconst [1]) x ) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMIPSMOVWconst || auxIntToInt32(v_0.AuxInt) != 1 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (MUL (MOVWconst [-1]) x ) + // result: (NEG x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMIPSMOVWconst || auxIntToInt32(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.reset(OpMIPSNEG) + v.AddArg(x) + return true + } + break + } + // match: (MUL (MOVWconst [c]) x ) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SLLconst [int32(log32u(uint32(c)))] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMIPSMOVWconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + if !(isUnsignedPowerOfTwo(uint32(c))) { + continue + } + v.reset(OpMIPSSLLconst) + v.AuxInt = int32ToAuxInt(int32(log32u(uint32(c)))) + v.AddArg(x) + return true + } + break + } + // match: (MUL (MOVWconst [c]) (MOVWconst [d])) + // result: (MOVWconst [c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMIPSMOVWconst { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpMIPSMOVWconst { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(c * d) + return true + } + break + } + return false +} +func rewriteValueMIPS_OpMIPSNEG(v *Value) bool { + v_0 := v.Args[0] + // match: (NEG (SUB x y)) + // result: (SUB y x) + for { + if v_0.Op != OpMIPSSUB { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpMIPSSUB) + v.AddArg2(y, x) + return true + } + // match: (NEG (NEG x)) + // result: x + for { + if v_0.Op != OpMIPSNEG { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (NEG (MOVWconst [c])) + // result: (MOVWconst [-c]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(-c) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSNOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NOR x (MOVWconst [c])) + // result: (NORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpMIPSNORconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueMIPS_OpMIPSNORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (NORconst [c] (MOVWconst [d])) + // result: (MOVWconst [^(c|d)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(^(c | d)) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (OR x (MOVWconst [c])) + // result: (ORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpMIPSORconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (OR x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (OR (SGTUzero x) (SGTUzero y)) + // result: (SGTUzero (OR x y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMIPSSGTUzero { + continue + } + x := v_0.Args[0] + if v_1.Op != OpMIPSSGTUzero { + continue + } + y := v_1.Args[0] + v.reset(OpMIPSSGTUzero) + v0 := b.NewValue0(v.Pos, OpMIPSOR, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + return false +} +func rewriteValueMIPS_OpMIPSORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ORconst [-1] _) + // result: (MOVWconst [-1]) + for { + if auxIntToInt32(v.AuxInt) != -1 { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(-1) + return true + } + // match: (ORconst [c] (MOVWconst [d])) + // result: (MOVWconst [c|d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(c | d) + return true + } + // match: (ORconst [c] (ORconst [d] x)) + // result: (ORconst [c|d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSORconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpMIPSORconst) + v.AuxInt = int32ToAuxInt(c | d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSGT(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SGT (MOVWconst [c]) x) + // result: (SGTconst [c] x) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpMIPSSGTconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SGT x (MOVWconst [0])) + // result: (SGTzero x) + for { + x := v_0 + if v_1.Op != OpMIPSMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + v.reset(OpMIPSSGTzero) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSGTU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SGTU (MOVWconst [c]) x) + // result: (SGTUconst [c] x) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + x := v_1 + v.reset(OpMIPSSGTUconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SGTU x (MOVWconst [0])) + // result: (SGTUzero x) + for { + x := v_0 + if v_1.Op != OpMIPSMOVWconst || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + v.reset(OpMIPSSGTUzero) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSGTUconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SGTUconst [c] (MOVWconst [d])) + // cond: uint32(c) > uint32(d) + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + if !(uint32(c) > uint32(d)) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (MOVWconst [d])) + // cond: uint32(c) <= uint32(d) + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + if !(uint32(c) <= uint32(d)) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SGTUconst [c] (MOVBUreg _)) + // cond: 0xff < uint32(c) + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVBUreg || !(0xff < uint32(c)) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (MOVHUreg _)) + // cond: 0xffff < uint32(c) + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVHUreg || !(0xffff < uint32(c)) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (ANDconst [m] _)) + // cond: uint32(m) < uint32(c) + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSANDconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + if !(uint32(m) < uint32(c)) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (SRLconst _ [d])) + // cond: uint32(d) <= 31 && 0xffffffff>>uint32(d) < uint32(c) + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSSRLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + if !(uint32(d) <= 31 && 0xffffffff>>uint32(d) < uint32(c)) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSGTUzero(v *Value) bool { + v_0 := v.Args[0] + // match: (SGTUzero (MOVWconst [d])) + // cond: d != 0 + // result: (MOVWconst [1]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + if !(d != 0) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTUzero (MOVWconst [d])) + // cond: d == 0 + // result: (MOVWconst [0]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + if !(d == 0) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSGTconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SGTconst [c] (MOVWconst [d])) + // cond: c > d + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + if !(c > d) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVWconst [d])) + // cond: c <= d + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + if !(c <= d) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVBreg _)) + // cond: 0x7f < c + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVBreg || !(0x7f < c) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVBreg _)) + // cond: c <= -0x80 + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVBreg || !(c <= -0x80) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVBUreg _)) + // cond: 0xff < c + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVBUreg || !(0xff < c) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVBUreg _)) + // cond: c < 0 + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVBUreg || !(c < 0) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVHreg _)) + // cond: 0x7fff < c + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVHreg || !(0x7fff < c) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVHreg _)) + // cond: c <= -0x8000 + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVHreg || !(c <= -0x8000) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVHUreg _)) + // cond: 0xffff < c + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVHUreg || !(0xffff < c) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVHUreg _)) + // cond: c < 0 + // result: (MOVWconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVHUreg || !(c < 0) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SGTconst [c] (ANDconst [m] _)) + // cond: 0 <= m && m < c + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSANDconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + if !(0 <= m && m < c) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTconst [c] (SRLconst _ [d])) + // cond: 0 <= c && uint32(d) <= 31 && 0xffffffff>>uint32(d) < uint32(c) + // result: (MOVWconst [1]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSSRLconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + if !(0 <= c && uint32(d) <= 31 && 0xffffffff>>uint32(d) < uint32(c)) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSGTzero(v *Value) bool { + v_0 := v.Args[0] + // match: (SGTzero (MOVWconst [d])) + // cond: d > 0 + // result: (MOVWconst [1]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + if !(d > 0) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (SGTzero (MOVWconst [d])) + // cond: d <= 0 + // result: (MOVWconst [0]) + for { + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + if !(d <= 0) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLL x (MOVWconst [c])) + // result: (SLLconst x [c&31]) + for { + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpMIPSSLLconst) + v.AuxInt = int32ToAuxInt(c & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSLLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLLconst [c] (MOVWconst [d])) + // result: (MOVWconst [d<>uint32(c)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(d >> uint32(c)) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRL x (MOVWconst [c])) + // result: (SRLconst x [c&31]) + for { + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpMIPSSRLconst) + v.AuxInt = int32ToAuxInt(c & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSRLconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRLconst [c] (MOVWconst [d])) + // result: (MOVWconst [int32(uint32(d)>>uint32(c))]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint32(d) >> uint32(c))) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSUB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUB x (MOVWconst [c])) + // result: (SUBconst [c] x) + for { + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpMIPSSUBconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SUB x (NEG y)) + // result: (ADD x y) + for { + x := v_0 + if v_1.Op != OpMIPSNEG { + break + } + y := v_1.Args[0] + v.reset(OpMIPSADD) + v.AddArg2(x, y) + return true + } + // match: (SUB x x) + // result: (MOVWconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (SUB (MOVWconst [0]) x) + // result: (NEG x) + for { + if v_0.Op != OpMIPSMOVWconst || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpMIPSNEG) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSSUBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SUBconst [c] (MOVWconst [d])) + // result: (MOVWconst [d-c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(d - c) + return true + } + // match: (SUBconst [c] (SUBconst [d] x)) + // result: (ADDconst [-c-d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSSUBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpMIPSADDconst) + v.AuxInt = int32ToAuxInt(-c - d) + v.AddArg(x) + return true + } + // match: (SUBconst [c] (ADDconst [d] x)) + // result: (ADDconst [-c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSADDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpMIPSADDconst) + v.AuxInt = int32ToAuxInt(-c + d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSXOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XOR x (MOVWconst [c])) + // result: (XORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + continue + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (XOR x x) + // result: (MOVWconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS_OpMIPSXORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (XORconst [-1] x) + // result: (NORconst [0] x) + for { + if auxIntToInt32(v.AuxInt) != -1 { + break + } + x := v_0 + v.reset(OpMIPSNORconst) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(x) + return true + } + // match: (XORconst [c] (MOVWconst [d])) + // result: (MOVWconst [c^d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(c ^ d) + return true + } + // match: (XORconst [c] (XORconst [d] x)) + // result: (XORconst [c^d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpMIPSXORconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(c ^ d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16 x y) + // result: (Select0 (DIV (SignExt16to32 x) (SignExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPSDIV, types.NewTuple(typ.Int32, typ.Int32)) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16u x y) + // result: (Select0 (DIVU (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPSDIVU, types.NewTuple(typ.UInt32, typ.UInt32)) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32 x y) + // result: (Select0 (DIV x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPSDIV, types.NewTuple(typ.Int32, typ.Int32)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpMod32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32u x y) + // result: (Select0 (DIVU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPSDIVU, types.NewTuple(typ.UInt32, typ.UInt32)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (Select0 (DIV (SignExt8to32 x) (SignExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPSDIV, types.NewTuple(typ.Int32, typ.Int32)) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (Select0 (DIVU (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPSDIVU, types.NewTuple(typ.UInt32, typ.UInt32)) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (MOVBstore dst (MOVBUload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpMIPSMOVBstore) + v0 := b.NewValue0(v.Pos, OpMIPSMOVBUload, typ.UInt8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore dst (MOVHUload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPSMOVHstore) + v0 := b.NewValue0(v.Pos, OpMIPSMOVHUload, typ.UInt16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (MOVBstore [1] dst (MOVBUload [1] src mem) (MOVBstore dst (MOVBUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSMOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(1) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpMIPSMOVBUload, typ.UInt8) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [4] {t} dst src mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore dst (MOVWload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPSMOVWstore) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWload, typ.UInt32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [4] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [2] dst (MOVHUload [2] src mem) (MOVHstore dst (MOVHUload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPSMOVHstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpMIPSMOVHUload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPSMOVHstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpMIPSMOVHUload, typ.UInt16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [4] dst src mem) + // result: (MOVBstore [3] dst (MOVBUload [3] src mem) (MOVBstore [2] dst (MOVBUload [2] src mem) (MOVBstore [1] dst (MOVBUload [1] src mem) (MOVBstore dst (MOVBUload src mem) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpMIPSMOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpMIPSMOVBUload, typ.UInt8) + v2.AuxInt = int32ToAuxInt(2) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(1) + v4 := b.NewValue0(v.Pos, OpMIPSMOVBUload, typ.UInt8) + v4.AuxInt = int32ToAuxInt(1) + v4.AddArg2(src, mem) + v5 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v6 := b.NewValue0(v.Pos, OpMIPSMOVBUload, typ.UInt8) + v6.AddArg2(src, mem) + v5.AddArg3(dst, v6, mem) + v3.AddArg3(dst, v4, v5) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [3] dst src mem) + // result: (MOVBstore [2] dst (MOVBUload [2] src mem) (MOVBstore [1] dst (MOVBUload [1] src mem) (MOVBstore dst (MOVBUload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpMIPSMOVBUload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpMIPSMOVBUload, typ.UInt8) + v2.AuxInt = int32ToAuxInt(1) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpMIPSMOVBUload, typ.UInt8) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [8] {t} dst src mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [4] dst (MOVWload [4] src mem) (MOVWstore dst (MOVWload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPSMOVWstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [8] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [6] dst (MOVHload [6] src mem) (MOVHstore [4] dst (MOVHload [4] src mem) (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPSMOVHstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpMIPSMOVHload, typ.Int16) + v0.AuxInt = int32ToAuxInt(6) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPSMOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpMIPSMOVHload, typ.Int16) + v2.AuxInt = int32ToAuxInt(4) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPSMOVHstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(2) + v4 := b.NewValue0(v.Pos, OpMIPSMOVHload, typ.Int16) + v4.AuxInt = int32ToAuxInt(2) + v4.AddArg2(src, mem) + v5 := b.NewValue0(v.Pos, OpMIPSMOVHstore, types.TypeMem) + v6 := b.NewValue0(v.Pos, OpMIPSMOVHload, typ.Int16) + v6.AddArg2(src, mem) + v5.AddArg3(dst, v6, mem) + v3.AddArg3(dst, v4, v5) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [6] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [4] dst (MOVHload [4] src mem) (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPSMOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpMIPSMOVHload, typ.Int16) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPSMOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpMIPSMOVHload, typ.Int16) + v2.AuxInt = int32ToAuxInt(2) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPSMOVHstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpMIPSMOVHload, typ.Int16) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [12] {t} dst src mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [8] dst (MOVWload [8] src mem) (MOVWstore [4] dst (MOVWload [4] src mem) (MOVWstore dst (MOVWload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPSMOVWstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWload, typ.UInt32) + v2.AuxInt = int32ToAuxInt(4) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpMIPSMOVWload, typ.UInt32) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [16] {t} dst src mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [12] dst (MOVWload [12] src mem) (MOVWstore [8] dst (MOVWload [8] src mem) (MOVWstore [4] dst (MOVWload [4] src mem) (MOVWstore dst (MOVWload src mem) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPSMOVWstore) + v.AuxInt = int32ToAuxInt(12) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWload, typ.UInt32) + v0.AuxInt = int32ToAuxInt(12) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(8) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWload, typ.UInt32) + v2.AuxInt = int32ToAuxInt(8) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(4) + v4 := b.NewValue0(v.Pos, OpMIPSMOVWload, typ.UInt32) + v4.AuxInt = int32ToAuxInt(4) + v4.AddArg2(src, mem) + v5 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v6 := b.NewValue0(v.Pos, OpMIPSMOVWload, typ.UInt32) + v6.AddArg2(src, mem) + v5.AddArg3(dst, v6, mem) + v3.AddArg3(dst, v4, v5) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] {t} dst src mem) + // cond: (s > 16 && logLargeCopy(v, s) || t.Alignment()%4 != 0) + // result: (LoweredMove [int32(t.Alignment())] dst src (ADDconst src [int32(s-moveSize(t.Alignment(), config))]) mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 16 && logLargeCopy(v, s) || t.Alignment()%4 != 0) { + break + } + v.reset(OpMIPSLoweredMove) + v.AuxInt = int32ToAuxInt(int32(t.Alignment())) + v0 := b.NewValue0(v.Pos, OpMIPSADDconst, src.Type) + v0.AuxInt = int32ToAuxInt(int32(s - moveSize(t.Alignment(), config))) + v0.AddArg(src) + v.AddArg4(dst, src, v0, mem) + return true + } + return false +} +func rewriteValueMIPS_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq16 x y) + // result: (SGTU (XOR (ZeroExt16to32 x) (ZeroExt16to32 y)) (MOVWconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTU) + v0 := b.NewValue0(v.Pos, OpMIPSXOR, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq32 x y) + // result: (SGTU (XOR x y) (MOVWconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTU) + v0 := b.NewValue0(v.Pos, OpMIPSXOR, typ.UInt32) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpNeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32F x y) + // result: (FPFlagFalse (CMPEQF x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSFPFlagFalse) + v0 := b.NewValue0(v.Pos, OpMIPSCMPEQF, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpNeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64F x y) + // result: (FPFlagFalse (CMPEQD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSFPFlagFalse) + v0 := b.NewValue0(v.Pos, OpMIPSCMPEQD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq8 x y) + // result: (SGTU (XOR (ZeroExt8to32 x) (ZeroExt8to32 y)) (MOVWconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTU) + v0 := b.NewValue0(v.Pos, OpMIPSXOR, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NeqPtr x y) + // result: (SGTU (XOR x y) (MOVWconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSGTU) + v0 := b.NewValue0(v.Pos, OpMIPSXOR, typ.UInt32) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpNot(v *Value) bool { + v_0 := v.Args[0] + // match: (Not x) + // result: (XORconst [1] x) + for { + x := v_0 + v.reset(OpMIPSXORconst) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueMIPS_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + // match: (OffPtr [off] ptr:(SP)) + // result: (MOVWaddr [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + if ptr.Op != OpSP { + break + } + v.reset(OpMIPSMOVWaddr) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } + // match: (OffPtr [off] ptr) + // result: (ADDconst [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + v.reset(OpMIPSADDconst) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } +} +func rewriteValueMIPS_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft16 x (MOVWconst [c])) + // result: (Or16 (Lsh16x32 x (MOVWconst [c&15])) (Rsh16Ux32 x (MOVWconst [-c&15]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpLsh16x32, t) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(c & 15) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh16Ux32, t) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(-c & 15) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueMIPS_OpRotateLeft32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft32 x (MOVWconst [c])) + // result: (Or32 (Lsh32x32 x (MOVWconst [c&31])) (Rsh32Ux32 x (MOVWconst [-c&31]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpOr32) + v0 := b.NewValue0(v.Pos, OpLsh32x32, t) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(c & 31) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh32Ux32, t) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(-c & 31) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueMIPS_OpRotateLeft64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft64 x (MOVWconst [c])) + // result: (Or64 (Lsh64x32 x (MOVWconst [c&63])) (Rsh64Ux32 x (MOVWconst [-c&63]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpOr64) + v0 := b.NewValue0(v.Pos, OpLsh64x32, t) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(c & 63) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh64Ux32, t) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(-c & 63) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueMIPS_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft8 x (MOVWconst [c])) + // result: (Or8 (Lsh8x32 x (MOVWconst [c&7])) (Rsh8Ux32 x (MOVWconst [-c&7]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpLsh8x32, t) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(c & 7) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh8Ux32, t) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(-c & 7) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueMIPS_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux16 x y) + // result: (CMOVZ (SRL (ZeroExt16to32 x) (ZeroExt16to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt16to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v4.AuxInt = int32ToAuxInt(32) + v4.AddArg(v2) + v.AddArg3(v0, v3, v4) + return true + } +} +func rewriteValueMIPS_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux32 x y) + // result: (CMOVZ (SRL (ZeroExt16to32 x) y) (MOVWconst [0]) (SGTUconst [32] y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueMIPS_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 x (Const64 [c])) + // cond: uint32(c) < 16 + // result: (SRLconst (SLLconst x [16]) [int32(c+16)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) < 16) { + break + } + v.reset(OpMIPSSRLconst) + v.AuxInt = int32ToAuxInt(int32(c + 16)) + v0 := b.NewValue0(v.Pos, OpMIPSSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh16Ux64 _ (Const64 [c])) + // cond: uint32(c) >= 16 + // result: (MOVWconst [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) >= 16) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux8 x y) + // result: (CMOVZ (SRL (ZeroExt16to32 x) (ZeroExt8to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt8to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v4.AuxInt = int32ToAuxInt(32) + v4.AddArg(v2) + v.AddArg3(v0, v3, v4) + return true + } +} +func rewriteValueMIPS_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x16 x y) + // result: (SRA (SignExt16to32 x) ( CMOVZ (ZeroExt16to32 y) (MOVWconst [31]) (SGTUconst [32] (ZeroExt16to32 y)))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPSCMOVZ, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(31) + v4 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v4.AuxInt = int32ToAuxInt(32) + v4.AddArg(v2) + v1.AddArg3(v2, v3, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x32 x y) + // result: (SRA (SignExt16to32 x) ( CMOVZ y (MOVWconst [31]) (SGTUconst [32] y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPSCMOVZ, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(31) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(y) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 x (Const64 [c])) + // cond: uint32(c) < 16 + // result: (SRAconst (SLLconst x [16]) [int32(c+16)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) < 16) { + break + } + v.reset(OpMIPSSRAconst) + v.AuxInt = int32ToAuxInt(int32(c + 16)) + v0 := b.NewValue0(v.Pos, OpMIPSSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh16x64 x (Const64 [c])) + // cond: uint32(c) >= 16 + // result: (SRAconst (SLLconst x [16]) [31]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) >= 16) { + break + } + v.reset(OpMIPSSRAconst) + v.AuxInt = int32ToAuxInt(31) + v0 := b.NewValue0(v.Pos, OpMIPSSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueMIPS_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x8 x y) + // result: (SRA (SignExt16to32 x) ( CMOVZ (ZeroExt8to32 y) (MOVWconst [31]) (SGTUconst [32] (ZeroExt8to32 y)))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPSCMOVZ, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(31) + v4 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v4.AuxInt = int32ToAuxInt(32) + v4.AddArg(v2) + v1.AddArg3(v2, v3, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux16 x y) + // result: (CMOVZ (SRL x (ZeroExt16to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt16to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(v1) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueMIPS_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux32 x y) + // result: (CMOVZ (SRL x y) (MOVWconst [0]) (SGTUconst [32] y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueMIPS_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Rsh32Ux64 x (Const64 [c])) + // cond: uint32(c) < 32 + // result: (SRLconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) < 32) { + break + } + v.reset(OpMIPSSRLconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Rsh32Ux64 _ (Const64 [c])) + // cond: uint32(c) >= 32 + // result: (MOVWconst [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) >= 32) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux8 x y) + // result: (CMOVZ (SRL x (ZeroExt8to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt8to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(v1) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueMIPS_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x16 x y) + // result: (SRA x ( CMOVZ (ZeroExt16to32 y) (MOVWconst [31]) (SGTUconst [32] (ZeroExt16to32 y)))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSRA) + v0 := b.NewValue0(v.Pos, OpMIPSCMOVZ, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(31) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(v1) + v0.AddArg3(v1, v2, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueMIPS_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x32 x y) + // result: (SRA x ( CMOVZ y (MOVWconst [31]) (SGTUconst [32] y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSRA) + v0 := b.NewValue0(v.Pos, OpMIPSCMOVZ, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(31) + v2 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueMIPS_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Rsh32x64 x (Const64 [c])) + // cond: uint32(c) < 32 + // result: (SRAconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) < 32) { + break + } + v.reset(OpMIPSSRAconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (Rsh32x64 x (Const64 [c])) + // cond: uint32(c) >= 32 + // result: (SRAconst x [31]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) >= 32) { + break + } + v.reset(OpMIPSSRAconst) + v.AuxInt = int32ToAuxInt(31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x8 x y) + // result: (SRA x ( CMOVZ (ZeroExt8to32 y) (MOVWconst [31]) (SGTUconst [32] (ZeroExt8to32 y)))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSRA) + v0 := b.NewValue0(v.Pos, OpMIPSCMOVZ, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(31) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(v1) + v0.AddArg3(v1, v2, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueMIPS_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux16 x y) + // result: (CMOVZ (SRL (ZeroExt8to32 x) (ZeroExt16to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt16to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v4.AuxInt = int32ToAuxInt(32) + v4.AddArg(v2) + v.AddArg3(v0, v3, v4) + return true + } +} +func rewriteValueMIPS_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux32 x y) + // result: (CMOVZ (SRL (ZeroExt8to32 x) y) (MOVWconst [0]) (SGTUconst [32] y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueMIPS_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 x (Const64 [c])) + // cond: uint32(c) < 8 + // result: (SRLconst (SLLconst x [24]) [int32(c+24)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) < 8) { + break + } + v.reset(OpMIPSSRLconst) + v.AuxInt = int32ToAuxInt(int32(c + 24)) + v0 := b.NewValue0(v.Pos, OpMIPSSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(24) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh8Ux64 _ (Const64 [c])) + // cond: uint32(c) >= 8 + // result: (MOVWconst [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) >= 8) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux8 x y) + // result: (CMOVZ (SRL (ZeroExt8to32 x) (ZeroExt8to32 y) ) (MOVWconst [0]) (SGTUconst [32] (ZeroExt8to32 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSSRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v4.AuxInt = int32ToAuxInt(32) + v4.AddArg(v2) + v.AddArg3(v0, v3, v4) + return true + } +} +func rewriteValueMIPS_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x16 x y) + // result: (SRA (SignExt16to32 x) ( CMOVZ (ZeroExt16to32 y) (MOVWconst [31]) (SGTUconst [32] (ZeroExt16to32 y)))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPSCMOVZ, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(31) + v4 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v4.AuxInt = int32ToAuxInt(32) + v4.AddArg(v2) + v1.AddArg3(v2, v3, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x32 x y) + // result: (SRA (SignExt16to32 x) ( CMOVZ y (MOVWconst [31]) (SGTUconst [32] y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPSCMOVZ, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v2.AuxInt = int32ToAuxInt(31) + v3 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v3.AuxInt = int32ToAuxInt(32) + v3.AddArg(y) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x64 x (Const64 [c])) + // cond: uint32(c) < 8 + // result: (SRAconst (SLLconst x [24]) [int32(c+24)]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) < 8) { + break + } + v.reset(OpMIPSSRAconst) + v.AuxInt = int32ToAuxInt(int32(c + 24)) + v0 := b.NewValue0(v.Pos, OpMIPSSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(24) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh8x64 x (Const64 [c])) + // cond: uint32(c) >= 8 + // result: (SRAconst (SLLconst x [24]) [31]) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint32(c) >= 8) { + break + } + v.reset(OpMIPSSRAconst) + v.AuxInt = int32ToAuxInt(31) + v0 := b.NewValue0(v.Pos, OpMIPSSLLconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(24) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueMIPS_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x8 x y) + // result: (SRA (SignExt16to32 x) ( CMOVZ (ZeroExt8to32 y) (MOVWconst [31]) (SGTUconst [32] (ZeroExt8to32 y)))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPSSRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPSCMOVZ, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v3.AuxInt = int32ToAuxInt(31) + v4 := b.NewValue0(v.Pos, OpMIPSSGTUconst, typ.Bool) + v4.AuxInt = int32ToAuxInt(32) + v4.AddArg(v2) + v1.AddArg3(v2, v3, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select0 (Add32carry x y)) + // result: (ADD x y) + for { + if v_0.Op != OpAdd32carry { + break + } + t := v_0.Type + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpMIPSADD) + v.Type = t.FieldType(0) + v.AddArg2(x, y) + return true + } + // match: (Select0 (Add32carrywithcarry x y c)) + // result: (ADD c (ADD x y)) + for { + if v_0.Op != OpAdd32carrywithcarry { + break + } + t := v_0.Type + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpMIPSADD) + v.Type = t.FieldType(0) + v0 := b.NewValue0(v.Pos, OpMIPSADD, t.FieldType(0)) + v0.AddArg2(x, y) + v.AddArg2(c, v0) + return true + } + // match: (Select0 (Sub32carry x y)) + // result: (SUB x y) + for { + if v_0.Op != OpSub32carry { + break + } + t := v_0.Type + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpMIPSSUB) + v.Type = t.FieldType(0) + v.AddArg2(x, y) + return true + } + // match: (Select0 (MULTU (MOVWconst [0]) _ )) + // result: (MOVWconst [0]) + for { + if v_0.Op != OpMIPSMULTU { + break + } + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPSMOVWconst || auxIntToInt32(v_0_0.AuxInt) != 0 { + continue + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + break + } + // match: (Select0 (MULTU (MOVWconst [1]) _ )) + // result: (MOVWconst [0]) + for { + if v_0.Op != OpMIPSMULTU { + break + } + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPSMOVWconst || auxIntToInt32(v_0_0.AuxInt) != 1 { + continue + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + break + } + // match: (Select0 (MULTU (MOVWconst [-1]) x )) + // result: (CMOVZ (ADDconst [-1] x) (MOVWconst [0]) x) + for { + if v_0.Op != OpMIPSMULTU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPSMOVWconst || auxIntToInt32(v_0_0.AuxInt) != -1 { + continue + } + x := v_0_1 + v.reset(OpMIPSCMOVZ) + v0 := b.NewValue0(v.Pos, OpMIPSADDconst, x.Type) + v0.AuxInt = int32ToAuxInt(-1) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0) + v.AddArg3(v0, v1, x) + return true + } + break + } + // match: (Select0 (MULTU (MOVWconst [c]) x )) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SRLconst [int32(32-log32u(uint32(c)))] x) + for { + if v_0.Op != OpMIPSMULTU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPSMOVWconst { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + x := v_0_1 + if !(isUnsignedPowerOfTwo(uint32(c))) { + continue + } + v.reset(OpMIPSSRLconst) + v.AuxInt = int32ToAuxInt(int32(32 - log32u(uint32(c)))) + v.AddArg(x) + return true + } + break + } + // match: (Select0 (MULTU (MOVWconst [c]) (MOVWconst [d]))) + // result: (MOVWconst [int32((int64(uint32(c))*int64(uint32(d)))>>32)]) + for { + if v_0.Op != OpMIPSMULTU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPSMOVWconst { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_0_1.Op != OpMIPSMOVWconst { + continue + } + d := auxIntToInt32(v_0_1.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32((int64(uint32(c)) * int64(uint32(d))) >> 32)) + return true + } + break + } + // match: (Select0 (DIV (MOVWconst [c]) (MOVWconst [d]))) + // cond: d != 0 + // result: (MOVWconst [c%d]) + for { + if v_0.Op != OpMIPSDIV { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(c % d) + return true + } + // match: (Select0 (DIVU (MOVWconst [c]) (MOVWconst [d]))) + // cond: d != 0 + // result: (MOVWconst [int32(uint32(c)%uint32(d))]) + for { + if v_0.Op != OpMIPSDIVU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) % uint32(d))) + return true + } + return false +} +func rewriteValueMIPS_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select1 (Add32carry x y)) + // result: (SGTU x (ADD x y)) + for { + if v_0.Op != OpAdd32carry { + break + } + t := v_0.Type + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpMIPSSGTU) + v.Type = typ.Bool + v0 := b.NewValue0(v.Pos, OpMIPSADD, t.FieldType(0)) + v0.AddArg2(x, y) + v.AddArg2(x, v0) + return true + } + // match: (Select1 (Add32carrywithcarry x y c)) + // result: (OR (SGTU x xy:(ADD x y)) (SGTU xy (ADD c xy))) + for { + if v_0.Op != OpAdd32carrywithcarry { + break + } + t := v_0.Type + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpMIPSOR) + v.Type = typ.Bool + v0 := b.NewValue0(v.Pos, OpMIPSSGTU, typ.Bool) + xy := b.NewValue0(v.Pos, OpMIPSADD, t.FieldType(0)) + xy.AddArg2(x, y) + v0.AddArg2(x, xy) + v2 := b.NewValue0(v.Pos, OpMIPSSGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpMIPSADD, t.FieldType(0)) + v3.AddArg2(c, xy) + v2.AddArg2(xy, v3) + v.AddArg2(v0, v2) + return true + } + // match: (Select1 (Sub32carry x y)) + // result: (SGTU (SUB x y) x) + for { + if v_0.Op != OpSub32carry { + break + } + t := v_0.Type + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpMIPSSGTU) + v.Type = typ.Bool + v0 := b.NewValue0(v.Pos, OpMIPSSUB, t.FieldType(0)) + v0.AddArg2(x, y) + v.AddArg2(v0, x) + return true + } + // match: (Select1 (MULTU (MOVWconst [0]) _ )) + // result: (MOVWconst [0]) + for { + if v_0.Op != OpMIPSMULTU { + break + } + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPSMOVWconst || auxIntToInt32(v_0_0.AuxInt) != 0 { + continue + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(0) + return true + } + break + } + // match: (Select1 (MULTU (MOVWconst [1]) x )) + // result: x + for { + if v_0.Op != OpMIPSMULTU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPSMOVWconst || auxIntToInt32(v_0_0.AuxInt) != 1 { + continue + } + x := v_0_1 + v.copyOf(x) + return true + } + break + } + // match: (Select1 (MULTU (MOVWconst [-1]) x )) + // result: (NEG x) + for { + if v_0.Op != OpMIPSMULTU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPSMOVWconst || auxIntToInt32(v_0_0.AuxInt) != -1 { + continue + } + x := v_0_1 + v.reset(OpMIPSNEG) + v.Type = x.Type + v.AddArg(x) + return true + } + break + } + // match: (Select1 (MULTU (MOVWconst [c]) x )) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (SLLconst [int32(log32u(uint32(c)))] x) + for { + if v_0.Op != OpMIPSMULTU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPSMOVWconst { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + x := v_0_1 + if !(isUnsignedPowerOfTwo(uint32(c))) { + continue + } + v.reset(OpMIPSSLLconst) + v.AuxInt = int32ToAuxInt(int32(log32u(uint32(c)))) + v.AddArg(x) + return true + } + break + } + // match: (Select1 (MULTU (MOVWconst [c]) (MOVWconst [d]))) + // result: (MOVWconst [int32(uint32(c)*uint32(d))]) + for { + if v_0.Op != OpMIPSMULTU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPSMOVWconst { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_0_1.Op != OpMIPSMOVWconst { + continue + } + d := auxIntToInt32(v_0_1.AuxInt) + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) * uint32(d))) + return true + } + break + } + // match: (Select1 (DIV (MOVWconst [c]) (MOVWconst [d]))) + // cond: d != 0 + // result: (MOVWconst [c/d]) + for { + if v_0.Op != OpMIPSDIV { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(c / d) + return true + } + // match: (Select1 (DIVU (MOVWconst [c]) (MOVWconst [d]))) + // cond: d != 0 + // result: (MOVWconst [int32(uint32(c)/uint32(d))]) + for { + if v_0.Op != OpMIPSDIVU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpMIPSMOVWconst { + break + } + c := auxIntToInt32(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPSMOVWconst { + break + } + d := auxIntToInt32(v_0_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpMIPSMOVWconst) + v.AuxInt = int32ToAuxInt(int32(uint32(c) / uint32(d))) + return true + } + return false +} +func rewriteValueMIPS_OpSignmask(v *Value) bool { + v_0 := v.Args[0] + // match: (Signmask x) + // result: (SRAconst x [31]) + for { + x := v_0 + v.reset(OpMIPSSRAconst) + v.AuxInt = int32ToAuxInt(31) + v.AddArg(x) + return true + } +} +func rewriteValueMIPS_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Slicemask x) + // result: (SRAconst (NEG x) [31]) + for { + t := v.Type + x := v_0 + v.reset(OpMIPSSRAconst) + v.AuxInt = int32ToAuxInt(31) + v0 := b.NewValue0(v.Pos, OpMIPSNEG, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (MOVBstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(OpMIPSMOVBstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (MOVHstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(OpMIPSMOVHstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && !t.IsFloat() + // result: (MOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && !t.IsFloat()) { + break + } + v.reset(OpMIPSMOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && t.IsFloat() + // result: (MOVFstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && t.IsFloat()) { + break + } + v.reset(OpMIPSMOVFstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && t.IsFloat() + // result: (MOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && t.IsFloat()) { + break + } + v.reset(OpMIPSMOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueMIPS_OpSub32withcarry(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Sub32withcarry x y c) + // result: (SUB (SUB x y) c) + for { + t := v.Type + x := v_0 + y := v_1 + c := v_2 + v.reset(OpMIPSSUB) + v0 := b.NewValue0(v.Pos, OpMIPSSUB, t) + v0.AddArg2(x, y) + v.AddArg2(v0, c) + return true + } +} +func rewriteValueMIPS_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] ptr mem) + // result: (MOVBstore ptr (MOVWconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpMIPSMOVBstore) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [2] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore ptr (MOVWconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPSMOVHstore) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [2] ptr mem) + // result: (MOVBstore [1] ptr (MOVWconst [0]) (MOVBstore [0] ptr (MOVWconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [4] {t} ptr mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore ptr (MOVWconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPSMOVWstore) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [4] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [2] ptr (MOVWconst [0]) (MOVHstore [0] ptr (MOVWconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPSMOVHstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPSMOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [4] ptr mem) + // result: (MOVBstore [3] ptr (MOVWconst [0]) (MOVBstore [2] ptr (MOVWconst [0]) (MOVBstore [1] ptr (MOVWconst [0]) (MOVBstore [0] ptr (MOVWconst [0]) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(1) + v3 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(0) + v3.AddArg3(ptr, v0, mem) + v2.AddArg3(ptr, v0, v3) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [3] ptr mem) + // result: (MOVBstore [2] ptr (MOVWconst [0]) (MOVBstore [1] ptr (MOVWconst [0]) (MOVBstore [0] ptr (MOVWconst [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpMIPSMOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpMIPSMOVBstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(0) + v2.AddArg3(ptr, v0, mem) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [6] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [4] ptr (MOVWconst [0]) (MOVHstore [2] ptr (MOVWconst [0]) (MOVHstore [0] ptr (MOVWconst [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPSMOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPSMOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpMIPSMOVHstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(0) + v2.AddArg3(ptr, v0, mem) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [8] {t} ptr mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [4] ptr (MOVWconst [0]) (MOVWstore [0] ptr (MOVWconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPSMOVWstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [12] {t} ptr mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [8] ptr (MOVWconst [0]) (MOVWstore [4] ptr (MOVWconst [0]) (MOVWstore [0] ptr (MOVWconst [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPSMOVWstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(0) + v2.AddArg3(ptr, v0, mem) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [16] {t} ptr mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [12] ptr (MOVWconst [0]) (MOVWstore [8] ptr (MOVWconst [0]) (MOVWstore [4] ptr (MOVWconst [0]) (MOVWstore [0] ptr (MOVWconst [0]) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPSMOVWstore) + v.AuxInt = int32ToAuxInt(12) + v0 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(8) + v2 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(4) + v3 := b.NewValue0(v.Pos, OpMIPSMOVWstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(0) + v3.AddArg3(ptr, v0, mem) + v2.AddArg3(ptr, v0, v3) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [s] {t} ptr mem) + // cond: (s > 16 || t.Alignment()%4 != 0) + // result: (LoweredZero [int32(t.Alignment())] ptr (ADDconst ptr [int32(s-moveSize(t.Alignment(), config))]) mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(s > 16 || t.Alignment()%4 != 0) { + break + } + v.reset(OpMIPSLoweredZero) + v.AuxInt = int32ToAuxInt(int32(t.Alignment())) + v0 := b.NewValue0(v.Pos, OpMIPSADDconst, ptr.Type) + v0.AuxInt = int32ToAuxInt(int32(s - moveSize(t.Alignment(), config))) + v0.AddArg(ptr) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValueMIPS_OpZeromask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Zeromask x) + // result: (NEG (SGTU x (MOVWconst [0]))) + for { + x := v_0 + v.reset(OpMIPSNEG) + v0 := b.NewValue0(v.Pos, OpMIPSSGTU, typ.Bool) + v1 := b.NewValue0(v.Pos, OpMIPSMOVWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(0) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } +} +func rewriteBlockMIPS(b *Block) bool { + switch b.Kind { + case BlockMIPSEQ: + // match: (EQ (FPFlagTrue cmp) yes no) + // result: (FPF cmp yes no) + for b.Controls[0].Op == OpMIPSFPFlagTrue { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockMIPSFPF, cmp) + return true + } + // match: (EQ (FPFlagFalse cmp) yes no) + // result: (FPT cmp yes no) + for b.Controls[0].Op == OpMIPSFPFlagFalse { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockMIPSFPT, cmp) + return true + } + // match: (EQ (XORconst [1] cmp:(SGT _ _)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGT { + break + } + b.resetWithControl(BlockMIPSNE, cmp) + return true + } + // match: (EQ (XORconst [1] cmp:(SGTU _ _)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGTU { + break + } + b.resetWithControl(BlockMIPSNE, cmp) + return true + } + // match: (EQ (XORconst [1] cmp:(SGTconst _)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGTconst { + break + } + b.resetWithControl(BlockMIPSNE, cmp) + return true + } + // match: (EQ (XORconst [1] cmp:(SGTUconst _)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGTUconst { + break + } + b.resetWithControl(BlockMIPSNE, cmp) + return true + } + // match: (EQ (XORconst [1] cmp:(SGTzero _)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGTzero { + break + } + b.resetWithControl(BlockMIPSNE, cmp) + return true + } + // match: (EQ (XORconst [1] cmp:(SGTUzero _)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGTUzero { + break + } + b.resetWithControl(BlockMIPSNE, cmp) + return true + } + // match: (EQ (SGTUconst [1] x) yes no) + // result: (NE x yes no) + for b.Controls[0].Op == OpMIPSSGTUconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockMIPSNE, x) + return true + } + // match: (EQ (SGTUzero x) yes no) + // result: (EQ x yes no) + for b.Controls[0].Op == OpMIPSSGTUzero { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockMIPSEQ, x) + return true + } + // match: (EQ (SGTconst [0] x) yes no) + // result: (GEZ x yes no) + for b.Controls[0].Op == OpMIPSSGTconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockMIPSGEZ, x) + return true + } + // match: (EQ (SGTzero x) yes no) + // result: (LEZ x yes no) + for b.Controls[0].Op == OpMIPSSGTzero { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockMIPSLEZ, x) + return true + } + // match: (EQ (MOVWconst [0]) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + b.Reset(BlockFirst) + return true + } + // match: (EQ (MOVWconst [c]) yes no) + // cond: c != 0 + // result: (First no yes) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + if !(c != 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockMIPSGEZ: + // match: (GEZ (MOVWconst [c]) yes no) + // cond: c >= 0 + // result: (First yes no) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + if !(c >= 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GEZ (MOVWconst [c]) yes no) + // cond: c < 0 + // result: (First no yes) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + if !(c < 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockMIPSGTZ: + // match: (GTZ (MOVWconst [c]) yes no) + // cond: c > 0 + // result: (First yes no) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + if !(c > 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GTZ (MOVWconst [c]) yes no) + // cond: c <= 0 + // result: (First no yes) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + if !(c <= 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockIf: + // match: (If cond yes no) + // result: (NE cond yes no) + for { + cond := b.Controls[0] + b.resetWithControl(BlockMIPSNE, cond) + return true + } + case BlockMIPSLEZ: + // match: (LEZ (MOVWconst [c]) yes no) + // cond: c <= 0 + // result: (First yes no) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + if !(c <= 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LEZ (MOVWconst [c]) yes no) + // cond: c > 0 + // result: (First no yes) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + if !(c > 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockMIPSLTZ: + // match: (LTZ (MOVWconst [c]) yes no) + // cond: c < 0 + // result: (First yes no) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + if !(c < 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LTZ (MOVWconst [c]) yes no) + // cond: c >= 0 + // result: (First no yes) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + if !(c >= 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockMIPSNE: + // match: (NE (FPFlagTrue cmp) yes no) + // result: (FPT cmp yes no) + for b.Controls[0].Op == OpMIPSFPFlagTrue { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockMIPSFPT, cmp) + return true + } + // match: (NE (FPFlagFalse cmp) yes no) + // result: (FPF cmp yes no) + for b.Controls[0].Op == OpMIPSFPFlagFalse { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockMIPSFPF, cmp) + return true + } + // match: (NE (XORconst [1] cmp:(SGT _ _)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGT { + break + } + b.resetWithControl(BlockMIPSEQ, cmp) + return true + } + // match: (NE (XORconst [1] cmp:(SGTU _ _)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGTU { + break + } + b.resetWithControl(BlockMIPSEQ, cmp) + return true + } + // match: (NE (XORconst [1] cmp:(SGTconst _)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGTconst { + break + } + b.resetWithControl(BlockMIPSEQ, cmp) + return true + } + // match: (NE (XORconst [1] cmp:(SGTUconst _)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGTUconst { + break + } + b.resetWithControl(BlockMIPSEQ, cmp) + return true + } + // match: (NE (XORconst [1] cmp:(SGTzero _)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGTzero { + break + } + b.resetWithControl(BlockMIPSEQ, cmp) + return true + } + // match: (NE (XORconst [1] cmp:(SGTUzero _)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpMIPSXORconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPSSGTUzero { + break + } + b.resetWithControl(BlockMIPSEQ, cmp) + return true + } + // match: (NE (SGTUconst [1] x) yes no) + // result: (EQ x yes no) + for b.Controls[0].Op == OpMIPSSGTUconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockMIPSEQ, x) + return true + } + // match: (NE (SGTUzero x) yes no) + // result: (NE x yes no) + for b.Controls[0].Op == OpMIPSSGTUzero { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockMIPSNE, x) + return true + } + // match: (NE (SGTconst [0] x) yes no) + // result: (LTZ x yes no) + for b.Controls[0].Op == OpMIPSSGTconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockMIPSLTZ, x) + return true + } + // match: (NE (SGTzero x) yes no) + // result: (GTZ x yes no) + for b.Controls[0].Op == OpMIPSSGTzero { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockMIPSGTZ, x) + return true + } + // match: (NE (MOVWconst [0]) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (NE (MOVWconst [c]) yes no) + // cond: c != 0 + // result: (First yes no) + for b.Controls[0].Op == OpMIPSMOVWconst { + v_0 := b.Controls[0] + c := auxIntToInt32(v_0.AuxInt) + if !(c != 0) { + break + } + b.Reset(BlockFirst) + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteMIPS64.go b/go/src/cmd/compile/internal/ssa/rewriteMIPS64.go new file mode 100644 index 0000000000000000000000000000000000000000..eae67a2afe10ca9f228743c90feade39b0d82fcd --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteMIPS64.go @@ -0,0 +1,8441 @@ +// Code generated from _gen/MIPS64.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "cmd/compile/internal/types" + +func rewriteValueMIPS64(v *Value) bool { + switch v.Op { + case OpAbs: + v.Op = OpMIPS64ABSD + return true + case OpAdd16: + v.Op = OpMIPS64ADDV + return true + case OpAdd32: + v.Op = OpMIPS64ADDV + return true + case OpAdd32F: + v.Op = OpMIPS64ADDF + return true + case OpAdd64: + v.Op = OpMIPS64ADDV + return true + case OpAdd64F: + v.Op = OpMIPS64ADDD + return true + case OpAdd8: + v.Op = OpMIPS64ADDV + return true + case OpAddPtr: + v.Op = OpMIPS64ADDV + return true + case OpAddr: + return rewriteValueMIPS64_OpAddr(v) + case OpAnd16: + v.Op = OpMIPS64AND + return true + case OpAnd32: + v.Op = OpMIPS64AND + return true + case OpAnd64: + v.Op = OpMIPS64AND + return true + case OpAnd8: + v.Op = OpMIPS64AND + return true + case OpAndB: + v.Op = OpMIPS64AND + return true + case OpAtomicAdd32: + v.Op = OpMIPS64LoweredAtomicAdd32 + return true + case OpAtomicAdd64: + v.Op = OpMIPS64LoweredAtomicAdd64 + return true + case OpAtomicAnd32: + v.Op = OpMIPS64LoweredAtomicAnd32 + return true + case OpAtomicAnd8: + return rewriteValueMIPS64_OpAtomicAnd8(v) + case OpAtomicCompareAndSwap32: + return rewriteValueMIPS64_OpAtomicCompareAndSwap32(v) + case OpAtomicCompareAndSwap64: + v.Op = OpMIPS64LoweredAtomicCas64 + return true + case OpAtomicExchange32: + v.Op = OpMIPS64LoweredAtomicExchange32 + return true + case OpAtomicExchange64: + v.Op = OpMIPS64LoweredAtomicExchange64 + return true + case OpAtomicLoad32: + v.Op = OpMIPS64LoweredAtomicLoad32 + return true + case OpAtomicLoad64: + v.Op = OpMIPS64LoweredAtomicLoad64 + return true + case OpAtomicLoad8: + v.Op = OpMIPS64LoweredAtomicLoad8 + return true + case OpAtomicLoadPtr: + v.Op = OpMIPS64LoweredAtomicLoad64 + return true + case OpAtomicOr32: + v.Op = OpMIPS64LoweredAtomicOr32 + return true + case OpAtomicOr8: + return rewriteValueMIPS64_OpAtomicOr8(v) + case OpAtomicStore32: + v.Op = OpMIPS64LoweredAtomicStore32 + return true + case OpAtomicStore64: + v.Op = OpMIPS64LoweredAtomicStore64 + return true + case OpAtomicStore8: + v.Op = OpMIPS64LoweredAtomicStore8 + return true + case OpAtomicStorePtrNoWB: + v.Op = OpMIPS64LoweredAtomicStore64 + return true + case OpAvg64u: + return rewriteValueMIPS64_OpAvg64u(v) + case OpClosureCall: + v.Op = OpMIPS64CALLclosure + return true + case OpCom16: + return rewriteValueMIPS64_OpCom16(v) + case OpCom32: + return rewriteValueMIPS64_OpCom32(v) + case OpCom64: + return rewriteValueMIPS64_OpCom64(v) + case OpCom8: + return rewriteValueMIPS64_OpCom8(v) + case OpConst16: + return rewriteValueMIPS64_OpConst16(v) + case OpConst32: + return rewriteValueMIPS64_OpConst32(v) + case OpConst32F: + return rewriteValueMIPS64_OpConst32F(v) + case OpConst64: + return rewriteValueMIPS64_OpConst64(v) + case OpConst64F: + return rewriteValueMIPS64_OpConst64F(v) + case OpConst8: + return rewriteValueMIPS64_OpConst8(v) + case OpConstBool: + return rewriteValueMIPS64_OpConstBool(v) + case OpConstNil: + return rewriteValueMIPS64_OpConstNil(v) + case OpCvt32Fto32: + v.Op = OpMIPS64TRUNCFW + return true + case OpCvt32Fto64: + v.Op = OpMIPS64TRUNCFV + return true + case OpCvt32Fto64F: + v.Op = OpMIPS64MOVFD + return true + case OpCvt32to32F: + v.Op = OpMIPS64MOVWF + return true + case OpCvt32to64F: + v.Op = OpMIPS64MOVWD + return true + case OpCvt64Fto32: + v.Op = OpMIPS64TRUNCDW + return true + case OpCvt64Fto32F: + v.Op = OpMIPS64MOVDF + return true + case OpCvt64Fto64: + v.Op = OpMIPS64TRUNCDV + return true + case OpCvt64to32F: + v.Op = OpMIPS64MOVVF + return true + case OpCvt64to64F: + v.Op = OpMIPS64MOVVD + return true + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpDiv16: + return rewriteValueMIPS64_OpDiv16(v) + case OpDiv16u: + return rewriteValueMIPS64_OpDiv16u(v) + case OpDiv32: + return rewriteValueMIPS64_OpDiv32(v) + case OpDiv32F: + v.Op = OpMIPS64DIVF + return true + case OpDiv32u: + return rewriteValueMIPS64_OpDiv32u(v) + case OpDiv64: + return rewriteValueMIPS64_OpDiv64(v) + case OpDiv64F: + v.Op = OpMIPS64DIVD + return true + case OpDiv64u: + return rewriteValueMIPS64_OpDiv64u(v) + case OpDiv8: + return rewriteValueMIPS64_OpDiv8(v) + case OpDiv8u: + return rewriteValueMIPS64_OpDiv8u(v) + case OpEq16: + return rewriteValueMIPS64_OpEq16(v) + case OpEq32: + return rewriteValueMIPS64_OpEq32(v) + case OpEq32F: + return rewriteValueMIPS64_OpEq32F(v) + case OpEq64: + return rewriteValueMIPS64_OpEq64(v) + case OpEq64F: + return rewriteValueMIPS64_OpEq64F(v) + case OpEq8: + return rewriteValueMIPS64_OpEq8(v) + case OpEqB: + return rewriteValueMIPS64_OpEqB(v) + case OpEqPtr: + return rewriteValueMIPS64_OpEqPtr(v) + case OpGetCallerPC: + v.Op = OpMIPS64LoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = OpMIPS64LoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = OpMIPS64LoweredGetClosurePtr + return true + case OpHmul32: + return rewriteValueMIPS64_OpHmul32(v) + case OpHmul32u: + return rewriteValueMIPS64_OpHmul32u(v) + case OpHmul64: + return rewriteValueMIPS64_OpHmul64(v) + case OpHmul64u: + return rewriteValueMIPS64_OpHmul64u(v) + case OpInterCall: + v.Op = OpMIPS64CALLinter + return true + case OpIsInBounds: + return rewriteValueMIPS64_OpIsInBounds(v) + case OpIsNonNil: + return rewriteValueMIPS64_OpIsNonNil(v) + case OpIsSliceInBounds: + return rewriteValueMIPS64_OpIsSliceInBounds(v) + case OpLeq16: + return rewriteValueMIPS64_OpLeq16(v) + case OpLeq16U: + return rewriteValueMIPS64_OpLeq16U(v) + case OpLeq32: + return rewriteValueMIPS64_OpLeq32(v) + case OpLeq32F: + return rewriteValueMIPS64_OpLeq32F(v) + case OpLeq32U: + return rewriteValueMIPS64_OpLeq32U(v) + case OpLeq64: + return rewriteValueMIPS64_OpLeq64(v) + case OpLeq64F: + return rewriteValueMIPS64_OpLeq64F(v) + case OpLeq64U: + return rewriteValueMIPS64_OpLeq64U(v) + case OpLeq8: + return rewriteValueMIPS64_OpLeq8(v) + case OpLeq8U: + return rewriteValueMIPS64_OpLeq8U(v) + case OpLess16: + return rewriteValueMIPS64_OpLess16(v) + case OpLess16U: + return rewriteValueMIPS64_OpLess16U(v) + case OpLess32: + return rewriteValueMIPS64_OpLess32(v) + case OpLess32F: + return rewriteValueMIPS64_OpLess32F(v) + case OpLess32U: + return rewriteValueMIPS64_OpLess32U(v) + case OpLess64: + return rewriteValueMIPS64_OpLess64(v) + case OpLess64F: + return rewriteValueMIPS64_OpLess64F(v) + case OpLess64U: + return rewriteValueMIPS64_OpLess64U(v) + case OpLess8: + return rewriteValueMIPS64_OpLess8(v) + case OpLess8U: + return rewriteValueMIPS64_OpLess8U(v) + case OpLoad: + return rewriteValueMIPS64_OpLoad(v) + case OpLocalAddr: + return rewriteValueMIPS64_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValueMIPS64_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValueMIPS64_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValueMIPS64_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValueMIPS64_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValueMIPS64_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValueMIPS64_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValueMIPS64_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValueMIPS64_OpLsh32x8(v) + case OpLsh64x16: + return rewriteValueMIPS64_OpLsh64x16(v) + case OpLsh64x32: + return rewriteValueMIPS64_OpLsh64x32(v) + case OpLsh64x64: + return rewriteValueMIPS64_OpLsh64x64(v) + case OpLsh64x8: + return rewriteValueMIPS64_OpLsh64x8(v) + case OpLsh8x16: + return rewriteValueMIPS64_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValueMIPS64_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValueMIPS64_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValueMIPS64_OpLsh8x8(v) + case OpMIPS64ADDV: + return rewriteValueMIPS64_OpMIPS64ADDV(v) + case OpMIPS64ADDVconst: + return rewriteValueMIPS64_OpMIPS64ADDVconst(v) + case OpMIPS64AND: + return rewriteValueMIPS64_OpMIPS64AND(v) + case OpMIPS64ANDconst: + return rewriteValueMIPS64_OpMIPS64ANDconst(v) + case OpMIPS64LoweredAtomicAdd32: + return rewriteValueMIPS64_OpMIPS64LoweredAtomicAdd32(v) + case OpMIPS64LoweredAtomicAdd64: + return rewriteValueMIPS64_OpMIPS64LoweredAtomicAdd64(v) + case OpMIPS64LoweredAtomicStore32: + return rewriteValueMIPS64_OpMIPS64LoweredAtomicStore32(v) + case OpMIPS64LoweredAtomicStore64: + return rewriteValueMIPS64_OpMIPS64LoweredAtomicStore64(v) + case OpMIPS64LoweredPanicBoundsCR: + return rewriteValueMIPS64_OpMIPS64LoweredPanicBoundsCR(v) + case OpMIPS64LoweredPanicBoundsRC: + return rewriteValueMIPS64_OpMIPS64LoweredPanicBoundsRC(v) + case OpMIPS64LoweredPanicBoundsRR: + return rewriteValueMIPS64_OpMIPS64LoweredPanicBoundsRR(v) + case OpMIPS64MOVBUload: + return rewriteValueMIPS64_OpMIPS64MOVBUload(v) + case OpMIPS64MOVBUreg: + return rewriteValueMIPS64_OpMIPS64MOVBUreg(v) + case OpMIPS64MOVBload: + return rewriteValueMIPS64_OpMIPS64MOVBload(v) + case OpMIPS64MOVBreg: + return rewriteValueMIPS64_OpMIPS64MOVBreg(v) + case OpMIPS64MOVBstore: + return rewriteValueMIPS64_OpMIPS64MOVBstore(v) + case OpMIPS64MOVDload: + return rewriteValueMIPS64_OpMIPS64MOVDload(v) + case OpMIPS64MOVDstore: + return rewriteValueMIPS64_OpMIPS64MOVDstore(v) + case OpMIPS64MOVFload: + return rewriteValueMIPS64_OpMIPS64MOVFload(v) + case OpMIPS64MOVFstore: + return rewriteValueMIPS64_OpMIPS64MOVFstore(v) + case OpMIPS64MOVHUload: + return rewriteValueMIPS64_OpMIPS64MOVHUload(v) + case OpMIPS64MOVHUreg: + return rewriteValueMIPS64_OpMIPS64MOVHUreg(v) + case OpMIPS64MOVHload: + return rewriteValueMIPS64_OpMIPS64MOVHload(v) + case OpMIPS64MOVHreg: + return rewriteValueMIPS64_OpMIPS64MOVHreg(v) + case OpMIPS64MOVHstore: + return rewriteValueMIPS64_OpMIPS64MOVHstore(v) + case OpMIPS64MOVVload: + return rewriteValueMIPS64_OpMIPS64MOVVload(v) + case OpMIPS64MOVVnop: + return rewriteValueMIPS64_OpMIPS64MOVVnop(v) + case OpMIPS64MOVVreg: + return rewriteValueMIPS64_OpMIPS64MOVVreg(v) + case OpMIPS64MOVVstore: + return rewriteValueMIPS64_OpMIPS64MOVVstore(v) + case OpMIPS64MOVWUload: + return rewriteValueMIPS64_OpMIPS64MOVWUload(v) + case OpMIPS64MOVWUreg: + return rewriteValueMIPS64_OpMIPS64MOVWUreg(v) + case OpMIPS64MOVWload: + return rewriteValueMIPS64_OpMIPS64MOVWload(v) + case OpMIPS64MOVWreg: + return rewriteValueMIPS64_OpMIPS64MOVWreg(v) + case OpMIPS64MOVWstore: + return rewriteValueMIPS64_OpMIPS64MOVWstore(v) + case OpMIPS64NEGV: + return rewriteValueMIPS64_OpMIPS64NEGV(v) + case OpMIPS64NOR: + return rewriteValueMIPS64_OpMIPS64NOR(v) + case OpMIPS64NORconst: + return rewriteValueMIPS64_OpMIPS64NORconst(v) + case OpMIPS64OR: + return rewriteValueMIPS64_OpMIPS64OR(v) + case OpMIPS64ORconst: + return rewriteValueMIPS64_OpMIPS64ORconst(v) + case OpMIPS64SGT: + return rewriteValueMIPS64_OpMIPS64SGT(v) + case OpMIPS64SGTU: + return rewriteValueMIPS64_OpMIPS64SGTU(v) + case OpMIPS64SGTUconst: + return rewriteValueMIPS64_OpMIPS64SGTUconst(v) + case OpMIPS64SGTconst: + return rewriteValueMIPS64_OpMIPS64SGTconst(v) + case OpMIPS64SLLV: + return rewriteValueMIPS64_OpMIPS64SLLV(v) + case OpMIPS64SLLVconst: + return rewriteValueMIPS64_OpMIPS64SLLVconst(v) + case OpMIPS64SRAV: + return rewriteValueMIPS64_OpMIPS64SRAV(v) + case OpMIPS64SRAVconst: + return rewriteValueMIPS64_OpMIPS64SRAVconst(v) + case OpMIPS64SRLV: + return rewriteValueMIPS64_OpMIPS64SRLV(v) + case OpMIPS64SRLVconst: + return rewriteValueMIPS64_OpMIPS64SRLVconst(v) + case OpMIPS64SUBV: + return rewriteValueMIPS64_OpMIPS64SUBV(v) + case OpMIPS64SUBVconst: + return rewriteValueMIPS64_OpMIPS64SUBVconst(v) + case OpMIPS64XOR: + return rewriteValueMIPS64_OpMIPS64XOR(v) + case OpMIPS64XORconst: + return rewriteValueMIPS64_OpMIPS64XORconst(v) + case OpMod16: + return rewriteValueMIPS64_OpMod16(v) + case OpMod16u: + return rewriteValueMIPS64_OpMod16u(v) + case OpMod32: + return rewriteValueMIPS64_OpMod32(v) + case OpMod32u: + return rewriteValueMIPS64_OpMod32u(v) + case OpMod64: + return rewriteValueMIPS64_OpMod64(v) + case OpMod64u: + return rewriteValueMIPS64_OpMod64u(v) + case OpMod8: + return rewriteValueMIPS64_OpMod8(v) + case OpMod8u: + return rewriteValueMIPS64_OpMod8u(v) + case OpMove: + return rewriteValueMIPS64_OpMove(v) + case OpMul16: + return rewriteValueMIPS64_OpMul16(v) + case OpMul32: + return rewriteValueMIPS64_OpMul32(v) + case OpMul32F: + v.Op = OpMIPS64MULF + return true + case OpMul64: + return rewriteValueMIPS64_OpMul64(v) + case OpMul64F: + v.Op = OpMIPS64MULD + return true + case OpMul64uhilo: + v.Op = OpMIPS64MULVU + return true + case OpMul8: + return rewriteValueMIPS64_OpMul8(v) + case OpNeg16: + v.Op = OpMIPS64NEGV + return true + case OpNeg32: + v.Op = OpMIPS64NEGV + return true + case OpNeg32F: + v.Op = OpMIPS64NEGF + return true + case OpNeg64: + v.Op = OpMIPS64NEGV + return true + case OpNeg64F: + v.Op = OpMIPS64NEGD + return true + case OpNeg8: + v.Op = OpMIPS64NEGV + return true + case OpNeq16: + return rewriteValueMIPS64_OpNeq16(v) + case OpNeq32: + return rewriteValueMIPS64_OpNeq32(v) + case OpNeq32F: + return rewriteValueMIPS64_OpNeq32F(v) + case OpNeq64: + return rewriteValueMIPS64_OpNeq64(v) + case OpNeq64F: + return rewriteValueMIPS64_OpNeq64F(v) + case OpNeq8: + return rewriteValueMIPS64_OpNeq8(v) + case OpNeqB: + v.Op = OpMIPS64XOR + return true + case OpNeqPtr: + return rewriteValueMIPS64_OpNeqPtr(v) + case OpNilCheck: + v.Op = OpMIPS64LoweredNilCheck + return true + case OpNot: + return rewriteValueMIPS64_OpNot(v) + case OpOffPtr: + return rewriteValueMIPS64_OpOffPtr(v) + case OpOr16: + v.Op = OpMIPS64OR + return true + case OpOr32: + v.Op = OpMIPS64OR + return true + case OpOr64: + v.Op = OpMIPS64OR + return true + case OpOr8: + v.Op = OpMIPS64OR + return true + case OpOrB: + v.Op = OpMIPS64OR + return true + case OpPanicBounds: + v.Op = OpMIPS64LoweredPanicBoundsRR + return true + case OpPubBarrier: + v.Op = OpMIPS64LoweredPubBarrier + return true + case OpRotateLeft16: + return rewriteValueMIPS64_OpRotateLeft16(v) + case OpRotateLeft32: + return rewriteValueMIPS64_OpRotateLeft32(v) + case OpRotateLeft64: + return rewriteValueMIPS64_OpRotateLeft64(v) + case OpRotateLeft8: + return rewriteValueMIPS64_OpRotateLeft8(v) + case OpRound32F: + v.Op = OpCopy + return true + case OpRound64F: + v.Op = OpCopy + return true + case OpRsh16Ux16: + return rewriteValueMIPS64_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValueMIPS64_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValueMIPS64_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValueMIPS64_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValueMIPS64_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValueMIPS64_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValueMIPS64_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValueMIPS64_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValueMIPS64_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValueMIPS64_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValueMIPS64_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValueMIPS64_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValueMIPS64_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValueMIPS64_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValueMIPS64_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValueMIPS64_OpRsh32x8(v) + case OpRsh64Ux16: + return rewriteValueMIPS64_OpRsh64Ux16(v) + case OpRsh64Ux32: + return rewriteValueMIPS64_OpRsh64Ux32(v) + case OpRsh64Ux64: + return rewriteValueMIPS64_OpRsh64Ux64(v) + case OpRsh64Ux8: + return rewriteValueMIPS64_OpRsh64Ux8(v) + case OpRsh64x16: + return rewriteValueMIPS64_OpRsh64x16(v) + case OpRsh64x32: + return rewriteValueMIPS64_OpRsh64x32(v) + case OpRsh64x64: + return rewriteValueMIPS64_OpRsh64x64(v) + case OpRsh64x8: + return rewriteValueMIPS64_OpRsh64x8(v) + case OpRsh8Ux16: + return rewriteValueMIPS64_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValueMIPS64_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValueMIPS64_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValueMIPS64_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValueMIPS64_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValueMIPS64_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValueMIPS64_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValueMIPS64_OpRsh8x8(v) + case OpSelect0: + return rewriteValueMIPS64_OpSelect0(v) + case OpSelect1: + return rewriteValueMIPS64_OpSelect1(v) + case OpSignExt16to32: + v.Op = OpMIPS64MOVHreg + return true + case OpSignExt16to64: + v.Op = OpMIPS64MOVHreg + return true + case OpSignExt32to64: + v.Op = OpMIPS64MOVWreg + return true + case OpSignExt8to16: + v.Op = OpMIPS64MOVBreg + return true + case OpSignExt8to32: + v.Op = OpMIPS64MOVBreg + return true + case OpSignExt8to64: + v.Op = OpMIPS64MOVBreg + return true + case OpSlicemask: + return rewriteValueMIPS64_OpSlicemask(v) + case OpSqrt: + v.Op = OpMIPS64SQRTD + return true + case OpSqrt32: + v.Op = OpMIPS64SQRTF + return true + case OpStaticCall: + v.Op = OpMIPS64CALLstatic + return true + case OpStore: + return rewriteValueMIPS64_OpStore(v) + case OpSub16: + v.Op = OpMIPS64SUBV + return true + case OpSub32: + v.Op = OpMIPS64SUBV + return true + case OpSub32F: + v.Op = OpMIPS64SUBF + return true + case OpSub64: + v.Op = OpMIPS64SUBV + return true + case OpSub64F: + v.Op = OpMIPS64SUBD + return true + case OpSub8: + v.Op = OpMIPS64SUBV + return true + case OpSubPtr: + v.Op = OpMIPS64SUBV + return true + case OpTailCall: + v.Op = OpMIPS64CALLtail + return true + case OpTrunc16to8: + v.Op = OpCopy + return true + case OpTrunc32to16: + v.Op = OpCopy + return true + case OpTrunc32to8: + v.Op = OpCopy + return true + case OpTrunc64to16: + v.Op = OpCopy + return true + case OpTrunc64to32: + v.Op = OpCopy + return true + case OpTrunc64to8: + v.Op = OpCopy + return true + case OpWB: + v.Op = OpMIPS64LoweredWB + return true + case OpXor16: + v.Op = OpMIPS64XOR + return true + case OpXor32: + v.Op = OpMIPS64XOR + return true + case OpXor64: + v.Op = OpMIPS64XOR + return true + case OpXor8: + v.Op = OpMIPS64XOR + return true + case OpZero: + return rewriteValueMIPS64_OpZero(v) + case OpZeroExt16to32: + v.Op = OpMIPS64MOVHUreg + return true + case OpZeroExt16to64: + v.Op = OpMIPS64MOVHUreg + return true + case OpZeroExt32to64: + v.Op = OpMIPS64MOVWUreg + return true + case OpZeroExt8to16: + v.Op = OpMIPS64MOVBUreg + return true + case OpZeroExt8to32: + v.Op = OpMIPS64MOVBUreg + return true + case OpZeroExt8to64: + v.Op = OpMIPS64MOVBUreg + return true + } + return false +} +func rewriteValueMIPS64_OpAddr(v *Value) bool { + v_0 := v.Args[0] + // match: (Addr {sym} base) + // result: (MOVVaddr {sym} base) + for { + sym := auxToSym(v.Aux) + base := v_0 + v.reset(OpMIPS64MOVVaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } +} +func rewriteValueMIPS64_OpAtomicAnd8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (AtomicAnd8 ptr val mem) + // cond: !config.BigEndian + // result: (LoweredAtomicAnd32 (AND (MOVVconst [^3]) ptr) (OR (SLLV (ZeroExt8to32 val) (SLLVconst [3] (ANDconst [3] ptr))) (NORconst [0] (SLLV (MOVVconst [0xff]) (SLLVconst [3] (ANDconst [3] ptr))))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + if !(!config.BigEndian) { + break + } + v.reset(OpMIPS64LoweredAtomicAnd32) + v0 := b.NewValue0(v.Pos, OpMIPS64AND, typ.UInt32Ptr) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(^3) + v0.AddArg2(v1, ptr) + v2 := b.NewValue0(v.Pos, OpMIPS64OR, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpMIPS64SLLV, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v4.AddArg(val) + v5 := b.NewValue0(v.Pos, OpMIPS64SLLVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(3) + v6 := b.NewValue0(v.Pos, OpMIPS64ANDconst, typ.UInt64) + v6.AuxInt = int64ToAuxInt(3) + v6.AddArg(ptr) + v5.AddArg(v6) + v3.AddArg2(v4, v5) + v7 := b.NewValue0(v.Pos, OpMIPS64NORconst, typ.UInt64) + v7.AuxInt = int64ToAuxInt(0) + v8 := b.NewValue0(v.Pos, OpMIPS64SLLV, typ.UInt64) + v9 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v9.AuxInt = int64ToAuxInt(0xff) + v8.AddArg2(v9, v5) + v7.AddArg(v8) + v2.AddArg2(v3, v7) + v.AddArg3(v0, v2, mem) + return true + } + // match: (AtomicAnd8 ptr val mem) + // cond: config.BigEndian + // result: (LoweredAtomicAnd32 (AND (MOVVconst [^3]) ptr) (OR (SLLV (ZeroExt8to32 val) (SLLVconst [3] (ANDconst [3] (XORconst [3] ptr)))) (NORconst [0] (SLLV (MOVVconst [0xff]) (SLLVconst [3] (ANDconst [3] (XORconst [3] ptr)))))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + if !(config.BigEndian) { + break + } + v.reset(OpMIPS64LoweredAtomicAnd32) + v0 := b.NewValue0(v.Pos, OpMIPS64AND, typ.UInt32Ptr) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(^3) + v0.AddArg2(v1, ptr) + v2 := b.NewValue0(v.Pos, OpMIPS64OR, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpMIPS64SLLV, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v4.AddArg(val) + v5 := b.NewValue0(v.Pos, OpMIPS64SLLVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(3) + v6 := b.NewValue0(v.Pos, OpMIPS64ANDconst, typ.UInt64) + v6.AuxInt = int64ToAuxInt(3) + v7 := b.NewValue0(v.Pos, OpMIPS64XORconst, typ.UInt64) + v7.AuxInt = int64ToAuxInt(3) + v7.AddArg(ptr) + v6.AddArg(v7) + v5.AddArg(v6) + v3.AddArg2(v4, v5) + v8 := b.NewValue0(v.Pos, OpMIPS64NORconst, typ.UInt64) + v8.AuxInt = int64ToAuxInt(0) + v9 := b.NewValue0(v.Pos, OpMIPS64SLLV, typ.UInt64) + v10 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v10.AuxInt = int64ToAuxInt(0xff) + v9.AddArg2(v10, v5) + v8.AddArg(v9) + v2.AddArg2(v3, v8) + v.AddArg3(v0, v2, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpAtomicCompareAndSwap32(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicCompareAndSwap32 ptr old new mem) + // result: (LoweredAtomicCas32 ptr (SignExt32to64 old) new mem) + for { + ptr := v_0 + old := v_1 + new := v_2 + mem := v_3 + v.reset(OpMIPS64LoweredAtomicCas32) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(old) + v.AddArg4(ptr, v0, new, mem) + return true + } +} +func rewriteValueMIPS64_OpAtomicOr8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (AtomicOr8 ptr val mem) + // cond: !config.BigEndian + // result: (LoweredAtomicOr32 (AND (MOVVconst [^3]) ptr) (SLLV (ZeroExt8to32 val) (SLLVconst [3] (ANDconst [3] ptr))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + if !(!config.BigEndian) { + break + } + v.reset(OpMIPS64LoweredAtomicOr32) + v0 := b.NewValue0(v.Pos, OpMIPS64AND, typ.UInt32Ptr) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(^3) + v0.AddArg2(v1, ptr) + v2 := b.NewValue0(v.Pos, OpMIPS64SLLV, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v3.AddArg(val) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(3) + v5 := b.NewValue0(v.Pos, OpMIPS64ANDconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(3) + v5.AddArg(ptr) + v4.AddArg(v5) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v2, mem) + return true + } + // match: (AtomicOr8 ptr val mem) + // cond: config.BigEndian + // result: (LoweredAtomicOr32 (AND (MOVVconst [^3]) ptr) (SLLV (ZeroExt8to32 val) (SLLVconst [3] (ANDconst [3] (XORconst [3] ptr)))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + if !(config.BigEndian) { + break + } + v.reset(OpMIPS64LoweredAtomicOr32) + v0 := b.NewValue0(v.Pos, OpMIPS64AND, typ.UInt32Ptr) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(^3) + v0.AddArg2(v1, ptr) + v2 := b.NewValue0(v.Pos, OpMIPS64SLLV, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v3.AddArg(val) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(3) + v5 := b.NewValue0(v.Pos, OpMIPS64ANDconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(3) + v6 := b.NewValue0(v.Pos, OpMIPS64XORconst, typ.UInt64) + v6.AuxInt = int64ToAuxInt(3) + v6.AddArg(ptr) + v5.AddArg(v6) + v4.AddArg(v5) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v2, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpAvg64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Avg64u x y) + // result: (ADDV (SRLVconst (SUBV x y) [1]) y) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64ADDV) + v0 := b.NewValue0(v.Pos, OpMIPS64SRLVconst, t) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64SUBV, t) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueMIPS64_OpCom16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com16 x) + // result: (NOR (MOVVconst [0]) x) + for { + x := v_0 + v.reset(OpMIPS64NOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueMIPS64_OpCom32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com32 x) + // result: (NOR (MOVVconst [0]) x) + for { + x := v_0 + v.reset(OpMIPS64NOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueMIPS64_OpCom64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com64 x) + // result: (NOR (MOVVconst [0]) x) + for { + x := v_0 + v.reset(OpMIPS64NOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueMIPS64_OpCom8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com8 x) + // result: (NOR (MOVVconst [0]) x) + for { + x := v_0 + v.reset(OpMIPS64NOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueMIPS64_OpConst16(v *Value) bool { + // match: (Const16 [val]) + // result: (MOVVconst [int64(val)]) + for { + val := auxIntToInt16(v.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueMIPS64_OpConst32(v *Value) bool { + // match: (Const32 [val]) + // result: (MOVVconst [int64(val)]) + for { + val := auxIntToInt32(v.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueMIPS64_OpConst32F(v *Value) bool { + // match: (Const32F [val]) + // result: (MOVFconst [float64(val)]) + for { + val := auxIntToFloat32(v.AuxInt) + v.reset(OpMIPS64MOVFconst) + v.AuxInt = float64ToAuxInt(float64(val)) + return true + } +} +func rewriteValueMIPS64_OpConst64(v *Value) bool { + // match: (Const64 [val]) + // result: (MOVVconst [int64(val)]) + for { + val := auxIntToInt64(v.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueMIPS64_OpConst64F(v *Value) bool { + // match: (Const64F [val]) + // result: (MOVDconst [float64(val)]) + for { + val := auxIntToFloat64(v.AuxInt) + v.reset(OpMIPS64MOVDconst) + v.AuxInt = float64ToAuxInt(float64(val)) + return true + } +} +func rewriteValueMIPS64_OpConst8(v *Value) bool { + // match: (Const8 [val]) + // result: (MOVVconst [int64(val)]) + for { + val := auxIntToInt8(v.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueMIPS64_OpConstBool(v *Value) bool { + // match: (ConstBool [t]) + // result: (MOVVconst [int64(b2i(t))]) + for { + t := auxIntToBool(v.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(b2i(t))) + return true + } +} +func rewriteValueMIPS64_OpConstNil(v *Value) bool { + // match: (ConstNil) + // result: (MOVVconst [0]) + for { + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } +} +func rewriteValueMIPS64_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 x y) + // result: (Select1 (DIVV (SignExt16to64 x) (SignExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVV, types.NewTuple(typ.Int64, typ.Int64)) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u x y) + // result: (Select1 (DIVVU (ZeroExt16to64 x) (ZeroExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32 x y) + // result: (Select1 (DIVV (SignExt32to64 x) (SignExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVV, types.NewTuple(typ.Int64, typ.Int64)) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpDiv32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32u x y) + // result: (Select1 (DIVVU (ZeroExt32to64 x) (ZeroExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpDiv64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div64 x y) + // result: (Select1 (DIVV x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVV, types.NewTuple(typ.Int64, typ.Int64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpDiv64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div64u x y) + // result: (Select1 (DIVVU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (Select1 (DIVV (SignExt8to64 x) (SignExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVV, types.NewTuple(typ.Int64, typ.Int64)) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (Select1 (DIVVU (ZeroExt8to64 x) (ZeroExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq16 x y) + // result: (SGTU (MOVVconst [1]) (XOR (ZeroExt16to64 x) (ZeroExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq32 x y) + // result: (SGTU (MOVVconst [1]) (XOR (ZeroExt32to64 x) (ZeroExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpEq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32F x y) + // result: (FPFlagTrue (CMPEQF x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPS64CMPEQF, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpEq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq64 x y) + // result: (SGTU (MOVVconst [1]) (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.UInt64) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpEq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64F x y) + // result: (FPFlagTrue (CMPEQD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPS64CMPEQD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq8 x y) + // result: (SGTU (MOVVconst [1]) (XOR (ZeroExt8to64 x) (ZeroExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqB x y) + // result: (XOR (MOVVconst [1]) (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64XOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.Bool) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqPtr x y) + // result: (SGTU (MOVVconst [1]) (XOR x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.UInt64) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpHmul32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul32 x y) + // result: (SRAVconst (Select1 (MULV (SignExt32to64 x) (SignExt32to64 y))) [32]) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAVconst) + v.AuxInt = int64ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpSelect1, typ.Int64) + v1 := b.NewValue0(v.Pos, OpMIPS64MULV, types.NewTuple(typ.Int64, typ.Int64)) + v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpHmul32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul32u x y) + // result: (SRLVconst (Select1 (MULVU (ZeroExt32to64 x) (ZeroExt32to64 y))) [32]) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SRLVconst) + v.AuxInt = int64ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpMIPS64MULVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpHmul64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul64 x y) + // result: (Select0 (MULV x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPS64MULV, types.NewTuple(typ.Int64, typ.Int64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpHmul64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul64u x y) + // result: (Select0 (MULVU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPS64MULVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpIsInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (IsInBounds idx len) + // result: (SGTU len idx) + for { + idx := v_0 + len := v_1 + v.reset(OpMIPS64SGTU) + v.AddArg2(len, idx) + return true + } +} +func rewriteValueMIPS64_OpIsNonNil(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsNonNil ptr) + // result: (SGTU ptr (MOVVconst [0])) + for { + ptr := v_0 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(ptr, v0) + return true + } +} +func rewriteValueMIPS64_OpIsSliceInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsSliceInBounds idx len) + // result: (XOR (MOVVconst [1]) (SGTU idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpMIPS64XOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v1.AddArg2(idx, len) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16 x y) + // result: (XOR (MOVVconst [1]) (SGT (SignExt16to64 x) (SignExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64XOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64SGT, typ.Bool) + v2 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16U x y) + // result: (XOR (MOVVconst [1]) (SGTU (ZeroExt16to64 x) (ZeroExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64XOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32 x y) + // result: (XOR (MOVVconst [1]) (SGT (SignExt32to64 x) (SignExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64XOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64SGT, typ.Bool) + v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32F x y) + // result: (FPFlagTrue (CMPGEF y x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPS64CMPGEF, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32U x y) + // result: (XOR (MOVVconst [1]) (SGTU (ZeroExt32to64 x) (ZeroExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64XOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64 x y) + // result: (XOR (MOVVconst [1]) (SGT x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64XOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64SGT, typ.Bool) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64F x y) + // result: (FPFlagTrue (CMPGED y x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPS64CMPGED, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpLeq64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64U x y) + // result: (XOR (MOVVconst [1]) (SGTU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64XOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v1.AddArg2(x, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8 x y) + // result: (XOR (MOVVconst [1]) (SGT (SignExt8to64 x) (SignExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64XOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64SGT, typ.Bool) + v2 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8U x y) + // result: (XOR (MOVVconst [1]) (SGTU (ZeroExt8to64 x) (ZeroExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64XOR) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16 x y) + // result: (SGT (SignExt16to64 y) (SignExt16to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGT) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16U x y) + // result: (SGTU (ZeroExt16to64 y) (ZeroExt16to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32 x y) + // result: (SGT (SignExt32to64 y) (SignExt32to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGT) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLess32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32F x y) + // result: (FPFlagTrue (CMPGTF y x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPS64CMPGTF, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32U x y) + // result: (SGTU (ZeroExt32to64 y) (ZeroExt32to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLess64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Less64 x y) + // result: (SGT y x) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGT) + v.AddArg2(y, x) + return true + } +} +func rewriteValueMIPS64_OpLess64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64F x y) + // result: (FPFlagTrue (CMPGTD y x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64FPFlagTrue) + v0 := b.NewValue0(v.Pos, OpMIPS64CMPGTD, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpLess64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Less64U x y) + // result: (SGTU y x) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v.AddArg2(y, x) + return true + } +} +func rewriteValueMIPS64_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8 x y) + // result: (SGT (SignExt8to64 y) (SignExt8to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGT) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8U x y) + // result: (SGTU (ZeroExt8to64 y) (ZeroExt8to64 x)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(y) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Load ptr mem) + // cond: t.IsBoolean() + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsBoolean()) { + break + } + v.reset(OpMIPS64MOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is8BitInt(t) && t.IsSigned()) + // result: (MOVBload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpMIPS64MOVBload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is8BitInt(t) && !t.IsSigned()) + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpMIPS64MOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && t.IsSigned()) + // result: (MOVHload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpMIPS64MOVHload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && !t.IsSigned()) + // result: (MOVHUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpMIPS64MOVHUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is32BitInt(t) && t.IsSigned()) + // result: (MOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpMIPS64MOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is32BitInt(t) && !t.IsSigned()) + // result: (MOVWUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpMIPS64MOVWUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (MOVVload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpMIPS64MOVVload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (MOVFload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(OpMIPS64MOVFload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (MOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(OpMIPS64MOVDload) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (MOVVaddr {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(OpMIPS64MOVVaddr) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (MOVVaddr {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(OpMIPS64MOVVaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValueMIPS64_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x16 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) (SLLV x (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x32 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) (SLLV x (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x64 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) y)) (SLLV x y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v0.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v3.AddArg2(x, y) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x8 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) (SLLV x (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x16 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) (SLLV x (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x32 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) (SLLV x (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x64 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) y)) (SLLV x y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v0.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v3.AddArg2(x, y) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x8 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) (SLLV x (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x16 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) (SLLV x (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x32 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) (SLLV x (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x64 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) y)) (SLLV x y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v0.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v3.AddArg2(x, y) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpLsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x8 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) (SLLV x (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x16 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) (SLLV x (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x32 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) (SLLV x (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x64 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) y)) (SLLV x y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v0.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v3.AddArg2(x, y) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x8 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) (SLLV x (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SLLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpMIPS64ADDV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDV x (MOVVconst [c])) + // cond: is32Bit(c) && !t.IsPtr() + // result: (ADDVconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + continue + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c) && !t.IsPtr()) { + continue + } + v.reset(OpMIPS64ADDVconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (ADDV x (NEGV y)) + // result: (SUBV x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPS64NEGV { + continue + } + y := v_1.Args[0] + v.reset(OpMIPS64SUBV) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueMIPS64_OpMIPS64ADDVconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDVconst [off1] (MOVVaddr [off2] {sym} ptr)) + // cond: is32Bit(off1+int64(off2)) + // result: (MOVVaddr [int32(off1)+int32(off2)] {sym} ptr) + for { + off1 := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + if !(is32Bit(off1 + int64(off2))) { + break + } + v.reset(OpMIPS64MOVVaddr) + v.AuxInt = int32ToAuxInt(int32(off1) + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg(ptr) + return true + } + // match: (ADDVconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ADDVconst [c] (MOVVconst [d])) + // result: (MOVVconst [c+d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(c + d) + return true + } + // match: (ADDVconst [c] (ADDVconst [d] x)) + // cond: is32Bit(c+d) + // result: (ADDVconst [c+d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64ADDVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c + d)) { + break + } + v.reset(OpMIPS64ADDVconst) + v.AuxInt = int64ToAuxInt(c + d) + v.AddArg(x) + return true + } + // match: (ADDVconst [c] (SUBVconst [d] x)) + // cond: is32Bit(c-d) + // result: (ADDVconst [c-d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64SUBVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c - d)) { + break + } + v.reset(OpMIPS64ADDVconst) + v.AuxInt = int64ToAuxInt(c - d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64AND(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AND x (MOVVconst [c])) + // cond: is32Bit(c) + // result: (ANDconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpMIPS64ANDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (AND x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64ANDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDconst [0] _) + // result: (MOVVconst [0]) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (ANDconst [-1] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ANDconst [c] (MOVVconst [d])) + // result: (MOVVconst [c&d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(c & d) + return true + } + // match: (ANDconst [c] (ANDconst [d] x)) + // result: (ANDconst [c&d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64ANDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpMIPS64ANDconst) + v.AuxInt = int64ToAuxInt(c & d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64LoweredAtomicAdd32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredAtomicAdd32 ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (LoweredAtomicAddconst32 [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpMIPS64LoweredAtomicAddconst32) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64LoweredAtomicAdd64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredAtomicAdd64 ptr (MOVVconst [c]) mem) + // cond: is32Bit(c) + // result: (LoweredAtomicAddconst64 [c] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is32Bit(c)) { + break + } + v.reset(OpMIPS64LoweredAtomicAddconst64) + v.AuxInt = int64ToAuxInt(c) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64LoweredAtomicStore32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredAtomicStore32 ptr (MOVVconst [0]) mem) + // result: (LoweredAtomicStorezero32 ptr mem) + for { + ptr := v_0 + if v_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpMIPS64LoweredAtomicStorezero32) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64LoweredAtomicStore64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredAtomicStore64 ptr (MOVVconst [0]) mem) + // result: (LoweredAtomicStorezero64 ptr mem) + for { + ptr := v_0 + if v_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpMIPS64LoweredAtomicStorezero64) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64LoweredPanicBoundsCR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsCR [kind] {p} (MOVVconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:p.C, Cy:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpMIPS64LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: p.C, Cy: c}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64LoweredPanicBoundsRC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRC [kind] {p} (MOVVconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:c, Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpMIPS64LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: c, Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64LoweredPanicBoundsRR(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRR [kind] x (MOVVconst [c]) mem) + // result: (LoweredPanicBoundsRC [kind] x {PanicBoundsC{C:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpMIPS64LoweredPanicBoundsRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(x, mem) + return true + } + // match: (LoweredPanicBoundsRR [kind] (MOVVconst [c]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:c}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + mem := v_2 + v.reset(OpMIPS64LoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVBUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBUload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVBUload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVBUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVBUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVBUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(read8(sym, int64(off)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(read8(sym, int64(off)))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVBUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBUreg x:(MOVBUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBUload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(MOVBUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBUreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg (MOVVconst [c])) + // result: (MOVVconst [int64(uint8(c))]) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint8(c))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVBload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVBload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVBload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVBload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVBload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(int8(read8(sym, int64(off))))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int8(read8(sym, int64(off))))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVBreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVBreg x:(MOVBload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVBreg (MOVVconst [c])) + // result: (MOVVconst [int64(int8(c))]) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int8(c))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVBstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVBstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVBreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVBUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVDload [off] {sym} ptr (MOVVstore [off] {sym} ptr val _)) + // result: (MOVVgpfp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVVstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpMIPS64MOVVgpfp) + v.AddArg(val) + return true + } + // match: (MOVDload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVDload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVDload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVDload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVDload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVDstore [off] {sym} ptr (MOVVgpfp val) mem) + // result: (MOVVstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVVgpfp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVVstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVDstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVDstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVDstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVDstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVFload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVFload [off] {sym} ptr (MOVWstore [off] {sym} ptr val _)) + // result: (MOVWgpfp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpMIPS64MOVWgpfp) + v.AddArg(val) + return true + } + // match: (MOVFload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVFload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVFload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVFload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVFload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVFload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVFstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVFstore [off] {sym} ptr (MOVWgpfp val) mem) + // result: (MOVWstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVWgpfp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVFstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVFstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVFstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVFstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVFstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVFstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVHUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHUload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVHUload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVHUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVHUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVHUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVHUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVHUreg x:(MOVBUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBUload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVHUload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVBUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBUreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVHUreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg (MOVVconst [c])) + // result: (MOVVconst [int64(uint16(c))]) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint16(c))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVHload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVHload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVHload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVHload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVHload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int16(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVHreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVHreg x:(MOVBload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBUload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVHload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBUreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVHreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVHreg (MOVVconst [c])) + // result: (MOVVconst [int64(int16(c))]) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int16(c))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVHstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVHstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVHstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVVload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVVload [off] {sym} ptr (MOVDstore [off] {sym} ptr val _)) + // result: (MOVVfpgp val) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpMIPS64MOVVfpgp) + v.AddArg(val) + return true + } + // match: (MOVVload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVVload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVVload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVVload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVVload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVVload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVVload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVVnop(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVVnop (MOVVconst [c])) + // result: (MOVVconst [c]) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(c) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVVreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVVreg x) + // cond: x.Uses == 1 + // result: (MOVVnop x) + for { + x := v_0 + if !(x.Uses == 1) { + break + } + v.reset(OpMIPS64MOVVnop) + v.AddArg(x) + return true + } + // match: (MOVVreg (MOVVconst [c])) + // result: (MOVVconst [c]) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(c) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVVstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVVstore [off] {sym} ptr (MOVVfpgp val) mem) + // result: (MOVDstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVVfpgp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVDstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVVstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVVstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVVstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVVstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVVstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVVstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVWUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVWUload [off] {sym} ptr (MOVFstore [off] {sym} ptr val _)) + // result: (ZeroExt32to64 (MOVWfpgp val)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVFstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + val := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpZeroExt32to64) + v0 := b.NewValue0(v_1.Pos, OpMIPS64MOVWfpgp, typ.Float32) + v0.AddArg(val) + v.AddArg(v0) + return true + } + // match: (MOVWUload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVWUload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVWUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWUload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVWUload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVWUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWUload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVWUreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWUreg x:(MOVBUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBUload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVHUload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVWUload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVBUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBUreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVHUreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVWUreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg (MOVVconst [c])) + // result: (MOVVconst [int64(uint32(c))]) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint32(c))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWload [off1] {sym} (ADDVconst [off2] ptr) mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVWload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVWload [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off] {sym} (SB) _) + // cond: symIsRO(sym) + // result: (MOVVconst [int64(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpSB || !(symIsRO(sym)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVWreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVWreg x:(MOVBload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBUload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVHload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHUload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVHUload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWload _ _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVWload { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBUreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVBUreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVHreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWreg _)) + // result: (MOVVreg x) + for { + x := v_0 + if x.Op != OpMIPS64MOVWreg { + break + } + v.reset(OpMIPS64MOVVreg) + v.AddArg(x) + return true + } + // match: (MOVWreg (MOVVconst [c])) + // result: (MOVVconst [int64(int32(c))]) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(int32(c))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64MOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWstore [off] {sym} ptr (MOVWfpgp val) mem) + // result: (MOVFstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVWfpgp { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVFstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off1] {sym} (ADDVconst [off2] ptr) val mem) + // cond: is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVWstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpMIPS64ADDVconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+off2) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off1] {sym1} (MOVVaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared) + // result: (MOVWstore [off1+int32(off2)] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpMIPS64MOVVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (ptr.Op != OpSB || !config.ctxt.Flag_shared)) { + break + } + v.reset(OpMIPS64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpMIPS64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpMIPS64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64NEGV(v *Value) bool { + v_0 := v.Args[0] + // match: (NEGV (SUBV x y)) + // result: (SUBV y x) + for { + if v_0.Op != OpMIPS64SUBV { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpMIPS64SUBV) + v.AddArg2(y, x) + return true + } + // match: (NEGV (NEGV x)) + // result: x + for { + if v_0.Op != OpMIPS64NEGV { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (NEGV (MOVVconst [c])) + // result: (MOVVconst [-c]) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(-c) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64NOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NOR x (MOVVconst [c])) + // cond: is32Bit(c) + // result: (NORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpMIPS64NORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueMIPS64_OpMIPS64NORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (NORconst [c] (MOVVconst [d])) + // result: (MOVVconst [^(c|d)]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(^(c | d)) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64OR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (OR x (MOVVconst [c])) + // cond: is32Bit(c) + // result: (ORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpMIPS64ORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (OR x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64ORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ORconst [-1] _) + // result: (MOVVconst [-1]) + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (ORconst [c] (MOVVconst [d])) + // result: (MOVVconst [c|d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(c | d) + return true + } + // match: (ORconst [c] (ORconst [d] x)) + // cond: is32Bit(c|d) + // result: (ORconst [c|d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64ORconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c | d)) { + break + } + v.reset(OpMIPS64ORconst) + v.AuxInt = int64ToAuxInt(c | d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SGT(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SGT (MOVVconst [c]) x) + // cond: is32Bit(c) + // result: (SGTconst [c] x) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(c)) { + break + } + v.reset(OpMIPS64SGTconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SGT x x) + // result: (MOVVconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SGTU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SGTU (MOVVconst [c]) x) + // cond: is32Bit(c) + // result: (SGTUconst [c] x) + for { + if v_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(c)) { + break + } + v.reset(OpMIPS64SGTUconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SGTU x x) + // result: (MOVVconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SGTUconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SGTUconst [c] (MOVVconst [d])) + // cond: uint64(c)>uint64(d) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(uint64(c) > uint64(d)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (MOVVconst [d])) + // cond: uint64(c)<=uint64(d) + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(uint64(c) <= uint64(d)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTUconst [c] (MOVBUreg _)) + // cond: 0xff < uint64(c) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVBUreg || !(0xff < uint64(c)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (MOVHUreg _)) + // cond: 0xffff < uint64(c) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVHUreg || !(0xffff < uint64(c)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (ANDconst [m] _)) + // cond: uint64(m) < uint64(c) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64ANDconst { + break + } + m := auxIntToInt64(v_0.AuxInt) + if !(uint64(m) < uint64(c)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTUconst [c] (SRLVconst _ [d])) + // cond: 0 < d && d <= 63 && 0xffffffffffffffff>>uint64(d) < uint64(c) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64SRLVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(0 < d && d <= 63 && 0xffffffffffffffff>>uint64(d) < uint64(c)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SGTconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SGTconst [c] (MOVVconst [d])) + // cond: c>d + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(c > d) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVVconst [d])) + // cond: c<=d + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(c <= d) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVBreg _)) + // cond: 0x7f < c + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVBreg || !(0x7f < c) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVBreg _)) + // cond: c <= -0x80 + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVBreg || !(c <= -0x80) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVBUreg _)) + // cond: 0xff < c + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVBUreg || !(0xff < c) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVBUreg _)) + // cond: c < 0 + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVBUreg || !(c < 0) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVHreg _)) + // cond: 0x7fff < c + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVHreg || !(0x7fff < c) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVHreg _)) + // cond: c <= -0x8000 + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVHreg || !(c <= -0x8000) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVHUreg _)) + // cond: 0xffff < c + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVHUreg || !(0xffff < c) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (MOVHUreg _)) + // cond: c < 0 + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVHUreg || !(c < 0) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (MOVWUreg _)) + // cond: c < 0 + // result: (MOVVconst [0]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVWUreg || !(c < 0) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SGTconst [c] (ANDconst [m] _)) + // cond: 0 <= m && m < c + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64ANDconst { + break + } + m := auxIntToInt64(v_0.AuxInt) + if !(0 <= m && m < c) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SGTconst [c] (SRLVconst _ [d])) + // cond: 0 <= c && 0 < d && d <= 63 && 0xffffffffffffffff>>uint64(d) < uint64(c) + // result: (MOVVconst [1]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64SRLVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + if !(0 <= c && 0 < d && d <= 63 && 0xffffffffffffffff>>uint64(d) < uint64(c)) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SLLV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLLV _ (MOVVconst [c])) + // cond: uint64(c)>=64 + // result: (MOVVconst [0]) + for { + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SLLV x (MOVVconst [c])) + // result: (SLLVconst x [c]) + for { + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpMIPS64SLLVconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SLLVconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLLVconst [c] (MOVVconst [d])) + // result: (MOVVconst [d<=64 + // result: (SRAVconst x [63]) + for { + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpMIPS64SRAVconst) + v.AuxInt = int64ToAuxInt(63) + v.AddArg(x) + return true + } + // match: (SRAV x (MOVVconst [c])) + // result: (SRAVconst x [c]) + for { + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpMIPS64SRAVconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SRAVconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRAVconst [c] (MOVVconst [d])) + // result: (MOVVconst [d>>uint64(c)]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(d >> uint64(c)) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SRLV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRLV _ (MOVVconst [c])) + // cond: uint64(c)>=64 + // result: (MOVVconst [0]) + for { + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLV x (MOVVconst [c])) + // result: (SRLVconst x [c]) + for { + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpMIPS64SRLVconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SRLVconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRLVconst [c] (MOVVconst [d])) + // result: (MOVVconst [int64(uint64(d)>>uint64(c))]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint64(d) >> uint64(c))) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SUBV(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBV x (MOVVconst [c])) + // cond: is32Bit(c) + // result: (SUBVconst [c] x) + for { + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + break + } + v.reset(OpMIPS64SUBVconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SUBV x (NEGV y)) + // result: (ADDV x y) + for { + x := v_0 + if v_1.Op != OpMIPS64NEGV { + break + } + y := v_1.Args[0] + v.reset(OpMIPS64ADDV) + v.AddArg2(x, y) + return true + } + // match: (SUBV x x) + // result: (MOVVconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SUBV (MOVVconst [0]) x) + // result: (NEGV x) + for { + if v_0.Op != OpMIPS64MOVVconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpMIPS64NEGV) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64SUBVconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBVconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SUBVconst [c] (MOVVconst [d])) + // result: (MOVVconst [d-c]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(d - c) + return true + } + // match: (SUBVconst [c] (SUBVconst [d] x)) + // cond: is32Bit(-c-d) + // result: (ADDVconst [-c-d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64SUBVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(-c - d)) { + break + } + v.reset(OpMIPS64ADDVconst) + v.AuxInt = int64ToAuxInt(-c - d) + v.AddArg(x) + return true + } + // match: (SUBVconst [c] (ADDVconst [d] x)) + // cond: is32Bit(-c+d) + // result: (ADDVconst [-c+d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64ADDVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(-c + d)) { + break + } + v.reset(OpMIPS64ADDVconst) + v.AuxInt = int64ToAuxInt(-c + d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64XOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XOR x (MOVVconst [c])) + // cond: is32Bit(c) + // result: (XORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpMIPS64XORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (XOR x x) + // result: (MOVVconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueMIPS64_OpMIPS64XORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (XORconst [-1] x) + // result: (NORconst [0] x) + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + x := v_0 + v.reset(OpMIPS64NORconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(x) + return true + } + // match: (XORconst [c] (MOVVconst [d])) + // result: (MOVVconst [c^d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(c ^ d) + return true + } + // match: (XORconst [c] (XORconst [d] x)) + // cond: is32Bit(c^d) + // result: (XORconst [c^d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpMIPS64XORconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c ^ d)) { + break + } + v.reset(OpMIPS64XORconst) + v.AuxInt = int64ToAuxInt(c ^ d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueMIPS64_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16 x y) + // result: (Select0 (DIVV (SignExt16to64 x) (SignExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVV, types.NewTuple(typ.Int64, typ.Int64)) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16u x y) + // result: (Select0 (DIVVU (ZeroExt16to64 x) (ZeroExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32 x y) + // result: (Select0 (DIVV (SignExt32to64 x) (SignExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVV, types.NewTuple(typ.Int64, typ.Int64)) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMod32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32u x y) + // result: (Select0 (DIVVU (ZeroExt32to64 x) (ZeroExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMod64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod64 x y) + // result: (Select0 (DIVV x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVV, types.NewTuple(typ.Int64, typ.Int64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMod64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod64u x y) + // result: (Select0 (DIVVU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (Select0 (DIVV (SignExt8to64 x) (SignExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVV, types.NewTuple(typ.Int64, typ.Int64)) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (Select0 (DIVVU (ZeroExt8to64 x) (ZeroExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMIPS64DIVVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (MOVBstore dst (MOVBload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpMIPS64MOVBstore) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVBload, typ.Int8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore dst (MOVHload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPS64MOVHstore) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVHload, typ.Int16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (MOVBstore [1] dst (MOVBload [1] src mem) (MOVBstore dst (MOVBload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVBload, typ.Int8) + v0.AuxInt = int32ToAuxInt(1) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVBload, typ.Int8) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [4] {t} dst src mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore dst (MOVWload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPS64MOVWstore) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVWload, typ.Int32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [4] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVHload, typ.Int16) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVHload, typ.Int16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [4] dst src mem) + // result: (MOVBstore [3] dst (MOVBload [3] src mem) (MOVBstore [2] dst (MOVBload [2] src mem) (MOVBstore [1] dst (MOVBload [1] src mem) (MOVBstore dst (MOVBload src mem) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVBload, typ.Int8) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVBload, typ.Int8) + v2.AuxInt = int32ToAuxInt(2) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(1) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVBload, typ.Int8) + v4.AuxInt = int32ToAuxInt(1) + v4.AddArg2(src, mem) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v6 := b.NewValue0(v.Pos, OpMIPS64MOVBload, typ.Int8) + v6.AddArg2(src, mem) + v5.AddArg3(dst, v6, mem) + v3.AddArg3(dst, v4, v5) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [8] {t} dst src mem) + // cond: t.Alignment()%8 == 0 + // result: (MOVVstore dst (MOVVload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%8 == 0) { + break + } + v.reset(OpMIPS64MOVVstore) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVload, typ.UInt64) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [8] {t} dst src mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [4] dst (MOVWload [4] src mem) (MOVWstore dst (MOVWload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPS64MOVWstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVWload, typ.Int32) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVWload, typ.Int32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [8] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [6] dst (MOVHload [6] src mem) (MOVHstore [4] dst (MOVHload [4] src mem) (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVHload, typ.Int16) + v0.AuxInt = int32ToAuxInt(6) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVHload, typ.Int16) + v2.AuxInt = int32ToAuxInt(4) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(2) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVHload, typ.Int16) + v4.AuxInt = int32ToAuxInt(2) + v4.AddArg2(src, mem) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v6 := b.NewValue0(v.Pos, OpMIPS64MOVHload, typ.Int16) + v6.AddArg2(src, mem) + v5.AddArg3(dst, v6, mem) + v3.AddArg3(dst, v4, v5) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [3] dst src mem) + // result: (MOVBstore [2] dst (MOVBload [2] src mem) (MOVBstore [1] dst (MOVBload [1] src mem) (MOVBstore dst (MOVBload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVBload, typ.Int8) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVBload, typ.Int8) + v2.AuxInt = int32ToAuxInt(1) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVBload, typ.Int8) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [6] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [4] dst (MOVHload [4] src mem) (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVHload, typ.Int16) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVHload, typ.Int16) + v2.AuxInt = int32ToAuxInt(2) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVHload, typ.Int16) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [12] {t} dst src mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [8] dst (MOVWload [8] src mem) (MOVWstore [4] dst (MOVWload [4] src mem) (MOVWstore dst (MOVWload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPS64MOVWstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVWload, typ.Int32) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVWstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVWload, typ.Int32) + v2.AuxInt = int32ToAuxInt(4) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVWstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVWload, typ.Int32) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [16] {t} dst src mem) + // cond: t.Alignment()%8 == 0 + // result: (MOVVstore [8] dst (MOVVload [8] src mem) (MOVVstore dst (MOVVload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%8 == 0) { + break + } + v.reset(OpMIPS64MOVVstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [24] {t} dst src mem) + // cond: t.Alignment()%8 == 0 + // result: (MOVVstore [16] dst (MOVVload [16] src mem) (MOVVstore [8] dst (MOVVload [8] src mem) (MOVVstore dst (MOVVload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 24 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%8 == 0) { + break + } + v.reset(OpMIPS64MOVVstore) + v.AuxInt = int32ToAuxInt(16) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(16) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(8) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVload, typ.UInt64) + v2.AuxInt = int32ToAuxInt(8) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVVstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVVload, typ.UInt64) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] {t} dst src mem) + // cond: s%8 == 0 && s >= 24 && s <= 8*128 && t.Alignment()%8 == 0 && logLargeCopy(v, s) + // result: (DUFFCOPY [16 * (128 - s/8)] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(s%8 == 0 && s >= 24 && s <= 8*128 && t.Alignment()%8 == 0 && logLargeCopy(v, s)) { + break + } + v.reset(OpMIPS64DUFFCOPY) + v.AuxInt = int64ToAuxInt(16 * (128 - s/8)) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] {t} dst src mem) + // cond: s > 24 && logLargeCopy(v, s) || t.Alignment()%8 != 0 + // result: (LoweredMove [t.Alignment()] dst src (ADDVconst src [s-moveSize(t.Alignment(), config)]) mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 24 && logLargeCopy(v, s) || t.Alignment()%8 != 0) { + break + } + v.reset(OpMIPS64LoweredMove) + v.AuxInt = int64ToAuxInt(t.Alignment()) + v0 := b.NewValue0(v.Pos, OpMIPS64ADDVconst, src.Type) + v0.AuxInt = int64ToAuxInt(s - moveSize(t.Alignment(), config)) + v0.AddArg(src) + v.AddArg4(dst, src, v0, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpMul16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul16 x y) + // result: (Select1 (MULVU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64MULVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMul32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul32 x y) + // result: (Select1 (MULVU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64MULVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMul64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul64 x y) + // result: (Select1 (MULVU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64MULVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpMul8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul8 x y) + // result: (Select1 (MULVU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect1) + v0 := b.NewValue0(v.Pos, OpMIPS64MULVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq16 x y) + // result: (SGTU (XOR (ZeroExt16to32 x) (ZeroExt16to64 y)) (MOVVconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq32 x y) + // result: (SGTU (XOR (ZeroExt32to64 x) (ZeroExt32to64 y)) (MOVVconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpNeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32F x y) + // result: (FPFlagFalse (CMPEQF x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64FPFlagFalse) + v0 := b.NewValue0(v.Pos, OpMIPS64CMPEQF, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpNeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq64 x y) + // result: (SGTU (XOR x y) (MOVVconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.UInt64) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpNeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64F x y) + // result: (FPFlagFalse (CMPEQD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64FPFlagFalse) + v0 := b.NewValue0(v.Pos, OpMIPS64CMPEQD, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq8 x y) + // result: (SGTU (XOR (ZeroExt8to64 x) (ZeroExt8to64 y)) (MOVVconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NeqPtr x y) + // result: (SGTU (XOR x y) (MOVVconst [0])) + for { + x := v_0 + y := v_1 + v.reset(OpMIPS64SGTU) + v0 := b.NewValue0(v.Pos, OpMIPS64XOR, typ.UInt64) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpNot(v *Value) bool { + v_0 := v.Args[0] + // match: (Not x) + // result: (XORconst [1] x) + for { + x := v_0 + v.reset(OpMIPS64XORconst) + v.AuxInt = int64ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueMIPS64_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + // match: (OffPtr [off] ptr:(SP)) + // cond: is32Bit(off) + // result: (MOVVaddr [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + if ptr.Op != OpSP || !(is32Bit(off)) { + break + } + v.reset(OpMIPS64MOVVaddr) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } + // match: (OffPtr [off] ptr) + // result: (ADDVconst [off] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + v.reset(OpMIPS64ADDVconst) + v.AuxInt = int64ToAuxInt(off) + v.AddArg(ptr) + return true + } +} +func rewriteValueMIPS64_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft16 x (MOVVconst [c])) + // result: (Or16 (Lsh16x64 x (MOVVconst [c&15])) (Rsh16Ux64 x (MOVVconst [-c&15]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpLsh16x64, t) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(c & 15) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh16Ux64, t) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(-c & 15) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueMIPS64_OpRotateLeft32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft32 x (MOVVconst [c])) + // result: (Or32 (Lsh32x64 x (MOVVconst [c&31])) (Rsh32Ux64 x (MOVVconst [-c&31]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr32) + v0 := b.NewValue0(v.Pos, OpLsh32x64, t) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(c & 31) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh32Ux64, t) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(-c & 31) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueMIPS64_OpRotateLeft64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft64 x (MOVVconst [c])) + // result: (Or64 (Lsh64x64 x (MOVVconst [c&63])) (Rsh64Ux64 x (MOVVconst [-c&63]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr64) + v0 := b.NewValue0(v.Pos, OpLsh64x64, t) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(c & 63) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh64Ux64, t) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(-c & 63) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueMIPS64_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft8 x (MOVVconst [c])) + // result: (Or8 (Lsh8x64 x (MOVVconst [c&7])) (Rsh8Ux64 x (MOVVconst [-c&7]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpLsh8x64, t) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(c & 7) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh8Ux64, t) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(-c & 7) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueMIPS64_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux16 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) (SRLV (ZeroExt16to64 x) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v5 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v5.AddArg(x) + v4.AddArg2(v5, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux32 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) (SRLV (ZeroExt16to64 x) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v5 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v5.AddArg(x) + v4.AddArg2(v5, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) y)) (SRLV (ZeroExt16to64 x) y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v0.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(x) + v3.AddArg2(v4, y) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux8 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) (SRLV (ZeroExt16to64 x) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v5 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v5.AddArg(x) + v4.AddArg2(v5, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x16 x y) + // result: (SRAV (SignExt16to64 x) (OR (NEGV (SGTU (ZeroExt16to64 y) (MOVVconst [63]))) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x32 x y) + // result: (SRAV (SignExt16to64 x) (OR (NEGV (SGTU (ZeroExt32to64 y) (MOVVconst [63]))) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 x y) + // result: (SRAV (SignExt16to64 x) (OR (NEGV (SGTU y (MOVVconst [63]))) y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v3.AddArg2(y, v4) + v2.AddArg(v3) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x8 x y) + // result: (SRAV (SignExt16to64 x) (OR (NEGV (SGTU (ZeroExt8to64 y) (MOVVconst [63]))) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux16 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) (SRLV (ZeroExt32to64 x) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v5 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v5.AddArg(x) + v4.AddArg2(v5, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux32 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) (SRLV (ZeroExt32to64 x) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v5 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v5.AddArg(x) + v4.AddArg2(v5, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux64 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) y)) (SRLV (ZeroExt32to64 x) y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v0.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(x) + v3.AddArg2(v4, y) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux8 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) (SRLV (ZeroExt32to64 x) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v5 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v5.AddArg(x) + v4.AddArg2(v5, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x16 x y) + // result: (SRAV (SignExt32to64 x) (OR (NEGV (SGTU (ZeroExt16to64 y) (MOVVconst [63]))) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x32 x y) + // result: (SRAV (SignExt32to64 x) (OR (NEGV (SGTU (ZeroExt32to64 y) (MOVVconst [63]))) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x64 x y) + // result: (SRAV (SignExt32to64 x) (OR (NEGV (SGTU y (MOVVconst [63]))) y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v3.AddArg2(y, v4) + v2.AddArg(v3) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x8 x y) + // result: (SRAV (SignExt32to64 x) (OR (NEGV (SGTU (ZeroExt8to64 y) (MOVVconst [63]))) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh64Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux16 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) (SRLV x (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh64Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux32 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) (SRLV x (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh64Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux64 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) y)) (SRLV x y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v0.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v3.AddArg2(x, y) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpRsh64Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux8 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) (SRLV x (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v4.AddArg2(x, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x16 x y) + // result: (SRAV x (OR (NEGV (SGTU (ZeroExt16to64 y) (MOVVconst [63]))) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v1 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v2 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueMIPS64_OpRsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x32 x y) + // result: (SRAV x (OR (NEGV (SGTU (ZeroExt32to64 y) (MOVVconst [63]))) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v1 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v2 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueMIPS64_OpRsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x64 x y) + // result: (SRAV x (OR (NEGV (SGTU y (MOVVconst [63]))) y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v1 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v2 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(63) + v2.AddArg2(y, v3) + v1.AddArg(v2) + v0.AddArg2(v1, y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueMIPS64_OpRsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x8 x y) + // result: (SRAV x (OR (NEGV (SGTU (ZeroExt8to64 y) (MOVVconst [63]))) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v1 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v2 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueMIPS64_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux16 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt16to64 y))) (SRLV (ZeroExt8to64 x) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v5 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v5.AddArg(x) + v4.AddArg2(v5, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux32 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt32to64 y))) (SRLV (ZeroExt8to64 x) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v5 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v5.AddArg(x) + v4.AddArg2(v5, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) y)) (SRLV (ZeroExt8to64 x) y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v1.AddArg2(v2, y) + v0.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(x) + v3.AddArg2(v4, y) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueMIPS64_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux8 x y) + // result: (AND (NEGV (SGTU (MOVVconst [64]) (ZeroExt8to64 y))) (SRLV (ZeroExt8to64 x) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64AND) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v1 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v1.AddArg2(v2, v3) + v0.AddArg(v1) + v4 := b.NewValue0(v.Pos, OpMIPS64SRLV, t) + v5 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v5.AddArg(x) + v4.AddArg2(v5, v3) + v.AddArg2(v0, v4) + return true + } +} +func rewriteValueMIPS64_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x16 x y) + // result: (SRAV (SignExt8to64 x) (OR (NEGV (SGTU (ZeroExt16to64 y) (MOVVconst [63]))) (ZeroExt16to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x32 x y) + // result: (SRAV (SignExt8to64 x) (OR (NEGV (SGTU (ZeroExt32to64 y) (MOVVconst [63]))) (ZeroExt32to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x64 x y) + // result: (SRAV (SignExt8to64 x) (OR (NEGV (SGTU y (MOVVconst [63]))) y)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v4.AuxInt = int64ToAuxInt(63) + v3.AddArg2(y, v4) + v2.AddArg(v3) + v1.AddArg2(v2, y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x8 x y) + // result: (SRAV (SignExt8to64 x) (OR (NEGV (SGTU (ZeroExt8to64 y) (MOVVconst [63]))) (ZeroExt8to64 y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpMIPS64SRAV) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpMIPS64OR, t) + v2 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SGTU, typ.Bool) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v5 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueMIPS64_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select0 (Mul64uover x y)) + // result: (Select1 (MULVU x y)) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpSelect1) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpMIPS64MULVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + // match: (Select0 (Add64carry x y c)) + // result: (ADDV (ADDV x y) c) + for { + t := v.Type + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpMIPS64ADDV) + v0 := b.NewValue0(v.Pos, OpMIPS64ADDV, t) + v0.AddArg2(x, y) + v.AddArg2(v0, c) + return true + } + // match: (Select0 (Sub64borrow x y c)) + // result: (SUBV (SUBV x y) c) + for { + t := v.Type + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpMIPS64SUBV) + v0 := b.NewValue0(v.Pos, OpMIPS64SUBV, t) + v0.AddArg2(x, y) + v.AddArg2(v0, c) + return true + } + // match: (Select0 (DIVVU _ (MOVVconst [1]))) + // result: (MOVVconst [0]) + for { + if v_0.Op != OpMIPS64DIVVU { + break + } + _ = v_0.Args[1] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 1 { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Select0 (DIVVU x (MOVVconst [c]))) + // cond: isPowerOfTwo(c) + // result: (ANDconst [c-1] x) + for { + if v_0.Op != OpMIPS64DIVVU { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpMIPS64ANDconst) + v.AuxInt = int64ToAuxInt(c - 1) + v.AddArg(x) + return true + } + // match: (Select0 (DIVV (MOVVconst [c]) (MOVVconst [d]))) + // cond: d != 0 + // result: (MOVVconst [c%d]) + for { + if v_0.Op != OpMIPS64DIVV { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(c % d) + return true + } + // match: (Select0 (DIVVU (MOVVconst [c]) (MOVVconst [d]))) + // cond: d != 0 + // result: (MOVVconst [int64(uint64(c)%uint64(d))]) + for { + if v_0.Op != OpMIPS64DIVVU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) % uint64(d))) + return true + } + return false +} +func rewriteValueMIPS64_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select1 (Mul64uover x y)) + // result: (SGTU (Select0 (MULVU x y)) (MOVVconst [0])) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpMIPS64SGTU) + v.Type = typ.Bool + v0 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpMIPS64MULVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v1.AddArg2(x, y) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + // match: (Select1 (Add64carry x y c)) + // result: (OR (SGTU x s:(ADDV x y)) (SGTU s (ADDV s c))) + for { + t := v.Type + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpMIPS64OR) + v0 := b.NewValue0(v.Pos, OpMIPS64SGTU, t) + s := b.NewValue0(v.Pos, OpMIPS64ADDV, t) + s.AddArg2(x, y) + v0.AddArg2(x, s) + v2 := b.NewValue0(v.Pos, OpMIPS64SGTU, t) + v3 := b.NewValue0(v.Pos, OpMIPS64ADDV, t) + v3.AddArg2(s, c) + v2.AddArg2(s, v3) + v.AddArg2(v0, v2) + return true + } + // match: (Select1 (Sub64borrow x y c)) + // result: (OR (SGTU s:(SUBV x y) x) (SGTU (SUBV s c) s)) + for { + t := v.Type + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpMIPS64OR) + v0 := b.NewValue0(v.Pos, OpMIPS64SGTU, t) + s := b.NewValue0(v.Pos, OpMIPS64SUBV, t) + s.AddArg2(x, y) + v0.AddArg2(s, x) + v2 := b.NewValue0(v.Pos, OpMIPS64SGTU, t) + v3 := b.NewValue0(v.Pos, OpMIPS64SUBV, t) + v3.AddArg2(s, c) + v2.AddArg2(v3, s) + v.AddArg2(v0, v2) + return true + } + // match: (Select1 (MULVU x (MOVVconst [-1]))) + // result: (NEGV x) + for { + if v_0.Op != OpMIPS64MULVU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != -1 { + continue + } + v.reset(OpMIPS64NEGV) + v.AddArg(x) + return true + } + break + } + // match: (Select1 (MULVU _ (MOVVconst [0]))) + // result: (MOVVconst [0]) + for { + if v_0.Op != OpMIPS64MULVU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 0 { + continue + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (Select1 (MULVU x (MOVVconst [1]))) + // result: x + for { + if v_0.Op != OpMIPS64MULVU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Select1 (MULVU x (MOVVconst [c]))) + // cond: isPowerOfTwo(c) + // result: (SLLVconst [log64(c)] x) + for { + if v_0.Op != OpMIPS64MULVU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpMIPS64MOVVconst { + continue + } + c := auxIntToInt64(v_0_1.AuxInt) + if !(isPowerOfTwo(c)) { + continue + } + v.reset(OpMIPS64SLLVconst) + v.AuxInt = int64ToAuxInt(log64(c)) + v.AddArg(x) + return true + } + break + } + // match: (Select1 (DIVVU x (MOVVconst [1]))) + // result: x + for { + if v_0.Op != OpMIPS64DIVVU { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 1 { + break + } + v.copyOf(x) + return true + } + // match: (Select1 (DIVVU x (MOVVconst [c]))) + // cond: isPowerOfTwo(c) + // result: (SRLVconst [log64(c)] x) + for { + if v_0.Op != OpMIPS64DIVVU { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpMIPS64SRLVconst) + v.AuxInt = int64ToAuxInt(log64(c)) + v.AddArg(x) + return true + } + // match: (Select1 (MULVU (MOVVconst [c]) (MOVVconst [d]))) + // result: (MOVVconst [c*d]) + for { + if v_0.Op != OpMIPS64MULVU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpMIPS64MOVVconst { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_0_1.Op != OpMIPS64MOVVconst { + continue + } + d := auxIntToInt64(v_0_1.AuxInt) + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(c * d) + return true + } + break + } + // match: (Select1 (DIVV (MOVVconst [c]) (MOVVconst [d]))) + // cond: d != 0 + // result: (MOVVconst [c/d]) + for { + if v_0.Op != OpMIPS64DIVV { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(c / d) + return true + } + // match: (Select1 (DIVVU (MOVVconst [c]) (MOVVconst [d]))) + // cond: d != 0 + // result: (MOVVconst [int64(uint64(c)/uint64(d))]) + for { + if v_0.Op != OpMIPS64DIVVU { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpMIPS64MOVVconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst { + break + } + d := auxIntToInt64(v_0_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpMIPS64MOVVconst) + v.AuxInt = int64ToAuxInt(int64(uint64(c) / uint64(d))) + return true + } + return false +} +func rewriteValueMIPS64_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Slicemask x) + // result: (SRAVconst (NEGV x) [63]) + for { + t := v.Type + x := v_0 + v.reset(OpMIPS64SRAVconst) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpMIPS64NEGV, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueMIPS64_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (MOVBstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(OpMIPS64MOVBstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (MOVHstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(OpMIPS64MOVHstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && !t.IsFloat() + // result: (MOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && !t.IsFloat()) { + break + } + v.reset(OpMIPS64MOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && !t.IsFloat() + // result: (MOVVstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && !t.IsFloat()) { + break + } + v.reset(OpMIPS64MOVVstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && t.IsFloat() + // result: (MOVFstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && t.IsFloat()) { + break + } + v.reset(OpMIPS64MOVFstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && t.IsFloat() + // result: (MOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && t.IsFloat()) { + break + } + v.reset(OpMIPS64MOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueMIPS64_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] ptr mem) + // result: (MOVBstore ptr (MOVVconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpMIPS64MOVBstore) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [2] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore ptr (MOVVconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPS64MOVHstore) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [2] ptr mem) + // result: (MOVBstore [1] ptr (MOVVconst [0]) (MOVBstore [0] ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [4] {t} ptr mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore ptr (MOVVconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPS64MOVWstore) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [4] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [2] ptr (MOVVconst [0]) (MOVHstore [0] ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [4] ptr mem) + // result: (MOVBstore [3] ptr (MOVVconst [0]) (MOVBstore [2] ptr (MOVVconst [0]) (MOVBstore [1] ptr (MOVVconst [0]) (MOVBstore [0] ptr (MOVVconst [0]) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(1) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(0) + v3.AddArg3(ptr, v0, mem) + v2.AddArg3(ptr, v0, v3) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [8] {t} ptr mem) + // cond: t.Alignment()%8 == 0 + // result: (MOVVstore ptr (MOVVconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%8 == 0) { + break + } + v.reset(OpMIPS64MOVVstore) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [8] {t} ptr mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [4] ptr (MOVVconst [0]) (MOVWstore [0] ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPS64MOVWstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVWstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [8] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [6] ptr (MOVVconst [0]) (MOVHstore [4] ptr (MOVVconst [0]) (MOVHstore [2] ptr (MOVVconst [0]) (MOVHstore [0] ptr (MOVVconst [0]) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(2) + v3 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(0) + v3.AddArg3(ptr, v0, mem) + v2.AddArg3(ptr, v0, v3) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [3] ptr mem) + // result: (MOVBstore [2] ptr (MOVVconst [0]) (MOVBstore [1] ptr (MOVVconst [0]) (MOVBstore [0] ptr (MOVVconst [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpMIPS64MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVBstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(0) + v2.AddArg3(ptr, v0, mem) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [6] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [4] ptr (MOVVconst [0]) (MOVHstore [2] ptr (MOVVconst [0]) (MOVHstore [0] ptr (MOVVconst [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpMIPS64MOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVHstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(0) + v2.AddArg3(ptr, v0, mem) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [12] {t} ptr mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [8] ptr (MOVVconst [0]) (MOVWstore [4] ptr (MOVVconst [0]) (MOVWstore [0] ptr (MOVVconst [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpMIPS64MOVWstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVWstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVWstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(0) + v2.AddArg3(ptr, v0, mem) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [16] {t} ptr mem) + // cond: t.Alignment()%8 == 0 + // result: (MOVVstore [8] ptr (MOVVconst [0]) (MOVVstore [0] ptr (MOVVconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%8 == 0) { + break + } + v.reset(OpMIPS64MOVVstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [24] {t} ptr mem) + // cond: t.Alignment()%8 == 0 + // result: (MOVVstore [16] ptr (MOVVconst [0]) (MOVVstore [8] ptr (MOVVconst [0]) (MOVVstore [0] ptr (MOVVconst [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 24 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%8 == 0) { + break + } + v.reset(OpMIPS64MOVVstore) + v.AuxInt = int32ToAuxInt(16) + v0 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpMIPS64MOVVstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(8) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(0) + v2.AddArg3(ptr, v0, mem) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [s] {t} ptr mem) + // cond: s%8 == 0 && s > 24 && s <= 8*128 && t.Alignment()%8 == 0 + // result: (DUFFZERO [8 * (128 - s/8)] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(s%8 == 0 && s > 24 && s <= 8*128 && t.Alignment()%8 == 0) { + break + } + v.reset(OpMIPS64DUFFZERO) + v.AuxInt = int64ToAuxInt(8 * (128 - s/8)) + v.AddArg2(ptr, mem) + return true + } + // match: (Zero [s] {t} ptr mem) + // cond: s > 8*128 || t.Alignment()%8 != 0 + // result: (LoweredZero [t.Alignment()] ptr (ADDVconst ptr [s-moveSize(t.Alignment(), config)]) mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(s > 8*128 || t.Alignment()%8 != 0) { + break + } + v.reset(OpMIPS64LoweredZero) + v.AuxInt = int64ToAuxInt(t.Alignment()) + v0 := b.NewValue0(v.Pos, OpMIPS64ADDVconst, ptr.Type) + v0.AuxInt = int64ToAuxInt(s - moveSize(t.Alignment(), config)) + v0.AddArg(ptr) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteBlockMIPS64(b *Block) bool { + switch b.Kind { + case BlockMIPS64EQ: + // match: (EQ (FPFlagTrue cmp) yes no) + // result: (FPF cmp yes no) + for b.Controls[0].Op == OpMIPS64FPFlagTrue { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockMIPS64FPF, cmp) + return true + } + // match: (EQ (FPFlagFalse cmp) yes no) + // result: (FPT cmp yes no) + for b.Controls[0].Op == OpMIPS64FPFlagFalse { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockMIPS64FPT, cmp) + return true + } + // match: (EQ (XORconst [1] cmp:(SGT _ _)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpMIPS64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPS64SGT { + break + } + b.resetWithControl(BlockMIPS64NE, cmp) + return true + } + // match: (EQ (XORconst [1] cmp:(SGTU _ _)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpMIPS64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPS64SGTU { + break + } + b.resetWithControl(BlockMIPS64NE, cmp) + return true + } + // match: (EQ (XORconst [1] cmp:(SGTconst _)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpMIPS64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPS64SGTconst { + break + } + b.resetWithControl(BlockMIPS64NE, cmp) + return true + } + // match: (EQ (XORconst [1] cmp:(SGTUconst _)) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpMIPS64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPS64SGTUconst { + break + } + b.resetWithControl(BlockMIPS64NE, cmp) + return true + } + // match: (EQ (SGTUconst [1] x) yes no) + // result: (NE x yes no) + for b.Controls[0].Op == OpMIPS64SGTUconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockMIPS64NE, x) + return true + } + // match: (EQ (SGTU x (MOVVconst [0])) yes no) + // result: (EQ x yes no) + for b.Controls[0].Op == OpMIPS64SGTU { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockMIPS64EQ, x) + return true + } + // match: (EQ (SGTconst [0] x) yes no) + // result: (GEZ x yes no) + for b.Controls[0].Op == OpMIPS64SGTconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockMIPS64GEZ, x) + return true + } + // match: (EQ (SGT x (MOVVconst [0])) yes no) + // result: (LEZ x yes no) + for b.Controls[0].Op == OpMIPS64SGT { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockMIPS64LEZ, x) + return true + } + // match: (EQ (MOVVconst [0]) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + b.Reset(BlockFirst) + return true + } + // match: (EQ (MOVVconst [c]) yes no) + // cond: c != 0 + // result: (First no yes) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c != 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockMIPS64GEZ: + // match: (GEZ (MOVVconst [c]) yes no) + // cond: c >= 0 + // result: (First yes no) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c >= 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GEZ (MOVVconst [c]) yes no) + // cond: c < 0 + // result: (First no yes) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c < 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockMIPS64GTZ: + // match: (GTZ (MOVVconst [c]) yes no) + // cond: c > 0 + // result: (First yes no) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c > 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (GTZ (MOVVconst [c]) yes no) + // cond: c <= 0 + // result: (First no yes) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c <= 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockIf: + // match: (If cond yes no) + // result: (NE cond yes no) + for { + cond := b.Controls[0] + b.resetWithControl(BlockMIPS64NE, cond) + return true + } + case BlockMIPS64LEZ: + // match: (LEZ (MOVVconst [c]) yes no) + // cond: c <= 0 + // result: (First yes no) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c <= 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LEZ (MOVVconst [c]) yes no) + // cond: c > 0 + // result: (First no yes) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c > 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockMIPS64LTZ: + // match: (LTZ (MOVVconst [c]) yes no) + // cond: c < 0 + // result: (First yes no) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c < 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (LTZ (MOVVconst [c]) yes no) + // cond: c >= 0 + // result: (First no yes) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c >= 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockMIPS64NE: + // match: (NE (FPFlagTrue cmp) yes no) + // result: (FPT cmp yes no) + for b.Controls[0].Op == OpMIPS64FPFlagTrue { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockMIPS64FPT, cmp) + return true + } + // match: (NE (FPFlagFalse cmp) yes no) + // result: (FPF cmp yes no) + for b.Controls[0].Op == OpMIPS64FPFlagFalse { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockMIPS64FPF, cmp) + return true + } + // match: (NE (XORconst [1] cmp:(SGT _ _)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpMIPS64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPS64SGT { + break + } + b.resetWithControl(BlockMIPS64EQ, cmp) + return true + } + // match: (NE (XORconst [1] cmp:(SGTU _ _)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpMIPS64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPS64SGTU { + break + } + b.resetWithControl(BlockMIPS64EQ, cmp) + return true + } + // match: (NE (XORconst [1] cmp:(SGTconst _)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpMIPS64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPS64SGTconst { + break + } + b.resetWithControl(BlockMIPS64EQ, cmp) + return true + } + // match: (NE (XORconst [1] cmp:(SGTUconst _)) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpMIPS64XORconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + cmp := v_0.Args[0] + if cmp.Op != OpMIPS64SGTUconst { + break + } + b.resetWithControl(BlockMIPS64EQ, cmp) + return true + } + // match: (NE (SGTUconst [1] x) yes no) + // result: (EQ x yes no) + for b.Controls[0].Op == OpMIPS64SGTUconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockMIPS64EQ, x) + return true + } + // match: (NE (SGTU x (MOVVconst [0])) yes no) + // result: (NE x yes no) + for b.Controls[0].Op == OpMIPS64SGTU { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockMIPS64NE, x) + return true + } + // match: (NE (SGTconst [0] x) yes no) + // result: (LTZ x yes no) + for b.Controls[0].Op == OpMIPS64SGTconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_0.Args[0] + b.resetWithControl(BlockMIPS64LTZ, x) + return true + } + // match: (NE (SGT x (MOVVconst [0])) yes no) + // result: (GTZ x yes no) + for b.Controls[0].Op == OpMIPS64SGT { + v_0 := b.Controls[0] + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpMIPS64MOVVconst || auxIntToInt64(v_0_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockMIPS64GTZ, x) + return true + } + // match: (NE (MOVVconst [0]) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (NE (MOVVconst [c]) yes no) + // cond: c != 0 + // result: (First yes no) + for b.Controls[0].Op == OpMIPS64MOVVconst { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + if !(c != 0) { + break + } + b.Reset(BlockFirst) + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteMIPS64latelower.go b/go/src/cmd/compile/internal/ssa/rewriteMIPS64latelower.go new file mode 100644 index 0000000000000000000000000000000000000000..e83dff15c23341a6e85f6a5dd8599b8f08368cce --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteMIPS64latelower.go @@ -0,0 +1,26 @@ +// Code generated from _gen/MIPS64latelower.rules using 'go generate'; DO NOT EDIT. + +package ssa + +func rewriteValueMIPS64latelower(v *Value) bool { + switch v.Op { + case OpMIPS64MOVVconst: + return rewriteValueMIPS64latelower_OpMIPS64MOVVconst(v) + } + return false +} +func rewriteValueMIPS64latelower_OpMIPS64MOVVconst(v *Value) bool { + // match: (MOVVconst [0]) + // result: (ZERO) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + v.reset(OpMIPS64ZERO) + return true + } + return false +} +func rewriteBlockMIPS64latelower(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewritePPC64.go b/go/src/cmd/compile/internal/ssa/rewritePPC64.go new file mode 100644 index 0000000000000000000000000000000000000000..2225aee97537dbabd5c7923e7891422fff5c5cb1 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewritePPC64.go @@ -0,0 +1,16581 @@ +// Code generated from _gen/PPC64.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "internal/buildcfg" +import "math" +import "cmd/compile/internal/types" + +func rewriteValuePPC64(v *Value) bool { + switch v.Op { + case OpAbs: + v.Op = OpPPC64FABS + return true + case OpAdd16: + v.Op = OpPPC64ADD + return true + case OpAdd32: + v.Op = OpPPC64ADD + return true + case OpAdd32F: + v.Op = OpPPC64FADDS + return true + case OpAdd64: + v.Op = OpPPC64ADD + return true + case OpAdd64F: + v.Op = OpPPC64FADD + return true + case OpAdd8: + v.Op = OpPPC64ADD + return true + case OpAddPtr: + v.Op = OpPPC64ADD + return true + case OpAddr: + return rewriteValuePPC64_OpAddr(v) + case OpAnd16: + v.Op = OpPPC64AND + return true + case OpAnd32: + v.Op = OpPPC64AND + return true + case OpAnd64: + v.Op = OpPPC64AND + return true + case OpAnd8: + v.Op = OpPPC64AND + return true + case OpAndB: + v.Op = OpPPC64AND + return true + case OpAtomicAdd32: + v.Op = OpPPC64LoweredAtomicAdd32 + return true + case OpAtomicAdd64: + v.Op = OpPPC64LoweredAtomicAdd64 + return true + case OpAtomicAnd32: + v.Op = OpPPC64LoweredAtomicAnd32 + return true + case OpAtomicAnd8: + v.Op = OpPPC64LoweredAtomicAnd8 + return true + case OpAtomicCompareAndSwap32: + return rewriteValuePPC64_OpAtomicCompareAndSwap32(v) + case OpAtomicCompareAndSwap64: + return rewriteValuePPC64_OpAtomicCompareAndSwap64(v) + case OpAtomicCompareAndSwapRel32: + return rewriteValuePPC64_OpAtomicCompareAndSwapRel32(v) + case OpAtomicExchange32: + v.Op = OpPPC64LoweredAtomicExchange32 + return true + case OpAtomicExchange64: + v.Op = OpPPC64LoweredAtomicExchange64 + return true + case OpAtomicExchange8: + v.Op = OpPPC64LoweredAtomicExchange8 + return true + case OpAtomicLoad32: + return rewriteValuePPC64_OpAtomicLoad32(v) + case OpAtomicLoad64: + return rewriteValuePPC64_OpAtomicLoad64(v) + case OpAtomicLoad8: + return rewriteValuePPC64_OpAtomicLoad8(v) + case OpAtomicLoadAcq32: + return rewriteValuePPC64_OpAtomicLoadAcq32(v) + case OpAtomicLoadAcq64: + return rewriteValuePPC64_OpAtomicLoadAcq64(v) + case OpAtomicLoadPtr: + return rewriteValuePPC64_OpAtomicLoadPtr(v) + case OpAtomicOr32: + v.Op = OpPPC64LoweredAtomicOr32 + return true + case OpAtomicOr8: + v.Op = OpPPC64LoweredAtomicOr8 + return true + case OpAtomicStore32: + return rewriteValuePPC64_OpAtomicStore32(v) + case OpAtomicStore64: + return rewriteValuePPC64_OpAtomicStore64(v) + case OpAtomicStore8: + return rewriteValuePPC64_OpAtomicStore8(v) + case OpAtomicStoreRel32: + return rewriteValuePPC64_OpAtomicStoreRel32(v) + case OpAtomicStoreRel64: + return rewriteValuePPC64_OpAtomicStoreRel64(v) + case OpAvg64u: + return rewriteValuePPC64_OpAvg64u(v) + case OpBitLen16: + return rewriteValuePPC64_OpBitLen16(v) + case OpBitLen32: + return rewriteValuePPC64_OpBitLen32(v) + case OpBitLen64: + return rewriteValuePPC64_OpBitLen64(v) + case OpBitLen8: + return rewriteValuePPC64_OpBitLen8(v) + case OpBswap16: + return rewriteValuePPC64_OpBswap16(v) + case OpBswap32: + return rewriteValuePPC64_OpBswap32(v) + case OpBswap64: + return rewriteValuePPC64_OpBswap64(v) + case OpCeil: + v.Op = OpPPC64FCEIL + return true + case OpClosureCall: + v.Op = OpPPC64CALLclosure + return true + case OpCom16: + return rewriteValuePPC64_OpCom16(v) + case OpCom32: + return rewriteValuePPC64_OpCom32(v) + case OpCom64: + return rewriteValuePPC64_OpCom64(v) + case OpCom8: + return rewriteValuePPC64_OpCom8(v) + case OpCondSelect: + return rewriteValuePPC64_OpCondSelect(v) + case OpConst16: + return rewriteValuePPC64_OpConst16(v) + case OpConst32: + return rewriteValuePPC64_OpConst32(v) + case OpConst32F: + v.Op = OpPPC64FMOVSconst + return true + case OpConst64: + return rewriteValuePPC64_OpConst64(v) + case OpConst64F: + v.Op = OpPPC64FMOVDconst + return true + case OpConst8: + return rewriteValuePPC64_OpConst8(v) + case OpConstBool: + return rewriteValuePPC64_OpConstBool(v) + case OpConstNil: + return rewriteValuePPC64_OpConstNil(v) + case OpCopysign: + return rewriteValuePPC64_OpCopysign(v) + case OpCtz16: + return rewriteValuePPC64_OpCtz16(v) + case OpCtz16NonZero: + v.Op = OpCtz64 + return true + case OpCtz32: + return rewriteValuePPC64_OpCtz32(v) + case OpCtz32NonZero: + v.Op = OpCtz64 + return true + case OpCtz64: + return rewriteValuePPC64_OpCtz64(v) + case OpCtz64NonZero: + v.Op = OpCtz64 + return true + case OpCtz8: + return rewriteValuePPC64_OpCtz8(v) + case OpCtz8NonZero: + v.Op = OpCtz64 + return true + case OpCvt32Fto32: + return rewriteValuePPC64_OpCvt32Fto32(v) + case OpCvt32Fto64: + return rewriteValuePPC64_OpCvt32Fto64(v) + case OpCvt32Fto64F: + v.Op = OpCopy + return true + case OpCvt32to32F: + return rewriteValuePPC64_OpCvt32to32F(v) + case OpCvt32to64F: + return rewriteValuePPC64_OpCvt32to64F(v) + case OpCvt64Fto32: + return rewriteValuePPC64_OpCvt64Fto32(v) + case OpCvt64Fto32F: + v.Op = OpPPC64FRSP + return true + case OpCvt64Fto64: + return rewriteValuePPC64_OpCvt64Fto64(v) + case OpCvt64to32F: + return rewriteValuePPC64_OpCvt64to32F(v) + case OpCvt64to64F: + return rewriteValuePPC64_OpCvt64to64F(v) + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpDiv16: + return rewriteValuePPC64_OpDiv16(v) + case OpDiv16u: + return rewriteValuePPC64_OpDiv16u(v) + case OpDiv32: + return rewriteValuePPC64_OpDiv32(v) + case OpDiv32F: + v.Op = OpPPC64FDIVS + return true + case OpDiv32u: + v.Op = OpPPC64DIVWU + return true + case OpDiv64: + return rewriteValuePPC64_OpDiv64(v) + case OpDiv64F: + v.Op = OpPPC64FDIV + return true + case OpDiv64u: + v.Op = OpPPC64DIVDU + return true + case OpDiv8: + return rewriteValuePPC64_OpDiv8(v) + case OpDiv8u: + return rewriteValuePPC64_OpDiv8u(v) + case OpEq16: + return rewriteValuePPC64_OpEq16(v) + case OpEq32: + return rewriteValuePPC64_OpEq32(v) + case OpEq32F: + return rewriteValuePPC64_OpEq32F(v) + case OpEq64: + return rewriteValuePPC64_OpEq64(v) + case OpEq64F: + return rewriteValuePPC64_OpEq64F(v) + case OpEq8: + return rewriteValuePPC64_OpEq8(v) + case OpEqB: + return rewriteValuePPC64_OpEqB(v) + case OpEqPtr: + return rewriteValuePPC64_OpEqPtr(v) + case OpFMA: + v.Op = OpPPC64FMADD + return true + case OpFloor: + v.Op = OpPPC64FFLOOR + return true + case OpGetCallerPC: + v.Op = OpPPC64LoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = OpPPC64LoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = OpPPC64LoweredGetClosurePtr + return true + case OpHmul32: + v.Op = OpPPC64MULHW + return true + case OpHmul32u: + v.Op = OpPPC64MULHWU + return true + case OpHmul64: + v.Op = OpPPC64MULHD + return true + case OpHmul64u: + v.Op = OpPPC64MULHDU + return true + case OpInterCall: + v.Op = OpPPC64CALLinter + return true + case OpIsInBounds: + return rewriteValuePPC64_OpIsInBounds(v) + case OpIsNonNil: + return rewriteValuePPC64_OpIsNonNil(v) + case OpIsSliceInBounds: + return rewriteValuePPC64_OpIsSliceInBounds(v) + case OpLeq16: + return rewriteValuePPC64_OpLeq16(v) + case OpLeq16U: + return rewriteValuePPC64_OpLeq16U(v) + case OpLeq32: + return rewriteValuePPC64_OpLeq32(v) + case OpLeq32F: + return rewriteValuePPC64_OpLeq32F(v) + case OpLeq32U: + return rewriteValuePPC64_OpLeq32U(v) + case OpLeq64: + return rewriteValuePPC64_OpLeq64(v) + case OpLeq64F: + return rewriteValuePPC64_OpLeq64F(v) + case OpLeq64U: + return rewriteValuePPC64_OpLeq64U(v) + case OpLeq8: + return rewriteValuePPC64_OpLeq8(v) + case OpLeq8U: + return rewriteValuePPC64_OpLeq8U(v) + case OpLess16: + return rewriteValuePPC64_OpLess16(v) + case OpLess16U: + return rewriteValuePPC64_OpLess16U(v) + case OpLess32: + return rewriteValuePPC64_OpLess32(v) + case OpLess32F: + return rewriteValuePPC64_OpLess32F(v) + case OpLess32U: + return rewriteValuePPC64_OpLess32U(v) + case OpLess64: + return rewriteValuePPC64_OpLess64(v) + case OpLess64F: + return rewriteValuePPC64_OpLess64F(v) + case OpLess64U: + return rewriteValuePPC64_OpLess64U(v) + case OpLess8: + return rewriteValuePPC64_OpLess8(v) + case OpLess8U: + return rewriteValuePPC64_OpLess8U(v) + case OpLoad: + return rewriteValuePPC64_OpLoad(v) + case OpLocalAddr: + return rewriteValuePPC64_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValuePPC64_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValuePPC64_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValuePPC64_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValuePPC64_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValuePPC64_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValuePPC64_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValuePPC64_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValuePPC64_OpLsh32x8(v) + case OpLsh64x16: + return rewriteValuePPC64_OpLsh64x16(v) + case OpLsh64x32: + return rewriteValuePPC64_OpLsh64x32(v) + case OpLsh64x64: + return rewriteValuePPC64_OpLsh64x64(v) + case OpLsh64x8: + return rewriteValuePPC64_OpLsh64x8(v) + case OpLsh8x16: + return rewriteValuePPC64_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValuePPC64_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValuePPC64_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValuePPC64_OpLsh8x8(v) + case OpMax32F: + return rewriteValuePPC64_OpMax32F(v) + case OpMax64F: + return rewriteValuePPC64_OpMax64F(v) + case OpMin32F: + return rewriteValuePPC64_OpMin32F(v) + case OpMin64F: + return rewriteValuePPC64_OpMin64F(v) + case OpMod16: + return rewriteValuePPC64_OpMod16(v) + case OpMod16u: + return rewriteValuePPC64_OpMod16u(v) + case OpMod32: + return rewriteValuePPC64_OpMod32(v) + case OpMod32u: + return rewriteValuePPC64_OpMod32u(v) + case OpMod64: + return rewriteValuePPC64_OpMod64(v) + case OpMod64u: + return rewriteValuePPC64_OpMod64u(v) + case OpMod8: + return rewriteValuePPC64_OpMod8(v) + case OpMod8u: + return rewriteValuePPC64_OpMod8u(v) + case OpMove: + return rewriteValuePPC64_OpMove(v) + case OpMul16: + v.Op = OpPPC64MULLW + return true + case OpMul32: + v.Op = OpPPC64MULLW + return true + case OpMul32F: + v.Op = OpPPC64FMULS + return true + case OpMul64: + v.Op = OpPPC64MULLD + return true + case OpMul64F: + v.Op = OpPPC64FMUL + return true + case OpMul8: + v.Op = OpPPC64MULLW + return true + case OpNeg16: + v.Op = OpPPC64NEG + return true + case OpNeg32: + v.Op = OpPPC64NEG + return true + case OpNeg32F: + v.Op = OpPPC64FNEG + return true + case OpNeg64: + v.Op = OpPPC64NEG + return true + case OpNeg64F: + v.Op = OpPPC64FNEG + return true + case OpNeg8: + v.Op = OpPPC64NEG + return true + case OpNeq16: + return rewriteValuePPC64_OpNeq16(v) + case OpNeq32: + return rewriteValuePPC64_OpNeq32(v) + case OpNeq32F: + return rewriteValuePPC64_OpNeq32F(v) + case OpNeq64: + return rewriteValuePPC64_OpNeq64(v) + case OpNeq64F: + return rewriteValuePPC64_OpNeq64F(v) + case OpNeq8: + return rewriteValuePPC64_OpNeq8(v) + case OpNeqB: + v.Op = OpPPC64XOR + return true + case OpNeqPtr: + return rewriteValuePPC64_OpNeqPtr(v) + case OpNilCheck: + v.Op = OpPPC64LoweredNilCheck + return true + case OpNot: + return rewriteValuePPC64_OpNot(v) + case OpOffPtr: + return rewriteValuePPC64_OpOffPtr(v) + case OpOr16: + v.Op = OpPPC64OR + return true + case OpOr32: + v.Op = OpPPC64OR + return true + case OpOr64: + v.Op = OpPPC64OR + return true + case OpOr8: + v.Op = OpPPC64OR + return true + case OpOrB: + v.Op = OpPPC64OR + return true + case OpPPC64ADD: + return rewriteValuePPC64_OpPPC64ADD(v) + case OpPPC64ADDC: + return rewriteValuePPC64_OpPPC64ADDC(v) + case OpPPC64ADDE: + return rewriteValuePPC64_OpPPC64ADDE(v) + case OpPPC64ADDconst: + return rewriteValuePPC64_OpPPC64ADDconst(v) + case OpPPC64AND: + return rewriteValuePPC64_OpPPC64AND(v) + case OpPPC64ANDN: + return rewriteValuePPC64_OpPPC64ANDN(v) + case OpPPC64ANDconst: + return rewriteValuePPC64_OpPPC64ANDconst(v) + case OpPPC64BRD: + return rewriteValuePPC64_OpPPC64BRD(v) + case OpPPC64BRH: + return rewriteValuePPC64_OpPPC64BRH(v) + case OpPPC64BRW: + return rewriteValuePPC64_OpPPC64BRW(v) + case OpPPC64CLRLSLDI: + return rewriteValuePPC64_OpPPC64CLRLSLDI(v) + case OpPPC64CMP: + return rewriteValuePPC64_OpPPC64CMP(v) + case OpPPC64CMPU: + return rewriteValuePPC64_OpPPC64CMPU(v) + case OpPPC64CMPUconst: + return rewriteValuePPC64_OpPPC64CMPUconst(v) + case OpPPC64CMPW: + return rewriteValuePPC64_OpPPC64CMPW(v) + case OpPPC64CMPWU: + return rewriteValuePPC64_OpPPC64CMPWU(v) + case OpPPC64CMPWUconst: + return rewriteValuePPC64_OpPPC64CMPWUconst(v) + case OpPPC64CMPWconst: + return rewriteValuePPC64_OpPPC64CMPWconst(v) + case OpPPC64CMPconst: + return rewriteValuePPC64_OpPPC64CMPconst(v) + case OpPPC64Equal: + return rewriteValuePPC64_OpPPC64Equal(v) + case OpPPC64FABS: + return rewriteValuePPC64_OpPPC64FABS(v) + case OpPPC64FADD: + return rewriteValuePPC64_OpPPC64FADD(v) + case OpPPC64FADDS: + return rewriteValuePPC64_OpPPC64FADDS(v) + case OpPPC64FCEIL: + return rewriteValuePPC64_OpPPC64FCEIL(v) + case OpPPC64FFLOOR: + return rewriteValuePPC64_OpPPC64FFLOOR(v) + case OpPPC64FGreaterEqual: + return rewriteValuePPC64_OpPPC64FGreaterEqual(v) + case OpPPC64FGreaterThan: + return rewriteValuePPC64_OpPPC64FGreaterThan(v) + case OpPPC64FLessEqual: + return rewriteValuePPC64_OpPPC64FLessEqual(v) + case OpPPC64FLessThan: + return rewriteValuePPC64_OpPPC64FLessThan(v) + case OpPPC64FMOVDload: + return rewriteValuePPC64_OpPPC64FMOVDload(v) + case OpPPC64FMOVDstore: + return rewriteValuePPC64_OpPPC64FMOVDstore(v) + case OpPPC64FMOVSload: + return rewriteValuePPC64_OpPPC64FMOVSload(v) + case OpPPC64FMOVSstore: + return rewriteValuePPC64_OpPPC64FMOVSstore(v) + case OpPPC64FNEG: + return rewriteValuePPC64_OpPPC64FNEG(v) + case OpPPC64FSQRT: + return rewriteValuePPC64_OpPPC64FSQRT(v) + case OpPPC64FSUB: + return rewriteValuePPC64_OpPPC64FSUB(v) + case OpPPC64FSUBS: + return rewriteValuePPC64_OpPPC64FSUBS(v) + case OpPPC64FTRUNC: + return rewriteValuePPC64_OpPPC64FTRUNC(v) + case OpPPC64GreaterEqual: + return rewriteValuePPC64_OpPPC64GreaterEqual(v) + case OpPPC64GreaterThan: + return rewriteValuePPC64_OpPPC64GreaterThan(v) + case OpPPC64ISEL: + return rewriteValuePPC64_OpPPC64ISEL(v) + case OpPPC64LessEqual: + return rewriteValuePPC64_OpPPC64LessEqual(v) + case OpPPC64LessThan: + return rewriteValuePPC64_OpPPC64LessThan(v) + case OpPPC64LoweredPanicBoundsCR: + return rewriteValuePPC64_OpPPC64LoweredPanicBoundsCR(v) + case OpPPC64LoweredPanicBoundsRC: + return rewriteValuePPC64_OpPPC64LoweredPanicBoundsRC(v) + case OpPPC64LoweredPanicBoundsRR: + return rewriteValuePPC64_OpPPC64LoweredPanicBoundsRR(v) + case OpPPC64MFVSRD: + return rewriteValuePPC64_OpPPC64MFVSRD(v) + case OpPPC64MOVBZload: + return rewriteValuePPC64_OpPPC64MOVBZload(v) + case OpPPC64MOVBZloadidx: + return rewriteValuePPC64_OpPPC64MOVBZloadidx(v) + case OpPPC64MOVBZreg: + return rewriteValuePPC64_OpPPC64MOVBZreg(v) + case OpPPC64MOVBreg: + return rewriteValuePPC64_OpPPC64MOVBreg(v) + case OpPPC64MOVBstore: + return rewriteValuePPC64_OpPPC64MOVBstore(v) + case OpPPC64MOVBstoreidx: + return rewriteValuePPC64_OpPPC64MOVBstoreidx(v) + case OpPPC64MOVBstorezero: + return rewriteValuePPC64_OpPPC64MOVBstorezero(v) + case OpPPC64MOVDaddr: + return rewriteValuePPC64_OpPPC64MOVDaddr(v) + case OpPPC64MOVDload: + return rewriteValuePPC64_OpPPC64MOVDload(v) + case OpPPC64MOVDloadidx: + return rewriteValuePPC64_OpPPC64MOVDloadidx(v) + case OpPPC64MOVDstore: + return rewriteValuePPC64_OpPPC64MOVDstore(v) + case OpPPC64MOVDstoreidx: + return rewriteValuePPC64_OpPPC64MOVDstoreidx(v) + case OpPPC64MOVDstorezero: + return rewriteValuePPC64_OpPPC64MOVDstorezero(v) + case OpPPC64MOVHBRstore: + return rewriteValuePPC64_OpPPC64MOVHBRstore(v) + case OpPPC64MOVHZload: + return rewriteValuePPC64_OpPPC64MOVHZload(v) + case OpPPC64MOVHZloadidx: + return rewriteValuePPC64_OpPPC64MOVHZloadidx(v) + case OpPPC64MOVHZreg: + return rewriteValuePPC64_OpPPC64MOVHZreg(v) + case OpPPC64MOVHload: + return rewriteValuePPC64_OpPPC64MOVHload(v) + case OpPPC64MOVHloadidx: + return rewriteValuePPC64_OpPPC64MOVHloadidx(v) + case OpPPC64MOVHreg: + return rewriteValuePPC64_OpPPC64MOVHreg(v) + case OpPPC64MOVHstore: + return rewriteValuePPC64_OpPPC64MOVHstore(v) + case OpPPC64MOVHstoreidx: + return rewriteValuePPC64_OpPPC64MOVHstoreidx(v) + case OpPPC64MOVHstorezero: + return rewriteValuePPC64_OpPPC64MOVHstorezero(v) + case OpPPC64MOVWBRstore: + return rewriteValuePPC64_OpPPC64MOVWBRstore(v) + case OpPPC64MOVWZload: + return rewriteValuePPC64_OpPPC64MOVWZload(v) + case OpPPC64MOVWZloadidx: + return rewriteValuePPC64_OpPPC64MOVWZloadidx(v) + case OpPPC64MOVWZreg: + return rewriteValuePPC64_OpPPC64MOVWZreg(v) + case OpPPC64MOVWload: + return rewriteValuePPC64_OpPPC64MOVWload(v) + case OpPPC64MOVWloadidx: + return rewriteValuePPC64_OpPPC64MOVWloadidx(v) + case OpPPC64MOVWreg: + return rewriteValuePPC64_OpPPC64MOVWreg(v) + case OpPPC64MOVWstore: + return rewriteValuePPC64_OpPPC64MOVWstore(v) + case OpPPC64MOVWstoreidx: + return rewriteValuePPC64_OpPPC64MOVWstoreidx(v) + case OpPPC64MOVWstorezero: + return rewriteValuePPC64_OpPPC64MOVWstorezero(v) + case OpPPC64MTVSRD: + return rewriteValuePPC64_OpPPC64MTVSRD(v) + case OpPPC64MULLD: + return rewriteValuePPC64_OpPPC64MULLD(v) + case OpPPC64MULLW: + return rewriteValuePPC64_OpPPC64MULLW(v) + case OpPPC64NEG: + return rewriteValuePPC64_OpPPC64NEG(v) + case OpPPC64NOR: + return rewriteValuePPC64_OpPPC64NOR(v) + case OpPPC64NotEqual: + return rewriteValuePPC64_OpPPC64NotEqual(v) + case OpPPC64OR: + return rewriteValuePPC64_OpPPC64OR(v) + case OpPPC64ORN: + return rewriteValuePPC64_OpPPC64ORN(v) + case OpPPC64ORconst: + return rewriteValuePPC64_OpPPC64ORconst(v) + case OpPPC64RLWINM: + return rewriteValuePPC64_OpPPC64RLWINM(v) + case OpPPC64ROTL: + return rewriteValuePPC64_OpPPC64ROTL(v) + case OpPPC64ROTLW: + return rewriteValuePPC64_OpPPC64ROTLW(v) + case OpPPC64ROTLWconst: + return rewriteValuePPC64_OpPPC64ROTLWconst(v) + case OpPPC64SETBC: + return rewriteValuePPC64_OpPPC64SETBC(v) + case OpPPC64SETBCR: + return rewriteValuePPC64_OpPPC64SETBCR(v) + case OpPPC64SLD: + return rewriteValuePPC64_OpPPC64SLD(v) + case OpPPC64SLDconst: + return rewriteValuePPC64_OpPPC64SLDconst(v) + case OpPPC64SLW: + return rewriteValuePPC64_OpPPC64SLW(v) + case OpPPC64SLWconst: + return rewriteValuePPC64_OpPPC64SLWconst(v) + case OpPPC64SRAD: + return rewriteValuePPC64_OpPPC64SRAD(v) + case OpPPC64SRAW: + return rewriteValuePPC64_OpPPC64SRAW(v) + case OpPPC64SRD: + return rewriteValuePPC64_OpPPC64SRD(v) + case OpPPC64SRW: + return rewriteValuePPC64_OpPPC64SRW(v) + case OpPPC64SRWconst: + return rewriteValuePPC64_OpPPC64SRWconst(v) + case OpPPC64SUB: + return rewriteValuePPC64_OpPPC64SUB(v) + case OpPPC64SUBE: + return rewriteValuePPC64_OpPPC64SUBE(v) + case OpPPC64SUBFCconst: + return rewriteValuePPC64_OpPPC64SUBFCconst(v) + case OpPPC64XOR: + return rewriteValuePPC64_OpPPC64XOR(v) + case OpPPC64XORconst: + return rewriteValuePPC64_OpPPC64XORconst(v) + case OpPanicBounds: + v.Op = OpPPC64LoweredPanicBoundsRR + return true + case OpPopCount16: + return rewriteValuePPC64_OpPopCount16(v) + case OpPopCount32: + return rewriteValuePPC64_OpPopCount32(v) + case OpPopCount64: + v.Op = OpPPC64POPCNTD + return true + case OpPopCount8: + return rewriteValuePPC64_OpPopCount8(v) + case OpPrefetchCache: + return rewriteValuePPC64_OpPrefetchCache(v) + case OpPrefetchCacheStreamed: + return rewriteValuePPC64_OpPrefetchCacheStreamed(v) + case OpPubBarrier: + v.Op = OpPPC64LoweredPubBarrier + return true + case OpRotateLeft16: + return rewriteValuePPC64_OpRotateLeft16(v) + case OpRotateLeft32: + v.Op = OpPPC64ROTLW + return true + case OpRotateLeft64: + v.Op = OpPPC64ROTL + return true + case OpRotateLeft8: + return rewriteValuePPC64_OpRotateLeft8(v) + case OpRound: + v.Op = OpPPC64FROUND + return true + case OpRound32F: + v.Op = OpPPC64LoweredRound32F + return true + case OpRound64F: + v.Op = OpPPC64LoweredRound64F + return true + case OpRsh16Ux16: + return rewriteValuePPC64_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValuePPC64_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValuePPC64_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValuePPC64_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValuePPC64_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValuePPC64_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValuePPC64_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValuePPC64_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValuePPC64_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValuePPC64_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValuePPC64_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValuePPC64_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValuePPC64_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValuePPC64_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValuePPC64_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValuePPC64_OpRsh32x8(v) + case OpRsh64Ux16: + return rewriteValuePPC64_OpRsh64Ux16(v) + case OpRsh64Ux32: + return rewriteValuePPC64_OpRsh64Ux32(v) + case OpRsh64Ux64: + return rewriteValuePPC64_OpRsh64Ux64(v) + case OpRsh64Ux8: + return rewriteValuePPC64_OpRsh64Ux8(v) + case OpRsh64x16: + return rewriteValuePPC64_OpRsh64x16(v) + case OpRsh64x32: + return rewriteValuePPC64_OpRsh64x32(v) + case OpRsh64x64: + return rewriteValuePPC64_OpRsh64x64(v) + case OpRsh64x8: + return rewriteValuePPC64_OpRsh64x8(v) + case OpRsh8Ux16: + return rewriteValuePPC64_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValuePPC64_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValuePPC64_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValuePPC64_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValuePPC64_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValuePPC64_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValuePPC64_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValuePPC64_OpRsh8x8(v) + case OpSelect0: + return rewriteValuePPC64_OpSelect0(v) + case OpSelect1: + return rewriteValuePPC64_OpSelect1(v) + case OpSelectN: + return rewriteValuePPC64_OpSelectN(v) + case OpSignExt16to32: + v.Op = OpPPC64MOVHreg + return true + case OpSignExt16to64: + v.Op = OpPPC64MOVHreg + return true + case OpSignExt32to64: + v.Op = OpPPC64MOVWreg + return true + case OpSignExt8to16: + v.Op = OpPPC64MOVBreg + return true + case OpSignExt8to32: + v.Op = OpPPC64MOVBreg + return true + case OpSignExt8to64: + v.Op = OpPPC64MOVBreg + return true + case OpSlicemask: + return rewriteValuePPC64_OpSlicemask(v) + case OpSqrt: + v.Op = OpPPC64FSQRT + return true + case OpSqrt32: + v.Op = OpPPC64FSQRTS + return true + case OpStaticCall: + v.Op = OpPPC64CALLstatic + return true + case OpStore: + return rewriteValuePPC64_OpStore(v) + case OpSub16: + v.Op = OpPPC64SUB + return true + case OpSub32: + v.Op = OpPPC64SUB + return true + case OpSub32F: + v.Op = OpPPC64FSUBS + return true + case OpSub64: + v.Op = OpPPC64SUB + return true + case OpSub64F: + v.Op = OpPPC64FSUB + return true + case OpSub8: + v.Op = OpPPC64SUB + return true + case OpSubPtr: + v.Op = OpPPC64SUB + return true + case OpTailCall: + v.Op = OpPPC64CALLtail + return true + case OpTrunc: + v.Op = OpPPC64FTRUNC + return true + case OpTrunc16to8: + return rewriteValuePPC64_OpTrunc16to8(v) + case OpTrunc32to16: + return rewriteValuePPC64_OpTrunc32to16(v) + case OpTrunc32to8: + return rewriteValuePPC64_OpTrunc32to8(v) + case OpTrunc64to16: + return rewriteValuePPC64_OpTrunc64to16(v) + case OpTrunc64to32: + return rewriteValuePPC64_OpTrunc64to32(v) + case OpTrunc64to8: + return rewriteValuePPC64_OpTrunc64to8(v) + case OpWB: + v.Op = OpPPC64LoweredWB + return true + case OpXor16: + v.Op = OpPPC64XOR + return true + case OpXor32: + v.Op = OpPPC64XOR + return true + case OpXor64: + v.Op = OpPPC64XOR + return true + case OpXor8: + v.Op = OpPPC64XOR + return true + case OpZero: + return rewriteValuePPC64_OpZero(v) + case OpZeroExt16to32: + v.Op = OpPPC64MOVHZreg + return true + case OpZeroExt16to64: + v.Op = OpPPC64MOVHZreg + return true + case OpZeroExt32to64: + v.Op = OpPPC64MOVWZreg + return true + case OpZeroExt8to16: + v.Op = OpPPC64MOVBZreg + return true + case OpZeroExt8to32: + v.Op = OpPPC64MOVBZreg + return true + case OpZeroExt8to64: + v.Op = OpPPC64MOVBZreg + return true + } + return false +} +func rewriteValuePPC64_OpAddr(v *Value) bool { + v_0 := v.Args[0] + // match: (Addr {sym} base) + // result: (MOVDaddr {sym} [0] base) + for { + sym := auxToSym(v.Aux) + base := v_0 + v.reset(OpPPC64MOVDaddr) + v.AuxInt = int32ToAuxInt(0) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } +} +func rewriteValuePPC64_OpAtomicCompareAndSwap32(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicCompareAndSwap32 ptr old new_ mem) + // result: (LoweredAtomicCas32 [1] ptr old new_ mem) + for { + ptr := v_0 + old := v_1 + new_ := v_2 + mem := v_3 + v.reset(OpPPC64LoweredAtomicCas32) + v.AuxInt = int64ToAuxInt(1) + v.AddArg4(ptr, old, new_, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicCompareAndSwap64(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicCompareAndSwap64 ptr old new_ mem) + // result: (LoweredAtomicCas64 [1] ptr old new_ mem) + for { + ptr := v_0 + old := v_1 + new_ := v_2 + mem := v_3 + v.reset(OpPPC64LoweredAtomicCas64) + v.AuxInt = int64ToAuxInt(1) + v.AddArg4(ptr, old, new_, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicCompareAndSwapRel32(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicCompareAndSwapRel32 ptr old new_ mem) + // result: (LoweredAtomicCas32 [0] ptr old new_ mem) + for { + ptr := v_0 + old := v_1 + new_ := v_2 + mem := v_3 + v.reset(OpPPC64LoweredAtomicCas32) + v.AuxInt = int64ToAuxInt(0) + v.AddArg4(ptr, old, new_, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicLoad32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoad32 ptr mem) + // result: (LoweredAtomicLoad32 [1] ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpPPC64LoweredAtomicLoad32) + v.AuxInt = int64ToAuxInt(1) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicLoad64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoad64 ptr mem) + // result: (LoweredAtomicLoad64 [1] ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpPPC64LoweredAtomicLoad64) + v.AuxInt = int64ToAuxInt(1) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicLoad8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoad8 ptr mem) + // result: (LoweredAtomicLoad8 [1] ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpPPC64LoweredAtomicLoad8) + v.AuxInt = int64ToAuxInt(1) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicLoadAcq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoadAcq32 ptr mem) + // result: (LoweredAtomicLoad32 [0] ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpPPC64LoweredAtomicLoad32) + v.AuxInt = int64ToAuxInt(0) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicLoadAcq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoadAcq64 ptr mem) + // result: (LoweredAtomicLoad64 [0] ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpPPC64LoweredAtomicLoad64) + v.AuxInt = int64ToAuxInt(0) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicLoadPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoadPtr ptr mem) + // result: (LoweredAtomicLoadPtr [1] ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpPPC64LoweredAtomicLoadPtr) + v.AuxInt = int64ToAuxInt(1) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicStore32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicStore32 ptr val mem) + // result: (LoweredAtomicStore32 [1] ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpPPC64LoweredAtomicStore32) + v.AuxInt = int64ToAuxInt(1) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicStore64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicStore64 ptr val mem) + // result: (LoweredAtomicStore64 [1] ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpPPC64LoweredAtomicStore64) + v.AuxInt = int64ToAuxInt(1) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicStore8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicStore8 ptr val mem) + // result: (LoweredAtomicStore8 [1] ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpPPC64LoweredAtomicStore8) + v.AuxInt = int64ToAuxInt(1) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicStoreRel32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicStoreRel32 ptr val mem) + // result: (LoweredAtomicStore32 [0] ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpPPC64LoweredAtomicStore32) + v.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValuePPC64_OpAtomicStoreRel64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicStoreRel64 ptr val mem) + // result: (LoweredAtomicStore64 [0] ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpPPC64LoweredAtomicStore64) + v.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValuePPC64_OpAvg64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Avg64u x y) + // result: (ADD (SRDconst (SUB x y) [1]) y) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ADD) + v0 := b.NewValue0(v.Pos, OpPPC64SRDconst, t) + v0.AuxInt = int64ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpPPC64SUB, t) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg2(v0, y) + return true + } +} +func rewriteValuePPC64_OpBitLen16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen16 x) + // result: (BitLen64 (ZeroExt16to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpBitLen32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen32 x) + // result: (SUBFCconst [32] (CNTLZW x)) + for { + x := v_0 + v.reset(OpPPC64SUBFCconst) + v.AuxInt = int64ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpPPC64CNTLZW, typ.Int) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpBitLen64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen64 x) + // result: (SUBFCconst [64] (CNTLZD x)) + for { + x := v_0 + v.reset(OpPPC64SUBFCconst) + v.AuxInt = int64ToAuxInt(64) + v0 := b.NewValue0(v.Pos, OpPPC64CNTLZD, typ.Int) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpBitLen8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen8 x) + // result: (BitLen64 (ZeroExt8to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpBswap16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Bswap16 x) + // cond: buildcfg.GOPPC64>=10 + // result: (BRH x) + for { + x := v_0 + if !(buildcfg.GOPPC64 >= 10) { + break + } + v.reset(OpPPC64BRH) + v.AddArg(x) + return true + } + // match: (Bswap16 x:(MOVHZload [off] {sym} ptr mem)) + // result: @x.Block (MOVHBRload (MOVDaddr [off] {sym} ptr) mem) + for { + x := v_0 + if x.Op != OpPPC64MOVHZload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + b = x.Block + v0 := b.NewValue0(x.Pos, OpPPC64MOVHBRload, typ.UInt16) + v.copyOf(v0) + v1 := b.NewValue0(x.Pos, OpPPC64MOVDaddr, ptr.Type) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(sym) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + // match: (Bswap16 x:(MOVHZloadidx ptr idx mem)) + // result: @x.Block (MOVHBRloadidx ptr idx mem) + for { + x := v_0 + if x.Op != OpPPC64MOVHZloadidx { + break + } + mem := x.Args[2] + ptr := x.Args[0] + idx := x.Args[1] + b = x.Block + v0 := b.NewValue0(v.Pos, OpPPC64MOVHBRloadidx, typ.Int16) + v.copyOf(v0) + v0.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpBswap32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Bswap32 x) + // cond: buildcfg.GOPPC64>=10 + // result: (BRW x) + for { + x := v_0 + if !(buildcfg.GOPPC64 >= 10) { + break + } + v.reset(OpPPC64BRW) + v.AddArg(x) + return true + } + // match: (Bswap32 x:(MOVWZload [off] {sym} ptr mem)) + // result: @x.Block (MOVWBRload (MOVDaddr [off] {sym} ptr) mem) + for { + x := v_0 + if x.Op != OpPPC64MOVWZload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + b = x.Block + v0 := b.NewValue0(x.Pos, OpPPC64MOVWBRload, typ.UInt32) + v.copyOf(v0) + v1 := b.NewValue0(x.Pos, OpPPC64MOVDaddr, ptr.Type) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(sym) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + // match: (Bswap32 x:(MOVWZloadidx ptr idx mem)) + // result: @x.Block (MOVWBRloadidx ptr idx mem) + for { + x := v_0 + if x.Op != OpPPC64MOVWZloadidx { + break + } + mem := x.Args[2] + ptr := x.Args[0] + idx := x.Args[1] + b = x.Block + v0 := b.NewValue0(v.Pos, OpPPC64MOVWBRloadidx, typ.Int32) + v.copyOf(v0) + v0.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpBswap64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Bswap64 x) + // cond: buildcfg.GOPPC64>=10 + // result: (BRD x) + for { + x := v_0 + if !(buildcfg.GOPPC64 >= 10) { + break + } + v.reset(OpPPC64BRD) + v.AddArg(x) + return true + } + // match: (Bswap64 x:(MOVDload [off] {sym} ptr mem)) + // result: @x.Block (MOVDBRload (MOVDaddr [off] {sym} ptr) mem) + for { + x := v_0 + if x.Op != OpPPC64MOVDload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + b = x.Block + v0 := b.NewValue0(x.Pos, OpPPC64MOVDBRload, typ.UInt64) + v.copyOf(v0) + v1 := b.NewValue0(x.Pos, OpPPC64MOVDaddr, ptr.Type) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(sym) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + // match: (Bswap64 x:(MOVDloadidx ptr idx mem)) + // result: @x.Block (MOVDBRloadidx ptr idx mem) + for { + x := v_0 + if x.Op != OpPPC64MOVDloadidx { + break + } + mem := x.Args[2] + ptr := x.Args[0] + idx := x.Args[1] + b = x.Block + v0 := b.NewValue0(v.Pos, OpPPC64MOVDBRloadidx, typ.Int64) + v.copyOf(v0) + v0.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpCom16(v *Value) bool { + v_0 := v.Args[0] + // match: (Com16 x) + // result: (NOR x x) + for { + x := v_0 + v.reset(OpPPC64NOR) + v.AddArg2(x, x) + return true + } +} +func rewriteValuePPC64_OpCom32(v *Value) bool { + v_0 := v.Args[0] + // match: (Com32 x) + // result: (NOR x x) + for { + x := v_0 + v.reset(OpPPC64NOR) + v.AddArg2(x, x) + return true + } +} +func rewriteValuePPC64_OpCom64(v *Value) bool { + v_0 := v.Args[0] + // match: (Com64 x) + // result: (NOR x x) + for { + x := v_0 + v.reset(OpPPC64NOR) + v.AddArg2(x, x) + return true + } +} +func rewriteValuePPC64_OpCom8(v *Value) bool { + v_0 := v.Args[0] + // match: (Com8 x) + // result: (NOR x x) + for { + x := v_0 + v.reset(OpPPC64NOR) + v.AddArg2(x, x) + return true + } +} +func rewriteValuePPC64_OpCondSelect(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (CondSelect x y (SETBC [a] cmp)) + // result: (ISEL [a] x y cmp) + for { + x := v_0 + y := v_1 + if v_2.Op != OpPPC64SETBC { + break + } + a := auxIntToInt32(v_2.AuxInt) + cmp := v_2.Args[0] + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(a) + v.AddArg3(x, y, cmp) + return true + } + // match: (CondSelect x y (SETBCR [a] cmp)) + // result: (ISEL [a+4] x y cmp) + for { + x := v_0 + y := v_1 + if v_2.Op != OpPPC64SETBCR { + break + } + a := auxIntToInt32(v_2.AuxInt) + cmp := v_2.Args[0] + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(a + 4) + v.AddArg3(x, y, cmp) + return true + } + // match: (CondSelect x y bool) + // cond: flagArg(bool) == nil + // result: (ISEL [6] x y (CMPconst [0] (ANDconst [1] bool))) + for { + x := v_0 + y := v_1 + bool := v_2 + if !(flagArg(bool) == nil) { + break + } + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v1.AuxInt = int64ToAuxInt(1) + v1.AddArg(bool) + v0.AddArg(v1) + v.AddArg3(x, y, v0) + return true + } + return false +} +func rewriteValuePPC64_OpConst16(v *Value) bool { + // match: (Const16 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt16(v.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValuePPC64_OpConst32(v *Value) bool { + // match: (Const32 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt32(v.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValuePPC64_OpConst64(v *Value) bool { + // match: (Const64 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt64(v.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValuePPC64_OpConst8(v *Value) bool { + // match: (Const8 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt8(v.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValuePPC64_OpConstBool(v *Value) bool { + // match: (ConstBool [t]) + // result: (MOVDconst [b2i(t)]) + for { + t := auxIntToBool(v.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(t)) + return true + } +} +func rewriteValuePPC64_OpConstNil(v *Value) bool { + // match: (ConstNil) + // result: (MOVDconst [0]) + for { + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } +} +func rewriteValuePPC64_OpCopysign(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Copysign x y) + // result: (FCPSGN y x) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64FCPSGN) + v.AddArg2(y, x) + return true + } +} +func rewriteValuePPC64_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz16 x) + // cond: buildcfg.GOPPC64 <= 8 + // result: (POPCNTW (MOVHZreg (ANDN (ADDconst [-1] x) x))) + for { + x := v_0 + if !(buildcfg.GOPPC64 <= 8) { + break + } + v.reset(OpPPC64POPCNTW) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v1 := b.NewValue0(v.Pos, OpPPC64ANDN, typ.Int16) + v2 := b.NewValue0(v.Pos, OpPPC64ADDconst, typ.Int16) + v2.AuxInt = int64ToAuxInt(-1) + v2.AddArg(x) + v1.AddArg2(v2, x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Ctz16 x) + // cond: buildcfg.GOPPC64 >= 9 + // result: (CNTTZD (OR x (MOVDconst [1<<16]))) + for { + x := v_0 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64CNTTZD) + v0 := b.NewValue0(v.Pos, OpPPC64OR, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(1 << 16) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuePPC64_OpCtz32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz32 x) + // cond: buildcfg.GOPPC64 <= 8 + // result: (POPCNTW (MOVWZreg (ANDN (ADDconst [-1] x) x))) + for { + x := v_0 + if !(buildcfg.GOPPC64 <= 8) { + break + } + v.reset(OpPPC64POPCNTW) + v0 := b.NewValue0(v.Pos, OpPPC64MOVWZreg, typ.Int64) + v1 := b.NewValue0(v.Pos, OpPPC64ANDN, typ.Int) + v2 := b.NewValue0(v.Pos, OpPPC64ADDconst, typ.Int) + v2.AuxInt = int64ToAuxInt(-1) + v2.AddArg(x) + v1.AddArg2(v2, x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Ctz32 x) + // cond: buildcfg.GOPPC64 >= 9 + // result: (CNTTZW (MOVWZreg x)) + for { + x := v_0 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64CNTTZW) + v0 := b.NewValue0(v.Pos, OpPPC64MOVWZreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuePPC64_OpCtz64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz64 x) + // cond: buildcfg.GOPPC64 <= 8 + // result: (POPCNTD (ANDN (ADDconst [-1] x) x)) + for { + x := v_0 + if !(buildcfg.GOPPC64 <= 8) { + break + } + v.reset(OpPPC64POPCNTD) + v0 := b.NewValue0(v.Pos, OpPPC64ANDN, typ.Int64) + v1 := b.NewValue0(v.Pos, OpPPC64ADDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(-1) + v1.AddArg(x) + v0.AddArg2(v1, x) + v.AddArg(v0) + return true + } + // match: (Ctz64 x) + // cond: buildcfg.GOPPC64 >= 9 + // result: (CNTTZD x) + for { + x := v_0 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64CNTTZD) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz8 x) + // cond: buildcfg.GOPPC64 <= 8 + // result: (POPCNTB (MOVBZreg (ANDN (ADDconst [-1] x) x))) + for { + x := v_0 + if !(buildcfg.GOPPC64 <= 8) { + break + } + v.reset(OpPPC64POPCNTB) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v1 := b.NewValue0(v.Pos, OpPPC64ANDN, typ.UInt8) + v2 := b.NewValue0(v.Pos, OpPPC64ADDconst, typ.UInt8) + v2.AuxInt = int64ToAuxInt(-1) + v2.AddArg(x) + v1.AddArg2(v2, x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Ctz8 x) + // cond: buildcfg.GOPPC64 >= 9 + // result: (CNTTZD (OR x (MOVDconst [1<<8]))) + for { + x := v_0 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64CNTTZD) + v0 := b.NewValue0(v.Pos, OpPPC64OR, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(1 << 8) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuePPC64_OpCvt32Fto32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt32Fto32 x) + // result: (MFVSRD (FCTIWZ x)) + for { + x := v_0 + v.reset(OpPPC64MFVSRD) + v0 := b.NewValue0(v.Pos, OpPPC64FCTIWZ, typ.Float64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpCvt32Fto64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt32Fto64 x) + // result: (MFVSRD (FCTIDZ x)) + for { + x := v_0 + v.reset(OpPPC64MFVSRD) + v0 := b.NewValue0(v.Pos, OpPPC64FCTIDZ, typ.Float64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpCvt32to32F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt32to32F x) + // result: (FCFIDS (MTVSRD (SignExt32to64 x))) + for { + x := v_0 + v.reset(OpPPC64FCFIDS) + v0 := b.NewValue0(v.Pos, OpPPC64MTVSRD, typ.Float64) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpCvt32to64F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt32to64F x) + // result: (FCFID (MTVSRD (SignExt32to64 x))) + for { + x := v_0 + v.reset(OpPPC64FCFID) + v0 := b.NewValue0(v.Pos, OpPPC64MTVSRD, typ.Float64) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpCvt64Fto32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt64Fto32 x) + // result: (MFVSRD (FCTIWZ x)) + for { + x := v_0 + v.reset(OpPPC64MFVSRD) + v0 := b.NewValue0(v.Pos, OpPPC64FCTIWZ, typ.Float64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpCvt64Fto64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt64Fto64 x) + // result: (MFVSRD (FCTIDZ x)) + for { + x := v_0 + v.reset(OpPPC64MFVSRD) + v0 := b.NewValue0(v.Pos, OpPPC64FCTIDZ, typ.Float64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpCvt64to32F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt64to32F x) + // result: (FCFIDS (MTVSRD x)) + for { + x := v_0 + v.reset(OpPPC64FCFIDS) + v0 := b.NewValue0(v.Pos, OpPPC64MTVSRD, typ.Float64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpCvt64to64F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt64to64F x) + // result: (FCFID (MTVSRD x)) + for { + x := v_0 + v.reset(OpPPC64FCFID) + v0 := b.NewValue0(v.Pos, OpPPC64MTVSRD, typ.Float64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 [false] x y) + // result: (DIVW (SignExt16to32 x) (SignExt16to32 y)) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpPPC64DIVW) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValuePPC64_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u x y) + // result: (DIVWU (ZeroExt16to32 x) (ZeroExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64DIVWU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuePPC64_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Div32 [false] x y) + // result: (DIVW x y) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpPPC64DIVW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValuePPC64_OpDiv64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Div64 [false] x y) + // result: (DIVD x y) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpPPC64DIVD) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValuePPC64_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (DIVW (SignExt8to32 x) (SignExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64DIVW) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuePPC64_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (DIVWU (ZeroExt8to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64DIVWU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuePPC64_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq16 x y) + // cond: x.Type.IsSigned() && y.Type.IsSigned() + // result: (Equal (CMPW (SignExt16to32 x) (SignExt16to32 y))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + y := v_1 + if !(x.Type.IsSigned() && y.Type.IsSigned()) { + continue + } + v.reset(OpPPC64Equal) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } + break + } + // match: (Eq16 x y) + // result: (Equal (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64Equal) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32 x y) + // result: (Equal (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64Equal) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpEq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32F x y) + // result: (Equal (FCMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64Equal) + v0 := b.NewValue0(v.Pos, OpPPC64FCMPU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpEq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64 x y) + // result: (Equal (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64Equal) + v0 := b.NewValue0(v.Pos, OpPPC64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpEq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64F x y) + // result: (Equal (FCMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64Equal) + v0 := b.NewValue0(v.Pos, OpPPC64FCMPU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq8 x y) + // cond: x.Type.IsSigned() && y.Type.IsSigned() + // result: (Equal (CMPW (SignExt8to32 x) (SignExt8to32 y))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + y := v_1 + if !(x.Type.IsSigned() && y.Type.IsSigned()) { + continue + } + v.reset(OpPPC64Equal) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } + break + } + // match: (Eq8 x y) + // result: (Equal (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64Equal) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqB x y) + // result: (ANDconst [1] (EQV x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64ANDconst) + v.AuxInt = int64ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpPPC64EQV, typ.Int64) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (EqPtr x y) + // result: (Equal (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64Equal) + v0 := b.NewValue0(v.Pos, OpPPC64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpIsInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (IsInBounds idx len) + // result: (LessThan (CMPU idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpPPC64LessThan) + v0 := b.NewValue0(v.Pos, OpPPC64CMPU, types.TypeFlags) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpIsNonNil(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (IsNonNil ptr) + // result: (NotEqual (CMPconst [0] ptr)) + for { + ptr := v_0 + v.reset(OpPPC64NotEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(0) + v0.AddArg(ptr) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpIsSliceInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (IsSliceInBounds idx len) + // result: (LessEqual (CMPU idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpPPC64LessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPU, types.TypeFlags) + v0.AddArg2(idx, len) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16 x y) + // result: (LessEqual (CMPW (SignExt16to32 x) (SignExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16U x y) + // result: (LessEqual (CMPWU (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPWU, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32 x y) + // result: (LessEqual (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32F x y) + // result: (FLessEqual (FCMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64FLessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64FCMPU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32U x y) + // result: (LessEqual (CMPWU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPWU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64 x y) + // result: (LessEqual (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64F x y) + // result: (FLessEqual (FCMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64FLessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64FCMPU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLeq64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64U x y) + // result: (LessEqual (CMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8 x y) + // result: (LessEqual (CMPW (SignExt8to32 x) (SignExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8U x y) + // result: (LessEqual (CMPWU (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPWU, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16 x y) + // result: (LessThan (CMPW (SignExt16to32 x) (SignExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessThan) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16U x y) + // result: (LessThan (CMPWU (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessThan) + v0 := b.NewValue0(v.Pos, OpPPC64CMPWU, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32 x y) + // result: (LessThan (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessThan) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLess32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32F x y) + // result: (FLessThan (FCMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64FLessThan) + v0 := b.NewValue0(v.Pos, OpPPC64FCMPU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32U x y) + // result: (LessThan (CMPWU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessThan) + v0 := b.NewValue0(v.Pos, OpPPC64CMPWU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLess64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64 x y) + // result: (LessThan (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessThan) + v0 := b.NewValue0(v.Pos, OpPPC64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLess64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64F x y) + // result: (FLessThan (FCMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64FLessThan) + v0 := b.NewValue0(v.Pos, OpPPC64FCMPU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLess64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64U x y) + // result: (LessThan (CMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessThan) + v0 := b.NewValue0(v.Pos, OpPPC64CMPU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8 x y) + // result: (LessThan (CMPW (SignExt8to32 x) (SignExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessThan) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8U x y) + // result: (LessThan (CMPWU (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64LessThan) + v0 := b.NewValue0(v.Pos, OpPPC64CMPWU, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Load ptr mem) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (MOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpPPC64MOVDload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitInt(t) && t.IsSigned() + // result: (MOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpPPC64MOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitInt(t) && !t.IsSigned() + // result: (MOVWZload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpPPC64MOVWZload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is16BitInt(t) && t.IsSigned() + // result: (MOVHload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpPPC64MOVHload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is16BitInt(t) && !t.IsSigned() + // result: (MOVHZload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpPPC64MOVHZload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.IsBoolean() + // result: (MOVBZload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsBoolean()) { + break + } + v.reset(OpPPC64MOVBZload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is8BitInt(t) && t.IsSigned() + // result: (MOVBreg (MOVBZload ptr mem)) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpPPC64MOVBreg) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZload, typ.UInt8) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + // match: (Load ptr mem) + // cond: is8BitInt(t) && !t.IsSigned() + // result: (MOVBZload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpPPC64MOVBZload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (FMOVSload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(OpPPC64FMOVSload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (FMOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(OpPPC64FMOVDload) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (MOVDaddr {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(OpPPC64MOVDaddr) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (MOVDaddr {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(OpPPC64MOVDaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValuePPC64_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x16 x y) + // result: (ISEL [2] (SLD (MOVHZreg x) y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0xFFF0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0xFFF0) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x32 x y) + // result: (ISEL [0] (SLD (MOVHZreg x) y) (MOVDconst [0]) (CMPWUconst y [16])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(16) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x64 x (MOVDconst [c])) + // cond: uint64(c) < 16 + // result: (SLWconst x [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 16) { + break + } + v.reset(OpPPC64SLWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (Lsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x64 x y) + // result: (ISEL [0] (SLD (MOVHZreg x) y) (MOVDconst [0]) (CMPUconst y [16])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(16) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x8 x y) + // result: (ISEL [2] (SLD (MOVHZreg x) y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0x00F0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0x00F0) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x16 x y) + // result: (ISEL [2] (SLW x y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0xFFE0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0xFFE0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x32 x y) + // result: (ISEL [0] (SLW x y) (MOVDconst [0]) (CMPWUconst y [32])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x64 x (MOVDconst [c])) + // cond: uint64(c) < 32 + // result: (SLWconst x [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 32) { + break + } + v.reset(OpPPC64SLWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (Lsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x64 x y) + // result: (ISEL [0] (SLW x y) (MOVDconst [0]) (CMPUconst y [32])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(32) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x8 x y) + // result: (ISEL [2] (SLW x y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0x00E0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0x00E0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpLsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x16 x y) + // result: (ISEL [2] (SLD x y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0xFFC0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0xFFC0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpLsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x32 x y) + // result: (ISEL [0] (SLD x y) (MOVDconst [0]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpLsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x64 x (MOVDconst [c])) + // cond: uint64(c) < 64 + // result: (SLDconst x [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 64) { + break + } + v.reset(OpPPC64SLDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (Lsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x64 x y) + // result: (ISEL [0] (SLD x y) (MOVDconst [0]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpLsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x8 x y) + // result: (ISEL [2] (SLD x y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0x00C0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0x00C0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x16 x y) + // result: (ISEL [2] (SLD (MOVBZreg x) y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0xFFF8] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0xFFF8) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x32 x y) + // result: (ISEL [0] (SLD (MOVBZreg x) y) (MOVDconst [0]) (CMPWUconst y [8])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(8) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x64 x (MOVDconst [c])) + // cond: uint64(c) < 8 + // result: (SLWconst x [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 8) { + break + } + v.reset(OpPPC64SLWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (Lsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x64 x y) + // result: (ISEL [0] (SLD (MOVBZreg x) y) (MOVDconst [0]) (CMPUconst y [8])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(8) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x8 x y) + // result: (ISEL [2] (SLD (MOVBZreg x) y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0x00F8] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SLD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0x00F8) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpMax32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Max32F x y) + // cond: buildcfg.GOPPC64 >= 9 + // result: (XSMAXJDP x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64XSMAXJDP) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValuePPC64_OpMax64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Max64F x y) + // cond: buildcfg.GOPPC64 >= 9 + // result: (XSMAXJDP x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64XSMAXJDP) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValuePPC64_OpMin32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Min32F x y) + // cond: buildcfg.GOPPC64 >= 9 + // result: (XSMINJDP x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64XSMINJDP) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValuePPC64_OpMin64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Min64F x y) + // cond: buildcfg.GOPPC64 >= 9 + // result: (XSMINJDP x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64XSMINJDP) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValuePPC64_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16 x y) + // result: (Mod32 (SignExt16to32 x) (SignExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpMod32) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuePPC64_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16u x y) + // result: (Mod32u (ZeroExt16to32 x) (ZeroExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpMod32u) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuePPC64_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32 x y) + // cond: buildcfg.GOPPC64 >= 9 + // result: (MODSW x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64MODSW) + v.AddArg2(x, y) + return true + } + // match: (Mod32 x y) + // cond: buildcfg.GOPPC64 <= 8 + // result: (SUB x (MULLW y (DIVW x y))) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 <= 8) { + break + } + v.reset(OpPPC64SUB) + v0 := b.NewValue0(v.Pos, OpPPC64MULLW, typ.Int32) + v1 := b.NewValue0(v.Pos, OpPPC64DIVW, typ.Int32) + v1.AddArg2(x, y) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuePPC64_OpMod32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32u x y) + // cond: buildcfg.GOPPC64 >= 9 + // result: (MODUW x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64MODUW) + v.AddArg2(x, y) + return true + } + // match: (Mod32u x y) + // cond: buildcfg.GOPPC64 <= 8 + // result: (SUB x (MULLW y (DIVWU x y))) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 <= 8) { + break + } + v.reset(OpPPC64SUB) + v0 := b.NewValue0(v.Pos, OpPPC64MULLW, typ.Int32) + v1 := b.NewValue0(v.Pos, OpPPC64DIVWU, typ.Int32) + v1.AddArg2(x, y) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuePPC64_OpMod64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod64 x y) + // cond: buildcfg.GOPPC64 >=9 + // result: (MODSD x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64MODSD) + v.AddArg2(x, y) + return true + } + // match: (Mod64 x y) + // cond: buildcfg.GOPPC64 <=8 + // result: (SUB x (MULLD y (DIVD x y))) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 <= 8) { + break + } + v.reset(OpPPC64SUB) + v0 := b.NewValue0(v.Pos, OpPPC64MULLD, typ.Int64) + v1 := b.NewValue0(v.Pos, OpPPC64DIVD, typ.Int64) + v1.AddArg2(x, y) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuePPC64_OpMod64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod64u x y) + // cond: buildcfg.GOPPC64 >= 9 + // result: (MODUD x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64MODUD) + v.AddArg2(x, y) + return true + } + // match: (Mod64u x y) + // cond: buildcfg.GOPPC64 <= 8 + // result: (SUB x (MULLD y (DIVDU x y))) + for { + x := v_0 + y := v_1 + if !(buildcfg.GOPPC64 <= 8) { + break + } + v.reset(OpPPC64SUB) + v0 := b.NewValue0(v.Pos, OpPPC64MULLD, typ.Int64) + v1 := b.NewValue0(v.Pos, OpPPC64DIVDU, typ.Int64) + v1.AddArg2(x, y) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuePPC64_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (Mod32 (SignExt8to32 x) (SignExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpMod32) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuePPC64_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (Mod32u (ZeroExt8to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpMod32u) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuePPC64_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (MOVBstore dst (MOVBZload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpPPC64MOVBstore) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZload, typ.UInt8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (MOVHstore dst (MOVHZload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpPPC64MOVHstore) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHZload, typ.UInt16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [4] dst src mem) + // result: (MOVWstore dst (MOVWZload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpPPC64MOVWstore) + v0 := b.NewValue0(v.Pos, OpPPC64MOVWZload, typ.UInt32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [8] {t} dst src mem) + // result: (MOVDstore dst (MOVDload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpPPC64MOVDstore) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDload, typ.Int64) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [3] dst src mem) + // result: (MOVBstore [2] dst (MOVBZload [2] src mem) (MOVHstore dst (MOVHload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpPPC64MOVHload, typ.Int16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [5] dst src mem) + // result: (MOVBstore [4] dst (MOVBZload [4] src mem) (MOVWstore dst (MOVWZload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpPPC64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpPPC64MOVWZload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [6] dst src mem) + // result: (MOVHstore [4] dst (MOVHZload [4] src mem) (MOVWstore dst (MOVWZload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpPPC64MOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHZload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpPPC64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpPPC64MOVWZload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [7] dst src mem) + // result: (MOVBstore [6] dst (MOVBZload [6] src mem) (MOVHstore [4] dst (MOVHZload [4] src mem) (MOVWstore dst (MOVWZload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(6) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpPPC64MOVHZload, typ.UInt16) + v2.AuxInt = int32ToAuxInt(4) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpPPC64MOVWstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpPPC64MOVWZload, typ.UInt32) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 8 && buildcfg.GOPPC64 <= 8 && logLargeCopy(v, s) + // result: (LoweredMove [s] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 8 && buildcfg.GOPPC64 <= 8 && logLargeCopy(v, s)) { + break + } + v.reset(OpPPC64LoweredMove) + v.AuxInt = int64ToAuxInt(s) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 8 && s <= 64 && buildcfg.GOPPC64 >= 9 + // result: (LoweredQuadMoveShort [s] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 8 && s <= 64 && buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64LoweredQuadMoveShort) + v.AuxInt = int64ToAuxInt(s) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 8 && buildcfg.GOPPC64 >= 9 && logLargeCopy(v, s) + // result: (LoweredQuadMove [s] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 8 && buildcfg.GOPPC64 >= 9 && logLargeCopy(v, s)) { + break + } + v.reset(OpPPC64LoweredQuadMove) + v.AuxInt = int64ToAuxInt(s) + v.AddArg3(dst, src, mem) + return true + } + return false +} +func rewriteValuePPC64_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq16 x y) + // cond: x.Type.IsSigned() && y.Type.IsSigned() + // result: (NotEqual (CMPW (SignExt16to32 x) (SignExt16to32 y))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + y := v_1 + if !(x.Type.IsSigned() && y.Type.IsSigned()) { + continue + } + v.reset(OpPPC64NotEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } + break + } + // match: (Neq16 x y) + // result: (NotEqual (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64NotEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32 x y) + // result: (NotEqual (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64NotEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpNeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32F x y) + // result: (NotEqual (FCMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64NotEqual) + v0 := b.NewValue0(v.Pos, OpPPC64FCMPU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpNeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64 x y) + // result: (NotEqual (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64NotEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpNeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64F x y) + // result: (NotEqual (FCMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64NotEqual) + v0 := b.NewValue0(v.Pos, OpPPC64FCMPU, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq8 x y) + // cond: x.Type.IsSigned() && y.Type.IsSigned() + // result: (NotEqual (CMPW (SignExt8to32 x) (SignExt8to32 y))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + y := v_1 + if !(x.Type.IsSigned() && y.Type.IsSigned()) { + continue + } + v.reset(OpPPC64NotEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } + break + } + // match: (Neq8 x y) + // result: (NotEqual (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64NotEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (NeqPtr x y) + // result: (NotEqual (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpPPC64NotEqual) + v0 := b.NewValue0(v.Pos, OpPPC64CMP, types.TypeFlags) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpNot(v *Value) bool { + v_0 := v.Args[0] + // match: (Not x) + // result: (XORconst [1] x) + for { + x := v_0 + v.reset(OpPPC64XORconst) + v.AuxInt = int64ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValuePPC64_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (OffPtr [off] ptr) + // result: (ADD (MOVDconst [off]) ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + v.reset(OpPPC64ADD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(off) + v.AddArg2(v0, ptr) + return true + } +} +func rewriteValuePPC64_OpPPC64ADD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADD z l:(MULLD x y)) + // cond: buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l) + // result: (MADDLD x y z ) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + z := v_0 + l := v_1 + if l.Op != OpPPC64MULLD { + continue + } + y := l.Args[1] + x := l.Args[0] + if !(buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l)) { + continue + } + v.reset(OpPPC64MADDLD) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (ADD z l:(MULLDconst [x] y)) + // cond: buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l) + // result: (MADDLD (MOVDconst [int64(x)]) y z ) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + z := v_0 + l := v_1 + if l.Op != OpPPC64MULLDconst { + continue + } + mt := l.Type + x := auxIntToInt32(l.AuxInt) + y := l.Args[0] + if !(buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l)) { + continue + } + v.reset(OpPPC64MADDLD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, mt) + v0.AuxInt = int64ToAuxInt(int64(x)) + v.AddArg3(v0, y, z) + return true + } + break + } + // match: (ADD x (MOVDconst [c])) + // cond: is32Bit(c) && !t.IsPtr() + // result: (ADDconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + continue + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c) && !t.IsPtr()) { + continue + } + v.reset(OpPPC64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64ADDC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDC x (MOVDconst [y])) + // cond: is16Bit(y) + // result: (ADDCconst [y] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + continue + } + y := auxIntToInt64(v_1.AuxInt) + if !(is16Bit(y)) { + continue + } + v.reset(OpPPC64ADDCconst) + v.AuxInt = int64ToAuxInt(y) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64ADDE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ADDE x y (Select1 (ADDCconst (MOVDconst [0]) [-1]))) + // result: (ADDC x y) + for { + x := v_0 + y := v_1 + if v_2.Op != OpSelect1 || v_2.Type != typ.UInt64 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64ADDCconst || auxIntToInt64(v_2_0.AuxInt) != -1 { + break + } + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpPPC64MOVDconst || auxIntToInt64(v_2_0_0.AuxInt) != 0 { + break + } + v.reset(OpPPC64ADDC) + v.AddArg2(x, y) + return true + } + // match: (ADDE (MOVDconst [0]) y c) + // result: (ADDZE y c) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst || auxIntToInt64(v_0.AuxInt) != 0 { + continue + } + y := v_1 + c := v_2 + v.reset(OpPPC64ADDZE) + v.AddArg2(y, c) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64ADDconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (ADDconst [z] l:(MULLD x y)) + // cond: buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l) + // result: (MADDLD x y (MOVDconst [int64(z)])) + for { + at := v.Type + z := auxIntToInt64(v.AuxInt) + l := v_0 + if l.Op != OpPPC64MULLD { + break + } + y := l.Args[1] + x := l.Args[0] + if !(buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l)) { + break + } + v.reset(OpPPC64MADDLD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, at) + v0.AuxInt = int64ToAuxInt(int64(z)) + v.AddArg3(x, y, v0) + return true + } + // match: (ADDconst [z] l:(MULLDconst [x] y)) + // cond: buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l) + // result: (MADDLD (MOVDconst [int64(x)]) y (MOVDconst [int64(z)])) + for { + at := v.Type + z := auxIntToInt64(v.AuxInt) + l := v_0 + if l.Op != OpPPC64MULLDconst { + break + } + mt := l.Type + x := auxIntToInt32(l.AuxInt) + y := l.Args[0] + if !(buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l)) { + break + } + v.reset(OpPPC64MADDLD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, mt) + v0.AuxInt = int64ToAuxInt(int64(x)) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, at) + v1.AuxInt = int64ToAuxInt(int64(z)) + v.AddArg3(v0, y, v1) + return true + } + // match: (ADDconst [c] (ADDconst [d] x)) + // cond: is32Bit(c+d) + // result: (ADDconst [c+d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64ADDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c + d)) { + break + } + v.reset(OpPPC64ADDconst) + v.AuxInt = int64ToAuxInt(c + d) + v.AddArg(x) + return true + } + // match: (ADDconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ADDconst [c] (MOVDaddr [d] {sym} x)) + // cond: is32Bit(c+int64(d)) + // result: (MOVDaddr [int32(c+int64(d))] {sym} x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVDaddr { + break + } + d := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + x := v_0.Args[0] + if !(is32Bit(c + int64(d))) { + break + } + v.reset(OpPPC64MOVDaddr) + v.AuxInt = int32ToAuxInt(int32(c + int64(d))) + v.Aux = symToAux(sym) + v.AddArg(x) + return true + } + // match: (ADDconst [c] x:(SP)) + // cond: is32Bit(c) + // result: (MOVDaddr [int32(c)] x) + for { + c := auxIntToInt64(v.AuxInt) + x := v_0 + if x.Op != OpSP || !(is32Bit(c)) { + break + } + v.reset(OpPPC64MOVDaddr) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (ADDconst [c] (SUBFCconst [d] x)) + // cond: is32Bit(c+d) + // result: (SUBFCconst [c+d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64SUBFCconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c + d)) { + break + } + v.reset(OpPPC64SUBFCconst) + v.AuxInt = int64ToAuxInt(c + d) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64AND(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AND (MOVDconst [m]) (ROTLWconst [r] x)) + // cond: isPPC64WordRotateMask(m) + // result: (RLWINM [encodePPC64RotateMask(r,m,32)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64ROTLWconst { + continue + } + r := auxIntToInt64(v_1.AuxInt) + x := v_1.Args[0] + if !(isPPC64WordRotateMask(m)) { + continue + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(r, m, 32)) + v.AddArg(x) + return true + } + break + } + // match: (AND (MOVDconst [m]) (ROTLW x r)) + // cond: isPPC64WordRotateMask(m) + // result: (RLWNM [encodePPC64RotateMask(0,m,32)] x r) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64ROTLW { + continue + } + r := v_1.Args[1] + x := v_1.Args[0] + if !(isPPC64WordRotateMask(m)) { + continue + } + v.reset(OpPPC64RLWNM) + v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(0, m, 32)) + v.AddArg2(x, r) + return true + } + break + } + // match: (AND (MOVDconst [m]) (SRWconst x [s])) + // cond: mergePPC64RShiftMask(m,s,32) == 0 + // result: (MOVDconst [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64SRWconst { + continue + } + s := auxIntToInt64(v_1.AuxInt) + if !(mergePPC64RShiftMask(m, s, 32) == 0) { + continue + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (AND (MOVDconst [m]) (SRWconst x [s])) + // cond: mergePPC64AndSrwi(m,s) != 0 + // result: (RLWINM [mergePPC64AndSrwi(m,s)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64SRWconst { + continue + } + s := auxIntToInt64(v_1.AuxInt) + x := v_1.Args[0] + if !(mergePPC64AndSrwi(m, s) != 0) { + continue + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndSrwi(m, s)) + v.AddArg(x) + return true + } + break + } + // match: (AND (MOVDconst [m]) (SRDconst x [s])) + // cond: mergePPC64AndSrdi(m,s) != 0 + // result: (RLWINM [mergePPC64AndSrdi(m,s)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64SRDconst { + continue + } + s := auxIntToInt64(v_1.AuxInt) + x := v_1.Args[0] + if !(mergePPC64AndSrdi(m, s) != 0) { + continue + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndSrdi(m, s)) + v.AddArg(x) + return true + } + break + } + // match: (AND (MOVDconst [m]) (SLDconst x [s])) + // cond: mergePPC64AndSldi(m,s) != 0 + // result: (RLWINM [mergePPC64AndSldi(m,s)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64SLDconst { + continue + } + s := auxIntToInt64(v_1.AuxInt) + x := v_1.Args[0] + if !(mergePPC64AndSldi(m, s) != 0) { + continue + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndSldi(m, s)) + v.AddArg(x) + return true + } + break + } + // match: (AND x (NOR y y)) + // result: (ANDN x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpPPC64NOR { + continue + } + y := v_1.Args[1] + if y != v_1.Args[0] { + continue + } + v.reset(OpPPC64ANDN) + v.AddArg2(x, y) + return true + } + break + } + // match: (AND (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [c&d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64MOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(c & d) + return true + } + break + } + // match: (AND x (MOVDconst [-1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpPPC64MOVDconst || auxIntToInt64(v_1.AuxInt) != -1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (AND x (MOVDconst [c])) + // cond: isU16Bit(c) + // result: (ANDconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isU16Bit(c)) { + continue + } + v.reset(OpPPC64ANDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (AND (MOVDconst [c]) y:(MOVWZreg _)) + // cond: c&0xFFFFFFFF == 0xFFFFFFFF + // result: y + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + if y.Op != OpPPC64MOVWZreg || !(c&0xFFFFFFFF == 0xFFFFFFFF) { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (AND (MOVDconst [0xFFFFFFFF]) y:(MOVWreg x)) + // result: (MOVWZreg x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst || auxIntToInt64(v_0.AuxInt) != 0xFFFFFFFF { + continue + } + y := v_1 + if y.Op != OpPPC64MOVWreg { + continue + } + x := y.Args[0] + v.reset(OpPPC64MOVWZreg) + v.AddArg(x) + return true + } + break + } + // match: (AND (MOVDconst [c]) x:(MOVBZload _ _)) + // result: (ANDconst [c&0xFF] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if x.Op != OpPPC64MOVBZload { + continue + } + v.reset(OpPPC64ANDconst) + v.AuxInt = int64ToAuxInt(c & 0xFF) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64ANDN(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ANDN (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [c&^d]) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64MOVDconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(c &^ d) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64ANDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDconst [m] (ROTLWconst [r] x)) + // cond: isPPC64WordRotateMask(m) + // result: (RLWINM [encodePPC64RotateMask(r,m,32)] x) + for { + m := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64ROTLWconst { + break + } + r := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(isPPC64WordRotateMask(m)) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(r, m, 32)) + v.AddArg(x) + return true + } + // match: (ANDconst [m] (ROTLW x r)) + // cond: isPPC64WordRotateMask(m) + // result: (RLWNM [encodePPC64RotateMask(0,m,32)] x r) + for { + m := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64ROTLW { + break + } + r := v_0.Args[1] + x := v_0.Args[0] + if !(isPPC64WordRotateMask(m)) { + break + } + v.reset(OpPPC64RLWNM) + v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(0, m, 32)) + v.AddArg2(x, r) + return true + } + // match: (ANDconst [m] (SRWconst x [s])) + // cond: mergePPC64RShiftMask(m,s,32) == 0 + // result: (MOVDconst [0]) + for { + m := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64SRWconst { + break + } + s := auxIntToInt64(v_0.AuxInt) + if !(mergePPC64RShiftMask(m, s, 32) == 0) { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (ANDconst [m] (SRWconst x [s])) + // cond: mergePPC64AndSrwi(m,s) != 0 + // result: (RLWINM [mergePPC64AndSrwi(m,s)] x) + for { + m := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64SRWconst { + break + } + s := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(mergePPC64AndSrwi(m, s) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndSrwi(m, s)) + v.AddArg(x) + return true + } + // match: (ANDconst [m] (SRDconst x [s])) + // cond: mergePPC64AndSrdi(m,s) != 0 + // result: (RLWINM [mergePPC64AndSrdi(m,s)] x) + for { + m := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64SRDconst { + break + } + s := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(mergePPC64AndSrdi(m, s) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndSrdi(m, s)) + v.AddArg(x) + return true + } + // match: (ANDconst [m] (SLDconst x [s])) + // cond: mergePPC64AndSldi(m,s) != 0 + // result: (RLWINM [mergePPC64AndSldi(m,s)] x) + for { + m := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64SLDconst { + break + } + s := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(mergePPC64AndSldi(m, s) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndSldi(m, s)) + v.AddArg(x) + return true + } + // match: (ANDconst [c] (ANDconst [d] x)) + // result: (ANDconst [c&d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64ANDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpPPC64ANDconst) + v.AuxInt = int64ToAuxInt(c & d) + v.AddArg(x) + return true + } + // match: (ANDconst [-1] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ANDconst [0] _) + // result: (MOVDconst [0]) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (ANDconst [c] y:(MOVBZreg _)) + // cond: c&0xFF == 0xFF + // result: y + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if y.Op != OpPPC64MOVBZreg || !(c&0xFF == 0xFF) { + break + } + v.copyOf(y) + return true + } + // match: (ANDconst [0xFF] (MOVBreg x)) + // result: (MOVBZreg x) + for { + if auxIntToInt64(v.AuxInt) != 0xFF || v_0.Op != OpPPC64MOVBreg { + break + } + x := v_0.Args[0] + v.reset(OpPPC64MOVBZreg) + v.AddArg(x) + return true + } + // match: (ANDconst [c] y:(MOVHZreg _)) + // cond: c&0xFFFF == 0xFFFF + // result: y + for { + c := auxIntToInt64(v.AuxInt) + y := v_0 + if y.Op != OpPPC64MOVHZreg || !(c&0xFFFF == 0xFFFF) { + break + } + v.copyOf(y) + return true + } + // match: (ANDconst [0xFFFF] (MOVHreg x)) + // result: (MOVHZreg x) + for { + if auxIntToInt64(v.AuxInt) != 0xFFFF || v_0.Op != OpPPC64MOVHreg { + break + } + x := v_0.Args[0] + v.reset(OpPPC64MOVHZreg) + v.AddArg(x) + return true + } + // match: (ANDconst [c] (MOVBZreg x)) + // result: (ANDconst [c&0xFF] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVBZreg { + break + } + x := v_0.Args[0] + v.reset(OpPPC64ANDconst) + v.AuxInt = int64ToAuxInt(c & 0xFF) + v.AddArg(x) + return true + } + // match: (ANDconst [c] (MOVHZreg x)) + // result: (ANDconst [c&0xFFFF] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVHZreg { + break + } + x := v_0.Args[0] + v.reset(OpPPC64ANDconst) + v.AuxInt = int64ToAuxInt(c & 0xFFFF) + v.AddArg(x) + return true + } + // match: (ANDconst [c] (MOVWZreg x)) + // result: (ANDconst [c&0xFFFFFFFF] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVWZreg { + break + } + x := v_0.Args[0] + v.reset(OpPPC64ANDconst) + v.AuxInt = int64ToAuxInt(c & 0xFFFFFFFF) + v.AddArg(x) + return true + } + // match: (ANDconst [m] (RLWINM [r] y)) + // cond: mergePPC64AndRlwinm(uint32(m),r) != 0 + // result: (RLWINM [mergePPC64AndRlwinm(uint32(m),r)] y) + for { + m := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64RLWINM { + break + } + r := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + if !(mergePPC64AndRlwinm(uint32(m), r) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndRlwinm(uint32(m), r)) + v.AddArg(y) + return true + } + // match: (ANDconst [1] z:(SRADconst [63] x)) + // cond: z.Uses == 1 + // result: (SRDconst [63] x) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + z := v_0 + if z.Op != OpPPC64SRADconst || auxIntToInt64(z.AuxInt) != 63 { + break + } + x := z.Args[0] + if !(z.Uses == 1) { + break + } + v.reset(OpPPC64SRDconst) + v.AuxInt = int64ToAuxInt(63) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64BRD(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BRD x:(MOVDload [off] {sym} ptr mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVDBRload (MOVDaddr [off] {sym} ptr) mem) + for { + x := v_0 + if x.Op != OpPPC64MOVDload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpPPC64MOVDBRload, typ.UInt64) + v.copyOf(v0) + v1 := b.NewValue0(x.Pos, OpPPC64MOVDaddr, ptr.Type) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(sym) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + // match: (BRD x:(MOVDloadidx ptr idx mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVDBRloadidx ptr idx mem) + for { + x := v_0 + if x.Op != OpPPC64MOVDloadidx { + break + } + mem := x.Args[2] + ptr := x.Args[0] + idx := x.Args[1] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpPPC64MOVDBRloadidx, typ.Int64) + v.copyOf(v0) + v0.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64BRH(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BRH x:(MOVHZload [off] {sym} ptr mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVHBRload (MOVDaddr [off] {sym} ptr) mem) + for { + x := v_0 + if x.Op != OpPPC64MOVHZload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpPPC64MOVHBRload, typ.UInt16) + v.copyOf(v0) + v1 := b.NewValue0(x.Pos, OpPPC64MOVDaddr, ptr.Type) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(sym) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + // match: (BRH x:(MOVHZloadidx ptr idx mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVHBRloadidx ptr idx mem) + for { + x := v_0 + if x.Op != OpPPC64MOVHZloadidx { + break + } + mem := x.Args[2] + ptr := x.Args[0] + idx := x.Args[1] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpPPC64MOVHBRloadidx, typ.Int16) + v.copyOf(v0) + v0.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64BRW(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BRW x:(MOVWZload [off] {sym} ptr mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVWBRload (MOVDaddr [off] {sym} ptr) mem) + for { + x := v_0 + if x.Op != OpPPC64MOVWZload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpPPC64MOVWBRload, typ.UInt32) + v.copyOf(v0) + v1 := b.NewValue0(x.Pos, OpPPC64MOVDaddr, ptr.Type) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(sym) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + // match: (BRW x:(MOVWZloadidx ptr idx mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVWBRloadidx ptr idx mem) + for { + x := v_0 + if x.Op != OpPPC64MOVWZloadidx { + break + } + mem := x.Args[2] + ptr := x.Args[0] + idx := x.Args[1] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpPPC64MOVWBRloadidx, typ.Int32) + v.copyOf(v0) + v0.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64CLRLSLDI(v *Value) bool { + v_0 := v.Args[0] + // match: (CLRLSLDI [c] (SRWconst [s] x)) + // cond: mergePPC64ClrlsldiSrw(int64(c),s) != 0 + // result: (RLWINM [mergePPC64ClrlsldiSrw(int64(c),s)] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpPPC64SRWconst { + break + } + s := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(mergePPC64ClrlsldiSrw(int64(c), s) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64ClrlsldiSrw(int64(c), s)) + v.AddArg(x) + return true + } + // match: (CLRLSLDI [c] (SRDconst [s] x)) + // cond: mergePPC64ClrlsldiSrd(int64(c),s) != 0 + // result: (RLWINM [mergePPC64ClrlsldiSrd(int64(c),s)] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpPPC64SRDconst { + break + } + s := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(mergePPC64ClrlsldiSrd(int64(c), s) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64ClrlsldiSrd(int64(c), s)) + v.AddArg(x) + return true + } + // match: (CLRLSLDI [c] i:(RLWINM [s] x)) + // cond: mergePPC64ClrlsldiRlwinm(c,s) != 0 + // result: (RLWINM [mergePPC64ClrlsldiRlwinm(c,s)] x) + for { + c := auxIntToInt32(v.AuxInt) + i := v_0 + if i.Op != OpPPC64RLWINM { + break + } + s := auxIntToInt64(i.AuxInt) + x := i.Args[0] + if !(mergePPC64ClrlsldiRlwinm(c, s) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64ClrlsldiRlwinm(c, s)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64CMP(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMP x (MOVDconst [c])) + // cond: is16Bit(c) + // result: (CMPconst x [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(is16Bit(c)) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMP (MOVDconst [c]) y) + // cond: is16Bit(c) + // result: (InvertFlags (CMPconst y [c])) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(is16Bit(c)) { + break + } + v.reset(OpPPC64InvertFlags) + v0 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (CMP x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMP y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpPPC64InvertFlags) + v0 := b.NewValue0(v.Pos, OpPPC64CMP, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64CMPU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPU x (MOVDconst [c])) + // cond: isU16Bit(c) + // result: (CMPUconst x [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isU16Bit(c)) { + break + } + v.reset(OpPPC64CMPUconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPU (MOVDconst [c]) y) + // cond: isU16Bit(c) + // result: (InvertFlags (CMPUconst y [c])) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(isU16Bit(c)) { + break + } + v.reset(OpPPC64InvertFlags) + v0 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (CMPU x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPU y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpPPC64InvertFlags) + v0 := b.NewValue0(v.Pos, OpPPC64CMPU, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64CMPUconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPUconst [d] (ANDconst z [c])) + // cond: uint64(d) > uint64(c) + // result: (FlagLT) + for { + d := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64ANDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if !(uint64(d) > uint64(c)) { + break + } + v.reset(OpPPC64FlagLT) + return true + } + // match: (CMPUconst (MOVDconst [x]) [y]) + // cond: x==y + // result: (FlagEQ) + for { + y := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(x == y) { + break + } + v.reset(OpPPC64FlagEQ) + return true + } + // match: (CMPUconst (MOVDconst [x]) [y]) + // cond: uint64(x)uint64(y) + // result: (FlagGT) + for { + y := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(uint64(x) > uint64(y)) { + break + } + v.reset(OpPPC64FlagGT) + return true + } + // match: (CMPUconst [0] a:(ANDconst [n] z)) + // result: (CMPconst [0] a) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + a := v_0 + if a.Op != OpPPC64ANDconst { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(a) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64CMPW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPW x (MOVWreg y)) + // result: (CMPW x y) + for { + x := v_0 + if v_1.Op != OpPPC64MOVWreg { + break + } + y := v_1.Args[0] + v.reset(OpPPC64CMPW) + v.AddArg2(x, y) + return true + } + // match: (CMPW (MOVWreg x) y) + // result: (CMPW x y) + for { + if v_0.Op != OpPPC64MOVWreg { + break + } + x := v_0.Args[0] + y := v_1 + v.reset(OpPPC64CMPW) + v.AddArg2(x, y) + return true + } + // match: (CMPW x (MOVDconst [c])) + // cond: is16Bit(c) + // result: (CMPWconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(is16Bit(c)) { + break + } + v.reset(OpPPC64CMPWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (CMPW (MOVDconst [c]) y) + // cond: is16Bit(c) + // result: (InvertFlags (CMPWconst y [int32(c)])) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(is16Bit(c)) { + break + } + v.reset(OpPPC64InvertFlags) + v0 := b.NewValue0(v.Pos, OpPPC64CMPWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (CMPW x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPW y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpPPC64InvertFlags) + v0 := b.NewValue0(v.Pos, OpPPC64CMPW, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64CMPWU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPWU x (MOVWZreg y)) + // result: (CMPWU x y) + for { + x := v_0 + if v_1.Op != OpPPC64MOVWZreg { + break + } + y := v_1.Args[0] + v.reset(OpPPC64CMPWU) + v.AddArg2(x, y) + return true + } + // match: (CMPWU (MOVWZreg x) y) + // result: (CMPWU x y) + for { + if v_0.Op != OpPPC64MOVWZreg { + break + } + x := v_0.Args[0] + y := v_1 + v.reset(OpPPC64CMPWU) + v.AddArg2(x, y) + return true + } + // match: (CMPWU x (MOVDconst [c])) + // cond: isU16Bit(c) + // result: (CMPWUconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isU16Bit(c)) { + break + } + v.reset(OpPPC64CMPWUconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (CMPWU (MOVDconst [c]) y) + // cond: isU16Bit(c) + // result: (InvertFlags (CMPWUconst y [int32(c)])) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(isU16Bit(c)) { + break + } + v.reset(OpPPC64InvertFlags) + v0 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (CMPWU x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPWU y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpPPC64InvertFlags) + v0 := b.NewValue0(v.Pos, OpPPC64CMPWU, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64CMPWUconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPWUconst [d] (ANDconst z [c])) + // cond: uint64(d) > uint64(c) + // result: (FlagLT) + for { + d := auxIntToInt32(v.AuxInt) + if v_0.Op != OpPPC64ANDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if !(uint64(d) > uint64(c)) { + break + } + v.reset(OpPPC64FlagLT) + return true + } + // match: (CMPWUconst (MOVDconst [x]) [y]) + // cond: int32(x)==int32(y) + // result: (FlagEQ) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpPPC64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(int32(x) == int32(y)) { + break + } + v.reset(OpPPC64FlagEQ) + return true + } + // match: (CMPWUconst (MOVDconst [x]) [y]) + // cond: uint32(x)uint32(y) + // result: (FlagGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpPPC64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(uint32(x) > uint32(y)) { + break + } + v.reset(OpPPC64FlagGT) + return true + } + // match: (CMPWUconst [0] a:(ANDconst [n] z)) + // result: (CMPconst [0] a) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + a := v_0 + if a.Op != OpPPC64ANDconst { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(a) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64CMPWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPWconst (MOVDconst [x]) [y]) + // cond: int32(x)==int32(y) + // result: (FlagEQ) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpPPC64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(int32(x) == int32(y)) { + break + } + v.reset(OpPPC64FlagEQ) + return true + } + // match: (CMPWconst (MOVDconst [x]) [y]) + // cond: int32(x)int32(y) + // result: (FlagGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpPPC64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(int32(x) > int32(y)) { + break + } + v.reset(OpPPC64FlagGT) + return true + } + // match: (CMPWconst [0] a:(ANDconst [n] z)) + // result: (CMPconst [0] a) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + a := v_0 + if a.Op != OpPPC64ANDconst { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(a) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64CMPconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPconst (MOVDconst [x]) [y]) + // cond: x==y + // result: (FlagEQ) + for { + y := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(x == y) { + break + } + v.reset(OpPPC64FlagEQ) + return true + } + // match: (CMPconst (MOVDconst [x]) [y]) + // cond: xy + // result: (FlagGT) + for { + y := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(x > y) { + break + } + v.reset(OpPPC64FlagGT) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64Equal(v *Value) bool { + v_0 := v.Args[0] + // match: (Equal (FlagEQ)) + // result: (MOVDconst [1]) + for { + if v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (Equal (FlagLT)) + // result: (MOVDconst [0]) + for { + if v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Equal (FlagGT)) + // result: (MOVDconst [0]) + for { + if v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Equal (InvertFlags x)) + // result: (Equal x) + for { + if v_0.Op != OpPPC64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpPPC64Equal) + v.AddArg(x) + return true + } + // match: (Equal cmp) + // result: (SETBC [2] cmp) + for { + cmp := v_0 + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(2) + v.AddArg(cmp) + return true + } +} +func rewriteValuePPC64_OpPPC64FABS(v *Value) bool { + v_0 := v.Args[0] + // match: (FABS (FMOVDconst [x])) + // result: (FMOVDconst [math.Abs(x)]) + for { + if v_0.Op != OpPPC64FMOVDconst { + break + } + x := auxIntToFloat64(v_0.AuxInt) + v.reset(OpPPC64FMOVDconst) + v.AuxInt = float64ToAuxInt(math.Abs(x)) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64FADD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FADD (FMUL x y) z) + // cond: x.Block.Func.useFMA(v) + // result: (FMADD x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64FMUL { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + z := v_1 + if !(x.Block.Func.useFMA(v)) { + continue + } + v.reset(OpPPC64FMADD) + v.AddArg3(x, y, z) + return true + } + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64FADDS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FADDS (FMULS x y) z) + // cond: x.Block.Func.useFMA(v) + // result: (FMADDS x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64FMULS { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + z := v_1 + if !(x.Block.Func.useFMA(v)) { + continue + } + v.reset(OpPPC64FMADDS) + v.AddArg3(x, y, z) + return true + } + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64FCEIL(v *Value) bool { + v_0 := v.Args[0] + // match: (FCEIL (FMOVDconst [x])) + // result: (FMOVDconst [math.Ceil(x)]) + for { + if v_0.Op != OpPPC64FMOVDconst { + break + } + x := auxIntToFloat64(v_0.AuxInt) + v.reset(OpPPC64FMOVDconst) + v.AuxInt = float64ToAuxInt(math.Ceil(x)) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64FFLOOR(v *Value) bool { + v_0 := v.Args[0] + // match: (FFLOOR (FMOVDconst [x])) + // result: (FMOVDconst [math.Floor(x)]) + for { + if v_0.Op != OpPPC64FMOVDconst { + break + } + x := auxIntToFloat64(v_0.AuxInt) + v.reset(OpPPC64FMOVDconst) + v.AuxInt = float64ToAuxInt(math.Floor(x)) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64FGreaterEqual(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (FGreaterEqual cmp) + // result: (OR (SETBC [2] cmp) (SETBC [1] cmp)) + for { + cmp := v_0 + v.reset(OpPPC64OR) + v0 := b.NewValue0(v.Pos, OpPPC64SETBC, typ.Int32) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg(cmp) + v1 := b.NewValue0(v.Pos, OpPPC64SETBC, typ.Int32) + v1.AuxInt = int32ToAuxInt(1) + v1.AddArg(cmp) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuePPC64_OpPPC64FGreaterThan(v *Value) bool { + v_0 := v.Args[0] + // match: (FGreaterThan cmp) + // result: (SETBC [1] cmp) + for { + cmp := v_0 + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(cmp) + return true + } +} +func rewriteValuePPC64_OpPPC64FLessEqual(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (FLessEqual cmp) + // result: (OR (SETBC [2] cmp) (SETBC [0] cmp)) + for { + cmp := v_0 + v.reset(OpPPC64OR) + v0 := b.NewValue0(v.Pos, OpPPC64SETBC, typ.Int32) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg(cmp) + v1 := b.NewValue0(v.Pos, OpPPC64SETBC, typ.Int32) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg(cmp) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuePPC64_OpPPC64FLessThan(v *Value) bool { + v_0 := v.Args[0] + // match: (FLessThan cmp) + // result: (SETBC [0] cmp) + for { + cmp := v_0 + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(cmp) + return true + } +} +func rewriteValuePPC64_OpPPC64FMOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVDload [off] {sym} ptr (MOVDstore [off] {sym} ptr x _)) + // result: (MTVSRD x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpPPC64MTVSRD) + v.AddArg(x) + return true + } + // match: (FMOVDload [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (FMOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64FMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (FMOVDload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (FMOVDload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64FMOVDload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64FMOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVDstore [off] {sym} ptr (MTVSRD x) mem) + // result: (MOVDstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MTVSRD { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVDstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (FMOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (FMOVDstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64FMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (FMOVDstore [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (FMOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64FMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64FMOVSload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVSload [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (FMOVSload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64FMOVSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (FMOVSload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (FMOVSload [off1+int32(off2)] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64FMOVSload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64FMOVSstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVSstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (FMOVSstore [off1+int32(off2)] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64FMOVSstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (FMOVSstore [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (FMOVSstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64FMOVSstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64FNEG(v *Value) bool { + v_0 := v.Args[0] + // match: (FNEG (FABS x)) + // result: (FNABS x) + for { + if v_0.Op != OpPPC64FABS { + break + } + x := v_0.Args[0] + v.reset(OpPPC64FNABS) + v.AddArg(x) + return true + } + // match: (FNEG (FNABS x)) + // result: (FABS x) + for { + if v_0.Op != OpPPC64FNABS { + break + } + x := v_0.Args[0] + v.reset(OpPPC64FABS) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64FSQRT(v *Value) bool { + v_0 := v.Args[0] + // match: (FSQRT (FMOVDconst [x])) + // cond: x >= 0 + // result: (FMOVDconst [math.Sqrt(x)]) + for { + if v_0.Op != OpPPC64FMOVDconst { + break + } + x := auxIntToFloat64(v_0.AuxInt) + if !(x >= 0) { + break + } + v.reset(OpPPC64FMOVDconst) + v.AuxInt = float64ToAuxInt(math.Sqrt(x)) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64FSUB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FSUB (FMUL x y) z) + // cond: x.Block.Func.useFMA(v) + // result: (FMSUB x y z) + for { + if v_0.Op != OpPPC64FMUL { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + z := v_1 + if !(x.Block.Func.useFMA(v)) { + continue + } + v.reset(OpPPC64FMSUB) + v.AddArg3(x, y, z) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64FSUBS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FSUBS (FMULS x y) z) + // cond: x.Block.Func.useFMA(v) + // result: (FMSUBS x y z) + for { + if v_0.Op != OpPPC64FMULS { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + z := v_1 + if !(x.Block.Func.useFMA(v)) { + continue + } + v.reset(OpPPC64FMSUBS) + v.AddArg3(x, y, z) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64FTRUNC(v *Value) bool { + v_0 := v.Args[0] + // match: (FTRUNC (FMOVDconst [x])) + // result: (FMOVDconst [math.Trunc(x)]) + for { + if v_0.Op != OpPPC64FMOVDconst { + break + } + x := auxIntToFloat64(v_0.AuxInt) + v.reset(OpPPC64FMOVDconst) + v.AuxInt = float64ToAuxInt(math.Trunc(x)) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64GreaterEqual(v *Value) bool { + v_0 := v.Args[0] + // match: (GreaterEqual (FlagEQ)) + // result: (MOVDconst [1]) + for { + if v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (GreaterEqual (FlagLT)) + // result: (MOVDconst [0]) + for { + if v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (GreaterEqual (FlagGT)) + // result: (MOVDconst [1]) + for { + if v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (GreaterEqual (InvertFlags x)) + // result: (LessEqual x) + for { + if v_0.Op != OpPPC64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpPPC64LessEqual) + v.AddArg(x) + return true + } + // match: (GreaterEqual cmp) + // result: (SETBCR [0] cmp) + for { + cmp := v_0 + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(cmp) + return true + } +} +func rewriteValuePPC64_OpPPC64GreaterThan(v *Value) bool { + v_0 := v.Args[0] + // match: (GreaterThan (FlagEQ)) + // result: (MOVDconst [0]) + for { + if v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (GreaterThan (FlagLT)) + // result: (MOVDconst [0]) + for { + if v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (GreaterThan (FlagGT)) + // result: (MOVDconst [1]) + for { + if v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (GreaterThan (InvertFlags x)) + // result: (LessThan x) + for { + if v_0.Op != OpPPC64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpPPC64LessThan) + v.AddArg(x) + return true + } + // match: (GreaterThan cmp) + // result: (SETBC [1] cmp) + for { + cmp := v_0 + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(cmp) + return true + } +} +func rewriteValuePPC64_OpPPC64ISEL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ISEL [6] x y (CMPconst [0] (ANDconst [1] (SETBC [c] cmp)))) + // result: (ISEL [c] x y cmp) + for { + if auxIntToInt32(v.AuxInt) != 6 { + break + } + x := v_0 + y := v_1 + if v_2.Op != OpPPC64CMPconst || auxIntToInt64(v_2.AuxInt) != 0 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64ANDconst || auxIntToInt64(v_2_0.AuxInt) != 1 { + break + } + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpPPC64SETBC { + break + } + c := auxIntToInt32(v_2_0_0.AuxInt) + cmp := v_2_0_0.Args[0] + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, cmp) + return true + } + // match: (ISEL [6] x y (CMPconst [0] (SETBC [c] cmp))) + // result: (ISEL [c] x y cmp) + for { + if auxIntToInt32(v.AuxInt) != 6 { + break + } + x := v_0 + y := v_1 + if v_2.Op != OpPPC64CMPconst || auxIntToInt64(v_2.AuxInt) != 0 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64SETBC { + break + } + c := auxIntToInt32(v_2_0.AuxInt) + cmp := v_2_0.Args[0] + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, cmp) + return true + } + // match: (ISEL [6] x y (CMPWconst [0] (SETBC [c] cmp))) + // result: (ISEL [c] x y cmp) + for { + if auxIntToInt32(v.AuxInt) != 6 { + break + } + x := v_0 + y := v_1 + if v_2.Op != OpPPC64CMPWconst || auxIntToInt32(v_2.AuxInt) != 0 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64SETBC { + break + } + c := auxIntToInt32(v_2_0.AuxInt) + cmp := v_2_0.Args[0] + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(c) + v.AddArg3(x, y, cmp) + return true + } + // match: (ISEL [6] x y (CMPconst [0] (SETBCR [c] cmp))) + // result: (ISEL [c+4] x y cmp) + for { + if auxIntToInt32(v.AuxInt) != 6 { + break + } + x := v_0 + y := v_1 + if v_2.Op != OpPPC64CMPconst || auxIntToInt64(v_2.AuxInt) != 0 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64SETBCR { + break + } + c := auxIntToInt32(v_2_0.AuxInt) + cmp := v_2_0.Args[0] + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(c + 4) + v.AddArg3(x, y, cmp) + return true + } + // match: (ISEL [6] x y (CMPWconst [0] (SETBCR [c] cmp))) + // result: (ISEL [c+4] x y cmp) + for { + if auxIntToInt32(v.AuxInt) != 6 { + break + } + x := v_0 + y := v_1 + if v_2.Op != OpPPC64CMPWconst || auxIntToInt32(v_2.AuxInt) != 0 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64SETBCR { + break + } + c := auxIntToInt32(v_2_0.AuxInt) + cmp := v_2_0.Args[0] + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(c + 4) + v.AddArg3(x, y, cmp) + return true + } + // match: (ISEL [2] x _ (FlagEQ)) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 2 { + break + } + x := v_0 + if v_2.Op != OpPPC64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (ISEL [2] _ y (FlagLT)) + // result: y + for { + if auxIntToInt32(v.AuxInt) != 2 { + break + } + y := v_1 + if v_2.Op != OpPPC64FlagLT { + break + } + v.copyOf(y) + return true + } + // match: (ISEL [2] _ y (FlagGT)) + // result: y + for { + if auxIntToInt32(v.AuxInt) != 2 { + break + } + y := v_1 + if v_2.Op != OpPPC64FlagGT { + break + } + v.copyOf(y) + return true + } + // match: (ISEL [6] _ y (FlagEQ)) + // result: y + for { + if auxIntToInt32(v.AuxInt) != 6 { + break + } + y := v_1 + if v_2.Op != OpPPC64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (ISEL [6] x _ (FlagLT)) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 6 { + break + } + x := v_0 + if v_2.Op != OpPPC64FlagLT { + break + } + v.copyOf(x) + return true + } + // match: (ISEL [6] x _ (FlagGT)) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 6 { + break + } + x := v_0 + if v_2.Op != OpPPC64FlagGT { + break + } + v.copyOf(x) + return true + } + // match: (ISEL [0] _ y (FlagEQ)) + // result: y + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + y := v_1 + if v_2.Op != OpPPC64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (ISEL [0] _ y (FlagGT)) + // result: y + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + y := v_1 + if v_2.Op != OpPPC64FlagGT { + break + } + v.copyOf(y) + return true + } + // match: (ISEL [0] x _ (FlagLT)) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + if v_2.Op != OpPPC64FlagLT { + break + } + v.copyOf(x) + return true + } + // match: (ISEL [5] _ x (FlagEQ)) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 5 { + break + } + x := v_1 + if v_2.Op != OpPPC64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (ISEL [5] _ x (FlagLT)) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 5 { + break + } + x := v_1 + if v_2.Op != OpPPC64FlagLT { + break + } + v.copyOf(x) + return true + } + // match: (ISEL [5] y _ (FlagGT)) + // result: y + for { + if auxIntToInt32(v.AuxInt) != 5 { + break + } + y := v_0 + if v_2.Op != OpPPC64FlagGT { + break + } + v.copyOf(y) + return true + } + // match: (ISEL [1] _ y (FlagEQ)) + // result: y + for { + if auxIntToInt32(v.AuxInt) != 1 { + break + } + y := v_1 + if v_2.Op != OpPPC64FlagEQ { + break + } + v.copyOf(y) + return true + } + // match: (ISEL [1] _ y (FlagLT)) + // result: y + for { + if auxIntToInt32(v.AuxInt) != 1 { + break + } + y := v_1 + if v_2.Op != OpPPC64FlagLT { + break + } + v.copyOf(y) + return true + } + // match: (ISEL [1] x _ (FlagGT)) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 1 { + break + } + x := v_0 + if v_2.Op != OpPPC64FlagGT { + break + } + v.copyOf(x) + return true + } + // match: (ISEL [4] x _ (FlagEQ)) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 4 { + break + } + x := v_0 + if v_2.Op != OpPPC64FlagEQ { + break + } + v.copyOf(x) + return true + } + // match: (ISEL [4] x _ (FlagGT)) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 4 { + break + } + x := v_0 + if v_2.Op != OpPPC64FlagGT { + break + } + v.copyOf(x) + return true + } + // match: (ISEL [4] _ y (FlagLT)) + // result: y + for { + if auxIntToInt32(v.AuxInt) != 4 { + break + } + y := v_1 + if v_2.Op != OpPPC64FlagLT { + break + } + v.copyOf(y) + return true + } + // match: (ISEL [n] x y (InvertFlags bool)) + // cond: n%4 == 0 + // result: (ISEL [n+1] x y bool) + for { + n := auxIntToInt32(v.AuxInt) + x := v_0 + y := v_1 + if v_2.Op != OpPPC64InvertFlags { + break + } + bool := v_2.Args[0] + if !(n%4 == 0) { + break + } + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(n + 1) + v.AddArg3(x, y, bool) + return true + } + // match: (ISEL [n] x y (InvertFlags bool)) + // cond: n%4 == 1 + // result: (ISEL [n-1] x y bool) + for { + n := auxIntToInt32(v.AuxInt) + x := v_0 + y := v_1 + if v_2.Op != OpPPC64InvertFlags { + break + } + bool := v_2.Args[0] + if !(n%4 == 1) { + break + } + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(n - 1) + v.AddArg3(x, y, bool) + return true + } + // match: (ISEL [n] x y (InvertFlags bool)) + // cond: n%4 == 2 + // result: (ISEL [n] x y bool) + for { + n := auxIntToInt32(v.AuxInt) + x := v_0 + y := v_1 + if v_2.Op != OpPPC64InvertFlags { + break + } + bool := v_2.Args[0] + if !(n%4 == 2) { + break + } + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(n) + v.AddArg3(x, y, bool) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64LessEqual(v *Value) bool { + v_0 := v.Args[0] + // match: (LessEqual (FlagEQ)) + // result: (MOVDconst [1]) + for { + if v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (LessEqual (FlagLT)) + // result: (MOVDconst [1]) + for { + if v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (LessEqual (FlagGT)) + // result: (MOVDconst [0]) + for { + if v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (LessEqual (InvertFlags x)) + // result: (GreaterEqual x) + for { + if v_0.Op != OpPPC64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpPPC64GreaterEqual) + v.AddArg(x) + return true + } + // match: (LessEqual cmp) + // result: (SETBCR [1] cmp) + for { + cmp := v_0 + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(cmp) + return true + } +} +func rewriteValuePPC64_OpPPC64LessThan(v *Value) bool { + v_0 := v.Args[0] + // match: (LessThan (FlagEQ)) + // result: (MOVDconst [0]) + for { + if v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (LessThan (FlagLT)) + // result: (MOVDconst [1]) + for { + if v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (LessThan (FlagGT)) + // result: (MOVDconst [0]) + for { + if v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (LessThan (InvertFlags x)) + // result: (GreaterThan x) + for { + if v_0.Op != OpPPC64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpPPC64GreaterThan) + v.AddArg(x) + return true + } + // match: (LessThan cmp) + // result: (SETBC [0] cmp) + for { + cmp := v_0 + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(cmp) + return true + } +} +func rewriteValuePPC64_OpPPC64LoweredPanicBoundsCR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsCR [kind] {p} (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:p.C, Cy:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpPPC64LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: p.C, Cy: c}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64LoweredPanicBoundsRC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRC [kind] {p} (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:c, Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpPPC64LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: c, Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64LoweredPanicBoundsRR(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRR [kind] x (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsRC [kind] x {PanicBoundsC{C:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpPPC64LoweredPanicBoundsRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(x, mem) + return true + } + // match: (LoweredPanicBoundsRR [kind] (MOVDconst [c]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:c}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + mem := v_2 + v.reset(OpPPC64LoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MFVSRD(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MFVSRD (FMOVDconst [c])) + // result: (MOVDconst [int64(math.Float64bits(c))]) + for { + if v_0.Op != OpPPC64FMOVDconst { + break + } + c := auxIntToFloat64(v_0.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(math.Float64bits(c))) + return true + } + // match: (MFVSRD x:(FMOVDload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVDload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpPPC64FMOVDload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpPPC64MOVDload, typ.Int64) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVBZload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBZload [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVBZload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVBZload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBZload [off1] {sym} (ADDconst [off2] x) mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (MOVBZload [off1+int32(off2)] {sym} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + mem := v_1 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64MOVBZload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(x, mem) + return true + } + // match: (MOVBZload [0] {sym} p:(ADD ptr idx) mem) + // cond: sym == nil && p.Uses == 1 + // result: (MOVBZloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + idx := p.Args[1] + ptr := p.Args[0] + mem := v_1 + if !(sym == nil && p.Uses == 1) { + break + } + v.reset(OpPPC64MOVBZloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVBZloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBZloadidx ptr (MOVDconst [c]) mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVBZload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVBZload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBZloadidx (MOVDconst [c]) ptr mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVBZload [int32(c)] ptr mem) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVBZload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVBZreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVBZreg y:(ANDconst [c] _)) + // cond: uint64(c) <= 0xFF + // result: y + for { + y := v_0 + if y.Op != OpPPC64ANDconst { + break + } + c := auxIntToInt64(y.AuxInt) + if !(uint64(c) <= 0xFF) { + break + } + v.copyOf(y) + return true + } + // match: (MOVBZreg (SRWconst [c] (MOVBZreg x))) + // result: (SRWconst [c] (MOVBZreg x)) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVBZreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVBZreg (SRWconst [c] x)) + // cond: x.Type.Size() == 8 + // result: (SRWconst [c] x) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(x.Type.Size() == 8) { + break + } + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBZreg (SRDconst [c] x)) + // cond: c>=56 + // result: (SRDconst [c] x) + for { + if v_0.Op != OpPPC64SRDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c >= 56) { + break + } + v.reset(OpPPC64SRDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBZreg (SRWconst [c] x)) + // cond: c>=24 + // result: (SRWconst [c] x) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c >= 24) { + break + } + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBZreg y:(MOVBZreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVBZreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVBZreg (MOVBreg x)) + // result: (MOVBZreg x) + for { + if v_0.Op != OpPPC64MOVBreg { + break + } + x := v_0.Args[0] + v.reset(OpPPC64MOVBZreg) + v.AddArg(x) + return true + } + // match: (MOVBZreg (SRWconst x [s])) + // cond: mergePPC64AndSrwi(0xFF,s) != 0 + // result: (RLWINM [mergePPC64AndSrwi(0xFF,s)] x) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + s := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(mergePPC64AndSrwi(0xFF, s) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndSrwi(0xFF, s)) + v.AddArg(x) + return true + } + // match: (MOVBZreg (RLWINM [r] y)) + // cond: mergePPC64AndRlwinm(0xFF,r) != 0 + // result: (RLWINM [mergePPC64AndRlwinm(0xFF,r)] y) + for { + if v_0.Op != OpPPC64RLWINM { + break + } + r := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + if !(mergePPC64AndRlwinm(0xFF, r) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndRlwinm(0xFF, r)) + v.AddArg(y) + return true + } + // match: (MOVBZreg (OR x (MOVWZreg y))) + // result: (MOVBZreg (OR x y)) + for { + if v_0.Op != OpPPC64OR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVWZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVBZreg) + v0 := b.NewValue0(v.Pos, OpPPC64OR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVBZreg (XOR x (MOVWZreg y))) + // result: (MOVBZreg (XOR x y)) + for { + if v_0.Op != OpPPC64XOR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVWZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVBZreg) + v0 := b.NewValue0(v.Pos, OpPPC64XOR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVBZreg (AND x (MOVWZreg y))) + // result: (MOVBZreg (AND x y)) + for { + if v_0.Op != OpPPC64AND { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVWZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVBZreg) + v0 := b.NewValue0(v.Pos, OpPPC64AND, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVBZreg (OR x (MOVHZreg y))) + // result: (MOVBZreg (OR x y)) + for { + if v_0.Op != OpPPC64OR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVHZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVBZreg) + v0 := b.NewValue0(v.Pos, OpPPC64OR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVBZreg (XOR x (MOVHZreg y))) + // result: (MOVBZreg (XOR x y)) + for { + if v_0.Op != OpPPC64XOR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVHZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVBZreg) + v0 := b.NewValue0(v.Pos, OpPPC64XOR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVBZreg (AND x (MOVHZreg y))) + // result: (MOVBZreg (AND x y)) + for { + if v_0.Op != OpPPC64AND { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVHZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVBZreg) + v0 := b.NewValue0(v.Pos, OpPPC64AND, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVBZreg (OR x (MOVBZreg y))) + // result: (MOVBZreg (OR x y)) + for { + if v_0.Op != OpPPC64OR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVBZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVBZreg) + v0 := b.NewValue0(v.Pos, OpPPC64OR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVBZreg (XOR x (MOVBZreg y))) + // result: (MOVBZreg (XOR x y)) + for { + if v_0.Op != OpPPC64XOR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVBZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVBZreg) + v0 := b.NewValue0(v.Pos, OpPPC64XOR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVBZreg (AND x (MOVBZreg y))) + // result: (MOVBZreg (AND x y)) + for { + if v_0.Op != OpPPC64AND { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVBZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVBZreg) + v0 := b.NewValue0(v.Pos, OpPPC64AND, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVBZreg z:(ANDconst [c] (MOVBZload ptr x))) + // result: z + for { + z := v_0 + if z.Op != OpPPC64ANDconst { + break + } + z_0 := z.Args[0] + if z_0.Op != OpPPC64MOVBZload { + break + } + v.copyOf(z) + return true + } + // match: (MOVBZreg z:(AND y (MOVBZload ptr x))) + // result: z + for { + z := v_0 + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + if z_1.Op != OpPPC64MOVBZload { + continue + } + v.copyOf(z) + return true + } + break + } + // match: (MOVBZreg x:(MOVBZload _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVBZload { + break + } + v.copyOf(x) + return true + } + // match: (MOVBZreg x:(MOVBZloadidx _ _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVBZloadidx { + break + } + v.copyOf(x) + return true + } + // match: (MOVBZreg x:(Select0 (LoweredAtomicLoad8 _ _))) + // result: x + for { + x := v_0 + if x.Op != OpSelect0 { + break + } + x_0 := x.Args[0] + if x_0.Op != OpPPC64LoweredAtomicLoad8 { + break + } + v.copyOf(x) + return true + } + // match: (MOVBZreg x:(Arg )) + // cond: is8BitInt(t) && !t.IsSigned() + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !(is8BitInt(t) && !t.IsSigned()) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBZreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint8(c))]) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint8(c))) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVBreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVBreg y:(ANDconst [c] _)) + // cond: uint64(c) <= 0x7F + // result: y + for { + y := v_0 + if y.Op != OpPPC64ANDconst { + break + } + c := auxIntToInt64(y.AuxInt) + if !(uint64(c) <= 0x7F) { + break + } + v.copyOf(y) + return true + } + // match: (MOVBreg (SRAWconst [c] (MOVBreg x))) + // result: (SRAWconst [c] (MOVBreg x)) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVBreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVBreg (SRAWconst [c] x)) + // cond: x.Type.Size() == 8 + // result: (SRAWconst [c] x) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(x.Type.Size() == 8) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBreg (SRDconst [c] x)) + // cond: c>56 + // result: (SRDconst [c] x) + for { + if v_0.Op != OpPPC64SRDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c > 56) { + break + } + v.reset(OpPPC64SRDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBreg (SRDconst [c] x)) + // cond: c==56 + // result: (SRADconst [c] x) + for { + if v_0.Op != OpPPC64SRDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c == 56) { + break + } + v.reset(OpPPC64SRADconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBreg (SRADconst [c] x)) + // cond: c>=56 + // result: (SRADconst [c] x) + for { + if v_0.Op != OpPPC64SRADconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c >= 56) { + break + } + v.reset(OpPPC64SRADconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBreg (SRWconst [c] x)) + // cond: c>24 + // result: (SRWconst [c] x) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c > 24) { + break + } + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBreg (SRWconst [c] x)) + // cond: c==24 + // result: (SRAWconst [c] x) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c == 24) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBreg (SRAWconst [c] x)) + // cond: c>=24 + // result: (SRAWconst [c] x) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c >= 24) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVBreg y:(MOVBreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVBreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVBreg (MOVBZreg x)) + // result: (MOVBreg x) + for { + if v_0.Op != OpPPC64MOVBZreg { + break + } + x := v_0.Args[0] + v.reset(OpPPC64MOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(Arg )) + // cond: is8BitInt(t) && t.IsSigned() + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !(is8BitInt(t) && t.IsSigned()) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBreg (MOVDconst [c])) + // result: (MOVDconst [int64(int8(c))]) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int8(c))) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVBstore [off1] {sym} (ADDconst [off2] x) val mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (MOVBstore [off1+int32(off2)] {sym} x val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(x, val, mem) + return true + } + // match: (MOVBstore [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVDconst [0]) mem) + // result: (MOVBstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpPPC64MOVBstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstore [0] {sym} p:(ADD ptr idx) val mem) + // cond: sym == nil && p.Uses == 1 + // result: (MOVBstoreidx ptr idx val mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + idx := p.Args[1] + ptr := p.Args[0] + val := v_1 + mem := v_2 + if !(sym == nil && p.Uses == 1) { + break + } + v.reset(OpPPC64MOVBstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVBreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBZreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVBZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHZreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVHZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWZreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVWZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (SRWconst (MOVHreg x) [c]) mem) + // cond: c <= 8 + // result: (MOVBstore [off] {sym} ptr (SRWconst x [c]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpPPC64MOVHreg { + break + } + x := v_1_0.Args[0] + mem := v_2 + if !(c <= 8) { + break + } + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpPPC64SRWconst, typ.UInt32) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (SRWconst (MOVHZreg x) [c]) mem) + // cond: c <= 8 + // result: (MOVBstore [off] {sym} ptr (SRWconst x [c]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpPPC64MOVHZreg { + break + } + x := v_1_0.Args[0] + mem := v_2 + if !(c <= 8) { + break + } + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpPPC64SRWconst, typ.UInt32) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (SRWconst (MOVWreg x) [c]) mem) + // cond: c <= 24 + // result: (MOVBstore [off] {sym} ptr (SRWconst x [c]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpPPC64MOVWreg { + break + } + x := v_1_0.Args[0] + mem := v_2 + if !(c <= 24) { + break + } + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpPPC64SRWconst, typ.UInt32) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (SRWconst (MOVWZreg x) [c]) mem) + // cond: c <= 24 + // result: (MOVBstore [off] {sym} ptr (SRWconst x [c]) mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpPPC64MOVWZreg { + break + } + x := v_1_0.Args[0] + mem := v_2 + if !(c <= 24) { + break + } + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpPPC64SRWconst, typ.UInt32) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(x) + v.AddArg3(ptr, v0, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVBstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVBstoreidx ptr (MOVDconst [c]) val mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVBstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstoreidx (MOVDconst [c]) ptr val mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVBstore [int32(c)] ptr val mem) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + val := v_2 + mem := v_3 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVBstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVBreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVBreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVBZreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVBZreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVHreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVHreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVHZreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVHZreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVWreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVWreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (MOVWZreg x) mem) + // result: (MOVBstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVWZreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVBstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVBstoreidx ptr idx (SRWconst (MOVHreg x) [c]) mem) + // cond: c <= 8 + // result: (MOVBstoreidx ptr idx (SRWconst x [c]) mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64MOVHreg { + break + } + x := v_2_0.Args[0] + mem := v_3 + if !(c <= 8) { + break + } + v.reset(OpPPC64MOVBstoreidx) + v0 := b.NewValue0(v.Pos, OpPPC64SRWconst, typ.UInt32) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(x) + v.AddArg4(ptr, idx, v0, mem) + return true + } + // match: (MOVBstoreidx ptr idx (SRWconst (MOVHZreg x) [c]) mem) + // cond: c <= 8 + // result: (MOVBstoreidx ptr idx (SRWconst x [c]) mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64MOVHZreg { + break + } + x := v_2_0.Args[0] + mem := v_3 + if !(c <= 8) { + break + } + v.reset(OpPPC64MOVBstoreidx) + v0 := b.NewValue0(v.Pos, OpPPC64SRWconst, typ.UInt32) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(x) + v.AddArg4(ptr, idx, v0, mem) + return true + } + // match: (MOVBstoreidx ptr idx (SRWconst (MOVWreg x) [c]) mem) + // cond: c <= 24 + // result: (MOVBstoreidx ptr idx (SRWconst x [c]) mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64MOVWreg { + break + } + x := v_2_0.Args[0] + mem := v_3 + if !(c <= 24) { + break + } + v.reset(OpPPC64MOVBstoreidx) + v0 := b.NewValue0(v.Pos, OpPPC64SRWconst, typ.UInt32) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(x) + v.AddArg4(ptr, idx, v0, mem) + return true + } + // match: (MOVBstoreidx ptr idx (SRWconst (MOVWZreg x) [c]) mem) + // cond: c <= 24 + // result: (MOVBstoreidx ptr idx (SRWconst x [c]) mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_2.AuxInt) + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64MOVWZreg { + break + } + x := v_2_0.Args[0] + mem := v_3 + if !(c <= 24) { + break + } + v.reset(OpPPC64MOVBstoreidx) + v0 := b.NewValue0(v.Pos, OpPPC64SRWconst, typ.UInt32) + v0.AuxInt = int64ToAuxInt(c) + v0.AddArg(x) + v.AddArg4(ptr, idx, v0, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVBstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstorezero [off1] {sym} (ADDconst [off2] x) mem) + // cond: ((supportsPPC64PCRel() && is32Bit(int64(off1)+off2)) || (is16Bit(int64(off1)+off2))) + // result: (MOVBstorezero [off1+int32(off2)] {sym} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + mem := v_1 + if !((supportsPPC64PCRel() && is32Bit(int64(off1)+off2)) || (is16Bit(int64(off1) + off2))) { + break + } + v.reset(OpPPC64MOVBstorezero) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(x, mem) + return true + } + // match: (MOVBstorezero [off1] {sym1} p:(MOVDaddr [off2] {sym2} x) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (x.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVBstorezero [off1+off2] {mergeSym(sym1,sym2)} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + x := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (x.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVBstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVDaddr(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVDaddr {sym} [n] p:(ADD x y)) + // cond: sym == nil && n == 0 + // result: p + for { + n := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + if !(sym == nil && n == 0) { + break + } + v.copyOf(p) + return true + } + // match: (MOVDaddr {sym} [n] ptr) + // cond: sym == nil && n == 0 && (ptr.Op == OpArgIntReg || ptr.Op == OpPhi) + // result: ptr + for { + n := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if !(sym == nil && n == 0 && (ptr.Op == OpArgIntReg || ptr.Op == OpPhi)) { + break + } + v.copyOf(ptr) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDload [off] {sym} ptr (FMOVDstore [off] {sym} ptr x _)) + // result: (MFVSRD x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64FMOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + if ptr != v_1.Args[0] { + break + } + v.reset(OpPPC64MFVSRD) + v.AddArg(x) + return true + } + // match: (MOVDload [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off1] {sym} (ADDconst [off2] x) mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (MOVDload [off1+int32(off2)] {sym} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + mem := v_1 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64MOVDload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(x, mem) + return true + } + // match: (MOVDload [0] {sym} p:(ADD ptr idx) mem) + // cond: sym == nil && p.Uses == 1 + // result: (MOVDloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + idx := p.Args[1] + ptr := p.Args[0] + mem := v_1 + if !(sym == nil && p.Uses == 1) { + break + } + v.reset(OpPPC64MOVDloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVDloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDloadidx ptr (MOVDconst [c]) mem) + // cond: ((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVDload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVDload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDloadidx (MOVDconst [c]) ptr mem) + // cond: ((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVDload [int32(c)] ptr mem) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVDload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MOVDstore [off] {sym} ptr (MFVSRD x) mem) + // result: (FMOVDstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MFVSRD { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64FMOVDstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVDstore [off1] {sym} (ADDconst [off2] x) val mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (MOVDstore [off1+int32(off2)] {sym} x val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64MOVDstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(x, val, mem) + return true + } + // match: (MOVDstore [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off] {sym} ptr (MOVDconst [0]) mem) + // result: (MOVDstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpPPC64MOVDstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDstore [0] {sym} p:(ADD ptr idx) val mem) + // cond: sym == nil && p.Uses == 1 + // result: (MOVDstoreidx ptr idx val mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + idx := p.Args[1] + ptr := p.Args[0] + val := v_1 + mem := v_2 + if !(sym == nil && p.Uses == 1) { + break + } + v.reset(OpPPC64MOVDstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVDstore [off] {sym} ptr r:(BRD val) mem) + // cond: r.Uses == 1 + // result: (MOVDBRstore (MOVDaddr [off] {sym} ptr) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + r := v_1 + if r.Op != OpPPC64BRD { + break + } + val := r.Args[0] + mem := v_2 + if !(r.Uses == 1) { + break + } + v.reset(OpPPC64MOVDBRstore) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDaddr, ptr.Type) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg(ptr) + v.AddArg3(v0, val, mem) + return true + } + // match: (MOVDstore [off] {sym} ptr (Bswap64 val) mem) + // result: (MOVDBRstore (MOVDaddr [off] {sym} ptr) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpBswap64 { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVDBRstore) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDaddr, ptr.Type) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg(ptr) + v.AddArg3(v0, val, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVDstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDstoreidx ptr (MOVDconst [c]) val mem) + // cond: ((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVDstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVDstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstoreidx (MOVDconst [c]) ptr val mem) + // cond: ((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVDstore [int32(c)] ptr val mem) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + val := v_2 + mem := v_3 + if !((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVDstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstoreidx ptr idx r:(BRD val) mem) + // cond: r.Uses == 1 + // result: (MOVDBRstoreidx ptr idx val mem) + for { + ptr := v_0 + idx := v_1 + r := v_2 + if r.Op != OpPPC64BRD { + break + } + val := r.Args[0] + mem := v_3 + if !(r.Uses == 1) { + break + } + v.reset(OpPPC64MOVDBRstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVDstoreidx ptr idx (Bswap64 val) mem) + // result: (MOVDBRstoreidx ptr idx val mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpBswap64 { + break + } + val := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVDBRstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVDstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDstorezero [off1] {sym} (ADDconst [off2] x) mem) + // cond: ((supportsPPC64PCRel() && is32Bit(int64(off1)+off2)) || (is16Bit(int64(off1)+off2))) + // result: (MOVDstorezero [off1+int32(off2)] {sym} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + mem := v_1 + if !((supportsPPC64PCRel() && is32Bit(int64(off1)+off2)) || (is16Bit(int64(off1) + off2))) { + break + } + v.reset(OpPPC64MOVDstorezero) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(x, mem) + return true + } + // match: (MOVDstorezero [off1] {sym1} p:(MOVDaddr [off2] {sym2} x) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (x.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVDstorezero [off1+off2] {mergeSym(sym1,sym2)} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + x := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (x.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVDstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVHBRstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHBRstore ptr (MOVHreg x) mem) + // result: (MOVHBRstore ptr x mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVHBRstore) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHBRstore ptr (MOVHZreg x) mem) + // result: (MOVHBRstore ptr x mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVHZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVHBRstore) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHBRstore ptr (MOVWreg x) mem) + // result: (MOVHBRstore ptr x mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVHBRstore) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHBRstore ptr (MOVWZreg x) mem) + // result: (MOVHBRstore ptr x mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVWZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVHBRstore) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVHZload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHZload [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVHZload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVHZload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHZload [off1] {sym} (ADDconst [off2] x) mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (MOVHZload [off1+int32(off2)] {sym} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + mem := v_1 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64MOVHZload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(x, mem) + return true + } + // match: (MOVHZload [0] {sym} p:(ADD ptr idx) mem) + // cond: sym == nil && p.Uses == 1 + // result: (MOVHZloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + idx := p.Args[1] + ptr := p.Args[0] + mem := v_1 + if !(sym == nil && p.Uses == 1) { + break + } + v.reset(OpPPC64MOVHZloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVHZloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHZloadidx ptr (MOVDconst [c]) mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVHZload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVHZload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHZloadidx (MOVDconst [c]) ptr mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVHZload [int32(c)] ptr mem) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVHZload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVHZreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVHZreg y:(ANDconst [c] _)) + // cond: uint64(c) <= 0xFFFF + // result: y + for { + y := v_0 + if y.Op != OpPPC64ANDconst { + break + } + c := auxIntToInt64(y.AuxInt) + if !(uint64(c) <= 0xFFFF) { + break + } + v.copyOf(y) + return true + } + // match: (MOVHZreg (SRWconst [c] (MOVBZreg x))) + // result: (SRWconst [c] (MOVBZreg x)) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVBZreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVHZreg (SRWconst [c] (MOVHZreg x))) + // result: (SRWconst [c] (MOVHZreg x)) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVHZreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVHZreg (SRWconst [c] x)) + // cond: x.Type.Size() <= 16 + // result: (SRWconst [c] x) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(x.Type.Size() <= 16) { + break + } + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHZreg (SRDconst [c] x)) + // cond: c>=48 + // result: (SRDconst [c] x) + for { + if v_0.Op != OpPPC64SRDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c >= 48) { + break + } + v.reset(OpPPC64SRDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHZreg (SRWconst [c] x)) + // cond: c>=16 + // result: (SRWconst [c] x) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c >= 16) { + break + } + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHZreg (RLWINM [r] y)) + // cond: mergePPC64AndRlwinm(0xFFFF,r) != 0 + // result: (RLWINM [mergePPC64AndRlwinm(0xFFFF,r)] y) + for { + if v_0.Op != OpPPC64RLWINM { + break + } + r := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + if !(mergePPC64AndRlwinm(0xFFFF, r) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndRlwinm(0xFFFF, r)) + v.AddArg(y) + return true + } + // match: (MOVHZreg y:(MOVHZreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVHZreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVHZreg y:(MOVBZreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVBZreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVHZreg y:(MOVHBRload _ _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVHBRload { + break + } + v.copyOf(y) + return true + } + // match: (MOVHZreg y:(MOVHreg x)) + // result: (MOVHZreg x) + for { + y := v_0 + if y.Op != OpPPC64MOVHreg { + break + } + x := y.Args[0] + v.reset(OpPPC64MOVHZreg) + v.AddArg(x) + return true + } + // match: (MOVHZreg (OR x (MOVWZreg y))) + // result: (MOVHZreg (OR x y)) + for { + if v_0.Op != OpPPC64OR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVWZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVHZreg) + v0 := b.NewValue0(v.Pos, OpPPC64OR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVHZreg (XOR x (MOVWZreg y))) + // result: (MOVHZreg (XOR x y)) + for { + if v_0.Op != OpPPC64XOR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVWZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVHZreg) + v0 := b.NewValue0(v.Pos, OpPPC64XOR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVHZreg (AND x (MOVWZreg y))) + // result: (MOVHZreg (AND x y)) + for { + if v_0.Op != OpPPC64AND { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVWZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVHZreg) + v0 := b.NewValue0(v.Pos, OpPPC64AND, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVHZreg (OR x (MOVHZreg y))) + // result: (MOVHZreg (OR x y)) + for { + if v_0.Op != OpPPC64OR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVHZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVHZreg) + v0 := b.NewValue0(v.Pos, OpPPC64OR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVHZreg (XOR x (MOVHZreg y))) + // result: (MOVHZreg (XOR x y)) + for { + if v_0.Op != OpPPC64XOR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVHZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVHZreg) + v0 := b.NewValue0(v.Pos, OpPPC64XOR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVHZreg (AND x (MOVHZreg y))) + // result: (MOVHZreg (AND x y)) + for { + if v_0.Op != OpPPC64AND { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVHZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVHZreg) + v0 := b.NewValue0(v.Pos, OpPPC64AND, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVHZreg z:(ANDconst [c] (MOVBZload ptr x))) + // result: z + for { + z := v_0 + if z.Op != OpPPC64ANDconst { + break + } + z_0 := z.Args[0] + if z_0.Op != OpPPC64MOVBZload { + break + } + v.copyOf(z) + return true + } + // match: (MOVHZreg z:(AND y (MOVHZload ptr x))) + // result: z + for { + z := v_0 + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + if z_1.Op != OpPPC64MOVHZload { + continue + } + v.copyOf(z) + return true + } + break + } + // match: (MOVHZreg z:(ANDconst [c] (MOVHZload ptr x))) + // result: z + for { + z := v_0 + if z.Op != OpPPC64ANDconst { + break + } + z_0 := z.Args[0] + if z_0.Op != OpPPC64MOVHZload { + break + } + v.copyOf(z) + return true + } + // match: (MOVHZreg x:(MOVBZload _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVBZload { + break + } + v.copyOf(x) + return true + } + // match: (MOVHZreg x:(MOVBZloadidx _ _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVBZloadidx { + break + } + v.copyOf(x) + return true + } + // match: (MOVHZreg x:(MOVHZload _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVHZload { + break + } + v.copyOf(x) + return true + } + // match: (MOVHZreg x:(MOVHZloadidx _ _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVHZloadidx { + break + } + v.copyOf(x) + return true + } + // match: (MOVHZreg x:(Arg )) + // cond: (is8BitInt(t) || is16BitInt(t)) && !t.IsSigned() + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !((is8BitInt(t) || is16BitInt(t)) && !t.IsSigned()) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHZreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint16(c))]) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint16(c))) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVHload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHload [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVHload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVHload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off1] {sym} (ADDconst [off2] x) mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (MOVHload [off1+int32(off2)] {sym} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + mem := v_1 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64MOVHload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(x, mem) + return true + } + // match: (MOVHload [0] {sym} p:(ADD ptr idx) mem) + // cond: sym == nil && p.Uses == 1 + // result: (MOVHloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + idx := p.Args[1] + ptr := p.Args[0] + mem := v_1 + if !(sym == nil && p.Uses == 1) { + break + } + v.reset(OpPPC64MOVHloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVHloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHloadidx ptr (MOVDconst [c]) mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVHload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVHload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHloadidx (MOVDconst [c]) ptr mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVHload [int32(c)] ptr mem) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVHload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVHreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVHreg y:(ANDconst [c] _)) + // cond: uint64(c) <= 0x7FFF + // result: y + for { + y := v_0 + if y.Op != OpPPC64ANDconst { + break + } + c := auxIntToInt64(y.AuxInt) + if !(uint64(c) <= 0x7FFF) { + break + } + v.copyOf(y) + return true + } + // match: (MOVHreg (SRAWconst [c] (MOVBreg x))) + // result: (SRAWconst [c] (MOVBreg x)) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVBreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVHreg (SRAWconst [c] (MOVHreg x))) + // result: (SRAWconst [c] (MOVHreg x)) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVHreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVHreg (SRAWconst [c] x)) + // cond: x.Type.Size() <= 16 + // result: (SRAWconst [c] x) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(x.Type.Size() <= 16) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHreg (SRDconst [c] x)) + // cond: c>48 + // result: (SRDconst [c] x) + for { + if v_0.Op != OpPPC64SRDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c > 48) { + break + } + v.reset(OpPPC64SRDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHreg (SRDconst [c] x)) + // cond: c==48 + // result: (SRADconst [c] x) + for { + if v_0.Op != OpPPC64SRDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c == 48) { + break + } + v.reset(OpPPC64SRADconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHreg (SRADconst [c] x)) + // cond: c>=48 + // result: (SRADconst [c] x) + for { + if v_0.Op != OpPPC64SRADconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c >= 48) { + break + } + v.reset(OpPPC64SRADconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHreg (SRWconst [c] x)) + // cond: c>16 + // result: (SRWconst [c] x) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c > 16) { + break + } + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHreg (SRAWconst [c] x)) + // cond: c>=16 + // result: (SRAWconst [c] x) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c >= 16) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHreg (SRWconst [c] x)) + // cond: c==16 + // result: (SRAWconst [c] x) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c == 16) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVHreg y:(MOVHreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVHreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVHreg y:(MOVBreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVBreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVHreg y:(MOVHZreg x)) + // result: (MOVHreg x) + for { + y := v_0 + if y.Op != OpPPC64MOVHZreg { + break + } + x := y.Args[0] + v.reset(OpPPC64MOVHreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHload _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVHload { + break + } + v.copyOf(x) + return true + } + // match: (MOVHreg x:(MOVHloadidx _ _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVHloadidx { + break + } + v.copyOf(x) + return true + } + // match: (MOVHreg x:(Arg )) + // cond: (is8BitInt(t) || is16BitInt(t)) && t.IsSigned() + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !((is8BitInt(t) || is16BitInt(t)) && t.IsSigned()) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHreg (MOVDconst [c])) + // result: (MOVDconst [int64(int16(c))]) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int16(c))) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVHstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MOVHstore [off1] {sym} (ADDconst [off2] x) val mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (MOVHstore [off1+int32(off2)] {sym} x val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64MOVHstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(x, val, mem) + return true + } + // match: (MOVHstore [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVHstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVHstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVDconst [0]) mem) + // result: (MOVHstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpPPC64MOVHstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHstore [0] {sym} p:(ADD ptr idx) val mem) + // cond: sym == nil && p.Uses == 1 + // result: (MOVHstoreidx ptr idx val mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + idx := p.Args[1] + ptr := p.Args[0] + val := v_1 + mem := v_2 + if !(sym == nil && p.Uses == 1) { + break + } + v.reset(OpPPC64MOVHstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHZreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVHZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWZreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVWZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr r:(BRH val) mem) + // cond: r.Uses == 1 + // result: (MOVHBRstore (MOVDaddr [off] {sym} ptr) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + r := v_1 + if r.Op != OpPPC64BRH { + break + } + val := r.Args[0] + mem := v_2 + if !(r.Uses == 1) { + break + } + v.reset(OpPPC64MOVHBRstore) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDaddr, ptr.Type) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg(ptr) + v.AddArg3(v0, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (Bswap16 val) mem) + // result: (MOVHBRstore (MOVDaddr [off] {sym} ptr) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpBswap16 { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVHBRstore) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDaddr, ptr.Type) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg(ptr) + v.AddArg3(v0, val, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVHstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstoreidx ptr (MOVDconst [c]) val mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVHstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVHstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstoreidx (MOVDconst [c]) ptr val mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVHstore [int32(c)] ptr val mem) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + val := v_2 + mem := v_3 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVHstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstoreidx ptr idx (MOVHreg x) mem) + // result: (MOVHstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVHreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVHstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVHstoreidx ptr idx (MOVHZreg x) mem) + // result: (MOVHstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVHZreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVHstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVHstoreidx ptr idx (MOVWreg x) mem) + // result: (MOVHstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVWreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVHstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVHstoreidx ptr idx (MOVWZreg x) mem) + // result: (MOVHstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVWZreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVHstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVHstoreidx ptr idx r:(BRH val) mem) + // cond: r.Uses == 1 + // result: (MOVHBRstoreidx ptr idx val mem) + for { + ptr := v_0 + idx := v_1 + r := v_2 + if r.Op != OpPPC64BRH { + break + } + val := r.Args[0] + mem := v_3 + if !(r.Uses == 1) { + break + } + v.reset(OpPPC64MOVHBRstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVHstoreidx ptr idx (Bswap16 val) mem) + // result: (MOVHBRstoreidx ptr idx val mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpBswap16 { + break + } + val := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVHBRstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVHstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstorezero [off1] {sym} (ADDconst [off2] x) mem) + // cond: ((supportsPPC64PCRel() && is32Bit(int64(off1)+off2)) || (is16Bit(int64(off1)+off2))) + // result: (MOVHstorezero [off1+int32(off2)] {sym} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + mem := v_1 + if !((supportsPPC64PCRel() && is32Bit(int64(off1)+off2)) || (is16Bit(int64(off1) + off2))) { + break + } + v.reset(OpPPC64MOVHstorezero) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(x, mem) + return true + } + // match: (MOVHstorezero [off1] {sym1} p:(MOVDaddr [off2] {sym2} x) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (x.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVHstorezero [off1+off2] {mergeSym(sym1,sym2)} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + x := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (x.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVHstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVWBRstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWBRstore ptr (MOVWreg x) mem) + // result: (MOVWBRstore ptr x mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVWBRstore) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWBRstore ptr (MOVWZreg x) mem) + // result: (MOVWBRstore ptr x mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVWZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVWBRstore) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVWZload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWZload [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVWZload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVWZload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWZload [off1] {sym} (ADDconst [off2] x) mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (MOVWZload [off1+int32(off2)] {sym} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + mem := v_1 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64MOVWZload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(x, mem) + return true + } + // match: (MOVWZload [0] {sym} p:(ADD ptr idx) mem) + // cond: sym == nil && p.Uses == 1 + // result: (MOVWZloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + idx := p.Args[1] + ptr := p.Args[0] + mem := v_1 + if !(sym == nil && p.Uses == 1) { + break + } + v.reset(OpPPC64MOVWZloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVWZloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWZloadidx ptr (MOVDconst [c]) mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVWZload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVWZload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWZloadidx (MOVDconst [c]) ptr mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVWZload [int32(c)] ptr mem) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVWZload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVWZreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVWZreg y:(ANDconst [c] _)) + // cond: uint64(c) <= 0xFFFFFFFF + // result: y + for { + y := v_0 + if y.Op != OpPPC64ANDconst { + break + } + c := auxIntToInt64(y.AuxInt) + if !(uint64(c) <= 0xFFFFFFFF) { + break + } + v.copyOf(y) + return true + } + // match: (MOVWZreg y:(AND (MOVDconst [c]) _)) + // cond: uint64(c) <= 0xFFFFFFFF + // result: y + for { + y := v_0 + if y.Op != OpPPC64AND { + break + } + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + if y_0.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(y_0.AuxInt) + if !(uint64(c) <= 0xFFFFFFFF) { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (MOVWZreg (SRWconst [c] (MOVBZreg x))) + // result: (SRWconst [c] (MOVBZreg x)) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVBZreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVWZreg (SRWconst [c] (MOVHZreg x))) + // result: (SRWconst [c] (MOVHZreg x)) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVHZreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVWZreg (SRWconst [c] (MOVWZreg x))) + // result: (SRWconst [c] (MOVWZreg x)) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVWZreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVWZreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVWZreg (SRWconst [c] x)) + // cond: x.Type.Size() <= 32 + // result: (SRWconst [c] x) + for { + if v_0.Op != OpPPC64SRWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(x.Type.Size() <= 32) { + break + } + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVWZreg (SRDconst [c] x)) + // cond: c>=32 + // result: (SRDconst [c] x) + for { + if v_0.Op != OpPPC64SRDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c >= 32) { + break + } + v.reset(OpPPC64SRDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVWZreg (RLWINM [r] y)) + // cond: mergePPC64MovwzregRlwinm(r) != 0 + // result: (RLWINM [mergePPC64MovwzregRlwinm(r)] y) + for { + if v_0.Op != OpPPC64RLWINM { + break + } + r := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + if !(mergePPC64MovwzregRlwinm(r) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64MovwzregRlwinm(r)) + v.AddArg(y) + return true + } + // match: (MOVWZreg w:(SLWconst u)) + // result: w + for { + w := v_0 + if w.Op != OpPPC64SLWconst { + break + } + v.copyOf(w) + return true + } + // match: (MOVWZreg y:(MOVWZreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVWZreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVWZreg y:(MOVHZreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVHZreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVWZreg y:(MOVBZreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVBZreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVWZreg y:(MOVHBRload _ _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVHBRload { + break + } + v.copyOf(y) + return true + } + // match: (MOVWZreg y:(MOVWBRload _ _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVWBRload { + break + } + v.copyOf(y) + return true + } + // match: (MOVWZreg y:(MOVWreg x)) + // result: (MOVWZreg x) + for { + y := v_0 + if y.Op != OpPPC64MOVWreg { + break + } + x := y.Args[0] + v.reset(OpPPC64MOVWZreg) + v.AddArg(x) + return true + } + // match: (MOVWZreg (OR x (MOVWZreg y))) + // result: (MOVWZreg (OR x y)) + for { + if v_0.Op != OpPPC64OR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVWZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVWZreg) + v0 := b.NewValue0(v.Pos, OpPPC64OR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVWZreg (XOR x (MOVWZreg y))) + // result: (MOVWZreg (XOR x y)) + for { + if v_0.Op != OpPPC64XOR { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVWZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVWZreg) + v0 := b.NewValue0(v.Pos, OpPPC64XOR, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVWZreg (AND x (MOVWZreg y))) + // result: (MOVWZreg (AND x y)) + for { + if v_0.Op != OpPPC64AND { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpPPC64MOVWZreg { + continue + } + y := v_0_1.Args[0] + v.reset(OpPPC64MOVWZreg) + v0 := b.NewValue0(v.Pos, OpPPC64AND, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (MOVWZreg z:(ANDconst [c] (MOVBZload ptr x))) + // result: z + for { + z := v_0 + if z.Op != OpPPC64ANDconst { + break + } + z_0 := z.Args[0] + if z_0.Op != OpPPC64MOVBZload { + break + } + v.copyOf(z) + return true + } + // match: (MOVWZreg z:(AND y (MOVWZload ptr x))) + // result: z + for { + z := v_0 + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + if z_1.Op != OpPPC64MOVWZload { + continue + } + v.copyOf(z) + return true + } + break + } + // match: (MOVWZreg z:(ANDconst [c] (MOVHZload ptr x))) + // result: z + for { + z := v_0 + if z.Op != OpPPC64ANDconst { + break + } + z_0 := z.Args[0] + if z_0.Op != OpPPC64MOVHZload { + break + } + v.copyOf(z) + return true + } + // match: (MOVWZreg z:(ANDconst [c] (MOVWZload ptr x))) + // result: z + for { + z := v_0 + if z.Op != OpPPC64ANDconst { + break + } + z_0 := z.Args[0] + if z_0.Op != OpPPC64MOVWZload { + break + } + v.copyOf(z) + return true + } + // match: (MOVWZreg x:(MOVBZload _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVBZload { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg x:(MOVBZloadidx _ _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVBZloadidx { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg x:(MOVHZload _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVHZload { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg x:(MOVHZloadidx _ _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVHZloadidx { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg x:(MOVWZload _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVWZload { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg x:(MOVWZloadidx _ _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVWZloadidx { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg x:(Select0 (LoweredAtomicLoad32 _ _))) + // result: x + for { + x := v_0 + if x.Op != OpSelect0 { + break + } + x_0 := x.Args[0] + if x_0.Op != OpPPC64LoweredAtomicLoad32 { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg x:(Arg )) + // cond: (is8BitInt(t) || is16BitInt(t) || is32BitInt(t)) && !t.IsSigned() + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !((is8BitInt(t) || is16BitInt(t) || is32BitInt(t)) && !t.IsSigned()) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint32(c))]) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint32(c))) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWload [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVWload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off1] {sym} (ADDconst [off2] x) mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (MOVWload [off1+int32(off2)] {sym} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + mem := v_1 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(x, mem) + return true + } + // match: (MOVWload [0] {sym} p:(ADD ptr idx) mem) + // cond: sym == nil && p.Uses == 1 + // result: (MOVWloadidx ptr idx mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + idx := p.Args[1] + ptr := p.Args[0] + mem := v_1 + if !(sym == nil && p.Uses == 1) { + break + } + v.reset(OpPPC64MOVWloadidx) + v.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVWloadidx(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWloadidx ptr (MOVDconst [c]) mem) + // cond: ((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVWload [int32(c)] ptr mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVWload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWloadidx (MOVDconst [c]) ptr mem) + // cond: ((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVWload [int32(c)] ptr mem) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + mem := v_2 + if !((is16Bit(c) && c%4 == 0) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVWload) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVWreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVWreg y:(ANDconst [c] _)) + // cond: uint64(c) <= 0xFFFF + // result: y + for { + y := v_0 + if y.Op != OpPPC64ANDconst { + break + } + c := auxIntToInt64(y.AuxInt) + if !(uint64(c) <= 0xFFFF) { + break + } + v.copyOf(y) + return true + } + // match: (MOVWreg y:(AND (MOVDconst [c]) _)) + // cond: uint64(c) <= 0x7FFFFFFF + // result: y + for { + y := v_0 + if y.Op != OpPPC64AND { + break + } + y_0 := y.Args[0] + y_1 := y.Args[1] + for _i0 := 0; _i0 <= 1; _i0, y_0, y_1 = _i0+1, y_1, y_0 { + if y_0.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(y_0.AuxInt) + if !(uint64(c) <= 0x7FFFFFFF) { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (MOVWreg (SRAWconst [c] (MOVBreg x))) + // result: (SRAWconst [c] (MOVBreg x)) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVBreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVWreg (SRAWconst [c] (MOVHreg x))) + // result: (SRAWconst [c] (MOVHreg x)) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVHreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVWreg (SRAWconst [c] (MOVWreg x))) + // result: (SRAWconst [c] (MOVWreg x)) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64MOVWreg { + break + } + x := v_0_0.Args[0] + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpPPC64MOVWreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (MOVWreg (SRAWconst [c] x)) + // cond: x.Type.Size() <= 32 + // result: (SRAWconst [c] x) + for { + if v_0.Op != OpPPC64SRAWconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(x.Type.Size() <= 32) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVWreg (SRDconst [c] x)) + // cond: c>32 + // result: (SRDconst [c] x) + for { + if v_0.Op != OpPPC64SRDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c > 32) { + break + } + v.reset(OpPPC64SRDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVWreg (SRADconst [c] x)) + // cond: c>=32 + // result: (SRADconst [c] x) + for { + if v_0.Op != OpPPC64SRADconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c >= 32) { + break + } + v.reset(OpPPC64SRADconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVWreg (SRDconst [c] x)) + // cond: c==32 + // result: (SRADconst [c] x) + for { + if v_0.Op != OpPPC64SRDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c == 32) { + break + } + v.reset(OpPPC64SRADconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (MOVWreg y:(MOVWreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVWreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVWreg y:(MOVHreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVHreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVWreg y:(MOVBreg _)) + // result: y + for { + y := v_0 + if y.Op != OpPPC64MOVBreg { + break + } + v.copyOf(y) + return true + } + // match: (MOVWreg y:(MOVWZreg x)) + // result: (MOVWreg x) + for { + y := v_0 + if y.Op != OpPPC64MOVWZreg { + break + } + x := y.Args[0] + v.reset(OpPPC64MOVWreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHload _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVHload { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg x:(MOVHloadidx _ _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVHloadidx { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg x:(MOVWload _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVWload { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg x:(MOVWloadidx _ _ _)) + // result: x + for { + x := v_0 + if x.Op != OpPPC64MOVWloadidx { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg x:(Arg )) + // cond: (is8BitInt(t) || is16BitInt(t) || is32BitInt(t)) && t.IsSigned() + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !((is8BitInt(t) || is16BitInt(t) || is32BitInt(t)) && t.IsSigned()) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg (MOVDconst [c])) + // result: (MOVDconst [int64(int32(c))]) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int32(c))) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MOVWstore [off1] {sym} (ADDconst [off2] x) val mem) + // cond: (is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) + // result: (MOVWstore [off1+int32(off2)] {sym} x val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is16Bit(int64(off1)+off2) || (supportsPPC64PCRel() && is32Bit(int64(off1)+off2))) { + break + } + v.reset(OpPPC64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(x, val, mem) + return true + } + // match: (MOVWstore [off1] {sym1} p:(MOVDaddr [off2] {sym2} ptr) val mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + ptr := p.Args[0] + val := v_1 + mem := v_2 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (ptr.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVDconst [0]) mem) + // result: (MOVWstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpPPC64MOVWstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstore [0] {sym} p:(ADD ptr idx) val mem) + // cond: sym == nil && p.Uses == 1 + // result: (MOVWstoreidx ptr idx val mem) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + sym := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64ADD { + break + } + idx := p.Args[1] + ptr := p.Args[0] + val := v_1 + mem := v_2 + if !(sym == nil && p.Uses == 1) { + break + } + v.reset(OpPPC64MOVWstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWZreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpPPC64MOVWZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr r:(BRW val) mem) + // cond: r.Uses == 1 + // result: (MOVWBRstore (MOVDaddr [off] {sym} ptr) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + r := v_1 + if r.Op != OpPPC64BRW { + break + } + val := r.Args[0] + mem := v_2 + if !(r.Uses == 1) { + break + } + v.reset(OpPPC64MOVWBRstore) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDaddr, ptr.Type) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg(ptr) + v.AddArg3(v0, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (Bswap32 val) mem) + // result: (MOVWBRstore (MOVDaddr [off] {sym} ptr) val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpBswap32 { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpPPC64MOVWBRstore) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDaddr, ptr.Type) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg(ptr) + v.AddArg3(v0, val, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVWstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstoreidx ptr (MOVDconst [c]) val mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVWstore [int32(c)] ptr val mem) + for { + ptr := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + val := v_2 + mem := v_3 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVWstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstoreidx (MOVDconst [c]) ptr val mem) + // cond: (is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) + // result: (MOVWstore [int32(c)] ptr val mem) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + ptr := v_1 + val := v_2 + mem := v_3 + if !(is16Bit(c) || (buildcfg.GOPPC64 >= 10 && is32Bit(c))) { + break + } + v.reset(OpPPC64MOVWstore) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstoreidx ptr idx (MOVWreg x) mem) + // result: (MOVWstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVWreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVWstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVWstoreidx ptr idx (MOVWZreg x) mem) + // result: (MOVWstoreidx ptr idx x mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpPPC64MOVWZreg { + break + } + x := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVWstoreidx) + v.AddArg4(ptr, idx, x, mem) + return true + } + // match: (MOVWstoreidx ptr idx r:(BRW val) mem) + // cond: r.Uses == 1 + // result: (MOVWBRstoreidx ptr idx val mem) + for { + ptr := v_0 + idx := v_1 + r := v_2 + if r.Op != OpPPC64BRW { + break + } + val := r.Args[0] + mem := v_3 + if !(r.Uses == 1) { + break + } + v.reset(OpPPC64MOVWBRstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + // match: (MOVWstoreidx ptr idx (Bswap32 val) mem) + // result: (MOVWBRstoreidx ptr idx val mem) + for { + ptr := v_0 + idx := v_1 + if v_2.Op != OpBswap32 { + break + } + val := v_2.Args[0] + mem := v_3 + v.reset(OpPPC64MOVWBRstoreidx) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MOVWstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstorezero [off1] {sym} (ADDconst [off2] x) mem) + // cond: ((supportsPPC64PCRel() && is32Bit(int64(off1)+off2)) || (is16Bit(int64(off1)+off2))) + // result: (MOVWstorezero [off1+int32(off2)] {sym} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpPPC64ADDconst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + mem := v_1 + if !((supportsPPC64PCRel() && is32Bit(int64(off1)+off2)) || (is16Bit(int64(off1) + off2))) { + break + } + v.reset(OpPPC64MOVWstorezero) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(x, mem) + return true + } + // match: (MOVWstorezero [off1] {sym1} p:(MOVDaddr [off2] {sym2} x) mem) + // cond: canMergeSym(sym1,sym2) && ((is16Bit(int64(off1+off2)) && (x.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2)))) + // result: (MOVWstorezero [off1+off2] {mergeSym(sym1,sym2)} x mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + p := v_0 + if p.Op != OpPPC64MOVDaddr { + break + } + off2 := auxIntToInt32(p.AuxInt) + sym2 := auxToSym(p.Aux) + x := p.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && ((is16Bit(int64(off1+off2)) && (x.Op != OpSB || p.Uses == 1)) || (supportsPPC64PCRel() && is32Bit(int64(off1+off2))))) { + break + } + v.reset(OpPPC64MOVWstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MTVSRD(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MTVSRD (MOVDconst [c])) + // cond: !math.IsNaN(math.Float64frombits(uint64(c))) + // result: (FMOVDconst [math.Float64frombits(uint64(c))]) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if !(!math.IsNaN(math.Float64frombits(uint64(c)))) { + break + } + v.reset(OpPPC64FMOVDconst) + v.AuxInt = float64ToAuxInt(math.Float64frombits(uint64(c))) + return true + } + // match: (MTVSRD x:(MOVDload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (FMOVDload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpPPC64MOVDload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpPPC64FMOVDload, typ.Float64) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64MULLD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULLD x (MOVDconst [c])) + // cond: is16Bit(c) + // result: (MULLDconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is16Bit(c)) { + continue + } + v.reset(OpPPC64MULLDconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64MULLW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULLW x (MOVDconst [c])) + // cond: is16Bit(c) + // result: (MULLWconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is16Bit(c)) { + continue + } + v.reset(OpPPC64MULLWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64NEG(v *Value) bool { + v_0 := v.Args[0] + // match: (NEG (ADDconst [c] x)) + // cond: is32Bit(-c) + // result: (SUBFCconst [-c] x) + for { + if v_0.Op != OpPPC64ADDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(-c)) { + break + } + v.reset(OpPPC64SUBFCconst) + v.AuxInt = int64ToAuxInt(-c) + v.AddArg(x) + return true + } + // match: (NEG (SUBFCconst [c] x)) + // cond: is32Bit(-c) + // result: (ADDconst [-c] x) + for { + if v_0.Op != OpPPC64SUBFCconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(-c)) { + break + } + v.reset(OpPPC64ADDconst) + v.AuxInt = int64ToAuxInt(-c) + v.AddArg(x) + return true + } + // match: (NEG (SUB x y)) + // result: (SUB y x) + for { + if v_0.Op != OpPPC64SUB { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpPPC64SUB) + v.AddArg2(y, x) + return true + } + // match: (NEG (NEG x)) + // result: x + for { + if v_0.Op != OpPPC64NEG { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64NOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NOR (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [^(c|d)]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64MOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(^(c | d)) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64NotEqual(v *Value) bool { + v_0 := v.Args[0] + // match: (NotEqual (FlagEQ)) + // result: (MOVDconst [0]) + for { + if v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (NotEqual (FlagLT)) + // result: (MOVDconst [1]) + for { + if v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (NotEqual (FlagGT)) + // result: (MOVDconst [1]) + for { + if v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (NotEqual (InvertFlags x)) + // result: (NotEqual x) + for { + if v_0.Op != OpPPC64InvertFlags { + break + } + x := v_0.Args[0] + v.reset(OpPPC64NotEqual) + v.AddArg(x) + return true + } + // match: (NotEqual cmp) + // result: (SETBCR [2] cmp) + for { + cmp := v_0 + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(2) + v.AddArg(cmp) + return true + } +} +func rewriteValuePPC64_OpPPC64OR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (OR x (NOR y y)) + // result: (ORN x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpPPC64NOR { + continue + } + y := v_1.Args[1] + if y != v_1.Args[0] { + continue + } + v.reset(OpPPC64ORN) + v.AddArg2(x, y) + return true + } + break + } + // match: (OR (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [c|d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64MOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(c | d) + return true + } + break + } + // match: (OR x (MOVDconst [c])) + // cond: isU32Bit(c) + // result: (ORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isU32Bit(c)) { + continue + } + v.reset(OpPPC64ORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64ORN(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORN x (MOVDconst [-1])) + // result: x + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst || auxIntToInt64(v_1.AuxInt) != -1 { + break + } + v.copyOf(x) + return true + } + // match: (ORN (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [c|^d]) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64MOVDconst { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(c | ^d) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64ORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORconst [c] (ORconst [d] x)) + // result: (ORconst [c|d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64ORconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpPPC64ORconst) + v.AuxInt = int64ToAuxInt(c | d) + v.AddArg(x) + return true + } + // match: (ORconst [-1] _) + // result: (MOVDconst [-1]) + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (ORconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64RLWINM(v *Value) bool { + v_0 := v.Args[0] + // match: (RLWINM [r] (MOVHZreg u)) + // cond: mergePPC64RlwinmAnd(r,0xFFFF) != 0 + // result: (RLWINM [mergePPC64RlwinmAnd(r,0xFFFF)] u) + for { + r := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVHZreg { + break + } + u := v_0.Args[0] + if !(mergePPC64RlwinmAnd(r, 0xFFFF) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64RlwinmAnd(r, 0xFFFF)) + v.AddArg(u) + return true + } + // match: (RLWINM [r] (ANDconst [a] u)) + // cond: mergePPC64RlwinmAnd(r,uint32(a)) != 0 + // result: (RLWINM [mergePPC64RlwinmAnd(r,uint32(a))] u) + for { + r := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64ANDconst { + break + } + a := auxIntToInt64(v_0.AuxInt) + u := v_0.Args[0] + if !(mergePPC64RlwinmAnd(r, uint32(a)) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64RlwinmAnd(r, uint32(a))) + v.AddArg(u) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64ROTL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROTL x (MOVDconst [c])) + // result: (ROTLconst x [c&63]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64ROTLconst) + v.AuxInt = int64ToAuxInt(c & 63) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64ROTLW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROTLW x (MOVDconst [c])) + // result: (ROTLWconst x [c&31]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64ROTLWconst) + v.AuxInt = int64ToAuxInt(c & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64ROTLWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ROTLWconst [r] (AND (MOVDconst [m]) x)) + // cond: isPPC64WordRotateMask(m) + // result: (RLWINM [encodePPC64RotateMask(r,rotateLeft32(m,r),32)] x) + for { + r := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64AND { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(v_0_0.AuxInt) + x := v_0_1 + if !(isPPC64WordRotateMask(m)) { + continue + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(r, rotateLeft32(m, r), 32)) + v.AddArg(x) + return true + } + break + } + // match: (ROTLWconst [r] (ANDconst [m] x)) + // cond: isPPC64WordRotateMask(m) + // result: (RLWINM [encodePPC64RotateMask(r,rotateLeft32(m,r),32)] x) + for { + r := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64ANDconst { + break + } + m := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(isPPC64WordRotateMask(m)) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(r, rotateLeft32(m, r), 32)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SETBC(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETBC [0] (FlagLT)) + // result: (MOVDconst [1]) + for { + if auxIntToInt32(v.AuxInt) != 0 || v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SETBC [0] (FlagGT)) + // result: (MOVDconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 0 || v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SETBC [0] (FlagEQ)) + // result: (MOVDconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 0 || v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SETBC [1] (FlagGT)) + // result: (MOVDconst [1]) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SETBC [1] (FlagLT)) + // result: (MOVDconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SETBC [1] (FlagEQ)) + // result: (MOVDconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SETBC [2] (FlagEQ)) + // result: (MOVDconst [1]) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SETBC [2] (FlagLT)) + // result: (MOVDconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SETBC [2] (FlagGT)) + // result: (MOVDconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SETBC [0] (InvertFlags bool)) + // result: (SETBC [1] bool) + for { + if auxIntToInt32(v.AuxInt) != 0 || v_0.Op != OpPPC64InvertFlags { + break + } + bool := v_0.Args[0] + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(bool) + return true + } + // match: (SETBC [1] (InvertFlags bool)) + // result: (SETBC [0] bool) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpPPC64InvertFlags { + break + } + bool := v_0.Args[0] + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(bool) + return true + } + // match: (SETBC [2] (InvertFlags bool)) + // result: (SETBC [2] bool) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64InvertFlags { + break + } + bool := v_0.Args[0] + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(2) + v.AddArg(bool) + return true + } + // match: (SETBC [n] (InvertFlags bool)) + // result: (SETBCR [n] bool) + for { + n := auxIntToInt32(v.AuxInt) + if v_0.Op != OpPPC64InvertFlags { + break + } + bool := v_0.Args[0] + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(n) + v.AddArg(bool) + return true + } + // match: (SETBC [2] (CMPconst [0] a:(ANDconst [1] _))) + // result: (XORconst [1] a) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + a := v_0.Args[0] + if a.Op != OpPPC64ANDconst || auxIntToInt64(a.AuxInt) != 1 { + break + } + v.reset(OpPPC64XORconst) + v.AuxInt = int64ToAuxInt(1) + v.AddArg(a) + return true + } + // match: (SETBC [2] (CMPconst [0] a:(AND y z))) + // cond: a.Uses == 1 + // result: (SETBC [2] (Select1 (ANDCC y z ))) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + a := v_0.Args[0] + if a.Op != OpPPC64AND { + break + } + z := a.Args[1] + y := a.Args[0] + if !(a.Uses == 1) { + break + } + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpPPC64ANDCC, types.NewTuple(typ.Int64, types.TypeFlags)) + v1.AddArg2(y, z) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (SETBC [2] (CMPconst [0] o:(OR y z))) + // cond: o.Uses == 1 + // result: (SETBC [2] (Select1 (ORCC y z ))) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + o := v_0.Args[0] + if o.Op != OpPPC64OR { + break + } + z := o.Args[1] + y := o.Args[0] + if !(o.Uses == 1) { + break + } + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpPPC64ORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(y, z) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (SETBC [2] (CMPconst [0] a:(XOR y z))) + // cond: a.Uses == 1 + // result: (SETBC [2] (Select1 (XORCC y z ))) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + a := v_0.Args[0] + if a.Op != OpPPC64XOR { + break + } + z := a.Args[1] + y := a.Args[0] + if !(a.Uses == 1) { + break + } + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpPPC64XORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(y, z) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SETBCR(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETBCR [0] (FlagLT)) + // result: (MOVDconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 0 || v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SETBCR [0] (FlagGT)) + // result: (MOVDconst [1]) + for { + if auxIntToInt32(v.AuxInt) != 0 || v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SETBCR [0] (FlagEQ)) + // result: (MOVDconst [1]) + for { + if auxIntToInt32(v.AuxInt) != 0 || v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SETBCR [1] (FlagGT)) + // result: (MOVDconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SETBCR [1] (FlagLT)) + // result: (MOVDconst [1]) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SETBCR [1] (FlagEQ)) + // result: (MOVDconst [1]) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SETBCR [2] (FlagEQ)) + // result: (MOVDconst [0]) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64FlagEQ { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SETBCR [2] (FlagLT)) + // result: (MOVDconst [1]) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64FlagLT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SETBCR [2] (FlagGT)) + // result: (MOVDconst [1]) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64FlagGT { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SETBCR [0] (InvertFlags bool)) + // result: (SETBCR [1] bool) + for { + if auxIntToInt32(v.AuxInt) != 0 || v_0.Op != OpPPC64InvertFlags { + break + } + bool := v_0.Args[0] + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(bool) + return true + } + // match: (SETBCR [1] (InvertFlags bool)) + // result: (SETBCR [0] bool) + for { + if auxIntToInt32(v.AuxInt) != 1 || v_0.Op != OpPPC64InvertFlags { + break + } + bool := v_0.Args[0] + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(0) + v.AddArg(bool) + return true + } + // match: (SETBCR [2] (InvertFlags bool)) + // result: (SETBCR [2] bool) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64InvertFlags { + break + } + bool := v_0.Args[0] + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(2) + v.AddArg(bool) + return true + } + // match: (SETBCR [n] (InvertFlags bool)) + // result: (SETBC [n] bool) + for { + n := auxIntToInt32(v.AuxInt) + if v_0.Op != OpPPC64InvertFlags { + break + } + bool := v_0.Args[0] + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(n) + v.AddArg(bool) + return true + } + // match: (SETBCR [2] (CMPconst [0] a:(ANDconst [1] _))) + // result: a + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + a := v_0.Args[0] + if a.Op != OpPPC64ANDconst || auxIntToInt64(a.AuxInt) != 1 { + break + } + v.copyOf(a) + return true + } + // match: (SETBCR [2] (CMPconst [0] a:(AND y z))) + // cond: a.Uses == 1 + // result: (SETBCR [2] (Select1 (ANDCC y z ))) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + a := v_0.Args[0] + if a.Op != OpPPC64AND { + break + } + z := a.Args[1] + y := a.Args[0] + if !(a.Uses == 1) { + break + } + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpPPC64ANDCC, types.NewTuple(typ.Int64, types.TypeFlags)) + v1.AddArg2(y, z) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (SETBCR [2] (CMPconst [0] o:(OR y z))) + // cond: o.Uses == 1 + // result: (SETBCR [2] (Select1 (ORCC y z ))) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + o := v_0.Args[0] + if o.Op != OpPPC64OR { + break + } + z := o.Args[1] + y := o.Args[0] + if !(o.Uses == 1) { + break + } + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpPPC64ORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(y, z) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (SETBCR [2] (CMPconst [0] a:(XOR y z))) + // cond: a.Uses == 1 + // result: (SETBCR [2] (Select1 (XORCC y z ))) + for { + if auxIntToInt32(v.AuxInt) != 2 || v_0.Op != OpPPC64CMPconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + a := v_0.Args[0] + if a.Op != OpPPC64XOR { + break + } + z := a.Args[1] + y := a.Args[0] + if !(a.Uses == 1) { + break + } + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v.Pos, OpPPC64XORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(y, z) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SLD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLD x (MOVDconst [c])) + // result: (SLDconst [c&63 | (c>>6&1*63)] x) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64SLDconst) + v.AuxInt = int64ToAuxInt(c&63 | (c >> 6 & 1 * 63)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SLDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLDconst [l] (SRWconst [r] x)) + // cond: mergePPC64SldiSrw(l,r) != 0 + // result: (RLWINM [mergePPC64SldiSrw(l,r)] x) + for { + l := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64SRWconst { + break + } + r := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(mergePPC64SldiSrw(l, r) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64SldiSrw(l, r)) + v.AddArg(x) + return true + } + // match: (SLDconst [s] (RLWINM [r] y)) + // cond: mergePPC64SldiRlwinm(s,r) != 0 + // result: (RLWINM [mergePPC64SldiRlwinm(s,r)] y) + for { + s := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64RLWINM { + break + } + r := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + if !(mergePPC64SldiRlwinm(s, r) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64SldiRlwinm(s, r)) + v.AddArg(y) + return true + } + // match: (SLDconst [c] z:(MOVBZreg x)) + // cond: c < 8 && z.Uses == 1 + // result: (CLRLSLDI [newPPC64ShiftAuxInt(c,56,63,64)] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64MOVBZreg { + break + } + x := z.Args[0] + if !(c < 8 && z.Uses == 1) { + break + } + v.reset(OpPPC64CLRLSLDI) + v.AuxInt = int32ToAuxInt(newPPC64ShiftAuxInt(c, 56, 63, 64)) + v.AddArg(x) + return true + } + // match: (SLDconst [c] z:(MOVHZreg x)) + // cond: c < 16 && z.Uses == 1 + // result: (CLRLSLDI [newPPC64ShiftAuxInt(c,48,63,64)] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64MOVHZreg { + break + } + x := z.Args[0] + if !(c < 16 && z.Uses == 1) { + break + } + v.reset(OpPPC64CLRLSLDI) + v.AuxInt = int32ToAuxInt(newPPC64ShiftAuxInt(c, 48, 63, 64)) + v.AddArg(x) + return true + } + // match: (SLDconst [c] z:(MOVWZreg x)) + // cond: c < 32 && z.Uses == 1 + // result: (CLRLSLDI [newPPC64ShiftAuxInt(c,32,63,64)] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64MOVWZreg { + break + } + x := z.Args[0] + if !(c < 32 && z.Uses == 1) { + break + } + v.reset(OpPPC64CLRLSLDI) + v.AuxInt = int32ToAuxInt(newPPC64ShiftAuxInt(c, 32, 63, 64)) + v.AddArg(x) + return true + } + // match: (SLDconst [c] z:(ANDconst [d] x)) + // cond: z.Uses == 1 && isPPC64ValidShiftMask(d) && c <= (64-getPPC64ShiftMaskLength(d)) + // result: (CLRLSLDI [newPPC64ShiftAuxInt(c,64-getPPC64ShiftMaskLength(d),63,64)] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64ANDconst { + break + } + d := auxIntToInt64(z.AuxInt) + x := z.Args[0] + if !(z.Uses == 1 && isPPC64ValidShiftMask(d) && c <= (64-getPPC64ShiftMaskLength(d))) { + break + } + v.reset(OpPPC64CLRLSLDI) + v.AuxInt = int32ToAuxInt(newPPC64ShiftAuxInt(c, 64-getPPC64ShiftMaskLength(d), 63, 64)) + v.AddArg(x) + return true + } + // match: (SLDconst [c] z:(AND (MOVDconst [d]) x)) + // cond: z.Uses == 1 && isPPC64ValidShiftMask(d) && c<=(64-getPPC64ShiftMaskLength(d)) + // result: (CLRLSLDI [newPPC64ShiftAuxInt(c,64-getPPC64ShiftMaskLength(d),63,64)] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + if z_0.Op != OpPPC64MOVDconst { + continue + } + d := auxIntToInt64(z_0.AuxInt) + x := z_1 + if !(z.Uses == 1 && isPPC64ValidShiftMask(d) && c <= (64-getPPC64ShiftMaskLength(d))) { + continue + } + v.reset(OpPPC64CLRLSLDI) + v.AuxInt = int32ToAuxInt(newPPC64ShiftAuxInt(c, 64-getPPC64ShiftMaskLength(d), 63, 64)) + v.AddArg(x) + return true + } + break + } + // match: (SLDconst [c] z:(MOVWreg x)) + // cond: c < 32 && buildcfg.GOPPC64 >= 9 + // result: (EXTSWSLconst [c] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64MOVWreg { + break + } + x := z.Args[0] + if !(c < 32 && buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64EXTSWSLconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SLW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLW x (MOVDconst [c])) + // result: (SLWconst [c&31 | (c>>5&1*31)] x) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64SLWconst) + v.AuxInt = int64ToAuxInt(c&31 | (c >> 5 & 1 * 31)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SLWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLWconst [s] (MOVWZreg w)) + // result: (SLWconst [s] w) + for { + s := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64MOVWZreg { + break + } + w := v_0.Args[0] + v.reset(OpPPC64SLWconst) + v.AuxInt = int64ToAuxInt(s) + v.AddArg(w) + return true + } + // match: (SLWconst [c] z:(MOVBZreg x)) + // cond: z.Uses == 1 && c < 8 + // result: (CLRLSLWI [newPPC64ShiftAuxInt(c,24,31,32)] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64MOVBZreg { + break + } + x := z.Args[0] + if !(z.Uses == 1 && c < 8) { + break + } + v.reset(OpPPC64CLRLSLWI) + v.AuxInt = int32ToAuxInt(newPPC64ShiftAuxInt(c, 24, 31, 32)) + v.AddArg(x) + return true + } + // match: (SLWconst [c] z:(MOVHZreg x)) + // cond: z.Uses == 1 && c < 16 + // result: (CLRLSLWI [newPPC64ShiftAuxInt(c,16,31,32)] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64MOVHZreg { + break + } + x := z.Args[0] + if !(z.Uses == 1 && c < 16) { + break + } + v.reset(OpPPC64CLRLSLWI) + v.AuxInt = int32ToAuxInt(newPPC64ShiftAuxInt(c, 16, 31, 32)) + v.AddArg(x) + return true + } + // match: (SLWconst [c] z:(ANDconst [d] x)) + // cond: z.Uses == 1 && isPPC64ValidShiftMask(d) && c<=(32-getPPC64ShiftMaskLength(d)) + // result: (CLRLSLWI [newPPC64ShiftAuxInt(c,32-getPPC64ShiftMaskLength(d),31,32)] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64ANDconst { + break + } + d := auxIntToInt64(z.AuxInt) + x := z.Args[0] + if !(z.Uses == 1 && isPPC64ValidShiftMask(d) && c <= (32-getPPC64ShiftMaskLength(d))) { + break + } + v.reset(OpPPC64CLRLSLWI) + v.AuxInt = int32ToAuxInt(newPPC64ShiftAuxInt(c, 32-getPPC64ShiftMaskLength(d), 31, 32)) + v.AddArg(x) + return true + } + // match: (SLWconst [c] z:(AND (MOVDconst [d]) x)) + // cond: z.Uses == 1 && isPPC64ValidShiftMask(d) && c<=(32-getPPC64ShiftMaskLength(d)) + // result: (CLRLSLWI [newPPC64ShiftAuxInt(c,32-getPPC64ShiftMaskLength(d),31,32)] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + if z_0.Op != OpPPC64MOVDconst { + continue + } + d := auxIntToInt64(z_0.AuxInt) + x := z_1 + if !(z.Uses == 1 && isPPC64ValidShiftMask(d) && c <= (32-getPPC64ShiftMaskLength(d))) { + continue + } + v.reset(OpPPC64CLRLSLWI) + v.AuxInt = int32ToAuxInt(newPPC64ShiftAuxInt(c, 32-getPPC64ShiftMaskLength(d), 31, 32)) + v.AddArg(x) + return true + } + break + } + // match: (SLWconst [c] z:(MOVWreg x)) + // cond: c < 32 && buildcfg.GOPPC64 >= 9 + // result: (EXTSWSLconst [c] x) + for { + c := auxIntToInt64(v.AuxInt) + z := v_0 + if z.Op != OpPPC64MOVWreg { + break + } + x := z.Args[0] + if !(c < 32 && buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64EXTSWSLconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SRAD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRAD x (MOVDconst [c])) + // result: (SRADconst [c&63 | (c>>6&1*63)] x) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64SRADconst) + v.AuxInt = int64ToAuxInt(c&63 | (c >> 6 & 1 * 63)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SRAW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRAW x (MOVDconst [c])) + // result: (SRAWconst [c&31 | (c>>5&1*31)] x) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c&31 | (c >> 5 & 1 * 31)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SRD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRD x (MOVDconst [c])) + // result: (SRDconst [c&63 | (c>>6&1*63)] x) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64SRDconst) + v.AuxInt = int64ToAuxInt(c&63 | (c >> 6 & 1 * 63)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SRW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRW x (MOVDconst [c])) + // result: (SRWconst [c&31 | (c>>5&1*31)] x) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c&31 | (c >> 5 & 1 * 31)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SRWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRWconst (ANDconst [m] x) [s]) + // cond: mergePPC64RShiftMask(m>>uint(s),s,32) == 0 + // result: (MOVDconst [0]) + for { + s := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64ANDconst { + break + } + m := auxIntToInt64(v_0.AuxInt) + if !(mergePPC64RShiftMask(m>>uint(s), s, 32) == 0) { + break + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRWconst (ANDconst [m] x) [s]) + // cond: mergePPC64AndSrwi(m>>uint(s),s) != 0 + // result: (RLWINM [mergePPC64AndSrwi(m>>uint(s),s)] x) + for { + s := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64ANDconst { + break + } + m := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(mergePPC64AndSrwi(m>>uint(s), s) != 0) { + break + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndSrwi(m>>uint(s), s)) + v.AddArg(x) + return true + } + // match: (SRWconst (AND (MOVDconst [m]) x) [s]) + // cond: mergePPC64RShiftMask(m>>uint(s),s,32) == 0 + // result: (MOVDconst [0]) + for { + s := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64AND { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(v_0_0.AuxInt) + if !(mergePPC64RShiftMask(m>>uint(s), s, 32) == 0) { + continue + } + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (SRWconst (AND (MOVDconst [m]) x) [s]) + // cond: mergePPC64AndSrwi(m>>uint(s),s) != 0 + // result: (RLWINM [mergePPC64AndSrwi(m>>uint(s),s)] x) + for { + s := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64AND { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(v_0_0.AuxInt) + x := v_0_1 + if !(mergePPC64AndSrwi(m>>uint(s), s) != 0) { + continue + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(mergePPC64AndSrwi(m>>uint(s), s)) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64SUB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUB x (MOVDconst [c])) + // cond: is32Bit(-c) + // result: (ADDconst [-c] x) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(-c)) { + break + } + v.reset(OpPPC64ADDconst) + v.AuxInt = int64ToAuxInt(-c) + v.AddArg(x) + return true + } + // match: (SUB (MOVDconst [c]) x) + // cond: is32Bit(c) + // result: (SUBFCconst [c] x) + for { + if v_0.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(c)) { + break + } + v.reset(OpPPC64SUBFCconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SUBE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SUBE x y (Select1 (SUBCconst (MOVDconst [0]) [0]))) + // result: (SUBC x y) + for { + x := v_0 + y := v_1 + if v_2.Op != OpSelect1 || v_2.Type != typ.UInt64 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpPPC64SUBCconst || auxIntToInt64(v_2_0.AuxInt) != 0 { + break + } + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpPPC64MOVDconst || auxIntToInt64(v_2_0_0.AuxInt) != 0 { + break + } + v.reset(OpPPC64SUBC) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64SUBFCconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBFCconst [c] (NEG x)) + // result: (ADDconst [c] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64NEG { + break + } + x := v_0.Args[0] + v.reset(OpPPC64ADDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (SUBFCconst [c] (SUBFCconst [d] x)) + // cond: is32Bit(c-d) + // result: (ADDconst [c-d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64SUBFCconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(c - d)) { + break + } + v.reset(OpPPC64ADDconst) + v.AuxInt = int64ToAuxInt(c - d) + v.AddArg(x) + return true + } + // match: (SUBFCconst [0] x) + // result: (NEG x) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.reset(OpPPC64NEG) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64_OpPPC64XOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XOR (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [c^d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpPPC64MOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpPPC64MOVDconst) + v.AuxInt = int64ToAuxInt(c ^ d) + return true + } + break + } + // match: (XOR x (MOVDconst [c])) + // cond: isU32Bit(c) + // result: (XORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isU32Bit(c)) { + continue + } + v.reset(OpPPC64XORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuePPC64_OpPPC64XORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORconst [c] (XORconst [d] x)) + // result: (XORconst [c^d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpPPC64XORconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpPPC64XORconst) + v.AuxInt = int64ToAuxInt(c ^ d) + v.AddArg(x) + return true + } + // match: (XORconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (XORconst [1] (SETBCR [n] cmp)) + // result: (SETBC [n] cmp) + for { + if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpPPC64SETBCR { + break + } + n := auxIntToInt32(v_0.AuxInt) + cmp := v_0.Args[0] + v.reset(OpPPC64SETBC) + v.AuxInt = int32ToAuxInt(n) + v.AddArg(cmp) + return true + } + // match: (XORconst [1] (SETBC [n] cmp)) + // result: (SETBCR [n] cmp) + for { + if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpPPC64SETBC { + break + } + n := auxIntToInt32(v_0.AuxInt) + cmp := v_0.Args[0] + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(n) + v.AddArg(cmp) + return true + } + return false +} +func rewriteValuePPC64_OpPopCount16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount16 x) + // result: (POPCNTW (MOVHZreg x)) + for { + x := v_0 + v.reset(OpPPC64POPCNTW) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpPopCount32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount32 x) + // result: (POPCNTW (MOVWZreg x)) + for { + x := v_0 + v.reset(OpPPC64POPCNTW) + v0 := b.NewValue0(v.Pos, OpPPC64MOVWZreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpPopCount8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount8 x) + // result: (POPCNTB (MOVBZreg x)) + for { + x := v_0 + v.reset(OpPPC64POPCNTB) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpPrefetchCache(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (PrefetchCache ptr mem) + // result: (DCBT ptr mem [0]) + for { + ptr := v_0 + mem := v_1 + v.reset(OpPPC64DCBT) + v.AuxInt = int64ToAuxInt(0) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValuePPC64_OpPrefetchCacheStreamed(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (PrefetchCacheStreamed ptr mem) + // result: (DCBT ptr mem [16]) + for { + ptr := v_0 + mem := v_1 + v.reset(OpPPC64DCBT) + v.AuxInt = int64ToAuxInt(16) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValuePPC64_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft16 x (MOVDconst [c])) + // result: (Or16 (Lsh16x64 x (MOVDconst [c&15])) (Rsh16Ux64 x (MOVDconst [-c&15]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpLsh16x64, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(c & 15) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh16Ux64, t) + v3 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v3.AuxInt = int64ToAuxInt(-c & 15) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValuePPC64_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft8 x (MOVDconst [c])) + // result: (Or8 (Lsh8x64 x (MOVDconst [c&7])) (Rsh8Ux64 x (MOVDconst [-c&7]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpLsh8x64, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(c & 7) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh8Ux64, t) + v3 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v3.AuxInt = int64ToAuxInt(-c & 7) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValuePPC64_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRD (MOVHZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux16 x y) + // result: (ISEL [2] (SRD (MOVHZreg x) y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0xFFF0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0xFFF0) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRD (MOVHZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux32 x y) + // result: (ISEL [0] (SRD (MOVHZreg x) y) (MOVDconst [0]) (CMPWUconst y [16])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(16) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 x (MOVDconst [c])) + // cond: uint64(c) < 16 + // result: (SRWconst (ZeroExt16to32 x) [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 16) { + break + } + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh16Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRD (MOVHZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux64 x y) + // result: (ISEL [0] (SRD (MOVHZreg x) y) (MOVDconst [0]) (CMPUconst y [16])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(16) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRD (MOVHZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux8 x y) + // result: (ISEL [2] (SRD (MOVHZreg x) y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0x00F0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0x00F0) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAD (MOVHreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x16 x y) + // result: (ISEL [2] (SRAD (MOVHreg x) y) (SRADconst (MOVHreg x) [15]) (CMPconst [0] (ANDconst [0xFFF0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v2.AuxInt = int64ToAuxInt(15) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0xFFF0) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAD (MOVHreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x32 x y) + // result: (ISEL [0] (SRAD (MOVHreg x) y) (SRADconst (MOVHreg x) [15]) (CMPWUconst y [16])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v2.AuxInt = int64ToAuxInt(15) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(16) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 x (MOVDconst [c])) + // cond: uint64(c) >= 16 + // result: (SRAWconst (SignExt16to32 x) [63]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 16) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh16x64 x (MOVDconst [c])) + // cond: uint64(c) < 16 + // result: (SRAWconst (SignExt16to32 x) [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 16) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAD (MOVHreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x64 x y) + // result: (ISEL [0] (SRAD (MOVHreg x) y) (SRADconst (MOVHreg x) [15]) (CMPUconst y [16])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v2.AuxInt = int64ToAuxInt(15) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(16) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAD (MOVHreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x8 x y) + // result: (ISEL [2] (SRAD (MOVHreg x) y) (SRADconst (MOVHreg x) [15]) (CMPconst [0] (ANDconst [0x00F0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v2.AuxInt = int64ToAuxInt(15) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0x00F0) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux16 x y) + // result: (ISEL [2] (SRW x y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0xFFE0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0xFFE0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux32 x y) + // result: (ISEL [0] (SRW x y) (MOVDconst [0]) (CMPWUconst y [32])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux64 x (MOVDconst [c])) + // cond: uint64(c) < 32 + // result: (SRWconst x [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 32) { + break + } + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (Rsh32Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux64 x y) + // result: (ISEL [0] (SRW x y) (MOVDconst [0]) (CMPUconst y [32])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(32) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux8 x y) + // result: (ISEL [2] (SRW x y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0x00E0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0x00E0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x16 x y) + // result: (ISEL [2] (SRAW x y) (SRAWconst x [31]) (CMPconst [0] (ANDconst [0xFFE0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRAW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64SRAWconst, t) + v1.AuxInt = int64ToAuxInt(31) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0xFFE0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x32 x y) + // result: (ISEL [0] (SRAW x y) (SRAWconst x [31]) (CMPWUconst y [32])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRAW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64SRAWconst, t) + v1.AuxInt = int64ToAuxInt(31) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(32) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x64 x (MOVDconst [c])) + // cond: uint64(c) >= 32 + // result: (SRAWconst x [63]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(63) + v.AddArg(x) + return true + } + // match: (Rsh32x64 x (MOVDconst [c])) + // cond: uint64(c) < 32 + // result: (SRAWconst x [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 32) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (Rsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x64 x y) + // result: (ISEL [0] (SRAW x y) (SRAWconst x [31]) (CMPUconst y [32])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRAW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64SRAWconst, t) + v1.AuxInt = int64ToAuxInt(31) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(32) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x8 x y) + // result: (ISEL [2] (SRAW x y) (SRAWconst x [31]) (CMPconst [0] (ANDconst [0x00E0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRAW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64SRAWconst, t) + v1.AuxInt = int64ToAuxInt(31) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0x00E0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh64Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux16 x y) + // result: (ISEL [2] (SRD x y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0xFFC0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0xFFC0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh64Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux32 x y) + // result: (ISEL [0] (SRD x y) (MOVDconst [0]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh64Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux64 x (MOVDconst [c])) + // cond: uint64(c) < 64 + // result: (SRDconst x [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 64) { + break + } + v.reset(OpPPC64SRDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (Rsh64Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux64 x y) + // result: (ISEL [0] (SRD x y) (MOVDconst [0]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh64Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux8 x y) + // result: (ISEL [2] (SRD x y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0x00C0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0x00C0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x16 x y) + // result: (ISEL [2] (SRAD x y) (SRADconst x [63]) (CMPconst [0] (ANDconst [0xFFC0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v1.AuxInt = int64ToAuxInt(63) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0xFFC0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x32 x y) + // result: (ISEL [0] (SRAD x y) (SRADconst x [63]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v1.AuxInt = int64ToAuxInt(63) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x64 x (MOVDconst [c])) + // cond: uint64(c) >= 64 + // result: (SRADconst x [63]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpPPC64SRADconst) + v.AuxInt = int64ToAuxInt(63) + v.AddArg(x) + return true + } + // match: (Rsh64x64 x (MOVDconst [c])) + // cond: uint64(c) < 64 + // result: (SRADconst x [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 64) { + break + } + v.reset(OpPPC64SRADconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (Rsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x64 x y) + // result: (ISEL [0] (SRAD x y) (SRADconst x [63]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v1.AuxInt = int64ToAuxInt(63) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x8 x y) + // result: (ISEL [2] (SRAD x y) (SRADconst x [63]) (CMPconst [0] (ANDconst [0x00C0] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v1.AuxInt = int64ToAuxInt(63) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v3.AuxInt = int64ToAuxInt(0x00C0) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValuePPC64_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRD (MOVBZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux16 x y) + // result: (ISEL [2] (SRD (MOVBZreg x) y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0xFFF8] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0xFFF8) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRD (MOVBZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux32 x y) + // result: (ISEL [0] (SRD (MOVBZreg x) y) (MOVDconst [0]) (CMPWUconst y [8])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(8) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 x (MOVDconst [c])) + // cond: uint64(c) < 8 + // result: (SRWconst (ZeroExt8to32 x) [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 8) { + break + } + v.reset(OpPPC64SRWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh8Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRD (MOVBZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux64 x y) + // result: (ISEL [0] (SRD (MOVBZreg x) y) (MOVDconst [0]) (CMPUconst y [8])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(8) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRD (MOVBZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux8 x y) + // result: (ISEL [2] (SRD (MOVBZreg x) y) (MOVDconst [0]) (CMPconst [0] (ANDconst [0x00F8] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0x00F8) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAD (MOVBreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x16 x y) + // result: (ISEL [2] (SRAD (MOVBreg x) y) (SRADconst (MOVBreg x) [7]) (CMPconst [0] (ANDconst [0xFFF8] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v2.AuxInt = int64ToAuxInt(7) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0xFFF8) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAD (MOVBreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x32 x y) + // result: (ISEL [0] (SRAD (MOVBreg x) y) (SRADconst (MOVBreg x) [7]) (CMPWUconst y [8])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v2.AuxInt = int64ToAuxInt(7) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpPPC64CMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(8) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x64 x (MOVDconst [c])) + // cond: uint64(c) >= 8 + // result: (SRAWconst (SignExt8to32 x) [63]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 8) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh8x64 x (MOVDconst [c])) + // cond: uint64(c) < 8 + // result: (SRAWconst (SignExt8to32 x) [c]) + for { + x := v_0 + if v_1.Op != OpPPC64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 8) { + break + } + v.reset(OpPPC64SRAWconst) + v.AuxInt = int64ToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAD (MOVBreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x64 x y) + // result: (ISEL [0] (SRAD (MOVBreg x) y) (SRADconst (MOVBreg x) [7]) (CMPUconst y [8])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v2.AuxInt = int64ToAuxInt(7) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpPPC64CMPUconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(8) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAD (MOVBreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpPPC64SRAD) + v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x8 x y) + // result: (ISEL [2] (SRAD (MOVBreg x) y) (SRADconst (MOVBreg x) [7]) (CMPconst [0] (ANDconst [0x00F8] y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpPPC64ISEL) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64SRAD, t) + v1 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpPPC64SRADconst, t) + v2.AuxInt = int64ToAuxInt(7) + v2.AddArg(v1) + v3 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v3.AuxInt = int64ToAuxInt(0) + v4 := b.NewValue0(v.Pos, OpPPC64ANDconst, typ.Int) + v4.AuxInt = int64ToAuxInt(0x00F8) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValuePPC64_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select0 (Mul64uhilo x y)) + // result: (MULHDU x y) + for { + if v_0.Op != OpMul64uhilo { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpPPC64MULHDU) + v.AddArg2(x, y) + return true + } + // match: (Select0 (Mul64uover x y)) + // result: (MULLD x y) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpPPC64MULLD) + v.AddArg2(x, y) + return true + } + // match: (Select0 (Add64carry x y c)) + // result: (Select0 (ADDE x y (Select1 (ADDCconst c [-1])))) + for { + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpSelect0) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpPPC64ADDE, types.NewTuple(typ.UInt64, typ.UInt64)) + v1 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpPPC64ADDCconst, types.NewTuple(typ.UInt64, typ.UInt64)) + v2.AuxInt = int64ToAuxInt(-1) + v2.AddArg(c) + v1.AddArg(v2) + v0.AddArg3(x, y, v1) + v.AddArg(v0) + return true + } + // match: (Select0 (Sub64borrow x y c)) + // result: (Select0 (SUBE x y (Select1 (SUBCconst c [0])))) + for { + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpSelect0) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpPPC64SUBE, types.NewTuple(typ.UInt64, typ.UInt64)) + v1 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpPPC64SUBCconst, types.NewTuple(typ.UInt64, typ.UInt64)) + v2.AuxInt = int64ToAuxInt(0) + v2.AddArg(c) + v1.AddArg(v2) + v0.AddArg3(x, y, v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuePPC64_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select1 (Mul64uhilo x y)) + // result: (MULLD x y) + for { + if v_0.Op != OpMul64uhilo { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpPPC64MULLD) + v.AddArg2(x, y) + return true + } + // match: (Select1 (Mul64uover x y)) + // result: (SETBCR [2] (CMPconst [0] (MULHDU x y))) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpPPC64SETBCR) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpPPC64MULHDU, x.Type) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Select1 (Add64carry x y c)) + // result: (ADDZEzero (Select1 (ADDE x y (Select1 (ADDCconst c [-1]))))) + for { + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpPPC64ADDZEzero) + v0 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpPPC64ADDE, types.NewTuple(typ.UInt64, typ.UInt64)) + v2 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpPPC64ADDCconst, types.NewTuple(typ.UInt64, typ.UInt64)) + v3.AuxInt = int64ToAuxInt(-1) + v3.AddArg(c) + v2.AddArg(v3) + v1.AddArg3(x, y, v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Select1 (ADDCconst n:(ADDZEzero x) [-1])) + // cond: n.Uses <= 2 + // result: x + for { + if v_0.Op != OpPPC64ADDCconst || auxIntToInt64(v_0.AuxInt) != -1 { + break + } + n := v_0.Args[0] + if n.Op != OpPPC64ADDZEzero { + break + } + x := n.Args[0] + if !(n.Uses <= 2) { + break + } + v.copyOf(x) + return true + } + // match: (Select1 (Sub64borrow x y c)) + // result: (NEG (SUBZEzero (Select1 (SUBE x y (Select1 (SUBCconst c [0])))))) + for { + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpPPC64NEG) + v0 := b.NewValue0(v.Pos, OpPPC64SUBZEzero, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpPPC64SUBE, types.NewTuple(typ.UInt64, typ.UInt64)) + v3 := b.NewValue0(v.Pos, OpSelect1, typ.UInt64) + v4 := b.NewValue0(v.Pos, OpPPC64SUBCconst, types.NewTuple(typ.UInt64, typ.UInt64)) + v4.AuxInt = int64ToAuxInt(0) + v4.AddArg(c) + v3.AddArg(v4) + v2.AddArg3(x, y, v3) + v1.AddArg(v2) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Select1 (SUBCconst n:(NEG (SUBZEzero x)) [0])) + // cond: n.Uses <= 2 + // result: x + for { + if v_0.Op != OpPPC64SUBCconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + n := v_0.Args[0] + if n.Op != OpPPC64NEG { + break + } + n_0 := n.Args[0] + if n_0.Op != OpPPC64SUBZEzero { + break + } + x := n_0.Args[0] + if !(n.Uses <= 2) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuePPC64_OpSelectN(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (SelectN [0] call:(CALLstatic {sym} s1:(MOVDstore _ (MOVDconst [sz]) s2:(MOVDstore _ src s3:(MOVDstore {t} _ dst mem))))) + // cond: sz >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(s1, s2, s3, call) + // result: (Move [sz] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpPPC64CALLstatic || len(call.Args) != 1 { + break + } + sym := auxToCall(call.Aux) + s1 := call.Args[0] + if s1.Op != OpPPC64MOVDstore { + break + } + _ = s1.Args[2] + s1_1 := s1.Args[1] + if s1_1.Op != OpPPC64MOVDconst { + break + } + sz := auxIntToInt64(s1_1.AuxInt) + s2 := s1.Args[2] + if s2.Op != OpPPC64MOVDstore { + break + } + _ = s2.Args[2] + src := s2.Args[1] + s3 := s2.Args[2] + if s3.Op != OpPPC64MOVDstore { + break + } + mem := s3.Args[2] + dst := s3.Args[1] + if !(sz >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(s1, s2, s3, call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(sz) + v.AddArg3(dst, src, mem) + return true + } + // match: (SelectN [0] call:(CALLstatic {sym} dst src (MOVDconst [sz]) mem)) + // cond: sz >= 0 && isSameCall(sym, "runtime.memmove") && call.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(call) + // result: (Move [sz] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpPPC64CALLstatic || len(call.Args) != 4 { + break + } + sym := auxToCall(call.Aux) + mem := call.Args[3] + dst := call.Args[0] + src := call.Args[1] + call_2 := call.Args[2] + if call_2.Op != OpPPC64MOVDconst { + break + } + sz := auxIntToInt64(call_2.AuxInt) + if !(sz >= 0 && isSameCall(sym, "runtime.memmove") && call.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(sz) + v.AddArg3(dst, src, mem) + return true + } + return false +} +func rewriteValuePPC64_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Slicemask x) + // result: (SRADconst (NEG x) [63]) + for { + t := v.Type + x := v_0 + v.reset(OpPPC64SRADconst) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpPPC64NEG, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuePPC64_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && t.IsFloat() + // result: (FMOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && t.IsFloat()) { + break + } + v.reset(OpPPC64FMOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && t.IsFloat() + // result: (FMOVSstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && t.IsFloat()) { + break + } + v.reset(OpPPC64FMOVSstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && !t.IsFloat() + // result: (MOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && !t.IsFloat()) { + break + } + v.reset(OpPPC64MOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && !t.IsFloat() + // result: (MOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && !t.IsFloat()) { + break + } + v.reset(OpPPC64MOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (MOVHstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(OpPPC64MOVHstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (MOVBstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(OpPPC64MOVBstore) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValuePPC64_OpTrunc16to8(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc16to8 x) + // cond: t.IsSigned() + // result: (MOVBreg x) + for { + t := v.Type + x := v_0 + if !(t.IsSigned()) { + break + } + v.reset(OpPPC64MOVBreg) + v.AddArg(x) + return true + } + // match: (Trunc16to8 x) + // result: (MOVBZreg x) + for { + x := v_0 + v.reset(OpPPC64MOVBZreg) + v.AddArg(x) + return true + } +} +func rewriteValuePPC64_OpTrunc32to16(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc32to16 x) + // cond: t.IsSigned() + // result: (MOVHreg x) + for { + t := v.Type + x := v_0 + if !(t.IsSigned()) { + break + } + v.reset(OpPPC64MOVHreg) + v.AddArg(x) + return true + } + // match: (Trunc32to16 x) + // result: (MOVHZreg x) + for { + x := v_0 + v.reset(OpPPC64MOVHZreg) + v.AddArg(x) + return true + } +} +func rewriteValuePPC64_OpTrunc32to8(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc32to8 x) + // cond: t.IsSigned() + // result: (MOVBreg x) + for { + t := v.Type + x := v_0 + if !(t.IsSigned()) { + break + } + v.reset(OpPPC64MOVBreg) + v.AddArg(x) + return true + } + // match: (Trunc32to8 x) + // result: (MOVBZreg x) + for { + x := v_0 + v.reset(OpPPC64MOVBZreg) + v.AddArg(x) + return true + } +} +func rewriteValuePPC64_OpTrunc64to16(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc64to16 x) + // cond: t.IsSigned() + // result: (MOVHreg x) + for { + t := v.Type + x := v_0 + if !(t.IsSigned()) { + break + } + v.reset(OpPPC64MOVHreg) + v.AddArg(x) + return true + } + // match: (Trunc64to16 x) + // result: (MOVHZreg x) + for { + x := v_0 + v.reset(OpPPC64MOVHZreg) + v.AddArg(x) + return true + } +} +func rewriteValuePPC64_OpTrunc64to32(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc64to32 x) + // cond: t.IsSigned() + // result: (MOVWreg x) + for { + t := v.Type + x := v_0 + if !(t.IsSigned()) { + break + } + v.reset(OpPPC64MOVWreg) + v.AddArg(x) + return true + } + // match: (Trunc64to32 x) + // result: (MOVWZreg x) + for { + x := v_0 + v.reset(OpPPC64MOVWZreg) + v.AddArg(x) + return true + } +} +func rewriteValuePPC64_OpTrunc64to8(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc64to8 x) + // cond: t.IsSigned() + // result: (MOVBreg x) + for { + t := v.Type + x := v_0 + if !(t.IsSigned()) { + break + } + v.reset(OpPPC64MOVBreg) + v.AddArg(x) + return true + } + // match: (Trunc64to8 x) + // result: (MOVBZreg x) + for { + x := v_0 + v.reset(OpPPC64MOVBZreg) + v.AddArg(x) + return true + } +} +func rewriteValuePPC64_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] destptr mem) + // result: (MOVBstorezero destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVBstorezero) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [2] destptr mem) + // result: (MOVHstorezero destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVHstorezero) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [3] destptr mem) + // result: (MOVBstorezero [2] destptr (MOVHstorezero destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVBstorezero) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHstorezero, types.TypeMem) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [4] destptr mem) + // result: (MOVWstorezero destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVWstorezero) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [5] destptr mem) + // result: (MOVBstorezero [4] destptr (MOVWstorezero destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVBstorezero) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpPPC64MOVWstorezero, types.TypeMem) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [6] destptr mem) + // result: (MOVHstorezero [4] destptr (MOVWstorezero destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVHstorezero) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpPPC64MOVWstorezero, types.TypeMem) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [7] destptr mem) + // result: (MOVBstorezero [6] destptr (MOVHstorezero [4] destptr (MOVWstorezero destptr mem))) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVBstorezero) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpPPC64MOVHstorezero, types.TypeMem) + v0.AuxInt = int32ToAuxInt(4) + v1 := b.NewValue0(v.Pos, OpPPC64MOVWstorezero, types.TypeMem) + v1.AddArg2(destptr, mem) + v0.AddArg2(destptr, v1) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [8] {t} destptr mem) + // result: (MOVDstorezero destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVDstorezero) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [12] {t} destptr mem) + // result: (MOVWstorezero [8] destptr (MOVDstorezero [0] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 12 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVWstorezero) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDstorezero, types.TypeMem) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [16] {t} destptr mem) + // result: (MOVDstorezero [8] destptr (MOVDstorezero [0] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVDstorezero) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDstorezero, types.TypeMem) + v0.AuxInt = int32ToAuxInt(0) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [24] {t} destptr mem) + // result: (MOVDstorezero [16] destptr (MOVDstorezero [8] destptr (MOVDstorezero [0] destptr mem))) + for { + if auxIntToInt64(v.AuxInt) != 24 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVDstorezero) + v.AuxInt = int32ToAuxInt(16) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDstorezero, types.TypeMem) + v0.AuxInt = int32ToAuxInt(8) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDstorezero, types.TypeMem) + v1.AuxInt = int32ToAuxInt(0) + v1.AddArg2(destptr, mem) + v0.AddArg2(destptr, v1) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [32] {t} destptr mem) + // result: (MOVDstorezero [24] destptr (MOVDstorezero [16] destptr (MOVDstorezero [8] destptr (MOVDstorezero [0] destptr mem)))) + for { + if auxIntToInt64(v.AuxInt) != 32 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpPPC64MOVDstorezero) + v.AuxInt = int32ToAuxInt(24) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDstorezero, types.TypeMem) + v0.AuxInt = int32ToAuxInt(16) + v1 := b.NewValue0(v.Pos, OpPPC64MOVDstorezero, types.TypeMem) + v1.AuxInt = int32ToAuxInt(8) + v2 := b.NewValue0(v.Pos, OpPPC64MOVDstorezero, types.TypeMem) + v2.AuxInt = int32ToAuxInt(0) + v2.AddArg2(destptr, mem) + v1.AddArg2(destptr, v2) + v0.AddArg2(destptr, v1) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [s] ptr mem) + // cond: buildcfg.GOPPC64 <= 8 && s < 64 + // result: (LoweredZeroShort [s] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + ptr := v_0 + mem := v_1 + if !(buildcfg.GOPPC64 <= 8 && s < 64) { + break + } + v.reset(OpPPC64LoweredZeroShort) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(ptr, mem) + return true + } + // match: (Zero [s] ptr mem) + // cond: buildcfg.GOPPC64 <= 8 + // result: (LoweredZero [s] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + ptr := v_0 + mem := v_1 + if !(buildcfg.GOPPC64 <= 8) { + break + } + v.reset(OpPPC64LoweredZero) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(ptr, mem) + return true + } + // match: (Zero [s] ptr mem) + // cond: s < 128 && buildcfg.GOPPC64 >= 9 + // result: (LoweredQuadZeroShort [s] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + ptr := v_0 + mem := v_1 + if !(s < 128 && buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64LoweredQuadZeroShort) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(ptr, mem) + return true + } + // match: (Zero [s] ptr mem) + // cond: buildcfg.GOPPC64 >= 9 + // result: (LoweredQuadZero [s] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + ptr := v_0 + mem := v_1 + if !(buildcfg.GOPPC64 >= 9) { + break + } + v.reset(OpPPC64LoweredQuadZero) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteBlockPPC64(b *Block) bool { + typ := &b.Func.Config.Types + switch b.Kind { + case BlockPPC64EQ: + // match: (EQ (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpPPC64FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (EQ (FlagLT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpPPC64FlagLT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (FlagGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpPPC64FlagGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (EQ (InvertFlags cmp) yes no) + // result: (EQ cmp yes no) + for b.Controls[0].Op == OpPPC64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockPPC64EQ, cmp) + return true + } + // match: (EQ (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (EQ (Select1 (ANDCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ANDCC, types.NewTuple(typ.Int64, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64EQ, v0) + return true + } + break + } + // match: (EQ (CMPconst [0] z:(OR x y)) yes no) + // cond: z.Uses == 1 + // result: (EQ (Select1 (ORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64OR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64EQ, v0) + return true + } + break + } + // match: (EQ (CMPconst [0] z:(XOR x y)) yes no) + // cond: z.Uses == 1 + // result: (EQ (Select1 (XORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64XOR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64XORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64EQ, v0) + return true + } + break + } + case BlockPPC64GE: + // match: (GE (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpPPC64FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (GE (FlagLT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpPPC64FlagLT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GE (FlagGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpPPC64FlagGT { + b.Reset(BlockFirst) + return true + } + // match: (GE (InvertFlags cmp) yes no) + // result: (LE cmp yes no) + for b.Controls[0].Op == OpPPC64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockPPC64LE, cmp) + return true + } + // match: (GE (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (GE (Select1 (ANDCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ANDCC, types.NewTuple(typ.Int64, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64GE, v0) + return true + } + break + } + // match: (GE (CMPconst [0] z:(OR x y)) yes no) + // cond: z.Uses == 1 + // result: (GE (Select1 (ORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64OR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64GE, v0) + return true + } + break + } + // match: (GE (CMPconst [0] z:(XOR x y)) yes no) + // cond: z.Uses == 1 + // result: (GE (Select1 (XORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64XOR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64XORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64GE, v0) + return true + } + break + } + case BlockPPC64GT: + // match: (GT (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpPPC64FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GT (FlagLT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpPPC64FlagLT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (GT (FlagGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpPPC64FlagGT { + b.Reset(BlockFirst) + return true + } + // match: (GT (InvertFlags cmp) yes no) + // result: (LT cmp yes no) + for b.Controls[0].Op == OpPPC64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockPPC64LT, cmp) + return true + } + // match: (GT (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (GT (Select1 (ANDCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ANDCC, types.NewTuple(typ.Int64, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64GT, v0) + return true + } + break + } + // match: (GT (CMPconst [0] z:(OR x y)) yes no) + // cond: z.Uses == 1 + // result: (GT (Select1 (ORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64OR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64GT, v0) + return true + } + break + } + // match: (GT (CMPconst [0] z:(XOR x y)) yes no) + // cond: z.Uses == 1 + // result: (GT (Select1 (XORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64XOR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64XORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64GT, v0) + return true + } + break + } + case BlockIf: + // match: (If (Equal cc) yes no) + // result: (EQ cc yes no) + for b.Controls[0].Op == OpPPC64Equal { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockPPC64EQ, cc) + return true + } + // match: (If (NotEqual cc) yes no) + // result: (NE cc yes no) + for b.Controls[0].Op == OpPPC64NotEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockPPC64NE, cc) + return true + } + // match: (If (LessThan cc) yes no) + // result: (LT cc yes no) + for b.Controls[0].Op == OpPPC64LessThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockPPC64LT, cc) + return true + } + // match: (If (LessEqual cc) yes no) + // result: (LE cc yes no) + for b.Controls[0].Op == OpPPC64LessEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockPPC64LE, cc) + return true + } + // match: (If (GreaterThan cc) yes no) + // result: (GT cc yes no) + for b.Controls[0].Op == OpPPC64GreaterThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockPPC64GT, cc) + return true + } + // match: (If (GreaterEqual cc) yes no) + // result: (GE cc yes no) + for b.Controls[0].Op == OpPPC64GreaterEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockPPC64GE, cc) + return true + } + // match: (If (FLessThan cc) yes no) + // result: (FLT cc yes no) + for b.Controls[0].Op == OpPPC64FLessThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockPPC64FLT, cc) + return true + } + // match: (If (FLessEqual cc) yes no) + // result: (FLE cc yes no) + for b.Controls[0].Op == OpPPC64FLessEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockPPC64FLE, cc) + return true + } + // match: (If (FGreaterThan cc) yes no) + // result: (FGT cc yes no) + for b.Controls[0].Op == OpPPC64FGreaterThan { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockPPC64FGT, cc) + return true + } + // match: (If (FGreaterEqual cc) yes no) + // result: (FGE cc yes no) + for b.Controls[0].Op == OpPPC64FGreaterEqual { + v_0 := b.Controls[0] + cc := v_0.Args[0] + b.resetWithControl(BlockPPC64FGE, cc) + return true + } + // match: (If cond yes no) + // result: (NE (CMPconst [0] (ANDconst [1] cond)) yes no) + for { + cond := b.Controls[0] + v0 := b.NewValue0(cond.Pos, OpPPC64CMPconst, types.TypeFlags) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(cond.Pos, OpPPC64ANDconst, typ.Int) + v1.AuxInt = int64ToAuxInt(1) + v1.AddArg(cond) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64NE, v0) + return true + } + case BlockPPC64LE: + // match: (LE (FlagEQ) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpPPC64FlagEQ { + b.Reset(BlockFirst) + return true + } + // match: (LE (FlagLT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpPPC64FlagLT { + b.Reset(BlockFirst) + return true + } + // match: (LE (FlagGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpPPC64FlagGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LE (InvertFlags cmp) yes no) + // result: (GE cmp yes no) + for b.Controls[0].Op == OpPPC64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockPPC64GE, cmp) + return true + } + // match: (LE (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (LE (Select1 (ANDCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ANDCC, types.NewTuple(typ.Int64, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64LE, v0) + return true + } + break + } + // match: (LE (CMPconst [0] z:(OR x y)) yes no) + // cond: z.Uses == 1 + // result: (LE (Select1 (ORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64OR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64LE, v0) + return true + } + break + } + // match: (LE (CMPconst [0] z:(XOR x y)) yes no) + // cond: z.Uses == 1 + // result: (LE (Select1 (XORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64XOR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64XORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64LE, v0) + return true + } + break + } + case BlockPPC64LT: + // match: (LT (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpPPC64FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LT (FlagLT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpPPC64FlagLT { + b.Reset(BlockFirst) + return true + } + // match: (LT (FlagGT) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpPPC64FlagGT { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (LT (InvertFlags cmp) yes no) + // result: (GT cmp yes no) + for b.Controls[0].Op == OpPPC64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockPPC64GT, cmp) + return true + } + // match: (LT (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (LT (Select1 (ANDCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ANDCC, types.NewTuple(typ.Int64, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64LT, v0) + return true + } + break + } + // match: (LT (CMPconst [0] z:(OR x y)) yes no) + // cond: z.Uses == 1 + // result: (LT (Select1 (ORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64OR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64LT, v0) + return true + } + break + } + // match: (LT (CMPconst [0] z:(XOR x y)) yes no) + // cond: z.Uses == 1 + // result: (LT (Select1 (XORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64XOR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64XORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64LT, v0) + return true + } + break + } + case BlockPPC64NE: + // match: (NE (CMPconst [0] (ANDconst [1] (Equal cc))) yes no) + // result: (EQ cc yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64ANDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpPPC64Equal { + break + } + cc := v_0_0_0.Args[0] + b.resetWithControl(BlockPPC64EQ, cc) + return true + } + // match: (NE (CMPconst [0] (ANDconst [1] (NotEqual cc))) yes no) + // result: (NE cc yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64ANDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpPPC64NotEqual { + break + } + cc := v_0_0_0.Args[0] + b.resetWithControl(BlockPPC64NE, cc) + return true + } + // match: (NE (CMPconst [0] (ANDconst [1] (LessThan cc))) yes no) + // result: (LT cc yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64ANDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpPPC64LessThan { + break + } + cc := v_0_0_0.Args[0] + b.resetWithControl(BlockPPC64LT, cc) + return true + } + // match: (NE (CMPconst [0] (ANDconst [1] (LessEqual cc))) yes no) + // result: (LE cc yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64ANDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpPPC64LessEqual { + break + } + cc := v_0_0_0.Args[0] + b.resetWithControl(BlockPPC64LE, cc) + return true + } + // match: (NE (CMPconst [0] (ANDconst [1] (GreaterThan cc))) yes no) + // result: (GT cc yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64ANDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpPPC64GreaterThan { + break + } + cc := v_0_0_0.Args[0] + b.resetWithControl(BlockPPC64GT, cc) + return true + } + // match: (NE (CMPconst [0] (ANDconst [1] (GreaterEqual cc))) yes no) + // result: (GE cc yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64ANDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpPPC64GreaterEqual { + break + } + cc := v_0_0_0.Args[0] + b.resetWithControl(BlockPPC64GE, cc) + return true + } + // match: (NE (CMPconst [0] (ANDconst [1] (FLessThan cc))) yes no) + // result: (FLT cc yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64ANDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpPPC64FLessThan { + break + } + cc := v_0_0_0.Args[0] + b.resetWithControl(BlockPPC64FLT, cc) + return true + } + // match: (NE (CMPconst [0] (ANDconst [1] (FLessEqual cc))) yes no) + // result: (FLE cc yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64ANDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpPPC64FLessEqual { + break + } + cc := v_0_0_0.Args[0] + b.resetWithControl(BlockPPC64FLE, cc) + return true + } + // match: (NE (CMPconst [0] (ANDconst [1] (FGreaterThan cc))) yes no) + // result: (FGT cc yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64ANDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpPPC64FGreaterThan { + break + } + cc := v_0_0_0.Args[0] + b.resetWithControl(BlockPPC64FGT, cc) + return true + } + // match: (NE (CMPconst [0] (ANDconst [1] (FGreaterEqual cc))) yes no) + // result: (FGE cc yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpPPC64ANDconst || auxIntToInt64(v_0_0.AuxInt) != 1 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpPPC64FGreaterEqual { + break + } + cc := v_0_0_0.Args[0] + b.resetWithControl(BlockPPC64FGE, cc) + return true + } + // match: (NE (FlagEQ) yes no) + // result: (First no yes) + for b.Controls[0].Op == OpPPC64FlagEQ { + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (NE (FlagLT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpPPC64FlagLT { + b.Reset(BlockFirst) + return true + } + // match: (NE (FlagGT) yes no) + // result: (First yes no) + for b.Controls[0].Op == OpPPC64FlagGT { + b.Reset(BlockFirst) + return true + } + // match: (NE (InvertFlags cmp) yes no) + // result: (NE cmp yes no) + for b.Controls[0].Op == OpPPC64InvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + b.resetWithControl(BlockPPC64NE, cmp) + return true + } + // match: (NE (CMPconst [0] z:(AND x y)) yes no) + // cond: z.Uses == 1 + // result: (NE (Select1 (ANDCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64AND { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ANDCC, types.NewTuple(typ.Int64, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64NE, v0) + return true + } + break + } + // match: (NE (CMPconst [0] z:(OR x y)) yes no) + // cond: z.Uses == 1 + // result: (NE (Select1 (ORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64OR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64ORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64NE, v0) + return true + } + break + } + // match: (NE (CMPconst [0] z:(XOR x y)) yes no) + // cond: z.Uses == 1 + // result: (NE (Select1 (XORCC x y)) yes no) + for b.Controls[0].Op == OpPPC64CMPconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64XOR { + break + } + _ = z.Args[1] + z_0 := z.Args[0] + z_1 := z.Args[1] + for _i0 := 0; _i0 <= 1; _i0, z_0, z_1 = _i0+1, z_1, z_0 { + x := z_0 + y := z_1 + if !(z.Uses == 1) { + continue + } + v0 := b.NewValue0(v_0.Pos, OpSelect1, types.TypeFlags) + v1 := b.NewValue0(v_0.Pos, OpPPC64XORCC, types.NewTuple(typ.Int, types.TypeFlags)) + v1.AddArg2(x, y) + v0.AddArg(v1) + b.resetWithControl(BlockPPC64NE, v0) + return true + } + break + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewritePPC64latelower.go b/go/src/cmd/compile/internal/ssa/rewritePPC64latelower.go new file mode 100644 index 0000000000000000000000000000000000000000..18c05280c04bf01af49d255a08d46cc048f2bc0f --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewritePPC64latelower.go @@ -0,0 +1,822 @@ +// Code generated from _gen/PPC64latelower.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "internal/buildcfg" + +func rewriteValuePPC64latelower(v *Value) bool { + switch v.Op { + case OpPPC64ADD: + return rewriteValuePPC64latelower_OpPPC64ADD(v) + case OpPPC64AND: + return rewriteValuePPC64latelower_OpPPC64AND(v) + case OpPPC64ANDconst: + return rewriteValuePPC64latelower_OpPPC64ANDconst(v) + case OpPPC64CMPconst: + return rewriteValuePPC64latelower_OpPPC64CMPconst(v) + case OpPPC64ISEL: + return rewriteValuePPC64latelower_OpPPC64ISEL(v) + case OpPPC64RLDICL: + return rewriteValuePPC64latelower_OpPPC64RLDICL(v) + case OpPPC64RLDICLCC: + return rewriteValuePPC64latelower_OpPPC64RLDICLCC(v) + case OpPPC64SETBC: + return rewriteValuePPC64latelower_OpPPC64SETBC(v) + case OpPPC64SETBCR: + return rewriteValuePPC64latelower_OpPPC64SETBCR(v) + } + return false +} +func rewriteValuePPC64latelower_OpPPC64ADD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADD (MOVDconst [m]) x) + // cond: supportsPPC64PCRel() && (m<<30)>>30 == m + // result: (ADDconst [m] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(supportsPPC64PCRel() && (m<<30)>>30 == m) { + continue + } + v.reset(OpPPC64ADDconst) + v.AuxInt = int64ToAuxInt(m) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuePPC64latelower_OpPPC64AND(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AND x:(MOVDconst [m]) n) + // cond: t.Size() <= 2 + // result: (ANDconst [int64(int16(m))] n) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if x.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(x.AuxInt) + n := v_1 + if !(t.Size() <= 2) { + continue + } + v.reset(OpPPC64ANDconst) + v.AuxInt = int64ToAuxInt(int64(int16(m))) + v.AddArg(n) + return true + } + break + } + // match: (AND x:(MOVDconst [m]) n) + // cond: isPPC64ValidShiftMask(m) + // result: (RLDICL [encodePPC64RotateMask(0,m,64)] n) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if x.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(x.AuxInt) + n := v_1 + if !(isPPC64ValidShiftMask(m)) { + continue + } + v.reset(OpPPC64RLDICL) + v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(0, m, 64)) + v.AddArg(n) + return true + } + break + } + // match: (AND x:(MOVDconst [m]) n) + // cond: m != 0 && isPPC64ValidShiftMask(^m) + // result: (RLDICR [encodePPC64RotateMask(0,m,64)] n) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if x.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(x.AuxInt) + n := v_1 + if !(m != 0 && isPPC64ValidShiftMask(^m)) { + continue + } + v.reset(OpPPC64RLDICR) + v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(0, m, 64)) + v.AddArg(n) + return true + } + break + } + // match: (AND x:(MOVDconst [m]) n) + // cond: t.Size() == 4 && isPPC64WordRotateMask(m) + // result: (RLWINM [encodePPC64RotateMask(0,m,32)] n) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if x.Op != OpPPC64MOVDconst { + continue + } + m := auxIntToInt64(x.AuxInt) + n := v_1 + if !(t.Size() == 4 && isPPC64WordRotateMask(m)) { + continue + } + v.reset(OpPPC64RLWINM) + v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(0, m, 32)) + v.AddArg(n) + return true + } + break + } + return false +} +func rewriteValuePPC64latelower_OpPPC64ANDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDconst [m] x) + // cond: isPPC64ValidShiftMask(m) + // result: (RLDICL [encodePPC64RotateMask(0,m,64)] x) + for { + m := auxIntToInt64(v.AuxInt) + x := v_0 + if !(isPPC64ValidShiftMask(m)) { + break + } + v.reset(OpPPC64RLDICL) + v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(0, m, 64)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64latelower_OpPPC64CMPconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPconst [0] z:(ADD x y)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64ADD { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(AND x y)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64AND { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(ANDN x y)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64ANDN { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(OR x y)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64OR { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(SUB x y)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64SUB { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(NOR x y)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64NOR { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(XOR x y)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64XOR { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(MULHDU x y)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64MULHDU { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(NEG x)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64NEG { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(CNTLZD x)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64CNTLZD { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(RLDICL x)) + // cond: v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64RLDICL { + break + } + if !(v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(ADDconst [c] x)) + // cond: int64(int16(c)) == c && v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64ADDconst { + break + } + c := auxIntToInt64(z.AuxInt) + if !(int64(int16(c)) == c && v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] z:(ANDconst [c] x)) + // cond: int64(uint16(c)) == c && v.Block == z.Block + // result: (CMPconst [0] convertPPC64OpToOpCC(z)) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + z := v_0 + if z.Op != OpPPC64ANDconst { + break + } + c := auxIntToInt64(z.AuxInt) + if !(int64(uint16(c)) == c && v.Block == z.Block) { + break + } + v.reset(OpPPC64CMPconst) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(convertPPC64OpToOpCC(z)) + return true + } + // match: (CMPconst [0] (Select0 z:(ADDCC x y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64ADDCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(ANDCC x y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64ANDCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(ANDNCC x y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64ANDNCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(ORCC x y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64ORCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(SUBCC x y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64SUBCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(NORCC x y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64NORCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(XORCC x y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64XORCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(MULHDUCC x y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64MULHDUCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(ADDCCconst y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64ADDCCconst { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(ANDCCconst y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64ANDCCconst { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(NEGCC y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64NEGCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(CNTLZDCC y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64CNTLZDCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + // match: (CMPconst [0] (Select0 z:(RLDICLCC y))) + // result: (Select1 z) + for { + t := v.Type + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 { + break + } + z := v_0.Args[0] + if z.Op != OpPPC64RLDICLCC { + break + } + v.reset(OpSelect1) + v.Type = t + v.AddArg(z) + return true + } + return false +} +func rewriteValuePPC64latelower_OpPPC64ISEL(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ISEL [a] x (MOVDconst [0]) z) + // result: (ISELZ [a] x z) + for { + a := auxIntToInt32(v.AuxInt) + x := v_0 + if v_1.Op != OpPPC64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + z := v_2 + v.reset(OpPPC64ISELZ) + v.AuxInt = int32ToAuxInt(a) + v.AddArg2(x, z) + return true + } + // match: (ISEL [a] (MOVDconst [0]) y z) + // result: (ISELZ [a^0x4] y z) + for { + a := auxIntToInt32(v.AuxInt) + if v_0.Op != OpPPC64MOVDconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + y := v_1 + z := v_2 + v.reset(OpPPC64ISELZ) + v.AuxInt = int32ToAuxInt(a ^ 0x4) + v.AddArg2(y, z) + return true + } + return false +} +func rewriteValuePPC64latelower_OpPPC64RLDICL(v *Value) bool { + v_0 := v.Args[0] + // match: (RLDICL [em] x:(SRDconst [s] a)) + // cond: (em&0xFF0000) == 0 + // result: (RLDICL [mergePPC64RLDICLandSRDconst(em, s)] a) + for { + em := auxIntToInt64(v.AuxInt) + x := v_0 + if x.Op != OpPPC64SRDconst { + break + } + s := auxIntToInt64(x.AuxInt) + a := x.Args[0] + if !((em & 0xFF0000) == 0) { + break + } + v.reset(OpPPC64RLDICL) + v.AuxInt = int64ToAuxInt(mergePPC64RLDICLandSRDconst(em, s)) + v.AddArg(a) + return true + } + return false +} +func rewriteValuePPC64latelower_OpPPC64RLDICLCC(v *Value) bool { + v_0 := v.Args[0] + // match: (RLDICLCC [a] x) + // cond: convertPPC64RldiclAndccconst(a) != 0 + // result: (ANDCCconst [convertPPC64RldiclAndccconst(a)] x) + for { + a := auxIntToInt64(v.AuxInt) + x := v_0 + if !(convertPPC64RldiclAndccconst(a) != 0) { + break + } + v.reset(OpPPC64ANDCCconst) + v.AuxInt = int64ToAuxInt(convertPPC64RldiclAndccconst(a)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuePPC64latelower_OpPPC64SETBC(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETBC [2] cmp) + // cond: buildcfg.GOPPC64 <= 9 + // result: (ISELZ [2] (MOVDconst [1]) cmp) + for { + if auxIntToInt32(v.AuxInt) != 2 { + break + } + cmp := v_0 + if !(buildcfg.GOPPC64 <= 9) { + break + } + v.reset(OpPPC64ISELZ) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, cmp) + return true + } + // match: (SETBC [0] cmp) + // cond: buildcfg.GOPPC64 <= 9 + // result: (ISELZ [0] (MOVDconst [1]) cmp) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + cmp := v_0 + if !(buildcfg.GOPPC64 <= 9) { + break + } + v.reset(OpPPC64ISELZ) + v.AuxInt = int32ToAuxInt(0) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, cmp) + return true + } + // match: (SETBC [1] cmp) + // cond: buildcfg.GOPPC64 <= 9 + // result: (ISELZ [1] (MOVDconst [1]) cmp) + for { + if auxIntToInt32(v.AuxInt) != 1 { + break + } + cmp := v_0 + if !(buildcfg.GOPPC64 <= 9) { + break + } + v.reset(OpPPC64ISELZ) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, cmp) + return true + } + return false +} +func rewriteValuePPC64latelower_OpPPC64SETBCR(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SETBCR [2] cmp) + // cond: buildcfg.GOPPC64 <= 9 + // result: (ISELZ [6] (MOVDconst [1]) cmp) + for { + if auxIntToInt32(v.AuxInt) != 2 { + break + } + cmp := v_0 + if !(buildcfg.GOPPC64 <= 9) { + break + } + v.reset(OpPPC64ISELZ) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, cmp) + return true + } + // match: (SETBCR [0] cmp) + // cond: buildcfg.GOPPC64 <= 9 + // result: (ISELZ [4] (MOVDconst [1]) cmp) + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + cmp := v_0 + if !(buildcfg.GOPPC64 <= 9) { + break + } + v.reset(OpPPC64ISELZ) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, cmp) + return true + } + // match: (SETBCR [1] cmp) + // cond: buildcfg.GOPPC64 <= 9 + // result: (ISELZ [5] (MOVDconst [1]) cmp) + for { + if auxIntToInt32(v.AuxInt) != 1 { + break + } + cmp := v_0 + if !(buildcfg.GOPPC64 <= 9) { + break + } + v.reset(OpPPC64ISELZ) + v.AuxInt = int32ToAuxInt(5) + v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, cmp) + return true + } + return false +} +func rewriteBlockPPC64latelower(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteRISCV64.go b/go/src/cmd/compile/internal/ssa/rewriteRISCV64.go new file mode 100644 index 0000000000000000000000000000000000000000..284d88967ba2d2f927dfe1dad39c90a68926f006 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteRISCV64.go @@ -0,0 +1,10386 @@ +// Code generated from _gen/RISCV64.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "internal/buildcfg" +import "math" +import "math/bits" +import "cmd/compile/internal/types" + +func rewriteValueRISCV64(v *Value) bool { + switch v.Op { + case OpAbs: + v.Op = OpRISCV64FABSD + return true + case OpAdd16: + v.Op = OpRISCV64ADD + return true + case OpAdd32: + v.Op = OpRISCV64ADD + return true + case OpAdd32F: + v.Op = OpRISCV64FADDS + return true + case OpAdd64: + v.Op = OpRISCV64ADD + return true + case OpAdd64F: + v.Op = OpRISCV64FADDD + return true + case OpAdd8: + v.Op = OpRISCV64ADD + return true + case OpAddPtr: + v.Op = OpRISCV64ADD + return true + case OpAddr: + return rewriteValueRISCV64_OpAddr(v) + case OpAnd16: + v.Op = OpRISCV64AND + return true + case OpAnd32: + v.Op = OpRISCV64AND + return true + case OpAnd64: + v.Op = OpRISCV64AND + return true + case OpAnd8: + v.Op = OpRISCV64AND + return true + case OpAndB: + v.Op = OpRISCV64AND + return true + case OpAtomicAdd32: + v.Op = OpRISCV64LoweredAtomicAdd32 + return true + case OpAtomicAdd64: + v.Op = OpRISCV64LoweredAtomicAdd64 + return true + case OpAtomicAnd32: + v.Op = OpRISCV64LoweredAtomicAnd32 + return true + case OpAtomicAnd8: + return rewriteValueRISCV64_OpAtomicAnd8(v) + case OpAtomicCompareAndSwap32: + return rewriteValueRISCV64_OpAtomicCompareAndSwap32(v) + case OpAtomicCompareAndSwap64: + v.Op = OpRISCV64LoweredAtomicCas64 + return true + case OpAtomicExchange32: + v.Op = OpRISCV64LoweredAtomicExchange32 + return true + case OpAtomicExchange64: + v.Op = OpRISCV64LoweredAtomicExchange64 + return true + case OpAtomicLoad32: + v.Op = OpRISCV64LoweredAtomicLoad32 + return true + case OpAtomicLoad64: + v.Op = OpRISCV64LoweredAtomicLoad64 + return true + case OpAtomicLoad8: + v.Op = OpRISCV64LoweredAtomicLoad8 + return true + case OpAtomicLoadPtr: + v.Op = OpRISCV64LoweredAtomicLoad64 + return true + case OpAtomicOr32: + v.Op = OpRISCV64LoweredAtomicOr32 + return true + case OpAtomicOr8: + return rewriteValueRISCV64_OpAtomicOr8(v) + case OpAtomicStore32: + v.Op = OpRISCV64LoweredAtomicStore32 + return true + case OpAtomicStore64: + v.Op = OpRISCV64LoweredAtomicStore64 + return true + case OpAtomicStore8: + v.Op = OpRISCV64LoweredAtomicStore8 + return true + case OpAtomicStorePtrNoWB: + v.Op = OpRISCV64LoweredAtomicStore64 + return true + case OpAvg64u: + return rewriteValueRISCV64_OpAvg64u(v) + case OpBitLen16: + return rewriteValueRISCV64_OpBitLen16(v) + case OpBitLen32: + return rewriteValueRISCV64_OpBitLen32(v) + case OpBitLen64: + return rewriteValueRISCV64_OpBitLen64(v) + case OpBitLen8: + return rewriteValueRISCV64_OpBitLen8(v) + case OpBswap16: + return rewriteValueRISCV64_OpBswap16(v) + case OpBswap32: + return rewriteValueRISCV64_OpBswap32(v) + case OpBswap64: + v.Op = OpRISCV64REV8 + return true + case OpClosureCall: + v.Op = OpRISCV64CALLclosure + return true + case OpCom16: + v.Op = OpRISCV64NOT + return true + case OpCom32: + v.Op = OpRISCV64NOT + return true + case OpCom64: + v.Op = OpRISCV64NOT + return true + case OpCom8: + v.Op = OpRISCV64NOT + return true + case OpConst16: + return rewriteValueRISCV64_OpConst16(v) + case OpConst32: + return rewriteValueRISCV64_OpConst32(v) + case OpConst32F: + v.Op = OpRISCV64FMOVFconst + return true + case OpConst64: + return rewriteValueRISCV64_OpConst64(v) + case OpConst64F: + v.Op = OpRISCV64FMOVDconst + return true + case OpConst8: + return rewriteValueRISCV64_OpConst8(v) + case OpConstBool: + return rewriteValueRISCV64_OpConstBool(v) + case OpConstNil: + return rewriteValueRISCV64_OpConstNil(v) + case OpCopysign: + v.Op = OpRISCV64FSGNJD + return true + case OpCtz16: + return rewriteValueRISCV64_OpCtz16(v) + case OpCtz16NonZero: + v.Op = OpCtz64 + return true + case OpCtz32: + v.Op = OpRISCV64CTZW + return true + case OpCtz32NonZero: + v.Op = OpCtz64 + return true + case OpCtz64: + v.Op = OpRISCV64CTZ + return true + case OpCtz64NonZero: + v.Op = OpCtz64 + return true + case OpCtz8: + return rewriteValueRISCV64_OpCtz8(v) + case OpCtz8NonZero: + v.Op = OpCtz64 + return true + case OpCvt32Fto32: + v.Op = OpRISCV64FCVTWS + return true + case OpCvt32Fto64: + v.Op = OpRISCV64FCVTLS + return true + case OpCvt32Fto64F: + v.Op = OpRISCV64FCVTDS + return true + case OpCvt32to32F: + v.Op = OpRISCV64FCVTSW + return true + case OpCvt32to64F: + v.Op = OpRISCV64FCVTDW + return true + case OpCvt64Fto32: + v.Op = OpRISCV64FCVTWD + return true + case OpCvt64Fto32F: + v.Op = OpRISCV64FCVTSD + return true + case OpCvt64Fto64: + v.Op = OpRISCV64FCVTLD + return true + case OpCvt64to32F: + v.Op = OpRISCV64FCVTSL + return true + case OpCvt64to64F: + v.Op = OpRISCV64FCVTDL + return true + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpDiv16: + return rewriteValueRISCV64_OpDiv16(v) + case OpDiv16u: + return rewriteValueRISCV64_OpDiv16u(v) + case OpDiv32: + return rewriteValueRISCV64_OpDiv32(v) + case OpDiv32F: + v.Op = OpRISCV64FDIVS + return true + case OpDiv32u: + v.Op = OpRISCV64DIVUW + return true + case OpDiv64: + return rewriteValueRISCV64_OpDiv64(v) + case OpDiv64F: + v.Op = OpRISCV64FDIVD + return true + case OpDiv64u: + v.Op = OpRISCV64DIVU + return true + case OpDiv8: + return rewriteValueRISCV64_OpDiv8(v) + case OpDiv8u: + return rewriteValueRISCV64_OpDiv8u(v) + case OpEq16: + return rewriteValueRISCV64_OpEq16(v) + case OpEq32: + return rewriteValueRISCV64_OpEq32(v) + case OpEq32F: + v.Op = OpRISCV64FEQS + return true + case OpEq64: + return rewriteValueRISCV64_OpEq64(v) + case OpEq64F: + v.Op = OpRISCV64FEQD + return true + case OpEq8: + return rewriteValueRISCV64_OpEq8(v) + case OpEqB: + return rewriteValueRISCV64_OpEqB(v) + case OpEqPtr: + return rewriteValueRISCV64_OpEqPtr(v) + case OpFMA: + v.Op = OpRISCV64FMADDD + return true + case OpGetCallerPC: + v.Op = OpRISCV64LoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = OpRISCV64LoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = OpRISCV64LoweredGetClosurePtr + return true + case OpHmul32: + return rewriteValueRISCV64_OpHmul32(v) + case OpHmul32u: + return rewriteValueRISCV64_OpHmul32u(v) + case OpHmul64: + v.Op = OpRISCV64MULH + return true + case OpHmul64u: + v.Op = OpRISCV64MULHU + return true + case OpInterCall: + v.Op = OpRISCV64CALLinter + return true + case OpIsInBounds: + v.Op = OpLess64U + return true + case OpIsNonNil: + v.Op = OpRISCV64SNEZ + return true + case OpIsSliceInBounds: + v.Op = OpLeq64U + return true + case OpLeq16: + return rewriteValueRISCV64_OpLeq16(v) + case OpLeq16U: + return rewriteValueRISCV64_OpLeq16U(v) + case OpLeq32: + return rewriteValueRISCV64_OpLeq32(v) + case OpLeq32F: + v.Op = OpRISCV64FLES + return true + case OpLeq32U: + return rewriteValueRISCV64_OpLeq32U(v) + case OpLeq64: + return rewriteValueRISCV64_OpLeq64(v) + case OpLeq64F: + v.Op = OpRISCV64FLED + return true + case OpLeq64U: + return rewriteValueRISCV64_OpLeq64U(v) + case OpLeq8: + return rewriteValueRISCV64_OpLeq8(v) + case OpLeq8U: + return rewriteValueRISCV64_OpLeq8U(v) + case OpLess16: + return rewriteValueRISCV64_OpLess16(v) + case OpLess16U: + return rewriteValueRISCV64_OpLess16U(v) + case OpLess32: + return rewriteValueRISCV64_OpLess32(v) + case OpLess32F: + v.Op = OpRISCV64FLTS + return true + case OpLess32U: + return rewriteValueRISCV64_OpLess32U(v) + case OpLess64: + v.Op = OpRISCV64SLT + return true + case OpLess64F: + v.Op = OpRISCV64FLTD + return true + case OpLess64U: + v.Op = OpRISCV64SLTU + return true + case OpLess8: + return rewriteValueRISCV64_OpLess8(v) + case OpLess8U: + return rewriteValueRISCV64_OpLess8U(v) + case OpLoad: + return rewriteValueRISCV64_OpLoad(v) + case OpLocalAddr: + return rewriteValueRISCV64_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValueRISCV64_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValueRISCV64_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValueRISCV64_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValueRISCV64_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValueRISCV64_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValueRISCV64_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValueRISCV64_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValueRISCV64_OpLsh32x8(v) + case OpLsh64x16: + return rewriteValueRISCV64_OpLsh64x16(v) + case OpLsh64x32: + return rewriteValueRISCV64_OpLsh64x32(v) + case OpLsh64x64: + return rewriteValueRISCV64_OpLsh64x64(v) + case OpLsh64x8: + return rewriteValueRISCV64_OpLsh64x8(v) + case OpLsh8x16: + return rewriteValueRISCV64_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValueRISCV64_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValueRISCV64_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValueRISCV64_OpLsh8x8(v) + case OpMax32F: + v.Op = OpRISCV64LoweredFMAXS + return true + case OpMax64: + return rewriteValueRISCV64_OpMax64(v) + case OpMax64F: + v.Op = OpRISCV64LoweredFMAXD + return true + case OpMax64u: + return rewriteValueRISCV64_OpMax64u(v) + case OpMin32F: + v.Op = OpRISCV64LoweredFMINS + return true + case OpMin64: + return rewriteValueRISCV64_OpMin64(v) + case OpMin64F: + v.Op = OpRISCV64LoweredFMIND + return true + case OpMin64u: + return rewriteValueRISCV64_OpMin64u(v) + case OpMod16: + return rewriteValueRISCV64_OpMod16(v) + case OpMod16u: + return rewriteValueRISCV64_OpMod16u(v) + case OpMod32: + return rewriteValueRISCV64_OpMod32(v) + case OpMod32u: + v.Op = OpRISCV64REMUW + return true + case OpMod64: + return rewriteValueRISCV64_OpMod64(v) + case OpMod64u: + v.Op = OpRISCV64REMU + return true + case OpMod8: + return rewriteValueRISCV64_OpMod8(v) + case OpMod8u: + return rewriteValueRISCV64_OpMod8u(v) + case OpMove: + return rewriteValueRISCV64_OpMove(v) + case OpMul16: + v.Op = OpRISCV64MULW + return true + case OpMul32: + v.Op = OpRISCV64MULW + return true + case OpMul32F: + v.Op = OpRISCV64FMULS + return true + case OpMul64: + v.Op = OpRISCV64MUL + return true + case OpMul64F: + v.Op = OpRISCV64FMULD + return true + case OpMul64uhilo: + v.Op = OpRISCV64LoweredMuluhilo + return true + case OpMul64uover: + v.Op = OpRISCV64LoweredMuluover + return true + case OpMul8: + v.Op = OpRISCV64MULW + return true + case OpNeg16: + v.Op = OpRISCV64NEG + return true + case OpNeg32: + v.Op = OpRISCV64NEG + return true + case OpNeg32F: + v.Op = OpRISCV64FNEGS + return true + case OpNeg64: + v.Op = OpRISCV64NEG + return true + case OpNeg64F: + v.Op = OpRISCV64FNEGD + return true + case OpNeg8: + v.Op = OpRISCV64NEG + return true + case OpNeq16: + return rewriteValueRISCV64_OpNeq16(v) + case OpNeq32: + return rewriteValueRISCV64_OpNeq32(v) + case OpNeq32F: + v.Op = OpRISCV64FNES + return true + case OpNeq64: + return rewriteValueRISCV64_OpNeq64(v) + case OpNeq64F: + v.Op = OpRISCV64FNED + return true + case OpNeq8: + return rewriteValueRISCV64_OpNeq8(v) + case OpNeqB: + return rewriteValueRISCV64_OpNeqB(v) + case OpNeqPtr: + return rewriteValueRISCV64_OpNeqPtr(v) + case OpNilCheck: + v.Op = OpRISCV64LoweredNilCheck + return true + case OpNot: + v.Op = OpRISCV64SEQZ + return true + case OpOffPtr: + return rewriteValueRISCV64_OpOffPtr(v) + case OpOr16: + v.Op = OpRISCV64OR + return true + case OpOr32: + v.Op = OpRISCV64OR + return true + case OpOr64: + v.Op = OpRISCV64OR + return true + case OpOr8: + v.Op = OpRISCV64OR + return true + case OpOrB: + v.Op = OpRISCV64OR + return true + case OpPanicBounds: + v.Op = OpRISCV64LoweredPanicBoundsRR + return true + case OpPopCount16: + return rewriteValueRISCV64_OpPopCount16(v) + case OpPopCount32: + v.Op = OpRISCV64CPOPW + return true + case OpPopCount64: + v.Op = OpRISCV64CPOP + return true + case OpPopCount8: + return rewriteValueRISCV64_OpPopCount8(v) + case OpPubBarrier: + v.Op = OpRISCV64LoweredPubBarrier + return true + case OpRISCV64ADD: + return rewriteValueRISCV64_OpRISCV64ADD(v) + case OpRISCV64ADDI: + return rewriteValueRISCV64_OpRISCV64ADDI(v) + case OpRISCV64AND: + return rewriteValueRISCV64_OpRISCV64AND(v) + case OpRISCV64ANDI: + return rewriteValueRISCV64_OpRISCV64ANDI(v) + case OpRISCV64FADDD: + return rewriteValueRISCV64_OpRISCV64FADDD(v) + case OpRISCV64FADDS: + return rewriteValueRISCV64_OpRISCV64FADDS(v) + case OpRISCV64FEQD: + return rewriteValueRISCV64_OpRISCV64FEQD(v) + case OpRISCV64FLED: + return rewriteValueRISCV64_OpRISCV64FLED(v) + case OpRISCV64FLTD: + return rewriteValueRISCV64_OpRISCV64FLTD(v) + case OpRISCV64FMADDD: + return rewriteValueRISCV64_OpRISCV64FMADDD(v) + case OpRISCV64FMADDS: + return rewriteValueRISCV64_OpRISCV64FMADDS(v) + case OpRISCV64FMOVDload: + return rewriteValueRISCV64_OpRISCV64FMOVDload(v) + case OpRISCV64FMOVDstore: + return rewriteValueRISCV64_OpRISCV64FMOVDstore(v) + case OpRISCV64FMOVWload: + return rewriteValueRISCV64_OpRISCV64FMOVWload(v) + case OpRISCV64FMOVWstore: + return rewriteValueRISCV64_OpRISCV64FMOVWstore(v) + case OpRISCV64FMSUBD: + return rewriteValueRISCV64_OpRISCV64FMSUBD(v) + case OpRISCV64FMSUBS: + return rewriteValueRISCV64_OpRISCV64FMSUBS(v) + case OpRISCV64FNED: + return rewriteValueRISCV64_OpRISCV64FNED(v) + case OpRISCV64FNMADDD: + return rewriteValueRISCV64_OpRISCV64FNMADDD(v) + case OpRISCV64FNMADDS: + return rewriteValueRISCV64_OpRISCV64FNMADDS(v) + case OpRISCV64FNMSUBD: + return rewriteValueRISCV64_OpRISCV64FNMSUBD(v) + case OpRISCV64FNMSUBS: + return rewriteValueRISCV64_OpRISCV64FNMSUBS(v) + case OpRISCV64FSUBD: + return rewriteValueRISCV64_OpRISCV64FSUBD(v) + case OpRISCV64FSUBS: + return rewriteValueRISCV64_OpRISCV64FSUBS(v) + case OpRISCV64LoweredPanicBoundsCR: + return rewriteValueRISCV64_OpRISCV64LoweredPanicBoundsCR(v) + case OpRISCV64LoweredPanicBoundsRC: + return rewriteValueRISCV64_OpRISCV64LoweredPanicBoundsRC(v) + case OpRISCV64LoweredPanicBoundsRR: + return rewriteValueRISCV64_OpRISCV64LoweredPanicBoundsRR(v) + case OpRISCV64MOVBUload: + return rewriteValueRISCV64_OpRISCV64MOVBUload(v) + case OpRISCV64MOVBUreg: + return rewriteValueRISCV64_OpRISCV64MOVBUreg(v) + case OpRISCV64MOVBload: + return rewriteValueRISCV64_OpRISCV64MOVBload(v) + case OpRISCV64MOVBreg: + return rewriteValueRISCV64_OpRISCV64MOVBreg(v) + case OpRISCV64MOVBstore: + return rewriteValueRISCV64_OpRISCV64MOVBstore(v) + case OpRISCV64MOVBstorezero: + return rewriteValueRISCV64_OpRISCV64MOVBstorezero(v) + case OpRISCV64MOVDload: + return rewriteValueRISCV64_OpRISCV64MOVDload(v) + case OpRISCV64MOVDnop: + return rewriteValueRISCV64_OpRISCV64MOVDnop(v) + case OpRISCV64MOVDreg: + return rewriteValueRISCV64_OpRISCV64MOVDreg(v) + case OpRISCV64MOVDstore: + return rewriteValueRISCV64_OpRISCV64MOVDstore(v) + case OpRISCV64MOVDstorezero: + return rewriteValueRISCV64_OpRISCV64MOVDstorezero(v) + case OpRISCV64MOVHUload: + return rewriteValueRISCV64_OpRISCV64MOVHUload(v) + case OpRISCV64MOVHUreg: + return rewriteValueRISCV64_OpRISCV64MOVHUreg(v) + case OpRISCV64MOVHload: + return rewriteValueRISCV64_OpRISCV64MOVHload(v) + case OpRISCV64MOVHreg: + return rewriteValueRISCV64_OpRISCV64MOVHreg(v) + case OpRISCV64MOVHstore: + return rewriteValueRISCV64_OpRISCV64MOVHstore(v) + case OpRISCV64MOVHstorezero: + return rewriteValueRISCV64_OpRISCV64MOVHstorezero(v) + case OpRISCV64MOVWUload: + return rewriteValueRISCV64_OpRISCV64MOVWUload(v) + case OpRISCV64MOVWUreg: + return rewriteValueRISCV64_OpRISCV64MOVWUreg(v) + case OpRISCV64MOVWload: + return rewriteValueRISCV64_OpRISCV64MOVWload(v) + case OpRISCV64MOVWreg: + return rewriteValueRISCV64_OpRISCV64MOVWreg(v) + case OpRISCV64MOVWstore: + return rewriteValueRISCV64_OpRISCV64MOVWstore(v) + case OpRISCV64MOVWstorezero: + return rewriteValueRISCV64_OpRISCV64MOVWstorezero(v) + case OpRISCV64NEG: + return rewriteValueRISCV64_OpRISCV64NEG(v) + case OpRISCV64NEGW: + return rewriteValueRISCV64_OpRISCV64NEGW(v) + case OpRISCV64OR: + return rewriteValueRISCV64_OpRISCV64OR(v) + case OpRISCV64ORI: + return rewriteValueRISCV64_OpRISCV64ORI(v) + case OpRISCV64ORN: + return rewriteValueRISCV64_OpRISCV64ORN(v) + case OpRISCV64ROL: + return rewriteValueRISCV64_OpRISCV64ROL(v) + case OpRISCV64ROLW: + return rewriteValueRISCV64_OpRISCV64ROLW(v) + case OpRISCV64ROR: + return rewriteValueRISCV64_OpRISCV64ROR(v) + case OpRISCV64RORW: + return rewriteValueRISCV64_OpRISCV64RORW(v) + case OpRISCV64SEQZ: + return rewriteValueRISCV64_OpRISCV64SEQZ(v) + case OpRISCV64SLL: + return rewriteValueRISCV64_OpRISCV64SLL(v) + case OpRISCV64SLLI: + return rewriteValueRISCV64_OpRISCV64SLLI(v) + case OpRISCV64SLLW: + return rewriteValueRISCV64_OpRISCV64SLLW(v) + case OpRISCV64SLT: + return rewriteValueRISCV64_OpRISCV64SLT(v) + case OpRISCV64SLTI: + return rewriteValueRISCV64_OpRISCV64SLTI(v) + case OpRISCV64SLTIU: + return rewriteValueRISCV64_OpRISCV64SLTIU(v) + case OpRISCV64SLTU: + return rewriteValueRISCV64_OpRISCV64SLTU(v) + case OpRISCV64SNEZ: + return rewriteValueRISCV64_OpRISCV64SNEZ(v) + case OpRISCV64SRA: + return rewriteValueRISCV64_OpRISCV64SRA(v) + case OpRISCV64SRAI: + return rewriteValueRISCV64_OpRISCV64SRAI(v) + case OpRISCV64SRAW: + return rewriteValueRISCV64_OpRISCV64SRAW(v) + case OpRISCV64SRL: + return rewriteValueRISCV64_OpRISCV64SRL(v) + case OpRISCV64SRLI: + return rewriteValueRISCV64_OpRISCV64SRLI(v) + case OpRISCV64SRLW: + return rewriteValueRISCV64_OpRISCV64SRLW(v) + case OpRISCV64SUB: + return rewriteValueRISCV64_OpRISCV64SUB(v) + case OpRISCV64SUBW: + return rewriteValueRISCV64_OpRISCV64SUBW(v) + case OpRISCV64XOR: + return rewriteValueRISCV64_OpRISCV64XOR(v) + case OpRotateLeft16: + return rewriteValueRISCV64_OpRotateLeft16(v) + case OpRotateLeft32: + v.Op = OpRISCV64ROLW + return true + case OpRotateLeft64: + v.Op = OpRISCV64ROL + return true + case OpRotateLeft8: + return rewriteValueRISCV64_OpRotateLeft8(v) + case OpRound32F: + v.Op = OpRISCV64LoweredRound32F + return true + case OpRound64F: + v.Op = OpRISCV64LoweredRound64F + return true + case OpRsh16Ux16: + return rewriteValueRISCV64_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValueRISCV64_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValueRISCV64_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValueRISCV64_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValueRISCV64_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValueRISCV64_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValueRISCV64_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValueRISCV64_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValueRISCV64_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValueRISCV64_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValueRISCV64_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValueRISCV64_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValueRISCV64_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValueRISCV64_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValueRISCV64_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValueRISCV64_OpRsh32x8(v) + case OpRsh64Ux16: + return rewriteValueRISCV64_OpRsh64Ux16(v) + case OpRsh64Ux32: + return rewriteValueRISCV64_OpRsh64Ux32(v) + case OpRsh64Ux64: + return rewriteValueRISCV64_OpRsh64Ux64(v) + case OpRsh64Ux8: + return rewriteValueRISCV64_OpRsh64Ux8(v) + case OpRsh64x16: + return rewriteValueRISCV64_OpRsh64x16(v) + case OpRsh64x32: + return rewriteValueRISCV64_OpRsh64x32(v) + case OpRsh64x64: + return rewriteValueRISCV64_OpRsh64x64(v) + case OpRsh64x8: + return rewriteValueRISCV64_OpRsh64x8(v) + case OpRsh8Ux16: + return rewriteValueRISCV64_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValueRISCV64_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValueRISCV64_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValueRISCV64_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValueRISCV64_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValueRISCV64_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValueRISCV64_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValueRISCV64_OpRsh8x8(v) + case OpSelect0: + return rewriteValueRISCV64_OpSelect0(v) + case OpSelect1: + return rewriteValueRISCV64_OpSelect1(v) + case OpSignExt16to32: + v.Op = OpRISCV64MOVHreg + return true + case OpSignExt16to64: + v.Op = OpRISCV64MOVHreg + return true + case OpSignExt32to64: + v.Op = OpRISCV64MOVWreg + return true + case OpSignExt8to16: + v.Op = OpRISCV64MOVBreg + return true + case OpSignExt8to32: + v.Op = OpRISCV64MOVBreg + return true + case OpSignExt8to64: + v.Op = OpRISCV64MOVBreg + return true + case OpSlicemask: + return rewriteValueRISCV64_OpSlicemask(v) + case OpSqrt: + v.Op = OpRISCV64FSQRTD + return true + case OpSqrt32: + v.Op = OpRISCV64FSQRTS + return true + case OpStaticCall: + v.Op = OpRISCV64CALLstatic + return true + case OpStore: + return rewriteValueRISCV64_OpStore(v) + case OpSub16: + v.Op = OpRISCV64SUB + return true + case OpSub32: + v.Op = OpRISCV64SUB + return true + case OpSub32F: + v.Op = OpRISCV64FSUBS + return true + case OpSub64: + v.Op = OpRISCV64SUB + return true + case OpSub64F: + v.Op = OpRISCV64FSUBD + return true + case OpSub8: + v.Op = OpRISCV64SUB + return true + case OpSubPtr: + v.Op = OpRISCV64SUB + return true + case OpTailCall: + v.Op = OpRISCV64CALLtail + return true + case OpTrunc16to8: + v.Op = OpCopy + return true + case OpTrunc32to16: + v.Op = OpCopy + return true + case OpTrunc32to8: + v.Op = OpCopy + return true + case OpTrunc64to16: + v.Op = OpCopy + return true + case OpTrunc64to32: + v.Op = OpCopy + return true + case OpTrunc64to8: + v.Op = OpCopy + return true + case OpWB: + v.Op = OpRISCV64LoweredWB + return true + case OpXor16: + v.Op = OpRISCV64XOR + return true + case OpXor32: + v.Op = OpRISCV64XOR + return true + case OpXor64: + v.Op = OpRISCV64XOR + return true + case OpXor8: + v.Op = OpRISCV64XOR + return true + case OpZero: + return rewriteValueRISCV64_OpZero(v) + case OpZeroExt16to32: + v.Op = OpRISCV64MOVHUreg + return true + case OpZeroExt16to64: + v.Op = OpRISCV64MOVHUreg + return true + case OpZeroExt32to64: + v.Op = OpRISCV64MOVWUreg + return true + case OpZeroExt8to16: + v.Op = OpRISCV64MOVBUreg + return true + case OpZeroExt8to32: + v.Op = OpRISCV64MOVBUreg + return true + case OpZeroExt8to64: + v.Op = OpRISCV64MOVBUreg + return true + } + return false +} +func rewriteValueRISCV64_OpAddr(v *Value) bool { + v_0 := v.Args[0] + // match: (Addr {sym} base) + // result: (MOVaddr {sym} [0] base) + for { + sym := auxToSym(v.Aux) + base := v_0 + v.reset(OpRISCV64MOVaddr) + v.AuxInt = int32ToAuxInt(0) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } +} +func rewriteValueRISCV64_OpAtomicAnd8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicAnd8 ptr val mem) + // result: (LoweredAtomicAnd32 (ANDI [^3] ptr) (NOT (SLL (XORI [0xff] (ZeroExt8to32 val)) (SLLI [3] (ANDI [3] ptr)))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpRISCV64LoweredAtomicAnd32) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Uintptr) + v0.AuxInt = int64ToAuxInt(^3) + v0.AddArg(ptr) + v1 := b.NewValue0(v.Pos, OpRISCV64NOT, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpRISCV64SLL, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpRISCV64XORI, typ.UInt32) + v3.AuxInt = int64ToAuxInt(0xff) + v4 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v4.AddArg(val) + v3.AddArg(v4) + v5 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64) + v5.AuxInt = int64ToAuxInt(3) + v6 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.UInt64) + v6.AuxInt = int64ToAuxInt(3) + v6.AddArg(ptr) + v5.AddArg(v6) + v2.AddArg2(v3, v5) + v1.AddArg(v2) + v.AddArg3(v0, v1, mem) + return true + } +} +func rewriteValueRISCV64_OpAtomicCompareAndSwap32(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicCompareAndSwap32 ptr old new mem) + // result: (LoweredAtomicCas32 ptr (SignExt32to64 old) new mem) + for { + ptr := v_0 + old := v_1 + new := v_2 + mem := v_3 + v.reset(OpRISCV64LoweredAtomicCas32) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(old) + v.AddArg4(ptr, v0, new, mem) + return true + } +} +func rewriteValueRISCV64_OpAtomicOr8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicOr8 ptr val mem) + // result: (LoweredAtomicOr32 (ANDI [^3] ptr) (SLL (ZeroExt8to32 val) (SLLI [3] (ANDI [3] ptr))) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpRISCV64LoweredAtomicOr32) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Uintptr) + v0.AuxInt = int64ToAuxInt(^3) + v0.AddArg(ptr) + v1 := b.NewValue0(v.Pos, OpRISCV64SLL, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(val) + v3 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64) + v3.AuxInt = int64ToAuxInt(3) + v4 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.UInt64) + v4.AuxInt = int64ToAuxInt(3) + v4.AddArg(ptr) + v3.AddArg(v4) + v1.AddArg2(v2, v3) + v.AddArg3(v0, v1, mem) + return true + } +} +func rewriteValueRISCV64_OpAvg64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Avg64u x y) + // result: (ADD (ADD (SRLI [1] x) (SRLI [1] y)) (ANDI [1] (AND x y))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpRISCV64ADD) + v0 := b.NewValue0(v.Pos, OpRISCV64ADD, t) + v1 := b.NewValue0(v.Pos, OpRISCV64SRLI, t) + v1.AuxInt = int64ToAuxInt(1) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpRISCV64SRLI, t) + v2.AuxInt = int64ToAuxInt(1) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpRISCV64ANDI, t) + v3.AuxInt = int64ToAuxInt(1) + v4 := b.NewValue0(v.Pos, OpRISCV64AND, t) + v4.AddArg2(x, y) + v3.AddArg(v4) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValueRISCV64_OpBitLen16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen16 x) + // result: (BitLen64 (ZeroExt16to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpBitLen32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen32 x) + // result: (SUB (MOVDconst [32]) (CLZW x)) + for { + t := v.Type + x := v_0 + v.reset(OpRISCV64SUB) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(32) + v1 := b.NewValue0(v.Pos, OpRISCV64CLZW, t) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpBitLen64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen64 x) + // result: (SUB (MOVDconst [64]) (CLZ x)) + for { + t := v.Type + x := v_0 + v.reset(OpRISCV64SUB) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(64) + v1 := b.NewValue0(v.Pos, OpRISCV64CLZ, t) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpBitLen8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen8 x) + // result: (BitLen64 (ZeroExt8to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpBswap16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Bswap16 x) + // result: (SRLI [48] (REV8 x)) + for { + t := v.Type + x := v_0 + v.reset(OpRISCV64SRLI) + v.AuxInt = int64ToAuxInt(48) + v0 := b.NewValue0(v.Pos, OpRISCV64REV8, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpBswap32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Bswap32 x) + // result: (SRLI [32] (REV8 x)) + for { + t := v.Type + x := v_0 + v.reset(OpRISCV64SRLI) + v.AuxInt = int64ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpRISCV64REV8, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpConst16(v *Value) bool { + // match: (Const16 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt16(v.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueRISCV64_OpConst32(v *Value) bool { + // match: (Const32 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt32(v.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueRISCV64_OpConst64(v *Value) bool { + // match: (Const64 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt64(v.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueRISCV64_OpConst8(v *Value) bool { + // match: (Const8 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt8(v.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueRISCV64_OpConstBool(v *Value) bool { + // match: (ConstBool [val]) + // result: (MOVDconst [int64(b2i(val))]) + for { + val := auxIntToBool(v.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(b2i(val))) + return true + } +} +func rewriteValueRISCV64_OpConstNil(v *Value) bool { + // match: (ConstNil) + // result: (MOVDconst [0]) + for { + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } +} +func rewriteValueRISCV64_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz16 x) + // result: (CTZW (ORI [1<<16] x)) + for { + x := v_0 + v.reset(OpRISCV64CTZW) + v0 := b.NewValue0(v.Pos, OpRISCV64ORI, typ.UInt32) + v0.AuxInt = int64ToAuxInt(1 << 16) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz8 x) + // result: (CTZW (ORI [1<<8] x)) + for { + x := v_0 + v.reset(OpRISCV64CTZW) + v0 := b.NewValue0(v.Pos, OpRISCV64ORI, typ.UInt32) + v0.AuxInt = int64ToAuxInt(1 << 8) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 x y [false]) + // result: (DIVW (SignExt16to32 x) (SignExt16to32 y)) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpRISCV64DIVW) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueRISCV64_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u x y) + // result: (DIVUW (ZeroExt16to32 x) (ZeroExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64DIVUW) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Div32 x y [false]) + // result: (DIVW x y) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpRISCV64DIVW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpDiv64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Div64 x y [false]) + // result: (DIV x y) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpRISCV64DIV) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (DIVW (SignExt8to32 x) (SignExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64DIVW) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (DIVUW (ZeroExt8to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64DIVUW) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq16 x y) + // result: (SEQZ (SUB (ZeroExt16to64 x) (ZeroExt16to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq32 x y) + // cond: x.Type.IsSigned() + // result: (SEQZ (SUB (SignExt32to64 x) (SignExt32to64 y))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + y := v_1 + if !(x.Type.IsSigned()) { + continue + } + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } + break + } + // match: (Eq32 x y) + // cond: !x.Type.IsSigned() + // result: (SEQZ (SUB (ZeroExt32to64 x) (ZeroExt32to64 y))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + y := v_1 + if !(!x.Type.IsSigned()) { + continue + } + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } + break + } + return false +} +func rewriteValueRISCV64_OpEq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64 x y) + // result: (SEQZ (SUB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq8 x y) + // result: (SEQZ (SUB (ZeroExt8to64 x) (ZeroExt8to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqB x y) + // result: (SEQZ (SUB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64SUB, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqPtr x y) + // result: (SEQZ (SUB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64SUB, typ.Uintptr) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpHmul32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul32 x y) + // result: (SRAI [32] (MUL (SignExt32to64 x) (SignExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SRAI) + v.AuxInt = int64ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpRISCV64MUL, typ.Int64) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpHmul32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul32u x y) + // result: (SRLI [32] (MUL (ZeroExt32to64 x) (ZeroExt32to64 y))) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SRLI) + v.AuxInt = int64ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpRISCV64MUL, typ.Int64) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16 x y) + // result: (Not (Less16 y x)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess16, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16U x y) + // result: (Not (Less16U y x)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess16U, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32 x y) + // result: (Not (Less32 y x)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess32, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32U x y) + // result: (Not (Less32U y x)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess32U, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpLeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64 x y) + // result: (Not (Less64 y x)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess64, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpLeq64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64U x y) + // result: (Not (Less64U y x)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess64U, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8 x y) + // result: (Not (Less8 y x)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess8, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8U x y) + // result: (Not (Less8U y x)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess8U, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16 x y) + // result: (SLT (SignExt16to64 x) (SignExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SLT) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16U x y) + // result: (SLTU (ZeroExt16to64 x) (ZeroExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SLTU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32 x y) + // result: (SLT (SignExt32to64 x) (SignExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SLT) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32U x y) + // result: (SLTU (ZeroExt32to64 x) (ZeroExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SLTU) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8 x y) + // result: (SLT (SignExt8to64 x) (SignExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SLT) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8U x y) + // result: (SLTU (ZeroExt8to64 x) (ZeroExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SLTU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Load ptr mem) + // cond: t.IsBoolean() + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsBoolean()) { + break + } + v.reset(OpRISCV64MOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: ( is8BitInt(t) && t.IsSigned()) + // result: (MOVBload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpRISCV64MOVBload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: ( is8BitInt(t) && !t.IsSigned()) + // result: (MOVBUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpRISCV64MOVBUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && t.IsSigned()) + // result: (MOVHload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpRISCV64MOVHload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is16BitInt(t) && !t.IsSigned()) + // result: (MOVHUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpRISCV64MOVHUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is32BitInt(t) && t.IsSigned()) + // result: (MOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpRISCV64MOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is32BitInt(t) && !t.IsSigned()) + // result: (MOVWUload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpRISCV64MOVWUload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (MOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpRISCV64MOVDload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (FMOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(OpRISCV64FMOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (FMOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(OpRISCV64FMOVDload) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (MOVaddr {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(OpRISCV64MOVaddr) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (MOVaddr {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(OpRISCV64MOVaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x16 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg16 (SLTIU [64] (ZeroExt16to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg16, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x32 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg16 (SLTIU [64] (ZeroExt32to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg16, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x64 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg16 (SLTIU [64] y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg16, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x8 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg16 (SLTIU [64] (ZeroExt8to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg16, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x16 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg32 (SLTIU [64] (ZeroExt16to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg32, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x32 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg32 (SLTIU [64] (ZeroExt32to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg32, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x64 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg32 (SLTIU [64] y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg32, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x8 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg32 (SLTIU [64] (ZeroExt8to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg32, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x16 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg64 (SLTIU [64] (ZeroExt16to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg64, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x32 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg64 (SLTIU [64] (ZeroExt32to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg64, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh64x64 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg64 (SLTIU [64] y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg64, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x8 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg64 (SLTIU [64] (ZeroExt8to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg64, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x16 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg8 (SLTIU [64] (ZeroExt16to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg8, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x32 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg8 (SLTIU [64] (ZeroExt32to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg8, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x64 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg8 (SLTIU [64] y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg8, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x8 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SLL x y) (Neg8 (SLTIU [64] (ZeroExt8to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg8, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Lsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SLL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SLL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpMax64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Max64 x y) + // cond: buildcfg.GORISCV64 >= 22 + // result: (MAX x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GORISCV64 >= 22) { + break + } + v.reset(OpRISCV64MAX) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpMax64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Max64u x y) + // cond: buildcfg.GORISCV64 >= 22 + // result: (MAXU x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GORISCV64 >= 22) { + break + } + v.reset(OpRISCV64MAXU) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpMin64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Min64 x y) + // cond: buildcfg.GORISCV64 >= 22 + // result: (MIN x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GORISCV64 >= 22) { + break + } + v.reset(OpRISCV64MIN) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpMin64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Min64u x y) + // cond: buildcfg.GORISCV64 >= 22 + // result: (MINU x y) + for { + x := v_0 + y := v_1 + if !(buildcfg.GORISCV64 >= 22) { + break + } + v.reset(OpRISCV64MINU) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16 x y [false]) + // result: (REMW (SignExt16to32 x) (SignExt16to32 y)) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpRISCV64REMW) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueRISCV64_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16u x y) + // result: (REMUW (ZeroExt16to32 x) (ZeroExt16to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64REMUW) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Mod32 x y [false]) + // result: (REMW x y) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpRISCV64REMW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpMod64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Mod64 x y [false]) + // result: (REM x y) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpRISCV64REM) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (REMW (SignExt8to32 x) (SignExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64REMW) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (REMUW (ZeroExt8to32 x) (ZeroExt8to32 y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64REMUW) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueRISCV64_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (MOVBstore dst (MOVBload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpRISCV64MOVBstore) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore dst (MOVHload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpRISCV64MOVHstore) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (MOVBstore [1] dst (MOVBload [1] src mem) (MOVBstore dst (MOVBload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) + v0.AuxInt = int32ToAuxInt(1) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [4] {t} dst src mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore dst (MOVWload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpRISCV64MOVWstore) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVWload, typ.Int32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [4] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [4] dst src mem) + // result: (MOVBstore [3] dst (MOVBload [3] src mem) (MOVBstore [2] dst (MOVBload [2] src mem) (MOVBstore [1] dst (MOVBload [1] src mem) (MOVBstore dst (MOVBload src mem) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) + v0.AuxInt = int32ToAuxInt(3) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) + v2.AuxInt = int32ToAuxInt(2) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(1) + v4 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) + v4.AuxInt = int32ToAuxInt(1) + v4.AddArg2(src, mem) + v5 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v6 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) + v6.AddArg2(src, mem) + v5.AddArg3(dst, v6, mem) + v3.AddArg3(dst, v4, v5) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [8] {t} dst src mem) + // cond: t.Alignment()%8 == 0 + // result: (MOVDstore dst (MOVDload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%8 == 0) { + break + } + v.reset(OpRISCV64MOVDstore) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDload, typ.Int64) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [8] {t} dst src mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [4] dst (MOVWload [4] src mem) (MOVWstore dst (MOVWload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpRISCV64MOVWstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVWload, typ.Int32) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVWload, typ.Int32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [8] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [6] dst (MOVHload [6] src mem) (MOVHstore [4] dst (MOVHload [4] src mem) (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) + v0.AuxInt = int32ToAuxInt(6) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) + v2.AuxInt = int32ToAuxInt(4) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v3.AuxInt = int32ToAuxInt(2) + v4 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) + v4.AuxInt = int32ToAuxInt(2) + v4.AddArg2(src, mem) + v5 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v6 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) + v6.AddArg2(src, mem) + v5.AddArg3(dst, v6, mem) + v3.AddArg3(dst, v4, v5) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [3] dst src mem) + // result: (MOVBstore [2] dst (MOVBload [2] src mem) (MOVBstore [1] dst (MOVBload [1] src mem) (MOVBstore dst (MOVBload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) + v2.AuxInt = int32ToAuxInt(1) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpRISCV64MOVBload, typ.Int8) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [6] {t} dst src mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [4] dst (MOVHload [4] src mem) (MOVHstore [2] dst (MOVHload [2] src mem) (MOVHstore dst (MOVHload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) + v2.AuxInt = int32ToAuxInt(2) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpRISCV64MOVHload, typ.Int16) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] {t} dst src mem) + // cond: s > 0 && s <= 3*8*moveSize(t.Alignment(), config) && logLargeCopy(v, s) + // result: (LoweredMove [makeValAndOff(int32(s),int32(t.Alignment()))] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 0 && s <= 3*8*moveSize(t.Alignment(), config) && logLargeCopy(v, s)) { + break + } + v.reset(OpRISCV64LoweredMove) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(s), int32(t.Alignment()))) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] {t} dst src mem) + // cond: s > 3*8*moveSize(t.Alignment(), config) && logLargeCopy(v, s) + // result: (LoweredMoveLoop [makeValAndOff(int32(s),int32(t.Alignment()))] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 3*8*moveSize(t.Alignment(), config) && logLargeCopy(v, s)) { + break + } + v.reset(OpRISCV64LoweredMoveLoop) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(s), int32(t.Alignment()))) + v.AddArg3(dst, src, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq16 x y) + // result: (Not (Eq16 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpEq16, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq32 x y) + // result: (Not (Eq32 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpNeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq64 x y) + // result: (Not (Eq64 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpEq64, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq8 x y) + // result: (Not (Eq8 x y)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpEq8, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpNeqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NeqB x y) + // result: (SNEZ (SUB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64SUB, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NeqPtr x y) + // result: (Not (EqPtr x y)) + for { + x := v_0 + y := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpEqPtr, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (OffPtr [off] ptr:(SP)) + // cond: is32Bit(off) + // result: (MOVaddr [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + if ptr.Op != OpSP || !(is32Bit(off)) { + break + } + v.reset(OpRISCV64MOVaddr) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } + // match: (OffPtr [off] ptr) + // cond: is32Bit(off) + // result: (ADDI [off] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + if !(is32Bit(off)) { + break + } + v.reset(OpRISCV64ADDI) + v.AuxInt = int64ToAuxInt(off) + v.AddArg(ptr) + return true + } + // match: (OffPtr [off] ptr) + // result: (ADD (MOVDconst [off]) ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + v.reset(OpRISCV64ADD) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(off) + v.AddArg2(v0, ptr) + return true + } +} +func rewriteValueRISCV64_OpPopCount16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount16 x) + // result: (CPOP (ZeroExt16to64 x)) + for { + x := v_0 + v.reset(OpRISCV64CPOP) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpPopCount8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount8 x) + // result: (CPOP (ZeroExt8to64 x)) + for { + x := v_0 + v.reset(OpRISCV64CPOP) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpRISCV64ADD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADD (MOVDconst [val]) x) + // cond: is32Bit(val) && !t.IsPtr() + // result: (ADDI [val] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpRISCV64MOVDconst { + continue + } + t := v_0.Type + val := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(val) && !t.IsPtr()) { + continue + } + v.reset(OpRISCV64ADDI) + v.AuxInt = int64ToAuxInt(val) + v.AddArg(x) + return true + } + break + } + // match: (ADD x (NEG y)) + // result: (SUB x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpRISCV64NEG { + continue + } + y := v_1.Args[0] + v.reset(OpRISCV64SUB) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADD (SLLI [1] x) y) + // cond: buildcfg.GORISCV64 >= 22 + // result: (SH1ADD x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpRISCV64SLLI || auxIntToInt64(v_0.AuxInt) != 1 { + continue + } + x := v_0.Args[0] + y := v_1 + if !(buildcfg.GORISCV64 >= 22) { + continue + } + v.reset(OpRISCV64SH1ADD) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADD (SLLI [2] x) y) + // cond: buildcfg.GORISCV64 >= 22 + // result: (SH2ADD x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpRISCV64SLLI || auxIntToInt64(v_0.AuxInt) != 2 { + continue + } + x := v_0.Args[0] + y := v_1 + if !(buildcfg.GORISCV64 >= 22) { + continue + } + v.reset(OpRISCV64SH2ADD) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADD (SLLI [3] x) y) + // cond: buildcfg.GORISCV64 >= 22 + // result: (SH3ADD x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpRISCV64SLLI || auxIntToInt64(v_0.AuxInt) != 3 { + continue + } + x := v_0.Args[0] + y := v_1 + if !(buildcfg.GORISCV64 >= 22) { + continue + } + v.reset(OpRISCV64SH3ADD) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueRISCV64_OpRISCV64ADDI(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDI [c] (MOVaddr [d] {s} x)) + // cond: is32Bit(c+int64(d)) + // result: (MOVaddr [int32(c)+d] {s} x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVaddr { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + x := v_0.Args[0] + if !(is32Bit(c + int64(d))) { + break + } + v.reset(OpRISCV64MOVaddr) + v.AuxInt = int32ToAuxInt(int32(c) + d) + v.Aux = symToAux(s) + v.AddArg(x) + return true + } + // match: (ADDI [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ADDI [x] (MOVDconst [y])) + // cond: is32Bit(x + y) + // result: (MOVDconst [x + y]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVDconst { + break + } + y := auxIntToInt64(v_0.AuxInt) + if !(is32Bit(x + y)) { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(x + y) + return true + } + // match: (ADDI [x] (ADDI [y] z)) + // cond: is32Bit(x + y) + // result: (ADDI [x + y] z) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64ADDI { + break + } + y := auxIntToInt64(v_0.AuxInt) + z := v_0.Args[0] + if !(is32Bit(x + y)) { + break + } + v.reset(OpRISCV64ADDI) + v.AuxInt = int64ToAuxInt(x + y) + v.AddArg(z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64AND(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AND (MOVDconst [val]) x) + // cond: is32Bit(val) + // result: (ANDI [val] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpRISCV64MOVDconst { + continue + } + val := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(val)) { + continue + } + v.reset(OpRISCV64ANDI) + v.AuxInt = int64ToAuxInt(val) + v.AddArg(x) + return true + } + break + } + // match: (AND x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64ANDI(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDI [0] x) + // result: (MOVDconst [0]) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (ANDI [-1] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ANDI [x] (MOVDconst [y])) + // result: (MOVDconst [x & y]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVDconst { + break + } + y := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(x & y) + return true + } + // match: (ANDI [x] (ANDI [y] z)) + // result: (ANDI [x & y] z) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64ANDI { + break + } + y := auxIntToInt64(v_0.AuxInt) + z := v_0.Args[0] + v.reset(OpRISCV64ANDI) + v.AuxInt = int64ToAuxInt(x & y) + v.AddArg(z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FADDD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FADDD a (FMULD x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FMADDD x y a) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if v_1.Op != OpRISCV64FMULD { + continue + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + continue + } + v.reset(OpRISCV64FMADDD) + v.AddArg3(x, y, a) + return true + } + break + } + return false +} +func rewriteValueRISCV64_OpRISCV64FADDS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FADDS a (FMULS x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FMADDS x y a) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + a := v_0 + if v_1.Op != OpRISCV64FMULS { + continue + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + continue + } + v.reset(OpRISCV64FMADDS) + v.AddArg3(x, y, a) + return true + } + break + } + return false +} +func rewriteValueRISCV64_OpRISCV64FEQD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (FEQD x (FMOVDconst [math.Inf(-1)])) + // result: (ANDI [0b00_0000_0001] (FCLASSD x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_1.AuxInt) != math.Inf(-1) { + continue + } + v.reset(OpRISCV64ANDI) + v.AuxInt = int64ToAuxInt(0b00_0000_0001) + v0 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (FEQD x (FMOVDconst [math.Inf(1)])) + // result: (SNEZ (ANDI [0b00_1000_0000] (FCLASSD x))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_1.AuxInt) != math.Inf(1) { + continue + } + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt(0b00_1000_0000) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + return false +} +func rewriteValueRISCV64_OpRISCV64FLED(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (FLED (FMOVDconst [-math.MaxFloat64]) x) + // result: (SNEZ (ANDI [0b00_1111_1110] (FCLASSD x))) + for { + if v_0.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_0.AuxInt) != -math.MaxFloat64 { + break + } + x := v_1 + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt(0b00_1111_1110) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (FLED x (FMOVDconst [math.MaxFloat64])) + // result: (SNEZ (ANDI [0b00_0111_1111] (FCLASSD x))) + for { + x := v_0 + if v_1.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_1.AuxInt) != math.MaxFloat64 { + break + } + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt(0b00_0111_1111) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (FLED (FMOVDconst [+0x1p-1022]) x) + // result: (SNEZ (ANDI [0b00_1100_0000] (FCLASSD x))) + for { + if v_0.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_0.AuxInt) != +0x1p-1022 { + break + } + x := v_1 + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt(0b00_1100_0000) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (FLED x (FMOVDconst [-0x1p-1022])) + // result: (SNEZ (ANDI [0b00_0000_0011] (FCLASSD x))) + for { + x := v_0 + if v_1.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_1.AuxInt) != -0x1p-1022 { + break + } + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt(0b00_0000_0011) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FLTD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (FLTD x (FMOVDconst [-math.MaxFloat64])) + // result: (ANDI [0b00_0000_0001] (FCLASSD x)) + for { + x := v_0 + if v_1.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_1.AuxInt) != -math.MaxFloat64 { + break + } + v.reset(OpRISCV64ANDI) + v.AuxInt = int64ToAuxInt(0b00_0000_0001) + v0 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (FLTD (FMOVDconst [math.MaxFloat64]) x) + // result: (SNEZ (ANDI [0b00_1000_0000] (FCLASSD x))) + for { + if v_0.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_0.AuxInt) != math.MaxFloat64 { + break + } + x := v_1 + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt(0b00_1000_0000) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (FLTD x (FMOVDconst [+0x1p-1022])) + // result: (SNEZ (ANDI [0b00_0011_1111] (FCLASSD x))) + for { + x := v_0 + if v_1.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_1.AuxInt) != +0x1p-1022 { + break + } + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt(0b00_0011_1111) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (FLTD (FMOVDconst [-0x1p-1022]) x) + // result: (SNEZ (ANDI [0b00_1111_1100] (FCLASSD x))) + for { + if v_0.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_0.AuxInt) != -0x1p-1022 { + break + } + x := v_1 + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt(0b00_1111_1100) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FMADDD(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMADDD neg:(FNEGD x) y z) + // cond: neg.Uses == 1 + // result: (FNMSUBD x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + neg := v_0 + if neg.Op != OpRISCV64FNEGD { + continue + } + x := neg.Args[0] + y := v_1 + z := v_2 + if !(neg.Uses == 1) { + continue + } + v.reset(OpRISCV64FNMSUBD) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (FMADDD x y neg:(FNEGD z)) + // cond: neg.Uses == 1 + // result: (FMSUBD x y z) + for { + x := v_0 + y := v_1 + neg := v_2 + if neg.Op != OpRISCV64FNEGD { + break + } + z := neg.Args[0] + if !(neg.Uses == 1) { + break + } + v.reset(OpRISCV64FMSUBD) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FMADDS(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMADDS neg:(FNEGS x) y z) + // cond: neg.Uses == 1 + // result: (FNMSUBS x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + neg := v_0 + if neg.Op != OpRISCV64FNEGS { + continue + } + x := neg.Args[0] + y := v_1 + z := v_2 + if !(neg.Uses == 1) { + continue + } + v.reset(OpRISCV64FNMSUBS) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (FMADDS x y neg:(FNEGS z)) + // cond: neg.Uses == 1 + // result: (FMSUBS x y z) + for { + x := v_0 + y := v_1 + neg := v_2 + if neg.Op != OpRISCV64FNEGS { + break + } + z := neg.Args[0] + if !(neg.Uses == 1) { + break + } + v.reset(OpRISCV64FMSUBS) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FMOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (FMOVDload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVDload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64FMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (FMOVDload [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (FMOVDload [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64FMOVDload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (FMOVDload [off] {sym} ptr1 (MOVDstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (FMVDX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64MOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64FMVDX) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FMOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (FMOVDstore [off1] {sym1} (MOVaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVDstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64FMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (FMOVDstore [off1] {sym} (ADDI [off2] base) val mem) + // cond: is32Bit(int64(off1)+off2) + // result: (FMOVDstore [off1+int32(off2)] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64FMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FMOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (FMOVWload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVWload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64FMOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (FMOVWload [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (FMOVWload [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64FMOVWload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (FMOVWload [off] {sym} ptr1 (MOVWstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (FMVSX x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64MOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64FMVSX) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FMOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (FMOVWstore [off1] {sym1} (MOVaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (FMOVWstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64FMOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (FMOVWstore [off1] {sym} (ADDI [off2] base) val mem) + // cond: is32Bit(int64(off1)+off2) + // result: (FMOVWstore [off1+int32(off2)] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64FMOVWstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FMSUBD(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMSUBD neg:(FNEGD x) y z) + // cond: neg.Uses == 1 + // result: (FNMADDD x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + neg := v_0 + if neg.Op != OpRISCV64FNEGD { + continue + } + x := neg.Args[0] + y := v_1 + z := v_2 + if !(neg.Uses == 1) { + continue + } + v.reset(OpRISCV64FNMADDD) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (FMSUBD x y neg:(FNEGD z)) + // cond: neg.Uses == 1 + // result: (FMADDD x y z) + for { + x := v_0 + y := v_1 + neg := v_2 + if neg.Op != OpRISCV64FNEGD { + break + } + z := neg.Args[0] + if !(neg.Uses == 1) { + break + } + v.reset(OpRISCV64FMADDD) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FMSUBS(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMSUBS neg:(FNEGS x) y z) + // cond: neg.Uses == 1 + // result: (FNMADDS x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + neg := v_0 + if neg.Op != OpRISCV64FNEGS { + continue + } + x := neg.Args[0] + y := v_1 + z := v_2 + if !(neg.Uses == 1) { + continue + } + v.reset(OpRISCV64FNMADDS) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (FMSUBS x y neg:(FNEGS z)) + // cond: neg.Uses == 1 + // result: (FMADDS x y z) + for { + x := v_0 + y := v_1 + neg := v_2 + if neg.Op != OpRISCV64FNEGS { + break + } + z := neg.Args[0] + if !(neg.Uses == 1) { + break + } + v.reset(OpRISCV64FMADDS) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FNED(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (FNED x (FMOVDconst [math.Inf(-1)])) + // result: (SEQZ (ANDI [0b00_0000_0001] (FCLASSD x))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_1.AuxInt) != math.Inf(-1) { + continue + } + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt(0b00_0000_0001) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + // match: (FNED x (FMOVDconst [math.Inf(1)])) + // result: (SEQZ (ANDI [0b00_1000_0000] (FCLASSD x))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpRISCV64FMOVDconst || auxIntToFloat64(v_1.AuxInt) != math.Inf(1) { + continue + } + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt(0b00_1000_0000) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + break + } + return false +} +func rewriteValueRISCV64_OpRISCV64FNMADDD(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FNMADDD neg:(FNEGD x) y z) + // cond: neg.Uses == 1 + // result: (FMSUBD x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + neg := v_0 + if neg.Op != OpRISCV64FNEGD { + continue + } + x := neg.Args[0] + y := v_1 + z := v_2 + if !(neg.Uses == 1) { + continue + } + v.reset(OpRISCV64FMSUBD) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (FNMADDD x y neg:(FNEGD z)) + // cond: neg.Uses == 1 + // result: (FNMSUBD x y z) + for { + x := v_0 + y := v_1 + neg := v_2 + if neg.Op != OpRISCV64FNEGD { + break + } + z := neg.Args[0] + if !(neg.Uses == 1) { + break + } + v.reset(OpRISCV64FNMSUBD) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FNMADDS(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FNMADDS neg:(FNEGS x) y z) + // cond: neg.Uses == 1 + // result: (FMSUBS x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + neg := v_0 + if neg.Op != OpRISCV64FNEGS { + continue + } + x := neg.Args[0] + y := v_1 + z := v_2 + if !(neg.Uses == 1) { + continue + } + v.reset(OpRISCV64FMSUBS) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (FNMADDS x y neg:(FNEGS z)) + // cond: neg.Uses == 1 + // result: (FNMSUBS x y z) + for { + x := v_0 + y := v_1 + neg := v_2 + if neg.Op != OpRISCV64FNEGS { + break + } + z := neg.Args[0] + if !(neg.Uses == 1) { + break + } + v.reset(OpRISCV64FNMSUBS) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FNMSUBD(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FNMSUBD neg:(FNEGD x) y z) + // cond: neg.Uses == 1 + // result: (FMADDD x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + neg := v_0 + if neg.Op != OpRISCV64FNEGD { + continue + } + x := neg.Args[0] + y := v_1 + z := v_2 + if !(neg.Uses == 1) { + continue + } + v.reset(OpRISCV64FMADDD) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (FNMSUBD x y neg:(FNEGD z)) + // cond: neg.Uses == 1 + // result: (FNMADDD x y z) + for { + x := v_0 + y := v_1 + neg := v_2 + if neg.Op != OpRISCV64FNEGD { + break + } + z := neg.Args[0] + if !(neg.Uses == 1) { + break + } + v.reset(OpRISCV64FNMADDD) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FNMSUBS(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FNMSUBS neg:(FNEGS x) y z) + // cond: neg.Uses == 1 + // result: (FMADDS x y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + neg := v_0 + if neg.Op != OpRISCV64FNEGS { + continue + } + x := neg.Args[0] + y := v_1 + z := v_2 + if !(neg.Uses == 1) { + continue + } + v.reset(OpRISCV64FMADDS) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (FNMSUBS x y neg:(FNEGS z)) + // cond: neg.Uses == 1 + // result: (FNMADDS x y z) + for { + x := v_0 + y := v_1 + neg := v_2 + if neg.Op != OpRISCV64FNEGS { + break + } + z := neg.Args[0] + if !(neg.Uses == 1) { + break + } + v.reset(OpRISCV64FNMADDS) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FSUBD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FSUBD a (FMULD x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FNMSUBD x y a) + for { + a := v_0 + if v_1.Op != OpRISCV64FMULD { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpRISCV64FNMSUBD) + v.AddArg3(x, y, a) + return true + } + // match: (FSUBD (FMULD x y) a) + // cond: a.Block.Func.useFMA(v) + // result: (FMSUBD x y a) + for { + if v_0.Op != OpRISCV64FMULD { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + a := v_1 + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpRISCV64FMSUBD) + v.AddArg3(x, y, a) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64FSUBS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FSUBS a (FMULS x y)) + // cond: a.Block.Func.useFMA(v) + // result: (FNMSUBS x y a) + for { + a := v_0 + if v_1.Op != OpRISCV64FMULS { + break + } + y := v_1.Args[1] + x := v_1.Args[0] + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpRISCV64FNMSUBS) + v.AddArg3(x, y, a) + return true + } + // match: (FSUBS (FMULS x y) a) + // cond: a.Block.Func.useFMA(v) + // result: (FMSUBS x y a) + for { + if v_0.Op != OpRISCV64FMULS { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + a := v_1 + if !(a.Block.Func.useFMA(v)) { + break + } + v.reset(OpRISCV64FMSUBS) + v.AddArg3(x, y, a) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64LoweredPanicBoundsCR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsCR [kind] {p} (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:p.C, Cy:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpRISCV64LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: p.C, Cy: c}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64LoweredPanicBoundsRC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRC [kind] {p} (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:c, Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpRISCV64LoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: c, Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64LoweredPanicBoundsRR(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRR [kind] x (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsRC [kind] x {PanicBoundsC{C:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpRISCV64LoweredPanicBoundsRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(x, mem) + return true + } + // match: (LoweredPanicBoundsRR [kind] (MOVDconst [c]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:c}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + mem := v_2 + v.reset(OpRISCV64LoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVBUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBUload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBUload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVBUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVBUload [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVBUload [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVBUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (MOVBUload [off] {sym} ptr1 (MOVBstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVBUreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64MOVBstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64MOVBUreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVBUreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVBUreg x:(FLES _ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64FLES { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(FLTS _ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64FLTS { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(FEQS _ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64FEQS { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(FNES _ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64FNES { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(FLED _ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64FLED { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(FLTD _ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64FLTD { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(FEQD _ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64FEQD { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(FNED _ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64FNED { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(SEQZ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64SEQZ { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(SNEZ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64SNEZ { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(SLT _ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64SLT { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(SLTU _ _)) + // result: x + for { + x := v_0 + if x.Op != OpRISCV64SLTU { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg x:(ANDI [c] y)) + // cond: c >= 0 && int64(uint8(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(uint8(c)) == c) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBUreg (ANDI [c] x)) + // cond: c < 0 + // result: (ANDI [int64(uint8(c))] x) + for { + if v_0.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c < 0) { + break + } + v.reset(OpRISCV64ANDI) + v.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg(x) + return true + } + // match: (MOVBUreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint8(c))]) + for { + if v_0.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint8(c))) + return true + } + // match: (MOVBUreg x:(MOVBUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBUload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(Select0 (LoweredAtomicLoad8 _ _))) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpSelect0 { + break + } + x_0 := x.Args[0] + if x_0.Op != OpRISCV64LoweredAtomicLoad8 { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(Select0 (LoweredAtomicCas32 _ _ _ _))) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpSelect0 { + break + } + x_0 := x.Args[0] + if x_0.Op != OpRISCV64LoweredAtomicCas32 { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(Select0 (LoweredAtomicCas64 _ _ _ _))) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpSelect0 { + break + } + x_0 := x.Args[0] + if x_0.Op != OpRISCV64LoweredAtomicCas64 { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(MOVBUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBUreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBUreg x:(MOVBload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBUload [off] {sym} ptr mem) + for { + t := v.Type + x := v_0 + if x.Op != OpRISCV64MOVBload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpRISCV64MOVBUload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVBload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVBload [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVBload [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVBload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (MOVBload [off] {sym} ptr1 (MOVBstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVBreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64MOVBstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64MOVBreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVBreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVBreg x:(ANDI [c] y)) + // cond: c >= 0 && int64(int8(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(int8(c)) == c) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBreg (MOVDconst [c])) + // result: (MOVDconst [int64(int8(c))]) + for { + if v_0.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int8(c))) + return true + } + // match: (MOVBreg x:(MOVBload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBUload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBload [off] {sym} ptr mem) + for { + t := v.Type + x := v_0 + if x.Op != OpRISCV64MOVBUload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpRISCV64MOVBload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBstore [off1] {sym1} (MOVaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVBstore [off1] {sym} (ADDI [off2] base) val mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVBstore [off1+int32(off2)] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVDconst [0]) mem) + // result: (MOVBstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpRISCV64MOVBstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVBreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVBUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVBstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVBstorezero [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVBstorezero [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVBstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVBstorezero [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVBstorezero [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVBstorezero) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVDload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVDload [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVDload [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVDload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (MOVDload [off] {sym} ptr1 (MOVDstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVDreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64MOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVDload [off] {sym} ptr1 (FMOVDstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (FMVXD x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64FMOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64FMVXD) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVDnop(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVDnop (MOVDconst [c])) + // result: (MOVDconst [c]) + for { + if v_0.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(c) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVDreg(v *Value) bool { + v_0 := v.Args[0] + // match: (MOVDreg x) + // cond: x.Uses == 1 + // result: (MOVDnop x) + for { + x := v_0 + if !(x.Uses == 1) { + break + } + v.reset(OpRISCV64MOVDnop) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVDstore [off1] {sym1} (MOVaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVDstore [off1] {sym} (ADDI [off2] base) val mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVDstore [off1+int32(off2)] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVDstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVDstore [off] {sym} ptr (MOVDconst [0]) mem) + // result: (MOVDstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpRISCV64MOVDstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVDstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVDstorezero [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVDstorezero [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVDstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVDstorezero [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVDstorezero [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVDstorezero) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVHUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHUload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHUload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVHUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVHUload [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVHUload [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVHUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (MOVHUload [off] {sym} ptr1 (MOVHstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVHUreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64MOVHstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64MOVHUreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVHUreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVHUreg x:(ANDI [c] y)) + // cond: c >= 0 && int64(uint16(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(uint16(c)) == c) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHUreg (ANDI [c] x)) + // cond: c < 0 + // result: (ANDI [int64(uint16(c))] x) + for { + if v_0.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c < 0) { + break + } + v.reset(OpRISCV64ANDI) + v.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg(x) + return true + } + // match: (MOVHUreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint16(c))]) + for { + if v_0.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint16(c))) + return true + } + // match: (MOVHUreg x:(MOVBUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBUload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVHUload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVBUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBUreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVHUreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHUreg x:(MOVHload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVHUload [off] {sym} ptr mem) + for { + t := v.Type + x := v_0 + if x.Op != OpRISCV64MOVHload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpRISCV64MOVHUload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVHload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVHload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVHload [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVHload [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVHload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (MOVHload [off] {sym} ptr1 (MOVHstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVHreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64MOVHstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64MOVHreg) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVHreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVHreg x:(ANDI [c] y)) + // cond: c >= 0 && int64(int16(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(int16(c)) == c) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHreg (MOVDconst [c])) + // result: (MOVDconst [int64(int16(c))]) + for { + if v_0.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int16(c))) + return true + } + // match: (MOVHreg x:(MOVBload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBUload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVHload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBUreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVHreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVHUload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVHload [off] {sym} ptr mem) + for { + t := v.Type + x := v_0 + if x.Op != OpRISCV64MOVHUload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpRISCV64MOVHload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVHstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHstore [off1] {sym1} (MOVaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVHstore [off1] {sym} (ADDI [off2] base) val mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVHstore [off1+int32(off2)] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVDconst [0]) mem) + // result: (MOVHstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpRISCV64MOVHstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVHUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVHstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVHstorezero [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVHstorezero [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVHstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVHstorezero [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVHstorezero [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVHstorezero) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVWUload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MOVWUload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWUload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVWUload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVWUload [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVWUload [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVWUload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (MOVWUload [off] {sym} ptr1 (MOVWstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVWUreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64MOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64MOVWUreg) + v.AddArg(x) + return true + } + // match: (MOVWUload [off] {sym} ptr1 (FMOVWstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVWUreg (FMVXS x)) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64FMOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64MOVWUreg) + v0 := b.NewValue0(v_1.Pos, OpRISCV64FMVXS, typ.Int32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVWUreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVWUreg x:(ANDI [c] y)) + // cond: c >= 0 && int64(uint32(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(uint32(c)) == c) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWUreg (ANDI [c] x)) + // cond: c < 0 + // result: (AND (MOVDconst [int64(uint32(c))]) x) + for { + if v_0.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + if !(c < 0) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(v0, x) + return true + } + // match: (MOVWUreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint32(c))]) + for { + if v_0.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint32(c))) + return true + } + // match: (MOVWUreg x:(MOVBUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBUload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVHUload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVWUload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVBUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBUreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVHUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVHUreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVWUreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWUreg x:(MOVWload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWUload [off] {sym} ptr mem) + for { + t := v.Type + x := v_0 + if x.Op != OpRISCV64MOVWload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpRISCV64MOVWUload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWload [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVWload [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVWload [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVWload) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + // match: (MOVWload [off] {sym} ptr1 (MOVWstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVWreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64MOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64MOVWreg) + v.AddArg(x) + return true + } + // match: (MOVWload [off] {sym} ptr1 (FMOVWstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (FMVXS x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpRISCV64FMOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpRISCV64FMVXS) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVWreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVWreg x:(ANDI [c] y)) + // cond: c >= 0 && int64(int32(c)) == c + // result: x + for { + x := v_0 + if x.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(x.AuxInt) + if !(c >= 0 && int64(int32(c)) == c) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg (NEG x)) + // result: (NEGW x) + for { + if v_0.Op != OpRISCV64NEG { + break + } + x := v_0.Args[0] + v.reset(OpRISCV64NEGW) + v.AddArg(x) + return true + } + // match: (MOVWreg (MOVDconst [c])) + // result: (MOVDconst [int64(int32(c))]) + for { + if v_0.Op != OpRISCV64MOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int32(c))) + return true + } + // match: (MOVWreg x:(MOVBload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBUload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVHload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHUload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVHUload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWload _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVWload { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(ADDIW _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64ADDIW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(SUBW _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64SUBW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(NEGW _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64NEGW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MULW _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MULW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(DIVW _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64DIVW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(DIVUW _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64DIVUW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(REMW _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64REMW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(REMUW _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64REMUW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(ROLW _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64ROLW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(RORW _ _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64RORW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(RORIW _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64RORIW { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBUreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVBUreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVHreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVHreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWreg _)) + // result: (MOVDreg x) + for { + x := v_0 + if x.Op != OpRISCV64MOVWreg { + break + } + v.reset(OpRISCV64MOVDreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVWUload [off] {sym} ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWload [off] {sym} ptr mem) + for { + t := v.Type + x := v_0 + if x.Op != OpRISCV64MOVWUload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpRISCV64MOVWload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWstore [off1] {sym1} (MOVaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVWstore [off1] {sym} (ADDI [off2] base) val mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVWstore [off1+int32(off2)] {sym} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVWstore) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVDconst [0]) mem) + // result: (MOVWstorezero [off] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + mem := v_2 + v.reset(OpRISCV64MOVWstorezero) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWUreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpRISCV64MOVWUreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpRISCV64MOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64MOVWstorezero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (MOVWstorezero [off1] {sym1} (MOVaddr [off2] {sym2} base) mem) + // cond: canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) && (base.Op != OpSB || !config.ctxt.Flag_dynlink) + // result: (MOVWstorezero [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpRISCV64MOVaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(canMergeSym(sym1, sym2) && is32Bit(int64(off1)+int64(off2)) && (base.Op != OpSB || !config.ctxt.Flag_dynlink)) { + break + } + v.reset(OpRISCV64MOVWstorezero) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + // match: (MOVWstorezero [off1] {sym} (ADDI [off2] base) mem) + // cond: is32Bit(int64(off1)+off2) + // result: (MOVWstorezero [off1+int32(off2)] {sym} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpRISCV64ADDI { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1) + off2)) { + break + } + v.reset(OpRISCV64MOVWstorezero) + v.AuxInt = int32ToAuxInt(off1 + int32(off2)) + v.Aux = symToAux(sym) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64NEG(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (NEG (SUB x y)) + // result: (SUB y x) + for { + if v_0.Op != OpRISCV64SUB { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpRISCV64SUB) + v.AddArg2(y, x) + return true + } + // match: (NEG s:(ADDI [val] (SUB x y))) + // cond: s.Uses == 1 && is32Bit(-val) + // result: (ADDI [-val] (SUB y x)) + for { + t := v.Type + s := v_0 + if s.Op != OpRISCV64ADDI { + break + } + val := auxIntToInt64(s.AuxInt) + s_0 := s.Args[0] + if s_0.Op != OpRISCV64SUB { + break + } + y := s_0.Args[1] + x := s_0.Args[0] + if !(s.Uses == 1 && is32Bit(-val)) { + break + } + v.reset(OpRISCV64ADDI) + v.AuxInt = int64ToAuxInt(-val) + v0 := b.NewValue0(v.Pos, OpRISCV64SUB, t) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + // match: (NEG (NEG x)) + // result: x + for { + if v_0.Op != OpRISCV64NEG { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (NEG s:(ADDI [val] (NEG x))) + // cond: s.Uses == 1 && is32Bit(-val) + // result: (ADDI [-val] x) + for { + s := v_0 + if s.Op != OpRISCV64ADDI { + break + } + val := auxIntToInt64(s.AuxInt) + s_0 := s.Args[0] + if s_0.Op != OpRISCV64NEG { + break + } + x := s_0.Args[0] + if !(s.Uses == 1 && is32Bit(-val)) { + break + } + v.reset(OpRISCV64ADDI) + v.AuxInt = int64ToAuxInt(-val) + v.AddArg(x) + return true + } + // match: (NEG (MOVDconst [x])) + // result: (MOVDconst [-x]) + for { + if v_0.Op != OpRISCV64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(-x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64NEGW(v *Value) bool { + v_0 := v.Args[0] + // match: (NEGW (MOVDconst [x])) + // result: (MOVDconst [int64(int32(-x))]) + for { + if v_0.Op != OpRISCV64MOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(int32(-x))) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64OR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (OR (MOVDconst [val]) x) + // cond: is32Bit(val) + // result: (ORI [val] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpRISCV64MOVDconst { + continue + } + val := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(val)) { + continue + } + v.reset(OpRISCV64ORI) + v.AuxInt = int64ToAuxInt(val) + v.AddArg(x) + return true + } + break + } + // match: (OR x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64ORI(v *Value) bool { + v_0 := v.Args[0] + // match: (ORI [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ORI [-1] x) + // result: (MOVDconst [-1]) + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (ORI [x] (MOVDconst [y])) + // result: (MOVDconst [x | y]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVDconst { + break + } + y := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(x | y) + return true + } + // match: (ORI [x] (ORI [y] z)) + // result: (ORI [x | y] z) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64ORI { + break + } + y := auxIntToInt64(v_0.AuxInt) + z := v_0.Args[0] + v.reset(OpRISCV64ORI) + v.AuxInt = int64ToAuxInt(x | y) + v.AddArg(z) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64ORN(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORN x x) + // result: (MOVDconst [-1]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64ROL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROL x (MOVDconst [val])) + // result: (RORI [-val&63] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + v.reset(OpRISCV64RORI) + v.AuxInt = int64ToAuxInt(-val & 63) + v.AddArg(x) + return true + } + // match: (ROL x (NEG y)) + // result: (ROR x y) + for { + x := v_0 + if v_1.Op != OpRISCV64NEG { + break + } + y := v_1.Args[0] + v.reset(OpRISCV64ROR) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64ROLW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROLW x (MOVDconst [val])) + // result: (RORIW [-val&31] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + v.reset(OpRISCV64RORIW) + v.AuxInt = int64ToAuxInt(-val & 31) + v.AddArg(x) + return true + } + // match: (ROLW x (NEG y)) + // result: (RORW x y) + for { + x := v_0 + if v_1.Op != OpRISCV64NEG { + break + } + y := v_1.Args[0] + v.reset(OpRISCV64RORW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64ROR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ROR x (MOVDconst [val])) + // result: (RORI [val&63] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + v.reset(OpRISCV64RORI) + v.AuxInt = int64ToAuxInt(val & 63) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64RORW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RORW x (MOVDconst [val])) + // result: (RORIW [val&31] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + v.reset(OpRISCV64RORIW) + v.AuxInt = int64ToAuxInt(val & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SEQZ(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SEQZ (NEG x)) + // result: (SEQZ x) + for { + if v_0.Op != OpRISCV64NEG { + break + } + x := v_0.Args[0] + v.reset(OpRISCV64SEQZ) + v.AddArg(x) + return true + } + // match: (SEQZ (SEQZ x)) + // result: (SNEZ x) + for { + if v_0.Op != OpRISCV64SEQZ { + break + } + x := v_0.Args[0] + v.reset(OpRISCV64SNEZ) + v.AddArg(x) + return true + } + // match: (SEQZ (SNEZ x)) + // result: (SEQZ x) + for { + if v_0.Op != OpRISCV64SNEZ { + break + } + x := v_0.Args[0] + v.reset(OpRISCV64SEQZ) + v.AddArg(x) + return true + } + // match: (SEQZ (ANDI [c] (FCLASSD (FNEGD x)))) + // result: (SEQZ (ANDI [(c&0b11_0000_0000)|int64(bits.Reverse8(uint8(c))&0b1111_1111)] (FCLASSD x))) + for { + if v_0.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRISCV64FCLASSD { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpRISCV64FNEGD { + break + } + x := v_0_0_0.Args[0] + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt((c & 0b11_0000_0000) | int64(bits.Reverse8(uint8(c))&0b1111_1111)) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (SEQZ (ANDI [c] (FCLASSD (FABSD x)))) + // result: (SEQZ (ANDI [(c&0b11_1111_0000)|int64(bits.Reverse8(uint8(c))&0b0000_1111)] (FCLASSD x))) + for { + if v_0.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRISCV64FCLASSD { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpRISCV64FABSD { + break + } + x := v_0_0_0.Args[0] + v.reset(OpRISCV64SEQZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt((c & 0b11_1111_0000) | int64(bits.Reverse8(uint8(c))&0b0000_1111)) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLL x (MOVDconst [val])) + // result: (SLLI [val&63] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + v.reset(OpRISCV64SLLI) + v.AuxInt = int64ToAuxInt(val & 63) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SLLI(v *Value) bool { + v_0 := v.Args[0] + // match: (SLLI [x] (MOVDconst [y])) + // cond: is32Bit(y << uint32(x)) + // result: (MOVDconst [y << uint32(x)]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVDconst { + break + } + y := auxIntToInt64(v_0.AuxInt) + if !(is32Bit(y << uint32(x))) { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(y << uint32(x)) + return true + } + // match: (SLLI [c] (ADD x x)) + // cond: c < t.Size() * 8 - 1 + // result: (SLLI [c+1] x) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64ADD { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || !(c < t.Size()*8-1) { + break + } + v.reset(OpRISCV64SLLI) + v.AuxInt = int64ToAuxInt(c + 1) + v.AddArg(x) + return true + } + // match: (SLLI [c] (ADD x x)) + // cond: c >= t.Size() * 8 - 1 + // result: (MOVDconst [0]) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64ADD { + break + } + x := v_0.Args[1] + if x != v_0.Args[0] || !(c >= t.Size()*8-1) { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SLLW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLLW x (MOVDconst [val])) + // result: (SLLIW [val&31] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + v.reset(OpRISCV64SLLIW) + v.AuxInt = int64ToAuxInt(val & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SLT(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLT x (MOVDconst [val])) + // cond: is12Bit(val) + // result: (SLTI [val] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + if !(is12Bit(val)) { + break + } + v.reset(OpRISCV64SLTI) + v.AuxInt = int64ToAuxInt(val) + v.AddArg(x) + return true + } + // match: (SLT x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SLTI(v *Value) bool { + v_0 := v.Args[0] + // match: (SLTI [x] (MOVDconst [y])) + // result: (MOVDconst [b2i(int64(y) < int64(x))]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVDconst { + break + } + y := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(int64(y) < int64(x))) + return true + } + // match: (SLTI [x] (ANDI [y] _)) + // cond: y >= 0 && int64(y) < int64(x) + // result: (MOVDconst [1]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64ANDI { + break + } + y := auxIntToInt64(v_0.AuxInt) + if !(y >= 0 && int64(y) < int64(x)) { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SLTIU(v *Value) bool { + v_0 := v.Args[0] + // match: (SLTIU [x] (MOVDconst [y])) + // result: (MOVDconst [b2i(uint64(y) < uint64(x))]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVDconst { + break + } + y := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(b2i(uint64(y) < uint64(x))) + return true + } + // match: (SLTIU [x] (ANDI [y] _)) + // cond: y >= 0 && uint64(y) < uint64(x) + // result: (MOVDconst [1]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64ANDI { + break + } + y := auxIntToInt64(v_0.AuxInt) + if !(y >= 0 && uint64(y) < uint64(x)) { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (SLTIU [x] (ORI [y] _)) + // cond: y >= 0 && uint64(y) >= uint64(x) + // result: (MOVDconst [0]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64ORI { + break + } + y := auxIntToInt64(v_0.AuxInt) + if !(y >= 0 && uint64(y) >= uint64(x)) { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SLTU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SLTU x (MOVDconst [val])) + // cond: is12Bit(val) + // result: (SLTIU [val] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + if !(is12Bit(val)) { + break + } + v.reset(OpRISCV64SLTIU) + v.AuxInt = int64ToAuxInt(val) + v.AddArg(x) + return true + } + // match: (SLTU x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SNEZ(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SNEZ (NEG x)) + // result: (SNEZ x) + for { + if v_0.Op != OpRISCV64NEG { + break + } + x := v_0.Args[0] + v.reset(OpRISCV64SNEZ) + v.AddArg(x) + return true + } + // match: (SNEZ (SEQZ x)) + // result: (SEQZ x) + for { + if v_0.Op != OpRISCV64SEQZ { + break + } + x := v_0.Args[0] + v.reset(OpRISCV64SEQZ) + v.AddArg(x) + return true + } + // match: (SNEZ (SNEZ x)) + // result: (SNEZ x) + for { + if v_0.Op != OpRISCV64SNEZ { + break + } + x := v_0.Args[0] + v.reset(OpRISCV64SNEZ) + v.AddArg(x) + return true + } + // match: (SNEZ (ANDI [c] (FCLASSD (FNEGD x)))) + // result: (SNEZ (ANDI [(c&0b11_0000_0000)|int64(bits.Reverse8(uint8(c))&0b1111_1111)] (FCLASSD x))) + for { + if v_0.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRISCV64FCLASSD { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpRISCV64FNEGD { + break + } + x := v_0_0_0.Args[0] + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt((c & 0b11_0000_0000) | int64(bits.Reverse8(uint8(c))&0b1111_1111)) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (SNEZ (ANDI [c] (FCLASSD (FABSD x)))) + // result: (SNEZ (ANDI [(c&0b11_1111_0000)|int64(bits.Reverse8(uint8(c))&0b0000_1111)] (FCLASSD x))) + for { + if v_0.Op != OpRISCV64ANDI { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRISCV64FCLASSD { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpRISCV64FABSD { + break + } + x := v_0_0_0.Args[0] + v.reset(OpRISCV64SNEZ) + v0 := b.NewValue0(v.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt((c & 0b11_1111_0000) | int64(bits.Reverse8(uint8(c))&0b0000_1111)) + v1 := b.NewValue0(v.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SRA(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRA x (MOVDconst [val])) + // result: (SRAI [val&63] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + v.reset(OpRISCV64SRAI) + v.AuxInt = int64ToAuxInt(val & 63) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SRAI(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (SRAI [x] (MOVWreg y)) + // cond: x >= 0 && x <= 31 + // result: (SRAIW [x] y) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVWreg { + break + } + y := v_0.Args[0] + if !(x >= 0 && x <= 31) { + break + } + v.reset(OpRISCV64SRAIW) + v.AuxInt = int64ToAuxInt(x) + v.AddArg(y) + return true + } + // match: (SRAI [x] (MOVBreg y)) + // cond: x >= 8 + // result: (SRAI [63] (SLLI [56] y)) + for { + t := v.Type + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVBreg { + break + } + y := v_0.Args[0] + if !(x >= 8) { + break + } + v.reset(OpRISCV64SRAI) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, t) + v0.AuxInt = int64ToAuxInt(56) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (SRAI [x] (MOVHreg y)) + // cond: x >= 16 + // result: (SRAI [63] (SLLI [48] y)) + for { + t := v.Type + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVHreg { + break + } + y := v_0.Args[0] + if !(x >= 16) { + break + } + v.reset(OpRISCV64SRAI) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, t) + v0.AuxInt = int64ToAuxInt(48) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (SRAI [x] (MOVWreg y)) + // cond: x >= 32 + // result: (SRAIW [31] y) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVWreg { + break + } + y := v_0.Args[0] + if !(x >= 32) { + break + } + v.reset(OpRISCV64SRAIW) + v.AuxInt = int64ToAuxInt(31) + v.AddArg(y) + return true + } + // match: (SRAI [x] (MOVDconst [y])) + // result: (MOVDconst [int64(y) >> uint32(x)]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVDconst { + break + } + y := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(y) >> uint32(x)) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SRAW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRAW x (MOVDconst [val])) + // result: (SRAIW [val&31] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + v.reset(OpRISCV64SRAIW) + v.AuxInt = int64ToAuxInt(val & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SRL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRL x (MOVDconst [val])) + // result: (SRLI [val&63] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + v.reset(OpRISCV64SRLI) + v.AuxInt = int64ToAuxInt(val & 63) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SRLI(v *Value) bool { + v_0 := v.Args[0] + // match: (SRLI [x] (MOVWUreg y)) + // cond: x >= 0 && x <= 31 + // result: (SRLIW [x] y) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVWUreg { + break + } + y := v_0.Args[0] + if !(x >= 0 && x <= 31) { + break + } + v.reset(OpRISCV64SRLIW) + v.AuxInt = int64ToAuxInt(x) + v.AddArg(y) + return true + } + // match: (SRLI [x] (MOVBUreg y)) + // cond: x >= 8 + // result: (MOVDconst [0]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVBUreg { + break + } + if !(x >= 8) { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLI [x] (MOVHUreg y)) + // cond: x >= 16 + // result: (MOVDconst [0]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVHUreg { + break + } + if !(x >= 16) { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLI [x] (MOVWUreg y)) + // cond: x >= 32 + // result: (MOVDconst [0]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVWUreg { + break + } + if !(x >= 32) { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRLI [x] (MOVDconst [y])) + // result: (MOVDconst [int64(uint64(y) >> uint32(x))]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVDconst { + break + } + y := auxIntToInt64(v_0.AuxInt) + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint64(y) >> uint32(x))) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SRLW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SRLW x (MOVDconst [val])) + // result: (SRLIW [val&31] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + v.reset(OpRISCV64SRLIW) + v.AuxInt = int64ToAuxInt(val & 31) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SUB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUB x (NEG y)) + // result: (ADD x y) + for { + x := v_0 + if v_1.Op != OpRISCV64NEG { + break + } + y := v_1.Args[0] + v.reset(OpRISCV64ADD) + v.AddArg2(x, y) + return true + } + // match: (SUB x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SUB x (MOVDconst [val])) + // cond: is32Bit(-val) + // result: (ADDI [-val] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(-val)) { + break + } + v.reset(OpRISCV64ADDI) + v.AuxInt = int64ToAuxInt(-val) + v.AddArg(x) + return true + } + // match: (SUB (MOVDconst [val]) y) + // cond: is32Bit(-val) + // result: (NEG (ADDI [-val] y)) + for { + t := v.Type + if v_0.Op != OpRISCV64MOVDconst { + break + } + val := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(is32Bit(-val)) { + break + } + v.reset(OpRISCV64NEG) + v0 := b.NewValue0(v.Pos, OpRISCV64ADDI, t) + v0.AuxInt = int64ToAuxInt(-val) + v0.AddArg(y) + v.AddArg(v0) + return true + } + // match: (SUB x (MOVDconst [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (SUB (MOVDconst [0]) x) + // result: (NEG x) + for { + if v_0.Op != OpRISCV64MOVDconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpRISCV64NEG) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64SUBW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBW x (MOVDconst [0])) + // result: (ADDIW [0] x) + for { + x := v_0 + if v_1.Op != OpRISCV64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.reset(OpRISCV64ADDIW) + v.AuxInt = int64ToAuxInt(0) + v.AddArg(x) + return true + } + // match: (SUBW (MOVDconst [0]) x) + // result: (NEGW x) + for { + if v_0.Op != OpRISCV64MOVDconst || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpRISCV64NEGW) + v.AddArg(x) + return true + } + return false +} +func rewriteValueRISCV64_OpRISCV64XOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XOR (MOVDconst [val]) x) + // cond: is32Bit(val) + // result: (XORI [val] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpRISCV64MOVDconst { + continue + } + val := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(val)) { + continue + } + v.reset(OpRISCV64XORI) + v.AuxInt = int64ToAuxInt(val) + v.AddArg(x) + return true + } + break + } + // match: (XOR x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpRISCV64MOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValueRISCV64_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft16 x y) + // result: (OR (SLL x (ANDI [15] y)) (SRL (ZeroExt16to64 x) (ANDI [15] (NEG y)))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpRISCV64OR) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v1 := b.NewValue0(v.Pos, OpRISCV64ANDI, y.Type) + v1.AuxInt = int64ToAuxInt(15) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpRISCV64ANDI, y.Type) + v4.AuxInt = int64ToAuxInt(15) + v5 := b.NewValue0(v.Pos, OpRISCV64NEG, y.Type) + v5.AddArg(y) + v4.AddArg(v5) + v2.AddArg2(v3, v4) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueRISCV64_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft8 x y) + // result: (OR (SLL x (ANDI [7] y)) (SRL (ZeroExt8to64 x) (ANDI [7] (NEG y)))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpRISCV64OR) + v0 := b.NewValue0(v.Pos, OpRISCV64SLL, t) + v1 := b.NewValue0(v.Pos, OpRISCV64ANDI, y.Type) + v1.AuxInt = int64ToAuxInt(7) + v1.AddArg(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpRISCV64ANDI, y.Type) + v4.AuxInt = int64ToAuxInt(7) + v5 := b.NewValue0(v.Pos, OpRISCV64NEG, y.Type) + v5.AddArg(y) + v4.AddArg(v5) + v2.AddArg2(v3, v4) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueRISCV64_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL (ZeroExt16to64 x) y) (Neg16 (SLTIU [64] (ZeroExt16to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpNeg16, t) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } + // match: (Rsh16Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL (ZeroExt16to64 x) y) (Neg16 (SLTIU [64] (ZeroExt32to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpNeg16, t) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } + // match: (Rsh16Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL (ZeroExt16to64 x) y) (Neg16 (SLTIU [64] y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpNeg16, t) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v3.AuxInt = int64ToAuxInt(64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } + // match: (Rsh16Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL (ZeroExt16to64 x) y) (Neg16 (SLTIU [64] (ZeroExt8to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpNeg16, t) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } + // match: (Rsh16Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) (OR y (ADDI [-1] (SLTIU [64] (ZeroExt16to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v2.AuxInt = int64ToAuxInt(-1) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v1.AddArg2(y, v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) (OR y (ADDI [-1] (SLTIU [64] (ZeroExt32to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v2.AuxInt = int64ToAuxInt(-1) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v1.AddArg2(y, v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) (OR y (ADDI [-1] (SLTIU [64] y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v2.AuxInt = int64ToAuxInt(-1) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v3.AuxInt = int64ToAuxInt(64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg2(y, v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) (OR y (ADDI [-1] (SLTIU [64] (ZeroExt8to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v2.AuxInt = int64ToAuxInt(-1) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v1.AddArg2(y, v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt16to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRLW x y) (Neg32 (SLTIU [32] (ZeroExt16to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg32, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(32) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRLW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRLW x y) (Neg32 (SLTIU [32] (ZeroExt32to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg32, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(32) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRLW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRLW x y) (Neg32 (SLTIU [32] y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg32, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRLW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRLW x y) (Neg32 (SLTIU [32] (ZeroExt8to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg32, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(32) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh32Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRLW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRAW x (OR y (ADDI [-1] (SLTIU [32] (ZeroExt16to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRAW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v1.AuxInt = int64ToAuxInt(-1) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v2.AuxInt = int64ToAuxInt(32) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRAW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRAW x (OR y (ADDI [-1] (SLTIU [32] (ZeroExt32to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRAW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v1.AuxInt = int64ToAuxInt(-1) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v2.AuxInt = int64ToAuxInt(32) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRAW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRAW x (OR y (ADDI [-1] (SLTIU [32] y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRAW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v1.AuxInt = int64ToAuxInt(-1) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v2.AuxInt = int64ToAuxInt(32) + v2.AddArg(y) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRAW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRAW x (OR y (ADDI [-1] (SLTIU [32] (ZeroExt8to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRAW) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v1.AuxInt = int64ToAuxInt(-1) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v2.AuxInt = int64ToAuxInt(32) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRAW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh64Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL x y) (Neg64 (SLTIU [64] (ZeroExt16to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg64, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh64Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh64Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL x y) (Neg64 (SLTIU [64] (ZeroExt32to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg64, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh64Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh64Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL x y) (Neg64 (SLTIU [64] y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg64, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh64Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh64Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL x y) (Neg64 (SLTIU [64] (ZeroExt8to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpNeg64, t) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh64Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRL x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (OR y (ADDI [-1] (SLTIU [64] (ZeroExt16to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v1.AuxInt = int64ToAuxInt(-1) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (OR y (ADDI [-1] (SLTIU [64] (ZeroExt32to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v1.AuxInt = int64ToAuxInt(-1) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (OR y (ADDI [-1] (SLTIU [64] y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v1.AuxInt = int64ToAuxInt(-1) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v2.AuxInt = int64ToAuxInt(64) + v2.AddArg(y) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRA x (OR y (ADDI [-1] (SLTIU [64] (ZeroExt8to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v1 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v1.AuxInt = int64ToAuxInt(-1) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v2.AuxInt = int64ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg(v2) + v0.AddArg2(y, v1) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SRA x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux16 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL (ZeroExt8to64 x) y) (Neg8 (SLTIU [64] (ZeroExt16to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpNeg8, t) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } + // match: (Rsh8Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux32 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL (ZeroExt8to64 x) y) (Neg8 (SLTIU [64] (ZeroExt32to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpNeg8, t) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } + // match: (Rsh8Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL (ZeroExt8to64 x) y) (Neg8 (SLTIU [64] y))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpNeg8, t) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v3.AuxInt = int64ToAuxInt(64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } + // match: (Rsh8Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux8 x y) + // cond: !shiftIsBounded(v) + // result: (AND (SRL (ZeroExt8to64 x) y) (Neg8 (SLTIU [64] (ZeroExt8to64 y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64AND) + v0 := b.NewValue0(v.Pos, OpRISCV64SRL, t) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpNeg8, t) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, t) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } + // match: (Rsh8Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRL (ZeroExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRL) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x16 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) (OR y (ADDI [-1] (SLTIU [64] (ZeroExt16to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v2.AuxInt = int64ToAuxInt(-1) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v1.AddArg2(y, v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x32 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) (OR y (ADDI [-1] (SLTIU [64] (ZeroExt32to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v2.AuxInt = int64ToAuxInt(-1) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v1.AddArg2(y, v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x64 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) (OR y (ADDI [-1] (SLTIU [64] y)))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v2.AuxInt = int64ToAuxInt(-1) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v3.AuxInt = int64ToAuxInt(64) + v3.AddArg(y) + v2.AddArg(v3) + v1.AddArg2(y, v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x8 x y) + // cond: !shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) (OR y (ADDI [-1] (SLTIU [64] (ZeroExt8to64 y))))) + for { + t := v.Type + x := v_0 + y := v_1 + if !(!shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v.Type = t + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpRISCV64OR, y.Type) + v2 := b.NewValue0(v.Pos, OpRISCV64ADDI, y.Type) + v2.AuxInt = int64ToAuxInt(-1) + v3 := b.NewValue0(v.Pos, OpRISCV64SLTIU, y.Type) + v3.AuxInt = int64ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v2.AddArg(v3) + v1.AddArg2(y, v2) + v.AddArg2(v0, v1) + return true + } + // match: (Rsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SRA (SignExt8to64 x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpRISCV64SRA) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + return false +} +func rewriteValueRISCV64_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select0 (Add64carry x y c)) + // result: (ADD (ADD x y) c) + for { + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpRISCV64ADD) + v0 := b.NewValue0(v.Pos, OpRISCV64ADD, typ.UInt64) + v0.AddArg2(x, y) + v.AddArg2(v0, c) + return true + } + // match: (Select0 (Sub64borrow x y c)) + // result: (SUB (SUB x y) c) + for { + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpRISCV64SUB) + v0 := b.NewValue0(v.Pos, OpRISCV64SUB, typ.UInt64) + v0.AddArg2(x, y) + v.AddArg2(v0, c) + return true + } + // match: (Select0 m:(LoweredMuluhilo x y)) + // cond: m.Uses == 1 + // result: (MULHU x y) + for { + m := v_0 + if m.Op != OpRISCV64LoweredMuluhilo { + break + } + y := m.Args[1] + x := m.Args[0] + if !(m.Uses == 1) { + break + } + v.reset(OpRISCV64MULHU) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select1 (Add64carry x y c)) + // result: (OR (SLTU s:(ADD x y) x) (SLTU (ADD s c) s)) + for { + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpRISCV64OR) + v0 := b.NewValue0(v.Pos, OpRISCV64SLTU, typ.UInt64) + s := b.NewValue0(v.Pos, OpRISCV64ADD, typ.UInt64) + s.AddArg2(x, y) + v0.AddArg2(s, x) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTU, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpRISCV64ADD, typ.UInt64) + v3.AddArg2(s, c) + v2.AddArg2(v3, s) + v.AddArg2(v0, v2) + return true + } + // match: (Select1 (Sub64borrow x y c)) + // result: (OR (SLTU x s:(SUB x y)) (SLTU s (SUB s c))) + for { + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpRISCV64OR) + v0 := b.NewValue0(v.Pos, OpRISCV64SLTU, typ.UInt64) + s := b.NewValue0(v.Pos, OpRISCV64SUB, typ.UInt64) + s.AddArg2(x, y) + v0.AddArg2(x, s) + v2 := b.NewValue0(v.Pos, OpRISCV64SLTU, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpRISCV64SUB, typ.UInt64) + v3.AddArg2(s, c) + v2.AddArg2(s, v3) + v.AddArg2(v0, v2) + return true + } + // match: (Select1 m:(LoweredMuluhilo x y)) + // cond: m.Uses == 1 + // result: (MUL x y) + for { + m := v_0 + if m.Op != OpRISCV64LoweredMuluhilo { + break + } + y := m.Args[1] + x := m.Args[0] + if !(m.Uses == 1) { + break + } + v.reset(OpRISCV64MUL) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Slicemask x) + // result: (SRAI [63] (NEG x)) + for { + t := v.Type + x := v_0 + v.reset(OpRISCV64SRAI) + v.AuxInt = int64ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpRISCV64NEG, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueRISCV64_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (MOVBstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(OpRISCV64MOVBstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (MOVHstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(OpRISCV64MOVHstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && !t.IsFloat() + // result: (MOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && !t.IsFloat()) { + break + } + v.reset(OpRISCV64MOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && !t.IsFloat() + // result: (MOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && !t.IsFloat()) { + break + } + v.reset(OpRISCV64MOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && t.IsFloat() + // result: (FMOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && t.IsFloat()) { + break + } + v.reset(OpRISCV64FMOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && t.IsFloat() + // result: (FMOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && t.IsFloat()) { + break + } + v.reset(OpRISCV64FMOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueRISCV64_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] ptr mem) + // result: (MOVBstore ptr (MOVDconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpRISCV64MOVBstore) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [2] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore ptr (MOVDconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpRISCV64MOVHstore) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [2] ptr mem) + // result: (MOVBstore [1] ptr (MOVDconst [0]) (MOVBstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(1) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [4] {t} ptr mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore ptr (MOVDconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpRISCV64MOVWstore) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [4] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [2] ptr (MOVDconst [0]) (MOVHstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [4] ptr mem) + // result: (MOVBstore [3] ptr (MOVDconst [0]) (MOVBstore [2] ptr (MOVDconst [0]) (MOVBstore [1] ptr (MOVDconst [0]) (MOVBstore ptr (MOVDconst [0]) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(1) + v3 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v3.AddArg3(ptr, v0, mem) + v2.AddArg3(ptr, v0, v3) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [8] {t} ptr mem) + // cond: t.Alignment()%8 == 0 + // result: (MOVDstore ptr (MOVDconst [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%8 == 0) { + break + } + v.reset(OpRISCV64MOVDstore) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(ptr, v0, mem) + return true + } + // match: (Zero [8] {t} ptr mem) + // cond: t.Alignment()%4 == 0 + // result: (MOVWstore [4] ptr (MOVDconst [0]) (MOVWstore ptr (MOVDconst [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%4 == 0) { + break + } + v.reset(OpRISCV64MOVWstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVWstore, types.TypeMem) + v1.AddArg3(ptr, v0, mem) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [8] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [6] ptr (MOVDconst [0]) (MOVHstore [4] ptr (MOVDconst [0]) (MOVHstore [2] ptr (MOVDconst [0]) (MOVHstore ptr (MOVDconst [0]) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v2.AuxInt = int32ToAuxInt(2) + v3 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v3.AddArg3(ptr, v0, mem) + v2.AddArg3(ptr, v0, v3) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [3] ptr mem) + // result: (MOVBstore [2] ptr (MOVDconst [0]) (MOVBstore [1] ptr (MOVDconst [0]) (MOVBstore ptr (MOVDconst [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + ptr := v_0 + mem := v_1 + v.reset(OpRISCV64MOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVBstore, types.TypeMem) + v2.AddArg3(ptr, v0, mem) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [6] {t} ptr mem) + // cond: t.Alignment()%2 == 0 + // result: (MOVHstore [4] ptr (MOVDconst [0]) (MOVHstore [2] ptr (MOVDconst [0]) (MOVHstore ptr (MOVDconst [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(t.Alignment()%2 == 0) { + break + } + v.reset(OpRISCV64MOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(2) + v2 := b.NewValue0(v.Pos, OpRISCV64MOVHstore, types.TypeMem) + v2.AddArg3(ptr, v0, mem) + v1.AddArg3(ptr, v0, v2) + v.AddArg3(ptr, v0, v1) + return true + } + // match: (Zero [s] {t} ptr mem) + // cond: s <= 24*moveSize(t.Alignment(), config) + // result: (LoweredZero [makeValAndOff(int32(s),int32(t.Alignment()))] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(s <= 24*moveSize(t.Alignment(), config)) { + break + } + v.reset(OpRISCV64LoweredZero) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(s), int32(t.Alignment()))) + v.AddArg2(ptr, mem) + return true + } + // match: (Zero [s] {t} ptr mem) + // cond: s > 24*moveSize(t.Alignment(), config) + // result: (LoweredZeroLoop [makeValAndOff(int32(s),int32(t.Alignment()))] ptr mem) + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + ptr := v_0 + mem := v_1 + if !(s > 24*moveSize(t.Alignment(), config)) { + break + } + v.reset(OpRISCV64LoweredZeroLoop) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(s), int32(t.Alignment()))) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteBlockRISCV64(b *Block) bool { + typ := &b.Func.Config.Types + switch b.Kind { + case BlockRISCV64BEQ: + // match: (BEQ (MOVDconst [0]) cond yes no) + // result: (BEQZ cond yes no) + for b.Controls[0].Op == OpRISCV64MOVDconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockRISCV64BEQZ, cond) + return true + } + // match: (BEQ cond (MOVDconst [0]) yes no) + // result: (BEQZ cond yes no) + for b.Controls[1].Op == OpRISCV64MOVDconst { + cond := b.Controls[0] + v_1 := b.Controls[1] + if auxIntToInt64(v_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockRISCV64BEQZ, cond) + return true + } + case BlockRISCV64BEQZ: + // match: (BEQZ (SEQZ x) yes no) + // result: (BNEZ x yes no) + for b.Controls[0].Op == OpRISCV64SEQZ { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockRISCV64BNEZ, x) + return true + } + // match: (BEQZ (SNEZ x) yes no) + // result: (BEQZ x yes no) + for b.Controls[0].Op == OpRISCV64SNEZ { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockRISCV64BEQZ, x) + return true + } + // match: (BEQZ (NEG x) yes no) + // result: (BEQZ x yes no) + for b.Controls[0].Op == OpRISCV64NEG { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockRISCV64BEQZ, x) + return true + } + // match: (BEQZ (FNES x y) yes no) + // result: (BNEZ (FEQS x y) yes no) + for b.Controls[0].Op == OpRISCV64FNES { + v_0 := b.Controls[0] + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + v0 := b.NewValue0(v_0.Pos, OpRISCV64FEQS, t) + v0.AddArg2(x, y) + b.resetWithControl(BlockRISCV64BNEZ, v0) + return true + } + } + // match: (BEQZ (FNED x y) yes no) + // result: (BNEZ (FEQD x y) yes no) + for b.Controls[0].Op == OpRISCV64FNED { + v_0 := b.Controls[0] + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + v0 := b.NewValue0(v_0.Pos, OpRISCV64FEQD, t) + v0.AddArg2(x, y) + b.resetWithControl(BlockRISCV64BNEZ, v0) + return true + } + } + // match: (BEQZ (SUB x y) yes no) + // result: (BEQ x y yes no) + for b.Controls[0].Op == OpRISCV64SUB { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockRISCV64BEQ, x, y) + return true + } + // match: (BEQZ (SLT x y) yes no) + // result: (BGE x y yes no) + for b.Controls[0].Op == OpRISCV64SLT { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockRISCV64BGE, x, y) + return true + } + // match: (BEQZ (SLTU x y) yes no) + // result: (BGEU x y yes no) + for b.Controls[0].Op == OpRISCV64SLTU { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockRISCV64BGEU, x, y) + return true + } + // match: (BEQZ (SLTI [x] y) yes no) + // result: (BGE y (MOVDconst [x]) yes no) + for b.Controls[0].Op == OpRISCV64SLTI { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + v0 := b.NewValue0(b.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(x) + b.resetWithControl2(BlockRISCV64BGE, y, v0) + return true + } + // match: (BEQZ (SLTIU [x] y) yes no) + // result: (BGEU y (MOVDconst [x]) yes no) + for b.Controls[0].Op == OpRISCV64SLTIU { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + v0 := b.NewValue0(b.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(x) + b.resetWithControl2(BlockRISCV64BGEU, y, v0) + return true + } + // match: (BEQZ (ANDI [c] (FCLASSD (FNEGD x))) yes no) + // result: (BEQZ (ANDI [(c&0b11_0000_0000)|int64(bits.Reverse8(uint8(c))&0b1111_1111)] (FCLASSD x)) yes no) + for b.Controls[0].Op == OpRISCV64ANDI { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRISCV64FCLASSD { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpRISCV64FNEGD { + break + } + x := v_0_0_0.Args[0] + v0 := b.NewValue0(v_0.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt((c & 0b11_0000_0000) | int64(bits.Reverse8(uint8(c))&0b1111_1111)) + v1 := b.NewValue0(v_0.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + b.resetWithControl(BlockRISCV64BEQZ, v0) + return true + } + // match: (BEQZ (ANDI [c] (FCLASSD (FABSD x))) yes no) + // result: (BEQZ (ANDI [(c&0b11_1111_0000)|int64(bits.Reverse8(uint8(c))&0b0000_1111)] (FCLASSD x)) yes no) + for b.Controls[0].Op == OpRISCV64ANDI { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRISCV64FCLASSD { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpRISCV64FABSD { + break + } + x := v_0_0_0.Args[0] + v0 := b.NewValue0(v_0.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt((c & 0b11_1111_0000) | int64(bits.Reverse8(uint8(c))&0b0000_1111)) + v1 := b.NewValue0(v_0.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + b.resetWithControl(BlockRISCV64BEQZ, v0) + return true + } + case BlockRISCV64BGE: + // match: (BGE (MOVDconst [0]) cond yes no) + // result: (BLEZ cond yes no) + for b.Controls[0].Op == OpRISCV64MOVDconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockRISCV64BLEZ, cond) + return true + } + // match: (BGE cond (MOVDconst [0]) yes no) + // result: (BGEZ cond yes no) + for b.Controls[1].Op == OpRISCV64MOVDconst { + cond := b.Controls[0] + v_1 := b.Controls[1] + if auxIntToInt64(v_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockRISCV64BGEZ, cond) + return true + } + case BlockRISCV64BGEU: + // match: (BGEU (MOVDconst [0]) cond yes no) + // result: (BEQZ cond yes no) + for b.Controls[0].Op == OpRISCV64MOVDconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockRISCV64BEQZ, cond) + return true + } + case BlockRISCV64BLT: + // match: (BLT (MOVDconst [0]) cond yes no) + // result: (BGTZ cond yes no) + for b.Controls[0].Op == OpRISCV64MOVDconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockRISCV64BGTZ, cond) + return true + } + // match: (BLT cond (MOVDconst [0]) yes no) + // result: (BLTZ cond yes no) + for b.Controls[1].Op == OpRISCV64MOVDconst { + cond := b.Controls[0] + v_1 := b.Controls[1] + if auxIntToInt64(v_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockRISCV64BLTZ, cond) + return true + } + case BlockRISCV64BLTU: + // match: (BLTU (MOVDconst [0]) cond yes no) + // result: (BNEZ cond yes no) + for b.Controls[0].Op == OpRISCV64MOVDconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockRISCV64BNEZ, cond) + return true + } + case BlockRISCV64BNE: + // match: (BNE (MOVDconst [0]) cond yes no) + // result: (BNEZ cond yes no) + for b.Controls[0].Op == OpRISCV64MOVDconst { + v_0 := b.Controls[0] + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + cond := b.Controls[1] + b.resetWithControl(BlockRISCV64BNEZ, cond) + return true + } + // match: (BNE cond (MOVDconst [0]) yes no) + // result: (BNEZ cond yes no) + for b.Controls[1].Op == OpRISCV64MOVDconst { + cond := b.Controls[0] + v_1 := b.Controls[1] + if auxIntToInt64(v_1.AuxInt) != 0 { + break + } + b.resetWithControl(BlockRISCV64BNEZ, cond) + return true + } + case BlockRISCV64BNEZ: + // match: (BNEZ (SEQZ x) yes no) + // result: (BEQZ x yes no) + for b.Controls[0].Op == OpRISCV64SEQZ { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockRISCV64BEQZ, x) + return true + } + // match: (BNEZ (SNEZ x) yes no) + // result: (BNEZ x yes no) + for b.Controls[0].Op == OpRISCV64SNEZ { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockRISCV64BNEZ, x) + return true + } + // match: (BNEZ (NEG x) yes no) + // result: (BNEZ x yes no) + for b.Controls[0].Op == OpRISCV64NEG { + v_0 := b.Controls[0] + x := v_0.Args[0] + b.resetWithControl(BlockRISCV64BNEZ, x) + return true + } + // match: (BNEZ (FNES x y) yes no) + // result: (BEQZ (FEQS x y) yes no) + for b.Controls[0].Op == OpRISCV64FNES { + v_0 := b.Controls[0] + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + v0 := b.NewValue0(v_0.Pos, OpRISCV64FEQS, t) + v0.AddArg2(x, y) + b.resetWithControl(BlockRISCV64BEQZ, v0) + return true + } + } + // match: (BNEZ (FNED x y) yes no) + // result: (BEQZ (FEQD x y) yes no) + for b.Controls[0].Op == OpRISCV64FNED { + v_0 := b.Controls[0] + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + v0 := b.NewValue0(v_0.Pos, OpRISCV64FEQD, t) + v0.AddArg2(x, y) + b.resetWithControl(BlockRISCV64BEQZ, v0) + return true + } + } + // match: (BNEZ (SUB x y) yes no) + // result: (BNE x y yes no) + for b.Controls[0].Op == OpRISCV64SUB { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockRISCV64BNE, x, y) + return true + } + // match: (BNEZ (SLT x y) yes no) + // result: (BLT x y yes no) + for b.Controls[0].Op == OpRISCV64SLT { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockRISCV64BLT, x, y) + return true + } + // match: (BNEZ (SLTU x y) yes no) + // result: (BLTU x y yes no) + for b.Controls[0].Op == OpRISCV64SLTU { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + b.resetWithControl2(BlockRISCV64BLTU, x, y) + return true + } + // match: (BNEZ (SLTI [x] y) yes no) + // result: (BLT y (MOVDconst [x]) yes no) + for b.Controls[0].Op == OpRISCV64SLTI { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + v0 := b.NewValue0(b.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(x) + b.resetWithControl2(BlockRISCV64BLT, y, v0) + return true + } + // match: (BNEZ (SLTIU [x] y) yes no) + // result: (BLTU y (MOVDconst [x]) yes no) + for b.Controls[0].Op == OpRISCV64SLTIU { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := v_0.Args[0] + v0 := b.NewValue0(b.Pos, OpRISCV64MOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(x) + b.resetWithControl2(BlockRISCV64BLTU, y, v0) + return true + } + // match: (BNEZ (ANDI [c] (FCLASSD (FNEGD x))) yes no) + // result: (BNEZ (ANDI [(c&0b11_0000_0000)|int64(bits.Reverse8(uint8(c))&0b1111_1111)] (FCLASSD x)) yes no) + for b.Controls[0].Op == OpRISCV64ANDI { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRISCV64FCLASSD { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpRISCV64FNEGD { + break + } + x := v_0_0_0.Args[0] + v0 := b.NewValue0(v_0.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt((c & 0b11_0000_0000) | int64(bits.Reverse8(uint8(c))&0b1111_1111)) + v1 := b.NewValue0(v_0.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + b.resetWithControl(BlockRISCV64BNEZ, v0) + return true + } + // match: (BNEZ (ANDI [c] (FCLASSD (FABSD x))) yes no) + // result: (BNEZ (ANDI [(c&0b11_1111_0000)|int64(bits.Reverse8(uint8(c))&0b0000_1111)] (FCLASSD x)) yes no) + for b.Controls[0].Op == OpRISCV64ANDI { + v_0 := b.Controls[0] + c := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRISCV64FCLASSD { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpRISCV64FABSD { + break + } + x := v_0_0_0.Args[0] + v0 := b.NewValue0(v_0.Pos, OpRISCV64ANDI, typ.Int64) + v0.AuxInt = int64ToAuxInt((c & 0b11_1111_0000) | int64(bits.Reverse8(uint8(c))&0b0000_1111)) + v1 := b.NewValue0(v_0.Pos, OpRISCV64FCLASSD, typ.Int64) + v1.AddArg(x) + v0.AddArg(v1) + b.resetWithControl(BlockRISCV64BNEZ, v0) + return true + } + case BlockIf: + // match: (If cond yes no) + // result: (BNEZ (MOVBUreg cond) yes no) + for { + cond := b.Controls[0] + v0 := b.NewValue0(cond.Pos, OpRISCV64MOVBUreg, typ.UInt64) + v0.AddArg(cond) + b.resetWithControl(BlockRISCV64BNEZ, v0) + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteRISCV64latelower.go b/go/src/cmd/compile/internal/ssa/rewriteRISCV64latelower.go new file mode 100644 index 0000000000000000000000000000000000000000..d2c3a8f73df2e9dbcbeb15046eff20718c443c16 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteRISCV64latelower.go @@ -0,0 +1,330 @@ +// Code generated from _gen/RISCV64latelower.rules using 'go generate'; DO NOT EDIT. + +package ssa + +func rewriteValueRISCV64latelower(v *Value) bool { + switch v.Op { + case OpRISCV64AND: + return rewriteValueRISCV64latelower_OpRISCV64AND(v) + case OpRISCV64NOT: + return rewriteValueRISCV64latelower_OpRISCV64NOT(v) + case OpRISCV64OR: + return rewriteValueRISCV64latelower_OpRISCV64OR(v) + case OpRISCV64SLLI: + return rewriteValueRISCV64latelower_OpRISCV64SLLI(v) + case OpRISCV64SRAI: + return rewriteValueRISCV64latelower_OpRISCV64SRAI(v) + case OpRISCV64SRLI: + return rewriteValueRISCV64latelower_OpRISCV64SRLI(v) + case OpRISCV64XOR: + return rewriteValueRISCV64latelower_OpRISCV64XOR(v) + } + return false +} +func rewriteValueRISCV64latelower_OpRISCV64AND(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AND x (NOT y)) + // result: (ANDN x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpRISCV64NOT { + continue + } + y := v_1.Args[0] + v.reset(OpRISCV64ANDN) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueRISCV64latelower_OpRISCV64NOT(v *Value) bool { + v_0 := v.Args[0] + // match: (NOT (XOR x y)) + // result: (XNOR x y) + for { + if v_0.Op != OpRISCV64XOR { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpRISCV64XNOR) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueRISCV64latelower_OpRISCV64OR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (OR x (NOT y)) + // result: (ORN x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpRISCV64NOT { + continue + } + y := v_1.Args[0] + v.reset(OpRISCV64ORN) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValueRISCV64latelower_OpRISCV64SLLI(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SLLI [c] (MOVBUreg x)) + // cond: c <= 56 + // result: (SRLI [56-c] (SLLI [56] x)) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVBUreg { + break + } + x := v_0.Args[0] + if !(c <= 56) { + break + } + v.reset(OpRISCV64SRLI) + v.AuxInt = int64ToAuxInt(56 - c) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64) + v0.AuxInt = int64ToAuxInt(56) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SLLI [c] (MOVHUreg x)) + // cond: c <= 48 + // result: (SRLI [48-c] (SLLI [48] x)) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVHUreg { + break + } + x := v_0.Args[0] + if !(c <= 48) { + break + } + v.reset(OpRISCV64SRLI) + v.AuxInt = int64ToAuxInt(48 - c) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64) + v0.AuxInt = int64ToAuxInt(48) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SLLI [c] (MOVWUreg x)) + // cond: c <= 32 + // result: (SRLI [32-c] (SLLI [32] x)) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVWUreg { + break + } + x := v_0.Args[0] + if !(c <= 32) { + break + } + v.reset(OpRISCV64SRLI) + v.AuxInt = int64ToAuxInt(32 - c) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64) + v0.AuxInt = int64ToAuxInt(32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SLLI [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueRISCV64latelower_OpRISCV64SRAI(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SRAI [c] (MOVBreg x)) + // cond: c < 8 + // result: (SRAI [56+c] (SLLI [56] x)) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVBreg { + break + } + x := v_0.Args[0] + if !(c < 8) { + break + } + v.reset(OpRISCV64SRAI) + v.AuxInt = int64ToAuxInt(56 + c) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.Int64) + v0.AuxInt = int64ToAuxInt(56) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SRAI [c] (MOVHreg x)) + // cond: c < 16 + // result: (SRAI [48+c] (SLLI [48] x)) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVHreg { + break + } + x := v_0.Args[0] + if !(c < 16) { + break + } + v.reset(OpRISCV64SRAI) + v.AuxInt = int64ToAuxInt(48 + c) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.Int64) + v0.AuxInt = int64ToAuxInt(48) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SRAI [c] (MOVWreg x)) + // cond: c < 32 + // result: (SRAI [32+c] (SLLI [32] x)) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVWreg { + break + } + x := v_0.Args[0] + if !(c < 32) { + break + } + v.reset(OpRISCV64SRAI) + v.AuxInt = int64ToAuxInt(32 + c) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.Int64) + v0.AuxInt = int64ToAuxInt(32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SRAI [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueRISCV64latelower_OpRISCV64SRLI(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SRLI [c] (MOVBUreg x)) + // cond: c < 8 + // result: (SRLI [56+c] (SLLI [56] x)) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVBUreg { + break + } + x := v_0.Args[0] + if !(c < 8) { + break + } + v.reset(OpRISCV64SRLI) + v.AuxInt = int64ToAuxInt(56 + c) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64) + v0.AuxInt = int64ToAuxInt(56) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SRLI [c] (MOVHUreg x)) + // cond: c < 16 + // result: (SRLI [48+c] (SLLI [48] x)) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVHUreg { + break + } + x := v_0.Args[0] + if !(c < 16) { + break + } + v.reset(OpRISCV64SRLI) + v.AuxInt = int64ToAuxInt(48 + c) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64) + v0.AuxInt = int64ToAuxInt(48) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SRLI [c] (MOVWUreg x)) + // cond: c < 32 + // result: (SRLI [32+c] (SLLI [32] x)) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpRISCV64MOVWUreg { + break + } + x := v_0.Args[0] + if !(c < 32) { + break + } + v.reset(OpRISCV64SRLI) + v.AuxInt = int64ToAuxInt(32 + c) + v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64) + v0.AuxInt = int64ToAuxInt(32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SRLI [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueRISCV64latelower_OpRISCV64XOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XOR x (NOT y)) + // result: (XNOR x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpRISCV64NOT { + continue + } + y := v_1.Args[0] + v.reset(OpRISCV64XNOR) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteBlockRISCV64latelower(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteS390X.go b/go/src/cmd/compile/internal/ssa/rewriteS390X.go new file mode 100644 index 0000000000000000000000000000000000000000..07dbe7bf7a697c8b7b3e5294a6541353ce5c45bd --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteS390X.go @@ -0,0 +1,16812 @@ +// Code generated from _gen/S390X.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "math" +import "cmd/compile/internal/types" +import "cmd/internal/obj/s390x" + +func rewriteValueS390X(v *Value) bool { + switch v.Op { + case OpAdd16: + v.Op = OpS390XADDW + return true + case OpAdd32: + v.Op = OpS390XADDW + return true + case OpAdd32F: + return rewriteValueS390X_OpAdd32F(v) + case OpAdd64: + v.Op = OpS390XADD + return true + case OpAdd64F: + return rewriteValueS390X_OpAdd64F(v) + case OpAdd8: + v.Op = OpS390XADDW + return true + case OpAddPtr: + v.Op = OpS390XADD + return true + case OpAddr: + return rewriteValueS390X_OpAddr(v) + case OpAnd16: + v.Op = OpS390XANDW + return true + case OpAnd32: + v.Op = OpS390XANDW + return true + case OpAnd64: + v.Op = OpS390XAND + return true + case OpAnd8: + v.Op = OpS390XANDW + return true + case OpAndB: + v.Op = OpS390XANDW + return true + case OpAtomicAdd32: + return rewriteValueS390X_OpAtomicAdd32(v) + case OpAtomicAdd64: + return rewriteValueS390X_OpAtomicAdd64(v) + case OpAtomicAnd32: + v.Op = OpS390XLAN + return true + case OpAtomicAnd8: + return rewriteValueS390X_OpAtomicAnd8(v) + case OpAtomicCompareAndSwap32: + return rewriteValueS390X_OpAtomicCompareAndSwap32(v) + case OpAtomicCompareAndSwap64: + return rewriteValueS390X_OpAtomicCompareAndSwap64(v) + case OpAtomicExchange32: + return rewriteValueS390X_OpAtomicExchange32(v) + case OpAtomicExchange64: + return rewriteValueS390X_OpAtomicExchange64(v) + case OpAtomicLoad32: + return rewriteValueS390X_OpAtomicLoad32(v) + case OpAtomicLoad64: + return rewriteValueS390X_OpAtomicLoad64(v) + case OpAtomicLoad8: + return rewriteValueS390X_OpAtomicLoad8(v) + case OpAtomicLoadAcq32: + return rewriteValueS390X_OpAtomicLoadAcq32(v) + case OpAtomicLoadPtr: + return rewriteValueS390X_OpAtomicLoadPtr(v) + case OpAtomicOr32: + v.Op = OpS390XLAO + return true + case OpAtomicOr8: + return rewriteValueS390X_OpAtomicOr8(v) + case OpAtomicStore32: + return rewriteValueS390X_OpAtomicStore32(v) + case OpAtomicStore64: + return rewriteValueS390X_OpAtomicStore64(v) + case OpAtomicStore8: + return rewriteValueS390X_OpAtomicStore8(v) + case OpAtomicStorePtrNoWB: + return rewriteValueS390X_OpAtomicStorePtrNoWB(v) + case OpAtomicStoreRel32: + return rewriteValueS390X_OpAtomicStoreRel32(v) + case OpAvg64u: + return rewriteValueS390X_OpAvg64u(v) + case OpBitLen16: + return rewriteValueS390X_OpBitLen16(v) + case OpBitLen32: + return rewriteValueS390X_OpBitLen32(v) + case OpBitLen64: + return rewriteValueS390X_OpBitLen64(v) + case OpBitLen8: + return rewriteValueS390X_OpBitLen8(v) + case OpBswap16: + return rewriteValueS390X_OpBswap16(v) + case OpBswap32: + v.Op = OpS390XMOVWBR + return true + case OpBswap64: + v.Op = OpS390XMOVDBR + return true + case OpCeil: + return rewriteValueS390X_OpCeil(v) + case OpClosureCall: + v.Op = OpS390XCALLclosure + return true + case OpCom16: + v.Op = OpS390XNOTW + return true + case OpCom32: + v.Op = OpS390XNOTW + return true + case OpCom64: + v.Op = OpS390XNOT + return true + case OpCom8: + v.Op = OpS390XNOTW + return true + case OpConst16: + return rewriteValueS390X_OpConst16(v) + case OpConst32: + return rewriteValueS390X_OpConst32(v) + case OpConst32F: + v.Op = OpS390XFMOVSconst + return true + case OpConst64: + return rewriteValueS390X_OpConst64(v) + case OpConst64F: + v.Op = OpS390XFMOVDconst + return true + case OpConst8: + return rewriteValueS390X_OpConst8(v) + case OpConstBool: + return rewriteValueS390X_OpConstBool(v) + case OpConstNil: + return rewriteValueS390X_OpConstNil(v) + case OpCtz16: + return rewriteValueS390X_OpCtz16(v) + case OpCtz16NonZero: + v.Op = OpCtz64 + return true + case OpCtz32: + return rewriteValueS390X_OpCtz32(v) + case OpCtz32NonZero: + v.Op = OpCtz64 + return true + case OpCtz64: + return rewriteValueS390X_OpCtz64(v) + case OpCtz64NonZero: + v.Op = OpCtz64 + return true + case OpCtz8: + return rewriteValueS390X_OpCtz8(v) + case OpCtz8NonZero: + v.Op = OpCtz64 + return true + case OpCvt32Fto32: + v.Op = OpS390XCFEBRA + return true + case OpCvt32Fto32U: + v.Op = OpS390XCLFEBR + return true + case OpCvt32Fto64: + v.Op = OpS390XCGEBRA + return true + case OpCvt32Fto64F: + v.Op = OpS390XLDEBR + return true + case OpCvt32Fto64U: + v.Op = OpS390XCLGEBR + return true + case OpCvt32Uto32F: + v.Op = OpS390XCELFBR + return true + case OpCvt32Uto64F: + v.Op = OpS390XCDLFBR + return true + case OpCvt32to32F: + v.Op = OpS390XCEFBRA + return true + case OpCvt32to64F: + v.Op = OpS390XCDFBRA + return true + case OpCvt64Fto32: + v.Op = OpS390XCFDBRA + return true + case OpCvt64Fto32F: + v.Op = OpS390XLEDBR + return true + case OpCvt64Fto32U: + v.Op = OpS390XCLFDBR + return true + case OpCvt64Fto64: + v.Op = OpS390XCGDBRA + return true + case OpCvt64Fto64U: + v.Op = OpS390XCLGDBR + return true + case OpCvt64Uto32F: + v.Op = OpS390XCELGBR + return true + case OpCvt64Uto64F: + v.Op = OpS390XCDLGBR + return true + case OpCvt64to32F: + v.Op = OpS390XCEGBRA + return true + case OpCvt64to64F: + v.Op = OpS390XCDGBRA + return true + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpDiv16: + return rewriteValueS390X_OpDiv16(v) + case OpDiv16u: + return rewriteValueS390X_OpDiv16u(v) + case OpDiv32: + return rewriteValueS390X_OpDiv32(v) + case OpDiv32F: + v.Op = OpS390XFDIVS + return true + case OpDiv32u: + return rewriteValueS390X_OpDiv32u(v) + case OpDiv64: + return rewriteValueS390X_OpDiv64(v) + case OpDiv64F: + v.Op = OpS390XFDIV + return true + case OpDiv64u: + v.Op = OpS390XDIVDU + return true + case OpDiv8: + return rewriteValueS390X_OpDiv8(v) + case OpDiv8u: + return rewriteValueS390X_OpDiv8u(v) + case OpEq16: + return rewriteValueS390X_OpEq16(v) + case OpEq32: + return rewriteValueS390X_OpEq32(v) + case OpEq32F: + return rewriteValueS390X_OpEq32F(v) + case OpEq64: + return rewriteValueS390X_OpEq64(v) + case OpEq64F: + return rewriteValueS390X_OpEq64F(v) + case OpEq8: + return rewriteValueS390X_OpEq8(v) + case OpEqB: + return rewriteValueS390X_OpEqB(v) + case OpEqPtr: + return rewriteValueS390X_OpEqPtr(v) + case OpFMA: + return rewriteValueS390X_OpFMA(v) + case OpFloor: + return rewriteValueS390X_OpFloor(v) + case OpGetCallerPC: + v.Op = OpS390XLoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = OpS390XLoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = OpS390XLoweredGetClosurePtr + return true + case OpGetG: + v.Op = OpS390XLoweredGetG + return true + case OpHmul32: + return rewriteValueS390X_OpHmul32(v) + case OpHmul32u: + return rewriteValueS390X_OpHmul32u(v) + case OpHmul64: + v.Op = OpS390XMULHD + return true + case OpHmul64u: + v.Op = OpS390XMULHDU + return true + case OpITab: + return rewriteValueS390X_OpITab(v) + case OpInterCall: + v.Op = OpS390XCALLinter + return true + case OpIsInBounds: + return rewriteValueS390X_OpIsInBounds(v) + case OpIsNonNil: + return rewriteValueS390X_OpIsNonNil(v) + case OpIsSliceInBounds: + return rewriteValueS390X_OpIsSliceInBounds(v) + case OpLeq16: + return rewriteValueS390X_OpLeq16(v) + case OpLeq16U: + return rewriteValueS390X_OpLeq16U(v) + case OpLeq32: + return rewriteValueS390X_OpLeq32(v) + case OpLeq32F: + return rewriteValueS390X_OpLeq32F(v) + case OpLeq32U: + return rewriteValueS390X_OpLeq32U(v) + case OpLeq64: + return rewriteValueS390X_OpLeq64(v) + case OpLeq64F: + return rewriteValueS390X_OpLeq64F(v) + case OpLeq64U: + return rewriteValueS390X_OpLeq64U(v) + case OpLeq8: + return rewriteValueS390X_OpLeq8(v) + case OpLeq8U: + return rewriteValueS390X_OpLeq8U(v) + case OpLess16: + return rewriteValueS390X_OpLess16(v) + case OpLess16U: + return rewriteValueS390X_OpLess16U(v) + case OpLess32: + return rewriteValueS390X_OpLess32(v) + case OpLess32F: + return rewriteValueS390X_OpLess32F(v) + case OpLess32U: + return rewriteValueS390X_OpLess32U(v) + case OpLess64: + return rewriteValueS390X_OpLess64(v) + case OpLess64F: + return rewriteValueS390X_OpLess64F(v) + case OpLess64U: + return rewriteValueS390X_OpLess64U(v) + case OpLess8: + return rewriteValueS390X_OpLess8(v) + case OpLess8U: + return rewriteValueS390X_OpLess8U(v) + case OpLoad: + return rewriteValueS390X_OpLoad(v) + case OpLocalAddr: + return rewriteValueS390X_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValueS390X_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValueS390X_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValueS390X_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValueS390X_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValueS390X_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValueS390X_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValueS390X_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValueS390X_OpLsh32x8(v) + case OpLsh64x16: + return rewriteValueS390X_OpLsh64x16(v) + case OpLsh64x32: + return rewriteValueS390X_OpLsh64x32(v) + case OpLsh64x64: + return rewriteValueS390X_OpLsh64x64(v) + case OpLsh64x8: + return rewriteValueS390X_OpLsh64x8(v) + case OpLsh8x16: + return rewriteValueS390X_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValueS390X_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValueS390X_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValueS390X_OpLsh8x8(v) + case OpMax32F: + v.Op = OpS390XWFMAXSB + return true + case OpMax64F: + v.Op = OpS390XWFMAXDB + return true + case OpMin32F: + v.Op = OpS390XWFMINSB + return true + case OpMin64F: + v.Op = OpS390XWFMINDB + return true + case OpMod16: + return rewriteValueS390X_OpMod16(v) + case OpMod16u: + return rewriteValueS390X_OpMod16u(v) + case OpMod32: + return rewriteValueS390X_OpMod32(v) + case OpMod32u: + return rewriteValueS390X_OpMod32u(v) + case OpMod64: + return rewriteValueS390X_OpMod64(v) + case OpMod64u: + v.Op = OpS390XMODDU + return true + case OpMod8: + return rewriteValueS390X_OpMod8(v) + case OpMod8u: + return rewriteValueS390X_OpMod8u(v) + case OpMove: + return rewriteValueS390X_OpMove(v) + case OpMul16: + v.Op = OpS390XMULLW + return true + case OpMul32: + v.Op = OpS390XMULLW + return true + case OpMul32F: + v.Op = OpS390XFMULS + return true + case OpMul64: + v.Op = OpS390XMULLD + return true + case OpMul64F: + v.Op = OpS390XFMUL + return true + case OpMul64uhilo: + v.Op = OpS390XMLGR + return true + case OpMul8: + v.Op = OpS390XMULLW + return true + case OpNeg16: + v.Op = OpS390XNEGW + return true + case OpNeg32: + v.Op = OpS390XNEGW + return true + case OpNeg32F: + v.Op = OpS390XFNEGS + return true + case OpNeg64: + v.Op = OpS390XNEG + return true + case OpNeg64F: + v.Op = OpS390XFNEG + return true + case OpNeg8: + v.Op = OpS390XNEGW + return true + case OpNeq16: + return rewriteValueS390X_OpNeq16(v) + case OpNeq32: + return rewriteValueS390X_OpNeq32(v) + case OpNeq32F: + return rewriteValueS390X_OpNeq32F(v) + case OpNeq64: + return rewriteValueS390X_OpNeq64(v) + case OpNeq64F: + return rewriteValueS390X_OpNeq64F(v) + case OpNeq8: + return rewriteValueS390X_OpNeq8(v) + case OpNeqB: + return rewriteValueS390X_OpNeqB(v) + case OpNeqPtr: + return rewriteValueS390X_OpNeqPtr(v) + case OpNilCheck: + v.Op = OpS390XLoweredNilCheck + return true + case OpNot: + return rewriteValueS390X_OpNot(v) + case OpOffPtr: + return rewriteValueS390X_OpOffPtr(v) + case OpOr16: + v.Op = OpS390XORW + return true + case OpOr32: + v.Op = OpS390XORW + return true + case OpOr64: + v.Op = OpS390XOR + return true + case OpOr8: + v.Op = OpS390XORW + return true + case OpOrB: + v.Op = OpS390XORW + return true + case OpPanicBounds: + v.Op = OpS390XLoweredPanicBoundsRR + return true + case OpPopCount16: + return rewriteValueS390X_OpPopCount16(v) + case OpPopCount32: + return rewriteValueS390X_OpPopCount32(v) + case OpPopCount64: + return rewriteValueS390X_OpPopCount64(v) + case OpPopCount8: + return rewriteValueS390X_OpPopCount8(v) + case OpRotateLeft16: + return rewriteValueS390X_OpRotateLeft16(v) + case OpRotateLeft32: + v.Op = OpS390XRLL + return true + case OpRotateLeft64: + v.Op = OpS390XRLLG + return true + case OpRotateLeft8: + return rewriteValueS390X_OpRotateLeft8(v) + case OpRound: + return rewriteValueS390X_OpRound(v) + case OpRound32F: + v.Op = OpS390XLoweredRound32F + return true + case OpRound64F: + v.Op = OpS390XLoweredRound64F + return true + case OpRoundToEven: + return rewriteValueS390X_OpRoundToEven(v) + case OpRsh16Ux16: + return rewriteValueS390X_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValueS390X_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValueS390X_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValueS390X_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValueS390X_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValueS390X_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValueS390X_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValueS390X_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValueS390X_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValueS390X_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValueS390X_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValueS390X_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValueS390X_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValueS390X_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValueS390X_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValueS390X_OpRsh32x8(v) + case OpRsh64Ux16: + return rewriteValueS390X_OpRsh64Ux16(v) + case OpRsh64Ux32: + return rewriteValueS390X_OpRsh64Ux32(v) + case OpRsh64Ux64: + return rewriteValueS390X_OpRsh64Ux64(v) + case OpRsh64Ux8: + return rewriteValueS390X_OpRsh64Ux8(v) + case OpRsh64x16: + return rewriteValueS390X_OpRsh64x16(v) + case OpRsh64x32: + return rewriteValueS390X_OpRsh64x32(v) + case OpRsh64x64: + return rewriteValueS390X_OpRsh64x64(v) + case OpRsh64x8: + return rewriteValueS390X_OpRsh64x8(v) + case OpRsh8Ux16: + return rewriteValueS390X_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValueS390X_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValueS390X_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValueS390X_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValueS390X_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValueS390X_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValueS390X_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValueS390X_OpRsh8x8(v) + case OpS390XADD: + return rewriteValueS390X_OpS390XADD(v) + case OpS390XADDC: + return rewriteValueS390X_OpS390XADDC(v) + case OpS390XADDE: + return rewriteValueS390X_OpS390XADDE(v) + case OpS390XADDW: + return rewriteValueS390X_OpS390XADDW(v) + case OpS390XADDWconst: + return rewriteValueS390X_OpS390XADDWconst(v) + case OpS390XADDWload: + return rewriteValueS390X_OpS390XADDWload(v) + case OpS390XADDconst: + return rewriteValueS390X_OpS390XADDconst(v) + case OpS390XADDload: + return rewriteValueS390X_OpS390XADDload(v) + case OpS390XAND: + return rewriteValueS390X_OpS390XAND(v) + case OpS390XANDW: + return rewriteValueS390X_OpS390XANDW(v) + case OpS390XANDWconst: + return rewriteValueS390X_OpS390XANDWconst(v) + case OpS390XANDWload: + return rewriteValueS390X_OpS390XANDWload(v) + case OpS390XANDconst: + return rewriteValueS390X_OpS390XANDconst(v) + case OpS390XANDload: + return rewriteValueS390X_OpS390XANDload(v) + case OpS390XCMP: + return rewriteValueS390X_OpS390XCMP(v) + case OpS390XCMPU: + return rewriteValueS390X_OpS390XCMPU(v) + case OpS390XCMPUconst: + return rewriteValueS390X_OpS390XCMPUconst(v) + case OpS390XCMPW: + return rewriteValueS390X_OpS390XCMPW(v) + case OpS390XCMPWU: + return rewriteValueS390X_OpS390XCMPWU(v) + case OpS390XCMPWUconst: + return rewriteValueS390X_OpS390XCMPWUconst(v) + case OpS390XCMPWconst: + return rewriteValueS390X_OpS390XCMPWconst(v) + case OpS390XCMPconst: + return rewriteValueS390X_OpS390XCMPconst(v) + case OpS390XCPSDR: + return rewriteValueS390X_OpS390XCPSDR(v) + case OpS390XFCMP: + return rewriteValueS390X_OpS390XFCMP(v) + case OpS390XFCMPS: + return rewriteValueS390X_OpS390XFCMPS(v) + case OpS390XFMOVDload: + return rewriteValueS390X_OpS390XFMOVDload(v) + case OpS390XFMOVDstore: + return rewriteValueS390X_OpS390XFMOVDstore(v) + case OpS390XFMOVSload: + return rewriteValueS390X_OpS390XFMOVSload(v) + case OpS390XFMOVSstore: + return rewriteValueS390X_OpS390XFMOVSstore(v) + case OpS390XFNEG: + return rewriteValueS390X_OpS390XFNEG(v) + case OpS390XFNEGS: + return rewriteValueS390X_OpS390XFNEGS(v) + case OpS390XLDGR: + return rewriteValueS390X_OpS390XLDGR(v) + case OpS390XLEDBR: + return rewriteValueS390X_OpS390XLEDBR(v) + case OpS390XLGDR: + return rewriteValueS390X_OpS390XLGDR(v) + case OpS390XLOCGR: + return rewriteValueS390X_OpS390XLOCGR(v) + case OpS390XLTDBR: + return rewriteValueS390X_OpS390XLTDBR(v) + case OpS390XLTEBR: + return rewriteValueS390X_OpS390XLTEBR(v) + case OpS390XLoweredPanicBoundsCR: + return rewriteValueS390X_OpS390XLoweredPanicBoundsCR(v) + case OpS390XLoweredPanicBoundsRC: + return rewriteValueS390X_OpS390XLoweredPanicBoundsRC(v) + case OpS390XLoweredPanicBoundsRR: + return rewriteValueS390X_OpS390XLoweredPanicBoundsRR(v) + case OpS390XLoweredRound32F: + return rewriteValueS390X_OpS390XLoweredRound32F(v) + case OpS390XLoweredRound64F: + return rewriteValueS390X_OpS390XLoweredRound64F(v) + case OpS390XMOVBZload: + return rewriteValueS390X_OpS390XMOVBZload(v) + case OpS390XMOVBZreg: + return rewriteValueS390X_OpS390XMOVBZreg(v) + case OpS390XMOVBload: + return rewriteValueS390X_OpS390XMOVBload(v) + case OpS390XMOVBreg: + return rewriteValueS390X_OpS390XMOVBreg(v) + case OpS390XMOVBstore: + return rewriteValueS390X_OpS390XMOVBstore(v) + case OpS390XMOVBstoreconst: + return rewriteValueS390X_OpS390XMOVBstoreconst(v) + case OpS390XMOVDBR: + return rewriteValueS390X_OpS390XMOVDBR(v) + case OpS390XMOVDaddridx: + return rewriteValueS390X_OpS390XMOVDaddridx(v) + case OpS390XMOVDload: + return rewriteValueS390X_OpS390XMOVDload(v) + case OpS390XMOVDstore: + return rewriteValueS390X_OpS390XMOVDstore(v) + case OpS390XMOVDstoreconst: + return rewriteValueS390X_OpS390XMOVDstoreconst(v) + case OpS390XMOVDstoreidx: + return rewriteValueS390X_OpS390XMOVDstoreidx(v) + case OpS390XMOVHZload: + return rewriteValueS390X_OpS390XMOVHZload(v) + case OpS390XMOVHZreg: + return rewriteValueS390X_OpS390XMOVHZreg(v) + case OpS390XMOVHload: + return rewriteValueS390X_OpS390XMOVHload(v) + case OpS390XMOVHreg: + return rewriteValueS390X_OpS390XMOVHreg(v) + case OpS390XMOVHstore: + return rewriteValueS390X_OpS390XMOVHstore(v) + case OpS390XMOVHstoreconst: + return rewriteValueS390X_OpS390XMOVHstoreconst(v) + case OpS390XMOVHstoreidx: + return rewriteValueS390X_OpS390XMOVHstoreidx(v) + case OpS390XMOVWBR: + return rewriteValueS390X_OpS390XMOVWBR(v) + case OpS390XMOVWZload: + return rewriteValueS390X_OpS390XMOVWZload(v) + case OpS390XMOVWZreg: + return rewriteValueS390X_OpS390XMOVWZreg(v) + case OpS390XMOVWload: + return rewriteValueS390X_OpS390XMOVWload(v) + case OpS390XMOVWreg: + return rewriteValueS390X_OpS390XMOVWreg(v) + case OpS390XMOVWstore: + return rewriteValueS390X_OpS390XMOVWstore(v) + case OpS390XMOVWstoreconst: + return rewriteValueS390X_OpS390XMOVWstoreconst(v) + case OpS390XMOVWstoreidx: + return rewriteValueS390X_OpS390XMOVWstoreidx(v) + case OpS390XMULLD: + return rewriteValueS390X_OpS390XMULLD(v) + case OpS390XMULLDconst: + return rewriteValueS390X_OpS390XMULLDconst(v) + case OpS390XMULLDload: + return rewriteValueS390X_OpS390XMULLDload(v) + case OpS390XMULLW: + return rewriteValueS390X_OpS390XMULLW(v) + case OpS390XMULLWconst: + return rewriteValueS390X_OpS390XMULLWconst(v) + case OpS390XMULLWload: + return rewriteValueS390X_OpS390XMULLWload(v) + case OpS390XNEG: + return rewriteValueS390X_OpS390XNEG(v) + case OpS390XNEGW: + return rewriteValueS390X_OpS390XNEGW(v) + case OpS390XNOT: + return rewriteValueS390X_OpS390XNOT(v) + case OpS390XNOTW: + return rewriteValueS390X_OpS390XNOTW(v) + case OpS390XOR: + return rewriteValueS390X_OpS390XOR(v) + case OpS390XORW: + return rewriteValueS390X_OpS390XORW(v) + case OpS390XORWconst: + return rewriteValueS390X_OpS390XORWconst(v) + case OpS390XORWload: + return rewriteValueS390X_OpS390XORWload(v) + case OpS390XORconst: + return rewriteValueS390X_OpS390XORconst(v) + case OpS390XORload: + return rewriteValueS390X_OpS390XORload(v) + case OpS390XRISBGZ: + return rewriteValueS390X_OpS390XRISBGZ(v) + case OpS390XRLL: + return rewriteValueS390X_OpS390XRLL(v) + case OpS390XRLLG: + return rewriteValueS390X_OpS390XRLLG(v) + case OpS390XSLD: + return rewriteValueS390X_OpS390XSLD(v) + case OpS390XSLDconst: + return rewriteValueS390X_OpS390XSLDconst(v) + case OpS390XSLW: + return rewriteValueS390X_OpS390XSLW(v) + case OpS390XSLWconst: + return rewriteValueS390X_OpS390XSLWconst(v) + case OpS390XSRAD: + return rewriteValueS390X_OpS390XSRAD(v) + case OpS390XSRADconst: + return rewriteValueS390X_OpS390XSRADconst(v) + case OpS390XSRAW: + return rewriteValueS390X_OpS390XSRAW(v) + case OpS390XSRAWconst: + return rewriteValueS390X_OpS390XSRAWconst(v) + case OpS390XSRD: + return rewriteValueS390X_OpS390XSRD(v) + case OpS390XSRDconst: + return rewriteValueS390X_OpS390XSRDconst(v) + case OpS390XSRW: + return rewriteValueS390X_OpS390XSRW(v) + case OpS390XSRWconst: + return rewriteValueS390X_OpS390XSRWconst(v) + case OpS390XSTM2: + return rewriteValueS390X_OpS390XSTM2(v) + case OpS390XSTMG2: + return rewriteValueS390X_OpS390XSTMG2(v) + case OpS390XSUB: + return rewriteValueS390X_OpS390XSUB(v) + case OpS390XSUBE: + return rewriteValueS390X_OpS390XSUBE(v) + case OpS390XSUBW: + return rewriteValueS390X_OpS390XSUBW(v) + case OpS390XSUBWconst: + return rewriteValueS390X_OpS390XSUBWconst(v) + case OpS390XSUBWload: + return rewriteValueS390X_OpS390XSUBWload(v) + case OpS390XSUBconst: + return rewriteValueS390X_OpS390XSUBconst(v) + case OpS390XSUBload: + return rewriteValueS390X_OpS390XSUBload(v) + case OpS390XSumBytes2: + return rewriteValueS390X_OpS390XSumBytes2(v) + case OpS390XSumBytes4: + return rewriteValueS390X_OpS390XSumBytes4(v) + case OpS390XSumBytes8: + return rewriteValueS390X_OpS390XSumBytes8(v) + case OpS390XXOR: + return rewriteValueS390X_OpS390XXOR(v) + case OpS390XXORW: + return rewriteValueS390X_OpS390XXORW(v) + case OpS390XXORWconst: + return rewriteValueS390X_OpS390XXORWconst(v) + case OpS390XXORWload: + return rewriteValueS390X_OpS390XXORWload(v) + case OpS390XXORconst: + return rewriteValueS390X_OpS390XXORconst(v) + case OpS390XXORload: + return rewriteValueS390X_OpS390XXORload(v) + case OpSelect0: + return rewriteValueS390X_OpSelect0(v) + case OpSelect1: + return rewriteValueS390X_OpSelect1(v) + case OpSignExt16to32: + v.Op = OpS390XMOVHreg + return true + case OpSignExt16to64: + v.Op = OpS390XMOVHreg + return true + case OpSignExt32to64: + v.Op = OpS390XMOVWreg + return true + case OpSignExt8to16: + v.Op = OpS390XMOVBreg + return true + case OpSignExt8to32: + v.Op = OpS390XMOVBreg + return true + case OpSignExt8to64: + v.Op = OpS390XMOVBreg + return true + case OpSlicemask: + return rewriteValueS390X_OpSlicemask(v) + case OpSqrt: + v.Op = OpS390XFSQRT + return true + case OpSqrt32: + v.Op = OpS390XFSQRTS + return true + case OpStaticCall: + v.Op = OpS390XCALLstatic + return true + case OpStore: + return rewriteValueS390X_OpStore(v) + case OpSub16: + v.Op = OpS390XSUBW + return true + case OpSub32: + v.Op = OpS390XSUBW + return true + case OpSub32F: + return rewriteValueS390X_OpSub32F(v) + case OpSub64: + v.Op = OpS390XSUB + return true + case OpSub64F: + return rewriteValueS390X_OpSub64F(v) + case OpSub8: + v.Op = OpS390XSUBW + return true + case OpSubPtr: + v.Op = OpS390XSUB + return true + case OpTailCall: + v.Op = OpS390XCALLtail + return true + case OpTrunc: + return rewriteValueS390X_OpTrunc(v) + case OpTrunc16to8: + v.Op = OpCopy + return true + case OpTrunc32to16: + v.Op = OpCopy + return true + case OpTrunc32to8: + v.Op = OpCopy + return true + case OpTrunc64to16: + v.Op = OpCopy + return true + case OpTrunc64to32: + v.Op = OpCopy + return true + case OpTrunc64to8: + v.Op = OpCopy + return true + case OpWB: + v.Op = OpS390XLoweredWB + return true + case OpXor16: + v.Op = OpS390XXORW + return true + case OpXor32: + v.Op = OpS390XXORW + return true + case OpXor64: + v.Op = OpS390XXOR + return true + case OpXor8: + v.Op = OpS390XXORW + return true + case OpZero: + return rewriteValueS390X_OpZero(v) + case OpZeroExt16to32: + v.Op = OpS390XMOVHZreg + return true + case OpZeroExt16to64: + v.Op = OpS390XMOVHZreg + return true + case OpZeroExt32to64: + v.Op = OpS390XMOVWZreg + return true + case OpZeroExt8to16: + v.Op = OpS390XMOVBZreg + return true + case OpZeroExt8to32: + v.Op = OpS390XMOVBZreg + return true + case OpZeroExt8to64: + v.Op = OpS390XMOVBZreg + return true + } + return false +} +func rewriteValueS390X_OpAdd32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Add32F x y) + // result: (Select0 (FADDS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpS390XFADDS, types.NewTuple(typ.Float32, types.TypeFlags)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpAdd64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Add64F x y) + // result: (Select0 (FADD x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpS390XFADD, types.NewTuple(typ.Float64, types.TypeFlags)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpAddr(v *Value) bool { + v_0 := v.Args[0] + // match: (Addr {sym} base) + // result: (MOVDaddr {sym} base) + for { + sym := auxToSym(v.Aux) + base := v_0 + v.reset(OpS390XMOVDaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } +} +func rewriteValueS390X_OpAtomicAdd32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicAdd32 ptr val mem) + // result: (AddTupleFirst32 val (LAA ptr val mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XAddTupleFirst32) + v0 := b.NewValue0(v.Pos, OpS390XLAA, types.NewTuple(typ.UInt32, types.TypeMem)) + v0.AddArg3(ptr, val, mem) + v.AddArg2(val, v0) + return true + } +} +func rewriteValueS390X_OpAtomicAdd64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicAdd64 ptr val mem) + // result: (AddTupleFirst64 val (LAAG ptr val mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XAddTupleFirst64) + v0 := b.NewValue0(v.Pos, OpS390XLAAG, types.NewTuple(typ.UInt64, types.TypeMem)) + v0.AddArg3(ptr, val, mem) + v.AddArg2(val, v0) + return true + } +} +func rewriteValueS390X_OpAtomicAnd8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicAnd8 ptr val mem) + // result: (LANfloor ptr (RLL (ORWconst val [-1<<8]) (RXSBG {s390x.NewRotateParams(59, 60, 3)} (MOVDconst [3<<3]) ptr)) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XLANfloor) + v0 := b.NewValue0(v.Pos, OpS390XRLL, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpS390XORWconst, typ.UInt32) + v1.AuxInt = int32ToAuxInt(-1 << 8) + v1.AddArg(val) + v2 := b.NewValue0(v.Pos, OpS390XRXSBG, typ.UInt32) + v2.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(59, 60, 3)) + v3 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(3 << 3) + v2.AddArg2(v3, ptr) + v0.AddArg2(v1, v2) + v.AddArg3(ptr, v0, mem) + return true + } +} +func rewriteValueS390X_OpAtomicCompareAndSwap32(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicCompareAndSwap32 ptr old new_ mem) + // result: (LoweredAtomicCas32 ptr old new_ mem) + for { + ptr := v_0 + old := v_1 + new_ := v_2 + mem := v_3 + v.reset(OpS390XLoweredAtomicCas32) + v.AddArg4(ptr, old, new_, mem) + return true + } +} +func rewriteValueS390X_OpAtomicCompareAndSwap64(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicCompareAndSwap64 ptr old new_ mem) + // result: (LoweredAtomicCas64 ptr old new_ mem) + for { + ptr := v_0 + old := v_1 + new_ := v_2 + mem := v_3 + v.reset(OpS390XLoweredAtomicCas64) + v.AddArg4(ptr, old, new_, mem) + return true + } +} +func rewriteValueS390X_OpAtomicExchange32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicExchange32 ptr val mem) + // result: (LoweredAtomicExchange32 ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XLoweredAtomicExchange32) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueS390X_OpAtomicExchange64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicExchange64 ptr val mem) + // result: (LoweredAtomicExchange64 ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XLoweredAtomicExchange64) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueS390X_OpAtomicLoad32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoad32 ptr mem) + // result: (MOVWZatomicload ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpS390XMOVWZatomicload) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValueS390X_OpAtomicLoad64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoad64 ptr mem) + // result: (MOVDatomicload ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpS390XMOVDatomicload) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValueS390X_OpAtomicLoad8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoad8 ptr mem) + // result: (MOVBZatomicload ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpS390XMOVBZatomicload) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValueS390X_OpAtomicLoadAcq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoadAcq32 ptr mem) + // result: (MOVWZatomicload ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpS390XMOVWZatomicload) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValueS390X_OpAtomicLoadPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicLoadPtr ptr mem) + // result: (MOVDatomicload ptr mem) + for { + ptr := v_0 + mem := v_1 + v.reset(OpS390XMOVDatomicload) + v.AddArg2(ptr, mem) + return true + } +} +func rewriteValueS390X_OpAtomicOr8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AtomicOr8 ptr val mem) + // result: (LAOfloor ptr (SLW (MOVBZreg val) (RXSBG {s390x.NewRotateParams(59, 60, 3)} (MOVDconst [3<<3]) ptr)) mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XLAOfloor) + v0 := b.NewValue0(v.Pos, OpS390XSLW, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt32) + v1.AddArg(val) + v2 := b.NewValue0(v.Pos, OpS390XRXSBG, typ.UInt32) + v2.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(59, 60, 3)) + v3 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(3 << 3) + v2.AddArg2(v3, ptr) + v0.AddArg2(v1, v2) + v.AddArg3(ptr, v0, mem) + return true + } +} +func rewriteValueS390X_OpAtomicStore32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (AtomicStore32 ptr val mem) + // result: (SYNC (MOVWatomicstore ptr val mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XSYNC) + v0 := b.NewValue0(v.Pos, OpS390XMOVWatomicstore, types.TypeMem) + v0.AddArg3(ptr, val, mem) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpAtomicStore64(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (AtomicStore64 ptr val mem) + // result: (SYNC (MOVDatomicstore ptr val mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XSYNC) + v0 := b.NewValue0(v.Pos, OpS390XMOVDatomicstore, types.TypeMem) + v0.AddArg3(ptr, val, mem) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpAtomicStore8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (AtomicStore8 ptr val mem) + // result: (SYNC (MOVBatomicstore ptr val mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XSYNC) + v0 := b.NewValue0(v.Pos, OpS390XMOVBatomicstore, types.TypeMem) + v0.AddArg3(ptr, val, mem) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpAtomicStorePtrNoWB(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (AtomicStorePtrNoWB ptr val mem) + // result: (SYNC (MOVDatomicstore ptr val mem)) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XSYNC) + v0 := b.NewValue0(v.Pos, OpS390XMOVDatomicstore, types.TypeMem) + v0.AddArg3(ptr, val, mem) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpAtomicStoreRel32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AtomicStoreRel32 ptr val mem) + // result: (MOVWatomicstore ptr val mem) + for { + ptr := v_0 + val := v_1 + mem := v_2 + v.reset(OpS390XMOVWatomicstore) + v.AddArg3(ptr, val, mem) + return true + } +} +func rewriteValueS390X_OpAvg64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Avg64u x y) + // result: (ADD (SRDconst (SUB x y) [1]) y) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XADD) + v0 := b.NewValue0(v.Pos, OpS390XSRDconst, t) + v0.AuxInt = uint8ToAuxInt(1) + v1 := b.NewValue0(v.Pos, OpS390XSUB, t) + v1.AddArg2(x, y) + v0.AddArg(v1) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueS390X_OpBitLen16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen16 x) + // result: (BitLen64 (ZeroExt16to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpBitLen32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen32 x) + // result: (BitLen64 (ZeroExt32to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpBitLen64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen64 x) + // result: (SUB (MOVDconst [64]) (FLOGR x)) + for { + x := v_0 + v.reset(OpS390XSUB) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(64) + v1 := b.NewValue0(v.Pos, OpS390XFLOGR, typ.UInt64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpBitLen8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen8 x) + // result: (BitLen64 (ZeroExt8to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpBswap16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Bswap16 x:(MOVHZload [off] {sym} ptr mem)) + // result: @x.Block (MOVHZreg (MOVHBRload [off] {sym} ptr mem)) + for { + x := v_0 + if x.Op != OpS390XMOVHZload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + b = x.Block + v0 := b.NewValue0(x.Pos, OpS390XMOVHZreg, typ.UInt64) + v.copyOf(v0) + v1 := b.NewValue0(x.Pos, OpS390XMOVHBRload, typ.UInt16) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(sym) + v1.AddArg2(ptr, mem) + v0.AddArg(v1) + return true + } + // match: (Bswap16 x:(MOVHZloadidx [off] {sym} ptr idx mem)) + // result: @x.Block (MOVHZreg (MOVHBRloadidx [off] {sym} ptr idx mem)) + for { + x := v_0 + if x.Op != OpS390XMOVHZloadidx { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[2] + ptr := x.Args[0] + idx := x.Args[1] + b = x.Block + v0 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpS390XMOVHBRloadidx, typ.Int16) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(sym) + v1.AddArg3(ptr, idx, mem) + v0.AddArg(v1) + return true + } + return false +} +func rewriteValueS390X_OpCeil(v *Value) bool { + v_0 := v.Args[0] + // match: (Ceil x) + // result: (FIDBR [6] x) + for { + x := v_0 + v.reset(OpS390XFIDBR) + v.AuxInt = int8ToAuxInt(6) + v.AddArg(x) + return true + } +} +func rewriteValueS390X_OpConst16(v *Value) bool { + // match: (Const16 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt16(v.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueS390X_OpConst32(v *Value) bool { + // match: (Const32 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt32(v.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueS390X_OpConst64(v *Value) bool { + // match: (Const64 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt64(v.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueS390X_OpConst8(v *Value) bool { + // match: (Const8 [val]) + // result: (MOVDconst [int64(val)]) + for { + val := auxIntToInt8(v.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(val)) + return true + } +} +func rewriteValueS390X_OpConstBool(v *Value) bool { + // match: (ConstBool [t]) + // result: (MOVDconst [b2i(t)]) + for { + t := auxIntToBool(v.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(b2i(t)) + return true + } +} +func rewriteValueS390X_OpConstNil(v *Value) bool { + // match: (ConstNil) + // result: (MOVDconst [0]) + for { + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } +} +func rewriteValueS390X_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz16 x) + // result: (Ctz64 (Or64 x (MOVDconst [1<<16]))) + for { + x := v_0 + v.reset(OpCtz64) + v0 := b.NewValue0(v.Pos, OpOr64, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1 << 16) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpCtz32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz32 x) + // result: (SUB (MOVDconst [64]) (FLOGR (MOVWZreg (ANDW (SUBWconst [1] x) (NOTW x))))) + for { + t := v.Type + x := v_0 + v.reset(OpS390XSUB) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(64) + v1 := b.NewValue0(v.Pos, OpS390XFLOGR, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpS390XMOVWZreg, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpS390XANDW, t) + v4 := b.NewValue0(v.Pos, OpS390XSUBWconst, t) + v4.AuxInt = int32ToAuxInt(1) + v4.AddArg(x) + v5 := b.NewValue0(v.Pos, OpS390XNOTW, t) + v5.AddArg(x) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpCtz64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz64 x) + // result: (SUB (MOVDconst [64]) (FLOGR (AND (SUBconst [1] x) (NOT x)))) + for { + t := v.Type + x := v_0 + v.reset(OpS390XSUB) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(64) + v1 := b.NewValue0(v.Pos, OpS390XFLOGR, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpS390XAND, t) + v3 := b.NewValue0(v.Pos, OpS390XSUBconst, t) + v3.AuxInt = int32ToAuxInt(1) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XNOT, t) + v4.AddArg(x) + v2.AddArg2(v3, v4) + v1.AddArg(v2) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz8 x) + // result: (Ctz64 (Or64 x (MOVDconst [1<<8]))) + for { + x := v_0 + v.reset(OpCtz64) + v0 := b.NewValue0(v.Pos, OpOr64, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1 << 8) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 x y) + // result: (DIVW (MOVHreg x) (MOVHreg y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XDIVW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u x y) + // result: (DIVWU (MOVHZreg x) (MOVHZreg y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XDIVWU) + v0 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32 x y) + // result: (DIVW (MOVWreg x) y) + for { + x := v_0 + y := v_1 + v.reset(OpS390XDIVW) + v0 := b.NewValue0(v.Pos, OpS390XMOVWreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueS390X_OpDiv32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32u x y) + // result: (DIVWU (MOVWZreg x) y) + for { + x := v_0 + y := v_1 + v.reset(OpS390XDIVWU) + v0 := b.NewValue0(v.Pos, OpS390XMOVWZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueS390X_OpDiv64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Div64 x y) + // result: (DIVD x y) + for { + x := v_0 + y := v_1 + v.reset(OpS390XDIVD) + v.AddArg2(x, y) + return true + } +} +func rewriteValueS390X_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (DIVW (MOVBreg x) (MOVBreg y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XDIVW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (DIVWU (MOVBZreg x) (MOVBZreg y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XDIVWU) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq16 x y) + // result: (LOCGR {s390x.Equal} (MOVDconst [0]) (MOVDconst [1]) (CMPW (MOVHreg x) (MOVHreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Equal) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq32 x y) + // result: (LOCGR {s390x.Equal} (MOVDconst [0]) (MOVDconst [1]) (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Equal) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpEq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq32F x y) + // result: (LOCGR {s390x.Equal} (MOVDconst [0]) (MOVDconst [1]) (FCMPS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Equal) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XFCMPS, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpEq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq64 x y) + // result: (LOCGR {s390x.Equal} (MOVDconst [0]) (MOVDconst [1]) (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Equal) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMP, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpEq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq64F x y) + // result: (LOCGR {s390x.Equal} (MOVDconst [0]) (MOVDconst [1]) (FCMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Equal) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XFCMP, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq8 x y) + // result: (LOCGR {s390x.Equal} (MOVDconst [0]) (MOVDconst [1]) (CMPW (MOVBreg x) (MOVBreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Equal) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqB x y) + // result: (LOCGR {s390x.Equal} (MOVDconst [0]) (MOVDconst [1]) (CMPW (MOVBreg x) (MOVBreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Equal) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqPtr x y) + // result: (LOCGR {s390x.Equal} (MOVDconst [0]) (MOVDconst [1]) (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Equal) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMP, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpFMA(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMA x y z) + // result: (FMADD z x y) + for { + x := v_0 + y := v_1 + z := v_2 + v.reset(OpS390XFMADD) + v.AddArg3(z, x, y) + return true + } +} +func rewriteValueS390X_OpFloor(v *Value) bool { + v_0 := v.Args[0] + // match: (Floor x) + // result: (FIDBR [7] x) + for { + x := v_0 + v.reset(OpS390XFIDBR) + v.AuxInt = int8ToAuxInt(7) + v.AddArg(x) + return true + } +} +func rewriteValueS390X_OpHmul32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul32 x y) + // result: (SRDconst [32] (MULLD (MOVWreg x) (MOVWreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRDconst) + v.AuxInt = uint8ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpS390XMULLD, typ.Int64) + v1 := b.NewValue0(v.Pos, OpS390XMOVWreg, typ.Int64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpS390XMOVWreg, typ.Int64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpHmul32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul32u x y) + // result: (SRDconst [32] (MULLD (MOVWZreg x) (MOVWZreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRDconst) + v.AuxInt = uint8ToAuxInt(32) + v0 := b.NewValue0(v.Pos, OpS390XMULLD, typ.Int64) + v1 := b.NewValue0(v.Pos, OpS390XMOVWZreg, typ.UInt64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpS390XMOVWZreg, typ.UInt64) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpITab(v *Value) bool { + v_0 := v.Args[0] + // match: (ITab (Load ptr mem)) + // result: (MOVDload ptr mem) + for { + if v_0.Op != OpLoad { + break + } + mem := v_0.Args[1] + ptr := v_0.Args[0] + v.reset(OpS390XMOVDload) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpIsInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsInBounds idx len) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (CMPU idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPU, types.TypeFlags) + v2.AddArg2(idx, len) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpIsNonNil(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsNonNil p) + // result: (LOCGR {s390x.NotEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPconst p [0])) + for { + p := v_0 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.NotEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(0) + v2.AddArg(p) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpIsSliceInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsSliceInBounds idx len) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPU idx len)) + for { + idx := v_0 + len := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPU, types.TypeFlags) + v2.AddArg2(idx, len) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16 x y) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPW (MOVHreg x) (MOVHreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16U x y) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPWU (MOVHZreg x) (MOVHZreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPWU, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32 x y) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32F x y) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (FCMPS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XFCMPS, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32U x y) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPWU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPWU, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64 x y) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMP, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64F x y) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (FCMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XFCMP, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLeq64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64U x y) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPU, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8 x y) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPW (MOVBreg x) (MOVBreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8U x y) + // result: (LOCGR {s390x.LessOrEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPWU (MOVBZreg x) (MOVBZreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPWU, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16 x y) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (CMPW (MOVHreg x) (MOVHreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16U x y) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (CMPWU (MOVHZreg x) (MOVHZreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPWU, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32 x y) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLess32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32F x y) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (FCMPS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XFCMPS, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32U x y) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (CMPWU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPWU, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLess64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less64 x y) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMP, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLess64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less64F x y) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (FCMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XFCMP, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLess64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less64U x y) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (CMPU x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPU, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8 x y) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (CMPW (MOVBreg x) (MOVBreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8U x y) + // result: (LOCGR {s390x.Less} (MOVDconst [0]) (MOVDconst [1]) (CMPWU (MOVBZreg x) (MOVBZreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.Less) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPWU, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Load ptr mem) + // cond: (is64BitInt(t) || isPtr(t)) + // result: (MOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) || isPtr(t)) { + break + } + v.reset(OpS390XMOVDload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitInt(t) && t.IsSigned() + // result: (MOVWload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpS390XMOVWload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitInt(t) && !t.IsSigned() + // result: (MOVWZload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpS390XMOVWZload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is16BitInt(t) && t.IsSigned() + // result: (MOVHload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpS390XMOVHload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is16BitInt(t) && !t.IsSigned() + // result: (MOVHZload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is16BitInt(t) && !t.IsSigned()) { + break + } + v.reset(OpS390XMOVHZload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is8BitInt(t) && t.IsSigned() + // result: (MOVBload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is8BitInt(t) && t.IsSigned()) { + break + } + v.reset(OpS390XMOVBload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: (t.IsBoolean() || (is8BitInt(t) && !t.IsSigned())) + // result: (MOVBZload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsBoolean() || (is8BitInt(t) && !t.IsSigned())) { + break + } + v.reset(OpS390XMOVBZload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (FMOVSload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(OpS390XFMOVSload) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (FMOVDload ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(OpS390XFMOVDload) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (MOVDaddr {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(OpS390XMOVDaddr) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (MOVDaddr {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(OpS390XMOVDaddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValueS390X_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x16 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPWUconst (MOVHZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x32 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x64 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh16x8 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPWUconst (MOVBZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x16 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPWUconst (MOVHZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x32 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x64 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh32x8 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPWUconst (MOVBZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x16 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLD x y) (MOVDconst [0]) (CMPWUconst (MOVHZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x32 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLD x y) (MOVDconst [0]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x64 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLD x y) (MOVDconst [0]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SLD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x8 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLD x y) (MOVDconst [0]) (CMPWUconst (MOVBZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x16 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPWUconst (MOVHZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x32 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x64 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SLW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (Lsh8x8 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SLW x y) (MOVDconst [0]) (CMPWUconst (MOVBZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSLW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16 x y) + // result: (MODW (MOVHreg x) (MOVHreg y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XMODW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16u x y) + // result: (MODWU (MOVHZreg x) (MOVHZreg y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XMODWU) + v0 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32 x y) + // result: (MODW (MOVWreg x) y) + for { + x := v_0 + y := v_1 + v.reset(OpS390XMODW) + v0 := b.NewValue0(v.Pos, OpS390XMOVWreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueS390X_OpMod32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32u x y) + // result: (MODWU (MOVWZreg x) y) + for { + x := v_0 + y := v_1 + v.reset(OpS390XMODWU) + v0 := b.NewValue0(v.Pos, OpS390XMOVWZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueS390X_OpMod64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Mod64 x y) + // result: (MODD x y) + for { + x := v_0 + y := v_1 + v.reset(OpS390XMODD) + v.AddArg2(x, y) + return true + } +} +func rewriteValueS390X_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (MODW (MOVBreg x) (MOVBreg y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XMODW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (MODWU (MOVBZreg x) (MOVBZreg y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XMODWU) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (MOVBstore dst (MOVBZload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpS390XMOVBstore) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZload, typ.UInt8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (MOVHstore dst (MOVHZload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpS390XMOVHstore) + v0 := b.NewValue0(v.Pos, OpS390XMOVHZload, typ.UInt16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [4] dst src mem) + // result: (MOVWstore dst (MOVWZload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpS390XMOVWstore) + v0 := b.NewValue0(v.Pos, OpS390XMOVWZload, typ.UInt32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [8] dst src mem) + // result: (MOVDstore dst (MOVDload src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpS390XMOVDstore) + v0 := b.NewValue0(v.Pos, OpS390XMOVDload, typ.UInt64) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [16] dst src mem) + // result: (MOVDstore [8] dst (MOVDload [8] src mem) (MOVDstore dst (MOVDload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpS390XMOVDstore) + v.AuxInt = int32ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpS390XMOVDload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpS390XMOVDstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpS390XMOVDload, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [24] dst src mem) + // result: (MOVDstore [16] dst (MOVDload [16] src mem) (MOVDstore [8] dst (MOVDload [8] src mem) (MOVDstore dst (MOVDload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 24 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpS390XMOVDstore) + v.AuxInt = int32ToAuxInt(16) + v0 := b.NewValue0(v.Pos, OpS390XMOVDload, typ.UInt64) + v0.AuxInt = int32ToAuxInt(16) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpS390XMOVDstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(8) + v2 := b.NewValue0(v.Pos, OpS390XMOVDload, typ.UInt64) + v2.AuxInt = int32ToAuxInt(8) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpS390XMOVDstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpS390XMOVDload, typ.UInt64) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [3] dst src mem) + // result: (MOVBstore [2] dst (MOVBZload [2] src mem) (MOVHstore dst (MOVHZload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpS390XMOVBstore) + v.AuxInt = int32ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpS390XMOVHstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpS390XMOVHZload, typ.UInt16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [5] dst src mem) + // result: (MOVBstore [4] dst (MOVBZload [4] src mem) (MOVWstore dst (MOVWZload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpS390XMOVBstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpS390XMOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpS390XMOVWZload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [6] dst src mem) + // result: (MOVHstore [4] dst (MOVHZload [4] src mem) (MOVWstore dst (MOVWZload src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpS390XMOVHstore) + v.AuxInt = int32ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpS390XMOVHZload, typ.UInt16) + v0.AuxInt = int32ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpS390XMOVWstore, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpS390XMOVWZload, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [7] dst src mem) + // result: (MOVBstore [6] dst (MOVBZload [6] src mem) (MOVHstore [4] dst (MOVHZload [4] src mem) (MOVWstore dst (MOVWZload src mem) mem))) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpS390XMOVBstore) + v.AuxInt = int32ToAuxInt(6) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZload, typ.UInt8) + v0.AuxInt = int32ToAuxInt(6) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpS390XMOVHstore, types.TypeMem) + v1.AuxInt = int32ToAuxInt(4) + v2 := b.NewValue0(v.Pos, OpS390XMOVHZload, typ.UInt16) + v2.AuxInt = int32ToAuxInt(4) + v2.AddArg2(src, mem) + v3 := b.NewValue0(v.Pos, OpS390XMOVWstore, types.TypeMem) + v4 := b.NewValue0(v.Pos, OpS390XMOVWZload, typ.UInt32) + v4.AddArg2(src, mem) + v3.AddArg3(dst, v4, mem) + v1.AddArg3(dst, v2, v3) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 0 && s <= 256 && logLargeCopy(v, s) + // result: (MVC [makeValAndOff(int32(s), 0)] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 0 && s <= 256 && logLargeCopy(v, s)) { + break + } + v.reset(OpS390XMVC) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(s), 0)) + v.AddArg3(dst, src, mem) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 256 && s <= 512 && logLargeCopy(v, s) + // result: (MVC [makeValAndOff(int32(s)-256, 256)] dst src (MVC [makeValAndOff(256, 0)] dst src mem)) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 256 && s <= 512 && logLargeCopy(v, s)) { + break + } + v.reset(OpS390XMVC) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(s)-256, 256)) + v0 := b.NewValue0(v.Pos, OpS390XMVC, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(256, 0)) + v0.AddArg3(dst, src, mem) + v.AddArg3(dst, src, v0) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 512 && s <= 768 && logLargeCopy(v, s) + // result: (MVC [makeValAndOff(int32(s)-512, 512)] dst src (MVC [makeValAndOff(256, 256)] dst src (MVC [makeValAndOff(256, 0)] dst src mem))) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 512 && s <= 768 && logLargeCopy(v, s)) { + break + } + v.reset(OpS390XMVC) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(s)-512, 512)) + v0 := b.NewValue0(v.Pos, OpS390XMVC, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(256, 256)) + v1 := b.NewValue0(v.Pos, OpS390XMVC, types.TypeMem) + v1.AuxInt = valAndOffToAuxInt(makeValAndOff(256, 0)) + v1.AddArg3(dst, src, mem) + v0.AddArg3(dst, src, v1) + v.AddArg3(dst, src, v0) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 768 && s <= 1024 && logLargeCopy(v, s) + // result: (MVC [makeValAndOff(int32(s)-768, 768)] dst src (MVC [makeValAndOff(256, 512)] dst src (MVC [makeValAndOff(256, 256)] dst src (MVC [makeValAndOff(256, 0)] dst src mem)))) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 768 && s <= 1024 && logLargeCopy(v, s)) { + break + } + v.reset(OpS390XMVC) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(s)-768, 768)) + v0 := b.NewValue0(v.Pos, OpS390XMVC, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(makeValAndOff(256, 512)) + v1 := b.NewValue0(v.Pos, OpS390XMVC, types.TypeMem) + v1.AuxInt = valAndOffToAuxInt(makeValAndOff(256, 256)) + v2 := b.NewValue0(v.Pos, OpS390XMVC, types.TypeMem) + v2.AuxInt = valAndOffToAuxInt(makeValAndOff(256, 0)) + v2.AddArg3(dst, src, mem) + v1.AddArg3(dst, src, v2) + v0.AddArg3(dst, src, v1) + v.AddArg3(dst, src, v0) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 1024 && logLargeCopy(v, s) + // result: (LoweredMove [s%256] dst src (ADD src (MOVDconst [(s/256)*256])) mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 1024 && logLargeCopy(v, s)) { + break + } + v.reset(OpS390XLoweredMove) + v.AuxInt = int64ToAuxInt(s % 256) + v0 := b.NewValue0(v.Pos, OpS390XADD, src.Type) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt((s / 256) * 256) + v0.AddArg2(src, v1) + v.AddArg4(dst, src, v0, mem) + return true + } + return false +} +func rewriteValueS390X_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq16 x y) + // result: (LOCGR {s390x.NotEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPW (MOVHreg x) (MOVHreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.NotEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq32 x y) + // result: (LOCGR {s390x.NotEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPW x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.NotEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpNeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq32F x y) + // result: (LOCGR {s390x.NotEqual} (MOVDconst [0]) (MOVDconst [1]) (FCMPS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.NotEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XFCMPS, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpNeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq64 x y) + // result: (LOCGR {s390x.NotEqual} (MOVDconst [0]) (MOVDconst [1]) (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.NotEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMP, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpNeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq64F x y) + // result: (LOCGR {s390x.NotEqual} (MOVDconst [0]) (MOVDconst [1]) (FCMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.NotEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XFCMP, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq8 x y) + // result: (LOCGR {s390x.NotEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPW (MOVBreg x) (MOVBreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.NotEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpNeqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NeqB x y) + // result: (LOCGR {s390x.NotEqual} (MOVDconst [0]) (MOVDconst [1]) (CMPW (MOVBreg x) (MOVBreg y))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.NotEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v4.AddArg(y) + v2.AddArg2(v3, v4) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NeqPtr x y) + // result: (LOCGR {s390x.NotEqual} (MOVDconst [0]) (MOVDconst [1]) (CMP x y)) + for { + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(s390x.NotEqual) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(1) + v2 := b.NewValue0(v.Pos, OpS390XCMP, types.TypeFlags) + v2.AddArg2(x, y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpNot(v *Value) bool { + v_0 := v.Args[0] + // match: (Not x) + // result: (XORWconst [1] x) + for { + x := v_0 + v.reset(OpS390XXORWconst) + v.AuxInt = int32ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueS390X_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (OffPtr [off] ptr:(SP)) + // result: (MOVDaddr [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + if ptr.Op != OpSP { + break + } + v.reset(OpS390XMOVDaddr) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } + // match: (OffPtr [off] ptr) + // cond: is32Bit(off) + // result: (ADDconst [int32(off)] ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + if !(is32Bit(off)) { + break + } + v.reset(OpS390XADDconst) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(ptr) + return true + } + // match: (OffPtr [off] ptr) + // result: (ADD (MOVDconst [off]) ptr) + for { + off := auxIntToInt64(v.AuxInt) + ptr := v_0 + v.reset(OpS390XADD) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(off) + v.AddArg2(v0, ptr) + return true + } +} +func rewriteValueS390X_OpPopCount16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount16 x) + // result: (MOVBZreg (SumBytes2 (POPCNT x))) + for { + x := v_0 + v.reset(OpS390XMOVBZreg) + v0 := b.NewValue0(v.Pos, OpS390XSumBytes2, typ.UInt8) + v1 := b.NewValue0(v.Pos, OpS390XPOPCNT, typ.UInt16) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpPopCount32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount32 x) + // result: (MOVBZreg (SumBytes4 (POPCNT x))) + for { + x := v_0 + v.reset(OpS390XMOVBZreg) + v0 := b.NewValue0(v.Pos, OpS390XSumBytes4, typ.UInt8) + v1 := b.NewValue0(v.Pos, OpS390XPOPCNT, typ.UInt32) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpPopCount64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount64 x) + // result: (MOVBZreg (SumBytes8 (POPCNT x))) + for { + x := v_0 + v.reset(OpS390XMOVBZreg) + v0 := b.NewValue0(v.Pos, OpS390XSumBytes8, typ.UInt8) + v1 := b.NewValue0(v.Pos, OpS390XPOPCNT, typ.UInt64) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpPopCount8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount8 x) + // result: (POPCNT (MOVBZreg x)) + for { + x := v_0 + v.reset(OpS390XPOPCNT) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft16 x (MOVDconst [c])) + // result: (Or16 (Lsh16x64 x (MOVDconst [c&15])) (Rsh16Ux64 x (MOVDconst [-c&15]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpLsh16x64, t) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(c & 15) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh16Ux64, t) + v3 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(-c & 15) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueS390X_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft8 x (MOVDconst [c])) + // result: (Or8 (Lsh8x64 x (MOVDconst [c&7])) (Rsh8Ux64 x (MOVDconst [-c&7]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpLsh8x64, t) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(c & 7) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh8Ux64, t) + v3 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(-c & 7) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueS390X_OpRound(v *Value) bool { + v_0 := v.Args[0] + // match: (Round x) + // result: (FIDBR [1] x) + for { + x := v_0 + v.reset(OpS390XFIDBR) + v.AuxInt = int8ToAuxInt(1) + v.AddArg(x) + return true + } +} +func rewriteValueS390X_OpRoundToEven(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEven x) + // result: (FIDBR [4] x) + for { + x := v_0 + v.reset(OpS390XFIDBR) + v.AuxInt = int8ToAuxInt(4) + v.AddArg(x) + return true + } +} +func rewriteValueS390X_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRW (MOVHZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux16 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW (MOVHZreg x) y) (MOVDconst [0]) (CMPWUconst (MOVHZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v1 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueS390X_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRW (MOVHZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux32 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW (MOVHZreg x) y) (MOVDconst [0]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v1 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueS390X_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRW (MOVHZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux64 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW (MOVHZreg x) y) (MOVDconst [0]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v1 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueS390X_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRW (MOVHZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16Ux8 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW (MOVHZreg x) y) (MOVDconst [0]) (CMPWUconst (MOVBZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v1 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueS390X_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAW (MOVHreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x16 x y) + // result: (SRAW (MOVHreg x) (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst (MOVHZreg y) [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v1.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAW (MOVHreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x32 x y) + // result: (SRAW (MOVHreg x) (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst y [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v1.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v3.AddArg(y) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAW (MOVHreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x64 x y) + // result: (SRAW (MOVHreg x) (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPUconst y [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v1.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v3.AddArg(y) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAW (MOVHreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh16x8 x y) + // result: (SRAW (MOVHreg x) (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst (MOVBZreg y) [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVHreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v1.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux16 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW x y) (MOVDconst [0]) (CMPWUconst (MOVHZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux32 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW x y) (MOVDconst [0]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux64 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW x y) (MOVDconst [0]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32Ux8 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW x y) (MOVDconst [0]) (CMPWUconst (MOVBZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x16 x y) + // result: (SRAW x (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst (MOVHZreg y) [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v0.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueS390X_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x32 x y) + // result: (SRAW x (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst y [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v0.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueS390X_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x64 x y) + // result: (SRAW x (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPUconst y [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v0.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueS390X_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAW x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (Rsh32x8 x y) + // result: (SRAW x (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst (MOVBZreg y) [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v0.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueS390X_OpRsh64Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux16 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRD x y) (MOVDconst [0]) (CMPWUconst (MOVHZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpRsh64Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux32 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRD x y) (MOVDconst [0]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpRsh64Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux64 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRD x y) (MOVDconst [0]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpRsh64Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux8 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRD x y) (MOVDconst [0]) (CMPWUconst (MOVBZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRD, t) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueS390X_OpRsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x16 x y) + // result: (SRAD x (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst (MOVHZreg y) [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAD) + v0 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v0.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueS390X_OpRsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x32 x y) + // result: (SRAD x (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst y [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAD) + v0 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v0.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueS390X_OpRsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x64 x y) + // result: (SRAD x (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPUconst y [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAD) + v0 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v0.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v2.AddArg(y) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueS390X_OpRsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAD x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x8 x y) + // result: (SRAD x (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst (MOVBZreg y) [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAD) + v0 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v0.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v2.AuxInt = int32ToAuxInt(64) + v3 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v3.AddArg(y) + v2.AddArg(v3) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueS390X_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux16 x y) + // cond: shiftIsBounded(v) + // result: (SRW (MOVBZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux16 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW (MOVBZreg x) y) (MOVDconst [0]) (CMPWUconst (MOVHZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v1 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueS390X_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux32 x y) + // cond: shiftIsBounded(v) + // result: (SRW (MOVBZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux32 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW (MOVBZreg x) y) (MOVDconst [0]) (CMPWUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v1 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueS390X_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 x y) + // cond: shiftIsBounded(v) + // result: (SRW (MOVBZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux64 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW (MOVBZreg x) y) (MOVDconst [0]) (CMPUconst y [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v1 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v3.AddArg(y) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueS390X_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux8 x y) + // cond: shiftIsBounded(v) + // result: (SRW (MOVBZreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8Ux8 x y) + // result: (LOCGR {s390x.GreaterOrEqual} (SRW (MOVBZreg x) y) (MOVDconst [0]) (CMPWUconst (MOVBZreg y) [64])) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpS390XLOCGR) + v.Type = t + v.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v0 := b.NewValue0(v.Pos, OpS390XSRW, t) + v1 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v1.AddArg(x) + v0.AddArg2(v1, y) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v.AddArg3(v0, v2, v3) + return true + } +} +func rewriteValueS390X_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x16 x y) + // cond: shiftIsBounded(v) + // result: (SRAW (MOVBreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x16 x y) + // result: (SRAW (MOVBreg x) (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst (MOVHZreg y) [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v1.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpS390XMOVHZreg, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x32 x y) + // cond: shiftIsBounded(v) + // result: (SRAW (MOVBreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x32 x y) + // result: (SRAW (MOVBreg x) (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst y [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v1.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v3.AddArg(y) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x64 x y) + // cond: shiftIsBounded(v) + // result: (SRAW (MOVBreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x64 x y) + // result: (SRAW (MOVBreg x) (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPUconst y [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v1.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v3.AddArg(y) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x8 x y) + // cond: shiftIsBounded(v) + // result: (SRAW (MOVBreg x) y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } + // match: (Rsh8x8 x y) + // result: (SRAW (MOVBreg x) (LOCGR {s390x.GreaterOrEqual} y (MOVDconst [63]) (CMPWUconst (MOVBZreg y) [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XMOVBreg, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XLOCGR, y.Type) + v1.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, y.Type) + v2.AuxInt = int64ToAuxInt(63) + v3 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v3.AuxInt = int32ToAuxInt(64) + v4 := b.NewValue0(v.Pos, OpS390XMOVBZreg, typ.UInt64) + v4.AddArg(y) + v3.AddArg(v4) + v1.AddArg3(y, v2, v3) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueS390X_OpS390XADD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADD x (MOVDconst [c])) + // cond: is32Bit(c) && !t.IsPtr() + // result: (ADDconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c) && !t.IsPtr()) { + continue + } + v.reset(OpS390XADDconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (ADD idx (MOVDaddr [c] {s} ptr)) + // cond: ptr.Op != OpSB + // result: (MOVDaddridx [c] {s} ptr idx) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + idx := v_0 + if v_1.Op != OpS390XMOVDaddr { + continue + } + c := auxIntToInt32(v_1.AuxInt) + s := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + if !(ptr.Op != OpSB) { + continue + } + v.reset(OpS390XMOVDaddridx) + v.AuxInt = int32ToAuxInt(c) + v.Aux = symToAux(s) + v.AddArg2(ptr, idx) + return true + } + break + } + // match: (ADD x (NEG y)) + // result: (SUB x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XNEG { + continue + } + y := v_1.Args[0] + v.reset(OpS390XSUB) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADD x g:(MOVDload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (ADDload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVDload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XADDload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XADDC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDC x (MOVDconst [c])) + // cond: is16Bit(c) + // result: (ADDCconst x [int16(c)]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is16Bit(c)) { + continue + } + v.reset(OpS390XADDCconst) + v.AuxInt = int16ToAuxInt(int16(c)) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XADDE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDE x y (FlagEQ)) + // result: (ADDC x y) + for { + x := v_0 + y := v_1 + if v_2.Op != OpS390XFlagEQ { + break + } + v.reset(OpS390XADDC) + v.AddArg2(x, y) + return true + } + // match: (ADDE x y (FlagLT)) + // result: (ADDC x y) + for { + x := v_0 + y := v_1 + if v_2.Op != OpS390XFlagLT { + break + } + v.reset(OpS390XADDC) + v.AddArg2(x, y) + return true + } + // match: (ADDE x y (Select1 (ADDCconst [-1] (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) c))))) + // result: (ADDE x y c) + for { + x := v_0 + y := v_1 + if v_2.Op != OpSelect1 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpS390XADDCconst || auxIntToInt16(v_2_0.AuxInt) != -1 { + break + } + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpSelect0 { + break + } + v_2_0_0_0 := v_2_0_0.Args[0] + if v_2_0_0_0.Op != OpS390XADDE { + break + } + c := v_2_0_0_0.Args[2] + v_2_0_0_0_0 := v_2_0_0_0.Args[0] + if v_2_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_2_0_0_0_0.AuxInt) != 0 { + break + } + v_2_0_0_0_1 := v_2_0_0_0.Args[1] + if v_2_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_2_0_0_0_1.AuxInt) != 0 { + break + } + v.reset(OpS390XADDE) + v.AddArg3(x, y, c) + return true + } + return false +} +func rewriteValueS390X_OpS390XADDW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDW x (MOVDconst [c])) + // result: (ADDWconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XADDWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (ADDW x (NEGW y)) + // result: (SUBW x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XNEGW { + continue + } + y := v_1.Args[0] + v.reset(OpS390XSUBW) + v.AddArg2(x, y) + return true + } + break + } + // match: (ADDW x g:(MOVWload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (ADDWload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XADDWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (ADDW x g:(MOVWZload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (ADDWload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWZload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XADDWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XADDWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDWconst [c] x) + // cond: int32(c)==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(int32(c) == 0) { + break + } + v.copyOf(x) + return true + } + // match: (ADDWconst [c] (MOVDconst [d])) + // result: (MOVDconst [int64(c)+d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(c) + d) + return true + } + // match: (ADDWconst [c] (ADDWconst [d] x)) + // result: (ADDWconst [int32(c+d)] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XADDWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpS390XADDWconst) + v.AuxInt = int32ToAuxInt(int32(c + d)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XADDWload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ADDWload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (ADDWload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XADDWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (ADDWload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (ADDWload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XADDWload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XADDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ADDconst [c] (MOVDaddr [d] {s} x:(SB))) + // cond: ((c+d)&1 == 0) && is32Bit(int64(c)+int64(d)) + // result: (MOVDaddr [c+d] {s} x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDaddr { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + x := v_0.Args[0] + if x.Op != OpSB || !(((c+d)&1 == 0) && is32Bit(int64(c)+int64(d))) { + break + } + v.reset(OpS390XMOVDaddr) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg(x) + return true + } + // match: (ADDconst [c] (MOVDaddr [d] {s} x)) + // cond: x.Op != OpSB && is20Bit(int64(c)+int64(d)) + // result: (MOVDaddr [c+d] {s} x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDaddr { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + x := v_0.Args[0] + if !(x.Op != OpSB && is20Bit(int64(c)+int64(d))) { + break + } + v.reset(OpS390XMOVDaddr) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg(x) + return true + } + // match: (ADDconst [c] (MOVDaddridx [d] {s} x y)) + // cond: is20Bit(int64(c)+int64(d)) + // result: (MOVDaddridx [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDaddridx { + break + } + d := auxIntToInt32(v_0.AuxInt) + s := auxToSym(v_0.Aux) + y := v_0.Args[1] + x := v_0.Args[0] + if !(is20Bit(int64(c) + int64(d))) { + break + } + v.reset(OpS390XMOVDaddridx) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (ADDconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ADDconst [c] (MOVDconst [d])) + // result: (MOVDconst [int64(c)+d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(c) + d) + return true + } + // match: (ADDconst [c] (ADDconst [d] x)) + // cond: is32Bit(int64(c)+int64(d)) + // result: (ADDconst [c+d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XADDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(int64(c) + int64(d))) { + break + } + v.reset(OpS390XADDconst) + v.AuxInt = int32ToAuxInt(c + d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XADDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ADDload [off] {sym} x ptr1 (FMOVDstore [off] {sym} ptr2 y _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (ADD x (LGDR y)) + for { + t := v.Type + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr1 := v_1 + if v_2.Op != OpS390XFMOVDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + ptr2 := v_2.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XADD) + v0 := b.NewValue0(v_2.Pos, OpS390XLGDR, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (ADDload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (ADDload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XADDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (ADDload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (ADDload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XADDload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XAND(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (AND x (MOVDconst [c])) + // cond: s390x.NewRotateParams(0, 63, 0).OutMerge(uint64(c)) != nil + // result: (RISBGZ x {*s390x.NewRotateParams(0, 63, 0).OutMerge(uint64(c))}) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(s390x.NewRotateParams(0, 63, 0).OutMerge(uint64(c)) != nil) { + continue + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(*s390x.NewRotateParams(0, 63, 0).OutMerge(uint64(c))) + v.AddArg(x) + return true + } + break + } + // match: (AND x (MOVDconst [c])) + // cond: is32Bit(c) && c < 0 + // result: (ANDconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c) && c < 0) { + continue + } + v.reset(OpS390XANDconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (AND x (MOVDconst [c])) + // cond: is32Bit(c) && c >= 0 + // result: (MOVWZreg (ANDWconst [int32(c)] x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c) && c >= 0) { + continue + } + v.reset(OpS390XMOVWZreg) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (AND (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [c&d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpS390XMOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(c & d) + return true + } + break + } + // match: (AND x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (AND x g:(MOVDload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (ANDload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVDload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XANDload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XANDW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ANDW x (MOVDconst [c])) + // result: (ANDWconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XANDWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (ANDW x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (ANDW x g:(MOVWload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (ANDWload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XANDWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (ANDW x g:(MOVWZload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (ANDWload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWZload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XANDWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XANDWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDWconst [c] (ANDWconst [d] x)) + // result: (ANDWconst [c&d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XANDWconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpS390XANDWconst) + v.AuxInt = int32ToAuxInt(c & d) + v.AddArg(x) + return true + } + // match: (ANDWconst [0x00ff] x) + // result: (MOVBZreg x) + for { + if auxIntToInt32(v.AuxInt) != 0x00ff { + break + } + x := v_0 + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (ANDWconst [0xffff] x) + // result: (MOVHZreg x) + for { + if auxIntToInt32(v.AuxInt) != 0xffff { + break + } + x := v_0 + v.reset(OpS390XMOVHZreg) + v.AddArg(x) + return true + } + // match: (ANDWconst [c] _) + // cond: int32(c)==0 + // result: (MOVDconst [0]) + for { + c := auxIntToInt32(v.AuxInt) + if !(int32(c) == 0) { + break + } + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (ANDWconst [c] x) + // cond: int32(c)==-1 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(int32(c) == -1) { + break + } + v.copyOf(x) + return true + } + // match: (ANDWconst [c] (MOVDconst [d])) + // result: (MOVDconst [int64(c)&d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(c) & d) + return true + } + return false +} +func rewriteValueS390X_OpS390XANDWload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ANDWload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (ANDWload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XANDWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (ANDWload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (ANDWload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XANDWload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XANDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ANDconst [c] (ANDconst [d] x)) + // result: (ANDconst [c&d] x) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpS390XANDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpS390XANDconst) + v.AuxInt = int64ToAuxInt(c & d) + v.AddArg(x) + return true + } + // match: (ANDconst [0] _) + // result: (MOVDconst [0]) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (ANDconst [-1] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ANDconst [c] (MOVDconst [d])) + // result: (MOVDconst [c&d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(c & d) + return true + } + return false +} +func rewriteValueS390X_OpS390XANDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ANDload [off] {sym} x ptr1 (FMOVDstore [off] {sym} ptr2 y _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (AND x (LGDR y)) + for { + t := v.Type + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr1 := v_1 + if v_2.Op != OpS390XFMOVDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + ptr2 := v_2.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XAND) + v0 := b.NewValue0(v_2.Pos, OpS390XLGDR, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (ANDload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (ANDload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XANDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (ANDload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (ANDload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XANDload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XCMP(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMP x (MOVDconst [c])) + // cond: is32Bit(c) + // result: (CMPconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + break + } + v.reset(OpS390XCMPconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (CMP (MOVDconst [c]) x) + // cond: is32Bit(c) + // result: (InvertFlags (CMPconst x [int32(c)])) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(c)) { + break + } + v.reset(OpS390XInvertFlags) + v0 := b.NewValue0(v.Pos, OpS390XCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMP x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMP y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpS390XInvertFlags) + v0 := b.NewValue0(v.Pos, OpS390XCMP, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueS390X_OpS390XCMPU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPU x (MOVDconst [c])) + // cond: isU32Bit(c) + // result: (CMPUconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isU32Bit(c)) { + break + } + v.reset(OpS390XCMPUconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (CMPU (MOVDconst [c]) x) + // cond: isU32Bit(c) + // result: (InvertFlags (CMPUconst x [int32(c)])) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(isU32Bit(c)) { + break + } + v.reset(OpS390XInvertFlags) + v0 := b.NewValue0(v.Pos, OpS390XCMPUconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMPU x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPU y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpS390XInvertFlags) + v0 := b.NewValue0(v.Pos, OpS390XCMPU, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueS390X_OpS390XCMPUconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPUconst (MOVDconst [x]) [y]) + // cond: uint64(x)==uint64(y) + // result: (FlagEQ) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(uint64(x) == uint64(y)) { + break + } + v.reset(OpS390XFlagEQ) + return true + } + // match: (CMPUconst (MOVDconst [x]) [y]) + // cond: uint64(x)uint64(y) + // result: (FlagGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(uint64(x) > uint64(y)) { + break + } + v.reset(OpS390XFlagGT) + return true + } + // match: (CMPUconst (SRDconst _ [c]) [n]) + // cond: c > 0 && c < 64 && (1< 0 && c < 64 && (1<= 0 + // result: (CMPWUconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVWZreg { + break + } + x := v_0.Args[0] + if x.Op != OpS390XANDWconst { + break + } + m := auxIntToInt32(x.AuxInt) + if !(int32(m) >= 0) { + break + } + v.reset(OpS390XCMPWUconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPUconst (MOVWreg x:(ANDWconst [m] _)) [c]) + // cond: int32(m) >= 0 + // result: (CMPWUconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVWreg { + break + } + x := v_0.Args[0] + if x.Op != OpS390XANDWconst { + break + } + m := auxIntToInt32(x.AuxInt) + if !(int32(m) >= 0) { + break + } + v.reset(OpS390XCMPWUconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XCMPW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPW x (MOVDconst [c])) + // result: (CMPWconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XCMPWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (CMPW (MOVDconst [c]) x) + // result: (InvertFlags (CMPWconst x [int32(c)])) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpS390XInvertFlags) + v0 := b.NewValue0(v.Pos, OpS390XCMPWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMPW x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPW y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpS390XInvertFlags) + v0 := b.NewValue0(v.Pos, OpS390XCMPW, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + // match: (CMPW x (MOVWreg y)) + // result: (CMPW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XCMPW) + v.AddArg2(x, y) + return true + } + // match: (CMPW x (MOVWZreg y)) + // result: (CMPW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XCMPW) + v.AddArg2(x, y) + return true + } + // match: (CMPW (MOVWreg x) y) + // result: (CMPW x y) + for { + if v_0.Op != OpS390XMOVWreg { + break + } + x := v_0.Args[0] + y := v_1 + v.reset(OpS390XCMPW) + v.AddArg2(x, y) + return true + } + // match: (CMPW (MOVWZreg x) y) + // result: (CMPW x y) + for { + if v_0.Op != OpS390XMOVWZreg { + break + } + x := v_0.Args[0] + y := v_1 + v.reset(OpS390XCMPW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueS390X_OpS390XCMPWU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (CMPWU x (MOVDconst [c])) + // result: (CMPWUconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XCMPWUconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (CMPWU (MOVDconst [c]) x) + // result: (InvertFlags (CMPWUconst x [int32(c)])) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpS390XInvertFlags) + v0 := b.NewValue0(v.Pos, OpS390XCMPWUconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (CMPWU x y) + // cond: canonLessThan(x,y) + // result: (InvertFlags (CMPWU y x)) + for { + x := v_0 + y := v_1 + if !(canonLessThan(x, y)) { + break + } + v.reset(OpS390XInvertFlags) + v0 := b.NewValue0(v.Pos, OpS390XCMPWU, types.TypeFlags) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + // match: (CMPWU x (MOVWreg y)) + // result: (CMPWU x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XCMPWU) + v.AddArg2(x, y) + return true + } + // match: (CMPWU x (MOVWZreg y)) + // result: (CMPWU x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XCMPWU) + v.AddArg2(x, y) + return true + } + // match: (CMPWU (MOVWreg x) y) + // result: (CMPWU x y) + for { + if v_0.Op != OpS390XMOVWreg { + break + } + x := v_0.Args[0] + y := v_1 + v.reset(OpS390XCMPWU) + v.AddArg2(x, y) + return true + } + // match: (CMPWU (MOVWZreg x) y) + // result: (CMPWU x y) + for { + if v_0.Op != OpS390XMOVWZreg { + break + } + x := v_0.Args[0] + y := v_1 + v.reset(OpS390XCMPWU) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueS390X_OpS390XCMPWUconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPWUconst (MOVDconst [x]) [y]) + // cond: uint32(x)==uint32(y) + // result: (FlagEQ) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(uint32(x) == uint32(y)) { + break + } + v.reset(OpS390XFlagEQ) + return true + } + // match: (CMPWUconst (MOVDconst [x]) [y]) + // cond: uint32(x)uint32(y) + // result: (FlagGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(uint32(x) > uint32(y)) { + break + } + v.reset(OpS390XFlagGT) + return true + } + // match: (CMPWUconst (MOVBZreg _) [c]) + // cond: 0xff < c + // result: (FlagLT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVBZreg || !(0xff < c) { + break + } + v.reset(OpS390XFlagLT) + return true + } + // match: (CMPWUconst (MOVHZreg _) [c]) + // cond: 0xffff < c + // result: (FlagLT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVHZreg || !(0xffff < c) { + break + } + v.reset(OpS390XFlagLT) + return true + } + // match: (CMPWUconst (SRWconst _ [c]) [n]) + // cond: c > 0 && c < 32 && (1< 0 && c < 32 && (1<int32(y) + // result: (FlagGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(int32(x) > int32(y)) { + break + } + v.reset(OpS390XFlagGT) + return true + } + // match: (CMPWconst (MOVBZreg _) [c]) + // cond: 0xff < c + // result: (FlagLT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVBZreg || !(0xff < c) { + break + } + v.reset(OpS390XFlagLT) + return true + } + // match: (CMPWconst (MOVHZreg _) [c]) + // cond: 0xffff < c + // result: (FlagLT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVHZreg || !(0xffff < c) { + break + } + v.reset(OpS390XFlagLT) + return true + } + // match: (CMPWconst (SRWconst _ [c]) [n]) + // cond: c > 0 && n < 0 + // result: (FlagGT) + for { + n := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XSRWconst { + break + } + c := auxIntToUint8(v_0.AuxInt) + if !(c > 0 && n < 0) { + break + } + v.reset(OpS390XFlagGT) + return true + } + // match: (CMPWconst (ANDWconst _ [m]) [n]) + // cond: int32(m) >= 0 && int32(m) < int32(n) + // result: (FlagLT) + for { + n := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XANDWconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + if !(int32(m) >= 0 && int32(m) < int32(n)) { + break + } + v.reset(OpS390XFlagLT) + return true + } + // match: (CMPWconst x:(SRWconst _ [c]) [n]) + // cond: c > 0 && n >= 0 + // result: (CMPWUconst x [n]) + for { + n := auxIntToInt32(v.AuxInt) + x := v_0 + if x.Op != OpS390XSRWconst { + break + } + c := auxIntToUint8(x.AuxInt) + if !(c > 0 && n >= 0) { + break + } + v.reset(OpS390XCMPWUconst) + v.AuxInt = int32ToAuxInt(n) + v.AddArg(x) + return true + } + // match: (CMPWconst (MOVWreg x) [c]) + // result: (CMPWconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVWreg { + break + } + x := v_0.Args[0] + v.reset(OpS390XCMPWconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPWconst (MOVWZreg x) [c]) + // result: (CMPWconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVWZreg { + break + } + x := v_0.Args[0] + v.reset(OpS390XCMPWconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XCMPconst(v *Value) bool { + v_0 := v.Args[0] + // match: (CMPconst (MOVDconst [x]) [y]) + // cond: x==int64(y) + // result: (FlagEQ) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(x == int64(y)) { + break + } + v.reset(OpS390XFlagEQ) + return true + } + // match: (CMPconst (MOVDconst [x]) [y]) + // cond: xint64(y) + // result: (FlagGT) + for { + y := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(x > int64(y)) { + break + } + v.reset(OpS390XFlagGT) + return true + } + // match: (CMPconst (SRDconst _ [c]) [n]) + // cond: c > 0 && n < 0 + // result: (FlagGT) + for { + n := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XSRDconst { + break + } + c := auxIntToUint8(v_0.AuxInt) + if !(c > 0 && n < 0) { + break + } + v.reset(OpS390XFlagGT) + return true + } + // match: (CMPconst (RISBGZ x {r}) [c]) + // cond: c > 0 && r.OutMask() < uint64(c) + // result: (FlagLT) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_0.Aux) + if !(c > 0 && r.OutMask() < uint64(c)) { + break + } + v.reset(OpS390XFlagLT) + return true + } + // match: (CMPconst (MOVWreg x) [c]) + // result: (CMPWconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVWreg { + break + } + x := v_0.Args[0] + v.reset(OpS390XCMPWconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPconst x:(MOVHreg _) [c]) + // result: (CMPWconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if x.Op != OpS390XMOVHreg { + break + } + v.reset(OpS390XCMPWconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPconst x:(MOVHZreg _) [c]) + // result: (CMPWconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if x.Op != OpS390XMOVHZreg { + break + } + v.reset(OpS390XCMPWconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPconst x:(MOVBreg _) [c]) + // result: (CMPWconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if x.Op != OpS390XMOVBreg { + break + } + v.reset(OpS390XCMPWconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPconst x:(MOVBZreg _) [c]) + // result: (CMPWconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if x.Op != OpS390XMOVBZreg { + break + } + v.reset(OpS390XCMPWconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPconst (MOVWZreg x:(ANDWconst [m] _)) [c]) + // cond: int32(m) >= 0 && c >= 0 + // result: (CMPWUconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVWZreg { + break + } + x := v_0.Args[0] + if x.Op != OpS390XANDWconst { + break + } + m := auxIntToInt32(x.AuxInt) + if !(int32(m) >= 0 && c >= 0) { + break + } + v.reset(OpS390XCMPWUconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPconst (MOVWreg x:(ANDWconst [m] _)) [c]) + // cond: int32(m) >= 0 && c >= 0 + // result: (CMPWUconst x [c]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVWreg { + break + } + x := v_0.Args[0] + if x.Op != OpS390XANDWconst { + break + } + m := auxIntToInt32(x.AuxInt) + if !(int32(m) >= 0 && c >= 0) { + break + } + v.reset(OpS390XCMPWUconst) + v.AuxInt = int32ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (CMPconst x:(SRDconst _ [c]) [n]) + // cond: c > 0 && n >= 0 + // result: (CMPUconst x [n]) + for { + n := auxIntToInt32(v.AuxInt) + x := v_0 + if x.Op != OpS390XSRDconst { + break + } + c := auxIntToUint8(x.AuxInt) + if !(c > 0 && n >= 0) { + break + } + v.reset(OpS390XCMPUconst) + v.AuxInt = int32ToAuxInt(n) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XCPSDR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (CPSDR y (FMOVDconst [c])) + // cond: !math.Signbit(c) + // result: (LPDFR y) + for { + y := v_0 + if v_1.Op != OpS390XFMOVDconst { + break + } + c := auxIntToFloat64(v_1.AuxInt) + if !(!math.Signbit(c)) { + break + } + v.reset(OpS390XLPDFR) + v.AddArg(y) + return true + } + // match: (CPSDR y (FMOVDconst [c])) + // cond: math.Signbit(c) + // result: (LNDFR y) + for { + y := v_0 + if v_1.Op != OpS390XFMOVDconst { + break + } + c := auxIntToFloat64(v_1.AuxInt) + if !(math.Signbit(c)) { + break + } + v.reset(OpS390XLNDFR) + v.AddArg(y) + return true + } + return false +} +func rewriteValueS390X_OpS390XFCMP(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (FCMP x (FMOVDconst [0.0])) + // result: (LTDBR x) + for { + x := v_0 + if v_1.Op != OpS390XFMOVDconst || auxIntToFloat64(v_1.AuxInt) != 0.0 { + break + } + v.reset(OpS390XLTDBR) + v.AddArg(x) + return true + } + // match: (FCMP (FMOVDconst [0.0]) x) + // result: (InvertFlags (LTDBR x)) + for { + if v_0.Op != OpS390XFMOVDconst || auxIntToFloat64(v_0.AuxInt) != 0.0 { + break + } + x := v_1 + v.reset(OpS390XInvertFlags) + v0 := b.NewValue0(v.Pos, OpS390XLTDBR, v.Type) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueS390X_OpS390XFCMPS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (FCMPS x (FMOVSconst [0.0])) + // result: (LTEBR x) + for { + x := v_0 + if v_1.Op != OpS390XFMOVSconst || auxIntToFloat32(v_1.AuxInt) != 0.0 { + break + } + v.reset(OpS390XLTEBR) + v.AddArg(x) + return true + } + // match: (FCMPS (FMOVSconst [0.0]) x) + // result: (InvertFlags (LTEBR x)) + for { + if v_0.Op != OpS390XFMOVSconst || auxIntToFloat32(v_0.AuxInt) != 0.0 { + break + } + x := v_1 + v.reset(OpS390XInvertFlags) + v0 := b.NewValue0(v.Pos, OpS390XLTEBR, v.Type) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueS390X_OpS390XFMOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVDload [off] {sym} ptr1 (MOVDstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (LDGR x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XMOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XLDGR) + v.AddArg(x) + return true + } + // match: (FMOVDload [off] {sym} ptr1 (FMOVDstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XFMOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.copyOf(x) + return true + } + // match: (FMOVDload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (FMOVDload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XFMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (FMOVDload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (FMOVDload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpS390XFMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XFMOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (FMOVDstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XFMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (FMOVDstore [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (FMOVDstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpS390XFMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XFMOVSload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVSload [off] {sym} ptr1 (FMOVSstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XFMOVSstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.copyOf(x) + return true + } + // match: (FMOVSload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (FMOVSload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XFMOVSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (FMOVSload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (FMOVSload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpS390XFMOVSload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XFMOVSstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (FMOVSstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (FMOVSstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XFMOVSstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (FMOVSstore [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (FMOVSstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpS390XFMOVSstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XFNEG(v *Value) bool { + v_0 := v.Args[0] + // match: (FNEG (LPDFR x)) + // result: (LNDFR x) + for { + if v_0.Op != OpS390XLPDFR { + break + } + x := v_0.Args[0] + v.reset(OpS390XLNDFR) + v.AddArg(x) + return true + } + // match: (FNEG (LNDFR x)) + // result: (LPDFR x) + for { + if v_0.Op != OpS390XLNDFR { + break + } + x := v_0.Args[0] + v.reset(OpS390XLPDFR) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XFNEGS(v *Value) bool { + v_0 := v.Args[0] + // match: (FNEGS (LPDFR x)) + // result: (LNDFR x) + for { + if v_0.Op != OpS390XLPDFR { + break + } + x := v_0.Args[0] + v.reset(OpS390XLNDFR) + v.AddArg(x) + return true + } + // match: (FNEGS (LNDFR x)) + // result: (LPDFR x) + for { + if v_0.Op != OpS390XLNDFR { + break + } + x := v_0.Args[0] + v.reset(OpS390XLPDFR) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XLDGR(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (LDGR (RISBGZ x {r})) + // cond: r == s390x.NewRotateParams(1, 63, 0) + // result: (LPDFR (LDGR x)) + for { + t := v.Type + if v_0.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_0.Aux) + x := v_0.Args[0] + if !(r == s390x.NewRotateParams(1, 63, 0)) { + break + } + v.reset(OpS390XLPDFR) + v0 := b.NewValue0(v.Pos, OpS390XLDGR, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (LDGR (OR (MOVDconst [-1<<63]) x)) + // result: (LNDFR (LDGR x)) + for { + t := v.Type + if v_0.Op != OpS390XOR { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0.AuxInt) != -1<<63 { + continue + } + x := v_0_1 + v.reset(OpS390XLNDFR) + v0 := b.NewValue0(v.Pos, OpS390XLDGR, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (LDGR x:(ORload [off] {sym} (MOVDconst [-1<<63]) ptr mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (LNDFR (LDGR (MOVDload [off] {sym} ptr mem))) + for { + t := v.Type + x := v_0 + if x.Op != OpS390XORload { + break + } + t1 := x.Type + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[2] + x_0 := x.Args[0] + if x_0.Op != OpS390XMOVDconst || auxIntToInt64(x_0.AuxInt) != -1<<63 { + break + } + ptr := x.Args[1] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpS390XLNDFR, t) + v.copyOf(v0) + v1 := b.NewValue0(x.Pos, OpS390XLDGR, t) + v2 := b.NewValue0(x.Pos, OpS390XMOVDload, t1) + v2.AuxInt = int32ToAuxInt(off) + v2.Aux = symToAux(sym) + v2.AddArg2(ptr, mem) + v1.AddArg(v2) + v0.AddArg(v1) + return true + } + // match: (LDGR (LGDR x)) + // result: x + for { + if v_0.Op != OpS390XLGDR { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XLEDBR(v *Value) bool { + v_0 := v.Args[0] + // match: (LEDBR (LPDFR (LDEBR x))) + // result: (LPDFR x) + for { + if v_0.Op != OpS390XLPDFR { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XLDEBR { + break + } + x := v_0_0.Args[0] + v.reset(OpS390XLPDFR) + v.AddArg(x) + return true + } + // match: (LEDBR (LNDFR (LDEBR x))) + // result: (LNDFR x) + for { + if v_0.Op != OpS390XLNDFR { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XLDEBR { + break + } + x := v_0_0.Args[0] + v.reset(OpS390XLNDFR) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XLGDR(v *Value) bool { + v_0 := v.Args[0] + // match: (LGDR (LDGR x)) + // result: x + for { + if v_0.Op != OpS390XLDGR { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XLOCGR(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LOCGR {c} x y (InvertFlags cmp)) + // result: (LOCGR {c.ReverseComparison()} x y cmp) + for { + c := auxToS390xCCMask(v.Aux) + x := v_0 + y := v_1 + if v_2.Op != OpS390XInvertFlags { + break + } + cmp := v_2.Args[0] + v.reset(OpS390XLOCGR) + v.Aux = s390xCCMaskToAux(c.ReverseComparison()) + v.AddArg3(x, y, cmp) + return true + } + // match: (LOCGR {c} _ x (FlagEQ)) + // cond: c&s390x.Equal != 0 + // result: x + for { + c := auxToS390xCCMask(v.Aux) + x := v_1 + if v_2.Op != OpS390XFlagEQ || !(c&s390x.Equal != 0) { + break + } + v.copyOf(x) + return true + } + // match: (LOCGR {c} _ x (FlagLT)) + // cond: c&s390x.Less != 0 + // result: x + for { + c := auxToS390xCCMask(v.Aux) + x := v_1 + if v_2.Op != OpS390XFlagLT || !(c&s390x.Less != 0) { + break + } + v.copyOf(x) + return true + } + // match: (LOCGR {c} _ x (FlagGT)) + // cond: c&s390x.Greater != 0 + // result: x + for { + c := auxToS390xCCMask(v.Aux) + x := v_1 + if v_2.Op != OpS390XFlagGT || !(c&s390x.Greater != 0) { + break + } + v.copyOf(x) + return true + } + // match: (LOCGR {c} _ x (FlagOV)) + // cond: c&s390x.Unordered != 0 + // result: x + for { + c := auxToS390xCCMask(v.Aux) + x := v_1 + if v_2.Op != OpS390XFlagOV || !(c&s390x.Unordered != 0) { + break + } + v.copyOf(x) + return true + } + // match: (LOCGR {c} x _ (FlagEQ)) + // cond: c&s390x.Equal == 0 + // result: x + for { + c := auxToS390xCCMask(v.Aux) + x := v_0 + if v_2.Op != OpS390XFlagEQ || !(c&s390x.Equal == 0) { + break + } + v.copyOf(x) + return true + } + // match: (LOCGR {c} x _ (FlagLT)) + // cond: c&s390x.Less == 0 + // result: x + for { + c := auxToS390xCCMask(v.Aux) + x := v_0 + if v_2.Op != OpS390XFlagLT || !(c&s390x.Less == 0) { + break + } + v.copyOf(x) + return true + } + // match: (LOCGR {c} x _ (FlagGT)) + // cond: c&s390x.Greater == 0 + // result: x + for { + c := auxToS390xCCMask(v.Aux) + x := v_0 + if v_2.Op != OpS390XFlagGT || !(c&s390x.Greater == 0) { + break + } + v.copyOf(x) + return true + } + // match: (LOCGR {c} x _ (FlagOV)) + // cond: c&s390x.Unordered == 0 + // result: x + for { + c := auxToS390xCCMask(v.Aux) + x := v_0 + if v_2.Op != OpS390XFlagOV || !(c&s390x.Unordered == 0) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XLTDBR(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (LTDBR (Select0 x:(FADD _ _))) + // cond: b == x.Block + // result: (Select1 x) + for { + if v_0.Op != OpSelect0 { + break + } + x := v_0.Args[0] + if x.Op != OpS390XFADD || !(b == x.Block) { + break + } + v.reset(OpSelect1) + v.AddArg(x) + return true + } + // match: (LTDBR (Select0 x:(FSUB _ _))) + // cond: b == x.Block + // result: (Select1 x) + for { + if v_0.Op != OpSelect0 { + break + } + x := v_0.Args[0] + if x.Op != OpS390XFSUB || !(b == x.Block) { + break + } + v.reset(OpSelect1) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XLTEBR(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (LTEBR (Select0 x:(FADDS _ _))) + // cond: b == x.Block + // result: (Select1 x) + for { + if v_0.Op != OpSelect0 { + break + } + x := v_0.Args[0] + if x.Op != OpS390XFADDS || !(b == x.Block) { + break + } + v.reset(OpSelect1) + v.AddArg(x) + return true + } + // match: (LTEBR (Select0 x:(FSUBS _ _))) + // cond: b == x.Block + // result: (Select1 x) + for { + if v_0.Op != OpSelect0 { + break + } + x := v_0.Args[0] + if x.Op != OpS390XFSUBS || !(b == x.Block) { + break + } + v.reset(OpSelect1) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XLoweredPanicBoundsCR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsCR [kind] {p} (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:p.C, Cy:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpS390XLoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: p.C, Cy: c}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XLoweredPanicBoundsRC(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRC [kind] {p} (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsCC [kind] {PanicBoundsCC{Cx:c, Cy:p.C}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + p := auxToPanicBoundsC(v.Aux) + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + mem := v_1 + v.reset(OpS390XLoweredPanicBoundsCC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCCToAux(PanicBoundsCC{Cx: c, Cy: p.C}) + v.AddArg(mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XLoweredPanicBoundsRR(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (LoweredPanicBoundsRR [kind] x (MOVDconst [c]) mem) + // result: (LoweredPanicBoundsRC [kind] x {PanicBoundsC{C:c}} mem) + for { + kind := auxIntToInt64(v.AuxInt) + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + v.reset(OpS390XLoweredPanicBoundsRC) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(x, mem) + return true + } + // match: (LoweredPanicBoundsRR [kind] (MOVDconst [c]) y mem) + // result: (LoweredPanicBoundsCR [kind] {PanicBoundsC{C:c}} y mem) + for { + kind := auxIntToInt64(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + y := v_1 + mem := v_2 + v.reset(OpS390XLoweredPanicBoundsCR) + v.AuxInt = int64ToAuxInt(kind) + v.Aux = panicBoundsCToAux(PanicBoundsC{C: c}) + v.AddArg2(y, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XLoweredRound32F(v *Value) bool { + v_0 := v.Args[0] + // match: (LoweredRound32F x:(FMOVSconst)) + // result: x + for { + x := v_0 + if x.Op != OpS390XFMOVSconst { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XLoweredRound64F(v *Value) bool { + v_0 := v.Args[0] + // match: (LoweredRound64F x:(FMOVDconst)) + // result: x + for { + x := v_0 + if x.Op != OpS390XFMOVDconst { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVBZload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBZload [off] {sym} ptr1 (MOVBstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVBZreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XMOVBstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (MOVBZload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVBZload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVBZload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBZload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVBZload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpS390XMOVBZload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVBZreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVBZreg e:(MOVBreg x)) + // cond: clobberIfDead(e) + // result: (MOVBZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVBreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (MOVBZreg e:(MOVHreg x)) + // cond: clobberIfDead(e) + // result: (MOVBZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVHreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (MOVBZreg e:(MOVWreg x)) + // cond: clobberIfDead(e) + // result: (MOVBZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (MOVBZreg e:(MOVBZreg x)) + // cond: clobberIfDead(e) + // result: (MOVBZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVBZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (MOVBZreg e:(MOVHZreg x)) + // cond: clobberIfDead(e) + // result: (MOVBZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVHZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (MOVBZreg e:(MOVWZreg x)) + // cond: clobberIfDead(e) + // result: (MOVBZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (MOVBZreg x:(MOVBZload _ _)) + // cond: (!x.Type.IsSigned() || x.Type.Size() > 1) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVBZload || !(!x.Type.IsSigned() || x.Type.Size() > 1) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBZreg x:(MOVBload [o] {s} p mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBZload [o] {s} p mem) + for { + t := v.Type + x := v_0 + if x.Op != OpS390XMOVBload { + break + } + o := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpS390XMOVBZload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(o) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + // match: (MOVBZreg x:(Arg )) + // cond: !t.IsSigned() && t.Size() == 1 + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !(!t.IsSigned() && t.Size() == 1) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBZreg (MOVDconst [c])) + // result: (MOVDconst [int64( uint8(c))]) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint8(c))) + return true + } + // match: (MOVBZreg x:(LOCGR (MOVDconst [c]) (MOVDconst [d]) _)) + // cond: int64(uint8(c)) == c && int64(uint8(d)) == d && (!x.Type.IsSigned() || x.Type.Size() > 1) + // result: x + for { + x := v_0 + if x.Op != OpS390XLOCGR { + break + } + _ = x.Args[1] + x_0 := x.Args[0] + if x_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(x_0.AuxInt) + x_1 := x.Args[1] + if x_1.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(x_1.AuxInt) + if !(int64(uint8(c)) == c && int64(uint8(d)) == d && (!x.Type.IsSigned() || x.Type.Size() > 1)) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBZreg (RISBGZ x {r})) + // cond: r.OutMerge(0x000000ff) != nil + // result: (RISBGZ x {*r.OutMerge(0x000000ff)}) + for { + if v_0.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_0.Aux) + x := v_0.Args[0] + if !(r.OutMerge(0x000000ff) != nil) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(*r.OutMerge(0x000000ff)) + v.AddArg(x) + return true + } + // match: (MOVBZreg (ANDWconst [m] x)) + // result: (MOVWZreg (ANDWconst [int32( uint8(m))] x)) + for { + if v_0.Op != OpS390XANDWconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpS390XMOVWZreg) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(uint8(m))) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVBload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBload [off] {sym} ptr1 (MOVBstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVBreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XMOVBstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVBload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVBload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpS390XMOVBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVBreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVBreg e:(MOVBreg x)) + // cond: clobberIfDead(e) + // result: (MOVBreg x) + for { + e := v_0 + if e.Op != OpS390XMOVBreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBreg e:(MOVHreg x)) + // cond: clobberIfDead(e) + // result: (MOVBreg x) + for { + e := v_0 + if e.Op != OpS390XMOVHreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBreg e:(MOVWreg x)) + // cond: clobberIfDead(e) + // result: (MOVBreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBreg e:(MOVBZreg x)) + // cond: clobberIfDead(e) + // result: (MOVBreg x) + for { + e := v_0 + if e.Op != OpS390XMOVBZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBreg e:(MOVHZreg x)) + // cond: clobberIfDead(e) + // result: (MOVBreg x) + for { + e := v_0 + if e.Op != OpS390XMOVHZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBreg e:(MOVWZreg x)) + // cond: clobberIfDead(e) + // result: (MOVBreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVBreg x:(MOVBload _ _)) + // cond: (x.Type.IsSigned() || x.Type.Size() == 8) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVBload || !(x.Type.IsSigned() || x.Type.Size() == 8) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBreg x:(MOVBZload [o] {s} p mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVBload [o] {s} p mem) + for { + t := v.Type + x := v_0 + if x.Op != OpS390XMOVBZload { + break + } + o := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpS390XMOVBload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(o) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + // match: (MOVBreg x:(Arg )) + // cond: t.IsSigned() && t.Size() == 1 + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !(t.IsSigned() && t.Size() == 1) { + break + } + v.copyOf(x) + return true + } + // match: (MOVBreg (MOVDconst [c])) + // result: (MOVDconst [int64( int8(c))]) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(int8(c))) + return true + } + // match: (MOVBreg (ANDWconst [m] x)) + // cond: int8(m) >= 0 + // result: (MOVWZreg (ANDWconst [int32( uint8(m))] x)) + for { + if v_0.Op != OpS390XANDWconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(int8(m) >= 0) { + break + } + v.reset(OpS390XMOVWZreg) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(uint8(m))) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVBstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstore [off] {sym} ptr (MOVBreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpS390XMOVBreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpS390XMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVBZreg x) mem) + // result: (MOVBstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpS390XMOVBZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpS390XMOVBstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVBstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVBstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVBstore [off] {sym} ptr (MOVDconst [c]) mem) + // cond: is20Bit(int64(off)) && ptr.Op != OpSB + // result: (MOVBstoreconst [makeValAndOff(int32(int8(c)),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is20Bit(int64(off)) && ptr.Op != OpSB) { + break + } + v.reset(OpS390XMOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(int8(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstore [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) + // result: (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2)) { + break + } + v.reset(OpS390XMOVBstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVBstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVBstoreconst [sc] {s} (ADDconst [off] ptr) mem) + // cond: is20Bit(sc.Off64()+int64(off)) + // result: (MOVBstoreconst [sc.addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is20Bit(sc.Off64() + int64(off))) { + break + } + v.reset(OpS390XMOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVBstoreconst [sc] {sym1} (MOVDaddr [off] {sym2} ptr) mem) + // cond: ptr.Op != OpSB && canMergeSym(sym1, sym2) && sc.canAdd32(off) + // result: (MOVBstoreconst [sc.addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(ptr.Op != OpSB && canMergeSym(sym1, sym2) && sc.canAdd32(off)) { + break + } + v.reset(OpS390XMOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVDBR(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVDBR x:(MOVDload [off] {sym} ptr mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVDBRload [off] {sym} ptr mem) + for { + x := v_0 + if x.Op != OpS390XMOVDload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpS390XMOVDBRload, typ.UInt64) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg2(ptr, mem) + return true + } + // match: (MOVDBR x:(MOVDloadidx [off] {sym} ptr idx mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVDBRloadidx [off] {sym} ptr idx mem) + for { + x := v_0 + if x.Op != OpS390XMOVDloadidx { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[2] + ptr := x.Args[0] + idx := x.Args[1] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpS390XMOVDBRloadidx, typ.Int64) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(sym) + v0.AddArg3(ptr, idx, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVDaddridx(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDaddridx [c] {s} (ADDconst [d] x) y) + // cond: is20Bit(int64(c)+int64(d)) + // result: (MOVDaddridx [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + y := v_1 + if !(is20Bit(int64(c) + int64(d))) { + break + } + v.reset(OpS390XMOVDaddridx) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (MOVDaddridx [c] {s} x (ADDconst [d] y)) + // cond: is20Bit(int64(c)+int64(d)) + // result: (MOVDaddridx [c+d] {s} x y) + for { + c := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + d := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(is20Bit(int64(c) + int64(d))) { + break + } + v.reset(OpS390XMOVDaddridx) + v.AuxInt = int32ToAuxInt(c + d) + v.Aux = symToAux(s) + v.AddArg2(x, y) + return true + } + // match: (MOVDaddridx [off1] {sym1} (MOVDaddr [off2] {sym2} x) y) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB + // result: (MOVDaddridx [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + x := v_0.Args[0] + y := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB) { + break + } + v.reset(OpS390XMOVDaddridx) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + // match: (MOVDaddridx [off1] {sym1} x (MOVDaddr [off2] {sym2} y)) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && y.Op != OpSB + // result: (MOVDaddridx [off1+off2] {mergeSym(sym1,sym2)} x y) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + sym2 := auxToSym(v_1.Aux) + y := v_1.Args[0] + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && y.Op != OpSB) { + break + } + v.reset(OpS390XMOVDaddridx) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVDload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDload [off] {sym} ptr1 (MOVDstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: x + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XMOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.copyOf(x) + return true + } + // match: (MOVDload [off] {sym} ptr1 (FMOVDstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (LGDR x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XFMOVDstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XLGDR) + v.AddArg(x) + return true + } + // match: (MOVDload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVDload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%8 == 0 && (off1+off2)%8 == 0)) + // result: (MOVDload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + t := v_0.Type + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%8 == 0 && (off1+off2)%8 == 0))) { + break + } + v.reset(OpS390XMOVDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVDstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVDstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVDstore [off] {sym} ptr (MOVDconst [c]) mem) + // cond: is16Bit(c) && isU12Bit(int64(off)) && ptr.Op != OpSB + // result: (MOVDstoreconst [makeValAndOff(int32(c),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is16Bit(c) && isU12Bit(int64(off)) && ptr.Op != OpSB) { + break + } + v.reset(OpS390XMOVDstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDstore [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%8 == 0 && (off1+off2)%8 == 0)) + // result: (MOVDstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + t := v_0.Type + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%8 == 0 && (off1+off2)%8 == 0))) { + break + } + v.reset(OpS390XMOVDstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVDstore [i] {s} p w1 x:(MOVDstore [i-8] {s} p w0 mem)) + // cond: p.Op != OpSB && x.Uses == 1 && is20Bit(int64(i)-8) && setPos(v, x.Pos) && clobber(x) + // result: (STMG2 [i-8] {s} p w0 w1 mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + w1 := v_1 + x := v_2 + if x.Op != OpS390XMOVDstore || auxIntToInt32(x.AuxInt) != i-8 || auxToSym(x.Aux) != s { + break + } + mem := x.Args[2] + if p != x.Args[0] { + break + } + w0 := x.Args[1] + if !(p.Op != OpSB && x.Uses == 1 && is20Bit(int64(i)-8) && setPos(v, x.Pos) && clobber(x)) { + break + } + v.reset(OpS390XSTMG2) + v.AuxInt = int32ToAuxInt(i - 8) + v.Aux = symToAux(s) + v.AddArg4(p, w0, w1, mem) + return true + } + // match: (MOVDstore [i] {s} p w2 x:(STMG2 [i-16] {s} p w0 w1 mem)) + // cond: x.Uses == 1 && is20Bit(int64(i)-16) && setPos(v, x.Pos) && clobber(x) + // result: (STMG3 [i-16] {s} p w0 w1 w2 mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + w2 := v_1 + x := v_2 + if x.Op != OpS390XSTMG2 || auxIntToInt32(x.AuxInt) != i-16 || auxToSym(x.Aux) != s { + break + } + mem := x.Args[3] + if p != x.Args[0] { + break + } + w0 := x.Args[1] + w1 := x.Args[2] + if !(x.Uses == 1 && is20Bit(int64(i)-16) && setPos(v, x.Pos) && clobber(x)) { + break + } + v.reset(OpS390XSTMG3) + v.AuxInt = int32ToAuxInt(i - 16) + v.Aux = symToAux(s) + v.AddArg5(p, w0, w1, w2, mem) + return true + } + // match: (MOVDstore [i] {s} p w3 x:(STMG3 [i-24] {s} p w0 w1 w2 mem)) + // cond: x.Uses == 1 && is20Bit(int64(i)-24) && setPos(v, x.Pos) && clobber(x) + // result: (STMG4 [i-24] {s} p w0 w1 w2 w3 mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + w3 := v_1 + x := v_2 + if x.Op != OpS390XSTMG3 || auxIntToInt32(x.AuxInt) != i-24 || auxToSym(x.Aux) != s { + break + } + mem := x.Args[4] + if p != x.Args[0] { + break + } + w0 := x.Args[1] + w1 := x.Args[2] + w2 := x.Args[3] + if !(x.Uses == 1 && is20Bit(int64(i)-24) && setPos(v, x.Pos) && clobber(x)) { + break + } + v.reset(OpS390XSTMG4) + v.AuxInt = int32ToAuxInt(i - 24) + v.Aux = symToAux(s) + v.AddArg6(p, w0, w1, w2, w3, mem) + return true + } + // match: (MOVDstore [off] {sym} ptr r:(MOVDBR x) mem) + // cond: r.Uses == 1 + // result: (MOVDBRstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + r := v_1 + if r.Op != OpS390XMOVDBR { + break + } + x := r.Args[0] + mem := v_2 + if !(r.Uses == 1) { + break + } + v.reset(OpS390XMOVDBRstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVDstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDstoreconst [sc] {s} (ADDconst [off] ptr) mem) + // cond: isU12Bit(sc.Off64()+int64(off)) + // result: (MOVDstoreconst [sc.addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(isU12Bit(sc.Off64() + int64(off))) { + break + } + v.reset(OpS390XMOVDstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVDstoreconst [sc] {sym1} (MOVDaddr [off] {sym2} ptr) mem) + // cond: ptr.Op != OpSB && canMergeSym(sym1, sym2) && sc.canAdd32(off) + // result: (MOVDstoreconst [sc.addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(ptr.Op != OpSB && canMergeSym(sym1, sym2) && sc.canAdd32(off)) { + break + } + v.reset(OpS390XMOVDstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVDstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVDstoreidx [off] {sym} ptr idx r:(MOVDBR x) mem) + // cond: r.Uses == 1 + // result: (MOVDBRstoreidx [off] {sym} ptr idx x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + r := v_2 + if r.Op != OpS390XMOVDBR { + break + } + x := r.Args[0] + mem := v_3 + if !(r.Uses == 1) { + break + } + v.reset(OpS390XMOVDBRstoreidx) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(ptr, idx, x, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVHZload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHZload [off] {sym} ptr1 (MOVHstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVHZreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XMOVHstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XMOVHZreg) + v.AddArg(x) + return true + } + // match: (MOVHZload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVHZload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVHZload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHZload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%2 == 0 && (off1+off2)%2 == 0)) + // result: (MOVHZload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + t := v_0.Type + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%2 == 0 && (off1+off2)%2 == 0))) { + break + } + v.reset(OpS390XMOVHZload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVHZreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVHZreg e:(MOVBZreg x)) + // cond: clobberIfDead(e) + // result: (MOVBZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVBZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (MOVHZreg e:(MOVHreg x)) + // cond: clobberIfDead(e) + // result: (MOVHZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVHreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVHZreg) + v.AddArg(x) + return true + } + // match: (MOVHZreg e:(MOVWreg x)) + // cond: clobberIfDead(e) + // result: (MOVHZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVHZreg) + v.AddArg(x) + return true + } + // match: (MOVHZreg e:(MOVHZreg x)) + // cond: clobberIfDead(e) + // result: (MOVHZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVHZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVHZreg) + v.AddArg(x) + return true + } + // match: (MOVHZreg e:(MOVWZreg x)) + // cond: clobberIfDead(e) + // result: (MOVHZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVHZreg) + v.AddArg(x) + return true + } + // match: (MOVHZreg x:(MOVBZload _ _)) + // cond: (!x.Type.IsSigned() || x.Type.Size() > 1) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVBZload || !(!x.Type.IsSigned() || x.Type.Size() > 1) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHZreg x:(MOVHZload _ _)) + // cond: (!x.Type.IsSigned() || x.Type.Size() > 2) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVHZload || !(!x.Type.IsSigned() || x.Type.Size() > 2) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHZreg x:(MOVHload [o] {s} p mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVHZload [o] {s} p mem) + for { + t := v.Type + x := v_0 + if x.Op != OpS390XMOVHload { + break + } + o := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpS390XMOVHZload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(o) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + // match: (MOVHZreg x:(Arg )) + // cond: !t.IsSigned() && t.Size() <= 2 + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !(!t.IsSigned() && t.Size() <= 2) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHZreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint16(c))]) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint16(c))) + return true + } + // match: (MOVHZreg (RISBGZ x {r})) + // cond: r.OutMerge(0x0000ffff) != nil + // result: (RISBGZ x {*r.OutMerge(0x0000ffff)}) + for { + if v_0.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_0.Aux) + x := v_0.Args[0] + if !(r.OutMerge(0x0000ffff) != nil) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(*r.OutMerge(0x0000ffff)) + v.AddArg(x) + return true + } + // match: (MOVHZreg (ANDWconst [m] x)) + // result: (MOVWZreg (ANDWconst [int32(uint16(m))] x)) + for { + if v_0.Op != OpS390XANDWconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpS390XMOVWZreg) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(uint16(m))) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVHload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHload [off] {sym} ptr1 (MOVHstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVHreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XMOVHstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XMOVHreg) + v.AddArg(x) + return true + } + // match: (MOVHload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVHload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVHload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%2 == 0 && (off1+off2)%2 == 0)) + // result: (MOVHload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + t := v_0.Type + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%2 == 0 && (off1+off2)%2 == 0))) { + break + } + v.reset(OpS390XMOVHload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVHreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVHreg e:(MOVBreg x)) + // cond: clobberIfDead(e) + // result: (MOVBreg x) + for { + e := v_0 + if e.Op != OpS390XMOVBreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVHreg e:(MOVHreg x)) + // cond: clobberIfDead(e) + // result: (MOVHreg x) + for { + e := v_0 + if e.Op != OpS390XMOVHreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVHreg) + v.AddArg(x) + return true + } + // match: (MOVHreg e:(MOVWreg x)) + // cond: clobberIfDead(e) + // result: (MOVHreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVHreg) + v.AddArg(x) + return true + } + // match: (MOVHreg e:(MOVHZreg x)) + // cond: clobberIfDead(e) + // result: (MOVHreg x) + for { + e := v_0 + if e.Op != OpS390XMOVHZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVHreg) + v.AddArg(x) + return true + } + // match: (MOVHreg e:(MOVWZreg x)) + // cond: clobberIfDead(e) + // result: (MOVHreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVHreg) + v.AddArg(x) + return true + } + // match: (MOVHreg x:(MOVBload _ _)) + // cond: (x.Type.IsSigned() || x.Type.Size() == 8) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVBload || !(x.Type.IsSigned() || x.Type.Size() == 8) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHreg x:(MOVHload _ _)) + // cond: (x.Type.IsSigned() || x.Type.Size() == 8) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVHload || !(x.Type.IsSigned() || x.Type.Size() == 8) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHreg x:(MOVBZload _ _)) + // cond: (!x.Type.IsSigned() || x.Type.Size() > 1) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVBZload || !(!x.Type.IsSigned() || x.Type.Size() > 1) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHreg x:(MOVHZload [o] {s} p mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVHload [o] {s} p mem) + for { + t := v.Type + x := v_0 + if x.Op != OpS390XMOVHZload { + break + } + o := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpS390XMOVHload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(o) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + // match: (MOVHreg x:(Arg )) + // cond: t.IsSigned() && t.Size() <= 2 + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !(t.IsSigned() && t.Size() <= 2) { + break + } + v.copyOf(x) + return true + } + // match: (MOVHreg (MOVDconst [c])) + // result: (MOVDconst [int64(int16(c))]) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(int16(c))) + return true + } + // match: (MOVHreg (ANDWconst [m] x)) + // cond: int16(m) >= 0 + // result: (MOVWZreg (ANDWconst [int32(uint16(m))] x)) + for { + if v_0.Op != OpS390XANDWconst { + break + } + m := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(int16(m) >= 0) { + break + } + v.reset(OpS390XMOVWZreg) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(uint16(m))) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVHstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstore [off] {sym} ptr (MOVHreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpS390XMOVHreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpS390XMOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVHZreg x) mem) + // result: (MOVHstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpS390XMOVHZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpS390XMOVHstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVHstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVHstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVHstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (MOVDconst [c]) mem) + // cond: isU12Bit(int64(off)) && ptr.Op != OpSB + // result: (MOVHstoreconst [makeValAndOff(int32(int16(c)),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(isU12Bit(int64(off)) && ptr.Op != OpSB) { + break + } + v.reset(OpS390XMOVHstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(int16(c)), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHstore [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%2 == 0 && (off1+off2)%2 == 0)) + // result: (MOVHstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + t := v_0.Type + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%2 == 0 && (off1+off2)%2 == 0))) { + break + } + v.reset(OpS390XMOVHstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVHstore [off] {sym} ptr (Bswap16 val) mem) + // result: (MOVHBRstore [off] {sym} ptr val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpBswap16 { + break + } + val := v_1.Args[0] + mem := v_2 + v.reset(OpS390XMOVHBRstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVHstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstoreconst [sc] {s} (ADDconst [off] ptr) mem) + // cond: isU12Bit(sc.Off64()+int64(off)) + // result: (MOVHstoreconst [sc.addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(isU12Bit(sc.Off64() + int64(off))) { + break + } + v.reset(OpS390XMOVHstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVHstoreconst [sc] {sym1} (MOVDaddr [off] {sym2} ptr) mem) + // cond: ptr.Op != OpSB && canMergeSym(sym1, sym2) && sc.canAdd32(off) + // result: (MOVHstoreconst [sc.addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(ptr.Op != OpSB && canMergeSym(sym1, sym2) && sc.canAdd32(off)) { + break + } + v.reset(OpS390XMOVHstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVHstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVHstoreidx [off] {sym} ptr idx (Bswap16 val) mem) + // result: (MOVHBRstoreidx [off] {sym} ptr idx val mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + if v_2.Op != OpBswap16 { + break + } + val := v_2.Args[0] + mem := v_3 + v.reset(OpS390XMOVHBRstoreidx) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(ptr, idx, val, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVWBR(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (MOVWBR x:(MOVWZload [off] {sym} ptr mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVWZreg (MOVWBRload [off] {sym} ptr mem)) + for { + x := v_0 + if x.Op != OpS390XMOVWZload { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[1] + ptr := x.Args[0] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpS390XMOVWZreg, typ.UInt64) + v.copyOf(v0) + v1 := b.NewValue0(x.Pos, OpS390XMOVWBRload, typ.UInt32) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(sym) + v1.AddArg2(ptr, mem) + v0.AddArg(v1) + return true + } + // match: (MOVWBR x:(MOVWZloadidx [off] {sym} ptr idx mem)) + // cond: x.Uses == 1 + // result: @x.Block (MOVWZreg (MOVWBRloadidx [off] {sym} ptr idx mem)) + for { + x := v_0 + if x.Op != OpS390XMOVWZloadidx { + break + } + off := auxIntToInt32(x.AuxInt) + sym := auxToSym(x.Aux) + mem := x.Args[2] + ptr := x.Args[0] + idx := x.Args[1] + if !(x.Uses == 1) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpS390XMOVWZreg, typ.UInt64) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpS390XMOVWBRloadidx, typ.Int32) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(sym) + v1.AddArg3(ptr, idx, mem) + v0.AddArg(v1) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVWZload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWZload [off] {sym} ptr1 (MOVWstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVWZreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XMOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XMOVWZreg) + v.AddArg(x) + return true + } + // match: (MOVWZload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVWZload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVWZload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWZload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%4 == 0 && (off1+off2)%4 == 0)) + // result: (MOVWZload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + t := v_0.Type + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%4 == 0 && (off1+off2)%4 == 0))) { + break + } + v.reset(OpS390XMOVWZload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVWZreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVWZreg e:(MOVBZreg x)) + // cond: clobberIfDead(e) + // result: (MOVBZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVBZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (MOVWZreg e:(MOVHZreg x)) + // cond: clobberIfDead(e) + // result: (MOVHZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVHZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVHZreg) + v.AddArg(x) + return true + } + // match: (MOVWZreg e:(MOVWreg x)) + // cond: clobberIfDead(e) + // result: (MOVWZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVWZreg) + v.AddArg(x) + return true + } + // match: (MOVWZreg e:(MOVWZreg x)) + // cond: clobberIfDead(e) + // result: (MOVWZreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVWZreg) + v.AddArg(x) + return true + } + // match: (MOVWZreg x:(MOVBZload _ _)) + // cond: (!x.Type.IsSigned() || x.Type.Size() > 1) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVBZload || !(!x.Type.IsSigned() || x.Type.Size() > 1) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg x:(MOVHZload _ _)) + // cond: (!x.Type.IsSigned() || x.Type.Size() > 2) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVHZload || !(!x.Type.IsSigned() || x.Type.Size() > 2) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg x:(MOVWZload _ _)) + // cond: (!x.Type.IsSigned() || x.Type.Size() > 4) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVWZload || !(!x.Type.IsSigned() || x.Type.Size() > 4) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg x:(MOVWload [o] {s} p mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWZload [o] {s} p mem) + for { + t := v.Type + x := v_0 + if x.Op != OpS390XMOVWload { + break + } + o := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpS390XMOVWZload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(o) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + // match: (MOVWZreg x:(Arg )) + // cond: !t.IsSigned() && t.Size() <= 4 + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !(!t.IsSigned() && t.Size() <= 4) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWZreg (MOVDconst [c])) + // result: (MOVDconst [int64(uint32(c))]) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(uint32(c))) + return true + } + // match: (MOVWZreg (RISBGZ x {r})) + // cond: r.OutMerge(0xffffffff) != nil + // result: (RISBGZ x {*r.OutMerge(0xffffffff)}) + for { + if v_0.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_0.Aux) + x := v_0.Args[0] + if !(r.OutMerge(0xffffffff) != nil) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(*r.OutMerge(0xffffffff)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVWload(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWload [off] {sym} ptr1 (MOVWstore [off] {sym} ptr2 x _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MOVWreg x) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr1 := v_0 + if v_1.Op != OpS390XMOVWstore || auxIntToInt32(v_1.AuxInt) != off || auxToSym(v_1.Aux) != sym { + break + } + x := v_1.Args[1] + ptr2 := v_1.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVWload [off1] {sym} (ADDconst [off2] ptr) mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVWload [off1+off2] {sym} ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%4 == 0 && (off1+off2)%4 == 0)) + // result: (MOVWload [off1+off2] {mergeSym(sym1,sym2)} base mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + t := v_0.Type + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + mem := v_1 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%4 == 0 && (off1+off2)%4 == 0))) { + break + } + v.reset(OpS390XMOVWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(base, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVWreg(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MOVWreg e:(MOVBreg x)) + // cond: clobberIfDead(e) + // result: (MOVBreg x) + for { + e := v_0 + if e.Op != OpS390XMOVBreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVBreg) + v.AddArg(x) + return true + } + // match: (MOVWreg e:(MOVHreg x)) + // cond: clobberIfDead(e) + // result: (MOVHreg x) + for { + e := v_0 + if e.Op != OpS390XMOVHreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVHreg) + v.AddArg(x) + return true + } + // match: (MOVWreg e:(MOVWreg x)) + // cond: clobberIfDead(e) + // result: (MOVWreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVWreg e:(MOVWZreg x)) + // cond: clobberIfDead(e) + // result: (MOVWreg x) + for { + e := v_0 + if e.Op != OpS390XMOVWZreg { + break + } + x := e.Args[0] + if !(clobberIfDead(e)) { + break + } + v.reset(OpS390XMOVWreg) + v.AddArg(x) + return true + } + // match: (MOVWreg x:(MOVBload _ _)) + // cond: (x.Type.IsSigned() || x.Type.Size() == 8) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVBload || !(x.Type.IsSigned() || x.Type.Size() == 8) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg x:(MOVHload _ _)) + // cond: (x.Type.IsSigned() || x.Type.Size() == 8) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVHload || !(x.Type.IsSigned() || x.Type.Size() == 8) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg x:(MOVWload _ _)) + // cond: (x.Type.IsSigned() || x.Type.Size() == 8) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVWload || !(x.Type.IsSigned() || x.Type.Size() == 8) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg x:(MOVBZload _ _)) + // cond: (!x.Type.IsSigned() || x.Type.Size() > 1) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVBZload || !(!x.Type.IsSigned() || x.Type.Size() > 1) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg x:(MOVHZload _ _)) + // cond: (!x.Type.IsSigned() || x.Type.Size() > 2) + // result: x + for { + x := v_0 + if x.Op != OpS390XMOVHZload || !(!x.Type.IsSigned() || x.Type.Size() > 2) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg x:(MOVWZload [o] {s} p mem)) + // cond: x.Uses == 1 && clobber(x) + // result: @x.Block (MOVWload [o] {s} p mem) + for { + t := v.Type + x := v_0 + if x.Op != OpS390XMOVWZload { + break + } + o := auxIntToInt32(x.AuxInt) + s := auxToSym(x.Aux) + mem := x.Args[1] + p := x.Args[0] + if !(x.Uses == 1 && clobber(x)) { + break + } + b = x.Block + v0 := b.NewValue0(x.Pos, OpS390XMOVWload, t) + v.copyOf(v0) + v0.AuxInt = int32ToAuxInt(o) + v0.Aux = symToAux(s) + v0.AddArg2(p, mem) + return true + } + // match: (MOVWreg x:(Arg )) + // cond: t.IsSigned() && t.Size() <= 4 + // result: x + for { + x := v_0 + if x.Op != OpArg { + break + } + t := x.Type + if !(t.IsSigned() && t.Size() <= 4) { + break + } + v.copyOf(x) + return true + } + // match: (MOVWreg (MOVDconst [c])) + // result: (MOVDconst [int64(int32(c))]) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(int32(c))) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVWstore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstore [off] {sym} ptr (MOVWreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpS390XMOVWreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpS390XMOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVWZreg x) mem) + // result: (MOVWstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpS390XMOVWZreg { + break + } + x := v_1.Args[0] + mem := v_2 + v.reset(OpS390XMOVWstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + // match: (MOVWstore [off1] {sym} (ADDconst [off2] ptr) val mem) + // cond: is20Bit(int64(off1)+int64(off2)) + // result: (MOVWstore [off1+off2] {sym} ptr val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is20Bit(int64(off1) + int64(off2))) { + break + } + v.reset(OpS390XMOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(ptr, val, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr (MOVDconst [c]) mem) + // cond: is16Bit(c) && isU12Bit(int64(off)) && ptr.Op != OpSB + // result: (MOVWstoreconst [makeValAndOff(int32(c),off)] {sym} ptr mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + mem := v_2 + if !(is16Bit(c) && isU12Bit(int64(off)) && ptr.Op != OpSB) { + break + } + v.reset(OpS390XMOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(c), off)) + v.Aux = symToAux(sym) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstore [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) + // cond: is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%4 == 0 && (off1+off2)%4 == 0)) + // result: (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} base val mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + t := v_0.Type + off2 := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + base := v_0.Args[0] + val := v_1 + mem := v_2 + if !(is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && (base.Op != OpSB || (t.IsPtr() && t.Elem().Alignment()%4 == 0 && (off1+off2)%4 == 0))) { + break + } + v.reset(OpS390XMOVWstore) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg3(base, val, mem) + return true + } + // match: (MOVWstore [i] {s} p w1 x:(MOVWstore [i-4] {s} p w0 mem)) + // cond: p.Op != OpSB && x.Uses == 1 && is20Bit(int64(i)-4) && setPos(v, x.Pos) && clobber(x) + // result: (STM2 [i-4] {s} p w0 w1 mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + w1 := v_1 + x := v_2 + if x.Op != OpS390XMOVWstore || auxIntToInt32(x.AuxInt) != i-4 || auxToSym(x.Aux) != s { + break + } + mem := x.Args[2] + if p != x.Args[0] { + break + } + w0 := x.Args[1] + if !(p.Op != OpSB && x.Uses == 1 && is20Bit(int64(i)-4) && setPos(v, x.Pos) && clobber(x)) { + break + } + v.reset(OpS390XSTM2) + v.AuxInt = int32ToAuxInt(i - 4) + v.Aux = symToAux(s) + v.AddArg4(p, w0, w1, mem) + return true + } + // match: (MOVWstore [i] {s} p w2 x:(STM2 [i-8] {s} p w0 w1 mem)) + // cond: x.Uses == 1 && is20Bit(int64(i)-8) && setPos(v, x.Pos) && clobber(x) + // result: (STM3 [i-8] {s} p w0 w1 w2 mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + w2 := v_1 + x := v_2 + if x.Op != OpS390XSTM2 || auxIntToInt32(x.AuxInt) != i-8 || auxToSym(x.Aux) != s { + break + } + mem := x.Args[3] + if p != x.Args[0] { + break + } + w0 := x.Args[1] + w1 := x.Args[2] + if !(x.Uses == 1 && is20Bit(int64(i)-8) && setPos(v, x.Pos) && clobber(x)) { + break + } + v.reset(OpS390XSTM3) + v.AuxInt = int32ToAuxInt(i - 8) + v.Aux = symToAux(s) + v.AddArg5(p, w0, w1, w2, mem) + return true + } + // match: (MOVWstore [i] {s} p w3 x:(STM3 [i-12] {s} p w0 w1 w2 mem)) + // cond: x.Uses == 1 && is20Bit(int64(i)-12) && setPos(v, x.Pos) && clobber(x) + // result: (STM4 [i-12] {s} p w0 w1 w2 w3 mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + w3 := v_1 + x := v_2 + if x.Op != OpS390XSTM3 || auxIntToInt32(x.AuxInt) != i-12 || auxToSym(x.Aux) != s { + break + } + mem := x.Args[4] + if p != x.Args[0] { + break + } + w0 := x.Args[1] + w1 := x.Args[2] + w2 := x.Args[3] + if !(x.Uses == 1 && is20Bit(int64(i)-12) && setPos(v, x.Pos) && clobber(x)) { + break + } + v.reset(OpS390XSTM4) + v.AuxInt = int32ToAuxInt(i - 12) + v.Aux = symToAux(s) + v.AddArg6(p, w0, w1, w2, w3, mem) + return true + } + // match: (MOVWstore [off] {sym} ptr r:(MOVWBR x) mem) + // cond: r.Uses == 1 + // result: (MOVWBRstore [off] {sym} ptr x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + r := v_1 + if r.Op != OpS390XMOVWBR { + break + } + x := r.Args[0] + mem := v_2 + if !(r.Uses == 1) { + break + } + v.reset(OpS390XMOVWBRstore) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(ptr, x, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVWstoreconst(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstoreconst [sc] {s} (ADDconst [off] ptr) mem) + // cond: isU12Bit(sc.Off64()+int64(off)) + // result: (MOVWstoreconst [sc.addOffset32(off)] {s} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + s := auxToSym(v.Aux) + if v_0.Op != OpS390XADDconst { + break + } + off := auxIntToInt32(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(isU12Bit(sc.Off64() + int64(off))) { + break + } + v.reset(OpS390XMOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(s) + v.AddArg2(ptr, mem) + return true + } + // match: (MOVWstoreconst [sc] {sym1} (MOVDaddr [off] {sym2} ptr) mem) + // cond: ptr.Op != OpSB && canMergeSym(sym1, sym2) && sc.canAdd32(off) + // result: (MOVWstoreconst [sc.addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) + for { + sc := auxIntToValAndOff(v.AuxInt) + sym1 := auxToSym(v.Aux) + if v_0.Op != OpS390XMOVDaddr { + break + } + off := auxIntToInt32(v_0.AuxInt) + sym2 := auxToSym(v_0.Aux) + ptr := v_0.Args[0] + mem := v_1 + if !(ptr.Op != OpSB && canMergeSym(sym1, sym2) && sc.canAdd32(off)) { + break + } + v.reset(OpS390XMOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(sc.addOffset32(off)) + v.Aux = symToAux(mergeSym(sym1, sym2)) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMOVWstoreidx(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MOVWstoreidx [off] {sym} ptr idx r:(MOVWBR x) mem) + // cond: r.Uses == 1 + // result: (MOVWBRstoreidx [off] {sym} ptr idx x mem) + for { + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + ptr := v_0 + idx := v_1 + r := v_2 + if r.Op != OpS390XMOVWBR { + break + } + x := r.Args[0] + mem := v_3 + if !(r.Uses == 1) { + break + } + v.reset(OpS390XMOVWBRstoreidx) + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg4(ptr, idx, x, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMULLD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULLD x (MOVDconst [c])) + // cond: is32Bit(c) + // result: (MULLDconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + continue + } + v.reset(OpS390XMULLDconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (MULLD x g:(MOVDload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (MULLDload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVDload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XMULLDload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XMULLDconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MULLDconst x [c]) + // cond: isPowerOfTwo(c&(c-1)) + // result: (ADD (SLDconst x [uint8(log32(c&(c-1)))]) (SLDconst x [uint8(log32(c&^(c-1)))])) + for { + t := v.Type + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(c & (c - 1))) { + break + } + v.reset(OpS390XADD) + v0 := b.NewValue0(v.Pos, OpS390XSLDconst, t) + v0.AuxInt = uint8ToAuxInt(uint8(log32(c & (c - 1)))) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XSLDconst, t) + v1.AuxInt = uint8ToAuxInt(uint8(log32(c &^ (c - 1)))) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } + // match: (MULLDconst x [c]) + // cond: isPowerOfTwo(c+(c&^(c-1))) + // result: (SUB (SLDconst x [uint8(log32(c+(c&^(c-1))))]) (SLDconst x [uint8(log32(c&^(c-1)))])) + for { + t := v.Type + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(c + (c &^ (c - 1)))) { + break + } + v.reset(OpS390XSUB) + v0 := b.NewValue0(v.Pos, OpS390XSLDconst, t) + v0.AuxInt = uint8ToAuxInt(uint8(log32(c + (c &^ (c - 1))))) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XSLDconst, t) + v1.AuxInt = uint8ToAuxInt(uint8(log32(c &^ (c - 1)))) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } + // match: (MULLDconst x [c]) + // cond: isPowerOfTwo(-c+(-c&^(-c-1))) + // result: (SUB (SLDconst x [uint8(log32(-c&^(-c-1)))]) (SLDconst x [uint8(log32(-c+(-c&^(-c-1))))])) + for { + t := v.Type + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(-c + (-c &^ (-c - 1)))) { + break + } + v.reset(OpS390XSUB) + v0 := b.NewValue0(v.Pos, OpS390XSLDconst, t) + v0.AuxInt = uint8ToAuxInt(uint8(log32(-c &^ (-c - 1)))) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XSLDconst, t) + v1.AuxInt = uint8ToAuxInt(uint8(log32(-c + (-c &^ (-c - 1))))) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } + // match: (MULLDconst [c] (MOVDconst [d])) + // result: (MOVDconst [int64(c)*d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(c) * d) + return true + } + return false +} +func rewriteValueS390X_OpS390XMULLDload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (MULLDload [off] {sym} x ptr1 (FMOVDstore [off] {sym} ptr2 y _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (MULLD x (LGDR y)) + for { + t := v.Type + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr1 := v_1 + if v_2.Op != OpS390XFMOVDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + ptr2 := v_2.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XMULLD) + v0 := b.NewValue0(v_2.Pos, OpS390XLGDR, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (MULLDload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (MULLDload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XMULLDload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (MULLDload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (MULLDload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XMULLDload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XMULLW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULLW x (MOVDconst [c])) + // result: (MULLWconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XMULLWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (MULLW x g:(MOVWload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (MULLWload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XMULLWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (MULLW x g:(MOVWZload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (MULLWload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWZload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XMULLWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XMULLWconst(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (MULLWconst x [c]) + // cond: isPowerOfTwo(c&(c-1)) + // result: (ADDW (SLWconst x [uint8(log32(c&(c-1)))]) (SLWconst x [uint8(log32(c&^(c-1)))])) + for { + t := v.Type + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(c & (c - 1))) { + break + } + v.reset(OpS390XADDW) + v0 := b.NewValue0(v.Pos, OpS390XSLWconst, t) + v0.AuxInt = uint8ToAuxInt(uint8(log32(c & (c - 1)))) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XSLWconst, t) + v1.AuxInt = uint8ToAuxInt(uint8(log32(c &^ (c - 1)))) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } + // match: (MULLWconst x [c]) + // cond: isPowerOfTwo(c+(c&^(c-1))) + // result: (SUBW (SLWconst x [uint8(log32(c+(c&^(c-1))))]) (SLWconst x [uint8(log32(c&^(c-1)))])) + for { + t := v.Type + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(c + (c &^ (c - 1)))) { + break + } + v.reset(OpS390XSUBW) + v0 := b.NewValue0(v.Pos, OpS390XSLWconst, t) + v0.AuxInt = uint8ToAuxInt(uint8(log32(c + (c &^ (c - 1))))) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XSLWconst, t) + v1.AuxInt = uint8ToAuxInt(uint8(log32(c &^ (c - 1)))) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } + // match: (MULLWconst x [c]) + // cond: isPowerOfTwo(-c+(-c&^(-c-1))) + // result: (SUBW (SLWconst x [uint8(log32(-c&^(-c-1)))]) (SLWconst x [uint8(log32(-c+(-c&^(-c-1))))])) + for { + t := v.Type + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(isPowerOfTwo(-c + (-c &^ (-c - 1)))) { + break + } + v.reset(OpS390XSUBW) + v0 := b.NewValue0(v.Pos, OpS390XSLWconst, t) + v0.AuxInt = uint8ToAuxInt(uint8(log32(-c &^ (-c - 1)))) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpS390XSLWconst, t) + v1.AuxInt = uint8ToAuxInt(uint8(log32(-c + (-c &^ (-c - 1))))) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } + // match: (MULLWconst [c] (MOVDconst [d])) + // result: (MOVDconst [int64(c*int32(d))]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(c * int32(d))) + return true + } + return false +} +func rewriteValueS390X_OpS390XMULLWload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (MULLWload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (MULLWload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XMULLWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (MULLWload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (MULLWload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XMULLWload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XNEG(v *Value) bool { + v_0 := v.Args[0] + // match: (NEG (MOVDconst [c])) + // result: (MOVDconst [-c]) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(-c) + return true + } + // match: (NEG (NEG x)) + // result: x + for { + if v_0.Op != OpS390XNEG { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (NEG (ADDconst [c] (NEG x))) + // cond: c != -(1<<31) + // result: (ADDconst [-c] x) + for { + if v_0.Op != OpS390XADDconst { + break + } + c := auxIntToInt32(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XNEG { + break + } + x := v_0_0.Args[0] + if !(c != -(1 << 31)) { + break + } + v.reset(OpS390XADDconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XNEGW(v *Value) bool { + v_0 := v.Args[0] + // match: (NEGW (MOVDconst [c])) + // result: (MOVDconst [int64(int32(-c))]) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(int32(-c))) + return true + } + return false +} +func rewriteValueS390X_OpS390XNOT(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NOT x) + // result: (XOR (MOVDconst [-1]) x) + for { + x := v_0 + v.reset(OpS390XXOR) + v0 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v0.AuxInt = int64ToAuxInt(-1) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueS390X_OpS390XNOTW(v *Value) bool { + v_0 := v.Args[0] + // match: (NOTW x) + // result: (XORWconst [-1] x) + for { + x := v_0 + v.reset(OpS390XXORWconst) + v.AuxInt = int32ToAuxInt(-1) + v.AddArg(x) + return true + } +} +func rewriteValueS390X_OpS390XOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (OR x (MOVDconst [c])) + // cond: isU32Bit(c) + // result: (ORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isU32Bit(c)) { + continue + } + v.reset(OpS390XORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (OR (MOVDconst [-1<<63]) (LGDR x)) + // result: (LGDR (LNDFR x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0.AuxInt) != -1<<63 || v_1.Op != OpS390XLGDR { + continue + } + t := v_1.Type + x := v_1.Args[0] + v.reset(OpS390XLGDR) + v.Type = t + v0 := b.NewValue0(v.Pos, OpS390XLNDFR, x.Type) + v0.AddArg(x) + v.AddArg(v0) + return true + } + break + } + // match: (OR (RISBGZ (LGDR x) {r}) (LGDR (LPDFR y))) + // cond: r == s390x.NewRotateParams(0, 0, 0) + // result: (LGDR (CPSDR y x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpS390XRISBGZ { + continue + } + r := auxToS390xRotateParams(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XLGDR { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpS390XLGDR { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpS390XLPDFR { + continue + } + t := v_1_0.Type + y := v_1_0.Args[0] + if !(r == s390x.NewRotateParams(0, 0, 0)) { + continue + } + v.reset(OpS390XLGDR) + v0 := b.NewValue0(v.Pos, OpS390XCPSDR, t) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + break + } + // match: (OR (RISBGZ (LGDR x) {r}) (MOVDconst [c])) + // cond: c >= 0 && r == s390x.NewRotateParams(0, 0, 0) + // result: (LGDR (CPSDR (FMOVDconst [math.Float64frombits(uint64(c))]) x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpS390XRISBGZ { + continue + } + r := auxToS390xRotateParams(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XLGDR { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(c >= 0 && r == s390x.NewRotateParams(0, 0, 0)) { + continue + } + v.reset(OpS390XLGDR) + v0 := b.NewValue0(v.Pos, OpS390XCPSDR, x.Type) + v1 := b.NewValue0(v.Pos, OpS390XFMOVDconst, x.Type) + v1.AuxInt = float64ToAuxInt(math.Float64frombits(uint64(c))) + v0.AddArg2(v1, x) + v.AddArg(v0) + return true + } + break + } + // match: (OR (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [c|d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpS390XMOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(c | d) + return true + } + break + } + // match: (OR x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (OR x g:(MOVDload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (ORload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVDload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XORload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XORW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORW x (MOVDconst [c])) + // result: (ORWconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XORWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (ORW x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (ORW x g:(MOVWload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (ORWload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XORWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (ORW x g:(MOVWZload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (ORWload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWZload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XORWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XORWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORWconst [c] x) + // cond: int32(c)==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(int32(c) == 0) { + break + } + v.copyOf(x) + return true + } + // match: (ORWconst [c] _) + // cond: int32(c)==-1 + // result: (MOVDconst [-1]) + for { + c := auxIntToInt32(v.AuxInt) + if !(int32(c) == -1) { + break + } + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (ORWconst [c] (MOVDconst [d])) + // result: (MOVDconst [int64(c)|d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(c) | d) + return true + } + return false +} +func rewriteValueS390X_OpS390XORWload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (ORWload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (ORWload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XORWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (ORWload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (ORWload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XORWload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (ORconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (ORconst [-1] _) + // result: (MOVDconst [-1]) + for { + if auxIntToInt64(v.AuxInt) != -1 { + break + } + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (ORconst [c] (MOVDconst [d])) + // result: (MOVDconst [c|d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(c | d) + return true + } + return false +} +func rewriteValueS390X_OpS390XORload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (ORload [off] {sym} x ptr1 (FMOVDstore [off] {sym} ptr2 y _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (OR x (LGDR y)) + for { + t := v.Type + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr1 := v_1 + if v_2.Op != OpS390XFMOVDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + ptr2 := v_2.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XOR) + v0 := b.NewValue0(v_2.Pos, OpS390XLGDR, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (ORload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (ORload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XORload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (ORload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (ORload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XORload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XRISBGZ(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (RISBGZ (MOVWZreg x) {r}) + // cond: r.InMerge(0xffffffff) != nil + // result: (RISBGZ x {*r.InMerge(0xffffffff)}) + for { + r := auxToS390xRotateParams(v.Aux) + if v_0.Op != OpS390XMOVWZreg { + break + } + x := v_0.Args[0] + if !(r.InMerge(0xffffffff) != nil) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(*r.InMerge(0xffffffff)) + v.AddArg(x) + return true + } + // match: (RISBGZ (MOVHZreg x) {r}) + // cond: r.InMerge(0x0000ffff) != nil + // result: (RISBGZ x {*r.InMerge(0x0000ffff)}) + for { + r := auxToS390xRotateParams(v.Aux) + if v_0.Op != OpS390XMOVHZreg { + break + } + x := v_0.Args[0] + if !(r.InMerge(0x0000ffff) != nil) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(*r.InMerge(0x0000ffff)) + v.AddArg(x) + return true + } + // match: (RISBGZ (MOVBZreg x) {r}) + // cond: r.InMerge(0x000000ff) != nil + // result: (RISBGZ x {*r.InMerge(0x000000ff)}) + for { + r := auxToS390xRotateParams(v.Aux) + if v_0.Op != OpS390XMOVBZreg { + break + } + x := v_0.Args[0] + if !(r.InMerge(0x000000ff) != nil) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(*r.InMerge(0x000000ff)) + v.AddArg(x) + return true + } + // match: (RISBGZ (SLDconst x [c]) {r}) + // cond: r.InMerge(^uint64(0)<>c) != nil + // result: (RISBGZ x {(*r.InMerge(^uint64(0)>>c)).RotateLeft(-c)}) + for { + r := auxToS390xRotateParams(v.Aux) + if v_0.Op != OpS390XSRDconst { + break + } + c := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + if !(r.InMerge(^uint64(0)>>c) != nil) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux((*r.InMerge(^uint64(0) >> c)).RotateLeft(-c)) + v.AddArg(x) + return true + } + // match: (RISBGZ (RISBGZ x {y}) {z}) + // cond: z.InMerge(y.OutMask()) != nil + // result: (RISBGZ x {(*z.InMerge(y.OutMask())).RotateLeft(y.Amount)}) + for { + z := auxToS390xRotateParams(v.Aux) + if v_0.Op != OpS390XRISBGZ { + break + } + y := auxToS390xRotateParams(v_0.Aux) + x := v_0.Args[0] + if !(z.InMerge(y.OutMask()) != nil) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux((*z.InMerge(y.OutMask())).RotateLeft(y.Amount)) + v.AddArg(x) + return true + } + // match: (RISBGZ x {r}) + // cond: r.End == 63 && r.Start == -r.Amount&63 + // result: (SRDconst x [-r.Amount&63]) + for { + r := auxToS390xRotateParams(v.Aux) + x := v_0 + if !(r.End == 63 && r.Start == -r.Amount&63) { + break + } + v.reset(OpS390XSRDconst) + v.AuxInt = uint8ToAuxInt(-r.Amount & 63) + v.AddArg(x) + return true + } + // match: (RISBGZ x {r}) + // cond: r.Start == 0 && r.End == 63-r.Amount + // result: (SLDconst x [r.Amount]) + for { + r := auxToS390xRotateParams(v.Aux) + x := v_0 + if !(r.Start == 0 && r.End == 63-r.Amount) { + break + } + v.reset(OpS390XSLDconst) + v.AuxInt = uint8ToAuxInt(r.Amount) + v.AddArg(x) + return true + } + // match: (RISBGZ (SRADconst x [c]) {r}) + // cond: r.Start == r.End && (r.Start+r.Amount)&63 <= c + // result: (RISBGZ x {s390x.NewRotateParams(r.Start, r.Start, -r.Start&63)}) + for { + r := auxToS390xRotateParams(v.Aux) + if v_0.Op != OpS390XSRADconst { + break + } + c := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + if !(r.Start == r.End && (r.Start+r.Amount)&63 <= c) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(r.Start, r.Start, -r.Start&63)) + v.AddArg(x) + return true + } + // match: (RISBGZ x {r}) + // cond: r == s390x.NewRotateParams(56, 63, 0) + // result: (MOVBZreg x) + for { + r := auxToS390xRotateParams(v.Aux) + x := v_0 + if !(r == s390x.NewRotateParams(56, 63, 0)) { + break + } + v.reset(OpS390XMOVBZreg) + v.AddArg(x) + return true + } + // match: (RISBGZ x {r}) + // cond: r == s390x.NewRotateParams(48, 63, 0) + // result: (MOVHZreg x) + for { + r := auxToS390xRotateParams(v.Aux) + x := v_0 + if !(r == s390x.NewRotateParams(48, 63, 0)) { + break + } + v.reset(OpS390XMOVHZreg) + v.AddArg(x) + return true + } + // match: (RISBGZ x {r}) + // cond: r == s390x.NewRotateParams(32, 63, 0) + // result: (MOVWZreg x) + for { + r := auxToS390xRotateParams(v.Aux) + x := v_0 + if !(r == s390x.NewRotateParams(32, 63, 0)) { + break + } + v.reset(OpS390XMOVWZreg) + v.AddArg(x) + return true + } + // match: (RISBGZ (LGDR x) {r}) + // cond: r == s390x.NewRotateParams(1, 63, 0) + // result: (LGDR (LPDFR x)) + for { + r := auxToS390xRotateParams(v.Aux) + if v_0.Op != OpS390XLGDR { + break + } + t := v_0.Type + x := v_0.Args[0] + if !(r == s390x.NewRotateParams(1, 63, 0)) { + break + } + v.reset(OpS390XLGDR) + v.Type = t + v0 := b.NewValue0(v.Pos, OpS390XLPDFR, x.Type) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueS390X_OpS390XRLL(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RLL x (MOVDconst [c])) + // result: (RLLconst x [uint8(c&31)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XRLLconst) + v.AuxInt = uint8ToAuxInt(uint8(c & 31)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XRLLG(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RLLG x (MOVDconst [c])) + // result: (RISBGZ x {s390x.NewRotateParams(0, 63, uint8(c&63))}) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(0, 63, uint8(c&63))) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XSLD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SLD x (MOVDconst [c])) + // result: (SLDconst x [uint8(c&63)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XSLDconst) + v.AuxInt = uint8ToAuxInt(uint8(c & 63)) + v.AddArg(x) + return true + } + // match: (SLD x (RISBGZ y {r})) + // cond: r.Amount == 0 && r.OutMask()&63 == 63 + // result: (SLD x y) + for { + x := v_0 + if v_1.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_1.Aux) + y := v_1.Args[0] + if !(r.Amount == 0 && r.OutMask()&63 == 63) { + break + } + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (SLD x (AND (MOVDconst [c]) y)) + // result: (SLD x (ANDWconst [int32(c&63)] y)) + for { + x := v_0 + if v_1.Op != OpS390XAND { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1_0.AuxInt) + y := v_1_1 + v.reset(OpS390XSLD) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(c & 63)) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (SLD x (ANDWconst [c] y)) + // cond: c&63 == 63 + // result: (SLD x y) + for { + x := v_0 + if v_1.Op != OpS390XANDWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (SLD x (MOVWreg y)) + // result: (SLD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (SLD x (MOVHreg y)) + // result: (SLD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (SLD x (MOVBreg y)) + // result: (SLD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (SLD x (MOVWZreg y)) + // result: (SLD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (SLD x (MOVHZreg y)) + // result: (SLD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + // match: (SLD x (MOVBZreg y)) + // result: (SLD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLD) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueS390X_OpS390XSLDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLDconst (SRDconst x [c]) [d]) + // result: (RISBGZ x {s390x.NewRotateParams(uint8(max(0, int8(c-d))), 63-d, uint8(int8(d-c)&63))}) + for { + d := auxIntToUint8(v.AuxInt) + if v_0.Op != OpS390XSRDconst { + break + } + c := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(uint8(max(0, int8(c-d))), 63-d, uint8(int8(d-c)&63))) + v.AddArg(x) + return true + } + // match: (SLDconst (RISBGZ x {r}) [c]) + // cond: s390x.NewRotateParams(0, 63-c, c).InMerge(r.OutMask()) != nil + // result: (RISBGZ x {(*s390x.NewRotateParams(0, 63-c, c).InMerge(r.OutMask())).RotateLeft(r.Amount)}) + for { + c := auxIntToUint8(v.AuxInt) + if v_0.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_0.Aux) + x := v_0.Args[0] + if !(s390x.NewRotateParams(0, 63-c, c).InMerge(r.OutMask()) != nil) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux((*s390x.NewRotateParams(0, 63-c, c).InMerge(r.OutMask())).RotateLeft(r.Amount)) + v.AddArg(x) + return true + } + // match: (SLDconst x [0]) + // result: x + for { + if auxIntToUint8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XSLW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SLW x (MOVDconst [c])) + // cond: c&32 == 0 + // result: (SLWconst x [uint8(c&31)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&32 == 0) { + break + } + v.reset(OpS390XSLWconst) + v.AuxInt = uint8ToAuxInt(uint8(c & 31)) + v.AddArg(x) + return true + } + // match: (SLW _ (MOVDconst [c])) + // cond: c&32 != 0 + // result: (MOVDconst [0]) + for { + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&32 != 0) { + break + } + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SLW x (RISBGZ y {r})) + // cond: r.Amount == 0 && r.OutMask()&63 == 63 + // result: (SLW x y) + for { + x := v_0 + if v_1.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_1.Aux) + y := v_1.Args[0] + if !(r.Amount == 0 && r.OutMask()&63 == 63) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (SLW x (AND (MOVDconst [c]) y)) + // result: (SLW x (ANDWconst [int32(c&63)] y)) + for { + x := v_0 + if v_1.Op != OpS390XAND { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1_0.AuxInt) + y := v_1_1 + v.reset(OpS390XSLW) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(c & 63)) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (SLW x (ANDWconst [c] y)) + // cond: c&63 == 63 + // result: (SLW x y) + for { + x := v_0 + if v_1.Op != OpS390XANDWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (SLW x (MOVWreg y)) + // result: (SLW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (SLW x (MOVHreg y)) + // result: (SLW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (SLW x (MOVBreg y)) + // result: (SLW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (SLW x (MOVWZreg y)) + // result: (SLW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (SLW x (MOVHZreg y)) + // result: (SLW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + // match: (SLW x (MOVBZreg y)) + // result: (SLW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSLW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueS390X_OpS390XSLWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SLWconst x [0]) + // result: x + for { + if auxIntToUint8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XSRAD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SRAD x (MOVDconst [c])) + // result: (SRADconst x [uint8(c&63)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XSRADconst) + v.AuxInt = uint8ToAuxInt(uint8(c & 63)) + v.AddArg(x) + return true + } + // match: (SRAD x (RISBGZ y {r})) + // cond: r.Amount == 0 && r.OutMask()&63 == 63 + // result: (SRAD x y) + for { + x := v_0 + if v_1.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_1.Aux) + y := v_1.Args[0] + if !(r.Amount == 0 && r.OutMask()&63 == 63) { + break + } + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (SRAD x (AND (MOVDconst [c]) y)) + // result: (SRAD x (ANDWconst [int32(c&63)] y)) + for { + x := v_0 + if v_1.Op != OpS390XAND { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1_0.AuxInt) + y := v_1_1 + v.reset(OpS390XSRAD) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(c & 63)) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (SRAD x (ANDWconst [c] y)) + // cond: c&63 == 63 + // result: (SRAD x y) + for { + x := v_0 + if v_1.Op != OpS390XANDWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (SRAD x (MOVWreg y)) + // result: (SRAD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (SRAD x (MOVHreg y)) + // result: (SRAD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (SRAD x (MOVBreg y)) + // result: (SRAD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (SRAD x (MOVWZreg y)) + // result: (SRAD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (SRAD x (MOVHZreg y)) + // result: (SRAD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + // match: (SRAD x (MOVBZreg y)) + // result: (SRAD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAD) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueS390X_OpS390XSRADconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRADconst x [0]) + // result: x + for { + if auxIntToUint8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SRADconst [c] (MOVDconst [d])) + // result: (MOVDconst [d>>uint64(c)]) + for { + c := auxIntToUint8(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(d >> uint64(c)) + return true + } + return false +} +func rewriteValueS390X_OpS390XSRAW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SRAW x (MOVDconst [c])) + // cond: c&32 == 0 + // result: (SRAWconst x [uint8(c&31)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&32 == 0) { + break + } + v.reset(OpS390XSRAWconst) + v.AuxInt = uint8ToAuxInt(uint8(c & 31)) + v.AddArg(x) + return true + } + // match: (SRAW x (MOVDconst [c])) + // cond: c&32 != 0 + // result: (SRAWconst x [31]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&32 != 0) { + break + } + v.reset(OpS390XSRAWconst) + v.AuxInt = uint8ToAuxInt(31) + v.AddArg(x) + return true + } + // match: (SRAW x (RISBGZ y {r})) + // cond: r.Amount == 0 && r.OutMask()&63 == 63 + // result: (SRAW x y) + for { + x := v_0 + if v_1.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_1.Aux) + y := v_1.Args[0] + if !(r.Amount == 0 && r.OutMask()&63 == 63) { + break + } + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (SRAW x (AND (MOVDconst [c]) y)) + // result: (SRAW x (ANDWconst [int32(c&63)] y)) + for { + x := v_0 + if v_1.Op != OpS390XAND { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1_0.AuxInt) + y := v_1_1 + v.reset(OpS390XSRAW) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(c & 63)) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (SRAW x (ANDWconst [c] y)) + // cond: c&63 == 63 + // result: (SRAW x y) + for { + x := v_0 + if v_1.Op != OpS390XANDWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (SRAW x (MOVWreg y)) + // result: (SRAW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (SRAW x (MOVHreg y)) + // result: (SRAW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (SRAW x (MOVBreg y)) + // result: (SRAW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (SRAW x (MOVWZreg y)) + // result: (SRAW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (SRAW x (MOVHZreg y)) + // result: (SRAW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + // match: (SRAW x (MOVBZreg y)) + // result: (SRAW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRAW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueS390X_OpS390XSRAWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRAWconst x [0]) + // result: x + for { + if auxIntToUint8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SRAWconst [c] (MOVDconst [d])) + // result: (MOVDconst [int64(int32(d))>>uint64(c)]) + for { + c := auxIntToUint8(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(int32(d)) >> uint64(c)) + return true + } + return false +} +func rewriteValueS390X_OpS390XSRD(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SRD x (MOVDconst [c])) + // result: (SRDconst x [uint8(c&63)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XSRDconst) + v.AuxInt = uint8ToAuxInt(uint8(c & 63)) + v.AddArg(x) + return true + } + // match: (SRD x (RISBGZ y {r})) + // cond: r.Amount == 0 && r.OutMask()&63 == 63 + // result: (SRD x y) + for { + x := v_0 + if v_1.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_1.Aux) + y := v_1.Args[0] + if !(r.Amount == 0 && r.OutMask()&63 == 63) { + break + } + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (SRD x (AND (MOVDconst [c]) y)) + // result: (SRD x (ANDWconst [int32(c&63)] y)) + for { + x := v_0 + if v_1.Op != OpS390XAND { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1_0.AuxInt) + y := v_1_1 + v.reset(OpS390XSRD) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(c & 63)) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (SRD x (ANDWconst [c] y)) + // cond: c&63 == 63 + // result: (SRD x y) + for { + x := v_0 + if v_1.Op != OpS390XANDWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (SRD x (MOVWreg y)) + // result: (SRD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (SRD x (MOVHreg y)) + // result: (SRD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (SRD x (MOVBreg y)) + // result: (SRD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (SRD x (MOVWZreg y)) + // result: (SRD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (SRD x (MOVHZreg y)) + // result: (SRD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + // match: (SRD x (MOVBZreg y)) + // result: (SRD x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRD) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueS390X_OpS390XSRDconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRDconst (SLDconst x [c]) [d]) + // result: (RISBGZ x {s390x.NewRotateParams(d, uint8(min(63, int8(63-c+d))), uint8(int8(c-d)&63))}) + for { + d := auxIntToUint8(v.AuxInt) + if v_0.Op != OpS390XSLDconst { + break + } + c := auxIntToUint8(v_0.AuxInt) + x := v_0.Args[0] + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(d, uint8(min(63, int8(63-c+d))), uint8(int8(c-d)&63))) + v.AddArg(x) + return true + } + // match: (SRDconst (RISBGZ x {r}) [c]) + // cond: s390x.NewRotateParams(c, 63, -c&63).InMerge(r.OutMask()) != nil + // result: (RISBGZ x {(*s390x.NewRotateParams(c, 63, -c&63).InMerge(r.OutMask())).RotateLeft(r.Amount)}) + for { + c := auxIntToUint8(v.AuxInt) + if v_0.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_0.Aux) + x := v_0.Args[0] + if !(s390x.NewRotateParams(c, 63, -c&63).InMerge(r.OutMask()) != nil) { + break + } + v.reset(OpS390XRISBGZ) + v.Aux = s390xRotateParamsToAux((*s390x.NewRotateParams(c, 63, -c&63).InMerge(r.OutMask())).RotateLeft(r.Amount)) + v.AddArg(x) + return true + } + // match: (SRDconst x [0]) + // result: x + for { + if auxIntToUint8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XSRW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SRW x (MOVDconst [c])) + // cond: c&32 == 0 + // result: (SRWconst x [uint8(c&31)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&32 == 0) { + break + } + v.reset(OpS390XSRWconst) + v.AuxInt = uint8ToAuxInt(uint8(c & 31)) + v.AddArg(x) + return true + } + // match: (SRW _ (MOVDconst [c])) + // cond: c&32 != 0 + // result: (MOVDconst [0]) + for { + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&32 != 0) { + break + } + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SRW x (RISBGZ y {r})) + // cond: r.Amount == 0 && r.OutMask()&63 == 63 + // result: (SRW x y) + for { + x := v_0 + if v_1.Op != OpS390XRISBGZ { + break + } + r := auxToS390xRotateParams(v_1.Aux) + y := v_1.Args[0] + if !(r.Amount == 0 && r.OutMask()&63 == 63) { + break + } + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (SRW x (AND (MOVDconst [c]) y)) + // result: (SRW x (ANDWconst [int32(c&63)] y)) + for { + x := v_0 + if v_1.Op != OpS390XAND { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1_0.AuxInt) + y := v_1_1 + v.reset(OpS390XSRW) + v0 := b.NewValue0(v.Pos, OpS390XANDWconst, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(c & 63)) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (SRW x (ANDWconst [c] y)) + // cond: c&63 == 63 + // result: (SRW x y) + for { + x := v_0 + if v_1.Op != OpS390XANDWconst { + break + } + c := auxIntToInt32(v_1.AuxInt) + y := v_1.Args[0] + if !(c&63 == 63) { + break + } + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (SRW x (MOVWreg y)) + // result: (SRW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (SRW x (MOVHreg y)) + // result: (SRW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (SRW x (MOVBreg y)) + // result: (SRW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (SRW x (MOVWZreg y)) + // result: (SRW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVWZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (SRW x (MOVHZreg y)) + // result: (SRW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVHZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + // match: (SRW x (MOVBZreg y)) + // result: (SRW x y) + for { + x := v_0 + if v_1.Op != OpS390XMOVBZreg { + break + } + y := v_1.Args[0] + v.reset(OpS390XSRW) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueS390X_OpS390XSRWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SRWconst x [0]) + // result: x + for { + if auxIntToUint8(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XSTM2(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (STM2 [i] {s} p w2 w3 x:(STM2 [i-8] {s} p w0 w1 mem)) + // cond: x.Uses == 1 && is20Bit(int64(i)-8) && setPos(v, x.Pos) && clobber(x) + // result: (STM4 [i-8] {s} p w0 w1 w2 w3 mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + w2 := v_1 + w3 := v_2 + x := v_3 + if x.Op != OpS390XSTM2 || auxIntToInt32(x.AuxInt) != i-8 || auxToSym(x.Aux) != s { + break + } + mem := x.Args[3] + if p != x.Args[0] { + break + } + w0 := x.Args[1] + w1 := x.Args[2] + if !(x.Uses == 1 && is20Bit(int64(i)-8) && setPos(v, x.Pos) && clobber(x)) { + break + } + v.reset(OpS390XSTM4) + v.AuxInt = int32ToAuxInt(i - 8) + v.Aux = symToAux(s) + v.AddArg6(p, w0, w1, w2, w3, mem) + return true + } + // match: (STM2 [i] {s} p (SRDconst [32] x) x mem) + // result: (MOVDstore [i] {s} p x mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + if v_1.Op != OpS390XSRDconst || auxIntToUint8(v_1.AuxInt) != 32 { + break + } + x := v_1.Args[0] + if x != v_2 { + break + } + mem := v_3 + v.reset(OpS390XMOVDstore) + v.AuxInt = int32ToAuxInt(i) + v.Aux = symToAux(s) + v.AddArg3(p, x, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XSTMG2(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (STMG2 [i] {s} p w2 w3 x:(STMG2 [i-16] {s} p w0 w1 mem)) + // cond: x.Uses == 1 && is20Bit(int64(i)-16) && setPos(v, x.Pos) && clobber(x) + // result: (STMG4 [i-16] {s} p w0 w1 w2 w3 mem) + for { + i := auxIntToInt32(v.AuxInt) + s := auxToSym(v.Aux) + p := v_0 + w2 := v_1 + w3 := v_2 + x := v_3 + if x.Op != OpS390XSTMG2 || auxIntToInt32(x.AuxInt) != i-16 || auxToSym(x.Aux) != s { + break + } + mem := x.Args[3] + if p != x.Args[0] { + break + } + w0 := x.Args[1] + w1 := x.Args[2] + if !(x.Uses == 1 && is20Bit(int64(i)-16) && setPos(v, x.Pos) && clobber(x)) { + break + } + v.reset(OpS390XSTMG4) + v.AuxInt = int32ToAuxInt(i - 16) + v.Aux = symToAux(s) + v.AddArg6(p, w0, w1, w2, w3, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XSUB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUB x (MOVDconst [c])) + // cond: is32Bit(c) + // result: (SUBconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(is32Bit(c)) { + break + } + v.reset(OpS390XSUBconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (SUB (MOVDconst [c]) x) + // cond: is32Bit(c) + // result: (NEG (SUBconst x [int32(c)])) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + if !(is32Bit(c)) { + break + } + v.reset(OpS390XNEG) + v0 := b.NewValue0(v.Pos, OpS390XSUBconst, v.Type) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUB x (NEG y)) + // result: (ADD x y) + for { + x := v_0 + if v_1.Op != OpS390XNEG { + break + } + y := v_1.Args[0] + v.reset(OpS390XADD) + v.AddArg2(x, y) + return true + } + // match: (SUB x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SUB x g:(MOVDload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (SUBload [off] {sym} x ptr mem) + for { + t := v.Type + x := v_0 + g := v_1 + if g.Op != OpS390XMOVDload { + break + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + break + } + v.reset(OpS390XSUBload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XSUBE(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBE x y (FlagGT)) + // result: (SUBC x y) + for { + x := v_0 + y := v_1 + if v_2.Op != OpS390XFlagGT { + break + } + v.reset(OpS390XSUBC) + v.AddArg2(x, y) + return true + } + // match: (SUBE x y (FlagOV)) + // result: (SUBC x y) + for { + x := v_0 + y := v_1 + if v_2.Op != OpS390XFlagOV { + break + } + v.reset(OpS390XSUBC) + v.AddArg2(x, y) + return true + } + // match: (SUBE x y (Select1 (SUBC (MOVDconst [0]) (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) c)))))) + // result: (SUBE x y c) + for { + x := v_0 + y := v_1 + if v_2.Op != OpSelect1 { + break + } + v_2_0 := v_2.Args[0] + if v_2_0.Op != OpS390XSUBC { + break + } + _ = v_2_0.Args[1] + v_2_0_0 := v_2_0.Args[0] + if v_2_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_2_0_0.AuxInt) != 0 { + break + } + v_2_0_1 := v_2_0.Args[1] + if v_2_0_1.Op != OpS390XNEG { + break + } + v_2_0_1_0 := v_2_0_1.Args[0] + if v_2_0_1_0.Op != OpSelect0 { + break + } + v_2_0_1_0_0 := v_2_0_1_0.Args[0] + if v_2_0_1_0_0.Op != OpS390XSUBE { + break + } + c := v_2_0_1_0_0.Args[2] + v_2_0_1_0_0_0 := v_2_0_1_0_0.Args[0] + if v_2_0_1_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_2_0_1_0_0_0.AuxInt) != 0 { + break + } + v_2_0_1_0_0_1 := v_2_0_1_0_0.Args[1] + if v_2_0_1_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_2_0_1_0_0_1.AuxInt) != 0 { + break + } + v.reset(OpS390XSUBE) + v.AddArg3(x, y, c) + return true + } + return false +} +func rewriteValueS390X_OpS390XSUBW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBW x (MOVDconst [c])) + // result: (SUBWconst x [int32(c)]) + for { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XSUBWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + // match: (SUBW (MOVDconst [c]) x) + // result: (NEGW (SUBWconst x [int32(c)])) + for { + if v_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0.AuxInt) + x := v_1 + v.reset(OpS390XNEGW) + v0 := b.NewValue0(v.Pos, OpS390XSUBWconst, v.Type) + v0.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (SUBW x (NEGW y)) + // result: (ADDW x y) + for { + x := v_0 + if v_1.Op != OpS390XNEGW { + break + } + y := v_1.Args[0] + v.reset(OpS390XADDW) + v.AddArg2(x, y) + return true + } + // match: (SUBW x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (SUBW x g:(MOVWload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (SUBWload [off] {sym} x ptr mem) + for { + t := v.Type + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWload { + break + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + break + } + v.reset(OpS390XSUBWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (SUBW x g:(MOVWZload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (SUBWload [off] {sym} x ptr mem) + for { + t := v.Type + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWZload { + break + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + break + } + v.reset(OpS390XSUBWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XSUBWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBWconst [c] x) + // cond: int32(c) == 0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(int32(c) == 0) { + break + } + v.copyOf(x) + return true + } + // match: (SUBWconst [c] x) + // result: (ADDWconst [-int32(c)] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + v.reset(OpS390XADDWconst) + v.AuxInt = int32ToAuxInt(-int32(c)) + v.AddArg(x) + return true + } +} +func rewriteValueS390X_OpS390XSUBWload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (SUBWload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (SUBWload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XSUBWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (SUBWload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (SUBWload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XSUBWload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XSUBconst(v *Value) bool { + v_0 := v.Args[0] + // match: (SUBconst [0] x) + // result: x + for { + if auxIntToInt32(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (SUBconst [c] x) + // cond: c != -(1<<31) + // result: (ADDconst [-c] x) + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(c != -(1 << 31)) { + break + } + v.reset(OpS390XADDconst) + v.AuxInt = int32ToAuxInt(-c) + v.AddArg(x) + return true + } + // match: (SUBconst (MOVDconst [d]) [c]) + // result: (MOVDconst [d-int64(c)]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(d - int64(c)) + return true + } + // match: (SUBconst (SUBconst x [d]) [c]) + // cond: is32Bit(-int64(c)-int64(d)) + // result: (ADDconst [-c-d] x) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XSUBconst { + break + } + d := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + if !(is32Bit(-int64(c) - int64(d))) { + break + } + v.reset(OpS390XADDconst) + v.AuxInt = int32ToAuxInt(-c - d) + v.AddArg(x) + return true + } + return false +} +func rewriteValueS390X_OpS390XSUBload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SUBload [off] {sym} x ptr1 (FMOVDstore [off] {sym} ptr2 y _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (SUB x (LGDR y)) + for { + t := v.Type + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr1 := v_1 + if v_2.Op != OpS390XFMOVDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + ptr2 := v_2.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XSUB) + v0 := b.NewValue0(v_2.Pos, OpS390XLGDR, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (SUBload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (SUBload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XSUBload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (SUBload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (SUBload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XSUBload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XSumBytes2(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SumBytes2 x) + // result: (ADDW (SRWconst x [8]) x) + for { + x := v_0 + v.reset(OpS390XADDW) + v0 := b.NewValue0(v.Pos, OpS390XSRWconst, typ.UInt8) + v0.AuxInt = uint8ToAuxInt(8) + v0.AddArg(x) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueS390X_OpS390XSumBytes4(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SumBytes4 x) + // result: (SumBytes2 (ADDW (SRWconst x [16]) x)) + for { + x := v_0 + v.reset(OpS390XSumBytes2) + v0 := b.NewValue0(v.Pos, OpS390XADDW, typ.UInt16) + v1 := b.NewValue0(v.Pos, OpS390XSRWconst, typ.UInt16) + v1.AuxInt = uint8ToAuxInt(16) + v1.AddArg(x) + v0.AddArg2(v1, x) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpS390XSumBytes8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SumBytes8 x) + // result: (SumBytes4 (ADDW (SRDconst x [32]) x)) + for { + x := v_0 + v.reset(OpS390XSumBytes4) + v0 := b.NewValue0(v.Pos, OpS390XADDW, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpS390XSRDconst, typ.UInt32) + v1.AuxInt = uint8ToAuxInt(32) + v1.AddArg(x) + v0.AddArg2(v1, x) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpS390XXOR(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XOR x (MOVDconst [c])) + // cond: isU32Bit(c) + // result: (XORconst [c] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isU32Bit(c)) { + continue + } + v.reset(OpS390XXORconst) + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + break + } + // match: (XOR (MOVDconst [c]) (MOVDconst [d])) + // result: (MOVDconst [c^d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpS390XMOVDconst { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(c ^ d) + return true + } + break + } + // match: (XOR x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (XOR x g:(MOVDload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (XORload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVDload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XXORload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XXORW(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XORW x (MOVDconst [c])) + // result: (XORWconst [int32(c)] x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpS390XMOVDconst { + continue + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpS390XXORWconst) + v.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg(x) + return true + } + break + } + // match: (XORW x x) + // result: (MOVDconst [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (XORW x g:(MOVWload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (XORWload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XXORWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + // match: (XORW x g:(MOVWZload [off] {sym} ptr mem)) + // cond: ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g) + // result: (XORWload [off] {sym} x ptr mem) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + g := v_1 + if g.Op != OpS390XMOVWZload { + continue + } + off := auxIntToInt32(g.AuxInt) + sym := auxToSym(g.Aux) + mem := g.Args[1] + ptr := g.Args[0] + if !(ptr.Op != OpSB && is20Bit(int64(off)) && canMergeLoadClobber(v, g, x) && clobber(g)) { + continue + } + v.reset(OpS390XXORWload) + v.Type = t + v.AuxInt = int32ToAuxInt(off) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + break + } + return false +} +func rewriteValueS390X_OpS390XXORWconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORWconst [c] x) + // cond: int32(c)==0 + // result: x + for { + c := auxIntToInt32(v.AuxInt) + x := v_0 + if !(int32(c) == 0) { + break + } + v.copyOf(x) + return true + } + // match: (XORWconst [c] (MOVDconst [d])) + // result: (MOVDconst [int64(c)^d]) + for { + c := auxIntToInt32(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(int64(c) ^ d) + return true + } + return false +} +func rewriteValueS390X_OpS390XXORWload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (XORWload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (XORWload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XXORWload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (XORWload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (XORWload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XXORWload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpS390XXORconst(v *Value) bool { + v_0 := v.Args[0] + // match: (XORconst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (XORconst [c] (MOVDconst [d])) + // result: (MOVDconst [c^d]) + for { + c := auxIntToInt64(v.AuxInt) + if v_0.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(c ^ d) + return true + } + return false +} +func rewriteValueS390X_OpS390XXORload(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (XORload [off] {sym} x ptr1 (FMOVDstore [off] {sym} ptr2 y _)) + // cond: isSamePtr(ptr1, ptr2) + // result: (XOR x (LGDR y)) + for { + t := v.Type + off := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + ptr1 := v_1 + if v_2.Op != OpS390XFMOVDstore || auxIntToInt32(v_2.AuxInt) != off || auxToSym(v_2.Aux) != sym { + break + } + y := v_2.Args[1] + ptr2 := v_2.Args[0] + if !(isSamePtr(ptr1, ptr2)) { + break + } + v.reset(OpS390XXOR) + v0 := b.NewValue0(v_2.Pos, OpS390XLGDR, t) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (XORload [off1] {sym} x (ADDconst [off2] ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2)) + // result: (XORload [off1+off2] {sym} x ptr mem) + for { + off1 := auxIntToInt32(v.AuxInt) + sym := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XADDconst { + break + } + off2 := auxIntToInt32(v_1.AuxInt) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(off1)+int64(off2))) { + break + } + v.reset(OpS390XXORload) + v.AuxInt = int32ToAuxInt(off1 + off2) + v.Aux = symToAux(sym) + v.AddArg3(x, ptr, mem) + return true + } + // match: (XORload [o1] {s1} x (MOVDaddr [o2] {s2} ptr) mem) + // cond: ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2) + // result: (XORload [o1+o2] {mergeSym(s1, s2)} x ptr mem) + for { + o1 := auxIntToInt32(v.AuxInt) + s1 := auxToSym(v.Aux) + x := v_0 + if v_1.Op != OpS390XMOVDaddr { + break + } + o2 := auxIntToInt32(v_1.AuxInt) + s2 := auxToSym(v_1.Aux) + ptr := v_1.Args[0] + mem := v_2 + if !(ptr.Op != OpSB && is20Bit(int64(o1)+int64(o2)) && canMergeSym(s1, s2)) { + break + } + v.reset(OpS390XXORload) + v.AuxInt = int32ToAuxInt(o1 + o2) + v.Aux = symToAux(mergeSym(s1, s2)) + v.AddArg3(x, ptr, mem) + return true + } + return false +} +func rewriteValueS390X_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select0 (Add64carry x y c)) + // result: (Select0 (ADDE x y (Select1 (ADDCconst c [-1])))) + for { + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpSelect0) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpS390XADDE, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v2 := b.NewValue0(v.Pos, OpS390XADDCconst, types.NewTuple(typ.UInt64, types.TypeFlags)) + v2.AuxInt = int16ToAuxInt(-1) + v2.AddArg(c) + v1.AddArg(v2) + v0.AddArg3(x, y, v1) + v.AddArg(v0) + return true + } + // match: (Select0 (Sub64borrow x y c)) + // result: (Select0 (SUBE x y (Select1 (SUBC (MOVDconst [0]) c)))) + for { + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpSelect0) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpS390XSUBE, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v2 := b.NewValue0(v.Pos, OpS390XSUBC, types.NewTuple(typ.UInt64, types.TypeFlags)) + v3 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v3.AuxInt = int64ToAuxInt(0) + v2.AddArg2(v3, c) + v1.AddArg(v2) + v0.AddArg3(x, y, v1) + v.AddArg(v0) + return true + } + // match: (Select0 (AddTupleFirst32 val tuple)) + // result: (ADDW val (Select0 tuple)) + for { + t := v.Type + if v_0.Op != OpS390XAddTupleFirst32 { + break + } + tuple := v_0.Args[1] + val := v_0.Args[0] + v.reset(OpS390XADDW) + v0 := b.NewValue0(v.Pos, OpSelect0, t) + v0.AddArg(tuple) + v.AddArg2(val, v0) + return true + } + // match: (Select0 (AddTupleFirst64 val tuple)) + // result: (ADD val (Select0 tuple)) + for { + t := v.Type + if v_0.Op != OpS390XAddTupleFirst64 { + break + } + tuple := v_0.Args[1] + val := v_0.Args[0] + v.reset(OpS390XADD) + v0 := b.NewValue0(v.Pos, OpSelect0, t) + v0.AddArg(tuple) + v.AddArg2(val, v0) + return true + } + // match: (Select0 (ADDCconst (MOVDconst [c]) [d])) + // result: (MOVDconst [c+int64(d)]) + for { + if v_0.Op != OpS390XADDCconst { + break + } + d := auxIntToInt16(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(c + int64(d)) + return true + } + // match: (Select0 (SUBC (MOVDconst [c]) (MOVDconst [d]))) + // result: (MOVDconst [c-d]) + for { + if v_0.Op != OpS390XSUBC { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0_1.AuxInt) + v.reset(OpS390XMOVDconst) + v.AuxInt = int64ToAuxInt(c - d) + return true + } + // match: (Select0 (FADD (FMUL y z) x)) + // cond: x.Block.Func.useFMA(v) + // result: (FMADD x y z) + for { + if v_0.Op != OpS390XFADD { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpS390XFMUL { + continue + } + z := v_0_0.Args[1] + y := v_0_0.Args[0] + x := v_0_1 + if !(x.Block.Func.useFMA(v)) { + continue + } + v.reset(OpS390XFMADD) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (Select0 (FSUB (FMUL y z) x)) + // cond: x.Block.Func.useFMA(v) + // result: (FMSUB x y z) + for { + if v_0.Op != OpS390XFSUB { + break + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XFMUL { + break + } + z := v_0_0.Args[1] + y := v_0_0.Args[0] + if !(x.Block.Func.useFMA(v)) { + break + } + v.reset(OpS390XFMSUB) + v.AddArg3(x, y, z) + return true + } + // match: (Select0 (FADDS (FMULS y z) x)) + // cond: x.Block.Func.useFMA(v) + // result: (FMADDS x y z) + for { + if v_0.Op != OpS390XFADDS { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpS390XFMULS { + continue + } + z := v_0_0.Args[1] + y := v_0_0.Args[0] + x := v_0_1 + if !(x.Block.Func.useFMA(v)) { + continue + } + v.reset(OpS390XFMADDS) + v.AddArg3(x, y, z) + return true + } + break + } + // match: (Select0 (FSUBS (FMULS y z) x)) + // cond: x.Block.Func.useFMA(v) + // result: (FMSUBS x y z) + for { + if v_0.Op != OpS390XFSUBS { + break + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XFMULS { + break + } + z := v_0_0.Args[1] + y := v_0_0.Args[0] + if !(x.Block.Func.useFMA(v)) { + break + } + v.reset(OpS390XFMSUBS) + v.AddArg3(x, y, z) + return true + } + return false +} +func rewriteValueS390X_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select1 (Add64carry x y c)) + // result: (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) (Select1 (ADDE x y (Select1 (ADDCconst c [-1])))))) + for { + if v_0.Op != OpAdd64carry { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpSelect0) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpS390XADDE, types.NewTuple(typ.UInt64, types.TypeFlags)) + v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v3 := b.NewValue0(v.Pos, OpS390XADDE, types.NewTuple(typ.UInt64, types.TypeFlags)) + v4 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v5 := b.NewValue0(v.Pos, OpS390XADDCconst, types.NewTuple(typ.UInt64, types.TypeFlags)) + v5.AuxInt = int16ToAuxInt(-1) + v5.AddArg(c) + v4.AddArg(v5) + v3.AddArg3(x, y, v4) + v2.AddArg(v3) + v0.AddArg3(v1, v1, v2) + v.AddArg(v0) + return true + } + // match: (Select1 (Sub64borrow x y c)) + // result: (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) (Select1 (SUBE x y (Select1 (SUBC (MOVDconst [0]) c))))))) + for { + if v_0.Op != OpSub64borrow { + break + } + c := v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v.reset(OpS390XNEG) + v0 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpS390XSUBE, types.NewTuple(typ.UInt64, types.TypeFlags)) + v2 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64) + v2.AuxInt = int64ToAuxInt(0) + v3 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v4 := b.NewValue0(v.Pos, OpS390XSUBE, types.NewTuple(typ.UInt64, types.TypeFlags)) + v5 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v6 := b.NewValue0(v.Pos, OpS390XSUBC, types.NewTuple(typ.UInt64, types.TypeFlags)) + v6.AddArg2(v2, c) + v5.AddArg(v6) + v4.AddArg3(x, y, v5) + v3.AddArg(v4) + v1.AddArg3(v2, v2, v3) + v0.AddArg(v1) + v.AddArg(v0) + return true + } + // match: (Select1 (AddTupleFirst32 _ tuple)) + // result: (Select1 tuple) + for { + if v_0.Op != OpS390XAddTupleFirst32 { + break + } + tuple := v_0.Args[1] + v.reset(OpSelect1) + v.AddArg(tuple) + return true + } + // match: (Select1 (AddTupleFirst64 _ tuple)) + // result: (Select1 tuple) + for { + if v_0.Op != OpS390XAddTupleFirst64 { + break + } + tuple := v_0.Args[1] + v.reset(OpSelect1) + v.AddArg(tuple) + return true + } + // match: (Select1 (ADDCconst (MOVDconst [c]) [d])) + // cond: uint64(c+int64(d)) >= uint64(c) && c+int64(d) == 0 + // result: (FlagEQ) + for { + if v_0.Op != OpS390XADDCconst { + break + } + d := auxIntToInt16(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + if !(uint64(c+int64(d)) >= uint64(c) && c+int64(d) == 0) { + break + } + v.reset(OpS390XFlagEQ) + return true + } + // match: (Select1 (ADDCconst (MOVDconst [c]) [d])) + // cond: uint64(c+int64(d)) >= uint64(c) && c+int64(d) != 0 + // result: (FlagLT) + for { + if v_0.Op != OpS390XADDCconst { + break + } + d := auxIntToInt16(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + if !(uint64(c+int64(d)) >= uint64(c) && c+int64(d) != 0) { + break + } + v.reset(OpS390XFlagLT) + return true + } + // match: (Select1 (SUBC (MOVDconst [c]) (MOVDconst [d]))) + // cond: uint64(d) <= uint64(c) && c-d == 0 + // result: (FlagGT) + for { + if v_0.Op != OpS390XSUBC { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0_1.AuxInt) + if !(uint64(d) <= uint64(c) && c-d == 0) { + break + } + v.reset(OpS390XFlagGT) + return true + } + // match: (Select1 (SUBC (MOVDconst [c]) (MOVDconst [d]))) + // cond: uint64(d) <= uint64(c) && c-d != 0 + // result: (FlagOV) + for { + if v_0.Op != OpS390XSUBC { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XMOVDconst { + break + } + c := auxIntToInt64(v_0_0.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpS390XMOVDconst { + break + } + d := auxIntToInt64(v_0_1.AuxInt) + if !(uint64(d) <= uint64(c) && c-d != 0) { + break + } + v.reset(OpS390XFlagOV) + return true + } + return false +} +func rewriteValueS390X_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Slicemask x) + // result: (SRADconst (NEG x) [63]) + for { + t := v.Type + x := v_0 + v.reset(OpS390XSRADconst) + v.AuxInt = uint8ToAuxInt(63) + v0 := b.NewValue0(v.Pos, OpS390XNEG, t) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && t.IsFloat() + // result: (FMOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && t.IsFloat()) { + break + } + v.reset(OpS390XFMOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && t.IsFloat() + // result: (FMOVSstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && t.IsFloat()) { + break + } + v.reset(OpS390XFMOVSstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 && !t.IsFloat() + // result: (MOVDstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8 && !t.IsFloat()) { + break + } + v.reset(OpS390XMOVDstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 && !t.IsFloat() + // result: (MOVWstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4 && !t.IsFloat()) { + break + } + v.reset(OpS390XMOVWstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (MOVHstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(OpS390XMOVHstore) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (MOVBstore ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(OpS390XMOVBstore) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueS390X_OpSub32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Sub32F x y) + // result: (Select0 (FSUBS x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpS390XFSUBS, types.NewTuple(typ.Float32, types.TypeFlags)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpSub64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Sub64F x y) + // result: (Select0 (FSUB x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpS390XFSUB, types.NewTuple(typ.Float64, types.TypeFlags)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValueS390X_OpTrunc(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc x) + // result: (FIDBR [5] x) + for { + x := v_0 + v.reset(OpS390XFIDBR) + v.AuxInt = int8ToAuxInt(5) + v.AddArg(x) + return true + } +} +func rewriteValueS390X_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] destptr mem) + // result: (MOVBstoreconst [0] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpS390XMOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(0) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [2] destptr mem) + // result: (MOVHstoreconst [0] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpS390XMOVHstoreconst) + v.AuxInt = valAndOffToAuxInt(0) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [4] destptr mem) + // result: (MOVWstoreconst [0] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpS390XMOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(0) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [8] destptr mem) + // result: (MOVDstoreconst [0] destptr mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpS390XMOVDstoreconst) + v.AuxInt = valAndOffToAuxInt(0) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [3] destptr mem) + // result: (MOVBstoreconst [makeValAndOff(0,2)] destptr (MOVHstoreconst [0] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpS390XMOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 2)) + v0 := b.NewValue0(v.Pos, OpS390XMOVHstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(0) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [5] destptr mem) + // result: (MOVBstoreconst [makeValAndOff(0,4)] destptr (MOVWstoreconst [0] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpS390XMOVBstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 4)) + v0 := b.NewValue0(v.Pos, OpS390XMOVWstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(0) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [6] destptr mem) + // result: (MOVHstoreconst [makeValAndOff(0,4)] destptr (MOVWstoreconst [0] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpS390XMOVHstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 4)) + v0 := b.NewValue0(v.Pos, OpS390XMOVWstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(0) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [7] destptr mem) + // result: (MOVWstoreconst [makeValAndOff(0,3)] destptr (MOVWstoreconst [0] destptr mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpS390XMOVWstoreconst) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(0, 3)) + v0 := b.NewValue0(v.Pos, OpS390XMOVWstoreconst, types.TypeMem) + v0.AuxInt = valAndOffToAuxInt(0) + v0.AddArg2(destptr, mem) + v.AddArg2(destptr, v0) + return true + } + // match: (Zero [s] destptr mem) + // cond: s > 0 && s <= 1024 + // result: (CLEAR [makeValAndOff(int32(s), 0)] destptr mem) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s > 0 && s <= 1024) { + break + } + v.reset(OpS390XCLEAR) + v.AuxInt = valAndOffToAuxInt(makeValAndOff(int32(s), 0)) + v.AddArg2(destptr, mem) + return true + } + // match: (Zero [s] destptr mem) + // cond: s > 1024 + // result: (LoweredZero [s%256] destptr (ADDconst destptr [(int32(s)/256)*256]) mem) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s > 1024) { + break + } + v.reset(OpS390XLoweredZero) + v.AuxInt = int64ToAuxInt(s % 256) + v0 := b.NewValue0(v.Pos, OpS390XADDconst, destptr.Type) + v0.AuxInt = int32ToAuxInt((int32(s) / 256) * 256) + v0.AddArg(destptr) + v.AddArg3(destptr, v0, mem) + return true + } + return false +} +func rewriteBlockS390X(b *Block) bool { + typ := &b.Func.Config.Types + switch b.Kind { + case BlockS390XBRC: + // match: (BRC {c} x:(CMP _ _) yes no) + // cond: c&s390x.Unordered != 0 + // result: (BRC {c&^s390x.Unordered} x yes no) + for b.Controls[0].Op == OpS390XCMP { + x := b.Controls[0] + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Unordered != 0) { + break + } + b.resetWithControl(BlockS390XBRC, x) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} x:(CMPW _ _) yes no) + // cond: c&s390x.Unordered != 0 + // result: (BRC {c&^s390x.Unordered} x yes no) + for b.Controls[0].Op == OpS390XCMPW { + x := b.Controls[0] + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Unordered != 0) { + break + } + b.resetWithControl(BlockS390XBRC, x) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} x:(CMPU _ _) yes no) + // cond: c&s390x.Unordered != 0 + // result: (BRC {c&^s390x.Unordered} x yes no) + for b.Controls[0].Op == OpS390XCMPU { + x := b.Controls[0] + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Unordered != 0) { + break + } + b.resetWithControl(BlockS390XBRC, x) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} x:(CMPWU _ _) yes no) + // cond: c&s390x.Unordered != 0 + // result: (BRC {c&^s390x.Unordered} x yes no) + for b.Controls[0].Op == OpS390XCMPWU { + x := b.Controls[0] + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Unordered != 0) { + break + } + b.resetWithControl(BlockS390XBRC, x) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} x:(CMPconst _) yes no) + // cond: c&s390x.Unordered != 0 + // result: (BRC {c&^s390x.Unordered} x yes no) + for b.Controls[0].Op == OpS390XCMPconst { + x := b.Controls[0] + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Unordered != 0) { + break + } + b.resetWithControl(BlockS390XBRC, x) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} x:(CMPWconst _) yes no) + // cond: c&s390x.Unordered != 0 + // result: (BRC {c&^s390x.Unordered} x yes no) + for b.Controls[0].Op == OpS390XCMPWconst { + x := b.Controls[0] + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Unordered != 0) { + break + } + b.resetWithControl(BlockS390XBRC, x) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} x:(CMPUconst _) yes no) + // cond: c&s390x.Unordered != 0 + // result: (BRC {c&^s390x.Unordered} x yes no) + for b.Controls[0].Op == OpS390XCMPUconst { + x := b.Controls[0] + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Unordered != 0) { + break + } + b.resetWithControl(BlockS390XBRC, x) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} x:(CMPWUconst _) yes no) + // cond: c&s390x.Unordered != 0 + // result: (BRC {c&^s390x.Unordered} x yes no) + for b.Controls[0].Op == OpS390XCMPWUconst { + x := b.Controls[0] + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Unordered != 0) { + break + } + b.resetWithControl(BlockS390XBRC, x) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} (CMP x y) yes no) + // result: (CGRJ {c&^s390x.Unordered} x y yes no) + for b.Controls[0].Op == OpS390XCMP { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + b.resetWithControl2(BlockS390XCGRJ, x, y) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} (CMPW x y) yes no) + // result: (CRJ {c&^s390x.Unordered} x y yes no) + for b.Controls[0].Op == OpS390XCMPW { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + b.resetWithControl2(BlockS390XCRJ, x, y) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} (CMPU x y) yes no) + // result: (CLGRJ {c&^s390x.Unordered} x y yes no) + for b.Controls[0].Op == OpS390XCMPU { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + b.resetWithControl2(BlockS390XCLGRJ, x, y) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} (CMPWU x y) yes no) + // result: (CLRJ {c&^s390x.Unordered} x y yes no) + for b.Controls[0].Op == OpS390XCMPWU { + v_0 := b.Controls[0] + y := v_0.Args[1] + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + b.resetWithControl2(BlockS390XCLRJ, x, y) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} (CMPconst x [y]) yes no) + // cond: y == int32( int8(y)) + // result: (CGIJ {c&^s390x.Unordered} x [ int8(y)] yes no) + for b.Controls[0].Op == OpS390XCMPconst { + v_0 := b.Controls[0] + y := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + if !(y == int32(int8(y))) { + break + } + b.resetWithControl(BlockS390XCGIJ, x) + b.AuxInt = int8ToAuxInt(int8(y)) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} (CMPWconst x [y]) yes no) + // cond: y == int32( int8(y)) + // result: (CIJ {c&^s390x.Unordered} x [ int8(y)] yes no) + for b.Controls[0].Op == OpS390XCMPWconst { + v_0 := b.Controls[0] + y := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + if !(y == int32(int8(y))) { + break + } + b.resetWithControl(BlockS390XCIJ, x) + b.AuxInt = int8ToAuxInt(int8(y)) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} (CMPUconst x [y]) yes no) + // cond: y == int32(uint8(y)) + // result: (CLGIJ {c&^s390x.Unordered} x [uint8(y)] yes no) + for b.Controls[0].Op == OpS390XCMPUconst { + v_0 := b.Controls[0] + y := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + if !(y == int32(uint8(y))) { + break + } + b.resetWithControl(BlockS390XCLGIJ, x) + b.AuxInt = uint8ToAuxInt(uint8(y)) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {c} (CMPWUconst x [y]) yes no) + // cond: y == int32(uint8(y)) + // result: (CLIJ {c&^s390x.Unordered} x [uint8(y)] yes no) + for b.Controls[0].Op == OpS390XCMPWUconst { + v_0 := b.Controls[0] + y := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + if !(y == int32(uint8(y))) { + break + } + b.resetWithControl(BlockS390XCLIJ, x) + b.AuxInt = uint8ToAuxInt(uint8(y)) + b.Aux = s390xCCMaskToAux(c &^ s390x.Unordered) + return true + } + // match: (BRC {s390x.Less} (CMPconst x [ 128]) yes no) + // result: (CGIJ {s390x.LessOrEqual} x [ 127] yes no) + for b.Controls[0].Op == OpS390XCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 128 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.Less { + break + } + b.resetWithControl(BlockS390XCGIJ, x) + b.AuxInt = int8ToAuxInt(127) + b.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + return true + } + // match: (BRC {s390x.Less} (CMPWconst x [ 128]) yes no) + // result: (CIJ {s390x.LessOrEqual} x [ 127] yes no) + for b.Controls[0].Op == OpS390XCMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 128 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.Less { + break + } + b.resetWithControl(BlockS390XCIJ, x) + b.AuxInt = int8ToAuxInt(127) + b.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + return true + } + // match: (BRC {s390x.LessOrEqual} (CMPconst x [-129]) yes no) + // result: (CGIJ {s390x.Less} x [-128] yes no) + for b.Controls[0].Op == OpS390XCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != -129 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.LessOrEqual { + break + } + b.resetWithControl(BlockS390XCGIJ, x) + b.AuxInt = int8ToAuxInt(-128) + b.Aux = s390xCCMaskToAux(s390x.Less) + return true + } + // match: (BRC {s390x.LessOrEqual} (CMPWconst x [-129]) yes no) + // result: (CIJ {s390x.Less} x [-128] yes no) + for b.Controls[0].Op == OpS390XCMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != -129 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.LessOrEqual { + break + } + b.resetWithControl(BlockS390XCIJ, x) + b.AuxInt = int8ToAuxInt(-128) + b.Aux = s390xCCMaskToAux(s390x.Less) + return true + } + // match: (BRC {s390x.Greater} (CMPconst x [-129]) yes no) + // result: (CGIJ {s390x.GreaterOrEqual} x [-128] yes no) + for b.Controls[0].Op == OpS390XCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != -129 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.Greater { + break + } + b.resetWithControl(BlockS390XCGIJ, x) + b.AuxInt = int8ToAuxInt(-128) + b.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + return true + } + // match: (BRC {s390x.Greater} (CMPWconst x [-129]) yes no) + // result: (CIJ {s390x.GreaterOrEqual} x [-128] yes no) + for b.Controls[0].Op == OpS390XCMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != -129 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.Greater { + break + } + b.resetWithControl(BlockS390XCIJ, x) + b.AuxInt = int8ToAuxInt(-128) + b.Aux = s390xCCMaskToAux(s390x.GreaterOrEqual) + return true + } + // match: (BRC {s390x.GreaterOrEqual} (CMPconst x [ 128]) yes no) + // result: (CGIJ {s390x.Greater} x [ 127] yes no) + for b.Controls[0].Op == OpS390XCMPconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 128 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.GreaterOrEqual { + break + } + b.resetWithControl(BlockS390XCGIJ, x) + b.AuxInt = int8ToAuxInt(127) + b.Aux = s390xCCMaskToAux(s390x.Greater) + return true + } + // match: (BRC {s390x.GreaterOrEqual} (CMPWconst x [ 128]) yes no) + // result: (CIJ {s390x.Greater} x [ 127] yes no) + for b.Controls[0].Op == OpS390XCMPWconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 128 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.GreaterOrEqual { + break + } + b.resetWithControl(BlockS390XCIJ, x) + b.AuxInt = int8ToAuxInt(127) + b.Aux = s390xCCMaskToAux(s390x.Greater) + return true + } + // match: (BRC {s390x.Less} (CMPWUconst x [256]) yes no) + // result: (CLIJ {s390x.LessOrEqual} x [255] yes no) + for b.Controls[0].Op == OpS390XCMPWUconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 256 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.Less { + break + } + b.resetWithControl(BlockS390XCLIJ, x) + b.AuxInt = uint8ToAuxInt(255) + b.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + return true + } + // match: (BRC {s390x.Less} (CMPUconst x [256]) yes no) + // result: (CLGIJ {s390x.LessOrEqual} x [255] yes no) + for b.Controls[0].Op == OpS390XCMPUconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 256 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.Less { + break + } + b.resetWithControl(BlockS390XCLGIJ, x) + b.AuxInt = uint8ToAuxInt(255) + b.Aux = s390xCCMaskToAux(s390x.LessOrEqual) + return true + } + // match: (BRC {s390x.GreaterOrEqual} (CMPWUconst x [256]) yes no) + // result: (CLIJ {s390x.Greater} x [255] yes no) + for b.Controls[0].Op == OpS390XCMPWUconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 256 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.GreaterOrEqual { + break + } + b.resetWithControl(BlockS390XCLIJ, x) + b.AuxInt = uint8ToAuxInt(255) + b.Aux = s390xCCMaskToAux(s390x.Greater) + return true + } + // match: (BRC {s390x.GreaterOrEqual} (CMPUconst x [256]) yes no) + // result: (CLGIJ {s390x.Greater} x [255] yes no) + for b.Controls[0].Op == OpS390XCMPUconst { + v_0 := b.Controls[0] + if auxIntToInt32(v_0.AuxInt) != 256 { + break + } + x := v_0.Args[0] + if auxToS390xCCMask(b.Aux) != s390x.GreaterOrEqual { + break + } + b.resetWithControl(BlockS390XCLGIJ, x) + b.AuxInt = uint8ToAuxInt(255) + b.Aux = s390xCCMaskToAux(s390x.Greater) + return true + } + // match: (BRC {c} (CMPconst x [y]) yes no) + // cond: y == int32(uint8(y)) && (c == s390x.Equal || c == s390x.LessOrGreater) + // result: (CLGIJ {c} x [uint8(y)] yes no) + for b.Controls[0].Op == OpS390XCMPconst { + v_0 := b.Controls[0] + y := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + if !(y == int32(uint8(y)) && (c == s390x.Equal || c == s390x.LessOrGreater)) { + break + } + b.resetWithControl(BlockS390XCLGIJ, x) + b.AuxInt = uint8ToAuxInt(uint8(y)) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (BRC {c} (CMPWconst x [y]) yes no) + // cond: y == int32(uint8(y)) && (c == s390x.Equal || c == s390x.LessOrGreater) + // result: (CLIJ {c} x [uint8(y)] yes no) + for b.Controls[0].Op == OpS390XCMPWconst { + v_0 := b.Controls[0] + y := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + if !(y == int32(uint8(y)) && (c == s390x.Equal || c == s390x.LessOrGreater)) { + break + } + b.resetWithControl(BlockS390XCLIJ, x) + b.AuxInt = uint8ToAuxInt(uint8(y)) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (BRC {c} (CMPUconst x [y]) yes no) + // cond: y == int32( int8(y)) && (c == s390x.Equal || c == s390x.LessOrGreater) + // result: (CGIJ {c} x [ int8(y)] yes no) + for b.Controls[0].Op == OpS390XCMPUconst { + v_0 := b.Controls[0] + y := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + if !(y == int32(int8(y)) && (c == s390x.Equal || c == s390x.LessOrGreater)) { + break + } + b.resetWithControl(BlockS390XCGIJ, x) + b.AuxInt = int8ToAuxInt(int8(y)) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (BRC {c} (CMPWUconst x [y]) yes no) + // cond: y == int32( int8(y)) && (c == s390x.Equal || c == s390x.LessOrGreater) + // result: (CIJ {c} x [ int8(y)] yes no) + for b.Controls[0].Op == OpS390XCMPWUconst { + v_0 := b.Controls[0] + y := auxIntToInt32(v_0.AuxInt) + x := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + if !(y == int32(int8(y)) && (c == s390x.Equal || c == s390x.LessOrGreater)) { + break + } + b.resetWithControl(BlockS390XCIJ, x) + b.AuxInt = int8ToAuxInt(int8(y)) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (BRC {c} (InvertFlags cmp) yes no) + // result: (BRC {c.ReverseComparison()} cmp yes no) + for b.Controls[0].Op == OpS390XInvertFlags { + v_0 := b.Controls[0] + cmp := v_0.Args[0] + c := auxToS390xCCMask(b.Aux) + b.resetWithControl(BlockS390XBRC, cmp) + b.Aux = s390xCCMaskToAux(c.ReverseComparison()) + return true + } + // match: (BRC {c} (FlagEQ) yes no) + // cond: c&s390x.Equal != 0 + // result: (First yes no) + for b.Controls[0].Op == OpS390XFlagEQ { + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Equal != 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (BRC {c} (FlagLT) yes no) + // cond: c&s390x.Less != 0 + // result: (First yes no) + for b.Controls[0].Op == OpS390XFlagLT { + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Less != 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (BRC {c} (FlagGT) yes no) + // cond: c&s390x.Greater != 0 + // result: (First yes no) + for b.Controls[0].Op == OpS390XFlagGT { + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Greater != 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (BRC {c} (FlagOV) yes no) + // cond: c&s390x.Unordered != 0 + // result: (First yes no) + for b.Controls[0].Op == OpS390XFlagOV { + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Unordered != 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (BRC {c} (FlagEQ) yes no) + // cond: c&s390x.Equal == 0 + // result: (First no yes) + for b.Controls[0].Op == OpS390XFlagEQ { + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Equal == 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (BRC {c} (FlagLT) yes no) + // cond: c&s390x.Less == 0 + // result: (First no yes) + for b.Controls[0].Op == OpS390XFlagLT { + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Less == 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (BRC {c} (FlagGT) yes no) + // cond: c&s390x.Greater == 0 + // result: (First no yes) + for b.Controls[0].Op == OpS390XFlagGT { + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Greater == 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (BRC {c} (FlagOV) yes no) + // cond: c&s390x.Unordered == 0 + // result: (First no yes) + for b.Controls[0].Op == OpS390XFlagOV { + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Unordered == 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockS390XCGIJ: + // match: (CGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Equal != 0 && int64(x) == int64(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Equal != 0 && int64(x) == int64(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Less != 0 && int64(x) < int64(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Less != 0 && int64(x) < int64(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Greater != 0 && int64(x) > int64(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Greater != 0 && int64(x) > int64(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Equal == 0 && int64(x) == int64(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Equal == 0 && int64(x) == int64(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Less == 0 && int64(x) < int64(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Less == 0 && int64(x) < int64(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Greater == 0 && int64(x) > int64(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Greater == 0 && int64(x) > int64(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CGIJ {s390x.Equal} (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) carry)) [0]) + // result: (BRC {s390x.NoCarry} carry) + for b.Controls[0].Op == OpSelect0 { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XADDE { + break + } + carry := v_0_0.Args[2] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0.AuxInt) != 0 { + break + } + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_1.AuxInt) != 0 || auxIntToInt8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.Equal { + break + } + b.resetWithControl(BlockS390XBRC, carry) + b.Aux = s390xCCMaskToAux(s390x.NoCarry) + return true + } + // match: (CGIJ {s390x.Equal} (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) carry)) [1]) + // result: (BRC {s390x.Carry} carry) + for b.Controls[0].Op == OpSelect0 { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XADDE { + break + } + carry := v_0_0.Args[2] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0.AuxInt) != 0 { + break + } + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_1.AuxInt) != 0 || auxIntToInt8(b.AuxInt) != 1 || auxToS390xCCMask(b.Aux) != s390x.Equal { + break + } + b.resetWithControl(BlockS390XBRC, carry) + b.Aux = s390xCCMaskToAux(s390x.Carry) + return true + } + // match: (CGIJ {s390x.LessOrGreater} (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) carry)) [0]) + // result: (BRC {s390x.Carry} carry) + for b.Controls[0].Op == OpSelect0 { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XADDE { + break + } + carry := v_0_0.Args[2] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0.AuxInt) != 0 { + break + } + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_1.AuxInt) != 0 || auxIntToInt8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.LessOrGreater { + break + } + b.resetWithControl(BlockS390XBRC, carry) + b.Aux = s390xCCMaskToAux(s390x.Carry) + return true + } + // match: (CGIJ {s390x.LessOrGreater} (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) carry)) [1]) + // result: (BRC {s390x.NoCarry} carry) + for b.Controls[0].Op == OpSelect0 { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XADDE { + break + } + carry := v_0_0.Args[2] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0.AuxInt) != 0 { + break + } + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_1.AuxInt) != 0 || auxIntToInt8(b.AuxInt) != 1 || auxToS390xCCMask(b.Aux) != s390x.LessOrGreater { + break + } + b.resetWithControl(BlockS390XBRC, carry) + b.Aux = s390xCCMaskToAux(s390x.NoCarry) + return true + } + // match: (CGIJ {s390x.Greater} (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) carry)) [0]) + // result: (BRC {s390x.Carry} carry) + for b.Controls[0].Op == OpSelect0 { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XADDE { + break + } + carry := v_0_0.Args[2] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0.AuxInt) != 0 { + break + } + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_1.AuxInt) != 0 || auxIntToInt8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.Greater { + break + } + b.resetWithControl(BlockS390XBRC, carry) + b.Aux = s390xCCMaskToAux(s390x.Carry) + return true + } + // match: (CGIJ {s390x.Equal} (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) borrow))) [0]) + // result: (BRC {s390x.NoBorrow} borrow) + for b.Controls[0].Op == OpS390XNEG { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelect0 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XSUBE { + break + } + borrow := v_0_0_0.Args[2] + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_0.AuxInt) != 0 { + break + } + v_0_0_0_1 := v_0_0_0.Args[1] + if v_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_1.AuxInt) != 0 || auxIntToInt8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.Equal { + break + } + b.resetWithControl(BlockS390XBRC, borrow) + b.Aux = s390xCCMaskToAux(s390x.NoBorrow) + return true + } + // match: (CGIJ {s390x.Equal} (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) borrow))) [1]) + // result: (BRC {s390x.Borrow} borrow) + for b.Controls[0].Op == OpS390XNEG { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelect0 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XSUBE { + break + } + borrow := v_0_0_0.Args[2] + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_0.AuxInt) != 0 { + break + } + v_0_0_0_1 := v_0_0_0.Args[1] + if v_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_1.AuxInt) != 0 || auxIntToInt8(b.AuxInt) != 1 || auxToS390xCCMask(b.Aux) != s390x.Equal { + break + } + b.resetWithControl(BlockS390XBRC, borrow) + b.Aux = s390xCCMaskToAux(s390x.Borrow) + return true + } + // match: (CGIJ {s390x.LessOrGreater} (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) borrow))) [0]) + // result: (BRC {s390x.Borrow} borrow) + for b.Controls[0].Op == OpS390XNEG { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelect0 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XSUBE { + break + } + borrow := v_0_0_0.Args[2] + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_0.AuxInt) != 0 { + break + } + v_0_0_0_1 := v_0_0_0.Args[1] + if v_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_1.AuxInt) != 0 || auxIntToInt8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.LessOrGreater { + break + } + b.resetWithControl(BlockS390XBRC, borrow) + b.Aux = s390xCCMaskToAux(s390x.Borrow) + return true + } + // match: (CGIJ {s390x.LessOrGreater} (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) borrow))) [1]) + // result: (BRC {s390x.NoBorrow} borrow) + for b.Controls[0].Op == OpS390XNEG { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelect0 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XSUBE { + break + } + borrow := v_0_0_0.Args[2] + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_0.AuxInt) != 0 { + break + } + v_0_0_0_1 := v_0_0_0.Args[1] + if v_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_1.AuxInt) != 0 || auxIntToInt8(b.AuxInt) != 1 || auxToS390xCCMask(b.Aux) != s390x.LessOrGreater { + break + } + b.resetWithControl(BlockS390XBRC, borrow) + b.Aux = s390xCCMaskToAux(s390x.NoBorrow) + return true + } + // match: (CGIJ {s390x.Greater} (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) borrow))) [0]) + // result: (BRC {s390x.Borrow} borrow) + for b.Controls[0].Op == OpS390XNEG { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelect0 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XSUBE { + break + } + borrow := v_0_0_0.Args[2] + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_0.AuxInt) != 0 { + break + } + v_0_0_0_1 := v_0_0_0.Args[1] + if v_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_1.AuxInt) != 0 || auxIntToInt8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.Greater { + break + } + b.resetWithControl(BlockS390XBRC, borrow) + b.Aux = s390xCCMaskToAux(s390x.Borrow) + return true + } + case BlockS390XCGRJ: + // match: (CGRJ {c} x (MOVDconst [y]) yes no) + // cond: is8Bit(y) + // result: (CGIJ {c} x [ int8(y)] yes no) + for b.Controls[1].Op == OpS390XMOVDconst { + x := b.Controls[0] + v_1 := b.Controls[1] + y := auxIntToInt64(v_1.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(is8Bit(y)) { + break + } + b.resetWithControl(BlockS390XCGIJ, x) + b.AuxInt = int8ToAuxInt(int8(y)) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CGRJ {c} (MOVDconst [x]) y yes no) + // cond: is8Bit(x) + // result: (CGIJ {c.ReverseComparison()} y [ int8(x)] yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(is8Bit(x)) { + break + } + b.resetWithControl(BlockS390XCGIJ, y) + b.AuxInt = int8ToAuxInt(int8(x)) + b.Aux = s390xCCMaskToAux(c.ReverseComparison()) + return true + } + // match: (CGRJ {c} x (MOVDconst [y]) yes no) + // cond: !is8Bit(y) && is32Bit(y) + // result: (BRC {c} (CMPconst x [int32(y)]) yes no) + for b.Controls[1].Op == OpS390XMOVDconst { + x := b.Controls[0] + v_1 := b.Controls[1] + y := auxIntToInt64(v_1.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(!is8Bit(y) && is32Bit(y)) { + break + } + v0 := b.NewValue0(x.Pos, OpS390XCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(y)) + v0.AddArg(x) + b.resetWithControl(BlockS390XBRC, v0) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CGRJ {c} (MOVDconst [x]) y yes no) + // cond: !is8Bit(x) && is32Bit(x) + // result: (BRC {c.ReverseComparison()} (CMPconst y [int32(x)]) yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(!is8Bit(x) && is32Bit(x)) { + break + } + v0 := b.NewValue0(v_0.Pos, OpS390XCMPconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(x)) + v0.AddArg(y) + b.resetWithControl(BlockS390XBRC, v0) + b.Aux = s390xCCMaskToAux(c.ReverseComparison()) + return true + } + // match: (CGRJ {c} x y yes no) + // cond: x == y && c&s390x.Equal != 0 + // result: (First yes no) + for { + x := b.Controls[0] + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(x == y && c&s390x.Equal != 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CGRJ {c} x y yes no) + // cond: x == y && c&s390x.Equal == 0 + // result: (First no yes) + for { + x := b.Controls[0] + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(x == y && c&s390x.Equal == 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockS390XCIJ: + // match: (CIJ {c} (MOVWreg x) [y] yes no) + // result: (CIJ {c} x [y] yes no) + for b.Controls[0].Op == OpS390XMOVWreg { + v_0 := b.Controls[0] + x := v_0.Args[0] + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + b.resetWithControl(BlockS390XCIJ, x) + b.AuxInt = int8ToAuxInt(y) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CIJ {c} (MOVWZreg x) [y] yes no) + // result: (CIJ {c} x [y] yes no) + for b.Controls[0].Op == OpS390XMOVWZreg { + v_0 := b.Controls[0] + x := v_0.Args[0] + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + b.resetWithControl(BlockS390XCIJ, x) + b.AuxInt = int8ToAuxInt(y) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Equal != 0 && int32(x) == int32(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Equal != 0 && int32(x) == int32(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Less != 0 && int32(x) < int32(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Less != 0 && int32(x) < int32(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Greater != 0 && int32(x) > int32(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Greater != 0 && int32(x) > int32(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Equal == 0 && int32(x) == int32(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Equal == 0 && int32(x) == int32(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Less == 0 && int32(x) < int32(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Less == 0 && int32(x) < int32(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Greater == 0 && int32(x) > int32(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToInt8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Greater == 0 && int32(x) > int32(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockS390XCLGIJ: + // match: (CLGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Equal != 0 && uint64(x) == uint64(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Equal != 0 && uint64(x) == uint64(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CLGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Less != 0 && uint64(x) < uint64(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Less != 0 && uint64(x) < uint64(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CLGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Greater != 0 && uint64(x) > uint64(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Greater != 0 && uint64(x) > uint64(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CLGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Equal == 0 && uint64(x) == uint64(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Equal == 0 && uint64(x) == uint64(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CLGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Less == 0 && uint64(x) < uint64(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Less == 0 && uint64(x) < uint64(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CLGIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Greater == 0 && uint64(x) > uint64(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Greater == 0 && uint64(x) > uint64(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CLGIJ {s390x.GreaterOrEqual} _ [0] yes no) + // result: (First yes no) + for { + if auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.GreaterOrEqual { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CLGIJ {s390x.Less} _ [0] yes no) + // result: (First no yes) + for { + if auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.Less { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CLGIJ {s390x.Equal} (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) carry)) [0]) + // result: (BRC {s390x.NoCarry} carry) + for b.Controls[0].Op == OpSelect0 { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XADDE { + break + } + carry := v_0_0.Args[2] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0.AuxInt) != 0 { + break + } + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_1.AuxInt) != 0 || auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.Equal { + break + } + b.resetWithControl(BlockS390XBRC, carry) + b.Aux = s390xCCMaskToAux(s390x.NoCarry) + return true + } + // match: (CLGIJ {s390x.Equal} (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) carry)) [1]) + // result: (BRC {s390x.Carry} carry) + for b.Controls[0].Op == OpSelect0 { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XADDE { + break + } + carry := v_0_0.Args[2] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0.AuxInt) != 0 { + break + } + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_1.AuxInt) != 0 || auxIntToUint8(b.AuxInt) != 1 || auxToS390xCCMask(b.Aux) != s390x.Equal { + break + } + b.resetWithControl(BlockS390XBRC, carry) + b.Aux = s390xCCMaskToAux(s390x.Carry) + return true + } + // match: (CLGIJ {s390x.LessOrGreater} (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) carry)) [0]) + // result: (BRC {s390x.Carry} carry) + for b.Controls[0].Op == OpSelect0 { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XADDE { + break + } + carry := v_0_0.Args[2] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0.AuxInt) != 0 { + break + } + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_1.AuxInt) != 0 || auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.LessOrGreater { + break + } + b.resetWithControl(BlockS390XBRC, carry) + b.Aux = s390xCCMaskToAux(s390x.Carry) + return true + } + // match: (CLGIJ {s390x.LessOrGreater} (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) carry)) [1]) + // result: (BRC {s390x.NoCarry} carry) + for b.Controls[0].Op == OpSelect0 { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XADDE { + break + } + carry := v_0_0.Args[2] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0.AuxInt) != 0 { + break + } + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_1.AuxInt) != 0 || auxIntToUint8(b.AuxInt) != 1 || auxToS390xCCMask(b.Aux) != s390x.LessOrGreater { + break + } + b.resetWithControl(BlockS390XBRC, carry) + b.Aux = s390xCCMaskToAux(s390x.NoCarry) + return true + } + // match: (CLGIJ {s390x.Greater} (Select0 (ADDE (MOVDconst [0]) (MOVDconst [0]) carry)) [0]) + // result: (BRC {s390x.Carry} carry) + for b.Controls[0].Op == OpSelect0 { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XADDE { + break + } + carry := v_0_0.Args[2] + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0.AuxInt) != 0 { + break + } + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_1.AuxInt) != 0 || auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.Greater { + break + } + b.resetWithControl(BlockS390XBRC, carry) + b.Aux = s390xCCMaskToAux(s390x.Carry) + return true + } + // match: (CLGIJ {s390x.Equal} (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) borrow))) [0]) + // result: (BRC {s390x.NoBorrow} borrow) + for b.Controls[0].Op == OpS390XNEG { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelect0 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XSUBE { + break + } + borrow := v_0_0_0.Args[2] + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_0.AuxInt) != 0 { + break + } + v_0_0_0_1 := v_0_0_0.Args[1] + if v_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_1.AuxInt) != 0 || auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.Equal { + break + } + b.resetWithControl(BlockS390XBRC, borrow) + b.Aux = s390xCCMaskToAux(s390x.NoBorrow) + return true + } + // match: (CLGIJ {s390x.Equal} (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) borrow))) [1]) + // result: (BRC {s390x.Borrow} borrow) + for b.Controls[0].Op == OpS390XNEG { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelect0 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XSUBE { + break + } + borrow := v_0_0_0.Args[2] + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_0.AuxInt) != 0 { + break + } + v_0_0_0_1 := v_0_0_0.Args[1] + if v_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_1.AuxInt) != 0 || auxIntToUint8(b.AuxInt) != 1 || auxToS390xCCMask(b.Aux) != s390x.Equal { + break + } + b.resetWithControl(BlockS390XBRC, borrow) + b.Aux = s390xCCMaskToAux(s390x.Borrow) + return true + } + // match: (CLGIJ {s390x.LessOrGreater} (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) borrow))) [0]) + // result: (BRC {s390x.Borrow} borrow) + for b.Controls[0].Op == OpS390XNEG { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelect0 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XSUBE { + break + } + borrow := v_0_0_0.Args[2] + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_0.AuxInt) != 0 { + break + } + v_0_0_0_1 := v_0_0_0.Args[1] + if v_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_1.AuxInt) != 0 || auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.LessOrGreater { + break + } + b.resetWithControl(BlockS390XBRC, borrow) + b.Aux = s390xCCMaskToAux(s390x.Borrow) + return true + } + // match: (CLGIJ {s390x.LessOrGreater} (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) borrow))) [1]) + // result: (BRC {s390x.NoBorrow} borrow) + for b.Controls[0].Op == OpS390XNEG { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelect0 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XSUBE { + break + } + borrow := v_0_0_0.Args[2] + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_0.AuxInt) != 0 { + break + } + v_0_0_0_1 := v_0_0_0.Args[1] + if v_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_1.AuxInt) != 0 || auxIntToUint8(b.AuxInt) != 1 || auxToS390xCCMask(b.Aux) != s390x.LessOrGreater { + break + } + b.resetWithControl(BlockS390XBRC, borrow) + b.Aux = s390xCCMaskToAux(s390x.NoBorrow) + return true + } + // match: (CLGIJ {s390x.Greater} (NEG (Select0 (SUBE (MOVDconst [0]) (MOVDconst [0]) borrow))) [0]) + // result: (BRC {s390x.Borrow} borrow) + for b.Controls[0].Op == OpS390XNEG { + v_0 := b.Controls[0] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelect0 { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpS390XSUBE { + break + } + borrow := v_0_0_0.Args[2] + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_0.AuxInt) != 0 { + break + } + v_0_0_0_1 := v_0_0_0.Args[1] + if v_0_0_0_1.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0_0_1.AuxInt) != 0 || auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.Greater { + break + } + b.resetWithControl(BlockS390XBRC, borrow) + b.Aux = s390xCCMaskToAux(s390x.Borrow) + return true + } + case BlockS390XCLGRJ: + // match: (CLGRJ {c} x (MOVDconst [y]) yes no) + // cond: isU8Bit(y) + // result: (CLGIJ {c} x [uint8(y)] yes no) + for b.Controls[1].Op == OpS390XMOVDconst { + x := b.Controls[0] + v_1 := b.Controls[1] + y := auxIntToInt64(v_1.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(isU8Bit(y)) { + break + } + b.resetWithControl(BlockS390XCLGIJ, x) + b.AuxInt = uint8ToAuxInt(uint8(y)) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CLGRJ {c} (MOVDconst [x]) y yes no) + // cond: isU8Bit(x) + // result: (CLGIJ {c.ReverseComparison()} y [uint8(x)] yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(isU8Bit(x)) { + break + } + b.resetWithControl(BlockS390XCLGIJ, y) + b.AuxInt = uint8ToAuxInt(uint8(x)) + b.Aux = s390xCCMaskToAux(c.ReverseComparison()) + return true + } + // match: (CLGRJ {c} x (MOVDconst [y]) yes no) + // cond: !isU8Bit(y) && isU32Bit(y) + // result: (BRC {c} (CMPUconst x [int32(y)]) yes no) + for b.Controls[1].Op == OpS390XMOVDconst { + x := b.Controls[0] + v_1 := b.Controls[1] + y := auxIntToInt64(v_1.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(!isU8Bit(y) && isU32Bit(y)) { + break + } + v0 := b.NewValue0(x.Pos, OpS390XCMPUconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(y)) + v0.AddArg(x) + b.resetWithControl(BlockS390XBRC, v0) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CLGRJ {c} (MOVDconst [x]) y yes no) + // cond: !isU8Bit(x) && isU32Bit(x) + // result: (BRC {c.ReverseComparison()} (CMPUconst y [int32(x)]) yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(!isU8Bit(x) && isU32Bit(x)) { + break + } + v0 := b.NewValue0(v_0.Pos, OpS390XCMPUconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(x)) + v0.AddArg(y) + b.resetWithControl(BlockS390XBRC, v0) + b.Aux = s390xCCMaskToAux(c.ReverseComparison()) + return true + } + // match: (CLGRJ {c} x y yes no) + // cond: x == y && c&s390x.Equal != 0 + // result: (First yes no) + for { + x := b.Controls[0] + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(x == y && c&s390x.Equal != 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CLGRJ {c} x y yes no) + // cond: x == y && c&s390x.Equal == 0 + // result: (First no yes) + for { + x := b.Controls[0] + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(x == y && c&s390x.Equal == 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockS390XCLIJ: + // match: (CLIJ {s390x.LessOrGreater} (LOCGR {d} (MOVDconst [0]) (MOVDconst [x]) cmp) [0] yes no) + // cond: int32(x) != 0 + // result: (BRC {d} cmp yes no) + for b.Controls[0].Op == OpS390XLOCGR { + v_0 := b.Controls[0] + d := auxToS390xCCMask(v_0.Aux) + cmp := v_0.Args[2] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpS390XMOVDconst || auxIntToInt64(v_0_0.AuxInt) != 0 { + break + } + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpS390XMOVDconst { + break + } + x := auxIntToInt64(v_0_1.AuxInt) + if auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.LessOrGreater || !(int32(x) != 0) { + break + } + b.resetWithControl(BlockS390XBRC, cmp) + b.Aux = s390xCCMaskToAux(d) + return true + } + // match: (CLIJ {c} (MOVWreg x) [y] yes no) + // result: (CLIJ {c} x [y] yes no) + for b.Controls[0].Op == OpS390XMOVWreg { + v_0 := b.Controls[0] + x := v_0.Args[0] + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + b.resetWithControl(BlockS390XCLIJ, x) + b.AuxInt = uint8ToAuxInt(y) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CLIJ {c} (MOVWZreg x) [y] yes no) + // result: (CLIJ {c} x [y] yes no) + for b.Controls[0].Op == OpS390XMOVWZreg { + v_0 := b.Controls[0] + x := v_0.Args[0] + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + b.resetWithControl(BlockS390XCLIJ, x) + b.AuxInt = uint8ToAuxInt(y) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CLIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Equal != 0 && uint32(x) == uint32(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Equal != 0 && uint32(x) == uint32(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CLIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Less != 0 && uint32(x) < uint32(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Less != 0 && uint32(x) < uint32(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CLIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Greater != 0 && uint32(x) > uint32(y) + // result: (First yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Greater != 0 && uint32(x) > uint32(y)) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CLIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Equal == 0 && uint32(x) == uint32(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Equal == 0 && uint32(x) == uint32(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CLIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Less == 0 && uint32(x) < uint32(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Less == 0 && uint32(x) < uint32(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CLIJ {c} (MOVDconst [x]) [y] yes no) + // cond: c&s390x.Greater == 0 && uint32(x) > uint32(y) + // result: (First no yes) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := auxIntToUint8(b.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(c&s390x.Greater == 0 && uint32(x) > uint32(y)) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + // match: (CLIJ {s390x.GreaterOrEqual} _ [0] yes no) + // result: (First yes no) + for { + if auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.GreaterOrEqual { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CLIJ {s390x.Less} _ [0] yes no) + // result: (First no yes) + for { + if auxIntToUint8(b.AuxInt) != 0 || auxToS390xCCMask(b.Aux) != s390x.Less { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockS390XCLRJ: + // match: (CLRJ {c} x (MOVDconst [y]) yes no) + // cond: isU8Bit(y) + // result: (CLIJ {c} x [uint8(y)] yes no) + for b.Controls[1].Op == OpS390XMOVDconst { + x := b.Controls[0] + v_1 := b.Controls[1] + y := auxIntToInt64(v_1.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(isU8Bit(y)) { + break + } + b.resetWithControl(BlockS390XCLIJ, x) + b.AuxInt = uint8ToAuxInt(uint8(y)) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CLRJ {c} (MOVDconst [x]) y yes no) + // cond: isU8Bit(x) + // result: (CLIJ {c.ReverseComparison()} y [uint8(x)] yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(isU8Bit(x)) { + break + } + b.resetWithControl(BlockS390XCLIJ, y) + b.AuxInt = uint8ToAuxInt(uint8(x)) + b.Aux = s390xCCMaskToAux(c.ReverseComparison()) + return true + } + // match: (CLRJ {c} x (MOVDconst [y]) yes no) + // cond: !isU8Bit(y) && isU32Bit(y) + // result: (BRC {c} (CMPWUconst x [int32(y)]) yes no) + for b.Controls[1].Op == OpS390XMOVDconst { + x := b.Controls[0] + v_1 := b.Controls[1] + y := auxIntToInt64(v_1.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(!isU8Bit(y) && isU32Bit(y)) { + break + } + v0 := b.NewValue0(x.Pos, OpS390XCMPWUconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(y)) + v0.AddArg(x) + b.resetWithControl(BlockS390XBRC, v0) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CLRJ {c} (MOVDconst [x]) y yes no) + // cond: !isU8Bit(x) && isU32Bit(x) + // result: (BRC {c.ReverseComparison()} (CMPWUconst y [int32(x)]) yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(!isU8Bit(x) && isU32Bit(x)) { + break + } + v0 := b.NewValue0(v_0.Pos, OpS390XCMPWUconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(x)) + v0.AddArg(y) + b.resetWithControl(BlockS390XBRC, v0) + b.Aux = s390xCCMaskToAux(c.ReverseComparison()) + return true + } + // match: (CLRJ {c} x y yes no) + // cond: x == y && c&s390x.Equal != 0 + // result: (First yes no) + for { + x := b.Controls[0] + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(x == y && c&s390x.Equal != 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CLRJ {c} x y yes no) + // cond: x == y && c&s390x.Equal == 0 + // result: (First no yes) + for { + x := b.Controls[0] + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(x == y && c&s390x.Equal == 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockS390XCRJ: + // match: (CRJ {c} x (MOVDconst [y]) yes no) + // cond: is8Bit(y) + // result: (CIJ {c} x [ int8(y)] yes no) + for b.Controls[1].Op == OpS390XMOVDconst { + x := b.Controls[0] + v_1 := b.Controls[1] + y := auxIntToInt64(v_1.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(is8Bit(y)) { + break + } + b.resetWithControl(BlockS390XCIJ, x) + b.AuxInt = int8ToAuxInt(int8(y)) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CRJ {c} (MOVDconst [x]) y yes no) + // cond: is8Bit(x) + // result: (CIJ {c.ReverseComparison()} y [ int8(x)] yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(is8Bit(x)) { + break + } + b.resetWithControl(BlockS390XCIJ, y) + b.AuxInt = int8ToAuxInt(int8(x)) + b.Aux = s390xCCMaskToAux(c.ReverseComparison()) + return true + } + // match: (CRJ {c} x (MOVDconst [y]) yes no) + // cond: !is8Bit(y) && is32Bit(y) + // result: (BRC {c} (CMPWconst x [int32(y)]) yes no) + for b.Controls[1].Op == OpS390XMOVDconst { + x := b.Controls[0] + v_1 := b.Controls[1] + y := auxIntToInt64(v_1.AuxInt) + c := auxToS390xCCMask(b.Aux) + if !(!is8Bit(y) && is32Bit(y)) { + break + } + v0 := b.NewValue0(x.Pos, OpS390XCMPWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(y)) + v0.AddArg(x) + b.resetWithControl(BlockS390XBRC, v0) + b.Aux = s390xCCMaskToAux(c) + return true + } + // match: (CRJ {c} (MOVDconst [x]) y yes no) + // cond: !is8Bit(x) && is32Bit(x) + // result: (BRC {c.ReverseComparison()} (CMPWconst y [int32(x)]) yes no) + for b.Controls[0].Op == OpS390XMOVDconst { + v_0 := b.Controls[0] + x := auxIntToInt64(v_0.AuxInt) + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(!is8Bit(x) && is32Bit(x)) { + break + } + v0 := b.NewValue0(v_0.Pos, OpS390XCMPWconst, types.TypeFlags) + v0.AuxInt = int32ToAuxInt(int32(x)) + v0.AddArg(y) + b.resetWithControl(BlockS390XBRC, v0) + b.Aux = s390xCCMaskToAux(c.ReverseComparison()) + return true + } + // match: (CRJ {c} x y yes no) + // cond: x == y && c&s390x.Equal != 0 + // result: (First yes no) + for { + x := b.Controls[0] + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(x == y && c&s390x.Equal != 0) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (CRJ {c} x y yes no) + // cond: x == y && c&s390x.Equal == 0 + // result: (First no yes) + for { + x := b.Controls[0] + y := b.Controls[1] + c := auxToS390xCCMask(b.Aux) + if !(x == y && c&s390x.Equal == 0) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + case BlockIf: + // match: (If cond yes no) + // result: (CLIJ {s390x.LessOrGreater} (MOVBZreg cond) [0] yes no) + for { + cond := b.Controls[0] + v0 := b.NewValue0(cond.Pos, OpS390XMOVBZreg, typ.Bool) + v0.AddArg(cond) + b.resetWithControl(BlockS390XCLIJ, v0) + b.AuxInt = uint8ToAuxInt(0) + b.Aux = s390xCCMaskToAux(s390x.LessOrGreater) + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewriteWasm.go b/go/src/cmd/compile/internal/ssa/rewriteWasm.go new file mode 100644 index 0000000000000000000000000000000000000000..faba41b3e5e16b41fb6f9368fc7026b8858c5156 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewriteWasm.go @@ -0,0 +1,5054 @@ +// Code generated from _gen/Wasm.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "math" +import "cmd/compile/internal/types" + +func rewriteValueWasm(v *Value) bool { + switch v.Op { + case OpAbs: + v.Op = OpWasmF64Abs + return true + case OpAdd16: + v.Op = OpWasmI64Add + return true + case OpAdd32: + v.Op = OpWasmI64Add + return true + case OpAdd32F: + v.Op = OpWasmF32Add + return true + case OpAdd64: + v.Op = OpWasmI64Add + return true + case OpAdd64F: + v.Op = OpWasmF64Add + return true + case OpAdd8: + v.Op = OpWasmI64Add + return true + case OpAddPtr: + v.Op = OpWasmI64Add + return true + case OpAddr: + return rewriteValueWasm_OpAddr(v) + case OpAnd16: + v.Op = OpWasmI64And + return true + case OpAnd32: + v.Op = OpWasmI64And + return true + case OpAnd64: + v.Op = OpWasmI64And + return true + case OpAnd8: + v.Op = OpWasmI64And + return true + case OpAndB: + v.Op = OpWasmI64And + return true + case OpAvg64u: + return rewriteValueWasm_OpAvg64u(v) + case OpBitLen16: + return rewriteValueWasm_OpBitLen16(v) + case OpBitLen32: + return rewriteValueWasm_OpBitLen32(v) + case OpBitLen64: + return rewriteValueWasm_OpBitLen64(v) + case OpBitLen8: + return rewriteValueWasm_OpBitLen8(v) + case OpCeil: + v.Op = OpWasmF64Ceil + return true + case OpClosureCall: + v.Op = OpWasmLoweredClosureCall + return true + case OpCom16: + return rewriteValueWasm_OpCom16(v) + case OpCom32: + return rewriteValueWasm_OpCom32(v) + case OpCom64: + return rewriteValueWasm_OpCom64(v) + case OpCom8: + return rewriteValueWasm_OpCom8(v) + case OpCondSelect: + v.Op = OpWasmSelect + return true + case OpConst16: + return rewriteValueWasm_OpConst16(v) + case OpConst32: + return rewriteValueWasm_OpConst32(v) + case OpConst32F: + v.Op = OpWasmF32Const + return true + case OpConst64: + v.Op = OpWasmI64Const + return true + case OpConst64F: + v.Op = OpWasmF64Const + return true + case OpConst8: + return rewriteValueWasm_OpConst8(v) + case OpConstBool: + return rewriteValueWasm_OpConstBool(v) + case OpConstNil: + return rewriteValueWasm_OpConstNil(v) + case OpConvert: + v.Op = OpWasmLoweredConvert + return true + case OpCopysign: + v.Op = OpWasmF64Copysign + return true + case OpCtz16: + return rewriteValueWasm_OpCtz16(v) + case OpCtz16NonZero: + v.Op = OpWasmI64Ctz + return true + case OpCtz32: + return rewriteValueWasm_OpCtz32(v) + case OpCtz32NonZero: + v.Op = OpWasmI64Ctz + return true + case OpCtz64: + v.Op = OpWasmI64Ctz + return true + case OpCtz64NonZero: + v.Op = OpWasmI64Ctz + return true + case OpCtz8: + return rewriteValueWasm_OpCtz8(v) + case OpCtz8NonZero: + v.Op = OpWasmI64Ctz + return true + case OpCvt32Fto32: + v.Op = OpWasmI64TruncSatF32S + return true + case OpCvt32Fto32U: + v.Op = OpWasmI64TruncSatF32U + return true + case OpCvt32Fto64: + v.Op = OpWasmI64TruncSatF32S + return true + case OpCvt32Fto64F: + v.Op = OpWasmF64PromoteF32 + return true + case OpCvt32Fto64U: + v.Op = OpWasmI64TruncSatF32U + return true + case OpCvt32Uto32F: + return rewriteValueWasm_OpCvt32Uto32F(v) + case OpCvt32Uto64F: + return rewriteValueWasm_OpCvt32Uto64F(v) + case OpCvt32to32F: + return rewriteValueWasm_OpCvt32to32F(v) + case OpCvt32to64F: + return rewriteValueWasm_OpCvt32to64F(v) + case OpCvt64Fto32: + v.Op = OpWasmI64TruncSatF64S + return true + case OpCvt64Fto32F: + v.Op = OpWasmF32DemoteF64 + return true + case OpCvt64Fto32U: + v.Op = OpWasmI64TruncSatF64U + return true + case OpCvt64Fto64: + v.Op = OpWasmI64TruncSatF64S + return true + case OpCvt64Fto64U: + v.Op = OpWasmI64TruncSatF64U + return true + case OpCvt64Uto32F: + v.Op = OpWasmF32ConvertI64U + return true + case OpCvt64Uto64F: + v.Op = OpWasmF64ConvertI64U + return true + case OpCvt64to32F: + v.Op = OpWasmF32ConvertI64S + return true + case OpCvt64to64F: + v.Op = OpWasmF64ConvertI64S + return true + case OpCvtBoolToUint8: + v.Op = OpCopy + return true + case OpDiv16: + return rewriteValueWasm_OpDiv16(v) + case OpDiv16u: + return rewriteValueWasm_OpDiv16u(v) + case OpDiv32: + return rewriteValueWasm_OpDiv32(v) + case OpDiv32F: + v.Op = OpWasmF32Div + return true + case OpDiv32u: + return rewriteValueWasm_OpDiv32u(v) + case OpDiv64: + return rewriteValueWasm_OpDiv64(v) + case OpDiv64F: + v.Op = OpWasmF64Div + return true + case OpDiv64u: + v.Op = OpWasmI64DivU + return true + case OpDiv8: + return rewriteValueWasm_OpDiv8(v) + case OpDiv8u: + return rewriteValueWasm_OpDiv8u(v) + case OpEq16: + return rewriteValueWasm_OpEq16(v) + case OpEq32: + return rewriteValueWasm_OpEq32(v) + case OpEq32F: + v.Op = OpWasmF32Eq + return true + case OpEq64: + v.Op = OpWasmI64Eq + return true + case OpEq64F: + v.Op = OpWasmF64Eq + return true + case OpEq8: + return rewriteValueWasm_OpEq8(v) + case OpEqB: + v.Op = OpWasmI64Eq + return true + case OpEqPtr: + v.Op = OpWasmI64Eq + return true + case OpFloor: + v.Op = OpWasmF64Floor + return true + case OpGetCallerPC: + v.Op = OpWasmLoweredGetCallerPC + return true + case OpGetCallerSP: + v.Op = OpWasmLoweredGetCallerSP + return true + case OpGetClosurePtr: + v.Op = OpWasmLoweredGetClosurePtr + return true + case OpHmul64: + return rewriteValueWasm_OpHmul64(v) + case OpHmul64u: + return rewriteValueWasm_OpHmul64u(v) + case OpInterCall: + v.Op = OpWasmLoweredInterCall + return true + case OpIsInBounds: + v.Op = OpWasmI64LtU + return true + case OpIsNonNil: + return rewriteValueWasm_OpIsNonNil(v) + case OpIsSliceInBounds: + v.Op = OpWasmI64LeU + return true + case OpLast: + return rewriteValueWasm_OpLast(v) + case OpLeq16: + return rewriteValueWasm_OpLeq16(v) + case OpLeq16U: + return rewriteValueWasm_OpLeq16U(v) + case OpLeq32: + return rewriteValueWasm_OpLeq32(v) + case OpLeq32F: + v.Op = OpWasmF32Le + return true + case OpLeq32U: + return rewriteValueWasm_OpLeq32U(v) + case OpLeq64: + v.Op = OpWasmI64LeS + return true + case OpLeq64F: + v.Op = OpWasmF64Le + return true + case OpLeq64U: + v.Op = OpWasmI64LeU + return true + case OpLeq8: + return rewriteValueWasm_OpLeq8(v) + case OpLeq8U: + return rewriteValueWasm_OpLeq8U(v) + case OpLess16: + return rewriteValueWasm_OpLess16(v) + case OpLess16U: + return rewriteValueWasm_OpLess16U(v) + case OpLess32: + return rewriteValueWasm_OpLess32(v) + case OpLess32F: + v.Op = OpWasmF32Lt + return true + case OpLess32U: + return rewriteValueWasm_OpLess32U(v) + case OpLess64: + v.Op = OpWasmI64LtS + return true + case OpLess64F: + v.Op = OpWasmF64Lt + return true + case OpLess64U: + v.Op = OpWasmI64LtU + return true + case OpLess8: + return rewriteValueWasm_OpLess8(v) + case OpLess8U: + return rewriteValueWasm_OpLess8U(v) + case OpLoad: + return rewriteValueWasm_OpLoad(v) + case OpLocalAddr: + return rewriteValueWasm_OpLocalAddr(v) + case OpLsh16x16: + return rewriteValueWasm_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValueWasm_OpLsh16x32(v) + case OpLsh16x64: + v.Op = OpLsh64x64 + return true + case OpLsh16x8: + return rewriteValueWasm_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValueWasm_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValueWasm_OpLsh32x32(v) + case OpLsh32x64: + v.Op = OpLsh64x64 + return true + case OpLsh32x8: + return rewriteValueWasm_OpLsh32x8(v) + case OpLsh64x16: + return rewriteValueWasm_OpLsh64x16(v) + case OpLsh64x32: + return rewriteValueWasm_OpLsh64x32(v) + case OpLsh64x64: + return rewriteValueWasm_OpLsh64x64(v) + case OpLsh64x8: + return rewriteValueWasm_OpLsh64x8(v) + case OpLsh8x16: + return rewriteValueWasm_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValueWasm_OpLsh8x32(v) + case OpLsh8x64: + v.Op = OpLsh64x64 + return true + case OpLsh8x8: + return rewriteValueWasm_OpLsh8x8(v) + case OpMod16: + return rewriteValueWasm_OpMod16(v) + case OpMod16u: + return rewriteValueWasm_OpMod16u(v) + case OpMod32: + return rewriteValueWasm_OpMod32(v) + case OpMod32u: + return rewriteValueWasm_OpMod32u(v) + case OpMod64: + return rewriteValueWasm_OpMod64(v) + case OpMod64u: + v.Op = OpWasmI64RemU + return true + case OpMod8: + return rewriteValueWasm_OpMod8(v) + case OpMod8u: + return rewriteValueWasm_OpMod8u(v) + case OpMove: + return rewriteValueWasm_OpMove(v) + case OpMul16: + v.Op = OpWasmI64Mul + return true + case OpMul32: + v.Op = OpWasmI64Mul + return true + case OpMul32F: + v.Op = OpWasmF32Mul + return true + case OpMul64: + v.Op = OpWasmI64Mul + return true + case OpMul64F: + v.Op = OpWasmF64Mul + return true + case OpMul8: + v.Op = OpWasmI64Mul + return true + case OpNeg16: + return rewriteValueWasm_OpNeg16(v) + case OpNeg32: + return rewriteValueWasm_OpNeg32(v) + case OpNeg32F: + v.Op = OpWasmF32Neg + return true + case OpNeg64: + return rewriteValueWasm_OpNeg64(v) + case OpNeg64F: + v.Op = OpWasmF64Neg + return true + case OpNeg8: + return rewriteValueWasm_OpNeg8(v) + case OpNeq16: + return rewriteValueWasm_OpNeq16(v) + case OpNeq32: + return rewriteValueWasm_OpNeq32(v) + case OpNeq32F: + v.Op = OpWasmF32Ne + return true + case OpNeq64: + v.Op = OpWasmI64Ne + return true + case OpNeq64F: + v.Op = OpWasmF64Ne + return true + case OpNeq8: + return rewriteValueWasm_OpNeq8(v) + case OpNeqB: + v.Op = OpWasmI64Ne + return true + case OpNeqPtr: + v.Op = OpWasmI64Ne + return true + case OpNilCheck: + v.Op = OpWasmLoweredNilCheck + return true + case OpNot: + v.Op = OpWasmI64Eqz + return true + case OpOffPtr: + v.Op = OpWasmI64AddConst + return true + case OpOr16: + v.Op = OpWasmI64Or + return true + case OpOr32: + v.Op = OpWasmI64Or + return true + case OpOr64: + v.Op = OpWasmI64Or + return true + case OpOr8: + v.Op = OpWasmI64Or + return true + case OpOrB: + v.Op = OpWasmI64Or + return true + case OpPopCount16: + return rewriteValueWasm_OpPopCount16(v) + case OpPopCount32: + return rewriteValueWasm_OpPopCount32(v) + case OpPopCount64: + v.Op = OpWasmI64Popcnt + return true + case OpPopCount8: + return rewriteValueWasm_OpPopCount8(v) + case OpRotateLeft16: + return rewriteValueWasm_OpRotateLeft16(v) + case OpRotateLeft32: + v.Op = OpWasmI32Rotl + return true + case OpRotateLeft64: + v.Op = OpWasmI64Rotl + return true + case OpRotateLeft8: + return rewriteValueWasm_OpRotateLeft8(v) + case OpRound32F: + v.Op = OpCopy + return true + case OpRound64F: + v.Op = OpCopy + return true + case OpRoundToEven: + v.Op = OpWasmF64Nearest + return true + case OpRsh16Ux16: + return rewriteValueWasm_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValueWasm_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValueWasm_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValueWasm_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValueWasm_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValueWasm_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValueWasm_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValueWasm_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValueWasm_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValueWasm_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValueWasm_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValueWasm_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValueWasm_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValueWasm_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValueWasm_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValueWasm_OpRsh32x8(v) + case OpRsh64Ux16: + return rewriteValueWasm_OpRsh64Ux16(v) + case OpRsh64Ux32: + return rewriteValueWasm_OpRsh64Ux32(v) + case OpRsh64Ux64: + return rewriteValueWasm_OpRsh64Ux64(v) + case OpRsh64Ux8: + return rewriteValueWasm_OpRsh64Ux8(v) + case OpRsh64x16: + return rewriteValueWasm_OpRsh64x16(v) + case OpRsh64x32: + return rewriteValueWasm_OpRsh64x32(v) + case OpRsh64x64: + return rewriteValueWasm_OpRsh64x64(v) + case OpRsh64x8: + return rewriteValueWasm_OpRsh64x8(v) + case OpRsh8Ux16: + return rewriteValueWasm_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValueWasm_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValueWasm_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValueWasm_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValueWasm_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValueWasm_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValueWasm_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValueWasm_OpRsh8x8(v) + case OpSelect0: + return rewriteValueWasm_OpSelect0(v) + case OpSelect1: + return rewriteValueWasm_OpSelect1(v) + case OpSignExt16to32: + return rewriteValueWasm_OpSignExt16to32(v) + case OpSignExt16to64: + return rewriteValueWasm_OpSignExt16to64(v) + case OpSignExt32to64: + return rewriteValueWasm_OpSignExt32to64(v) + case OpSignExt8to16: + return rewriteValueWasm_OpSignExt8to16(v) + case OpSignExt8to32: + return rewriteValueWasm_OpSignExt8to32(v) + case OpSignExt8to64: + return rewriteValueWasm_OpSignExt8to64(v) + case OpSlicemask: + return rewriteValueWasm_OpSlicemask(v) + case OpSqrt: + v.Op = OpWasmF64Sqrt + return true + case OpSqrt32: + v.Op = OpWasmF32Sqrt + return true + case OpStaticCall: + v.Op = OpWasmLoweredStaticCall + return true + case OpStore: + return rewriteValueWasm_OpStore(v) + case OpSub16: + v.Op = OpWasmI64Sub + return true + case OpSub32: + v.Op = OpWasmI64Sub + return true + case OpSub32F: + v.Op = OpWasmF32Sub + return true + case OpSub64: + v.Op = OpWasmI64Sub + return true + case OpSub64F: + v.Op = OpWasmF64Sub + return true + case OpSub8: + v.Op = OpWasmI64Sub + return true + case OpSubPtr: + v.Op = OpWasmI64Sub + return true + case OpTailCall: + v.Op = OpWasmLoweredTailCall + return true + case OpTrunc: + v.Op = OpWasmF64Trunc + return true + case OpTrunc16to8: + v.Op = OpCopy + return true + case OpTrunc32to16: + v.Op = OpCopy + return true + case OpTrunc32to8: + v.Op = OpCopy + return true + case OpTrunc64to16: + v.Op = OpCopy + return true + case OpTrunc64to32: + v.Op = OpCopy + return true + case OpTrunc64to8: + v.Op = OpCopy + return true + case OpWB: + v.Op = OpWasmLoweredWB + return true + case OpWasmF64Add: + return rewriteValueWasm_OpWasmF64Add(v) + case OpWasmF64Mul: + return rewriteValueWasm_OpWasmF64Mul(v) + case OpWasmI64Add: + return rewriteValueWasm_OpWasmI64Add(v) + case OpWasmI64AddConst: + return rewriteValueWasm_OpWasmI64AddConst(v) + case OpWasmI64And: + return rewriteValueWasm_OpWasmI64And(v) + case OpWasmI64Eq: + return rewriteValueWasm_OpWasmI64Eq(v) + case OpWasmI64Eqz: + return rewriteValueWasm_OpWasmI64Eqz(v) + case OpWasmI64LeU: + return rewriteValueWasm_OpWasmI64LeU(v) + case OpWasmI64Load: + return rewriteValueWasm_OpWasmI64Load(v) + case OpWasmI64Load16S: + return rewriteValueWasm_OpWasmI64Load16S(v) + case OpWasmI64Load16U: + return rewriteValueWasm_OpWasmI64Load16U(v) + case OpWasmI64Load32S: + return rewriteValueWasm_OpWasmI64Load32S(v) + case OpWasmI64Load32U: + return rewriteValueWasm_OpWasmI64Load32U(v) + case OpWasmI64Load8S: + return rewriteValueWasm_OpWasmI64Load8S(v) + case OpWasmI64Load8U: + return rewriteValueWasm_OpWasmI64Load8U(v) + case OpWasmI64LtU: + return rewriteValueWasm_OpWasmI64LtU(v) + case OpWasmI64Mul: + return rewriteValueWasm_OpWasmI64Mul(v) + case OpWasmI64Ne: + return rewriteValueWasm_OpWasmI64Ne(v) + case OpWasmI64Or: + return rewriteValueWasm_OpWasmI64Or(v) + case OpWasmI64Shl: + return rewriteValueWasm_OpWasmI64Shl(v) + case OpWasmI64ShrS: + return rewriteValueWasm_OpWasmI64ShrS(v) + case OpWasmI64ShrU: + return rewriteValueWasm_OpWasmI64ShrU(v) + case OpWasmI64Store: + return rewriteValueWasm_OpWasmI64Store(v) + case OpWasmI64Store16: + return rewriteValueWasm_OpWasmI64Store16(v) + case OpWasmI64Store32: + return rewriteValueWasm_OpWasmI64Store32(v) + case OpWasmI64Store8: + return rewriteValueWasm_OpWasmI64Store8(v) + case OpWasmI64Xor: + return rewriteValueWasm_OpWasmI64Xor(v) + case OpXor16: + v.Op = OpWasmI64Xor + return true + case OpXor32: + v.Op = OpWasmI64Xor + return true + case OpXor64: + v.Op = OpWasmI64Xor + return true + case OpXor8: + v.Op = OpWasmI64Xor + return true + case OpZero: + return rewriteValueWasm_OpZero(v) + case OpZeroExt16to32: + return rewriteValueWasm_OpZeroExt16to32(v) + case OpZeroExt16to64: + return rewriteValueWasm_OpZeroExt16to64(v) + case OpZeroExt32to64: + return rewriteValueWasm_OpZeroExt32to64(v) + case OpZeroExt8to16: + return rewriteValueWasm_OpZeroExt8to16(v) + case OpZeroExt8to32: + return rewriteValueWasm_OpZeroExt8to32(v) + case OpZeroExt8to64: + return rewriteValueWasm_OpZeroExt8to64(v) + } + return false +} +func rewriteValueWasm_OpAddr(v *Value) bool { + v_0 := v.Args[0] + // match: (Addr {sym} base) + // result: (LoweredAddr {sym} [0] base) + for { + sym := auxToSym(v.Aux) + base := v_0 + v.reset(OpWasmLoweredAddr) + v.AuxInt = int32ToAuxInt(0) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } +} +func rewriteValueWasm_OpAvg64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Avg64u x y) + // result: (I64Add (I64ShrU (I64Sub x y) (I64Const [1])) y) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64Add) + v0 := b.NewValue0(v.Pos, OpWasmI64ShrU, typ.Int64) + v1 := b.NewValue0(v.Pos, OpWasmI64Sub, typ.Int64) + v1.AddArg2(x, y) + v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v2.AuxInt = int64ToAuxInt(1) + v0.AddArg2(v1, v2) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueWasm_OpBitLen16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen16 x) + // result: (BitLen64 (ZeroExt16to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpBitLen32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen32 x) + // result: (BitLen64 (ZeroExt32to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpBitLen64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen64 x) + // result: (I64Sub (I64Const [64]) (I64Clz x)) + for { + x := v_0 + v.reset(OpWasmI64Sub) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(64) + v1 := b.NewValue0(v.Pos, OpWasmI64Clz, typ.Int64) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpBitLen8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen8 x) + // result: (BitLen64 (ZeroExt8to64 x)) + for { + x := v_0 + v.reset(OpBitLen64) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpCom16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com16 x) + // result: (I64Xor x (I64Const [-1])) + for { + x := v_0 + v.reset(OpWasmI64Xor) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(-1) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpCom32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com32 x) + // result: (I64Xor x (I64Const [-1])) + for { + x := v_0 + v.reset(OpWasmI64Xor) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(-1) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpCom64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com64 x) + // result: (I64Xor x (I64Const [-1])) + for { + x := v_0 + v.reset(OpWasmI64Xor) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(-1) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpCom8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com8 x) + // result: (I64Xor x (I64Const [-1])) + for { + x := v_0 + v.reset(OpWasmI64Xor) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(-1) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpConst16(v *Value) bool { + // match: (Const16 [c]) + // result: (I64Const [int64(c)]) + for { + c := auxIntToInt16(v.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(c)) + return true + } +} +func rewriteValueWasm_OpConst32(v *Value) bool { + // match: (Const32 [c]) + // result: (I64Const [int64(c)]) + for { + c := auxIntToInt32(v.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(c)) + return true + } +} +func rewriteValueWasm_OpConst8(v *Value) bool { + // match: (Const8 [c]) + // result: (I64Const [int64(c)]) + for { + c := auxIntToInt8(v.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(c)) + return true + } +} +func rewriteValueWasm_OpConstBool(v *Value) bool { + // match: (ConstBool [c]) + // result: (I64Const [b2i(c)]) + for { + c := auxIntToBool(v.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(b2i(c)) + return true + } +} +func rewriteValueWasm_OpConstNil(v *Value) bool { + // match: (ConstNil) + // result: (I64Const [0]) + for { + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(0) + return true + } +} +func rewriteValueWasm_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz16 x) + // result: (I64Ctz (I64Or x (I64Const [0x10000]))) + for { + x := v_0 + v.reset(OpWasmI64Ctz) + v0 := b.NewValue0(v.Pos, OpWasmI64Or, typ.Int64) + v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v1.AuxInt = int64ToAuxInt(0x10000) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpCtz32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz32 x) + // result: (I64Ctz (I64Or x (I64Const [0x100000000]))) + for { + x := v_0 + v.reset(OpWasmI64Ctz) + v0 := b.NewValue0(v.Pos, OpWasmI64Or, typ.Int64) + v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v1.AuxInt = int64ToAuxInt(0x100000000) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz8 x) + // result: (I64Ctz (I64Or x (I64Const [0x100]))) + for { + x := v_0 + v.reset(OpWasmI64Ctz) + v0 := b.NewValue0(v.Pos, OpWasmI64Or, typ.Int64) + v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v1.AuxInt = int64ToAuxInt(0x100) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpCvt32Uto32F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt32Uto32F x) + // result: (F32ConvertI64U (ZeroExt32to64 x)) + for { + x := v_0 + v.reset(OpWasmF32ConvertI64U) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpCvt32Uto64F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt32Uto64F x) + // result: (F64ConvertI64U (ZeroExt32to64 x)) + for { + x := v_0 + v.reset(OpWasmF64ConvertI64U) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpCvt32to32F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt32to32F x) + // result: (F32ConvertI64S (SignExt32to64 x)) + for { + x := v_0 + v.reset(OpWasmF32ConvertI64S) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpCvt32to64F(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Cvt32to64F x) + // result: (F64ConvertI64S (SignExt32to64 x)) + for { + x := v_0 + v.reset(OpWasmF64ConvertI64S) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 [false] x y) + // result: (I64DivS (SignExt16to64 x) (SignExt16to64 y)) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpWasmI64DivS) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueWasm_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u x y) + // result: (I64DivU (ZeroExt16to64 x) (ZeroExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64DivU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32 [false] x y) + // result: (I64DivS (SignExt32to64 x) (SignExt32to64 y)) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpWasmI64DivS) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueWasm_OpDiv32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32u x y) + // result: (I64DivU (ZeroExt32to64 x) (ZeroExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64DivU) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpDiv64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Div64 [false] x y) + // result: (I64DivS x y) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpWasmI64DivS) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueWasm_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 x y) + // result: (I64DivS (SignExt8to64 x) (SignExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64DivS) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x y) + // result: (I64DivU (ZeroExt8to64 x) (ZeroExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64DivU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq16 x y) + // result: (I64Eq (ZeroExt16to64 x) (ZeroExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64Eq) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq32 x y) + // result: (I64Eq (ZeroExt32to64 x) (ZeroExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64Eq) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq8 x y) + // result: (I64Eq (ZeroExt8to64 x) (ZeroExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64Eq) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpHmul64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul64 x y) + // result: (Last x0: (ZeroExt32to64 x) x1: (I64ShrS x (I64Const [32])) y0: (ZeroExt32to64 y) y1: (I64ShrS y (I64Const [32])) x0y0: (I64Mul x0 y0) tt: (I64Add (I64Mul x1 y0) (I64ShrU x0y0 (I64Const [32]))) w1: (I64Add (I64Mul x0 y1) (ZeroExt32to64 tt)) w2: (I64ShrS tt (I64Const [32])) (I64Add (I64Add (I64Mul x1 y1) w2) (I64ShrS w1 (I64Const [32])))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpLast) + v.Type = t + x0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + x0.AddArg(x) + x1 := b.NewValue0(v.Pos, OpWasmI64ShrS, typ.Int64) + v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v2.AuxInt = int64ToAuxInt(32) + x1.AddArg2(x, v2) + y0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + y0.AddArg(y) + y1 := b.NewValue0(v.Pos, OpWasmI64ShrS, typ.Int64) + y1.AddArg2(y, v2) + x0y0 := b.NewValue0(v.Pos, OpWasmI64Mul, typ.Int64) + x0y0.AddArg2(x0, y0) + tt := b.NewValue0(v.Pos, OpWasmI64Add, typ.Int64) + v7 := b.NewValue0(v.Pos, OpWasmI64Mul, typ.Int64) + v7.AddArg2(x1, y0) + v8 := b.NewValue0(v.Pos, OpWasmI64ShrU, typ.Int64) + v8.AddArg2(x0y0, v2) + tt.AddArg2(v7, v8) + w1 := b.NewValue0(v.Pos, OpWasmI64Add, typ.Int64) + v10 := b.NewValue0(v.Pos, OpWasmI64Mul, typ.Int64) + v10.AddArg2(x0, y1) + v11 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v11.AddArg(tt) + w1.AddArg2(v10, v11) + w2 := b.NewValue0(v.Pos, OpWasmI64ShrS, typ.Int64) + w2.AddArg2(tt, v2) + v13 := b.NewValue0(v.Pos, OpWasmI64Add, typ.Int64) + v14 := b.NewValue0(v.Pos, OpWasmI64Add, typ.Int64) + v15 := b.NewValue0(v.Pos, OpWasmI64Mul, typ.Int64) + v15.AddArg2(x1, y1) + v14.AddArg2(v15, w2) + v16 := b.NewValue0(v.Pos, OpWasmI64ShrS, typ.Int64) + v16.AddArg2(w1, v2) + v13.AddArg2(v14, v16) + v.AddArgs(x0, x1, y0, y1, x0y0, tt, w1, w2, v13) + return true + } +} +func rewriteValueWasm_OpHmul64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul64u x y) + // result: (Last x0: (ZeroExt32to64 x) x1: (I64ShrU x (I64Const [32])) y0: (ZeroExt32to64 y) y1: (I64ShrU y (I64Const [32])) w0: (I64Mul x0 y0) tt: (I64Add (I64Mul x1 y0) (I64ShrU w0 (I64Const [32]))) w1: (I64Add (I64Mul x0 y1) (ZeroExt32to64 tt)) w2: (I64ShrU tt (I64Const [32])) hi: (I64Add (I64Add (I64Mul x1 y1) w2) (I64ShrU w1 (I64Const [32])))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpLast) + v.Type = t + x0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + x0.AddArg(x) + x1 := b.NewValue0(v.Pos, OpWasmI64ShrU, typ.Int64) + v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v2.AuxInt = int64ToAuxInt(32) + x1.AddArg2(x, v2) + y0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + y0.AddArg(y) + y1 := b.NewValue0(v.Pos, OpWasmI64ShrU, typ.Int64) + y1.AddArg2(y, v2) + w0 := b.NewValue0(v.Pos, OpWasmI64Mul, typ.Int64) + w0.AddArg2(x0, y0) + tt := b.NewValue0(v.Pos, OpWasmI64Add, typ.Int64) + v7 := b.NewValue0(v.Pos, OpWasmI64Mul, typ.Int64) + v7.AddArg2(x1, y0) + v8 := b.NewValue0(v.Pos, OpWasmI64ShrU, typ.Int64) + v8.AddArg2(w0, v2) + tt.AddArg2(v7, v8) + w1 := b.NewValue0(v.Pos, OpWasmI64Add, typ.Int64) + v10 := b.NewValue0(v.Pos, OpWasmI64Mul, typ.Int64) + v10.AddArg2(x0, y1) + v11 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v11.AddArg(tt) + w1.AddArg2(v10, v11) + w2 := b.NewValue0(v.Pos, OpWasmI64ShrU, typ.Int64) + w2.AddArg2(tt, v2) + hi := b.NewValue0(v.Pos, OpWasmI64Add, typ.Int64) + v14 := b.NewValue0(v.Pos, OpWasmI64Add, typ.Int64) + v15 := b.NewValue0(v.Pos, OpWasmI64Mul, typ.Int64) + v15.AddArg2(x1, y1) + v14.AddArg2(v15, w2) + v16 := b.NewValue0(v.Pos, OpWasmI64ShrU, typ.Int64) + v16.AddArg2(w1, v2) + hi.AddArg2(v14, v16) + v.AddArgs(x0, x1, y0, y1, w0, tt, w1, w2, hi) + return true + } +} +func rewriteValueWasm_OpIsNonNil(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (IsNonNil p) + // result: (I64Eqz (I64Eqz p)) + for { + p := v_0 + v.reset(OpWasmI64Eqz) + v0 := b.NewValue0(v.Pos, OpWasmI64Eqz, typ.Bool) + v0.AddArg(p) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpLast(v *Value) bool { + // match: (Last ___) + // result: v.Args[len(v.Args)-1] + for { + v.copyOf(v.Args[len(v.Args)-1]) + return true + } +} +func rewriteValueWasm_OpLeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16 x y) + // result: (I64LeS (SignExt16to64 x) (SignExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LeS) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq16U x y) + // result: (I64LeU (ZeroExt16to64 x) (ZeroExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LeU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32 x y) + // result: (I64LeS (SignExt32to64 x) (SignExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LeS) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq32U x y) + // result: (I64LeU (ZeroExt32to64 x) (ZeroExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LeU) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8 x y) + // result: (I64LeS (SignExt8to64 x) (SignExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LeS) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq8U x y) + // result: (I64LeU (ZeroExt8to64 x) (ZeroExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LeU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16 x y) + // result: (I64LtS (SignExt16to64 x) (SignExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LtS) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less16U x y) + // result: (I64LtU (ZeroExt16to64 x) (ZeroExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LtU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32 x y) + // result: (I64LtS (SignExt32to64 x) (SignExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LtS) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less32U x y) + // result: (I64LtU (ZeroExt32to64 x) (ZeroExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LtU) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8 x y) + // result: (I64LtS (SignExt8to64 x) (SignExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LtS) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less8U x y) + // result: (I64LtU (ZeroExt8to64 x) (ZeroExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64LtU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Load ptr mem) + // cond: is32BitFloat(t) + // result: (F32Load ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is32BitFloat(t)) { + break + } + v.reset(OpWasmF32Load) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: is64BitFloat(t) + // result: (F64Load ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitFloat(t)) { + break + } + v.reset(OpWasmF64Load) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.Size() == 8 + // result: (I64Load ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.Size() == 8) { + break + } + v.reset(OpWasmI64Load) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.Size() == 4 && !t.IsSigned() + // result: (I64Load32U ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.Size() == 4 && !t.IsSigned()) { + break + } + v.reset(OpWasmI64Load32U) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.Size() == 4 && t.IsSigned() + // result: (I64Load32S ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.Size() == 4 && t.IsSigned()) { + break + } + v.reset(OpWasmI64Load32S) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.Size() == 2 && !t.IsSigned() + // result: (I64Load16U ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.Size() == 2 && !t.IsSigned()) { + break + } + v.reset(OpWasmI64Load16U) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.Size() == 2 && t.IsSigned() + // result: (I64Load16S ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.Size() == 2 && t.IsSigned()) { + break + } + v.reset(OpWasmI64Load16S) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.Size() == 1 && !t.IsSigned() + // result: (I64Load8U ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.Size() == 1 && !t.IsSigned()) { + break + } + v.reset(OpWasmI64Load8U) + v.AddArg2(ptr, mem) + return true + } + // match: (Load ptr mem) + // cond: t.Size() == 1 && t.IsSigned() + // result: (I64Load8S ptr mem) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.Size() == 1 && t.IsSigned()) { + break + } + v.reset(OpWasmI64Load8S) + v.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValueWasm_OpLocalAddr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (LocalAddr {sym} base mem) + // cond: t.Elem().HasPointers() + // result: (LoweredAddr {sym} (SPanchored base mem)) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + mem := v_1 + if !(t.Elem().HasPointers()) { + break + } + v.reset(OpWasmLoweredAddr) + v.Aux = symToAux(sym) + v0 := b.NewValue0(v.Pos, OpSPanchored, typ.Uintptr) + v0.AddArg2(base, mem) + v.AddArg(v0) + return true + } + // match: (LocalAddr {sym} base _) + // cond: !t.Elem().HasPointers() + // result: (LoweredAddr {sym} base) + for { + t := v.Type + sym := auxToSym(v.Aux) + base := v_0 + if !(!t.Elem().HasPointers()) { + break + } + v.reset(OpWasmLoweredAddr) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + return false +} +func rewriteValueWasm_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x16 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x32 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x8 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x16 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x32 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x8 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x16 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x32 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (I64Shl x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpWasmI64Shl) + v.AddArg2(x, y) + return true + } + // match: (Lsh64x64 x (I64Const [c])) + // cond: uint64(c) < 64 + // result: (I64Shl x (I64Const [c])) + for { + x := v_0 + if v_1.Op != OpWasmI64Const { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 64) { + break + } + v.reset(OpWasmI64Shl) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + // match: (Lsh64x64 x (I64Const [c])) + // cond: uint64(c) >= 64 + // result: (I64Const [0]) + for { + if v_1.Op != OpWasmI64Const { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Lsh64x64 x y) + // result: (Select (I64Shl x y) (I64Const [0]) (I64LtU y (I64Const [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpWasmSelect) + v0 := b.NewValue0(v.Pos, OpWasmI64Shl, typ.Int64) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpWasmI64LtU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(y, v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueWasm_OpLsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x8 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x16 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x32 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpLsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x8 [c] x y) + // result: (Lsh64x64 [c] x (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpLsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16 [false] x y) + // result: (I64RemS (SignExt16to64 x) (SignExt16to64 y)) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpWasmI64RemS) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueWasm_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod16u x y) + // result: (I64RemU (ZeroExt16to64 x) (ZeroExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64RemU) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32 [false] x y) + // result: (I64RemS (SignExt32to64 x) (SignExt32to64 y)) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpWasmI64RemS) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValueWasm_OpMod32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod32u x y) + // result: (I64RemU (ZeroExt32to64 x) (ZeroExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64RemU) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpMod64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Mod64 [false] x y) + // result: (I64RemS x y) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + y := v_1 + v.reset(OpWasmI64RemS) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueWasm_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8 x y) + // result: (I64RemS (SignExt8to64 x) (SignExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64RemS) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mod8u x y) + // result: (I64RemU (ZeroExt8to64 x) (ZeroExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64RemU) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Move [0] _ _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Move [1] dst src mem) + // result: (I64Store8 dst (I64Load8U src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpWasmI64Store8) + v0 := b.NewValue0(v.Pos, OpWasmI64Load8U, typ.UInt8) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [2] dst src mem) + // result: (I64Store16 dst (I64Load16U src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpWasmI64Store16) + v0 := b.NewValue0(v.Pos, OpWasmI64Load16U, typ.UInt16) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [4] dst src mem) + // result: (I64Store32 dst (I64Load32U src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpWasmI64Store32) + v0 := b.NewValue0(v.Pos, OpWasmI64Load32U, typ.UInt32) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [8] dst src mem) + // result: (I64Store dst (I64Load src mem) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpWasmI64Store) + v0 := b.NewValue0(v.Pos, OpWasmI64Load, typ.UInt64) + v0.AddArg2(src, mem) + v.AddArg3(dst, v0, mem) + return true + } + // match: (Move [16] dst src mem) + // result: (I64Store [8] dst (I64Load [8] src mem) (I64Store dst (I64Load src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpWasmI64Store) + v.AuxInt = int64ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpWasmI64Load, typ.UInt64) + v0.AuxInt = int64ToAuxInt(8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpWasmI64Load, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [3] dst src mem) + // result: (I64Store8 [2] dst (I64Load8U [2] src mem) (I64Store16 dst (I64Load16U src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpWasmI64Store8) + v.AuxInt = int64ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpWasmI64Load8U, typ.UInt8) + v0.AuxInt = int64ToAuxInt(2) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpWasmI64Store16, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpWasmI64Load16U, typ.UInt16) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [5] dst src mem) + // result: (I64Store8 [4] dst (I64Load8U [4] src mem) (I64Store32 dst (I64Load32U src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpWasmI64Store8) + v.AuxInt = int64ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpWasmI64Load8U, typ.UInt8) + v0.AuxInt = int64ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpWasmI64Store32, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpWasmI64Load32U, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [6] dst src mem) + // result: (I64Store16 [4] dst (I64Load16U [4] src mem) (I64Store32 dst (I64Load32U src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpWasmI64Store16) + v.AuxInt = int64ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpWasmI64Load16U, typ.UInt16) + v0.AuxInt = int64ToAuxInt(4) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpWasmI64Store32, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpWasmI64Load32U, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [7] dst src mem) + // result: (I64Store32 [3] dst (I64Load32U [3] src mem) (I64Store32 dst (I64Load32U src mem) mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + dst := v_0 + src := v_1 + mem := v_2 + v.reset(OpWasmI64Store32) + v.AuxInt = int64ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpWasmI64Load32U, typ.UInt32) + v0.AuxInt = int64ToAuxInt(3) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpWasmI64Store32, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpWasmI64Load32U, typ.UInt32) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: s > 8 && s < 16 + // result: (I64Store [s-8] dst (I64Load [s-8] src mem) (I64Store dst (I64Load src mem) mem)) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(s > 8 && s < 16) { + break + } + v.reset(OpWasmI64Store) + v.AuxInt = int64ToAuxInt(s - 8) + v0 := b.NewValue0(v.Pos, OpWasmI64Load, typ.UInt64) + v0.AuxInt = int64ToAuxInt(s - 8) + v0.AddArg2(src, mem) + v1 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpWasmI64Load, typ.UInt64) + v2.AddArg2(src, mem) + v1.AddArg3(dst, v2, mem) + v.AddArg3(dst, v0, v1) + return true + } + // match: (Move [s] dst src mem) + // cond: logLargeCopy(v, s) + // result: (LoweredMove [s] dst src mem) + for { + s := auxIntToInt64(v.AuxInt) + dst := v_0 + src := v_1 + mem := v_2 + if !(logLargeCopy(v, s)) { + break + } + v.reset(OpWasmLoweredMove) + v.AuxInt = int64ToAuxInt(s) + v.AddArg3(dst, src, mem) + return true + } + return false +} +func rewriteValueWasm_OpNeg16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neg16 x) + // result: (I64Sub (I64Const [0]) x) + for { + x := v_0 + v.reset(OpWasmI64Sub) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueWasm_OpNeg32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neg32 x) + // result: (I64Sub (I64Const [0]) x) + for { + x := v_0 + v.reset(OpWasmI64Sub) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueWasm_OpNeg64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neg64 x) + // result: (I64Sub (I64Const [0]) x) + for { + x := v_0 + v.reset(OpWasmI64Sub) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueWasm_OpNeg8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neg8 x) + // result: (I64Sub (I64Const [0]) x) + for { + x := v_0 + v.reset(OpWasmI64Sub) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValueWasm_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq16 x y) + // result: (I64Ne (ZeroExt16to64 x) (ZeroExt16to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64Ne) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq32 x y) + // result: (I64Ne (ZeroExt32to64 x) (ZeroExt32to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64Ne) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq8 x y) + // result: (I64Ne (ZeroExt8to64 x) (ZeroExt8to64 y)) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64Ne) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpPopCount16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount16 x) + // result: (I64Popcnt (ZeroExt16to64 x)) + for { + x := v_0 + v.reset(OpWasmI64Popcnt) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpPopCount32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount32 x) + // result: (I64Popcnt (ZeroExt32to64 x)) + for { + x := v_0 + v.reset(OpWasmI64Popcnt) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpPopCount8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (PopCount8 x) + // result: (I64Popcnt (ZeroExt8to64 x)) + for { + x := v_0 + v.reset(OpWasmI64Popcnt) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValueWasm_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft16 x (I64Const [c])) + // result: (Or16 (Lsh16x64 x (I64Const [c&15])) (Rsh16Ux64 x (I64Const [-c&15]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpWasmI64Const { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpLsh16x64, t) + v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v1.AuxInt = int64ToAuxInt(c & 15) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh16Ux64, t) + v3 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v3.AuxInt = int64ToAuxInt(-c & 15) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueWasm_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft8 x (I64Const [c])) + // result: (Or8 (Lsh8x64 x (I64Const [c&7])) (Rsh8Ux64 x (I64Const [-c&7]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpWasmI64Const { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpLsh8x64, t) + v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v1.AuxInt = int64ToAuxInt(c & 7) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpRsh8Ux64, t) + v3 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v3.AuxInt = int64ToAuxInt(-c & 7) + v2.AddArg2(x, v3) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValueWasm_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux16 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt16to64 x) (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux32 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt16to64 x) (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt16to64 x) y) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueWasm_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux8 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt16to64 x) (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x16 [c] x y) + // result: (Rsh64x64 [c] (SignExt16to64 x) (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x32 [c] x y) + // result: (Rsh64x64 [c] (SignExt16to64 x) (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 [c] x y) + // result: (Rsh64x64 [c] (SignExt16to64 x) y) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueWasm_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x8 [c] x y) + // result: (Rsh64x64 [c] (SignExt16to64 x) (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt16to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux16 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt32to64 x) (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux32 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt32to64 x) (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux64 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt32to64 x) y) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueWasm_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux8 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt32to64 x) (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x16 [c] x y) + // result: (Rsh64x64 [c] (SignExt32to64 x) (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x32 [c] x y) + // result: (Rsh64x64 [c] (SignExt32to64 x) (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x64 [c] x y) + // result: (Rsh64x64 [c] (SignExt32to64 x) y) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueWasm_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x8 [c] x y) + // result: (Rsh64x64 [c] (SignExt32to64 x) (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh64Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux16 [c] x y) + // result: (Rsh64Ux64 [c] x (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpRsh64Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux32 [c] x y) + // result: (Rsh64Ux64 [c] x (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpRsh64Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux64 x y) + // cond: shiftIsBounded(v) + // result: (I64ShrU x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpWasmI64ShrU) + v.AddArg2(x, y) + return true + } + // match: (Rsh64Ux64 x (I64Const [c])) + // cond: uint64(c) < 64 + // result: (I64ShrU x (I64Const [c])) + for { + x := v_0 + if v_1.Op != OpWasmI64Const { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 64) { + break + } + v.reset(OpWasmI64ShrU) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64Ux64 x (I64Const [c])) + // cond: uint64(c) >= 64 + // result: (I64Const [0]) + for { + if v_1.Op != OpWasmI64Const { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64Ux64 x y) + // result: (Select (I64ShrU x y) (I64Const [0]) (I64LtU y (I64Const [64]))) + for { + x := v_0 + y := v_1 + v.reset(OpWasmSelect) + v0 := b.NewValue0(v.Pos, OpWasmI64ShrU, typ.Int64) + v0.AddArg2(x, y) + v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpWasmI64LtU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(y, v3) + v.AddArg3(v0, v1, v2) + return true + } +} +func rewriteValueWasm_OpRsh64Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux8 [c] x y) + // result: (Rsh64Ux64 [c] x (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpRsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x16 [c] x y) + // result: (Rsh64x64 [c] x (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpRsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x32 [c] x y) + // result: (Rsh64x64 [c] x (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpRsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (I64ShrS x y) + for { + x := v_0 + y := v_1 + if !(shiftIsBounded(v)) { + break + } + v.reset(OpWasmI64ShrS) + v.AddArg2(x, y) + return true + } + // match: (Rsh64x64 x (I64Const [c])) + // cond: uint64(c) < 64 + // result: (I64ShrS x (I64Const [c])) + for { + x := v_0 + if v_1.Op != OpWasmI64Const { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) < 64) { + break + } + v.reset(OpWasmI64ShrS) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(c) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x64 x (I64Const [c])) + // cond: uint64(c) >= 64 + // result: (I64ShrS x (I64Const [63])) + for { + x := v_0 + if v_1.Op != OpWasmI64Const { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpWasmI64ShrS) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(63) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x64 x y) + // result: (I64ShrS x (Select y (I64Const [63]) (I64LtU y (I64Const [64])))) + for { + x := v_0 + y := v_1 + v.reset(OpWasmI64ShrS) + v0 := b.NewValue0(v.Pos, OpWasmSelect, typ.Int64) + v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v1.AuxInt = int64ToAuxInt(63) + v2 := b.NewValue0(v.Pos, OpWasmI64LtU, typ.Bool) + v3 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v3.AuxInt = int64ToAuxInt(64) + v2.AddArg2(y, v3) + v0.AddArg3(y, v1, v2) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpRsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x8 [c] x y) + // result: (Rsh64x64 [c] x (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux16 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt8to64 x) (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux32 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt8to64 x) (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt8to64 x) y) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueWasm_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux8 [c] x y) + // result: (Rsh64Ux64 [c] (ZeroExt8to64 x) (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x16 [c] x y) + // result: (Rsh64x64 [c] (SignExt8to64 x) (ZeroExt16to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x32 [c] x y) + // result: (Rsh64x64 [c] (SignExt8to64 x) (ZeroExt32to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x64 [c] x y) + // result: (Rsh64x64 [c] (SignExt8to64 x) y) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v.AddArg2(v0, y) + return true + } +} +func rewriteValueWasm_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x8 [c] x y) + // result: (Rsh64x64 [c] (SignExt8to64 x) (ZeroExt8to64 y)) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + y := v_1 + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(c) + v0 := b.NewValue0(v.Pos, OpSignExt8to64, typ.Int64) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.UInt64) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValueWasm_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + // match: (Select0 (Mul64uhilo x y)) + // result: (Hmul64u x y) + for { + t := v.Type + if v_0.Op != OpMul64uhilo { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpHmul64u) + v.Type = t + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueWasm_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + // match: (Select1 (Mul64uhilo x y)) + // result: (I64Mul x y) + for { + if v_0.Op != OpMul64uhilo { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpWasmI64Mul) + v.AddArg2(x, y) + return true + } + return false +} +func rewriteValueWasm_OpSignExt16to32(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt16to32 x:(I64Load16S _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load16S { + break + } + v.copyOf(x) + return true + } + // match: (SignExt16to32 x) + // result: (I64Extend16S x) + for { + x := v_0 + v.reset(OpWasmI64Extend16S) + v.AddArg(x) + return true + } +} +func rewriteValueWasm_OpSignExt16to64(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt16to64 x:(I64Load16S _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load16S { + break + } + v.copyOf(x) + return true + } + // match: (SignExt16to64 x) + // result: (I64Extend16S x) + for { + x := v_0 + v.reset(OpWasmI64Extend16S) + v.AddArg(x) + return true + } +} +func rewriteValueWasm_OpSignExt32to64(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt32to64 x:(I64Load32S _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load32S { + break + } + v.copyOf(x) + return true + } + // match: (SignExt32to64 x) + // result: (I64Extend32S x) + for { + x := v_0 + v.reset(OpWasmI64Extend32S) + v.AddArg(x) + return true + } +} +func rewriteValueWasm_OpSignExt8to16(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt8to16 x:(I64Load8S _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load8S { + break + } + v.copyOf(x) + return true + } + // match: (SignExt8to16 x) + // result: (I64Extend8S x) + for { + x := v_0 + v.reset(OpWasmI64Extend8S) + v.AddArg(x) + return true + } +} +func rewriteValueWasm_OpSignExt8to32(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt8to32 x:(I64Load8S _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load8S { + break + } + v.copyOf(x) + return true + } + // match: (SignExt8to32 x) + // result: (I64Extend8S x) + for { + x := v_0 + v.reset(OpWasmI64Extend8S) + v.AddArg(x) + return true + } +} +func rewriteValueWasm_OpSignExt8to64(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt8to64 x:(I64Load8S _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load8S { + break + } + v.copyOf(x) + return true + } + // match: (SignExt8to64 x) + // result: (I64Extend8S x) + for { + x := v_0 + v.reset(OpWasmI64Extend8S) + v.AddArg(x) + return true + } +} +func rewriteValueWasm_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Slicemask x) + // result: (I64ShrS (I64Sub (I64Const [0]) x) (I64Const [63])) + for { + x := v_0 + v.reset(OpWasmI64ShrS) + v0 := b.NewValue0(v.Pos, OpWasmI64Sub, typ.Int64) + v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v1.AuxInt = int64ToAuxInt(0) + v0.AddArg2(v1, x) + v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v2.AuxInt = int64ToAuxInt(63) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValueWasm_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Store {t} ptr val mem) + // cond: is64BitFloat(t) + // result: (F64Store ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(is64BitFloat(t)) { + break + } + v.reset(OpWasmF64Store) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: is32BitFloat(t) + // result: (F32Store ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(is32BitFloat(t)) { + break + } + v.reset(OpWasmF32Store) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 8 + // result: (I64Store ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 8) { + break + } + v.reset(OpWasmI64Store) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 4 + // result: (I64Store32 ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 4) { + break + } + v.reset(OpWasmI64Store32) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 2 + // result: (I64Store16 ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 2) { + break + } + v.reset(OpWasmI64Store16) + v.AddArg3(ptr, val, mem) + return true + } + // match: (Store {t} ptr val mem) + // cond: t.Size() == 1 + // result: (I64Store8 ptr val mem) + for { + t := auxToType(v.Aux) + ptr := v_0 + val := v_1 + mem := v_2 + if !(t.Size() == 1) { + break + } + v.reset(OpWasmI64Store8) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueWasm_OpWasmF64Add(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (F64Add (F64Const [x]) (F64Const [y])) + // result: (F64Const [x + y]) + for { + if v_0.Op != OpWasmF64Const { + break + } + x := auxIntToFloat64(v_0.AuxInt) + if v_1.Op != OpWasmF64Const { + break + } + y := auxIntToFloat64(v_1.AuxInt) + v.reset(OpWasmF64Const) + v.AuxInt = float64ToAuxInt(x + y) + return true + } + // match: (F64Add (F64Const [x]) y) + // cond: y.Op != OpWasmF64Const + // result: (F64Add y (F64Const [x])) + for { + if v_0.Op != OpWasmF64Const { + break + } + x := auxIntToFloat64(v_0.AuxInt) + y := v_1 + if !(y.Op != OpWasmF64Const) { + break + } + v.reset(OpWasmF64Add) + v0 := b.NewValue0(v.Pos, OpWasmF64Const, typ.Float64) + v0.AuxInt = float64ToAuxInt(x) + v.AddArg2(y, v0) + return true + } + return false +} +func rewriteValueWasm_OpWasmF64Mul(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (F64Mul (F64Const [x]) (F64Const [y])) + // cond: !math.IsNaN(x * y) + // result: (F64Const [x * y]) + for { + if v_0.Op != OpWasmF64Const { + break + } + x := auxIntToFloat64(v_0.AuxInt) + if v_1.Op != OpWasmF64Const { + break + } + y := auxIntToFloat64(v_1.AuxInt) + if !(!math.IsNaN(x * y)) { + break + } + v.reset(OpWasmF64Const) + v.AuxInt = float64ToAuxInt(x * y) + return true + } + // match: (F64Mul (F64Const [x]) y) + // cond: y.Op != OpWasmF64Const + // result: (F64Mul y (F64Const [x])) + for { + if v_0.Op != OpWasmF64Const { + break + } + x := auxIntToFloat64(v_0.AuxInt) + y := v_1 + if !(y.Op != OpWasmF64Const) { + break + } + v.reset(OpWasmF64Mul) + v0 := b.NewValue0(v.Pos, OpWasmF64Const, typ.Float64) + v0.AuxInt = float64ToAuxInt(x) + v.AddArg2(y, v0) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Add(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (I64Add (I64Const [x]) (I64Const [y])) + // result: (I64Const [x + y]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(x + y) + return true + } + // match: (I64Add (I64Const [x]) y) + // cond: y.Op != OpWasmI64Const + // result: (I64Add y (I64Const [x])) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(y.Op != OpWasmI64Const) { + break + } + v.reset(OpWasmI64Add) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(x) + v.AddArg2(y, v0) + return true + } + // match: (I64Add x (I64Const [y])) + // cond: !t.IsPtr() + // result: (I64AddConst [y] x) + for { + x := v_0 + if v_1.Op != OpWasmI64Const { + break + } + t := v_1.Type + y := auxIntToInt64(v_1.AuxInt) + if !(!t.IsPtr()) { + break + } + v.reset(OpWasmI64AddConst) + v.AuxInt = int64ToAuxInt(y) + v.AddArg(x) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64AddConst(v *Value) bool { + v_0 := v.Args[0] + // match: (I64AddConst [0] x) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + v.copyOf(x) + return true + } + // match: (I64AddConst [off] (LoweredAddr {sym} [off2] base)) + // cond: isU32Bit(off+int64(off2)) + // result: (LoweredAddr {sym} [int32(off)+off2] base) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmLoweredAddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + base := v_0.Args[0] + if !(isU32Bit(off + int64(off2))) { + break + } + v.reset(OpWasmLoweredAddr) + v.AuxInt = int32ToAuxInt(int32(off) + off2) + v.Aux = symToAux(sym) + v.AddArg(base) + return true + } + // match: (I64AddConst [off] x:(SP)) + // cond: isU32Bit(off) + // result: (LoweredAddr [int32(off)] x) + for { + off := auxIntToInt64(v.AuxInt) + x := v_0 + if x.Op != OpSP || !(isU32Bit(off)) { + break + } + v.reset(OpWasmLoweredAddr) + v.AuxInt = int32ToAuxInt(int32(off)) + v.AddArg(x) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64And(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (I64And (I64Const [x]) (I64Const [y])) + // result: (I64Const [x & y]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(x & y) + return true + } + // match: (I64And (I64Const [x]) y) + // cond: y.Op != OpWasmI64Const + // result: (I64And y (I64Const [x])) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(y.Op != OpWasmI64Const) { + break + } + v.reset(OpWasmI64And) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(x) + v.AddArg2(y, v0) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Eq(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (I64Eq (I64Const [x]) (I64Const [y])) + // cond: x == y + // result: (I64Const [1]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + if !(x == y) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (I64Eq (I64Const [x]) (I64Const [y])) + // cond: x != y + // result: (I64Const [0]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + if !(x != y) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (I64Eq (I64Const [x]) y) + // cond: y.Op != OpWasmI64Const + // result: (I64Eq y (I64Const [x])) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(y.Op != OpWasmI64Const) { + break + } + v.reset(OpWasmI64Eq) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(x) + v.AddArg2(y, v0) + return true + } + // match: (I64Eq x (I64Const [0])) + // result: (I64Eqz x) + for { + x := v_0 + if v_1.Op != OpWasmI64Const || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.reset(OpWasmI64Eqz) + v.AddArg(x) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Eqz(v *Value) bool { + v_0 := v.Args[0] + // match: (I64Eqz (I64Eqz (I64Eqz x))) + // result: (I64Eqz x) + for { + if v_0.Op != OpWasmI64Eqz { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpWasmI64Eqz { + break + } + x := v_0_0.Args[0] + v.reset(OpWasmI64Eqz) + v.AddArg(x) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64LeU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (I64LeU x (I64Const [0])) + // result: (I64Eqz x) + for { + x := v_0 + if v_1.Op != OpWasmI64Const || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.reset(OpWasmI64Eqz) + v.AddArg(x) + return true + } + // match: (I64LeU (I64Const [1]) x) + // result: (I64Eqz (I64Eqz x)) + for { + if v_0.Op != OpWasmI64Const || auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpWasmI64Eqz) + v0 := b.NewValue0(v.Pos, OpWasmI64Eqz, typ.Bool) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Load(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (I64Load [off] (I64AddConst [off2] ptr) mem) + // cond: isU32Bit(off+off2) + // result: (I64Load [off+off2] ptr mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Load) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg2(ptr, mem) + return true + } + // match: (I64Load [off] (LoweredAddr {sym} [off2] (SB)) _) + // cond: symIsRO(sym) && isU32Bit(off+int64(off2)) + // result: (I64Const [int64(read64(sym, off+int64(off2), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmLoweredAddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB || !(symIsRO(sym) && isU32Bit(off+int64(off2))) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(read64(sym, off+int64(off2), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Load16S(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (I64Load16S [off] (I64AddConst [off2] ptr) mem) + // cond: isU32Bit(off+off2) + // result: (I64Load16S [off+off2] ptr mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Load16S) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg2(ptr, mem) + return true + } + // match: (I64Load16S [off] (LoweredAddr {sym} [off2] (SB)) _) + // cond: symIsRO(sym) && isU32Bit(off+int64(off2)) + // result: (I64Const [int64(int16(read16(sym, off+int64(off2), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmLoweredAddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB || !(symIsRO(sym) && isU32Bit(off+int64(off2))) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(int16(read16(sym, off+int64(off2), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Load16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (I64Load16U [off] (I64AddConst [off2] ptr) mem) + // cond: isU32Bit(off+off2) + // result: (I64Load16U [off+off2] ptr mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Load16U) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg2(ptr, mem) + return true + } + // match: (I64Load16U [off] (LoweredAddr {sym} [off2] (SB)) _) + // cond: symIsRO(sym) && isU32Bit(off+int64(off2)) + // result: (I64Const [int64(read16(sym, off+int64(off2), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmLoweredAddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB || !(symIsRO(sym) && isU32Bit(off+int64(off2))) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(read16(sym, off+int64(off2), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Load32S(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (I64Load32S [off] (I64AddConst [off2] ptr) mem) + // cond: isU32Bit(off+off2) + // result: (I64Load32S [off+off2] ptr mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Load32S) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg2(ptr, mem) + return true + } + // match: (I64Load32S [off] (LoweredAddr {sym} [off2] (SB)) _) + // cond: symIsRO(sym) && isU32Bit(off+int64(off2)) + // result: (I64Const [int64(int32(read32(sym, off+int64(off2), config.ctxt.Arch.ByteOrder)))]) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmLoweredAddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB || !(symIsRO(sym) && isU32Bit(off+int64(off2))) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(int32(read32(sym, off+int64(off2), config.ctxt.Arch.ByteOrder)))) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Load32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (I64Load32U [off] (I64AddConst [off2] ptr) mem) + // cond: isU32Bit(off+off2) + // result: (I64Load32U [off+off2] ptr mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Load32U) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg2(ptr, mem) + return true + } + // match: (I64Load32U [off] (LoweredAddr {sym} [off2] (SB)) _) + // cond: symIsRO(sym) && isU32Bit(off+int64(off2)) + // result: (I64Const [int64(read32(sym, off+int64(off2), config.ctxt.Arch.ByteOrder))]) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmLoweredAddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB || !(symIsRO(sym) && isU32Bit(off+int64(off2))) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(read32(sym, off+int64(off2), config.ctxt.Arch.ByteOrder))) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Load8S(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (I64Load8S [off] (I64AddConst [off2] ptr) mem) + // cond: isU32Bit(off+off2) + // result: (I64Load8S [off+off2] ptr mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Load8S) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg2(ptr, mem) + return true + } + // match: (I64Load8S [off] (LoweredAddr {sym} [off2] (SB)) _) + // cond: symIsRO(sym) && isU32Bit(off+int64(off2)) + // result: (I64Const [int64(int8(read8(sym, off+int64(off2))))]) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmLoweredAddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB || !(symIsRO(sym) && isU32Bit(off+int64(off2))) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(int8(read8(sym, off+int64(off2))))) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Load8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (I64Load8U [off] (I64AddConst [off2] ptr) mem) + // cond: isU32Bit(off+off2) + // result: (I64Load8U [off+off2] ptr mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + mem := v_1 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Load8U) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg2(ptr, mem) + return true + } + // match: (I64Load8U [off] (LoweredAddr {sym} [off2] (SB)) _) + // cond: symIsRO(sym) && isU32Bit(off+int64(off2)) + // result: (I64Const [int64(read8(sym, off+int64(off2)))]) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmLoweredAddr { + break + } + off2 := auxIntToInt32(v_0.AuxInt) + sym := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB || !(symIsRO(sym) && isU32Bit(off+int64(off2))) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(read8(sym, off+int64(off2)))) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64LtU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (I64LtU (I64Const [0]) x) + // result: (I64Eqz (I64Eqz x)) + for { + if v_0.Op != OpWasmI64Const || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_1 + v.reset(OpWasmI64Eqz) + v0 := b.NewValue0(v.Pos, OpWasmI64Eqz, typ.Bool) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (I64LtU x (I64Const [1])) + // result: (I64Eqz x) + for { + x := v_0 + if v_1.Op != OpWasmI64Const || auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.reset(OpWasmI64Eqz) + v.AddArg(x) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Mul(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (I64Mul (I64Const [x]) (I64Const [y])) + // result: (I64Const [x * y]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(x * y) + return true + } + // match: (I64Mul (I64Const [x]) y) + // cond: y.Op != OpWasmI64Const + // result: (I64Mul y (I64Const [x])) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(y.Op != OpWasmI64Const) { + break + } + v.reset(OpWasmI64Mul) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(x) + v.AddArg2(y, v0) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Ne(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (I64Ne (I64Const [x]) (I64Const [y])) + // cond: x == y + // result: (I64Const [0]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + if !(x == y) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (I64Ne (I64Const [x]) (I64Const [y])) + // cond: x != y + // result: (I64Const [1]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + if !(x != y) { + break + } + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (I64Ne (I64Const [x]) y) + // cond: y.Op != OpWasmI64Const + // result: (I64Ne y (I64Const [x])) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(y.Op != OpWasmI64Const) { + break + } + v.reset(OpWasmI64Ne) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(x) + v.AddArg2(y, v0) + return true + } + // match: (I64Ne x (I64Const [0])) + // result: (I64Eqz (I64Eqz x)) + for { + x := v_0 + if v_1.Op != OpWasmI64Const || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.reset(OpWasmI64Eqz) + v0 := b.NewValue0(v.Pos, OpWasmI64Eqz, typ.Bool) + v0.AddArg(x) + v.AddArg(v0) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Or(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (I64Or (I64Const [x]) (I64Const [y])) + // result: (I64Const [x | y]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(x | y) + return true + } + // match: (I64Or (I64Const [x]) y) + // cond: y.Op != OpWasmI64Const + // result: (I64Or y (I64Const [x])) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(y.Op != OpWasmI64Const) { + break + } + v.reset(OpWasmI64Or) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(x) + v.AddArg2(y, v0) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Shl(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (I64Shl (I64Const [x]) (I64Const [y])) + // result: (I64Const [x << uint64(y)]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(x << uint64(y)) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64ShrS(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (I64ShrS (I64Const [x]) (I64Const [y])) + // result: (I64Const [x >> uint64(y)]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(x >> uint64(y)) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64ShrU(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (I64ShrU (I64Const [x]) (I64Const [y])) + // result: (I64Const [int64(uint64(x) >> uint64(y))]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(int64(uint64(x) >> uint64(y))) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Store(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (I64Store [off] (I64AddConst [off2] ptr) val mem) + // cond: isU32Bit(off+off2) + // result: (I64Store [off+off2] ptr val mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Store) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Store16(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (I64Store16 [off] (I64AddConst [off2] ptr) val mem) + // cond: isU32Bit(off+off2) + // result: (I64Store16 [off+off2] ptr val mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Store16) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Store32(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (I64Store32 [off] (I64AddConst [off2] ptr) val mem) + // cond: isU32Bit(off+off2) + // result: (I64Store32 [off+off2] ptr val mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Store32) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Store8(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (I64Store8 [off] (I64AddConst [off2] ptr) val mem) + // cond: isU32Bit(off+off2) + // result: (I64Store8 [off+off2] ptr val mem) + for { + off := auxIntToInt64(v.AuxInt) + if v_0.Op != OpWasmI64AddConst { + break + } + off2 := auxIntToInt64(v_0.AuxInt) + ptr := v_0.Args[0] + val := v_1 + mem := v_2 + if !(isU32Bit(off + off2)) { + break + } + v.reset(OpWasmI64Store8) + v.AuxInt = int64ToAuxInt(off + off2) + v.AddArg3(ptr, val, mem) + return true + } + return false +} +func rewriteValueWasm_OpWasmI64Xor(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (I64Xor (I64Const [x]) (I64Const [y])) + // result: (I64Const [x ^ y]) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpWasmI64Const { + break + } + y := auxIntToInt64(v_1.AuxInt) + v.reset(OpWasmI64Const) + v.AuxInt = int64ToAuxInt(x ^ y) + return true + } + // match: (I64Xor (I64Const [x]) y) + // cond: y.Op != OpWasmI64Const + // result: (I64Xor y (I64Const [x])) + for { + if v_0.Op != OpWasmI64Const { + break + } + x := auxIntToInt64(v_0.AuxInt) + y := v_1 + if !(y.Op != OpWasmI64Const) { + break + } + v.reset(OpWasmI64Xor) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(x) + v.AddArg2(y, v0) + return true + } + return false +} +func rewriteValueWasm_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Zero [0] _ mem) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + mem := v_1 + v.copyOf(mem) + return true + } + // match: (Zero [1] destptr mem) + // result: (I64Store8 destptr (I64Const [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store8) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(destptr, v0, mem) + return true + } + // match: (Zero [2] destptr mem) + // result: (I64Store16 destptr (I64Const [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 2 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store16) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(destptr, v0, mem) + return true + } + // match: (Zero [4] destptr mem) + // result: (I64Store32 destptr (I64Const [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 4 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store32) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(destptr, v0, mem) + return true + } + // match: (Zero [8] destptr mem) + // result: (I64Store destptr (I64Const [0]) mem) + for { + if auxIntToInt64(v.AuxInt) != 8 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg3(destptr, v0, mem) + return true + } + // match: (Zero [3] destptr mem) + // result: (I64Store8 [2] destptr (I64Const [0]) (I64Store16 destptr (I64Const [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 3 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store8) + v.AuxInt = int64ToAuxInt(2) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpWasmI64Store16, types.TypeMem) + v1.AddArg3(destptr, v0, mem) + v.AddArg3(destptr, v0, v1) + return true + } + // match: (Zero [5] destptr mem) + // result: (I64Store8 [4] destptr (I64Const [0]) (I64Store32 destptr (I64Const [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 5 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store8) + v.AuxInt = int64ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpWasmI64Store32, types.TypeMem) + v1.AddArg3(destptr, v0, mem) + v.AddArg3(destptr, v0, v1) + return true + } + // match: (Zero [6] destptr mem) + // result: (I64Store16 [4] destptr (I64Const [0]) (I64Store32 destptr (I64Const [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 6 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store16) + v.AuxInt = int64ToAuxInt(4) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpWasmI64Store32, types.TypeMem) + v1.AddArg3(destptr, v0, mem) + v.AddArg3(destptr, v0, v1) + return true + } + // match: (Zero [7] destptr mem) + // result: (I64Store32 [3] destptr (I64Const [0]) (I64Store32 destptr (I64Const [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 7 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store32) + v.AuxInt = int64ToAuxInt(3) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpWasmI64Store32, types.TypeMem) + v1.AddArg3(destptr, v0, mem) + v.AddArg3(destptr, v0, v1) + return true + } + // match: (Zero [s] destptr mem) + // cond: s%8 != 0 && s > 8 && s < 32 + // result: (Zero [s-s%8] (OffPtr destptr [s%8]) (I64Store destptr (I64Const [0]) mem)) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + if !(s%8 != 0 && s > 8 && s < 32) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(s - s%8) + v0 := b.NewValue0(v.Pos, OpOffPtr, destptr.Type) + v0.AuxInt = int64ToAuxInt(s % 8) + v0.AddArg(destptr) + v1 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v2.AuxInt = int64ToAuxInt(0) + v1.AddArg3(destptr, v2, mem) + v.AddArg2(v0, v1) + return true + } + // match: (Zero [16] destptr mem) + // result: (I64Store [8] destptr (I64Const [0]) (I64Store destptr (I64Const [0]) mem)) + for { + if auxIntToInt64(v.AuxInt) != 16 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store) + v.AuxInt = int64ToAuxInt(8) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v1.AddArg3(destptr, v0, mem) + v.AddArg3(destptr, v0, v1) + return true + } + // match: (Zero [24] destptr mem) + // result: (I64Store [16] destptr (I64Const [0]) (I64Store [8] destptr (I64Const [0]) (I64Store destptr (I64Const [0]) mem))) + for { + if auxIntToInt64(v.AuxInt) != 24 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store) + v.AuxInt = int64ToAuxInt(16) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v1.AuxInt = int64ToAuxInt(8) + v2 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v2.AddArg3(destptr, v0, mem) + v1.AddArg3(destptr, v0, v2) + v.AddArg3(destptr, v0, v1) + return true + } + // match: (Zero [32] destptr mem) + // result: (I64Store [24] destptr (I64Const [0]) (I64Store [16] destptr (I64Const [0]) (I64Store [8] destptr (I64Const [0]) (I64Store destptr (I64Const [0]) mem)))) + for { + if auxIntToInt64(v.AuxInt) != 32 { + break + } + destptr := v_0 + mem := v_1 + v.reset(OpWasmI64Store) + v.AuxInt = int64ToAuxInt(24) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v1.AuxInt = int64ToAuxInt(16) + v2 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v2.AuxInt = int64ToAuxInt(8) + v3 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v3.AddArg3(destptr, v0, mem) + v2.AddArg3(destptr, v0, v3) + v1.AddArg3(destptr, v0, v2) + v.AddArg3(destptr, v0, v1) + return true + } + // match: (Zero [s] destptr mem) + // result: (LoweredZero [s] destptr mem) + for { + s := auxIntToInt64(v.AuxInt) + destptr := v_0 + mem := v_1 + v.reset(OpWasmLoweredZero) + v.AuxInt = int64ToAuxInt(s) + v.AddArg2(destptr, mem) + return true + } +} +func rewriteValueWasm_OpZeroExt16to32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ZeroExt16to32 x:(I64Load16U _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load16U { + break + } + v.copyOf(x) + return true + } + // match: (ZeroExt16to32 x) + // result: (I64And x (I64Const [0xffff])) + for { + x := v_0 + v.reset(OpWasmI64And) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0xffff) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpZeroExt16to64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ZeroExt16to64 x:(I64Load16U _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load16U { + break + } + v.copyOf(x) + return true + } + // match: (ZeroExt16to64 x) + // result: (I64And x (I64Const [0xffff])) + for { + x := v_0 + v.reset(OpWasmI64And) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0xffff) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpZeroExt32to64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ZeroExt32to64 x:(I64Load32U _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load32U { + break + } + v.copyOf(x) + return true + } + // match: (ZeroExt32to64 x) + // result: (I64And x (I64Const [0xffffffff])) + for { + x := v_0 + v.reset(OpWasmI64And) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0xffffffff) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpZeroExt8to16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ZeroExt8to16 x:(I64Load8U _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load8U { + break + } + v.copyOf(x) + return true + } + // match: (ZeroExt8to16 x) + // result: (I64And x (I64Const [0xff])) + for { + x := v_0 + v.reset(OpWasmI64And) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0xff) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpZeroExt8to32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ZeroExt8to32 x:(I64Load8U _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load8U { + break + } + v.copyOf(x) + return true + } + // match: (ZeroExt8to32 x) + // result: (I64And x (I64Const [0xff])) + for { + x := v_0 + v.reset(OpWasmI64And) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0xff) + v.AddArg2(x, v0) + return true + } +} +func rewriteValueWasm_OpZeroExt8to64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ZeroExt8to64 x:(I64Load8U _ _)) + // result: x + for { + x := v_0 + if x.Op != OpWasmI64Load8U { + break + } + v.copyOf(x) + return true + } + // match: (ZeroExt8to64 x) + // result: (I64And x (I64Const [0xff])) + for { + x := v_0 + v.reset(OpWasmI64And) + v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) + v0.AuxInt = int64ToAuxInt(0xff) + v.AddArg2(x, v0) + return true + } +} +func rewriteBlockWasm(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewrite_test.go b/go/src/cmd/compile/internal/ssa/rewrite_test.go new file mode 100644 index 0000000000000000000000000000000000000000..92e9d3fd5b9ca5b574fc119d978b3374c025256e --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewrite_test.go @@ -0,0 +1,287 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/rttype" + "reflect" + "testing" + "unsafe" +) + +// We generate memmove for copy(x[1:], x[:]), however we may change it to OpMove, +// because size is known. Check that OpMove is alias-safe, or we did call memmove. +func TestMove(t *testing.T) { + x := [...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40} + copy(x[1:], x[:]) + for i := 1; i < len(x); i++ { + if int(x[i]) != i { + t.Errorf("Memmove got converted to OpMove in alias-unsafe way. Got %d instead of %d in position %d", int(x[i]), i, i+1) + } + } +} + +func TestMoveSmall(t *testing.T) { + x := [...]byte{1, 2, 3, 4, 5, 6, 7} + copy(x[1:], x[:]) + for i := 1; i < len(x); i++ { + if int(x[i]) != i { + t.Errorf("Memmove got converted to OpMove in alias-unsafe way. Got %d instead of %d in position %d", int(x[i]), i, i+1) + } + } +} + +func TestSubFlags(t *testing.T) { + if !subFlags32(0, 1).lt() { + t.Errorf("subFlags32(0,1).lt() returned false") + } + if !subFlags32(0, 1).ult() { + t.Errorf("subFlags32(0,1).ult() returned false") + } +} + +func TestIsPPC64WordRotateMask(t *testing.T) { + tests := []struct { + input int64 + expected bool + }{ + {0x00000001, true}, + {0x80000001, true}, + {0x80010001, false}, + {0xFFFFFFFA, false}, + {0xF0F0F0F0, false}, + {0xFFFFFFFD, true}, + {0x80000000, true}, + {0x00000000, false}, + {0xFFFFFFFF, true}, + {0x0000FFFF, true}, + {0xFF0000FF, true}, + {0x00FFFF00, true}, + } + + for _, v := range tests { + if v.expected != isPPC64WordRotateMask(v.input) { + t.Errorf("isPPC64WordRotateMask(0x%x) failed", v.input) + } + } +} + +func TestEncodeDecodePPC64WordRotateMask(t *testing.T) { + tests := []struct { + rotate int64 + mask uint64 + nbits, + mb, + me, + encoded int64 + }{ + {1, 0x00000001, 32, 31, 31, 0x20011f20}, + {2, 0x80000001, 32, 31, 0, 0x20021f01}, + {3, 0xFFFFFFFD, 32, 31, 29, 0x20031f1e}, + {4, 0x80000000, 32, 0, 0, 0x20040001}, + {5, 0xFFFFFFFF, 32, 0, 31, 0x20050020}, + {6, 0x0000FFFF, 32, 16, 31, 0x20061020}, + {7, 0xFF0000FF, 32, 24, 7, 0x20071808}, + {8, 0x00FFFF00, 32, 8, 23, 0x20080818}, + + {9, 0x0000000000FFFF00, 64, 40, 55, 0x40092838}, + {10, 0xFFFF000000000000, 64, 0, 15, 0x400A0010}, + {10, 0xFFFF000000000001, 64, 63, 15, 0x400A3f10}, + } + + for i, v := range tests { + result := encodePPC64RotateMask(v.rotate, int64(v.mask), v.nbits) + if result != v.encoded { + t.Errorf("encodePPC64RotateMask(%d,0x%x,%d) = 0x%x, expected 0x%x", v.rotate, v.mask, v.nbits, result, v.encoded) + } + rotate, mb, me, mask := DecodePPC64RotateMask(result) + if rotate != v.rotate || mb != v.mb || me != v.me || mask != v.mask { + t.Errorf("DecodePPC64Failure(Test %d) got (%d, %d, %d, %x) expected (%d, %d, %d, %x)", i, rotate, mb, me, mask, v.rotate, v.mb, v.me, v.mask) + } + } +} + +func TestMergePPC64ClrlsldiSrw(t *testing.T) { + tests := []struct { + clrlsldi int32 + srw int64 + valid bool + rotate int64 + mask uint64 + }{ + // ((x>>4)&0xFF)<<4 + {newPPC64ShiftAuxInt(4, 56, 63, 64), 4, true, 0, 0xFF0}, + // ((x>>4)&0xFFFF)<<4 + {newPPC64ShiftAuxInt(4, 48, 63, 64), 4, true, 0, 0xFFFF0}, + // ((x>>4)&0xFFFF)<<17 + {newPPC64ShiftAuxInt(17, 48, 63, 64), 4, false, 0, 0}, + // ((x>>4)&0xFFFF)<<16 + {newPPC64ShiftAuxInt(16, 48, 63, 64), 4, true, 12, 0xFFFF0000}, + // ((x>>32)&0xFFFF)<<17 + {newPPC64ShiftAuxInt(17, 48, 63, 64), 32, false, 0, 0}, + } + for i, v := range tests { + result := mergePPC64ClrlsldiSrw(int64(v.clrlsldi), v.srw) + if v.valid && result == 0 { + t.Errorf("mergePPC64ClrlsldiSrw(Test %d) did not merge", i) + } else if !v.valid && result != 0 { + t.Errorf("mergePPC64ClrlsldiSrw(Test %d) should return 0", i) + } else if r, _, _, m := DecodePPC64RotateMask(result); v.rotate != r || v.mask != m { + t.Errorf("mergePPC64ClrlsldiSrw(Test %d) got (%d,0x%x) expected (%d,0x%x)", i, r, m, v.rotate, v.mask) + } + } +} + +func TestMergePPC64ClrlsldiRlwinm(t *testing.T) { + tests := []struct { + clrlsldi int32 + rlwinm int64 + valid bool + rotate int64 + mask uint64 + }{ + // ((x<<4)&0xFF00)<<4 + {newPPC64ShiftAuxInt(4, 56, 63, 64), encodePPC64RotateMask(4, 0xFF00, 32), false, 0, 0}, + // ((x>>4)&0xFF)<<4 + {newPPC64ShiftAuxInt(4, 56, 63, 64), encodePPC64RotateMask(28, 0x0FFFFFFF, 32), true, 0, 0xFF0}, + // ((x>>4)&0xFFFF)<<4 + {newPPC64ShiftAuxInt(4, 48, 63, 64), encodePPC64RotateMask(28, 0xFFFF, 32), true, 0, 0xFFFF0}, + // ((x>>4)&0xFFFF)<<17 + {newPPC64ShiftAuxInt(17, 48, 63, 64), encodePPC64RotateMask(28, 0xFFFF, 32), false, 0, 0}, + // ((x>>4)&0xFFFF)<<16 + {newPPC64ShiftAuxInt(16, 48, 63, 64), encodePPC64RotateMask(28, 0xFFFF, 32), true, 12, 0xFFFF0000}, + // ((x>>4)&0xF000FFFF)<<16 + {newPPC64ShiftAuxInt(16, 48, 63, 64), encodePPC64RotateMask(28, 0xF000FFFF, 32), true, 12, 0xFFFF0000}, + } + for i, v := range tests { + result := mergePPC64ClrlsldiRlwinm(v.clrlsldi, v.rlwinm) + if v.valid && result == 0 { + t.Errorf("mergePPC64ClrlsldiRlwinm(Test %d) did not merge", i) + } else if !v.valid && result != 0 { + t.Errorf("mergePPC64ClrlsldiRlwinm(Test %d) should return 0", i) + } else if r, _, _, m := DecodePPC64RotateMask(result); v.rotate != r || v.mask != m { + t.Errorf("mergePPC64ClrlsldiRlwinm(Test %d) got (%d,0x%x) expected (%d,0x%x)", i, r, m, v.rotate, v.mask) + } + } +} + +func TestMergePPC64SldiSrw(t *testing.T) { + tests := []struct { + sld int64 + srw int64 + valid bool + rotate int64 + mask uint64 + }{ + {4, 4, true, 0, 0xFFFFFFF0}, + {4, 8, true, 28, 0x0FFFFFF0}, + {0, 0, true, 0, 0xFFFFFFFF}, + {8, 4, false, 0, 0}, + {0, 32, false, 0, 0}, + {0, 31, true, 1, 0x1}, + {31, 31, true, 0, 0x80000000}, + {32, 32, false, 0, 0}, + } + for i, v := range tests { + result := mergePPC64SldiSrw(v.sld, v.srw) + if v.valid && result == 0 { + t.Errorf("mergePPC64SldiSrw(Test %d) did not merge", i) + } else if !v.valid && result != 0 { + t.Errorf("mergePPC64SldiSrw(Test %d) should return 0", i) + } else if r, _, _, m := DecodePPC64RotateMask(result); v.rotate != r || v.mask != m { + t.Errorf("mergePPC64SldiSrw(Test %d) got (%d,0x%x) expected (%d,0x%x)", i, r, m, v.rotate, v.mask) + } + } +} + +func TestMergePPC64AndSrwi(t *testing.T) { + tests := []struct { + and int64 + srw int64 + valid bool + rotate int64 + mask uint64 + }{ + {0x000000FF, 8, true, 24, 0xFF}, + {0xF00000FF, 8, true, 24, 0xFF}, + {0x0F0000FF, 4, false, 0, 0}, + {0x00000000, 4, false, 0, 0}, + {0xF0000000, 4, false, 0, 0}, + {0xF0000000, 32, false, 0, 0}, + {0xFFFFFFFF, 0, true, 0, 0xFFFFFFFF}, + } + for i, v := range tests { + result := mergePPC64AndSrwi(v.and, v.srw) + if v.valid && result == 0 { + t.Errorf("mergePPC64AndSrwi(Test %d) did not merge", i) + } else if !v.valid && result != 0 { + t.Errorf("mergePPC64AndSrwi(Test %d) should return 0", i) + } else if r, _, _, m := DecodePPC64RotateMask(result); v.rotate != r || v.mask != m { + t.Errorf("mergePPC64AndSrwi(Test %d) got (%d,0x%x) expected (%d,0x%x)", i, r, m, v.rotate, v.mask) + } + } +} + +func TestDisjointTypes(t *testing.T) { + tests := []struct { + v1, v2 any // two pointers to some types + expected bool + }{ + {new(int8), new(int8), false}, + {new(int8), new(float32), false}, + {new(int8), new(*int8), true}, + {new(*int8), new(*float32), false}, + {new(*int8), new(chan<- int8), false}, + {new(**int8), new(*int8), false}, + {new(***int8), new(**int8), false}, + {new(int8), new(chan<- int8), true}, + {new(int), unsafe.Pointer(nil), false}, + {new(byte), new(string), false}, + {new(int), new(string), false}, + {new(*int8), new(struct{ a, b int }), true}, + {new(*int8), new(struct { + a *int + b int + }), false}, + {new(*int8), new(struct { + a int + b *int + }), false}, // with more precise analysis it should be true + {new(*byte), new(string), false}, + {new(int), new(struct { + a int + b *int + }), false}, + {new(float64), new(complex128), false}, + {new(*byte), new([]byte), false}, + {new(int), new([]byte), false}, + {new(int), new([2]*byte), false}, // with more recise analysis it should be true + {new([2]int), new(*byte), true}, + } + for _, tst := range tests { + t1 := rttype.FromReflect(reflect.TypeOf(tst.v1)) + t2 := rttype.FromReflect(reflect.TypeOf(tst.v2)) + result := disjointTypes(t1, t2) + if result != tst.expected { + t.Errorf("disjointTypes(%s, %s) got %t expected %t", t1.String(), t2.String(), result, tst.expected) + } + } +} + +//go:noinline +func foo(p1 *int64, p2 *float64) int64 { + *p1 = 10 + *p2 = 0 // disjointTypes shouldn't consider this and preceding stores as non-aliasing + return *p1 +} + +func TestDisjointTypesRun(t *testing.T) { + f := float64(0) + i := (*int64)(unsafe.Pointer(&f)) + r := foo(i, &f) + if r != 0 { + t.Errorf("disjointTypes gives an incorrect answer that leads to an incorrect optimization.") + } +} diff --git a/go/src/cmd/compile/internal/ssa/rewritedec.go b/go/src/cmd/compile/internal/ssa/rewritedec.go new file mode 100644 index 0000000000000000000000000000000000000000..1141d322bf0a592bd65a5bbc7a12da70834f2e36 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewritedec.go @@ -0,0 +1,929 @@ +// Code generated from _gen/dec.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "cmd/compile/internal/types" + +func rewriteValuedec(v *Value) bool { + switch v.Op { + case OpArrayMake1: + return rewriteValuedec_OpArrayMake1(v) + case OpArraySelect: + return rewriteValuedec_OpArraySelect(v) + case OpComplexImag: + return rewriteValuedec_OpComplexImag(v) + case OpComplexReal: + return rewriteValuedec_OpComplexReal(v) + case OpIData: + return rewriteValuedec_OpIData(v) + case OpIMake: + return rewriteValuedec_OpIMake(v) + case OpITab: + return rewriteValuedec_OpITab(v) + case OpLoad: + return rewriteValuedec_OpLoad(v) + case OpSliceCap: + return rewriteValuedec_OpSliceCap(v) + case OpSliceLen: + return rewriteValuedec_OpSliceLen(v) + case OpSlicePtr: + return rewriteValuedec_OpSlicePtr(v) + case OpSlicePtrUnchecked: + return rewriteValuedec_OpSlicePtrUnchecked(v) + case OpStore: + return rewriteValuedec_OpStore(v) + case OpStringLen: + return rewriteValuedec_OpStringLen(v) + case OpStringPtr: + return rewriteValuedec_OpStringPtr(v) + case OpStructMake: + return rewriteValuedec_OpStructMake(v) + case OpStructSelect: + return rewriteValuedec_OpStructSelect(v) + } + return false +} +func rewriteValuedec_OpArrayMake1(v *Value) bool { + v_0 := v.Args[0] + // match: (ArrayMake1 x) + // cond: x.Type.IsPtrShaped() + // result: x + for { + x := v_0 + if !(x.Type.IsPtrShaped()) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuedec_OpArraySelect(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (ArraySelect [0] x) + // cond: x.Type.IsPtrShaped() + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + x := v_0 + if !(x.Type.IsPtrShaped()) { + break + } + v.copyOf(x) + return true + } + // match: (ArraySelect (ArrayMake1 x)) + // result: x + for { + if v_0.Op != OpArrayMake1 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (ArraySelect [0] (IData x)) + // result: (IData x) + for { + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpIData { + break + } + x := v_0.Args[0] + v.reset(OpIData) + v.AddArg(x) + return true + } + // match: (ArraySelect [i] x:(Load ptr mem)) + // result: @x.Block (Load (OffPtr [t.Elem().Size()*i] ptr) mem) + for { + i := auxIntToInt64(v.AuxInt) + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, v.Type) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, v.Type.PtrTo()) + v1.AuxInt = int64ToAuxInt(t.Elem().Size() * i) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + return false +} +func rewriteValuedec_OpComplexImag(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ComplexImag (ComplexMake _ imag )) + // result: imag + for { + if v_0.Op != OpComplexMake { + break + } + imag := v_0.Args[1] + v.copyOf(imag) + return true + } + // match: (ComplexImag x:(Load ptr mem)) + // cond: t.IsComplex() && t.Size() == 8 + // result: @x.Block (Load (OffPtr [4] ptr) mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsComplex() && t.Size() == 8) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, typ.Float32) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, typ.Float32Ptr) + v1.AuxInt = int64ToAuxInt(4) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + // match: (ComplexImag x:(Load ptr mem)) + // cond: t.IsComplex() && t.Size() == 16 + // result: @x.Block (Load (OffPtr [8] ptr) mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsComplex() && t.Size() == 16) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, typ.Float64) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, typ.Float64Ptr) + v1.AuxInt = int64ToAuxInt(8) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + return false +} +func rewriteValuedec_OpComplexReal(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ComplexReal (ComplexMake real _ )) + // result: real + for { + if v_0.Op != OpComplexMake { + break + } + real := v_0.Args[0] + v.copyOf(real) + return true + } + // match: (ComplexReal x:(Load ptr mem)) + // cond: t.IsComplex() && t.Size() == 8 + // result: @x.Block (Load ptr mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsComplex() && t.Size() == 8) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, typ.Float32) + v.copyOf(v0) + v0.AddArg2(ptr, mem) + return true + } + // match: (ComplexReal x:(Load ptr mem)) + // cond: t.IsComplex() && t.Size() == 16 + // result: @x.Block (Load ptr mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsComplex() && t.Size() == 16) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, typ.Float64) + v.copyOf(v0) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuedec_OpIData(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (IData (IMake _ data)) + // cond: data.Op != OpStructMake && data.Op != OpArrayMake1 + // result: data + for { + if v_0.Op != OpIMake { + break + } + data := v_0.Args[1] + if !(data.Op != OpStructMake && data.Op != OpArrayMake1) { + break + } + v.copyOf(data) + return true + } + // match: (IData x:(Load ptr mem)) + // cond: t.IsInterface() + // result: @x.Block (Load (OffPtr [config.PtrSize] ptr) mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsInterface()) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr) + v1.AuxInt = int64ToAuxInt(config.PtrSize) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + return false +} +func rewriteValuedec_OpIMake(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (IMake _typ (StructMake ___)) + // result: imakeOfStructMake(v) + for { + if v_1.Op != OpStructMake { + break + } + v.copyOf(imakeOfStructMake(v)) + return true + } + // match: (IMake _typ (ArrayMake1 val)) + // result: (IMake _typ val) + for { + _typ := v_0 + if v_1.Op != OpArrayMake1 { + break + } + val := v_1.Args[0] + v.reset(OpIMake) + v.AddArg2(_typ, val) + return true + } + return false +} +func rewriteValuedec_OpITab(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ITab (IMake itab _)) + // result: itab + for { + if v_0.Op != OpIMake { + break + } + itab := v_0.Args[0] + v.copyOf(itab) + return true + } + // match: (ITab x:(Load ptr mem)) + // cond: t.IsInterface() + // result: @x.Block (Load ptr mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsInterface()) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, typ.Uintptr) + v.copyOf(v0) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuedec_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Load ptr mem) + // cond: t.IsComplex() && t.Size() == 8 + // result: (ComplexMake (Load ptr mem) (Load (OffPtr [4] ptr) mem) ) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsComplex() && t.Size() == 8) { + break + } + v.reset(OpComplexMake) + v0 := b.NewValue0(v.Pos, OpLoad, typ.Float32) + v0.AddArg2(ptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Float32) + v2 := b.NewValue0(v.Pos, OpOffPtr, typ.Float32Ptr) + v2.AuxInt = int64ToAuxInt(4) + v2.AddArg(ptr) + v1.AddArg2(v2, mem) + v.AddArg2(v0, v1) + return true + } + // match: (Load ptr mem) + // cond: t.IsComplex() && t.Size() == 16 + // result: (ComplexMake (Load ptr mem) (Load (OffPtr [8] ptr) mem) ) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsComplex() && t.Size() == 16) { + break + } + v.reset(OpComplexMake) + v0 := b.NewValue0(v.Pos, OpLoad, typ.Float64) + v0.AddArg2(ptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Float64) + v2 := b.NewValue0(v.Pos, OpOffPtr, typ.Float64Ptr) + v2.AuxInt = int64ToAuxInt(8) + v2.AddArg(ptr) + v1.AddArg2(v2, mem) + v.AddArg2(v0, v1) + return true + } + // match: (Load ptr mem) + // cond: t.IsString() + // result: (StringMake (Load ptr mem) (Load (OffPtr [config.PtrSize] ptr) mem)) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsString()) { + break + } + v.reset(OpStringMake) + v0 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr) + v0.AddArg2(ptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int) + v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr) + v2.AuxInt = int64ToAuxInt(config.PtrSize) + v2.AddArg(ptr) + v1.AddArg2(v2, mem) + v.AddArg2(v0, v1) + return true + } + // match: (Load ptr mem) + // cond: t.IsSlice() + // result: (SliceMake (Load ptr mem) (Load (OffPtr [config.PtrSize] ptr) mem) (Load (OffPtr [2*config.PtrSize] ptr) mem)) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsSlice()) { + break + } + v.reset(OpSliceMake) + v0 := b.NewValue0(v.Pos, OpLoad, t.Elem().PtrTo()) + v0.AddArg2(ptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int) + v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr) + v2.AuxInt = int64ToAuxInt(config.PtrSize) + v2.AddArg(ptr) + v1.AddArg2(v2, mem) + v3 := b.NewValue0(v.Pos, OpLoad, typ.Int) + v4 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr) + v4.AuxInt = int64ToAuxInt(2 * config.PtrSize) + v4.AddArg(ptr) + v3.AddArg2(v4, mem) + v.AddArg3(v0, v1, v3) + return true + } + // match: (Load ptr mem) + // cond: t.IsInterface() + // result: (IMake (Load ptr mem) (Load (OffPtr [config.PtrSize] ptr) mem)) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsInterface()) { + break + } + v.reset(OpIMake) + v0 := b.NewValue0(v.Pos, OpLoad, typ.Uintptr) + v0.AddArg2(ptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr) + v2 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr) + v2.AuxInt = int64ToAuxInt(config.PtrSize) + v2.AddArg(ptr) + v1.AddArg2(v2, mem) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValuedec_OpSliceCap(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (SliceCap (SliceMake _ _ cap)) + // result: cap + for { + if v_0.Op != OpSliceMake { + break + } + cap := v_0.Args[2] + v.copyOf(cap) + return true + } + // match: (SliceCap x:(Load ptr mem)) + // cond: t.IsSlice() + // result: @x.Block (Load (OffPtr [2*config.PtrSize] ptr) mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsSlice()) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, typ.Int) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr) + v1.AuxInt = int64ToAuxInt(2 * config.PtrSize) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + return false +} +func rewriteValuedec_OpSliceLen(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (SliceLen (SliceMake _ len _)) + // result: len + for { + if v_0.Op != OpSliceMake { + break + } + len := v_0.Args[1] + v.copyOf(len) + return true + } + // match: (SliceLen x:(Load ptr mem)) + // cond: t.IsSlice() + // result: @x.Block (Load (OffPtr [config.PtrSize] ptr) mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsSlice()) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, typ.Int) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr) + v1.AuxInt = int64ToAuxInt(config.PtrSize) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + return false +} +func rewriteValuedec_OpSlicePtr(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (SlicePtr (SliceMake ptr _ _ )) + // result: ptr + for { + if v_0.Op != OpSliceMake { + break + } + ptr := v_0.Args[0] + v.copyOf(ptr) + return true + } + // match: (SlicePtr x:(Load ptr mem)) + // cond: t.IsSlice() + // result: @x.Block (Load ptr mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsSlice()) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, t.Elem().PtrTo()) + v.copyOf(v0) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuedec_OpSlicePtrUnchecked(v *Value) bool { + v_0 := v.Args[0] + // match: (SlicePtrUnchecked (SliceMake ptr _ _ )) + // result: ptr + for { + if v_0.Op != OpSliceMake { + break + } + ptr := v_0.Args[0] + v.copyOf(ptr) + return true + } + return false +} +func rewriteValuedec_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Store {t} _ _ mem) + // cond: t.Size() == 0 + // result: mem + for { + t := auxToType(v.Aux) + mem := v_2 + if !(t.Size() == 0) { + break + } + v.copyOf(mem) + return true + } + // match: (Store {t} dst (ComplexMake real imag) mem) + // cond: t.Size() == 8 + // result: (Store {typ.Float32} (OffPtr [4] dst) imag (Store {typ.Float32} dst real mem)) + for { + t := auxToType(v.Aux) + dst := v_0 + if v_1.Op != OpComplexMake { + break + } + imag := v_1.Args[1] + real := v_1.Args[0] + mem := v_2 + if !(t.Size() == 8) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(typ.Float32) + v0 := b.NewValue0(v.Pos, OpOffPtr, typ.Float32Ptr) + v0.AuxInt = int64ToAuxInt(4) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(typ.Float32) + v1.AddArg3(dst, real, mem) + v.AddArg3(v0, imag, v1) + return true + } + // match: (Store {t} dst (ComplexMake real imag) mem) + // cond: t.Size() == 16 + // result: (Store {typ.Float64} (OffPtr [8] dst) imag (Store {typ.Float64} dst real mem)) + for { + t := auxToType(v.Aux) + dst := v_0 + if v_1.Op != OpComplexMake { + break + } + imag := v_1.Args[1] + real := v_1.Args[0] + mem := v_2 + if !(t.Size() == 16) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(typ.Float64) + v0 := b.NewValue0(v.Pos, OpOffPtr, typ.Float64Ptr) + v0.AuxInt = int64ToAuxInt(8) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(typ.Float64) + v1.AddArg3(dst, real, mem) + v.AddArg3(v0, imag, v1) + return true + } + // match: (Store dst (StringMake ptr len) mem) + // result: (Store {typ.Int} (OffPtr [config.PtrSize] dst) len (Store {typ.BytePtr} dst ptr mem)) + for { + dst := v_0 + if v_1.Op != OpStringMake { + break + } + len := v_1.Args[1] + ptr := v_1.Args[0] + mem := v_2 + v.reset(OpStore) + v.Aux = typeToAux(typ.Int) + v0 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr) + v0.AuxInt = int64ToAuxInt(config.PtrSize) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(typ.BytePtr) + v1.AddArg3(dst, ptr, mem) + v.AddArg3(v0, len, v1) + return true + } + // match: (Store {t} dst (SliceMake ptr len cap) mem) + // result: (Store {typ.Int} (OffPtr [2*config.PtrSize] dst) cap (Store {typ.Int} (OffPtr [config.PtrSize] dst) len (Store {t.Elem().PtrTo()} dst ptr mem))) + for { + t := auxToType(v.Aux) + dst := v_0 + if v_1.Op != OpSliceMake { + break + } + cap := v_1.Args[2] + ptr := v_1.Args[0] + len := v_1.Args[1] + mem := v_2 + v.reset(OpStore) + v.Aux = typeToAux(typ.Int) + v0 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr) + v0.AuxInt = int64ToAuxInt(2 * config.PtrSize) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(typ.Int) + v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr) + v2.AuxInt = int64ToAuxInt(config.PtrSize) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v3.Aux = typeToAux(t.Elem().PtrTo()) + v3.AddArg3(dst, ptr, mem) + v1.AddArg3(v2, len, v3) + v.AddArg3(v0, cap, v1) + return true + } + // match: (Store dst (IMake itab data) mem) + // result: (Store {typ.BytePtr} (OffPtr [config.PtrSize] dst) data (Store {typ.Uintptr} dst itab mem)) + for { + dst := v_0 + if v_1.Op != OpIMake { + break + } + data := v_1.Args[1] + itab := v_1.Args[0] + mem := v_2 + v.reset(OpStore) + v.Aux = typeToAux(typ.BytePtr) + v0 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr) + v0.AuxInt = int64ToAuxInt(config.PtrSize) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(typ.Uintptr) + v1.AddArg3(dst, itab, mem) + v.AddArg3(v0, data, v1) + return true + } + // match: (Store _ (StructMake ___) _) + // result: rewriteStructStore(v) + for { + if v_1.Op != OpStructMake { + break + } + v.copyOf(rewriteStructStore(v)) + return true + } + // match: (Store dst (ArrayMake1 e) mem) + // result: (Store {e.Type} dst e mem) + for { + dst := v_0 + if v_1.Op != OpArrayMake1 { + break + } + e := v_1.Args[0] + mem := v_2 + v.reset(OpStore) + v.Aux = typeToAux(e.Type) + v.AddArg3(dst, e, mem) + return true + } + return false +} +func rewriteValuedec_OpStringLen(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (StringLen (StringMake _ len)) + // result: len + for { + if v_0.Op != OpStringMake { + break + } + len := v_0.Args[1] + v.copyOf(len) + return true + } + // match: (StringLen x:(Load ptr mem)) + // cond: t.IsString() + // result: @x.Block (Load (OffPtr [config.PtrSize] ptr) mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsString()) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, typ.Int) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr) + v1.AuxInt = int64ToAuxInt(config.PtrSize) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + return false +} +func rewriteValuedec_OpStringPtr(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (StringPtr (StringMake ptr _)) + // result: ptr + for { + if v_0.Op != OpStringMake { + break + } + ptr := v_0.Args[0] + v.copyOf(ptr) + return true + } + // match: (StringPtr x:(Load ptr mem)) + // cond: t.IsString() + // result: @x.Block (Load ptr mem) + for { + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(t.IsString()) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr) + v.copyOf(v0) + v0.AddArg2(ptr, mem) + return true + } + return false +} +func rewriteValuedec_OpStructMake(v *Value) bool { + // match: (StructMake x) + // cond: x.Type.IsPtrShaped() + // result: x + for { + if len(v.Args) != 1 { + break + } + x := v.Args[0] + if !(x.Type.IsPtrShaped()) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuedec_OpStructSelect(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (StructSelect (IData x)) + // cond: v.Type.Size() > 0 + // result: (IData x) + for { + if v_0.Op != OpIData { + break + } + x := v_0.Args[0] + if !(v.Type.Size() > 0) { + break + } + v.reset(OpIData) + v.AddArg(x) + return true + } + // match: (StructSelect (IData x)) + // cond: v.Type.Size() == 0 + // result: (Empty) + for { + if v_0.Op != OpIData { + break + } + if !(v.Type.Size() == 0) { + break + } + v.reset(OpEmpty) + return true + } + // match: (StructSelect [i] x:(StructMake ___)) + // result: x.Args[i] + for { + i := auxIntToInt64(v.AuxInt) + x := v_0 + if x.Op != OpStructMake { + break + } + v.copyOf(x.Args[i]) + return true + } + // match: (StructSelect x) + // cond: x.Type.IsPtrShaped() + // result: x + for { + x := v_0 + if !(x.Type.IsPtrShaped()) { + break + } + v.copyOf(x) + return true + } + // match: (StructSelect [i] x:(Load ptr mem)) + // result: @x.Block (Load (OffPtr [t.FieldOff(int(i))] ptr) mem) + for { + i := auxIntToInt64(v.AuxInt) + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, v.Type) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, v.Type.PtrTo()) + v1.AuxInt = int64ToAuxInt(t.FieldOff(int(i))) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + return false +} +func rewriteBlockdec(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewritedec64.go b/go/src/cmd/compile/internal/ssa/rewritedec64.go new file mode 100644 index 0000000000000000000000000000000000000000..a0388551b5301581ecfaf3154d2fa5f7019a8840 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewritedec64.go @@ -0,0 +1,3216 @@ +// Code generated from _gen/dec64.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "cmd/compile/internal/types" + +func rewriteValuedec64(v *Value) bool { + switch v.Op { + case OpAdd64: + return rewriteValuedec64_OpAdd64(v) + case OpAnd64: + return rewriteValuedec64_OpAnd64(v) + case OpArg: + return rewriteValuedec64_OpArg(v) + case OpAvg64u: + return rewriteValuedec64_OpAvg64u(v) + case OpBitLen64: + return rewriteValuedec64_OpBitLen64(v) + case OpBswap64: + return rewriteValuedec64_OpBswap64(v) + case OpCom64: + return rewriteValuedec64_OpCom64(v) + case OpConst64: + return rewriteValuedec64_OpConst64(v) + case OpCtz64: + return rewriteValuedec64_OpCtz64(v) + case OpCtz64NonZero: + v.Op = OpCtz64 + return true + case OpEq64: + return rewriteValuedec64_OpEq64(v) + case OpHmul64: + return rewriteValuedec64_OpHmul64(v) + case OpHmul64u: + return rewriteValuedec64_OpHmul64u(v) + case OpInt64Hi: + return rewriteValuedec64_OpInt64Hi(v) + case OpInt64Lo: + return rewriteValuedec64_OpInt64Lo(v) + case OpLast: + return rewriteValuedec64_OpLast(v) + case OpLeq64: + return rewriteValuedec64_OpLeq64(v) + case OpLeq64U: + return rewriteValuedec64_OpLeq64U(v) + case OpLess64: + return rewriteValuedec64_OpLess64(v) + case OpLess64U: + return rewriteValuedec64_OpLess64U(v) + case OpLoad: + return rewriteValuedec64_OpLoad(v) + case OpLsh16x64: + return rewriteValuedec64_OpLsh16x64(v) + case OpLsh32x64: + return rewriteValuedec64_OpLsh32x64(v) + case OpLsh64x16: + return rewriteValuedec64_OpLsh64x16(v) + case OpLsh64x32: + return rewriteValuedec64_OpLsh64x32(v) + case OpLsh64x64: + return rewriteValuedec64_OpLsh64x64(v) + case OpLsh64x8: + return rewriteValuedec64_OpLsh64x8(v) + case OpLsh8x64: + return rewriteValuedec64_OpLsh8x64(v) + case OpMul64: + return rewriteValuedec64_OpMul64(v) + case OpMul64uhilo: + return rewriteValuedec64_OpMul64uhilo(v) + case OpNeg64: + return rewriteValuedec64_OpNeg64(v) + case OpNeq64: + return rewriteValuedec64_OpNeq64(v) + case OpOr32: + return rewriteValuedec64_OpOr32(v) + case OpOr64: + return rewriteValuedec64_OpOr64(v) + case OpRotateLeft16: + return rewriteValuedec64_OpRotateLeft16(v) + case OpRotateLeft32: + return rewriteValuedec64_OpRotateLeft32(v) + case OpRotateLeft64: + return rewriteValuedec64_OpRotateLeft64(v) + case OpRotateLeft8: + return rewriteValuedec64_OpRotateLeft8(v) + case OpRsh16Ux64: + return rewriteValuedec64_OpRsh16Ux64(v) + case OpRsh16x64: + return rewriteValuedec64_OpRsh16x64(v) + case OpRsh32Ux64: + return rewriteValuedec64_OpRsh32Ux64(v) + case OpRsh32x64: + return rewriteValuedec64_OpRsh32x64(v) + case OpRsh64Ux16: + return rewriteValuedec64_OpRsh64Ux16(v) + case OpRsh64Ux32: + return rewriteValuedec64_OpRsh64Ux32(v) + case OpRsh64Ux64: + return rewriteValuedec64_OpRsh64Ux64(v) + case OpRsh64Ux8: + return rewriteValuedec64_OpRsh64Ux8(v) + case OpRsh64x16: + return rewriteValuedec64_OpRsh64x16(v) + case OpRsh64x32: + return rewriteValuedec64_OpRsh64x32(v) + case OpRsh64x64: + return rewriteValuedec64_OpRsh64x64(v) + case OpRsh64x8: + return rewriteValuedec64_OpRsh64x8(v) + case OpRsh8Ux64: + return rewriteValuedec64_OpRsh8Ux64(v) + case OpRsh8x64: + return rewriteValuedec64_OpRsh8x64(v) + case OpSelect0: + return rewriteValuedec64_OpSelect0(v) + case OpSelect1: + return rewriteValuedec64_OpSelect1(v) + case OpSignExt16to64: + return rewriteValuedec64_OpSignExt16to64(v) + case OpSignExt32to64: + return rewriteValuedec64_OpSignExt32to64(v) + case OpSignExt8to64: + return rewriteValuedec64_OpSignExt8to64(v) + case OpStore: + return rewriteValuedec64_OpStore(v) + case OpSub64: + return rewriteValuedec64_OpSub64(v) + case OpTrunc64to16: + return rewriteValuedec64_OpTrunc64to16(v) + case OpTrunc64to32: + return rewriteValuedec64_OpTrunc64to32(v) + case OpTrunc64to8: + return rewriteValuedec64_OpTrunc64to8(v) + case OpXor64: + return rewriteValuedec64_OpXor64(v) + case OpZeroExt16to64: + return rewriteValuedec64_OpZeroExt16to64(v) + case OpZeroExt32to64: + return rewriteValuedec64_OpZeroExt32to64(v) + case OpZeroExt8to64: + return rewriteValuedec64_OpZeroExt8to64(v) + } + return false +} +func rewriteValuedec64_OpAdd64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Add64 x y) + // result: (Last x0: (Int64Lo x) x1: (Int64Hi x) y0: (Int64Lo y) y1: (Int64Hi y) add: (Add32carry x0 y0) (Int64Make (Add32withcarry x1 y1 (Select1 add)) (Select0 add))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpLast) + v.Type = t + x0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + x0.AddArg(x) + x1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + x1.AddArg(x) + y0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + y0.AddArg(y) + y1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + y1.AddArg(y) + add := b.NewValue0(v.Pos, OpAdd32carry, types.NewTuple(typ.UInt32, types.TypeFlags)) + add.AddArg2(x0, y0) + v5 := b.NewValue0(v.Pos, OpInt64Make, typ.UInt64) + v6 := b.NewValue0(v.Pos, OpAdd32withcarry, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v7.AddArg(add) + v6.AddArg3(x1, y1, v7) + v8 := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + v8.AddArg(add) + v5.AddArg2(v6, v8) + v.AddArg6(x0, x1, y0, y1, add, v5) + return true + } +} +func rewriteValuedec64_OpAnd64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (And64 x y) + // result: (Int64Make (And32 (Int64Hi x) (Int64Hi y)) (And32 (Int64Lo x) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v4.AddArg(x) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(y) + v3.AddArg2(v4, v5) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValuedec64_OpArg(v *Value) bool { + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Arg {n} [off]) + // cond: is64BitInt(v.Type) && !config.BigEndian && v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin") + // result: (Int64Make (Arg {n} [off+4]) (Arg {n} [off])) + for { + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) + if !(is64BitInt(v.Type) && !config.BigEndian && v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpArg, typ.Int32) + v0.AuxInt = int32ToAuxInt(off + 4) + v0.Aux = symToAux(n) + v1 := b.NewValue0(v.Pos, OpArg, typ.UInt32) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(n) + v.AddArg2(v0, v1) + return true + } + // match: (Arg {n} [off]) + // cond: is64BitInt(v.Type) && !config.BigEndian && !v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin") + // result: (Int64Make (Arg {n} [off+4]) (Arg {n} [off])) + for { + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) + if !(is64BitInt(v.Type) && !config.BigEndian && !v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpArg, typ.UInt32) + v0.AuxInt = int32ToAuxInt(off + 4) + v0.Aux = symToAux(n) + v1 := b.NewValue0(v.Pos, OpArg, typ.UInt32) + v1.AuxInt = int32ToAuxInt(off) + v1.Aux = symToAux(n) + v.AddArg2(v0, v1) + return true + } + // match: (Arg {n} [off]) + // cond: is64BitInt(v.Type) && config.BigEndian && v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin") + // result: (Int64Make (Arg {n} [off]) (Arg {n} [off+4])) + for { + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) + if !(is64BitInt(v.Type) && config.BigEndian && v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpArg, typ.Int32) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(n) + v1 := b.NewValue0(v.Pos, OpArg, typ.UInt32) + v1.AuxInt = int32ToAuxInt(off + 4) + v1.Aux = symToAux(n) + v.AddArg2(v0, v1) + return true + } + // match: (Arg {n} [off]) + // cond: is64BitInt(v.Type) && config.BigEndian && !v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin") + // result: (Int64Make (Arg {n} [off]) (Arg {n} [off+4])) + for { + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) + if !(is64BitInt(v.Type) && config.BigEndian && !v.Type.IsSigned() && !(b.Func.pass.name == "decompose builtin")) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpArg, typ.UInt32) + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(n) + v1 := b.NewValue0(v.Pos, OpArg, typ.UInt32) + v1.AuxInt = int32ToAuxInt(off + 4) + v1.Aux = symToAux(n) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValuedec64_OpAvg64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Avg64u x y) + // result: (Add64 (Rsh64Ux32 (Sub64 x y) (Const32 [1])) y) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpAdd64) + v0 := b.NewValue0(v.Pos, OpRsh64Ux32, t) + v1 := b.NewValue0(v.Pos, OpSub64, t) + v1.AddArg2(x, y) + v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v2.AuxInt = int32ToAuxInt(1) + v0.AddArg2(v1, v2) + v.AddArg2(v0, y) + return true + } +} +func rewriteValuedec64_OpBitLen64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (BitLen64 x) + // result: (Add32 (BitLen32 (Int64Hi x)) (BitLen32 (Or32 (Int64Lo x) (Zeromask (Int64Hi x))))) + for { + x := v_0 + v.reset(OpAdd32) + v.Type = typ.Int + v0 := b.NewValue0(v.Pos, OpBitLen32, typ.Int) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpBitLen32, typ.Int) + v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v4.AddArg(x) + v5 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v5.AddArg(v1) + v3.AddArg2(v4, v5) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValuedec64_OpBswap64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Bswap64 x) + // result: (Int64Make (Bswap32 (Int64Lo x)) (Bswap32 (Int64Hi x))) + for { + x := v_0 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpBswap32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v1.AddArg(x) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpBswap32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v3.AddArg(x) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValuedec64_OpCom64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Com64 x) + // result: (Int64Make (Com32 (Int64Hi x)) (Com32 (Int64Lo x))) + for { + x := v_0 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpCom32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpCom32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(x) + v2.AddArg(v3) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValuedec64_OpConst64(v *Value) bool { + b := v.Block + typ := &b.Func.Config.Types + // match: (Const64 [c]) + // cond: t.IsSigned() + // result: (Int64Make (Const32 [int32(c>>32)]) (Const32 [int32(c)])) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if !(t.IsSigned()) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v0.AuxInt = int32ToAuxInt(int32(c >> 32)) + v1 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v1.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(v0, v1) + return true + } + // match: (Const64 [c]) + // cond: !t.IsSigned() + // result: (Int64Make (Const32 [int32(c>>32)]) (Const32 [int32(c)])) + for { + t := v.Type + c := auxIntToInt64(v.AuxInt) + if !(!t.IsSigned()) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v0.AuxInt = int32ToAuxInt(int32(c >> 32)) + v1 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v1.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValuedec64_OpCtz64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Ctz64 x) + // result: (Add32 (Ctz32 (Int64Lo x)) (And32 (Com32 (Zeromask (Int64Lo x))) (Ctz32 (Int64Hi x)))) + for { + x := v_0 + v.reset(OpAdd32) + v.Type = typ.UInt32 + v0 := b.NewValue0(v.Pos, OpCtz32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v1.AddArg(x) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpCom32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v4.AddArg(v1) + v3.AddArg(v4) + v5 := b.NewValue0(v.Pos, OpCtz32, typ.UInt32) + v6 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v6.AddArg(x) + v5.AddArg(v6) + v2.AddArg2(v3, v5) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValuedec64_OpEq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Eq64 x y) + // result: (AndB (Eq32 (Int64Hi x) (Int64Hi y)) (Eq32 (Int64Lo x) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpAndB) + v0 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v4.AddArg(x) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(y) + v3.AddArg2(v4, v5) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValuedec64_OpHmul64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul64 x y) + // result: (Last p: (Hmul64u x y) xSign: (Int64Make xs:(Rsh32x32 (Int64Hi x) (Const32 [31])) xs) ySign: (Int64Make ys:(Rsh32x32 (Int64Hi y) (Const32 [31])) ys) (Sub64 (Sub64 p (And64 xSign y)) (And64 ySign x))) + for { + x := v_0 + y := v_1 + v.reset(OpLast) + p := b.NewValue0(v.Pos, OpHmul64u, typ.UInt64) + p.AddArg2(x, y) + xSign := b.NewValue0(v.Pos, OpInt64Make, typ.UInt64) + xs := b.NewValue0(v.Pos, OpRsh32x32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v4.AuxInt = int32ToAuxInt(31) + xs.AddArg2(v3, v4) + xSign.AddArg2(xs, xs) + ySign := b.NewValue0(v.Pos, OpInt64Make, typ.UInt64) + ys := b.NewValue0(v.Pos, OpRsh32x32, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v7.AddArg(y) + ys.AddArg2(v7, v4) + ySign.AddArg2(ys, ys) + v8 := b.NewValue0(v.Pos, OpSub64, typ.Int64) + v9 := b.NewValue0(v.Pos, OpSub64, typ.Int64) + v10 := b.NewValue0(v.Pos, OpAnd64, typ.Int64) + v10.AddArg2(xSign, y) + v9.AddArg2(p, v10) + v11 := b.NewValue0(v.Pos, OpAnd64, typ.Int64) + v11.AddArg2(ySign, x) + v8.AddArg2(v9, v11) + v.AddArg4(p, xSign, ySign, v8) + return true + } +} +func rewriteValuedec64_OpHmul64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Hmul64u x y) + // result: (Select0 (Mul64uhilo x y)) + for { + x := v_0 + y := v_1 + v.reset(OpSelect0) + v0 := b.NewValue0(v.Pos, OpMul64uhilo, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } +} +func rewriteValuedec64_OpInt64Hi(v *Value) bool { + v_0 := v.Args[0] + // match: (Int64Hi (Int64Make hi _)) + // result: hi + for { + if v_0.Op != OpInt64Make { + break + } + hi := v_0.Args[0] + v.copyOf(hi) + return true + } + return false +} +func rewriteValuedec64_OpInt64Lo(v *Value) bool { + v_0 := v.Args[0] + // match: (Int64Lo (Int64Make _ lo)) + // result: lo + for { + if v_0.Op != OpInt64Make { + break + } + lo := v_0.Args[1] + v.copyOf(lo) + return true + } + return false +} +func rewriteValuedec64_OpLast(v *Value) bool { + // match: (Last ___) + // result: v.Args[len(v.Args)-1] + for { + v.copyOf(v.Args[len(v.Args)-1]) + return true + } +} +func rewriteValuedec64_OpLeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64 x y) + // result: (OrB (Less32 (Int64Hi x) (Int64Hi y)) (AndB (Eq32 (Int64Hi x) (Int64Hi y)) (Leq32U (Int64Lo x) (Int64Lo y)))) + for { + x := v_0 + y := v_1 + v.reset(OpOrB) + v0 := b.NewValue0(v.Pos, OpLess32, typ.Bool) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpAndB, typ.Bool) + v4 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v4.AddArg2(v1, v2) + v5 := b.NewValue0(v.Pos, OpLeq32U, typ.Bool) + v6 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v6.AddArg(x) + v7 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v7.AddArg(y) + v5.AddArg2(v6, v7) + v3.AddArg2(v4, v5) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValuedec64_OpLeq64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Leq64U x y) + // result: (OrB (Less32U (Int64Hi x) (Int64Hi y)) (AndB (Eq32 (Int64Hi x) (Int64Hi y)) (Leq32U (Int64Lo x) (Int64Lo y)))) + for { + x := v_0 + y := v_1 + v.reset(OpOrB) + v0 := b.NewValue0(v.Pos, OpLess32U, typ.Bool) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpAndB, typ.Bool) + v4 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v4.AddArg2(v1, v2) + v5 := b.NewValue0(v.Pos, OpLeq32U, typ.Bool) + v6 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v6.AddArg(x) + v7 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v7.AddArg(y) + v5.AddArg2(v6, v7) + v3.AddArg2(v4, v5) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValuedec64_OpLess64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less64 x y) + // result: (OrB (Less32 (Int64Hi x) (Int64Hi y)) (AndB (Eq32 (Int64Hi x) (Int64Hi y)) (Less32U (Int64Lo x) (Int64Lo y)))) + for { + x := v_0 + y := v_1 + v.reset(OpOrB) + v0 := b.NewValue0(v.Pos, OpLess32, typ.Bool) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpAndB, typ.Bool) + v4 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v4.AddArg2(v1, v2) + v5 := b.NewValue0(v.Pos, OpLess32U, typ.Bool) + v6 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v6.AddArg(x) + v7 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v7.AddArg(y) + v5.AddArg2(v6, v7) + v3.AddArg2(v4, v5) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValuedec64_OpLess64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Less64U x y) + // result: (OrB (Less32U (Int64Hi x) (Int64Hi y)) (AndB (Eq32 (Int64Hi x) (Int64Hi y)) (Less32U (Int64Lo x) (Int64Lo y)))) + for { + x := v_0 + y := v_1 + v.reset(OpOrB) + v0 := b.NewValue0(v.Pos, OpLess32U, typ.Bool) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpAndB, typ.Bool) + v4 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v4.AddArg2(v1, v2) + v5 := b.NewValue0(v.Pos, OpLess32U, typ.Bool) + v6 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v6.AddArg(x) + v7 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v7.AddArg(y) + v5.AddArg2(v6, v7) + v3.AddArg2(v4, v5) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValuedec64_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Load ptr mem) + // cond: is64BitInt(t) && !config.BigEndian && t.IsSigned() + // result: (Int64Make (Load (OffPtr [4] ptr) mem) (Load ptr mem)) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) && !config.BigEndian && t.IsSigned()) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v1 := b.NewValue0(v.Pos, OpOffPtr, typ.Int32Ptr) + v1.AuxInt = int64ToAuxInt(4) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + v2 := b.NewValue0(v.Pos, OpLoad, typ.UInt32) + v2.AddArg2(ptr, mem) + v.AddArg2(v0, v2) + return true + } + // match: (Load ptr mem) + // cond: is64BitInt(t) && !config.BigEndian && !t.IsSigned() + // result: (Int64Make (Load (OffPtr [4] ptr) mem) (Load ptr mem)) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) && !config.BigEndian && !t.IsSigned()) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpLoad, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpOffPtr, typ.UInt32Ptr) + v1.AuxInt = int64ToAuxInt(4) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + v2 := b.NewValue0(v.Pos, OpLoad, typ.UInt32) + v2.AddArg2(ptr, mem) + v.AddArg2(v0, v2) + return true + } + // match: (Load ptr mem) + // cond: is64BitInt(t) && config.BigEndian && t.IsSigned() + // result: (Int64Make (Load ptr mem) (Load (OffPtr [4] ptr) mem)) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) && config.BigEndian && t.IsSigned()) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v0.AddArg2(ptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpOffPtr, typ.UInt32Ptr) + v2.AuxInt = int64ToAuxInt(4) + v2.AddArg(ptr) + v1.AddArg2(v2, mem) + v.AddArg2(v0, v1) + return true + } + // match: (Load ptr mem) + // cond: is64BitInt(t) && config.BigEndian && !t.IsSigned() + // result: (Int64Make (Load ptr mem) (Load (OffPtr [4] ptr) mem)) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(is64BitInt(t) && config.BigEndian && !t.IsSigned()) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpLoad, typ.UInt32) + v0.AddArg2(ptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpOffPtr, typ.UInt32Ptr) + v2.AuxInt = int64ToAuxInt(4) + v2.AddArg(ptr) + v1.AddArg2(v2, mem) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValuedec64_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x64 _ (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Const32 [0]) + for { + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Lsh16x64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Lsh16x32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpLsh16x32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Lsh16x64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Lsh16x32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpLsh16x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Lsh16x64 x y) + // result: (Lsh16x32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpLsh16x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x64 _ (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Const32 [0]) + for { + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Lsh32x64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Lsh32x32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpLsh32x32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Lsh32x64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Lsh32x32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpLsh32x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Lsh32x64 x y) + // result: (Lsh32x32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpLsh32x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpLsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x16 x s) + // result: (Int64Make (Or32 (Or32 (Lsh32x16 (Int64Hi x) s) (Rsh32Ux16 (Int64Lo x) (Sub16 (Const16 [32]) s))) (Lsh32x16 (Int64Lo x) (Sub16 s (Const16 [32])))) (Lsh32x16 (Int64Lo x) s)) + for { + x := v_0 + s := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpLsh32x16, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v3.AddArg(x) + v2.AddArg2(v3, s) + v4 := b.NewValue0(v.Pos, OpRsh32Ux16, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpSub16, typ.UInt16) + v7 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) + v7.AuxInt = int16ToAuxInt(32) + v6.AddArg2(v7, s) + v4.AddArg2(v5, v6) + v1.AddArg2(v2, v4) + v8 := b.NewValue0(v.Pos, OpLsh32x16, typ.UInt32) + v9 := b.NewValue0(v.Pos, OpSub16, typ.UInt16) + v9.AddArg2(s, v7) + v8.AddArg2(v5, v9) + v0.AddArg2(v1, v8) + v10 := b.NewValue0(v.Pos, OpLsh32x16, typ.UInt32) + v10.AddArg2(v5, s) + v.AddArg2(v0, v10) + return true + } +} +func rewriteValuedec64_OpLsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x32 x s) + // result: (Int64Make (Or32 (Or32 (Lsh32x32 (Int64Hi x) s) (Rsh32Ux32 (Int64Lo x) (Sub32 (Const32 [32]) s))) (Lsh32x32 (Int64Lo x) (Sub32 s (Const32 [32])))) (Lsh32x32 (Int64Lo x) s)) + for { + x := v_0 + s := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v3.AddArg(x) + v2.AddArg2(v3, s) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpSub32, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v7.AuxInt = int32ToAuxInt(32) + v6.AddArg2(v7, s) + v4.AddArg2(v5, v6) + v1.AddArg2(v2, v4) + v8 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v9 := b.NewValue0(v.Pos, OpSub32, typ.UInt32) + v9.AddArg2(s, v7) + v8.AddArg2(v5, v9) + v0.AddArg2(v1, v8) + v10 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v10.AddArg2(v5, s) + v.AddArg2(v0, v10) + return true + } +} +func rewriteValuedec64_OpLsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x64 _ (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Const64 [0]) + for { + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Lsh64x64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Lsh64x32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpLsh64x32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Lsh64x64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Lsh64x32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpLsh64x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Lsh64x64 x y) + // result: (Lsh64x32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpLsh64x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpLsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x8 x s) + // result: (Int64Make (Or32 (Or32 (Lsh32x8 (Int64Hi x) s) (Rsh32Ux8 (Int64Lo x) (Sub8 (Const8 [32]) s))) (Lsh32x8 (Int64Lo x) (Sub8 s (Const8 [32])))) (Lsh32x8 (Int64Lo x) s)) + for { + x := v_0 + s := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpLsh32x8, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v3.AddArg(x) + v2.AddArg2(v3, s) + v4 := b.NewValue0(v.Pos, OpRsh32Ux8, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpSub8, typ.UInt8) + v7 := b.NewValue0(v.Pos, OpConst8, typ.UInt8) + v7.AuxInt = int8ToAuxInt(32) + v6.AddArg2(v7, s) + v4.AddArg2(v5, v6) + v1.AddArg2(v2, v4) + v8 := b.NewValue0(v.Pos, OpLsh32x8, typ.UInt32) + v9 := b.NewValue0(v.Pos, OpSub8, typ.UInt8) + v9.AddArg2(s, v7) + v8.AddArg2(v5, v9) + v0.AddArg2(v1, v8) + v10 := b.NewValue0(v.Pos, OpLsh32x8, typ.UInt32) + v10.AddArg2(v5, s) + v.AddArg2(v0, v10) + return true + } +} +func rewriteValuedec64_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x64 _ (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Const32 [0]) + for { + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Lsh8x64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Lsh8x32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpLsh8x32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Lsh8x64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Lsh8x32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpLsh8x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Lsh8x64 x y) + // result: (Lsh8x32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpLsh8x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpMul64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul64 x y) + // result: (Last x0: (Int64Lo x) x1: (Int64Hi x) y0: (Int64Lo y) y1: (Int64Hi y) x0y0: (Mul32uhilo x0 y0) x0y0Hi: (Select0 x0y0) x0y0Lo: (Select1 x0y0) (Int64Make (Add32 x0y0Hi (Add32 (Mul32 x0 y1) (Mul32 x1 y0))) x0y0Lo)) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpLast) + v.Type = t + x0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + x0.AddArg(x) + x1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + x1.AddArg(x) + y0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + y0.AddArg(y) + y1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + y1.AddArg(y) + x0y0 := b.NewValue0(v.Pos, OpMul32uhilo, types.NewTuple(typ.UInt32, typ.UInt32)) + x0y0.AddArg2(x0, y0) + x0y0Hi := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + x0y0Hi.AddArg(x0y0) + x0y0Lo := b.NewValue0(v.Pos, OpSelect1, typ.UInt32) + x0y0Lo.AddArg(x0y0) + v7 := b.NewValue0(v.Pos, OpInt64Make, typ.UInt64) + v8 := b.NewValue0(v.Pos, OpAdd32, typ.UInt32) + v9 := b.NewValue0(v.Pos, OpAdd32, typ.UInt32) + v10 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) + v10.AddArg2(x0, y1) + v11 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) + v11.AddArg2(x1, y0) + v9.AddArg2(v10, v11) + v8.AddArg2(x0y0Hi, v9) + v7.AddArg2(v8, x0y0Lo) + v.AddArgs(x0, x1, y0, y1, x0y0, x0y0Hi, x0y0Lo, v7) + return true + } +} +func rewriteValuedec64_OpMul64uhilo(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul64uhilo x y) + // result: (Last x0: (Int64Lo x) x1: (Int64Hi x) y0: (Int64Lo y) y1: (Int64Hi y) x0y0: (Mul32uhilo x0 y0) x0y1: (Mul32uhilo x0 y1) x1y0: (Mul32uhilo x1 y0) x1y1: (Mul32uhilo x1 y1) x0y0Hi: (Select0 x0y0) x0y0Lo: (Select1 x0y0) x0y1Hi: (Select0 x0y1) x0y1Lo: (Select1 x0y1) x1y0Hi: (Select0 x1y0) x1y0Lo: (Select1 x1y0) x1y1Hi: (Select0 x1y1) x1y1Lo: (Select1 x1y1) w1a: (Add32carry x0y0Hi x0y1Lo) w2a: (Add32carrywithcarry x0y1Hi x1y0Hi (Select1 w1a)) w3a: (Add32withcarry x1y1Hi (Const32 [0]) (Select1 w2a)) w1b: (Add32carry x1y0Lo (Select0 w1a)) w2b: (Add32carrywithcarry x1y1Lo (Select0 w2a) (Select1 w1b)) w3b: (Add32withcarry w3a (Const32 [0]) (Select1 w2b)) (MakeTuple (Int64Make w3b (Select0 w2b)) (Int64Make (Select0 w1b) x0y0Lo))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpLast) + v.Type = t + x0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + x0.AddArg(x) + x1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + x1.AddArg(x) + y0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + y0.AddArg(y) + y1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + y1.AddArg(y) + x0y0 := b.NewValue0(v.Pos, OpMul32uhilo, types.NewTuple(typ.UInt32, typ.UInt32)) + x0y0.AddArg2(x0, y0) + x0y1 := b.NewValue0(v.Pos, OpMul32uhilo, types.NewTuple(typ.UInt32, typ.UInt32)) + x0y1.AddArg2(x0, y1) + x1y0 := b.NewValue0(v.Pos, OpMul32uhilo, types.NewTuple(typ.UInt32, typ.UInt32)) + x1y0.AddArg2(x1, y0) + x1y1 := b.NewValue0(v.Pos, OpMul32uhilo, types.NewTuple(typ.UInt32, typ.UInt32)) + x1y1.AddArg2(x1, y1) + x0y0Hi := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + x0y0Hi.AddArg(x0y0) + x0y0Lo := b.NewValue0(v.Pos, OpSelect1, typ.UInt32) + x0y0Lo.AddArg(x0y0) + x0y1Hi := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + x0y1Hi.AddArg(x0y1) + x0y1Lo := b.NewValue0(v.Pos, OpSelect1, typ.UInt32) + x0y1Lo.AddArg(x0y1) + x1y0Hi := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + x1y0Hi.AddArg(x1y0) + x1y0Lo := b.NewValue0(v.Pos, OpSelect1, typ.UInt32) + x1y0Lo.AddArg(x1y0) + x1y1Hi := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + x1y1Hi.AddArg(x1y1) + x1y1Lo := b.NewValue0(v.Pos, OpSelect1, typ.UInt32) + x1y1Lo.AddArg(x1y1) + w1a := b.NewValue0(v.Pos, OpAdd32carry, types.NewTuple(typ.UInt32, types.TypeFlags)) + w1a.AddArg2(x0y0Hi, x0y1Lo) + w2a := b.NewValue0(v.Pos, OpAdd32carrywithcarry, types.NewTuple(typ.UInt32, types.TypeFlags)) + v18 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v18.AddArg(w1a) + w2a.AddArg3(x0y1Hi, x1y0Hi, v18) + w3a := b.NewValue0(v.Pos, OpAdd32withcarry, typ.UInt32) + v20 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v20.AuxInt = int32ToAuxInt(0) + v21 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v21.AddArg(w2a) + w3a.AddArg3(x1y1Hi, v20, v21) + w1b := b.NewValue0(v.Pos, OpAdd32carry, types.NewTuple(typ.UInt32, types.TypeFlags)) + v23 := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + v23.AddArg(w1a) + w1b.AddArg2(x1y0Lo, v23) + w2b := b.NewValue0(v.Pos, OpAdd32carrywithcarry, types.NewTuple(typ.UInt32, types.TypeFlags)) + v25 := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + v25.AddArg(w2a) + v26 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v26.AddArg(w1b) + w2b.AddArg3(x1y1Lo, v25, v26) + w3b := b.NewValue0(v.Pos, OpAdd32withcarry, typ.UInt32) + v28 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v28.AddArg(w2b) + w3b.AddArg3(w3a, v20, v28) + v29 := b.NewValue0(v.Pos, OpMakeTuple, types.NewTuple(typ.UInt64, typ.UInt64)) + v30 := b.NewValue0(v.Pos, OpInt64Make, typ.UInt64) + v31 := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + v31.AddArg(w2b) + v30.AddArg2(w3b, v31) + v32 := b.NewValue0(v.Pos, OpInt64Make, typ.UInt64) + v33 := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + v33.AddArg(w1b) + v32.AddArg2(v33, x0y0Lo) + v29.AddArg2(v30, v32) + v.AddArgs(x0, x1, y0, y1, x0y0, x0y1, x1y0, x1y1, x0y0Hi, x0y0Lo, x0y1Hi, x0y1Lo, x1y0Hi, x1y0Lo, x1y1Hi, x1y1Lo, w1a, w2a, w3a, w1b, w2b, w3b, v29) + return true + } +} +func rewriteValuedec64_OpNeg64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Neg64 x) + // result: (Sub64 (Const64 [0]) x) + for { + t := v.Type + x := v_0 + v.reset(OpSub64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValuedec64_OpNeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Neq64 x y) + // result: (OrB (Neq32 (Int64Hi x) (Int64Hi y)) (Neq32 (Int64Lo x) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpOrB) + v0 := b.NewValue0(v.Pos, OpNeq32, typ.Bool) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpNeq32, typ.Bool) + v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v4.AddArg(x) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(y) + v3.AddArg2(v4, v5) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValuedec64_OpOr32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Or32 (Zeromask (Const32 [c])) y) + // cond: c == 0 + // result: y + for { + if v.Type != typ.UInt32 { + break + } + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeromask { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + y := v_1 + if !(c == 0) { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (Or32 (Zeromask (Const32 [c])) y) + // cond: c != 0 + // result: (Const32 [-1]) + for { + if v.Type != typ.UInt32 { + break + } + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeromask { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if !(c != 0) { + continue + } + v.reset(OpConst32) + v.Type = typ.UInt32 + v.AuxInt = int32ToAuxInt(-1) + return true + } + break + } + return false +} +func rewriteValuedec64_OpOr64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Or64 x y) + // result: (Int64Make (Or32 (Int64Hi x) (Int64Hi y)) (Or32 (Int64Lo x) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v4.AddArg(x) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(y) + v3.AddArg2(v4, v5) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValuedec64_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RotateLeft16 x (Int64Make hi lo)) + // result: (RotateLeft16 x lo) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v.reset(OpRotateLeft16) + v.AddArg2(x, lo) + return true + } + return false +} +func rewriteValuedec64_OpRotateLeft32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RotateLeft32 x (Int64Make hi lo)) + // result: (RotateLeft32 x lo) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v.reset(OpRotateLeft32) + v.AddArg2(x, lo) + return true + } + return false +} +func rewriteValuedec64_OpRotateLeft64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (RotateLeft64 x (Int64Make hi lo)) + // result: (RotateLeft64 x lo) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v.reset(OpRotateLeft64) + v.AddArg2(x, lo) + return true + } + // match: (RotateLeft64 x (Const64 [c])) + // cond: c&63 == 0 + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&63 == 0) { + break + } + v.copyOf(x) + return true + } + // match: (RotateLeft64 x (Const32 [c])) + // cond: c&63 == 0 + // result: x + for { + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c&63 == 0) { + break + } + v.copyOf(x) + return true + } + // match: (RotateLeft64 x (Const16 [c])) + // cond: c&63 == 0 + // result: x + for { + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(c&63 == 0) { + break + } + v.copyOf(x) + return true + } + // match: (RotateLeft64 x (Const8 [c])) + // cond: c&63 == 0 + // result: x + for { + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(c&63 == 0) { + break + } + v.copyOf(x) + return true + } + // match: (RotateLeft64 x (Const64 [c])) + // cond: c&63 == 32 + // result: (Int64Make (Int64Lo x) (Int64Hi x)) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c&63 == 32) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } + // match: (RotateLeft64 x (Const32 [c])) + // cond: c&63 == 32 + // result: (Int64Make (Int64Lo x) (Int64Hi x)) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c&63 == 32) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } + // match: (RotateLeft64 x (Const16 [c])) + // cond: c&63 == 32 + // result: (Int64Make (Int64Lo x) (Int64Hi x)) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(c&63 == 32) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } + // match: (RotateLeft64 x (Const8 [c])) + // cond: c&63 == 32 + // result: (Int64Make (Int64Lo x) (Int64Hi x)) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(c&63 == 32) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v.AddArg2(v0, v1) + return true + } + // match: (RotateLeft64 x (Const64 [c])) + // cond: 0 < c&63 && c&63 < 32 + // result: (Int64Make (Or32 (Lsh32x32 (Int64Hi x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Lo x) (Const32 [int32(32-c&31)]))) (Or32 (Lsh32x32 (Int64Lo x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Hi x) (Const32 [int32(32-c&31)])))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(0 < c&63 && c&63 < 32) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(c & 31)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v6.AuxInt = int32ToAuxInt(int32(32 - c&31)) + v4.AddArg2(v5, v6) + v0.AddArg2(v1, v4) + v7 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v8.AddArg2(v5, v3) + v9 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v9.AddArg2(v2, v6) + v7.AddArg2(v8, v9) + v.AddArg2(v0, v7) + return true + } + // match: (RotateLeft64 x (Const32 [c])) + // cond: 0 < c&63 && c&63 < 32 + // result: (Int64Make (Or32 (Lsh32x32 (Int64Hi x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Lo x) (Const32 [int32(32-c&31)]))) (Or32 (Lsh32x32 (Int64Lo x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Hi x) (Const32 [int32(32-c&31)])))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(0 < c&63 && c&63 < 32) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(c & 31)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v6.AuxInt = int32ToAuxInt(int32(32 - c&31)) + v4.AddArg2(v5, v6) + v0.AddArg2(v1, v4) + v7 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v8.AddArg2(v5, v3) + v9 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v9.AddArg2(v2, v6) + v7.AddArg2(v8, v9) + v.AddArg2(v0, v7) + return true + } + // match: (RotateLeft64 x (Const16 [c])) + // cond: 0 < c&63 && c&63 < 32 + // result: (Int64Make (Or32 (Lsh32x32 (Int64Hi x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Lo x) (Const32 [int32(32-c&31)]))) (Or32 (Lsh32x32 (Int64Lo x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Hi x) (Const32 [int32(32-c&31)])))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(0 < c&63 && c&63 < 32) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(c & 31)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v6.AuxInt = int32ToAuxInt(int32(32 - c&31)) + v4.AddArg2(v5, v6) + v0.AddArg2(v1, v4) + v7 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v8.AddArg2(v5, v3) + v9 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v9.AddArg2(v2, v6) + v7.AddArg2(v8, v9) + v.AddArg2(v0, v7) + return true + } + // match: (RotateLeft64 x (Const8 [c])) + // cond: 0 < c&63 && c&63 < 32 + // result: (Int64Make (Or32 (Lsh32x32 (Int64Hi x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Lo x) (Const32 [int32(32-c&31)]))) (Or32 (Lsh32x32 (Int64Lo x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Hi x) (Const32 [int32(32-c&31)])))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(0 < c&63 && c&63 < 32) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(c & 31)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v6.AuxInt = int32ToAuxInt(int32(32 - c&31)) + v4.AddArg2(v5, v6) + v0.AddArg2(v1, v4) + v7 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v8.AddArg2(v5, v3) + v9 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v9.AddArg2(v2, v6) + v7.AddArg2(v8, v9) + v.AddArg2(v0, v7) + return true + } + // match: (RotateLeft64 x (Const64 [c])) + // cond: 32 < c&63 && c&63 < 64 + // result: (Int64Make (Or32 (Lsh32x32 (Int64Lo x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Hi x) (Const32 [int32(32-c&31)]))) (Or32 (Lsh32x32 (Int64Hi x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Lo x) (Const32 [int32(32-c&31)])))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(32 < c&63 && c&63 < 64) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(c & 31)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v6.AuxInt = int32ToAuxInt(int32(32 - c&31)) + v4.AddArg2(v5, v6) + v0.AddArg2(v1, v4) + v7 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v8.AddArg2(v5, v3) + v9 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v9.AddArg2(v2, v6) + v7.AddArg2(v8, v9) + v.AddArg2(v0, v7) + return true + } + // match: (RotateLeft64 x (Const32 [c])) + // cond: 32 < c&63 && c&63 < 64 + // result: (Int64Make (Or32 (Lsh32x32 (Int64Lo x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Hi x) (Const32 [int32(32-c&31)]))) (Or32 (Lsh32x32 (Int64Hi x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Lo x) (Const32 [int32(32-c&31)])))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(32 < c&63 && c&63 < 64) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(c & 31)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v6.AuxInt = int32ToAuxInt(int32(32 - c&31)) + v4.AddArg2(v5, v6) + v0.AddArg2(v1, v4) + v7 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v8.AddArg2(v5, v3) + v9 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v9.AddArg2(v2, v6) + v7.AddArg2(v8, v9) + v.AddArg2(v0, v7) + return true + } + // match: (RotateLeft64 x (Const16 [c])) + // cond: 32 < c&63 && c&63 < 64 + // result: (Int64Make (Or32 (Lsh32x32 (Int64Lo x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Hi x) (Const32 [int32(32-c&31)]))) (Or32 (Lsh32x32 (Int64Hi x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Lo x) (Const32 [int32(32-c&31)])))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(32 < c&63 && c&63 < 64) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(c & 31)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v6.AuxInt = int32ToAuxInt(int32(32 - c&31)) + v4.AddArg2(v5, v6) + v0.AddArg2(v1, v4) + v7 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v8.AddArg2(v5, v3) + v9 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v9.AddArg2(v2, v6) + v7.AddArg2(v8, v9) + v.AddArg2(v0, v7) + return true + } + // match: (RotateLeft64 x (Const8 [c])) + // cond: 32 < c&63 && c&63 < 64 + // result: (Int64Make (Or32 (Lsh32x32 (Int64Lo x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Hi x) (Const32 [int32(32-c&31)]))) (Or32 (Lsh32x32 (Int64Hi x) (Const32 [int32(c&31)])) (Rsh32Ux32 (Int64Lo x) (Const32 [int32(32-c&31)])))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(32 < c&63 && c&63 < 64) { + break + } + v.reset(OpInt64Make) + v.Type = t + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(c & 31)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v5.AddArg(x) + v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v6.AuxInt = int32ToAuxInt(int32(32 - c&31)) + v4.AddArg2(v5, v6) + v0.AddArg2(v1, v4) + v7 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v8.AddArg2(v5, v3) + v9 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v9.AddArg2(v2, v6) + v7.AddArg2(v8, v9) + v.AddArg2(v0, v7) + return true + } + return false +} +func rewriteValuedec64_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (RotateLeft8 x (Int64Make hi lo)) + // result: (RotateLeft8 x lo) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v.reset(OpRotateLeft8) + v.AddArg2(x, lo) + return true + } + return false +} +func rewriteValuedec64_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 _ (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Const32 [0]) + for { + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh16Ux64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Rsh16Ux32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpRsh16Ux32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Rsh16Ux64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Rsh16Ux32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpRsh16Ux32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16Ux64 x y) + // result: (Rsh16Ux32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpRsh16Ux32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 x (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Signmask (SignExt16to32 x)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpSignmask) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh16x64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Rsh16x32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpRsh16x32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Rsh16x64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Rsh16x32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpRsh16x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x64 x y) + // result: (Rsh16x32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpRsh16x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux64 _ (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Const32 [0]) + for { + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh32Ux64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Rsh32Ux32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpRsh32Ux32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Rsh32Ux64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Rsh32Ux32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpRsh32Ux32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32Ux64 x y) + // result: (Rsh32Ux32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpRsh32Ux32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x64 x (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Signmask x) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpSignmask) + v.AddArg(x) + return true + } + // match: (Rsh32x64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Rsh32x32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpRsh32x32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Rsh32x64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Rsh32x32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpRsh32x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x64 x y) + // result: (Rsh32x32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpRsh32x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpRsh64Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux16 x s) + // result: (Int64Make (Rsh32Ux16 (Int64Hi x) s) (Or32 (Or32 (Rsh32Ux16 (Int64Lo x) s) (Lsh32x16 (Int64Hi x) (Sub16 (Const16 [32]) s))) (Rsh32Ux16 (Int64Hi x) (Sub16 s (Const16 [32]))))) + for { + x := v_0 + s := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpRsh32Ux16, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, s) + v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpRsh32Ux16, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v4.AddArg2(v5, s) + v6 := b.NewValue0(v.Pos, OpLsh32x16, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpSub16, typ.UInt16) + v8 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) + v8.AuxInt = int16ToAuxInt(32) + v7.AddArg2(v8, s) + v6.AddArg2(v1, v7) + v3.AddArg2(v4, v6) + v9 := b.NewValue0(v.Pos, OpRsh32Ux16, typ.UInt32) + v10 := b.NewValue0(v.Pos, OpSub16, typ.UInt16) + v10.AddArg2(s, v8) + v9.AddArg2(v1, v10) + v2.AddArg2(v3, v9) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValuedec64_OpRsh64Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux32 x s) + // result: (Int64Make (Rsh32Ux32 (Int64Hi x) s) (Or32 (Or32 (Rsh32Ux32 (Int64Lo x) s) (Lsh32x32 (Int64Hi x) (Sub32 (Const32 [32]) s))) (Rsh32Ux32 (Int64Hi x) (Sub32 s (Const32 [32]))))) + for { + x := v_0 + s := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, s) + v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v4.AddArg2(v5, s) + v6 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpSub32, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v8.AuxInt = int32ToAuxInt(32) + v7.AddArg2(v8, s) + v6.AddArg2(v1, v7) + v3.AddArg2(v4, v6) + v9 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v10 := b.NewValue0(v.Pos, OpSub32, typ.UInt32) + v10.AddArg2(s, v8) + v9.AddArg2(v1, v10) + v2.AddArg2(v3, v9) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValuedec64_OpRsh64Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux64 _ (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Const64 [0]) + for { + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64Ux64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Rsh64Ux32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpRsh64Ux32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Rsh64Ux64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Rsh64Ux32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpRsh64Ux32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64Ux64 x y) + // result: (Rsh64Ux32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpRsh64Ux32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpRsh64Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux8 x s) + // result: (Int64Make (Rsh32Ux8 (Int64Hi x) s) (Or32 (Or32 (Rsh32Ux8 (Int64Lo x) s) (Lsh32x8 (Int64Hi x) (Sub8 (Const8 [32]) s))) (Rsh32Ux8 (Int64Hi x) (Sub8 s (Const8 [32]))))) + for { + x := v_0 + s := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpRsh32Ux8, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, s) + v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpRsh32Ux8, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v4.AddArg2(v5, s) + v6 := b.NewValue0(v.Pos, OpLsh32x8, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpSub8, typ.UInt8) + v8 := b.NewValue0(v.Pos, OpConst8, typ.UInt8) + v8.AuxInt = int8ToAuxInt(32) + v7.AddArg2(v8, s) + v6.AddArg2(v1, v7) + v3.AddArg2(v4, v6) + v9 := b.NewValue0(v.Pos, OpRsh32Ux8, typ.UInt32) + v10 := b.NewValue0(v.Pos, OpSub8, typ.UInt8) + v10.AddArg2(s, v8) + v9.AddArg2(v1, v10) + v2.AddArg2(v3, v9) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValuedec64_OpRsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x16 x s) + // result: (Int64Make (Rsh32x16 (Int64Hi x) s) (Or32 (Or32 (Rsh32Ux16 (Int64Lo x) s) (Lsh32x16 (Int64Hi x) (Sub16 (Const16 [32]) s))) (And32 (Rsh32x16 (Int64Hi x) (Sub16 s (Const16 [32]))) (Zeromask (ZeroExt16to32 (Rsh16Ux32 s (Const32 [5]))))))) + for { + x := v_0 + s := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpRsh32x16, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, s) + v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpRsh32Ux16, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v4.AddArg2(v5, s) + v6 := b.NewValue0(v.Pos, OpLsh32x16, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpSub16, typ.UInt16) + v8 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) + v8.AuxInt = int16ToAuxInt(32) + v7.AddArg2(v8, s) + v6.AddArg2(v1, v7) + v3.AddArg2(v4, v6) + v9 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32) + v10 := b.NewValue0(v.Pos, OpRsh32x16, typ.UInt32) + v11 := b.NewValue0(v.Pos, OpSub16, typ.UInt16) + v11.AddArg2(s, v8) + v10.AddArg2(v1, v11) + v12 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v13 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v14 := b.NewValue0(v.Pos, OpRsh16Ux32, typ.UInt16) + v15 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v15.AuxInt = int32ToAuxInt(5) + v14.AddArg2(s, v15) + v13.AddArg(v14) + v12.AddArg(v13) + v9.AddArg2(v10, v12) + v2.AddArg2(v3, v9) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValuedec64_OpRsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x32 x s) + // result: (Int64Make (Rsh32x32 (Int64Hi x) s) (Or32 (Or32 (Rsh32Ux32 (Int64Lo x) s) (Lsh32x32 (Int64Hi x) (Sub32 (Const32 [32]) s))) (And32 (Rsh32x32 (Int64Hi x) (Sub32 s (Const32 [32]))) (Zeromask (Rsh32Ux32 s (Const32 [5])))))) + for { + x := v_0 + s := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpRsh32x32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, s) + v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v4.AddArg2(v5, s) + v6 := b.NewValue0(v.Pos, OpLsh32x32, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpSub32, typ.UInt32) + v8 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v8.AuxInt = int32ToAuxInt(32) + v7.AddArg2(v8, s) + v6.AddArg2(v1, v7) + v3.AddArg2(v4, v6) + v9 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32) + v10 := b.NewValue0(v.Pos, OpRsh32x32, typ.UInt32) + v11 := b.NewValue0(v.Pos, OpSub32, typ.UInt32) + v11.AddArg2(s, v8) + v10.AddArg2(v1, v11) + v12 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v13 := b.NewValue0(v.Pos, OpRsh32Ux32, typ.UInt32) + v14 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v14.AuxInt = int32ToAuxInt(5) + v13.AddArg2(s, v14) + v12.AddArg(v13) + v9.AddArg2(v10, v12) + v2.AddArg2(v3, v9) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValuedec64_OpRsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x64 x (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Int64Make (Signmask (Int64Hi x)) (Signmask (Int64Hi x))) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpSignmask, typ.Int32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v0.AddArg(v1) + v.AddArg2(v0, v0) + return true + } + // match: (Rsh64x64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Rsh64x32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpRsh64x32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Rsh64x64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Rsh64x32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpRsh64x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x64 x y) + // result: (Rsh64x32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpRsh64x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpRsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x8 x s) + // result: (Int64Make (Rsh32x8 (Int64Hi x) s) (Or32 (Or32 (Rsh32Ux8 (Int64Lo x) s) (Lsh32x8 (Int64Hi x) (Sub8 (Const8 [32]) s))) (And32 (Rsh32x8 (Int64Hi x) (Sub8 s (Const8 [32]))) (Zeromask (ZeroExt8to32 (Rsh8Ux32 s (Const32 [5]))))))) + for { + x := v_0 + s := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpRsh32x8, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v0.AddArg2(v1, s) + v2 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpRsh32Ux8, typ.UInt32) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(x) + v4.AddArg2(v5, s) + v6 := b.NewValue0(v.Pos, OpLsh32x8, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpSub8, typ.UInt8) + v8 := b.NewValue0(v.Pos, OpConst8, typ.UInt8) + v8.AuxInt = int8ToAuxInt(32) + v7.AddArg2(v8, s) + v6.AddArg2(v1, v7) + v3.AddArg2(v4, v6) + v9 := b.NewValue0(v.Pos, OpAnd32, typ.UInt32) + v10 := b.NewValue0(v.Pos, OpRsh32x8, typ.UInt32) + v11 := b.NewValue0(v.Pos, OpSub8, typ.UInt8) + v11.AddArg2(s, v8) + v10.AddArg2(v1, v11) + v12 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v13 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v14 := b.NewValue0(v.Pos, OpRsh8Ux32, typ.UInt8) + v15 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v15.AuxInt = int32ToAuxInt(5) + v14.AddArg2(s, v15) + v13.AddArg(v14) + v12.AddArg(v13) + v9.AddArg2(v10, v12) + v2.AddArg2(v3, v9) + v.AddArg2(v0, v2) + return true + } +} +func rewriteValuedec64_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 _ (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Const32 [0]) + for { + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh8Ux64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Rsh8Ux32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpRsh8Ux32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Rsh8Ux64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Rsh8Ux32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpRsh8Ux32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8Ux64 x y) + // result: (Rsh8Ux32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpRsh8Ux32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8x64 x (Int64Make (Const32 [c]) _)) + // cond: c != 0 + // result: (Signmask (SignExt8to32 x)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpSignmask) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh8x64 [c] x (Int64Make (Const32 [0]) lo)) + // result: (Rsh8x32 [c] x lo) + for { + c := auxIntToBool(v.AuxInt) + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || auxIntToInt32(v_1_0.AuxInt) != 0 { + break + } + v.reset(OpRsh8x32) + v.AuxInt = boolToAuxInt(c) + v.AddArg2(x, lo) + return true + } + // match: (Rsh8x64 x (Int64Make hi lo)) + // cond: hi.Op != OpConst32 + // result: (Rsh8x32 x (Or32 (Zeromask hi) lo)) + for { + x := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + if !(hi.Op != OpConst32) { + break + } + v.reset(OpRsh8x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v1.AddArg(hi) + v0.AddArg2(v1, lo) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x64 x y) + // result: (Rsh8x32 x (Or32 (Zeromask (Int64Hi y)) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpRsh8x32) + v0 := b.NewValue0(v.Pos, OpOr32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeromask, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v1.AddArg(v2) + v3 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v3.AddArg(y) + v0.AddArg2(v1, v3) + v.AddArg2(x, v0) + return true + } +} +func rewriteValuedec64_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + // match: (Select0 (MakeTuple x y)) + // result: x + for { + if v_0.Op != OpMakeTuple { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValuedec64_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + // match: (Select1 (MakeTuple x y)) + // result: y + for { + if v_0.Op != OpMakeTuple { + break + } + y := v_0.Args[1] + v.copyOf(y) + return true + } + return false +} +func rewriteValuedec64_OpSignExt16to64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SignExt16to64 x) + // result: (SignExt32to64 (SignExt16to32 x)) + for { + x := v_0 + v.reset(OpSignExt32to64) + v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuedec64_OpSignExt32to64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SignExt32to64 x) + // result: (Int64Make (Signmask x) x) + for { + x := v_0 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpSignmask, typ.Int32) + v0.AddArg(x) + v.AddArg2(v0, x) + return true + } +} +func rewriteValuedec64_OpSignExt8to64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (SignExt8to64 x) + // result: (SignExt32to64 (SignExt8to32 x)) + for { + x := v_0 + v.reset(OpSignExt32to64) + v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuedec64_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Store {t} dst (Int64Make hi lo) mem) + // cond: t.Size() == 8 && !config.BigEndian + // result: (Store {hi.Type} (OffPtr [4] dst) hi (Store {lo.Type} dst lo mem)) + for { + t := auxToType(v.Aux) + dst := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + mem := v_2 + if !(t.Size() == 8 && !config.BigEndian) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(hi.Type) + v0 := b.NewValue0(v.Pos, OpOffPtr, hi.Type.PtrTo()) + v0.AuxInt = int64ToAuxInt(4) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(lo.Type) + v1.AddArg3(dst, lo, mem) + v.AddArg3(v0, hi, v1) + return true + } + // match: (Store {t} dst (Int64Make hi lo) mem) + // cond: t.Size() == 8 && config.BigEndian + // result: (Store {lo.Type} (OffPtr [4] dst) lo (Store {hi.Type} dst hi mem)) + for { + t := auxToType(v.Aux) + dst := v_0 + if v_1.Op != OpInt64Make { + break + } + lo := v_1.Args[1] + hi := v_1.Args[0] + mem := v_2 + if !(t.Size() == 8 && config.BigEndian) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(lo.Type) + v0 := b.NewValue0(v.Pos, OpOffPtr, lo.Type.PtrTo()) + v0.AuxInt = int64ToAuxInt(4) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(hi.Type) + v1.AddArg3(dst, hi, mem) + v.AddArg3(v0, lo, v1) + return true + } + return false +} +func rewriteValuedec64_OpSub64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Sub64 x y) + // result: (Last x0: (Int64Lo x) x1: (Int64Hi x) y0: (Int64Lo y) y1: (Int64Hi y) sub: (Sub32carry x0 y0) (Int64Make (Sub32withcarry x1 y1 (Select1 sub)) (Select0 sub))) + for { + t := v.Type + x := v_0 + y := v_1 + v.reset(OpLast) + v.Type = t + x0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + x0.AddArg(x) + x1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + x1.AddArg(x) + y0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + y0.AddArg(y) + y1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + y1.AddArg(y) + sub := b.NewValue0(v.Pos, OpSub32carry, types.NewTuple(typ.UInt32, types.TypeFlags)) + sub.AddArg2(x0, y0) + v5 := b.NewValue0(v.Pos, OpInt64Make, typ.UInt64) + v6 := b.NewValue0(v.Pos, OpSub32withcarry, typ.UInt32) + v7 := b.NewValue0(v.Pos, OpSelect1, types.TypeFlags) + v7.AddArg(sub) + v6.AddArg3(x1, y1, v7) + v8 := b.NewValue0(v.Pos, OpSelect0, typ.UInt32) + v8.AddArg(sub) + v5.AddArg2(v6, v8) + v.AddArg6(x0, x1, y0, y1, sub, v5) + return true + } +} +func rewriteValuedec64_OpTrunc64to16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Trunc64to16 (Int64Make _ lo)) + // result: (Trunc32to16 lo) + for { + if v_0.Op != OpInt64Make { + break + } + lo := v_0.Args[1] + v.reset(OpTrunc32to16) + v.AddArg(lo) + return true + } + // match: (Trunc64to16 x) + // result: (Trunc32to16 (Int64Lo x)) + for { + x := v_0 + v.reset(OpTrunc32to16) + v0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuedec64_OpTrunc64to32(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc64to32 (Int64Make _ lo)) + // result: lo + for { + if v_0.Op != OpInt64Make { + break + } + lo := v_0.Args[1] + v.copyOf(lo) + return true + } + // match: (Trunc64to32 x) + // result: (Int64Lo x) + for { + x := v_0 + v.reset(OpInt64Lo) + v.AddArg(x) + return true + } +} +func rewriteValuedec64_OpTrunc64to8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Trunc64to8 (Int64Make _ lo)) + // result: (Trunc32to8 lo) + for { + if v_0.Op != OpInt64Make { + break + } + lo := v_0.Args[1] + v.reset(OpTrunc32to8) + v.AddArg(lo) + return true + } + // match: (Trunc64to8 x) + // result: (Trunc32to8 (Int64Lo x)) + for { + x := v_0 + v.reset(OpTrunc32to8) + v0 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuedec64_OpXor64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Xor64 x y) + // result: (Int64Make (Xor32 (Int64Hi x) (Int64Hi y)) (Xor32 (Int64Lo x) (Int64Lo y))) + for { + x := v_0 + y := v_1 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpXor32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpInt64Hi, typ.UInt32) + v2.AddArg(y) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpXor32, typ.UInt32) + v4 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v4.AddArg(x) + v5 := b.NewValue0(v.Pos, OpInt64Lo, typ.UInt32) + v5.AddArg(y) + v3.AddArg2(v4, v5) + v.AddArg2(v0, v3) + return true + } +} +func rewriteValuedec64_OpZeroExt16to64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ZeroExt16to64 x) + // result: (ZeroExt32to64 (ZeroExt16to32 x)) + for { + x := v_0 + v.reset(OpZeroExt32to64) + v0 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteValuedec64_OpZeroExt32to64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ZeroExt32to64 x) + // result: (Int64Make (Const32 [0]) x) + for { + x := v_0 + v.reset(OpInt64Make) + v0 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, x) + return true + } +} +func rewriteValuedec64_OpZeroExt8to64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (ZeroExt8to64 x) + // result: (ZeroExt32to64 (ZeroExt8to32 x)) + for { + x := v_0 + v.reset(OpZeroExt32to64) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } +} +func rewriteBlockdec64(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewritedivisible.go b/go/src/cmd/compile/internal/ssa/rewritedivisible.go new file mode 100644 index 0000000000000000000000000000000000000000..b9c077af0f474bc18778ed0218bb094f2ee1d632 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewritedivisible.go @@ -0,0 +1,1532 @@ +// Code generated from _gen/divisible.rules using 'go generate'; DO NOT EDIT. + +package ssa + +func rewriteValuedivisible(v *Value) bool { + switch v.Op { + case OpEq16: + return rewriteValuedivisible_OpEq16(v) + case OpEq32: + return rewriteValuedivisible_OpEq32(v) + case OpEq64: + return rewriteValuedivisible_OpEq64(v) + case OpEq8: + return rewriteValuedivisible_OpEq8(v) + case OpNeq16: + return rewriteValuedivisible_OpNeq16(v) + case OpNeq32: + return rewriteValuedivisible_OpNeq32(v) + case OpNeq64: + return rewriteValuedivisible_OpNeq64(v) + case OpNeq8: + return rewriteValuedivisible_OpNeq8(v) + } + return false +} +func rewriteValuedivisible_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq16 x (Mul16 (Div16u x (Const16 [c])) (Const16 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Eq16 (And16 x (Const16 [c-1])) (Const16 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul16 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv16u { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst16 || auxIntToInt16(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpAnd16, t) + v1 := b.NewValue0(v.Pos, OpConst16, t) + v1.AuxInt = int16ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq16 x (Mul16 (Div16 x (Const16 [c])) (Const16 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Eq16 (And16 x (Const16 [c-1])) (Const16 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul16 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv16 { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst16 || auxIntToInt16(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpAnd16, t) + v1 := b.NewValue0(v.Pos, OpConst16, t) + v1.AuxInt = int16ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq16 x (Mul16 div:(Div16u x (Const16 [c])) (Const16 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst16 && udivisibleOK16(c) + // result: (Leq16U (RotateLeft16 (Mul16 x (Const16 [int16(udivisible16(c).m)])) (Const16 [int16(16 - udivisible16(c).k)])) (Const16 [int16(udivisible16(c).max)])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul16 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv16u { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(div_1.AuxInt) + if v_1_1.Op != OpConst16 || auxIntToInt16(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst16 && udivisibleOK16(c)) { + continue + } + v.reset(OpLeq16U) + v0 := b.NewValue0(v.Pos, OpRotateLeft16, t) + v1 := b.NewValue0(v.Pos, OpMul16, t) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(int16(udivisible16(c).m)) + v1.AddArg2(x, v2) + v3 := b.NewValue0(v.Pos, OpConst16, t) + v3.AuxInt = int16ToAuxInt(int16(16 - udivisible16(c).k)) + v0.AddArg2(v1, v3) + v4 := b.NewValue0(v.Pos, OpConst16, t) + v4.AuxInt = int16ToAuxInt(int16(udivisible16(c).max)) + v.AddArg2(v0, v4) + return true + } + } + break + } + // match: (Eq16 x (Mul16 div:(Div16 x (Const16 [c])) (Const16 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst16 && sdivisibleOK16(c) + // result: (Leq16U (RotateLeft16 (Add16 (Mul16 x (Const16 [int16(sdivisible16(c).m)])) (Const16 [int16(sdivisible16(c).a)])) (Const16 [int16(16 - sdivisible16(c).k)])) (Const16 [int16(sdivisible16(c).max)])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul16 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv16 { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(div_1.AuxInt) + if v_1_1.Op != OpConst16 || auxIntToInt16(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst16 && sdivisibleOK16(c)) { + continue + } + v.reset(OpLeq16U) + v0 := b.NewValue0(v.Pos, OpRotateLeft16, t) + v1 := b.NewValue0(v.Pos, OpAdd16, t) + v2 := b.NewValue0(v.Pos, OpMul16, t) + v3 := b.NewValue0(v.Pos, OpConst16, t) + v3.AuxInt = int16ToAuxInt(int16(sdivisible16(c).m)) + v2.AddArg2(x, v3) + v4 := b.NewValue0(v.Pos, OpConst16, t) + v4.AuxInt = int16ToAuxInt(int16(sdivisible16(c).a)) + v1.AddArg2(v2, v4) + v5 := b.NewValue0(v.Pos, OpConst16, t) + v5.AuxInt = int16ToAuxInt(int16(16 - sdivisible16(c).k)) + v0.AddArg2(v1, v5) + v6 := b.NewValue0(v.Pos, OpConst16, t) + v6.AuxInt = int16ToAuxInt(int16(sdivisible16(c).max)) + v.AddArg2(v0, v6) + return true + } + } + break + } + return false +} +func rewriteValuedivisible_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32 x (Mul32 (Div32u x (Const32 [c])) (Const32 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Eq32 (And32 x (Const32 [c-1])) (Const32 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul32 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv32u { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst32 || auxIntToInt32(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpAnd32, t) + v1 := b.NewValue0(v.Pos, OpConst32, t) + v1.AuxInt = int32ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq32 x (Mul32 (Div32 x (Const32 [c])) (Const32 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Eq32 (And32 x (Const32 [c-1])) (Const32 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul32 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv32 { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst32 || auxIntToInt32(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpAnd32, t) + v1 := b.NewValue0(v.Pos, OpConst32, t) + v1.AuxInt = int32ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq32 x (Mul32 div:(Div32u x (Const32 [c])) (Const32 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst32 && udivisibleOK32(c) + // result: (Leq32U (RotateLeft32 (Mul32 x (Const32 [int32(udivisible32(c).m)])) (Const32 [int32(32 - udivisible32(c).k)])) (Const32 [int32(udivisible32(c).max)])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul32 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv32u { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(div_1.AuxInt) + if v_1_1.Op != OpConst32 || auxIntToInt32(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst32 && udivisibleOK32(c)) { + continue + } + v.reset(OpLeq32U) + v0 := b.NewValue0(v.Pos, OpRotateLeft32, t) + v1 := b.NewValue0(v.Pos, OpMul32, t) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(int32(udivisible32(c).m)) + v1.AddArg2(x, v2) + v3 := b.NewValue0(v.Pos, OpConst32, t) + v3.AuxInt = int32ToAuxInt(int32(32 - udivisible32(c).k)) + v0.AddArg2(v1, v3) + v4 := b.NewValue0(v.Pos, OpConst32, t) + v4.AuxInt = int32ToAuxInt(int32(udivisible32(c).max)) + v.AddArg2(v0, v4) + return true + } + } + break + } + // match: (Eq32 x (Mul32 div:(Div32 x (Const32 [c])) (Const32 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst32 && sdivisibleOK32(c) + // result: (Leq32U (RotateLeft32 (Add32 (Mul32 x (Const32 [int32(sdivisible32(c).m)])) (Const32 [int32(sdivisible32(c).a)])) (Const32 [int32(32 - sdivisible32(c).k)])) (Const32 [int32(sdivisible32(c).max)])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul32 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv32 { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(div_1.AuxInt) + if v_1_1.Op != OpConst32 || auxIntToInt32(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst32 && sdivisibleOK32(c)) { + continue + } + v.reset(OpLeq32U) + v0 := b.NewValue0(v.Pos, OpRotateLeft32, t) + v1 := b.NewValue0(v.Pos, OpAdd32, t) + v2 := b.NewValue0(v.Pos, OpMul32, t) + v3 := b.NewValue0(v.Pos, OpConst32, t) + v3.AuxInt = int32ToAuxInt(int32(sdivisible32(c).m)) + v2.AddArg2(x, v3) + v4 := b.NewValue0(v.Pos, OpConst32, t) + v4.AuxInt = int32ToAuxInt(int32(sdivisible32(c).a)) + v1.AddArg2(v2, v4) + v5 := b.NewValue0(v.Pos, OpConst32, t) + v5.AuxInt = int32ToAuxInt(int32(32 - sdivisible32(c).k)) + v0.AddArg2(v1, v5) + v6 := b.NewValue0(v.Pos, OpConst32, t) + v6.AuxInt = int32ToAuxInt(int32(sdivisible32(c).max)) + v.AddArg2(v0, v6) + return true + } + } + break + } + return false +} +func rewriteValuedivisible_OpEq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64 x (Mul64 (Div64u x (Const64 [c])) (Const64 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Eq64 (And64 x (Const64 [c-1])) (Const64 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul64 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv64u { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst64 || auxIntToInt64(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpAnd64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq64 x (Mul64 (Div64 x (Const64 [c])) (Const64 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Eq64 (And64 x (Const64 [c-1])) (Const64 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul64 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv64 { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst64 || auxIntToInt64(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpAnd64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq64 x (Mul64 div:(Div64u x (Const64 [c])) (Const64 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst64 && udivisibleOK64(c) + // result: (Leq64U (RotateLeft64 (Mul64 x (Const64 [int64(udivisible64(c).m)])) (Const64 [int64(64 - udivisible64(c).k)])) (Const64 [int64(udivisible64(c).max)])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul64 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv64u { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(div_1.AuxInt) + if v_1_1.Op != OpConst64 || auxIntToInt64(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst64 && udivisibleOK64(c)) { + continue + } + v.reset(OpLeq64U) + v0 := b.NewValue0(v.Pos, OpRotateLeft64, t) + v1 := b.NewValue0(v.Pos, OpMul64, t) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(int64(udivisible64(c).m)) + v1.AddArg2(x, v2) + v3 := b.NewValue0(v.Pos, OpConst64, t) + v3.AuxInt = int64ToAuxInt(int64(64 - udivisible64(c).k)) + v0.AddArg2(v1, v3) + v4 := b.NewValue0(v.Pos, OpConst64, t) + v4.AuxInt = int64ToAuxInt(int64(udivisible64(c).max)) + v.AddArg2(v0, v4) + return true + } + } + break + } + // match: (Eq64 x (Mul64 div:(Div64 x (Const64 [c])) (Const64 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst64 && sdivisibleOK64(c) + // result: (Leq64U (RotateLeft64 (Add64 (Mul64 x (Const64 [int64(sdivisible64(c).m)])) (Const64 [int64(sdivisible64(c).a)])) (Const64 [int64(64 - sdivisible64(c).k)])) (Const64 [int64(sdivisible64(c).max)])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul64 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv64 { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(div_1.AuxInt) + if v_1_1.Op != OpConst64 || auxIntToInt64(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst64 && sdivisibleOK64(c)) { + continue + } + v.reset(OpLeq64U) + v0 := b.NewValue0(v.Pos, OpRotateLeft64, t) + v1 := b.NewValue0(v.Pos, OpAdd64, t) + v2 := b.NewValue0(v.Pos, OpMul64, t) + v3 := b.NewValue0(v.Pos, OpConst64, t) + v3.AuxInt = int64ToAuxInt(int64(sdivisible64(c).m)) + v2.AddArg2(x, v3) + v4 := b.NewValue0(v.Pos, OpConst64, t) + v4.AuxInt = int64ToAuxInt(int64(sdivisible64(c).a)) + v1.AddArg2(v2, v4) + v5 := b.NewValue0(v.Pos, OpConst64, t) + v5.AuxInt = int64ToAuxInt(int64(64 - sdivisible64(c).k)) + v0.AddArg2(v1, v5) + v6 := b.NewValue0(v.Pos, OpConst64, t) + v6.AuxInt = int64ToAuxInt(int64(sdivisible64(c).max)) + v.AddArg2(v0, v6) + return true + } + } + break + } + return false +} +func rewriteValuedivisible_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq8 x (Mul8 (Div8u x (Const8 [c])) (Const8 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Eq8 (And8 x (Const8 [c-1])) (Const8 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul8 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv8u { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst8 || auxIntToInt8(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpAnd8, t) + v1 := b.NewValue0(v.Pos, OpConst8, t) + v1.AuxInt = int8ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq8 x (Mul8 (Div8 x (Const8 [c])) (Const8 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Eq8 (And8 x (Const8 [c-1])) (Const8 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul8 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv8 { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst8 || auxIntToInt8(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpAnd8, t) + v1 := b.NewValue0(v.Pos, OpConst8, t) + v1.AuxInt = int8ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq8 x (Mul8 div:(Div8u x (Const8 [c])) (Const8 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst8 && udivisibleOK8(c) + // result: (Leq8U (RotateLeft8 (Mul8 x (Const8 [int8(udivisible8(c).m)])) (Const8 [int8(8 - udivisible8(c).k)])) (Const8 [int8(udivisible8(c).max)])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul8 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv8u { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(div_1.AuxInt) + if v_1_1.Op != OpConst8 || auxIntToInt8(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst8 && udivisibleOK8(c)) { + continue + } + v.reset(OpLeq8U) + v0 := b.NewValue0(v.Pos, OpRotateLeft8, t) + v1 := b.NewValue0(v.Pos, OpMul8, t) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(int8(udivisible8(c).m)) + v1.AddArg2(x, v2) + v3 := b.NewValue0(v.Pos, OpConst8, t) + v3.AuxInt = int8ToAuxInt(int8(8 - udivisible8(c).k)) + v0.AddArg2(v1, v3) + v4 := b.NewValue0(v.Pos, OpConst8, t) + v4.AuxInt = int8ToAuxInt(int8(udivisible8(c).max)) + v.AddArg2(v0, v4) + return true + } + } + break + } + // match: (Eq8 x (Mul8 div:(Div8 x (Const8 [c])) (Const8 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst8 && sdivisibleOK8(c) + // result: (Leq8U (RotateLeft8 (Add8 (Mul8 x (Const8 [int8(sdivisible8(c).m)])) (Const8 [int8(sdivisible8(c).a)])) (Const8 [int8(8 - sdivisible8(c).k)])) (Const8 [int8(sdivisible8(c).max)])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul8 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv8 { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(div_1.AuxInt) + if v_1_1.Op != OpConst8 || auxIntToInt8(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst8 && sdivisibleOK8(c)) { + continue + } + v.reset(OpLeq8U) + v0 := b.NewValue0(v.Pos, OpRotateLeft8, t) + v1 := b.NewValue0(v.Pos, OpAdd8, t) + v2 := b.NewValue0(v.Pos, OpMul8, t) + v3 := b.NewValue0(v.Pos, OpConst8, t) + v3.AuxInt = int8ToAuxInt(int8(sdivisible8(c).m)) + v2.AddArg2(x, v3) + v4 := b.NewValue0(v.Pos, OpConst8, t) + v4.AuxInt = int8ToAuxInt(int8(sdivisible8(c).a)) + v1.AddArg2(v2, v4) + v5 := b.NewValue0(v.Pos, OpConst8, t) + v5.AuxInt = int8ToAuxInt(int8(8 - sdivisible8(c).k)) + v0.AddArg2(v1, v5) + v6 := b.NewValue0(v.Pos, OpConst8, t) + v6.AuxInt = int8ToAuxInt(int8(sdivisible8(c).max)) + v.AddArg2(v0, v6) + return true + } + } + break + } + return false +} +func rewriteValuedivisible_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq16 x (Mul16 (Div16u x (Const16 [c])) (Const16 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Neq16 (And16 x (Const16 [c-1])) (Const16 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul16 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv16u { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst16 || auxIntToInt16(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpNeq16) + v0 := b.NewValue0(v.Pos, OpAnd16, t) + v1 := b.NewValue0(v.Pos, OpConst16, t) + v1.AuxInt = int16ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq16 x (Mul16 (Div16 x (Const16 [c])) (Const16 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Neq16 (And16 x (Const16 [c-1])) (Const16 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul16 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv16 { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst16 || auxIntToInt16(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpNeq16) + v0 := b.NewValue0(v.Pos, OpAnd16, t) + v1 := b.NewValue0(v.Pos, OpConst16, t) + v1.AuxInt = int16ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq16 x (Mul16 div:(Div16u x (Const16 [c])) (Const16 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst16 && udivisibleOK16(c) + // result: (Less16U (Const16 [int16(udivisible16(c).max)]) (RotateLeft16 (Mul16 x (Const16 [int16(udivisible16(c).m)])) (Const16 [int16(16 - udivisible16(c).k)]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul16 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv16u { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(div_1.AuxInt) + if v_1_1.Op != OpConst16 || auxIntToInt16(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst16 && udivisibleOK16(c)) { + continue + } + v.reset(OpLess16U) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(int16(udivisible16(c).max)) + v1 := b.NewValue0(v.Pos, OpRotateLeft16, t) + v2 := b.NewValue0(v.Pos, OpMul16, t) + v3 := b.NewValue0(v.Pos, OpConst16, t) + v3.AuxInt = int16ToAuxInt(int16(udivisible16(c).m)) + v2.AddArg2(x, v3) + v4 := b.NewValue0(v.Pos, OpConst16, t) + v4.AuxInt = int16ToAuxInt(int16(16 - udivisible16(c).k)) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } + } + break + } + // match: (Neq16 x (Mul16 div:(Div16 x (Const16 [c])) (Const16 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst16 && sdivisibleOK16(c) + // result: (Less16U (Const16 [int16(sdivisible16(c).max)]) (RotateLeft16 (Add16 (Mul16 x (Const16 [int16(sdivisible16(c).m)])) (Const16 [int16(sdivisible16(c).a)])) (Const16 [int16(16 - sdivisible16(c).k)]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul16 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv16 { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(div_1.AuxInt) + if v_1_1.Op != OpConst16 || auxIntToInt16(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst16 && sdivisibleOK16(c)) { + continue + } + v.reset(OpLess16U) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(int16(sdivisible16(c).max)) + v1 := b.NewValue0(v.Pos, OpRotateLeft16, t) + v2 := b.NewValue0(v.Pos, OpAdd16, t) + v3 := b.NewValue0(v.Pos, OpMul16, t) + v4 := b.NewValue0(v.Pos, OpConst16, t) + v4.AuxInt = int16ToAuxInt(int16(sdivisible16(c).m)) + v3.AddArg2(x, v4) + v5 := b.NewValue0(v.Pos, OpConst16, t) + v5.AuxInt = int16ToAuxInt(int16(sdivisible16(c).a)) + v2.AddArg2(v3, v5) + v6 := b.NewValue0(v.Pos, OpConst16, t) + v6.AuxInt = int16ToAuxInt(int16(16 - sdivisible16(c).k)) + v1.AddArg2(v2, v6) + v.AddArg2(v0, v1) + return true + } + } + break + } + return false +} +func rewriteValuedivisible_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32 x (Mul32 (Div32u x (Const32 [c])) (Const32 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Neq32 (And32 x (Const32 [c-1])) (Const32 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul32 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv32u { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst32 || auxIntToInt32(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpNeq32) + v0 := b.NewValue0(v.Pos, OpAnd32, t) + v1 := b.NewValue0(v.Pos, OpConst32, t) + v1.AuxInt = int32ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq32 x (Mul32 (Div32 x (Const32 [c])) (Const32 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Neq32 (And32 x (Const32 [c-1])) (Const32 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul32 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv32 { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst32 || auxIntToInt32(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpNeq32) + v0 := b.NewValue0(v.Pos, OpAnd32, t) + v1 := b.NewValue0(v.Pos, OpConst32, t) + v1.AuxInt = int32ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq32 x (Mul32 div:(Div32u x (Const32 [c])) (Const32 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst32 && udivisibleOK32(c) + // result: (Less32U (Const32 [int32(udivisible32(c).max)]) (RotateLeft32 (Mul32 x (Const32 [int32(udivisible32(c).m)])) (Const32 [int32(32 - udivisible32(c).k)]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul32 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv32u { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(div_1.AuxInt) + if v_1_1.Op != OpConst32 || auxIntToInt32(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst32 && udivisibleOK32(c)) { + continue + } + v.reset(OpLess32U) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(int32(udivisible32(c).max)) + v1 := b.NewValue0(v.Pos, OpRotateLeft32, t) + v2 := b.NewValue0(v.Pos, OpMul32, t) + v3 := b.NewValue0(v.Pos, OpConst32, t) + v3.AuxInt = int32ToAuxInt(int32(udivisible32(c).m)) + v2.AddArg2(x, v3) + v4 := b.NewValue0(v.Pos, OpConst32, t) + v4.AuxInt = int32ToAuxInt(int32(32 - udivisible32(c).k)) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } + } + break + } + // match: (Neq32 x (Mul32 div:(Div32 x (Const32 [c])) (Const32 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst32 && sdivisibleOK32(c) + // result: (Less32U (Const32 [int32(sdivisible32(c).max)]) (RotateLeft32 (Add32 (Mul32 x (Const32 [int32(sdivisible32(c).m)])) (Const32 [int32(sdivisible32(c).a)])) (Const32 [int32(32 - sdivisible32(c).k)]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul32 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv32 { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(div_1.AuxInt) + if v_1_1.Op != OpConst32 || auxIntToInt32(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst32 && sdivisibleOK32(c)) { + continue + } + v.reset(OpLess32U) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(int32(sdivisible32(c).max)) + v1 := b.NewValue0(v.Pos, OpRotateLeft32, t) + v2 := b.NewValue0(v.Pos, OpAdd32, t) + v3 := b.NewValue0(v.Pos, OpMul32, t) + v4 := b.NewValue0(v.Pos, OpConst32, t) + v4.AuxInt = int32ToAuxInt(int32(sdivisible32(c).m)) + v3.AddArg2(x, v4) + v5 := b.NewValue0(v.Pos, OpConst32, t) + v5.AuxInt = int32ToAuxInt(int32(sdivisible32(c).a)) + v2.AddArg2(v3, v5) + v6 := b.NewValue0(v.Pos, OpConst32, t) + v6.AuxInt = int32ToAuxInt(int32(32 - sdivisible32(c).k)) + v1.AddArg2(v2, v6) + v.AddArg2(v0, v1) + return true + } + } + break + } + return false +} +func rewriteValuedivisible_OpNeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64 x (Mul64 (Div64u x (Const64 [c])) (Const64 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Neq64 (And64 x (Const64 [c-1])) (Const64 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul64 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv64u { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst64 || auxIntToInt64(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpNeq64) + v0 := b.NewValue0(v.Pos, OpAnd64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq64 x (Mul64 (Div64 x (Const64 [c])) (Const64 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Neq64 (And64 x (Const64 [c-1])) (Const64 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul64 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv64 { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst64 || auxIntToInt64(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpNeq64) + v0 := b.NewValue0(v.Pos, OpAnd64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq64 x (Mul64 div:(Div64u x (Const64 [c])) (Const64 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst64 && udivisibleOK64(c) + // result: (Less64U (Const64 [int64(udivisible64(c).max)]) (RotateLeft64 (Mul64 x (Const64 [int64(udivisible64(c).m)])) (Const64 [int64(64 - udivisible64(c).k)]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul64 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv64u { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(div_1.AuxInt) + if v_1_1.Op != OpConst64 || auxIntToInt64(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst64 && udivisibleOK64(c)) { + continue + } + v.reset(OpLess64U) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(udivisible64(c).max)) + v1 := b.NewValue0(v.Pos, OpRotateLeft64, t) + v2 := b.NewValue0(v.Pos, OpMul64, t) + v3 := b.NewValue0(v.Pos, OpConst64, t) + v3.AuxInt = int64ToAuxInt(int64(udivisible64(c).m)) + v2.AddArg2(x, v3) + v4 := b.NewValue0(v.Pos, OpConst64, t) + v4.AuxInt = int64ToAuxInt(int64(64 - udivisible64(c).k)) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } + } + break + } + // match: (Neq64 x (Mul64 div:(Div64 x (Const64 [c])) (Const64 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst64 && sdivisibleOK64(c) + // result: (Less64U (Const64 [int64(sdivisible64(c).max)]) (RotateLeft64 (Add64 (Mul64 x (Const64 [int64(sdivisible64(c).m)])) (Const64 [int64(sdivisible64(c).a)])) (Const64 [int64(64 - sdivisible64(c).k)]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul64 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv64 { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(div_1.AuxInt) + if v_1_1.Op != OpConst64 || auxIntToInt64(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst64 && sdivisibleOK64(c)) { + continue + } + v.reset(OpLess64U) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(sdivisible64(c).max)) + v1 := b.NewValue0(v.Pos, OpRotateLeft64, t) + v2 := b.NewValue0(v.Pos, OpAdd64, t) + v3 := b.NewValue0(v.Pos, OpMul64, t) + v4 := b.NewValue0(v.Pos, OpConst64, t) + v4.AuxInt = int64ToAuxInt(int64(sdivisible64(c).m)) + v3.AddArg2(x, v4) + v5 := b.NewValue0(v.Pos, OpConst64, t) + v5.AuxInt = int64ToAuxInt(int64(sdivisible64(c).a)) + v2.AddArg2(v3, v5) + v6 := b.NewValue0(v.Pos, OpConst64, t) + v6.AuxInt = int64ToAuxInt(int64(64 - sdivisible64(c).k)) + v1.AddArg2(v2, v6) + v.AddArg2(v0, v1) + return true + } + } + break + } + return false +} +func rewriteValuedivisible_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq8 x (Mul8 (Div8u x (Const8 [c])) (Const8 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Neq8 (And8 x (Const8 [c-1])) (Const8 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul8 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv8u { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst8 || auxIntToInt8(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpNeq8) + v0 := b.NewValue0(v.Pos, OpAnd8, t) + v1 := b.NewValue0(v.Pos, OpConst8, t) + v1.AuxInt = int8ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq8 x (Mul8 (Div8 x (Const8 [c])) (Const8 [c]))) + // cond: x.Op != OpConst64 && isPowerOfTwo(c) + // result: (Neq8 (And8 x (Const8 [c-1])) (Const8 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul8 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpDiv8 { + continue + } + _ = v_1_0.Args[1] + if x != v_1_0.Args[0] { + continue + } + v_1_0_1 := v_1_0.Args[1] + if v_1_0_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_0_1.AuxInt) + if v_1_1.Op != OpConst8 || auxIntToInt8(v_1_1.AuxInt) != c || !(x.Op != OpConst64 && isPowerOfTwo(c)) { + continue + } + v.reset(OpNeq8) + v0 := b.NewValue0(v.Pos, OpAnd8, t) + v1 := b.NewValue0(v.Pos, OpConst8, t) + v1.AuxInt = int8ToAuxInt(c - 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq8 x (Mul8 div:(Div8u x (Const8 [c])) (Const8 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst8 && udivisibleOK8(c) + // result: (Less8U (Const8 [int8(udivisible8(c).max)]) (RotateLeft8 (Mul8 x (Const8 [int8(udivisible8(c).m)])) (Const8 [int8(8 - udivisible8(c).k)]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul8 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv8u { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(div_1.AuxInt) + if v_1_1.Op != OpConst8 || auxIntToInt8(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst8 && udivisibleOK8(c)) { + continue + } + v.reset(OpLess8U) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(int8(udivisible8(c).max)) + v1 := b.NewValue0(v.Pos, OpRotateLeft8, t) + v2 := b.NewValue0(v.Pos, OpMul8, t) + v3 := b.NewValue0(v.Pos, OpConst8, t) + v3.AuxInt = int8ToAuxInt(int8(udivisible8(c).m)) + v2.AddArg2(x, v3) + v4 := b.NewValue0(v.Pos, OpConst8, t) + v4.AuxInt = int8ToAuxInt(int8(8 - udivisible8(c).k)) + v1.AddArg2(v2, v4) + v.AddArg2(v0, v1) + return true + } + } + break + } + // match: (Neq8 x (Mul8 div:(Div8 x (Const8 [c])) (Const8 [c]))) + // cond: div.Uses == 1 && x.Op != OpConst8 && sdivisibleOK8(c) + // result: (Less8U (Const8 [int8(sdivisible8(c).max)]) (RotateLeft8 (Add8 (Mul8 x (Const8 [int8(sdivisible8(c).m)])) (Const8 [int8(sdivisible8(c).a)])) (Const8 [int8(8 - sdivisible8(c).k)]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpMul8 { + continue + } + t := v_1.Type + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + div := v_1_0 + if div.Op != OpDiv8 { + continue + } + _ = div.Args[1] + if x != div.Args[0] { + continue + } + div_1 := div.Args[1] + if div_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(div_1.AuxInt) + if v_1_1.Op != OpConst8 || auxIntToInt8(v_1_1.AuxInt) != c || !(div.Uses == 1 && x.Op != OpConst8 && sdivisibleOK8(c)) { + continue + } + v.reset(OpLess8U) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(int8(sdivisible8(c).max)) + v1 := b.NewValue0(v.Pos, OpRotateLeft8, t) + v2 := b.NewValue0(v.Pos, OpAdd8, t) + v3 := b.NewValue0(v.Pos, OpMul8, t) + v4 := b.NewValue0(v.Pos, OpConst8, t) + v4.AuxInt = int8ToAuxInt(int8(sdivisible8(c).m)) + v3.AddArg2(x, v4) + v5 := b.NewValue0(v.Pos, OpConst8, t) + v5.AuxInt = int8ToAuxInt(int8(sdivisible8(c).a)) + v2.AddArg2(v3, v5) + v6 := b.NewValue0(v.Pos, OpConst8, t) + v6.AuxInt = int8ToAuxInt(int8(8 - sdivisible8(c).k)) + v1.AddArg2(v2, v6) + v.AddArg2(v0, v1) + return true + } + } + break + } + return false +} +func rewriteBlockdivisible(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewritedivmod.go b/go/src/cmd/compile/internal/ssa/rewritedivmod.go new file mode 100644 index 0000000000000000000000000000000000000000..ab5cf7d676abc5f30d62fb379bd1f81ef751a41f --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewritedivmod.go @@ -0,0 +1,923 @@ +// Code generated from _gen/divmod.rules using 'go generate'; DO NOT EDIT. + +package ssa + +func rewriteValuedivmod(v *Value) bool { + switch v.Op { + case OpDiv16: + return rewriteValuedivmod_OpDiv16(v) + case OpDiv16u: + return rewriteValuedivmod_OpDiv16u(v) + case OpDiv32: + return rewriteValuedivmod_OpDiv32(v) + case OpDiv32u: + return rewriteValuedivmod_OpDiv32u(v) + case OpDiv64: + return rewriteValuedivmod_OpDiv64(v) + case OpDiv64u: + return rewriteValuedivmod_OpDiv64u(v) + case OpDiv8: + return rewriteValuedivmod_OpDiv8(v) + case OpDiv8u: + return rewriteValuedivmod_OpDiv8u(v) + } + return false +} +func rewriteValuedivmod_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 n (Const16 [c])) + // cond: isPowerOfTwo(c) + // result: (Rsh16x64 (Add16 n (Rsh16Ux64 (Rsh16x64 n (Const64 [15])) (Const64 [int64(16-log16(c))]))) (Const64 [int64(log16(c))])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpRsh16x64) + v0 := b.NewValue0(v.Pos, OpAdd16, t) + v1 := b.NewValue0(v.Pos, OpRsh16Ux64, t) + v2 := b.NewValue0(v.Pos, OpRsh16x64, t) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(15) + v2.AddArg2(n, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(int64(16 - log16(c))) + v1.AddArg2(v2, v4) + v0.AddArg2(n, v1) + v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v5.AuxInt = int64ToAuxInt(int64(log16(c))) + v.AddArg2(v0, v5) + return true + } + // match: (Div16 x (Const16 [c])) + // cond: smagicOK16(c) + // result: (Sub16 (Rsh32x64 (Mul32 (SignExt16to32 x) (Const32 [int32(smagic16(c).m)])) (Const64 [16 + smagic16(c).s])) (Rsh32x64 (SignExt16to32 x) (Const64 [31]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(smagicOK16(c)) { + break + } + v.reset(OpSub16) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh32x64, t) + v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(smagic16(c).m)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(16 + smagic16(c).s) + v0.AddArg2(v1, v4) + v5 := b.NewValue0(v.Pos, OpRsh32x64, t) + v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v6.AuxInt = int64ToAuxInt(31) + v5.AddArg2(v2, v6) + v.AddArg2(v0, v5) + return true + } + return false +} +func rewriteValuedivmod_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Div16u x (Const16 [c])) + // cond: t.IsSigned() && smagicOK16(c) + // result: (Rsh32Ux64 (Mul32 (SignExt16to32 x) (Const32 [int32(smagic16(c).m)])) (Const64 [16 + smagic16(c).s])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(t.IsSigned() && smagicOK16(c)) { + break + } + v.reset(OpRsh32Ux64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v2.AuxInt = int32ToAuxInt(int32(smagic16(c).m)) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(16 + smagic16(c).s) + v.AddArg2(v0, v3) + return true + } + // match: (Div16u x (Const16 [c])) + // cond: umagicOK16(c) && config.RegSize == 8 + // result: (Trunc64to16 (Rsh64Ux64 (Mul64 (ZeroExt16to64 x) (Const64 [int64(1<<16 + umagic16(c).m)])) (Const64 [16 + umagic16(c).s]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(umagicOK16(c) && config.RegSize == 8) { + break + } + v.reset(OpTrunc64to16) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(int64(1<<16 + umagic16(c).m)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(16 + umagic16(c).s) + v0.AddArg2(v1, v4) + v.AddArg(v0) + return true + } + // match: (Div16u x (Const16 [c])) + // cond: umagicOK16(c) && umagic16(c).m&1 == 0 + // result: (Trunc32to16 (Rsh32Ux64 (Mul32 (ZeroExt16to32 x) (Const32 [int32(1<<15 + umagic16(c).m/2)])) (Const64 [16 + umagic16(c).s - 1]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(umagicOK16(c) && umagic16(c).m&1 == 0) { + break + } + v.reset(OpTrunc32to16) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(1<<15 + umagic16(c).m/2)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(16 + umagic16(c).s - 1) + v0.AddArg2(v1, v4) + v.AddArg(v0) + return true + } + // match: (Div16u x (Const16 [c])) + // cond: umagicOK16(c) && config.RegSize == 4 && c&1 == 0 + // result: (Trunc32to16 (Rsh32Ux64 (Mul32 (Rsh32Ux64 (ZeroExt16to32 x) (Const64 [1])) (Const32 [int32(1<<15 + (umagic16(c).m+1)/2)])) (Const64 [16 + umagic16(c).s - 2]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(umagicOK16(c) && config.RegSize == 4 && c&1 == 0) { + break + } + v.reset(OpTrunc32to16) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(1) + v2.AddArg2(v3, v4) + v5 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v5.AuxInt = int32ToAuxInt(int32(1<<15 + (umagic16(c).m+1)/2)) + v1.AddArg2(v2, v5) + v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v6.AuxInt = int64ToAuxInt(16 + umagic16(c).s - 2) + v0.AddArg2(v1, v6) + v.AddArg(v0) + return true + } + // match: (Div16u x (Const16 [c])) + // cond: umagicOK16(c) && config.RegSize == 4 + // result: (Trunc32to16 (Rsh32Ux64 (Avg32u (Lsh32x64 (ZeroExt16to32 x) (Const64 [16])) (Mul32 (ZeroExt16to32 x) (Const32 [int32(umagic16(c).m)]))) (Const64 [16 + umagic16(c).s - 1]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(umagicOK16(c) && config.RegSize == 4) { + break + } + v.reset(OpTrunc32to16) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpAvg32u, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpLsh32x64, typ.UInt32) + v3 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(16) + v2.AddArg2(v3, v4) + v5 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) + v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v6.AuxInt = int32ToAuxInt(int32(umagic16(c).m)) + v5.AddArg2(v3, v6) + v1.AddArg2(v2, v5) + v7 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v7.AuxInt = int64ToAuxInt(16 + umagic16(c).s - 1) + v0.AddArg2(v1, v7) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuedivmod_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Div32 n (Const32 [c])) + // cond: isPowerOfTwo(c) + // result: (Rsh32x64 (Add32 n (Rsh32Ux64 (Rsh32x64 n (Const64 [31])) (Const64 [int64(32-log32(c))]))) (Const64 [int64(log32(c))])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpRsh32x64) + v0 := b.NewValue0(v.Pos, OpAdd32, t) + v1 := b.NewValue0(v.Pos, OpRsh32Ux64, t) + v2 := b.NewValue0(v.Pos, OpRsh32x64, t) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(31) + v2.AddArg2(n, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(int64(32 - log32(c))) + v1.AddArg2(v2, v4) + v0.AddArg2(n, v1) + v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v5.AuxInt = int64ToAuxInt(int64(log32(c))) + v.AddArg2(v0, v5) + return true + } + // match: (Div32 x (Const32 [c])) + // cond: smagicOK32(c) && config.RegSize == 8 + // result: (Sub32 (Rsh64x64 (Mul64 (SignExt32to64 x) (Const64 [int64(smagic32(c).m)])) (Const64 [32 + smagic32(c).s])) (Rsh64x64 (SignExt32to64 x) (Const64 [63]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(smagicOK32(c) && config.RegSize == 8) { + break + } + v.reset(OpSub32) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh64x64, t) + v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(int64(smagic32(c).m)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(32 + smagic32(c).s) + v0.AddArg2(v1, v4) + v5 := b.NewValue0(v.Pos, OpRsh64x64, t) + v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v6.AuxInt = int64ToAuxInt(63) + v5.AddArg2(v2, v6) + v.AddArg2(v0, v5) + return true + } + // match: (Div32 x (Const32 [c])) + // cond: smagicOK32(c) && config.RegSize == 4 && smagic32(c).m&1 == 0 + // result: (Sub32 (Rsh32x64 (Hmul32 x (Const32 [int32(smagic32(c).m/2)])) (Const64 [smagic32(c).s - 1])) (Rsh32x64 x (Const64 [31]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(smagicOK32(c) && config.RegSize == 4 && smagic32(c).m&1 == 0) { + break + } + v.reset(OpSub32) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh32x64, t) + v1 := b.NewValue0(v.Pos, OpHmul32, t) + v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v2.AuxInt = int32ToAuxInt(int32(smagic32(c).m / 2)) + v1.AddArg2(x, v2) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(smagic32(c).s - 1) + v0.AddArg2(v1, v3) + v4 := b.NewValue0(v.Pos, OpRsh32x64, t) + v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v5.AuxInt = int64ToAuxInt(31) + v4.AddArg2(x, v5) + v.AddArg2(v0, v4) + return true + } + // match: (Div32 x (Const32 [c])) + // cond: smagicOK32(c) && config.RegSize == 4 && smagic32(c).m&1 != 0 + // result: (Sub32 (Rsh32x64 (Add32 x (Hmul32 x (Const32 [int32(smagic32(c).m)]))) (Const64 [smagic32(c).s])) (Rsh32x64 x (Const64 [31]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(smagicOK32(c) && config.RegSize == 4 && smagic32(c).m&1 != 0) { + break + } + v.reset(OpSub32) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh32x64, t) + v1 := b.NewValue0(v.Pos, OpAdd32, t) + v2 := b.NewValue0(v.Pos, OpHmul32, t) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(smagic32(c).m)) + v2.AddArg2(x, v3) + v1.AddArg2(x, v2) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(smagic32(c).s) + v0.AddArg2(v1, v4) + v5 := b.NewValue0(v.Pos, OpRsh32x64, t) + v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v6.AuxInt = int64ToAuxInt(31) + v5.AddArg2(x, v6) + v.AddArg2(v0, v5) + return true + } + return false +} +func rewriteValuedivmod_OpDiv32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Div32u x (Const32 [c])) + // cond: t.IsSigned() && smagicOK32(c) && config.RegSize == 8 + // result: (Rsh64Ux64 (Mul64 (SignExt32to64 x) (Const64 [int64(smagic32(c).m)])) (Const64 [32 + smagic32(c).s])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(t.IsSigned() && smagicOK32(c) && config.RegSize == 8) { + break + } + v.reset(OpRsh64Ux64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(int64(smagic32(c).m)) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(32 + smagic32(c).s) + v.AddArg2(v0, v3) + return true + } + // match: (Div32u x (Const32 [c])) + // cond: t.IsSigned() && smagicOK32(c) && config.RegSize == 4 + // result: (Rsh32Ux64 (Hmul32u x (Const32 [int32(smagic32(c).m)])) (Const64 [smagic32(c).s])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(t.IsSigned() && smagicOK32(c) && config.RegSize == 4) { + break + } + v.reset(OpRsh32Ux64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpHmul32u, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v1.AuxInt = int32ToAuxInt(int32(smagic32(c).m)) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(smagic32(c).s) + v.AddArg2(v0, v2) + return true + } + // match: (Div32u x (Const32 [c])) + // cond: umagicOK32(c) && umagic32(c).m&1 == 0 && config.RegSize == 8 + // result: (Trunc64to32 (Rsh64Ux64 (Mul64 (ZeroExt32to64 x) (Const64 [int64(1<<31 + umagic32(c).m/2)])) (Const64 [32 + umagic32(c).s - 1]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(umagicOK32(c) && umagic32(c).m&1 == 0 && config.RegSize == 8) { + break + } + v.reset(OpTrunc64to32) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(int64(1<<31 + umagic32(c).m/2)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(32 + umagic32(c).s - 1) + v0.AddArg2(v1, v4) + v.AddArg(v0) + return true + } + // match: (Div32u x (Const32 [c])) + // cond: umagicOK32(c) && umagic32(c).m&1 == 0 && config.RegSize == 4 + // result: (Rsh32Ux64 (Hmul32u x (Const32 [int32(1<<31 + umagic32(c).m/2)])) (Const64 [umagic32(c).s - 1])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(umagicOK32(c) && umagic32(c).m&1 == 0 && config.RegSize == 4) { + break + } + v.reset(OpRsh32Ux64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpHmul32u, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v1.AuxInt = int32ToAuxInt(int32(1<<31 + umagic32(c).m/2)) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(umagic32(c).s - 1) + v.AddArg2(v0, v2) + return true + } + // match: (Div32u x (Const32 [c])) + // cond: umagicOK32(c) && config.RegSize == 8 && c&1 == 0 + // result: (Trunc64to32 (Rsh64Ux64 (Mul64 (Rsh64Ux64 (ZeroExt32to64 x) (Const64 [1])) (Const64 [int64(1<<31 + (umagic32(c).m+1)/2)])) (Const64 [32 + umagic32(c).s - 2]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(umagicOK32(c) && config.RegSize == 8 && c&1 == 0) { + break + } + v.reset(OpTrunc64to32) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(1) + v2.AddArg2(v3, v4) + v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v5.AuxInt = int64ToAuxInt(int64(1<<31 + (umagic32(c).m+1)/2)) + v1.AddArg2(v2, v5) + v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v6.AuxInt = int64ToAuxInt(32 + umagic32(c).s - 2) + v0.AddArg2(v1, v6) + v.AddArg(v0) + return true + } + // match: (Div32u x (Const32 [c])) + // cond: umagicOK32(c) && config.RegSize == 4 && c&1 == 0 + // result: (Rsh32Ux64 (Hmul32u (Rsh32Ux64 x (Const64 [1])) (Const32 [int32(1<<31 + (umagic32(c).m+1)/2)])) (Const64 [umagic32(c).s - 2])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(umagicOK32(c) && config.RegSize == 4 && c&1 == 0) { + break + } + v.reset(OpRsh32Ux64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpHmul32u, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(1) + v1.AddArg2(x, v2) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(1<<31 + (umagic32(c).m+1)/2)) + v0.AddArg2(v1, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(umagic32(c).s - 2) + v.AddArg2(v0, v4) + return true + } + // match: (Div32u x (Const32 [c])) + // cond: umagicOK32(c) && config.RegSize == 8 + // result: (Trunc64to32 (Rsh64Ux64 (Avg64u (Lsh64x64 (ZeroExt32to64 x) (Const64 [32])) (Mul64 (ZeroExt32to64 x) (Const64 [int64(umagic32(c).m)]))) (Const64 [32 + umagic32(c).s - 1]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(umagicOK32(c) && config.RegSize == 8) { + break + } + v.reset(OpTrunc64to32) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpAvg64u, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpLsh64x64, typ.UInt64) + v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) + v3.AddArg(x) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(32) + v2.AddArg2(v3, v4) + v5 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) + v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt32) + v6.AuxInt = int64ToAuxInt(int64(umagic32(c).m)) + v5.AddArg2(v3, v6) + v1.AddArg2(v2, v5) + v7 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v7.AuxInt = int64ToAuxInt(32 + umagic32(c).s - 1) + v0.AddArg2(v1, v7) + v.AddArg(v0) + return true + } + // match: (Div32u x (Const32 [c])) + // cond: umagicOK32(c) && config.RegSize == 4 + // result: (Rsh32Ux64 (Avg32u x (Hmul32u x (Const32 [int32(umagic32(c).m)]))) (Const64 [umagic32(c).s - 1])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(umagicOK32(c) && config.RegSize == 4) { + break + } + v.reset(OpRsh32Ux64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAvg32u, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpHmul32u, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v2.AuxInt = int32ToAuxInt(int32(umagic32(c).m)) + v1.AddArg2(x, v2) + v0.AddArg2(x, v1) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(umagic32(c).s - 1) + v.AddArg2(v0, v3) + return true + } + return false +} +func rewriteValuedivmod_OpDiv64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div64 n (Const64 [c])) + // cond: isPowerOfTwo(c) + // result: (Rsh64x64 (Add64 n (Rsh64Ux64 (Rsh64x64 n (Const64 [63])) (Const64 [int64(64-log64(c))]))) (Const64 [int64(log64(c))])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpRsh64x64) + v0 := b.NewValue0(v.Pos, OpAdd64, t) + v1 := b.NewValue0(v.Pos, OpRsh64Ux64, t) + v2 := b.NewValue0(v.Pos, OpRsh64x64, t) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(63) + v2.AddArg2(n, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(int64(64 - log64(c))) + v1.AddArg2(v2, v4) + v0.AddArg2(n, v1) + v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v5.AuxInt = int64ToAuxInt(int64(log64(c))) + v.AddArg2(v0, v5) + return true + } + // match: (Div64 x (Const64 [c])) + // cond: smagicOK64(c) && smagic64(c).m&1 == 0 + // result: (Sub64 (Rsh64x64 (Hmul64 x (Const64 [int64(smagic64(c).m/2)])) (Const64 [smagic64(c).s - 1])) (Rsh64x64 x (Const64 [63]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(smagicOK64(c) && smagic64(c).m&1 == 0) { + break + } + v.reset(OpSub64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh64x64, t) + v1 := b.NewValue0(v.Pos, OpHmul64, t) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(int64(smagic64(c).m / 2)) + v1.AddArg2(x, v2) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(smagic64(c).s - 1) + v0.AddArg2(v1, v3) + v4 := b.NewValue0(v.Pos, OpRsh64x64, t) + v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v5.AuxInt = int64ToAuxInt(63) + v4.AddArg2(x, v5) + v.AddArg2(v0, v4) + return true + } + // match: (Div64 x (Const64 [c])) + // cond: smagicOK64(c) && smagic64(c).m&1 != 0 + // result: (Sub64 (Rsh64x64 (Add64 x (Hmul64 x (Const64 [int64(smagic64(c).m)]))) (Const64 [smagic64(c).s])) (Rsh64x64 x (Const64 [63]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(smagicOK64(c) && smagic64(c).m&1 != 0) { + break + } + v.reset(OpSub64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh64x64, t) + v1 := b.NewValue0(v.Pos, OpAdd64, t) + v2 := b.NewValue0(v.Pos, OpHmul64, t) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(int64(smagic64(c).m)) + v2.AddArg2(x, v3) + v1.AddArg2(x, v2) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(smagic64(c).s) + v0.AddArg2(v1, v4) + v5 := b.NewValue0(v.Pos, OpRsh64x64, t) + v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v6.AuxInt = int64ToAuxInt(63) + v5.AddArg2(x, v6) + v.AddArg2(v0, v5) + return true + } + return false +} +func rewriteValuedivmod_OpDiv64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div64u x (Const64 [c])) + // cond: t.IsSigned() && smagicOK64(c) + // result: (Rsh64Ux64 (Hmul64u x (Const64 [int64(smagic64(c).m)])) (Const64 [smagic64(c).s])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(t.IsSigned() && smagicOK64(c)) { + break + } + v.reset(OpRsh64Ux64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpHmul64u, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v1.AuxInt = int64ToAuxInt(int64(smagic64(c).m)) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(smagic64(c).s) + v.AddArg2(v0, v2) + return true + } + // match: (Div64u x (Const64 [c])) + // cond: umagicOK64(c) && umagic64(c).m&1 == 0 + // result: (Rsh64Ux64 (Hmul64u x (Const64 [int64(1<<63 + umagic64(c).m/2)])) (Const64 [umagic64(c).s - 1])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(umagicOK64(c) && umagic64(c).m&1 == 0) { + break + } + v.reset(OpRsh64Ux64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpHmul64u, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v1.AuxInt = int64ToAuxInt(int64(1<<63 + umagic64(c).m/2)) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(umagic64(c).s - 1) + v.AddArg2(v0, v2) + return true + } + // match: (Div64u x (Const64 [c])) + // cond: umagicOK64(c) && c&1 == 0 + // result: (Rsh64Ux64 (Hmul64u (Rsh64Ux64 x (Const64 [1])) (Const64 [int64(1<<63 + (umagic64(c).m+1)/2)])) (Const64 [umagic64(c).s - 2])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(umagicOK64(c) && c&1 == 0) { + break + } + v.reset(OpRsh64Ux64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpHmul64u, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(1) + v1.AddArg2(x, v2) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(int64(1<<63 + (umagic64(c).m+1)/2)) + v0.AddArg2(v1, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(umagic64(c).s - 2) + v.AddArg2(v0, v4) + return true + } + // match: (Div64u x (Const64 [c])) + // cond: umagicOK64(c) + // result: (Rsh64Ux64 (Avg64u x (Hmul64u x (Const64 [int64(umagic64(c).m)]))) (Const64 [umagic64(c).s - 1])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(umagicOK64(c)) { + break + } + v.reset(OpRsh64Ux64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpAvg64u, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpHmul64u, typ.UInt64) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(int64(umagic64(c).m)) + v1.AddArg2(x, v2) + v0.AddArg2(x, v1) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(umagic64(c).s - 1) + v.AddArg2(v0, v3) + return true + } + return false +} +func rewriteValuedivmod_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 n (Const8 [c])) + // cond: isPowerOfTwo(c) + // result: (Rsh8x64 (Add8 n (Rsh8Ux64 (Rsh8x64 n (Const64 [ 7])) (Const64 [int64( 8-log8(c))]))) (Const64 [int64(log8(c))])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(isPowerOfTwo(c)) { + break + } + v.reset(OpRsh8x64) + v0 := b.NewValue0(v.Pos, OpAdd8, t) + v1 := b.NewValue0(v.Pos, OpRsh8Ux64, t) + v2 := b.NewValue0(v.Pos, OpRsh8x64, t) + v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v3.AuxInt = int64ToAuxInt(7) + v2.AddArg2(n, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(int64(8 - log8(c))) + v1.AddArg2(v2, v4) + v0.AddArg2(n, v1) + v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v5.AuxInt = int64ToAuxInt(int64(log8(c))) + v.AddArg2(v0, v5) + return true + } + // match: (Div8 x (Const8 [c])) + // cond: smagicOK8(c) + // result: (Sub8 (Rsh32x64 (Mul32 (SignExt8to32 x) (Const32 [int32(smagic8(c).m)])) (Const64 [8 + smagic8(c).s])) (Rsh32x64 (SignExt8to32 x) (Const64 [31]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(smagicOK8(c)) { + break + } + v.reset(OpSub8) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh32x64, t) + v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(smagic8(c).m)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(8 + smagic8(c).s) + v0.AddArg2(v1, v4) + v5 := b.NewValue0(v.Pos, OpRsh32x64, t) + v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v6.AuxInt = int64ToAuxInt(31) + v5.AddArg2(v2, v6) + v.AddArg2(v0, v5) + return true + } + return false +} +func rewriteValuedivmod_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u x (Const8 [c])) + // cond: umagicOK8(c) + // result: (Trunc32to8 (Rsh32Ux64 (Mul32 (ZeroExt8to32 x) (Const32 [int32(1<<8 + umagic8(c).m)])) (Const64 [8 + umagic8(c).s]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(umagicOK8(c)) { + break + } + v.reset(OpTrunc32to8) + v.Type = t + v0 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) + v2 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v2.AddArg(x) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(int32(1<<8 + umagic8(c).m)) + v1.AddArg2(v2, v3) + v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v4.AuxInt = int64ToAuxInt(8 + umagic8(c).s) + v0.AddArg2(v1, v4) + v.AddArg(v0) + return true + } + return false +} +func rewriteBlockdivmod(b *Block) bool { + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewritegeneric.go b/go/src/cmd/compile/internal/ssa/rewritegeneric.go new file mode 100644 index 0000000000000000000000000000000000000000..be944ef8546c0c1ce0dfa39c8434caf597632f49 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewritegeneric.go @@ -0,0 +1,36835 @@ +// Code generated from _gen/generic.rules using 'go generate'; DO NOT EDIT. + +package ssa + +import "math" +import "math/bits" +import "cmd/internal/obj" +import "cmd/compile/internal/types" +import "cmd/compile/internal/ir" + +func rewriteValuegeneric(v *Value) bool { + switch v.Op { + case OpAdd16: + return rewriteValuegeneric_OpAdd16(v) + case OpAdd32: + return rewriteValuegeneric_OpAdd32(v) + case OpAdd32F: + return rewriteValuegeneric_OpAdd32F(v) + case OpAdd64: + return rewriteValuegeneric_OpAdd64(v) + case OpAdd64F: + return rewriteValuegeneric_OpAdd64F(v) + case OpAdd64carry: + return rewriteValuegeneric_OpAdd64carry(v) + case OpAdd8: + return rewriteValuegeneric_OpAdd8(v) + case OpAddPtr: + return rewriteValuegeneric_OpAddPtr(v) + case OpAnd16: + return rewriteValuegeneric_OpAnd16(v) + case OpAnd32: + return rewriteValuegeneric_OpAnd32(v) + case OpAnd64: + return rewriteValuegeneric_OpAnd64(v) + case OpAnd8: + return rewriteValuegeneric_OpAnd8(v) + case OpAndB: + return rewriteValuegeneric_OpAndB(v) + case OpArraySelect: + return rewriteValuegeneric_OpArraySelect(v) + case OpBitLen16: + return rewriteValuegeneric_OpBitLen16(v) + case OpBitLen32: + return rewriteValuegeneric_OpBitLen32(v) + case OpBitLen64: + return rewriteValuegeneric_OpBitLen64(v) + case OpBitLen8: + return rewriteValuegeneric_OpBitLen8(v) + case OpCeil: + return rewriteValuegeneric_OpCeil(v) + case OpCom16: + return rewriteValuegeneric_OpCom16(v) + case OpCom32: + return rewriteValuegeneric_OpCom32(v) + case OpCom64: + return rewriteValuegeneric_OpCom64(v) + case OpCom8: + return rewriteValuegeneric_OpCom8(v) + case OpCondSelect: + return rewriteValuegeneric_OpCondSelect(v) + case OpConstInterface: + return rewriteValuegeneric_OpConstInterface(v) + case OpConstSlice: + return rewriteValuegeneric_OpConstSlice(v) + case OpConstString: + return rewriteValuegeneric_OpConstString(v) + case OpConvert: + return rewriteValuegeneric_OpConvert(v) + case OpCtz16: + return rewriteValuegeneric_OpCtz16(v) + case OpCtz32: + return rewriteValuegeneric_OpCtz32(v) + case OpCtz64: + return rewriteValuegeneric_OpCtz64(v) + case OpCtz8: + return rewriteValuegeneric_OpCtz8(v) + case OpCvt32Fto32: + return rewriteValuegeneric_OpCvt32Fto32(v) + case OpCvt32Fto64: + return rewriteValuegeneric_OpCvt32Fto64(v) + case OpCvt32Fto64F: + return rewriteValuegeneric_OpCvt32Fto64F(v) + case OpCvt32to32F: + return rewriteValuegeneric_OpCvt32to32F(v) + case OpCvt32to64F: + return rewriteValuegeneric_OpCvt32to64F(v) + case OpCvt64Fto32: + return rewriteValuegeneric_OpCvt64Fto32(v) + case OpCvt64Fto32F: + return rewriteValuegeneric_OpCvt64Fto32F(v) + case OpCvt64Fto64: + return rewriteValuegeneric_OpCvt64Fto64(v) + case OpCvt64to32F: + return rewriteValuegeneric_OpCvt64to32F(v) + case OpCvt64to64F: + return rewriteValuegeneric_OpCvt64to64F(v) + case OpCvtBoolToUint8: + return rewriteValuegeneric_OpCvtBoolToUint8(v) + case OpDiv128u: + return rewriteValuegeneric_OpDiv128u(v) + case OpDiv16: + return rewriteValuegeneric_OpDiv16(v) + case OpDiv16u: + return rewriteValuegeneric_OpDiv16u(v) + case OpDiv32: + return rewriteValuegeneric_OpDiv32(v) + case OpDiv32F: + return rewriteValuegeneric_OpDiv32F(v) + case OpDiv32u: + return rewriteValuegeneric_OpDiv32u(v) + case OpDiv64: + return rewriteValuegeneric_OpDiv64(v) + case OpDiv64F: + return rewriteValuegeneric_OpDiv64F(v) + case OpDiv64u: + return rewriteValuegeneric_OpDiv64u(v) + case OpDiv8: + return rewriteValuegeneric_OpDiv8(v) + case OpDiv8u: + return rewriteValuegeneric_OpDiv8u(v) + case OpEq16: + return rewriteValuegeneric_OpEq16(v) + case OpEq32: + return rewriteValuegeneric_OpEq32(v) + case OpEq32F: + return rewriteValuegeneric_OpEq32F(v) + case OpEq64: + return rewriteValuegeneric_OpEq64(v) + case OpEq64F: + return rewriteValuegeneric_OpEq64F(v) + case OpEq8: + return rewriteValuegeneric_OpEq8(v) + case OpEqB: + return rewriteValuegeneric_OpEqB(v) + case OpEqInter: + return rewriteValuegeneric_OpEqInter(v) + case OpEqPtr: + return rewriteValuegeneric_OpEqPtr(v) + case OpEqSlice: + return rewriteValuegeneric_OpEqSlice(v) + case OpFloor: + return rewriteValuegeneric_OpFloor(v) + case OpIMake: + return rewriteValuegeneric_OpIMake(v) + case OpInterLECall: + return rewriteValuegeneric_OpInterLECall(v) + case OpIsInBounds: + return rewriteValuegeneric_OpIsInBounds(v) + case OpIsNonNil: + return rewriteValuegeneric_OpIsNonNil(v) + case OpIsSliceInBounds: + return rewriteValuegeneric_OpIsSliceInBounds(v) + case OpLeq16: + return rewriteValuegeneric_OpLeq16(v) + case OpLeq16U: + return rewriteValuegeneric_OpLeq16U(v) + case OpLeq32: + return rewriteValuegeneric_OpLeq32(v) + case OpLeq32F: + return rewriteValuegeneric_OpLeq32F(v) + case OpLeq32U: + return rewriteValuegeneric_OpLeq32U(v) + case OpLeq64: + return rewriteValuegeneric_OpLeq64(v) + case OpLeq64F: + return rewriteValuegeneric_OpLeq64F(v) + case OpLeq64U: + return rewriteValuegeneric_OpLeq64U(v) + case OpLeq8: + return rewriteValuegeneric_OpLeq8(v) + case OpLeq8U: + return rewriteValuegeneric_OpLeq8U(v) + case OpLess16: + return rewriteValuegeneric_OpLess16(v) + case OpLess16U: + return rewriteValuegeneric_OpLess16U(v) + case OpLess32: + return rewriteValuegeneric_OpLess32(v) + case OpLess32F: + return rewriteValuegeneric_OpLess32F(v) + case OpLess32U: + return rewriteValuegeneric_OpLess32U(v) + case OpLess64: + return rewriteValuegeneric_OpLess64(v) + case OpLess64F: + return rewriteValuegeneric_OpLess64F(v) + case OpLess64U: + return rewriteValuegeneric_OpLess64U(v) + case OpLess8: + return rewriteValuegeneric_OpLess8(v) + case OpLess8U: + return rewriteValuegeneric_OpLess8U(v) + case OpLoad: + return rewriteValuegeneric_OpLoad(v) + case OpLsh16x16: + return rewriteValuegeneric_OpLsh16x16(v) + case OpLsh16x32: + return rewriteValuegeneric_OpLsh16x32(v) + case OpLsh16x64: + return rewriteValuegeneric_OpLsh16x64(v) + case OpLsh16x8: + return rewriteValuegeneric_OpLsh16x8(v) + case OpLsh32x16: + return rewriteValuegeneric_OpLsh32x16(v) + case OpLsh32x32: + return rewriteValuegeneric_OpLsh32x32(v) + case OpLsh32x64: + return rewriteValuegeneric_OpLsh32x64(v) + case OpLsh32x8: + return rewriteValuegeneric_OpLsh32x8(v) + case OpLsh64x16: + return rewriteValuegeneric_OpLsh64x16(v) + case OpLsh64x32: + return rewriteValuegeneric_OpLsh64x32(v) + case OpLsh64x64: + return rewriteValuegeneric_OpLsh64x64(v) + case OpLsh64x8: + return rewriteValuegeneric_OpLsh64x8(v) + case OpLsh8x16: + return rewriteValuegeneric_OpLsh8x16(v) + case OpLsh8x32: + return rewriteValuegeneric_OpLsh8x32(v) + case OpLsh8x64: + return rewriteValuegeneric_OpLsh8x64(v) + case OpLsh8x8: + return rewriteValuegeneric_OpLsh8x8(v) + case OpMemEq: + return rewriteValuegeneric_OpMemEq(v) + case OpMod16: + return rewriteValuegeneric_OpMod16(v) + case OpMod16u: + return rewriteValuegeneric_OpMod16u(v) + case OpMod32: + return rewriteValuegeneric_OpMod32(v) + case OpMod32u: + return rewriteValuegeneric_OpMod32u(v) + case OpMod64: + return rewriteValuegeneric_OpMod64(v) + case OpMod64u: + return rewriteValuegeneric_OpMod64u(v) + case OpMod8: + return rewriteValuegeneric_OpMod8(v) + case OpMod8u: + return rewriteValuegeneric_OpMod8u(v) + case OpMove: + return rewriteValuegeneric_OpMove(v) + case OpMul16: + return rewriteValuegeneric_OpMul16(v) + case OpMul32: + return rewriteValuegeneric_OpMul32(v) + case OpMul32F: + return rewriteValuegeneric_OpMul32F(v) + case OpMul32uhilo: + return rewriteValuegeneric_OpMul32uhilo(v) + case OpMul32uover: + return rewriteValuegeneric_OpMul32uover(v) + case OpMul64: + return rewriteValuegeneric_OpMul64(v) + case OpMul64F: + return rewriteValuegeneric_OpMul64F(v) + case OpMul64uhilo: + return rewriteValuegeneric_OpMul64uhilo(v) + case OpMul64uover: + return rewriteValuegeneric_OpMul64uover(v) + case OpMul8: + return rewriteValuegeneric_OpMul8(v) + case OpNeg16: + return rewriteValuegeneric_OpNeg16(v) + case OpNeg32: + return rewriteValuegeneric_OpNeg32(v) + case OpNeg32F: + return rewriteValuegeneric_OpNeg32F(v) + case OpNeg64: + return rewriteValuegeneric_OpNeg64(v) + case OpNeg64F: + return rewriteValuegeneric_OpNeg64F(v) + case OpNeg8: + return rewriteValuegeneric_OpNeg8(v) + case OpNeq16: + return rewriteValuegeneric_OpNeq16(v) + case OpNeq32: + return rewriteValuegeneric_OpNeq32(v) + case OpNeq32F: + return rewriteValuegeneric_OpNeq32F(v) + case OpNeq64: + return rewriteValuegeneric_OpNeq64(v) + case OpNeq64F: + return rewriteValuegeneric_OpNeq64F(v) + case OpNeq8: + return rewriteValuegeneric_OpNeq8(v) + case OpNeqB: + return rewriteValuegeneric_OpNeqB(v) + case OpNeqInter: + return rewriteValuegeneric_OpNeqInter(v) + case OpNeqPtr: + return rewriteValuegeneric_OpNeqPtr(v) + case OpNeqSlice: + return rewriteValuegeneric_OpNeqSlice(v) + case OpNilCheck: + return rewriteValuegeneric_OpNilCheck(v) + case OpNot: + return rewriteValuegeneric_OpNot(v) + case OpOffPtr: + return rewriteValuegeneric_OpOffPtr(v) + case OpOr16: + return rewriteValuegeneric_OpOr16(v) + case OpOr32: + return rewriteValuegeneric_OpOr32(v) + case OpOr64: + return rewriteValuegeneric_OpOr64(v) + case OpOr8: + return rewriteValuegeneric_OpOr8(v) + case OpOrB: + return rewriteValuegeneric_OpOrB(v) + case OpPhi: + return rewriteValuegeneric_OpPhi(v) + case OpPopCount16: + return rewriteValuegeneric_OpPopCount16(v) + case OpPopCount32: + return rewriteValuegeneric_OpPopCount32(v) + case OpPopCount64: + return rewriteValuegeneric_OpPopCount64(v) + case OpPopCount8: + return rewriteValuegeneric_OpPopCount8(v) + case OpPtrIndex: + return rewriteValuegeneric_OpPtrIndex(v) + case OpRotateLeft16: + return rewriteValuegeneric_OpRotateLeft16(v) + case OpRotateLeft32: + return rewriteValuegeneric_OpRotateLeft32(v) + case OpRotateLeft64: + return rewriteValuegeneric_OpRotateLeft64(v) + case OpRotateLeft8: + return rewriteValuegeneric_OpRotateLeft8(v) + case OpRound32F: + return rewriteValuegeneric_OpRound32F(v) + case OpRound64F: + return rewriteValuegeneric_OpRound64F(v) + case OpRoundToEven: + return rewriteValuegeneric_OpRoundToEven(v) + case OpRsh16Ux16: + return rewriteValuegeneric_OpRsh16Ux16(v) + case OpRsh16Ux32: + return rewriteValuegeneric_OpRsh16Ux32(v) + case OpRsh16Ux64: + return rewriteValuegeneric_OpRsh16Ux64(v) + case OpRsh16Ux8: + return rewriteValuegeneric_OpRsh16Ux8(v) + case OpRsh16x16: + return rewriteValuegeneric_OpRsh16x16(v) + case OpRsh16x32: + return rewriteValuegeneric_OpRsh16x32(v) + case OpRsh16x64: + return rewriteValuegeneric_OpRsh16x64(v) + case OpRsh16x8: + return rewriteValuegeneric_OpRsh16x8(v) + case OpRsh32Ux16: + return rewriteValuegeneric_OpRsh32Ux16(v) + case OpRsh32Ux32: + return rewriteValuegeneric_OpRsh32Ux32(v) + case OpRsh32Ux64: + return rewriteValuegeneric_OpRsh32Ux64(v) + case OpRsh32Ux8: + return rewriteValuegeneric_OpRsh32Ux8(v) + case OpRsh32x16: + return rewriteValuegeneric_OpRsh32x16(v) + case OpRsh32x32: + return rewriteValuegeneric_OpRsh32x32(v) + case OpRsh32x64: + return rewriteValuegeneric_OpRsh32x64(v) + case OpRsh32x8: + return rewriteValuegeneric_OpRsh32x8(v) + case OpRsh64Ux16: + return rewriteValuegeneric_OpRsh64Ux16(v) + case OpRsh64Ux32: + return rewriteValuegeneric_OpRsh64Ux32(v) + case OpRsh64Ux64: + return rewriteValuegeneric_OpRsh64Ux64(v) + case OpRsh64Ux8: + return rewriteValuegeneric_OpRsh64Ux8(v) + case OpRsh64x16: + return rewriteValuegeneric_OpRsh64x16(v) + case OpRsh64x32: + return rewriteValuegeneric_OpRsh64x32(v) + case OpRsh64x64: + return rewriteValuegeneric_OpRsh64x64(v) + case OpRsh64x8: + return rewriteValuegeneric_OpRsh64x8(v) + case OpRsh8Ux16: + return rewriteValuegeneric_OpRsh8Ux16(v) + case OpRsh8Ux32: + return rewriteValuegeneric_OpRsh8Ux32(v) + case OpRsh8Ux64: + return rewriteValuegeneric_OpRsh8Ux64(v) + case OpRsh8Ux8: + return rewriteValuegeneric_OpRsh8Ux8(v) + case OpRsh8x16: + return rewriteValuegeneric_OpRsh8x16(v) + case OpRsh8x32: + return rewriteValuegeneric_OpRsh8x32(v) + case OpRsh8x64: + return rewriteValuegeneric_OpRsh8x64(v) + case OpRsh8x8: + return rewriteValuegeneric_OpRsh8x8(v) + case OpSelect0: + return rewriteValuegeneric_OpSelect0(v) + case OpSelect1: + return rewriteValuegeneric_OpSelect1(v) + case OpSelectN: + return rewriteValuegeneric_OpSelectN(v) + case OpSignExt16to32: + return rewriteValuegeneric_OpSignExt16to32(v) + case OpSignExt16to64: + return rewriteValuegeneric_OpSignExt16to64(v) + case OpSignExt32to64: + return rewriteValuegeneric_OpSignExt32to64(v) + case OpSignExt8to16: + return rewriteValuegeneric_OpSignExt8to16(v) + case OpSignExt8to32: + return rewriteValuegeneric_OpSignExt8to32(v) + case OpSignExt8to64: + return rewriteValuegeneric_OpSignExt8to64(v) + case OpSliceCap: + return rewriteValuegeneric_OpSliceCap(v) + case OpSliceLen: + return rewriteValuegeneric_OpSliceLen(v) + case OpSliceMake: + return rewriteValuegeneric_OpSliceMake(v) + case OpSlicePtr: + return rewriteValuegeneric_OpSlicePtr(v) + case OpSlicemask: + return rewriteValuegeneric_OpSlicemask(v) + case OpSqrt: + return rewriteValuegeneric_OpSqrt(v) + case OpStaticCall: + return rewriteValuegeneric_OpStaticCall(v) + case OpStaticLECall: + return rewriteValuegeneric_OpStaticLECall(v) + case OpStore: + return rewriteValuegeneric_OpStore(v) + case OpStringLen: + return rewriteValuegeneric_OpStringLen(v) + case OpStringPtr: + return rewriteValuegeneric_OpStringPtr(v) + case OpStructSelect: + return rewriteValuegeneric_OpStructSelect(v) + case OpSub16: + return rewriteValuegeneric_OpSub16(v) + case OpSub32: + return rewriteValuegeneric_OpSub32(v) + case OpSub32F: + return rewriteValuegeneric_OpSub32F(v) + case OpSub64: + return rewriteValuegeneric_OpSub64(v) + case OpSub64F: + return rewriteValuegeneric_OpSub64F(v) + case OpSub8: + return rewriteValuegeneric_OpSub8(v) + case OpTrunc: + return rewriteValuegeneric_OpTrunc(v) + case OpTrunc16to8: + return rewriteValuegeneric_OpTrunc16to8(v) + case OpTrunc32to16: + return rewriteValuegeneric_OpTrunc32to16(v) + case OpTrunc32to8: + return rewriteValuegeneric_OpTrunc32to8(v) + case OpTrunc64to16: + return rewriteValuegeneric_OpTrunc64to16(v) + case OpTrunc64to32: + return rewriteValuegeneric_OpTrunc64to32(v) + case OpTrunc64to8: + return rewriteValuegeneric_OpTrunc64to8(v) + case OpXor16: + return rewriteValuegeneric_OpXor16(v) + case OpXor32: + return rewriteValuegeneric_OpXor32(v) + case OpXor64: + return rewriteValuegeneric_OpXor64(v) + case OpXor8: + return rewriteValuegeneric_OpXor8(v) + case OpZero: + return rewriteValuegeneric_OpZero(v) + case OpZeroExt16to32: + return rewriteValuegeneric_OpZeroExt16to32(v) + case OpZeroExt16to64: + return rewriteValuegeneric_OpZeroExt16to64(v) + case OpZeroExt32to64: + return rewriteValuegeneric_OpZeroExt32to64(v) + case OpZeroExt8to16: + return rewriteValuegeneric_OpZeroExt8to16(v) + case OpZeroExt8to32: + return rewriteValuegeneric_OpZeroExt8to32(v) + case OpZeroExt8to64: + return rewriteValuegeneric_OpZeroExt8to64(v) + } + return false +} +func rewriteValuegeneric_OpAdd16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Add16 (Const16 [c]) (Const16 [d])) + // result: (Const16 [c+d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c + d) + return true + } + break + } + // match: (Add16 (Mul16 x y) (Mul16 x z)) + // result: (Mul16 x (Add16 y z)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMul16 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if v_1.Op != OpMul16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + z := v_1_1 + v.reset(OpMul16) + v0 := b.NewValue0(v.Pos, OpAdd16, t) + v0.AddArg2(y, z) + v.AddArg2(x, v0) + return true + } + } + } + break + } + // match: (Add16 (Const16 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Add16 x (Neg16 y)) + // result: (Sub16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpNeg16 { + continue + } + y := v_1.Args[0] + v.reset(OpSub16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add16 (Com16 x) x) + // result: (Const16 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom16 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(-1) + return true + } + break + } + // match: (Add16 (Sub16 x t) (Add16 t y)) + // result: (Add16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSub16 { + continue + } + t := v_0.Args[1] + x := v_0.Args[0] + if v_1.Op != OpAdd16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if t != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpAdd16) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Add16 (Const16 [1]) (Com16 x)) + // result: (Neg16 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 1 || v_1.Op != OpCom16 { + continue + } + x := v_1.Args[0] + v.reset(OpNeg16) + v.AddArg(x) + return true + } + break + } + // match: (Add16 x (Sub16 y x)) + // result: y + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpSub16 { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if x != v_1.Args[1] { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (Add16 x (Add16 y (Sub16 z x))) + // result: (Add16 y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAdd16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpSub16 { + continue + } + _ = v_1_1.Args[1] + z := v_1_1.Args[0] + if x != v_1_1.Args[1] { + continue + } + v.reset(OpAdd16) + v.AddArg2(y, z) + return true + } + } + break + } + // match: (Add16 (Add16 i:(Const16 ) z) x) + // cond: (z.Op != OpConst16 && x.Op != OpConst16) + // result: (Add16 i (Add16 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAdd16 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst16 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst16 && x.Op != OpConst16) { + continue + } + v.reset(OpAdd16) + v0 := b.NewValue0(v.Pos, OpAdd16, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Add16 (Sub16 i:(Const16 ) z) x) + // cond: (z.Op != OpConst16 && x.Op != OpConst16) + // result: (Add16 i (Sub16 x z)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSub16 { + continue + } + z := v_0.Args[1] + i := v_0.Args[0] + if i.Op != OpConst16 { + continue + } + t := i.Type + x := v_1 + if !(z.Op != OpConst16 && x.Op != OpConst16) { + continue + } + v.reset(OpAdd16) + v0 := b.NewValue0(v.Pos, OpSub16, t) + v0.AddArg2(x, z) + v.AddArg2(i, v0) + return true + } + break + } + // match: (Add16 (Const16 [c]) (Add16 (Const16 [d]) x)) + // result: (Add16 (Const16 [c+d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpAdd16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + continue + } + d := auxIntToInt16(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpAdd16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c + d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Add16 (Const16 [c]) (Sub16 (Const16 [d]) x)) + // result: (Sub16 (Const16 [c+d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpSub16 { + continue + } + x := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + continue + } + d := auxIntToInt16(v_1_0.AuxInt) + v.reset(OpSub16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c + d) + v.AddArg2(v0, x) + return true + } + break + } + // match: (Add16 (Lsh16x64 x z:(Const64 [c])) (Rsh16Ux64 x (Const64 [d]))) + // cond: c < 16 && d == 16-c && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh16x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh16Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 16 && d == 16-c && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add16 left:(Lsh16x64 x y) right:(Rsh16Ux64 x (Sub64 (Const64 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add16 left:(Lsh16x32 x y) right:(Rsh16Ux32 x (Sub32 (Const32 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add16 left:(Lsh16x16 x y) right:(Rsh16Ux16 x (Sub16 (Const16 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add16 left:(Lsh16x8 x y) right:(Rsh16Ux8 x (Sub8 (Const8 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add16 right:(Rsh16Ux64 x y) left:(Lsh16x64 x z:(Sub64 (Const64 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add16 right:(Rsh16Ux32 x y) left:(Lsh16x32 x z:(Sub32 (Const32 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add16 right:(Rsh16Ux16 x y) left:(Lsh16x16 x z:(Sub16 (Const16 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add16 right:(Rsh16Ux8 x y) left:(Lsh16x8 x z:(Sub8 (Const8 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpAdd32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Add32 (Const32 [c]) (Const32 [d])) + // result: (Const32 [c+d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c + d) + return true + } + break + } + // match: (Add32 (Mul32 x y) (Mul32 x z)) + // result: (Mul32 x (Add32 y z)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMul32 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if v_1.Op != OpMul32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + z := v_1_1 + v.reset(OpMul32) + v0 := b.NewValue0(v.Pos, OpAdd32, t) + v0.AddArg2(y, z) + v.AddArg2(x, v0) + return true + } + } + } + break + } + // match: (Add32 (Const32 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Add32 x (Neg32 y)) + // result: (Sub32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpNeg32 { + continue + } + y := v_1.Args[0] + v.reset(OpSub32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add32 (Com32 x) x) + // result: (Const32 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom32 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(-1) + return true + } + break + } + // match: (Add32 (Sub32 x t) (Add32 t y)) + // result: (Add32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSub32 { + continue + } + t := v_0.Args[1] + x := v_0.Args[0] + if v_1.Op != OpAdd32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if t != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpAdd32) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Add32 (Const32 [1]) (Com32 x)) + // result: (Neg32 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 1 || v_1.Op != OpCom32 { + continue + } + x := v_1.Args[0] + v.reset(OpNeg32) + v.AddArg(x) + return true + } + break + } + // match: (Add32 x (Sub32 y x)) + // result: y + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpSub32 { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if x != v_1.Args[1] { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (Add32 x (Add32 y (Sub32 z x))) + // result: (Add32 y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAdd32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpSub32 { + continue + } + _ = v_1_1.Args[1] + z := v_1_1.Args[0] + if x != v_1_1.Args[1] { + continue + } + v.reset(OpAdd32) + v.AddArg2(y, z) + return true + } + } + break + } + // match: (Add32 (Add32 i:(Const32 ) z) x) + // cond: (z.Op != OpConst32 && x.Op != OpConst32) + // result: (Add32 i (Add32 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAdd32 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst32 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst32 && x.Op != OpConst32) { + continue + } + v.reset(OpAdd32) + v0 := b.NewValue0(v.Pos, OpAdd32, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Add32 (Sub32 i:(Const32 ) z) x) + // cond: (z.Op != OpConst32 && x.Op != OpConst32) + // result: (Add32 i (Sub32 x z)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSub32 { + continue + } + z := v_0.Args[1] + i := v_0.Args[0] + if i.Op != OpConst32 { + continue + } + t := i.Type + x := v_1 + if !(z.Op != OpConst32 && x.Op != OpConst32) { + continue + } + v.reset(OpAdd32) + v0 := b.NewValue0(v.Pos, OpSub32, t) + v0.AddArg2(x, z) + v.AddArg2(i, v0) + return true + } + break + } + // match: (Add32 (Const32 [c]) (Add32 (Const32 [d]) x)) + // result: (Add32 (Const32 [c+d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpAdd32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + continue + } + d := auxIntToInt32(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpAdd32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c + d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Add32 (Const32 [c]) (Sub32 (Const32 [d]) x)) + // result: (Sub32 (Const32 [c+d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpSub32 { + continue + } + x := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + continue + } + d := auxIntToInt32(v_1_0.AuxInt) + v.reset(OpSub32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c + d) + v.AddArg2(v0, x) + return true + } + break + } + // match: (Add32 (Lsh32x64 x z:(Const64 [c])) (Rsh32Ux64 x (Const64 [d]))) + // cond: c < 32 && d == 32-c && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh32x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh32Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 32 && d == 32-c && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add32 left:(Lsh32x64 x y) right:(Rsh32Ux64 x (Sub64 (Const64 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add32 left:(Lsh32x32 x y) right:(Rsh32Ux32 x (Sub32 (Const32 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add32 left:(Lsh32x16 x y) right:(Rsh32Ux16 x (Sub16 (Const16 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add32 left:(Lsh32x8 x y) right:(Rsh32Ux8 x (Sub8 (Const8 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add32 right:(Rsh32Ux64 x y) left:(Lsh32x64 x z:(Sub64 (Const64 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add32 right:(Rsh32Ux32 x y) left:(Lsh32x32 x z:(Sub32 (Const32 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add32 right:(Rsh32Ux16 x y) left:(Lsh32x16 x z:(Sub16 (Const16 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add32 right:(Rsh32Ux8 x y) left:(Lsh32x8 x z:(Sub8 (Const8 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpAdd32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Add32F (Const32F [c]) (Const32F [d])) + // cond: c+d == c+d + // result: (Const32F [c+d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32F { + continue + } + c := auxIntToFloat32(v_0.AuxInt) + if v_1.Op != OpConst32F { + continue + } + d := auxIntToFloat32(v_1.AuxInt) + if !(c+d == c+d) { + continue + } + v.reset(OpConst32F) + v.AuxInt = float32ToAuxInt(c + d) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpAdd64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Add64 (Const64 [c]) (Const64 [d])) + // result: (Const64 [c+d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c + d) + return true + } + break + } + // match: (Add64 (Mul64 x y) (Mul64 x z)) + // result: (Mul64 x (Add64 y z)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMul64 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if v_1.Op != OpMul64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + z := v_1_1 + v.reset(OpMul64) + v0 := b.NewValue0(v.Pos, OpAdd64, t) + v0.AddArg2(y, z) + v.AddArg2(x, v0) + return true + } + } + } + break + } + // match: (Add64 (Const64 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Add64 x (Neg64 y)) + // result: (Sub64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpNeg64 { + continue + } + y := v_1.Args[0] + v.reset(OpSub64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add64 (Com64 x) x) + // result: (Const64 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom64 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(-1) + return true + } + break + } + // match: (Add64 (Sub64 x t) (Add64 t y)) + // result: (Add64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSub64 { + continue + } + t := v_0.Args[1] + x := v_0.Args[0] + if v_1.Op != OpAdd64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if t != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpAdd64) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Add64 (Const64 [1]) (Com64 x)) + // result: (Neg64 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 1 || v_1.Op != OpCom64 { + continue + } + x := v_1.Args[0] + v.reset(OpNeg64) + v.AddArg(x) + return true + } + break + } + // match: (Add64 x (Sub64 y x)) + // result: y + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpSub64 { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if x != v_1.Args[1] { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (Add64 x (Add64 y (Sub64 z x))) + // result: (Add64 y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAdd64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpSub64 { + continue + } + _ = v_1_1.Args[1] + z := v_1_1.Args[0] + if x != v_1_1.Args[1] { + continue + } + v.reset(OpAdd64) + v.AddArg2(y, z) + return true + } + } + break + } + // match: (Add64 (Add64 i:(Const64 ) z) x) + // cond: (z.Op != OpConst64 && x.Op != OpConst64) + // result: (Add64 i (Add64 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAdd64 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst64 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst64 && x.Op != OpConst64) { + continue + } + v.reset(OpAdd64) + v0 := b.NewValue0(v.Pos, OpAdd64, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Add64 (Sub64 i:(Const64 ) z) x) + // cond: (z.Op != OpConst64 && x.Op != OpConst64) + // result: (Add64 i (Sub64 x z)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSub64 { + continue + } + z := v_0.Args[1] + i := v_0.Args[0] + if i.Op != OpConst64 { + continue + } + t := i.Type + x := v_1 + if !(z.Op != OpConst64 && x.Op != OpConst64) { + continue + } + v.reset(OpAdd64) + v0 := b.NewValue0(v.Pos, OpSub64, t) + v0.AddArg2(x, z) + v.AddArg2(i, v0) + return true + } + break + } + // match: (Add64 (Const64 [c]) (Add64 (Const64 [d]) x)) + // result: (Add64 (Const64 [c+d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpAdd64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + continue + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpAdd64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Add64 (Const64 [c]) (Sub64 (Const64 [d]) x)) + // result: (Sub64 (Const64 [c+d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpSub64 { + continue + } + x := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + continue + } + d := auxIntToInt64(v_1_0.AuxInt) + v.reset(OpSub64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(v0, x) + return true + } + break + } + // match: (Add64 (Lsh64x64 x z:(Const64 [c])) (Rsh64Ux64 x (Const64 [d]))) + // cond: c < 64 && d == 64-c && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh64x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh64Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 64 && d == 64-c && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add64 left:(Lsh64x64 x y) right:(Rsh64Ux64 x (Sub64 (Const64 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add64 left:(Lsh64x32 x y) right:(Rsh64Ux32 x (Sub32 (Const32 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add64 left:(Lsh64x16 x y) right:(Rsh64Ux16 x (Sub16 (Const16 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add64 left:(Lsh64x8 x y) right:(Rsh64Ux8 x (Sub8 (Const8 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add64 right:(Rsh64Ux64 x y) left:(Lsh64x64 x z:(Sub64 (Const64 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add64 right:(Rsh64Ux32 x y) left:(Lsh64x32 x z:(Sub32 (Const32 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add64 right:(Rsh64Ux16 x y) left:(Lsh64x16 x z:(Sub16 (Const16 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add64 right:(Rsh64Ux8 x y) left:(Lsh64x8 x z:(Sub8 (Const8 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpAdd64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Add64F (Const64F [c]) (Const64F [d])) + // cond: c+d == c+d + // result: (Const64F [c+d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64F { + continue + } + c := auxIntToFloat64(v_0.AuxInt) + if v_1.Op != OpConst64F { + continue + } + d := auxIntToFloat64(v_1.AuxInt) + if !(c+d == c+d) { + continue + } + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(c + d) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpAdd64carry(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Add64carry (Const64 [x]) (Const64 [y]) (Const64 [c])) + // cond: c >= 0 && c <= 1 + // result: (MakeTuple (Const64 [bitsAdd64(x, y, c).sum]) (Const64 [bitsAdd64(x, y, c).carry])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + x := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + y := auxIntToInt64(v_1.AuxInt) + if v_2.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_2.AuxInt) + if !(c >= 0 && c <= 1) { + continue + } + v.reset(OpMakeTuple) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(bitsAdd64(x, y, c).sum) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(bitsAdd64(x, y, c).carry) + v.AddArg2(v0, v1) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpAdd8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Add8 (Const8 [c]) (Const8 [d])) + // result: (Const8 [c+d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c + d) + return true + } + break + } + // match: (Add8 (Mul8 x y) (Mul8 x z)) + // result: (Mul8 x (Add8 y z)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMul8 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if v_1.Op != OpMul8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + z := v_1_1 + v.reset(OpMul8) + v0 := b.NewValue0(v.Pos, OpAdd8, t) + v0.AddArg2(y, z) + v.AddArg2(x, v0) + return true + } + } + } + break + } + // match: (Add8 (Const8 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Add8 x (Neg8 y)) + // result: (Sub8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpNeg8 { + continue + } + y := v_1.Args[0] + v.reset(OpSub8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add8 (Com8 x) x) + // result: (Const8 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom8 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(-1) + return true + } + break + } + // match: (Add8 (Sub8 x t) (Add8 t y)) + // result: (Add8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSub8 { + continue + } + t := v_0.Args[1] + x := v_0.Args[0] + if v_1.Op != OpAdd8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if t != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpAdd8) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Add8 (Const8 [1]) (Com8 x)) + // result: (Neg8 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 1 || v_1.Op != OpCom8 { + continue + } + x := v_1.Args[0] + v.reset(OpNeg8) + v.AddArg(x) + return true + } + break + } + // match: (Add8 x (Sub8 y x)) + // result: y + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpSub8 { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if x != v_1.Args[1] { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (Add8 x (Add8 y (Sub8 z x))) + // result: (Add8 y z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAdd8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpSub8 { + continue + } + _ = v_1_1.Args[1] + z := v_1_1.Args[0] + if x != v_1_1.Args[1] { + continue + } + v.reset(OpAdd8) + v.AddArg2(y, z) + return true + } + } + break + } + // match: (Add8 (Add8 i:(Const8 ) z) x) + // cond: (z.Op != OpConst8 && x.Op != OpConst8) + // result: (Add8 i (Add8 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAdd8 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst8 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst8 && x.Op != OpConst8) { + continue + } + v.reset(OpAdd8) + v0 := b.NewValue0(v.Pos, OpAdd8, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Add8 (Sub8 i:(Const8 ) z) x) + // cond: (z.Op != OpConst8 && x.Op != OpConst8) + // result: (Add8 i (Sub8 x z)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSub8 { + continue + } + z := v_0.Args[1] + i := v_0.Args[0] + if i.Op != OpConst8 { + continue + } + t := i.Type + x := v_1 + if !(z.Op != OpConst8 && x.Op != OpConst8) { + continue + } + v.reset(OpAdd8) + v0 := b.NewValue0(v.Pos, OpSub8, t) + v0.AddArg2(x, z) + v.AddArg2(i, v0) + return true + } + break + } + // match: (Add8 (Const8 [c]) (Add8 (Const8 [d]) x)) + // result: (Add8 (Const8 [c+d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpAdd8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + continue + } + d := auxIntToInt8(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpAdd8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c + d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Add8 (Const8 [c]) (Sub8 (Const8 [d]) x)) + // result: (Sub8 (Const8 [c+d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpSub8 { + continue + } + x := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + continue + } + d := auxIntToInt8(v_1_0.AuxInt) + v.reset(OpSub8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c + d) + v.AddArg2(v0, x) + return true + } + break + } + // match: (Add8 (Lsh8x64 x z:(Const64 [c])) (Rsh8Ux64 x (Const64 [d]))) + // cond: c < 8 && d == 8-c && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh8x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh8Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 8 && d == 8-c && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add8 left:(Lsh8x64 x y) right:(Rsh8Ux64 x (Sub64 (Const64 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add8 left:(Lsh8x32 x y) right:(Rsh8Ux32 x (Sub32 (Const32 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add8 left:(Lsh8x16 x y) right:(Rsh8Ux16 x (Sub16 (Const16 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add8 left:(Lsh8x8 x y) right:(Rsh8Ux8 x (Sub8 (Const8 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Add8 right:(Rsh8Ux64 x y) left:(Lsh8x64 x z:(Sub64 (Const64 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add8 right:(Rsh8Ux32 x y) left:(Lsh8x32 x z:(Sub32 (Const32 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add8 right:(Rsh8Ux16 x y) left:(Lsh8x16 x z:(Sub16 (Const16 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Add8 right:(Rsh8Ux8 x y) left:(Lsh8x8 x z:(Sub8 (Const8 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpAddPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (AddPtr x (Const64 [c])) + // result: (OffPtr x [c]) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + v.reset(OpOffPtr) + v.Type = t + v.AuxInt = int64ToAuxInt(c) + v.AddArg(x) + return true + } + // match: (AddPtr x (Const32 [c])) + // result: (OffPtr x [int64(c)]) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpOffPtr) + v.Type = t + v.AuxInt = int64ToAuxInt(int64(c)) + v.AddArg(x) + return true + } + return false +} +func rewriteValuegeneric_OpAnd16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (And16 (Const16 [c]) (Const16 [d])) + // result: (Const16 [c&d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c & d) + return true + } + break + } + // match: (And16 (Com16 x) (Com16 y)) + // result: (Com16 (Or16 x y)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom16 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpCom16 { + continue + } + y := v_1.Args[0] + v.reset(OpCom16) + v0 := b.NewValue0(v.Pos, OpOr16, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (And16 (Const16 [m]) (Rsh16Ux64 _ (Const64 [c]))) + // cond: c >= int64(16-ntz16(m)) + // result: (Const16 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + m := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpRsh16Ux64 { + continue + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c >= int64(16-ntz16(m))) { + continue + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + break + } + // match: (And16 (Const16 [m]) (Lsh16x64 _ (Const64 [c]))) + // cond: c >= int64(16-nlz16(m)) + // result: (Const16 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + m := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpLsh16x64 { + continue + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c >= int64(16-nlz16(m))) { + continue + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + break + } + // match: (And16 x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (And16 (Const16 [-1]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (And16 (Const16 [0]) _) + // result: (Const16 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + continue + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + break + } + // match: (And16 (Com16 x) x) + // result: (Const16 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom16 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + break + } + // match: (And16 x (And16 x y)) + // result: (And16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAnd16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpAnd16) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (And16 (And16 i:(Const16 ) z) x) + // cond: (z.Op != OpConst16 && x.Op != OpConst16) + // result: (And16 i (And16 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd16 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst16 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst16 && x.Op != OpConst16) { + continue + } + v.reset(OpAnd16) + v0 := b.NewValue0(v.Pos, OpAnd16, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (And16 (Const16 [c]) (And16 (Const16 [d]) x)) + // result: (And16 (Const16 [c&d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpAnd16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + continue + } + d := auxIntToInt16(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpAnd16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c & d) + v.AddArg2(v0, x) + return true + } + } + break + } + return false +} +func rewriteValuegeneric_OpAnd32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (And32 (Const32 [c]) (Const32 [d])) + // result: (Const32 [c&d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c & d) + return true + } + break + } + // match: (And32 (Com32 x) (Com32 y)) + // result: (Com32 (Or32 x y)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom32 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpCom32 { + continue + } + y := v_1.Args[0] + v.reset(OpCom32) + v0 := b.NewValue0(v.Pos, OpOr32, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (And32 (Const32 [m]) (Rsh32Ux64 _ (Const64 [c]))) + // cond: c >= int64(32-ntz32(m)) + // result: (Const32 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + m := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpRsh32Ux64 { + continue + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c >= int64(32-ntz32(m))) { + continue + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + break + } + // match: (And32 (Const32 [m]) (Lsh32x64 _ (Const64 [c]))) + // cond: c >= int64(32-nlz32(m)) + // result: (Const32 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + m := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpLsh32x64 { + continue + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c >= int64(32-nlz32(m))) { + continue + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + break + } + // match: (And32 x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (And32 (Const32 [-1]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (And32 (Const32 [0]) _) + // result: (Const32 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + continue + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + break + } + // match: (And32 (Com32 x) x) + // result: (Const32 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom32 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + break + } + // match: (And32 x (And32 x y)) + // result: (And32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAnd32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpAnd32) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (And32 (And32 i:(Const32 ) z) x) + // cond: (z.Op != OpConst32 && x.Op != OpConst32) + // result: (And32 i (And32 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd32 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst32 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst32 && x.Op != OpConst32) { + continue + } + v.reset(OpAnd32) + v0 := b.NewValue0(v.Pos, OpAnd32, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (And32 (Const32 [c]) (And32 (Const32 [d]) x)) + // result: (And32 (Const32 [c&d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpAnd32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + continue + } + d := auxIntToInt32(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpAnd32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c & d) + v.AddArg2(v0, x) + return true + } + } + break + } + return false +} +func rewriteValuegeneric_OpAnd64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (And64 (Const64 [c]) (Const64 [d])) + // result: (Const64 [c&d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c & d) + return true + } + break + } + // match: (And64 (Com64 x) (Com64 y)) + // result: (Com64 (Or64 x y)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom64 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpCom64 { + continue + } + y := v_1.Args[0] + v.reset(OpCom64) + v0 := b.NewValue0(v.Pos, OpOr64, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (And64 (Const64 [m]) (Rsh64Ux64 _ (Const64 [c]))) + // cond: c >= int64(64-ntz64(m)) + // result: (Const64 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + m := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpRsh64Ux64 { + continue + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c >= int64(64-ntz64(m))) { + continue + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (And64 (Const64 [m]) (Lsh64x64 _ (Const64 [c]))) + // cond: c >= int64(64-nlz64(m)) + // result: (Const64 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + m := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpLsh64x64 { + continue + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c >= int64(64-nlz64(m))) { + continue + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (And64 x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (And64 (Const64 [-1]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (And64 (Const64 [0]) _) + // result: (Const64 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + continue + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (And64 (Com64 x) x) + // result: (Const64 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom64 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (And64 x (And64 x y)) + // result: (And64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAnd64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpAnd64) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (And64 (And64 i:(Const64 ) z) x) + // cond: (z.Op != OpConst64 && x.Op != OpConst64) + // result: (And64 i (And64 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd64 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst64 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst64 && x.Op != OpConst64) { + continue + } + v.reset(OpAnd64) + v0 := b.NewValue0(v.Pos, OpAnd64, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (And64 (Const64 [c]) (And64 (Const64 [d]) x)) + // result: (And64 (Const64 [c&d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpAnd64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + continue + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpAnd64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c & d) + v.AddArg2(v0, x) + return true + } + } + break + } + return false +} +func rewriteValuegeneric_OpAnd8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (And8 (Const8 [c]) (Const8 [d])) + // result: (Const8 [c&d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c & d) + return true + } + break + } + // match: (And8 (Com8 x) (Com8 y)) + // result: (Com8 (Or8 x y)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom8 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpCom8 { + continue + } + y := v_1.Args[0] + v.reset(OpCom8) + v0 := b.NewValue0(v.Pos, OpOr8, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (And8 (Const8 [m]) (Rsh8Ux64 _ (Const64 [c]))) + // cond: c >= int64(8-ntz8(m)) + // result: (Const8 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + m := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpRsh8Ux64 { + continue + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c >= int64(8-ntz8(m))) { + continue + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + break + } + // match: (And8 (Const8 [m]) (Lsh8x64 _ (Const64 [c]))) + // cond: c >= int64(8-nlz8(m)) + // result: (Const8 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + m := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpLsh8x64 { + continue + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c >= int64(8-nlz8(m))) { + continue + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + break + } + // match: (And8 x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (And8 (Const8 [-1]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (And8 (Const8 [0]) _) + // result: (Const8 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + continue + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + break + } + // match: (And8 (Com8 x) x) + // result: (Const8 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom8 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + break + } + // match: (And8 x (And8 x y)) + // result: (And8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpAnd8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpAnd8) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (And8 (And8 i:(Const8 ) z) x) + // cond: (z.Op != OpConst8 && x.Op != OpConst8) + // result: (And8 i (And8 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd8 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst8 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst8 && x.Op != OpConst8) { + continue + } + v.reset(OpAnd8) + v0 := b.NewValue0(v.Pos, OpAnd8, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (And8 (Const8 [c]) (And8 (Const8 [d]) x)) + // result: (And8 (Const8 [c&d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpAnd8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + continue + } + d := auxIntToInt8(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpAnd8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c & d) + v.AddArg2(v0, x) + return true + } + } + break + } + return false +} +func rewriteValuegeneric_OpAndB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (AndB (Leq64 (Const64 [c]) x) (Less64 x (Const64 [d]))) + // cond: d >= c + // result: (Less64U (Sub64 x (Const64 [c])) (Const64 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq64 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLess64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(d >= c) { + continue + } + v.reset(OpLess64U) + v0 := b.NewValue0(v.Pos, OpSub64, x.Type) + v1 := b.NewValue0(v.Pos, OpConst64, x.Type) + v1.AuxInt = int64ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq64 (Const64 [c]) x) (Leq64 x (Const64 [d]))) + // cond: d >= c + // result: (Leq64U (Sub64 x (Const64 [c])) (Const64 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq64 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLeq64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(d >= c) { + continue + } + v.reset(OpLeq64U) + v0 := b.NewValue0(v.Pos, OpSub64, x.Type) + v1 := b.NewValue0(v.Pos, OpConst64, x.Type) + v1.AuxInt = int64ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq32 (Const32 [c]) x) (Less32 x (Const32 [d]))) + // cond: d >= c + // result: (Less32U (Sub32 x (Const32 [c])) (Const32 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq32 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLess32 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(d >= c) { + continue + } + v.reset(OpLess32U) + v0 := b.NewValue0(v.Pos, OpSub32, x.Type) + v1 := b.NewValue0(v.Pos, OpConst32, x.Type) + v1.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq32 (Const32 [c]) x) (Leq32 x (Const32 [d]))) + // cond: d >= c + // result: (Leq32U (Sub32 x (Const32 [c])) (Const32 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq32 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLeq32 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(d >= c) { + continue + } + v.reset(OpLeq32U) + v0 := b.NewValue0(v.Pos, OpSub32, x.Type) + v1 := b.NewValue0(v.Pos, OpConst32, x.Type) + v1.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq16 (Const16 [c]) x) (Less16 x (Const16 [d]))) + // cond: d >= c + // result: (Less16U (Sub16 x (Const16 [c])) (Const16 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq16 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLess16 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(d >= c) { + continue + } + v.reset(OpLess16U) + v0 := b.NewValue0(v.Pos, OpSub16, x.Type) + v1 := b.NewValue0(v.Pos, OpConst16, x.Type) + v1.AuxInt = int16ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq16 (Const16 [c]) x) (Leq16 x (Const16 [d]))) + // cond: d >= c + // result: (Leq16U (Sub16 x (Const16 [c])) (Const16 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq16 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLeq16 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(d >= c) { + continue + } + v.reset(OpLeq16U) + v0 := b.NewValue0(v.Pos, OpSub16, x.Type) + v1 := b.NewValue0(v.Pos, OpConst16, x.Type) + v1.AuxInt = int16ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq8 (Const8 [c]) x) (Less8 x (Const8 [d]))) + // cond: d >= c + // result: (Less8U (Sub8 x (Const8 [c])) (Const8 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq8 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLess8 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(d >= c) { + continue + } + v.reset(OpLess8U) + v0 := b.NewValue0(v.Pos, OpSub8, x.Type) + v1 := b.NewValue0(v.Pos, OpConst8, x.Type) + v1.AuxInt = int8ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq8 (Const8 [c]) x) (Leq8 x (Const8 [d]))) + // cond: d >= c + // result: (Leq8U (Sub8 x (Const8 [c])) (Const8 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq8 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLeq8 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(d >= c) { + continue + } + v.reset(OpLeq8U) + v0 := b.NewValue0(v.Pos, OpSub8, x.Type) + v1 := b.NewValue0(v.Pos, OpConst8, x.Type) + v1.AuxInt = int8ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less64 (Const64 [c]) x) (Less64 x (Const64 [d]))) + // cond: d >= c+1 && c+1 > c + // result: (Less64U (Sub64 x (Const64 [c+1])) (Const64 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess64 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLess64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(d >= c+1 && c+1 > c) { + continue + } + v.reset(OpLess64U) + v0 := b.NewValue0(v.Pos, OpSub64, x.Type) + v1 := b.NewValue0(v.Pos, OpConst64, x.Type) + v1.AuxInt = int64ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less64 (Const64 [c]) x) (Leq64 x (Const64 [d]))) + // cond: d >= c+1 && c+1 > c + // result: (Leq64U (Sub64 x (Const64 [c+1])) (Const64 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess64 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLeq64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(d >= c+1 && c+1 > c) { + continue + } + v.reset(OpLeq64U) + v0 := b.NewValue0(v.Pos, OpSub64, x.Type) + v1 := b.NewValue0(v.Pos, OpConst64, x.Type) + v1.AuxInt = int64ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less32 (Const32 [c]) x) (Less32 x (Const32 [d]))) + // cond: d >= c+1 && c+1 > c + // result: (Less32U (Sub32 x (Const32 [c+1])) (Const32 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess32 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLess32 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(d >= c+1 && c+1 > c) { + continue + } + v.reset(OpLess32U) + v0 := b.NewValue0(v.Pos, OpSub32, x.Type) + v1 := b.NewValue0(v.Pos, OpConst32, x.Type) + v1.AuxInt = int32ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less32 (Const32 [c]) x) (Leq32 x (Const32 [d]))) + // cond: d >= c+1 && c+1 > c + // result: (Leq32U (Sub32 x (Const32 [c+1])) (Const32 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess32 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLeq32 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(d >= c+1 && c+1 > c) { + continue + } + v.reset(OpLeq32U) + v0 := b.NewValue0(v.Pos, OpSub32, x.Type) + v1 := b.NewValue0(v.Pos, OpConst32, x.Type) + v1.AuxInt = int32ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less16 (Const16 [c]) x) (Less16 x (Const16 [d]))) + // cond: d >= c+1 && c+1 > c + // result: (Less16U (Sub16 x (Const16 [c+1])) (Const16 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess16 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLess16 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(d >= c+1 && c+1 > c) { + continue + } + v.reset(OpLess16U) + v0 := b.NewValue0(v.Pos, OpSub16, x.Type) + v1 := b.NewValue0(v.Pos, OpConst16, x.Type) + v1.AuxInt = int16ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less16 (Const16 [c]) x) (Leq16 x (Const16 [d]))) + // cond: d >= c+1 && c+1 > c + // result: (Leq16U (Sub16 x (Const16 [c+1])) (Const16 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess16 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLeq16 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(d >= c+1 && c+1 > c) { + continue + } + v.reset(OpLeq16U) + v0 := b.NewValue0(v.Pos, OpSub16, x.Type) + v1 := b.NewValue0(v.Pos, OpConst16, x.Type) + v1.AuxInt = int16ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less8 (Const8 [c]) x) (Less8 x (Const8 [d]))) + // cond: d >= c+1 && c+1 > c + // result: (Less8U (Sub8 x (Const8 [c+1])) (Const8 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess8 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLess8 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(d >= c+1 && c+1 > c) { + continue + } + v.reset(OpLess8U) + v0 := b.NewValue0(v.Pos, OpSub8, x.Type) + v1 := b.NewValue0(v.Pos, OpConst8, x.Type) + v1.AuxInt = int8ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less8 (Const8 [c]) x) (Leq8 x (Const8 [d]))) + // cond: d >= c+1 && c+1 > c + // result: (Leq8U (Sub8 x (Const8 [c+1])) (Const8 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess8 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLeq8 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(d >= c+1 && c+1 > c) { + continue + } + v.reset(OpLeq8U) + v0 := b.NewValue0(v.Pos, OpSub8, x.Type) + v1 := b.NewValue0(v.Pos, OpConst8, x.Type) + v1.AuxInt = int8ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq64U (Const64 [c]) x) (Less64U x (Const64 [d]))) + // cond: uint64(d) >= uint64(c) + // result: (Less64U (Sub64 x (Const64 [c])) (Const64 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq64U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLess64U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(uint64(d) >= uint64(c)) { + continue + } + v.reset(OpLess64U) + v0 := b.NewValue0(v.Pos, OpSub64, x.Type) + v1 := b.NewValue0(v.Pos, OpConst64, x.Type) + v1.AuxInt = int64ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq64U (Const64 [c]) x) (Leq64U x (Const64 [d]))) + // cond: uint64(d) >= uint64(c) + // result: (Leq64U (Sub64 x (Const64 [c])) (Const64 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq64U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLeq64U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(uint64(d) >= uint64(c)) { + continue + } + v.reset(OpLeq64U) + v0 := b.NewValue0(v.Pos, OpSub64, x.Type) + v1 := b.NewValue0(v.Pos, OpConst64, x.Type) + v1.AuxInt = int64ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq32U (Const32 [c]) x) (Less32U x (Const32 [d]))) + // cond: uint32(d) >= uint32(c) + // result: (Less32U (Sub32 x (Const32 [c])) (Const32 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq32U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLess32U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(uint32(d) >= uint32(c)) { + continue + } + v.reset(OpLess32U) + v0 := b.NewValue0(v.Pos, OpSub32, x.Type) + v1 := b.NewValue0(v.Pos, OpConst32, x.Type) + v1.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq32U (Const32 [c]) x) (Leq32U x (Const32 [d]))) + // cond: uint32(d) >= uint32(c) + // result: (Leq32U (Sub32 x (Const32 [c])) (Const32 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq32U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLeq32U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(uint32(d) >= uint32(c)) { + continue + } + v.reset(OpLeq32U) + v0 := b.NewValue0(v.Pos, OpSub32, x.Type) + v1 := b.NewValue0(v.Pos, OpConst32, x.Type) + v1.AuxInt = int32ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq16U (Const16 [c]) x) (Less16U x (Const16 [d]))) + // cond: uint16(d) >= uint16(c) + // result: (Less16U (Sub16 x (Const16 [c])) (Const16 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq16U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLess16U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(uint16(d) >= uint16(c)) { + continue + } + v.reset(OpLess16U) + v0 := b.NewValue0(v.Pos, OpSub16, x.Type) + v1 := b.NewValue0(v.Pos, OpConst16, x.Type) + v1.AuxInt = int16ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq16U (Const16 [c]) x) (Leq16U x (Const16 [d]))) + // cond: uint16(d) >= uint16(c) + // result: (Leq16U (Sub16 x (Const16 [c])) (Const16 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq16U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLeq16U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(uint16(d) >= uint16(c)) { + continue + } + v.reset(OpLeq16U) + v0 := b.NewValue0(v.Pos, OpSub16, x.Type) + v1 := b.NewValue0(v.Pos, OpConst16, x.Type) + v1.AuxInt = int16ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq8U (Const8 [c]) x) (Less8U x (Const8 [d]))) + // cond: uint8(d) >= uint8(c) + // result: (Less8U (Sub8 x (Const8 [c])) (Const8 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq8U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLess8U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(uint8(d) >= uint8(c)) { + continue + } + v.reset(OpLess8U) + v0 := b.NewValue0(v.Pos, OpSub8, x.Type) + v1 := b.NewValue0(v.Pos, OpConst8, x.Type) + v1.AuxInt = int8ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Leq8U (Const8 [c]) x) (Leq8U x (Const8 [d]))) + // cond: uint8(d) >= uint8(c) + // result: (Leq8U (Sub8 x (Const8 [c])) (Const8 [d-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq8U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLeq8U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(uint8(d) >= uint8(c)) { + continue + } + v.reset(OpLeq8U) + v0 := b.NewValue0(v.Pos, OpSub8, x.Type) + v1 := b.NewValue0(v.Pos, OpConst8, x.Type) + v1.AuxInt = int8ToAuxInt(c) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d - c) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less64U (Const64 [c]) x) (Less64U x (Const64 [d]))) + // cond: uint64(d) >= uint64(c+1) && uint64(c+1) > uint64(c) + // result: (Less64U (Sub64 x (Const64 [c+1])) (Const64 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess64U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLess64U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(uint64(d) >= uint64(c+1) && uint64(c+1) > uint64(c)) { + continue + } + v.reset(OpLess64U) + v0 := b.NewValue0(v.Pos, OpSub64, x.Type) + v1 := b.NewValue0(v.Pos, OpConst64, x.Type) + v1.AuxInt = int64ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less64U (Const64 [c]) x) (Leq64U x (Const64 [d]))) + // cond: uint64(d) >= uint64(c+1) && uint64(c+1) > uint64(c) + // result: (Leq64U (Sub64 x (Const64 [c+1])) (Const64 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess64U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLeq64U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(uint64(d) >= uint64(c+1) && uint64(c+1) > uint64(c)) { + continue + } + v.reset(OpLeq64U) + v0 := b.NewValue0(v.Pos, OpSub64, x.Type) + v1 := b.NewValue0(v.Pos, OpConst64, x.Type) + v1.AuxInt = int64ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less32U (Const32 [c]) x) (Less32U x (Const32 [d]))) + // cond: uint32(d) >= uint32(c+1) && uint32(c+1) > uint32(c) + // result: (Less32U (Sub32 x (Const32 [c+1])) (Const32 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess32U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLess32U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(uint32(d) >= uint32(c+1) && uint32(c+1) > uint32(c)) { + continue + } + v.reset(OpLess32U) + v0 := b.NewValue0(v.Pos, OpSub32, x.Type) + v1 := b.NewValue0(v.Pos, OpConst32, x.Type) + v1.AuxInt = int32ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less32U (Const32 [c]) x) (Leq32U x (Const32 [d]))) + // cond: uint32(d) >= uint32(c+1) && uint32(c+1) > uint32(c) + // result: (Leq32U (Sub32 x (Const32 [c+1])) (Const32 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess32U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLeq32U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(uint32(d) >= uint32(c+1) && uint32(c+1) > uint32(c)) { + continue + } + v.reset(OpLeq32U) + v0 := b.NewValue0(v.Pos, OpSub32, x.Type) + v1 := b.NewValue0(v.Pos, OpConst32, x.Type) + v1.AuxInt = int32ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less16U (Const16 [c]) x) (Less16U x (Const16 [d]))) + // cond: uint16(d) >= uint16(c+1) && uint16(c+1) > uint16(c) + // result: (Less16U (Sub16 x (Const16 [c+1])) (Const16 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess16U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLess16U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(uint16(d) >= uint16(c+1) && uint16(c+1) > uint16(c)) { + continue + } + v.reset(OpLess16U) + v0 := b.NewValue0(v.Pos, OpSub16, x.Type) + v1 := b.NewValue0(v.Pos, OpConst16, x.Type) + v1.AuxInt = int16ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less16U (Const16 [c]) x) (Leq16U x (Const16 [d]))) + // cond: uint16(d) >= uint16(c+1) && uint16(c+1) > uint16(c) + // result: (Leq16U (Sub16 x (Const16 [c+1])) (Const16 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess16U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLeq16U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(uint16(d) >= uint16(c+1) && uint16(c+1) > uint16(c)) { + continue + } + v.reset(OpLeq16U) + v0 := b.NewValue0(v.Pos, OpSub16, x.Type) + v1 := b.NewValue0(v.Pos, OpConst16, x.Type) + v1.AuxInt = int16ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less8U (Const8 [c]) x) (Less8U x (Const8 [d]))) + // cond: uint8(d) >= uint8(c+1) && uint8(c+1) > uint8(c) + // result: (Less8U (Sub8 x (Const8 [c+1])) (Const8 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess8U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLess8U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(uint8(d) >= uint8(c+1) && uint8(c+1) > uint8(c)) { + continue + } + v.reset(OpLess8U) + v0 := b.NewValue0(v.Pos, OpSub8, x.Type) + v1 := b.NewValue0(v.Pos, OpConst8, x.Type) + v1.AuxInt = int8ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Less8U (Const8 [c]) x) (Leq8U x (Const8 [d]))) + // cond: uint8(d) >= uint8(c+1) && uint8(c+1) > uint8(c) + // result: (Leq8U (Sub8 x (Const8 [c+1])) (Const8 [d-c-1])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess8U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLeq8U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(uint8(d) >= uint8(c+1) && uint8(c+1) > uint8(c)) { + continue + } + v.reset(OpLeq8U) + v0 := b.NewValue0(v.Pos, OpSub8, x.Type) + v1 := b.NewValue0(v.Pos, OpConst8, x.Type) + v1.AuxInt = int8ToAuxInt(c + 1) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d - c - 1) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (AndB (Neq64 x cv:(Const64 [c])) (Neq64 x (Const64 [d]))) + // cond: c|d == c && oneBit(c^d) + // result: (Neq64 (Or64 x (Const64 [c^d])) cv) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + cv := v_0_1 + if cv.Op != OpConst64 { + continue + } + c := auxIntToInt64(cv.AuxInt) + if v_1.Op != OpNeq64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 || v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c|d == c && oneBit(c^d)) { + continue + } + v.reset(OpNeq64) + v0 := b.NewValue0(v.Pos, OpOr64, x.Type) + v1 := b.NewValue0(v.Pos, OpConst64, x.Type) + v1.AuxInt = int64ToAuxInt(c ^ d) + v0.AddArg2(x, v1) + v.AddArg2(v0, cv) + return true + } + } + } + break + } + // match: (AndB (Neq32 x cv:(Const32 [c])) (Neq32 x (Const32 [d]))) + // cond: c|d == c && oneBit(c^d) + // result: (Neq32 (Or32 x (Const32 [c^d])) cv) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq32 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + cv := v_0_1 + if cv.Op != OpConst32 { + continue + } + c := auxIntToInt32(cv.AuxInt) + if v_1.Op != OpNeq32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 || v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(c|d == c && oneBit(c^d)) { + continue + } + v.reset(OpNeq32) + v0 := b.NewValue0(v.Pos, OpOr32, x.Type) + v1 := b.NewValue0(v.Pos, OpConst32, x.Type) + v1.AuxInt = int32ToAuxInt(c ^ d) + v0.AddArg2(x, v1) + v.AddArg2(v0, cv) + return true + } + } + } + break + } + // match: (AndB (Neq16 x cv:(Const16 [c])) (Neq16 x (Const16 [d]))) + // cond: c|d == c && oneBit(c^d) + // result: (Neq16 (Or16 x (Const16 [c^d])) cv) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq16 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + cv := v_0_1 + if cv.Op != OpConst16 { + continue + } + c := auxIntToInt16(cv.AuxInt) + if v_1.Op != OpNeq16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 || v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(c|d == c && oneBit(c^d)) { + continue + } + v.reset(OpNeq16) + v0 := b.NewValue0(v.Pos, OpOr16, x.Type) + v1 := b.NewValue0(v.Pos, OpConst16, x.Type) + v1.AuxInt = int16ToAuxInt(c ^ d) + v0.AddArg2(x, v1) + v.AddArg2(v0, cv) + return true + } + } + } + break + } + // match: (AndB (Neq8 x cv:(Const8 [c])) (Neq8 x (Const8 [d]))) + // cond: c|d == c && oneBit(c^d) + // result: (Neq8 (Or8 x (Const8 [c^d])) cv) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq8 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + cv := v_0_1 + if cv.Op != OpConst8 { + continue + } + c := auxIntToInt8(cv.AuxInt) + if v_1.Op != OpNeq8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 || v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(c|d == c && oneBit(c^d)) { + continue + } + v.reset(OpNeq8) + v0 := b.NewValue0(v.Pos, OpOr8, x.Type) + v1 := b.NewValue0(v.Pos, OpConst8, x.Type) + v1.AuxInt = int8ToAuxInt(c ^ d) + v0.AddArg2(x, v1) + v.AddArg2(v0, cv) + return true + } + } + } + break + } + return false +} +func rewriteValuegeneric_OpArraySelect(v *Value) bool { + v_0 := v.Args[0] + // match: (ArraySelect (ArrayMake1 x)) + // result: x + for { + if v_0.Op != OpArrayMake1 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (ArraySelect [0] (IData x)) + // result: (IData x) + for { + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpIData { + break + } + x := v_0.Args[0] + v.reset(OpIData) + v.AddArg(x) + return true + } + return false +} +func rewriteValuegeneric_OpBitLen16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (BitLen16 (Const16 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(bits.Len16(uint16(c)))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(bits.Len16(uint16(c)))) + return true + } + // match: (BitLen16 (Const16 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(bits.Len16(uint16(c)))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(bits.Len16(uint16(c)))) + return true + } + return false +} +func rewriteValuegeneric_OpBitLen32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (BitLen32 (Const32 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(bits.Len32(uint32(c)))]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(bits.Len32(uint32(c)))) + return true + } + // match: (BitLen32 (Const32 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(bits.Len32(uint32(c)))]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(bits.Len32(uint32(c)))) + return true + } + return false +} +func rewriteValuegeneric_OpBitLen64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (BitLen64 (Const64 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(bits.Len64(uint64(c)))]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(bits.Len64(uint64(c)))) + return true + } + // match: (BitLen64 (Const64 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(bits.Len64(uint64(c)))]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(bits.Len64(uint64(c)))) + return true + } + return false +} +func rewriteValuegeneric_OpBitLen8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (BitLen8 (Const8 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(bits.Len8(uint8(c)))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(bits.Len8(uint8(c)))) + return true + } + // match: (BitLen8 (Const8 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(bits.Len8(uint8(c)))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(bits.Len8(uint8(c)))) + return true + } + return false +} +func rewriteValuegeneric_OpCeil(v *Value) bool { + v_0 := v.Args[0] + // match: (Ceil (Const64F [c])) + // result: (Const64F [math.Ceil(c)]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(math.Ceil(c)) + return true + } + return false +} +func rewriteValuegeneric_OpCom16(v *Value) bool { + v_0 := v.Args[0] + // match: (Com16 (Com16 x)) + // result: x + for { + if v_0.Op != OpCom16 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Com16 (Const16 [c])) + // result: (Const16 [^c]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(^c) + return true + } + // match: (Com16 (Add16 (Const16 [-1]) x)) + // result: (Neg16 x) + for { + if v_0.Op != OpAdd16 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst16 || auxIntToInt16(v_0_0.AuxInt) != -1 { + continue + } + x := v_0_1 + v.reset(OpNeg16) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpCom32(v *Value) bool { + v_0 := v.Args[0] + // match: (Com32 (Com32 x)) + // result: x + for { + if v_0.Op != OpCom32 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Com32 (Const32 [c])) + // result: (Const32 [^c]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(^c) + return true + } + // match: (Com32 (Add32 (Const32 [-1]) x)) + // result: (Neg32 x) + for { + if v_0.Op != OpAdd32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst32 || auxIntToInt32(v_0_0.AuxInt) != -1 { + continue + } + x := v_0_1 + v.reset(OpNeg32) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpCom64(v *Value) bool { + v_0 := v.Args[0] + // match: (Com64 (Com64 x)) + // result: x + for { + if v_0.Op != OpCom64 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Com64 (Const64 [c])) + // result: (Const64 [^c]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(^c) + return true + } + // match: (Com64 (Add64 (Const64 [-1]) x)) + // result: (Neg64 x) + for { + if v_0.Op != OpAdd64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst64 || auxIntToInt64(v_0_0.AuxInt) != -1 { + continue + } + x := v_0_1 + v.reset(OpNeg64) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpCom8(v *Value) bool { + v_0 := v.Args[0] + // match: (Com8 (Com8 x)) + // result: x + for { + if v_0.Op != OpCom8 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Com8 (Const8 [c])) + // result: (Const8 [^c]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(^c) + return true + } + // match: (Com8 (Add8 (Const8 [-1]) x)) + // result: (Neg8 x) + for { + if v_0.Op != OpAdd8 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst8 || auxIntToInt8(v_0_0.AuxInt) != -1 { + continue + } + x := v_0_1 + v.reset(OpNeg8) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpCondSelect(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (CondSelect x _ (ConstBool [true ])) + // result: x + for { + x := v_0 + if v_2.Op != OpConstBool || auxIntToBool(v_2.AuxInt) != true { + break + } + v.copyOf(x) + return true + } + // match: (CondSelect _ y (ConstBool [false])) + // result: y + for { + y := v_1 + if v_2.Op != OpConstBool || auxIntToBool(v_2.AuxInt) != false { + break + } + v.copyOf(y) + return true + } + // match: (CondSelect x x _) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (CondSelect (Add8 x (Const8 [1])) x bool) + // cond: config.arch != "arm64" + // result: (Add8 x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpAdd8 { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst8 || auxIntToInt8(v_0_1.AuxInt) != 1 || x != v_1 { + continue + } + bool := v_2 + if !(config.arch != "arm64") { + continue + } + v.reset(OpAdd8) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, t) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + break + } + // match: (CondSelect (Add64 x (Const64 [1])) x bool) + // cond: config.arch != "arm64" + // result: (Add64 x (ZeroExt8to64 (CvtBoolToUint8 bool))) + for { + if v_0.Op != OpAdd64 { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + continue + } + bool := v_2 + if !(config.arch != "arm64") { + continue + } + v.reset(OpAdd64) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, t) + v1 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v1.AddArg(bool) + v0.AddArg(v1) + v.AddArg2(x, v0) + return true + } + break + } + // match: (CondSelect (Add32 x (Const32 [1])) x bool) + // cond: config.arch != "arm64" + // result: (Add32 x (ZeroExt8to32 (CvtBoolToUint8 bool))) + for { + if v_0.Op != OpAdd32 { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst32 || auxIntToInt32(v_0_1.AuxInt) != 1 || x != v_1 { + continue + } + bool := v_2 + if !(config.arch != "arm64") { + continue + } + v.reset(OpAdd32) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, t) + v1 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v1.AddArg(bool) + v0.AddArg(v1) + v.AddArg2(x, v0) + return true + } + break + } + // match: (CondSelect (Add16 x (Const16 [1])) x bool) + // cond: config.arch != "arm64" + // result: (Add16 x (ZeroExt8to16 (CvtBoolToUint8 bool))) + for { + if v_0.Op != OpAdd16 { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst16 || auxIntToInt16(v_0_1.AuxInt) != 1 || x != v_1 { + continue + } + bool := v_2 + if !(config.arch != "arm64") { + continue + } + v.reset(OpAdd16) + v0 := b.NewValue0(v.Pos, OpZeroExt8to16, t) + v1 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v1.AddArg(bool) + v0.AddArg(v1) + v.AddArg2(x, v0) + return true + } + break + } + // match: (CondSelect (Add8 x (Const8 [-1])) x bool) + // result: (Sub8 x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpAdd8 { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst8 || auxIntToInt8(v_0_1.AuxInt) != -1 || x != v_1 { + continue + } + bool := v_2 + v.reset(OpSub8) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, t) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + break + } + // match: (CondSelect (Add64 x (Const64 [-1])) x bool) + // result: (Sub64 x (ZeroExt8to64 (CvtBoolToUint8 bool))) + for { + if v_0.Op != OpAdd64 { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != -1 || x != v_1 { + continue + } + bool := v_2 + v.reset(OpSub64) + v0 := b.NewValue0(v.Pos, OpZeroExt8to64, t) + v1 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v1.AddArg(bool) + v0.AddArg(v1) + v.AddArg2(x, v0) + return true + } + break + } + // match: (CondSelect (Add32 x (Const32 [-1])) x bool) + // result: (Sub32 x (ZeroExt8to32 (CvtBoolToUint8 bool))) + for { + if v_0.Op != OpAdd32 { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst32 || auxIntToInt32(v_0_1.AuxInt) != -1 || x != v_1 { + continue + } + bool := v_2 + v.reset(OpSub32) + v0 := b.NewValue0(v.Pos, OpZeroExt8to32, t) + v1 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v1.AddArg(bool) + v0.AddArg(v1) + v.AddArg2(x, v0) + return true + } + break + } + // match: (CondSelect (Add16 x (Const16 [-1])) x bool) + // result: (Sub16 x (ZeroExt8to16 (CvtBoolToUint8 bool))) + for { + if v_0.Op != OpAdd16 { + break + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst16 || auxIntToInt16(v_0_1.AuxInt) != -1 || x != v_1 { + continue + } + bool := v_2 + v.reset(OpSub16) + v0 := b.NewValue0(v.Pos, OpZeroExt8to16, t) + v1 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v1.AddArg(bool) + v0.AddArg(v1) + v.AddArg2(x, v0) + return true + } + break + } + // match: (CondSelect (Lsh64x64 x (Const64 [1])) x bool) + // result: (Lsh64x8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpLsh64x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpLsh64x8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Lsh32x64 x (Const64 [1])) x bool) + // result: (Lsh32x8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpLsh32x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpLsh32x8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Lsh16x64 x (Const64 [1])) x bool) + // result: (Lsh16x8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpLsh16x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpLsh16x8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Lsh8x64 x (Const64 [1])) x bool) + // result: (Lsh8x8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpLsh8x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpLsh8x8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Rsh64x64 x (Const64 [1])) x bool) + // result: (Rsh64x8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpRsh64x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpRsh64x8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Rsh32x64 x (Const64 [1])) x bool) + // result: (Rsh32x8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpRsh32x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpRsh32x8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Rsh16x64 x (Const64 [1])) x bool) + // result: (Rsh16x8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpRsh16x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpRsh16x8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Rsh8x64 x (Const64 [1])) x bool) + // result: (Rsh8x8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpRsh8x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpRsh8x8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Rsh64Ux64 x (Const64 [1])) x bool) + // result: (Rsh64Ux8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpRsh64Ux64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpRsh64Ux8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Rsh32Ux64 x (Const64 [1])) x bool) + // result: (Rsh32Ux8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpRsh32Ux64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpRsh32Ux8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Rsh16Ux64 x (Const64 [1])) x bool) + // result: (Rsh16Ux8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpRsh16Ux64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpRsh16Ux8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + // match: (CondSelect (Rsh8Ux64 x (Const64 [1])) x bool) + // result: (Rsh8Ux8 [true] x (CvtBoolToUint8 bool)) + for { + if v_0.Op != OpRsh8Ux64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 1 || x != v_1 { + break + } + bool := v_2 + v.reset(OpRsh8Ux8) + v.AuxInt = boolToAuxInt(true) + v0 := b.NewValue0(v.Pos, OpCvtBoolToUint8, types.Types[types.TUINT8]) + v0.AddArg(bool) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpConstInterface(v *Value) bool { + b := v.Block + typ := &b.Func.Config.Types + // match: (ConstInterface) + // result: (IMake (ConstNil ) (ConstNil )) + for { + v.reset(OpIMake) + v0 := b.NewValue0(v.Pos, OpConstNil, typ.Uintptr) + v1 := b.NewValue0(v.Pos, OpConstNil, typ.BytePtr) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuegeneric_OpConstSlice(v *Value) bool { + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (ConstSlice) + // cond: config.PtrSize == 4 + // result: (SliceMake (ConstNil ) (Const32 [0]) (Const32 [0])) + for { + if !(config.PtrSize == 4) { + break + } + v.reset(OpSliceMake) + v0 := b.NewValue0(v.Pos, OpConstNil, v.Type.Elem().PtrTo()) + v1 := b.NewValue0(v.Pos, OpConst32, typ.Int) + v1.AuxInt = int32ToAuxInt(0) + v.AddArg3(v0, v1, v1) + return true + } + // match: (ConstSlice) + // cond: config.PtrSize == 8 + // result: (SliceMake (ConstNil ) (Const64 [0]) (Const64 [0])) + for { + if !(config.PtrSize == 8) { + break + } + v.reset(OpSliceMake) + v0 := b.NewValue0(v.Pos, OpConstNil, v.Type.Elem().PtrTo()) + v1 := b.NewValue0(v.Pos, OpConst64, typ.Int) + v1.AuxInt = int64ToAuxInt(0) + v.AddArg3(v0, v1, v1) + return true + } + return false +} +func rewriteValuegeneric_OpConstString(v *Value) bool { + b := v.Block + config := b.Func.Config + fe := b.Func.fe + typ := &b.Func.Config.Types + // match: (ConstString {str}) + // cond: config.PtrSize == 4 && str == "" + // result: (StringMake (ConstNil) (Const32 [0])) + for { + str := auxToString(v.Aux) + if !(config.PtrSize == 4 && str == "") { + break + } + v.reset(OpStringMake) + v0 := b.NewValue0(v.Pos, OpConstNil, typ.BytePtr) + v1 := b.NewValue0(v.Pos, OpConst32, typ.Int) + v1.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v1) + return true + } + // match: (ConstString {str}) + // cond: config.PtrSize == 8 && str == "" + // result: (StringMake (ConstNil) (Const64 [0])) + for { + str := auxToString(v.Aux) + if !(config.PtrSize == 8 && str == "") { + break + } + v.reset(OpStringMake) + v0 := b.NewValue0(v.Pos, OpConstNil, typ.BytePtr) + v1 := b.NewValue0(v.Pos, OpConst64, typ.Int) + v1.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v1) + return true + } + // match: (ConstString {str}) + // cond: config.PtrSize == 4 && str != "" + // result: (StringMake (Addr {fe.StringData(str)} (SB)) (Const32 [int32(len(str))])) + for { + str := auxToString(v.Aux) + if !(config.PtrSize == 4 && str != "") { + break + } + v.reset(OpStringMake) + v0 := b.NewValue0(v.Pos, OpAddr, typ.BytePtr) + v0.Aux = symToAux(fe.StringData(str)) + v1 := b.NewValue0(v.Pos, OpSB, typ.Uintptr) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpConst32, typ.Int) + v2.AuxInt = int32ToAuxInt(int32(len(str))) + v.AddArg2(v0, v2) + return true + } + // match: (ConstString {str}) + // cond: config.PtrSize == 8 && str != "" + // result: (StringMake (Addr {fe.StringData(str)} (SB)) (Const64 [int64(len(str))])) + for { + str := auxToString(v.Aux) + if !(config.PtrSize == 8 && str != "") { + break + } + v.reset(OpStringMake) + v0 := b.NewValue0(v.Pos, OpAddr, typ.BytePtr) + v0.Aux = symToAux(fe.StringData(str)) + v1 := b.NewValue0(v.Pos, OpSB, typ.Uintptr) + v0.AddArg(v1) + v2 := b.NewValue0(v.Pos, OpConst64, typ.Int) + v2.AuxInt = int64ToAuxInt(int64(len(str))) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValuegeneric_OpConvert(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Convert (Add64 (Convert ptr mem) off) mem) + // result: (AddPtr ptr off) + for { + if v_0.Op != OpAdd64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConvert { + continue + } + mem := v_0_0.Args[1] + ptr := v_0_0.Args[0] + off := v_0_1 + if mem != v_1 { + continue + } + v.reset(OpAddPtr) + v.AddArg2(ptr, off) + return true + } + break + } + // match: (Convert (Add32 (Convert ptr mem) off) mem) + // result: (AddPtr ptr off) + for { + if v_0.Op != OpAdd32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConvert { + continue + } + mem := v_0_0.Args[1] + ptr := v_0_0.Args[0] + off := v_0_1 + if mem != v_1 { + continue + } + v.reset(OpAddPtr) + v.AddArg2(ptr, off) + return true + } + break + } + // match: (Convert (Convert ptr mem) mem) + // result: ptr + for { + if v_0.Op != OpConvert { + break + } + mem := v_0.Args[1] + ptr := v_0.Args[0] + if mem != v_1 { + break + } + v.copyOf(ptr) + return true + } + // match: (Convert a:(Add64 (Add64 (Convert ptr mem) off1) off2) mem) + // result: (AddPtr ptr (Add64 off1 off2)) + for { + a := v_0 + if a.Op != OpAdd64 { + break + } + _ = a.Args[1] + a_0 := a.Args[0] + a_1 := a.Args[1] + for _i0 := 0; _i0 <= 1; _i0, a_0, a_1 = _i0+1, a_1, a_0 { + if a_0.Op != OpAdd64 { + continue + } + _ = a_0.Args[1] + a_0_0 := a_0.Args[0] + a_0_1 := a_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, a_0_0, a_0_1 = _i1+1, a_0_1, a_0_0 { + if a_0_0.Op != OpConvert { + continue + } + mem := a_0_0.Args[1] + ptr := a_0_0.Args[0] + off1 := a_0_1 + off2 := a_1 + if mem != v_1 { + continue + } + v.reset(OpAddPtr) + v0 := b.NewValue0(v.Pos, OpAdd64, a.Type) + v0.AddArg2(off1, off2) + v.AddArg2(ptr, v0) + return true + } + } + break + } + // match: (Convert a:(Add32 (Add32 (Convert ptr mem) off1) off2) mem) + // result: (AddPtr ptr (Add32 off1 off2)) + for { + a := v_0 + if a.Op != OpAdd32 { + break + } + _ = a.Args[1] + a_0 := a.Args[0] + a_1 := a.Args[1] + for _i0 := 0; _i0 <= 1; _i0, a_0, a_1 = _i0+1, a_1, a_0 { + if a_0.Op != OpAdd32 { + continue + } + _ = a_0.Args[1] + a_0_0 := a_0.Args[0] + a_0_1 := a_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, a_0_0, a_0_1 = _i1+1, a_0_1, a_0_0 { + if a_0_0.Op != OpConvert { + continue + } + mem := a_0_0.Args[1] + ptr := a_0_0.Args[0] + off1 := a_0_1 + off2 := a_1 + if mem != v_1 { + continue + } + v.reset(OpAddPtr) + v0 := b.NewValue0(v.Pos, OpAdd32, a.Type) + v0.AddArg2(off1, off2) + v.AddArg2(ptr, v0) + return true + } + } + break + } + return false +} +func rewriteValuegeneric_OpCtz16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Ctz16 (Const16 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(ntz16(c))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(ntz16(c))) + return true + } + // match: (Ctz16 (Const16 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(ntz16(c))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(ntz16(c))) + return true + } + return false +} +func rewriteValuegeneric_OpCtz32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Ctz32 (Const32 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(ntz32(c))]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(ntz32(c))) + return true + } + // match: (Ctz32 (Const32 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(ntz32(c))]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(ntz32(c))) + return true + } + return false +} +func rewriteValuegeneric_OpCtz64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Ctz64 (Const64 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(ntz64(c))]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(ntz64(c))) + return true + } + // match: (Ctz64 (Const64 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(ntz64(c))]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(ntz64(c))) + return true + } + return false +} +func rewriteValuegeneric_OpCtz8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Ctz8 (Const8 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(ntz8(c))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(ntz8(c))) + return true + } + // match: (Ctz8 (Const8 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(ntz8(c))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(ntz8(c))) + return true + } + return false +} +func rewriteValuegeneric_OpCvt32Fto32(v *Value) bool { + v_0 := v.Args[0] + // match: (Cvt32Fto32 (Const32F [c])) + // cond: c >= -1<<31 && c < 1<<31 + // result: (Const32 [int32(c)]) + for { + if v_0.Op != OpConst32F { + break + } + c := auxIntToFloat32(v_0.AuxInt) + if !(c >= -1<<31 && c < 1<<31) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(c)) + return true + } + return false +} +func rewriteValuegeneric_OpCvt32Fto64(v *Value) bool { + v_0 := v.Args[0] + // match: (Cvt32Fto64 (Const32F [c])) + // cond: c >= -1<<63 && c < 1<<63 + // result: (Const64 [int64(c)]) + for { + if v_0.Op != OpConst32F { + break + } + c := auxIntToFloat32(v_0.AuxInt) + if !(c >= -1<<63 && c < 1<<63) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(c)) + return true + } + return false +} +func rewriteValuegeneric_OpCvt32Fto64F(v *Value) bool { + v_0 := v.Args[0] + // match: (Cvt32Fto64F (Const32F [c])) + // result: (Const64F [float64(c)]) + for { + if v_0.Op != OpConst32F { + break + } + c := auxIntToFloat32(v_0.AuxInt) + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(float64(c)) + return true + } + return false +} +func rewriteValuegeneric_OpCvt32to32F(v *Value) bool { + v_0 := v.Args[0] + // match: (Cvt32to32F (Const32 [c])) + // result: (Const32F [float32(c)]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpConst32F) + v.AuxInt = float32ToAuxInt(float32(c)) + return true + } + return false +} +func rewriteValuegeneric_OpCvt32to64F(v *Value) bool { + v_0 := v.Args[0] + // match: (Cvt32to64F (Const32 [c])) + // result: (Const64F [float64(c)]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(float64(c)) + return true + } + return false +} +func rewriteValuegeneric_OpCvt64Fto32(v *Value) bool { + v_0 := v.Args[0] + // match: (Cvt64Fto32 (Const64F [c])) + // cond: c >= -1<<31 && c < 1<<31 + // result: (Const32 [int32(c)]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + if !(c >= -1<<31 && c < 1<<31) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(c)) + return true + } + return false +} +func rewriteValuegeneric_OpCvt64Fto32F(v *Value) bool { + v_0 := v.Args[0] + // match: (Cvt64Fto32F (Const64F [c])) + // result: (Const32F [float32(c)]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + v.reset(OpConst32F) + v.AuxInt = float32ToAuxInt(float32(c)) + return true + } + // match: (Cvt64Fto32F sqrt0:(Sqrt (Cvt32Fto64F x))) + // cond: sqrt0.Uses==1 + // result: (Sqrt32 x) + for { + sqrt0 := v_0 + if sqrt0.Op != OpSqrt { + break + } + sqrt0_0 := sqrt0.Args[0] + if sqrt0_0.Op != OpCvt32Fto64F { + break + } + x := sqrt0_0.Args[0] + if !(sqrt0.Uses == 1) { + break + } + v.reset(OpSqrt32) + v.AddArg(x) + return true + } + return false +} +func rewriteValuegeneric_OpCvt64Fto64(v *Value) bool { + v_0 := v.Args[0] + // match: (Cvt64Fto64 (Const64F [c])) + // cond: c >= -1<<63 && c < 1<<63 + // result: (Const64 [int64(c)]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + if !(c >= -1<<63 && c < 1<<63) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(c)) + return true + } + return false +} +func rewriteValuegeneric_OpCvt64to32F(v *Value) bool { + v_0 := v.Args[0] + // match: (Cvt64to32F (Const64 [c])) + // result: (Const32F [float32(c)]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpConst32F) + v.AuxInt = float32ToAuxInt(float32(c)) + return true + } + return false +} +func rewriteValuegeneric_OpCvt64to64F(v *Value) bool { + v_0 := v.Args[0] + // match: (Cvt64to64F (Const64 [c])) + // result: (Const64F [float64(c)]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(float64(c)) + return true + } + return false +} +func rewriteValuegeneric_OpCvtBoolToUint8(v *Value) bool { + v_0 := v.Args[0] + // match: (CvtBoolToUint8 (ConstBool [false])) + // result: (Const8 [0]) + for { + if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != false { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (CvtBoolToUint8 (ConstBool [true])) + // result: (Const8 [1]) + for { + if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != true { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(1) + return true + } + return false +} +func rewriteValuegeneric_OpDiv128u(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Div128u (Const64 [0]) lo y) + // result: (MakeTuple (Div64u lo y) (Mod64u lo y)) + for { + t := v.Type + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + lo := v_1 + y := v_2 + v.reset(OpMakeTuple) + v0 := b.NewValue0(v.Pos, OpDiv64u, t.FieldType(0)) + v0.AddArg2(lo, y) + v1 := b.NewValue0(v.Pos, OpMod64u, t.FieldType(1)) + v1.AddArg2(lo, y) + v.AddArg2(v0, v1) + return true + } + return false +} +func rewriteValuegeneric_OpDiv16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16 (Const16 [c]) (Const16 [d])) + // cond: d != 0 + // result: (Const16 [c/d]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + break + } + d := auxIntToInt16(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c / d) + return true + } + // match: (Div16 n (Const16 [c])) + // cond: c < 0 && c != -1<<15 + // result: (Neg16 (Div16 n (Const16 [-c]))) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(c < 0 && c != -1<<15) { + break + } + v.reset(OpNeg16) + v0 := b.NewValue0(v.Pos, OpDiv16, t) + v1 := b.NewValue0(v.Pos, OpConst16, t) + v1.AuxInt = int16ToAuxInt(-c) + v0.AddArg2(n, v1) + v.AddArg(v0) + return true + } + // match: (Div16 x (Const16 [-1<<15])) + // result: (Rsh16Ux64 (And16 x (Neg16 x)) (Const64 [15])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != -1<<15 { + break + } + v.reset(OpRsh16Ux64) + v0 := b.NewValue0(v.Pos, OpAnd16, t) + v1 := b.NewValue0(v.Pos, OpNeg16, t) + v1.AddArg(x) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(15) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValuegeneric_OpDiv16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div16u (Const16 [c]) (Const16 [d])) + // cond: d != 0 + // result: (Const16 [int16(uint16(c)/uint16(d))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + break + } + d := auxIntToInt16(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(int16(uint16(c) / uint16(d))) + return true + } + // match: (Div16u n (Const16 [c])) + // cond: isUnsignedPowerOfTwo(uint16(c)) + // result: (Rsh16Ux64 n (Const64 [log16u(uint16(c))])) + for { + n := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(isUnsignedPowerOfTwo(uint16(c))) { + break + } + v.reset(OpRsh16Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(log16u(uint16(c))) + v.AddArg2(n, v0) + return true + } + return false +} +func rewriteValuegeneric_OpDiv32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32 (Const32 [c]) (Const32 [d])) + // cond: d != 0 + // result: (Const32 [c/d]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + break + } + d := auxIntToInt32(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c / d) + return true + } + // match: (Div32 n (Const32 [c])) + // cond: c < 0 && c != -1<<31 + // result: (Neg32 (Div32 n (Const32 [-c]))) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c < 0 && c != -1<<31) { + break + } + v.reset(OpNeg32) + v0 := b.NewValue0(v.Pos, OpDiv32, t) + v1 := b.NewValue0(v.Pos, OpConst32, t) + v1.AuxInt = int32ToAuxInt(-c) + v0.AddArg2(n, v1) + v.AddArg(v0) + return true + } + // match: (Div32 x (Const32 [-1<<31])) + // result: (Rsh32Ux64 (And32 x (Neg32 x)) (Const64 [31])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != -1<<31 { + break + } + v.reset(OpRsh32Ux64) + v0 := b.NewValue0(v.Pos, OpAnd32, t) + v1 := b.NewValue0(v.Pos, OpNeg32, t) + v1.AddArg(x) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(31) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValuegeneric_OpDiv32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Div32F (Const32F [c]) (Const32F [d])) + // cond: c/d == c/d + // result: (Const32F [c/d]) + for { + if v_0.Op != OpConst32F { + break + } + c := auxIntToFloat32(v_0.AuxInt) + if v_1.Op != OpConst32F { + break + } + d := auxIntToFloat32(v_1.AuxInt) + if !(c/d == c/d) { + break + } + v.reset(OpConst32F) + v.AuxInt = float32ToAuxInt(c / d) + return true + } + // match: (Div32F x (Const32F [c])) + // cond: reciprocalExact32(c) + // result: (Mul32F x (Const32F [1/c])) + for { + x := v_0 + if v_1.Op != OpConst32F { + break + } + t := v_1.Type + c := auxIntToFloat32(v_1.AuxInt) + if !(reciprocalExact32(c)) { + break + } + v.reset(OpMul32F) + v0 := b.NewValue0(v.Pos, OpConst32F, t) + v0.AuxInt = float32ToAuxInt(1 / c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpDiv32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div32u (Const32 [c]) (Const32 [d])) + // cond: d != 0 + // result: (Const32 [int32(uint32(c)/uint32(d))]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + break + } + d := auxIntToInt32(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(uint32(c) / uint32(d))) + return true + } + // match: (Div32u n (Const32 [c])) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (Rsh32Ux64 n (Const64 [log32u(uint32(c))])) + for { + n := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(isUnsignedPowerOfTwo(uint32(c))) { + break + } + v.reset(OpRsh32Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(log32u(uint32(c))) + v.AddArg2(n, v0) + return true + } + return false +} +func rewriteValuegeneric_OpDiv64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div64 (Const64 [c]) (Const64 [d])) + // cond: d != 0 + // result: (Const64 [c/d]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c / d) + return true + } + // match: (Div64 n (Const64 [c])) + // cond: c < 0 && c != -1<<63 + // result: (Neg64 (Div64 n (Const64 [-c]))) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c < 0 && c != -1<<63) { + break + } + v.reset(OpNeg64) + v0 := b.NewValue0(v.Pos, OpDiv64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(-c) + v0.AddArg2(n, v1) + v.AddArg(v0) + return true + } + // match: (Div64 x (Const64 [-1<<63])) + // cond: isNonNegative(x) + // result: (Const64 [0]) + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != -1<<63 || !(isNonNegative(x)) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Div64 x (Const64 [-1<<63])) + // result: (Rsh64Ux64 (And64 x (Neg64 x)) (Const64 [63])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != -1<<63 { + break + } + v.reset(OpRsh64Ux64) + v0 := b.NewValue0(v.Pos, OpAnd64, t) + v1 := b.NewValue0(v.Pos, OpNeg64, t) + v1.AddArg(x) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(63) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValuegeneric_OpDiv64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Div64F (Const64F [c]) (Const64F [d])) + // cond: c/d == c/d + // result: (Const64F [c/d]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + if v_1.Op != OpConst64F { + break + } + d := auxIntToFloat64(v_1.AuxInt) + if !(c/d == c/d) { + break + } + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(c / d) + return true + } + // match: (Div64F x (Const64F [c])) + // cond: reciprocalExact64(c) + // result: (Mul64F x (Const64F [1/c])) + for { + x := v_0 + if v_1.Op != OpConst64F { + break + } + t := v_1.Type + c := auxIntToFloat64(v_1.AuxInt) + if !(reciprocalExact64(c)) { + break + } + v.reset(OpMul64F) + v0 := b.NewValue0(v.Pos, OpConst64F, t) + v0.AuxInt = float64ToAuxInt(1 / c) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpDiv64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div64u (Const64 [c]) (Const64 [d])) + // cond: d != 0 + // result: (Const64 [int64(uint64(c)/uint64(d))]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(uint64(c) / uint64(d))) + return true + } + // match: (Div64u n (Const64 [c])) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (Rsh64Ux64 n (Const64 [log64u(uint64(c))])) + for { + n := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isUnsignedPowerOfTwo(uint64(c))) { + break + } + v.reset(OpRsh64Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(log64u(uint64(c))) + v.AddArg2(n, v0) + return true + } + return false +} +func rewriteValuegeneric_OpDiv8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8 (Const8 [c]) (Const8 [d])) + // cond: d != 0 + // result: (Const8 [c/d]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + break + } + d := auxIntToInt8(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c / d) + return true + } + // match: (Div8 n (Const8 [c])) + // cond: c < 0 && c != -1<<7 + // result: (Neg8 (Div8 n (Const8 [-c]))) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(c < 0 && c != -1<<7) { + break + } + v.reset(OpNeg8) + v0 := b.NewValue0(v.Pos, OpDiv8, t) + v1 := b.NewValue0(v.Pos, OpConst8, t) + v1.AuxInt = int8ToAuxInt(-c) + v0.AddArg2(n, v1) + v.AddArg(v0) + return true + } + // match: (Div8 x (Const8 [-1<<7 ])) + // result: (Rsh8Ux64 (And8 x (Neg8 x)) (Const64 [7 ])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != -1<<7 { + break + } + v.reset(OpRsh8Ux64) + v0 := b.NewValue0(v.Pos, OpAnd8, t) + v1 := b.NewValue0(v.Pos, OpNeg8, t) + v1.AddArg(x) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v2.AuxInt = int64ToAuxInt(7) + v.AddArg2(v0, v2) + return true + } + return false +} +func rewriteValuegeneric_OpDiv8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Div8u (Const8 [c]) (Const8 [d])) + // cond: d != 0 + // result: (Const8 [int8(uint8(c)/uint8(d))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + break + } + d := auxIntToInt8(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(int8(uint8(c) / uint8(d))) + return true + } + // match: (Div8u n (Const8 [c])) + // cond: isUnsignedPowerOfTwo(uint8(c)) + // result: (Rsh8Ux64 n (Const64 [log8u(uint8(c))])) + for { + n := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(isUnsignedPowerOfTwo(uint8(c))) { + break + } + v.reset(OpRsh8Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(log8u(uint8(c))) + v.AddArg2(n, v0) + return true + } + return false +} +func rewriteValuegeneric_OpEq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Eq16 x x) + // result: (ConstBool [true]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Eq16 (Const16 [c]) (Add16 (Const16 [d]) x)) + // result: (Eq16 (Const16 [c-d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpAdd16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + continue + } + d := auxIntToInt16(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Eq16 (Const16 [c]) (Const16 [d])) + // result: (ConstBool [c == d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c == d) + return true + } + break + } + // match: (Eq16 (Mod16u x (Const16 [c])) (Const16 [0])) + // cond: x.Op != OpConst16 && udivisibleOK16(c) && !hasSmallRotate(config) + // result: (Eq32 (Mod32u (ZeroExt16to32 x) (Const32 [int32(uint16(c))])) (Const32 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMod16u { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_1.AuxInt) + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 || !(x.Op != OpConst16 && udivisibleOK16(c) && !hasSmallRotate(config)) { + continue + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpMod32u, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v2.AuxInt = int32ToAuxInt(int32(uint16(c))) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } + break + } + // match: (Eq16 (Mod16 x (Const16 [c])) (Const16 [0])) + // cond: x.Op != OpConst16 && sdivisibleOK16(c) && !hasSmallRotate(config) + // result: (Eq32 (Mod32 (SignExt16to32 x) (Const32 [int32(c)])) (Const32 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMod16 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_1.AuxInt) + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 || !(x.Op != OpConst16 && sdivisibleOK16(c) && !hasSmallRotate(config)) { + continue + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpMod32, typ.Int32) + v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v2.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v3.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } + break + } + // match: (Eq16 s:(Sub16 x y) (Const16 [0])) + // cond: s.Uses == 1 + // result: (Eq16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + s := v_0 + if s.Op != OpSub16 { + continue + } + y := s.Args[1] + x := s.Args[0] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 || !(s.Uses == 1) { + continue + } + v.reset(OpEq16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Eq16 (And16 x (Const16 [y])) (Const16 [y])) + // cond: oneBit(y) + // result: (Neq16 (And16 x (Const16 [y])) (Const16 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd16 { + continue + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst16 || v_0_1.Type != t { + continue + } + y := auxIntToInt16(v_0_1.AuxInt) + if v_1.Op != OpConst16 || v_1.Type != t || auxIntToInt16(v_1.AuxInt) != y || !(oneBit(y)) { + continue + } + v.reset(OpNeq16) + v0 := b.NewValue0(v.Pos, OpAnd16, t) + v1 := b.NewValue0(v.Pos, OpConst16, t) + v1.AuxInt = int16ToAuxInt(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq16 (ZeroExt8to16 (CvtBoolToUint8 x)) (Const16 [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to16 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Eq16 (ZeroExt8to16 (CvtBoolToUint8 x)) (Const16 [0])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to16 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + // match: (Eq16 (SignExt8to16 (CvtBoolToUint8 x)) (Const16 [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to16 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Eq16 (SignExt8to16 (CvtBoolToUint8 x)) (Const16 [0])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to16 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpEq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq32 x x) + // result: (ConstBool [true]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Eq32 (Const32 [c]) (Add32 (Const32 [d]) x)) + // result: (Eq32 (Const32 [c-d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpAdd32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + continue + } + d := auxIntToInt32(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Eq32 (Const32 [c]) (Const32 [d])) + // result: (ConstBool [c == d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c == d) + return true + } + break + } + // match: (Eq32 s:(Sub32 x y) (Const32 [0])) + // cond: s.Uses == 1 + // result: (Eq32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + s := v_0 + if s.Op != OpSub32 { + continue + } + y := s.Args[1] + x := s.Args[0] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 0 || !(s.Uses == 1) { + continue + } + v.reset(OpEq32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Eq32 (And32 x (Const32 [y])) (Const32 [y])) + // cond: oneBit(y) + // result: (Neq32 (And32 x (Const32 [y])) (Const32 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd32 { + continue + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst32 || v_0_1.Type != t { + continue + } + y := auxIntToInt32(v_0_1.AuxInt) + if v_1.Op != OpConst32 || v_1.Type != t || auxIntToInt32(v_1.AuxInt) != y || !(oneBit(y)) { + continue + } + v.reset(OpNeq32) + v0 := b.NewValue0(v.Pos, OpAnd32, t) + v1 := b.NewValue0(v.Pos, OpConst32, t) + v1.AuxInt = int32ToAuxInt(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq32 (ZeroExt8to32 (CvtBoolToUint8 x)) (Const32 [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to32 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Eq32 (ZeroExt8to32 (CvtBoolToUint8 x)) (Const32 [0])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to32 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 0 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + // match: (Eq32 (SignExt8to32 (CvtBoolToUint8 x)) (Const32 [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to32 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Eq32 (SignExt8to32 (CvtBoolToUint8 x)) (Const32 [0])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to32 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 0 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpEq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Eq32F (Const32F [c]) (Const32F [d])) + // result: (ConstBool [c == d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32F { + continue + } + c := auxIntToFloat32(v_0.AuxInt) + if v_1.Op != OpConst32F { + continue + } + d := auxIntToFloat32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c == d) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpEq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Eq64 x x) + // result: (ConstBool [true]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Eq64 (Const64 [c]) (Add64 (Const64 [d]) x)) + // result: (Eq64 (Const64 [c-d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpAdd64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + continue + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Eq64 (Const64 [c]) (Const64 [d])) + // result: (ConstBool [c == d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c == d) + return true + } + break + } + // match: (Eq64 s:(Sub64 x y) (Const64 [0])) + // cond: s.Uses == 1 + // result: (Eq64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + s := v_0 + if s.Op != OpSub64 { + continue + } + y := s.Args[1] + x := s.Args[0] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 || !(s.Uses == 1) { + continue + } + v.reset(OpEq64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Eq64 (And64 x (Const64 [y])) (Const64 [y])) + // cond: oneBit(y) + // result: (Neq64 (And64 x (Const64 [y])) (Const64 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd64 { + continue + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst64 || v_0_1.Type != t { + continue + } + y := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 || v_1.Type != t || auxIntToInt64(v_1.AuxInt) != y || !(oneBit(y)) { + continue + } + v.reset(OpNeq64) + v0 := b.NewValue0(v.Pos, OpAnd64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq64 (ZeroExt8to64 (CvtBoolToUint8 x)) (Const64 [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to64 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Eq64 (ZeroExt8to64 (CvtBoolToUint8 x)) (Const64 [0])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to64 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + // match: (Eq64 (SignExt8to64 (CvtBoolToUint8 x)) (Const64 [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to64 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Eq64 (SignExt8to64 (CvtBoolToUint8 x)) (Const64 [0])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to64 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpEq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Eq64F (Const64F [c]) (Const64F [d])) + // result: (ConstBool [c == d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64F { + continue + } + c := auxIntToFloat64(v_0.AuxInt) + if v_1.Op != OpConst64F { + continue + } + d := auxIntToFloat64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c == d) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpEq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Eq8 x x) + // result: (ConstBool [true]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Eq8 (Const8 [c]) (Add8 (Const8 [d]) x)) + // result: (Eq8 (Const8 [c-d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpAdd8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + continue + } + d := auxIntToInt8(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Eq8 (Const8 [c]) (Const8 [d])) + // result: (ConstBool [c == d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c == d) + return true + } + break + } + // match: (Eq8 (Mod8u x (Const8 [c])) (Const8 [0])) + // cond: x.Op != OpConst8 && udivisibleOK8(c) && !hasSmallRotate(config) + // result: (Eq32 (Mod32u (ZeroExt8to32 x) (Const32 [int32(uint8(c))])) (Const32 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMod8u { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_1.AuxInt) + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 || !(x.Op != OpConst8 && udivisibleOK8(c) && !hasSmallRotate(config)) { + continue + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpMod32u, typ.UInt32) + v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v2.AuxInt = int32ToAuxInt(int32(uint8(c))) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v3.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } + break + } + // match: (Eq8 (Mod8 x (Const8 [c])) (Const8 [0])) + // cond: x.Op != OpConst8 && sdivisibleOK8(c) && !hasSmallRotate(config) + // result: (Eq32 (Mod32 (SignExt8to32 x) (Const32 [int32(c)])) (Const32 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMod8 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_1.AuxInt) + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 || !(x.Op != OpConst8 && sdivisibleOK8(c) && !hasSmallRotate(config)) { + continue + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpMod32, typ.Int32) + v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) + v1.AddArg(x) + v2 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v2.AuxInt = int32ToAuxInt(int32(c)) + v0.AddArg2(v1, v2) + v3 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v3.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v3) + return true + } + break + } + // match: (Eq8 s:(Sub8 x y) (Const8 [0])) + // cond: s.Uses == 1 + // result: (Eq8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + s := v_0 + if s.Op != OpSub8 { + continue + } + y := s.Args[1] + x := s.Args[0] + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 || !(s.Uses == 1) { + continue + } + v.reset(OpEq8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Eq8 (And8 x (Const8 [y])) (Const8 [y])) + // cond: oneBit(y) + // result: (Neq8 (And8 x (Const8 [y])) (Const8 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd8 { + continue + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst8 || v_0_1.Type != t { + continue + } + y := auxIntToInt8(v_0_1.AuxInt) + if v_1.Op != OpConst8 || v_1.Type != t || auxIntToInt8(v_1.AuxInt) != y || !(oneBit(y)) { + continue + } + v.reset(OpNeq8) + v0 := b.NewValue0(v.Pos, OpAnd8, t) + v1 := b.NewValue0(v.Pos, OpConst8, t) + v1.AuxInt = int8ToAuxInt(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Eq8 (CvtBoolToUint8 x) (Const8 [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Eq8 (CvtBoolToUint8 x) (Const8 [0])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpEqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (EqB (ConstBool [c]) (ConstBool [d])) + // result: (ConstBool [c == d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConstBool { + continue + } + c := auxIntToBool(v_0.AuxInt) + if v_1.Op != OpConstBool { + continue + } + d := auxIntToBool(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c == d) + return true + } + break + } + // match: (EqB (ConstBool [false]) x) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != false { + continue + } + x := v_1 + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + // match: (EqB (ConstBool [true]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != true { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpEqInter(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqInter x y) + // result: (EqPtr (ITab x) (ITab y)) + for { + x := v_0 + y := v_1 + v.reset(OpEqPtr) + v0 := b.NewValue0(v.Pos, OpITab, typ.Uintptr) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpITab, typ.Uintptr) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuegeneric_OpEqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqPtr x x) + // result: (ConstBool [true]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (EqPtr (Addr {x} _) (Addr {y} _)) + // result: (ConstBool [x == y]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAddr { + continue + } + x := auxToSym(v_0.Aux) + if v_1.Op != OpAddr { + continue + } + y := auxToSym(v_1.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x == y) + return true + } + break + } + // match: (EqPtr (Addr {x} _) (OffPtr [o] (Addr {y} _))) + // result: (ConstBool [x == y && o == 0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAddr { + continue + } + x := auxToSym(v_0.Aux) + if v_1.Op != OpOffPtr { + continue + } + o := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAddr { + continue + } + y := auxToSym(v_1_0.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x == y && o == 0) + return true + } + break + } + // match: (EqPtr (OffPtr [o1] (Addr {x} _)) (OffPtr [o2] (Addr {y} _))) + // result: (ConstBool [x == y && o1 == o2]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + o1 := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAddr { + continue + } + x := auxToSym(v_0_0.Aux) + if v_1.Op != OpOffPtr { + continue + } + o2 := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAddr { + continue + } + y := auxToSym(v_1_0.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x == y && o1 == o2) + return true + } + break + } + // match: (EqPtr (LocalAddr {x} _ _) (LocalAddr {y} _ _)) + // result: (ConstBool [x == y]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLocalAddr { + continue + } + x := auxToSym(v_0.Aux) + if v_1.Op != OpLocalAddr { + continue + } + y := auxToSym(v_1.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x == y) + return true + } + break + } + // match: (EqPtr (LocalAddr {x} _ _) (OffPtr [o] (LocalAddr {y} _ _))) + // result: (ConstBool [x == y && o == 0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLocalAddr { + continue + } + x := auxToSym(v_0.Aux) + if v_1.Op != OpOffPtr { + continue + } + o := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLocalAddr { + continue + } + y := auxToSym(v_1_0.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x == y && o == 0) + return true + } + break + } + // match: (EqPtr (OffPtr [o1] (LocalAddr {x} _ _)) (OffPtr [o2] (LocalAddr {y} _ _))) + // result: (ConstBool [x == y && o1 == o2]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + o1 := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLocalAddr { + continue + } + x := auxToSym(v_0_0.Aux) + if v_1.Op != OpOffPtr { + continue + } + o2 := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLocalAddr { + continue + } + y := auxToSym(v_1_0.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x == y && o1 == o2) + return true + } + break + } + // match: (EqPtr (OffPtr [o1] p1) p2) + // cond: isSamePtr(p1, p2) + // result: (ConstBool [o1 == 0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + o1 := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + p2 := v_1 + if !(isSamePtr(p1, p2)) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(o1 == 0) + return true + } + break + } + // match: (EqPtr (OffPtr [o1] p1) (OffPtr [o2] p2)) + // cond: isSamePtr(p1, p2) + // result: (ConstBool [o1 == o2]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + o1 := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + if v_1.Op != OpOffPtr { + continue + } + o2 := auxIntToInt64(v_1.AuxInt) + p2 := v_1.Args[0] + if !(isSamePtr(p1, p2)) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(o1 == o2) + return true + } + break + } + // match: (EqPtr (Const32 [c]) (Const32 [d])) + // result: (ConstBool [c == d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c == d) + return true + } + break + } + // match: (EqPtr (Const64 [c]) (Const64 [d])) + // result: (ConstBool [c == d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c == d) + return true + } + break + } + // match: (EqPtr (Convert (Addr {x} _) _) (Addr {y} _)) + // result: (ConstBool [x==y]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConvert { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAddr { + continue + } + x := auxToSym(v_0_0.Aux) + if v_1.Op != OpAddr { + continue + } + y := auxToSym(v_1.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x == y) + return true + } + break + } + // match: (EqPtr (LocalAddr _ _) (Addr _)) + // result: (ConstBool [false]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLocalAddr || v_1.Op != OpAddr { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + break + } + // match: (EqPtr (OffPtr (LocalAddr _ _)) (Addr _)) + // result: (ConstBool [false]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLocalAddr || v_1.Op != OpAddr { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + break + } + // match: (EqPtr (LocalAddr _ _) (OffPtr (Addr _))) + // result: (ConstBool [false]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLocalAddr || v_1.Op != OpOffPtr { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAddr { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + break + } + // match: (EqPtr (OffPtr (LocalAddr _ _)) (OffPtr (Addr _))) + // result: (ConstBool [false]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLocalAddr || v_1.Op != OpOffPtr { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAddr { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + break + } + // match: (EqPtr (AddPtr p1 o1) p2) + // cond: isSamePtr(p1, p2) + // result: (Not (IsNonNil o1)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAddPtr { + continue + } + o1 := v_0.Args[1] + p1 := v_0.Args[0] + p2 := v_1 + if !(isSamePtr(p1, p2)) { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpIsNonNil, typ.Bool) + v0.AddArg(o1) + v.AddArg(v0) + return true + } + break + } + // match: (EqPtr (Const32 [0]) p) + // result: (Not (IsNonNil p)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + continue + } + p := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpIsNonNil, typ.Bool) + v0.AddArg(p) + v.AddArg(v0) + return true + } + break + } + // match: (EqPtr (Const64 [0]) p) + // result: (Not (IsNonNil p)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + continue + } + p := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpIsNonNil, typ.Bool) + v0.AddArg(p) + v.AddArg(v0) + return true + } + break + } + // match: (EqPtr (ConstNil) p) + // result: (Not (IsNonNil p)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConstNil { + continue + } + p := v_1 + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpIsNonNil, typ.Bool) + v0.AddArg(p) + v.AddArg(v0) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpEqSlice(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (EqSlice x y) + // result: (EqPtr (SlicePtr x) (SlicePtr y)) + for { + x := v_0 + y := v_1 + v.reset(OpEqPtr) + v0 := b.NewValue0(v.Pos, OpSlicePtr, typ.BytePtr) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSlicePtr, typ.BytePtr) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuegeneric_OpFloor(v *Value) bool { + v_0 := v.Args[0] + // match: (Floor (Const64F [c])) + // result: (Const64F [math.Floor(c)]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(math.Floor(c)) + return true + } + return false +} +func rewriteValuegeneric_OpIMake(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (IMake _typ (StructMake ___)) + // result: imakeOfStructMake(v) + for { + if v_1.Op != OpStructMake { + break + } + v.copyOf(imakeOfStructMake(v)) + return true + } + // match: (IMake _typ (ArrayMake1 val)) + // result: (IMake _typ val) + for { + _typ := v_0 + if v_1.Op != OpArrayMake1 { + break + } + val := v_1.Args[0] + v.reset(OpIMake) + v.AddArg2(_typ, val) + return true + } + return false +} +func rewriteValuegeneric_OpInterLECall(v *Value) bool { + // match: (InterLECall [argsize] {auxCall} (Addr {fn} (SB)) ___) + // result: devirtLECall(v, fn.(*obj.LSym)) + for { + if len(v.Args) < 1 { + break + } + v_0 := v.Args[0] + if v_0.Op != OpAddr { + break + } + fn := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB { + break + } + v.copyOf(devirtLECall(v, fn.(*obj.LSym))) + return true + } + return false +} +func rewriteValuegeneric_OpIsInBounds(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (IsInBounds (ZeroExt8to32 _) (Const32 [c])) + // cond: (1 << 8) <= c + // result: (ConstBool [true]) + for { + if v_0.Op != OpZeroExt8to32 || v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !((1 << 8) <= c) { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (IsInBounds (ZeroExt8to64 _) (Const64 [c])) + // cond: (1 << 8) <= c + // result: (ConstBool [true]) + for { + if v_0.Op != OpZeroExt8to64 || v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !((1 << 8) <= c) { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (IsInBounds (ZeroExt16to32 _) (Const32 [c])) + // cond: (1 << 16) <= c + // result: (ConstBool [true]) + for { + if v_0.Op != OpZeroExt16to32 || v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !((1 << 16) <= c) { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (IsInBounds (ZeroExt16to64 _) (Const64 [c])) + // cond: (1 << 16) <= c + // result: (ConstBool [true]) + for { + if v_0.Op != OpZeroExt16to64 || v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !((1 << 16) <= c) { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (IsInBounds x x) + // result: (ConstBool [false]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (IsInBounds (And8 (Const8 [c]) _) (Const8 [d])) + // cond: 0 <= c && c < d + // result: (ConstBool [true]) + for { + if v_0.Op != OpAnd8 { + break + } + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1.AuxInt) + if !(0 <= c && c < d) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (IsInBounds (ZeroExt8to16 (And8 (Const8 [c]) _)) (Const16 [d])) + // cond: 0 <= c && int16(c) < d + // result: (ConstBool [true]) + for { + if v_0.Op != OpZeroExt8to16 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAnd8 { + break + } + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0_0.AuxInt) + if v_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1.AuxInt) + if !(0 <= c && int16(c) < d) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (IsInBounds (ZeroExt8to32 (And8 (Const8 [c]) _)) (Const32 [d])) + // cond: 0 <= c && int32(c) < d + // result: (ConstBool [true]) + for { + if v_0.Op != OpZeroExt8to32 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAnd8 { + break + } + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + if !(0 <= c && int32(c) < d) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (IsInBounds (ZeroExt8to64 (And8 (Const8 [c]) _)) (Const64 [d])) + // cond: 0 <= c && int64(c) < d + // result: (ConstBool [true]) + for { + if v_0.Op != OpZeroExt8to64 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAnd8 { + break + } + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + if !(0 <= c && int64(c) < d) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (IsInBounds (And16 (Const16 [c]) _) (Const16 [d])) + // cond: 0 <= c && c < d + // result: (ConstBool [true]) + for { + if v_0.Op != OpAnd16 { + break + } + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1.AuxInt) + if !(0 <= c && c < d) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (IsInBounds (ZeroExt16to32 (And16 (Const16 [c]) _)) (Const32 [d])) + // cond: 0 <= c && int32(c) < d + // result: (ConstBool [true]) + for { + if v_0.Op != OpZeroExt16to32 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAnd16 { + break + } + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + if !(0 <= c && int32(c) < d) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (IsInBounds (ZeroExt16to64 (And16 (Const16 [c]) _)) (Const64 [d])) + // cond: 0 <= c && int64(c) < d + // result: (ConstBool [true]) + for { + if v_0.Op != OpZeroExt16to64 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAnd16 { + break + } + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + if !(0 <= c && int64(c) < d) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (IsInBounds (And32 (Const32 [c]) _) (Const32 [d])) + // cond: 0 <= c && c < d + // result: (ConstBool [true]) + for { + if v_0.Op != OpAnd32 { + break + } + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + if !(0 <= c && c < d) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (IsInBounds (ZeroExt32to64 (And32 (Const32 [c]) _)) (Const64 [d])) + // cond: 0 <= c && int64(c) < d + // result: (ConstBool [true]) + for { + if v_0.Op != OpZeroExt32to64 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAnd32 { + break + } + v_0_0_0 := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { + if v_0_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + if !(0 <= c && int64(c) < d) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (IsInBounds (And64 (Const64 [c]) _) (Const64 [d])) + // cond: 0 <= c && c < d + // result: (ConstBool [true]) + for { + if v_0.Op != OpAnd64 { + break + } + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + if !(0 <= c && c < d) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (IsInBounds (Const32 [c]) (Const32 [d])) + // result: (ConstBool [0 <= c && c < d]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + break + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(0 <= c && c < d) + return true + } + // match: (IsInBounds (Const64 [c]) (Const64 [d])) + // result: (ConstBool [0 <= c && c < d]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(0 <= c && c < d) + return true + } + // match: (IsInBounds (Mod32u _ y) y) + // result: (ConstBool [true]) + for { + if v_0.Op != OpMod32u { + break + } + y := v_0.Args[1] + if y != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (IsInBounds (Mod64u _ y) y) + // result: (ConstBool [true]) + for { + if v_0.Op != OpMod64u { + break + } + y := v_0.Args[1] + if y != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (IsInBounds (ZeroExt8to64 (Rsh8Ux64 _ (Const64 [c]))) (Const64 [d])) + // cond: 0 < c && c < 8 && 1<= 0 + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 || v_1.Op != OpAnd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_1.AuxInt) + if !(c >= 0) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (Leq16 (Const16 [0]) (Rsh16Ux64 _ (Const64 [c]))) + // cond: c > 0 + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 || v_1.Op != OpRsh16Ux64 { + break + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c > 0) { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq16 x (Const16 [-1])) + // result: (Less16 x (Const16 [0])) + for { + x := v_0 + if v_1.Op != OpConst16 { + break + } + t := v_1.Type + if auxIntToInt16(v_1.AuxInt) != -1 { + break + } + v.reset(OpLess16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Leq16 (Const16 [1]) x) + // result: (Less16 (Const16 [0]) x) + for { + if v_0.Op != OpConst16 { + break + } + t := v_0.Type + if auxIntToInt16(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpLess16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq16 (Const16 [math.MinInt16]) _) + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != math.MinInt16 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq16 _ (Const16 [math.MaxInt16])) + // result: (ConstBool [true]) + for { + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != math.MaxInt16 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq16 x c:(Const16 [math.MinInt16])) + // result: (Eq16 x c) + for { + x := v_0 + c := v_1 + if c.Op != OpConst16 || auxIntToInt16(c.AuxInt) != math.MinInt16 { + break + } + v.reset(OpEq16) + v.AddArg2(x, c) + return true + } + // match: (Leq16 c:(Const16 [math.MaxInt16]) x) + // result: (Eq16 x c) + for { + c := v_0 + if c.Op != OpConst16 || auxIntToInt16(c.AuxInt) != math.MaxInt16 { + break + } + x := v_1 + v.reset(OpEq16) + v.AddArg2(x, c) + return true + } + return false +} +func rewriteValuegeneric_OpLeq16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq16U (Const16 [c]) (Const16 [d])) + // result: (ConstBool [uint16(c) <= uint16(d)]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + break + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(uint16(c) <= uint16(d)) + return true + } + // match: (Leq16U (Const16 [1]) x) + // result: (Neq16 (Const16 [0]) x) + for { + if v_0.Op != OpConst16 { + break + } + t := v_0.Type + if auxIntToInt16(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpNeq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq16U (Const16 [0]) _) + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq16U _ (Const16 [-1])) + // result: (ConstBool [true]) + for { + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != -1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq16U x c:(Const16 [0])) + // result: (Eq16 x c) + for { + x := v_0 + c := v_1 + if c.Op != OpConst16 || auxIntToInt16(c.AuxInt) != 0 { + break + } + v.reset(OpEq16) + v.AddArg2(x, c) + return true + } + // match: (Leq16U c:(Const16 [-1]) x) + // result: (Eq16 x c) + for { + c := v_0 + if c.Op != OpConst16 || auxIntToInt16(c.AuxInt) != -1 { + break + } + x := v_1 + v.reset(OpEq16) + v.AddArg2(x, c) + return true + } + return false +} +func rewriteValuegeneric_OpLeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32 (Const32 [c]) (Const32 [d])) + // result: (ConstBool [c <= d]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + break + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c <= d) + return true + } + // match: (Leq32 (Const32 [0]) (And32 _ (Const32 [c]))) + // cond: c >= 0 + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 || v_1.Op != OpAnd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_1.AuxInt) + if !(c >= 0) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (Leq32 (Const32 [0]) (Rsh32Ux64 _ (Const64 [c]))) + // cond: c > 0 + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 || v_1.Op != OpRsh32Ux64 { + break + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c > 0) { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq32 x (Const32 [-1])) + // result: (Less32 x (Const32 [0])) + for { + x := v_0 + if v_1.Op != OpConst32 { + break + } + t := v_1.Type + if auxIntToInt32(v_1.AuxInt) != -1 { + break + } + v.reset(OpLess32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Leq32 (Const32 [1]) x) + // result: (Less32 (Const32 [0]) x) + for { + if v_0.Op != OpConst32 { + break + } + t := v_0.Type + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpLess32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq32 (Const32 [math.MinInt32]) _) + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != math.MinInt32 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq32 _ (Const32 [math.MaxInt32])) + // result: (ConstBool [true]) + for { + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != math.MaxInt32 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq32 x c:(Const32 [math.MinInt32])) + // result: (Eq32 x c) + for { + x := v_0 + c := v_1 + if c.Op != OpConst32 || auxIntToInt32(c.AuxInt) != math.MinInt32 { + break + } + v.reset(OpEq32) + v.AddArg2(x, c) + return true + } + // match: (Leq32 c:(Const32 [math.MaxInt32]) x) + // result: (Eq32 x c) + for { + c := v_0 + if c.Op != OpConst32 || auxIntToInt32(c.AuxInt) != math.MaxInt32 { + break + } + x := v_1 + v.reset(OpEq32) + v.AddArg2(x, c) + return true + } + return false +} +func rewriteValuegeneric_OpLeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Leq32F (Const32F [c]) (Const32F [d])) + // result: (ConstBool [c <= d]) + for { + if v_0.Op != OpConst32F { + break + } + c := auxIntToFloat32(v_0.AuxInt) + if v_1.Op != OpConst32F { + break + } + d := auxIntToFloat32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c <= d) + return true + } + return false +} +func rewriteValuegeneric_OpLeq32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq32U (Const32 [c]) (Const32 [d])) + // result: (ConstBool [uint32(c) <= uint32(d)]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + break + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(uint32(c) <= uint32(d)) + return true + } + // match: (Leq32U (Const32 [1]) x) + // result: (Neq32 (Const32 [0]) x) + for { + if v_0.Op != OpConst32 { + break + } + t := v_0.Type + if auxIntToInt32(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpNeq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq32U (Const32 [0]) _) + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq32U _ (Const32 [-1])) + // result: (ConstBool [true]) + for { + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != -1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq32U x c:(Const32 [0])) + // result: (Eq32 x c) + for { + x := v_0 + c := v_1 + if c.Op != OpConst32 || auxIntToInt32(c.AuxInt) != 0 { + break + } + v.reset(OpEq32) + v.AddArg2(x, c) + return true + } + // match: (Leq32U c:(Const32 [-1]) x) + // result: (Eq32 x c) + for { + c := v_0 + if c.Op != OpConst32 || auxIntToInt32(c.AuxInt) != -1 { + break + } + x := v_1 + v.reset(OpEq32) + v.AddArg2(x, c) + return true + } + return false +} +func rewriteValuegeneric_OpLeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64 (Const64 [c]) (Const64 [d])) + // result: (ConstBool [c <= d]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c <= d) + return true + } + // match: (Leq64 (Const64 [0]) (And64 _ (Const64 [c]))) + // cond: c >= 0 + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 || v_1.Op != OpAnd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c >= 0) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (Leq64 (Const64 [0]) (Rsh64Ux64 _ (Const64 [c]))) + // cond: c > 0 + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 || v_1.Op != OpRsh64Ux64 { + break + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c > 0) { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq64 x (Const64 [-1])) + // result: (Less64 x (Const64 [0])) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + if auxIntToInt64(v_1.AuxInt) != -1 { + break + } + v.reset(OpLess64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Leq64 (Const64 [1]) x) + // result: (Less64 (Const64 [0]) x) + for { + if v_0.Op != OpConst64 { + break + } + t := v_0.Type + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpLess64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq64 (Const64 [math.MinInt64]) _) + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != math.MinInt64 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq64 _ (Const64 [math.MaxInt64])) + // result: (ConstBool [true]) + for { + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != math.MaxInt64 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq64 x c:(Const64 [math.MinInt64])) + // result: (Eq64 x c) + for { + x := v_0 + c := v_1 + if c.Op != OpConst64 || auxIntToInt64(c.AuxInt) != math.MinInt64 { + break + } + v.reset(OpEq64) + v.AddArg2(x, c) + return true + } + // match: (Leq64 c:(Const64 [math.MaxInt64]) x) + // result: (Eq64 x c) + for { + c := v_0 + if c.Op != OpConst64 || auxIntToInt64(c.AuxInt) != math.MaxInt64 { + break + } + x := v_1 + v.reset(OpEq64) + v.AddArg2(x, c) + return true + } + return false +} +func rewriteValuegeneric_OpLeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Leq64F (Const64F [c]) (Const64F [d])) + // result: (ConstBool [c <= d]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + if v_1.Op != OpConst64F { + break + } + d := auxIntToFloat64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c <= d) + return true + } + return false +} +func rewriteValuegeneric_OpLeq64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq64U (Const64 [c]) (Const64 [d])) + // result: (ConstBool [uint64(c) <= uint64(d)]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(uint64(c) <= uint64(d)) + return true + } + // match: (Leq64U (Const64 [1]) x) + // result: (Neq64 (Const64 [0]) x) + for { + if v_0.Op != OpConst64 { + break + } + t := v_0.Type + if auxIntToInt64(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpNeq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq64U (Const64 [0]) _) + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq64U _ (Const64 [-1])) + // result: (ConstBool [true]) + for { + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != -1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq64U x c:(Const64 [0])) + // result: (Eq64 x c) + for { + x := v_0 + c := v_1 + if c.Op != OpConst64 || auxIntToInt64(c.AuxInt) != 0 { + break + } + v.reset(OpEq64) + v.AddArg2(x, c) + return true + } + // match: (Leq64U c:(Const64 [-1]) x) + // result: (Eq64 x c) + for { + c := v_0 + if c.Op != OpConst64 || auxIntToInt64(c.AuxInt) != -1 { + break + } + x := v_1 + v.reset(OpEq64) + v.AddArg2(x, c) + return true + } + return false +} +func rewriteValuegeneric_OpLeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq8 (Const8 [c]) (Const8 [d])) + // result: (ConstBool [c <= d]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + break + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c <= d) + return true + } + // match: (Leq8 (Const8 [0]) (And8 _ (Const8 [c]))) + // cond: c >= 0 + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 || v_1.Op != OpAnd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_1.AuxInt) + if !(c >= 0) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (Leq8 (Const8 [0]) (Rsh8Ux64 _ (Const64 [c]))) + // cond: c > 0 + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 || v_1.Op != OpRsh8Ux64 { + break + } + _ = v_1.Args[1] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c > 0) { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq8 x (Const8 [-1])) + // result: (Less8 x (Const8 [0])) + for { + x := v_0 + if v_1.Op != OpConst8 { + break + } + t := v_1.Type + if auxIntToInt8(v_1.AuxInt) != -1 { + break + } + v.reset(OpLess8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Leq8 (Const8 [1]) x) + // result: (Less8 (Const8 [0]) x) + for { + if v_0.Op != OpConst8 { + break + } + t := v_0.Type + if auxIntToInt8(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpLess8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq8 (Const8 [math.MinInt8 ]) _) + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != math.MinInt8 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq8 _ (Const8 [math.MaxInt8 ])) + // result: (ConstBool [true]) + for { + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != math.MaxInt8 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq8 x c:(Const8 [math.MinInt8 ])) + // result: (Eq8 x c) + for { + x := v_0 + c := v_1 + if c.Op != OpConst8 || auxIntToInt8(c.AuxInt) != math.MinInt8 { + break + } + v.reset(OpEq8) + v.AddArg2(x, c) + return true + } + // match: (Leq8 c:(Const8 [math.MaxInt8 ]) x) + // result: (Eq8 x c) + for { + c := v_0 + if c.Op != OpConst8 || auxIntToInt8(c.AuxInt) != math.MaxInt8 { + break + } + x := v_1 + v.reset(OpEq8) + v.AddArg2(x, c) + return true + } + return false +} +func rewriteValuegeneric_OpLeq8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Leq8U (Const8 [c]) (Const8 [d])) + // result: (ConstBool [ uint8(c) <= uint8(d)]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + break + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(uint8(c) <= uint8(d)) + return true + } + // match: (Leq8U (Const8 [1]) x) + // result: (Neq8 (Const8 [0]) x) + for { + if v_0.Op != OpConst8 { + break + } + t := v_0.Type + if auxIntToInt8(v_0.AuxInt) != 1 { + break + } + x := v_1 + v.reset(OpNeq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Leq8U (Const8 [0]) _) + // result: (ConstBool [true]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq8U _ (Const8 [-1])) + // result: (ConstBool [true]) + for { + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != -1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (Leq8U x c:(Const8 [0])) + // result: (Eq8 x c) + for { + x := v_0 + c := v_1 + if c.Op != OpConst8 || auxIntToInt8(c.AuxInt) != 0 { + break + } + v.reset(OpEq8) + v.AddArg2(x, c) + return true + } + // match: (Leq8U c:(Const8 [-1]) x) + // result: (Eq8 x c) + for { + c := v_0 + if c.Op != OpConst8 || auxIntToInt8(c.AuxInt) != -1 { + break + } + x := v_1 + v.reset(OpEq8) + v.AddArg2(x, c) + return true + } + return false +} +func rewriteValuegeneric_OpLess16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less16 (Const16 [c]) (Const16 [d])) + // result: (ConstBool [c < d]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + break + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c < d) + return true + } + // match: (Less16 (Const16 [0]) x) + // cond: isNonNegative(x) + // result: (Neq16 (Const16 [0]) x) + for { + if v_0.Op != OpConst16 { + break + } + t := v_0.Type + if auxIntToInt16(v_0.AuxInt) != 0 { + break + } + x := v_1 + if !(isNonNegative(x)) { + break + } + v.reset(OpNeq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less16 x (Const16 [1])) + // cond: isNonNegative(x) + // result: (Eq16 (Const16 [0]) x) + for { + x := v_0 + if v_1.Op != OpConst16 { + break + } + t := v_1.Type + if auxIntToInt16(v_1.AuxInt) != 1 || !(isNonNegative(x)) { + break + } + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less16 x (Const16 [1])) + // result: (Leq16 x (Const16 [0])) + for { + x := v_0 + if v_1.Op != OpConst16 { + break + } + t := v_1.Type + if auxIntToInt16(v_1.AuxInt) != 1 { + break + } + v.reset(OpLeq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less16 (Const16 [-1]) x) + // result: (Leq16 (Const16 [0]) x) + for { + if v_0.Op != OpConst16 { + break + } + t := v_0.Type + if auxIntToInt16(v_0.AuxInt) != -1 { + break + } + x := v_1 + v.reset(OpLeq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less16 _ (Const16 [math.MinInt16])) + // result: (ConstBool [false]) + for { + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != math.MinInt16 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less16 (Const16 [math.MaxInt16]) _) + // result: (ConstBool [false]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != math.MaxInt16 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less16 x (Const16 [math.MinInt16+1])) + // result: (Eq16 x (Const16 [math.MinInt16])) + for { + x := v_0 + if v_1.Op != OpConst16 { + break + } + t := v_1.Type + if auxIntToInt16(v_1.AuxInt) != math.MinInt16+1 { + break + } + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(math.MinInt16) + v.AddArg2(x, v0) + return true + } + // match: (Less16 (Const16 [math.MaxInt16-1]) x) + // result: (Eq16 x (Const16 [math.MaxInt16])) + for { + if v_0.Op != OpConst16 { + break + } + t := v_0.Type + if auxIntToInt16(v_0.AuxInt) != math.MaxInt16-1 { + break + } + x := v_1 + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(math.MaxInt16) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpLess16U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less16U (Const16 [c]) (Const16 [d])) + // result: (ConstBool [uint16(c) < uint16(d)]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + break + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(uint16(c) < uint16(d)) + return true + } + // match: (Less16U x (Const16 [1])) + // result: (Eq16 (Const16 [0]) x) + for { + x := v_0 + if v_1.Op != OpConst16 { + break + } + t := v_1.Type + if auxIntToInt16(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less16U _ (Const16 [0])) + // result: (ConstBool [false]) + for { + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less16U (Const16 [-1]) _) + // result: (ConstBool [false]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != -1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less16U x (Const16 [1])) + // result: (Eq16 x (Const16 [0])) + for { + x := v_0 + if v_1.Op != OpConst16 { + break + } + t := v_1.Type + if auxIntToInt16(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less16U (Const16 [-2]) x) + // result: (Eq16 x (Const16 [-1])) + for { + if v_0.Op != OpConst16 { + break + } + t := v_0.Type + if auxIntToInt16(v_0.AuxInt) != -2 { + break + } + x := v_1 + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(-1) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpLess32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32 (Const32 [c]) (Const32 [d])) + // result: (ConstBool [c < d]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + break + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c < d) + return true + } + // match: (Less32 (Const32 [0]) x) + // cond: isNonNegative(x) + // result: (Neq32 (Const32 [0]) x) + for { + if v_0.Op != OpConst32 { + break + } + t := v_0.Type + if auxIntToInt32(v_0.AuxInt) != 0 { + break + } + x := v_1 + if !(isNonNegative(x)) { + break + } + v.reset(OpNeq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less32 x (Const32 [1])) + // cond: isNonNegative(x) + // result: (Eq32 (Const32 [0]) x) + for { + x := v_0 + if v_1.Op != OpConst32 { + break + } + t := v_1.Type + if auxIntToInt32(v_1.AuxInt) != 1 || !(isNonNegative(x)) { + break + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less32 x (Const32 [1])) + // result: (Leq32 x (Const32 [0])) + for { + x := v_0 + if v_1.Op != OpConst32 { + break + } + t := v_1.Type + if auxIntToInt32(v_1.AuxInt) != 1 { + break + } + v.reset(OpLeq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less32 (Const32 [-1]) x) + // result: (Leq32 (Const32 [0]) x) + for { + if v_0.Op != OpConst32 { + break + } + t := v_0.Type + if auxIntToInt32(v_0.AuxInt) != -1 { + break + } + x := v_1 + v.reset(OpLeq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less32 _ (Const32 [math.MinInt32])) + // result: (ConstBool [false]) + for { + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != math.MinInt32 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less32 (Const32 [math.MaxInt32]) _) + // result: (ConstBool [false]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != math.MaxInt32 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less32 x (Const32 [math.MinInt32+1])) + // result: (Eq32 x (Const32 [math.MinInt32])) + for { + x := v_0 + if v_1.Op != OpConst32 { + break + } + t := v_1.Type + if auxIntToInt32(v_1.AuxInt) != math.MinInt32+1 { + break + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(math.MinInt32) + v.AddArg2(x, v0) + return true + } + // match: (Less32 (Const32 [math.MaxInt32-1]) x) + // result: (Eq32 x (Const32 [math.MaxInt32])) + for { + if v_0.Op != OpConst32 { + break + } + t := v_0.Type + if auxIntToInt32(v_0.AuxInt) != math.MaxInt32-1 { + break + } + x := v_1 + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(math.MaxInt32) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpLess32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Less32F (Const32F [c]) (Const32F [d])) + // result: (ConstBool [c < d]) + for { + if v_0.Op != OpConst32F { + break + } + c := auxIntToFloat32(v_0.AuxInt) + if v_1.Op != OpConst32F { + break + } + d := auxIntToFloat32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c < d) + return true + } + return false +} +func rewriteValuegeneric_OpLess32U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less32U (Const32 [c]) (Const32 [d])) + // result: (ConstBool [uint32(c) < uint32(d)]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + break + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(uint32(c) < uint32(d)) + return true + } + // match: (Less32U x (Const32 [1])) + // result: (Eq32 (Const32 [0]) x) + for { + x := v_0 + if v_1.Op != OpConst32 { + break + } + t := v_1.Type + if auxIntToInt32(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less32U _ (Const32 [0])) + // result: (ConstBool [false]) + for { + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less32U (Const32 [-1]) _) + // result: (ConstBool [false]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != -1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less32U x (Const32 [1])) + // result: (Eq32 x (Const32 [0])) + for { + x := v_0 + if v_1.Op != OpConst32 { + break + } + t := v_1.Type + if auxIntToInt32(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less32U (Const32 [-2]) x) + // result: (Eq32 x (Const32 [-1])) + for { + if v_0.Op != OpConst32 { + break + } + t := v_0.Type + if auxIntToInt32(v_0.AuxInt) != -2 { + break + } + x := v_1 + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(-1) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpLess64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64 (Const64 [c]) (Const64 [d])) + // result: (ConstBool [c < d]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c < d) + return true + } + // match: (Less64 (Const64 [0]) x) + // cond: isNonNegative(x) + // result: (Neq64 (Const64 [0]) x) + for { + if v_0.Op != OpConst64 { + break + } + t := v_0.Type + if auxIntToInt64(v_0.AuxInt) != 0 { + break + } + x := v_1 + if !(isNonNegative(x)) { + break + } + v.reset(OpNeq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less64 x (Const64 [1])) + // cond: isNonNegative(x) + // result: (Eq64 (Const64 [0]) x) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + if auxIntToInt64(v_1.AuxInt) != 1 || !(isNonNegative(x)) { + break + } + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less64 x (Const64 [1])) + // result: (Leq64 x (Const64 [0])) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + if auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.reset(OpLeq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less64 (Const64 [-1]) x) + // result: (Leq64 (Const64 [0]) x) + for { + if v_0.Op != OpConst64 { + break + } + t := v_0.Type + if auxIntToInt64(v_0.AuxInt) != -1 { + break + } + x := v_1 + v.reset(OpLeq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less64 _ (Const64 [math.MinInt64])) + // result: (ConstBool [false]) + for { + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != math.MinInt64 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less64 (Const64 [math.MaxInt64]) _) + // result: (ConstBool [false]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != math.MaxInt64 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less64 x (Const64 [math.MinInt64+1])) + // result: (Eq64 x (Const64 [math.MinInt64])) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + if auxIntToInt64(v_1.AuxInt) != math.MinInt64+1 { + break + } + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(math.MinInt64) + v.AddArg2(x, v0) + return true + } + // match: (Less64 (Const64 [math.MaxInt64-1]) x) + // result: (Eq64 x (Const64 [math.MaxInt64])) + for { + if v_0.Op != OpConst64 { + break + } + t := v_0.Type + if auxIntToInt64(v_0.AuxInt) != math.MaxInt64-1 { + break + } + x := v_1 + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(math.MaxInt64) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpLess64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Less64F (Const64F [c]) (Const64F [d])) + // result: (ConstBool [c < d]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + if v_1.Op != OpConst64F { + break + } + d := auxIntToFloat64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c < d) + return true + } + return false +} +func rewriteValuegeneric_OpLess64U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less64U (Const64 [c]) (Const64 [d])) + // result: (ConstBool [uint64(c) < uint64(d)]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(uint64(c) < uint64(d)) + return true + } + // match: (Less64U x (Const64 [1])) + // result: (Eq64 (Const64 [0]) x) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + if auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less64U _ (Const64 [0])) + // result: (ConstBool [false]) + for { + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less64U (Const64 [-1]) _) + // result: (ConstBool [false]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != -1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less64U x (Const64 [1])) + // result: (Eq64 x (Const64 [0])) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + if auxIntToInt64(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less64U (Const64 [-2]) x) + // result: (Eq64 x (Const64 [-1])) + for { + if v_0.Op != OpConst64 { + break + } + t := v_0.Type + if auxIntToInt64(v_0.AuxInt) != -2 { + break + } + x := v_1 + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(-1) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpLess8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less8 (Const8 [c]) (Const8 [d])) + // result: (ConstBool [c < d]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + break + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c < d) + return true + } + // match: (Less8 (Const8 [0]) x) + // cond: isNonNegative(x) + // result: (Neq8 (Const8 [0]) x) + for { + if v_0.Op != OpConst8 { + break + } + t := v_0.Type + if auxIntToInt8(v_0.AuxInt) != 0 { + break + } + x := v_1 + if !(isNonNegative(x)) { + break + } + v.reset(OpNeq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less8 x (Const8 [1])) + // cond: isNonNegative(x) + // result: (Eq8 (Const8 [0]) x) + for { + x := v_0 + if v_1.Op != OpConst8 { + break + } + t := v_1.Type + if auxIntToInt8(v_1.AuxInt) != 1 || !(isNonNegative(x)) { + break + } + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less8 x (Const8 [1])) + // result: (Leq8 x (Const8 [0])) + for { + x := v_0 + if v_1.Op != OpConst8 { + break + } + t := v_1.Type + if auxIntToInt8(v_1.AuxInt) != 1 { + break + } + v.reset(OpLeq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less8 (Const8 [-1]) x) + // result: (Leq8 (Const8 [0]) x) + for { + if v_0.Op != OpConst8 { + break + } + t := v_0.Type + if auxIntToInt8(v_0.AuxInt) != -1 { + break + } + x := v_1 + v.reset(OpLeq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less8 _ (Const8 [math.MinInt8 ])) + // result: (ConstBool [false]) + for { + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != math.MinInt8 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less8 (Const8 [math.MaxInt8 ]) _) + // result: (ConstBool [false]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != math.MaxInt8 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less8 x (Const8 [math.MinInt8 +1])) + // result: (Eq8 x (Const8 [math.MinInt8 ])) + for { + x := v_0 + if v_1.Op != OpConst8 { + break + } + t := v_1.Type + if auxIntToInt8(v_1.AuxInt) != math.MinInt8+1 { + break + } + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(math.MinInt8) + v.AddArg2(x, v0) + return true + } + // match: (Less8 (Const8 [math.MaxInt8 -1]) x) + // result: (Eq8 x (Const8 [math.MaxInt8 ])) + for { + if v_0.Op != OpConst8 { + break + } + t := v_0.Type + if auxIntToInt8(v_0.AuxInt) != math.MaxInt8-1 { + break + } + x := v_1 + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(math.MaxInt8) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpLess8U(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Less8U (Const8 [c]) (Const8 [d])) + // result: (ConstBool [ uint8(c) < uint8(d)]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + break + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(uint8(c) < uint8(d)) + return true + } + // match: (Less8U x (Const8 [1])) + // result: (Eq8 (Const8 [0]) x) + for { + x := v_0 + if v_1.Op != OpConst8 { + break + } + t := v_1.Type + if auxIntToInt8(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, x) + return true + } + // match: (Less8U _ (Const8 [0])) + // result: (ConstBool [false]) + for { + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less8U (Const8 [-1]) _) + // result: (ConstBool [false]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != -1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Less8U x (Const8 [1])) + // result: (Eq8 x (Const8 [0])) + for { + x := v_0 + if v_1.Op != OpConst8 { + break + } + t := v_1.Type + if auxIntToInt8(v_1.AuxInt) != 1 { + break + } + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(0) + v.AddArg2(x, v0) + return true + } + // match: (Less8U (Const8 [-2]) x) + // result: (Eq8 x (Const8 [-1])) + for { + if v_0.Op != OpConst8 { + break + } + t := v_0.Type + if auxIntToInt8(v_0.AuxInt) != -2 { + break + } + x := v_1 + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(-1) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpLoad(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (Load p1 (Store {t2} p2 x _)) + // cond: isSamePtr(p1, p2) && copyCompatibleType(t1, x.Type) && t1.Size() == t2.Size() + // result: x + for { + t1 := v.Type + p1 := v_0 + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + x := v_1.Args[1] + p2 := v_1.Args[0] + if !(isSamePtr(p1, p2) && copyCompatibleType(t1, x.Type) && t1.Size() == t2.Size()) { + break + } + v.copyOf(x) + return true + } + // match: (Load p1 (Store {t2} p2 _ (Store {t3} p3 x _))) + // cond: isSamePtr(p1, p3) && copyCompatibleType(t1, x.Type) && t1.Size() == t3.Size() && disjoint(p3, t3.Size(), p2, t2.Size()) + // result: x + for { + t1 := v.Type + p1 := v_0 + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[2] + p2 := v_1.Args[0] + v_1_2 := v_1.Args[2] + if v_1_2.Op != OpStore { + break + } + t3 := auxToType(v_1_2.Aux) + x := v_1_2.Args[1] + p3 := v_1_2.Args[0] + if !(isSamePtr(p1, p3) && copyCompatibleType(t1, x.Type) && t1.Size() == t3.Size() && disjoint(p3, t3.Size(), p2, t2.Size())) { + break + } + v.copyOf(x) + return true + } + // match: (Load p1 (Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 x _)))) + // cond: isSamePtr(p1, p4) && copyCompatibleType(t1, x.Type) && t1.Size() == t4.Size() && disjoint(p4, t4.Size(), p2, t2.Size()) && disjoint(p4, t4.Size(), p3, t3.Size()) + // result: x + for { + t1 := v.Type + p1 := v_0 + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[2] + p2 := v_1.Args[0] + v_1_2 := v_1.Args[2] + if v_1_2.Op != OpStore { + break + } + t3 := auxToType(v_1_2.Aux) + _ = v_1_2.Args[2] + p3 := v_1_2.Args[0] + v_1_2_2 := v_1_2.Args[2] + if v_1_2_2.Op != OpStore { + break + } + t4 := auxToType(v_1_2_2.Aux) + x := v_1_2_2.Args[1] + p4 := v_1_2_2.Args[0] + if !(isSamePtr(p1, p4) && copyCompatibleType(t1, x.Type) && t1.Size() == t4.Size() && disjoint(p4, t4.Size(), p2, t2.Size()) && disjoint(p4, t4.Size(), p3, t3.Size())) { + break + } + v.copyOf(x) + return true + } + // match: (Load p1 (Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ (Store {t5} p5 x _))))) + // cond: isSamePtr(p1, p5) && copyCompatibleType(t1, x.Type) && t1.Size() == t5.Size() && disjoint(p5, t5.Size(), p2, t2.Size()) && disjoint(p5, t5.Size(), p3, t3.Size()) && disjoint(p5, t5.Size(), p4, t4.Size()) + // result: x + for { + t1 := v.Type + p1 := v_0 + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[2] + p2 := v_1.Args[0] + v_1_2 := v_1.Args[2] + if v_1_2.Op != OpStore { + break + } + t3 := auxToType(v_1_2.Aux) + _ = v_1_2.Args[2] + p3 := v_1_2.Args[0] + v_1_2_2 := v_1_2.Args[2] + if v_1_2_2.Op != OpStore { + break + } + t4 := auxToType(v_1_2_2.Aux) + _ = v_1_2_2.Args[2] + p4 := v_1_2_2.Args[0] + v_1_2_2_2 := v_1_2_2.Args[2] + if v_1_2_2_2.Op != OpStore { + break + } + t5 := auxToType(v_1_2_2_2.Aux) + x := v_1_2_2_2.Args[1] + p5 := v_1_2_2_2.Args[0] + if !(isSamePtr(p1, p5) && copyCompatibleType(t1, x.Type) && t1.Size() == t5.Size() && disjoint(p5, t5.Size(), p2, t2.Size()) && disjoint(p5, t5.Size(), p3, t3.Size()) && disjoint(p5, t5.Size(), p4, t4.Size())) { + break + } + v.copyOf(x) + return true + } + // match: (Load p1 (Store {t2} p2 (Const64 [x]) _)) + // cond: isSamePtr(p1,p2) && t2.Size() == 8 && is64BitFloat(t1) && !math.IsNaN(math.Float64frombits(uint64(x))) + // result: (Const64F [math.Float64frombits(uint64(x))]) + for { + t1 := v.Type + p1 := v_0 + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[1] + p2 := v_1.Args[0] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + break + } + x := auxIntToInt64(v_1_1.AuxInt) + if !(isSamePtr(p1, p2) && t2.Size() == 8 && is64BitFloat(t1) && !math.IsNaN(math.Float64frombits(uint64(x)))) { + break + } + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(math.Float64frombits(uint64(x))) + return true + } + // match: (Load p1 (Store {t2} p2 (Const32 [x]) _)) + // cond: isSamePtr(p1,p2) && t2.Size() == 4 && is32BitFloat(t1) && !math.IsNaN(float64(math.Float32frombits(uint32(x)))) + // result: (Const32F [math.Float32frombits(uint32(x))]) + for { + t1 := v.Type + p1 := v_0 + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[1] + p2 := v_1.Args[0] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + break + } + x := auxIntToInt32(v_1_1.AuxInt) + if !(isSamePtr(p1, p2) && t2.Size() == 4 && is32BitFloat(t1) && !math.IsNaN(float64(math.Float32frombits(uint32(x))))) { + break + } + v.reset(OpConst32F) + v.AuxInt = float32ToAuxInt(math.Float32frombits(uint32(x))) + return true + } + // match: (Load p1 (Store {t2} p2 (Const64F [x]) _)) + // cond: isSamePtr(p1,p2) && t2.Size() == 8 && is64BitInt(t1) + // result: (Const64 [int64(math.Float64bits(x))]) + for { + t1 := v.Type + p1 := v_0 + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[1] + p2 := v_1.Args[0] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64F { + break + } + x := auxIntToFloat64(v_1_1.AuxInt) + if !(isSamePtr(p1, p2) && t2.Size() == 8 && is64BitInt(t1)) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(math.Float64bits(x))) + return true + } + // match: (Load p1 (Store {t2} p2 (Const32F [x]) _)) + // cond: isSamePtr(p1,p2) && t2.Size() == 4 && is32BitInt(t1) + // result: (Const32 [int32(math.Float32bits(x))]) + for { + t1 := v.Type + p1 := v_0 + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[1] + p2 := v_1.Args[0] + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32F { + break + } + x := auxIntToFloat32(v_1_1.AuxInt) + if !(isSamePtr(p1, p2) && t2.Size() == 4 && is32BitInt(t1)) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(math.Float32bits(x))) + return true + } + // match: (Load op:(OffPtr [o1] p1) (Store {t2} p2 _ mem:(Zero [n] p3 _))) + // cond: o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p3) && CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) + // result: @mem.Block (Load (OffPtr [o1] p3) mem) + for { + t1 := v.Type + op := v_0 + if op.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op.AuxInt) + p1 := op.Args[0] + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[2] + p2 := v_1.Args[0] + mem := v_1.Args[2] + if mem.Op != OpZero { + break + } + n := auxIntToInt64(mem.AuxInt) + p3 := mem.Args[0] + if !(o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p3) && CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size())) { + break + } + b = mem.Block + v0 := b.NewValue0(v.Pos, OpLoad, t1) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, op.Type) + v1.AuxInt = int64ToAuxInt(o1) + v1.AddArg(p3) + v0.AddArg2(v1, mem) + return true + } + // match: (Load op:(OffPtr [o1] p1) (Store {t2} p2 _ (Store {t3} p3 _ mem:(Zero [n] p4 _)))) + // cond: o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p4) && CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) + // result: @mem.Block (Load (OffPtr [o1] p4) mem) + for { + t1 := v.Type + op := v_0 + if op.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op.AuxInt) + p1 := op.Args[0] + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[2] + p2 := v_1.Args[0] + v_1_2 := v_1.Args[2] + if v_1_2.Op != OpStore { + break + } + t3 := auxToType(v_1_2.Aux) + _ = v_1_2.Args[2] + p3 := v_1_2.Args[0] + mem := v_1_2.Args[2] + if mem.Op != OpZero { + break + } + n := auxIntToInt64(mem.AuxInt) + p4 := mem.Args[0] + if !(o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p4) && CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size())) { + break + } + b = mem.Block + v0 := b.NewValue0(v.Pos, OpLoad, t1) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, op.Type) + v1.AuxInt = int64ToAuxInt(o1) + v1.AddArg(p4) + v0.AddArg2(v1, mem) + return true + } + // match: (Load op:(OffPtr [o1] p1) (Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ mem:(Zero [n] p5 _))))) + // cond: o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p5) && CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size()) + // result: @mem.Block (Load (OffPtr [o1] p5) mem) + for { + t1 := v.Type + op := v_0 + if op.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op.AuxInt) + p1 := op.Args[0] + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[2] + p2 := v_1.Args[0] + v_1_2 := v_1.Args[2] + if v_1_2.Op != OpStore { + break + } + t3 := auxToType(v_1_2.Aux) + _ = v_1_2.Args[2] + p3 := v_1_2.Args[0] + v_1_2_2 := v_1_2.Args[2] + if v_1_2_2.Op != OpStore { + break + } + t4 := auxToType(v_1_2_2.Aux) + _ = v_1_2_2.Args[2] + p4 := v_1_2_2.Args[0] + mem := v_1_2_2.Args[2] + if mem.Op != OpZero { + break + } + n := auxIntToInt64(mem.AuxInt) + p5 := mem.Args[0] + if !(o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p5) && CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size())) { + break + } + b = mem.Block + v0 := b.NewValue0(v.Pos, OpLoad, t1) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, op.Type) + v1.AuxInt = int64ToAuxInt(o1) + v1.AddArg(p5) + v0.AddArg2(v1, mem) + return true + } + // match: (Load op:(OffPtr [o1] p1) (Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ (Store {t5} p5 _ mem:(Zero [n] p6 _)))))) + // cond: o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p6) && CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size()) && disjoint(op, t1.Size(), p5, t5.Size()) + // result: @mem.Block (Load (OffPtr [o1] p6) mem) + for { + t1 := v.Type + op := v_0 + if op.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op.AuxInt) + p1 := op.Args[0] + if v_1.Op != OpStore { + break + } + t2 := auxToType(v_1.Aux) + _ = v_1.Args[2] + p2 := v_1.Args[0] + v_1_2 := v_1.Args[2] + if v_1_2.Op != OpStore { + break + } + t3 := auxToType(v_1_2.Aux) + _ = v_1_2.Args[2] + p3 := v_1_2.Args[0] + v_1_2_2 := v_1_2.Args[2] + if v_1_2_2.Op != OpStore { + break + } + t4 := auxToType(v_1_2_2.Aux) + _ = v_1_2_2.Args[2] + p4 := v_1_2_2.Args[0] + v_1_2_2_2 := v_1_2_2.Args[2] + if v_1_2_2_2.Op != OpStore { + break + } + t5 := auxToType(v_1_2_2_2.Aux) + _ = v_1_2_2_2.Args[2] + p5 := v_1_2_2_2.Args[0] + mem := v_1_2_2_2.Args[2] + if mem.Op != OpZero { + break + } + n := auxIntToInt64(mem.AuxInt) + p6 := mem.Args[0] + if !(o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p6) && CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size()) && disjoint(op, t1.Size(), p5, t5.Size())) { + break + } + b = mem.Block + v0 := b.NewValue0(v.Pos, OpLoad, t1) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, op.Type) + v1.AuxInt = int64ToAuxInt(o1) + v1.AddArg(p6) + v0.AddArg2(v1, mem) + return true + } + // match: (Load (OffPtr [o] p1) (Zero [n] p2 _)) + // cond: t1.IsBoolean() && isSamePtr(p1, p2) && n >= o + 1 + // result: (ConstBool [false]) + for { + t1 := v.Type + if v_0.Op != OpOffPtr { + break + } + o := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + if v_1.Op != OpZero { + break + } + n := auxIntToInt64(v_1.AuxInt) + p2 := v_1.Args[0] + if !(t1.IsBoolean() && isSamePtr(p1, p2) && n >= o+1) { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Load (OffPtr [o] p1) (Zero [n] p2 _)) + // cond: is8BitInt(t1) && isSamePtr(p1, p2) && n >= o + 1 + // result: (Const8 [0]) + for { + t1 := v.Type + if v_0.Op != OpOffPtr { + break + } + o := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + if v_1.Op != OpZero { + break + } + n := auxIntToInt64(v_1.AuxInt) + p2 := v_1.Args[0] + if !(is8BitInt(t1) && isSamePtr(p1, p2) && n >= o+1) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Load (OffPtr [o] p1) (Zero [n] p2 _)) + // cond: is16BitInt(t1) && isSamePtr(p1, p2) && n >= o + 2 + // result: (Const16 [0]) + for { + t1 := v.Type + if v_0.Op != OpOffPtr { + break + } + o := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + if v_1.Op != OpZero { + break + } + n := auxIntToInt64(v_1.AuxInt) + p2 := v_1.Args[0] + if !(is16BitInt(t1) && isSamePtr(p1, p2) && n >= o+2) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Load (OffPtr [o] p1) (Zero [n] p2 _)) + // cond: is32BitInt(t1) && isSamePtr(p1, p2) && n >= o + 4 + // result: (Const32 [0]) + for { + t1 := v.Type + if v_0.Op != OpOffPtr { + break + } + o := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + if v_1.Op != OpZero { + break + } + n := auxIntToInt64(v_1.AuxInt) + p2 := v_1.Args[0] + if !(is32BitInt(t1) && isSamePtr(p1, p2) && n >= o+4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Load (OffPtr [o] p1) (Zero [n] p2 _)) + // cond: is64BitInt(t1) && isSamePtr(p1, p2) && n >= o + 8 + // result: (Const64 [0]) + for { + t1 := v.Type + if v_0.Op != OpOffPtr { + break + } + o := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + if v_1.Op != OpZero { + break + } + n := auxIntToInt64(v_1.AuxInt) + p2 := v_1.Args[0] + if !(is64BitInt(t1) && isSamePtr(p1, p2) && n >= o+8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Load (OffPtr [o] p1) (Zero [n] p2 _)) + // cond: is32BitFloat(t1) && isSamePtr(p1, p2) && n >= o + 4 + // result: (Const32F [0]) + for { + t1 := v.Type + if v_0.Op != OpOffPtr { + break + } + o := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + if v_1.Op != OpZero { + break + } + n := auxIntToInt64(v_1.AuxInt) + p2 := v_1.Args[0] + if !(is32BitFloat(t1) && isSamePtr(p1, p2) && n >= o+4) { + break + } + v.reset(OpConst32F) + v.AuxInt = float32ToAuxInt(0) + return true + } + // match: (Load (OffPtr [o] p1) (Zero [n] p2 _)) + // cond: is64BitFloat(t1) && isSamePtr(p1, p2) && n >= o + 8 + // result: (Const64F [0]) + for { + t1 := v.Type + if v_0.Op != OpOffPtr { + break + } + o := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + if v_1.Op != OpZero { + break + } + n := auxIntToInt64(v_1.AuxInt) + p2 := v_1.Args[0] + if !(is64BitFloat(t1) && isSamePtr(p1, p2) && n >= o+8) { + break + } + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(0) + return true + } + // match: (Load _ _) + // cond: t.IsStruct() && t.Size() > 0 && CanSSA(t) && !t.IsSIMD() + // result: rewriteStructLoad(v) + for { + t := v.Type + if !(t.IsStruct() && t.Size() > 0 && CanSSA(t) && !t.IsSIMD()) { + break + } + v.copyOf(rewriteStructLoad(v)) + return true + } + // match: (Load ptr mem) + // cond: t.IsArray() && t.NumElem() == 1 && CanSSA(t) + // result: (ArrayMake1 (Load ptr mem)) + for { + t := v.Type + ptr := v_0 + mem := v_1 + if !(t.IsArray() && t.NumElem() == 1 && CanSSA(t)) { + break + } + v.reset(OpArrayMake1) + v0 := b.NewValue0(v.Pos, OpLoad, t.Elem()) + v0.AddArg2(ptr, mem) + v.AddArg(v0) + return true + } + // match: (Load _ _) + // cond: t.Size() == 0 + // result: (Empty) + for { + t := v.Type + if !(t.Size() == 0) { + break + } + v.reset(OpEmpty) + return true + } + // match: (Load sptr:(Addr {scon} (SB)) mem) + // cond: symIsRO(scon) + // result: (Const8 [int8(read8(scon,0))]) + for { + if v.Type != typ.Int8 { + break + } + sptr := v_0 + if sptr.Op != OpAddr { + break + } + scon := auxToSym(sptr.Aux) + sptr_0 := sptr.Args[0] + if sptr_0.Op != OpSB { + break + } + if !(symIsRO(scon)) { + break + } + v.reset(OpConst8) + v.Type = typ.Int8 + v.AuxInt = int8ToAuxInt(int8(read8(scon, 0))) + return true + } + // match: (Load sptr:(Addr {scon} (SB)) mem) + // cond: symIsRO(scon) + // result: (Const16 [int16(read16(scon,0,config.ctxt.Arch.ByteOrder))]) + for { + if v.Type != typ.Int16 { + break + } + sptr := v_0 + if sptr.Op != OpAddr { + break + } + scon := auxToSym(sptr.Aux) + sptr_0 := sptr.Args[0] + if sptr_0.Op != OpSB { + break + } + if !(symIsRO(scon)) { + break + } + v.reset(OpConst16) + v.Type = typ.Int16 + v.AuxInt = int16ToAuxInt(int16(read16(scon, 0, config.ctxt.Arch.ByteOrder))) + return true + } + // match: (Load sptr:(Addr {scon} (SB)) mem) + // cond: symIsRO(scon) + // result: (Const32 [int32(read32(scon,0,config.ctxt.Arch.ByteOrder))]) + for { + if v.Type != typ.Int32 { + break + } + sptr := v_0 + if sptr.Op != OpAddr { + break + } + scon := auxToSym(sptr.Aux) + sptr_0 := sptr.Args[0] + if sptr_0.Op != OpSB { + break + } + if !(symIsRO(scon)) { + break + } + v.reset(OpConst32) + v.Type = typ.Int32 + v.AuxInt = int32ToAuxInt(int32(read32(scon, 0, config.ctxt.Arch.ByteOrder))) + return true + } + // match: (Load sptr:(Addr {scon} (SB)) mem) + // cond: symIsRO(scon) + // result: (Const64 [int64(read64(scon,0,config.ctxt.Arch.ByteOrder))]) + for { + if v.Type != typ.Int64 { + break + } + sptr := v_0 + if sptr.Op != OpAddr { + break + } + scon := auxToSym(sptr.Aux) + sptr_0 := sptr.Args[0] + if sptr_0.Op != OpSB { + break + } + if !(symIsRO(scon)) { + break + } + v.reset(OpConst64) + v.Type = typ.Int64 + v.AuxInt = int64ToAuxInt(int64(read64(scon, 0, config.ctxt.Arch.ByteOrder))) + return true + } + // match: (Load (Addr {s} sb) _) + // cond: isFixedLoad(v, s, 0) + // result: rewriteFixedLoad(v, s, sb, 0) + for { + if v_0.Op != OpAddr { + break + } + s := auxToSym(v_0.Aux) + sb := v_0.Args[0] + if !(isFixedLoad(v, s, 0)) { + break + } + v.copyOf(rewriteFixedLoad(v, s, sb, 0)) + return true + } + // match: (Load (Convert (Addr {s} sb) _) _) + // cond: isFixedLoad(v, s, 0) + // result: rewriteFixedLoad(v, s, sb, 0) + for { + if v_0.Op != OpConvert { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAddr { + break + } + s := auxToSym(v_0_0.Aux) + sb := v_0_0.Args[0] + if !(isFixedLoad(v, s, 0)) { + break + } + v.copyOf(rewriteFixedLoad(v, s, sb, 0)) + return true + } + // match: (Load (ITab (IMake (Addr {s} sb) _)) _) + // cond: isFixedLoad(v, s, 0) + // result: rewriteFixedLoad(v, s, sb, 0) + for { + if v_0.Op != OpITab { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpIMake { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAddr { + break + } + s := auxToSym(v_0_0_0.Aux) + sb := v_0_0_0.Args[0] + if !(isFixedLoad(v, s, 0)) { + break + } + v.copyOf(rewriteFixedLoad(v, s, sb, 0)) + return true + } + // match: (Load (ITab (IMake (Convert (Addr {s} sb) _) _)) _) + // cond: isFixedLoad(v, s, 0) + // result: rewriteFixedLoad(v, s, sb, 0) + for { + if v_0.Op != OpITab { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpIMake { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpConvert { + break + } + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpAddr { + break + } + s := auxToSym(v_0_0_0_0.Aux) + sb := v_0_0_0_0.Args[0] + if !(isFixedLoad(v, s, 0)) { + break + } + v.copyOf(rewriteFixedLoad(v, s, sb, 0)) + return true + } + // match: (Load (OffPtr [off] (Addr {s} sb) ) _) + // cond: isFixedLoad(v, s, off) + // result: rewriteFixedLoad(v, s, sb, off) + for { + if v_0.Op != OpOffPtr { + break + } + off := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAddr { + break + } + s := auxToSym(v_0_0.Aux) + sb := v_0_0.Args[0] + if !(isFixedLoad(v, s, off)) { + break + } + v.copyOf(rewriteFixedLoad(v, s, sb, off)) + return true + } + // match: (Load (OffPtr [off] (Convert (Addr {s} sb) _) ) _) + // cond: isFixedLoad(v, s, off) + // result: rewriteFixedLoad(v, s, sb, off) + for { + if v_0.Op != OpOffPtr { + break + } + off := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConvert { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpAddr { + break + } + s := auxToSym(v_0_0_0.Aux) + sb := v_0_0_0.Args[0] + if !(isFixedLoad(v, s, off)) { + break + } + v.copyOf(rewriteFixedLoad(v, s, sb, off)) + return true + } + // match: (Load (OffPtr [off] (ITab (IMake (Addr {s} sb) _))) _) + // cond: isFixedLoad(v, s, off) + // result: rewriteFixedLoad(v, s, sb, off) + for { + if v_0.Op != OpOffPtr { + break + } + off := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpITab { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpIMake { + break + } + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpAddr { + break + } + s := auxToSym(v_0_0_0_0.Aux) + sb := v_0_0_0_0.Args[0] + if !(isFixedLoad(v, s, off)) { + break + } + v.copyOf(rewriteFixedLoad(v, s, sb, off)) + return true + } + // match: (Load (OffPtr [off] (ITab (IMake (Convert (Addr {s} sb) _) _))) _) + // cond: isFixedLoad(v, s, off) + // result: rewriteFixedLoad(v, s, sb, off) + for { + if v_0.Op != OpOffPtr { + break + } + off := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpITab { + break + } + v_0_0_0 := v_0_0.Args[0] + if v_0_0_0.Op != OpIMake { + break + } + v_0_0_0_0 := v_0_0_0.Args[0] + if v_0_0_0_0.Op != OpConvert { + break + } + v_0_0_0_0_0 := v_0_0_0_0.Args[0] + if v_0_0_0_0_0.Op != OpAddr { + break + } + s := auxToSym(v_0_0_0_0_0.Aux) + sb := v_0_0_0_0_0.Args[0] + if !(isFixedLoad(v, s, off)) { + break + } + v.copyOf(rewriteFixedLoad(v, s, sb, off)) + return true + } + return false +} +func rewriteValuegeneric_OpLsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x16 x (Const16 [c])) + // result: (Lsh16x64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpLsh16x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh16x16 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Lsh16x16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 16 + // result: (Lsh16x16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpLsh16x16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh16x32 x (Const32 [c])) + // result: (Lsh16x64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpLsh16x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh16x32 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Lsh16x32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 16 + // result: (Lsh16x32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpLsh16x32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh16x64 (Const16 [c]) (Const64 [d])) + // result: (Const16 [c << uint64(d)]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c << uint64(d)) + return true + } + // match: (Lsh16x64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Lsh16x64 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Lsh16x64 _ (Const64 [c])) + // cond: uint64(c) >= 16 + // result: (Const16 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 16) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Lsh16x64 (Lsh16x64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Lsh16x64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpLsh16x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpLsh16x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Lsh16x64 i:(Rsh16x64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 16 && i.Uses == 1 + // result: (And16 x (Const16 [int16(-1) << c])) + for { + i := v_0 + if i.Op != OpRsh16x64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 16 && i.Uses == 1) { + break + } + v.reset(OpAnd16) + v0 := b.NewValue0(v.Pos, OpConst16, v.Type) + v0.AuxInt = int16ToAuxInt(int16(-1) << c) + v.AddArg2(x, v0) + return true + } + // match: (Lsh16x64 i:(Rsh16Ux64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 16 && i.Uses == 1 + // result: (And16 x (Const16 [int16(-1) << c])) + for { + i := v_0 + if i.Op != OpRsh16Ux64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 16 && i.Uses == 1) { + break + } + v.reset(OpAnd16) + v0 := b.NewValue0(v.Pos, OpConst16, v.Type) + v0.AuxInt = int16ToAuxInt(int16(-1) << c) + v.AddArg2(x, v0) + return true + } + // match: (Lsh16x64 (Rsh16Ux64 (Lsh16x64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) + // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) + // result: (Lsh16x64 x (Const64 [c1-c2+c3])) + for { + if v_0.Op != OpRsh16Ux64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLsh16x64 { + break + } + _ = v_0_0.Args[1] + x := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpConst64 { + break + } + c1 := auxIntToInt64(v_0_0_1.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c2 := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + c3 := auxIntToInt64(v_1.AuxInt) + if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { + break + } + v.reset(OpLsh16x64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) + v.AddArg2(x, v0) + return true + } + // match: (Lsh16x64 (And16 (Rsh16x64 x (Const64 [c])) (Const16 [d])) (Const64 [e])) + // cond: c >= e + // result: (And16 (Rsh16x64 x (Const64 [c-e])) (Const16 [d<= e) { + continue + } + v.reset(OpAnd16) + v0 := b.NewValue0(v.Pos, OpRsh16x64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t2) + v1.AuxInt = int64ToAuxInt(c - e) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(d << e) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (Lsh16x64 (And16 (Rsh16Ux64 x (Const64 [c])) (Const16 [d])) (Const64 [e])) + // cond: c >= e + // result: (And16 (Rsh16Ux64 x (Const64 [c-e])) (Const16 [d<= e) { + continue + } + v.reset(OpAnd16) + v0 := b.NewValue0(v.Pos, OpRsh16Ux64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t2) + v1.AuxInt = int64ToAuxInt(c - e) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(d << e) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (Lsh16x64 (And16 (Rsh16x64 x (Const64 [c])) (Const16 [d])) (Const64 [e])) + // cond: c < e + // result: (And16 (Lsh16x64 x (Const64 [e-c])) (Const16 [d< x (Const64 [c])) (Const16 [d])) (Const64 [e])) + // cond: c < e + // result: (And16 (Lsh16x64 x (Const64 [e-c])) (Const16 [d< x (Const8 [c])) + // result: (Lsh16x64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpLsh16x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh16x8 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Lsh16x8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 16 + // result: (Lsh16x8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpLsh16x8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x16 x (Const16 [c])) + // result: (Lsh32x64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpLsh32x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh32x16 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Lsh32x16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 32 + // result: (Lsh32x16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpLsh32x16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh32x32 x (Const32 [c])) + // result: (Lsh32x64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpLsh32x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh32x32 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Lsh32x32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 32 + // result: (Lsh32x32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpLsh32x32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh32x64 (Const32 [c]) (Const64 [d])) + // result: (Const32 [c << uint64(d)]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c << uint64(d)) + return true + } + // match: (Lsh32x64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Lsh32x64 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Lsh32x64 _ (Const64 [c])) + // cond: uint64(c) >= 32 + // result: (Const32 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Lsh32x64 (Lsh32x64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Lsh32x64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpLsh32x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpLsh32x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Lsh32x64 i:(Rsh32x64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 32 && i.Uses == 1 + // result: (And32 x (Const32 [int32(-1) << c])) + for { + i := v_0 + if i.Op != OpRsh32x64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 32 && i.Uses == 1) { + break + } + v.reset(OpAnd32) + v0 := b.NewValue0(v.Pos, OpConst32, v.Type) + v0.AuxInt = int32ToAuxInt(int32(-1) << c) + v.AddArg2(x, v0) + return true + } + // match: (Lsh32x64 i:(Rsh32Ux64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 32 && i.Uses == 1 + // result: (And32 x (Const32 [int32(-1) << c])) + for { + i := v_0 + if i.Op != OpRsh32Ux64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 32 && i.Uses == 1) { + break + } + v.reset(OpAnd32) + v0 := b.NewValue0(v.Pos, OpConst32, v.Type) + v0.AuxInt = int32ToAuxInt(int32(-1) << c) + v.AddArg2(x, v0) + return true + } + // match: (Lsh32x64 (Rsh32Ux64 (Lsh32x64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) + // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) + // result: (Lsh32x64 x (Const64 [c1-c2+c3])) + for { + if v_0.Op != OpRsh32Ux64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLsh32x64 { + break + } + _ = v_0_0.Args[1] + x := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpConst64 { + break + } + c1 := auxIntToInt64(v_0_0_1.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c2 := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + c3 := auxIntToInt64(v_1.AuxInt) + if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { + break + } + v.reset(OpLsh32x64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) + v.AddArg2(x, v0) + return true + } + // match: (Lsh32x64 (And32 (Rsh32x64 x (Const64 [c])) (Const32 [d])) (Const64 [e])) + // cond: c >= e + // result: (And32 (Rsh32x64 x (Const64 [c-e])) (Const32 [d<= e) { + continue + } + v.reset(OpAnd32) + v0 := b.NewValue0(v.Pos, OpRsh32x64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t2) + v1.AuxInt = int64ToAuxInt(c - e) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(d << e) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (Lsh32x64 (And32 (Rsh32Ux64 x (Const64 [c])) (Const32 [d])) (Const64 [e])) + // cond: c >= e + // result: (And32 (Rsh32Ux64 x (Const64 [c-e])) (Const32 [d<= e) { + continue + } + v.reset(OpAnd32) + v0 := b.NewValue0(v.Pos, OpRsh32Ux64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t2) + v1.AuxInt = int64ToAuxInt(c - e) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(d << e) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (Lsh32x64 (And32 (Rsh32x64 x (Const64 [c])) (Const32 [d])) (Const64 [e])) + // cond: c < e + // result: (And32 (Lsh32x64 x (Const64 [e-c])) (Const32 [d< x (Const64 [c])) (Const32 [d])) (Const64 [e])) + // cond: c < e + // result: (And32 (Lsh32x64 x (Const64 [e-c])) (Const32 [d< x (Const8 [c])) + // result: (Lsh32x64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpLsh32x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh32x8 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Lsh32x8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 32 + // result: (Lsh32x8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpLsh32x8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh64x16 x (Const16 [c])) + // result: (Lsh64x64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpLsh64x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh64x16 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Lsh64x16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 64 + // result: (Lsh64x16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpLsh64x16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh64x32 x (Const32 [c])) + // result: (Lsh64x64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpLsh64x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh64x32 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Lsh64x32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 64 + // result: (Lsh64x32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpLsh64x32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh64x64 (Const64 [c]) (Const64 [d])) + // result: (Const64 [c << uint64(d)]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c << uint64(d)) + return true + } + // match: (Lsh64x64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Lsh64x64 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Lsh64x64 _ (Const64 [c])) + // cond: uint64(c) >= 64 + // result: (Const64 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Lsh64x64 (Lsh64x64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Lsh64x64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpLsh64x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpLsh64x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Lsh64x64 i:(Rsh64x64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 64 && i.Uses == 1 + // result: (And64 x (Const64 [int64(-1) << c])) + for { + i := v_0 + if i.Op != OpRsh64x64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 64 && i.Uses == 1) { + break + } + v.reset(OpAnd64) + v0 := b.NewValue0(v.Pos, OpConst64, v.Type) + v0.AuxInt = int64ToAuxInt(int64(-1) << c) + v.AddArg2(x, v0) + return true + } + // match: (Lsh64x64 i:(Rsh64Ux64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 64 && i.Uses == 1 + // result: (And64 x (Const64 [int64(-1) << c])) + for { + i := v_0 + if i.Op != OpRsh64Ux64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 64 && i.Uses == 1) { + break + } + v.reset(OpAnd64) + v0 := b.NewValue0(v.Pos, OpConst64, v.Type) + v0.AuxInt = int64ToAuxInt(int64(-1) << c) + v.AddArg2(x, v0) + return true + } + // match: (Lsh64x64 (Rsh64Ux64 (Lsh64x64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) + // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) + // result: (Lsh64x64 x (Const64 [c1-c2+c3])) + for { + if v_0.Op != OpRsh64Ux64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLsh64x64 { + break + } + _ = v_0_0.Args[1] + x := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpConst64 { + break + } + c1 := auxIntToInt64(v_0_0_1.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c2 := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + c3 := auxIntToInt64(v_1.AuxInt) + if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { + break + } + v.reset(OpLsh64x64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) + v.AddArg2(x, v0) + return true + } + // match: (Lsh64x64 (And64 (Rsh64x64 x (Const64 [c])) (Const64 [d])) (Const64 [e])) + // cond: c >= e + // result: (And64 (Rsh64x64 x (Const64 [c-e])) (Const64 [d<= e) { + continue + } + v.reset(OpAnd64) + v0 := b.NewValue0(v.Pos, OpRsh64x64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t2) + v1.AuxInt = int64ToAuxInt(c - e) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(d << e) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (Lsh64x64 (And64 (Rsh64Ux64 x (Const64 [c])) (Const64 [d])) (Const64 [e])) + // cond: c >= e + // result: (And64 (Rsh64Ux64 x (Const64 [c-e])) (Const64 [d<= e) { + continue + } + v.reset(OpAnd64) + v0 := b.NewValue0(v.Pos, OpRsh64Ux64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t2) + v1.AuxInt = int64ToAuxInt(c - e) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(d << e) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (Lsh64x64 (And64 (Rsh64x64 x (Const64 [c])) (Const64 [d])) (Const64 [e])) + // cond: c < e + // result: (And64 (Lsh64x64 x (Const64 [e-c])) (Const64 [d< x (Const64 [c])) (Const64 [d])) (Const64 [e])) + // cond: c < e + // result: (And64 (Lsh64x64 x (Const64 [e-c])) (Const64 [d< x (Const8 [c])) + // result: (Lsh64x64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpLsh64x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh64x8 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Lsh64x8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 64 + // result: (Lsh64x8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpLsh64x8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x16 x (Const16 [c])) + // result: (Lsh8x64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpLsh8x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh8x16 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Lsh8x16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 8 + // result: (Lsh8x16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpLsh8x16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Lsh8x32 x (Const32 [c])) + // result: (Lsh8x64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpLsh8x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh8x32 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Lsh8x32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 8 + // result: (Lsh8x32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpLsh8x32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpLsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Lsh8x64 (Const8 [c]) (Const64 [d])) + // result: (Const8 [c << uint64(d)]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c << uint64(d)) + return true + } + // match: (Lsh8x64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Lsh8x64 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Lsh8x64 _ (Const64 [c])) + // cond: uint64(c) >= 8 + // result: (Const8 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 8) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Lsh8x64 (Lsh8x64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Lsh8x64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpLsh8x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpLsh8x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Lsh8x64 i:(Rsh8x64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 8 && i.Uses == 1 + // result: (And8 x (Const8 [int8(-1) << c])) + for { + i := v_0 + if i.Op != OpRsh8x64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 8 && i.Uses == 1) { + break + } + v.reset(OpAnd8) + v0 := b.NewValue0(v.Pos, OpConst8, v.Type) + v0.AuxInt = int8ToAuxInt(int8(-1) << c) + v.AddArg2(x, v0) + return true + } + // match: (Lsh8x64 i:(Rsh8Ux64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 8 && i.Uses == 1 + // result: (And8 x (Const8 [int8(-1) << c])) + for { + i := v_0 + if i.Op != OpRsh8Ux64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 8 && i.Uses == 1) { + break + } + v.reset(OpAnd8) + v0 := b.NewValue0(v.Pos, OpConst8, v.Type) + v0.AuxInt = int8ToAuxInt(int8(-1) << c) + v.AddArg2(x, v0) + return true + } + // match: (Lsh8x64 (Rsh8Ux64 (Lsh8x64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) + // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) + // result: (Lsh8x64 x (Const64 [c1-c2+c3])) + for { + if v_0.Op != OpRsh8Ux64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLsh8x64 { + break + } + _ = v_0_0.Args[1] + x := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpConst64 { + break + } + c1 := auxIntToInt64(v_0_0_1.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c2 := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + c3 := auxIntToInt64(v_1.AuxInt) + if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { + break + } + v.reset(OpLsh8x64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) + v.AddArg2(x, v0) + return true + } + // match: (Lsh8x64 (And8 (Rsh8x64 x (Const64 [c])) (Const8 [d])) (Const64 [e])) + // cond: c >= e + // result: (And8 (Rsh8x64 x (Const64 [c-e])) (Const8 [d<= e) { + continue + } + v.reset(OpAnd8) + v0 := b.NewValue0(v.Pos, OpRsh8x64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t2) + v1.AuxInt = int64ToAuxInt(c - e) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(d << e) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (Lsh8x64 (And8 (Rsh8Ux64 x (Const64 [c])) (Const8 [d])) (Const64 [e])) + // cond: c >= e + // result: (And8 (Rsh8Ux64 x (Const64 [c-e])) (Const8 [d<= e) { + continue + } + v.reset(OpAnd8) + v0 := b.NewValue0(v.Pos, OpRsh8Ux64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t2) + v1.AuxInt = int64ToAuxInt(c - e) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(d << e) + v.AddArg2(v0, v2) + return true + } + break + } + // match: (Lsh8x64 (And8 (Rsh8x64 x (Const64 [c])) (Const8 [d])) (Const64 [e])) + // cond: c < e + // result: (And8 (Lsh8x64 x (Const64 [e-c])) (Const8 [d< x (Const64 [c])) (Const8 [d])) (Const64 [e])) + // cond: c < e + // result: (And8 (Lsh8x64 x (Const64 [e-c])) (Const8 [d< x (Const8 [c])) + // result: (Lsh8x64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpLsh8x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Lsh8x8 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Lsh8x8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 8 + // result: (Lsh8x8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpLsh8x8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpMemEq(v *Value) bool { + v_3 := v.Args[3] + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (MemEq sptr tptr (Const64 [1]) mem) + // result: (Eq8 (Load sptr mem) (Load tptr mem)) + for { + sptr := v_0 + tptr := v_1 + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 1 { + break + } + mem := v_3 + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpLoad, typ.Int8) + v0.AddArg2(sptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int8) + v1.AddArg2(tptr, mem) + v.AddArg2(v0, v1) + return true + } + // match: (MemEq sptr tptr (Const64 [2]) mem) + // cond: canLoadUnaligned(config) + // result: (Eq16 (Load sptr mem) (Load tptr mem)) + for { + sptr := v_0 + tptr := v_1 + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 2 { + break + } + mem := v_3 + if !(canLoadUnaligned(config)) { + break + } + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpLoad, typ.Int16) + v0.AddArg2(sptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int16) + v1.AddArg2(tptr, mem) + v.AddArg2(v0, v1) + return true + } + // match: (MemEq sptr tptr (Const64 [4]) mem) + // cond: canLoadUnaligned(config) + // result: (Eq32 (Load sptr mem) (Load tptr mem)) + for { + sptr := v_0 + tptr := v_1 + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 4 { + break + } + mem := v_3 + if !(canLoadUnaligned(config)) { + break + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v0.AddArg2(sptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v1.AddArg2(tptr, mem) + v.AddArg2(v0, v1) + return true + } + // match: (MemEq sptr tptr (Const64 [8]) mem) + // cond: canLoadUnaligned(config) && config.PtrSize == 8 + // result: (Eq64 (Load sptr mem) (Load tptr mem)) + for { + sptr := v_0 + tptr := v_1 + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 8 { + break + } + mem := v_3 + if !(canLoadUnaligned(config) && config.PtrSize == 8) { + break + } + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpLoad, typ.Int64) + v0.AddArg2(sptr, mem) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int64) + v1.AddArg2(tptr, mem) + v.AddArg2(v0, v1) + return true + } + // match: (MemEq _ _ (Const64 [0]) _) + // result: (ConstBool [true]) + for { + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 0 { + break + } + v.reset(OpConstBool) + v.Type = typ.Bool + v.AuxInt = boolToAuxInt(true) + return true + } + // match: (MemEq p q _ _) + // cond: isSamePtr(p, q) + // result: (ConstBool [true]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + p := v_0 + q := v_1 + if !(isSamePtr(p, q)) { + continue + } + v.reset(OpConstBool) + v.Type = typ.Bool + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpMod16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Mod16 (Const16 [c]) (Const16 [d])) + // cond: d != 0 + // result: (Const16 [c % d]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + break + } + d := auxIntToInt16(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c % d) + return true + } + // match: (Mod16 n (Const16 [c])) + // cond: isNonNegative(n) && isPowerOfTwo(c) + // result: (And16 n (Const16 [c-1])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(isNonNegative(n) && isPowerOfTwo(c)) { + break + } + v.reset(OpAnd16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c - 1) + v.AddArg2(n, v0) + return true + } + // match: (Mod16 n (Const16 [c])) + // cond: c < 0 && c != -1<<15 + // result: (Mod16 n (Const16 [-c])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(c < 0 && c != -1<<15) { + break + } + v.reset(OpMod16) + v.Type = t + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(-c) + v.AddArg2(n, v0) + return true + } + // match: (Mod16 x (Const16 [c])) + // cond: x.Op != OpConst16 && (c > 0 || c == -1<<15) + // result: (Sub16 x (Mul16 (Div16 x (Const16 [c])) (Const16 [c]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(x.Op != OpConst16 && (c > 0 || c == -1<<15)) { + break + } + v.reset(OpSub16) + v0 := b.NewValue0(v.Pos, OpMul16, t) + v1 := b.NewValue0(v.Pos, OpDiv16, t) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(c) + v1.AddArg2(x, v2) + v0.AddArg2(v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpMod16u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Mod16u (Const16 [c]) (Const16 [d])) + // cond: d != 0 + // result: (Const16 [int16(uint16(c) % uint16(d))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + break + } + d := auxIntToInt16(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(int16(uint16(c) % uint16(d))) + return true + } + // match: (Mod16u n (Const16 [c])) + // cond: isUnsignedPowerOfTwo(uint16(c)) + // result: (And16 n (Const16 [c-1])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(isUnsignedPowerOfTwo(uint16(c))) { + break + } + v.reset(OpAnd16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c - 1) + v.AddArg2(n, v0) + return true + } + // match: (Mod16u x (Const16 [c])) + // cond: x.Op != OpConst16 && c != 0 + // result: (Sub16 x (Mul16 (Div16u x (Const16 [c])) (Const16 [c]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(x.Op != OpConst16 && c != 0) { + break + } + v.reset(OpSub16) + v0 := b.NewValue0(v.Pos, OpMul16, t) + v1 := b.NewValue0(v.Pos, OpDiv16u, t) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(c) + v1.AddArg2(x, v2) + v0.AddArg2(v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpMod32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Mod32 (Const32 [c]) (Const32 [d])) + // cond: d != 0 + // result: (Const32 [c % d]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + break + } + d := auxIntToInt32(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c % d) + return true + } + // match: (Mod32 n (Const32 [c])) + // cond: isNonNegative(n) && isPowerOfTwo(c) + // result: (And32 n (Const32 [c-1])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(isNonNegative(n) && isPowerOfTwo(c)) { + break + } + v.reset(OpAnd32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c - 1) + v.AddArg2(n, v0) + return true + } + // match: (Mod32 n (Const32 [c])) + // cond: c < 0 && c != -1<<31 + // result: (Mod32 n (Const32 [-c])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c < 0 && c != -1<<31) { + break + } + v.reset(OpMod32) + v.Type = t + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(-c) + v.AddArg2(n, v0) + return true + } + // match: (Mod32 x (Const32 [c])) + // cond: x.Op != OpConst32 && (c > 0 || c == -1<<31) + // result: (Sub32 x (Mul32 (Div32 x (Const32 [c])) (Const32 [c]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(x.Op != OpConst32 && (c > 0 || c == -1<<31)) { + break + } + v.reset(OpSub32) + v0 := b.NewValue0(v.Pos, OpMul32, t) + v1 := b.NewValue0(v.Pos, OpDiv32, t) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(c) + v1.AddArg2(x, v2) + v0.AddArg2(v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpMod32u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Mod32u (Const32 [c]) (Const32 [d])) + // cond: d != 0 + // result: (Const32 [int32(uint32(c) % uint32(d))]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + break + } + d := auxIntToInt32(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(uint32(c) % uint32(d))) + return true + } + // match: (Mod32u n (Const32 [c])) + // cond: isUnsignedPowerOfTwo(uint32(c)) + // result: (And32 n (Const32 [c-1])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(isUnsignedPowerOfTwo(uint32(c))) { + break + } + v.reset(OpAnd32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c - 1) + v.AddArg2(n, v0) + return true + } + // match: (Mod32u x (Const32 [c])) + // cond: x.Op != OpConst32 && c != 0 + // result: (Sub32 x (Mul32 (Div32u x (Const32 [c])) (Const32 [c]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(x.Op != OpConst32 && c != 0) { + break + } + v.reset(OpSub32) + v0 := b.NewValue0(v.Pos, OpMul32, t) + v1 := b.NewValue0(v.Pos, OpDiv32u, t) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(c) + v1.AddArg2(x, v2) + v0.AddArg2(v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpMod64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Mod64 (Const64 [c]) (Const64 [d])) + // cond: d != 0 + // result: (Const64 [c % d]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c % d) + return true + } + // match: (Mod64 n (Const64 [c])) + // cond: isNonNegative(n) && isPowerOfTwo(c) + // result: (And64 n (Const64 [c-1])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isNonNegative(n) && isPowerOfTwo(c)) { + break + } + v.reset(OpAnd64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c - 1) + v.AddArg2(n, v0) + return true + } + // match: (Mod64 n (Const64 [-1<<63])) + // cond: isNonNegative(n) + // result: n + for { + n := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != -1<<63 || !(isNonNegative(n)) { + break + } + v.copyOf(n) + return true + } + // match: (Mod64 n (Const64 [c])) + // cond: c < 0 && c != -1<<63 + // result: (Mod64 n (Const64 [-c])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c < 0 && c != -1<<63) { + break + } + v.reset(OpMod64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(-c) + v.AddArg2(n, v0) + return true + } + // match: (Mod64 x (Const64 [c])) + // cond: x.Op != OpConst64 && (c > 0 || c == -1<<63) + // result: (Sub64 x (Mul64 (Div64 x (Const64 [c])) (Const64 [c]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(x.Op != OpConst64 && (c > 0 || c == -1<<63)) { + break + } + v.reset(OpSub64) + v0 := b.NewValue0(v.Pos, OpMul64, t) + v1 := b.NewValue0(v.Pos, OpDiv64, t) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(c) + v1.AddArg2(x, v2) + v0.AddArg2(v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpMod64u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Mod64u (Const64 [c]) (Const64 [d])) + // cond: d != 0 + // result: (Const64 [int64(uint64(c) % uint64(d))]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(uint64(c) % uint64(d))) + return true + } + // match: (Mod64u n (Const64 [c])) + // cond: isUnsignedPowerOfTwo(uint64(c)) + // result: (And64 n (Const64 [c-1])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(isUnsignedPowerOfTwo(uint64(c))) { + break + } + v.reset(OpAnd64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c - 1) + v.AddArg2(n, v0) + return true + } + // match: (Mod64u x (Const64 [c])) + // cond: x.Op != OpConst64 && c != 0 + // result: (Sub64 x (Mul64 (Div64u x (Const64 [c])) (Const64 [c]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(x.Op != OpConst64 && c != 0) { + break + } + v.reset(OpSub64) + v0 := b.NewValue0(v.Pos, OpMul64, t) + v1 := b.NewValue0(v.Pos, OpDiv64u, t) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(c) + v1.AddArg2(x, v2) + v0.AddArg2(v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpMod8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Mod8 (Const8 [c]) (Const8 [d])) + // cond: d != 0 + // result: (Const8 [c % d]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + break + } + d := auxIntToInt8(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c % d) + return true + } + // match: (Mod8 n (Const8 [c])) + // cond: isNonNegative(n) && isPowerOfTwo(c) + // result: (And8 n (Const8 [c-1])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(isNonNegative(n) && isPowerOfTwo(c)) { + break + } + v.reset(OpAnd8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c - 1) + v.AddArg2(n, v0) + return true + } + // match: (Mod8 n (Const8 [c])) + // cond: c < 0 && c != -1<<7 + // result: (Mod8 n (Const8 [-c])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(c < 0 && c != -1<<7) { + break + } + v.reset(OpMod8) + v.Type = t + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(-c) + v.AddArg2(n, v0) + return true + } + // match: (Mod8 x (Const8 [c])) + // cond: x.Op != OpConst8 && (c > 0 || c == -1<<7) + // result: (Sub8 x (Mul8 (Div8 x (Const8 [c])) (Const8 [c]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(x.Op != OpConst8 && (c > 0 || c == -1<<7)) { + break + } + v.reset(OpSub8) + v0 := b.NewValue0(v.Pos, OpMul8, t) + v1 := b.NewValue0(v.Pos, OpDiv8, t) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(c) + v1.AddArg2(x, v2) + v0.AddArg2(v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpMod8u(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Mod8u (Const8 [c]) (Const8 [d])) + // cond: d != 0 + // result: (Const8 [int8(uint8(c) % uint8(d))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + break + } + d := auxIntToInt8(v_1.AuxInt) + if !(d != 0) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(int8(uint8(c) % uint8(d))) + return true + } + // match: (Mod8u n (Const8 [c])) + // cond: isUnsignedPowerOfTwo(uint8(c)) + // result: (And8 n (Const8 [c-1])) + for { + t := v.Type + n := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(isUnsignedPowerOfTwo(uint8(c))) { + break + } + v.reset(OpAnd8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c - 1) + v.AddArg2(n, v0) + return true + } + // match: (Mod8u x (Const8 [c])) + // cond: x.Op != OpConst8 && c != 0 + // result: (Sub8 x (Mul8 (Div8u x (Const8 [c])) (Const8 [c]))) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(x.Op != OpConst8 && c != 0) { + break + } + v.reset(OpSub8) + v0 := b.NewValue0(v.Pos, OpMul8, t) + v1 := b.NewValue0(v.Pos, OpDiv8u, t) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(c) + v1.AddArg2(x, v2) + v0.AddArg2(v1, v2) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpMove(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Move {t} [n] dst1 src mem:(Zero {t} [n] dst2 _)) + // cond: isSamePtr(src, dst2) + // result: (Zero {t} [n] dst1 mem) + for { + n := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst1 := v_0 + src := v_1 + mem := v_2 + if mem.Op != OpZero || auxIntToInt64(mem.AuxInt) != n || auxToType(mem.Aux) != t { + break + } + dst2 := mem.Args[0] + if !(isSamePtr(src, dst2)) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t) + v.AddArg2(dst1, mem) + return true + } + // match: (Move {t} [n] dst1 src mem:(VarDef (Zero {t} [n] dst0 _))) + // cond: isSamePtr(src, dst0) + // result: (Zero {t} [n] dst1 mem) + for { + n := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst1 := v_0 + src := v_1 + mem := v_2 + if mem.Op != OpVarDef { + break + } + mem_0 := mem.Args[0] + if mem_0.Op != OpZero || auxIntToInt64(mem_0.AuxInt) != n || auxToType(mem_0.Aux) != t { + break + } + dst0 := mem_0.Args[0] + if !(isSamePtr(src, dst0)) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t) + v.AddArg2(dst1, mem) + return true + } + // match: (Move {t} [n] dst (Addr {sym} (SB)) mem) + // cond: symIsROZero(sym) + // result: (Zero {t} [n] dst mem) + for { + n := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst := v_0 + if v_1.Op != OpAddr { + break + } + sym := auxToSym(v_1.Aux) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpSB { + break + } + mem := v_2 + if !(symIsROZero(sym)) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t) + v.AddArg2(dst, mem) + return true + } + // match: (Move {t1} [n] dst1 src1 store:(Store {t2} op:(OffPtr [o2] dst2) _ mem)) + // cond: isSamePtr(dst1, dst2) && store.Uses == 1 && n >= o2 + t2.Size() && disjoint(src1, n, op, t2.Size()) && clobber(store) + // result: (Move {t1} [n] dst1 src1 mem) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst1 := v_0 + src1 := v_1 + store := v_2 + if store.Op != OpStore { + break + } + t2 := auxToType(store.Aux) + mem := store.Args[2] + op := store.Args[0] + if op.Op != OpOffPtr { + break + } + o2 := auxIntToInt64(op.AuxInt) + dst2 := op.Args[0] + if !(isSamePtr(dst1, dst2) && store.Uses == 1 && n >= o2+t2.Size() && disjoint(src1, n, op, t2.Size()) && clobber(store)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t1) + v.AddArg3(dst1, src1, mem) + return true + } + // match: (Move {t} [n] dst1 src1 move:(Move {t} [n] dst2 _ mem)) + // cond: move.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(move) + // result: (Move {t} [n] dst1 src1 mem) + for { + n := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst1 := v_0 + src1 := v_1 + move := v_2 + if move.Op != OpMove || auxIntToInt64(move.AuxInt) != n || auxToType(move.Aux) != t { + break + } + mem := move.Args[2] + dst2 := move.Args[0] + if !(move.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(move)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t) + v.AddArg3(dst1, src1, mem) + return true + } + // match: (Move {t} [n] dst1 src1 vardef:(VarDef {x} move:(Move {t} [n] dst2 _ mem))) + // cond: move.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(move, vardef) + // result: (Move {t} [n] dst1 src1 (VarDef {x} mem)) + for { + n := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst1 := v_0 + src1 := v_1 + vardef := v_2 + if vardef.Op != OpVarDef { + break + } + x := auxToSym(vardef.Aux) + move := vardef.Args[0] + if move.Op != OpMove || auxIntToInt64(move.AuxInt) != n || auxToType(move.Aux) != t { + break + } + mem := move.Args[2] + dst2 := move.Args[0] + if !(move.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(move, vardef)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t) + v0 := b.NewValue0(v.Pos, OpVarDef, types.TypeMem) + v0.Aux = symToAux(x) + v0.AddArg(mem) + v.AddArg3(dst1, src1, v0) + return true + } + // match: (Move {t} [n] dst1 src1 zero:(Zero {t} [n] dst2 mem)) + // cond: zero.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(zero) + // result: (Move {t} [n] dst1 src1 mem) + for { + n := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst1 := v_0 + src1 := v_1 + zero := v_2 + if zero.Op != OpZero || auxIntToInt64(zero.AuxInt) != n || auxToType(zero.Aux) != t { + break + } + mem := zero.Args[1] + dst2 := zero.Args[0] + if !(zero.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(zero)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t) + v.AddArg3(dst1, src1, mem) + return true + } + // match: (Move {t} [n] dst1 src1 vardef:(VarDef {x} zero:(Zero {t} [n] dst2 mem))) + // cond: zero.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(zero, vardef) + // result: (Move {t} [n] dst1 src1 (VarDef {x} mem)) + for { + n := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst1 := v_0 + src1 := v_1 + vardef := v_2 + if vardef.Op != OpVarDef { + break + } + x := auxToSym(vardef.Aux) + zero := vardef.Args[0] + if zero.Op != OpZero || auxIntToInt64(zero.AuxInt) != n || auxToType(zero.Aux) != t { + break + } + mem := zero.Args[1] + dst2 := zero.Args[0] + if !(zero.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(zero, vardef)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t) + v0 := b.NewValue0(v.Pos, OpVarDef, types.TypeMem) + v0.Aux = symToAux(x) + v0.AddArg(mem) + v.AddArg3(dst1, src1, v0) + return true + } + // match: (Move {t1} [n] dst p1 mem:(Store {t2} op2:(OffPtr [o2] p2) d1 (Store {t3} op3:(OffPtr [0] p3) d2 _))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && o2 == t3.Size() && n == t2.Size() + t3.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [0] dst) d2 mem)) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpStore { + break + } + t2 := auxToType(mem.Aux) + _ = mem.Args[2] + op2 := mem.Args[0] + if op2.Op != OpOffPtr { + break + } + tt2 := op2.Type + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d1 := mem.Args[1] + mem_2 := mem.Args[2] + if mem_2.Op != OpStore { + break + } + t3 := auxToType(mem_2.Aux) + d2 := mem_2.Args[1] + op3 := mem_2.Args[0] + if op3.Op != OpOffPtr { + break + } + tt3 := op3.Type + if auxIntToInt64(op3.AuxInt) != 0 { + break + } + p3 := op3.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && o2 == t3.Size() && n == t2.Size()+t3.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(0) + v2.AddArg(dst) + v1.AddArg3(v2, d2, mem) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(Store {t2} op2:(OffPtr [o2] p2) d1 (Store {t3} op3:(OffPtr [o3] p3) d2 (Store {t4} op4:(OffPtr [0] p4) d3 _)))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && o3 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size() + t3.Size() + t4.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [o3] dst) d2 (Store {t4} (OffPtr [0] dst) d3 mem))) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpStore { + break + } + t2 := auxToType(mem.Aux) + _ = mem.Args[2] + op2 := mem.Args[0] + if op2.Op != OpOffPtr { + break + } + tt2 := op2.Type + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d1 := mem.Args[1] + mem_2 := mem.Args[2] + if mem_2.Op != OpStore { + break + } + t3 := auxToType(mem_2.Aux) + _ = mem_2.Args[2] + op3 := mem_2.Args[0] + if op3.Op != OpOffPtr { + break + } + tt3 := op3.Type + o3 := auxIntToInt64(op3.AuxInt) + p3 := op3.Args[0] + d2 := mem_2.Args[1] + mem_2_2 := mem_2.Args[2] + if mem_2_2.Op != OpStore { + break + } + t4 := auxToType(mem_2_2.Aux) + d3 := mem_2_2.Args[1] + op4 := mem_2_2.Args[0] + if op4.Op != OpOffPtr { + break + } + tt4 := op4.Type + if auxIntToInt64(op4.AuxInt) != 0 { + break + } + p4 := op4.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && o3 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size()+t3.Size()+t4.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(o3) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v3.Aux = typeToAux(t4) + v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) + v4.AuxInt = int64ToAuxInt(0) + v4.AddArg(dst) + v3.AddArg3(v4, d3, mem) + v1.AddArg3(v2, d2, v3) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(Store {t2} op2:(OffPtr [o2] p2) d1 (Store {t3} op3:(OffPtr [o3] p3) d2 (Store {t4} op4:(OffPtr [o4] p4) d3 (Store {t5} op5:(OffPtr [0] p5) d4 _))))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && o4 == t5.Size() && o3-o4 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size() + t3.Size() + t4.Size() + t5.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [o3] dst) d2 (Store {t4} (OffPtr [o4] dst) d3 (Store {t5} (OffPtr [0] dst) d4 mem)))) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpStore { + break + } + t2 := auxToType(mem.Aux) + _ = mem.Args[2] + op2 := mem.Args[0] + if op2.Op != OpOffPtr { + break + } + tt2 := op2.Type + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d1 := mem.Args[1] + mem_2 := mem.Args[2] + if mem_2.Op != OpStore { + break + } + t3 := auxToType(mem_2.Aux) + _ = mem_2.Args[2] + op3 := mem_2.Args[0] + if op3.Op != OpOffPtr { + break + } + tt3 := op3.Type + o3 := auxIntToInt64(op3.AuxInt) + p3 := op3.Args[0] + d2 := mem_2.Args[1] + mem_2_2 := mem_2.Args[2] + if mem_2_2.Op != OpStore { + break + } + t4 := auxToType(mem_2_2.Aux) + _ = mem_2_2.Args[2] + op4 := mem_2_2.Args[0] + if op4.Op != OpOffPtr { + break + } + tt4 := op4.Type + o4 := auxIntToInt64(op4.AuxInt) + p4 := op4.Args[0] + d3 := mem_2_2.Args[1] + mem_2_2_2 := mem_2_2.Args[2] + if mem_2_2_2.Op != OpStore { + break + } + t5 := auxToType(mem_2_2_2.Aux) + d4 := mem_2_2_2.Args[1] + op5 := mem_2_2_2.Args[0] + if op5.Op != OpOffPtr { + break + } + tt5 := op5.Type + if auxIntToInt64(op5.AuxInt) != 0 { + break + } + p5 := op5.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && o4 == t5.Size() && o3-o4 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size()+t3.Size()+t4.Size()+t5.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(o3) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v3.Aux = typeToAux(t4) + v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) + v4.AuxInt = int64ToAuxInt(o4) + v4.AddArg(dst) + v5 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v5.Aux = typeToAux(t5) + v6 := b.NewValue0(v.Pos, OpOffPtr, tt5) + v6.AuxInt = int64ToAuxInt(0) + v6.AddArg(dst) + v5.AddArg3(v6, d4, mem) + v3.AddArg3(v4, d3, v5) + v1.AddArg3(v2, d2, v3) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} op2:(OffPtr [o2] p2) d1 (Store {t3} op3:(OffPtr [0] p3) d2 _)))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && o2 == t3.Size() && n == t2.Size() + t3.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [0] dst) d2 mem)) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpVarDef { + break + } + mem_0 := mem.Args[0] + if mem_0.Op != OpStore { + break + } + t2 := auxToType(mem_0.Aux) + _ = mem_0.Args[2] + op2 := mem_0.Args[0] + if op2.Op != OpOffPtr { + break + } + tt2 := op2.Type + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d1 := mem_0.Args[1] + mem_0_2 := mem_0.Args[2] + if mem_0_2.Op != OpStore { + break + } + t3 := auxToType(mem_0_2.Aux) + d2 := mem_0_2.Args[1] + op3 := mem_0_2.Args[0] + if op3.Op != OpOffPtr { + break + } + tt3 := op3.Type + if auxIntToInt64(op3.AuxInt) != 0 { + break + } + p3 := op3.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && o2 == t3.Size() && n == t2.Size()+t3.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(0) + v2.AddArg(dst) + v1.AddArg3(v2, d2, mem) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} op2:(OffPtr [o2] p2) d1 (Store {t3} op3:(OffPtr [o3] p3) d2 (Store {t4} op4:(OffPtr [0] p4) d3 _))))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && o3 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size() + t3.Size() + t4.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [o3] dst) d2 (Store {t4} (OffPtr [0] dst) d3 mem))) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpVarDef { + break + } + mem_0 := mem.Args[0] + if mem_0.Op != OpStore { + break + } + t2 := auxToType(mem_0.Aux) + _ = mem_0.Args[2] + op2 := mem_0.Args[0] + if op2.Op != OpOffPtr { + break + } + tt2 := op2.Type + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d1 := mem_0.Args[1] + mem_0_2 := mem_0.Args[2] + if mem_0_2.Op != OpStore { + break + } + t3 := auxToType(mem_0_2.Aux) + _ = mem_0_2.Args[2] + op3 := mem_0_2.Args[0] + if op3.Op != OpOffPtr { + break + } + tt3 := op3.Type + o3 := auxIntToInt64(op3.AuxInt) + p3 := op3.Args[0] + d2 := mem_0_2.Args[1] + mem_0_2_2 := mem_0_2.Args[2] + if mem_0_2_2.Op != OpStore { + break + } + t4 := auxToType(mem_0_2_2.Aux) + d3 := mem_0_2_2.Args[1] + op4 := mem_0_2_2.Args[0] + if op4.Op != OpOffPtr { + break + } + tt4 := op4.Type + if auxIntToInt64(op4.AuxInt) != 0 { + break + } + p4 := op4.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && o3 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size()+t3.Size()+t4.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(o3) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v3.Aux = typeToAux(t4) + v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) + v4.AuxInt = int64ToAuxInt(0) + v4.AddArg(dst) + v3.AddArg3(v4, d3, mem) + v1.AddArg3(v2, d2, v3) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} op2:(OffPtr [o2] p2) d1 (Store {t3} op3:(OffPtr [o3] p3) d2 (Store {t4} op4:(OffPtr [o4] p4) d3 (Store {t5} op5:(OffPtr [0] p5) d4 _)))))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && o4 == t5.Size() && o3-o4 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size() + t3.Size() + t4.Size() + t5.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [o3] dst) d2 (Store {t4} (OffPtr [o4] dst) d3 (Store {t5} (OffPtr [0] dst) d4 mem)))) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpVarDef { + break + } + mem_0 := mem.Args[0] + if mem_0.Op != OpStore { + break + } + t2 := auxToType(mem_0.Aux) + _ = mem_0.Args[2] + op2 := mem_0.Args[0] + if op2.Op != OpOffPtr { + break + } + tt2 := op2.Type + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d1 := mem_0.Args[1] + mem_0_2 := mem_0.Args[2] + if mem_0_2.Op != OpStore { + break + } + t3 := auxToType(mem_0_2.Aux) + _ = mem_0_2.Args[2] + op3 := mem_0_2.Args[0] + if op3.Op != OpOffPtr { + break + } + tt3 := op3.Type + o3 := auxIntToInt64(op3.AuxInt) + p3 := op3.Args[0] + d2 := mem_0_2.Args[1] + mem_0_2_2 := mem_0_2.Args[2] + if mem_0_2_2.Op != OpStore { + break + } + t4 := auxToType(mem_0_2_2.Aux) + _ = mem_0_2_2.Args[2] + op4 := mem_0_2_2.Args[0] + if op4.Op != OpOffPtr { + break + } + tt4 := op4.Type + o4 := auxIntToInt64(op4.AuxInt) + p4 := op4.Args[0] + d3 := mem_0_2_2.Args[1] + mem_0_2_2_2 := mem_0_2_2.Args[2] + if mem_0_2_2_2.Op != OpStore { + break + } + t5 := auxToType(mem_0_2_2_2.Aux) + d4 := mem_0_2_2_2.Args[1] + op5 := mem_0_2_2_2.Args[0] + if op5.Op != OpOffPtr { + break + } + tt5 := op5.Type + if auxIntToInt64(op5.AuxInt) != 0 { + break + } + p5 := op5.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && o4 == t5.Size() && o3-o4 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size()+t3.Size()+t4.Size()+t5.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(o3) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v3.Aux = typeToAux(t4) + v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) + v4.AuxInt = int64ToAuxInt(o4) + v4.AddArg(dst) + v5 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v5.Aux = typeToAux(t5) + v6 := b.NewValue0(v.Pos, OpOffPtr, tt5) + v6.AuxInt = int64ToAuxInt(0) + v6.AddArg(dst) + v5.AddArg3(v6, d4, mem) + v3.AddArg3(v4, d3, v5) + v1.AddArg3(v2, d2, v3) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(Store {t2} op2:(OffPtr [o2] p2) d1 (Zero {t3} [n] p3 _))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && n >= o2 + t2.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Zero {t1} [n] dst mem)) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpStore { + break + } + t2 := auxToType(mem.Aux) + _ = mem.Args[2] + op2 := mem.Args[0] + if op2.Op != OpOffPtr { + break + } + tt2 := op2.Type + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d1 := mem.Args[1] + mem_2 := mem.Args[2] + if mem_2.Op != OpZero || auxIntToInt64(mem_2.AuxInt) != n { + break + } + t3 := auxToType(mem_2.Aux) + p3 := mem_2.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && n >= o2+t2.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpZero, types.TypeMem) + v1.AuxInt = int64ToAuxInt(n) + v1.Aux = typeToAux(t1) + v1.AddArg2(dst, mem) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(Store {t2} (OffPtr [o2] p2) d1 (Store {t3} (OffPtr [o3] p3) d2 (Zero {t4} [n] p4 _)))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && n >= o2 + t2.Size() && n >= o3 + t3.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [o3] dst) d2 (Zero {t1} [n] dst mem))) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpStore { + break + } + t2 := auxToType(mem.Aux) + _ = mem.Args[2] + mem_0 := mem.Args[0] + if mem_0.Op != OpOffPtr { + break + } + tt2 := mem_0.Type + o2 := auxIntToInt64(mem_0.AuxInt) + p2 := mem_0.Args[0] + d1 := mem.Args[1] + mem_2 := mem.Args[2] + if mem_2.Op != OpStore { + break + } + t3 := auxToType(mem_2.Aux) + _ = mem_2.Args[2] + mem_2_0 := mem_2.Args[0] + if mem_2_0.Op != OpOffPtr { + break + } + tt3 := mem_2_0.Type + o3 := auxIntToInt64(mem_2_0.AuxInt) + p3 := mem_2_0.Args[0] + d2 := mem_2.Args[1] + mem_2_2 := mem_2.Args[2] + if mem_2_2.Op != OpZero || auxIntToInt64(mem_2_2.AuxInt) != n { + break + } + t4 := auxToType(mem_2_2.Aux) + p4 := mem_2_2.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && n >= o2+t2.Size() && n >= o3+t3.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(o3) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpZero, types.TypeMem) + v3.AuxInt = int64ToAuxInt(n) + v3.Aux = typeToAux(t1) + v3.AddArg2(dst, mem) + v1.AddArg3(v2, d2, v3) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(Store {t2} (OffPtr [o2] p2) d1 (Store {t3} (OffPtr [o3] p3) d2 (Store {t4} (OffPtr [o4] p4) d3 (Zero {t5} [n] p5 _))))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && n >= o2 + t2.Size() && n >= o3 + t3.Size() && n >= o4 + t4.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [o3] dst) d2 (Store {t4} (OffPtr [o4] dst) d3 (Zero {t1} [n] dst mem)))) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpStore { + break + } + t2 := auxToType(mem.Aux) + _ = mem.Args[2] + mem_0 := mem.Args[0] + if mem_0.Op != OpOffPtr { + break + } + tt2 := mem_0.Type + o2 := auxIntToInt64(mem_0.AuxInt) + p2 := mem_0.Args[0] + d1 := mem.Args[1] + mem_2 := mem.Args[2] + if mem_2.Op != OpStore { + break + } + t3 := auxToType(mem_2.Aux) + _ = mem_2.Args[2] + mem_2_0 := mem_2.Args[0] + if mem_2_0.Op != OpOffPtr { + break + } + tt3 := mem_2_0.Type + o3 := auxIntToInt64(mem_2_0.AuxInt) + p3 := mem_2_0.Args[0] + d2 := mem_2.Args[1] + mem_2_2 := mem_2.Args[2] + if mem_2_2.Op != OpStore { + break + } + t4 := auxToType(mem_2_2.Aux) + _ = mem_2_2.Args[2] + mem_2_2_0 := mem_2_2.Args[0] + if mem_2_2_0.Op != OpOffPtr { + break + } + tt4 := mem_2_2_0.Type + o4 := auxIntToInt64(mem_2_2_0.AuxInt) + p4 := mem_2_2_0.Args[0] + d3 := mem_2_2.Args[1] + mem_2_2_2 := mem_2_2.Args[2] + if mem_2_2_2.Op != OpZero || auxIntToInt64(mem_2_2_2.AuxInt) != n { + break + } + t5 := auxToType(mem_2_2_2.Aux) + p5 := mem_2_2_2.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && n >= o2+t2.Size() && n >= o3+t3.Size() && n >= o4+t4.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(o3) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v3.Aux = typeToAux(t4) + v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) + v4.AuxInt = int64ToAuxInt(o4) + v4.AddArg(dst) + v5 := b.NewValue0(v.Pos, OpZero, types.TypeMem) + v5.AuxInt = int64ToAuxInt(n) + v5.Aux = typeToAux(t1) + v5.AddArg2(dst, mem) + v3.AddArg3(v4, d3, v5) + v1.AddArg3(v2, d2, v3) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(Store {t2} (OffPtr [o2] p2) d1 (Store {t3} (OffPtr [o3] p3) d2 (Store {t4} (OffPtr [o4] p4) d3 (Store {t5} (OffPtr [o5] p5) d4 (Zero {t6} [n] p6 _)))))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && isSamePtr(p5, p6) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && t6.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && n >= o2 + t2.Size() && n >= o3 + t3.Size() && n >= o4 + t4.Size() && n >= o5 + t5.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [o3] dst) d2 (Store {t4} (OffPtr [o4] dst) d3 (Store {t5} (OffPtr [o5] dst) d4 (Zero {t1} [n] dst mem))))) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpStore { + break + } + t2 := auxToType(mem.Aux) + _ = mem.Args[2] + mem_0 := mem.Args[0] + if mem_0.Op != OpOffPtr { + break + } + tt2 := mem_0.Type + o2 := auxIntToInt64(mem_0.AuxInt) + p2 := mem_0.Args[0] + d1 := mem.Args[1] + mem_2 := mem.Args[2] + if mem_2.Op != OpStore { + break + } + t3 := auxToType(mem_2.Aux) + _ = mem_2.Args[2] + mem_2_0 := mem_2.Args[0] + if mem_2_0.Op != OpOffPtr { + break + } + tt3 := mem_2_0.Type + o3 := auxIntToInt64(mem_2_0.AuxInt) + p3 := mem_2_0.Args[0] + d2 := mem_2.Args[1] + mem_2_2 := mem_2.Args[2] + if mem_2_2.Op != OpStore { + break + } + t4 := auxToType(mem_2_2.Aux) + _ = mem_2_2.Args[2] + mem_2_2_0 := mem_2_2.Args[0] + if mem_2_2_0.Op != OpOffPtr { + break + } + tt4 := mem_2_2_0.Type + o4 := auxIntToInt64(mem_2_2_0.AuxInt) + p4 := mem_2_2_0.Args[0] + d3 := mem_2_2.Args[1] + mem_2_2_2 := mem_2_2.Args[2] + if mem_2_2_2.Op != OpStore { + break + } + t5 := auxToType(mem_2_2_2.Aux) + _ = mem_2_2_2.Args[2] + mem_2_2_2_0 := mem_2_2_2.Args[0] + if mem_2_2_2_0.Op != OpOffPtr { + break + } + tt5 := mem_2_2_2_0.Type + o5 := auxIntToInt64(mem_2_2_2_0.AuxInt) + p5 := mem_2_2_2_0.Args[0] + d4 := mem_2_2_2.Args[1] + mem_2_2_2_2 := mem_2_2_2.Args[2] + if mem_2_2_2_2.Op != OpZero || auxIntToInt64(mem_2_2_2_2.AuxInt) != n { + break + } + t6 := auxToType(mem_2_2_2_2.Aux) + p6 := mem_2_2_2_2.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && isSamePtr(p5, p6) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && t6.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && n >= o2+t2.Size() && n >= o3+t3.Size() && n >= o4+t4.Size() && n >= o5+t5.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(o3) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v3.Aux = typeToAux(t4) + v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) + v4.AuxInt = int64ToAuxInt(o4) + v4.AddArg(dst) + v5 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v5.Aux = typeToAux(t5) + v6 := b.NewValue0(v.Pos, OpOffPtr, tt5) + v6.AuxInt = int64ToAuxInt(o5) + v6.AddArg(dst) + v7 := b.NewValue0(v.Pos, OpZero, types.TypeMem) + v7.AuxInt = int64ToAuxInt(n) + v7.Aux = typeToAux(t1) + v7.AddArg2(dst, mem) + v5.AddArg3(v6, d4, v7) + v3.AddArg3(v4, d3, v5) + v1.AddArg3(v2, d2, v3) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} op2:(OffPtr [o2] p2) d1 (Zero {t3} [n] p3 _)))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && n >= o2 + t2.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Zero {t1} [n] dst mem)) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpVarDef { + break + } + mem_0 := mem.Args[0] + if mem_0.Op != OpStore { + break + } + t2 := auxToType(mem_0.Aux) + _ = mem_0.Args[2] + op2 := mem_0.Args[0] + if op2.Op != OpOffPtr { + break + } + tt2 := op2.Type + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d1 := mem_0.Args[1] + mem_0_2 := mem_0.Args[2] + if mem_0_2.Op != OpZero || auxIntToInt64(mem_0_2.AuxInt) != n { + break + } + t3 := auxToType(mem_0_2.Aux) + p3 := mem_0_2.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && n >= o2+t2.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpZero, types.TypeMem) + v1.AuxInt = int64ToAuxInt(n) + v1.Aux = typeToAux(t1) + v1.AddArg2(dst, mem) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} (OffPtr [o2] p2) d1 (Store {t3} (OffPtr [o3] p3) d2 (Zero {t4} [n] p4 _))))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && n >= o2 + t2.Size() && n >= o3 + t3.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [o3] dst) d2 (Zero {t1} [n] dst mem))) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpVarDef { + break + } + mem_0 := mem.Args[0] + if mem_0.Op != OpStore { + break + } + t2 := auxToType(mem_0.Aux) + _ = mem_0.Args[2] + mem_0_0 := mem_0.Args[0] + if mem_0_0.Op != OpOffPtr { + break + } + tt2 := mem_0_0.Type + o2 := auxIntToInt64(mem_0_0.AuxInt) + p2 := mem_0_0.Args[0] + d1 := mem_0.Args[1] + mem_0_2 := mem_0.Args[2] + if mem_0_2.Op != OpStore { + break + } + t3 := auxToType(mem_0_2.Aux) + _ = mem_0_2.Args[2] + mem_0_2_0 := mem_0_2.Args[0] + if mem_0_2_0.Op != OpOffPtr { + break + } + tt3 := mem_0_2_0.Type + o3 := auxIntToInt64(mem_0_2_0.AuxInt) + p3 := mem_0_2_0.Args[0] + d2 := mem_0_2.Args[1] + mem_0_2_2 := mem_0_2.Args[2] + if mem_0_2_2.Op != OpZero || auxIntToInt64(mem_0_2_2.AuxInt) != n { + break + } + t4 := auxToType(mem_0_2_2.Aux) + p4 := mem_0_2_2.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && n >= o2+t2.Size() && n >= o3+t3.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(o3) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpZero, types.TypeMem) + v3.AuxInt = int64ToAuxInt(n) + v3.Aux = typeToAux(t1) + v3.AddArg2(dst, mem) + v1.AddArg3(v2, d2, v3) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} (OffPtr [o2] p2) d1 (Store {t3} (OffPtr [o3] p3) d2 (Store {t4} (OffPtr [o4] p4) d3 (Zero {t5} [n] p5 _)))))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && n >= o2 + t2.Size() && n >= o3 + t3.Size() && n >= o4 + t4.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [o3] dst) d2 (Store {t4} (OffPtr [o4] dst) d3 (Zero {t1} [n] dst mem)))) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpVarDef { + break + } + mem_0 := mem.Args[0] + if mem_0.Op != OpStore { + break + } + t2 := auxToType(mem_0.Aux) + _ = mem_0.Args[2] + mem_0_0 := mem_0.Args[0] + if mem_0_0.Op != OpOffPtr { + break + } + tt2 := mem_0_0.Type + o2 := auxIntToInt64(mem_0_0.AuxInt) + p2 := mem_0_0.Args[0] + d1 := mem_0.Args[1] + mem_0_2 := mem_0.Args[2] + if mem_0_2.Op != OpStore { + break + } + t3 := auxToType(mem_0_2.Aux) + _ = mem_0_2.Args[2] + mem_0_2_0 := mem_0_2.Args[0] + if mem_0_2_0.Op != OpOffPtr { + break + } + tt3 := mem_0_2_0.Type + o3 := auxIntToInt64(mem_0_2_0.AuxInt) + p3 := mem_0_2_0.Args[0] + d2 := mem_0_2.Args[1] + mem_0_2_2 := mem_0_2.Args[2] + if mem_0_2_2.Op != OpStore { + break + } + t4 := auxToType(mem_0_2_2.Aux) + _ = mem_0_2_2.Args[2] + mem_0_2_2_0 := mem_0_2_2.Args[0] + if mem_0_2_2_0.Op != OpOffPtr { + break + } + tt4 := mem_0_2_2_0.Type + o4 := auxIntToInt64(mem_0_2_2_0.AuxInt) + p4 := mem_0_2_2_0.Args[0] + d3 := mem_0_2_2.Args[1] + mem_0_2_2_2 := mem_0_2_2.Args[2] + if mem_0_2_2_2.Op != OpZero || auxIntToInt64(mem_0_2_2_2.AuxInt) != n { + break + } + t5 := auxToType(mem_0_2_2_2.Aux) + p5 := mem_0_2_2_2.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && n >= o2+t2.Size() && n >= o3+t3.Size() && n >= o4+t4.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(o3) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v3.Aux = typeToAux(t4) + v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) + v4.AuxInt = int64ToAuxInt(o4) + v4.AddArg(dst) + v5 := b.NewValue0(v.Pos, OpZero, types.TypeMem) + v5.AuxInt = int64ToAuxInt(n) + v5.Aux = typeToAux(t1) + v5.AddArg2(dst, mem) + v3.AddArg3(v4, d3, v5) + v1.AddArg3(v2, d2, v3) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} (OffPtr [o2] p2) d1 (Store {t3} (OffPtr [o3] p3) d2 (Store {t4} (OffPtr [o4] p4) d3 (Store {t5} (OffPtr [o5] p5) d4 (Zero {t6} [n] p6 _))))))) + // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && isSamePtr(p5, p6) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && t6.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && n >= o2 + t2.Size() && n >= o3 + t3.Size() && n >= o4 + t4.Size() && n >= o5 + t5.Size() + // result: (Store {t2} (OffPtr [o2] dst) d1 (Store {t3} (OffPtr [o3] dst) d2 (Store {t4} (OffPtr [o4] dst) d3 (Store {t5} (OffPtr [o5] dst) d4 (Zero {t1} [n] dst mem))))) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + p1 := v_1 + mem := v_2 + if mem.Op != OpVarDef { + break + } + mem_0 := mem.Args[0] + if mem_0.Op != OpStore { + break + } + t2 := auxToType(mem_0.Aux) + _ = mem_0.Args[2] + mem_0_0 := mem_0.Args[0] + if mem_0_0.Op != OpOffPtr { + break + } + tt2 := mem_0_0.Type + o2 := auxIntToInt64(mem_0_0.AuxInt) + p2 := mem_0_0.Args[0] + d1 := mem_0.Args[1] + mem_0_2 := mem_0.Args[2] + if mem_0_2.Op != OpStore { + break + } + t3 := auxToType(mem_0_2.Aux) + _ = mem_0_2.Args[2] + mem_0_2_0 := mem_0_2.Args[0] + if mem_0_2_0.Op != OpOffPtr { + break + } + tt3 := mem_0_2_0.Type + o3 := auxIntToInt64(mem_0_2_0.AuxInt) + p3 := mem_0_2_0.Args[0] + d2 := mem_0_2.Args[1] + mem_0_2_2 := mem_0_2.Args[2] + if mem_0_2_2.Op != OpStore { + break + } + t4 := auxToType(mem_0_2_2.Aux) + _ = mem_0_2_2.Args[2] + mem_0_2_2_0 := mem_0_2_2.Args[0] + if mem_0_2_2_0.Op != OpOffPtr { + break + } + tt4 := mem_0_2_2_0.Type + o4 := auxIntToInt64(mem_0_2_2_0.AuxInt) + p4 := mem_0_2_2_0.Args[0] + d3 := mem_0_2_2.Args[1] + mem_0_2_2_2 := mem_0_2_2.Args[2] + if mem_0_2_2_2.Op != OpStore { + break + } + t5 := auxToType(mem_0_2_2_2.Aux) + _ = mem_0_2_2_2.Args[2] + mem_0_2_2_2_0 := mem_0_2_2_2.Args[0] + if mem_0_2_2_2_0.Op != OpOffPtr { + break + } + tt5 := mem_0_2_2_2_0.Type + o5 := auxIntToInt64(mem_0_2_2_2_0.AuxInt) + p5 := mem_0_2_2_2_0.Args[0] + d4 := mem_0_2_2_2.Args[1] + mem_0_2_2_2_2 := mem_0_2_2_2.Args[2] + if mem_0_2_2_2_2.Op != OpZero || auxIntToInt64(mem_0_2_2_2_2.AuxInt) != n { + break + } + t6 := auxToType(mem_0_2_2_2_2.Aux) + p6 := mem_0_2_2_2_2.Args[0] + if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && isSamePtr(p5, p6) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && t6.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && n >= o2+t2.Size() && n >= o3+t3.Size() && n >= o4+t4.Size() && n >= o5+t5.Size()) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t2) + v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) + v0.AuxInt = int64ToAuxInt(o2) + v0.AddArg(dst) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) + v2.AuxInt = int64ToAuxInt(o3) + v2.AddArg(dst) + v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v3.Aux = typeToAux(t4) + v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) + v4.AuxInt = int64ToAuxInt(o4) + v4.AddArg(dst) + v5 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v5.Aux = typeToAux(t5) + v6 := b.NewValue0(v.Pos, OpOffPtr, tt5) + v6.AuxInt = int64ToAuxInt(o5) + v6.AddArg(dst) + v7 := b.NewValue0(v.Pos, OpZero, types.TypeMem) + v7.AuxInt = int64ToAuxInt(n) + v7.Aux = typeToAux(t1) + v7.AddArg2(dst, mem) + v5.AddArg3(v6, d4, v7) + v3.AddArg3(v4, d3, v5) + v1.AddArg3(v2, d2, v3) + v.AddArg3(v0, d1, v1) + return true + } + // match: (Move {t1} [s] dst tmp1 midmem:(Move {t2} [s] tmp2 src _)) + // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config)) + // result: (Move {t1} [s] dst src midmem) + for { + s := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + tmp1 := v_1 + midmem := v_2 + if midmem.Op != OpMove || auxIntToInt64(midmem.AuxInt) != s { + break + } + t2 := auxToType(midmem.Aux) + src := midmem.Args[1] + tmp2 := midmem.Args[0] + if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(s) + v.Aux = typeToAux(t1) + v.AddArg3(dst, src, midmem) + return true + } + // match: (Move {t1} [s] dst tmp1 midmem:(VarDef (Move {t2} [s] tmp2 src _))) + // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config)) + // result: (Move {t1} [s] dst src midmem) + for { + s := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + dst := v_0 + tmp1 := v_1 + midmem := v_2 + if midmem.Op != OpVarDef { + break + } + midmem_0 := midmem.Args[0] + if midmem_0.Op != OpMove || auxIntToInt64(midmem_0.AuxInt) != s { + break + } + t2 := auxToType(midmem_0.Aux) + src := midmem_0.Args[1] + tmp2 := midmem_0.Args[0] + if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && !isVolatile(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(s) + v.Aux = typeToAux(t1) + v.AddArg3(dst, src, midmem) + return true + } + // match: (Move dst src mem) + // cond: isSamePtr(dst, src) + // result: mem + for { + dst := v_0 + src := v_1 + mem := v_2 + if !(isSamePtr(dst, src)) { + break + } + v.copyOf(mem) + return true + } + return false +} +func rewriteValuegeneric_OpMul16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul16 (Const16 [c]) (Const16 [d])) + // result: (Const16 [c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c * d) + return true + } + break + } + // match: (Mul16 (Const16 [1]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 1 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Mul16 (Const16 [-1]) x) + // result: (Neg16 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.reset(OpNeg16) + v.AddArg(x) + return true + } + break + } + // match: (Mul16 (Const16 [c]) (Neg16 x)) + // result: (Mul16 x (Const16 [-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpNeg16 { + continue + } + x := v_1.Args[0] + v.reset(OpMul16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(-c) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Mul16 (Neg16 x) (Neg16 y)) + // result: (Mul16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeg16 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpNeg16 { + continue + } + y := v_1.Args[0] + v.reset(OpMul16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Mul16 (Const16 [c]) (Add16 (Const16 [d]) x)) + // cond: !isPowerOfTwo(c) + // result: (Add16 (Const16 [c*d]) (Mul16 (Const16 [c]) x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpAdd16 || v_1.Type != t { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + continue + } + d := auxIntToInt16(v_1_0.AuxInt) + x := v_1_1 + if !(!isPowerOfTwo(c)) { + continue + } + v.reset(OpAdd16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c * d) + v1 := b.NewValue0(v.Pos, OpMul16, t) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(c) + v1.AddArg2(v2, x) + v.AddArg2(v0, v1) + return true + } + } + break + } + // match: (Mul16 (Const16 [0]) _) + // result: (Const16 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + continue + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + break + } + // match: (Mul16 x (Const16 [c])) + // cond: isPowerOfTwo(c) && v.Block.Func.pass.name != "opt" + // result: (Lsh16x64 x (Const64 [log16(c)])) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1.AuxInt) + if !(isPowerOfTwo(c) && v.Block.Func.pass.name != "opt") { + continue + } + v.reset(OpLsh16x64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(log16(c)) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Mul16 x (Const16 [c])) + // cond: t.IsSigned() && isPowerOfTwo(-c) && v.Block.Func.pass.name != "opt" + // result: (Neg16 (Lsh16x64 x (Const64 [log16(-c)]))) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1.AuxInt) + if !(t.IsSigned() && isPowerOfTwo(-c) && v.Block.Func.pass.name != "opt") { + continue + } + v.reset(OpNeg16) + v0 := b.NewValue0(v.Pos, OpLsh16x64, t) + v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v1.AuxInt = int64ToAuxInt(log16(-c)) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } + break + } + // match: (Mul16 (Mul16 i:(Const16 ) z) x) + // cond: (z.Op != OpConst16 && x.Op != OpConst16) + // result: (Mul16 i (Mul16 x z)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMul16 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst16 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst16 && x.Op != OpConst16) { + continue + } + v.reset(OpMul16) + v0 := b.NewValue0(v.Pos, OpMul16, t) + v0.AddArg2(x, z) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Mul16 (Const16 [c]) (Mul16 (Const16 [d]) x)) + // result: (Mul16 (Const16 [c*d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpMul16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + continue + } + d := auxIntToInt16(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpMul16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c * d) + v.AddArg2(v0, x) + return true + } + } + break + } + return false +} +func rewriteValuegeneric_OpMul32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul32 (Const32 [c]) (Const32 [d])) + // result: (Const32 [c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c * d) + return true + } + break + } + // match: (Mul32 (Const32 [1]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 1 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Mul32 (Const32 [-1]) x) + // result: (Neg32 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.reset(OpNeg32) + v.AddArg(x) + return true + } + break + } + // match: (Mul32 (Const32 [c]) (Neg32 x)) + // result: (Mul32 x (Const32 [-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpNeg32 { + continue + } + x := v_1.Args[0] + v.reset(OpMul32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(-c) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Mul32 (Neg32 x) (Neg32 y)) + // result: (Mul32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeg32 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpNeg32 { + continue + } + y := v_1.Args[0] + v.reset(OpMul32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Mul32 (Const32 [c]) (Add32 (Const32 [d]) x)) + // cond: !isPowerOfTwo(c) + // result: (Add32 (Const32 [c*d]) (Mul32 (Const32 [c]) x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpAdd32 || v_1.Type != t { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + continue + } + d := auxIntToInt32(v_1_0.AuxInt) + x := v_1_1 + if !(!isPowerOfTwo(c)) { + continue + } + v.reset(OpAdd32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c * d) + v1 := b.NewValue0(v.Pos, OpMul32, t) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(c) + v1.AddArg2(v2, x) + v.AddArg2(v0, v1) + return true + } + } + break + } + // match: (Mul32 (Const32 [0]) _) + // result: (Const32 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + continue + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + break + } + // match: (Mul32 x (Const32 [c])) + // cond: isPowerOfTwo(c) && v.Block.Func.pass.name != "opt" + // result: (Lsh32x64 x (Const64 [log32(c)])) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1.AuxInt) + if !(isPowerOfTwo(c) && v.Block.Func.pass.name != "opt") { + continue + } + v.reset(OpLsh32x64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(log32(c)) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Mul32 x (Const32 [c])) + // cond: t.IsSigned() && isPowerOfTwo(-c) && v.Block.Func.pass.name != "opt" + // result: (Neg32 (Lsh32x64 x (Const64 [log32(-c)]))) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1.AuxInt) + if !(t.IsSigned() && isPowerOfTwo(-c) && v.Block.Func.pass.name != "opt") { + continue + } + v.reset(OpNeg32) + v0 := b.NewValue0(v.Pos, OpLsh32x64, t) + v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v1.AuxInt = int64ToAuxInt(log32(-c)) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } + break + } + // match: (Mul32 (Mul32 i:(Const32 ) z) x) + // cond: (z.Op != OpConst32 && x.Op != OpConst32) + // result: (Mul32 i (Mul32 x z)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMul32 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst32 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst32 && x.Op != OpConst32) { + continue + } + v.reset(OpMul32) + v0 := b.NewValue0(v.Pos, OpMul32, t) + v0.AddArg2(x, z) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Mul32 (Const32 [c]) (Mul32 (Const32 [d]) x)) + // result: (Mul32 (Const32 [c*d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpMul32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + continue + } + d := auxIntToInt32(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpMul32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c * d) + v.AddArg2(v0, x) + return true + } + } + break + } + return false +} +func rewriteValuegeneric_OpMul32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Mul32F (Const32F [c]) (Const32F [d])) + // cond: c*d == c*d + // result: (Const32F [c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32F { + continue + } + c := auxIntToFloat32(v_0.AuxInt) + if v_1.Op != OpConst32F { + continue + } + d := auxIntToFloat32(v_1.AuxInt) + if !(c*d == c*d) { + continue + } + v.reset(OpConst32F) + v.AuxInt = float32ToAuxInt(c * d) + return true + } + break + } + // match: (Mul32F x (Const32F [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst32F || auxIntToFloat32(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Mul32F x (Const32F [-1])) + // result: (Neg32F x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst32F || auxIntToFloat32(v_1.AuxInt) != -1 { + continue + } + v.reset(OpNeg32F) + v.AddArg(x) + return true + } + break + } + // match: (Mul32F x (Const32F [2])) + // result: (Add32F x x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst32F || auxIntToFloat32(v_1.AuxInt) != 2 { + continue + } + v.reset(OpAdd32F) + v.AddArg2(x, x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpMul32uhilo(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul32uhilo (Const32 [c]) (Const32 [d])) + // result: (MakeTuple (Const32 [bitsMulU32(c, d).hi]) (Const32 [bitsMulU32(c,d).lo])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpMakeTuple) + v0 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v0.AuxInt = int32ToAuxInt(bitsMulU32(c, d).hi) + v1 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v1.AuxInt = int32ToAuxInt(bitsMulU32(c, d).lo) + v.AddArg2(v0, v1) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpMul32uover(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul32uover (Const32 [c]) (Const32 [d])) + // result: (MakeTuple (Const32 [bitsMulU32(c, d).lo]) (ConstBool [bitsMulU32(c,d).hi != 0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpMakeTuple) + v0 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) + v0.AuxInt = int32ToAuxInt(bitsMulU32(c, d).lo) + v1 := b.NewValue0(v.Pos, OpConstBool, typ.Bool) + v1.AuxInt = boolToAuxInt(bitsMulU32(c, d).hi != 0) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (Mul32uover (Const32 [1]) x) + // result: (MakeTuple x (ConstBool [false])) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 1 { + continue + } + x := v_1 + v.reset(OpMakeTuple) + v0 := b.NewValue0(v.Pos, OpConstBool, t.FieldType(1)) + v0.AuxInt = boolToAuxInt(false) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Mul32uover (Const32 [0]) x) + // result: (MakeTuple (Const32 [0]) (ConstBool [false])) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + continue + } + v.reset(OpMakeTuple) + v0 := b.NewValue0(v.Pos, OpConst32, t.FieldType(0)) + v0.AuxInt = int32ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpConstBool, t.FieldType(1)) + v1.AuxInt = boolToAuxInt(false) + v.AddArg2(v0, v1) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpMul64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul64 (Const64 [c]) (Const64 [d])) + // result: (Const64 [c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c * d) + return true + } + break + } + // match: (Mul64 (Const64 [1]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 1 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Mul64 (Const64 [-1]) x) + // result: (Neg64 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.reset(OpNeg64) + v.AddArg(x) + return true + } + break + } + // match: (Mul64 (Const64 [c]) (Neg64 x)) + // result: (Mul64 x (Const64 [-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpNeg64 { + continue + } + x := v_1.Args[0] + v.reset(OpMul64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(-c) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Mul64 (Neg64 x) (Neg64 y)) + // result: (Mul64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeg64 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpNeg64 { + continue + } + y := v_1.Args[0] + v.reset(OpMul64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Mul64 (Const64 [c]) (Add64 (Const64 [d]) x)) + // cond: !isPowerOfTwo(c) + // result: (Add64 (Const64 [c*d]) (Mul64 (Const64 [c]) x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpAdd64 || v_1.Type != t { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + continue + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + if !(!isPowerOfTwo(c)) { + continue + } + v.reset(OpAdd64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c * d) + v1 := b.NewValue0(v.Pos, OpMul64, t) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(c) + v1.AddArg2(v2, x) + v.AddArg2(v0, v1) + return true + } + } + break + } + // match: (Mul64 (Const64 [0]) _) + // result: (Const64 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + continue + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + break + } + // match: (Mul64 x (Const64 [c])) + // cond: isPowerOfTwo(c) && v.Block.Func.pass.name != "opt" + // result: (Lsh64x64 x (Const64 [log64(c)])) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(isPowerOfTwo(c) && v.Block.Func.pass.name != "opt") { + continue + } + v.reset(OpLsh64x64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(log64(c)) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Mul64 x (Const64 [c])) + // cond: t.IsSigned() && isPowerOfTwo(-c) && v.Block.Func.pass.name != "opt" + // result: (Neg64 (Lsh64x64 x (Const64 [log64(-c)]))) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1.AuxInt) + if !(t.IsSigned() && isPowerOfTwo(-c) && v.Block.Func.pass.name != "opt") { + continue + } + v.reset(OpNeg64) + v0 := b.NewValue0(v.Pos, OpLsh64x64, t) + v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v1.AuxInt = int64ToAuxInt(log64(-c)) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } + break + } + // match: (Mul64 (Mul64 i:(Const64 ) z) x) + // cond: (z.Op != OpConst64 && x.Op != OpConst64) + // result: (Mul64 i (Mul64 x z)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMul64 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst64 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst64 && x.Op != OpConst64) { + continue + } + v.reset(OpMul64) + v0 := b.NewValue0(v.Pos, OpMul64, t) + v0.AddArg2(x, z) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Mul64 (Const64 [c]) (Mul64 (Const64 [d]) x)) + // result: (Mul64 (Const64 [c*d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpMul64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + continue + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpMul64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c * d) + v.AddArg2(v0, x) + return true + } + } + break + } + return false +} +func rewriteValuegeneric_OpMul64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Mul64F (Const64F [c]) (Const64F [d])) + // cond: c*d == c*d + // result: (Const64F [c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64F { + continue + } + c := auxIntToFloat64(v_0.AuxInt) + if v_1.Op != OpConst64F { + continue + } + d := auxIntToFloat64(v_1.AuxInt) + if !(c*d == c*d) { + continue + } + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(c * d) + return true + } + break + } + // match: (Mul64F x (Const64F [1])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst64F || auxIntToFloat64(v_1.AuxInt) != 1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Mul64F x (Const64F [-1])) + // result: (Neg64F x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst64F || auxIntToFloat64(v_1.AuxInt) != -1 { + continue + } + v.reset(OpNeg64F) + v.AddArg(x) + return true + } + break + } + // match: (Mul64F x (Const64F [2])) + // result: (Add64F x x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst64F || auxIntToFloat64(v_1.AuxInt) != 2 { + continue + } + v.reset(OpAdd64F) + v.AddArg2(x, x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpMul64uhilo(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul64uhilo (Const64 [c]) (Const64 [d])) + // result: (MakeTuple (Const64 [bitsMulU64(c, d).hi]) (Const64 [bitsMulU64(c,d).lo])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpMakeTuple) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(bitsMulU64(c, d).hi) + v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v1.AuxInt = int64ToAuxInt(bitsMulU64(c, d).lo) + v.AddArg2(v0, v1) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpMul64uover(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul64uover (Const64 [c]) (Const64 [d])) + // result: (MakeTuple (Const64 [bitsMulU64(c, d).lo]) (ConstBool [bitsMulU64(c,d).hi != 0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpMakeTuple) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(bitsMulU64(c, d).lo) + v1 := b.NewValue0(v.Pos, OpConstBool, typ.Bool) + v1.AuxInt = boolToAuxInt(bitsMulU64(c, d).hi != 0) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (Mul64uover (Const64 [1]) x) + // result: (MakeTuple x (ConstBool [false])) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 1 { + continue + } + x := v_1 + v.reset(OpMakeTuple) + v0 := b.NewValue0(v.Pos, OpConstBool, t.FieldType(1)) + v0.AuxInt = boolToAuxInt(false) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Mul64uover (Const64 [0]) x) + // result: (MakeTuple (Const64 [0]) (ConstBool [false])) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + continue + } + v.reset(OpMakeTuple) + v0 := b.NewValue0(v.Pos, OpConst64, t.FieldType(0)) + v0.AuxInt = int64ToAuxInt(0) + v1 := b.NewValue0(v.Pos, OpConstBool, t.FieldType(1)) + v1.AuxInt = boolToAuxInt(false) + v.AddArg2(v0, v1) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpMul8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Mul8 (Const8 [c]) (Const8 [d])) + // result: (Const8 [c*d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c * d) + return true + } + break + } + // match: (Mul8 (Const8 [1]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 1 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Mul8 (Const8 [-1]) x) + // result: (Neg8 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.reset(OpNeg8) + v.AddArg(x) + return true + } + break + } + // match: (Mul8 (Const8 [c]) (Neg8 x)) + // result: (Mul8 x (Const8 [-c])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpNeg8 { + continue + } + x := v_1.Args[0] + v.reset(OpMul8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(-c) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Mul8 (Neg8 x) (Neg8 y)) + // result: (Mul8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeg8 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpNeg8 { + continue + } + y := v_1.Args[0] + v.reset(OpMul8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Mul8 (Const8 [c]) (Add8 (Const8 [d]) x)) + // cond: !isPowerOfTwo(c) + // result: (Add8 (Const8 [c*d]) (Mul8 (Const8 [c]) x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpAdd8 || v_1.Type != t { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + continue + } + d := auxIntToInt8(v_1_0.AuxInt) + x := v_1_1 + if !(!isPowerOfTwo(c)) { + continue + } + v.reset(OpAdd8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c * d) + v1 := b.NewValue0(v.Pos, OpMul8, t) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(c) + v1.AddArg2(v2, x) + v.AddArg2(v0, v1) + return true + } + } + break + } + // match: (Mul8 (Const8 [0]) _) + // result: (Const8 [0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + continue + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + break + } + // match: (Mul8 x (Const8 [c])) + // cond: isPowerOfTwo(c) && v.Block.Func.pass.name != "opt" + // result: (Lsh8x64 x (Const64 [log8(c)])) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1.AuxInt) + if !(isPowerOfTwo(c) && v.Block.Func.pass.name != "opt") { + continue + } + v.reset(OpLsh8x64) + v.Type = t + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(log8(c)) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Mul8 x (Const8 [c])) + // cond: t.IsSigned() && isPowerOfTwo(-c) && v.Block.Func.pass.name != "opt" + // result: (Neg8 (Lsh8x64 x (Const64 [log8(-c)]))) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1.AuxInt) + if !(t.IsSigned() && isPowerOfTwo(-c) && v.Block.Func.pass.name != "opt") { + continue + } + v.reset(OpNeg8) + v0 := b.NewValue0(v.Pos, OpLsh8x64, t) + v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v1.AuxInt = int64ToAuxInt(log8(-c)) + v0.AddArg2(x, v1) + v.AddArg(v0) + return true + } + break + } + // match: (Mul8 (Mul8 i:(Const8 ) z) x) + // cond: (z.Op != OpConst8 && x.Op != OpConst8) + // result: (Mul8 i (Mul8 x z)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpMul8 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst8 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst8 && x.Op != OpConst8) { + continue + } + v.reset(OpMul8) + v0 := b.NewValue0(v.Pos, OpMul8, t) + v0.AddArg2(x, z) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Mul8 (Const8 [c]) (Mul8 (Const8 [d]) x)) + // result: (Mul8 (Const8 [c*d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpMul8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + continue + } + d := auxIntToInt8(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpMul8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c * d) + v.AddArg2(v0, x) + return true + } + } + break + } + return false +} +func rewriteValuegeneric_OpNeg16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Neg16 (Const16 [c])) + // result: (Const16 [-c]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(-c) + return true + } + // match: (Neg16 (Mul16 x (Const16 [c]))) + // result: (Mul16 x (Const16 [-c])) + for { + if v_0.Op != OpMul16 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst16 { + continue + } + t := v_0_1.Type + c := auxIntToInt16(v_0_1.AuxInt) + v.reset(OpMul16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(-c) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Neg16 (Mul16 x (Neg16 y))) + // result: (Mul16 x y) + for { + if v_0.Op != OpMul16 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpNeg16 { + continue + } + y := v_0_1.Args[0] + v.reset(OpMul16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Neg16 (Sub16 x y)) + // result: (Sub16 y x) + for { + if v_0.Op != OpSub16 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpSub16) + v.AddArg2(y, x) + return true + } + // match: (Neg16 (Neg16 x)) + // result: x + for { + if v_0.Op != OpNeg16 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Neg16 (Com16 x)) + // result: (Add16 (Const16 [1]) x) + for { + t := v.Type + if v_0.Op != OpCom16 { + break + } + x := v_0.Args[0] + v.reset(OpAdd16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(1) + v.AddArg2(v0, x) + return true + } + return false +} +func rewriteValuegeneric_OpNeg32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Neg32 (Const32 [c])) + // result: (Const32 [-c]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(-c) + return true + } + // match: (Neg32 (Mul32 x (Const32 [c]))) + // result: (Mul32 x (Const32 [-c])) + for { + if v_0.Op != OpMul32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst32 { + continue + } + t := v_0_1.Type + c := auxIntToInt32(v_0_1.AuxInt) + v.reset(OpMul32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(-c) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Neg32 (Mul32 x (Neg32 y))) + // result: (Mul32 x y) + for { + if v_0.Op != OpMul32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpNeg32 { + continue + } + y := v_0_1.Args[0] + v.reset(OpMul32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Neg32 (Sub32 x y)) + // result: (Sub32 y x) + for { + if v_0.Op != OpSub32 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpSub32) + v.AddArg2(y, x) + return true + } + // match: (Neg32 (Neg32 x)) + // result: x + for { + if v_0.Op != OpNeg32 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Neg32 (Com32 x)) + // result: (Add32 (Const32 [1]) x) + for { + t := v.Type + if v_0.Op != OpCom32 { + break + } + x := v_0.Args[0] + v.reset(OpAdd32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(1) + v.AddArg2(v0, x) + return true + } + return false +} +func rewriteValuegeneric_OpNeg32F(v *Value) bool { + v_0 := v.Args[0] + // match: (Neg32F (Const32F [c])) + // cond: c != 0 + // result: (Const32F [-c]) + for { + if v_0.Op != OpConst32F { + break + } + c := auxIntToFloat32(v_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpConst32F) + v.AuxInt = float32ToAuxInt(-c) + return true + } + return false +} +func rewriteValuegeneric_OpNeg64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Neg64 (Const64 [c])) + // result: (Const64 [-c]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(-c) + return true + } + // match: (Neg64 (Mul64 x (Const64 [c]))) + // result: (Mul64 x (Const64 [-c])) + for { + if v_0.Op != OpMul64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst64 { + continue + } + t := v_0_1.Type + c := auxIntToInt64(v_0_1.AuxInt) + v.reset(OpMul64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(-c) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Neg64 (Mul64 x (Neg64 y))) + // result: (Mul64 x y) + for { + if v_0.Op != OpMul64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpNeg64 { + continue + } + y := v_0_1.Args[0] + v.reset(OpMul64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Neg64 (Sub64 x y)) + // result: (Sub64 y x) + for { + if v_0.Op != OpSub64 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpSub64) + v.AddArg2(y, x) + return true + } + // match: (Neg64 (Neg64 x)) + // result: x + for { + if v_0.Op != OpNeg64 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Neg64 (Com64 x)) + // result: (Add64 (Const64 [1]) x) + for { + t := v.Type + if v_0.Op != OpCom64 { + break + } + x := v_0.Args[0] + v.reset(OpAdd64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(1) + v.AddArg2(v0, x) + return true + } + return false +} +func rewriteValuegeneric_OpNeg64F(v *Value) bool { + v_0 := v.Args[0] + // match: (Neg64F (Const64F [c])) + // cond: c != 0 + // result: (Const64F [-c]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + if !(c != 0) { + break + } + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(-c) + return true + } + return false +} +func rewriteValuegeneric_OpNeg8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (Neg8 (Const8 [c])) + // result: (Const8 [-c]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(-c) + return true + } + // match: (Neg8 (Mul8 x (Const8 [c]))) + // result: (Mul8 x (Const8 [-c])) + for { + if v_0.Op != OpMul8 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst8 { + continue + } + t := v_0_1.Type + c := auxIntToInt8(v_0_1.AuxInt) + v.reset(OpMul8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(-c) + v.AddArg2(x, v0) + return true + } + break + } + // match: (Neg8 (Mul8 x (Neg8 y))) + // result: (Mul8 x y) + for { + if v_0.Op != OpMul8 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpNeg8 { + continue + } + y := v_0_1.Args[0] + v.reset(OpMul8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Neg8 (Sub8 x y)) + // result: (Sub8 y x) + for { + if v_0.Op != OpSub8 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpSub8) + v.AddArg2(y, x) + return true + } + // match: (Neg8 (Neg8 x)) + // result: x + for { + if v_0.Op != OpNeg8 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Neg8 (Com8 x)) + // result: (Add8 (Const8 [1]) x) + for { + t := v.Type + if v_0.Op != OpCom8 { + break + } + x := v_0.Args[0] + v.reset(OpAdd8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(1) + v.AddArg2(v0, x) + return true + } + return false +} +func rewriteValuegeneric_OpNeq16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq16 x x) + // result: (ConstBool [false]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Neq16 (Const16 [c]) (Add16 (Const16 [d]) x)) + // result: (Neq16 (Const16 [c-d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpAdd16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + continue + } + d := auxIntToInt16(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpNeq16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Neq16 (Const16 [c]) (Const16 [d])) + // result: (ConstBool [c != d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c != d) + return true + } + break + } + // match: (Neq16 s:(Sub16 x y) (Const16 [0])) + // cond: s.Uses == 1 + // result: (Neq16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + s := v_0 + if s.Op != OpSub16 { + continue + } + y := s.Args[1] + x := s.Args[0] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 || !(s.Uses == 1) { + continue + } + v.reset(OpNeq16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Neq16 (And16 x (Const16 [y])) (Const16 [y])) + // cond: oneBit(y) + // result: (Eq16 (And16 x (Const16 [y])) (Const16 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd16 { + continue + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst16 || v_0_1.Type != t { + continue + } + y := auxIntToInt16(v_0_1.AuxInt) + if v_1.Op != OpConst16 || v_1.Type != t || auxIntToInt16(v_1.AuxInt) != y || !(oneBit(y)) { + continue + } + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpAnd16, t) + v1 := b.NewValue0(v.Pos, OpConst16, t) + v1.AuxInt = int16ToAuxInt(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst16, t) + v2.AuxInt = int16ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq16 (ZeroExt8to16 (CvtBoolToUint8 x)) (Const16 [0])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to16 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Neq16 (ZeroExt8to16 (CvtBoolToUint8 x)) (Const16 [1])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to16 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 1 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + // match: (Neq16 (SignExt8to16 (CvtBoolToUint8 x)) (Const16 [0])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to16 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Neq16 (SignExt8to16 (CvtBoolToUint8 x)) (Const16 [1])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to16 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 1 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpNeq32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq32 x x) + // result: (ConstBool [false]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Neq32 (Const32 [c]) (Add32 (Const32 [d]) x)) + // result: (Neq32 (Const32 [c-d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpAdd32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + continue + } + d := auxIntToInt32(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpNeq32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Neq32 (Const32 [c]) (Const32 [d])) + // result: (ConstBool [c != d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c != d) + return true + } + break + } + // match: (Neq32 s:(Sub32 x y) (Const32 [0])) + // cond: s.Uses == 1 + // result: (Neq32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + s := v_0 + if s.Op != OpSub32 { + continue + } + y := s.Args[1] + x := s.Args[0] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 0 || !(s.Uses == 1) { + continue + } + v.reset(OpNeq32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Neq32 (And32 x (Const32 [y])) (Const32 [y])) + // cond: oneBit(y) + // result: (Eq32 (And32 x (Const32 [y])) (Const32 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd32 { + continue + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst32 || v_0_1.Type != t { + continue + } + y := auxIntToInt32(v_0_1.AuxInt) + if v_1.Op != OpConst32 || v_1.Type != t || auxIntToInt32(v_1.AuxInt) != y || !(oneBit(y)) { + continue + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpAnd32, t) + v1 := b.NewValue0(v.Pos, OpConst32, t) + v1.AuxInt = int32ToAuxInt(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst32, t) + v2.AuxInt = int32ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq32 (ZeroExt8to32 (CvtBoolToUint8 x)) (Const32 [0])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to32 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 0 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Neq32 (ZeroExt8to32 (CvtBoolToUint8 x)) (Const32 [1])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to32 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 1 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + // match: (Neq32 (SignExt8to32 (CvtBoolToUint8 x)) (Const32 [0])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to32 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 0 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Neq32 (SignExt8to32 (CvtBoolToUint8 x)) (Const32 [1])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to32 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 1 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpNeq32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Neq32F (Const32F [c]) (Const32F [d])) + // result: (ConstBool [c != d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32F { + continue + } + c := auxIntToFloat32(v_0.AuxInt) + if v_1.Op != OpConst32F { + continue + } + d := auxIntToFloat32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c != d) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpNeq64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq64 x x) + // result: (ConstBool [false]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Neq64 (Const64 [c]) (Add64 (Const64 [d]) x)) + // result: (Neq64 (Const64 [c-d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpAdd64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + continue + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpNeq64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Neq64 (Const64 [c]) (Const64 [d])) + // result: (ConstBool [c != d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c != d) + return true + } + break + } + // match: (Neq64 s:(Sub64 x y) (Const64 [0])) + // cond: s.Uses == 1 + // result: (Neq64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + s := v_0 + if s.Op != OpSub64 { + continue + } + y := s.Args[1] + x := s.Args[0] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 || !(s.Uses == 1) { + continue + } + v.reset(OpNeq64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Neq64 (And64 x (Const64 [y])) (Const64 [y])) + // cond: oneBit(y) + // result: (Eq64 (And64 x (Const64 [y])) (Const64 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd64 { + continue + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst64 || v_0_1.Type != t { + continue + } + y := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 || v_1.Type != t || auxIntToInt64(v_1.AuxInt) != y || !(oneBit(y)) { + continue + } + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpAnd64, t) + v1 := b.NewValue0(v.Pos, OpConst64, t) + v1.AuxInt = int64ToAuxInt(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst64, t) + v2.AuxInt = int64ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq64 (ZeroExt8to64 (CvtBoolToUint8 x)) (Const64 [0])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to64 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Neq64 (ZeroExt8to64 (CvtBoolToUint8 x)) (Const64 [1])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpZeroExt8to64 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 1 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + // match: (Neq64 (SignExt8to64 (CvtBoolToUint8 x)) (Const64 [0])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to64 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Neq64 (SignExt8to64 (CvtBoolToUint8 x)) (Const64 [1])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpSignExt8to64 { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0_0.Args[0] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 1 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpNeq64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Neq64F (Const64F [c]) (Const64F [d])) + // result: (ConstBool [c != d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64F { + continue + } + c := auxIntToFloat64(v_0.AuxInt) + if v_1.Op != OpConst64F { + continue + } + d := auxIntToFloat64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c != d) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpNeq8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Neq8 x x) + // result: (ConstBool [false]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (Neq8 (Const8 [c]) (Add8 (Const8 [d]) x)) + // result: (Neq8 (Const8 [c-d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpAdd8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + continue + } + d := auxIntToInt8(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpNeq8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Neq8 (Const8 [c]) (Const8 [d])) + // result: (ConstBool [c != d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c != d) + return true + } + break + } + // match: (Neq8 s:(Sub8 x y) (Const8 [0])) + // cond: s.Uses == 1 + // result: (Neq8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + s := v_0 + if s.Op != OpSub8 { + continue + } + y := s.Args[1] + x := s.Args[0] + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 || !(s.Uses == 1) { + continue + } + v.reset(OpNeq8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Neq8 (And8 x (Const8 [y])) (Const8 [y])) + // cond: oneBit(y) + // result: (Eq8 (And8 x (Const8 [y])) (Const8 [0])) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd8 { + continue + } + t := v_0.Type + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst8 || v_0_1.Type != t { + continue + } + y := auxIntToInt8(v_0_1.AuxInt) + if v_1.Op != OpConst8 || v_1.Type != t || auxIntToInt8(v_1.AuxInt) != y || !(oneBit(y)) { + continue + } + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpAnd8, t) + v1 := b.NewValue0(v.Pos, OpConst8, t) + v1.AuxInt = int8ToAuxInt(y) + v0.AddArg2(x, v1) + v2 := b.NewValue0(v.Pos, OpConst8, t) + v2.AuxInt = int8ToAuxInt(0) + v.AddArg2(v0, v2) + return true + } + } + break + } + // match: (Neq8 (CvtBoolToUint8 x) (Const8 [0])) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Neq8 (CvtBoolToUint8 x) (Const8 [1])) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCvtBoolToUint8 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 1 { + continue + } + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpNeqB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NeqB (ConstBool [c]) (ConstBool [d])) + // result: (ConstBool [c != d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConstBool { + continue + } + c := auxIntToBool(v_0.AuxInt) + if v_1.Op != OpConstBool { + continue + } + d := auxIntToBool(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c != d) + return true + } + break + } + // match: (NeqB (ConstBool [false]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != false { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (NeqB (ConstBool [true]) x) + // result: (Not x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != true { + continue + } + x := v_1 + v.reset(OpNot) + v.AddArg(x) + return true + } + break + } + // match: (NeqB (Not x) (Not y)) + // result: (NeqB x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNot { + continue + } + x := v_0.Args[0] + if v_1.Op != OpNot { + continue + } + y := v_1.Args[0] + v.reset(OpNeqB) + v.AddArg2(x, y) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpNeqInter(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NeqInter x y) + // result: (NeqPtr (ITab x) (ITab y)) + for { + x := v_0 + y := v_1 + v.reset(OpNeqPtr) + v0 := b.NewValue0(v.Pos, OpITab, typ.Uintptr) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpITab, typ.Uintptr) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuegeneric_OpNeqPtr(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (NeqPtr x x) + // result: (ConstBool [false]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(false) + return true + } + // match: (NeqPtr (Addr {x} _) (Addr {y} _)) + // result: (ConstBool [x != y]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAddr { + continue + } + x := auxToSym(v_0.Aux) + if v_1.Op != OpAddr { + continue + } + y := auxToSym(v_1.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x != y) + return true + } + break + } + // match: (NeqPtr (Addr {x} _) (OffPtr [o] (Addr {y} _))) + // result: (ConstBool [x != y || o != 0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAddr { + continue + } + x := auxToSym(v_0.Aux) + if v_1.Op != OpOffPtr { + continue + } + o := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAddr { + continue + } + y := auxToSym(v_1_0.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x != y || o != 0) + return true + } + break + } + // match: (NeqPtr (OffPtr [o1] (Addr {x} _)) (OffPtr [o2] (Addr {y} _))) + // result: (ConstBool [x != y || o1 != o2]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + o1 := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAddr { + continue + } + x := auxToSym(v_0_0.Aux) + if v_1.Op != OpOffPtr { + continue + } + o2 := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAddr { + continue + } + y := auxToSym(v_1_0.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x != y || o1 != o2) + return true + } + break + } + // match: (NeqPtr (LocalAddr {x} _ _) (LocalAddr {y} _ _)) + // result: (ConstBool [x != y]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLocalAddr { + continue + } + x := auxToSym(v_0.Aux) + if v_1.Op != OpLocalAddr { + continue + } + y := auxToSym(v_1.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x != y) + return true + } + break + } + // match: (NeqPtr (LocalAddr {x} _ _) (OffPtr [o] (LocalAddr {y} _ _))) + // result: (ConstBool [x != y || o != 0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLocalAddr { + continue + } + x := auxToSym(v_0.Aux) + if v_1.Op != OpOffPtr { + continue + } + o := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLocalAddr { + continue + } + y := auxToSym(v_1_0.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x != y || o != 0) + return true + } + break + } + // match: (NeqPtr (OffPtr [o1] (LocalAddr {x} _ _)) (OffPtr [o2] (LocalAddr {y} _ _))) + // result: (ConstBool [x != y || o1 != o2]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + o1 := auxIntToInt64(v_0.AuxInt) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLocalAddr { + continue + } + x := auxToSym(v_0_0.Aux) + if v_1.Op != OpOffPtr { + continue + } + o2 := auxIntToInt64(v_1.AuxInt) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpLocalAddr { + continue + } + y := auxToSym(v_1_0.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x != y || o1 != o2) + return true + } + break + } + // match: (NeqPtr (OffPtr [o1] p1) p2) + // cond: isSamePtr(p1, p2) + // result: (ConstBool [o1 != 0]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + o1 := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + p2 := v_1 + if !(isSamePtr(p1, p2)) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(o1 != 0) + return true + } + break + } + // match: (NeqPtr (OffPtr [o1] p1) (OffPtr [o2] p2)) + // cond: isSamePtr(p1, p2) + // result: (ConstBool [o1 != o2]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + o1 := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + if v_1.Op != OpOffPtr { + continue + } + o2 := auxIntToInt64(v_1.AuxInt) + p2 := v_1.Args[0] + if !(isSamePtr(p1, p2)) { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(o1 != o2) + return true + } + break + } + // match: (NeqPtr (Const32 [c]) (Const32 [d])) + // result: (ConstBool [c != d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c != d) + return true + } + break + } + // match: (NeqPtr (Const64 [c]) (Const64 [d])) + // result: (ConstBool [c != d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(c != d) + return true + } + break + } + // match: (NeqPtr (Convert (Addr {x} _) _) (Addr {y} _)) + // result: (ConstBool [x!=y]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConvert { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAddr { + continue + } + x := auxToSym(v_0_0.Aux) + if v_1.Op != OpAddr { + continue + } + y := auxToSym(v_1.Aux) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(x != y) + return true + } + break + } + // match: (NeqPtr (LocalAddr _ _) (Addr _)) + // result: (ConstBool [true]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLocalAddr || v_1.Op != OpAddr { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (NeqPtr (OffPtr (LocalAddr _ _)) (Addr _)) + // result: (ConstBool [true]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLocalAddr || v_1.Op != OpAddr { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (NeqPtr (LocalAddr _ _) (OffPtr (Addr _))) + // result: (ConstBool [true]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLocalAddr || v_1.Op != OpOffPtr { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAddr { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (NeqPtr (OffPtr (LocalAddr _ _)) (OffPtr (Addr _))) + // result: (ConstBool [true]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOffPtr { + continue + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpLocalAddr || v_1.Op != OpOffPtr { + continue + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAddr { + continue + } + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(true) + return true + } + break + } + // match: (NeqPtr (AddPtr p1 o1) p2) + // cond: isSamePtr(p1, p2) + // result: (IsNonNil o1) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAddPtr { + continue + } + o1 := v_0.Args[1] + p1 := v_0.Args[0] + p2 := v_1 + if !(isSamePtr(p1, p2)) { + continue + } + v.reset(OpIsNonNil) + v.AddArg(o1) + return true + } + break + } + // match: (NeqPtr (Const32 [0]) p) + // result: (IsNonNil p) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + continue + } + p := v_1 + v.reset(OpIsNonNil) + v.AddArg(p) + return true + } + break + } + // match: (NeqPtr (Const64 [0]) p) + // result: (IsNonNil p) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + continue + } + p := v_1 + v.reset(OpIsNonNil) + v.AddArg(p) + return true + } + break + } + // match: (NeqPtr (ConstNil) p) + // result: (IsNonNil p) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConstNil { + continue + } + p := v_1 + v.reset(OpIsNonNil) + v.AddArg(p) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpNeqSlice(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (NeqSlice x y) + // result: (NeqPtr (SlicePtr x) (SlicePtr y)) + for { + x := v_0 + y := v_1 + v.reset(OpNeqPtr) + v0 := b.NewValue0(v.Pos, OpSlicePtr, typ.BytePtr) + v0.AddArg(x) + v1 := b.NewValue0(v.Pos, OpSlicePtr, typ.BytePtr) + v1.AddArg(y) + v.AddArg2(v0, v1) + return true + } +} +func rewriteValuegeneric_OpNilCheck(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + fe := b.Func.fe + // match: (NilCheck ptr:(GetG mem) mem) + // result: ptr + for { + ptr := v_0 + if ptr.Op != OpGetG { + break + } + mem := ptr.Args[0] + if mem != v_1 { + break + } + v.copyOf(ptr) + return true + } + // match: (NilCheck ptr:(SelectN [0] call:(StaticLECall ___)) _) + // cond: isMalloc(call.Aux) && warnRule(fe.Debug_checknil(), v, "removed nil check") + // result: ptr + for { + ptr := v_0 + if ptr.Op != OpSelectN || auxIntToInt64(ptr.AuxInt) != 0 { + break + } + call := ptr.Args[0] + if call.Op != OpStaticLECall { + break + } + if !(isMalloc(call.Aux) && warnRule(fe.Debug_checknil(), v, "removed nil check")) { + break + } + v.copyOf(ptr) + return true + } + // match: (NilCheck ptr:(OffPtr (SelectN [0] call:(StaticLECall ___))) _) + // cond: isMalloc(call.Aux) && warnRule(fe.Debug_checknil(), v, "removed nil check") + // result: ptr + for { + ptr := v_0 + if ptr.Op != OpOffPtr { + break + } + ptr_0 := ptr.Args[0] + if ptr_0.Op != OpSelectN || auxIntToInt64(ptr_0.AuxInt) != 0 { + break + } + call := ptr_0.Args[0] + if call.Op != OpStaticLECall { + break + } + if !(isMalloc(call.Aux) && warnRule(fe.Debug_checknil(), v, "removed nil check")) { + break + } + v.copyOf(ptr) + return true + } + // match: (NilCheck ptr:(Addr {_} (SB)) _) + // result: ptr + for { + ptr := v_0 + if ptr.Op != OpAddr { + break + } + ptr_0 := ptr.Args[0] + if ptr_0.Op != OpSB { + break + } + v.copyOf(ptr) + return true + } + // match: (NilCheck ptr:(Convert (Addr {_} (SB)) _) _) + // result: ptr + for { + ptr := v_0 + if ptr.Op != OpConvert { + break + } + ptr_0 := ptr.Args[0] + if ptr_0.Op != OpAddr { + break + } + ptr_0_0 := ptr_0.Args[0] + if ptr_0_0.Op != OpSB { + break + } + v.copyOf(ptr) + return true + } + // match: (NilCheck ptr:(LocalAddr _ _) _) + // cond: warnRule(fe.Debug_checknil(), v, "removed nil check") + // result: ptr + for { + ptr := v_0 + if ptr.Op != OpLocalAddr || !(warnRule(fe.Debug_checknil(), v, "removed nil check")) { + break + } + v.copyOf(ptr) + return true + } + // match: (NilCheck ptr:(Arg {sym}) _) + // cond: isDictArgSym(sym) + // result: ptr + for { + ptr := v_0 + if ptr.Op != OpArg { + break + } + sym := auxToSym(ptr.Aux) + if !(isDictArgSym(sym)) { + break + } + v.copyOf(ptr) + return true + } + // match: (NilCheck ptr:(NilCheck _ _) _ ) + // result: ptr + for { + ptr := v_0 + if ptr.Op != OpNilCheck { + break + } + v.copyOf(ptr) + return true + } + return false +} +func rewriteValuegeneric_OpNot(v *Value) bool { + v_0 := v.Args[0] + // match: (Not (ConstBool [c])) + // result: (ConstBool [!c]) + for { + if v_0.Op != OpConstBool { + break + } + c := auxIntToBool(v_0.AuxInt) + v.reset(OpConstBool) + v.AuxInt = boolToAuxInt(!c) + return true + } + // match: (Not (Eq64 x y)) + // result: (Neq64 x y) + for { + if v_0.Op != OpEq64 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpNeq64) + v.AddArg2(x, y) + return true + } + // match: (Not (Eq32 x y)) + // result: (Neq32 x y) + for { + if v_0.Op != OpEq32 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpNeq32) + v.AddArg2(x, y) + return true + } + // match: (Not (Eq16 x y)) + // result: (Neq16 x y) + for { + if v_0.Op != OpEq16 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpNeq16) + v.AddArg2(x, y) + return true + } + // match: (Not (Eq8 x y)) + // result: (Neq8 x y) + for { + if v_0.Op != OpEq8 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpNeq8) + v.AddArg2(x, y) + return true + } + // match: (Not (EqB x y)) + // result: (NeqB x y) + for { + if v_0.Op != OpEqB { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpNeqB) + v.AddArg2(x, y) + return true + } + // match: (Not (EqPtr x y)) + // result: (NeqPtr x y) + for { + if v_0.Op != OpEqPtr { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpNeqPtr) + v.AddArg2(x, y) + return true + } + // match: (Not (Eq64F x y)) + // result: (Neq64F x y) + for { + if v_0.Op != OpEq64F { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpNeq64F) + v.AddArg2(x, y) + return true + } + // match: (Not (Eq32F x y)) + // result: (Neq32F x y) + for { + if v_0.Op != OpEq32F { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpNeq32F) + v.AddArg2(x, y) + return true + } + // match: (Not (Neq64 x y)) + // result: (Eq64 x y) + for { + if v_0.Op != OpNeq64 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpEq64) + v.AddArg2(x, y) + return true + } + // match: (Not (Neq32 x y)) + // result: (Eq32 x y) + for { + if v_0.Op != OpNeq32 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpEq32) + v.AddArg2(x, y) + return true + } + // match: (Not (Neq16 x y)) + // result: (Eq16 x y) + for { + if v_0.Op != OpNeq16 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpEq16) + v.AddArg2(x, y) + return true + } + // match: (Not (Neq8 x y)) + // result: (Eq8 x y) + for { + if v_0.Op != OpNeq8 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpEq8) + v.AddArg2(x, y) + return true + } + // match: (Not (NeqB x y)) + // result: (EqB x y) + for { + if v_0.Op != OpNeqB { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpEqB) + v.AddArg2(x, y) + return true + } + // match: (Not (NeqPtr x y)) + // result: (EqPtr x y) + for { + if v_0.Op != OpNeqPtr { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpEqPtr) + v.AddArg2(x, y) + return true + } + // match: (Not (Neq64F x y)) + // result: (Eq64F x y) + for { + if v_0.Op != OpNeq64F { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpEq64F) + v.AddArg2(x, y) + return true + } + // match: (Not (Neq32F x y)) + // result: (Eq32F x y) + for { + if v_0.Op != OpNeq32F { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpEq32F) + v.AddArg2(x, y) + return true + } + // match: (Not (Less64 x y)) + // result: (Leq64 y x) + for { + if v_0.Op != OpLess64 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLeq64) + v.AddArg2(y, x) + return true + } + // match: (Not (Less32 x y)) + // result: (Leq32 y x) + for { + if v_0.Op != OpLess32 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLeq32) + v.AddArg2(y, x) + return true + } + // match: (Not (Less16 x y)) + // result: (Leq16 y x) + for { + if v_0.Op != OpLess16 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLeq16) + v.AddArg2(y, x) + return true + } + // match: (Not (Less8 x y)) + // result: (Leq8 y x) + for { + if v_0.Op != OpLess8 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLeq8) + v.AddArg2(y, x) + return true + } + // match: (Not (Less64U x y)) + // result: (Leq64U y x) + for { + if v_0.Op != OpLess64U { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLeq64U) + v.AddArg2(y, x) + return true + } + // match: (Not (Less32U x y)) + // result: (Leq32U y x) + for { + if v_0.Op != OpLess32U { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLeq32U) + v.AddArg2(y, x) + return true + } + // match: (Not (Less16U x y)) + // result: (Leq16U y x) + for { + if v_0.Op != OpLess16U { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLeq16U) + v.AddArg2(y, x) + return true + } + // match: (Not (Less8U x y)) + // result: (Leq8U y x) + for { + if v_0.Op != OpLess8U { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLeq8U) + v.AddArg2(y, x) + return true + } + // match: (Not (Leq64 x y)) + // result: (Less64 y x) + for { + if v_0.Op != OpLeq64 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLess64) + v.AddArg2(y, x) + return true + } + // match: (Not (Leq32 x y)) + // result: (Less32 y x) + for { + if v_0.Op != OpLeq32 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLess32) + v.AddArg2(y, x) + return true + } + // match: (Not (Leq16 x y)) + // result: (Less16 y x) + for { + if v_0.Op != OpLeq16 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLess16) + v.AddArg2(y, x) + return true + } + // match: (Not (Leq8 x y)) + // result: (Less8 y x) + for { + if v_0.Op != OpLeq8 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLess8) + v.AddArg2(y, x) + return true + } + // match: (Not (Leq64U x y)) + // result: (Less64U y x) + for { + if v_0.Op != OpLeq64U { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLess64U) + v.AddArg2(y, x) + return true + } + // match: (Not (Leq32U x y)) + // result: (Less32U y x) + for { + if v_0.Op != OpLeq32U { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLess32U) + v.AddArg2(y, x) + return true + } + // match: (Not (Leq16U x y)) + // result: (Less16U y x) + for { + if v_0.Op != OpLeq16U { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLess16U) + v.AddArg2(y, x) + return true + } + // match: (Not (Leq8U x y)) + // result: (Less8U y x) + for { + if v_0.Op != OpLeq8U { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpLess8U) + v.AddArg2(y, x) + return true + } + return false +} +func rewriteValuegeneric_OpOffPtr(v *Value) bool { + v_0 := v.Args[0] + // match: (OffPtr (OffPtr p [y]) [x]) + // result: (OffPtr p [x+y]) + for { + x := auxIntToInt64(v.AuxInt) + if v_0.Op != OpOffPtr { + break + } + y := auxIntToInt64(v_0.AuxInt) + p := v_0.Args[0] + v.reset(OpOffPtr) + v.AuxInt = int64ToAuxInt(x + y) + v.AddArg(p) + return true + } + // match: (OffPtr p [0]) + // cond: v.Type.Compare(p.Type) == types.CMPeq + // result: p + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + p := v_0 + if !(v.Type.Compare(p.Type) == types.CMPeq) { + break + } + v.copyOf(p) + return true + } + return false +} +func rewriteValuegeneric_OpOr16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Or16 (Const16 [c]) (Const16 [d])) + // result: (Const16 [c|d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c | d) + return true + } + break + } + // match: (Or16 (Com16 x) (Com16 y)) + // result: (Com16 (And16 x y)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom16 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpCom16 { + continue + } + y := v_1.Args[0] + v.reset(OpCom16) + v0 := b.NewValue0(v.Pos, OpAnd16, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (Or16 x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (Or16 (Const16 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Or16 (Const16 [-1]) _) + // result: (Const16 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != -1 { + continue + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(-1) + return true + } + break + } + // match: (Or16 (Com16 x) x) + // result: (Const16 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom16 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(-1) + return true + } + break + } + // match: (Or16 x (Or16 x y)) + // result: (Or16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpOr16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpOr16) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Or16 (And16 x (Const16 [c2])) (Const16 [c1])) + // cond: ^(c1 | c2) == 0 + // result: (Or16 (Const16 [c1]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd16 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst16 { + continue + } + c2 := auxIntToInt16(v_0_1.AuxInt) + if v_1.Op != OpConst16 { + continue + } + t := v_1.Type + c1 := auxIntToInt16(v_1.AuxInt) + if !(^(c1 | c2) == 0) { + continue + } + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c1) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Or16 (Or16 i:(Const16 ) z) x) + // cond: (z.Op != OpConst16 && x.Op != OpConst16) + // result: (Or16 i (Or16 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOr16 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst16 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst16 && x.Op != OpConst16) { + continue + } + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpOr16, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Or16 (Const16 [c]) (Or16 (Const16 [d]) x)) + // result: (Or16 (Const16 [c|d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpOr16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + continue + } + d := auxIntToInt16(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpOr16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c | d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Or16 (Lsh16x64 x z:(Const64 [c])) (Rsh16Ux64 x (Const64 [d]))) + // cond: c < 16 && d == 16-c && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh16x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh16Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 16 && d == 16-c && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or16 left:(Lsh16x64 x y) right:(Rsh16Ux64 x (Sub64 (Const64 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or16 left:(Lsh16x32 x y) right:(Rsh16Ux32 x (Sub32 (Const32 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or16 left:(Lsh16x16 x y) right:(Rsh16Ux16 x (Sub16 (Const16 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or16 left:(Lsh16x8 x y) right:(Rsh16Ux8 x (Sub8 (Const8 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or16 right:(Rsh16Ux64 x y) left:(Lsh16x64 x z:(Sub64 (Const64 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or16 right:(Rsh16Ux32 x y) left:(Lsh16x32 x z:(Sub32 (Const32 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or16 right:(Rsh16Ux16 x y) left:(Lsh16x16 x z:(Sub16 (Const16 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or16 right:(Rsh16Ux8 x y) left:(Lsh16x8 x z:(Sub8 (Const8 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpOr32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Or32 (Const32 [c]) (Const32 [d])) + // result: (Const32 [c|d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c | d) + return true + } + break + } + // match: (Or32 (Com32 x) (Com32 y)) + // result: (Com32 (And32 x y)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom32 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpCom32 { + continue + } + y := v_1.Args[0] + v.reset(OpCom32) + v0 := b.NewValue0(v.Pos, OpAnd32, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (Or32 x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (Or32 (Const32 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Or32 (Const32 [-1]) _) + // result: (Const32 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != -1 { + continue + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(-1) + return true + } + break + } + // match: (Or32 (Com32 x) x) + // result: (Const32 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom32 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(-1) + return true + } + break + } + // match: (Or32 x (Or32 x y)) + // result: (Or32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpOr32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpOr32) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Or32 (And32 x (Const32 [c2])) (Const32 [c1])) + // cond: ^(c1 | c2) == 0 + // result: (Or32 (Const32 [c1]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd32 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst32 { + continue + } + c2 := auxIntToInt32(v_0_1.AuxInt) + if v_1.Op != OpConst32 { + continue + } + t := v_1.Type + c1 := auxIntToInt32(v_1.AuxInt) + if !(^(c1 | c2) == 0) { + continue + } + v.reset(OpOr32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c1) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Or32 (Or32 i:(Const32 ) z) x) + // cond: (z.Op != OpConst32 && x.Op != OpConst32) + // result: (Or32 i (Or32 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOr32 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst32 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst32 && x.Op != OpConst32) { + continue + } + v.reset(OpOr32) + v0 := b.NewValue0(v.Pos, OpOr32, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Or32 (Const32 [c]) (Or32 (Const32 [d]) x)) + // result: (Or32 (Const32 [c|d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpOr32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + continue + } + d := auxIntToInt32(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpOr32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c | d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Or32 (Lsh32x64 x z:(Const64 [c])) (Rsh32Ux64 x (Const64 [d]))) + // cond: c < 32 && d == 32-c && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh32x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh32Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 32 && d == 32-c && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or32 left:(Lsh32x64 x y) right:(Rsh32Ux64 x (Sub64 (Const64 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or32 left:(Lsh32x32 x y) right:(Rsh32Ux32 x (Sub32 (Const32 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or32 left:(Lsh32x16 x y) right:(Rsh32Ux16 x (Sub16 (Const16 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or32 left:(Lsh32x8 x y) right:(Rsh32Ux8 x (Sub8 (Const8 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or32 right:(Rsh32Ux64 x y) left:(Lsh32x64 x z:(Sub64 (Const64 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or32 right:(Rsh32Ux32 x y) left:(Lsh32x32 x z:(Sub32 (Const32 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or32 right:(Rsh32Ux16 x y) left:(Lsh32x16 x z:(Sub16 (Const16 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or32 right:(Rsh32Ux8 x y) left:(Lsh32x8 x z:(Sub8 (Const8 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpOr64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Or64 (Const64 [c]) (Const64 [d])) + // result: (Const64 [c|d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c | d) + return true + } + break + } + // match: (Or64 (Com64 x) (Com64 y)) + // result: (Com64 (And64 x y)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom64 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpCom64 { + continue + } + y := v_1.Args[0] + v.reset(OpCom64) + v0 := b.NewValue0(v.Pos, OpAnd64, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (Or64 x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (Or64 (Const64 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Or64 (Const64 [-1]) _) + // result: (Const64 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != -1 { + continue + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(-1) + return true + } + break + } + // match: (Or64 (Com64 x) x) + // result: (Const64 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom64 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(-1) + return true + } + break + } + // match: (Or64 x (Or64 x y)) + // result: (Or64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpOr64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpOr64) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Or64 (And64 x (Const64 [c2])) (Const64 [c1])) + // cond: ^(c1 | c2) == 0 + // result: (Or64 (Const64 [c1]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd64 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst64 { + continue + } + c2 := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + continue + } + t := v_1.Type + c1 := auxIntToInt64(v_1.AuxInt) + if !(^(c1 | c2) == 0) { + continue + } + v.reset(OpOr64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c1) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Or64 (Or64 i:(Const64 ) z) x) + // cond: (z.Op != OpConst64 && x.Op != OpConst64) + // result: (Or64 i (Or64 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOr64 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst64 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst64 && x.Op != OpConst64) { + continue + } + v.reset(OpOr64) + v0 := b.NewValue0(v.Pos, OpOr64, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Or64 (Const64 [c]) (Or64 (Const64 [d]) x)) + // result: (Or64 (Const64 [c|d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpOr64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + continue + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpOr64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c | d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Or64 (Lsh64x64 x z:(Const64 [c])) (Rsh64Ux64 x (Const64 [d]))) + // cond: c < 64 && d == 64-c && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh64x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh64Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 64 && d == 64-c && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or64 left:(Lsh64x64 x y) right:(Rsh64Ux64 x (Sub64 (Const64 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or64 left:(Lsh64x32 x y) right:(Rsh64Ux32 x (Sub32 (Const32 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or64 left:(Lsh64x16 x y) right:(Rsh64Ux16 x (Sub16 (Const16 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or64 left:(Lsh64x8 x y) right:(Rsh64Ux8 x (Sub8 (Const8 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or64 right:(Rsh64Ux64 x y) left:(Lsh64x64 x z:(Sub64 (Const64 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or64 right:(Rsh64Ux32 x y) left:(Lsh64x32 x z:(Sub32 (Const32 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or64 right:(Rsh64Ux16 x y) left:(Lsh64x16 x z:(Sub16 (Const16 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or64 right:(Rsh64Ux8 x y) left:(Lsh64x8 x z:(Sub8 (Const8 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpOr8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Or8 (Const8 [c]) (Const8 [d])) + // result: (Const8 [c|d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c | d) + return true + } + break + } + // match: (Or8 (Com8 x) (Com8 y)) + // result: (Com8 (And8 x y)) + for { + t := v.Type + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom8 { + continue + } + x := v_0.Args[0] + if v_1.Op != OpCom8 { + continue + } + y := v_1.Args[0] + v.reset(OpCom8) + v0 := b.NewValue0(v.Pos, OpAnd8, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (Or8 x x) + // result: x + for { + x := v_0 + if x != v_1 { + break + } + v.copyOf(x) + return true + } + // match: (Or8 (Const8 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Or8 (Const8 [-1]) _) + // result: (Const8 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != -1 { + continue + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(-1) + return true + } + break + } + // match: (Or8 (Com8 x) x) + // result: (Const8 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom8 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(-1) + return true + } + break + } + // match: (Or8 x (Or8 x y)) + // result: (Or8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpOr8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpOr8) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Or8 (And8 x (Const8 [c2])) (Const8 [c1])) + // cond: ^(c1 | c2) == 0 + // result: (Or8 (Const8 [c1]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpAnd8 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + if v_0_1.Op != OpConst8 { + continue + } + c2 := auxIntToInt8(v_0_1.AuxInt) + if v_1.Op != OpConst8 { + continue + } + t := v_1.Type + c1 := auxIntToInt8(v_1.AuxInt) + if !(^(c1 | c2) == 0) { + continue + } + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c1) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Or8 (Or8 i:(Const8 ) z) x) + // cond: (z.Op != OpConst8 && x.Op != OpConst8) + // result: (Or8 i (Or8 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpOr8 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst8 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst8 && x.Op != OpConst8) { + continue + } + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpOr8, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Or8 (Const8 [c]) (Or8 (Const8 [d]) x)) + // result: (Or8 (Const8 [c|d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpOr8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + continue + } + d := auxIntToInt8(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpOr8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c | d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Or8 (Lsh8x64 x z:(Const64 [c])) (Rsh8Ux64 x (Const64 [d]))) + // cond: c < 8 && d == 8-c && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh8x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh8Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 8 && d == 8-c && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or8 left:(Lsh8x64 x y) right:(Rsh8Ux64 x (Sub64 (Const64 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or8 left:(Lsh8x32 x y) right:(Rsh8Ux32 x (Sub32 (Const32 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or8 left:(Lsh8x16 x y) right:(Rsh8Ux16 x (Sub16 (Const16 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or8 left:(Lsh8x8 x y) right:(Rsh8Ux8 x (Sub8 (Const8 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Or8 right:(Rsh8Ux64 x y) left:(Lsh8x64 x z:(Sub64 (Const64 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or8 right:(Rsh8Ux32 x y) left:(Lsh8x32 x z:(Sub32 (Const32 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or8 right:(Rsh8Ux16 x y) left:(Lsh8x16 x z:(Sub16 (Const16 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Or8 right:(Rsh8Ux8 x y) left:(Lsh8x8 x z:(Sub8 (Const8 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpOrB(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (OrB (Less64 (Const64 [c]) x) (Less64 x (Const64 [d]))) + // cond: c >= d + // result: (Less64U (Const64 [c-d]) (Sub64 x (Const64 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess64 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLess64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c >= d) { + continue + } + v.reset(OpLess64U) + v0 := b.NewValue0(v.Pos, OpConst64, x.Type) + v0.AuxInt = int64ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub64, x.Type) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq64 (Const64 [c]) x) (Less64 x (Const64 [d]))) + // cond: c >= d + // result: (Leq64U (Const64 [c-d]) (Sub64 x (Const64 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq64 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLess64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c >= d) { + continue + } + v.reset(OpLeq64U) + v0 := b.NewValue0(v.Pos, OpConst64, x.Type) + v0.AuxInt = int64ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub64, x.Type) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less32 (Const32 [c]) x) (Less32 x (Const32 [d]))) + // cond: c >= d + // result: (Less32U (Const32 [c-d]) (Sub32 x (Const32 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess32 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLess32 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(c >= d) { + continue + } + v.reset(OpLess32U) + v0 := b.NewValue0(v.Pos, OpConst32, x.Type) + v0.AuxInt = int32ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub32, x.Type) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq32 (Const32 [c]) x) (Less32 x (Const32 [d]))) + // cond: c >= d + // result: (Leq32U (Const32 [c-d]) (Sub32 x (Const32 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq32 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLess32 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(c >= d) { + continue + } + v.reset(OpLeq32U) + v0 := b.NewValue0(v.Pos, OpConst32, x.Type) + v0.AuxInt = int32ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub32, x.Type) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less16 (Const16 [c]) x) (Less16 x (Const16 [d]))) + // cond: c >= d + // result: (Less16U (Const16 [c-d]) (Sub16 x (Const16 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess16 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLess16 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(c >= d) { + continue + } + v.reset(OpLess16U) + v0 := b.NewValue0(v.Pos, OpConst16, x.Type) + v0.AuxInt = int16ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub16, x.Type) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq16 (Const16 [c]) x) (Less16 x (Const16 [d]))) + // cond: c >= d + // result: (Leq16U (Const16 [c-d]) (Sub16 x (Const16 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq16 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLess16 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(c >= d) { + continue + } + v.reset(OpLeq16U) + v0 := b.NewValue0(v.Pos, OpConst16, x.Type) + v0.AuxInt = int16ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub16, x.Type) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less8 (Const8 [c]) x) (Less8 x (Const8 [d]))) + // cond: c >= d + // result: (Less8U (Const8 [c-d]) (Sub8 x (Const8 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess8 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLess8 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(c >= d) { + continue + } + v.reset(OpLess8U) + v0 := b.NewValue0(v.Pos, OpConst8, x.Type) + v0.AuxInt = int8ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub8, x.Type) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq8 (Const8 [c]) x) (Less8 x (Const8 [d]))) + // cond: c >= d + // result: (Leq8U (Const8 [c-d]) (Sub8 x (Const8 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq8 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLess8 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(c >= d) { + continue + } + v.reset(OpLeq8U) + v0 := b.NewValue0(v.Pos, OpConst8, x.Type) + v0.AuxInt = int8ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub8, x.Type) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less64 (Const64 [c]) x) (Leq64 x (Const64 [d]))) + // cond: c >= d+1 && d+1 > d + // result: (Less64U (Const64 [c-d-1]) (Sub64 x (Const64 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess64 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLeq64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c >= d+1 && d+1 > d) { + continue + } + v.reset(OpLess64U) + v0 := b.NewValue0(v.Pos, OpConst64, x.Type) + v0.AuxInt = int64ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub64, x.Type) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq64 (Const64 [c]) x) (Leq64 x (Const64 [d]))) + // cond: c >= d+1 && d+1 > d + // result: (Leq64U (Const64 [c-d-1]) (Sub64 x (Const64 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq64 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLeq64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c >= d+1 && d+1 > d) { + continue + } + v.reset(OpLeq64U) + v0 := b.NewValue0(v.Pos, OpConst64, x.Type) + v0.AuxInt = int64ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub64, x.Type) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less32 (Const32 [c]) x) (Leq32 x (Const32 [d]))) + // cond: c >= d+1 && d+1 > d + // result: (Less32U (Const32 [c-d-1]) (Sub32 x (Const32 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess32 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLeq32 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(c >= d+1 && d+1 > d) { + continue + } + v.reset(OpLess32U) + v0 := b.NewValue0(v.Pos, OpConst32, x.Type) + v0.AuxInt = int32ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub32, x.Type) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq32 (Const32 [c]) x) (Leq32 x (Const32 [d]))) + // cond: c >= d+1 && d+1 > d + // result: (Leq32U (Const32 [c-d-1]) (Sub32 x (Const32 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq32 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLeq32 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(c >= d+1 && d+1 > d) { + continue + } + v.reset(OpLeq32U) + v0 := b.NewValue0(v.Pos, OpConst32, x.Type) + v0.AuxInt = int32ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub32, x.Type) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less16 (Const16 [c]) x) (Leq16 x (Const16 [d]))) + // cond: c >= d+1 && d+1 > d + // result: (Less16U (Const16 [c-d-1]) (Sub16 x (Const16 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess16 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLeq16 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(c >= d+1 && d+1 > d) { + continue + } + v.reset(OpLess16U) + v0 := b.NewValue0(v.Pos, OpConst16, x.Type) + v0.AuxInt = int16ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub16, x.Type) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq16 (Const16 [c]) x) (Leq16 x (Const16 [d]))) + // cond: c >= d+1 && d+1 > d + // result: (Leq16U (Const16 [c-d-1]) (Sub16 x (Const16 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq16 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLeq16 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(c >= d+1 && d+1 > d) { + continue + } + v.reset(OpLeq16U) + v0 := b.NewValue0(v.Pos, OpConst16, x.Type) + v0.AuxInt = int16ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub16, x.Type) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less8 (Const8 [c]) x) (Leq8 x (Const8 [d]))) + // cond: c >= d+1 && d+1 > d + // result: (Less8U (Const8 [c-d-1]) (Sub8 x (Const8 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess8 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLeq8 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(c >= d+1 && d+1 > d) { + continue + } + v.reset(OpLess8U) + v0 := b.NewValue0(v.Pos, OpConst8, x.Type) + v0.AuxInt = int8ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub8, x.Type) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq8 (Const8 [c]) x) (Leq8 x (Const8 [d]))) + // cond: c >= d+1 && d+1 > d + // result: (Leq8U (Const8 [c-d-1]) (Sub8 x (Const8 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq8 { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLeq8 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(c >= d+1 && d+1 > d) { + continue + } + v.reset(OpLeq8U) + v0 := b.NewValue0(v.Pos, OpConst8, x.Type) + v0.AuxInt = int8ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub8, x.Type) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less64U (Const64 [c]) x) (Less64U x (Const64 [d]))) + // cond: uint64(c) >= uint64(d) + // result: (Less64U (Const64 [c-d]) (Sub64 x (Const64 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess64U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLess64U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(uint64(c) >= uint64(d)) { + continue + } + v.reset(OpLess64U) + v0 := b.NewValue0(v.Pos, OpConst64, x.Type) + v0.AuxInt = int64ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub64, x.Type) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq64U (Const64 [c]) x) (Less64U x (Const64 [d]))) + // cond: uint64(c) >= uint64(d) + // result: (Leq64U (Const64 [c-d]) (Sub64 x (Const64 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq64U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLess64U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(uint64(c) >= uint64(d)) { + continue + } + v.reset(OpLeq64U) + v0 := b.NewValue0(v.Pos, OpConst64, x.Type) + v0.AuxInt = int64ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub64, x.Type) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less32U (Const32 [c]) x) (Less32U x (Const32 [d]))) + // cond: uint32(c) >= uint32(d) + // result: (Less32U (Const32 [c-d]) (Sub32 x (Const32 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess32U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLess32U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(uint32(c) >= uint32(d)) { + continue + } + v.reset(OpLess32U) + v0 := b.NewValue0(v.Pos, OpConst32, x.Type) + v0.AuxInt = int32ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub32, x.Type) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq32U (Const32 [c]) x) (Less32U x (Const32 [d]))) + // cond: uint32(c) >= uint32(d) + // result: (Leq32U (Const32 [c-d]) (Sub32 x (Const32 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq32U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLess32U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(uint32(c) >= uint32(d)) { + continue + } + v.reset(OpLeq32U) + v0 := b.NewValue0(v.Pos, OpConst32, x.Type) + v0.AuxInt = int32ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub32, x.Type) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less16U (Const16 [c]) x) (Less16U x (Const16 [d]))) + // cond: uint16(c) >= uint16(d) + // result: (Less16U (Const16 [c-d]) (Sub16 x (Const16 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess16U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLess16U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(uint16(c) >= uint16(d)) { + continue + } + v.reset(OpLess16U) + v0 := b.NewValue0(v.Pos, OpConst16, x.Type) + v0.AuxInt = int16ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub16, x.Type) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq16U (Const16 [c]) x) (Less16U x (Const16 [d]))) + // cond: uint16(c) >= uint16(d) + // result: (Leq16U (Const16 [c-d]) (Sub16 x (Const16 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq16U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLess16U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(uint16(c) >= uint16(d)) { + continue + } + v.reset(OpLeq16U) + v0 := b.NewValue0(v.Pos, OpConst16, x.Type) + v0.AuxInt = int16ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub16, x.Type) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less8U (Const8 [c]) x) (Less8U x (Const8 [d]))) + // cond: uint8(c) >= uint8(d) + // result: (Less8U (Const8 [c-d]) (Sub8 x (Const8 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess8U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLess8U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(uint8(c) >= uint8(d)) { + continue + } + v.reset(OpLess8U) + v0 := b.NewValue0(v.Pos, OpConst8, x.Type) + v0.AuxInt = int8ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub8, x.Type) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq8U (Const8 [c]) x) (Less8U x (Const8 [d]))) + // cond: uint8(c) >= uint8(d) + // result: (Leq8U (Const8 [c-d]) (Sub8 x (Const8 [d]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq8U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLess8U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(uint8(c) >= uint8(d)) { + continue + } + v.reset(OpLeq8U) + v0 := b.NewValue0(v.Pos, OpConst8, x.Type) + v0.AuxInt = int8ToAuxInt(c - d) + v1 := b.NewValue0(v.Pos, OpSub8, x.Type) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less64U (Const64 [c]) x) (Leq64U x (Const64 [d]))) + // cond: uint64(c) >= uint64(d+1) && uint64(d+1) > uint64(d) + // result: (Less64U (Const64 [c-d-1]) (Sub64 x (Const64 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess64U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLeq64U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(uint64(c) >= uint64(d+1) && uint64(d+1) > uint64(d)) { + continue + } + v.reset(OpLess64U) + v0 := b.NewValue0(v.Pos, OpConst64, x.Type) + v0.AuxInt = int64ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub64, x.Type) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq64U (Const64 [c]) x) (Leq64U x (Const64 [d]))) + // cond: uint64(c) >= uint64(d+1) && uint64(d+1) > uint64(d) + // result: (Leq64U (Const64 [c-d-1]) (Sub64 x (Const64 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq64U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0_0.AuxInt) + if v_1.Op != OpLeq64U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(uint64(c) >= uint64(d+1) && uint64(d+1) > uint64(d)) { + continue + } + v.reset(OpLeq64U) + v0 := b.NewValue0(v.Pos, OpConst64, x.Type) + v0.AuxInt = int64ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub64, x.Type) + v2 := b.NewValue0(v.Pos, OpConst64, x.Type) + v2.AuxInt = int64ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less32U (Const32 [c]) x) (Leq32U x (Const32 [d]))) + // cond: uint32(c) >= uint32(d+1) && uint32(d+1) > uint32(d) + // result: (Less32U (Const32 [c-d-1]) (Sub32 x (Const32 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess32U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLeq32U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(uint32(c) >= uint32(d+1) && uint32(d+1) > uint32(d)) { + continue + } + v.reset(OpLess32U) + v0 := b.NewValue0(v.Pos, OpConst32, x.Type) + v0.AuxInt = int32ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub32, x.Type) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq32U (Const32 [c]) x) (Leq32U x (Const32 [d]))) + // cond: uint32(c) >= uint32(d+1) && uint32(d+1) > uint32(d) + // result: (Leq32U (Const32 [c-d-1]) (Sub32 x (Const32 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq32U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0_0.AuxInt) + if v_1.Op != OpLeq32U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(uint32(c) >= uint32(d+1) && uint32(d+1) > uint32(d)) { + continue + } + v.reset(OpLeq32U) + v0 := b.NewValue0(v.Pos, OpConst32, x.Type) + v0.AuxInt = int32ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub32, x.Type) + v2 := b.NewValue0(v.Pos, OpConst32, x.Type) + v2.AuxInt = int32ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less16U (Const16 [c]) x) (Leq16U x (Const16 [d]))) + // cond: uint16(c) >= uint16(d+1) && uint16(d+1) > uint16(d) + // result: (Less16U (Const16 [c-d-1]) (Sub16 x (Const16 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess16U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLeq16U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(uint16(c) >= uint16(d+1) && uint16(d+1) > uint16(d)) { + continue + } + v.reset(OpLess16U) + v0 := b.NewValue0(v.Pos, OpConst16, x.Type) + v0.AuxInt = int16ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub16, x.Type) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq16U (Const16 [c]) x) (Leq16U x (Const16 [d]))) + // cond: uint16(c) >= uint16(d+1) && uint16(d+1) > uint16(d) + // result: (Leq16U (Const16 [c-d-1]) (Sub16 x (Const16 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq16U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0_0.AuxInt) + if v_1.Op != OpLeq16U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(uint16(c) >= uint16(d+1) && uint16(d+1) > uint16(d)) { + continue + } + v.reset(OpLeq16U) + v0 := b.NewValue0(v.Pos, OpConst16, x.Type) + v0.AuxInt = int16ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub16, x.Type) + v2 := b.NewValue0(v.Pos, OpConst16, x.Type) + v2.AuxInt = int16ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Less8U (Const8 [c]) x) (Leq8U x (Const8 [d]))) + // cond: uint8(c) >= uint8(d+1) && uint8(d+1) > uint8(d) + // result: (Less8U (Const8 [c-d-1]) (Sub8 x (Const8 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLess8U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLeq8U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(uint8(c) >= uint8(d+1) && uint8(d+1) > uint8(d)) { + continue + } + v.reset(OpLess8U) + v0 := b.NewValue0(v.Pos, OpConst8, x.Type) + v0.AuxInt = int8ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub8, x.Type) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Leq8U (Const8 [c]) x) (Leq8U x (Const8 [d]))) + // cond: uint8(c) >= uint8(d+1) && uint8(d+1) > uint8(d) + // result: (Leq8U (Const8 [c-d-1]) (Sub8 x (Const8 [d+1]))) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLeq8U { + continue + } + x := v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0_0.AuxInt) + if v_1.Op != OpLeq8U { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(uint8(c) >= uint8(d+1) && uint8(d+1) > uint8(d)) { + continue + } + v.reset(OpLeq8U) + v0 := b.NewValue0(v.Pos, OpConst8, x.Type) + v0.AuxInt = int8ToAuxInt(c - d - 1) + v1 := b.NewValue0(v.Pos, OpSub8, x.Type) + v2 := b.NewValue0(v.Pos, OpConst8, x.Type) + v2.AuxInt = int8ToAuxInt(d + 1) + v1.AddArg2(x, v2) + v.AddArg2(v0, v1) + return true + } + break + } + // match: (OrB (Eq64 x cv:(Const64 [c])) (Eq64 x (Const64 [d]))) + // cond: c|d == c && oneBit(c^d) + // result: (Eq64 (Or64 x (Const64 [c^d])) cv) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpEq64 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + cv := v_0_1 + if cv.Op != OpConst64 { + continue + } + c := auxIntToInt64(cv.AuxInt) + if v_1.Op != OpEq64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 || v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c|d == c && oneBit(c^d)) { + continue + } + v.reset(OpEq64) + v0 := b.NewValue0(v.Pos, OpOr64, x.Type) + v1 := b.NewValue0(v.Pos, OpConst64, x.Type) + v1.AuxInt = int64ToAuxInt(c ^ d) + v0.AddArg2(x, v1) + v.AddArg2(v0, cv) + return true + } + } + } + break + } + // match: (OrB (Eq32 x cv:(Const32 [c])) (Eq32 x (Const32 [d]))) + // cond: c|d == c && oneBit(c^d) + // result: (Eq32 (Or32 x (Const32 [c^d])) cv) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpEq32 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + cv := v_0_1 + if cv.Op != OpConst32 { + continue + } + c := auxIntToInt32(cv.AuxInt) + if v_1.Op != OpEq32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 || v_1_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1_1.AuxInt) + if !(c|d == c && oneBit(c^d)) { + continue + } + v.reset(OpEq32) + v0 := b.NewValue0(v.Pos, OpOr32, x.Type) + v1 := b.NewValue0(v.Pos, OpConst32, x.Type) + v1.AuxInt = int32ToAuxInt(c ^ d) + v0.AddArg2(x, v1) + v.AddArg2(v0, cv) + return true + } + } + } + break + } + // match: (OrB (Eq16 x cv:(Const16 [c])) (Eq16 x (Const16 [d]))) + // cond: c|d == c && oneBit(c^d) + // result: (Eq16 (Or16 x (Const16 [c^d])) cv) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpEq16 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + cv := v_0_1 + if cv.Op != OpConst16 { + continue + } + c := auxIntToInt16(cv.AuxInt) + if v_1.Op != OpEq16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 || v_1_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1_1.AuxInt) + if !(c|d == c && oneBit(c^d)) { + continue + } + v.reset(OpEq16) + v0 := b.NewValue0(v.Pos, OpOr16, x.Type) + v1 := b.NewValue0(v.Pos, OpConst16, x.Type) + v1.AuxInt = int16ToAuxInt(c ^ d) + v0.AddArg2(x, v1) + v.AddArg2(v0, cv) + return true + } + } + } + break + } + // match: (OrB (Eq8 x cv:(Const8 [c])) (Eq8 x (Const8 [d]))) + // cond: c|d == c && oneBit(c^d) + // result: (Eq8 (Or8 x (Const8 [c^d])) cv) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpEq8 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + x := v_0_0 + cv := v_0_1 + if cv.Op != OpConst8 { + continue + } + c := auxIntToInt8(cv.AuxInt) + if v_1.Op != OpEq8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { + if x != v_1_0 || v_1_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1_1.AuxInt) + if !(c|d == c && oneBit(c^d)) { + continue + } + v.reset(OpEq8) + v0 := b.NewValue0(v.Pos, OpOr8, x.Type) + v1 := b.NewValue0(v.Pos, OpConst8, x.Type) + v1.AuxInt = int8ToAuxInt(c ^ d) + v0.AddArg2(x, v1) + v.AddArg2(v0, cv) + return true + } + } + } + break + } + // match: (OrB (Neq64F x x) (Less64F x y:(Const64F [c]))) + // result: (Not (Leq64F y x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLess64F { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + y := v_1.Args[1] + if y.Op != OpConst64F { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLeq64F, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Leq64F x y:(Const64F [c]))) + // result: (Not (Less64F y x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLeq64F { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + y := v_1.Args[1] + if y.Op != OpConst64F { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess64F, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Less64F y:(Const64F [c]) x)) + // result: (Not (Leq64F x y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLess64F { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if y.Op != OpConst64F { + continue + } + if x != v_1.Args[1] { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLeq64F, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Leq64F y:(Const64F [c]) x)) + // result: (Not (Less64F x y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLeq64F { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if y.Op != OpConst64F { + continue + } + if x != v_1.Args[1] { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess64F, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq32F x x) (Less32F x y:(Const32F [c]))) + // result: (Not (Leq32F y x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq32F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLess32F { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + y := v_1.Args[1] + if y.Op != OpConst32F { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLeq32F, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq32F x x) (Leq32F x y:(Const32F [c]))) + // result: (Not (Less32F y x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq32F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLeq32F { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + y := v_1.Args[1] + if y.Op != OpConst32F { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess32F, typ.Bool) + v0.AddArg2(y, x) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq32F x x) (Less32F y:(Const32F [c]) x)) + // result: (Not (Leq32F x y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq32F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLess32F { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if y.Op != OpConst32F { + continue + } + if x != v_1.Args[1] { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLeq32F, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq32F x x) (Leq32F y:(Const32F [c]) x)) + // result: (Not (Less32F x y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq32F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLeq32F { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if y.Op != OpConst32F { + continue + } + if x != v_1.Args[1] { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess32F, typ.Bool) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Less64F abs:(Abs x) y:(Const64F [c]))) + // result: (Not (Leq64F y abs)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLess64F { + continue + } + _ = v_1.Args[1] + abs := v_1.Args[0] + if abs.Op != OpAbs || x != abs.Args[0] { + continue + } + y := v_1.Args[1] + if y.Op != OpConst64F { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLeq64F, typ.Bool) + v0.AddArg2(y, abs) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Leq64F abs:(Abs x) y:(Const64F [c]))) + // result: (Not (Less64F y abs)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLeq64F { + continue + } + _ = v_1.Args[1] + abs := v_1.Args[0] + if abs.Op != OpAbs || x != abs.Args[0] { + continue + } + y := v_1.Args[1] + if y.Op != OpConst64F { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess64F, typ.Bool) + v0.AddArg2(y, abs) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Less64F y:(Const64F [c]) abs:(Abs x))) + // result: (Not (Leq64F abs y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLess64F { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if y.Op != OpConst64F { + continue + } + abs := v_1.Args[1] + if abs.Op != OpAbs || x != abs.Args[0] { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLeq64F, typ.Bool) + v0.AddArg2(abs, y) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Leq64F y:(Const64F [c]) abs:(Abs x))) + // result: (Not (Less64F abs y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLeq64F { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if y.Op != OpConst64F { + continue + } + abs := v_1.Args[1] + if abs.Op != OpAbs || x != abs.Args[0] { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess64F, typ.Bool) + v0.AddArg2(abs, y) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Less64F neg:(Neg64F x) y:(Const64F [c]))) + // result: (Not (Leq64F y neg)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLess64F { + continue + } + _ = v_1.Args[1] + neg := v_1.Args[0] + if neg.Op != OpNeg64F || x != neg.Args[0] { + continue + } + y := v_1.Args[1] + if y.Op != OpConst64F { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLeq64F, typ.Bool) + v0.AddArg2(y, neg) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Leq64F neg:(Neg64F x) y:(Const64F [c]))) + // result: (Not (Less64F y neg)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLeq64F { + continue + } + _ = v_1.Args[1] + neg := v_1.Args[0] + if neg.Op != OpNeg64F || x != neg.Args[0] { + continue + } + y := v_1.Args[1] + if y.Op != OpConst64F { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess64F, typ.Bool) + v0.AddArg2(y, neg) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Less64F y:(Const64F [c]) neg:(Neg64F x))) + // result: (Not (Leq64F neg y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLess64F { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if y.Op != OpConst64F { + continue + } + neg := v_1.Args[1] + if neg.Op != OpNeg64F || x != neg.Args[0] { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLeq64F, typ.Bool) + v0.AddArg2(neg, y) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq64F x x) (Leq64F y:(Const64F [c]) neg:(Neg64F x))) + // result: (Not (Less64F neg y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq64F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLeq64F { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if y.Op != OpConst64F { + continue + } + neg := v_1.Args[1] + if neg.Op != OpNeg64F || x != neg.Args[0] { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess64F, typ.Bool) + v0.AddArg2(neg, y) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq32F x x) (Less32F neg:(Neg32F x) y:(Const32F [c]))) + // result: (Not (Leq32F y neg)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq32F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLess32F { + continue + } + _ = v_1.Args[1] + neg := v_1.Args[0] + if neg.Op != OpNeg32F || x != neg.Args[0] { + continue + } + y := v_1.Args[1] + if y.Op != OpConst32F { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLeq32F, typ.Bool) + v0.AddArg2(y, neg) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq32F x x) (Leq32F neg:(Neg32F x) y:(Const32F [c]))) + // result: (Not (Less32F y neg)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq32F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLeq32F { + continue + } + _ = v_1.Args[1] + neg := v_1.Args[0] + if neg.Op != OpNeg32F || x != neg.Args[0] { + continue + } + y := v_1.Args[1] + if y.Op != OpConst32F { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess32F, typ.Bool) + v0.AddArg2(y, neg) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq32F x x) (Less32F y:(Const32F [c]) neg:(Neg32F x))) + // result: (Not (Leq32F neg y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq32F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLess32F { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if y.Op != OpConst32F { + continue + } + neg := v_1.Args[1] + if neg.Op != OpNeg32F || x != neg.Args[0] { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLeq32F, typ.Bool) + v0.AddArg2(neg, y) + v.AddArg(v0) + return true + } + break + } + // match: (OrB (Neq32F x x) (Leq32F y:(Const32F [c]) neg:(Neg32F x))) + // result: (Not (Less32F neg y)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpNeq32F { + continue + } + x := v_0.Args[1] + if x != v_0.Args[0] || v_1.Op != OpLeq32F { + continue + } + _ = v_1.Args[1] + y := v_1.Args[0] + if y.Op != OpConst32F { + continue + } + neg := v_1.Args[1] + if neg.Op != OpNeg32F || x != neg.Args[0] { + continue + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpLess32F, typ.Bool) + v0.AddArg2(neg, y) + v.AddArg(v0) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpPhi(v *Value) bool { + b := v.Block + // match: (Phi (Const8 [c]) (Const8 [c])) + // result: (Const8 [c]) + for { + if len(v.Args) != 2 { + break + } + _ = v.Args[1] + v_0 := v.Args[0] + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + v_1 := v.Args[1] + if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != c { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c) + return true + } + // match: (Phi (Const16 [c]) (Const16 [c])) + // result: (Const16 [c]) + for { + if len(v.Args) != 2 { + break + } + _ = v.Args[1] + v_0 := v.Args[0] + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + v_1 := v.Args[1] + if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != c { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c) + return true + } + // match: (Phi (Const32 [c]) (Const32 [c])) + // result: (Const32 [c]) + for { + if len(v.Args) != 2 { + break + } + _ = v.Args[1] + v_0 := v.Args[0] + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + v_1 := v.Args[1] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != c { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c) + return true + } + // match: (Phi (Const64 [c]) (Const64 [c])) + // result: (Const64 [c]) + for { + if len(v.Args) != 2 { + break + } + _ = v.Args[1] + v_0 := v.Args[0] + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + v_1 := v.Args[1] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c) + return true + } + // match: (Phi nx:(Not x) ny:(Not y)) + // cond: nx.Uses == 1 && ny.Uses == 1 + // result: (Not (Phi x y)) + for { + if len(v.Args) != 2 { + break + } + t := v.Type + _ = v.Args[1] + nx := v.Args[0] + if nx.Op != OpNot { + break + } + x := nx.Args[0] + ny := v.Args[1] + if ny.Op != OpNot { + break + } + y := ny.Args[0] + if !(nx.Uses == 1 && ny.Uses == 1) { + break + } + v.reset(OpNot) + v0 := b.NewValue0(v.Pos, OpPhi, t) + v0.AddArg2(x, y) + v.AddArg(v0) + return true + } + return false +} +func rewriteValuegeneric_OpPopCount16(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (PopCount16 (Const16 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(bits.OnesCount16(uint16(c)))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(bits.OnesCount16(uint16(c)))) + return true + } + // match: (PopCount16 (Const16 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(bits.OnesCount16(uint16(c)))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(bits.OnesCount16(uint16(c)))) + return true + } + return false +} +func rewriteValuegeneric_OpPopCount32(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (PopCount32 (Const32 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(bits.OnesCount32(uint32(c)))]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(bits.OnesCount32(uint32(c)))) + return true + } + // match: (PopCount32 (Const32 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(bits.OnesCount32(uint32(c)))]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(bits.OnesCount32(uint32(c)))) + return true + } + return false +} +func rewriteValuegeneric_OpPopCount64(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (PopCount64 (Const64 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(bits.OnesCount64(uint64(c)))]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(bits.OnesCount64(uint64(c)))) + return true + } + // match: (PopCount64 (Const64 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(bits.OnesCount64(uint64(c)))]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(bits.OnesCount64(uint64(c)))) + return true + } + return false +} +func rewriteValuegeneric_OpPopCount8(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (PopCount8 (Const8 [c])) + // cond: config.PtrSize == 8 + // result: (Const64 [int64(bits.OnesCount8(uint8(c)))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if !(config.PtrSize == 8) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(bits.OnesCount8(uint8(c)))) + return true + } + // match: (PopCount8 (Const8 [c])) + // cond: config.PtrSize == 4 + // result: (Const32 [int32(bits.OnesCount8(uint8(c)))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(bits.OnesCount8(uint8(c)))) + return true + } + return false +} +func rewriteValuegeneric_OpPtrIndex(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (PtrIndex ptr idx) + // cond: config.PtrSize == 4 && is32Bit(t.Elem().Size()) + // result: (AddPtr ptr (Mul32 idx (Const32 [int32(t.Elem().Size())]))) + for { + t := v.Type + ptr := v_0 + idx := v_1 + if !(config.PtrSize == 4 && is32Bit(t.Elem().Size())) { + break + } + v.reset(OpAddPtr) + v0 := b.NewValue0(v.Pos, OpMul32, typ.Int) + v1 := b.NewValue0(v.Pos, OpConst32, typ.Int) + v1.AuxInt = int32ToAuxInt(int32(t.Elem().Size())) + v0.AddArg2(idx, v1) + v.AddArg2(ptr, v0) + return true + } + // match: (PtrIndex ptr idx) + // cond: config.PtrSize == 8 + // result: (AddPtr ptr (Mul64 idx (Const64 [t.Elem().Size()]))) + for { + t := v.Type + ptr := v_0 + idx := v_1 + if !(config.PtrSize == 8) { + break + } + v.reset(OpAddPtr) + v0 := b.NewValue0(v.Pos, OpMul64, typ.Int) + v1 := b.NewValue0(v.Pos, OpConst64, typ.Int) + v1.AuxInt = int64ToAuxInt(t.Elem().Size()) + v0.AddArg2(idx, v1) + v.AddArg2(ptr, v0) + return true + } + return false +} +func rewriteValuegeneric_OpRotateLeft16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (RotateLeft16 x (Const16 [c])) + // cond: c%16 == 0 + // result: x + for { + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + if !(c%16 == 0) { + break + } + v.copyOf(x) + return true + } + // match: (RotateLeft16 x (And64 y (Const64 [c]))) + // cond: c&15 == 15 + // result: (RotateLeft16 x y) + for { + x := v_0 + if v_1.Op != OpAnd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c&15 == 15) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft16 x (And32 y (Const32 [c]))) + // cond: c&15 == 15 + // result: (RotateLeft16 x y) + for { + x := v_0 + if v_1.Op != OpAnd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_1.AuxInt) + if !(c&15 == 15) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft16 x (And16 y (Const16 [c]))) + // cond: c&15 == 15 + // result: (RotateLeft16 x y) + for { + x := v_0 + if v_1.Op != OpAnd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_1.AuxInt) + if !(c&15 == 15) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft16 x (And8 y (Const8 [c]))) + // cond: c&15 == 15 + // result: (RotateLeft16 x y) + for { + x := v_0 + if v_1.Op != OpAnd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_1.AuxInt) + if !(c&15 == 15) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft16 x (Neg64 (And64 y (Const64 [c])))) + // cond: c&15 == 15 + // result: (RotateLeft16 x (Neg64 y)) + for { + x := v_0 + if v_1.Op != OpNeg64 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd64 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_0_1.AuxInt) + if !(c&15 == 15) { + continue + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpNeg64, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft16 x (Neg32 (And32 y (Const32 [c])))) + // cond: c&15 == 15 + // result: (RotateLeft16 x (Neg32 y)) + for { + x := v_0 + if v_1.Op != OpNeg32 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd32 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_0_1.AuxInt) + if !(c&15 == 15) { + continue + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpNeg32, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft16 x (Neg16 (And16 y (Const16 [c])))) + // cond: c&15 == 15 + // result: (RotateLeft16 x (Neg16 y)) + for { + x := v_0 + if v_1.Op != OpNeg16 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd16 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_0_1.AuxInt) + if !(c&15 == 15) { + continue + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpNeg16, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft16 x (Neg8 (And8 y (Const8 [c])))) + // cond: c&15 == 15 + // result: (RotateLeft16 x (Neg8 y)) + for { + x := v_0 + if v_1.Op != OpNeg8 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd8 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_0_1.AuxInt) + if !(c&15 == 15) { + continue + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpNeg8, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft16 x (Add64 y (Const64 [c]))) + // cond: c&15 == 0 + // result: (RotateLeft16 x y) + for { + x := v_0 + if v_1.Op != OpAdd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c&15 == 0) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft16 x (Add32 y (Const32 [c]))) + // cond: c&15 == 0 + // result: (RotateLeft16 x y) + for { + x := v_0 + if v_1.Op != OpAdd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_1.AuxInt) + if !(c&15 == 0) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft16 x (Add16 y (Const16 [c]))) + // cond: c&15 == 0 + // result: (RotateLeft16 x y) + for { + x := v_0 + if v_1.Op != OpAdd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_1.AuxInt) + if !(c&15 == 0) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft16 x (Add8 y (Const8 [c]))) + // cond: c&15 == 0 + // result: (RotateLeft16 x y) + for { + x := v_0 + if v_1.Op != OpAdd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_1.AuxInt) + if !(c&15 == 0) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft16 x (Sub64 (Const64 [c]) y)) + // cond: c&15 == 0 + // result: (RotateLeft16 x (Neg64 y)) + for { + x := v_0 + if v_1.Op != OpSub64 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1_0.AuxInt) + if !(c&15 == 0) { + break + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpNeg64, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft16 x (Sub32 (Const32 [c]) y)) + // cond: c&15 == 0 + // result: (RotateLeft16 x (Neg32 y)) + for { + x := v_0 + if v_1.Op != OpSub32 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c&15 == 0) { + break + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpNeg32, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft16 x (Sub16 (Const16 [c]) y)) + // cond: c&15 == 0 + // result: (RotateLeft16 x (Neg16 y)) + for { + x := v_0 + if v_1.Op != OpSub16 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1_0.AuxInt) + if !(c&15 == 0) { + break + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpNeg16, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft16 x (Sub8 (Const8 [c]) y)) + // cond: c&15 == 0 + // result: (RotateLeft16 x (Neg8 y)) + for { + x := v_0 + if v_1.Op != OpSub8 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1_0.AuxInt) + if !(c&15 == 0) { + break + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpNeg8, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft16 x (Const64 [c])) + // cond: config.PtrSize == 4 + // result: (RotateLeft16 x (Const32 [int32(c)])) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft16 (RotateLeft16 x c) d) + // cond: c.Type.Size() == 8 && d.Type.Size() == 8 + // result: (RotateLeft16 x (Add64 c d)) + for { + if v_0.Op != OpRotateLeft16 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 8 && d.Type.Size() == 8) { + break + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpAdd64, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft16 (RotateLeft16 x c) d) + // cond: c.Type.Size() == 4 && d.Type.Size() == 4 + // result: (RotateLeft16 x (Add32 c d)) + for { + if v_0.Op != OpRotateLeft16 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 4 && d.Type.Size() == 4) { + break + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpAdd32, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft16 (RotateLeft16 x c) d) + // cond: c.Type.Size() == 2 && d.Type.Size() == 2 + // result: (RotateLeft16 x (Add16 c d)) + for { + if v_0.Op != OpRotateLeft16 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 2 && d.Type.Size() == 2) { + break + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpAdd16, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft16 (RotateLeft16 x c) d) + // cond: c.Type.Size() == 1 && d.Type.Size() == 1 + // result: (RotateLeft16 x (Add8 c d)) + for { + if v_0.Op != OpRotateLeft16 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 1 && d.Type.Size() == 1) { + break + } + v.reset(OpRotateLeft16) + v0 := b.NewValue0(v.Pos, OpAdd8, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpRotateLeft32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (RotateLeft32 x (Const32 [c])) + // cond: c%32 == 0 + // result: x + for { + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + if !(c%32 == 0) { + break + } + v.copyOf(x) + return true + } + // match: (RotateLeft32 x (And64 y (Const64 [c]))) + // cond: c&31 == 31 + // result: (RotateLeft32 x y) + for { + x := v_0 + if v_1.Op != OpAnd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c&31 == 31) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft32 x (And32 y (Const32 [c]))) + // cond: c&31 == 31 + // result: (RotateLeft32 x y) + for { + x := v_0 + if v_1.Op != OpAnd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_1.AuxInt) + if !(c&31 == 31) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft32 x (And16 y (Const16 [c]))) + // cond: c&31 == 31 + // result: (RotateLeft32 x y) + for { + x := v_0 + if v_1.Op != OpAnd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_1.AuxInt) + if !(c&31 == 31) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft32 x (And8 y (Const8 [c]))) + // cond: c&31 == 31 + // result: (RotateLeft32 x y) + for { + x := v_0 + if v_1.Op != OpAnd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_1.AuxInt) + if !(c&31 == 31) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft32 x (Neg64 (And64 y (Const64 [c])))) + // cond: c&31 == 31 + // result: (RotateLeft32 x (Neg64 y)) + for { + x := v_0 + if v_1.Op != OpNeg64 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd64 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_0_1.AuxInt) + if !(c&31 == 31) { + continue + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpNeg64, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft32 x (Neg32 (And32 y (Const32 [c])))) + // cond: c&31 == 31 + // result: (RotateLeft32 x (Neg32 y)) + for { + x := v_0 + if v_1.Op != OpNeg32 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd32 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_0_1.AuxInt) + if !(c&31 == 31) { + continue + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpNeg32, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft32 x (Neg16 (And16 y (Const16 [c])))) + // cond: c&31 == 31 + // result: (RotateLeft32 x (Neg16 y)) + for { + x := v_0 + if v_1.Op != OpNeg16 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd16 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_0_1.AuxInt) + if !(c&31 == 31) { + continue + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpNeg16, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft32 x (Neg8 (And8 y (Const8 [c])))) + // cond: c&31 == 31 + // result: (RotateLeft32 x (Neg8 y)) + for { + x := v_0 + if v_1.Op != OpNeg8 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd8 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_0_1.AuxInt) + if !(c&31 == 31) { + continue + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpNeg8, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft32 x (Add64 y (Const64 [c]))) + // cond: c&31 == 0 + // result: (RotateLeft32 x y) + for { + x := v_0 + if v_1.Op != OpAdd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c&31 == 0) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft32 x (Add32 y (Const32 [c]))) + // cond: c&31 == 0 + // result: (RotateLeft32 x y) + for { + x := v_0 + if v_1.Op != OpAdd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_1.AuxInt) + if !(c&31 == 0) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft32 x (Add16 y (Const16 [c]))) + // cond: c&31 == 0 + // result: (RotateLeft32 x y) + for { + x := v_0 + if v_1.Op != OpAdd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_1.AuxInt) + if !(c&31 == 0) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft32 x (Add8 y (Const8 [c]))) + // cond: c&31 == 0 + // result: (RotateLeft32 x y) + for { + x := v_0 + if v_1.Op != OpAdd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_1.AuxInt) + if !(c&31 == 0) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft32 x (Sub64 (Const64 [c]) y)) + // cond: c&31 == 0 + // result: (RotateLeft32 x (Neg64 y)) + for { + x := v_0 + if v_1.Op != OpSub64 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1_0.AuxInt) + if !(c&31 == 0) { + break + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpNeg64, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft32 x (Sub32 (Const32 [c]) y)) + // cond: c&31 == 0 + // result: (RotateLeft32 x (Neg32 y)) + for { + x := v_0 + if v_1.Op != OpSub32 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c&31 == 0) { + break + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpNeg32, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft32 x (Sub16 (Const16 [c]) y)) + // cond: c&31 == 0 + // result: (RotateLeft32 x (Neg16 y)) + for { + x := v_0 + if v_1.Op != OpSub16 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1_0.AuxInt) + if !(c&31 == 0) { + break + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpNeg16, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft32 x (Sub8 (Const8 [c]) y)) + // cond: c&31 == 0 + // result: (RotateLeft32 x (Neg8 y)) + for { + x := v_0 + if v_1.Op != OpSub8 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1_0.AuxInt) + if !(c&31 == 0) { + break + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpNeg8, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft32 x (Const64 [c])) + // cond: config.PtrSize == 4 + // result: (RotateLeft32 x (Const32 [int32(c)])) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft32 (RotateLeft32 x c) d) + // cond: c.Type.Size() == 8 && d.Type.Size() == 8 + // result: (RotateLeft32 x (Add64 c d)) + for { + if v_0.Op != OpRotateLeft32 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 8 && d.Type.Size() == 8) { + break + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpAdd64, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft32 (RotateLeft32 x c) d) + // cond: c.Type.Size() == 4 && d.Type.Size() == 4 + // result: (RotateLeft32 x (Add32 c d)) + for { + if v_0.Op != OpRotateLeft32 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 4 && d.Type.Size() == 4) { + break + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpAdd32, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft32 (RotateLeft32 x c) d) + // cond: c.Type.Size() == 2 && d.Type.Size() == 2 + // result: (RotateLeft32 x (Add16 c d)) + for { + if v_0.Op != OpRotateLeft32 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 2 && d.Type.Size() == 2) { + break + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpAdd16, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft32 (RotateLeft32 x c) d) + // cond: c.Type.Size() == 1 && d.Type.Size() == 1 + // result: (RotateLeft32 x (Add8 c d)) + for { + if v_0.Op != OpRotateLeft32 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 1 && d.Type.Size() == 1) { + break + } + v.reset(OpRotateLeft32) + v0 := b.NewValue0(v.Pos, OpAdd8, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpRotateLeft64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (RotateLeft64 x (Const64 [c])) + // cond: c%64 == 0 + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(c%64 == 0) { + break + } + v.copyOf(x) + return true + } + // match: (RotateLeft64 x (And64 y (Const64 [c]))) + // cond: c&63 == 63 + // result: (RotateLeft64 x y) + for { + x := v_0 + if v_1.Op != OpAnd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c&63 == 63) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft64 x (And32 y (Const32 [c]))) + // cond: c&63 == 63 + // result: (RotateLeft64 x y) + for { + x := v_0 + if v_1.Op != OpAnd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_1.AuxInt) + if !(c&63 == 63) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft64 x (And16 y (Const16 [c]))) + // cond: c&63 == 63 + // result: (RotateLeft64 x y) + for { + x := v_0 + if v_1.Op != OpAnd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_1.AuxInt) + if !(c&63 == 63) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft64 x (And8 y (Const8 [c]))) + // cond: c&63 == 63 + // result: (RotateLeft64 x y) + for { + x := v_0 + if v_1.Op != OpAnd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_1.AuxInt) + if !(c&63 == 63) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft64 x (Neg64 (And64 y (Const64 [c])))) + // cond: c&63 == 63 + // result: (RotateLeft64 x (Neg64 y)) + for { + x := v_0 + if v_1.Op != OpNeg64 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd64 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_0_1.AuxInt) + if !(c&63 == 63) { + continue + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpNeg64, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft64 x (Neg32 (And32 y (Const32 [c])))) + // cond: c&63 == 63 + // result: (RotateLeft64 x (Neg32 y)) + for { + x := v_0 + if v_1.Op != OpNeg32 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd32 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_0_1.AuxInt) + if !(c&63 == 63) { + continue + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpNeg32, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft64 x (Neg16 (And16 y (Const16 [c])))) + // cond: c&63 == 63 + // result: (RotateLeft64 x (Neg16 y)) + for { + x := v_0 + if v_1.Op != OpNeg16 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd16 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_0_1.AuxInt) + if !(c&63 == 63) { + continue + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpNeg16, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft64 x (Neg8 (And8 y (Const8 [c])))) + // cond: c&63 == 63 + // result: (RotateLeft64 x (Neg8 y)) + for { + x := v_0 + if v_1.Op != OpNeg8 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd8 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_0_1.AuxInt) + if !(c&63 == 63) { + continue + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpNeg8, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft64 x (Add64 y (Const64 [c]))) + // cond: c&63 == 0 + // result: (RotateLeft64 x y) + for { + x := v_0 + if v_1.Op != OpAdd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c&63 == 0) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft64 x (Add32 y (Const32 [c]))) + // cond: c&63 == 0 + // result: (RotateLeft64 x y) + for { + x := v_0 + if v_1.Op != OpAdd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_1.AuxInt) + if !(c&63 == 0) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft64 x (Add16 y (Const16 [c]))) + // cond: c&63 == 0 + // result: (RotateLeft64 x y) + for { + x := v_0 + if v_1.Op != OpAdd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_1.AuxInt) + if !(c&63 == 0) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft64 x (Add8 y (Const8 [c]))) + // cond: c&63 == 0 + // result: (RotateLeft64 x y) + for { + x := v_0 + if v_1.Op != OpAdd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_1.AuxInt) + if !(c&63 == 0) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft64 x (Sub64 (Const64 [c]) y)) + // cond: c&63 == 0 + // result: (RotateLeft64 x (Neg64 y)) + for { + x := v_0 + if v_1.Op != OpSub64 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1_0.AuxInt) + if !(c&63 == 0) { + break + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpNeg64, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft64 x (Sub32 (Const32 [c]) y)) + // cond: c&63 == 0 + // result: (RotateLeft64 x (Neg32 y)) + for { + x := v_0 + if v_1.Op != OpSub32 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c&63 == 0) { + break + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpNeg32, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft64 x (Sub16 (Const16 [c]) y)) + // cond: c&63 == 0 + // result: (RotateLeft64 x (Neg16 y)) + for { + x := v_0 + if v_1.Op != OpSub16 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1_0.AuxInt) + if !(c&63 == 0) { + break + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpNeg16, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft64 x (Sub8 (Const8 [c]) y)) + // cond: c&63 == 0 + // result: (RotateLeft64 x (Neg8 y)) + for { + x := v_0 + if v_1.Op != OpSub8 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1_0.AuxInt) + if !(c&63 == 0) { + break + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpNeg8, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft64 x (Const64 [c])) + // cond: config.PtrSize == 4 + // result: (RotateLeft64 x (Const32 [int32(c)])) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft64 (RotateLeft64 x c) d) + // cond: c.Type.Size() == 8 && d.Type.Size() == 8 + // result: (RotateLeft64 x (Add64 c d)) + for { + if v_0.Op != OpRotateLeft64 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 8 && d.Type.Size() == 8) { + break + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpAdd64, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft64 (RotateLeft64 x c) d) + // cond: c.Type.Size() == 4 && d.Type.Size() == 4 + // result: (RotateLeft64 x (Add32 c d)) + for { + if v_0.Op != OpRotateLeft64 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 4 && d.Type.Size() == 4) { + break + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpAdd32, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft64 (RotateLeft64 x c) d) + // cond: c.Type.Size() == 2 && d.Type.Size() == 2 + // result: (RotateLeft64 x (Add16 c d)) + for { + if v_0.Op != OpRotateLeft64 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 2 && d.Type.Size() == 2) { + break + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpAdd16, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft64 (RotateLeft64 x c) d) + // cond: c.Type.Size() == 1 && d.Type.Size() == 1 + // result: (RotateLeft64 x (Add8 c d)) + for { + if v_0.Op != OpRotateLeft64 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 1 && d.Type.Size() == 1) { + break + } + v.reset(OpRotateLeft64) + v0 := b.NewValue0(v.Pos, OpAdd8, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpRotateLeft8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (RotateLeft8 x (Const8 [c])) + // cond: c%8 == 0 + // result: x + for { + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + if !(c%8 == 0) { + break + } + v.copyOf(x) + return true + } + // match: (RotateLeft8 x (And64 y (Const64 [c]))) + // cond: c&7 == 7 + // result: (RotateLeft8 x y) + for { + x := v_0 + if v_1.Op != OpAnd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c&7 == 7) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft8 x (And32 y (Const32 [c]))) + // cond: c&7 == 7 + // result: (RotateLeft8 x y) + for { + x := v_0 + if v_1.Op != OpAnd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_1.AuxInt) + if !(c&7 == 7) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft8 x (And16 y (Const16 [c]))) + // cond: c&7 == 7 + // result: (RotateLeft8 x y) + for { + x := v_0 + if v_1.Op != OpAnd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_1.AuxInt) + if !(c&7 == 7) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft8 x (And8 y (Const8 [c]))) + // cond: c&7 == 7 + // result: (RotateLeft8 x y) + for { + x := v_0 + if v_1.Op != OpAnd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_1.AuxInt) + if !(c&7 == 7) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft8 x (Neg64 (And64 y (Const64 [c])))) + // cond: c&7 == 7 + // result: (RotateLeft8 x (Neg64 y)) + for { + x := v_0 + if v_1.Op != OpNeg64 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd64 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_0_1.AuxInt) + if !(c&7 == 7) { + continue + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpNeg64, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft8 x (Neg32 (And32 y (Const32 [c])))) + // cond: c&7 == 7 + // result: (RotateLeft8 x (Neg32 y)) + for { + x := v_0 + if v_1.Op != OpNeg32 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd32 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_0_1.AuxInt) + if !(c&7 == 7) { + continue + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpNeg32, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft8 x (Neg16 (And16 y (Const16 [c])))) + // cond: c&7 == 7 + // result: (RotateLeft8 x (Neg16 y)) + for { + x := v_0 + if v_1.Op != OpNeg16 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd16 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_0_1.AuxInt) + if !(c&7 == 7) { + continue + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpNeg16, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft8 x (Neg8 (And8 y (Const8 [c])))) + // cond: c&7 == 7 + // result: (RotateLeft8 x (Neg8 y)) + for { + x := v_0 + if v_1.Op != OpNeg8 { + break + } + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpAnd8 { + break + } + _ = v_1_0.Args[1] + v_1_0_0 := v_1_0.Args[0] + v_1_0_1 := v_1_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0_0, v_1_0_1 = _i0+1, v_1_0_1, v_1_0_0 { + y := v_1_0_0 + if v_1_0_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_0_1.AuxInt) + if !(c&7 == 7) { + continue + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpNeg8, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + break + } + // match: (RotateLeft8 x (Add64 y (Const64 [c]))) + // cond: c&7 == 0 + // result: (RotateLeft8 x y) + for { + x := v_0 + if v_1.Op != OpAdd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_1_1.AuxInt) + if !(c&7 == 0) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft8 x (Add32 y (Const32 [c]))) + // cond: c&7 == 0 + // result: (RotateLeft8 x y) + for { + x := v_0 + if v_1.Op != OpAdd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_1_1.AuxInt) + if !(c&7 == 0) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft8 x (Add16 y (Const16 [c]))) + // cond: c&7 == 0 + // result: (RotateLeft8 x y) + for { + x := v_0 + if v_1.Op != OpAdd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_1_1.AuxInt) + if !(c&7 == 0) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft8 x (Add8 y (Const8 [c]))) + // cond: c&7 == 0 + // result: (RotateLeft8 x y) + for { + x := v_0 + if v_1.Op != OpAdd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + y := v_1_0 + if v_1_1.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_1_1.AuxInt) + if !(c&7 == 0) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (RotateLeft8 x (Sub64 (Const64 [c]) y)) + // cond: c&7 == 0 + // result: (RotateLeft8 x (Neg64 y)) + for { + x := v_0 + if v_1.Op != OpSub64 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1_0.AuxInt) + if !(c&7 == 0) { + break + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpNeg64, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft8 x (Sub32 (Const32 [c]) y)) + // cond: c&7 == 0 + // result: (RotateLeft8 x (Neg32 y)) + for { + x := v_0 + if v_1.Op != OpSub32 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1_0.AuxInt) + if !(c&7 == 0) { + break + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpNeg32, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft8 x (Sub16 (Const16 [c]) y)) + // cond: c&7 == 0 + // result: (RotateLeft8 x (Neg16 y)) + for { + x := v_0 + if v_1.Op != OpSub16 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1_0.AuxInt) + if !(c&7 == 0) { + break + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpNeg16, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft8 x (Sub8 (Const8 [c]) y)) + // cond: c&7 == 0 + // result: (RotateLeft8 x (Neg8 y)) + for { + x := v_0 + if v_1.Op != OpSub8 { + break + } + y := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1_0.AuxInt) + if !(c&7 == 0) { + break + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpNeg8, y.Type) + v0.AddArg(y) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft8 x (Const64 [c])) + // cond: config.PtrSize == 4 + // result: (RotateLeft8 x (Const32 [int32(c)])) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(config.PtrSize == 4) { + break + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(int32(c)) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft8 (RotateLeft8 x c) d) + // cond: c.Type.Size() == 8 && d.Type.Size() == 8 + // result: (RotateLeft8 x (Add64 c d)) + for { + if v_0.Op != OpRotateLeft8 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 8 && d.Type.Size() == 8) { + break + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpAdd64, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft8 (RotateLeft8 x c) d) + // cond: c.Type.Size() == 4 && d.Type.Size() == 4 + // result: (RotateLeft8 x (Add32 c d)) + for { + if v_0.Op != OpRotateLeft8 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 4 && d.Type.Size() == 4) { + break + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpAdd32, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft8 (RotateLeft8 x c) d) + // cond: c.Type.Size() == 2 && d.Type.Size() == 2 + // result: (RotateLeft8 x (Add16 c d)) + for { + if v_0.Op != OpRotateLeft8 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 2 && d.Type.Size() == 2) { + break + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpAdd16, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + // match: (RotateLeft8 (RotateLeft8 x c) d) + // cond: c.Type.Size() == 1 && d.Type.Size() == 1 + // result: (RotateLeft8 x (Add8 c d)) + for { + if v_0.Op != OpRotateLeft8 { + break + } + c := v_0.Args[1] + x := v_0.Args[0] + d := v_1 + if !(c.Type.Size() == 1 && d.Type.Size() == 1) { + break + } + v.reset(OpRotateLeft8) + v0 := b.NewValue0(v.Pos, OpAdd8, c.Type) + v0.AddArg2(c, d) + v.AddArg2(x, v0) + return true + } + return false +} +func rewriteValuegeneric_OpRound32F(v *Value) bool { + v_0 := v.Args[0] + // match: (Round32F x:(Const32F)) + // result: x + for { + x := v_0 + if x.Op != OpConst32F { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpRound64F(v *Value) bool { + v_0 := v.Args[0] + // match: (Round64F x:(Const64F)) + // result: x + for { + x := v_0 + if x.Op != OpConst64F { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpRoundToEven(v *Value) bool { + v_0 := v.Args[0] + // match: (RoundToEven (Const64F [c])) + // result: (Const64F [math.RoundToEven(c)]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(math.RoundToEven(c)) + return true + } + return false +} +func rewriteValuegeneric_OpRsh16Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16Ux16 x (Const16 [c])) + // result: (Rsh16Ux64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpRsh16Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16Ux16 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Rsh16Ux16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 16 + // result: (Rsh16Ux16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpRsh16Ux16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh16Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16Ux32 x (Const32 [c])) + // result: (Rsh16Ux64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpRsh16Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16Ux32 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Rsh16Ux32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 16 + // result: (Rsh16Ux32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpRsh16Ux32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh16Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16Ux64 (Const16 [c]) (Const64 [d])) + // result: (Const16 [int16(uint16(c) >> uint64(d))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(int16(uint16(c) >> uint64(d))) + return true + } + // match: (Rsh16Ux64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Rsh16Ux64 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Rsh16Ux64 _ (Const64 [c])) + // cond: uint64(c) >= 16 + // result: (Const16 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 16) { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Rsh16Ux64 (Rsh16Ux64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Rsh16Ux64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpRsh16Ux64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpRsh16Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16Ux64 (Rsh16x64 x _) (Const64 [15])) + // result: (Rsh16Ux64 x (Const64 [15])) + for { + if v_0.Op != OpRsh16x64 { + break + } + x := v_0.Args[0] + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + if auxIntToInt64(v_1.AuxInt) != 15 { + break + } + v.reset(OpRsh16Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(15) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16Ux64 i:(Lsh16x64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 16 && i.Uses == 1 + // result: (And16 x (Const16 [int16(^uint16(0)>>c)])) + for { + i := v_0 + if i.Op != OpLsh16x64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 16 && i.Uses == 1) { + break + } + v.reset(OpAnd16) + v0 := b.NewValue0(v.Pos, OpConst16, v.Type) + v0.AuxInt = int16ToAuxInt(int16(^uint16(0) >> c)) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16Ux64 (Lsh16x64 (Rsh16Ux64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) + // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) + // result: (Rsh16Ux64 x (Const64 [c1-c2+c3])) + for { + if v_0.Op != OpLsh16x64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRsh16Ux64 { + break + } + _ = v_0_0.Args[1] + x := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpConst64 { + break + } + c1 := auxIntToInt64(v_0_0_1.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c2 := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + c3 := auxIntToInt64(v_1.AuxInt) + if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { + break + } + v.reset(OpRsh16Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16Ux64 (Lsh16x64 x (Const64 [8])) (Const64 [8])) + // result: (ZeroExt8to16 (Trunc16to8 x)) + for { + if v_0.Op != OpLsh16x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 8 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 8 { + break + } + v.reset(OpZeroExt8to16) + v0 := b.NewValue0(v.Pos, OpTrunc16to8, typ.UInt8) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh16Ux64 [false] x con:(Const64 [c])) + // cond: 0 < c && c < 16 + // result: (Rsh16Ux64 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst64 { + break + } + c := auxIntToInt64(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpRsh16Ux64) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh16Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16Ux8 x (Const8 [c])) + // result: (Rsh16Ux64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpRsh16Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16Ux8 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Rsh16Ux8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 16 + // result: (Rsh16Ux8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpRsh16Ux8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh16x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16x16 x (Const16 [c])) + // result: (Rsh16x64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpRsh16x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x16 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Rsh16x16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 16 + // result: (Rsh16x16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpRsh16x16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh16x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16x32 x (Const32 [c])) + // result: (Rsh16x64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpRsh16x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x32 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Rsh16x32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 16 + // result: (Rsh16x32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpRsh16x32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh16x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh16x64 (Const16 [c]) (Const64 [d])) + // result: (Const16 [c >> uint64(d)]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c >> uint64(d)) + return true + } + // match: (Rsh16x64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Rsh16x64 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Rsh16x64 (Rsh16x64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Rsh16x64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpRsh16x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpRsh16x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x64 (Lsh16x64 x (Const64 [8])) (Const64 [8])) + // result: (SignExt8to16 (Trunc16to8 x)) + for { + if v_0.Op != OpLsh16x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 8 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 8 { + break + } + v.reset(OpSignExt8to16) + v0 := b.NewValue0(v.Pos, OpTrunc16to8, typ.Int8) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh16x64 [false] x con:(Const64 [c])) + // cond: 0 < c && c < 16 + // result: (Rsh16x64 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst64 { + break + } + c := auxIntToInt64(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpRsh16x64) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh16x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh16x8 x (Const8 [c])) + // result: (Rsh16x64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpRsh16x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh16x8 (Const16 [0]) _) + // result: (Const16 [0]) + for { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Rsh16x8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 16 + // result: (Rsh16x8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 16) { + break + } + v.reset(OpRsh16x8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh32Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux16 x (Const16 [c])) + // result: (Rsh32Ux64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpRsh32Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32Ux16 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh32Ux16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 32 + // result: (Rsh32Ux16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpRsh32Ux16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh32Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux32 x (Const32 [c])) + // result: (Rsh32Ux64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpRsh32Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32Ux32 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh32Ux32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 32 + // result: (Rsh32Ux32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpRsh32Ux32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh32Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32Ux64 (Const32 [c]) (Const64 [d])) + // result: (Const32 [int32(uint32(c) >> uint64(d))]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) + return true + } + // match: (Rsh32Ux64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Rsh32Ux64 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh32Ux64 _ (Const64 [c])) + // cond: uint64(c) >= 32 + // result: (Const32 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 32) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh32Ux64 (Rsh32Ux64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Rsh32Ux64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpRsh32Ux64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpRsh32Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32Ux64 (Rsh32x64 x _) (Const64 [31])) + // result: (Rsh32Ux64 x (Const64 [31])) + for { + if v_0.Op != OpRsh32x64 { + break + } + x := v_0.Args[0] + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + if auxIntToInt64(v_1.AuxInt) != 31 { + break + } + v.reset(OpRsh32Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(31) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32Ux64 i:(Lsh32x64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 32 && i.Uses == 1 + // result: (And32 x (Const32 [int32(^uint32(0)>>c)])) + for { + i := v_0 + if i.Op != OpLsh32x64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 32 && i.Uses == 1) { + break + } + v.reset(OpAnd32) + v0 := b.NewValue0(v.Pos, OpConst32, v.Type) + v0.AuxInt = int32ToAuxInt(int32(^uint32(0) >> c)) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32Ux64 (Lsh32x64 (Rsh32Ux64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) + // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) + // result: (Rsh32Ux64 x (Const64 [c1-c2+c3])) + for { + if v_0.Op != OpLsh32x64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRsh32Ux64 { + break + } + _ = v_0_0.Args[1] + x := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpConst64 { + break + } + c1 := auxIntToInt64(v_0_0_1.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c2 := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + c3 := auxIntToInt64(v_1.AuxInt) + if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { + break + } + v.reset(OpRsh32Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32Ux64 (Lsh32x64 x (Const64 [24])) (Const64 [24])) + // result: (ZeroExt8to32 (Trunc32to8 x)) + for { + if v_0.Op != OpLsh32x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 24 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 24 { + break + } + v.reset(OpZeroExt8to32) + v0 := b.NewValue0(v.Pos, OpTrunc32to8, typ.UInt8) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh32Ux64 (Lsh32x64 x (Const64 [16])) (Const64 [16])) + // result: (ZeroExt16to32 (Trunc32to16 x)) + for { + if v_0.Op != OpLsh32x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 16 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 16 { + break + } + v.reset(OpZeroExt16to32) + v0 := b.NewValue0(v.Pos, OpTrunc32to16, typ.UInt16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh32Ux64 [false] x con:(Const64 [c])) + // cond: 0 < c && c < 32 + // result: (Rsh32Ux64 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst64 { + break + } + c := auxIntToInt64(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpRsh32Ux64) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh32Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32Ux8 x (Const8 [c])) + // result: (Rsh32Ux64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpRsh32Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32Ux8 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh32Ux8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 32 + // result: (Rsh32Ux8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpRsh32Ux8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh32x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x16 x (Const16 [c])) + // result: (Rsh32x64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpRsh32x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x16 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh32x16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 32 + // result: (Rsh32x16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpRsh32x16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh32x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x32 x (Const32 [c])) + // result: (Rsh32x64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpRsh32x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x32 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh32x32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 32 + // result: (Rsh32x32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpRsh32x32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh32x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh32x64 (Const32 [c]) (Const64 [d])) + // result: (Const32 [c >> uint64(d)]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c >> uint64(d)) + return true + } + // match: (Rsh32x64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Rsh32x64 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh32x64 (Rsh32x64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Rsh32x64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpRsh32x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpRsh32x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x64 (Lsh32x64 x (Const64 [24])) (Const64 [24])) + // result: (SignExt8to32 (Trunc32to8 x)) + for { + if v_0.Op != OpLsh32x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 24 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 24 { + break + } + v.reset(OpSignExt8to32) + v0 := b.NewValue0(v.Pos, OpTrunc32to8, typ.Int8) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh32x64 (Lsh32x64 x (Const64 [16])) (Const64 [16])) + // result: (SignExt16to32 (Trunc32to16 x)) + for { + if v_0.Op != OpLsh32x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 16 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 16 { + break + } + v.reset(OpSignExt16to32) + v0 := b.NewValue0(v.Pos, OpTrunc32to16, typ.Int16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh32x64 [false] x con:(Const64 [c])) + // cond: 0 < c && c < 32 + // result: (Rsh32x64 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst64 { + break + } + c := auxIntToInt64(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpRsh32x64) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh32x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh32x8 x (Const8 [c])) + // result: (Rsh32x64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpRsh32x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh32x8 (Const32 [0]) _) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Rsh32x8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 32 + // result: (Rsh32x8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 32) { + break + } + v.reset(OpRsh32x8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh64Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64Ux16 x (Const16 [c])) + // result: (Rsh64Ux64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpRsh64Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64Ux16 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64Ux16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 64 + // result: (Rsh64Ux16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpRsh64Ux16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh64Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64Ux32 x (Const32 [c])) + // result: (Rsh64Ux64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpRsh64Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64Ux32 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64Ux32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 64 + // result: (Rsh64Ux32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpRsh64Ux32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh64Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64Ux64 (Const64 [c]) (Const64 [d])) + // result: (Const64 [int64(uint64(c) >> uint64(d))]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(uint64(c) >> uint64(d))) + return true + } + // match: (Rsh64Ux64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Rsh64Ux64 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64Ux64 _ (Const64 [c])) + // cond: uint64(c) >= 64 + // result: (Const64 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 64) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64Ux64 (Rsh64Ux64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Rsh64Ux64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpRsh64Ux64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpRsh64Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64Ux64 (Rsh64x64 x _) (Const64 [63])) + // result: (Rsh64Ux64 x (Const64 [63])) + for { + if v_0.Op != OpRsh64x64 { + break + } + x := v_0.Args[0] + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + if auxIntToInt64(v_1.AuxInt) != 63 { + break + } + v.reset(OpRsh64Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(63) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64Ux64 i:(Lsh64x64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 64 && i.Uses == 1 + // result: (And64 x (Const64 [int64(^uint64(0)>>c)])) + for { + i := v_0 + if i.Op != OpLsh64x64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 64 && i.Uses == 1) { + break + } + v.reset(OpAnd64) + v0 := b.NewValue0(v.Pos, OpConst64, v.Type) + v0.AuxInt = int64ToAuxInt(int64(^uint64(0) >> c)) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64Ux64 (Lsh64x64 (Rsh64Ux64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) + // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) + // result: (Rsh64Ux64 x (Const64 [c1-c2+c3])) + for { + if v_0.Op != OpLsh64x64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRsh64Ux64 { + break + } + _ = v_0_0.Args[1] + x := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpConst64 { + break + } + c1 := auxIntToInt64(v_0_0_1.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c2 := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + c3 := auxIntToInt64(v_1.AuxInt) + if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { + break + } + v.reset(OpRsh64Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64Ux64 (Lsh64x64 x (Const64 [56])) (Const64 [56])) + // result: (ZeroExt8to64 (Trunc64to8 x)) + for { + if v_0.Op != OpLsh64x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 56 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 56 { + break + } + v.reset(OpZeroExt8to64) + v0 := b.NewValue0(v.Pos, OpTrunc64to8, typ.UInt8) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh64Ux64 (Lsh64x64 x (Const64 [48])) (Const64 [48])) + // result: (ZeroExt16to64 (Trunc64to16 x)) + for { + if v_0.Op != OpLsh64x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 48 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 48 { + break + } + v.reset(OpZeroExt16to64) + v0 := b.NewValue0(v.Pos, OpTrunc64to16, typ.UInt16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh64Ux64 (Lsh64x64 x (Const64 [32])) (Const64 [32])) + // result: (ZeroExt32to64 (Trunc64to32 x)) + for { + if v_0.Op != OpLsh64x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 32 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 32 { + break + } + v.reset(OpZeroExt32to64) + v0 := b.NewValue0(v.Pos, OpTrunc64to32, typ.UInt32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh64Ux64 [false] x con:(Const64 [c])) + // cond: 0 < c && c < 64 + // result: (Rsh64Ux64 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst64 { + break + } + c := auxIntToInt64(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpRsh64Ux64) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh64Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64Ux8 x (Const8 [c])) + // result: (Rsh64Ux64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpRsh64Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64Ux8 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64Ux8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 64 + // result: (Rsh64Ux8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpRsh64Ux8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh64x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x16 x (Const16 [c])) + // result: (Rsh64x64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpRsh64x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x16 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64x16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 64 + // result: (Rsh64x16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpRsh64x16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh64x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x32 x (Const32 [c])) + // result: (Rsh64x64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpRsh64x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x32 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64x32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 64 + // result: (Rsh64x32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpRsh64x32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh64x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh64x64 (Const64 [c]) (Const64 [d])) + // result: (Const64 [c >> uint64(d)]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c >> uint64(d)) + return true + } + // match: (Rsh64x64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Rsh64x64 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64x64 (Rsh64x64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Rsh64x64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpRsh64x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpRsh64x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x64 (Lsh64x64 x (Const64 [56])) (Const64 [56])) + // result: (SignExt8to64 (Trunc64to8 x)) + for { + if v_0.Op != OpLsh64x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 56 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 56 { + break + } + v.reset(OpSignExt8to64) + v0 := b.NewValue0(v.Pos, OpTrunc64to8, typ.Int8) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh64x64 (Lsh64x64 x (Const64 [48])) (Const64 [48])) + // result: (SignExt16to64 (Trunc64to16 x)) + for { + if v_0.Op != OpLsh64x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 48 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 48 { + break + } + v.reset(OpSignExt16to64) + v0 := b.NewValue0(v.Pos, OpTrunc64to16, typ.Int16) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh64x64 (Lsh64x64 x (Const64 [32])) (Const64 [32])) + // result: (SignExt32to64 (Trunc64to32 x)) + for { + if v_0.Op != OpLsh64x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 32 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 32 { + break + } + v.reset(OpSignExt32to64) + v0 := b.NewValue0(v.Pos, OpTrunc64to32, typ.Int32) + v0.AddArg(x) + v.AddArg(v0) + return true + } + // match: (Rsh64x64 [false] x con:(Const64 [c])) + // cond: 0 < c && c < 64 + // result: (Rsh64x64 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst64 { + break + } + c := auxIntToInt64(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpRsh64x64) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh64x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh64x8 x (Const8 [c])) + // result: (Rsh64x64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpRsh64x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh64x8 (Const64 [0]) _) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Rsh64x8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 64 + // result: (Rsh64x8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 64) { + break + } + v.reset(OpRsh64x8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh8Ux16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8Ux16 x (Const16 [c])) + // result: (Rsh8Ux64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpRsh8Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8Ux16 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Rsh8Ux16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 8 + // result: (Rsh8Ux16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpRsh8Ux16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh8Ux32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8Ux32 x (Const32 [c])) + // result: (Rsh8Ux64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpRsh8Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8Ux32 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Rsh8Ux32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 8 + // result: (Rsh8Ux32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpRsh8Ux32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh8Ux64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Rsh8Ux64 (Const8 [c]) (Const64 [d])) + // result: (Const8 [int8(uint8(c) >> uint64(d))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(int8(uint8(c) >> uint64(d))) + return true + } + // match: (Rsh8Ux64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Rsh8Ux64 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Rsh8Ux64 _ (Const64 [c])) + // cond: uint64(c) >= 8 + // result: (Const8 [0]) + for { + if v_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_1.AuxInt) + if !(uint64(c) >= 8) { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Rsh8Ux64 (Rsh8Ux64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Rsh8Ux64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpRsh8Ux64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpRsh8Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8Ux64 (Rsh8x64 x _) (Const64 [7] )) + // result: (Rsh8Ux64 x (Const64 [7] )) + for { + if v_0.Op != OpRsh8x64 { + break + } + x := v_0.Args[0] + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + if auxIntToInt64(v_1.AuxInt) != 7 { + break + } + v.reset(OpRsh8Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(7) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8Ux64 i:(Lsh8x64 x (Const64 [c])) (Const64 [c])) + // cond: c >= 0 && c < 8 && i.Uses == 1 + // result: (And8 x (Const8 [int8 (^uint8 (0)>>c)])) + for { + i := v_0 + if i.Op != OpLsh8x64 { + break + } + _ = i.Args[1] + x := i.Args[0] + i_1 := i.Args[1] + if i_1.Op != OpConst64 { + break + } + c := auxIntToInt64(i_1.AuxInt) + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || !(c >= 0 && c < 8 && i.Uses == 1) { + break + } + v.reset(OpAnd8) + v0 := b.NewValue0(v.Pos, OpConst8, v.Type) + v0.AuxInt = int8ToAuxInt(int8(^uint8(0) >> c)) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8Ux64 (Lsh8x64 (Rsh8Ux64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) + // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) + // result: (Rsh8Ux64 x (Const64 [c1-c2+c3])) + for { + if v_0.Op != OpLsh8x64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpRsh8Ux64 { + break + } + _ = v_0_0.Args[1] + x := v_0_0.Args[0] + v_0_0_1 := v_0_0.Args[1] + if v_0_0_1.Op != OpConst64 { + break + } + c1 := auxIntToInt64(v_0_0_1.AuxInt) + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c2 := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + c3 := auxIntToInt64(v_1.AuxInt) + if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { + break + } + v.reset(OpRsh8Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) + v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8Ux64 [false] x con:(Const64 [c])) + // cond: 0 < c && c < 8 + // result: (Rsh8Ux64 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst64 { + break + } + c := auxIntToInt64(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpRsh8Ux64) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh8Ux8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8Ux8 x (Const8 [c])) + // result: (Rsh8Ux64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpRsh8Ux64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8Ux8 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Rsh8Ux8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 8 + // result: (Rsh8Ux8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpRsh8Ux8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh8x16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x16 x (Const16 [c])) + // result: (Rsh8x64 x (Const64 [int64(uint16(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst16 { + break + } + c := auxIntToInt16(v_1.AuxInt) + v.reset(OpRsh8x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint16(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x16 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Rsh8x16 [false] x con:(Const16 [c])) + // cond: 0 < c && c < 8 + // result: (Rsh8x16 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst16 { + break + } + c := auxIntToInt16(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpRsh8x16) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh8x32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x32 x (Const32 [c])) + // result: (Rsh8x64 x (Const64 [int64(uint32(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst32 { + break + } + c := auxIntToInt32(v_1.AuxInt) + v.reset(OpRsh8x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint32(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x32 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Rsh8x32 [false] x con:(Const32 [c])) + // cond: 0 < c && c < 8 + // result: (Rsh8x32 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst32 { + break + } + c := auxIntToInt32(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpRsh8x32) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh8x64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x64 (Const8 [c]) (Const64 [d])) + // result: (Const8 [c >> uint64(d)]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c >> uint64(d)) + return true + } + // match: (Rsh8x64 x (Const64 [0])) + // result: x + for { + x := v_0 + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v.copyOf(x) + return true + } + // match: (Rsh8x64 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Rsh8x64 (Rsh8x64 x (Const64 [c])) (Const64 [d])) + // cond: !uaddOvf(c,d) + // result: (Rsh8x64 x (Const64 [c+d])) + for { + t := v.Type + if v_0.Op != OpRsh8x64 { + break + } + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0_1.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + if !(!uaddOvf(c, d)) { + break + } + v.reset(OpRsh8x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c + d) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x64 [false] x con:(Const64 [c])) + // cond: 0 < c && c < 8 + // result: (Rsh8x64 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst64 { + break + } + c := auxIntToInt64(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpRsh8x64) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpRsh8x8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Rsh8x8 x (Const8 [c])) + // result: (Rsh8x64 x (Const64 [int64(uint8(c))])) + for { + t := v.Type + x := v_0 + if v_1.Op != OpConst8 { + break + } + c := auxIntToInt8(v_1.AuxInt) + v.reset(OpRsh8x64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(int64(uint8(c))) + v.AddArg2(x, v0) + return true + } + // match: (Rsh8x8 (Const8 [0]) _) + // result: (Const8 [0]) + for { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Rsh8x8 [false] x con:(Const8 [c])) + // cond: 0 < c && c < 8 + // result: (Rsh8x8 [true] x con) + for { + if auxIntToBool(v.AuxInt) != false { + break + } + x := v_0 + con := v_1 + if con.Op != OpConst8 { + break + } + c := auxIntToInt8(con.AuxInt) + if !(0 < c && c < 8) { + break + } + v.reset(OpRsh8x8) + v.AuxInt = boolToAuxInt(true) + v.AddArg2(x, con) + return true + } + return false +} +func rewriteValuegeneric_OpSelect0(v *Value) bool { + v_0 := v.Args[0] + // match: (Select0 a:(Add64carry x y (Const64 [0]))) + // cond: a.Uses == 1 + // result: (Add64 x y) + for { + a := v_0 + if a.Op != OpAdd64carry { + break + } + _ = a.Args[2] + x := a.Args[0] + y := a.Args[1] + a_2 := a.Args[2] + if a_2.Op != OpConst64 || auxIntToInt64(a_2.AuxInt) != 0 || !(a.Uses == 1) { + break + } + v.reset(OpAdd64) + v.AddArg2(x, y) + return true + } + // match: (Select0 (MakeTuple x y)) + // result: x + for { + if v_0.Op != OpMakeTuple { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpSelect1(v *Value) bool { + v_0 := v.Args[0] + // match: (Select1 (MakeTuple x y)) + // result: y + for { + if v_0.Op != OpMakeTuple { + break + } + y := v_0.Args[1] + v.copyOf(y) + return true + } + return false +} +func rewriteValuegeneric_OpSelectN(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (SelectN [n] m:(MakeResult ___)) + // result: m.Args[n] + for { + n := auxIntToInt64(v.AuxInt) + m := v_0 + if m.Op != OpMakeResult { + break + } + v.copyOf(m.Args[n]) + return true + } + // match: (SelectN [0] call:(StaticCall {sym} sptr (Const64 [c]) mem)) + // cond: isInlinableMemclr(config, int64(c)) && isSameCall(sym, "runtime.memclrNoHeapPointers") && call.Uses == 1 && clobber(call) + // result: (Zero {types.Types[types.TUINT8]} [int64(c)] sptr mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpStaticCall || len(call.Args) != 3 { + break + } + sym := auxToCall(call.Aux) + mem := call.Args[2] + sptr := call.Args[0] + call_1 := call.Args[1] + if call_1.Op != OpConst64 { + break + } + c := auxIntToInt64(call_1.AuxInt) + if !(isInlinableMemclr(config, int64(c)) && isSameCall(sym, "runtime.memclrNoHeapPointers") && call.Uses == 1 && clobber(call)) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(int64(c)) + v.Aux = typeToAux(types.Types[types.TUINT8]) + v.AddArg2(sptr, mem) + return true + } + // match: (SelectN [0] call:(StaticCall {sym} sptr (Const32 [c]) mem)) + // cond: isInlinableMemclr(config, int64(c)) && isSameCall(sym, "runtime.memclrNoHeapPointers") && call.Uses == 1 && clobber(call) + // result: (Zero {types.Types[types.TUINT8]} [int64(c)] sptr mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpStaticCall || len(call.Args) != 3 { + break + } + sym := auxToCall(call.Aux) + mem := call.Args[2] + sptr := call.Args[0] + call_1 := call.Args[1] + if call_1.Op != OpConst32 { + break + } + c := auxIntToInt32(call_1.AuxInt) + if !(isInlinableMemclr(config, int64(c)) && isSameCall(sym, "runtime.memclrNoHeapPointers") && call.Uses == 1 && clobber(call)) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(int64(c)) + v.Aux = typeToAux(types.Types[types.TUINT8]) + v.AddArg2(sptr, mem) + return true + } + // match: (SelectN [0] call:(StaticCall {sym} s1:(Store _ (Const64 [sz]) s2:(Store _ src s3:(Store {t} _ dst mem))))) + // cond: sz >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, int64(sz), config) && clobber(s1, s2, s3, call) + // result: (Move {types.Types[types.TUINT8]} [int64(sz)] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpStaticCall || len(call.Args) != 1 { + break + } + sym := auxToCall(call.Aux) + s1 := call.Args[0] + if s1.Op != OpStore { + break + } + _ = s1.Args[2] + s1_1 := s1.Args[1] + if s1_1.Op != OpConst64 { + break + } + sz := auxIntToInt64(s1_1.AuxInt) + s2 := s1.Args[2] + if s2.Op != OpStore { + break + } + _ = s2.Args[2] + src := s2.Args[1] + s3 := s2.Args[2] + if s3.Op != OpStore { + break + } + mem := s3.Args[2] + dst := s3.Args[1] + if !(sz >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, int64(sz), config) && clobber(s1, s2, s3, call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(int64(sz)) + v.Aux = typeToAux(types.Types[types.TUINT8]) + v.AddArg3(dst, src, mem) + return true + } + // match: (SelectN [0] call:(StaticCall {sym} s1:(Store _ (Const32 [sz]) s2:(Store _ src s3:(Store {t} _ dst mem))))) + // cond: sz >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, int64(sz), config) && clobber(s1, s2, s3, call) + // result: (Move {types.Types[types.TUINT8]} [int64(sz)] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpStaticCall || len(call.Args) != 1 { + break + } + sym := auxToCall(call.Aux) + s1 := call.Args[0] + if s1.Op != OpStore { + break + } + _ = s1.Args[2] + s1_1 := s1.Args[1] + if s1_1.Op != OpConst32 { + break + } + sz := auxIntToInt32(s1_1.AuxInt) + s2 := s1.Args[2] + if s2.Op != OpStore { + break + } + _ = s2.Args[2] + src := s2.Args[1] + s3 := s2.Args[2] + if s3.Op != OpStore { + break + } + mem := s3.Args[2] + dst := s3.Args[1] + if !(sz >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, int64(sz), config) && clobber(s1, s2, s3, call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(int64(sz)) + v.Aux = typeToAux(types.Types[types.TUINT8]) + v.AddArg3(dst, src, mem) + return true + } + // match: (SelectN [0] call:(StaticCall {sym} dst src (Const64 [sz]) mem)) + // cond: sz >= 0 && call.Uses == 1 && isSameCall(sym, "runtime.memmove") && isInlinableMemmove(dst, src, int64(sz), config) && clobber(call) + // result: (Move {types.Types[types.TUINT8]} [int64(sz)] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpStaticCall || len(call.Args) != 4 { + break + } + sym := auxToCall(call.Aux) + mem := call.Args[3] + dst := call.Args[0] + src := call.Args[1] + call_2 := call.Args[2] + if call_2.Op != OpConst64 { + break + } + sz := auxIntToInt64(call_2.AuxInt) + if !(sz >= 0 && call.Uses == 1 && isSameCall(sym, "runtime.memmove") && isInlinableMemmove(dst, src, int64(sz), config) && clobber(call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(int64(sz)) + v.Aux = typeToAux(types.Types[types.TUINT8]) + v.AddArg3(dst, src, mem) + return true + } + // match: (SelectN [0] call:(StaticCall {sym} dst src (Const32 [sz]) mem)) + // cond: sz >= 0 && call.Uses == 1 && isSameCall(sym, "runtime.memmove") && isInlinableMemmove(dst, src, int64(sz), config) && clobber(call) + // result: (Move {types.Types[types.TUINT8]} [int64(sz)] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpStaticCall || len(call.Args) != 4 { + break + } + sym := auxToCall(call.Aux) + mem := call.Args[3] + dst := call.Args[0] + src := call.Args[1] + call_2 := call.Args[2] + if call_2.Op != OpConst32 { + break + } + sz := auxIntToInt32(call_2.AuxInt) + if !(sz >= 0 && call.Uses == 1 && isSameCall(sym, "runtime.memmove") && isInlinableMemmove(dst, src, int64(sz), config) && clobber(call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(int64(sz)) + v.Aux = typeToAux(types.Types[types.TUINT8]) + v.AddArg3(dst, src, mem) + return true + } + // match: (SelectN [0] call:(StaticLECall {sym} dst src (Const64 [sz]) mem)) + // cond: sz >= 0 && call.Uses == 1 && isSameCall(sym, "runtime.memmove") && isInlinableMemmove(dst, src, int64(sz), config) && clobber(call) + // result: (Move {types.Types[types.TUINT8]} [int64(sz)] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpStaticLECall || len(call.Args) != 4 { + break + } + sym := auxToCall(call.Aux) + mem := call.Args[3] + dst := call.Args[0] + src := call.Args[1] + call_2 := call.Args[2] + if call_2.Op != OpConst64 { + break + } + sz := auxIntToInt64(call_2.AuxInt) + if !(sz >= 0 && call.Uses == 1 && isSameCall(sym, "runtime.memmove") && isInlinableMemmove(dst, src, int64(sz), config) && clobber(call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(int64(sz)) + v.Aux = typeToAux(types.Types[types.TUINT8]) + v.AddArg3(dst, src, mem) + return true + } + // match: (SelectN [0] call:(StaticLECall {sym} dst src (Const32 [sz]) mem)) + // cond: sz >= 0 && call.Uses == 1 && isSameCall(sym, "runtime.memmove") && isInlinableMemmove(dst, src, int64(sz), config) && clobber(call) + // result: (Move {types.Types[types.TUINT8]} [int64(sz)] dst src mem) + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpStaticLECall || len(call.Args) != 4 { + break + } + sym := auxToCall(call.Aux) + mem := call.Args[3] + dst := call.Args[0] + src := call.Args[1] + call_2 := call.Args[2] + if call_2.Op != OpConst32 { + break + } + sz := auxIntToInt32(call_2.AuxInt) + if !(sz >= 0 && call.Uses == 1 && isSameCall(sym, "runtime.memmove") && isInlinableMemmove(dst, src, int64(sz), config) && clobber(call)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(int64(sz)) + v.Aux = typeToAux(types.Types[types.TUINT8]) + v.AddArg3(dst, src, mem) + return true + } + // match: (SelectN [0] call:(StaticLECall {sym} a x)) + // cond: needRaceCleanup(sym, call) && clobber(call) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpStaticLECall || len(call.Args) != 2 { + break + } + sym := auxToCall(call.Aux) + x := call.Args[1] + if !(needRaceCleanup(sym, call) && clobber(call)) { + break + } + v.copyOf(x) + return true + } + // match: (SelectN [0] call:(StaticLECall {sym} x)) + // cond: needRaceCleanup(sym, call) && clobber(call) + // result: x + for { + if auxIntToInt64(v.AuxInt) != 0 { + break + } + call := v_0 + if call.Op != OpStaticLECall || len(call.Args) != 1 { + break + } + sym := auxToCall(call.Aux) + x := call.Args[0] + if !(needRaceCleanup(sym, call) && clobber(call)) { + break + } + v.copyOf(x) + return true + } + // match: (SelectN [1] (StaticCall {sym} _ newLen:(Const64) _ _ _ _)) + // cond: v.Type.IsInteger() && (isSameCall(sym, "runtime.growslice") || isSameCall(sym, "runtime.growsliceNoAlias")) + // result: newLen + for { + if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpStaticCall || len(v_0.Args) != 6 { + break + } + sym := auxToCall(v_0.Aux) + _ = v_0.Args[1] + newLen := v_0.Args[1] + if newLen.Op != OpConst64 || !(v.Type.IsInteger() && (isSameCall(sym, "runtime.growslice") || isSameCall(sym, "runtime.growsliceNoAlias"))) { + break + } + v.copyOf(newLen) + return true + } + // match: (SelectN [1] (StaticCall {sym} _ newLen:(Const32) _ _ _ _)) + // cond: v.Type.IsInteger() && (isSameCall(sym, "runtime.growslice") || isSameCall(sym, "runtime.growsliceNoAlias")) + // result: newLen + for { + if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpStaticCall || len(v_0.Args) != 6 { + break + } + sym := auxToCall(v_0.Aux) + _ = v_0.Args[1] + newLen := v_0.Args[1] + if newLen.Op != OpConst32 || !(v.Type.IsInteger() && (isSameCall(sym, "runtime.growslice") || isSameCall(sym, "runtime.growsliceNoAlias"))) { + break + } + v.copyOf(newLen) + return true + } + // match: (SelectN [0] (StaticLECall {f} x y (SelectN [1] c:(StaticLECall {g} x y mem)))) + // cond: isSameCall(f, "runtime.cmpstring") && isSameCall(g, "runtime.cmpstring") + // result: @c.Block (SelectN [0] c) + for { + if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpStaticLECall || len(v_0.Args) != 3 { + break + } + f := auxToCall(v_0.Aux) + _ = v_0.Args[2] + x := v_0.Args[0] + y := v_0.Args[1] + v_0_2 := v_0.Args[2] + if v_0_2.Op != OpSelectN || auxIntToInt64(v_0_2.AuxInt) != 1 { + break + } + c := v_0_2.Args[0] + if c.Op != OpStaticLECall || len(c.Args) != 3 { + break + } + g := auxToCall(c.Aux) + if x != c.Args[0] || y != c.Args[1] || !(isSameCall(f, "runtime.cmpstring") && isSameCall(g, "runtime.cmpstring")) { + break + } + b = c.Block + v0 := b.NewValue0(v.Pos, OpSelectN, typ.Int) + v.copyOf(v0) + v0.AuxInt = int64ToAuxInt(0) + v0.AddArg(c) + return true + } + // match: (SelectN [1] c:(StaticLECall {f} _ _ mem)) + // cond: c.Uses == 1 && isSameCall(f, "runtime.cmpstring") && clobber(c) + // result: mem + for { + if auxIntToInt64(v.AuxInt) != 1 { + break + } + c := v_0 + if c.Op != OpStaticLECall || len(c.Args) != 3 { + break + } + f := auxToCall(c.Aux) + mem := c.Args[2] + if !(c.Uses == 1 && isSameCall(f, "runtime.cmpstring") && clobber(c)) { + break + } + v.copyOf(mem) + return true + } + return false +} +func rewriteValuegeneric_OpSignExt16to32(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt16to32 (Const16 [c])) + // result: (Const32 [int32(c)]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(c)) + return true + } + // match: (SignExt16to32 (Trunc32to16 x:(Rsh32x64 _ (Const64 [s])))) + // cond: s >= 16 + // result: x + for { + if v_0.Op != OpTrunc32to16 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh32x64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 16) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpSignExt16to64(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt16to64 (Const16 [c])) + // result: (Const64 [int64(c)]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(c)) + return true + } + // match: (SignExt16to64 (Trunc64to16 x:(Rsh64x64 _ (Const64 [s])))) + // cond: s >= 48 + // result: x + for { + if v_0.Op != OpTrunc64to16 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh64x64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 48) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpSignExt32to64(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt32to64 (Const32 [c])) + // result: (Const64 [int64(c)]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(c)) + return true + } + // match: (SignExt32to64 (Trunc64to32 x:(Rsh64x64 _ (Const64 [s])))) + // cond: s >= 32 + // result: x + for { + if v_0.Op != OpTrunc64to32 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh64x64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 32) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpSignExt8to16(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt8to16 (Const8 [c])) + // result: (Const16 [int16(c)]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(int16(c)) + return true + } + // match: (SignExt8to16 (Trunc16to8 x:(Rsh16x64 _ (Const64 [s])))) + // cond: s >= 8 + // result: x + for { + if v_0.Op != OpTrunc16to8 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh16x64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 8) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpSignExt8to32(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt8to32 (Const8 [c])) + // result: (Const32 [int32(c)]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(c)) + return true + } + // match: (SignExt8to32 (Trunc32to8 x:(Rsh32x64 _ (Const64 [s])))) + // cond: s >= 24 + // result: x + for { + if v_0.Op != OpTrunc32to8 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh32x64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 24) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpSignExt8to64(v *Value) bool { + v_0 := v.Args[0] + // match: (SignExt8to64 (Const8 [c])) + // result: (Const64 [int64(c)]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(c)) + return true + } + // match: (SignExt8to64 (Trunc64to8 x:(Rsh64x64 _ (Const64 [s])))) + // cond: s >= 56 + // result: x + for { + if v_0.Op != OpTrunc64to8 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh64x64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 56) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpSliceCap(v *Value) bool { + v_0 := v.Args[0] + // match: (SliceCap (SliceMake _ _ (Const64 [c]))) + // result: (Const64 [c]) + for { + if v_0.Op != OpSliceMake { + break + } + _ = v_0.Args[2] + v_0_2 := v_0.Args[2] + if v_0_2.Op != OpConst64 { + break + } + t := v_0_2.Type + c := auxIntToInt64(v_0_2.AuxInt) + v.reset(OpConst64) + v.Type = t + v.AuxInt = int64ToAuxInt(c) + return true + } + // match: (SliceCap (SliceMake _ _ (Const32 [c]))) + // result: (Const32 [c]) + for { + if v_0.Op != OpSliceMake { + break + } + _ = v_0.Args[2] + v_0_2 := v_0.Args[2] + if v_0_2.Op != OpConst32 { + break + } + t := v_0_2.Type + c := auxIntToInt32(v_0_2.AuxInt) + v.reset(OpConst32) + v.Type = t + v.AuxInt = int32ToAuxInt(c) + return true + } + // match: (SliceCap (SliceMake _ _ (SliceCap x))) + // result: (SliceCap x) + for { + if v_0.Op != OpSliceMake { + break + } + _ = v_0.Args[2] + v_0_2 := v_0.Args[2] + if v_0_2.Op != OpSliceCap { + break + } + x := v_0_2.Args[0] + v.reset(OpSliceCap) + v.AddArg(x) + return true + } + // match: (SliceCap (SliceMake _ _ (SliceLen x))) + // result: (SliceLen x) + for { + if v_0.Op != OpSliceMake { + break + } + _ = v_0.Args[2] + v_0_2 := v_0.Args[2] + if v_0_2.Op != OpSliceLen { + break + } + x := v_0_2.Args[0] + v.reset(OpSliceLen) + v.AddArg(x) + return true + } + return false +} +func rewriteValuegeneric_OpSliceLen(v *Value) bool { + v_0 := v.Args[0] + // match: (SliceLen (SliceMake _ (Const64 [c]) _)) + // result: (Const64 [c]) + for { + if v_0.Op != OpSliceMake { + break + } + _ = v_0.Args[1] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + t := v_0_1.Type + c := auxIntToInt64(v_0_1.AuxInt) + v.reset(OpConst64) + v.Type = t + v.AuxInt = int64ToAuxInt(c) + return true + } + // match: (SliceLen (SliceMake _ (Const32 [c]) _)) + // result: (Const32 [c]) + for { + if v_0.Op != OpSliceMake { + break + } + _ = v_0.Args[1] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst32 { + break + } + t := v_0_1.Type + c := auxIntToInt32(v_0_1.AuxInt) + v.reset(OpConst32) + v.Type = t + v.AuxInt = int32ToAuxInt(c) + return true + } + // match: (SliceLen (SliceMake _ (SliceLen x) _)) + // result: (SliceLen x) + for { + if v_0.Op != OpSliceMake { + break + } + _ = v_0.Args[1] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpSliceLen { + break + } + x := v_0_1.Args[0] + v.reset(OpSliceLen) + v.AddArg(x) + return true + } + // match: (SliceLen (SelectN [0] (StaticLECall {sym} _ newLen:(Const64) _ _ _ _))) + // cond: (isSameCall(sym, "runtime.growslice") || isSameCall(sym, "runtime.growsliceNoAlias")) + // result: newLen + for { + if v_0.Op != OpSelectN || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpStaticLECall || len(v_0_0.Args) != 6 { + break + } + sym := auxToCall(v_0_0.Aux) + _ = v_0_0.Args[1] + newLen := v_0_0.Args[1] + if newLen.Op != OpConst64 || !(isSameCall(sym, "runtime.growslice") || isSameCall(sym, "runtime.growsliceNoAlias")) { + break + } + v.copyOf(newLen) + return true + } + // match: (SliceLen (SelectN [0] (StaticLECall {sym} _ newLen:(Const32) _ _ _ _))) + // cond: (isSameCall(sym, "runtime.growslice") || isSameCall(sym, "runtime.growsliceNoAlias")) + // result: newLen + for { + if v_0.Op != OpSelectN || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpStaticLECall || len(v_0_0.Args) != 6 { + break + } + sym := auxToCall(v_0_0.Aux) + _ = v_0_0.Args[1] + newLen := v_0_0.Args[1] + if newLen.Op != OpConst32 || !(isSameCall(sym, "runtime.growslice") || isSameCall(sym, "runtime.growsliceNoAlias")) { + break + } + v.copyOf(newLen) + return true + } + return false +} +func rewriteValuegeneric_OpSliceMake(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (SliceMake (AddPtr x (And64 y (Slicemask _))) w:(Const64 [c]) z) + // cond: c > 0 + // result: (SliceMake (AddPtr x y) w z) + for { + if v_0.Op != OpAddPtr { + break + } + t := v_0.Type + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAnd64 { + break + } + _ = v_0_1.Args[1] + v_0_1_0 := v_0_1.Args[0] + v_0_1_1 := v_0_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_1_0, v_0_1_1 = _i0+1, v_0_1_1, v_0_1_0 { + y := v_0_1_0 + if v_0_1_1.Op != OpSlicemask { + continue + } + w := v_1 + if w.Op != OpConst64 { + continue + } + c := auxIntToInt64(w.AuxInt) + z := v_2 + if !(c > 0) { + continue + } + v.reset(OpSliceMake) + v0 := b.NewValue0(v.Pos, OpAddPtr, t) + v0.AddArg2(x, y) + v.AddArg3(v0, w, z) + return true + } + break + } + // match: (SliceMake (AddPtr x (And32 y (Slicemask _))) w:(Const32 [c]) z) + // cond: c > 0 + // result: (SliceMake (AddPtr x y) w z) + for { + if v_0.Op != OpAddPtr { + break + } + t := v_0.Type + _ = v_0.Args[1] + x := v_0.Args[0] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpAnd32 { + break + } + _ = v_0_1.Args[1] + v_0_1_0 := v_0_1.Args[0] + v_0_1_1 := v_0_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_1_0, v_0_1_1 = _i0+1, v_0_1_1, v_0_1_0 { + y := v_0_1_0 + if v_0_1_1.Op != OpSlicemask { + continue + } + w := v_1 + if w.Op != OpConst32 { + continue + } + c := auxIntToInt32(w.AuxInt) + z := v_2 + if !(c > 0) { + continue + } + v.reset(OpSliceMake) + v0 := b.NewValue0(v.Pos, OpAddPtr, t) + v0.AddArg2(x, y) + v.AddArg3(v0, w, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpSlicePtr(v *Value) bool { + v_0 := v.Args[0] + // match: (SlicePtr (SliceMake (SlicePtr x) _ _)) + // result: (SlicePtr x) + for { + if v_0.Op != OpSliceMake { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSlicePtr { + break + } + x := v_0_0.Args[0] + v.reset(OpSlicePtr) + v.AddArg(x) + return true + } + return false +} +func rewriteValuegeneric_OpSlicemask(v *Value) bool { + v_0 := v.Args[0] + // match: (Slicemask (Const32 [x])) + // cond: x > 0 + // result: (Const32 [-1]) + for { + if v_0.Op != OpConst32 { + break + } + x := auxIntToInt32(v_0.AuxInt) + if !(x > 0) { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(-1) + return true + } + // match: (Slicemask (Const32 [0])) + // result: (Const32 [0]) + for { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Slicemask (Const64 [x])) + // cond: x > 0 + // result: (Const64 [-1]) + for { + if v_0.Op != OpConst64 { + break + } + x := auxIntToInt64(v_0.AuxInt) + if !(x > 0) { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (Slicemask (Const64 [0])) + // result: (Const64 [0]) + for { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + return false +} +func rewriteValuegeneric_OpSqrt(v *Value) bool { + v_0 := v.Args[0] + // match: (Sqrt (Const64F [c])) + // cond: !math.IsNaN(math.Sqrt(c)) + // result: (Const64F [math.Sqrt(c)]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + if !(!math.IsNaN(math.Sqrt(c))) { + break + } + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(math.Sqrt(c)) + return true + } + return false +} +func rewriteValuegeneric_OpStaticCall(v *Value) bool { + b := v.Block + typ := &b.Func.Config.Types + // match: (StaticCall {callAux} p q _ mem) + // cond: isSameCall(callAux, "runtime.memequal") && isSamePtr(p, q) + // result: (MakeResult (ConstBool [true]) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + p := v.Args[0] + q := v.Args[1] + if !(isSameCall(callAux, "runtime.memequal") && isSamePtr(p, q)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpConstBool, typ.Bool) + v0.AuxInt = boolToAuxInt(true) + v.AddArg2(v0, mem) + return true + } + return false +} +func rewriteValuegeneric_OpStaticLECall(v *Value) bool { + b := v.Block + config := b.Func.Config + typ := &b.Func.Config.Types + // match: (StaticLECall {callAux} sptr (Addr {scon} (SB)) (Const64 [1]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) + // result: (MakeResult (Eq8 (Load sptr mem) (Const8 [int8(read8(scon,0))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + sptr := v.Args[0] + v_1 := v.Args[1] + if v_1.Op != OpAddr { + break + } + scon := auxToSym(v_1.Aux) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpSB { + break + } + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 1 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq8, typ.Bool) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int8) + v1.AddArg2(sptr, mem) + v2 := b.NewValue0(v.Pos, OpConst8, typ.Int8) + v2.AuxInt = int8ToAuxInt(int8(read8(scon, 0))) + v0.AddArg2(v1, v2) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} (Addr {scon} (SB)) sptr (Const64 [1]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) + // result: (MakeResult (Eq8 (Load sptr mem) (Const8 [int8(read8(scon,0))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_0 := v.Args[0] + if v_0.Op != OpAddr { + break + } + scon := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB { + break + } + sptr := v.Args[1] + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 1 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq8, typ.Bool) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int8) + v1.AddArg2(sptr, mem) + v2 := b.NewValue0(v.Pos, OpConst8, typ.Int8) + v2.AuxInt = int8ToAuxInt(int8(read8(scon, 0))) + v0.AddArg2(v1, v2) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} sptr (Addr {scon} (SB)) (Const64 [2]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) + // result: (MakeResult (Eq16 (Load sptr mem) (Const16 [int16(read16(scon,0,config.ctxt.Arch.ByteOrder))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + sptr := v.Args[0] + v_1 := v.Args[1] + if v_1.Op != OpAddr { + break + } + scon := auxToSym(v_1.Aux) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpSB { + break + } + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 2 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq16, typ.Bool) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int16) + v1.AddArg2(sptr, mem) + v2 := b.NewValue0(v.Pos, OpConst16, typ.Int16) + v2.AuxInt = int16ToAuxInt(int16(read16(scon, 0, config.ctxt.Arch.ByteOrder))) + v0.AddArg2(v1, v2) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} (Addr {scon} (SB)) sptr (Const64 [2]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) + // result: (MakeResult (Eq16 (Load sptr mem) (Const16 [int16(read16(scon,0,config.ctxt.Arch.ByteOrder))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_0 := v.Args[0] + if v_0.Op != OpAddr { + break + } + scon := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB { + break + } + sptr := v.Args[1] + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 2 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq16, typ.Bool) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int16) + v1.AddArg2(sptr, mem) + v2 := b.NewValue0(v.Pos, OpConst16, typ.Int16) + v2.AuxInt = int16ToAuxInt(int16(read16(scon, 0, config.ctxt.Arch.ByteOrder))) + v0.AddArg2(v1, v2) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} sptr (Addr {scon} (SB)) (Const64 [4]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) + // result: (MakeResult (Eq32 (Load sptr mem) (Const32 [int32(read32(scon,0,config.ctxt.Arch.ByteOrder))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + sptr := v.Args[0] + v_1 := v.Args[1] + if v_1.Op != OpAddr { + break + } + scon := auxToSym(v_1.Aux) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpSB { + break + } + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 4 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v1.AddArg2(sptr, mem) + v2 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v2.AuxInt = int32ToAuxInt(int32(read32(scon, 0, config.ctxt.Arch.ByteOrder))) + v0.AddArg2(v1, v2) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} (Addr {scon} (SB)) sptr (Const64 [4]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) + // result: (MakeResult (Eq32 (Load sptr mem) (Const32 [int32(read32(scon,0,config.ctxt.Arch.ByteOrder))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_0 := v.Args[0] + if v_0.Op != OpAddr { + break + } + scon := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB { + break + } + sptr := v.Args[1] + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 4 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v1.AddArg2(sptr, mem) + v2 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v2.AuxInt = int32ToAuxInt(int32(read32(scon, 0, config.ctxt.Arch.ByteOrder))) + v0.AddArg2(v1, v2) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} sptr (Addr {scon} (SB)) (Const64 [8]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8 + // result: (MakeResult (Eq64 (Load sptr mem) (Const64 [int64(read64(scon,0,config.ctxt.Arch.ByteOrder))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + sptr := v.Args[0] + v_1 := v.Args[1] + if v_1.Op != OpAddr { + break + } + scon := auxToSym(v_1.Aux) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpSB { + break + } + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 8 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq64, typ.Bool) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int64) + v1.AddArg2(sptr, mem) + v2 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v2.AuxInt = int64ToAuxInt(int64(read64(scon, 0, config.ctxt.Arch.ByteOrder))) + v0.AddArg2(v1, v2) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} (Addr {scon} (SB)) sptr (Const64 [8]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8 + // result: (MakeResult (Eq64 (Load sptr mem) (Const64 [int64(read64(scon,0,config.ctxt.Arch.ByteOrder))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_0 := v.Args[0] + if v_0.Op != OpAddr { + break + } + scon := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB { + break + } + sptr := v.Args[1] + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 8 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq64, typ.Bool) + v1 := b.NewValue0(v.Pos, OpLoad, typ.Int64) + v1.AddArg2(sptr, mem) + v2 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v2.AuxInt = int64ToAuxInt(int64(read64(scon, 0, config.ctxt.Arch.ByteOrder))) + v0.AddArg2(v1, v2) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} sptr (Addr {scon} (SB)) (Const64 [3]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) + // result: (MakeResult (Eq32 (Or32 (ZeroExt16to32 (Load sptr mem)) (Lsh32x32 (ZeroExt8to32 (Load (OffPtr [2] sptr) mem)) (Const32 [16]))) (Const32 [int32(uint32(read16(scon,0,config.ctxt.Arch.ByteOrder))|(uint32(read8(scon,2))<<16))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + sptr := v.Args[0] + v_1 := v.Args[1] + if v_1.Op != OpAddr { + break + } + scon := auxToSym(v_1.Aux) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpSB { + break + } + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 3 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v1 := b.NewValue0(v.Pos, OpOr32, typ.Int32) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.Int32) + v3 := b.NewValue0(v.Pos, OpLoad, typ.Int16) + v3.AddArg2(sptr, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpLsh32x32, typ.Int32) + v5 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.Int32) + v6 := b.NewValue0(v.Pos, OpLoad, typ.Int8) + v7 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtr) + v7.AuxInt = int64ToAuxInt(2) + v7.AddArg(sptr) + v6.AddArg2(v7, mem) + v5.AddArg(v6) + v8 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v8.AuxInt = int32ToAuxInt(16) + v4.AddArg2(v5, v8) + v1.AddArg2(v2, v4) + v9 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v9.AuxInt = int32ToAuxInt(int32(uint32(read16(scon, 0, config.ctxt.Arch.ByteOrder)) | (uint32(read8(scon, 2)) << 16))) + v0.AddArg2(v1, v9) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} (Addr {scon} (SB)) sptr (Const64 [3]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) + // result: (MakeResult (Eq32 (Or32 (ZeroExt16to32 (Load sptr mem)) (Lsh32x32 (ZeroExt8to32 (Load (OffPtr [2] sptr) mem)) (Const32 [16]))) (Const32 [int32(uint32(read16(scon,0,config.ctxt.Arch.ByteOrder))|(uint32(read8(scon,2))<<16))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_0 := v.Args[0] + if v_0.Op != OpAddr { + break + } + scon := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB { + break + } + sptr := v.Args[1] + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 3 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq32, typ.Bool) + v1 := b.NewValue0(v.Pos, OpOr32, typ.Int32) + v2 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.Int32) + v3 := b.NewValue0(v.Pos, OpLoad, typ.Int16) + v3.AddArg2(sptr, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpLsh32x32, typ.Int32) + v5 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.Int32) + v6 := b.NewValue0(v.Pos, OpLoad, typ.Int8) + v7 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtr) + v7.AuxInt = int64ToAuxInt(2) + v7.AddArg(sptr) + v6.AddArg2(v7, mem) + v5.AddArg(v6) + v8 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v8.AuxInt = int32ToAuxInt(16) + v4.AddArg2(v5, v8) + v1.AddArg2(v2, v4) + v9 := b.NewValue0(v.Pos, OpConst32, typ.Int32) + v9.AuxInt = int32ToAuxInt(int32(uint32(read16(scon, 0, config.ctxt.Arch.ByteOrder)) | (uint32(read8(scon, 2)) << 16))) + v0.AddArg2(v1, v9) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} sptr (Addr {scon} (SB)) (Const64 [5]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8 + // result: (MakeResult (Eq64 (Or64 (ZeroExt32to64 (Load sptr mem)) (Lsh64x64 (ZeroExt8to64 (Load (OffPtr [4] sptr) mem)) (Const64 [32]))) (Const64 [int64(uint64(read32(scon,0,config.ctxt.Arch.ByteOrder))|(uint64(read8(scon,4))<<32))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + sptr := v.Args[0] + v_1 := v.Args[1] + if v_1.Op != OpAddr { + break + } + scon := auxToSym(v_1.Aux) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpSB { + break + } + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 5 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq64, typ.Bool) + v1 := b.NewValue0(v.Pos, OpOr64, typ.Int64) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.Int64) + v3 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v3.AddArg2(sptr, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpLsh64x64, typ.Int64) + v5 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.Int64) + v6 := b.NewValue0(v.Pos, OpLoad, typ.Int8) + v7 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtr) + v7.AuxInt = int64ToAuxInt(4) + v7.AddArg(sptr) + v6.AddArg2(v7, mem) + v5.AddArg(v6) + v8 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v8.AuxInt = int64ToAuxInt(32) + v4.AddArg2(v5, v8) + v1.AddArg2(v2, v4) + v9 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v9.AuxInt = int64ToAuxInt(int64(uint64(read32(scon, 0, config.ctxt.Arch.ByteOrder)) | (uint64(read8(scon, 4)) << 32))) + v0.AddArg2(v1, v9) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} (Addr {scon} (SB)) sptr (Const64 [5]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8 + // result: (MakeResult (Eq64 (Or64 (ZeroExt32to64 (Load sptr mem)) (Lsh64x64 (ZeroExt8to64 (Load (OffPtr [4] sptr) mem)) (Const64 [32]))) (Const64 [int64(uint64(read32(scon,0,config.ctxt.Arch.ByteOrder))|(uint64(read8(scon,4))<<32))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_0 := v.Args[0] + if v_0.Op != OpAddr { + break + } + scon := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB { + break + } + sptr := v.Args[1] + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 5 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq64, typ.Bool) + v1 := b.NewValue0(v.Pos, OpOr64, typ.Int64) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.Int64) + v3 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v3.AddArg2(sptr, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpLsh64x64, typ.Int64) + v5 := b.NewValue0(v.Pos, OpZeroExt8to64, typ.Int64) + v6 := b.NewValue0(v.Pos, OpLoad, typ.Int8) + v7 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtr) + v7.AuxInt = int64ToAuxInt(4) + v7.AddArg(sptr) + v6.AddArg2(v7, mem) + v5.AddArg(v6) + v8 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v8.AuxInt = int64ToAuxInt(32) + v4.AddArg2(v5, v8) + v1.AddArg2(v2, v4) + v9 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v9.AuxInt = int64ToAuxInt(int64(uint64(read32(scon, 0, config.ctxt.Arch.ByteOrder)) | (uint64(read8(scon, 4)) << 32))) + v0.AddArg2(v1, v9) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} sptr (Addr {scon} (SB)) (Const64 [6]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8 + // result: (MakeResult (Eq64 (Or64 (ZeroExt32to64 (Load sptr mem)) (Lsh64x64 (ZeroExt16to64 (Load (OffPtr [4] sptr) mem)) (Const64 [32]))) (Const64 [int64(uint64(read32(scon,0,config.ctxt.Arch.ByteOrder))|(uint64(read16(scon,4,config.ctxt.Arch.ByteOrder))<<32))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + sptr := v.Args[0] + v_1 := v.Args[1] + if v_1.Op != OpAddr { + break + } + scon := auxToSym(v_1.Aux) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpSB { + break + } + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 6 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq64, typ.Bool) + v1 := b.NewValue0(v.Pos, OpOr64, typ.Int64) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.Int64) + v3 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v3.AddArg2(sptr, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpLsh64x64, typ.Int64) + v5 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.Int64) + v6 := b.NewValue0(v.Pos, OpLoad, typ.Int16) + v7 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtr) + v7.AuxInt = int64ToAuxInt(4) + v7.AddArg(sptr) + v6.AddArg2(v7, mem) + v5.AddArg(v6) + v8 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v8.AuxInt = int64ToAuxInt(32) + v4.AddArg2(v5, v8) + v1.AddArg2(v2, v4) + v9 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v9.AuxInt = int64ToAuxInt(int64(uint64(read32(scon, 0, config.ctxt.Arch.ByteOrder)) | (uint64(read16(scon, 4, config.ctxt.Arch.ByteOrder)) << 32))) + v0.AddArg2(v1, v9) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} (Addr {scon} (SB)) sptr (Const64 [6]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8 + // result: (MakeResult (Eq64 (Or64 (ZeroExt32to64 (Load sptr mem)) (Lsh64x64 (ZeroExt16to64 (Load (OffPtr [4] sptr) mem)) (Const64 [32]))) (Const64 [int64(uint64(read32(scon,0,config.ctxt.Arch.ByteOrder))|(uint64(read16(scon,4,config.ctxt.Arch.ByteOrder))<<32))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_0 := v.Args[0] + if v_0.Op != OpAddr { + break + } + scon := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB { + break + } + sptr := v.Args[1] + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 6 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq64, typ.Bool) + v1 := b.NewValue0(v.Pos, OpOr64, typ.Int64) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.Int64) + v3 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v3.AddArg2(sptr, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpLsh64x64, typ.Int64) + v5 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.Int64) + v6 := b.NewValue0(v.Pos, OpLoad, typ.Int16) + v7 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtr) + v7.AuxInt = int64ToAuxInt(4) + v7.AddArg(sptr) + v6.AddArg2(v7, mem) + v5.AddArg(v6) + v8 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v8.AuxInt = int64ToAuxInt(32) + v4.AddArg2(v5, v8) + v1.AddArg2(v2, v4) + v9 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v9.AuxInt = int64ToAuxInt(int64(uint64(read32(scon, 0, config.ctxt.Arch.ByteOrder)) | (uint64(read16(scon, 4, config.ctxt.Arch.ByteOrder)) << 32))) + v0.AddArg2(v1, v9) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} sptr (Addr {scon} (SB)) (Const64 [7]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8 + // result: (MakeResult (Eq64 (Or64 (ZeroExt32to64 (Load sptr mem)) (Lsh64x64 (ZeroExt32to64 (Load (OffPtr [3] sptr) mem)) (Const64 [32]))) (Const64 [int64(uint64(read32(scon,0,config.ctxt.Arch.ByteOrder))|(uint64(read32(scon,3,config.ctxt.Arch.ByteOrder))<<32))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + sptr := v.Args[0] + v_1 := v.Args[1] + if v_1.Op != OpAddr { + break + } + scon := auxToSym(v_1.Aux) + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpSB { + break + } + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 7 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq64, typ.Bool) + v1 := b.NewValue0(v.Pos, OpOr64, typ.Int64) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.Int64) + v3 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v3.AddArg2(sptr, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpLsh64x64, typ.Int64) + v5 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.Int64) + v6 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v7 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtr) + v7.AuxInt = int64ToAuxInt(3) + v7.AddArg(sptr) + v6.AddArg2(v7, mem) + v5.AddArg(v6) + v8 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v8.AuxInt = int64ToAuxInt(32) + v4.AddArg2(v5, v8) + v1.AddArg2(v2, v4) + v9 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v9.AuxInt = int64ToAuxInt(int64(uint64(read32(scon, 0, config.ctxt.Arch.ByteOrder)) | (uint64(read32(scon, 3, config.ctxt.Arch.ByteOrder)) << 32))) + v0.AddArg2(v1, v9) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} (Addr {scon} (SB)) sptr (Const64 [7]) mem) + // cond: isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8 + // result: (MakeResult (Eq64 (Or64 (ZeroExt32to64 (Load sptr mem)) (Lsh64x64 (ZeroExt32to64 (Load (OffPtr [3] sptr) mem)) (Const64 [32]))) (Const64 [int64(uint64(read32(scon,0,config.ctxt.Arch.ByteOrder))|(uint64(read32(scon,3,config.ctxt.Arch.ByteOrder))<<32))])) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_0 := v.Args[0] + if v_0.Op != OpAddr { + break + } + scon := auxToSym(v_0.Aux) + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSB { + break + } + sptr := v.Args[1] + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 7 || !(isSameCall(callAux, "runtime.memequal") && symIsRO(scon) && canLoadUnaligned(config) && config.PtrSize == 8) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEq64, typ.Bool) + v1 := b.NewValue0(v.Pos, OpOr64, typ.Int64) + v2 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.Int64) + v3 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v3.AddArg2(sptr, mem) + v2.AddArg(v3) + v4 := b.NewValue0(v.Pos, OpLsh64x64, typ.Int64) + v5 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.Int64) + v6 := b.NewValue0(v.Pos, OpLoad, typ.Int32) + v7 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtr) + v7.AuxInt = int64ToAuxInt(3) + v7.AddArg(sptr) + v6.AddArg2(v7, mem) + v5.AddArg(v6) + v8 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v8.AuxInt = int64ToAuxInt(32) + v4.AddArg2(v5, v8) + v1.AddArg2(v2, v4) + v9 := b.NewValue0(v.Pos, OpConst64, typ.Int64) + v9.AuxInt = int64ToAuxInt(int64(uint64(read32(scon, 0, config.ctxt.Arch.ByteOrder)) | (uint64(read32(scon, 3, config.ctxt.Arch.ByteOrder)) << 32))) + v0.AddArg2(v1, v9) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} _ _ (Const64 [0]) mem) + // cond: isSameCall(callAux, "runtime.memequal") + // result: (MakeResult (ConstBool [true]) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 0 || !(isSameCall(callAux, "runtime.memequal")) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpConstBool, typ.Bool) + v0.AuxInt = boolToAuxInt(true) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} p q _ mem) + // cond: isSameCall(callAux, "runtime.memequal") && isSamePtr(p, q) + // result: (MakeResult (ConstBool [true]) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + p := v.Args[0] + q := v.Args[1] + if !(isSameCall(callAux, "runtime.memequal") && isSamePtr(p, q)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpConstBool, typ.Bool) + v0.AuxInt = boolToAuxInt(true) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} _ (Const64 [0]) (Const64 [0]) mem) + // cond: isSameCall(callAux, "runtime.makeslice") + // result: (MakeResult (Addr {ir.Syms.Zerobase} (SB)) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_1 := v.Args[1] + if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { + break + } + v_2 := v.Args[2] + if v_2.Op != OpConst64 || auxIntToInt64(v_2.AuxInt) != 0 || !(isSameCall(callAux, "runtime.makeslice")) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpAddr, v.Type.FieldType(0)) + v0.Aux = symToAux(ir.Syms.Zerobase) + v1 := b.NewValue0(v.Pos, OpSB, typ.Uintptr) + v0.AddArg(v1) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {callAux} _ (Const32 [0]) (Const32 [0]) mem) + // cond: isSameCall(callAux, "runtime.makeslice") + // result: (MakeResult (Addr {ir.Syms.Zerobase} (SB)) mem) + for { + if len(v.Args) != 4 { + break + } + callAux := auxToCall(v.Aux) + mem := v.Args[3] + v_1 := v.Args[1] + if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 0 { + break + } + v_2 := v.Args[2] + if v_2.Op != OpConst32 || auxIntToInt32(v_2.AuxInt) != 0 || !(isSameCall(callAux, "runtime.makeslice")) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpAddr, v.Type.FieldType(0)) + v0.Aux = symToAux(ir.Syms.Zerobase) + v1 := b.NewValue0(v.Pos, OpSB, typ.Uintptr) + v0.AddArg(v1) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {f} typ_ x y mem) + // cond: isSameCall(f, "runtime.efaceeq") && isDirectAndComparableType(typ_) && clobber(v) + // result: (MakeResult (EqPtr x y) mem) + for { + if len(v.Args) != 4 { + break + } + f := auxToCall(v.Aux) + mem := v.Args[3] + typ_ := v.Args[0] + x := v.Args[1] + y := v.Args[2] + if !(isSameCall(f, "runtime.efaceeq") && isDirectAndComparableType(typ_) && clobber(v)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEqPtr, typ.Bool) + v0.AddArg2(x, y) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {f} itab x y mem) + // cond: isSameCall(f, "runtime.ifaceeq") && isDirectAndComparableIface(itab) && clobber(v) + // result: (MakeResult (EqPtr x y) mem) + for { + if len(v.Args) != 4 { + break + } + f := auxToCall(v.Aux) + mem := v.Args[3] + itab := v.Args[0] + x := v.Args[1] + y := v.Args[2] + if !(isSameCall(f, "runtime.ifaceeq") && isDirectAndComparableIface(itab) && clobber(v)) { + break + } + v.reset(OpMakeResult) + v0 := b.NewValue0(v.Pos, OpEqPtr, typ.Bool) + v0.AddArg2(x, y) + v.AddArg2(v0, mem) + return true + } + // match: (StaticLECall {f} [argsize] typ_ map_ key:(SelectN [0] sbts:(StaticLECall {g} _ ptr len mem)) m:(SelectN [1] sbts)) + // cond: (isSameCall(f, "runtime.mapaccess1_faststr") || isSameCall(f, "runtime.mapaccess2_faststr") || isSameCall(f, "runtime.mapdelete_faststr")) && isSameCall(g, "runtime.slicebytetostring") && key.Uses == 1 && sbts.Uses == 2 && resetCopy(m, mem) && clobber(sbts) && clobber(key) + // result: (StaticLECall {f} [argsize] typ_ map_ (StringMake ptr len) mem) + for { + if len(v.Args) != 4 { + break + } + argsize := auxIntToInt32(v.AuxInt) + f := auxToCall(v.Aux) + _ = v.Args[3] + typ_ := v.Args[0] + map_ := v.Args[1] + key := v.Args[2] + if key.Op != OpSelectN || auxIntToInt64(key.AuxInt) != 0 { + break + } + sbts := key.Args[0] + if sbts.Op != OpStaticLECall || len(sbts.Args) != 4 { + break + } + g := auxToCall(sbts.Aux) + mem := sbts.Args[3] + ptr := sbts.Args[1] + len := sbts.Args[2] + m := v.Args[3] + if m.Op != OpSelectN || auxIntToInt64(m.AuxInt) != 1 || sbts != m.Args[0] || !((isSameCall(f, "runtime.mapaccess1_faststr") || isSameCall(f, "runtime.mapaccess2_faststr") || isSameCall(f, "runtime.mapdelete_faststr")) && isSameCall(g, "runtime.slicebytetostring") && key.Uses == 1 && sbts.Uses == 2 && resetCopy(m, mem) && clobber(sbts) && clobber(key)) { + break + } + v.reset(OpStaticLECall) + v.AuxInt = int32ToAuxInt(argsize) + v.Aux = callToAux(f) + v0 := b.NewValue0(v.Pos, OpStringMake, typ.String) + v0.AddArg2(ptr, len) + v.AddArg4(typ_, map_, v0, mem) + return true + } + // match: (StaticLECall {f} [argsize] dict_ key:(SelectN [0] sbts:(StaticLECall {g} _ ptr len mem)) m:(SelectN [1] sbts)) + // cond: isSameCall(f, "unique.Make[go.shape.string]") && isSameCall(g, "runtime.slicebytetostring") && key.Uses == 1 && sbts.Uses == 2 && resetCopy(m, mem) && clobber(sbts) && clobber(key) + // result: (StaticLECall {f} [argsize] dict_ (StringMake ptr len) mem) + for { + if len(v.Args) != 3 { + break + } + argsize := auxIntToInt32(v.AuxInt) + f := auxToCall(v.Aux) + _ = v.Args[2] + dict_ := v.Args[0] + key := v.Args[1] + if key.Op != OpSelectN || auxIntToInt64(key.AuxInt) != 0 { + break + } + sbts := key.Args[0] + if sbts.Op != OpStaticLECall || len(sbts.Args) != 4 { + break + } + g := auxToCall(sbts.Aux) + mem := sbts.Args[3] + ptr := sbts.Args[1] + len := sbts.Args[2] + m := v.Args[2] + if m.Op != OpSelectN || auxIntToInt64(m.AuxInt) != 1 || sbts != m.Args[0] || !(isSameCall(f, "unique.Make[go.shape.string]") && isSameCall(g, "runtime.slicebytetostring") && key.Uses == 1 && sbts.Uses == 2 && resetCopy(m, mem) && clobber(sbts) && clobber(key)) { + break + } + v.reset(OpStaticLECall) + v.AuxInt = int32ToAuxInt(argsize) + v.Aux = callToAux(f) + v0 := b.NewValue0(v.Pos, OpStringMake, typ.String) + v0.AddArg2(ptr, len) + v.AddArg3(dict_, v0, mem) + return true + } + return false +} +func rewriteValuegeneric_OpStore(v *Value) bool { + v_2 := v.Args[2] + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Store {t1} p1 (Load p2 mem) mem) + // cond: isSamePtr(p1, p2) && t2.Size() == t1.Size() + // result: mem + for { + t1 := auxToType(v.Aux) + p1 := v_0 + if v_1.Op != OpLoad { + break + } + t2 := v_1.Type + mem := v_1.Args[1] + p2 := v_1.Args[0] + if mem != v_2 || !(isSamePtr(p1, p2) && t2.Size() == t1.Size()) { + break + } + v.copyOf(mem) + return true + } + // match: (Store {t1} p1 (Load p2 oldmem) mem:(Store {t3} p3 _ oldmem)) + // cond: isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size()) + // result: mem + for { + t1 := auxToType(v.Aux) + p1 := v_0 + if v_1.Op != OpLoad { + break + } + t2 := v_1.Type + oldmem := v_1.Args[1] + p2 := v_1.Args[0] + mem := v_2 + if mem.Op != OpStore { + break + } + t3 := auxToType(mem.Aux) + _ = mem.Args[2] + p3 := mem.Args[0] + if oldmem != mem.Args[2] || !(isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size())) { + break + } + v.copyOf(mem) + return true + } + // match: (Store {t1} p1 (Load p2 oldmem) mem:(Store {t3} p3 _ (Store {t4} p4 _ oldmem))) + // cond: isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size()) && disjoint(p1, t1.Size(), p4, t4.Size()) + // result: mem + for { + t1 := auxToType(v.Aux) + p1 := v_0 + if v_1.Op != OpLoad { + break + } + t2 := v_1.Type + oldmem := v_1.Args[1] + p2 := v_1.Args[0] + mem := v_2 + if mem.Op != OpStore { + break + } + t3 := auxToType(mem.Aux) + _ = mem.Args[2] + p3 := mem.Args[0] + mem_2 := mem.Args[2] + if mem_2.Op != OpStore { + break + } + t4 := auxToType(mem_2.Aux) + _ = mem_2.Args[2] + p4 := mem_2.Args[0] + if oldmem != mem_2.Args[2] || !(isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size()) && disjoint(p1, t1.Size(), p4, t4.Size())) { + break + } + v.copyOf(mem) + return true + } + // match: (Store {t1} p1 (Load p2 oldmem) mem:(Store {t3} p3 _ (Store {t4} p4 _ (Store {t5} p5 _ oldmem)))) + // cond: isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size()) && disjoint(p1, t1.Size(), p4, t4.Size()) && disjoint(p1, t1.Size(), p5, t5.Size()) + // result: mem + for { + t1 := auxToType(v.Aux) + p1 := v_0 + if v_1.Op != OpLoad { + break + } + t2 := v_1.Type + oldmem := v_1.Args[1] + p2 := v_1.Args[0] + mem := v_2 + if mem.Op != OpStore { + break + } + t3 := auxToType(mem.Aux) + _ = mem.Args[2] + p3 := mem.Args[0] + mem_2 := mem.Args[2] + if mem_2.Op != OpStore { + break + } + t4 := auxToType(mem_2.Aux) + _ = mem_2.Args[2] + p4 := mem_2.Args[0] + mem_2_2 := mem_2.Args[2] + if mem_2_2.Op != OpStore { + break + } + t5 := auxToType(mem_2_2.Aux) + _ = mem_2_2.Args[2] + p5 := mem_2_2.Args[0] + if oldmem != mem_2_2.Args[2] || !(isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size()) && disjoint(p1, t1.Size(), p4, t4.Size()) && disjoint(p1, t1.Size(), p5, t5.Size())) { + break + } + v.copyOf(mem) + return true + } + // match: (Store {t} (OffPtr [o] p1) x mem:(Zero [n] p2 _)) + // cond: isConstZero(x) && o >= 0 && t.Size() + o <= n && isSamePtr(p1, p2) + // result: mem + for { + t := auxToType(v.Aux) + if v_0.Op != OpOffPtr { + break + } + o := auxIntToInt64(v_0.AuxInt) + p1 := v_0.Args[0] + x := v_1 + mem := v_2 + if mem.Op != OpZero { + break + } + n := auxIntToInt64(mem.AuxInt) + p2 := mem.Args[0] + if !(isConstZero(x) && o >= 0 && t.Size()+o <= n && isSamePtr(p1, p2)) { + break + } + v.copyOf(mem) + return true + } + // match: (Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Zero [n] p3 _))) + // cond: isConstZero(x) && o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p3) && disjoint(op, t1.Size(), p2, t2.Size()) + // result: mem + for { + t1 := auxToType(v.Aux) + op := v_0 + if op.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op.AuxInt) + p1 := op.Args[0] + x := v_1 + mem := v_2 + if mem.Op != OpStore { + break + } + t2 := auxToType(mem.Aux) + _ = mem.Args[2] + p2 := mem.Args[0] + mem_2 := mem.Args[2] + if mem_2.Op != OpZero { + break + } + n := auxIntToInt64(mem_2.AuxInt) + p3 := mem_2.Args[0] + if !(isConstZero(x) && o1 >= 0 && t1.Size()+o1 <= n && isSamePtr(p1, p3) && disjoint(op, t1.Size(), p2, t2.Size())) { + break + } + v.copyOf(mem) + return true + } + // match: (Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Zero [n] p4 _)))) + // cond: isConstZero(x) && o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p4) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) + // result: mem + for { + t1 := auxToType(v.Aux) + op := v_0 + if op.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op.AuxInt) + p1 := op.Args[0] + x := v_1 + mem := v_2 + if mem.Op != OpStore { + break + } + t2 := auxToType(mem.Aux) + _ = mem.Args[2] + p2 := mem.Args[0] + mem_2 := mem.Args[2] + if mem_2.Op != OpStore { + break + } + t3 := auxToType(mem_2.Aux) + _ = mem_2.Args[2] + p3 := mem_2.Args[0] + mem_2_2 := mem_2.Args[2] + if mem_2_2.Op != OpZero { + break + } + n := auxIntToInt64(mem_2_2.AuxInt) + p4 := mem_2_2.Args[0] + if !(isConstZero(x) && o1 >= 0 && t1.Size()+o1 <= n && isSamePtr(p1, p4) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size())) { + break + } + v.copyOf(mem) + return true + } + // match: (Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ (Zero [n] p5 _))))) + // cond: isConstZero(x) && o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p5) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size()) + // result: mem + for { + t1 := auxToType(v.Aux) + op := v_0 + if op.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op.AuxInt) + p1 := op.Args[0] + x := v_1 + mem := v_2 + if mem.Op != OpStore { + break + } + t2 := auxToType(mem.Aux) + _ = mem.Args[2] + p2 := mem.Args[0] + mem_2 := mem.Args[2] + if mem_2.Op != OpStore { + break + } + t3 := auxToType(mem_2.Aux) + _ = mem_2.Args[2] + p3 := mem_2.Args[0] + mem_2_2 := mem_2.Args[2] + if mem_2_2.Op != OpStore { + break + } + t4 := auxToType(mem_2_2.Aux) + _ = mem_2_2.Args[2] + p4 := mem_2_2.Args[0] + mem_2_2_2 := mem_2_2.Args[2] + if mem_2_2_2.Op != OpZero { + break + } + n := auxIntToInt64(mem_2_2_2.AuxInt) + p5 := mem_2_2_2.Args[0] + if !(isConstZero(x) && o1 >= 0 && t1.Size()+o1 <= n && isSamePtr(p1, p5) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size())) { + break + } + v.copyOf(mem) + return true + } + // match: (Store _ (StructMake ___) _) + // result: rewriteStructStore(v) + for { + if v_1.Op != OpStructMake { + break + } + v.copyOf(rewriteStructStore(v)) + return true + } + // match: (Store {t} dst (Load src mem) mem) + // cond: !CanSSA(t) + // result: (Move {t} [t.Size()] dst src mem) + for { + t := auxToType(v.Aux) + dst := v_0 + if v_1.Op != OpLoad { + break + } + mem := v_1.Args[1] + src := v_1.Args[0] + if mem != v_2 || !(!CanSSA(t)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(t.Size()) + v.Aux = typeToAux(t) + v.AddArg3(dst, src, mem) + return true + } + // match: (Store {t} dst (Load src mem) (VarDef {x} mem)) + // cond: !CanSSA(t) + // result: (Move {t} [t.Size()] dst src (VarDef {x} mem)) + for { + t := auxToType(v.Aux) + dst := v_0 + if v_1.Op != OpLoad { + break + } + mem := v_1.Args[1] + src := v_1.Args[0] + if v_2.Op != OpVarDef { + break + } + x := auxToSym(v_2.Aux) + if mem != v_2.Args[0] || !(!CanSSA(t)) { + break + } + v.reset(OpMove) + v.AuxInt = int64ToAuxInt(t.Size()) + v.Aux = typeToAux(t) + v0 := b.NewValue0(v.Pos, OpVarDef, types.TypeMem) + v0.Aux = symToAux(x) + v0.AddArg(mem) + v.AddArg3(dst, src, v0) + return true + } + // match: (Store dst (ArrayMake1 e) mem) + // result: (Store {e.Type} dst e mem) + for { + dst := v_0 + if v_1.Op != OpArrayMake1 { + break + } + e := v_1.Args[0] + mem := v_2 + v.reset(OpStore) + v.Aux = typeToAux(e.Type) + v.AddArg3(dst, e, mem) + return true + } + // match: (Store _ (Empty) mem) + // result: mem + for { + if v_1.Op != OpEmpty { + break + } + mem := v_2 + v.copyOf(mem) + return true + } + // match: (Store (SelectN [0] call:(StaticLECall ___)) x mem:(SelectN [1] call)) + // cond: isConstZero(x) && isMalloc(call.Aux) + // result: mem + for { + if v_0.Op != OpSelectN || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + call := v_0.Args[0] + if call.Op != OpStaticLECall { + break + } + x := v_1 + mem := v_2 + if mem.Op != OpSelectN || auxIntToInt64(mem.AuxInt) != 1 || call != mem.Args[0] || !(isConstZero(x) && isMalloc(call.Aux)) { + break + } + v.copyOf(mem) + return true + } + // match: (Store (OffPtr (SelectN [0] call:(StaticLECall ___))) x mem:(SelectN [1] call)) + // cond: isConstZero(x) && isMalloc(call.Aux) + // result: mem + for { + if v_0.Op != OpOffPtr { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpSelectN || auxIntToInt64(v_0_0.AuxInt) != 0 { + break + } + call := v_0_0.Args[0] + if call.Op != OpStaticLECall { + break + } + x := v_1 + mem := v_2 + if mem.Op != OpSelectN || auxIntToInt64(mem.AuxInt) != 1 || call != mem.Args[0] || !(isConstZero(x) && isMalloc(call.Aux)) { + break + } + v.copyOf(mem) + return true + } + // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [0] p2) d2 m3:(Move [n] p3 _ mem))) + // cond: m2.Uses == 1 && m3.Uses == 1 && o1 == t2.Size() && n == t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && clobber(m2, m3) + // result: (Store {t1} op1 d1 (Store {t2} op2 d2 mem)) + for { + t1 := auxToType(v.Aux) + op1 := v_0 + if op1.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op1.AuxInt) + p1 := op1.Args[0] + d1 := v_1 + m2 := v_2 + if m2.Op != OpStore { + break + } + t2 := auxToType(m2.Aux) + _ = m2.Args[2] + op2 := m2.Args[0] + if op2.Op != OpOffPtr || auxIntToInt64(op2.AuxInt) != 0 { + break + } + p2 := op2.Args[0] + d2 := m2.Args[1] + m3 := m2.Args[2] + if m3.Op != OpMove { + break + } + n := auxIntToInt64(m3.AuxInt) + mem := m3.Args[2] + p3 := m3.Args[0] + if !(m2.Uses == 1 && m3.Uses == 1 && o1 == t2.Size() && n == t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && clobber(m2, m3)) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t1) + v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v0.Aux = typeToAux(t2) + v0.AddArg3(op2, d2, mem) + v.AddArg3(op1, d1, v0) + return true + } + // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [o2] p2) d2 m3:(Store {t3} op3:(OffPtr [0] p3) d3 m4:(Move [n] p4 _ mem)))) + // cond: m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && o2 == t3.Size() && o1-o2 == t2.Size() && n == t3.Size() + t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && clobber(m2, m3, m4) + // result: (Store {t1} op1 d1 (Store {t2} op2 d2 (Store {t3} op3 d3 mem))) + for { + t1 := auxToType(v.Aux) + op1 := v_0 + if op1.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op1.AuxInt) + p1 := op1.Args[0] + d1 := v_1 + m2 := v_2 + if m2.Op != OpStore { + break + } + t2 := auxToType(m2.Aux) + _ = m2.Args[2] + op2 := m2.Args[0] + if op2.Op != OpOffPtr { + break + } + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d2 := m2.Args[1] + m3 := m2.Args[2] + if m3.Op != OpStore { + break + } + t3 := auxToType(m3.Aux) + _ = m3.Args[2] + op3 := m3.Args[0] + if op3.Op != OpOffPtr || auxIntToInt64(op3.AuxInt) != 0 { + break + } + p3 := op3.Args[0] + d3 := m3.Args[1] + m4 := m3.Args[2] + if m4.Op != OpMove { + break + } + n := auxIntToInt64(m4.AuxInt) + mem := m4.Args[2] + p4 := m4.Args[0] + if !(m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && o2 == t3.Size() && o1-o2 == t2.Size() && n == t3.Size()+t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && clobber(m2, m3, m4)) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t1) + v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v0.Aux = typeToAux(t2) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v1.AddArg3(op3, d3, mem) + v0.AddArg3(op2, d2, v1) + v.AddArg3(op1, d1, v0) + return true + } + // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [o2] p2) d2 m3:(Store {t3} op3:(OffPtr [o3] p3) d3 m4:(Store {t4} op4:(OffPtr [0] p4) d4 m5:(Move [n] p5 _ mem))))) + // cond: m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && m5.Uses == 1 && o3 == t4.Size() && o2-o3 == t3.Size() && o1-o2 == t2.Size() && n == t4.Size() + t3.Size() + t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && clobber(m2, m3, m4, m5) + // result: (Store {t1} op1 d1 (Store {t2} op2 d2 (Store {t3} op3 d3 (Store {t4} op4 d4 mem)))) + for { + t1 := auxToType(v.Aux) + op1 := v_0 + if op1.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op1.AuxInt) + p1 := op1.Args[0] + d1 := v_1 + m2 := v_2 + if m2.Op != OpStore { + break + } + t2 := auxToType(m2.Aux) + _ = m2.Args[2] + op2 := m2.Args[0] + if op2.Op != OpOffPtr { + break + } + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d2 := m2.Args[1] + m3 := m2.Args[2] + if m3.Op != OpStore { + break + } + t3 := auxToType(m3.Aux) + _ = m3.Args[2] + op3 := m3.Args[0] + if op3.Op != OpOffPtr { + break + } + o3 := auxIntToInt64(op3.AuxInt) + p3 := op3.Args[0] + d3 := m3.Args[1] + m4 := m3.Args[2] + if m4.Op != OpStore { + break + } + t4 := auxToType(m4.Aux) + _ = m4.Args[2] + op4 := m4.Args[0] + if op4.Op != OpOffPtr || auxIntToInt64(op4.AuxInt) != 0 { + break + } + p4 := op4.Args[0] + d4 := m4.Args[1] + m5 := m4.Args[2] + if m5.Op != OpMove { + break + } + n := auxIntToInt64(m5.AuxInt) + mem := m5.Args[2] + p5 := m5.Args[0] + if !(m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && m5.Uses == 1 && o3 == t4.Size() && o2-o3 == t3.Size() && o1-o2 == t2.Size() && n == t4.Size()+t3.Size()+t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && clobber(m2, m3, m4, m5)) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t1) + v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v0.Aux = typeToAux(t2) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v2.Aux = typeToAux(t4) + v2.AddArg3(op4, d4, mem) + v1.AddArg3(op3, d3, v2) + v0.AddArg3(op2, d2, v1) + v.AddArg3(op1, d1, v0) + return true + } + // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [0] p2) d2 m3:(Zero [n] p3 mem))) + // cond: m2.Uses == 1 && m3.Uses == 1 && o1 == t2.Size() && n == t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && clobber(m2, m3) + // result: (Store {t1} op1 d1 (Store {t2} op2 d2 mem)) + for { + t1 := auxToType(v.Aux) + op1 := v_0 + if op1.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op1.AuxInt) + p1 := op1.Args[0] + d1 := v_1 + m2 := v_2 + if m2.Op != OpStore { + break + } + t2 := auxToType(m2.Aux) + _ = m2.Args[2] + op2 := m2.Args[0] + if op2.Op != OpOffPtr || auxIntToInt64(op2.AuxInt) != 0 { + break + } + p2 := op2.Args[0] + d2 := m2.Args[1] + m3 := m2.Args[2] + if m3.Op != OpZero { + break + } + n := auxIntToInt64(m3.AuxInt) + mem := m3.Args[1] + p3 := m3.Args[0] + if !(m2.Uses == 1 && m3.Uses == 1 && o1 == t2.Size() && n == t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && clobber(m2, m3)) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t1) + v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v0.Aux = typeToAux(t2) + v0.AddArg3(op2, d2, mem) + v.AddArg3(op1, d1, v0) + return true + } + // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [o2] p2) d2 m3:(Store {t3} op3:(OffPtr [0] p3) d3 m4:(Zero [n] p4 mem)))) + // cond: m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && o2 == t3.Size() && o1-o2 == t2.Size() && n == t3.Size() + t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && clobber(m2, m3, m4) + // result: (Store {t1} op1 d1 (Store {t2} op2 d2 (Store {t3} op3 d3 mem))) + for { + t1 := auxToType(v.Aux) + op1 := v_0 + if op1.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op1.AuxInt) + p1 := op1.Args[0] + d1 := v_1 + m2 := v_2 + if m2.Op != OpStore { + break + } + t2 := auxToType(m2.Aux) + _ = m2.Args[2] + op2 := m2.Args[0] + if op2.Op != OpOffPtr { + break + } + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d2 := m2.Args[1] + m3 := m2.Args[2] + if m3.Op != OpStore { + break + } + t3 := auxToType(m3.Aux) + _ = m3.Args[2] + op3 := m3.Args[0] + if op3.Op != OpOffPtr || auxIntToInt64(op3.AuxInt) != 0 { + break + } + p3 := op3.Args[0] + d3 := m3.Args[1] + m4 := m3.Args[2] + if m4.Op != OpZero { + break + } + n := auxIntToInt64(m4.AuxInt) + mem := m4.Args[1] + p4 := m4.Args[0] + if !(m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && o2 == t3.Size() && o1-o2 == t2.Size() && n == t3.Size()+t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && clobber(m2, m3, m4)) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t1) + v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v0.Aux = typeToAux(t2) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v1.AddArg3(op3, d3, mem) + v0.AddArg3(op2, d2, v1) + v.AddArg3(op1, d1, v0) + return true + } + // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [o2] p2) d2 m3:(Store {t3} op3:(OffPtr [o3] p3) d3 m4:(Store {t4} op4:(OffPtr [0] p4) d4 m5:(Zero [n] p5 mem))))) + // cond: m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && m5.Uses == 1 && o3 == t4.Size() && o2-o3 == t3.Size() && o1-o2 == t2.Size() && n == t4.Size() + t3.Size() + t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && clobber(m2, m3, m4, m5) + // result: (Store {t1} op1 d1 (Store {t2} op2 d2 (Store {t3} op3 d3 (Store {t4} op4 d4 mem)))) + for { + t1 := auxToType(v.Aux) + op1 := v_0 + if op1.Op != OpOffPtr { + break + } + o1 := auxIntToInt64(op1.AuxInt) + p1 := op1.Args[0] + d1 := v_1 + m2 := v_2 + if m2.Op != OpStore { + break + } + t2 := auxToType(m2.Aux) + _ = m2.Args[2] + op2 := m2.Args[0] + if op2.Op != OpOffPtr { + break + } + o2 := auxIntToInt64(op2.AuxInt) + p2 := op2.Args[0] + d2 := m2.Args[1] + m3 := m2.Args[2] + if m3.Op != OpStore { + break + } + t3 := auxToType(m3.Aux) + _ = m3.Args[2] + op3 := m3.Args[0] + if op3.Op != OpOffPtr { + break + } + o3 := auxIntToInt64(op3.AuxInt) + p3 := op3.Args[0] + d3 := m3.Args[1] + m4 := m3.Args[2] + if m4.Op != OpStore { + break + } + t4 := auxToType(m4.Aux) + _ = m4.Args[2] + op4 := m4.Args[0] + if op4.Op != OpOffPtr || auxIntToInt64(op4.AuxInt) != 0 { + break + } + p4 := op4.Args[0] + d4 := m4.Args[1] + m5 := m4.Args[2] + if m5.Op != OpZero { + break + } + n := auxIntToInt64(m5.AuxInt) + mem := m5.Args[1] + p5 := m5.Args[0] + if !(m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && m5.Uses == 1 && o3 == t4.Size() && o2-o3 == t3.Size() && o1-o2 == t2.Size() && n == t4.Size()+t3.Size()+t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && clobber(m2, m3, m4, m5)) { + break + } + v.reset(OpStore) + v.Aux = typeToAux(t1) + v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v0.Aux = typeToAux(t2) + v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v1.Aux = typeToAux(t3) + v2 := b.NewValue0(v.Pos, OpStore, types.TypeMem) + v2.Aux = typeToAux(t4) + v2.AddArg3(op4, d4, mem) + v1.AddArg3(op3, d3, v2) + v0.AddArg3(op2, d2, v1) + v.AddArg3(op1, d1, v0) + return true + } + return false +} +func rewriteValuegeneric_OpStringLen(v *Value) bool { + v_0 := v.Args[0] + // match: (StringLen (StringMake _ (Const64 [c]))) + // result: (Const64 [c]) + for { + if v_0.Op != OpStringMake { + break + } + _ = v_0.Args[1] + v_0_1 := v_0.Args[1] + if v_0_1.Op != OpConst64 { + break + } + t := v_0_1.Type + c := auxIntToInt64(v_0_1.AuxInt) + v.reset(OpConst64) + v.Type = t + v.AuxInt = int64ToAuxInt(c) + return true + } + return false +} +func rewriteValuegeneric_OpStringPtr(v *Value) bool { + v_0 := v.Args[0] + // match: (StringPtr (StringMake (Addr {s} base) _)) + // result: (Addr {s} base) + for { + if v_0.Op != OpStringMake { + break + } + v_0_0 := v_0.Args[0] + if v_0_0.Op != OpAddr { + break + } + t := v_0_0.Type + s := auxToSym(v_0_0.Aux) + base := v_0_0.Args[0] + v.reset(OpAddr) + v.Type = t + v.Aux = symToAux(s) + v.AddArg(base) + return true + } + return false +} +func rewriteValuegeneric_OpStructSelect(v *Value) bool { + v_0 := v.Args[0] + b := v.Block + // match: (StructSelect [i] x:(StructMake ___)) + // result: x.Args[i] + for { + i := auxIntToInt64(v.AuxInt) + x := v_0 + if x.Op != OpStructMake { + break + } + v.copyOf(x.Args[i]) + return true + } + // match: (StructSelect [i] x:(Load ptr mem)) + // cond: !CanSSA(t) + // result: @x.Block (Load (OffPtr [t.FieldOff(int(i))] ptr) mem) + for { + i := auxIntToInt64(v.AuxInt) + x := v_0 + if x.Op != OpLoad { + break + } + t := x.Type + mem := x.Args[1] + ptr := x.Args[0] + if !(!CanSSA(t)) { + break + } + b = x.Block + v0 := b.NewValue0(v.Pos, OpLoad, v.Type) + v.copyOf(v0) + v1 := b.NewValue0(v.Pos, OpOffPtr, v.Type.PtrTo()) + v1.AuxInt = int64ToAuxInt(t.FieldOff(int(i))) + v1.AddArg(ptr) + v0.AddArg2(v1, mem) + return true + } + // match: (StructSelect (IData x)) + // cond: v.Type.Size() > 0 + // result: (IData x) + for { + if v_0.Op != OpIData { + break + } + x := v_0.Args[0] + if !(v.Type.Size() > 0) { + break + } + v.reset(OpIData) + v.AddArg(x) + return true + } + // match: (StructSelect (IData x)) + // cond: v.Type.Size() == 0 + // result: (Empty) + for { + if v_0.Op != OpIData { + break + } + if !(v.Type.Size() == 0) { + break + } + v.reset(OpEmpty) + return true + } + return false +} +func rewriteValuegeneric_OpSub16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Sub16 (Const16 [c]) (Const16 [d])) + // result: (Const16 [c-d]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + break + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c - d) + return true + } + // match: (Sub16 x (Const16 [c])) + // cond: x.Op != OpConst16 + // result: (Add16 (Const16 [-c]) x) + for { + x := v_0 + if v_1.Op != OpConst16 { + break + } + t := v_1.Type + c := auxIntToInt16(v_1.AuxInt) + if !(x.Op != OpConst16) { + break + } + v.reset(OpAdd16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(-c) + v.AddArg2(v0, x) + return true + } + // match: (Sub16 (Mul16 x y) (Mul16 x z)) + // result: (Mul16 x (Sub16 y z)) + for { + t := v.Type + if v_0.Op != OpMul16 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if v_1.Op != OpMul16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + z := v_1_1 + v.reset(OpMul16) + v0 := b.NewValue0(v.Pos, OpSub16, t) + v0.AddArg2(y, z) + v.AddArg2(x, v0) + return true + } + } + break + } + // match: (Sub16 x x) + // result: (Const16 [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Sub16 (Neg16 x) (Com16 x)) + // result: (Const16 [1]) + for { + if v_0.Op != OpNeg16 { + break + } + x := v_0.Args[0] + if v_1.Op != OpCom16 || x != v_1.Args[0] { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(1) + return true + } + // match: (Sub16 (Com16 x) (Neg16 x)) + // result: (Const16 [-1]) + for { + if v_0.Op != OpCom16 { + break + } + x := v_0.Args[0] + if v_1.Op != OpNeg16 || x != v_1.Args[0] { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(-1) + return true + } + // match: (Sub16 (Add16 t x) (Add16 t y)) + // result: (Sub16 x y) + for { + if v_0.Op != OpAdd16 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + t := v_0_0 + x := v_0_1 + if v_1.Op != OpAdd16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if t != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpSub16) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Sub16 (Add16 x y) x) + // result: y + for { + if v_0.Op != OpAdd16 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if x != v_1 { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (Sub16 (Add16 x y) y) + // result: x + for { + if v_0.Op != OpAdd16 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if y != v_1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Sub16 (Sub16 x y) x) + // result: (Neg16 y) + for { + if v_0.Op != OpSub16 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpNeg16) + v.AddArg(y) + return true + } + // match: (Sub16 x (Add16 x y)) + // result: (Neg16 y) + for { + x := v_0 + if v_1.Op != OpAdd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpNeg16) + v.AddArg(y) + return true + } + break + } + // match: (Sub16 x (Sub16 i:(Const16 ) z)) + // cond: (z.Op != OpConst16 && x.Op != OpConst16) + // result: (Sub16 (Add16 x z) i) + for { + x := v_0 + if v_1.Op != OpSub16 { + break + } + z := v_1.Args[1] + i := v_1.Args[0] + if i.Op != OpConst16 { + break + } + t := i.Type + if !(z.Op != OpConst16 && x.Op != OpConst16) { + break + } + v.reset(OpSub16) + v0 := b.NewValue0(v.Pos, OpAdd16, t) + v0.AddArg2(x, z) + v.AddArg2(v0, i) + return true + } + // match: (Sub16 x (Add16 z i:(Const16 ))) + // cond: (z.Op != OpConst16 && x.Op != OpConst16) + // result: (Sub16 (Sub16 x z) i) + for { + x := v_0 + if v_1.Op != OpAdd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z := v_1_0 + i := v_1_1 + if i.Op != OpConst16 { + continue + } + t := i.Type + if !(z.Op != OpConst16 && x.Op != OpConst16) { + continue + } + v.reset(OpSub16) + v0 := b.NewValue0(v.Pos, OpSub16, t) + v0.AddArg2(x, z) + v.AddArg2(v0, i) + return true + } + break + } + // match: (Sub16 (Sub16 i:(Const16 ) z) x) + // cond: (z.Op != OpConst16 && x.Op != OpConst16) + // result: (Sub16 i (Add16 z x)) + for { + if v_0.Op != OpSub16 { + break + } + z := v_0.Args[1] + i := v_0.Args[0] + if i.Op != OpConst16 { + break + } + t := i.Type + x := v_1 + if !(z.Op != OpConst16 && x.Op != OpConst16) { + break + } + v.reset(OpSub16) + v0 := b.NewValue0(v.Pos, OpAdd16, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + // match: (Sub16 (Add16 z i:(Const16 )) x) + // cond: (z.Op != OpConst16 && x.Op != OpConst16) + // result: (Add16 i (Sub16 z x)) + for { + if v_0.Op != OpAdd16 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z := v_0_0 + i := v_0_1 + if i.Op != OpConst16 { + continue + } + t := i.Type + x := v_1 + if !(z.Op != OpConst16 && x.Op != OpConst16) { + continue + } + v.reset(OpAdd16) + v0 := b.NewValue0(v.Pos, OpSub16, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + break + } + // match: (Sub16 (Const16 [c]) (Sub16 (Const16 [d]) x)) + // result: (Add16 (Const16 [c-d]) x) + for { + if v_0.Op != OpConst16 { + break + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpSub16 { + break + } + x := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + break + } + d := auxIntToInt16(v_1_0.AuxInt) + v.reset(OpAdd16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + // match: (Sub16 (Const16 [c]) (Add16 (Const16 [d]) x)) + // result: (Sub16 (Const16 [c-d]) x) + for { + if v_0.Op != OpConst16 { + break + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpAdd16 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + continue + } + d := auxIntToInt16(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpSub16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpSub32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Sub32 (Const32 [c]) (Const32 [d])) + // result: (Const32 [c-d]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + break + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c - d) + return true + } + // match: (Sub32 x (Const32 [c])) + // cond: x.Op != OpConst32 + // result: (Add32 (Const32 [-c]) x) + for { + x := v_0 + if v_1.Op != OpConst32 { + break + } + t := v_1.Type + c := auxIntToInt32(v_1.AuxInt) + if !(x.Op != OpConst32) { + break + } + v.reset(OpAdd32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(-c) + v.AddArg2(v0, x) + return true + } + // match: (Sub32 (Mul32 x y) (Mul32 x z)) + // result: (Mul32 x (Sub32 y z)) + for { + t := v.Type + if v_0.Op != OpMul32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if v_1.Op != OpMul32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + z := v_1_1 + v.reset(OpMul32) + v0 := b.NewValue0(v.Pos, OpSub32, t) + v0.AddArg2(y, z) + v.AddArg2(x, v0) + return true + } + } + break + } + // match: (Sub32 x x) + // result: (Const32 [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Sub32 (Neg32 x) (Com32 x)) + // result: (Const32 [1]) + for { + if v_0.Op != OpNeg32 { + break + } + x := v_0.Args[0] + if v_1.Op != OpCom32 || x != v_1.Args[0] { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(1) + return true + } + // match: (Sub32 (Com32 x) (Neg32 x)) + // result: (Const32 [-1]) + for { + if v_0.Op != OpCom32 { + break + } + x := v_0.Args[0] + if v_1.Op != OpNeg32 || x != v_1.Args[0] { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(-1) + return true + } + // match: (Sub32 (Add32 t x) (Add32 t y)) + // result: (Sub32 x y) + for { + if v_0.Op != OpAdd32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + t := v_0_0 + x := v_0_1 + if v_1.Op != OpAdd32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if t != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpSub32) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Sub32 (Add32 x y) x) + // result: y + for { + if v_0.Op != OpAdd32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if x != v_1 { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (Sub32 (Add32 x y) y) + // result: x + for { + if v_0.Op != OpAdd32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if y != v_1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Sub32 (Sub32 x y) x) + // result: (Neg32 y) + for { + if v_0.Op != OpSub32 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpNeg32) + v.AddArg(y) + return true + } + // match: (Sub32 x (Add32 x y)) + // result: (Neg32 y) + for { + x := v_0 + if v_1.Op != OpAdd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpNeg32) + v.AddArg(y) + return true + } + break + } + // match: (Sub32 x (Sub32 i:(Const32 ) z)) + // cond: (z.Op != OpConst32 && x.Op != OpConst32) + // result: (Sub32 (Add32 x z) i) + for { + x := v_0 + if v_1.Op != OpSub32 { + break + } + z := v_1.Args[1] + i := v_1.Args[0] + if i.Op != OpConst32 { + break + } + t := i.Type + if !(z.Op != OpConst32 && x.Op != OpConst32) { + break + } + v.reset(OpSub32) + v0 := b.NewValue0(v.Pos, OpAdd32, t) + v0.AddArg2(x, z) + v.AddArg2(v0, i) + return true + } + // match: (Sub32 x (Add32 z i:(Const32 ))) + // cond: (z.Op != OpConst32 && x.Op != OpConst32) + // result: (Sub32 (Sub32 x z) i) + for { + x := v_0 + if v_1.Op != OpAdd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z := v_1_0 + i := v_1_1 + if i.Op != OpConst32 { + continue + } + t := i.Type + if !(z.Op != OpConst32 && x.Op != OpConst32) { + continue + } + v.reset(OpSub32) + v0 := b.NewValue0(v.Pos, OpSub32, t) + v0.AddArg2(x, z) + v.AddArg2(v0, i) + return true + } + break + } + // match: (Sub32 (Sub32 i:(Const32 ) z) x) + // cond: (z.Op != OpConst32 && x.Op != OpConst32) + // result: (Sub32 i (Add32 z x)) + for { + if v_0.Op != OpSub32 { + break + } + z := v_0.Args[1] + i := v_0.Args[0] + if i.Op != OpConst32 { + break + } + t := i.Type + x := v_1 + if !(z.Op != OpConst32 && x.Op != OpConst32) { + break + } + v.reset(OpSub32) + v0 := b.NewValue0(v.Pos, OpAdd32, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + // match: (Sub32 (Add32 z i:(Const32 )) x) + // cond: (z.Op != OpConst32 && x.Op != OpConst32) + // result: (Add32 i (Sub32 z x)) + for { + if v_0.Op != OpAdd32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z := v_0_0 + i := v_0_1 + if i.Op != OpConst32 { + continue + } + t := i.Type + x := v_1 + if !(z.Op != OpConst32 && x.Op != OpConst32) { + continue + } + v.reset(OpAdd32) + v0 := b.NewValue0(v.Pos, OpSub32, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + break + } + // match: (Sub32 (Const32 [c]) (Sub32 (Const32 [d]) x)) + // result: (Add32 (Const32 [c-d]) x) + for { + if v_0.Op != OpConst32 { + break + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpSub32 { + break + } + x := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + break + } + d := auxIntToInt32(v_1_0.AuxInt) + v.reset(OpAdd32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + // match: (Sub32 (Const32 [c]) (Add32 (Const32 [d]) x)) + // result: (Sub32 (Const32 [c-d]) x) + for { + if v_0.Op != OpConst32 { + break + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpAdd32 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + continue + } + d := auxIntToInt32(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpSub32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpSub32F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Sub32F (Const32F [c]) (Const32F [d])) + // cond: c-d == c-d + // result: (Const32F [c-d]) + for { + if v_0.Op != OpConst32F { + break + } + c := auxIntToFloat32(v_0.AuxInt) + if v_1.Op != OpConst32F { + break + } + d := auxIntToFloat32(v_1.AuxInt) + if !(c-d == c-d) { + break + } + v.reset(OpConst32F) + v.AuxInt = float32ToAuxInt(c - d) + return true + } + return false +} +func rewriteValuegeneric_OpSub64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Sub64 (Const64 [c]) (Const64 [d])) + // result: (Const64 [c-d]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + break + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c - d) + return true + } + // match: (Sub64 x (Const64 [c])) + // cond: x.Op != OpConst64 + // result: (Add64 (Const64 [-c]) x) + for { + x := v_0 + if v_1.Op != OpConst64 { + break + } + t := v_1.Type + c := auxIntToInt64(v_1.AuxInt) + if !(x.Op != OpConst64) { + break + } + v.reset(OpAdd64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(-c) + v.AddArg2(v0, x) + return true + } + // match: (Sub64 (Mul64 x y) (Mul64 x z)) + // result: (Mul64 x (Sub64 y z)) + for { + t := v.Type + if v_0.Op != OpMul64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if v_1.Op != OpMul64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + z := v_1_1 + v.reset(OpMul64) + v0 := b.NewValue0(v.Pos, OpSub64, t) + v0.AddArg2(y, z) + v.AddArg2(x, v0) + return true + } + } + break + } + // match: (Sub64 x x) + // result: (Const64 [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Sub64 (Neg64 x) (Com64 x)) + // result: (Const64 [1]) + for { + if v_0.Op != OpNeg64 { + break + } + x := v_0.Args[0] + if v_1.Op != OpCom64 || x != v_1.Args[0] { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(1) + return true + } + // match: (Sub64 (Com64 x) (Neg64 x)) + // result: (Const64 [-1]) + for { + if v_0.Op != OpCom64 { + break + } + x := v_0.Args[0] + if v_1.Op != OpNeg64 || x != v_1.Args[0] { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(-1) + return true + } + // match: (Sub64 (Add64 t x) (Add64 t y)) + // result: (Sub64 x y) + for { + if v_0.Op != OpAdd64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + t := v_0_0 + x := v_0_1 + if v_1.Op != OpAdd64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if t != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpSub64) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Sub64 (Add64 x y) x) + // result: y + for { + if v_0.Op != OpAdd64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if x != v_1 { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (Sub64 (Add64 x y) y) + // result: x + for { + if v_0.Op != OpAdd64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if y != v_1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Sub64 (Sub64 x y) x) + // result: (Neg64 y) + for { + if v_0.Op != OpSub64 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpNeg64) + v.AddArg(y) + return true + } + // match: (Sub64 x (Add64 x y)) + // result: (Neg64 y) + for { + x := v_0 + if v_1.Op != OpAdd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpNeg64) + v.AddArg(y) + return true + } + break + } + // match: (Sub64 x (Sub64 i:(Const64 ) z)) + // cond: (z.Op != OpConst64 && x.Op != OpConst64) + // result: (Sub64 (Add64 x z) i) + for { + x := v_0 + if v_1.Op != OpSub64 { + break + } + z := v_1.Args[1] + i := v_1.Args[0] + if i.Op != OpConst64 { + break + } + t := i.Type + if !(z.Op != OpConst64 && x.Op != OpConst64) { + break + } + v.reset(OpSub64) + v0 := b.NewValue0(v.Pos, OpAdd64, t) + v0.AddArg2(x, z) + v.AddArg2(v0, i) + return true + } + // match: (Sub64 x (Add64 z i:(Const64 ))) + // cond: (z.Op != OpConst64 && x.Op != OpConst64) + // result: (Sub64 (Sub64 x z) i) + for { + x := v_0 + if v_1.Op != OpAdd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z := v_1_0 + i := v_1_1 + if i.Op != OpConst64 { + continue + } + t := i.Type + if !(z.Op != OpConst64 && x.Op != OpConst64) { + continue + } + v.reset(OpSub64) + v0 := b.NewValue0(v.Pos, OpSub64, t) + v0.AddArg2(x, z) + v.AddArg2(v0, i) + return true + } + break + } + // match: (Sub64 (Sub64 i:(Const64 ) z) x) + // cond: (z.Op != OpConst64 && x.Op != OpConst64) + // result: (Sub64 i (Add64 z x)) + for { + if v_0.Op != OpSub64 { + break + } + z := v_0.Args[1] + i := v_0.Args[0] + if i.Op != OpConst64 { + break + } + t := i.Type + x := v_1 + if !(z.Op != OpConst64 && x.Op != OpConst64) { + break + } + v.reset(OpSub64) + v0 := b.NewValue0(v.Pos, OpAdd64, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + // match: (Sub64 (Add64 z i:(Const64 )) x) + // cond: (z.Op != OpConst64 && x.Op != OpConst64) + // result: (Add64 i (Sub64 z x)) + for { + if v_0.Op != OpAdd64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z := v_0_0 + i := v_0_1 + if i.Op != OpConst64 { + continue + } + t := i.Type + x := v_1 + if !(z.Op != OpConst64 && x.Op != OpConst64) { + continue + } + v.reset(OpAdd64) + v0 := b.NewValue0(v.Pos, OpSub64, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + break + } + // match: (Sub64 (Const64 [c]) (Sub64 (Const64 [d]) x)) + // result: (Add64 (Const64 [c-d]) x) + for { + if v_0.Op != OpConst64 { + break + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpSub64 { + break + } + x := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + break + } + d := auxIntToInt64(v_1_0.AuxInt) + v.reset(OpAdd64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + // match: (Sub64 (Const64 [c]) (Add64 (Const64 [d]) x)) + // result: (Sub64 (Const64 [c-d]) x) + for { + if v_0.Op != OpConst64 { + break + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpAdd64 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + continue + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpSub64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpSub64F(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + // match: (Sub64F (Const64F [c]) (Const64F [d])) + // cond: c-d == c-d + // result: (Const64F [c-d]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + if v_1.Op != OpConst64F { + break + } + d := auxIntToFloat64(v_1.AuxInt) + if !(c-d == c-d) { + break + } + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(c - d) + return true + } + return false +} +func rewriteValuegeneric_OpSub8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Sub8 (Const8 [c]) (Const8 [d])) + // result: (Const8 [c-d]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + break + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c - d) + return true + } + // match: (Sub8 x (Const8 [c])) + // cond: x.Op != OpConst8 + // result: (Add8 (Const8 [-c]) x) + for { + x := v_0 + if v_1.Op != OpConst8 { + break + } + t := v_1.Type + c := auxIntToInt8(v_1.AuxInt) + if !(x.Op != OpConst8) { + break + } + v.reset(OpAdd8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(-c) + v.AddArg2(v0, x) + return true + } + // match: (Sub8 (Mul8 x y) (Mul8 x z)) + // result: (Mul8 x (Sub8 y z)) + for { + t := v.Type + if v_0.Op != OpMul8 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if v_1.Op != OpMul8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + z := v_1_1 + v.reset(OpMul8) + v0 := b.NewValue0(v.Pos, OpSub8, t) + v0.AddArg2(y, z) + v.AddArg2(x, v0) + return true + } + } + break + } + // match: (Sub8 x x) + // result: (Const8 [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Sub8 (Neg8 x) (Com8 x)) + // result: (Const8 [1]) + for { + if v_0.Op != OpNeg8 { + break + } + x := v_0.Args[0] + if v_1.Op != OpCom8 || x != v_1.Args[0] { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(1) + return true + } + // match: (Sub8 (Com8 x) (Neg8 x)) + // result: (Const8 [-1]) + for { + if v_0.Op != OpCom8 { + break + } + x := v_0.Args[0] + if v_1.Op != OpNeg8 || x != v_1.Args[0] { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(-1) + return true + } + // match: (Sub8 (Add8 t x) (Add8 t y)) + // result: (Sub8 x y) + for { + if v_0.Op != OpAdd8 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + t := v_0_0 + x := v_0_1 + if v_1.Op != OpAdd8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if t != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpSub8) + v.AddArg2(x, y) + return true + } + } + break + } + // match: (Sub8 (Add8 x y) x) + // result: y + for { + if v_0.Op != OpAdd8 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if x != v_1 { + continue + } + v.copyOf(y) + return true + } + break + } + // match: (Sub8 (Add8 x y) y) + // result: x + for { + if v_0.Op != OpAdd8 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + x := v_0_0 + y := v_0_1 + if y != v_1 { + continue + } + v.copyOf(x) + return true + } + break + } + // match: (Sub8 (Sub8 x y) x) + // result: (Neg8 y) + for { + if v_0.Op != OpSub8 { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + if x != v_1 { + break + } + v.reset(OpNeg8) + v.AddArg(y) + return true + } + // match: (Sub8 x (Add8 x y)) + // result: (Neg8 y) + for { + x := v_0 + if v_1.Op != OpAdd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.reset(OpNeg8) + v.AddArg(y) + return true + } + break + } + // match: (Sub8 x (Sub8 i:(Const8 ) z)) + // cond: (z.Op != OpConst8 && x.Op != OpConst8) + // result: (Sub8 (Add8 x z) i) + for { + x := v_0 + if v_1.Op != OpSub8 { + break + } + z := v_1.Args[1] + i := v_1.Args[0] + if i.Op != OpConst8 { + break + } + t := i.Type + if !(z.Op != OpConst8 && x.Op != OpConst8) { + break + } + v.reset(OpSub8) + v0 := b.NewValue0(v.Pos, OpAdd8, t) + v0.AddArg2(x, z) + v.AddArg2(v0, i) + return true + } + // match: (Sub8 x (Add8 z i:(Const8 ))) + // cond: (z.Op != OpConst8 && x.Op != OpConst8) + // result: (Sub8 (Sub8 x z) i) + for { + x := v_0 + if v_1.Op != OpAdd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + z := v_1_0 + i := v_1_1 + if i.Op != OpConst8 { + continue + } + t := i.Type + if !(z.Op != OpConst8 && x.Op != OpConst8) { + continue + } + v.reset(OpSub8) + v0 := b.NewValue0(v.Pos, OpSub8, t) + v0.AddArg2(x, z) + v.AddArg2(v0, i) + return true + } + break + } + // match: (Sub8 (Sub8 i:(Const8 ) z) x) + // cond: (z.Op != OpConst8 && x.Op != OpConst8) + // result: (Sub8 i (Add8 z x)) + for { + if v_0.Op != OpSub8 { + break + } + z := v_0.Args[1] + i := v_0.Args[0] + if i.Op != OpConst8 { + break + } + t := i.Type + x := v_1 + if !(z.Op != OpConst8 && x.Op != OpConst8) { + break + } + v.reset(OpSub8) + v0 := b.NewValue0(v.Pos, OpAdd8, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + // match: (Sub8 (Add8 z i:(Const8 )) x) + // cond: (z.Op != OpConst8 && x.Op != OpConst8) + // result: (Add8 i (Sub8 z x)) + for { + if v_0.Op != OpAdd8 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + z := v_0_0 + i := v_0_1 + if i.Op != OpConst8 { + continue + } + t := i.Type + x := v_1 + if !(z.Op != OpConst8 && x.Op != OpConst8) { + continue + } + v.reset(OpAdd8) + v0 := b.NewValue0(v.Pos, OpSub8, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + break + } + // match: (Sub8 (Const8 [c]) (Sub8 (Const8 [d]) x)) + // result: (Add8 (Const8 [c-d]) x) + for { + if v_0.Op != OpConst8 { + break + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpSub8 { + break + } + x := v_1.Args[1] + v_1_0 := v_1.Args[0] + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + break + } + d := auxIntToInt8(v_1_0.AuxInt) + v.reset(OpAdd8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + // match: (Sub8 (Const8 [c]) (Add8 (Const8 [d]) x)) + // result: (Sub8 (Const8 [c-d]) x) + for { + if v_0.Op != OpConst8 { + break + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpAdd8 { + break + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + continue + } + d := auxIntToInt8(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpSub8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c - d) + v.AddArg2(v0, x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpTrunc(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc (Const64F [c])) + // result: (Const64F [math.Trunc(c)]) + for { + if v_0.Op != OpConst64F { + break + } + c := auxIntToFloat64(v_0.AuxInt) + v.reset(OpConst64F) + v.AuxInt = float64ToAuxInt(math.Trunc(c)) + return true + } + return false +} +func rewriteValuegeneric_OpTrunc16to8(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc16to8 (Const16 [c])) + // result: (Const8 [int8(c)]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(int8(c)) + return true + } + // match: (Trunc16to8 (ZeroExt8to16 x)) + // result: x + for { + if v_0.Op != OpZeroExt8to16 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc16to8 (SignExt8to16 x)) + // result: x + for { + if v_0.Op != OpSignExt8to16 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc16to8 (And16 (Const16 [y]) x)) + // cond: y&0xFF == 0xFF + // result: (Trunc16to8 x) + for { + if v_0.Op != OpAnd16 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst16 { + continue + } + y := auxIntToInt16(v_0_0.AuxInt) + x := v_0_1 + if !(y&0xFF == 0xFF) { + continue + } + v.reset(OpTrunc16to8) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpTrunc32to16(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc32to16 (Const32 [c])) + // result: (Const16 [int16(c)]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(int16(c)) + return true + } + // match: (Trunc32to16 (ZeroExt8to32 x)) + // result: (ZeroExt8to16 x) + for { + if v_0.Op != OpZeroExt8to32 { + break + } + x := v_0.Args[0] + v.reset(OpZeroExt8to16) + v.AddArg(x) + return true + } + // match: (Trunc32to16 (ZeroExt16to32 x)) + // result: x + for { + if v_0.Op != OpZeroExt16to32 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc32to16 (SignExt8to32 x)) + // result: (SignExt8to16 x) + for { + if v_0.Op != OpSignExt8to32 { + break + } + x := v_0.Args[0] + v.reset(OpSignExt8to16) + v.AddArg(x) + return true + } + // match: (Trunc32to16 (SignExt16to32 x)) + // result: x + for { + if v_0.Op != OpSignExt16to32 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc32to16 (And32 (Const32 [y]) x)) + // cond: y&0xFFFF == 0xFFFF + // result: (Trunc32to16 x) + for { + if v_0.Op != OpAnd32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst32 { + continue + } + y := auxIntToInt32(v_0_0.AuxInt) + x := v_0_1 + if !(y&0xFFFF == 0xFFFF) { + continue + } + v.reset(OpTrunc32to16) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpTrunc32to8(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc32to8 (Const32 [c])) + // result: (Const8 [int8(c)]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(int8(c)) + return true + } + // match: (Trunc32to8 (ZeroExt8to32 x)) + // result: x + for { + if v_0.Op != OpZeroExt8to32 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc32to8 (SignExt8to32 x)) + // result: x + for { + if v_0.Op != OpSignExt8to32 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc32to8 (And32 (Const32 [y]) x)) + // cond: y&0xFF == 0xFF + // result: (Trunc32to8 x) + for { + if v_0.Op != OpAnd32 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst32 { + continue + } + y := auxIntToInt32(v_0_0.AuxInt) + x := v_0_1 + if !(y&0xFF == 0xFF) { + continue + } + v.reset(OpTrunc32to8) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpTrunc64to16(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc64to16 (Const64 [c])) + // result: (Const16 [int16(c)]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(int16(c)) + return true + } + // match: (Trunc64to16 (ZeroExt8to64 x)) + // result: (ZeroExt8to16 x) + for { + if v_0.Op != OpZeroExt8to64 { + break + } + x := v_0.Args[0] + v.reset(OpZeroExt8to16) + v.AddArg(x) + return true + } + // match: (Trunc64to16 (ZeroExt16to64 x)) + // result: x + for { + if v_0.Op != OpZeroExt16to64 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc64to16 (SignExt8to64 x)) + // result: (SignExt8to16 x) + for { + if v_0.Op != OpSignExt8to64 { + break + } + x := v_0.Args[0] + v.reset(OpSignExt8to16) + v.AddArg(x) + return true + } + // match: (Trunc64to16 (SignExt16to64 x)) + // result: x + for { + if v_0.Op != OpSignExt16to64 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc64to16 (And64 (Const64 [y]) x)) + // cond: y&0xFFFF == 0xFFFF + // result: (Trunc64to16 x) + for { + if v_0.Op != OpAnd64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst64 { + continue + } + y := auxIntToInt64(v_0_0.AuxInt) + x := v_0_1 + if !(y&0xFFFF == 0xFFFF) { + continue + } + v.reset(OpTrunc64to16) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpTrunc64to32(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc64to32 (Const64 [c])) + // result: (Const32 [int32(c)]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(c)) + return true + } + // match: (Trunc64to32 (ZeroExt8to64 x)) + // result: (ZeroExt8to32 x) + for { + if v_0.Op != OpZeroExt8to64 { + break + } + x := v_0.Args[0] + v.reset(OpZeroExt8to32) + v.AddArg(x) + return true + } + // match: (Trunc64to32 (ZeroExt16to64 x)) + // result: (ZeroExt16to32 x) + for { + if v_0.Op != OpZeroExt16to64 { + break + } + x := v_0.Args[0] + v.reset(OpZeroExt16to32) + v.AddArg(x) + return true + } + // match: (Trunc64to32 (ZeroExt32to64 x)) + // result: x + for { + if v_0.Op != OpZeroExt32to64 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc64to32 (SignExt8to64 x)) + // result: (SignExt8to32 x) + for { + if v_0.Op != OpSignExt8to64 { + break + } + x := v_0.Args[0] + v.reset(OpSignExt8to32) + v.AddArg(x) + return true + } + // match: (Trunc64to32 (SignExt16to64 x)) + // result: (SignExt16to32 x) + for { + if v_0.Op != OpSignExt16to64 { + break + } + x := v_0.Args[0] + v.reset(OpSignExt16to32) + v.AddArg(x) + return true + } + // match: (Trunc64to32 (SignExt32to64 x)) + // result: x + for { + if v_0.Op != OpSignExt32to64 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc64to32 (And64 (Const64 [y]) x)) + // cond: y&0xFFFFFFFF == 0xFFFFFFFF + // result: (Trunc64to32 x) + for { + if v_0.Op != OpAnd64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst64 { + continue + } + y := auxIntToInt64(v_0_0.AuxInt) + x := v_0_1 + if !(y&0xFFFFFFFF == 0xFFFFFFFF) { + continue + } + v.reset(OpTrunc64to32) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpTrunc64to8(v *Value) bool { + v_0 := v.Args[0] + // match: (Trunc64to8 (Const64 [c])) + // result: (Const8 [int8(c)]) + for { + if v_0.Op != OpConst64 { + break + } + c := auxIntToInt64(v_0.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(int8(c)) + return true + } + // match: (Trunc64to8 (ZeroExt8to64 x)) + // result: x + for { + if v_0.Op != OpZeroExt8to64 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc64to8 (SignExt8to64 x)) + // result: x + for { + if v_0.Op != OpSignExt8to64 { + break + } + x := v_0.Args[0] + v.copyOf(x) + return true + } + // match: (Trunc64to8 (And64 (Const64 [y]) x)) + // cond: y&0xFF == 0xFF + // result: (Trunc64to8 x) + for { + if v_0.Op != OpAnd64 { + break + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { + if v_0_0.Op != OpConst64 { + continue + } + y := auxIntToInt64(v_0_0.AuxInt) + x := v_0_1 + if !(y&0xFF == 0xFF) { + continue + } + v.reset(OpTrunc64to8) + v.AddArg(x) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpXor16(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Xor16 (Const16 [c]) (Const16 [d])) + // result: (Const16 [c^d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpConst16 { + continue + } + d := auxIntToInt16(v_1.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(c ^ d) + return true + } + break + } + // match: (Xor16 x x) + // result: (Const16 [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(0) + return true + } + // match: (Xor16 (Const16 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Xor16 (Com16 x) x) + // result: (Const16 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom16 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(-1) + return true + } + break + } + // match: (Xor16 (Const16 [-1]) x) + // result: (Com16 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.reset(OpCom16) + v.AddArg(x) + return true + } + break + } + // match: (Xor16 x (Xor16 x y)) + // result: y + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpXor16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.copyOf(y) + return true + } + } + break + } + // match: (Xor16 (Xor16 i:(Const16 ) z) x) + // cond: (z.Op != OpConst16 && x.Op != OpConst16) + // result: (Xor16 i (Xor16 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpXor16 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst16 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst16 && x.Op != OpConst16) { + continue + } + v.reset(OpXor16) + v0 := b.NewValue0(v.Pos, OpXor16, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Xor16 (Const16 [c]) (Xor16 (Const16 [d]) x)) + // result: (Xor16 (Const16 [c^d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst16 { + continue + } + t := v_0.Type + c := auxIntToInt16(v_0.AuxInt) + if v_1.Op != OpXor16 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst16 || v_1_0.Type != t { + continue + } + d := auxIntToInt16(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpXor16) + v0 := b.NewValue0(v.Pos, OpConst16, t) + v0.AuxInt = int16ToAuxInt(c ^ d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Xor16 (Lsh16x64 x z:(Const64 [c])) (Rsh16Ux64 x (Const64 [d]))) + // cond: c < 16 && d == 16-c && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh16x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh16Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 16 && d == 16-c && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor16 left:(Lsh16x64 x y) right:(Rsh16Ux64 x (Sub64 (Const64 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor16 left:(Lsh16x32 x y) right:(Rsh16Ux32 x (Sub32 (Const32 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor16 left:(Lsh16x16 x y) right:(Rsh16Ux16 x (Sub16 (Const16 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor16 left:(Lsh16x8 x y) right:(Rsh16Ux8 x (Sub8 (Const8 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh16x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh16Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 16 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor16 right:(Rsh16Ux64 x y) left:(Lsh16x64 x z:(Sub64 (Const64 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor16 right:(Rsh16Ux32 x y) left:(Lsh16x32 x z:(Sub32 (Const32 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor16 right:(Rsh16Ux16 x y) left:(Lsh16x16 x z:(Sub16 (Const16 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor16 right:(Rsh16Ux8 x y) left:(Lsh16x8 x z:(Sub8 (Const8 [16]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16) + // result: (RotateLeft16 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh16Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh16x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 16 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 16)) { + continue + } + v.reset(OpRotateLeft16) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpXor32(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Xor32 (Const32 [c]) (Const32 [d])) + // result: (Const32 [c^d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpConst32 { + continue + } + d := auxIntToInt32(v_1.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(c ^ d) + return true + } + break + } + // match: (Xor32 x x) + // result: (Const32 [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(0) + return true + } + // match: (Xor32 (Const32 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Xor32 (Com32 x) x) + // result: (Const32 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom32 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(-1) + return true + } + break + } + // match: (Xor32 (Const32 [-1]) x) + // result: (Com32 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.reset(OpCom32) + v.AddArg(x) + return true + } + break + } + // match: (Xor32 x (Xor32 x y)) + // result: y + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpXor32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.copyOf(y) + return true + } + } + break + } + // match: (Xor32 (Xor32 i:(Const32 ) z) x) + // cond: (z.Op != OpConst32 && x.Op != OpConst32) + // result: (Xor32 i (Xor32 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpXor32 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst32 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst32 && x.Op != OpConst32) { + continue + } + v.reset(OpXor32) + v0 := b.NewValue0(v.Pos, OpXor32, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Xor32 (Const32 [c]) (Xor32 (Const32 [d]) x)) + // result: (Xor32 (Const32 [c^d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst32 { + continue + } + t := v_0.Type + c := auxIntToInt32(v_0.AuxInt) + if v_1.Op != OpXor32 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst32 || v_1_0.Type != t { + continue + } + d := auxIntToInt32(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpXor32) + v0 := b.NewValue0(v.Pos, OpConst32, t) + v0.AuxInt = int32ToAuxInt(c ^ d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Xor32 (Lsh32x64 x z:(Const64 [c])) (Rsh32Ux64 x (Const64 [d]))) + // cond: c < 32 && d == 32-c && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh32x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh32Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 32 && d == 32-c && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor32 left:(Lsh32x64 x y) right:(Rsh32Ux64 x (Sub64 (Const64 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor32 left:(Lsh32x32 x y) right:(Rsh32Ux32 x (Sub32 (Const32 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor32 left:(Lsh32x16 x y) right:(Rsh32Ux16 x (Sub16 (Const16 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor32 left:(Lsh32x8 x y) right:(Rsh32Ux8 x (Sub8 (Const8 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh32x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh32Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 32 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor32 right:(Rsh32Ux64 x y) left:(Lsh32x64 x z:(Sub64 (Const64 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor32 right:(Rsh32Ux32 x y) left:(Lsh32x32 x z:(Sub32 (Const32 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor32 right:(Rsh32Ux16 x y) left:(Lsh32x16 x z:(Sub16 (Const16 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor32 right:(Rsh32Ux8 x y) left:(Lsh32x8 x z:(Sub8 (Const8 [32]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32) + // result: (RotateLeft32 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh32Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh32x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 32 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 32)) { + continue + } + v.reset(OpRotateLeft32) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpXor64(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Xor64 (Const64 [c]) (Const64 [d])) + // result: (Const64 [c^d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(c ^ d) + return true + } + break + } + // match: (Xor64 x x) + // result: (Const64 [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(0) + return true + } + // match: (Xor64 (Const64 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Xor64 (Com64 x) x) + // result: (Const64 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom64 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(-1) + return true + } + break + } + // match: (Xor64 (Const64 [-1]) x) + // result: (Com64 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.reset(OpCom64) + v.AddArg(x) + return true + } + break + } + // match: (Xor64 x (Xor64 x y)) + // result: y + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpXor64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.copyOf(y) + return true + } + } + break + } + // match: (Xor64 (Xor64 i:(Const64 ) z) x) + // cond: (z.Op != OpConst64 && x.Op != OpConst64) + // result: (Xor64 i (Xor64 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpXor64 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst64 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst64 && x.Op != OpConst64) { + continue + } + v.reset(OpXor64) + v0 := b.NewValue0(v.Pos, OpXor64, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Xor64 (Const64 [c]) (Xor64 (Const64 [d]) x)) + // result: (Xor64 (Const64 [c^d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst64 { + continue + } + t := v_0.Type + c := auxIntToInt64(v_0.AuxInt) + if v_1.Op != OpXor64 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst64 || v_1_0.Type != t { + continue + } + d := auxIntToInt64(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpXor64) + v0 := b.NewValue0(v.Pos, OpConst64, t) + v0.AuxInt = int64ToAuxInt(c ^ d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Xor64 (Lsh64x64 x z:(Const64 [c])) (Rsh64Ux64 x (Const64 [d]))) + // cond: c < 64 && d == 64-c && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh64x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh64Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 64 && d == 64-c && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor64 left:(Lsh64x64 x y) right:(Rsh64Ux64 x (Sub64 (Const64 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor64 left:(Lsh64x32 x y) right:(Rsh64Ux32 x (Sub32 (Const32 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor64 left:(Lsh64x16 x y) right:(Rsh64Ux16 x (Sub16 (Const16 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor64 left:(Lsh64x8 x y) right:(Rsh64Ux8 x (Sub8 (Const8 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh64x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh64Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 64 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor64 right:(Rsh64Ux64 x y) left:(Lsh64x64 x z:(Sub64 (Const64 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor64 right:(Rsh64Ux32 x y) left:(Lsh64x32 x z:(Sub32 (Const32 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor64 right:(Rsh64Ux16 x y) left:(Lsh64x16 x z:(Sub16 (Const16 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor64 right:(Rsh64Ux8 x y) left:(Lsh64x8 x z:(Sub8 (Const8 [64]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64) + // result: (RotateLeft64 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh64Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh64x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 64 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 64)) { + continue + } + v.reset(OpRotateLeft64) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpXor8(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + config := b.Func.Config + // match: (Xor8 (Const8 [c]) (Const8 [d])) + // result: (Const8 [c^d]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpConst8 { + continue + } + d := auxIntToInt8(v_1.AuxInt) + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(c ^ d) + return true + } + break + } + // match: (Xor8 x x) + // result: (Const8 [0]) + for { + x := v_0 + if x != v_1 { + break + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(0) + return true + } + // match: (Xor8 (Const8 [0]) x) + // result: x + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { + continue + } + x := v_1 + v.copyOf(x) + return true + } + break + } + // match: (Xor8 (Com8 x) x) + // result: (Const8 [-1]) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpCom8 { + continue + } + x := v_0.Args[0] + if x != v_1 { + continue + } + v.reset(OpConst8) + v.AuxInt = int8ToAuxInt(-1) + return true + } + break + } + // match: (Xor8 (Const8 [-1]) x) + // result: (Com8 x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != -1 { + continue + } + x := v_1 + v.reset(OpCom8) + v.AddArg(x) + return true + } + break + } + // match: (Xor8 x (Xor8 x y)) + // result: y + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + x := v_0 + if v_1.Op != OpXor8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if x != v_1_0 { + continue + } + y := v_1_1 + v.copyOf(y) + return true + } + } + break + } + // match: (Xor8 (Xor8 i:(Const8 ) z) x) + // cond: (z.Op != OpConst8 && x.Op != OpConst8) + // result: (Xor8 i (Xor8 z x)) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpXor8 { + continue + } + _ = v_0.Args[1] + v_0_0 := v_0.Args[0] + v_0_1 := v_0.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { + i := v_0_0 + if i.Op != OpConst8 { + continue + } + t := i.Type + z := v_0_1 + x := v_1 + if !(z.Op != OpConst8 && x.Op != OpConst8) { + continue + } + v.reset(OpXor8) + v0 := b.NewValue0(v.Pos, OpXor8, t) + v0.AddArg2(z, x) + v.AddArg2(i, v0) + return true + } + } + break + } + // match: (Xor8 (Const8 [c]) (Xor8 (Const8 [d]) x)) + // result: (Xor8 (Const8 [c^d]) x) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpConst8 { + continue + } + t := v_0.Type + c := auxIntToInt8(v_0.AuxInt) + if v_1.Op != OpXor8 { + continue + } + _ = v_1.Args[1] + v_1_0 := v_1.Args[0] + v_1_1 := v_1.Args[1] + for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { + if v_1_0.Op != OpConst8 || v_1_0.Type != t { + continue + } + d := auxIntToInt8(v_1_0.AuxInt) + x := v_1_1 + v.reset(OpXor8) + v0 := b.NewValue0(v.Pos, OpConst8, t) + v0.AuxInt = int8ToAuxInt(c ^ d) + v.AddArg2(v0, x) + return true + } + } + break + } + // match: (Xor8 (Lsh8x64 x z:(Const64 [c])) (Rsh8Ux64 x (Const64 [d]))) + // cond: c < 8 && d == 8-c && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + if v_0.Op != OpLsh8x64 { + continue + } + _ = v_0.Args[1] + x := v_0.Args[0] + z := v_0.Args[1] + if z.Op != OpConst64 { + continue + } + c := auxIntToInt64(z.AuxInt) + if v_1.Op != OpRsh8Ux64 { + continue + } + _ = v_1.Args[1] + if x != v_1.Args[0] { + continue + } + v_1_1 := v_1.Args[1] + if v_1_1.Op != OpConst64 { + continue + } + d := auxIntToInt64(v_1_1.AuxInt) + if !(c < 8 && d == 8-c && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor8 left:(Lsh8x64 x y) right:(Rsh8Ux64 x (Sub64 (Const64 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x64 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux64 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub64 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst64 || auxIntToInt64(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor8 left:(Lsh8x32 x y) right:(Rsh8Ux32 x (Sub32 (Const32 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x32 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux32 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub32 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst32 || auxIntToInt32(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor8 left:(Lsh8x16 x y) right:(Rsh8Ux16 x (Sub16 (Const16 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x16 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux16 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub16 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst16 || auxIntToInt16(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor8 left:(Lsh8x8 x y) right:(Rsh8Ux8 x (Sub8 (Const8 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x y) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + left := v_0 + if left.Op != OpLsh8x8 { + continue + } + y := left.Args[1] + x := left.Args[0] + right := v_1 + if right.Op != OpRsh8Ux8 { + continue + } + _ = right.Args[1] + if x != right.Args[0] { + continue + } + right_1 := right.Args[1] + if right_1.Op != OpSub8 { + continue + } + _ = right_1.Args[1] + right_1_0 := right_1.Args[0] + if right_1_0.Op != OpConst8 || auxIntToInt8(right_1_0.AuxInt) != 8 || y != right_1.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, y) + return true + } + break + } + // match: (Xor8 right:(Rsh8Ux64 x y) left:(Lsh8x64 x z:(Sub64 (Const64 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux64 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x64 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub64 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst64 || auxIntToInt64(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor8 right:(Rsh8Ux32 x y) left:(Lsh8x32 x z:(Sub32 (Const32 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux32 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x32 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub32 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst32 || auxIntToInt32(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor8 right:(Rsh8Ux16 x y) left:(Lsh8x16 x z:(Sub16 (Const16 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux16 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x16 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub16 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst16 || auxIntToInt16(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + // match: (Xor8 right:(Rsh8Ux8 x y) left:(Lsh8x8 x z:(Sub8 (Const8 [8]) y))) + // cond: (shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8) + // result: (RotateLeft8 x z) + for { + for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { + right := v_0 + if right.Op != OpRsh8Ux8 { + continue + } + y := right.Args[1] + x := right.Args[0] + left := v_1 + if left.Op != OpLsh8x8 { + continue + } + _ = left.Args[1] + if x != left.Args[0] { + continue + } + z := left.Args[1] + if z.Op != OpSub8 { + continue + } + _ = z.Args[1] + z_0 := z.Args[0] + if z_0.Op != OpConst8 || auxIntToInt8(z_0.AuxInt) != 8 || y != z.Args[1] || !((shiftIsBounded(left) || shiftIsBounded(right)) && canRotate(config, 8)) { + continue + } + v.reset(OpRotateLeft8) + v.AddArg2(x, z) + return true + } + break + } + return false +} +func rewriteValuegeneric_OpZero(v *Value) bool { + v_1 := v.Args[1] + v_0 := v.Args[0] + b := v.Block + // match: (Zero (SelectN [0] call:(StaticLECall ___)) mem:(SelectN [1] call)) + // cond: isMalloc(call.Aux) + // result: mem + for { + if v_0.Op != OpSelectN || auxIntToInt64(v_0.AuxInt) != 0 { + break + } + call := v_0.Args[0] + if call.Op != OpStaticLECall { + break + } + mem := v_1 + if mem.Op != OpSelectN || auxIntToInt64(mem.AuxInt) != 1 || call != mem.Args[0] || !(isMalloc(call.Aux)) { + break + } + v.copyOf(mem) + return true + } + // match: (Zero {t1} [n] p1 store:(Store {t2} (OffPtr [o2] p2) _ mem)) + // cond: isSamePtr(p1, p2) && store.Uses == 1 && n >= o2 + t2.Size() && clobber(store) + // result: (Zero {t1} [n] p1 mem) + for { + n := auxIntToInt64(v.AuxInt) + t1 := auxToType(v.Aux) + p1 := v_0 + store := v_1 + if store.Op != OpStore { + break + } + t2 := auxToType(store.Aux) + mem := store.Args[2] + store_0 := store.Args[0] + if store_0.Op != OpOffPtr { + break + } + o2 := auxIntToInt64(store_0.AuxInt) + p2 := store_0.Args[0] + if !(isSamePtr(p1, p2) && store.Uses == 1 && n >= o2+t2.Size() && clobber(store)) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t1) + v.AddArg2(p1, mem) + return true + } + // match: (Zero {t} [n] dst1 move:(Move {t} [n] dst2 _ mem)) + // cond: move.Uses == 1 && isSamePtr(dst1, dst2) && clobber(move) + // result: (Zero {t} [n] dst1 mem) + for { + n := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst1 := v_0 + move := v_1 + if move.Op != OpMove || auxIntToInt64(move.AuxInt) != n || auxToType(move.Aux) != t { + break + } + mem := move.Args[2] + dst2 := move.Args[0] + if !(move.Uses == 1 && isSamePtr(dst1, dst2) && clobber(move)) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t) + v.AddArg2(dst1, mem) + return true + } + // match: (Zero {t} [n] dst1 vardef:(VarDef {x} move:(Move {t} [n] dst2 _ mem))) + // cond: move.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && clobber(move, vardef) + // result: (Zero {t} [n] dst1 (VarDef {x} mem)) + for { + n := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst1 := v_0 + vardef := v_1 + if vardef.Op != OpVarDef { + break + } + x := auxToSym(vardef.Aux) + move := vardef.Args[0] + if move.Op != OpMove || auxIntToInt64(move.AuxInt) != n || auxToType(move.Aux) != t { + break + } + mem := move.Args[2] + dst2 := move.Args[0] + if !(move.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && clobber(move, vardef)) { + break + } + v.reset(OpZero) + v.AuxInt = int64ToAuxInt(n) + v.Aux = typeToAux(t) + v0 := b.NewValue0(v.Pos, OpVarDef, types.TypeMem) + v0.Aux = symToAux(x) + v0.AddArg(mem) + v.AddArg2(dst1, v0) + return true + } + // match: (Zero {t} [s] dst1 zero:(Zero {t} [s] dst2 _)) + // cond: isSamePtr(dst1, dst2) + // result: zero + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst1 := v_0 + zero := v_1 + if zero.Op != OpZero || auxIntToInt64(zero.AuxInt) != s || auxToType(zero.Aux) != t { + break + } + dst2 := zero.Args[0] + if !(isSamePtr(dst1, dst2)) { + break + } + v.copyOf(zero) + return true + } + // match: (Zero {t} [s] dst1 vardef:(VarDef (Zero {t} [s] dst2 _))) + // cond: isSamePtr(dst1, dst2) + // result: vardef + for { + s := auxIntToInt64(v.AuxInt) + t := auxToType(v.Aux) + dst1 := v_0 + vardef := v_1 + if vardef.Op != OpVarDef { + break + } + vardef_0 := vardef.Args[0] + if vardef_0.Op != OpZero || auxIntToInt64(vardef_0.AuxInt) != s || auxToType(vardef_0.Aux) != t { + break + } + dst2 := vardef_0.Args[0] + if !(isSamePtr(dst1, dst2)) { + break + } + v.copyOf(vardef) + return true + } + return false +} +func rewriteValuegeneric_OpZeroExt16to32(v *Value) bool { + v_0 := v.Args[0] + // match: (ZeroExt16to32 (Const16 [c])) + // result: (Const32 [int32(uint16(c))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(uint16(c))) + return true + } + // match: (ZeroExt16to32 (Trunc32to16 x:(Rsh32Ux64 _ (Const64 [s])))) + // cond: s >= 16 + // result: x + for { + if v_0.Op != OpTrunc32to16 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh32Ux64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 16) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpZeroExt16to64(v *Value) bool { + v_0 := v.Args[0] + // match: (ZeroExt16to64 (Const16 [c])) + // result: (Const64 [int64(uint16(c))]) + for { + if v_0.Op != OpConst16 { + break + } + c := auxIntToInt16(v_0.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(uint16(c))) + return true + } + // match: (ZeroExt16to64 (Trunc64to16 x:(Rsh64Ux64 _ (Const64 [s])))) + // cond: s >= 48 + // result: x + for { + if v_0.Op != OpTrunc64to16 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh64Ux64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 48) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpZeroExt32to64(v *Value) bool { + v_0 := v.Args[0] + // match: (ZeroExt32to64 (Const32 [c])) + // result: (Const64 [int64(uint32(c))]) + for { + if v_0.Op != OpConst32 { + break + } + c := auxIntToInt32(v_0.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(uint32(c))) + return true + } + // match: (ZeroExt32to64 (Trunc64to32 x:(Rsh64Ux64 _ (Const64 [s])))) + // cond: s >= 32 + // result: x + for { + if v_0.Op != OpTrunc64to32 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh64Ux64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 32) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpZeroExt8to16(v *Value) bool { + v_0 := v.Args[0] + // match: (ZeroExt8to16 (Const8 [c])) + // result: (Const16 [int16( uint8(c))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + v.reset(OpConst16) + v.AuxInt = int16ToAuxInt(int16(uint8(c))) + return true + } + // match: (ZeroExt8to16 (Trunc16to8 x:(Rsh16Ux64 _ (Const64 [s])))) + // cond: s >= 8 + // result: x + for { + if v_0.Op != OpTrunc16to8 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh16Ux64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 8) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpZeroExt8to32(v *Value) bool { + v_0 := v.Args[0] + // match: (ZeroExt8to32 (Const8 [c])) + // result: (Const32 [int32( uint8(c))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + v.reset(OpConst32) + v.AuxInt = int32ToAuxInt(int32(uint8(c))) + return true + } + // match: (ZeroExt8to32 (Trunc32to8 x:(Rsh32Ux64 _ (Const64 [s])))) + // cond: s >= 24 + // result: x + for { + if v_0.Op != OpTrunc32to8 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh32Ux64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 24) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteValuegeneric_OpZeroExt8to64(v *Value) bool { + v_0 := v.Args[0] + // match: (ZeroExt8to64 (Const8 [c])) + // result: (Const64 [int64( uint8(c))]) + for { + if v_0.Op != OpConst8 { + break + } + c := auxIntToInt8(v_0.AuxInt) + v.reset(OpConst64) + v.AuxInt = int64ToAuxInt(int64(uint8(c))) + return true + } + // match: (ZeroExt8to64 (Trunc64to8 x:(Rsh64Ux64 _ (Const64 [s])))) + // cond: s >= 56 + // result: x + for { + if v_0.Op != OpTrunc64to8 { + break + } + x := v_0.Args[0] + if x.Op != OpRsh64Ux64 { + break + } + _ = x.Args[1] + x_1 := x.Args[1] + if x_1.Op != OpConst64 { + break + } + s := auxIntToInt64(x_1.AuxInt) + if !(s >= 56) { + break + } + v.copyOf(x) + return true + } + return false +} +func rewriteBlockgeneric(b *Block) bool { + switch b.Kind { + case BlockIf: + // match: (If (Not cond) yes no) + // result: (If cond no yes) + for b.Controls[0].Op == OpNot { + v_0 := b.Controls[0] + cond := v_0.Args[0] + b.resetWithControl(BlockIf, cond) + b.swapSuccessors() + return true + } + // match: (If (ConstBool [c]) yes no) + // cond: c + // result: (First yes no) + for b.Controls[0].Op == OpConstBool { + v_0 := b.Controls[0] + c := auxIntToBool(v_0.AuxInt) + if !(c) { + break + } + b.Reset(BlockFirst) + return true + } + // match: (If (ConstBool [c]) yes no) + // cond: !c + // result: (First no yes) + for b.Controls[0].Op == OpConstBool { + v_0 := b.Controls[0] + c := auxIntToBool(v_0.AuxInt) + if !(!c) { + break + } + b.Reset(BlockFirst) + b.swapSuccessors() + return true + } + } + return false +} diff --git a/go/src/cmd/compile/internal/ssa/rewritetern.go b/go/src/cmd/compile/internal/ssa/rewritetern.go new file mode 100644 index 0000000000000000000000000000000000000000..766b3f898c0765440fd158cf7f158fd898b04ffc --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/rewritetern.go @@ -0,0 +1,294 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "internal/goarch" + "slices" +) + +var truthTableValues [3]uint8 = [3]uint8{0b1111_0000, 0b1100_1100, 0b1010_1010} + +func (slop SIMDLogicalOP) String() string { + if slop == sloInterior { + return "leaf" + } + interior := "" + if slop&sloInterior != 0 { + interior = "+interior" + } + switch slop &^ sloInterior { + case sloAnd: + return "and" + interior + case sloXor: + return "xor" + interior + case sloOr: + return "or" + interior + case sloAndNot: + return "andNot" + interior + case sloNot: + return "not" + interior + } + return "wrong" +} + +func rewriteTern(f *Func) { + if f.maxCPUFeatures == CPUNone { + return + } + + arch := f.Config.Ctxt().Arch.Family + // TODO there are other SIMD architectures + if arch != goarch.AMD64 { + return + } + + boolExprTrees := make(map[*Value]SIMDLogicalOP) + + // Find logical-expr expression trees, including leaves. + // interior nodes will be marked sloInterior, + // root nodes will not be marked sloInterior, + // leaf nodes are only marked sloInterior. + for _, b := range f.Blocks { + for _, v := range b.Values { + slo := classifyBooleanSIMD(v) + switch slo { + case sloOr, + sloAndNot, + sloXor, + sloAnd: + boolExprTrees[v.Args[1]] |= sloInterior + fallthrough + case sloNot: + boolExprTrees[v.Args[0]] |= sloInterior + boolExprTrees[v] |= slo + } + } + } + + // get a canonical sorted set of roots + var roots []*Value + for v, slo := range boolExprTrees { + if f.pass.debug > 1 { + f.Warnl(v.Pos, "%s has SLO %v", v.LongString(), slo) + } + + if slo&sloInterior == 0 && v.Block.CPUfeatures.hasFeature(CPUavx512) { + roots = append(roots, v) + } + } + slices.SortFunc(roots, func(u, v *Value) int { return int(u.ID - v.ID) }) // IDs are small enough to not care about overflow. + + // This rewrite works by iterating over the root set. + // For each boolean expression, it walks the expression + // bottom up accumulating sets of variables mentioned in + // subexpressions, lazy-greedily finding the largest subexpressions + // of 3 inputs that can be rewritten to use ternary-truth-table instructions. + + // rewrite recursively attempts to replace v and v's subexpressions with + // ternary-logic truth-table operations, returning a set of not more than 3 + // subexpressions within v that may be combined into a parent's replacement. + // V need not have the CPU features that allow a ternary-logic operation; + // in that case, v will not be rewritten. Replacements also require + // exactly 3 different variable inputs to a boolean expression. + // + // Given the CPU feature and 3 inputs, v is replaced in the following + // cases: + // + // 1) v is a root + // 2) u = NOT(v) and u lacks the CPU feature + // 3) u = OP(v, w) and u lacks the CPU feature + // 4) u = OP(v, w) and u has more than 3 variable inputs. var rewrite func(v *Value) [3]*Value + var rewrite func(v *Value) [3]*Value + + // computeTT returns the truth table for a boolean expression + // over the variables in vars, where vars[0] varies slowest in + // the truth table and vars[2] varies fastest. + // e.g. computeTT( "and(x, or(y, not(z)))", {x,y,z} ) returns + // (bit 0 first) 0 0 0 0 1 0 1 1 = (reversed) 1101_0000 = 0xD0 + // x: 0 0 0 0 1 1 1 1 + // y: 0 0 1 1 0 0 1 1 + // z: 0 1 0 1 0 1 0 1 + var computeTT func(v *Value, vars [3]*Value) uint8 + + // combine two sets of variables into one, returning ok/not + // if the two sets contained 3 or fewer elements. Combine + // ensures that the sets of Values never contain duplicates. + // (Duplicates would create less-efficient code, not incorrect code.) + combine := func(a, b [3]*Value) ([3]*Value, bool) { + var c [3]*Value + i := 0 + for _, v := range a { + if v == nil { + break + } + c[i] = v + i++ + } + bloop: + for _, v := range b { + if v == nil { + break + } + for _, u := range a { + if v == u { + continue bloop + } + } + if i == 3 { + return [3]*Value{}, false + } + c[i] = v + i++ + } + return c, true + } + + computeTT = func(v *Value, vars [3]*Value) uint8 { + i := 0 + for ; i < len(vars); i++ { + if vars[i] == v { + return truthTableValues[i] + } + } + slo := boolExprTrees[v] &^ sloInterior + a := computeTT(v.Args[0], vars) + switch slo { + case sloNot: + return ^a + case sloAnd: + return a & computeTT(v.Args[1], vars) + case sloXor: + return a ^ computeTT(v.Args[1], vars) + case sloOr: + return a | computeTT(v.Args[1], vars) + case sloAndNot: + return a & ^computeTT(v.Args[1], vars) + } + panic("switch should have covered all cases, or unknown var in logical expression") + } + + replace := func(a0 *Value, vars0 [3]*Value) { + imm := computeTT(a0, vars0) + op := ternOpForLogical(a0.Op) + if op == a0.Op { + if f.pass.debug > 0 { + f.Warnl(a0.Pos, "Skipping rewrite for %s, op=%v", a0.LongString(), op) + } + return + } + if f.pass.debug > 0 { + f.Warnl(a0.Pos, "Rewriting %s into %v of 0b%b %v %v %v", a0.LongString(), op, imm, + vars0[0], vars0[1], vars0[2]) + } + a0.reset(op) + a0.SetArgs3(vars0[0], vars0[1], vars0[2]) + a0.AuxInt = int64(int8(imm)) + } + + // addOne ensures the no-duplicates addition of a single value + // to a set that is not full. It seems possible that a shared + // subexpression in tricky combination with blocks lacking the + // AVX512 feature might permit this. + addOne := func(vars [3]*Value, v *Value) [3]*Value { + if vars[2] != nil { + panic("rewriteTern.addOne, vars[2] should be nil") + } + if v == vars[0] || v == vars[1] { + return vars + } + if vars[1] == nil { + vars[1] = v + } else { + vars[2] = v + } + return vars + } + + rewrite = func(v *Value) [3]*Value { + slo := boolExprTrees[v] + if slo == sloInterior { // leaf node, i.e., a "variable" + return [3]*Value{v, nil, nil} + } + var vars [3]*Value + hasFeature := v.Block.CPUfeatures.hasFeature(CPUavx512) + if slo&sloNot == sloNot { + vars = rewrite(v.Args[0]) + if !hasFeature { + if vars[2] != nil { + replace(v.Args[0], vars) + return [3]*Value{v, nil, nil} + } + return vars + } + } else { + var ok bool + a0, a1 := v.Args[0], v.Args[1] + vars0 := rewrite(a0) + vars1 := rewrite(a1) + vars, ok = combine(vars0, vars1) + + if f.pass.debug > 1 { + f.Warnl(a0.Pos, "combine(%v, %v) -> %v, %v", vars0, vars1, vars, ok) + } + + if !(ok && v.Block.CPUfeatures.hasFeature(CPUavx512)) { + // too many variables, or cannot rewrite current values. + // rewrite one or both subtrees if possible + if vars0[2] != nil && a0.Block.CPUfeatures.hasFeature(CPUavx512) { + replace(a0, vars0) + } + if vars1[2] != nil && a1.Block.CPUfeatures.hasFeature(CPUavx512) { + replace(a1, vars1) + } + + // 3-element var arrays are either rewritten, or unable to be rewritten + // because of the features in effect in their block. Either way, they + // are treated as a "new var" if 3 elements are present. + + if vars0[2] == nil { + if vars1[2] == nil { + // both subtrees are 2-element and were not rewritten. + // + // TODO a clever person would look at subtrees of inputs, + // e.g. rewrite + // ((a AND b) XOR b) XOR (d XOR (c AND d)) + // to (((a AND b) XOR b) XOR d) XOR (c AND d) + // to v = TERNLOG(truthtable, a, b, d) XOR (c AND d) + // and return the variable set {v, c, d} + // + // But for now, just restart with a0 and a1. + return [3]*Value{a0, a1, nil} + } else { + // a1 (maybe) rewrote, a0 has room for another var + vars = addOne(vars0, a1) + } + } else if vars1[2] == nil { + // a0 (maybe) rewrote, a1 has room for another var + vars = addOne(vars1, a0) + } else if !ok { + // both (maybe) rewrote + // a0 and a1 are different because otherwise their variable + // sets would have combined "ok". + return [3]*Value{a0, a1, nil} + } + // continue with either the vars from "ok" or the updated set of vars. + } + } + // if root and 3 vars and hasFeature, rewrite. + if slo&sloInterior == 0 && vars[2] != nil && hasFeature { + replace(v, vars) + return [3]*Value{v, nil, nil} + } + return vars + } + + for _, v := range roots { + if f.pass.debug > 1 { + f.Warnl(v.Pos, "SLO root %s", v.LongString()) + } + rewrite(v) + } +} diff --git a/go/src/cmd/compile/internal/ssa/sccp.go b/go/src/cmd/compile/internal/ssa/sccp.go new file mode 100644 index 0000000000000000000000000000000000000000..7ef8d6b7c1976ee1fe2148e4df40495020f9ca53 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/sccp.go @@ -0,0 +1,585 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// ---------------------------------------------------------------------------- +// Sparse Conditional Constant Propagation +// +// Described in +// Mark N. Wegman, F. Kenneth Zadeck: Constant Propagation with Conditional Branches. +// TOPLAS 1991. +// +// This algorithm uses three level lattice for SSA value +// +// Top undefined +// / | \ +// .. 1 2 3 .. constant +// \ | / +// Bottom not constant +// +// It starts with optimistically assuming that all SSA values are initially Top +// and then propagates constant facts only along reachable control flow paths. +// Since some basic blocks are not visited yet, corresponding inputs of phi become +// Top, we use the meet(phi) to compute its lattice. +// +// Top ∩ any = any +// Bottom ∩ any = Bottom +// ConstantA ∩ ConstantA = ConstantA +// ConstantA ∩ ConstantB = Bottom +// +// Each lattice value is lowered most twice(Top to Constant, Constant to Bottom) +// due to lattice depth, resulting in a fast convergence speed of the algorithm. +// In this way, sccp can discover optimization opportunities that cannot be found +// by just combining constant folding and constant propagation and dead code +// elimination separately. + +// Three level lattice holds compile time knowledge about SSA value +const ( + top int8 = iota // undefined + constant // constant + bottom // not a constant +) + +type lattice struct { + tag int8 // lattice type + val *Value // constant value +} + +type worklist struct { + f *Func // the target function to be optimized out + edges []Edge // propagate constant facts through edges + uses []*Value // re-visiting set + visited map[Edge]bool // visited edges + latticeCells map[*Value]lattice // constant lattices + defUse map[*Value][]*Value // def-use chains for some values + defBlock map[*Value][]*Block // use blocks of def + visitedBlock []bool // visited block +} + +// sccp stands for sparse conditional constant propagation, it propagates constants +// through CFG conditionally and applies constant folding, constant replacement and +// dead code elimination all together. +func sccp(f *Func) { + var t worklist + t.f = f + t.edges = make([]Edge, 0) + t.visited = make(map[Edge]bool) + t.edges = append(t.edges, Edge{f.Entry, 0}) + t.defUse = make(map[*Value][]*Value) + t.defBlock = make(map[*Value][]*Block) + t.latticeCells = make(map[*Value]lattice) + t.visitedBlock = f.Cache.allocBoolSlice(f.NumBlocks()) + defer f.Cache.freeBoolSlice(t.visitedBlock) + + // build it early since we rely heavily on the def-use chain later + t.buildDefUses() + + // pick up either an edge or SSA value from worklist, process it + for { + if len(t.edges) > 0 { + edge := t.edges[0] + t.edges = t.edges[1:] + if _, exist := t.visited[edge]; !exist { + dest := edge.b + destVisited := t.visitedBlock[dest.ID] + + // mark edge as visited + t.visited[edge] = true + t.visitedBlock[dest.ID] = true + for _, val := range dest.Values { + if val.Op == OpPhi || !destVisited { + t.visitValue(val) + } + } + // propagates constants facts through CFG, taking condition test + // into account + if !destVisited { + t.propagate(dest) + } + } + continue + } + if len(t.uses) > 0 { + use := t.uses[0] + t.uses = t.uses[1:] + t.visitValue(use) + continue + } + break + } + + // apply optimizations based on discovered constants + constCnt, rewireCnt := t.replaceConst() + if f.pass.debug > 0 { + if constCnt > 0 || rewireCnt > 0 { + f.Warnl(f.Entry.Pos, "Phase SCCP for %v : %v constants, %v dce", f.Name, constCnt, rewireCnt) + } + } +} + +func equals(a, b lattice) bool { + if a == b { + // fast path + return true + } + if a.tag != b.tag { + return false + } + if a.tag == constant { + // The same content of const value may be different, we should + // compare with auxInt instead + v1 := a.val + v2 := b.val + if v1.Op == v2.Op && v1.AuxInt == v2.AuxInt { + return true + } else { + return false + } + } + return true +} + +// possibleConst checks if Value can be folded to const. For those Values that can +// never become constants(e.g. StaticCall), we don't make futile efforts. +func possibleConst(val *Value) bool { + if isConst(val) { + return true + } + switch val.Op { + case OpCopy: + return true + case OpPhi: + return true + case + // negate + OpNeg8, OpNeg16, OpNeg32, OpNeg64, OpNeg32F, OpNeg64F, + OpCom8, OpCom16, OpCom32, OpCom64, + // math + OpFloor, OpCeil, OpTrunc, OpRoundToEven, OpSqrt, + // conversion + OpTrunc16to8, OpTrunc32to8, OpTrunc32to16, OpTrunc64to8, + OpTrunc64to16, OpTrunc64to32, OpCvt32to32F, OpCvt32to64F, + OpCvt64to32F, OpCvt64to64F, OpCvt32Fto32, OpCvt32Fto64, + OpCvt64Fto32, OpCvt64Fto64, OpCvt32Fto64F, OpCvt64Fto32F, + OpCvtBoolToUint8, + OpZeroExt8to16, OpZeroExt8to32, OpZeroExt8to64, OpZeroExt16to32, + OpZeroExt16to64, OpZeroExt32to64, OpSignExt8to16, OpSignExt8to32, + OpSignExt8to64, OpSignExt16to32, OpSignExt16to64, OpSignExt32to64, + // bit + OpCtz8, OpCtz16, OpCtz32, OpCtz64, + // mask + OpSlicemask, + // safety check + OpIsNonNil, + // not + OpNot: + return true + case + // add + OpAdd64, OpAdd32, OpAdd16, OpAdd8, + OpAdd32F, OpAdd64F, + // sub + OpSub64, OpSub32, OpSub16, OpSub8, + OpSub32F, OpSub64F, + // mul + OpMul64, OpMul32, OpMul16, OpMul8, + OpMul32F, OpMul64F, + // div + OpDiv32F, OpDiv64F, + OpDiv8, OpDiv16, OpDiv32, OpDiv64, + OpDiv8u, OpDiv16u, OpDiv32u, OpDiv64u, + OpMod8, OpMod16, OpMod32, OpMod64, + OpMod8u, OpMod16u, OpMod32u, OpMod64u, + // compare + OpEq64, OpEq32, OpEq16, OpEq8, + OpEq32F, OpEq64F, + OpLess64, OpLess32, OpLess16, OpLess8, + OpLess64U, OpLess32U, OpLess16U, OpLess8U, + OpLess32F, OpLess64F, + OpLeq64, OpLeq32, OpLeq16, OpLeq8, + OpLeq64U, OpLeq32U, OpLeq16U, OpLeq8U, + OpLeq32F, OpLeq64F, + OpEqB, OpNeqB, + // shift + OpLsh64x64, OpRsh64x64, OpRsh64Ux64, OpLsh32x64, + OpRsh32x64, OpRsh32Ux64, OpLsh16x64, OpRsh16x64, + OpRsh16Ux64, OpLsh8x64, OpRsh8x64, OpRsh8Ux64, + // safety check + OpIsInBounds, OpIsSliceInBounds, + // bit + OpAnd8, OpAnd16, OpAnd32, OpAnd64, + OpOr8, OpOr16, OpOr32, OpOr64, + OpXor8, OpXor16, OpXor32, OpXor64: + return true + default: + return false + } +} + +func (t *worklist) getLatticeCell(val *Value) lattice { + if !possibleConst(val) { + // they are always worst + return lattice{bottom, nil} + } + lt, exist := t.latticeCells[val] + if !exist { + return lattice{top, nil} // optimistically for un-visited value + } + return lt +} + +func isConst(val *Value) bool { + switch val.Op { + case OpConst64, OpConst32, OpConst16, OpConst8, + OpConstBool, OpConst32F, OpConst64F: + return true + default: + return false + } +} + +// buildDefUses builds def-use chain for some values early, because once the +// lattice of a value is changed, we need to update lattices of use. But we don't +// need all uses of it, only uses that can become constants would be added into +// re-visit worklist since no matter how many times they are revisited, uses which +// can't become constants lattice remains unchanged, i.e. Bottom. +func (t *worklist) buildDefUses() { + for _, block := range t.f.Blocks { + for _, val := range block.Values { + for _, arg := range val.Args { + // find its uses, only uses that can become constants take into account + if possibleConst(arg) && possibleConst(val) { + if _, exist := t.defUse[arg]; !exist { + t.defUse[arg] = make([]*Value, 0, arg.Uses) + } + t.defUse[arg] = append(t.defUse[arg], val) + } + } + } + for _, ctl := range block.ControlValues() { + // for control values that can become constants, find their use blocks + if possibleConst(ctl) { + t.defBlock[ctl] = append(t.defBlock[ctl], block) + } + } + } +} + +// addUses finds all uses of value and appends them into work list for further process +func (t *worklist) addUses(val *Value) { + for _, use := range t.defUse[val] { + if val == use { + // Phi may refer to itself as uses, ignore them to avoid re-visiting phi + // for performance reason + continue + } + t.uses = append(t.uses, use) + } + for _, block := range t.defBlock[val] { + if t.visitedBlock[block.ID] { + t.propagate(block) + } + } +} + +// meet meets all of phi arguments and computes result lattice +func (t *worklist) meet(val *Value) lattice { + optimisticLt := lattice{top, nil} + for i := 0; i < len(val.Args); i++ { + edge := Edge{val.Block, i} + // If incoming edge for phi is not visited, assume top optimistically. + // According to rules of meet: + // Top ∩ any = any + // Top participates in meet() but does not affect the result, so here + // we will ignore Top and only take other lattices into consideration. + if _, exist := t.visited[edge]; exist { + lt := t.getLatticeCell(val.Args[i]) + if lt.tag == constant { + if optimisticLt.tag == top { + optimisticLt = lt + } else { + if !equals(optimisticLt, lt) { + // ConstantA ∩ ConstantB = Bottom + return lattice{bottom, nil} + } + } + } else if lt.tag == bottom { + // Bottom ∩ any = Bottom + return lattice{bottom, nil} + } else { + // Top ∩ any = any + } + } else { + // Top ∩ any = any + } + } + + // ConstantA ∩ ConstantA = ConstantA or Top ∩ any = any + return optimisticLt +} + +func computeLattice(f *Func, val *Value, args ...*Value) lattice { + // In general, we need to perform constant evaluation based on constant args: + // + // res := lattice{constant, nil} + // switch op { + // case OpAdd16: + // res.val = newConst(argLt1.val.AuxInt16() + argLt2.val.AuxInt16()) + // case OpAdd32: + // res.val = newConst(argLt1.val.AuxInt32() + argLt2.val.AuxInt32()) + // case OpDiv8: + // if !isDivideByZero(argLt2.val.AuxInt8()) { + // res.val = newConst(argLt1.val.AuxInt8() / argLt2.val.AuxInt8()) + // } + // ... + // } + // + // However, this would create a huge switch for all opcodes that can be + // evaluated during compile time. Moreover, some operations can be evaluated + // only if its arguments satisfy additional conditions(e.g. divide by zero). + // It's fragile and error-prone. We did a trick by reusing the existing rules + // in generic rules for compile-time evaluation. But generic rules rewrite + // original value, this behavior is undesired, because the lattice of values + // may change multiple times, once it was rewritten, we lose the opportunity + // to change it permanently, which can lead to errors. For example, We cannot + // change its value immediately after visiting Phi, because some of its input + // edges may still not be visited at this moment. + constValue := f.newValue(val.Op, val.Type, f.Entry, val.Pos) + constValue.AddArgs(args...) + matched := rewriteValuegeneric(constValue) + if matched { + if isConst(constValue) { + return lattice{constant, constValue} + } + } + // Either we can not match generic rules for given value or it does not + // satisfy additional constraints(e.g. divide by zero), in these cases, clean + // up temporary value immediately in case they are not dominated by their args. + constValue.reset(OpInvalid) + return lattice{bottom, nil} +} + +func (t *worklist) visitValue(val *Value) { + if !possibleConst(val) { + // fast fail for always worst Values, i.e. there is no lowering happen + // on them, their lattices must be initially worse Bottom. + return + } + + oldLt := t.getLatticeCell(val) + defer func() { + // re-visit all uses of value if its lattice is changed + newLt := t.getLatticeCell(val) + if !equals(newLt, oldLt) { + if oldLt.tag > newLt.tag { + t.f.Fatalf("Must lower lattice\n") + } + t.addUses(val) + } + }() + + switch val.Op { + // they are constant values, aren't they? + case OpConst64, OpConst32, OpConst16, OpConst8, + OpConstBool, OpConst32F, OpConst64F: //TODO: support ConstNil ConstString etc + t.latticeCells[val] = lattice{constant, val} + // lattice value of copy(x) actually means lattice value of (x) + case OpCopy: + t.latticeCells[val] = t.getLatticeCell(val.Args[0]) + // phi should be processed specially + case OpPhi: + t.latticeCells[val] = t.meet(val) + // fold 1-input operations: + case + // negate + OpNeg8, OpNeg16, OpNeg32, OpNeg64, OpNeg32F, OpNeg64F, + OpCom8, OpCom16, OpCom32, OpCom64, + // math + OpFloor, OpCeil, OpTrunc, OpRoundToEven, OpSqrt, + // conversion + OpTrunc16to8, OpTrunc32to8, OpTrunc32to16, OpTrunc64to8, + OpTrunc64to16, OpTrunc64to32, OpCvt32to32F, OpCvt32to64F, + OpCvt64to32F, OpCvt64to64F, OpCvt32Fto32, OpCvt32Fto64, + OpCvt64Fto32, OpCvt64Fto64, OpCvt32Fto64F, OpCvt64Fto32F, + OpCvtBoolToUint8, + OpZeroExt8to16, OpZeroExt8to32, OpZeroExt8to64, OpZeroExt16to32, + OpZeroExt16to64, OpZeroExt32to64, OpSignExt8to16, OpSignExt8to32, + OpSignExt8to64, OpSignExt16to32, OpSignExt16to64, OpSignExt32to64, + // bit + OpCtz8, OpCtz16, OpCtz32, OpCtz64, + // mask + OpSlicemask, + // safety check + OpIsNonNil, + // not + OpNot: + lt1 := t.getLatticeCell(val.Args[0]) + + if lt1.tag == constant { + // here we take a shortcut by reusing generic rules to fold constants + t.latticeCells[val] = computeLattice(t.f, val, lt1.val) + } else { + t.latticeCells[val] = lattice{lt1.tag, nil} + } + // fold 2-input operations + case + // add + OpAdd64, OpAdd32, OpAdd16, OpAdd8, + OpAdd32F, OpAdd64F, + // sub + OpSub64, OpSub32, OpSub16, OpSub8, + OpSub32F, OpSub64F, + // mul + OpMul64, OpMul32, OpMul16, OpMul8, + OpMul32F, OpMul64F, + // div + OpDiv32F, OpDiv64F, + OpDiv8, OpDiv16, OpDiv32, OpDiv64, + OpDiv8u, OpDiv16u, OpDiv32u, OpDiv64u, //TODO: support div128u + // mod + OpMod8, OpMod16, OpMod32, OpMod64, + OpMod8u, OpMod16u, OpMod32u, OpMod64u, + // compare + OpEq64, OpEq32, OpEq16, OpEq8, + OpEq32F, OpEq64F, + OpLess64, OpLess32, OpLess16, OpLess8, + OpLess64U, OpLess32U, OpLess16U, OpLess8U, + OpLess32F, OpLess64F, + OpLeq64, OpLeq32, OpLeq16, OpLeq8, + OpLeq64U, OpLeq32U, OpLeq16U, OpLeq8U, + OpLeq32F, OpLeq64F, + OpEqB, OpNeqB, + // shift + OpLsh64x64, OpRsh64x64, OpRsh64Ux64, OpLsh32x64, + OpRsh32x64, OpRsh32Ux64, OpLsh16x64, OpRsh16x64, + OpRsh16Ux64, OpLsh8x64, OpRsh8x64, OpRsh8Ux64, + // safety check + OpIsInBounds, OpIsSliceInBounds, + // bit + OpAnd8, OpAnd16, OpAnd32, OpAnd64, + OpOr8, OpOr16, OpOr32, OpOr64, + OpXor8, OpXor16, OpXor32, OpXor64: + lt1 := t.getLatticeCell(val.Args[0]) + lt2 := t.getLatticeCell(val.Args[1]) + + if lt1.tag == constant && lt2.tag == constant { + // here we take a shortcut by reusing generic rules to fold constants + t.latticeCells[val] = computeLattice(t.f, val, lt1.val, lt2.val) + } else { + if lt1.tag == bottom || lt2.tag == bottom { + t.latticeCells[val] = lattice{bottom, nil} + } else { + t.latticeCells[val] = lattice{top, nil} + } + } + default: + // Any other type of value cannot be a constant, they are always worst(Bottom) + } +} + +// propagate propagates constants facts through CFG. If the block has single successor, +// add the successor anyway. If the block has multiple successors, only add the +// branch destination corresponding to lattice value of condition value. +func (t *worklist) propagate(block *Block) { + switch block.Kind { + case BlockExit, BlockRet, BlockRetJmp, BlockInvalid: + // control flow ends, do nothing then + break + case BlockDefer: + // we know nothing about control flow, add all branch destinations + t.edges = append(t.edges, block.Succs...) + case BlockFirst: + fallthrough // always takes the first branch + case BlockPlain: + t.edges = append(t.edges, block.Succs[0]) + case BlockIf, BlockJumpTable: + cond := block.ControlValues()[0] + condLattice := t.getLatticeCell(cond) + if condLattice.tag == bottom { + // we know nothing about control flow, add all branch destinations + t.edges = append(t.edges, block.Succs...) + } else if condLattice.tag == constant { + // add branchIdx destinations depends on its condition + var branchIdx int64 + if block.Kind == BlockIf { + branchIdx = 1 - condLattice.val.AuxInt + } else { + branchIdx = condLattice.val.AuxInt + if branchIdx < 0 || branchIdx >= int64(len(block.Succs)) { + // unreachable code, do nothing then + break + } + } + t.edges = append(t.edges, block.Succs[branchIdx]) + } else { + // condition value is not visited yet, don't propagate it now + } + default: + t.f.Fatalf("All kind of block should be processed above.") + } +} + +// rewireSuccessor rewires corresponding successors according to constant value +// discovered by previous analysis. As the result, some successors become unreachable +// and thus can be removed in further deadcode phase +func rewireSuccessor(block *Block, constVal *Value) bool { + switch block.Kind { + case BlockIf: + block.removeEdge(int(constVal.AuxInt)) + block.Kind = BlockPlain + block.Likely = BranchUnknown + block.ResetControls() + return true + case BlockJumpTable: + // Remove everything but the known taken branch. + idx := int(constVal.AuxInt) + if idx < 0 || idx >= len(block.Succs) { + // This can only happen in unreachable code, + // as an invariant of jump tables is that their + // input index is in range. + // See issue 64826. + return false + } + block.swapSuccessorsByIdx(0, idx) + for len(block.Succs) > 1 { + block.removeEdge(1) + } + block.Kind = BlockPlain + block.Likely = BranchUnknown + block.ResetControls() + return true + default: + return false + } +} + +// replaceConst will replace non-constant values that have been proven by sccp +// to be constants. +func (t *worklist) replaceConst() (int, int) { + constCnt, rewireCnt := 0, 0 + for val, lt := range t.latticeCells { + if lt.tag == constant { + if !isConst(val) { + if t.f.pass.debug > 0 { + t.f.Warnl(val.Pos, "Replace %v with %v", val.LongString(), lt.val.LongString()) + } + val.reset(lt.val.Op) + val.AuxInt = lt.val.AuxInt + constCnt++ + } + // If const value controls this block, rewires successors according to its value + ctrlBlock := t.defBlock[val] + for _, block := range ctrlBlock { + if rewireSuccessor(block, lt.val) { + rewireCnt++ + if t.f.pass.debug > 0 { + t.f.Warnl(block.Pos, "Rewire %v %v successors", block.Kind, block) + } + } + } + } + } + return constCnt, rewireCnt +} diff --git a/go/src/cmd/compile/internal/ssa/sccp_test.go b/go/src/cmd/compile/internal/ssa/sccp_test.go new file mode 100644 index 0000000000000000000000000000000000000000..70c23e752755a3e6e3a0747f6ed284b309416e83 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/sccp_test.go @@ -0,0 +1,95 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "strings" + "testing" +) + +func TestSCCPBasic(t *testing.T) { + c := testConfig(t) + fun := c.Fun("b1", + Bloc("b1", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("v1", OpConst64, c.config.Types.Int64, 20, nil), + Valu("v2", OpConst64, c.config.Types.Int64, 21, nil), + Valu("v3", OpConst64F, c.config.Types.Float64, 21.0, nil), + Valu("v4", OpConstBool, c.config.Types.Bool, 1, nil), + Valu("t1", OpAdd64, c.config.Types.Int64, 0, nil, "v1", "v2"), + Valu("t2", OpDiv64, c.config.Types.Int64, 0, nil, "t1", "v1"), + Valu("t3", OpAdd64, c.config.Types.Int64, 0, nil, "t1", "t2"), + Valu("t4", OpSub64, c.config.Types.Int64, 0, nil, "t3", "v2"), + Valu("t5", OpMul64, c.config.Types.Int64, 0, nil, "t4", "v2"), + Valu("t6", OpMod64, c.config.Types.Int64, 0, nil, "t5", "v2"), + Valu("t7", OpAnd64, c.config.Types.Int64, 0, nil, "t6", "v2"), + Valu("t8", OpOr64, c.config.Types.Int64, 0, nil, "t7", "v2"), + Valu("t9", OpXor64, c.config.Types.Int64, 0, nil, "t8", "v2"), + Valu("t10", OpNeg64, c.config.Types.Int64, 0, nil, "t9"), + Valu("t11", OpCom64, c.config.Types.Int64, 0, nil, "t10"), + Valu("t12", OpNeg64, c.config.Types.Int64, 0, nil, "t11"), + Valu("t13", OpFloor, c.config.Types.Float64, 0, nil, "v3"), + Valu("t14", OpSqrt, c.config.Types.Float64, 0, nil, "t13"), + Valu("t15", OpCeil, c.config.Types.Float64, 0, nil, "t14"), + Valu("t16", OpTrunc, c.config.Types.Float64, 0, nil, "t15"), + Valu("t17", OpRoundToEven, c.config.Types.Float64, 0, nil, "t16"), + Valu("t18", OpTrunc64to32, c.config.Types.Int64, 0, nil, "t12"), + Valu("t19", OpCvt64Fto64, c.config.Types.Float64, 0, nil, "t17"), + Valu("t20", OpCtz64, c.config.Types.Int64, 0, nil, "v2"), + Valu("t21", OpSlicemask, c.config.Types.Int64, 0, nil, "t20"), + Valu("t22", OpIsNonNil, c.config.Types.Int64, 0, nil, "v2"), + Valu("t23", OpNot, c.config.Types.Bool, 0, nil, "v4"), + Valu("t24", OpEq64, c.config.Types.Bool, 0, nil, "v1", "v2"), + Valu("t25", OpLess64, c.config.Types.Bool, 0, nil, "v1", "v2"), + Valu("t26", OpLeq64, c.config.Types.Bool, 0, nil, "v1", "v2"), + Valu("t27", OpEqB, c.config.Types.Bool, 0, nil, "v4", "v4"), + Valu("t28", OpLsh64x64, c.config.Types.Int64, 0, nil, "v2", "v1"), + Valu("t29", OpIsInBounds, c.config.Types.Int64, 0, nil, "v2", "v1"), + Valu("t30", OpIsSliceInBounds, c.config.Types.Int64, 0, nil, "v2", "v1"), + Goto("b2")), + Bloc("b2", + Exit("mem"))) + sccp(fun.f) + CheckFunc(fun.f) + for name, value := range fun.values { + if strings.HasPrefix(name, "t") { + if !isConst(value) { + t.Errorf("Must be constant: %v", value.LongString()) + } + } + } +} + +func TestSCCPIf(t *testing.T) { + c := testConfig(t) + fun := c.Fun("b1", + Bloc("b1", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("v1", OpConst64, c.config.Types.Int64, 0, nil), + Valu("v2", OpConst64, c.config.Types.Int64, 1, nil), + Valu("cmp", OpLess64, c.config.Types.Bool, 0, nil, "v1", "v2"), + If("cmp", "b2", "b3")), + Bloc("b2", + Valu("v3", OpConst64, c.config.Types.Int64, 3, nil), + Goto("b4")), + Bloc("b3", + Valu("v4", OpConst64, c.config.Types.Int64, 4, nil), + Goto("b4")), + Bloc("b4", + Valu("merge", OpPhi, c.config.Types.Int64, 0, nil, "v3", "v4"), + Exit("mem"))) + sccp(fun.f) + CheckFunc(fun.f) + for _, b := range fun.blocks { + for _, v := range b.Values { + if v == fun.values["merge"] { + if !isConst(v) { + t.Errorf("Must be constant: %v", v.LongString()) + } + } + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/schedule.go b/go/src/cmd/compile/internal/ssa/schedule.go new file mode 100644 index 0000000000000000000000000000000000000000..800625314530d773fea0cd556923a9ef6da29bbb --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/schedule.go @@ -0,0 +1,599 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/types" + "cmp" + "container/heap" + "slices" + "sort" +) + +const ( + ScorePhi = iota // towards top of block + ScoreArg // must occur at the top of the entry block + ScoreInitMem // after the args - used as mark by debug info generation + ScoreReadTuple // must occur immediately after tuple-generating insn (or call) + ScoreNilCheck + ScoreMemory + ScoreReadFlags + ScoreDefault + ScoreInductionInc // an increment of an induction variable + ScoreFlags + ScoreControl // towards bottom of block +) + +type ValHeap struct { + a []*Value + score []int8 + inBlockUses []bool +} + +func (h ValHeap) Len() int { return len(h.a) } +func (h ValHeap) Swap(i, j int) { a := h.a; a[i], a[j] = a[j], a[i] } + +func (h *ValHeap) Push(x any) { + // Push and Pop use pointer receivers because they modify the slice's length, + // not just its contents. + v := x.(*Value) + h.a = append(h.a, v) +} +func (h *ValHeap) Pop() any { + old := h.a + n := len(old) + x := old[n-1] + h.a = old[0 : n-1] + return x +} +func (h ValHeap) Less(i, j int) bool { + x := h.a[i] + y := h.a[j] + sx := h.score[x.ID] + sy := h.score[y.ID] + if c := sx - sy; c != 0 { + return c < 0 // lower scores come earlier. + } + // Note: only scores are required for correct scheduling. + // Everything else is just heuristics. + + ix := h.inBlockUses[x.ID] + iy := h.inBlockUses[y.ID] + if ix != iy { + return ix // values with in-block uses come earlier + } + + if x.Pos != y.Pos { // Favor in-order line stepping + return x.Pos.Before(y.Pos) + } + if x.Op != OpPhi { + if c := len(x.Args) - len(y.Args); c != 0 { + return c > 0 // smaller args come later + } + } + if c := x.Uses - y.Uses; c != 0 { + return c > 0 // smaller uses come later + } + // These comparisons are fairly arbitrary. + // The goal here is stability in the face + // of unrelated changes elsewhere in the compiler. + if c := x.AuxInt - y.AuxInt; c != 0 { + return c < 0 + } + if cmp := x.Type.Compare(y.Type); cmp != types.CMPeq { + return cmp == types.CMPlt + } + return x.ID < y.ID +} + +func (op Op) isLoweredGetClosurePtr() bool { + switch op { + case OpAMD64LoweredGetClosurePtr, OpPPC64LoweredGetClosurePtr, OpARMLoweredGetClosurePtr, OpARM64LoweredGetClosurePtr, + Op386LoweredGetClosurePtr, OpMIPS64LoweredGetClosurePtr, OpLOONG64LoweredGetClosurePtr, OpS390XLoweredGetClosurePtr, OpMIPSLoweredGetClosurePtr, + OpRISCV64LoweredGetClosurePtr, OpWasmLoweredGetClosurePtr: + return true + } + return false +} + +// Schedule the Values in each Block. After this phase returns, the +// order of b.Values matters and is the order in which those values +// will appear in the assembly output. For now it generates a +// reasonable valid schedule using a priority queue. TODO(khr): +// schedule smarter. +func schedule(f *Func) { + // reusable priority queue + priq := new(ValHeap) + + // "priority" for a value + score := f.Cache.allocInt8Slice(f.NumValues()) + defer f.Cache.freeInt8Slice(score) + + // maps mem values to the next live memory value + nextMem := f.Cache.allocValueSlice(f.NumValues()) + defer f.Cache.freeValueSlice(nextMem) + + // inBlockUses records whether a value is used in the block + // in which it lives. (block control values don't count as uses.) + inBlockUses := f.Cache.allocBoolSlice(f.NumValues()) + defer f.Cache.freeBoolSlice(inBlockUses) + if f.Config.optimize { + for _, b := range f.Blocks { + for _, v := range b.Values { + for _, a := range v.Args { + if a.Block == b { + inBlockUses[a.ID] = true + } + } + } + } + } + priq.inBlockUses = inBlockUses + + for _, b := range f.Blocks { + // Compute score. Larger numbers are scheduled closer to the end of the block. + for _, v := range b.Values { + switch { + case v.Op.isLoweredGetClosurePtr(): + // We also score GetLoweredClosurePtr as early as possible to ensure that the + // context register is not stomped. GetLoweredClosurePtr should only appear + // in the entry block where there are no phi functions, so there is no + // conflict or ambiguity here. + if b != f.Entry { + f.Fatalf("LoweredGetClosurePtr appeared outside of entry block, b=%s", b.String()) + } + score[v.ID] = ScorePhi + case opcodeTable[v.Op].nilCheck: + // Nil checks must come before loads from the same address. + score[v.ID] = ScoreNilCheck + case v.Op == OpPhi: + // We want all the phis first. + score[v.ID] = ScorePhi + case v.Op == OpArgIntReg || v.Op == OpArgFloatReg: + // In-register args must be scheduled as early as possible to ensure that they + // are not stomped (similar to the closure pointer above). + // In particular, they need to come before regular OpArg operations because + // of how regalloc places spill code (see regalloc.go:placeSpills:mustBeFirst). + if b != f.Entry { + f.Fatalf("%s appeared outside of entry block, b=%s", v.Op, b.String()) + } + score[v.ID] = ScorePhi + case v.Op == OpArg || v.Op == OpSP || v.Op == OpSB: + // We want all the args as early as possible, for better debugging. + score[v.ID] = ScoreArg + case v.Op == OpInitMem: + // Early, but after args. See debug.go:buildLocationLists + score[v.ID] = ScoreInitMem + case v.Type.IsMemory(): + // Schedule stores as early as possible. This tends to + // reduce register pressure. + score[v.ID] = ScoreMemory + case v.Op == OpSelect0 || v.Op == OpSelect1 || v.Op == OpSelectN: + // Tuple selectors need to appear immediately after the instruction + // that generates the tuple. + score[v.ID] = ScoreReadTuple + case v.hasFlagInput(): + // Schedule flag-reading ops earlier, to minimize the lifetime + // of flag values. + score[v.ID] = ScoreReadFlags + case v.isFlagOp(): + // Schedule flag register generation as late as possible. + // This makes sure that we only have one live flags + // value at a time. + // Note that this case is after the case above, so values + // which both read and generate flags are given ScoreReadFlags. + score[v.ID] = ScoreFlags + case (len(v.Args) == 1 && + v.Args[0].Op == OpPhi && + v.Args[0].Uses > 1 && + len(b.Succs) == 1 && + b.Succs[0].b == v.Args[0].Block && + v.Args[0].Args[b.Succs[0].i] == v): + // This is a value computing v++ (or similar) in a loop. + // Try to schedule it later, so we issue all uses of v before the v++. + // If we don't, then we need an additional move. + // loop: + // p = (PHI v ...) + // ... ok other uses of p ... + // v = (ADDQconst [1] p) + // ... troublesome other uses of p ... + // goto loop + // We want to allocate p and v to the same register so when we get to + // the end of the block we don't have to move v back to p's register. + // But we can only do that if v comes after all the other uses of p. + // Any "troublesome" use means we have to reg-reg move either p or v + // somewhere in the loop. + score[v.ID] = ScoreInductionInc + default: + score[v.ID] = ScoreDefault + } + } + for _, c := range b.ControlValues() { + // Force the control values to be scheduled at the end, + // unless they have other special priority. + if c.Block != b || score[c.ID] < ScoreReadTuple { + continue + } + if score[c.ID] == ScoreReadTuple { + score[c.Args[0].ID] = ScoreControl + continue + } + score[c.ID] = ScoreControl + } + } + priq.score = score + + // An edge represents a scheduling constraint that x must appear before y in the schedule. + type edge struct { + x, y *Value + } + edges := make([]edge, 0, 64) + + // inEdges is the number of scheduling edges incoming from values that haven't been scheduled yet. + // i.e. inEdges[y.ID] = |e in edges where e.y == y and e.x is not in the schedule yet|. + inEdges := f.Cache.allocInt32Slice(f.NumValues()) + defer f.Cache.freeInt32Slice(inEdges) + + for _, b := range f.Blocks { + edges = edges[:0] + // Standard edges: from the argument of a value to that value. + for _, v := range b.Values { + if v.Op == OpPhi { + // If a value is used by a phi, it does not induce + // a scheduling edge because that use is from the + // previous iteration. + continue + } + for _, a := range v.Args { + if a.Block == b { + edges = append(edges, edge{a, v}) + } + } + } + + // Find store chain for block. + // Store chains for different blocks overwrite each other, so + // the calculated store chain is good only for this block. + for _, v := range b.Values { + if v.Op != OpPhi && v.Op != OpInitMem && v.Type.IsMemory() { + nextMem[v.MemoryArg().ID] = v + } + } + + // Add edges to enforce that any load must come before the following store. + for _, v := range b.Values { + if v.Op == OpPhi || v.Type.IsMemory() { + continue + } + w := v.MemoryArg() + if w == nil { + continue + } + if s := nextMem[w.ID]; s != nil && s.Block == b { + edges = append(edges, edge{v, s}) + } + } + + // Sort all the edges by source Value ID. + slices.SortFunc(edges, func(a, b edge) int { + return cmp.Compare(a.x.ID, b.x.ID) + }) + // Compute inEdges for values in this block. + for _, e := range edges { + inEdges[e.y.ID]++ + } + + // Initialize priority queue with schedulable values. + priq.a = priq.a[:0] + for _, v := range b.Values { + if inEdges[v.ID] == 0 { + heap.Push(priq, v) + } + } + + // Produce the schedule. Pick the highest priority scheduleable value, + // add it to the schedule, add any of its uses that are now scheduleable + // to the queue, and repeat. + nv := len(b.Values) + b.Values = b.Values[:0] + for priq.Len() > 0 { + // Schedule the next schedulable value in priority order. + v := heap.Pop(priq).(*Value) + b.Values = append(b.Values, v) + + // Find all the scheduling edges out from this value. + i := sort.Search(len(edges), func(i int) bool { + return edges[i].x.ID >= v.ID + }) + j := sort.Search(len(edges), func(i int) bool { + return edges[i].x.ID > v.ID + }) + // Decrement inEdges for each target of edges from v. + for _, e := range edges[i:j] { + inEdges[e.y.ID]-- + if inEdges[e.y.ID] == 0 { + heap.Push(priq, e.y) + } + } + } + if len(b.Values) != nv { + f.Fatalf("schedule does not include all values in block %s", b) + } + } + + // Remove SPanchored now that we've scheduled. + // Also unlink nil checks now that ordering is assured + // between the nil check and the uses of the nil-checked pointer. + for _, b := range f.Blocks { + for _, v := range b.Values { + for i, a := range v.Args { + for a.Op == OpSPanchored || opcodeTable[a.Op].nilCheck { + a = a.Args[0] + v.SetArg(i, a) + } + } + } + for i, c := range b.ControlValues() { + for c.Op == OpSPanchored || opcodeTable[c.Op].nilCheck { + c = c.Args[0] + b.ReplaceControl(i, c) + } + } + } + for _, b := range f.Blocks { + i := 0 + for _, v := range b.Values { + if v.Op == OpSPanchored { + // Free this value + if v.Uses != 0 { + base.Fatalf("SPAnchored still has %d uses", v.Uses) + } + v.resetArgs() + f.freeValue(v) + } else { + if opcodeTable[v.Op].nilCheck { + if v.Uses != 0 { + base.Fatalf("nilcheck still has %d uses", v.Uses) + } + // We can't delete the nil check, but we mark + // it as having void type so regalloc won't + // try to allocate a register for it. + v.Type = types.TypeVoid + } + b.Values[i] = v + i++ + } + } + b.truncateValues(i) + } + + f.scheduled = true +} + +// storeOrder orders values with respect to stores. That is, +// if v transitively depends on store s, v is ordered after s, +// otherwise v is ordered before s. +// Specifically, values are ordered like +// +// store1 +// NilCheck that depends on store1 +// other values that depends on store1 +// store2 +// NilCheck that depends on store2 +// other values that depends on store2 +// ... +// +// The order of non-store and non-NilCheck values are undefined +// (not necessarily dependency order). This should be cheaper +// than a full scheduling as done above. +// Note that simple dependency order won't work: there is no +// dependency between NilChecks and values like IsNonNil. +// Auxiliary data structures are passed in as arguments, so +// that they can be allocated in the caller and be reused. +// This function takes care of reset them. +func storeOrder(values []*Value, sset *sparseSet, storeNumber []int32) []*Value { + if len(values) == 0 { + return values + } + + f := values[0].Block.Func + + // find all stores + + // Members of values that are store values. + // A constant bound allows this to be stack-allocated. 64 is + // enough to cover almost every storeOrder call. + stores := make([]*Value, 0, 64) + hasNilCheck := false + sset.clear() // sset is the set of stores that are used in other values + for _, v := range values { + if v.Type.IsMemory() { + stores = append(stores, v) + if v.Op == OpInitMem || v.Op == OpPhi { + continue + } + sset.add(v.MemoryArg().ID) // record that v's memory arg is used + } + if v.Op == OpNilCheck { + hasNilCheck = true + } + } + if len(stores) == 0 || !hasNilCheck && f.pass.name == "nilcheckelim" { + // there is no store, the order does not matter + return values + } + + // find last store, which is the one that is not used by other stores + var last *Value + for _, v := range stores { + if !sset.contains(v.ID) { + if last != nil { + f.Fatalf("two stores live simultaneously: %v and %v", v, last) + } + last = v + } + } + + // We assign a store number to each value. Store number is the + // index of the latest store that this value transitively depends. + // The i-th store in the current block gets store number 3*i. A nil + // check that depends on the i-th store gets store number 3*i+1. + // Other values that depends on the i-th store gets store number 3*i+2. + // Special case: 0 -- unassigned, 1 or 2 -- the latest store it depends + // is in the previous block (or no store at all, e.g. value is Const). + // First we assign the number to all stores by walking back the store chain, + // then assign the number to other values in DFS order. + count := make([]int32, 3*(len(stores)+1)) + sset.clear() // reuse sparse set to ensure that a value is pushed to stack only once + for n, w := len(stores), last; n > 0; n-- { + storeNumber[w.ID] = int32(3 * n) + count[3*n]++ + sset.add(w.ID) + if w.Op == OpInitMem || w.Op == OpPhi { + if n != 1 { + f.Fatalf("store order is wrong: there are stores before %v", w) + } + break + } + w = w.MemoryArg() + } + var stack []*Value + for _, v := range values { + if sset.contains(v.ID) { + // in sset means v is a store, or already pushed to stack, or already assigned a store number + continue + } + stack = append(stack, v) + sset.add(v.ID) + + for len(stack) > 0 { + w := stack[len(stack)-1] + if storeNumber[w.ID] != 0 { + stack = stack[:len(stack)-1] + continue + } + if w.Op == OpPhi { + // Phi value doesn't depend on store in the current block. + // Do this early to avoid dependency cycle. + storeNumber[w.ID] = 2 + count[2]++ + stack = stack[:len(stack)-1] + continue + } + + max := int32(0) // latest store dependency + argsdone := true + for _, a := range w.Args { + if a.Block != w.Block { + continue + } + if !sset.contains(a.ID) { + stack = append(stack, a) + sset.add(a.ID) + argsdone = false + break + } + if storeNumber[a.ID]/3 > max { + max = storeNumber[a.ID] / 3 + } + } + if !argsdone { + continue + } + + n := 3*max + 2 + if w.Op == OpNilCheck { + n = 3*max + 1 + } + storeNumber[w.ID] = n + count[n]++ + stack = stack[:len(stack)-1] + } + } + + // convert count to prefix sum of counts: count'[i] = sum_{j<=i} count[i] + for i := range count { + if i == 0 { + continue + } + count[i] += count[i-1] + } + if count[len(count)-1] != int32(len(values)) { + f.Fatalf("storeOrder: value is missing, total count = %d, values = %v", count[len(count)-1], values) + } + + // place values in count-indexed bins, which are in the desired store order + order := make([]*Value, len(values)) + for _, v := range values { + s := storeNumber[v.ID] + order[count[s-1]] = v + count[s-1]++ + } + + // Order nil checks in source order. We want the first in source order to trigger. + // If two are on the same line, we don't really care which happens first. + // See issue 18169. + if hasNilCheck { + start := -1 + for i, v := range order { + if v.Op == OpNilCheck { + if start == -1 { + start = i + } + } else { + if start != -1 { + slices.SortFunc(order[start:i], valuePosCmp) + start = -1 + } + } + } + if start != -1 { + slices.SortFunc(order[start:], valuePosCmp) + } + } + + return order +} + +// isFlagOp reports if v is an OP with the flag type. +func (v *Value) isFlagOp() bool { + if v.Type.IsFlags() || v.Type.IsTuple() && v.Type.FieldType(1).IsFlags() { + return true + } + // PPC64 carry generators put their carry in a non-flag-typed register + // in their output. + switch v.Op { + case OpPPC64SUBC, OpPPC64ADDC, OpPPC64SUBCconst, OpPPC64ADDCconst: + return true + } + return false +} + +// hasFlagInput reports whether v has a flag value as any of its inputs. +func (v *Value) hasFlagInput() bool { + for _, a := range v.Args { + if a.isFlagOp() { + return true + } + } + // PPC64 carry dependencies are conveyed through their final argument, + // so we treat those operations as taking flags as well. + switch v.Op { + case OpPPC64SUBE, OpPPC64ADDE, OpPPC64SUBZEzero, OpPPC64ADDZE, OpPPC64ADDZEzero: + return true + } + return false +} + +func valuePosCmp(a, b *Value) int { + if a.Pos.Before(b.Pos) { + return -1 + } + if a.Pos.After(b.Pos) { + return +1 + } + return 0 +} diff --git a/go/src/cmd/compile/internal/ssa/schedule_test.go b/go/src/cmd/compile/internal/ssa/schedule_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6cf5105be1f44ef9d77ed05376be17769893c484 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/schedule_test.go @@ -0,0 +1,160 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "testing" +) + +func TestSchedule(t *testing.T) { + c := testConfig(t) + cases := []fun{ + c.Fun("entry", + Bloc("entry", + Valu("mem0", OpInitMem, types.TypeMem, 0, nil), + Valu("ptr", OpConst64, c.config.Types.Int64, 0xABCD, nil), + Valu("v", OpConst64, c.config.Types.Int64, 12, nil), + Valu("mem1", OpStore, types.TypeMem, 0, c.config.Types.Int64, "ptr", "v", "mem0"), + Valu("mem2", OpStore, types.TypeMem, 0, c.config.Types.Int64, "ptr", "v", "mem1"), + Valu("mem3", OpStore, types.TypeMem, 0, c.config.Types.Int64, "ptr", "sum", "mem2"), + Valu("l1", OpLoad, c.config.Types.Int64, 0, nil, "ptr", "mem1"), + Valu("l2", OpLoad, c.config.Types.Int64, 0, nil, "ptr", "mem2"), + Valu("sum", OpAdd64, c.config.Types.Int64, 0, nil, "l1", "l2"), + Goto("exit")), + Bloc("exit", + Exit("mem3"))), + } + for _, c := range cases { + schedule(c.f) + if !isSingleLiveMem(c.f) { + t.Error("single-live-mem restriction not enforced by schedule for func:") + printFunc(c.f) + } + } +} + +func isSingleLiveMem(f *Func) bool { + for _, b := range f.Blocks { + var liveMem *Value + for _, v := range b.Values { + for _, w := range v.Args { + if w.Type.IsMemory() { + if liveMem == nil { + liveMem = w + continue + } + if w != liveMem { + return false + } + } + } + if v.Type.IsMemory() { + liveMem = v + } + } + } + return true +} + +func TestStoreOrder(t *testing.T) { + // In the function below, v2 depends on v3 and v4, v4 depends on v3, and v3 depends on store v5. + // storeOrder did not handle this case correctly. + c := testConfig(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem0", OpInitMem, types.TypeMem, 0, nil), + Valu("a", OpAdd64, c.config.Types.Int64, 0, nil, "b", "c"), // v2 + Valu("b", OpLoad, c.config.Types.Int64, 0, nil, "ptr", "mem1"), // v3 + Valu("c", OpNeg64, c.config.Types.Int64, 0, nil, "b"), // v4 + Valu("mem1", OpStore, types.TypeMem, 0, c.config.Types.Int64, "ptr", "v", "mem0"), // v5 + Valu("mem2", OpStore, types.TypeMem, 0, c.config.Types.Int64, "ptr", "a", "mem1"), + Valu("ptr", OpConst64, c.config.Types.Int64, 0xABCD, nil), + Valu("v", OpConst64, c.config.Types.Int64, 12, nil), + Goto("exit")), + Bloc("exit", + Exit("mem2"))) + + CheckFunc(fun.f) + order := storeOrder(fun.f.Blocks[0].Values, fun.f.newSparseSet(fun.f.NumValues()), make([]int32, fun.f.NumValues())) + + // check that v2, v3, v4 is sorted after v5 + var ai, bi, ci, si int + for i, v := range order { + switch v.ID { + case 2: + ai = i + case 3: + bi = i + case 4: + ci = i + case 5: + si = i + } + } + if ai < si || bi < si || ci < si { + t.Logf("Func: %s", fun.f) + t.Errorf("store order is wrong: got %v, want v2 v3 v4 after v5", order) + } +} + +func TestCarryChainOrder(t *testing.T) { + // In the function below, there are two carry chains that have no dependencies on each other, + // one is A1 -> A1carry -> A1Carryvalue, the other is A2 -> A2carry -> A2Carryvalue. If they + // are not scheduled properly, the carry will be clobbered, causing the carry to be regenerated. + c := testConfigARM64(t) + fun := c.Fun("entry", + Bloc("entry", + Valu("mem0", OpInitMem, types.TypeMem, 0, nil), + Valu("x", OpARM64MOVDconst, c.config.Types.UInt64, 5, nil), + Valu("y", OpARM64MOVDconst, c.config.Types.UInt64, 6, nil), + Valu("z", OpARM64MOVDconst, c.config.Types.UInt64, 7, nil), + Valu("A1", OpARM64ADDSflags, types.NewTuple(c.config.Types.UInt64, types.TypeFlags), 0, nil, "x", "z"), // x+z, set flags + Valu("A1carry", OpSelect1, types.TypeFlags, 0, nil, "A1"), + Valu("A2", OpARM64ADDSflags, types.NewTuple(c.config.Types.UInt64, types.TypeFlags), 0, nil, "y", "z"), // y+z, set flags + Valu("A2carry", OpSelect1, types.TypeFlags, 0, nil, "A2"), + Valu("A1value", OpSelect0, c.config.Types.UInt64, 0, nil, "A1"), + Valu("A1Carryvalue", OpARM64ADCzerocarry, c.config.Types.UInt64, 0, nil, "A1carry"), // 0+0+A1carry + Valu("A2value", OpSelect0, c.config.Types.UInt64, 0, nil, "A2"), + Valu("A2Carryvalue", OpARM64ADCzerocarry, c.config.Types.UInt64, 0, nil, "A2carry"), // 0+0+A2carry + Valu("ValueSum", OpARM64ADD, c.config.Types.UInt64, 0, nil, "A1value", "A2value"), + Valu("CarrySum", OpARM64ADD, c.config.Types.UInt64, 0, nil, "A1Carryvalue", "A2Carryvalue"), + Valu("Sum", OpARM64AND, c.config.Types.UInt64, 0, nil, "ValueSum", "CarrySum"), + Goto("exit")), + Bloc("exit", + Exit("mem0")), + ) + + CheckFunc(fun.f) + schedule(fun.f) + + // The expected order is A1 < A1carry < A1Carryvalue < A2 < A2carry < A2Carryvalue. + // There is no dependency between the two carry chains, so it doesn't matter which + // comes first and which comes after, but the unsorted position of A1 is before A2, + // so A1Carryvalue < A2. + var ai, bi, ci, di, ei, fi int + for i, v := range fun.f.Blocks[0].Values { + switch { + case fun.values["A1"] == v: + ai = i + case fun.values["A1carry"] == v: + bi = i + case fun.values["A1Carryvalue"] == v: + ci = i + case fun.values["A2"] == v: + di = i + case fun.values["A2carry"] == v: + ei = i + case fun.values["A2Carryvalue"] == v: + fi = i + } + } + if !(ai < bi && bi < ci && ci < di && di < ei && ei < fi) { + t.Logf("Func: %s", fun.f) + t.Errorf("carry chain order is wrong: got %v, want V%d after V%d after V%d after V%d after V%d after V%d,", + fun.f.Blocks[0], fun.values["A1"].ID, fun.values["A1carry"].ID, fun.values["A1Carryvalue"].ID, + fun.values["A2"].ID, fun.values["A2carry"].ID, fun.values["A2Carryvalue"].ID) + } +} diff --git a/go/src/cmd/compile/internal/ssa/shift_test.go b/go/src/cmd/compile/internal/ssa/shift_test.go new file mode 100644 index 0000000000000000000000000000000000000000..06c2f6720ff7ff6f35ce57ef0165217516c9adff --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/shift_test.go @@ -0,0 +1,107 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "testing" +) + +func TestShiftConstAMD64(t *testing.T) { + c := testConfig(t) + fun := makeConstShiftFunc(c, 18, OpLsh64x64, c.config.Types.UInt64) + checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SHLQconst: 1, OpAMD64CMPQconst: 0, OpAMD64ANDQconst: 0}) + + fun = makeConstShiftFunc(c, 66, OpLsh64x64, c.config.Types.UInt64) + checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SHLQconst: 0, OpAMD64CMPQconst: 0, OpAMD64ANDQconst: 0}) + + fun = makeConstShiftFunc(c, 18, OpRsh64Ux64, c.config.Types.UInt64) + checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SHRQconst: 1, OpAMD64CMPQconst: 0, OpAMD64ANDQconst: 0}) + + fun = makeConstShiftFunc(c, 66, OpRsh64Ux64, c.config.Types.UInt64) + checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SHRQconst: 0, OpAMD64CMPQconst: 0, OpAMD64ANDQconst: 0}) + + fun = makeConstShiftFunc(c, 18, OpRsh64x64, c.config.Types.Int64) + checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SARQconst: 1, OpAMD64CMPQconst: 0}) + + fun = makeConstShiftFunc(c, 66, OpRsh64x64, c.config.Types.Int64) + checkOpcodeCounts(t, fun.f, map[Op]int{OpAMD64SARQconst: 1, OpAMD64CMPQconst: 0}) +} + +func makeConstShiftFunc(c *Conf, amount int64, op Op, typ *types.Type) fun { + ptyp := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("SP", OpSP, c.config.Types.Uintptr, 0, nil), + Valu("argptr", OpOffPtr, ptyp, 8, nil, "SP"), + Valu("resptr", OpOffPtr, ptyp, 16, nil, "SP"), + Valu("load", OpLoad, typ, 0, nil, "argptr", "mem"), + Valu("c", OpConst64, c.config.Types.UInt64, amount, nil), + Valu("shift", op, typ, 0, nil, "load", "c"), + Valu("store", OpStore, types.TypeMem, 0, c.config.Types.UInt64, "resptr", "shift", "mem"), + Exit("store"))) + Compile(fun.f) + return fun +} + +func TestShiftToExtensionAMD64(t *testing.T) { + c := testConfig(t) + // Test that eligible pairs of constant shifts are converted to extensions. + // For example: + // (uint64(x) << 32) >> 32 -> uint64(uint32(x)) + ops := map[Op]int{ + OpAMD64SHLQconst: 0, OpAMD64SHLLconst: 0, + OpAMD64SHRQconst: 0, OpAMD64SHRLconst: 0, + OpAMD64SARQconst: 0, OpAMD64SARLconst: 0, + } + tests := [...]struct { + amount int64 + left, right Op + typ *types.Type + }{ + // unsigned + {56, OpLsh64x64, OpRsh64Ux64, c.config.Types.UInt64}, + {48, OpLsh64x64, OpRsh64Ux64, c.config.Types.UInt64}, + {32, OpLsh64x64, OpRsh64Ux64, c.config.Types.UInt64}, + {24, OpLsh32x64, OpRsh32Ux64, c.config.Types.UInt32}, + {16, OpLsh32x64, OpRsh32Ux64, c.config.Types.UInt32}, + {8, OpLsh16x64, OpRsh16Ux64, c.config.Types.UInt16}, + // signed + {56, OpLsh64x64, OpRsh64x64, c.config.Types.Int64}, + {48, OpLsh64x64, OpRsh64x64, c.config.Types.Int64}, + {32, OpLsh64x64, OpRsh64x64, c.config.Types.Int64}, + {24, OpLsh32x64, OpRsh32x64, c.config.Types.Int32}, + {16, OpLsh32x64, OpRsh32x64, c.config.Types.Int32}, + {8, OpLsh16x64, OpRsh16x64, c.config.Types.Int16}, + } + for _, tc := range tests { + fun := makeShiftExtensionFunc(c, tc.amount, tc.left, tc.right, tc.typ) + checkOpcodeCounts(t, fun.f, ops) + } +} + +// makeShiftExtensionFunc generates a function containing: +// +// (rshift (lshift (Const64 [amount])) (Const64 [amount])) +// +// This may be equivalent to a sign or zero extension. +func makeShiftExtensionFunc(c *Conf, amount int64, lshift, rshift Op, typ *types.Type) fun { + ptyp := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("SP", OpSP, c.config.Types.Uintptr, 0, nil), + Valu("argptr", OpOffPtr, ptyp, 8, nil, "SP"), + Valu("resptr", OpOffPtr, ptyp, 16, nil, "SP"), + Valu("load", OpLoad, typ, 0, nil, "argptr", "mem"), + Valu("c", OpConst64, c.config.Types.UInt64, amount, nil), + Valu("lshift", lshift, typ, 0, nil, "load", "c"), + Valu("rshift", rshift, typ, 0, nil, "lshift", "c"), + Valu("store", OpStore, types.TypeMem, 0, c.config.Types.UInt64, "resptr", "rshift", "mem"), + Exit("store"))) + Compile(fun.f) + return fun +} diff --git a/go/src/cmd/compile/internal/ssa/shortcircuit.go b/go/src/cmd/compile/internal/ssa/shortcircuit.go new file mode 100644 index 0000000000000000000000000000000000000000..b86596026b76eaf92ca82ea0a169a32105ca3655 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/shortcircuit.go @@ -0,0 +1,596 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// shortcircuit finds situations where branch directions +// are always correlated and rewrites the CFG to take +// advantage of that fact. +// This optimization is useful for compiling && and || expressions. +func shortcircuit(f *Func) { + // Step 1: Replace a phi arg with a constant if that arg + // is the control value of a preceding If block. + // b1: + // If a goto b2 else b3 + // b2: <- b1 ... + // x = phi(a, ...) + // + // We can replace the "a" in the phi with the constant true. + var ct, cf *Value + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op != OpPhi { + continue + } + if !v.Type.IsBoolean() { + continue + } + for i, a := range v.Args { + e := b.Preds[i] + p := e.b + if p.Kind != BlockIf { + continue + } + if p.Controls[0] != a { + continue + } + if e.i == 0 { + if ct == nil { + ct = f.ConstBool(f.Config.Types.Bool, true) + } + v.SetArg(i, ct) + } else { + if cf == nil { + cf = f.ConstBool(f.Config.Types.Bool, false) + } + v.SetArg(i, cf) + } + } + } + } + + // Step 2: Redirect control flow around known branches. + // p: + // ... goto b ... + // b: <- p ... + // v = phi(true, ...) + // if v goto t else u + // We can redirect p to go directly to t instead of b. + // (If v is not live after b). + fuse(f, fuseTypePlain|fuseTypeShortCircuit) +} + +// shortcircuitBlock checks for a CFG in which an If block +// has as its control value a Phi that has a ConstBool arg. +// In some such cases, we can rewrite the CFG into a flatter form. +// +// (1) Look for a CFG of the form +// +// p other pred(s) +// \ / +// b +// / \ +// t other succ +// +// in which b is an If block containing a single phi value with a single use (b's Control), +// which has a ConstBool arg. +// p is the predecessor corresponding to the argument slot in which the ConstBool is found. +// t is the successor corresponding to the value of the ConstBool arg. +// +// Rewrite this into +// +// p other pred(s) +// | / +// | b +// |/ \ +// t u +// +// and remove the appropriate phi arg(s). +// +// (2) Look for a CFG of the form +// +// p q +// \ / +// b +// / \ +// t u +// +// in which b is as described in (1). +// However, b may also contain other phi values. +// The CFG will be modified as described in (1). +// However, in order to handle those other phi values, +// for each other phi value w, we must be able to eliminate w from b. +// We can do that though a combination of moving w to a different block +// and rewriting uses of w to use a different value instead. +// See shortcircuitPhiPlan for details. +func shortcircuitBlock(b *Block) bool { + if b.Kind != BlockIf { + return false + } + // Look for control values of the form Copy(Not(Copy(Phi(const, ...)))). + // Those must be the only values in the b, and they each must be used only by b. + // Track the negations so that we can swap successors as needed later. + ctl := b.Controls[0] + nval := 1 // the control value + var swap int64 + for ctl.Uses == 1 && ctl.Block == b && (ctl.Op == OpCopy || ctl.Op == OpNot) { + if ctl.Op == OpNot { + swap = 1 ^ swap + } + ctl = ctl.Args[0] + nval++ // wrapper around control value + } + if ctl.Op != OpPhi || ctl.Block != b || ctl.Uses != 1 { + return false + } + nOtherPhi := 0 + for _, w := range b.Values { + if w.Op == OpPhi && w != ctl { + nOtherPhi++ + } + } + if nOtherPhi > 0 && len(b.Preds) != 2 { + // We rely on b having exactly two preds in shortcircuitPhiPlan + // to reason about the values of phis. + return false + } + // We only process blocks with only phi values except for control + // value and its wrappers. + if len(b.Values) != nval+nOtherPhi { + return false + } + if nOtherPhi > 0 { + // Check for any phi which is the argument of another phi. + // These cases are tricky, as substitutions done by replaceUses + // are no longer trivial to do in any ordering. See issue 45175. + m := make(map[*Value]bool, 1+nOtherPhi) + for _, v := range b.Values { + if v.Op == OpPhi { + m[v] = true + } + } + for v := range m { + for _, a := range v.Args { + if a != v && m[a] { + return false + } + } + } + } + + // Locate index of first const phi arg. + cidx := -1 + for i, a := range ctl.Args { + if a.Op == OpConstBool { + cidx = i + break + } + } + if cidx == -1 { + return false + } + + // p is the predecessor corresponding to cidx. + pe := b.Preds[cidx] + p := pe.b + pi := pe.i + + // t is the "taken" branch: the successor we always go to when coming in from p. + ti := 1 ^ ctl.Args[cidx].AuxInt ^ swap + te := b.Succs[ti] + t := te.b + if p == b || t == b { + // This is an infinite loop; we can't remove it. See issue 33903. + return false + } + + var fixPhi func(*Value, int) + if nOtherPhi > 0 { + fixPhi = shortcircuitPhiPlan(b, ctl, cidx, ti) + if fixPhi == nil { + return false + } + } + + // We're committed. Update CFG and Phis. + // If you modify this section, update shortcircuitPhiPlan corresponding. + + // Remove b's incoming edge from p. + b.removePred(cidx) + b.removePhiArg(ctl, cidx) + + // Redirect p's outgoing edge to t. + p.Succs[pi] = Edge{t, len(t.Preds)} + + // Fix up t to have one more predecessor. + t.Preds = append(t.Preds, Edge{p, pi}) + for _, v := range t.Values { + if v.Op != OpPhi { + continue + } + v.AddArg(v.Args[te.i]) + } + + if nOtherPhi != 0 { + // Adjust all other phis as necessary. + // Use a plain for loop instead of range because fixPhi may move phis, + // thus modifying b.Values. + for i := 0; i < len(b.Values); i++ { + phi := b.Values[i] + if phi.Uses == 0 || phi == ctl || phi.Op != OpPhi { + continue + } + fixPhi(phi, i) + if phi.Block == b { + continue + } + // phi got moved to a different block with v.moveTo. + // Adjust phi values in this new block that refer + // to phi to refer to the corresponding phi arg instead. + // phi used to be evaluated prior to this block, + // and now it is evaluated in this block. + for _, v := range phi.Block.Values { + if v.Op != OpPhi || v == phi { + continue + } + for j, a := range v.Args { + if a == phi { + v.SetArg(j, phi.Args[j]) + } + } + } + if phi.Uses != 0 { + phielimValue(phi) + } else { + phi.reset(OpInvalid) + } + i-- // v.moveTo put a new value at index i; reprocess + } + + // We may have left behind some phi values with no uses + // but the wrong number of arguments. Eliminate those. + for _, v := range b.Values { + if v.Uses == 0 { + v.reset(OpInvalid) + } + } + } + + if len(b.Preds) == 0 { + // Block is now dead. + b.Kind = BlockInvalid + } + + phielimValue(ctl) + return true +} + +// shortcircuitPhiPlan returns a function to handle non-ctl phi values in b, +// where b is as described in shortcircuitBlock. +// The returned function accepts a value v +// and the index i of v in v.Block: v.Block.Values[i] == v. +// If the returned function moves v to a different block, it will use v.moveTo. +// cidx is the index in ctl of the ConstBool arg. +// ti is the index in b.Succs of the always taken branch when arriving from p. +// If shortcircuitPhiPlan returns nil, there is no plan available, +// and the CFG modifications must not proceed. +// The returned function assumes that shortcircuitBlock has completed its CFG modifications. +func shortcircuitPhiPlan(b *Block, ctl *Value, cidx int, ti int64) func(*Value, int) { + // t is the "taken" branch: the successor we always go to when coming in from p. + t := b.Succs[ti].b + // u is the "untaken" branch: the successor we never go to when coming in from p. + u := b.Succs[1^ti].b + + // In the following CFG matching, ensure that b's preds are entirely distinct from b's succs. + // This is probably a stronger condition than required, but this happens extremely rarely, + // and it makes it easier to avoid getting deceived by pretty ASCII charts. See #44465. + if p0, p1 := b.Preds[0].b, b.Preds[1].b; p0 == t || p1 == t || p0 == u || p1 == u { + return nil + } + + // Look for some common CFG structures + // in which the outbound paths from b merge, + // with no other preds joining them. + // In these cases, we can reconstruct what the value + // of any phi in b must be in the successor blocks. + + if len(t.Preds) == 1 && len(t.Succs) == 1 && len(u.Preds) == 1 && + len(t.Succs[0].b.Preds) == 2 { + m := t.Succs[0].b + if visited := u.flowsTo(m, 5); visited != nil { + // p q + // \ / + // b + // / \ + // t U (sub graph that satisfy condition in flowsTo) + // \ / + // m + // + // After the CFG modifications, this will look like + // + // p q + // | / + // | b + // |/ \ + // t U + // \ / + // m + // + // NB: t.Preds is (b, p), not (p, b). + return func(v *Value, i int) { + // Replace any uses of v in t and u with the value v must have, + // given that we have arrived at that block. + // Then move v to m and adjust its value accordingly; + // this handles all other uses of v. + argP, argQ := v.Args[cidx], v.Args[1^cidx] + phi := t.Func.newValue(OpPhi, v.Type, t, v.Pos) + phi.AddArg2(argQ, argP) + t.replaceUses(v, phi) + for bb := range visited { + bb.replaceUses(v, argQ) + } + if v.Uses == 0 { + return + } + v.moveTo(m, i) + // The phi in m belongs to whichever pred idx corresponds to t. + if m.Preds[0].b == t { + v.SetArgs2(phi, argQ) + } else { + v.SetArgs2(argQ, phi) + } + } + } + } + + if len(t.Preds) == 2 && len(u.Preds) == 1 { + if visited := u.flowsTo(t, 5); visited != nil { + // p q + // \ / + // b + // |\ + // | U ((sub graph that satisfy condition in flowsTo)) + // |/ + // t + // + // After the CFG modifications, this will look like + // + // q + // / + // b + // |\ + // p | U + // \|/ + // t + // + // NB: t.Preds is (b or U, b or U, p). + return func(v *Value, i int) { + // Replace any uses of v in U. Then move v to t. + argP, argQ := v.Args[cidx], v.Args[1^cidx] + for bb := range visited { + bb.replaceUses(v, argQ) + } + v.moveTo(t, i) + v.SetArgs3(argQ, argQ, argP) + } + } + } + + if len(u.Preds) == 2 && len(t.Preds) == 1 && len(t.Succs) == 1 && t.Succs[0].b == u { + // p q + // \ / + // b + // /| + // t | + // \| + // u + // + // After the CFG modifications, this will look like + // + // p q + // | / + // | b + // |/| + // t | + // \| + // u + // + // NB: t.Preds is (b, p), not (p, b). + return func(v *Value, i int) { + // Replace any uses of v in t. Then move v to u. + argP, argQ := v.Args[cidx], v.Args[1^cidx] + phi := t.Func.newValue(OpPhi, v.Type, t, v.Pos) + phi.AddArg2(argQ, argP) + t.replaceUses(v, phi) + if v.Uses == 0 { + return + } + v.moveTo(u, i) + v.SetArgs2(argQ, phi) + } + } + + // Look for some common CFG structures + // in which one outbound path from b exits, + // with no other preds joining. + // In these cases, we can reconstruct what the value + // of any phi in b must be in the path leading to exit, + // and move the phi to the non-exit path. + + if len(t.Preds) == 1 && len(u.Preds) == 1 && len(t.Succs) == 0 { + // p q + // \ / + // b + // / \ + // t u + // + // where t is an Exit/Ret block. + // + // After the CFG modifications, this will look like + // + // p q + // | / + // | b + // |/ \ + // t u + // + // NB: t.Preds is (b, p), not (p, b). + return func(v *Value, i int) { + // Replace any uses of v in t and x. Then move v to u. + argP, argQ := v.Args[cidx], v.Args[1^cidx] + // If there are no uses of v in t or x, this phi will be unused. + // That's OK; it's not worth the cost to prevent that. + phi := t.Func.newValue(OpPhi, v.Type, t, v.Pos) + phi.AddArg2(argQ, argP) + t.replaceUses(v, phi) + if v.Uses == 0 { + return + } + v.moveTo(u, i) + v.SetArgs1(argQ) + } + } + + if len(u.Preds) == 1 && len(t.Preds) == 1 && len(u.Succs) == 0 { + // p q + // \ / + // b + // / \ + // t u + // + // where u is an Exit/Ret block. + // + // After the CFG modifications, this will look like + // + // p q + // | / + // | b + // |/ \ + // t u + // + // NB: t.Preds is (b, p), not (p, b). + return func(v *Value, i int) { + // Replace any uses of v in u (and x). Then move v to t. + argP, argQ := v.Args[cidx], v.Args[1^cidx] + u.replaceUses(v, argQ) + v.moveTo(t, i) + v.SetArgs2(argQ, argP) + } + } + + // TODO: handle more cases; shortcircuit optimizations turn out to be reasonably high impact + return nil +} + +// replaceUses replaces all uses of old in b with new. +func (b *Block) replaceUses(old, new *Value) { + for _, v := range b.Values { + for i, a := range v.Args { + if a == old { + v.SetArg(i, new) + } + } + } + for i, v := range b.ControlValues() { + if v == old { + b.ReplaceControl(i, new) + } + } +} + +// moveTo moves v to dst, adjusting the appropriate Block.Values slices. +// The caller is responsible for ensuring that this is safe. +// i is the index of v in v.Block.Values. +func (v *Value) moveTo(dst *Block, i int) { + if dst.Func.scheduled { + v.Fatalf("moveTo after scheduling") + } + src := v.Block + if src.Values[i] != v { + v.Fatalf("moveTo bad index %d", v, i) + } + if src == dst { + return + } + v.Block = dst + dst.Values = append(dst.Values, v) + last := len(src.Values) - 1 + src.Values[i] = src.Values[last] + src.Values[last] = nil + src.Values = src.Values[:last] +} + +// flowsTo checks that the subgraph starting from v and ends at t is a DAG, with +// the following constraints: +// +// (1) v can reach t. +// (2) v's connected component removing the paths containing t is a DAG. +// (3) The blocks in the subgraph G defined in (2) has all their preds also in G, +// except v. +// (4) The subgraph defined in (2) has a size smaller than cap. +// +// We know that the subgraph G defined in constraint (2)(3) has the property that v +// dominates all the blocks in G: +// If there exist a block x in G that is not dominated by v, then there exist a +// path P from entry to x that does not contain v. Denote x's predecessor in P +// as x', then x' must also be in G given constraint (3), same to its pred x'' +// in P. Given constraint (2), by going back in P we will in the end reach v, +// which conflicts with the definition of P. +// +// Constraint (2)'s DAG requirement could be further relaxed to contain "internal" +// loops that doesn't change the dominance relation of v. But that is more subtle +// and requires another constraint on the source block v, and a more complex proof. +// Furthermore optimizing the branch guarding a loop might bring less gains as the +// loop itself might be the bottleneck. +func (v *Block) flowsTo(t *Block, cap int) map[*Block]struct{} { + seen := map[*Block]struct{}{} + var boundedDFS func(b *Block) + hasPathToT := false + fullyExplored := true + isDAG := true + visited := map[*Block]struct{}{} + boundedDFS = func(b *Block) { + if _, ok := seen[b]; ok { + return + } + if _, ok := visited[b]; ok { + isDAG = false + return + } + if b == t { + // do not put t into seen, this way + // if v can reach t's connected component without going through t, + // it will fail the pred check after boundedDFSUntil. + hasPathToT = true + return + } + if len(seen) > cap { + fullyExplored = false + return + } + seen[b] = struct{}{} + visited[b] = struct{}{} + for _, se := range b.Succs { + boundedDFS(se.b) + if !(isDAG && fullyExplored) { + return + } + } + delete(visited, b) + } + boundedDFS(v) + if hasPathToT && fullyExplored && isDAG { + for b := range seen { + if b != v { + for _, se := range b.Preds { + if _, ok := seen[se.b]; !ok { + return nil + } + } + } + } + return seen + } + return nil +} diff --git a/go/src/cmd/compile/internal/ssa/shortcircuit_test.go b/go/src/cmd/compile/internal/ssa/shortcircuit_test.go new file mode 100644 index 0000000000000000000000000000000000000000..b25eeb4740e6614821cbb50d26e857b50e4ce717 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/shortcircuit_test.go @@ -0,0 +1,53 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "testing" +) + +func TestShortCircuit(t *testing.T) { + c := testConfig(t) + + fun := c.Fun("entry", + Bloc("entry", + Valu("mem", OpInitMem, types.TypeMem, 0, nil), + Valu("arg1", OpArg, c.config.Types.Int64, 0, nil), + Valu("arg2", OpArg, c.config.Types.Int64, 0, nil), + Valu("arg3", OpArg, c.config.Types.Int64, 0, nil), + Goto("b1")), + Bloc("b1", + Valu("cmp1", OpLess64, c.config.Types.Bool, 0, nil, "arg1", "arg2"), + If("cmp1", "b2", "b3")), + Bloc("b2", + Valu("cmp2", OpLess64, c.config.Types.Bool, 0, nil, "arg2", "arg3"), + Goto("b3")), + Bloc("b3", + Valu("phi2", OpPhi, c.config.Types.Bool, 0, nil, "cmp1", "cmp2"), + If("phi2", "b4", "b5")), + Bloc("b4", + Valu("cmp3", OpLess64, c.config.Types.Bool, 0, nil, "arg3", "arg1"), + Goto("b5")), + Bloc("b5", + Valu("phi3", OpPhi, c.config.Types.Bool, 0, nil, "phi2", "cmp3"), + If("phi3", "b6", "b7")), + Bloc("b6", + Exit("mem")), + Bloc("b7", + Exit("mem"))) + + CheckFunc(fun.f) + shortcircuit(fun.f) + CheckFunc(fun.f) + + for _, b := range fun.f.Blocks { + for _, v := range b.Values { + if v.Op == OpPhi { + t.Errorf("phi %s remains", v) + } + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/sizeof_test.go b/go/src/cmd/compile/internal/ssa/sizeof_test.go new file mode 100644 index 0000000000000000000000000000000000000000..c81b66f76a6c0c96cb76eeaac8518282227d4232 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/sizeof_test.go @@ -0,0 +1,39 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "reflect" + "testing" + "unsafe" +) + +// Assert that the size of important structures do not change unexpectedly. + +func TestSizeof(t *testing.T) { + const _64bit = unsafe.Sizeof(uintptr(0)) == 8 + + var tests = []struct { + val any // type as a value + _32bit uintptr // size on 32bit platforms + _64bit uintptr // size on 64bit platforms + }{ + {Value{}, 72, 112}, + {Block{}, 168, 312}, + {LocalSlot{}, 28, 40}, + {valState{}, 28, 40}, + } + + for _, tt := range tests { + want := tt._32bit + if _64bit { + want = tt._64bit + } + got := reflect.TypeOf(tt.val).Size() + if want != got { + t.Errorf("unsafe.Sizeof(%T) = %d, want %d", tt.val, got, want) + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/softfloat.go b/go/src/cmd/compile/internal/ssa/softfloat.go new file mode 100644 index 0000000000000000000000000000000000000000..cd6df5fe8b0361f810c282d0906eba19f1fbc485 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/softfloat.go @@ -0,0 +1,80 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "math" +) + +func softfloat(f *Func) { + if !f.Config.SoftFloat { + return + } + newInt64 := false + + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Type.IsFloat() { + f.unCache(v) + switch v.Op { + case OpPhi, OpLoad, OpArg: + if v.Type.Size() == 4 { + v.Type = f.Config.Types.UInt32 + } else { + v.Type = f.Config.Types.UInt64 + } + case OpConst32F: + v.Op = OpConst32 + v.Type = f.Config.Types.UInt32 + v.AuxInt = int64(int32(math.Float32bits(auxTo32F(v.AuxInt)))) + case OpConst64F: + v.Op = OpConst64 + v.Type = f.Config.Types.UInt64 + case OpNeg32F: + arg0 := v.Args[0] + v.reset(OpXor32) + v.Type = f.Config.Types.UInt32 + v.AddArg(arg0) + mask := v.Block.NewValue0(v.Pos, OpConst32, v.Type) + mask.AuxInt = -0x80000000 + v.AddArg(mask) + case OpNeg64F: + arg0 := v.Args[0] + v.reset(OpXor64) + v.Type = f.Config.Types.UInt64 + v.AddArg(arg0) + mask := v.Block.NewValue0(v.Pos, OpConst64, v.Type) + mask.AuxInt = -0x8000000000000000 + v.AddArg(mask) + case OpRound32F: + v.Op = OpCopy + v.Type = f.Config.Types.UInt32 + case OpRound64F: + v.Op = OpCopy + v.Type = f.Config.Types.UInt64 + } + newInt64 = newInt64 || v.Type.Size() == 8 + } else if (v.Op == OpStore || v.Op == OpZero || v.Op == OpMove) && v.Aux.(*types.Type).IsFloat() { + switch size := v.Aux.(*types.Type).Size(); size { + case 4: + v.Aux = f.Config.Types.UInt32 + case 8: + v.Aux = f.Config.Types.UInt64 + newInt64 = true + default: + v.Fatalf("bad float type with size %d", size) + } + } + } + } + + if newInt64 && f.Config.RegSize == 4 { + // On 32bit arch, decompose Uint64 introduced in the switch above. + decomposeBuiltin(f) + applyRewrite(f, rewriteBlockdec64, rewriteValuedec64, removeDeadValues) + } + +} diff --git a/go/src/cmd/compile/internal/ssa/sparsemap.go b/go/src/cmd/compile/internal/ssa/sparsemap.go new file mode 100644 index 0000000000000000000000000000000000000000..255a346d37f01d5523e0f68f48ba4f1caab40219 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/sparsemap.go @@ -0,0 +1,87 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// from https://research.swtch.com/sparse +// in turn, from Briggs and Torczon + +// sparseKey needs to be something we can index a slice with. +type sparseKey interface{ ~int | ~int32 } + +type sparseEntry[K sparseKey, V any] struct { + key K + val V +} + +type genericSparseMap[K sparseKey, V any] struct { + dense []sparseEntry[K, V] + sparse []int32 +} + +// newGenericSparseMap returns a sparseMap that can map +// integers between 0 and n-1 to a value type. +func newGenericSparseMap[K sparseKey, V any](n int) *genericSparseMap[K, V] { + return &genericSparseMap[K, V]{dense: nil, sparse: make([]int32, n)} +} + +func (s *genericSparseMap[K, V]) cap() int { + return len(s.sparse) +} + +func (s *genericSparseMap[K, V]) size() int { + return len(s.dense) +} + +func (s *genericSparseMap[K, V]) contains(k K) bool { + i := s.sparse[k] + return i < int32(len(s.dense)) && s.dense[i].key == k +} + +// get returns the value for key k, or the zero V +// if k does not appear in the map. +func (s *genericSparseMap[K, V]) get(k K) (V, bool) { + i := s.sparse[k] + if i < int32(len(s.dense)) && s.dense[i].key == k { + return s.dense[i].val, true + } + var v V + return v, false +} + +func (s *genericSparseMap[K, V]) set(k K, v V) { + i := s.sparse[k] + if i < int32(len(s.dense)) && s.dense[i].key == k { + s.dense[i].val = v + return + } + s.dense = append(s.dense, sparseEntry[K, V]{k, v}) + s.sparse[k] = int32(len(s.dense)) - 1 +} + +func (s *genericSparseMap[K, V]) remove(k K) { + i := s.sparse[k] + if i < int32(len(s.dense)) && s.dense[i].key == k { + y := s.dense[len(s.dense)-1] + s.dense[i] = y + s.sparse[y.key] = i + s.dense = s.dense[:len(s.dense)-1] + } +} + +func (s *genericSparseMap[K, V]) clear() { + s.dense = s.dense[:0] +} + +func (s *genericSparseMap[K, V]) contents() []sparseEntry[K, V] { + return s.dense +} + +type sparseMap = genericSparseMap[ID, int32] + +// newSparseMap returns a sparseMap that can map +// integers between 0 and n-1 to int32s. +func newSparseMap(n int) *sparseMap { + return newGenericSparseMap[ID, int32](n) +} diff --git a/go/src/cmd/compile/internal/ssa/sparsemappos.go b/go/src/cmd/compile/internal/ssa/sparsemappos.go new file mode 100644 index 0000000000000000000000000000000000000000..60bad8298bfe52098ba0d7ef842138d7f286a93e --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/sparsemappos.go @@ -0,0 +1,79 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import "cmd/internal/src" + +// from https://research.swtch.com/sparse +// in turn, from Briggs and Torczon + +type sparseEntryPos struct { + key ID + val int32 + pos src.XPos +} + +type sparseMapPos struct { + dense []sparseEntryPos + sparse []int32 +} + +// newSparseMapPos returns a sparseMapPos that can map +// integers between 0 and n-1 to the pair . +func newSparseMapPos(n int) *sparseMapPos { + return &sparseMapPos{dense: nil, sparse: make([]int32, n)} +} + +func (s *sparseMapPos) cap() int { + return len(s.sparse) +} + +func (s *sparseMapPos) size() int { + return len(s.dense) +} + +func (s *sparseMapPos) contains(k ID) bool { + i := s.sparse[k] + return i < int32(len(s.dense)) && s.dense[i].key == k +} + +// get returns the value for key k, or -1 if k does +// not appear in the map. +func (s *sparseMapPos) get(k ID) int32 { + i := s.sparse[k] + if i < int32(len(s.dense)) && s.dense[i].key == k { + return s.dense[i].val + } + return -1 +} + +func (s *sparseMapPos) set(k ID, v int32, a src.XPos) { + i := s.sparse[k] + if i < int32(len(s.dense)) && s.dense[i].key == k { + s.dense[i].val = v + s.dense[i].pos = a + return + } + s.dense = append(s.dense, sparseEntryPos{k, v, a}) + s.sparse[k] = int32(len(s.dense)) - 1 +} + +func (s *sparseMapPos) remove(k ID) { + i := s.sparse[k] + if i < int32(len(s.dense)) && s.dense[i].key == k { + y := s.dense[len(s.dense)-1] + s.dense[i] = y + s.sparse[y.key] = i + s.dense = s.dense[:len(s.dense)-1] + } +} + +func (s *sparseMapPos) clear() { + s.dense = s.dense[:0] +} + +func (s *sparseMapPos) contents() []sparseEntryPos { + return s.dense +} diff --git a/go/src/cmd/compile/internal/ssa/sparseset.go b/go/src/cmd/compile/internal/ssa/sparseset.go new file mode 100644 index 0000000000000000000000000000000000000000..07d40dc948cc2faabbd558e23d4635e3afe448f3 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/sparseset.go @@ -0,0 +1,79 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// from https://research.swtch.com/sparse +// in turn, from Briggs and Torczon + +type sparseSet struct { + dense []ID + sparse []int32 +} + +// newSparseSet returns a sparseSet that can represent +// integers between 0 and n-1. +func newSparseSet(n int) *sparseSet { + return &sparseSet{dense: nil, sparse: make([]int32, n)} +} + +func (s *sparseSet) cap() int { + return len(s.sparse) +} + +func (s *sparseSet) size() int { + return len(s.dense) +} + +func (s *sparseSet) contains(x ID) bool { + i := s.sparse[x] + return i < int32(len(s.dense)) && s.dense[i] == x +} + +func (s *sparseSet) add(x ID) { + i := s.sparse[x] + if i < int32(len(s.dense)) && s.dense[i] == x { + return + } + s.dense = append(s.dense, x) + s.sparse[x] = int32(len(s.dense)) - 1 +} + +func (s *sparseSet) addAll(a []ID) { + for _, x := range a { + s.add(x) + } +} + +func (s *sparseSet) addAllValues(a []*Value) { + for _, v := range a { + s.add(v.ID) + } +} + +func (s *sparseSet) remove(x ID) { + i := s.sparse[x] + if i < int32(len(s.dense)) && s.dense[i] == x { + y := s.dense[len(s.dense)-1] + s.dense[i] = y + s.sparse[y] = i + s.dense = s.dense[:len(s.dense)-1] + } +} + +// pop removes an arbitrary element from the set. +// The set must be nonempty. +func (s *sparseSet) pop() ID { + x := s.dense[len(s.dense)-1] + s.dense = s.dense[:len(s.dense)-1] + return x +} + +func (s *sparseSet) clear() { + s.dense = s.dense[:0] +} + +func (s *sparseSet) contents() []ID { + return s.dense +} diff --git a/go/src/cmd/compile/internal/ssa/sparsetree.go b/go/src/cmd/compile/internal/ssa/sparsetree.go new file mode 100644 index 0000000000000000000000000000000000000000..6f2bd040375a83c129f69d8a021b13e4a55803f6 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/sparsetree.go @@ -0,0 +1,242 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "fmt" + "strings" +) + +type SparseTreeNode struct { + child *Block + sibling *Block + parent *Block + + // Every block has 6 numbers associated with it: + // entry-1, entry, entry+1, exit-1, and exit, exit+1. + // entry and exit are conceptually the top of the block (phi functions) + // entry+1 and exit-1 are conceptually the bottom of the block (ordinary defs) + // entry-1 and exit+1 are conceptually "just before" the block (conditions flowing in) + // + // This simplifies life if we wish to query information about x + // when x is both an input to and output of a block. + entry, exit int32 +} + +func (s *SparseTreeNode) String() string { + return fmt.Sprintf("[%d,%d]", s.entry, s.exit) +} + +func (s *SparseTreeNode) Entry() int32 { + return s.entry +} + +func (s *SparseTreeNode) Exit() int32 { + return s.exit +} + +const ( + // When used to lookup up definitions in a sparse tree, + // these adjustments to a block's entry (+adjust) and + // exit (-adjust) numbers allow a distinction to be made + // between assignments (typically branch-dependent + // conditionals) occurring "before" the block (e.g., as inputs + // to the block and its phi functions), "within" the block, + // and "after" the block. + AdjustBefore = -1 // defined before phi + AdjustWithin = 0 // defined by phi + AdjustAfter = 1 // defined within block +) + +// A SparseTree is a tree of Blocks. +// It allows rapid ancestor queries, +// such as whether one block dominates another. +type SparseTree []SparseTreeNode + +// newSparseTree creates a SparseTree from a block-to-parent map (array indexed by Block.ID). +func newSparseTree(f *Func, parentOf []*Block) SparseTree { + t := make(SparseTree, f.NumBlocks()) + for _, b := range f.Blocks { + n := &t[b.ID] + if p := parentOf[b.ID]; p != nil { + n.parent = p + n.sibling = t[p.ID].child + t[p.ID].child = b + } + } + t.numberBlock(f.Entry, 1) + return t +} + +// newSparseOrderedTree creates a SparseTree from a block-to-parent map (array indexed by Block.ID) +// children will appear in the reverse of their order in reverseOrder +// in particular, if reverseOrder is a dfs-reversePostOrder, then the root-to-children +// walk of the tree will yield a pre-order. +func newSparseOrderedTree(f *Func, parentOf, reverseOrder []*Block) SparseTree { + t := make(SparseTree, f.NumBlocks()) + for _, b := range reverseOrder { + n := &t[b.ID] + if p := parentOf[b.ID]; p != nil { + n.parent = p + n.sibling = t[p.ID].child + t[p.ID].child = b + } + } + t.numberBlock(f.Entry, 1) + return t +} + +// treestructure provides a string description of the dominator +// tree and flow structure of block b and all blocks that it +// dominates. +func (t SparseTree) treestructure(b *Block) string { + return t.treestructure1(b, 0) +} +func (t SparseTree) treestructure1(b *Block, i int) string { + s := "\n" + strings.Repeat("\t", i) + b.String() + "->[" + for i, e := range b.Succs { + if i > 0 { + s += "," + } + s += e.b.String() + } + s += "]" + if c0 := t[b.ID].child; c0 != nil { + s += "(" + for c := c0; c != nil; c = t[c.ID].sibling { + if c != c0 { + s += " " + } + s += t.treestructure1(c, i+1) + } + s += ")" + } + return s +} + +// numberBlock assigns entry and exit numbers for b and b's +// children in an in-order walk from a gappy sequence, where n +// is the first number not yet assigned or reserved. N should +// be larger than zero. For each entry and exit number, the +// values one larger and smaller are reserved to indicate +// "strictly above" and "strictly below". numberBlock returns +// the smallest number not yet assigned or reserved (i.e., the +// exit number of the last block visited, plus two, because +// last.exit+1 is a reserved value.) +// +// examples: +// +// single node tree Root, call with n=1 +// entry=2 Root exit=5; returns 7 +// +// two node tree, Root->Child, call with n=1 +// entry=2 Root exit=11; returns 13 +// entry=5 Child exit=8 +// +// three node tree, Root->(Left, Right), call with n=1 +// entry=2 Root exit=17; returns 19 +// entry=5 Left exit=8; entry=11 Right exit=14 +// +// This is the in-order sequence of assigned and reserved numbers +// for the last example: +// root left left right right root +// 1 2e 3 | 4 5e 6 | 7 8x 9 | 10 11e 12 | 13 14x 15 | 16 17x 18 + +func (t SparseTree) numberBlock(b *Block, n int32) int32 { + // reserve n for entry-1, assign n+1 to entry + n++ + t[b.ID].entry = n + // reserve n+1 for entry+1, n+2 is next free number + n += 2 + for c := t[b.ID].child; c != nil; c = t[c.ID].sibling { + n = t.numberBlock(c, n) // preserves n = next free number + } + // reserve n for exit-1, assign n+1 to exit + n++ + t[b.ID].exit = n + // reserve n+1 for exit+1, n+2 is next free number, returned. + return n + 2 +} + +// Sibling returns a sibling of x in the dominator tree (i.e., +// a node with the same immediate dominator) or nil if there +// are no remaining siblings in the arbitrary but repeatable +// order chosen. Because the Child-Sibling order is used +// to assign entry and exit numbers in the treewalk, those +// numbers are also consistent with this order (i.e., +// Sibling(x) has entry number larger than x's exit number). +func (t SparseTree) Sibling(x *Block) *Block { + return t[x.ID].sibling +} + +// Child returns a child of x in the dominator tree, or +// nil if there are none. The choice of first child is +// arbitrary but repeatable. +func (t SparseTree) Child(x *Block) *Block { + return t[x.ID].child +} + +// Parent returns the parent of x in the dominator tree, or +// nil if x is the function's entry. +func (t SparseTree) Parent(x *Block) *Block { + return t[x.ID].parent +} + +// IsAncestorEq reports whether x is an ancestor of or equal to y. +func (t SparseTree) IsAncestorEq(x, y *Block) bool { + if x == y { + return true + } + xx := &t[x.ID] + yy := &t[y.ID] + return xx.entry <= yy.entry && yy.exit <= xx.exit +} + +// isAncestor reports whether x is a strict ancestor of y. +func (t SparseTree) isAncestor(x, y *Block) bool { + if x == y { + return false + } + xx := &t[x.ID] + yy := &t[y.ID] + return xx.entry < yy.entry && yy.exit < xx.exit +} + +// domorder returns a value for dominator-oriented sorting. +// Block domination does not provide a total ordering, +// but domorder two has useful properties. +// 1. If domorder(x) > domorder(y) then x does not dominate y. +// 2. If domorder(x) < domorder(y) and domorder(y) < domorder(z) and x does not dominate y, +// then x does not dominate z. +// +// Property (1) means that blocks sorted by domorder always have a maximal dominant block first. +// Property (2) allows searches for dominated blocks to exit early. +func (t SparseTree) domorder(x *Block) int32 { + // Here is an argument that entry(x) provides the properties documented above. + // + // Entry and exit values are assigned in a depth-first dominator tree walk. + // For all blocks x and y, one of the following holds: + // + // (x-dom-y) x dominates y => entry(x) < entry(y) < exit(y) < exit(x) + // (y-dom-x) y dominates x => entry(y) < entry(x) < exit(x) < exit(y) + // (x-then-y) neither x nor y dominates the other and x walked before y => entry(x) < exit(x) < entry(y) < exit(y) + // (y-then-x) neither x nor y dominates the other and y walked before y => entry(y) < exit(y) < entry(x) < exit(x) + // + // entry(x) > entry(y) eliminates case x-dom-y. This provides property (1) above. + // + // For property (2), assume entry(x) < entry(y) and entry(y) < entry(z) and x does not dominate y. + // entry(x) < entry(y) allows cases x-dom-y and x-then-y. + // But by supposition, x does not dominate y. So we have x-then-y. + // + // For contradiction, assume x dominates z. + // Then entry(x) < entry(z) < exit(z) < exit(x). + // But we know x-then-y, so entry(x) < exit(x) < entry(y) < exit(y). + // Combining those, entry(x) < entry(z) < exit(z) < exit(x) < entry(y) < exit(y). + // By supposition, entry(y) < entry(z), which allows cases y-dom-z and y-then-z. + // y-dom-z requires entry(y) < entry(z), but we have entry(z) < entry(y). + // y-then-z requires exit(y) < entry(z), but we have entry(z) < exit(y). + // We have a contradiction, so x does not dominate z, as required. + return t[x.ID].entry +} diff --git a/go/src/cmd/compile/internal/ssa/stackalloc.go b/go/src/cmd/compile/internal/ssa/stackalloc.go new file mode 100644 index 0000000000000000000000000000000000000000..06097e95da0bc1dac948408408a9b0ac31745e7c --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/stackalloc.go @@ -0,0 +1,484 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// TODO: live at start of block instead? + +package ssa + +import ( + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" + "fmt" +) + +type stackAllocState struct { + f *Func + + // live is the output of stackalloc. + // live[b.id] = live values at the end of block b. + live [][]ID + + // The following slices are reused across multiple users + // of stackAllocState. + values []stackValState + interfere [][]ID // interfere[v.id] = values that interfere with v. + names []LocalSlot + + nArgSlot, // Number of Values sourced to arg slot + nNotNeed, // Number of Values not needing a stack slot + nNamedSlot, // Number of Values using a named stack slot + nReuse, // Number of values reusing a stack slot + nAuto, // Number of autos allocated for stack slots. + nSelfInterfere int32 // Number of self-interferences +} + +func newStackAllocState(f *Func) *stackAllocState { + s := f.Cache.stackAllocState + if s == nil { + return new(stackAllocState) + } + if s.f != nil { + f.fe.Fatalf(src.NoXPos, "newStackAllocState called without previous free") + } + return s +} + +func putStackAllocState(s *stackAllocState) { + clear(s.values) + clear(s.interfere) + clear(s.names) + s.f.Cache.stackAllocState = s + s.f = nil + s.live = nil + s.nArgSlot, s.nNotNeed, s.nNamedSlot, s.nReuse, s.nAuto, s.nSelfInterfere = 0, 0, 0, 0, 0, 0 +} + +type stackValState struct { + typ *types.Type + spill *Value + needSlot bool + isArg bool + defBlock ID + useBlocks []stackUseBlock +} + +// addUseBlock adds a block to the set of blocks that uses this value. +// Note that we only loosely enforce the set property by checking the last +// block that was appended to the list and duplicates may occur. +// Because we add values block by block (barring phi-nodes), the number of duplicates is +// small and we deduplicate as part of the liveness algorithm later anyway. +func (sv *stackValState) addUseBlock(b *Block, liveout bool) { + entry := stackUseBlock{ + b: b, + liveout: liveout, + } + if sv.useBlocks == nil || sv.useBlocks[len(sv.useBlocks)-1] != entry { + sv.useBlocks = append(sv.useBlocks, stackUseBlock{ + b: b, + liveout: liveout, + }) + } +} + +type stackUseBlock struct { + b *Block + liveout bool +} + +// stackalloc allocates storage in the stack frame for +// all Values that did not get a register. +// Returns a map from block ID to the stack values live at the end of that block. +func stackalloc(f *Func, spillLive [][]ID) [][]ID { + if f.pass.debug > stackDebug { + fmt.Println("before stackalloc") + fmt.Println(f.String()) + } + s := newStackAllocState(f) + s.init(f, spillLive) + defer putStackAllocState(s) + + s.stackalloc() + if f.pass.stats > 0 { + f.LogStat("stack_alloc_stats", + s.nArgSlot, "arg_slots", s.nNotNeed, "slot_not_needed", + s.nNamedSlot, "named_slots", s.nAuto, "auto_slots", + s.nReuse, "reused_slots", s.nSelfInterfere, "self_interfering") + } + + return s.live +} + +func (s *stackAllocState) init(f *Func, spillLive [][]ID) { + s.f = f + + // Initialize value information. + if n := f.NumValues(); cap(s.values) >= n { + s.values = s.values[:n] + } else { + s.values = make([]stackValState, n) + } + for _, b := range f.Blocks { + for _, v := range b.Values { + s.values[v.ID].typ = v.Type + s.values[v.ID].needSlot = !v.Type.IsMemory() && !v.Type.IsVoid() && !v.Type.IsFlags() && f.getHome(v.ID) == nil && !v.rematerializeable() && !v.OnWasmStack + s.values[v.ID].isArg = hasAnyArgOp(v) + s.values[v.ID].defBlock = b.ID + if f.pass.debug > stackDebug && s.values[v.ID].needSlot { + fmt.Printf("%s needs a stack slot\n", v) + } + if v.Op == OpStoreReg { + s.values[v.Args[0].ID].spill = v + } + } + } + + // Compute liveness info for values needing a slot. + s.computeLive(spillLive) + + // Build interference graph among values needing a slot. + s.buildInterferenceGraph() +} + +func (s *stackAllocState) stackalloc() { + f := s.f + + // Build map from values to their names, if any. + // A value may be associated with more than one name (e.g. after + // the assignment i=j). This step picks one name per value arbitrarily. + if n := f.NumValues(); cap(s.names) >= n { + s.names = s.names[:n] + } else { + s.names = make([]LocalSlot, n) + } + names := s.names + empty := LocalSlot{} + for _, name := range f.Names { + // Note: not "range f.NamedValues" above, because + // that would be nondeterministic. + for _, v := range f.NamedValues[*name] { + if v.Op == OpArgIntReg || v.Op == OpArgFloatReg { + aux := v.Aux.(*AuxNameOffset) + // Never let an arg be bound to a differently named thing. + if name.N != aux.Name || name.Off != aux.Offset { + if f.pass.debug > stackDebug { + fmt.Printf("stackalloc register arg %s skipping name %s\n", v, name) + } + continue + } + } else if name.N.Class == ir.PPARAM && v.Op != OpArg { + // PPARAM's only bind to OpArg + if f.pass.debug > stackDebug { + fmt.Printf("stackalloc PPARAM name %s skipping non-Arg %s\n", name, v) + } + continue + } + + if names[v.ID] == empty { + if f.pass.debug > stackDebug { + fmt.Printf("stackalloc value %s to name %s\n", v, *name) + } + names[v.ID] = *name + } + } + } + + // Allocate args to their assigned locations. + for _, v := range f.Entry.Values { + if !hasAnyArgOp(v) { + continue + } + if v.Aux == nil { + f.Fatalf("%s has nil Aux\n", v.LongString()) + } + if v.Op == OpArg { + loc := LocalSlot{N: v.Aux.(*ir.Name), Type: v.Type, Off: v.AuxInt} + if f.pass.debug > stackDebug { + fmt.Printf("stackalloc OpArg %s to %s\n", v, loc) + } + f.setHome(v, loc) + continue + } + // You might think this below would be the right idea, but you would be wrong. + // It almost works; as of 105a6e9518 - 2021-04-23, + // GOSSAHASH=11011011001011111 == cmd/compile/internal/noder.(*noder).embedded + // is compiled incorrectly. I believe the cause is one of those SSA-to-registers + // puzzles that the register allocator untangles; in the event that a register + // parameter does not end up bound to a name, "fixing" it is a bad idea. + // + //if f.DebugTest { + // if v.Op == OpArgIntReg || v.Op == OpArgFloatReg { + // aux := v.Aux.(*AuxNameOffset) + // loc := LocalSlot{N: aux.Name, Type: v.Type, Off: aux.Offset} + // if f.pass.debug > stackDebug { + // fmt.Printf("stackalloc Op%s %s to %s\n", v.Op, v, loc) + // } + // names[v.ID] = loc + // continue + // } + //} + + } + + // For each type, we keep track of all the stack slots we + // have allocated for that type. This map is keyed by + // strings returned by types.LinkString. This guarantees + // type equality, but also lets us match the same type represented + // by two different types.Type structures. See issue 65783. + locations := map[string][]LocalSlot{} + + // Each time we assign a stack slot to a value v, we remember + // the slot we used via an index into locations[v.Type]. + slots := f.Cache.allocIntSlice(f.NumValues()) + defer f.Cache.freeIntSlice(slots) + for i := range slots { + slots[i] = -1 + } + + // Pick a stack slot for each value needing one. + used := f.Cache.allocBoolSlice(f.NumValues()) + defer f.Cache.freeBoolSlice(used) + for _, b := range f.Blocks { + for _, v := range b.Values { + if !s.values[v.ID].needSlot { + s.nNotNeed++ + continue + } + if hasAnyArgOp(v) { + s.nArgSlot++ + continue // already picked + } + + // If this is a named value, try to use the name as + // the spill location. + var name LocalSlot + if v.Op == OpStoreReg { + name = names[v.Args[0].ID] + } else { + name = names[v.ID] + } + if name.N != nil && v.Type.Compare(name.Type) == types.CMPeq { + for _, id := range s.interfere[v.ID] { + h := f.getHome(id) + if h != nil && h.(LocalSlot).N == name.N && h.(LocalSlot).Off == name.Off { + // A variable can interfere with itself. + // It is rare, but it can happen. + s.nSelfInterfere++ + goto noname + } + } + if f.pass.debug > stackDebug { + fmt.Printf("stackalloc %s to %s\n", v, name) + } + s.nNamedSlot++ + f.setHome(v, name) + continue + } + + noname: + // Set of stack slots we could reuse. + typeKey := v.Type.LinkString() + locs := locations[typeKey] + // Mark all positions in locs used by interfering values. + for i := 0; i < len(locs); i++ { + used[i] = false + } + for _, xid := range s.interfere[v.ID] { + slot := slots[xid] + if slot >= 0 { + used[slot] = true + } + } + // Find an unused stack slot. + var i int + for i = 0; i < len(locs); i++ { + if !used[i] { + s.nReuse++ + break + } + } + // If there is no unused stack slot, allocate a new one. + if i == len(locs) { + s.nAuto++ + locs = append(locs, LocalSlot{N: f.NewLocal(v.Pos, v.Type), Type: v.Type, Off: 0}) + locations[typeKey] = locs + } + // Use the stack variable at that index for v. + loc := locs[i] + if f.pass.debug > stackDebug { + fmt.Printf("stackalloc %s to %s\n", v, loc) + } + f.setHome(v, loc) + slots[v.ID] = i + } + } +} + +// computeLive computes a map from block ID to a list of +// stack-slot-needing value IDs live at the end of that block. +func (s *stackAllocState) computeLive(spillLive [][]ID) { + + // Because values using stack slots are few and far inbetween + // (compared to the set of all values), we use a path exploration + // algorithm to calculate liveness here. + f := s.f + for _, b := range f.Blocks { + for _, spillvid := range spillLive[b.ID] { + val := &s.values[spillvid] + val.addUseBlock(b, true) + } + for _, v := range b.Values { + for i, a := range v.Args { + val := &s.values[a.ID] + useBlock := b + forceLiveout := false + if v.Op == OpPhi { + useBlock = b.Preds[i].b + forceLiveout = true + if spill := val.spill; spill != nil { + //TODO: remove? Subsumed by SpillUse? + s.values[spill.ID].addUseBlock(useBlock, true) + } + } + if !val.needSlot { + continue + } + val.addUseBlock(useBlock, forceLiveout) + } + } + } + + s.live = make([][]ID, f.NumBlocks()) + push := func(bid, vid ID) { + l := s.live[bid] + if l == nil || l[len(l)-1] != vid { + l = append(l, vid) + s.live[bid] = l + } + } + // TODO: If we can help along the interference graph by calculating livein sets, + // we can do so trivially by turning this sparse set into an array of arrays + // and checking the top for the current value instead of inclusion in the sparse set. + seen := f.newSparseSet(f.NumBlocks()) + defer f.retSparseSet(seen) + // instead of pruning out duplicate blocks when we build the useblocks slices + // or when we add them to the queue, rely on the seen set to stop considering + // them. This is slightly faster than building the workqueues as sets + // + // However, this means that the queue can grow larger than the number of blocks, + // usually in very short functions. Returning a slice with values appended beyond the + // original allocation can corrupt the allocator state, so cap the queue and return + // the originally allocated slice regardless. + allocedBqueue := f.Cache.allocBlockSlice(f.NumBlocks()) + defer f.Cache.freeBlockSlice(allocedBqueue) + bqueue := allocedBqueue[:0:f.NumBlocks()] + + for vid, v := range s.values { + if !v.needSlot { + continue + } + seen.clear() + bqueue = bqueue[:0] + for _, b := range v.useBlocks { + if b.liveout { + push(b.b.ID, ID(vid)) + } + bqueue = append(bqueue, b.b) + } + for len(bqueue) > 0 { + work := bqueue[len(bqueue)-1] + bqueue = bqueue[:len(bqueue)-1] + if seen.contains(work.ID) || work.ID == v.defBlock { + continue + } + seen.add(work.ID) + for _, e := range work.Preds { + push(e.b.ID, ID(vid)) + bqueue = append(bqueue, e.b) + } + } + } + + if s.f.pass.debug > stackDebug { + for _, b := range s.f.Blocks { + fmt.Printf("stacklive %s %v\n", b, s.live[b.ID]) + } + } +} + +func (f *Func) getHome(vid ID) Location { + if int(vid) >= len(f.RegAlloc) { + return nil + } + return f.RegAlloc[vid] +} + +func (f *Func) setHome(v *Value, loc Location) { + for v.ID >= ID(len(f.RegAlloc)) { + f.RegAlloc = append(f.RegAlloc, nil) + } + f.RegAlloc[v.ID] = loc +} + +func (s *stackAllocState) buildInterferenceGraph() { + f := s.f + if n := f.NumValues(); cap(s.interfere) >= n { + s.interfere = s.interfere[:n] + } else { + s.interfere = make([][]ID, n) + } + live := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(live) + for _, b := range f.Blocks { + // Propagate liveness backwards to the start of the block. + // Two values interfere if one is defined while the other is live. + live.clear() + live.addAll(s.live[b.ID]) + for i := len(b.Values) - 1; i >= 0; i-- { + v := b.Values[i] + if s.values[v.ID].needSlot { + live.remove(v.ID) + for _, id := range live.contents() { + // Note: args can have different types and still interfere + // (with each other or with other values). See issue 23522. + if s.values[v.ID].typ.Compare(s.values[id].typ) == types.CMPeq || hasAnyArgOp(v) || s.values[id].isArg { + s.interfere[v.ID] = append(s.interfere[v.ID], id) + s.interfere[id] = append(s.interfere[id], v.ID) + } + } + } + for _, a := range v.Args { + if s.values[a.ID].needSlot { + live.add(a.ID) + } + } + if hasAnyArgOp(v) && s.values[v.ID].needSlot { + // OpArg is an input argument which is pre-spilled. + // We add back v.ID here because we want this value + // to appear live even before this point. Being live + // all the way to the start of the entry block prevents other + // values from being allocated to the same slot and clobbering + // the input value before we have a chance to load it. + + // TODO(register args) this is apparently not wrong for register args -- is it necessary? + live.add(v.ID) + } + } + } + if f.pass.debug > stackDebug { + for vid, i := range s.interfere { + if len(i) > 0 { + fmt.Printf("v%d interferes with", vid) + for _, x := range i { + fmt.Printf(" v%d", x) + } + fmt.Println() + } + } + } +} + +func hasAnyArgOp(v *Value) bool { + return v.Op == OpArg || v.Op == OpArgIntReg || v.Op == OpArgFloatReg +} diff --git a/go/src/cmd/compile/internal/ssa/stmtlines_test.go b/go/src/cmd/compile/internal/ssa/stmtlines_test.go new file mode 100644 index 0000000000000000000000000000000000000000..02bdfca92504e0da800c1ec4bff7e6fb9d387b2b --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/stmtlines_test.go @@ -0,0 +1,166 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa_test + +import ( + cmddwarf "cmd/internal/dwarf" + "cmd/internal/quoted" + "cmp" + "debug/dwarf" + "debug/elf" + "debug/macho" + "debug/pe" + "fmt" + "internal/platform" + "internal/testenv" + "internal/xcoff" + "io" + "os" + "runtime" + "slices" + "strings" + "testing" +) + +func open(path string) (*dwarf.Data, error) { + if fh, err := elf.Open(path); err == nil { + return fh.DWARF() + } + + if fh, err := pe.Open(path); err == nil { + return fh.DWARF() + } + + if fh, err := macho.Open(path); err == nil { + return fh.DWARF() + } + + if fh, err := xcoff.Open(path); err == nil { + return fh.DWARF() + } + + return nil, fmt.Errorf("unrecognized executable format") +} + +func must(err error) { + if err != nil { + panic(err) + } +} + +type Line struct { + File string + Line int +} + +func TestStmtLines(t *testing.T) { + if !platform.ExecutableHasDWARF(runtime.GOOS, runtime.GOARCH) { + t.Skipf("skipping on %s/%s: no DWARF symbol table in executables", runtime.GOOS, runtime.GOARCH) + } + + if runtime.GOOS == "aix" { + extld := os.Getenv("CC") + if extld == "" { + extld = "gcc" + } + extldArgs, err := quoted.Split(extld) + if err != nil { + t.Fatal(err) + } + enabled, err := cmddwarf.IsDWARFEnabledOnAIXLd(extldArgs) + if err != nil { + t.Fatal(err) + } + if !enabled { + t.Skip("skipping on aix: no DWARF with ld version < 7.2.2 ") + } + } + + // Build cmd/go forcing DWARF enabled, as a large test case. + dir := t.TempDir() + out, err := testenv.Command(t, testenv.GoToolPath(t), "build", "-ldflags=-w=0", "-o", dir+"/test.exe", "cmd/go").CombinedOutput() + if err != nil { + t.Fatalf("go build: %v\n%s", err, out) + } + + lines := map[Line]bool{} + dw, err := open(dir + "/test.exe") + must(err) + rdr := dw.Reader() + rdr.Seek(0) + for { + e, err := rdr.Next() + must(err) + if e == nil { + break + } + if e.Tag != dwarf.TagCompileUnit { + continue + } + pkgname, _ := e.Val(dwarf.AttrName).(string) + if pkgname == "runtime" { + continue + } + if pkgname == "crypto/internal/fips140/nistec/fiat" { + continue // golang.org/issue/49372 + } + if e.Val(dwarf.AttrStmtList) == nil { + continue + } + lrdr, err := dw.LineReader(e) + must(err) + + var le dwarf.LineEntry + + for { + err := lrdr.Next(&le) + if err == io.EOF { + break + } + must(err) + if le.EndSequence { + // When EndSequence is true only + // le.Address is meaningful, skip. + continue + } + fl := Line{le.File.Name, le.Line} + lines[fl] = lines[fl] || le.IsStmt + } + } + + nonStmtLines := []Line{} + for line, isstmt := range lines { + if !isstmt { + nonStmtLines = append(nonStmtLines, line) + } + } + + var m float64 + switch runtime.GOARCH { + case "amd64": + m = 0.015 // > 98.5% obtained on amd64, there has been minor backsliding + case "riscv64": + m = 0.03 // XXX temporary update threshold to 97% for regabi + default: + m = 0.02 // expect 98% elsewhere. + } + + if float64(len(nonStmtLines)) > m*float64(len(lines)) { + t.Errorf("Saw too many (%s, > %.1f%%) lines without statement marks, total=%d, nostmt=%d ('-run TestStmtLines -v' lists failing lines)\n", runtime.GOARCH, m*100, len(lines), len(nonStmtLines)) + } + t.Logf("Saw %d out of %d lines without statement marks", len(nonStmtLines), len(lines)) + if testing.Verbose() { + slices.SortFunc(nonStmtLines, func(a, b Line) int { + if a.File != b.File { + return strings.Compare(a.File, b.File) + } + return cmp.Compare(a.Line, b.Line) + }) + for _, l := range nonStmtLines { + t.Logf("%s:%d has no DWARF is_stmt mark\n", l.File, l.Line) + } + } + t.Logf("total=%d, nostmt=%d\n", len(lines), len(nonStmtLines)) +} diff --git a/go/src/cmd/compile/internal/ssa/tern_helpers.go b/go/src/cmd/compile/internal/ssa/tern_helpers.go new file mode 100644 index 0000000000000000000000000000000000000000..923a9f505e5fd3845c148544e704679ee104728f --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/tern_helpers.go @@ -0,0 +1,160 @@ +// Code generated by 'tmplgen'; DO NOT EDIT. + +package ssa + +type SIMDLogicalOP uint8 + +const ( + // boolean simd operations, for reducing expression to VPTERNLOG* instructions + // sloInterior is set for non-root nodes in logical-op expression trees. + // the operations are even-numbered. + sloInterior SIMDLogicalOP = 1 + sloNone SIMDLogicalOP = 2 * iota + sloAnd + sloOr + sloAndNot + sloXor + sloNot +) + +func classifyBooleanSIMD(v *Value) SIMDLogicalOP { + switch v.Op { + case OpAndInt8x16, OpAndInt16x8, OpAndInt32x4, OpAndInt64x2, OpAndInt8x32, OpAndInt16x16, OpAndInt32x8, OpAndInt64x4, OpAndInt8x64, OpAndInt16x32, OpAndInt32x16, OpAndInt64x8: + return sloAnd + + case OpOrInt8x16, OpOrInt16x8, OpOrInt32x4, OpOrInt64x2, OpOrInt8x32, OpOrInt16x16, OpOrInt32x8, OpOrInt64x4, OpOrInt8x64, OpOrInt16x32, OpOrInt32x16, OpOrInt64x8: + return sloOr + + case OpAndNotInt8x16, OpAndNotInt16x8, OpAndNotInt32x4, OpAndNotInt64x2, OpAndNotInt8x32, OpAndNotInt16x16, OpAndNotInt32x8, OpAndNotInt64x4, OpAndNotInt8x64, OpAndNotInt16x32, OpAndNotInt32x16, OpAndNotInt64x8: + return sloAndNot + case OpXorInt8x16: + if y := v.Args[1]; y.Op == OpEqualInt8x16 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt16x8: + if y := v.Args[1]; y.Op == OpEqualInt16x8 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt32x4: + if y := v.Args[1]; y.Op == OpEqualInt32x4 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt64x2: + if y := v.Args[1]; y.Op == OpEqualInt64x2 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt8x32: + if y := v.Args[1]; y.Op == OpEqualInt8x32 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt16x16: + if y := v.Args[1]; y.Op == OpEqualInt16x16 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt32x8: + if y := v.Args[1]; y.Op == OpEqualInt32x8 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt64x4: + if y := v.Args[1]; y.Op == OpEqualInt64x4 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt8x64: + if y := v.Args[1]; y.Op == OpEqualInt8x64 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt16x32: + if y := v.Args[1]; y.Op == OpEqualInt16x32 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt32x16: + if y := v.Args[1]; y.Op == OpEqualInt32x16 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + case OpXorInt64x8: + if y := v.Args[1]; y.Op == OpEqualInt64x8 && + y.Args[0] == y.Args[1] { + return sloNot + } + return sloXor + + } + return sloNone +} + +func ternOpForLogical(op Op) Op { + switch op { + case OpAndInt8x16, OpOrInt8x16, OpXorInt8x16, OpAndNotInt8x16: + return OpternInt32x4 + case OpAndUint8x16, OpOrUint8x16, OpXorUint8x16, OpAndNotUint8x16: + return OpternUint32x4 + case OpAndInt16x8, OpOrInt16x8, OpXorInt16x8, OpAndNotInt16x8: + return OpternInt32x4 + case OpAndUint16x8, OpOrUint16x8, OpXorUint16x8, OpAndNotUint16x8: + return OpternUint32x4 + case OpAndInt32x4, OpOrInt32x4, OpXorInt32x4, OpAndNotInt32x4: + return OpternInt32x4 + case OpAndUint32x4, OpOrUint32x4, OpXorUint32x4, OpAndNotUint32x4: + return OpternUint32x4 + case OpAndInt64x2, OpOrInt64x2, OpXorInt64x2, OpAndNotInt64x2: + return OpternInt64x2 + case OpAndUint64x2, OpOrUint64x2, OpXorUint64x2, OpAndNotUint64x2: + return OpternUint64x2 + case OpAndInt8x32, OpOrInt8x32, OpXorInt8x32, OpAndNotInt8x32: + return OpternInt32x8 + case OpAndUint8x32, OpOrUint8x32, OpXorUint8x32, OpAndNotUint8x32: + return OpternUint32x8 + case OpAndInt16x16, OpOrInt16x16, OpXorInt16x16, OpAndNotInt16x16: + return OpternInt32x8 + case OpAndUint16x16, OpOrUint16x16, OpXorUint16x16, OpAndNotUint16x16: + return OpternUint32x8 + case OpAndInt32x8, OpOrInt32x8, OpXorInt32x8, OpAndNotInt32x8: + return OpternInt32x8 + case OpAndUint32x8, OpOrUint32x8, OpXorUint32x8, OpAndNotUint32x8: + return OpternUint32x8 + case OpAndInt64x4, OpOrInt64x4, OpXorInt64x4, OpAndNotInt64x4: + return OpternInt64x4 + case OpAndUint64x4, OpOrUint64x4, OpXorUint64x4, OpAndNotUint64x4: + return OpternUint64x4 + case OpAndInt8x64, OpOrInt8x64, OpXorInt8x64, OpAndNotInt8x64: + return OpternInt32x16 + case OpAndUint8x64, OpOrUint8x64, OpXorUint8x64, OpAndNotUint8x64: + return OpternUint32x16 + case OpAndInt16x32, OpOrInt16x32, OpXorInt16x32, OpAndNotInt16x32: + return OpternInt32x16 + case OpAndUint16x32, OpOrUint16x32, OpXorUint16x32, OpAndNotUint16x32: + return OpternUint32x16 + case OpAndInt32x16, OpOrInt32x16, OpXorInt32x16, OpAndNotInt32x16: + return OpternInt32x16 + case OpAndUint32x16, OpOrUint32x16, OpXorUint32x16, OpAndNotUint32x16: + return OpternUint32x16 + case OpAndInt64x8, OpOrInt64x8, OpXorInt64x8, OpAndNotInt64x8: + return OpternInt64x8 + case OpAndUint64x8, OpOrUint64x8, OpXorUint64x8, OpAndNotUint64x8: + return OpternUint64x8 + + } + return op +} diff --git a/go/src/cmd/compile/internal/ssa/tighten.go b/go/src/cmd/compile/internal/ssa/tighten.go new file mode 100644 index 0000000000000000000000000000000000000000..b1f787e03b7aea8a38a8507ad03f0890e0ec70c8 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/tighten.go @@ -0,0 +1,277 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import "cmd/compile/internal/base" + +// tighten moves Values closer to the Blocks in which they are used. +// This can reduce the amount of register spilling required, +// if it doesn't also create more live values. +// A Value can be moved to any block that +// dominates all blocks in which it is used. +func tighten(f *Func) { + if base.Flag.N != 0 && len(f.Blocks) < 10000 { + // Skip the optimization in -N mode, except for huge functions. + // Too many values live across blocks can cause pathological + // behavior in the register allocator (see issue 52180). + return + } + + canMove := f.Cache.allocBoolSlice(f.NumValues()) + defer f.Cache.freeBoolSlice(canMove) + + // Compute the memory states of each block. + startMem := f.Cache.allocValueSlice(f.NumBlocks()) + defer f.Cache.freeValueSlice(startMem) + endMem := f.Cache.allocValueSlice(f.NumBlocks()) + defer f.Cache.freeValueSlice(endMem) + distinctArgs := f.newSparseSet(f.NumValues()) + defer f.retSparseSet(distinctArgs) + memState(f, startMem, endMem) + + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op.isLoweredGetClosurePtr() { + // Must stay in the entry block. + continue + } + switch v.Op { + case OpPhi, OpArg, OpArgIntReg, OpArgFloatReg, OpSelect0, OpSelect1, OpSelectN: + // Phis need to stay in their block. + // Arg must stay in the entry block. + // Tuple selectors must stay with the tuple generator. + // SelectN is typically, ultimately, a register. + continue + } + if opcodeTable[v.Op].nilCheck { + // Nil checks need to stay in their block. See issue 72860. + continue + } + // Count distinct arguments which will need a register. + distinctArgs.clear() + + for _, a := range v.Args { + // SP and SB are special registers and have no effect on + // the allocation of general-purpose registers. + if a.needRegister() && a.Op != OpSB && a.Op != OpSP { + distinctArgs.add(a.ID) + } + } + + if distinctArgs.size() >= 2 && !v.Type.IsFlags() { + // Don't move values with more than one input, as that may + // increase register pressure. + // We make an exception for flags, as we want flag generators + // moved next to uses (because we only have 1 flag register). + continue + } + canMove[v.ID] = true + } + } + + // Build data structure for fast least-common-ancestor queries. + lca := makeLCArange(f) + + // For each moveable value, record the block that dominates all uses found so far. + target := f.Cache.allocBlockSlice(f.NumValues()) + defer f.Cache.freeBlockSlice(target) + + // Grab loop information. + // We use this to make sure we don't tighten a value into a (deeper) loop. + idom := f.Idom() + loops := f.loopnest() + + changed := true + for changed { + changed = false + + // Reset target + clear(target) + + // Compute target locations (for moveable values only). + // target location = the least common ancestor of all uses in the dominator tree. + for _, b := range f.Blocks { + for _, v := range b.Values { + for i, a := range v.Args { + if !canMove[a.ID] { + continue + } + use := b + if v.Op == OpPhi { + use = b.Preds[i].b + } + if target[a.ID] == nil { + target[a.ID] = use + } else { + target[a.ID] = lca.find(target[a.ID], use) + } + } + } + for _, c := range b.ControlValues() { + if !canMove[c.ID] { + continue + } + if target[c.ID] == nil { + target[c.ID] = b + } else { + target[c.ID] = lca.find(target[c.ID], b) + } + } + } + + // If the target location is inside a loop, + // move the target location up to just before the loop head. + if !loops.hasIrreducible { + // Loop info might not be correct for irreducible loops. See issue 75569. + for _, b := range f.Blocks { + origloop := loops.b2l[b.ID] + for _, v := range b.Values { + t := target[v.ID] + if t == nil { + continue + } + targetloop := loops.b2l[t.ID] + for targetloop != nil && (origloop == nil || targetloop.depth > origloop.depth) { + t = idom[targetloop.header.ID] + target[v.ID] = t + targetloop = loops.b2l[t.ID] + } + } + } + } + + // Move values to target locations. + for _, b := range f.Blocks { + for i := 0; i < len(b.Values); i++ { + v := b.Values[i] + t := target[v.ID] + if t == nil || t == b { + // v is not moveable, or is already in correct place. + continue + } + if mem := v.MemoryArg(); mem != nil { + if startMem[t.ID] != mem { + // We can't move a value with a memory arg unless the target block + // has that memory arg as its starting memory. + continue + } + } + if f.pass.debug > 0 { + b.Func.Warnl(v.Pos, "%v is moved", v.Op) + } + // Move v to the block which dominates its uses. + t.Values = append(t.Values, v) + v.Block = t + last := len(b.Values) - 1 + b.Values[i] = b.Values[last] + b.Values[last] = nil + b.Values = b.Values[:last] + changed = true + i-- + } + } + } +} + +// phiTighten moves constants closer to phi users. +// This pass avoids having lots of constants live for lots of the program. +// See issue 16407. +func phiTighten(f *Func) { + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op != OpPhi { + continue + } + for i, a := range v.Args { + if !a.rematerializeable() { + continue // not a constant we can move around + } + if a.Block == b.Preds[i].b { + continue // already in the right place + } + // Make a copy of a, put in predecessor block. + v.SetArg(i, a.copyInto(b.Preds[i].b)) + } + } + } +} + +// memState computes the memory state at the beginning and end of each block of +// the function. The memory state is represented by a value of mem type. +// The returned result is stored in startMem and endMem, and endMem is nil for +// blocks with no successors (Exit,Ret,RetJmp blocks). This algorithm is not +// suitable for infinite loop blocks that do not contain any mem operations. +// For example: +// b1: +// +// (some values) +// +// plain -> b2 +// b2: <- b1 b2 +// Plain -> b2 +// +// Algorithm introduction: +// 1. The start memory state of a block is InitMem, a Phi node of type mem or +// an incoming memory value. +// 2. The start memory state of a block is consistent with the end memory state +// of its parent nodes. If the start memory state of a block is a Phi value, +// then the end memory state of its parent nodes is consistent with the +// corresponding argument value of the Phi node. +// 3. The algorithm first obtains the memory state of some blocks in the tree +// in the first step. Then floods the known memory state to other nodes in +// the second step. +func memState(f *Func, startMem, endMem []*Value) { + // This slice contains the set of blocks that have had their startMem set but this + // startMem value has not yet been propagated to the endMem of its predecessors + changed := make([]*Block, 0) + // First step, init the memory state of some blocks. + for _, b := range f.Blocks { + for _, v := range b.Values { + var mem *Value + if v.Op == OpPhi { + if v.Type.IsMemory() { + mem = v + } + } else if v.Op == OpInitMem { + mem = v // This is actually not needed. + } else if a := v.MemoryArg(); a != nil && a.Block != b { + // The only incoming memory value doesn't belong to this block. + mem = a + } + if mem != nil { + if old := startMem[b.ID]; old != nil { + if old == mem { + continue + } + f.Fatalf("func %s, startMem[%v] has different values, old %v, new %v", f.Name, b, old, mem) + } + startMem[b.ID] = mem + changed = append(changed, b) + } + } + } + + // Second step, floods the known memory state of some blocks to others. + for len(changed) != 0 { + top := changed[0] + changed = changed[1:] + mem := startMem[top.ID] + for i, p := range top.Preds { + pb := p.b + if endMem[pb.ID] != nil { + continue + } + if mem.Op == OpPhi && mem.Block == top { + endMem[pb.ID] = mem.Args[i] + } else { + endMem[pb.ID] = mem + } + if startMem[pb.ID] == nil { + startMem[pb.ID] = endMem[pb.ID] + changed = append(changed, pb) + } + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/trim.go b/go/src/cmd/compile/internal/ssa/trim.go new file mode 100644 index 0000000000000000000000000000000000000000..a607a57a76e88aa90e795855f69c7d900e18da51 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/trim.go @@ -0,0 +1,169 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import "cmd/internal/src" + +// trim removes blocks with no code in them. +// These blocks were inserted to remove critical edges. +func trim(f *Func) { + n := 0 + for _, b := range f.Blocks { + if !trimmableBlock(b) { + f.Blocks[n] = b + n++ + continue + } + + bPos := b.Pos + bIsStmt := bPos.IsStmt() == src.PosIsStmt + + // Splice b out of the graph. NOTE: `mergePhi` depends on the + // order, in which the predecessors edges are merged here. + p, i := b.Preds[0].b, b.Preds[0].i + s, j := b.Succs[0].b, b.Succs[0].i + ns := len(s.Preds) + p.Succs[i] = Edge{s, j} + s.Preds[j] = Edge{p, i} + + for _, e := range b.Preds[1:] { + p, i := e.b, e.i + p.Succs[i] = Edge{s, len(s.Preds)} + s.Preds = append(s.Preds, Edge{p, i}) + } + + // Attempt to preserve a statement boundary + if bIsStmt { + sawStmt := false + for _, v := range s.Values { + if isPoorStatementOp(v.Op) { + continue + } + if v.Pos.SameFileAndLine(bPos) { + v.Pos = v.Pos.WithIsStmt() + } + sawStmt = true + break + } + if !sawStmt && s.Pos.SameFileAndLine(bPos) { + s.Pos = s.Pos.WithIsStmt() + } + } + // If `s` had more than one predecessor, update its phi-ops to + // account for the merge. + if ns > 1 { + for _, v := range s.Values { + if v.Op == OpPhi { + mergePhi(v, j, b) + } + + } + // Remove the phi-ops from `b` if they were merged into the + // phi-ops of `s`. + k := 0 + for _, v := range b.Values { + if v.Op == OpPhi { + if v.Uses == 0 { + v.resetArgs() + continue + } + // Pad the arguments of the remaining phi-ops so + // they match the new predecessor count of `s`. + // Since s did not have a Phi op corresponding to + // the phi op in b, the other edges coming into s + // must be loopback edges from s, so v is the right + // argument to v! + args := make([]*Value, len(v.Args)) + copy(args, v.Args) + v.resetArgs() + for x := 0; x < j; x++ { + v.AddArg(v) + } + v.AddArg(args[0]) + for x := j + 1; x < ns; x++ { + v.AddArg(v) + } + for _, a := range args[1:] { + v.AddArg(a) + } + } + b.Values[k] = v + k++ + } + b.Values = b.Values[:k] + } + + // Merge the blocks' values. + for _, v := range b.Values { + v.Block = s + } + k := len(b.Values) + m := len(s.Values) + for i := 0; i < k; i++ { + s.Values = append(s.Values, nil) + } + copy(s.Values[k:], s.Values[:m]) + copy(s.Values, b.Values) + } + if n < len(f.Blocks) { + f.invalidateCFG() + clear(f.Blocks[n:]) + f.Blocks = f.Blocks[:n] + } +} + +// emptyBlock reports whether the block does not contain actual +// instructions. +func emptyBlock(b *Block) bool { + for _, v := range b.Values { + if v.Op != OpPhi { + return false + } + } + return true +} + +// trimmableBlock reports whether the block can be trimmed from the CFG, +// subject to the following criteria: +// - it should not be the first block. +// - it should be BlockPlain. +// - it should not loop back to itself. +// - it either is the single predecessor of the successor block or +// contains no actual instructions. +func trimmableBlock(b *Block) bool { + if b.Kind != BlockPlain || b == b.Func.Entry { + return false + } + s := b.Succs[0].b + return s != b && (len(s.Preds) == 1 || emptyBlock(b)) +} + +// mergePhi adjusts the number of `v`s arguments to account for merge +// of `b`, which was `i`th predecessor of the `v`s block. +func mergePhi(v *Value, i int, b *Block) { + u := v.Args[i] + if u.Block == b { + if u.Op != OpPhi { + b.Func.Fatalf("value %s is not a phi operation", u.LongString()) + } + // If the original block contained u = φ(u0, u1, ..., un) and + // the current phi is + // v = φ(v0, v1, ..., u, ..., vk) + // then the merged phi is + // v = φ(v0, v1, ..., u0, ..., vk, u1, ..., un) + v.SetArg(i, u.Args[0]) + v.AddArgs(u.Args[1:]...) + } else { + // If the original block contained u = φ(u0, u1, ..., un) and + // the current phi is + // v = φ(v0, v1, ..., vi, ..., vk) + // i.e. it does not use a value from the predecessor block, + // then the merged phi is + // v = φ(v0, v1, ..., vk, vi, vi, ...) + for j := 1; j < len(b.Preds); j++ { + v.AddArg(v.Args[i]) + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/tuple.go b/go/src/cmd/compile/internal/ssa/tuple.go new file mode 100644 index 0000000000000000000000000000000000000000..289df40431a7a7b4ce2cb3083d7e24332d45af07 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/tuple.go @@ -0,0 +1,71 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +// tightenTupleSelectors ensures that tuple selectors (Select0, Select1, +// and SelectN ops) are in the same block as their tuple generator. The +// function also ensures that there are no duplicate tuple selectors. +// These properties are expected by the scheduler but may not have +// been maintained by the optimization pipeline up to this point. +// +// See issues 16741 and 39472. +func tightenTupleSelectors(f *Func) { + selectors := make(map[struct { + id ID + which int + }]*Value) + for _, b := range f.Blocks { + for _, selector := range b.Values { + // Key fields for de-duplication + var tuple *Value + idx := 0 + switch selector.Op { + default: + continue + case OpSelect1: + idx = 1 + fallthrough + case OpSelect0: + tuple = selector.Args[0] + if !tuple.Type.IsTuple() { + f.Fatalf("arg of tuple selector %s is not a tuple: %s", selector.String(), tuple.LongString()) + } + case OpSelectN: + tuple = selector.Args[0] + idx = int(selector.AuxInt) + if !tuple.Type.IsResults() { + f.Fatalf("arg of result selector %s is not a results: %s", selector.String(), tuple.LongString()) + } + } + + // If there is a pre-existing selector in the target block then + // use that. Do this even if the selector is already in the + // target block to avoid duplicate tuple selectors. + key := struct { + id ID + which int + }{tuple.ID, idx} + if t := selectors[key]; t != nil { + if selector != t { + selector.copyOf(t) + } + continue + } + + // If the selector is in the wrong block copy it into the target + // block. + if selector.Block != tuple.Block { + t := selector.copyInto(tuple.Block) + selector.copyOf(t) + selectors[key] = t + continue + } + + // The selector is in the target block. Add it to the map so it + // cannot be duplicated. + selectors[key] = selector + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/value.go b/go/src/cmd/compile/internal/ssa/value.go new file mode 100644 index 0000000000000000000000000000000000000000..95710d9024bfeb5689a05a350e40c9e19b5fc465 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/value.go @@ -0,0 +1,667 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" + "fmt" + "internal/buildcfg" + "math" + "sort" + "strings" +) + +// A Value represents a value in the SSA representation of the program. +// The ID and Type fields must not be modified. The remainder may be modified +// if they preserve the value of the Value (e.g. changing a (mul 2 x) to an (add x x)). +type Value struct { + // A unique identifier for the value. For performance we allocate these IDs + // densely starting at 1. There is no guarantee that there won't be occasional holes, though. + ID ID + + // The operation that computes this value. See op.go. + Op Op + + // The type of this value. Normally this will be a Go type, but there + // are a few other pseudo-types, see ../types/type.go. + Type *types.Type + + // Auxiliary info for this value. The type of this information depends on the opcode and type. + // AuxInt is used for integer values, Aux is used for other values. + // Floats are stored in AuxInt using math.Float64bits(f). + // Unused portions of AuxInt are filled by sign-extending the used portion, + // even if the represented value is unsigned. + // Users of AuxInt which interpret AuxInt as unsigned (e.g. shifts) must be careful. + // Use Value.AuxUnsigned to get the zero-extended value of AuxInt. + AuxInt int64 + Aux Aux + + // Arguments of this value + Args []*Value + + // Containing basic block + Block *Block + + // Source position + Pos src.XPos + + // Use count. Each appearance in Value.Args and Block.Controls counts once. + Uses int32 + + // wasm: Value stays on the WebAssembly stack. This value will not get a "register" (WebAssembly variable) + // nor a slot on Go stack, and the generation of this value is delayed to its use time. + OnWasmStack bool + + // Is this value in the per-function constant cache? If so, remove from cache before changing it or recycling it. + InCache bool + + // Storage for the first three args + argstorage [3]*Value +} + +// Examples: +// Opcode aux args +// OpAdd nil 2 +// OpConst string 0 string constant +// OpConst int64 0 int64 constant +// OpAddcq int64 1 amd64 op: v = arg[0] + constant + +// short form print. Just v#. +func (v *Value) String() string { + if v == nil { + return "nil" // should never happen, but not panicking helps with debugging + } + return fmt.Sprintf("v%d", v.ID) +} + +func (v *Value) AuxInt8() int8 { + if opcodeTable[v.Op].auxType != auxInt8 && opcodeTable[v.Op].auxType != auxNameOffsetInt8 { + v.Fatalf("op %s doesn't have an int8 aux field", v.Op) + } + return int8(v.AuxInt) +} + +func (v *Value) AuxUInt8() uint8 { + if opcodeTable[v.Op].auxType != auxUInt8 { + v.Fatalf("op %s doesn't have a uint8 aux field", v.Op) + } + return uint8(v.AuxInt) +} + +func (v *Value) AuxInt16() int16 { + if opcodeTable[v.Op].auxType != auxInt16 { + v.Fatalf("op %s doesn't have an int16 aux field", v.Op) + } + return int16(v.AuxInt) +} + +func (v *Value) AuxInt32() int32 { + if opcodeTable[v.Op].auxType != auxInt32 { + v.Fatalf("op %s doesn't have an int32 aux field", v.Op) + } + return int32(v.AuxInt) +} + +// AuxUnsigned returns v.AuxInt as an unsigned value for OpConst*. +// v.AuxInt is always sign-extended to 64 bits, even if the +// represented value is unsigned. This undoes that sign extension. +func (v *Value) AuxUnsigned() uint64 { + c := v.AuxInt + switch v.Op { + case OpConst64: + return uint64(c) + case OpConst32: + return uint64(uint32(c)) + case OpConst16: + return uint64(uint16(c)) + case OpConst8: + return uint64(uint8(c)) + } + v.Fatalf("op %s isn't OpConst*", v.Op) + return 0 +} + +func (v *Value) AuxFloat() float64 { + if opcodeTable[v.Op].auxType != auxFloat32 && opcodeTable[v.Op].auxType != auxFloat64 { + v.Fatalf("op %s doesn't have a float aux field", v.Op) + } + return math.Float64frombits(uint64(v.AuxInt)) +} +func (v *Value) AuxValAndOff() ValAndOff { + if opcodeTable[v.Op].auxType != auxSymValAndOff { + v.Fatalf("op %s doesn't have a ValAndOff aux field", v.Op) + } + return ValAndOff(v.AuxInt) +} + +func (v *Value) AuxArm64BitField() arm64BitField { + if opcodeTable[v.Op].auxType != auxARM64BitField { + v.Fatalf("op %s doesn't have a ARM64BitField aux field", v.Op) + } + return arm64BitField(v.AuxInt) +} + +func (v *Value) AuxArm64ConditionalParams() arm64ConditionalParams { + if opcodeTable[v.Op].auxType != auxARM64ConditionalParams { + v.Fatalf("op %s doesn't have a ARM64ConditionalParams aux field", v.Op) + } + return auxIntToArm64ConditionalParams(v.AuxInt) +} + +// long form print. v# = opcode [aux] args [: reg] (names) +func (v *Value) LongString() string { + if v == nil { + return "" + } + s := fmt.Sprintf("v%d = %s", v.ID, v.Op) + s += " <" + v.Type.String() + ">" + s += v.auxString() + for _, a := range v.Args { + s += fmt.Sprintf(" %v", a) + } + if v.Block == nil { + return s + } + r := v.Block.Func.RegAlloc + if int(v.ID) < len(r) && r[v.ID] != nil { + s += " : " + r[v.ID].String() + } + if reg := v.Block.Func.tempRegs[v.ID]; reg != nil { + s += " tmp=" + reg.String() + } + var names []string + for name, values := range v.Block.Func.NamedValues { + for _, value := range values { + if value == v { + names = append(names, name.String()) + break // drop duplicates. + } + } + } + if len(names) != 0 { + sort.Strings(names) // Otherwise a source of variation in debugging output. + s += " (" + strings.Join(names, ", ") + ")" + } + return s +} + +func (v *Value) auxString() string { + switch opcodeTable[v.Op].auxType { + case auxBool: + if v.AuxInt == 0 { + return " [false]" + } else { + return " [true]" + } + case auxInt8: + return fmt.Sprintf(" [%d]", v.AuxInt8()) + case auxInt16: + return fmt.Sprintf(" [%d]", v.AuxInt16()) + case auxInt32: + return fmt.Sprintf(" [%d]", v.AuxInt32()) + case auxInt64, auxInt128: + return fmt.Sprintf(" [%d]", v.AuxInt) + case auxUInt8: + return fmt.Sprintf(" [%d]", v.AuxUInt8()) + case auxARM64BitField: + lsb := v.AuxArm64BitField().lsb() + width := v.AuxArm64BitField().width() + return fmt.Sprintf(" [lsb=%d,width=%d]", lsb, width) + case auxARM64ConditionalParams: + params := v.AuxArm64ConditionalParams() + cond := params.Cond() + nzcv := params.Nzcv() + imm, ok := params.ConstValue() + if ok { + return fmt.Sprintf(" [cond=%s,nzcv=%d,imm=%d]", cond, nzcv, imm) + } + return fmt.Sprintf(" [cond=%s,nzcv=%d]", cond, nzcv) + case auxFloat32, auxFloat64: + return fmt.Sprintf(" [%g]", v.AuxFloat()) + case auxString: + return fmt.Sprintf(" {%q}", v.Aux) + case auxSym, auxCall, auxTyp: + if v.Aux != nil { + return fmt.Sprintf(" {%v}", v.Aux) + } + return "" + case auxSymOff, auxCallOff, auxTypSize, auxNameOffsetInt8: + s := "" + if v.Aux != nil { + s = fmt.Sprintf(" {%v}", v.Aux) + } + if v.AuxInt != 0 || opcodeTable[v.Op].auxType == auxNameOffsetInt8 { + s += fmt.Sprintf(" [%v]", v.AuxInt) + } + return s + case auxSymValAndOff: + s := "" + if v.Aux != nil { + s = fmt.Sprintf(" {%v}", v.Aux) + } + return s + fmt.Sprintf(" [%s]", v.AuxValAndOff()) + case auxCCop: + return fmt.Sprintf(" [%s]", Op(v.AuxInt)) + case auxS390XCCMask, auxS390XRotateParams: + return fmt.Sprintf(" {%v}", v.Aux) + case auxFlagConstant: + return fmt.Sprintf("[%s]", flagConstant(v.AuxInt)) + case auxNone: + return "" + default: + // If you see this, add a case above instead. + return fmt.Sprintf("[auxtype=%d AuxInt=%d Aux=%v]", opcodeTable[v.Op].auxType, v.AuxInt, v.Aux) + } +} + +// If/when midstack inlining is enabled (-l=4), the compiler gets both larger and slower. +// Not-inlining this method is a help (*Value.reset and *Block.NewValue0 are similar). +// +//go:noinline +func (v *Value) AddArg(w *Value) { + if v.Args == nil { + v.resetArgs() // use argstorage + } + v.Args = append(v.Args, w) + w.Uses++ +} + +//go:noinline +func (v *Value) AddArg2(w1, w2 *Value) { + if v.Args == nil { + v.resetArgs() // use argstorage + } + v.Args = append(v.Args, w1, w2) + w1.Uses++ + w2.Uses++ +} + +//go:noinline +func (v *Value) AddArg3(w1, w2, w3 *Value) { + if v.Args == nil { + v.resetArgs() // use argstorage + } + v.Args = append(v.Args, w1, w2, w3) + w1.Uses++ + w2.Uses++ + w3.Uses++ +} + +//go:noinline +func (v *Value) AddArg4(w1, w2, w3, w4 *Value) { + v.Args = append(v.Args, w1, w2, w3, w4) + w1.Uses++ + w2.Uses++ + w3.Uses++ + w4.Uses++ +} + +//go:noinline +func (v *Value) AddArg5(w1, w2, w3, w4, w5 *Value) { + v.Args = append(v.Args, w1, w2, w3, w4, w5) + w1.Uses++ + w2.Uses++ + w3.Uses++ + w4.Uses++ + w5.Uses++ +} + +//go:noinline +func (v *Value) AddArg6(w1, w2, w3, w4, w5, w6 *Value) { + v.Args = append(v.Args, w1, w2, w3, w4, w5, w6) + w1.Uses++ + w2.Uses++ + w3.Uses++ + w4.Uses++ + w5.Uses++ + w6.Uses++ +} + +func (v *Value) AddArgs(a ...*Value) { + if v.Args == nil { + v.resetArgs() // use argstorage + } + v.Args = append(v.Args, a...) + for _, x := range a { + x.Uses++ + } +} +func (v *Value) SetArg(i int, w *Value) { + v.Args[i].Uses-- + v.Args[i] = w + w.Uses++ +} +func (v *Value) SetArgs1(a *Value) { + v.resetArgs() + v.AddArg(a) +} +func (v *Value) SetArgs2(a, b *Value) { + v.resetArgs() + v.AddArg(a) + v.AddArg(b) +} +func (v *Value) SetArgs3(a, b, c *Value) { + v.resetArgs() + v.AddArg(a) + v.AddArg(b) + v.AddArg(c) +} +func (v *Value) SetArgs4(a, b, c, d *Value) { + v.resetArgs() + v.AddArg(a) + v.AddArg(b) + v.AddArg(c) + v.AddArg(d) +} + +func (v *Value) resetArgs() { + for _, a := range v.Args { + a.Uses-- + } + v.argstorage[0] = nil + v.argstorage[1] = nil + v.argstorage[2] = nil + v.Args = v.argstorage[:0] +} + +// reset is called from most rewrite rules. +// Allowing it to be inlined increases the size +// of cmd/compile by almost 10%, and slows it down. +// +//go:noinline +func (v *Value) reset(op Op) { + if v.InCache { + v.Block.Func.unCache(v) + } + v.Op = op + v.resetArgs() + v.AuxInt = 0 + v.Aux = nil +} + +// invalidateRecursively marks a value as invalid (unused) +// and after decrementing reference counts on its Args, +// also recursively invalidates any of those whose use +// count goes to zero. It returns whether any of the +// invalidated values was marked with IsStmt. +// +// BEWARE of doing this *before* you've applied intended +// updates to SSA. +func (v *Value) invalidateRecursively() bool { + lostStmt := v.Pos.IsStmt() == src.PosIsStmt + if v.InCache { + v.Block.Func.unCache(v) + } + v.Op = OpInvalid + + for _, a := range v.Args { + a.Uses-- + if a.Uses == 0 { + lost := a.invalidateRecursively() + lostStmt = lost || lostStmt + } + } + + v.argstorage[0] = nil + v.argstorage[1] = nil + v.argstorage[2] = nil + v.Args = v.argstorage[:0] + + v.AuxInt = 0 + v.Aux = nil + return lostStmt +} + +// copyOf is called from rewrite rules. +// It modifies v to be (Copy a). +// +//go:noinline +func (v *Value) copyOf(a *Value) { + if v == a { + return + } + if v.InCache { + v.Block.Func.unCache(v) + } + v.Op = OpCopy + v.resetArgs() + v.AddArg(a) + v.AuxInt = 0 + v.Aux = nil + v.Type = a.Type +} + +// copyInto makes a new value identical to v and adds it to the end of b. +// unlike copyIntoWithXPos this does not check for v.Pos being a statement. +func (v *Value) copyInto(b *Block) *Value { + c := b.NewValue0(v.Pos.WithNotStmt(), v.Op, v.Type) // Lose the position, this causes line number churn otherwise. + c.Aux = v.Aux + c.AuxInt = v.AuxInt + c.AddArgs(v.Args...) + for _, a := range v.Args { + if a.Type.IsMemory() { + v.Fatalf("can't move a value with a memory arg %s", v.LongString()) + } + } + return c +} + +// copyIntoWithXPos makes a new value identical to v and adds it to the end of b. +// The supplied position is used as the position of the new value. +// Because this is used for rematerialization, check for case that (rematerialized) +// input to value with position 'pos' carried a statement mark, and that the supplied +// position (of the instruction using the rematerialized value) is not marked, and +// preserve that mark if its line matches the supplied position. +func (v *Value) copyIntoWithXPos(b *Block, pos src.XPos) *Value { + if v.Pos.IsStmt() == src.PosIsStmt && pos.IsStmt() != src.PosIsStmt && v.Pos.SameFileAndLine(pos) { + pos = pos.WithIsStmt() + } + c := b.NewValue0(pos, v.Op, v.Type) + c.Aux = v.Aux + c.AuxInt = v.AuxInt + c.AddArgs(v.Args...) + for _, a := range v.Args { + if a.Type.IsMemory() { + v.Fatalf("can't move a value with a memory arg %s", v.LongString()) + } + } + return c +} + +func (v *Value) Logf(msg string, args ...any) { v.Block.Logf(msg, args...) } +func (v *Value) Log() bool { return v.Block.Log() } +func (v *Value) Fatalf(msg string, args ...any) { + v.Block.Func.fe.Fatalf(v.Pos, msg, args...) +} + +// isGenericIntConst reports whether v is a generic integer constant. +func (v *Value) isGenericIntConst() bool { + return v != nil && (v.Op == OpConst64 || v.Op == OpConst32 || v.Op == OpConst16 || v.Op == OpConst8) +} + +// ResultReg returns the result register assigned to v, in cmd/internal/obj/$ARCH numbering. +// It is similar to Reg and Reg0, except that it is usable interchangeably for all Value Ops. +// If you know v.Op, using Reg or Reg0 (as appropriate) will be more efficient. +func (v *Value) ResultReg() int16 { + reg := v.Block.Func.RegAlloc[v.ID] + if reg == nil { + v.Fatalf("nil reg for value: %s\n%s\n", v.LongString(), v.Block.Func) + } + if pair, ok := reg.(LocPair); ok { + reg = pair[0] + } + if reg == nil { + v.Fatalf("nil reg0 for value: %s\n%s\n", v.LongString(), v.Block.Func) + } + return reg.(*Register).objNum +} + +// Reg returns the register assigned to v, in cmd/internal/obj/$ARCH numbering. +func (v *Value) Reg() int16 { + reg := v.Block.Func.RegAlloc[v.ID] + if reg == nil { + v.Fatalf("nil register for value: %s\n%s\n", v.LongString(), v.Block.Func) + } + return reg.(*Register).objNum +} + +// Reg0 returns the register assigned to the first output of v, in cmd/internal/obj/$ARCH numbering. +func (v *Value) Reg0() int16 { + reg := v.Block.Func.RegAlloc[v.ID].(LocPair)[0] + if reg == nil { + v.Fatalf("nil first register for value: %s\n%s\n", v.LongString(), v.Block.Func) + } + return reg.(*Register).objNum +} + +// Reg1 returns the register assigned to the second output of v, in cmd/internal/obj/$ARCH numbering. +func (v *Value) Reg1() int16 { + reg := v.Block.Func.RegAlloc[v.ID].(LocPair)[1] + if reg == nil { + v.Fatalf("nil second register for value: %s\n%s\n", v.LongString(), v.Block.Func) + } + return reg.(*Register).objNum +} + +// RegTmp returns the temporary register assigned to v, in cmd/internal/obj/$ARCH numbering. +func (v *Value) RegTmp() int16 { + reg := v.Block.Func.tempRegs[v.ID] + if reg == nil { + v.Fatalf("nil tmp register for value: %s\n%s\n", v.LongString(), v.Block.Func) + } + return reg.objNum +} + +func (v *Value) RegName() string { + reg := v.Block.Func.RegAlloc[v.ID] + if reg == nil { + v.Fatalf("nil register for value: %s\n%s\n", v.LongString(), v.Block.Func) + } + return reg.(*Register).name +} + +// MemoryArg returns the memory argument for the Value. +// The returned value, if non-nil, will be memory-typed (or a tuple with a memory-typed second part). +// Otherwise, nil is returned. +func (v *Value) MemoryArg() *Value { + if v.Op == OpPhi { + v.Fatalf("MemoryArg on Phi") + } + na := len(v.Args) + if na == 0 { + return nil + } + if m := v.Args[na-1]; m.Type.IsMemory() { + return m + } + return nil +} + +// LackingPos indicates whether v is a value that is unlikely to have a correct +// position assigned to it. Ignoring such values leads to more user-friendly positions +// assigned to nearby values and the blocks containing them. +func (v *Value) LackingPos() bool { + // The exact definition of LackingPos is somewhat heuristically defined and may change + // in the future, for example if some of these operations are generated more carefully + // with respect to their source position. + return v.Op == OpVarDef || v.Op == OpVarLive || v.Op == OpPhi || + (v.Op == OpFwdRef || v.Op == OpCopy) && v.Type == types.TypeMem +} + +// removeable reports whether the value v can be removed from the SSA graph entirely +// if its use count drops to 0. +func (v *Value) removeable() bool { + if v.Type.IsVoid() { + // Void ops (inline marks), must stay. + return false + } + if opcodeTable[v.Op].nilCheck { + // Nil pointer checks must stay. + return false + } + if v.Type.IsMemory() { + // We don't need to preserve all memory ops, but we do need + // to keep calls at least (because they might have + // synchronization operations we can't see). + return false + } + if v.Op.HasSideEffects() { + // These are mostly synchronization operations. + return false + } + return true +} + +// AutoVar returns a *Name and int64 representing the auto variable and offset within it +// where v should be spilled. +func AutoVar(v *Value) (*ir.Name, int64) { + if loc, ok := v.Block.Func.RegAlloc[v.ID].(LocalSlot); ok { + if v.Type.Size() > loc.Type.Size() { + v.Fatalf("v%d: spill/restore type %v doesn't fit in slot type %v", v.ID, v.Type, loc.Type) + } + return loc.N, loc.Off + } + // Assume it is a register, return its spill slot, which needs to be live + nameOff := v.Aux.(*AuxNameOffset) + return nameOff.Name, nameOff.Offset +} + +// CanSSA reports whether values of type t can be represented as a Value. +func CanSSA(t *types.Type) bool { + types.CalcSize(t) + if t.IsSIMD() { + return true + } + if t.Size() == 0 { + return true + } + sizeLimit := int64(MaxStruct * types.PtrSize) + if t.Size() > sizeLimit { + // 4*Widthptr is an arbitrary constant. We want it + // to be at least 3*Widthptr so slices can be registerized. + // Too big and we'll introduce too much register pressure. + if !buildcfg.Experiment.SIMD { + return false + } + } + switch t.Kind() { + case types.TARRAY: + // We can't do larger arrays because dynamic indexing is + // not supported on SSA variables. + // TODO: allow if all indexes are constant. + if t.NumElem() <= 1 { + return CanSSA(t.Elem()) + } + return false + case types.TSTRUCT: + if types.IsDirectIface(t) { + // Note: even if t.NumFields()>MaxStruct! See issue 77534. + return true + } + if t.NumFields() > MaxStruct { + return false + } + for _, t1 := range t.Fields() { + if !CanSSA(t1.Type) { + return false + } + } + // Special check for SIMD. If the composite type + // contains SIMD vectors we can return true + // if it pass the checks below. + if !buildcfg.Experiment.SIMD { + return true + } + if t.Size() <= sizeLimit { + return true + } + i, f := t.Registers() + return i+f <= MaxStruct + default: + return true + } +} diff --git a/go/src/cmd/compile/internal/ssa/writebarrier.go b/go/src/cmd/compile/internal/ssa/writebarrier.go new file mode 100644 index 0000000000000000000000000000000000000000..ec5a0fed29d7910d6c316a0760f2077e5fd7aa89 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/writebarrier.go @@ -0,0 +1,859 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/reflectdata" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" + "fmt" + "internal/buildcfg" +) + +// A ZeroRegion records parts of an object which are known to be zero. +// A ZeroRegion only applies to a single memory state. +// Each bit in mask is set if the corresponding pointer-sized word of +// the base object is known to be zero. +// In other words, if mask & (1< 64*ptrSize { + // memory range goes off end of tracked offsets + return true + } + z := zeroes[mem.ID] + if ptr != z.base { + // This isn't the object we know about at this memory state. + return true + } + // Mask of bits we're asking about + m := (uint64(1)<<(size/ptrSize) - 1) << (off / ptrSize) + + if z.mask&m == m { + // All locations are known to be zero, so no heap pointers. + return false + } + return true +} + +// needwb reports whether we need write barrier for store op v. +// v must be Store/Move/Zero. +// zeroes provides known zero information (keyed by ID of memory-type values). +func needwb(v *Value, zeroes map[ID]ZeroRegion) bool { + t, ok := v.Aux.(*types.Type) + if !ok { + v.Fatalf("store aux is not a type: %s", v.LongString()) + } + if !t.HasPointers() { + return false + } + dst := v.Args[0] + if IsStackAddr(dst) { + return false // writes into the stack don't need write barrier + } + // If we're writing to a place that might have heap pointers, we need + // the write barrier. + if mightContainHeapPointer(dst, t.Size(), v.MemoryArg(), zeroes) { + return true + } + // Lastly, check if the values we're writing might be heap pointers. + // If they aren't, we don't need a write barrier. + switch v.Op { + case OpStore: + if !mightBeHeapPointer(v.Args[1]) { + return false + } + case OpZero: + return false // nil is not a heap pointer + case OpMove: + if !mightContainHeapPointer(v.Args[1], t.Size(), v.Args[2], zeroes) { + return false + } + default: + v.Fatalf("store op unknown: %s", v.LongString()) + } + return true +} + +// needWBsrc reports whether GC needs to see v when it is the source of a store. +func needWBsrc(v *Value) bool { + return !IsGlobalAddr(v) +} + +// needWBdst reports whether GC needs to see what used to be in *ptr when ptr is +// the target of a pointer store. +func needWBdst(ptr, mem *Value, zeroes map[ID]ZeroRegion) bool { + // Detect storing to zeroed memory. + var off int64 + for ptr.Op == OpOffPtr { + off += ptr.AuxInt + ptr = ptr.Args[0] + } + ptrSize := ptr.Block.Func.Config.PtrSize + if off%ptrSize != 0 { + return true // see issue 61187 + } + if off < 0 || off >= 64*ptrSize { + // write goes off end of tracked offsets + return true + } + z := zeroes[mem.ID] + if ptr != z.base { + return true + } + // If destination is known to be zeroed, we don't need the write barrier + // to record the old value in *ptr. + return z.mask>>uint(off/ptrSize)&1 == 0 +} + +// writebarrier pass inserts write barriers for store ops (Store, Move, Zero) +// when necessary (the condition above). It rewrites store ops to branches +// and runtime calls, like +// +// if writeBarrier.enabled { +// buf := gcWriteBarrier2() // Not a regular Go call +// buf[0] = val +// buf[1] = *ptr +// } +// *ptr = val +// +// A sequence of WB stores for many pointer fields of a single type will +// be emitted together, with a single branch. +func writebarrier(f *Func) { + if !f.fe.UseWriteBarrier() { + return + } + + // Number of write buffer entries we can request at once. + // Must match runtime/mwbbuf.go:wbMaxEntriesPerCall. + // It must also match the number of instances of runtime.gcWriteBarrier{X}. + const maxEntries = 8 + + var sb, sp, wbaddr, const0 *Value + var cgoCheckPtrWrite, cgoCheckMemmove *obj.LSym + var wbZero, wbMove *obj.LSym + var stores, after []*Value + var sset, sset2 *sparseSet + var storeNumber []int32 + + // Compute map from a value to the SelectN [1] value that uses it. + select1 := f.Cache.allocValueSlice(f.NumValues()) + defer func() { f.Cache.freeValueSlice(select1) }() + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op != OpSelectN { + continue + } + if v.AuxInt != 1 { + continue + } + select1[v.Args[0].ID] = v + } + } + + zeroes := f.computeZeroMap(select1) + for _, b := range f.Blocks { // range loop is safe since the blocks we added contain no stores to expand + // first, identify all the stores that need to insert a write barrier. + // mark them with WB ops temporarily. record presence of WB ops. + nWBops := 0 // count of temporarily created WB ops remaining to be rewritten in the current block + for _, v := range b.Values { + switch v.Op { + case OpStore, OpMove, OpZero: + if needwb(v, zeroes) { + switch v.Op { + case OpStore: + v.Op = OpStoreWB + case OpMove: + v.Op = OpMoveWB + case OpZero: + v.Op = OpZeroWB + } + nWBops++ + } + } + } + if nWBops == 0 { + continue + } + + if wbaddr == nil { + // lazily initialize global values for write barrier test and calls + // find SB and SP values in entry block + initpos := f.Entry.Pos + sp, sb = f.spSb() + wbsym := f.fe.Syslook("writeBarrier") + wbaddr = f.Entry.NewValue1A(initpos, OpAddr, f.Config.Types.UInt32Ptr, wbsym, sb) + wbZero = f.fe.Syslook("wbZero") + wbMove = f.fe.Syslook("wbMove") + if buildcfg.Experiment.CgoCheck2 { + cgoCheckPtrWrite = f.fe.Syslook("cgoCheckPtrWrite") + cgoCheckMemmove = f.fe.Syslook("cgoCheckMemmove") + } + const0 = f.ConstInt32(f.Config.Types.UInt32, 0) + + // allocate auxiliary data structures for computing store order + sset = f.newSparseSet(f.NumValues()) + defer f.retSparseSet(sset) + sset2 = f.newSparseSet(f.NumValues()) + defer f.retSparseSet(sset2) + storeNumber = f.Cache.allocInt32Slice(f.NumValues()) + defer f.Cache.freeInt32Slice(storeNumber) + } + + // order values in store order + b.Values = storeOrder(b.Values, sset, storeNumber) + again: + // find the start and end of the last contiguous WB store sequence. + // a branch will be inserted there. values after it will be moved + // to a new block. + var last *Value + var start, end int + var nonPtrStores int + values := b.Values + hasMove := false + FindSeq: + for i := len(values) - 1; i >= 0; i-- { + w := values[i] + switch w.Op { + case OpStoreWB, OpMoveWB, OpZeroWB: + start = i + if last == nil { + last = w + end = i + 1 + } + nonPtrStores = 0 + if w.Op == OpMoveWB { + hasMove = true + } + case OpVarDef, OpVarLive: + continue + case OpStore: + if last == nil { + continue + } + nonPtrStores++ + if nonPtrStores > 2 { + break FindSeq + } + if hasMove { + // We need to ensure that this store happens + // before we issue a wbMove, as the wbMove might + // use the result of this store as its source. + // Even though this store is not write-barrier + // eligible, it might nevertheless be the store + // of a pointer to the stack, which is then the + // source of the move. + // See issue 71228. + break FindSeq + } + default: + if last == nil { + continue + } + break FindSeq + } + } + stores = append(stores[:0], b.Values[start:end]...) // copy to avoid aliasing + after = append(after[:0], b.Values[end:]...) + b.Values = b.Values[:start] + + // find the memory before the WB stores + mem := stores[0].MemoryArg() + pos := stores[0].Pos + + // If there is a nil check before the WB store, duplicate it to + // the two branches, where the store and the WB load occur. So + // they are more likely be removed by late nilcheck removal (which + // is block-local). + var nilcheck, nilcheckThen, nilcheckEnd *Value + if a := stores[0].Args[0]; a.Op == OpNilCheck && a.Args[1] == mem { + nilcheck = a + } + + // If the source of a MoveWB is volatile (will be clobbered by a + // function call), we need to copy it to a temporary location, as + // marshaling the args of wbMove might clobber the value we're + // trying to move. + // Look for volatile source, copy it to temporary before we check + // the write barrier flag. + // It is unlikely to have more than one of them. Just do a linear + // search instead of using a map. + // See issue 15854. + type volatileCopy struct { + src *Value // address of original volatile value + tmp *Value // address of temporary we've copied the volatile value into + } + var volatiles []volatileCopy + + if !(f.ABIDefault == f.ABI1 && len(f.Config.intParamRegs) >= 3) { + // We don't need to do this if the calls we're going to do take + // all their arguments in registers. + // 3 is the magic number because it covers wbZero, wbMove, cgoCheckMemmove. + copyLoop: + for _, w := range stores { + if w.Op == OpMoveWB { + val := w.Args[1] + if isVolatile(val) { + for _, c := range volatiles { + if val == c.src { + continue copyLoop // already copied + } + } + + t := val.Type.Elem() + tmp := f.NewLocal(w.Pos, t) + mem = b.NewValue1A(w.Pos, OpVarDef, types.TypeMem, tmp, mem) + tmpaddr := b.NewValue2A(w.Pos, OpLocalAddr, t.PtrTo(), tmp, sp, mem) + siz := t.Size() + mem = b.NewValue3I(w.Pos, OpMove, types.TypeMem, siz, tmpaddr, val, mem) + mem.Aux = t + volatiles = append(volatiles, volatileCopy{val, tmpaddr}) + } + } + } + } + + // Build branch point. + bThen := f.NewBlock(BlockPlain) + bEnd := f.NewBlock(b.Kind) + bThen.Pos = pos + bEnd.Pos = b.Pos + b.Pos = pos + + // Set up control flow for end block. + bEnd.CopyControls(b) + bEnd.Likely = b.Likely + for _, e := range b.Succs { + bEnd.Succs = append(bEnd.Succs, e) + e.b.Preds[e.i].b = bEnd + } + + // set up control flow for write barrier test + // load word, test word, avoiding partial register write from load byte. + cfgtypes := &f.Config.Types + flag := b.NewValue2(pos, OpLoad, cfgtypes.UInt32, wbaddr, mem) + flag = b.NewValue2(pos, OpNeq32, cfgtypes.Bool, flag, const0) + b.Kind = BlockIf + b.SetControl(flag) + b.Likely = BranchUnlikely + b.Succs = b.Succs[:0] + b.AddEdgeTo(bThen) + b.AddEdgeTo(bEnd) + bThen.AddEdgeTo(bEnd) + + // For each write barrier store, append write barrier code to bThen. + memThen := mem + + if nilcheck != nil { + nilcheckThen = bThen.NewValue2(nilcheck.Pos, OpNilCheck, nilcheck.Type, nilcheck.Args[0], memThen) + } + + // Note: we can issue the write barrier code in any order. In particular, + // it doesn't matter if they are in a different order *even if* they end + // up referring to overlapping memory regions. For instance if an OpStore + // stores to a location that is later read by an OpMove. In all cases + // any pointers we must get into the write barrier buffer still make it, + // possibly in a different order and possibly a different (but definitely + // more than 0) number of times. + // In light of that, we process all the OpStoreWBs first. This minimizes + // the amount of spill/restore code we need around the Zero/Move calls. + + // srcs contains the value IDs of pointer values we've put in the write barrier buffer. + srcs := sset + srcs.clear() + // dsts contains the value IDs of locations which we've read a pointer out of + // and put the result in the write barrier buffer. + dsts := sset2 + dsts.clear() + + // Buffer up entries that we need to put in the write barrier buffer. + type write struct { + ptr *Value // value to put in write barrier buffer + pos src.XPos // location to use for the write + } + var writeStore [maxEntries]write + writes := writeStore[:0] + + flush := func() { + if len(writes) == 0 { + return + } + // Issue a call to get a write barrier buffer. + t := types.NewTuple(types.Types[types.TUINTPTR].PtrTo(), types.TypeMem) + call := bThen.NewValue1I(pos, OpWB, t, int64(len(writes)), memThen) + curPtr := bThen.NewValue1(pos, OpSelect0, types.Types[types.TUINTPTR].PtrTo(), call) + memThen = bThen.NewValue1(pos, OpSelect1, types.TypeMem, call) + // Write each pending pointer to a slot in the buffer. + for i, write := range writes { + wbuf := bThen.NewValue1I(write.pos, OpOffPtr, types.Types[types.TUINTPTR].PtrTo(), int64(i)*f.Config.PtrSize, curPtr) + memThen = bThen.NewValue3A(write.pos, OpStore, types.TypeMem, types.Types[types.TUINTPTR], wbuf, write.ptr, memThen) + } + writes = writes[:0] + } + addEntry := func(pos src.XPos, ptr *Value) { + writes = append(writes, write{ptr: ptr, pos: pos}) + if len(writes) == maxEntries { + flush() + } + } + + // Find all the pointers we need to write to the buffer. + for _, w := range stores { + if w.Op != OpStoreWB { + continue + } + pos := w.Pos + ptr := w.Args[0] + val := w.Args[1] + if !srcs.contains(val.ID) && needWBsrc(val) { + srcs.add(val.ID) + addEntry(pos, val) + } + if !dsts.contains(ptr.ID) && needWBdst(ptr, w.Args[2], zeroes) { + dsts.add(ptr.ID) + // Load old value from store target. + // Note: This turns bad pointer writes into bad + // pointer reads, which could be confusing. We could avoid + // reading from obviously bad pointers, which would + // take care of the vast majority of these. We could + // patch this up in the signal handler, or use XCHG to + // combine the read and the write. + if ptr == nilcheck { + ptr = nilcheckThen + } + oldVal := bThen.NewValue2(pos, OpLoad, types.Types[types.TUINTPTR], ptr, memThen) + // Save old value to write buffer. + addEntry(pos, oldVal) + } + f.fe.Func().SetWBPos(pos) + nWBops-- + } + flush() + + // Now do the rare cases, Zeros and Moves. + for _, w := range stores { + pos := w.Pos + dst := w.Args[0] + if dst == nilcheck { + dst = nilcheckThen + } + switch w.Op { + case OpZeroWB: + typ := reflectdata.TypeLinksym(w.Aux.(*types.Type)) + // zeroWB(&typ, dst) + taddr := b.NewValue1A(pos, OpAddr, b.Func.Config.Types.Uintptr, typ, sb) + memThen = wbcall(pos, bThen, wbZero, sp, memThen, taddr, dst) + f.fe.Func().SetWBPos(pos) + nWBops-- + case OpMoveWB: + src := w.Args[1] + if isVolatile(src) { + for _, c := range volatiles { + if src == c.src { + src = c.tmp + break + } + } + } + typ := reflectdata.TypeLinksym(w.Aux.(*types.Type)) + // moveWB(&typ, dst, src) + taddr := b.NewValue1A(pos, OpAddr, b.Func.Config.Types.Uintptr, typ, sb) + memThen = wbcall(pos, bThen, wbMove, sp, memThen, taddr, dst, src) + f.fe.Func().SetWBPos(pos) + nWBops-- + } + } + + // merge memory + mem = bEnd.NewValue2(pos, OpPhi, types.TypeMem, mem, memThen) + + if nilcheck != nil { + nilcheckEnd = bEnd.NewValue2(nilcheck.Pos, OpNilCheck, nilcheck.Type, nilcheck.Args[0], mem) + } + + // Do raw stores after merge point. + for _, w := range stores { + pos := w.Pos + dst := w.Args[0] + if dst == nilcheck { + dst = nilcheckEnd + } + switch w.Op { + case OpStoreWB: + val := w.Args[1] + if buildcfg.Experiment.CgoCheck2 { + // Issue cgo checking code. + mem = wbcall(pos, bEnd, cgoCheckPtrWrite, sp, mem, dst, val) + } + mem = bEnd.NewValue3A(pos, OpStore, types.TypeMem, w.Aux, dst, val, mem) + case OpZeroWB: + mem = bEnd.NewValue2I(pos, OpZero, types.TypeMem, w.AuxInt, dst, mem) + mem.Aux = w.Aux + case OpMoveWB: + src := w.Args[1] + if isVolatile(src) { + for _, c := range volatiles { + if src == c.src { + src = c.tmp + break + } + } + } + if buildcfg.Experiment.CgoCheck2 { + // Issue cgo checking code. + typ := reflectdata.TypeLinksym(w.Aux.(*types.Type)) + taddr := b.NewValue1A(pos, OpAddr, b.Func.Config.Types.Uintptr, typ, sb) + mem = wbcall(pos, bEnd, cgoCheckMemmove, sp, mem, taddr, dst, src) + } + mem = bEnd.NewValue3I(pos, OpMove, types.TypeMem, w.AuxInt, dst, src, mem) + mem.Aux = w.Aux + case OpVarDef, OpVarLive: + mem = bEnd.NewValue1A(pos, w.Op, types.TypeMem, w.Aux, mem) + case OpStore: + val := w.Args[1] + mem = bEnd.NewValue3A(pos, OpStore, types.TypeMem, w.Aux, dst, val, mem) + } + } + + // The last store becomes the WBend marker. This marker is used by the liveness + // pass to determine what parts of the code are preemption-unsafe. + // All subsequent memory operations use this memory, so we have to sacrifice the + // previous last memory op to become this new value. + bEnd.Values = append(bEnd.Values, last) + last.Block = bEnd + last.reset(OpWBend) + last.Pos = last.Pos.WithNotStmt() + last.Type = types.TypeMem + last.AddArg(mem) + + // Free all the old stores, except last which became the WBend marker. + for _, w := range stores { + if w != last { + w.resetArgs() + } + } + for _, w := range stores { + if w != last { + f.freeValue(w) + } + } + if nilcheck != nil && nilcheck.Uses == 0 { + nilcheck.reset(OpInvalid) + } + + // put values after the store sequence into the end block + bEnd.Values = append(bEnd.Values, after...) + for _, w := range after { + w.Block = bEnd + } + + // if we have more stores in this block, do this block again + if nWBops > 0 { + goto again + } + } +} + +// computeZeroMap returns a map from an ID of a memory value to +// a set of locations that are known to be zeroed at that memory value. +func (f *Func) computeZeroMap(select1 []*Value) map[ID]ZeroRegion { + + ptrSize := f.Config.PtrSize + // Keep track of which parts of memory are known to be zero. + // This helps with removing write barriers for various initialization patterns. + // This analysis is conservative. We only keep track, for each memory state, of + // which of the first 64 words of a single object are known to be zero. + zeroes := map[ID]ZeroRegion{} + // Find new objects. + for _, b := range f.Blocks { + for _, v := range b.Values { + if mem, ok := IsNewObject(v, select1); ok { + // While compiling package runtime itself, we might see user + // calls to newobject, which will have result type + // unsafe.Pointer instead. We can't easily infer how large the + // allocated memory is, so just skip it. + if types.LocalPkg.Path == "runtime" && v.Type.IsUnsafePtr() { + continue + } + + nptr := min(64, v.Type.Elem().Size()/ptrSize) + zeroes[mem.ID] = ZeroRegion{base: v, mask: 1< 0 { + fmt.Printf("func %s\n", f.Name) + for mem, z := range zeroes { + fmt.Printf(" memory=v%d ptr=%v zeromask=%b\n", mem, z.base, z.mask) + } + } + return zeroes +} + +// wbcall emits write barrier runtime call in b, returns memory. +func wbcall(pos src.XPos, b *Block, fn *obj.LSym, sp, mem *Value, args ...*Value) *Value { + config := b.Func.Config + typ := config.Types.Uintptr // type of all argument values + nargs := len(args) + + // TODO (register args) this is a bit of a hack. + inRegs := b.Func.ABIDefault == b.Func.ABI1 && len(config.intParamRegs) >= 3 + + if !inRegs { + // Store arguments to the appropriate stack slot. + off := config.ctxt.Arch.FixedFrameSize + for _, arg := range args { + stkaddr := b.NewValue1I(pos, OpOffPtr, typ.PtrTo(), off, sp) + mem = b.NewValue3A(pos, OpStore, types.TypeMem, typ, stkaddr, arg, mem) + off += typ.Size() + } + args = args[:0] + } + + args = append(args, mem) + + // issue call + argTypes := make([]*types.Type, nargs, 3) // at most 3 args; allows stack allocation + for i := 0; i < nargs; i++ { + argTypes[i] = typ + } + call := b.NewValue0A(pos, OpStaticCall, types.TypeResultMem, StaticAuxCall(fn, b.Func.ABIDefault.ABIAnalyzeTypes(argTypes, nil))) + call.AddArgs(args...) + call.AuxInt = int64(nargs) * typ.Size() + return b.NewValue1I(pos, OpSelectN, types.TypeMem, 0, call) +} + +// IsStackAddr reports whether v is known to be an address of a stack slot. +func IsStackAddr(v *Value) bool { + for v.Op == OpOffPtr || v.Op == OpAddPtr || v.Op == OpPtrIndex || v.Op == OpCopy { + v = v.Args[0] + } + switch v.Op { + case OpSP, OpLocalAddr, OpSelectNAddr, OpGetCallerSP: + return true + } + return false +} + +// IsGlobalAddr reports whether v is known to be an address of a global (or nil). +func IsGlobalAddr(v *Value) bool { + for v.Op == OpOffPtr || v.Op == OpAddPtr || v.Op == OpPtrIndex || v.Op == OpCopy { + v = v.Args[0] + } + if v.Op == OpAddr && v.Args[0].Op == OpSB { + return true // address of a global + } + if v.Op == OpConstNil { + return true + } + if v.Op == OpLoad && IsReadOnlyGlobalAddr(v.Args[0]) { + return true // loading from a read-only global - the resulting address can't be a heap address. + } + return false +} + +// IsReadOnlyGlobalAddr reports whether v is known to be an address of a read-only global. +func IsReadOnlyGlobalAddr(v *Value) bool { + if v.Op == OpConstNil { + // Nil pointers are read only. See issue 33438. + return true + } + if v.Op == OpAddr && v.Aux != nil && v.Aux.(*obj.LSym).Type == objabi.SRODATA { + return true + } + return false +} + +// IsNewObject reports whether v is a pointer to a freshly allocated & zeroed object, +// if so, also returns the memory state mem at which v is zero. +func IsNewObject(v *Value, select1 []*Value) (mem *Value, ok bool) { + f := v.Block.Func + c := f.Config + if f.ABIDefault == f.ABI1 && len(c.intParamRegs) >= 1 { + if v.Op != OpSelectN || v.AuxInt != 0 { + return nil, false + } + mem = select1[v.Args[0].ID] + if mem == nil { + return nil, false + } + } else { + if v.Op != OpLoad { + return nil, false + } + mem = v.MemoryArg() + if mem.Op != OpSelectN { + return nil, false + } + if mem.Type != types.TypeMem { + return nil, false + } // assume it is the right selection if true + } + call := mem.Args[0] + if call.Op != OpStaticCall { + return nil, false + } + // Check for new object, or for new object calls that have been transformed into size-specialized malloc calls. + // Calls that have return type unsafe pointer may have originally been produced by flushPendingHeapAllocations + // in the ssa generator, so may have not originally been newObject calls. + var numParameters int64 + switch { + case isNewObject(call.Aux): + numParameters = 1 + case isSpecializedMalloc(call.Aux) && !v.Type.IsUnsafePtr(): + numParameters = 3 + default: + return nil, false + } + if f.ABIDefault == f.ABI1 && len(c.intParamRegs) >= 1 { + if v.Args[0] == call { + return mem, true + } + return nil, false + } + if v.Args[0].Op != OpOffPtr { + return nil, false + } + if v.Args[0].Args[0].Op != OpSP { + return nil, false + } + if v.Args[0].AuxInt != c.ctxt.Arch.FixedFrameSize+numParameters*c.RegSize { // offset of return value + return nil, false + } + return mem, true +} + +// IsSanitizerSafeAddr reports whether v is known to be an address +// that doesn't need instrumentation. +func IsSanitizerSafeAddr(v *Value) bool { + for v.Op == OpOffPtr || v.Op == OpAddPtr || v.Op == OpPtrIndex || v.Op == OpCopy { + v = v.Args[0] + } + switch v.Op { + case OpSP, OpLocalAddr, OpSelectNAddr: + // Stack addresses are always safe. + return true + case OpITab, OpStringPtr, OpGetClosurePtr: + // Itabs, string data, and closure fields are + // read-only once initialized. + return true + case OpAddr: + vt := v.Aux.(*obj.LSym).Type + return vt == objabi.SRODATA || vt == objabi.SLIBFUZZER_8BIT_COUNTER || vt == objabi.SCOVERAGE_COUNTER || vt == objabi.SCOVERAGE_AUXVAR + } + return false +} + +// isVolatile reports whether v is a pointer to argument region on stack which +// will be clobbered by a function call. +func isVolatile(v *Value) bool { + for v.Op == OpOffPtr || v.Op == OpAddPtr || v.Op == OpPtrIndex || v.Op == OpCopy || v.Op == OpSelectNAddr { + v = v.Args[0] + } + return v.Op == OpSP +} diff --git a/go/src/cmd/compile/internal/ssa/writebarrier_test.go b/go/src/cmd/compile/internal/ssa/writebarrier_test.go new file mode 100644 index 0000000000000000000000000000000000000000..0b11afc84da6433863765d6ea106fa764e872b88 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/writebarrier_test.go @@ -0,0 +1,56 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/compile/internal/types" + "testing" +) + +func TestWriteBarrierStoreOrder(t *testing.T) { + // Make sure writebarrier phase works even StoreWB ops are not in dependency order + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil), + Valu("v", OpConstNil, ptrType, 0, nil), + Valu("addr1", OpAddr, ptrType, 0, nil, "sb"), + Valu("wb2", OpStore, types.TypeMem, 0, ptrType, "addr1", "v", "wb1"), + Valu("wb1", OpStore, types.TypeMem, 0, ptrType, "addr1", "v", "start"), // wb1 and wb2 are out of order + Goto("exit")), + Bloc("exit", + Exit("wb2"))) + + CheckFunc(fun.f) + writebarrier(fun.f) + CheckFunc(fun.f) +} + +func TestWriteBarrierPhi(t *testing.T) { + // Make sure writebarrier phase works for single-block loop, where + // a Phi op takes the store in the same block as argument. + // See issue #19067. + c := testConfig(t) + ptrType := c.config.Types.BytePtr + fun := c.Fun("entry", + Bloc("entry", + Valu("start", OpInitMem, types.TypeMem, 0, nil), + Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil), + Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil), + Goto("loop")), + Bloc("loop", + Valu("phi", OpPhi, types.TypeMem, 0, nil, "start", "wb"), + Valu("v", OpConstNil, ptrType, 0, nil), + Valu("addr", OpAddr, ptrType, 0, nil, "sb"), + Valu("wb", OpStore, types.TypeMem, 0, ptrType, "addr", "v", "phi"), // has write barrier + Goto("loop"))) + + CheckFunc(fun.f) + writebarrier(fun.f) + CheckFunc(fun.f) +} diff --git a/go/src/cmd/compile/internal/ssa/xposmap.go b/go/src/cmd/compile/internal/ssa/xposmap.go new file mode 100644 index 0000000000000000000000000000000000000000..382f916571c0a23b560c4bae3d1a1e51d41fcd30 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/xposmap.go @@ -0,0 +1,116 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import ( + "cmd/internal/src" + "fmt" +) + +type lineRange struct { + first, last uint32 +} + +// An xposmap is a map from fileindex and line of src.XPos to int32, +// implemented sparsely to save space (column and statement status are ignored). +// The sparse skeleton is constructed once, and then reused by ssa phases +// that (re)move values with statements attached. +type xposmap struct { + // A map from file index to maps from line range to integers (block numbers) + maps map[int32]*biasedSparseMap + // The next two fields provide a single-item cache for common case of repeated lines from same file. + lastIndex int32 // -1 means no entry in cache + lastMap *biasedSparseMap // map found at maps[lastIndex] +} + +// newXposmap constructs an xposmap valid for inputs which have a file index in the keys of x, +// and line numbers in the range x[file index]. +// The resulting xposmap will panic if a caller attempts to set or add an XPos not in that range. +func newXposmap(x map[int]lineRange) *xposmap { + maps := make(map[int32]*biasedSparseMap) + for i, p := range x { + maps[int32(i)] = newBiasedSparseMap(int(p.first), int(p.last)) + } + return &xposmap{maps: maps, lastIndex: -1} // zero for the rest is okay +} + +// clear removes data from the map but leaves the sparse skeleton. +func (m *xposmap) clear() { + for _, l := range m.maps { + if l != nil { + l.clear() + } + } + m.lastIndex = -1 + m.lastMap = nil +} + +// mapFor returns the line range map for a given file index. +func (m *xposmap) mapFor(index int32) *biasedSparseMap { + if index == m.lastIndex { + return m.lastMap + } + mf := m.maps[index] + m.lastIndex = index + m.lastMap = mf + return mf +} + +// set inserts p->v into the map. +// If p does not fall within the set of fileindex->lineRange used to construct m, this will panic. +func (m *xposmap) set(p src.XPos, v int32) { + s := m.mapFor(p.FileIndex()) + if s == nil { + panic(fmt.Sprintf("xposmap.set(%d), file index not found in map\n", p.FileIndex())) + } + s.set(p.Line(), v) +} + +// get returns the int32 associated with the file index and line of p. +func (m *xposmap) get(p src.XPos) (int32, bool) { + s := m.mapFor(p.FileIndex()) + if s == nil { + return 0, false + } + return s.get(p.Line()) +} + +// add adds p to m, treating m as a set instead of as a map. +// If p does not fall within the set of fileindex->lineRange used to construct m, this will panic. +// Use clear() in between set/map interpretations of m. +func (m *xposmap) add(p src.XPos) { + m.set(p, 0) +} + +// contains returns whether the file index and line of p are in m, +// treating m as a set instead of as a map. +func (m *xposmap) contains(p src.XPos) bool { + s := m.mapFor(p.FileIndex()) + if s == nil { + return false + } + return s.contains(p.Line()) +} + +// remove removes the file index and line for p from m, +// whether m is currently treated as a map or set. +func (m *xposmap) remove(p src.XPos) { + s := m.mapFor(p.FileIndex()) + if s == nil { + return + } + s.remove(p.Line()) +} + +// foreachEntry applies f to each (fileindex, line, value) triple in m. +func (m *xposmap) foreachEntry(f func(j int32, l uint, v int32)) { + for j, mm := range m.maps { + s := mm.size() + for i := 0; i < s; i++ { + l, v := mm.getEntry(i) + f(j, l, v) + } + } +} diff --git a/go/src/cmd/compile/internal/ssa/zcse.go b/go/src/cmd/compile/internal/ssa/zcse.go new file mode 100644 index 0000000000000000000000000000000000000000..e08272c34580173c60929b7c9edc4183d80050f4 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/zcse.go @@ -0,0 +1,79 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import "cmd/compile/internal/types" + +// zcse does an initial pass of common-subexpression elimination on the +// function for values with zero arguments to allow the more expensive cse +// to begin with a reduced number of values. Values are just relinked, +// nothing is deleted. A subsequent deadcode pass is required to actually +// remove duplicate expressions. +func zcse(f *Func) { + vals := make(map[vkey]*Value) + + for _, b := range f.Blocks { + for i := 0; i < len(b.Values); i++ { + v := b.Values[i] + if opcodeTable[v.Op].argLen == 0 { + key := vkey{v.Op, keyFor(v), v.Aux, v.Type} + if vals[key] == nil { + vals[key] = v + if b != f.Entry { + // Move v to the entry block so it will dominate every block + // where we might use it. This prevents the need for any dominator + // calculations in this pass. + v.Block = f.Entry + f.Entry.Values = append(f.Entry.Values, v) + last := len(b.Values) - 1 + b.Values[i] = b.Values[last] + b.Values[last] = nil + b.Values = b.Values[:last] + + i-- // process b.Values[i] again + } + } + } + } + } + + for _, b := range f.Blocks { + for _, v := range b.Values { + for i, a := range v.Args { + if opcodeTable[a.Op].argLen == 0 { + key := vkey{a.Op, keyFor(a), a.Aux, a.Type} + if rv, ok := vals[key]; ok { + v.SetArg(i, rv) + } + } + } + } + } +} + +// vkey is a type used to uniquely identify a zero arg value. +type vkey struct { + op Op + ai int64 // aux int + ax Aux // aux + t *types.Type // type +} + +// keyFor returns the AuxInt portion of a key structure uniquely identifying a +// zero arg value for the supported ops. +func keyFor(v *Value) int64 { + switch v.Op { + case OpConst64, OpConst64F, OpConst32F: + return v.AuxInt + case OpConst32: + return int64(int32(v.AuxInt)) + case OpConst16: + return int64(int16(v.AuxInt)) + case OpConst8, OpConstBool: + return int64(int8(v.AuxInt)) + default: + return v.AuxInt + } +} diff --git a/go/src/cmd/compile/internal/ssa/zeroextension_test.go b/go/src/cmd/compile/internal/ssa/zeroextension_test.go new file mode 100644 index 0000000000000000000000000000000000000000..2e316214114fccdffadb8ad7832f3c02b95902b6 --- /dev/null +++ b/go/src/cmd/compile/internal/ssa/zeroextension_test.go @@ -0,0 +1,34 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssa + +import "testing" + +type extTest struct { + f func(uint64, uint64) uint64 + arg1 uint64 + arg2 uint64 + res uint64 + name string +} + +var extTests = [...]extTest{ + {f: func(a, b uint64) uint64 { op1 := int32(a); op2 := int32(b); return uint64(uint32(op1 / op2)) }, arg1: 0x1, arg2: 0xfffffffeffffffff, res: 0xffffffff, name: "div"}, + {f: func(a, b uint64) uint64 { op1 := int32(a); op2 := int32(b); return uint64(uint32(op1 * op2)) }, arg1: 0x1, arg2: 0x100000001, res: 0x1, name: "mul"}, + {f: func(a, b uint64) uint64 { op1 := int32(a); op2 := int32(b); return uint64(uint32(op1 + op2)) }, arg1: 0x1, arg2: 0xeeeeeeeeffffffff, res: 0x0, name: "add"}, + {f: func(a, b uint64) uint64 { op1 := int32(a); op2 := int32(b); return uint64(uint32(op1 - op2)) }, arg1: 0x1, arg2: 0xeeeeeeeeffffffff, res: 0x2, name: "sub"}, + {f: func(a, b uint64) uint64 { op1 := int32(a); op2 := int32(b); return uint64(uint32(op1 | op2)) }, arg1: 0x100000000000001, arg2: 0xfffffffffffffff, res: 0xffffffff, name: "or"}, + {f: func(a, b uint64) uint64 { op1 := int32(a); op2 := int32(b); return uint64(uint32(op1 ^ op2)) }, arg1: 0x100000000000001, arg2: 0xfffffffffffffff, res: 0xfffffffe, name: "xor"}, + {f: func(a, b uint64) uint64 { op1 := int32(a); op2 := int32(b); return uint64(uint32(op1 & op2)) }, arg1: 0x100000000000001, arg2: 0x100000000000001, res: 0x1, name: "and"}, +} + +func TestZeroExtension(t *testing.T) { + for _, x := range extTests { + r := x.f(x.arg1, x.arg2) + if x.res != r { + t.Errorf("%s: got %d want %d", x.name, r, x.res) + } + } +} diff --git a/go/src/cmd/compile/internal/ssagen/abi.go b/go/src/cmd/compile/internal/ssagen/abi.go new file mode 100644 index 0000000000000000000000000000000000000000..0e8dbd944540e0e8b265886597ee896f10c1f957 --- /dev/null +++ b/go/src/cmd/compile/internal/ssagen/abi.go @@ -0,0 +1,582 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssagen + +import ( + "fmt" + "internal/buildcfg" + "log" + "os" + "strings" + + "cmd/compile/internal/abi" + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/wasm" + + rtabi "internal/abi" +) + +// SymABIs records information provided by the assembler about symbol +// definition ABIs and reference ABIs. +type SymABIs struct { + defs map[string]obj.ABI + refs map[string]obj.ABISet +} + +func NewSymABIs() *SymABIs { + return &SymABIs{ + defs: make(map[string]obj.ABI), + refs: make(map[string]obj.ABISet), + } +} + +// canonicalize returns the canonical name used for a linker symbol in +// s's maps. Symbols in this package may be written either as "".X or +// with the package's import path already in the symbol. This rewrites +// both to use the full path, which matches compiler-generated linker +// symbol names. +func (s *SymABIs) canonicalize(linksym string) string { + if strings.HasPrefix(linksym, `"".`) { + panic("non-canonical symbol name: " + linksym) + } + return linksym +} + +// ReadSymABIs reads a symabis file that specifies definitions and +// references of text symbols by ABI. +// +// The symabis format is a set of lines, where each line is a sequence +// of whitespace-separated fields. The first field is a verb and is +// either "def" for defining a symbol ABI or "ref" for referencing a +// symbol using an ABI. For both "def" and "ref", the second field is +// the symbol name and the third field is the ABI name, as one of the +// named cmd/internal/obj.ABI constants. +func (s *SymABIs) ReadSymABIs(file string) { + data, err := os.ReadFile(file) + if err != nil { + log.Fatalf("-symabis: %v", err) + } + + for lineNum, line := range strings.Split(string(data), "\n") { + lineNum++ // 1-based + line = strings.TrimSpace(line) + if line == "" || strings.HasPrefix(line, "#") { + continue + } + + parts := strings.Fields(line) + switch parts[0] { + case "def", "ref": + // Parse line. + if len(parts) != 3 { + log.Fatalf(`%s:%d: invalid symabi: syntax is "%s sym abi"`, file, lineNum, parts[0]) + } + sym, abistr := parts[1], parts[2] + abi, valid := obj.ParseABI(abistr) + if !valid { + log.Fatalf(`%s:%d: invalid symabi: unknown abi "%s"`, file, lineNum, abistr) + } + + sym = s.canonicalize(sym) + + // Record for later. + if parts[0] == "def" { + s.defs[sym] = abi + base.Ctxt.DwTextCount++ + } else { + s.refs[sym] |= obj.ABISetOf(abi) + } + default: + log.Fatalf(`%s:%d: invalid symabi type "%s"`, file, lineNum, parts[0]) + } + } +} + +// HasDef returns whether the given symbol has an assembly definition. +func (s *SymABIs) HasDef(sym *types.Sym) bool { + symName := sym.Linkname + if symName == "" { + symName = sym.Pkg.Prefix + "." + sym.Name + } + symName = s.canonicalize(symName) + + _, hasDefABI := s.defs[symName] + return hasDefABI +} + +// GenABIWrappers applies ABI information to Funcs and generates ABI +// wrapper functions where necessary. +func (s *SymABIs) GenABIWrappers() { + // For cgo exported symbols, we tell the linker to export the + // definition ABI to C. That also means that we don't want to + // create ABI wrappers even if there's a linkname. + // + // TODO(austin): Maybe we want to create the ABI wrappers, but + // ensure the linker exports the right ABI definition under + // the unmangled name? + cgoExports := make(map[string][]*[]string) + for i, prag := range typecheck.Target.CgoPragmas { + switch prag[0] { + case "cgo_export_static", "cgo_export_dynamic": + symName := s.canonicalize(prag[1]) + pprag := &typecheck.Target.CgoPragmas[i] + cgoExports[symName] = append(cgoExports[symName], pprag) + } + } + + // Apply ABI defs and refs to Funcs and generate wrappers. + // + // This may generate new decls for the wrappers, but we + // specifically *don't* want to visit those, lest we create + // wrappers for wrappers. + for _, fn := range typecheck.Target.Funcs { + nam := fn.Nname + if ir.IsBlank(nam) { + continue + } + sym := nam.Sym() + + symName := sym.Linkname + if symName == "" { + symName = sym.Pkg.Prefix + "." + sym.Name + } + symName = s.canonicalize(symName) + + // Apply definitions. + defABI, hasDefABI := s.defs[symName] + if hasDefABI { + if len(fn.Body) != 0 { + base.ErrorfAt(fn.Pos(), 0, "%v defined in both Go and assembly", fn) + } + fn.ABI = defABI + } + + if fn.Pragma&ir.CgoUnsafeArgs != 0 { + // CgoUnsafeArgs indicates the function (or its callee) uses + // offsets to dispatch arguments, which currently using ABI0 + // frame layout. Pin it to ABI0. + fn.ABI = obj.ABI0 + // Propagate linkname attribute, which was set on the ABIInternal + // symbol. + if sym.Linksym().IsLinkname() { + sym.LinksymABI(fn.ABI).Set(obj.AttrLinkname, true) + } + } + + // If cgo-exported, add the definition ABI to the cgo + // pragmas. + cgoExport := cgoExports[symName] + for _, pprag := range cgoExport { + // The export pragmas have the form: + // + // cgo_export_* [] + // + // If is omitted, it's the same as + // . + // + // Expand to + // + // cgo_export_* + if len(*pprag) == 2 { + *pprag = append(*pprag, (*pprag)[1]) + } + // Add the ABI argument. + *pprag = append(*pprag, fn.ABI.String()) + } + + // Apply references. + if abis, ok := s.refs[symName]; ok { + fn.ABIRefs |= abis + } + // Assume all functions are referenced at least as + // ABIInternal, since they may be referenced from + // other packages. + fn.ABIRefs.Set(obj.ABIInternal, true) + + // If a symbol is defined in this package (either in + // Go or assembly) and given a linkname, it may be + // referenced from another package, so make it + // callable via any ABI. It's important that we know + // it's defined in this package since other packages + // may "pull" symbols using linkname and we don't want + // to create duplicate ABI wrappers. + // + // However, if it's given a linkname for exporting to + // C, then we don't make ABI wrappers because the cgo + // tool wants the original definition. + hasBody := len(fn.Body) != 0 + if sym.Linkname != "" && (hasBody || hasDefABI) && len(cgoExport) == 0 { + fn.ABIRefs |= obj.ABISetCallable + } + + // Double check that cgo-exported symbols don't get + // any wrappers. + if len(cgoExport) > 0 && fn.ABIRefs&^obj.ABISetOf(fn.ABI) != 0 { + base.Fatalf("cgo exported function %v cannot have ABI wrappers", fn) + } + + if !buildcfg.Experiment.RegabiWrappers { + continue + } + + forEachWrapperABI(fn, makeABIWrapper) + } +} + +func forEachWrapperABI(fn *ir.Func, cb func(fn *ir.Func, wrapperABI obj.ABI)) { + need := fn.ABIRefs &^ obj.ABISetOf(fn.ABI) + if need == 0 { + return + } + + for wrapperABI := obj.ABI(0); wrapperABI < obj.ABICount; wrapperABI++ { + if !need.Get(wrapperABI) { + continue + } + cb(fn, wrapperABI) + } +} + +// makeABIWrapper creates a new function that will be called with +// wrapperABI and calls "f" using f.ABI. +func makeABIWrapper(f *ir.Func, wrapperABI obj.ABI) { + if base.Debug.ABIWrap != 0 { + fmt.Fprintf(os.Stderr, "=-= %v to %v wrapper for %v\n", wrapperABI, f.ABI, f) + } + + // Q: is this needed? + savepos := base.Pos + savedcurfn := ir.CurFunc + + pos := base.AutogeneratedPos + base.Pos = pos + + // At the moment we don't support wrapping a method, we'd need machinery + // below to handle the receiver. Panic if we see this scenario. + ft := f.Nname.Type() + if ft.NumRecvs() != 0 { + base.ErrorfAt(f.Pos(), 0, "makeABIWrapper support for wrapping methods not implemented") + return + } + + // Reuse f's types.Sym to create a new ODCLFUNC/function. + // TODO(mdempsky): Means we can't set sym.Def in Declfunc, ugh. + fn := ir.NewFunc(pos, pos, f.Sym(), types.NewSignature(nil, + typecheck.NewFuncParams(ft.Params()), + typecheck.NewFuncParams(ft.Results()))) + fn.ABI = wrapperABI + typecheck.DeclFunc(fn) + + fn.SetABIWrapper(true) + fn.SetDupok(true) + + // ABI0-to-ABIInternal wrappers will be mainly loading params from + // stack into registers (and/or storing stack locations back to + // registers after the wrapped call); in most cases they won't + // need to allocate stack space, so it should be OK to mark them + // as NOSPLIT in these cases. In addition, my assumption is that + // functions written in assembly are NOSPLIT in most (but not all) + // cases. In the case of an ABIInternal target that has too many + // parameters to fit into registers, the wrapper would need to + // allocate stack space, but this seems like an unlikely scenario. + // Hence: mark these wrappers NOSPLIT. + // + // ABIInternal-to-ABI0 wrappers on the other hand will be taking + // things in registers and pushing them onto the stack prior to + // the ABI0 call, meaning that they will always need to allocate + // stack space. If the compiler marks them as NOSPLIT this seems + // as though it could lead to situations where the linker's + // nosplit-overflow analysis would trigger a link failure. On the + // other hand if they not tagged NOSPLIT then this could cause + // problems when building the runtime (since there may be calls to + // asm routine in cases where it's not safe to grow the stack). In + // most cases the wrapper would be (in effect) inlined, but are + // there (perhaps) indirect calls from the runtime that could run + // into trouble here. + // FIXME: at the moment all.bash does not pass when I leave out + // NOSPLIT for these wrappers, so all are currently tagged with NOSPLIT. + fn.Pragma |= ir.Nosplit + + // Generate call. Use tail call if no params and no returns, + // but a regular call otherwise. + // + // Note: ideally we would be using a tail call in cases where + // there are params but no returns for ABI0->ABIInternal wrappers, + // provided that all params fit into registers (e.g. we don't have + // to allocate any stack space). Doing this will require some + // extra work in typecheck/walk/ssa, might want to add a new node + // OTAILCALL or something to this effect. + tailcall := fn.Type().NumResults() == 0 && fn.Type().NumParams() == 0 && fn.Type().NumRecvs() == 0 + if base.Ctxt.Arch.Name == "ppc64le" && base.Ctxt.Flag_dynlink { + // cannot tailcall on PPC64 with dynamic linking, as we need + // to restore R2 after call. + tailcall = false + } + if base.Ctxt.Arch.Name == "amd64" && wrapperABI == obj.ABIInternal { + // cannot tailcall from ABIInternal to ABI0 on AMD64, as we need + // to special registers (X15) when returning to ABIInternal. + tailcall = false + } + + var tail ir.Node + call := ir.NewCallExpr(base.Pos, ir.OCALL, f.Nname, nil) + call.Args = ir.ParamNames(fn.Type()) + call.IsDDD = fn.Type().IsVariadic() + tail = call + if tailcall { + tail = ir.NewTailCallStmt(base.Pos, call) + } else if fn.Type().NumResults() > 0 { + n := ir.NewReturnStmt(base.Pos, nil) + n.Results = []ir.Node{call} + tail = n + } + fn.Body.Append(tail) + + typecheck.FinishFuncBody() + + ir.CurFunc = fn + typecheck.Stmts(fn.Body) + + // Restore previous context. + base.Pos = savepos + ir.CurFunc = savedcurfn +} + +// CreateWasmImportWrapper creates a wrapper for imported WASM functions to +// adapt them to the Go calling convention. The body for this function is +// generated in cmd/internal/obj/wasm/wasmobj.go +func CreateWasmImportWrapper(fn *ir.Func) bool { + if fn.WasmImport == nil { + return false + } + if buildcfg.GOARCH != "wasm" { + base.FatalfAt(fn.Pos(), "CreateWasmImportWrapper call not supported on %s: func was %v", buildcfg.GOARCH, fn) + } + + ir.InitLSym(fn, true) + + setupWasmImport(fn) + + pp := objw.NewProgs(fn, 0) + defer pp.Free() + pp.Text.To.Type = obj.TYPE_TEXTSIZE + pp.Text.To.Val = int32(types.RoundUp(fn.Type().ArgWidth(), int64(types.RegSize))) + // Wrapper functions never need their own stack frame + pp.Text.To.Offset = 0 + pp.Flush() + + return true +} + +func GenWasmExportWrapper(wrapped *ir.Func) { + if wrapped.WasmExport == nil { + return + } + if buildcfg.GOARCH != "wasm" { + base.FatalfAt(wrapped.Pos(), "GenWasmExportWrapper call not supported on %s: func was %v", buildcfg.GOARCH, wrapped) + } + + pos := base.AutogeneratedPos + sym := &types.Sym{ + Name: wrapped.WasmExport.Name, + Linkname: wrapped.WasmExport.Name, + } + ft := wrapped.Nname.Type() + fn := ir.NewFunc(pos, pos, sym, types.NewSignature(nil, + typecheck.NewFuncParams(ft.Params()), + typecheck.NewFuncParams(ft.Results()))) + fn.ABI = obj.ABI0 // actually wasm ABI + // The wrapper function has a special calling convention that + // morestack currently doesn't handle. For now we require that + // the argument size fits in StackSmall, which we know we have + // on stack, so we don't need to split stack. + // cmd/internal/obj/wasm supports only 16 argument "registers" + // anyway. + if ft.ArgWidth() > rtabi.StackSmall { + base.ErrorfAt(wrapped.Pos(), 0, "wasmexport function argument too large") + } + fn.Pragma |= ir.Nosplit + + ir.InitLSym(fn, true) + + setupWasmExport(fn, wrapped) + + pp := objw.NewProgs(fn, 0) + defer pp.Free() + // TEXT. Has a frame to pass args on stack to the Go function. + pp.Text.To.Type = obj.TYPE_TEXTSIZE + pp.Text.To.Val = int32(0) + pp.Text.To.Offset = types.RoundUp(ft.ArgWidth(), int64(types.RegSize)) + // No locals. (Callee's args are covered in the callee's stackmap.) + p := pp.Prog(obj.AFUNCDATA) + p.From.SetConst(rtabi.FUNCDATA_LocalsPointerMaps) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = base.Ctxt.Lookup("no_pointers_stackmap") + pp.Flush() + // Actual code geneneration is in cmd/internal/obj/wasm. +} + +func paramsToWasmFields(f *ir.Func, pragma string, result *abi.ABIParamResultInfo, abiParams []abi.ABIParamAssignment) []obj.WasmField { + wfs := make([]obj.WasmField, 0, len(abiParams)) + for _, p := range abiParams { + t := p.Type + var wt obj.WasmFieldType + switch t.Kind() { + case types.TINT32, types.TUINT32: + wt = obj.WasmI32 + case types.TINT64, types.TUINT64: + wt = obj.WasmI64 + case types.TFLOAT32: + wt = obj.WasmF32 + case types.TFLOAT64: + wt = obj.WasmF64 + case types.TUNSAFEPTR, types.TUINTPTR: + wt = obj.WasmPtr + case types.TBOOL: + wt = obj.WasmBool + case types.TSTRING: + // Two parts, (ptr, len) + wt = obj.WasmPtr + wfs = append(wfs, obj.WasmField{Type: wt, Offset: p.FrameOffset(result)}) + wfs = append(wfs, obj.WasmField{Type: wt, Offset: p.FrameOffset(result) + int64(types.PtrSize)}) + continue + case types.TPTR: + if wasmElemTypeAllowed(t.Elem()) { + wt = obj.WasmPtr + break + } + fallthrough + default: + base.ErrorfAt(f.Pos(), 0, "%s: unsupported parameter type %s", pragma, t.String()) + } + wfs = append(wfs, obj.WasmField{Type: wt, Offset: p.FrameOffset(result)}) + } + return wfs +} + +func resultsToWasmFields(f *ir.Func, pragma string, result *abi.ABIParamResultInfo, abiParams []abi.ABIParamAssignment) []obj.WasmField { + if len(abiParams) > 1 { + base.ErrorfAt(f.Pos(), 0, "%s: too many return values", pragma) + return nil + } + wfs := make([]obj.WasmField, len(abiParams)) + for i, p := range abiParams { + t := p.Type + switch t.Kind() { + case types.TINT32, types.TUINT32: + wfs[i].Type = obj.WasmI32 + case types.TINT64, types.TUINT64: + wfs[i].Type = obj.WasmI64 + case types.TFLOAT32: + wfs[i].Type = obj.WasmF32 + case types.TFLOAT64: + wfs[i].Type = obj.WasmF64 + case types.TUNSAFEPTR, types.TUINTPTR: + wfs[i].Type = obj.WasmPtr + case types.TBOOL: + wfs[i].Type = obj.WasmBool + case types.TPTR: + if wasmElemTypeAllowed(t.Elem()) { + wfs[i].Type = obj.WasmPtr + break + } + fallthrough + default: + base.ErrorfAt(f.Pos(), 0, "%s: unsupported result type %s", pragma, t.String()) + } + wfs[i].Offset = p.FrameOffset(result) + } + return wfs +} + +// wasmElemTypeAllowed reports whether t is allowed to be passed in memory +// (as a pointer's element type, a field of it, etc.) between the Go wasm +// module and the host. +func wasmElemTypeAllowed(t *types.Type) bool { + switch t.Kind() { + case types.TINT8, types.TUINT8, types.TINT16, types.TUINT16, + types.TINT32, types.TUINT32, types.TINT64, types.TUINT64, + types.TFLOAT32, types.TFLOAT64, types.TBOOL: + return true + case types.TARRAY: + return wasmElemTypeAllowed(t.Elem()) + case types.TSTRUCT: + if len(t.Fields()) == 0 { + return true + } + seenHostLayout := false + for _, f := range t.Fields() { + sym := f.Type.Sym() + if sym != nil && sym.Name == "HostLayout" && sym.Pkg.Path == "structs" { + seenHostLayout = true + continue + } + if !wasmElemTypeAllowed(f.Type) { + return false + } + } + return seenHostLayout + } + // Pointer, and all pointerful types are not allowed, as pointers have + // different width on the Go side and the host side. (It will be allowed + // on GOARCH=wasm32.) + return false +} + +// setupWasmImport calculates the params and results in terms of WebAssembly values for the given function, +// and sets up the wasmimport metadata. +func setupWasmImport(f *ir.Func) { + wi := obj.WasmImport{ + Module: f.WasmImport.Module, + Name: f.WasmImport.Name, + } + if wi.Module == wasm.GojsModule { + // Functions that are imported from the "gojs" module use a special + // ABI that just accepts the stack pointer. + // Example: + // + // //go:wasmimport gojs add + // func importedAdd(a, b uint) uint + // + // will roughly become + // + // (import "gojs" "add" (func (param i32))) + wi.Params = []obj.WasmField{{Type: obj.WasmI32}} + } else { + // All other imported functions use the normal WASM ABI. + // Example: + // + // //go:wasmimport a_module add + // func importedAdd(a, b uint) uint + // + // will roughly become + // + // (import "a_module" "add" (func (param i32 i32) (result i32))) + abiConfig := AbiForBodylessFuncStackMap(f) + abiInfo := abiConfig.ABIAnalyzeFuncType(f.Type()) + wi.Params = paramsToWasmFields(f, "go:wasmimport", abiInfo, abiInfo.InParams()) + wi.Results = resultsToWasmFields(f, "go:wasmimport", abiInfo, abiInfo.OutParams()) + } + f.LSym.Func().WasmImport = &wi +} + +// setupWasmExport calculates the params and results in terms of WebAssembly values for the given function, +// and sets up the wasmexport metadata. +func setupWasmExport(f, wrapped *ir.Func) { + we := obj.WasmExport{ + WrappedSym: wrapped.LSym, + } + abiConfig := AbiForBodylessFuncStackMap(wrapped) + abiInfo := abiConfig.ABIAnalyzeFuncType(wrapped.Type()) + we.Params = paramsToWasmFields(wrapped, "go:wasmexport", abiInfo, abiInfo.InParams()) + we.Results = resultsToWasmFields(wrapped, "go:wasmexport", abiInfo, abiInfo.OutParams()) + f.LSym.Func().WasmExport = &we +} diff --git a/go/src/cmd/compile/internal/ssagen/arch.go b/go/src/cmd/compile/internal/ssagen/arch.go new file mode 100644 index 0000000000000000000000000000000000000000..ef5d8f59d7168a8bc0c3c9f62d1fd4cf471f6089 --- /dev/null +++ b/go/src/cmd/compile/internal/ssagen/arch.go @@ -0,0 +1,56 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssagen + +import ( + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/ssa" + "cmd/compile/internal/types" + "cmd/internal/obj" +) + +var Arch ArchInfo + +// interface to back end + +type ArchInfo struct { + LinkArch *obj.LinkArch + + REGSP int + MAXWIDTH int64 + SoftFloat bool + + PadFrame func(int64) int64 + + // ZeroRange zeroes a range of memory the on stack. + // - it is only called at function entry + // - it is ok to clobber (non-arg) registers. + // - currently used only for small things, so it can be simple. + // - pointers to heap-allocated return values + // - open-coded deferred functions + // (Max size in make.bash is 40 bytes.) + ZeroRange func(*objw.Progs, *obj.Prog, int64, int64, *uint32) *obj.Prog + + Ginsnop func(*objw.Progs) *obj.Prog + + // SSAMarkMoves marks any MOVXconst ops that need to avoid clobbering flags. + SSAMarkMoves func(*State, *ssa.Block) + + // SSAGenValue emits Prog(s) for the Value. + SSAGenValue func(*State, *ssa.Value) + + // SSAGenBlock emits end-of-block Progs. SSAGenValue should be called + // for all values in the block before SSAGenBlock. + SSAGenBlock func(s *State, b, next *ssa.Block) + + // LoadRegResult emits instructions that loads register-assigned result + // at n+off (n is PPARAMOUT) to register reg. The result is already in + // memory. Used in open-coded defer return path. + LoadRegResult func(s *State, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog + + // SpillArgReg emits instructions that spill reg to n+off. + SpillArgReg func(pp *objw.Progs, p *obj.Prog, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog +} diff --git a/go/src/cmd/compile/internal/ssagen/intrinsics.go b/go/src/cmd/compile/internal/ssagen/intrinsics.go new file mode 100644 index 0000000000000000000000000000000000000000..e2eebd783d5f76442b1aa84b0d82e7dc6ff7e1d0 --- /dev/null +++ b/go/src/cmd/compile/internal/ssagen/intrinsics.go @@ -0,0 +1,2260 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssagen + +import ( + "fmt" + "internal/abi" + "internal/buildcfg" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/ssa" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/sys" +) + +var intrinsics intrinsicBuilders + +// An intrinsicBuilder converts a call node n into an ssa value that +// implements that call as an intrinsic. args is a list of arguments to the func. +type intrinsicBuilder func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value + +type intrinsicKey struct { + arch *sys.Arch + pkg string + fn string +} + +// intrinsicBuildConfig specifies the config to use for intrinsic building. +type intrinsicBuildConfig struct { + instrumenting bool + + go386 string + goamd64 int + goarm buildcfg.GoarmFeatures + goarm64 buildcfg.Goarm64Features + gomips string + gomips64 string + goppc64 int + goriscv64 int +} + +type intrinsicBuilders map[intrinsicKey]intrinsicBuilder + +// add adds the intrinsic builder b for pkg.fn for the given architecture. +func (ib intrinsicBuilders) add(arch *sys.Arch, pkg, fn string, b intrinsicBuilder) { + if _, found := ib[intrinsicKey{arch, pkg, fn}]; found { + panic(fmt.Sprintf("intrinsic already exists for %v.%v on %v", pkg, fn, arch.Name)) + } + ib[intrinsicKey{arch, pkg, fn}] = b +} + +// addForArchs adds the intrinsic builder b for pkg.fn for the given architectures. +func (ib intrinsicBuilders) addForArchs(pkg, fn string, b intrinsicBuilder, archs ...*sys.Arch) { + for _, arch := range archs { + ib.add(arch, pkg, fn, b) + } +} + +// addForFamilies does the same as addForArchs but operates on architecture families. +func (ib intrinsicBuilders) addForFamilies(pkg, fn string, b intrinsicBuilder, archFamilies ...sys.ArchFamily) { + for _, arch := range sys.Archs { + if arch.InFamily(archFamilies...) { + intrinsics.add(arch, pkg, fn, b) + } + } +} + +// alias aliases pkg.fn to targetPkg.targetFn for all architectures in archs +// for which targetPkg.targetFn already exists. +func (ib intrinsicBuilders) alias(pkg, fn, targetPkg, targetFn string, archs ...*sys.Arch) { + // TODO(jsing): Consider making this work even if the alias is added + // before the intrinsic. + aliased := false + for _, arch := range archs { + if b := intrinsics.lookup(arch, targetPkg, targetFn); b != nil { + intrinsics.add(arch, pkg, fn, b) + aliased = true + } + } + if !aliased { + panic(fmt.Sprintf("attempted to alias undefined intrinsic: %s.%s", pkg, fn)) + } +} + +// lookup looks up the intrinsic for a pkg.fn on the specified architecture. +func (ib intrinsicBuilders) lookup(arch *sys.Arch, pkg, fn string) intrinsicBuilder { + return intrinsics[intrinsicKey{arch, pkg, fn}] +} + +func initIntrinsics(cfg *intrinsicBuildConfig) { + if cfg == nil { + cfg = &intrinsicBuildConfig{ + instrumenting: base.Flag.Cfg.Instrumenting, + go386: buildcfg.GO386, + goamd64: buildcfg.GOAMD64, + goarm: buildcfg.GOARM, + goarm64: buildcfg.GOARM64, + gomips: buildcfg.GOMIPS, + gomips64: buildcfg.GOMIPS64, + goppc64: buildcfg.GOPPC64, + goriscv64: buildcfg.GORISCV64, + } + } + intrinsics = intrinsicBuilders{} + + var p4 []*sys.Arch + var p8 []*sys.Arch + var lwatomics []*sys.Arch + for _, a := range sys.Archs { + if a.PtrSize == 4 { + p4 = append(p4, a) + } else { + p8 = append(p8, a) + } + if a.Family != sys.PPC64 { + lwatomics = append(lwatomics, a) + } + } + all := sys.Archs[:] + + add := func(pkg, fn string, b intrinsicBuilder, archs ...*sys.Arch) { + intrinsics.addForArchs(pkg, fn, b, archs...) + } + addF := func(pkg, fn string, b intrinsicBuilder, archFamilies ...sys.ArchFamily) { + intrinsics.addForFamilies(pkg, fn, b, archFamilies...) + } + alias := func(pkg, fn, pkg2, fn2 string, archs ...*sys.Arch) { + intrinsics.alias(pkg, fn, pkg2, fn2, archs...) + } + + /******** runtime ********/ + if !cfg.instrumenting { + add("runtime", "slicebytetostringtmp", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + // Compiler frontend optimizations emit OBYTES2STRTMP nodes + // for the backend instead of slicebytetostringtmp calls + // when not instrumenting. + return s.newValue2(ssa.OpStringMake, n.Type(), args[0], args[1]) + }, + all...) + } + addF("internal/runtime/math", "MulUintptr", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + if s.config.PtrSize == 4 { + return s.newValue2(ssa.OpMul32uover, types.NewTuple(types.Types[types.TUINT], types.Types[types.TUINT]), args[0], args[1]) + } + return s.newValue2(ssa.OpMul64uover, types.NewTuple(types.Types[types.TUINT], types.Types[types.TUINT]), args[0], args[1]) + }, + sys.AMD64, sys.I386, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.ARM64) + add("runtime", "KeepAlive", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + data := s.newValue1(ssa.OpIData, s.f.Config.Types.BytePtr, args[0]) + s.vars[memVar] = s.newValue2(ssa.OpKeepAlive, types.TypeMem, data, s.mem()) + return nil + }, + all...) + + addF("runtime", "publicationBarrier", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue1(ssa.OpPubBarrier, types.TypeMem, s.mem()) + return nil + }, + sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64) + + /******** internal/runtime/sys ********/ + add("internal/runtime/sys", "GetCallerPC", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue0(ssa.OpGetCallerPC, s.f.Config.Types.Uintptr) + }, + all...) + + add("internal/runtime/sys", "GetCallerSP", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpGetCallerSP, s.f.Config.Types.Uintptr, s.mem()) + }, + all...) + + add("internal/runtime/sys", "GetClosurePtr", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue0(ssa.OpGetClosurePtr, s.f.Config.Types.Uintptr) + }, + all...) + + addF("internal/runtime/sys", "Bswap32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBswap32, types.Types[types.TUINT32], args[0]) + }, + sys.AMD64, sys.I386, sys.ARM64, sys.ARM, sys.Loong64, sys.S390X) + addF("internal/runtime/sys", "Bswap64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBswap64, types.Types[types.TUINT64], args[0]) + }, + sys.AMD64, sys.I386, sys.ARM64, sys.ARM, sys.Loong64, sys.S390X) + + addF("runtime", "memequal", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue4(ssa.OpMemEq, s.f.Config.Types.Bool, args[0], args[1], args[2], s.mem()) + }, + sys.ARM64) + + if cfg.goppc64 >= 10 { + // Use only on Power10 as the new byte reverse instructions that Power10 provide + // make it worthwhile as an intrinsic + addF("internal/runtime/sys", "Bswap32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBswap32, types.Types[types.TUINT32], args[0]) + }, + sys.PPC64) + addF("internal/runtime/sys", "Bswap64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBswap64, types.Types[types.TUINT64], args[0]) + }, + sys.PPC64) + } + + if cfg.goriscv64 >= 22 { + addF("internal/runtime/sys", "Bswap32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBswap32, types.Types[types.TUINT32], args[0]) + }, + sys.RISCV64) + addF("internal/runtime/sys", "Bswap64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBswap64, types.Types[types.TUINT64], args[0]) + }, + sys.RISCV64) + } + + /****** Prefetch ******/ + makePrefetchFunc := func(op ssa.Op) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue2(op, types.TypeMem, args[0], s.mem()) + return nil + } + } + + // Make Prefetch intrinsics for supported platforms + // On the unsupported platforms stub function will be eliminated + addF("internal/runtime/sys", "Prefetch", makePrefetchFunc(ssa.OpPrefetchCache), + sys.AMD64, sys.ARM64, sys.Loong64, sys.PPC64) + addF("internal/runtime/sys", "PrefetchStreamed", makePrefetchFunc(ssa.OpPrefetchCacheStreamed), + sys.AMD64, sys.ARM64, sys.Loong64, sys.PPC64) + + /******** internal/runtime/atomic ********/ + type atomicOpEmitter func(s *state, n *ir.CallExpr, args []*ssa.Value, op ssa.Op, typ types.Kind, needReturn bool) + + addF("internal/runtime/atomic", "Load", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue2(ssa.OpAtomicLoad32, types.NewTuple(types.Types[types.TUINT32], types.TypeMem), args[0], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT32], v) + }, + sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "Load8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue2(ssa.OpAtomicLoad8, types.NewTuple(types.Types[types.TUINT8], types.TypeMem), args[0], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT8], v) + }, + sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "Load64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue2(ssa.OpAtomicLoad64, types.NewTuple(types.Types[types.TUINT64], types.TypeMem), args[0], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT64], v) + }, + sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "LoadAcq", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue2(ssa.OpAtomicLoadAcq32, types.NewTuple(types.Types[types.TUINT32], types.TypeMem), args[0], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT32], v) + }, + sys.PPC64) + addF("internal/runtime/atomic", "LoadAcq64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue2(ssa.OpAtomicLoadAcq64, types.NewTuple(types.Types[types.TUINT64], types.TypeMem), args[0], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT64], v) + }, + sys.PPC64) + addF("internal/runtime/atomic", "Loadp", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue2(ssa.OpAtomicLoadPtr, types.NewTuple(s.f.Config.Types.BytePtr, types.TypeMem), args[0], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, s.f.Config.Types.BytePtr, v) + }, + sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + + addF("internal/runtime/atomic", "Store", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicStore32, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.AMD64, sys.ARM64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "Store8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicStore8, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.AMD64, sys.ARM64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "Store64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicStore64, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.AMD64, sys.ARM64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "StorepNoWB", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicStorePtrNoWB, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "StoreRel", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicStoreRel32, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.PPC64) + addF("internal/runtime/atomic", "StoreRel64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicStoreRel64, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.PPC64) + + makeAtomicStoreGuardedIntrinsicLoong64 := func(op0, op1 ssa.Op, typ types.Kind, emit atomicOpEmitter) intrinsicBuilder { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + // Target Atomic feature is identified by dynamic detection + addr := s.entryNewValue1A(ssa.OpAddr, types.Types[types.TBOOL].PtrTo(), ir.Syms.Loong64HasLAM_BH, s.sb) + v := s.load(types.Types[types.TBOOL], addr) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(v) + bTrue := s.f.NewBlock(ssa.BlockPlain) + bFalse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bTrue) + b.AddEdgeTo(bFalse) + b.Likely = ssa.BranchLikely + + // We have atomic instructions - use it directly. + s.startBlock(bTrue) + emit(s, n, args, op1, typ, false) + s.endBlock().AddEdgeTo(bEnd) + + // Use original instruction sequence. + s.startBlock(bFalse) + emit(s, n, args, op0, typ, false) + s.endBlock().AddEdgeTo(bEnd) + + // Merge results. + s.startBlock(bEnd) + + return nil + } + } + + atomicStoreEmitterLoong64 := func(s *state, n *ir.CallExpr, args []*ssa.Value, op ssa.Op, typ types.Kind, needReturn bool) { + v := s.newValue3(op, types.NewTuple(types.Types[typ], types.TypeMem), args[0], args[1], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + if needReturn { + s.vars[n] = s.newValue1(ssa.OpSelect0, types.Types[typ], v) + } + } + + addF("internal/runtime/atomic", "Store8", + makeAtomicStoreGuardedIntrinsicLoong64(ssa.OpAtomicStore8, ssa.OpAtomicStore8Variant, types.TUINT8, atomicStoreEmitterLoong64), + sys.Loong64) + addF("internal/runtime/atomic", "Store", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicStore32Variant, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.Loong64) + addF("internal/runtime/atomic", "Store64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicStore64Variant, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.Loong64) + + addF("internal/runtime/atomic", "Xchg8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue3(ssa.OpAtomicExchange8, types.NewTuple(types.Types[types.TUINT8], types.TypeMem), args[0], args[1], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT8], v) + }, + sys.AMD64, sys.PPC64) + addF("internal/runtime/atomic", "Xchg", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue3(ssa.OpAtomicExchange32, types.NewTuple(types.Types[types.TUINT32], types.TypeMem), args[0], args[1], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT32], v) + }, + sys.AMD64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "Xchg64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue3(ssa.OpAtomicExchange64, types.NewTuple(types.Types[types.TUINT64], types.TypeMem), args[0], args[1], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT64], v) + }, + sys.AMD64, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + + makeAtomicGuardedIntrinsicARM64common := func(op0, op1 ssa.Op, typ types.Kind, emit atomicOpEmitter, needReturn bool) intrinsicBuilder { + + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + if cfg.goarm64.LSE { + emit(s, n, args, op1, typ, needReturn) + } else { + // Target Atomic feature is identified by dynamic detection + addr := s.entryNewValue1A(ssa.OpAddr, types.Types[types.TBOOL].PtrTo(), ir.Syms.ARM64HasATOMICS, s.sb) + v := s.load(types.Types[types.TBOOL], addr) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(v) + bTrue := s.f.NewBlock(ssa.BlockPlain) + bFalse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bTrue) + b.AddEdgeTo(bFalse) + b.Likely = ssa.BranchLikely + + // We have atomic instructions - use it directly. + s.startBlock(bTrue) + emit(s, n, args, op1, typ, needReturn) + s.endBlock().AddEdgeTo(bEnd) + + // Use original instruction sequence. + s.startBlock(bFalse) + emit(s, n, args, op0, typ, needReturn) + s.endBlock().AddEdgeTo(bEnd) + + // Merge results. + s.startBlock(bEnd) + } + if needReturn { + return s.variable(n, types.Types[typ]) + } else { + return nil + } + } + } + makeAtomicGuardedIntrinsicARM64 := func(op0, op1 ssa.Op, typ types.Kind, emit atomicOpEmitter) intrinsicBuilder { + return makeAtomicGuardedIntrinsicARM64common(op0, op1, typ, emit, true) + } + makeAtomicGuardedIntrinsicARM64old := func(op0, op1 ssa.Op, typ types.Kind, emit atomicOpEmitter) intrinsicBuilder { + return makeAtomicGuardedIntrinsicARM64common(op0, op1, typ, emit, false) + } + + atomicEmitterARM64 := func(s *state, n *ir.CallExpr, args []*ssa.Value, op ssa.Op, typ types.Kind, needReturn bool) { + v := s.newValue3(op, types.NewTuple(types.Types[typ], types.TypeMem), args[0], args[1], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + if needReturn { + s.vars[n] = s.newValue1(ssa.OpSelect0, types.Types[typ], v) + } + } + addF("internal/runtime/atomic", "Xchg8", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicExchange8, ssa.OpAtomicExchange8Variant, types.TUINT8, atomicEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "Xchg", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicExchange32, ssa.OpAtomicExchange32Variant, types.TUINT32, atomicEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "Xchg64", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicExchange64, ssa.OpAtomicExchange64Variant, types.TUINT64, atomicEmitterARM64), + sys.ARM64) + + makeAtomicXchg8GuardedIntrinsicLoong64 := func(op ssa.Op) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + addr := s.entryNewValue1A(ssa.OpAddr, types.Types[types.TBOOL].PtrTo(), ir.Syms.Loong64HasLAM_BH, s.sb) + v := s.load(types.Types[types.TBOOL], addr) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(v) + bTrue := s.f.NewBlock(ssa.BlockPlain) + bFalse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bTrue) + b.AddEdgeTo(bFalse) + b.Likely = ssa.BranchLikely // most loong64 machines support the amswapdb.b + + // We have the intrinsic - use it directly. + s.startBlock(bTrue) + s.vars[n] = s.newValue3(op, types.NewTuple(types.Types[types.TUINT8], types.TypeMem), args[0], args[1], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, s.vars[n]) + s.vars[n] = s.newValue1(ssa.OpSelect0, types.Types[types.TUINT8], s.vars[n]) + s.endBlock().AddEdgeTo(bEnd) + + // Call the pure Go version. + s.startBlock(bFalse) + s.vars[n] = s.callResult(n, callNormal) // types.Types[TUINT8] + s.endBlock().AddEdgeTo(bEnd) + + // Merge results. + s.startBlock(bEnd) + return s.variable(n, types.Types[types.TUINT8]) + } + } + addF("internal/runtime/atomic", "Xchg8", + makeAtomicXchg8GuardedIntrinsicLoong64(ssa.OpAtomicExchange8Variant), + sys.Loong64) + + addF("internal/runtime/atomic", "Xadd", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue3(ssa.OpAtomicAdd32, types.NewTuple(types.Types[types.TUINT32], types.TypeMem), args[0], args[1], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT32], v) + }, + sys.AMD64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "Xadd64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue3(ssa.OpAtomicAdd64, types.NewTuple(types.Types[types.TUINT64], types.TypeMem), args[0], args[1], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT64], v) + }, + sys.AMD64, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + + addF("internal/runtime/atomic", "Xadd", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicAdd32, ssa.OpAtomicAdd32Variant, types.TUINT32, atomicEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "Xadd64", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicAdd64, ssa.OpAtomicAdd64Variant, types.TUINT64, atomicEmitterARM64), + sys.ARM64) + + addF("internal/runtime/atomic", "Cas", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue4(ssa.OpAtomicCompareAndSwap32, types.NewTuple(types.Types[types.TBOOL], types.TypeMem), args[0], args[1], args[2], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TBOOL], v) + }, + sys.AMD64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "Cas64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue4(ssa.OpAtomicCompareAndSwap64, types.NewTuple(types.Types[types.TBOOL], types.TypeMem), args[0], args[1], args[2], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TBOOL], v) + }, + sys.AMD64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "CasRel", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue4(ssa.OpAtomicCompareAndSwap32, types.NewTuple(types.Types[types.TBOOL], types.TypeMem), args[0], args[1], args[2], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + return s.newValue1(ssa.OpSelect0, types.Types[types.TBOOL], v) + }, + sys.PPC64) + + atomicCasEmitterARM64 := func(s *state, n *ir.CallExpr, args []*ssa.Value, op ssa.Op, typ types.Kind, needReturn bool) { + v := s.newValue4(op, types.NewTuple(types.Types[types.TBOOL], types.TypeMem), args[0], args[1], args[2], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + if needReturn { + s.vars[n] = s.newValue1(ssa.OpSelect0, types.Types[typ], v) + } + } + + addF("internal/runtime/atomic", "Cas", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicCompareAndSwap32, ssa.OpAtomicCompareAndSwap32Variant, types.TBOOL, atomicCasEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "Cas64", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicCompareAndSwap64, ssa.OpAtomicCompareAndSwap64Variant, types.TBOOL, atomicCasEmitterARM64), + sys.ARM64) + + atomicCasEmitterLoong64 := func(s *state, n *ir.CallExpr, args []*ssa.Value, op ssa.Op, typ types.Kind, needReturn bool) { + v := s.newValue4(op, types.NewTuple(types.Types[types.TBOOL], types.TypeMem), args[0], args[1], args[2], s.mem()) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) + if needReturn { + s.vars[n] = s.newValue1(ssa.OpSelect0, types.Types[typ], v) + } + } + + makeAtomicCasGuardedIntrinsicLoong64 := func(op0, op1 ssa.Op, emit atomicOpEmitter) intrinsicBuilder { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + // Target Atomic feature is identified by dynamic detection + addr := s.entryNewValue1A(ssa.OpAddr, types.Types[types.TBOOL].PtrTo(), ir.Syms.Loong64HasLAMCAS, s.sb) + v := s.load(types.Types[types.TBOOL], addr) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(v) + bTrue := s.f.NewBlock(ssa.BlockPlain) + bFalse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bTrue) + b.AddEdgeTo(bFalse) + b.Likely = ssa.BranchLikely + + // We have atomic instructions - use it directly. + s.startBlock(bTrue) + emit(s, n, args, op1, types.TBOOL, true) + s.endBlock().AddEdgeTo(bEnd) + + // Use original instruction sequence. + s.startBlock(bFalse) + emit(s, n, args, op0, types.TBOOL, true) + s.endBlock().AddEdgeTo(bEnd) + + // Merge results. + s.startBlock(bEnd) + + return s.variable(n, types.Types[types.TBOOL]) + } + } + + addF("internal/runtime/atomic", "Cas", + makeAtomicCasGuardedIntrinsicLoong64(ssa.OpAtomicCompareAndSwap32, ssa.OpAtomicCompareAndSwap32Variant, atomicCasEmitterLoong64), + sys.Loong64) + addF("internal/runtime/atomic", "Cas64", + makeAtomicCasGuardedIntrinsicLoong64(ssa.OpAtomicCompareAndSwap64, ssa.OpAtomicCompareAndSwap64Variant, atomicCasEmitterLoong64), + sys.Loong64) + + // Old-style atomic logical operation API (all supported archs except arm64). + addF("internal/runtime/atomic", "And8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicAnd8, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.AMD64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "And", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicAnd32, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.AMD64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "Or8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicOr8, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.AMD64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("internal/runtime/atomic", "Or", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue3(ssa.OpAtomicOr32, types.TypeMem, args[0], args[1], s.mem()) + return nil + }, + sys.AMD64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) + + // arm64 always uses the new-style atomic logical operations, for both the + // old and new style API. + addF("internal/runtime/atomic", "And8", + makeAtomicGuardedIntrinsicARM64old(ssa.OpAtomicAnd8value, ssa.OpAtomicAnd8valueVariant, types.TUINT8, atomicEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "Or8", + makeAtomicGuardedIntrinsicARM64old(ssa.OpAtomicOr8value, ssa.OpAtomicOr8valueVariant, types.TUINT8, atomicEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "And64", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicAnd64value, ssa.OpAtomicAnd64valueVariant, types.TUINT64, atomicEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "And32", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicAnd32value, ssa.OpAtomicAnd32valueVariant, types.TUINT32, atomicEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "And", + makeAtomicGuardedIntrinsicARM64old(ssa.OpAtomicAnd32value, ssa.OpAtomicAnd32valueVariant, types.TUINT32, atomicEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "Or64", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicOr64value, ssa.OpAtomicOr64valueVariant, types.TUINT64, atomicEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "Or32", + makeAtomicGuardedIntrinsicARM64(ssa.OpAtomicOr32value, ssa.OpAtomicOr32valueVariant, types.TUINT32, atomicEmitterARM64), + sys.ARM64) + addF("internal/runtime/atomic", "Or", + makeAtomicGuardedIntrinsicARM64old(ssa.OpAtomicOr32value, ssa.OpAtomicOr32valueVariant, types.TUINT32, atomicEmitterARM64), + sys.ARM64) + + // New-style atomic logical operations, which return the old memory value. + addF("internal/runtime/atomic", "And64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue3(ssa.OpAtomicAnd64value, types.NewTuple(types.Types[types.TUINT64], types.TypeMem), args[0], args[1], s.mem()) + p0, p1 := s.split(v) + s.vars[memVar] = p1 + return p0 + }, + sys.AMD64, sys.Loong64) + addF("internal/runtime/atomic", "And32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue3(ssa.OpAtomicAnd32value, types.NewTuple(types.Types[types.TUINT32], types.TypeMem), args[0], args[1], s.mem()) + p0, p1 := s.split(v) + s.vars[memVar] = p1 + return p0 + }, + sys.AMD64, sys.Loong64) + addF("internal/runtime/atomic", "Or64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue3(ssa.OpAtomicOr64value, types.NewTuple(types.Types[types.TUINT64], types.TypeMem), args[0], args[1], s.mem()) + p0, p1 := s.split(v) + s.vars[memVar] = p1 + return p0 + }, + sys.AMD64, sys.Loong64) + addF("internal/runtime/atomic", "Or32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v := s.newValue3(ssa.OpAtomicOr32value, types.NewTuple(types.Types[types.TUINT32], types.TypeMem), args[0], args[1], s.mem()) + p0, p1 := s.split(v) + s.vars[memVar] = p1 + return p0 + }, + sys.AMD64, sys.Loong64) + + // Aliases for atomic load operations + alias("internal/runtime/atomic", "Loadint32", "internal/runtime/atomic", "Load", all...) + alias("internal/runtime/atomic", "Loadint64", "internal/runtime/atomic", "Load64", all...) + alias("internal/runtime/atomic", "Loaduintptr", "internal/runtime/atomic", "Load", p4...) + alias("internal/runtime/atomic", "Loaduintptr", "internal/runtime/atomic", "Load64", p8...) + alias("internal/runtime/atomic", "Loaduint", "internal/runtime/atomic", "Load", p4...) + alias("internal/runtime/atomic", "Loaduint", "internal/runtime/atomic", "Load64", p8...) + alias("internal/runtime/atomic", "LoadAcq", "internal/runtime/atomic", "Load", lwatomics...) + alias("internal/runtime/atomic", "LoadAcq64", "internal/runtime/atomic", "Load64", lwatomics...) + alias("internal/runtime/atomic", "LoadAcquintptr", "internal/runtime/atomic", "LoadAcq", p4...) + alias("sync", "runtime_LoadAcquintptr", "internal/runtime/atomic", "LoadAcq", p4...) // linknamed + alias("internal/runtime/atomic", "LoadAcquintptr", "internal/runtime/atomic", "LoadAcq64", p8...) + alias("sync", "runtime_LoadAcquintptr", "internal/runtime/atomic", "LoadAcq64", p8...) // linknamed + + // Aliases for atomic store operations + alias("internal/runtime/atomic", "Storeint32", "internal/runtime/atomic", "Store", all...) + alias("internal/runtime/atomic", "Storeint64", "internal/runtime/atomic", "Store64", all...) + alias("internal/runtime/atomic", "Storeuintptr", "internal/runtime/atomic", "Store", p4...) + alias("internal/runtime/atomic", "Storeuintptr", "internal/runtime/atomic", "Store64", p8...) + alias("internal/runtime/atomic", "StoreRel", "internal/runtime/atomic", "Store", lwatomics...) + alias("internal/runtime/atomic", "StoreRel64", "internal/runtime/atomic", "Store64", lwatomics...) + alias("internal/runtime/atomic", "StoreReluintptr", "internal/runtime/atomic", "StoreRel", p4...) + alias("sync", "runtime_StoreReluintptr", "internal/runtime/atomic", "StoreRel", p4...) // linknamed + alias("internal/runtime/atomic", "StoreReluintptr", "internal/runtime/atomic", "StoreRel64", p8...) + alias("sync", "runtime_StoreReluintptr", "internal/runtime/atomic", "StoreRel64", p8...) // linknamed + + // Aliases for atomic swap operations + alias("internal/runtime/atomic", "Xchgint32", "internal/runtime/atomic", "Xchg", all...) + alias("internal/runtime/atomic", "Xchgint64", "internal/runtime/atomic", "Xchg64", all...) + alias("internal/runtime/atomic", "Xchguintptr", "internal/runtime/atomic", "Xchg", p4...) + alias("internal/runtime/atomic", "Xchguintptr", "internal/runtime/atomic", "Xchg64", p8...) + + // Aliases for atomic add operations + alias("internal/runtime/atomic", "Xaddint32", "internal/runtime/atomic", "Xadd", all...) + alias("internal/runtime/atomic", "Xaddint64", "internal/runtime/atomic", "Xadd64", all...) + alias("internal/runtime/atomic", "Xadduintptr", "internal/runtime/atomic", "Xadd", p4...) + alias("internal/runtime/atomic", "Xadduintptr", "internal/runtime/atomic", "Xadd64", p8...) + + // Aliases for atomic CAS operations + alias("internal/runtime/atomic", "Casint32", "internal/runtime/atomic", "Cas", all...) + alias("internal/runtime/atomic", "Casint64", "internal/runtime/atomic", "Cas64", all...) + alias("internal/runtime/atomic", "Casuintptr", "internal/runtime/atomic", "Cas", p4...) + alias("internal/runtime/atomic", "Casuintptr", "internal/runtime/atomic", "Cas64", p8...) + alias("internal/runtime/atomic", "Casp1", "internal/runtime/atomic", "Cas", p4...) + alias("internal/runtime/atomic", "Casp1", "internal/runtime/atomic", "Cas64", p8...) + alias("internal/runtime/atomic", "CasRel", "internal/runtime/atomic", "Cas", lwatomics...) + + // Aliases for atomic And/Or operations + alias("internal/runtime/atomic", "Anduintptr", "internal/runtime/atomic", "And64", sys.ArchARM64, sys.ArchLoong64) + alias("internal/runtime/atomic", "Oruintptr", "internal/runtime/atomic", "Or64", sys.ArchARM64, sys.ArchLoong64) + + /******** math ********/ + addF("math", "sqrt", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpSqrt, types.Types[types.TFLOAT64], args[0]) + }, + sys.I386, sys.AMD64, sys.ARM, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X, sys.Wasm) + addF("math", "Trunc", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpTrunc, types.Types[types.TFLOAT64], args[0]) + }, + sys.ARM64, sys.PPC64, sys.S390X, sys.Wasm) + addF("math", "Ceil", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpCeil, types.Types[types.TFLOAT64], args[0]) + }, + sys.ARM64, sys.PPC64, sys.S390X, sys.Wasm) + addF("math", "Floor", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpFloor, types.Types[types.TFLOAT64], args[0]) + }, + sys.ARM64, sys.PPC64, sys.S390X, sys.Wasm) + addF("math", "Round", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpRound, types.Types[types.TFLOAT64], args[0]) + }, + sys.ARM64, sys.PPC64, sys.S390X) + addF("math", "RoundToEven", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpRoundToEven, types.Types[types.TFLOAT64], args[0]) + }, + sys.ARM64, sys.S390X, sys.Wasm) + addF("math", "Abs", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpAbs, types.Types[types.TFLOAT64], args[0]) + }, + sys.ARM64, sys.ARM, sys.Loong64, sys.PPC64, sys.RISCV64, sys.Wasm, sys.MIPS, sys.MIPS64) + addF("math", "Copysign", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue2(ssa.OpCopysign, types.Types[types.TFLOAT64], args[0], args[1]) + }, + sys.Loong64, sys.PPC64, sys.RISCV64, sys.Wasm) + addF("math", "FMA", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue3(ssa.OpFMA, types.Types[types.TFLOAT64], args[0], args[1], args[2]) + }, + sys.ARM64, sys.Loong64, sys.PPC64, sys.RISCV64, sys.S390X) + addF("math", "FMA", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + if cfg.goamd64 >= 3 { + return s.newValue3(ssa.OpFMA, types.Types[types.TFLOAT64], args[0], args[1], args[2]) + } + + v := s.entryNewValue0A(ssa.OpHasCPUFeature, types.Types[types.TBOOL], ir.Syms.X86HasFMA) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(v) + bTrue := s.f.NewBlock(ssa.BlockPlain) + bFalse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bTrue) + b.AddEdgeTo(bFalse) + b.Likely = ssa.BranchLikely // >= haswell cpus are common + + // We have the intrinsic - use it directly. + s.startBlock(bTrue) + s.vars[n] = s.newValue3(ssa.OpFMA, types.Types[types.TFLOAT64], args[0], args[1], args[2]) + s.endBlock().AddEdgeTo(bEnd) + + // Call the pure Go version. + s.startBlock(bFalse) + s.vars[n] = s.callResult(n, callNormal) // types.Types[TFLOAT64] + s.endBlock().AddEdgeTo(bEnd) + + // Merge results. + s.startBlock(bEnd) + return s.variable(n, types.Types[types.TFLOAT64]) + }, + sys.AMD64) + addF("math", "FMA", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + addr := s.entryNewValue1A(ssa.OpAddr, types.Types[types.TBOOL].PtrTo(), ir.Syms.ARMHasVFPv4, s.sb) + v := s.load(types.Types[types.TBOOL], addr) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(v) + bTrue := s.f.NewBlock(ssa.BlockPlain) + bFalse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bTrue) + b.AddEdgeTo(bFalse) + b.Likely = ssa.BranchLikely + + // We have the intrinsic - use it directly. + s.startBlock(bTrue) + s.vars[n] = s.newValue3(ssa.OpFMA, types.Types[types.TFLOAT64], args[0], args[1], args[2]) + s.endBlock().AddEdgeTo(bEnd) + + // Call the pure Go version. + s.startBlock(bFalse) + s.vars[n] = s.callResult(n, callNormal) // types.Types[TFLOAT64] + s.endBlock().AddEdgeTo(bEnd) + + // Merge results. + s.startBlock(bEnd) + return s.variable(n, types.Types[types.TFLOAT64]) + }, + sys.ARM) + + makeRoundAMD64 := func(op ssa.Op) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + if cfg.goamd64 >= 2 { + return s.newValue1(op, types.Types[types.TFLOAT64], args[0]) + } + + v := s.entryNewValue0A(ssa.OpHasCPUFeature, types.Types[types.TBOOL], ir.Syms.X86HasSSE41) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(v) + bTrue := s.f.NewBlock(ssa.BlockPlain) + bFalse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bTrue) + b.AddEdgeTo(bFalse) + b.Likely = ssa.BranchLikely // most machines have sse4.1 nowadays + + // We have the intrinsic - use it directly. + s.startBlock(bTrue) + s.vars[n] = s.newValue1(op, types.Types[types.TFLOAT64], args[0]) + s.endBlock().AddEdgeTo(bEnd) + + // Call the pure Go version. + s.startBlock(bFalse) + s.vars[n] = s.callResult(n, callNormal) // types.Types[TFLOAT64] + s.endBlock().AddEdgeTo(bEnd) + + // Merge results. + s.startBlock(bEnd) + return s.variable(n, types.Types[types.TFLOAT64]) + } + } + addF("math", "RoundToEven", + makeRoundAMD64(ssa.OpRoundToEven), + sys.AMD64) + addF("math", "Floor", + makeRoundAMD64(ssa.OpFloor), + sys.AMD64) + addF("math", "Ceil", + makeRoundAMD64(ssa.OpCeil), + sys.AMD64) + addF("math", "Trunc", + makeRoundAMD64(ssa.OpTrunc), + sys.AMD64) + + /******** math/bits ********/ + addF("math/bits", "TrailingZeros64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpCtz64, types.Types[types.TINT], args[0]) + }, + sys.AMD64, sys.ARM64, sys.ARM, sys.Loong64, sys.S390X, sys.MIPS, sys.PPC64, sys.Wasm) + addF("math/bits", "TrailingZeros64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + lo := s.newValue1(ssa.OpInt64Lo, types.Types[types.TUINT32], args[0]) + hi := s.newValue1(ssa.OpInt64Hi, types.Types[types.TUINT32], args[0]) + return s.newValue2(ssa.OpCtz64On32, types.Types[types.TINT], lo, hi) + }, + sys.I386) + addF("math/bits", "TrailingZeros32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpCtz32, types.Types[types.TINT], args[0]) + }, + sys.AMD64, sys.I386, sys.ARM64, sys.ARM, sys.Loong64, sys.S390X, sys.MIPS, sys.PPC64, sys.Wasm) + addF("math/bits", "TrailingZeros16", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpCtz16, types.Types[types.TINT], args[0]) + }, + sys.AMD64, sys.ARM, sys.ARM64, sys.I386, sys.MIPS, sys.Loong64, sys.PPC64, sys.S390X, sys.Wasm) + addF("math/bits", "TrailingZeros8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpCtz8, types.Types[types.TINT], args[0]) + }, + sys.AMD64, sys.ARM, sys.ARM64, sys.I386, sys.MIPS, sys.Loong64, sys.PPC64, sys.S390X, sys.Wasm) + + if cfg.goriscv64 >= 22 { + addF("math/bits", "TrailingZeros64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpCtz64, types.Types[types.TINT], args[0]) + }, + sys.RISCV64) + addF("math/bits", "TrailingZeros32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpCtz32, types.Types[types.TINT], args[0]) + }, + sys.RISCV64) + addF("math/bits", "TrailingZeros16", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpCtz16, types.Types[types.TINT], args[0]) + }, + sys.RISCV64) + addF("math/bits", "TrailingZeros8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpCtz8, types.Types[types.TINT], args[0]) + }, + sys.RISCV64) + } + + // ReverseBytes inlines correctly, no need to intrinsify it. + alias("math/bits", "ReverseBytes64", "internal/runtime/sys", "Bswap64", all...) + alias("math/bits", "ReverseBytes32", "internal/runtime/sys", "Bswap32", all...) + // Nothing special is needed for targets where ReverseBytes16 lowers to a rotate + addF("math/bits", "ReverseBytes16", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBswap16, types.Types[types.TUINT16], args[0]) + }, + sys.Loong64) + if cfg.goppc64 >= 10 { + // On Power10, 16-bit rotate is not available so use BRH instruction + addF("math/bits", "ReverseBytes16", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBswap16, types.Types[types.TUINT], args[0]) + }, + sys.PPC64) + } + if cfg.goriscv64 >= 22 { + addF("math/bits", "ReverseBytes16", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBswap16, types.Types[types.TUINT16], args[0]) + }, + sys.RISCV64) + } + + addF("math/bits", "Len64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitLen64, types.Types[types.TINT], args[0]) + }, + sys.AMD64, sys.ARM, sys.ARM64, sys.Loong64, sys.MIPS, sys.PPC64, sys.S390X, sys.Wasm) + addF("math/bits", "Len32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitLen32, types.Types[types.TINT], args[0]) + }, + sys.AMD64, sys.ARM, sys.ARM64, sys.Loong64, sys.MIPS, sys.PPC64, sys.S390X, sys.Wasm) + addF("math/bits", "Len16", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitLen16, types.Types[types.TINT], args[0]) + }, + sys.AMD64, sys.ARM, sys.ARM64, sys.Loong64, sys.MIPS, sys.PPC64, sys.S390X, sys.Wasm) + addF("math/bits", "Len8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitLen8, types.Types[types.TINT], args[0]) + }, + sys.AMD64, sys.ARM, sys.ARM64, sys.Loong64, sys.MIPS, sys.PPC64, sys.S390X, sys.Wasm) + + if cfg.goriscv64 >= 22 { + addF("math/bits", "Len64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitLen64, types.Types[types.TINT], args[0]) + }, + sys.RISCV64) + addF("math/bits", "Len32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitLen32, types.Types[types.TINT], args[0]) + }, + sys.RISCV64) + addF("math/bits", "Len16", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitLen16, types.Types[types.TINT], args[0]) + }, + sys.RISCV64) + addF("math/bits", "Len8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitLen8, types.Types[types.TINT], args[0]) + }, + sys.RISCV64) + } + + alias("math/bits", "Len", "math/bits", "Len64", p8...) + alias("math/bits", "Len", "math/bits", "Len32", p4...) + + // LeadingZeros is handled because it trivially calls Len. + addF("math/bits", "Reverse64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitRev64, types.Types[types.TINT], args[0]) + }, + sys.ARM64, sys.Loong64) + addF("math/bits", "Reverse32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitRev32, types.Types[types.TINT], args[0]) + }, + sys.ARM64, sys.Loong64) + addF("math/bits", "Reverse16", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitRev16, types.Types[types.TINT], args[0]) + }, + sys.ARM64, sys.Loong64) + addF("math/bits", "Reverse8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitRev8, types.Types[types.TINT], args[0]) + }, + sys.ARM64, sys.Loong64) + addF("math/bits", "Reverse", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpBitRev64, types.Types[types.TINT], args[0]) + }, + sys.ARM64, sys.Loong64) + addF("math/bits", "RotateLeft8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue2(ssa.OpRotateLeft8, types.Types[types.TUINT8], args[0], args[1]) + }, + sys.AMD64, sys.RISCV64) + addF("math/bits", "RotateLeft16", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue2(ssa.OpRotateLeft16, types.Types[types.TUINT16], args[0], args[1]) + }, + sys.AMD64, sys.RISCV64) + addF("math/bits", "RotateLeft32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue2(ssa.OpRotateLeft32, types.Types[types.TUINT32], args[0], args[1]) + }, + sys.AMD64, sys.ARM, sys.ARM64, sys.Loong64, sys.PPC64, sys.RISCV64, sys.S390X, sys.Wasm) + addF("math/bits", "RotateLeft64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue2(ssa.OpRotateLeft64, types.Types[types.TUINT64], args[0], args[1]) + }, + sys.AMD64, sys.ARM64, sys.Loong64, sys.PPC64, sys.RISCV64, sys.S390X, sys.Wasm) + alias("math/bits", "RotateLeft", "math/bits", "RotateLeft64", p8...) + + makeOnesCountAMD64 := func(op ssa.Op) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + if cfg.goamd64 >= 2 { + return s.newValue1(op, types.Types[types.TINT], args[0]) + } + + v := s.entryNewValue0A(ssa.OpHasCPUFeature, types.Types[types.TBOOL], ir.Syms.X86HasPOPCNT) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(v) + bTrue := s.f.NewBlock(ssa.BlockPlain) + bFalse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bTrue) + b.AddEdgeTo(bFalse) + b.Likely = ssa.BranchLikely // most machines have popcnt nowadays + + // We have the intrinsic - use it directly. + s.startBlock(bTrue) + s.vars[n] = s.newValue1(op, types.Types[types.TINT], args[0]) + s.endBlock().AddEdgeTo(bEnd) + + // Call the pure Go version. + s.startBlock(bFalse) + s.vars[n] = s.callResult(n, callNormal) // types.Types[TINT] + s.endBlock().AddEdgeTo(bEnd) + + // Merge results. + s.startBlock(bEnd) + return s.variable(n, types.Types[types.TINT]) + } + } + + makeOnesCountLoong64 := func(op ssa.Op) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + addr := s.entryNewValue1A(ssa.OpAddr, types.Types[types.TBOOL].PtrTo(), ir.Syms.Loong64HasLSX, s.sb) + v := s.load(types.Types[types.TBOOL], addr) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(v) + bTrue := s.f.NewBlock(ssa.BlockPlain) + bFalse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bTrue) + b.AddEdgeTo(bFalse) + b.Likely = ssa.BranchLikely // most loong64 machines support the LSX + + // We have the intrinsic - use it directly. + s.startBlock(bTrue) + s.vars[n] = s.newValue1(op, types.Types[types.TINT], args[0]) + s.endBlock().AddEdgeTo(bEnd) + + // Call the pure Go version. + s.startBlock(bFalse) + s.vars[n] = s.callResult(n, callNormal) // types.Types[TINT] + s.endBlock().AddEdgeTo(bEnd) + + // Merge results. + s.startBlock(bEnd) + return s.variable(n, types.Types[types.TINT]) + } + } + + makeOnesCountRISCV64 := func(op ssa.Op) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + if cfg.goriscv64 >= 22 { + return s.newValue1(op, types.Types[types.TINT], args[0]) + } + + addr := s.entryNewValue1A(ssa.OpAddr, types.Types[types.TBOOL].PtrTo(), ir.Syms.RISCV64HasZbb, s.sb) + v := s.load(types.Types[types.TBOOL], addr) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(v) + bTrue := s.f.NewBlock(ssa.BlockPlain) + bFalse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bTrue) + b.AddEdgeTo(bFalse) + b.Likely = ssa.BranchLikely // Majority of RISC-V support Zbb. + + // We have the intrinsic - use it directly. + s.startBlock(bTrue) + s.vars[n] = s.newValue1(op, types.Types[types.TINT], args[0]) + s.endBlock().AddEdgeTo(bEnd) + + // Call the pure Go version. + s.startBlock(bFalse) + s.vars[n] = s.callResult(n, callNormal) // types.Types[TINT] + s.endBlock().AddEdgeTo(bEnd) + + // Merge results. + s.startBlock(bEnd) + return s.variable(n, types.Types[types.TINT]) + } + } + + addF("math/bits", "OnesCount64", + makeOnesCountAMD64(ssa.OpPopCount64), + sys.AMD64) + addF("math/bits", "OnesCount64", + makeOnesCountLoong64(ssa.OpPopCount64), + sys.Loong64) + addF("math/bits", "OnesCount64", + makeOnesCountRISCV64(ssa.OpPopCount64), + sys.RISCV64) + addF("math/bits", "OnesCount64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpPopCount64, types.Types[types.TINT], args[0]) + }, + sys.PPC64, sys.ARM64, sys.S390X, sys.Wasm) + addF("math/bits", "OnesCount32", + makeOnesCountAMD64(ssa.OpPopCount32), + sys.AMD64) + addF("math/bits", "OnesCount32", + makeOnesCountLoong64(ssa.OpPopCount32), + sys.Loong64) + addF("math/bits", "OnesCount32", + makeOnesCountRISCV64(ssa.OpPopCount32), + sys.RISCV64) + addF("math/bits", "OnesCount32", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpPopCount32, types.Types[types.TINT], args[0]) + }, + sys.PPC64, sys.ARM64, sys.S390X, sys.Wasm) + addF("math/bits", "OnesCount16", + makeOnesCountAMD64(ssa.OpPopCount16), + sys.AMD64) + addF("math/bits", "OnesCount16", + makeOnesCountLoong64(ssa.OpPopCount16), + sys.Loong64) + addF("math/bits", "OnesCount16", + makeOnesCountRISCV64(ssa.OpPopCount16), + sys.RISCV64) + addF("math/bits", "OnesCount16", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpPopCount16, types.Types[types.TINT], args[0]) + }, + sys.ARM64, sys.S390X, sys.PPC64, sys.Wasm) + addF("math/bits", "OnesCount8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpPopCount8, types.Types[types.TINT], args[0]) + }, + sys.S390X, sys.PPC64, sys.Wasm) + + if cfg.goriscv64 >= 22 { + addF("math/bits", "OnesCount8", + makeOnesCountRISCV64(ssa.OpPopCount8), + sys.RISCV64) + } + + alias("math/bits", "OnesCount", "math/bits", "OnesCount64", p8...) + + add("math/bits", "Mul64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue2(ssa.OpMul64uhilo, types.NewTuple(types.Types[types.TUINT64], types.Types[types.TUINT64]), args[0], args[1]) + }, + all...) + alias("math/bits", "Mul", "math/bits", "Mul64", p8...) + alias("internal/runtime/math", "Mul64", "math/bits", "Mul64", p8...) + addF("math/bits", "Add64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue3(ssa.OpAdd64carry, types.NewTuple(types.Types[types.TUINT64], types.Types[types.TUINT64]), args[0], args[1], args[2]) + }, + sys.AMD64, sys.ARM64, sys.PPC64, sys.S390X, sys.RISCV64, sys.Loong64, sys.MIPS64) + alias("math/bits", "Add", "math/bits", "Add64", p8...) + alias("internal/runtime/math", "Add64", "math/bits", "Add64", all...) + addF("math/bits", "Sub64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue3(ssa.OpSub64borrow, types.NewTuple(types.Types[types.TUINT64], types.Types[types.TUINT64]), args[0], args[1], args[2]) + }, + sys.AMD64, sys.ARM64, sys.PPC64, sys.S390X, sys.RISCV64, sys.Loong64, sys.MIPS64) + alias("math/bits", "Sub", "math/bits", "Sub64", p8...) + addF("math/bits", "Div64", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + // check for divide-by-zero/overflow and panic with appropriate message + cmpZero := s.newValue2(s.ssaOp(ir.ONE, types.Types[types.TUINT64]), types.Types[types.TBOOL], args[2], s.zeroVal(types.Types[types.TUINT64])) + s.check(cmpZero, ir.Syms.Panicdivide) + cmpOverflow := s.newValue2(s.ssaOp(ir.OLT, types.Types[types.TUINT64]), types.Types[types.TBOOL], args[0], args[2]) + s.check(cmpOverflow, ir.Syms.Panicoverflow) + return s.newValue3(ssa.OpDiv128u, types.NewTuple(types.Types[types.TUINT64], types.Types[types.TUINT64]), args[0], args[1], args[2]) + }, + sys.AMD64) + alias("math/bits", "Div", "math/bits", "Div64", sys.ArchAMD64) + + alias("internal/runtime/sys", "TrailingZeros8", "math/bits", "TrailingZeros8", all...) + alias("internal/runtime/sys", "TrailingZeros32", "math/bits", "TrailingZeros32", all...) + alias("internal/runtime/sys", "TrailingZeros64", "math/bits", "TrailingZeros64", all...) + alias("internal/runtime/sys", "Len8", "math/bits", "Len8", all...) + alias("internal/runtime/sys", "Len64", "math/bits", "Len64", all...) + alias("internal/runtime/sys", "OnesCount64", "math/bits", "OnesCount64", all...) + + /******** sync/atomic ********/ + + // Note: these are disabled by flag_race in findIntrinsic below. + alias("sync/atomic", "LoadInt32", "internal/runtime/atomic", "Load", all...) + alias("sync/atomic", "LoadInt64", "internal/runtime/atomic", "Load64", all...) + alias("sync/atomic", "LoadPointer", "internal/runtime/atomic", "Loadp", all...) + alias("sync/atomic", "LoadUint32", "internal/runtime/atomic", "Load", all...) + alias("sync/atomic", "LoadUint64", "internal/runtime/atomic", "Load64", all...) + alias("sync/atomic", "LoadUintptr", "internal/runtime/atomic", "Load", p4...) + alias("sync/atomic", "LoadUintptr", "internal/runtime/atomic", "Load64", p8...) + + alias("sync/atomic", "StoreInt32", "internal/runtime/atomic", "Store", all...) + alias("sync/atomic", "StoreInt64", "internal/runtime/atomic", "Store64", all...) + // Note: not StorePointer, that needs a write barrier. Same below for {CompareAnd}Swap. + alias("sync/atomic", "StoreUint32", "internal/runtime/atomic", "Store", all...) + alias("sync/atomic", "StoreUint64", "internal/runtime/atomic", "Store64", all...) + alias("sync/atomic", "StoreUintptr", "internal/runtime/atomic", "Store", p4...) + alias("sync/atomic", "StoreUintptr", "internal/runtime/atomic", "Store64", p8...) + + alias("sync/atomic", "SwapInt32", "internal/runtime/atomic", "Xchg", all...) + alias("sync/atomic", "SwapInt64", "internal/runtime/atomic", "Xchg64", all...) + alias("sync/atomic", "SwapUint32", "internal/runtime/atomic", "Xchg", all...) + alias("sync/atomic", "SwapUint64", "internal/runtime/atomic", "Xchg64", all...) + alias("sync/atomic", "SwapUintptr", "internal/runtime/atomic", "Xchg", p4...) + alias("sync/atomic", "SwapUintptr", "internal/runtime/atomic", "Xchg64", p8...) + + alias("sync/atomic", "CompareAndSwapInt32", "internal/runtime/atomic", "Cas", all...) + alias("sync/atomic", "CompareAndSwapInt64", "internal/runtime/atomic", "Cas64", all...) + alias("sync/atomic", "CompareAndSwapUint32", "internal/runtime/atomic", "Cas", all...) + alias("sync/atomic", "CompareAndSwapUint64", "internal/runtime/atomic", "Cas64", all...) + alias("sync/atomic", "CompareAndSwapUintptr", "internal/runtime/atomic", "Cas", p4...) + alias("sync/atomic", "CompareAndSwapUintptr", "internal/runtime/atomic", "Cas64", p8...) + + alias("sync/atomic", "AddInt32", "internal/runtime/atomic", "Xadd", all...) + alias("sync/atomic", "AddInt64", "internal/runtime/atomic", "Xadd64", all...) + alias("sync/atomic", "AddUint32", "internal/runtime/atomic", "Xadd", all...) + alias("sync/atomic", "AddUint64", "internal/runtime/atomic", "Xadd64", all...) + alias("sync/atomic", "AddUintptr", "internal/runtime/atomic", "Xadd", p4...) + alias("sync/atomic", "AddUintptr", "internal/runtime/atomic", "Xadd64", p8...) + + alias("sync/atomic", "AndInt32", "internal/runtime/atomic", "And32", sys.ArchARM64, sys.ArchAMD64, sys.ArchLoong64) + alias("sync/atomic", "AndUint32", "internal/runtime/atomic", "And32", sys.ArchARM64, sys.ArchAMD64, sys.ArchLoong64) + alias("sync/atomic", "AndInt64", "internal/runtime/atomic", "And64", sys.ArchARM64, sys.ArchAMD64, sys.ArchLoong64) + alias("sync/atomic", "AndUint64", "internal/runtime/atomic", "And64", sys.ArchARM64, sys.ArchAMD64, sys.ArchLoong64) + alias("sync/atomic", "AndUintptr", "internal/runtime/atomic", "And64", sys.ArchARM64, sys.ArchAMD64, sys.ArchLoong64) + alias("sync/atomic", "OrInt32", "internal/runtime/atomic", "Or32", sys.ArchARM64, sys.ArchAMD64, sys.ArchLoong64) + alias("sync/atomic", "OrUint32", "internal/runtime/atomic", "Or32", sys.ArchARM64, sys.ArchAMD64, sys.ArchLoong64) + alias("sync/atomic", "OrInt64", "internal/runtime/atomic", "Or64", sys.ArchARM64, sys.ArchAMD64, sys.ArchLoong64) + alias("sync/atomic", "OrUint64", "internal/runtime/atomic", "Or64", sys.ArchARM64, sys.ArchAMD64, sys.ArchLoong64) + alias("sync/atomic", "OrUintptr", "internal/runtime/atomic", "Or64", sys.ArchARM64, sys.ArchAMD64, sys.ArchLoong64) + + /******** math/big ********/ + alias("math/big", "mulWW", "math/bits", "Mul64", p8...) + + /******** internal/runtime/maps ********/ + + // Important: The intrinsic implementations below return a packed + // bitset, while the portable Go implementation uses an unpacked + // representation (one bit set in each byte). + // + // Thus we must replace most bitset methods with implementations that + // work with the packed representation. + // + // TODO(prattmic): The bitset implementations don't use SIMD, so they + // could be handled with build tags (though that would break + // -d=ssa/intrinsics/off=1). + + // With a packed representation we no longer need to shift the result + // of TrailingZeros64. + alias("internal/runtime/maps", "bitsetFirst", "internal/runtime/sys", "TrailingZeros64", sys.ArchAMD64) + + addF("internal/runtime/maps", "bitsetRemoveBelow", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + b := args[0] + i := args[1] + + // Clear the lower i bits in b. + // + // out = b &^ ((1 << i) - 1) + + one := s.constInt64(types.Types[types.TUINT64], 1) + + mask := s.newValue2(ssa.OpLsh8x8, types.Types[types.TUINT64], one, i) + mask = s.newValue2(ssa.OpSub64, types.Types[types.TUINT64], mask, one) + mask = s.newValue1(ssa.OpCom64, types.Types[types.TUINT64], mask) + + return s.newValue2(ssa.OpAnd64, types.Types[types.TUINT64], b, mask) + }, + sys.AMD64) + + addF("internal/runtime/maps", "bitsetLowestSet", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + b := args[0] + + // Test the lowest bit in b. + // + // out = (b & 1) == 1 + + one := s.constInt64(types.Types[types.TUINT64], 1) + and := s.newValue2(ssa.OpAnd64, types.Types[types.TUINT64], b, one) + return s.newValue2(ssa.OpEq64, types.Types[types.TBOOL], and, one) + }, + sys.AMD64) + + addF("internal/runtime/maps", "bitsetShiftOutLowest", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + b := args[0] + + // Right shift out the lowest bit in b. + // + // out = b >> 1 + + one := s.constInt64(types.Types[types.TUINT64], 1) + return s.newValue2(ssa.OpRsh64Ux64, types.Types[types.TUINT64], b, one) + }, + sys.AMD64) + + addF("internal/runtime/maps", "ctrlGroupMatchH2", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + g := args[0] + h := args[1] + + // Explicit copies to fp registers. See + // https://go.dev/issue/70451. + gfp := s.newValue1(ssa.OpAMD64MOVQi2f, types.TypeInt128, g) + hfp := s.newValue1(ssa.OpAMD64MOVQi2f, types.TypeInt128, h) + + // Broadcast h2 into each byte of a word. + var broadcast *ssa.Value + if buildcfg.GOAMD64 >= 4 { + // VPBROADCASTB saves 1 instruction vs PSHUFB + // because the input can come from a GP + // register, while PSHUFB requires moving into + // an FP register first. + // + // Nominally PSHUFB would require a second + // additional instruction to load the control + // mask into a FP register. But broadcast uses + // a control mask of 0, and the register ABI + // already defines X15 as a zero register. + broadcast = s.newValue1(ssa.OpAMD64VPBROADCASTB, types.TypeInt128, h) // use gp copy of h + } else if buildcfg.GOAMD64 >= 2 { + // PSHUFB performs a byte broadcast when given + // a control input of 0. + broadcast = s.newValue1(ssa.OpAMD64PSHUFBbroadcast, types.TypeInt128, hfp) + } else { + // No direct byte broadcast. First we must + // duplicate the lower byte and then do a + // 16-bit broadcast. + + // "Unpack" h2 with itself. This duplicates the + // input, resulting in h2 in the lower two + // bytes. + unpack := s.newValue2(ssa.OpAMD64PUNPCKLBW, types.TypeInt128, hfp, hfp) + + // Copy the lower 16-bits of unpack into every + // 16-bit slot in the lower 64-bits of the + // output register. Note that immediate 0 + // selects the low word as the source for every + // destination slot. + broadcast = s.newValue1I(ssa.OpAMD64PSHUFLW, types.TypeInt128, 0, unpack) + + // No need to broadcast into the upper 64-bits, + // as we don't use those. + } + + // Compare each byte of the control word with h2. Each + // matching byte has every bit set. + eq := s.newValue2(ssa.OpAMD64PCMPEQB, types.TypeInt128, broadcast, gfp) + + // Construct a "byte mask": each output bit is equal to + // the sign bit each input byte. + // + // This results in a packed output (bit N set means + // byte N matched). + // + // NOTE: See comment above on bitsetFirst. + out := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT16], eq) + + // g is only 64-bits so the upper 64-bits of the + // 128-bit register will be zero. If h2 is also zero, + // then we'll get matches on those bytes. Truncate the + // upper bits to ignore such matches. + ret := s.newValue1(ssa.OpZeroExt8to64, types.Types[types.TUINT64], out) + + return ret + }, + sys.AMD64) + + addF("internal/runtime/maps", "ctrlGroupMatchEmpty", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + // An empty slot is 1000 0000 + // A deleted slot is 1111 1110 + // A full slot is 0??? ???? + + g := args[0] + + // Explicit copy to fp register. See + // https://go.dev/issue/70451. + gfp := s.newValue1(ssa.OpAMD64MOVQi2f, types.TypeInt128, g) + + if buildcfg.GOAMD64 >= 2 { + // "PSIGNB negates each data element of the + // destination operand (the first operand) if + // the signed integer value of the + // corresponding data element in the source + // operand (the second operand) is less than + // zero. If the signed integer value of a data + // element in the source operand is positive, + // the corresponding data element in the + // destination operand is unchanged. If a data + // element in the source operand is zero, the + // corresponding data element in the + // destination operand is set to zero" - Intel SDM + // + // If we pass the group control word as both + // arguments: + // - Full slots are unchanged. + // - Deleted slots are negated, becoming + // 0000 0010. + // - Empty slots are negated, becoming + // 1000 0000 (unchanged!). + // + // The result is that only empty slots have the + // sign bit set. We then use PMOVMSKB to + // extract the sign bits. + sign := s.newValue2(ssa.OpAMD64PSIGNB, types.TypeInt128, gfp, gfp) + + // Construct a "byte mask": each output bit is + // equal to the sign bit each input byte. The + // sign bit is only set for empty or deleted + // slots. + // + // This results in a packed output (bit N set + // means byte N matched). + // + // NOTE: See comment above on bitsetFirst. + ret := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT16], sign) + + // g is only 64-bits so the upper 64-bits of + // the 128-bit register will be zero. PSIGNB + // will keep all of these bytes zero, so no + // need to truncate. + + return ret + } + + // No PSIGNB, simply do byte equality with ctrlEmpty. + + // Load ctrlEmpty into each byte of a control word. + var ctrlsEmpty uint64 = abi.MapCtrlEmpty + e := s.constInt64(types.Types[types.TUINT64], int64(ctrlsEmpty)) + // Explicit copy to fp register. See + // https://go.dev/issue/70451. + efp := s.newValue1(ssa.OpAMD64MOVQi2f, types.TypeInt128, e) + + // Compare each byte of the control word with ctrlEmpty. Each + // matching byte has every bit set. + eq := s.newValue2(ssa.OpAMD64PCMPEQB, types.TypeInt128, efp, gfp) + + // Construct a "byte mask": each output bit is equal to + // the sign bit each input byte. + // + // This results in a packed output (bit N set means + // byte N matched). + // + // NOTE: See comment above on bitsetFirst. + out := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT16], eq) + + // g is only 64-bits so the upper 64-bits of the + // 128-bit register will be zero. The upper 64-bits of + // efp are also zero, so we'll get matches on those + // bytes. Truncate the upper bits to ignore such + // matches. + return s.newValue1(ssa.OpZeroExt8to64, types.Types[types.TUINT64], out) + }, + sys.AMD64) + + addF("internal/runtime/maps", "ctrlGroupMatchEmptyOrDeleted", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + // An empty slot is 1000 0000 + // A deleted slot is 1111 1110 + // A full slot is 0??? ???? + // + // A slot is empty or deleted iff bit 7 (sign bit) is + // set. + + g := args[0] + + // Explicit copy to fp register. See + // https://go.dev/issue/70451. + gfp := s.newValue1(ssa.OpAMD64MOVQi2f, types.TypeInt128, g) + + // Construct a "byte mask": each output bit is equal to + // the sign bit each input byte. The sign bit is only + // set for empty or deleted slots. + // + // This results in a packed output (bit N set means + // byte N matched). + // + // NOTE: See comment above on bitsetFirst. + ret := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT16], gfp) + + // g is only 64-bits so the upper 64-bits of the + // 128-bit register will be zero. Zero will never match + // ctrlEmpty or ctrlDeleted, so no need to truncate. + + return ret + }, + sys.AMD64) + + addF("internal/runtime/maps", "ctrlGroupMatchFull", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + // An empty slot is 1000 0000 + // A deleted slot is 1111 1110 + // A full slot is 0??? ???? + // + // A slot is full iff bit 7 (sign bit) is unset. + + g := args[0] + + // Explicit copy to fp register. See + // https://go.dev/issue/70451. + gfp := s.newValue1(ssa.OpAMD64MOVQi2f, types.TypeInt128, g) + + // Construct a "byte mask": each output bit is equal to + // the sign bit each input byte. The sign bit is only + // set for empty or deleted slots. + // + // This results in a packed output (bit N set means + // byte N matched). + // + // NOTE: See comment above on bitsetFirst. + mask := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT16], gfp) + + // Invert the mask to set the bits for the full slots. + out := s.newValue1(ssa.OpCom16, types.Types[types.TUINT16], mask) + + // g is only 64-bits so the upper 64-bits of the + // 128-bit register will be zero, with bit 7 unset. + // Truncate the upper bits to ignore these. + return s.newValue1(ssa.OpZeroExt8to64, types.Types[types.TUINT64], out) + }, + sys.AMD64) + + /******** crypto/internal/constanttime ********/ + // We implement a superset of the Select promise: + // Select returns x if v != 0 and y if v == 0. + add("crypto/internal/constanttime", "Select", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + v, x, y := args[0], args[1], args[2] + + var checkOp ssa.Op + var zero *ssa.Value + switch s.config.PtrSize { + case 8: + checkOp = ssa.OpNeq64 + zero = s.constInt64(types.Types[types.TINT], 0) + case 4: + checkOp = ssa.OpNeq32 + zero = s.constInt32(types.Types[types.TINT], 0) + default: + panic("unreachable") + } + check := s.newValue2(checkOp, types.Types[types.TBOOL], zero, v) + + return s.newValue3(ssa.OpCondSelect, types.Types[types.TINT], x, y, check) + }, + sys.ArchAMD64, sys.ArchARM64, sys.ArchLoong64, sys.ArchPPC64, sys.ArchPPC64LE, sys.ArchWasm) // all with CMOV support. + add("crypto/internal/constanttime", "boolToUint8", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(ssa.OpCvtBoolToUint8, types.Types[types.TUINT8], args[0]) + }, + all...) + + if buildcfg.Experiment.SIMD { + // Only enable intrinsics, if SIMD experiment. + simdIntrinsics(addF) + + addF(simdPackage, "ClearAVXUpperBits", + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + s.vars[memVar] = s.newValue1(ssa.OpAMD64VZEROUPPER, types.TypeMem, s.mem()) + return nil + }, + sys.AMD64) + + addF(simdPackage, "Int8x16.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Int16x8.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Int32x4.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Int64x2.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Uint8x16.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Uint16x8.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Uint32x4.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Uint64x2.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Int8x32.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Int16x16.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Int32x8.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Int64x4.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Uint8x32.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Uint16x16.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Uint32x8.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Uint64x4.IsZero", opLen1(ssa.OpIsZeroVec, types.Types[types.TBOOL]), sys.AMD64) + addF(simdPackage, "Float32x4.IsNaN", opLen1(ssa.OpIsNaNFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.IsNaN", opLen1(ssa.OpIsNaNFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.IsNaN", opLen1(ssa.OpIsNaNFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.IsNaN", opLen1(ssa.OpIsNaNFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.IsNaN", opLen1(ssa.OpIsNaNFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.IsNaN", opLen1(ssa.OpIsNaNFloat64x8, types.TypeVec512), sys.AMD64) + + // sfp4 is intrinsic-if-constant, but otherwise it's complicated enough to just implement in Go. + sfp4 := func(method string, hwop ssa.Op, vectype *types.Type) { + addF(simdPackage, method, + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + x, a, b, c, d, y := args[0], args[1], args[2], args[3], args[4], args[5] + if a.Op == ssa.OpConst8 && b.Op == ssa.OpConst8 && c.Op == ssa.OpConst8 && d.Op == ssa.OpConst8 { + z := select4FromPair(x, a, b, c, d, y, s, hwop, vectype) + if z != nil { + return z + } + } + return s.callResult(n, callNormal) + }, + sys.AMD64) + } + + sfp4("Int32x4.SelectFromPair", ssa.OpconcatSelectedConstantInt32x4, types.TypeVec128) + sfp4("Uint32x4.SelectFromPair", ssa.OpconcatSelectedConstantUint32x4, types.TypeVec128) + sfp4("Float32x4.SelectFromPair", ssa.OpconcatSelectedConstantFloat32x4, types.TypeVec128) + + sfp4("Int32x8.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedInt32x8, types.TypeVec256) + sfp4("Uint32x8.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedUint32x8, types.TypeVec256) + sfp4("Float32x8.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedFloat32x8, types.TypeVec256) + + sfp4("Int32x16.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedInt32x16, types.TypeVec512) + sfp4("Uint32x16.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedUint32x16, types.TypeVec512) + sfp4("Float32x16.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedFloat32x16, types.TypeVec512) + + // sfp2 is intrinsic-if-constant, but otherwise it's complicated enough to just implement in Go. + sfp2 := func(method string, hwop ssa.Op, vectype *types.Type, cscimm func(i, j uint8) int64) { + addF(simdPackage, method, + func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + x, a, b, y := args[0], args[1], args[2], args[3] + if a.Op == ssa.OpConst8 && b.Op == ssa.OpConst8 { + z := select2FromPair(x, a, b, y, s, hwop, vectype, cscimm) + if z != nil { + return z + } + } + return s.callResult(n, callNormal) + }, + sys.AMD64) + } + + sfp2("Uint64x2.SelectFromPair", ssa.OpconcatSelectedConstantUint64x2, types.TypeVec128, cscimm2) + sfp2("Int64x2.SelectFromPair", ssa.OpconcatSelectedConstantInt64x2, types.TypeVec128, cscimm2) + sfp2("Float64x2.SelectFromPair", ssa.OpconcatSelectedConstantFloat64x2, types.TypeVec128, cscimm2) + + sfp2("Uint64x4.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedUint64x4, types.TypeVec256, cscimm2g2) + sfp2("Int64x4.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedInt64x4, types.TypeVec256, cscimm2g2) + sfp2("Float64x4.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedFloat64x4, types.TypeVec256, cscimm2g2) + + sfp2("Uint64x8.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedUint64x8, types.TypeVec512, cscimm2g4) + sfp2("Int64x8.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedInt64x8, types.TypeVec512, cscimm2g4) + sfp2("Float64x8.SelectFromPairGrouped", ssa.OpconcatSelectedConstantGroupedFloat64x8, types.TypeVec512, cscimm2g4) + + } +} + +func cscimm4(a, b, c, d uint8) int64 { + return se(a + b<<2 + c<<4 + d<<6) +} + +func cscimm2(a, b uint8) int64 { + return se(a + b<<1) +} + +func cscimm2g2(a, b uint8) int64 { + g := cscimm2(a, b) + return int64(int8(g + g<<2)) +} + +func cscimm2g4(a, b uint8) int64 { + g := cscimm2g2(a, b) + return int64(int8(g + g<<4)) +} + +const ( + _LLLL = iota + _HLLL + _LHLL + _HHLL + _LLHL + _HLHL + _LHHL + _HHHL + _LLLH + _HLLH + _LHLH + _HHLH + _LLHH + _HLHH + _LHHH + _HHHH +) + +const ( + _LL = iota + _HL + _LH + _HH +) + +func select2FromPair(x, _a, _b, y *ssa.Value, s *state, op ssa.Op, t *types.Type, csc func(a, b uint8) int64) *ssa.Value { + a, b := uint8(_a.AuxInt8()), uint8(_b.AuxInt8()) + if a > 3 || b > 3 { + return nil + } + pattern := (a&2)>>1 + (b & 2) + a, b = a&1, b&1 + + switch pattern { + case _LL: + return s.newValue2I(op, t, csc(a, b), x, x) + case _HH: + return s.newValue2I(op, t, csc(a, b), y, y) + case _LH: + return s.newValue2I(op, t, csc(a, b), x, y) + case _HL: + return s.newValue2I(op, t, csc(a, b), y, x) + } + panic("The preceding switch should have been exhaustive") +} + +func select4FromPair(x, _a, _b, _c, _d, y *ssa.Value, s *state, op ssa.Op, t *types.Type) *ssa.Value { + a, b, c, d := uint8(_a.AuxInt8()), uint8(_b.AuxInt8()), uint8(_c.AuxInt8()), uint8(_d.AuxInt8()) + if a > 7 || b > 7 || c > 7 || d > 7 { + return nil + } + pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1 + + a, b, c, d = a&3, b&3, c&3, d&3 + + switch pattern { + case _LLLL: + // TODO DETECT 0,1,2,3, 0,0,0,0 + return s.newValue2I(op, t, cscimm4(a, b, c, d), x, x) + case _HHHH: + // TODO DETECT 0,1,2,3, 0,0,0,0 + return s.newValue2I(op, t, cscimm4(a, b, c, d), y, y) + case _LLHH: + return s.newValue2I(op, t, cscimm4(a, b, c, d), x, y) + case _HHLL: + return s.newValue2I(op, t, cscimm4(a, b, c, d), y, x) + + case _HLLL: + z := s.newValue2I(op, t, cscimm4(a, a, b, b), y, x) + return s.newValue2I(op, t, cscimm4(0, 2, c, d), z, x) + case _LHLL: + z := s.newValue2I(op, t, cscimm4(a, a, b, b), x, y) + return s.newValue2I(op, t, cscimm4(0, 2, c, d), z, x) + case _HLHH: + z := s.newValue2I(op, t, cscimm4(a, a, b, b), y, x) + return s.newValue2I(op, t, cscimm4(0, 2, c, d), z, y) + case _LHHH: + z := s.newValue2I(op, t, cscimm4(a, a, b, b), x, y) + return s.newValue2I(op, t, cscimm4(0, 2, c, d), z, y) + + case _LLLH: + z := s.newValue2I(op, t, cscimm4(c, c, d, d), x, y) + return s.newValue2I(op, t, cscimm4(a, b, 0, 2), x, z) + case _LLHL: + z := s.newValue2I(op, t, cscimm4(c, c, d, d), y, x) + return s.newValue2I(op, t, cscimm4(a, b, 0, 2), x, z) + + case _HHLH: + z := s.newValue2I(op, t, cscimm4(c, c, d, d), x, y) + return s.newValue2I(op, t, cscimm4(a, b, 0, 2), y, z) + + case _HHHL: + z := s.newValue2I(op, t, cscimm4(c, c, d, d), y, x) + return s.newValue2I(op, t, cscimm4(a, b, 0, 2), y, z) + + case _LHLH: + z := s.newValue2I(op, t, cscimm4(a, c, b, d), x, y) + return s.newValue2I(op, t, se(0b11_01_10_00), z, z) + case _HLHL: + z := s.newValue2I(op, t, cscimm4(b, d, a, c), x, y) + return s.newValue2I(op, t, se(0b01_11_00_10), z, z) + case _HLLH: + z := s.newValue2I(op, t, cscimm4(b, c, a, d), x, y) + return s.newValue2I(op, t, se(0b11_01_00_10), z, z) + case _LHHL: + z := s.newValue2I(op, t, cscimm4(a, d, b, c), x, y) + return s.newValue2I(op, t, se(0b01_11_10_00), z, z) + } + panic("The preceding switch should have been exhaustive") +} + +// se smears the not-really-a-sign bit of a uint8 to conform to the conventions +// for representing AuxInt in ssa. +func se(x uint8) int64 { + return int64(int8(x)) +} + +func opLen1(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue1(op, t, args[0]) + } +} + +func opLen2(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue2(op, t, args[0], args[1]) + } +} + +func opLen2_21(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue2(op, t, args[1], args[0]) + } +} + +func opLen3(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue3(op, t, args[0], args[1], args[2]) + } +} + +var ssaVecBySize = map[int64]*types.Type{ + 16: types.TypeVec128, + 32: types.TypeVec256, + 64: types.TypeVec512, +} + +func opLen3_31Zero3(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + if t, ok := ssaVecBySize[args[1].Type.Size()]; !ok { + panic("unknown simd vector size") + } else { + return s.newValue3(op, t, s.newValue0(ssa.OpZeroSIMD, t), args[1], args[0]) + } + } +} + +func opLen3_21(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue3(op, t, args[1], args[0], args[2]) + } +} + +func opLen3_231(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue3(op, t, args[2], args[0], args[1]) + } +} + +func opLen4(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue4(op, t, args[0], args[1], args[2], args[3]) + } +} + +func opLen4_231(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue4(op, t, args[2], args[0], args[1], args[3]) + } +} + +func opLen4_31(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return s.newValue4(op, t, args[2], args[1], args[0], args[3]) + } +} + +func immJumpTable(s *state, idx *ssa.Value, intrinsicCall *ir.CallExpr, genOp func(*state, int)) *ssa.Value { + // Make blocks we'll need. + bEnd := s.f.NewBlock(ssa.BlockPlain) + + if !idx.Type.IsKind(types.TUINT8) { + panic("immJumpTable expects uint8 value") + } + + // We will exhaust 0-255, so no need to check the bounds. + t := types.Types[types.TUINTPTR] + idx = s.conv(nil, idx, idx.Type, t) + + b := s.curBlock + b.Kind = ssa.BlockJumpTable + b.Pos = intrinsicCall.Pos() + if base.Flag.Cfg.SpectreIndex { + // Potential Spectre vulnerability hardening? + idx = s.newValue2(ssa.OpSpectreSliceIndex, t, idx, s.uintptrConstant(255)) + } + b.SetControl(idx) + targets := [256]*ssa.Block{} + for i := range 256 { + t := s.f.NewBlock(ssa.BlockPlain) + targets[i] = t + b.AddEdgeTo(t) + } + s.endBlock() + + for i, t := range targets { + s.startBlock(t) + genOp(s, i) + if t.Kind != ssa.BlockExit { + t.AddEdgeTo(bEnd) + } + s.endBlock() + } + + s.startBlock(bEnd) + ret := s.variable(intrinsicCall, intrinsicCall.Type()) + return ret +} + +func opLen1Imm8(op ssa.Op, t *types.Type, offset int) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { + if args[1].Op == ssa.OpConst8 { + return s.newValue1I(op, t, args[1].AuxInt< 0 { + if ft.NumResults() == 1 { + call.SetType(ft.Result(0).Type) + } else { + call.SetType(ft.ResultsTuple()) + } + n := ir.NewReturnStmt(base.Pos, nil) + n.Results = []ir.Node{call} + ret = n + } + fn.Body.Append(ret) + + if base.Flag.LowerR != 0 { + ir.DumpList("generate intrinsic body", fn.Body) + } + + ir.CurFunc = fn + typecheck.Stmts(fn.Body) + ir.CurFunc = nil // we know CurFunc is nil at entry +} diff --git a/go/src/cmd/compile/internal/ssagen/intrinsics_test.go b/go/src/cmd/compile/internal/ssagen/intrinsics_test.go new file mode 100644 index 0000000000000000000000000000000000000000..3d866a6bf4a8848499a8d61bdc066ef8567d7dc3 --- /dev/null +++ b/go/src/cmd/compile/internal/ssagen/intrinsics_test.go @@ -0,0 +1,1463 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssagen + +import ( + "flag" + "fmt" + "slices" + "strings" + "testing" + + "cmd/internal/sys" +) + +var updateIntrinsics = flag.Bool("update", false, "Print an updated intrinsics table") + +// TODO turn on after SIMD is stable. The time burned keeping this test happy during SIMD development has already well exceeded any plausible benefit. +var simd = flag.Bool("simd", false, "Also check SIMD intrinsics; for now, it is noisy and not helpful") + +type testIntrinsicKey struct { + archName string + pkg string + fn string +} + +var wantIntrinsics = map[testIntrinsicKey]struct{}{ + {"386", "internal/runtime/math", "MulUintptr"}: struct{}{}, + {"386", "internal/runtime/sys", "Bswap32"}: struct{}{}, + {"386", "internal/runtime/sys", "Bswap64"}: struct{}{}, + {"386", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"386", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"386", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"386", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"386", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"386", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"386", "math", "sqrt"}: struct{}{}, + {"386", "math/bits", "Mul64"}: struct{}{}, + {"386", "math/bits", "ReverseBytes32"}: struct{}{}, + {"386", "math/bits", "ReverseBytes64"}: struct{}{}, + {"386", "math/bits", "TrailingZeros16"}: struct{}{}, + {"386", "math/bits", "TrailingZeros32"}: struct{}{}, + {"386", "math/bits", "TrailingZeros64"}: struct{}{}, + {"386", "math/bits", "TrailingZeros8"}: struct{}{}, + {"386", "runtime", "KeepAlive"}: struct{}{}, + {"386", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"386", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "And"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "And32"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "And64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "And8"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Cas64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Casint64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Load"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Load64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "LoadAcq64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Loadint64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Or"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Or32"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Or64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Store"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Store64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "StoreRel64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Storeint64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "StorepNoWB"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xadd64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xaddint64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xchg64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xchg8"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xchgint64"}: struct{}{}, + {"amd64", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"amd64", "internal/runtime/maps", "bitsetFirst"}: struct{}{}, + {"amd64", "internal/runtime/maps", "bitsetRemoveBelow"}: struct{}{}, + {"amd64", "internal/runtime/maps", "bitsetLowestSet"}: struct{}{}, + {"amd64", "internal/runtime/maps", "bitsetShiftOutLowest"}: struct{}{}, + {"amd64", "internal/runtime/maps", "ctrlGroupMatchH2"}: struct{}{}, + {"amd64", "internal/runtime/maps", "ctrlGroupMatchEmpty"}: struct{}{}, + {"amd64", "internal/runtime/maps", "ctrlGroupMatchEmptyOrDeleted"}: struct{}{}, + {"amd64", "internal/runtime/maps", "ctrlGroupMatchFull"}: struct{}{}, + {"amd64", "internal/runtime/math", "Add64"}: struct{}{}, + {"amd64", "internal/runtime/math", "Mul64"}: struct{}{}, + {"amd64", "internal/runtime/math", "MulUintptr"}: struct{}{}, + {"amd64", "internal/runtime/sys", "Bswap32"}: struct{}{}, + {"amd64", "internal/runtime/sys", "Bswap64"}: struct{}{}, + {"amd64", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"amd64", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"amd64", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"amd64", "internal/runtime/sys", "Len64"}: struct{}{}, + {"amd64", "internal/runtime/sys", "Len8"}: struct{}{}, + {"amd64", "internal/runtime/sys", "OnesCount64"}: struct{}{}, + {"amd64", "internal/runtime/sys", "Prefetch"}: struct{}{}, + {"amd64", "internal/runtime/sys", "PrefetchStreamed"}: struct{}{}, + {"amd64", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"amd64", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"amd64", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"amd64", "math", "Ceil"}: struct{}{}, + {"amd64", "math", "FMA"}: struct{}{}, + {"amd64", "math", "Floor"}: struct{}{}, + {"amd64", "math", "RoundToEven"}: struct{}{}, + {"amd64", "math", "Trunc"}: struct{}{}, + {"amd64", "math", "sqrt"}: struct{}{}, + {"amd64", "math/big", "mulWW"}: struct{}{}, + {"amd64", "math/bits", "Add"}: struct{}{}, + {"amd64", "math/bits", "Add64"}: struct{}{}, + {"amd64", "math/bits", "Div"}: struct{}{}, + {"amd64", "math/bits", "Div64"}: struct{}{}, + {"amd64", "math/bits", "Len"}: struct{}{}, + {"amd64", "math/bits", "Len16"}: struct{}{}, + {"amd64", "math/bits", "Len32"}: struct{}{}, + {"amd64", "math/bits", "Len64"}: struct{}{}, + {"amd64", "math/bits", "Len8"}: struct{}{}, + {"amd64", "math/bits", "Mul"}: struct{}{}, + {"amd64", "math/bits", "Mul64"}: struct{}{}, + {"amd64", "math/bits", "OnesCount"}: struct{}{}, + {"amd64", "math/bits", "OnesCount16"}: struct{}{}, + {"amd64", "math/bits", "OnesCount32"}: struct{}{}, + {"amd64", "math/bits", "OnesCount64"}: struct{}{}, + {"amd64", "math/bits", "ReverseBytes32"}: struct{}{}, + {"amd64", "math/bits", "ReverseBytes64"}: struct{}{}, + {"amd64", "math/bits", "RotateLeft"}: struct{}{}, + {"amd64", "math/bits", "RotateLeft16"}: struct{}{}, + {"amd64", "math/bits", "RotateLeft32"}: struct{}{}, + {"amd64", "math/bits", "RotateLeft64"}: struct{}{}, + {"amd64", "math/bits", "RotateLeft8"}: struct{}{}, + {"amd64", "math/bits", "Sub"}: struct{}{}, + {"amd64", "math/bits", "Sub64"}: struct{}{}, + {"amd64", "math/bits", "TrailingZeros16"}: struct{}{}, + {"amd64", "math/bits", "TrailingZeros32"}: struct{}{}, + {"amd64", "math/bits", "TrailingZeros64"}: struct{}{}, + {"amd64", "math/bits", "TrailingZeros8"}: struct{}{}, + {"amd64", "runtime", "KeepAlive"}: struct{}{}, + {"amd64", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"amd64", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"amd64", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"amd64", "sync/atomic", "AddInt32"}: struct{}{}, + {"amd64", "sync/atomic", "AddInt64"}: struct{}{}, + {"amd64", "sync/atomic", "AddUint32"}: struct{}{}, + {"amd64", "sync/atomic", "AddUint64"}: struct{}{}, + {"amd64", "sync/atomic", "AddUintptr"}: struct{}{}, + {"amd64", "sync/atomic", "AndInt32"}: struct{}{}, + {"amd64", "sync/atomic", "AndInt64"}: struct{}{}, + {"amd64", "sync/atomic", "AndUint32"}: struct{}{}, + {"amd64", "sync/atomic", "AndUint64"}: struct{}{}, + {"amd64", "sync/atomic", "AndUintptr"}: struct{}{}, + {"amd64", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"amd64", "sync/atomic", "CompareAndSwapInt64"}: struct{}{}, + {"amd64", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"amd64", "sync/atomic", "CompareAndSwapUint64"}: struct{}{}, + {"amd64", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"amd64", "sync/atomic", "LoadInt32"}: struct{}{}, + {"amd64", "sync/atomic", "LoadInt64"}: struct{}{}, + {"amd64", "sync/atomic", "LoadPointer"}: struct{}{}, + {"amd64", "sync/atomic", "LoadUint32"}: struct{}{}, + {"amd64", "sync/atomic", "LoadUint64"}: struct{}{}, + {"amd64", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"amd64", "sync/atomic", "OrInt32"}: struct{}{}, + {"amd64", "sync/atomic", "OrInt64"}: struct{}{}, + {"amd64", "sync/atomic", "OrUint32"}: struct{}{}, + {"amd64", "sync/atomic", "OrUint64"}: struct{}{}, + {"amd64", "sync/atomic", "OrUintptr"}: struct{}{}, + {"amd64", "sync/atomic", "StoreInt32"}: struct{}{}, + {"amd64", "sync/atomic", "StoreInt64"}: struct{}{}, + {"amd64", "sync/atomic", "StoreUint32"}: struct{}{}, + {"amd64", "sync/atomic", "StoreUint64"}: struct{}{}, + {"amd64", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"amd64", "sync/atomic", "SwapInt32"}: struct{}{}, + {"amd64", "sync/atomic", "SwapInt64"}: struct{}{}, + {"amd64", "sync/atomic", "SwapUint32"}: struct{}{}, + {"amd64", "sync/atomic", "SwapUint64"}: struct{}{}, + {"amd64", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"amd64", "crypto/internal/constanttime", "Select"}: struct{}{}, + {"amd64", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"arm", "internal/runtime/sys", "Bswap32"}: struct{}{}, + {"arm", "internal/runtime/sys", "Bswap64"}: struct{}{}, + {"arm", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"arm", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"arm", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"arm", "internal/runtime/sys", "Len64"}: struct{}{}, + {"arm", "internal/runtime/sys", "Len8"}: struct{}{}, + {"arm", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"arm", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"arm", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"arm", "math", "Abs"}: struct{}{}, + {"arm", "math", "FMA"}: struct{}{}, + {"arm", "math", "sqrt"}: struct{}{}, + {"arm", "math/bits", "Len"}: struct{}{}, + {"arm", "math/bits", "Len16"}: struct{}{}, + {"arm", "math/bits", "Len32"}: struct{}{}, + {"arm", "math/bits", "Len64"}: struct{}{}, + {"arm", "math/bits", "Len8"}: struct{}{}, + {"arm", "math/bits", "Mul64"}: struct{}{}, + {"arm", "math/bits", "ReverseBytes32"}: struct{}{}, + {"arm", "math/bits", "ReverseBytes64"}: struct{}{}, + {"arm", "math/bits", "RotateLeft32"}: struct{}{}, + {"arm", "math/bits", "TrailingZeros16"}: struct{}{}, + {"arm", "math/bits", "TrailingZeros32"}: struct{}{}, + {"arm", "math/bits", "TrailingZeros64"}: struct{}{}, + {"arm", "math/bits", "TrailingZeros8"}: struct{}{}, + {"arm", "runtime", "KeepAlive"}: struct{}{}, + {"arm", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"arm", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "And"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "And32"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "And64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "And8"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Anduintptr"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Cas64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Casint64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Load"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Load64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "LoadAcq64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Loadint64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Or"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Or32"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Or64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Oruintptr"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Store"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Store64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "StoreRel64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Storeint64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "StorepNoWB"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xadd64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xaddint64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xchg8"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xchg64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xchgint64"}: struct{}{}, + {"arm64", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"arm64", "internal/runtime/math", "Add64"}: struct{}{}, + {"arm64", "internal/runtime/math", "Mul64"}: struct{}{}, + {"arm64", "internal/runtime/math", "MulUintptr"}: struct{}{}, + {"arm64", "internal/runtime/sys", "Bswap32"}: struct{}{}, + {"arm64", "internal/runtime/sys", "Bswap64"}: struct{}{}, + {"arm64", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"arm64", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"arm64", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"arm64", "internal/runtime/sys", "Len64"}: struct{}{}, + {"arm64", "internal/runtime/sys", "Len8"}: struct{}{}, + {"arm64", "internal/runtime/sys", "OnesCount64"}: struct{}{}, + {"arm64", "internal/runtime/sys", "Prefetch"}: struct{}{}, + {"arm64", "internal/runtime/sys", "PrefetchStreamed"}: struct{}{}, + {"arm64", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"arm64", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"arm64", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"arm64", "math", "Abs"}: struct{}{}, + {"arm64", "math", "Ceil"}: struct{}{}, + {"arm64", "math", "FMA"}: struct{}{}, + {"arm64", "math", "Floor"}: struct{}{}, + {"arm64", "math", "Round"}: struct{}{}, + {"arm64", "math", "RoundToEven"}: struct{}{}, + {"arm64", "math", "Trunc"}: struct{}{}, + {"arm64", "math", "sqrt"}: struct{}{}, + {"arm64", "math/big", "mulWW"}: struct{}{}, + {"arm64", "math/bits", "Add"}: struct{}{}, + {"arm64", "math/bits", "Add64"}: struct{}{}, + {"arm64", "math/bits", "Len"}: struct{}{}, + {"arm64", "math/bits", "Len16"}: struct{}{}, + {"arm64", "math/bits", "Len32"}: struct{}{}, + {"arm64", "math/bits", "Len64"}: struct{}{}, + {"arm64", "math/bits", "Len8"}: struct{}{}, + {"arm64", "math/bits", "Mul"}: struct{}{}, + {"arm64", "math/bits", "Mul64"}: struct{}{}, + {"arm64", "math/bits", "OnesCount"}: struct{}{}, + {"arm64", "math/bits", "OnesCount16"}: struct{}{}, + {"arm64", "math/bits", "OnesCount32"}: struct{}{}, + {"arm64", "math/bits", "OnesCount64"}: struct{}{}, + {"arm64", "math/bits", "Reverse"}: struct{}{}, + {"arm64", "math/bits", "Reverse16"}: struct{}{}, + {"arm64", "math/bits", "Reverse32"}: struct{}{}, + {"arm64", "math/bits", "Reverse64"}: struct{}{}, + {"arm64", "math/bits", "Reverse8"}: struct{}{}, + {"arm64", "math/bits", "ReverseBytes32"}: struct{}{}, + {"arm64", "math/bits", "ReverseBytes64"}: struct{}{}, + {"arm64", "math/bits", "RotateLeft"}: struct{}{}, + {"arm64", "math/bits", "RotateLeft32"}: struct{}{}, + {"arm64", "math/bits", "RotateLeft64"}: struct{}{}, + {"arm64", "math/bits", "Sub"}: struct{}{}, + {"arm64", "math/bits", "Sub64"}: struct{}{}, + {"arm64", "math/bits", "TrailingZeros16"}: struct{}{}, + {"arm64", "math/bits", "TrailingZeros32"}: struct{}{}, + {"arm64", "math/bits", "TrailingZeros64"}: struct{}{}, + {"arm64", "math/bits", "TrailingZeros8"}: struct{}{}, + {"arm64", "runtime", "KeepAlive"}: struct{}{}, + {"arm64", "runtime", "memequal"}: struct{}{}, + {"arm64", "runtime", "publicationBarrier"}: struct{}{}, + {"arm64", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"arm64", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"arm64", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"arm64", "sync/atomic", "AddInt32"}: struct{}{}, + {"arm64", "sync/atomic", "AddInt64"}: struct{}{}, + {"arm64", "sync/atomic", "AddUint32"}: struct{}{}, + {"arm64", "sync/atomic", "AddUint64"}: struct{}{}, + {"arm64", "sync/atomic", "AddUintptr"}: struct{}{}, + {"arm64", "sync/atomic", "AndInt32"}: struct{}{}, + {"arm64", "sync/atomic", "AndInt64"}: struct{}{}, + {"arm64", "sync/atomic", "AndUint32"}: struct{}{}, + {"arm64", "sync/atomic", "AndUint64"}: struct{}{}, + {"arm64", "sync/atomic", "AndUintptr"}: struct{}{}, + {"arm64", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"arm64", "sync/atomic", "CompareAndSwapInt64"}: struct{}{}, + {"arm64", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"arm64", "sync/atomic", "CompareAndSwapUint64"}: struct{}{}, + {"arm64", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"arm64", "sync/atomic", "LoadInt32"}: struct{}{}, + {"arm64", "sync/atomic", "LoadInt64"}: struct{}{}, + {"arm64", "sync/atomic", "LoadPointer"}: struct{}{}, + {"arm64", "sync/atomic", "LoadUint32"}: struct{}{}, + {"arm64", "sync/atomic", "LoadUint64"}: struct{}{}, + {"arm64", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"arm64", "sync/atomic", "OrInt32"}: struct{}{}, + {"arm64", "sync/atomic", "OrInt64"}: struct{}{}, + {"arm64", "sync/atomic", "OrUint32"}: struct{}{}, + {"arm64", "sync/atomic", "OrUint64"}: struct{}{}, + {"arm64", "sync/atomic", "OrUintptr"}: struct{}{}, + {"arm64", "sync/atomic", "StoreInt32"}: struct{}{}, + {"arm64", "sync/atomic", "StoreInt64"}: struct{}{}, + {"arm64", "sync/atomic", "StoreUint32"}: struct{}{}, + {"arm64", "sync/atomic", "StoreUint64"}: struct{}{}, + {"arm64", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"arm64", "sync/atomic", "SwapInt32"}: struct{}{}, + {"arm64", "sync/atomic", "SwapInt64"}: struct{}{}, + {"arm64", "sync/atomic", "SwapUint32"}: struct{}{}, + {"arm64", "sync/atomic", "SwapUint64"}: struct{}{}, + {"arm64", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"arm64", "crypto/internal/constanttime", "Select"}: struct{}{}, + {"arm64", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "And"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "And32"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "And64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "And8"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Anduintptr"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Cas64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Casint64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Load"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Load64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "LoadAcq64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Loadint64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Or"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Or32"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Or64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Oruintptr"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Store"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Store64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "StoreRel64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Storeint64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "StorepNoWB"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xadd64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xaddint64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xchg8"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xchg64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xchgint64"}: struct{}{}, + {"loong64", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"loong64", "internal/runtime/math", "Add64"}: struct{}{}, + {"loong64", "internal/runtime/math", "Mul64"}: struct{}{}, + {"loong64", "internal/runtime/math", "MulUintptr"}: struct{}{}, + {"loong64", "internal/runtime/sys", "Bswap32"}: struct{}{}, + {"loong64", "internal/runtime/sys", "Bswap64"}: struct{}{}, + {"loong64", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"loong64", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"loong64", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"loong64", "internal/runtime/sys", "Len64"}: struct{}{}, + {"loong64", "internal/runtime/sys", "Len8"}: struct{}{}, + {"loong64", "internal/runtime/sys", "OnesCount64"}: struct{}{}, + {"loong64", "internal/runtime/sys", "Prefetch"}: struct{}{}, + {"loong64", "internal/runtime/sys", "PrefetchStreamed"}: struct{}{}, + {"loong64", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"loong64", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"loong64", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"loong64", "math", "Abs"}: struct{}{}, + {"loong64", "math", "Copysign"}: struct{}{}, + {"loong64", "math", "FMA"}: struct{}{}, + {"loong64", "math", "sqrt"}: struct{}{}, + {"loong64", "math/big", "mulWW"}: struct{}{}, + {"loong64", "math/bits", "Add"}: struct{}{}, + {"loong64", "math/bits", "Add64"}: struct{}{}, + {"loong64", "math/bits", "Mul"}: struct{}{}, + {"loong64", "math/bits", "Mul64"}: struct{}{}, + {"loong64", "math/bits", "Len"}: struct{}{}, + {"loong64", "math/bits", "Len8"}: struct{}{}, + {"loong64", "math/bits", "Len16"}: struct{}{}, + {"loong64", "math/bits", "Len32"}: struct{}{}, + {"loong64", "math/bits", "Len64"}: struct{}{}, + {"loong64", "math/bits", "OnesCount"}: struct{}{}, + {"loong64", "math/bits", "OnesCount16"}: struct{}{}, + {"loong64", "math/bits", "OnesCount32"}: struct{}{}, + {"loong64", "math/bits", "OnesCount64"}: struct{}{}, + {"loong64", "math/bits", "Reverse"}: struct{}{}, + {"loong64", "math/bits", "Reverse8"}: struct{}{}, + {"loong64", "math/bits", "Reverse16"}: struct{}{}, + {"loong64", "math/bits", "Reverse32"}: struct{}{}, + {"loong64", "math/bits", "Reverse64"}: struct{}{}, + {"loong64", "math/bits", "RotateLeft"}: struct{}{}, + {"loong64", "math/bits", "RotateLeft32"}: struct{}{}, + {"loong64", "math/bits", "RotateLeft64"}: struct{}{}, + {"loong64", "math/bits", "ReverseBytes16"}: struct{}{}, + {"loong64", "math/bits", "ReverseBytes32"}: struct{}{}, + {"loong64", "math/bits", "ReverseBytes64"}: struct{}{}, + {"loong64", "math/bits", "TrailingZeros16"}: struct{}{}, + {"loong64", "math/bits", "TrailingZeros32"}: struct{}{}, + {"loong64", "math/bits", "TrailingZeros64"}: struct{}{}, + {"loong64", "math/bits", "TrailingZeros8"}: struct{}{}, + {"loong64", "math/bits", "Sub"}: struct{}{}, + {"loong64", "math/bits", "Sub64"}: struct{}{}, + {"loong64", "runtime", "KeepAlive"}: struct{}{}, + {"loong64", "runtime", "publicationBarrier"}: struct{}{}, + {"loong64", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"loong64", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"loong64", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"loong64", "sync/atomic", "AddInt32"}: struct{}{}, + {"loong64", "sync/atomic", "AddInt64"}: struct{}{}, + {"loong64", "sync/atomic", "AddUint32"}: struct{}{}, + {"loong64", "sync/atomic", "AddUint64"}: struct{}{}, + {"loong64", "sync/atomic", "AddUintptr"}: struct{}{}, + {"loong64", "sync/atomic", "AddInt32"}: struct{}{}, + {"loong64", "sync/atomic", "AddInt64"}: struct{}{}, + {"loong64", "sync/atomic", "AddUint32"}: struct{}{}, + {"loong64", "sync/atomic", "AddUint64"}: struct{}{}, + {"loong64", "sync/atomic", "AddUintptr"}: struct{}{}, + {"loong64", "sync/atomic", "AndInt32"}: struct{}{}, + {"loong64", "sync/atomic", "AndInt64"}: struct{}{}, + {"loong64", "sync/atomic", "AndUint32"}: struct{}{}, + {"loong64", "sync/atomic", "AndUint64"}: struct{}{}, + {"loong64", "sync/atomic", "AndUintptr"}: struct{}{}, + {"loong64", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"loong64", "sync/atomic", "CompareAndSwapInt64"}: struct{}{}, + {"loong64", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"loong64", "sync/atomic", "CompareAndSwapUint64"}: struct{}{}, + {"loong64", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"loong64", "sync/atomic", "LoadInt32"}: struct{}{}, + {"loong64", "sync/atomic", "LoadInt64"}: struct{}{}, + {"loong64", "sync/atomic", "LoadPointer"}: struct{}{}, + {"loong64", "sync/atomic", "LoadUint32"}: struct{}{}, + {"loong64", "sync/atomic", "LoadUint64"}: struct{}{}, + {"loong64", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"loong64", "sync/atomic", "OrInt32"}: struct{}{}, + {"loong64", "sync/atomic", "OrInt64"}: struct{}{}, + {"loong64", "sync/atomic", "OrUint32"}: struct{}{}, + {"loong64", "sync/atomic", "OrUint64"}: struct{}{}, + {"loong64", "sync/atomic", "OrUintptr"}: struct{}{}, + {"loong64", "sync/atomic", "StoreInt32"}: struct{}{}, + {"loong64", "sync/atomic", "StoreInt64"}: struct{}{}, + {"loong64", "sync/atomic", "StoreUint32"}: struct{}{}, + {"loong64", "sync/atomic", "StoreUint64"}: struct{}{}, + {"loong64", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"loong64", "sync/atomic", "SwapInt32"}: struct{}{}, + {"loong64", "sync/atomic", "SwapInt64"}: struct{}{}, + {"loong64", "sync/atomic", "SwapUint32"}: struct{}{}, + {"loong64", "sync/atomic", "SwapUint64"}: struct{}{}, + {"loong64", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"loong64", "crypto/internal/constanttime", "Select"}: struct{}{}, + {"loong64", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"mips", "internal/runtime/atomic", "And"}: struct{}{}, + {"mips", "internal/runtime/atomic", "And8"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"mips", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Load"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"mips", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"mips", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Or"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Store"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"mips", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"mips", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"mips", "internal/runtime/atomic", "StorepNoWB"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"mips", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"mips", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"mips", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"mips", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"mips", "internal/runtime/sys", "Len64"}: struct{}{}, + {"mips", "internal/runtime/sys", "Len8"}: struct{}{}, + {"mips", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"mips", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"mips", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"mips", "math", "Abs"}: struct{}{}, + {"mips", "math", "sqrt"}: struct{}{}, + {"mips", "math/bits", "Len"}: struct{}{}, + {"mips", "math/bits", "Len16"}: struct{}{}, + {"mips", "math/bits", "Len32"}: struct{}{}, + {"mips", "math/bits", "Len64"}: struct{}{}, + {"mips", "math/bits", "Len8"}: struct{}{}, + {"mips", "math/bits", "Mul64"}: struct{}{}, + {"mips", "math/bits", "TrailingZeros16"}: struct{}{}, + {"mips", "math/bits", "TrailingZeros32"}: struct{}{}, + {"mips", "math/bits", "TrailingZeros64"}: struct{}{}, + {"mips", "math/bits", "TrailingZeros8"}: struct{}{}, + {"mips", "runtime", "KeepAlive"}: struct{}{}, + {"mips", "runtime", "publicationBarrier"}: struct{}{}, + {"mips", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"mips", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"mips", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"mips", "sync/atomic", "AddInt32"}: struct{}{}, + {"mips", "sync/atomic", "AddUint32"}: struct{}{}, + {"mips", "sync/atomic", "AddUintptr"}: struct{}{}, + {"mips", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"mips", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"mips", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"mips", "sync/atomic", "LoadInt32"}: struct{}{}, + {"mips", "sync/atomic", "LoadPointer"}: struct{}{}, + {"mips", "sync/atomic", "LoadUint32"}: struct{}{}, + {"mips", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"mips", "sync/atomic", "StoreInt32"}: struct{}{}, + {"mips", "sync/atomic", "StoreUint32"}: struct{}{}, + {"mips", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"mips", "sync/atomic", "SwapInt32"}: struct{}{}, + {"mips", "sync/atomic", "SwapUint32"}: struct{}{}, + {"mips", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"mips", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "And"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "And8"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Cas64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Casint64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Load"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Load64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "LoadAcq64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Loadint64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Or"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Store"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Store64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "StoreRel64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Storeint64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "StorepNoWB"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Xadd64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Xaddint64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Xchg64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Xchgint64"}: struct{}{}, + {"mips64", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"mips64", "internal/runtime/math", "Add64"}: struct{}{}, + {"mips64", "internal/runtime/math", "Mul64"}: struct{}{}, + {"mips64", "internal/runtime/math", "MulUintptr"}: struct{}{}, + {"mips64", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"mips64", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"mips64", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"mips64", "math", "Abs"}: struct{}{}, + {"mips64", "math", "sqrt"}: struct{}{}, + {"mips64", "math/big", "mulWW"}: struct{}{}, + {"mips64", "math/bits", "Add"}: struct{}{}, + {"mips64", "math/bits", "Add64"}: struct{}{}, + {"mips64", "math/bits", "Mul"}: struct{}{}, + {"mips64", "math/bits", "Mul64"}: struct{}{}, + {"mips64", "math/bits", "Sub"}: struct{}{}, + {"mips64", "math/bits", "Sub64"}: struct{}{}, + {"mips64", "runtime", "KeepAlive"}: struct{}{}, + {"mips64", "runtime", "publicationBarrier"}: struct{}{}, + {"mips64", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"mips64", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"mips64", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"mips64", "sync/atomic", "AddInt32"}: struct{}{}, + {"mips64", "sync/atomic", "AddInt64"}: struct{}{}, + {"mips64", "sync/atomic", "AddUint32"}: struct{}{}, + {"mips64", "sync/atomic", "AddUint64"}: struct{}{}, + {"mips64", "sync/atomic", "AddUintptr"}: struct{}{}, + {"mips64", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"mips64", "sync/atomic", "CompareAndSwapInt64"}: struct{}{}, + {"mips64", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"mips64", "sync/atomic", "CompareAndSwapUint64"}: struct{}{}, + {"mips64", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"mips64", "sync/atomic", "LoadInt32"}: struct{}{}, + {"mips64", "sync/atomic", "LoadInt64"}: struct{}{}, + {"mips64", "sync/atomic", "LoadPointer"}: struct{}{}, + {"mips64", "sync/atomic", "LoadUint32"}: struct{}{}, + {"mips64", "sync/atomic", "LoadUint64"}: struct{}{}, + {"mips64", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"mips64", "sync/atomic", "StoreInt32"}: struct{}{}, + {"mips64", "sync/atomic", "StoreInt64"}: struct{}{}, + {"mips64", "sync/atomic", "StoreUint32"}: struct{}{}, + {"mips64", "sync/atomic", "StoreUint64"}: struct{}{}, + {"mips64", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"mips64", "sync/atomic", "SwapInt32"}: struct{}{}, + {"mips64", "sync/atomic", "SwapInt64"}: struct{}{}, + {"mips64", "sync/atomic", "SwapUint32"}: struct{}{}, + {"mips64", "sync/atomic", "SwapUint64"}: struct{}{}, + {"mips64", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"mips64", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "And"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "And8"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Cas64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Casint64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Load"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Load64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "LoadAcq64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Loadint64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Or"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Store"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Store64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "StoreRel64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Storeint64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "StorepNoWB"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Xadd64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Xaddint64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Xchg64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Xchgint64"}: struct{}{}, + {"mips64le", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"mips64le", "internal/runtime/math", "Add64"}: struct{}{}, + {"mips64le", "internal/runtime/math", "Mul64"}: struct{}{}, + {"mips64le", "internal/runtime/math", "MulUintptr"}: struct{}{}, + {"mips64le", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"mips64le", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"mips64le", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"mips64le", "math", "Abs"}: struct{}{}, + {"mips64le", "math", "sqrt"}: struct{}{}, + {"mips64le", "math/big", "mulWW"}: struct{}{}, + {"mips64le", "math/bits", "Add"}: struct{}{}, + {"mips64le", "math/bits", "Add64"}: struct{}{}, + {"mips64le", "math/bits", "Mul"}: struct{}{}, + {"mips64le", "math/bits", "Mul64"}: struct{}{}, + {"mips64le", "math/bits", "Sub"}: struct{}{}, + {"mips64le", "math/bits", "Sub64"}: struct{}{}, + {"mips64le", "runtime", "KeepAlive"}: struct{}{}, + {"mips64le", "runtime", "publicationBarrier"}: struct{}{}, + {"mips64le", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"mips64le", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"mips64le", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"mips64le", "sync/atomic", "AddInt32"}: struct{}{}, + {"mips64le", "sync/atomic", "AddInt64"}: struct{}{}, + {"mips64le", "sync/atomic", "AddUint32"}: struct{}{}, + {"mips64le", "sync/atomic", "AddUint64"}: struct{}{}, + {"mips64le", "sync/atomic", "AddUintptr"}: struct{}{}, + {"mips64le", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"mips64le", "sync/atomic", "CompareAndSwapInt64"}: struct{}{}, + {"mips64le", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"mips64le", "sync/atomic", "CompareAndSwapUint64"}: struct{}{}, + {"mips64le", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"mips64le", "sync/atomic", "LoadInt32"}: struct{}{}, + {"mips64le", "sync/atomic", "LoadInt64"}: struct{}{}, + {"mips64le", "sync/atomic", "LoadPointer"}: struct{}{}, + {"mips64le", "sync/atomic", "LoadUint32"}: struct{}{}, + {"mips64le", "sync/atomic", "LoadUint64"}: struct{}{}, + {"mips64le", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"mips64le", "sync/atomic", "StoreInt32"}: struct{}{}, + {"mips64le", "sync/atomic", "StoreInt64"}: struct{}{}, + {"mips64le", "sync/atomic", "StoreUint32"}: struct{}{}, + {"mips64le", "sync/atomic", "StoreUint64"}: struct{}{}, + {"mips64le", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"mips64le", "sync/atomic", "SwapInt32"}: struct{}{}, + {"mips64le", "sync/atomic", "SwapInt64"}: struct{}{}, + {"mips64le", "sync/atomic", "SwapUint32"}: struct{}{}, + {"mips64le", "sync/atomic", "SwapUint64"}: struct{}{}, + {"mips64le", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"mips64le", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "And"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "And8"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Load"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Or"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Store"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "StorepNoWB"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"mipsle", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"mipsle", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"mipsle", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"mipsle", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"mipsle", "internal/runtime/sys", "Len64"}: struct{}{}, + {"mipsle", "internal/runtime/sys", "Len8"}: struct{}{}, + {"mipsle", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"mipsle", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"mipsle", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"mipsle", "math", "Abs"}: struct{}{}, + {"mipsle", "math", "sqrt"}: struct{}{}, + {"mipsle", "math/bits", "Len"}: struct{}{}, + {"mipsle", "math/bits", "Len16"}: struct{}{}, + {"mipsle", "math/bits", "Len32"}: struct{}{}, + {"mipsle", "math/bits", "Len64"}: struct{}{}, + {"mipsle", "math/bits", "Len8"}: struct{}{}, + {"mipsle", "math/bits", "Mul64"}: struct{}{}, + {"mipsle", "math/bits", "TrailingZeros16"}: struct{}{}, + {"mipsle", "math/bits", "TrailingZeros32"}: struct{}{}, + {"mipsle", "math/bits", "TrailingZeros64"}: struct{}{}, + {"mipsle", "math/bits", "TrailingZeros8"}: struct{}{}, + {"mipsle", "runtime", "KeepAlive"}: struct{}{}, + {"mipsle", "runtime", "publicationBarrier"}: struct{}{}, + {"mipsle", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"mipsle", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"mipsle", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"mipsle", "sync/atomic", "AddInt32"}: struct{}{}, + {"mipsle", "sync/atomic", "AddUint32"}: struct{}{}, + {"mipsle", "sync/atomic", "AddUintptr"}: struct{}{}, + {"mipsle", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"mipsle", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"mipsle", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"mipsle", "sync/atomic", "LoadInt32"}: struct{}{}, + {"mipsle", "sync/atomic", "LoadPointer"}: struct{}{}, + {"mipsle", "sync/atomic", "LoadUint32"}: struct{}{}, + {"mipsle", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"mipsle", "sync/atomic", "StoreInt32"}: struct{}{}, + {"mipsle", "sync/atomic", "StoreUint32"}: struct{}{}, + {"mipsle", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"mipsle", "sync/atomic", "SwapInt32"}: struct{}{}, + {"mipsle", "sync/atomic", "SwapUint32"}: struct{}{}, + {"mipsle", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"mipsle", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "And"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "And8"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Cas64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Casint64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Load"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Load64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "LoadAcq64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Loadint64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Or"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Store"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Store64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "StoreRel64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Storeint64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xadd64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xaddint64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xchg8"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xchg64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xchgint64"}: struct{}{}, + {"ppc64", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"ppc64", "internal/runtime/math", "Add64"}: struct{}{}, + {"ppc64", "internal/runtime/math", "Mul64"}: struct{}{}, + {"ppc64", "internal/runtime/math", "MulUintptr"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "Bswap32"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "Bswap64"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "Len64"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "Len8"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "OnesCount64"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "Prefetch"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "PrefetchStreamed"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"ppc64", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"ppc64", "math", "Abs"}: struct{}{}, + {"ppc64", "math", "Ceil"}: struct{}{}, + {"ppc64", "math", "Copysign"}: struct{}{}, + {"ppc64", "math", "FMA"}: struct{}{}, + {"ppc64", "math", "Floor"}: struct{}{}, + {"ppc64", "math", "Round"}: struct{}{}, + {"ppc64", "math", "Trunc"}: struct{}{}, + {"ppc64", "math", "sqrt"}: struct{}{}, + {"ppc64", "math/big", "mulWW"}: struct{}{}, + {"ppc64", "math/bits", "Add"}: struct{}{}, + {"ppc64", "math/bits", "Add64"}: struct{}{}, + {"ppc64", "math/bits", "Len"}: struct{}{}, + {"ppc64", "math/bits", "Len16"}: struct{}{}, + {"ppc64", "math/bits", "Len32"}: struct{}{}, + {"ppc64", "math/bits", "Len64"}: struct{}{}, + {"ppc64", "math/bits", "Len8"}: struct{}{}, + {"ppc64", "math/bits", "Mul"}: struct{}{}, + {"ppc64", "math/bits", "Mul64"}: struct{}{}, + {"ppc64", "math/bits", "OnesCount"}: struct{}{}, + {"ppc64", "math/bits", "OnesCount16"}: struct{}{}, + {"ppc64", "math/bits", "OnesCount32"}: struct{}{}, + {"ppc64", "math/bits", "OnesCount64"}: struct{}{}, + {"ppc64", "math/bits", "OnesCount8"}: struct{}{}, + {"ppc64", "math/bits", "ReverseBytes16"}: struct{}{}, + {"ppc64", "math/bits", "ReverseBytes32"}: struct{}{}, + {"ppc64", "math/bits", "ReverseBytes64"}: struct{}{}, + {"ppc64", "math/bits", "RotateLeft"}: struct{}{}, + {"ppc64", "math/bits", "RotateLeft32"}: struct{}{}, + {"ppc64", "math/bits", "RotateLeft64"}: struct{}{}, + {"ppc64", "math/bits", "Sub"}: struct{}{}, + {"ppc64", "math/bits", "Sub64"}: struct{}{}, + {"ppc64", "math/bits", "TrailingZeros8"}: struct{}{}, + {"ppc64", "math/bits", "TrailingZeros16"}: struct{}{}, + {"ppc64", "math/bits", "TrailingZeros32"}: struct{}{}, + {"ppc64", "math/bits", "TrailingZeros64"}: struct{}{}, + {"ppc64", "runtime", "KeepAlive"}: struct{}{}, + {"ppc64", "runtime", "publicationBarrier"}: struct{}{}, + {"ppc64", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"ppc64", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"ppc64", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"ppc64", "sync/atomic", "AddInt32"}: struct{}{}, + {"ppc64", "sync/atomic", "AddInt64"}: struct{}{}, + {"ppc64", "sync/atomic", "AddUint32"}: struct{}{}, + {"ppc64", "sync/atomic", "AddUint64"}: struct{}{}, + {"ppc64", "sync/atomic", "AddUintptr"}: struct{}{}, + {"ppc64", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"ppc64", "sync/atomic", "CompareAndSwapInt64"}: struct{}{}, + {"ppc64", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"ppc64", "sync/atomic", "CompareAndSwapUint64"}: struct{}{}, + {"ppc64", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"ppc64", "sync/atomic", "LoadInt32"}: struct{}{}, + {"ppc64", "sync/atomic", "LoadInt64"}: struct{}{}, + {"ppc64", "sync/atomic", "LoadPointer"}: struct{}{}, + {"ppc64", "sync/atomic", "LoadUint32"}: struct{}{}, + {"ppc64", "sync/atomic", "LoadUint64"}: struct{}{}, + {"ppc64", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"ppc64", "sync/atomic", "StoreInt32"}: struct{}{}, + {"ppc64", "sync/atomic", "StoreInt64"}: struct{}{}, + {"ppc64", "sync/atomic", "StoreUint32"}: struct{}{}, + {"ppc64", "sync/atomic", "StoreUint64"}: struct{}{}, + {"ppc64", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"ppc64", "sync/atomic", "SwapInt32"}: struct{}{}, + {"ppc64", "sync/atomic", "SwapInt64"}: struct{}{}, + {"ppc64", "sync/atomic", "SwapUint32"}: struct{}{}, + {"ppc64", "sync/atomic", "SwapUint64"}: struct{}{}, + {"ppc64", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"ppc64", "crypto/internal/constanttime", "Select"}: struct{}{}, + {"ppc64", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "And"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "And8"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Cas64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Casint64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Load"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Load64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "LoadAcq64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Loadint64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Or"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Store"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Store64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "StoreRel64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Storeint64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xadd64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xaddint64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xchg8"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xchg64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xchgint64"}: struct{}{}, + {"ppc64le", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"ppc64le", "internal/runtime/math", "Add64"}: struct{}{}, + {"ppc64le", "internal/runtime/math", "Mul64"}: struct{}{}, + {"ppc64le", "internal/runtime/math", "MulUintptr"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "Bswap32"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "Bswap64"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "Len64"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "Len8"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "OnesCount64"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "Prefetch"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "PrefetchStreamed"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"ppc64le", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"ppc64le", "math", "Abs"}: struct{}{}, + {"ppc64le", "math", "Ceil"}: struct{}{}, + {"ppc64le", "math", "Copysign"}: struct{}{}, + {"ppc64le", "math", "FMA"}: struct{}{}, + {"ppc64le", "math", "Floor"}: struct{}{}, + {"ppc64le", "math", "Round"}: struct{}{}, + {"ppc64le", "math", "Trunc"}: struct{}{}, + {"ppc64le", "math", "sqrt"}: struct{}{}, + {"ppc64le", "math/big", "mulWW"}: struct{}{}, + {"ppc64le", "math/bits", "Add"}: struct{}{}, + {"ppc64le", "math/bits", "Add64"}: struct{}{}, + {"ppc64le", "math/bits", "Len"}: struct{}{}, + {"ppc64le", "math/bits", "Len16"}: struct{}{}, + {"ppc64le", "math/bits", "Len32"}: struct{}{}, + {"ppc64le", "math/bits", "Len64"}: struct{}{}, + {"ppc64le", "math/bits", "Len8"}: struct{}{}, + {"ppc64le", "math/bits", "Mul"}: struct{}{}, + {"ppc64le", "math/bits", "Mul64"}: struct{}{}, + {"ppc64le", "math/bits", "OnesCount"}: struct{}{}, + {"ppc64le", "math/bits", "OnesCount16"}: struct{}{}, + {"ppc64le", "math/bits", "OnesCount32"}: struct{}{}, + {"ppc64le", "math/bits", "OnesCount64"}: struct{}{}, + {"ppc64le", "math/bits", "OnesCount8"}: struct{}{}, + {"ppc64le", "math/bits", "ReverseBytes16"}: struct{}{}, + {"ppc64le", "math/bits", "ReverseBytes32"}: struct{}{}, + {"ppc64le", "math/bits", "ReverseBytes64"}: struct{}{}, + {"ppc64le", "math/bits", "RotateLeft"}: struct{}{}, + {"ppc64le", "math/bits", "RotateLeft32"}: struct{}{}, + {"ppc64le", "math/bits", "RotateLeft64"}: struct{}{}, + {"ppc64le", "math/bits", "Sub"}: struct{}{}, + {"ppc64le", "math/bits", "Sub64"}: struct{}{}, + {"ppc64le", "math/bits", "TrailingZeros8"}: struct{}{}, + {"ppc64le", "math/bits", "TrailingZeros16"}: struct{}{}, + {"ppc64le", "math/bits", "TrailingZeros32"}: struct{}{}, + {"ppc64le", "math/bits", "TrailingZeros64"}: struct{}{}, + {"ppc64le", "runtime", "KeepAlive"}: struct{}{}, + {"ppc64le", "runtime", "publicationBarrier"}: struct{}{}, + {"ppc64le", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"ppc64le", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"ppc64le", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"ppc64le", "sync/atomic", "AddInt32"}: struct{}{}, + {"ppc64le", "sync/atomic", "AddInt64"}: struct{}{}, + {"ppc64le", "sync/atomic", "AddUint32"}: struct{}{}, + {"ppc64le", "sync/atomic", "AddUint64"}: struct{}{}, + {"ppc64le", "sync/atomic", "AddUintptr"}: struct{}{}, + {"ppc64le", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"ppc64le", "sync/atomic", "CompareAndSwapInt64"}: struct{}{}, + {"ppc64le", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"ppc64le", "sync/atomic", "CompareAndSwapUint64"}: struct{}{}, + {"ppc64le", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"ppc64le", "sync/atomic", "LoadInt32"}: struct{}{}, + {"ppc64le", "sync/atomic", "LoadInt64"}: struct{}{}, + {"ppc64le", "sync/atomic", "LoadPointer"}: struct{}{}, + {"ppc64le", "sync/atomic", "LoadUint32"}: struct{}{}, + {"ppc64le", "sync/atomic", "LoadUint64"}: struct{}{}, + {"ppc64le", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"ppc64le", "sync/atomic", "StoreInt32"}: struct{}{}, + {"ppc64le", "sync/atomic", "StoreInt64"}: struct{}{}, + {"ppc64le", "sync/atomic", "StoreUint32"}: struct{}{}, + {"ppc64le", "sync/atomic", "StoreUint64"}: struct{}{}, + {"ppc64le", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"ppc64le", "sync/atomic", "SwapInt32"}: struct{}{}, + {"ppc64le", "sync/atomic", "SwapInt64"}: struct{}{}, + {"ppc64le", "sync/atomic", "SwapUint32"}: struct{}{}, + {"ppc64le", "sync/atomic", "SwapUint64"}: struct{}{}, + {"ppc64le", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"ppc64le", "crypto/internal/constanttime", "Select"}: struct{}{}, + {"ppc64le", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "And"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "And8"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Cas64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Casint64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Load"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Load64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "LoadAcq64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Loadint64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Or"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Store"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Store64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "StoreRel64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Storeint64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "StorepNoWB"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Xadd64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Xaddint64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Xchg64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Xchgint64"}: struct{}{}, + {"riscv64", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"riscv64", "internal/runtime/math", "Add64"}: struct{}{}, + {"riscv64", "internal/runtime/math", "Mul64"}: struct{}{}, + {"riscv64", "internal/runtime/math", "MulUintptr"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "Bswap32"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "Bswap64"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "Len64"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "Len8"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "OnesCount64"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"riscv64", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"riscv64", "math", "Abs"}: struct{}{}, + {"riscv64", "math", "Copysign"}: struct{}{}, + {"riscv64", "math", "FMA"}: struct{}{}, + {"riscv64", "math", "sqrt"}: struct{}{}, + {"riscv64", "math/big", "mulWW"}: struct{}{}, + {"riscv64", "math/bits", "Add"}: struct{}{}, + {"riscv64", "math/bits", "Add64"}: struct{}{}, + {"riscv64", "math/bits", "Len"}: struct{}{}, + {"riscv64", "math/bits", "Len16"}: struct{}{}, + {"riscv64", "math/bits", "Len32"}: struct{}{}, + {"riscv64", "math/bits", "Len64"}: struct{}{}, + {"riscv64", "math/bits", "Len8"}: struct{}{}, + {"riscv64", "math/bits", "Mul"}: struct{}{}, + {"riscv64", "math/bits", "Mul64"}: struct{}{}, + {"riscv64", "math/bits", "OnesCount"}: struct{}{}, + {"riscv64", "math/bits", "OnesCount16"}: struct{}{}, + {"riscv64", "math/bits", "OnesCount32"}: struct{}{}, + {"riscv64", "math/bits", "OnesCount64"}: struct{}{}, + {"riscv64", "math/bits", "OnesCount8"}: struct{}{}, + {"riscv64", "math/bits", "ReverseBytes16"}: struct{}{}, + {"riscv64", "math/bits", "ReverseBytes32"}: struct{}{}, + {"riscv64", "math/bits", "ReverseBytes64"}: struct{}{}, + {"riscv64", "math/bits", "RotateLeft"}: struct{}{}, + {"riscv64", "math/bits", "RotateLeft16"}: struct{}{}, + {"riscv64", "math/bits", "RotateLeft32"}: struct{}{}, + {"riscv64", "math/bits", "RotateLeft64"}: struct{}{}, + {"riscv64", "math/bits", "RotateLeft8"}: struct{}{}, + {"riscv64", "math/bits", "Sub"}: struct{}{}, + {"riscv64", "math/bits", "Sub64"}: struct{}{}, + {"riscv64", "math/bits", "TrailingZeros16"}: struct{}{}, + {"riscv64", "math/bits", "TrailingZeros32"}: struct{}{}, + {"riscv64", "math/bits", "TrailingZeros64"}: struct{}{}, + {"riscv64", "math/bits", "TrailingZeros8"}: struct{}{}, + {"riscv64", "runtime", "KeepAlive"}: struct{}{}, + {"riscv64", "runtime", "publicationBarrier"}: struct{}{}, + {"riscv64", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"riscv64", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"riscv64", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"riscv64", "sync/atomic", "AddInt32"}: struct{}{}, + {"riscv64", "sync/atomic", "AddInt64"}: struct{}{}, + {"riscv64", "sync/atomic", "AddUint32"}: struct{}{}, + {"riscv64", "sync/atomic", "AddUint64"}: struct{}{}, + {"riscv64", "sync/atomic", "AddUintptr"}: struct{}{}, + {"riscv64", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"riscv64", "sync/atomic", "CompareAndSwapInt64"}: struct{}{}, + {"riscv64", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"riscv64", "sync/atomic", "CompareAndSwapUint64"}: struct{}{}, + {"riscv64", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"riscv64", "sync/atomic", "LoadInt32"}: struct{}{}, + {"riscv64", "sync/atomic", "LoadInt64"}: struct{}{}, + {"riscv64", "sync/atomic", "LoadPointer"}: struct{}{}, + {"riscv64", "sync/atomic", "LoadUint32"}: struct{}{}, + {"riscv64", "sync/atomic", "LoadUint64"}: struct{}{}, + {"riscv64", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"riscv64", "sync/atomic", "StoreInt32"}: struct{}{}, + {"riscv64", "sync/atomic", "StoreInt64"}: struct{}{}, + {"riscv64", "sync/atomic", "StoreUint32"}: struct{}{}, + {"riscv64", "sync/atomic", "StoreUint64"}: struct{}{}, + {"riscv64", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"riscv64", "sync/atomic", "SwapInt32"}: struct{}{}, + {"riscv64", "sync/atomic", "SwapInt64"}: struct{}{}, + {"riscv64", "sync/atomic", "SwapUint32"}: struct{}{}, + {"riscv64", "sync/atomic", "SwapUint64"}: struct{}{}, + {"riscv64", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"riscv64", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "And"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "And8"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Cas"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Cas64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "CasRel"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Casint32"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Casint64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Casp1"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Casuintptr"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Load"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Load64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Load8"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "LoadAcq"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "LoadAcq64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "LoadAcquintptr"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Loadint32"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Loadint64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Loadp"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Loaduint"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Loaduintptr"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Or"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Or8"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Store"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Store64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Store8"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "StoreRel"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "StoreRel64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "StoreReluintptr"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Storeint32"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Storeint64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "StorepNoWB"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Storeuintptr"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Xadd"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Xadd64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Xaddint32"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Xaddint64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Xadduintptr"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Xchg"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Xchg64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Xchgint32"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Xchgint64"}: struct{}{}, + {"s390x", "internal/runtime/atomic", "Xchguintptr"}: struct{}{}, + {"s390x", "internal/runtime/math", "Add64"}: struct{}{}, + {"s390x", "internal/runtime/math", "Mul64"}: struct{}{}, + {"s390x", "internal/runtime/sys", "Bswap32"}: struct{}{}, + {"s390x", "internal/runtime/sys", "Bswap64"}: struct{}{}, + {"s390x", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"s390x", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"s390x", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"s390x", "internal/runtime/sys", "Len64"}: struct{}{}, + {"s390x", "internal/runtime/sys", "Len8"}: struct{}{}, + {"s390x", "internal/runtime/sys", "OnesCount64"}: struct{}{}, + {"s390x", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"s390x", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"s390x", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"s390x", "math", "Ceil"}: struct{}{}, + {"s390x", "math", "FMA"}: struct{}{}, + {"s390x", "math", "Floor"}: struct{}{}, + {"s390x", "math", "Round"}: struct{}{}, + {"s390x", "math", "RoundToEven"}: struct{}{}, + {"s390x", "math", "Trunc"}: struct{}{}, + {"s390x", "math", "sqrt"}: struct{}{}, + {"s390x", "math/big", "mulWW"}: struct{}{}, + {"s390x", "math/bits", "Add"}: struct{}{}, + {"s390x", "math/bits", "Add64"}: struct{}{}, + {"s390x", "math/bits", "Len"}: struct{}{}, + {"s390x", "math/bits", "Len16"}: struct{}{}, + {"s390x", "math/bits", "Len32"}: struct{}{}, + {"s390x", "math/bits", "Len64"}: struct{}{}, + {"s390x", "math/bits", "Len8"}: struct{}{}, + {"s390x", "math/bits", "Mul"}: struct{}{}, + {"s390x", "math/bits", "Mul64"}: struct{}{}, + {"s390x", "math/bits", "OnesCount"}: struct{}{}, + {"s390x", "math/bits", "OnesCount16"}: struct{}{}, + {"s390x", "math/bits", "OnesCount32"}: struct{}{}, + {"s390x", "math/bits", "OnesCount64"}: struct{}{}, + {"s390x", "math/bits", "OnesCount8"}: struct{}{}, + {"s390x", "math/bits", "ReverseBytes32"}: struct{}{}, + {"s390x", "math/bits", "ReverseBytes64"}: struct{}{}, + {"s390x", "math/bits", "RotateLeft"}: struct{}{}, + {"s390x", "math/bits", "RotateLeft32"}: struct{}{}, + {"s390x", "math/bits", "RotateLeft64"}: struct{}{}, + {"s390x", "math/bits", "Sub"}: struct{}{}, + {"s390x", "math/bits", "Sub64"}: struct{}{}, + {"s390x", "math/bits", "TrailingZeros16"}: struct{}{}, + {"s390x", "math/bits", "TrailingZeros32"}: struct{}{}, + {"s390x", "math/bits", "TrailingZeros64"}: struct{}{}, + {"s390x", "math/bits", "TrailingZeros8"}: struct{}{}, + {"s390x", "runtime", "KeepAlive"}: struct{}{}, + {"s390x", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"s390x", "sync", "runtime_LoadAcquintptr"}: struct{}{}, + {"s390x", "sync", "runtime_StoreReluintptr"}: struct{}{}, + {"s390x", "sync/atomic", "AddInt32"}: struct{}{}, + {"s390x", "sync/atomic", "AddInt64"}: struct{}{}, + {"s390x", "sync/atomic", "AddUint32"}: struct{}{}, + {"s390x", "sync/atomic", "AddUint64"}: struct{}{}, + {"s390x", "sync/atomic", "AddUintptr"}: struct{}{}, + {"s390x", "sync/atomic", "CompareAndSwapInt32"}: struct{}{}, + {"s390x", "sync/atomic", "CompareAndSwapInt64"}: struct{}{}, + {"s390x", "sync/atomic", "CompareAndSwapUint32"}: struct{}{}, + {"s390x", "sync/atomic", "CompareAndSwapUint64"}: struct{}{}, + {"s390x", "sync/atomic", "CompareAndSwapUintptr"}: struct{}{}, + {"s390x", "sync/atomic", "LoadInt32"}: struct{}{}, + {"s390x", "sync/atomic", "LoadInt64"}: struct{}{}, + {"s390x", "sync/atomic", "LoadPointer"}: struct{}{}, + {"s390x", "sync/atomic", "LoadUint32"}: struct{}{}, + {"s390x", "sync/atomic", "LoadUint64"}: struct{}{}, + {"s390x", "sync/atomic", "LoadUintptr"}: struct{}{}, + {"s390x", "sync/atomic", "StoreInt32"}: struct{}{}, + {"s390x", "sync/atomic", "StoreInt64"}: struct{}{}, + {"s390x", "sync/atomic", "StoreUint32"}: struct{}{}, + {"s390x", "sync/atomic", "StoreUint64"}: struct{}{}, + {"s390x", "sync/atomic", "StoreUintptr"}: struct{}{}, + {"s390x", "sync/atomic", "SwapInt32"}: struct{}{}, + {"s390x", "sync/atomic", "SwapInt64"}: struct{}{}, + {"s390x", "sync/atomic", "SwapUint32"}: struct{}{}, + {"s390x", "sync/atomic", "SwapUint64"}: struct{}{}, + {"s390x", "sync/atomic", "SwapUintptr"}: struct{}{}, + {"s390x", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, + {"wasm", "internal/runtime/math", "Mul64"}: struct{}{}, + {"wasm", "internal/runtime/sys", "GetCallerPC"}: struct{}{}, + {"wasm", "internal/runtime/sys", "GetCallerSP"}: struct{}{}, + {"wasm", "internal/runtime/sys", "GetClosurePtr"}: struct{}{}, + {"wasm", "internal/runtime/sys", "Len64"}: struct{}{}, + {"wasm", "internal/runtime/sys", "Len8"}: struct{}{}, + {"wasm", "internal/runtime/sys", "OnesCount64"}: struct{}{}, + {"wasm", "internal/runtime/sys", "TrailingZeros32"}: struct{}{}, + {"wasm", "internal/runtime/sys", "TrailingZeros64"}: struct{}{}, + {"wasm", "internal/runtime/sys", "TrailingZeros8"}: struct{}{}, + {"wasm", "math", "Abs"}: struct{}{}, + {"wasm", "math", "Ceil"}: struct{}{}, + {"wasm", "math", "Copysign"}: struct{}{}, + {"wasm", "math", "Floor"}: struct{}{}, + {"wasm", "math", "RoundToEven"}: struct{}{}, + {"wasm", "math", "Trunc"}: struct{}{}, + {"wasm", "math", "sqrt"}: struct{}{}, + {"wasm", "math/big", "mulWW"}: struct{}{}, + {"wasm", "math/bits", "Len"}: struct{}{}, + {"wasm", "math/bits", "Len16"}: struct{}{}, + {"wasm", "math/bits", "Len32"}: struct{}{}, + {"wasm", "math/bits", "Len64"}: struct{}{}, + {"wasm", "math/bits", "Len8"}: struct{}{}, + {"wasm", "math/bits", "Mul"}: struct{}{}, + {"wasm", "math/bits", "Mul64"}: struct{}{}, + {"wasm", "math/bits", "OnesCount"}: struct{}{}, + {"wasm", "math/bits", "OnesCount16"}: struct{}{}, + {"wasm", "math/bits", "OnesCount32"}: struct{}{}, + {"wasm", "math/bits", "OnesCount64"}: struct{}{}, + {"wasm", "math/bits", "OnesCount8"}: struct{}{}, + {"wasm", "math/bits", "RotateLeft"}: struct{}{}, + {"wasm", "math/bits", "RotateLeft32"}: struct{}{}, + {"wasm", "math/bits", "RotateLeft64"}: struct{}{}, + {"wasm", "math/bits", "TrailingZeros16"}: struct{}{}, + {"wasm", "math/bits", "TrailingZeros32"}: struct{}{}, + {"wasm", "math/bits", "TrailingZeros64"}: struct{}{}, + {"wasm", "math/bits", "TrailingZeros8"}: struct{}{}, + {"wasm", "runtime", "KeepAlive"}: struct{}{}, + {"wasm", "runtime", "slicebytetostringtmp"}: struct{}{}, + {"wasm", "crypto/internal/constanttime", "Select"}: struct{}{}, + {"wasm", "crypto/internal/constanttime", "boolToUint8"}: struct{}{}, +} + +func TestIntrinsics(t *testing.T) { + cfg := &intrinsicBuildConfig{ + goppc64: 10, + goriscv64: 23, + } + initIntrinsics(cfg) + + if *updateIntrinsics { + var updatedIntrinsics []*testIntrinsicKey + for ik, _ := range intrinsics { + updatedIntrinsics = append(updatedIntrinsics, &testIntrinsicKey{ik.arch.Name, ik.pkg, ik.fn}) + } + slices.SortFunc(updatedIntrinsics, func(a, b *testIntrinsicKey) int { + if n := strings.Compare(a.archName, b.archName); n != 0 { + return n + } + if n := strings.Compare(a.pkg, b.pkg); n != 0 { + return n + } + return strings.Compare(a.fn, b.fn) + }) + for _, tik := range updatedIntrinsics { + fmt.Printf("\t{%q, %q, %q}: struct{}{},\n", tik.archName, tik.pkg, tik.fn) + } + return + } + + gotIntrinsics := make(map[testIntrinsicKey]struct{}) + for ik, _ := range intrinsics { + gotIntrinsics[testIntrinsicKey{ik.arch.Name, ik.pkg, ik.fn}] = struct{}{} + } + for ik, _ := range gotIntrinsics { + if _, found := wantIntrinsics[ik]; !found && (ik.pkg != "simd/archsimd" || *simd) { + t.Errorf("Got unwanted intrinsic %v %v.%v", ik.archName, ik.pkg, ik.fn) + } + } + + for ik, _ := range wantIntrinsics { + if _, found := gotIntrinsics[ik]; !found && (ik.pkg != "simd/archsimd" || *simd) { + t.Errorf("Want missing intrinsic %v %v.%v", ik.archName, ik.pkg, ik.fn) + } + } +} + +func TestIntrinsicBuilders(t *testing.T) { + cfg := &intrinsicBuildConfig{} + initIntrinsics(cfg) + + for _, arch := range sys.Archs { + if intrinsics.lookup(arch, "internal/runtime/sys", "GetCallerSP") == nil { + t.Errorf("No intrinsic for internal/runtime/sys.GetCallerSP on arch %v", arch) + } + } + + if intrinsics.lookup(sys.ArchAMD64, "runtime", "slicebytetostringtmp") == nil { + t.Error("No intrinsic for runtime.slicebytetostringtmp") + } + + if intrinsics.lookup(sys.ArchRISCV64, "runtime", "publicationBarrier") == nil { + t.Errorf("No intrinsic for runtime.publicationBarrier on arch %v", sys.ArchRISCV64) + } + + if intrinsics.lookup(sys.ArchAMD64, "internal/runtime/sys", "Bswap32") == nil { + t.Errorf("No intrinsic for internal/runtime/sys.Bswap32 on arch %v", sys.ArchAMD64) + } + if intrinsics.lookup(sys.ArchAMD64, "internal/runtime/sys", "Bswap64") == nil { + t.Errorf("No intrinsic for internal/runtime/sys.Bswap64 on arch %v", sys.ArchAMD64) + } + + if intrinsics.lookup(sys.ArchPPC64, "internal/runtime/sys", "Bswap64") != nil { + t.Errorf("Found intrinsic for internal/runtime/sys.Bswap64 on arch %v", sys.ArchPPC64) + } + + cfg.goppc64 = 10 + cfg.instrumenting = true + + initIntrinsics(cfg) + + if intrinsics.lookup(sys.ArchAMD64, "runtime", "slicebytetostringtmp") != nil { + t.Error("Intrinsic incorrectly exists for runtime.slicebytetostringtmp") + } + + if intrinsics.lookup(sys.ArchPPC64, "internal/runtime/sys", "Bswap64") == nil { + t.Errorf("No intrinsic for internal/runtime/sys.Bswap64 on arch %v", sys.ArchPPC64) + } +} diff --git a/go/src/cmd/compile/internal/ssagen/nowb.go b/go/src/cmd/compile/internal/ssagen/nowb.go new file mode 100644 index 0000000000000000000000000000000000000000..8e776695e3cef5db8e623ee44af51af33e2ff34a --- /dev/null +++ b/go/src/cmd/compile/internal/ssagen/nowb.go @@ -0,0 +1,203 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssagen + +import ( + "fmt" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" +) + +func EnableNoWriteBarrierRecCheck() { + nowritebarrierrecCheck = newNowritebarrierrecChecker() +} + +func NoWriteBarrierRecCheck() { + // Write barriers are now known. Check the + // call graph. + nowritebarrierrecCheck.check() + nowritebarrierrecCheck = nil +} + +var nowritebarrierrecCheck *nowritebarrierrecChecker + +type nowritebarrierrecChecker struct { + // extraCalls contains extra function calls that may not be + // visible during later analysis. It maps from the ODCLFUNC of + // the caller to a list of callees. + extraCalls map[*ir.Func][]nowritebarrierrecCall + + // curfn is the current function during AST walks. + curfn *ir.Func +} + +type nowritebarrierrecCall struct { + target *ir.Func // caller or callee + lineno src.XPos // line of call +} + +// newNowritebarrierrecChecker creates a nowritebarrierrecChecker. It +// must be called before walk. +func newNowritebarrierrecChecker() *nowritebarrierrecChecker { + c := &nowritebarrierrecChecker{ + extraCalls: make(map[*ir.Func][]nowritebarrierrecCall), + } + + // Find all systemstack calls and record their targets. In + // general, flow analysis can't see into systemstack, but it's + // important to handle it for this check, so we model it + // directly. This has to happen before transforming closures in walk since + // it's a lot harder to work out the argument after. + for _, n := range typecheck.Target.Funcs { + c.curfn = n + if c.curfn.ABIWrapper() { + // We only want "real" calls to these + // functions, not the generated ones within + // their own ABI wrappers. + continue + } + ir.Visit(n, c.findExtraCalls) + } + c.curfn = nil + return c +} + +func (c *nowritebarrierrecChecker) findExtraCalls(nn ir.Node) { + if nn.Op() != ir.OCALLFUNC { + return + } + n := nn.(*ir.CallExpr) + if n.Fun == nil || n.Fun.Op() != ir.ONAME { + return + } + fn := n.Fun.(*ir.Name) + if fn.Class != ir.PFUNC || fn.Defn == nil { + return + } + if types.RuntimeSymName(fn.Sym()) != "systemstack" { + return + } + + var callee *ir.Func + arg := n.Args[0] + switch arg.Op() { + case ir.ONAME: + arg := arg.(*ir.Name) + callee = arg.Defn.(*ir.Func) + case ir.OCLOSURE: + arg := arg.(*ir.ClosureExpr) + callee = arg.Func + default: + base.Fatalf("expected ONAME or OCLOSURE node, got %+v", arg) + } + c.extraCalls[c.curfn] = append(c.extraCalls[c.curfn], nowritebarrierrecCall{callee, n.Pos()}) +} + +// recordCall records a call from ODCLFUNC node "from", to function +// symbol "to" at position pos. +// +// This should be done as late as possible during compilation to +// capture precise call graphs. The target of the call is an LSym +// because that's all we know after we start SSA. +// +// This can be called concurrently for different from Nodes. +func (c *nowritebarrierrecChecker) recordCall(fn *ir.Func, to *obj.LSym, pos src.XPos) { + // We record this information on the *Func so this is concurrent-safe. + if fn.NWBRCalls == nil { + fn.NWBRCalls = new([]ir.SymAndPos) + } + *fn.NWBRCalls = append(*fn.NWBRCalls, ir.SymAndPos{Sym: to, Pos: pos}) +} + +func (c *nowritebarrierrecChecker) check() { + // We walk the call graph as late as possible so we can + // capture all calls created by lowering, but this means we + // only get to see the obj.LSyms of calls. symToFunc lets us + // get back to the ODCLFUNCs. + symToFunc := make(map[*obj.LSym]*ir.Func) + // funcs records the back-edges of the BFS call graph walk. It + // maps from the ODCLFUNC of each function that must not have + // write barriers to the call that inhibits them. Functions + // that are directly marked go:nowritebarrierrec are in this + // map with a zero-valued nowritebarrierrecCall. This also + // acts as the set of marks for the BFS of the call graph. + funcs := make(map[*ir.Func]nowritebarrierrecCall) + // q is the queue of ODCLFUNC Nodes to visit in BFS order. + var q ir.NameQueue + + for _, fn := range typecheck.Target.Funcs { + symToFunc[fn.LSym] = fn + + // Make nowritebarrierrec functions BFS roots. + if fn.Pragma&ir.Nowritebarrierrec != 0 { + funcs[fn] = nowritebarrierrecCall{} + q.PushRight(fn.Nname) + } + // Check go:nowritebarrier functions. + if fn.Pragma&ir.Nowritebarrier != 0 && fn.WBPos.IsKnown() { + base.ErrorfAt(fn.WBPos, 0, "write barrier prohibited") + } + } + + // Perform a BFS of the call graph from all + // go:nowritebarrierrec functions. + enqueue := func(src, target *ir.Func, pos src.XPos) { + if target.Pragma&ir.Yeswritebarrierrec != 0 { + // Don't flow into this function. + return + } + if _, ok := funcs[target]; ok { + // Already found a path to target. + return + } + + // Record the path. + funcs[target] = nowritebarrierrecCall{target: src, lineno: pos} + q.PushRight(target.Nname) + } + for !q.Empty() { + fn := q.PopLeft().Func + + // Check fn. + if fn.WBPos.IsKnown() { + var err strings.Builder + call := funcs[fn] + for call.target != nil { + fmt.Fprintf(&err, "\n\t%v: called by %v", base.FmtPos(call.lineno), call.target.Nname) + call = funcs[call.target] + } + // Seeing this error in a failed CI run? It indicates that + // a function in the runtime package marked nowritebarrierrec + // (the outermost stack element) was found, by a static + // reachability analysis over the fully lowered optimized code, + // to call a function (fn) that involves a write barrier. + // + // Even if the call path is infeasable, + // you will need to reorganize the code to avoid it. + base.ErrorfAt(fn.WBPos, 0, "write barrier prohibited by caller; %v%s", fn.Nname, err.String()) + continue + } + + // Enqueue fn's calls. + for _, callee := range c.extraCalls[fn] { + enqueue(fn, callee.target, callee.lineno) + } + if fn.NWBRCalls == nil { + continue + } + for _, callee := range *fn.NWBRCalls { + target := symToFunc[callee.Sym] + if target != nil { + enqueue(fn, target, callee.Pos) + } + } + } +} diff --git a/go/src/cmd/compile/internal/ssagen/pgen.go b/go/src/cmd/compile/internal/ssagen/pgen.go new file mode 100644 index 0000000000000000000000000000000000000000..0a2010363f8d0497881110aaee4c2f48cb3bf802 --- /dev/null +++ b/go/src/cmd/compile/internal/ssagen/pgen.go @@ -0,0 +1,450 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssagen + +import ( + "fmt" + "internal/buildcfg" + "os" + "slices" + "sort" + "strings" + "sync" + + "cmd/compile/internal/base" + "cmd/compile/internal/inline" + "cmd/compile/internal/ir" + "cmd/compile/internal/liveness" + "cmd/compile/internal/objw" + "cmd/compile/internal/pgoir" + "cmd/compile/internal/ssa" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" +) + +// cmpstackvarlt reports whether the stack variable a sorts before b. +func cmpstackvarlt(a, b *ir.Name, mls *liveness.MergeLocalsState) bool { + // Sort non-autos before autos. + if needAlloc(a) != needAlloc(b) { + return needAlloc(b) + } + + // If both are non-auto (e.g., parameters, results), then sort by + // frame offset (defined by ABI). + if !needAlloc(a) { + return a.FrameOffset() < b.FrameOffset() + } + + // From here on, a and b are both autos (i.e., local variables). + + // Sort followers after leaders, if mls != nil + if mls != nil { + aFollow := mls.Subsumed(a) + bFollow := mls.Subsumed(b) + if aFollow != bFollow { + return bFollow + } + } + + // Sort used before unused (so AllocFrame can truncate unused + // variables). + if a.Used() != b.Used() { + return a.Used() + } + + // Sort pointer-typed before non-pointer types. + // Keeps the stack's GC bitmap compact. + ap := a.Type().HasPointers() + bp := b.Type().HasPointers() + if ap != bp { + return ap + } + + // Group variables that need zeroing, so we can efficiently zero + // them altogether. + ap = a.Needzero() + bp = b.Needzero() + if ap != bp { + return ap + } + + // Sort variables in descending alignment order, so we can optimally + // pack variables into the frame. + if a.Type().Alignment() != b.Type().Alignment() { + return a.Type().Alignment() > b.Type().Alignment() + } + + // Sort normal variables before open-coded-defer slots, so that the + // latter are grouped together and near the top of the frame (to + // minimize varint encoding of their varp offset). + if a.OpenDeferSlot() != b.OpenDeferSlot() { + return a.OpenDeferSlot() + } + + // If a and b are both open-coded defer slots, then order them by + // index in descending order, so they'll be laid out in the frame in + // ascending order. + // + // Their index was saved in FrameOffset in state.openDeferSave. + if a.OpenDeferSlot() { + return a.FrameOffset() > b.FrameOffset() + } + + // Tie breaker for stable results. + return a.Sym().Name < b.Sym().Name +} + +// needAlloc reports whether n is within the current frame, for which we need to +// allocate space. In particular, it excludes arguments and results, which are in +// the callers frame. +func needAlloc(n *ir.Name) bool { + if n.Op() != ir.ONAME { + base.FatalfAt(n.Pos(), "%v has unexpected Op %v", n, n.Op()) + } + + switch n.Class { + case ir.PAUTO: + return true + case ir.PPARAM: + return false + case ir.PPARAMOUT: + return n.IsOutputParamInRegisters() + + default: + base.FatalfAt(n.Pos(), "%v has unexpected Class %v", n, n.Class) + return false + } +} + +func (s *ssafn) AllocFrame(f *ssa.Func) { + s.stksize = 0 + s.stkptrsize = 0 + s.stkalign = int64(types.RegSize) + fn := s.curfn + + // Mark the PAUTO's unused. + for _, ln := range fn.Dcl { + if ln.OpenDeferSlot() { + // Open-coded defer slots have indices that were assigned + // upfront during SSA construction, but the defer statement can + // later get removed during deadcode elimination (#61895). To + // keep their relative offsets correct, treat them all as used. + continue + } + + if needAlloc(ln) { + ln.SetUsed(false) + } + } + + for _, l := range f.RegAlloc { + if ls, ok := l.(ssa.LocalSlot); ok { + ls.N.SetUsed(true) + } + } + + for _, b := range f.Blocks { + for _, v := range b.Values { + if n, ok := v.Aux.(*ir.Name); ok { + switch n.Class { + case ir.PPARAMOUT: + if n.IsOutputParamInRegisters() && v.Op == ssa.OpVarDef { + // ignore VarDef, look for "real" uses. + // TODO: maybe do this for PAUTO as well? + continue + } + fallthrough + case ir.PPARAM, ir.PAUTO: + n.SetUsed(true) + } + } + } + } + + var mls *liveness.MergeLocalsState + var leaders map[*ir.Name]int64 + if base.Debug.MergeLocals != 0 { + mls = liveness.MergeLocals(fn, f) + if base.Debug.MergeLocalsTrace > 0 && mls != nil { + savedNP, savedP := mls.EstSavings() + fmt.Fprintf(os.Stderr, "%s: %d bytes of stack space saved via stack slot merging (%d nonpointer %d pointer)\n", ir.FuncName(fn), savedNP+savedP, savedNP, savedP) + if base.Debug.MergeLocalsTrace > 1 { + fmt.Fprintf(os.Stderr, "=-= merge locals state for %v:\n%v", + fn, mls) + } + } + leaders = make(map[*ir.Name]int64) + } + + // Use sort.SliceStable instead of sort.Slice so stack layout (and thus + // compiler output) is less sensitive to frontend changes that + // introduce or remove unused variables. + sort.SliceStable(fn.Dcl, func(i, j int) bool { + return cmpstackvarlt(fn.Dcl[i], fn.Dcl[j], mls) + }) + + if mls != nil { + // Rewrite fn.Dcl to reposition followers (subsumed vars) to + // be immediately following the leader var in their partition. + followers := []*ir.Name{} + newdcl := make([]*ir.Name, 0, len(fn.Dcl)) + for i := 0; i < len(fn.Dcl); i++ { + n := fn.Dcl[i] + if mls.Subsumed(n) { + continue + } + newdcl = append(newdcl, n) + if mls.IsLeader(n) { + followers = mls.Followers(n, followers) + // position followers immediately after leader + newdcl = append(newdcl, followers...) + } + } + fn.Dcl = newdcl + } + + if base.Debug.MergeLocalsTrace > 1 && mls != nil { + fmt.Fprintf(os.Stderr, "=-= sorted DCL for %v:\n", fn) + for i, v := range fn.Dcl { + if !ssa.IsMergeCandidate(v) { + continue + } + fmt.Fprintf(os.Stderr, " %d: %q isleader=%v subsumed=%v used=%v sz=%d align=%d t=%s\n", i, v.Sym().Name, mls.IsLeader(v), mls.Subsumed(v), v.Used(), v.Type().Size(), v.Type().Alignment(), v.Type().String()) + } + } + + // Reassign stack offsets of the locals that are used. + lastHasPtr := false + for i, n := range fn.Dcl { + if n.Op() != ir.ONAME || n.Class != ir.PAUTO && !(n.Class == ir.PPARAMOUT && n.IsOutputParamInRegisters()) { + // i.e., stack assign if AUTO, or if PARAMOUT in registers (which has no predefined spill locations) + continue + } + if mls != nil && mls.Subsumed(n) { + continue + } + if !n.Used() { + fn.DebugInfo.(*ssa.FuncDebug).OptDcl = fn.Dcl[i:] + fn.Dcl = fn.Dcl[:i] + break + } + types.CalcSize(n.Type()) + w := n.Type().Size() + if w >= types.MaxWidth || w < 0 { + base.Fatalf("bad width") + } + if w == 0 && lastHasPtr { + // Pad between a pointer-containing object and a zero-sized object. + // This prevents a pointer to the zero-sized object from being interpreted + // as a pointer to the pointer-containing object (and causing it + // to be scanned when it shouldn't be). See issue 24993. + w = 1 + } + s.stksize += w + s.stksize = types.RoundUp(s.stksize, n.Type().Alignment()) + if n.Type().Alignment() > int64(types.RegSize) { + s.stkalign = n.Type().Alignment() + } + if n.Type().HasPointers() { + s.stkptrsize = s.stksize + lastHasPtr = true + } else { + lastHasPtr = false + } + n.SetFrameOffset(-s.stksize) + if mls != nil && mls.IsLeader(n) { + leaders[n] = -s.stksize + } + } + + if mls != nil { + // Update offsets of followers (subsumed vars) to be the + // same as the leader var in their partition. + for i := 0; i < len(fn.Dcl); i++ { + n := fn.Dcl[i] + if !mls.Subsumed(n) { + continue + } + leader := mls.Leader(n) + off, ok := leaders[leader] + if !ok { + panic("internal error missing leader") + } + // Set the stack offset this subsumed (followed) var + // to be the same as the leader. + n.SetFrameOffset(off) + } + + if base.Debug.MergeLocalsTrace > 1 { + fmt.Fprintf(os.Stderr, "=-= stack layout for %v:\n", fn) + for i, v := range fn.Dcl { + if v.Op() != ir.ONAME || (v.Class != ir.PAUTO && !(v.Class == ir.PPARAMOUT && v.IsOutputParamInRegisters())) { + continue + } + fmt.Fprintf(os.Stderr, " %d: %q frameoff %d isleader=%v subsumed=%v sz=%d align=%d t=%s\n", i, v.Sym().Name, v.FrameOffset(), mls.IsLeader(v), mls.Subsumed(v), v.Type().Size(), v.Type().Alignment(), v.Type().String()) + } + } + } + + s.stksize = types.RoundUp(s.stksize, s.stkalign) + s.stkptrsize = types.RoundUp(s.stkptrsize, s.stkalign) +} + +const maxStackSize = 1 << 30 + +// Compile builds an SSA backend function, +// uses it to generate a plist, +// and flushes that plist to machine code. +// worker indicates which of the backend workers is doing the processing. +func Compile(fn *ir.Func, worker int, profile *pgoir.Profile) { + f := buildssa(fn, worker, inline.IsPgoHotFunc(fn, profile) || inline.HasPgoHotInline(fn)) + // Note: check arg size to fix issue 25507. + if f.Frontend().(*ssafn).stksize >= maxStackSize || f.OwnAux.ArgWidth() >= maxStackSize { + largeStackFramesMu.Lock() + largeStackFrames = append(largeStackFrames, largeStack{locals: f.Frontend().(*ssafn).stksize, args: f.OwnAux.ArgWidth(), pos: fn.Pos()}) + largeStackFramesMu.Unlock() + return + } + pp := objw.NewProgs(fn, worker) + defer pp.Free() + genssa(f, pp) + // Check frame size again. + // The check above included only the space needed for local variables. + // After genssa, the space needed includes local variables and the callee arg region. + // We must do this check prior to calling pp.Flush. + // If there are any oversized stack frames, + // the assembler may emit inscrutable complaints about invalid instructions. + if pp.Text.To.Offset >= maxStackSize { + largeStackFramesMu.Lock() + locals := f.Frontend().(*ssafn).stksize + largeStackFrames = append(largeStackFrames, largeStack{locals: locals, args: f.OwnAux.ArgWidth(), callee: pp.Text.To.Offset - locals, pos: fn.Pos()}) + largeStackFramesMu.Unlock() + return + } + + pp.Flush() // assemble, fill in boilerplate, etc. + + // If we're compiling the package init function, search for any + // relocations that target global map init outline functions and + // turn them into weak relocs. + if fn.IsPackageInit() && base.Debug.WrapGlobalMapCtl != 1 { + weakenGlobalMapInitRelocs(fn) + } + + // fieldtrack must be called after pp.Flush. See issue 20014. + fieldtrack(pp.Text.From.Sym, fn.FieldTrack) +} + +// globalMapInitLsyms records the LSym of each map.init.NNN outlined +// map initializer function created by the compiler. +var globalMapInitLsyms map[*obj.LSym]struct{} + +// RegisterMapInitLsym records "s" in the set of outlined map initializer +// functions. +func RegisterMapInitLsym(s *obj.LSym) { + if globalMapInitLsyms == nil { + globalMapInitLsyms = make(map[*obj.LSym]struct{}) + } + globalMapInitLsyms[s] = struct{}{} +} + +// weakenGlobalMapInitRelocs walks through all of the relocations on a +// given a package init function "fn" and looks for relocs that target +// outlined global map initializer functions; if it finds any such +// relocs, it flags them as R_WEAK. +func weakenGlobalMapInitRelocs(fn *ir.Func) { + if globalMapInitLsyms == nil { + return + } + for i := range fn.LSym.R { + tgt := fn.LSym.R[i].Sym + if tgt == nil { + continue + } + if _, ok := globalMapInitLsyms[tgt]; !ok { + continue + } + if base.Debug.WrapGlobalMapDbg > 1 { + fmt.Fprintf(os.Stderr, "=-= weakify fn %v reloc %d %+v\n", fn, i, + fn.LSym.R[i]) + } + // set the R_WEAK bit, leave rest of reloc type intact + fn.LSym.R[i].Type |= objabi.R_WEAK + } +} + +// StackOffset returns the stack location of a LocalSlot relative to the +// stack pointer, suitable for use in a DWARF location entry. This has nothing +// to do with its offset in the user variable. +func StackOffset(slot ssa.LocalSlot) int32 { + n := slot.N + var off int64 + switch n.Class { + case ir.PPARAM, ir.PPARAMOUT: + if !n.IsOutputParamInRegisters() { + off = n.FrameOffset() + base.Ctxt.Arch.FixedFrameSize + break + } + fallthrough // PPARAMOUT in registers allocates like an AUTO + case ir.PAUTO: + off = n.FrameOffset() + if base.Ctxt.Arch.FixedFrameSize == 0 { + off -= int64(types.PtrSize) + } + if buildcfg.FramePointerEnabled { + off -= int64(types.PtrSize) + } + } + return int32(off + slot.Off) +} + +// fieldtrack adds R_USEFIELD relocations to fnsym to record any +// struct fields that it used. +func fieldtrack(fnsym *obj.LSym, tracked map[*obj.LSym]struct{}) { + if fnsym == nil { + return + } + if !buildcfg.Experiment.FieldTrack || len(tracked) == 0 { + return + } + + trackSyms := make([]*obj.LSym, 0, len(tracked)) + for sym := range tracked { + trackSyms = append(trackSyms, sym) + } + slices.SortFunc(trackSyms, func(a, b *obj.LSym) int { return strings.Compare(a.Name, b.Name) }) + for _, sym := range trackSyms { + fnsym.AddRel(base.Ctxt, obj.Reloc{Type: objabi.R_USEFIELD, Sym: sym}) + } +} + +// largeStack is info about a function whose stack frame is too large (rare). +type largeStack struct { + locals int64 + args int64 + callee int64 + pos src.XPos +} + +var ( + largeStackFramesMu sync.Mutex // protects largeStackFrames + largeStackFrames []largeStack +) + +func CheckLargeStacks() { + // Check whether any of the functions we have compiled have gigantic stack frames. + sort.Slice(largeStackFrames, func(i, j int) bool { + return largeStackFrames[i].pos.Before(largeStackFrames[j].pos) + }) + for _, large := range largeStackFrames { + if large.callee != 0 { + base.ErrorfAt(large.pos, 0, "stack frame too large (>1GB): %d MB locals + %d MB args + %d MB callee", large.locals>>20, large.args>>20, large.callee>>20) + } else { + base.ErrorfAt(large.pos, 0, "stack frame too large (>1GB): %d MB locals + %d MB args", large.locals>>20, large.args>>20) + } + } +} diff --git a/go/src/cmd/compile/internal/ssagen/phi.go b/go/src/cmd/compile/internal/ssagen/phi.go new file mode 100644 index 0000000000000000000000000000000000000000..4043ac457648e1e98a0e62db6f3c41be1b513d90 --- /dev/null +++ b/go/src/cmd/compile/internal/ssagen/phi.go @@ -0,0 +1,558 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssagen + +import ( + "container/heap" + "fmt" + + "cmd/compile/internal/ir" + "cmd/compile/internal/ssa" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +// This file contains the algorithm to place phi nodes in a function. +// For small functions, we use Braun, Buchwald, Hack, Leißa, Mallon, and Zwinkau. +// https://pp.info.uni-karlsruhe.de/uploads/publikationen/braun13cc.pdf +// For large functions, we use Sreedhar & Gao: A Linear Time Algorithm for Placing Φ-Nodes. +// http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.8.1979&rep=rep1&type=pdf + +const smallBlocks = 500 + +const debugPhi = false + +// fwdRefAux wraps an arbitrary ir.Node as an ssa.Aux for use with OpFwdref. +type fwdRefAux struct { + _ [0]func() // ensure ir.Node isn't compared for equality + N ir.Node +} + +func (fwdRefAux) CanBeAnSSAAux() {} + +// insertPhis finds all the places in the function where a phi is +// necessary and inserts them. +// Uses FwdRef ops to find all uses of variables, and s.defvars to find +// all definitions. +// Phi values are inserted, and all FwdRefs are changed to a Copy +// of the appropriate phi or definition. +// TODO: make this part of cmd/compile/internal/ssa somehow? +func (s *state) insertPhis() { + if len(s.f.Blocks) <= smallBlocks { + sps := simplePhiState{s: s, f: s.f, defvars: s.defvars} + sps.insertPhis() + return + } + ps := phiState{s: s, f: s.f, defvars: s.defvars} + ps.insertPhis() +} + +type phiState struct { + s *state // SSA state + f *ssa.Func // function to work on + defvars []map[ir.Node]*ssa.Value // defined variables at end of each block + + varnum map[ir.Node]int32 // variable numbering + + // properties of the dominator tree + idom []*ssa.Block // dominator parents + tree []domBlock // dominator child+sibling + level []int32 // level in dominator tree (0 = root or unreachable, 1 = children of root, ...) + + // scratch locations + priq blockHeap // priority queue of blocks, higher level (toward leaves) = higher priority + q []*ssa.Block // inner loop queue + queued *sparseSet // has been put in q + hasPhi *sparseSet // has a phi + hasDef *sparseSet // has a write of the variable we're processing + + // miscellaneous + placeholder *ssa.Value // value to use as a "not set yet" placeholder. +} + +func (s *phiState) insertPhis() { + if debugPhi { + fmt.Println(s.f.String()) + } + + // Find all the variables for which we need to match up reads & writes. + // This step prunes any basic-block-only variables from consideration. + // Generate a numbering for these variables. + s.varnum = map[ir.Node]int32{} + var vars []ir.Node + var vartypes []*types.Type + for _, b := range s.f.Blocks { + for _, v := range b.Values { + if v.Op != ssa.OpFwdRef { + continue + } + var_ := v.Aux.(fwdRefAux).N + + // Optimization: look back 1 block for the definition. + if len(b.Preds) == 1 { + c := b.Preds[0].Block() + if w := s.defvars[c.ID][var_]; w != nil { + v.Op = ssa.OpCopy + v.Aux = nil + v.AddArg(w) + continue + } + } + + if _, ok := s.varnum[var_]; ok { + continue + } + s.varnum[var_] = int32(len(vartypes)) + if debugPhi { + fmt.Printf("var%d = %v\n", len(vartypes), var_) + } + vars = append(vars, var_) + vartypes = append(vartypes, v.Type) + } + } + + if len(vartypes) == 0 { + return + } + + // Find all definitions of the variables we need to process. + // defs[n] contains all the blocks in which variable number n is assigned. + defs := make([][]*ssa.Block, len(vartypes)) + for _, b := range s.f.Blocks { + for var_ := range s.defvars[b.ID] { // TODO: encode defvars some other way (explicit ops)? make defvars[n] a slice instead of a map. + if n, ok := s.varnum[var_]; ok { + defs[n] = append(defs[n], b) + } + } + } + + // Make dominator tree. + s.idom = s.f.Idom() + s.tree = make([]domBlock, s.f.NumBlocks()) + for _, b := range s.f.Blocks { + p := s.idom[b.ID] + if p != nil { + s.tree[b.ID].sibling = s.tree[p.ID].firstChild + s.tree[p.ID].firstChild = b + } + } + // Compute levels in dominator tree. + // With parent pointers we can do a depth-first walk without + // any auxiliary storage. + s.level = make([]int32, s.f.NumBlocks()) + b := s.f.Entry +levels: + for { + if p := s.idom[b.ID]; p != nil { + s.level[b.ID] = s.level[p.ID] + 1 + if debugPhi { + fmt.Printf("level %s = %d\n", b, s.level[b.ID]) + } + } + if c := s.tree[b.ID].firstChild; c != nil { + b = c + continue + } + for { + if c := s.tree[b.ID].sibling; c != nil { + b = c + continue levels + } + b = s.idom[b.ID] + if b == nil { + break levels + } + } + } + + // Allocate scratch locations. + s.priq.level = s.level + s.q = make([]*ssa.Block, 0, s.f.NumBlocks()) + s.queued = newSparseSet(s.f.NumBlocks()) + s.hasPhi = newSparseSet(s.f.NumBlocks()) + s.hasDef = newSparseSet(s.f.NumBlocks()) + s.placeholder = s.s.entryNewValue0(ssa.OpUnknown, types.TypeInvalid) + + // Generate phi ops for each variable. + for n := range vartypes { + s.insertVarPhis(n, vars[n], defs[n], vartypes[n]) + } + + // Resolve FwdRefs to the correct write or phi. + s.resolveFwdRefs() + + // Erase variable numbers stored in AuxInt fields of phi ops. They are no longer needed. + for _, b := range s.f.Blocks { + for _, v := range b.Values { + if v.Op == ssa.OpPhi { + v.AuxInt = 0 + } + // Any remaining FwdRefs are dead code. + if v.Op == ssa.OpFwdRef { + v.Op = ssa.OpUnknown + v.Aux = nil + } + } + } +} + +func (s *phiState) insertVarPhis(n int, var_ ir.Node, defs []*ssa.Block, typ *types.Type) { + priq := &s.priq + q := s.q + queued := s.queued + queued.clear() + hasPhi := s.hasPhi + hasPhi.clear() + hasDef := s.hasDef + hasDef.clear() + + // Add defining blocks to priority queue. + for _, b := range defs { + priq.a = append(priq.a, b) + hasDef.add(b.ID) + if debugPhi { + fmt.Printf("def of var%d in %s\n", n, b) + } + } + heap.Init(priq) + + // Visit blocks defining variable n, from deepest to shallowest. + for len(priq.a) > 0 { + currentRoot := heap.Pop(priq).(*ssa.Block) + if debugPhi { + fmt.Printf("currentRoot %s\n", currentRoot) + } + // Walk subtree below definition. + // Skip subtrees we've done in previous iterations. + // Find edges exiting tree dominated by definition (the dominance frontier). + // Insert phis at target blocks. + if queued.contains(currentRoot.ID) { + s.s.Fatalf("root already in queue") + } + q = append(q, currentRoot) + queued.add(currentRoot.ID) + for len(q) > 0 { + b := q[len(q)-1] + q = q[:len(q)-1] + if debugPhi { + fmt.Printf(" processing %s\n", b) + } + + currentRootLevel := s.level[currentRoot.ID] + for _, e := range b.Succs { + c := e.Block() + // TODO: if the variable is dead at c, skip it. + if s.level[c.ID] > currentRootLevel { + // a D-edge, or an edge whose target is in currentRoot's subtree. + continue + } + if hasPhi.contains(c.ID) { + continue + } + // Add a phi to block c for variable n. + hasPhi.add(c.ID) + v := c.NewValue0I(s.s.blockStarts[b.ID], ssa.OpPhi, typ, int64(n)) + // Note: we store the variable number in the phi's AuxInt field. Used temporarily by phi building. + if var_.Op() == ir.ONAME { + s.s.addNamedValue(var_.(*ir.Name), v) + } + for range c.Preds { + v.AddArg(s.placeholder) // Actual args will be filled in by resolveFwdRefs. + } + if debugPhi { + fmt.Printf("new phi for var%d in %s: %s\n", n, c, v) + } + if !hasDef.contains(c.ID) { + // There's now a new definition of this variable in block c. + // Add it to the priority queue to explore. + heap.Push(priq, c) + hasDef.add(c.ID) + } + } + + // Visit children if they have not been visited yet. + for c := s.tree[b.ID].firstChild; c != nil; c = s.tree[c.ID].sibling { + if !queued.contains(c.ID) { + q = append(q, c) + queued.add(c.ID) + } + } + } + } +} + +// resolveFwdRefs links all FwdRef uses up to their nearest dominating definition. +func (s *phiState) resolveFwdRefs() { + // Do a depth-first walk of the dominator tree, keeping track + // of the most-recently-seen value for each variable. + + // Map from variable ID to SSA value at the current point of the walk. + values := make([]*ssa.Value, len(s.varnum)) + for i := range values { + values[i] = s.placeholder + } + + // Stack of work to do. + type stackEntry struct { + b *ssa.Block // block to explore + + // variable/value pair to reinstate on exit + n int32 // variable ID + v *ssa.Value + + // Note: only one of b or n,v will be set. + } + var stk []stackEntry + + stk = append(stk, stackEntry{b: s.f.Entry}) + for len(stk) > 0 { + work := stk[len(stk)-1] + stk = stk[:len(stk)-1] + + b := work.b + if b == nil { + // On exit from a block, this case will undo any assignments done below. + values[work.n] = work.v + continue + } + + // Process phis as new defs. They come before FwdRefs in this block. + for _, v := range b.Values { + if v.Op != ssa.OpPhi { + continue + } + n := int32(v.AuxInt) + // Remember the old assignment so we can undo it when we exit b. + stk = append(stk, stackEntry{n: n, v: values[n]}) + // Record the new assignment. + values[n] = v + } + + // Replace a FwdRef op with the current incoming value for its variable. + for _, v := range b.Values { + if v.Op != ssa.OpFwdRef { + continue + } + n := s.varnum[v.Aux.(fwdRefAux).N] + v.Op = ssa.OpCopy + v.Aux = nil + v.AddArg(values[n]) + } + + // Establish values for variables defined in b. + for var_, v := range s.defvars[b.ID] { + n, ok := s.varnum[var_] + if !ok { + // some variable not live across a basic block boundary. + continue + } + // Remember the old assignment so we can undo it when we exit b. + stk = append(stk, stackEntry{n: n, v: values[n]}) + // Record the new assignment. + values[n] = v + } + + // Replace phi args in successors with the current incoming value. + for _, e := range b.Succs { + c, i := e.Block(), e.Index() + for j := len(c.Values) - 1; j >= 0; j-- { + v := c.Values[j] + if v.Op != ssa.OpPhi { + break // All phis will be at the end of the block during phi building. + } + // Only set arguments that have been resolved. + // For very wide CFGs, this significantly speeds up phi resolution. + // See golang.org/issue/8225. + if w := values[v.AuxInt]; w.Op != ssa.OpUnknown { + v.SetArg(i, w) + } + } + } + + // Walk children in dominator tree. + for c := s.tree[b.ID].firstChild; c != nil; c = s.tree[c.ID].sibling { + stk = append(stk, stackEntry{b: c}) + } + } +} + +// domBlock contains extra per-block information to record the dominator tree. +type domBlock struct { + firstChild *ssa.Block // first child of block in dominator tree + sibling *ssa.Block // next child of parent in dominator tree +} + +// A block heap is used as a priority queue to implement the PiggyBank +// from Sreedhar and Gao. That paper uses an array which is better +// asymptotically but worse in the common case when the PiggyBank +// holds a sparse set of blocks. +type blockHeap struct { + a []*ssa.Block // block IDs in heap + level []int32 // depth in dominator tree (static, used for determining priority) +} + +func (h *blockHeap) Len() int { return len(h.a) } +func (h *blockHeap) Swap(i, j int) { a := h.a; a[i], a[j] = a[j], a[i] } + +func (h *blockHeap) Push(x any) { + v := x.(*ssa.Block) + h.a = append(h.a, v) +} +func (h *blockHeap) Pop() any { + old := h.a + n := len(old) + x := old[n-1] + h.a = old[:n-1] + return x +} +func (h *blockHeap) Less(i, j int) bool { + return h.level[h.a[i].ID] > h.level[h.a[j].ID] +} + +// TODO: stop walking the iterated domininance frontier when +// the variable is dead. Maybe detect that by checking if the +// node we're on is reverse dominated by all the reads? +// Reverse dominated by the highest common successor of all the reads? + +// copy of ../ssa/sparseset.go +// TODO: move this file to ../ssa, then use sparseSet there. +type sparseSet struct { + dense []ssa.ID + sparse []int32 +} + +// newSparseSet returns a sparseSet that can represent +// integers between 0 and n-1. +func newSparseSet(n int) *sparseSet { + return &sparseSet{dense: nil, sparse: make([]int32, n)} +} + +func (s *sparseSet) contains(x ssa.ID) bool { + i := s.sparse[x] + return i < int32(len(s.dense)) && s.dense[i] == x +} + +func (s *sparseSet) add(x ssa.ID) { + i := s.sparse[x] + if i < int32(len(s.dense)) && s.dense[i] == x { + return + } + s.dense = append(s.dense, x) + s.sparse[x] = int32(len(s.dense)) - 1 +} + +func (s *sparseSet) clear() { + s.dense = s.dense[:0] +} + +// Variant to use for small functions. +type simplePhiState struct { + s *state // SSA state + f *ssa.Func // function to work on + fwdrefs []*ssa.Value // list of FwdRefs to be processed + defvars []map[ir.Node]*ssa.Value // defined variables at end of each block + reachable []bool // which blocks are reachable +} + +func (s *simplePhiState) insertPhis() { + s.reachable = ssa.ReachableBlocks(s.f) + + // Find FwdRef ops. + for _, b := range s.f.Blocks { + for _, v := range b.Values { + if v.Op != ssa.OpFwdRef { + continue + } + s.fwdrefs = append(s.fwdrefs, v) + var_ := v.Aux.(fwdRefAux).N + if _, ok := s.defvars[b.ID][var_]; !ok { + s.defvars[b.ID][var_] = v // treat FwdDefs as definitions. + } + } + } + + var args []*ssa.Value + +loop: + for len(s.fwdrefs) > 0 { + v := s.fwdrefs[len(s.fwdrefs)-1] + s.fwdrefs = s.fwdrefs[:len(s.fwdrefs)-1] + b := v.Block + var_ := v.Aux.(fwdRefAux).N + if b == s.f.Entry { + // No variable should be live at entry. + s.s.Fatalf("value %v (%v) incorrectly live at entry", var_, v) + } + if !s.reachable[b.ID] { + // This block is dead. + // It doesn't matter what we use here as long as it is well-formed. + v.Op = ssa.OpUnknown + v.Aux = nil + continue + } + // Find variable value on each predecessor. + args = args[:0] + for _, e := range b.Preds { + args = append(args, s.lookupVarOutgoing(e.Block(), v.Type, var_, v.Pos)) + } + + // Decide if we need a phi or not. We need a phi if there + // are two different args (which are both not v). + var w *ssa.Value + for _, a := range args { + if a == v { + continue // self-reference + } + if a == w { + continue // already have this witness + } + if w != nil { + // two witnesses, need a phi value + v.Op = ssa.OpPhi + v.AddArgs(args...) + v.Aux = nil + v.Pos = s.s.blockStarts[b.ID] + continue loop + } + w = a // save witness + } + if w == nil { + s.s.Fatalf("no witness for reachable phi %s", v) + } + // One witness. Make v a copy of w. + v.Op = ssa.OpCopy + v.Aux = nil + v.AddArg(w) + } +} + +// lookupVarOutgoing finds the variable's value at the end of block b. +func (s *simplePhiState) lookupVarOutgoing(b *ssa.Block, t *types.Type, var_ ir.Node, line src.XPos) *ssa.Value { + for { + if v := s.defvars[b.ID][var_]; v != nil { + return v + } + // The variable is not defined by b and we haven't looked it up yet. + // If b has exactly one predecessor, loop to look it up there. + // Otherwise, give up and insert a new FwdRef and resolve it later. + if len(b.Preds) != 1 { + break + } + b = b.Preds[0].Block() + if !s.reachable[b.ID] { + // This is rare; it happens with oddly interleaved infinite loops in dead code. + // See issue 19783. + break + } + } + // Generate a FwdRef for the variable and return that. + v := b.NewValue0A(line, ssa.OpFwdRef, t, fwdRefAux{N: var_}) + s.defvars[b.ID][var_] = v + if var_.Op() == ir.ONAME { + s.s.addNamedValue(var_.(*ir.Name), v) + } + s.fwdrefs = append(s.fwdrefs, v) + return v +} diff --git a/go/src/cmd/compile/internal/ssagen/simdintrinsics.go b/go/src/cmd/compile/internal/ssagen/simdintrinsics.go new file mode 100644 index 0000000000000000000000000000000000000000..e50561845b76a5ddd46dc0555a9fe9c13ba1d7ae --- /dev/null +++ b/go/src/cmd/compile/internal/ssagen/simdintrinsics.go @@ -0,0 +1,1805 @@ +// Code generated by 'simdgen -o godefs -goroot $GOROOT -xedPath $XED_PATH go.yaml types.yaml categories.yaml'; DO NOT EDIT. + +package ssagen + +import ( + "cmd/compile/internal/ir" + "cmd/compile/internal/ssa" + "cmd/compile/internal/types" + "cmd/internal/sys" +) + +const simdPackage = "simd/archsimd" + +func simdIntrinsics(addF func(pkg, fn string, b intrinsicBuilder, archFamilies ...sys.ArchFamily)) { + addF(simdPackage, "Uint8x16.AESDecryptLastRound", opLen2(ssa.OpAESDecryptLastRoundUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.AESDecryptLastRound", opLen2(ssa.OpAESDecryptLastRoundUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.AESDecryptLastRound", opLen2(ssa.OpAESDecryptLastRoundUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.AESDecryptOneRound", opLen2(ssa.OpAESDecryptOneRoundUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.AESDecryptOneRound", opLen2(ssa.OpAESDecryptOneRoundUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.AESDecryptOneRound", opLen2(ssa.OpAESDecryptOneRoundUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.AESEncryptLastRound", opLen2(ssa.OpAESEncryptLastRoundUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.AESEncryptLastRound", opLen2(ssa.OpAESEncryptLastRoundUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.AESEncryptLastRound", opLen2(ssa.OpAESEncryptLastRoundUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.AESEncryptOneRound", opLen2(ssa.OpAESEncryptOneRoundUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.AESEncryptOneRound", opLen2(ssa.OpAESEncryptOneRoundUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.AESEncryptOneRound", opLen2(ssa.OpAESEncryptOneRoundUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.AESInvMixColumns", opLen1(ssa.OpAESInvMixColumnsUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.AESRoundKeyGenAssist", opLen1Imm8(ssa.OpAESRoundKeyGenAssistUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int8x16.Abs", opLen1(ssa.OpAbsInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Abs", opLen1(ssa.OpAbsInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Abs", opLen1(ssa.OpAbsInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Abs", opLen1(ssa.OpAbsInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Abs", opLen1(ssa.OpAbsInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Abs", opLen1(ssa.OpAbsInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Abs", opLen1(ssa.OpAbsInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Abs", opLen1(ssa.OpAbsInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Abs", opLen1(ssa.OpAbsInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Abs", opLen1(ssa.OpAbsInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Abs", opLen1(ssa.OpAbsInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Abs", opLen1(ssa.OpAbsInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Add", opLen2(ssa.OpAddFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Add", opLen2(ssa.OpAddFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Add", opLen2(ssa.OpAddFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Add", opLen2(ssa.OpAddFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Add", opLen2(ssa.OpAddFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Add", opLen2(ssa.OpAddFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Add", opLen2(ssa.OpAddInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Add", opLen2(ssa.OpAddInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Add", opLen2(ssa.OpAddInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Add", opLen2(ssa.OpAddInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Add", opLen2(ssa.OpAddInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Add", opLen2(ssa.OpAddInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Add", opLen2(ssa.OpAddInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Add", opLen2(ssa.OpAddInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Add", opLen2(ssa.OpAddInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Add", opLen2(ssa.OpAddInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Add", opLen2(ssa.OpAddInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Add", opLen2(ssa.OpAddInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Add", opLen2(ssa.OpAddUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.Add", opLen2(ssa.OpAddUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.Add", opLen2(ssa.OpAddUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Add", opLen2(ssa.OpAddUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Add", opLen2(ssa.OpAddUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Add", opLen2(ssa.OpAddUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.Add", opLen2(ssa.OpAddUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.Add", opLen2(ssa.OpAddUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.Add", opLen2(ssa.OpAddUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.Add", opLen2(ssa.OpAddUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.Add", opLen2(ssa.OpAddUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.Add", opLen2(ssa.OpAddUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.AddPairs", opLen2(ssa.OpAddPairsFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x2.AddPairs", opLen2(ssa.OpAddPairsFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x8.AddPairs", opLen2(ssa.OpAddPairsInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.AddPairs", opLen2(ssa.OpAddPairsInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x8.AddPairs", opLen2(ssa.OpAddPairsUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.AddPairs", opLen2(ssa.OpAddPairsUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.AddPairsGrouped", opLen2(ssa.OpAddPairsGroupedFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x4.AddPairsGrouped", opLen2(ssa.OpAddPairsGroupedFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x16.AddPairsGrouped", opLen2(ssa.OpAddPairsGroupedInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x8.AddPairsGrouped", opLen2(ssa.OpAddPairsGroupedInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x16.AddPairsGrouped", opLen2(ssa.OpAddPairsGroupedUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x8.AddPairsGrouped", opLen2(ssa.OpAddPairsGroupedUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x8.AddPairsSaturated", opLen2(ssa.OpAddPairsSaturatedInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.AddPairsSaturatedGrouped", opLen2(ssa.OpAddPairsSaturatedGroupedInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x16.AddSaturated", opLen2(ssa.OpAddSaturatedInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.AddSaturated", opLen2(ssa.OpAddSaturatedInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.AddSaturated", opLen2(ssa.OpAddSaturatedInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.AddSaturated", opLen2(ssa.OpAddSaturatedInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.AddSaturated", opLen2(ssa.OpAddSaturatedInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.AddSaturated", opLen2(ssa.OpAddSaturatedInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.AddSaturated", opLen2(ssa.OpAddSaturatedUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.AddSaturated", opLen2(ssa.OpAddSaturatedUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.AddSaturated", opLen2(ssa.OpAddSaturatedUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.AddSaturated", opLen2(ssa.OpAddSaturatedUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.AddSaturated", opLen2(ssa.OpAddSaturatedUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.AddSaturated", opLen2(ssa.OpAddSaturatedUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.AddSub", opLen2(ssa.OpAddSubFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.AddSub", opLen2(ssa.OpAddSubFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x2.AddSub", opLen2(ssa.OpAddSubFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.AddSub", opLen2(ssa.OpAddSubFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x16.And", opLen2(ssa.OpAndInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.And", opLen2(ssa.OpAndInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.And", opLen2(ssa.OpAndInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.And", opLen2(ssa.OpAndInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.And", opLen2(ssa.OpAndInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.And", opLen2(ssa.OpAndInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.And", opLen2(ssa.OpAndInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.And", opLen2(ssa.OpAndInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.And", opLen2(ssa.OpAndInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.And", opLen2(ssa.OpAndInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.And", opLen2(ssa.OpAndInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.And", opLen2(ssa.OpAndInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.And", opLen2(ssa.OpAndUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.And", opLen2(ssa.OpAndUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.And", opLen2(ssa.OpAndUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.And", opLen2(ssa.OpAndUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.And", opLen2(ssa.OpAndUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.And", opLen2(ssa.OpAndUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.And", opLen2(ssa.OpAndUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.And", opLen2(ssa.OpAndUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.And", opLen2(ssa.OpAndUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.And", opLen2(ssa.OpAndUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.And", opLen2(ssa.OpAndUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.And", opLen2(ssa.OpAndUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.AndNot", opLen2_21(ssa.OpAndNotInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.AndNot", opLen2_21(ssa.OpAndNotInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.AndNot", opLen2_21(ssa.OpAndNotInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.AndNot", opLen2_21(ssa.OpAndNotInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.AndNot", opLen2_21(ssa.OpAndNotInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.AndNot", opLen2_21(ssa.OpAndNotInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.AndNot", opLen2_21(ssa.OpAndNotInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.AndNot", opLen2_21(ssa.OpAndNotInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.AndNot", opLen2_21(ssa.OpAndNotInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.AndNot", opLen2_21(ssa.OpAndNotInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.AndNot", opLen2_21(ssa.OpAndNotInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.AndNot", opLen2_21(ssa.OpAndNotInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.AndNot", opLen2_21(ssa.OpAndNotUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.AndNot", opLen2_21(ssa.OpAndNotUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.AndNot", opLen2_21(ssa.OpAndNotUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.AndNot", opLen2_21(ssa.OpAndNotUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.AndNot", opLen2_21(ssa.OpAndNotUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.AndNot", opLen2_21(ssa.OpAndNotUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.AndNot", opLen2_21(ssa.OpAndNotUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.AndNot", opLen2_21(ssa.OpAndNotUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.AndNot", opLen2_21(ssa.OpAndNotUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.AndNot", opLen2_21(ssa.OpAndNotUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.AndNot", opLen2_21(ssa.OpAndNotUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.AndNot", opLen2_21(ssa.OpAndNotUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Average", opLen2(ssa.OpAverageUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.Average", opLen2(ssa.OpAverageUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.Average", opLen2(ssa.OpAverageUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Average", opLen2(ssa.OpAverageUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Average", opLen2(ssa.OpAverageUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Average", opLen2(ssa.OpAverageUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Broadcast1To2", opLen1(ssa.OpBroadcast1To2Float64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x2.Broadcast1To2", opLen1(ssa.OpBroadcast1To2Int64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x2.Broadcast1To2", opLen1(ssa.OpBroadcast1To2Uint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x4.Broadcast1To4", opLen1(ssa.OpBroadcast1To4Float32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x2.Broadcast1To4", opLen1(ssa.OpBroadcast1To4Float64x2, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x4.Broadcast1To4", opLen1(ssa.OpBroadcast1To4Int32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x2.Broadcast1To4", opLen1(ssa.OpBroadcast1To4Int64x2, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x4.Broadcast1To4", opLen1(ssa.OpBroadcast1To4Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x2.Broadcast1To4", opLen1(ssa.OpBroadcast1To4Uint64x2, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x4.Broadcast1To8", opLen1(ssa.OpBroadcast1To8Float32x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x2.Broadcast1To8", opLen1(ssa.OpBroadcast1To8Float64x2, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Broadcast1To8", opLen1(ssa.OpBroadcast1To8Int16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.Broadcast1To8", opLen1(ssa.OpBroadcast1To8Int32x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x2.Broadcast1To8", opLen1(ssa.OpBroadcast1To8Int64x2, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Broadcast1To8", opLen1(ssa.OpBroadcast1To8Uint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.Broadcast1To8", opLen1(ssa.OpBroadcast1To8Uint32x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x2.Broadcast1To8", opLen1(ssa.OpBroadcast1To8Uint64x2, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Broadcast1To16", opLen1(ssa.OpBroadcast1To16Float32x4, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Broadcast1To16", opLen1(ssa.OpBroadcast1To16Int8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x8.Broadcast1To16", opLen1(ssa.OpBroadcast1To16Int16x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x4.Broadcast1To16", opLen1(ssa.OpBroadcast1To16Int32x4, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Broadcast1To16", opLen1(ssa.OpBroadcast1To16Uint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x8.Broadcast1To16", opLen1(ssa.OpBroadcast1To16Uint16x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x4.Broadcast1To16", opLen1(ssa.OpBroadcast1To16Uint32x4, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Broadcast1To32", opLen1(ssa.OpBroadcast1To32Int8x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x8.Broadcast1To32", opLen1(ssa.OpBroadcast1To32Int16x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Broadcast1To32", opLen1(ssa.OpBroadcast1To32Uint8x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x8.Broadcast1To32", opLen1(ssa.OpBroadcast1To32Uint16x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Broadcast1To64", opLen1(ssa.OpBroadcast1To64Int8x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Broadcast1To64", opLen1(ssa.OpBroadcast1To64Uint8x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Ceil", opLen1(ssa.OpCeilFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Ceil", opLen1(ssa.OpCeilFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x2.Ceil", opLen1(ssa.OpCeilFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Ceil", opLen1(ssa.OpCeilFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x4.CeilScaled", opLen1Imm8(ssa.OpCeilScaledFloat32x4, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float32x8.CeilScaled", opLen1Imm8(ssa.OpCeilScaledFloat32x8, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float32x16.CeilScaled", opLen1Imm8(ssa.OpCeilScaledFloat32x16, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float64x2.CeilScaled", opLen1Imm8(ssa.OpCeilScaledFloat64x2, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float64x4.CeilScaled", opLen1Imm8(ssa.OpCeilScaledFloat64x4, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float64x8.CeilScaled", opLen1Imm8(ssa.OpCeilScaledFloat64x8, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float32x4.CeilScaledResidue", opLen1Imm8(ssa.OpCeilScaledResidueFloat32x4, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float32x8.CeilScaledResidue", opLen1Imm8(ssa.OpCeilScaledResidueFloat32x8, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float32x16.CeilScaledResidue", opLen1Imm8(ssa.OpCeilScaledResidueFloat32x16, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float64x2.CeilScaledResidue", opLen1Imm8(ssa.OpCeilScaledResidueFloat64x2, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float64x4.CeilScaledResidue", opLen1Imm8(ssa.OpCeilScaledResidueFloat64x4, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float64x8.CeilScaledResidue", opLen1Imm8(ssa.OpCeilScaledResidueFloat64x8, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float32x4.Compress", opLen2(ssa.OpCompressFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Compress", opLen2(ssa.OpCompressFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Compress", opLen2(ssa.OpCompressFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Compress", opLen2(ssa.OpCompressFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Compress", opLen2(ssa.OpCompressFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Compress", opLen2(ssa.OpCompressFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Compress", opLen2(ssa.OpCompressInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Compress", opLen2(ssa.OpCompressInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Compress", opLen2(ssa.OpCompressInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Compress", opLen2(ssa.OpCompressInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Compress", opLen2(ssa.OpCompressInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Compress", opLen2(ssa.OpCompressInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Compress", opLen2(ssa.OpCompressInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Compress", opLen2(ssa.OpCompressInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Compress", opLen2(ssa.OpCompressInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Compress", opLen2(ssa.OpCompressInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Compress", opLen2(ssa.OpCompressInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Compress", opLen2(ssa.OpCompressInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Compress", opLen2(ssa.OpCompressUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.Compress", opLen2(ssa.OpCompressUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.Compress", opLen2(ssa.OpCompressUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Compress", opLen2(ssa.OpCompressUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Compress", opLen2(ssa.OpCompressUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Compress", opLen2(ssa.OpCompressUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.Compress", opLen2(ssa.OpCompressUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.Compress", opLen2(ssa.OpCompressUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.Compress", opLen2(ssa.OpCompressUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.Compress", opLen2(ssa.OpCompressUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.Compress", opLen2(ssa.OpCompressUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.Compress", opLen2(ssa.OpCompressUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x16.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x32.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x64.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x8.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x16.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x32.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.ConcatPermute", opLen3_231(ssa.OpConcatPermuteFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.ConcatPermute", opLen3_231(ssa.OpConcatPermuteFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x8.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x8.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.ConcatPermute", opLen3_231(ssa.OpConcatPermuteFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x16.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x16.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.ConcatPermute", opLen3_231(ssa.OpConcatPermuteFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x2.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x2.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.ConcatPermute", opLen3_231(ssa.OpConcatPermuteFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x4.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x4.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.ConcatPermute", opLen3_231(ssa.OpConcatPermuteFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x8.ConcatPermute", opLen3_231(ssa.OpConcatPermuteInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x8.ConcatPermute", opLen3_231(ssa.OpConcatPermuteUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.ConcatShiftBytesRight", opLen2Imm8(ssa.OpConcatShiftBytesRightUint8x16, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint8x32.ConcatShiftBytesRightGrouped", opLen2Imm8(ssa.OpConcatShiftBytesRightGroupedUint8x32, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint8x64.ConcatShiftBytesRightGrouped", opLen2Imm8(ssa.OpConcatShiftBytesRightGroupedUint8x64, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Float64x2.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Float64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Float64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x8.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Float64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x4.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Int32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Int32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Int32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Int64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Int64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x8.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Int64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x4.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Uint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Uint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Uint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Uint64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x8.ConvertToFloat32", opLen1(ssa.OpConvertToFloat32Uint64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x4.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Float32x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x8.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Float32x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Int32x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x8.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Int32x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Int64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Int64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Int64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Uint32x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x8.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Uint32x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Uint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Uint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.ConvertToFloat64", opLen1(ssa.OpConvertToFloat64Uint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.ConvertToInt32", opLen1(ssa.OpConvertToInt32Float32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.ConvertToInt32", opLen1(ssa.OpConvertToInt32Float32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.ConvertToInt32", opLen1(ssa.OpConvertToInt32Float32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.ConvertToInt32", opLen1(ssa.OpConvertToInt32Float64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.ConvertToInt32", opLen1(ssa.OpConvertToInt32Float64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x8.ConvertToInt32", opLen1(ssa.OpConvertToInt32Float64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x4.ConvertToInt64", opLen1(ssa.OpConvertToInt64Float32x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x8.ConvertToInt64", opLen1(ssa.OpConvertToInt64Float32x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.ConvertToInt64", opLen1(ssa.OpConvertToInt64Float64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.ConvertToInt64", opLen1(ssa.OpConvertToInt64Float64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.ConvertToInt64", opLen1(ssa.OpConvertToInt64Float64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.ConvertToUint32", opLen1(ssa.OpConvertToUint32Float32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.ConvertToUint32", opLen1(ssa.OpConvertToUint32Float32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.ConvertToUint32", opLen1(ssa.OpConvertToUint32Float32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.ConvertToUint32", opLen1(ssa.OpConvertToUint32Float64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.ConvertToUint32", opLen1(ssa.OpConvertToUint32Float64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x8.ConvertToUint32", opLen1(ssa.OpConvertToUint32Float64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x4.ConvertToUint64", opLen1(ssa.OpConvertToUint64Float32x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x8.ConvertToUint64", opLen1(ssa.OpConvertToUint64Float32x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.ConvertToUint64", opLen1(ssa.OpConvertToUint64Float64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.ConvertToUint64", opLen1(ssa.OpConvertToUint64Float64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.ConvertToUint64", opLen1(ssa.OpConvertToUint64Float64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.CopySign", opLen2(ssa.OpCopySignInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.CopySign", opLen2(ssa.OpCopySignInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x8.CopySign", opLen2(ssa.OpCopySignInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.CopySign", opLen2(ssa.OpCopySignInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x4.CopySign", opLen2(ssa.OpCopySignInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.CopySign", opLen2(ssa.OpCopySignInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x4.Div", opLen2(ssa.OpDivFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Div", opLen2(ssa.OpDivFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Div", opLen2(ssa.OpDivFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Div", opLen2(ssa.OpDivFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Div", opLen2(ssa.OpDivFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Div", opLen2(ssa.OpDivFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.DotProductPairs", opLen2(ssa.OpDotProductPairsInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.DotProductPairs", opLen2(ssa.OpDotProductPairsInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.DotProductPairs", opLen2(ssa.OpDotProductPairsInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.DotProductPairsSaturated", opLen2(ssa.OpDotProductPairsSaturatedUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.DotProductPairsSaturated", opLen2(ssa.OpDotProductPairsSaturatedUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.DotProductPairsSaturated", opLen2(ssa.OpDotProductPairsSaturatedUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Equal", opLen2(ssa.OpEqualInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Equal", opLen2(ssa.OpEqualInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Equal", opLen2(ssa.OpEqualInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Equal", opLen2(ssa.OpEqualInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Equal", opLen2(ssa.OpEqualInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Equal", opLen2(ssa.OpEqualInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Equal", opLen2(ssa.OpEqualInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Equal", opLen2(ssa.OpEqualInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Equal", opLen2(ssa.OpEqualInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Equal", opLen2(ssa.OpEqualInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Equal", opLen2(ssa.OpEqualInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Equal", opLen2(ssa.OpEqualInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Equal", opLen2(ssa.OpEqualUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.Equal", opLen2(ssa.OpEqualUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.Equal", opLen2(ssa.OpEqualUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Equal", opLen2(ssa.OpEqualUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Equal", opLen2(ssa.OpEqualUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Equal", opLen2(ssa.OpEqualUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.Equal", opLen2(ssa.OpEqualUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.Equal", opLen2(ssa.OpEqualUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.Equal", opLen2(ssa.OpEqualUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.Equal", opLen2(ssa.OpEqualUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.Equal", opLen2(ssa.OpEqualUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.Equal", opLen2(ssa.OpEqualUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Equal", opLen2(ssa.OpEqualFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Equal", opLen2(ssa.OpEqualFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Equal", opLen2(ssa.OpEqualFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Equal", opLen2(ssa.OpEqualFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Equal", opLen2(ssa.OpEqualFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Equal", opLen2(ssa.OpEqualFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Expand", opLen2(ssa.OpExpandFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Expand", opLen2(ssa.OpExpandFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Expand", opLen2(ssa.OpExpandFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Expand", opLen2(ssa.OpExpandFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Expand", opLen2(ssa.OpExpandFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Expand", opLen2(ssa.OpExpandFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Expand", opLen2(ssa.OpExpandInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Expand", opLen2(ssa.OpExpandInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Expand", opLen2(ssa.OpExpandInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Expand", opLen2(ssa.OpExpandInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Expand", opLen2(ssa.OpExpandInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Expand", opLen2(ssa.OpExpandInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Expand", opLen2(ssa.OpExpandInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Expand", opLen2(ssa.OpExpandInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Expand", opLen2(ssa.OpExpandInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Expand", opLen2(ssa.OpExpandInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Expand", opLen2(ssa.OpExpandInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Expand", opLen2(ssa.OpExpandInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Expand", opLen2(ssa.OpExpandUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.Expand", opLen2(ssa.OpExpandUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.Expand", opLen2(ssa.OpExpandUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Expand", opLen2(ssa.OpExpandUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Expand", opLen2(ssa.OpExpandUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Expand", opLen2(ssa.OpExpandUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.Expand", opLen2(ssa.OpExpandUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.Expand", opLen2(ssa.OpExpandUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.Expand", opLen2(ssa.OpExpandUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.Expand", opLen2(ssa.OpExpandUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.Expand", opLen2(ssa.OpExpandUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.Expand", opLen2(ssa.OpExpandUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.ExtendLo2ToInt64", opLen1(ssa.OpExtendLo2ToInt64Int8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x8.ExtendLo2ToInt64", opLen1(ssa.OpExtendLo2ToInt64Int16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.ExtendLo2ToInt64", opLen1(ssa.OpExtendLo2ToInt64Int32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x16.ExtendLo2ToUint64", opLen1(ssa.OpExtendLo2ToUint64Uint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x8.ExtendLo2ToUint64", opLen1(ssa.OpExtendLo2ToUint64Uint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.ExtendLo2ToUint64", opLen1(ssa.OpExtendLo2ToUint64Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x16.ExtendLo4ToInt32", opLen1(ssa.OpExtendLo4ToInt32Int8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x8.ExtendLo4ToInt32", opLen1(ssa.OpExtendLo4ToInt32Int16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x16.ExtendLo4ToInt64", opLen1(ssa.OpExtendLo4ToInt64Int8x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x8.ExtendLo4ToInt64", opLen1(ssa.OpExtendLo4ToInt64Int16x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x16.ExtendLo4ToUint32", opLen1(ssa.OpExtendLo4ToUint32Uint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x8.ExtendLo4ToUint32", opLen1(ssa.OpExtendLo4ToUint32Uint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x16.ExtendLo4ToUint64", opLen1(ssa.OpExtendLo4ToUint64Uint8x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x8.ExtendLo4ToUint64", opLen1(ssa.OpExtendLo4ToUint64Uint16x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x16.ExtendLo8ToInt16", opLen1(ssa.OpExtendLo8ToInt16Int8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x16.ExtendLo8ToInt32", opLen1(ssa.OpExtendLo8ToInt32Int8x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x16.ExtendLo8ToInt64", opLen1(ssa.OpExtendLo8ToInt64Int8x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.ExtendLo8ToUint16", opLen1(ssa.OpExtendLo8ToUint16Uint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x16.ExtendLo8ToUint32", opLen1(ssa.OpExtendLo8ToUint32Uint8x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x16.ExtendLo8ToUint64", opLen1(ssa.OpExtendLo8ToUint64Uint8x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.ExtendToInt16", opLen1(ssa.OpExtendToInt16Int8x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x32.ExtendToInt16", opLen1(ssa.OpExtendToInt16Int8x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.ExtendToInt32", opLen1(ssa.OpExtendToInt32Int8x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.ExtendToInt32", opLen1(ssa.OpExtendToInt32Int16x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x16.ExtendToInt32", opLen1(ssa.OpExtendToInt32Int16x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.ExtendToInt64", opLen1(ssa.OpExtendToInt64Int16x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.ExtendToInt64", opLen1(ssa.OpExtendToInt64Int32x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x8.ExtendToInt64", opLen1(ssa.OpExtendToInt64Int32x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.ExtendToUint16", opLen1(ssa.OpExtendToUint16Uint8x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x32.ExtendToUint16", opLen1(ssa.OpExtendToUint16Uint8x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.ExtendToUint32", opLen1(ssa.OpExtendToUint32Uint8x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.ExtendToUint32", opLen1(ssa.OpExtendToUint32Uint16x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x16.ExtendToUint32", opLen1(ssa.OpExtendToUint32Uint16x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.ExtendToUint64", opLen1(ssa.OpExtendToUint64Uint16x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.ExtendToUint64", opLen1(ssa.OpExtendToUint64Uint32x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x8.ExtendToUint64", opLen1(ssa.OpExtendToUint64Uint32x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Floor", opLen1(ssa.OpFloorFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Floor", opLen1(ssa.OpFloorFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x2.Floor", opLen1(ssa.OpFloorFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Floor", opLen1(ssa.OpFloorFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x4.FloorScaled", opLen1Imm8(ssa.OpFloorScaledFloat32x4, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float32x8.FloorScaled", opLen1Imm8(ssa.OpFloorScaledFloat32x8, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float32x16.FloorScaled", opLen1Imm8(ssa.OpFloorScaledFloat32x16, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float64x2.FloorScaled", opLen1Imm8(ssa.OpFloorScaledFloat64x2, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float64x4.FloorScaled", opLen1Imm8(ssa.OpFloorScaledFloat64x4, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float64x8.FloorScaled", opLen1Imm8(ssa.OpFloorScaledFloat64x8, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float32x4.FloorScaledResidue", opLen1Imm8(ssa.OpFloorScaledResidueFloat32x4, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float32x8.FloorScaledResidue", opLen1Imm8(ssa.OpFloorScaledResidueFloat32x8, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float32x16.FloorScaledResidue", opLen1Imm8(ssa.OpFloorScaledResidueFloat32x16, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float64x2.FloorScaledResidue", opLen1Imm8(ssa.OpFloorScaledResidueFloat64x2, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float64x4.FloorScaledResidue", opLen1Imm8(ssa.OpFloorScaledResidueFloat64x4, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float64x8.FloorScaledResidue", opLen1Imm8(ssa.OpFloorScaledResidueFloat64x8, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Uint8x16.GaloisFieldAffineTransform", opLen2Imm8_2I(ssa.OpGaloisFieldAffineTransformUint8x16, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint8x32.GaloisFieldAffineTransform", opLen2Imm8_2I(ssa.OpGaloisFieldAffineTransformUint8x32, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint8x64.GaloisFieldAffineTransform", opLen2Imm8_2I(ssa.OpGaloisFieldAffineTransformUint8x64, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint8x16.GaloisFieldAffineTransformInverse", opLen2Imm8_2I(ssa.OpGaloisFieldAffineTransformInverseUint8x16, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint8x32.GaloisFieldAffineTransformInverse", opLen2Imm8_2I(ssa.OpGaloisFieldAffineTransformInverseUint8x32, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint8x64.GaloisFieldAffineTransformInverse", opLen2Imm8_2I(ssa.OpGaloisFieldAffineTransformInverseUint8x64, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint8x16.GaloisFieldMul", opLen2(ssa.OpGaloisFieldMulUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.GaloisFieldMul", opLen2(ssa.OpGaloisFieldMulUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.GaloisFieldMul", opLen2(ssa.OpGaloisFieldMulUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.GetElem", opLen1Imm8(ssa.OpGetElemFloat32x4, types.Types[types.TFLOAT32], 0), sys.AMD64) + addF(simdPackage, "Float64x2.GetElem", opLen1Imm8(ssa.OpGetElemFloat64x2, types.Types[types.TFLOAT64], 0), sys.AMD64) + addF(simdPackage, "Int8x16.GetElem", opLen1Imm8(ssa.OpGetElemInt8x16, types.Types[types.TINT8], 0), sys.AMD64) + addF(simdPackage, "Int16x8.GetElem", opLen1Imm8(ssa.OpGetElemInt16x8, types.Types[types.TINT16], 0), sys.AMD64) + addF(simdPackage, "Int32x4.GetElem", opLen1Imm8(ssa.OpGetElemInt32x4, types.Types[types.TINT32], 0), sys.AMD64) + addF(simdPackage, "Int64x2.GetElem", opLen1Imm8(ssa.OpGetElemInt64x2, types.Types[types.TINT64], 0), sys.AMD64) + addF(simdPackage, "Uint8x16.GetElem", opLen1Imm8(ssa.OpGetElemUint8x16, types.Types[types.TUINT8], 0), sys.AMD64) + addF(simdPackage, "Uint16x8.GetElem", opLen1Imm8(ssa.OpGetElemUint16x8, types.Types[types.TUINT16], 0), sys.AMD64) + addF(simdPackage, "Uint32x4.GetElem", opLen1Imm8(ssa.OpGetElemUint32x4, types.Types[types.TUINT32], 0), sys.AMD64) + addF(simdPackage, "Uint64x2.GetElem", opLen1Imm8(ssa.OpGetElemUint64x2, types.Types[types.TUINT64], 0), sys.AMD64) + addF(simdPackage, "Float32x8.GetHi", opLen1(ssa.OpGetHiFloat32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x16.GetHi", opLen1(ssa.OpGetHiFloat32x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x4.GetHi", opLen1(ssa.OpGetHiFloat64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x8.GetHi", opLen1(ssa.OpGetHiFloat64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x32.GetHi", opLen1(ssa.OpGetHiInt8x32, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x64.GetHi", opLen1(ssa.OpGetHiInt8x64, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x16.GetHi", opLen1(ssa.OpGetHiInt16x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x32.GetHi", opLen1(ssa.OpGetHiInt16x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x8.GetHi", opLen1(ssa.OpGetHiInt32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x16.GetHi", opLen1(ssa.OpGetHiInt32x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x4.GetHi", opLen1(ssa.OpGetHiInt64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x8.GetHi", opLen1(ssa.OpGetHiInt64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x32.GetHi", opLen1(ssa.OpGetHiUint8x32, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x64.GetHi", opLen1(ssa.OpGetHiUint8x64, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x16.GetHi", opLen1(ssa.OpGetHiUint16x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x32.GetHi", opLen1(ssa.OpGetHiUint16x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x8.GetHi", opLen1(ssa.OpGetHiUint32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x16.GetHi", opLen1(ssa.OpGetHiUint32x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x4.GetHi", opLen1(ssa.OpGetHiUint64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x8.GetHi", opLen1(ssa.OpGetHiUint64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x8.GetLo", opLen1(ssa.OpGetLoFloat32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x16.GetLo", opLen1(ssa.OpGetLoFloat32x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x4.GetLo", opLen1(ssa.OpGetLoFloat64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x8.GetLo", opLen1(ssa.OpGetLoFloat64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x32.GetLo", opLen1(ssa.OpGetLoInt8x32, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x64.GetLo", opLen1(ssa.OpGetLoInt8x64, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x16.GetLo", opLen1(ssa.OpGetLoInt16x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x32.GetLo", opLen1(ssa.OpGetLoInt16x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x8.GetLo", opLen1(ssa.OpGetLoInt32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x16.GetLo", opLen1(ssa.OpGetLoInt32x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x4.GetLo", opLen1(ssa.OpGetLoInt64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x8.GetLo", opLen1(ssa.OpGetLoInt64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x32.GetLo", opLen1(ssa.OpGetLoUint8x32, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x64.GetLo", opLen1(ssa.OpGetLoUint8x64, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x16.GetLo", opLen1(ssa.OpGetLoUint16x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x32.GetLo", opLen1(ssa.OpGetLoUint16x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x8.GetLo", opLen1(ssa.OpGetLoUint32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x16.GetLo", opLen1(ssa.OpGetLoUint32x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x4.GetLo", opLen1(ssa.OpGetLoUint64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x8.GetLo", opLen1(ssa.OpGetLoUint64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x16.Greater", opLen2(ssa.OpGreaterInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Greater", opLen2(ssa.OpGreaterInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Greater", opLen2(ssa.OpGreaterInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Greater", opLen2(ssa.OpGreaterInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Greater", opLen2(ssa.OpGreaterInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Greater", opLen2(ssa.OpGreaterInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Greater", opLen2(ssa.OpGreaterInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Greater", opLen2(ssa.OpGreaterInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Greater", opLen2(ssa.OpGreaterInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Greater", opLen2(ssa.OpGreaterInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Greater", opLen2(ssa.OpGreaterInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Greater", opLen2(ssa.OpGreaterInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Greater", opLen2(ssa.OpGreaterFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Greater", opLen2(ssa.OpGreaterFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Greater", opLen2(ssa.OpGreaterFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Greater", opLen2(ssa.OpGreaterFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Greater", opLen2(ssa.OpGreaterFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Greater", opLen2(ssa.OpGreaterFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x64.Greater", opLen2(ssa.OpGreaterUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x32.Greater", opLen2(ssa.OpGreaterUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x16.Greater", opLen2(ssa.OpGreaterUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x8.Greater", opLen2(ssa.OpGreaterUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.GreaterEqual", opLen2(ssa.OpGreaterEqualFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.GreaterEqual", opLen2(ssa.OpGreaterEqualFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.GreaterEqual", opLen2(ssa.OpGreaterEqualFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.GreaterEqual", opLen2(ssa.OpGreaterEqualFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.GreaterEqual", opLen2(ssa.OpGreaterEqualFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.GreaterEqual", opLen2(ssa.OpGreaterEqualFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x64.GreaterEqual", opLen2(ssa.OpGreaterEqualInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x32.GreaterEqual", opLen2(ssa.OpGreaterEqualInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x16.GreaterEqual", opLen2(ssa.OpGreaterEqualInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x8.GreaterEqual", opLen2(ssa.OpGreaterEqualInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x64.GreaterEqual", opLen2(ssa.OpGreaterEqualUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x32.GreaterEqual", opLen2(ssa.OpGreaterEqualUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x16.GreaterEqual", opLen2(ssa.OpGreaterEqualUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x8.GreaterEqual", opLen2(ssa.OpGreaterEqualUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.InterleaveHi", opLen2(ssa.OpInterleaveHiInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.InterleaveHi", opLen2(ssa.OpInterleaveHiInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x2.InterleaveHi", opLen2(ssa.OpInterleaveHiInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x8.InterleaveHi", opLen2(ssa.OpInterleaveHiUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.InterleaveHi", opLen2(ssa.OpInterleaveHiUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x2.InterleaveHi", opLen2(ssa.OpInterleaveHiUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x8.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x4.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x16.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x8.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x4.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.InterleaveHiGrouped", opLen2(ssa.OpInterleaveHiGroupedUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.InterleaveLo", opLen2(ssa.OpInterleaveLoInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.InterleaveLo", opLen2(ssa.OpInterleaveLoInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x2.InterleaveLo", opLen2(ssa.OpInterleaveLoInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x8.InterleaveLo", opLen2(ssa.OpInterleaveLoUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.InterleaveLo", opLen2(ssa.OpInterleaveLoUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x2.InterleaveLo", opLen2(ssa.OpInterleaveLoUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x8.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x4.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x16.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x8.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x4.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.InterleaveLoGrouped", opLen2(ssa.OpInterleaveLoGroupedUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.LeadingZeros", opLen1(ssa.OpLeadingZerosInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.LeadingZeros", opLen1(ssa.OpLeadingZerosInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.LeadingZeros", opLen1(ssa.OpLeadingZerosInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.LeadingZeros", opLen1(ssa.OpLeadingZerosInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.LeadingZeros", opLen1(ssa.OpLeadingZerosInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.LeadingZeros", opLen1(ssa.OpLeadingZerosInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.LeadingZeros", opLen1(ssa.OpLeadingZerosUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.LeadingZeros", opLen1(ssa.OpLeadingZerosUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.LeadingZeros", opLen1(ssa.OpLeadingZerosUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.LeadingZeros", opLen1(ssa.OpLeadingZerosUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.LeadingZeros", opLen1(ssa.OpLeadingZerosUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.LeadingZeros", opLen1(ssa.OpLeadingZerosUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Less", opLen2(ssa.OpLessFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Less", opLen2(ssa.OpLessFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Less", opLen2(ssa.OpLessFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Less", opLen2(ssa.OpLessFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Less", opLen2(ssa.OpLessFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Less", opLen2(ssa.OpLessFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x64.Less", opLen2(ssa.OpLessInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x32.Less", opLen2(ssa.OpLessInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x16.Less", opLen2(ssa.OpLessInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x8.Less", opLen2(ssa.OpLessInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x64.Less", opLen2(ssa.OpLessUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x32.Less", opLen2(ssa.OpLessUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x16.Less", opLen2(ssa.OpLessUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x8.Less", opLen2(ssa.OpLessUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.LessEqual", opLen2(ssa.OpLessEqualFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.LessEqual", opLen2(ssa.OpLessEqualFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.LessEqual", opLen2(ssa.OpLessEqualFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.LessEqual", opLen2(ssa.OpLessEqualFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.LessEqual", opLen2(ssa.OpLessEqualFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.LessEqual", opLen2(ssa.OpLessEqualFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x64.LessEqual", opLen2(ssa.OpLessEqualInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x32.LessEqual", opLen2(ssa.OpLessEqualInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x16.LessEqual", opLen2(ssa.OpLessEqualInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x8.LessEqual", opLen2(ssa.OpLessEqualInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x64.LessEqual", opLen2(ssa.OpLessEqualUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x32.LessEqual", opLen2(ssa.OpLessEqualUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x16.LessEqual", opLen2(ssa.OpLessEqualUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x8.LessEqual", opLen2(ssa.OpLessEqualUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Max", opLen2(ssa.OpMaxFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Max", opLen2(ssa.OpMaxFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Max", opLen2(ssa.OpMaxFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Max", opLen2(ssa.OpMaxFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Max", opLen2(ssa.OpMaxFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Max", opLen2(ssa.OpMaxFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Max", opLen2(ssa.OpMaxInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Max", opLen2(ssa.OpMaxInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Max", opLen2(ssa.OpMaxInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Max", opLen2(ssa.OpMaxInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Max", opLen2(ssa.OpMaxInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Max", opLen2(ssa.OpMaxInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Max", opLen2(ssa.OpMaxInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Max", opLen2(ssa.OpMaxInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Max", opLen2(ssa.OpMaxInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Max", opLen2(ssa.OpMaxInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Max", opLen2(ssa.OpMaxInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Max", opLen2(ssa.OpMaxInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Max", opLen2(ssa.OpMaxUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.Max", opLen2(ssa.OpMaxUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.Max", opLen2(ssa.OpMaxUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Max", opLen2(ssa.OpMaxUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Max", opLen2(ssa.OpMaxUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Max", opLen2(ssa.OpMaxUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.Max", opLen2(ssa.OpMaxUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.Max", opLen2(ssa.OpMaxUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.Max", opLen2(ssa.OpMaxUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.Max", opLen2(ssa.OpMaxUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.Max", opLen2(ssa.OpMaxUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.Max", opLen2(ssa.OpMaxUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Min", opLen2(ssa.OpMinFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Min", opLen2(ssa.OpMinFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Min", opLen2(ssa.OpMinFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Min", opLen2(ssa.OpMinFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Min", opLen2(ssa.OpMinFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Min", opLen2(ssa.OpMinFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Min", opLen2(ssa.OpMinInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Min", opLen2(ssa.OpMinInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Min", opLen2(ssa.OpMinInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Min", opLen2(ssa.OpMinInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Min", opLen2(ssa.OpMinInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Min", opLen2(ssa.OpMinInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Min", opLen2(ssa.OpMinInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Min", opLen2(ssa.OpMinInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Min", opLen2(ssa.OpMinInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Min", opLen2(ssa.OpMinInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Min", opLen2(ssa.OpMinInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Min", opLen2(ssa.OpMinInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Min", opLen2(ssa.OpMinUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.Min", opLen2(ssa.OpMinUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.Min", opLen2(ssa.OpMinUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Min", opLen2(ssa.OpMinUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Min", opLen2(ssa.OpMinUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Min", opLen2(ssa.OpMinUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.Min", opLen2(ssa.OpMinUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.Min", opLen2(ssa.OpMinUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.Min", opLen2(ssa.OpMinUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.Min", opLen2(ssa.OpMinUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.Min", opLen2(ssa.OpMinUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.Min", opLen2(ssa.OpMinUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Mul", opLen2(ssa.OpMulFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Mul", opLen2(ssa.OpMulFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Mul", opLen2(ssa.OpMulFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Mul", opLen2(ssa.OpMulFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Mul", opLen2(ssa.OpMulFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Mul", opLen2(ssa.OpMulFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Mul", opLen2(ssa.OpMulInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Mul", opLen2(ssa.OpMulInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Mul", opLen2(ssa.OpMulInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Mul", opLen2(ssa.OpMulInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Mul", opLen2(ssa.OpMulInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Mul", opLen2(ssa.OpMulInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Mul", opLen2(ssa.OpMulInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Mul", opLen2(ssa.OpMulInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Mul", opLen2(ssa.OpMulInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Mul", opLen2(ssa.OpMulUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Mul", opLen2(ssa.OpMulUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Mul", opLen2(ssa.OpMulUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.Mul", opLen2(ssa.OpMulUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.Mul", opLen2(ssa.OpMulUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.Mul", opLen2(ssa.OpMulUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.Mul", opLen2(ssa.OpMulUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.Mul", opLen2(ssa.OpMulUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.Mul", opLen2(ssa.OpMulUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.MulAdd", opLen3(ssa.OpMulAddFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.MulAdd", opLen3(ssa.OpMulAddFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.MulAdd", opLen3(ssa.OpMulAddFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.MulAdd", opLen3(ssa.OpMulAddFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.MulAdd", opLen3(ssa.OpMulAddFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.MulAdd", opLen3(ssa.OpMulAddFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.MulAddSub", opLen3(ssa.OpMulAddSubFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.MulAddSub", opLen3(ssa.OpMulAddSubFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.MulAddSub", opLen3(ssa.OpMulAddSubFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.MulAddSub", opLen3(ssa.OpMulAddSubFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.MulAddSub", opLen3(ssa.OpMulAddSubFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.MulAddSub", opLen3(ssa.OpMulAddSubFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.MulEvenWiden", opLen2(ssa.OpMulEvenWidenInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.MulEvenWiden", opLen2(ssa.OpMulEvenWidenInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x4.MulEvenWiden", opLen2(ssa.OpMulEvenWidenUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.MulEvenWiden", opLen2(ssa.OpMulEvenWidenUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x8.MulHigh", opLen2(ssa.OpMulHighInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.MulHigh", opLen2(ssa.OpMulHighInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.MulHigh", opLen2(ssa.OpMulHighInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.MulHigh", opLen2(ssa.OpMulHighUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.MulHigh", opLen2(ssa.OpMulHighUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.MulHigh", opLen2(ssa.OpMulHighUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.MulSubAdd", opLen3(ssa.OpMulSubAddFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.MulSubAdd", opLen3(ssa.OpMulSubAddFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.MulSubAdd", opLen3(ssa.OpMulSubAddFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.MulSubAdd", opLen3(ssa.OpMulSubAddFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.MulSubAdd", opLen3(ssa.OpMulSubAddFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.MulSubAdd", opLen3(ssa.OpMulSubAddFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.NotEqual", opLen2(ssa.OpNotEqualFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.NotEqual", opLen2(ssa.OpNotEqualFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.NotEqual", opLen2(ssa.OpNotEqualFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.NotEqual", opLen2(ssa.OpNotEqualFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.NotEqual", opLen2(ssa.OpNotEqualFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.NotEqual", opLen2(ssa.OpNotEqualFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x64.NotEqual", opLen2(ssa.OpNotEqualInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x32.NotEqual", opLen2(ssa.OpNotEqualInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x16.NotEqual", opLen2(ssa.OpNotEqualInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x8.NotEqual", opLen2(ssa.OpNotEqualInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x64.NotEqual", opLen2(ssa.OpNotEqualUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x32.NotEqual", opLen2(ssa.OpNotEqualUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x16.NotEqual", opLen2(ssa.OpNotEqualUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x8.NotEqual", opLen2(ssa.OpNotEqualUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.OnesCount", opLen1(ssa.OpOnesCountInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.OnesCount", opLen1(ssa.OpOnesCountInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.OnesCount", opLen1(ssa.OpOnesCountInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.OnesCount", opLen1(ssa.OpOnesCountInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.OnesCount", opLen1(ssa.OpOnesCountInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.OnesCount", opLen1(ssa.OpOnesCountInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.OnesCount", opLen1(ssa.OpOnesCountInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.OnesCount", opLen1(ssa.OpOnesCountInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.OnesCount", opLen1(ssa.OpOnesCountInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.OnesCount", opLen1(ssa.OpOnesCountInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.OnesCount", opLen1(ssa.OpOnesCountInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.OnesCount", opLen1(ssa.OpOnesCountInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.OnesCount", opLen1(ssa.OpOnesCountUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.OnesCount", opLen1(ssa.OpOnesCountUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.OnesCount", opLen1(ssa.OpOnesCountUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.OnesCount", opLen1(ssa.OpOnesCountUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.OnesCount", opLen1(ssa.OpOnesCountUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.OnesCount", opLen1(ssa.OpOnesCountUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.OnesCount", opLen1(ssa.OpOnesCountUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.OnesCount", opLen1(ssa.OpOnesCountUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.OnesCount", opLen1(ssa.OpOnesCountUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.OnesCount", opLen1(ssa.OpOnesCountUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.OnesCount", opLen1(ssa.OpOnesCountUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.OnesCount", opLen1(ssa.OpOnesCountUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Or", opLen2(ssa.OpOrInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Or", opLen2(ssa.OpOrInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Or", opLen2(ssa.OpOrInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Or", opLen2(ssa.OpOrInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Or", opLen2(ssa.OpOrInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Or", opLen2(ssa.OpOrInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Or", opLen2(ssa.OpOrInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Or", opLen2(ssa.OpOrInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Or", opLen2(ssa.OpOrInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Or", opLen2(ssa.OpOrInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Or", opLen2(ssa.OpOrInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Or", opLen2(ssa.OpOrInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Or", opLen2(ssa.OpOrUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.Or", opLen2(ssa.OpOrUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.Or", opLen2(ssa.OpOrUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Or", opLen2(ssa.OpOrUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Or", opLen2(ssa.OpOrUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Or", opLen2(ssa.OpOrUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.Or", opLen2(ssa.OpOrUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.Or", opLen2(ssa.OpOrUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.Or", opLen2(ssa.OpOrUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.Or", opLen2(ssa.OpOrUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.Or", opLen2(ssa.OpOrUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.Or", opLen2(ssa.OpOrUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Permute", opLen2_21(ssa.OpPermuteInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x16.Permute", opLen2_21(ssa.OpPermuteUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Permute", opLen2_21(ssa.OpPermuteInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x32.Permute", opLen2_21(ssa.OpPermuteUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Permute", opLen2_21(ssa.OpPermuteInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x64.Permute", opLen2_21(ssa.OpPermuteUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Permute", opLen2_21(ssa.OpPermuteInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x8.Permute", opLen2_21(ssa.OpPermuteUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Permute", opLen2_21(ssa.OpPermuteInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x16.Permute", opLen2_21(ssa.OpPermuteUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Permute", opLen2_21(ssa.OpPermuteInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x32.Permute", opLen2_21(ssa.OpPermuteUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x8.Permute", opLen2_21(ssa.OpPermuteFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x8.Permute", opLen2_21(ssa.OpPermuteInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x8.Permute", opLen2_21(ssa.OpPermuteUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Permute", opLen2_21(ssa.OpPermuteFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x16.Permute", opLen2_21(ssa.OpPermuteInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x16.Permute", opLen2_21(ssa.OpPermuteUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x4.Permute", opLen2_21(ssa.OpPermuteFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x4.Permute", opLen2_21(ssa.OpPermuteInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x4.Permute", opLen2_21(ssa.OpPermuteUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Permute", opLen2_21(ssa.OpPermuteFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x8.Permute", opLen2_21(ssa.OpPermuteInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x8.Permute", opLen2_21(ssa.OpPermuteUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.PermuteOrZero", opLen2(ssa.OpPermuteOrZeroInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x16.PermuteOrZero", opLen2(ssa.OpPermuteOrZeroUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.PermuteOrZeroGrouped", opLen2(ssa.OpPermuteOrZeroGroupedInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.PermuteOrZeroGrouped", opLen2(ssa.OpPermuteOrZeroGroupedInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x32.PermuteOrZeroGrouped", opLen2(ssa.OpPermuteOrZeroGroupedUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.PermuteOrZeroGrouped", opLen2(ssa.OpPermuteOrZeroGroupedUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Reciprocal", opLen1(ssa.OpReciprocalFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Reciprocal", opLen1(ssa.OpReciprocalFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Reciprocal", opLen1(ssa.OpReciprocalFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Reciprocal", opLen1(ssa.OpReciprocalFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Reciprocal", opLen1(ssa.OpReciprocalFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Reciprocal", opLen1(ssa.OpReciprocalFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.ReciprocalSqrt", opLen1(ssa.OpReciprocalSqrtFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.ReciprocalSqrt", opLen1(ssa.OpReciprocalSqrtFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.ReciprocalSqrt", opLen1(ssa.OpReciprocalSqrtFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.ReciprocalSqrt", opLen1(ssa.OpReciprocalSqrtFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.ReciprocalSqrt", opLen1(ssa.OpReciprocalSqrtFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.ReciprocalSqrt", opLen1(ssa.OpReciprocalSqrtFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftInt32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int32x8.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftInt32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int32x16.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftInt32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int64x2.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftInt64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int64x4.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftInt64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int64x8.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftInt64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint32x4.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint32x8.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftUint32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint32x16.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftUint32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint64x2.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftUint64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint64x4.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftUint64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint64x8.RotateAllLeft", opLen1Imm8(ssa.OpRotateAllLeftUint64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int32x4.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightInt32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int32x8.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightInt32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int32x16.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightInt32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int64x2.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightInt64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int64x4.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightInt64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int64x8.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightInt64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint32x4.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint32x8.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightUint32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint32x16.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightUint32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint64x2.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightUint64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint64x4.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightUint64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint64x8.RotateAllRight", opLen1Imm8(ssa.OpRotateAllRightUint64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int32x4.RotateLeft", opLen2(ssa.OpRotateLeftInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.RotateLeft", opLen2(ssa.OpRotateLeftInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.RotateLeft", opLen2(ssa.OpRotateLeftInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.RotateLeft", opLen2(ssa.OpRotateLeftInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.RotateLeft", opLen2(ssa.OpRotateLeftInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.RotateLeft", opLen2(ssa.OpRotateLeftInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.RotateLeft", opLen2(ssa.OpRotateLeftUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.RotateLeft", opLen2(ssa.OpRotateLeftUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.RotateLeft", opLen2(ssa.OpRotateLeftUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.RotateLeft", opLen2(ssa.OpRotateLeftUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.RotateLeft", opLen2(ssa.OpRotateLeftUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.RotateLeft", opLen2(ssa.OpRotateLeftUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.RotateRight", opLen2(ssa.OpRotateRightInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.RotateRight", opLen2(ssa.OpRotateRightInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.RotateRight", opLen2(ssa.OpRotateRightInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.RotateRight", opLen2(ssa.OpRotateRightInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.RotateRight", opLen2(ssa.OpRotateRightInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.RotateRight", opLen2(ssa.OpRotateRightInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.RotateRight", opLen2(ssa.OpRotateRightUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.RotateRight", opLen2(ssa.OpRotateRightUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.RotateRight", opLen2(ssa.OpRotateRightUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.RotateRight", opLen2(ssa.OpRotateRightUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.RotateRight", opLen2(ssa.OpRotateRightUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.RotateRight", opLen2(ssa.OpRotateRightUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.RoundToEven", opLen1(ssa.OpRoundToEvenFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.RoundToEven", opLen1(ssa.OpRoundToEvenFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x2.RoundToEven", opLen1(ssa.OpRoundToEvenFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.RoundToEven", opLen1(ssa.OpRoundToEvenFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x4.RoundToEvenScaled", opLen1Imm8(ssa.OpRoundToEvenScaledFloat32x4, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float32x8.RoundToEvenScaled", opLen1Imm8(ssa.OpRoundToEvenScaledFloat32x8, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float32x16.RoundToEvenScaled", opLen1Imm8(ssa.OpRoundToEvenScaledFloat32x16, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float64x2.RoundToEvenScaled", opLen1Imm8(ssa.OpRoundToEvenScaledFloat64x2, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float64x4.RoundToEvenScaled", opLen1Imm8(ssa.OpRoundToEvenScaledFloat64x4, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float64x8.RoundToEvenScaled", opLen1Imm8(ssa.OpRoundToEvenScaledFloat64x8, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float32x4.RoundToEvenScaledResidue", opLen1Imm8(ssa.OpRoundToEvenScaledResidueFloat32x4, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float32x8.RoundToEvenScaledResidue", opLen1Imm8(ssa.OpRoundToEvenScaledResidueFloat32x8, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float32x16.RoundToEvenScaledResidue", opLen1Imm8(ssa.OpRoundToEvenScaledResidueFloat32x16, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float64x2.RoundToEvenScaledResidue", opLen1Imm8(ssa.OpRoundToEvenScaledResidueFloat64x2, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float64x4.RoundToEvenScaledResidue", opLen1Imm8(ssa.OpRoundToEvenScaledResidueFloat64x4, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float64x8.RoundToEvenScaledResidue", opLen1Imm8(ssa.OpRoundToEvenScaledResidueFloat64x8, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA1FourRounds", opLen2Imm8_SHA1RNDS4(ssa.OpSHA1FourRoundsUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA1Message1", opLen2(ssa.OpSHA1Message1Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA1Message2", opLen2(ssa.OpSHA1Message2Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA1NextE", opLen2(ssa.OpSHA1NextEUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA256Message1", opLen2(ssa.OpSHA256Message1Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA256Message2", opLen2(ssa.OpSHA256Message2Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SHA256TwoRounds", opLen3(ssa.OpSHA256TwoRoundsUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x8.SaturateToInt8", opLen1(ssa.OpSaturateToInt8Int16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.SaturateToInt8", opLen1(ssa.OpSaturateToInt8Int16x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x32.SaturateToInt8", opLen1(ssa.OpSaturateToInt8Int16x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x4.SaturateToInt8", opLen1(ssa.OpSaturateToInt8Int32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.SaturateToInt8", opLen1(ssa.OpSaturateToInt8Int32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x16.SaturateToInt8", opLen1(ssa.OpSaturateToInt8Int32x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x2.SaturateToInt8", opLen1(ssa.OpSaturateToInt8Int64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.SaturateToInt8", opLen1(ssa.OpSaturateToInt8Int64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x8.SaturateToInt8", opLen1(ssa.OpSaturateToInt8Int64x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.SaturateToInt16", opLen1(ssa.OpSaturateToInt16Int32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.SaturateToInt16", opLen1(ssa.OpSaturateToInt16Int32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x16.SaturateToInt16", opLen1(ssa.OpSaturateToInt16Int32x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x2.SaturateToInt16", opLen1(ssa.OpSaturateToInt16Int64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.SaturateToInt16", opLen1(ssa.OpSaturateToInt16Int64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x8.SaturateToInt16", opLen1(ssa.OpSaturateToInt16Int64x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.SaturateToInt16Concat", opLen2(ssa.OpSaturateToInt16ConcatInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.SaturateToInt16ConcatGrouped", opLen2(ssa.OpSaturateToInt16ConcatGroupedInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.SaturateToInt16ConcatGrouped", opLen2(ssa.OpSaturateToInt16ConcatGroupedInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.SaturateToInt32", opLen1(ssa.OpSaturateToInt32Int64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.SaturateToInt32", opLen1(ssa.OpSaturateToInt32Int64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x8.SaturateToInt32", opLen1(ssa.OpSaturateToInt32Int64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x8.SaturateToUint8", opLen1(ssa.OpSaturateToUint8Uint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.SaturateToUint8", opLen1(ssa.OpSaturateToUint8Uint16x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x32.SaturateToUint8", opLen1(ssa.OpSaturateToUint8Uint16x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x4.SaturateToUint8", opLen1(ssa.OpSaturateToUint8Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.SaturateToUint8", opLen1(ssa.OpSaturateToUint8Uint32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x16.SaturateToUint8", opLen1(ssa.OpSaturateToUint8Uint32x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x2.SaturateToUint8", opLen1(ssa.OpSaturateToUint8Uint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.SaturateToUint8", opLen1(ssa.OpSaturateToUint8Uint64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x8.SaturateToUint8", opLen1(ssa.OpSaturateToUint8Uint64x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SaturateToUint16", opLen1(ssa.OpSaturateToUint16Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.SaturateToUint16", opLen1(ssa.OpSaturateToUint16Uint32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x16.SaturateToUint16", opLen1(ssa.OpSaturateToUint16Uint32x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x2.SaturateToUint16", opLen1(ssa.OpSaturateToUint16Uint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.SaturateToUint16", opLen1(ssa.OpSaturateToUint16Uint64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x8.SaturateToUint16", opLen1(ssa.OpSaturateToUint16Uint64x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.SaturateToUint16Concat", opLen2(ssa.OpSaturateToUint16ConcatInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.SaturateToUint16ConcatGrouped", opLen2(ssa.OpSaturateToUint16ConcatGroupedInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.SaturateToUint16ConcatGrouped", opLen2(ssa.OpSaturateToUint16ConcatGroupedInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.SaturateToUint32", opLen1(ssa.OpSaturateToUint32Uint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.SaturateToUint32", opLen1(ssa.OpSaturateToUint32Uint64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x8.SaturateToUint32", opLen1(ssa.OpSaturateToUint32Uint64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x4.Scale", opLen2(ssa.OpScaleFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Scale", opLen2(ssa.OpScaleFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Scale", opLen2(ssa.OpScaleFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Scale", opLen2(ssa.OpScaleFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Scale", opLen2(ssa.OpScaleFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Scale", opLen2(ssa.OpScaleFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x8.Select128FromPair", opLen2Imm8_II(ssa.OpSelect128FromPairFloat32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Float64x4.Select128FromPair", opLen2Imm8_II(ssa.OpSelect128FromPairFloat64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int8x32.Select128FromPair", opLen2Imm8_II(ssa.OpSelect128FromPairInt8x32, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int16x16.Select128FromPair", opLen2Imm8_II(ssa.OpSelect128FromPairInt16x16, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int32x8.Select128FromPair", opLen2Imm8_II(ssa.OpSelect128FromPairInt32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int64x4.Select128FromPair", opLen2Imm8_II(ssa.OpSelect128FromPairInt64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint8x32.Select128FromPair", opLen2Imm8_II(ssa.OpSelect128FromPairUint8x32, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint16x16.Select128FromPair", opLen2Imm8_II(ssa.OpSelect128FromPairUint16x16, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint32x8.Select128FromPair", opLen2Imm8_II(ssa.OpSelect128FromPairUint32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint64x4.Select128FromPair", opLen2Imm8_II(ssa.OpSelect128FromPairUint64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Float32x4.SetElem", opLen2Imm8(ssa.OpSetElemFloat32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Float64x2.SetElem", opLen2Imm8(ssa.OpSetElemFloat64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int8x16.SetElem", opLen2Imm8(ssa.OpSetElemInt8x16, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int16x8.SetElem", opLen2Imm8(ssa.OpSetElemInt16x8, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int32x4.SetElem", opLen2Imm8(ssa.OpSetElemInt32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int64x2.SetElem", opLen2Imm8(ssa.OpSetElemInt64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint8x16.SetElem", opLen2Imm8(ssa.OpSetElemUint8x16, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint16x8.SetElem", opLen2Imm8(ssa.OpSetElemUint16x8, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint32x4.SetElem", opLen2Imm8(ssa.OpSetElemUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint64x2.SetElem", opLen2Imm8(ssa.OpSetElemUint64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Float32x8.SetHi", opLen2(ssa.OpSetHiFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.SetHi", opLen2(ssa.OpSetHiFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x4.SetHi", opLen2(ssa.OpSetHiFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.SetHi", opLen2(ssa.OpSetHiFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x32.SetHi", opLen2(ssa.OpSetHiInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.SetHi", opLen2(ssa.OpSetHiInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x16.SetHi", opLen2(ssa.OpSetHiInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.SetHi", opLen2(ssa.OpSetHiInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x8.SetHi", opLen2(ssa.OpSetHiInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.SetHi", opLen2(ssa.OpSetHiInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x4.SetHi", opLen2(ssa.OpSetHiInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.SetHi", opLen2(ssa.OpSetHiInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x32.SetHi", opLen2(ssa.OpSetHiUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.SetHi", opLen2(ssa.OpSetHiUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x16.SetHi", opLen2(ssa.OpSetHiUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.SetHi", opLen2(ssa.OpSetHiUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x8.SetHi", opLen2(ssa.OpSetHiUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.SetHi", opLen2(ssa.OpSetHiUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x4.SetHi", opLen2(ssa.OpSetHiUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.SetHi", opLen2(ssa.OpSetHiUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x8.SetLo", opLen2(ssa.OpSetLoFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.SetLo", opLen2(ssa.OpSetLoFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x4.SetLo", opLen2(ssa.OpSetLoFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.SetLo", opLen2(ssa.OpSetLoFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x32.SetLo", opLen2(ssa.OpSetLoInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.SetLo", opLen2(ssa.OpSetLoInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x16.SetLo", opLen2(ssa.OpSetLoInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.SetLo", opLen2(ssa.OpSetLoInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x8.SetLo", opLen2(ssa.OpSetLoInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.SetLo", opLen2(ssa.OpSetLoInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x4.SetLo", opLen2(ssa.OpSetLoInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.SetLo", opLen2(ssa.OpSetLoInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x32.SetLo", opLen2(ssa.OpSetLoUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.SetLo", opLen2(ssa.OpSetLoUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x16.SetLo", opLen2(ssa.OpSetLoUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.SetLo", opLen2(ssa.OpSetLoUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x8.SetLo", opLen2(ssa.OpSetLoUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.SetLo", opLen2(ssa.OpSetLoUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x4.SetLo", opLen2(ssa.OpSetLoUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.SetLo", opLen2(ssa.OpSetLoUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.ShiftAllLeft", opLen2(ssa.OpShiftAllLeftUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatInt16x8, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int16x16.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatInt16x16, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int16x32.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatInt16x32, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int32x4.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatInt32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int32x8.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatInt32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int32x16.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatInt32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int64x2.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatInt64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int64x4.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatInt64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int64x8.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatInt64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint16x8.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatUint16x8, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint16x16.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatUint16x16, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint16x32.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatUint16x32, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint32x4.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint32x8.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatUint32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint32x16.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatUint32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint64x2.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatUint64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint64x4.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatUint64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint64x8.ShiftAllLeftConcat", opLen2Imm8(ssa.OpShiftAllLeftConcatUint64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int16x8.ShiftAllRight", opLen2(ssa.OpShiftAllRightInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.ShiftAllRight", opLen2(ssa.OpShiftAllRightInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.ShiftAllRight", opLen2(ssa.OpShiftAllRightInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.ShiftAllRight", opLen2(ssa.OpShiftAllRightInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.ShiftAllRight", opLen2(ssa.OpShiftAllRightInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.ShiftAllRight", opLen2(ssa.OpShiftAllRightInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.ShiftAllRight", opLen2(ssa.OpShiftAllRightInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.ShiftAllRight", opLen2(ssa.OpShiftAllRightInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.ShiftAllRight", opLen2(ssa.OpShiftAllRightInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.ShiftAllRight", opLen2(ssa.OpShiftAllRightUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.ShiftAllRight", opLen2(ssa.OpShiftAllRightUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.ShiftAllRight", opLen2(ssa.OpShiftAllRightUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.ShiftAllRight", opLen2(ssa.OpShiftAllRightUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.ShiftAllRight", opLen2(ssa.OpShiftAllRightUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.ShiftAllRight", opLen2(ssa.OpShiftAllRightUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.ShiftAllRight", opLen2(ssa.OpShiftAllRightUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.ShiftAllRight", opLen2(ssa.OpShiftAllRightUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.ShiftAllRight", opLen2(ssa.OpShiftAllRightUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatInt16x8, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int16x16.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatInt16x16, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int16x32.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatInt16x32, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int32x4.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatInt32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int32x8.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatInt32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int32x16.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatInt32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int64x2.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatInt64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int64x4.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatInt64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int64x8.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatInt64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint16x8.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatUint16x8, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint16x16.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatUint16x16, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint16x32.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatUint16x32, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint32x4.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint32x8.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatUint32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint32x16.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatUint32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint64x2.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatUint64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint64x4.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatUint64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint64x8.ShiftAllRightConcat", opLen2Imm8(ssa.OpShiftAllRightConcatUint64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int16x8.ShiftLeft", opLen2(ssa.OpShiftLeftInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.ShiftLeft", opLen2(ssa.OpShiftLeftInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.ShiftLeft", opLen2(ssa.OpShiftLeftInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.ShiftLeft", opLen2(ssa.OpShiftLeftInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.ShiftLeft", opLen2(ssa.OpShiftLeftInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.ShiftLeft", opLen2(ssa.OpShiftLeftInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.ShiftLeft", opLen2(ssa.OpShiftLeftInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.ShiftLeft", opLen2(ssa.OpShiftLeftInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.ShiftLeft", opLen2(ssa.OpShiftLeftInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.ShiftLeft", opLen2(ssa.OpShiftLeftUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.ShiftLeft", opLen2(ssa.OpShiftLeftUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.ShiftLeft", opLen2(ssa.OpShiftLeftUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.ShiftLeft", opLen2(ssa.OpShiftLeftUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.ShiftLeft", opLen2(ssa.OpShiftLeftUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.ShiftLeft", opLen2(ssa.OpShiftLeftUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.ShiftLeft", opLen2(ssa.OpShiftLeftUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.ShiftLeft", opLen2(ssa.OpShiftLeftUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.ShiftLeft", opLen2(ssa.OpShiftLeftUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.ShiftLeftConcat", opLen3(ssa.OpShiftLeftConcatUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.ShiftRight", opLen2(ssa.OpShiftRightInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.ShiftRight", opLen2(ssa.OpShiftRightInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.ShiftRight", opLen2(ssa.OpShiftRightInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.ShiftRight", opLen2(ssa.OpShiftRightInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.ShiftRight", opLen2(ssa.OpShiftRightInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.ShiftRight", opLen2(ssa.OpShiftRightInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.ShiftRight", opLen2(ssa.OpShiftRightInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.ShiftRight", opLen2(ssa.OpShiftRightInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.ShiftRight", opLen2(ssa.OpShiftRightInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.ShiftRight", opLen2(ssa.OpShiftRightUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.ShiftRight", opLen2(ssa.OpShiftRightUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.ShiftRight", opLen2(ssa.OpShiftRightUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.ShiftRight", opLen2(ssa.OpShiftRightUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.ShiftRight", opLen2(ssa.OpShiftRightUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.ShiftRight", opLen2(ssa.OpShiftRightUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.ShiftRight", opLen2(ssa.OpShiftRightUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.ShiftRight", opLen2(ssa.OpShiftRightUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.ShiftRight", opLen2(ssa.OpShiftRightUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.ShiftRightConcat", opLen3(ssa.OpShiftRightConcatUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Sqrt", opLen1(ssa.OpSqrtFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Sqrt", opLen1(ssa.OpSqrtFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Sqrt", opLen1(ssa.OpSqrtFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Sqrt", opLen1(ssa.OpSqrtFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Sqrt", opLen1(ssa.OpSqrtFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Sqrt", opLen1(ssa.OpSqrtFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Sub", opLen2(ssa.OpSubFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Sub", opLen2(ssa.OpSubFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x16.Sub", opLen2(ssa.OpSubFloat32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float64x2.Sub", opLen2(ssa.OpSubFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Sub", opLen2(ssa.OpSubFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x8.Sub", opLen2(ssa.OpSubFloat64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.Sub", opLen2(ssa.OpSubInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Sub", opLen2(ssa.OpSubInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Sub", opLen2(ssa.OpSubInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Sub", opLen2(ssa.OpSubInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Sub", opLen2(ssa.OpSubInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Sub", opLen2(ssa.OpSubInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Sub", opLen2(ssa.OpSubInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Sub", opLen2(ssa.OpSubInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Sub", opLen2(ssa.OpSubInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Sub", opLen2(ssa.OpSubInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Sub", opLen2(ssa.OpSubInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Sub", opLen2(ssa.OpSubInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Sub", opLen2(ssa.OpSubUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.Sub", opLen2(ssa.OpSubUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.Sub", opLen2(ssa.OpSubUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Sub", opLen2(ssa.OpSubUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Sub", opLen2(ssa.OpSubUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Sub", opLen2(ssa.OpSubUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.Sub", opLen2(ssa.OpSubUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.Sub", opLen2(ssa.OpSubUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.Sub", opLen2(ssa.OpSubUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.Sub", opLen2(ssa.OpSubUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.Sub", opLen2(ssa.OpSubUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.Sub", opLen2(ssa.OpSubUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.SubPairs", opLen2(ssa.OpSubPairsFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x2.SubPairs", opLen2(ssa.OpSubPairsFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x8.SubPairs", opLen2(ssa.OpSubPairsInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.SubPairs", opLen2(ssa.OpSubPairsInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x8.SubPairs", opLen2(ssa.OpSubPairsUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.SubPairs", opLen2(ssa.OpSubPairsUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.SubPairsGrouped", opLen2(ssa.OpSubPairsGroupedFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x4.SubPairsGrouped", opLen2(ssa.OpSubPairsGroupedFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x16.SubPairsGrouped", opLen2(ssa.OpSubPairsGroupedInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x8.SubPairsGrouped", opLen2(ssa.OpSubPairsGroupedInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x16.SubPairsGrouped", opLen2(ssa.OpSubPairsGroupedUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x8.SubPairsGrouped", opLen2(ssa.OpSubPairsGroupedUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x8.SubPairsSaturated", opLen2(ssa.OpSubPairsSaturatedInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.SubPairsSaturatedGrouped", opLen2(ssa.OpSubPairsSaturatedGroupedInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x16.SubSaturated", opLen2(ssa.OpSubSaturatedInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.SubSaturated", opLen2(ssa.OpSubSaturatedInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.SubSaturated", opLen2(ssa.OpSubSaturatedInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.SubSaturated", opLen2(ssa.OpSubSaturatedInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.SubSaturated", opLen2(ssa.OpSubSaturatedInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.SubSaturated", opLen2(ssa.OpSubSaturatedInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.SubSaturated", opLen2(ssa.OpSubSaturatedUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.SubSaturated", opLen2(ssa.OpSubSaturatedUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.SubSaturated", opLen2(ssa.OpSubSaturatedUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.SubSaturated", opLen2(ssa.OpSubSaturatedUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.SubSaturated", opLen2(ssa.OpSubSaturatedUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.SubSaturated", opLen2(ssa.OpSubSaturatedUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.SumAbsDiff", opLen2(ssa.OpSumAbsDiffUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.SumAbsDiff", opLen2(ssa.OpSumAbsDiffUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.SumAbsDiff", opLen2(ssa.OpSumAbsDiffUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Float32x4.Trunc", opLen1(ssa.OpTruncFloat32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float32x8.Trunc", opLen1(ssa.OpTruncFloat32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float64x2.Trunc", opLen1(ssa.OpTruncFloat64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Float64x4.Trunc", opLen1(ssa.OpTruncFloat64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Float32x4.TruncScaled", opLen1Imm8(ssa.OpTruncScaledFloat32x4, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float32x8.TruncScaled", opLen1Imm8(ssa.OpTruncScaledFloat32x8, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float32x16.TruncScaled", opLen1Imm8(ssa.OpTruncScaledFloat32x16, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float64x2.TruncScaled", opLen1Imm8(ssa.OpTruncScaledFloat64x2, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float64x4.TruncScaled", opLen1Imm8(ssa.OpTruncScaledFloat64x4, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float64x8.TruncScaled", opLen1Imm8(ssa.OpTruncScaledFloat64x8, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float32x4.TruncScaledResidue", opLen1Imm8(ssa.OpTruncScaledResidueFloat32x4, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float32x8.TruncScaledResidue", opLen1Imm8(ssa.OpTruncScaledResidueFloat32x8, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float32x16.TruncScaledResidue", opLen1Imm8(ssa.OpTruncScaledResidueFloat32x16, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Float64x2.TruncScaledResidue", opLen1Imm8(ssa.OpTruncScaledResidueFloat64x2, types.TypeVec128, 4), sys.AMD64) + addF(simdPackage, "Float64x4.TruncScaledResidue", opLen1Imm8(ssa.OpTruncScaledResidueFloat64x4, types.TypeVec256, 4), sys.AMD64) + addF(simdPackage, "Float64x8.TruncScaledResidue", opLen1Imm8(ssa.OpTruncScaledResidueFloat64x8, types.TypeVec512, 4), sys.AMD64) + addF(simdPackage, "Int16x8.TruncateToInt8", opLen1(ssa.OpTruncateToInt8Int16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.TruncateToInt8", opLen1(ssa.OpTruncateToInt8Int16x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x32.TruncateToInt8", opLen1(ssa.OpTruncateToInt8Int16x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x4.TruncateToInt8", opLen1(ssa.OpTruncateToInt8Int32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.TruncateToInt8", opLen1(ssa.OpTruncateToInt8Int32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x16.TruncateToInt8", opLen1(ssa.OpTruncateToInt8Int32x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x2.TruncateToInt8", opLen1(ssa.OpTruncateToInt8Int64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.TruncateToInt8", opLen1(ssa.OpTruncateToInt8Int64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x8.TruncateToInt8", opLen1(ssa.OpTruncateToInt8Int64x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x4.TruncateToInt16", opLen1(ssa.OpTruncateToInt16Int32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.TruncateToInt16", opLen1(ssa.OpTruncateToInt16Int32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x16.TruncateToInt16", opLen1(ssa.OpTruncateToInt16Int32x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x2.TruncateToInt16", opLen1(ssa.OpTruncateToInt16Int64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.TruncateToInt16", opLen1(ssa.OpTruncateToInt16Int64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x8.TruncateToInt16", opLen1(ssa.OpTruncateToInt16Int64x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x2.TruncateToInt32", opLen1(ssa.OpTruncateToInt32Int64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.TruncateToInt32", opLen1(ssa.OpTruncateToInt32Int64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x8.TruncateToInt32", opLen1(ssa.OpTruncateToInt32Int64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x8.TruncateToUint8", opLen1(ssa.OpTruncateToUint8Uint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.TruncateToUint8", opLen1(ssa.OpTruncateToUint8Uint16x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x32.TruncateToUint8", opLen1(ssa.OpTruncateToUint8Uint16x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x4.TruncateToUint8", opLen1(ssa.OpTruncateToUint8Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.TruncateToUint8", opLen1(ssa.OpTruncateToUint8Uint32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x16.TruncateToUint8", opLen1(ssa.OpTruncateToUint8Uint32x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x2.TruncateToUint8", opLen1(ssa.OpTruncateToUint8Uint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.TruncateToUint8", opLen1(ssa.OpTruncateToUint8Uint64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x8.TruncateToUint8", opLen1(ssa.OpTruncateToUint8Uint64x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x4.TruncateToUint16", opLen1(ssa.OpTruncateToUint16Uint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.TruncateToUint16", opLen1(ssa.OpTruncateToUint16Uint32x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x16.TruncateToUint16", opLen1(ssa.OpTruncateToUint16Uint32x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x2.TruncateToUint16", opLen1(ssa.OpTruncateToUint16Uint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.TruncateToUint16", opLen1(ssa.OpTruncateToUint16Uint64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x8.TruncateToUint16", opLen1(ssa.OpTruncateToUint16Uint64x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x2.TruncateToUint32", opLen1(ssa.OpTruncateToUint32Uint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.TruncateToUint32", opLen1(ssa.OpTruncateToUint32Uint64x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x8.TruncateToUint32", opLen1(ssa.OpTruncateToUint32Uint64x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x16.Xor", opLen2(ssa.OpXorInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.Xor", opLen2(ssa.OpXorInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.Xor", opLen2(ssa.OpXorInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x8.Xor", opLen2(ssa.OpXorInt16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int16x16.Xor", opLen2(ssa.OpXorInt16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int16x32.Xor", opLen2(ssa.OpXorInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x4.Xor", opLen2(ssa.OpXorInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int32x8.Xor", opLen2(ssa.OpXorInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int32x16.Xor", opLen2(ssa.OpXorInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x2.Xor", opLen2(ssa.OpXorInt64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int64x4.Xor", opLen2(ssa.OpXorInt64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int64x8.Xor", opLen2(ssa.OpXorInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint8x16.Xor", opLen2(ssa.OpXorUint8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint8x32.Xor", opLen2(ssa.OpXorUint8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint8x64.Xor", opLen2(ssa.OpXorUint8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint16x8.Xor", opLen2(ssa.OpXorUint16x8, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint16x16.Xor", opLen2(ssa.OpXorUint16x16, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint16x32.Xor", opLen2(ssa.OpXorUint16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint32x4.Xor", opLen2(ssa.OpXorUint32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint32x8.Xor", opLen2(ssa.OpXorUint32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint32x16.Xor", opLen2(ssa.OpXorUint32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.Xor", opLen2(ssa.OpXorUint64x2, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Uint64x4.Xor", opLen2(ssa.OpXorUint64x4, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Uint64x8.Xor", opLen2(ssa.OpXorUint64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int8x16.blend", opLen3(ssa.OpblendInt8x16, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Int8x32.blend", opLen3(ssa.OpblendInt8x32, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Int8x64.blendMasked", opLen3(ssa.OpblendMaskedInt8x64, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int16x32.blendMasked", opLen3(ssa.OpblendMaskedInt16x32, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int32x16.blendMasked", opLen3(ssa.OpblendMaskedInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Int64x8.blendMasked", opLen3(ssa.OpblendMaskedInt64x8, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Uint64x2.carrylessMultiply", opLen2Imm8(ssa.OpcarrylessMultiplyUint64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint64x4.carrylessMultiply", opLen2Imm8(ssa.OpcarrylessMultiplyUint64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint64x8.carrylessMultiply", opLen2Imm8(ssa.OpcarrylessMultiplyUint64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Float32x4.concatSelectedConstant", opLen2Imm8(ssa.OpconcatSelectedConstantFloat32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Float64x2.concatSelectedConstant", opLen2Imm8(ssa.OpconcatSelectedConstantFloat64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int32x4.concatSelectedConstant", opLen2Imm8(ssa.OpconcatSelectedConstantInt32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int64x2.concatSelectedConstant", opLen2Imm8(ssa.OpconcatSelectedConstantInt64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint32x4.concatSelectedConstant", opLen2Imm8(ssa.OpconcatSelectedConstantUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint64x2.concatSelectedConstant", opLen2Imm8(ssa.OpconcatSelectedConstantUint64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Float32x8.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedFloat32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Float32x16.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedFloat32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Float64x4.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedFloat64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Float64x8.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedFloat64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int32x8.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedInt32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int32x16.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedInt32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int64x4.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedInt64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int64x8.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedInt64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint32x8.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedUint32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint32x16.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedUint32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint64x4.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedUint64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint64x8.concatSelectedConstantGrouped", opLen2Imm8(ssa.OpconcatSelectedConstantGroupedUint64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int32x4.permuteScalars", opLen1Imm8(ssa.OppermuteScalarsInt32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint32x4.permuteScalars", opLen1Imm8(ssa.OppermuteScalarsUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int32x8.permuteScalarsGrouped", opLen1Imm8(ssa.OppermuteScalarsGroupedInt32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int32x16.permuteScalarsGrouped", opLen1Imm8(ssa.OppermuteScalarsGroupedInt32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint32x8.permuteScalarsGrouped", opLen1Imm8(ssa.OppermuteScalarsGroupedUint32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint32x16.permuteScalarsGrouped", opLen1Imm8(ssa.OppermuteScalarsGroupedUint32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int16x8.permuteScalarsHi", opLen1Imm8(ssa.OppermuteScalarsHiInt16x8, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint16x8.permuteScalarsHi", opLen1Imm8(ssa.OppermuteScalarsHiUint16x8, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int16x16.permuteScalarsHiGrouped", opLen1Imm8(ssa.OppermuteScalarsHiGroupedInt16x16, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int16x32.permuteScalarsHiGrouped", opLen1Imm8(ssa.OppermuteScalarsHiGroupedInt16x32, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint16x16.permuteScalarsHiGrouped", opLen1Imm8(ssa.OppermuteScalarsHiGroupedUint16x16, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint16x32.permuteScalarsHiGrouped", opLen1Imm8(ssa.OppermuteScalarsHiGroupedUint16x32, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int16x8.permuteScalarsLo", opLen1Imm8(ssa.OppermuteScalarsLoInt16x8, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint16x8.permuteScalarsLo", opLen1Imm8(ssa.OppermuteScalarsLoUint16x8, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int16x16.permuteScalarsLoGrouped", opLen1Imm8(ssa.OppermuteScalarsLoGroupedInt16x16, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int16x32.permuteScalarsLoGrouped", opLen1Imm8(ssa.OppermuteScalarsLoGroupedInt16x32, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint16x16.permuteScalarsLoGrouped", opLen1Imm8(ssa.OppermuteScalarsLoGroupedUint16x16, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint16x32.permuteScalarsLoGrouped", opLen1Imm8(ssa.OppermuteScalarsLoGroupedUint16x32, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int32x4.tern", opLen3Imm8(ssa.OpternInt32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int32x8.tern", opLen3Imm8(ssa.OpternInt32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int32x16.tern", opLen3Imm8(ssa.OpternInt32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Int64x2.tern", opLen3Imm8(ssa.OpternInt64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Int64x4.tern", opLen3Imm8(ssa.OpternInt64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Int64x8.tern", opLen3Imm8(ssa.OpternInt64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint32x4.tern", opLen3Imm8(ssa.OpternUint32x4, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint32x8.tern", opLen3Imm8(ssa.OpternUint32x8, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint32x16.tern", opLen3Imm8(ssa.OpternUint32x16, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Uint64x2.tern", opLen3Imm8(ssa.OpternUint64x2, types.TypeVec128, 0), sys.AMD64) + addF(simdPackage, "Uint64x4.tern", opLen3Imm8(ssa.OpternUint64x4, types.TypeVec256, 0), sys.AMD64) + addF(simdPackage, "Uint64x8.tern", opLen3Imm8(ssa.OpternUint64x8, types.TypeVec512, 0), sys.AMD64) + addF(simdPackage, "Float32x4.AsFloat64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x4.AsInt8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x4.AsInt16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x4.AsInt32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x4.AsInt64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x4.AsUint8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x4.AsUint16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x4.AsUint32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x4.AsUint64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x8.AsFloat64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x8.AsInt8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x8.AsInt16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x8.AsInt32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x8.AsInt64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x8.AsUint8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x8.AsUint16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x8.AsUint32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x8.AsUint64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x16.AsFloat64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x16.AsInt8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x16.AsInt16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x16.AsInt32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x16.AsInt64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x16.AsUint8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x16.AsUint16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x16.AsUint32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float32x16.AsUint64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x2.AsFloat32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x2.AsInt8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x2.AsInt16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x2.AsInt32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x2.AsInt64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x2.AsUint8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x2.AsUint16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x2.AsUint32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x2.AsUint64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x4.AsFloat32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x4.AsInt8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x4.AsInt16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x4.AsInt32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x4.AsInt64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x4.AsUint8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x4.AsUint16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x4.AsUint32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x4.AsUint64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x8.AsFloat32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x8.AsInt8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x8.AsInt16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x8.AsInt32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x8.AsInt64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x8.AsUint8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x8.AsUint16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x8.AsUint32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Float64x8.AsUint64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x16.AsFloat32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x16.AsFloat64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x16.AsInt16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x16.AsInt32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x16.AsInt64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x16.AsUint8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x16.AsUint16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x16.AsUint32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x16.AsUint64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x32.AsFloat32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x32.AsFloat64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x32.AsInt16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x32.AsInt32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x32.AsInt64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x32.AsUint8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x32.AsUint16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x32.AsUint32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x32.AsUint64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x64.AsFloat32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x64.AsFloat64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x64.AsInt16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x64.AsInt32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x64.AsInt64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x64.AsUint8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x64.AsUint16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x64.AsUint32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x64.AsUint64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x8.AsFloat32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x8.AsFloat64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x8.AsInt8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x8.AsInt32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x8.AsInt64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x8.AsUint8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x8.AsUint16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x8.AsUint32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x8.AsUint64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x16.AsFloat32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x16.AsFloat64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x16.AsInt8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x16.AsInt32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x16.AsInt64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x16.AsUint8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x16.AsUint16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x16.AsUint32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x16.AsUint64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x32.AsFloat32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x32.AsFloat64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x32.AsInt8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x32.AsInt32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x32.AsInt64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x32.AsUint8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x32.AsUint16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x32.AsUint32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x32.AsUint64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x4.AsFloat32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x4.AsFloat64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x4.AsInt8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x4.AsInt16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x4.AsInt64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x4.AsUint8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x4.AsUint16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x4.AsUint32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x4.AsUint64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x8.AsFloat32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x8.AsFloat64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x8.AsInt8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x8.AsInt16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x8.AsInt64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x8.AsUint8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x8.AsUint16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x8.AsUint32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x8.AsUint64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x16.AsFloat32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x16.AsFloat64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x16.AsInt8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x16.AsInt16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x16.AsInt64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x16.AsUint8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x16.AsUint16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x16.AsUint32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x16.AsUint64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x2.AsFloat32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x2.AsFloat64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x2.AsInt8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x2.AsInt16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x2.AsInt32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x2.AsUint8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x2.AsUint16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x2.AsUint32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x2.AsUint64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x4.AsFloat32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x4.AsFloat64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x4.AsInt8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x4.AsInt16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x4.AsInt32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x4.AsUint8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x4.AsUint16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x4.AsUint32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x4.AsUint64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x8.AsFloat32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x8.AsFloat64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x8.AsInt8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x8.AsInt16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x8.AsInt32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x8.AsUint8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x8.AsUint16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x8.AsUint32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x8.AsUint64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x16.AsFloat32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x16.AsFloat64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x16.AsInt8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x16.AsInt16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x16.AsInt32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x16.AsInt64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x16.AsUint16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x16.AsUint32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x16.AsUint64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x32.AsFloat32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x32.AsFloat64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x32.AsInt8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x32.AsInt16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x32.AsInt32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x32.AsInt64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x32.AsUint16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x32.AsUint32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x32.AsUint64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x64.AsFloat32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x64.AsFloat64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x64.AsInt8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x64.AsInt16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x64.AsInt32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x64.AsInt64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x64.AsUint16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x64.AsUint32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint8x64.AsUint64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x8.AsFloat32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x8.AsFloat64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x8.AsInt8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x8.AsInt16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x8.AsInt32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x8.AsInt64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x8.AsUint8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x8.AsUint32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x8.AsUint64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x16.AsFloat32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x16.AsFloat64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x16.AsInt8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x16.AsInt16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x16.AsInt32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x16.AsInt64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x16.AsUint8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x16.AsUint32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x16.AsUint64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x32.AsFloat32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x32.AsFloat64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x32.AsInt8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x32.AsInt16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x32.AsInt32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x32.AsInt64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x32.AsUint8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x32.AsUint32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint16x32.AsUint64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x4.AsFloat32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x4.AsFloat64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x4.AsInt8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x4.AsInt16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x4.AsInt32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x4.AsInt64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x4.AsUint8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x4.AsUint16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x4.AsUint64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x8.AsFloat32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x8.AsFloat64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x8.AsInt8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x8.AsInt16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x8.AsInt32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x8.AsInt64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x8.AsUint8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x8.AsUint16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x8.AsUint64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x16.AsFloat32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x16.AsFloat64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x16.AsInt8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x16.AsInt16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x16.AsInt32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x16.AsInt64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x16.AsUint8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x16.AsUint16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint32x16.AsUint64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x2.AsFloat32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x2.AsFloat64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x2.AsInt8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x2.AsInt16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x2.AsInt32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x2.AsInt64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x2.AsUint8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x2.AsUint16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x2.AsUint32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x4.AsFloat32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x4.AsFloat64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x4.AsInt8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x4.AsInt16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x4.AsInt32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x4.AsInt64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x4.AsUint8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x4.AsUint16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x4.AsUint32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x8.AsFloat32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x8.AsFloat64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x8.AsInt8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x8.AsInt16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x8.AsInt32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x8.AsInt64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x8.AsUint8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x8.AsUint16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Uint64x8.AsUint32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "LoadFloat32x4", simdLoad(), sys.AMD64) + addF(simdPackage, "Float32x4.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadFloat32x8", simdLoad(), sys.AMD64) + addF(simdPackage, "Float32x8.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadFloat32x16", simdLoad(), sys.AMD64) + addF(simdPackage, "Float32x16.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadFloat64x2", simdLoad(), sys.AMD64) + addF(simdPackage, "Float64x2.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadFloat64x4", simdLoad(), sys.AMD64) + addF(simdPackage, "Float64x4.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadFloat64x8", simdLoad(), sys.AMD64) + addF(simdPackage, "Float64x8.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt8x16", simdLoad(), sys.AMD64) + addF(simdPackage, "Int8x16.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt8x32", simdLoad(), sys.AMD64) + addF(simdPackage, "Int8x32.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt8x64", simdLoad(), sys.AMD64) + addF(simdPackage, "Int8x64.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt16x8", simdLoad(), sys.AMD64) + addF(simdPackage, "Int16x8.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt16x16", simdLoad(), sys.AMD64) + addF(simdPackage, "Int16x16.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt16x32", simdLoad(), sys.AMD64) + addF(simdPackage, "Int16x32.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt32x4", simdLoad(), sys.AMD64) + addF(simdPackage, "Int32x4.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt32x8", simdLoad(), sys.AMD64) + addF(simdPackage, "Int32x8.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt32x16", simdLoad(), sys.AMD64) + addF(simdPackage, "Int32x16.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt64x2", simdLoad(), sys.AMD64) + addF(simdPackage, "Int64x2.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt64x4", simdLoad(), sys.AMD64) + addF(simdPackage, "Int64x4.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadInt64x8", simdLoad(), sys.AMD64) + addF(simdPackage, "Int64x8.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint8x16", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint8x16.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint8x32", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint8x32.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint8x64", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint8x64.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint16x8", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint16x8.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint16x16", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint16x16.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint16x32", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint16x32.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint32x4", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint32x4.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint32x8", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint32x8.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint32x16", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint32x16.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint64x2", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint64x2.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint64x4", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint64x4.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadUint64x8", simdLoad(), sys.AMD64) + addF(simdPackage, "Uint64x8.Store", simdStore(), sys.AMD64) + addF(simdPackage, "LoadMaskedFloat32x4", simdMaskedLoad(ssa.OpLoadMasked32), sys.AMD64) + addF(simdPackage, "Float32x4.StoreMasked", simdMaskedStore(ssa.OpStoreMasked32), sys.AMD64) + addF(simdPackage, "LoadMaskedFloat32x8", simdMaskedLoad(ssa.OpLoadMasked32), sys.AMD64) + addF(simdPackage, "Float32x8.StoreMasked", simdMaskedStore(ssa.OpStoreMasked32), sys.AMD64) + addF(simdPackage, "LoadMaskedFloat32x16", simdMaskedLoad(ssa.OpLoadMasked32), sys.AMD64) + addF(simdPackage, "Float32x16.StoreMasked", simdMaskedStore(ssa.OpStoreMasked32), sys.AMD64) + addF(simdPackage, "LoadMaskedFloat64x2", simdMaskedLoad(ssa.OpLoadMasked64), sys.AMD64) + addF(simdPackage, "Float64x2.StoreMasked", simdMaskedStore(ssa.OpStoreMasked64), sys.AMD64) + addF(simdPackage, "LoadMaskedFloat64x4", simdMaskedLoad(ssa.OpLoadMasked64), sys.AMD64) + addF(simdPackage, "Float64x4.StoreMasked", simdMaskedStore(ssa.OpStoreMasked64), sys.AMD64) + addF(simdPackage, "LoadMaskedFloat64x8", simdMaskedLoad(ssa.OpLoadMasked64), sys.AMD64) + addF(simdPackage, "Float64x8.StoreMasked", simdMaskedStore(ssa.OpStoreMasked64), sys.AMD64) + addF(simdPackage, "LoadMaskedInt8x64", simdMaskedLoad(ssa.OpLoadMasked8), sys.AMD64) + addF(simdPackage, "Int8x64.StoreMasked", simdMaskedStore(ssa.OpStoreMasked8), sys.AMD64) + addF(simdPackage, "LoadMaskedInt16x32", simdMaskedLoad(ssa.OpLoadMasked16), sys.AMD64) + addF(simdPackage, "Int16x32.StoreMasked", simdMaskedStore(ssa.OpStoreMasked16), sys.AMD64) + addF(simdPackage, "LoadMaskedInt32x4", simdMaskedLoad(ssa.OpLoadMasked32), sys.AMD64) + addF(simdPackage, "Int32x4.StoreMasked", simdMaskedStore(ssa.OpStoreMasked32), sys.AMD64) + addF(simdPackage, "LoadMaskedInt32x8", simdMaskedLoad(ssa.OpLoadMasked32), sys.AMD64) + addF(simdPackage, "Int32x8.StoreMasked", simdMaskedStore(ssa.OpStoreMasked32), sys.AMD64) + addF(simdPackage, "LoadMaskedInt32x16", simdMaskedLoad(ssa.OpLoadMasked32), sys.AMD64) + addF(simdPackage, "Int32x16.StoreMasked", simdMaskedStore(ssa.OpStoreMasked32), sys.AMD64) + addF(simdPackage, "LoadMaskedInt64x2", simdMaskedLoad(ssa.OpLoadMasked64), sys.AMD64) + addF(simdPackage, "Int64x2.StoreMasked", simdMaskedStore(ssa.OpStoreMasked64), sys.AMD64) + addF(simdPackage, "LoadMaskedInt64x4", simdMaskedLoad(ssa.OpLoadMasked64), sys.AMD64) + addF(simdPackage, "Int64x4.StoreMasked", simdMaskedStore(ssa.OpStoreMasked64), sys.AMD64) + addF(simdPackage, "LoadMaskedInt64x8", simdMaskedLoad(ssa.OpLoadMasked64), sys.AMD64) + addF(simdPackage, "Int64x8.StoreMasked", simdMaskedStore(ssa.OpStoreMasked64), sys.AMD64) + addF(simdPackage, "LoadMaskedUint8x64", simdMaskedLoad(ssa.OpLoadMasked8), sys.AMD64) + addF(simdPackage, "Uint8x64.StoreMasked", simdMaskedStore(ssa.OpStoreMasked8), sys.AMD64) + addF(simdPackage, "LoadMaskedUint16x32", simdMaskedLoad(ssa.OpLoadMasked16), sys.AMD64) + addF(simdPackage, "Uint16x32.StoreMasked", simdMaskedStore(ssa.OpStoreMasked16), sys.AMD64) + addF(simdPackage, "LoadMaskedUint32x4", simdMaskedLoad(ssa.OpLoadMasked32), sys.AMD64) + addF(simdPackage, "Uint32x4.StoreMasked", simdMaskedStore(ssa.OpStoreMasked32), sys.AMD64) + addF(simdPackage, "LoadMaskedUint32x8", simdMaskedLoad(ssa.OpLoadMasked32), sys.AMD64) + addF(simdPackage, "Uint32x8.StoreMasked", simdMaskedStore(ssa.OpStoreMasked32), sys.AMD64) + addF(simdPackage, "LoadMaskedUint32x16", simdMaskedLoad(ssa.OpLoadMasked32), sys.AMD64) + addF(simdPackage, "Uint32x16.StoreMasked", simdMaskedStore(ssa.OpStoreMasked32), sys.AMD64) + addF(simdPackage, "LoadMaskedUint64x2", simdMaskedLoad(ssa.OpLoadMasked64), sys.AMD64) + addF(simdPackage, "Uint64x2.StoreMasked", simdMaskedStore(ssa.OpStoreMasked64), sys.AMD64) + addF(simdPackage, "LoadMaskedUint64x4", simdMaskedLoad(ssa.OpLoadMasked64), sys.AMD64) + addF(simdPackage, "Uint64x4.StoreMasked", simdMaskedStore(ssa.OpStoreMasked64), sys.AMD64) + addF(simdPackage, "LoadMaskedUint64x8", simdMaskedLoad(ssa.OpLoadMasked64), sys.AMD64) + addF(simdPackage, "Uint64x8.StoreMasked", simdMaskedStore(ssa.OpStoreMasked64), sys.AMD64) + addF(simdPackage, "LoadMaskedMask8x64", simdMaskedLoad(ssa.OpLoadMasked8), sys.AMD64) + addF(simdPackage, "Mask8x64.StoreMasked", simdMaskedStore(ssa.OpStoreMasked8), sys.AMD64) + addF(simdPackage, "LoadMaskedMask16x32", simdMaskedLoad(ssa.OpLoadMasked16), sys.AMD64) + addF(simdPackage, "Mask16x32.StoreMasked", simdMaskedStore(ssa.OpStoreMasked16), sys.AMD64) + addF(simdPackage, "LoadMaskedMask32x16", simdMaskedLoad(ssa.OpLoadMasked32), sys.AMD64) + addF(simdPackage, "Mask32x16.StoreMasked", simdMaskedStore(ssa.OpStoreMasked32), sys.AMD64) + addF(simdPackage, "LoadMaskedMask64x8", simdMaskedLoad(ssa.OpLoadMasked64), sys.AMD64) + addF(simdPackage, "Mask64x8.StoreMasked", simdMaskedStore(ssa.OpStoreMasked64), sys.AMD64) + addF(simdPackage, "Mask8x16.ToInt8x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x16.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask8x16.And", opLen2(ssa.OpAndInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Mask8x16.Or", opLen2(ssa.OpOrInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Mask8x16FromBits", simdCvtVToMask(8, 16), sys.AMD64) + addF(simdPackage, "Mask8x16.ToBits", simdCvtMaskToV(8, 16), sys.AMD64) + addF(simdPackage, "Mask8x32.ToInt8x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x32.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask8x32.And", opLen2(ssa.OpAndInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Mask8x32.Or", opLen2(ssa.OpOrInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Mask8x32FromBits", simdCvtVToMask(8, 32), sys.AMD64) + addF(simdPackage, "Mask8x32.ToBits", simdCvtMaskToV(8, 32), sys.AMD64) + addF(simdPackage, "Mask8x64.ToInt8x64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int8x64.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask8x64.And", opLen2(ssa.OpAndInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Mask8x64.Or", opLen2(ssa.OpOrInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Mask8x64FromBits", simdCvtVToMask(8, 64), sys.AMD64) + addF(simdPackage, "Mask8x64.ToBits", simdCvtMaskToV(8, 64), sys.AMD64) + addF(simdPackage, "Mask16x8.ToInt16x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x8.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask16x8.And", opLen2(ssa.OpAndInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Mask16x8.Or", opLen2(ssa.OpOrInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Mask16x8FromBits", simdCvtVToMask(16, 8), sys.AMD64) + addF(simdPackage, "Mask16x8.ToBits", simdCvtMaskToV(16, 8), sys.AMD64) + addF(simdPackage, "Mask16x16.ToInt16x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x16.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask16x16.And", opLen2(ssa.OpAndInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Mask16x16.Or", opLen2(ssa.OpOrInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Mask16x16FromBits", simdCvtVToMask(16, 16), sys.AMD64) + addF(simdPackage, "Mask16x16.ToBits", simdCvtMaskToV(16, 16), sys.AMD64) + addF(simdPackage, "Mask16x32.ToInt16x32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int16x32.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask16x32.And", opLen2(ssa.OpAndInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Mask16x32.Or", opLen2(ssa.OpOrInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Mask16x32FromBits", simdCvtVToMask(16, 32), sys.AMD64) + addF(simdPackage, "Mask16x32.ToBits", simdCvtMaskToV(16, 32), sys.AMD64) + addF(simdPackage, "Mask32x4.ToInt32x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x4.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask32x4.And", opLen2(ssa.OpAndInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Mask32x4.Or", opLen2(ssa.OpOrInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Mask32x4FromBits", simdCvtVToMask(32, 4), sys.AMD64) + addF(simdPackage, "Mask32x4.ToBits", simdCvtMaskToV(32, 4), sys.AMD64) + addF(simdPackage, "Mask32x8.ToInt32x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x8.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask32x8.And", opLen2(ssa.OpAndInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Mask32x8.Or", opLen2(ssa.OpOrInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Mask32x8FromBits", simdCvtVToMask(32, 8), sys.AMD64) + addF(simdPackage, "Mask32x8.ToBits", simdCvtMaskToV(32, 8), sys.AMD64) + addF(simdPackage, "Mask32x16.ToInt32x16", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int32x16.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask32x16.And", opLen2(ssa.OpAndInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Mask32x16.Or", opLen2(ssa.OpOrInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Mask32x16FromBits", simdCvtVToMask(32, 16), sys.AMD64) + addF(simdPackage, "Mask32x16.ToBits", simdCvtMaskToV(32, 16), sys.AMD64) + addF(simdPackage, "Mask64x2.ToInt64x2", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x2.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask64x2.And", opLen2(ssa.OpAndInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Mask64x2.Or", opLen2(ssa.OpOrInt32x4, types.TypeVec128), sys.AMD64) + addF(simdPackage, "Mask64x2FromBits", simdCvtVToMask(64, 2), sys.AMD64) + addF(simdPackage, "Mask64x2.ToBits", simdCvtMaskToV(64, 2), sys.AMD64) + addF(simdPackage, "Mask64x4.ToInt64x4", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x4.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask64x4.And", opLen2(ssa.OpAndInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Mask64x4.Or", opLen2(ssa.OpOrInt32x8, types.TypeVec256), sys.AMD64) + addF(simdPackage, "Mask64x4FromBits", simdCvtVToMask(64, 4), sys.AMD64) + addF(simdPackage, "Mask64x4.ToBits", simdCvtMaskToV(64, 4), sys.AMD64) + addF(simdPackage, "Mask64x8.ToInt64x8", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Int64x8.asMask", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return args[0] }, sys.AMD64) + addF(simdPackage, "Mask64x8.And", opLen2(ssa.OpAndInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Mask64x8.Or", opLen2(ssa.OpOrInt32x16, types.TypeVec512), sys.AMD64) + addF(simdPackage, "Mask64x8FromBits", simdCvtVToMask(64, 8), sys.AMD64) + addF(simdPackage, "Mask64x8.ToBits", simdCvtMaskToV(64, 8), sys.AMD64) +} diff --git a/go/src/cmd/compile/internal/ssagen/ssa.go b/go/src/cmd/compile/internal/ssagen/ssa.go new file mode 100644 index 0000000000000000000000000000000000000000..3da43e715e7df6116c3b0df898b6283b8f2bdefa --- /dev/null +++ b/go/src/cmd/compile/internal/ssagen/ssa.go @@ -0,0 +1,8115 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ssagen + +import ( + "bufio" + "bytes" + "cmp" + "fmt" + "go/constant" + "html" + "internal/buildcfg" + "internal/goexperiment" + "internal/runtime/gc" + "os" + "path/filepath" + "slices" + "strings" + + "cmd/compile/internal/abi" + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/liveness" + "cmd/compile/internal/objw" + "cmd/compile/internal/reflectdata" + "cmd/compile/internal/rttype" + "cmd/compile/internal/ssa" + "cmd/compile/internal/staticdata" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" + "cmd/internal/sys" + + rtabi "internal/abi" +) + +var ssaConfig *ssa.Config +var ssaCaches []ssa.Cache + +var ssaDump string // early copy of $GOSSAFUNC; the func name to dump output for +var ssaDir string // optional destination for ssa dump file +var ssaDumpStdout bool // whether to dump to stdout +var ssaDumpCFG string // generate CFGs for these phases +const ssaDumpFile = "ssa.html" + +// ssaDumpInlined holds all inlined functions when ssaDump contains a function name. +var ssaDumpInlined []*ir.Func + +// Maximum size we will aggregate heap allocations of scalar locals. +// Almost certainly can't hurt to be as big as the tiny allocator. +// Might help to be a bit bigger. +const maxAggregatedHeapAllocation = 16 + +func DumpInline(fn *ir.Func) { + if ssaDump != "" && ssaDump == ir.FuncName(fn) { + ssaDumpInlined = append(ssaDumpInlined, fn) + } +} + +func InitEnv() { + ssaDump = os.Getenv("GOSSAFUNC") + ssaDir = os.Getenv("GOSSADIR") + if ssaDump != "" { + if strings.HasSuffix(ssaDump, "+") { + ssaDump = ssaDump[:len(ssaDump)-1] + ssaDumpStdout = true + } + spl := strings.Split(ssaDump, ":") + if len(spl) > 1 { + ssaDump = spl[0] + ssaDumpCFG = spl[1] + } + } +} + +func InitConfig() { + types_ := ssa.NewTypes() + + if Arch.SoftFloat { + softfloatInit() + } + + // Generate a few pointer types that are uncommon in the frontend but common in the backend. + // Caching is disabled in the backend, so generating these here avoids allocations. + _ = types.NewPtr(types.Types[types.TINTER]) // *interface{} + _ = types.NewPtr(types.NewPtr(types.Types[types.TSTRING])) // **string + _ = types.NewPtr(types.NewSlice(types.Types[types.TINTER])) // *[]interface{} + _ = types.NewPtr(types.NewPtr(types.ByteType)) // **byte + _ = types.NewPtr(types.NewSlice(types.ByteType)) // *[]byte + _ = types.NewPtr(types.NewSlice(types.Types[types.TSTRING])) // *[]string + _ = types.NewPtr(types.NewPtr(types.NewPtr(types.Types[types.TUINT8]))) // ***uint8 + _ = types.NewPtr(types.Types[types.TINT16]) // *int16 + _ = types.NewPtr(types.Types[types.TINT64]) // *int64 + _ = types.NewPtr(types.ErrorType) // *error + _ = types.NewPtr(reflectdata.MapType()) // *internal/runtime/maps.Map + _ = types.NewPtr(deferstruct()) // *runtime._defer + types.NewPtrCacheEnabled = false + ssaConfig = ssa.NewConfig(base.Ctxt.Arch.Name, *types_, base.Ctxt, base.Flag.N == 0, Arch.SoftFloat) + ssaConfig.Race = base.Flag.Race + ssaCaches = make([]ssa.Cache, base.Flag.LowerC) + + // Set up some runtime functions we'll need to call. + ir.Syms.AssertE2I = typecheck.LookupRuntimeFunc("assertE2I") + ir.Syms.AssertE2I2 = typecheck.LookupRuntimeFunc("assertE2I2") + ir.Syms.CgoCheckMemmove = typecheck.LookupRuntimeFunc("cgoCheckMemmove") + ir.Syms.CgoCheckPtrWrite = typecheck.LookupRuntimeFunc("cgoCheckPtrWrite") + ir.Syms.CheckPtrAlignment = typecheck.LookupRuntimeFunc("checkptrAlignment") + ir.Syms.Deferproc = typecheck.LookupRuntimeFunc("deferproc") + ir.Syms.Deferprocat = typecheck.LookupRuntimeFunc("deferprocat") + ir.Syms.DeferprocStack = typecheck.LookupRuntimeFunc("deferprocStack") + ir.Syms.Deferreturn = typecheck.LookupRuntimeFunc("deferreturn") + ir.Syms.Duffcopy = typecheck.LookupRuntimeFunc("duffcopy") + ir.Syms.Duffzero = typecheck.LookupRuntimeFunc("duffzero") + ir.Syms.GCWriteBarrier[0] = typecheck.LookupRuntimeFunc("gcWriteBarrier1") + ir.Syms.GCWriteBarrier[1] = typecheck.LookupRuntimeFunc("gcWriteBarrier2") + ir.Syms.GCWriteBarrier[2] = typecheck.LookupRuntimeFunc("gcWriteBarrier3") + ir.Syms.GCWriteBarrier[3] = typecheck.LookupRuntimeFunc("gcWriteBarrier4") + ir.Syms.GCWriteBarrier[4] = typecheck.LookupRuntimeFunc("gcWriteBarrier5") + ir.Syms.GCWriteBarrier[5] = typecheck.LookupRuntimeFunc("gcWriteBarrier6") + ir.Syms.GCWriteBarrier[6] = typecheck.LookupRuntimeFunc("gcWriteBarrier7") + ir.Syms.GCWriteBarrier[7] = typecheck.LookupRuntimeFunc("gcWriteBarrier8") + ir.Syms.Goschedguarded = typecheck.LookupRuntimeFunc("goschedguarded") + ir.Syms.Growslice = typecheck.LookupRuntimeFunc("growslice") + ir.Syms.GrowsliceBuf = typecheck.LookupRuntimeFunc("growsliceBuf") + ir.Syms.GrowsliceBufNoAlias = typecheck.LookupRuntimeFunc("growsliceBufNoAlias") + ir.Syms.GrowsliceNoAlias = typecheck.LookupRuntimeFunc("growsliceNoAlias") + ir.Syms.MoveSlice = typecheck.LookupRuntimeFunc("moveSlice") + ir.Syms.MoveSliceNoScan = typecheck.LookupRuntimeFunc("moveSliceNoScan") + ir.Syms.MoveSliceNoCap = typecheck.LookupRuntimeFunc("moveSliceNoCap") + ir.Syms.MoveSliceNoCapNoScan = typecheck.LookupRuntimeFunc("moveSliceNoCapNoScan") + ir.Syms.InterfaceSwitch = typecheck.LookupRuntimeFunc("interfaceSwitch") + for i := 1; i < len(ir.Syms.MallocGCSmallNoScan); i++ { + ir.Syms.MallocGCSmallNoScan[i] = typecheck.LookupRuntimeFunc(fmt.Sprintf("mallocgcSmallNoScanSC%d", i)) + } + for i := 1; i < len(ir.Syms.MallocGCSmallScanNoHeader); i++ { + ir.Syms.MallocGCSmallScanNoHeader[i] = typecheck.LookupRuntimeFunc(fmt.Sprintf("mallocgcSmallScanNoHeaderSC%d", i)) + } + for i := 1; i < len(ir.Syms.MallocGCTiny); i++ { + ir.Syms.MallocGCTiny[i] = typecheck.LookupRuntimeFunc(fmt.Sprintf("mallocgcTinySize%d", i)) + } + ir.Syms.MallocGC = typecheck.LookupRuntimeFunc("mallocgc") + ir.Syms.Memmove = typecheck.LookupRuntimeFunc("memmove") + ir.Syms.Memequal = typecheck.LookupRuntimeFunc("memequal") + ir.Syms.Msanread = typecheck.LookupRuntimeFunc("msanread") + ir.Syms.Msanwrite = typecheck.LookupRuntimeFunc("msanwrite") + ir.Syms.Msanmove = typecheck.LookupRuntimeFunc("msanmove") + ir.Syms.Asanread = typecheck.LookupRuntimeFunc("asanread") + ir.Syms.Asanwrite = typecheck.LookupRuntimeFunc("asanwrite") + ir.Syms.Newobject = typecheck.LookupRuntimeFunc("newobject") + ir.Syms.Newproc = typecheck.LookupRuntimeFunc("newproc") + ir.Syms.PanicBounds = typecheck.LookupRuntimeFunc("panicBounds") + ir.Syms.PanicExtend = typecheck.LookupRuntimeFunc("panicExtend") + ir.Syms.Panicdivide = typecheck.LookupRuntimeFunc("panicdivide") + ir.Syms.PanicdottypeE = typecheck.LookupRuntimeFunc("panicdottypeE") + ir.Syms.PanicdottypeI = typecheck.LookupRuntimeFunc("panicdottypeI") + ir.Syms.Panicnildottype = typecheck.LookupRuntimeFunc("panicnildottype") + ir.Syms.Panicoverflow = typecheck.LookupRuntimeFunc("panicoverflow") + ir.Syms.Panicshift = typecheck.LookupRuntimeFunc("panicshift") + ir.Syms.PanicSimdImm = typecheck.LookupRuntimeFunc("panicSimdImm") + ir.Syms.Racefuncenter = typecheck.LookupRuntimeFunc("racefuncenter") + ir.Syms.Racefuncexit = typecheck.LookupRuntimeFunc("racefuncexit") + ir.Syms.Raceread = typecheck.LookupRuntimeFunc("raceread") + ir.Syms.Racereadrange = typecheck.LookupRuntimeFunc("racereadrange") + ir.Syms.Racewrite = typecheck.LookupRuntimeFunc("racewrite") + ir.Syms.Racewriterange = typecheck.LookupRuntimeFunc("racewriterange") + ir.Syms.TypeAssert = typecheck.LookupRuntimeFunc("typeAssert") + ir.Syms.WBZero = typecheck.LookupRuntimeFunc("wbZero") + ir.Syms.WBMove = typecheck.LookupRuntimeFunc("wbMove") + ir.Syms.X86HasAVX = typecheck.LookupRuntimeVar("x86HasAVX") // bool + ir.Syms.X86HasFMA = typecheck.LookupRuntimeVar("x86HasFMA") // bool + ir.Syms.X86HasPOPCNT = typecheck.LookupRuntimeVar("x86HasPOPCNT") // bool + ir.Syms.X86HasSSE41 = typecheck.LookupRuntimeVar("x86HasSSE41") // bool + ir.Syms.ARMHasVFPv4 = typecheck.LookupRuntimeVar("armHasVFPv4") // bool + ir.Syms.ARM64HasATOMICS = typecheck.LookupRuntimeVar("arm64HasATOMICS") // bool + ir.Syms.Loong64HasLAMCAS = typecheck.LookupRuntimeVar("loong64HasLAMCAS") // bool + ir.Syms.Loong64HasLAM_BH = typecheck.LookupRuntimeVar("loong64HasLAM_BH") // bool + ir.Syms.Loong64HasLSX = typecheck.LookupRuntimeVar("loong64HasLSX") // bool + ir.Syms.RISCV64HasZbb = typecheck.LookupRuntimeVar("riscv64HasZbb") // bool + ir.Syms.Staticuint64s = typecheck.LookupRuntimeVar("staticuint64s") + ir.Syms.Typedmemmove = typecheck.LookupRuntimeFunc("typedmemmove") + ir.Syms.Udiv = typecheck.LookupRuntimeVar("udiv") // asm func with special ABI + ir.Syms.WriteBarrier = typecheck.LookupRuntimeVar("writeBarrier") // struct { bool; ... } + ir.Syms.Zerobase = typecheck.LookupRuntimeVar("zerobase") + ir.Syms.ZeroVal = typecheck.LookupRuntimeVar("zeroVal") + + if Arch.LinkArch.Family == sys.Wasm { + BoundsCheckFunc[ssa.BoundsIndex] = typecheck.LookupRuntimeFunc("goPanicIndex") + BoundsCheckFunc[ssa.BoundsIndexU] = typecheck.LookupRuntimeFunc("goPanicIndexU") + BoundsCheckFunc[ssa.BoundsSliceAlen] = typecheck.LookupRuntimeFunc("goPanicSliceAlen") + BoundsCheckFunc[ssa.BoundsSliceAlenU] = typecheck.LookupRuntimeFunc("goPanicSliceAlenU") + BoundsCheckFunc[ssa.BoundsSliceAcap] = typecheck.LookupRuntimeFunc("goPanicSliceAcap") + BoundsCheckFunc[ssa.BoundsSliceAcapU] = typecheck.LookupRuntimeFunc("goPanicSliceAcapU") + BoundsCheckFunc[ssa.BoundsSliceB] = typecheck.LookupRuntimeFunc("goPanicSliceB") + BoundsCheckFunc[ssa.BoundsSliceBU] = typecheck.LookupRuntimeFunc("goPanicSliceBU") + BoundsCheckFunc[ssa.BoundsSlice3Alen] = typecheck.LookupRuntimeFunc("goPanicSlice3Alen") + BoundsCheckFunc[ssa.BoundsSlice3AlenU] = typecheck.LookupRuntimeFunc("goPanicSlice3AlenU") + BoundsCheckFunc[ssa.BoundsSlice3Acap] = typecheck.LookupRuntimeFunc("goPanicSlice3Acap") + BoundsCheckFunc[ssa.BoundsSlice3AcapU] = typecheck.LookupRuntimeFunc("goPanicSlice3AcapU") + BoundsCheckFunc[ssa.BoundsSlice3B] = typecheck.LookupRuntimeFunc("goPanicSlice3B") + BoundsCheckFunc[ssa.BoundsSlice3BU] = typecheck.LookupRuntimeFunc("goPanicSlice3BU") + BoundsCheckFunc[ssa.BoundsSlice3C] = typecheck.LookupRuntimeFunc("goPanicSlice3C") + BoundsCheckFunc[ssa.BoundsSlice3CU] = typecheck.LookupRuntimeFunc("goPanicSlice3CU") + BoundsCheckFunc[ssa.BoundsConvert] = typecheck.LookupRuntimeFunc("goPanicSliceConvert") + } + + // Wasm (all asm funcs with special ABIs) + ir.Syms.WasmDiv = typecheck.LookupRuntimeVar("wasmDiv") + ir.Syms.WasmTruncS = typecheck.LookupRuntimeVar("wasmTruncS") + ir.Syms.WasmTruncU = typecheck.LookupRuntimeVar("wasmTruncU") + ir.Syms.SigPanic = typecheck.LookupRuntimeFunc("sigpanic") +} + +func InitTables() { + initIntrinsics(nil) +} + +// AbiForBodylessFuncStackMap returns the ABI for a bodyless function's stack map. +// This is not necessarily the ABI used to call it. +// Currently (1.17 dev) such a stack map is always ABI0; +// any ABI wrapper that is present is nosplit, hence a precise +// stack map is not needed there (the parameters survive only long +// enough to call the wrapped assembly function). +// This always returns a freshly copied ABI. +func AbiForBodylessFuncStackMap(fn *ir.Func) *abi.ABIConfig { + return ssaConfig.ABI0.Copy() // No idea what races will result, be safe +} + +// abiForFunc implements ABI policy for a function, but does not return a copy of the ABI. +// Passing a nil function returns the default ABI based on experiment configuration. +func abiForFunc(fn *ir.Func, abi0, abi1 *abi.ABIConfig) *abi.ABIConfig { + if buildcfg.Experiment.RegabiArgs { + // Select the ABI based on the function's defining ABI. + if fn == nil { + return abi1 + } + switch fn.ABI { + case obj.ABI0: + return abi0 + case obj.ABIInternal: + // TODO(austin): Clean up the nomenclature here. + // It's not clear that "abi1" is ABIInternal. + return abi1 + } + base.Fatalf("function %v has unknown ABI %v", fn, fn.ABI) + panic("not reachable") + } + + a := abi0 + if fn != nil { + if fn.Pragma&ir.RegisterParams != 0 { // TODO(register args) remove after register abi is working + a = abi1 + } + } + return a +} + +// emitOpenDeferInfo emits FUNCDATA information about the defers in a function +// that is using open-coded defers. This funcdata is used to determine the active +// defers in a function and execute those defers during panic processing. +// +// The funcdata is all encoded in varints (since values will almost always be less than +// 128, but stack offsets could potentially be up to 2Gbyte). All "locations" (offsets) +// for stack variables are specified as the number of bytes below varp (pointer to the +// top of the local variables) for their starting address. The format is: +// +// - Offset of the deferBits variable +// - Offset of the first closure slot (the rest are laid out consecutively). +func (s *state) emitOpenDeferInfo() { + firstOffset := s.openDefers[0].closureNode.FrameOffset() + + // Verify that cmpstackvarlt laid out the slots in order. + for i, r := range s.openDefers { + have := r.closureNode.FrameOffset() + want := firstOffset + int64(i)*int64(types.PtrSize) + if have != want { + base.FatalfAt(s.curfn.Pos(), "unexpected frame offset for open-coded defer slot #%v: have %v, want %v", i, have, want) + } + } + + x := base.Ctxt.Lookup(s.curfn.LSym.Name + ".opendefer") + x.Set(obj.AttrContentAddressable, true) + s.curfn.LSym.Func().OpenCodedDeferInfo = x + + off := 0 + off = objw.Uvarint(x, off, uint64(-s.deferBitsTemp.FrameOffset())) + off = objw.Uvarint(x, off, uint64(-firstOffset)) +} + +// buildssa builds an SSA function for fn. +// worker indicates which of the backend workers is doing the processing. +func buildssa(fn *ir.Func, worker int, isPgoHot bool) *ssa.Func { + name := ir.FuncName(fn) + + abiSelf := abiForFunc(fn, ssaConfig.ABI0, ssaConfig.ABI1) + + printssa := false + // match either a simple name e.g. "(*Reader).Reset", package.name e.g. "compress/gzip.(*Reader).Reset", or subpackage name "gzip.(*Reader).Reset" + // optionally allows an ABI suffix specification in the GOSSAHASH, e.g. "(*Reader).Reset<0>" etc + if strings.Contains(ssaDump, name) { // in all the cases the function name is entirely contained within the GOSSAFUNC string. + nameOptABI := name + if l := len(ssaDump); l > 1 && ssaDump[l-2] == ',' { // ABI specification + nameOptABI = ssa.FuncNameABI(name, abiSelf.Which()) + } else if strings.HasSuffix(ssaDump, ">") { // if they use the linker syntax instead.... + l := len(ssaDump) + if l >= 3 && ssaDump[l-3] == '<' { + nameOptABI = ssa.FuncNameABI(name, abiSelf.Which()) + ssaDump = ssaDump[:l-3] + "," + ssaDump[l-2:l-1] + } + } + pkgDotName := base.Ctxt.Pkgpath + "." + nameOptABI + printssa = nameOptABI == ssaDump || // "(*Reader).Reset" + pkgDotName == ssaDump || // "compress/gzip.(*Reader).Reset" + strings.HasSuffix(pkgDotName, ssaDump) && strings.HasSuffix(pkgDotName, "/"+ssaDump) // "gzip.(*Reader).Reset" + } + + var astBuf *bytes.Buffer + if printssa { + astBuf = &bytes.Buffer{} + ir.FDumpList(astBuf, "buildssa-body", fn.Body) + if ssaDumpStdout { + fmt.Println("generating SSA for", name) + fmt.Print(astBuf.String()) + } + } + + var s state + s.pushLine(fn.Pos()) + defer s.popLine() + + s.hasdefer = fn.HasDefer() + if fn.Pragma&ir.CgoUnsafeArgs != 0 { + s.cgoUnsafeArgs = true + } + s.checkPtrEnabled = ir.ShouldCheckPtr(fn, 1) + + if base.Flag.Cfg.Instrumenting && fn.Pragma&ir.Norace == 0 && !fn.Linksym().ABIWrapper() { + if !base.Flag.Race || !objabi.LookupPkgSpecial(fn.Sym().Pkg.Path).NoRaceFunc { + s.instrumentMemory = true + if base.Flag.Race { + s.instrumentEnterExit = true + } + } + } + + fe := ssafn{ + curfn: fn, + log: printssa && ssaDumpStdout, + } + s.curfn = fn + + cache := &ssaCaches[worker] + cache.Reset() + + s.f = ssaConfig.NewFunc(&fe, cache) + s.config = ssaConfig + s.f.Type = fn.Type() + s.f.Name = name + s.f.PrintOrHtmlSSA = printssa + if fn.Pragma&ir.Nosplit != 0 { + s.f.NoSplit = true + } + s.f.ABI0 = ssaConfig.ABI0 + s.f.ABI1 = ssaConfig.ABI1 + s.f.ABIDefault = abiForFunc(nil, ssaConfig.ABI0, ssaConfig.ABI1) + s.f.ABISelf = abiSelf + + s.panics = map[funcLine]*ssa.Block{} + s.softFloat = s.config.SoftFloat + + // Allocate starting block + s.f.Entry = s.f.NewBlock(ssa.BlockPlain) + s.f.Entry.Pos = fn.Pos() + s.f.IsPgoHot = isPgoHot + + if printssa { + ssaDF := ssaDumpFile + if ssaDir != "" { + ssaDF = filepath.Join(ssaDir, base.Ctxt.Pkgpath+"."+s.f.NameABI()+".html") + ssaD := filepath.Dir(ssaDF) + os.MkdirAll(ssaD, 0755) + } + s.f.HTMLWriter = ssa.NewHTMLWriter(ssaDF, s.f, ssaDumpCFG) + // TODO: generate and print a mapping from nodes to values and blocks + dumpSourcesColumn(s.f.HTMLWriter, fn) + s.f.HTMLWriter.WriteAST("AST", astBuf) + } + + // Allocate starting values + s.labels = map[string]*ssaLabel{} + s.fwdVars = map[ir.Node]*ssa.Value{} + s.startmem = s.entryNewValue0(ssa.OpInitMem, types.TypeMem) + + s.hasOpenDefers = base.Flag.N == 0 && s.hasdefer && !s.curfn.OpenCodedDeferDisallowed() + switch { + case base.Debug.NoOpenDefer != 0: + s.hasOpenDefers = false + case s.hasOpenDefers && (base.Ctxt.Flag_shared || base.Ctxt.Flag_dynlink) && base.Ctxt.Arch.Name == "386": + // Don't support open-coded defers for 386 ONLY when using shared + // libraries, because there is extra code (added by rewriteToUseGot()) + // preceding the deferreturn/ret code that we don't track correctly. + // + // TODO this restriction can be removed given adjusted offset in computeDeferReturn in cmd/link/internal/ld/pcln.go + s.hasOpenDefers = false + } + if s.hasOpenDefers && s.instrumentEnterExit { + // Skip doing open defers if we need to instrument function + // returns for the race detector, since we will not generate that + // code in the case of the extra deferreturn/ret segment. + s.hasOpenDefers = false + } + if s.hasOpenDefers { + // Similarly, skip if there are any heap-allocated result + // parameters that need to be copied back to their stack slots. + for _, f := range s.curfn.Type().Results() { + if !f.Nname.(*ir.Name).OnStack() { + s.hasOpenDefers = false + break + } + } + } + if s.hasOpenDefers && + s.curfn.NumReturns*s.curfn.NumDefers > 15 { + // Since we are generating defer calls at every exit for + // open-coded defers, skip doing open-coded defers if there are + // too many returns (especially if there are multiple defers). + // Open-coded defers are most important for improving performance + // for smaller functions (which don't have many returns). + s.hasOpenDefers = false + } + + s.sp = s.entryNewValue0(ssa.OpSP, types.Types[types.TUINTPTR]) // TODO: use generic pointer type (unsafe.Pointer?) instead + s.sb = s.entryNewValue0(ssa.OpSB, types.Types[types.TUINTPTR]) + + s.startBlock(s.f.Entry) + s.vars[memVar] = s.startmem + if s.hasOpenDefers { + // Create the deferBits variable and stack slot. deferBits is a + // bitmask showing which of the open-coded defers in this function + // have been activated. + deferBitsTemp := typecheck.TempAt(src.NoXPos, s.curfn, types.Types[types.TUINT8]) + deferBitsTemp.SetAddrtaken(true) + s.deferBitsTemp = deferBitsTemp + // For this value, AuxInt is initialized to zero by default + startDeferBits := s.entryNewValue0(ssa.OpConst8, types.Types[types.TUINT8]) + s.vars[deferBitsVar] = startDeferBits + s.deferBitsAddr = s.addr(deferBitsTemp) + s.store(types.Types[types.TUINT8], s.deferBitsAddr, startDeferBits) + // Make sure that the deferBits stack slot is kept alive (for use + // by panics) and stores to deferBits are not eliminated, even if + // all checking code on deferBits in the function exit can be + // eliminated, because the defer statements were all + // unconditional. + s.vars[memVar] = s.newValue1Apos(ssa.OpVarLive, types.TypeMem, deferBitsTemp, s.mem(), false) + } + + var params *abi.ABIParamResultInfo + params = s.f.ABISelf.ABIAnalyze(fn.Type(), true) + + // The backend's stackframe pass prunes away entries from the fn's + // Dcl list, including PARAMOUT nodes that correspond to output + // params passed in registers. Walk the Dcl list and capture these + // nodes to a side list, so that we'll have them available during + // DWARF-gen later on. See issue 48573 for more details. + var debugInfo ssa.FuncDebug + for _, n := range fn.Dcl { + if n.Class == ir.PPARAMOUT && n.IsOutputParamInRegisters() { + debugInfo.RegOutputParams = append(debugInfo.RegOutputParams, n) + } + } + fn.DebugInfo = &debugInfo + + // Generate addresses of local declarations + s.decladdrs = map[*ir.Name]*ssa.Value{} + for _, n := range fn.Dcl { + switch n.Class { + case ir.PPARAM: + // Be aware that blank and unnamed input parameters will not appear here, but do appear in the type + s.decladdrs[n] = s.entryNewValue2A(ssa.OpLocalAddr, types.NewPtr(n.Type()), n, s.sp, s.startmem) + case ir.PPARAMOUT: + s.decladdrs[n] = s.entryNewValue2A(ssa.OpLocalAddr, types.NewPtr(n.Type()), n, s.sp, s.startmem) + case ir.PAUTO: + // processed at each use, to prevent Addr coming + // before the decl. + default: + s.Fatalf("local variable with class %v unimplemented", n.Class) + } + } + + s.f.OwnAux = ssa.OwnAuxCall(fn.LSym, params) + + // Populate SSAable arguments. + for _, n := range fn.Dcl { + if n.Class == ir.PPARAM { + if s.canSSA(n) { + v := s.newValue0A(ssa.OpArg, n.Type(), n) + s.vars[n] = v + s.addNamedValue(n, v) // This helps with debugging information, not needed for compilation itself. + } else { // address was taken AND/OR too large for SSA + paramAssignment := ssa.ParamAssignmentForArgName(s.f, n) + if len(paramAssignment.Registers) > 0 { + if ssa.CanSSA(n.Type()) { // SSA-able type, so address was taken -- receive value in OpArg, DO NOT bind to var, store immediately to memory. + v := s.newValue0A(ssa.OpArg, n.Type(), n) + s.store(n.Type(), s.decladdrs[n], v) + } else { // Too big for SSA. + // Brute force, and early, do a bunch of stores from registers + // Note that expand calls knows about this and doesn't trouble itself with larger-than-SSA-able Args in registers. + s.storeParameterRegsToStack(s.f.ABISelf, paramAssignment, n, s.decladdrs[n], false) + } + } + } + } + } + + // Populate closure variables. + if fn.Needctxt() { + clo := s.entryNewValue0(ssa.OpGetClosurePtr, s.f.Config.Types.BytePtr) + if fn.RangeParent != nil && base.Flag.N != 0 { + // For a range body closure, keep its closure pointer live on the + // stack with a special name, so the debugger can look for it and + // find the parent frame. + sym := &types.Sym{Name: ".closureptr", Pkg: types.LocalPkg} + cloSlot := s.curfn.NewLocal(src.NoXPos, sym, s.f.Config.Types.BytePtr) + cloSlot.SetUsed(true) + cloSlot.SetEsc(ir.EscNever) + cloSlot.SetAddrtaken(true) + s.f.CloSlot = cloSlot + s.vars[memVar] = s.newValue1Apos(ssa.OpVarDef, types.TypeMem, cloSlot, s.mem(), false) + addr := s.addr(cloSlot) + s.store(s.f.Config.Types.BytePtr, addr, clo) + // Keep it from being dead-store eliminated. + s.vars[memVar] = s.newValue1Apos(ssa.OpVarLive, types.TypeMem, cloSlot, s.mem(), false) + } + csiter := typecheck.NewClosureStructIter(fn.ClosureVars) + for { + n, typ, offset := csiter.Next() + if n == nil { + break + } + + ptr := s.newValue1I(ssa.OpOffPtr, types.NewPtr(typ), offset, clo) + + // If n is a small variable captured by value, promote + // it to PAUTO so it can be converted to SSA. + // + // Note: While we never capture a variable by value if + // the user took its address, we may have generated + // runtime calls that did (#43701). Since we don't + // convert Addrtaken variables to SSA anyway, no point + // in promoting them either. + if n.Byval() && !n.Addrtaken() && ssa.CanSSA(n.Type()) { + n.Class = ir.PAUTO + fn.Dcl = append(fn.Dcl, n) + s.assign(n, s.load(n.Type(), ptr), false, 0) + continue + } + + if !n.Byval() { + ptr = s.load(typ, ptr) + } + s.setHeapaddr(fn.Pos(), n, ptr) + } + } + + // Convert the AST-based IR to the SSA-based IR + if s.instrumentEnterExit { + s.rtcall(ir.Syms.Racefuncenter, true, nil, s.newValue0(ssa.OpGetCallerPC, types.Types[types.TUINTPTR])) + } + s.zeroResults() + s.paramsToHeap() + s.stmtList(fn.Body) + + // fallthrough to exit + if s.curBlock != nil { + s.pushLine(fn.Endlineno) + s.exit() + s.popLine() + } + + for _, b := range s.f.Blocks { + if b.Pos != src.NoXPos { + s.updateUnsetPredPos(b) + } + } + + s.f.HTMLWriter.WritePhase("before insert phis", "before insert phis") + + s.insertPhis() + + // Main call to ssa package to compile function + ssa.Compile(s.f) + + fe.AllocFrame(s.f) + + if len(s.openDefers) != 0 { + s.emitOpenDeferInfo() + } + + // Record incoming parameter spill information for morestack calls emitted in the assembler. + // This is done here, using all the parameters (used, partially used, and unused) because + // it mimics the behavior of the former ABI (everything stored) and because it's not 100% + // clear if naming conventions are respected in autogenerated code. + // TODO figure out exactly what's unused, don't spill it. Make liveness fine-grained, also. + for _, p := range params.InParams() { + typs, offs := p.RegisterTypesAndOffsets() + if len(offs) < len(typs) { + s.Fatalf("len(offs)=%d < len(typs)=%d, params=\n%s", len(offs), len(typs), params) + } + for i, t := range typs { + o := offs[i] // offset within parameter + fo := p.FrameOffset(params) // offset of parameter in frame + reg := ssa.ObjRegForAbiReg(p.Registers[i], s.f.Config) + s.f.RegArgs = append(s.f.RegArgs, ssa.Spill{Reg: reg, Offset: fo + o, Type: t}) + } + } + + return s.f +} + +func (s *state) storeParameterRegsToStack(abi *abi.ABIConfig, paramAssignment *abi.ABIParamAssignment, n *ir.Name, addr *ssa.Value, pointersOnly bool) { + typs, offs := paramAssignment.RegisterTypesAndOffsets() + for i, t := range typs { + if pointersOnly && !t.IsPtrShaped() { + continue + } + r := paramAssignment.Registers[i] + o := offs[i] + op, reg := ssa.ArgOpAndRegisterFor(r, abi) + aux := &ssa.AuxNameOffset{Name: n, Offset: o} + v := s.newValue0I(op, t, reg) + v.Aux = aux + p := s.newValue1I(ssa.OpOffPtr, types.NewPtr(t), o, addr) + s.store(t, p, v) + } +} + +// zeroResults zeros the return values at the start of the function. +// We need to do this very early in the function. Defer might stop a +// panic and show the return values as they exist at the time of +// panic. For precise stacks, the garbage collector assumes results +// are always live, so we need to zero them before any allocations, +// even allocations to move params/results to the heap. +func (s *state) zeroResults() { + for _, f := range s.curfn.Type().Results() { + n := f.Nname.(*ir.Name) + if !n.OnStack() { + // The local which points to the return value is the + // thing that needs zeroing. This is already handled + // by a Needzero annotation in plive.go:(*liveness).epilogue. + continue + } + // Zero the stack location containing f. + if typ := n.Type(); ssa.CanSSA(typ) { + s.assign(n, s.zeroVal(typ), false, 0) + } else { + if typ.HasPointers() || ssa.IsMergeCandidate(n) { + s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, n, s.mem()) + } + s.zero(n.Type(), s.decladdrs[n]) + } + } +} + +// paramsToHeap produces code to allocate memory for heap-escaped parameters +// and to copy non-result parameters' values from the stack. +func (s *state) paramsToHeap() { + do := func(params []*types.Field) { + for _, f := range params { + if f.Nname == nil { + continue // anonymous or blank parameter + } + n := f.Nname.(*ir.Name) + if ir.IsBlank(n) || n.OnStack() { + continue + } + s.newHeapaddr(n) + if n.Class == ir.PPARAM { + s.move(n.Type(), s.expr(n.Heapaddr), s.decladdrs[n]) + } + } + } + + typ := s.curfn.Type() + do(typ.Recvs()) + do(typ.Params()) + do(typ.Results()) +} + +// allocSizeAndAlign returns the size and alignment of t. +// Normally just t.Size() and t.Alignment(), but there +// is a special case to handle 64-bit atomics on 32-bit systems. +func allocSizeAndAlign(t *types.Type) (int64, int64) { + size, align := t.Size(), t.Alignment() + if types.PtrSize == 4 && align == 4 && size >= 8 { + // For 64-bit atomics on 32-bit systems. + size = types.RoundUp(size, 8) + align = 8 + } + return size, align +} +func allocSize(t *types.Type) int64 { + size, _ := allocSizeAndAlign(t) + return size +} +func allocAlign(t *types.Type) int64 { + _, align := allocSizeAndAlign(t) + return align +} + +// newHeapaddr allocates heap memory for n and sets its heap address. +func (s *state) newHeapaddr(n *ir.Name) { + size := allocSize(n.Type()) + if n.Type().HasPointers() || size >= maxAggregatedHeapAllocation || size == 0 { + s.setHeapaddr(n.Pos(), n, s.newObject(n.Type())) + return + } + + // Do we have room together with our pending allocations? + // If not, flush all the current ones. + var used int64 + for _, v := range s.pendingHeapAllocations { + used += allocSize(v.Type.Elem()) + } + if used+size > maxAggregatedHeapAllocation { + s.flushPendingHeapAllocations() + } + + var allocCall *ssa.Value // (SelectN [0] (call of runtime.newobject)) + if len(s.pendingHeapAllocations) == 0 { + // Make an allocation, but the type being allocated is just + // the first pending object. We will come back and update it + // later if needed. + allocCall = s.newObjectNonSpecialized(n.Type(), nil) + } else { + allocCall = s.pendingHeapAllocations[0].Args[0] + } + // v is an offset to the shared allocation. Offsets are dummy 0s for now. + v := s.newValue1I(ssa.OpOffPtr, n.Type().PtrTo(), 0, allocCall) + + // Add to list of pending allocations. + s.pendingHeapAllocations = append(s.pendingHeapAllocations, v) + + // Finally, record for posterity. + s.setHeapaddr(n.Pos(), n, v) +} + +func (s *state) flushPendingHeapAllocations() { + pending := s.pendingHeapAllocations + if len(pending) == 0 { + return // nothing to do + } + s.pendingHeapAllocations = nil // reset state + ptr := pending[0].Args[0] // The SelectN [0] op + call := ptr.Args[0] // The runtime.newobject call + + if len(pending) == 1 { + // Just a single object, do a standard allocation. + v := pending[0] + v.Op = ssa.OpCopy // instead of OffPtr [0] + return + } + + // Sort in decreasing alignment. + // This way we never have to worry about padding. + // (Stable not required; just cleaner to keep program order among equal alignments.) + slices.SortStableFunc(pending, func(x, y *ssa.Value) int { + return cmp.Compare(allocAlign(y.Type.Elem()), allocAlign(x.Type.Elem())) + }) + + // Figure out how much data we need allocate. + var size int64 + for _, v := range pending { + v.AuxInt = size // Adjust OffPtr to the right value while we are here. + size += allocSize(v.Type.Elem()) + } + align := allocAlign(pending[0].Type.Elem()) + size = types.RoundUp(size, align) + + // Convert newObject call to a mallocgc call. + args := []*ssa.Value{ + s.constInt(types.Types[types.TUINTPTR], size), + s.constNil(call.Args[0].Type), // a nil *runtime._type + s.constBool(true), // needZero TODO: false is ok? + call.Args[1], // memory + } + mallocSym := ir.Syms.MallocGC + if specialMallocSym := s.specializedMallocSym(size, false); specialMallocSym != nil { + mallocSym = specialMallocSym + } + call.Aux = ssa.StaticAuxCall(mallocSym, s.f.ABIDefault.ABIAnalyzeTypes( + []*types.Type{args[0].Type, args[1].Type, args[2].Type}, + []*types.Type{types.Types[types.TUNSAFEPTR]}, + )) + call.AuxInt = 4 * s.config.PtrSize // arg+results size, uintptr/ptr/bool/ptr + call.SetArgs4(args[0], args[1], args[2], args[3]) + // TODO: figure out how to pass alignment to runtime + + call.Type = types.NewTuple(types.Types[types.TUNSAFEPTR], types.TypeMem) + ptr.Type = types.Types[types.TUNSAFEPTR] +} + +func (s *state) specializedMallocSym(size int64, hasPointers bool) *obj.LSym { + if !s.sizeSpecializedMallocEnabled() { + return nil + } + ptrSize := s.config.PtrSize + ptrBits := ptrSize * 8 + minSizeForMallocHeader := ptrSize * ptrBits + heapBitsInSpan := size <= minSizeForMallocHeader + if !heapBitsInSpan { + return nil + } + divRoundUp := func(n, a uintptr) uintptr { return (n + a - 1) / a } + sizeClass := gc.SizeToSizeClass8[divRoundUp(uintptr(size), gc.SmallSizeDiv)] + if hasPointers { + return ir.Syms.MallocGCSmallScanNoHeader[sizeClass] + } + if size < gc.TinySize { + return ir.Syms.MallocGCTiny[size] + } + return ir.Syms.MallocGCSmallNoScan[sizeClass] +} + +func (s *state) sizeSpecializedMallocEnabled() bool { + if base.Flag.CompilingRuntime { + // The compiler forces the values of the asan, msan, and race flags to false if + // we're compiling the runtime, so we lose the information about whether we're + // building in asan, msan, or race mode. Because the specialized functions don't + // work in that mode, just turn if off in that case. + // TODO(matloob): Save the information about whether the flags were passed in + // originally so we can turn off size specialized malloc in that case instead + // using Instrumenting below. Then we can remove this condition. + return false + } + + return buildcfg.Experiment.SizeSpecializedMalloc && !base.Flag.Cfg.Instrumenting +} + +// setHeapaddr allocates a new PAUTO variable to store ptr (which must be non-nil) +// and then sets it as n's heap address. +func (s *state) setHeapaddr(pos src.XPos, n *ir.Name, ptr *ssa.Value) { + if !ptr.Type.IsPtr() || !types.Identical(n.Type(), ptr.Type.Elem()) { + base.FatalfAt(n.Pos(), "setHeapaddr %L with type %v", n, ptr.Type) + } + + // Declare variable to hold address. + sym := &types.Sym{Name: "&" + n.Sym().Name, Pkg: types.LocalPkg} + addr := s.curfn.NewLocal(pos, sym, types.NewPtr(n.Type())) + addr.SetUsed(true) + types.CalcSize(addr.Type()) + + if n.Class == ir.PPARAMOUT { + addr.SetIsOutputParamHeapAddr(true) + } + + n.Heapaddr = addr + s.assign(addr, ptr, false, 0) +} + +// newObject returns an SSA value denoting new(typ). +func (s *state) newObject(typ *types.Type) *ssa.Value { + if typ.Size() == 0 { + return s.newValue1A(ssa.OpAddr, types.NewPtr(typ), ir.Syms.Zerobase, s.sb) + } + rtype := s.reflectType(typ) + if specialMallocSym := s.specializedMallocSym(typ.Size(), typ.HasPointers()); specialMallocSym != nil { + return s.rtcall(specialMallocSym, true, []*types.Type{types.NewPtr(typ)}, + s.constInt(types.Types[types.TUINTPTR], typ.Size()), + rtype, + s.constBool(true), + )[0] + } + return s.rtcall(ir.Syms.Newobject, true, []*types.Type{types.NewPtr(typ)}, rtype)[0] +} + +// newObjectNonSpecialized returns an SSA value denoting new(typ). It does +// not produce size-specialized malloc functions. +func (s *state) newObjectNonSpecialized(typ *types.Type, rtype *ssa.Value) *ssa.Value { + if typ.Size() == 0 { + return s.newValue1A(ssa.OpAddr, types.NewPtr(typ), ir.Syms.Zerobase, s.sb) + } + if rtype == nil { + rtype = s.reflectType(typ) + } + return s.rtcall(ir.Syms.Newobject, true, []*types.Type{types.NewPtr(typ)}, rtype)[0] +} + +func (s *state) checkPtrAlignment(n *ir.ConvExpr, v *ssa.Value, count *ssa.Value) { + if !n.Type().IsPtr() { + s.Fatalf("expected pointer type: %v", n.Type()) + } + elem, rtypeExpr := n.Type().Elem(), n.ElemRType + if count != nil { + if !elem.IsArray() { + s.Fatalf("expected array type: %v", elem) + } + elem, rtypeExpr = elem.Elem(), n.ElemElemRType + } + size := elem.Size() + // Casting from larger type to smaller one is ok, so for smallest type, do nothing. + if elem.Alignment() == 1 && (size == 0 || size == 1 || count == nil) { + return + } + if count == nil { + count = s.constInt(types.Types[types.TUINTPTR], 1) + } + if count.Type.Size() != s.config.PtrSize { + s.Fatalf("expected count fit to a uintptr size, have: %d, want: %d", count.Type.Size(), s.config.PtrSize) + } + var rtype *ssa.Value + if rtypeExpr != nil { + rtype = s.expr(rtypeExpr) + } else { + rtype = s.reflectType(elem) + } + s.rtcall(ir.Syms.CheckPtrAlignment, true, nil, v, rtype, count) +} + +// reflectType returns an SSA value representing a pointer to typ's +// reflection type descriptor. +func (s *state) reflectType(typ *types.Type) *ssa.Value { + // TODO(mdempsky): Make this Fatalf under Unified IR; frontend needs + // to supply RType expressions. + lsym := reflectdata.TypeLinksym(typ) + return s.entryNewValue1A(ssa.OpAddr, types.NewPtr(types.Types[types.TUINT8]), lsym, s.sb) +} + +func dumpSourcesColumn(writer *ssa.HTMLWriter, fn *ir.Func) { + // Read sources of target function fn. + fname := base.Ctxt.PosTable.Pos(fn.Pos()).Filename() + targetFn, err := readFuncLines(fname, fn.Pos().Line(), fn.Endlineno.Line()) + if err != nil { + writer.Logf("cannot read sources for function %v: %v", fn, err) + } + + // Read sources of inlined functions. + var inlFns []*ssa.FuncLines + for _, fi := range ssaDumpInlined { + elno := fi.Endlineno + fname := base.Ctxt.PosTable.Pos(fi.Pos()).Filename() + fnLines, err := readFuncLines(fname, fi.Pos().Line(), elno.Line()) + if err != nil { + writer.Logf("cannot read sources for inlined function %v: %v", fi, err) + continue + } + inlFns = append(inlFns, fnLines) + } + + slices.SortFunc(inlFns, ssa.ByTopoCmp) + if targetFn != nil { + inlFns = append([]*ssa.FuncLines{targetFn}, inlFns...) + } + + writer.WriteSources("sources", inlFns) +} + +func readFuncLines(file string, start, end uint) (*ssa.FuncLines, error) { + f, err := os.Open(os.ExpandEnv(file)) + if err != nil { + return nil, err + } + defer f.Close() + var lines []string + ln := uint(1) + scanner := bufio.NewScanner(f) + for scanner.Scan() && ln <= end { + if ln >= start { + lines = append(lines, scanner.Text()) + } + ln++ + } + return &ssa.FuncLines{Filename: file, StartLineno: start, Lines: lines}, nil +} + +// updateUnsetPredPos propagates the earliest-value position information for b +// towards all of b's predecessors that need a position, and recurs on that +// predecessor if its position is updated. B should have a non-empty position. +func (s *state) updateUnsetPredPos(b *ssa.Block) { + if b.Pos == src.NoXPos { + s.Fatalf("Block %s should have a position", b) + } + bestPos := src.NoXPos + for _, e := range b.Preds { + p := e.Block() + if !p.LackingPos() { + continue + } + if bestPos == src.NoXPos { + bestPos = b.Pos + for _, v := range b.Values { + if v.LackingPos() { + continue + } + if v.Pos != src.NoXPos { + // Assume values are still in roughly textual order; + // TODO: could also seek minimum position? + bestPos = v.Pos + break + } + } + } + p.Pos = bestPos + s.updateUnsetPredPos(p) // We do not expect long chains of these, thus recursion is okay. + } +} + +// Information about each open-coded defer. +type openDeferInfo struct { + // The node representing the call of the defer + n *ir.CallExpr + // If defer call is closure call, the address of the argtmp where the + // closure is stored. + closure *ssa.Value + // The node representing the argtmp where the closure is stored - used for + // function, method, or interface call, to store a closure that panic + // processing can use for this defer. + closureNode *ir.Name +} + +type state struct { + // configuration (arch) information + config *ssa.Config + + // function we're building + f *ssa.Func + + // Node for function + curfn *ir.Func + + // labels in f + labels map[string]*ssaLabel + + // unlabeled break and continue statement tracking + breakTo *ssa.Block // current target for plain break statement + continueTo *ssa.Block // current target for plain continue statement + + // current location where we're interpreting the AST + curBlock *ssa.Block + + // variable assignments in the current block (map from variable symbol to ssa value) + // *Node is the unique identifier (an ONAME Node) for the variable. + // TODO: keep a single varnum map, then make all of these maps slices instead? + vars map[ir.Node]*ssa.Value + + // fwdVars are variables that are used before they are defined in the current block. + // This map exists just to coalesce multiple references into a single FwdRef op. + // *Node is the unique identifier (an ONAME Node) for the variable. + fwdVars map[ir.Node]*ssa.Value + + // all defined variables at the end of each block. Indexed by block ID. + defvars []map[ir.Node]*ssa.Value + + // addresses of PPARAM and PPARAMOUT variables on the stack. + decladdrs map[*ir.Name]*ssa.Value + + // starting values. Memory, stack pointer, and globals pointer + startmem *ssa.Value + sp *ssa.Value + sb *ssa.Value + // value representing address of where deferBits autotmp is stored + deferBitsAddr *ssa.Value + deferBitsTemp *ir.Name + + // line number stack. The current line number is top of stack + line []src.XPos + // the last line number processed; it may have been popped + lastPos src.XPos + + // list of panic calls by function name and line number. + // Used to deduplicate panic calls. + panics map[funcLine]*ssa.Block + + cgoUnsafeArgs bool + hasdefer bool // whether the function contains a defer statement + softFloat bool + hasOpenDefers bool // whether we are doing open-coded defers + checkPtrEnabled bool // whether to insert checkptr instrumentation + instrumentEnterExit bool // whether to instrument function enter/exit + instrumentMemory bool // whether to instrument memory operations + + // If doing open-coded defers, list of info about the defer calls in + // scanning order. Hence, at exit we should run these defers in reverse + // order of this list + openDefers []*openDeferInfo + // For open-coded defers, this is the beginning and end blocks of the last + // defer exit code that we have generated so far. We use these to share + // code between exits if the shareDeferExits option (disabled by default) + // is on. + lastDeferExit *ssa.Block // Entry block of last defer exit code we generated + lastDeferFinalBlock *ssa.Block // Final block of last defer exit code we generated + lastDeferCount int // Number of defers encountered at that point + + prevCall *ssa.Value // the previous call; use this to tie results to the call op. + + // List of allocations in the current block that are still pending. + // They are all (OffPtr (Select0 (runtime call))) and have the correct types, + // but the offsets are not set yet, and the type of the runtime call is also not final. + pendingHeapAllocations []*ssa.Value + + // First argument of append calls that could be stack allocated. + appendTargets map[ir.Node]bool + + // Block starting position, indexed by block id. + blockStarts []src.XPos + + // Information for stack allocation. Indexed by the first argument + // to an append call. Normally a slice-typed variable, but not always. + backingStores map[ir.Node]*backingStoreInfo +} + +type backingStoreInfo struct { + // Size of backing store array (in elements) + K int64 + // Stack-allocated backing store variable. + store *ir.Name + // Dynamic boolean variable marking the fact that we used this backing store. + used *ir.Name + // Have we used this variable statically yet? This is just a hint + // to avoid checking the dynamic variable if the answer is obvious. + // (usedStatic == true implies used == true) + usedStatic bool +} + +type funcLine struct { + f *obj.LSym + base *src.PosBase + line uint +} + +type ssaLabel struct { + target *ssa.Block // block identified by this label + breakTarget *ssa.Block // block to break to in control flow node identified by this label + continueTarget *ssa.Block // block to continue to in control flow node identified by this label +} + +// label returns the label associated with sym, creating it if necessary. +func (s *state) label(sym *types.Sym) *ssaLabel { + lab := s.labels[sym.Name] + if lab == nil { + lab = new(ssaLabel) + s.labels[sym.Name] = lab + } + return lab +} + +func (s *state) Logf(msg string, args ...any) { s.f.Logf(msg, args...) } +func (s *state) Log() bool { return s.f.Log() } +func (s *state) Fatalf(msg string, args ...any) { + s.f.Frontend().Fatalf(s.peekPos(), msg, args...) +} +func (s *state) Warnl(pos src.XPos, msg string, args ...any) { s.f.Warnl(pos, msg, args...) } +func (s *state) Debug_checknil() bool { return s.f.Frontend().Debug_checknil() } + +func ssaMarker(name string) *ir.Name { + return ir.NewNameAt(base.Pos, &types.Sym{Name: name}, nil) +} + +var ( + // marker node for the memory variable + memVar = ssaMarker("mem") + + // marker nodes for temporary variables + ptrVar = ssaMarker("ptr") + lenVar = ssaMarker("len") + capVar = ssaMarker("cap") + typVar = ssaMarker("typ") + okVar = ssaMarker("ok") + deferBitsVar = ssaMarker("deferBits") + hashVar = ssaMarker("hash") +) + +// startBlock sets the current block we're generating code in to b. +func (s *state) startBlock(b *ssa.Block) { + if s.curBlock != nil { + s.Fatalf("starting block %v when block %v has not ended", b, s.curBlock) + } + s.curBlock = b + s.vars = map[ir.Node]*ssa.Value{} + clear(s.fwdVars) + for len(s.blockStarts) <= int(b.ID) { + s.blockStarts = append(s.blockStarts, src.NoXPos) + } +} + +// endBlock marks the end of generating code for the current block. +// Returns the (former) current block. Returns nil if there is no current +// block, i.e. if no code flows to the current execution point. +func (s *state) endBlock() *ssa.Block { + b := s.curBlock + if b == nil { + return nil + } + + s.flushPendingHeapAllocations() + + for len(s.defvars) <= int(b.ID) { + s.defvars = append(s.defvars, nil) + } + s.defvars[b.ID] = s.vars + s.curBlock = nil + s.vars = nil + if b.LackingPos() { + // Empty plain blocks get the line of their successor (handled after all blocks created), + // except for increment blocks in For statements (handled in ssa conversion of OFOR), + // and for blocks ending in GOTO/BREAK/CONTINUE. + b.Pos = src.NoXPos + } else { + b.Pos = s.lastPos + if s.blockStarts[b.ID] == src.NoXPos { + s.blockStarts[b.ID] = s.lastPos + } + } + return b +} + +// pushLine pushes a line number on the line number stack. +func (s *state) pushLine(line src.XPos) { + if !line.IsKnown() { + // the frontend may emit node with line number missing, + // use the parent line number in this case. + line = s.peekPos() + if base.Flag.K != 0 { + base.Warn("buildssa: unknown position (line 0)") + } + } else { + s.lastPos = line + } + // The first position we see for a new block is its starting position + // (the line number for its phis, if any). + if b := s.curBlock; b != nil && s.blockStarts[b.ID] == src.NoXPos { + s.blockStarts[b.ID] = line + } + + s.line = append(s.line, line) +} + +// popLine pops the top of the line number stack. +func (s *state) popLine() { + s.line = s.line[:len(s.line)-1] +} + +// peekPos peeks the top of the line number stack. +func (s *state) peekPos() src.XPos { + return s.line[len(s.line)-1] +} + +// newValue0 adds a new value with no arguments to the current block. +func (s *state) newValue0(op ssa.Op, t *types.Type) *ssa.Value { + return s.curBlock.NewValue0(s.peekPos(), op, t) +} + +// newValue0A adds a new value with no arguments and an aux value to the current block. +func (s *state) newValue0A(op ssa.Op, t *types.Type, aux ssa.Aux) *ssa.Value { + return s.curBlock.NewValue0A(s.peekPos(), op, t, aux) +} + +// newValue0I adds a new value with no arguments and an auxint value to the current block. +func (s *state) newValue0I(op ssa.Op, t *types.Type, auxint int64) *ssa.Value { + return s.curBlock.NewValue0I(s.peekPos(), op, t, auxint) +} + +// newValue1 adds a new value with one argument to the current block. +func (s *state) newValue1(op ssa.Op, t *types.Type, arg *ssa.Value) *ssa.Value { + return s.curBlock.NewValue1(s.peekPos(), op, t, arg) +} + +// newValue1A adds a new value with one argument and an aux value to the current block. +func (s *state) newValue1A(op ssa.Op, t *types.Type, aux ssa.Aux, arg *ssa.Value) *ssa.Value { + return s.curBlock.NewValue1A(s.peekPos(), op, t, aux, arg) +} + +// newValue1Apos adds a new value with one argument and an aux value to the current block. +// isStmt determines whether the created values may be a statement or not +// (i.e., false means never, yes means maybe). +func (s *state) newValue1Apos(op ssa.Op, t *types.Type, aux ssa.Aux, arg *ssa.Value, isStmt bool) *ssa.Value { + if isStmt { + return s.curBlock.NewValue1A(s.peekPos(), op, t, aux, arg) + } + return s.curBlock.NewValue1A(s.peekPos().WithNotStmt(), op, t, aux, arg) +} + +// newValue1I adds a new value with one argument and an auxint value to the current block. +func (s *state) newValue1I(op ssa.Op, t *types.Type, aux int64, arg *ssa.Value) *ssa.Value { + return s.curBlock.NewValue1I(s.peekPos(), op, t, aux, arg) +} + +// newValue2 adds a new value with two arguments to the current block. +func (s *state) newValue2(op ssa.Op, t *types.Type, arg0, arg1 *ssa.Value) *ssa.Value { + return s.curBlock.NewValue2(s.peekPos(), op, t, arg0, arg1) +} + +// newValue2A adds a new value with two arguments and an aux value to the current block. +func (s *state) newValue2A(op ssa.Op, t *types.Type, aux ssa.Aux, arg0, arg1 *ssa.Value) *ssa.Value { + return s.curBlock.NewValue2A(s.peekPos(), op, t, aux, arg0, arg1) +} + +// newValue2Apos adds a new value with two arguments and an aux value to the current block. +// isStmt determines whether the created values may be a statement or not +// (i.e., false means never, yes means maybe). +func (s *state) newValue2Apos(op ssa.Op, t *types.Type, aux ssa.Aux, arg0, arg1 *ssa.Value, isStmt bool) *ssa.Value { + if isStmt { + return s.curBlock.NewValue2A(s.peekPos(), op, t, aux, arg0, arg1) + } + return s.curBlock.NewValue2A(s.peekPos().WithNotStmt(), op, t, aux, arg0, arg1) +} + +// newValue2I adds a new value with two arguments and an auxint value to the current block. +func (s *state) newValue2I(op ssa.Op, t *types.Type, aux int64, arg0, arg1 *ssa.Value) *ssa.Value { + return s.curBlock.NewValue2I(s.peekPos(), op, t, aux, arg0, arg1) +} + +// newValue3 adds a new value with three arguments to the current block. +func (s *state) newValue3(op ssa.Op, t *types.Type, arg0, arg1, arg2 *ssa.Value) *ssa.Value { + return s.curBlock.NewValue3(s.peekPos(), op, t, arg0, arg1, arg2) +} + +// newValue3I adds a new value with three arguments and an auxint value to the current block. +func (s *state) newValue3I(op ssa.Op, t *types.Type, aux int64, arg0, arg1, arg2 *ssa.Value) *ssa.Value { + return s.curBlock.NewValue3I(s.peekPos(), op, t, aux, arg0, arg1, arg2) +} + +// newValue3A adds a new value with three arguments and an aux value to the current block. +func (s *state) newValue3A(op ssa.Op, t *types.Type, aux ssa.Aux, arg0, arg1, arg2 *ssa.Value) *ssa.Value { + return s.curBlock.NewValue3A(s.peekPos(), op, t, aux, arg0, arg1, arg2) +} + +// newValue3Apos adds a new value with three arguments and an aux value to the current block. +// isStmt determines whether the created values may be a statement or not +// (i.e., false means never, yes means maybe). +func (s *state) newValue3Apos(op ssa.Op, t *types.Type, aux ssa.Aux, arg0, arg1, arg2 *ssa.Value, isStmt bool) *ssa.Value { + if isStmt { + return s.curBlock.NewValue3A(s.peekPos(), op, t, aux, arg0, arg1, arg2) + } + return s.curBlock.NewValue3A(s.peekPos().WithNotStmt(), op, t, aux, arg0, arg1, arg2) +} + +// newValue4 adds a new value with four arguments to the current block. +func (s *state) newValue4(op ssa.Op, t *types.Type, arg0, arg1, arg2, arg3 *ssa.Value) *ssa.Value { + return s.curBlock.NewValue4(s.peekPos(), op, t, arg0, arg1, arg2, arg3) +} + +// newValue4A adds a new value with four arguments and an aux value to the current block. +func (s *state) newValue4A(op ssa.Op, t *types.Type, aux ssa.Aux, arg0, arg1, arg2, arg3 *ssa.Value) *ssa.Value { + return s.curBlock.NewValue4A(s.peekPos(), op, t, aux, arg0, arg1, arg2, arg3) +} + +// newValue4I adds a new value with four arguments and an auxint value to the current block. +func (s *state) newValue4I(op ssa.Op, t *types.Type, aux int64, arg0, arg1, arg2, arg3 *ssa.Value) *ssa.Value { + return s.curBlock.NewValue4I(s.peekPos(), op, t, aux, arg0, arg1, arg2, arg3) +} + +func (s *state) entryBlock() *ssa.Block { + b := s.f.Entry + if base.Flag.N > 0 && s.curBlock != nil { + // If optimizations are off, allocate in current block instead. Since with -N + // we're not doing the CSE or tighten passes, putting lots of stuff in the + // entry block leads to O(n^2) entries in the live value map during regalloc. + // See issue 45897. + b = s.curBlock + } + return b +} + +// entryNewValue0 adds a new value with no arguments to the entry block. +func (s *state) entryNewValue0(op ssa.Op, t *types.Type) *ssa.Value { + return s.entryBlock().NewValue0(src.NoXPos, op, t) +} + +// entryNewValue0A adds a new value with no arguments and an aux value to the entry block. +func (s *state) entryNewValue0A(op ssa.Op, t *types.Type, aux ssa.Aux) *ssa.Value { + return s.entryBlock().NewValue0A(src.NoXPos, op, t, aux) +} + +// entryNewValue1 adds a new value with one argument to the entry block. +func (s *state) entryNewValue1(op ssa.Op, t *types.Type, arg *ssa.Value) *ssa.Value { + return s.entryBlock().NewValue1(src.NoXPos, op, t, arg) +} + +// entryNewValue1I adds a new value with one argument and an auxint value to the entry block. +func (s *state) entryNewValue1I(op ssa.Op, t *types.Type, auxint int64, arg *ssa.Value) *ssa.Value { + return s.entryBlock().NewValue1I(src.NoXPos, op, t, auxint, arg) +} + +// entryNewValue1A adds a new value with one argument and an aux value to the entry block. +func (s *state) entryNewValue1A(op ssa.Op, t *types.Type, aux ssa.Aux, arg *ssa.Value) *ssa.Value { + return s.entryBlock().NewValue1A(src.NoXPos, op, t, aux, arg) +} + +// entryNewValue2 adds a new value with two arguments to the entry block. +func (s *state) entryNewValue2(op ssa.Op, t *types.Type, arg0, arg1 *ssa.Value) *ssa.Value { + return s.entryBlock().NewValue2(src.NoXPos, op, t, arg0, arg1) +} + +// entryNewValue2A adds a new value with two arguments and an aux value to the entry block. +func (s *state) entryNewValue2A(op ssa.Op, t *types.Type, aux ssa.Aux, arg0, arg1 *ssa.Value) *ssa.Value { + return s.entryBlock().NewValue2A(src.NoXPos, op, t, aux, arg0, arg1) +} + +// const* routines add a new const value to the entry block. +func (s *state) constSlice(t *types.Type) *ssa.Value { + return s.f.ConstSlice(t) +} +func (s *state) constInterface(t *types.Type) *ssa.Value { + return s.f.ConstInterface(t) +} +func (s *state) constNil(t *types.Type) *ssa.Value { return s.f.ConstNil(t) } +func (s *state) constEmptyString(t *types.Type) *ssa.Value { + return s.f.ConstEmptyString(t) +} +func (s *state) constBool(c bool) *ssa.Value { + return s.f.ConstBool(types.Types[types.TBOOL], c) +} +func (s *state) constInt8(t *types.Type, c int8) *ssa.Value { + return s.f.ConstInt8(t, c) +} +func (s *state) constInt16(t *types.Type, c int16) *ssa.Value { + return s.f.ConstInt16(t, c) +} +func (s *state) constInt32(t *types.Type, c int32) *ssa.Value { + return s.f.ConstInt32(t, c) +} +func (s *state) constInt64(t *types.Type, c int64) *ssa.Value { + return s.f.ConstInt64(t, c) +} +func (s *state) constFloat32(t *types.Type, c float64) *ssa.Value { + return s.f.ConstFloat32(t, c) +} +func (s *state) constFloat64(t *types.Type, c float64) *ssa.Value { + return s.f.ConstFloat64(t, c) +} +func (s *state) constInt(t *types.Type, c int64) *ssa.Value { + if s.config.PtrSize == 8 { + return s.constInt64(t, c) + } + if int64(int32(c)) != c { + s.Fatalf("integer constant too big %d", c) + } + return s.constInt32(t, int32(c)) +} + +// newValueOrSfCall* are wrappers around newValue*, which may create a call to a +// soft-float runtime function instead (when emitting soft-float code). +func (s *state) newValueOrSfCall1(op ssa.Op, t *types.Type, arg *ssa.Value) *ssa.Value { + if s.softFloat { + if c, ok := s.sfcall(op, arg); ok { + return c + } + } + return s.newValue1(op, t, arg) +} +func (s *state) newValueOrSfCall2(op ssa.Op, t *types.Type, arg0, arg1 *ssa.Value) *ssa.Value { + if s.softFloat { + if c, ok := s.sfcall(op, arg0, arg1); ok { + return c + } + } + return s.newValue2(op, t, arg0, arg1) +} + +type instrumentKind uint8 + +const ( + instrumentRead = iota + instrumentWrite + instrumentMove +) + +func (s *state) instrument(t *types.Type, addr *ssa.Value, kind instrumentKind) { + s.instrument2(t, addr, nil, kind) +} + +// instrumentFields instruments a read/write operation on addr. +// If it is instrumenting for MSAN or ASAN and t is a struct type, it instruments +// operation for each field, instead of for the whole struct. +func (s *state) instrumentFields(t *types.Type, addr *ssa.Value, kind instrumentKind) { + if !(base.Flag.MSan || base.Flag.ASan) || !isStructNotSIMD(t) { + s.instrument(t, addr, kind) + return + } + for _, f := range t.Fields() { + if f.Sym.IsBlank() { + continue + } + offptr := s.newValue1I(ssa.OpOffPtr, types.NewPtr(f.Type), f.Offset, addr) + s.instrumentFields(f.Type, offptr, kind) + } +} + +func (s *state) instrumentMove(t *types.Type, dst, src *ssa.Value) { + if base.Flag.MSan { + s.instrument2(t, dst, src, instrumentMove) + } else { + s.instrument(t, src, instrumentRead) + s.instrument(t, dst, instrumentWrite) + } +} + +func (s *state) instrument2(t *types.Type, addr, addr2 *ssa.Value, kind instrumentKind) { + if !s.instrumentMemory { + return + } + + w := t.Size() + if w == 0 { + return // can't race on zero-sized things + } + + if ssa.IsSanitizerSafeAddr(addr) { + return + } + + var fn *obj.LSym + needWidth := false + + if addr2 != nil && kind != instrumentMove { + panic("instrument2: non-nil addr2 for non-move instrumentation") + } + + if base.Flag.MSan { + switch kind { + case instrumentRead: + fn = ir.Syms.Msanread + case instrumentWrite: + fn = ir.Syms.Msanwrite + case instrumentMove: + fn = ir.Syms.Msanmove + default: + panic("unreachable") + } + needWidth = true + } else if base.Flag.Race && t.NumComponents(types.CountBlankFields) > 1 { + // for composite objects we have to write every address + // because a write might happen to any subobject. + // composites with only one element don't have subobjects, though. + switch kind { + case instrumentRead: + fn = ir.Syms.Racereadrange + case instrumentWrite: + fn = ir.Syms.Racewriterange + default: + panic("unreachable") + } + needWidth = true + } else if base.Flag.Race { + // for non-composite objects we can write just the start + // address, as any write must write the first byte. + switch kind { + case instrumentRead: + fn = ir.Syms.Raceread + case instrumentWrite: + fn = ir.Syms.Racewrite + default: + panic("unreachable") + } + } else if base.Flag.ASan { + switch kind { + case instrumentRead: + fn = ir.Syms.Asanread + case instrumentWrite: + fn = ir.Syms.Asanwrite + default: + panic("unreachable") + } + needWidth = true + } else { + panic("unreachable") + } + + args := []*ssa.Value{addr} + if addr2 != nil { + args = append(args, addr2) + } + if needWidth { + args = append(args, s.constInt(types.Types[types.TUINTPTR], w)) + } + s.rtcall(fn, true, nil, args...) +} + +func (s *state) load(t *types.Type, src *ssa.Value) *ssa.Value { + s.instrumentFields(t, src, instrumentRead) + return s.rawLoad(t, src) +} + +func (s *state) rawLoad(t *types.Type, src *ssa.Value) *ssa.Value { + return s.newValue2(ssa.OpLoad, t, src, s.mem()) +} + +func (s *state) store(t *types.Type, dst, val *ssa.Value) { + s.vars[memVar] = s.newValue3A(ssa.OpStore, types.TypeMem, t, dst, val, s.mem()) +} + +func (s *state) zero(t *types.Type, dst *ssa.Value) { + s.instrument(t, dst, instrumentWrite) + store := s.newValue2I(ssa.OpZero, types.TypeMem, t.Size(), dst, s.mem()) + store.Aux = t + s.vars[memVar] = store +} + +func (s *state) move(t *types.Type, dst, src *ssa.Value) { + s.moveWhichMayOverlap(t, dst, src, false) +} +func (s *state) moveWhichMayOverlap(t *types.Type, dst, src *ssa.Value, mayOverlap bool) { + s.instrumentMove(t, dst, src) + if mayOverlap && t.IsArray() && t.NumElem() > 1 && !ssa.IsInlinableMemmove(dst, src, t.Size(), s.f.Config) { + // Normally, when moving Go values of type T from one location to another, + // we don't need to worry about partial overlaps. The two Ts must either be + // in disjoint (nonoverlapping) memory or in exactly the same location. + // There are 2 cases where this isn't true: + // 1) Using unsafe you can arrange partial overlaps. + // 2) Since Go 1.17, you can use a cast from a slice to a ptr-to-array. + // https://go.dev/ref/spec#Conversions_from_slice_to_array_pointer + // This feature can be used to construct partial overlaps of array types. + // var a [3]int + // p := (*[2]int)(a[:]) + // q := (*[2]int)(a[1:]) + // *p = *q + // We don't care about solving 1. Or at least, we haven't historically + // and no one has complained. + // For 2, we need to ensure that if there might be partial overlap, + // then we can't use OpMove; we must use memmove instead. + // (memmove handles partial overlap by copying in the correct + // direction. OpMove does not.) + // + // Note that we have to be careful here not to introduce a call when + // we're marshaling arguments to a call or unmarshaling results from a call. + // Cases where this is happening must pass mayOverlap to false. + // (Currently this only happens when unmarshaling results of a call.) + if t.HasPointers() { + s.rtcall(ir.Syms.Typedmemmove, true, nil, s.reflectType(t), dst, src) + // We would have otherwise implemented this move with straightline code, + // including a write barrier. Pretend we issue a write barrier here, + // so that the write barrier tests work. (Otherwise they'd need to know + // the details of IsInlineableMemmove.) + s.curfn.SetWBPos(s.peekPos()) + } else { + s.rtcall(ir.Syms.Memmove, true, nil, dst, src, s.constInt(types.Types[types.TUINTPTR], t.Size())) + } + ssa.LogLargeCopy(s.f.Name, s.peekPos(), t.Size()) + return + } + store := s.newValue3I(ssa.OpMove, types.TypeMem, t.Size(), dst, src, s.mem()) + store.Aux = t + s.vars[memVar] = store +} + +// stmtList converts the statement list n to SSA and adds it to s. +func (s *state) stmtList(l ir.Nodes) { + for _, n := range l { + s.stmt(n) + } +} + +func peelConvNop(n ir.Node) ir.Node { + if n == nil { + return n + } + for n.Op() == ir.OCONVNOP { + n = n.(*ir.ConvExpr).X + } + return n +} + +// stmt converts the statement n to SSA and adds it to s. +func (s *state) stmt(n ir.Node) { + s.pushLine(n.Pos()) + defer s.popLine() + + // If s.curBlock is nil, and n isn't a label (which might have an associated goto somewhere), + // then this code is dead. Stop here. + if s.curBlock == nil && n.Op() != ir.OLABEL { + return + } + + s.stmtList(n.Init()) + switch n.Op() { + + case ir.OBLOCK: + n := n.(*ir.BlockStmt) + s.stmtList(n.List) + + case ir.OFALL: // no-op + + // Expression statements + case ir.OCALLFUNC: + n := n.(*ir.CallExpr) + if ir.IsIntrinsicCall(n) { + s.intrinsicCall(n) + return + } + fallthrough + + case ir.OCALLINTER: + n := n.(*ir.CallExpr) + s.callResult(n, callNormal) + if n.Op() == ir.OCALLFUNC && n.Fun.Op() == ir.ONAME && n.Fun.(*ir.Name).Class == ir.PFUNC { + if fn := n.Fun.Sym().Name; base.Flag.CompilingRuntime && fn == "throw" || + n.Fun.Sym().Pkg == ir.Pkgs.Runtime && + (fn == "throwinit" || fn == "gopanic" || fn == "panicwrap" || fn == "block" || + fn == "panicmakeslicelen" || fn == "panicmakeslicecap" || fn == "panicunsafeslicelen" || + fn == "panicunsafeslicenilptr" || fn == "panicunsafestringlen" || fn == "panicunsafestringnilptr" || + fn == "panicrangestate") { + m := s.mem() + b := s.endBlock() + b.Kind = ssa.BlockExit + b.SetControl(m) + // TODO: never rewrite OPANIC to OCALLFUNC in the + // first place. Need to wait until all backends + // go through SSA. + } + } + case ir.ODEFER: + n := n.(*ir.GoDeferStmt) + if base.Debug.Defer > 0 { + var defertype string + if s.hasOpenDefers { + defertype = "open-coded" + } else if n.Esc() == ir.EscNever { + defertype = "stack-allocated" + } else { + defertype = "heap-allocated" + } + base.WarnfAt(n.Pos(), "%s defer", defertype) + } + if s.hasOpenDefers { + s.openDeferRecord(n.Call.(*ir.CallExpr)) + } else { + d := callDefer + if n.Esc() == ir.EscNever && n.DeferAt == nil { + d = callDeferStack + } + s.call(n.Call.(*ir.CallExpr), d, false, n.DeferAt) + } + case ir.OGO: + n := n.(*ir.GoDeferStmt) + s.callResult(n.Call.(*ir.CallExpr), callGo) + + case ir.OAS2DOTTYPE: + n := n.(*ir.AssignListStmt) + var res, resok *ssa.Value + if n.Rhs[0].Op() == ir.ODOTTYPE2 { + res, resok = s.dottype(n.Rhs[0].(*ir.TypeAssertExpr), true) + } else { + res, resok = s.dynamicDottype(n.Rhs[0].(*ir.DynamicTypeAssertExpr), true) + } + deref := false + if !ssa.CanSSA(n.Rhs[0].Type()) { + if res.Op != ssa.OpLoad { + s.Fatalf("dottype of non-load") + } + mem := s.mem() + if res.Args[1] != mem { + s.Fatalf("memory no longer live from 2-result dottype load") + } + deref = true + res = res.Args[0] + } + s.assign(n.Lhs[0], res, deref, 0) + s.assign(n.Lhs[1], resok, false, 0) + return + + case ir.OAS2FUNC: + // We come here only when it is an intrinsic call returning two values. + n := n.(*ir.AssignListStmt) + call := n.Rhs[0].(*ir.CallExpr) + if !ir.IsIntrinsicCall(call) { + s.Fatalf("non-intrinsic AS2FUNC not expanded %v", call) + } + v := s.intrinsicCall(call) + v1 := s.newValue1(ssa.OpSelect0, n.Lhs[0].Type(), v) + v2 := s.newValue1(ssa.OpSelect1, n.Lhs[1].Type(), v) + s.assign(n.Lhs[0], v1, false, 0) + s.assign(n.Lhs[1], v2, false, 0) + return + + case ir.ODCL: + n := n.(*ir.Decl) + if v := n.X; v.Esc() == ir.EscHeap { + s.newHeapaddr(v) + } + + case ir.OLABEL: + n := n.(*ir.LabelStmt) + sym := n.Label + if sym.IsBlank() { + // Nothing to do because the label isn't targetable. See issue 52278. + break + } + lab := s.label(sym) + + // The label might already have a target block via a goto. + if lab.target == nil { + lab.target = s.f.NewBlock(ssa.BlockPlain) + } + + // Go to that label. + // (We pretend "label:" is preceded by "goto label", unless the predecessor is unreachable.) + if s.curBlock != nil { + b := s.endBlock() + b.AddEdgeTo(lab.target) + } + s.startBlock(lab.target) + + case ir.OGOTO: + n := n.(*ir.BranchStmt) + sym := n.Label + + lab := s.label(sym) + if lab.target == nil { + lab.target = s.f.NewBlock(ssa.BlockPlain) + } + + b := s.endBlock() + b.Pos = s.lastPos.WithIsStmt() // Do this even if b is an empty block. + b.AddEdgeTo(lab.target) + + case ir.OAS: + n := n.(*ir.AssignStmt) + if n.X == n.Y && n.X.Op() == ir.ONAME { + // An x=x assignment. No point in doing anything + // here. In addition, skipping this assignment + // prevents generating: + // VARDEF x + // COPY x -> x + // which is bad because x is incorrectly considered + // dead before the vardef. See issue #14904. + return + } + + // mayOverlap keeps track of whether the LHS and RHS might + // refer to partially overlapping memory. Partial overlapping can + // only happen for arrays, see the comment in moveWhichMayOverlap. + // + // If both sides of the assignment are not dereferences, then partial + // overlap can't happen. Partial overlap can only occur only when the + // arrays referenced are strictly smaller parts of the same base array. + // If one side of the assignment is a full array, then partial overlap + // can't happen. (The arrays are either disjoint or identical.) + ny := peelConvNop(n.Y) + mayOverlap := n.X.Op() == ir.ODEREF && (n.Y != nil && ny.Op() == ir.ODEREF) + if ny != nil && ny.Op() == ir.ODEREF { + p := peelConvNop(ny.(*ir.StarExpr).X) + if p.Op() == ir.OSPTR && p.(*ir.UnaryExpr).X.Type().IsString() { + // Pointer fields of strings point to unmodifiable memory. + // That memory can't overlap with the memory being written. + mayOverlap = false + } + } + + // Evaluate RHS. + rhs := n.Y + if rhs != nil { + switch rhs.Op() { + case ir.OSTRUCTLIT, ir.OARRAYLIT, ir.OSLICELIT: + // All literals with nonzero fields have already been + // rewritten during walk. Any that remain are just T{} + // or equivalents. Use the zero value. + if !ir.IsZero(rhs) { + s.Fatalf("literal with nonzero value in SSA: %v", rhs) + } + rhs = nil + case ir.OAPPEND: + rhs := rhs.(*ir.CallExpr) + // Check whether we're writing the result of an append back to the same slice. + // If so, we handle it specially to avoid write barriers on the fast + // (non-growth) path. + if !ir.SameSafeExpr(n.X, rhs.Args[0]) || base.Flag.N != 0 { + break + } + // If the slice can be SSA'd, it'll be on the stack, + // so there will be no write barriers, + // so there's no need to attempt to prevent them. + if s.canSSA(n.X) { + if base.Debug.Append > 0 { // replicating old diagnostic message + base.WarnfAt(n.Pos(), "append: len-only update (in local slice)") + } + break + } + if base.Debug.Append > 0 { + base.WarnfAt(n.Pos(), "append: len-only update") + } + s.append(rhs, true) + return + } + } + + if ir.IsBlank(n.X) { + // _ = rhs + // Just evaluate rhs for side-effects. + if rhs != nil { + s.expr(rhs) + } + return + } + + var t *types.Type + if n.Y != nil { + t = n.Y.Type() + } else { + t = n.X.Type() + } + + var r *ssa.Value + deref := !ssa.CanSSA(t) + if deref { + if rhs == nil { + r = nil // Signal assign to use OpZero. + } else { + r = s.addr(rhs) + } + } else { + if rhs == nil { + r = s.zeroVal(t) + } else { + r = s.expr(rhs) + } + } + + var skip skipMask + if rhs != nil && (rhs.Op() == ir.OSLICE || rhs.Op() == ir.OSLICE3 || rhs.Op() == ir.OSLICESTR) && ir.SameSafeExpr(rhs.(*ir.SliceExpr).X, n.X) { + // We're assigning a slicing operation back to its source. + // Don't write back fields we aren't changing. See issue #14855. + rhs := rhs.(*ir.SliceExpr) + i, j, k := rhs.Low, rhs.High, rhs.Max + if i != nil && (i.Op() == ir.OLITERAL && i.Val().Kind() == constant.Int && ir.Int64Val(i) == 0) { + // [0:...] is the same as [:...] + i = nil + } + // TODO: detect defaults for len/cap also. + // Currently doesn't really work because (*p)[:len(*p)] appears here as: + // tmp = len(*p) + // (*p)[:tmp] + // if j != nil && (j.Op == OLEN && SameSafeExpr(j.Left, n.Left)) { + // j = nil + // } + // if k != nil && (k.Op == OCAP && SameSafeExpr(k.Left, n.Left)) { + // k = nil + // } + if i == nil { + skip |= skipPtr + if j == nil { + skip |= skipLen + } + if k == nil { + skip |= skipCap + } + } + } + + s.assignWhichMayOverlap(n.X, r, deref, skip, mayOverlap) + + case ir.OIF: + n := n.(*ir.IfStmt) + if ir.IsConst(n.Cond, constant.Bool) { + s.stmtList(n.Cond.Init()) + if ir.BoolVal(n.Cond) { + s.stmtList(n.Body) + } else { + s.stmtList(n.Else) + } + break + } + + bEnd := s.f.NewBlock(ssa.BlockPlain) + var likely int8 + if n.Likely { + likely = 1 + } + var bThen *ssa.Block + if len(n.Body) != 0 { + bThen = s.f.NewBlock(ssa.BlockPlain) + } else { + bThen = bEnd + } + var bElse *ssa.Block + if len(n.Else) != 0 { + bElse = s.f.NewBlock(ssa.BlockPlain) + } else { + bElse = bEnd + } + s.condBranch(n.Cond, bThen, bElse, likely) + + if len(n.Body) != 0 { + s.startBlock(bThen) + s.stmtList(n.Body) + if b := s.endBlock(); b != nil { + b.AddEdgeTo(bEnd) + } + } + if len(n.Else) != 0 { + s.startBlock(bElse) + s.stmtList(n.Else) + if b := s.endBlock(); b != nil { + b.AddEdgeTo(bEnd) + } + } + s.startBlock(bEnd) + + case ir.ORETURN: + n := n.(*ir.ReturnStmt) + s.stmtList(n.Results) + b := s.exit() + b.Pos = s.lastPos.WithIsStmt() + + case ir.OTAILCALL: + n := n.(*ir.TailCallStmt) + s.callResult(n.Call, callTail) + call := s.mem() + b := s.endBlock() + b.Kind = ssa.BlockRetJmp // could use BlockExit. BlockRetJmp is mostly for clarity. + b.SetControl(call) + + case ir.OCONTINUE, ir.OBREAK: + n := n.(*ir.BranchStmt) + var to *ssa.Block + if n.Label == nil { + // plain break/continue + switch n.Op() { + case ir.OCONTINUE: + to = s.continueTo + case ir.OBREAK: + to = s.breakTo + } + } else { + // labeled break/continue; look up the target + sym := n.Label + lab := s.label(sym) + switch n.Op() { + case ir.OCONTINUE: + to = lab.continueTarget + case ir.OBREAK: + to = lab.breakTarget + } + } + + b := s.endBlock() + b.Pos = s.lastPos.WithIsStmt() // Do this even if b is an empty block. + b.AddEdgeTo(to) + + case ir.OFOR: + // OFOR: for Ninit; Left; Right { Nbody } + // cond (Left); body (Nbody); incr (Right) + n := n.(*ir.ForStmt) + base.Assert(!n.DistinctVars) // Should all be rewritten before escape analysis + bCond := s.f.NewBlock(ssa.BlockPlain) + bBody := s.f.NewBlock(ssa.BlockPlain) + bIncr := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + + // ensure empty for loops have correct position; issue #30167 + bBody.Pos = n.Pos() + + // first, jump to condition test + b := s.endBlock() + b.AddEdgeTo(bCond) + + // generate code to test condition + s.startBlock(bCond) + if n.Cond != nil { + s.condBranch(n.Cond, bBody, bEnd, 1) + } else { + b := s.endBlock() + b.Kind = ssa.BlockPlain + b.AddEdgeTo(bBody) + } + + // set up for continue/break in body + prevContinue := s.continueTo + prevBreak := s.breakTo + s.continueTo = bIncr + s.breakTo = bEnd + var lab *ssaLabel + if sym := n.Label; sym != nil { + // labeled for loop + lab = s.label(sym) + lab.continueTarget = bIncr + lab.breakTarget = bEnd + } + + // generate body + s.startBlock(bBody) + s.stmtList(n.Body) + + // tear down continue/break + s.continueTo = prevContinue + s.breakTo = prevBreak + if lab != nil { + lab.continueTarget = nil + lab.breakTarget = nil + } + + // done with body, goto incr + if b := s.endBlock(); b != nil { + b.AddEdgeTo(bIncr) + } + + // generate incr + s.startBlock(bIncr) + if n.Post != nil { + s.stmt(n.Post) + } + if b := s.endBlock(); b != nil { + b.AddEdgeTo(bCond) + // It can happen that bIncr ends in a block containing only VARKILL, + // and that muddles the debugging experience. + if b.Pos == src.NoXPos { + b.Pos = bCond.Pos + } + } + + s.startBlock(bEnd) + + case ir.OSWITCH, ir.OSELECT: + // These have been mostly rewritten by the front end into their Nbody fields. + // Our main task is to correctly hook up any break statements. + bEnd := s.f.NewBlock(ssa.BlockPlain) + + prevBreak := s.breakTo + s.breakTo = bEnd + var sym *types.Sym + var body ir.Nodes + if n.Op() == ir.OSWITCH { + n := n.(*ir.SwitchStmt) + sym = n.Label + body = n.Compiled + } else { + n := n.(*ir.SelectStmt) + sym = n.Label + body = n.Compiled + } + + var lab *ssaLabel + if sym != nil { + // labeled + lab = s.label(sym) + lab.breakTarget = bEnd + } + + // generate body code + s.stmtList(body) + + s.breakTo = prevBreak + if lab != nil { + lab.breakTarget = nil + } + + // walk adds explicit OBREAK nodes to the end of all reachable code paths. + // If we still have a current block here, then mark it unreachable. + if s.curBlock != nil { + m := s.mem() + b := s.endBlock() + b.Kind = ssa.BlockExit + b.SetControl(m) + } + s.startBlock(bEnd) + + case ir.OJUMPTABLE: + n := n.(*ir.JumpTableStmt) + + // Make blocks we'll need. + jt := s.f.NewBlock(ssa.BlockJumpTable) + bEnd := s.f.NewBlock(ssa.BlockPlain) + + // The only thing that needs evaluating is the index we're looking up. + idx := s.expr(n.Idx) + unsigned := idx.Type.IsUnsigned() + + // Extend so we can do everything in uintptr arithmetic. + t := types.Types[types.TUINTPTR] + idx = s.conv(nil, idx, idx.Type, t) + + // The ending condition for the current block decides whether we'll use + // the jump table at all. + // We check that min <= idx <= max and jump around the jump table + // if that test fails. + // We implement min <= idx <= max with 0 <= idx-min <= max-min, because + // we'll need idx-min anyway as the control value for the jump table. + var min, max uint64 + if unsigned { + min, _ = constant.Uint64Val(n.Cases[0]) + max, _ = constant.Uint64Val(n.Cases[len(n.Cases)-1]) + } else { + mn, _ := constant.Int64Val(n.Cases[0]) + mx, _ := constant.Int64Val(n.Cases[len(n.Cases)-1]) + min = uint64(mn) + max = uint64(mx) + } + // Compare idx-min with max-min, to see if we can use the jump table. + idx = s.newValue2(s.ssaOp(ir.OSUB, t), t, idx, s.uintptrConstant(min)) + width := s.uintptrConstant(max - min) + cmp := s.newValue2(s.ssaOp(ir.OLE, t), types.Types[types.TBOOL], idx, width) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp) + b.AddEdgeTo(jt) // in range - use jump table + b.AddEdgeTo(bEnd) // out of range - no case in the jump table will trigger + b.Likely = ssa.BranchLikely // TODO: assumes missing the table entirely is unlikely. True? + + // Build jump table block. + s.startBlock(jt) + jt.Pos = n.Pos() + if base.Flag.Cfg.SpectreIndex { + idx = s.newValue2(ssa.OpSpectreSliceIndex, t, idx, width) + } + jt.SetControl(idx) + + // Figure out where we should go for each index in the table. + table := make([]*ssa.Block, max-min+1) + for i := range table { + table[i] = bEnd // default target + } + for i := range n.Targets { + c := n.Cases[i] + lab := s.label(n.Targets[i]) + if lab.target == nil { + lab.target = s.f.NewBlock(ssa.BlockPlain) + } + var val uint64 + if unsigned { + val, _ = constant.Uint64Val(c) + } else { + vl, _ := constant.Int64Val(c) + val = uint64(vl) + } + // Overwrite the default target. + table[val-min] = lab.target + } + for _, t := range table { + jt.AddEdgeTo(t) + } + s.endBlock() + + s.startBlock(bEnd) + + case ir.OINTERFACESWITCH: + n := n.(*ir.InterfaceSwitchStmt) + typs := s.f.Config.Types + + t := s.expr(n.RuntimeType) + h := s.expr(n.Hash) + d := s.newValue1A(ssa.OpAddr, typs.BytePtr, n.Descriptor, s.sb) + + // Check the cache first. + var merge *ssa.Block + if base.Flag.N == 0 && rtabi.UseInterfaceSwitchCache(Arch.LinkArch.Family) { + // Note: we can only use the cache if we have the right atomic load instruction. + // Double-check that here. + if intrinsics.lookup(Arch.LinkArch.Arch, "internal/runtime/atomic", "Loadp") == nil { + s.Fatalf("atomic load not available") + } + merge = s.f.NewBlock(ssa.BlockPlain) + cacheHit := s.f.NewBlock(ssa.BlockPlain) + cacheMiss := s.f.NewBlock(ssa.BlockPlain) + loopHead := s.f.NewBlock(ssa.BlockPlain) + loopBody := s.f.NewBlock(ssa.BlockPlain) + + // Pick right size ops. + var mul, and, add, zext ssa.Op + if s.config.PtrSize == 4 { + mul = ssa.OpMul32 + and = ssa.OpAnd32 + add = ssa.OpAdd32 + zext = ssa.OpCopy + } else { + mul = ssa.OpMul64 + and = ssa.OpAnd64 + add = ssa.OpAdd64 + zext = ssa.OpZeroExt32to64 + } + + // Load cache pointer out of descriptor, with an atomic load so + // we ensure that we see a fully written cache. + atomicLoad := s.newValue2(ssa.OpAtomicLoadPtr, types.NewTuple(typs.BytePtr, types.TypeMem), d, s.mem()) + cache := s.newValue1(ssa.OpSelect0, typs.BytePtr, atomicLoad) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, atomicLoad) + + // Initialize hash variable. + s.vars[hashVar] = s.newValue1(zext, typs.Uintptr, h) + + // Load mask from cache. + mask := s.newValue2(ssa.OpLoad, typs.Uintptr, cache, s.mem()) + // Jump to loop head. + b := s.endBlock() + b.AddEdgeTo(loopHead) + + // At loop head, get pointer to the cache entry. + // e := &cache.Entries[hash&mask] + s.startBlock(loopHead) + entries := s.newValue2(ssa.OpAddPtr, typs.UintptrPtr, cache, s.uintptrConstant(uint64(s.config.PtrSize))) + idx := s.newValue2(and, typs.Uintptr, s.variable(hashVar, typs.Uintptr), mask) + idx = s.newValue2(mul, typs.Uintptr, idx, s.uintptrConstant(uint64(3*s.config.PtrSize))) + e := s.newValue2(ssa.OpAddPtr, typs.UintptrPtr, entries, idx) + // hash++ + s.vars[hashVar] = s.newValue2(add, typs.Uintptr, s.variable(hashVar, typs.Uintptr), s.uintptrConstant(1)) + + // Look for a cache hit. + // if e.Typ == t { goto hit } + eTyp := s.newValue2(ssa.OpLoad, typs.Uintptr, e, s.mem()) + cmp1 := s.newValue2(ssa.OpEqPtr, typs.Bool, t, eTyp) + b = s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp1) + b.AddEdgeTo(cacheHit) + b.AddEdgeTo(loopBody) + + // Look for an empty entry, the tombstone for this hash table. + // if e.Typ == nil { goto miss } + s.startBlock(loopBody) + cmp2 := s.newValue2(ssa.OpEqPtr, typs.Bool, eTyp, s.constNil(typs.BytePtr)) + b = s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp2) + b.AddEdgeTo(cacheMiss) + b.AddEdgeTo(loopHead) + + // On a hit, load the data fields of the cache entry. + // Case = e.Case + // Itab = e.Itab + s.startBlock(cacheHit) + eCase := s.newValue2(ssa.OpLoad, typs.Int, s.newValue1I(ssa.OpOffPtr, typs.IntPtr, s.config.PtrSize, e), s.mem()) + eItab := s.newValue2(ssa.OpLoad, typs.BytePtr, s.newValue1I(ssa.OpOffPtr, typs.BytePtrPtr, 2*s.config.PtrSize, e), s.mem()) + s.assign(n.Case, eCase, false, 0) + s.assign(n.Itab, eItab, false, 0) + b = s.endBlock() + b.AddEdgeTo(merge) + + // On a miss, call into the runtime to get the answer. + s.startBlock(cacheMiss) + } + + r := s.rtcall(ir.Syms.InterfaceSwitch, true, []*types.Type{typs.Int, typs.BytePtr}, d, t) + s.assign(n.Case, r[0], false, 0) + s.assign(n.Itab, r[1], false, 0) + + if merge != nil { + // Cache hits merge in here. + b := s.endBlock() + b.Kind = ssa.BlockPlain + b.AddEdgeTo(merge) + s.startBlock(merge) + } + + case ir.OCHECKNIL: + n := n.(*ir.UnaryExpr) + p := s.expr(n.X) + _ = s.nilCheck(p) + // TODO: check that throwing away the nilcheck result is ok. + + case ir.OINLMARK: + n := n.(*ir.InlineMarkStmt) + s.newValue1I(ssa.OpInlMark, types.TypeVoid, n.Index, s.mem()) + + default: + s.Fatalf("unhandled stmt %v", n.Op()) + } +} + +// If true, share as many open-coded defer exits as possible (with the downside of +// worse line-number information) +const shareDeferExits = false + +// exit processes any code that needs to be generated just before returning. +// It returns a BlockRet block that ends the control flow. Its control value +// will be set to the final memory state. +func (s *state) exit() *ssa.Block { + if s.hasdefer { + if s.hasOpenDefers { + if shareDeferExits && s.lastDeferExit != nil && len(s.openDefers) == s.lastDeferCount { + if s.curBlock.Kind != ssa.BlockPlain { + panic("Block for an exit should be BlockPlain") + } + s.curBlock.AddEdgeTo(s.lastDeferExit) + s.endBlock() + return s.lastDeferFinalBlock + } + s.openDeferExit() + } else { + // Shared deferreturn is assigned the "last" position in the function. + // The linker picks the first deferreturn call it sees, so this is + // the only sensible "shared" place. + // To not-share deferreturn, the protocol would need to be changed + // so that the call to deferproc-etc would receive the PC offset from + // the return PC, and the runtime would need to use that instead of + // the deferreturn retrieved from the pcln information. + // opendefers would remain a problem, however. + s.pushLine(s.curfn.Endlineno) + s.rtcall(ir.Syms.Deferreturn, true, nil) + s.popLine() + } + } + + // Do actual return. + // These currently turn into self-copies (in many cases). + resultFields := s.curfn.Type().Results() + results := make([]*ssa.Value, len(resultFields)+1, len(resultFields)+1) + // Store SSAable and heap-escaped PPARAMOUT variables back to stack locations. + for i, f := range resultFields { + n := f.Nname.(*ir.Name) + if s.canSSA(n) { // result is in some SSA variable + if !n.IsOutputParamInRegisters() && n.Type().HasPointers() { + // We are about to store to the result slot. + s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, n, s.mem()) + } + results[i] = s.variable(n, n.Type()) + } else if !n.OnStack() { // result is actually heap allocated + // We are about to copy the in-heap result to the result slot. + if n.Type().HasPointers() { + s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, n, s.mem()) + } + ha := s.expr(n.Heapaddr) + s.instrumentFields(n.Type(), ha, instrumentRead) + results[i] = s.newValue2(ssa.OpDereference, n.Type(), ha, s.mem()) + } else { // result is not SSA-able; not escaped, so not on heap, but too large for SSA. + // Before register ABI this ought to be a self-move, home=dest, + // With register ABI, it's still a self-move if parameter is on stack (i.e., too big or overflowed) + // No VarDef, as the result slot is already holding live value. + results[i] = s.newValue2(ssa.OpDereference, n.Type(), s.addr(n), s.mem()) + } + } + + // In -race mode, we need to call racefuncexit. + // Note: This has to happen after we load any heap-allocated results, + // otherwise races will be attributed to the caller instead. + if s.instrumentEnterExit { + s.rtcall(ir.Syms.Racefuncexit, true, nil) + } + + results[len(results)-1] = s.mem() + m := s.newValue0(ssa.OpMakeResult, s.f.OwnAux.LateExpansionResultType()) + m.AddArgs(results...) + + b := s.endBlock() + b.Kind = ssa.BlockRet + b.SetControl(m) + if s.hasdefer && s.hasOpenDefers { + s.lastDeferFinalBlock = b + } + return b +} + +type opAndType struct { + op ir.Op + etype types.Kind +} + +var opToSSA = map[opAndType]ssa.Op{ + {ir.OADD, types.TINT8}: ssa.OpAdd8, + {ir.OADD, types.TUINT8}: ssa.OpAdd8, + {ir.OADD, types.TINT16}: ssa.OpAdd16, + {ir.OADD, types.TUINT16}: ssa.OpAdd16, + {ir.OADD, types.TINT32}: ssa.OpAdd32, + {ir.OADD, types.TUINT32}: ssa.OpAdd32, + {ir.OADD, types.TINT64}: ssa.OpAdd64, + {ir.OADD, types.TUINT64}: ssa.OpAdd64, + {ir.OADD, types.TFLOAT32}: ssa.OpAdd32F, + {ir.OADD, types.TFLOAT64}: ssa.OpAdd64F, + + {ir.OSUB, types.TINT8}: ssa.OpSub8, + {ir.OSUB, types.TUINT8}: ssa.OpSub8, + {ir.OSUB, types.TINT16}: ssa.OpSub16, + {ir.OSUB, types.TUINT16}: ssa.OpSub16, + {ir.OSUB, types.TINT32}: ssa.OpSub32, + {ir.OSUB, types.TUINT32}: ssa.OpSub32, + {ir.OSUB, types.TINT64}: ssa.OpSub64, + {ir.OSUB, types.TUINT64}: ssa.OpSub64, + {ir.OSUB, types.TFLOAT32}: ssa.OpSub32F, + {ir.OSUB, types.TFLOAT64}: ssa.OpSub64F, + + {ir.ONOT, types.TBOOL}: ssa.OpNot, + + {ir.ONEG, types.TINT8}: ssa.OpNeg8, + {ir.ONEG, types.TUINT8}: ssa.OpNeg8, + {ir.ONEG, types.TINT16}: ssa.OpNeg16, + {ir.ONEG, types.TUINT16}: ssa.OpNeg16, + {ir.ONEG, types.TINT32}: ssa.OpNeg32, + {ir.ONEG, types.TUINT32}: ssa.OpNeg32, + {ir.ONEG, types.TINT64}: ssa.OpNeg64, + {ir.ONEG, types.TUINT64}: ssa.OpNeg64, + {ir.ONEG, types.TFLOAT32}: ssa.OpNeg32F, + {ir.ONEG, types.TFLOAT64}: ssa.OpNeg64F, + + {ir.OBITNOT, types.TINT8}: ssa.OpCom8, + {ir.OBITNOT, types.TUINT8}: ssa.OpCom8, + {ir.OBITNOT, types.TINT16}: ssa.OpCom16, + {ir.OBITNOT, types.TUINT16}: ssa.OpCom16, + {ir.OBITNOT, types.TINT32}: ssa.OpCom32, + {ir.OBITNOT, types.TUINT32}: ssa.OpCom32, + {ir.OBITNOT, types.TINT64}: ssa.OpCom64, + {ir.OBITNOT, types.TUINT64}: ssa.OpCom64, + + {ir.OIMAG, types.TCOMPLEX64}: ssa.OpComplexImag, + {ir.OIMAG, types.TCOMPLEX128}: ssa.OpComplexImag, + {ir.OREAL, types.TCOMPLEX64}: ssa.OpComplexReal, + {ir.OREAL, types.TCOMPLEX128}: ssa.OpComplexReal, + + {ir.OMUL, types.TINT8}: ssa.OpMul8, + {ir.OMUL, types.TUINT8}: ssa.OpMul8, + {ir.OMUL, types.TINT16}: ssa.OpMul16, + {ir.OMUL, types.TUINT16}: ssa.OpMul16, + {ir.OMUL, types.TINT32}: ssa.OpMul32, + {ir.OMUL, types.TUINT32}: ssa.OpMul32, + {ir.OMUL, types.TINT64}: ssa.OpMul64, + {ir.OMUL, types.TUINT64}: ssa.OpMul64, + {ir.OMUL, types.TFLOAT32}: ssa.OpMul32F, + {ir.OMUL, types.TFLOAT64}: ssa.OpMul64F, + + {ir.ODIV, types.TFLOAT32}: ssa.OpDiv32F, + {ir.ODIV, types.TFLOAT64}: ssa.OpDiv64F, + + {ir.ODIV, types.TINT8}: ssa.OpDiv8, + {ir.ODIV, types.TUINT8}: ssa.OpDiv8u, + {ir.ODIV, types.TINT16}: ssa.OpDiv16, + {ir.ODIV, types.TUINT16}: ssa.OpDiv16u, + {ir.ODIV, types.TINT32}: ssa.OpDiv32, + {ir.ODIV, types.TUINT32}: ssa.OpDiv32u, + {ir.ODIV, types.TINT64}: ssa.OpDiv64, + {ir.ODIV, types.TUINT64}: ssa.OpDiv64u, + + {ir.OMOD, types.TINT8}: ssa.OpMod8, + {ir.OMOD, types.TUINT8}: ssa.OpMod8u, + {ir.OMOD, types.TINT16}: ssa.OpMod16, + {ir.OMOD, types.TUINT16}: ssa.OpMod16u, + {ir.OMOD, types.TINT32}: ssa.OpMod32, + {ir.OMOD, types.TUINT32}: ssa.OpMod32u, + {ir.OMOD, types.TINT64}: ssa.OpMod64, + {ir.OMOD, types.TUINT64}: ssa.OpMod64u, + + {ir.OAND, types.TINT8}: ssa.OpAnd8, + {ir.OAND, types.TUINT8}: ssa.OpAnd8, + {ir.OAND, types.TINT16}: ssa.OpAnd16, + {ir.OAND, types.TUINT16}: ssa.OpAnd16, + {ir.OAND, types.TINT32}: ssa.OpAnd32, + {ir.OAND, types.TUINT32}: ssa.OpAnd32, + {ir.OAND, types.TINT64}: ssa.OpAnd64, + {ir.OAND, types.TUINT64}: ssa.OpAnd64, + + {ir.OOR, types.TINT8}: ssa.OpOr8, + {ir.OOR, types.TUINT8}: ssa.OpOr8, + {ir.OOR, types.TINT16}: ssa.OpOr16, + {ir.OOR, types.TUINT16}: ssa.OpOr16, + {ir.OOR, types.TINT32}: ssa.OpOr32, + {ir.OOR, types.TUINT32}: ssa.OpOr32, + {ir.OOR, types.TINT64}: ssa.OpOr64, + {ir.OOR, types.TUINT64}: ssa.OpOr64, + + {ir.OXOR, types.TINT8}: ssa.OpXor8, + {ir.OXOR, types.TUINT8}: ssa.OpXor8, + {ir.OXOR, types.TINT16}: ssa.OpXor16, + {ir.OXOR, types.TUINT16}: ssa.OpXor16, + {ir.OXOR, types.TINT32}: ssa.OpXor32, + {ir.OXOR, types.TUINT32}: ssa.OpXor32, + {ir.OXOR, types.TINT64}: ssa.OpXor64, + {ir.OXOR, types.TUINT64}: ssa.OpXor64, + + {ir.OEQ, types.TBOOL}: ssa.OpEqB, + {ir.OEQ, types.TINT8}: ssa.OpEq8, + {ir.OEQ, types.TUINT8}: ssa.OpEq8, + {ir.OEQ, types.TINT16}: ssa.OpEq16, + {ir.OEQ, types.TUINT16}: ssa.OpEq16, + {ir.OEQ, types.TINT32}: ssa.OpEq32, + {ir.OEQ, types.TUINT32}: ssa.OpEq32, + {ir.OEQ, types.TINT64}: ssa.OpEq64, + {ir.OEQ, types.TUINT64}: ssa.OpEq64, + {ir.OEQ, types.TINTER}: ssa.OpEqInter, + {ir.OEQ, types.TSLICE}: ssa.OpEqSlice, + {ir.OEQ, types.TFUNC}: ssa.OpEqPtr, + {ir.OEQ, types.TMAP}: ssa.OpEqPtr, + {ir.OEQ, types.TCHAN}: ssa.OpEqPtr, + {ir.OEQ, types.TPTR}: ssa.OpEqPtr, + {ir.OEQ, types.TUINTPTR}: ssa.OpEqPtr, + {ir.OEQ, types.TUNSAFEPTR}: ssa.OpEqPtr, + {ir.OEQ, types.TFLOAT64}: ssa.OpEq64F, + {ir.OEQ, types.TFLOAT32}: ssa.OpEq32F, + + {ir.ONE, types.TBOOL}: ssa.OpNeqB, + {ir.ONE, types.TINT8}: ssa.OpNeq8, + {ir.ONE, types.TUINT8}: ssa.OpNeq8, + {ir.ONE, types.TINT16}: ssa.OpNeq16, + {ir.ONE, types.TUINT16}: ssa.OpNeq16, + {ir.ONE, types.TINT32}: ssa.OpNeq32, + {ir.ONE, types.TUINT32}: ssa.OpNeq32, + {ir.ONE, types.TINT64}: ssa.OpNeq64, + {ir.ONE, types.TUINT64}: ssa.OpNeq64, + {ir.ONE, types.TINTER}: ssa.OpNeqInter, + {ir.ONE, types.TSLICE}: ssa.OpNeqSlice, + {ir.ONE, types.TFUNC}: ssa.OpNeqPtr, + {ir.ONE, types.TMAP}: ssa.OpNeqPtr, + {ir.ONE, types.TCHAN}: ssa.OpNeqPtr, + {ir.ONE, types.TPTR}: ssa.OpNeqPtr, + {ir.ONE, types.TUINTPTR}: ssa.OpNeqPtr, + {ir.ONE, types.TUNSAFEPTR}: ssa.OpNeqPtr, + {ir.ONE, types.TFLOAT64}: ssa.OpNeq64F, + {ir.ONE, types.TFLOAT32}: ssa.OpNeq32F, + + {ir.OLT, types.TINT8}: ssa.OpLess8, + {ir.OLT, types.TUINT8}: ssa.OpLess8U, + {ir.OLT, types.TINT16}: ssa.OpLess16, + {ir.OLT, types.TUINT16}: ssa.OpLess16U, + {ir.OLT, types.TINT32}: ssa.OpLess32, + {ir.OLT, types.TUINT32}: ssa.OpLess32U, + {ir.OLT, types.TINT64}: ssa.OpLess64, + {ir.OLT, types.TUINT64}: ssa.OpLess64U, + {ir.OLT, types.TFLOAT64}: ssa.OpLess64F, + {ir.OLT, types.TFLOAT32}: ssa.OpLess32F, + + {ir.OLE, types.TINT8}: ssa.OpLeq8, + {ir.OLE, types.TUINT8}: ssa.OpLeq8U, + {ir.OLE, types.TINT16}: ssa.OpLeq16, + {ir.OLE, types.TUINT16}: ssa.OpLeq16U, + {ir.OLE, types.TINT32}: ssa.OpLeq32, + {ir.OLE, types.TUINT32}: ssa.OpLeq32U, + {ir.OLE, types.TINT64}: ssa.OpLeq64, + {ir.OLE, types.TUINT64}: ssa.OpLeq64U, + {ir.OLE, types.TFLOAT64}: ssa.OpLeq64F, + {ir.OLE, types.TFLOAT32}: ssa.OpLeq32F, +} + +func (s *state) concreteEtype(t *types.Type) types.Kind { + e := t.Kind() + switch e { + default: + return e + case types.TINT: + if s.config.PtrSize == 8 { + return types.TINT64 + } + return types.TINT32 + case types.TUINT: + if s.config.PtrSize == 8 { + return types.TUINT64 + } + return types.TUINT32 + case types.TUINTPTR: + if s.config.PtrSize == 8 { + return types.TUINT64 + } + return types.TUINT32 + } +} + +func (s *state) ssaOp(op ir.Op, t *types.Type) ssa.Op { + etype := s.concreteEtype(t) + x, ok := opToSSA[opAndType{op, etype}] + if !ok { + s.Fatalf("unhandled binary op %v %s", op, etype) + } + return x +} + +type opAndTwoTypes struct { + op ir.Op + etype1 types.Kind + etype2 types.Kind +} + +type twoTypes struct { + etype1 types.Kind + etype2 types.Kind +} + +type twoOpsAndType struct { + op1 ssa.Op + op2 ssa.Op + intermediateType types.Kind +} + +var fpConvOpToSSA = map[twoTypes]twoOpsAndType{ + + {types.TINT8, types.TFLOAT32}: {ssa.OpSignExt8to32, ssa.OpCvt32to32F, types.TINT32}, + {types.TINT16, types.TFLOAT32}: {ssa.OpSignExt16to32, ssa.OpCvt32to32F, types.TINT32}, + {types.TINT32, types.TFLOAT32}: {ssa.OpCopy, ssa.OpCvt32to32F, types.TINT32}, + {types.TINT64, types.TFLOAT32}: {ssa.OpCopy, ssa.OpCvt64to32F, types.TINT64}, + + {types.TINT8, types.TFLOAT64}: {ssa.OpSignExt8to32, ssa.OpCvt32to64F, types.TINT32}, + {types.TINT16, types.TFLOAT64}: {ssa.OpSignExt16to32, ssa.OpCvt32to64F, types.TINT32}, + {types.TINT32, types.TFLOAT64}: {ssa.OpCopy, ssa.OpCvt32to64F, types.TINT32}, + {types.TINT64, types.TFLOAT64}: {ssa.OpCopy, ssa.OpCvt64to64F, types.TINT64}, + + {types.TFLOAT32, types.TINT8}: {ssa.OpCvt32Fto32, ssa.OpTrunc32to8, types.TINT32}, + {types.TFLOAT32, types.TINT16}: {ssa.OpCvt32Fto32, ssa.OpTrunc32to16, types.TINT32}, + {types.TFLOAT32, types.TINT32}: {ssa.OpCvt32Fto32, ssa.OpCopy, types.TINT32}, + {types.TFLOAT32, types.TINT64}: {ssa.OpCvt32Fto64, ssa.OpCopy, types.TINT64}, + + {types.TFLOAT64, types.TINT8}: {ssa.OpCvt64Fto32, ssa.OpTrunc32to8, types.TINT32}, + {types.TFLOAT64, types.TINT16}: {ssa.OpCvt64Fto32, ssa.OpTrunc32to16, types.TINT32}, + {types.TFLOAT64, types.TINT32}: {ssa.OpCvt64Fto32, ssa.OpCopy, types.TINT32}, + {types.TFLOAT64, types.TINT64}: {ssa.OpCvt64Fto64, ssa.OpCopy, types.TINT64}, + // unsigned + {types.TUINT8, types.TFLOAT32}: {ssa.OpZeroExt8to32, ssa.OpCvt32to32F, types.TINT32}, + {types.TUINT16, types.TFLOAT32}: {ssa.OpZeroExt16to32, ssa.OpCvt32to32F, types.TINT32}, + {types.TUINT32, types.TFLOAT32}: {ssa.OpZeroExt32to64, ssa.OpCvt64to32F, types.TINT64}, // go wide to dodge unsigned + {types.TUINT64, types.TFLOAT32}: {ssa.OpCopy, ssa.OpInvalid, types.TUINT64}, // Cvt64Uto32F, branchy code expansion instead + + {types.TUINT8, types.TFLOAT64}: {ssa.OpZeroExt8to32, ssa.OpCvt32to64F, types.TINT32}, + {types.TUINT16, types.TFLOAT64}: {ssa.OpZeroExt16to32, ssa.OpCvt32to64F, types.TINT32}, + {types.TUINT32, types.TFLOAT64}: {ssa.OpZeroExt32to64, ssa.OpCvt64to64F, types.TINT64}, // go wide to dodge unsigned + {types.TUINT64, types.TFLOAT64}: {ssa.OpCopy, ssa.OpInvalid, types.TUINT64}, // Cvt64Uto64F, branchy code expansion instead + + {types.TFLOAT32, types.TUINT8}: {ssa.OpCvt32Fto32, ssa.OpTrunc32to8, types.TINT32}, + {types.TFLOAT32, types.TUINT16}: {ssa.OpCvt32Fto32, ssa.OpTrunc32to16, types.TINT32}, + {types.TFLOAT32, types.TUINT32}: {ssa.OpInvalid, ssa.OpCopy, types.TINT64}, // Cvt64Fto32U, branchy code expansion instead + {types.TFLOAT32, types.TUINT64}: {ssa.OpInvalid, ssa.OpCopy, types.TUINT64}, // Cvt32Fto64U, branchy code expansion instead + + {types.TFLOAT64, types.TUINT8}: {ssa.OpCvt64Fto32, ssa.OpTrunc32to8, types.TINT32}, + {types.TFLOAT64, types.TUINT16}: {ssa.OpCvt64Fto32, ssa.OpTrunc32to16, types.TINT32}, + {types.TFLOAT64, types.TUINT32}: {ssa.OpInvalid, ssa.OpCopy, types.TINT64}, // Cvt64Fto32U, branchy code expansion instead + {types.TFLOAT64, types.TUINT64}: {ssa.OpInvalid, ssa.OpCopy, types.TUINT64}, // Cvt64Fto64U, branchy code expansion instead + + // float + {types.TFLOAT64, types.TFLOAT32}: {ssa.OpCvt64Fto32F, ssa.OpCopy, types.TFLOAT32}, + {types.TFLOAT64, types.TFLOAT64}: {ssa.OpRound64F, ssa.OpCopy, types.TFLOAT64}, + {types.TFLOAT32, types.TFLOAT32}: {ssa.OpRound32F, ssa.OpCopy, types.TFLOAT32}, + {types.TFLOAT32, types.TFLOAT64}: {ssa.OpCvt32Fto64F, ssa.OpCopy, types.TFLOAT64}, +} + +// this map is used only for 32-bit arch, and only includes the difference +// on 32-bit arch, don't use int64<->float conversion for uint32 +var fpConvOpToSSA32 = map[twoTypes]twoOpsAndType{ + {types.TUINT32, types.TFLOAT32}: {ssa.OpCopy, ssa.OpCvt32Uto32F, types.TUINT32}, + {types.TUINT32, types.TFLOAT64}: {ssa.OpCopy, ssa.OpCvt32Uto64F, types.TUINT32}, + {types.TFLOAT32, types.TUINT32}: {ssa.OpCvt32Fto32U, ssa.OpCopy, types.TUINT32}, + {types.TFLOAT64, types.TUINT32}: {ssa.OpCvt64Fto32U, ssa.OpCopy, types.TUINT32}, +} + +// uint64<->float conversions, only on machines that have instructions for that +var uint64fpConvOpToSSA = map[twoTypes]twoOpsAndType{ + {types.TUINT64, types.TFLOAT32}: {ssa.OpCopy, ssa.OpCvt64Uto32F, types.TUINT64}, + {types.TUINT64, types.TFLOAT64}: {ssa.OpCopy, ssa.OpCvt64Uto64F, types.TUINT64}, + {types.TFLOAT32, types.TUINT64}: {ssa.OpCvt32Fto64U, ssa.OpCopy, types.TUINT64}, + {types.TFLOAT64, types.TUINT64}: {ssa.OpCvt64Fto64U, ssa.OpCopy, types.TUINT64}, +} + +var shiftOpToSSA = map[opAndTwoTypes]ssa.Op{ + {ir.OLSH, types.TINT8, types.TUINT8}: ssa.OpLsh8x8, + {ir.OLSH, types.TUINT8, types.TUINT8}: ssa.OpLsh8x8, + {ir.OLSH, types.TINT8, types.TUINT16}: ssa.OpLsh8x16, + {ir.OLSH, types.TUINT8, types.TUINT16}: ssa.OpLsh8x16, + {ir.OLSH, types.TINT8, types.TUINT32}: ssa.OpLsh8x32, + {ir.OLSH, types.TUINT8, types.TUINT32}: ssa.OpLsh8x32, + {ir.OLSH, types.TINT8, types.TUINT64}: ssa.OpLsh8x64, + {ir.OLSH, types.TUINT8, types.TUINT64}: ssa.OpLsh8x64, + + {ir.OLSH, types.TINT16, types.TUINT8}: ssa.OpLsh16x8, + {ir.OLSH, types.TUINT16, types.TUINT8}: ssa.OpLsh16x8, + {ir.OLSH, types.TINT16, types.TUINT16}: ssa.OpLsh16x16, + {ir.OLSH, types.TUINT16, types.TUINT16}: ssa.OpLsh16x16, + {ir.OLSH, types.TINT16, types.TUINT32}: ssa.OpLsh16x32, + {ir.OLSH, types.TUINT16, types.TUINT32}: ssa.OpLsh16x32, + {ir.OLSH, types.TINT16, types.TUINT64}: ssa.OpLsh16x64, + {ir.OLSH, types.TUINT16, types.TUINT64}: ssa.OpLsh16x64, + + {ir.OLSH, types.TINT32, types.TUINT8}: ssa.OpLsh32x8, + {ir.OLSH, types.TUINT32, types.TUINT8}: ssa.OpLsh32x8, + {ir.OLSH, types.TINT32, types.TUINT16}: ssa.OpLsh32x16, + {ir.OLSH, types.TUINT32, types.TUINT16}: ssa.OpLsh32x16, + {ir.OLSH, types.TINT32, types.TUINT32}: ssa.OpLsh32x32, + {ir.OLSH, types.TUINT32, types.TUINT32}: ssa.OpLsh32x32, + {ir.OLSH, types.TINT32, types.TUINT64}: ssa.OpLsh32x64, + {ir.OLSH, types.TUINT32, types.TUINT64}: ssa.OpLsh32x64, + + {ir.OLSH, types.TINT64, types.TUINT8}: ssa.OpLsh64x8, + {ir.OLSH, types.TUINT64, types.TUINT8}: ssa.OpLsh64x8, + {ir.OLSH, types.TINT64, types.TUINT16}: ssa.OpLsh64x16, + {ir.OLSH, types.TUINT64, types.TUINT16}: ssa.OpLsh64x16, + {ir.OLSH, types.TINT64, types.TUINT32}: ssa.OpLsh64x32, + {ir.OLSH, types.TUINT64, types.TUINT32}: ssa.OpLsh64x32, + {ir.OLSH, types.TINT64, types.TUINT64}: ssa.OpLsh64x64, + {ir.OLSH, types.TUINT64, types.TUINT64}: ssa.OpLsh64x64, + + {ir.ORSH, types.TINT8, types.TUINT8}: ssa.OpRsh8x8, + {ir.ORSH, types.TUINT8, types.TUINT8}: ssa.OpRsh8Ux8, + {ir.ORSH, types.TINT8, types.TUINT16}: ssa.OpRsh8x16, + {ir.ORSH, types.TUINT8, types.TUINT16}: ssa.OpRsh8Ux16, + {ir.ORSH, types.TINT8, types.TUINT32}: ssa.OpRsh8x32, + {ir.ORSH, types.TUINT8, types.TUINT32}: ssa.OpRsh8Ux32, + {ir.ORSH, types.TINT8, types.TUINT64}: ssa.OpRsh8x64, + {ir.ORSH, types.TUINT8, types.TUINT64}: ssa.OpRsh8Ux64, + + {ir.ORSH, types.TINT16, types.TUINT8}: ssa.OpRsh16x8, + {ir.ORSH, types.TUINT16, types.TUINT8}: ssa.OpRsh16Ux8, + {ir.ORSH, types.TINT16, types.TUINT16}: ssa.OpRsh16x16, + {ir.ORSH, types.TUINT16, types.TUINT16}: ssa.OpRsh16Ux16, + {ir.ORSH, types.TINT16, types.TUINT32}: ssa.OpRsh16x32, + {ir.ORSH, types.TUINT16, types.TUINT32}: ssa.OpRsh16Ux32, + {ir.ORSH, types.TINT16, types.TUINT64}: ssa.OpRsh16x64, + {ir.ORSH, types.TUINT16, types.TUINT64}: ssa.OpRsh16Ux64, + + {ir.ORSH, types.TINT32, types.TUINT8}: ssa.OpRsh32x8, + {ir.ORSH, types.TUINT32, types.TUINT8}: ssa.OpRsh32Ux8, + {ir.ORSH, types.TINT32, types.TUINT16}: ssa.OpRsh32x16, + {ir.ORSH, types.TUINT32, types.TUINT16}: ssa.OpRsh32Ux16, + {ir.ORSH, types.TINT32, types.TUINT32}: ssa.OpRsh32x32, + {ir.ORSH, types.TUINT32, types.TUINT32}: ssa.OpRsh32Ux32, + {ir.ORSH, types.TINT32, types.TUINT64}: ssa.OpRsh32x64, + {ir.ORSH, types.TUINT32, types.TUINT64}: ssa.OpRsh32Ux64, + + {ir.ORSH, types.TINT64, types.TUINT8}: ssa.OpRsh64x8, + {ir.ORSH, types.TUINT64, types.TUINT8}: ssa.OpRsh64Ux8, + {ir.ORSH, types.TINT64, types.TUINT16}: ssa.OpRsh64x16, + {ir.ORSH, types.TUINT64, types.TUINT16}: ssa.OpRsh64Ux16, + {ir.ORSH, types.TINT64, types.TUINT32}: ssa.OpRsh64x32, + {ir.ORSH, types.TUINT64, types.TUINT32}: ssa.OpRsh64Ux32, + {ir.ORSH, types.TINT64, types.TUINT64}: ssa.OpRsh64x64, + {ir.ORSH, types.TUINT64, types.TUINT64}: ssa.OpRsh64Ux64, +} + +func (s *state) ssaShiftOp(op ir.Op, t *types.Type, u *types.Type) ssa.Op { + etype1 := s.concreteEtype(t) + etype2 := s.concreteEtype(u) + x, ok := shiftOpToSSA[opAndTwoTypes{op, etype1, etype2}] + if !ok { + s.Fatalf("unhandled shift op %v etype=%s/%s", op, etype1, etype2) + } + return x +} + +func (s *state) uintptrConstant(v uint64) *ssa.Value { + if s.config.PtrSize == 4 { + return s.newValue0I(ssa.OpConst32, types.Types[types.TUINTPTR], int64(v)) + } + return s.newValue0I(ssa.OpConst64, types.Types[types.TUINTPTR], int64(v)) +} + +func (s *state) conv(n ir.Node, v *ssa.Value, ft, tt *types.Type) *ssa.Value { + if ft.IsBoolean() && tt.IsKind(types.TUINT8) { + // Bool -> uint8 is generated internally when indexing into runtime.staticbyte. + return s.newValue1(ssa.OpCvtBoolToUint8, tt, v) + } + if ft.IsInteger() && tt.IsInteger() { + var op ssa.Op + if tt.Size() == ft.Size() { + op = ssa.OpCopy + } else if tt.Size() < ft.Size() { + // truncation + switch 10*ft.Size() + tt.Size() { + case 21: + op = ssa.OpTrunc16to8 + case 41: + op = ssa.OpTrunc32to8 + case 42: + op = ssa.OpTrunc32to16 + case 81: + op = ssa.OpTrunc64to8 + case 82: + op = ssa.OpTrunc64to16 + case 84: + op = ssa.OpTrunc64to32 + default: + s.Fatalf("weird integer truncation %v -> %v", ft, tt) + } + } else if ft.IsSigned() { + // sign extension + switch 10*ft.Size() + tt.Size() { + case 12: + op = ssa.OpSignExt8to16 + case 14: + op = ssa.OpSignExt8to32 + case 18: + op = ssa.OpSignExt8to64 + case 24: + op = ssa.OpSignExt16to32 + case 28: + op = ssa.OpSignExt16to64 + case 48: + op = ssa.OpSignExt32to64 + default: + s.Fatalf("bad integer sign extension %v -> %v", ft, tt) + } + } else { + // zero extension + switch 10*ft.Size() + tt.Size() { + case 12: + op = ssa.OpZeroExt8to16 + case 14: + op = ssa.OpZeroExt8to32 + case 18: + op = ssa.OpZeroExt8to64 + case 24: + op = ssa.OpZeroExt16to32 + case 28: + op = ssa.OpZeroExt16to64 + case 48: + op = ssa.OpZeroExt32to64 + default: + s.Fatalf("weird integer sign extension %v -> %v", ft, tt) + } + } + return s.newValue1(op, tt, v) + } + + if ft.IsComplex() && tt.IsComplex() { + var op ssa.Op + if ft.Size() == tt.Size() { + switch ft.Size() { + case 8: + op = ssa.OpRound32F + case 16: + op = ssa.OpRound64F + default: + s.Fatalf("weird complex conversion %v -> %v", ft, tt) + } + } else if ft.Size() == 8 && tt.Size() == 16 { + op = ssa.OpCvt32Fto64F + } else if ft.Size() == 16 && tt.Size() == 8 { + op = ssa.OpCvt64Fto32F + } else { + s.Fatalf("weird complex conversion %v -> %v", ft, tt) + } + ftp := types.FloatForComplex(ft) + ttp := types.FloatForComplex(tt) + return s.newValue2(ssa.OpComplexMake, tt, + s.newValueOrSfCall1(op, ttp, s.newValue1(ssa.OpComplexReal, ftp, v)), + s.newValueOrSfCall1(op, ttp, s.newValue1(ssa.OpComplexImag, ftp, v))) + } + + if tt.IsComplex() { // and ft is not complex + // Needed for generics support - can't happen in normal Go code. + et := types.FloatForComplex(tt) + v = s.conv(n, v, ft, et) + return s.newValue2(ssa.OpComplexMake, tt, v, s.zeroVal(et)) + } + + if ft.IsFloat() || tt.IsFloat() { + cft, ctt := s.concreteEtype(ft), s.concreteEtype(tt) + conv, ok := fpConvOpToSSA[twoTypes{cft, ctt}] + // there's a change to a conversion-op table, this restores the old behavior if ConvertHash is false. + // use salted hash to distinguish unsigned convert at a Pos from signed convert at a Pos + if ctt == types.TUINT32 && ft.IsFloat() && !base.ConvertHash.MatchPosWithInfo(n.Pos(), "U", nil) { + // revert to old behavior + conv.op1 = ssa.OpCvt64Fto64 + if cft == types.TFLOAT32 { + conv.op1 = ssa.OpCvt32Fto64 + } + conv.op2 = ssa.OpTrunc64to32 + + } + if s.config.RegSize == 4 && Arch.LinkArch.Family != sys.MIPS && !s.softFloat { + if conv1, ok1 := fpConvOpToSSA32[twoTypes{s.concreteEtype(ft), s.concreteEtype(tt)}]; ok1 { + conv = conv1 + } + } + if Arch.LinkArch.Family == sys.ARM64 || Arch.LinkArch.Family == sys.Wasm || Arch.LinkArch.Family == sys.S390X || s.softFloat { + if conv1, ok1 := uint64fpConvOpToSSA[twoTypes{s.concreteEtype(ft), s.concreteEtype(tt)}]; ok1 { + conv = conv1 + } + } + + if Arch.LinkArch.Family == sys.MIPS && !s.softFloat { + if ft.Size() == 4 && ft.IsInteger() && !ft.IsSigned() { + // tt is float32 or float64, and ft is also unsigned + if tt.Size() == 4 { + return s.uint32Tofloat32(n, v, ft, tt) + } + if tt.Size() == 8 { + return s.uint32Tofloat64(n, v, ft, tt) + } + } else if tt.Size() == 4 && tt.IsInteger() && !tt.IsSigned() { + // ft is float32 or float64, and tt is unsigned integer + if ft.Size() == 4 { + return s.float32ToUint32(n, v, ft, tt) + } + if ft.Size() == 8 { + return s.float64ToUint32(n, v, ft, tt) + } + } + } + + if !ok { + s.Fatalf("weird float conversion %v -> %v", ft, tt) + } + op1, op2, it := conv.op1, conv.op2, conv.intermediateType + + if op1 != ssa.OpInvalid && op2 != ssa.OpInvalid { + // normal case, not tripping over unsigned 64 + if op1 == ssa.OpCopy { + if op2 == ssa.OpCopy { + return v + } + return s.newValueOrSfCall1(op2, tt, v) + } + if op2 == ssa.OpCopy { + return s.newValueOrSfCall1(op1, tt, v) + } + return s.newValueOrSfCall1(op2, tt, s.newValueOrSfCall1(op1, types.Types[it], v)) + } + // Tricky 64-bit unsigned cases. + if ft.IsInteger() { + // tt is float32 or float64, and ft is also unsigned + if tt.Size() == 4 { + return s.uint64Tofloat32(n, v, ft, tt) + } + if tt.Size() == 8 { + return s.uint64Tofloat64(n, v, ft, tt) + } + s.Fatalf("weird unsigned integer to float conversion %v -> %v", ft, tt) + } + // ft is float32 or float64, and tt is unsigned integer + if ft.Size() == 4 { + switch tt.Size() { + case 8: + return s.float32ToUint64(n, v, ft, tt) + case 4, 2, 1: + // TODO should 2 and 1 saturate or truncate? + return s.float32ToUint32(n, v, ft, tt) + } + } + if ft.Size() == 8 { + switch tt.Size() { + case 8: + return s.float64ToUint64(n, v, ft, tt) + case 4, 2, 1: + // TODO should 2 and 1 saturate or truncate? + return s.float64ToUint32(n, v, ft, tt) + } + + } + s.Fatalf("weird float to unsigned integer conversion %v -> %v", ft, tt) + return nil + } + + s.Fatalf("unhandled OCONV %s -> %s", ft.Kind(), tt.Kind()) + return nil +} + +// expr converts the expression n to ssa, adds it to s and returns the ssa result. +func (s *state) expr(n ir.Node) *ssa.Value { + return s.exprCheckPtr(n, true) +} + +func (s *state) exprCheckPtr(n ir.Node, checkPtrOK bool) *ssa.Value { + if ir.HasUniquePos(n) { + // ONAMEs and named OLITERALs have the line number + // of the decl, not the use. See issue 14742. + s.pushLine(n.Pos()) + defer s.popLine() + } + + s.stmtList(n.Init()) + switch n.Op() { + case ir.OBYTES2STRTMP: + n := n.(*ir.ConvExpr) + slice := s.expr(n.X) + ptr := s.newValue1(ssa.OpSlicePtr, s.f.Config.Types.BytePtr, slice) + len := s.newValue1(ssa.OpSliceLen, types.Types[types.TINT], slice) + return s.newValue2(ssa.OpStringMake, n.Type(), ptr, len) + case ir.OSTR2BYTESTMP: + n := n.(*ir.ConvExpr) + str := s.expr(n.X) + ptr := s.newValue1(ssa.OpStringPtr, s.f.Config.Types.BytePtr, str) + if !n.NonNil() { + // We need to ensure []byte("") evaluates to []byte{}, and not []byte(nil). + // + // TODO(mdempsky): Investigate using "len != 0" instead of "ptr != nil". + cond := s.newValue2(ssa.OpNeqPtr, types.Types[types.TBOOL], ptr, s.constNil(ptr.Type)) + zerobase := s.newValue1A(ssa.OpAddr, ptr.Type, ir.Syms.Zerobase, s.sb) + ptr = s.ternary(cond, ptr, zerobase) + } + len := s.newValue1(ssa.OpStringLen, types.Types[types.TINT], str) + return s.newValue3(ssa.OpSliceMake, n.Type(), ptr, len, len) + case ir.OCFUNC: + n := n.(*ir.UnaryExpr) + aux := n.X.(*ir.Name).Linksym() + // OCFUNC is used to build function values, which must + // always reference ABIInternal entry points. + if aux.ABI() != obj.ABIInternal { + s.Fatalf("expected ABIInternal: %v", aux.ABI()) + } + return s.entryNewValue1A(ssa.OpAddr, n.Type(), aux, s.sb) + case ir.ONAME: + n := n.(*ir.Name) + if n.Class == ir.PFUNC { + // "value" of a function is the address of the function's closure + sym := staticdata.FuncLinksym(n) + return s.entryNewValue1A(ssa.OpAddr, types.NewPtr(n.Type()), sym, s.sb) + } + if s.canSSA(n) { + return s.variable(n, n.Type()) + } + return s.load(n.Type(), s.addr(n)) + case ir.OLINKSYMOFFSET: + n := n.(*ir.LinksymOffsetExpr) + return s.load(n.Type(), s.addr(n)) + case ir.ONIL: + n := n.(*ir.NilExpr) + t := n.Type() + switch { + case t.IsSlice(): + return s.constSlice(t) + case t.IsInterface(): + return s.constInterface(t) + default: + return s.constNil(t) + } + case ir.OLITERAL: + switch u := n.Val(); u.Kind() { + case constant.Int: + i := ir.IntVal(n.Type(), u) + switch n.Type().Size() { + case 1: + return s.constInt8(n.Type(), int8(i)) + case 2: + return s.constInt16(n.Type(), int16(i)) + case 4: + return s.constInt32(n.Type(), int32(i)) + case 8: + return s.constInt64(n.Type(), i) + default: + s.Fatalf("bad integer size %d", n.Type().Size()) + return nil + } + case constant.String: + i := constant.StringVal(u) + if i == "" { + return s.constEmptyString(n.Type()) + } + return s.entryNewValue0A(ssa.OpConstString, n.Type(), ssa.StringToAux(i)) + case constant.Bool: + return s.constBool(constant.BoolVal(u)) + case constant.Float: + f, _ := constant.Float64Val(u) + switch n.Type().Size() { + case 4: + return s.constFloat32(n.Type(), f) + case 8: + return s.constFloat64(n.Type(), f) + default: + s.Fatalf("bad float size %d", n.Type().Size()) + return nil + } + case constant.Complex: + re, _ := constant.Float64Val(constant.Real(u)) + im, _ := constant.Float64Val(constant.Imag(u)) + switch n.Type().Size() { + case 8: + pt := types.Types[types.TFLOAT32] + return s.newValue2(ssa.OpComplexMake, n.Type(), + s.constFloat32(pt, re), + s.constFloat32(pt, im)) + case 16: + pt := types.Types[types.TFLOAT64] + return s.newValue2(ssa.OpComplexMake, n.Type(), + s.constFloat64(pt, re), + s.constFloat64(pt, im)) + default: + s.Fatalf("bad complex size %d", n.Type().Size()) + return nil + } + default: + s.Fatalf("unhandled OLITERAL %v", u.Kind()) + return nil + } + case ir.OCONVNOP: + n := n.(*ir.ConvExpr) + to := n.Type() + from := n.X.Type() + + // Assume everything will work out, so set up our return value. + // Anything interesting that happens from here is a fatal. + x := s.expr(n.X) + if to == from { + return x + } + + // Special case for not confusing GC and liveness. + // We don't want pointers accidentally classified + // as not-pointers or vice-versa because of copy + // elision. + if to.IsPtrShaped() != from.IsPtrShaped() { + return s.newValue2(ssa.OpConvert, to, x, s.mem()) + } + + v := s.newValue1(ssa.OpCopy, to, x) // ensure that v has the right type + + // CONVNOP closure + if to.Kind() == types.TFUNC && from.IsPtrShaped() { + return v + } + + // named <--> unnamed type or typed <--> untyped const + if from.Kind() == to.Kind() { + return v + } + + // unsafe.Pointer <--> *T + if to.IsUnsafePtr() && from.IsPtrShaped() || from.IsUnsafePtr() && to.IsPtrShaped() { + if s.checkPtrEnabled && checkPtrOK && to.IsPtr() && from.IsUnsafePtr() { + s.checkPtrAlignment(n, v, nil) + } + return v + } + + // map <--> *internal/runtime/maps.Map + mt := types.NewPtr(reflectdata.MapType()) + if to.Kind() == types.TMAP && from == mt { + return v + } + + types.CalcSize(from) + types.CalcSize(to) + if from.Size() != to.Size() { + s.Fatalf("CONVNOP width mismatch %v (%d) -> %v (%d)\n", from, from.Size(), to, to.Size()) + return nil + } + if etypesign(from.Kind()) != etypesign(to.Kind()) { + s.Fatalf("CONVNOP sign mismatch %v (%s) -> %v (%s)\n", from, from.Kind(), to, to.Kind()) + return nil + } + + if base.Flag.Cfg.Instrumenting { + // These appear to be fine, but they fail the + // integer constraint below, so okay them here. + // Sample non-integer conversion: map[string]string -> *uint8 + return v + } + + if etypesign(from.Kind()) == 0 { + s.Fatalf("CONVNOP unrecognized non-integer %v -> %v\n", from, to) + return nil + } + + // integer, same width, same sign + return v + + case ir.OCONV: + n := n.(*ir.ConvExpr) + x := s.expr(n.X) + return s.conv(n, x, n.X.Type(), n.Type()) + + case ir.ODOTTYPE: + n := n.(*ir.TypeAssertExpr) + res, _ := s.dottype(n, false) + return res + + case ir.ODYNAMICDOTTYPE: + n := n.(*ir.DynamicTypeAssertExpr) + res, _ := s.dynamicDottype(n, false) + return res + + // binary ops + case ir.OLT, ir.OEQ, ir.ONE, ir.OLE, ir.OGE, ir.OGT: + n := n.(*ir.BinaryExpr) + a := s.expr(n.X) + b := s.expr(n.Y) + if n.X.Type().IsComplex() { + pt := types.FloatForComplex(n.X.Type()) + op := s.ssaOp(ir.OEQ, pt) + r := s.newValueOrSfCall2(op, types.Types[types.TBOOL], s.newValue1(ssa.OpComplexReal, pt, a), s.newValue1(ssa.OpComplexReal, pt, b)) + i := s.newValueOrSfCall2(op, types.Types[types.TBOOL], s.newValue1(ssa.OpComplexImag, pt, a), s.newValue1(ssa.OpComplexImag, pt, b)) + c := s.newValue2(ssa.OpAndB, types.Types[types.TBOOL], r, i) + switch n.Op() { + case ir.OEQ: + return c + case ir.ONE: + return s.newValue1(ssa.OpNot, types.Types[types.TBOOL], c) + default: + s.Fatalf("ordered complex compare %v", n.Op()) + } + } + + // Convert OGE and OGT into OLE and OLT. + op := n.Op() + switch op { + case ir.OGE: + op, a, b = ir.OLE, b, a + case ir.OGT: + op, a, b = ir.OLT, b, a + } + if n.X.Type().IsFloat() { + // float comparison + return s.newValueOrSfCall2(s.ssaOp(op, n.X.Type()), types.Types[types.TBOOL], a, b) + } + // integer comparison + return s.newValue2(s.ssaOp(op, n.X.Type()), types.Types[types.TBOOL], a, b) + case ir.OMUL: + n := n.(*ir.BinaryExpr) + a := s.expr(n.X) + b := s.expr(n.Y) + if n.Type().IsComplex() { + mulop := ssa.OpMul64F + addop := ssa.OpAdd64F + subop := ssa.OpSub64F + pt := types.FloatForComplex(n.Type()) // Could be Float32 or Float64 + wt := types.Types[types.TFLOAT64] // Compute in Float64 to minimize cancellation error + + areal := s.newValue1(ssa.OpComplexReal, pt, a) + breal := s.newValue1(ssa.OpComplexReal, pt, b) + aimag := s.newValue1(ssa.OpComplexImag, pt, a) + bimag := s.newValue1(ssa.OpComplexImag, pt, b) + + if pt != wt { // Widen for calculation + areal = s.newValueOrSfCall1(ssa.OpCvt32Fto64F, wt, areal) + breal = s.newValueOrSfCall1(ssa.OpCvt32Fto64F, wt, breal) + aimag = s.newValueOrSfCall1(ssa.OpCvt32Fto64F, wt, aimag) + bimag = s.newValueOrSfCall1(ssa.OpCvt32Fto64F, wt, bimag) + } + + xreal := s.newValueOrSfCall2(subop, wt, s.newValueOrSfCall2(mulop, wt, areal, breal), s.newValueOrSfCall2(mulop, wt, aimag, bimag)) + ximag := s.newValueOrSfCall2(addop, wt, s.newValueOrSfCall2(mulop, wt, areal, bimag), s.newValueOrSfCall2(mulop, wt, aimag, breal)) + + if pt != wt { // Narrow to store back + xreal = s.newValueOrSfCall1(ssa.OpCvt64Fto32F, pt, xreal) + ximag = s.newValueOrSfCall1(ssa.OpCvt64Fto32F, pt, ximag) + } + + return s.newValue2(ssa.OpComplexMake, n.Type(), xreal, ximag) + } + + if n.Type().IsFloat() { + return s.newValueOrSfCall2(s.ssaOp(n.Op(), n.Type()), a.Type, a, b) + } + + return s.newValue2(s.ssaOp(n.Op(), n.Type()), a.Type, a, b) + + case ir.ODIV: + n := n.(*ir.BinaryExpr) + a := s.expr(n.X) + b := s.expr(n.Y) + if n.Type().IsComplex() { + // TODO this is not executed because the front-end substitutes a runtime call. + // That probably ought to change; with modest optimization the widen/narrow + // conversions could all be elided in larger expression trees. + mulop := ssa.OpMul64F + addop := ssa.OpAdd64F + subop := ssa.OpSub64F + divop := ssa.OpDiv64F + pt := types.FloatForComplex(n.Type()) // Could be Float32 or Float64 + wt := types.Types[types.TFLOAT64] // Compute in Float64 to minimize cancellation error + + areal := s.newValue1(ssa.OpComplexReal, pt, a) + breal := s.newValue1(ssa.OpComplexReal, pt, b) + aimag := s.newValue1(ssa.OpComplexImag, pt, a) + bimag := s.newValue1(ssa.OpComplexImag, pt, b) + + if pt != wt { // Widen for calculation + areal = s.newValueOrSfCall1(ssa.OpCvt32Fto64F, wt, areal) + breal = s.newValueOrSfCall1(ssa.OpCvt32Fto64F, wt, breal) + aimag = s.newValueOrSfCall1(ssa.OpCvt32Fto64F, wt, aimag) + bimag = s.newValueOrSfCall1(ssa.OpCvt32Fto64F, wt, bimag) + } + + denom := s.newValueOrSfCall2(addop, wt, s.newValueOrSfCall2(mulop, wt, breal, breal), s.newValueOrSfCall2(mulop, wt, bimag, bimag)) + xreal := s.newValueOrSfCall2(addop, wt, s.newValueOrSfCall2(mulop, wt, areal, breal), s.newValueOrSfCall2(mulop, wt, aimag, bimag)) + ximag := s.newValueOrSfCall2(subop, wt, s.newValueOrSfCall2(mulop, wt, aimag, breal), s.newValueOrSfCall2(mulop, wt, areal, bimag)) + + // TODO not sure if this is best done in wide precision or narrow + // Double-rounding might be an issue. + // Note that the pre-SSA implementation does the entire calculation + // in wide format, so wide is compatible. + xreal = s.newValueOrSfCall2(divop, wt, xreal, denom) + ximag = s.newValueOrSfCall2(divop, wt, ximag, denom) + + if pt != wt { // Narrow to store back + xreal = s.newValueOrSfCall1(ssa.OpCvt64Fto32F, pt, xreal) + ximag = s.newValueOrSfCall1(ssa.OpCvt64Fto32F, pt, ximag) + } + return s.newValue2(ssa.OpComplexMake, n.Type(), xreal, ximag) + } + if n.Type().IsFloat() { + return s.newValueOrSfCall2(s.ssaOp(n.Op(), n.Type()), a.Type, a, b) + } + return s.intDivide(n, a, b) + case ir.OMOD: + n := n.(*ir.BinaryExpr) + a := s.expr(n.X) + b := s.expr(n.Y) + return s.intDivide(n, a, b) + case ir.OADD, ir.OSUB: + n := n.(*ir.BinaryExpr) + a := s.expr(n.X) + b := s.expr(n.Y) + if n.Type().IsComplex() { + pt := types.FloatForComplex(n.Type()) + op := s.ssaOp(n.Op(), pt) + return s.newValue2(ssa.OpComplexMake, n.Type(), + s.newValueOrSfCall2(op, pt, s.newValue1(ssa.OpComplexReal, pt, a), s.newValue1(ssa.OpComplexReal, pt, b)), + s.newValueOrSfCall2(op, pt, s.newValue1(ssa.OpComplexImag, pt, a), s.newValue1(ssa.OpComplexImag, pt, b))) + } + if n.Type().IsFloat() { + return s.newValueOrSfCall2(s.ssaOp(n.Op(), n.Type()), a.Type, a, b) + } + return s.newValue2(s.ssaOp(n.Op(), n.Type()), a.Type, a, b) + case ir.OAND, ir.OOR, ir.OXOR: + n := n.(*ir.BinaryExpr) + a := s.expr(n.X) + b := s.expr(n.Y) + return s.newValue2(s.ssaOp(n.Op(), n.Type()), a.Type, a, b) + case ir.OANDNOT: + n := n.(*ir.BinaryExpr) + a := s.expr(n.X) + b := s.expr(n.Y) + b = s.newValue1(s.ssaOp(ir.OBITNOT, b.Type), b.Type, b) + return s.newValue2(s.ssaOp(ir.OAND, n.Type()), a.Type, a, b) + case ir.OLSH, ir.ORSH: + n := n.(*ir.BinaryExpr) + a := s.expr(n.X) + b := s.expr(n.Y) + bt := b.Type + if bt.IsSigned() { + cmp := s.newValue2(s.ssaOp(ir.OLE, bt), types.Types[types.TBOOL], s.zeroVal(bt), b) + s.check(cmp, ir.Syms.Panicshift) + bt = bt.ToUnsigned() + } + return s.newValue2(s.ssaShiftOp(n.Op(), n.Type(), bt), a.Type, a, b) + case ir.OANDAND, ir.OOROR: + // To implement OANDAND (and OOROR), we introduce a + // new temporary variable to hold the result. The + // variable is associated with the OANDAND node in the + // s.vars table (normally variables are only + // associated with ONAME nodes). We convert + // A && B + // to + // var = A + // if var { + // var = B + // } + // Using var in the subsequent block introduces the + // necessary phi variable. + n := n.(*ir.LogicalExpr) + el := s.expr(n.X) + s.vars[n] = el + + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(el) + // In theory, we should set b.Likely here based on context. + // However, gc only gives us likeliness hints + // in a single place, for plain OIF statements, + // and passing around context is finicky, so don't bother for now. + + bRight := s.f.NewBlock(ssa.BlockPlain) + bResult := s.f.NewBlock(ssa.BlockPlain) + if n.Op() == ir.OANDAND { + b.AddEdgeTo(bRight) + b.AddEdgeTo(bResult) + } else if n.Op() == ir.OOROR { + b.AddEdgeTo(bResult) + b.AddEdgeTo(bRight) + } + + s.startBlock(bRight) + er := s.expr(n.Y) + s.vars[n] = er + + b = s.endBlock() + b.AddEdgeTo(bResult) + + s.startBlock(bResult) + return s.variable(n, types.Types[types.TBOOL]) + case ir.OCOMPLEX: + n := n.(*ir.BinaryExpr) + r := s.expr(n.X) + i := s.expr(n.Y) + return s.newValue2(ssa.OpComplexMake, n.Type(), r, i) + + // unary ops + case ir.ONEG: + n := n.(*ir.UnaryExpr) + a := s.expr(n.X) + if n.Type().IsComplex() { + tp := types.FloatForComplex(n.Type()) + negop := s.ssaOp(n.Op(), tp) + return s.newValue2(ssa.OpComplexMake, n.Type(), + s.newValue1(negop, tp, s.newValue1(ssa.OpComplexReal, tp, a)), + s.newValue1(negop, tp, s.newValue1(ssa.OpComplexImag, tp, a))) + } + return s.newValue1(s.ssaOp(n.Op(), n.Type()), a.Type, a) + case ir.ONOT, ir.OBITNOT: + n := n.(*ir.UnaryExpr) + a := s.expr(n.X) + return s.newValue1(s.ssaOp(n.Op(), n.Type()), a.Type, a) + case ir.OIMAG, ir.OREAL: + n := n.(*ir.UnaryExpr) + a := s.expr(n.X) + return s.newValue1(s.ssaOp(n.Op(), n.X.Type()), n.Type(), a) + case ir.OPLUS: + n := n.(*ir.UnaryExpr) + return s.expr(n.X) + + case ir.OADDR: + n := n.(*ir.AddrExpr) + return s.addr(n.X) + + case ir.ORESULT: + n := n.(*ir.ResultExpr) + if s.prevCall == nil || s.prevCall.Op != ssa.OpStaticLECall && s.prevCall.Op != ssa.OpInterLECall && s.prevCall.Op != ssa.OpClosureLECall { + panic("Expected to see a previous call") + } + which := n.Index + if which == -1 { + panic(fmt.Errorf("ORESULT %v does not match call %s", n, s.prevCall)) + } + return s.resultOfCall(s.prevCall, which, n.Type()) + + case ir.ODEREF: + n := n.(*ir.StarExpr) + p := s.exprPtr(n.X, n.Bounded(), n.Pos()) + return s.load(n.Type(), p) + + case ir.ODOT: + n := n.(*ir.SelectorExpr) + if n.X.Op() == ir.OSTRUCTLIT { + // All literals with nonzero fields have already been + // rewritten during walk. Any that remain are just T{} + // or equivalents. Use the zero value. + if !ir.IsZero(n.X) { + s.Fatalf("literal with nonzero value in SSA: %v", n.X) + } + return s.zeroVal(n.Type()) + } + // If n is addressable and can't be represented in + // SSA, then load just the selected field. This + // prevents false memory dependencies in race/msan/asan + // instrumentation. + if ir.IsAddressable(n) && !s.canSSA(n) { + p := s.addr(n) + return s.load(n.Type(), p) + } + v := s.expr(n.X) + return s.newValue1I(ssa.OpStructSelect, n.Type(), int64(fieldIdx(n)), v) + + case ir.ODOTPTR: + n := n.(*ir.SelectorExpr) + p := s.exprPtr(n.X, n.Bounded(), n.Pos()) + p = s.newValue1I(ssa.OpOffPtr, types.NewPtr(n.Type()), n.Offset(), p) + return s.load(n.Type(), p) + + case ir.OINDEX: + n := n.(*ir.IndexExpr) + switch { + case n.X.Type().IsString(): + if n.Bounded() && ir.IsConst(n.X, constant.String) && ir.IsConst(n.Index, constant.Int) { + // Replace "abc"[1] with 'b'. + // Delayed until now because "abc"[1] is not an ideal constant. + // See test/fixedbugs/issue11370.go. + return s.newValue0I(ssa.OpConst8, types.Types[types.TUINT8], int64(int8(ir.StringVal(n.X)[ir.Int64Val(n.Index)]))) + } + a := s.expr(n.X) + i := s.expr(n.Index) + len := s.newValue1(ssa.OpStringLen, types.Types[types.TINT], a) + i = s.boundsCheck(i, len, ssa.BoundsIndex, n.Bounded()) + ptrtyp := s.f.Config.Types.BytePtr + ptr := s.newValue1(ssa.OpStringPtr, ptrtyp, a) + if ir.IsConst(n.Index, constant.Int) { + ptr = s.newValue1I(ssa.OpOffPtr, ptrtyp, ir.Int64Val(n.Index), ptr) + } else { + ptr = s.newValue2(ssa.OpAddPtr, ptrtyp, ptr, i) + } + return s.load(types.Types[types.TUINT8], ptr) + case n.X.Type().IsSlice(): + p := s.addr(n) + return s.load(n.X.Type().Elem(), p) + case n.X.Type().IsArray(): + if ssa.CanSSA(n.X.Type()) { + // SSA can handle arrays of length at most 1. + bound := n.X.Type().NumElem() + a := s.expr(n.X) + i := s.expr(n.Index) + if bound == 0 { + // Bounds check will never succeed. Might as well + // use constants for the bounds check. + z := s.constInt(types.Types[types.TINT], 0) + s.boundsCheck(z, z, ssa.BoundsIndex, false) + // The return value won't be live, return junk. + // But not quite junk, in case bounds checks are turned off. See issue 48092. + return s.zeroVal(n.Type()) + } + len := s.constInt(types.Types[types.TINT], bound) + s.boundsCheck(i, len, ssa.BoundsIndex, n.Bounded()) // checks i == 0 + return s.newValue1I(ssa.OpArraySelect, n.Type(), 0, a) + } + p := s.addr(n) + return s.load(n.X.Type().Elem(), p) + default: + s.Fatalf("bad type for index %v", n.X.Type()) + return nil + } + + case ir.OLEN, ir.OCAP: + n := n.(*ir.UnaryExpr) + // Note: all constant cases are handled by the frontend. If len or cap + // makes it here, we want the side effects of the argument. See issue 72844. + a := s.expr(n.X) + t := n.X.Type() + switch { + case t.IsSlice(): + op := ssa.OpSliceLen + if n.Op() == ir.OCAP { + op = ssa.OpSliceCap + } + return s.newValue1(op, types.Types[types.TINT], a) + case t.IsString(): // string; not reachable for OCAP + return s.newValue1(ssa.OpStringLen, types.Types[types.TINT], a) + case t.IsMap(), t.IsChan(): + return s.referenceTypeBuiltin(n, a) + case t.IsArray(): + return s.constInt(types.Types[types.TINT], t.NumElem()) + case t.IsPtr() && t.Elem().IsArray(): + return s.constInt(types.Types[types.TINT], t.Elem().NumElem()) + default: + s.Fatalf("bad type in len/cap: %v", t) + return nil + } + + case ir.OSPTR: + n := n.(*ir.UnaryExpr) + a := s.expr(n.X) + if n.X.Type().IsSlice() { + if n.Bounded() { + return s.newValue1(ssa.OpSlicePtr, n.Type(), a) + } + return s.newValue1(ssa.OpSlicePtrUnchecked, n.Type(), a) + } else { + return s.newValue1(ssa.OpStringPtr, n.Type(), a) + } + + case ir.OITAB: + n := n.(*ir.UnaryExpr) + a := s.expr(n.X) + return s.newValue1(ssa.OpITab, n.Type(), a) + + case ir.OIDATA: + n := n.(*ir.UnaryExpr) + a := s.expr(n.X) + return s.newValue1(ssa.OpIData, n.Type(), a) + + case ir.OMAKEFACE: + n := n.(*ir.BinaryExpr) + tab := s.expr(n.X) + data := s.expr(n.Y) + return s.newValue2(ssa.OpIMake, n.Type(), tab, data) + + case ir.OSLICEHEADER: + n := n.(*ir.SliceHeaderExpr) + p := s.expr(n.Ptr) + l := s.expr(n.Len) + c := s.expr(n.Cap) + return s.newValue3(ssa.OpSliceMake, n.Type(), p, l, c) + + case ir.OSTRINGHEADER: + n := n.(*ir.StringHeaderExpr) + p := s.expr(n.Ptr) + l := s.expr(n.Len) + return s.newValue2(ssa.OpStringMake, n.Type(), p, l) + + case ir.OSLICE, ir.OSLICEARR, ir.OSLICE3, ir.OSLICE3ARR: + n := n.(*ir.SliceExpr) + check := s.checkPtrEnabled && n.Op() == ir.OSLICE3ARR && n.X.Op() == ir.OCONVNOP && n.X.(*ir.ConvExpr).X.Type().IsUnsafePtr() + v := s.exprCheckPtr(n.X, !check) + var i, j, k *ssa.Value + if n.Low != nil { + i = s.expr(n.Low) + } + if n.High != nil { + j = s.expr(n.High) + } + if n.Max != nil { + k = s.expr(n.Max) + } + p, l, c := s.slice(v, i, j, k, n.Bounded()) + if check { + // Emit checkptr instrumentation after bound check to prevent false positive, see #46938. + s.checkPtrAlignment(n.X.(*ir.ConvExpr), v, s.conv(n.Max, k, k.Type, types.Types[types.TUINTPTR])) + } + return s.newValue3(ssa.OpSliceMake, n.Type(), p, l, c) + + case ir.OSLICESTR: + n := n.(*ir.SliceExpr) + v := s.expr(n.X) + var i, j *ssa.Value + if n.Low != nil { + i = s.expr(n.Low) + } + if n.High != nil { + j = s.expr(n.High) + } + p, l, _ := s.slice(v, i, j, nil, n.Bounded()) + return s.newValue2(ssa.OpStringMake, n.Type(), p, l) + + case ir.OSLICE2ARRPTR: + // if arrlen > slice.len { + // panic(...) + // } + // slice.ptr + n := n.(*ir.ConvExpr) + v := s.expr(n.X) + nelem := n.Type().Elem().NumElem() + arrlen := s.constInt(types.Types[types.TINT], nelem) + cap := s.newValue1(ssa.OpSliceLen, types.Types[types.TINT], v) + s.boundsCheck(arrlen, cap, ssa.BoundsConvert, false) + op := ssa.OpSlicePtr + if nelem == 0 { + op = ssa.OpSlicePtrUnchecked + } + return s.newValue1(op, n.Type(), v) + + case ir.OCALLFUNC: + n := n.(*ir.CallExpr) + if ir.IsIntrinsicCall(n) { + return s.intrinsicCall(n) + } + fallthrough + + case ir.OCALLINTER: + n := n.(*ir.CallExpr) + return s.callResult(n, callNormal) + + case ir.OGETG: + n := n.(*ir.CallExpr) + return s.newValue1(ssa.OpGetG, n.Type(), s.mem()) + + case ir.OGETCALLERSP: + n := n.(*ir.CallExpr) + return s.newValue1(ssa.OpGetCallerSP, n.Type(), s.mem()) + + case ir.OAPPEND: + return s.append(n.(*ir.CallExpr), false) + + case ir.OMOVE2HEAP: + return s.move2heap(n.(*ir.MoveToHeapExpr)) + + case ir.OMIN, ir.OMAX: + return s.minMax(n.(*ir.CallExpr)) + + case ir.OSTRUCTLIT, ir.OARRAYLIT: + // All literals with nonzero fields have already been + // rewritten during walk. Any that remain are just T{} + // or equivalents. Use the zero value. + n := n.(*ir.CompLitExpr) + if !ir.IsZero(n) { + s.Fatalf("literal with nonzero value in SSA: %v", n) + } + return s.zeroVal(n.Type()) + + case ir.ONEW: + n := n.(*ir.UnaryExpr) + if x, ok := n.X.(*ir.DynamicType); ok && x.Op() == ir.ODYNAMICTYPE { + return s.newObjectNonSpecialized(n.Type().Elem(), s.expr(x.RType)) + } + return s.newObject(n.Type().Elem()) + + case ir.OUNSAFEADD: + n := n.(*ir.BinaryExpr) + ptr := s.expr(n.X) + len := s.expr(n.Y) + + // Force len to uintptr to prevent misuse of garbage bits in the + // upper part of the register (#48536). + len = s.conv(n, len, len.Type, types.Types[types.TUINTPTR]) + + return s.newValue2(ssa.OpAddPtr, n.Type(), ptr, len) + + default: + s.Fatalf("unhandled expr %v", n.Op()) + return nil + } +} + +func (s *state) resultOfCall(c *ssa.Value, which int64, t *types.Type) *ssa.Value { + aux := c.Aux.(*ssa.AuxCall) + pa := aux.ParamAssignmentForResult(which) + // TODO(register args) determine if in-memory TypeOK is better loaded early from SelectNAddr or later when SelectN is expanded. + // SelectN is better for pattern-matching and possible call-aware analysis we might want to do in the future. + if len(pa.Registers) == 0 && !ssa.CanSSA(t) { + addr := s.newValue1I(ssa.OpSelectNAddr, types.NewPtr(t), which, c) + return s.rawLoad(t, addr) + } + return s.newValue1I(ssa.OpSelectN, t, which, c) +} + +func (s *state) resultAddrOfCall(c *ssa.Value, which int64, t *types.Type) *ssa.Value { + aux := c.Aux.(*ssa.AuxCall) + pa := aux.ParamAssignmentForResult(which) + if len(pa.Registers) == 0 { + return s.newValue1I(ssa.OpSelectNAddr, types.NewPtr(t), which, c) + } + _, addr := s.temp(c.Pos, t) + rval := s.newValue1I(ssa.OpSelectN, t, which, c) + s.vars[memVar] = s.newValue3Apos(ssa.OpStore, types.TypeMem, t, addr, rval, s.mem(), false) + return addr +} + +// Get backing store information for an append call. +func (s *state) getBackingStoreInfoForAppend(n *ir.CallExpr) *backingStoreInfo { + if n.Esc() != ir.EscNone { + return nil + } + return s.getBackingStoreInfo(n.Args[0]) +} +func (s *state) getBackingStoreInfo(n ir.Node) *backingStoreInfo { + t := n.Type() + et := t.Elem() + maxStackSize := int64(base.Debug.VariableMakeThreshold) + if et.Size() == 0 || et.Size() > maxStackSize { + return nil + } + if base.Flag.N != 0 { + return nil + } + if !base.VariableMakeHash.MatchPos(n.Pos(), nil) { + return nil + } + i := s.backingStores[n] + if i != nil { + return i + } + + // Build type of backing store. + K := maxStackSize / et.Size() // rounds down + KT := types.NewArray(et, K) + KT.SetNoalg(true) + types.CalcArraySize(KT) + // Align more than naturally for the type KT. See issue 73199. + align := types.NewArray(types.Types[types.TUINTPTR], 0) + types.CalcArraySize(align) + storeTyp := types.NewStruct([]*types.Field{ + {Sym: types.BlankSym, Type: align}, + {Sym: types.BlankSym, Type: KT}, + }) + storeTyp.SetNoalg(true) + types.CalcStructSize(storeTyp) + + // Make backing store variable. + backingStore := typecheck.TempAt(n.Pos(), s.curfn, storeTyp) + backingStore.SetAddrtaken(true) + + // Make "used" boolean. + used := typecheck.TempAt(n.Pos(), s.curfn, types.Types[types.TBOOL]) + if s.curBlock == s.f.Entry { + s.vars[used] = s.constBool(false) + } else { + // initialize this variable at end of entry block + s.defvars[s.f.Entry.ID][used] = s.constBool(false) + } + + // Initialize an info structure. + if s.backingStores == nil { + s.backingStores = map[ir.Node]*backingStoreInfo{} + } + i = &backingStoreInfo{K: K, store: backingStore, used: used, usedStatic: false} + s.backingStores[n] = i + return i +} + +// append converts an OAPPEND node to SSA. +// If inplace is false, it converts the OAPPEND expression n to an ssa.Value, +// adds it to s, and returns the Value. +// If inplace is true, it writes the result of the OAPPEND expression n +// back to the slice being appended to, and returns nil. +// inplace MUST be set to false if the slice can be SSA'd. +// Note: this code only handles fixed-count appends. Dotdotdot appends +// have already been rewritten at this point (by walk). +func (s *state) append(n *ir.CallExpr, inplace bool) *ssa.Value { + // If inplace is false, process as expression "append(s, e1, e2, e3)": + // + // ptr, len, cap := s + // len += 3 + // if uint(len) > uint(cap) { + // ptr, len, cap = growslice(ptr, len, cap, 3, typ) + // Note that len is unmodified by growslice. + // } + // // with write barriers, if needed: + // *(ptr+(len-3)) = e1 + // *(ptr+(len-2)) = e2 + // *(ptr+(len-1)) = e3 + // return makeslice(ptr, len, cap) + // + // + // If inplace is true, process as statement "s = append(s, e1, e2, e3)": + // + // a := &s + // ptr, len, cap := s + // len += 3 + // if uint(len) > uint(cap) { + // ptr, len, cap = growslice(ptr, len, cap, 3, typ) + // vardef(a) // if necessary, advise liveness we are writing a new a + // *a.cap = cap // write before ptr to avoid a spill + // *a.ptr = ptr // with write barrier + // } + // *a.len = len + // // with write barriers, if needed: + // *(ptr+(len-3)) = e1 + // *(ptr+(len-2)) = e2 + // *(ptr+(len-1)) = e3 + + et := n.Type().Elem() + pt := types.NewPtr(et) + + // Evaluate slice + sn := n.Args[0] // the slice node is the first in the list + var slice, addr *ssa.Value + if inplace { + addr = s.addr(sn) + slice = s.load(n.Type(), addr) + } else { + slice = s.expr(sn) + } + + // Allocate new blocks + grow := s.f.NewBlock(ssa.BlockPlain) + assign := s.f.NewBlock(ssa.BlockPlain) + + // Decomposse input slice. + p := s.newValue1(ssa.OpSlicePtr, pt, slice) + l := s.newValue1(ssa.OpSliceLen, types.Types[types.TINT], slice) + c := s.newValue1(ssa.OpSliceCap, types.Types[types.TINT], slice) + + // Add number of new elements to length. + nargs := s.constInt(types.Types[types.TINT], int64(len(n.Args)-1)) + oldLen := l + l = s.newValue2(s.ssaOp(ir.OADD, types.Types[types.TINT]), types.Types[types.TINT], l, nargs) + + // Decide if we need to grow + cmp := s.newValue2(s.ssaOp(ir.OLT, types.Types[types.TUINT]), types.Types[types.TBOOL], c, l) + + // Record values of ptr/len/cap before branch. + s.vars[ptrVar] = p + s.vars[lenVar] = l + if !inplace { + s.vars[capVar] = c + } + + b := s.endBlock() + b.Kind = ssa.BlockIf + b.Likely = ssa.BranchUnlikely + b.SetControl(cmp) + b.AddEdgeTo(grow) + b.AddEdgeTo(assign) + + // If the result of the append does not escape, we can use + // a stack-allocated backing store if len is small enough. + // A stack-allocated backing store could be used at every + // append that qualifies, but we limit it in some cases to + // avoid wasted code and stack space. + // + // Note that we have two different strategies. + // 1. The standard strategy is just to allocate the full + // backing store at the first append. + // 2. An alternate strategy is used when + // a. The backing store eventually escapes via move2heap + // and b. The capacity is used somehow + // In this case, we don't want to just allocate + // the full buffer at the first append, because when + // we move2heap the buffer to the heap when it escapes, + // we might end up wasting memory because we can't + // change the capacity. + // So in this case we use growsliceBuf to reuse the buffer + // and walk one step up the size class ladder each time. + // + // TODO: handle ... append case? Currently we handle only + // a fixed number of appended elements. + var info *backingStoreInfo + if !inplace { + info = s.getBackingStoreInfoForAppend(n) + } + + if !inplace && info != nil && !n.UseBuf && !info.usedStatic { + // if l <= K { + // if !used { + // if oldLen == 0 { + // var store [K]T + // s = store[:l:K] + // used = true + // } + // } + // } + // ... if we didn't use the stack backing store, call growslice ... + // + // oldLen==0 is not strictly necessary, but requiring it means + // we don't have to worry about copying existing elements. + // Allowing oldLen>0 would add complication. Worth it? I would guess not. + // + // TODO: instead of the used boolean, we could insist that this only applies + // to monotonic slices, those which once they have >0 entries never go back + // to 0 entries. Then oldLen==0 is enough. + // + // We also do this for append(x, ...) once for every x. + // It is ok to do it more often, but it is probably helpful only for + // the first instance. TODO: this could use more tuning. Using ir.Node + // as the key works for *ir.Name instances but probably nothing else. + info.usedStatic = true + // TODO: unset usedStatic somehow? + + usedTestBlock := s.f.NewBlock(ssa.BlockPlain) + oldLenTestBlock := s.f.NewBlock(ssa.BlockPlain) + bodyBlock := s.f.NewBlock(ssa.BlockPlain) + growSlice := s.f.NewBlock(ssa.BlockPlain) + tInt := types.Types[types.TINT] + tBool := types.Types[types.TBOOL] + + // if l <= K + s.startBlock(grow) + kTest := s.newValue2(s.ssaOp(ir.OLE, tInt), tBool, l, s.constInt(tInt, info.K)) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(kTest) + b.AddEdgeTo(usedTestBlock) + b.AddEdgeTo(growSlice) + b.Likely = ssa.BranchLikely + + // if !used + s.startBlock(usedTestBlock) + usedTest := s.newValue1(ssa.OpNot, tBool, s.expr(info.used)) + b = s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(usedTest) + b.AddEdgeTo(oldLenTestBlock) + b.AddEdgeTo(growSlice) + b.Likely = ssa.BranchLikely + + // if oldLen == 0 + s.startBlock(oldLenTestBlock) + oldLenTest := s.newValue2(s.ssaOp(ir.OEQ, tInt), tBool, oldLen, s.constInt(tInt, 0)) + b = s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(oldLenTest) + b.AddEdgeTo(bodyBlock) + b.AddEdgeTo(growSlice) + b.Likely = ssa.BranchLikely + + // var store struct { _ [0]uintptr; arr [K]T } + s.startBlock(bodyBlock) + if et.HasPointers() { + s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, info.store, s.mem()) + } + addr := s.addr(info.store) + s.zero(info.store.Type(), addr) + + // s = store.arr[:l:K] + s.vars[ptrVar] = addr + s.vars[lenVar] = l // nargs would also be ok because of the oldLen==0 test. + s.vars[capVar] = s.constInt(tInt, info.K) + + // used = true + s.assign(info.used, s.constBool(true), false, 0) + b = s.endBlock() + b.AddEdgeTo(assign) + + // New block to use for growslice call. + grow = growSlice + } + + // Call growslice + s.startBlock(grow) + taddr := s.expr(n.Fun) + var r []*ssa.Value + if info != nil && n.UseBuf { + // Use stack-allocated buffer as backing store, if we can. + if et.HasPointers() && !info.usedStatic { + // Initialize in the function header. Not the best place, + // but it makes sure we don't scan this area before it is + // initialized. + mem := s.defvars[s.f.Entry.ID][memVar] + mem = s.f.Entry.NewValue1A(n.Pos(), ssa.OpVarDef, types.TypeMem, info.store, mem) + addr := s.f.Entry.NewValue2A(n.Pos(), ssa.OpLocalAddr, types.NewPtr(info.store.Type()), info.store, s.sp, mem) + mem = s.f.Entry.NewValue2I(n.Pos(), ssa.OpZero, types.TypeMem, info.store.Type().Size(), addr, mem) + mem.Aux = info.store.Type() + s.defvars[s.f.Entry.ID][memVar] = mem + info.usedStatic = true + } + fn := ir.Syms.GrowsliceBuf + if goexperiment.RuntimeFreegc && n.AppendNoAlias && !et.HasPointers() { + // The append is for a non-aliased slice where the runtime knows how to free + // the old logically dead backing store after growth. + // TODO(thepudds): for now, we only use the NoAlias version for element types + // without pointers while waiting on additional runtime support (CL 698515). + fn = ir.Syms.GrowsliceBufNoAlias + } + r = s.rtcall(fn, true, []*types.Type{n.Type()}, p, l, c, nargs, taddr, s.addr(info.store), s.constInt(types.Types[types.TINT], info.K)) + } else { + fn := ir.Syms.Growslice + if goexperiment.RuntimeFreegc && n.AppendNoAlias && !et.HasPointers() { + // The append is for a non-aliased slice where the runtime knows how to free + // the old logically dead backing store after growth. + // TODO(thepudds): for now, we only use the NoAlias version for element types + // without pointers while waiting on additional runtime support (CL 698515). + fn = ir.Syms.GrowsliceNoAlias + } + r = s.rtcall(fn, true, []*types.Type{n.Type()}, p, l, c, nargs, taddr) + } + + // Decompose output slice + p = s.newValue1(ssa.OpSlicePtr, pt, r[0]) + l = s.newValue1(ssa.OpSliceLen, types.Types[types.TINT], r[0]) + c = s.newValue1(ssa.OpSliceCap, types.Types[types.TINT], r[0]) + + s.vars[ptrVar] = p + s.vars[lenVar] = l + s.vars[capVar] = c + if inplace { + if sn.Op() == ir.ONAME { + sn := sn.(*ir.Name) + if sn.Class != ir.PEXTERN { + // Tell liveness we're about to build a new slice + s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, sn, s.mem()) + } + } + capaddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, types.SliceCapOffset, addr) + s.store(types.Types[types.TINT], capaddr, c) + s.store(pt, addr, p) + } + + b = s.endBlock() + b.AddEdgeTo(assign) + + // assign new elements to slots + s.startBlock(assign) + p = s.variable(ptrVar, pt) // generates phi for ptr + l = s.variable(lenVar, types.Types[types.TINT]) // generates phi for len + if !inplace { + c = s.variable(capVar, types.Types[types.TINT]) // generates phi for cap + } + + if inplace { + // Update length in place. + // We have to wait until here to make sure growslice succeeded. + lenaddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, types.SliceLenOffset, addr) + s.store(types.Types[types.TINT], lenaddr, l) + } + + // Evaluate args + type argRec struct { + // if store is true, we're appending the value v. If false, we're appending the + // value at *v. + v *ssa.Value + store bool + } + args := make([]argRec, 0, len(n.Args[1:])) + for _, n := range n.Args[1:] { + if ssa.CanSSA(n.Type()) { + args = append(args, argRec{v: s.expr(n), store: true}) + } else { + v := s.addr(n) + args = append(args, argRec{v: v}) + } + } + + // Write args into slice. + oldLen = s.newValue2(s.ssaOp(ir.OSUB, types.Types[types.TINT]), types.Types[types.TINT], l, nargs) + p2 := s.newValue2(ssa.OpPtrIndex, pt, p, oldLen) + for i, arg := range args { + addr := s.newValue2(ssa.OpPtrIndex, pt, p2, s.constInt(types.Types[types.TINT], int64(i))) + if arg.store { + s.storeType(et, addr, arg.v, 0, true) + } else { + s.move(et, addr, arg.v) + } + } + + // The following deletions have no practical effect at this time + // because state.vars has been reset by the preceding state.startBlock. + // They only enforce the fact that these variables are no longer need in + // the current scope. + delete(s.vars, ptrVar) + delete(s.vars, lenVar) + if !inplace { + delete(s.vars, capVar) + } + + // make result + if inplace { + return nil + } + return s.newValue3(ssa.OpSliceMake, n.Type(), p, l, c) +} + +func (s *state) move2heap(n *ir.MoveToHeapExpr) *ssa.Value { + // s := n.Slice + // if s.ptr points to current stack frame { + // s2 := make([]T, s.len, s.cap) + // copy(s2[:cap], s[:cap]) + // s = s2 + // } + // return s + + slice := s.expr(n.Slice) + et := slice.Type.Elem() + pt := types.NewPtr(et) + + info := s.getBackingStoreInfo(n) + if info == nil { + // Backing store will never be stack allocated, so + // move2heap is a no-op. + return slice + } + + // Decomposse input slice. + p := s.newValue1(ssa.OpSlicePtr, pt, slice) + l := s.newValue1(ssa.OpSliceLen, types.Types[types.TINT], slice) + c := s.newValue1(ssa.OpSliceCap, types.Types[types.TINT], slice) + + moveBlock := s.f.NewBlock(ssa.BlockPlain) + mergeBlock := s.f.NewBlock(ssa.BlockPlain) + + s.vars[ptrVar] = p + s.vars[lenVar] = l + s.vars[capVar] = c + + // Decide if we need to move the slice backing store. + // It needs to be moved if it is currently on the stack. + sub := ssa.OpSub64 + less := ssa.OpLess64U + if s.config.PtrSize == 4 { + sub = ssa.OpSub32 + less = ssa.OpLess32U + } + callerSP := s.newValue1(ssa.OpGetCallerSP, types.Types[types.TUINTPTR], s.mem()) + frameSize := s.newValue2(sub, types.Types[types.TUINTPTR], callerSP, s.sp) + pInt := s.newValue2(ssa.OpConvert, types.Types[types.TUINTPTR], p, s.mem()) + off := s.newValue2(sub, types.Types[types.TUINTPTR], pInt, s.sp) + cond := s.newValue2(less, types.Types[types.TBOOL], off, frameSize) + + b := s.endBlock() + b.Kind = ssa.BlockIf + b.Likely = ssa.BranchUnlikely // fast path is to not have to call into runtime + b.SetControl(cond) + b.AddEdgeTo(moveBlock) + b.AddEdgeTo(mergeBlock) + + // Move the slice to heap + s.startBlock(moveBlock) + var newSlice *ssa.Value + if et.HasPointers() { + typ := s.expr(n.RType) + if n.PreserveCapacity { + newSlice = s.rtcall(ir.Syms.MoveSlice, true, []*types.Type{slice.Type}, typ, p, l, c)[0] + } else { + newSlice = s.rtcall(ir.Syms.MoveSliceNoCap, true, []*types.Type{slice.Type}, typ, p, l)[0] + } + } else { + elemSize := s.constInt(types.Types[types.TUINTPTR], et.Size()) + if n.PreserveCapacity { + newSlice = s.rtcall(ir.Syms.MoveSliceNoScan, true, []*types.Type{slice.Type}, elemSize, p, l, c)[0] + } else { + newSlice = s.rtcall(ir.Syms.MoveSliceNoCapNoScan, true, []*types.Type{slice.Type}, elemSize, p, l)[0] + } + } + // Decompose output slice + s.vars[ptrVar] = s.newValue1(ssa.OpSlicePtr, pt, newSlice) + s.vars[lenVar] = s.newValue1(ssa.OpSliceLen, types.Types[types.TINT], newSlice) + s.vars[capVar] = s.newValue1(ssa.OpSliceCap, types.Types[types.TINT], newSlice) + b = s.endBlock() + b.AddEdgeTo(mergeBlock) + + // Merge fast path (no moving) and slow path (moved) + s.startBlock(mergeBlock) + p = s.variable(ptrVar, pt) // generates phi for ptr + l = s.variable(lenVar, types.Types[types.TINT]) // generates phi for len + c = s.variable(capVar, types.Types[types.TINT]) // generates phi for cap + delete(s.vars, ptrVar) + delete(s.vars, lenVar) + delete(s.vars, capVar) + return s.newValue3(ssa.OpSliceMake, slice.Type, p, l, c) +} + +// minMax converts an OMIN/OMAX builtin call into SSA. +func (s *state) minMax(n *ir.CallExpr) *ssa.Value { + // The OMIN/OMAX builtin is variadic, but its semantics are + // equivalent to left-folding a binary min/max operation across the + // arguments list. + fold := func(op func(x, a *ssa.Value) *ssa.Value) *ssa.Value { + x := s.expr(n.Args[0]) + for _, arg := range n.Args[1:] { + x = op(x, s.expr(arg)) + } + return x + } + + typ := n.Type() + + if typ.IsFloat() || typ.IsString() { + // min/max semantics for floats are tricky because of NaNs and + // negative zero. Some architectures have instructions which + // we can use to generate the right result. For others we must + // call into the runtime instead. + // + // Strings are conceptually simpler, but we currently desugar + // string comparisons during walk, not ssagen. + + if typ.IsFloat() { + hasIntrinsic := false + switch Arch.LinkArch.Family { + case sys.AMD64, sys.ARM64, sys.Loong64, sys.RISCV64, sys.S390X: + hasIntrinsic = true + case sys.PPC64: + hasIntrinsic = buildcfg.GOPPC64 >= 9 + } + + if hasIntrinsic { + var op ssa.Op + switch { + case typ.Kind() == types.TFLOAT64 && n.Op() == ir.OMIN: + op = ssa.OpMin64F + case typ.Kind() == types.TFLOAT64 && n.Op() == ir.OMAX: + op = ssa.OpMax64F + case typ.Kind() == types.TFLOAT32 && n.Op() == ir.OMIN: + op = ssa.OpMin32F + case typ.Kind() == types.TFLOAT32 && n.Op() == ir.OMAX: + op = ssa.OpMax32F + } + return fold(func(x, a *ssa.Value) *ssa.Value { + return s.newValue2(op, typ, x, a) + }) + } + } + var name string + switch typ.Kind() { + case types.TFLOAT32: + switch n.Op() { + case ir.OMIN: + name = "fmin32" + case ir.OMAX: + name = "fmax32" + } + case types.TFLOAT64: + switch n.Op() { + case ir.OMIN: + name = "fmin64" + case ir.OMAX: + name = "fmax64" + } + case types.TSTRING: + switch n.Op() { + case ir.OMIN: + name = "strmin" + case ir.OMAX: + name = "strmax" + } + } + fn := typecheck.LookupRuntimeFunc(name) + + return fold(func(x, a *ssa.Value) *ssa.Value { + return s.rtcall(fn, true, []*types.Type{typ}, x, a)[0] + }) + } + + if typ.IsInteger() { + if Arch.LinkArch.Family == sys.RISCV64 && buildcfg.GORISCV64 >= 22 && typ.Size() == 8 { + var op ssa.Op + switch { + case typ.IsSigned() && n.Op() == ir.OMIN: + op = ssa.OpMin64 + case typ.IsSigned() && n.Op() == ir.OMAX: + op = ssa.OpMax64 + case typ.IsUnsigned() && n.Op() == ir.OMIN: + op = ssa.OpMin64u + case typ.IsUnsigned() && n.Op() == ir.OMAX: + op = ssa.OpMax64u + } + return fold(func(x, a *ssa.Value) *ssa.Value { + return s.newValue2(op, typ, x, a) + }) + } + } + + lt := s.ssaOp(ir.OLT, typ) + + return fold(func(x, a *ssa.Value) *ssa.Value { + switch n.Op() { + case ir.OMIN: + // a < x ? a : x + return s.ternary(s.newValue2(lt, types.Types[types.TBOOL], a, x), a, x) + case ir.OMAX: + // x < a ? a : x + return s.ternary(s.newValue2(lt, types.Types[types.TBOOL], x, a), a, x) + } + panic("unreachable") + }) +} + +// ternary emits code to evaluate cond ? x : y. +func (s *state) ternary(cond, x, y *ssa.Value) *ssa.Value { + // Note that we need a new ternaryVar each time (unlike okVar where we can + // reuse the variable) because it might have a different type every time. + ternaryVar := ssaMarker("ternary") + + bThen := s.f.NewBlock(ssa.BlockPlain) + bElse := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cond) + b.AddEdgeTo(bThen) + b.AddEdgeTo(bElse) + + s.startBlock(bThen) + s.vars[ternaryVar] = x + s.endBlock().AddEdgeTo(bEnd) + + s.startBlock(bElse) + s.vars[ternaryVar] = y + s.endBlock().AddEdgeTo(bEnd) + + s.startBlock(bEnd) + r := s.variable(ternaryVar, x.Type) + delete(s.vars, ternaryVar) + return r +} + +// condBranch evaluates the boolean expression cond and branches to yes +// if cond is true and no if cond is false. +// This function is intended to handle && and || better than just calling +// s.expr(cond) and branching on the result. +func (s *state) condBranch(cond ir.Node, yes, no *ssa.Block, likely int8) { + switch cond.Op() { + case ir.OANDAND: + cond := cond.(*ir.LogicalExpr) + mid := s.f.NewBlock(ssa.BlockPlain) + s.stmtList(cond.Init()) + s.condBranch(cond.X, mid, no, max(likely, 0)) + s.startBlock(mid) + s.condBranch(cond.Y, yes, no, likely) + return + // Note: if likely==1, then both recursive calls pass 1. + // If likely==-1, then we don't have enough information to decide + // whether the first branch is likely or not. So we pass 0 for + // the likeliness of the first branch. + // TODO: have the frontend give us branch prediction hints for + // OANDAND and OOROR nodes (if it ever has such info). + case ir.OOROR: + cond := cond.(*ir.LogicalExpr) + mid := s.f.NewBlock(ssa.BlockPlain) + s.stmtList(cond.Init()) + s.condBranch(cond.X, yes, mid, min(likely, 0)) + s.startBlock(mid) + s.condBranch(cond.Y, yes, no, likely) + return + // Note: if likely==-1, then both recursive calls pass -1. + // If likely==1, then we don't have enough info to decide + // the likelihood of the first branch. + case ir.ONOT: + cond := cond.(*ir.UnaryExpr) + s.stmtList(cond.Init()) + s.condBranch(cond.X, no, yes, -likely) + return + case ir.OCONVNOP: + cond := cond.(*ir.ConvExpr) + s.stmtList(cond.Init()) + s.condBranch(cond.X, yes, no, likely) + return + } + c := s.expr(cond) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(c) + b.Likely = ssa.BranchPrediction(likely) // gc and ssa both use -1/0/+1 for likeliness + b.AddEdgeTo(yes) + b.AddEdgeTo(no) +} + +type skipMask uint8 + +const ( + skipPtr skipMask = 1 << iota + skipLen + skipCap +) + +// assign does left = right. +// Right has already been evaluated to ssa, left has not. +// If deref is true, then we do left = *right instead (and right has already been nil-checked). +// If deref is true and right == nil, just do left = 0. +// skip indicates assignments (at the top level) that can be avoided. +// mayOverlap indicates whether left&right might partially overlap in memory. Default is false. +func (s *state) assign(left ir.Node, right *ssa.Value, deref bool, skip skipMask) { + s.assignWhichMayOverlap(left, right, deref, skip, false) +} +func (s *state) assignWhichMayOverlap(left ir.Node, right *ssa.Value, deref bool, skip skipMask, mayOverlap bool) { + if left.Op() == ir.ONAME && ir.IsBlank(left) { + return + } + t := left.Type() + types.CalcSize(t) + if s.canSSA(left) { + if deref { + s.Fatalf("can SSA LHS %v but not RHS %s", left, right) + } + if left.Op() == ir.ODOT { + // We're assigning to a field of an ssa-able value. + // We need to build a new structure with the new value for the + // field we're assigning and the old values for the other fields. + // For instance: + // type T struct {a, b, c int} + // var T x + // x.b = 5 + // For the x.b = 5 assignment we want to generate x = T{x.a, 5, x.c} + + // Grab information about the structure type. + left := left.(*ir.SelectorExpr) + t := left.X.Type() + nf := t.NumFields() + idx := fieldIdx(left) + + // Grab old value of structure. + old := s.expr(left.X) + + if left.Type().Size() == 0 { + // Nothing to do when assigning zero-sized things. + return + } + + // Make new structure. + new := s.newValue0(ssa.OpStructMake, t) + + // Add fields as args. + for i := 0; i < nf; i++ { + if i == idx { + new.AddArg(right) + } else { + new.AddArg(s.newValue1I(ssa.OpStructSelect, t.FieldType(i), int64(i), old)) + } + } + + // Recursively assign the new value we've made to the base of the dot op. + s.assign(left.X, new, false, 0) + // TODO: do we need to update named values here? + return + } + if left.Op() == ir.OINDEX && left.(*ir.IndexExpr).X.Type().IsArray() { + left := left.(*ir.IndexExpr) + s.pushLine(left.Pos()) + defer s.popLine() + // We're assigning to an element of an ssa-able array. + // a[i] = v + t := left.X.Type() + n := t.NumElem() + + i := s.expr(left.Index) // index + if n == 0 { + // The bounds check must fail. Might as well + // ignore the actual index and just use zeros. + z := s.constInt(types.Types[types.TINT], 0) + s.boundsCheck(z, z, ssa.BoundsIndex, false) + return + } + if n != 1 { + // This can happen in weird, always-panics cases, like: + // var x [0][2]int + // x[i][j] = 5 + // We know it always panics because the LHS is ssa-able, + // and arrays of length > 1 can't be ssa-able unless + // they are somewhere inside an outer [0]. + // We can ignore the actual assignment, it is dynamically + // unreachable. See issue 77635. + return + } + if t.Size() == 0 { + return + } + + // Rewrite to a = [1]{v} + len := s.constInt(types.Types[types.TINT], 1) + s.boundsCheck(i, len, ssa.BoundsIndex, false) // checks i == 0 + v := s.newValue1(ssa.OpArrayMake1, t, right) + s.assign(left.X, v, false, 0) + return + } + left := left.(*ir.Name) + // Update variable assignment. + s.vars[left] = right + s.addNamedValue(left, right) + return + } + + // If this assignment clobbers an entire local variable, then emit + // OpVarDef so liveness analysis knows the variable is redefined. + if base, ok := clobberBase(left).(*ir.Name); ok && base.OnStack() && skip == 0 && (t.HasPointers() || ssa.IsMergeCandidate(base)) { + s.vars[memVar] = s.newValue1Apos(ssa.OpVarDef, types.TypeMem, base, s.mem(), !ir.IsAutoTmp(base)) + } + + // Left is not ssa-able. Compute its address. + addr := s.addr(left) + if ir.IsReflectHeaderDataField(left) { + // Package unsafe's documentation says storing pointers into + // reflect.SliceHeader and reflect.StringHeader's Data fields + // is valid, even though they have type uintptr (#19168). + // Mark it pointer type to signal the writebarrier pass to + // insert a write barrier. + t = types.Types[types.TUNSAFEPTR] + } + if deref { + // Treat as a mem->mem move. + if right == nil { + s.zero(t, addr) + } else { + s.moveWhichMayOverlap(t, addr, right, mayOverlap) + } + return + } + // Treat as a store. + s.storeType(t, addr, right, skip, !ir.IsAutoTmp(left)) +} + +// zeroVal returns the zero value for type t. +func (s *state) zeroVal(t *types.Type) *ssa.Value { + if t.Size() == 0 { + return s.entryNewValue0(ssa.OpEmpty, t) + } + switch { + case t.IsInteger(): + switch t.Size() { + case 1: + return s.constInt8(t, 0) + case 2: + return s.constInt16(t, 0) + case 4: + return s.constInt32(t, 0) + case 8: + return s.constInt64(t, 0) + default: + s.Fatalf("bad sized integer type %v", t) + } + case t.IsFloat(): + switch t.Size() { + case 4: + return s.constFloat32(t, 0) + case 8: + return s.constFloat64(t, 0) + default: + s.Fatalf("bad sized float type %v", t) + } + case t.IsComplex(): + switch t.Size() { + case 8: + z := s.constFloat32(types.Types[types.TFLOAT32], 0) + return s.entryNewValue2(ssa.OpComplexMake, t, z, z) + case 16: + z := s.constFloat64(types.Types[types.TFLOAT64], 0) + return s.entryNewValue2(ssa.OpComplexMake, t, z, z) + default: + s.Fatalf("bad sized complex type %v", t) + } + + case t.IsString(): + return s.constEmptyString(t) + case t.IsPtrShaped(): + return s.constNil(t) + case t.IsBoolean(): + return s.constBool(false) + case t.IsInterface(): + return s.constInterface(t) + case t.IsSlice(): + return s.constSlice(t) + case isStructNotSIMD(t): + n := t.NumFields() + v := s.entryNewValue0(ssa.OpStructMake, t) + for i := 0; i < n; i++ { + v.AddArg(s.zeroVal(t.FieldType(i))) + } + return v + case t.IsArray() && t.NumElem() == 1: + return s.entryNewValue1(ssa.OpArrayMake1, t, s.zeroVal(t.Elem())) + case t.IsSIMD(): + return s.newValue0(ssa.OpZeroSIMD, t) + } + s.Fatalf("zero for type %v not implemented", t) + return nil +} + +type callKind int8 + +const ( + callNormal callKind = iota + callDefer + callDeferStack + callGo + callTail +) + +type sfRtCallDef struct { + rtfn *obj.LSym + rtype types.Kind +} + +var softFloatOps map[ssa.Op]sfRtCallDef + +func softfloatInit() { + // Some of these operations get transformed by sfcall. + softFloatOps = map[ssa.Op]sfRtCallDef{ + ssa.OpAdd32F: {typecheck.LookupRuntimeFunc("fadd32"), types.TFLOAT32}, + ssa.OpAdd64F: {typecheck.LookupRuntimeFunc("fadd64"), types.TFLOAT64}, + ssa.OpSub32F: {typecheck.LookupRuntimeFunc("fadd32"), types.TFLOAT32}, + ssa.OpSub64F: {typecheck.LookupRuntimeFunc("fadd64"), types.TFLOAT64}, + ssa.OpMul32F: {typecheck.LookupRuntimeFunc("fmul32"), types.TFLOAT32}, + ssa.OpMul64F: {typecheck.LookupRuntimeFunc("fmul64"), types.TFLOAT64}, + ssa.OpDiv32F: {typecheck.LookupRuntimeFunc("fdiv32"), types.TFLOAT32}, + ssa.OpDiv64F: {typecheck.LookupRuntimeFunc("fdiv64"), types.TFLOAT64}, + + ssa.OpEq64F: {typecheck.LookupRuntimeFunc("feq64"), types.TBOOL}, + ssa.OpEq32F: {typecheck.LookupRuntimeFunc("feq32"), types.TBOOL}, + ssa.OpNeq64F: {typecheck.LookupRuntimeFunc("feq64"), types.TBOOL}, + ssa.OpNeq32F: {typecheck.LookupRuntimeFunc("feq32"), types.TBOOL}, + ssa.OpLess64F: {typecheck.LookupRuntimeFunc("fgt64"), types.TBOOL}, + ssa.OpLess32F: {typecheck.LookupRuntimeFunc("fgt32"), types.TBOOL}, + ssa.OpLeq64F: {typecheck.LookupRuntimeFunc("fge64"), types.TBOOL}, + ssa.OpLeq32F: {typecheck.LookupRuntimeFunc("fge32"), types.TBOOL}, + + ssa.OpCvt32to32F: {typecheck.LookupRuntimeFunc("fint32to32"), types.TFLOAT32}, + ssa.OpCvt32Fto32: {typecheck.LookupRuntimeFunc("f32toint32"), types.TINT32}, + ssa.OpCvt64to32F: {typecheck.LookupRuntimeFunc("fint64to32"), types.TFLOAT32}, + ssa.OpCvt32Fto64: {typecheck.LookupRuntimeFunc("f32toint64"), types.TINT64}, + ssa.OpCvt64Uto32F: {typecheck.LookupRuntimeFunc("fuint64to32"), types.TFLOAT32}, + ssa.OpCvt32Fto64U: {typecheck.LookupRuntimeFunc("f32touint64"), types.TUINT64}, + ssa.OpCvt32to64F: {typecheck.LookupRuntimeFunc("fint32to64"), types.TFLOAT64}, + ssa.OpCvt64Fto32: {typecheck.LookupRuntimeFunc("f64toint32"), types.TINT32}, + ssa.OpCvt64to64F: {typecheck.LookupRuntimeFunc("fint64to64"), types.TFLOAT64}, + ssa.OpCvt64Fto64: {typecheck.LookupRuntimeFunc("f64toint64"), types.TINT64}, + ssa.OpCvt64Uto64F: {typecheck.LookupRuntimeFunc("fuint64to64"), types.TFLOAT64}, + ssa.OpCvt64Fto64U: {typecheck.LookupRuntimeFunc("f64touint64"), types.TUINT64}, + ssa.OpCvt32Fto64F: {typecheck.LookupRuntimeFunc("f32to64"), types.TFLOAT64}, + ssa.OpCvt64Fto32F: {typecheck.LookupRuntimeFunc("f64to32"), types.TFLOAT32}, + } +} + +// TODO: do not emit sfcall if operation can be optimized to constant in later +// opt phase +func (s *state) sfcall(op ssa.Op, args ...*ssa.Value) (*ssa.Value, bool) { + f2i := func(t *types.Type) *types.Type { + switch t.Kind() { + case types.TFLOAT32: + return types.Types[types.TUINT32] + case types.TFLOAT64: + return types.Types[types.TUINT64] + } + return t + } + + if callDef, ok := softFloatOps[op]; ok { + switch op { + case ssa.OpLess32F, + ssa.OpLess64F, + ssa.OpLeq32F, + ssa.OpLeq64F: + args[0], args[1] = args[1], args[0] + case ssa.OpSub32F, + ssa.OpSub64F: + args[1] = s.newValue1(s.ssaOp(ir.ONEG, types.Types[callDef.rtype]), args[1].Type, args[1]) + } + + // runtime functions take uints for floats and returns uints. + // Convert to uints so we use the right calling convention. + for i, a := range args { + if a.Type.IsFloat() { + args[i] = s.newValue1(ssa.OpCopy, f2i(a.Type), a) + } + } + + rt := types.Types[callDef.rtype] + result := s.rtcall(callDef.rtfn, true, []*types.Type{f2i(rt)}, args...)[0] + if rt.IsFloat() { + result = s.newValue1(ssa.OpCopy, rt, result) + } + if op == ssa.OpNeq32F || op == ssa.OpNeq64F { + result = s.newValue1(ssa.OpNot, result.Type, result) + } + return result, true + } + return nil, false +} + +// split breaks up a tuple-typed value into its 2 parts. +func (s *state) split(v *ssa.Value) (*ssa.Value, *ssa.Value) { + p0 := s.newValue1(ssa.OpSelect0, v.Type.FieldType(0), v) + p1 := s.newValue1(ssa.OpSelect1, v.Type.FieldType(1), v) + return p0, p1 +} + +// intrinsicCall converts a call to a recognized intrinsic function into the intrinsic SSA operation. +func (s *state) intrinsicCall(n *ir.CallExpr) *ssa.Value { + v := findIntrinsic(n.Fun.Sym())(s, n, s.intrinsicArgs(n)) + if ssa.IntrinsicsDebug > 0 { + x := v + if x == nil { + x = s.mem() + } + if x.Op == ssa.OpSelect0 || x.Op == ssa.OpSelect1 { + x = x.Args[0] + } + base.WarnfAt(n.Pos(), "intrinsic substitution for %v with %s", n.Fun.Sym().Name, x.LongString()) + } + return v +} + +// intrinsicArgs extracts args from n, evaluates them to SSA values, and returns them. +func (s *state) intrinsicArgs(n *ir.CallExpr) []*ssa.Value { + args := make([]*ssa.Value, len(n.Args)) + for i, n := range n.Args { + args[i] = s.expr(n) + } + return args +} + +// openDeferRecord adds code to evaluate and store the function for an open-code defer +// call, and records info about the defer, so we can generate proper code on the +// exit paths. n is the sub-node of the defer node that is the actual function +// call. We will also record funcdata information on where the function is stored +// (as well as the deferBits variable), and this will enable us to run the proper +// defer calls during panics. +func (s *state) openDeferRecord(n *ir.CallExpr) { + if len(n.Args) != 0 || n.Op() != ir.OCALLFUNC || n.Fun.Type().NumResults() != 0 { + s.Fatalf("defer call with arguments or results: %v", n) + } + + opendefer := &openDeferInfo{ + n: n, + } + fn := n.Fun + // We must always store the function value in a stack slot for the + // runtime panic code to use. But in the defer exit code, we will + // call the function directly if it is a static function. + closureVal := s.expr(fn) + closure := s.openDeferSave(fn.Type(), closureVal) + opendefer.closureNode = closure.Aux.(*ir.Name) + if !(fn.Op() == ir.ONAME && fn.(*ir.Name).Class == ir.PFUNC) { + opendefer.closure = closure + } + index := len(s.openDefers) + s.openDefers = append(s.openDefers, opendefer) + + // Update deferBits only after evaluation and storage to stack of + // the function is successful. + bitvalue := s.constInt8(types.Types[types.TUINT8], 1<= 0; i-- { + r := s.openDefers[i] + bCond := s.f.NewBlock(ssa.BlockPlain) + bEnd := s.f.NewBlock(ssa.BlockPlain) + + deferBits := s.variable(deferBitsVar, types.Types[types.TUINT8]) + // Generate code to check if the bit associated with the current + // defer is set. + bitval := s.constInt8(types.Types[types.TUINT8], 1< 1 { + s.f.Warnl(lineno, "removed nil check") + } + return p + } + p = s.nilCheck(p) + return p +} + +// nilCheck generates nil pointer checking code. +// Used only for automatically inserted nil checks, +// not for user code like 'x != nil'. +// Returns a "definitely not nil" copy of x to ensure proper ordering +// of the uses of the post-nilcheck pointer. +func (s *state) nilCheck(ptr *ssa.Value) *ssa.Value { + if base.Debug.DisableNil != 0 || s.curfn.NilCheckDisabled() { + return ptr + } + return s.newValue2(ssa.OpNilCheck, ptr.Type, ptr, s.mem()) +} + +// boundsCheck generates bounds checking code. Checks if 0 <= idx <[=] len, branches to exit if not. +// Starts a new block on return. +// On input, len must be converted to full int width and be nonnegative. +// Returns idx converted to full int width. +// If bounded is true then caller guarantees the index is not out of bounds +// (but boundsCheck will still extend the index to full int width). +func (s *state) boundsCheck(idx, len *ssa.Value, kind ssa.BoundsKind, bounded bool) *ssa.Value { + idx = s.extendIndex(idx, len, kind, bounded) + + if bounded || base.Flag.B != 0 { + // If bounded or bounds checking is flag-disabled, then no check necessary, + // just return the extended index. + // + // Here, bounded == true if the compiler generated the index itself, + // such as in the expansion of a slice initializer. These indexes are + // compiler-generated, not Go program variables, so they cannot be + // attacker-controlled, so we can omit Spectre masking as well. + // + // Note that we do not want to omit Spectre masking in code like: + // + // if 0 <= i && i < len(x) { + // use(x[i]) + // } + // + // Lucky for us, bounded==false for that code. + // In that case (handled below), we emit a bound check (and Spectre mask) + // and then the prove pass will remove the bounds check. + // In theory the prove pass could potentially remove certain + // Spectre masks, but it's very delicate and probably better + // to be conservative and leave them all in. + return idx + } + + bNext := s.f.NewBlock(ssa.BlockPlain) + bPanic := s.f.NewBlock(ssa.BlockExit) + + if !idx.Type.IsSigned() { + switch kind { + case ssa.BoundsIndex: + kind = ssa.BoundsIndexU + case ssa.BoundsSliceAlen: + kind = ssa.BoundsSliceAlenU + case ssa.BoundsSliceAcap: + kind = ssa.BoundsSliceAcapU + case ssa.BoundsSliceB: + kind = ssa.BoundsSliceBU + case ssa.BoundsSlice3Alen: + kind = ssa.BoundsSlice3AlenU + case ssa.BoundsSlice3Acap: + kind = ssa.BoundsSlice3AcapU + case ssa.BoundsSlice3B: + kind = ssa.BoundsSlice3BU + case ssa.BoundsSlice3C: + kind = ssa.BoundsSlice3CU + } + } + + var cmp *ssa.Value + if kind == ssa.BoundsIndex || kind == ssa.BoundsIndexU { + cmp = s.newValue2(ssa.OpIsInBounds, types.Types[types.TBOOL], idx, len) + } else { + cmp = s.newValue2(ssa.OpIsSliceInBounds, types.Types[types.TBOOL], idx, len) + } + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp) + b.Likely = ssa.BranchLikely + b.AddEdgeTo(bNext) + b.AddEdgeTo(bPanic) + + s.startBlock(bPanic) + if Arch.LinkArch.Family == sys.Wasm { + // TODO(khr): figure out how to do "register" based calling convention for bounds checks. + // Should be similar to gcWriteBarrier, but I can't make it work. + s.rtcall(BoundsCheckFunc[kind], false, nil, idx, len) + } else { + mem := s.newValue3I(ssa.OpPanicBounds, types.TypeMem, int64(kind), idx, len, s.mem()) + s.endBlock().SetControl(mem) + } + s.startBlock(bNext) + + // In Spectre index mode, apply an appropriate mask to avoid speculative out-of-bounds accesses. + if base.Flag.Cfg.SpectreIndex { + op := ssa.OpSpectreIndex + if kind != ssa.BoundsIndex && kind != ssa.BoundsIndexU { + op = ssa.OpSpectreSliceIndex + } + idx = s.newValue2(op, types.Types[types.TINT], idx, len) + } + + return idx +} + +// If cmp (a bool) is false, panic using the given function. +func (s *state) check(cmp *ssa.Value, fn *obj.LSym) { + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp) + b.Likely = ssa.BranchLikely + bNext := s.f.NewBlock(ssa.BlockPlain) + line := s.peekPos() + pos := base.Ctxt.PosTable.Pos(line) + fl := funcLine{f: fn, base: pos.Base(), line: pos.Line()} + bPanic := s.panics[fl] + if bPanic == nil { + bPanic = s.f.NewBlock(ssa.BlockPlain) + s.panics[fl] = bPanic + s.startBlock(bPanic) + // The panic call takes/returns memory to ensure that the right + // memory state is observed if the panic happens. + s.rtcall(fn, false, nil) + } + b.AddEdgeTo(bNext) + b.AddEdgeTo(bPanic) + s.startBlock(bNext) +} + +func (s *state) intDivide(n ir.Node, a, b *ssa.Value) *ssa.Value { + needcheck := true + switch b.Op { + case ssa.OpConst8, ssa.OpConst16, ssa.OpConst32, ssa.OpConst64: + if b.AuxInt != 0 { + needcheck = false + } + } + if needcheck { + // do a size-appropriate check for zero + cmp := s.newValue2(s.ssaOp(ir.ONE, n.Type()), types.Types[types.TBOOL], b, s.zeroVal(n.Type())) + s.check(cmp, ir.Syms.Panicdivide) + } + return s.newValue2(s.ssaOp(n.Op(), n.Type()), a.Type, a, b) +} + +// rtcall issues a call to the given runtime function fn with the listed args. +// Returns a slice of results of the given result types. +// The call is added to the end of the current block. +// If returns is false, the block is marked as an exit block. +func (s *state) rtcall(fn *obj.LSym, returns bool, results []*types.Type, args ...*ssa.Value) []*ssa.Value { + s.prevCall = nil + // Write args to the stack + off := base.Ctxt.Arch.FixedFrameSize + var callArgs []*ssa.Value + var callArgTypes []*types.Type + + for _, arg := range args { + t := arg.Type + off = types.RoundUp(off, t.Alignment()) + size := t.Size() + callArgs = append(callArgs, arg) + callArgTypes = append(callArgTypes, t) + off += size + } + off = types.RoundUp(off, int64(types.RegSize)) + + // Issue call + var call *ssa.Value + aux := ssa.StaticAuxCall(fn, s.f.ABIDefault.ABIAnalyzeTypes(callArgTypes, results)) + callArgs = append(callArgs, s.mem()) + call = s.newValue0A(ssa.OpStaticLECall, aux.LateExpansionResultType(), aux) + call.AddArgs(callArgs...) + s.vars[memVar] = s.newValue1I(ssa.OpSelectN, types.TypeMem, int64(len(results)), call) + + if !returns { + // Finish block + b := s.endBlock() + b.Kind = ssa.BlockExit + b.SetControl(call) + call.AuxInt = off - base.Ctxt.Arch.FixedFrameSize + if len(results) > 0 { + s.Fatalf("panic call can't have results") + } + return nil + } + + // Load results + res := make([]*ssa.Value, len(results)) + for i, t := range results { + off = types.RoundUp(off, t.Alignment()) + res[i] = s.resultOfCall(call, int64(i), t) + off += t.Size() + } + off = types.RoundUp(off, int64(types.PtrSize)) + + // Remember how much callee stack space we needed. + call.AuxInt = off + + return res +} + +// do *left = right for type t. +func (s *state) storeType(t *types.Type, left, right *ssa.Value, skip skipMask, leftIsStmt bool) { + s.instrument(t, left, instrumentWrite) + + if skip == 0 && (!t.HasPointers() || ssa.IsStackAddr(left)) { + // Known to not have write barrier. Store the whole type. + s.vars[memVar] = s.newValue3Apos(ssa.OpStore, types.TypeMem, t, left, right, s.mem(), leftIsStmt) + return + } + + // store scalar fields first, so write barrier stores for + // pointer fields can be grouped together, and scalar values + // don't need to be live across the write barrier call. + // TODO: if the writebarrier pass knows how to reorder stores, + // we can do a single store here as long as skip==0. + s.storeTypeScalars(t, left, right, skip) + if skip&skipPtr == 0 && t.HasPointers() { + s.storeTypePtrs(t, left, right) + } +} + +// do *left = right for all scalar (non-pointer) parts of t. +func (s *state) storeTypeScalars(t *types.Type, left, right *ssa.Value, skip skipMask) { + switch { + case t.IsBoolean() || t.IsInteger() || t.IsFloat() || t.IsComplex() || t.IsSIMD(): + s.store(t, left, right) + case t.IsPtrShaped(): + if t.IsPtr() && t.Elem().NotInHeap() { + s.store(t, left, right) // see issue 42032 + } + // otherwise, no scalar fields. + case t.IsString(): + if skip&skipLen != 0 { + return + } + len := s.newValue1(ssa.OpStringLen, types.Types[types.TINT], right) + lenAddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, s.config.PtrSize, left) + s.store(types.Types[types.TINT], lenAddr, len) + case t.IsSlice(): + if skip&skipLen == 0 { + len := s.newValue1(ssa.OpSliceLen, types.Types[types.TINT], right) + lenAddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, s.config.PtrSize, left) + s.store(types.Types[types.TINT], lenAddr, len) + } + if skip&skipCap == 0 { + cap := s.newValue1(ssa.OpSliceCap, types.Types[types.TINT], right) + capAddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, 2*s.config.PtrSize, left) + s.store(types.Types[types.TINT], capAddr, cap) + } + case t.IsInterface(): + // itab field doesn't need a write barrier (even though it is a pointer). + itab := s.newValue1(ssa.OpITab, s.f.Config.Types.BytePtr, right) + s.store(types.Types[types.TUINTPTR], left, itab) + case isStructNotSIMD(t): + n := t.NumFields() + for i := 0; i < n; i++ { + ft := t.FieldType(i) + addr := s.newValue1I(ssa.OpOffPtr, ft.PtrTo(), t.FieldOff(i), left) + val := s.newValue1I(ssa.OpStructSelect, ft, int64(i), right) + s.storeTypeScalars(ft, addr, val, 0) + } + case t.IsArray() && t.Size() == 0: + // nothing + case t.IsArray() && t.NumElem() == 1: + s.storeTypeScalars(t.Elem(), left, s.newValue1I(ssa.OpArraySelect, t.Elem(), 0, right), 0) + default: + s.Fatalf("bad write barrier type %v", t) + } +} + +// do *left = right for all pointer parts of t. +func (s *state) storeTypePtrs(t *types.Type, left, right *ssa.Value) { + switch { + case t.IsPtrShaped(): + if t.IsPtr() && t.Elem().NotInHeap() { + break // see issue 42032 + } + s.store(t, left, right) + case t.IsString(): + ptr := s.newValue1(ssa.OpStringPtr, s.f.Config.Types.BytePtr, right) + s.store(s.f.Config.Types.BytePtr, left, ptr) + case t.IsSlice(): + elType := types.NewPtr(t.Elem()) + ptr := s.newValue1(ssa.OpSlicePtr, elType, right) + s.store(elType, left, ptr) + case t.IsInterface(): + // itab field is treated as a scalar. + idata := s.newValue1(ssa.OpIData, s.f.Config.Types.BytePtr, right) + idataAddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.BytePtrPtr, s.config.PtrSize, left) + s.store(s.f.Config.Types.BytePtr, idataAddr, idata) + case isStructNotSIMD(t): + n := t.NumFields() + for i := 0; i < n; i++ { + ft := t.FieldType(i) + if !ft.HasPointers() { + continue + } + addr := s.newValue1I(ssa.OpOffPtr, ft.PtrTo(), t.FieldOff(i), left) + val := s.newValue1I(ssa.OpStructSelect, ft, int64(i), right) + s.storeTypePtrs(ft, addr, val) + } + case t.IsArray() && t.Size() == 0: + // nothing + case t.IsArray() && t.NumElem() == 1: + s.storeTypePtrs(t.Elem(), left, s.newValue1I(ssa.OpArraySelect, t.Elem(), 0, right)) + default: + s.Fatalf("bad write barrier type %v", t) + } +} + +// putArg evaluates n for the purpose of passing it as an argument to a function and returns the value for the call. +func (s *state) putArg(n ir.Node, t *types.Type) *ssa.Value { + var a *ssa.Value + if !ssa.CanSSA(t) { + a = s.newValue2(ssa.OpDereference, t, s.addr(n), s.mem()) + } else { + a = s.expr(n) + } + return a +} + +// slice computes the slice v[i:j:k] and returns ptr, len, and cap of result. +// i,j,k may be nil, in which case they are set to their default value. +// v may be a slice, string or pointer to an array. +func (s *state) slice(v, i, j, k *ssa.Value, bounded bool) (p, l, c *ssa.Value) { + t := v.Type + var ptr, len, cap *ssa.Value + switch { + case t.IsSlice(): + ptr = s.newValue1(ssa.OpSlicePtr, types.NewPtr(t.Elem()), v) + len = s.newValue1(ssa.OpSliceLen, types.Types[types.TINT], v) + cap = s.newValue1(ssa.OpSliceCap, types.Types[types.TINT], v) + case t.IsString(): + ptr = s.newValue1(ssa.OpStringPtr, types.NewPtr(types.Types[types.TUINT8]), v) + len = s.newValue1(ssa.OpStringLen, types.Types[types.TINT], v) + cap = len + case t.IsPtr(): + if !t.Elem().IsArray() { + s.Fatalf("bad ptr to array in slice %v\n", t) + } + nv := s.nilCheck(v) + ptr = s.newValue1(ssa.OpCopy, types.NewPtr(t.Elem().Elem()), nv) + len = s.constInt(types.Types[types.TINT], t.Elem().NumElem()) + cap = len + default: + s.Fatalf("bad type in slice %v\n", t) + } + + // Set default values + if i == nil { + i = s.constInt(types.Types[types.TINT], 0) + } + if j == nil { + j = len + } + three := true + if k == nil { + three = false + k = cap + } + + // Panic if slice indices are not in bounds. + // Make sure we check these in reverse order so that we're always + // comparing against a value known to be nonnegative. See issue 28797. + if three { + if k != cap { + kind := ssa.BoundsSlice3Alen + if t.IsSlice() { + kind = ssa.BoundsSlice3Acap + } + k = s.boundsCheck(k, cap, kind, bounded) + } + if j != k { + j = s.boundsCheck(j, k, ssa.BoundsSlice3B, bounded) + } + i = s.boundsCheck(i, j, ssa.BoundsSlice3C, bounded) + } else { + if j != k { + kind := ssa.BoundsSliceAlen + if t.IsSlice() { + kind = ssa.BoundsSliceAcap + } + j = s.boundsCheck(j, k, kind, bounded) + } + i = s.boundsCheck(i, j, ssa.BoundsSliceB, bounded) + } + + // Word-sized integer operations. + subOp := s.ssaOp(ir.OSUB, types.Types[types.TINT]) + mulOp := s.ssaOp(ir.OMUL, types.Types[types.TINT]) + andOp := s.ssaOp(ir.OAND, types.Types[types.TINT]) + + // Calculate the length (rlen) and capacity (rcap) of the new slice. + // For strings the capacity of the result is unimportant. However, + // we use rcap to test if we've generated a zero-length slice. + // Use length of strings for that. + rlen := s.newValue2(subOp, types.Types[types.TINT], j, i) + rcap := rlen + if j != k && !t.IsString() { + rcap = s.newValue2(subOp, types.Types[types.TINT], k, i) + } + + if (i.Op == ssa.OpConst64 || i.Op == ssa.OpConst32) && i.AuxInt == 0 { + // No pointer arithmetic necessary. + return ptr, rlen, rcap + } + + // Calculate the base pointer (rptr) for the new slice. + // + // Generate the following code assuming that indexes are in bounds. + // The masking is to make sure that we don't generate a slice + // that points to the next object in memory. We cannot just set + // the pointer to nil because then we would create a nil slice or + // string. + // + // rcap = k - i + // rlen = j - i + // rptr = ptr + (mask(rcap) & (i * stride)) + // + // Where mask(x) is 0 if x==0 and -1 if x>0 and stride is the width + // of the element type. + stride := s.constInt(types.Types[types.TINT], ptr.Type.Elem().Size()) + + // The delta is the number of bytes to offset ptr by. + delta := s.newValue2(mulOp, types.Types[types.TINT], i, stride) + + // If we're slicing to the point where the capacity is zero, + // zero out the delta. + mask := s.newValue1(ssa.OpSlicemask, types.Types[types.TINT], rcap) + delta = s.newValue2(andOp, types.Types[types.TINT], delta, mask) + + // Compute rptr = ptr + delta. + rptr := s.newValue2(ssa.OpAddPtr, ptr.Type, ptr, delta) + + return rptr, rlen, rcap +} + +type u642fcvtTab struct { + leq, cvt2F, and, rsh, or, add ssa.Op + one func(*state, *types.Type, int64) *ssa.Value +} + +var u64_f64 = u642fcvtTab{ + leq: ssa.OpLeq64, + cvt2F: ssa.OpCvt64to64F, + and: ssa.OpAnd64, + rsh: ssa.OpRsh64Ux64, + or: ssa.OpOr64, + add: ssa.OpAdd64F, + one: (*state).constInt64, +} + +var u64_f32 = u642fcvtTab{ + leq: ssa.OpLeq64, + cvt2F: ssa.OpCvt64to32F, + and: ssa.OpAnd64, + rsh: ssa.OpRsh64Ux64, + or: ssa.OpOr64, + add: ssa.OpAdd32F, + one: (*state).constInt64, +} + +func (s *state) uint64Tofloat64(n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + return s.uint64Tofloat(&u64_f64, n, x, ft, tt) +} + +func (s *state) uint64Tofloat32(n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + return s.uint64Tofloat(&u64_f32, n, x, ft, tt) +} + +func (s *state) uint64Tofloat(cvttab *u642fcvtTab, n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + // if x >= 0 { + // result = (floatY) x + // } else { + // y = uintX(x) ; y = x & 1 + // z = uintX(x) ; z = z >> 1 + // z = z | y + // result = floatY(z) + // result = result + result + // } + // + // Code borrowed from old code generator. + // What's going on: large 64-bit "unsigned" looks like + // negative number to hardware's integer-to-float + // conversion. However, because the mantissa is only + // 63 bits, we don't need the LSB, so instead we do an + // unsigned right shift (divide by two), convert, and + // double. However, before we do that, we need to be + // sure that we do not lose a "1" if that made the + // difference in the resulting rounding. Therefore, we + // preserve it, and OR (not ADD) it back in. The case + // that matters is when the eleven discarded bits are + // equal to 10000000001; that rounds up, and the 1 cannot + // be lost else it would round down if the LSB of the + // candidate mantissa is 0. + + cmp := s.newValue2(cvttab.leq, types.Types[types.TBOOL], s.zeroVal(ft), x) + + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp) + b.Likely = ssa.BranchLikely + + bThen := s.f.NewBlock(ssa.BlockPlain) + bElse := s.f.NewBlock(ssa.BlockPlain) + bAfter := s.f.NewBlock(ssa.BlockPlain) + + b.AddEdgeTo(bThen) + s.startBlock(bThen) + a0 := s.newValue1(cvttab.cvt2F, tt, x) + s.vars[n] = a0 + s.endBlock() + bThen.AddEdgeTo(bAfter) + + b.AddEdgeTo(bElse) + s.startBlock(bElse) + one := cvttab.one(s, ft, 1) + y := s.newValue2(cvttab.and, ft, x, one) + z := s.newValue2(cvttab.rsh, ft, x, one) + z = s.newValue2(cvttab.or, ft, z, y) + a := s.newValue1(cvttab.cvt2F, tt, z) + a1 := s.newValue2(cvttab.add, tt, a, a) + s.vars[n] = a1 + s.endBlock() + bElse.AddEdgeTo(bAfter) + + s.startBlock(bAfter) + return s.variable(n, n.Type()) +} + +type u322fcvtTab struct { + cvtI2F, cvtF2F ssa.Op +} + +var u32_f64 = u322fcvtTab{ + cvtI2F: ssa.OpCvt32to64F, + cvtF2F: ssa.OpCopy, +} + +var u32_f32 = u322fcvtTab{ + cvtI2F: ssa.OpCvt32to32F, + cvtF2F: ssa.OpCvt64Fto32F, +} + +func (s *state) uint32Tofloat64(n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + return s.uint32Tofloat(&u32_f64, n, x, ft, tt) +} + +func (s *state) uint32Tofloat32(n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + return s.uint32Tofloat(&u32_f32, n, x, ft, tt) +} + +func (s *state) uint32Tofloat(cvttab *u322fcvtTab, n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + // if x >= 0 { + // result = floatY(x) + // } else { + // result = floatY(float64(x) + (1<<32)) + // } + cmp := s.newValue2(ssa.OpLeq32, types.Types[types.TBOOL], s.zeroVal(ft), x) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp) + b.Likely = ssa.BranchLikely + + bThen := s.f.NewBlock(ssa.BlockPlain) + bElse := s.f.NewBlock(ssa.BlockPlain) + bAfter := s.f.NewBlock(ssa.BlockPlain) + + b.AddEdgeTo(bThen) + s.startBlock(bThen) + a0 := s.newValue1(cvttab.cvtI2F, tt, x) + s.vars[n] = a0 + s.endBlock() + bThen.AddEdgeTo(bAfter) + + b.AddEdgeTo(bElse) + s.startBlock(bElse) + a1 := s.newValue1(ssa.OpCvt32to64F, types.Types[types.TFLOAT64], x) + twoToThe32 := s.constFloat64(types.Types[types.TFLOAT64], float64(1<<32)) + a2 := s.newValue2(ssa.OpAdd64F, types.Types[types.TFLOAT64], a1, twoToThe32) + a3 := s.newValue1(cvttab.cvtF2F, tt, a2) + + s.vars[n] = a3 + s.endBlock() + bElse.AddEdgeTo(bAfter) + + s.startBlock(bAfter) + return s.variable(n, n.Type()) +} + +// referenceTypeBuiltin generates code for the len/cap builtins for maps and channels. +func (s *state) referenceTypeBuiltin(n *ir.UnaryExpr, x *ssa.Value) *ssa.Value { + if !n.X.Type().IsMap() && !n.X.Type().IsChan() { + s.Fatalf("node must be a map or a channel") + } + if n.X.Type().IsChan() && n.Op() == ir.OLEN { + s.Fatalf("cannot inline len(chan)") // must use runtime.chanlen now + } + if n.X.Type().IsChan() && n.Op() == ir.OCAP { + s.Fatalf("cannot inline cap(chan)") // must use runtime.chancap now + } + if n.X.Type().IsMap() && n.Op() == ir.OCAP { + s.Fatalf("cannot inline cap(map)") // cap(map) does not exist + } + // if n == nil { + // return 0 + // } else { + // // len, the actual loadType depends + // return int(*((*loadType)n)) + // // cap (chan only, not used for now) + // return *(((*int)n)+1) + // } + lenType := n.Type() + nilValue := s.constNil(types.Types[types.TUINTPTR]) + cmp := s.newValue2(ssa.OpEqPtr, types.Types[types.TBOOL], x, nilValue) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp) + b.Likely = ssa.BranchUnlikely + + bThen := s.f.NewBlock(ssa.BlockPlain) + bElse := s.f.NewBlock(ssa.BlockPlain) + bAfter := s.f.NewBlock(ssa.BlockPlain) + + // length/capacity of a nil map/chan is zero + b.AddEdgeTo(bThen) + s.startBlock(bThen) + s.vars[n] = s.zeroVal(lenType) + s.endBlock() + bThen.AddEdgeTo(bAfter) + + b.AddEdgeTo(bElse) + s.startBlock(bElse) + switch n.Op() { + case ir.OLEN: + if n.X.Type().IsMap() { + // length is stored in the first word, but needs conversion to int. + loadType := reflectdata.MapType().Field(0).Type // uint64 + load := s.load(loadType, x) + s.vars[n] = s.conv(nil, load, loadType, lenType) // integer conversion doesn't need Node + } else { + // length is stored in the first word for chan, no conversion needed. + s.vars[n] = s.load(lenType, x) + } + case ir.OCAP: + // capacity is stored in the second word for chan + sw := s.newValue1I(ssa.OpOffPtr, lenType.PtrTo(), lenType.Size(), x) + s.vars[n] = s.load(lenType, sw) + default: + s.Fatalf("op must be OLEN or OCAP") + } + s.endBlock() + bElse.AddEdgeTo(bAfter) + + s.startBlock(bAfter) + return s.variable(n, lenType) +} + +type f2uCvtTab struct { + ltf, cvt2U, subf, or ssa.Op + floatValue func(*state, *types.Type, float64) *ssa.Value + intValue func(*state, *types.Type, int64) *ssa.Value + cutoff uint64 +} + +var f32_u64 = f2uCvtTab{ + ltf: ssa.OpLess32F, + cvt2U: ssa.OpCvt32Fto64, + subf: ssa.OpSub32F, + or: ssa.OpOr64, + floatValue: (*state).constFloat32, + intValue: (*state).constInt64, + cutoff: 1 << 63, +} + +var f64_u64 = f2uCvtTab{ + ltf: ssa.OpLess64F, + cvt2U: ssa.OpCvt64Fto64, + subf: ssa.OpSub64F, + or: ssa.OpOr64, + floatValue: (*state).constFloat64, + intValue: (*state).constInt64, + cutoff: 1 << 63, +} + +var f32_u32 = f2uCvtTab{ + ltf: ssa.OpLess32F, + cvt2U: ssa.OpCvt32Fto32, + subf: ssa.OpSub32F, + or: ssa.OpOr32, + floatValue: (*state).constFloat32, + intValue: func(s *state, t *types.Type, v int64) *ssa.Value { return s.constInt32(t, int32(v)) }, + cutoff: 1 << 31, +} + +var f64_u32 = f2uCvtTab{ + ltf: ssa.OpLess64F, + cvt2U: ssa.OpCvt64Fto32, + subf: ssa.OpSub64F, + or: ssa.OpOr32, + floatValue: (*state).constFloat64, + intValue: func(s *state, t *types.Type, v int64) *ssa.Value { return s.constInt32(t, int32(v)) }, + cutoff: 1 << 31, +} + +func (s *state) float32ToUint64(n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + return s.floatToUint(&f32_u64, n, x, ft, tt) +} +func (s *state) float64ToUint64(n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + return s.floatToUint(&f64_u64, n, x, ft, tt) +} + +func (s *state) float32ToUint32(n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + return s.floatToUint(&f32_u32, n, x, ft, tt) +} + +func (s *state) float64ToUint32(n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + return s.floatToUint(&f64_u32, n, x, ft, tt) +} + +func (s *state) floatToUint(cvttab *f2uCvtTab, n ir.Node, x *ssa.Value, ft, tt *types.Type) *ssa.Value { + // cutoff:=1<<(intY_Size-1) + // if x < floatX(cutoff) { + // result = uintY(x) // bThen + // // gated by ConvertHash, clamp negative inputs to zero + // if x < 0 { // unlikely + // result = 0 // bZero + // } + // } else { + // y = x - floatX(cutoff) // bElse + // z = uintY(y) + // result = z | -(cutoff) + // } + + cutoff := cvttab.floatValue(s, ft, float64(cvttab.cutoff)) + cmp := s.newValueOrSfCall2(cvttab.ltf, types.Types[types.TBOOL], x, cutoff) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp) + b.Likely = ssa.BranchLikely + + var bThen, bZero *ssa.Block + // use salted hash to distinguish unsigned convert at a Pos from signed convert at a Pos + newConversion := base.ConvertHash.MatchPosWithInfo(n.Pos(), "U", nil) + if newConversion { + bZero = s.f.NewBlock(ssa.BlockPlain) + bThen = s.f.NewBlock(ssa.BlockIf) + } else { + bThen = s.f.NewBlock(ssa.BlockPlain) + } + + bElse := s.f.NewBlock(ssa.BlockPlain) + bAfter := s.f.NewBlock(ssa.BlockPlain) + + b.AddEdgeTo(bThen) + s.startBlock(bThen) + a0 := s.newValueOrSfCall1(cvttab.cvt2U, tt, x) + s.vars[n] = a0 + + if newConversion { + cmpz := s.newValueOrSfCall2(cvttab.ltf, types.Types[types.TBOOL], x, cvttab.floatValue(s, ft, 0.0)) + s.endBlock() + bThen.SetControl(cmpz) + bThen.AddEdgeTo(bZero) + bThen.Likely = ssa.BranchUnlikely + bThen.AddEdgeTo(bAfter) + + s.startBlock(bZero) + s.vars[n] = cvttab.intValue(s, tt, 0) + s.endBlock() + bZero.AddEdgeTo(bAfter) + } else { + s.endBlock() + bThen.AddEdgeTo(bAfter) + } + + b.AddEdgeTo(bElse) + s.startBlock(bElse) + y := s.newValueOrSfCall2(cvttab.subf, ft, x, cutoff) + y = s.newValueOrSfCall1(cvttab.cvt2U, tt, y) + z := cvttab.intValue(s, tt, int64(-cvttab.cutoff)) + a1 := s.newValue2(cvttab.or, tt, y, z) + s.vars[n] = a1 + s.endBlock() + bElse.AddEdgeTo(bAfter) + + s.startBlock(bAfter) + return s.variable(n, n.Type()) +} + +// dottype generates SSA for a type assertion node. +// commaok indicates whether to panic or return a bool. +// If commaok is false, resok will be nil. +func (s *state) dottype(n *ir.TypeAssertExpr, commaok bool) (res, resok *ssa.Value) { + iface := s.expr(n.X) // input interface + target := s.reflectType(n.Type()) // target type + var targetItab *ssa.Value + if n.ITab != nil { + targetItab = s.expr(n.ITab) + } + + if n.UseNilPanic { + if commaok { + base.Fatalf("unexpected *ir.TypeAssertExpr with UseNilPanic == true && commaok == true") + } + if n.Type().IsInterface() { + // Currently we do not expect the compiler to emit type assertions with UseNilPanic, that asserts to an interface type. + // If needed, this can be relaxed in the future, but for now we can't assert that. + base.Fatalf("unexpected *ir.TypeAssertExpr with UseNilPanic == true && Type().IsInterface() == true") + } + typs := s.f.Config.Types + iface = s.newValue2( + ssa.OpIMake, + iface.Type, + s.nilCheck(s.newValue1(ssa.OpITab, typs.BytePtr, iface)), + s.newValue1(ssa.OpIData, typs.BytePtr, iface), + ) + } + + return s.dottype1(n.Pos(), n.X.Type(), n.Type(), iface, nil, target, targetItab, commaok, n.Descriptor) +} + +func (s *state) dynamicDottype(n *ir.DynamicTypeAssertExpr, commaok bool) (res, resok *ssa.Value) { + iface := s.expr(n.X) + var source, target, targetItab *ssa.Value + if n.SrcRType != nil { + source = s.expr(n.SrcRType) + } + if !n.X.Type().IsEmptyInterface() && !n.Type().IsInterface() { + byteptr := s.f.Config.Types.BytePtr + targetItab = s.expr(n.ITab) + // TODO(mdempsky): Investigate whether compiling n.RType could be + // better than loading itab.typ. + target = s.load(byteptr, s.newValue1I(ssa.OpOffPtr, byteptr, rttype.ITab.OffsetOf("Type"), targetItab)) + } else { + target = s.expr(n.RType) + } + return s.dottype1(n.Pos(), n.X.Type(), n.Type(), iface, source, target, targetItab, commaok, nil) +} + +// dottype1 implements a x.(T) operation. iface is the argument (x), dst is the type we're asserting to (T) +// and src is the type we're asserting from. +// source is the *runtime._type of src +// target is the *runtime._type of dst. +// If src is a nonempty interface and dst is not an interface, targetItab is an itab representing (dst, src). Otherwise it is nil. +// commaok is true if the caller wants a boolean success value. Otherwise, the generated code panics if the conversion fails. +// descriptor is a compiler-allocated internal/abi.TypeAssert whose address is passed to runtime.typeAssert when +// the target type is a compile-time-known non-empty interface. It may be nil. +func (s *state) dottype1(pos src.XPos, src, dst *types.Type, iface, source, target, targetItab *ssa.Value, commaok bool, descriptor *obj.LSym) (res, resok *ssa.Value) { + typs := s.f.Config.Types + byteptr := typs.BytePtr + if dst.IsInterface() { + if dst.IsEmptyInterface() { + // Converting to an empty interface. + // Input could be an empty or nonempty interface. + if base.Debug.TypeAssert > 0 { + base.WarnfAt(pos, "type assertion inlined") + } + + // Get itab/type field from input. + itab := s.newValue1(ssa.OpITab, byteptr, iface) + // Conversion succeeds iff that field is not nil. + cond := s.newValue2(ssa.OpNeqPtr, types.Types[types.TBOOL], itab, s.constNil(byteptr)) + + if src.IsEmptyInterface() && commaok { + // Converting empty interface to empty interface with ,ok is just a nil check. + return iface, cond + } + + // Branch on nilness. + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cond) + b.Likely = ssa.BranchLikely + bOk := s.f.NewBlock(ssa.BlockPlain) + bFail := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bOk) + b.AddEdgeTo(bFail) + + if !commaok { + // On failure, panic by calling panicnildottype. + s.startBlock(bFail) + s.rtcall(ir.Syms.Panicnildottype, false, nil, target) + + // On success, return (perhaps modified) input interface. + s.startBlock(bOk) + if src.IsEmptyInterface() { + res = iface // Use input interface unchanged. + return + } + // Load type out of itab, build interface with existing idata. + off := s.newValue1I(ssa.OpOffPtr, byteptr, rttype.ITab.OffsetOf("Type"), itab) + typ := s.load(byteptr, off) + idata := s.newValue1(ssa.OpIData, byteptr, iface) + res = s.newValue2(ssa.OpIMake, dst, typ, idata) + return + } + + s.startBlock(bOk) + // nonempty -> empty + // Need to load type from itab + off := s.newValue1I(ssa.OpOffPtr, byteptr, rttype.ITab.OffsetOf("Type"), itab) + s.vars[typVar] = s.load(byteptr, off) + s.endBlock() + + // itab is nil, might as well use that as the nil result. + s.startBlock(bFail) + s.vars[typVar] = itab + s.endBlock() + + // Merge point. + bEnd := s.f.NewBlock(ssa.BlockPlain) + bOk.AddEdgeTo(bEnd) + bFail.AddEdgeTo(bEnd) + s.startBlock(bEnd) + idata := s.newValue1(ssa.OpIData, byteptr, iface) + res = s.newValue2(ssa.OpIMake, dst, s.variable(typVar, byteptr), idata) + resok = cond + delete(s.vars, typVar) // no practical effect, just to indicate typVar is no longer live. + return + } + // converting to a nonempty interface needs a runtime call. + if base.Debug.TypeAssert > 0 { + base.WarnfAt(pos, "type assertion not inlined") + } + + itab := s.newValue1(ssa.OpITab, byteptr, iface) + data := s.newValue1(ssa.OpIData, types.Types[types.TUNSAFEPTR], iface) + + // First, check for nil. + bNil := s.f.NewBlock(ssa.BlockPlain) + bNonNil := s.f.NewBlock(ssa.BlockPlain) + bMerge := s.f.NewBlock(ssa.BlockPlain) + cond := s.newValue2(ssa.OpNeqPtr, types.Types[types.TBOOL], itab, s.constNil(byteptr)) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cond) + b.Likely = ssa.BranchLikely + b.AddEdgeTo(bNonNil) + b.AddEdgeTo(bNil) + + s.startBlock(bNil) + if commaok { + s.vars[typVar] = itab // which will be nil + b := s.endBlock() + b.AddEdgeTo(bMerge) + } else { + // Panic if input is nil. + s.rtcall(ir.Syms.Panicnildottype, false, nil, target) + } + + // Get typ, possibly by loading out of itab. + s.startBlock(bNonNil) + typ := itab + if !src.IsEmptyInterface() { + typ = s.load(byteptr, s.newValue1I(ssa.OpOffPtr, byteptr, rttype.ITab.OffsetOf("Type"), itab)) + } + + // Check the cache first. + var d *ssa.Value + if descriptor != nil { + d = s.newValue1A(ssa.OpAddr, byteptr, descriptor, s.sb) + if base.Flag.N == 0 && rtabi.UseInterfaceSwitchCache(Arch.LinkArch.Family) { + // Note: we can only use the cache if we have the right atomic load instruction. + // Double-check that here. + if intrinsics.lookup(Arch.LinkArch.Arch, "internal/runtime/atomic", "Loadp") == nil { + s.Fatalf("atomic load not available") + } + // Pick right size ops. + var mul, and, add, zext ssa.Op + if s.config.PtrSize == 4 { + mul = ssa.OpMul32 + and = ssa.OpAnd32 + add = ssa.OpAdd32 + zext = ssa.OpCopy + } else { + mul = ssa.OpMul64 + and = ssa.OpAnd64 + add = ssa.OpAdd64 + zext = ssa.OpZeroExt32to64 + } + + loopHead := s.f.NewBlock(ssa.BlockPlain) + loopBody := s.f.NewBlock(ssa.BlockPlain) + cacheHit := s.f.NewBlock(ssa.BlockPlain) + cacheMiss := s.f.NewBlock(ssa.BlockPlain) + + // Load cache pointer out of descriptor, with an atomic load so + // we ensure that we see a fully written cache. + atomicLoad := s.newValue2(ssa.OpAtomicLoadPtr, types.NewTuple(typs.BytePtr, types.TypeMem), d, s.mem()) + cache := s.newValue1(ssa.OpSelect0, typs.BytePtr, atomicLoad) + s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, atomicLoad) + + // Load hash from type or itab. + var hash *ssa.Value + if src.IsEmptyInterface() { + hash = s.newValue2(ssa.OpLoad, typs.UInt32, s.newValue1I(ssa.OpOffPtr, typs.UInt32Ptr, rttype.Type.OffsetOf("Hash"), typ), s.mem()) + } else { + hash = s.newValue2(ssa.OpLoad, typs.UInt32, s.newValue1I(ssa.OpOffPtr, typs.UInt32Ptr, rttype.ITab.OffsetOf("Hash"), itab), s.mem()) + } + hash = s.newValue1(zext, typs.Uintptr, hash) + s.vars[hashVar] = hash + // Load mask from cache. + mask := s.newValue2(ssa.OpLoad, typs.Uintptr, cache, s.mem()) + // Jump to loop head. + b := s.endBlock() + b.AddEdgeTo(loopHead) + + // At loop head, get pointer to the cache entry. + // e := &cache.Entries[hash&mask] + s.startBlock(loopHead) + idx := s.newValue2(and, typs.Uintptr, s.variable(hashVar, typs.Uintptr), mask) + idx = s.newValue2(mul, typs.Uintptr, idx, s.uintptrConstant(uint64(2*s.config.PtrSize))) + idx = s.newValue2(add, typs.Uintptr, idx, s.uintptrConstant(uint64(s.config.PtrSize))) + e := s.newValue2(ssa.OpAddPtr, typs.UintptrPtr, cache, idx) + // hash++ + s.vars[hashVar] = s.newValue2(add, typs.Uintptr, s.variable(hashVar, typs.Uintptr), s.uintptrConstant(1)) + + // Look for a cache hit. + // if e.Typ == typ { goto hit } + eTyp := s.newValue2(ssa.OpLoad, typs.Uintptr, e, s.mem()) + cmp1 := s.newValue2(ssa.OpEqPtr, typs.Bool, typ, eTyp) + b = s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp1) + b.AddEdgeTo(cacheHit) + b.AddEdgeTo(loopBody) + + // Look for an empty entry, the tombstone for this hash table. + // if e.Typ == nil { goto miss } + s.startBlock(loopBody) + cmp2 := s.newValue2(ssa.OpEqPtr, typs.Bool, eTyp, s.constNil(typs.BytePtr)) + b = s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp2) + b.AddEdgeTo(cacheMiss) + b.AddEdgeTo(loopHead) + + // On a hit, load the data fields of the cache entry. + // Itab = e.Itab + s.startBlock(cacheHit) + eItab := s.newValue2(ssa.OpLoad, typs.BytePtr, s.newValue1I(ssa.OpOffPtr, typs.BytePtrPtr, s.config.PtrSize, e), s.mem()) + s.vars[typVar] = eItab + b = s.endBlock() + b.AddEdgeTo(bMerge) + + // On a miss, call into the runtime to get the answer. + s.startBlock(cacheMiss) + } + } + + // Call into runtime to get itab for result. + if descriptor != nil { + itab = s.rtcall(ir.Syms.TypeAssert, true, []*types.Type{byteptr}, d, typ)[0] + } else { + var fn *obj.LSym + if commaok { + fn = ir.Syms.AssertE2I2 + } else { + fn = ir.Syms.AssertE2I + } + itab = s.rtcall(fn, true, []*types.Type{byteptr}, target, typ)[0] + } + s.vars[typVar] = itab + b = s.endBlock() + b.AddEdgeTo(bMerge) + + // Build resulting interface. + s.startBlock(bMerge) + itab = s.variable(typVar, byteptr) + var ok *ssa.Value + if commaok { + ok = s.newValue2(ssa.OpNeqPtr, types.Types[types.TBOOL], itab, s.constNil(byteptr)) + } + return s.newValue2(ssa.OpIMake, dst, itab, data), ok + } + + if base.Debug.TypeAssert > 0 { + base.WarnfAt(pos, "type assertion inlined") + } + + // Converting to a concrete type. + direct := types.IsDirectIface(dst) + itab := s.newValue1(ssa.OpITab, byteptr, iface) // type word of interface + if base.Debug.TypeAssert > 0 { + base.WarnfAt(pos, "type assertion inlined") + } + var wantedFirstWord *ssa.Value + if src.IsEmptyInterface() { + // Looking for pointer to target type. + wantedFirstWord = target + } else { + // Looking for pointer to itab for target type and source interface. + wantedFirstWord = targetItab + } + + var tmp ir.Node // temporary for use with large types + var addr *ssa.Value // address of tmp + if commaok && !ssa.CanSSA(dst) { + // unSSAable type, use temporary. + // TODO: get rid of some of these temporaries. + tmp, addr = s.temp(pos, dst) + } + + cond := s.newValue2(ssa.OpEqPtr, types.Types[types.TBOOL], itab, wantedFirstWord) + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cond) + b.Likely = ssa.BranchLikely + + bOk := s.f.NewBlock(ssa.BlockPlain) + bFail := s.f.NewBlock(ssa.BlockPlain) + b.AddEdgeTo(bOk) + b.AddEdgeTo(bFail) + + if !commaok { + // on failure, panic by calling panicdottype + s.startBlock(bFail) + taddr := source + if taddr == nil { + taddr = s.reflectType(src) + } + if src.IsEmptyInterface() { + s.rtcall(ir.Syms.PanicdottypeE, false, nil, itab, target, taddr) + } else { + s.rtcall(ir.Syms.PanicdottypeI, false, nil, itab, target, taddr) + } + + // on success, return data from interface + s.startBlock(bOk) + if direct { + return s.newValue1(ssa.OpIData, dst, iface), nil + } + p := s.newValue1(ssa.OpIData, types.NewPtr(dst), iface) + return s.load(dst, p), nil + } + + // commaok is the more complicated case because we have + // a control flow merge point. + bEnd := s.f.NewBlock(ssa.BlockPlain) + // Note that we need a new valVar each time (unlike okVar where we can + // reuse the variable) because it might have a different type every time. + valVar := ssaMarker("val") + + // type assertion succeeded + s.startBlock(bOk) + if tmp == nil { + if direct { + s.vars[valVar] = s.newValue1(ssa.OpIData, dst, iface) + } else { + p := s.newValue1(ssa.OpIData, types.NewPtr(dst), iface) + s.vars[valVar] = s.load(dst, p) + } + } else { + p := s.newValue1(ssa.OpIData, types.NewPtr(dst), iface) + s.move(dst, addr, p) + } + s.vars[okVar] = s.constBool(true) + s.endBlock() + bOk.AddEdgeTo(bEnd) + + // type assertion failed + s.startBlock(bFail) + if tmp == nil { + s.vars[valVar] = s.zeroVal(dst) + } else { + s.zero(dst, addr) + } + s.vars[okVar] = s.constBool(false) + s.endBlock() + bFail.AddEdgeTo(bEnd) + + // merge point + s.startBlock(bEnd) + if tmp == nil { + res = s.variable(valVar, dst) + delete(s.vars, valVar) // no practical effect, just to indicate typVar is no longer live. + } else { + res = s.load(dst, addr) + } + resok = s.variable(okVar, types.Types[types.TBOOL]) + delete(s.vars, okVar) // ditto + return res, resok +} + +// temp allocates a temp of type t at position pos +func (s *state) temp(pos src.XPos, t *types.Type) (*ir.Name, *ssa.Value) { + tmp := typecheck.TempAt(pos, s.curfn, t) + if t.HasPointers() || (ssa.IsMergeCandidate(tmp) && t != deferstruct()) { + s.vars[memVar] = s.newValue1A(ssa.OpVarDef, types.TypeMem, tmp, s.mem()) + } + addr := s.addr(tmp) + return tmp, addr +} + +// variable returns the value of a variable at the current location. +func (s *state) variable(n ir.Node, t *types.Type) *ssa.Value { + v := s.vars[n] + if v != nil { + return v + } + v = s.fwdVars[n] + if v != nil { + return v + } + + if s.curBlock == s.f.Entry { + // No variable should be live at entry. + s.f.Fatalf("value %v (%v) incorrectly live at entry", n, v) + } + // Make a FwdRef, which records a value that's live on block input. + // We'll find the matching definition as part of insertPhis. + v = s.newValue0A(ssa.OpFwdRef, t, fwdRefAux{N: n}) + s.fwdVars[n] = v + if n.Op() == ir.ONAME { + s.addNamedValue(n.(*ir.Name), v) + } + return v +} + +func (s *state) mem() *ssa.Value { + return s.variable(memVar, types.TypeMem) +} + +func (s *state) addNamedValue(n *ir.Name, v *ssa.Value) { + if n.Class == ir.Pxxx { + // Don't track our marker nodes (memVar etc.). + return + } + if ir.IsAutoTmp(n) { + // Don't track temporary variables. + return + } + if n.Class == ir.PPARAMOUT { + // Don't track named output values. This prevents return values + // from being assigned too early. See #14591 and #14762. TODO: allow this. + return + } + loc := ssa.LocalSlot{N: n, Type: n.Type(), Off: 0} + values, ok := s.f.NamedValues[loc] + if !ok { + s.f.Names = append(s.f.Names, &loc) + s.f.CanonicalLocalSlots[loc] = &loc + } + s.f.NamedValues[loc] = append(values, v) +} + +// Branch is an unresolved branch. +type Branch struct { + P *obj.Prog // branch instruction + B *ssa.Block // target +} + +// State contains state needed during Prog generation. +type State struct { + ABI obj.ABI + + pp *objw.Progs + + // Branches remembers all the branch instructions we've seen + // and where they would like to go. + Branches []Branch + + // JumpTables remembers all the jump tables we've seen. + JumpTables []*ssa.Block + + // bstart remembers where each block starts (indexed by block ID) + bstart []*obj.Prog + + maxarg int64 // largest frame size for arguments to calls made by the function + + // Map from GC safe points to liveness index, generated by + // liveness analysis. + livenessMap liveness.Map + + // partLiveArgs includes arguments that may be partially live, for which we + // need to generate instructions that spill the argument registers. + partLiveArgs map[*ir.Name]bool + + // lineRunStart records the beginning of the current run of instructions + // within a single block sharing the same line number + // Used to move statement marks to the beginning of such runs. + lineRunStart *obj.Prog + + // wasm: The number of values on the WebAssembly stack. This is only used as a safeguard. + OnWasmStackSkipped int +} + +func (s *State) FuncInfo() *obj.FuncInfo { + return s.pp.CurFunc.LSym.Func() +} + +// Prog appends a new Prog. +func (s *State) Prog(as obj.As) *obj.Prog { + p := s.pp.Prog(as) + if objw.LosesStmtMark(as) { + return p + } + // Float a statement start to the beginning of any same-line run. + // lineRunStart is reset at block boundaries, which appears to work well. + if s.lineRunStart == nil || s.lineRunStart.Pos.Line() != p.Pos.Line() { + s.lineRunStart = p + } else if p.Pos.IsStmt() == src.PosIsStmt { + s.lineRunStart.Pos = s.lineRunStart.Pos.WithIsStmt() + p.Pos = p.Pos.WithNotStmt() + } + return p +} + +// Pc returns the current Prog. +func (s *State) Pc() *obj.Prog { + return s.pp.Next +} + +// SetPos sets the current source position. +func (s *State) SetPos(pos src.XPos) { + s.pp.Pos = pos +} + +// Br emits a single branch instruction and returns the instruction. +// Not all architectures need the returned instruction, but otherwise +// the boilerplate is common to all. +func (s *State) Br(op obj.As, target *ssa.Block) *obj.Prog { + p := s.Prog(op) + p.To.Type = obj.TYPE_BRANCH + s.Branches = append(s.Branches, Branch{P: p, B: target}) + return p +} + +// DebugFriendlySetPosFrom adjusts Pos.IsStmt subject to heuristics +// that reduce "jumpy" line number churn when debugging. +// Spill/fill/copy instructions from the register allocator, +// phi functions, and instructions with a no-pos position +// are examples of instructions that can cause churn. +func (s *State) DebugFriendlySetPosFrom(v *ssa.Value) { + switch v.Op { + case ssa.OpPhi, ssa.OpCopy, ssa.OpLoadReg, ssa.OpStoreReg: + // These are not statements + s.SetPos(v.Pos.WithNotStmt()) + default: + p := v.Pos + if p != src.NoXPos { + // If the position is defined, update the position. + // Also convert default IsStmt to NotStmt; only + // explicit statement boundaries should appear + // in the generated code. + if p.IsStmt() != src.PosIsStmt { + if s.pp.Pos.IsStmt() == src.PosIsStmt && s.pp.Pos.SameFileAndLine(p) { + // If s.pp.Pos already has a statement mark, then it was set here (below) for + // the previous value. If an actual instruction had been emitted for that + // value, then the statement mark would have been reset. Since the statement + // mark of s.pp.Pos was not reset, this position (file/line) still needs a + // statement mark on an instruction. If file and line for this value are + // the same as the previous value, then the first instruction for this + // value will work to take the statement mark. Return early to avoid + // resetting the statement mark. + // + // The reset of s.pp.Pos occurs in (*Progs).Prog() -- if it emits + // an instruction, and the instruction's statement mark was set, + // and it is not one of the LosesStmtMark instructions, + // then Prog() resets the statement mark on the (*Progs).Pos. + return + } + p = p.WithNotStmt() + // Calls use the pos attached to v, but copy the statement mark from State + } + s.SetPos(p) + } else { + s.SetPos(s.pp.Pos.WithNotStmt()) + } + } +} + +// emit argument info (locations on stack) for traceback. +func emitArgInfo(e *ssafn, f *ssa.Func, pp *objw.Progs) { + ft := e.curfn.Type() + if ft.NumRecvs() == 0 && ft.NumParams() == 0 { + return + } + + x := EmitArgInfo(e.curfn, f.OwnAux.ABIInfo()) + x.Set(obj.AttrContentAddressable, true) + e.curfn.LSym.Func().ArgInfo = x + + // Emit a funcdata pointing at the arg info data. + p := pp.Prog(obj.AFUNCDATA) + p.From.SetConst(rtabi.FUNCDATA_ArgInfo) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = x +} + +// emit argument info (locations on stack) of f for traceback. +func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym { + x := base.Ctxt.Lookup(fmt.Sprintf("%s.arginfo%d", f.LSym.Name, f.ABI)) + // NOTE: do not set ContentAddressable here. This may be referenced from + // assembly code by name (in this case f is a declaration). + // Instead, set it in emitArgInfo above. + + PtrSize := int64(types.PtrSize) + uintptrTyp := types.Types[types.TUINTPTR] + + isAggregate := func(t *types.Type) bool { + return isStructNotSIMD(t) || t.IsArray() || t.IsComplex() || t.IsInterface() || t.IsString() || t.IsSlice() + } + + wOff := 0 + n := 0 + writebyte := func(o uint8) { wOff = objw.Uint8(x, wOff, o) } + + // Write one non-aggregate arg/field/element. + write1 := func(sz, offset int64) { + if offset >= rtabi.TraceArgsSpecial { + writebyte(rtabi.TraceArgsOffsetTooLarge) + } else { + writebyte(uint8(offset)) + writebyte(uint8(sz)) + } + n++ + } + + // Visit t recursively and write it out. + // Returns whether to continue visiting. + var visitType func(baseOffset int64, t *types.Type, depth int) bool + visitType = func(baseOffset int64, t *types.Type, depth int) bool { + if n >= rtabi.TraceArgsLimit { + writebyte(rtabi.TraceArgsDotdotdot) + return false + } + if !isAggregate(t) { + write1(t.Size(), baseOffset) + return true + } + writebyte(rtabi.TraceArgsStartAgg) + depth++ + if depth >= rtabi.TraceArgsMaxDepth { + writebyte(rtabi.TraceArgsDotdotdot) + writebyte(rtabi.TraceArgsEndAgg) + n++ + return true + } + switch { + case t.IsInterface(), t.IsString(): + _ = visitType(baseOffset, uintptrTyp, depth) && + visitType(baseOffset+PtrSize, uintptrTyp, depth) + case t.IsSlice(): + _ = visitType(baseOffset, uintptrTyp, depth) && + visitType(baseOffset+PtrSize, uintptrTyp, depth) && + visitType(baseOffset+PtrSize*2, uintptrTyp, depth) + case t.IsComplex(): + _ = visitType(baseOffset, types.FloatForComplex(t), depth) && + visitType(baseOffset+t.Size()/2, types.FloatForComplex(t), depth) + case t.IsArray(): + if t.NumElem() == 0 { + n++ // {} counts as a component + break + } + for i := int64(0); i < t.NumElem(); i++ { + if !visitType(baseOffset, t.Elem(), depth) { + break + } + baseOffset += t.Elem().Size() + } + case isStructNotSIMD(t): + if t.NumFields() == 0 { + n++ // {} counts as a component + break + } + for _, field := range t.Fields() { + if !visitType(baseOffset+field.Offset, field.Type, depth) { + break + } + } + } + writebyte(rtabi.TraceArgsEndAgg) + return true + } + + start := 0 + if strings.Contains(f.LSym.Name, "[") { + // Skip the dictionary argument - it is implicit and the user doesn't need to see it. + start = 1 + } + + for _, a := range abiInfo.InParams()[start:] { + if !visitType(a.FrameOffset(abiInfo), a.Type, 0) { + break + } + } + writebyte(rtabi.TraceArgsEndSeq) + if wOff > rtabi.TraceArgsMaxLen { + base.Fatalf("ArgInfo too large") + } + + return x +} + +// for wrapper, emit info of wrapped function. +func emitWrappedFuncInfo(e *ssafn, pp *objw.Progs) { + if base.Ctxt.Flag_linkshared { + // Relative reference (SymPtrOff) to another shared object doesn't work. + // Unfortunate. + return + } + + wfn := e.curfn.WrappedFunc + if wfn == nil { + return + } + + wsym := wfn.Linksym() + x := base.Ctxt.LookupInit(fmt.Sprintf("%s.wrapinfo", wsym.Name), func(x *obj.LSym) { + objw.SymPtrOff(x, 0, wsym) + x.Set(obj.AttrContentAddressable, true) + }) + e.curfn.LSym.Func().WrapInfo = x + + // Emit a funcdata pointing at the wrap info data. + p := pp.Prog(obj.AFUNCDATA) + p.From.SetConst(rtabi.FUNCDATA_WrapInfo) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = x +} + +// genssa appends entries to pp for each instruction in f. +func genssa(f *ssa.Func, pp *objw.Progs) { + var s State + s.ABI = f.OwnAux.Fn.ABI() + + e := f.Frontend().(*ssafn) + + gatherPrintInfo := f.PrintOrHtmlSSA || ssa.GenssaDump[f.Name] + + var lv *liveness.Liveness + s.livenessMap, s.partLiveArgs, lv = liveness.Compute(e.curfn, f, e.stkptrsize, pp, gatherPrintInfo) + emitArgInfo(e, f, pp) + argLiveBlockMap, argLiveValueMap := liveness.ArgLiveness(e.curfn, f, pp) + + openDeferInfo := e.curfn.LSym.Func().OpenCodedDeferInfo + if openDeferInfo != nil { + // This function uses open-coded defers -- write out the funcdata + // info that we computed at the end of genssa. + p := pp.Prog(obj.AFUNCDATA) + p.From.SetConst(rtabi.FUNCDATA_OpenCodedDeferInfo) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = openDeferInfo + } + + emitWrappedFuncInfo(e, pp) + + // Remember where each block starts. + s.bstart = make([]*obj.Prog, f.NumBlocks()) + s.pp = pp + var progToValue map[*obj.Prog]*ssa.Value + var progToBlock map[*obj.Prog]*ssa.Block + var valueToProgAfter []*obj.Prog // The first Prog following computation of a value v; v is visible at this point. + if gatherPrintInfo { + progToValue = make(map[*obj.Prog]*ssa.Value, f.NumValues()) + progToBlock = make(map[*obj.Prog]*ssa.Block, f.NumBlocks()) + f.Logf("genssa %s\n", f.Name) + progToBlock[s.pp.Next] = f.Blocks[0] + } + + if base.Ctxt.Flag_locationlists { + if cap(f.Cache.ValueToProgAfter) < f.NumValues() { + f.Cache.ValueToProgAfter = make([]*obj.Prog, f.NumValues()) + } + valueToProgAfter = f.Cache.ValueToProgAfter[:f.NumValues()] + clear(valueToProgAfter) + } + + // If the very first instruction is not tagged as a statement, + // debuggers may attribute it to previous function in program. + firstPos := src.NoXPos + for _, v := range f.Entry.Values { + if v.Pos.IsStmt() == src.PosIsStmt && v.Op != ssa.OpArg && v.Op != ssa.OpArgIntReg && v.Op != ssa.OpArgFloatReg && v.Op != ssa.OpLoadReg && v.Op != ssa.OpStoreReg { + firstPos = v.Pos + v.Pos = firstPos.WithDefaultStmt() + break + } + } + + // inlMarks has an entry for each Prog that implements an inline mark. + // It maps from that Prog to the global inlining id of the inlined body + // which should unwind to this Prog's location. + var inlMarks map[*obj.Prog]int32 + var inlMarkList []*obj.Prog + + // inlMarksByPos maps from a (column 1) source position to the set of + // Progs that are in the set above and have that source position. + var inlMarksByPos map[src.XPos][]*obj.Prog + + var argLiveIdx int = -1 // argument liveness info index + + // These control cache line alignment; if the required portion of + // a cache line is not available, then pad to obtain cache line + // alignment. Not implemented on all architectures, may not be + // useful on all architectures. + var hotAlign, hotRequire int64 + + if base.Debug.AlignHot > 0 { + switch base.Ctxt.Arch.Name { + // enable this on a case-by-case basis, with benchmarking. + // currently shown: + // good for amd64 + // not helpful for Apple Silicon + // + case "amd64", "386": + // Align to 64 if 31 or fewer bytes remain in a cache line + // benchmarks a little better than always aligning, and also + // adds slightly less to the (PGO-compiled) binary size. + hotAlign = 64 + hotRequire = 31 + } + } + + // Emit basic blocks + for i, b := range f.Blocks { + + s.lineRunStart = nil + s.SetPos(s.pp.Pos.WithNotStmt()) // It needs a non-empty Pos, but cannot be a statement boundary (yet). + + if hotAlign > 0 && b.Hotness&ssa.HotPgoInitial == ssa.HotPgoInitial { + // So far this has only been shown profitable for PGO-hot loop headers. + // The Hotness values allows distinctions between initial blocks that are "hot" or not, and "flow-in" or not. + // Currently only the initial blocks of loops are tagged in this way; + // there are no blocks tagged "pgo-hot" that are not also tagged "initial". + // TODO more heuristics, more architectures. + p := s.pp.Prog(obj.APCALIGNMAX) + p.From.SetConst(hotAlign) + p.To.SetConst(hotRequire) + } + + s.bstart[b.ID] = s.pp.Next + + if idx, ok := argLiveBlockMap[b.ID]; ok && idx != argLiveIdx { + argLiveIdx = idx + p := s.pp.Prog(obj.APCDATA) + p.From.SetConst(rtabi.PCDATA_ArgLiveIndex) + p.To.SetConst(int64(idx)) + } + + // Emit values in block + Arch.SSAMarkMoves(&s, b) + for _, v := range b.Values { + x := s.pp.Next + s.DebugFriendlySetPosFrom(v) + + if v.Op.ResultInArg0() && v.ResultReg() != v.Args[0].Reg() { + v.Fatalf("input[0] and output not in same register %s", v.LongString()) + } + + switch v.Op { + case ssa.OpInitMem: + // memory arg needs no code + case ssa.OpArg: + // input args need no code + case ssa.OpSP, ssa.OpSB: + // nothing to do + case ssa.OpSelect0, ssa.OpSelect1, ssa.OpSelectN, ssa.OpMakeResult: + // nothing to do + case ssa.OpGetG: + // nothing to do when there's a g register, + // and checkLower complains if there's not + case ssa.OpVarDef, ssa.OpVarLive, ssa.OpKeepAlive, ssa.OpWBend: + // nothing to do; already used by liveness + case ssa.OpPhi: + CheckLoweredPhi(v) + case ssa.OpConvert: + // nothing to do; no-op conversion for liveness + if v.Args[0].Reg() != v.Reg() { + v.Fatalf("OpConvert should be a no-op: %s; %s", v.Args[0].LongString(), v.LongString()) + } + case ssa.OpInlMark: + p := Arch.Ginsnop(s.pp) + if inlMarks == nil { + inlMarks = map[*obj.Prog]int32{} + inlMarksByPos = map[src.XPos][]*obj.Prog{} + } + inlMarks[p] = v.AuxInt32() + inlMarkList = append(inlMarkList, p) + pos := v.Pos.AtColumn1() + inlMarksByPos[pos] = append(inlMarksByPos[pos], p) + firstPos = src.NoXPos + + default: + // Special case for first line in function; move it to the start (which cannot be a register-valued instruction) + if firstPos != src.NoXPos && v.Op != ssa.OpArgIntReg && v.Op != ssa.OpArgFloatReg && v.Op != ssa.OpLoadReg && v.Op != ssa.OpStoreReg { + s.SetPos(firstPos) + firstPos = src.NoXPos + } + // Attach this safe point to the next + // instruction. + s.pp.NextLive = s.livenessMap.Get(v) + s.pp.NextUnsafe = s.livenessMap.GetUnsafe(v) + + // let the backend handle it + Arch.SSAGenValue(&s, v) + } + + if idx, ok := argLiveValueMap[v.ID]; ok && idx != argLiveIdx { + argLiveIdx = idx + p := s.pp.Prog(obj.APCDATA) + p.From.SetConst(rtabi.PCDATA_ArgLiveIndex) + p.To.SetConst(int64(idx)) + } + + if base.Ctxt.Flag_locationlists { + valueToProgAfter[v.ID] = s.pp.Next + } + + if gatherPrintInfo { + for ; x != s.pp.Next; x = x.Link { + progToValue[x] = v + } + } + } + // If this is an empty infinite loop, stick a hardware NOP in there so that debuggers are less confused. + if s.bstart[b.ID] == s.pp.Next && len(b.Succs) == 1 && b.Succs[0].Block() == b { + p := Arch.Ginsnop(s.pp) + p.Pos = p.Pos.WithIsStmt() + if b.Pos == src.NoXPos { + b.Pos = p.Pos // It needs a file, otherwise a no-file non-zero line causes confusion. See #35652. + if b.Pos == src.NoXPos { + b.Pos = s.pp.Text.Pos // Sometimes p.Pos is empty. See #35695. + } + } + b.Pos = b.Pos.WithBogusLine() // Debuggers are not good about infinite loops, force a change in line number + } + + // Set unsafe mark for any end-of-block generated instructions + // (normally, conditional or unconditional branches). + // This is particularly important for empty blocks, as there + // are no values to inherit the unsafe mark from. + s.pp.NextUnsafe = s.livenessMap.GetUnsafeBlock(b) + + // Emit control flow instructions for block + var next *ssa.Block + if i < len(f.Blocks)-1 && base.Flag.N == 0 { + // If -N, leave next==nil so every block with successors + // ends in a JMP (except call blocks - plive doesn't like + // select{send,recv} followed by a JMP call). Helps keep + // line numbers for otherwise empty blocks. + next = f.Blocks[i+1] + } + x := s.pp.Next + s.SetPos(b.Pos) + Arch.SSAGenBlock(&s, b, next) + if gatherPrintInfo { + for ; x != s.pp.Next; x = x.Link { + progToBlock[x] = b + } + } + } + if f.Blocks[len(f.Blocks)-1].Kind == ssa.BlockExit { + // We need the return address of a panic call to + // still be inside the function in question. So if + // it ends in a call which doesn't return, add a + // nop (which will never execute) after the call. + Arch.Ginsnop(s.pp) + } + if openDeferInfo != nil { + // When doing open-coded defers, generate a disconnected call to + // deferreturn and a return. This will be used to during panic + // recovery to unwind the stack and return back to the runtime. + + // Note that this exit code doesn't work if a return parameter + // is heap-allocated, but open defers aren't enabled in that case. + + // TODO either make this handle heap-allocated return parameters or reuse the other-defers general-purpose code path. + s.pp.NextLive = s.livenessMap.DeferReturn + p := s.pp.Prog(obj.ACALL) + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = ir.Syms.Deferreturn + + // Load results into registers. So when a deferred function + // recovers a panic, it will return to caller with right results. + // The results are already in memory, because they are not SSA'd + // when the function has defers (see canSSAName). + for _, o := range f.OwnAux.ABIInfo().OutParams() { + n := o.Name + rts, offs := o.RegisterTypesAndOffsets() + for i := range o.Registers { + Arch.LoadRegResult(&s, f, rts[i], ssa.ObjRegForAbiReg(o.Registers[i], f.Config), n, offs[i]) + } + } + + s.pp.Prog(obj.ARET) + } + + if inlMarks != nil { + hasCall := false + + // We have some inline marks. Try to find other instructions we're + // going to emit anyway, and use those instructions instead of the + // inline marks. + for p := s.pp.Text; p != nil; p = p.Link { + if p.As == obj.ANOP || p.As == obj.AFUNCDATA || p.As == obj.APCDATA || p.As == obj.ATEXT || + p.As == obj.APCALIGN || p.As == obj.APCALIGNMAX || Arch.LinkArch.Family == sys.Wasm { + // Don't use 0-sized instructions as inline marks, because we need + // to identify inline mark instructions by pc offset. + // (Some of these instructions are sometimes zero-sized, sometimes not. + // We must not use anything that even might be zero-sized.) + // TODO: are there others? + continue + } + if _, ok := inlMarks[p]; ok { + // Don't use inline marks themselves. We don't know + // whether they will be zero-sized or not yet. + continue + } + if p.As == obj.ACALL || p.As == obj.ADUFFCOPY || p.As == obj.ADUFFZERO { + hasCall = true + } + pos := p.Pos.AtColumn1() + marks := inlMarksByPos[pos] + if len(marks) == 0 { + continue + } + for _, m := range marks { + // We found an instruction with the same source position as + // some of the inline marks. + // Use this instruction instead. + p.Pos = p.Pos.WithIsStmt() // promote position to a statement + s.pp.CurFunc.LSym.Func().AddInlMark(p, inlMarks[m]) + // Make the inline mark a real nop, so it doesn't generate any code. + m.As = obj.ANOP + m.Pos = src.NoXPos + m.From = obj.Addr{} + m.To = obj.Addr{} + } + delete(inlMarksByPos, pos) + } + // Any unmatched inline marks now need to be added to the inlining tree (and will generate a nop instruction). + for _, p := range inlMarkList { + if p.As != obj.ANOP { + s.pp.CurFunc.LSym.Func().AddInlMark(p, inlMarks[p]) + } + } + + if e.stksize == 0 && !hasCall { + // Frameless leaf function. It doesn't need any preamble, + // so make sure its first instruction isn't from an inlined callee. + // If it is, add a nop at the start of the function with a position + // equal to the start of the function. + // This ensures that runtime.FuncForPC(uintptr(reflect.ValueOf(fn).Pointer())).Name() + // returns the right answer. See issue 58300. + for p := s.pp.Text; p != nil; p = p.Link { + if p.As == obj.AFUNCDATA || p.As == obj.APCDATA || p.As == obj.ATEXT || p.As == obj.ANOP { + continue + } + if base.Ctxt.PosTable.Pos(p.Pos).Base().InliningIndex() >= 0 { + // Make a real (not 0-sized) nop. + nop := Arch.Ginsnop(s.pp) + nop.Pos = e.curfn.Pos().WithIsStmt() + + // Unfortunately, Ginsnop puts the instruction at the + // end of the list. Move it up to just before p. + + // Unlink from the current list. + for x := s.pp.Text; x != nil; x = x.Link { + if x.Link == nop { + x.Link = nop.Link + break + } + } + // Splice in right before p. + for x := s.pp.Text; x != nil; x = x.Link { + if x.Link == p { + nop.Link = p + x.Link = nop + break + } + } + } + break + } + } + } + + if base.Ctxt.Flag_locationlists { + var debugInfo *ssa.FuncDebug + debugInfo = e.curfn.DebugInfo.(*ssa.FuncDebug) + // Save off entry ID in case we need it later for DWARF generation + // for return values promoted to the heap. + debugInfo.EntryID = f.Entry.ID + if e.curfn.ABI == obj.ABIInternal && base.Flag.N != 0 { + ssa.BuildFuncDebugNoOptimized(base.Ctxt, f, base.Debug.LocationLists > 1, StackOffset, debugInfo) + } else { + ssa.BuildFuncDebug(base.Ctxt, f, base.Debug.LocationLists, StackOffset, debugInfo) + } + bstart := s.bstart + idToIdx := make([]int, f.NumBlocks()) + for i, b := range f.Blocks { + idToIdx[b.ID] = i + } + // Register a callback that will be used later to fill in PCs into location + // lists. At the moment, Prog.Pc is a sequence number; it's not a real PC + // until after assembly, so the translation needs to be deferred. + debugInfo.GetPC = func(b, v ssa.ID) int64 { + switch v { + case ssa.BlockStart.ID: + if b == f.Entry.ID { + return 0 // Start at the very beginning, at the assembler-generated prologue. + // this should only happen for function args (ssa.OpArg) + } + return bstart[b].Pc + case ssa.BlockEnd.ID: + blk := f.Blocks[idToIdx[b]] + nv := len(blk.Values) + return valueToProgAfter[blk.Values[nv-1].ID].Pc + case ssa.FuncEnd.ID: + return e.curfn.LSym.Size + default: + return valueToProgAfter[v].Pc + } + } + } + + // Resolve branches, and relax DefaultStmt into NotStmt + for _, br := range s.Branches { + br.P.To.SetTarget(s.bstart[br.B.ID]) + if br.P.Pos.IsStmt() != src.PosIsStmt { + br.P.Pos = br.P.Pos.WithNotStmt() + } else if v0 := br.B.FirstPossibleStmtValue(); v0 != nil && v0.Pos.Line() == br.P.Pos.Line() && v0.Pos.IsStmt() == src.PosIsStmt { + br.P.Pos = br.P.Pos.WithNotStmt() + } + + } + + // Resolve jump table destinations. + for _, jt := range s.JumpTables { + // Convert from *Block targets to *Prog targets. + targets := make([]*obj.Prog, len(jt.Succs)) + for i, e := range jt.Succs { + targets[i] = s.bstart[e.Block().ID] + } + // Add to list of jump tables to be resolved at assembly time. + // The assembler converts from *Prog entries to absolute addresses + // once it knows instruction byte offsets. + fi := s.pp.CurFunc.LSym.Func() + fi.JumpTables = append(fi.JumpTables, obj.JumpTable{Sym: jt.Aux.(*obj.LSym), Targets: targets}) + } + + if e.log { // spew to stdout + filename := "" + for p := s.pp.Text; p != nil; p = p.Link { + if p.Pos.IsKnown() && p.InnermostFilename() != filename { + filename = p.InnermostFilename() + f.Logf("# %s\n", filename) + } + + var s string + if v, ok := progToValue[p]; ok { + s = v.String() + } else if b, ok := progToBlock[p]; ok { + s = b.String() + } else { + s = " " // most value and branch strings are 2-3 characters long + } + f.Logf(" %-6s\t%.5d (%s)\t%s\n", s, p.Pc, p.InnermostLineNumber(), p.InstructionString()) + } + } + if f.HTMLWriter != nil { // spew to ssa.html + var buf strings.Builder + buf.WriteString("") + buf.WriteString("
    ") + filename := "" + + liveness := lv.Format(nil) + if liveness != "" { + buf.WriteString("
    ") + buf.WriteString(html.EscapeString("# " + liveness)) + buf.WriteString("
    ") + } + + for p := s.pp.Text; p != nil; p = p.Link { + // Don't spam every line with the file name, which is often huge. + // Only print changes, and "unknown" is not a change. + if p.Pos.IsKnown() && p.InnermostFilename() != filename { + filename = p.InnermostFilename() + buf.WriteString("
    ") + buf.WriteString(html.EscapeString("# " + filename)) + buf.WriteString("
    ") + } + + buf.WriteString("
    ") + if v, ok := progToValue[p]; ok { + + // Prefix calls with their liveness, if any + if p.As != obj.APCDATA { + if liveness := lv.Format(v); liveness != "" { + // Steal this line, and restart a line + buf.WriteString("
    ") + buf.WriteString(html.EscapeString("# " + liveness)) + buf.WriteString("
    ") + // restarting a line + buf.WriteString("
    ") + } + } + + buf.WriteString(v.HTML()) + } else if b, ok := progToBlock[p]; ok { + buf.WriteString("" + b.HTML() + "") + } + buf.WriteString("
    ") + buf.WriteString("
    ") + fmt.Fprintf(&buf, "%.5d (%s) %s", p.Pc, p.InnermostLineNumber(), p.InnermostLineNumberHTML(), html.EscapeString(p.InstructionString())) + buf.WriteString("
    ") + } + buf.WriteString("
    ") + buf.WriteString("
    ") + f.HTMLWriter.WriteColumn("genssa", "genssa", "ssa-prog", buf.String()) + } + if ssa.GenssaDump[f.Name] { + fi := f.DumpFileForPhase("genssa") + if fi != nil { + + // inliningDiffers if any filename changes or if any line number except the innermost (last index) changes. + inliningDiffers := func(a, b []src.Pos) bool { + if len(a) != len(b) { + return true + } + for i := range a { + if a[i].Filename() != b[i].Filename() { + return true + } + if i != len(a)-1 && a[i].Line() != b[i].Line() { + return true + } + } + return false + } + + var allPosOld []src.Pos + var allPos []src.Pos + + for p := s.pp.Text; p != nil; p = p.Link { + if p.Pos.IsKnown() { + allPos = allPos[:0] + p.Ctxt.AllPos(p.Pos, func(pos src.Pos) { allPos = append(allPos, pos) }) + if inliningDiffers(allPos, allPosOld) { + for _, pos := range allPos { + fmt.Fprintf(fi, "# %s:%d\n", pos.Filename(), pos.Line()) + } + allPos, allPosOld = allPosOld, allPos // swap, not copy, so that they do not share slice storage. + } + } + + var s string + if v, ok := progToValue[p]; ok { + s = v.String() + } else if b, ok := progToBlock[p]; ok { + s = b.String() + } else { + s = " " // most value and branch strings are 2-3 characters long + } + fmt.Fprintf(fi, " %-6s\t%.5d %s\t%s\n", s, p.Pc, ssa.StmtString(p.Pos), p.InstructionString()) + } + fi.Close() + } + } + + defframe(&s, e, f) + + f.HTMLWriter.Close() + f.HTMLWriter = nil +} + +func defframe(s *State, e *ssafn, f *ssa.Func) { + pp := s.pp + + s.maxarg = types.RoundUp(s.maxarg, e.stkalign) + frame := s.maxarg + e.stksize + if Arch.PadFrame != nil { + frame = Arch.PadFrame(frame) + } + + // Fill in argument and frame size. + pp.Text.To.Type = obj.TYPE_TEXTSIZE + pp.Text.To.Val = int32(types.RoundUp(f.OwnAux.ArgWidth(), int64(types.RegSize))) + pp.Text.To.Offset = frame + + p := pp.Text + + // Insert code to spill argument registers if the named slot may be partially + // live. That is, the named slot is considered live by liveness analysis, + // (because a part of it is live), but we may not spill all parts into the + // slot. This can only happen with aggregate-typed arguments that are SSA-able + // and not address-taken (for non-SSA-able or address-taken arguments we always + // spill upfront). + // Note: spilling is unnecessary in the -N/no-optimize case, since all values + // will be considered non-SSAable and spilled up front. + // TODO(register args) Make liveness more fine-grained to that partial spilling is okay. + if f.OwnAux.ABIInfo().InRegistersUsed() != 0 && base.Flag.N == 0 { + // First, see if it is already spilled before it may be live. Look for a spill + // in the entry block up to the first safepoint. + type nameOff struct { + n *ir.Name + off int64 + } + partLiveArgsSpilled := make(map[nameOff]bool) + for _, v := range f.Entry.Values { + if v.Op.IsCall() { + break + } + if v.Op != ssa.OpStoreReg || v.Args[0].Op != ssa.OpArgIntReg { + continue + } + n, off := ssa.AutoVar(v) + if n.Class != ir.PPARAM || n.Addrtaken() || !ssa.CanSSA(n.Type()) || !s.partLiveArgs[n] { + continue + } + partLiveArgsSpilled[nameOff{n, off}] = true + } + + // Then, insert code to spill registers if not already. + for _, a := range f.OwnAux.ABIInfo().InParams() { + n := a.Name + if n == nil || n.Addrtaken() || !ssa.CanSSA(n.Type()) || !s.partLiveArgs[n] || len(a.Registers) <= 1 { + continue + } + rts, offs := a.RegisterTypesAndOffsets() + for i := range a.Registers { + if !rts[i].HasPointers() { + continue + } + if partLiveArgsSpilled[nameOff{n, offs[i]}] { + continue // already spilled + } + reg := ssa.ObjRegForAbiReg(a.Registers[i], f.Config) + p = Arch.SpillArgReg(pp, p, f, rts[i], reg, n, offs[i]) + } + } + } + + // Insert code to zero ambiguously live variables so that the + // garbage collector only sees initialized values when it + // looks for pointers. + var lo, hi int64 + + // Opaque state for backend to use. Current backends use it to + // keep track of which helper registers have been zeroed. + var state uint32 + + // Iterate through declarations. Autos are sorted in decreasing + // frame offset order. + for _, n := range e.curfn.Dcl { + if !n.Needzero() { + continue + } + if n.Class != ir.PAUTO { + e.Fatalf(n.Pos(), "needzero class %d", n.Class) + } + if n.Type().Size()%int64(types.PtrSize) != 0 || n.FrameOffset()%int64(types.PtrSize) != 0 || n.Type().Size() == 0 { + e.Fatalf(n.Pos(), "var %L has size %d offset %d", n, n.Type().Size(), n.Offset_) + } + + if lo != hi && n.FrameOffset()+n.Type().Size() >= lo-int64(2*types.RegSize) { + // Merge with range we already have. + lo = n.FrameOffset() + continue + } + + // Zero old range + p = Arch.ZeroRange(pp, p, frame+lo, hi-lo, &state) + + // Set new range. + lo = n.FrameOffset() + hi = lo + n.Type().Size() + } + + // Zero final range. + Arch.ZeroRange(pp, p, frame+lo, hi-lo, &state) +} + +// For generating consecutive jump instructions to model a specific branching +type IndexJump struct { + Jump obj.As + Index int +} + +func (s *State) oneJump(b *ssa.Block, jump *IndexJump) { + p := s.Br(jump.Jump, b.Succs[jump.Index].Block()) + p.Pos = b.Pos +} + +// CombJump generates combinational instructions (2 at present) for a block jump, +// thereby the behaviour of non-standard condition codes could be simulated +func (s *State) CombJump(b, next *ssa.Block, jumps *[2][2]IndexJump) { + switch next { + case b.Succs[0].Block(): + s.oneJump(b, &jumps[0][0]) + s.oneJump(b, &jumps[0][1]) + case b.Succs[1].Block(): + s.oneJump(b, &jumps[1][0]) + s.oneJump(b, &jumps[1][1]) + default: + var q *obj.Prog + if b.Likely != ssa.BranchUnlikely { + s.oneJump(b, &jumps[1][0]) + s.oneJump(b, &jumps[1][1]) + q = s.Br(obj.AJMP, b.Succs[1].Block()) + } else { + s.oneJump(b, &jumps[0][0]) + s.oneJump(b, &jumps[0][1]) + q = s.Br(obj.AJMP, b.Succs[0].Block()) + } + q.Pos = b.Pos + } +} + +// AddAux adds the offset in the aux fields (AuxInt and Aux) of v to a. +func AddAux(a *obj.Addr, v *ssa.Value) { + AddAux2(a, v, v.AuxInt) +} +func AddAux2(a *obj.Addr, v *ssa.Value, offset int64) { + if a.Type != obj.TYPE_MEM && a.Type != obj.TYPE_ADDR { + v.Fatalf("bad AddAux addr %v", a) + } + // add integer offset + a.Offset += offset + + // If no additional symbol offset, we're done. + if v.Aux == nil { + return + } + // Add symbol's offset from its base register. + switch n := v.Aux.(type) { + case *ssa.AuxCall: + a.Name = obj.NAME_EXTERN + a.Sym = n.Fn + case *obj.LSym: + a.Name = obj.NAME_EXTERN + a.Sym = n + case *ir.Name: + if n.Class == ir.PPARAM || (n.Class == ir.PPARAMOUT && !n.IsOutputParamInRegisters()) { + a.Name = obj.NAME_PARAM + } else { + a.Name = obj.NAME_AUTO + } + a.Sym = n.Linksym() + a.Offset += n.FrameOffset() + default: + v.Fatalf("aux in %s not implemented %#v", v, v.Aux) + } +} + +// extendIndex extends v to a full int width. +// panic with the given kind if v does not fit in an int (only on 32-bit archs). +func (s *state) extendIndex(idx, len *ssa.Value, kind ssa.BoundsKind, bounded bool) *ssa.Value { + size := idx.Type.Size() + if size == s.config.PtrSize { + return idx + } + if size > s.config.PtrSize { + // truncate 64-bit indexes on 32-bit pointer archs. Test the + // high word and branch to out-of-bounds failure if it is not 0. + var lo *ssa.Value + if idx.Type.IsSigned() { + lo = s.newValue1(ssa.OpInt64Lo, types.Types[types.TINT], idx) + } else { + lo = s.newValue1(ssa.OpInt64Lo, types.Types[types.TUINT], idx) + } + if bounded || base.Flag.B != 0 { + return lo + } + bNext := s.f.NewBlock(ssa.BlockPlain) + bPanic := s.f.NewBlock(ssa.BlockExit) + hi := s.newValue1(ssa.OpInt64Hi, types.Types[types.TUINT32], idx) + cmp := s.newValue2(ssa.OpEq32, types.Types[types.TBOOL], hi, s.constInt32(types.Types[types.TUINT32], 0)) + if !idx.Type.IsSigned() { + switch kind { + case ssa.BoundsIndex: + kind = ssa.BoundsIndexU + case ssa.BoundsSliceAlen: + kind = ssa.BoundsSliceAlenU + case ssa.BoundsSliceAcap: + kind = ssa.BoundsSliceAcapU + case ssa.BoundsSliceB: + kind = ssa.BoundsSliceBU + case ssa.BoundsSlice3Alen: + kind = ssa.BoundsSlice3AlenU + case ssa.BoundsSlice3Acap: + kind = ssa.BoundsSlice3AcapU + case ssa.BoundsSlice3B: + kind = ssa.BoundsSlice3BU + case ssa.BoundsSlice3C: + kind = ssa.BoundsSlice3CU + } + } + b := s.endBlock() + b.Kind = ssa.BlockIf + b.SetControl(cmp) + b.Likely = ssa.BranchLikely + b.AddEdgeTo(bNext) + b.AddEdgeTo(bPanic) + + s.startBlock(bPanic) + mem := s.newValue4I(ssa.OpPanicExtend, types.TypeMem, int64(kind), hi, lo, len, s.mem()) + s.endBlock().SetControl(mem) + s.startBlock(bNext) + + return lo + } + + // Extend value to the required size + var op ssa.Op + if idx.Type.IsSigned() { + switch 10*size + s.config.PtrSize { + case 14: + op = ssa.OpSignExt8to32 + case 18: + op = ssa.OpSignExt8to64 + case 24: + op = ssa.OpSignExt16to32 + case 28: + op = ssa.OpSignExt16to64 + case 48: + op = ssa.OpSignExt32to64 + default: + s.Fatalf("bad signed index extension %s", idx.Type) + } + } else { + switch 10*size + s.config.PtrSize { + case 14: + op = ssa.OpZeroExt8to32 + case 18: + op = ssa.OpZeroExt8to64 + case 24: + op = ssa.OpZeroExt16to32 + case 28: + op = ssa.OpZeroExt16to64 + case 48: + op = ssa.OpZeroExt32to64 + default: + s.Fatalf("bad unsigned index extension %s", idx.Type) + } + } + return s.newValue1(op, types.Types[types.TINT], idx) +} + +// CheckLoweredPhi checks that regalloc and stackalloc correctly handled phi values. +// Called during ssaGenValue. +func CheckLoweredPhi(v *ssa.Value) { + if v.Op != ssa.OpPhi { + v.Fatalf("CheckLoweredPhi called with non-phi value: %v", v.LongString()) + } + if v.Type.IsMemory() { + return + } + f := v.Block.Func + loc := f.RegAlloc[v.ID] + for _, a := range v.Args { + if aloc := f.RegAlloc[a.ID]; aloc != loc { // TODO: .Equal() instead? + v.Fatalf("phi arg at different location than phi: %v @ %s, but arg %v @ %s\n%s\n", v, loc, a, aloc, v.Block.Func) + } + } +} + +// CheckLoweredGetClosurePtr checks that v is the first instruction in the function's entry block, +// except for incoming in-register arguments. +// The output of LoweredGetClosurePtr is generally hardwired to the correct register. +// That register contains the closure pointer on closure entry. +func CheckLoweredGetClosurePtr(v *ssa.Value) { + entry := v.Block.Func.Entry + if entry != v.Block { + base.Fatalf("in %s, badly placed LoweredGetClosurePtr: %v %v", v.Block.Func.Name, v.Block, v) + } + for _, w := range entry.Values { + if w == v { + break + } + switch w.Op { + case ssa.OpArgIntReg, ssa.OpArgFloatReg: + // okay + default: + base.Fatalf("in %s, badly placed LoweredGetClosurePtr: %v %v", v.Block.Func.Name, v.Block, v) + } + } +} + +// CheckArgReg ensures that v is in the function's entry block. +func CheckArgReg(v *ssa.Value) { + entry := v.Block.Func.Entry + if entry != v.Block { + base.Fatalf("in %s, badly placed ArgIReg or ArgFReg: %v %v", v.Block.Func.Name, v.Block, v) + } +} + +func AddrAuto(a *obj.Addr, v *ssa.Value) { + n, off := ssa.AutoVar(v) + a.Type = obj.TYPE_MEM + a.Sym = n.Linksym() + a.Reg = int16(Arch.REGSP) + a.Offset = n.FrameOffset() + off + if n.Class == ir.PPARAM || (n.Class == ir.PPARAMOUT && !n.IsOutputParamInRegisters()) { + a.Name = obj.NAME_PARAM + } else { + a.Name = obj.NAME_AUTO + } +} + +// Call returns a new CALL instruction for the SSA value v. +// It uses PrepareCall to prepare the call. +func (s *State) Call(v *ssa.Value) *obj.Prog { + pPosIsStmt := s.pp.Pos.IsStmt() // The statement-ness of the call comes from ssaGenState + s.PrepareCall(v) + + p := s.Prog(obj.ACALL) + if pPosIsStmt == src.PosIsStmt { + p.Pos = v.Pos.WithIsStmt() + } else { + p.Pos = v.Pos.WithNotStmt() + } + if sym, ok := v.Aux.(*ssa.AuxCall); ok && sym.Fn != nil { + p.To.Type = obj.TYPE_MEM + p.To.Name = obj.NAME_EXTERN + p.To.Sym = sym.Fn + } else { + // TODO(mdempsky): Can these differences be eliminated? + switch Arch.LinkArch.Family { + case sys.AMD64, sys.I386, sys.PPC64, sys.RISCV64, sys.S390X, sys.Wasm: + p.To.Type = obj.TYPE_REG + case sys.ARM, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64: + p.To.Type = obj.TYPE_MEM + default: + base.Fatalf("unknown indirect call family") + } + p.To.Reg = v.Args[0].Reg() + } + return p +} + +// TailCall returns a new tail call instruction for the SSA value v. +// It is like Call, but for a tail call. +func (s *State) TailCall(v *ssa.Value) *obj.Prog { + p := s.Call(v) + p.As = obj.ARET + return p +} + +// PrepareCall prepares to emit a CALL instruction for v and does call-related bookkeeping. +// It must be called immediately before emitting the actual CALL instruction, +// since it emits PCDATA for the stack map at the call (calls are safe points). +func (s *State) PrepareCall(v *ssa.Value) { + idx := s.livenessMap.Get(v) + if !idx.StackMapValid() { + // See Liveness.hasStackMap. + if sym, ok := v.Aux.(*ssa.AuxCall); !ok || !(sym.Fn == ir.Syms.WBZero || sym.Fn == ir.Syms.WBMove) { + base.Fatalf("missing stack map index for %v", v.LongString()) + } + } + + call, ok := v.Aux.(*ssa.AuxCall) + + if ok { + // Record call graph information for nowritebarrierrec + // analysis. + if nowritebarrierrecCheck != nil { + nowritebarrierrecCheck.recordCall(s.pp.CurFunc, call.Fn, v.Pos) + } + } + + if s.maxarg < v.AuxInt { + s.maxarg = v.AuxInt + } +} + +// UseArgs records the fact that an instruction needs a certain amount of +// callee args space for its use. +func (s *State) UseArgs(n int64) { + if s.maxarg < n { + s.maxarg = n + } +} + +// fieldIdx finds the index of the field referred to by the ODOT node n. +func fieldIdx(n *ir.SelectorExpr) int { + t := n.X.Type() + if !isStructNotSIMD(t) { + panic("ODOT's LHS is not a struct") + } + + for i, f := range t.Fields() { + if f.Sym == n.Sel { + if f.Offset != n.Offset() { + panic("field offset doesn't match") + } + return i + } + } + panic(fmt.Sprintf("can't find field in expr %v\n", n)) + + // TODO: keep the result of this function somewhere in the ODOT Node + // so we don't have to recompute it each time we need it. +} + +// ssafn holds frontend information about a function that the backend is processing. +// It also exports a bunch of compiler services for the ssa backend. +type ssafn struct { + curfn *ir.Func + strings map[string]*obj.LSym // map from constant string to data symbols + stksize int64 // stack size for current frame + stkptrsize int64 // prefix of stack containing pointers + + // alignment for current frame. + // NOTE: when stkalign > PtrSize, currently this only ensures the offsets of + // objects in the stack frame are aligned. The stack pointer is still aligned + // only PtrSize. + stkalign int64 + + log bool // print ssa debug to the stdout +} + +// StringData returns a symbol which +// is the data component of a global string constant containing s. +func (e *ssafn) StringData(s string) *obj.LSym { + if aux, ok := e.strings[s]; ok { + return aux + } + if e.strings == nil { + e.strings = make(map[string]*obj.LSym) + } + data := staticdata.StringSym(e.curfn.Pos(), s) + e.strings[s] = data + return data +} + +// SplitSlot returns a slot representing the data of parent starting at offset. +func (e *ssafn) SplitSlot(parent *ssa.LocalSlot, suffix string, offset int64, t *types.Type) ssa.LocalSlot { + node := parent.N + + if node.Class != ir.PAUTO || node.Addrtaken() { + // addressed things and non-autos retain their parents (i.e., cannot truly be split) + return ssa.LocalSlot{N: node, Type: t, Off: parent.Off + offset} + } + + sym := &types.Sym{Name: node.Sym().Name + suffix, Pkg: types.LocalPkg} + n := e.curfn.NewLocal(parent.N.Pos(), sym, t) + n.SetUsed(true) + n.SetEsc(ir.EscNever) + types.CalcSize(t) + return ssa.LocalSlot{N: n, Type: t, Off: 0, SplitOf: parent, SplitOffset: offset} +} + +// Logf logs a message from the compiler. +func (e *ssafn) Logf(msg string, args ...any) { + if e.log { + fmt.Printf(msg, args...) + } +} + +func (e *ssafn) Log() bool { + return e.log +} + +// Fatalf reports a compiler error and exits. +func (e *ssafn) Fatalf(pos src.XPos, msg string, args ...any) { + base.Pos = pos + nargs := append([]any{ir.FuncName(e.curfn)}, args...) + base.Fatalf("'%s': "+msg, nargs...) +} + +// Warnl reports a "warning", which is usually flag-triggered +// logging output for the benefit of tests. +func (e *ssafn) Warnl(pos src.XPos, fmt_ string, args ...any) { + base.WarnfAt(pos, fmt_, args...) +} + +func (e *ssafn) Debug_checknil() bool { + return base.Debug.Nil != 0 +} + +func (e *ssafn) UseWriteBarrier() bool { + return base.Flag.WB +} + +func (e *ssafn) Syslook(name string) *obj.LSym { + switch name { + case "goschedguarded": + return ir.Syms.Goschedguarded + case "writeBarrier": + return ir.Syms.WriteBarrier + case "wbZero": + return ir.Syms.WBZero + case "wbMove": + return ir.Syms.WBMove + case "cgoCheckMemmove": + return ir.Syms.CgoCheckMemmove + case "cgoCheckPtrWrite": + return ir.Syms.CgoCheckPtrWrite + } + e.Fatalf(src.NoXPos, "unknown Syslook func %v", name) + return nil +} + +func (e *ssafn) Func() *ir.Func { + return e.curfn +} + +func clobberBase(n ir.Node) ir.Node { + if n.Op() == ir.ODOT { + n := n.(*ir.SelectorExpr) + if n.X.Type().NumFields() == 1 { + return clobberBase(n.X) + } + } + if n.Op() == ir.OINDEX { + n := n.(*ir.IndexExpr) + if n.X.Type().IsArray() && n.X.Type().NumElem() == 1 { + return clobberBase(n.X) + } + } + return n +} + +// callTargetLSym returns the correct LSym to call 'callee' using its ABI. +func callTargetLSym(callee *ir.Name) *obj.LSym { + if callee.Func == nil { + // TODO(austin): This happens in case of interface method I.M from imported package. + // It's ABIInternal, and would be better if callee.Func was never nil and we didn't + // need this case. + return callee.Linksym() + } + + return callee.LinksymABI(callee.Func.ABI) +} + +// deferStructFnField is the field index of _defer.fn. +const deferStructFnField = 4 + +var deferType *types.Type + +// deferstruct returns a type interchangeable with runtime._defer. +// Make sure this stays in sync with runtime/runtime2.go:_defer. +func deferstruct() *types.Type { + if deferType != nil { + return deferType + } + + makefield := func(name string, t *types.Type) *types.Field { + sym := (*types.Pkg)(nil).Lookup(name) + return types.NewField(src.NoXPos, sym, t) + } + + fields := []*types.Field{ + makefield("heap", types.Types[types.TBOOL]), + makefield("rangefunc", types.Types[types.TBOOL]), + makefield("sp", types.Types[types.TUINTPTR]), + makefield("pc", types.Types[types.TUINTPTR]), + // Note: the types here don't really matter. Defer structures + // are always scanned explicitly during stack copying and GC, + // so we make them uintptr type even though they are real pointers. + makefield("fn", types.Types[types.TUINTPTR]), + makefield("link", types.Types[types.TUINTPTR]), + makefield("head", types.Types[types.TUINTPTR]), + } + if name := fields[deferStructFnField].Sym.Name; name != "fn" { + base.Fatalf("deferStructFnField is %q, not fn", name) + } + + n := ir.NewDeclNameAt(src.NoXPos, ir.OTYPE, ir.Pkgs.Runtime.Lookup("_defer")) + typ := types.NewNamed(n) + n.SetType(typ) + n.SetTypecheck(1) + + // build struct holding the above fields + typ.SetUnderlying(types.NewStruct(fields)) + types.CalcStructSize(typ) + + deferType = typ + return typ +} + +// SpillSlotAddr uses LocalSlot information to initialize an obj.Addr +// The resulting addr is used in a non-standard context -- in the prologue +// of a function, before the frame has been constructed, so the standard +// addressing for the parameters will be wrong. +func SpillSlotAddr(spill ssa.Spill, baseReg int16, extraOffset int64) obj.Addr { + return obj.Addr{ + Name: obj.NAME_NONE, + Type: obj.TYPE_MEM, + Reg: baseReg, + Offset: spill.Offset + extraOffset, + } +} + +func isStructNotSIMD(t *types.Type) bool { + return t.IsStruct() && !t.IsSIMD() +} + +var BoundsCheckFunc [ssa.BoundsKindCount]*obj.LSym diff --git a/go/src/cmd/compile/internal/staticdata/data.go b/go/src/cmd/compile/internal/staticdata/data.go new file mode 100644 index 0000000000000000000000000000000000000000..acafe9d3393e85a8bb36d6726ea42dbb5f5f9dae --- /dev/null +++ b/go/src/cmd/compile/internal/staticdata/data.go @@ -0,0 +1,347 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package staticdata + +import ( + "encoding/base64" + "fmt" + "go/constant" + "io" + "os" + "slices" + "strconv" + "strings" + "sync" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/types" + "cmd/internal/hash" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" +) + +// InitAddrOffset writes the static name symbol lsym to n, it does not modify n. +// It's the caller responsibility to make sure lsym is from ONAME/PEXTERN node. +func InitAddrOffset(n *ir.Name, noff int64, lsym *obj.LSym, off int64) { + if n.Op() != ir.ONAME { + base.Fatalf("InitAddr n op %v", n.Op()) + } + if n.Sym() == nil { + base.Fatalf("InitAddr nil n sym") + } + s := n.Linksym() + s.WriteAddr(base.Ctxt, noff, types.PtrSize, lsym, off) +} + +// InitAddr is InitAddrOffset, with offset fixed to 0. +func InitAddr(n *ir.Name, noff int64, lsym *obj.LSym) { + InitAddrOffset(n, noff, lsym, 0) +} + +// InitSlice writes a static slice symbol {lsym, lencap, lencap} to n+noff, it does not modify n. +// It's the caller responsibility to make sure lsym is from ONAME node. +func InitSlice(n *ir.Name, noff int64, lsym *obj.LSym, lencap int64) { + s := n.Linksym() + s.WriteAddr(base.Ctxt, noff, types.PtrSize, lsym, 0) + s.WriteInt(base.Ctxt, noff+types.SliceLenOffset, types.PtrSize, lencap) + s.WriteInt(base.Ctxt, noff+types.SliceCapOffset, types.PtrSize, lencap) +} + +func InitSliceBytes(nam *ir.Name, off int64, s string) { + if nam.Op() != ir.ONAME { + base.Fatalf("InitSliceBytes %v", nam) + } + InitSlice(nam, off, slicedata(nam.Pos(), s), int64(len(s))) +} + +const ( + stringSymPrefix = "go:string." + stringSymPattern = ".gostring.%d.%s" +) + +// shortHashString converts the hash to a string for use with stringSymPattern. +// We cut it to 16 bytes and then base64-encode to make it even smaller. +func shortHashString(hash []byte) string { + return base64.StdEncoding.EncodeToString(hash[:16]) +} + +// StringSym returns a symbol containing the string s. +// The symbol contains the string data, not a string header. +func StringSym(pos src.XPos, s string) (data *obj.LSym) { + var symname string + if len(s) > 100 { + // Huge strings are hashed to avoid long names in object files. + // Indulge in some paranoia by writing the length of s, too, + // as protection against length extension attacks. + // Same pattern is known to fileStringSym below. + h := hash.New32() + io.WriteString(h, s) + symname = fmt.Sprintf(stringSymPattern, len(s), shortHashString(h.Sum(nil))) + } else { + // Small strings get named directly by their contents. + symname = strconv.Quote(s) + } + + symdata := base.Ctxt.Lookup(stringSymPrefix + symname) + if !symdata.OnList() { + off := dstringdata(symdata, 0, s, pos, "string") + objw.Global(symdata, int32(off), obj.DUPOK|obj.RODATA|obj.LOCAL) + symdata.Set(obj.AttrContentAddressable, true) + } + + return symdata +} + +// StringSymNoCommon is like StringSym, but produces a symbol that is not content- +// addressable. This symbol is not supposed to appear in the final binary, it is +// only used to pass string arguments to the linker like R_USENAMEDMETHOD does. +func StringSymNoCommon(s string) (data *obj.LSym) { + var nameSym obj.LSym + nameSym.WriteString(base.Ctxt, 0, len(s), s) + objw.Global(&nameSym, int32(len(s)), obj.RODATA) + return &nameSym +} + +// maxFileSize is the maximum file size permitted by the linker +// (see issue #9862). +const maxFileSize = int64(2e9) + +// fileStringSym returns a symbol for the contents and the size of file. +// If readonly is true, the symbol shares storage with any literal string +// or other file with the same content and is placed in a read-only section. +// If readonly is false, the symbol is a read-write copy separate from any other, +// for use as the backing store of a []byte. +// The content hash of file is copied into hashBytes. (If hash is nil, nothing is copied.) +// The returned symbol contains the data itself, not a string header. +func fileStringSym(pos src.XPos, file string, readonly bool, hashBytes []byte) (*obj.LSym, int64, error) { + f, err := os.Open(file) + if err != nil { + return nil, 0, err + } + defer f.Close() + info, err := f.Stat() + if err != nil { + return nil, 0, err + } + if !info.Mode().IsRegular() { + return nil, 0, fmt.Errorf("not a regular file") + } + size := info.Size() + if size <= 1*1024 { + data, err := io.ReadAll(f) + if err != nil { + return nil, 0, err + } + if int64(len(data)) != size { + return nil, 0, fmt.Errorf("file changed between reads") + } + var sym *obj.LSym + if readonly { + sym = StringSym(pos, string(data)) + } else { + sym = slicedata(pos, string(data)) + } + if len(hashBytes) > 0 { + sum := hash.Sum32(data) + copy(hashBytes, sum[:]) + } + return sym, size, nil + } + if size > maxFileSize { + // ggloblsym takes an int32, + // and probably the rest of the toolchain + // can't handle such big symbols either. + // See golang.org/issue/9862. + return nil, 0, fmt.Errorf("file too large (%d bytes > %d bytes)", size, maxFileSize) + } + + // File is too big to read and keep in memory. + // Compute hashBytes if needed for read-only content hashing or if the caller wants it. + var sum []byte + if readonly || len(hashBytes) > 0 { + h := hash.New32() + n, err := io.Copy(h, f) + if err != nil { + return nil, 0, err + } + if n != size { + return nil, 0, fmt.Errorf("file changed between reads") + } + sum = h.Sum(nil) + copy(hashBytes, sum) + } + + var symdata *obj.LSym + if readonly { + symname := fmt.Sprintf(stringSymPattern, size, shortHashString(sum)) + symdata = base.Ctxt.Lookup(stringSymPrefix + symname) + if !symdata.OnList() { + info := symdata.NewFileInfo() + info.Name = file + info.Size = size + objw.Global(symdata, int32(size), obj.DUPOK|obj.RODATA|obj.LOCAL) + // Note: AttrContentAddressable cannot be set here, + // because the content-addressable-handling code + // does not know about file symbols. + } + } else { + // Emit a zero-length data symbol + // and then fix up length and content to use file. + symdata = slicedata(pos, "") + symdata.Size = size + symdata.Type = objabi.SNOPTRDATA + info := symdata.NewFileInfo() + info.Name = file + info.Size = size + } + + return symdata, size, nil +} + +var slicedataGen int + +func slicedata(pos src.XPos, s string) *obj.LSym { + slicedataGen++ + symname := fmt.Sprintf(".gobytes.%d", slicedataGen) + lsym := types.LocalPkg.Lookup(symname).LinksymABI(obj.ABI0) + off := dstringdata(lsym, 0, s, pos, "slice") + objw.Global(lsym, int32(off), obj.NOPTR|obj.LOCAL) + + return lsym +} + +func dstringdata(s *obj.LSym, off int, t string, pos src.XPos, what string) int { + // Objects that are too large will cause the data section to overflow right away, + // causing a cryptic error message by the linker. Check for oversize objects here + // and provide a useful error message instead. + if int64(len(t)) > 2e9 { + base.ErrorfAt(pos, 0, "%v with length %v is too big", what, len(t)) + return 0 + } + + s.WriteString(base.Ctxt, int64(off), len(t), t) + return off + len(t) +} + +var ( + funcsymsmu sync.Mutex // protects funcsyms and associated package lookups (see func funcsym) + funcsyms []*ir.Name // functions that need function value symbols +) + +// FuncLinksym returns n·f, the function value symbol for n. +func FuncLinksym(n *ir.Name) *obj.LSym { + if n.Op() != ir.ONAME || n.Class != ir.PFUNC { + base.Fatalf("expected func name: %v", n) + } + s := n.Sym() + + // funcsymsmu here serves to protect not just mutations of funcsyms (below), + // but also the package lookup of the func sym name, + // since this function gets called concurrently from the backend. + // There are no other concurrent package lookups in the backend, + // except for the types package, which is protected separately. + // Reusing funcsymsmu to also cover this package lookup + // avoids a general, broader, expensive package lookup mutex. + funcsymsmu.Lock() + sf, existed := s.Pkg.LookupOK(ir.FuncSymName(s)) + if !existed { + funcsyms = append(funcsyms, n) + } + funcsymsmu.Unlock() + + return sf.Linksym() +} + +func GlobalLinksym(n *ir.Name) *obj.LSym { + if n.Op() != ir.ONAME || n.Class != ir.PEXTERN { + base.Fatalf("expected global variable: %v", n) + } + return n.Linksym() +} + +func WriteFuncSyms() { + slices.SortFunc(funcsyms, func(a, b *ir.Name) int { + return strings.Compare(a.Linksym().Name, b.Linksym().Name) + }) + for _, nam := range funcsyms { + s := nam.Sym() + sf := s.Pkg.Lookup(ir.FuncSymName(s)).Linksym() + + // While compiling package runtime, we might try to create + // funcsyms for functions from both types.LocalPkg and + // ir.Pkgs.Runtime. + if base.Flag.CompilingRuntime && sf.OnList() { + continue + } + + // Function values must always reference ABIInternal + // entry points. + target := s.Linksym() + if target.ABI() != obj.ABIInternal { + base.Fatalf("expected ABIInternal: %v has %v", target, target.ABI()) + } + objw.SymPtr(sf, 0, target, 0) + objw.Global(sf, int32(types.PtrSize), obj.DUPOK|obj.RODATA) + } +} + +// InitConst writes the static literal c to n. +// Neither n nor c is modified. +func InitConst(n *ir.Name, noff int64, c ir.Node, wid int) { + if n.Op() != ir.ONAME { + base.Fatalf("InitConst n op %v", n.Op()) + } + if n.Sym() == nil { + base.Fatalf("InitConst nil n sym") + } + if c.Op() == ir.ONIL { + return + } + if c.Op() != ir.OLITERAL { + base.Fatalf("InitConst c op %v", c.Op()) + } + s := n.Linksym() + switch u := c.Val(); u.Kind() { + case constant.Bool: + i := int64(obj.Bool2int(constant.BoolVal(u))) + s.WriteInt(base.Ctxt, noff, wid, i) + + case constant.Int: + s.WriteInt(base.Ctxt, noff, wid, ir.IntVal(c.Type(), u)) + + case constant.Float: + f, _ := constant.Float64Val(u) + switch c.Type().Kind() { + case types.TFLOAT32: + s.WriteFloat32(base.Ctxt, noff, float32(f)) + case types.TFLOAT64: + s.WriteFloat64(base.Ctxt, noff, f) + } + + case constant.Complex: + re, _ := constant.Float64Val(constant.Real(u)) + im, _ := constant.Float64Val(constant.Imag(u)) + switch c.Type().Kind() { + case types.TCOMPLEX64: + s.WriteFloat32(base.Ctxt, noff, float32(re)) + s.WriteFloat32(base.Ctxt, noff+4, float32(im)) + case types.TCOMPLEX128: + s.WriteFloat64(base.Ctxt, noff, re) + s.WriteFloat64(base.Ctxt, noff+8, im) + } + + case constant.String: + i := constant.StringVal(u) + symdata := StringSym(n.Pos(), i) + s.WriteAddr(base.Ctxt, noff, types.PtrSize, symdata, 0) + s.WriteInt(base.Ctxt, noff+int64(types.PtrSize), types.PtrSize, int64(len(i))) + + default: + base.Fatalf("InitConst unhandled OLITERAL %v", c) + } +} diff --git a/go/src/cmd/compile/internal/staticdata/embed.go b/go/src/cmd/compile/internal/staticdata/embed.go new file mode 100644 index 0000000000000000000000000000000000000000..28468bda0379d261b20ca455fd32c641a31e0ed5 --- /dev/null +++ b/go/src/cmd/compile/internal/staticdata/embed.go @@ -0,0 +1,171 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package staticdata + +import ( + "path" + "sort" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/objw" + "cmd/compile/internal/types" + "cmd/internal/obj" +) + +const ( + embedUnknown = iota + embedBytes + embedString + embedFiles +) + +func embedFileList(v *ir.Name, kind int) []string { + // Build list of files to store. + have := make(map[string]bool) + var list []string + for _, e := range *v.Embed { + for _, pattern := range e.Patterns { + files, ok := base.Flag.Cfg.Embed.Patterns[pattern] + if !ok { + base.ErrorfAt(e.Pos, 0, "invalid go:embed: build system did not map pattern: %s", pattern) + } + for _, file := range files { + if base.Flag.Cfg.Embed.Files[file] == "" { + base.ErrorfAt(e.Pos, 0, "invalid go:embed: build system did not map file: %s", file) + continue + } + if !have[file] { + have[file] = true + list = append(list, file) + } + if kind == embedFiles { + for dir := path.Dir(file); dir != "." && !have[dir]; dir = path.Dir(dir) { + have[dir] = true + list = append(list, dir+"/") + } + } + } + } + } + sort.Slice(list, func(i, j int) bool { + return embedFileLess(list[i], list[j]) + }) + + if kind == embedString || kind == embedBytes { + if len(list) > 1 { + base.ErrorfAt(v.Pos(), 0, "invalid go:embed: multiple files for type %v", v.Type()) + return nil + } + } + + return list +} + +// embedKind determines the kind of embedding variable. +func embedKind(typ *types.Type) int { + if typ.Sym() != nil && typ.Sym().Name == "FS" && typ.Sym().Pkg.Path == "embed" { + return embedFiles + } + if typ.Kind() == types.TSTRING { + return embedString + } + if typ.IsSlice() && typ.Elem().Kind() == types.TUINT8 { + return embedBytes + } + return embedUnknown +} + +func embedFileNameSplit(name string) (dir, elem string, isDir bool) { + name, isDir = strings.CutSuffix(name, "/") + i := strings.LastIndexByte(name, '/') + if i < 0 { + return ".", name, isDir + } + return name[:i], name[i+1:], isDir +} + +// embedFileLess implements the sort order for a list of embedded files. +// See the comment inside ../../../../embed/embed.go's Files struct for rationale. +func embedFileLess(x, y string) bool { + xdir, xelem, _ := embedFileNameSplit(x) + ydir, yelem, _ := embedFileNameSplit(y) + return xdir < ydir || xdir == ydir && xelem < yelem +} + +// WriteEmbed emits the init data for a //go:embed variable, +// which is either a string, a []byte, or an embed.FS. +func WriteEmbed(v *ir.Name) { + // TODO(mdempsky): User errors should be reported by the frontend. + + commentPos := (*v.Embed)[0].Pos + if base.Flag.Cfg.Embed.Patterns == nil { + base.ErrorfAt(commentPos, 0, "invalid go:embed: build system did not supply embed configuration") + return + } + kind := embedKind(v.Type()) + if kind == embedUnknown { + base.ErrorfAt(v.Pos(), 0, "go:embed cannot apply to var of type %v", v.Type()) + return + } + + files := embedFileList(v, kind) + if base.Errors() > 0 { + return + } + switch kind { + case embedString, embedBytes: + file := files[0] + fsym, size, err := fileStringSym(v.Pos(), base.Flag.Cfg.Embed.Files[file], kind == embedString, nil) + if err != nil { + base.ErrorfAt(v.Pos(), 0, "embed %s: %v", file, err) + } + sym := v.Linksym() + off := 0 + off = objw.SymPtr(sym, off, fsym, 0) // data string + off = objw.Uintptr(sym, off, uint64(size)) // len + if kind == embedBytes { + objw.Uintptr(sym, off, uint64(size)) // cap for slice + } + + case embedFiles: + slicedata := v.Sym().Pkg.Lookup(v.Sym().Name + `.files`).Linksym() + off := 0 + // []files pointed at by Files + off = objw.SymPtr(slicedata, off, slicedata, 3*types.PtrSize) // []file, pointing just past slice + off = objw.Uintptr(slicedata, off, uint64(len(files))) + off = objw.Uintptr(slicedata, off, uint64(len(files))) + + // embed/embed.go type file is: + // name string + // data string + // hash [16]byte + // Emit one of these per file in the set. + const hashSize = 16 + hash := make([]byte, hashSize) + for _, file := range files { + off = objw.SymPtr(slicedata, off, StringSym(v.Pos(), file), 0) // file string + off = objw.Uintptr(slicedata, off, uint64(len(file))) + if strings.HasSuffix(file, "/") { + // entry for directory - no data + off = objw.Uintptr(slicedata, off, 0) + off = objw.Uintptr(slicedata, off, 0) + off += hashSize + } else { + fsym, size, err := fileStringSym(v.Pos(), base.Flag.Cfg.Embed.Files[file], true, hash) + if err != nil { + base.ErrorfAt(v.Pos(), 0, "embed %s: %v", file, err) + } + off = objw.SymPtr(slicedata, off, fsym, 0) // data string + off = objw.Uintptr(slicedata, off, uint64(size)) + off = int(slicedata.WriteBytes(base.Ctxt, int64(off), hash)) + } + } + objw.Global(slicedata, int32(off), obj.RODATA|obj.LOCAL) + sym := v.Linksym() + objw.SymPtr(sym, 0, slicedata, 0) + } +} diff --git a/go/src/cmd/compile/internal/staticinit/sched.go b/go/src/cmd/compile/internal/staticinit/sched.go new file mode 100644 index 0000000000000000000000000000000000000000..c79715be4699c26d30e37438f4e1ddaf4344e8eb --- /dev/null +++ b/go/src/cmd/compile/internal/staticinit/sched.go @@ -0,0 +1,1247 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package staticinit + +import ( + "fmt" + "go/constant" + "go/token" + "os" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/reflectdata" + "cmd/compile/internal/staticdata" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/objabi" + "cmd/internal/src" +) + +type Entry struct { + Xoffset int64 // struct, array only + Expr ir.Node // bytes of run-time computed expressions +} + +type Plan struct { + E []Entry +} + +// An Schedule is used to decompose assignment statements into +// static and dynamic initialization parts. Static initializations are +// handled by populating variables' linker symbol data, while dynamic +// initializations are accumulated to be executed in order. +type Schedule struct { + // Out is the ordered list of dynamic initialization + // statements. + Out []ir.Node + + Plans map[ir.Node]*Plan + Temps map[ir.Node]*ir.Name + + // seenMutation tracks whether we've seen an initialization + // expression that may have modified other package-scope variables + // within this package. + seenMutation bool +} + +func (s *Schedule) append(n ir.Node) { + s.Out = append(s.Out, n) +} + +// StaticInit adds an initialization statement n to the schedule. +func (s *Schedule) StaticInit(n ir.Node) { + if !s.tryStaticInit(n) { + if base.Flag.Percent != 0 { + ir.Dump("StaticInit failed", n) + } + s.append(n) + } +} + +// varToMapInit holds book-keeping state for global map initialization; +// it records the init function created by the compiler to host the +// initialization code for the map in question. +var varToMapInit map[*ir.Name]*ir.Func + +// MapInitToVar is the inverse of VarToMapInit; it maintains a mapping +// from a compiler-generated init function to the map the function is +// initializing. +var MapInitToVar map[*ir.Func]*ir.Name + +// recordFuncForVar establishes a mapping between global map var "v" and +// outlined init function "fn" (and vice versa); so that we can use +// the mappings later on to update relocations. +func recordFuncForVar(v *ir.Name, fn *ir.Func) { + if varToMapInit == nil { + varToMapInit = make(map[*ir.Name]*ir.Func) + MapInitToVar = make(map[*ir.Func]*ir.Name) + } + varToMapInit[v] = fn + MapInitToVar[fn] = v +} + +// allBlank reports whether every node in exprs is blank. +func allBlank(exprs []ir.Node) bool { + for _, expr := range exprs { + if !ir.IsBlank(expr) { + return false + } + } + return true +} + +// tryStaticInit attempts to statically execute an initialization +// statement and reports whether it succeeded. +func (s *Schedule) tryStaticInit(n ir.Node) bool { + var lhs []ir.Node + var rhs ir.Node + + switch n.Op() { + default: + base.FatalfAt(n.Pos(), "unexpected initialization statement: %v", n) + case ir.OAS: + n := n.(*ir.AssignStmt) + lhs, rhs = []ir.Node{n.X}, n.Y + case ir.OAS2: + // Usually OAS2 has been rewritten to separate OASes by types2. + // What's left here is "var a, b = tmp1, tmp2" as a result from rewriting + // "var a, b = f()" that needs type conversion, which is not static. + n := n.(*ir.AssignListStmt) + for _, rhs := range n.Rhs { + for rhs.Op() == ir.OCONVNOP { + rhs = rhs.(*ir.ConvExpr).X + } + if name, ok := rhs.(*ir.Name); !ok || !name.AutoTemp() { + base.FatalfAt(n.Pos(), "unexpected rhs, not an autotmp: %+v", rhs) + } + } + return false + case ir.OAS2DOTTYPE, ir.OAS2FUNC, ir.OAS2MAPR, ir.OAS2RECV: + n := n.(*ir.AssignListStmt) + if len(n.Lhs) < 2 || len(n.Rhs) != 1 { + base.FatalfAt(n.Pos(), "unexpected shape for %v: %v", n.Op(), n) + } + lhs, rhs = n.Lhs, n.Rhs[0] + case ir.OCALLFUNC: + return false // outlined map init call; no mutations + } + + if !s.seenMutation { + s.seenMutation = mayModifyPkgVar(rhs) + } + + if allBlank(lhs) && !AnySideEffects(rhs) { + return true // discard + } + + // Only worry about simple "l = r" assignments. The OAS2* + // assignments mostly necessitate dynamic execution anyway. + if len(lhs) > 1 { + return false + } + + lno := ir.SetPos(n) + defer func() { base.Pos = lno }() + + nam := lhs[0].(*ir.Name) + return s.StaticAssign(nam, 0, rhs, nam.Type()) +} + +// like staticassign but we are copying an already +// initialized value r. +func (s *Schedule) staticcopy(l *ir.Name, loff int64, rn *ir.Name, typ *types.Type) bool { + if rn.Class == ir.PFUNC { + // TODO if roff != 0 { panic } + staticdata.InitAddr(l, loff, staticdata.FuncLinksym(rn)) + return true + } + if rn.Class != ir.PEXTERN || rn.Sym().Pkg != types.LocalPkg { + return false + } + if rn.Defn == nil { + // No explicit initialization value. Probably zeroed but perhaps + // supplied externally and of unknown value. + return false + } + if rn.Defn.Op() != ir.OAS { + return false + } + if rn.Type().IsString() { // perhaps overwritten by cmd/link -X (#34675) + return false + } + if rn.Embed != nil { + return false + } + orig := rn + r := rn.Defn.(*ir.AssignStmt).Y + if r == nil { + // types2.InitOrder doesn't include default initializers. + base.Fatalf("unexpected initializer: %v", rn.Defn) + } + + // Variable may have been reassigned by a user-written function call + // that was invoked to initialize another global variable (#51913). + if s.seenMutation { + if base.Debug.StaticCopy != 0 { + base.WarnfAt(l.Pos(), "skipping static copy of %v+%v with %v", l, loff, r) + } + return false + } + + for r.Op() == ir.OCONVNOP && !types.Identical(r.Type(), typ) { + r = r.(*ir.ConvExpr).X + } + + switch r.Op() { + case ir.OMETHEXPR: + r = r.(*ir.SelectorExpr).FuncName() + fallthrough + case ir.ONAME: + r := r.(*ir.Name) + if s.staticcopy(l, loff, r, typ) { + return true + } + // We may have skipped past one or more OCONVNOPs, so + // use conv to ensure r is assignable to l (#13263). + dst := ir.Node(l) + if loff != 0 || !types.Identical(typ, l.Type()) { + dst = ir.NewNameOffsetExpr(base.Pos, l, loff, typ) + } + s.append(ir.NewAssignStmt(base.Pos, dst, typecheck.Conv(r, typ))) + return true + + case ir.ONIL: + return true + + case ir.OLITERAL: + if ir.IsZero(r) { + return true + } + staticdata.InitConst(l, loff, r, int(typ.Size())) + return true + + case ir.OADDR: + r := r.(*ir.AddrExpr) + if a, ok := r.X.(*ir.Name); ok && a.Op() == ir.ONAME { + if a.Class != ir.PEXTERN { + return false // e.g. local from new(expr) + } + staticdata.InitAddr(l, loff, staticdata.GlobalLinksym(a)) + return true + } + + case ir.OPTRLIT: + r := r.(*ir.AddrExpr) + switch r.X.Op() { + case ir.OARRAYLIT, ir.OSLICELIT, ir.OSTRUCTLIT, ir.OMAPLIT: + // copy pointer + staticdata.InitAddr(l, loff, staticdata.GlobalLinksym(s.Temps[r])) + return true + } + + case ir.OSLICELIT: + r := r.(*ir.CompLitExpr) + // copy slice + staticdata.InitSlice(l, loff, staticdata.GlobalLinksym(s.Temps[r]), r.Len) + return true + + case ir.OARRAYLIT, ir.OSTRUCTLIT: + r := r.(*ir.CompLitExpr) + p := s.Plans[r] + for i := range p.E { + e := &p.E[i] + typ := e.Expr.Type() + if e.Expr.Op() == ir.OLITERAL || e.Expr.Op() == ir.ONIL { + staticdata.InitConst(l, loff+e.Xoffset, e.Expr, int(typ.Size())) + continue + } + x := e.Expr + if x.Op() == ir.OMETHEXPR { + x = x.(*ir.SelectorExpr).FuncName() + } + if x.Op() == ir.ONAME && s.staticcopy(l, loff+e.Xoffset, x.(*ir.Name), typ) { + continue + } + // Requires computation, but we're + // copying someone else's computation. + ll := ir.NewNameOffsetExpr(base.Pos, l, loff+e.Xoffset, typ) + rr := ir.NewNameOffsetExpr(base.Pos, orig, e.Xoffset, typ) + ir.SetPos(rr) + s.append(ir.NewAssignStmt(base.Pos, ll, rr)) + } + + return true + } + + return false +} + +func (s *Schedule) StaticAssign(l *ir.Name, loff int64, r ir.Node, typ *types.Type) bool { + // If we're building for FIPS, avoid global data relocations + // by treating all address-of operations as non-static. + // See ../../../internal/obj/fips.go for more context. + // We do this even in non-PIE mode to avoid generating + // static temporaries that would go into SRODATAFIPS + // but need relocations. We can't handle that in the verification. + disableGlobalAddrs := base.Ctxt.IsFIPS() + + if r == nil { + // No explicit initialization value. Either zero or supplied + // externally. + return true + } + for r.Op() == ir.OCONVNOP { + r = r.(*ir.ConvExpr).X + } + + assign := func(pos src.XPos, a *ir.Name, aoff int64, v ir.Node) { + if s.StaticAssign(a, aoff, v, v.Type()) { + return + } + var lhs ir.Node + if ir.IsBlank(a) { + // Don't use NameOffsetExpr with blank (#43677). + lhs = ir.BlankNode + } else { + lhs = ir.NewNameOffsetExpr(pos, a, aoff, v.Type()) + } + s.append(ir.NewAssignStmt(pos, lhs, v)) + } + + switch r.Op() { + case ir.ONAME: + if disableGlobalAddrs { + return false + } + r := r.(*ir.Name) + return s.staticcopy(l, loff, r, typ) + + case ir.OMETHEXPR: + if disableGlobalAddrs { + return false + } + r := r.(*ir.SelectorExpr) + return s.staticcopy(l, loff, r.FuncName(), typ) + + case ir.ONIL: + return true + + case ir.OLITERAL: + if ir.IsZero(r) { + return true + } + if disableGlobalAddrs && r.Type().IsString() { + return false + } + staticdata.InitConst(l, loff, r, int(typ.Size())) + return true + + case ir.OADDR: + if disableGlobalAddrs { + return false + } + r := r.(*ir.AddrExpr) + if name, offset, ok := StaticLoc(r.X); ok && name.Class == ir.PEXTERN { + staticdata.InitAddrOffset(l, loff, name.Linksym(), offset) + return true + } + fallthrough + + case ir.OPTRLIT: + if disableGlobalAddrs { + return false + } + r := r.(*ir.AddrExpr) + switch r.X.Op() { + case ir.OARRAYLIT, ir.OSLICELIT, ir.OMAPLIT, ir.OSTRUCTLIT: + // Init pointer. + a := StaticName(r.X.Type()) + + s.Temps[r] = a + staticdata.InitAddr(l, loff, a.Linksym()) + + // Init underlying literal. + assign(base.Pos, a, 0, r.X) + return true + } + //dump("not static ptrlit", r); + + case ir.OSTR2BYTES: + if disableGlobalAddrs { + return false + } + r := r.(*ir.ConvExpr) + if l.Class == ir.PEXTERN && r.X.Op() == ir.OLITERAL { + sval := ir.StringVal(r.X) + staticdata.InitSliceBytes(l, loff, sval) + return true + } + + case ir.OSLICELIT: + if disableGlobalAddrs { + return false + } + r := r.(*ir.CompLitExpr) + s.initplan(r) + // Init slice. + ta := types.NewArray(r.Type().Elem(), r.Len) + ta.SetNoalg(true) + a := StaticName(ta) + s.Temps[r] = a + staticdata.InitSlice(l, loff, a.Linksym(), r.Len) + // Fall through to init underlying array. + l = a + loff = 0 + fallthrough + + case ir.OARRAYLIT, ir.OSTRUCTLIT: + r := r.(*ir.CompLitExpr) + s.initplan(r) + + p := s.Plans[r] + for i := range p.E { + e := &p.E[i] + if e.Expr.Op() == ir.OLITERAL && !disableGlobalAddrs || e.Expr.Op() == ir.ONIL { + staticdata.InitConst(l, loff+e.Xoffset, e.Expr, int(e.Expr.Type().Size())) + continue + } + ir.SetPos(e.Expr) + assign(base.Pos, l, loff+e.Xoffset, e.Expr) + } + + return true + + case ir.OMAPLIT: + break + + case ir.OCLOSURE: + if disableGlobalAddrs { + return false + } + r := r.(*ir.ClosureExpr) + if !r.Func.IsClosure() { + if base.Debug.Closure > 0 { + base.WarnfAt(r.Pos(), "closure converted to global") + } + // Closures with no captured variables are globals, + // so the assignment can be done at link time. + // TODO if roff != 0 { panic } + staticdata.InitAddr(l, loff, staticdata.FuncLinksym(r.Func.Nname)) + return true + } + ir.ClosureDebugRuntimeCheck(r) + + case ir.OCONVIFACE: + // This logic is mirrored in isStaticCompositeLiteral. + // If you change something here, change it there, and vice versa. + + if disableGlobalAddrs { + return false + } + + // Determine the underlying concrete type and value we are converting from. + r := r.(*ir.ConvExpr) + val := ir.Node(r) + for val.Op() == ir.OCONVIFACE { + val = val.(*ir.ConvExpr).X + } + + if val.Type().IsInterface() { + // val is an interface type. + // If val is nil, we can statically initialize l; + // both words are zero and so there no work to do, so report success. + // If val is non-nil, we have no concrete type to record, + // and we won't be able to statically initialize its value, so report failure. + return val.Op() == ir.ONIL + } + + if val.Type().HasShape() { + // See comment in cmd/compile/internal/walk/convert.go:walkConvInterface + return false + } + + reflectdata.MarkTypeUsedInInterface(val.Type(), l.Linksym()) + + var itab *ir.AddrExpr + if typ.IsEmptyInterface() { + itab = reflectdata.TypePtrAt(base.Pos, val.Type()) + } else { + itab = reflectdata.ITabAddrAt(base.Pos, val.Type(), typ) + } + + // Create a copy of l to modify while we emit data. + + // Emit itab, advance offset. + staticdata.InitAddr(l, loff, itab.X.(*ir.LinksymOffsetExpr).Linksym) + + // Emit data. + if types.IsDirectIface(val.Type()) { + if val.Op() == ir.ONIL { + // Nil is zero, nothing to do. + return true + } + // Copy val directly into n. + ir.SetPos(val) + assign(base.Pos, l, loff+int64(types.PtrSize), val) + } else { + // Construct temp to hold val, write pointer to temp into n. + a := StaticName(val.Type()) + s.Temps[val] = a + assign(base.Pos, a, 0, val) + staticdata.InitAddr(l, loff+int64(types.PtrSize), a.Linksym()) + } + + return true + + case ir.OINLCALL: + if disableGlobalAddrs { + return false + } + r := r.(*ir.InlinedCallExpr) + return s.staticAssignInlinedCall(l, loff, r, typ) + } + + if base.Flag.Percent != 0 { + ir.Dump("not static", r) + } + return false +} + +func (s *Schedule) initplan(n ir.Node) { + if s.Plans[n] != nil { + return + } + p := new(Plan) + s.Plans[n] = p + switch n.Op() { + default: + base.Fatalf("initplan") + + case ir.OARRAYLIT, ir.OSLICELIT: + n := n.(*ir.CompLitExpr) + var k int64 + for _, a := range n.List { + if a.Op() == ir.OKEY { + kv := a.(*ir.KeyExpr) + k = typecheck.IndexConst(kv.Key) + a = kv.Value + } + s.addvalue(p, k*n.Type().Elem().Size(), a) + k++ + } + + case ir.OSTRUCTLIT: + n := n.(*ir.CompLitExpr) + for _, a := range n.List { + if a.Op() != ir.OSTRUCTKEY { + base.Fatalf("initplan structlit") + } + a := a.(*ir.StructKeyExpr) + if a.Sym().IsBlank() { + continue + } + s.addvalue(p, a.Field.Offset, a.Value) + } + + case ir.OMAPLIT: + n := n.(*ir.CompLitExpr) + for _, a := range n.List { + if a.Op() != ir.OKEY { + base.Fatalf("initplan maplit") + } + a := a.(*ir.KeyExpr) + s.addvalue(p, -1, a.Value) + } + } +} + +func (s *Schedule) addvalue(p *Plan, xoffset int64, n ir.Node) { + // special case: zero can be dropped entirely + if ir.IsZero(n) { + return + } + + // special case: inline struct and array (not slice) literals + if isvaluelit(n) { + s.initplan(n) + q := s.Plans[n] + for _, qe := range q.E { + // qe is a copy; we are not modifying entries in q.E + qe.Xoffset += xoffset + p.E = append(p.E, qe) + } + return + } + + // add to plan + p.E = append(p.E, Entry{Xoffset: xoffset, Expr: n}) +} + +func (s *Schedule) staticAssignInlinedCall(l *ir.Name, loff int64, call *ir.InlinedCallExpr, typ *types.Type) bool { + if base.Debug.InlStaticInit == 0 { + return false + } + + // Handle the special case of an inlined call of + // a function body with a single return statement, + // which turns into a single assignment plus a goto. + // + // For example code like this: + // + // type T struct{ x int } + // func F(x int) *T { return &T{x} } + // var Global = F(400) + // + // turns into IR like this: + // + // INLCALL-init + // . AS2-init + // . . DCL # x.go:18:13 + // . . . NAME-p.x Class:PAUTO Offset:0 InlFormal OnStack Used int tc(1) # x.go:14:9,x.go:18:13 + // . AS2 Def tc(1) # x.go:18:13 + // . AS2-Lhs + // . . NAME-p.x Class:PAUTO Offset:0 InlFormal OnStack Used int tc(1) # x.go:14:9,x.go:18:13 + // . AS2-Rhs + // . . LITERAL-400 int tc(1) # x.go:18:14 + // . INLMARK Index:1 # +x.go:18:13 + // INLCALL PTR-*T tc(1) # x.go:18:13 + // INLCALL-Body + // . BLOCK tc(1) # x.go:18:13 + // . BLOCK-List + // . . DCL tc(1) # x.go:18:13 + // . . . NAME-p.~R0 Class:PAUTO Offset:0 OnStack Used PTR-*T tc(1) # x.go:18:13 + // . . AS2 tc(1) # x.go:18:13 + // . . AS2-Lhs + // . . . NAME-p.~R0 Class:PAUTO Offset:0 OnStack Used PTR-*T tc(1) # x.go:18:13 + // . . AS2-Rhs + // . . . INLINED RETURN ARGUMENT HERE + // . . GOTO p..i1 tc(1) # x.go:18:13 + // . LABEL p..i1 # x.go:18:13 + // INLCALL-ReturnVars + // . NAME-p.~R0 Class:PAUTO Offset:0 OnStack Used PTR-*T tc(1) # x.go:18:13 + // + // If the init values are side-effect-free and each either only + // appears once in the function body or is safely repeatable, + // then we inline the value expressions into the return argument + // and then call StaticAssign to handle that copy. + // + // This handles simple cases like + // + // var myError = errors.New("mine") + // + // where errors.New is + // + // func New(text string) error { + // return &errorString{text} + // } + // + // We could make things more sophisticated but this kind of initializer + // is the most important case for us to get right. + + init := call.Init() + if len(init) != 2 || init[0].Op() != ir.OAS2 || init[1].Op() != ir.OINLMARK { + return false + } + as2init := init[0].(*ir.AssignListStmt) + + if len(call.Body) != 2 || call.Body[0].Op() != ir.OBLOCK || call.Body[1].Op() != ir.OLABEL { + return false + } + label := call.Body[1].(*ir.LabelStmt).Label + block := call.Body[0].(*ir.BlockStmt) + list := block.List + if len(list) != 3 || + list[0].Op() != ir.ODCL || + list[1].Op() != ir.OAS2 || + list[2].Op() != ir.OGOTO || + list[2].(*ir.BranchStmt).Label != label { + return false + } + dcl := list[0].(*ir.Decl) + as2body := list[1].(*ir.AssignListStmt) + if len(as2body.Lhs) != 1 || as2body.Lhs[0] != dcl.X { + return false + } + + // Can't remove the parameter variables if an address is taken. + for _, v := range as2init.Lhs { + if v.(*ir.Name).Addrtaken() { + return false + } + } + // Can't move the computation of the args if they have side effects. + for _, r := range as2init.Rhs { + if AnySideEffects(r) { + return false + } + } + + // Can only substitute arg for param if param is used + // at most once or is repeatable. + count := make(map[*ir.Name]int) + for _, x := range as2init.Lhs { + count[x.(*ir.Name)] = 0 + } + + hasClosure := false + ir.Visit(as2body.Rhs[0], func(n ir.Node) { + if name, ok := n.(*ir.Name); ok { + if c, ok := count[name]; ok { + count[name] = c + 1 + } + } + if clo, ok := n.(*ir.ClosureExpr); ok { + hasClosure = hasClosure || clo.Func.IsClosure() + } + }) + + // If there's a closure, it has captured the param, + // so we can't substitute arg for param. + if hasClosure { + return false + } + + for name, c := range count { + if c > 1 { + // Check whether corresponding initializer can be repeated. + // Something like 1 can be; make(chan int) or &T{} cannot, + // because they need to evaluate to the same result in each use. + for i, n := range as2init.Lhs { + if n == name && !canRepeat(as2init.Rhs[i]) { + return false + } + } + } + } + + // Possible static init. + // Build tree with args substituted for params and try it. + args := make(map[*ir.Name]ir.Node) + for i, v := range as2init.Lhs { + if ir.IsBlank(v) { + continue + } + args[v.(*ir.Name)] = as2init.Rhs[i] + } + r, ok := subst(as2body.Rhs[0], args) + if !ok { + return false + } + ok = s.StaticAssign(l, loff, r, typ) + + if ok && base.Flag.Percent != 0 { + ir.Dump("static inlined-LEFT", l) + ir.Dump("static inlined-ORIG", call) + ir.Dump("static inlined-RIGHT", r) + } + return ok +} + +// from here down is the walk analysis +// of composite literals. +// most of the work is to generate +// data statements for the constant +// part of the composite literal. + +var statuniqgen int // name generator for static temps + +// StaticName returns a name backed by a (writable) static data symbol. +func StaticName(t *types.Type) *ir.Name { + // Don't use LookupNum; it interns the resulting string, but these are all unique. + sym := typecheck.Lookup(fmt.Sprintf("%s%d", obj.StaticNamePrefix, statuniqgen)) + statuniqgen++ + + n := ir.NewNameAt(base.Pos, sym, t) + sym.Def = n + + n.Class = ir.PEXTERN + typecheck.Target.Externs = append(typecheck.Target.Externs, n) + + n.Linksym().Set(obj.AttrStatic, true) + return n +} + +// StaticLoc returns the static address of n, if n has one, or else nil. +func StaticLoc(n ir.Node) (name *ir.Name, offset int64, ok bool) { + if n == nil { + return nil, 0, false + } + + switch n.Op() { + case ir.ONAME: + n := n.(*ir.Name) + return n, 0, true + + case ir.OMETHEXPR: + n := n.(*ir.SelectorExpr) + return StaticLoc(n.FuncName()) + + case ir.ODOT: + n := n.(*ir.SelectorExpr) + if name, offset, ok = StaticLoc(n.X); !ok { + break + } + offset += n.Offset() + return name, offset, true + + case ir.OINDEX: + n := n.(*ir.IndexExpr) + if n.X.Type().IsSlice() { + break + } + if name, offset, ok = StaticLoc(n.X); !ok { + break + } + l := getlit(n.Index) + if l < 0 { + break + } + + // Check for overflow. + if n.Type().Size() != 0 && types.MaxWidth/n.Type().Size() <= int64(l) { + break + } + offset += int64(l) * n.Type().Size() + return name, offset, true + } + + return nil, 0, false +} + +func isSideEffect(n ir.Node) bool { + switch n.Op() { + // Assume side effects unless we know otherwise. + default: + return true + + // No side effects here (arguments are checked separately). + case ir.ONAME, + ir.ONONAME, + ir.OTYPE, + ir.OLITERAL, + ir.ONIL, + ir.OADD, + ir.OSUB, + ir.OOR, + ir.OXOR, + ir.OADDSTR, + ir.OADDR, + ir.OANDAND, + ir.OBYTES2STR, + ir.ORUNES2STR, + ir.OSTR2BYTES, + ir.OSTR2RUNES, + ir.OCAP, + ir.OCOMPLIT, + ir.OMAPLIT, + ir.OSTRUCTLIT, + ir.OARRAYLIT, + ir.OSLICELIT, + ir.OPTRLIT, + ir.OCONV, + ir.OCONVIFACE, + ir.OCONVNOP, + ir.ODOT, + ir.OEQ, + ir.ONE, + ir.OLT, + ir.OLE, + ir.OGT, + ir.OGE, + ir.OKEY, + ir.OSTRUCTKEY, + ir.OLEN, + ir.OMUL, + ir.OLSH, + ir.ORSH, + ir.OAND, + ir.OANDNOT, + ir.ONEW, + ir.ONOT, + ir.OBITNOT, + ir.OPLUS, + ir.ONEG, + ir.OOROR, + ir.OPAREN, + ir.ORUNESTR, + ir.OREAL, + ir.OIMAG, + ir.OCOMPLEX: + return false + + // Only possible side effect is division by zero. + case ir.ODIV, ir.OMOD: + n := n.(*ir.BinaryExpr) + if n.Y.Op() != ir.OLITERAL || constant.Sign(n.Y.Val()) == 0 { + return true + } + + // Only possible side effect is panic on invalid size, + // but many makechan and makemap use size zero, which is definitely OK. + case ir.OMAKECHAN, ir.OMAKEMAP: + n := n.(*ir.MakeExpr) + if !ir.IsConst(n.Len, constant.Int) || constant.Sign(n.Len.Val()) != 0 { + return true + } + + // Only possible side effect is panic on invalid size. + // TODO(rsc): Merge with previous case (probably breaks toolstash -cmp). + case ir.OMAKESLICE, ir.OMAKESLICECOPY: + return true + } + return false +} + +// AnySideEffects reports whether n contains any operations that could have observable side effects. +func AnySideEffects(n ir.Node) bool { + return ir.Any(n, isSideEffect) +} + +// mayModifyPkgVar reports whether expression n may modify any +// package-scope variables declared within the current package. +func mayModifyPkgVar(n ir.Node) bool { + // safeLHS reports whether the assigned-to variable lhs is either a + // local variable or a global from another package. + safeLHS := func(lhs ir.Node) bool { + outer := ir.OuterValue(lhs) + // "*p = ..." should be safe if p is a local variable. + // TODO: Should ir.OuterValue handle this? + for outer.Op() == ir.ODEREF { + outer = outer.(*ir.StarExpr).X + } + v, ok := outer.(*ir.Name) + return ok && v.Op() == ir.ONAME && !(v.Class == ir.PEXTERN && v.Sym().Pkg == types.LocalPkg) + } + + return ir.Any(n, func(n ir.Node) bool { + switch n.Op() { + case ir.OCALLFUNC, ir.OCALLINTER: + return !ir.IsFuncPCIntrinsic(n.(*ir.CallExpr)) + + case ir.OAPPEND, ir.OCLEAR, ir.OCOPY: + return true // could mutate a global array + + case ir.OASOP: + n := n.(*ir.AssignOpStmt) + if !safeLHS(n.X) { + return true + } + + case ir.OAS: + n := n.(*ir.AssignStmt) + if !safeLHS(n.X) { + return true + } + + case ir.OAS2, ir.OAS2DOTTYPE, ir.OAS2FUNC, ir.OAS2MAPR, ir.OAS2RECV: + n := n.(*ir.AssignListStmt) + for _, lhs := range n.Lhs { + if !safeLHS(lhs) { + return true + } + } + } + + return false + }) +} + +// canRepeat reports whether executing n multiple times has the same effect as +// assigning n to a single variable and using that variable multiple times. +func canRepeat(n ir.Node) bool { + bad := func(n ir.Node) bool { + if isSideEffect(n) { + return true + } + switch n.Op() { + case ir.OMAKECHAN, + ir.OMAKEMAP, + ir.OMAKESLICE, + ir.OMAKESLICECOPY, + ir.OMAPLIT, + ir.ONEW, + ir.OPTRLIT, + ir.OSLICELIT, + ir.OSTR2BYTES, + ir.OSTR2RUNES: + return true + } + return false + } + return !ir.Any(n, bad) +} + +func getlit(lit ir.Node) int { + if ir.IsSmallIntConst(lit) { + return int(ir.Int64Val(lit)) + } + return -1 +} + +func isvaluelit(n ir.Node) bool { + return n.Op() == ir.OARRAYLIT || n.Op() == ir.OSTRUCTLIT +} + +func subst(n ir.Node, m map[*ir.Name]ir.Node) (ir.Node, bool) { + valid := true + var edit func(ir.Node) ir.Node + edit = func(x ir.Node) ir.Node { + switch x.Op() { + case ir.ONAME: + x := x.(*ir.Name) + if v, ok := m[x]; ok { + return ir.DeepCopy(v.Pos(), v) + } + return x + case ir.ONONAME, ir.OLITERAL, ir.ONIL, ir.OTYPE: + return x + } + x = ir.Copy(x) + ir.EditChildrenWithHidden(x, edit) + + // TODO: handle more operations, see details discussion in go.dev/cl/466277. + switch x.Op() { + case ir.OCONV: + x := x.(*ir.ConvExpr) + if x.X.Op() == ir.OLITERAL { + if x, ok := truncate(x.X, x.Type()); ok { + return x + } + valid = false + return x + } + case ir.OADDSTR: + return addStr(x.(*ir.AddStringExpr)) + } + return x + } + n = edit(n) + return n, valid +} + +// truncate returns the result of force converting c to type t, +// truncating its value as needed, like a conversion of a variable. +// If the conversion is too difficult, truncate returns nil, false. +func truncate(c ir.Node, t *types.Type) (ir.Node, bool) { + ct := c.Type() + cv := c.Val() + if ct.Kind() != t.Kind() { + switch { + default: + // Note: float -> float/integer and complex -> complex are valid but subtle. + // For example a float32(float64 1e300) evaluates to +Inf at runtime + // and the compiler doesn't have any concept of +Inf, so that would + // have to be left for runtime code evaluation. + // For now + return nil, false + + case ct.IsInteger() && t.IsInteger(): + // truncate or sign extend + bits := t.Size() * 8 + cv = constant.BinaryOp(cv, token.AND, constant.MakeUint64(1< 0 { + fmt.Fprintf(os.Stderr, "=-= mapassign %s %v rhs size %d\n", + base.Ctxt.Pkgpath, n, rsiz) + } + + // Reject smaller candidates if not in stress mode. + if rsiz < wrapGlobalMapInitSizeThreshold && base.Debug.WrapGlobalMapCtl != 2 { + if base.Debug.WrapGlobalMapDbg > 1 { + fmt.Fprintf(os.Stderr, "=-= skipping %v size too small at %d\n", + nm, rsiz) + } + return nil + } + + // Reject right hand sides with side effects. + if AnySideEffects(as.Y) { + if base.Debug.WrapGlobalMapDbg > 0 { + fmt.Fprintf(os.Stderr, "=-= rejected %v due to side effects\n", nm) + } + return nil + } + + if base.Debug.WrapGlobalMapDbg > 1 { + fmt.Fprintf(os.Stderr, "=-= committed for: %+v\n", n) + } + + // Create a new function that will (eventually) have this form: + // + // func map.init.%d() { + // globmapvar = + // } + // + // Note: cmd/link expects the function name to contain "map.init". + minitsym := typecheck.LookupNum("map.init.", mapinitgen) + mapinitgen++ + + fn := ir.NewFunc(n.Pos(), n.Pos(), minitsym, types.NewSignature(nil, nil, nil)) + fn.SetInlinabilityChecked(true) // suppress inlining (which would defeat the point) + typecheck.DeclFunc(fn) + if base.Debug.WrapGlobalMapDbg > 0 { + fmt.Fprintf(os.Stderr, "=-= generated func is %v\n", fn) + } + + // NB: we're relying on this phase being run before inlining; + // if for some reason we need to move it after inlining, we'll + // need code here that relocates or duplicates inline temps. + + // Insert assignment into function body; mark body finished. + fn.Body = []ir.Node{as} + typecheck.FinishFuncBody() + + if base.Debug.WrapGlobalMapDbg > 1 { + fmt.Fprintf(os.Stderr, "=-= mapvar is %v\n", nm) + fmt.Fprintf(os.Stderr, "=-= newfunc is %+v\n", fn) + } + + recordFuncForVar(nm, fn) + + return fn +} + +// mapinitgen is a counter used to uniquify compiler-generated +// map init functions. +var mapinitgen int + +// AddKeepRelocations adds a dummy "R_KEEP" relocation from each +// global map variable V to its associated outlined init function. +// These relocation ensure that if the map var itself is determined to +// be reachable at link time, we also mark the init function as +// reachable. +func AddKeepRelocations() { + if varToMapInit == nil { + return + } + for k, v := range varToMapInit { + // Add R_KEEP relocation from map to init function. + fs := v.Linksym() + if fs == nil { + base.Fatalf("bad: func %v has no linksym", v) + } + vs := k.Linksym() + if vs == nil { + base.Fatalf("bad: mapvar %v has no linksym", k) + } + vs.AddRel(base.Ctxt, obj.Reloc{Type: objabi.R_KEEP, Sym: fs}) + if base.Debug.WrapGlobalMapDbg > 1 { + fmt.Fprintf(os.Stderr, "=-= add R_KEEP relo from %s to %s\n", + vs.Name, fs.Name) + } + } + varToMapInit = nil +} + +// OutlineMapInits replaces global map initializers with outlined +// calls to separate "map init" functions (where possible and +// profitable), to facilitate better dead-code elimination by the +// linker. +func OutlineMapInits(fn *ir.Func) { + if base.Debug.WrapGlobalMapCtl == 1 { + return + } + + outlined := 0 + for i, stmt := range fn.Body { + // Attempt to outline stmt. If successful, replace it with a call + // to the returned wrapper function. + if wrapperFn := tryWrapGlobalInit(stmt); wrapperFn != nil { + ir.WithFunc(fn, func() { + fn.Body[i] = typecheck.Call(stmt.Pos(), wrapperFn.Nname, nil, false) + }) + outlined++ + } + } + + if base.Debug.WrapGlobalMapDbg > 1 { + fmt.Fprintf(os.Stderr, "=-= outlined %v map initializations\n", outlined) + } +} diff --git a/go/src/cmd/compile/internal/syntax/branches.go b/go/src/cmd/compile/internal/syntax/branches.go new file mode 100644 index 0000000000000000000000000000000000000000..3a2479bb8a1eab7a65eed3aaa49b4676e67ea1b2 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/branches.go @@ -0,0 +1,339 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import "fmt" + +// checkBranches checks correct use of labels and branch +// statements (break, continue, fallthrough, goto) in a function body. +// It catches: +// - misplaced breaks, continues, and fallthroughs +// - bad labeled breaks and continues +// - invalid, unused, duplicate, and missing labels +// - gotos jumping over variable declarations and into blocks +func checkBranches(body *BlockStmt, errh ErrorHandler) { + if body == nil { + return + } + + // scope of all labels in this body + ls := &labelScope{errh: errh} + fwdGotos := ls.blockBranches(nil, targets{}, nil, body.Pos(), body.List) + + // If there are any forward gotos left, no matching label was + // found for them. Either those labels were never defined, or + // they are inside blocks and not reachable from the gotos. + for _, fwd := range fwdGotos { + name := fwd.Label.Value + if l := ls.labels[name]; l != nil { + l.used = true // avoid "defined and not used" error + ls.errf(fwd.Label.Pos(), "goto %s jumps into block starting at %s", name, l.parent.start) + } else { + ls.errf(fwd.Label.Pos(), "label %s not defined", name) + } + } + + // spec: "It is illegal to define a label that is never used." + for _, l := range ls.labels { + if !l.used { + l := l.lstmt.Label + ls.errf(l.Pos(), "label %s defined and not used", l.Value) + } + } +} + +type labelScope struct { + errh ErrorHandler + labels map[string]*label // all label declarations inside the function; allocated lazily +} + +type label struct { + parent *block // block containing this label declaration + lstmt *LabeledStmt // statement declaring the label + used bool // whether the label is used or not +} + +type block struct { + parent *block // immediately enclosing block, or nil + start Pos // start of block + lstmt *LabeledStmt // labeled statement associated with this block, or nil +} + +func (ls *labelScope) errf(pos Pos, format string, args ...any) { + ls.errh(Error{pos, fmt.Sprintf(format, args...)}) +} + +// declare declares the label introduced by s in block b and returns +// the new label. If the label was already declared, declare reports +// and error and the existing label is returned instead. +func (ls *labelScope) declare(b *block, s *LabeledStmt) *label { + name := s.Label.Value + labels := ls.labels + if labels == nil { + labels = make(map[string]*label) + ls.labels = labels + } else if alt := labels[name]; alt != nil { + ls.errf(s.Label.Pos(), "label %s already defined at %s", name, alt.lstmt.Label.Pos().String()) + return alt + } + l := &label{b, s, false} + labels[name] = l + return l +} + +// gotoTarget returns the labeled statement matching the given name and +// declared in block b or any of its enclosing blocks. The result is nil +// if the label is not defined, or doesn't match a valid labeled statement. +func (ls *labelScope) gotoTarget(b *block, name string) *LabeledStmt { + if l := ls.labels[name]; l != nil { + l.used = true // even if it's not a valid target + for ; b != nil; b = b.parent { + if l.parent == b { + return l.lstmt + } + } + } + return nil +} + +var invalid = new(LabeledStmt) // singleton to signal invalid enclosing target + +// enclosingTarget returns the innermost enclosing labeled statement matching +// the given name. The result is nil if the label is not defined, and invalid +// if the label is defined but doesn't label a valid labeled statement. +func (ls *labelScope) enclosingTarget(b *block, name string) *LabeledStmt { + if l := ls.labels[name]; l != nil { + l.used = true // even if it's not a valid target (see e.g., test/fixedbugs/bug136.go) + for ; b != nil; b = b.parent { + if l.lstmt == b.lstmt { + return l.lstmt + } + } + return invalid + } + return nil +} + +// targets describes the target statements within which break +// or continue statements are valid. +type targets struct { + breaks Stmt // *ForStmt, *SwitchStmt, *SelectStmt, or nil + continues *ForStmt // or nil + caseIndex int // case index of immediately enclosing switch statement, or < 0 +} + +// blockBranches processes a block's body starting at start and returns the +// list of unresolved (forward) gotos. parent is the immediately enclosing +// block (or nil), ctxt provides information about the enclosing statements, +// and lstmt is the labeled statement associated with this block, or nil. +func (ls *labelScope) blockBranches(parent *block, ctxt targets, lstmt *LabeledStmt, start Pos, body []Stmt) []*BranchStmt { + b := &block{parent: parent, start: start, lstmt: lstmt} + + var varPos Pos + var varName Expr + var fwdGotos, badGotos []*BranchStmt + + recordVarDecl := func(pos Pos, name Expr) { + varPos = pos + varName = name + // Any existing forward goto jumping over the variable + // declaration is invalid. The goto may still jump out + // of the block and be ok, but we don't know that yet. + // Remember all forward gotos as potential bad gotos. + badGotos = append(badGotos[:0], fwdGotos...) + } + + jumpsOverVarDecl := func(fwd *BranchStmt) bool { + if varPos.IsKnown() { + for _, bad := range badGotos { + if fwd == bad { + return true + } + } + } + return false + } + + innerBlock := func(ctxt targets, start Pos, body []Stmt) { + // Unresolved forward gotos from the inner block + // become forward gotos for the current block. + fwdGotos = append(fwdGotos, ls.blockBranches(b, ctxt, lstmt, start, body)...) + } + + // A fallthrough statement counts as last statement in a statement + // list even if there are trailing empty statements; remove them. + stmtList := trimTrailingEmptyStmts(body) + for stmtIndex, stmt := range stmtList { + lstmt = nil + L: + switch s := stmt.(type) { + case *DeclStmt: + for _, d := range s.DeclList { + if v, ok := d.(*VarDecl); ok { + recordVarDecl(v.Pos(), v.NameList[0]) + break // the first VarDecl will do + } + } + + case *LabeledStmt: + // declare non-blank label + if name := s.Label.Value; name != "_" { + l := ls.declare(b, s) + // resolve matching forward gotos + i := 0 + for _, fwd := range fwdGotos { + if fwd.Label.Value == name { + fwd.Target = s + l.used = true + if jumpsOverVarDecl(fwd) { + ls.errf( + fwd.Label.Pos(), + "goto %s jumps over declaration of %s at %s", + name, String(varName), varPos, + ) + } + } else { + // no match - keep forward goto + fwdGotos[i] = fwd + i++ + } + } + fwdGotos = fwdGotos[:i] + lstmt = s + } + // process labeled statement + stmt = s.Stmt + goto L + + case *BranchStmt: + // unlabeled branch statement + if s.Label == nil { + switch s.Tok { + case _Break: + if t := ctxt.breaks; t != nil { + s.Target = t + } else { + ls.errf(s.Pos(), "break is not in a loop, switch, or select") + } + case _Continue: + if t := ctxt.continues; t != nil { + s.Target = t + } else { + ls.errf(s.Pos(), "continue is not in a loop") + } + case _Fallthrough: + msg := "fallthrough statement out of place" + if t, _ := ctxt.breaks.(*SwitchStmt); t != nil { + if _, ok := t.Tag.(*TypeSwitchGuard); ok { + msg = "cannot fallthrough in type switch" + } else if ctxt.caseIndex < 0 || stmtIndex+1 < len(stmtList) { + // fallthrough nested in a block or not the last statement + // use msg as is + } else if ctxt.caseIndex+1 == len(t.Body) { + msg = "cannot fallthrough final case in switch" + } else { + break // fallthrough ok + } + } + ls.errf(s.Pos(), "%s", msg) + case _Goto: + fallthrough // should always have a label + default: + panic("invalid BranchStmt") + } + break + } + + // labeled branch statement + name := s.Label.Value + switch s.Tok { + case _Break: + // spec: "If there is a label, it must be that of an enclosing + // "for", "switch", or "select" statement, and that is the one + // whose execution terminates." + if t := ls.enclosingTarget(b, name); t != nil { + switch t := t.Stmt.(type) { + case *SwitchStmt, *SelectStmt, *ForStmt: + s.Target = t + default: + ls.errf(s.Label.Pos(), "invalid break label %s", name) + } + } else { + ls.errf(s.Label.Pos(), "break label not defined: %s", name) + } + + case _Continue: + // spec: "If there is a label, it must be that of an enclosing + // "for" statement, and that is the one whose execution advances." + if t := ls.enclosingTarget(b, name); t != nil { + if t, ok := t.Stmt.(*ForStmt); ok { + s.Target = t + } else { + ls.errf(s.Label.Pos(), "invalid continue label %s", name) + } + } else { + ls.errf(s.Label.Pos(), "continue label not defined: %s", name) + } + + case _Goto: + if t := ls.gotoTarget(b, name); t != nil { + s.Target = t + } else { + // label may be declared later - add goto to forward gotos + fwdGotos = append(fwdGotos, s) + } + + case _Fallthrough: + fallthrough // should never have a label + default: + panic("invalid BranchStmt") + } + + case *AssignStmt: + if s.Op == Def { + recordVarDecl(s.Pos(), s.Lhs) + } + + case *BlockStmt: + inner := targets{ctxt.breaks, ctxt.continues, -1} + innerBlock(inner, s.Pos(), s.List) + + case *IfStmt: + inner := targets{ctxt.breaks, ctxt.continues, -1} + innerBlock(inner, s.Then.Pos(), s.Then.List) + if s.Else != nil { + innerBlock(inner, s.Else.Pos(), []Stmt{s.Else}) + } + + case *ForStmt: + inner := targets{s, s, -1} + innerBlock(inner, s.Body.Pos(), s.Body.List) + + case *SwitchStmt: + inner := targets{s, ctxt.continues, -1} + for i, cc := range s.Body { + inner.caseIndex = i + innerBlock(inner, cc.Pos(), cc.Body) + } + + case *SelectStmt: + inner := targets{s, ctxt.continues, -1} + for _, cc := range s.Body { + innerBlock(inner, cc.Pos(), cc.Body) + } + } + } + + return fwdGotos +} + +func trimTrailingEmptyStmts(list []Stmt) []Stmt { + for i := len(list); i > 0; i-- { + if _, ok := list[i-1].(*EmptyStmt); !ok { + return list[:i] + } + } + return nil +} diff --git a/go/src/cmd/compile/internal/syntax/dumper.go b/go/src/cmd/compile/internal/syntax/dumper.go new file mode 100644 index 0000000000000000000000000000000000000000..9a021a4582903d23af4222226a91ffe1ddeb5149 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/dumper.go @@ -0,0 +1,212 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements printing of syntax tree structures. + +package syntax + +import ( + "fmt" + "io" + "reflect" + "unicode" + "unicode/utf8" +) + +// Fdump dumps the structure of the syntax tree rooted at n to w. +// It is intended for debugging purposes; no specific output format +// is guaranteed. +func Fdump(w io.Writer, n Node) (err error) { + p := dumper{ + output: w, + ptrmap: make(map[Node]int), + last: '\n', // force printing of line number on first line + } + + defer func() { + if e := recover(); e != nil { + err = e.(writeError).err // re-panics if it's not a writeError + } + }() + + if n == nil { + p.printf("nil\n") + return + } + p.dump(reflect.ValueOf(n), n) + p.printf("\n") + + return +} + +type dumper struct { + output io.Writer + ptrmap map[Node]int // node -> dump line number + indent int // current indentation level + last byte // last byte processed by Write + line int // current line number +} + +var indentBytes = []byte(". ") + +func (p *dumper) Write(data []byte) (n int, err error) { + var m int + for i, b := range data { + // invariant: data[0:n] has been written + if b == '\n' { + m, err = p.output.Write(data[n : i+1]) + n += m + if err != nil { + return + } + } else if p.last == '\n' { + p.line++ + _, err = fmt.Fprintf(p.output, "%6d ", p.line) + if err != nil { + return + } + for j := p.indent; j > 0; j-- { + _, err = p.output.Write(indentBytes) + if err != nil { + return + } + } + } + p.last = b + } + if len(data) > n { + m, err = p.output.Write(data[n:]) + n += m + } + return +} + +// writeError wraps locally caught write errors so we can distinguish +// them from genuine panics which we don't want to return as errors. +type writeError struct { + err error +} + +// printf is a convenience wrapper that takes care of print errors. +func (p *dumper) printf(format string, args ...any) { + if _, err := fmt.Fprintf(p, format, args...); err != nil { + panic(writeError{err}) + } +} + +// dump prints the contents of x. +// If x is the reflect.Value of a struct s, where &s +// implements Node, then &s should be passed for n - +// this permits printing of the unexported span and +// comments fields of the embedded isNode field by +// calling the Span() and Comment() instead of using +// reflection. +func (p *dumper) dump(x reflect.Value, n Node) { + switch x.Kind() { + case reflect.Interface: + if x.IsNil() { + p.printf("nil") + return + } + p.dump(x.Elem(), nil) + + case reflect.Ptr: + if x.IsNil() { + p.printf("nil") + return + } + + // special cases for identifiers w/o attached comments (common case) + if x, ok := x.Interface().(*Name); ok { + p.printf("%s @ %v", x.Value, x.Pos()) + return + } + + p.printf("*") + // Fields may share type expressions, and declarations + // may share the same group - use ptrmap to keep track + // of nodes that have been printed already. + if ptr, ok := x.Interface().(Node); ok { + if line, exists := p.ptrmap[ptr]; exists { + p.printf("(Node @ %d)", line) + return + } + p.ptrmap[ptr] = p.line + n = ptr + } + p.dump(x.Elem(), n) + + case reflect.Slice: + if x.IsNil() { + p.printf("nil") + return + } + p.printf("%s (%d entries) {", x.Type(), x.Len()) + if x.Len() > 0 { + p.indent++ + p.printf("\n") + for i, n := 0, x.Len(); i < n; i++ { + p.printf("%d: ", i) + p.dump(x.Index(i), nil) + p.printf("\n") + } + p.indent-- + } + p.printf("}") + + case reflect.Struct: + typ := x.Type() + + // if span, ok := x.Interface().(lexical.Span); ok { + // p.printf("%s", &span) + // return + // } + + p.printf("%s {", typ) + p.indent++ + + first := true + if n != nil { + p.printf("\n") + first = false + // p.printf("Span: %s\n", n.Span()) + // if c := *n.Comments(); c != nil { + // p.printf("Comments: ") + // p.dump(reflect.ValueOf(c), nil) // a Comment is not a Node + // p.printf("\n") + // } + } + + for i, n := 0, typ.NumField(); i < n; i++ { + // Exclude non-exported fields because their + // values cannot be accessed via reflection. + if name := typ.Field(i).Name; isExported(name) { + if first { + p.printf("\n") + first = false + } + p.printf("%s: ", name) + p.dump(x.Field(i), nil) + p.printf("\n") + } + } + + p.indent-- + p.printf("}") + + default: + switch x := x.Interface().(type) { + case string: + // print strings in quotes + p.printf("%q", x) + default: + p.printf("%v", x) + } + } +} + +func isExported(name string) bool { + ch, _ := utf8.DecodeRuneInString(name) + return unicode.IsUpper(ch) +} diff --git a/go/src/cmd/compile/internal/syntax/dumper_test.go b/go/src/cmd/compile/internal/syntax/dumper_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1ba85cc8d9a9870bbbb1338355954a0ee8a1b0f0 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/dumper_test.go @@ -0,0 +1,21 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import ( + "testing" +) + +func TestDump(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + + ast, _ := ParseFile(*src_, func(err error) { t.Error(err) }, nil, CheckBranches) + + if ast != nil { + Fdump(testOut(), ast) + } +} diff --git a/go/src/cmd/compile/internal/syntax/error_test.go b/go/src/cmd/compile/internal/syntax/error_test.go new file mode 100644 index 0000000000000000000000000000000000000000..55ea6345b90fdf5525b0accb3ee1f0212ac34863 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/error_test.go @@ -0,0 +1,190 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements a regression test harness for syntax errors. +// The files in the testdata directory are parsed and the reported +// errors are compared against the errors declared in those files. +// +// Errors are declared in place in the form of "error comments", +// just before (or on the same line as) the offending token. +// +// Error comments must be of the form // ERROR rx or /* ERROR rx */ +// where rx is a regular expression that matches the reported error +// message. The rx text comprises the comment text after "ERROR ", +// with any white space around it stripped. +// +// If the line comment form is used, the reported error's line must +// match the line of the error comment. +// +// If the regular comment form is used, the reported error's position +// must match the position of the token immediately following the +// error comment. Thus, /* ERROR ... */ comments should appear +// immediately before the position where the error is reported. +// +// Currently, the test harness only supports one error comment per +// token. If multiple error comments appear before a token, only +// the last one is considered. + +package syntax + +import ( + "flag" + "fmt" + "internal/testenv" + "os" + "path/filepath" + "regexp" + "sort" + "strings" + "testing" +) + +const testdata = "testdata" // directory containing test files + +var print = flag.Bool("print", false, "only print errors") + +// A position represents a source position in the current file. +type position struct { + line, col uint +} + +func (pos position) String() string { + return fmt.Sprintf("%d:%d", pos.line, pos.col) +} + +func sortedPositions(m map[position]string) []position { + list := make([]position, len(m)) + i := 0 + for pos := range m { + list[i] = pos + i++ + } + sort.Slice(list, func(i, j int) bool { + a, b := list[i], list[j] + return a.line < b.line || a.line == b.line && a.col < b.col + }) + return list +} + +// declaredErrors returns a map of source positions to error +// patterns, extracted from error comments in the given file. +// Error comments in the form of line comments use col = 0 +// in their position. +func declaredErrors(t *testing.T, filename string) map[position]string { + f, err := os.Open(filename) + if err != nil { + t.Fatal(err) + } + defer f.Close() + + declared := make(map[position]string) + + var s scanner + var pattern string + s.init(f, func(line, col uint, msg string) { + // errors never start with '/' so they are automatically excluded here + switch { + case strings.HasPrefix(msg, "// ERROR "): + // we can't have another comment on the same line - just add it + declared[position{s.line, 0}] = strings.TrimSpace(msg[9:]) + case strings.HasPrefix(msg, "/* ERROR "): + // we may have more comments before the next token - collect them + pattern = strings.TrimSpace(msg[9 : len(msg)-2]) + } + }, comments) + + // consume file + for { + s.next() + if pattern != "" { + declared[position{s.line, s.col}] = pattern + pattern = "" + } + if s.tok == _EOF { + break + } + } + + return declared +} + +func testSyntaxErrors(t *testing.T, filename string) { + declared := declaredErrors(t, filename) + if *print { + fmt.Println("Declared errors:") + for _, pos := range sortedPositions(declared) { + fmt.Printf("%s:%s: %s\n", filename, pos, declared[pos]) + } + + fmt.Println() + fmt.Println("Reported errors:") + } + + f, err := os.Open(filename) + if err != nil { + t.Fatal(err) + } + defer f.Close() + + ParseFile(filename, func(err error) { + e, ok := err.(Error) + if !ok { + return + } + + if *print { + fmt.Println(err) + return + } + + orig := position{e.Pos.Line(), e.Pos.Col()} + pos := orig + pattern, found := declared[pos] + if !found { + // try line comment (only line must match) + pos = position{e.Pos.Line(), 0} + pattern, found = declared[pos] + } + if found { + rx, err := regexp.Compile(pattern) + if err != nil { + t.Errorf("%s:%s: %v", filename, pos, err) + return + } + if match := rx.MatchString(e.Msg); !match { + t.Errorf("%s:%s: %q does not match %q", filename, pos, e.Msg, pattern) + return + } + // we have a match - eliminate this error + delete(declared, pos) + } else { + t.Errorf("%s:%s: unexpected error: %s", filename, orig, e.Msg) + } + }, nil, CheckBranches) + + if *print { + fmt.Println() + return // we're done + } + + // report expected but not reported errors + for pos, pattern := range declared { + t.Errorf("%s:%s: missing error: %s", filename, pos, pattern) + } +} + +func TestSyntaxErrors(t *testing.T) { + testenv.MustHaveGoBuild(t) // we need access to source (testdata) + + list, err := os.ReadDir(testdata) + if err != nil { + t.Fatal(err) + } + for _, fi := range list { + name := fi.Name() + if !fi.IsDir() && !strings.HasPrefix(name, ".") { + testSyntaxErrors(t, filepath.Join(testdata, name)) + } + } +} diff --git a/go/src/cmd/compile/internal/syntax/issues_test.go b/go/src/cmd/compile/internal/syntax/issues_test.go new file mode 100644 index 0000000000000000000000000000000000000000..d72890ca5ed1426b299c95f411f1fd779ab5e125 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/issues_test.go @@ -0,0 +1,51 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file holds test cases for individual issues +// for which there is (currently) no better location. + +package syntax + +import ( + "strings" + "testing" +) + +func TestIssue67866(t *testing.T) { + var tests = []string{ + "package p; var _ = T{@0: 0}", + "package p; var _ = T{@1 + 2: 0}", + "package p; var _ = T{@x[i]: 0}", + "package p; var _ = T{@f(1, 2, 3): 0}", + "package p; var _ = T{@a + f(b) + <-ch: 0}", + } + + for _, src := range tests { + // identify column position of @ and remove it from src + i := strings.Index(src, "@") + if i < 0 { + t.Errorf("%s: invalid test case (missing @)", src) + continue + } + src = src[:i] + src[i+1:] + want := colbase + uint(i) + + f, err := Parse(nil, strings.NewReader(src), nil, nil, 0) + if err != nil { + t.Errorf("%s: %v", src, err) + continue + } + + // locate KeyValueExpr + Inspect(f, func(n Node) bool { + _, ok := n.(*KeyValueExpr) + if ok { + if got := StartPos(n).Col(); got != want { + t.Errorf("%s: got col = %d, want %d", src, got, want) + } + } + return !ok + }) + } +} diff --git a/go/src/cmd/compile/internal/syntax/nodes.go b/go/src/cmd/compile/internal/syntax/nodes.go new file mode 100644 index 0000000000000000000000000000000000000000..de277fc3d8cdabe845538ee6c6fb5629ee97932a --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/nodes.go @@ -0,0 +1,487 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +// ---------------------------------------------------------------------------- +// Nodes + +type Node interface { + // Pos() returns the position associated with the node as follows: + // 1) The position of a node representing a terminal syntax production + // (Name, BasicLit, etc.) is the position of the respective production + // in the source. + // 2) The position of a node representing a non-terminal production + // (IndexExpr, IfStmt, etc.) is the position of a token uniquely + // associated with that production; usually the left-most one + // ('[' for IndexExpr, 'if' for IfStmt, etc.) + Pos() Pos + SetPos(Pos) + aNode() +} + +type node struct { + // commented out for now since not yet used + // doc *Comment // nil means no comment(s) attached + pos Pos +} + +func (n *node) Pos() Pos { return n.pos } +func (n *node) SetPos(pos Pos) { n.pos = pos } +func (*node) aNode() {} + +// ---------------------------------------------------------------------------- +// Files + +// package PkgName; DeclList[0], DeclList[1], ... +type File struct { + Pragma Pragma + PkgName *Name + DeclList []Decl + EOF Pos + GoVersion string + node +} + +// ---------------------------------------------------------------------------- +// Declarations + +type ( + Decl interface { + Node + aDecl() + } + + // Path + // LocalPkgName Path + ImportDecl struct { + Group *Group // nil means not part of a group + Pragma Pragma + LocalPkgName *Name // including "."; nil means no rename present + Path *BasicLit // Path.Bad || Path.Kind == StringLit; nil means no path + decl + } + + // NameList + // NameList = Values + // NameList Type = Values + ConstDecl struct { + Group *Group // nil means not part of a group + Pragma Pragma + NameList []*Name + Type Expr // nil means no type + Values Expr // nil means no values + decl + } + + // Name Type + TypeDecl struct { + Group *Group // nil means not part of a group + Pragma Pragma + Name *Name + TParamList []*Field // nil means no type parameters + Alias bool + Type Expr + decl + } + + // NameList Type + // NameList Type = Values + // NameList = Values + VarDecl struct { + Group *Group // nil means not part of a group + Pragma Pragma + NameList []*Name + Type Expr // nil means no type + Values Expr // nil means no values + decl + } + + // func Name Type { Body } + // func Name Type + // func Receiver Name Type { Body } + // func Receiver Name Type + FuncDecl struct { + Pragma Pragma + Recv *Field // nil means regular function + Name *Name + TParamList []*Field // nil means no type parameters + Type *FuncType + Body *BlockStmt // nil means no body (forward declaration) + decl + } +) + +type decl struct{ node } + +func (*decl) aDecl() {} + +// All declarations belonging to the same group point to the same Group node. +type Group struct { + _ int // not empty so we are guaranteed different Group instances +} + +// ---------------------------------------------------------------------------- +// Expressions + +func NewName(pos Pos, value string) *Name { + n := new(Name) + n.pos = pos + n.Value = value + return n +} + +type ( + Expr interface { + Node + typeInfo + aExpr() + } + + // Placeholder for an expression that failed to parse + // correctly and where we can't provide a better node. + BadExpr struct { + expr + } + + // Value + Name struct { + Value string + expr + } + + // Value + BasicLit struct { + Value string + Kind LitKind + Bad bool // true means the literal Value has syntax errors + expr + } + + // Type { ElemList[0], ElemList[1], ... } + CompositeLit struct { + Type Expr // nil means no literal type + ElemList []Expr + NKeys int // number of elements with keys + Rbrace Pos + expr + } + + // Key: Value + KeyValueExpr struct { + Key, Value Expr + expr + } + + // func Type { Body } + FuncLit struct { + Type *FuncType + Body *BlockStmt + expr + } + + // (X) + ParenExpr struct { + X Expr + expr + } + + // X.Sel + SelectorExpr struct { + X Expr + Sel *Name + expr + } + + // X[Index] + // X[T1, T2, ...] (with Ti = Index.(*ListExpr).ElemList[i]) + IndexExpr struct { + X Expr + Index Expr + expr + } + + // X[Index[0] : Index[1] : Index[2]] + SliceExpr struct { + X Expr + Index [3]Expr + // Full indicates whether this is a simple or full slice expression. + // In a valid AST, this is equivalent to Index[2] != nil. + // TODO(mdempsky): This is only needed to report the "3-index + // slice of string" error when Index[2] is missing. + Full bool + expr + } + + // X.(Type) + AssertExpr struct { + X Expr + Type Expr + expr + } + + // X.(type) + // Lhs := X.(type) + TypeSwitchGuard struct { + Lhs *Name // nil means no Lhs := + X Expr // X.(type) + expr + } + + Operation struct { + Op Operator + X, Y Expr // Y == nil means unary expression + expr + } + + // Fun(ArgList[0], ArgList[1], ...) + CallExpr struct { + Fun Expr + ArgList []Expr // nil means no arguments + HasDots bool // last argument is followed by ... + expr + } + + // ElemList[0], ElemList[1], ... + ListExpr struct { + ElemList []Expr + expr + } + + // [Len]Elem + ArrayType struct { + // TODO(gri) consider using Name{"..."} instead of nil (permits attaching of comments) + Len Expr // nil means Len is ... + Elem Expr + expr + } + + // []Elem + SliceType struct { + Elem Expr + expr + } + + // ...Elem + DotsType struct { + Elem Expr + expr + } + + // struct { FieldList[0] TagList[0]; FieldList[1] TagList[1]; ... } + StructType struct { + FieldList []*Field + TagList []*BasicLit // i >= len(TagList) || TagList[i] == nil means no tag for field i + expr + } + + // Name Type + // Type + Field struct { + Name *Name // nil means anonymous field/parameter (structs/parameters), or embedded element (interfaces) + Type Expr // field names declared in a list share the same Type (identical pointers) + node + } + + // interface { MethodList[0]; MethodList[1]; ... } + InterfaceType struct { + MethodList []*Field + expr + } + + FuncType struct { + ParamList []*Field + ResultList []*Field + expr + } + + // map[Key]Value + MapType struct { + Key, Value Expr + expr + } + + // chan Elem + // <-chan Elem + // chan<- Elem + ChanType struct { + Dir ChanDir // 0 means no direction + Elem Expr + expr + } +) + +type expr struct { + node + typeAndValue // After typechecking, contains the results of typechecking this expression. +} + +func (*expr) aExpr() {} + +type ChanDir uint + +const ( + _ ChanDir = iota + SendOnly + RecvOnly +) + +// ---------------------------------------------------------------------------- +// Statements + +type ( + Stmt interface { + Node + aStmt() + } + + SimpleStmt interface { + Stmt + aSimpleStmt() + } + + EmptyStmt struct { + simpleStmt + } + + LabeledStmt struct { + Label *Name + Stmt Stmt + stmt + } + + BlockStmt struct { + List []Stmt + Rbrace Pos + stmt + } + + ExprStmt struct { + X Expr + simpleStmt + } + + SendStmt struct { + Chan, Value Expr // Chan <- Value + simpleStmt + } + + DeclStmt struct { + DeclList []Decl + stmt + } + + AssignStmt struct { + Op Operator // 0 means no operation + Lhs, Rhs Expr // Rhs == nil means Lhs++ (Op == Add) or Lhs-- (Op == Sub) + simpleStmt + } + + BranchStmt struct { + Tok token // Break, Continue, Fallthrough, or Goto + Label *Name + // Target is the continuation of the control flow after executing + // the branch; it is computed by the parser if CheckBranches is set. + // Target is a *LabeledStmt for gotos, and a *SwitchStmt, *SelectStmt, + // or *ForStmt for breaks and continues, depending on the context of + // the branch. Target is not set for fallthroughs. + Target Stmt + stmt + } + + CallStmt struct { + Tok token // Go or Defer + Call Expr + DeferAt Expr // argument to runtime.deferprocat + stmt + } + + ReturnStmt struct { + Results Expr // nil means no explicit return values + stmt + } + + IfStmt struct { + Init SimpleStmt + Cond Expr + Then *BlockStmt + Else Stmt // either nil, *IfStmt, or *BlockStmt + stmt + } + + ForStmt struct { + Init SimpleStmt // incl. *RangeClause + Cond Expr + Post SimpleStmt + Body *BlockStmt + stmt + } + + SwitchStmt struct { + Init SimpleStmt + Tag Expr // incl. *TypeSwitchGuard + Body []*CaseClause + Rbrace Pos + stmt + } + + SelectStmt struct { + Body []*CommClause + Rbrace Pos + stmt + } +) + +type ( + RangeClause struct { + Lhs Expr // nil means no Lhs = or Lhs := + Def bool // means := + X Expr // range X + simpleStmt + } + + CaseClause struct { + Cases Expr // nil means default clause + Body []Stmt + Colon Pos + node + } + + CommClause struct { + Comm SimpleStmt // send or receive stmt; nil means default clause + Body []Stmt + Colon Pos + node + } +) + +type stmt struct{ node } + +func (stmt) aStmt() {} + +type simpleStmt struct { + stmt +} + +func (simpleStmt) aSimpleStmt() {} + +// ---------------------------------------------------------------------------- +// Comments + +// TODO(gri) Consider renaming to CommentPos, CommentPlacement, etc. +// Kind = Above doesn't make much sense. +type CommentKind uint + +const ( + Above CommentKind = iota + Below + Left + Right +) + +type Comment struct { + Kind CommentKind + Text string + Next *Comment +} diff --git a/go/src/cmd/compile/internal/syntax/nodes_test.go b/go/src/cmd/compile/internal/syntax/nodes_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a86ae87adf3ab842b1aa8aaa1fbeb5d644ae848b --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/nodes_test.go @@ -0,0 +1,326 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import ( + "fmt" + "strings" + "testing" +) + +// A test is a source code snippet of a particular node type. +// In the snippet, a '@' indicates the position recorded by +// the parser when creating the respective node. +type test struct { + nodetyp string + snippet string +} + +var decls = []test{ + // The position of declarations is always the + // position of the first token of an individual + // declaration, independent of grouping. + {"ImportDecl", `import @"math"`}, + {"ImportDecl", `import @mymath "math"`}, + {"ImportDecl", `import @. "math"`}, + {"ImportDecl", `import (@"math")`}, + {"ImportDecl", `import (@mymath "math")`}, + {"ImportDecl", `import (@. "math")`}, + + {"ConstDecl", `const @x`}, + {"ConstDecl", `const @x = 0`}, + {"ConstDecl", `const @x, y, z = 0, 1, 2`}, + {"ConstDecl", `const (@x)`}, + {"ConstDecl", `const (@x = 0)`}, + {"ConstDecl", `const (@x, y, z = 0, 1, 2)`}, + + {"TypeDecl", `type @T int`}, + {"TypeDecl", `type @T = int`}, + {"TypeDecl", `type (@T int)`}, + {"TypeDecl", `type (@T = int)`}, + + {"VarDecl", `var @x int`}, + {"VarDecl", `var @x, y, z int`}, + {"VarDecl", `var @x int = 0`}, + {"VarDecl", `var @x, y, z int = 1, 2, 3`}, + {"VarDecl", `var @x = 0`}, + {"VarDecl", `var @x, y, z = 1, 2, 3`}, + {"VarDecl", `var (@x int)`}, + {"VarDecl", `var (@x, y, z int)`}, + {"VarDecl", `var (@x int = 0)`}, + {"VarDecl", `var (@x, y, z int = 1, 2, 3)`}, + {"VarDecl", `var (@x = 0)`}, + {"VarDecl", `var (@x, y, z = 1, 2, 3)`}, + + {"FuncDecl", `func @f() {}`}, + {"FuncDecl", `func @(T) f() {}`}, + {"FuncDecl", `func @(x T) f() {}`}, +} + +var exprs = []test{ + // The position of an expression is the position + // of the left-most token that identifies the + // kind of expression. + {"Name", `@x`}, + + {"BasicLit", `@0`}, + {"BasicLit", `@0x123`}, + {"BasicLit", `@3.1415`}, + {"BasicLit", `@.2718`}, + {"BasicLit", `@1i`}, + {"BasicLit", `@'a'`}, + {"BasicLit", `@"abc"`}, + {"BasicLit", "@`abc`"}, + + {"CompositeLit", `@{}`}, + {"CompositeLit", `T@{}`}, + {"CompositeLit", `struct{x, y int}@{}`}, + + {"KeyValueExpr", `"foo"@: true`}, + {"KeyValueExpr", `"a"@: b`}, + + {"FuncLit", `@func (){}`}, + {"ParenExpr", `@(x)`}, + {"SelectorExpr", `a@.b`}, + {"IndexExpr", `a@[i]`}, + + {"SliceExpr", `a@[:]`}, + {"SliceExpr", `a@[i:]`}, + {"SliceExpr", `a@[:j]`}, + {"SliceExpr", `a@[i:j]`}, + {"SliceExpr", `a@[i:j:k]`}, + + {"AssertExpr", `x@.(T)`}, + + {"Operation", `@*b`}, + {"Operation", `@+b`}, + {"Operation", `@-b`}, + {"Operation", `@!b`}, + {"Operation", `@^b`}, + {"Operation", `@&b`}, + {"Operation", `@<-b`}, + + {"Operation", `a @|| b`}, + {"Operation", `a @&& b`}, + {"Operation", `a @== b`}, + {"Operation", `a @+ b`}, + {"Operation", `a @* b`}, + + {"CallExpr", `f@()`}, + {"CallExpr", `f@(x, y, z)`}, + {"CallExpr", `obj.f@(1, 2, 3)`}, + {"CallExpr", `func(x int) int { return x + 1 }@(y)`}, + + // ListExpr: tested via multi-value const/var declarations +} + +var types = []test{ + {"Operation", `@*T`}, + {"Operation", `@*struct{}`}, + + {"ArrayType", `@[10]T`}, + {"ArrayType", `@[...]T`}, + + {"SliceType", `@[]T`}, + {"DotsType", `@...T`}, + {"StructType", `@struct{}`}, + {"InterfaceType", `@interface{}`}, + {"FuncType", `func@()`}, + {"MapType", `@map[T]T`}, + + {"ChanType", `@chan T`}, + {"ChanType", `@chan<- T`}, + {"ChanType", `@<-chan T`}, +} + +var fields = []test{ + {"Field", `@T`}, + {"Field", `@(T)`}, + {"Field", `@x T`}, + {"Field", `@x *(T)`}, + {"Field", `@x, y, z T`}, + {"Field", `@x, y, z (*T)`}, +} + +var stmts = []test{ + {"EmptyStmt", `@`}, + + {"LabeledStmt", `L@:`}, + {"LabeledStmt", `L@: ;`}, + {"LabeledStmt", `L@: f()`}, + + {"BlockStmt", `@{}`}, + + // The position of an ExprStmt is the position of the expression. + {"ExprStmt", `@<-ch`}, + {"ExprStmt", `f@()`}, + {"ExprStmt", `append@(s, 1, 2, 3)`}, + + {"SendStmt", `ch @<- x`}, + + {"DeclStmt", `@const x = 0`}, + {"DeclStmt", `@const (x = 0)`}, + {"DeclStmt", `@type T int`}, + {"DeclStmt", `@type T = int`}, + {"DeclStmt", `@type (T1 = int; T2 = float32)`}, + {"DeclStmt", `@var x = 0`}, + {"DeclStmt", `@var x, y, z int`}, + {"DeclStmt", `@var (a, b = 1, 2)`}, + + {"AssignStmt", `x @= y`}, + {"AssignStmt", `a, b, x @= 1, 2, 3`}, + {"AssignStmt", `x @+= y`}, + {"AssignStmt", `x @:= y`}, + {"AssignStmt", `x, ok @:= f()`}, + {"AssignStmt", `x@++`}, + {"AssignStmt", `a[i]@--`}, + + {"BranchStmt", `@break`}, + {"BranchStmt", `@break L`}, + {"BranchStmt", `@continue`}, + {"BranchStmt", `@continue L`}, + {"BranchStmt", `@fallthrough`}, + {"BranchStmt", `@goto L`}, + + {"CallStmt", `@defer f()`}, + {"CallStmt", `@go f()`}, + + {"ReturnStmt", `@return`}, + {"ReturnStmt", `@return x`}, + {"ReturnStmt", `@return a, b, a + b*f(1, 2, 3)`}, + + {"IfStmt", `@if cond {}`}, + {"IfStmt", `@if cond { f() } else {}`}, + {"IfStmt", `@if cond { f() } else { g(); h() }`}, + {"ForStmt", `@for {}`}, + {"ForStmt", `@for { f() }`}, + {"SwitchStmt", `@switch {}`}, + {"SwitchStmt", `@switch { default: }`}, + {"SwitchStmt", `@switch { default: x++ }`}, + {"SelectStmt", `@select {}`}, + {"SelectStmt", `@select { default: }`}, + {"SelectStmt", `@select { default: ch <- false }`}, +} + +var ranges = []test{ + {"RangeClause", `@range s`}, + {"RangeClause", `i = @range s`}, + {"RangeClause", `i := @range s`}, + {"RangeClause", `_, x = @range s`}, + {"RangeClause", `i, x = @range s`}, + {"RangeClause", `_, x := @range s.f`}, + {"RangeClause", `i, x := @range f(i)`}, +} + +var guards = []test{ + {"TypeSwitchGuard", `x@.(type)`}, + {"TypeSwitchGuard", `x := x@.(type)`}, +} + +var cases = []test{ + {"CaseClause", `@case x:`}, + {"CaseClause", `@case x, y, z:`}, + {"CaseClause", `@case x == 1, y == 2:`}, + {"CaseClause", `@default:`}, +} + +var comms = []test{ + {"CommClause", `@case <-ch:`}, + {"CommClause", `@case x <- ch:`}, + {"CommClause", `@case x = <-ch:`}, + {"CommClause", `@case x := <-ch:`}, + {"CommClause", `@case x, ok = <-ch: f(1, 2, 3)`}, + {"CommClause", `@case x, ok := <-ch: x++`}, + {"CommClause", `@default:`}, + {"CommClause", `@default: ch <- true`}, +} + +func TestPos(t *testing.T) { + // TODO(gri) Once we have a general tree walker, we can use that to find + // the first occurrence of the respective node and we don't need to hand- + // extract the node for each specific kind of construct. + + testPos(t, decls, "package p; ", "", + func(f *File) Node { return f.DeclList[0] }, + ) + + // embed expressions in a composite literal so we can test key:value and naked composite literals + testPos(t, exprs, "package p; var _ = T{ ", " }", + func(f *File) Node { return f.DeclList[0].(*VarDecl).Values.(*CompositeLit).ElemList[0] }, + ) + + // embed types in a function signature so we can test ... types + testPos(t, types, "package p; func f(", ")", + func(f *File) Node { return f.DeclList[0].(*FuncDecl).Type.ParamList[0].Type }, + ) + + testPos(t, fields, "package p; func f(", ")", + func(f *File) Node { return f.DeclList[0].(*FuncDecl).Type.ParamList[0] }, + ) + + testPos(t, stmts, "package p; func _() { ", "; }", + func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body.List[0] }, + ) + + testPos(t, ranges, "package p; func _() { for ", " {} }", + func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body.List[0].(*ForStmt).Init.(*RangeClause) }, + ) + + testPos(t, guards, "package p; func _() { switch ", " {} }", + func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body.List[0].(*SwitchStmt).Tag.(*TypeSwitchGuard) }, + ) + + testPos(t, cases, "package p; func _() { switch { ", " } }", + func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body.List[0].(*SwitchStmt).Body[0] }, + ) + + testPos(t, comms, "package p; func _() { select { ", " } }", + func(f *File) Node { return f.DeclList[0].(*FuncDecl).Body.List[0].(*SelectStmt).Body[0] }, + ) +} + +func testPos(t *testing.T, list []test, prefix, suffix string, extract func(*File) Node) { + for _, test := range list { + // complete source, compute @ position, and strip @ from source + src, index := stripAt(prefix + test.snippet + suffix) + if index < 0 { + t.Errorf("missing @: %s (%s)", src, test.nodetyp) + continue + } + + // build syntax tree + file, err := Parse(nil, strings.NewReader(src), nil, nil, 0) + if err != nil { + t.Errorf("parse error: %s: %v (%s)", src, err, test.nodetyp) + continue + } + + // extract desired node + node := extract(file) + if typ := typeOf(node); typ != test.nodetyp { + t.Errorf("type error: %s: type = %s, want %s", src, typ, test.nodetyp) + continue + } + + // verify node position with expected position as indicated by @ + if pos := int(node.Pos().Col()); pos != index+colbase { + t.Errorf("pos error: %s: pos = %d, want %d (%s)", src, pos, index+colbase, test.nodetyp) + continue + } + } +} + +func stripAt(s string) (string, int) { + if i := strings.Index(s, "@"); i >= 0 { + return s[:i] + s[i+1:], i + } + return s, -1 +} + +func typeOf(n Node) string { + const prefix = "*syntax." + k := fmt.Sprintf("%T", n) + return strings.TrimPrefix(k, prefix) +} diff --git a/go/src/cmd/compile/internal/syntax/operator_string.go b/go/src/cmd/compile/internal/syntax/operator_string.go new file mode 100644 index 0000000000000000000000000000000000000000..f045d8c55243ea307922e2372d0deae119b43207 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/operator_string.go @@ -0,0 +1,46 @@ +// Code generated by "stringer -type Operator -linecomment tokens.go"; DO NOT EDIT. + +package syntax + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Def-1] + _ = x[Not-2] + _ = x[Recv-3] + _ = x[Tilde-4] + _ = x[OrOr-5] + _ = x[AndAnd-6] + _ = x[Eql-7] + _ = x[Neq-8] + _ = x[Lss-9] + _ = x[Leq-10] + _ = x[Gtr-11] + _ = x[Geq-12] + _ = x[Add-13] + _ = x[Sub-14] + _ = x[Or-15] + _ = x[Xor-16] + _ = x[Mul-17] + _ = x[Div-18] + _ = x[Rem-19] + _ = x[And-20] + _ = x[AndNot-21] + _ = x[Shl-22] + _ = x[Shr-23] +} + +const _Operator_name = ":!<-~||&&==!=<<=>>=+-|^*/%&&^<<>>" + +var _Operator_index = [...]uint8{0, 1, 2, 4, 5, 7, 9, 11, 13, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31, 33} + +func (i Operator) String() string { + i -= 1 + if i >= Operator(len(_Operator_index)-1) { + return "Operator(" + strconv.FormatInt(int64(i+1), 10) + ")" + } + return _Operator_name[_Operator_index[i]:_Operator_index[i+1]] +} diff --git a/go/src/cmd/compile/internal/syntax/parser.go b/go/src/cmd/compile/internal/syntax/parser.go new file mode 100644 index 0000000000000000000000000000000000000000..82786859435b977d4430b71d317cfe7ea4d650b3 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/parser.go @@ -0,0 +1,2900 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import ( + "fmt" + "go/build/constraint" + "io" + "strconv" + "strings" +) + +const debug = false +const trace = false + +type parser struct { + file *PosBase + errh ErrorHandler + mode Mode + pragh PragmaHandler + scanner + + base *PosBase // current position base + first error // first error encountered + errcnt int // number of errors encountered + pragma Pragma // pragmas + goVersion string // Go version from //go:build line + + top bool // in top of file (before package clause) + fnest int // function nesting level (for error handling) + xnest int // expression nesting level (for complit ambiguity resolution) + indent []byte // tracing support +} + +func (p *parser) init(file *PosBase, r io.Reader, errh ErrorHandler, pragh PragmaHandler, mode Mode) { + p.top = true + p.file = file + p.errh = errh + p.mode = mode + p.pragh = pragh + p.scanner.init( + r, + // Error and directive handler for scanner. + // Because the (line, col) positions passed to the + // handler is always at or after the current reading + // position, it is safe to use the most recent position + // base to compute the corresponding Pos value. + func(line, col uint, msg string) { + if msg[0] != '/' { + p.errorAt(p.posAt(line, col), msg) + return + } + + // otherwise it must be a comment containing a line or go: directive. + // //line directives must be at the start of the line (column colbase). + // /*line*/ directives can be anywhere in the line. + text := commentText(msg) + if (col == colbase || msg[1] == '*') && strings.HasPrefix(text, "line ") { + var pos Pos // position immediately following the comment + if msg[1] == '/' { + // line comment (newline is part of the comment) + pos = MakePos(p.file, line+1, colbase) + } else { + // regular comment + // (if the comment spans multiple lines it's not + // a valid line directive and will be discarded + // by updateBase) + pos = MakePos(p.file, line, col+uint(len(msg))) + } + p.updateBase(pos, line, col+2+5, text[5:]) // +2 to skip over // or /* + return + } + + // go: directive (but be conservative and test) + if strings.HasPrefix(text, "go:") { + if p.top && strings.HasPrefix(msg, "//go:build") { + if x, err := constraint.Parse(msg); err == nil { + p.goVersion = constraint.GoVersion(x) + } + } + if pragh != nil { + p.pragma = pragh(p.posAt(line, col+2), p.scanner.blank, text, p.pragma) // +2 to skip over // or /* + } + } + }, + directives, + ) + + p.base = file + p.first = nil + p.errcnt = 0 + p.pragma = nil + + p.fnest = 0 + p.xnest = 0 + p.indent = nil +} + +// takePragma returns the current parsed pragmas +// and clears them from the parser state. +func (p *parser) takePragma() Pragma { + prag := p.pragma + p.pragma = nil + return prag +} + +// clearPragma is called at the end of a statement or +// other Go form that does NOT accept a pragma. +// It sends the pragma back to the pragma handler +// to be reported as unused. +func (p *parser) clearPragma() { + if p.pragma != nil { + p.pragh(p.pos(), p.scanner.blank, "", p.pragma) + p.pragma = nil + } +} + +// updateBase sets the current position base to a new line base at pos. +// The base's filename, line, and column values are extracted from text +// which is positioned at (tline, tcol) (only needed for error messages). +func (p *parser) updateBase(pos Pos, tline, tcol uint, text string) { + i, n, ok := trailingDigits(text) + if i == 0 { + return // ignore (not a line directive) + } + // i > 0 + + if !ok { + // text has a suffix :xxx but xxx is not a number + p.errorAt(p.posAt(tline, tcol+i), "invalid line number: "+text[i:]) + return + } + + var line, col uint + i2, n2, ok2 := trailingDigits(text[:i-1]) + if ok2 { + //line filename:line:col + i, i2 = i2, i + line, col = n2, n + if col == 0 || col > PosMax { + p.errorAt(p.posAt(tline, tcol+i2), "invalid column number: "+text[i2:]) + return + } + text = text[:i2-1] // lop off ":col" + } else { + //line filename:line + line = n + } + + if line == 0 || line > PosMax { + p.errorAt(p.posAt(tline, tcol+i), "invalid line number: "+text[i:]) + return + } + + // If we have a column (//line filename:line:col form), + // an empty filename means to use the previous filename. + filename := text[:i-1] // lop off ":line" + trimmed := false + if filename == "" && ok2 { + filename = p.base.Filename() + trimmed = p.base.Trimmed() + } + + p.base = NewLineBase(pos, filename, trimmed, line, col) +} + +func commentText(s string) string { + if s[:2] == "/*" { + return s[2 : len(s)-2] // lop off /* and */ + } + + // line comment (does not include newline) + // (on Windows, the line comment may end in \r\n) + i := len(s) + if s[i-1] == '\r' { + i-- + } + return s[2:i] // lop off //, and \r at end, if any +} + +func trailingDigits(text string) (uint, uint, bool) { + i := strings.LastIndexByte(text, ':') // look from right (Windows filenames may contain ':') + if i < 0 { + return 0, 0, false // no ':' + } + // i >= 0 + n, err := strconv.ParseUint(text[i+1:], 10, 0) + return uint(i + 1), uint(n), err == nil +} + +func (p *parser) got(tok token) bool { + if p.tok == tok { + p.next() + return true + } + return false +} + +func (p *parser) want(tok token) { + if !p.got(tok) { + p.syntaxError("expected " + tokstring(tok)) + p.advance() + } +} + +// gotAssign is like got(_Assign) but it also accepts ":=" +// (and reports an error) for better parser error recovery. +func (p *parser) gotAssign() bool { + switch p.tok { + case _Define: + p.syntaxError("expected =") + fallthrough + case _Assign: + p.next() + return true + } + return false +} + +// ---------------------------------------------------------------------------- +// Error handling + +// posAt returns the Pos value for (line, col) and the current position base. +func (p *parser) posAt(line, col uint) Pos { + return MakePos(p.base, line, col) +} + +// errorAt reports an error at the given position. +func (p *parser) errorAt(pos Pos, msg string) { + err := Error{pos, msg} + if p.first == nil { + p.first = err + } + p.errcnt++ + if p.errh == nil { + panic(p.first) + } + p.errh(err) +} + +// syntaxErrorAt reports a syntax error at the given position. +func (p *parser) syntaxErrorAt(pos Pos, msg string) { + if trace { + p.print("syntax error: " + msg) + } + + if p.tok == _EOF && p.first != nil { + return // avoid meaningless follow-up errors + } + + // add punctuation etc. as needed to msg + switch { + case msg == "": + // nothing to do + case strings.HasPrefix(msg, "in "), strings.HasPrefix(msg, "at "), strings.HasPrefix(msg, "after "): + msg = " " + msg + case strings.HasPrefix(msg, "expected "): + msg = ", " + msg + default: + // plain error - we don't care about current token + p.errorAt(pos, "syntax error: "+msg) + return + } + + // determine token string + var tok string + switch p.tok { + case _Name: + tok = "name " + p.lit + case _Semi: + tok = p.lit + case _Literal: + tok = "literal " + p.lit + case _Operator: + tok = p.op.String() + case _AssignOp: + tok = p.op.String() + "=" + case _IncOp: + tok = p.op.String() + tok += tok + default: + tok = tokstring(p.tok) + } + + // TODO(gri) This may print "unexpected X, expected Y". + // Consider "got X, expected Y" in this case. + p.errorAt(pos, "syntax error: unexpected "+tok+msg) +} + +// tokstring returns the English word for selected punctuation tokens +// for more readable error messages. Use tokstring (not tok.String()) +// for user-facing (error) messages; use tok.String() for debugging +// output. +func tokstring(tok token) string { + switch tok { + case _Comma: + return "comma" + case _Semi: + return "semicolon or newline" + } + s := tok.String() + if _Break <= tok && tok <= _Var { + return "keyword " + s + } + return s +} + +// Convenience methods using the current token position. +func (p *parser) pos() Pos { return p.posAt(p.line, p.col) } +func (p *parser) error(msg string) { p.errorAt(p.pos(), msg) } +func (p *parser) syntaxError(msg string) { p.syntaxErrorAt(p.pos(), msg) } + +// The stopset contains keywords that start a statement. +// They are good synchronization points in case of syntax +// errors and (usually) shouldn't be skipped over. +const stopset uint64 = 1<<_Break | + 1<<_Const | + 1<<_Continue | + 1<<_Defer | + 1<<_Fallthrough | + 1<<_For | + 1<<_Go | + 1<<_Goto | + 1<<_If | + 1<<_Return | + 1<<_Select | + 1<<_Switch | + 1<<_Type | + 1<<_Var + +// advance consumes tokens until it finds a token of the stopset or followlist. +// The stopset is only considered if we are inside a function (p.fnest > 0). +// The followlist is the list of valid tokens that can follow a production; +// if it is empty, exactly one (non-EOF) token is consumed to ensure progress. +func (p *parser) advance(followlist ...token) { + if trace { + p.print(fmt.Sprintf("advance %s", followlist)) + } + + // compute follow set + // (not speed critical, advance is only called in error situations) + var followset uint64 = 1 << _EOF // don't skip over EOF + if len(followlist) > 0 { + if p.fnest > 0 { + followset |= stopset + } + for _, tok := range followlist { + followset |= 1 << tok + } + } + + for !contains(followset, p.tok) { + if trace { + p.print("skip " + p.tok.String()) + } + p.next() + if len(followlist) == 0 { + break + } + } + + if trace { + p.print("next " + p.tok.String()) + } +} + +// usage: defer p.trace(msg)() +func (p *parser) trace(msg string) func() { + p.print(msg + " (") + const tab = ". " + p.indent = append(p.indent, tab...) + return func() { + p.indent = p.indent[:len(p.indent)-len(tab)] + if x := recover(); x != nil { + panic(x) // skip print_trace + } + p.print(")") + } +} + +func (p *parser) print(msg string) { + fmt.Printf("%5d: %s%s\n", p.line, p.indent, msg) +} + +// ---------------------------------------------------------------------------- +// Package files +// +// Parse methods are annotated with matching Go productions as appropriate. +// The annotations are intended as guidelines only since a single Go grammar +// rule may be covered by multiple parse methods and vice versa. +// +// Excluding methods returning slices, parse methods named xOrNil may return +// nil; all others are expected to return a valid non-nil node. + +// SourceFile = PackageClause ";" { ImportDecl ";" } { TopLevelDecl ";" } . +func (p *parser) fileOrNil() *File { + if trace { + defer p.trace("file")() + } + + f := new(File) + f.pos = p.pos() + + // PackageClause + f.GoVersion = p.goVersion + p.top = false + if !p.got(_Package) { + p.syntaxError("package statement must be first") + return nil + } + f.Pragma = p.takePragma() + f.PkgName = p.name() + p.want(_Semi) + + // don't bother continuing if package clause has errors + if p.first != nil { + return nil + } + + // Accept import declarations anywhere for error tolerance, but complain. + // { ( ImportDecl | TopLevelDecl ) ";" } + prev := _Import + for p.tok != _EOF { + if p.tok == _Import && prev != _Import { + p.syntaxError("imports must appear before other declarations") + } + prev = p.tok + + switch p.tok { + case _Import: + p.next() + f.DeclList = p.appendGroup(f.DeclList, p.importDecl) + + case _Const: + p.next() + f.DeclList = p.appendGroup(f.DeclList, p.constDecl) + + case _Type: + p.next() + f.DeclList = p.appendGroup(f.DeclList, p.typeDecl) + + case _Var: + p.next() + f.DeclList = p.appendGroup(f.DeclList, p.varDecl) + + case _Func: + p.next() + if d := p.funcDeclOrNil(); d != nil { + f.DeclList = append(f.DeclList, d) + } + + default: + if p.tok == _Lbrace && len(f.DeclList) > 0 && isEmptyFuncDecl(f.DeclList[len(f.DeclList)-1]) { + // opening { of function declaration on next line + p.syntaxError("unexpected semicolon or newline before {") + } else { + p.syntaxError("non-declaration statement outside function body") + } + p.advance(_Import, _Const, _Type, _Var, _Func) + continue + } + + // Reset p.pragma BEFORE advancing to the next token (consuming ';') + // since comments before may set pragmas for the next function decl. + p.clearPragma() + + if p.tok != _EOF && !p.got(_Semi) { + p.syntaxError("after top level declaration") + p.advance(_Import, _Const, _Type, _Var, _Func) + } + } + // p.tok == _EOF + + p.clearPragma() + f.EOF = p.pos() + + return f +} + +func isEmptyFuncDecl(dcl Decl) bool { + f, ok := dcl.(*FuncDecl) + return ok && f.Body == nil +} + +// ---------------------------------------------------------------------------- +// Declarations + +// list parses a possibly empty, sep-separated list of elements, optionally +// followed by sep, and closed by close (or EOF). sep must be one of _Comma +// or _Semi, and close must be one of _Rparen, _Rbrace, or _Rbrack. +// +// For each list element, f is called. Specifically, unless we're at close +// (or EOF), f is called at least once. After f returns true, no more list +// elements are accepted. list returns the position of the closing token. +// +// list = [ f { sep f } [sep] ] close . +func (p *parser) list(context string, sep, close token, f func() bool) Pos { + if debug && (sep != _Comma && sep != _Semi || close != _Rparen && close != _Rbrace && close != _Rbrack) { + panic("invalid sep or close argument for list") + } + + done := false + for p.tok != _EOF && p.tok != close && !done { + done = f() + // sep is optional before close + if !p.got(sep) && p.tok != close { + p.syntaxError(fmt.Sprintf("in %s; possibly missing %s or %s", context, tokstring(sep), tokstring(close))) + p.advance(_Rparen, _Rbrack, _Rbrace) + if p.tok != close { + // position could be better but we had an error so we don't care + return p.pos() + } + } + } + + pos := p.pos() + p.want(close) + return pos +} + +// appendGroup(f) = f | "(" { f ";" } ")" . // ";" is optional before ")" +func (p *parser) appendGroup(list []Decl, f func(*Group) Decl) []Decl { + if p.tok == _Lparen { + g := new(Group) + p.clearPragma() + p.next() // must consume "(" after calling clearPragma! + p.list("grouped declaration", _Semi, _Rparen, func() bool { + if x := f(g); x != nil { + list = append(list, x) + } + return false + }) + } else { + if x := f(nil); x != nil { + list = append(list, x) + } + } + return list +} + +// ImportSpec = [ "." | PackageName ] ImportPath . +// ImportPath = string_lit . +func (p *parser) importDecl(group *Group) Decl { + if trace { + defer p.trace("importDecl")() + } + + d := new(ImportDecl) + d.pos = p.pos() + d.Group = group + d.Pragma = p.takePragma() + + switch p.tok { + case _Name: + d.LocalPkgName = p.name() + case _Dot: + d.LocalPkgName = NewName(p.pos(), ".") + p.next() + } + d.Path = p.oliteral() + if d.Path == nil { + p.syntaxError("missing import path") + p.advance(_Semi, _Rparen) + return d + } + if !d.Path.Bad && d.Path.Kind != StringLit { + p.syntaxErrorAt(d.Path.Pos(), "import path must be a string") + d.Path.Bad = true + } + // d.Path.Bad || d.Path.Kind == StringLit + + return d +} + +// ConstSpec = IdentifierList [ [ Type ] "=" ExpressionList ] . +func (p *parser) constDecl(group *Group) Decl { + if trace { + defer p.trace("constDecl")() + } + + d := new(ConstDecl) + d.pos = p.pos() + d.Group = group + d.Pragma = p.takePragma() + + d.NameList = p.nameList(p.name()) + if p.tok != _EOF && p.tok != _Semi && p.tok != _Rparen { + d.Type = p.typeOrNil() + if p.gotAssign() { + d.Values = p.exprList() + } + } + + return d +} + +// TypeSpec = identifier [ TypeParams ] [ "=" ] Type . +func (p *parser) typeDecl(group *Group) Decl { + if trace { + defer p.trace("typeDecl")() + } + + d := new(TypeDecl) + d.pos = p.pos() + d.Group = group + d.Pragma = p.takePragma() + + d.Name = p.name() + if p.tok == _Lbrack { + // d.Name "[" ... + // array/slice type or type parameter list + pos := p.pos() + p.next() + switch p.tok { + case _Name: + // We may have an array type or a type parameter list. + // In either case we expect an expression x (which may + // just be a name, or a more complex expression) which + // we can analyze further. + // + // A type parameter list may have a type bound starting + // with a "[" as in: P []E. In that case, simply parsing + // an expression would lead to an error: P[] is invalid. + // But since index or slice expressions are never constant + // and thus invalid array length expressions, if the name + // is followed by "[" it must be the start of an array or + // slice constraint. Only if we don't see a "[" do we + // need to parse a full expression. Notably, name <- x + // is not a concern because name <- x is a statement and + // not an expression. + var x Expr = p.name() + if p.tok != _Lbrack { + // To parse the expression starting with name, expand + // the call sequence we would get by passing in name + // to parser.expr, and pass in name to parser.pexpr. + p.xnest++ + x = p.binaryExpr(p.pexpr(x, false), 0) + p.xnest-- + } + // Analyze expression x. If we can split x into a type parameter + // name, possibly followed by a type parameter type, we consider + // this the start of a type parameter list, with some caveats: + // a single name followed by "]" tilts the decision towards an + // array declaration; a type parameter type that could also be + // an ordinary expression but which is followed by a comma tilts + // the decision towards a type parameter list. + if pname, ptype := extractName(x, p.tok == _Comma); pname != nil && (ptype != nil || p.tok != _Rbrack) { + // d.Name "[" pname ... + // d.Name "[" pname ptype ... + // d.Name "[" pname ptype "," ... + d.TParamList = p.paramList(pname, ptype, _Rbrack, true, false) // ptype may be nil + d.Alias = p.gotAssign() + d.Type = p.typeOrNil() + } else { + // d.Name "[" pname "]" ... + // d.Name "[" x ... + d.Type = p.arrayType(pos, x) + } + case _Rbrack: + // d.Name "[" "]" ... + p.next() + d.Type = p.sliceType(pos) + default: + // d.Name "[" ... + d.Type = p.arrayType(pos, nil) + } + } else { + d.Alias = p.gotAssign() + d.Type = p.typeOrNil() + } + + if d.Type == nil { + d.Type = p.badExpr() + p.syntaxError("in type declaration") + p.advance(_Semi, _Rparen) + } + + return d +} + +// extractName splits the expression x into (name, expr) if syntactically +// x can be written as name expr. The split only happens if expr is a type +// element (per the isTypeElem predicate) or if force is set. +// If x is just a name, the result is (name, nil). If the split succeeds, +// the result is (name, expr). Otherwise the result is (nil, x). +// Examples: +// +// x force name expr +// ------------------------------------ +// P*[]int T/F P *[]int +// P*E T P *E +// P*E F nil P*E +// P([]int) T/F P []int +// P(E) T P E +// P(E) F nil P(E) +// P*E|F|~G T/F P *E|F|~G +// P*E|F|G T P *E|F|G +// P*E|F|G F nil P*E|F|G +func extractName(x Expr, force bool) (*Name, Expr) { + switch x := x.(type) { + case *Name: + return x, nil + case *Operation: + if x.Y == nil { + break // unary expr + } + switch x.Op { + case Mul: + if name, _ := x.X.(*Name); name != nil && (force || isTypeElem(x.Y)) { + // x = name *x.Y + op := *x + op.X, op.Y = op.Y, nil // change op into unary *op.Y + return name, &op + } + case Or: + if name, lhs := extractName(x.X, force || isTypeElem(x.Y)); name != nil && lhs != nil { + // x = name lhs|x.Y + op := *x + op.X = lhs + return name, &op + } + } + case *CallExpr: + if name, _ := x.Fun.(*Name); name != nil { + if len(x.ArgList) == 1 && !x.HasDots && (force || isTypeElem(x.ArgList[0])) { + // The parser doesn't keep unnecessary parentheses. + // Set the flag below to keep them, for testing + // (see go.dev/issues/69206). + const keep_parens = false + if keep_parens { + // x = name (x.ArgList[0]) + px := new(ParenExpr) + px.pos = x.pos // position of "(" in call + px.X = x.ArgList[0] + return name, px + } else { + // x = name x.ArgList[0] + return name, Unparen(x.ArgList[0]) + } + } + } + } + return nil, x +} + +// isTypeElem reports whether x is a (possibly parenthesized) type element expression. +// The result is false if x could be a type element OR an ordinary (value) expression. +func isTypeElem(x Expr) bool { + switch x := x.(type) { + case *ArrayType, *StructType, *FuncType, *InterfaceType, *SliceType, *MapType, *ChanType: + return true + case *Operation: + return isTypeElem(x.X) || (x.Y != nil && isTypeElem(x.Y)) || x.Op == Tilde + case *ParenExpr: + return isTypeElem(x.X) + } + return false +} + +// VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) . +func (p *parser) varDecl(group *Group) Decl { + if trace { + defer p.trace("varDecl")() + } + + d := new(VarDecl) + d.pos = p.pos() + d.Group = group + d.Pragma = p.takePragma() + + d.NameList = p.nameList(p.name()) + if p.gotAssign() { + d.Values = p.exprList() + } else { + d.Type = p.type_() + if p.gotAssign() { + d.Values = p.exprList() + } + } + + return d +} + +// FunctionDecl = "func" FunctionName [ TypeParams ] ( Function | Signature ) . +// FunctionName = identifier . +// Function = Signature FunctionBody . +// MethodDecl = "func" Receiver MethodName ( Function | Signature ) . +// Receiver = Parameters . +func (p *parser) funcDeclOrNil() *FuncDecl { + if trace { + defer p.trace("funcDecl")() + } + + f := new(FuncDecl) + f.pos = p.pos() + f.Pragma = p.takePragma() + + var context string + if p.got(_Lparen) { + context = "method" + rcvr := p.paramList(nil, nil, _Rparen, false, false) + switch len(rcvr) { + case 0: + p.error("method has no receiver") + default: + p.error("method has multiple receivers") + fallthrough + case 1: + f.Recv = rcvr[0] + } + } + + if p.tok == _Name { + f.Name = p.name() + f.TParamList, f.Type = p.funcType(context) + } else { + f.Name = NewName(p.pos(), "_") + f.Type = new(FuncType) + f.Type.pos = p.pos() + msg := "expected name or (" + if context != "" { + msg = "expected name" + } + p.syntaxError(msg) + p.advance(_Lbrace, _Semi) + } + + if p.tok == _Lbrace { + f.Body = p.funcBody() + } + + return f +} + +func (p *parser) funcBody() *BlockStmt { + p.fnest++ + errcnt := p.errcnt + body := p.blockStmt("") + p.fnest-- + + // Don't check branches if there were syntax errors in the function + // as it may lead to spurious errors (e.g., see test/switch2.go) or + // possibly crashes due to incomplete syntax trees. + if p.mode&CheckBranches != 0 && errcnt == p.errcnt { + checkBranches(body, p.errh) + } + + return body +} + +// ---------------------------------------------------------------------------- +// Expressions + +func (p *parser) expr() Expr { + if trace { + defer p.trace("expr")() + } + + return p.binaryExpr(nil, 0) +} + +// Expression = UnaryExpr | Expression binary_op Expression . +func (p *parser) binaryExpr(x Expr, prec int) Expr { + // don't trace binaryExpr - only leads to overly nested trace output + + if x == nil { + x = p.unaryExpr() + } + for (p.tok == _Operator || p.tok == _Star) && p.prec > prec { + t := new(Operation) + t.pos = p.pos() + t.Op = p.op + tprec := p.prec + p.next() + t.X = x + t.Y = p.binaryExpr(nil, tprec) + x = t + } + return x +} + +// UnaryExpr = PrimaryExpr | unary_op UnaryExpr . +func (p *parser) unaryExpr() Expr { + if trace { + defer p.trace("unaryExpr")() + } + + switch p.tok { + case _Operator, _Star: + switch p.op { + case Mul, Add, Sub, Not, Xor, Tilde: + x := new(Operation) + x.pos = p.pos() + x.Op = p.op + p.next() + x.X = p.unaryExpr() + return x + + case And: + x := new(Operation) + x.pos = p.pos() + x.Op = And + p.next() + // unaryExpr may have returned a parenthesized composite literal + // (see comment in operand) - remove parentheses if any + x.X = Unparen(p.unaryExpr()) + return x + } + + case _Arrow: + // receive op (<-x) or receive-only channel (<-chan E) + pos := p.pos() + p.next() + + // If the next token is _Chan we still don't know if it is + // a channel (<-chan int) or a receive op (<-chan int(ch)). + // We only know once we have found the end of the unaryExpr. + + x := p.unaryExpr() + + // There are two cases: + // + // <-chan... => <-x is a channel type + // <-x => <-x is a receive operation + // + // In the first case, <- must be re-associated with + // the channel type parsed already: + // + // <-(chan E) => (<-chan E) + // <-(chan<-E) => (<-chan (<-E)) + + if _, ok := x.(*ChanType); ok { + // x is a channel type => re-associate <- + dir := SendOnly + t := x + for dir == SendOnly { + c, ok := t.(*ChanType) + if !ok { + break + } + dir = c.Dir + if dir == RecvOnly { + // t is type <-chan E but <-<-chan E is not permitted + // (report same error as for "type _ <-<-chan E") + p.syntaxError("unexpected <-, expected chan") + // already progressed, no need to advance + } + c.Dir = RecvOnly + t = c.Elem + } + if dir == SendOnly { + // channel dir is <- but channel element E is not a channel + // (report same error as for "type _ <-chan<-E") + p.syntaxError(fmt.Sprintf("unexpected %s, expected chan", String(t))) + // already progressed, no need to advance + } + return x + } + + // x is not a channel type => we have a receive op + o := new(Operation) + o.pos = pos + o.Op = Recv + o.X = x + return o + } + + // TODO(mdempsky): We need parens here so we can report an + // error for "(x) := true". It should be possible to detect + // and reject that more efficiently though. + return p.pexpr(nil, true) +} + +// callStmt parses call-like statements that can be preceded by 'defer' and 'go'. +func (p *parser) callStmt() *CallStmt { + if trace { + defer p.trace("callStmt")() + } + + s := new(CallStmt) + s.pos = p.pos() + s.Tok = p.tok // _Defer or _Go + p.next() + + x := p.pexpr(nil, p.tok == _Lparen) // keep_parens so we can report error below + if t := Unparen(x); t != x { + p.errorAt(x.Pos(), fmt.Sprintf("expression in %s must not be parenthesized", s.Tok)) + // already progressed, no need to advance + x = t + } + + s.Call = x + return s +} + +// Operand = Literal | OperandName | MethodExpr | "(" Expression ")" . +// Literal = BasicLit | CompositeLit | FunctionLit . +// BasicLit = int_lit | float_lit | imaginary_lit | rune_lit | string_lit . +// OperandName = identifier | QualifiedIdent. +func (p *parser) operand(keep_parens bool) Expr { + if trace { + defer p.trace("operand " + p.tok.String())() + } + + switch p.tok { + case _Name: + return p.name() + + case _Literal: + return p.oliteral() + + case _Lparen: + pos := p.pos() + p.next() + p.xnest++ + x := p.expr() + p.xnest-- + p.want(_Rparen) + + // Optimization: Record presence of ()'s only where needed + // for error reporting. Don't bother in other cases; it is + // just a waste of memory and time. + // + // Parentheses are not permitted around T in a composite + // literal T{}. If the next token is a {, assume x is a + // composite literal type T (it may not be, { could be + // the opening brace of a block, but we don't know yet). + if p.tok == _Lbrace { + keep_parens = true + } + + // Parentheses are also not permitted around the expression + // in a go/defer statement. In that case, operand is called + // with keep_parens set. + if keep_parens { + px := new(ParenExpr) + px.pos = pos + px.X = x + x = px + } + return x + + case _Func: + pos := p.pos() + p.next() + _, ftyp := p.funcType("function type") + if p.tok == _Lbrace { + p.xnest++ + + f := new(FuncLit) + f.pos = pos + f.Type = ftyp + f.Body = p.funcBody() + + p.xnest-- + return f + } + return ftyp + + case _Lbrack, _Chan, _Map, _Struct, _Interface: + return p.type_() // othertype + + default: + x := p.badExpr() + p.syntaxError("expected expression") + p.advance(_Rparen, _Rbrack, _Rbrace) + return x + } + + // Syntactically, composite literals are operands. Because a complit + // type may be a qualified identifier which is handled by pexpr + // (together with selector expressions), complits are parsed there + // as well (operand is only called from pexpr). +} + +// pexpr parses a PrimaryExpr. +// +// PrimaryExpr = +// Operand | +// Conversion | +// PrimaryExpr Selector | +// PrimaryExpr Index | +// PrimaryExpr Slice | +// PrimaryExpr TypeAssertion | +// PrimaryExpr Arguments . +// +// Selector = "." identifier . +// Index = "[" Expression "]" . +// Slice = "[" ( [ Expression ] ":" [ Expression ] ) | +// ( [ Expression ] ":" Expression ":" Expression ) +// "]" . +// TypeAssertion = "." "(" Type ")" . +// Arguments = "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" . +func (p *parser) pexpr(x Expr, keep_parens bool) Expr { + if trace { + defer p.trace("pexpr")() + } + + if x == nil { + x = p.operand(keep_parens) + } + +loop: + for { + pos := p.pos() + switch p.tok { + case _Dot: + p.next() + switch p.tok { + case _Name: + // pexpr '.' sym + t := new(SelectorExpr) + t.pos = pos + t.X = x + t.Sel = p.name() + x = t + + case _Lparen: + p.next() + if p.got(_Type) { + t := new(TypeSwitchGuard) + // t.Lhs is filled in by parser.simpleStmt + t.pos = pos + t.X = x + x = t + } else { + t := new(AssertExpr) + t.pos = pos + t.X = x + t.Type = p.type_() + x = t + } + p.want(_Rparen) + + default: + p.syntaxError("expected name or (") + p.advance(_Semi, _Rparen) + } + + case _Lbrack: + p.next() + + var i Expr + if p.tok != _Colon { + var comma bool + if p.tok == _Rbrack { + // invalid empty instance, slice or index expression; accept but complain + p.syntaxError("expected operand") + i = p.badExpr() + } else { + i, comma = p.typeList(false) + } + if comma || p.tok == _Rbrack { + p.want(_Rbrack) + // x[], x[i,] or x[i, j, ...] + t := new(IndexExpr) + t.pos = pos + t.X = x + t.Index = i + x = t + break + } + } + + // x[i:... + // For better error message, don't simply use p.want(_Colon) here (go.dev/issue/47704). + if !p.got(_Colon) { + p.syntaxError("expected comma, : or ]") + p.advance(_Comma, _Colon, _Rbrack) + } + p.xnest++ + t := new(SliceExpr) + t.pos = pos + t.X = x + t.Index[0] = i + if p.tok != _Colon && p.tok != _Rbrack { + // x[i:j... + t.Index[1] = p.expr() + } + if p.tok == _Colon { + t.Full = true + // x[i:j:...] + if t.Index[1] == nil { + p.error("middle index required in 3-index slice") + t.Index[1] = p.badExpr() + } + p.next() + if p.tok != _Rbrack { + // x[i:j:k... + t.Index[2] = p.expr() + } else { + p.error("final index required in 3-index slice") + t.Index[2] = p.badExpr() + } + } + p.xnest-- + p.want(_Rbrack) + x = t + + case _Lparen: + t := new(CallExpr) + t.pos = pos + p.next() + t.Fun = x + t.ArgList, t.HasDots = p.argList() + x = t + + case _Lbrace: + // operand may have returned a parenthesized complit + // type; accept it but complain if we have a complit + t := Unparen(x) + // determine if '{' belongs to a composite literal or a block statement + complit_ok := false + switch t.(type) { + case *Name, *SelectorExpr: + if p.xnest >= 0 { + // x is possibly a composite literal type + complit_ok = true + } + case *IndexExpr: + if p.xnest >= 0 && !isValue(t) { + // x is possibly a composite literal type + complit_ok = true + } + case *ArrayType, *SliceType, *StructType, *MapType: + // x is a comptype + complit_ok = true + } + if !complit_ok { + break loop + } + if t != x { + p.syntaxError("cannot parenthesize type in composite literal") + // already progressed, no need to advance + } + n := p.complitexpr() + n.Type = x + x = n + + default: + break loop + } + } + + return x +} + +// isValue reports whether x syntactically must be a value (and not a type) expression. +func isValue(x Expr) bool { + switch x := x.(type) { + case *BasicLit, *CompositeLit, *FuncLit, *SliceExpr, *AssertExpr, *TypeSwitchGuard, *CallExpr: + return true + case *Operation: + return x.Op != Mul || x.Y != nil // *T may be a type + case *ParenExpr: + return isValue(x.X) + case *IndexExpr: + return isValue(x.X) || isValue(x.Index) + } + return false +} + +// Element = Expression | LiteralValue . +func (p *parser) bare_complitexpr() Expr { + if trace { + defer p.trace("bare_complitexpr")() + } + + if p.tok == _Lbrace { + // '{' start_complit braced_keyval_list '}' + return p.complitexpr() + } + + return p.expr() +} + +// LiteralValue = "{" [ ElementList [ "," ] ] "}" . +func (p *parser) complitexpr() *CompositeLit { + if trace { + defer p.trace("complitexpr")() + } + + x := new(CompositeLit) + x.pos = p.pos() + + p.xnest++ + p.want(_Lbrace) + x.Rbrace = p.list("composite literal", _Comma, _Rbrace, func() bool { + // value + e := p.bare_complitexpr() + if p.tok == _Colon { + // key ':' value + l := new(KeyValueExpr) + l.pos = p.pos() + p.next() + l.Key = e + l.Value = p.bare_complitexpr() + e = l + x.NKeys++ + } + x.ElemList = append(x.ElemList, e) + return false + }) + p.xnest-- + + return x +} + +// ---------------------------------------------------------------------------- +// Types + +func (p *parser) type_() Expr { + if trace { + defer p.trace("type_")() + } + + typ := p.typeOrNil() + if typ == nil { + typ = p.badExpr() + p.syntaxError("expected type") + p.advance(_Comma, _Colon, _Semi, _Rparen, _Rbrack, _Rbrace) + } + + return typ +} + +func newIndirect(pos Pos, typ Expr) Expr { + o := new(Operation) + o.pos = pos + o.Op = Mul + o.X = typ + return o +} + +// typeOrNil is like type_ but it returns nil if there was no type +// instead of reporting an error. +// +// Type = TypeName | TypeLit | "(" Type ")" . +// TypeName = identifier | QualifiedIdent . +// TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType | +// SliceType | MapType | Channel_Type . +func (p *parser) typeOrNil() Expr { + if trace { + defer p.trace("typeOrNil")() + } + + pos := p.pos() + switch p.tok { + case _Star: + // ptrtype + p.next() + return newIndirect(pos, p.type_()) + + case _Arrow: + // recvchantype + p.next() + p.want(_Chan) + t := new(ChanType) + t.pos = pos + t.Dir = RecvOnly + t.Elem = p.chanElem() + return t + + case _Func: + // fntype + p.next() + _, t := p.funcType("function type") + return t + + case _Lbrack: + // '[' oexpr ']' ntype + // '[' _DotDotDot ']' ntype + p.next() + if p.got(_Rbrack) { + return p.sliceType(pos) + } + return p.arrayType(pos, nil) + + case _Chan: + // _Chan non_recvchantype + // _Chan _Comm ntype + p.next() + t := new(ChanType) + t.pos = pos + if p.got(_Arrow) { + t.Dir = SendOnly + } + t.Elem = p.chanElem() + return t + + case _Map: + // _Map '[' ntype ']' ntype + p.next() + p.want(_Lbrack) + t := new(MapType) + t.pos = pos + t.Key = p.type_() + p.want(_Rbrack) + t.Value = p.type_() + return t + + case _Struct: + return p.structType() + + case _Interface: + return p.interfaceType() + + case _Name: + return p.qualifiedName(nil) + + case _Lparen: + p.next() + t := p.type_() + p.want(_Rparen) + // The parser doesn't keep unnecessary parentheses. + // Set the flag below to keep them, for testing + // (see e.g. tests for go.dev/issue/68639). + const keep_parens = false + if keep_parens { + px := new(ParenExpr) + px.pos = pos + px.X = t + t = px + } + return t + } + + return nil +} + +func (p *parser) typeInstance(typ Expr) Expr { + if trace { + defer p.trace("typeInstance")() + } + + pos := p.pos() + p.want(_Lbrack) + x := new(IndexExpr) + x.pos = pos + x.X = typ + if p.tok == _Rbrack { + p.syntaxError("expected type argument list") + x.Index = p.badExpr() + } else { + x.Index, _ = p.typeList(true) + } + p.want(_Rbrack) + return x +} + +// If context != "", type parameters are not permitted. +func (p *parser) funcType(context string) ([]*Field, *FuncType) { + if trace { + defer p.trace("funcType")() + } + + typ := new(FuncType) + typ.pos = p.pos() + + var tparamList []*Field + if p.got(_Lbrack) { + if context != "" { + // accept but complain + p.syntaxErrorAt(typ.pos, context+" must have no type parameters") + } + if p.tok == _Rbrack { + p.syntaxError("empty type parameter list") + p.next() + } else { + tparamList = p.paramList(nil, nil, _Rbrack, true, false) + } + } + + p.want(_Lparen) + typ.ParamList = p.paramList(nil, nil, _Rparen, false, true) + typ.ResultList = p.funcResult() + + return tparamList, typ +} + +// "[" has already been consumed, and pos is its position. +// If len != nil it is the already consumed array length. +func (p *parser) arrayType(pos Pos, len Expr) Expr { + if trace { + defer p.trace("arrayType")() + } + + if len == nil && !p.got(_DotDotDot) { + p.xnest++ + len = p.expr() + p.xnest-- + } + if p.tok == _Comma { + // Trailing commas are accepted in type parameter + // lists but not in array type declarations. + // Accept for better error handling but complain. + p.syntaxError("unexpected comma; expected ]") + p.next() + } + p.want(_Rbrack) + t := new(ArrayType) + t.pos = pos + t.Len = len + t.Elem = p.type_() + return t +} + +// "[" and "]" have already been consumed, and pos is the position of "[". +func (p *parser) sliceType(pos Pos) Expr { + t := new(SliceType) + t.pos = pos + t.Elem = p.type_() + return t +} + +func (p *parser) chanElem() Expr { + if trace { + defer p.trace("chanElem")() + } + + typ := p.typeOrNil() + if typ == nil { + typ = p.badExpr() + p.syntaxError("missing channel element type") + // assume element type is simply absent - don't advance + } + + return typ +} + +// StructType = "struct" "{" { FieldDecl ";" } "}" . +func (p *parser) structType() *StructType { + if trace { + defer p.trace("structType")() + } + + typ := new(StructType) + typ.pos = p.pos() + + p.want(_Struct) + p.want(_Lbrace) + p.list("struct type", _Semi, _Rbrace, func() bool { + p.fieldDecl(typ) + return false + }) + + return typ +} + +// InterfaceType = "interface" "{" { ( MethodDecl | EmbeddedElem ) ";" } "}" . +func (p *parser) interfaceType() *InterfaceType { + if trace { + defer p.trace("interfaceType")() + } + + typ := new(InterfaceType) + typ.pos = p.pos() + + p.want(_Interface) + p.want(_Lbrace) + p.list("interface type", _Semi, _Rbrace, func() bool { + var f *Field + if p.tok == _Name { + f = p.methodDecl() + } + if f == nil || f.Name == nil { + f = p.embeddedElem(f) + } + typ.MethodList = append(typ.MethodList, f) + return false + }) + + return typ +} + +// Result = Parameters | Type . +func (p *parser) funcResult() []*Field { + if trace { + defer p.trace("funcResult")() + } + + if p.got(_Lparen) { + return p.paramList(nil, nil, _Rparen, false, false) + } + + pos := p.pos() + if typ := p.typeOrNil(); typ != nil { + f := new(Field) + f.pos = pos + f.Type = typ + return []*Field{f} + } + + return nil +} + +func (p *parser) addField(styp *StructType, pos Pos, name *Name, typ Expr, tag *BasicLit) { + if tag != nil { + for i := len(styp.FieldList) - len(styp.TagList); i > 0; i-- { + styp.TagList = append(styp.TagList, nil) + } + styp.TagList = append(styp.TagList, tag) + } + + f := new(Field) + f.pos = pos + f.Name = name + f.Type = typ + styp.FieldList = append(styp.FieldList, f) + + if debug && tag != nil && len(styp.FieldList) != len(styp.TagList) { + panic("inconsistent struct field list") + } +} + +// FieldDecl = (IdentifierList Type | AnonymousField) [ Tag ] . +// AnonymousField = [ "*" ] TypeName . +// Tag = string_lit . +func (p *parser) fieldDecl(styp *StructType) { + if trace { + defer p.trace("fieldDecl")() + } + + pos := p.pos() + switch p.tok { + case _Name: + name := p.name() + if p.tok == _Dot || p.tok == _Literal || p.tok == _Semi || p.tok == _Rbrace { + // embedded type + typ := p.qualifiedName(name) + tag := p.oliteral() + p.addField(styp, pos, nil, typ, tag) + break + } + + // name1, name2, ... Type [ tag ] + names := p.nameList(name) + var typ Expr + + // Careful dance: We don't know if we have an embedded instantiated + // type T[P1, P2, ...] or a field T of array/slice type [P]E or []E. + if len(names) == 1 && p.tok == _Lbrack { + typ = p.arrayOrTArgs() + if typ, ok := typ.(*IndexExpr); ok { + // embedded type T[P1, P2, ...] + typ.X = name // name == names[0] + tag := p.oliteral() + p.addField(styp, pos, nil, typ, tag) + break + } + } else { + // T P + typ = p.type_() + } + + tag := p.oliteral() + + for _, name := range names { + p.addField(styp, name.Pos(), name, typ, tag) + } + + case _Star: + p.next() + var typ Expr + if p.tok == _Lparen { + // *(T) + p.syntaxError("cannot parenthesize embedded type") + p.next() + typ = p.qualifiedName(nil) + p.got(_Rparen) // no need to complain if missing + } else { + // *T + typ = p.qualifiedName(nil) + } + tag := p.oliteral() + p.addField(styp, pos, nil, newIndirect(pos, typ), tag) + + case _Lparen: + p.syntaxError("cannot parenthesize embedded type") + p.next() + var typ Expr + if p.tok == _Star { + // (*T) + pos := p.pos() + p.next() + typ = newIndirect(pos, p.qualifiedName(nil)) + } else { + // (T) + typ = p.qualifiedName(nil) + } + p.got(_Rparen) // no need to complain if missing + tag := p.oliteral() + p.addField(styp, pos, nil, typ, tag) + + default: + p.syntaxError("expected field name or embedded type") + p.advance(_Semi, _Rbrace) + } +} + +func (p *parser) arrayOrTArgs() Expr { + if trace { + defer p.trace("arrayOrTArgs")() + } + + pos := p.pos() + p.want(_Lbrack) + if p.got(_Rbrack) { + return p.sliceType(pos) + } + + // x [n]E or x[n,], x[n1, n2], ... + n, comma := p.typeList(false) + p.want(_Rbrack) + if !comma { + if elem := p.typeOrNil(); elem != nil { + // x [n]E + t := new(ArrayType) + t.pos = pos + t.Len = n + t.Elem = elem + return t + } + } + + // x[n,], x[n1, n2], ... + t := new(IndexExpr) + t.pos = pos + // t.X will be filled in by caller + t.Index = n + return t +} + +func (p *parser) oliteral() *BasicLit { + if p.tok == _Literal { + b := new(BasicLit) + b.pos = p.pos() + b.Value = p.lit + b.Kind = p.kind + b.Bad = p.bad + p.next() + return b + } + return nil +} + +// MethodSpec = MethodName Signature | InterfaceTypeName . +// MethodName = identifier . +// InterfaceTypeName = TypeName . +func (p *parser) methodDecl() *Field { + if trace { + defer p.trace("methodDecl")() + } + + f := new(Field) + f.pos = p.pos() + name := p.name() + + const context = "interface method" + + switch p.tok { + case _Lparen: + // method + f.Name = name + _, f.Type = p.funcType(context) + + case _Lbrack: + // Careful dance: We don't know if we have a generic method m[T C](x T) + // or an embedded instantiated type T[P1, P2] (we accept generic methods + // for generality and robustness of parsing but complain with an error). + pos := p.pos() + p.next() + + // Empty type parameter or argument lists are not permitted. + // Treat as if [] were absent. + if p.tok == _Rbrack { + // name[] + pos := p.pos() + p.next() + if p.tok == _Lparen { + // name[]( + p.errorAt(pos, "empty type parameter list") + f.Name = name + _, f.Type = p.funcType(context) + } else { + p.errorAt(pos, "empty type argument list") + f.Type = name + } + break + } + + // A type argument list looks like a parameter list with only + // types. Parse a parameter list and decide afterwards. + list := p.paramList(nil, nil, _Rbrack, false, false) + if len(list) == 0 { + // The type parameter list is not [] but we got nothing + // due to other errors (reported by paramList). Treat + // as if [] were absent. + if p.tok == _Lparen { + f.Name = name + _, f.Type = p.funcType(context) + } else { + f.Type = name + } + break + } + + // len(list) > 0 + if list[0].Name != nil { + // generic method + f.Name = name + _, f.Type = p.funcType(context) + p.errorAt(pos, "interface method must have no type parameters") + break + } + + // embedded instantiated type + t := new(IndexExpr) + t.pos = pos + t.X = name + if len(list) == 1 { + t.Index = list[0].Type + } else { + // len(list) > 1 + l := new(ListExpr) + l.pos = list[0].Pos() + l.ElemList = make([]Expr, len(list)) + for i := range list { + l.ElemList[i] = list[i].Type + } + t.Index = l + } + f.Type = t + + default: + // embedded type + f.Type = p.qualifiedName(name) + } + + return f +} + +// EmbeddedElem = MethodSpec | EmbeddedTerm { "|" EmbeddedTerm } . +func (p *parser) embeddedElem(f *Field) *Field { + if trace { + defer p.trace("embeddedElem")() + } + + if f == nil { + f = new(Field) + f.pos = p.pos() + f.Type = p.embeddedTerm() + } + + for p.tok == _Operator && p.op == Or { + t := new(Operation) + t.pos = p.pos() + t.Op = Or + p.next() + t.X = f.Type + t.Y = p.embeddedTerm() + f.Type = t + } + + return f +} + +// EmbeddedTerm = [ "~" ] Type . +func (p *parser) embeddedTerm() Expr { + if trace { + defer p.trace("embeddedTerm")() + } + + if p.tok == _Operator && p.op == Tilde { + t := new(Operation) + t.pos = p.pos() + t.Op = Tilde + p.next() + t.X = p.type_() + return t + } + + t := p.typeOrNil() + if t == nil { + t = p.badExpr() + p.syntaxError("expected ~ term or type") + p.advance(_Operator, _Semi, _Rparen, _Rbrack, _Rbrace) + } + + return t +} + +// ParameterDecl = [ IdentifierList ] [ "..." ] Type . +func (p *parser) paramDeclOrNil(name *Name, follow token) *Field { + if trace { + defer p.trace("paramDeclOrNil")() + } + + // type set notation is ok in type parameter lists + typeSetsOk := follow == _Rbrack + + pos := p.pos() + if name != nil { + pos = name.pos + } else if typeSetsOk && p.tok == _Operator && p.op == Tilde { + // "~" ... + return p.embeddedElem(nil) + } + + f := new(Field) + f.pos = pos + + if p.tok == _Name || name != nil { + // name + if name == nil { + name = p.name() + } + + if p.tok == _Lbrack { + // name "[" ... + f.Type = p.arrayOrTArgs() + if typ, ok := f.Type.(*IndexExpr); ok { + // name "[" ... "]" + typ.X = name + } else { + // name "[" n "]" E + f.Name = name + } + if typeSetsOk && p.tok == _Operator && p.op == Or { + // name "[" ... "]" "|" ... + // name "[" n "]" E "|" ... + f = p.embeddedElem(f) + } + return f + } + + if p.tok == _Dot { + // name "." ... + f.Type = p.qualifiedName(name) + if typeSetsOk && p.tok == _Operator && p.op == Or { + // name "." name "|" ... + f = p.embeddedElem(f) + } + return f + } + + if typeSetsOk && p.tok == _Operator && p.op == Or { + // name "|" ... + f.Type = name + return p.embeddedElem(f) + } + + f.Name = name + } + + if p.tok == _DotDotDot { + // [name] "..." ... + t := new(DotsType) + t.pos = p.pos() + p.next() + t.Elem = p.typeOrNil() + if t.Elem == nil { + f.Type = p.badExpr() + p.syntaxError("... is missing type") + } else { + f.Type = t + } + return f + } + + if typeSetsOk && p.tok == _Operator && p.op == Tilde { + // [name] "~" ... + f.Type = p.embeddedElem(nil).Type + return f + } + + f.Type = p.typeOrNil() + if typeSetsOk && p.tok == _Operator && p.op == Or && f.Type != nil { + // [name] type "|" + f = p.embeddedElem(f) + } + if f.Name != nil || f.Type != nil { + return f + } + + p.syntaxError("expected " + tokstring(follow)) + p.advance(_Comma, follow) + return nil +} + +// Parameters = "(" [ ParameterList [ "," ] ] ")" . +// ParameterList = ParameterDecl { "," ParameterDecl } . +// "(" or "[" has already been consumed. +// If name != nil, it is the first name after "(" or "[". +// If typ != nil, name must be != nil, and (name, typ) is the first field in the list. +// In the result list, either all fields have a name, or no field has a name. +func (p *parser) paramList(name *Name, typ Expr, close token, requireNames, dddok bool) (list []*Field) { + if trace { + defer p.trace("paramList")() + } + + // p.list won't invoke its function argument if we're at the end of the + // parameter list. If we have a complete field, handle this case here. + if name != nil && typ != nil && p.tok == close { + p.next() + par := new(Field) + par.pos = name.pos + par.Name = name + par.Type = typ + return []*Field{par} + } + + var named int // number of parameters that have an explicit name and type + var typed int // number of parameters that have an explicit type + end := p.list("parameter list", _Comma, close, func() bool { + var par *Field + if typ != nil { + if debug && name == nil { + panic("initial type provided without name") + } + par = new(Field) + par.pos = name.pos + par.Name = name + par.Type = typ + } else { + par = p.paramDeclOrNil(name, close) + } + name = nil // 1st name was consumed if present + typ = nil // 1st type was consumed if present + if par != nil { + if debug && par.Name == nil && par.Type == nil { + panic("parameter without name or type") + } + if par.Name != nil && par.Type != nil { + named++ + } + if par.Type != nil { + typed++ + } + list = append(list, par) + } + return false + }) + + if len(list) == 0 { + return + } + + // distribute parameter types (len(list) > 0) + if named == 0 && !requireNames { + // all unnamed and we're not in a type parameter list => found names are named types + for _, par := range list { + if typ := par.Name; typ != nil { + par.Type = typ + par.Name = nil + } + } + } else if named != len(list) { + // some named or we're in a type parameter list => all must be named + var errPos Pos // left-most error position (or unknown) + var typ Expr // current type (from right to left) + for i := len(list) - 1; i >= 0; i-- { + par := list[i] + if par.Type != nil { + typ = par.Type + if par.Name == nil { + errPos = StartPos(typ) + par.Name = NewName(errPos, "_") + } + } else if typ != nil { + par.Type = typ + } else { + // par.Type == nil && typ == nil => we only have a par.Name + errPos = par.Name.Pos() + t := p.badExpr() + t.pos = errPos // correct position + par.Type = t + } + } + if errPos.IsKnown() { + // Not all parameters are named because named != len(list). + // If named == typed, there must be parameters that have no types. + // They must be at the end of the parameter list, otherwise types + // would have been filled in by the right-to-left sweep above and + // there would be no error. + // If requireNames is set, the parameter list is a type parameter + // list. + var msg string + if named == typed { + errPos = end // position error at closing token ) or ] + if requireNames { + msg = "missing type constraint" + } else { + msg = "missing parameter type" + } + } else { + if requireNames { + msg = "missing type parameter name" + // go.dev/issue/60812 + if len(list) == 1 { + msg += " or invalid array length" + } + } else { + msg = "missing parameter name" + } + } + p.syntaxErrorAt(errPos, msg) + } + } + + // check use of ... + first := true // only report first occurrence + for i, f := range list { + if t, _ := f.Type.(*DotsType); t != nil && (!dddok || i+1 < len(list)) { + if first { + first = false + if dddok { + p.errorAt(t.pos, "can only use ... with final parameter") + } else { + p.errorAt(t.pos, "invalid use of ...") + } + } + // use T instead of invalid ...T + f.Type = t.Elem + } + } + + return +} + +func (p *parser) badExpr() *BadExpr { + b := new(BadExpr) + b.pos = p.pos() + return b +} + +// ---------------------------------------------------------------------------- +// Statements + +// SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | ShortVarDecl . +func (p *parser) simpleStmt(lhs Expr, keyword token) SimpleStmt { + if trace { + defer p.trace("simpleStmt")() + } + + if keyword == _For && p.tok == _Range { + // _Range expr + if debug && lhs != nil { + panic("invalid call of simpleStmt") + } + return p.newRangeClause(nil, false) + } + + if lhs == nil { + lhs = p.exprList() + } + + if _, ok := lhs.(*ListExpr); !ok && p.tok != _Assign && p.tok != _Define { + // expr + pos := p.pos() + switch p.tok { + case _AssignOp: + // lhs op= rhs + op := p.op + p.next() + return p.newAssignStmt(pos, op, lhs, p.expr()) + + case _IncOp: + // lhs++ or lhs-- + op := p.op + p.next() + return p.newAssignStmt(pos, op, lhs, nil) + + case _Arrow: + // lhs <- rhs + s := new(SendStmt) + s.pos = pos + p.next() + s.Chan = lhs + s.Value = p.expr() + return s + + default: + // expr + s := new(ExprStmt) + s.pos = lhs.Pos() + s.X = lhs + return s + } + } + + // expr_list + switch p.tok { + case _Assign, _Define: + pos := p.pos() + var op Operator + if p.tok == _Define { + op = Def + } + p.next() + + if keyword == _For && p.tok == _Range { + // expr_list op= _Range expr + return p.newRangeClause(lhs, op == Def) + } + + // expr_list op= expr_list + rhs := p.exprList() + + if x, ok := rhs.(*TypeSwitchGuard); ok && keyword == _Switch && op == Def { + if lhs, ok := lhs.(*Name); ok { + // switch … lhs := rhs.(type) + x.Lhs = lhs + s := new(ExprStmt) + s.pos = x.Pos() + s.X = x + return s + } + } + + return p.newAssignStmt(pos, op, lhs, rhs) + + default: + p.syntaxError("expected := or = or comma") + p.advance(_Semi, _Rbrace) + // make the best of what we have + if x, ok := lhs.(*ListExpr); ok { + lhs = x.ElemList[0] + } + s := new(ExprStmt) + s.pos = lhs.Pos() + s.X = lhs + return s + } +} + +func (p *parser) newRangeClause(lhs Expr, def bool) *RangeClause { + r := new(RangeClause) + r.pos = p.pos() + p.next() // consume _Range + r.Lhs = lhs + r.Def = def + r.X = p.expr() + return r +} + +func (p *parser) newAssignStmt(pos Pos, op Operator, lhs, rhs Expr) *AssignStmt { + a := new(AssignStmt) + a.pos = pos + a.Op = op + a.Lhs = lhs + a.Rhs = rhs + return a +} + +func (p *parser) labeledStmtOrNil(label *Name) Stmt { + if trace { + defer p.trace("labeledStmt")() + } + + s := new(LabeledStmt) + s.pos = p.pos() + s.Label = label + + p.want(_Colon) + + if p.tok == _Rbrace { + // We expect a statement (incl. an empty statement), which must be + // terminated by a semicolon. Because semicolons may be omitted before + // an _Rbrace, seeing an _Rbrace implies an empty statement. + e := new(EmptyStmt) + e.pos = p.pos() + s.Stmt = e + return s + } + + s.Stmt = p.stmtOrNil() + if s.Stmt != nil { + return s + } + + // report error at line of ':' token + p.syntaxErrorAt(s.pos, "missing statement after label") + // we are already at the end of the labeled statement - no need to advance + return nil // avoids follow-on errors (see e.g., fixedbugs/bug274.go) +} + +// context must be a non-empty string unless we know that p.tok == _Lbrace. +func (p *parser) blockStmt(context string) *BlockStmt { + if trace { + defer p.trace("blockStmt")() + } + + s := new(BlockStmt) + s.pos = p.pos() + + // people coming from C may forget that braces are mandatory in Go + if !p.got(_Lbrace) { + p.syntaxError("expected { after " + context) + p.advance(_Name, _Rbrace) + s.Rbrace = p.pos() // in case we found "}" + if p.got(_Rbrace) { + return s + } + } + + s.List = p.stmtList() + s.Rbrace = p.pos() + p.want(_Rbrace) + + return s +} + +func (p *parser) declStmt(f func(*Group) Decl) *DeclStmt { + if trace { + defer p.trace("declStmt")() + } + + s := new(DeclStmt) + s.pos = p.pos() + + p.next() // _Const, _Type, or _Var + s.DeclList = p.appendGroup(nil, f) + + return s +} + +func (p *parser) forStmt() Stmt { + if trace { + defer p.trace("forStmt")() + } + + s := new(ForStmt) + s.pos = p.pos() + + s.Init, s.Cond, s.Post = p.header(_For) + s.Body = p.blockStmt("for clause") + + return s +} + +func (p *parser) header(keyword token) (init SimpleStmt, cond Expr, post SimpleStmt) { + p.want(keyword) + + if p.tok == _Lbrace { + if keyword == _If { + p.syntaxError("missing condition in if statement") + cond = p.badExpr() + } + return + } + // p.tok != _Lbrace + + outer := p.xnest + p.xnest = -1 + + if p.tok != _Semi { + // accept potential varDecl but complain + if p.got(_Var) { + p.syntaxError(fmt.Sprintf("var declaration not allowed in %s initializer", keyword.String())) + } + init = p.simpleStmt(nil, keyword) + // If we have a range clause, we are done (can only happen for keyword == _For). + if _, ok := init.(*RangeClause); ok { + p.xnest = outer + return + } + } + + var condStmt SimpleStmt + var semi struct { + pos Pos + lit string // valid if pos.IsKnown() + } + if p.tok != _Lbrace { + if p.tok == _Semi { + semi.pos = p.pos() + semi.lit = p.lit + p.next() + } else { + // asking for a '{' rather than a ';' here leads to a better error message + p.want(_Lbrace) + if p.tok != _Lbrace { + p.advance(_Lbrace, _Rbrace) // for better synchronization (e.g., go.dev/issue/22581) + } + } + if keyword == _For { + if p.tok != _Semi { + if p.tok == _Lbrace { + p.syntaxError("expected for loop condition") + goto done + } + condStmt = p.simpleStmt(nil, 0 /* range not permitted */) + } + p.want(_Semi) + if p.tok != _Lbrace { + post = p.simpleStmt(nil, 0 /* range not permitted */) + if a, _ := post.(*AssignStmt); a != nil && a.Op == Def { + p.syntaxErrorAt(a.Pos(), "cannot declare in post statement of for loop") + } + } + } else if p.tok != _Lbrace { + condStmt = p.simpleStmt(nil, keyword) + } + } else { + condStmt = init + init = nil + } + +done: + // unpack condStmt + switch s := condStmt.(type) { + case nil: + if keyword == _If && semi.pos.IsKnown() { + if semi.lit != "semicolon" { + p.syntaxErrorAt(semi.pos, fmt.Sprintf("unexpected %s, expected { after if clause", semi.lit)) + } else { + p.syntaxErrorAt(semi.pos, "missing condition in if statement") + } + b := new(BadExpr) + b.pos = semi.pos + cond = b + } + case *ExprStmt: + cond = s.X + default: + // A common syntax error is to write '=' instead of '==', + // which turns an expression into an assignment. Provide + // a more explicit error message in that case to prevent + // further confusion. + var str string + if as, ok := s.(*AssignStmt); ok && as.Op == 0 { + // Emphasize complex Lhs and Rhs of assignment with parentheses to highlight '='. + str = "assignment " + emphasize(as.Lhs) + " = " + emphasize(as.Rhs) + } else { + str = String(s) + } + p.syntaxErrorAt(s.Pos(), fmt.Sprintf("cannot use %s as value", str)) + } + + p.xnest = outer + return +} + +// emphasize returns a string representation of x, with (top-level) +// binary expressions emphasized by enclosing them in parentheses. +func emphasize(x Expr) string { + s := String(x) + if op, _ := x.(*Operation); op != nil && op.Y != nil { + // binary expression + return "(" + s + ")" + } + return s +} + +func (p *parser) ifStmt() *IfStmt { + if trace { + defer p.trace("ifStmt")() + } + + s := new(IfStmt) + s.pos = p.pos() + + s.Init, s.Cond, _ = p.header(_If) + s.Then = p.blockStmt("if clause") + + if p.got(_Else) { + switch p.tok { + case _If: + s.Else = p.ifStmt() + case _Lbrace: + s.Else = p.blockStmt("") + default: + p.syntaxError("else must be followed by if or statement block") + p.advance(_Name, _Rbrace) + } + } + + return s +} + +func (p *parser) switchStmt() *SwitchStmt { + if trace { + defer p.trace("switchStmt")() + } + + s := new(SwitchStmt) + s.pos = p.pos() + + s.Init, s.Tag, _ = p.header(_Switch) + + if !p.got(_Lbrace) { + p.syntaxError("missing { after switch clause") + p.advance(_Case, _Default, _Rbrace) + } + for p.tok != _EOF && p.tok != _Rbrace { + s.Body = append(s.Body, p.caseClause()) + } + s.Rbrace = p.pos() + p.want(_Rbrace) + + return s +} + +func (p *parser) selectStmt() *SelectStmt { + if trace { + defer p.trace("selectStmt")() + } + + s := new(SelectStmt) + s.pos = p.pos() + + p.want(_Select) + if !p.got(_Lbrace) { + p.syntaxError("missing { after select clause") + p.advance(_Case, _Default, _Rbrace) + } + for p.tok != _EOF && p.tok != _Rbrace { + s.Body = append(s.Body, p.commClause()) + } + s.Rbrace = p.pos() + p.want(_Rbrace) + + return s +} + +func (p *parser) caseClause() *CaseClause { + if trace { + defer p.trace("caseClause")() + } + + c := new(CaseClause) + c.pos = p.pos() + + switch p.tok { + case _Case: + p.next() + c.Cases = p.exprList() + + case _Default: + p.next() + + default: + p.syntaxError("expected case or default or }") + p.advance(_Colon, _Case, _Default, _Rbrace) + } + + c.Colon = p.pos() + p.want(_Colon) + c.Body = p.stmtList() + + return c +} + +func (p *parser) commClause() *CommClause { + if trace { + defer p.trace("commClause")() + } + + c := new(CommClause) + c.pos = p.pos() + + switch p.tok { + case _Case: + p.next() + c.Comm = p.simpleStmt(nil, 0) + + // The syntax restricts the possible simple statements here to: + // + // lhs <- x (send statement) + // <-x + // lhs = <-x + // lhs := <-x + // + // All these (and more) are recognized by simpleStmt and invalid + // syntax trees are flagged later, during type checking. + + case _Default: + p.next() + + default: + p.syntaxError("expected case or default or }") + p.advance(_Colon, _Case, _Default, _Rbrace) + } + + c.Colon = p.pos() + p.want(_Colon) + c.Body = p.stmtList() + + return c +} + +// stmtOrNil parses a statement if one is present, or else returns nil. +// +// Statement = +// Declaration | LabeledStmt | SimpleStmt | +// GoStmt | ReturnStmt | BreakStmt | ContinueStmt | GotoStmt | +// FallthroughStmt | Block | IfStmt | SwitchStmt | SelectStmt | ForStmt | +// DeferStmt . +func (p *parser) stmtOrNil() Stmt { + if trace { + defer p.trace("stmt " + p.tok.String())() + } + + // Most statements (assignments) start with an identifier; + // look for it first before doing anything more expensive. + if p.tok == _Name { + p.clearPragma() + lhs := p.exprList() + if label, ok := lhs.(*Name); ok && p.tok == _Colon { + return p.labeledStmtOrNil(label) + } + return p.simpleStmt(lhs, 0) + } + + switch p.tok { + case _Var: + return p.declStmt(p.varDecl) + + case _Const: + return p.declStmt(p.constDecl) + + case _Type: + return p.declStmt(p.typeDecl) + } + + p.clearPragma() + + switch p.tok { + case _Lbrace: + return p.blockStmt("") + + case _Operator, _Star: + switch p.op { + case Add, Sub, Mul, And, Xor, Not: + return p.simpleStmt(nil, 0) // unary operators + } + + case _Literal, _Func, _Lparen, // operands + _Lbrack, _Struct, _Map, _Chan, _Interface, // composite types + _Arrow: // receive operator + return p.simpleStmt(nil, 0) + + case _For: + return p.forStmt() + + case _Switch: + return p.switchStmt() + + case _Select: + return p.selectStmt() + + case _If: + return p.ifStmt() + + case _Fallthrough: + s := new(BranchStmt) + s.pos = p.pos() + p.next() + s.Tok = _Fallthrough + return s + + case _Break, _Continue: + s := new(BranchStmt) + s.pos = p.pos() + s.Tok = p.tok + p.next() + if p.tok == _Name { + s.Label = p.name() + } + return s + + case _Go, _Defer: + return p.callStmt() + + case _Goto: + s := new(BranchStmt) + s.pos = p.pos() + s.Tok = _Goto + p.next() + s.Label = p.name() + return s + + case _Return: + s := new(ReturnStmt) + s.pos = p.pos() + p.next() + if p.tok != _Semi && p.tok != _Rbrace { + s.Results = p.exprList() + } + return s + + case _Semi: + s := new(EmptyStmt) + s.pos = p.pos() + return s + } + + return nil +} + +// StatementList = { Statement ";" } . +func (p *parser) stmtList() (l []Stmt) { + if trace { + defer p.trace("stmtList")() + } + + for p.tok != _EOF && p.tok != _Rbrace && p.tok != _Case && p.tok != _Default { + s := p.stmtOrNil() + p.clearPragma() + if s == nil { + break + } + l = append(l, s) + // ";" is optional before "}" + if !p.got(_Semi) && p.tok != _Rbrace { + p.syntaxError("at end of statement") + p.advance(_Semi, _Rbrace, _Case, _Default) + p.got(_Semi) // avoid spurious empty statement + } + } + return +} + +// argList parses a possibly empty, comma-separated list of arguments, +// optionally followed by a comma (if not empty), and closed by ")". +// The last argument may be followed by "...". +// +// argList = [ arg { "," arg } [ "..." ] [ "," ] ] ")" . +func (p *parser) argList() (list []Expr, hasDots bool) { + if trace { + defer p.trace("argList")() + } + + p.xnest++ + p.list("argument list", _Comma, _Rparen, func() bool { + list = append(list, p.expr()) + hasDots = p.got(_DotDotDot) + return hasDots + }) + p.xnest-- + + return +} + +// ---------------------------------------------------------------------------- +// Common productions + +func (p *parser) name() *Name { + // no tracing to avoid overly verbose output + + if p.tok == _Name { + n := NewName(p.pos(), p.lit) + p.next() + return n + } + + n := NewName(p.pos(), "_") + p.syntaxError("expected name") + p.advance() + return n +} + +// IdentifierList = identifier { "," identifier } . +// The first name must be provided. +func (p *parser) nameList(first *Name) []*Name { + if trace { + defer p.trace("nameList")() + } + + if debug && first == nil { + panic("first name not provided") + } + + l := []*Name{first} + for p.got(_Comma) { + l = append(l, p.name()) + } + + return l +} + +// The first name may be provided, or nil. +func (p *parser) qualifiedName(name *Name) Expr { + if trace { + defer p.trace("qualifiedName")() + } + + var x Expr + switch { + case name != nil: + x = name + case p.tok == _Name: + x = p.name() + default: + x = NewName(p.pos(), "_") + p.syntaxError("expected name") + p.advance(_Dot, _Semi, _Rbrace) + } + + if p.tok == _Dot { + s := new(SelectorExpr) + s.pos = p.pos() + p.next() + s.X = x + s.Sel = p.name() + x = s + } + + if p.tok == _Lbrack { + x = p.typeInstance(x) + } + + return x +} + +// ExpressionList = Expression { "," Expression } . +func (p *parser) exprList() Expr { + if trace { + defer p.trace("exprList")() + } + + x := p.expr() + if p.got(_Comma) { + list := []Expr{x, p.expr()} + for p.got(_Comma) { + list = append(list, p.expr()) + } + t := new(ListExpr) + t.pos = x.Pos() + t.ElemList = list + x = t + } + return x +} + +// typeList parses a non-empty, comma-separated list of types, +// optionally followed by a comma. If strict is set to false, +// the first element may also be a (non-type) expression. +// If there is more than one argument, the result is a *ListExpr. +// The comma result indicates whether there was a (separating or +// trailing) comma. +// +// typeList = arg { "," arg } [ "," ] . +func (p *parser) typeList(strict bool) (x Expr, comma bool) { + if trace { + defer p.trace("typeList")() + } + + p.xnest++ + if strict { + x = p.type_() + } else { + x = p.expr() + } + if p.got(_Comma) { + comma = true + if t := p.typeOrNil(); t != nil { + list := []Expr{x, t} + for p.got(_Comma) { + if t = p.typeOrNil(); t == nil { + break + } + list = append(list, t) + } + l := new(ListExpr) + l.pos = x.Pos() // == list[0].Pos() + l.ElemList = list + x = l + } + } + p.xnest-- + return +} + +// Unparen returns e with any enclosing parentheses stripped. +func Unparen(x Expr) Expr { + for { + p, ok := x.(*ParenExpr) + if !ok { + break + } + x = p.X + } + return x +} + +// UnpackListExpr unpacks a *ListExpr into a []Expr. +func UnpackListExpr(x Expr) []Expr { + switch x := x.(type) { + case nil: + return nil + case *ListExpr: + return x.ElemList + default: + return []Expr{x} + } +} diff --git a/go/src/cmd/compile/internal/syntax/parser_test.go b/go/src/cmd/compile/internal/syntax/parser_test.go new file mode 100644 index 0000000000000000000000000000000000000000..b6c4b8fd5693d165f882f091177fadb26ac24e0c --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/parser_test.go @@ -0,0 +1,395 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import ( + "bytes" + "flag" + "fmt" + "internal/testenv" + "os" + "path/filepath" + "regexp" + "runtime" + "strings" + "sync" + "testing" + "time" +) + +var ( + fast = flag.Bool("fast", false, "parse package files in parallel") + verify = flag.Bool("verify", false, "verify idempotent printing") + src_ = flag.String("src", "parser.go", "source file to parse") + skip = flag.String("skip", "", "files matching this regular expression are skipped by TestStdLib") +) + +func TestParse(t *testing.T) { + ParseFile(*src_, func(err error) { t.Error(err) }, nil, 0) +} + +func TestVerify(t *testing.T) { + ast, err := ParseFile(*src_, func(err error) { t.Error(err) }, nil, 0) + if err != nil { + return // error already reported + } + verifyPrint(t, *src_, ast) +} + +func TestStdLib(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + + var skipRx *regexp.Regexp + if *skip != "" { + var err error + skipRx, err = regexp.Compile(*skip) + if err != nil { + t.Fatalf("invalid argument for -skip (%v)", err) + } + } + + var m1 runtime.MemStats + runtime.ReadMemStats(&m1) + start := time.Now() + + type parseResult struct { + filename string + lines uint + } + + goroot := testenv.GOROOT(t) + + results := make(chan parseResult) + go func() { + defer close(results) + for _, dir := range []string{ + filepath.Join(goroot, "src"), + filepath.Join(goroot, "misc"), + } { + if filepath.Base(dir) == "misc" { + // cmd/distpack deletes GOROOT/misc, so skip that directory if it isn't present. + // cmd/distpack also requires GOROOT/VERSION to exist, so use that to + // suppress false-positive skips. + if _, err := os.Stat(dir); os.IsNotExist(err) { + if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "VERSION")); err == nil { + fmt.Printf("%s not present; skipping\n", dir) + continue + } + } + } + + walkDirs(t, dir, func(filename string) { + if skipRx != nil && skipRx.MatchString(filename) { + // Always report skipped files since regexp + // typos can lead to surprising results. + fmt.Printf("skipping %s\n", filename) + return + } + if debug { + fmt.Printf("parsing %s\n", filename) + } + ast, err := ParseFile(filename, nil, nil, 0) + if err != nil { + t.Error(err) + return + } + if *verify { + verifyPrint(t, filename, ast) + } + results <- parseResult{filename, ast.EOF.Line()} + }) + } + }() + + var count, lines uint + for res := range results { + count++ + lines += res.lines + if testing.Verbose() { + fmt.Printf("%5d %s (%d lines)\n", count, res.filename, res.lines) + } + } + + dt := time.Since(start) + var m2 runtime.MemStats + runtime.ReadMemStats(&m2) + dm := float64(m2.TotalAlloc-m1.TotalAlloc) / 1e6 + + fmt.Printf("parsed %d lines (%d files) in %v (%d lines/s)\n", lines, count, dt, int64(float64(lines)/dt.Seconds())) + fmt.Printf("allocated %.3fMb (%.3fMb/s)\n", dm, dm/dt.Seconds()) +} + +func walkDirs(t *testing.T, dir string, action func(string)) { + entries, err := os.ReadDir(dir) + if err != nil { + t.Error(err) + return + } + + var files, dirs []string + for _, entry := range entries { + if entry.Type().IsRegular() { + if strings.HasSuffix(entry.Name(), ".go") { + path := filepath.Join(dir, entry.Name()) + files = append(files, path) + } + } else if entry.IsDir() && entry.Name() != "testdata" { + path := filepath.Join(dir, entry.Name()) + if !strings.HasSuffix(path, string(filepath.Separator)+"test") { + dirs = append(dirs, path) + } + } + } + + if *fast { + var wg sync.WaitGroup + wg.Add(len(files)) + for _, filename := range files { + go func(filename string) { + defer wg.Done() + action(filename) + }(filename) + } + wg.Wait() + } else { + for _, filename := range files { + action(filename) + } + } + + for _, dir := range dirs { + walkDirs(t, dir, action) + } +} + +func verifyPrint(t *testing.T, filename string, ast1 *File) { + var buf1 bytes.Buffer + _, err := Fprint(&buf1, ast1, LineForm) + if err != nil { + panic(err) + } + bytes1 := buf1.Bytes() + + ast2, err := Parse(NewFileBase(filename), &buf1, nil, nil, 0) + if err != nil { + panic(err) + } + + var buf2 bytes.Buffer + _, err = Fprint(&buf2, ast2, LineForm) + if err != nil { + panic(err) + } + bytes2 := buf2.Bytes() + + if !bytes.Equal(bytes1, bytes2) { + fmt.Printf("--- %s ---\n", filename) + fmt.Printf("%s\n", bytes1) + fmt.Println() + + fmt.Printf("--- %s ---\n", filename) + fmt.Printf("%s\n", bytes2) + fmt.Println() + + t.Error("printed syntax trees do not match") + } +} + +func TestIssue17697(t *testing.T) { + _, err := Parse(nil, bytes.NewReader(nil), nil, nil, 0) // return with parser error, don't panic + if err == nil { + t.Errorf("no error reported") + } +} + +func TestParseFile(t *testing.T) { + _, err := ParseFile("", nil, nil, 0) + if err == nil { + t.Error("missing io error") + } + + var first error + _, err = ParseFile("", func(err error) { + if first == nil { + first = err + } + }, nil, 0) + if err == nil || first == nil { + t.Error("missing io error") + } + if err != first { + t.Errorf("got %v; want first error %v", err, first) + } +} + +// Make sure (PosMax + 1) doesn't overflow when converted to default +// type int (when passed as argument to fmt.Sprintf) on 32bit platforms +// (see test cases below). +var tooLarge int = PosMax + 1 + +func TestLineDirectives(t *testing.T) { + // valid line directives lead to a syntax error after them + const valid = "syntax error: package statement must be first" + const filename = "directives.go" + + for _, test := range []struct { + src, msg string + filename string + line, col uint // 1-based; 0 means unknown + }{ + // ignored //line directives + {"//\n", valid, filename, 2, 1}, // no directive + {"//line\n", valid, filename, 2, 1}, // missing colon + {"//line foo\n", valid, filename, 2, 1}, // missing colon + {" //line foo:\n", valid, filename, 2, 1}, // not a line start + {"// line foo:\n", valid, filename, 2, 1}, // space between // and line + + // invalid //line directives with one colon + {"//line :\n", "invalid line number: ", filename, 1, 9}, + {"//line :x\n", "invalid line number: x", filename, 1, 9}, + {"//line foo :\n", "invalid line number: ", filename, 1, 13}, + {"//line foo:x\n", "invalid line number: x", filename, 1, 12}, + {"//line foo:0\n", "invalid line number: 0", filename, 1, 12}, + {"//line foo:1 \n", "invalid line number: 1 ", filename, 1, 12}, + {"//line foo:-12\n", "invalid line number: -12", filename, 1, 12}, + {"//line C:foo:0\n", "invalid line number: 0", filename, 1, 14}, + {fmt.Sprintf("//line foo:%d\n", tooLarge), fmt.Sprintf("invalid line number: %d", tooLarge), filename, 1, 12}, + + // invalid //line directives with two colons + {"//line ::\n", "invalid line number: ", filename, 1, 10}, + {"//line ::x\n", "invalid line number: x", filename, 1, 10}, + {"//line foo::123abc\n", "invalid line number: 123abc", filename, 1, 13}, + {"//line foo::0\n", "invalid line number: 0", filename, 1, 13}, + {"//line foo:0:1\n", "invalid line number: 0", filename, 1, 12}, + + {"//line :123:0\n", "invalid column number: 0", filename, 1, 13}, + {"//line foo:123:0\n", "invalid column number: 0", filename, 1, 16}, + {fmt.Sprintf("//line foo:10:%d\n", tooLarge), fmt.Sprintf("invalid column number: %d", tooLarge), filename, 1, 15}, + + // effect of valid //line directives on lines + {"//line foo:123\n foo", valid, "foo", 123, 0}, + {"//line foo:123\n foo", valid, " foo", 123, 0}, + {"//line foo:123\n//line bar:345\nfoo", valid, "bar", 345, 0}, + {"//line C:foo:123\n", valid, "C:foo", 123, 0}, + {"//line /src/a/a.go:123\n foo", valid, "/src/a/a.go", 123, 0}, + {"//line :x:1\n", valid, ":x", 1, 0}, + {"//line foo ::1\n", valid, "foo :", 1, 0}, + {"//line foo:123abc:1\n", valid, "foo:123abc", 1, 0}, + {"//line foo :123:1\n", valid, "foo ", 123, 1}, + {"//line ::123\n", valid, ":", 123, 0}, + + // effect of valid //line directives on columns + {"//line :x:1:10\n", valid, ":x", 1, 10}, + {"//line foo ::1:2\n", valid, "foo :", 1, 2}, + {"//line foo:123abc:1:1000\n", valid, "foo:123abc", 1, 1000}, + {"//line foo :123:1000\n\n", valid, "foo ", 124, 1}, + {"//line ::123:1234\n", valid, ":", 123, 1234}, + + // //line directives with omitted filenames lead to empty filenames + {"//line :10\n", valid, "", 10, 0}, + {"//line :10:20\n", valid, filename, 10, 20}, + {"//line bar:1\n//line :10\n", valid, "", 10, 0}, + {"//line bar:1\n//line :10:20\n", valid, "bar", 10, 20}, + + // ignored /*line directives + {"/**/", valid, filename, 1, 5}, // no directive + {"/*line*/", valid, filename, 1, 9}, // missing colon + {"/*line foo*/", valid, filename, 1, 13}, // missing colon + {" //line foo:*/", valid, filename, 1, 16}, // not a line start + {"/* line foo:*/", valid, filename, 1, 16}, // space between // and line + + // invalid /*line directives with one colon + {"/*line :*/", "invalid line number: ", filename, 1, 9}, + {"/*line :x*/", "invalid line number: x", filename, 1, 9}, + {"/*line foo :*/", "invalid line number: ", filename, 1, 13}, + {"/*line foo:x*/", "invalid line number: x", filename, 1, 12}, + {"/*line foo:0*/", "invalid line number: 0", filename, 1, 12}, + {"/*line foo:1 */", "invalid line number: 1 ", filename, 1, 12}, + {"/*line C:foo:0*/", "invalid line number: 0", filename, 1, 14}, + {fmt.Sprintf("/*line foo:%d*/", tooLarge), fmt.Sprintf("invalid line number: %d", tooLarge), filename, 1, 12}, + + // invalid /*line directives with two colons + {"/*line ::*/", "invalid line number: ", filename, 1, 10}, + {"/*line ::x*/", "invalid line number: x", filename, 1, 10}, + {"/*line foo::123abc*/", "invalid line number: 123abc", filename, 1, 13}, + {"/*line foo::0*/", "invalid line number: 0", filename, 1, 13}, + {"/*line foo:0:1*/", "invalid line number: 0", filename, 1, 12}, + + {"/*line :123:0*/", "invalid column number: 0", filename, 1, 13}, + {"/*line foo:123:0*/", "invalid column number: 0", filename, 1, 16}, + {fmt.Sprintf("/*line foo:10:%d*/", tooLarge), fmt.Sprintf("invalid column number: %d", tooLarge), filename, 1, 15}, + + // effect of valid /*line directives on lines + {"/*line foo:123*/ foo", valid, "foo", 123, 0}, + {"/*line foo:123*/\n//line bar:345\nfoo", valid, "bar", 345, 0}, + {"/*line C:foo:123*/", valid, "C:foo", 123, 0}, + {"/*line /src/a/a.go:123*/ foo", valid, "/src/a/a.go", 123, 0}, + {"/*line :x:1*/", valid, ":x", 1, 0}, + {"/*line foo ::1*/", valid, "foo :", 1, 0}, + {"/*line foo:123abc:1*/", valid, "foo:123abc", 1, 0}, + {"/*line foo :123:10*/", valid, "foo ", 123, 10}, + {"/*line ::123*/", valid, ":", 123, 0}, + + // effect of valid /*line directives on columns + {"/*line :x:1:10*/", valid, ":x", 1, 10}, + {"/*line foo ::1:2*/", valid, "foo :", 1, 2}, + {"/*line foo:123abc:1:1000*/", valid, "foo:123abc", 1, 1000}, + {"/*line foo :123:1000*/\n", valid, "foo ", 124, 1}, + {"/*line ::123:1234*/", valid, ":", 123, 1234}, + + // /*line directives with omitted filenames lead to the previously used filenames + {"/*line :10*/", valid, "", 10, 0}, + {"/*line :10:20*/", valid, filename, 10, 20}, + {"//line bar:1\n/*line :10*/", valid, "", 10, 0}, + {"//line bar:1\n/*line :10:20*/", valid, "bar", 10, 20}, + } { + base := NewFileBase(filename) + _, err := Parse(base, strings.NewReader(test.src), nil, nil, 0) + if err == nil { + t.Errorf("%s: no error reported", test.src) + continue + } + perr, ok := err.(Error) + if !ok { + t.Errorf("%s: got %v; want parser error", test.src, err) + continue + } + if msg := perr.Msg; msg != test.msg { + t.Errorf("%s: got msg = %q; want %q", test.src, msg, test.msg) + } + + pos := perr.Pos + if filename := pos.RelFilename(); filename != test.filename { + t.Errorf("%s: got filename = %q; want %q", test.src, filename, test.filename) + } + if line := pos.RelLine(); line != test.line { + t.Errorf("%s: got line = %d; want %d", test.src, line, test.line) + } + if col := pos.RelCol(); col != test.col { + t.Errorf("%s: got col = %d; want %d", test.src, col, test.col) + } + } +} + +// Test that typical uses of UnpackListExpr don't allocate. +func TestUnpackListExprAllocs(t *testing.T) { + var x Expr = NewName(Pos{}, "x") + allocs := testing.AllocsPerRun(1000, func() { + list := UnpackListExpr(x) + if len(list) != 1 || list[0] != x { + t.Fatalf("unexpected result") + } + }) + + if allocs > 0 { + errorf := t.Errorf + if testenv.OptimizationOff() { + errorf = t.Logf // noopt builder disables inlining + } + errorf("UnpackListExpr allocated %v times", allocs) + } +} diff --git a/go/src/cmd/compile/internal/syntax/pos.go b/go/src/cmd/compile/internal/syntax/pos.go new file mode 100644 index 0000000000000000000000000000000000000000..5ea9f5304ab6124d8c4d4e2d678a296c50f3a704 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/pos.go @@ -0,0 +1,223 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import "fmt" + +// PosMax is the largest line or column value that can be represented without loss. +// Incoming values (arguments) larger than PosMax will be set to PosMax. +// +// Keep this consistent with maxLineCol in go/scanner. +const PosMax = 1 << 30 + +// A Pos represents an absolute (line, col) source position +// with a reference to position base for computing relative +// (to a file, or line directive) position information. +// Pos values are intentionally light-weight so that they +// can be created without too much concern about space use. +type Pos struct { + base *PosBase + line, col uint32 +} + +// MakePos returns a new Pos for the given PosBase, line and column. +func MakePos(base *PosBase, line, col uint) Pos { return Pos{base, sat32(line), sat32(col)} } + +// TODO(gri) IsKnown makes an assumption about linebase < 1. +// Maybe we should check for Base() != nil instead. + +func (pos Pos) Pos() Pos { return pos } +func (pos Pos) IsKnown() bool { return pos.line > 0 } +func (pos Pos) Base() *PosBase { return pos.base } +func (pos Pos) Line() uint { return uint(pos.line) } +func (pos Pos) Col() uint { return uint(pos.col) } + +// FileBase returns the PosBase of the file containing pos, +// skipping over intermediate PosBases from //line directives. +// The result is nil if pos doesn't have a file base. +func (pos Pos) FileBase() *PosBase { + b := pos.base + for b != nil && b != b.pos.base { + b = b.pos.base + } + // b == nil || b == b.pos.base + return b +} + +func (pos Pos) RelFilename() string { return pos.base.Filename() } + +func (pos Pos) RelLine() uint { + b := pos.base + if b.Line() == 0 { + // base line is unknown => relative line is unknown + return 0 + } + return b.Line() + (pos.Line() - b.Pos().Line()) +} + +func (pos Pos) RelCol() uint { + b := pos.base + if b.Col() == 0 { + // base column is unknown => relative column is unknown + // (the current specification for line directives requires + // this to apply until the next PosBase/line directive, + // not just until the new newline) + return 0 + } + if pos.Line() == b.Pos().Line() { + // pos on same line as pos base => column is relative to pos base + return b.Col() + (pos.Col() - b.Pos().Col()) + } + return pos.Col() +} + +// Cmp compares the positions p and q and returns a result r as follows: +// +// r < 0: p is before q +// r == 0: p and q are the same position (but may not be identical) +// r > 0: p is after q +// +// If p and q are in different files, p is before q if the filename +// of p sorts lexicographically before the filename of q. +func (p Pos) Cmp(q Pos) int { + pname := p.RelFilename() + qname := q.RelFilename() + switch { + case pname < qname: + return -1 + case pname > qname: + return +1 + } + + pline := p.Line() + qline := q.Line() + switch { + case pline < qline: + return -1 + case pline > qline: + return +1 + } + + pcol := p.Col() + qcol := q.Col() + switch { + case pcol < qcol: + return -1 + case pcol > qcol: + return +1 + } + + return 0 +} + +func (pos Pos) String() string { + rel := position_{pos.RelFilename(), pos.RelLine(), pos.RelCol()} + abs := position_{pos.Base().Pos().RelFilename(), pos.Line(), pos.Col()} + s := rel.String() + if rel != abs { + s += "[" + abs.String() + "]" + } + return s +} + +// TODO(gri) cleanup: find better name, avoid conflict with position in error_test.go +type position_ struct { + filename string + line, col uint +} + +func (p position_) String() string { + if p.line == 0 { + if p.filename == "" { + return "" + } + return p.filename + } + if p.col == 0 { + return fmt.Sprintf("%s:%d", p.filename, p.line) + } + return fmt.Sprintf("%s:%d:%d", p.filename, p.line, p.col) +} + +// A PosBase represents the base for relative position information: +// At position pos, the relative position is filename:line:col. +type PosBase struct { + pos Pos + filename string + line, col uint32 + trimmed bool // whether -trimpath has been applied +} + +// NewFileBase returns a new PosBase for the given filename. +// A file PosBase's position is relative to itself, with the +// position being filename:1:1. +func NewFileBase(filename string) *PosBase { + return NewTrimmedFileBase(filename, false) +} + +// NewTrimmedFileBase is like NewFileBase, but allows specifying Trimmed. +func NewTrimmedFileBase(filename string, trimmed bool) *PosBase { + base := &PosBase{MakePos(nil, linebase, colbase), filename, linebase, colbase, trimmed} + base.pos.base = base + return base +} + +// NewLineBase returns a new PosBase for a line directive "line filename:line:col" +// relative to pos, which is the position of the character immediately following +// the comment containing the line directive. For a directive in a line comment, +// that position is the beginning of the next line (i.e., the newline character +// belongs to the line comment). +func NewLineBase(pos Pos, filename string, trimmed bool, line, col uint) *PosBase { + return &PosBase{pos, filename, sat32(line), sat32(col), trimmed} +} + +func (base *PosBase) IsFileBase() bool { + if base == nil { + return false + } + return base.pos.base == base +} + +func (base *PosBase) Pos() (_ Pos) { + if base == nil { + return + } + return base.pos +} + +func (base *PosBase) Filename() string { + if base == nil { + return "" + } + return base.filename +} + +func (base *PosBase) Line() uint { + if base == nil { + return 0 + } + return uint(base.line) +} + +func (base *PosBase) Col() uint { + if base == nil { + return 0 + } + return uint(base.col) +} + +func (base *PosBase) Trimmed() bool { + if base == nil { + return false + } + return base.trimmed +} + +func sat32(x uint) uint32 { + if x > PosMax { + return PosMax + } + return uint32(x) +} diff --git a/go/src/cmd/compile/internal/syntax/positions.go b/go/src/cmd/compile/internal/syntax/positions.go new file mode 100644 index 0000000000000000000000000000000000000000..419855f70ffe71f13ba31a1c32cc171f04d8a0b1 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/positions.go @@ -0,0 +1,365 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements helper functions for scope position computations. + +package syntax + +// StartPos returns the start position of n. +func StartPos(n Node) Pos { + // Cases for nodes which don't need a correction are commented out. + for m := n; ; { + switch n := m.(type) { + case nil: + panic("nil node") + + // packages + case *File: + // file block starts at the beginning of the file + return MakePos(n.Pos().Base(), 1, 1) + + // declarations + // case *ImportDecl: + // case *ConstDecl: + // case *TypeDecl: + // case *VarDecl: + // case *FuncDecl: + + // expressions + // case *BadExpr: + // case *Name: + // case *BasicLit: + case *CompositeLit: + if n.Type != nil { + m = n.Type + continue + } + return n.Pos() + case *KeyValueExpr: + m = n.Key + // case *FuncLit: + // case *ParenExpr: + case *SelectorExpr: + m = n.X + case *IndexExpr: + m = n.X + // case *SliceExpr: + case *AssertExpr: + m = n.X + case *TypeSwitchGuard: + if n.Lhs != nil { + m = n.Lhs + continue + } + m = n.X + case *Operation: + if n.Y != nil { + m = n.X + continue + } + return n.Pos() + case *CallExpr: + m = n.Fun + case *ListExpr: + if len(n.ElemList) > 0 { + m = n.ElemList[0] + continue + } + return n.Pos() + // types + // case *ArrayType: + // case *SliceType: + // case *DotsType: + // case *StructType: + // case *Field: + // case *InterfaceType: + // case *FuncType: + // case *MapType: + // case *ChanType: + + // statements + // case *EmptyStmt: + // case *LabeledStmt: + // case *BlockStmt: + // case *ExprStmt: + case *SendStmt: + m = n.Chan + // case *DeclStmt: + case *AssignStmt: + m = n.Lhs + // case *BranchStmt: + // case *CallStmt: + // case *ReturnStmt: + // case *IfStmt: + // case *ForStmt: + // case *SwitchStmt: + // case *SelectStmt: + + // helper nodes + case *RangeClause: + if n.Lhs != nil { + m = n.Lhs + continue + } + m = n.X + // case *CaseClause: + // case *CommClause: + + default: + return n.Pos() + } + } +} + +// EndPos returns the approximate end position of n in the source. +// For some nodes (*Name, *BasicLit) it returns the position immediately +// following the node; for others (*BlockStmt, *SwitchStmt, etc.) it +// returns the position of the closing '}'; and for some (*ParenExpr) +// the returned position is the end position of the last enclosed +// expression. +// Thus, EndPos should not be used for exact demarcation of the +// end of a node in the source; it is mostly useful to determine +// scope ranges where there is some leeway. +func EndPos(n Node) Pos { + for m := n; ; { + switch n := m.(type) { + case nil: + panic("nil node") + + // packages + case *File: + return n.EOF + + // declarations + case *ImportDecl: + m = n.Path + case *ConstDecl: + if n.Values != nil { + m = n.Values + continue + } + if n.Type != nil { + m = n.Type + continue + } + if l := len(n.NameList); l > 0 { + m = n.NameList[l-1] + continue + } + return n.Pos() + case *TypeDecl: + m = n.Type + case *VarDecl: + if n.Values != nil { + m = n.Values + continue + } + if n.Type != nil { + m = n.Type + continue + } + if l := len(n.NameList); l > 0 { + m = n.NameList[l-1] + continue + } + return n.Pos() + case *FuncDecl: + if n.Body != nil { + m = n.Body + continue + } + m = n.Type + + // expressions + case *BadExpr: + return n.Pos() + case *Name: + p := n.Pos() + return MakePos(p.Base(), p.Line(), p.Col()+uint(len(n.Value))) + case *BasicLit: + p := n.Pos() + return MakePos(p.Base(), p.Line(), p.Col()+uint(len(n.Value))) + case *CompositeLit: + return n.Rbrace + case *KeyValueExpr: + m = n.Value + case *FuncLit: + m = n.Body + case *ParenExpr: + m = n.X + case *SelectorExpr: + m = n.Sel + case *IndexExpr: + m = n.Index + case *SliceExpr: + for i := len(n.Index) - 1; i >= 0; i-- { + if x := n.Index[i]; x != nil { + m = x + continue + } + } + m = n.X + case *AssertExpr: + m = n.Type + case *TypeSwitchGuard: + m = n.X + case *Operation: + if n.Y != nil { + m = n.Y + continue + } + m = n.X + case *CallExpr: + if l := lastExpr(n.ArgList); l != nil { + m = l + continue + } + m = n.Fun + case *ListExpr: + if l := lastExpr(n.ElemList); l != nil { + m = l + continue + } + return n.Pos() + + // types + case *ArrayType: + m = n.Elem + case *SliceType: + m = n.Elem + case *DotsType: + m = n.Elem + case *StructType: + if l := lastField(n.FieldList); l != nil { + m = l + continue + } + return n.Pos() + // TODO(gri) need to take TagList into account + case *Field: + if n.Type != nil { + m = n.Type + continue + } + m = n.Name + case *InterfaceType: + if l := lastField(n.MethodList); l != nil { + m = l + continue + } + return n.Pos() + case *FuncType: + if l := lastField(n.ResultList); l != nil { + m = l + continue + } + if l := lastField(n.ParamList); l != nil { + m = l + continue + } + return n.Pos() + case *MapType: + m = n.Value + case *ChanType: + m = n.Elem + + // statements + case *EmptyStmt: + return n.Pos() + case *LabeledStmt: + m = n.Stmt + case *BlockStmt: + return n.Rbrace + case *ExprStmt: + m = n.X + case *SendStmt: + m = n.Value + case *DeclStmt: + if l := lastDecl(n.DeclList); l != nil { + m = l + continue + } + return n.Pos() + case *AssignStmt: + m = n.Rhs + if m == nil { + p := EndPos(n.Lhs) + return MakePos(p.Base(), p.Line(), p.Col()+2) + } + case *BranchStmt: + if n.Label != nil { + m = n.Label + continue + } + return n.Pos() + case *CallStmt: + m = n.Call + case *ReturnStmt: + if n.Results != nil { + m = n.Results + continue + } + return n.Pos() + case *IfStmt: + if n.Else != nil { + m = n.Else + continue + } + m = n.Then + case *ForStmt: + m = n.Body + case *SwitchStmt: + return n.Rbrace + case *SelectStmt: + return n.Rbrace + + // helper nodes + case *RangeClause: + m = n.X + case *CaseClause: + if l := lastStmt(n.Body); l != nil { + m = l + continue + } + return n.Colon + case *CommClause: + if l := lastStmt(n.Body); l != nil { + m = l + continue + } + return n.Colon + + default: + return n.Pos() + } + } +} + +func lastDecl(list []Decl) Decl { + if l := len(list); l > 0 { + return list[l-1] + } + return nil +} + +func lastExpr(list []Expr) Expr { + if l := len(list); l > 0 { + return list[l-1] + } + return nil +} + +func lastStmt(list []Stmt) Stmt { + if l := len(list); l > 0 { + return list[l-1] + } + return nil +} + +func lastField(list []*Field) *Field { + if l := len(list); l > 0 { + return list[l-1] + } + return nil +} diff --git a/go/src/cmd/compile/internal/syntax/printer.go b/go/src/cmd/compile/internal/syntax/printer.go new file mode 100644 index 0000000000000000000000000000000000000000..86d93e8932d2b3f3ab844f48bc915b984f8ec464 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/printer.go @@ -0,0 +1,1020 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements printing of syntax trees in source format. + +package syntax + +import ( + "fmt" + "io" + "strings" +) + +// Form controls print formatting. +type Form uint + +const ( + _ Form = iota // default + LineForm // use spaces instead of linebreaks where possible + ShortForm // like LineForm but print "…" for non-empty function or composite literal bodies +) + +// Fprint prints node x to w in the specified form. +// It returns the number of bytes written, and whether there was an error. +func Fprint(w io.Writer, x Node, form Form) (n int, err error) { + p := printer{ + output: w, + form: form, + linebreaks: form == 0, + } + + defer func() { + n = p.written + if e := recover(); e != nil { + err = e.(writeError).err // re-panics if it's not a writeError + } + }() + + p.print(x) + p.flush(_EOF) + + return +} + +// String is a convenience function that prints n in ShortForm +// and returns the printed string. +func String(n Node) string { + var buf strings.Builder + _, err := Fprint(&buf, n, ShortForm) + if err != nil { + fmt.Fprintf(&buf, "<<< ERROR: %s", err) + } + return buf.String() +} + +type ctrlSymbol int + +const ( + none ctrlSymbol = iota + semi + blank + newline + indent + outdent + // comment + // eolComment +) + +type whitespace struct { + last token + kind ctrlSymbol + //text string // comment text (possibly ""); valid if kind == comment +} + +type printer struct { + output io.Writer + written int // number of bytes written + form Form + linebreaks bool // print linebreaks instead of semis + + indent int // current indentation level + nlcount int // number of consecutive newlines + + pending []whitespace // pending whitespace + lastTok token // last token (after any pending semi) processed by print +} + +// write is a thin wrapper around p.output.Write +// that takes care of accounting and error handling. +func (p *printer) write(data []byte) { + n, err := p.output.Write(data) + p.written += n + if err != nil { + panic(writeError{err}) + } +} + +var ( + tabBytes = []byte("\t\t\t\t\t\t\t\t") + newlineByte = []byte("\n") + blankByte = []byte(" ") +) + +func (p *printer) writeBytes(data []byte) { + if len(data) == 0 { + panic("expected non-empty []byte") + } + if p.nlcount > 0 && p.indent > 0 { + // write indentation + n := p.indent + for n > len(tabBytes) { + p.write(tabBytes) + n -= len(tabBytes) + } + p.write(tabBytes[:n]) + } + p.write(data) + p.nlcount = 0 +} + +func (p *printer) writeString(s string) { + p.writeBytes([]byte(s)) +} + +// If impliesSemi returns true for a non-blank line's final token tok, +// a semicolon is automatically inserted. Vice versa, a semicolon may +// be omitted in those cases. +func impliesSemi(tok token) bool { + switch tok { + case _Name, + _Break, _Continue, _Fallthrough, _Return, + /*_Inc, _Dec,*/ _Rparen, _Rbrack, _Rbrace: // TODO(gri) fix this + return true + } + return false +} + +// TODO(gri) provide table of []byte values for all tokens to avoid repeated string conversion + +func (p *printer) addWhitespace(kind ctrlSymbol, text string) { + p.pending = append(p.pending, whitespace{p.lastTok, kind /*text*/}) + switch kind { + case semi: + p.lastTok = _Semi + case newline: + p.lastTok = 0 + // TODO(gri) do we need to handle /*-style comments containing newlines here? + } +} + +func (p *printer) flush(next token) { + // eliminate semis and redundant whitespace + sawNewline := next == _EOF + sawParen := next == _Rparen || next == _Rbrace + for i := len(p.pending) - 1; i >= 0; i-- { + switch p.pending[i].kind { + case semi: + k := semi + if sawParen { + sawParen = false + k = none // eliminate semi + } else if sawNewline && impliesSemi(p.pending[i].last) { + sawNewline = false + k = none // eliminate semi + } + p.pending[i].kind = k + case newline: + sawNewline = true + case blank, indent, outdent: + // nothing to do + // case comment: + // // A multi-line comment acts like a newline; and a "" + // // comment implies by definition at least one newline. + // if text := p.pending[i].text; strings.HasPrefix(text, "/*") && strings.ContainsRune(text, '\n') { + // sawNewline = true + // } + // case eolComment: + // // TODO(gri) act depending on sawNewline + default: + panic("unreachable") + } + } + + // print pending + prev := none + for i := range p.pending { + switch p.pending[i].kind { + case none: + // nothing to do + case semi: + p.writeString(";") + p.nlcount = 0 + prev = semi + case blank: + if prev != blank { + // at most one blank + p.writeBytes(blankByte) + p.nlcount = 0 + prev = blank + } + case newline: + const maxEmptyLines = 1 + if p.nlcount <= maxEmptyLines { + p.write(newlineByte) + p.nlcount++ + prev = newline + } + case indent: + p.indent++ + case outdent: + p.indent-- + if p.indent < 0 { + panic("negative indentation") + } + // case comment: + // if text := p.pending[i].text; text != "" { + // p.writeString(text) + // p.nlcount = 0 + // prev = comment + // } + // // TODO(gri) should check that line comments are always followed by newline + default: + panic("unreachable") + } + } + + p.pending = p.pending[:0] // re-use underlying array +} + +func mayCombine(prev token, next byte) (b bool) { + return // for now + // switch prev { + // case lexical.Int: + // b = next == '.' // 1. + // case lexical.Add: + // b = next == '+' // ++ + // case lexical.Sub: + // b = next == '-' // -- + // case lexical.Quo: + // b = next == '*' // /* + // case lexical.Lss: + // b = next == '-' || next == '<' // <- or << + // case lexical.And: + // b = next == '&' || next == '^' // && or &^ + // } + // return +} + +func (p *printer) print(args ...any) { + for i := 0; i < len(args); i++ { + switch x := args[i].(type) { + case nil: + // we should not reach here but don't crash + + case Node: + p.printNode(x) + + case token: + // _Name implies an immediately following string + // argument which is the actual value to print. + var s string + if x == _Name { + i++ + if i >= len(args) { + panic("missing string argument after _Name") + } + s = args[i].(string) + } else { + s = x.String() + } + + // TODO(gri) This check seems at the wrong place since it doesn't + // take into account pending white space. + if mayCombine(p.lastTok, s[0]) { + panic("adjacent tokens combine without whitespace") + } + + if x == _Semi { + // delay printing of semi + p.addWhitespace(semi, "") + } else { + p.flush(x) + p.writeString(s) + p.nlcount = 0 + p.lastTok = x + } + + case Operator: + if x != 0 { + p.flush(_Operator) + p.writeString(x.String()) + } + + case ctrlSymbol: + switch x { + case none, semi /*, comment*/ : + panic("unreachable") + case newline: + // TODO(gri) need to handle mandatory newlines after a //-style comment + if !p.linebreaks { + x = blank + } + } + p.addWhitespace(x, "") + + // case *Comment: // comments are not Nodes + // p.addWhitespace(comment, x.Text) + + default: + panic(fmt.Sprintf("unexpected argument %v (%T)", x, x)) + } + } +} + +func (p *printer) printNode(n Node) { + // ncom := *n.Comments() + // if ncom != nil { + // // TODO(gri) in general we cannot make assumptions about whether + // // a comment is a /*- or a //-style comment since the syntax + // // tree may have been manipulated. Need to make sure the correct + // // whitespace is emitted. + // for _, c := range ncom.Alone { + // p.print(c, newline) + // } + // for _, c := range ncom.Before { + // if c.Text == "" || lineComment(c.Text) { + // panic("unexpected empty line or //-style 'before' comment") + // } + // p.print(c, blank) + // } + // } + + p.printRawNode(n) + + // if ncom != nil && len(ncom.After) > 0 { + // for i, c := range ncom.After { + // if i+1 < len(ncom.After) { + // if c.Text == "" || lineComment(c.Text) { + // panic("unexpected empty line or //-style non-final 'after' comment") + // } + // } + // p.print(blank, c) + // } + // //p.print(newline) + // } +} + +func (p *printer) printRawNode(n Node) { + switch n := n.(type) { + case nil: + // we should not reach here but don't crash + + // expressions and types + case *BadExpr: + p.print(_Name, "") + + case *Name: + p.print(_Name, n.Value) // _Name requires actual value following immediately + + case *BasicLit: + p.print(_Name, n.Value) // _Name requires actual value following immediately + + case *FuncLit: + p.print(n.Type, blank) + if n.Body != nil { + if p.form == ShortForm { + p.print(_Lbrace) + if len(n.Body.List) > 0 { + p.print(_Name, "…") + } + p.print(_Rbrace) + } else { + p.print(n.Body) + } + } + + case *CompositeLit: + if n.Type != nil { + p.print(n.Type) + } + p.print(_Lbrace) + if p.form == ShortForm { + if len(n.ElemList) > 0 { + p.print(_Name, "…") + } + } else { + if n.NKeys > 0 && n.NKeys == len(n.ElemList) { + p.printExprLines(n.ElemList) + } else { + p.printExprList(n.ElemList) + } + } + p.print(_Rbrace) + + case *ParenExpr: + p.print(_Lparen, n.X, _Rparen) + + case *SelectorExpr: + p.print(n.X, _Dot, n.Sel) + + case *IndexExpr: + p.print(n.X, _Lbrack, n.Index, _Rbrack) + + case *SliceExpr: + p.print(n.X, _Lbrack) + if i := n.Index[0]; i != nil { + p.printNode(i) + } + p.print(_Colon) + if j := n.Index[1]; j != nil { + p.printNode(j) + } + if k := n.Index[2]; k != nil { + p.print(_Colon, k) + } + p.print(_Rbrack) + + case *AssertExpr: + p.print(n.X, _Dot, _Lparen, n.Type, _Rparen) + + case *TypeSwitchGuard: + if n.Lhs != nil { + p.print(n.Lhs, blank, _Define, blank) + } + p.print(n.X, _Dot, _Lparen, _Type, _Rparen) + + case *CallExpr: + p.print(n.Fun, _Lparen) + p.printExprList(n.ArgList) + if n.HasDots { + p.print(_DotDotDot) + } + p.print(_Rparen) + + case *Operation: + if n.Y == nil { + // unary expr + p.print(n.Op) + // if n.Op == lexical.Range { + // p.print(blank) + // } + p.print(n.X) + } else { + // binary expr + // TODO(gri) eventually take precedence into account + // to control possibly missing parentheses + p.print(n.X, blank, n.Op, blank, n.Y) + } + + case *KeyValueExpr: + p.print(n.Key, _Colon, blank, n.Value) + + case *ListExpr: + p.printExprList(n.ElemList) + + case *ArrayType: + var len any = _DotDotDot + if n.Len != nil { + len = n.Len + } + p.print(_Lbrack, len, _Rbrack, n.Elem) + + case *SliceType: + p.print(_Lbrack, _Rbrack, n.Elem) + + case *DotsType: + p.print(_DotDotDot, n.Elem) + + case *StructType: + p.print(_Struct) + if len(n.FieldList) > 0 && p.linebreaks { + p.print(blank) + } + p.print(_Lbrace) + if len(n.FieldList) > 0 { + if p.linebreaks { + p.print(newline, indent) + p.printFieldList(n.FieldList, n.TagList, _Semi) + p.print(outdent, newline) + } else { + p.printFieldList(n.FieldList, n.TagList, _Semi) + } + } + p.print(_Rbrace) + + case *FuncType: + p.print(_Func) + p.printSignature(n) + + case *InterfaceType: + p.print(_Interface) + if p.linebreaks && len(n.MethodList) > 1 { + p.print(blank) + p.print(_Lbrace) + p.print(newline, indent) + p.printMethodList(n.MethodList) + p.print(outdent, newline) + } else { + p.print(_Lbrace) + p.printMethodList(n.MethodList) + } + p.print(_Rbrace) + + case *MapType: + p.print(_Map, _Lbrack, n.Key, _Rbrack, n.Value) + + case *ChanType: + if n.Dir == RecvOnly { + p.print(_Arrow) + } + p.print(_Chan) + if n.Dir == SendOnly { + p.print(_Arrow) + } + p.print(blank) + if e, _ := n.Elem.(*ChanType); n.Dir == 0 && e != nil && e.Dir == RecvOnly { + // don't print chan (<-chan T) as chan <-chan T + p.print(_Lparen) + p.print(n.Elem) + p.print(_Rparen) + } else { + p.print(n.Elem) + } + + // statements + case *DeclStmt: + p.printDecl(n.DeclList) + + case *EmptyStmt: + // nothing to print + + case *LabeledStmt: + p.print(outdent, n.Label, _Colon, indent, newline, n.Stmt) + + case *ExprStmt: + p.print(n.X) + + case *SendStmt: + p.print(n.Chan, blank, _Arrow, blank, n.Value) + + case *AssignStmt: + p.print(n.Lhs) + if n.Rhs == nil { + // TODO(gri) This is going to break the mayCombine + // check once we enable that again. + p.print(n.Op, n.Op) // ++ or -- + } else { + p.print(blank, n.Op, _Assign, blank) + p.print(n.Rhs) + } + + case *CallStmt: + p.print(n.Tok, blank, n.Call) + + case *ReturnStmt: + p.print(_Return) + if n.Results != nil { + p.print(blank, n.Results) + } + + case *BranchStmt: + p.print(n.Tok) + if n.Label != nil { + p.print(blank, n.Label) + } + + case *BlockStmt: + p.print(_Lbrace) + if len(n.List) > 0 { + p.print(newline, indent) + p.printStmtList(n.List, true) + p.print(outdent, newline) + } + p.print(_Rbrace) + + case *IfStmt: + p.print(_If, blank) + if n.Init != nil { + p.print(n.Init, _Semi, blank) + } + p.print(n.Cond, blank, n.Then) + if n.Else != nil { + p.print(blank, _Else, blank, n.Else) + } + + case *SwitchStmt: + p.print(_Switch, blank) + if n.Init != nil { + p.print(n.Init, _Semi, blank) + } + if n.Tag != nil { + p.print(n.Tag, blank) + } + p.printSwitchBody(n.Body) + + case *SelectStmt: + p.print(_Select, blank) // for now + p.printSelectBody(n.Body) + + case *RangeClause: + if n.Lhs != nil { + tok := _Assign + if n.Def { + tok = _Define + } + p.print(n.Lhs, blank, tok, blank) + } + p.print(_Range, blank, n.X) + + case *ForStmt: + p.print(_For, blank) + if n.Init == nil && n.Post == nil { + if n.Cond != nil { + p.print(n.Cond, blank) + } + } else { + if n.Init != nil { + p.print(n.Init) + // TODO(gri) clean this up + if _, ok := n.Init.(*RangeClause); ok { + p.print(blank, n.Body) + break + } + } + p.print(_Semi, blank) + if n.Cond != nil { + p.print(n.Cond) + } + p.print(_Semi, blank) + if n.Post != nil { + p.print(n.Post, blank) + } + } + p.print(n.Body) + + case *ImportDecl: + if n.Group == nil { + p.print(_Import, blank) + } + if n.LocalPkgName != nil { + p.print(n.LocalPkgName, blank) + } + p.print(n.Path) + + case *ConstDecl: + if n.Group == nil { + p.print(_Const, blank) + } + p.printNameList(n.NameList) + if n.Type != nil { + p.print(blank, n.Type) + } + if n.Values != nil { + p.print(blank, _Assign, blank, n.Values) + } + + case *TypeDecl: + if n.Group == nil { + p.print(_Type, blank) + } + p.print(n.Name) + if n.TParamList != nil { + p.printParameterList(n.TParamList, _Type) + } + p.print(blank) + if n.Alias { + p.print(_Assign, blank) + } + p.print(n.Type) + + case *VarDecl: + if n.Group == nil { + p.print(_Var, blank) + } + p.printNameList(n.NameList) + if n.Type != nil { + p.print(blank, n.Type) + } + if n.Values != nil { + p.print(blank, _Assign, blank, n.Values) + } + + case *FuncDecl: + p.print(_Func, blank) + if r := n.Recv; r != nil { + p.print(_Lparen) + if r.Name != nil { + p.print(r.Name, blank) + } + p.printNode(r.Type) + p.print(_Rparen, blank) + } + p.print(n.Name) + if n.TParamList != nil { + p.printParameterList(n.TParamList, _Func) + } + p.printSignature(n.Type) + if n.Body != nil { + p.print(blank, n.Body) + } + + case *printGroup: + p.print(n.Tok, blank, _Lparen) + if len(n.Decls) > 0 { + p.print(newline, indent) + for _, d := range n.Decls { + p.printNode(d) + p.print(_Semi, newline) + } + p.print(outdent) + } + p.print(_Rparen) + + // files + case *File: + p.print(_Package, blank, n.PkgName) + if len(n.DeclList) > 0 { + p.print(_Semi, newline, newline) + p.printDeclList(n.DeclList) + } + + default: + panic(fmt.Sprintf("syntax.Iterate: unexpected node type %T", n)) + } +} + +func (p *printer) printFields(fields []*Field, tags []*BasicLit, i, j int) { + if i+1 == j && fields[i].Name == nil { + // anonymous field + p.printNode(fields[i].Type) + } else { + for k, f := range fields[i:j] { + if k > 0 { + p.print(_Comma, blank) + } + p.printNode(f.Name) + } + p.print(blank) + p.printNode(fields[i].Type) + } + if i < len(tags) && tags[i] != nil { + p.print(blank) + p.printNode(tags[i]) + } +} + +func (p *printer) printFieldList(fields []*Field, tags []*BasicLit, sep token) { + i0 := 0 + var typ Expr + for i, f := range fields { + if f.Name == nil || f.Type != typ { + if i0 < i { + p.printFields(fields, tags, i0, i) + p.print(sep, newline) + i0 = i + } + typ = f.Type + } + } + p.printFields(fields, tags, i0, len(fields)) +} + +func (p *printer) printMethodList(methods []*Field) { + for i, m := range methods { + if i > 0 { + p.print(_Semi, newline) + } + if m.Name != nil { + p.printNode(m.Name) + p.printSignature(m.Type.(*FuncType)) + } else { + p.printNode(m.Type) + } + } +} + +func (p *printer) printNameList(list []*Name) { + for i, x := range list { + if i > 0 { + p.print(_Comma, blank) + } + p.printNode(x) + } +} + +func (p *printer) printExprList(list []Expr) { + for i, x := range list { + if i > 0 { + p.print(_Comma, blank) + } + p.printNode(x) + } +} + +func (p *printer) printExprLines(list []Expr) { + if len(list) > 0 { + p.print(newline, indent) + for _, x := range list { + p.print(x, _Comma, newline) + } + p.print(outdent) + } +} + +func groupFor(d Decl) (token, *Group) { + switch d := d.(type) { + case *ImportDecl: + return _Import, d.Group + case *ConstDecl: + return _Const, d.Group + case *TypeDecl: + return _Type, d.Group + case *VarDecl: + return _Var, d.Group + case *FuncDecl: + return _Func, nil + default: + panic("unreachable") + } +} + +type printGroup struct { + node + Tok token + Decls []Decl +} + +func (p *printer) printDecl(list []Decl) { + tok, group := groupFor(list[0]) + + if group == nil { + if len(list) != 1 { + panic("unreachable") + } + p.printNode(list[0]) + return + } + + // if _, ok := list[0].(*EmptyDecl); ok { + // if len(list) != 1 { + // panic("unreachable") + // } + // // TODO(gri) if there are comments inside the empty + // // group, we may need to keep the list non-nil + // list = nil + // } + + // printGroup is here for consistent comment handling + // (this is not yet used) + var pg printGroup + // *pg.Comments() = *group.Comments() + pg.Tok = tok + pg.Decls = list + p.printNode(&pg) +} + +func (p *printer) printDeclList(list []Decl) { + i0 := 0 + var tok token + var group *Group + for i, x := range list { + if s, g := groupFor(x); g == nil || g != group { + if i0 < i { + p.printDecl(list[i0:i]) + p.print(_Semi, newline) + // print empty line between different declaration groups, + // different kinds of declarations, or between functions + if g != group || s != tok || s == _Func { + p.print(newline) + } + i0 = i + } + tok, group = s, g + } + } + p.printDecl(list[i0:]) +} + +func (p *printer) printSignature(sig *FuncType) { + p.printParameterList(sig.ParamList, 0) + if list := sig.ResultList; list != nil { + p.print(blank) + if len(list) == 1 && list[0].Name == nil { + p.printNode(list[0].Type) + } else { + p.printParameterList(list, 0) + } + } +} + +// If tok != 0 print a type parameter list: tok == _Type means +// a type parameter list for a type, tok == _Func means a type +// parameter list for a func. +func (p *printer) printParameterList(list []*Field, tok token) { + open, close := _Lparen, _Rparen + if tok != 0 { + open, close = _Lbrack, _Rbrack + } + p.print(open) + for i, f := range list { + if i > 0 { + p.print(_Comma, blank) + } + if f.Name != nil { + p.printNode(f.Name) + if i+1 < len(list) { + f1 := list[i+1] + if f1.Name != nil && f1.Type == f.Type { + continue // no need to print type + } + } + p.print(blank) + } + p.printNode(f.Type) + } + // A type parameter list [P T] where the name P and the type expression T syntactically + // combine to another valid (value) expression requires a trailing comma, as in [P *T,] + // (or an enclosing interface as in [P interface(*T)]), so that the type parameter list + // is not parsed as an array length [P*T]. + if tok == _Type && len(list) == 1 && combinesWithName(list[0].Type) { + p.print(_Comma) + } + p.print(close) +} + +// combinesWithName reports whether a name followed by the expression x +// syntactically combines to another valid (value) expression. For instance +// using *T for x, "name *T" syntactically appears as the expression x*T. +// On the other hand, using P|Q or *P|~Q for x, "name P|Q" or "name *P|~Q" +// cannot be combined into a valid (value) expression. +func combinesWithName(x Expr) bool { + switch x := x.(type) { + case *Operation: + if x.Y == nil { + // name *x.X combines to name*x.X if x.X is not a type element + return x.Op == Mul && !isTypeElem(x.X) + } + // binary expressions + return combinesWithName(x.X) && !isTypeElem(x.Y) + case *ParenExpr: + // Note that the parser strips parentheses in these cases + // (see extractName, parser.typeOrNil) unless keep_parens + // is set, so we should never reach here. + // Do the right thing (rather than panic) for testing and + // in case we change parser behavior. + // See also go.dev/issues/69206. + return !isTypeElem(x.X) + } + return false +} + +func (p *printer) printStmtList(list []Stmt, braces bool) { + for i, x := range list { + p.print(x, _Semi) + if i+1 < len(list) { + p.print(newline) + } else if braces { + // Print an extra semicolon if the last statement is + // an empty statement and we are in a braced block + // because one semicolon is automatically removed. + if _, ok := x.(*EmptyStmt); ok { + p.print(x, _Semi) + } + } + } +} + +func (p *printer) printSwitchBody(list []*CaseClause) { + p.print(_Lbrace) + if len(list) > 0 { + p.print(newline) + for i, c := range list { + p.printCaseClause(c, i+1 == len(list)) + p.print(newline) + } + } + p.print(_Rbrace) +} + +func (p *printer) printSelectBody(list []*CommClause) { + p.print(_Lbrace) + if len(list) > 0 { + p.print(newline) + for i, c := range list { + p.printCommClause(c, i+1 == len(list)) + p.print(newline) + } + } + p.print(_Rbrace) +} + +func (p *printer) printCaseClause(c *CaseClause, braces bool) { + if c.Cases != nil { + p.print(_Case, blank, c.Cases) + } else { + p.print(_Default) + } + p.print(_Colon) + if len(c.Body) > 0 { + p.print(newline, indent) + p.printStmtList(c.Body, braces) + p.print(outdent) + } +} + +func (p *printer) printCommClause(c *CommClause, braces bool) { + if c.Comm != nil { + p.print(_Case, blank) + p.print(c.Comm) + } else { + p.print(_Default) + } + p.print(_Colon) + if len(c.Body) > 0 { + p.print(newline, indent) + p.printStmtList(c.Body, braces) + p.print(outdent) + } +} diff --git a/go/src/cmd/compile/internal/syntax/printer_test.go b/go/src/cmd/compile/internal/syntax/printer_test.go new file mode 100644 index 0000000000000000000000000000000000000000..22585dfd259b24a825dd669caf18193ac46875bf --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/printer_test.go @@ -0,0 +1,291 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import ( + "fmt" + "io" + "os" + "strings" + "testing" +) + +func TestPrint(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + + ast, _ := ParseFile(*src_, func(err error) { t.Error(err) }, nil, 0) + + if ast != nil { + Fprint(testOut(), ast, LineForm) + fmt.Println() + } +} + +type shortBuffer struct { + buf []byte +} + +func (w *shortBuffer) Write(data []byte) (n int, err error) { + w.buf = append(w.buf, data...) + n = len(data) + if len(w.buf) > 10 { + err = io.ErrShortBuffer + } + return +} + +func TestPrintError(t *testing.T) { + const src = "package p; var x int" + ast, err := Parse(nil, strings.NewReader(src), nil, nil, 0) + if err != nil { + t.Fatal(err) + } + + var buf shortBuffer + _, err = Fprint(&buf, ast, 0) + if err == nil || err != io.ErrShortBuffer { + t.Errorf("got err = %s, want %s", err, io.ErrShortBuffer) + } +} + +var stringTests = [][2]string{ + dup("package p"), + dup("package p; type _ int; type T1 = struct{}; type ( _ *struct{}; T2 = float32 )"), + + // generic type declarations (given type separated with blank from LHS) + dup("package p; type _[T any] struct{}"), + dup("package p; type _[A, B, C interface{m()}] struct{}"), + dup("package p; type _[T any, A, B, C interface{m()}, X, Y, Z interface{~int}] struct{}"), + + dup("package p; type _[P *struct{}] struct{}"), + dup("package p; type _[P *T,] struct{}"), + dup("package p; type _[P *T, _ any] struct{}"), + {"package p; type _[P (*T),] struct{}", "package p; type _[P *T,] struct{}"}, + {"package p; type _[P (*T), _ any] struct{}", "package p; type _[P *T, _ any] struct{}"}, + {"package p; type _[P (T),] struct{}", "package p; type _[P T] struct{}"}, + {"package p; type _[P (T), _ any] struct{}", "package p; type _[P T, _ any] struct{}"}, + + {"package p; type _[P (*struct{})] struct{}", "package p; type _[P *struct{}] struct{}"}, + {"package p; type _[P ([]int)] struct{}", "package p; type _[P []int] struct{}"}, + {"package p; type _[P ([]int) | int] struct{}", "package p; type _[P []int | int] struct{}"}, + + // a type literal in an |-expression indicates a type parameter list (blank after type parameter list and type) + dup("package p; type _[P *[]int] struct{}"), + dup("package p; type _[P T | T] struct{}"), + dup("package p; type _[P T | T | T | T] struct{}"), + dup("package p; type _[P *T | T, Q T] struct{}"), + dup("package p; type _[P *[]T | T] struct{}"), + dup("package p; type _[P *T | T | T | T | ~T] struct{}"), + dup("package p; type _[P *T | T | T | ~T | T] struct{}"), + dup("package p; type _[P *T | T | struct{} | T] struct{}"), + dup("package p; type _[P <-chan int] struct{}"), + dup("package p; type _[P *T | struct{} | T] struct{}"), + + // a trailing comma always indicates a (possibly invalid) type parameter list (blank after type parameter list and type) + dup("package p; type _[P *T,] struct{}"), + dup("package p; type _[P *T | T,] struct{}"), + dup("package p; type _[P *T | <-T | T,] struct{}"), + + // slice/array type declarations (no blank between array length and element type) + dup("package p; type _ []byte"), + dup("package p; type _ [n]byte"), + dup("package p; type _ [P(T)]byte"), + dup("package p; type _ [P((T))]byte"), + dup("package p; type _ [P * *T]byte"), + dup("package p; type _ [P * T]byte"), + dup("package p; type _ [P(*T)]byte"), + dup("package p; type _ [P(**T)]byte"), + dup("package p; type _ [P * T - T]byte"), + dup("package p; type _ [P * T - T]byte"), + dup("package p; type _ [P * T | T]byte"), + dup("package p; type _ [P * T | <-T | T]byte"), + + // generic function declarations + dup("package p; func _[T any]()"), + dup("package p; func _[A, B, C interface{m()}]()"), + dup("package p; func _[T any, A, B, C interface{m()}, X, Y, Z interface{~int}]()"), + + // generic functions with elided interfaces in type constraints + dup("package p; func _[P *T]() {}"), + dup("package p; func _[P *T | T | T | T | ~T]() {}"), + dup("package p; func _[P *T | T | struct{} | T]() {}"), + dup("package p; func _[P ~int, Q int | string]() {}"), + dup("package p; func _[P struct{f int}, Q *P]() {}"), + + // methods with generic receiver types + dup("package p; func (R[T]) _()"), + dup("package p; func (*R[A, B, C]) _()"), + dup("package p; func (_ *R[A, B, C]) _()"), + + // channels + dup("package p; type _ chan chan int"), + dup("package p; type _ chan (<-chan int)"), + dup("package p; type _ chan chan<- int"), + + dup("package p; type _ <-chan chan int"), + dup("package p; type _ <-chan <-chan int"), + dup("package p; type _ <-chan chan<- int"), + + dup("package p; type _ chan<- chan int"), + dup("package p; type _ chan<- <-chan int"), + dup("package p; type _ chan<- chan<- int"), + + // go.dev/issues/69206 + dup("package p; type _[P C] int"), + {"package p; type _[P (C),] int", "package p; type _[P C] int"}, + {"package p; type _[P ((C)),] int", "package p; type _[P C] int"}, + {"package p; type _[P, Q ((C))] int", "package p; type _[P, Q C] int"}, + + // TODO(gri) expand +} + +func TestPrintString(t *testing.T) { + for _, test := range stringTests { + ast, err := Parse(nil, strings.NewReader(test[0]), nil, nil, 0) + if err != nil { + t.Error(err) + continue + } + if got := String(ast); got != test[1] { + t.Errorf("%q: got %q", test[1], got) + } + } +} + +func testOut() io.Writer { + if testing.Verbose() { + return os.Stdout + } + return io.Discard +} + +func dup(s string) [2]string { return [2]string{s, s} } + +var exprTests = [][2]string{ + // basic type literals + dup("x"), + dup("true"), + dup("42"), + dup("3.1415"), + dup("2.71828i"), + dup(`'a'`), + dup(`"foo"`), + dup("`bar`"), + dup("any"), + + // func and composite literals + dup("func() {}"), + dup("[]int{}"), + {"func(x int) complex128 { return 0 }", "func(x int) complex128 {…}"}, + {"[]int{1, 2, 3}", "[]int{…}"}, + + // type expressions + dup("[1 << 10]byte"), + dup("[]int"), + dup("*int"), + dup("struct{x int}"), + dup("func()"), + dup("func(int, float32) string"), + dup("interface{m()}"), + dup("interface{m() string; n(x int)}"), + dup("interface{~int}"), + dup("interface{~int | ~float64 | ~string}"), + dup("interface{~int; m()}"), + dup("interface{~int | ~float64 | ~string; m() string; n(x int)}"), + dup("map[string]int"), + dup("chan E"), + dup("<-chan E"), + dup("chan<- E"), + + // new interfaces + dup("interface{int}"), + dup("interface{~int}"), + + // generic constraints + dup("interface{~a | ~b | ~c; ~int | ~string; float64; m()}"), + dup("interface{int | string}"), + dup("interface{~int | ~string; float64; m()}"), + dup("interface{~T[int, string] | string}"), + + // generic types + dup("x[T]"), + dup("x[N | A | S]"), + dup("x[N, A]"), + + // non-type expressions + dup("(x)"), + dup("x.f"), + dup("a[i]"), + + dup("s[:]"), + dup("s[i:]"), + dup("s[:j]"), + dup("s[i:j]"), + dup("s[:j:k]"), + dup("s[i:j:k]"), + + dup("x.(T)"), + + dup("x.([10]int)"), + dup("x.([...]int)"), + + dup("x.(struct{})"), + dup("x.(struct{x int; y, z float32; E})"), + + dup("x.(func())"), + dup("x.(func(x int))"), + dup("x.(func() int)"), + dup("x.(func(x, y int, z float32) (r int))"), + dup("x.(func(a, b, c int))"), + dup("x.(func(x ...T))"), + + dup("x.(interface{})"), + dup("x.(interface{m(); n(x int); E})"), + dup("x.(interface{m(); n(x int) T; E; F})"), + + dup("x.(map[K]V)"), + + dup("x.(chan E)"), + dup("x.(<-chan E)"), + dup("x.(chan<- chan int)"), + dup("x.(chan<- <-chan int)"), + dup("x.(<-chan chan int)"), + dup("x.(chan (<-chan int))"), + + dup("f()"), + dup("f(x)"), + dup("int(x)"), + dup("f(x, x + y)"), + dup("f(s...)"), + dup("f(a, s...)"), + + // generic functions + dup("f[T]()"), + dup("f[T](T)"), + dup("f[T, T1]()"), + dup("f[T, T1](T, T1)"), + + dup("*x"), + dup("&x"), + dup("x + y"), + dup("x + y << (2 * s)"), +} + +func TestShortString(t *testing.T) { + for _, test := range exprTests { + src := "package p; var _ = " + test[0] + ast, err := Parse(nil, strings.NewReader(src), nil, nil, 0) + if err != nil { + t.Errorf("%s: %s", test[0], err) + continue + } + x := ast.DeclList[0].(*VarDecl).Values + if got := String(x); got != test[1] { + t.Errorf("%s: got %s, want %s", test[0], got, test[1]) + } + } +} diff --git a/go/src/cmd/compile/internal/syntax/scanner.go b/go/src/cmd/compile/internal/syntax/scanner.go new file mode 100644 index 0000000000000000000000000000000000000000..700908f6bda28a5bb2e199480e15e679f3d60b3d --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/scanner.go @@ -0,0 +1,881 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements scanner, a lexical tokenizer for +// Go source. After initialization, consecutive calls of +// next advance the scanner one token at a time. +// +// This file, source.go, tokens.go, and token_string.go are self-contained +// (`go tool compile scanner.go source.go tokens.go token_string.go` compiles) +// and thus could be made into their own package. + +package syntax + +import ( + "fmt" + "io" + "unicode" + "unicode/utf8" +) + +// The mode flags below control which comments are reported +// by calling the error handler. If no flag is set, comments +// are ignored. +const ( + comments uint = 1 << iota // call handler for all comments + directives // call handler for directives only +) + +type scanner struct { + source + mode uint + nlsemi bool // if set '\n' and EOF translate to ';' + + // current token, valid after calling next() + line, col uint + blank bool // line is blank up to col + tok token + lit string // valid if tok is _Name, _Literal, or _Semi ("semicolon", "newline", or "EOF"); may be malformed if bad is true + bad bool // valid if tok is _Literal, true if a syntax error occurred, lit may be malformed + kind LitKind // valid if tok is _Literal + op Operator // valid if tok is _Operator, _Star, _AssignOp, or _IncOp + prec int // valid if tok is _Operator, _Star, _AssignOp, or _IncOp +} + +func (s *scanner) init(src io.Reader, errh func(line, col uint, msg string), mode uint) { + s.source.init(src, errh) + s.mode = mode + s.nlsemi = false +} + +// errorf reports an error at the most recently read character position. +func (s *scanner) errorf(format string, args ...any) { + s.error(fmt.Sprintf(format, args...)) +} + +// errorAtf reports an error at a byte column offset relative to the current token start. +func (s *scanner) errorAtf(offset int, format string, args ...any) { + s.errh(s.line, s.col+uint(offset), fmt.Sprintf(format, args...)) +} + +// setLit sets the scanner state for a recognized _Literal token. +func (s *scanner) setLit(kind LitKind, ok bool) { + s.nlsemi = true + s.tok = _Literal + s.lit = string(s.segment()) + s.bad = !ok + s.kind = kind +} + +// next advances the scanner by reading the next token. +// +// If a read, source encoding, or lexical error occurs, next calls +// the installed error handler with the respective error position +// and message. The error message is guaranteed to be non-empty and +// never starts with a '/'. The error handler must exist. +// +// If the scanner mode includes the comments flag and a comment +// (including comments containing directives) is encountered, the +// error handler is also called with each comment position and text +// (including opening /* or // and closing */, but without a newline +// at the end of line comments). Comment text always starts with a / +// which can be used to distinguish these handler calls from errors. +// +// If the scanner mode includes the directives (but not the comments) +// flag, only comments containing a //line, /*line, or //go: directive +// are reported, in the same way as regular comments. +func (s *scanner) next() { + nlsemi := s.nlsemi + s.nlsemi = false + +redo: + // skip white space + s.stop() + startLine, startCol := s.pos() + for s.ch == ' ' || s.ch == '\t' || s.ch == '\n' && !nlsemi || s.ch == '\r' { + s.nextch() + } + + // token start + s.line, s.col = s.pos() + s.blank = s.line > startLine || startCol == colbase + s.start() + if isLetter(s.ch) || s.ch >= utf8.RuneSelf && s.atIdentChar(true) { + s.nextch() + s.ident() + return + } + + switch s.ch { + case -1: + if nlsemi { + s.lit = "EOF" + s.tok = _Semi + break + } + s.tok = _EOF + + case '\n': + s.nextch() + s.lit = "newline" + s.tok = _Semi + + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + s.number(false) + + case '"': + s.stdString() + + case '`': + s.rawString() + + case '\'': + s.rune() + + case '(': + s.nextch() + s.tok = _Lparen + + case '[': + s.nextch() + s.tok = _Lbrack + + case '{': + s.nextch() + s.tok = _Lbrace + + case ',': + s.nextch() + s.tok = _Comma + + case ';': + s.nextch() + s.lit = "semicolon" + s.tok = _Semi + + case ')': + s.nextch() + s.nlsemi = true + s.tok = _Rparen + + case ']': + s.nextch() + s.nlsemi = true + s.tok = _Rbrack + + case '}': + s.nextch() + s.nlsemi = true + s.tok = _Rbrace + + case ':': + s.nextch() + if s.ch == '=' { + s.nextch() + s.tok = _Define + break + } + s.tok = _Colon + + case '.': + s.nextch() + if isDecimal(s.ch) { + s.number(true) + break + } + if s.ch == '.' { + s.nextch() + if s.ch == '.' { + s.nextch() + s.tok = _DotDotDot + break + } + s.rewind() // now s.ch holds 1st '.' + s.nextch() // consume 1st '.' again + } + s.tok = _Dot + + case '+': + s.nextch() + s.op, s.prec = Add, precAdd + if s.ch != '+' { + goto assignop + } + s.nextch() + s.nlsemi = true + s.tok = _IncOp + + case '-': + s.nextch() + s.op, s.prec = Sub, precAdd + if s.ch != '-' { + goto assignop + } + s.nextch() + s.nlsemi = true + s.tok = _IncOp + + case '*': + s.nextch() + s.op, s.prec = Mul, precMul + // don't goto assignop - want _Star token + if s.ch == '=' { + s.nextch() + s.tok = _AssignOp + break + } + s.tok = _Star + + case '/': + s.nextch() + if s.ch == '/' { + s.nextch() + s.lineComment() + goto redo + } + if s.ch == '*' { + s.nextch() + s.fullComment() + if line, _ := s.pos(); line > s.line && nlsemi { + // A multi-line comment acts like a newline; + // it translates to a ';' if nlsemi is set. + s.lit = "newline" + s.tok = _Semi + break + } + goto redo + } + s.op, s.prec = Div, precMul + goto assignop + + case '%': + s.nextch() + s.op, s.prec = Rem, precMul + goto assignop + + case '&': + s.nextch() + if s.ch == '&' { + s.nextch() + s.op, s.prec = AndAnd, precAndAnd + s.tok = _Operator + break + } + s.op, s.prec = And, precMul + if s.ch == '^' { + s.nextch() + s.op = AndNot + } + goto assignop + + case '|': + s.nextch() + if s.ch == '|' { + s.nextch() + s.op, s.prec = OrOr, precOrOr + s.tok = _Operator + break + } + s.op, s.prec = Or, precAdd + goto assignop + + case '^': + s.nextch() + s.op, s.prec = Xor, precAdd + goto assignop + + case '<': + s.nextch() + if s.ch == '=' { + s.nextch() + s.op, s.prec = Leq, precCmp + s.tok = _Operator + break + } + if s.ch == '<' { + s.nextch() + s.op, s.prec = Shl, precMul + goto assignop + } + if s.ch == '-' { + s.nextch() + s.tok = _Arrow + break + } + s.op, s.prec = Lss, precCmp + s.tok = _Operator + + case '>': + s.nextch() + if s.ch == '=' { + s.nextch() + s.op, s.prec = Geq, precCmp + s.tok = _Operator + break + } + if s.ch == '>' { + s.nextch() + s.op, s.prec = Shr, precMul + goto assignop + } + s.op, s.prec = Gtr, precCmp + s.tok = _Operator + + case '=': + s.nextch() + if s.ch == '=' { + s.nextch() + s.op, s.prec = Eql, precCmp + s.tok = _Operator + break + } + s.tok = _Assign + + case '!': + s.nextch() + if s.ch == '=' { + s.nextch() + s.op, s.prec = Neq, precCmp + s.tok = _Operator + break + } + s.op, s.prec = Not, 0 + s.tok = _Operator + + case '~': + s.nextch() + s.op, s.prec = Tilde, 0 + s.tok = _Operator + + default: + s.errorf("invalid character %#U", s.ch) + s.nextch() + goto redo + } + + return + +assignop: + if s.ch == '=' { + s.nextch() + s.tok = _AssignOp + return + } + s.tok = _Operator +} + +func (s *scanner) ident() { + // accelerate common case (7bit ASCII) + for isLetter(s.ch) || isDecimal(s.ch) { + s.nextch() + } + + // general case + if s.ch >= utf8.RuneSelf { + for s.atIdentChar(false) { + s.nextch() + } + } + + // possibly a keyword + lit := s.segment() + if len(lit) >= 2 { + if tok := keywordMap[hash(lit)]; tok != 0 && tokStrFast(tok) == string(lit) { + s.nlsemi = contains(1<<_Break|1<<_Continue|1<<_Fallthrough|1<<_Return, tok) + s.tok = tok + return + } + } + + s.nlsemi = true + s.lit = string(lit) + s.tok = _Name +} + +// tokStrFast is a faster version of token.String, which assumes that tok +// is one of the valid tokens - and can thus skip bounds checks. +func tokStrFast(tok token) string { + return _token_name[_token_index[tok-1]:_token_index[tok]] +} + +func (s *scanner) atIdentChar(first bool) bool { + switch { + case unicode.IsLetter(s.ch) || s.ch == '_': + // ok + case unicode.IsDigit(s.ch): + if first { + s.errorf("identifier cannot begin with digit %#U", s.ch) + } + case s.ch >= utf8.RuneSelf: + s.errorf("invalid character %#U in identifier", s.ch) + default: + return false + } + return true +} + +// hash is a perfect hash function for keywords. +// It assumes that s has at least length 2. +func hash(s []byte) uint { + return (uint(s[0])<<4 ^ uint(s[1]) + uint(len(s))) & uint(len(keywordMap)-1) +} + +var keywordMap [1 << 6]token // size must be power of two + +func init() { + // populate keywordMap + for tok := _Break; tok <= _Var; tok++ { + h := hash([]byte(tok.String())) + if keywordMap[h] != 0 { + panic("imperfect hash") + } + keywordMap[h] = tok + } +} + +func lower(ch rune) rune { return ('a' - 'A') | ch } // returns lower-case ch iff ch is ASCII letter +func isLetter(ch rune) bool { return 'a' <= lower(ch) && lower(ch) <= 'z' || ch == '_' } +func isDecimal(ch rune) bool { return '0' <= ch && ch <= '9' } +func isHex(ch rune) bool { return '0' <= ch && ch <= '9' || 'a' <= lower(ch) && lower(ch) <= 'f' } + +// digits accepts the sequence { digit | '_' }. +// If base <= 10, digits accepts any decimal digit but records +// the index (relative to the literal start) of a digit >= base +// in *invalid, if *invalid < 0. +// digits returns a bitset describing whether the sequence contained +// digits (bit 0 is set), or separators '_' (bit 1 is set). +func (s *scanner) digits(base int, invalid *int) (digsep int) { + if base <= 10 { + max := rune('0' + base) + for isDecimal(s.ch) || s.ch == '_' { + ds := 1 + if s.ch == '_' { + ds = 2 + } else if s.ch >= max && *invalid < 0 { + _, col := s.pos() + *invalid = int(col - s.col) // record invalid rune index + } + digsep |= ds + s.nextch() + } + } else { + for isHex(s.ch) || s.ch == '_' { + ds := 1 + if s.ch == '_' { + ds = 2 + } + digsep |= ds + s.nextch() + } + } + return +} + +func (s *scanner) number(seenPoint bool) { + ok := true + kind := IntLit + base := 10 // number base + prefix := rune(0) // one of 0 (decimal), '0' (0-octal), 'x', 'o', or 'b' + digsep := 0 // bit 0: digit present, bit 1: '_' present + invalid := -1 // index of invalid digit in literal, or < 0 + + // integer part + if !seenPoint { + if s.ch == '0' { + s.nextch() + switch lower(s.ch) { + case 'x': + s.nextch() + base, prefix = 16, 'x' + case 'o': + s.nextch() + base, prefix = 8, 'o' + case 'b': + s.nextch() + base, prefix = 2, 'b' + default: + base, prefix = 8, '0' + digsep = 1 // leading 0 + } + } + digsep |= s.digits(base, &invalid) + if s.ch == '.' { + if prefix == 'o' || prefix == 'b' { + s.errorf("invalid radix point in %s literal", baseName(base)) + ok = false + } + s.nextch() + seenPoint = true + } + } + + // fractional part + if seenPoint { + kind = FloatLit + digsep |= s.digits(base, &invalid) + } + + if digsep&1 == 0 && ok { + s.errorf("%s literal has no digits", baseName(base)) + ok = false + } + + // exponent + if e := lower(s.ch); e == 'e' || e == 'p' { + if ok { + switch { + case e == 'e' && prefix != 0 && prefix != '0': + s.errorf("%q exponent requires decimal mantissa", s.ch) + ok = false + case e == 'p' && prefix != 'x': + s.errorf("%q exponent requires hexadecimal mantissa", s.ch) + ok = false + } + } + s.nextch() + kind = FloatLit + if s.ch == '+' || s.ch == '-' { + s.nextch() + } + digsep = s.digits(10, nil) | digsep&2 // don't lose sep bit + if digsep&1 == 0 && ok { + s.errorf("exponent has no digits") + ok = false + } + } else if prefix == 'x' && kind == FloatLit && ok { + s.errorf("hexadecimal mantissa requires a 'p' exponent") + ok = false + } + + // suffix 'i' + if s.ch == 'i' { + kind = ImagLit + s.nextch() + } + + s.setLit(kind, ok) // do this now so we can use s.lit below + + if kind == IntLit && invalid >= 0 && ok { + s.errorAtf(invalid, "invalid digit %q in %s literal", s.lit[invalid], baseName(base)) + ok = false + } + + if digsep&2 != 0 && ok { + if i := invalidSep(s.lit); i >= 0 { + s.errorAtf(i, "'_' must separate successive digits") + ok = false + } + } + + s.bad = !ok // correct s.bad +} + +func baseName(base int) string { + switch base { + case 2: + return "binary" + case 8: + return "octal" + case 10: + return "decimal" + case 16: + return "hexadecimal" + } + panic("invalid base") +} + +// invalidSep returns the index of the first invalid separator in x, or -1. +func invalidSep(x string) int { + x1 := ' ' // prefix char, we only care if it's 'x' + d := '.' // digit, one of '_', '0' (a digit), or '.' (anything else) + i := 0 + + // a prefix counts as a digit + if len(x) >= 2 && x[0] == '0' { + x1 = lower(rune(x[1])) + if x1 == 'x' || x1 == 'o' || x1 == 'b' { + d = '0' + i = 2 + } + } + + // mantissa and exponent + for ; i < len(x); i++ { + p := d // previous digit + d = rune(x[i]) + switch { + case d == '_': + if p != '0' { + return i + } + case isDecimal(d) || x1 == 'x' && isHex(d): + d = '0' + default: + if p == '_' { + return i - 1 + } + d = '.' + } + } + if d == '_' { + return len(x) - 1 + } + + return -1 +} + +func (s *scanner) rune() { + ok := true + s.nextch() + + n := 0 + for ; ; n++ { + if s.ch == '\'' { + if ok { + if n == 0 { + s.errorf("empty rune literal or unescaped '") + ok = false + } else if n != 1 { + s.errorAtf(0, "more than one character in rune literal") + ok = false + } + } + s.nextch() + break + } + if s.ch == '\\' { + s.nextch() + if !s.escape('\'') { + ok = false + } + continue + } + if s.ch == '\n' { + if ok { + s.errorf("newline in rune literal") + ok = false + } + break + } + if s.ch < 0 { + if ok { + s.errorAtf(0, "rune literal not terminated") + ok = false + } + break + } + s.nextch() + } + + s.setLit(RuneLit, ok) +} + +func (s *scanner) stdString() { + ok := true + s.nextch() + + for { + if s.ch == '"' { + s.nextch() + break + } + if s.ch == '\\' { + s.nextch() + if !s.escape('"') { + ok = false + } + continue + } + if s.ch == '\n' { + s.errorf("newline in string") + ok = false + break + } + if s.ch < 0 { + s.errorAtf(0, "string not terminated") + ok = false + break + } + s.nextch() + } + + s.setLit(StringLit, ok) +} + +func (s *scanner) rawString() { + ok := true + s.nextch() + + for { + if s.ch == '`' { + s.nextch() + break + } + if s.ch < 0 { + s.errorAtf(0, "string not terminated") + ok = false + break + } + s.nextch() + } + // We leave CRs in the string since they are part of the + // literal (even though they are not part of the literal + // value). + + s.setLit(StringLit, ok) +} + +func (s *scanner) comment(text string) { + s.errorAtf(0, "%s", text) +} + +func (s *scanner) skipLine() { + // don't consume '\n' - needed for nlsemi logic + for s.ch >= 0 && s.ch != '\n' { + s.nextch() + } +} + +func (s *scanner) lineComment() { + // opening has already been consumed + + if s.mode&comments != 0 { + s.skipLine() + s.comment(string(s.segment())) + return + } + + // are we saving directives? or is this definitely not a directive? + if s.mode&directives == 0 || (s.ch != 'g' && s.ch != 'l') { + s.stop() + s.skipLine() + return + } + + // recognize go: or line directives + prefix := "go:" + if s.ch == 'l' { + prefix = "line " + } + for _, m := range prefix { + if s.ch != m { + s.stop() + s.skipLine() + return + } + s.nextch() + } + + // directive text + s.skipLine() + s.comment(string(s.segment())) +} + +func (s *scanner) skipComment() bool { + for s.ch >= 0 { + for s.ch == '*' { + s.nextch() + if s.ch == '/' { + s.nextch() + return true + } + } + s.nextch() + } + s.errorAtf(0, "comment not terminated") + return false +} + +func (s *scanner) fullComment() { + /* opening has already been consumed */ + + if s.mode&comments != 0 { + if s.skipComment() { + s.comment(string(s.segment())) + } + return + } + + if s.mode&directives == 0 || s.ch != 'l' { + s.stop() + s.skipComment() + return + } + + // recognize line directive + const prefix = "line " + for _, m := range prefix { + if s.ch != m { + s.stop() + s.skipComment() + return + } + s.nextch() + } + + // directive text + if s.skipComment() { + s.comment(string(s.segment())) + } +} + +func (s *scanner) escape(quote rune) bool { + var n int + var base, max uint32 + + switch s.ch { + case quote, 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\': + s.nextch() + return true + case '0', '1', '2', '3', '4', '5', '6', '7': + n, base, max = 3, 8, 255 + case 'x': + s.nextch() + n, base, max = 2, 16, 255 + case 'u': + s.nextch() + n, base, max = 4, 16, unicode.MaxRune + case 'U': + s.nextch() + n, base, max = 8, 16, unicode.MaxRune + default: + if s.ch < 0 { + return true // complain in caller about EOF + } + s.errorf("unknown escape") + return false + } + + var x uint32 + for i := n; i > 0; i-- { + if s.ch < 0 { + return true // complain in caller about EOF + } + d := base + if isDecimal(s.ch) { + d = uint32(s.ch) - '0' + } else if 'a' <= lower(s.ch) && lower(s.ch) <= 'f' { + d = uint32(lower(s.ch)) - 'a' + 10 + } + if d >= base { + s.errorf("invalid character %q in %s escape", s.ch, baseName(int(base))) + return false + } + // d < base + x = x*base + d + s.nextch() + } + + if x > max && base == 8 { + s.errorf("octal escape value %d > 255", x) + return false + } + + if x > max || 0xD800 <= x && x < 0xE000 /* surrogate range */ { + s.errorf("escape is invalid Unicode code point %#U", x) + return false + } + + return true +} diff --git a/go/src/cmd/compile/internal/syntax/scanner_test.go b/go/src/cmd/compile/internal/syntax/scanner_test.go new file mode 100644 index 0000000000000000000000000000000000000000..450ec1ff8a55f6138318e7dc84164bceaa4ca406 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/scanner_test.go @@ -0,0 +1,767 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import ( + "bytes" + "fmt" + "os" + "strings" + "testing" +) + +// errh is a default error handler for basic tests. +func errh(line, col uint, msg string) { + panic(fmt.Sprintf("%d:%d: %s", line, col, msg)) +} + +// Don't bother with other tests if TestSmoke doesn't pass. +func TestSmoke(t *testing.T) { + const src = "if (+foo\t+=..123/***/0.9_0e-0i'a'`raw`\"string\"..f;//$" + tokens := []token{_If, _Lparen, _Operator, _Name, _AssignOp, _Dot, _Literal, _Literal, _Literal, _Literal, _Literal, _Dot, _Dot, _Name, _Semi, _EOF} + + var got scanner + got.init(strings.NewReader(src), errh, 0) + for _, want := range tokens { + got.next() + if got.tok != want { + t.Errorf("%d:%d: got %s; want %s", got.line, got.col, got.tok, want) + continue + } + } +} + +// Once TestSmoke passes, run TestTokens next. +func TestTokens(t *testing.T) { + var got scanner + for _, want := range sampleTokens { + got.init(strings.NewReader(want.src), func(line, col uint, msg string) { + t.Errorf("%s:%d:%d: %s", want.src, line, col, msg) + }, 0) + got.next() + if got.tok != want.tok { + t.Errorf("%s: got %s; want %s", want.src, got.tok, want.tok) + continue + } + if (got.tok == _Name || got.tok == _Literal) && got.lit != want.src { + t.Errorf("%s: got %q; want %q", want.src, got.lit, want.src) + } + } +} + +func TestScanner(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + + filename := *src_ // can be changed via -src flag + src, err := os.Open(filename) + if err != nil { + t.Fatal(err) + } + defer src.Close() + + var s scanner + s.init(src, errh, 0) + for { + s.next() + if s.tok == _EOF { + break + } + if !testing.Verbose() { + continue + } + switch s.tok { + case _Name, _Literal: + fmt.Printf("%s:%d:%d: %s => %s\n", filename, s.line, s.col, s.tok, s.lit) + case _Operator: + fmt.Printf("%s:%d:%d: %s => %s (prec = %d)\n", filename, s.line, s.col, s.tok, s.op, s.prec) + default: + fmt.Printf("%s:%d:%d: %s\n", filename, s.line, s.col, s.tok) + } + } +} + +func TestEmbeddedTokens(t *testing.T) { + // make source + var buf bytes.Buffer + for i, s := range sampleTokens { + buf.WriteString("\t\t\t\t"[:i&3]) // leading indentation + buf.WriteString(s.src) // token + buf.WriteString(" "[:i&7]) // trailing spaces + fmt.Fprintf(&buf, "/*line foo:%d */ // bar\n", i) // comments + newline (don't crash w/o directive handler) + } + + // scan source + var got scanner + var src string + got.init(&buf, func(line, col uint, msg string) { + t.Fatalf("%s:%d:%d: %s", src, line, col, msg) + }, 0) + got.next() + for i, want := range sampleTokens { + src = want.src + nlsemi := false + + if got.line-linebase != uint(i) { + t.Errorf("%s: got line %d; want %d", src, got.line-linebase, i) + } + + if got.tok != want.tok { + t.Errorf("%s: got tok %s; want %s", src, got.tok, want.tok) + continue + } + + switch want.tok { + case _Semi: + if got.lit != "semicolon" { + t.Errorf("%s: got %s; want semicolon", src, got.lit) + } + + case _Name, _Literal: + if got.lit != want.src { + t.Errorf("%s: got lit %q; want %q", src, got.lit, want.src) + continue + } + nlsemi = true + + case _Operator, _AssignOp, _IncOp: + if got.op != want.op { + t.Errorf("%s: got op %s; want %s", src, got.op, want.op) + continue + } + if got.prec != want.prec { + t.Errorf("%s: got prec %d; want %d", src, got.prec, want.prec) + continue + } + nlsemi = want.tok == _IncOp + + case _Rparen, _Rbrack, _Rbrace, _Break, _Continue, _Fallthrough, _Return: + nlsemi = true + } + + if nlsemi { + got.next() + if got.tok != _Semi { + t.Errorf("%s: got tok %s; want ;", src, got.tok) + continue + } + if got.lit != "newline" { + t.Errorf("%s: got %s; want newline", src, got.lit) + } + } + + got.next() + } + + if got.tok != _EOF { + t.Errorf("got %q; want _EOF", got.tok) + } +} + +var sampleTokens = [...]struct { + tok token + src string + op Operator + prec int +}{ + // name samples + {_Name, "x", 0, 0}, + {_Name, "X123", 0, 0}, + {_Name, "foo", 0, 0}, + {_Name, "Foo123", 0, 0}, + {_Name, "foo_bar", 0, 0}, + {_Name, "_", 0, 0}, + {_Name, "_foobar", 0, 0}, + {_Name, "a۰۱۸", 0, 0}, + {_Name, "foo६४", 0, 0}, + {_Name, "bar9876", 0, 0}, + {_Name, "ŝ", 0, 0}, + {_Name, "ŝfoo", 0, 0}, + + // literal samples + {_Literal, "0", 0, 0}, + {_Literal, "1", 0, 0}, + {_Literal, "12345", 0, 0}, + {_Literal, "123456789012345678890123456789012345678890", 0, 0}, + {_Literal, "01234567", 0, 0}, + {_Literal, "0_1_234_567", 0, 0}, + {_Literal, "0X0", 0, 0}, + {_Literal, "0xcafebabe", 0, 0}, + {_Literal, "0x_cafe_babe", 0, 0}, + {_Literal, "0O0", 0, 0}, + {_Literal, "0o000", 0, 0}, + {_Literal, "0o_000", 0, 0}, + {_Literal, "0B1", 0, 0}, + {_Literal, "0b01100110", 0, 0}, + {_Literal, "0b_0110_0110", 0, 0}, + {_Literal, "0.", 0, 0}, + {_Literal, "0.e0", 0, 0}, + {_Literal, "0.e-1", 0, 0}, + {_Literal, "0.e+123", 0, 0}, + {_Literal, ".0", 0, 0}, + {_Literal, ".0E00", 0, 0}, + {_Literal, ".0E-0123", 0, 0}, + {_Literal, ".0E+12345678901234567890", 0, 0}, + {_Literal, ".45e1", 0, 0}, + {_Literal, "3.14159265", 0, 0}, + {_Literal, "1e0", 0, 0}, + {_Literal, "1e+100", 0, 0}, + {_Literal, "1e-100", 0, 0}, + {_Literal, "2.71828e-1000", 0, 0}, + {_Literal, "0i", 0, 0}, + {_Literal, "1i", 0, 0}, + {_Literal, "012345678901234567889i", 0, 0}, + {_Literal, "123456789012345678890i", 0, 0}, + {_Literal, "0.i", 0, 0}, + {_Literal, ".0i", 0, 0}, + {_Literal, "3.14159265i", 0, 0}, + {_Literal, "1e0i", 0, 0}, + {_Literal, "1e+100i", 0, 0}, + {_Literal, "1e-100i", 0, 0}, + {_Literal, "2.71828e-1000i", 0, 0}, + {_Literal, "'a'", 0, 0}, + {_Literal, "'\\000'", 0, 0}, + {_Literal, "'\\xFF'", 0, 0}, + {_Literal, "'\\uff16'", 0, 0}, + {_Literal, "'\\U0000ff16'", 0, 0}, + {_Literal, "`foobar`", 0, 0}, + {_Literal, "`foo\tbar`", 0, 0}, + {_Literal, "`\r`", 0, 0}, + + // operators + {_Operator, "!", Not, 0}, + {_Operator, "~", Tilde, 0}, + + {_Operator, "||", OrOr, precOrOr}, + + {_Operator, "&&", AndAnd, precAndAnd}, + + {_Operator, "==", Eql, precCmp}, + {_Operator, "!=", Neq, precCmp}, + {_Operator, "<", Lss, precCmp}, + {_Operator, "<=", Leq, precCmp}, + {_Operator, ">", Gtr, precCmp}, + {_Operator, ">=", Geq, precCmp}, + + {_Operator, "+", Add, precAdd}, + {_Operator, "-", Sub, precAdd}, + {_Operator, "|", Or, precAdd}, + {_Operator, "^", Xor, precAdd}, + + {_Star, "*", Mul, precMul}, + {_Operator, "/", Div, precMul}, + {_Operator, "%", Rem, precMul}, + {_Operator, "&", And, precMul}, + {_Operator, "&^", AndNot, precMul}, + {_Operator, "<<", Shl, precMul}, + {_Operator, ">>", Shr, precMul}, + + // assignment operations + {_AssignOp, "+=", Add, precAdd}, + {_AssignOp, "-=", Sub, precAdd}, + {_AssignOp, "|=", Or, precAdd}, + {_AssignOp, "^=", Xor, precAdd}, + + {_AssignOp, "*=", Mul, precMul}, + {_AssignOp, "/=", Div, precMul}, + {_AssignOp, "%=", Rem, precMul}, + {_AssignOp, "&=", And, precMul}, + {_AssignOp, "&^=", AndNot, precMul}, + {_AssignOp, "<<=", Shl, precMul}, + {_AssignOp, ">>=", Shr, precMul}, + + // other operations + {_IncOp, "++", Add, precAdd}, + {_IncOp, "--", Sub, precAdd}, + {_Assign, "=", 0, 0}, + {_Define, ":=", 0, 0}, + {_Arrow, "<-", 0, 0}, + + // delimiters + {_Lparen, "(", 0, 0}, + {_Lbrack, "[", 0, 0}, + {_Lbrace, "{", 0, 0}, + {_Rparen, ")", 0, 0}, + {_Rbrack, "]", 0, 0}, + {_Rbrace, "}", 0, 0}, + {_Comma, ",", 0, 0}, + {_Semi, ";", 0, 0}, + {_Colon, ":", 0, 0}, + {_Dot, ".", 0, 0}, + {_DotDotDot, "...", 0, 0}, + + // keywords + {_Break, "break", 0, 0}, + {_Case, "case", 0, 0}, + {_Chan, "chan", 0, 0}, + {_Const, "const", 0, 0}, + {_Continue, "continue", 0, 0}, + {_Default, "default", 0, 0}, + {_Defer, "defer", 0, 0}, + {_Else, "else", 0, 0}, + {_Fallthrough, "fallthrough", 0, 0}, + {_For, "for", 0, 0}, + {_Func, "func", 0, 0}, + {_Go, "go", 0, 0}, + {_Goto, "goto", 0, 0}, + {_If, "if", 0, 0}, + {_Import, "import", 0, 0}, + {_Interface, "interface", 0, 0}, + {_Map, "map", 0, 0}, + {_Package, "package", 0, 0}, + {_Range, "range", 0, 0}, + {_Return, "return", 0, 0}, + {_Select, "select", 0, 0}, + {_Struct, "struct", 0, 0}, + {_Switch, "switch", 0, 0}, + {_Type, "type", 0, 0}, + {_Var, "var", 0, 0}, +} + +func TestComments(t *testing.T) { + type comment struct { + line, col uint // 0-based + text string + } + + for _, test := range []struct { + src string + want comment + }{ + // no comments + {"no comment here", comment{0, 0, ""}}, + {" /", comment{0, 0, ""}}, + {"\n /*/", comment{0, 0, ""}}, + + //-style comments + {"// line comment\n", comment{0, 0, "// line comment"}}, + {"package p // line comment\n", comment{0, 10, "// line comment"}}, + {"//\n//\n\t// want this one\r\n", comment{2, 1, "// want this one\r"}}, + {"\n\n//\n", comment{2, 0, "//"}}, + {"//", comment{0, 0, "//"}}, + + /*-style comments */ + {"123/* regular comment */", comment{0, 3, "/* regular comment */"}}, + {"package p /* regular comment", comment{0, 0, ""}}, + {"\n\n\n/*\n*//* want this one */", comment{4, 2, "/* want this one */"}}, + {"\n\n/**/", comment{2, 0, "/**/"}}, + {"/*", comment{0, 0, ""}}, + } { + var s scanner + var got comment + s.init(strings.NewReader(test.src), func(line, col uint, msg string) { + if msg[0] != '/' { + // error + if msg != "comment not terminated" { + t.Errorf("%q: %s", test.src, msg) + } + return + } + got = comment{line - linebase, col - colbase, msg} // keep last one + }, comments) + + for { + s.next() + if s.tok == _EOF { + break + } + } + + want := test.want + if got.line != want.line || got.col != want.col { + t.Errorf("%q: got position %d:%d; want %d:%d", test.src, got.line, got.col, want.line, want.col) + } + if got.text != want.text { + t.Errorf("%q: got %q; want %q", test.src, got.text, want.text) + } + } +} + +func TestNumbers(t *testing.T) { + for _, test := range []struct { + kind LitKind + src, tokens, err string + }{ + // binaries + {IntLit, "0b0", "0b0", ""}, + {IntLit, "0b1010", "0b1010", ""}, + {IntLit, "0B1110", "0B1110", ""}, + + {IntLit, "0b", "0b", "binary literal has no digits"}, + {IntLit, "0b0190", "0b0190", "invalid digit '9' in binary literal"}, + {IntLit, "0b01a0", "0b01 a0", ""}, // only accept 0-9 + + {FloatLit, "0b.", "0b.", "invalid radix point in binary literal"}, + {FloatLit, "0b.1", "0b.1", "invalid radix point in binary literal"}, + {FloatLit, "0b1.0", "0b1.0", "invalid radix point in binary literal"}, + {FloatLit, "0b1e10", "0b1e10", "'e' exponent requires decimal mantissa"}, + {FloatLit, "0b1P-1", "0b1P-1", "'P' exponent requires hexadecimal mantissa"}, + + {ImagLit, "0b10i", "0b10i", ""}, + {ImagLit, "0b10.0i", "0b10.0i", "invalid radix point in binary literal"}, + + // octals + {IntLit, "0o0", "0o0", ""}, + {IntLit, "0o1234", "0o1234", ""}, + {IntLit, "0O1234", "0O1234", ""}, + + {IntLit, "0o", "0o", "octal literal has no digits"}, + {IntLit, "0o8123", "0o8123", "invalid digit '8' in octal literal"}, + {IntLit, "0o1293", "0o1293", "invalid digit '9' in octal literal"}, + {IntLit, "0o12a3", "0o12 a3", ""}, // only accept 0-9 + + {FloatLit, "0o.", "0o.", "invalid radix point in octal literal"}, + {FloatLit, "0o.2", "0o.2", "invalid radix point in octal literal"}, + {FloatLit, "0o1.2", "0o1.2", "invalid radix point in octal literal"}, + {FloatLit, "0o1E+2", "0o1E+2", "'E' exponent requires decimal mantissa"}, + {FloatLit, "0o1p10", "0o1p10", "'p' exponent requires hexadecimal mantissa"}, + + {ImagLit, "0o10i", "0o10i", ""}, + {ImagLit, "0o10e0i", "0o10e0i", "'e' exponent requires decimal mantissa"}, + + // 0-octals + {IntLit, "0", "0", ""}, + {IntLit, "0123", "0123", ""}, + + {IntLit, "08123", "08123", "invalid digit '8' in octal literal"}, + {IntLit, "01293", "01293", "invalid digit '9' in octal literal"}, + {IntLit, "0F.", "0 F .", ""}, // only accept 0-9 + {IntLit, "0123F.", "0123 F .", ""}, + {IntLit, "0123456x", "0123456 x", ""}, + + // decimals + {IntLit, "1", "1", ""}, + {IntLit, "1234", "1234", ""}, + + {IntLit, "1f", "1 f", ""}, // only accept 0-9 + + {ImagLit, "0i", "0i", ""}, + {ImagLit, "0678i", "0678i", ""}, + + // decimal floats + {FloatLit, "0.", "0.", ""}, + {FloatLit, "123.", "123.", ""}, + {FloatLit, "0123.", "0123.", ""}, + + {FloatLit, ".0", ".0", ""}, + {FloatLit, ".123", ".123", ""}, + {FloatLit, ".0123", ".0123", ""}, + + {FloatLit, "0.0", "0.0", ""}, + {FloatLit, "123.123", "123.123", ""}, + {FloatLit, "0123.0123", "0123.0123", ""}, + + {FloatLit, "0e0", "0e0", ""}, + {FloatLit, "123e+0", "123e+0", ""}, + {FloatLit, "0123E-1", "0123E-1", ""}, + + {FloatLit, "0.e+1", "0.e+1", ""}, + {FloatLit, "123.E-10", "123.E-10", ""}, + {FloatLit, "0123.e123", "0123.e123", ""}, + + {FloatLit, ".0e-1", ".0e-1", ""}, + {FloatLit, ".123E+10", ".123E+10", ""}, + {FloatLit, ".0123E123", ".0123E123", ""}, + + {FloatLit, "0.0e1", "0.0e1", ""}, + {FloatLit, "123.123E-10", "123.123E-10", ""}, + {FloatLit, "0123.0123e+456", "0123.0123e+456", ""}, + + {FloatLit, "0e", "0e", "exponent has no digits"}, + {FloatLit, "0E+", "0E+", "exponent has no digits"}, + {FloatLit, "1e+f", "1e+ f", "exponent has no digits"}, + {FloatLit, "0p0", "0p0", "'p' exponent requires hexadecimal mantissa"}, + {FloatLit, "1.0P-1", "1.0P-1", "'P' exponent requires hexadecimal mantissa"}, + + {ImagLit, "0.i", "0.i", ""}, + {ImagLit, ".123i", ".123i", ""}, + {ImagLit, "123.123i", "123.123i", ""}, + {ImagLit, "123e+0i", "123e+0i", ""}, + {ImagLit, "123.E-10i", "123.E-10i", ""}, + {ImagLit, ".123E+10i", ".123E+10i", ""}, + + // hexadecimals + {IntLit, "0x0", "0x0", ""}, + {IntLit, "0x1234", "0x1234", ""}, + {IntLit, "0xcafef00d", "0xcafef00d", ""}, + {IntLit, "0XCAFEF00D", "0XCAFEF00D", ""}, + + {IntLit, "0x", "0x", "hexadecimal literal has no digits"}, + {IntLit, "0x1g", "0x1 g", ""}, + + {ImagLit, "0xf00i", "0xf00i", ""}, + + // hexadecimal floats + {FloatLit, "0x0p0", "0x0p0", ""}, + {FloatLit, "0x12efp-123", "0x12efp-123", ""}, + {FloatLit, "0xABCD.p+0", "0xABCD.p+0", ""}, + {FloatLit, "0x.0189P-0", "0x.0189P-0", ""}, + {FloatLit, "0x1.ffffp+1023", "0x1.ffffp+1023", ""}, + + {FloatLit, "0x.", "0x.", "hexadecimal literal has no digits"}, + {FloatLit, "0x0.", "0x0.", "hexadecimal mantissa requires a 'p' exponent"}, + {FloatLit, "0x.0", "0x.0", "hexadecimal mantissa requires a 'p' exponent"}, + {FloatLit, "0x1.1", "0x1.1", "hexadecimal mantissa requires a 'p' exponent"}, + {FloatLit, "0x1.1e0", "0x1.1e0", "hexadecimal mantissa requires a 'p' exponent"}, + {FloatLit, "0x1.2gp1a", "0x1.2 gp1a", "hexadecimal mantissa requires a 'p' exponent"}, + {FloatLit, "0x0p", "0x0p", "exponent has no digits"}, + {FloatLit, "0xeP-", "0xeP-", "exponent has no digits"}, + {FloatLit, "0x1234PAB", "0x1234P AB", "exponent has no digits"}, + {FloatLit, "0x1.2p1a", "0x1.2p1 a", ""}, + + {ImagLit, "0xf00.bap+12i", "0xf00.bap+12i", ""}, + + // separators + {IntLit, "0b_1000_0001", "0b_1000_0001", ""}, + {IntLit, "0o_600", "0o_600", ""}, + {IntLit, "0_466", "0_466", ""}, + {IntLit, "1_000", "1_000", ""}, + {FloatLit, "1_000.000_1", "1_000.000_1", ""}, + {ImagLit, "10e+1_2_3i", "10e+1_2_3i", ""}, + {IntLit, "0x_f00d", "0x_f00d", ""}, + {FloatLit, "0x_f00d.0p1_2", "0x_f00d.0p1_2", ""}, + + {IntLit, "0b__1000", "0b__1000", "'_' must separate successive digits"}, + {IntLit, "0o60___0", "0o60___0", "'_' must separate successive digits"}, + {IntLit, "0466_", "0466_", "'_' must separate successive digits"}, + {FloatLit, "1_.", "1_.", "'_' must separate successive digits"}, + {FloatLit, "0._1", "0._1", "'_' must separate successive digits"}, + {FloatLit, "2.7_e0", "2.7_e0", "'_' must separate successive digits"}, + {ImagLit, "10e+12_i", "10e+12_i", "'_' must separate successive digits"}, + {IntLit, "0x___0", "0x___0", "'_' must separate successive digits"}, + {FloatLit, "0x1.0_p0", "0x1.0_p0", "'_' must separate successive digits"}, + } { + var s scanner + var err string + s.init(strings.NewReader(test.src), func(_, _ uint, msg string) { + if err == "" { + err = msg + } + }, 0) + + for i, want := range strings.Split(test.tokens, " ") { + err = "" + s.next() + + if err != "" && !s.bad { + t.Errorf("%q: got error but bad not set", test.src) + } + + // compute lit where s.lit is not defined + var lit string + switch s.tok { + case _Name, _Literal: + lit = s.lit + case _Dot: + lit = "." + } + + if i == 0 { + if s.tok != _Literal || s.kind != test.kind { + t.Errorf("%q: got token %s (kind = %d); want literal (kind = %d)", test.src, s.tok, s.kind, test.kind) + } + if err != test.err { + t.Errorf("%q: got error %q; want %q", test.src, err, test.err) + } + } + + if lit != want { + t.Errorf("%q: got literal %q (%s); want %s", test.src, lit, s.tok, want) + } + } + + // make sure we read all + s.next() + if s.tok == _Semi { + s.next() + } + if s.tok != _EOF { + t.Errorf("%q: got %s; want EOF", test.src, s.tok) + } + } +} + +func TestScanErrors(t *testing.T) { + for _, test := range []struct { + src, err string + line, col uint // 0-based + }{ + // Note: Positions for lexical errors are the earliest position + // where the error is apparent, not the beginning of the respective + // token. + + // rune-level errors + {"fo\x00o", "invalid NUL character", 0, 2}, + {"foo\n\ufeff bar", "invalid BOM in the middle of the file", 1, 0}, + {"foo\n\n\xff ", "invalid UTF-8 encoding", 2, 0}, + + // token-level errors + {"\u00BD" /* ½ */, "invalid character U+00BD '½' in identifier", 0, 0}, + {"\U0001d736\U0001d737\U0001d738_½" /* 𝜶𝜷𝜸_½ */, "invalid character U+00BD '½' in identifier", 0, 13 /* byte offset */}, + {"\U0001d7d8" /* 𝟘 */, "identifier cannot begin with digit U+1D7D8 '𝟘'", 0, 0}, + {"foo\U0001d7d8_½" /* foo𝟘_½ */, "invalid character U+00BD '½' in identifier", 0, 8 /* byte offset */}, + + {"x + #y", "invalid character U+0023 '#'", 0, 4}, + {"foo$bar = 0", "invalid character U+0024 '$'", 0, 3}, + {"0123456789", "invalid digit '8' in octal literal", 0, 8}, + {"0123456789. /* foobar", "comment not terminated", 0, 12}, // valid float constant + {"0123456789e0 /*\nfoobar", "comment not terminated", 0, 13}, // valid float constant + {"var a, b = 09, 07\n", "invalid digit '9' in octal literal", 0, 12}, + + {`''`, "empty rune literal or unescaped '", 0, 1}, + {"'\n", "newline in rune literal", 0, 1}, + {`'\`, "rune literal not terminated", 0, 0}, + {`'\'`, "rune literal not terminated", 0, 0}, + {`'\x`, "rune literal not terminated", 0, 0}, + {`'\x'`, "invalid character '\\'' in hexadecimal escape", 0, 3}, + {`'\y'`, "unknown escape", 0, 2}, + {`'\x0'`, "invalid character '\\'' in hexadecimal escape", 0, 4}, + {`'\00'`, "invalid character '\\'' in octal escape", 0, 4}, + {`'\377' /*`, "comment not terminated", 0, 7}, // valid octal escape + {`'\378`, "invalid character '8' in octal escape", 0, 4}, + {`'\400'`, "octal escape value 256 > 255", 0, 5}, + {`'xx`, "rune literal not terminated", 0, 0}, + {`'xx'`, "more than one character in rune literal", 0, 0}, + + {"\n \"foo\n", "newline in string", 1, 7}, + {`"`, "string not terminated", 0, 0}, + {`"foo`, "string not terminated", 0, 0}, + {"`", "string not terminated", 0, 0}, + {"`foo", "string not terminated", 0, 0}, + {"/*/", "comment not terminated", 0, 0}, + {"/*\n\nfoo", "comment not terminated", 0, 0}, + {`"\`, "string not terminated", 0, 0}, + {`"\"`, "string not terminated", 0, 0}, + {`"\x`, "string not terminated", 0, 0}, + {`"\x"`, "invalid character '\"' in hexadecimal escape", 0, 3}, + {`"\y"`, "unknown escape", 0, 2}, + {`"\x0"`, "invalid character '\"' in hexadecimal escape", 0, 4}, + {`"\00"`, "invalid character '\"' in octal escape", 0, 4}, + {`"\377" /*`, "comment not terminated", 0, 7}, // valid octal escape + {`"\378"`, "invalid character '8' in octal escape", 0, 4}, + {`"\400"`, "octal escape value 256 > 255", 0, 5}, + + {`s := "foo\z"`, "unknown escape", 0, 10}, + {`s := "foo\z00\nbar"`, "unknown escape", 0, 10}, + {`"\x`, "string not terminated", 0, 0}, + {`"\x"`, "invalid character '\"' in hexadecimal escape", 0, 3}, + {`var s string = "\x"`, "invalid character '\"' in hexadecimal escape", 0, 18}, + {`return "\Uffffffff"`, "escape is invalid Unicode code point U+FFFFFFFF", 0, 18}, + + {"0b.0", "invalid radix point in binary literal", 0, 2}, + {"0x.p0\n", "hexadecimal literal has no digits", 0, 3}, + + // former problem cases + {"package p\n\n\xef", "invalid UTF-8 encoding", 2, 0}, + } { + var s scanner + var line, col uint + var err string + s.init(strings.NewReader(test.src), func(l, c uint, msg string) { + if err == "" { + line, col = l-linebase, c-colbase + err = msg + } + }, 0) + + for { + s.next() + if s.tok == _EOF { + break + } + } + + if err != "" { + if err != test.err { + t.Errorf("%q: got err = %q; want %q", test.src, err, test.err) + } + if line != test.line { + t.Errorf("%q: got line = %d; want %d", test.src, line, test.line) + } + if col != test.col { + t.Errorf("%q: got col = %d; want %d", test.src, col, test.col) + } + } else { + t.Errorf("%q: got no error; want %q", test.src, test.err) + } + } +} + +func TestDirectives(t *testing.T) { + for _, src := range []string{ + "line", + "// line", + "//line", + "//line foo", + "//line foo%bar", + + "go", + "// go:", + "//go:", + "//go :foo", + "//go:foo", + "//go:foo%bar", + } { + got := "" + var s scanner + s.init(strings.NewReader(src), func(_, col uint, msg string) { + if col != colbase { + t.Errorf("%s: got col = %d; want %d", src, col, colbase) + } + if msg == "" { + t.Errorf("%s: handler called with empty msg", src) + } + got = msg + }, directives) + + s.next() + if strings.HasPrefix(src, "//line ") || strings.HasPrefix(src, "//go:") { + // handler should have been called + if got != src { + t.Errorf("got %s; want %s", got, src) + } + } else { + // handler should not have been called + if got != "" { + t.Errorf("got %s for %s", got, src) + } + } + } +} + +func TestIssue21938(t *testing.T) { + s := "/*" + strings.Repeat(" ", 4089) + "*/ .5" + + var got scanner + got.init(strings.NewReader(s), errh, 0) + got.next() + + if got.tok != _Literal || got.lit != ".5" { + t.Errorf("got %s %q; want %s %q", got.tok, got.lit, _Literal, ".5") + } +} + +func TestIssue33961(t *testing.T) { + literals := `08__ 0b.p 0b_._p 0x.e 0x.p` + for _, lit := range strings.Split(literals, " ") { + n := 0 + var got scanner + got.init(strings.NewReader(lit), func(_, _ uint, msg string) { + // fmt.Printf("%s: %s\n", lit, msg) // uncomment for debugging + n++ + }, 0) + got.next() + + if n != 1 { + t.Errorf("%q: got %d errors; want 1", lit, n) + continue + } + + if !got.bad { + t.Errorf("%q: got error but bad not set", lit) + } + } +} diff --git a/go/src/cmd/compile/internal/syntax/source.go b/go/src/cmd/compile/internal/syntax/source.go new file mode 100644 index 0000000000000000000000000000000000000000..01b592152bb7886885e2b870f513d81d7d20ead0 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/source.go @@ -0,0 +1,218 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements source, a buffered rune reader +// specialized for scanning Go code: Reading +// ASCII characters, maintaining current (line, col) +// position information, and recording of the most +// recently read source segment are highly optimized. +// This file is self-contained (go tool compile source.go +// compiles) and thus could be made into its own package. + +package syntax + +import ( + "io" + "unicode/utf8" +) + +// The source buffer is accessed using three indices b (begin), +// r (read), and e (end): +// +// - If b >= 0, it points to the beginning of a segment of most +// recently read characters (typically a Go literal). +// +// - r points to the byte immediately following the most recently +// read character ch, which starts at r-chw. +// +// - e points to the byte immediately following the last byte that +// was read into the buffer. +// +// The buffer content is terminated at buf[e] with the sentinel +// character utf8.RuneSelf. This makes it possible to test for +// the common case of ASCII characters with a single 'if' (see +// nextch method). +// +// +------ content in use -------+ +// v v +// buf [...read...|...segment...|ch|...unread...|s|...free...] +// ^ ^ ^ ^ +// | | | | +// b r-chw r e +// +// Invariant: -1 <= b < r <= e < len(buf) && buf[e] == sentinel + +type source struct { + in io.Reader + errh func(line, col uint, msg string) + + buf []byte // source buffer + ioerr error // pending I/O error, or nil + b, r, e int // buffer indices (see comment above) + line, col uint // source position of ch (0-based) + ch rune // most recently read character + chw int // width of ch +} + +const sentinel = utf8.RuneSelf + +func (s *source) init(in io.Reader, errh func(line, col uint, msg string)) { + s.in = in + s.errh = errh + + if s.buf == nil { + s.buf = make([]byte, nextSize(0)) + } + s.buf[0] = sentinel + s.ioerr = nil + s.b, s.r, s.e = -1, 0, 0 + s.line, s.col = 0, 0 + s.ch = ' ' + s.chw = 0 +} + +// starting points for line and column numbers +const linebase = 1 +const colbase = 1 + +// pos returns the (line, col) source position of s.ch. +func (s *source) pos() (line, col uint) { + return linebase + s.line, colbase + s.col +} + +// error reports the error msg at source position s.pos(). +func (s *source) error(msg string) { + line, col := s.pos() + s.errh(line, col, msg) +} + +// start starts a new active source segment (including s.ch). +// As long as stop has not been called, the active segment's +// bytes (excluding s.ch) may be retrieved by calling segment. +func (s *source) start() { s.b = s.r - s.chw } +func (s *source) stop() { s.b = -1 } +func (s *source) segment() []byte { return s.buf[s.b : s.r-s.chw] } + +// rewind rewinds the scanner's read position and character s.ch +// to the start of the currently active segment, which must not +// contain any newlines (otherwise position information will be +// incorrect). Currently, rewind is only needed for handling the +// source sequence ".."; it must not be called outside an active +// segment. +func (s *source) rewind() { + // ok to verify precondition - rewind is rarely called + if s.b < 0 { + panic("no active segment") + } + s.col -= uint(s.r - s.b) + s.r = s.b + s.nextch() +} + +func (s *source) nextch() { +redo: + s.col += uint(s.chw) + if s.ch == '\n' { + s.line++ + s.col = 0 + } + + // fast common case: at least one ASCII character + if s.ch = rune(s.buf[s.r]); s.ch < sentinel { + s.r++ + s.chw = 1 + if s.ch == 0 { + s.error("invalid NUL character") + goto redo + } + return + } + + // slower general case: add more bytes to buffer if we don't have a full rune + for s.e-s.r < utf8.UTFMax && !utf8.FullRune(s.buf[s.r:s.e]) && s.ioerr == nil { + s.fill() + } + + // EOF + if s.r == s.e { + if s.ioerr != io.EOF { + // ensure we never start with a '/' (e.g., rooted path) in the error message + s.error("I/O error: " + s.ioerr.Error()) + s.ioerr = nil + } + s.ch = -1 + s.chw = 0 + return + } + + s.ch, s.chw = utf8.DecodeRune(s.buf[s.r:s.e]) + s.r += s.chw + + if s.ch == utf8.RuneError && s.chw == 1 { + s.error("invalid UTF-8 encoding") + goto redo + } + + // BOM's are only allowed as the first character in a file + const BOM = 0xfeff + if s.ch == BOM { + if s.line > 0 || s.col > 0 { + s.error("invalid BOM in the middle of the file") + } + goto redo + } +} + +// fill reads more source bytes into s.buf. +// It returns with at least one more byte in the buffer, or with s.ioerr != nil. +func (s *source) fill() { + // determine content to preserve + b := s.r + if s.b >= 0 { + b = s.b + s.b = 0 // after buffer has grown or content has been moved down + } + content := s.buf[b:s.e] + + // grow buffer or move content down + if len(content)*2 > len(s.buf) { + s.buf = make([]byte, nextSize(len(s.buf))) + copy(s.buf, content) + } else if b > 0 { + copy(s.buf, content) + } + s.r -= b + s.e -= b + + // read more data: try a limited number of times + for i := 0; i < 10; i++ { + var n int + n, s.ioerr = s.in.Read(s.buf[s.e : len(s.buf)-1]) // -1 to leave space for sentinel + if n < 0 { + panic("negative read") // incorrect underlying io.Reader implementation + } + if n > 0 || s.ioerr != nil { + s.e += n + s.buf[s.e] = sentinel + return + } + // n == 0 + } + + s.buf[s.e] = sentinel + s.ioerr = io.ErrNoProgress +} + +// nextSize returns the next bigger size for a buffer of a given size. +func nextSize(size int) int { + const min = 4 << 10 // 4K: minimum buffer size + const max = 1 << 20 // 1M: maximum buffer size which is still doubled + if size < min { + return min + } + if size <= max { + return size << 1 + } + return size + max +} diff --git a/go/src/cmd/compile/internal/syntax/syntax.go b/go/src/cmd/compile/internal/syntax/syntax.go new file mode 100644 index 0000000000000000000000000000000000000000..dd8f2b8200457185d693f1fc54fb0e3581cf4ed5 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/syntax.go @@ -0,0 +1,94 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import ( + "fmt" + "io" + "os" +) + +// Mode describes the parser mode. +type Mode uint + +// Modes supported by the parser. +const ( + CheckBranches Mode = 1 << iota // check correct use of labels, break, continue, and goto statements +) + +// Error describes a syntax error. Error implements the error interface. +type Error struct { + Pos Pos + Msg string +} + +func (err Error) Error() string { + return fmt.Sprintf("%s: %s", err.Pos, err.Msg) +} + +var _ error = Error{} // verify that Error implements error + +// An ErrorHandler is called for each error encountered reading a .go file. +type ErrorHandler func(err error) + +// A Pragma value augments a package, import, const, func, type, or var declaration. +// Its meaning is entirely up to the PragmaHandler, +// except that nil is used to mean “no pragma seen.” +type Pragma any + +// A PragmaHandler is used to process //go: directives while scanning. +// It is passed the current pragma value, which starts out being nil, +// and it returns an updated pragma value. +// The text is the directive, with the "//" prefix stripped. +// The current pragma is saved at each package, import, const, func, type, or var +// declaration, into the File, ImportDecl, ConstDecl, FuncDecl, TypeDecl, or VarDecl node. +// +// If text is the empty string, the pragma is being returned +// to the handler unused, meaning it appeared before a non-declaration. +// The handler may wish to report an error. In this case, pos is the +// current parser position, not the position of the pragma itself. +// Blank specifies whether the line is blank before the pragma. +type PragmaHandler func(pos Pos, blank bool, text string, current Pragma) Pragma + +// Parse parses a single Go source file from src and returns the corresponding +// syntax tree. If there are errors, Parse will return the first error found, +// and a possibly partially constructed syntax tree, or nil. +// +// If errh != nil, it is called with each error encountered, and Parse will +// process as much source as possible. In this case, the returned syntax tree +// is only nil if no correct package clause was found. +// If errh is nil, Parse will terminate immediately upon encountering the first +// error, and the returned syntax tree is nil. +// +// If pragh != nil, it is called with each pragma encountered. +func Parse(base *PosBase, src io.Reader, errh ErrorHandler, pragh PragmaHandler, mode Mode) (_ *File, first error) { + defer func() { + if p := recover(); p != nil { + if err, ok := p.(Error); ok { + first = err + return + } + panic(p) + } + }() + + var p parser + p.init(base, src, errh, pragh, mode) + p.next() + return p.fileOrNil(), p.first +} + +// ParseFile behaves like Parse but it reads the source from the named file. +func ParseFile(filename string, errh ErrorHandler, pragh PragmaHandler, mode Mode) (*File, error) { + f, err := os.Open(filename) + if err != nil { + if errh != nil { + errh(err) + } + return nil, err + } + defer f.Close() + return Parse(NewFileBase(filename), f, errh, pragh, mode) +} diff --git a/go/src/cmd/compile/internal/syntax/testing.go b/go/src/cmd/compile/internal/syntax/testing.go new file mode 100644 index 0000000000000000000000000000000000000000..202b2efc3e0d913b3aaef4fafb8e98a27bdacc6a --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/testing.go @@ -0,0 +1,69 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements testing support. + +package syntax + +import ( + "io" + "regexp" +) + +// CommentsDo parses the given source and calls the provided handler for each +// comment or error. If the text provided to handler starts with a '/' it is +// the comment text; otherwise it is the error message. +func CommentsDo(src io.Reader, handler func(line, col uint, text string)) { + var s scanner + s.init(src, handler, comments) + for s.tok != _EOF { + s.next() + } +} + +// CommentMap collects all comments in the given src with comment text +// that matches the supplied regular expression rx and returns them as +// []Error lists in a map indexed by line number. The comment text is +// the comment with any comment markers ("//", "/*", or "*/") stripped. +// The position for each Error is the position of the token immediately +// preceding the comment and the Error message is the comment text, +// with all comments that are on the same line collected in a slice, in +// source order. If there is no preceding token (the matching comment +// appears at the beginning of the file), then the recorded position +// is unknown (line, col = 0, 0). If there are no matching comments, +// the result is nil. +func CommentMap(src io.Reader, rx *regexp.Regexp) (res map[uint][]Error) { + // position of previous token + var base *PosBase + var prev struct{ line, col uint } + + var s scanner + s.init(src, func(_, _ uint, text string) { + if text[0] != '/' { + return // not a comment, ignore + } + if text[1] == '*' { + text = text[:len(text)-2] // strip trailing */ + } + text = text[2:] // strip leading // or /* + if rx.MatchString(text) { + pos := MakePos(base, prev.line, prev.col) + err := Error{pos, text} + if res == nil { + res = make(map[uint][]Error) + } + res[prev.line] = append(res[prev.line], err) + } + }, comments) + + for s.tok != _EOF { + s.next() + if s.tok == _Semi && s.lit != "semicolon" { + continue // ignore automatically inserted semicolons + } + prev.line, prev.col = s.line, s.col + } + + return +} diff --git a/go/src/cmd/compile/internal/syntax/testing_test.go b/go/src/cmd/compile/internal/syntax/testing_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7e439c5523998698c632a561587c982eb29e5a26 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/testing_test.go @@ -0,0 +1,48 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import ( + "fmt" + "regexp" + "strings" + "testing" +) + +func TestCommentMap(t *testing.T) { + const src = `/* ERROR "0:0" */ /* ERROR "0:0" */ // ERROR "0:0" +// ERROR "0:0" +x /* ERROR "3:1" */ // ignore automatically inserted semicolon here +/* ERROR "3:1" */ // position of x on previous line + x /* ERROR "5:4" */ ; // do not ignore this semicolon +/* ERROR "5:24" */ // position of ; on previous line + package /* ERROR "7:2" */ // indented with tab + import /* ERROR "8:9" */ // indented with blanks +` + m := CommentMap(strings.NewReader(src), regexp.MustCompile("^ ERROR ")) + found := 0 // number of errors found + for line, errlist := range m { + for _, err := range errlist { + if err.Pos.Line() != line { + t.Errorf("%v: got map line %d; want %d", err, err.Pos.Line(), line) + continue + } + // err.Pos.Line() == line + + got := strings.TrimSpace(err.Msg[len(" ERROR "):]) + want := fmt.Sprintf(`"%d:%d"`, line, err.Pos.Col()) + if got != want { + t.Errorf("%v: got msg %q; want %q", err, got, want) + continue + } + found++ + } + } + + want := strings.Count(src, " ERROR ") + if found != want { + t.Errorf("CommentMap got %d errors; want %d", found, want) + } +} diff --git a/go/src/cmd/compile/internal/syntax/token_string.go b/go/src/cmd/compile/internal/syntax/token_string.go new file mode 100644 index 0000000000000000000000000000000000000000..ef295eb24b2bc9acb4b0d44ca9893f3bcb5067c2 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/token_string.go @@ -0,0 +1,70 @@ +// Code generated by "stringer -type token -linecomment tokens.go"; DO NOT EDIT. + +package syntax + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[_EOF-1] + _ = x[_Name-2] + _ = x[_Literal-3] + _ = x[_Operator-4] + _ = x[_AssignOp-5] + _ = x[_IncOp-6] + _ = x[_Assign-7] + _ = x[_Define-8] + _ = x[_Arrow-9] + _ = x[_Star-10] + _ = x[_Lparen-11] + _ = x[_Lbrack-12] + _ = x[_Lbrace-13] + _ = x[_Rparen-14] + _ = x[_Rbrack-15] + _ = x[_Rbrace-16] + _ = x[_Comma-17] + _ = x[_Semi-18] + _ = x[_Colon-19] + _ = x[_Dot-20] + _ = x[_DotDotDot-21] + _ = x[_Break-22] + _ = x[_Case-23] + _ = x[_Chan-24] + _ = x[_Const-25] + _ = x[_Continue-26] + _ = x[_Default-27] + _ = x[_Defer-28] + _ = x[_Else-29] + _ = x[_Fallthrough-30] + _ = x[_For-31] + _ = x[_Func-32] + _ = x[_Go-33] + _ = x[_Goto-34] + _ = x[_If-35] + _ = x[_Import-36] + _ = x[_Interface-37] + _ = x[_Map-38] + _ = x[_Package-39] + _ = x[_Range-40] + _ = x[_Return-41] + _ = x[_Select-42] + _ = x[_Struct-43] + _ = x[_Switch-44] + _ = x[_Type-45] + _ = x[_Var-46] + _ = x[tokenCount-47] +} + +const _token_name = "EOFnameliteralopop=opop=:=<-*([{)]},;:....breakcasechanconstcontinuedefaultdeferelsefallthroughforfuncgogotoifimportinterfacemappackagerangereturnselectstructswitchtypevar" + +var _token_index = [...]uint8{0, 3, 7, 14, 16, 19, 23, 24, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 42, 47, 51, 55, 60, 68, 75, 80, 84, 95, 98, 102, 104, 108, 110, 116, 125, 128, 135, 140, 146, 152, 158, 164, 168, 171, 171} + +func (i token) String() string { + i -= 1 + if i >= token(len(_token_index)-1) { + return "token(" + strconv.FormatInt(int64(i+1), 10) + ")" + } + return _token_name[_token_index[i]:_token_index[i+1]] +} diff --git a/go/src/cmd/compile/internal/syntax/tokens.go b/go/src/cmd/compile/internal/syntax/tokens.go new file mode 100644 index 0000000000000000000000000000000000000000..b08f699582fb6595fcd6046e31ee857f3766e808 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/tokens.go @@ -0,0 +1,159 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +type Token uint + +type token = Token + +//go:generate stringer -type token -linecomment tokens.go + +const ( + _ token = iota + _EOF // EOF + + // names and literals + _Name // name + _Literal // literal + + // operators and operations + // _Operator is excluding '*' (_Star) + _Operator // op + _AssignOp // op= + _IncOp // opop + _Assign // = + _Define // := + _Arrow // <- + _Star // * + + // delimiters + _Lparen // ( + _Lbrack // [ + _Lbrace // { + _Rparen // ) + _Rbrack // ] + _Rbrace // } + _Comma // , + _Semi // ; + _Colon // : + _Dot // . + _DotDotDot // ... + + // keywords + _Break // break + _Case // case + _Chan // chan + _Const // const + _Continue // continue + _Default // default + _Defer // defer + _Else // else + _Fallthrough // fallthrough + _For // for + _Func // func + _Go // go + _Goto // goto + _If // if + _Import // import + _Interface // interface + _Map // map + _Package // package + _Range // range + _Return // return + _Select // select + _Struct // struct + _Switch // switch + _Type // type + _Var // var + + // empty line comment to exclude it from .String + tokenCount // +) + +const ( + // for BranchStmt + Break = _Break + Continue = _Continue + Fallthrough = _Fallthrough + Goto = _Goto + + // for CallStmt + Go = _Go + Defer = _Defer +) + +// Make sure we have at most 64 tokens so we can use them in a set. +const _ uint64 = 1 << (tokenCount - 1) + +// contains reports whether tok is in tokset. +func contains(tokset uint64, tok token) bool { + return tokset&(1< + Geq // >= + + // precAdd + Add // + + Sub // - + Or // | + Xor // ^ + + // precMul + Mul // * + Div // / + Rem // % + And // & + AndNot // &^ + Shl // << + Shr // >> +) + +// Operator precedences +const ( + _ = iota + precOrOr + precAndAnd + precCmp + precAdd + precMul +) diff --git a/go/src/cmd/compile/internal/syntax/type.go b/go/src/cmd/compile/internal/syntax/type.go new file mode 100644 index 0000000000000000000000000000000000000000..0be7e250ee25625cc4ab8d12a635c9c87f05a4e6 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/type.go @@ -0,0 +1,78 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syntax + +import "go/constant" + +// A Type represents a type of Go. +// All types implement the Type interface. +// (This type originally lived in types2. We moved it here +// so we could depend on it from other packages without +// introducing an import cycle.) +type Type interface { + // Underlying returns the underlying type of a type. + // Underlying types are never Named, TypeParam, or Alias types. + // + // See https://go.dev/ref/spec#Underlying_types. + Underlying() Type + + // String returns a string representation of a type. + String() string +} + +// Expressions in the syntax package provide storage for +// the typechecker to record its results. This interface +// is the mechanism the typechecker uses to record results, +// and clients use to retrieve those results. +type typeInfo interface { + SetTypeInfo(TypeAndValue) + GetTypeInfo() TypeAndValue +} + +// A TypeAndValue records the type information, constant +// value if known, and various other flags associated with +// an expression. +// This type is similar to types2.TypeAndValue, but exposes +// none of types2's internals. +type TypeAndValue struct { + Type Type + Value constant.Value + exprFlags +} + +type exprFlags uint16 + +func (f exprFlags) IsVoid() bool { return f&1 != 0 } +func (f exprFlags) IsType() bool { return f&2 != 0 } +func (f exprFlags) IsBuiltin() bool { return f&4 != 0 } // a language builtin that resembles a function call, e.g., "make, append, new" +func (f exprFlags) IsValue() bool { return f&8 != 0 } +func (f exprFlags) IsNil() bool { return f&16 != 0 } +func (f exprFlags) Addressable() bool { return f&32 != 0 } +func (f exprFlags) Assignable() bool { return f&64 != 0 } +func (f exprFlags) HasOk() bool { return f&128 != 0 } +func (f exprFlags) IsRuntimeHelper() bool { return f&256 != 0 } // a runtime function called from transformed syntax + +func (f *exprFlags) SetIsVoid() { *f |= 1 } +func (f *exprFlags) SetIsType() { *f |= 2 } +func (f *exprFlags) SetIsBuiltin() { *f |= 4 } +func (f *exprFlags) SetIsValue() { *f |= 8 } +func (f *exprFlags) SetIsNil() { *f |= 16 } +func (f *exprFlags) SetAddressable() { *f |= 32 } +func (f *exprFlags) SetAssignable() { *f |= 64 } +func (f *exprFlags) SetHasOk() { *f |= 128 } +func (f *exprFlags) SetIsRuntimeHelper() { *f |= 256 } + +// a typeAndValue contains the results of typechecking an expression. +// It is embedded in expression nodes. +type typeAndValue struct { + tv TypeAndValue +} + +func (x *typeAndValue) SetTypeInfo(tv TypeAndValue) { + x.tv = tv +} +func (x *typeAndValue) GetTypeInfo() TypeAndValue { + return x.tv +} diff --git a/go/src/cmd/compile/internal/syntax/walk.go b/go/src/cmd/compile/internal/syntax/walk.go new file mode 100644 index 0000000000000000000000000000000000000000..b03a7c14b0d14e579fb6ec91d4334fd397735a24 --- /dev/null +++ b/go/src/cmd/compile/internal/syntax/walk.go @@ -0,0 +1,346 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements syntax tree walking. + +package syntax + +import "fmt" + +// Inspect traverses an AST in pre-order: it starts by calling f(root); +// root must not be nil. If f returns true, Inspect invokes f recursively +// for each of the non-nil children of root, followed by a call of f(nil). +// +// See Walk for caveats about shared nodes. +func Inspect(root Node, f func(Node) bool) { + Walk(root, inspector(f)) +} + +type inspector func(Node) bool + +func (v inspector) Visit(node Node) Visitor { + if v(node) { + return v + } + return nil +} + +// Walk traverses an AST in pre-order: It starts by calling +// v.Visit(node); node must not be nil. If the visitor w returned by +// v.Visit(node) is not nil, Walk is invoked recursively with visitor +// w for each of the non-nil children of node, followed by a call of +// w.Visit(nil). +// +// Some nodes may be shared among multiple parent nodes (e.g., types in +// field lists such as type T in "a, b, c T"). Such shared nodes are +// walked multiple times. +// TODO(gri) Revisit this design. It may make sense to walk those nodes +// only once. A place where this matters is types2.TestResolveIdents. +func Walk(root Node, v Visitor) { + walker{v}.node(root) +} + +// A Visitor's Visit method is invoked for each node encountered by Walk. +// If the result visitor w is not nil, Walk visits each of the children +// of node with the visitor w, followed by a call of w.Visit(nil). +type Visitor interface { + Visit(node Node) (w Visitor) +} + +type walker struct { + v Visitor +} + +func (w walker) node(n Node) { + if n == nil { + panic("nil node") + } + + w.v = w.v.Visit(n) + if w.v == nil { + return + } + + switch n := n.(type) { + // packages + case *File: + w.node(n.PkgName) + w.declList(n.DeclList) + + // declarations + case *ImportDecl: + if n.LocalPkgName != nil { + w.node(n.LocalPkgName) + } + w.node(n.Path) + + case *ConstDecl: + w.nameList(n.NameList) + if n.Type != nil { + w.node(n.Type) + } + if n.Values != nil { + w.node(n.Values) + } + + case *TypeDecl: + w.node(n.Name) + w.fieldList(n.TParamList) + w.node(n.Type) + + case *VarDecl: + w.nameList(n.NameList) + if n.Type != nil { + w.node(n.Type) + } + if n.Values != nil { + w.node(n.Values) + } + + case *FuncDecl: + if n.Recv != nil { + w.node(n.Recv) + } + w.node(n.Name) + w.fieldList(n.TParamList) + w.node(n.Type) + if n.Body != nil { + w.node(n.Body) + } + + // expressions + case *BadExpr: // nothing to do + case *Name: // nothing to do + case *BasicLit: // nothing to do + + case *CompositeLit: + if n.Type != nil { + w.node(n.Type) + } + w.exprList(n.ElemList) + + case *KeyValueExpr: + w.node(n.Key) + w.node(n.Value) + + case *FuncLit: + w.node(n.Type) + w.node(n.Body) + + case *ParenExpr: + w.node(n.X) + + case *SelectorExpr: + w.node(n.X) + w.node(n.Sel) + + case *IndexExpr: + w.node(n.X) + w.node(n.Index) + + case *SliceExpr: + w.node(n.X) + for _, x := range n.Index { + if x != nil { + w.node(x) + } + } + + case *AssertExpr: + w.node(n.X) + w.node(n.Type) + + case *TypeSwitchGuard: + if n.Lhs != nil { + w.node(n.Lhs) + } + w.node(n.X) + + case *Operation: + w.node(n.X) + if n.Y != nil { + w.node(n.Y) + } + + case *CallExpr: + w.node(n.Fun) + w.exprList(n.ArgList) + + case *ListExpr: + w.exprList(n.ElemList) + + // types + case *ArrayType: + if n.Len != nil { + w.node(n.Len) + } + w.node(n.Elem) + + case *SliceType: + w.node(n.Elem) + + case *DotsType: + w.node(n.Elem) + + case *StructType: + w.fieldList(n.FieldList) + for _, t := range n.TagList { + if t != nil { + w.node(t) + } + } + + case *Field: + if n.Name != nil { + w.node(n.Name) + } + w.node(n.Type) + + case *InterfaceType: + w.fieldList(n.MethodList) + + case *FuncType: + w.fieldList(n.ParamList) + w.fieldList(n.ResultList) + + case *MapType: + w.node(n.Key) + w.node(n.Value) + + case *ChanType: + w.node(n.Elem) + + // statements + case *EmptyStmt: // nothing to do + + case *LabeledStmt: + w.node(n.Label) + w.node(n.Stmt) + + case *BlockStmt: + w.stmtList(n.List) + + case *ExprStmt: + w.node(n.X) + + case *SendStmt: + w.node(n.Chan) + w.node(n.Value) + + case *DeclStmt: + w.declList(n.DeclList) + + case *AssignStmt: + w.node(n.Lhs) + if n.Rhs != nil { + w.node(n.Rhs) + } + + case *BranchStmt: + if n.Label != nil { + w.node(n.Label) + } + // Target points to nodes elsewhere in the syntax tree + + case *CallStmt: + w.node(n.Call) + + case *ReturnStmt: + if n.Results != nil { + w.node(n.Results) + } + + case *IfStmt: + if n.Init != nil { + w.node(n.Init) + } + w.node(n.Cond) + w.node(n.Then) + if n.Else != nil { + w.node(n.Else) + } + + case *ForStmt: + if n.Init != nil { + w.node(n.Init) + } + if n.Cond != nil { + w.node(n.Cond) + } + if n.Post != nil { + w.node(n.Post) + } + w.node(n.Body) + + case *SwitchStmt: + if n.Init != nil { + w.node(n.Init) + } + if n.Tag != nil { + w.node(n.Tag) + } + for _, s := range n.Body { + w.node(s) + } + + case *SelectStmt: + for _, s := range n.Body { + w.node(s) + } + + // helper nodes + case *RangeClause: + if n.Lhs != nil { + w.node(n.Lhs) + } + w.node(n.X) + + case *CaseClause: + if n.Cases != nil { + w.node(n.Cases) + } + w.stmtList(n.Body) + + case *CommClause: + if n.Comm != nil { + w.node(n.Comm) + } + w.stmtList(n.Body) + + default: + panic(fmt.Sprintf("internal error: unknown node type %T", n)) + } + + w.v.Visit(nil) +} + +func (w walker) declList(list []Decl) { + for _, n := range list { + w.node(n) + } +} + +func (w walker) exprList(list []Expr) { + for _, n := range list { + w.node(n) + } +} + +func (w walker) stmtList(list []Stmt) { + for _, n := range list { + w.node(n) + } +} + +func (w walker) nameList(list []*Name) { + for _, n := range list { + w.node(n) + } +} + +func (w walker) fieldList(list []*Field) { + for _, n := range list { + w.node(n) + } +} diff --git a/go/src/cmd/compile/internal/test/README b/go/src/cmd/compile/internal/test/README new file mode 100644 index 0000000000000000000000000000000000000000..3bf4a57a68f850ea01f0e764da3649d477f5ae81 --- /dev/null +++ b/go/src/cmd/compile/internal/test/README @@ -0,0 +1,4 @@ +This directory holds small tests and benchmarks of code +generated by the compiler. This code is not for importing, +and the tests are intended to verify that specific optimizations +are applied and correct. diff --git a/go/src/cmd/compile/internal/test/abiutils_test.go b/go/src/cmd/compile/internal/test/abiutils_test.go new file mode 100644 index 0000000000000000000000000000000000000000..da807f5a0aab4fee51ace7a58055cd905692ecde --- /dev/null +++ b/go/src/cmd/compile/internal/test/abiutils_test.go @@ -0,0 +1,398 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "bufio" + "cmd/compile/internal/abi" + "cmd/compile/internal/base" + "cmd/compile/internal/ssagen" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/obj/x86" + "cmd/internal/src" + "fmt" + "os" + "testing" +) + +// AMD64 registers available: +// - integer: RAX, RBX, RCX, RDI, RSI, R8, R9, r10, R11 +// - floating point: X0 - X14 +var configAMD64 = abi.NewABIConfig(9, 15, 0, 1) + +func TestMain(m *testing.M) { + ssagen.Arch.LinkArch = &x86.Linkamd64 + ssagen.Arch.REGSP = x86.REGSP + ssagen.Arch.MAXWIDTH = 1 << 50 + types.MaxWidth = ssagen.Arch.MAXWIDTH + base.Ctxt = obj.Linknew(ssagen.Arch.LinkArch) + base.Ctxt.DiagFunc = base.Errorf + base.Ctxt.DiagFlush = base.FlushErrors + base.Ctxt.Bso = bufio.NewWriter(os.Stdout) + types.LocalPkg = types.NewPkg("p", "local") + types.LocalPkg.Prefix = "p" + types.PtrSize = ssagen.Arch.LinkArch.PtrSize + types.RegSize = ssagen.Arch.LinkArch.RegSize + typecheck.InitUniverse() + os.Exit(m.Run()) +} + +func TestABIUtilsBasic1(t *testing.T) { + + // func(x int32) int32 + i32 := types.Types[types.TINT32] + ft := mkFuncType(nil, []*types.Type{i32}, []*types.Type{i32}) + + // expected results + exp := makeExpectedDump(` + IN 0: R{ I0 } spilloffset: 0 typ: int32 + OUT 0: R{ I0 } spilloffset: -1 typ: int32 + offsetToSpillArea: 0 spillAreaSize: 8 +`) + + abitest(t, ft, exp) +} + +func TestABIUtilsBasic2(t *testing.T) { + // func(p1 int8, p2 int16, p3 int32, p4 int64, + // p5 float32, p6 float32, p7 float64, p8 float64, + // p9 int8, p10 int16, p11 int32, p12 int64, + // p13 float32, p14 float32, p15 float64, p16 float64, + // p17 complex128, p18 complex128, p19 complex12, p20 complex128, + // p21 complex64, p22 int8, p23 in16, p24 int32, p25 int64, + // p26 int8, p27 in16, p28 int32, p29 int64) + // (r1 int32, r2 float64, r3 float64) { + i8 := types.Types[types.TINT8] + i16 := types.Types[types.TINT16] + i32 := types.Types[types.TINT32] + i64 := types.Types[types.TINT64] + f32 := types.Types[types.TFLOAT32] + f64 := types.Types[types.TFLOAT64] + c64 := types.Types[types.TCOMPLEX64] + c128 := types.Types[types.TCOMPLEX128] + ft := mkFuncType(nil, + []*types.Type{ + i8, i16, i32, i64, + f32, f32, f64, f64, + i8, i16, i32, i64, + f32, f32, f64, f64, + c128, c128, c128, c128, c64, + i8, i16, i32, i64, + i8, i16, i32, i64}, + []*types.Type{i32, f64, f64}) + exp := makeExpectedDump(` + IN 0: R{ I0 } spilloffset: 0 typ: int8 + IN 1: R{ I1 } spilloffset: 2 typ: int16 + IN 2: R{ I2 } spilloffset: 4 typ: int32 + IN 3: R{ I3 } spilloffset: 8 typ: int64 + IN 4: R{ F0 } spilloffset: 16 typ: float32 + IN 5: R{ F1 } spilloffset: 20 typ: float32 + IN 6: R{ F2 } spilloffset: 24 typ: float64 + IN 7: R{ F3 } spilloffset: 32 typ: float64 + IN 8: R{ I4 } spilloffset: 40 typ: int8 + IN 9: R{ I5 } spilloffset: 42 typ: int16 + IN 10: R{ I6 } spilloffset: 44 typ: int32 + IN 11: R{ I7 } spilloffset: 48 typ: int64 + IN 12: R{ F4 } spilloffset: 56 typ: float32 + IN 13: R{ F5 } spilloffset: 60 typ: float32 + IN 14: R{ F6 } spilloffset: 64 typ: float64 + IN 15: R{ F7 } spilloffset: 72 typ: float64 + IN 16: R{ F8 F9 } spilloffset: 80 typ: complex128 + IN 17: R{ F10 F11 } spilloffset: 96 typ: complex128 + IN 18: R{ F12 F13 } spilloffset: 112 typ: complex128 + IN 19: R{ } offset: 0 typ: complex128 + IN 20: R{ } offset: 16 typ: complex64 + IN 21: R{ I8 } spilloffset: 128 typ: int8 + IN 22: R{ } offset: 24 typ: int16 + IN 23: R{ } offset: 28 typ: int32 + IN 24: R{ } offset: 32 typ: int64 + IN 25: R{ } offset: 40 typ: int8 + IN 26: R{ } offset: 42 typ: int16 + IN 27: R{ } offset: 44 typ: int32 + IN 28: R{ } offset: 48 typ: int64 + OUT 0: R{ I0 } spilloffset: -1 typ: int32 + OUT 1: R{ F0 } spilloffset: -1 typ: float64 + OUT 2: R{ F1 } spilloffset: -1 typ: float64 + offsetToSpillArea: 56 spillAreaSize: 136 +`) + + abitest(t, ft, exp) +} + +func TestABIUtilsArrays(t *testing.T) { + // func(p1 [1]int32, p2 [0]int32, p3 [1][1]int32, p4 [2]int32) + // (r1 [2]int32, r2 [1]int32, r3 [0]int32, r4 [1][1]int32) { + i32 := types.Types[types.TINT32] + ae := types.NewArray(i32, 0) + a1 := types.NewArray(i32, 1) + a2 := types.NewArray(i32, 2) + aa1 := types.NewArray(a1, 1) + ft := mkFuncType(nil, []*types.Type{a1, ae, aa1, a2}, + []*types.Type{a2, a1, ae, aa1}) + + exp := makeExpectedDump(` + IN 0: R{ I0 } spilloffset: 0 typ: [1]int32 + IN 1: R{ } offset: 0 typ: [0]int32 + IN 2: R{ I1 } spilloffset: 4 typ: [1][1]int32 + IN 3: R{ } offset: 0 typ: [2]int32 + OUT 0: R{ } offset: 8 typ: [2]int32 + OUT 1: R{ I0 } spilloffset: -1 typ: [1]int32 + OUT 2: R{ } offset: 16 typ: [0]int32 + OUT 3: R{ I1 } spilloffset: -1 typ: [1][1]int32 + offsetToSpillArea: 16 spillAreaSize: 8 +`) + + abitest(t, ft, exp) +} + +func TestABIUtilsStruct1(t *testing.T) { + // type s struct { f1 int8; f2 int8; f3 struct {}; f4 int8; f5 int16) } + // func(p1 int6, p2 s, p3 int64) + // (r1 s, r2 int8, r3 int32) { + i8 := types.Types[types.TINT8] + i16 := types.Types[types.TINT16] + i32 := types.Types[types.TINT32] + i64 := types.Types[types.TINT64] + s := mkstruct(i8, i8, mkstruct(), i8, i16) + ft := mkFuncType(nil, []*types.Type{i8, s, i64}, + []*types.Type{s, i8, i32}) + + exp := makeExpectedDump(` + IN 0: R{ I0 } spilloffset: 0 typ: int8 + IN 1: R{ I1 I2 I3 I4 } spilloffset: 2 typ: struct { int8; int8; struct {}; int8; int16 } + IN 2: R{ I5 } spilloffset: 8 typ: int64 + OUT 0: R{ I0 I1 I2 I3 } spilloffset: -1 typ: struct { int8; int8; struct {}; int8; int16 } + OUT 1: R{ I4 } spilloffset: -1 typ: int8 + OUT 2: R{ I5 } spilloffset: -1 typ: int32 + offsetToSpillArea: 0 spillAreaSize: 16 +`) + + abitest(t, ft, exp) +} + +func TestABIUtilsStruct2(t *testing.T) { + // type s struct { f1 int64; f2 struct { } } + // type fs struct { f1 float64; f2 s; f3 struct { } } + // func(p1 s, p2 s, p3 fs) + // (r1 fs, r2 fs) + f64 := types.Types[types.TFLOAT64] + i64 := types.Types[types.TINT64] + s := mkstruct(i64, mkstruct()) + fs := mkstruct(f64, s, mkstruct()) + ft := mkFuncType(nil, []*types.Type{s, s, fs}, + []*types.Type{fs, fs}) + + exp := makeExpectedDump(` + IN 0: R{ I0 } spilloffset: 0 typ: struct { int64; struct {} } + IN 1: R{ I1 } spilloffset: 16 typ: struct { int64; struct {} } + IN 2: R{ F0 I2 } spilloffset: 32 typ: struct { float64; struct { int64; struct {} }; struct {} } + OUT 0: R{ F0 I0 } spilloffset: -1 typ: struct { float64; struct { int64; struct {} }; struct {} } + OUT 1: R{ F1 I1 } spilloffset: -1 typ: struct { float64; struct { int64; struct {} }; struct {} } + offsetToSpillArea: 0 spillAreaSize: 64 +`) + + abitest(t, ft, exp) +} + +// TestABIUtilsEmptyFieldAtEndOfStruct is testing to make sure +// the abi code is doing the right thing for struct types that have +// a trailing zero-sized field (where the we need to add padding). +func TestABIUtilsEmptyFieldAtEndOfStruct(t *testing.T) { + // type s struct { f1 [2]int64; f2 struct { } } + // type s2 struct { f1 [3]int16; f2 struct { } } + // type fs struct { f1 float64; f s; f3 struct { } } + // func(p1 s, p2 s, p3 fs) (r1 fs, r2 fs) + f64 := types.Types[types.TFLOAT64] + i64 := types.Types[types.TINT64] + i16 := types.Types[types.TINT16] + tb := types.Types[types.TBOOL] + ab2 := types.NewArray(tb, 2) + a2 := types.NewArray(i64, 2) + a3 := types.NewArray(i16, 3) + empty := mkstruct() + s := mkstruct(a2, empty) + s2 := mkstruct(a3, empty) + fs := mkstruct(f64, s, empty) + ft := mkFuncType(nil, []*types.Type{s, ab2, s2, fs, fs}, + []*types.Type{fs, ab2, fs}) + + exp := makeExpectedDump(` + IN 0: R{ } offset: 0 typ: struct { [2]int64; struct {} } + IN 1: R{ } offset: 24 typ: [2]bool + IN 2: R{ } offset: 26 typ: struct { [3]int16; struct {} } + IN 3: R{ } offset: 40 typ: struct { float64; struct { [2]int64; struct {} }; struct {} } + IN 4: R{ } offset: 80 typ: struct { float64; struct { [2]int64; struct {} }; struct {} } + OUT 0: R{ } offset: 120 typ: struct { float64; struct { [2]int64; struct {} }; struct {} } + OUT 1: R{ } offset: 160 typ: [2]bool + OUT 2: R{ } offset: 168 typ: struct { float64; struct { [2]int64; struct {} }; struct {} } + offsetToSpillArea: 208 spillAreaSize: 0 +`) + + abitest(t, ft, exp) + + // Test that NumParamRegs doesn't assign registers to trailing padding. + typ := mkstruct(i64, i64, mkstruct()) + have := configAMD64.NumParamRegs(typ) + if have != 2 { + t.Errorf("NumParams(%v): have %v, want %v", typ, have, 2) + } +} + +func TestABIUtilsSliceString(t *testing.T) { + // func(p1 []int32, p2 int8, p3 []int32, p4 int8, p5 string, + // p6 int64, p6 []intr32) (r1 string, r2 int64, r3 string, r4 []int32) + i32 := types.Types[types.TINT32] + sli32 := types.NewSlice(i32) + str := types.Types[types.TSTRING] + i8 := types.Types[types.TINT8] + i64 := types.Types[types.TINT64] + ft := mkFuncType(nil, []*types.Type{sli32, i8, sli32, i8, str, i8, i64, sli32}, + []*types.Type{str, i64, str, sli32}) + + exp := makeExpectedDump(` + IN 0: R{ I0 I1 I2 } spilloffset: 0 typ: []int32 + IN 1: R{ I3 } spilloffset: 24 typ: int8 + IN 2: R{ I4 I5 I6 } spilloffset: 32 typ: []int32 + IN 3: R{ I7 } spilloffset: 56 typ: int8 + IN 4: R{ } offset: 0 typ: string + IN 5: R{ I8 } spilloffset: 57 typ: int8 + IN 6: R{ } offset: 16 typ: int64 + IN 7: R{ } offset: 24 typ: []int32 + OUT 0: R{ I0 I1 } spilloffset: -1 typ: string + OUT 1: R{ I2 } spilloffset: -1 typ: int64 + OUT 2: R{ I3 I4 } spilloffset: -1 typ: string + OUT 3: R{ I5 I6 I7 } spilloffset: -1 typ: []int32 + offsetToSpillArea: 48 spillAreaSize: 64 +`) + + abitest(t, ft, exp) +} + +func TestABIUtilsMethod(t *testing.T) { + // type s1 struct { f1 int16; f2 int16; f3 int16 } + // func(p1 *s1, p2 [7]*s1, p3 float64, p4 int16, p5 int16, p6 int16) + // (r1 [7]*s1, r2 float64, r3 int64) + i16 := types.Types[types.TINT16] + i64 := types.Types[types.TINT64] + f64 := types.Types[types.TFLOAT64] + s1 := mkstruct(i16, i16, i16) + ps1 := types.NewPtr(s1) + a7 := types.NewArray(ps1, 7) + ft := mkFuncType(s1, []*types.Type{ps1, a7, f64, i16, i16, i16}, + []*types.Type{a7, f64, i64}) + + exp := makeExpectedDump(` + IN 0: R{ I0 I1 I2 } spilloffset: 0 typ: struct { int16; int16; int16 } + IN 1: R{ I3 } spilloffset: 8 typ: *struct { int16; int16; int16 } + IN 2: R{ } offset: 0 typ: [7]*struct { int16; int16; int16 } + IN 3: R{ F0 } spilloffset: 16 typ: float64 + IN 4: R{ I4 } spilloffset: 24 typ: int16 + IN 5: R{ I5 } spilloffset: 26 typ: int16 + IN 6: R{ I6 } spilloffset: 28 typ: int16 + OUT 0: R{ } offset: 56 typ: [7]*struct { int16; int16; int16 } + OUT 1: R{ F0 } spilloffset: -1 typ: float64 + OUT 2: R{ I0 } spilloffset: -1 typ: int64 + offsetToSpillArea: 112 spillAreaSize: 32 +`) + + abitest(t, ft, exp) +} + +func TestABIUtilsInterfaces(t *testing.T) { + // type s1 { f1 int16; f2 int16; f3 bool) + // type nei interface { ...() string } + // func(p1 s1, p2 interface{}, p3 interface{}, p4 nei, + // p5 *interface{}, p6 nei, p7 int64) + // (r1 interface{}, r2 nei, r3 bool) + ei := types.Types[types.TINTER] // interface{} + pei := types.NewPtr(ei) // *interface{} + fldt := mkFuncType(types.FakeRecvType(), []*types.Type{}, + []*types.Type{types.Types[types.TSTRING]}) + field := types.NewField(src.NoXPos, typecheck.Lookup("F"), fldt) + nei := types.NewInterface([]*types.Field{field}) + i16 := types.Types[types.TINT16] + tb := types.Types[types.TBOOL] + s1 := mkstruct(i16, i16, tb) + ft := mkFuncType(nil, []*types.Type{s1, ei, ei, nei, pei, nei, i16}, + []*types.Type{ei, nei, pei}) + + exp := makeExpectedDump(` + IN 0: R{ I0 I1 I2 } spilloffset: 0 typ: struct { int16; int16; bool } + IN 1: R{ I3 I4 } spilloffset: 8 typ: interface {} + IN 2: R{ I5 I6 } spilloffset: 24 typ: interface {} + IN 3: R{ I7 I8 } spilloffset: 40 typ: interface { F() string } + IN 4: R{ } offset: 0 typ: *interface {} + IN 5: R{ } offset: 8 typ: interface { F() string } + IN 6: R{ } offset: 24 typ: int16 + OUT 0: R{ I0 I1 } spilloffset: -1 typ: interface {} + OUT 1: R{ I2 I3 } spilloffset: -1 typ: interface { F() string } + OUT 2: R{ I4 } spilloffset: -1 typ: *interface {} + offsetToSpillArea: 32 spillAreaSize: 56 +`) + + abitest(t, ft, exp) +} + +func TestABINumParamRegs(t *testing.T) { + i8 := types.Types[types.TINT8] + i16 := types.Types[types.TINT16] + i32 := types.Types[types.TINT32] + i64 := types.Types[types.TINT64] + f32 := types.Types[types.TFLOAT32] + f64 := types.Types[types.TFLOAT64] + c64 := types.Types[types.TCOMPLEX64] + c128 := types.Types[types.TCOMPLEX128] + + s := mkstruct(i8, i8, mkstruct(), i8, i16) + a := mkstruct(s, s, s) + + nrtest(t, i8, 1) + nrtest(t, i16, 1) + nrtest(t, i32, 1) + nrtest(t, i64, 1) + nrtest(t, f32, 1) + nrtest(t, f64, 1) + nrtest(t, c64, 2) + nrtest(t, c128, 2) + nrtest(t, s, 4) + nrtest(t, a, 12) +} + +func TestABIUtilsComputePadding(t *testing.T) { + // type s1 { f1 int8; f2 int16; f3 struct{}; f4 int32; f5 int64 } + i8 := types.Types[types.TINT8] + i16 := types.Types[types.TINT16] + i32 := types.Types[types.TINT32] + i64 := types.Types[types.TINT64] + emptys := mkstruct() + s1 := mkstruct(i8, i16, emptys, i32, i64) + // func (p1 int32, p2 s1, p3 emptys, p4 [1]int32) + a1 := types.NewArray(i32, 1) + ft := mkFuncType(nil, []*types.Type{i32, s1, emptys, a1}, nil) + + // Run abitest() just to document what we're expected to see. + exp := makeExpectedDump(` + IN 0: R{ I0 } spilloffset: 0 typ: int32 + IN 1: R{ I1 I2 I3 I4 } spilloffset: 8 typ: struct { int8; int16; struct {}; int32; int64 } + IN 2: R{ } offset: 0 typ: struct {} + IN 3: R{ I5 } spilloffset: 24 typ: [1]int32 + offsetToSpillArea: 0 spillAreaSize: 32 +`) + abitest(t, ft, exp) + + // Analyze with full set of registers, then call ComputePadding + // on the second param, verifying the results. + regRes := configAMD64.ABIAnalyze(ft, false) + padding := make([]uint64, 32) + parm := regRes.InParams()[1] + padding = parm.ComputePadding(padding) + want := "[1 0 0 0]" + got := fmt.Sprintf("%+v", padding) + if got != want { + t.Errorf("padding mismatch: wanted %q got %q\n", want, got) + } +} diff --git a/go/src/cmd/compile/internal/test/abiutilsaux_test.go b/go/src/cmd/compile/internal/test/abiutilsaux_test.go new file mode 100644 index 0000000000000000000000000000000000000000..fb1c3983a8715c304beb42dec6485fe10e5250db --- /dev/null +++ b/go/src/cmd/compile/internal/test/abiutilsaux_test.go @@ -0,0 +1,131 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +// This file contains utility routines and harness infrastructure used +// by the ABI tests in "abiutils_test.go". + +import ( + "cmd/compile/internal/abi" + "cmd/compile/internal/ir" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/src" + "fmt" + "strings" + "testing" + "text/scanner" +) + +func mkParamResultField(t *types.Type, s *types.Sym, which ir.Class) *types.Field { + field := types.NewField(src.NoXPos, s, t) + n := ir.NewNameAt(src.NoXPos, s, t) + n.Class = which + field.Nname = n + return field +} + +// mkstruct is a helper routine to create a struct type with fields +// of the types specified in 'fieldtypes'. +func mkstruct(fieldtypes ...*types.Type) *types.Type { + fields := make([]*types.Field, len(fieldtypes)) + for k, t := range fieldtypes { + if t == nil { + panic("bad -- field has no type") + } + f := types.NewField(src.NoXPos, nil, t) + fields[k] = f + } + s := types.NewStruct(fields) + return s +} + +func mkFuncType(rcvr *types.Type, ins []*types.Type, outs []*types.Type) *types.Type { + q := typecheck.Lookup("?") + inf := []*types.Field{} + for _, it := range ins { + inf = append(inf, mkParamResultField(it, q, ir.PPARAM)) + } + outf := []*types.Field{} + for _, ot := range outs { + outf = append(outf, mkParamResultField(ot, q, ir.PPARAMOUT)) + } + var rf *types.Field + if rcvr != nil { + rf = mkParamResultField(rcvr, q, ir.PPARAM) + } + return types.NewSignature(rf, inf, outf) +} + +type expectedDump struct { + dump string + file string + line int +} + +func tokenize(src string) []string { + var s scanner.Scanner + s.Init(strings.NewReader(src)) + res := []string{} + for tok := s.Scan(); tok != scanner.EOF; tok = s.Scan() { + res = append(res, s.TokenText()) + } + return res +} + +func verifyParamResultOffset(t *testing.T, f *types.Field, r abi.ABIParamAssignment, which string, idx int) int { + n := f.Nname.(*ir.Name) + if n.FrameOffset() != int64(r.Offset()) { + t.Errorf("%s %d: got offset %d wanted %d t=%v", + which, idx, r.Offset(), n.Offset_, f.Type) + return 1 + } + return 0 +} + +func makeExpectedDump(e string) expectedDump { + return expectedDump{dump: e} +} + +func difftokens(atoks []string, etoks []string) string { + if len(atoks) != len(etoks) { + return fmt.Sprintf("expected %d tokens got %d", + len(etoks), len(atoks)) + } + for i := 0; i < len(etoks); i++ { + if etoks[i] == atoks[i] { + continue + } + + return fmt.Sprintf("diff at token %d: expected %q got %q", + i, etoks[i], atoks[i]) + } + return "" +} + +func nrtest(t *testing.T, ft *types.Type, expected int) { + types.CalcSize(ft) + got := configAMD64.NumParamRegs(ft) + if got != expected { + t.Errorf("]\nexpected num regs = %d, got %d, type %v", expected, got, ft) + } +} + +func abitest(t *testing.T, ft *types.Type, exp expectedDump) { + + types.CalcSize(ft) + + // Analyze with full set of registers. + regRes := configAMD64.ABIAnalyze(ft, false) + regResString := strings.TrimSpace(regRes.String()) + + // Check results. + reason := difftokens(tokenize(regResString), tokenize(exp.dump)) + if reason != "" { + t.Errorf("\nexpected:\n%s\ngot:\n%s\nreason: %s", + strings.TrimSpace(exp.dump), regResString, reason) + } + +} diff --git a/go/src/cmd/compile/internal/test/align_test.go b/go/src/cmd/compile/internal/test/align_test.go new file mode 100644 index 0000000000000000000000000000000000000000..32afc92973622705d416d492c0677bc9646340fe --- /dev/null +++ b/go/src/cmd/compile/internal/test/align_test.go @@ -0,0 +1,96 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test to make sure that equality functions (and hash +// functions) don't do unaligned reads on architectures +// that can't do unaligned reads. See issue 46283. + +package test + +import "testing" + +type T1 struct { + x float32 + a, b, c, d int16 // memequal64 +} +type T2 struct { + x float32 + a, b, c, d int32 // memequal128 +} + +type A2 [2]byte // eq uses a 2-byte load +type A4 [4]byte // eq uses a 4-byte load +type A8 [8]byte // eq uses an 8-byte load + +//go:noinline +func cmpT1(p, q *T1) { + if *p != *q { + panic("comparison test wrong") + } +} + +//go:noinline +func cmpT2(p, q *T2) { + if *p != *q { + panic("comparison test wrong") + } +} + +//go:noinline +func cmpA2(p, q *A2) { + if *p != *q { + panic("comparison test wrong") + } +} + +//go:noinline +func cmpA4(p, q *A4) { + if *p != *q { + panic("comparison test wrong") + } +} + +//go:noinline +func cmpA8(p, q *A8) { + if *p != *q { + panic("comparison test wrong") + } +} + +func TestAlignEqual(t *testing.T) { + cmpT1(&T1{}, &T1{}) + cmpT2(&T2{}, &T2{}) + + m1 := map[T1]bool{} + m1[T1{}] = true + m1[T1{}] = false + if len(m1) != 1 { + t.Fatalf("len(m1)=%d, want 1", len(m1)) + } + m2 := map[T2]bool{} + m2[T2{}] = true + m2[T2{}] = false + if len(m2) != 1 { + t.Fatalf("len(m2)=%d, want 1", len(m2)) + } + + type X2 struct { + y byte + z A2 + } + var x2 X2 + cmpA2(&x2.z, &A2{}) + type X4 struct { + y byte + z A4 + } + var x4 X4 + cmpA4(&x4.z, &A4{}) + type X8 struct { + y byte + z A8 + } + var x8 X8 + cmpA8(&x8.z, &A8{}) +} diff --git a/go/src/cmd/compile/internal/test/bench_test.go b/go/src/cmd/compile/internal/test/bench_test.go new file mode 100644 index 0000000000000000000000000000000000000000..694673a8f6abe437fb3afd3ca51505ba333364b7 --- /dev/null +++ b/go/src/cmd/compile/internal/test/bench_test.go @@ -0,0 +1,176 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import "testing" + +var globl int64 +var globl32 int32 + +func BenchmarkLoadAdd(b *testing.B) { + x := make([]int64, 1024) + y := make([]int64, 1024) + for i := 0; i < b.N; i++ { + var s int64 + for i := range x { + s ^= x[i] + y[i] + } + globl = s + } +} + +// Added for ppc64 extswsli on power9 +func BenchmarkExtShift(b *testing.B) { + x := make([]int32, 1024) + for i := 0; i < b.N; i++ { + var s int64 + for i := range x { + s ^= int64(x[i]+32) * 8 + } + globl = s + } +} + +func BenchmarkModify(b *testing.B) { + a := make([]int64, 1024) + v := globl + for i := 0; i < b.N; i++ { + for j := range a { + a[j] += v + } + } +} + +func BenchmarkMullImm(b *testing.B) { + x := make([]int32, 1024) + for i := 0; i < b.N; i++ { + var s int32 + for i := range x { + s += x[i] * 100 + } + globl32 = s + } +} + +func BenchmarkConstModify(b *testing.B) { + a := make([]int64, 1024) + for i := 0; i < b.N; i++ { + for j := range a { + a[j] += 3 + } + } +} + +func BenchmarkBitSet(b *testing.B) { + const N = 64 * 8 + a := make([]uint64, N/64) + for i := 0; i < b.N; i++ { + for j := uint64(0); j < N; j++ { + a[j/64] |= 1 << (j % 64) + } + } +} + +func BenchmarkBitClear(b *testing.B) { + const N = 64 * 8 + a := make([]uint64, N/64) + for i := 0; i < b.N; i++ { + for j := uint64(0); j < N; j++ { + a[j/64] &^= 1 << (j % 64) + } + } +} + +func BenchmarkBitToggle(b *testing.B) { + const N = 64 * 8 + a := make([]uint64, N/64) + for i := 0; i < b.N; i++ { + for j := uint64(0); j < N; j++ { + a[j/64] ^= 1 << (j % 64) + } + } +} + +func BenchmarkBitSetConst(b *testing.B) { + const N = 64 + a := make([]uint64, N) + for i := 0; i < b.N; i++ { + for j := range a { + a[j] |= 1 << 37 + } + } +} + +func BenchmarkBitClearConst(b *testing.B) { + const N = 64 + a := make([]uint64, N) + for i := 0; i < b.N; i++ { + for j := range a { + a[j] &^= 1 << 37 + } + } +} + +func BenchmarkBitToggleConst(b *testing.B) { + const N = 64 + a := make([]uint64, N) + for i := 0; i < b.N; i++ { + for j := range a { + a[j] ^= 1 << 37 + } + } +} + +func BenchmarkMulNeg(b *testing.B) { + x := make([]int64, 1024) + for i := 0; i < b.N; i++ { + var s int64 + for i := range x { + s = (-x[i]) * 11 + } + globl = s + } +} + +func BenchmarkMul2Neg(b *testing.B) { + x := make([]int64, 1024) + y := make([]int64, 1024) + for i := 0; i < b.N; i++ { + var s int64 + for i := range x { + s = (-x[i]) * (-y[i]) + } + globl = s + } +} + +func BenchmarkSimplifyNegMul(b *testing.B) { + x := make([]int64, 1024) + y := make([]int64, 1024) + b.ResetTimer() + for i := 0; i < b.N; i++ { + var s int64 + for i := range x { + s = -(-x[i] * y[i]) + } + globl = s + } +} + +func BenchmarkSimplifyNegDiv(b *testing.B) { + x := make([]int64, 1024) + y := make([]int64, 1024) + for i := range y { + y[i] = 42 + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + var s int64 + for i := range x { + s = -(-x[i] / y[i]) + } + globl = s + } +} diff --git a/go/src/cmd/compile/internal/test/clobberdead_test.go b/go/src/cmd/compile/internal/test/clobberdead_test.go new file mode 100644 index 0000000000000000000000000000000000000000..80d9678c082866d2cd5ca7a6cba68336614db5f4 --- /dev/null +++ b/go/src/cmd/compile/internal/test/clobberdead_test.go @@ -0,0 +1,54 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "internal/testenv" + "os" + "path/filepath" + "testing" +) + +const helloSrc = ` +package main +import "fmt" +func main() { fmt.Println("hello") } +` + +func TestClobberDead(t *testing.T) { + // Test that clobberdead mode generates correct program. + runHello(t, "-clobberdead") +} + +func TestClobberDeadReg(t *testing.T) { + // Test that clobberdeadreg mode generates correct program. + runHello(t, "-clobberdeadreg") +} + +func runHello(t *testing.T, flag string) { + if testing.Short() { + // This test rebuilds the runtime with a special flag, which + // takes a while. + t.Skip("skip in short mode") + } + testenv.MustHaveGoRun(t) + t.Parallel() + + tmpdir := t.TempDir() + src := filepath.Join(tmpdir, "x.go") + err := os.WriteFile(src, []byte(helloSrc), 0644) + if err != nil { + t.Fatalf("write file failed: %v", err) + } + + cmd := testenv.Command(t, testenv.GoToolPath(t), "run", "-gcflags=all="+flag, src) + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("go run failed: %v\n%s", err, out) + } + if string(out) != "hello\n" { + t.Errorf("wrong output: got %q, want %q", out, "hello\n") + } +} diff --git a/go/src/cmd/compile/internal/test/constFold_test.go b/go/src/cmd/compile/internal/test/constFold_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7159f0ed33a375960c782f69940446d4c7ae5278 --- /dev/null +++ b/go/src/cmd/compile/internal/test/constFold_test.go @@ -0,0 +1,18111 @@ +// run +// Code generated by gen/constFoldGen.go. DO NOT EDIT. + +package test + +import "testing" + +func TestConstFolduint64add(t *testing.T) { + var x, y, r uint64 + x = 0 + y = 0 + r = x + y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "+", r) + } + y = 1 + r = x + y + if r != 1 { + t.Errorf("0 %s 1 = %d, want 1", "+", r) + } + y = 4294967296 + r = x + y + if r != 4294967296 { + t.Errorf("0 %s 4294967296 = %d, want 4294967296", "+", r) + } + y = 18446744073709551615 + r = x + y + if r != 18446744073709551615 { + t.Errorf("0 %s 18446744073709551615 = %d, want 18446744073709551615", "+", r) + } + x = 1 + y = 0 + r = x + y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "+", r) + } + y = 1 + r = x + y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "+", r) + } + y = 4294967296 + r = x + y + if r != 4294967297 { + t.Errorf("1 %s 4294967296 = %d, want 4294967297", "+", r) + } + y = 18446744073709551615 + r = x + y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", "+", r) + } + x = 4294967296 + y = 0 + r = x + y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "+", r) + } + y = 1 + r = x + y + if r != 4294967297 { + t.Errorf("4294967296 %s 1 = %d, want 4294967297", "+", r) + } + y = 4294967296 + r = x + y + if r != 8589934592 { + t.Errorf("4294967296 %s 4294967296 = %d, want 8589934592", "+", r) + } + y = 18446744073709551615 + r = x + y + if r != 4294967295 { + t.Errorf("4294967296 %s 18446744073709551615 = %d, want 4294967295", "+", r) + } + x = 18446744073709551615 + y = 0 + r = x + y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 0 = %d, want 18446744073709551615", "+", r) + } + y = 1 + r = x + y + if r != 0 { + t.Errorf("18446744073709551615 %s 1 = %d, want 0", "+", r) + } + y = 4294967296 + r = x + y + if r != 4294967295 { + t.Errorf("18446744073709551615 %s 4294967296 = %d, want 4294967295", "+", r) + } + y = 18446744073709551615 + r = x + y + if r != 18446744073709551614 { + t.Errorf("18446744073709551615 %s 18446744073709551615 = %d, want 18446744073709551614", "+", r) + } +} +func TestConstFolduint64sub(t *testing.T) { + var x, y, r uint64 + x = 0 + y = 0 + r = x - y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "-", r) + } + y = 1 + r = x - y + if r != 18446744073709551615 { + t.Errorf("0 %s 1 = %d, want 18446744073709551615", "-", r) + } + y = 4294967296 + r = x - y + if r != 18446744069414584320 { + t.Errorf("0 %s 4294967296 = %d, want 18446744069414584320", "-", r) + } + y = 18446744073709551615 + r = x - y + if r != 1 { + t.Errorf("0 %s 18446744073709551615 = %d, want 1", "-", r) + } + x = 1 + y = 0 + r = x - y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "-", r) + } + y = 1 + r = x - y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "-", r) + } + y = 4294967296 + r = x - y + if r != 18446744069414584321 { + t.Errorf("1 %s 4294967296 = %d, want 18446744069414584321", "-", r) + } + y = 18446744073709551615 + r = x - y + if r != 2 { + t.Errorf("1 %s 18446744073709551615 = %d, want 2", "-", r) + } + x = 4294967296 + y = 0 + r = x - y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "-", r) + } + y = 1 + r = x - y + if r != 4294967295 { + t.Errorf("4294967296 %s 1 = %d, want 4294967295", "-", r) + } + y = 4294967296 + r = x - y + if r != 0 { + t.Errorf("4294967296 %s 4294967296 = %d, want 0", "-", r) + } + y = 18446744073709551615 + r = x - y + if r != 4294967297 { + t.Errorf("4294967296 %s 18446744073709551615 = %d, want 4294967297", "-", r) + } + x = 18446744073709551615 + y = 0 + r = x - y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 0 = %d, want 18446744073709551615", "-", r) + } + y = 1 + r = x - y + if r != 18446744073709551614 { + t.Errorf("18446744073709551615 %s 1 = %d, want 18446744073709551614", "-", r) + } + y = 4294967296 + r = x - y + if r != 18446744069414584319 { + t.Errorf("18446744073709551615 %s 4294967296 = %d, want 18446744069414584319", "-", r) + } + y = 18446744073709551615 + r = x - y + if r != 0 { + t.Errorf("18446744073709551615 %s 18446744073709551615 = %d, want 0", "-", r) + } +} +func TestConstFolduint64div(t *testing.T) { + var x, y, r uint64 + x = 0 + y = 1 + r = x / y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "/", r) + } + y = 4294967296 + r = x / y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "/", r) + } + y = 18446744073709551615 + r = x / y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "/", r) + } + x = 1 + y = 1 + r = x / y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "/", r) + } + y = 4294967296 + r = x / y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", "/", r) + } + y = 18446744073709551615 + r = x / y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", "/", r) + } + x = 4294967296 + y = 1 + r = x / y + if r != 4294967296 { + t.Errorf("4294967296 %s 1 = %d, want 4294967296", "/", r) + } + y = 4294967296 + r = x / y + if r != 1 { + t.Errorf("4294967296 %s 4294967296 = %d, want 1", "/", r) + } + y = 18446744073709551615 + r = x / y + if r != 0 { + t.Errorf("4294967296 %s 18446744073709551615 = %d, want 0", "/", r) + } + x = 18446744073709551615 + y = 1 + r = x / y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 1 = %d, want 18446744073709551615", "/", r) + } + y = 4294967296 + r = x / y + if r != 4294967295 { + t.Errorf("18446744073709551615 %s 4294967296 = %d, want 4294967295", "/", r) + } + y = 18446744073709551615 + r = x / y + if r != 1 { + t.Errorf("18446744073709551615 %s 18446744073709551615 = %d, want 1", "/", r) + } +} +func TestConstFolduint64mul(t *testing.T) { + var x, y, r uint64 + x = 0 + y = 0 + r = x * y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "*", r) + } + y = 4294967296 + r = x * y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "*", r) + } + y = 18446744073709551615 + r = x * y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "*", r) + } + x = 1 + y = 0 + r = x * y + if r != 0 { + t.Errorf("1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "*", r) + } + y = 4294967296 + r = x * y + if r != 4294967296 { + t.Errorf("1 %s 4294967296 = %d, want 4294967296", "*", r) + } + y = 18446744073709551615 + r = x * y + if r != 18446744073709551615 { + t.Errorf("1 %s 18446744073709551615 = %d, want 18446744073709551615", "*", r) + } + x = 4294967296 + y = 0 + r = x * y + if r != 0 { + t.Errorf("4294967296 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 4294967296 { + t.Errorf("4294967296 %s 1 = %d, want 4294967296", "*", r) + } + y = 4294967296 + r = x * y + if r != 0 { + t.Errorf("4294967296 %s 4294967296 = %d, want 0", "*", r) + } + y = 18446744073709551615 + r = x * y + if r != 18446744069414584320 { + t.Errorf("4294967296 %s 18446744073709551615 = %d, want 18446744069414584320", "*", r) + } + x = 18446744073709551615 + y = 0 + r = x * y + if r != 0 { + t.Errorf("18446744073709551615 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 1 = %d, want 18446744073709551615", "*", r) + } + y = 4294967296 + r = x * y + if r != 18446744069414584320 { + t.Errorf("18446744073709551615 %s 4294967296 = %d, want 18446744069414584320", "*", r) + } + y = 18446744073709551615 + r = x * y + if r != 1 { + t.Errorf("18446744073709551615 %s 18446744073709551615 = %d, want 1", "*", r) + } +} +func TestConstFolduint64mod(t *testing.T) { + var x, y, r uint64 + x = 0 + y = 1 + r = x % y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "%", r) + } + y = 18446744073709551615 + r = x % y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "%", r) + } + x = 1 + y = 1 + r = x % y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 1 { + t.Errorf("1 %s 4294967296 = %d, want 1", "%", r) + } + y = 18446744073709551615 + r = x % y + if r != 1 { + t.Errorf("1 %s 18446744073709551615 = %d, want 1", "%", r) + } + x = 4294967296 + y = 1 + r = x % y + if r != 0 { + t.Errorf("4294967296 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 0 { + t.Errorf("4294967296 %s 4294967296 = %d, want 0", "%", r) + } + y = 18446744073709551615 + r = x % y + if r != 4294967296 { + t.Errorf("4294967296 %s 18446744073709551615 = %d, want 4294967296", "%", r) + } + x = 18446744073709551615 + y = 1 + r = x % y + if r != 0 { + t.Errorf("18446744073709551615 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 4294967295 { + t.Errorf("18446744073709551615 %s 4294967296 = %d, want 4294967295", "%", r) + } + y = 18446744073709551615 + r = x % y + if r != 0 { + t.Errorf("18446744073709551615 %s 18446744073709551615 = %d, want 0", "%", r) + } +} +func TestConstFoldint64add(t *testing.T) { + var x, y, r int64 + x = -9223372036854775808 + y = -9223372036854775808 + r = x + y + if r != 0 { + t.Errorf("-9223372036854775808 %s -9223372036854775808 = %d, want 0", "+", r) + } + y = -9223372036854775807 + r = x + y + if r != 1 { + t.Errorf("-9223372036854775808 %s -9223372036854775807 = %d, want 1", "+", r) + } + y = -4294967296 + r = x + y + if r != 9223372032559808512 { + t.Errorf("-9223372036854775808 %s -4294967296 = %d, want 9223372032559808512", "+", r) + } + y = -1 + r = x + y + if r != 9223372036854775807 { + t.Errorf("-9223372036854775808 %s -1 = %d, want 9223372036854775807", "+", r) + } + y = 0 + r = x + y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 0 = %d, want -9223372036854775808", "+", r) + } + y = 1 + r = x + y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775808 %s 1 = %d, want -9223372036854775807", "+", r) + } + y = 4294967296 + r = x + y + if r != -9223372032559808512 { + t.Errorf("-9223372036854775808 %s 4294967296 = %d, want -9223372032559808512", "+", r) + } + y = 9223372036854775806 + r = x + y + if r != -2 { + t.Errorf("-9223372036854775808 %s 9223372036854775806 = %d, want -2", "+", r) + } + y = 9223372036854775807 + r = x + y + if r != -1 { + t.Errorf("-9223372036854775808 %s 9223372036854775807 = %d, want -1", "+", r) + } + x = -9223372036854775807 + y = -9223372036854775808 + r = x + y + if r != 1 { + t.Errorf("-9223372036854775807 %s -9223372036854775808 = %d, want 1", "+", r) + } + y = -9223372036854775807 + r = x + y + if r != 2 { + t.Errorf("-9223372036854775807 %s -9223372036854775807 = %d, want 2", "+", r) + } + y = -4294967296 + r = x + y + if r != 9223372032559808513 { + t.Errorf("-9223372036854775807 %s -4294967296 = %d, want 9223372032559808513", "+", r) + } + y = -1 + r = x + y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775807 %s -1 = %d, want -9223372036854775808", "+", r) + } + y = 0 + r = x + y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 0 = %d, want -9223372036854775807", "+", r) + } + y = 1 + r = x + y + if r != -9223372036854775806 { + t.Errorf("-9223372036854775807 %s 1 = %d, want -9223372036854775806", "+", r) + } + y = 4294967296 + r = x + y + if r != -9223372032559808511 { + t.Errorf("-9223372036854775807 %s 4294967296 = %d, want -9223372032559808511", "+", r) + } + y = 9223372036854775806 + r = x + y + if r != -1 { + t.Errorf("-9223372036854775807 %s 9223372036854775806 = %d, want -1", "+", r) + } + y = 9223372036854775807 + r = x + y + if r != 0 { + t.Errorf("-9223372036854775807 %s 9223372036854775807 = %d, want 0", "+", r) + } + x = -4294967296 + y = -9223372036854775808 + r = x + y + if r != 9223372032559808512 { + t.Errorf("-4294967296 %s -9223372036854775808 = %d, want 9223372032559808512", "+", r) + } + y = -9223372036854775807 + r = x + y + if r != 9223372032559808513 { + t.Errorf("-4294967296 %s -9223372036854775807 = %d, want 9223372032559808513", "+", r) + } + y = -4294967296 + r = x + y + if r != -8589934592 { + t.Errorf("-4294967296 %s -4294967296 = %d, want -8589934592", "+", r) + } + y = -1 + r = x + y + if r != -4294967297 { + t.Errorf("-4294967296 %s -1 = %d, want -4294967297", "+", r) + } + y = 0 + r = x + y + if r != -4294967296 { + t.Errorf("-4294967296 %s 0 = %d, want -4294967296", "+", r) + } + y = 1 + r = x + y + if r != -4294967295 { + t.Errorf("-4294967296 %s 1 = %d, want -4294967295", "+", r) + } + y = 4294967296 + r = x + y + if r != 0 { + t.Errorf("-4294967296 %s 4294967296 = %d, want 0", "+", r) + } + y = 9223372036854775806 + r = x + y + if r != 9223372032559808510 { + t.Errorf("-4294967296 %s 9223372036854775806 = %d, want 9223372032559808510", "+", r) + } + y = 9223372036854775807 + r = x + y + if r != 9223372032559808511 { + t.Errorf("-4294967296 %s 9223372036854775807 = %d, want 9223372032559808511", "+", r) + } + x = -1 + y = -9223372036854775808 + r = x + y + if r != 9223372036854775807 { + t.Errorf("-1 %s -9223372036854775808 = %d, want 9223372036854775807", "+", r) + } + y = -9223372036854775807 + r = x + y + if r != -9223372036854775808 { + t.Errorf("-1 %s -9223372036854775807 = %d, want -9223372036854775808", "+", r) + } + y = -4294967296 + r = x + y + if r != -4294967297 { + t.Errorf("-1 %s -4294967296 = %d, want -4294967297", "+", r) + } + y = -1 + r = x + y + if r != -2 { + t.Errorf("-1 %s -1 = %d, want -2", "+", r) + } + y = 0 + r = x + y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "+", r) + } + y = 1 + r = x + y + if r != 0 { + t.Errorf("-1 %s 1 = %d, want 0", "+", r) + } + y = 4294967296 + r = x + y + if r != 4294967295 { + t.Errorf("-1 %s 4294967296 = %d, want 4294967295", "+", r) + } + y = 9223372036854775806 + r = x + y + if r != 9223372036854775805 { + t.Errorf("-1 %s 9223372036854775806 = %d, want 9223372036854775805", "+", r) + } + y = 9223372036854775807 + r = x + y + if r != 9223372036854775806 { + t.Errorf("-1 %s 9223372036854775807 = %d, want 9223372036854775806", "+", r) + } + x = 0 + y = -9223372036854775808 + r = x + y + if r != -9223372036854775808 { + t.Errorf("0 %s -9223372036854775808 = %d, want -9223372036854775808", "+", r) + } + y = -9223372036854775807 + r = x + y + if r != -9223372036854775807 { + t.Errorf("0 %s -9223372036854775807 = %d, want -9223372036854775807", "+", r) + } + y = -4294967296 + r = x + y + if r != -4294967296 { + t.Errorf("0 %s -4294967296 = %d, want -4294967296", "+", r) + } + y = -1 + r = x + y + if r != -1 { + t.Errorf("0 %s -1 = %d, want -1", "+", r) + } + y = 0 + r = x + y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "+", r) + } + y = 1 + r = x + y + if r != 1 { + t.Errorf("0 %s 1 = %d, want 1", "+", r) + } + y = 4294967296 + r = x + y + if r != 4294967296 { + t.Errorf("0 %s 4294967296 = %d, want 4294967296", "+", r) + } + y = 9223372036854775806 + r = x + y + if r != 9223372036854775806 { + t.Errorf("0 %s 9223372036854775806 = %d, want 9223372036854775806", "+", r) + } + y = 9223372036854775807 + r = x + y + if r != 9223372036854775807 { + t.Errorf("0 %s 9223372036854775807 = %d, want 9223372036854775807", "+", r) + } + x = 1 + y = -9223372036854775808 + r = x + y + if r != -9223372036854775807 { + t.Errorf("1 %s -9223372036854775808 = %d, want -9223372036854775807", "+", r) + } + y = -9223372036854775807 + r = x + y + if r != -9223372036854775806 { + t.Errorf("1 %s -9223372036854775807 = %d, want -9223372036854775806", "+", r) + } + y = -4294967296 + r = x + y + if r != -4294967295 { + t.Errorf("1 %s -4294967296 = %d, want -4294967295", "+", r) + } + y = -1 + r = x + y + if r != 0 { + t.Errorf("1 %s -1 = %d, want 0", "+", r) + } + y = 0 + r = x + y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "+", r) + } + y = 1 + r = x + y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "+", r) + } + y = 4294967296 + r = x + y + if r != 4294967297 { + t.Errorf("1 %s 4294967296 = %d, want 4294967297", "+", r) + } + y = 9223372036854775806 + r = x + y + if r != 9223372036854775807 { + t.Errorf("1 %s 9223372036854775806 = %d, want 9223372036854775807", "+", r) + } + y = 9223372036854775807 + r = x + y + if r != -9223372036854775808 { + t.Errorf("1 %s 9223372036854775807 = %d, want -9223372036854775808", "+", r) + } + x = 4294967296 + y = -9223372036854775808 + r = x + y + if r != -9223372032559808512 { + t.Errorf("4294967296 %s -9223372036854775808 = %d, want -9223372032559808512", "+", r) + } + y = -9223372036854775807 + r = x + y + if r != -9223372032559808511 { + t.Errorf("4294967296 %s -9223372036854775807 = %d, want -9223372032559808511", "+", r) + } + y = -4294967296 + r = x + y + if r != 0 { + t.Errorf("4294967296 %s -4294967296 = %d, want 0", "+", r) + } + y = -1 + r = x + y + if r != 4294967295 { + t.Errorf("4294967296 %s -1 = %d, want 4294967295", "+", r) + } + y = 0 + r = x + y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "+", r) + } + y = 1 + r = x + y + if r != 4294967297 { + t.Errorf("4294967296 %s 1 = %d, want 4294967297", "+", r) + } + y = 4294967296 + r = x + y + if r != 8589934592 { + t.Errorf("4294967296 %s 4294967296 = %d, want 8589934592", "+", r) + } + y = 9223372036854775806 + r = x + y + if r != -9223372032559808514 { + t.Errorf("4294967296 %s 9223372036854775806 = %d, want -9223372032559808514", "+", r) + } + y = 9223372036854775807 + r = x + y + if r != -9223372032559808513 { + t.Errorf("4294967296 %s 9223372036854775807 = %d, want -9223372032559808513", "+", r) + } + x = 9223372036854775806 + y = -9223372036854775808 + r = x + y + if r != -2 { + t.Errorf("9223372036854775806 %s -9223372036854775808 = %d, want -2", "+", r) + } + y = -9223372036854775807 + r = x + y + if r != -1 { + t.Errorf("9223372036854775806 %s -9223372036854775807 = %d, want -1", "+", r) + } + y = -4294967296 + r = x + y + if r != 9223372032559808510 { + t.Errorf("9223372036854775806 %s -4294967296 = %d, want 9223372032559808510", "+", r) + } + y = -1 + r = x + y + if r != 9223372036854775805 { + t.Errorf("9223372036854775806 %s -1 = %d, want 9223372036854775805", "+", r) + } + y = 0 + r = x + y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 0 = %d, want 9223372036854775806", "+", r) + } + y = 1 + r = x + y + if r != 9223372036854775807 { + t.Errorf("9223372036854775806 %s 1 = %d, want 9223372036854775807", "+", r) + } + y = 4294967296 + r = x + y + if r != -9223372032559808514 { + t.Errorf("9223372036854775806 %s 4294967296 = %d, want -9223372032559808514", "+", r) + } + y = 9223372036854775806 + r = x + y + if r != -4 { + t.Errorf("9223372036854775806 %s 9223372036854775806 = %d, want -4", "+", r) + } + y = 9223372036854775807 + r = x + y + if r != -3 { + t.Errorf("9223372036854775806 %s 9223372036854775807 = %d, want -3", "+", r) + } + x = 9223372036854775807 + y = -9223372036854775808 + r = x + y + if r != -1 { + t.Errorf("9223372036854775807 %s -9223372036854775808 = %d, want -1", "+", r) + } + y = -9223372036854775807 + r = x + y + if r != 0 { + t.Errorf("9223372036854775807 %s -9223372036854775807 = %d, want 0", "+", r) + } + y = -4294967296 + r = x + y + if r != 9223372032559808511 { + t.Errorf("9223372036854775807 %s -4294967296 = %d, want 9223372032559808511", "+", r) + } + y = -1 + r = x + y + if r != 9223372036854775806 { + t.Errorf("9223372036854775807 %s -1 = %d, want 9223372036854775806", "+", r) + } + y = 0 + r = x + y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 0 = %d, want 9223372036854775807", "+", r) + } + y = 1 + r = x + y + if r != -9223372036854775808 { + t.Errorf("9223372036854775807 %s 1 = %d, want -9223372036854775808", "+", r) + } + y = 4294967296 + r = x + y + if r != -9223372032559808513 { + t.Errorf("9223372036854775807 %s 4294967296 = %d, want -9223372032559808513", "+", r) + } + y = 9223372036854775806 + r = x + y + if r != -3 { + t.Errorf("9223372036854775807 %s 9223372036854775806 = %d, want -3", "+", r) + } + y = 9223372036854775807 + r = x + y + if r != -2 { + t.Errorf("9223372036854775807 %s 9223372036854775807 = %d, want -2", "+", r) + } +} +func TestConstFoldint64sub(t *testing.T) { + var x, y, r int64 + x = -9223372036854775808 + y = -9223372036854775808 + r = x - y + if r != 0 { + t.Errorf("-9223372036854775808 %s -9223372036854775808 = %d, want 0", "-", r) + } + y = -9223372036854775807 + r = x - y + if r != -1 { + t.Errorf("-9223372036854775808 %s -9223372036854775807 = %d, want -1", "-", r) + } + y = -4294967296 + r = x - y + if r != -9223372032559808512 { + t.Errorf("-9223372036854775808 %s -4294967296 = %d, want -9223372032559808512", "-", r) + } + y = -1 + r = x - y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775808 %s -1 = %d, want -9223372036854775807", "-", r) + } + y = 0 + r = x - y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 0 = %d, want -9223372036854775808", "-", r) + } + y = 1 + r = x - y + if r != 9223372036854775807 { + t.Errorf("-9223372036854775808 %s 1 = %d, want 9223372036854775807", "-", r) + } + y = 4294967296 + r = x - y + if r != 9223372032559808512 { + t.Errorf("-9223372036854775808 %s 4294967296 = %d, want 9223372032559808512", "-", r) + } + y = 9223372036854775806 + r = x - y + if r != 2 { + t.Errorf("-9223372036854775808 %s 9223372036854775806 = %d, want 2", "-", r) + } + y = 9223372036854775807 + r = x - y + if r != 1 { + t.Errorf("-9223372036854775808 %s 9223372036854775807 = %d, want 1", "-", r) + } + x = -9223372036854775807 + y = -9223372036854775808 + r = x - y + if r != 1 { + t.Errorf("-9223372036854775807 %s -9223372036854775808 = %d, want 1", "-", r) + } + y = -9223372036854775807 + r = x - y + if r != 0 { + t.Errorf("-9223372036854775807 %s -9223372036854775807 = %d, want 0", "-", r) + } + y = -4294967296 + r = x - y + if r != -9223372032559808511 { + t.Errorf("-9223372036854775807 %s -4294967296 = %d, want -9223372032559808511", "-", r) + } + y = -1 + r = x - y + if r != -9223372036854775806 { + t.Errorf("-9223372036854775807 %s -1 = %d, want -9223372036854775806", "-", r) + } + y = 0 + r = x - y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 0 = %d, want -9223372036854775807", "-", r) + } + y = 1 + r = x - y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775807 %s 1 = %d, want -9223372036854775808", "-", r) + } + y = 4294967296 + r = x - y + if r != 9223372032559808513 { + t.Errorf("-9223372036854775807 %s 4294967296 = %d, want 9223372032559808513", "-", r) + } + y = 9223372036854775806 + r = x - y + if r != 3 { + t.Errorf("-9223372036854775807 %s 9223372036854775806 = %d, want 3", "-", r) + } + y = 9223372036854775807 + r = x - y + if r != 2 { + t.Errorf("-9223372036854775807 %s 9223372036854775807 = %d, want 2", "-", r) + } + x = -4294967296 + y = -9223372036854775808 + r = x - y + if r != 9223372032559808512 { + t.Errorf("-4294967296 %s -9223372036854775808 = %d, want 9223372032559808512", "-", r) + } + y = -9223372036854775807 + r = x - y + if r != 9223372032559808511 { + t.Errorf("-4294967296 %s -9223372036854775807 = %d, want 9223372032559808511", "-", r) + } + y = -4294967296 + r = x - y + if r != 0 { + t.Errorf("-4294967296 %s -4294967296 = %d, want 0", "-", r) + } + y = -1 + r = x - y + if r != -4294967295 { + t.Errorf("-4294967296 %s -1 = %d, want -4294967295", "-", r) + } + y = 0 + r = x - y + if r != -4294967296 { + t.Errorf("-4294967296 %s 0 = %d, want -4294967296", "-", r) + } + y = 1 + r = x - y + if r != -4294967297 { + t.Errorf("-4294967296 %s 1 = %d, want -4294967297", "-", r) + } + y = 4294967296 + r = x - y + if r != -8589934592 { + t.Errorf("-4294967296 %s 4294967296 = %d, want -8589934592", "-", r) + } + y = 9223372036854775806 + r = x - y + if r != 9223372032559808514 { + t.Errorf("-4294967296 %s 9223372036854775806 = %d, want 9223372032559808514", "-", r) + } + y = 9223372036854775807 + r = x - y + if r != 9223372032559808513 { + t.Errorf("-4294967296 %s 9223372036854775807 = %d, want 9223372032559808513", "-", r) + } + x = -1 + y = -9223372036854775808 + r = x - y + if r != 9223372036854775807 { + t.Errorf("-1 %s -9223372036854775808 = %d, want 9223372036854775807", "-", r) + } + y = -9223372036854775807 + r = x - y + if r != 9223372036854775806 { + t.Errorf("-1 %s -9223372036854775807 = %d, want 9223372036854775806", "-", r) + } + y = -4294967296 + r = x - y + if r != 4294967295 { + t.Errorf("-1 %s -4294967296 = %d, want 4294967295", "-", r) + } + y = -1 + r = x - y + if r != 0 { + t.Errorf("-1 %s -1 = %d, want 0", "-", r) + } + y = 0 + r = x - y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "-", r) + } + y = 1 + r = x - y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "-", r) + } + y = 4294967296 + r = x - y + if r != -4294967297 { + t.Errorf("-1 %s 4294967296 = %d, want -4294967297", "-", r) + } + y = 9223372036854775806 + r = x - y + if r != -9223372036854775807 { + t.Errorf("-1 %s 9223372036854775806 = %d, want -9223372036854775807", "-", r) + } + y = 9223372036854775807 + r = x - y + if r != -9223372036854775808 { + t.Errorf("-1 %s 9223372036854775807 = %d, want -9223372036854775808", "-", r) + } + x = 0 + y = -9223372036854775808 + r = x - y + if r != -9223372036854775808 { + t.Errorf("0 %s -9223372036854775808 = %d, want -9223372036854775808", "-", r) + } + y = -9223372036854775807 + r = x - y + if r != 9223372036854775807 { + t.Errorf("0 %s -9223372036854775807 = %d, want 9223372036854775807", "-", r) + } + y = -4294967296 + r = x - y + if r != 4294967296 { + t.Errorf("0 %s -4294967296 = %d, want 4294967296", "-", r) + } + y = -1 + r = x - y + if r != 1 { + t.Errorf("0 %s -1 = %d, want 1", "-", r) + } + y = 0 + r = x - y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "-", r) + } + y = 1 + r = x - y + if r != -1 { + t.Errorf("0 %s 1 = %d, want -1", "-", r) + } + y = 4294967296 + r = x - y + if r != -4294967296 { + t.Errorf("0 %s 4294967296 = %d, want -4294967296", "-", r) + } + y = 9223372036854775806 + r = x - y + if r != -9223372036854775806 { + t.Errorf("0 %s 9223372036854775806 = %d, want -9223372036854775806", "-", r) + } + y = 9223372036854775807 + r = x - y + if r != -9223372036854775807 { + t.Errorf("0 %s 9223372036854775807 = %d, want -9223372036854775807", "-", r) + } + x = 1 + y = -9223372036854775808 + r = x - y + if r != -9223372036854775807 { + t.Errorf("1 %s -9223372036854775808 = %d, want -9223372036854775807", "-", r) + } + y = -9223372036854775807 + r = x - y + if r != -9223372036854775808 { + t.Errorf("1 %s -9223372036854775807 = %d, want -9223372036854775808", "-", r) + } + y = -4294967296 + r = x - y + if r != 4294967297 { + t.Errorf("1 %s -4294967296 = %d, want 4294967297", "-", r) + } + y = -1 + r = x - y + if r != 2 { + t.Errorf("1 %s -1 = %d, want 2", "-", r) + } + y = 0 + r = x - y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "-", r) + } + y = 1 + r = x - y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "-", r) + } + y = 4294967296 + r = x - y + if r != -4294967295 { + t.Errorf("1 %s 4294967296 = %d, want -4294967295", "-", r) + } + y = 9223372036854775806 + r = x - y + if r != -9223372036854775805 { + t.Errorf("1 %s 9223372036854775806 = %d, want -9223372036854775805", "-", r) + } + y = 9223372036854775807 + r = x - y + if r != -9223372036854775806 { + t.Errorf("1 %s 9223372036854775807 = %d, want -9223372036854775806", "-", r) + } + x = 4294967296 + y = -9223372036854775808 + r = x - y + if r != -9223372032559808512 { + t.Errorf("4294967296 %s -9223372036854775808 = %d, want -9223372032559808512", "-", r) + } + y = -9223372036854775807 + r = x - y + if r != -9223372032559808513 { + t.Errorf("4294967296 %s -9223372036854775807 = %d, want -9223372032559808513", "-", r) + } + y = -4294967296 + r = x - y + if r != 8589934592 { + t.Errorf("4294967296 %s -4294967296 = %d, want 8589934592", "-", r) + } + y = -1 + r = x - y + if r != 4294967297 { + t.Errorf("4294967296 %s -1 = %d, want 4294967297", "-", r) + } + y = 0 + r = x - y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "-", r) + } + y = 1 + r = x - y + if r != 4294967295 { + t.Errorf("4294967296 %s 1 = %d, want 4294967295", "-", r) + } + y = 4294967296 + r = x - y + if r != 0 { + t.Errorf("4294967296 %s 4294967296 = %d, want 0", "-", r) + } + y = 9223372036854775806 + r = x - y + if r != -9223372032559808510 { + t.Errorf("4294967296 %s 9223372036854775806 = %d, want -9223372032559808510", "-", r) + } + y = 9223372036854775807 + r = x - y + if r != -9223372032559808511 { + t.Errorf("4294967296 %s 9223372036854775807 = %d, want -9223372032559808511", "-", r) + } + x = 9223372036854775806 + y = -9223372036854775808 + r = x - y + if r != -2 { + t.Errorf("9223372036854775806 %s -9223372036854775808 = %d, want -2", "-", r) + } + y = -9223372036854775807 + r = x - y + if r != -3 { + t.Errorf("9223372036854775806 %s -9223372036854775807 = %d, want -3", "-", r) + } + y = -4294967296 + r = x - y + if r != -9223372032559808514 { + t.Errorf("9223372036854775806 %s -4294967296 = %d, want -9223372032559808514", "-", r) + } + y = -1 + r = x - y + if r != 9223372036854775807 { + t.Errorf("9223372036854775806 %s -1 = %d, want 9223372036854775807", "-", r) + } + y = 0 + r = x - y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 0 = %d, want 9223372036854775806", "-", r) + } + y = 1 + r = x - y + if r != 9223372036854775805 { + t.Errorf("9223372036854775806 %s 1 = %d, want 9223372036854775805", "-", r) + } + y = 4294967296 + r = x - y + if r != 9223372032559808510 { + t.Errorf("9223372036854775806 %s 4294967296 = %d, want 9223372032559808510", "-", r) + } + y = 9223372036854775806 + r = x - y + if r != 0 { + t.Errorf("9223372036854775806 %s 9223372036854775806 = %d, want 0", "-", r) + } + y = 9223372036854775807 + r = x - y + if r != -1 { + t.Errorf("9223372036854775806 %s 9223372036854775807 = %d, want -1", "-", r) + } + x = 9223372036854775807 + y = -9223372036854775808 + r = x - y + if r != -1 { + t.Errorf("9223372036854775807 %s -9223372036854775808 = %d, want -1", "-", r) + } + y = -9223372036854775807 + r = x - y + if r != -2 { + t.Errorf("9223372036854775807 %s -9223372036854775807 = %d, want -2", "-", r) + } + y = -4294967296 + r = x - y + if r != -9223372032559808513 { + t.Errorf("9223372036854775807 %s -4294967296 = %d, want -9223372032559808513", "-", r) + } + y = -1 + r = x - y + if r != -9223372036854775808 { + t.Errorf("9223372036854775807 %s -1 = %d, want -9223372036854775808", "-", r) + } + y = 0 + r = x - y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 0 = %d, want 9223372036854775807", "-", r) + } + y = 1 + r = x - y + if r != 9223372036854775806 { + t.Errorf("9223372036854775807 %s 1 = %d, want 9223372036854775806", "-", r) + } + y = 4294967296 + r = x - y + if r != 9223372032559808511 { + t.Errorf("9223372036854775807 %s 4294967296 = %d, want 9223372032559808511", "-", r) + } + y = 9223372036854775806 + r = x - y + if r != 1 { + t.Errorf("9223372036854775807 %s 9223372036854775806 = %d, want 1", "-", r) + } + y = 9223372036854775807 + r = x - y + if r != 0 { + t.Errorf("9223372036854775807 %s 9223372036854775807 = %d, want 0", "-", r) + } +} +func TestConstFoldint64div(t *testing.T) { + var x, y, r int64 + x = -9223372036854775808 + y = -9223372036854775808 + r = x / y + if r != 1 { + t.Errorf("-9223372036854775808 %s -9223372036854775808 = %d, want 1", "/", r) + } + y = -9223372036854775807 + r = x / y + if r != 1 { + t.Errorf("-9223372036854775808 %s -9223372036854775807 = %d, want 1", "/", r) + } + y = -4294967296 + r = x / y + if r != 2147483648 { + t.Errorf("-9223372036854775808 %s -4294967296 = %d, want 2147483648", "/", r) + } + y = -1 + r = x / y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s -1 = %d, want -9223372036854775808", "/", r) + } + y = 1 + r = x / y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 1 = %d, want -9223372036854775808", "/", r) + } + y = 4294967296 + r = x / y + if r != -2147483648 { + t.Errorf("-9223372036854775808 %s 4294967296 = %d, want -2147483648", "/", r) + } + y = 9223372036854775806 + r = x / y + if r != -1 { + t.Errorf("-9223372036854775808 %s 9223372036854775806 = %d, want -1", "/", r) + } + y = 9223372036854775807 + r = x / y + if r != -1 { + t.Errorf("-9223372036854775808 %s 9223372036854775807 = %d, want -1", "/", r) + } + x = -9223372036854775807 + y = -9223372036854775808 + r = x / y + if r != 0 { + t.Errorf("-9223372036854775807 %s -9223372036854775808 = %d, want 0", "/", r) + } + y = -9223372036854775807 + r = x / y + if r != 1 { + t.Errorf("-9223372036854775807 %s -9223372036854775807 = %d, want 1", "/", r) + } + y = -4294967296 + r = x / y + if r != 2147483647 { + t.Errorf("-9223372036854775807 %s -4294967296 = %d, want 2147483647", "/", r) + } + y = -1 + r = x / y + if r != 9223372036854775807 { + t.Errorf("-9223372036854775807 %s -1 = %d, want 9223372036854775807", "/", r) + } + y = 1 + r = x / y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 1 = %d, want -9223372036854775807", "/", r) + } + y = 4294967296 + r = x / y + if r != -2147483647 { + t.Errorf("-9223372036854775807 %s 4294967296 = %d, want -2147483647", "/", r) + } + y = 9223372036854775806 + r = x / y + if r != -1 { + t.Errorf("-9223372036854775807 %s 9223372036854775806 = %d, want -1", "/", r) + } + y = 9223372036854775807 + r = x / y + if r != -1 { + t.Errorf("-9223372036854775807 %s 9223372036854775807 = %d, want -1", "/", r) + } + x = -4294967296 + y = -9223372036854775808 + r = x / y + if r != 0 { + t.Errorf("-4294967296 %s -9223372036854775808 = %d, want 0", "/", r) + } + y = -9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("-4294967296 %s -9223372036854775807 = %d, want 0", "/", r) + } + y = -4294967296 + r = x / y + if r != 1 { + t.Errorf("-4294967296 %s -4294967296 = %d, want 1", "/", r) + } + y = -1 + r = x / y + if r != 4294967296 { + t.Errorf("-4294967296 %s -1 = %d, want 4294967296", "/", r) + } + y = 1 + r = x / y + if r != -4294967296 { + t.Errorf("-4294967296 %s 1 = %d, want -4294967296", "/", r) + } + y = 4294967296 + r = x / y + if r != -1 { + t.Errorf("-4294967296 %s 4294967296 = %d, want -1", "/", r) + } + y = 9223372036854775806 + r = x / y + if r != 0 { + t.Errorf("-4294967296 %s 9223372036854775806 = %d, want 0", "/", r) + } + y = 9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("-4294967296 %s 9223372036854775807 = %d, want 0", "/", r) + } + x = -1 + y = -9223372036854775808 + r = x / y + if r != 0 { + t.Errorf("-1 %s -9223372036854775808 = %d, want 0", "/", r) + } + y = -9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("-1 %s -9223372036854775807 = %d, want 0", "/", r) + } + y = -4294967296 + r = x / y + if r != 0 { + t.Errorf("-1 %s -4294967296 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != 1 { + t.Errorf("-1 %s -1 = %d, want 1", "/", r) + } + y = 1 + r = x / y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", "/", r) + } + y = 4294967296 + r = x / y + if r != 0 { + t.Errorf("-1 %s 4294967296 = %d, want 0", "/", r) + } + y = 9223372036854775806 + r = x / y + if r != 0 { + t.Errorf("-1 %s 9223372036854775806 = %d, want 0", "/", r) + } + y = 9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("-1 %s 9223372036854775807 = %d, want 0", "/", r) + } + x = 0 + y = -9223372036854775808 + r = x / y + if r != 0 { + t.Errorf("0 %s -9223372036854775808 = %d, want 0", "/", r) + } + y = -9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("0 %s -9223372036854775807 = %d, want 0", "/", r) + } + y = -4294967296 + r = x / y + if r != 0 { + t.Errorf("0 %s -4294967296 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "/", r) + } + y = 1 + r = x / y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "/", r) + } + y = 4294967296 + r = x / y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "/", r) + } + y = 9223372036854775806 + r = x / y + if r != 0 { + t.Errorf("0 %s 9223372036854775806 = %d, want 0", "/", r) + } + y = 9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("0 %s 9223372036854775807 = %d, want 0", "/", r) + } + x = 1 + y = -9223372036854775808 + r = x / y + if r != 0 { + t.Errorf("1 %s -9223372036854775808 = %d, want 0", "/", r) + } + y = -9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("1 %s -9223372036854775807 = %d, want 0", "/", r) + } + y = -4294967296 + r = x / y + if r != 0 { + t.Errorf("1 %s -4294967296 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != -1 { + t.Errorf("1 %s -1 = %d, want -1", "/", r) + } + y = 1 + r = x / y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "/", r) + } + y = 4294967296 + r = x / y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", "/", r) + } + y = 9223372036854775806 + r = x / y + if r != 0 { + t.Errorf("1 %s 9223372036854775806 = %d, want 0", "/", r) + } + y = 9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("1 %s 9223372036854775807 = %d, want 0", "/", r) + } + x = 4294967296 + y = -9223372036854775808 + r = x / y + if r != 0 { + t.Errorf("4294967296 %s -9223372036854775808 = %d, want 0", "/", r) + } + y = -9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("4294967296 %s -9223372036854775807 = %d, want 0", "/", r) + } + y = -4294967296 + r = x / y + if r != -1 { + t.Errorf("4294967296 %s -4294967296 = %d, want -1", "/", r) + } + y = -1 + r = x / y + if r != -4294967296 { + t.Errorf("4294967296 %s -1 = %d, want -4294967296", "/", r) + } + y = 1 + r = x / y + if r != 4294967296 { + t.Errorf("4294967296 %s 1 = %d, want 4294967296", "/", r) + } + y = 4294967296 + r = x / y + if r != 1 { + t.Errorf("4294967296 %s 4294967296 = %d, want 1", "/", r) + } + y = 9223372036854775806 + r = x / y + if r != 0 { + t.Errorf("4294967296 %s 9223372036854775806 = %d, want 0", "/", r) + } + y = 9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("4294967296 %s 9223372036854775807 = %d, want 0", "/", r) + } + x = 9223372036854775806 + y = -9223372036854775808 + r = x / y + if r != 0 { + t.Errorf("9223372036854775806 %s -9223372036854775808 = %d, want 0", "/", r) + } + y = -9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("9223372036854775806 %s -9223372036854775807 = %d, want 0", "/", r) + } + y = -4294967296 + r = x / y + if r != -2147483647 { + t.Errorf("9223372036854775806 %s -4294967296 = %d, want -2147483647", "/", r) + } + y = -1 + r = x / y + if r != -9223372036854775806 { + t.Errorf("9223372036854775806 %s -1 = %d, want -9223372036854775806", "/", r) + } + y = 1 + r = x / y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 1 = %d, want 9223372036854775806", "/", r) + } + y = 4294967296 + r = x / y + if r != 2147483647 { + t.Errorf("9223372036854775806 %s 4294967296 = %d, want 2147483647", "/", r) + } + y = 9223372036854775806 + r = x / y + if r != 1 { + t.Errorf("9223372036854775806 %s 9223372036854775806 = %d, want 1", "/", r) + } + y = 9223372036854775807 + r = x / y + if r != 0 { + t.Errorf("9223372036854775806 %s 9223372036854775807 = %d, want 0", "/", r) + } + x = 9223372036854775807 + y = -9223372036854775808 + r = x / y + if r != 0 { + t.Errorf("9223372036854775807 %s -9223372036854775808 = %d, want 0", "/", r) + } + y = -9223372036854775807 + r = x / y + if r != -1 { + t.Errorf("9223372036854775807 %s -9223372036854775807 = %d, want -1", "/", r) + } + y = -4294967296 + r = x / y + if r != -2147483647 { + t.Errorf("9223372036854775807 %s -4294967296 = %d, want -2147483647", "/", r) + } + y = -1 + r = x / y + if r != -9223372036854775807 { + t.Errorf("9223372036854775807 %s -1 = %d, want -9223372036854775807", "/", r) + } + y = 1 + r = x / y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 1 = %d, want 9223372036854775807", "/", r) + } + y = 4294967296 + r = x / y + if r != 2147483647 { + t.Errorf("9223372036854775807 %s 4294967296 = %d, want 2147483647", "/", r) + } + y = 9223372036854775806 + r = x / y + if r != 1 { + t.Errorf("9223372036854775807 %s 9223372036854775806 = %d, want 1", "/", r) + } + y = 9223372036854775807 + r = x / y + if r != 1 { + t.Errorf("9223372036854775807 %s 9223372036854775807 = %d, want 1", "/", r) + } +} +func TestConstFoldint64mul(t *testing.T) { + var x, y, r int64 + x = -9223372036854775808 + y = -9223372036854775808 + r = x * y + if r != 0 { + t.Errorf("-9223372036854775808 %s -9223372036854775808 = %d, want 0", "*", r) + } + y = -9223372036854775807 + r = x * y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s -9223372036854775807 = %d, want -9223372036854775808", "*", r) + } + y = -4294967296 + r = x * y + if r != 0 { + t.Errorf("-9223372036854775808 %s -4294967296 = %d, want 0", "*", r) + } + y = -1 + r = x * y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s -1 = %d, want -9223372036854775808", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-9223372036854775808 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 1 = %d, want -9223372036854775808", "*", r) + } + y = 4294967296 + r = x * y + if r != 0 { + t.Errorf("-9223372036854775808 %s 4294967296 = %d, want 0", "*", r) + } + y = 9223372036854775806 + r = x * y + if r != 0 { + t.Errorf("-9223372036854775808 %s 9223372036854775806 = %d, want 0", "*", r) + } + y = 9223372036854775807 + r = x * y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 9223372036854775807 = %d, want -9223372036854775808", "*", r) + } + x = -9223372036854775807 + y = -9223372036854775808 + r = x * y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775807 %s -9223372036854775808 = %d, want -9223372036854775808", "*", r) + } + y = -9223372036854775807 + r = x * y + if r != 1 { + t.Errorf("-9223372036854775807 %s -9223372036854775807 = %d, want 1", "*", r) + } + y = -4294967296 + r = x * y + if r != -4294967296 { + t.Errorf("-9223372036854775807 %s -4294967296 = %d, want -4294967296", "*", r) + } + y = -1 + r = x * y + if r != 9223372036854775807 { + t.Errorf("-9223372036854775807 %s -1 = %d, want 9223372036854775807", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-9223372036854775807 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 1 = %d, want -9223372036854775807", "*", r) + } + y = 4294967296 + r = x * y + if r != 4294967296 { + t.Errorf("-9223372036854775807 %s 4294967296 = %d, want 4294967296", "*", r) + } + y = 9223372036854775806 + r = x * y + if r != 9223372036854775806 { + t.Errorf("-9223372036854775807 %s 9223372036854775806 = %d, want 9223372036854775806", "*", r) + } + y = 9223372036854775807 + r = x * y + if r != -1 { + t.Errorf("-9223372036854775807 %s 9223372036854775807 = %d, want -1", "*", r) + } + x = -4294967296 + y = -9223372036854775808 + r = x * y + if r != 0 { + t.Errorf("-4294967296 %s -9223372036854775808 = %d, want 0", "*", r) + } + y = -9223372036854775807 + r = x * y + if r != -4294967296 { + t.Errorf("-4294967296 %s -9223372036854775807 = %d, want -4294967296", "*", r) + } + y = -4294967296 + r = x * y + if r != 0 { + t.Errorf("-4294967296 %s -4294967296 = %d, want 0", "*", r) + } + y = -1 + r = x * y + if r != 4294967296 { + t.Errorf("-4294967296 %s -1 = %d, want 4294967296", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-4294967296 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -4294967296 { + t.Errorf("-4294967296 %s 1 = %d, want -4294967296", "*", r) + } + y = 4294967296 + r = x * y + if r != 0 { + t.Errorf("-4294967296 %s 4294967296 = %d, want 0", "*", r) + } + y = 9223372036854775806 + r = x * y + if r != 8589934592 { + t.Errorf("-4294967296 %s 9223372036854775806 = %d, want 8589934592", "*", r) + } + y = 9223372036854775807 + r = x * y + if r != 4294967296 { + t.Errorf("-4294967296 %s 9223372036854775807 = %d, want 4294967296", "*", r) + } + x = -1 + y = -9223372036854775808 + r = x * y + if r != -9223372036854775808 { + t.Errorf("-1 %s -9223372036854775808 = %d, want -9223372036854775808", "*", r) + } + y = -9223372036854775807 + r = x * y + if r != 9223372036854775807 { + t.Errorf("-1 %s -9223372036854775807 = %d, want 9223372036854775807", "*", r) + } + y = -4294967296 + r = x * y + if r != 4294967296 { + t.Errorf("-1 %s -4294967296 = %d, want 4294967296", "*", r) + } + y = -1 + r = x * y + if r != 1 { + t.Errorf("-1 %s -1 = %d, want 1", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", "*", r) + } + y = 4294967296 + r = x * y + if r != -4294967296 { + t.Errorf("-1 %s 4294967296 = %d, want -4294967296", "*", r) + } + y = 9223372036854775806 + r = x * y + if r != -9223372036854775806 { + t.Errorf("-1 %s 9223372036854775806 = %d, want -9223372036854775806", "*", r) + } + y = 9223372036854775807 + r = x * y + if r != -9223372036854775807 { + t.Errorf("-1 %s 9223372036854775807 = %d, want -9223372036854775807", "*", r) + } + x = 0 + y = -9223372036854775808 + r = x * y + if r != 0 { + t.Errorf("0 %s -9223372036854775808 = %d, want 0", "*", r) + } + y = -9223372036854775807 + r = x * y + if r != 0 { + t.Errorf("0 %s -9223372036854775807 = %d, want 0", "*", r) + } + y = -4294967296 + r = x * y + if r != 0 { + t.Errorf("0 %s -4294967296 = %d, want 0", "*", r) + } + y = -1 + r = x * y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "*", r) + } + y = 4294967296 + r = x * y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "*", r) + } + y = 9223372036854775806 + r = x * y + if r != 0 { + t.Errorf("0 %s 9223372036854775806 = %d, want 0", "*", r) + } + y = 9223372036854775807 + r = x * y + if r != 0 { + t.Errorf("0 %s 9223372036854775807 = %d, want 0", "*", r) + } + x = 1 + y = -9223372036854775808 + r = x * y + if r != -9223372036854775808 { + t.Errorf("1 %s -9223372036854775808 = %d, want -9223372036854775808", "*", r) + } + y = -9223372036854775807 + r = x * y + if r != -9223372036854775807 { + t.Errorf("1 %s -9223372036854775807 = %d, want -9223372036854775807", "*", r) + } + y = -4294967296 + r = x * y + if r != -4294967296 { + t.Errorf("1 %s -4294967296 = %d, want -4294967296", "*", r) + } + y = -1 + r = x * y + if r != -1 { + t.Errorf("1 %s -1 = %d, want -1", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "*", r) + } + y = 4294967296 + r = x * y + if r != 4294967296 { + t.Errorf("1 %s 4294967296 = %d, want 4294967296", "*", r) + } + y = 9223372036854775806 + r = x * y + if r != 9223372036854775806 { + t.Errorf("1 %s 9223372036854775806 = %d, want 9223372036854775806", "*", r) + } + y = 9223372036854775807 + r = x * y + if r != 9223372036854775807 { + t.Errorf("1 %s 9223372036854775807 = %d, want 9223372036854775807", "*", r) + } + x = 4294967296 + y = -9223372036854775808 + r = x * y + if r != 0 { + t.Errorf("4294967296 %s -9223372036854775808 = %d, want 0", "*", r) + } + y = -9223372036854775807 + r = x * y + if r != 4294967296 { + t.Errorf("4294967296 %s -9223372036854775807 = %d, want 4294967296", "*", r) + } + y = -4294967296 + r = x * y + if r != 0 { + t.Errorf("4294967296 %s -4294967296 = %d, want 0", "*", r) + } + y = -1 + r = x * y + if r != -4294967296 { + t.Errorf("4294967296 %s -1 = %d, want -4294967296", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("4294967296 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 4294967296 { + t.Errorf("4294967296 %s 1 = %d, want 4294967296", "*", r) + } + y = 4294967296 + r = x * y + if r != 0 { + t.Errorf("4294967296 %s 4294967296 = %d, want 0", "*", r) + } + y = 9223372036854775806 + r = x * y + if r != -8589934592 { + t.Errorf("4294967296 %s 9223372036854775806 = %d, want -8589934592", "*", r) + } + y = 9223372036854775807 + r = x * y + if r != -4294967296 { + t.Errorf("4294967296 %s 9223372036854775807 = %d, want -4294967296", "*", r) + } + x = 9223372036854775806 + y = -9223372036854775808 + r = x * y + if r != 0 { + t.Errorf("9223372036854775806 %s -9223372036854775808 = %d, want 0", "*", r) + } + y = -9223372036854775807 + r = x * y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s -9223372036854775807 = %d, want 9223372036854775806", "*", r) + } + y = -4294967296 + r = x * y + if r != 8589934592 { + t.Errorf("9223372036854775806 %s -4294967296 = %d, want 8589934592", "*", r) + } + y = -1 + r = x * y + if r != -9223372036854775806 { + t.Errorf("9223372036854775806 %s -1 = %d, want -9223372036854775806", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("9223372036854775806 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 1 = %d, want 9223372036854775806", "*", r) + } + y = 4294967296 + r = x * y + if r != -8589934592 { + t.Errorf("9223372036854775806 %s 4294967296 = %d, want -8589934592", "*", r) + } + y = 9223372036854775806 + r = x * y + if r != 4 { + t.Errorf("9223372036854775806 %s 9223372036854775806 = %d, want 4", "*", r) + } + y = 9223372036854775807 + r = x * y + if r != -9223372036854775806 { + t.Errorf("9223372036854775806 %s 9223372036854775807 = %d, want -9223372036854775806", "*", r) + } + x = 9223372036854775807 + y = -9223372036854775808 + r = x * y + if r != -9223372036854775808 { + t.Errorf("9223372036854775807 %s -9223372036854775808 = %d, want -9223372036854775808", "*", r) + } + y = -9223372036854775807 + r = x * y + if r != -1 { + t.Errorf("9223372036854775807 %s -9223372036854775807 = %d, want -1", "*", r) + } + y = -4294967296 + r = x * y + if r != 4294967296 { + t.Errorf("9223372036854775807 %s -4294967296 = %d, want 4294967296", "*", r) + } + y = -1 + r = x * y + if r != -9223372036854775807 { + t.Errorf("9223372036854775807 %s -1 = %d, want -9223372036854775807", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("9223372036854775807 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 1 = %d, want 9223372036854775807", "*", r) + } + y = 4294967296 + r = x * y + if r != -4294967296 { + t.Errorf("9223372036854775807 %s 4294967296 = %d, want -4294967296", "*", r) + } + y = 9223372036854775806 + r = x * y + if r != -9223372036854775806 { + t.Errorf("9223372036854775807 %s 9223372036854775806 = %d, want -9223372036854775806", "*", r) + } + y = 9223372036854775807 + r = x * y + if r != 1 { + t.Errorf("9223372036854775807 %s 9223372036854775807 = %d, want 1", "*", r) + } +} +func TestConstFoldint64mod(t *testing.T) { + var x, y, r int64 + x = -9223372036854775808 + y = -9223372036854775808 + r = x % y + if r != 0 { + t.Errorf("-9223372036854775808 %s -9223372036854775808 = %d, want 0", "%", r) + } + y = -9223372036854775807 + r = x % y + if r != -1 { + t.Errorf("-9223372036854775808 %s -9223372036854775807 = %d, want -1", "%", r) + } + y = -4294967296 + r = x % y + if r != 0 { + t.Errorf("-9223372036854775808 %s -4294967296 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-9223372036854775808 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-9223372036854775808 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 0 { + t.Errorf("-9223372036854775808 %s 4294967296 = %d, want 0", "%", r) + } + y = 9223372036854775806 + r = x % y + if r != -2 { + t.Errorf("-9223372036854775808 %s 9223372036854775806 = %d, want -2", "%", r) + } + y = 9223372036854775807 + r = x % y + if r != -1 { + t.Errorf("-9223372036854775808 %s 9223372036854775807 = %d, want -1", "%", r) + } + x = -9223372036854775807 + y = -9223372036854775808 + r = x % y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s -9223372036854775808 = %d, want -9223372036854775807", "%", r) + } + y = -9223372036854775807 + r = x % y + if r != 0 { + t.Errorf("-9223372036854775807 %s -9223372036854775807 = %d, want 0", "%", r) + } + y = -4294967296 + r = x % y + if r != -4294967295 { + t.Errorf("-9223372036854775807 %s -4294967296 = %d, want -4294967295", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-9223372036854775807 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-9223372036854775807 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != -4294967295 { + t.Errorf("-9223372036854775807 %s 4294967296 = %d, want -4294967295", "%", r) + } + y = 9223372036854775806 + r = x % y + if r != -1 { + t.Errorf("-9223372036854775807 %s 9223372036854775806 = %d, want -1", "%", r) + } + y = 9223372036854775807 + r = x % y + if r != 0 { + t.Errorf("-9223372036854775807 %s 9223372036854775807 = %d, want 0", "%", r) + } + x = -4294967296 + y = -9223372036854775808 + r = x % y + if r != -4294967296 { + t.Errorf("-4294967296 %s -9223372036854775808 = %d, want -4294967296", "%", r) + } + y = -9223372036854775807 + r = x % y + if r != -4294967296 { + t.Errorf("-4294967296 %s -9223372036854775807 = %d, want -4294967296", "%", r) + } + y = -4294967296 + r = x % y + if r != 0 { + t.Errorf("-4294967296 %s -4294967296 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-4294967296 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-4294967296 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 0 { + t.Errorf("-4294967296 %s 4294967296 = %d, want 0", "%", r) + } + y = 9223372036854775806 + r = x % y + if r != -4294967296 { + t.Errorf("-4294967296 %s 9223372036854775806 = %d, want -4294967296", "%", r) + } + y = 9223372036854775807 + r = x % y + if r != -4294967296 { + t.Errorf("-4294967296 %s 9223372036854775807 = %d, want -4294967296", "%", r) + } + x = -1 + y = -9223372036854775808 + r = x % y + if r != -1 { + t.Errorf("-1 %s -9223372036854775808 = %d, want -1", "%", r) + } + y = -9223372036854775807 + r = x % y + if r != -1 { + t.Errorf("-1 %s -9223372036854775807 = %d, want -1", "%", r) + } + y = -4294967296 + r = x % y + if r != -1 { + t.Errorf("-1 %s -4294967296 = %d, want -1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-1 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-1 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != -1 { + t.Errorf("-1 %s 4294967296 = %d, want -1", "%", r) + } + y = 9223372036854775806 + r = x % y + if r != -1 { + t.Errorf("-1 %s 9223372036854775806 = %d, want -1", "%", r) + } + y = 9223372036854775807 + r = x % y + if r != -1 { + t.Errorf("-1 %s 9223372036854775807 = %d, want -1", "%", r) + } + x = 0 + y = -9223372036854775808 + r = x % y + if r != 0 { + t.Errorf("0 %s -9223372036854775808 = %d, want 0", "%", r) + } + y = -9223372036854775807 + r = x % y + if r != 0 { + t.Errorf("0 %s -9223372036854775807 = %d, want 0", "%", r) + } + y = -4294967296 + r = x % y + if r != 0 { + t.Errorf("0 %s -4294967296 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "%", r) + } + y = 9223372036854775806 + r = x % y + if r != 0 { + t.Errorf("0 %s 9223372036854775806 = %d, want 0", "%", r) + } + y = 9223372036854775807 + r = x % y + if r != 0 { + t.Errorf("0 %s 9223372036854775807 = %d, want 0", "%", r) + } + x = 1 + y = -9223372036854775808 + r = x % y + if r != 1 { + t.Errorf("1 %s -9223372036854775808 = %d, want 1", "%", r) + } + y = -9223372036854775807 + r = x % y + if r != 1 { + t.Errorf("1 %s -9223372036854775807 = %d, want 1", "%", r) + } + y = -4294967296 + r = x % y + if r != 1 { + t.Errorf("1 %s -4294967296 = %d, want 1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("1 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 1 { + t.Errorf("1 %s 4294967296 = %d, want 1", "%", r) + } + y = 9223372036854775806 + r = x % y + if r != 1 { + t.Errorf("1 %s 9223372036854775806 = %d, want 1", "%", r) + } + y = 9223372036854775807 + r = x % y + if r != 1 { + t.Errorf("1 %s 9223372036854775807 = %d, want 1", "%", r) + } + x = 4294967296 + y = -9223372036854775808 + r = x % y + if r != 4294967296 { + t.Errorf("4294967296 %s -9223372036854775808 = %d, want 4294967296", "%", r) + } + y = -9223372036854775807 + r = x % y + if r != 4294967296 { + t.Errorf("4294967296 %s -9223372036854775807 = %d, want 4294967296", "%", r) + } + y = -4294967296 + r = x % y + if r != 0 { + t.Errorf("4294967296 %s -4294967296 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("4294967296 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("4294967296 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 0 { + t.Errorf("4294967296 %s 4294967296 = %d, want 0", "%", r) + } + y = 9223372036854775806 + r = x % y + if r != 4294967296 { + t.Errorf("4294967296 %s 9223372036854775806 = %d, want 4294967296", "%", r) + } + y = 9223372036854775807 + r = x % y + if r != 4294967296 { + t.Errorf("4294967296 %s 9223372036854775807 = %d, want 4294967296", "%", r) + } + x = 9223372036854775806 + y = -9223372036854775808 + r = x % y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s -9223372036854775808 = %d, want 9223372036854775806", "%", r) + } + y = -9223372036854775807 + r = x % y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s -9223372036854775807 = %d, want 9223372036854775806", "%", r) + } + y = -4294967296 + r = x % y + if r != 4294967294 { + t.Errorf("9223372036854775806 %s -4294967296 = %d, want 4294967294", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("9223372036854775806 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("9223372036854775806 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 4294967294 { + t.Errorf("9223372036854775806 %s 4294967296 = %d, want 4294967294", "%", r) + } + y = 9223372036854775806 + r = x % y + if r != 0 { + t.Errorf("9223372036854775806 %s 9223372036854775806 = %d, want 0", "%", r) + } + y = 9223372036854775807 + r = x % y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 9223372036854775807 = %d, want 9223372036854775806", "%", r) + } + x = 9223372036854775807 + y = -9223372036854775808 + r = x % y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s -9223372036854775808 = %d, want 9223372036854775807", "%", r) + } + y = -9223372036854775807 + r = x % y + if r != 0 { + t.Errorf("9223372036854775807 %s -9223372036854775807 = %d, want 0", "%", r) + } + y = -4294967296 + r = x % y + if r != 4294967295 { + t.Errorf("9223372036854775807 %s -4294967296 = %d, want 4294967295", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("9223372036854775807 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("9223372036854775807 %s 1 = %d, want 0", "%", r) + } + y = 4294967296 + r = x % y + if r != 4294967295 { + t.Errorf("9223372036854775807 %s 4294967296 = %d, want 4294967295", "%", r) + } + y = 9223372036854775806 + r = x % y + if r != 1 { + t.Errorf("9223372036854775807 %s 9223372036854775806 = %d, want 1", "%", r) + } + y = 9223372036854775807 + r = x % y + if r != 0 { + t.Errorf("9223372036854775807 %s 9223372036854775807 = %d, want 0", "%", r) + } +} +func TestConstFolduint32add(t *testing.T) { + var x, y, r uint32 + x = 0 + y = 0 + r = x + y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "+", r) + } + y = 1 + r = x + y + if r != 1 { + t.Errorf("0 %s 1 = %d, want 1", "+", r) + } + y = 4294967295 + r = x + y + if r != 4294967295 { + t.Errorf("0 %s 4294967295 = %d, want 4294967295", "+", r) + } + x = 1 + y = 0 + r = x + y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "+", r) + } + y = 1 + r = x + y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "+", r) + } + y = 4294967295 + r = x + y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", "+", r) + } + x = 4294967295 + y = 0 + r = x + y + if r != 4294967295 { + t.Errorf("4294967295 %s 0 = %d, want 4294967295", "+", r) + } + y = 1 + r = x + y + if r != 0 { + t.Errorf("4294967295 %s 1 = %d, want 0", "+", r) + } + y = 4294967295 + r = x + y + if r != 4294967294 { + t.Errorf("4294967295 %s 4294967295 = %d, want 4294967294", "+", r) + } +} +func TestConstFolduint32sub(t *testing.T) { + var x, y, r uint32 + x = 0 + y = 0 + r = x - y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "-", r) + } + y = 1 + r = x - y + if r != 4294967295 { + t.Errorf("0 %s 1 = %d, want 4294967295", "-", r) + } + y = 4294967295 + r = x - y + if r != 1 { + t.Errorf("0 %s 4294967295 = %d, want 1", "-", r) + } + x = 1 + y = 0 + r = x - y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "-", r) + } + y = 1 + r = x - y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "-", r) + } + y = 4294967295 + r = x - y + if r != 2 { + t.Errorf("1 %s 4294967295 = %d, want 2", "-", r) + } + x = 4294967295 + y = 0 + r = x - y + if r != 4294967295 { + t.Errorf("4294967295 %s 0 = %d, want 4294967295", "-", r) + } + y = 1 + r = x - y + if r != 4294967294 { + t.Errorf("4294967295 %s 1 = %d, want 4294967294", "-", r) + } + y = 4294967295 + r = x - y + if r != 0 { + t.Errorf("4294967295 %s 4294967295 = %d, want 0", "-", r) + } +} +func TestConstFolduint32div(t *testing.T) { + var x, y, r uint32 + x = 0 + y = 1 + r = x / y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "/", r) + } + y = 4294967295 + r = x / y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "/", r) + } + x = 1 + y = 1 + r = x / y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "/", r) + } + y = 4294967295 + r = x / y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", "/", r) + } + x = 4294967295 + y = 1 + r = x / y + if r != 4294967295 { + t.Errorf("4294967295 %s 1 = %d, want 4294967295", "/", r) + } + y = 4294967295 + r = x / y + if r != 1 { + t.Errorf("4294967295 %s 4294967295 = %d, want 1", "/", r) + } +} +func TestConstFolduint32mul(t *testing.T) { + var x, y, r uint32 + x = 0 + y = 0 + r = x * y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "*", r) + } + y = 4294967295 + r = x * y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "*", r) + } + x = 1 + y = 0 + r = x * y + if r != 0 { + t.Errorf("1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "*", r) + } + y = 4294967295 + r = x * y + if r != 4294967295 { + t.Errorf("1 %s 4294967295 = %d, want 4294967295", "*", r) + } + x = 4294967295 + y = 0 + r = x * y + if r != 0 { + t.Errorf("4294967295 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 4294967295 { + t.Errorf("4294967295 %s 1 = %d, want 4294967295", "*", r) + } + y = 4294967295 + r = x * y + if r != 1 { + t.Errorf("4294967295 %s 4294967295 = %d, want 1", "*", r) + } +} +func TestConstFolduint32mod(t *testing.T) { + var x, y, r uint32 + x = 0 + y = 1 + r = x % y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "%", r) + } + y = 4294967295 + r = x % y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "%", r) + } + x = 1 + y = 1 + r = x % y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "%", r) + } + y = 4294967295 + r = x % y + if r != 1 { + t.Errorf("1 %s 4294967295 = %d, want 1", "%", r) + } + x = 4294967295 + y = 1 + r = x % y + if r != 0 { + t.Errorf("4294967295 %s 1 = %d, want 0", "%", r) + } + y = 4294967295 + r = x % y + if r != 0 { + t.Errorf("4294967295 %s 4294967295 = %d, want 0", "%", r) + } +} +func TestConstFoldint32add(t *testing.T) { + var x, y, r int32 + x = -2147483648 + y = -2147483648 + r = x + y + if r != 0 { + t.Errorf("-2147483648 %s -2147483648 = %d, want 0", "+", r) + } + y = -2147483647 + r = x + y + if r != 1 { + t.Errorf("-2147483648 %s -2147483647 = %d, want 1", "+", r) + } + y = -1 + r = x + y + if r != 2147483647 { + t.Errorf("-2147483648 %s -1 = %d, want 2147483647", "+", r) + } + y = 0 + r = x + y + if r != -2147483648 { + t.Errorf("-2147483648 %s 0 = %d, want -2147483648", "+", r) + } + y = 1 + r = x + y + if r != -2147483647 { + t.Errorf("-2147483648 %s 1 = %d, want -2147483647", "+", r) + } + y = 2147483647 + r = x + y + if r != -1 { + t.Errorf("-2147483648 %s 2147483647 = %d, want -1", "+", r) + } + x = -2147483647 + y = -2147483648 + r = x + y + if r != 1 { + t.Errorf("-2147483647 %s -2147483648 = %d, want 1", "+", r) + } + y = -2147483647 + r = x + y + if r != 2 { + t.Errorf("-2147483647 %s -2147483647 = %d, want 2", "+", r) + } + y = -1 + r = x + y + if r != -2147483648 { + t.Errorf("-2147483647 %s -1 = %d, want -2147483648", "+", r) + } + y = 0 + r = x + y + if r != -2147483647 { + t.Errorf("-2147483647 %s 0 = %d, want -2147483647", "+", r) + } + y = 1 + r = x + y + if r != -2147483646 { + t.Errorf("-2147483647 %s 1 = %d, want -2147483646", "+", r) + } + y = 2147483647 + r = x + y + if r != 0 { + t.Errorf("-2147483647 %s 2147483647 = %d, want 0", "+", r) + } + x = -1 + y = -2147483648 + r = x + y + if r != 2147483647 { + t.Errorf("-1 %s -2147483648 = %d, want 2147483647", "+", r) + } + y = -2147483647 + r = x + y + if r != -2147483648 { + t.Errorf("-1 %s -2147483647 = %d, want -2147483648", "+", r) + } + y = -1 + r = x + y + if r != -2 { + t.Errorf("-1 %s -1 = %d, want -2", "+", r) + } + y = 0 + r = x + y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "+", r) + } + y = 1 + r = x + y + if r != 0 { + t.Errorf("-1 %s 1 = %d, want 0", "+", r) + } + y = 2147483647 + r = x + y + if r != 2147483646 { + t.Errorf("-1 %s 2147483647 = %d, want 2147483646", "+", r) + } + x = 0 + y = -2147483648 + r = x + y + if r != -2147483648 { + t.Errorf("0 %s -2147483648 = %d, want -2147483648", "+", r) + } + y = -2147483647 + r = x + y + if r != -2147483647 { + t.Errorf("0 %s -2147483647 = %d, want -2147483647", "+", r) + } + y = -1 + r = x + y + if r != -1 { + t.Errorf("0 %s -1 = %d, want -1", "+", r) + } + y = 0 + r = x + y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "+", r) + } + y = 1 + r = x + y + if r != 1 { + t.Errorf("0 %s 1 = %d, want 1", "+", r) + } + y = 2147483647 + r = x + y + if r != 2147483647 { + t.Errorf("0 %s 2147483647 = %d, want 2147483647", "+", r) + } + x = 1 + y = -2147483648 + r = x + y + if r != -2147483647 { + t.Errorf("1 %s -2147483648 = %d, want -2147483647", "+", r) + } + y = -2147483647 + r = x + y + if r != -2147483646 { + t.Errorf("1 %s -2147483647 = %d, want -2147483646", "+", r) + } + y = -1 + r = x + y + if r != 0 { + t.Errorf("1 %s -1 = %d, want 0", "+", r) + } + y = 0 + r = x + y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "+", r) + } + y = 1 + r = x + y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "+", r) + } + y = 2147483647 + r = x + y + if r != -2147483648 { + t.Errorf("1 %s 2147483647 = %d, want -2147483648", "+", r) + } + x = 2147483647 + y = -2147483648 + r = x + y + if r != -1 { + t.Errorf("2147483647 %s -2147483648 = %d, want -1", "+", r) + } + y = -2147483647 + r = x + y + if r != 0 { + t.Errorf("2147483647 %s -2147483647 = %d, want 0", "+", r) + } + y = -1 + r = x + y + if r != 2147483646 { + t.Errorf("2147483647 %s -1 = %d, want 2147483646", "+", r) + } + y = 0 + r = x + y + if r != 2147483647 { + t.Errorf("2147483647 %s 0 = %d, want 2147483647", "+", r) + } + y = 1 + r = x + y + if r != -2147483648 { + t.Errorf("2147483647 %s 1 = %d, want -2147483648", "+", r) + } + y = 2147483647 + r = x + y + if r != -2 { + t.Errorf("2147483647 %s 2147483647 = %d, want -2", "+", r) + } +} +func TestConstFoldint32sub(t *testing.T) { + var x, y, r int32 + x = -2147483648 + y = -2147483648 + r = x - y + if r != 0 { + t.Errorf("-2147483648 %s -2147483648 = %d, want 0", "-", r) + } + y = -2147483647 + r = x - y + if r != -1 { + t.Errorf("-2147483648 %s -2147483647 = %d, want -1", "-", r) + } + y = -1 + r = x - y + if r != -2147483647 { + t.Errorf("-2147483648 %s -1 = %d, want -2147483647", "-", r) + } + y = 0 + r = x - y + if r != -2147483648 { + t.Errorf("-2147483648 %s 0 = %d, want -2147483648", "-", r) + } + y = 1 + r = x - y + if r != 2147483647 { + t.Errorf("-2147483648 %s 1 = %d, want 2147483647", "-", r) + } + y = 2147483647 + r = x - y + if r != 1 { + t.Errorf("-2147483648 %s 2147483647 = %d, want 1", "-", r) + } + x = -2147483647 + y = -2147483648 + r = x - y + if r != 1 { + t.Errorf("-2147483647 %s -2147483648 = %d, want 1", "-", r) + } + y = -2147483647 + r = x - y + if r != 0 { + t.Errorf("-2147483647 %s -2147483647 = %d, want 0", "-", r) + } + y = -1 + r = x - y + if r != -2147483646 { + t.Errorf("-2147483647 %s -1 = %d, want -2147483646", "-", r) + } + y = 0 + r = x - y + if r != -2147483647 { + t.Errorf("-2147483647 %s 0 = %d, want -2147483647", "-", r) + } + y = 1 + r = x - y + if r != -2147483648 { + t.Errorf("-2147483647 %s 1 = %d, want -2147483648", "-", r) + } + y = 2147483647 + r = x - y + if r != 2 { + t.Errorf("-2147483647 %s 2147483647 = %d, want 2", "-", r) + } + x = -1 + y = -2147483648 + r = x - y + if r != 2147483647 { + t.Errorf("-1 %s -2147483648 = %d, want 2147483647", "-", r) + } + y = -2147483647 + r = x - y + if r != 2147483646 { + t.Errorf("-1 %s -2147483647 = %d, want 2147483646", "-", r) + } + y = -1 + r = x - y + if r != 0 { + t.Errorf("-1 %s -1 = %d, want 0", "-", r) + } + y = 0 + r = x - y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "-", r) + } + y = 1 + r = x - y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "-", r) + } + y = 2147483647 + r = x - y + if r != -2147483648 { + t.Errorf("-1 %s 2147483647 = %d, want -2147483648", "-", r) + } + x = 0 + y = -2147483648 + r = x - y + if r != -2147483648 { + t.Errorf("0 %s -2147483648 = %d, want -2147483648", "-", r) + } + y = -2147483647 + r = x - y + if r != 2147483647 { + t.Errorf("0 %s -2147483647 = %d, want 2147483647", "-", r) + } + y = -1 + r = x - y + if r != 1 { + t.Errorf("0 %s -1 = %d, want 1", "-", r) + } + y = 0 + r = x - y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "-", r) + } + y = 1 + r = x - y + if r != -1 { + t.Errorf("0 %s 1 = %d, want -1", "-", r) + } + y = 2147483647 + r = x - y + if r != -2147483647 { + t.Errorf("0 %s 2147483647 = %d, want -2147483647", "-", r) + } + x = 1 + y = -2147483648 + r = x - y + if r != -2147483647 { + t.Errorf("1 %s -2147483648 = %d, want -2147483647", "-", r) + } + y = -2147483647 + r = x - y + if r != -2147483648 { + t.Errorf("1 %s -2147483647 = %d, want -2147483648", "-", r) + } + y = -1 + r = x - y + if r != 2 { + t.Errorf("1 %s -1 = %d, want 2", "-", r) + } + y = 0 + r = x - y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "-", r) + } + y = 1 + r = x - y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "-", r) + } + y = 2147483647 + r = x - y + if r != -2147483646 { + t.Errorf("1 %s 2147483647 = %d, want -2147483646", "-", r) + } + x = 2147483647 + y = -2147483648 + r = x - y + if r != -1 { + t.Errorf("2147483647 %s -2147483648 = %d, want -1", "-", r) + } + y = -2147483647 + r = x - y + if r != -2 { + t.Errorf("2147483647 %s -2147483647 = %d, want -2", "-", r) + } + y = -1 + r = x - y + if r != -2147483648 { + t.Errorf("2147483647 %s -1 = %d, want -2147483648", "-", r) + } + y = 0 + r = x - y + if r != 2147483647 { + t.Errorf("2147483647 %s 0 = %d, want 2147483647", "-", r) + } + y = 1 + r = x - y + if r != 2147483646 { + t.Errorf("2147483647 %s 1 = %d, want 2147483646", "-", r) + } + y = 2147483647 + r = x - y + if r != 0 { + t.Errorf("2147483647 %s 2147483647 = %d, want 0", "-", r) + } +} +func TestConstFoldint32div(t *testing.T) { + var x, y, r int32 + x = -2147483648 + y = -2147483648 + r = x / y + if r != 1 { + t.Errorf("-2147483648 %s -2147483648 = %d, want 1", "/", r) + } + y = -2147483647 + r = x / y + if r != 1 { + t.Errorf("-2147483648 %s -2147483647 = %d, want 1", "/", r) + } + y = -1 + r = x / y + if r != -2147483648 { + t.Errorf("-2147483648 %s -1 = %d, want -2147483648", "/", r) + } + y = 1 + r = x / y + if r != -2147483648 { + t.Errorf("-2147483648 %s 1 = %d, want -2147483648", "/", r) + } + y = 2147483647 + r = x / y + if r != -1 { + t.Errorf("-2147483648 %s 2147483647 = %d, want -1", "/", r) + } + x = -2147483647 + y = -2147483648 + r = x / y + if r != 0 { + t.Errorf("-2147483647 %s -2147483648 = %d, want 0", "/", r) + } + y = -2147483647 + r = x / y + if r != 1 { + t.Errorf("-2147483647 %s -2147483647 = %d, want 1", "/", r) + } + y = -1 + r = x / y + if r != 2147483647 { + t.Errorf("-2147483647 %s -1 = %d, want 2147483647", "/", r) + } + y = 1 + r = x / y + if r != -2147483647 { + t.Errorf("-2147483647 %s 1 = %d, want -2147483647", "/", r) + } + y = 2147483647 + r = x / y + if r != -1 { + t.Errorf("-2147483647 %s 2147483647 = %d, want -1", "/", r) + } + x = -1 + y = -2147483648 + r = x / y + if r != 0 { + t.Errorf("-1 %s -2147483648 = %d, want 0", "/", r) + } + y = -2147483647 + r = x / y + if r != 0 { + t.Errorf("-1 %s -2147483647 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != 1 { + t.Errorf("-1 %s -1 = %d, want 1", "/", r) + } + y = 1 + r = x / y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", "/", r) + } + y = 2147483647 + r = x / y + if r != 0 { + t.Errorf("-1 %s 2147483647 = %d, want 0", "/", r) + } + x = 0 + y = -2147483648 + r = x / y + if r != 0 { + t.Errorf("0 %s -2147483648 = %d, want 0", "/", r) + } + y = -2147483647 + r = x / y + if r != 0 { + t.Errorf("0 %s -2147483647 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "/", r) + } + y = 1 + r = x / y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "/", r) + } + y = 2147483647 + r = x / y + if r != 0 { + t.Errorf("0 %s 2147483647 = %d, want 0", "/", r) + } + x = 1 + y = -2147483648 + r = x / y + if r != 0 { + t.Errorf("1 %s -2147483648 = %d, want 0", "/", r) + } + y = -2147483647 + r = x / y + if r != 0 { + t.Errorf("1 %s -2147483647 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != -1 { + t.Errorf("1 %s -1 = %d, want -1", "/", r) + } + y = 1 + r = x / y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "/", r) + } + y = 2147483647 + r = x / y + if r != 0 { + t.Errorf("1 %s 2147483647 = %d, want 0", "/", r) + } + x = 2147483647 + y = -2147483648 + r = x / y + if r != 0 { + t.Errorf("2147483647 %s -2147483648 = %d, want 0", "/", r) + } + y = -2147483647 + r = x / y + if r != -1 { + t.Errorf("2147483647 %s -2147483647 = %d, want -1", "/", r) + } + y = -1 + r = x / y + if r != -2147483647 { + t.Errorf("2147483647 %s -1 = %d, want -2147483647", "/", r) + } + y = 1 + r = x / y + if r != 2147483647 { + t.Errorf("2147483647 %s 1 = %d, want 2147483647", "/", r) + } + y = 2147483647 + r = x / y + if r != 1 { + t.Errorf("2147483647 %s 2147483647 = %d, want 1", "/", r) + } +} +func TestConstFoldint32mul(t *testing.T) { + var x, y, r int32 + x = -2147483648 + y = -2147483648 + r = x * y + if r != 0 { + t.Errorf("-2147483648 %s -2147483648 = %d, want 0", "*", r) + } + y = -2147483647 + r = x * y + if r != -2147483648 { + t.Errorf("-2147483648 %s -2147483647 = %d, want -2147483648", "*", r) + } + y = -1 + r = x * y + if r != -2147483648 { + t.Errorf("-2147483648 %s -1 = %d, want -2147483648", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-2147483648 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -2147483648 { + t.Errorf("-2147483648 %s 1 = %d, want -2147483648", "*", r) + } + y = 2147483647 + r = x * y + if r != -2147483648 { + t.Errorf("-2147483648 %s 2147483647 = %d, want -2147483648", "*", r) + } + x = -2147483647 + y = -2147483648 + r = x * y + if r != -2147483648 { + t.Errorf("-2147483647 %s -2147483648 = %d, want -2147483648", "*", r) + } + y = -2147483647 + r = x * y + if r != 1 { + t.Errorf("-2147483647 %s -2147483647 = %d, want 1", "*", r) + } + y = -1 + r = x * y + if r != 2147483647 { + t.Errorf("-2147483647 %s -1 = %d, want 2147483647", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-2147483647 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -2147483647 { + t.Errorf("-2147483647 %s 1 = %d, want -2147483647", "*", r) + } + y = 2147483647 + r = x * y + if r != -1 { + t.Errorf("-2147483647 %s 2147483647 = %d, want -1", "*", r) + } + x = -1 + y = -2147483648 + r = x * y + if r != -2147483648 { + t.Errorf("-1 %s -2147483648 = %d, want -2147483648", "*", r) + } + y = -2147483647 + r = x * y + if r != 2147483647 { + t.Errorf("-1 %s -2147483647 = %d, want 2147483647", "*", r) + } + y = -1 + r = x * y + if r != 1 { + t.Errorf("-1 %s -1 = %d, want 1", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", "*", r) + } + y = 2147483647 + r = x * y + if r != -2147483647 { + t.Errorf("-1 %s 2147483647 = %d, want -2147483647", "*", r) + } + x = 0 + y = -2147483648 + r = x * y + if r != 0 { + t.Errorf("0 %s -2147483648 = %d, want 0", "*", r) + } + y = -2147483647 + r = x * y + if r != 0 { + t.Errorf("0 %s -2147483647 = %d, want 0", "*", r) + } + y = -1 + r = x * y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "*", r) + } + y = 2147483647 + r = x * y + if r != 0 { + t.Errorf("0 %s 2147483647 = %d, want 0", "*", r) + } + x = 1 + y = -2147483648 + r = x * y + if r != -2147483648 { + t.Errorf("1 %s -2147483648 = %d, want -2147483648", "*", r) + } + y = -2147483647 + r = x * y + if r != -2147483647 { + t.Errorf("1 %s -2147483647 = %d, want -2147483647", "*", r) + } + y = -1 + r = x * y + if r != -1 { + t.Errorf("1 %s -1 = %d, want -1", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "*", r) + } + y = 2147483647 + r = x * y + if r != 2147483647 { + t.Errorf("1 %s 2147483647 = %d, want 2147483647", "*", r) + } + x = 2147483647 + y = -2147483648 + r = x * y + if r != -2147483648 { + t.Errorf("2147483647 %s -2147483648 = %d, want -2147483648", "*", r) + } + y = -2147483647 + r = x * y + if r != -1 { + t.Errorf("2147483647 %s -2147483647 = %d, want -1", "*", r) + } + y = -1 + r = x * y + if r != -2147483647 { + t.Errorf("2147483647 %s -1 = %d, want -2147483647", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("2147483647 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 2147483647 { + t.Errorf("2147483647 %s 1 = %d, want 2147483647", "*", r) + } + y = 2147483647 + r = x * y + if r != 1 { + t.Errorf("2147483647 %s 2147483647 = %d, want 1", "*", r) + } +} +func TestConstFoldint32mod(t *testing.T) { + var x, y, r int32 + x = -2147483648 + y = -2147483648 + r = x % y + if r != 0 { + t.Errorf("-2147483648 %s -2147483648 = %d, want 0", "%", r) + } + y = -2147483647 + r = x % y + if r != -1 { + t.Errorf("-2147483648 %s -2147483647 = %d, want -1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-2147483648 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-2147483648 %s 1 = %d, want 0", "%", r) + } + y = 2147483647 + r = x % y + if r != -1 { + t.Errorf("-2147483648 %s 2147483647 = %d, want -1", "%", r) + } + x = -2147483647 + y = -2147483648 + r = x % y + if r != -2147483647 { + t.Errorf("-2147483647 %s -2147483648 = %d, want -2147483647", "%", r) + } + y = -2147483647 + r = x % y + if r != 0 { + t.Errorf("-2147483647 %s -2147483647 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-2147483647 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-2147483647 %s 1 = %d, want 0", "%", r) + } + y = 2147483647 + r = x % y + if r != 0 { + t.Errorf("-2147483647 %s 2147483647 = %d, want 0", "%", r) + } + x = -1 + y = -2147483648 + r = x % y + if r != -1 { + t.Errorf("-1 %s -2147483648 = %d, want -1", "%", r) + } + y = -2147483647 + r = x % y + if r != -1 { + t.Errorf("-1 %s -2147483647 = %d, want -1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-1 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-1 %s 1 = %d, want 0", "%", r) + } + y = 2147483647 + r = x % y + if r != -1 { + t.Errorf("-1 %s 2147483647 = %d, want -1", "%", r) + } + x = 0 + y = -2147483648 + r = x % y + if r != 0 { + t.Errorf("0 %s -2147483648 = %d, want 0", "%", r) + } + y = -2147483647 + r = x % y + if r != 0 { + t.Errorf("0 %s -2147483647 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "%", r) + } + y = 2147483647 + r = x % y + if r != 0 { + t.Errorf("0 %s 2147483647 = %d, want 0", "%", r) + } + x = 1 + y = -2147483648 + r = x % y + if r != 1 { + t.Errorf("1 %s -2147483648 = %d, want 1", "%", r) + } + y = -2147483647 + r = x % y + if r != 1 { + t.Errorf("1 %s -2147483647 = %d, want 1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("1 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "%", r) + } + y = 2147483647 + r = x % y + if r != 1 { + t.Errorf("1 %s 2147483647 = %d, want 1", "%", r) + } + x = 2147483647 + y = -2147483648 + r = x % y + if r != 2147483647 { + t.Errorf("2147483647 %s -2147483648 = %d, want 2147483647", "%", r) + } + y = -2147483647 + r = x % y + if r != 0 { + t.Errorf("2147483647 %s -2147483647 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("2147483647 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("2147483647 %s 1 = %d, want 0", "%", r) + } + y = 2147483647 + r = x % y + if r != 0 { + t.Errorf("2147483647 %s 2147483647 = %d, want 0", "%", r) + } +} +func TestConstFolduint16add(t *testing.T) { + var x, y, r uint16 + x = 0 + y = 0 + r = x + y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "+", r) + } + y = 1 + r = x + y + if r != 1 { + t.Errorf("0 %s 1 = %d, want 1", "+", r) + } + y = 65535 + r = x + y + if r != 65535 { + t.Errorf("0 %s 65535 = %d, want 65535", "+", r) + } + x = 1 + y = 0 + r = x + y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "+", r) + } + y = 1 + r = x + y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "+", r) + } + y = 65535 + r = x + y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", "+", r) + } + x = 65535 + y = 0 + r = x + y + if r != 65535 { + t.Errorf("65535 %s 0 = %d, want 65535", "+", r) + } + y = 1 + r = x + y + if r != 0 { + t.Errorf("65535 %s 1 = %d, want 0", "+", r) + } + y = 65535 + r = x + y + if r != 65534 { + t.Errorf("65535 %s 65535 = %d, want 65534", "+", r) + } +} +func TestConstFolduint16sub(t *testing.T) { + var x, y, r uint16 + x = 0 + y = 0 + r = x - y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "-", r) + } + y = 1 + r = x - y + if r != 65535 { + t.Errorf("0 %s 1 = %d, want 65535", "-", r) + } + y = 65535 + r = x - y + if r != 1 { + t.Errorf("0 %s 65535 = %d, want 1", "-", r) + } + x = 1 + y = 0 + r = x - y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "-", r) + } + y = 1 + r = x - y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "-", r) + } + y = 65535 + r = x - y + if r != 2 { + t.Errorf("1 %s 65535 = %d, want 2", "-", r) + } + x = 65535 + y = 0 + r = x - y + if r != 65535 { + t.Errorf("65535 %s 0 = %d, want 65535", "-", r) + } + y = 1 + r = x - y + if r != 65534 { + t.Errorf("65535 %s 1 = %d, want 65534", "-", r) + } + y = 65535 + r = x - y + if r != 0 { + t.Errorf("65535 %s 65535 = %d, want 0", "-", r) + } +} +func TestConstFolduint16div(t *testing.T) { + var x, y, r uint16 + x = 0 + y = 1 + r = x / y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "/", r) + } + y = 65535 + r = x / y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "/", r) + } + x = 1 + y = 1 + r = x / y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "/", r) + } + y = 65535 + r = x / y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", "/", r) + } + x = 65535 + y = 1 + r = x / y + if r != 65535 { + t.Errorf("65535 %s 1 = %d, want 65535", "/", r) + } + y = 65535 + r = x / y + if r != 1 { + t.Errorf("65535 %s 65535 = %d, want 1", "/", r) + } +} +func TestConstFolduint16mul(t *testing.T) { + var x, y, r uint16 + x = 0 + y = 0 + r = x * y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "*", r) + } + y = 65535 + r = x * y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "*", r) + } + x = 1 + y = 0 + r = x * y + if r != 0 { + t.Errorf("1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "*", r) + } + y = 65535 + r = x * y + if r != 65535 { + t.Errorf("1 %s 65535 = %d, want 65535", "*", r) + } + x = 65535 + y = 0 + r = x * y + if r != 0 { + t.Errorf("65535 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 65535 { + t.Errorf("65535 %s 1 = %d, want 65535", "*", r) + } + y = 65535 + r = x * y + if r != 1 { + t.Errorf("65535 %s 65535 = %d, want 1", "*", r) + } +} +func TestConstFolduint16mod(t *testing.T) { + var x, y, r uint16 + x = 0 + y = 1 + r = x % y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "%", r) + } + y = 65535 + r = x % y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "%", r) + } + x = 1 + y = 1 + r = x % y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "%", r) + } + y = 65535 + r = x % y + if r != 1 { + t.Errorf("1 %s 65535 = %d, want 1", "%", r) + } + x = 65535 + y = 1 + r = x % y + if r != 0 { + t.Errorf("65535 %s 1 = %d, want 0", "%", r) + } + y = 65535 + r = x % y + if r != 0 { + t.Errorf("65535 %s 65535 = %d, want 0", "%", r) + } +} +func TestConstFoldint16add(t *testing.T) { + var x, y, r int16 + x = -32768 + y = -32768 + r = x + y + if r != 0 { + t.Errorf("-32768 %s -32768 = %d, want 0", "+", r) + } + y = -32767 + r = x + y + if r != 1 { + t.Errorf("-32768 %s -32767 = %d, want 1", "+", r) + } + y = -1 + r = x + y + if r != 32767 { + t.Errorf("-32768 %s -1 = %d, want 32767", "+", r) + } + y = 0 + r = x + y + if r != -32768 { + t.Errorf("-32768 %s 0 = %d, want -32768", "+", r) + } + y = 1 + r = x + y + if r != -32767 { + t.Errorf("-32768 %s 1 = %d, want -32767", "+", r) + } + y = 32766 + r = x + y + if r != -2 { + t.Errorf("-32768 %s 32766 = %d, want -2", "+", r) + } + y = 32767 + r = x + y + if r != -1 { + t.Errorf("-32768 %s 32767 = %d, want -1", "+", r) + } + x = -32767 + y = -32768 + r = x + y + if r != 1 { + t.Errorf("-32767 %s -32768 = %d, want 1", "+", r) + } + y = -32767 + r = x + y + if r != 2 { + t.Errorf("-32767 %s -32767 = %d, want 2", "+", r) + } + y = -1 + r = x + y + if r != -32768 { + t.Errorf("-32767 %s -1 = %d, want -32768", "+", r) + } + y = 0 + r = x + y + if r != -32767 { + t.Errorf("-32767 %s 0 = %d, want -32767", "+", r) + } + y = 1 + r = x + y + if r != -32766 { + t.Errorf("-32767 %s 1 = %d, want -32766", "+", r) + } + y = 32766 + r = x + y + if r != -1 { + t.Errorf("-32767 %s 32766 = %d, want -1", "+", r) + } + y = 32767 + r = x + y + if r != 0 { + t.Errorf("-32767 %s 32767 = %d, want 0", "+", r) + } + x = -1 + y = -32768 + r = x + y + if r != 32767 { + t.Errorf("-1 %s -32768 = %d, want 32767", "+", r) + } + y = -32767 + r = x + y + if r != -32768 { + t.Errorf("-1 %s -32767 = %d, want -32768", "+", r) + } + y = -1 + r = x + y + if r != -2 { + t.Errorf("-1 %s -1 = %d, want -2", "+", r) + } + y = 0 + r = x + y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "+", r) + } + y = 1 + r = x + y + if r != 0 { + t.Errorf("-1 %s 1 = %d, want 0", "+", r) + } + y = 32766 + r = x + y + if r != 32765 { + t.Errorf("-1 %s 32766 = %d, want 32765", "+", r) + } + y = 32767 + r = x + y + if r != 32766 { + t.Errorf("-1 %s 32767 = %d, want 32766", "+", r) + } + x = 0 + y = -32768 + r = x + y + if r != -32768 { + t.Errorf("0 %s -32768 = %d, want -32768", "+", r) + } + y = -32767 + r = x + y + if r != -32767 { + t.Errorf("0 %s -32767 = %d, want -32767", "+", r) + } + y = -1 + r = x + y + if r != -1 { + t.Errorf("0 %s -1 = %d, want -1", "+", r) + } + y = 0 + r = x + y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "+", r) + } + y = 1 + r = x + y + if r != 1 { + t.Errorf("0 %s 1 = %d, want 1", "+", r) + } + y = 32766 + r = x + y + if r != 32766 { + t.Errorf("0 %s 32766 = %d, want 32766", "+", r) + } + y = 32767 + r = x + y + if r != 32767 { + t.Errorf("0 %s 32767 = %d, want 32767", "+", r) + } + x = 1 + y = -32768 + r = x + y + if r != -32767 { + t.Errorf("1 %s -32768 = %d, want -32767", "+", r) + } + y = -32767 + r = x + y + if r != -32766 { + t.Errorf("1 %s -32767 = %d, want -32766", "+", r) + } + y = -1 + r = x + y + if r != 0 { + t.Errorf("1 %s -1 = %d, want 0", "+", r) + } + y = 0 + r = x + y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "+", r) + } + y = 1 + r = x + y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "+", r) + } + y = 32766 + r = x + y + if r != 32767 { + t.Errorf("1 %s 32766 = %d, want 32767", "+", r) + } + y = 32767 + r = x + y + if r != -32768 { + t.Errorf("1 %s 32767 = %d, want -32768", "+", r) + } + x = 32766 + y = -32768 + r = x + y + if r != -2 { + t.Errorf("32766 %s -32768 = %d, want -2", "+", r) + } + y = -32767 + r = x + y + if r != -1 { + t.Errorf("32766 %s -32767 = %d, want -1", "+", r) + } + y = -1 + r = x + y + if r != 32765 { + t.Errorf("32766 %s -1 = %d, want 32765", "+", r) + } + y = 0 + r = x + y + if r != 32766 { + t.Errorf("32766 %s 0 = %d, want 32766", "+", r) + } + y = 1 + r = x + y + if r != 32767 { + t.Errorf("32766 %s 1 = %d, want 32767", "+", r) + } + y = 32766 + r = x + y + if r != -4 { + t.Errorf("32766 %s 32766 = %d, want -4", "+", r) + } + y = 32767 + r = x + y + if r != -3 { + t.Errorf("32766 %s 32767 = %d, want -3", "+", r) + } + x = 32767 + y = -32768 + r = x + y + if r != -1 { + t.Errorf("32767 %s -32768 = %d, want -1", "+", r) + } + y = -32767 + r = x + y + if r != 0 { + t.Errorf("32767 %s -32767 = %d, want 0", "+", r) + } + y = -1 + r = x + y + if r != 32766 { + t.Errorf("32767 %s -1 = %d, want 32766", "+", r) + } + y = 0 + r = x + y + if r != 32767 { + t.Errorf("32767 %s 0 = %d, want 32767", "+", r) + } + y = 1 + r = x + y + if r != -32768 { + t.Errorf("32767 %s 1 = %d, want -32768", "+", r) + } + y = 32766 + r = x + y + if r != -3 { + t.Errorf("32767 %s 32766 = %d, want -3", "+", r) + } + y = 32767 + r = x + y + if r != -2 { + t.Errorf("32767 %s 32767 = %d, want -2", "+", r) + } +} +func TestConstFoldint16sub(t *testing.T) { + var x, y, r int16 + x = -32768 + y = -32768 + r = x - y + if r != 0 { + t.Errorf("-32768 %s -32768 = %d, want 0", "-", r) + } + y = -32767 + r = x - y + if r != -1 { + t.Errorf("-32768 %s -32767 = %d, want -1", "-", r) + } + y = -1 + r = x - y + if r != -32767 { + t.Errorf("-32768 %s -1 = %d, want -32767", "-", r) + } + y = 0 + r = x - y + if r != -32768 { + t.Errorf("-32768 %s 0 = %d, want -32768", "-", r) + } + y = 1 + r = x - y + if r != 32767 { + t.Errorf("-32768 %s 1 = %d, want 32767", "-", r) + } + y = 32766 + r = x - y + if r != 2 { + t.Errorf("-32768 %s 32766 = %d, want 2", "-", r) + } + y = 32767 + r = x - y + if r != 1 { + t.Errorf("-32768 %s 32767 = %d, want 1", "-", r) + } + x = -32767 + y = -32768 + r = x - y + if r != 1 { + t.Errorf("-32767 %s -32768 = %d, want 1", "-", r) + } + y = -32767 + r = x - y + if r != 0 { + t.Errorf("-32767 %s -32767 = %d, want 0", "-", r) + } + y = -1 + r = x - y + if r != -32766 { + t.Errorf("-32767 %s -1 = %d, want -32766", "-", r) + } + y = 0 + r = x - y + if r != -32767 { + t.Errorf("-32767 %s 0 = %d, want -32767", "-", r) + } + y = 1 + r = x - y + if r != -32768 { + t.Errorf("-32767 %s 1 = %d, want -32768", "-", r) + } + y = 32766 + r = x - y + if r != 3 { + t.Errorf("-32767 %s 32766 = %d, want 3", "-", r) + } + y = 32767 + r = x - y + if r != 2 { + t.Errorf("-32767 %s 32767 = %d, want 2", "-", r) + } + x = -1 + y = -32768 + r = x - y + if r != 32767 { + t.Errorf("-1 %s -32768 = %d, want 32767", "-", r) + } + y = -32767 + r = x - y + if r != 32766 { + t.Errorf("-1 %s -32767 = %d, want 32766", "-", r) + } + y = -1 + r = x - y + if r != 0 { + t.Errorf("-1 %s -1 = %d, want 0", "-", r) + } + y = 0 + r = x - y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "-", r) + } + y = 1 + r = x - y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "-", r) + } + y = 32766 + r = x - y + if r != -32767 { + t.Errorf("-1 %s 32766 = %d, want -32767", "-", r) + } + y = 32767 + r = x - y + if r != -32768 { + t.Errorf("-1 %s 32767 = %d, want -32768", "-", r) + } + x = 0 + y = -32768 + r = x - y + if r != -32768 { + t.Errorf("0 %s -32768 = %d, want -32768", "-", r) + } + y = -32767 + r = x - y + if r != 32767 { + t.Errorf("0 %s -32767 = %d, want 32767", "-", r) + } + y = -1 + r = x - y + if r != 1 { + t.Errorf("0 %s -1 = %d, want 1", "-", r) + } + y = 0 + r = x - y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "-", r) + } + y = 1 + r = x - y + if r != -1 { + t.Errorf("0 %s 1 = %d, want -1", "-", r) + } + y = 32766 + r = x - y + if r != -32766 { + t.Errorf("0 %s 32766 = %d, want -32766", "-", r) + } + y = 32767 + r = x - y + if r != -32767 { + t.Errorf("0 %s 32767 = %d, want -32767", "-", r) + } + x = 1 + y = -32768 + r = x - y + if r != -32767 { + t.Errorf("1 %s -32768 = %d, want -32767", "-", r) + } + y = -32767 + r = x - y + if r != -32768 { + t.Errorf("1 %s -32767 = %d, want -32768", "-", r) + } + y = -1 + r = x - y + if r != 2 { + t.Errorf("1 %s -1 = %d, want 2", "-", r) + } + y = 0 + r = x - y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "-", r) + } + y = 1 + r = x - y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "-", r) + } + y = 32766 + r = x - y + if r != -32765 { + t.Errorf("1 %s 32766 = %d, want -32765", "-", r) + } + y = 32767 + r = x - y + if r != -32766 { + t.Errorf("1 %s 32767 = %d, want -32766", "-", r) + } + x = 32766 + y = -32768 + r = x - y + if r != -2 { + t.Errorf("32766 %s -32768 = %d, want -2", "-", r) + } + y = -32767 + r = x - y + if r != -3 { + t.Errorf("32766 %s -32767 = %d, want -3", "-", r) + } + y = -1 + r = x - y + if r != 32767 { + t.Errorf("32766 %s -1 = %d, want 32767", "-", r) + } + y = 0 + r = x - y + if r != 32766 { + t.Errorf("32766 %s 0 = %d, want 32766", "-", r) + } + y = 1 + r = x - y + if r != 32765 { + t.Errorf("32766 %s 1 = %d, want 32765", "-", r) + } + y = 32766 + r = x - y + if r != 0 { + t.Errorf("32766 %s 32766 = %d, want 0", "-", r) + } + y = 32767 + r = x - y + if r != -1 { + t.Errorf("32766 %s 32767 = %d, want -1", "-", r) + } + x = 32767 + y = -32768 + r = x - y + if r != -1 { + t.Errorf("32767 %s -32768 = %d, want -1", "-", r) + } + y = -32767 + r = x - y + if r != -2 { + t.Errorf("32767 %s -32767 = %d, want -2", "-", r) + } + y = -1 + r = x - y + if r != -32768 { + t.Errorf("32767 %s -1 = %d, want -32768", "-", r) + } + y = 0 + r = x - y + if r != 32767 { + t.Errorf("32767 %s 0 = %d, want 32767", "-", r) + } + y = 1 + r = x - y + if r != 32766 { + t.Errorf("32767 %s 1 = %d, want 32766", "-", r) + } + y = 32766 + r = x - y + if r != 1 { + t.Errorf("32767 %s 32766 = %d, want 1", "-", r) + } + y = 32767 + r = x - y + if r != 0 { + t.Errorf("32767 %s 32767 = %d, want 0", "-", r) + } +} +func TestConstFoldint16div(t *testing.T) { + var x, y, r int16 + x = -32768 + y = -32768 + r = x / y + if r != 1 { + t.Errorf("-32768 %s -32768 = %d, want 1", "/", r) + } + y = -32767 + r = x / y + if r != 1 { + t.Errorf("-32768 %s -32767 = %d, want 1", "/", r) + } + y = -1 + r = x / y + if r != -32768 { + t.Errorf("-32768 %s -1 = %d, want -32768", "/", r) + } + y = 1 + r = x / y + if r != -32768 { + t.Errorf("-32768 %s 1 = %d, want -32768", "/", r) + } + y = 32766 + r = x / y + if r != -1 { + t.Errorf("-32768 %s 32766 = %d, want -1", "/", r) + } + y = 32767 + r = x / y + if r != -1 { + t.Errorf("-32768 %s 32767 = %d, want -1", "/", r) + } + x = -32767 + y = -32768 + r = x / y + if r != 0 { + t.Errorf("-32767 %s -32768 = %d, want 0", "/", r) + } + y = -32767 + r = x / y + if r != 1 { + t.Errorf("-32767 %s -32767 = %d, want 1", "/", r) + } + y = -1 + r = x / y + if r != 32767 { + t.Errorf("-32767 %s -1 = %d, want 32767", "/", r) + } + y = 1 + r = x / y + if r != -32767 { + t.Errorf("-32767 %s 1 = %d, want -32767", "/", r) + } + y = 32766 + r = x / y + if r != -1 { + t.Errorf("-32767 %s 32766 = %d, want -1", "/", r) + } + y = 32767 + r = x / y + if r != -1 { + t.Errorf("-32767 %s 32767 = %d, want -1", "/", r) + } + x = -1 + y = -32768 + r = x / y + if r != 0 { + t.Errorf("-1 %s -32768 = %d, want 0", "/", r) + } + y = -32767 + r = x / y + if r != 0 { + t.Errorf("-1 %s -32767 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != 1 { + t.Errorf("-1 %s -1 = %d, want 1", "/", r) + } + y = 1 + r = x / y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", "/", r) + } + y = 32766 + r = x / y + if r != 0 { + t.Errorf("-1 %s 32766 = %d, want 0", "/", r) + } + y = 32767 + r = x / y + if r != 0 { + t.Errorf("-1 %s 32767 = %d, want 0", "/", r) + } + x = 0 + y = -32768 + r = x / y + if r != 0 { + t.Errorf("0 %s -32768 = %d, want 0", "/", r) + } + y = -32767 + r = x / y + if r != 0 { + t.Errorf("0 %s -32767 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "/", r) + } + y = 1 + r = x / y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "/", r) + } + y = 32766 + r = x / y + if r != 0 { + t.Errorf("0 %s 32766 = %d, want 0", "/", r) + } + y = 32767 + r = x / y + if r != 0 { + t.Errorf("0 %s 32767 = %d, want 0", "/", r) + } + x = 1 + y = -32768 + r = x / y + if r != 0 { + t.Errorf("1 %s -32768 = %d, want 0", "/", r) + } + y = -32767 + r = x / y + if r != 0 { + t.Errorf("1 %s -32767 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != -1 { + t.Errorf("1 %s -1 = %d, want -1", "/", r) + } + y = 1 + r = x / y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "/", r) + } + y = 32766 + r = x / y + if r != 0 { + t.Errorf("1 %s 32766 = %d, want 0", "/", r) + } + y = 32767 + r = x / y + if r != 0 { + t.Errorf("1 %s 32767 = %d, want 0", "/", r) + } + x = 32766 + y = -32768 + r = x / y + if r != 0 { + t.Errorf("32766 %s -32768 = %d, want 0", "/", r) + } + y = -32767 + r = x / y + if r != 0 { + t.Errorf("32766 %s -32767 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != -32766 { + t.Errorf("32766 %s -1 = %d, want -32766", "/", r) + } + y = 1 + r = x / y + if r != 32766 { + t.Errorf("32766 %s 1 = %d, want 32766", "/", r) + } + y = 32766 + r = x / y + if r != 1 { + t.Errorf("32766 %s 32766 = %d, want 1", "/", r) + } + y = 32767 + r = x / y + if r != 0 { + t.Errorf("32766 %s 32767 = %d, want 0", "/", r) + } + x = 32767 + y = -32768 + r = x / y + if r != 0 { + t.Errorf("32767 %s -32768 = %d, want 0", "/", r) + } + y = -32767 + r = x / y + if r != -1 { + t.Errorf("32767 %s -32767 = %d, want -1", "/", r) + } + y = -1 + r = x / y + if r != -32767 { + t.Errorf("32767 %s -1 = %d, want -32767", "/", r) + } + y = 1 + r = x / y + if r != 32767 { + t.Errorf("32767 %s 1 = %d, want 32767", "/", r) + } + y = 32766 + r = x / y + if r != 1 { + t.Errorf("32767 %s 32766 = %d, want 1", "/", r) + } + y = 32767 + r = x / y + if r != 1 { + t.Errorf("32767 %s 32767 = %d, want 1", "/", r) + } +} +func TestConstFoldint16mul(t *testing.T) { + var x, y, r int16 + x = -32768 + y = -32768 + r = x * y + if r != 0 { + t.Errorf("-32768 %s -32768 = %d, want 0", "*", r) + } + y = -32767 + r = x * y + if r != -32768 { + t.Errorf("-32768 %s -32767 = %d, want -32768", "*", r) + } + y = -1 + r = x * y + if r != -32768 { + t.Errorf("-32768 %s -1 = %d, want -32768", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-32768 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -32768 { + t.Errorf("-32768 %s 1 = %d, want -32768", "*", r) + } + y = 32766 + r = x * y + if r != 0 { + t.Errorf("-32768 %s 32766 = %d, want 0", "*", r) + } + y = 32767 + r = x * y + if r != -32768 { + t.Errorf("-32768 %s 32767 = %d, want -32768", "*", r) + } + x = -32767 + y = -32768 + r = x * y + if r != -32768 { + t.Errorf("-32767 %s -32768 = %d, want -32768", "*", r) + } + y = -32767 + r = x * y + if r != 1 { + t.Errorf("-32767 %s -32767 = %d, want 1", "*", r) + } + y = -1 + r = x * y + if r != 32767 { + t.Errorf("-32767 %s -1 = %d, want 32767", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-32767 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -32767 { + t.Errorf("-32767 %s 1 = %d, want -32767", "*", r) + } + y = 32766 + r = x * y + if r != 32766 { + t.Errorf("-32767 %s 32766 = %d, want 32766", "*", r) + } + y = 32767 + r = x * y + if r != -1 { + t.Errorf("-32767 %s 32767 = %d, want -1", "*", r) + } + x = -1 + y = -32768 + r = x * y + if r != -32768 { + t.Errorf("-1 %s -32768 = %d, want -32768", "*", r) + } + y = -32767 + r = x * y + if r != 32767 { + t.Errorf("-1 %s -32767 = %d, want 32767", "*", r) + } + y = -1 + r = x * y + if r != 1 { + t.Errorf("-1 %s -1 = %d, want 1", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", "*", r) + } + y = 32766 + r = x * y + if r != -32766 { + t.Errorf("-1 %s 32766 = %d, want -32766", "*", r) + } + y = 32767 + r = x * y + if r != -32767 { + t.Errorf("-1 %s 32767 = %d, want -32767", "*", r) + } + x = 0 + y = -32768 + r = x * y + if r != 0 { + t.Errorf("0 %s -32768 = %d, want 0", "*", r) + } + y = -32767 + r = x * y + if r != 0 { + t.Errorf("0 %s -32767 = %d, want 0", "*", r) + } + y = -1 + r = x * y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "*", r) + } + y = 32766 + r = x * y + if r != 0 { + t.Errorf("0 %s 32766 = %d, want 0", "*", r) + } + y = 32767 + r = x * y + if r != 0 { + t.Errorf("0 %s 32767 = %d, want 0", "*", r) + } + x = 1 + y = -32768 + r = x * y + if r != -32768 { + t.Errorf("1 %s -32768 = %d, want -32768", "*", r) + } + y = -32767 + r = x * y + if r != -32767 { + t.Errorf("1 %s -32767 = %d, want -32767", "*", r) + } + y = -1 + r = x * y + if r != -1 { + t.Errorf("1 %s -1 = %d, want -1", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "*", r) + } + y = 32766 + r = x * y + if r != 32766 { + t.Errorf("1 %s 32766 = %d, want 32766", "*", r) + } + y = 32767 + r = x * y + if r != 32767 { + t.Errorf("1 %s 32767 = %d, want 32767", "*", r) + } + x = 32766 + y = -32768 + r = x * y + if r != 0 { + t.Errorf("32766 %s -32768 = %d, want 0", "*", r) + } + y = -32767 + r = x * y + if r != 32766 { + t.Errorf("32766 %s -32767 = %d, want 32766", "*", r) + } + y = -1 + r = x * y + if r != -32766 { + t.Errorf("32766 %s -1 = %d, want -32766", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("32766 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 32766 { + t.Errorf("32766 %s 1 = %d, want 32766", "*", r) + } + y = 32766 + r = x * y + if r != 4 { + t.Errorf("32766 %s 32766 = %d, want 4", "*", r) + } + y = 32767 + r = x * y + if r != -32766 { + t.Errorf("32766 %s 32767 = %d, want -32766", "*", r) + } + x = 32767 + y = -32768 + r = x * y + if r != -32768 { + t.Errorf("32767 %s -32768 = %d, want -32768", "*", r) + } + y = -32767 + r = x * y + if r != -1 { + t.Errorf("32767 %s -32767 = %d, want -1", "*", r) + } + y = -1 + r = x * y + if r != -32767 { + t.Errorf("32767 %s -1 = %d, want -32767", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("32767 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 32767 { + t.Errorf("32767 %s 1 = %d, want 32767", "*", r) + } + y = 32766 + r = x * y + if r != -32766 { + t.Errorf("32767 %s 32766 = %d, want -32766", "*", r) + } + y = 32767 + r = x * y + if r != 1 { + t.Errorf("32767 %s 32767 = %d, want 1", "*", r) + } +} +func TestConstFoldint16mod(t *testing.T) { + var x, y, r int16 + x = -32768 + y = -32768 + r = x % y + if r != 0 { + t.Errorf("-32768 %s -32768 = %d, want 0", "%", r) + } + y = -32767 + r = x % y + if r != -1 { + t.Errorf("-32768 %s -32767 = %d, want -1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-32768 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-32768 %s 1 = %d, want 0", "%", r) + } + y = 32766 + r = x % y + if r != -2 { + t.Errorf("-32768 %s 32766 = %d, want -2", "%", r) + } + y = 32767 + r = x % y + if r != -1 { + t.Errorf("-32768 %s 32767 = %d, want -1", "%", r) + } + x = -32767 + y = -32768 + r = x % y + if r != -32767 { + t.Errorf("-32767 %s -32768 = %d, want -32767", "%", r) + } + y = -32767 + r = x % y + if r != 0 { + t.Errorf("-32767 %s -32767 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-32767 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-32767 %s 1 = %d, want 0", "%", r) + } + y = 32766 + r = x % y + if r != -1 { + t.Errorf("-32767 %s 32766 = %d, want -1", "%", r) + } + y = 32767 + r = x % y + if r != 0 { + t.Errorf("-32767 %s 32767 = %d, want 0", "%", r) + } + x = -1 + y = -32768 + r = x % y + if r != -1 { + t.Errorf("-1 %s -32768 = %d, want -1", "%", r) + } + y = -32767 + r = x % y + if r != -1 { + t.Errorf("-1 %s -32767 = %d, want -1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-1 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-1 %s 1 = %d, want 0", "%", r) + } + y = 32766 + r = x % y + if r != -1 { + t.Errorf("-1 %s 32766 = %d, want -1", "%", r) + } + y = 32767 + r = x % y + if r != -1 { + t.Errorf("-1 %s 32767 = %d, want -1", "%", r) + } + x = 0 + y = -32768 + r = x % y + if r != 0 { + t.Errorf("0 %s -32768 = %d, want 0", "%", r) + } + y = -32767 + r = x % y + if r != 0 { + t.Errorf("0 %s -32767 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "%", r) + } + y = 32766 + r = x % y + if r != 0 { + t.Errorf("0 %s 32766 = %d, want 0", "%", r) + } + y = 32767 + r = x % y + if r != 0 { + t.Errorf("0 %s 32767 = %d, want 0", "%", r) + } + x = 1 + y = -32768 + r = x % y + if r != 1 { + t.Errorf("1 %s -32768 = %d, want 1", "%", r) + } + y = -32767 + r = x % y + if r != 1 { + t.Errorf("1 %s -32767 = %d, want 1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("1 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "%", r) + } + y = 32766 + r = x % y + if r != 1 { + t.Errorf("1 %s 32766 = %d, want 1", "%", r) + } + y = 32767 + r = x % y + if r != 1 { + t.Errorf("1 %s 32767 = %d, want 1", "%", r) + } + x = 32766 + y = -32768 + r = x % y + if r != 32766 { + t.Errorf("32766 %s -32768 = %d, want 32766", "%", r) + } + y = -32767 + r = x % y + if r != 32766 { + t.Errorf("32766 %s -32767 = %d, want 32766", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("32766 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("32766 %s 1 = %d, want 0", "%", r) + } + y = 32766 + r = x % y + if r != 0 { + t.Errorf("32766 %s 32766 = %d, want 0", "%", r) + } + y = 32767 + r = x % y + if r != 32766 { + t.Errorf("32766 %s 32767 = %d, want 32766", "%", r) + } + x = 32767 + y = -32768 + r = x % y + if r != 32767 { + t.Errorf("32767 %s -32768 = %d, want 32767", "%", r) + } + y = -32767 + r = x % y + if r != 0 { + t.Errorf("32767 %s -32767 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("32767 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("32767 %s 1 = %d, want 0", "%", r) + } + y = 32766 + r = x % y + if r != 1 { + t.Errorf("32767 %s 32766 = %d, want 1", "%", r) + } + y = 32767 + r = x % y + if r != 0 { + t.Errorf("32767 %s 32767 = %d, want 0", "%", r) + } +} +func TestConstFolduint8add(t *testing.T) { + var x, y, r uint8 + x = 0 + y = 0 + r = x + y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "+", r) + } + y = 1 + r = x + y + if r != 1 { + t.Errorf("0 %s 1 = %d, want 1", "+", r) + } + y = 255 + r = x + y + if r != 255 { + t.Errorf("0 %s 255 = %d, want 255", "+", r) + } + x = 1 + y = 0 + r = x + y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "+", r) + } + y = 1 + r = x + y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "+", r) + } + y = 255 + r = x + y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", "+", r) + } + x = 255 + y = 0 + r = x + y + if r != 255 { + t.Errorf("255 %s 0 = %d, want 255", "+", r) + } + y = 1 + r = x + y + if r != 0 { + t.Errorf("255 %s 1 = %d, want 0", "+", r) + } + y = 255 + r = x + y + if r != 254 { + t.Errorf("255 %s 255 = %d, want 254", "+", r) + } +} +func TestConstFolduint8sub(t *testing.T) { + var x, y, r uint8 + x = 0 + y = 0 + r = x - y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "-", r) + } + y = 1 + r = x - y + if r != 255 { + t.Errorf("0 %s 1 = %d, want 255", "-", r) + } + y = 255 + r = x - y + if r != 1 { + t.Errorf("0 %s 255 = %d, want 1", "-", r) + } + x = 1 + y = 0 + r = x - y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "-", r) + } + y = 1 + r = x - y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "-", r) + } + y = 255 + r = x - y + if r != 2 { + t.Errorf("1 %s 255 = %d, want 2", "-", r) + } + x = 255 + y = 0 + r = x - y + if r != 255 { + t.Errorf("255 %s 0 = %d, want 255", "-", r) + } + y = 1 + r = x - y + if r != 254 { + t.Errorf("255 %s 1 = %d, want 254", "-", r) + } + y = 255 + r = x - y + if r != 0 { + t.Errorf("255 %s 255 = %d, want 0", "-", r) + } +} +func TestConstFolduint8div(t *testing.T) { + var x, y, r uint8 + x = 0 + y = 1 + r = x / y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "/", r) + } + y = 255 + r = x / y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "/", r) + } + x = 1 + y = 1 + r = x / y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "/", r) + } + y = 255 + r = x / y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", "/", r) + } + x = 255 + y = 1 + r = x / y + if r != 255 { + t.Errorf("255 %s 1 = %d, want 255", "/", r) + } + y = 255 + r = x / y + if r != 1 { + t.Errorf("255 %s 255 = %d, want 1", "/", r) + } +} +func TestConstFolduint8mul(t *testing.T) { + var x, y, r uint8 + x = 0 + y = 0 + r = x * y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "*", r) + } + y = 255 + r = x * y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "*", r) + } + x = 1 + y = 0 + r = x * y + if r != 0 { + t.Errorf("1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "*", r) + } + y = 255 + r = x * y + if r != 255 { + t.Errorf("1 %s 255 = %d, want 255", "*", r) + } + x = 255 + y = 0 + r = x * y + if r != 0 { + t.Errorf("255 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 255 { + t.Errorf("255 %s 1 = %d, want 255", "*", r) + } + y = 255 + r = x * y + if r != 1 { + t.Errorf("255 %s 255 = %d, want 1", "*", r) + } +} +func TestConstFolduint8mod(t *testing.T) { + var x, y, r uint8 + x = 0 + y = 1 + r = x % y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "%", r) + } + y = 255 + r = x % y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "%", r) + } + x = 1 + y = 1 + r = x % y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "%", r) + } + y = 255 + r = x % y + if r != 1 { + t.Errorf("1 %s 255 = %d, want 1", "%", r) + } + x = 255 + y = 1 + r = x % y + if r != 0 { + t.Errorf("255 %s 1 = %d, want 0", "%", r) + } + y = 255 + r = x % y + if r != 0 { + t.Errorf("255 %s 255 = %d, want 0", "%", r) + } +} +func TestConstFoldint8add(t *testing.T) { + var x, y, r int8 + x = -128 + y = -128 + r = x + y + if r != 0 { + t.Errorf("-128 %s -128 = %d, want 0", "+", r) + } + y = -127 + r = x + y + if r != 1 { + t.Errorf("-128 %s -127 = %d, want 1", "+", r) + } + y = -1 + r = x + y + if r != 127 { + t.Errorf("-128 %s -1 = %d, want 127", "+", r) + } + y = 0 + r = x + y + if r != -128 { + t.Errorf("-128 %s 0 = %d, want -128", "+", r) + } + y = 1 + r = x + y + if r != -127 { + t.Errorf("-128 %s 1 = %d, want -127", "+", r) + } + y = 126 + r = x + y + if r != -2 { + t.Errorf("-128 %s 126 = %d, want -2", "+", r) + } + y = 127 + r = x + y + if r != -1 { + t.Errorf("-128 %s 127 = %d, want -1", "+", r) + } + x = -127 + y = -128 + r = x + y + if r != 1 { + t.Errorf("-127 %s -128 = %d, want 1", "+", r) + } + y = -127 + r = x + y + if r != 2 { + t.Errorf("-127 %s -127 = %d, want 2", "+", r) + } + y = -1 + r = x + y + if r != -128 { + t.Errorf("-127 %s -1 = %d, want -128", "+", r) + } + y = 0 + r = x + y + if r != -127 { + t.Errorf("-127 %s 0 = %d, want -127", "+", r) + } + y = 1 + r = x + y + if r != -126 { + t.Errorf("-127 %s 1 = %d, want -126", "+", r) + } + y = 126 + r = x + y + if r != -1 { + t.Errorf("-127 %s 126 = %d, want -1", "+", r) + } + y = 127 + r = x + y + if r != 0 { + t.Errorf("-127 %s 127 = %d, want 0", "+", r) + } + x = -1 + y = -128 + r = x + y + if r != 127 { + t.Errorf("-1 %s -128 = %d, want 127", "+", r) + } + y = -127 + r = x + y + if r != -128 { + t.Errorf("-1 %s -127 = %d, want -128", "+", r) + } + y = -1 + r = x + y + if r != -2 { + t.Errorf("-1 %s -1 = %d, want -2", "+", r) + } + y = 0 + r = x + y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "+", r) + } + y = 1 + r = x + y + if r != 0 { + t.Errorf("-1 %s 1 = %d, want 0", "+", r) + } + y = 126 + r = x + y + if r != 125 { + t.Errorf("-1 %s 126 = %d, want 125", "+", r) + } + y = 127 + r = x + y + if r != 126 { + t.Errorf("-1 %s 127 = %d, want 126", "+", r) + } + x = 0 + y = -128 + r = x + y + if r != -128 { + t.Errorf("0 %s -128 = %d, want -128", "+", r) + } + y = -127 + r = x + y + if r != -127 { + t.Errorf("0 %s -127 = %d, want -127", "+", r) + } + y = -1 + r = x + y + if r != -1 { + t.Errorf("0 %s -1 = %d, want -1", "+", r) + } + y = 0 + r = x + y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "+", r) + } + y = 1 + r = x + y + if r != 1 { + t.Errorf("0 %s 1 = %d, want 1", "+", r) + } + y = 126 + r = x + y + if r != 126 { + t.Errorf("0 %s 126 = %d, want 126", "+", r) + } + y = 127 + r = x + y + if r != 127 { + t.Errorf("0 %s 127 = %d, want 127", "+", r) + } + x = 1 + y = -128 + r = x + y + if r != -127 { + t.Errorf("1 %s -128 = %d, want -127", "+", r) + } + y = -127 + r = x + y + if r != -126 { + t.Errorf("1 %s -127 = %d, want -126", "+", r) + } + y = -1 + r = x + y + if r != 0 { + t.Errorf("1 %s -1 = %d, want 0", "+", r) + } + y = 0 + r = x + y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "+", r) + } + y = 1 + r = x + y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "+", r) + } + y = 126 + r = x + y + if r != 127 { + t.Errorf("1 %s 126 = %d, want 127", "+", r) + } + y = 127 + r = x + y + if r != -128 { + t.Errorf("1 %s 127 = %d, want -128", "+", r) + } + x = 126 + y = -128 + r = x + y + if r != -2 { + t.Errorf("126 %s -128 = %d, want -2", "+", r) + } + y = -127 + r = x + y + if r != -1 { + t.Errorf("126 %s -127 = %d, want -1", "+", r) + } + y = -1 + r = x + y + if r != 125 { + t.Errorf("126 %s -1 = %d, want 125", "+", r) + } + y = 0 + r = x + y + if r != 126 { + t.Errorf("126 %s 0 = %d, want 126", "+", r) + } + y = 1 + r = x + y + if r != 127 { + t.Errorf("126 %s 1 = %d, want 127", "+", r) + } + y = 126 + r = x + y + if r != -4 { + t.Errorf("126 %s 126 = %d, want -4", "+", r) + } + y = 127 + r = x + y + if r != -3 { + t.Errorf("126 %s 127 = %d, want -3", "+", r) + } + x = 127 + y = -128 + r = x + y + if r != -1 { + t.Errorf("127 %s -128 = %d, want -1", "+", r) + } + y = -127 + r = x + y + if r != 0 { + t.Errorf("127 %s -127 = %d, want 0", "+", r) + } + y = -1 + r = x + y + if r != 126 { + t.Errorf("127 %s -1 = %d, want 126", "+", r) + } + y = 0 + r = x + y + if r != 127 { + t.Errorf("127 %s 0 = %d, want 127", "+", r) + } + y = 1 + r = x + y + if r != -128 { + t.Errorf("127 %s 1 = %d, want -128", "+", r) + } + y = 126 + r = x + y + if r != -3 { + t.Errorf("127 %s 126 = %d, want -3", "+", r) + } + y = 127 + r = x + y + if r != -2 { + t.Errorf("127 %s 127 = %d, want -2", "+", r) + } +} +func TestConstFoldint8sub(t *testing.T) { + var x, y, r int8 + x = -128 + y = -128 + r = x - y + if r != 0 { + t.Errorf("-128 %s -128 = %d, want 0", "-", r) + } + y = -127 + r = x - y + if r != -1 { + t.Errorf("-128 %s -127 = %d, want -1", "-", r) + } + y = -1 + r = x - y + if r != -127 { + t.Errorf("-128 %s -1 = %d, want -127", "-", r) + } + y = 0 + r = x - y + if r != -128 { + t.Errorf("-128 %s 0 = %d, want -128", "-", r) + } + y = 1 + r = x - y + if r != 127 { + t.Errorf("-128 %s 1 = %d, want 127", "-", r) + } + y = 126 + r = x - y + if r != 2 { + t.Errorf("-128 %s 126 = %d, want 2", "-", r) + } + y = 127 + r = x - y + if r != 1 { + t.Errorf("-128 %s 127 = %d, want 1", "-", r) + } + x = -127 + y = -128 + r = x - y + if r != 1 { + t.Errorf("-127 %s -128 = %d, want 1", "-", r) + } + y = -127 + r = x - y + if r != 0 { + t.Errorf("-127 %s -127 = %d, want 0", "-", r) + } + y = -1 + r = x - y + if r != -126 { + t.Errorf("-127 %s -1 = %d, want -126", "-", r) + } + y = 0 + r = x - y + if r != -127 { + t.Errorf("-127 %s 0 = %d, want -127", "-", r) + } + y = 1 + r = x - y + if r != -128 { + t.Errorf("-127 %s 1 = %d, want -128", "-", r) + } + y = 126 + r = x - y + if r != 3 { + t.Errorf("-127 %s 126 = %d, want 3", "-", r) + } + y = 127 + r = x - y + if r != 2 { + t.Errorf("-127 %s 127 = %d, want 2", "-", r) + } + x = -1 + y = -128 + r = x - y + if r != 127 { + t.Errorf("-1 %s -128 = %d, want 127", "-", r) + } + y = -127 + r = x - y + if r != 126 { + t.Errorf("-1 %s -127 = %d, want 126", "-", r) + } + y = -1 + r = x - y + if r != 0 { + t.Errorf("-1 %s -1 = %d, want 0", "-", r) + } + y = 0 + r = x - y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "-", r) + } + y = 1 + r = x - y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "-", r) + } + y = 126 + r = x - y + if r != -127 { + t.Errorf("-1 %s 126 = %d, want -127", "-", r) + } + y = 127 + r = x - y + if r != -128 { + t.Errorf("-1 %s 127 = %d, want -128", "-", r) + } + x = 0 + y = -128 + r = x - y + if r != -128 { + t.Errorf("0 %s -128 = %d, want -128", "-", r) + } + y = -127 + r = x - y + if r != 127 { + t.Errorf("0 %s -127 = %d, want 127", "-", r) + } + y = -1 + r = x - y + if r != 1 { + t.Errorf("0 %s -1 = %d, want 1", "-", r) + } + y = 0 + r = x - y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "-", r) + } + y = 1 + r = x - y + if r != -1 { + t.Errorf("0 %s 1 = %d, want -1", "-", r) + } + y = 126 + r = x - y + if r != -126 { + t.Errorf("0 %s 126 = %d, want -126", "-", r) + } + y = 127 + r = x - y + if r != -127 { + t.Errorf("0 %s 127 = %d, want -127", "-", r) + } + x = 1 + y = -128 + r = x - y + if r != -127 { + t.Errorf("1 %s -128 = %d, want -127", "-", r) + } + y = -127 + r = x - y + if r != -128 { + t.Errorf("1 %s -127 = %d, want -128", "-", r) + } + y = -1 + r = x - y + if r != 2 { + t.Errorf("1 %s -1 = %d, want 2", "-", r) + } + y = 0 + r = x - y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "-", r) + } + y = 1 + r = x - y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "-", r) + } + y = 126 + r = x - y + if r != -125 { + t.Errorf("1 %s 126 = %d, want -125", "-", r) + } + y = 127 + r = x - y + if r != -126 { + t.Errorf("1 %s 127 = %d, want -126", "-", r) + } + x = 126 + y = -128 + r = x - y + if r != -2 { + t.Errorf("126 %s -128 = %d, want -2", "-", r) + } + y = -127 + r = x - y + if r != -3 { + t.Errorf("126 %s -127 = %d, want -3", "-", r) + } + y = -1 + r = x - y + if r != 127 { + t.Errorf("126 %s -1 = %d, want 127", "-", r) + } + y = 0 + r = x - y + if r != 126 { + t.Errorf("126 %s 0 = %d, want 126", "-", r) + } + y = 1 + r = x - y + if r != 125 { + t.Errorf("126 %s 1 = %d, want 125", "-", r) + } + y = 126 + r = x - y + if r != 0 { + t.Errorf("126 %s 126 = %d, want 0", "-", r) + } + y = 127 + r = x - y + if r != -1 { + t.Errorf("126 %s 127 = %d, want -1", "-", r) + } + x = 127 + y = -128 + r = x - y + if r != -1 { + t.Errorf("127 %s -128 = %d, want -1", "-", r) + } + y = -127 + r = x - y + if r != -2 { + t.Errorf("127 %s -127 = %d, want -2", "-", r) + } + y = -1 + r = x - y + if r != -128 { + t.Errorf("127 %s -1 = %d, want -128", "-", r) + } + y = 0 + r = x - y + if r != 127 { + t.Errorf("127 %s 0 = %d, want 127", "-", r) + } + y = 1 + r = x - y + if r != 126 { + t.Errorf("127 %s 1 = %d, want 126", "-", r) + } + y = 126 + r = x - y + if r != 1 { + t.Errorf("127 %s 126 = %d, want 1", "-", r) + } + y = 127 + r = x - y + if r != 0 { + t.Errorf("127 %s 127 = %d, want 0", "-", r) + } +} +func TestConstFoldint8div(t *testing.T) { + var x, y, r int8 + x = -128 + y = -128 + r = x / y + if r != 1 { + t.Errorf("-128 %s -128 = %d, want 1", "/", r) + } + y = -127 + r = x / y + if r != 1 { + t.Errorf("-128 %s -127 = %d, want 1", "/", r) + } + y = -1 + r = x / y + if r != -128 { + t.Errorf("-128 %s -1 = %d, want -128", "/", r) + } + y = 1 + r = x / y + if r != -128 { + t.Errorf("-128 %s 1 = %d, want -128", "/", r) + } + y = 126 + r = x / y + if r != -1 { + t.Errorf("-128 %s 126 = %d, want -1", "/", r) + } + y = 127 + r = x / y + if r != -1 { + t.Errorf("-128 %s 127 = %d, want -1", "/", r) + } + x = -127 + y = -128 + r = x / y + if r != 0 { + t.Errorf("-127 %s -128 = %d, want 0", "/", r) + } + y = -127 + r = x / y + if r != 1 { + t.Errorf("-127 %s -127 = %d, want 1", "/", r) + } + y = -1 + r = x / y + if r != 127 { + t.Errorf("-127 %s -1 = %d, want 127", "/", r) + } + y = 1 + r = x / y + if r != -127 { + t.Errorf("-127 %s 1 = %d, want -127", "/", r) + } + y = 126 + r = x / y + if r != -1 { + t.Errorf("-127 %s 126 = %d, want -1", "/", r) + } + y = 127 + r = x / y + if r != -1 { + t.Errorf("-127 %s 127 = %d, want -1", "/", r) + } + x = -1 + y = -128 + r = x / y + if r != 0 { + t.Errorf("-1 %s -128 = %d, want 0", "/", r) + } + y = -127 + r = x / y + if r != 0 { + t.Errorf("-1 %s -127 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != 1 { + t.Errorf("-1 %s -1 = %d, want 1", "/", r) + } + y = 1 + r = x / y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", "/", r) + } + y = 126 + r = x / y + if r != 0 { + t.Errorf("-1 %s 126 = %d, want 0", "/", r) + } + y = 127 + r = x / y + if r != 0 { + t.Errorf("-1 %s 127 = %d, want 0", "/", r) + } + x = 0 + y = -128 + r = x / y + if r != 0 { + t.Errorf("0 %s -128 = %d, want 0", "/", r) + } + y = -127 + r = x / y + if r != 0 { + t.Errorf("0 %s -127 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "/", r) + } + y = 1 + r = x / y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "/", r) + } + y = 126 + r = x / y + if r != 0 { + t.Errorf("0 %s 126 = %d, want 0", "/", r) + } + y = 127 + r = x / y + if r != 0 { + t.Errorf("0 %s 127 = %d, want 0", "/", r) + } + x = 1 + y = -128 + r = x / y + if r != 0 { + t.Errorf("1 %s -128 = %d, want 0", "/", r) + } + y = -127 + r = x / y + if r != 0 { + t.Errorf("1 %s -127 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != -1 { + t.Errorf("1 %s -1 = %d, want -1", "/", r) + } + y = 1 + r = x / y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "/", r) + } + y = 126 + r = x / y + if r != 0 { + t.Errorf("1 %s 126 = %d, want 0", "/", r) + } + y = 127 + r = x / y + if r != 0 { + t.Errorf("1 %s 127 = %d, want 0", "/", r) + } + x = 126 + y = -128 + r = x / y + if r != 0 { + t.Errorf("126 %s -128 = %d, want 0", "/", r) + } + y = -127 + r = x / y + if r != 0 { + t.Errorf("126 %s -127 = %d, want 0", "/", r) + } + y = -1 + r = x / y + if r != -126 { + t.Errorf("126 %s -1 = %d, want -126", "/", r) + } + y = 1 + r = x / y + if r != 126 { + t.Errorf("126 %s 1 = %d, want 126", "/", r) + } + y = 126 + r = x / y + if r != 1 { + t.Errorf("126 %s 126 = %d, want 1", "/", r) + } + y = 127 + r = x / y + if r != 0 { + t.Errorf("126 %s 127 = %d, want 0", "/", r) + } + x = 127 + y = -128 + r = x / y + if r != 0 { + t.Errorf("127 %s -128 = %d, want 0", "/", r) + } + y = -127 + r = x / y + if r != -1 { + t.Errorf("127 %s -127 = %d, want -1", "/", r) + } + y = -1 + r = x / y + if r != -127 { + t.Errorf("127 %s -1 = %d, want -127", "/", r) + } + y = 1 + r = x / y + if r != 127 { + t.Errorf("127 %s 1 = %d, want 127", "/", r) + } + y = 126 + r = x / y + if r != 1 { + t.Errorf("127 %s 126 = %d, want 1", "/", r) + } + y = 127 + r = x / y + if r != 1 { + t.Errorf("127 %s 127 = %d, want 1", "/", r) + } +} +func TestConstFoldint8mul(t *testing.T) { + var x, y, r int8 + x = -128 + y = -128 + r = x * y + if r != 0 { + t.Errorf("-128 %s -128 = %d, want 0", "*", r) + } + y = -127 + r = x * y + if r != -128 { + t.Errorf("-128 %s -127 = %d, want -128", "*", r) + } + y = -1 + r = x * y + if r != -128 { + t.Errorf("-128 %s -1 = %d, want -128", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-128 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -128 { + t.Errorf("-128 %s 1 = %d, want -128", "*", r) + } + y = 126 + r = x * y + if r != 0 { + t.Errorf("-128 %s 126 = %d, want 0", "*", r) + } + y = 127 + r = x * y + if r != -128 { + t.Errorf("-128 %s 127 = %d, want -128", "*", r) + } + x = -127 + y = -128 + r = x * y + if r != -128 { + t.Errorf("-127 %s -128 = %d, want -128", "*", r) + } + y = -127 + r = x * y + if r != 1 { + t.Errorf("-127 %s -127 = %d, want 1", "*", r) + } + y = -1 + r = x * y + if r != 127 { + t.Errorf("-127 %s -1 = %d, want 127", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-127 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -127 { + t.Errorf("-127 %s 1 = %d, want -127", "*", r) + } + y = 126 + r = x * y + if r != 126 { + t.Errorf("-127 %s 126 = %d, want 126", "*", r) + } + y = 127 + r = x * y + if r != -1 { + t.Errorf("-127 %s 127 = %d, want -1", "*", r) + } + x = -1 + y = -128 + r = x * y + if r != -128 { + t.Errorf("-1 %s -128 = %d, want -128", "*", r) + } + y = -127 + r = x * y + if r != 127 { + t.Errorf("-1 %s -127 = %d, want 127", "*", r) + } + y = -1 + r = x * y + if r != 1 { + t.Errorf("-1 %s -1 = %d, want 1", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("-1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", "*", r) + } + y = 126 + r = x * y + if r != -126 { + t.Errorf("-1 %s 126 = %d, want -126", "*", r) + } + y = 127 + r = x * y + if r != -127 { + t.Errorf("-1 %s 127 = %d, want -127", "*", r) + } + x = 0 + y = -128 + r = x * y + if r != 0 { + t.Errorf("0 %s -128 = %d, want 0", "*", r) + } + y = -127 + r = x * y + if r != 0 { + t.Errorf("0 %s -127 = %d, want 0", "*", r) + } + y = -1 + r = x * y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "*", r) + } + y = 126 + r = x * y + if r != 0 { + t.Errorf("0 %s 126 = %d, want 0", "*", r) + } + y = 127 + r = x * y + if r != 0 { + t.Errorf("0 %s 127 = %d, want 0", "*", r) + } + x = 1 + y = -128 + r = x * y + if r != -128 { + t.Errorf("1 %s -128 = %d, want -128", "*", r) + } + y = -127 + r = x * y + if r != -127 { + t.Errorf("1 %s -127 = %d, want -127", "*", r) + } + y = -1 + r = x * y + if r != -1 { + t.Errorf("1 %s -1 = %d, want -1", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("1 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 1 { + t.Errorf("1 %s 1 = %d, want 1", "*", r) + } + y = 126 + r = x * y + if r != 126 { + t.Errorf("1 %s 126 = %d, want 126", "*", r) + } + y = 127 + r = x * y + if r != 127 { + t.Errorf("1 %s 127 = %d, want 127", "*", r) + } + x = 126 + y = -128 + r = x * y + if r != 0 { + t.Errorf("126 %s -128 = %d, want 0", "*", r) + } + y = -127 + r = x * y + if r != 126 { + t.Errorf("126 %s -127 = %d, want 126", "*", r) + } + y = -1 + r = x * y + if r != -126 { + t.Errorf("126 %s -1 = %d, want -126", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("126 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 126 { + t.Errorf("126 %s 1 = %d, want 126", "*", r) + } + y = 126 + r = x * y + if r != 4 { + t.Errorf("126 %s 126 = %d, want 4", "*", r) + } + y = 127 + r = x * y + if r != -126 { + t.Errorf("126 %s 127 = %d, want -126", "*", r) + } + x = 127 + y = -128 + r = x * y + if r != -128 { + t.Errorf("127 %s -128 = %d, want -128", "*", r) + } + y = -127 + r = x * y + if r != -1 { + t.Errorf("127 %s -127 = %d, want -1", "*", r) + } + y = -1 + r = x * y + if r != -127 { + t.Errorf("127 %s -1 = %d, want -127", "*", r) + } + y = 0 + r = x * y + if r != 0 { + t.Errorf("127 %s 0 = %d, want 0", "*", r) + } + y = 1 + r = x * y + if r != 127 { + t.Errorf("127 %s 1 = %d, want 127", "*", r) + } + y = 126 + r = x * y + if r != -126 { + t.Errorf("127 %s 126 = %d, want -126", "*", r) + } + y = 127 + r = x * y + if r != 1 { + t.Errorf("127 %s 127 = %d, want 1", "*", r) + } +} +func TestConstFoldint8mod(t *testing.T) { + var x, y, r int8 + x = -128 + y = -128 + r = x % y + if r != 0 { + t.Errorf("-128 %s -128 = %d, want 0", "%", r) + } + y = -127 + r = x % y + if r != -1 { + t.Errorf("-128 %s -127 = %d, want -1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-128 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-128 %s 1 = %d, want 0", "%", r) + } + y = 126 + r = x % y + if r != -2 { + t.Errorf("-128 %s 126 = %d, want -2", "%", r) + } + y = 127 + r = x % y + if r != -1 { + t.Errorf("-128 %s 127 = %d, want -1", "%", r) + } + x = -127 + y = -128 + r = x % y + if r != -127 { + t.Errorf("-127 %s -128 = %d, want -127", "%", r) + } + y = -127 + r = x % y + if r != 0 { + t.Errorf("-127 %s -127 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-127 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-127 %s 1 = %d, want 0", "%", r) + } + y = 126 + r = x % y + if r != -1 { + t.Errorf("-127 %s 126 = %d, want -1", "%", r) + } + y = 127 + r = x % y + if r != 0 { + t.Errorf("-127 %s 127 = %d, want 0", "%", r) + } + x = -1 + y = -128 + r = x % y + if r != -1 { + t.Errorf("-1 %s -128 = %d, want -1", "%", r) + } + y = -127 + r = x % y + if r != -1 { + t.Errorf("-1 %s -127 = %d, want -1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("-1 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("-1 %s 1 = %d, want 0", "%", r) + } + y = 126 + r = x % y + if r != -1 { + t.Errorf("-1 %s 126 = %d, want -1", "%", r) + } + y = 127 + r = x % y + if r != -1 { + t.Errorf("-1 %s 127 = %d, want -1", "%", r) + } + x = 0 + y = -128 + r = x % y + if r != 0 { + t.Errorf("0 %s -128 = %d, want 0", "%", r) + } + y = -127 + r = x % y + if r != 0 { + t.Errorf("0 %s -127 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("0 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "%", r) + } + y = 126 + r = x % y + if r != 0 { + t.Errorf("0 %s 126 = %d, want 0", "%", r) + } + y = 127 + r = x % y + if r != 0 { + t.Errorf("0 %s 127 = %d, want 0", "%", r) + } + x = 1 + y = -128 + r = x % y + if r != 1 { + t.Errorf("1 %s -128 = %d, want 1", "%", r) + } + y = -127 + r = x % y + if r != 1 { + t.Errorf("1 %s -127 = %d, want 1", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("1 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", "%", r) + } + y = 126 + r = x % y + if r != 1 { + t.Errorf("1 %s 126 = %d, want 1", "%", r) + } + y = 127 + r = x % y + if r != 1 { + t.Errorf("1 %s 127 = %d, want 1", "%", r) + } + x = 126 + y = -128 + r = x % y + if r != 126 { + t.Errorf("126 %s -128 = %d, want 126", "%", r) + } + y = -127 + r = x % y + if r != 126 { + t.Errorf("126 %s -127 = %d, want 126", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("126 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("126 %s 1 = %d, want 0", "%", r) + } + y = 126 + r = x % y + if r != 0 { + t.Errorf("126 %s 126 = %d, want 0", "%", r) + } + y = 127 + r = x % y + if r != 126 { + t.Errorf("126 %s 127 = %d, want 126", "%", r) + } + x = 127 + y = -128 + r = x % y + if r != 127 { + t.Errorf("127 %s -128 = %d, want 127", "%", r) + } + y = -127 + r = x % y + if r != 0 { + t.Errorf("127 %s -127 = %d, want 0", "%", r) + } + y = -1 + r = x % y + if r != 0 { + t.Errorf("127 %s -1 = %d, want 0", "%", r) + } + y = 1 + r = x % y + if r != 0 { + t.Errorf("127 %s 1 = %d, want 0", "%", r) + } + y = 126 + r = x % y + if r != 1 { + t.Errorf("127 %s 126 = %d, want 1", "%", r) + } + y = 127 + r = x % y + if r != 0 { + t.Errorf("127 %s 127 = %d, want 0", "%", r) + } +} +func TestConstFolduint64uint64lsh(t *testing.T) { + var x, r uint64 + var y uint64 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 4294967296 + y = 0 + r = x << y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "<<", r) + } + y = 1 + r = x << y + if r != 8589934592 { + t.Errorf("4294967296 %s 1 = %d, want 8589934592", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("4294967296 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("4294967296 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 18446744073709551615 + y = 0 + r = x << y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 0 = %d, want 18446744073709551615", "<<", r) + } + y = 1 + r = x << y + if r != 18446744073709551614 { + t.Errorf("18446744073709551615 %s 1 = %d, want 18446744073709551614", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("18446744073709551615 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("18446744073709551615 %s 18446744073709551615 = %d, want 0", "<<", r) + } +} +func TestConstFolduint64uint64rsh(t *testing.T) { + var x, r uint64 + var y uint64 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 4294967296 + y = 0 + r = x >> y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483648 { + t.Errorf("4294967296 %s 1 = %d, want 2147483648", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("4294967296 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("4294967296 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 18446744073709551615 + y = 0 + r = x >> y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 0 = %d, want 18446744073709551615", ">>", r) + } + y = 1 + r = x >> y + if r != 9223372036854775807 { + t.Errorf("18446744073709551615 %s 1 = %d, want 9223372036854775807", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("18446744073709551615 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("18446744073709551615 %s 18446744073709551615 = %d, want 0", ">>", r) + } +} +func TestConstFolduint64uint32lsh(t *testing.T) { + var x, r uint64 + var y uint32 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 4294967296 + y = 0 + r = x << y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "<<", r) + } + y = 1 + r = x << y + if r != 8589934592 { + t.Errorf("4294967296 %s 1 = %d, want 8589934592", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("4294967296 %s 4294967295 = %d, want 0", "<<", r) + } + x = 18446744073709551615 + y = 0 + r = x << y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 0 = %d, want 18446744073709551615", "<<", r) + } + y = 1 + r = x << y + if r != 18446744073709551614 { + t.Errorf("18446744073709551615 %s 1 = %d, want 18446744073709551614", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("18446744073709551615 %s 4294967295 = %d, want 0", "<<", r) + } +} +func TestConstFolduint64uint32rsh(t *testing.T) { + var x, r uint64 + var y uint32 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", ">>", r) + } + x = 4294967296 + y = 0 + r = x >> y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483648 { + t.Errorf("4294967296 %s 1 = %d, want 2147483648", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("4294967296 %s 4294967295 = %d, want 0", ">>", r) + } + x = 18446744073709551615 + y = 0 + r = x >> y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 0 = %d, want 18446744073709551615", ">>", r) + } + y = 1 + r = x >> y + if r != 9223372036854775807 { + t.Errorf("18446744073709551615 %s 1 = %d, want 9223372036854775807", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("18446744073709551615 %s 4294967295 = %d, want 0", ">>", r) + } +} +func TestConstFolduint64uint16lsh(t *testing.T) { + var x, r uint64 + var y uint16 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", "<<", r) + } + x = 4294967296 + y = 0 + r = x << y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "<<", r) + } + y = 1 + r = x << y + if r != 8589934592 { + t.Errorf("4294967296 %s 1 = %d, want 8589934592", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("4294967296 %s 65535 = %d, want 0", "<<", r) + } + x = 18446744073709551615 + y = 0 + r = x << y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 0 = %d, want 18446744073709551615", "<<", r) + } + y = 1 + r = x << y + if r != 18446744073709551614 { + t.Errorf("18446744073709551615 %s 1 = %d, want 18446744073709551614", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("18446744073709551615 %s 65535 = %d, want 0", "<<", r) + } +} +func TestConstFolduint64uint16rsh(t *testing.T) { + var x, r uint64 + var y uint16 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", ">>", r) + } + x = 4294967296 + y = 0 + r = x >> y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483648 { + t.Errorf("4294967296 %s 1 = %d, want 2147483648", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("4294967296 %s 65535 = %d, want 0", ">>", r) + } + x = 18446744073709551615 + y = 0 + r = x >> y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 0 = %d, want 18446744073709551615", ">>", r) + } + y = 1 + r = x >> y + if r != 9223372036854775807 { + t.Errorf("18446744073709551615 %s 1 = %d, want 9223372036854775807", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("18446744073709551615 %s 65535 = %d, want 0", ">>", r) + } +} +func TestConstFolduint64uint8lsh(t *testing.T) { + var x, r uint64 + var y uint8 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", "<<", r) + } + x = 4294967296 + y = 0 + r = x << y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "<<", r) + } + y = 1 + r = x << y + if r != 8589934592 { + t.Errorf("4294967296 %s 1 = %d, want 8589934592", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("4294967296 %s 255 = %d, want 0", "<<", r) + } + x = 18446744073709551615 + y = 0 + r = x << y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 0 = %d, want 18446744073709551615", "<<", r) + } + y = 1 + r = x << y + if r != 18446744073709551614 { + t.Errorf("18446744073709551615 %s 1 = %d, want 18446744073709551614", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("18446744073709551615 %s 255 = %d, want 0", "<<", r) + } +} +func TestConstFolduint64uint8rsh(t *testing.T) { + var x, r uint64 + var y uint8 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", ">>", r) + } + x = 4294967296 + y = 0 + r = x >> y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483648 { + t.Errorf("4294967296 %s 1 = %d, want 2147483648", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("4294967296 %s 255 = %d, want 0", ">>", r) + } + x = 18446744073709551615 + y = 0 + r = x >> y + if r != 18446744073709551615 { + t.Errorf("18446744073709551615 %s 0 = %d, want 18446744073709551615", ">>", r) + } + y = 1 + r = x >> y + if r != 9223372036854775807 { + t.Errorf("18446744073709551615 %s 1 = %d, want 9223372036854775807", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("18446744073709551615 %s 255 = %d, want 0", ">>", r) + } +} +func TestConstFoldint64uint64lsh(t *testing.T) { + var x, r int64 + var y uint64 + x = -9223372036854775808 + y = 0 + r = x << y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 0 = %d, want -9223372036854775808", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775808 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775808 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775808 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = -9223372036854775807 + y = 0 + r = x << y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 0 = %d, want -9223372036854775807", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-9223372036854775807 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775807 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775807 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = -4294967296 + y = 0 + r = x << y + if r != -4294967296 { + t.Errorf("-4294967296 %s 0 = %d, want -4294967296", "<<", r) + } + y = 1 + r = x << y + if r != -8589934592 { + t.Errorf("-4294967296 %s 1 = %d, want -8589934592", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-4294967296 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-4294967296 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 4294967296 + y = 0 + r = x << y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "<<", r) + } + y = 1 + r = x << y + if r != 8589934592 { + t.Errorf("4294967296 %s 1 = %d, want 8589934592", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("4294967296 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("4294967296 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 9223372036854775806 + y = 0 + r = x << y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 0 = %d, want 9223372036854775806", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("9223372036854775806 %s 1 = %d, want -4", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("9223372036854775806 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("9223372036854775806 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 9223372036854775807 + y = 0 + r = x << y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 0 = %d, want 9223372036854775807", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("9223372036854775807 %s 1 = %d, want -2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("9223372036854775807 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("9223372036854775807 %s 18446744073709551615 = %d, want 0", "<<", r) + } +} +func TestConstFoldint64uint64rsh(t *testing.T) { + var x, r int64 + var y uint64 + x = -9223372036854775808 + y = 0 + r = x >> y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 0 = %d, want -9223372036854775808", ">>", r) + } + y = 1 + r = x >> y + if r != -4611686018427387904 { + t.Errorf("-9223372036854775808 %s 1 = %d, want -4611686018427387904", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-9223372036854775808 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-9223372036854775808 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = -9223372036854775807 + y = 0 + r = x >> y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 0 = %d, want -9223372036854775807", ">>", r) + } + y = 1 + r = x >> y + if r != -4611686018427387904 { + t.Errorf("-9223372036854775807 %s 1 = %d, want -4611686018427387904", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-9223372036854775807 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-9223372036854775807 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = -4294967296 + y = 0 + r = x >> y + if r != -4294967296 { + t.Errorf("-4294967296 %s 0 = %d, want -4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != -2147483648 { + t.Errorf("-4294967296 %s 1 = %d, want -2147483648", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-4294967296 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-4294967296 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 4294967296 + y = 0 + r = x >> y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483648 { + t.Errorf("4294967296 %s 1 = %d, want 2147483648", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("4294967296 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("4294967296 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 9223372036854775806 + y = 0 + r = x >> y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 0 = %d, want 9223372036854775806", ">>", r) + } + y = 1 + r = x >> y + if r != 4611686018427387903 { + t.Errorf("9223372036854775806 %s 1 = %d, want 4611686018427387903", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("9223372036854775806 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("9223372036854775806 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 9223372036854775807 + y = 0 + r = x >> y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 0 = %d, want 9223372036854775807", ">>", r) + } + y = 1 + r = x >> y + if r != 4611686018427387903 { + t.Errorf("9223372036854775807 %s 1 = %d, want 4611686018427387903", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("9223372036854775807 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("9223372036854775807 %s 18446744073709551615 = %d, want 0", ">>", r) + } +} +func TestConstFoldint64uint32lsh(t *testing.T) { + var x, r int64 + var y uint32 + x = -9223372036854775808 + y = 0 + r = x << y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 0 = %d, want -9223372036854775808", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775808 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775808 %s 4294967295 = %d, want 0", "<<", r) + } + x = -9223372036854775807 + y = 0 + r = x << y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 0 = %d, want -9223372036854775807", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-9223372036854775807 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775807 %s 4294967295 = %d, want 0", "<<", r) + } + x = -4294967296 + y = 0 + r = x << y + if r != -4294967296 { + t.Errorf("-4294967296 %s 0 = %d, want -4294967296", "<<", r) + } + y = 1 + r = x << y + if r != -8589934592 { + t.Errorf("-4294967296 %s 1 = %d, want -8589934592", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-4294967296 %s 4294967295 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 4294967296 + y = 0 + r = x << y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "<<", r) + } + y = 1 + r = x << y + if r != 8589934592 { + t.Errorf("4294967296 %s 1 = %d, want 8589934592", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("4294967296 %s 4294967295 = %d, want 0", "<<", r) + } + x = 9223372036854775806 + y = 0 + r = x << y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 0 = %d, want 9223372036854775806", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("9223372036854775806 %s 1 = %d, want -4", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("9223372036854775806 %s 4294967295 = %d, want 0", "<<", r) + } + x = 9223372036854775807 + y = 0 + r = x << y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 0 = %d, want 9223372036854775807", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("9223372036854775807 %s 1 = %d, want -2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("9223372036854775807 %s 4294967295 = %d, want 0", "<<", r) + } +} +func TestConstFoldint64uint32rsh(t *testing.T) { + var x, r int64 + var y uint32 + x = -9223372036854775808 + y = 0 + r = x >> y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 0 = %d, want -9223372036854775808", ">>", r) + } + y = 1 + r = x >> y + if r != -4611686018427387904 { + t.Errorf("-9223372036854775808 %s 1 = %d, want -4611686018427387904", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-9223372036854775808 %s 4294967295 = %d, want -1", ">>", r) + } + x = -9223372036854775807 + y = 0 + r = x >> y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 0 = %d, want -9223372036854775807", ">>", r) + } + y = 1 + r = x >> y + if r != -4611686018427387904 { + t.Errorf("-9223372036854775807 %s 1 = %d, want -4611686018427387904", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-9223372036854775807 %s 4294967295 = %d, want -1", ">>", r) + } + x = -4294967296 + y = 0 + r = x >> y + if r != -4294967296 { + t.Errorf("-4294967296 %s 0 = %d, want -4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != -2147483648 { + t.Errorf("-4294967296 %s 1 = %d, want -2147483648", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-4294967296 %s 4294967295 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 4294967295 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", ">>", r) + } + x = 4294967296 + y = 0 + r = x >> y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483648 { + t.Errorf("4294967296 %s 1 = %d, want 2147483648", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("4294967296 %s 4294967295 = %d, want 0", ">>", r) + } + x = 9223372036854775806 + y = 0 + r = x >> y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 0 = %d, want 9223372036854775806", ">>", r) + } + y = 1 + r = x >> y + if r != 4611686018427387903 { + t.Errorf("9223372036854775806 %s 1 = %d, want 4611686018427387903", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("9223372036854775806 %s 4294967295 = %d, want 0", ">>", r) + } + x = 9223372036854775807 + y = 0 + r = x >> y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 0 = %d, want 9223372036854775807", ">>", r) + } + y = 1 + r = x >> y + if r != 4611686018427387903 { + t.Errorf("9223372036854775807 %s 1 = %d, want 4611686018427387903", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("9223372036854775807 %s 4294967295 = %d, want 0", ">>", r) + } +} +func TestConstFoldint64uint16lsh(t *testing.T) { + var x, r int64 + var y uint16 + x = -9223372036854775808 + y = 0 + r = x << y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 0 = %d, want -9223372036854775808", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775808 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775808 %s 65535 = %d, want 0", "<<", r) + } + x = -9223372036854775807 + y = 0 + r = x << y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 0 = %d, want -9223372036854775807", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-9223372036854775807 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775807 %s 65535 = %d, want 0", "<<", r) + } + x = -4294967296 + y = 0 + r = x << y + if r != -4294967296 { + t.Errorf("-4294967296 %s 0 = %d, want -4294967296", "<<", r) + } + y = 1 + r = x << y + if r != -8589934592 { + t.Errorf("-4294967296 %s 1 = %d, want -8589934592", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-4294967296 %s 65535 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-1 %s 65535 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", "<<", r) + } + x = 4294967296 + y = 0 + r = x << y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "<<", r) + } + y = 1 + r = x << y + if r != 8589934592 { + t.Errorf("4294967296 %s 1 = %d, want 8589934592", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("4294967296 %s 65535 = %d, want 0", "<<", r) + } + x = 9223372036854775806 + y = 0 + r = x << y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 0 = %d, want 9223372036854775806", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("9223372036854775806 %s 1 = %d, want -4", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("9223372036854775806 %s 65535 = %d, want 0", "<<", r) + } + x = 9223372036854775807 + y = 0 + r = x << y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 0 = %d, want 9223372036854775807", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("9223372036854775807 %s 1 = %d, want -2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("9223372036854775807 %s 65535 = %d, want 0", "<<", r) + } +} +func TestConstFoldint64uint16rsh(t *testing.T) { + var x, r int64 + var y uint16 + x = -9223372036854775808 + y = 0 + r = x >> y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 0 = %d, want -9223372036854775808", ">>", r) + } + y = 1 + r = x >> y + if r != -4611686018427387904 { + t.Errorf("-9223372036854775808 %s 1 = %d, want -4611686018427387904", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-9223372036854775808 %s 65535 = %d, want -1", ">>", r) + } + x = -9223372036854775807 + y = 0 + r = x >> y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 0 = %d, want -9223372036854775807", ">>", r) + } + y = 1 + r = x >> y + if r != -4611686018427387904 { + t.Errorf("-9223372036854775807 %s 1 = %d, want -4611686018427387904", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-9223372036854775807 %s 65535 = %d, want -1", ">>", r) + } + x = -4294967296 + y = 0 + r = x >> y + if r != -4294967296 { + t.Errorf("-4294967296 %s 0 = %d, want -4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != -2147483648 { + t.Errorf("-4294967296 %s 1 = %d, want -2147483648", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-4294967296 %s 65535 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 65535 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", ">>", r) + } + x = 4294967296 + y = 0 + r = x >> y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483648 { + t.Errorf("4294967296 %s 1 = %d, want 2147483648", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("4294967296 %s 65535 = %d, want 0", ">>", r) + } + x = 9223372036854775806 + y = 0 + r = x >> y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 0 = %d, want 9223372036854775806", ">>", r) + } + y = 1 + r = x >> y + if r != 4611686018427387903 { + t.Errorf("9223372036854775806 %s 1 = %d, want 4611686018427387903", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("9223372036854775806 %s 65535 = %d, want 0", ">>", r) + } + x = 9223372036854775807 + y = 0 + r = x >> y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 0 = %d, want 9223372036854775807", ">>", r) + } + y = 1 + r = x >> y + if r != 4611686018427387903 { + t.Errorf("9223372036854775807 %s 1 = %d, want 4611686018427387903", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("9223372036854775807 %s 65535 = %d, want 0", ">>", r) + } +} +func TestConstFoldint64uint8lsh(t *testing.T) { + var x, r int64 + var y uint8 + x = -9223372036854775808 + y = 0 + r = x << y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 0 = %d, want -9223372036854775808", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775808 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775808 %s 255 = %d, want 0", "<<", r) + } + x = -9223372036854775807 + y = 0 + r = x << y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 0 = %d, want -9223372036854775807", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-9223372036854775807 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-9223372036854775807 %s 255 = %d, want 0", "<<", r) + } + x = -4294967296 + y = 0 + r = x << y + if r != -4294967296 { + t.Errorf("-4294967296 %s 0 = %d, want -4294967296", "<<", r) + } + y = 1 + r = x << y + if r != -8589934592 { + t.Errorf("-4294967296 %s 1 = %d, want -8589934592", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-4294967296 %s 255 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-1 %s 255 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", "<<", r) + } + x = 4294967296 + y = 0 + r = x << y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", "<<", r) + } + y = 1 + r = x << y + if r != 8589934592 { + t.Errorf("4294967296 %s 1 = %d, want 8589934592", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("4294967296 %s 255 = %d, want 0", "<<", r) + } + x = 9223372036854775806 + y = 0 + r = x << y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 0 = %d, want 9223372036854775806", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("9223372036854775806 %s 1 = %d, want -4", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("9223372036854775806 %s 255 = %d, want 0", "<<", r) + } + x = 9223372036854775807 + y = 0 + r = x << y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 0 = %d, want 9223372036854775807", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("9223372036854775807 %s 1 = %d, want -2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("9223372036854775807 %s 255 = %d, want 0", "<<", r) + } +} +func TestConstFoldint64uint8rsh(t *testing.T) { + var x, r int64 + var y uint8 + x = -9223372036854775808 + y = 0 + r = x >> y + if r != -9223372036854775808 { + t.Errorf("-9223372036854775808 %s 0 = %d, want -9223372036854775808", ">>", r) + } + y = 1 + r = x >> y + if r != -4611686018427387904 { + t.Errorf("-9223372036854775808 %s 1 = %d, want -4611686018427387904", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-9223372036854775808 %s 255 = %d, want -1", ">>", r) + } + x = -9223372036854775807 + y = 0 + r = x >> y + if r != -9223372036854775807 { + t.Errorf("-9223372036854775807 %s 0 = %d, want -9223372036854775807", ">>", r) + } + y = 1 + r = x >> y + if r != -4611686018427387904 { + t.Errorf("-9223372036854775807 %s 1 = %d, want -4611686018427387904", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-9223372036854775807 %s 255 = %d, want -1", ">>", r) + } + x = -4294967296 + y = 0 + r = x >> y + if r != -4294967296 { + t.Errorf("-4294967296 %s 0 = %d, want -4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != -2147483648 { + t.Errorf("-4294967296 %s 1 = %d, want -2147483648", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-4294967296 %s 255 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 255 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", ">>", r) + } + x = 4294967296 + y = 0 + r = x >> y + if r != 4294967296 { + t.Errorf("4294967296 %s 0 = %d, want 4294967296", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483648 { + t.Errorf("4294967296 %s 1 = %d, want 2147483648", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("4294967296 %s 255 = %d, want 0", ">>", r) + } + x = 9223372036854775806 + y = 0 + r = x >> y + if r != 9223372036854775806 { + t.Errorf("9223372036854775806 %s 0 = %d, want 9223372036854775806", ">>", r) + } + y = 1 + r = x >> y + if r != 4611686018427387903 { + t.Errorf("9223372036854775806 %s 1 = %d, want 4611686018427387903", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("9223372036854775806 %s 255 = %d, want 0", ">>", r) + } + x = 9223372036854775807 + y = 0 + r = x >> y + if r != 9223372036854775807 { + t.Errorf("9223372036854775807 %s 0 = %d, want 9223372036854775807", ">>", r) + } + y = 1 + r = x >> y + if r != 4611686018427387903 { + t.Errorf("9223372036854775807 %s 1 = %d, want 4611686018427387903", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("9223372036854775807 %s 255 = %d, want 0", ">>", r) + } +} +func TestConstFolduint32uint64lsh(t *testing.T) { + var x, r uint32 + var y uint64 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 4294967295 + y = 0 + r = x << y + if r != 4294967295 { + t.Errorf("4294967295 %s 0 = %d, want 4294967295", "<<", r) + } + y = 1 + r = x << y + if r != 4294967294 { + t.Errorf("4294967295 %s 1 = %d, want 4294967294", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("4294967295 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("4294967295 %s 18446744073709551615 = %d, want 0", "<<", r) + } +} +func TestConstFolduint32uint64rsh(t *testing.T) { + var x, r uint32 + var y uint64 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 4294967295 + y = 0 + r = x >> y + if r != 4294967295 { + t.Errorf("4294967295 %s 0 = %d, want 4294967295", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483647 { + t.Errorf("4294967295 %s 1 = %d, want 2147483647", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("4294967295 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("4294967295 %s 18446744073709551615 = %d, want 0", ">>", r) + } +} +func TestConstFolduint32uint32lsh(t *testing.T) { + var x, r uint32 + var y uint32 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 4294967295 + y = 0 + r = x << y + if r != 4294967295 { + t.Errorf("4294967295 %s 0 = %d, want 4294967295", "<<", r) + } + y = 1 + r = x << y + if r != 4294967294 { + t.Errorf("4294967295 %s 1 = %d, want 4294967294", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("4294967295 %s 4294967295 = %d, want 0", "<<", r) + } +} +func TestConstFolduint32uint32rsh(t *testing.T) { + var x, r uint32 + var y uint32 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", ">>", r) + } + x = 4294967295 + y = 0 + r = x >> y + if r != 4294967295 { + t.Errorf("4294967295 %s 0 = %d, want 4294967295", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483647 { + t.Errorf("4294967295 %s 1 = %d, want 2147483647", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("4294967295 %s 4294967295 = %d, want 0", ">>", r) + } +} +func TestConstFolduint32uint16lsh(t *testing.T) { + var x, r uint32 + var y uint16 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", "<<", r) + } + x = 4294967295 + y = 0 + r = x << y + if r != 4294967295 { + t.Errorf("4294967295 %s 0 = %d, want 4294967295", "<<", r) + } + y = 1 + r = x << y + if r != 4294967294 { + t.Errorf("4294967295 %s 1 = %d, want 4294967294", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("4294967295 %s 65535 = %d, want 0", "<<", r) + } +} +func TestConstFolduint32uint16rsh(t *testing.T) { + var x, r uint32 + var y uint16 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", ">>", r) + } + x = 4294967295 + y = 0 + r = x >> y + if r != 4294967295 { + t.Errorf("4294967295 %s 0 = %d, want 4294967295", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483647 { + t.Errorf("4294967295 %s 1 = %d, want 2147483647", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("4294967295 %s 65535 = %d, want 0", ">>", r) + } +} +func TestConstFolduint32uint8lsh(t *testing.T) { + var x, r uint32 + var y uint8 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", "<<", r) + } + x = 4294967295 + y = 0 + r = x << y + if r != 4294967295 { + t.Errorf("4294967295 %s 0 = %d, want 4294967295", "<<", r) + } + y = 1 + r = x << y + if r != 4294967294 { + t.Errorf("4294967295 %s 1 = %d, want 4294967294", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("4294967295 %s 255 = %d, want 0", "<<", r) + } +} +func TestConstFolduint32uint8rsh(t *testing.T) { + var x, r uint32 + var y uint8 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", ">>", r) + } + x = 4294967295 + y = 0 + r = x >> y + if r != 4294967295 { + t.Errorf("4294967295 %s 0 = %d, want 4294967295", ">>", r) + } + y = 1 + r = x >> y + if r != 2147483647 { + t.Errorf("4294967295 %s 1 = %d, want 2147483647", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("4294967295 %s 255 = %d, want 0", ">>", r) + } +} +func TestConstFoldint32uint64lsh(t *testing.T) { + var x, r int32 + var y uint64 + x = -2147483648 + y = 0 + r = x << y + if r != -2147483648 { + t.Errorf("-2147483648 %s 0 = %d, want -2147483648", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-2147483648 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-2147483648 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-2147483648 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = -2147483647 + y = 0 + r = x << y + if r != -2147483647 { + t.Errorf("-2147483647 %s 0 = %d, want -2147483647", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-2147483647 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-2147483647 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-2147483647 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 2147483647 + y = 0 + r = x << y + if r != 2147483647 { + t.Errorf("2147483647 %s 0 = %d, want 2147483647", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("2147483647 %s 1 = %d, want -2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("2147483647 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("2147483647 %s 18446744073709551615 = %d, want 0", "<<", r) + } +} +func TestConstFoldint32uint64rsh(t *testing.T) { + var x, r int32 + var y uint64 + x = -2147483648 + y = 0 + r = x >> y + if r != -2147483648 { + t.Errorf("-2147483648 %s 0 = %d, want -2147483648", ">>", r) + } + y = 1 + r = x >> y + if r != -1073741824 { + t.Errorf("-2147483648 %s 1 = %d, want -1073741824", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-2147483648 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-2147483648 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = -2147483647 + y = 0 + r = x >> y + if r != -2147483647 { + t.Errorf("-2147483647 %s 0 = %d, want -2147483647", ">>", r) + } + y = 1 + r = x >> y + if r != -1073741824 { + t.Errorf("-2147483647 %s 1 = %d, want -1073741824", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-2147483647 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-2147483647 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 2147483647 + y = 0 + r = x >> y + if r != 2147483647 { + t.Errorf("2147483647 %s 0 = %d, want 2147483647", ">>", r) + } + y = 1 + r = x >> y + if r != 1073741823 { + t.Errorf("2147483647 %s 1 = %d, want 1073741823", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("2147483647 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("2147483647 %s 18446744073709551615 = %d, want 0", ">>", r) + } +} +func TestConstFoldint32uint32lsh(t *testing.T) { + var x, r int32 + var y uint32 + x = -2147483648 + y = 0 + r = x << y + if r != -2147483648 { + t.Errorf("-2147483648 %s 0 = %d, want -2147483648", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-2147483648 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-2147483648 %s 4294967295 = %d, want 0", "<<", r) + } + x = -2147483647 + y = 0 + r = x << y + if r != -2147483647 { + t.Errorf("-2147483647 %s 0 = %d, want -2147483647", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-2147483647 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-2147483647 %s 4294967295 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 2147483647 + y = 0 + r = x << y + if r != 2147483647 { + t.Errorf("2147483647 %s 0 = %d, want 2147483647", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("2147483647 %s 1 = %d, want -2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("2147483647 %s 4294967295 = %d, want 0", "<<", r) + } +} +func TestConstFoldint32uint32rsh(t *testing.T) { + var x, r int32 + var y uint32 + x = -2147483648 + y = 0 + r = x >> y + if r != -2147483648 { + t.Errorf("-2147483648 %s 0 = %d, want -2147483648", ">>", r) + } + y = 1 + r = x >> y + if r != -1073741824 { + t.Errorf("-2147483648 %s 1 = %d, want -1073741824", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-2147483648 %s 4294967295 = %d, want -1", ">>", r) + } + x = -2147483647 + y = 0 + r = x >> y + if r != -2147483647 { + t.Errorf("-2147483647 %s 0 = %d, want -2147483647", ">>", r) + } + y = 1 + r = x >> y + if r != -1073741824 { + t.Errorf("-2147483647 %s 1 = %d, want -1073741824", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-2147483647 %s 4294967295 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 4294967295 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", ">>", r) + } + x = 2147483647 + y = 0 + r = x >> y + if r != 2147483647 { + t.Errorf("2147483647 %s 0 = %d, want 2147483647", ">>", r) + } + y = 1 + r = x >> y + if r != 1073741823 { + t.Errorf("2147483647 %s 1 = %d, want 1073741823", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("2147483647 %s 4294967295 = %d, want 0", ">>", r) + } +} +func TestConstFoldint32uint16lsh(t *testing.T) { + var x, r int32 + var y uint16 + x = -2147483648 + y = 0 + r = x << y + if r != -2147483648 { + t.Errorf("-2147483648 %s 0 = %d, want -2147483648", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-2147483648 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-2147483648 %s 65535 = %d, want 0", "<<", r) + } + x = -2147483647 + y = 0 + r = x << y + if r != -2147483647 { + t.Errorf("-2147483647 %s 0 = %d, want -2147483647", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-2147483647 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-2147483647 %s 65535 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-1 %s 65535 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", "<<", r) + } + x = 2147483647 + y = 0 + r = x << y + if r != 2147483647 { + t.Errorf("2147483647 %s 0 = %d, want 2147483647", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("2147483647 %s 1 = %d, want -2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("2147483647 %s 65535 = %d, want 0", "<<", r) + } +} +func TestConstFoldint32uint16rsh(t *testing.T) { + var x, r int32 + var y uint16 + x = -2147483648 + y = 0 + r = x >> y + if r != -2147483648 { + t.Errorf("-2147483648 %s 0 = %d, want -2147483648", ">>", r) + } + y = 1 + r = x >> y + if r != -1073741824 { + t.Errorf("-2147483648 %s 1 = %d, want -1073741824", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-2147483648 %s 65535 = %d, want -1", ">>", r) + } + x = -2147483647 + y = 0 + r = x >> y + if r != -2147483647 { + t.Errorf("-2147483647 %s 0 = %d, want -2147483647", ">>", r) + } + y = 1 + r = x >> y + if r != -1073741824 { + t.Errorf("-2147483647 %s 1 = %d, want -1073741824", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-2147483647 %s 65535 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 65535 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", ">>", r) + } + x = 2147483647 + y = 0 + r = x >> y + if r != 2147483647 { + t.Errorf("2147483647 %s 0 = %d, want 2147483647", ">>", r) + } + y = 1 + r = x >> y + if r != 1073741823 { + t.Errorf("2147483647 %s 1 = %d, want 1073741823", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("2147483647 %s 65535 = %d, want 0", ">>", r) + } +} +func TestConstFoldint32uint8lsh(t *testing.T) { + var x, r int32 + var y uint8 + x = -2147483648 + y = 0 + r = x << y + if r != -2147483648 { + t.Errorf("-2147483648 %s 0 = %d, want -2147483648", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-2147483648 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-2147483648 %s 255 = %d, want 0", "<<", r) + } + x = -2147483647 + y = 0 + r = x << y + if r != -2147483647 { + t.Errorf("-2147483647 %s 0 = %d, want -2147483647", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-2147483647 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-2147483647 %s 255 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-1 %s 255 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", "<<", r) + } + x = 2147483647 + y = 0 + r = x << y + if r != 2147483647 { + t.Errorf("2147483647 %s 0 = %d, want 2147483647", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("2147483647 %s 1 = %d, want -2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("2147483647 %s 255 = %d, want 0", "<<", r) + } +} +func TestConstFoldint32uint8rsh(t *testing.T) { + var x, r int32 + var y uint8 + x = -2147483648 + y = 0 + r = x >> y + if r != -2147483648 { + t.Errorf("-2147483648 %s 0 = %d, want -2147483648", ">>", r) + } + y = 1 + r = x >> y + if r != -1073741824 { + t.Errorf("-2147483648 %s 1 = %d, want -1073741824", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-2147483648 %s 255 = %d, want -1", ">>", r) + } + x = -2147483647 + y = 0 + r = x >> y + if r != -2147483647 { + t.Errorf("-2147483647 %s 0 = %d, want -2147483647", ">>", r) + } + y = 1 + r = x >> y + if r != -1073741824 { + t.Errorf("-2147483647 %s 1 = %d, want -1073741824", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-2147483647 %s 255 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 255 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", ">>", r) + } + x = 2147483647 + y = 0 + r = x >> y + if r != 2147483647 { + t.Errorf("2147483647 %s 0 = %d, want 2147483647", ">>", r) + } + y = 1 + r = x >> y + if r != 1073741823 { + t.Errorf("2147483647 %s 1 = %d, want 1073741823", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("2147483647 %s 255 = %d, want 0", ">>", r) + } +} +func TestConstFolduint16uint64lsh(t *testing.T) { + var x, r uint16 + var y uint64 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 65535 + y = 0 + r = x << y + if r != 65535 { + t.Errorf("65535 %s 0 = %d, want 65535", "<<", r) + } + y = 1 + r = x << y + if r != 65534 { + t.Errorf("65535 %s 1 = %d, want 65534", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("65535 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("65535 %s 18446744073709551615 = %d, want 0", "<<", r) + } +} +func TestConstFolduint16uint64rsh(t *testing.T) { + var x, r uint16 + var y uint64 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 65535 + y = 0 + r = x >> y + if r != 65535 { + t.Errorf("65535 %s 0 = %d, want 65535", ">>", r) + } + y = 1 + r = x >> y + if r != 32767 { + t.Errorf("65535 %s 1 = %d, want 32767", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("65535 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("65535 %s 18446744073709551615 = %d, want 0", ">>", r) + } +} +func TestConstFolduint16uint32lsh(t *testing.T) { + var x, r uint16 + var y uint32 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 65535 + y = 0 + r = x << y + if r != 65535 { + t.Errorf("65535 %s 0 = %d, want 65535", "<<", r) + } + y = 1 + r = x << y + if r != 65534 { + t.Errorf("65535 %s 1 = %d, want 65534", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("65535 %s 4294967295 = %d, want 0", "<<", r) + } +} +func TestConstFolduint16uint32rsh(t *testing.T) { + var x, r uint16 + var y uint32 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", ">>", r) + } + x = 65535 + y = 0 + r = x >> y + if r != 65535 { + t.Errorf("65535 %s 0 = %d, want 65535", ">>", r) + } + y = 1 + r = x >> y + if r != 32767 { + t.Errorf("65535 %s 1 = %d, want 32767", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("65535 %s 4294967295 = %d, want 0", ">>", r) + } +} +func TestConstFolduint16uint16lsh(t *testing.T) { + var x, r uint16 + var y uint16 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", "<<", r) + } + x = 65535 + y = 0 + r = x << y + if r != 65535 { + t.Errorf("65535 %s 0 = %d, want 65535", "<<", r) + } + y = 1 + r = x << y + if r != 65534 { + t.Errorf("65535 %s 1 = %d, want 65534", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("65535 %s 65535 = %d, want 0", "<<", r) + } +} +func TestConstFolduint16uint16rsh(t *testing.T) { + var x, r uint16 + var y uint16 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", ">>", r) + } + x = 65535 + y = 0 + r = x >> y + if r != 65535 { + t.Errorf("65535 %s 0 = %d, want 65535", ">>", r) + } + y = 1 + r = x >> y + if r != 32767 { + t.Errorf("65535 %s 1 = %d, want 32767", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("65535 %s 65535 = %d, want 0", ">>", r) + } +} +func TestConstFolduint16uint8lsh(t *testing.T) { + var x, r uint16 + var y uint8 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", "<<", r) + } + x = 65535 + y = 0 + r = x << y + if r != 65535 { + t.Errorf("65535 %s 0 = %d, want 65535", "<<", r) + } + y = 1 + r = x << y + if r != 65534 { + t.Errorf("65535 %s 1 = %d, want 65534", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("65535 %s 255 = %d, want 0", "<<", r) + } +} +func TestConstFolduint16uint8rsh(t *testing.T) { + var x, r uint16 + var y uint8 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", ">>", r) + } + x = 65535 + y = 0 + r = x >> y + if r != 65535 { + t.Errorf("65535 %s 0 = %d, want 65535", ">>", r) + } + y = 1 + r = x >> y + if r != 32767 { + t.Errorf("65535 %s 1 = %d, want 32767", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("65535 %s 255 = %d, want 0", ">>", r) + } +} +func TestConstFoldint16uint64lsh(t *testing.T) { + var x, r int16 + var y uint64 + x = -32768 + y = 0 + r = x << y + if r != -32768 { + t.Errorf("-32768 %s 0 = %d, want -32768", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-32768 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-32768 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-32768 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = -32767 + y = 0 + r = x << y + if r != -32767 { + t.Errorf("-32767 %s 0 = %d, want -32767", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-32767 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-32767 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-32767 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 32766 + y = 0 + r = x << y + if r != 32766 { + t.Errorf("32766 %s 0 = %d, want 32766", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("32766 %s 1 = %d, want -4", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("32766 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("32766 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 32767 + y = 0 + r = x << y + if r != 32767 { + t.Errorf("32767 %s 0 = %d, want 32767", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("32767 %s 1 = %d, want -2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("32767 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("32767 %s 18446744073709551615 = %d, want 0", "<<", r) + } +} +func TestConstFoldint16uint64rsh(t *testing.T) { + var x, r int16 + var y uint64 + x = -32768 + y = 0 + r = x >> y + if r != -32768 { + t.Errorf("-32768 %s 0 = %d, want -32768", ">>", r) + } + y = 1 + r = x >> y + if r != -16384 { + t.Errorf("-32768 %s 1 = %d, want -16384", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-32768 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-32768 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = -32767 + y = 0 + r = x >> y + if r != -32767 { + t.Errorf("-32767 %s 0 = %d, want -32767", ">>", r) + } + y = 1 + r = x >> y + if r != -16384 { + t.Errorf("-32767 %s 1 = %d, want -16384", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-32767 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-32767 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 32766 + y = 0 + r = x >> y + if r != 32766 { + t.Errorf("32766 %s 0 = %d, want 32766", ">>", r) + } + y = 1 + r = x >> y + if r != 16383 { + t.Errorf("32766 %s 1 = %d, want 16383", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("32766 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("32766 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 32767 + y = 0 + r = x >> y + if r != 32767 { + t.Errorf("32767 %s 0 = %d, want 32767", ">>", r) + } + y = 1 + r = x >> y + if r != 16383 { + t.Errorf("32767 %s 1 = %d, want 16383", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("32767 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("32767 %s 18446744073709551615 = %d, want 0", ">>", r) + } +} +func TestConstFoldint16uint32lsh(t *testing.T) { + var x, r int16 + var y uint32 + x = -32768 + y = 0 + r = x << y + if r != -32768 { + t.Errorf("-32768 %s 0 = %d, want -32768", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-32768 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-32768 %s 4294967295 = %d, want 0", "<<", r) + } + x = -32767 + y = 0 + r = x << y + if r != -32767 { + t.Errorf("-32767 %s 0 = %d, want -32767", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-32767 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-32767 %s 4294967295 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 32766 + y = 0 + r = x << y + if r != 32766 { + t.Errorf("32766 %s 0 = %d, want 32766", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("32766 %s 1 = %d, want -4", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("32766 %s 4294967295 = %d, want 0", "<<", r) + } + x = 32767 + y = 0 + r = x << y + if r != 32767 { + t.Errorf("32767 %s 0 = %d, want 32767", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("32767 %s 1 = %d, want -2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("32767 %s 4294967295 = %d, want 0", "<<", r) + } +} +func TestConstFoldint16uint32rsh(t *testing.T) { + var x, r int16 + var y uint32 + x = -32768 + y = 0 + r = x >> y + if r != -32768 { + t.Errorf("-32768 %s 0 = %d, want -32768", ">>", r) + } + y = 1 + r = x >> y + if r != -16384 { + t.Errorf("-32768 %s 1 = %d, want -16384", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-32768 %s 4294967295 = %d, want -1", ">>", r) + } + x = -32767 + y = 0 + r = x >> y + if r != -32767 { + t.Errorf("-32767 %s 0 = %d, want -32767", ">>", r) + } + y = 1 + r = x >> y + if r != -16384 { + t.Errorf("-32767 %s 1 = %d, want -16384", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-32767 %s 4294967295 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 4294967295 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", ">>", r) + } + x = 32766 + y = 0 + r = x >> y + if r != 32766 { + t.Errorf("32766 %s 0 = %d, want 32766", ">>", r) + } + y = 1 + r = x >> y + if r != 16383 { + t.Errorf("32766 %s 1 = %d, want 16383", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("32766 %s 4294967295 = %d, want 0", ">>", r) + } + x = 32767 + y = 0 + r = x >> y + if r != 32767 { + t.Errorf("32767 %s 0 = %d, want 32767", ">>", r) + } + y = 1 + r = x >> y + if r != 16383 { + t.Errorf("32767 %s 1 = %d, want 16383", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("32767 %s 4294967295 = %d, want 0", ">>", r) + } +} +func TestConstFoldint16uint16lsh(t *testing.T) { + var x, r int16 + var y uint16 + x = -32768 + y = 0 + r = x << y + if r != -32768 { + t.Errorf("-32768 %s 0 = %d, want -32768", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-32768 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-32768 %s 65535 = %d, want 0", "<<", r) + } + x = -32767 + y = 0 + r = x << y + if r != -32767 { + t.Errorf("-32767 %s 0 = %d, want -32767", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-32767 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-32767 %s 65535 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-1 %s 65535 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", "<<", r) + } + x = 32766 + y = 0 + r = x << y + if r != 32766 { + t.Errorf("32766 %s 0 = %d, want 32766", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("32766 %s 1 = %d, want -4", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("32766 %s 65535 = %d, want 0", "<<", r) + } + x = 32767 + y = 0 + r = x << y + if r != 32767 { + t.Errorf("32767 %s 0 = %d, want 32767", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("32767 %s 1 = %d, want -2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("32767 %s 65535 = %d, want 0", "<<", r) + } +} +func TestConstFoldint16uint16rsh(t *testing.T) { + var x, r int16 + var y uint16 + x = -32768 + y = 0 + r = x >> y + if r != -32768 { + t.Errorf("-32768 %s 0 = %d, want -32768", ">>", r) + } + y = 1 + r = x >> y + if r != -16384 { + t.Errorf("-32768 %s 1 = %d, want -16384", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-32768 %s 65535 = %d, want -1", ">>", r) + } + x = -32767 + y = 0 + r = x >> y + if r != -32767 { + t.Errorf("-32767 %s 0 = %d, want -32767", ">>", r) + } + y = 1 + r = x >> y + if r != -16384 { + t.Errorf("-32767 %s 1 = %d, want -16384", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-32767 %s 65535 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 65535 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", ">>", r) + } + x = 32766 + y = 0 + r = x >> y + if r != 32766 { + t.Errorf("32766 %s 0 = %d, want 32766", ">>", r) + } + y = 1 + r = x >> y + if r != 16383 { + t.Errorf("32766 %s 1 = %d, want 16383", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("32766 %s 65535 = %d, want 0", ">>", r) + } + x = 32767 + y = 0 + r = x >> y + if r != 32767 { + t.Errorf("32767 %s 0 = %d, want 32767", ">>", r) + } + y = 1 + r = x >> y + if r != 16383 { + t.Errorf("32767 %s 1 = %d, want 16383", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("32767 %s 65535 = %d, want 0", ">>", r) + } +} +func TestConstFoldint16uint8lsh(t *testing.T) { + var x, r int16 + var y uint8 + x = -32768 + y = 0 + r = x << y + if r != -32768 { + t.Errorf("-32768 %s 0 = %d, want -32768", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-32768 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-32768 %s 255 = %d, want 0", "<<", r) + } + x = -32767 + y = 0 + r = x << y + if r != -32767 { + t.Errorf("-32767 %s 0 = %d, want -32767", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-32767 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-32767 %s 255 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-1 %s 255 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", "<<", r) + } + x = 32766 + y = 0 + r = x << y + if r != 32766 { + t.Errorf("32766 %s 0 = %d, want 32766", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("32766 %s 1 = %d, want -4", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("32766 %s 255 = %d, want 0", "<<", r) + } + x = 32767 + y = 0 + r = x << y + if r != 32767 { + t.Errorf("32767 %s 0 = %d, want 32767", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("32767 %s 1 = %d, want -2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("32767 %s 255 = %d, want 0", "<<", r) + } +} +func TestConstFoldint16uint8rsh(t *testing.T) { + var x, r int16 + var y uint8 + x = -32768 + y = 0 + r = x >> y + if r != -32768 { + t.Errorf("-32768 %s 0 = %d, want -32768", ">>", r) + } + y = 1 + r = x >> y + if r != -16384 { + t.Errorf("-32768 %s 1 = %d, want -16384", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-32768 %s 255 = %d, want -1", ">>", r) + } + x = -32767 + y = 0 + r = x >> y + if r != -32767 { + t.Errorf("-32767 %s 0 = %d, want -32767", ">>", r) + } + y = 1 + r = x >> y + if r != -16384 { + t.Errorf("-32767 %s 1 = %d, want -16384", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-32767 %s 255 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 255 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", ">>", r) + } + x = 32766 + y = 0 + r = x >> y + if r != 32766 { + t.Errorf("32766 %s 0 = %d, want 32766", ">>", r) + } + y = 1 + r = x >> y + if r != 16383 { + t.Errorf("32766 %s 1 = %d, want 16383", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("32766 %s 255 = %d, want 0", ">>", r) + } + x = 32767 + y = 0 + r = x >> y + if r != 32767 { + t.Errorf("32767 %s 0 = %d, want 32767", ">>", r) + } + y = 1 + r = x >> y + if r != 16383 { + t.Errorf("32767 %s 1 = %d, want 16383", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("32767 %s 255 = %d, want 0", ">>", r) + } +} +func TestConstFolduint8uint64lsh(t *testing.T) { + var x, r uint8 + var y uint64 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 255 + y = 0 + r = x << y + if r != 255 { + t.Errorf("255 %s 0 = %d, want 255", "<<", r) + } + y = 1 + r = x << y + if r != 254 { + t.Errorf("255 %s 1 = %d, want 254", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("255 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("255 %s 18446744073709551615 = %d, want 0", "<<", r) + } +} +func TestConstFolduint8uint64rsh(t *testing.T) { + var x, r uint8 + var y uint64 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 255 + y = 0 + r = x >> y + if r != 255 { + t.Errorf("255 %s 0 = %d, want 255", ">>", r) + } + y = 1 + r = x >> y + if r != 127 { + t.Errorf("255 %s 1 = %d, want 127", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("255 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("255 %s 18446744073709551615 = %d, want 0", ">>", r) + } +} +func TestConstFolduint8uint32lsh(t *testing.T) { + var x, r uint8 + var y uint32 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 255 + y = 0 + r = x << y + if r != 255 { + t.Errorf("255 %s 0 = %d, want 255", "<<", r) + } + y = 1 + r = x << y + if r != 254 { + t.Errorf("255 %s 1 = %d, want 254", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("255 %s 4294967295 = %d, want 0", "<<", r) + } +} +func TestConstFolduint8uint32rsh(t *testing.T) { + var x, r uint8 + var y uint32 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", ">>", r) + } + x = 255 + y = 0 + r = x >> y + if r != 255 { + t.Errorf("255 %s 0 = %d, want 255", ">>", r) + } + y = 1 + r = x >> y + if r != 127 { + t.Errorf("255 %s 1 = %d, want 127", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("255 %s 4294967295 = %d, want 0", ">>", r) + } +} +func TestConstFolduint8uint16lsh(t *testing.T) { + var x, r uint8 + var y uint16 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", "<<", r) + } + x = 255 + y = 0 + r = x << y + if r != 255 { + t.Errorf("255 %s 0 = %d, want 255", "<<", r) + } + y = 1 + r = x << y + if r != 254 { + t.Errorf("255 %s 1 = %d, want 254", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("255 %s 65535 = %d, want 0", "<<", r) + } +} +func TestConstFolduint8uint16rsh(t *testing.T) { + var x, r uint8 + var y uint16 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", ">>", r) + } + x = 255 + y = 0 + r = x >> y + if r != 255 { + t.Errorf("255 %s 0 = %d, want 255", ">>", r) + } + y = 1 + r = x >> y + if r != 127 { + t.Errorf("255 %s 1 = %d, want 127", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("255 %s 65535 = %d, want 0", ">>", r) + } +} +func TestConstFolduint8uint8lsh(t *testing.T) { + var x, r uint8 + var y uint8 + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", "<<", r) + } + x = 255 + y = 0 + r = x << y + if r != 255 { + t.Errorf("255 %s 0 = %d, want 255", "<<", r) + } + y = 1 + r = x << y + if r != 254 { + t.Errorf("255 %s 1 = %d, want 254", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("255 %s 255 = %d, want 0", "<<", r) + } +} +func TestConstFolduint8uint8rsh(t *testing.T) { + var x, r uint8 + var y uint8 + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", ">>", r) + } + x = 255 + y = 0 + r = x >> y + if r != 255 { + t.Errorf("255 %s 0 = %d, want 255", ">>", r) + } + y = 1 + r = x >> y + if r != 127 { + t.Errorf("255 %s 1 = %d, want 127", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("255 %s 255 = %d, want 0", ">>", r) + } +} +func TestConstFoldint8uint64lsh(t *testing.T) { + var x, r int8 + var y uint64 + x = -128 + y = 0 + r = x << y + if r != -128 { + t.Errorf("-128 %s 0 = %d, want -128", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-128 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-128 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-128 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = -127 + y = 0 + r = x << y + if r != -127 { + t.Errorf("-127 %s 0 = %d, want -127", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-127 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-127 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-127 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("-1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("-1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 126 + y = 0 + r = x << y + if r != 126 { + t.Errorf("126 %s 0 = %d, want 126", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("126 %s 1 = %d, want -4", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("126 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("126 %s 18446744073709551615 = %d, want 0", "<<", r) + } + x = 127 + y = 0 + r = x << y + if r != 127 { + t.Errorf("127 %s 0 = %d, want 127", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("127 %s 1 = %d, want -2", "<<", r) + } + y = 4294967296 + r = x << y + if r != 0 { + t.Errorf("127 %s 4294967296 = %d, want 0", "<<", r) + } + y = 18446744073709551615 + r = x << y + if r != 0 { + t.Errorf("127 %s 18446744073709551615 = %d, want 0", "<<", r) + } +} +func TestConstFoldint8uint64rsh(t *testing.T) { + var x, r int8 + var y uint64 + x = -128 + y = 0 + r = x >> y + if r != -128 { + t.Errorf("-128 %s 0 = %d, want -128", ">>", r) + } + y = 1 + r = x >> y + if r != -64 { + t.Errorf("-128 %s 1 = %d, want -64", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-128 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-128 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = -127 + y = 0 + r = x >> y + if r != -127 { + t.Errorf("-127 %s 0 = %d, want -127", ">>", r) + } + y = 1 + r = x >> y + if r != -64 { + t.Errorf("-127 %s 1 = %d, want -64", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-127 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-127 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 4294967296 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 4294967296 = %d, want -1", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 18446744073709551615 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("0 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("1 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 126 + y = 0 + r = x >> y + if r != 126 { + t.Errorf("126 %s 0 = %d, want 126", ">>", r) + } + y = 1 + r = x >> y + if r != 63 { + t.Errorf("126 %s 1 = %d, want 63", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("126 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("126 %s 18446744073709551615 = %d, want 0", ">>", r) + } + x = 127 + y = 0 + r = x >> y + if r != 127 { + t.Errorf("127 %s 0 = %d, want 127", ">>", r) + } + y = 1 + r = x >> y + if r != 63 { + t.Errorf("127 %s 1 = %d, want 63", ">>", r) + } + y = 4294967296 + r = x >> y + if r != 0 { + t.Errorf("127 %s 4294967296 = %d, want 0", ">>", r) + } + y = 18446744073709551615 + r = x >> y + if r != 0 { + t.Errorf("127 %s 18446744073709551615 = %d, want 0", ">>", r) + } +} +func TestConstFoldint8uint32lsh(t *testing.T) { + var x, r int8 + var y uint32 + x = -128 + y = 0 + r = x << y + if r != -128 { + t.Errorf("-128 %s 0 = %d, want -128", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-128 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-128 %s 4294967295 = %d, want 0", "<<", r) + } + x = -127 + y = 0 + r = x << y + if r != -127 { + t.Errorf("-127 %s 0 = %d, want -127", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-127 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-127 %s 4294967295 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("-1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", "<<", r) + } + x = 126 + y = 0 + r = x << y + if r != 126 { + t.Errorf("126 %s 0 = %d, want 126", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("126 %s 1 = %d, want -4", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("126 %s 4294967295 = %d, want 0", "<<", r) + } + x = 127 + y = 0 + r = x << y + if r != 127 { + t.Errorf("127 %s 0 = %d, want 127", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("127 %s 1 = %d, want -2", "<<", r) + } + y = 4294967295 + r = x << y + if r != 0 { + t.Errorf("127 %s 4294967295 = %d, want 0", "<<", r) + } +} +func TestConstFoldint8uint32rsh(t *testing.T) { + var x, r int8 + var y uint32 + x = -128 + y = 0 + r = x >> y + if r != -128 { + t.Errorf("-128 %s 0 = %d, want -128", ">>", r) + } + y = 1 + r = x >> y + if r != -64 { + t.Errorf("-128 %s 1 = %d, want -64", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-128 %s 4294967295 = %d, want -1", ">>", r) + } + x = -127 + y = 0 + r = x >> y + if r != -127 { + t.Errorf("-127 %s 0 = %d, want -127", ">>", r) + } + y = 1 + r = x >> y + if r != -64 { + t.Errorf("-127 %s 1 = %d, want -64", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-127 %s 4294967295 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 4294967295 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 4294967295 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("0 %s 4294967295 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("1 %s 4294967295 = %d, want 0", ">>", r) + } + x = 126 + y = 0 + r = x >> y + if r != 126 { + t.Errorf("126 %s 0 = %d, want 126", ">>", r) + } + y = 1 + r = x >> y + if r != 63 { + t.Errorf("126 %s 1 = %d, want 63", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("126 %s 4294967295 = %d, want 0", ">>", r) + } + x = 127 + y = 0 + r = x >> y + if r != 127 { + t.Errorf("127 %s 0 = %d, want 127", ">>", r) + } + y = 1 + r = x >> y + if r != 63 { + t.Errorf("127 %s 1 = %d, want 63", ">>", r) + } + y = 4294967295 + r = x >> y + if r != 0 { + t.Errorf("127 %s 4294967295 = %d, want 0", ">>", r) + } +} +func TestConstFoldint8uint16lsh(t *testing.T) { + var x, r int8 + var y uint16 + x = -128 + y = 0 + r = x << y + if r != -128 { + t.Errorf("-128 %s 0 = %d, want -128", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-128 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-128 %s 65535 = %d, want 0", "<<", r) + } + x = -127 + y = 0 + r = x << y + if r != -127 { + t.Errorf("-127 %s 0 = %d, want -127", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-127 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-127 %s 65535 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("-1 %s 65535 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", "<<", r) + } + x = 126 + y = 0 + r = x << y + if r != 126 { + t.Errorf("126 %s 0 = %d, want 126", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("126 %s 1 = %d, want -4", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("126 %s 65535 = %d, want 0", "<<", r) + } + x = 127 + y = 0 + r = x << y + if r != 127 { + t.Errorf("127 %s 0 = %d, want 127", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("127 %s 1 = %d, want -2", "<<", r) + } + y = 65535 + r = x << y + if r != 0 { + t.Errorf("127 %s 65535 = %d, want 0", "<<", r) + } +} +func TestConstFoldint8uint16rsh(t *testing.T) { + var x, r int8 + var y uint16 + x = -128 + y = 0 + r = x >> y + if r != -128 { + t.Errorf("-128 %s 0 = %d, want -128", ">>", r) + } + y = 1 + r = x >> y + if r != -64 { + t.Errorf("-128 %s 1 = %d, want -64", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-128 %s 65535 = %d, want -1", ">>", r) + } + x = -127 + y = 0 + r = x >> y + if r != -127 { + t.Errorf("-127 %s 0 = %d, want -127", ">>", r) + } + y = 1 + r = x >> y + if r != -64 { + t.Errorf("-127 %s 1 = %d, want -64", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-127 %s 65535 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 65535 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 65535 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("0 %s 65535 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("1 %s 65535 = %d, want 0", ">>", r) + } + x = 126 + y = 0 + r = x >> y + if r != 126 { + t.Errorf("126 %s 0 = %d, want 126", ">>", r) + } + y = 1 + r = x >> y + if r != 63 { + t.Errorf("126 %s 1 = %d, want 63", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("126 %s 65535 = %d, want 0", ">>", r) + } + x = 127 + y = 0 + r = x >> y + if r != 127 { + t.Errorf("127 %s 0 = %d, want 127", ">>", r) + } + y = 1 + r = x >> y + if r != 63 { + t.Errorf("127 %s 1 = %d, want 63", ">>", r) + } + y = 65535 + r = x >> y + if r != 0 { + t.Errorf("127 %s 65535 = %d, want 0", ">>", r) + } +} +func TestConstFoldint8uint8lsh(t *testing.T) { + var x, r int8 + var y uint8 + x = -128 + y = 0 + r = x << y + if r != -128 { + t.Errorf("-128 %s 0 = %d, want -128", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("-128 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-128 %s 255 = %d, want 0", "<<", r) + } + x = -127 + y = 0 + r = x << y + if r != -127 { + t.Errorf("-127 %s 0 = %d, want -127", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("-127 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-127 %s 255 = %d, want 0", "<<", r) + } + x = -1 + y = 0 + r = x << y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("-1 %s 1 = %d, want -2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("-1 %s 255 = %d, want 0", "<<", r) + } + x = 0 + y = 0 + r = x << y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", "<<", r) + } + y = 1 + r = x << y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", "<<", r) + } + x = 1 + y = 0 + r = x << y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", "<<", r) + } + y = 1 + r = x << y + if r != 2 { + t.Errorf("1 %s 1 = %d, want 2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", "<<", r) + } + x = 126 + y = 0 + r = x << y + if r != 126 { + t.Errorf("126 %s 0 = %d, want 126", "<<", r) + } + y = 1 + r = x << y + if r != -4 { + t.Errorf("126 %s 1 = %d, want -4", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("126 %s 255 = %d, want 0", "<<", r) + } + x = 127 + y = 0 + r = x << y + if r != 127 { + t.Errorf("127 %s 0 = %d, want 127", "<<", r) + } + y = 1 + r = x << y + if r != -2 { + t.Errorf("127 %s 1 = %d, want -2", "<<", r) + } + y = 255 + r = x << y + if r != 0 { + t.Errorf("127 %s 255 = %d, want 0", "<<", r) + } +} +func TestConstFoldint8uint8rsh(t *testing.T) { + var x, r int8 + var y uint8 + x = -128 + y = 0 + r = x >> y + if r != -128 { + t.Errorf("-128 %s 0 = %d, want -128", ">>", r) + } + y = 1 + r = x >> y + if r != -64 { + t.Errorf("-128 %s 1 = %d, want -64", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-128 %s 255 = %d, want -1", ">>", r) + } + x = -127 + y = 0 + r = x >> y + if r != -127 { + t.Errorf("-127 %s 0 = %d, want -127", ">>", r) + } + y = 1 + r = x >> y + if r != -64 { + t.Errorf("-127 %s 1 = %d, want -64", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-127 %s 255 = %d, want -1", ">>", r) + } + x = -1 + y = 0 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 0 = %d, want -1", ">>", r) + } + y = 1 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 1 = %d, want -1", ">>", r) + } + y = 255 + r = x >> y + if r != -1 { + t.Errorf("-1 %s 255 = %d, want -1", ">>", r) + } + x = 0 + y = 0 + r = x >> y + if r != 0 { + t.Errorf("0 %s 0 = %d, want 0", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("0 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("0 %s 255 = %d, want 0", ">>", r) + } + x = 1 + y = 0 + r = x >> y + if r != 1 { + t.Errorf("1 %s 0 = %d, want 1", ">>", r) + } + y = 1 + r = x >> y + if r != 0 { + t.Errorf("1 %s 1 = %d, want 0", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("1 %s 255 = %d, want 0", ">>", r) + } + x = 126 + y = 0 + r = x >> y + if r != 126 { + t.Errorf("126 %s 0 = %d, want 126", ">>", r) + } + y = 1 + r = x >> y + if r != 63 { + t.Errorf("126 %s 1 = %d, want 63", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("126 %s 255 = %d, want 0", ">>", r) + } + x = 127 + y = 0 + r = x >> y + if r != 127 { + t.Errorf("127 %s 0 = %d, want 127", ">>", r) + } + y = 1 + r = x >> y + if r != 63 { + t.Errorf("127 %s 1 = %d, want 63", ">>", r) + } + y = 255 + r = x >> y + if r != 0 { + t.Errorf("127 %s 255 = %d, want 0", ">>", r) + } +} +func TestConstFoldCompareuint64(t *testing.T) { + { + var x uint64 = 0 + var y uint64 = 0 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint64 = 0 + var y uint64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint64 = 0 + var y uint64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint64 = 0 + var y uint64 = 18446744073709551615 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint64 = 1 + var y uint64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint64 = 1 + var y uint64 = 1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint64 = 1 + var y uint64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint64 = 1 + var y uint64 = 18446744073709551615 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint64 = 4294967296 + var y uint64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint64 = 4294967296 + var y uint64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint64 = 4294967296 + var y uint64 = 4294967296 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint64 = 4294967296 + var y uint64 = 18446744073709551615 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint64 = 18446744073709551615 + var y uint64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint64 = 18446744073709551615 + var y uint64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint64 = 18446744073709551615 + var y uint64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint64 = 18446744073709551615 + var y uint64 = 18446744073709551615 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } +} +func TestConstFoldCompareint64(t *testing.T) { + { + var x int64 = -9223372036854775808 + var y int64 = -9223372036854775808 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = -9223372036854775808 + var y int64 = -9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775808 + var y int64 = -4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775808 + var y int64 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775808 + var y int64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775808 + var y int64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775808 + var y int64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775808 + var y int64 = 9223372036854775806 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775808 + var y int64 = 9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775807 + var y int64 = -9223372036854775808 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = -9223372036854775807 + var y int64 = -9223372036854775807 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = -9223372036854775807 + var y int64 = -4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775807 + var y int64 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775807 + var y int64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775807 + var y int64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775807 + var y int64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775807 + var y int64 = 9223372036854775806 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -9223372036854775807 + var y int64 = 9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -4294967296 + var y int64 = -9223372036854775808 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = -4294967296 + var y int64 = -9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = -4294967296 + var y int64 = -4294967296 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = -4294967296 + var y int64 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -4294967296 + var y int64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -4294967296 + var y int64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -4294967296 + var y int64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -4294967296 + var y int64 = 9223372036854775806 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -4294967296 + var y int64 = 9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -1 + var y int64 = -9223372036854775808 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = -1 + var y int64 = -9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = -1 + var y int64 = -4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = -1 + var y int64 = -1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = -1 + var y int64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -1 + var y int64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -1 + var y int64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -1 + var y int64 = 9223372036854775806 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = -1 + var y int64 = 9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 0 + var y int64 = -9223372036854775808 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 0 + var y int64 = -9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 0 + var y int64 = -4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 0 + var y int64 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 0 + var y int64 = 0 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 0 + var y int64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 0 + var y int64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 0 + var y int64 = 9223372036854775806 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 0 + var y int64 = 9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 1 + var y int64 = -9223372036854775808 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 1 + var y int64 = -9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 1 + var y int64 = -4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 1 + var y int64 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 1 + var y int64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 1 + var y int64 = 1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 1 + var y int64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 1 + var y int64 = 9223372036854775806 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 1 + var y int64 = 9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 4294967296 + var y int64 = -9223372036854775808 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 4294967296 + var y int64 = -9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 4294967296 + var y int64 = -4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 4294967296 + var y int64 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 4294967296 + var y int64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 4294967296 + var y int64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 4294967296 + var y int64 = 4294967296 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 4294967296 + var y int64 = 9223372036854775806 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 4294967296 + var y int64 = 9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 9223372036854775806 + var y int64 = -9223372036854775808 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775806 + var y int64 = -9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775806 + var y int64 = -4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775806 + var y int64 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775806 + var y int64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775806 + var y int64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775806 + var y int64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775806 + var y int64 = 9223372036854775806 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775806 + var y int64 = 9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int64 = 9223372036854775807 + var y int64 = -9223372036854775808 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775807 + var y int64 = -9223372036854775807 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775807 + var y int64 = -4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775807 + var y int64 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775807 + var y int64 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775807 + var y int64 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775807 + var y int64 = 4294967296 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775807 + var y int64 = 9223372036854775806 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int64 = 9223372036854775807 + var y int64 = 9223372036854775807 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } +} +func TestConstFoldCompareuint32(t *testing.T) { + { + var x uint32 = 0 + var y uint32 = 0 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint32 = 0 + var y uint32 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint32 = 0 + var y uint32 = 4294967295 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint32 = 1 + var y uint32 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint32 = 1 + var y uint32 = 1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint32 = 1 + var y uint32 = 4294967295 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint32 = 4294967295 + var y uint32 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint32 = 4294967295 + var y uint32 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint32 = 4294967295 + var y uint32 = 4294967295 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } +} +func TestConstFoldCompareint32(t *testing.T) { + { + var x int32 = -2147483648 + var y int32 = -2147483648 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = -2147483648 + var y int32 = -2147483647 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -2147483648 + var y int32 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -2147483648 + var y int32 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -2147483648 + var y int32 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -2147483648 + var y int32 = 2147483647 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -2147483647 + var y int32 = -2147483648 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = -2147483647 + var y int32 = -2147483647 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = -2147483647 + var y int32 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -2147483647 + var y int32 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -2147483647 + var y int32 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -2147483647 + var y int32 = 2147483647 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -1 + var y int32 = -2147483648 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = -1 + var y int32 = -2147483647 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = -1 + var y int32 = -1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = -1 + var y int32 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -1 + var y int32 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = -1 + var y int32 = 2147483647 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = 0 + var y int32 = -2147483648 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 0 + var y int32 = -2147483647 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 0 + var y int32 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 0 + var y int32 = 0 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 0 + var y int32 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = 0 + var y int32 = 2147483647 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = 1 + var y int32 = -2147483648 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 1 + var y int32 = -2147483647 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 1 + var y int32 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 1 + var y int32 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 1 + var y int32 = 1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 1 + var y int32 = 2147483647 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int32 = 2147483647 + var y int32 = -2147483648 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 2147483647 + var y int32 = -2147483647 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 2147483647 + var y int32 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 2147483647 + var y int32 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 2147483647 + var y int32 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int32 = 2147483647 + var y int32 = 2147483647 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } +} +func TestConstFoldCompareuint16(t *testing.T) { + { + var x uint16 = 0 + var y uint16 = 0 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint16 = 0 + var y uint16 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint16 = 0 + var y uint16 = 65535 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint16 = 1 + var y uint16 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint16 = 1 + var y uint16 = 1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint16 = 1 + var y uint16 = 65535 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint16 = 65535 + var y uint16 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint16 = 65535 + var y uint16 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint16 = 65535 + var y uint16 = 65535 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } +} +func TestConstFoldCompareint16(t *testing.T) { + { + var x int16 = -32768 + var y int16 = -32768 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = -32768 + var y int16 = -32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -32768 + var y int16 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -32768 + var y int16 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -32768 + var y int16 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -32768 + var y int16 = 32766 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -32768 + var y int16 = 32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -32767 + var y int16 = -32768 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = -32767 + var y int16 = -32767 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = -32767 + var y int16 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -32767 + var y int16 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -32767 + var y int16 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -32767 + var y int16 = 32766 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -32767 + var y int16 = 32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -1 + var y int16 = -32768 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = -1 + var y int16 = -32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = -1 + var y int16 = -1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = -1 + var y int16 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -1 + var y int16 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -1 + var y int16 = 32766 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = -1 + var y int16 = 32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = 0 + var y int16 = -32768 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 0 + var y int16 = -32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 0 + var y int16 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 0 + var y int16 = 0 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 0 + var y int16 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = 0 + var y int16 = 32766 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = 0 + var y int16 = 32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = 1 + var y int16 = -32768 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 1 + var y int16 = -32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 1 + var y int16 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 1 + var y int16 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 1 + var y int16 = 1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 1 + var y int16 = 32766 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = 1 + var y int16 = 32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = 32766 + var y int16 = -32768 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32766 + var y int16 = -32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32766 + var y int16 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32766 + var y int16 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32766 + var y int16 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32766 + var y int16 = 32766 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32766 + var y int16 = 32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int16 = 32767 + var y int16 = -32768 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32767 + var y int16 = -32767 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32767 + var y int16 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32767 + var y int16 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32767 + var y int16 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32767 + var y int16 = 32766 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int16 = 32767 + var y int16 = 32767 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } +} +func TestConstFoldCompareuint8(t *testing.T) { + { + var x uint8 = 0 + var y uint8 = 0 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint8 = 0 + var y uint8 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint8 = 0 + var y uint8 = 255 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint8 = 1 + var y uint8 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint8 = 1 + var y uint8 = 1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint8 = 1 + var y uint8 = 255 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x uint8 = 255 + var y uint8 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint8 = 255 + var y uint8 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x uint8 = 255 + var y uint8 = 255 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } +} +func TestConstFoldCompareint8(t *testing.T) { + { + var x int8 = -128 + var y int8 = -128 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = -128 + var y int8 = -127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -128 + var y int8 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -128 + var y int8 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -128 + var y int8 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -128 + var y int8 = 126 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -128 + var y int8 = 127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -127 + var y int8 = -128 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = -127 + var y int8 = -127 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = -127 + var y int8 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -127 + var y int8 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -127 + var y int8 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -127 + var y int8 = 126 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -127 + var y int8 = 127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -1 + var y int8 = -128 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = -1 + var y int8 = -127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = -1 + var y int8 = -1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = -1 + var y int8 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -1 + var y int8 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -1 + var y int8 = 126 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = -1 + var y int8 = 127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = 0 + var y int8 = -128 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 0 + var y int8 = -127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 0 + var y int8 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 0 + var y int8 = 0 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 0 + var y int8 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = 0 + var y int8 = 126 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = 0 + var y int8 = 127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = 1 + var y int8 = -128 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 1 + var y int8 = -127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 1 + var y int8 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 1 + var y int8 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 1 + var y int8 = 1 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 1 + var y int8 = 126 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = 1 + var y int8 = 127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = 126 + var y int8 = -128 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 126 + var y int8 = -127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 126 + var y int8 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 126 + var y int8 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 126 + var y int8 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 126 + var y int8 = 126 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 126 + var y int8 = 127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if !(x < y) { + t.Errorf("!(%d < %d)", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if x >= y { + t.Errorf("%d >= %d", x, y) + } + } + { + var x int8 = 127 + var y int8 = -128 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 127 + var y int8 = -127 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 127 + var y int8 = -1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 127 + var y int8 = 0 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 127 + var y int8 = 1 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 127 + var y int8 = 126 + if x == y { + t.Errorf("%d == %d", x, y) + } + if !(x != y) { + t.Errorf("!(%d != %d)", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if !(x > y) { + t.Errorf("!(%d > %d)", x, y) + } + if x <= y { + t.Errorf("%d <= %d", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } + { + var x int8 = 127 + var y int8 = 127 + if !(x == y) { + t.Errorf("!(%d == %d)", x, y) + } + if x != y { + t.Errorf("%d != %d", x, y) + } + if x < y { + t.Errorf("%d < %d", x, y) + } + if x > y { + t.Errorf("%d > %d", x, y) + } + if !(x <= y) { + t.Errorf("!(%d <= %d)", x, y) + } + if !(x >= y) { + t.Errorf("!(%d >= %d)", x, y) + } + } +} diff --git a/go/src/cmd/compile/internal/test/dep_test.go b/go/src/cmd/compile/internal/test/dep_test.go new file mode 100644 index 0000000000000000000000000000000000000000..d141f1074a59164f35724d7479c3876d70727bdc --- /dev/null +++ b/go/src/cmd/compile/internal/test/dep_test.go @@ -0,0 +1,29 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "internal/testenv" + "strings" + "testing" +) + +func TestDeps(t *testing.T) { + out, err := testenv.Command(t, testenv.GoToolPath(t), "list", "-f", "{{.Deps}}", "cmd/compile/internal/gc").Output() + if err != nil { + t.Fatal(err) + } + for _, dep := range strings.Fields(strings.Trim(string(out), "[]")) { + switch dep { + case "go/build", "go/scanner": + // cmd/compile/internal/importer introduces a dependency + // on go/build and go/token; cmd/compile/internal/ uses + // go/constant which uses go/token in its API. Once we + // got rid of those dependencies, enable this check again. + // TODO(gri) fix this + // t.Errorf("undesired dependency on %q", dep) + } + } +} diff --git a/go/src/cmd/compile/internal/test/divconst_test.go b/go/src/cmd/compile/internal/test/divconst_test.go new file mode 100644 index 0000000000000000000000000000000000000000..5e89ce9a3d30b8f0b94791a04cd3bd003fa8dc2d --- /dev/null +++ b/go/src/cmd/compile/internal/test/divconst_test.go @@ -0,0 +1,325 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "testing" +) + +var boolres bool + +var i64res int64 + +func BenchmarkDivconstI64(b *testing.B) { + for i := 0; i < b.N; i++ { + i64res = int64(i) / 7 + } +} + +func BenchmarkModconstI64(b *testing.B) { + for i := 0; i < b.N; i++ { + i64res = int64(i) % 7 + } +} + +func BenchmarkDivisiblePow2constI64(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = int64(i)%16 == 0 + } +} +func BenchmarkDivisibleconstI64(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = int64(i)%7 == 0 + } +} + +func BenchmarkDivisibleWDivconstI64(b *testing.B) { + for i := 0; i < b.N; i++ { + i64res = int64(i) / 7 + boolres = int64(i)%7 == 0 + } +} + +var u64res uint64 + +func TestDivmodConstU64(t *testing.T) { + // Test division by c. Function f must be func(n) { return n/c, n%c } + testdiv := func(c uint64, f func(uint64) (uint64, uint64)) func(*testing.T) { + return func(t *testing.T) { + x := uint64(12345) + for i := 0; i < 10000; i++ { + x += x << 2 + q, r := f(x) + if r < 0 || r >= c || q*c+r != x { + t.Errorf("divmod(%d, %d) returned incorrect (%d, %d)", x, c, q, r) + } + } + max := uint64(1<<64-1) / c * c + xs := []uint64{0, 1, c - 1, c, c + 1, 2*c - 1, 2 * c, 2*c + 1, + c*c - 1, c * c, c*c + 1, max - 1, max, max + 1, 1<<64 - 1} + for _, x := range xs { + q, r := f(x) + if r < 0 || r >= c || q*c+r != x { + t.Errorf("divmod(%d, %d) returned incorrect (%d, %d)", x, c, q, r) + } + } + } + } + t.Run("2", testdiv(2, func(n uint64) (uint64, uint64) { return n / 2, n % 2 })) + t.Run("3", testdiv(3, func(n uint64) (uint64, uint64) { return n / 3, n % 3 })) + t.Run("4", testdiv(4, func(n uint64) (uint64, uint64) { return n / 4, n % 4 })) + t.Run("5", testdiv(5, func(n uint64) (uint64, uint64) { return n / 5, n % 5 })) + t.Run("6", testdiv(6, func(n uint64) (uint64, uint64) { return n / 6, n % 6 })) + t.Run("7", testdiv(7, func(n uint64) (uint64, uint64) { return n / 7, n % 7 })) + t.Run("8", testdiv(8, func(n uint64) (uint64, uint64) { return n / 8, n % 8 })) + t.Run("9", testdiv(9, func(n uint64) (uint64, uint64) { return n / 9, n % 9 })) + t.Run("10", testdiv(10, func(n uint64) (uint64, uint64) { return n / 10, n % 10 })) + t.Run("11", testdiv(11, func(n uint64) (uint64, uint64) { return n / 11, n % 11 })) + t.Run("12", testdiv(12, func(n uint64) (uint64, uint64) { return n / 12, n % 12 })) + t.Run("13", testdiv(13, func(n uint64) (uint64, uint64) { return n / 13, n % 13 })) + t.Run("14", testdiv(14, func(n uint64) (uint64, uint64) { return n / 14, n % 14 })) + t.Run("15", testdiv(15, func(n uint64) (uint64, uint64) { return n / 15, n % 15 })) + t.Run("16", testdiv(16, func(n uint64) (uint64, uint64) { return n / 16, n % 16 })) + t.Run("17", testdiv(17, func(n uint64) (uint64, uint64) { return n / 17, n % 17 })) + t.Run("255", testdiv(255, func(n uint64) (uint64, uint64) { return n / 255, n % 255 })) + t.Run("256", testdiv(256, func(n uint64) (uint64, uint64) { return n / 256, n % 256 })) + t.Run("257", testdiv(257, func(n uint64) (uint64, uint64) { return n / 257, n % 257 })) + t.Run("65535", testdiv(65535, func(n uint64) (uint64, uint64) { return n / 65535, n % 65535 })) + t.Run("65536", testdiv(65536, func(n uint64) (uint64, uint64) { return n / 65536, n % 65536 })) + t.Run("65537", testdiv(65537, func(n uint64) (uint64, uint64) { return n / 65537, n % 65537 })) + t.Run("1<<32-1", testdiv(1<<32-1, func(n uint64) (uint64, uint64) { return n / (1<<32 - 1), n % (1<<32 - 1) })) + t.Run("1<<32+1", testdiv(1<<32+1, func(n uint64) (uint64, uint64) { return n / (1<<32 + 1), n % (1<<32 + 1) })) + t.Run("1<<64-1", testdiv(1<<64-1, func(n uint64) (uint64, uint64) { return n / (1<<64 - 1), n % (1<<64 - 1) })) +} + +func BenchmarkDivconstU64(b *testing.B) { + b.Run("3", func(b *testing.B) { + x := uint64(123456789123456789) + for i := 0; i < b.N; i++ { + x += x << 4 + u64res = x / 3 + } + }) + b.Run("5", func(b *testing.B) { + x := uint64(123456789123456789) + for i := 0; i < b.N; i++ { + x += x << 4 + u64res = x / 5 + } + }) + b.Run("37", func(b *testing.B) { + x := uint64(123456789123456789) + for i := 0; i < b.N; i++ { + x += x << 4 + u64res = x / 37 + } + }) + b.Run("1234567", func(b *testing.B) { + x := uint64(123456789123456789) + for i := 0; i < b.N; i++ { + x += x << 4 + u64res = x / 1234567 + } + }) +} + +func BenchmarkModconstU64(b *testing.B) { + for i := 0; i < b.N; i++ { + u64res = uint64(i) % 7 + } +} + +func BenchmarkDivisibleconstU64(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = uint64(i)%7 == 0 + } +} + +func BenchmarkDivisibleWDivconstU64(b *testing.B) { + for i := 0; i < b.N; i++ { + u64res = uint64(i) / 7 + boolres = uint64(i)%7 == 0 + } +} + +var i32res int32 + +func BenchmarkDivconstI32(b *testing.B) { + for i := 0; i < b.N; i++ { + i32res = int32(i) / 7 + } +} + +func BenchmarkModconstI32(b *testing.B) { + for i := 0; i < b.N; i++ { + i32res = int32(i) % 7 + } +} + +func BenchmarkDivisiblePow2constI32(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = int32(i)%16 == 0 + } +} + +func BenchmarkDivisibleconstI32(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = int32(i)%7 == 0 + } +} + +func BenchmarkDivisibleWDivconstI32(b *testing.B) { + for i := 0; i < b.N; i++ { + i32res = int32(i) / 7 + boolres = int32(i)%7 == 0 + } +} + +var u32res uint32 + +func BenchmarkDivconstU32(b *testing.B) { + for i := 0; i < b.N; i++ { + u32res = uint32(i) / 7 + } +} + +func BenchmarkModconstU32(b *testing.B) { + for i := 0; i < b.N; i++ { + u32res = uint32(i) % 7 + } +} + +func BenchmarkDivisibleconstU32(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = uint32(i)%7 == 0 + } +} + +func BenchmarkDivisibleWDivconstU32(b *testing.B) { + for i := 0; i < b.N; i++ { + u32res = uint32(i) / 7 + boolres = uint32(i)%7 == 0 + } +} + +var i16res int16 + +func BenchmarkDivconstI16(b *testing.B) { + for i := 0; i < b.N; i++ { + i16res = int16(i) / 7 + } +} + +func BenchmarkModconstI16(b *testing.B) { + for i := 0; i < b.N; i++ { + i16res = int16(i) % 7 + } +} + +func BenchmarkDivisiblePow2constI16(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = int16(i)%16 == 0 + } +} + +func BenchmarkDivisibleconstI16(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = int16(i)%7 == 0 + } +} + +func BenchmarkDivisibleWDivconstI16(b *testing.B) { + for i := 0; i < b.N; i++ { + i16res = int16(i) / 7 + boolres = int16(i)%7 == 0 + } +} + +var u16res uint16 + +func BenchmarkDivconstU16(b *testing.B) { + for i := 0; i < b.N; i++ { + u16res = uint16(i) / 7 + } +} + +func BenchmarkModconstU16(b *testing.B) { + for i := 0; i < b.N; i++ { + u16res = uint16(i) % 7 + } +} + +func BenchmarkDivisibleconstU16(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = uint16(i)%7 == 0 + } +} + +func BenchmarkDivisibleWDivconstU16(b *testing.B) { + for i := 0; i < b.N; i++ { + u16res = uint16(i) / 7 + boolres = uint16(i)%7 == 0 + } +} + +var i8res int8 + +func BenchmarkDivconstI8(b *testing.B) { + for i := 0; i < b.N; i++ { + i8res = int8(i) / 7 + } +} + +func BenchmarkModconstI8(b *testing.B) { + for i := 0; i < b.N; i++ { + i8res = int8(i) % 7 + } +} + +func BenchmarkDivisiblePow2constI8(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = int8(i)%16 == 0 + } +} + +func BenchmarkDivisibleconstI8(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = int8(i)%7 == 0 + } +} + +func BenchmarkDivisibleWDivconstI8(b *testing.B) { + for i := 0; i < b.N; i++ { + i8res = int8(i) / 7 + boolres = int8(i)%7 == 0 + } +} + +var u8res uint8 + +func BenchmarkDivconstU8(b *testing.B) { + for i := 0; i < b.N; i++ { + u8res = uint8(i) / 7 + } +} + +func BenchmarkModconstU8(b *testing.B) { + for i := 0; i < b.N; i++ { + u8res = uint8(i) % 7 + } +} + +func BenchmarkDivisibleconstU8(b *testing.B) { + for i := 0; i < b.N; i++ { + boolres = uint8(i)%7 == 0 + } +} + +func BenchmarkDivisibleWDivconstU8(b *testing.B) { + for i := 0; i < b.N; i++ { + u8res = uint8(i) / 7 + boolres = uint8(i)%7 == 0 + } +} diff --git a/go/src/cmd/compile/internal/test/eq_test.go b/go/src/cmd/compile/internal/test/eq_test.go new file mode 100644 index 0000000000000000000000000000000000000000..336ec01e08e065ea069a8bfd660647ee2c165720 --- /dev/null +++ b/go/src/cmd/compile/internal/test/eq_test.go @@ -0,0 +1,298 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Tests of generated equality functions. + +package test + +import ( + "reflect" + "testing" + "unsafe" +) + +//go:noinline +func checkEq(t *testing.T, x, y any) { + // Make sure we don't inline the equality test. + if x != y { + t.Errorf("%#v != %#v, wanted equal", x, y) + } +} + +//go:noinline +func checkNe(t *testing.T, x, y any) { + // Make sure we don't inline the equality test. + if x == y { + t.Errorf("%#v == %#v, wanted not equal", x, y) + } +} + +//go:noinline +func checkPanic(t *testing.T, x, y any) { + defer func() { + if recover() == nil { + t.Errorf("%#v == %#v didn't panic", x, y) + } + }() + _ = x == y +} + +type fooComparable struct { + x int +} + +func (f fooComparable) foo() { +} + +type fooIncomparable struct { + b func() +} + +func (i fooIncomparable) foo() { +} + +type eqResult int + +const ( + eq eqResult = iota + ne + panic_ +) + +func (x eqResult) String() string { + return []string{eq: "eq", ne: "ne", panic_: "panic"}[x] +} + +// testEq returns eq if x==y, ne if x!=y, or panic_ if the comparison panics. +func testEq(x, y any) (r eqResult) { + defer func() { + if e := recover(); e != nil { + r = panic_ + } + }() + r = ne + if x == y { + r = eq + } + return +} + +// testCompare make two instances of struct type typ, then +// assigns its len(vals) fields one value from each slice in vals. +// Then it checks the results against a "manual" comparison field +// by field. +func testCompare(t *testing.T, typ reflect.Type, vals [][]any) { + if len(vals) != typ.NumField() { + t.Fatalf("bad test, have %d fields in the list, but %d fields in the type", len(vals), typ.NumField()) + } + + x := reflect.New(typ).Elem() + y := reflect.New(typ).Elem() + ps := powerSet(vals) // all possible settings of fields of the test type. + for _, xf := range ps { // Pick fields for x + for _, yf := range ps { // Pick fields for y + // Make x and y from their chosen fields. + for i, f := range xf { + x.Field(i).Set(reflect.ValueOf(f)) + } + for i, f := range yf { + y.Field(i).Set(reflect.ValueOf(f)) + } + // Compute what we want the result to be. + want := eq + for i := range len(vals) { + if c := testEq(xf[i], yf[i]); c != eq { + want = c + break + } + } + // Compute actual result using generated equality function. + got := testEq(x.Interface(), y.Interface()) + if got != want { + t.Errorf("%#v == %#v, got %s want %s\n", x, y, got, want) + } + } + } +} + +// powerset returns all possible sequences of choosing one +// element from each entry in s. +// For instance, if s = {{1,2}, {a,b}}, then +// it returns {{1,a},{1,b},{2,a},{2,b}}. +func powerSet(s [][]any) [][]any { + if len(s) == 0 { + return [][]any{{}} + } + p := powerSet(s[:len(s)-1]) // powerset from first len(s)-1 entries + var r [][]any + for _, head := range p { + // add one more entry. + for _, v := range s[len(s)-1] { + x := make([]any, 0, len(s)) + x = append(x, head...) + x = append(x, v) + r = append(r, x) + } + } + return r +} + +func TestCompareKinds1(t *testing.T) { + type S struct { + X0 int8 + X1 int16 + X2 int32 + X3 int64 + X4 float32 + X5 float64 + } + testCompare(t, reflect.TypeOf(S{}), [][]any{ + {int8(0), int8(1)}, + {int16(0), int16(1), int16(1 << 14)}, + {int32(0), int32(1), int32(1 << 30)}, + {int64(0), int64(1), int64(1 << 62)}, + {float32(0), float32(1.0)}, + {0.0, 1.0}, + }) +} +func TestCompareKinds2(t *testing.T) { + type S struct { + X0 uint8 + X1 uint16 + X2 uint32 + X3 uint64 + X4 uintptr + X5 bool + } + testCompare(t, reflect.TypeOf(S{}), [][]any{ + {uint8(0), uint8(1)}, + {uint16(0), uint16(1), uint16(1 << 15)}, + {uint32(0), uint32(1), uint32(1 << 31)}, + {uint64(0), uint64(1), uint64(1 << 63)}, + {uintptr(0), uintptr(1)}, + {false, true}, + }) +} +func TestCompareKinds3(t *testing.T) { + type S struct { + X0 complex64 + X1 complex128 + X2 *byte + X3 chan int + X4 unsafe.Pointer + } + testCompare(t, reflect.TypeOf(S{}), [][]any{ + {complex64(1 + 1i), complex64(1 + 2i), complex64(2 + 1i)}, + {complex128(1 + 1i), complex128(1 + 2i), complex128(2 + 1i)}, + {new(byte), new(byte)}, + {make(chan int), make(chan int)}, + {unsafe.Pointer(new(byte)), unsafe.Pointer(new(byte))}, + }) +} + +func TestCompareOrdering(t *testing.T) { + type S struct { + A string + E any + B string + } + + testCompare(t, reflect.TypeOf(S{}), [][]any{ + {"a", "b", "cc"}, + {3, []byte{0}, []byte{1}}, + {"a", "b", "cc"}, + }) +} +func TestCompareInterfaces(t *testing.T) { + type S struct { + A any + B fooer + } + testCompare(t, reflect.TypeOf(S{}), [][]any{ + {3, []byte{0}}, + {fooComparable{x: 3}, fooIncomparable{b: nil}}, + }) +} + +func TestCompareSkip(t *testing.T) { + type S struct { + A int8 + B int16 + } + type S2 struct { + A int8 + padding int8 + B int16 + } + x := S{A: 1, B: 3} + y := S{A: 1, B: 3} + (*S2)(unsafe.Pointer(&x)).padding = 88 + (*S2)(unsafe.Pointer(&y)).padding = 99 + + want := eq + if got := testEq(x, y); got != want { + t.Errorf("%#v == %#v, got %s want %s", x, y, got, want) + } +} + +func TestCompareMemequal(t *testing.T) { + type S struct { + s1 string + d [100]byte + s2 string + } + var x, y S + + checkEq(t, x, y) + y.d[0] = 1 + checkNe(t, x, y) + y.d[0] = 0 + y.d[99] = 1 + checkNe(t, x, y) +} + +func TestComparePanic(t *testing.T) { + type S struct { + X0 string + X1 any + X2 string + X3 fooer + X4 string + } + testCompare(t, reflect.TypeOf(S{}), [][]any{ + {"a", "b", "cc"}, // length equal, as well as length unequal + {3, []byte{1}}, // comparable and incomparable + {"a", "b", "cc"}, // length equal, as well as length unequal + {fooComparable{x: 3}, fooIncomparable{b: nil}}, // comparable and incomparable + {"a", "b", "cc"}, // length equal, as well as length unequal + }) +} + +func TestCompareArray(t *testing.T) { + type S struct { + X0 string + X1 [100]string + X2 string + } + x := S{X0: "a", X2: "b"} + y := x + checkEq(t, x, y) + x.X0 = "c" + checkNe(t, x, y) + x.X0 = "a" + x.X2 = "c" + checkNe(t, x, y) + x.X2 = "b" + checkEq(t, x, y) + + for i := 0; i < 100; i++ { + x.X1[i] = "d" + checkNe(t, x, y) + y.X1[i] = "e" + checkNe(t, x, y) + x.X1[i] = "" + y.X1[i] = "" + checkEq(t, x, y) + } +} diff --git a/go/src/cmd/compile/internal/test/fixedbugs_test.go b/go/src/cmd/compile/internal/test/fixedbugs_test.go new file mode 100644 index 0000000000000000000000000000000000000000..49d4fbb4157d8cebd3592d1614e66fb4f61fb574 --- /dev/null +++ b/go/src/cmd/compile/internal/test/fixedbugs_test.go @@ -0,0 +1,132 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "bytes" + "internal/platform" + "internal/testenv" + "os" + "path/filepath" + "runtime" + "strings" + "testing" +) + +type T struct { + x [2]int64 // field that will be clobbered. Also makes type not SSAable. + p *byte // has a pointer +} + +//go:noinline +func makeT() T { + return T{} +} + +var g T + +var sink any + +func TestIssue15854(t *testing.T) { + for i := 0; i < 10000; i++ { + if g.x[0] != 0 { + t.Fatalf("g.x[0] clobbered with %x\n", g.x[0]) + } + // The bug was in the following assignment. The return + // value of makeT() is not copied out of the args area of + // stack frame in a timely fashion. So when write barriers + // are enabled, the marshaling of the args for the write + // barrier call clobbers the result of makeT() before it is + // read by the write barrier code. + g = makeT() + sink = make([]byte, 1000) // force write barriers to eventually happen + } +} +func TestIssue15854b(t *testing.T) { + const N = 10000 + a := make([]T, N) + for i := 0; i < N; i++ { + a = append(a, makeT()) + sink = make([]byte, 1000) // force write barriers to eventually happen + } + for i, v := range a { + if v.x[0] != 0 { + t.Fatalf("a[%d].x[0] clobbered with %x\n", i, v.x[0]) + } + } +} + +// Test that the generated assembly has line numbers (Issue #16214). +func TestIssue16214(t *testing.T) { + testenv.MustHaveGoBuild(t) + dir := t.TempDir() + + src := filepath.Join(dir, "x.go") + err := os.WriteFile(src, []byte(issue16214src), 0644) + if err != nil { + t.Fatalf("could not write file: %v", err) + } + + cmd := testenv.Command(t, testenv.GoToolPath(t), "tool", "compile", "-p=main", "-S", "-o", filepath.Join(dir, "out.o"), src) + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("go tool compile: %v\n%s", err, out) + } + + if strings.Contains(string(out), "unknown line number") { + t.Errorf("line number missing in assembly:\n%s", out) + } +} + +var issue16214src = ` +package main + +func Mod32(x uint32) uint32 { + return x % 3 // frontend rewrites it as HMUL with 2863311531, the LITERAL node has unknown Pos +} +` + +// Test that building and running a program with -race -gcflags='all=-N -l' +// does not crash. This is a regression test for #77597 where generic functions +// from NoRaceFunc packages (like internal/runtime/atomic) were incorrectly +// getting racefuncenter/racefuncexit instrumentation when instantiated in +// other packages with optimizations disabled. +func TestIssue77597(t *testing.T) { + if !platform.RaceDetectorSupported(runtime.GOOS, runtime.GOARCH) { + t.Skipf("race detector not supported on %s/%s", runtime.GOOS, runtime.GOARCH) + } + testenv.MustHaveGoBuild(t) + testenv.MustHaveGoRun(t) + testenv.MustHaveCGO(t) + + dir := t.TempDir() + src := filepath.Join(dir, "main.go") + err := os.WriteFile(src, []byte(issue77597src), 0644) + if err != nil { + t.Fatalf("could not write file: %v", err) + } + + cmd := testenv.Command(t, testenv.GoToolPath(t), "run", "-race", "-gcflags=all=-N -l", src) + out, err := cmd.CombinedOutput() + if err != nil { + // For details, please refer to CL 160919. + unsupportedVMA := []byte("unsupported VMA range") + if bytes.Contains(out, unsupportedVMA) { + t.Skipf("skipped due to unsupported VMA on %s/%s", runtime.GOOS, runtime.GOARCH) + } else { + t.Fatalf("program failed: %v\n%s", err, out) + } + } +} + +var issue77597src = ` +package main + +import "fmt" + +func main() { + fmt.Println("OK") +} +` diff --git a/go/src/cmd/compile/internal/test/float_test.go b/go/src/cmd/compile/internal/test/float_test.go new file mode 100644 index 0000000000000000000000000000000000000000..00735e3cb11162cd9c822b94aa2816eba01fd810 --- /dev/null +++ b/go/src/cmd/compile/internal/test/float_test.go @@ -0,0 +1,808 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "math" + "testing" +) + +//go:noinline +func compare1(a, b float64) bool { + return a < b +} + +//go:noinline +func compare2(a, b float32) bool { + return a < b +} + +func TestFloatCompare(t *testing.T) { + if !compare1(3, 5) { + t.Errorf("compare1 returned false") + } + if !compare2(3, 5) { + t.Errorf("compare2 returned false") + } +} + +func TestFloatCompareFolded(t *testing.T) { + // float64 comparisons + d1, d3, d5, d9 := float64(1), float64(3), float64(5), float64(9) + if d3 == d5 { + t.Errorf("d3 == d5 returned true") + } + if d3 != d3 { + t.Errorf("d3 != d3 returned true") + } + if d3 > d5 { + t.Errorf("d3 > d5 returned true") + } + if d3 >= d9 { + t.Errorf("d3 >= d9 returned true") + } + if d5 < d1 { + t.Errorf("d5 < d1 returned true") + } + if d9 <= d1 { + t.Errorf("d9 <= d1 returned true") + } + if math.NaN() == math.NaN() { + t.Errorf("math.NaN() == math.NaN() returned true") + } + if math.NaN() >= math.NaN() { + t.Errorf("math.NaN() >= math.NaN() returned true") + } + if math.NaN() <= math.NaN() { + t.Errorf("math.NaN() <= math.NaN() returned true") + } + if math.Copysign(math.NaN(), -1) < math.NaN() { + t.Errorf("math.Copysign(math.NaN(), -1) < math.NaN() returned true") + } + if math.Inf(1) != math.Inf(1) { + t.Errorf("math.Inf(1) != math.Inf(1) returned true") + } + if math.Inf(-1) != math.Inf(-1) { + t.Errorf("math.Inf(-1) != math.Inf(-1) returned true") + } + if math.Copysign(0, -1) != 0 { + t.Errorf("math.Copysign(0, -1) != 0 returned true") + } + if math.Copysign(0, -1) < 0 { + t.Errorf("math.Copysign(0, -1) < 0 returned true") + } + if 0 > math.Copysign(0, -1) { + t.Errorf("0 > math.Copysign(0, -1) returned true") + } + + // float32 comparisons + s1, s3, s5, s9 := float32(1), float32(3), float32(5), float32(9) + if s3 == s5 { + t.Errorf("s3 == s5 returned true") + } + if s3 != s3 { + t.Errorf("s3 != s3 returned true") + } + if s3 > s5 { + t.Errorf("s3 > s5 returned true") + } + if s3 >= s9 { + t.Errorf("s3 >= s9 returned true") + } + if s5 < s1 { + t.Errorf("s5 < s1 returned true") + } + if s9 <= s1 { + t.Errorf("s9 <= s1 returned true") + } + sPosNaN, sNegNaN := float32(math.NaN()), float32(math.Copysign(math.NaN(), -1)) + if sPosNaN == sPosNaN { + t.Errorf("sPosNaN == sPosNaN returned true") + } + if sPosNaN >= sPosNaN { + t.Errorf("sPosNaN >= sPosNaN returned true") + } + if sPosNaN <= sPosNaN { + t.Errorf("sPosNaN <= sPosNaN returned true") + } + if sNegNaN < sPosNaN { + t.Errorf("sNegNaN < sPosNaN returned true") + } + sPosInf, sNegInf := float32(math.Inf(1)), float32(math.Inf(-1)) + if sPosInf != sPosInf { + t.Errorf("sPosInf != sPosInf returned true") + } + if sNegInf != sNegInf { + t.Errorf("sNegInf != sNegInf returned true") + } + sNegZero := float32(math.Copysign(0, -1)) + if sNegZero != 0 { + t.Errorf("sNegZero != 0 returned true") + } + if sNegZero < 0 { + t.Errorf("sNegZero < 0 returned true") + } + if 0 > sNegZero { + t.Errorf("0 > sNegZero returned true") + } +} + +//go:noinline +func cvt1(a float64) uint64 { + return uint64(a) +} + +//go:noinline +func cvt2(a float64) uint32 { + return uint32(a) +} + +//go:noinline +func cvt3(a float32) uint64 { + return uint64(a) +} + +//go:noinline +func cvt4(a float32) uint32 { + return uint32(a) +} + +//go:noinline +func cvt5(a float64) int64 { + return int64(a) +} + +//go:noinline +func cvt6(a float64) int32 { + return int32(a) +} + +//go:noinline +func cvt7(a float32) int64 { + return int64(a) +} + +//go:noinline +func cvt8(a float32) int32 { + return int32(a) +} + +// make sure to cover int, uint cases (issue #16738) +// +//go:noinline +func cvt9(a float64) int { + return int(a) +} + +//go:noinline +func cvt10(a float64) uint { + return uint(a) +} + +//go:noinline +func cvt11(a float32) int { + return int(a) +} + +//go:noinline +func cvt12(a float32) uint { + return uint(a) +} + +//go:noinline +func f2i64p(v float64) *int64 { + return ip64(int64(v / 0.1)) +} + +//go:noinline +func ip64(v int64) *int64 { + return &v +} + +func TestFloatConvert(t *testing.T) { + if got := cvt1(3.5); got != 3 { + t.Errorf("cvt1 got %d, wanted 3", got) + } + if got := cvt2(3.5); got != 3 { + t.Errorf("cvt2 got %d, wanted 3", got) + } + if got := cvt3(3.5); got != 3 { + t.Errorf("cvt3 got %d, wanted 3", got) + } + if got := cvt4(3.5); got != 3 { + t.Errorf("cvt4 got %d, wanted 3", got) + } + if got := cvt5(3.5); got != 3 { + t.Errorf("cvt5 got %d, wanted 3", got) + } + if got := cvt6(3.5); got != 3 { + t.Errorf("cvt6 got %d, wanted 3", got) + } + if got := cvt7(3.5); got != 3 { + t.Errorf("cvt7 got %d, wanted 3", got) + } + if got := cvt8(3.5); got != 3 { + t.Errorf("cvt8 got %d, wanted 3", got) + } + if got := cvt9(3.5); got != 3 { + t.Errorf("cvt9 got %d, wanted 3", got) + } + if got := cvt10(3.5); got != 3 { + t.Errorf("cvt10 got %d, wanted 3", got) + } + if got := cvt11(3.5); got != 3 { + t.Errorf("cvt11 got %d, wanted 3", got) + } + if got := cvt12(3.5); got != 3 { + t.Errorf("cvt12 got %d, wanted 3", got) + } + if got := *f2i64p(10); got != 100 { + t.Errorf("f2i64p got %d, wanted 100", got) + } +} + +func TestFloatConvertFolded(t *testing.T) { + // Assign constants to variables so that they are (hopefully) constant folded + // by the SSA backend rather than the frontend. + u64, u32, u16, u8 := uint64(1<<63), uint32(1<<31), uint16(1<<15), uint8(1<<7) + i64, i32, i16, i8 := int64(-1<<63), int32(-1<<31), int16(-1<<15), int8(-1<<7) + du64, du32, du16, du8 := float64(1<<63), float64(1<<31), float64(1<<15), float64(1<<7) + di64, di32, di16, di8 := float64(-1<<63), float64(-1<<31), float64(-1<<15), float64(-1<<7) + su64, su32, su16, su8 := float32(1<<63), float32(1<<31), float32(1<<15), float32(1<<7) + si64, si32, si16, si8 := float32(-1<<63), float32(-1<<31), float32(-1<<15), float32(-1<<7) + + // integer to float + if float64(u64) != du64 { + t.Errorf("float64(u64) != du64") + } + if float64(u32) != du32 { + t.Errorf("float64(u32) != du32") + } + if float64(u16) != du16 { + t.Errorf("float64(u16) != du16") + } + if float64(u8) != du8 { + t.Errorf("float64(u8) != du8") + } + if float64(i64) != di64 { + t.Errorf("float64(i64) != di64") + } + if float64(i32) != di32 { + t.Errorf("float64(i32) != di32") + } + if float64(i16) != di16 { + t.Errorf("float64(i16) != di16") + } + if float64(i8) != di8 { + t.Errorf("float64(i8) != di8") + } + if float32(u64) != su64 { + t.Errorf("float32(u64) != su64") + } + if float32(u32) != su32 { + t.Errorf("float32(u32) != su32") + } + if float32(u16) != su16 { + t.Errorf("float32(u16) != su16") + } + if float32(u8) != su8 { + t.Errorf("float32(u8) != su8") + } + if float32(i64) != si64 { + t.Errorf("float32(i64) != si64") + } + if float32(i32) != si32 { + t.Errorf("float32(i32) != si32") + } + if float32(i16) != si16 { + t.Errorf("float32(i16) != si16") + } + if float32(i8) != si8 { + t.Errorf("float32(i8) != si8") + } + + // float to integer + if uint64(du64) != u64 { + t.Errorf("uint64(du64) != u64") + } + if uint32(du32) != u32 { + t.Errorf("uint32(du32) != u32") + } + if uint16(du16) != u16 { + t.Errorf("uint16(du16) != u16") + } + if uint8(du8) != u8 { + t.Errorf("uint8(du8) != u8") + } + if int64(di64) != i64 { + t.Errorf("int64(di64) != i64") + } + if int32(di32) != i32 { + t.Errorf("int32(di32) != i32") + } + if int16(di16) != i16 { + t.Errorf("int16(di16) != i16") + } + if int8(di8) != i8 { + t.Errorf("int8(di8) != i8") + } + if uint64(su64) != u64 { + t.Errorf("uint64(su64) != u64") + } + if uint32(su32) != u32 { + t.Errorf("uint32(su32) != u32") + } + if uint16(su16) != u16 { + t.Errorf("uint16(su16) != u16") + } + if uint8(su8) != u8 { + t.Errorf("uint8(su8) != u8") + } + if int64(si64) != i64 { + t.Errorf("int64(si64) != i64") + } + if int32(si32) != i32 { + t.Errorf("int32(si32) != i32") + } + if int16(si16) != i16 { + t.Errorf("int16(si16) != i16") + } + if int8(si8) != i8 { + t.Errorf("int8(si8) != i8") + } +} + +func TestFloat32StoreToLoadConstantFold(t *testing.T) { + // Test that math.Float32{,from}bits constant fold correctly. + // In particular we need to be careful that signaling NaN (sNaN) values + // are not converted to quiet NaN (qNaN) values during compilation. + // See issue #27193 for more information. + + // signaling NaNs + { + const nan = uint32(0x7f800001) // sNaN + if x := math.Float32bits(math.Float32frombits(nan)); x != nan { + t.Errorf("got %#x, want %#x", x, nan) + } + } + { + const nan = uint32(0x7fbfffff) // sNaN + if x := math.Float32bits(math.Float32frombits(nan)); x != nan { + t.Errorf("got %#x, want %#x", x, nan) + } + } + { + const nan = uint32(0xff800001) // sNaN + if x := math.Float32bits(math.Float32frombits(nan)); x != nan { + t.Errorf("got %#x, want %#x", x, nan) + } + } + { + const nan = uint32(0xffbfffff) // sNaN + if x := math.Float32bits(math.Float32frombits(nan)); x != nan { + t.Errorf("got %#x, want %#x", x, nan) + } + } + + // quiet NaNs + { + const nan = uint32(0x7fc00000) // qNaN + if x := math.Float32bits(math.Float32frombits(nan)); x != nan { + t.Errorf("got %#x, want %#x", x, nan) + } + } + { + const nan = uint32(0x7fffffff) // qNaN + if x := math.Float32bits(math.Float32frombits(nan)); x != nan { + t.Errorf("got %#x, want %#x", x, nan) + } + } + { + const nan = uint32(0x8fc00000) // qNaN + if x := math.Float32bits(math.Float32frombits(nan)); x != nan { + t.Errorf("got %#x, want %#x", x, nan) + } + } + { + const nan = uint32(0x8fffffff) // qNaN + if x := math.Float32bits(math.Float32frombits(nan)); x != nan { + t.Errorf("got %#x, want %#x", x, nan) + } + } + + // infinities + { + const inf = uint32(0x7f800000) // +∞ + if x := math.Float32bits(math.Float32frombits(inf)); x != inf { + t.Errorf("got %#x, want %#x", x, inf) + } + } + { + const negInf = uint32(0xff800000) // -∞ + if x := math.Float32bits(math.Float32frombits(negInf)); x != negInf { + t.Errorf("got %#x, want %#x", x, negInf) + } + } + + // numbers + { + const zero = uint32(0) // +0.0 + if x := math.Float32bits(math.Float32frombits(zero)); x != zero { + t.Errorf("got %#x, want %#x", x, zero) + } + } + { + const negZero = uint32(1 << 31) // -0.0 + if x := math.Float32bits(math.Float32frombits(negZero)); x != negZero { + t.Errorf("got %#x, want %#x", x, negZero) + } + } + { + const one = uint32(0x3f800000) // 1.0 + if x := math.Float32bits(math.Float32frombits(one)); x != one { + t.Errorf("got %#x, want %#x", x, one) + } + } + { + const negOne = uint32(0xbf800000) // -1.0 + if x := math.Float32bits(math.Float32frombits(negOne)); x != negOne { + t.Errorf("got %#x, want %#x", x, negOne) + } + } + { + const frac = uint32(0x3fc00000) // +1.5 + if x := math.Float32bits(math.Float32frombits(frac)); x != frac { + t.Errorf("got %#x, want %#x", x, frac) + } + } + { + const negFrac = uint32(0xbfc00000) // -1.5 + if x := math.Float32bits(math.Float32frombits(negFrac)); x != negFrac { + t.Errorf("got %#x, want %#x", x, negFrac) + } + } +} + +// Signaling NaN values as constants. +const ( + snan32bits uint32 = 0x7f800001 + snan64bits uint64 = 0x7ff0000000000001 +) + +// Signaling NaNs as variables. +var snan32bitsVar uint32 = snan32bits +var snan64bitsVar uint64 = snan64bits + +func TestFloatSignalingNaN(t *testing.T) { + // Make sure we generate a signaling NaN from a constant properly. + // See issue 36400. + f32 := math.Float32frombits(snan32bits) + g32 := math.Float32frombits(snan32bitsVar) + x32 := math.Float32bits(f32) + y32 := math.Float32bits(g32) + if x32 != y32 { + t.Errorf("got %x, want %x (diff=%x)", x32, y32, x32^y32) + } + + f64 := math.Float64frombits(snan64bits) + g64 := math.Float64frombits(snan64bitsVar) + x64 := math.Float64bits(f64) + y64 := math.Float64bits(g64) + if x64 != y64 { + t.Errorf("got %x, want %x (diff=%x)", x64, y64, x64^y64) + } +} + +func TestFloatSignalingNaNConversion(t *testing.T) { + // Test to make sure when we convert a signaling NaN, we get a NaN. + // (Ideally we want a quiet NaN, but some platforms don't agree.) + // See issue 36399. + s32 := math.Float32frombits(snan32bitsVar) + if s32 == s32 { + t.Errorf("converting a NaN did not result in a NaN") + } + s64 := math.Float64frombits(snan64bitsVar) + if s64 == s64 { + t.Errorf("converting a NaN did not result in a NaN") + } +} + +func TestFloatSignalingNaNConversionConst(t *testing.T) { + // Test to make sure when we convert a signaling NaN, it converts to a NaN. + // (Ideally we want a quiet NaN, but some platforms don't agree.) + // See issue 36399 and 36400. + s32 := math.Float32frombits(snan32bits) + if s32 == s32 { + t.Errorf("converting a NaN did not result in a NaN") + } + s64 := math.Float64frombits(snan64bits) + if s64 == s64 { + t.Errorf("converting a NaN did not result in a NaN") + } +} + +//go:noinline +func isPosInf(x float64) bool { + return math.IsInf(x, 1) +} + +//go:noinline +func isPosInfEq(x float64) bool { + return x == math.Inf(1) +} + +//go:noinline +func isPosInfCmp(x float64) bool { + return x > math.MaxFloat64 +} + +//go:noinline +func isNotPosInf(x float64) bool { + return !math.IsInf(x, 1) +} + +//go:noinline +func isNotPosInfEq(x float64) bool { + return x != math.Inf(1) +} + +//go:noinline +func isNotPosInfCmp(x float64) bool { + return x <= math.MaxFloat64 +} + +//go:noinline +func isNegInf(x float64) bool { + return math.IsInf(x, -1) +} + +//go:noinline +func isNegInfEq(x float64) bool { + return x == math.Inf(-1) +} + +//go:noinline +func isNegInfCmp(x float64) bool { + return x < -math.MaxFloat64 +} + +//go:noinline +func isNotNegInf(x float64) bool { + return !math.IsInf(x, -1) +} + +//go:noinline +func isNotNegInfEq(x float64) bool { + return x != math.Inf(-1) +} + +//go:noinline +func isNotNegInfCmp(x float64) bool { + return x >= -math.MaxFloat64 +} + +func TestInf(t *testing.T) { + tests := []struct { + value float64 + isPosInf bool + isNegInf bool + isNaN bool + }{ + {value: math.Inf(1), isPosInf: true}, + {value: math.MaxFloat64}, + {value: math.Inf(-1), isNegInf: true}, + {value: -math.MaxFloat64}, + {value: math.NaN(), isNaN: true}, + } + + check := func(name string, f func(x float64) bool, value float64, want bool) { + got := f(value) + if got != want { + t.Errorf("%v(%g): want %v, got %v", name, value, want, got) + } + } + + for _, test := range tests { + check("isPosInf", isPosInf, test.value, test.isPosInf) + check("isPosInfEq", isPosInfEq, test.value, test.isPosInf) + check("isPosInfCmp", isPosInfCmp, test.value, test.isPosInf) + + check("isNotPosInf", isNotPosInf, test.value, !test.isPosInf) + check("isNotPosInfEq", isNotPosInfEq, test.value, !test.isPosInf) + check("isNotPosInfCmp", isNotPosInfCmp, test.value, !test.isPosInf && !test.isNaN) + + check("isNegInf", isNegInf, test.value, test.isNegInf) + check("isNegInfEq", isNegInfEq, test.value, test.isNegInf) + check("isNegInfCmp", isNegInfCmp, test.value, test.isNegInf) + + check("isNotNegInf", isNotNegInf, test.value, !test.isNegInf) + check("isNotNegInfEq", isNotNegInfEq, test.value, !test.isNegInf) + check("isNotNegInfCmp", isNotNegInfCmp, test.value, !test.isNegInf && !test.isNaN) + } +} + +//go:noinline +func isNaNOrGtZero64(x float64) bool { + return math.IsNaN(x) || x > 0 +} + +//go:noinline +func isNaNOrGteZero64(x float64) bool { + return x >= 0 || math.IsNaN(x) +} + +//go:noinline +func isNaNOrLtZero64(x float64) bool { + return x < 0 || math.IsNaN(x) +} + +//go:noinline +func isNaNOrLteZero64(x float64) bool { + return math.IsNaN(x) || x <= 0 +} + +func TestFusedNaNChecks64(t *testing.T) { + tests := []struct { + value float64 + isZero bool + isGreaterThanZero bool + isLessThanZero bool + isNaN bool + }{ + {value: 0.0, isZero: true}, + {value: math.Copysign(0, -1), isZero: true}, + {value: 1.0, isGreaterThanZero: true}, + {value: -1.0, isLessThanZero: true}, + {value: math.Inf(1), isGreaterThanZero: true}, + {value: math.Inf(-1), isLessThanZero: true}, + {value: math.NaN(), isNaN: true}, + } + + check := func(name string, f func(x float64) bool, value float64, want bool) { + got := f(value) + if got != want { + t.Errorf("%v(%g): want %v, got %v", name, value, want, got) + } + } + + for _, test := range tests { + check("isNaNOrGtZero64", isNaNOrGtZero64, test.value, test.isNaN || test.isGreaterThanZero) + check("isNaNOrGteZero64", isNaNOrGteZero64, test.value, test.isNaN || test.isGreaterThanZero || test.isZero) + check("isNaNOrLtZero64", isNaNOrLtZero64, test.value, test.isNaN || test.isLessThanZero) + check("isNaNOrLteZero64", isNaNOrLteZero64, test.value, test.isNaN || test.isLessThanZero || test.isZero) + } +} + +//go:noinline +func isNaNOrGtZero32(x float32) bool { + return x > 0 || x != x +} + +//go:noinline +func isNaNOrGteZero32(x float32) bool { + return x != x || x >= 0 +} + +//go:noinline +func isNaNOrLtZero32(x float32) bool { + return x != x || x < 0 +} + +//go:noinline +func isNaNOrLteZero32(x float32) bool { + return x <= 0 || x != x +} + +func TestFusedNaNChecks32(t *testing.T) { + tests := []struct { + value float32 + isZero bool + isGreaterThanZero bool + isLessThanZero bool + isNaN bool + }{ + {value: 0.0, isZero: true}, + {value: float32(math.Copysign(0, -1)), isZero: true}, + {value: 1.0, isGreaterThanZero: true}, + {value: -1.0, isLessThanZero: true}, + {value: float32(math.Inf(1)), isGreaterThanZero: true}, + {value: float32(math.Inf(-1)), isLessThanZero: true}, + {value: float32(math.NaN()), isNaN: true}, + } + + check := func(name string, f func(x float32) bool, value float32, want bool) { + got := f(value) + if got != want { + t.Errorf("%v(%g): want %v, got %v", name, value, want, got) + } + } + + for _, test := range tests { + check("isNaNOrGtZero32", isNaNOrGtZero32, test.value, test.isNaN || test.isGreaterThanZero) + check("isNaNOrGteZero32", isNaNOrGteZero32, test.value, test.isNaN || test.isGreaterThanZero || test.isZero) + check("isNaNOrLtZero32", isNaNOrLtZero32, test.value, test.isNaN || test.isLessThanZero) + check("isNaNOrLteZero32", isNaNOrLteZero32, test.value, test.isNaN || test.isLessThanZero || test.isZero) + } +} + +// minNormal64 is the smallest float64 value that is not subnormal. +const minNormal64 = 2.2250738585072014e-308 + +//go:noinline +func isAbsLessThanMinNormal64(x float64) bool { + return math.Abs(x) < minNormal64 +} + +//go:noinline +func isLessThanMinNormal64(x float64) bool { + return x < minNormal64 +} + +//go:noinline +func isGreaterThanNegMinNormal64(x float64) bool { + return x > -minNormal64 +} + +//go:noinline +func isGreaterThanOrEqualToMinNormal64(x float64) bool { + return math.Abs(x) >= minNormal64 +} + +func TestSubnormalComparisons(t *testing.T) { + tests := []struct { + value float64 + isAbsLessThanMinNormal bool + isPositive bool + isNegative bool + isNaN bool + }{ + {value: math.Inf(1), isPositive: true}, + {value: math.MaxFloat64, isPositive: true}, + {value: math.Inf(-1), isNegative: true}, + {value: -math.MaxFloat64, isNegative: true}, + {value: math.NaN(), isNaN: true}, + {value: minNormal64, isPositive: true}, + {value: minNormal64 / 2, isAbsLessThanMinNormal: true, isPositive: true}, + {value: -minNormal64, isNegative: true}, + {value: -minNormal64 / 2, isAbsLessThanMinNormal: true, isNegative: true}, + {value: 0, isAbsLessThanMinNormal: true, isPositive: true}, + {value: math.Copysign(0, -1), isAbsLessThanMinNormal: true, isNegative: true}, + } + + check := func(name string, f func(x float64) bool, value float64, want bool) { + got := f(value) + if got != want { + t.Errorf("%v(%g): want %v, got %v", name, value, want, got) + } + } + + for _, test := range tests { + check("isAbsLessThanMinNormal64", isAbsLessThanMinNormal64, test.value, test.isAbsLessThanMinNormal) + check("isLessThanMinNormal64", isLessThanMinNormal64, test.value, test.isAbsLessThanMinNormal || test.isNegative) + check("isGreaterThanNegMinNormal64", isGreaterThanNegMinNormal64, test.value, test.isAbsLessThanMinNormal || test.isPositive) + check("isGreaterThanOrEqualToMinNormal64", isGreaterThanOrEqualToMinNormal64, test.value, !test.isAbsLessThanMinNormal && !test.isNaN) + } +} + +var sinkFloat float64 + +func BenchmarkMul2(b *testing.B) { + for i := 0; i < b.N; i++ { + var m float64 = 1 + for j := 0; j < 500; j++ { + m *= 2 + } + sinkFloat = m + } +} +func BenchmarkMulNeg2(b *testing.B) { + for i := 0; i < b.N; i++ { + var m float64 = 1 + for j := 0; j < 500; j++ { + m *= -2 + } + sinkFloat = m + } +} diff --git a/go/src/cmd/compile/internal/test/free_test.go b/go/src/cmd/compile/internal/test/free_test.go new file mode 100644 index 0000000000000000000000000000000000000000..061cc9a6e4e3ac767619825ef50ff8cfcf17033e --- /dev/null +++ b/go/src/cmd/compile/internal/test/free_test.go @@ -0,0 +1,55 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "internal/asan" + "internal/goexperiment" + "internal/msan" + "internal/race" + "testing" +) + +func TestFreeAppendAllocations(t *testing.T) { + t.Run("slice-no-alias", func(t *testing.T) { + if !goexperiment.RuntimeFreegc { + t.Skip("skipping allocation test when runtime.freegc is disabled") + } + if race.Enabled || msan.Enabled || asan.Enabled { + // TODO(thepudds): we get 8 allocs for slice-no-alias instead of 1 with -race. This + // might be expected given some allocation optimizations are already disabled + // under race, but if not, we might need to update walk. + t.Skip("skipping allocation test under race detector and other sanitizers") + } + + allocs := testing.AllocsPerRun(100, func() { + var s []int64 + for i := range 100 { + s = append(s, int64(i)) + } + _ = s + }) + t.Logf("allocs: %v", allocs) + if allocs != 1 { + t.Errorf("allocs: %v, want 1", allocs) + } + }) + + t.Run("slice-aliased", func(t *testing.T) { + allocs := testing.AllocsPerRun(100, func() { + var s []int64 + var alias []int64 + for i := range 100 { + s = append(s, int64(i)) + alias = s + } + _ = alias + }) + t.Logf("allocs: %v", allocs) + if allocs < 2 { + t.Errorf("allocs: %v, want >= 2", allocs) + } + }) +} diff --git a/go/src/cmd/compile/internal/test/global_test.go b/go/src/cmd/compile/internal/test/global_test.go new file mode 100644 index 0000000000000000000000000000000000000000..c8b3370e9c6cb293b573f4171062fee524a9a75b --- /dev/null +++ b/go/src/cmd/compile/internal/test/global_test.go @@ -0,0 +1,106 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "bytes" + "internal/testenv" + "os" + "path/filepath" + "strings" + "testing" +) + +// Make sure "hello world" does not link in all the +// fmt.scanf routines. See issue 6853. +func TestScanfRemoval(t *testing.T) { + testenv.MustHaveGoBuild(t) + t.Parallel() + + // Make a directory to work in. + dir := t.TempDir() + + // Create source. + src := filepath.Join(dir, "test.go") + f, err := os.Create(src) + if err != nil { + t.Fatalf("could not create source file: %v", err) + } + f.Write([]byte(` +package main +import "fmt" +func main() { + fmt.Println("hello world") +} +`)) + f.Close() + + // Name of destination. + dst := filepath.Join(dir, "test") + + // Compile source. + cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-o", dst, src) + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("could not build target: %v\n%s", err, out) + } + + // Check destination to see if scanf code was included. + cmd = testenv.Command(t, testenv.GoToolPath(t), "tool", "nm", dst) + out, err = cmd.CombinedOutput() + if err != nil { + t.Fatalf("could not read target: %v", err) + } + if bytes.Contains(out, []byte("scanInt")) { + t.Fatalf("scanf code not removed from helloworld") + } +} + +// Make sure -S prints assembly code. See issue 14515. +func TestDashS(t *testing.T) { + testenv.MustHaveGoBuild(t) + t.Parallel() + + // Make a directory to work in. + dir := t.TempDir() + + // Create source. + src := filepath.Join(dir, "test.go") + f, err := os.Create(src) + if err != nil { + t.Fatalf("could not create source file: %v", err) + } + f.Write([]byte(` +package main +import "fmt" +func main() { + fmt.Println("hello world") +} +`)) + f.Close() + + // Compile source. + cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-gcflags", "-S", "-o", filepath.Join(dir, "test"), src) + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("could not build target: %v\n%s", err, out) + } + + patterns := []string{ + // It is hard to look for actual instructions in an + // arch-independent way. So we'll just look for + // pseudo-ops that are arch-independent. + "\tTEXT\t", + "\tFUNCDATA\t", + "\tPCDATA\t", + } + outstr := string(out) + for _, p := range patterns { + if !strings.Contains(outstr, p) { + println(outstr) + panic("can't find pattern " + p) + } + } +} diff --git a/go/src/cmd/compile/internal/test/iface_test.go b/go/src/cmd/compile/internal/test/iface_test.go new file mode 100644 index 0000000000000000000000000000000000000000..cb7dc70c2ff89380285b8af9dc7e90a7a9dd561d --- /dev/null +++ b/go/src/cmd/compile/internal/test/iface_test.go @@ -0,0 +1,138 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import "testing" + +// Test to make sure we make copies of the values we +// put in interfaces. + +var x int + +func TestEfaceConv1(t *testing.T) { + a := 5 + i := any(a) + a += 2 + if got := i.(int); got != 5 { + t.Errorf("wanted 5, got %d\n", got) + } +} + +func TestEfaceConv2(t *testing.T) { + a := 5 + sink = &a + i := any(a) + a += 2 + if got := i.(int); got != 5 { + t.Errorf("wanted 5, got %d\n", got) + } +} + +func TestEfaceConv3(t *testing.T) { + x = 5 + if got := e2int3(x); got != 5 { + t.Errorf("wanted 5, got %d\n", got) + } +} + +//go:noinline +func e2int3(i any) int { + x = 7 + return i.(int) +} + +func TestEfaceConv4(t *testing.T) { + a := 5 + if got := e2int4(a, &a); got != 5 { + t.Errorf("wanted 5, got %d\n", got) + } +} + +//go:noinline +func e2int4(i any, p *int) int { + *p = 7 + return i.(int) +} + +type Int int + +var y Int + +type I interface { + foo() +} + +func (i Int) foo() { +} + +func TestIfaceConv1(t *testing.T) { + a := Int(5) + i := any(a) + a += 2 + if got := i.(Int); got != 5 { + t.Errorf("wanted 5, got %d\n", int(got)) + } +} + +func TestIfaceConv2(t *testing.T) { + a := Int(5) + sink = &a + i := any(a) + a += 2 + if got := i.(Int); got != 5 { + t.Errorf("wanted 5, got %d\n", int(got)) + } +} + +func TestIfaceConv3(t *testing.T) { + y = 5 + if got := i2Int3(y); got != 5 { + t.Errorf("wanted 5, got %d\n", int(got)) + } +} + +//go:noinline +func i2Int3(i I) Int { + y = 7 + return i.(Int) +} + +func TestIfaceConv4(t *testing.T) { + a := Int(5) + if got := i2Int4(a, &a); got != 5 { + t.Errorf("wanted 5, got %d\n", int(got)) + } +} + +//go:noinline +func i2Int4(i I, p *Int) Int { + *p = 7 + return i.(Int) +} + +func BenchmarkEfaceInteger(b *testing.B) { + sum := 0 + for i := 0; i < b.N; i++ { + sum += i2int(i) + } + sink = sum +} + +//go:noinline +func i2int(i any) int { + return i.(int) +} + +func BenchmarkTypeAssert(b *testing.B) { + e := any(Int(0)) + r := true + for i := 0; i < b.N; i++ { + _, ok := e.(I) + if !ok { + r = false + } + } + sink = r +} diff --git a/go/src/cmd/compile/internal/test/inl_test.go b/go/src/cmd/compile/internal/test/inl_test.go new file mode 100644 index 0000000000000000000000000000000000000000..3bea11dbb17b125e26f8fa100167cc69bc1b6eae --- /dev/null +++ b/go/src/cmd/compile/internal/test/inl_test.go @@ -0,0 +1,429 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "bufio" + "internal/testenv" + "io" + "math/bits" + "regexp" + "runtime" + "strings" + "testing" +) + +// TestIntendedInlining tests that specific functions are inlined. +// This allows refactoring for code clarity and re-use without fear that +// changes to the compiler will cause silent performance regressions. +func TestIntendedInlining(t *testing.T) { + if testing.Short() && testenv.Builder() == "" { + t.Skip("skipping in short mode") + } + testenv.MustHaveGoRun(t) + t.Parallel() + + // want is the list of function names (by package) that should + // be inlinable. If they have no callers in their packages, they + // might not actually be inlined anywhere. + want := map[string][]string{ + "runtime": { + "add", + "acquirem", + "add1", + "addb", + "adjustpanics", + "adjustpointer", + "alignDown", + "alignUp", + "chanbuf", + "fastlog2", + "float64bits", + "funcspdelta", + "getm", + "getMCache", + "heapSetTypeNoHeader", + "heapSetTypeSmallHeader", + "itabHashFunc", + "nextslicecap", + "noescape", + "pcvalueCacheKey", + "rand32", + "readUnaligned32", + "readUnaligned64", + "releasem", + "roundupsize", + "stackmapdata", + "stringStructOf", + "subtract1", + "subtractb", + "(*waitq).enqueue", + "funcInfo.entry", + + // GC-related ones + "cgoInRange", + "gclinkptr.ptr", + "gcUsesSpanInlineMarkBits", + "guintptr.ptr", + "heapBitsSlice", + "markBits.isMarked", + "muintptr.ptr", + "puintptr.ptr", + "spanHeapBitsRange", + "spanOf", + "spanOfUnchecked", + "typePointers.nextFast", + "(*gcWork).putObjFast", + "(*gcWork).tryGetObjFast", + "(*guintptr).set", + "(*markBits).advance", + "(*mspan).allocBitsForIndex", + "(*mspan).base", + "(*mspan).markBitsForBase", + "(*mspan).markBitsForIndex", + "(*mspan).writeUserArenaHeapBits", + "(*muintptr).set", + "(*puintptr).set", + "(*wbBuf).get1", + "(*wbBuf).get2", + + // Trace-related ones. + "traceLocker.ok", + "traceEnabled", + }, + "bytes": { + "(*Buffer).Bytes", + "(*Buffer).Cap", + "(*Buffer).Len", + "(*Buffer).Grow", + "(*Buffer).Next", + "(*Buffer).Read", + "(*Buffer).ReadByte", + "(*Buffer).Reset", + "(*Buffer).String", + "(*Buffer).UnreadByte", + "(*Buffer).tryGrowByReslice", + }, + "internal/abi": { + "(*Type).IsDirectIface", + "UseInterfaceSwitchCache", + }, + "internal/runtime/math": { + "MulUintptr", + }, + "internal/runtime/sys": {}, + "compress/flate": { + "byLiteral.Len", + "byLiteral.Less", + "byLiteral.Swap", + "(*dictDecoder).tryWriteCopy", + }, + "encoding/base64": { + "assemble32", + "assemble64", + }, + "unicode/utf8": { + "DecodeRune", + "DecodeRuneInString", + "FullRune", + "FullRuneInString", + "RuneLen", + "AppendRune", + "ValidRune", + }, + "unicode/utf16": { + "Decode", + }, + "reflect": { + "Value.Bool", + "Value.Bytes", + "Value.CanAddr", + "Value.CanComplex", + "Value.CanFloat", + "Value.CanInt", + "Value.CanInterface", + "Value.CanSet", + "Value.CanUint", + "Value.Cap", + "Value.Complex", + "Value.Float", + "Value.Int", + "Value.Interface", + "Value.IsNil", + "Value.IsValid", + "Value.Kind", + "Value.Len", + "Value.MapRange", + "Value.OverflowComplex", + "Value.OverflowFloat", + "Value.OverflowInt", + "Value.OverflowUint", + "Value.String", + "Value.Type", + "Value.Uint", + "Value.UnsafeAddr", + "Value.pointer", + "add", + "align", + "flag.mustBe", + "flag.mustBeAssignable", + "flag.mustBeExported", + "flag.kind", + "flag.ro", + }, + "regexp": { + "(*bitState).push", + }, + "math/big": { + "bigEndianWord", + }, + "math/rand": { + "(*rngSource).Int63", + "(*rngSource).Uint64", + }, + "net": { + "(*UDPConn).ReadFromUDP", + }, + "sync": { + // Both OnceFunc and its returned closure need to be inlinable so + // that the returned closure can be inlined into the caller of OnceFunc. + "OnceFunc", + "OnceFunc.func1", // The returned closure. + // TODO(austin): It would be good to check OnceValue and OnceValues, + // too, but currently they aren't reported because they have type + // parameters and aren't instantiated in sync. + }, + "sync/atomic": { + // (*Bool).CompareAndSwap handled below. + "(*Bool).Load", + "(*Bool).Store", + "(*Bool).Swap", + "(*Int32).Add", + "(*Int32).CompareAndSwap", + "(*Int32).Load", + "(*Int32).Store", + "(*Int32).Swap", + "(*Int64).Add", + "(*Int64).CompareAndSwap", + "(*Int64).Load", + "(*Int64).Store", + "(*Int64).Swap", + "(*Uint32).Add", + "(*Uint32).CompareAndSwap", + "(*Uint32).Load", + "(*Uint32).Store", + "(*Uint32).Swap", + "(*Uint64).Add", + "(*Uint64).CompareAndSwap", + "(*Uint64).Load", + "(*Uint64).Store", + "(*Uint64).Swap", + "(*Uintptr).Add", + "(*Uintptr).CompareAndSwap", + "(*Uintptr).Load", + "(*Uintptr).Store", + "(*Uintptr).Swap", + "(*Pointer[go.shape.int]).CompareAndSwap", + "(*Pointer[go.shape.int]).Load", + "(*Pointer[go.shape.int]).Store", + "(*Pointer[go.shape.int]).Swap", + }, + "testing": { + "(*B).Loop", + }, + "path": { + "Base", + "scanChunk", + }, + "path/filepath": { + "scanChunk", + }, + } + + if runtime.GOARCH != "386" && runtime.GOARCH != "loong64" && runtime.GOARCH != "mips64" && runtime.GOARCH != "mips64le" && runtime.GOARCH != "riscv64" { + // nextFreeFast calls sys.TrailingZeros64, which on 386 is implemented in asm and is not inlinable. + // We currently don't have midstack inlining so nextFreeFast is also not inlinable on 386. + // On loong64, mips64x and riscv64, TrailingZeros64 is not intrinsified and causes nextFreeFast + // too expensive to inline (Issue 22239). + want["runtime"] = append(want["runtime"], "nextFreeFast") + } + if runtime.GOARCH != "386" { + // As explained above, TrailingZeros64 and TrailingZeros32 are not Go code on 386. + // The same applies to Bswap32. + want["internal/runtime/sys"] = append(want["internal/runtime/sys"], "TrailingZeros64") + want["internal/runtime/sys"] = append(want["internal/runtime/sys"], "TrailingZeros32") + want["internal/runtime/sys"] = append(want["internal/runtime/sys"], "Bswap32") + } + if runtime.GOARCH == "amd64" || runtime.GOARCH == "arm64" || runtime.GOARCH == "loong64" || runtime.GOARCH == "mips" || runtime.GOARCH == "mips64" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "riscv64" || runtime.GOARCH == "s390x" { + // internal/runtime/atomic.Loaduintptr is only intrinsified on these platforms. + want["runtime"] = append(want["runtime"], "traceAcquire") + } + if bits.UintSize == 64 { + // mix is only defined on 64-bit architectures + want["runtime"] = append(want["runtime"], "mix") + // (*Bool).CompareAndSwap is just over budget on 32-bit systems (386, arm). + want["sync/atomic"] = append(want["sync/atomic"], "(*Bool).CompareAndSwap") + } + + switch runtime.GOARCH { + case "386", "wasm", "arm": + default: + // TODO(mvdan): As explained in /test/inline_sync.go, some + // architectures don't have atomic intrinsics, so these go over + // the inlining budget. Move back to the main table once that + // problem is solved. + want["sync"] = []string{ + "(*Mutex).Lock", + "(*Mutex).Unlock", + "(*RWMutex).RLock", + "(*RWMutex).RUnlock", + "(*Once).Do", + } + } + + if runtime.GOARCH != "wasm" { + // mutex implementation for multi-threaded GOARCHes + want["runtime"] = append(want["runtime"], + // in the fast paths of lock2 and unlock2 + "key8", + "(*mLockProfile).store", + ) + if bits.UintSize == 64 { + // these use 64-bit arithmetic, which is hard to inline on 32-bit platforms + want["runtime"] = append(want["runtime"], + // in the fast paths of lock2 and unlock2 + "mutexSampleContention", + + // in a slow path of lock2, but within the critical section + "(*mLockProfile).end", + ) + } + } + + // Functions that must actually be inlined; they must have actual callers. + must := map[string]bool{ + "compress/flate.byLiteral.Len": true, + "compress/flate.byLiteral.Less": true, + "compress/flate.byLiteral.Swap": true, + } + + notInlinedReason := make(map[string]string) + pkgs := make([]string, 0, len(want)) + for pname, fnames := range want { + pkgs = append(pkgs, pname) + for _, fname := range fnames { + fullName := pname + "." + fname + if _, ok := notInlinedReason[fullName]; ok { + t.Errorf("duplicate func: %s", fullName) + } + notInlinedReason[fullName] = "unknown reason" + } + } + + args := append([]string{"build", "-gcflags=-m -m", "-tags=math_big_pure_go"}, pkgs...) + cmd := testenv.CleanCmdEnv(testenv.Command(t, testenv.GoToolPath(t), args...)) + pr, pw := io.Pipe() + cmd.Stdout = pw + cmd.Stderr = pw + cmdErr := make(chan error, 1) + go func() { + cmdErr <- cmd.Run() + pw.Close() + }() + scanner := bufio.NewScanner(pr) + curPkg := "" + canInline := regexp.MustCompile(`: can inline ([^ ]*)`) + haveInlined := regexp.MustCompile(`: inlining call to ([^ ]*)`) + cannotInline := regexp.MustCompile(`: cannot inline ([^ ]*): (.*)`) + for scanner.Scan() { + line := scanner.Text() + if strings.HasPrefix(line, "# ") { + curPkg = line[2:] + continue + } + if m := haveInlined.FindStringSubmatch(line); m != nil { + fname := m[1] + delete(notInlinedReason, curPkg+"."+fname) + continue + } + if m := canInline.FindStringSubmatch(line); m != nil { + fname := m[1] + fullname := curPkg + "." + fname + // If function must be inlined somewhere, being inlinable is not enough + if _, ok := must[fullname]; !ok { + delete(notInlinedReason, fullname) + continue + } + } + if m := cannotInline.FindStringSubmatch(line); m != nil { + fname, reason := m[1], m[2] + fullName := curPkg + "." + fname + if _, ok := notInlinedReason[fullName]; ok { + // cmd/compile gave us a reason why + notInlinedReason[fullName] = reason + } + continue + } + } + if err := <-cmdErr; err != nil { + t.Fatal(err) + } + if err := scanner.Err(); err != nil { + t.Fatal(err) + } + for fullName, reason := range notInlinedReason { + t.Errorf("%s was not inlined: %s", fullName, reason) + } +} + +func collectInlCands(msgs string) map[string]struct{} { + rv := make(map[string]struct{}) + lines := strings.Split(msgs, "\n") + re := regexp.MustCompile(`^\S+\s+can\s+inline\s+(\S+)`) + for _, line := range lines { + m := re.FindStringSubmatch(line) + if m != nil { + rv[m[1]] = struct{}{} + } + } + return rv +} + +func TestIssue56044(t *testing.T) { + if testing.Short() { + t.Skipf("skipping test: too long for short mode") + } + testenv.MustHaveGoBuild(t) + + modes := []string{"-covermode=set", "-covermode=atomic"} + + for _, mode := range modes { + // Build the Go runtime with "-m", capturing output. + args := []string{"build", "-gcflags=runtime=-m", "runtime"} + cmd := testenv.Command(t, testenv.GoToolPath(t), args...) + b, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("build failed (%v): %s", err, b) + } + mbase := collectInlCands(string(b)) + + // Redo the build with -cover, also with "-m". + args = []string{"build", "-gcflags=runtime=-m", mode, "runtime"} + cmd = testenv.Command(t, testenv.GoToolPath(t), args...) + b, err = cmd.CombinedOutput() + if err != nil { + t.Fatalf("build failed (%v): %s", err, b) + } + mcov := collectInlCands(string(b)) + + // Make sure that there aren't any functions that are marked + // as inline candidates at base but not with coverage. + for k := range mbase { + if _, ok := mcov[k]; !ok { + t.Errorf("error: did not find %s in coverage -m output", k) + } + } + } +} diff --git a/go/src/cmd/compile/internal/test/inst_test.go b/go/src/cmd/compile/internal/test/inst_test.go new file mode 100644 index 0000000000000000000000000000000000000000..069e2ffaf5b8df663e74e0b8b7480609992a10c7 --- /dev/null +++ b/go/src/cmd/compile/internal/test/inst_test.go @@ -0,0 +1,60 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "internal/testenv" + "os" + "path/filepath" + "regexp" + "testing" +) + +// TestInst tests that only one instantiation of Sort is created, even though generic +// Sort is used for multiple pointer types across two packages. +func TestInst(t *testing.T) { + testenv.MustHaveGoBuild(t) + testenv.MustHaveGoRun(t) + + // Build ptrsort.go, which uses package mysort. + var output []byte + var err error + filename := "ptrsort.go" + exename := "ptrsort" + outname := "ptrsort.out" + gotool := testenv.GoToolPath(t) + dest := filepath.Join(t.TempDir(), exename) + cmd := testenv.Command(t, gotool, "build", "-o", dest, filepath.Join("testdata", filename)) + if output, err = cmd.CombinedOutput(); err != nil { + t.Fatalf("Failed: %v:\nOutput: %s\n", err, output) + } + + // Test that there is exactly one shape-based instantiation of Sort in + // the executable. + cmd = testenv.Command(t, gotool, "tool", "nm", dest) + if output, err = cmd.CombinedOutput(); err != nil { + t.Fatalf("Failed: %v:\nOut: %s\n", err, output) + } + // Look for shape-based instantiation of Sort, but ignore any extra wrapper + // ending in "-tramp" (which are created on riscv). + re := regexp.MustCompile(`\bSort\[.*shape.*\][^-]`) + r := re.FindAllIndex(output, -1) + if len(r) != 1 { + t.Fatalf("Wanted 1 instantiations of Sort function, got %d\n", len(r)) + } + + // Actually run the test and make sure output is correct. + cmd = testenv.Command(t, gotool, "run", filepath.Join("testdata", filename)) + if output, err = cmd.CombinedOutput(); err != nil { + t.Fatalf("Failed: %v:\nOut: %s\n", err, output) + } + out, err := os.ReadFile(filepath.Join("testdata", outname)) + if err != nil { + t.Fatalf("Could not find %s\n", outname) + } + if string(out) != string(output) { + t.Fatalf("Wanted output %v, got %v\n", string(out), string(output)) + } +} diff --git a/go/src/cmd/compile/internal/test/intrinsics_test.go b/go/src/cmd/compile/internal/test/intrinsics_test.go new file mode 100644 index 0000000000000000000000000000000000000000..b89198c5058d8538772311207054fe65c622f051 --- /dev/null +++ b/go/src/cmd/compile/internal/test/intrinsics_test.go @@ -0,0 +1,62 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "math/bits" + "testing" +) + +func TestBitLen64(t *testing.T) { + for i := 0; i <= 64; i++ { + got := bits.Len64(1 << i) + want := i + 1 + if want == 65 { + want = 0 + } + if got != want { + t.Errorf("Len64(1<<%d) = %d, want %d", i, got, want) + } + } +} + +func TestBitLen32(t *testing.T) { + for i := 0; i <= 32; i++ { + got := bits.Len32(1 << i) + want := i + 1 + if want == 33 { + want = 0 + } + if got != want { + t.Errorf("Len32(1<<%d) = %d, want %d", i, got, want) + } + } +} + +func TestBitLen16(t *testing.T) { + for i := 0; i <= 16; i++ { + got := bits.Len16(1 << i) + want := i + 1 + if want == 17 { + want = 0 + } + if got != want { + t.Errorf("Len16(1<<%d) = %d, want %d", i, got, want) + } + } +} + +func TestBitLen8(t *testing.T) { + for i := 0; i <= 8; i++ { + got := bits.Len8(1 << i) + want := i + 1 + if want == 9 { + want = 0 + } + if got != want { + t.Errorf("Len8(1<<%d) = %d, want %d", i, got, want) + } + } +} diff --git a/go/src/cmd/compile/internal/test/issue50182_test.go b/go/src/cmd/compile/internal/test/issue50182_test.go new file mode 100644 index 0000000000000000000000000000000000000000..cd277fa285eab5c98fd4e091c538387b49766290 --- /dev/null +++ b/go/src/cmd/compile/internal/test/issue50182_test.go @@ -0,0 +1,62 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "fmt" + "sort" + "testing" +) + +// Test that calling methods on generic types doesn't cause allocations. +func genericSorted[T sort.Interface](data T) bool { + n := data.Len() + for i := n - 1; i > 0; i-- { + if data.Less(i, i-1) { + return false + } + } + return true +} +func TestGenericSorted(t *testing.T) { + var data = sort.IntSlice{-10, -5, 0, 1, 2, 3, 5, 7, 11, 100, 100, 100, 1000, 10000} + f := func() { + genericSorted(data) + } + if n := testing.AllocsPerRun(10, f); n > 0 { + t.Errorf("got %f allocs, want 0", n) + } +} + +// Test that escape analysis correctly tracks escaping inside of methods +// called on generic types. +type fooer interface { + foo() +} +type P struct { + p *int + q int +} + +var esc []*int + +func (p P) foo() { + esc = append(esc, p.p) // foo escapes the pointer from inside of p +} +func f[T fooer](t T) { + t.foo() +} +func TestGenericEscape(t *testing.T) { + for i := 0; i < 4; i++ { + var x int = 77 + i + var p P = P{p: &x} + f(p) + } + for i, p := range esc { + if got, want := *p, 77+i; got != want { + panic(fmt.Sprintf("entry %d: got %d, want %d", i, got, want)) + } + } +} diff --git a/go/src/cmd/compile/internal/test/issue53888_test.go b/go/src/cmd/compile/internal/test/issue53888_test.go new file mode 100644 index 0000000000000000000000000000000000000000..c25c545e0817298d51a57eb4df796aecc065a65f --- /dev/null +++ b/go/src/cmd/compile/internal/test/issue53888_test.go @@ -0,0 +1,46 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !race && !asan && !msan + +package test + +import ( + "internal/testenv" + "testing" +) + +func TestAppendOfMake(t *testing.T) { + testenv.SkipIfOptimizationOff(t) + for n := 32; n < 33; n++ { // avoid stack allocation of make() + b := make([]byte, n) + f := func() { + b = append(b[:0], make([]byte, n)...) + } + if n := testing.AllocsPerRun(10, f); n > 0 { + t.Errorf("got %f allocs, want 0", n) + } + type S []byte + + s := make(S, n) + g := func() { + s = append(s[:0], make(S, n)...) + } + if n := testing.AllocsPerRun(10, g); n > 0 { + t.Errorf("got %f allocs, want 0", n) + } + h := func() { + s = append(s[:0], make([]byte, n)...) + } + if n := testing.AllocsPerRun(10, h); n > 0 { + t.Errorf("got %f allocs, want 0", n) + } + i := func() { + b = append(b[:0], make(S, n)...) + } + if n := testing.AllocsPerRun(10, i); n > 0 { + t.Errorf("got %f allocs, want 0", n) + } + } +} diff --git a/go/src/cmd/compile/internal/test/issue57434_test.go b/go/src/cmd/compile/internal/test/issue57434_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6a34b54a0721a4d3bc749939b3f1596ce0eaa0a5 --- /dev/null +++ b/go/src/cmd/compile/internal/test/issue57434_test.go @@ -0,0 +1,38 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "testing" +) + +var output int + +type Object struct { + Val int +} + +func (o *Object) Initialize() *Object { + o.Val = 5 + return o +} + +func (o *Object) Update() *Object { + o.Val = o.Val + 1 + return o +} + +func TestAutotmpLoopDepth(t *testing.T) { + f := func() { + for i := 0; i < 10; i++ { + var obj Object + obj.Initialize().Update() + output = obj.Val + } + } + if n := testing.AllocsPerRun(10, f); n > 0 { + t.Error("obj moved to heap") + } +} diff --git a/go/src/cmd/compile/internal/test/issue62407_test.go b/go/src/cmd/compile/internal/test/issue62407_test.go new file mode 100644 index 0000000000000000000000000000000000000000..fc9e7a5be082612e341e191cd87727327b6bd4d3 --- /dev/null +++ b/go/src/cmd/compile/internal/test/issue62407_test.go @@ -0,0 +1,62 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "reflect" + "testing" +) + +//go:noinline +func foo() string { return "foofoofoofoofoofo" } // len == 17 + +//go:noinline +func empty() string { return "" } + +func TestConcatBytes(t *testing.T) { + empty := empty() + s := foo() + tests := map[string]struct { + got []byte + want []byte + }{ + "two empty elements": {got: []byte(empty + empty), want: []byte{}}, + "two nonempty elements": {got: []byte(s + s), want: append([]byte(foo()), foo()...)}, + "one empty and one nonempty element": {got: []byte(s + empty), want: []byte(foo())}, + "multiple empty elements": {got: []byte(empty + empty + empty + empty + empty + empty), want: []byte{}}, + "multiple nonempty elements": {got: []byte("1" + "2" + "3" + "4" + "5" + "6"), want: []byte("123456")}, + } + + for name, test := range tests { + if !reflect.DeepEqual(test.got, test.want) { + t.Errorf("[%s] got: %s, want: %s", name, test.got, test.want) + } + } +} + +func TestConcatBytesAllocations(t *testing.T) { + empty := empty() + s := foo() + tests := map[string]struct { + f func() []byte + allocs float64 + }{ + "two empty elements": {f: func() []byte { return []byte(empty + empty) }, allocs: 0}, + "multiple empty elements": {f: func() []byte { return []byte(empty + empty + empty + empty + empty + empty) }, allocs: 0}, + + "two elements": {f: func() []byte { return []byte(s + s) }, allocs: 1}, + "three elements": {f: func() []byte { return []byte(s + s + s) }, allocs: 1}, + "four elements": {f: func() []byte { return []byte(s + s + s + s) }, allocs: 1}, + "five elements": {f: func() []byte { return []byte(s + s + s + s + s) }, allocs: 1}, + "one empty and one nonempty element": {f: func() []byte { return []byte(s + empty) }, allocs: 1}, + "two empty and two nonempty element": {f: func() []byte { return []byte(s + empty + s + empty) }, allocs: 1}, + } + for name, test := range tests { + allocs := testing.AllocsPerRun(100, func() { test.f() }) + if allocs != test.allocs { + t.Errorf("concatbytes [%s]: %v allocs, want %v", name, allocs, test.allocs) + } + } +} diff --git a/go/src/cmd/compile/internal/test/issue71943_test.go b/go/src/cmd/compile/internal/test/issue71943_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a92b0a1e2b038da8fcbede71ac99b12a455df05d --- /dev/null +++ b/go/src/cmd/compile/internal/test/issue71943_test.go @@ -0,0 +1,25 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "crypto/sha256" + "internal/testenv" + "runtime" + "testing" +) + +func Verify(token, salt string) [32]byte { + return sha256.Sum256([]byte(token + salt)) +} + +func TestIssue71943(t *testing.T) { + testenv.SkipIfOptimizationOff(t) + if n := testing.AllocsPerRun(10, func() { + runtime.KeepAlive(Verify("teststring", "test")) + }); n > 0 { + t.Fatalf("unexpected allocation: %f", n) + } +} diff --git a/go/src/cmd/compile/internal/test/lang_test.go b/go/src/cmd/compile/internal/test/lang_test.go new file mode 100644 index 0000000000000000000000000000000000000000..34ed378cd8eaa1cbbe96e24d0219a0b36b69f2a7 --- /dev/null +++ b/go/src/cmd/compile/internal/test/lang_test.go @@ -0,0 +1,58 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "internal/testenv" + "os" + "path/filepath" + "testing" +) + +const aliasSrc = ` +package x + +type T = int +` + +func TestInvalidLang(t *testing.T) { + t.Parallel() + + testenv.MustHaveGoBuild(t) + + dir := t.TempDir() + + src := filepath.Join(dir, "alias.go") + if err := os.WriteFile(src, []byte(aliasSrc), 0644); err != nil { + t.Fatal(err) + } + + outfile := filepath.Join(dir, "alias.o") + + if testLang(t, "go9.99", src, outfile) == nil { + t.Error("compilation with -lang=go9.99 succeeded unexpectedly") + } + + // This test will have to be adjusted if we ever reach 1.99 or 2.0. + if testLang(t, "go1.99", src, outfile) == nil { + t.Error("compilation with -lang=go1.99 succeeded unexpectedly") + } + + if testLang(t, "go1.8", src, outfile) == nil { + t.Error("compilation with -lang=go1.8 succeeded unexpectedly") + } + + if err := testLang(t, "go1.9", src, outfile); err != nil { + t.Errorf("compilation with -lang=go1.9 failed unexpectedly: %v", err) + } +} + +func testLang(t *testing.T, lang, src, outfile string) error { + run := []string{testenv.GoToolPath(t), "tool", "compile", "-p=p", "-lang", lang, "-o", outfile, src} + t.Log(run) + out, err := testenv.Command(t, run[0], run[1:]...).CombinedOutput() + t.Logf("%s", out) + return err +} diff --git a/go/src/cmd/compile/internal/test/locals_test.go b/go/src/cmd/compile/internal/test/locals_test.go new file mode 100644 index 0000000000000000000000000000000000000000..8e8a54950a8ee3c424cad2c62cad68fa96faf717 --- /dev/null +++ b/go/src/cmd/compile/internal/test/locals_test.go @@ -0,0 +1,93 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "sync/atomic" + "testing" +) + +func locals() { + var x int64 + var y int32 + var z int16 + var w int8 + sink64 = &x + sink32 = &y + sink16 = &z + sink8 = &w +} + +//go:noinline +func args(x int64, y int32, z int16, w int8) { + sink64 = &x + sink32 = &y + sink16 = &z + sink8 = &w + +} + +//go:noinline +func half(x int64, y int16) { + var z int32 + var w int8 + sink64 = &x + sink16 = &y + sink32 = &z + sink8 = &w +} + +//go:noinline +func closure() func() { + var x int64 + var y int32 + var z int16 + var w int8 + _, _, _, _ = x, y, z, w + return func() { + x = 1 + y = 2 + z = 3 + w = 4 + } +} + +//go:noinline +func atomicFn() { + var x int32 + var y int64 + var z int16 + var w int8 + sink32 = &x + sink64 = &y + sink16 = &z + sink8 = &w + atomic.StoreInt64(&y, 7) +} + +var sink64 *int64 +var sink32 *int32 +var sink16 *int16 +var sink8 *int8 + +func TestLocalAllocations(t *testing.T) { + type test struct { + name string + f func() + want int + } + for _, tst := range []test{ + {"locals", locals, 1}, + {"args", func() { args(1, 2, 3, 4) }, 1}, + {"half", func() { half(1, 2) }, 1}, + {"closure", func() { _ = closure() }, 2}, + {"atomic", atomicFn, 1}, + } { + allocs := testing.AllocsPerRun(100, tst.f) + if allocs != float64(tst.want) { + t.Errorf("test %s uses %v allocs, want %d", tst.name, allocs, tst.want) + } + } +} diff --git a/go/src/cmd/compile/internal/test/logic_test.go b/go/src/cmd/compile/internal/test/logic_test.go new file mode 100644 index 0000000000000000000000000000000000000000..0e46b5faef8924a6ec28d8b39fe7791951b9acb5 --- /dev/null +++ b/go/src/cmd/compile/internal/test/logic_test.go @@ -0,0 +1,293 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import "testing" + +// Tests to make sure logic simplification rules are correct. + +func TestLogic64(t *testing.T) { + // test values to determine function equality + values := [...]int64{-1 << 63, 1<<63 - 1, -4, -3, -2, -1, 0, 1, 2, 3, 4} + + // golden functions we use repeatedly + zero := func(x int64) int64 { return 0 } + id := func(x int64) int64 { return x } + or := func(x, y int64) int64 { return x | y } + and := func(x, y int64) int64 { return x & y } + y := func(x, y int64) int64 { return y } + + for _, test := range [...]struct { + name string + f func(int64) int64 + golden func(int64) int64 + }{ + {"x|x", func(x int64) int64 { return x | x }, id}, + {"x|0", func(x int64) int64 { return x | 0 }, id}, + {"x|-1", func(x int64) int64 { return x | -1 }, func(x int64) int64 { return -1 }}, + {"x&x", func(x int64) int64 { return x & x }, id}, + {"x&0", func(x int64) int64 { return x & 0 }, zero}, + {"x&-1", func(x int64) int64 { return x & -1 }, id}, + {"x^x", func(x int64) int64 { return x ^ x }, zero}, + {"x^0", func(x int64) int64 { return x ^ 0 }, id}, + {"x^-1", func(x int64) int64 { return x ^ -1 }, func(x int64) int64 { return ^x }}, + {"x+0", func(x int64) int64 { return x + 0 }, id}, + {"x-x", func(x int64) int64 { return x - x }, zero}, + {"x*0", func(x int64) int64 { return x * 0 }, zero}, + {"^^x", func(x int64) int64 { return ^^x }, id}, + } { + for _, v := range values { + got := test.f(v) + want := test.golden(v) + if want != got { + t.Errorf("[%s](%d)=%d, want %d", test.name, v, got, want) + } + } + } + for _, test := range [...]struct { + name string + f func(int64, int64) int64 + golden func(int64, int64) int64 + }{ + {"x|(x|y)", func(x, y int64) int64 { return x | (x | y) }, or}, + {"x|(y|x)", func(x, y int64) int64 { return x | (y | x) }, or}, + {"(x|y)|x", func(x, y int64) int64 { return (x | y) | x }, or}, + {"(y|x)|x", func(x, y int64) int64 { return (y | x) | x }, or}, + {"x&(x&y)", func(x, y int64) int64 { return x & (x & y) }, and}, + {"x&(y&x)", func(x, y int64) int64 { return x & (y & x) }, and}, + {"(x&y)&x", func(x, y int64) int64 { return (x & y) & x }, and}, + {"(y&x)&x", func(x, y int64) int64 { return (y & x) & x }, and}, + {"x^(x^y)", func(x, y int64) int64 { return x ^ (x ^ y) }, y}, + {"x^(y^x)", func(x, y int64) int64 { return x ^ (y ^ x) }, y}, + {"(x^y)^x", func(x, y int64) int64 { return (x ^ y) ^ x }, y}, + {"(y^x)^x", func(x, y int64) int64 { return (y ^ x) ^ x }, y}, + {"-(y-x)", func(x, y int64) int64 { return -(y - x) }, func(x, y int64) int64 { return x - y }}, + {"(x+y)-x", func(x, y int64) int64 { return (x + y) - x }, y}, + {"(y+x)-x", func(x, y int64) int64 { return (y + x) - x }, y}, + } { + for _, v := range values { + for _, w := range values { + got := test.f(v, w) + want := test.golden(v, w) + if want != got { + t.Errorf("[%s](%d,%d)=%d, want %d", test.name, v, w, got, want) + } + } + } + } +} + +func TestLogic32(t *testing.T) { + // test values to determine function equality + values := [...]int32{-1 << 31, 1<<31 - 1, -4, -3, -2, -1, 0, 1, 2, 3, 4} + + // golden functions we use repeatedly + zero := func(x int32) int32 { return 0 } + id := func(x int32) int32 { return x } + or := func(x, y int32) int32 { return x | y } + and := func(x, y int32) int32 { return x & y } + y := func(x, y int32) int32 { return y } + + for _, test := range [...]struct { + name string + f func(int32) int32 + golden func(int32) int32 + }{ + {"x|x", func(x int32) int32 { return x | x }, id}, + {"x|0", func(x int32) int32 { return x | 0 }, id}, + {"x|-1", func(x int32) int32 { return x | -1 }, func(x int32) int32 { return -1 }}, + {"x&x", func(x int32) int32 { return x & x }, id}, + {"x&0", func(x int32) int32 { return x & 0 }, zero}, + {"x&-1", func(x int32) int32 { return x & -1 }, id}, + {"x^x", func(x int32) int32 { return x ^ x }, zero}, + {"x^0", func(x int32) int32 { return x ^ 0 }, id}, + {"x^-1", func(x int32) int32 { return x ^ -1 }, func(x int32) int32 { return ^x }}, + {"x+0", func(x int32) int32 { return x + 0 }, id}, + {"x-x", func(x int32) int32 { return x - x }, zero}, + {"x*0", func(x int32) int32 { return x * 0 }, zero}, + {"^^x", func(x int32) int32 { return ^^x }, id}, + } { + for _, v := range values { + got := test.f(v) + want := test.golden(v) + if want != got { + t.Errorf("[%s](%d)=%d, want %d", test.name, v, got, want) + } + } + } + for _, test := range [...]struct { + name string + f func(int32, int32) int32 + golden func(int32, int32) int32 + }{ + {"x|(x|y)", func(x, y int32) int32 { return x | (x | y) }, or}, + {"x|(y|x)", func(x, y int32) int32 { return x | (y | x) }, or}, + {"(x|y)|x", func(x, y int32) int32 { return (x | y) | x }, or}, + {"(y|x)|x", func(x, y int32) int32 { return (y | x) | x }, or}, + {"x&(x&y)", func(x, y int32) int32 { return x & (x & y) }, and}, + {"x&(y&x)", func(x, y int32) int32 { return x & (y & x) }, and}, + {"(x&y)&x", func(x, y int32) int32 { return (x & y) & x }, and}, + {"(y&x)&x", func(x, y int32) int32 { return (y & x) & x }, and}, + {"x^(x^y)", func(x, y int32) int32 { return x ^ (x ^ y) }, y}, + {"x^(y^x)", func(x, y int32) int32 { return x ^ (y ^ x) }, y}, + {"(x^y)^x", func(x, y int32) int32 { return (x ^ y) ^ x }, y}, + {"(y^x)^x", func(x, y int32) int32 { return (y ^ x) ^ x }, y}, + {"-(y-x)", func(x, y int32) int32 { return -(y - x) }, func(x, y int32) int32 { return x - y }}, + {"(x+y)-x", func(x, y int32) int32 { return (x + y) - x }, y}, + {"(y+x)-x", func(x, y int32) int32 { return (y + x) - x }, y}, + } { + for _, v := range values { + for _, w := range values { + got := test.f(v, w) + want := test.golden(v, w) + if want != got { + t.Errorf("[%s](%d,%d)=%d, want %d", test.name, v, w, got, want) + } + } + } + } +} + +func TestLogic16(t *testing.T) { + // test values to determine function equality + values := [...]int16{-1 << 15, 1<<15 - 1, -4, -3, -2, -1, 0, 1, 2, 3, 4} + + // golden functions we use repeatedly + zero := func(x int16) int16 { return 0 } + id := func(x int16) int16 { return x } + or := func(x, y int16) int16 { return x | y } + and := func(x, y int16) int16 { return x & y } + y := func(x, y int16) int16 { return y } + + for _, test := range [...]struct { + name string + f func(int16) int16 + golden func(int16) int16 + }{ + {"x|x", func(x int16) int16 { return x | x }, id}, + {"x|0", func(x int16) int16 { return x | 0 }, id}, + {"x|-1", func(x int16) int16 { return x | -1 }, func(x int16) int16 { return -1 }}, + {"x&x", func(x int16) int16 { return x & x }, id}, + {"x&0", func(x int16) int16 { return x & 0 }, zero}, + {"x&-1", func(x int16) int16 { return x & -1 }, id}, + {"x^x", func(x int16) int16 { return x ^ x }, zero}, + {"x^0", func(x int16) int16 { return x ^ 0 }, id}, + {"x^-1", func(x int16) int16 { return x ^ -1 }, func(x int16) int16 { return ^x }}, + {"x+0", func(x int16) int16 { return x + 0 }, id}, + {"x-x", func(x int16) int16 { return x - x }, zero}, + {"x*0", func(x int16) int16 { return x * 0 }, zero}, + {"^^x", func(x int16) int16 { return ^^x }, id}, + } { + for _, v := range values { + got := test.f(v) + want := test.golden(v) + if want != got { + t.Errorf("[%s](%d)=%d, want %d", test.name, v, got, want) + } + } + } + for _, test := range [...]struct { + name string + f func(int16, int16) int16 + golden func(int16, int16) int16 + }{ + {"x|(x|y)", func(x, y int16) int16 { return x | (x | y) }, or}, + {"x|(y|x)", func(x, y int16) int16 { return x | (y | x) }, or}, + {"(x|y)|x", func(x, y int16) int16 { return (x | y) | x }, or}, + {"(y|x)|x", func(x, y int16) int16 { return (y | x) | x }, or}, + {"x&(x&y)", func(x, y int16) int16 { return x & (x & y) }, and}, + {"x&(y&x)", func(x, y int16) int16 { return x & (y & x) }, and}, + {"(x&y)&x", func(x, y int16) int16 { return (x & y) & x }, and}, + {"(y&x)&x", func(x, y int16) int16 { return (y & x) & x }, and}, + {"x^(x^y)", func(x, y int16) int16 { return x ^ (x ^ y) }, y}, + {"x^(y^x)", func(x, y int16) int16 { return x ^ (y ^ x) }, y}, + {"(x^y)^x", func(x, y int16) int16 { return (x ^ y) ^ x }, y}, + {"(y^x)^x", func(x, y int16) int16 { return (y ^ x) ^ x }, y}, + {"-(y-x)", func(x, y int16) int16 { return -(y - x) }, func(x, y int16) int16 { return x - y }}, + {"(x+y)-x", func(x, y int16) int16 { return (x + y) - x }, y}, + {"(y+x)-x", func(x, y int16) int16 { return (y + x) - x }, y}, + } { + for _, v := range values { + for _, w := range values { + got := test.f(v, w) + want := test.golden(v, w) + if want != got { + t.Errorf("[%s](%d,%d)=%d, want %d", test.name, v, w, got, want) + } + } + } + } +} + +func TestLogic8(t *testing.T) { + // test values to determine function equality + values := [...]int8{-1 << 7, 1<<7 - 1, -4, -3, -2, -1, 0, 1, 2, 3, 4} + + // golden functions we use repeatedly + zero := func(x int8) int8 { return 0 } + id := func(x int8) int8 { return x } + or := func(x, y int8) int8 { return x | y } + and := func(x, y int8) int8 { return x & y } + y := func(x, y int8) int8 { return y } + + for _, test := range [...]struct { + name string + f func(int8) int8 + golden func(int8) int8 + }{ + {"x|x", func(x int8) int8 { return x | x }, id}, + {"x|0", func(x int8) int8 { return x | 0 }, id}, + {"x|-1", func(x int8) int8 { return x | -1 }, func(x int8) int8 { return -1 }}, + {"x&x", func(x int8) int8 { return x & x }, id}, + {"x&0", func(x int8) int8 { return x & 0 }, zero}, + {"x&-1", func(x int8) int8 { return x & -1 }, id}, + {"x^x", func(x int8) int8 { return x ^ x }, zero}, + {"x^0", func(x int8) int8 { return x ^ 0 }, id}, + {"x^-1", func(x int8) int8 { return x ^ -1 }, func(x int8) int8 { return ^x }}, + {"x+0", func(x int8) int8 { return x + 0 }, id}, + {"x-x", func(x int8) int8 { return x - x }, zero}, + {"x*0", func(x int8) int8 { return x * 0 }, zero}, + {"^^x", func(x int8) int8 { return ^^x }, id}, + } { + for _, v := range values { + got := test.f(v) + want := test.golden(v) + if want != got { + t.Errorf("[%s](%d)=%d, want %d", test.name, v, got, want) + } + } + } + for _, test := range [...]struct { + name string + f func(int8, int8) int8 + golden func(int8, int8) int8 + }{ + {"x|(x|y)", func(x, y int8) int8 { return x | (x | y) }, or}, + {"x|(y|x)", func(x, y int8) int8 { return x | (y | x) }, or}, + {"(x|y)|x", func(x, y int8) int8 { return (x | y) | x }, or}, + {"(y|x)|x", func(x, y int8) int8 { return (y | x) | x }, or}, + {"x&(x&y)", func(x, y int8) int8 { return x & (x & y) }, and}, + {"x&(y&x)", func(x, y int8) int8 { return x & (y & x) }, and}, + {"(x&y)&x", func(x, y int8) int8 { return (x & y) & x }, and}, + {"(y&x)&x", func(x, y int8) int8 { return (y & x) & x }, and}, + {"x^(x^y)", func(x, y int8) int8 { return x ^ (x ^ y) }, y}, + {"x^(y^x)", func(x, y int8) int8 { return x ^ (y ^ x) }, y}, + {"(x^y)^x", func(x, y int8) int8 { return (x ^ y) ^ x }, y}, + {"(y^x)^x", func(x, y int8) int8 { return (y ^ x) ^ x }, y}, + {"-(y-x)", func(x, y int8) int8 { return -(y - x) }, func(x, y int8) int8 { return x - y }}, + {"(x+y)-x", func(x, y int8) int8 { return (x + y) - x }, y}, + {"(y+x)-x", func(x, y int8) int8 { return (y + x) - x }, y}, + } { + for _, v := range values { + for _, w := range values { + got := test.f(v, w) + want := test.golden(v, w) + if want != got { + t.Errorf("[%s](%d,%d)=%d, want %d", test.name, v, w, got, want) + } + } + } + } +} diff --git a/go/src/cmd/compile/internal/test/math_test.go b/go/src/cmd/compile/internal/test/math_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1febe9d42be96c3a486c9ed9aed09ab2e6afb6cc --- /dev/null +++ b/go/src/cmd/compile/internal/test/math_test.go @@ -0,0 +1,171 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "testing" +) + +var Output int + +func BenchmarkDiv64UnsignedSmall(b *testing.B) { + q := uint64(1) + for i := 1; i <= b.N; i++ { + q = (q + uint64(i)) / uint64(i) + } + Output = int(q) +} + +func BenchmarkDiv64Small(b *testing.B) { + q := int64(1) + for i := 1; i <= b.N; i++ { + q = (q + int64(i)) / int64(i) + } + Output = int(q) +} + +func BenchmarkDiv64SmallNegDivisor(b *testing.B) { + q := int64(-1) + for i := 1; i <= b.N; i++ { + q = (int64(i) - q) / -int64(i) + } + Output = int(q) +} + +func BenchmarkDiv64SmallNegDividend(b *testing.B) { + q := int64(-1) + for i := 1; i <= b.N; i++ { + q = -(int64(i) - q) / int64(i) + } + Output = int(q) +} + +func BenchmarkDiv64SmallNegBoth(b *testing.B) { + q := int64(1) + for i := 1; i <= b.N; i++ { + q = -(int64(i) + q) / -int64(i) + } + Output = int(q) +} + +func BenchmarkDiv64Unsigned(b *testing.B) { + q := uint64(1) + for i := 1; i <= b.N; i++ { + q = (uint64(0x7fffffffffffffff) - uint64(i) - (q & 1)) / uint64(i) + } + Output = int(q) +} + +func BenchmarkDiv64(b *testing.B) { + q := int64(1) + for i := 1; i <= b.N; i++ { + q = (int64(0x7fffffffffffffff) - int64(i) - (q & 1)) / int64(i) + } + Output = int(q) +} + +func BenchmarkDiv64NegDivisor(b *testing.B) { + q := int64(-1) + for i := 1; i <= b.N; i++ { + q = (int64(0x7fffffffffffffff) - int64(i) - (q & 1)) / -int64(i) + } + Output = int(q) +} + +func BenchmarkDiv64NegDividend(b *testing.B) { + q := int64(-1) + for i := 1; i <= b.N; i++ { + q = -(int64(0x7fffffffffffffff) - int64(i) - (q & 1)) / int64(i) + } + Output = int(q) +} + +func BenchmarkDiv64NegBoth(b *testing.B) { + q := int64(-1) + for i := 1; i <= b.N; i++ { + q = -(int64(0x7fffffffffffffff) - int64(i) - (q & 1)) / -int64(i) + } + Output = int(q) +} + +func BenchmarkMod64UnsignedSmall(b *testing.B) { + r := uint64(1) + for i := 1; i <= b.N; i++ { + r = (uint64(i) + r) % uint64(i) + } + Output = int(r) +} + +func BenchmarkMod64Small(b *testing.B) { + r := int64(1) + for i := 1; i <= b.N; i++ { + r = (int64(i) + r) % int64(i) + } + Output = int(r) +} + +func BenchmarkMod64SmallNegDivisor(b *testing.B) { + r := int64(-1) + for i := 1; i <= b.N; i++ { + r = (int64(i) - r) % -int64(i) + } + Output = int(r) +} + +func BenchmarkMod64SmallNegDividend(b *testing.B) { + r := int64(-1) + for i := 1; i <= b.N; i++ { + r = -(int64(i) - r) % int64(i) + } + Output = int(r) +} + +func BenchmarkMod64SmallNegBoth(b *testing.B) { + r := int64(1) + for i := 1; i <= b.N; i++ { + r = -(int64(i) + r) % -int64(i) + } + Output = int(r) +} + +func BenchmarkMod64Unsigned(b *testing.B) { + r := uint64(1) + for i := 1; i <= b.N; i++ { + r = (uint64(0x7fffffffffffffff) - uint64(i) - (r & 1)) % uint64(i) + } + Output = int(r) +} + +func BenchmarkMod64(b *testing.B) { + r := int64(1) + for i := 1; i <= b.N; i++ { + r = (int64(0x7fffffffffffffff) - int64(i) - (r & 1)) % int64(i) + } + Output = int(r) +} + +func BenchmarkMod64NegDivisor(b *testing.B) { + r := int64(-1) + for i := 1; i <= b.N; i++ { + r = (int64(0x7fffffffffffffff) - int64(i) - (r & 1)) % -int64(i) + } + Output = int(r) +} + +func BenchmarkMod64NegDividend(b *testing.B) { + r := int64(-1) + for i := 1; i <= b.N; i++ { + r = -(int64(0x7fffffffffffffff) - int64(i) - (r & 1)) % int64(i) + } + Output = int(r) +} + +func BenchmarkMod64NegBoth(b *testing.B) { + r := int64(1) + for i := 1; i <= b.N; i++ { + r = -(int64(0x7fffffffffffffff) - int64(i) - (r & 1)) % -int64(i) + } + Output = int(r) +} diff --git a/go/src/cmd/compile/internal/test/memcombine_test.go b/go/src/cmd/compile/internal/test/memcombine_test.go new file mode 100644 index 0000000000000000000000000000000000000000..3fc4a004a3d583e4a61ca0f18714f7fd2a225d2e --- /dev/null +++ b/go/src/cmd/compile/internal/test/memcombine_test.go @@ -0,0 +1,199 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "encoding/binary" + "testing" +) + +var gv = [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8} + +//go:noinline +func readGlobalUnaligned() uint64 { + return binary.LittleEndian.Uint64(gv[1:]) +} + +func TestUnalignedGlobal(t *testing.T) { + // Note: this is a test not so much of the result of the read, but of + // the correct compilation of that read. On s390x unaligned global + // accesses fail to compile. + if got, want := readGlobalUnaligned(), uint64(0x0807060504030201); got != want { + t.Errorf("read global %x, want %x", got, want) + } +} + +func TestSpillOfExtendedEndianLoads(t *testing.T) { + b := []byte{0xaa, 0xbb, 0xcc, 0xdd} + + var testCases = []struct { + fn func([]byte) uint64 + want uint64 + }{ + {readUint16le, 0xbbaa}, + {readUint16be, 0xaabb}, + {readUint32le, 0xddccbbaa}, + {readUint32be, 0xaabbccdd}, + } + for _, test := range testCases { + if got := test.fn(b); got != test.want { + t.Errorf("got %x, want %x", got, test.want) + } + } +} + +func readUint16le(b []byte) uint64 { + y := uint64(binary.LittleEndian.Uint16(b)) + nop() // force spill + return y +} + +func readUint16be(b []byte) uint64 { + y := uint64(binary.BigEndian.Uint16(b)) + nop() // force spill + return y +} + +func readUint32le(b []byte) uint64 { + y := uint64(binary.LittleEndian.Uint32(b)) + nop() // force spill + return y +} + +func readUint32be(b []byte) uint64 { + y := uint64(binary.BigEndian.Uint32(b)) + nop() // force spill + return y +} + +//go:noinline +func nop() { +} + +type T32 struct { + a, b uint32 +} + +//go:noinline +func (t *T32) bigEndianLoad() uint64 { + return uint64(t.a)<<32 | uint64(t.b) +} + +//go:noinline +func (t *T32) littleEndianLoad() uint64 { + return uint64(t.a) | (uint64(t.b) << 32) +} + +//go:noinline +func (t *T32) bigEndianStore(x uint64) { + t.a = uint32(x >> 32) + t.b = uint32(x) +} + +//go:noinline +func (t *T32) littleEndianStore(x uint64) { + t.a = uint32(x) + t.b = uint32(x >> 32) +} + +type T16 struct { + a, b uint16 +} + +//go:noinline +func (t *T16) bigEndianLoad() uint32 { + return uint32(t.a)<<16 | uint32(t.b) +} + +//go:noinline +func (t *T16) littleEndianLoad() uint32 { + return uint32(t.a) | (uint32(t.b) << 16) +} + +//go:noinline +func (t *T16) bigEndianStore(x uint32) { + t.a = uint16(x >> 16) + t.b = uint16(x) +} + +//go:noinline +func (t *T16) littleEndianStore(x uint32) { + t.a = uint16(x) + t.b = uint16(x >> 16) +} + +type T8 struct { + a, b uint8 +} + +//go:noinline +func (t *T8) bigEndianLoad() uint16 { + return uint16(t.a)<<8 | uint16(t.b) +} + +//go:noinline +func (t *T8) littleEndianLoad() uint16 { + return uint16(t.a) | (uint16(t.b) << 8) +} + +//go:noinline +func (t *T8) bigEndianStore(x uint16) { + t.a = uint8(x >> 8) + t.b = uint8(x) +} + +//go:noinline +func (t *T8) littleEndianStore(x uint16) { + t.a = uint8(x) + t.b = uint8(x >> 8) +} + +func TestIssue64468(t *testing.T) { + t32 := T32{1, 2} + if got, want := t32.bigEndianLoad(), uint64(1<<32+2); got != want { + t.Errorf("T32.bigEndianLoad got %x want %x\n", got, want) + } + if got, want := t32.littleEndianLoad(), uint64(1+2<<32); got != want { + t.Errorf("T32.littleEndianLoad got %x want %x\n", got, want) + } + t16 := T16{1, 2} + if got, want := t16.bigEndianLoad(), uint32(1<<16+2); got != want { + t.Errorf("T16.bigEndianLoad got %x want %x\n", got, want) + } + if got, want := t16.littleEndianLoad(), uint32(1+2<<16); got != want { + t.Errorf("T16.littleEndianLoad got %x want %x\n", got, want) + } + t8 := T8{1, 2} + if got, want := t8.bigEndianLoad(), uint16(1<<8+2); got != want { + t.Errorf("T8.bigEndianLoad got %x want %x\n", got, want) + } + if got, want := t8.littleEndianLoad(), uint16(1+2<<8); got != want { + t.Errorf("T8.littleEndianLoad got %x want %x\n", got, want) + } + t32.bigEndianStore(1<<32 + 2) + if got, want := t32, (T32{1, 2}); got != want { + t.Errorf("T32.bigEndianStore got %x want %x\n", got, want) + } + t32.littleEndianStore(1<<32 + 2) + if got, want := t32, (T32{2, 1}); got != want { + t.Errorf("T32.littleEndianStore got %x want %x\n", got, want) + } + t16.bigEndianStore(1<<16 + 2) + if got, want := t16, (T16{1, 2}); got != want { + t.Errorf("T16.bigEndianStore got %x want %x\n", got, want) + } + t16.littleEndianStore(1<<16 + 2) + if got, want := t16, (T16{2, 1}); got != want { + t.Errorf("T16.littleEndianStore got %x want %x\n", got, want) + } + t8.bigEndianStore(1<<8 + 2) + if got, want := t8, (T8{1, 2}); got != want { + t.Errorf("T8.bigEndianStore got %x want %x\n", got, want) + } + t8.littleEndianStore(1<<8 + 2) + if got, want := t8, (T8{2, 1}); got != want { + t.Errorf("T8.littleEndianStore got %x want %x\n", got, want) + } +} diff --git a/go/src/cmd/compile/internal/test/memoverlap_test.go b/go/src/cmd/compile/internal/test/memoverlap_test.go new file mode 100644 index 0000000000000000000000000000000000000000..c53288e6bb24ac055216a8ee5a68559a3eba2f42 --- /dev/null +++ b/go/src/cmd/compile/internal/test/memoverlap_test.go @@ -0,0 +1,41 @@ +// Copyright 2026 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import "testing" + +const arrFooSize = 96 + +type arrFoo [arrFooSize]int + +//go:noinline +func badCopy(dst, src []int) { + p := (*[arrFooSize]int)(dst[:arrFooSize]) + q := (*[arrFooSize]int)(src[:arrFooSize]) + *p = arrFoo(*q) +} + +//go:noinline +func goodCopy(dst, src []int) { + p := (*[arrFooSize]int)(dst[:arrFooSize]) + q := (*[arrFooSize]int)(src[:arrFooSize]) + *p = *q +} + +func TestOverlapedMoveWithNoopIConv(t *testing.T) { + h1 := make([]int, arrFooSize+1) + h2 := make([]int, arrFooSize+1) + for i := range arrFooSize + 1 { + h1[i] = i + h2[i] = i + } + badCopy(h1[1:], h1[:arrFooSize]) + goodCopy(h2[1:], h2[:arrFooSize]) + for i := range arrFooSize + 1 { + if h1[i] != h2[i] { + t.Errorf("h1 and h2 differ at index %d, expect them to be the same", i) + } + } +} diff --git a/go/src/cmd/compile/internal/test/mergelocals_test.go b/go/src/cmd/compile/internal/test/mergelocals_test.go new file mode 100644 index 0000000000000000000000000000000000000000..77389fa7b70682ec1614d5424a605db95fa1ce1a --- /dev/null +++ b/go/src/cmd/compile/internal/test/mergelocals_test.go @@ -0,0 +1,194 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "cmd/compile/internal/ir" + "cmd/compile/internal/liveness" + "cmd/compile/internal/typecheck" + "cmd/compile/internal/types" + "cmd/internal/src" + "internal/testenv" + "path/filepath" + "sort" + "strings" + "testing" +) + +func mkiv(name string) *ir.Name { + i32 := types.Types[types.TINT32] + s := typecheck.Lookup(name) + v := ir.NewNameAt(src.NoXPos, s, i32) + return v +} + +func TestMergeLocalState(t *testing.T) { + v1 := mkiv("v1") + v2 := mkiv("v2") + v3 := mkiv("v3") + + testcases := []struct { + vars []*ir.Name + partition map[*ir.Name][]int + experr bool + }{ + { + vars: []*ir.Name{v1, v2, v3}, + partition: map[*ir.Name][]int{ + v1: []int{0, 1, 2}, + v2: []int{0, 1, 2}, + v3: []int{0, 1, 2}, + }, + experr: false, + }, + { + // invalid mls.v slot -1 + vars: []*ir.Name{v1, v2, v3}, + partition: map[*ir.Name][]int{ + v1: []int{-1, 0}, + v2: []int{0, 1, 2}, + v3: []int{0, 1, 2}, + }, + experr: true, + }, + { + // duplicate var in v + vars: []*ir.Name{v1, v2, v2}, + partition: map[*ir.Name][]int{ + v1: []int{0, 1, 2}, + v2: []int{0, 1, 2}, + v3: []int{0, 1, 2}, + }, + experr: true, + }, + { + // single element in partition + vars: []*ir.Name{v1, v2, v3}, + partition: map[*ir.Name][]int{ + v1: []int{0}, + v2: []int{0, 1, 2}, + v3: []int{0, 1, 2}, + }, + experr: true, + }, + { + // missing element 2 + vars: []*ir.Name{v1, v2, v3}, + partition: map[*ir.Name][]int{ + v1: []int{0, 1}, + v2: []int{0, 1}, + v3: []int{0, 1}, + }, + experr: true, + }, + { + // partitions disagree for v1 vs v2 + vars: []*ir.Name{v1, v2, v3}, + partition: map[*ir.Name][]int{ + v1: []int{0, 1, 2}, + v2: []int{1, 0, 2}, + v3: []int{0, 1, 2}, + }, + experr: true, + }, + } + + for k, testcase := range testcases { + mls, err := liveness.MakeMergeLocalsState(testcase.partition, testcase.vars) + t.Logf("tc %d err is %v\n", k, err) + if testcase.experr && err == nil { + t.Fatalf("tc:%d missing error mls %v", k, mls) + } else if !testcase.experr && err != nil { + t.Fatalf("tc:%d unexpected error mls %v", k, err) + } + if mls != nil { + t.Logf("tc %d: mls: %v\n", k, mls.String()) + } + } +} + +func TestMergeLocalsIntegration(t *testing.T) { + testenv.MustHaveGoBuild(t) + + // This test does a build of a specific canned package to + // check whether merging of stack slots is taking place. + // The idea is to do the compile with a trace option turned + // on and then pick up on the frame offsets of specific + // variables. + // + // Stack slot merging is a greedy algorithm, and there can + // be many possible ways to overlap a given set of candidate + // variables, all of them legal. Rather than locking down + // a specific set of overlappings or frame offsets, this + // tests just verifies that there is a decent-sized clump of 4+ vars that + // get overlapped. + // + // The expected output blob we're interested might look like + // this (for amd64): + // + // =-= stack layout for ABC: + // 2: "p1" frameoff -8200 ... + // 3: "s" frameoff -8200 ... + // 4: "v2" frameoff -8200 ... + // 5: "v3" frameoff -8200 ... + // 6: "xp3" frameoff -8200 ... + // 7: "xp4" frameoff -8200 ... + // 8: "p2" frameoff -16400 ... + // 9: "r" frameoff -16408 ... + // + tmpdir := t.TempDir() + src := filepath.Join("testdata", "mergelocals", "integration.go") + obj := filepath.Join(tmpdir, "p.a") + out, err := testenv.Command(t, testenv.GoToolPath(t), "tool", "compile", + "-p=p", "-c", "1", "-o", obj, "-d=mergelocalstrace=2,mergelocals=1", + src).CombinedOutput() + if err != nil { + t.Fatalf("failed to compile: %v\n%s", err, out) + } + vars := make(map[string]string) + lines := strings.Split(string(out), "\n") + prolog := true + varsAtFrameOffset := make(map[string]int) + for _, line := range lines { + if line == "=-= stack layout for ABC:" { + prolog = false + continue + } else if prolog || line == "" { + continue + } + fields := strings.Fields(line) + wantFields := 9 + if len(fields) != wantFields { + t.Log(string(out)) + t.Fatalf("bad trace output line, wanted %d fields got %d: %s", + wantFields, len(fields), line) + } + vname := fields[1] + frameoff := fields[3] + varsAtFrameOffset[frameoff] = varsAtFrameOffset[frameoff] + 1 + vars[vname] = frameoff + } + wantvnum := 8 + gotvnum := len(vars) + if wantvnum != gotvnum { + t.Log(string(out)) + t.Fatalf("expected trace output on %d vars got %d\n", wantvnum, gotvnum) + } + + // Expect at least one clump of at least 3. + n3 := 0 + got := []int{} + for _, v := range varsAtFrameOffset { + if v > 2 { + n3++ + } + got = append(got, v) + } + sort.Ints(got) + if n3 == 0 { + t.Logf("%s\n", string(out)) + t.Fatalf("expected at least one clump of 3, got: %+v", got) + } +} diff --git a/go/src/cmd/compile/internal/test/move_test.go b/go/src/cmd/compile/internal/test/move_test.go new file mode 100644 index 0000000000000000000000000000000000000000..f361a86539142db90ababaa0baf5262633d88b38 --- /dev/null +++ b/go/src/cmd/compile/internal/test/move_test.go @@ -0,0 +1,55 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import "testing" + +var ( + n = [16]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} + m = [16]int{2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32} +) + +func TestEqual(t *testing.T) { + if r := move2(n, m, 0); r != n { + t.Fatalf("%v != %v", r, n) + } + if r := move2(n, m, 1); r != m { + t.Fatalf("%v != %v", r, m) + } + if r := move2p(n, m, 0); r != n { + t.Fatalf("%v != %v", r, n) + } + if r := move2p(n, m, 1); r != m { + t.Fatalf("%v != %v", r, m) + } +} + +//go:noinline +func move2(a, b [16]int, c int) [16]int { + e := a + f := b + var d [16]int + if c%2 == 0 { + d = e + } else { + d = f + } + r := d + return r +} + +//go:noinline +func move2p(a, b [16]int, c int) [16]int { + e := a + f := b + var p *[16]int + if c%2 == 0 { + p = &e + } else { + p = &f + } + r := *p + return r +} diff --git a/go/src/cmd/compile/internal/test/mulconst_test.go b/go/src/cmd/compile/internal/test/mulconst_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1d1b351af19640fba65795affadf91c10e421af1 --- /dev/null +++ b/go/src/cmd/compile/internal/test/mulconst_test.go @@ -0,0 +1,331 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "bytes" + "fmt" + "internal/testenv" + "os" + "path/filepath" + "strings" + "testing" +) + +func TestConstantMultiplies(t *testing.T) { + testenv.MustHaveGoRun(t) + + signs := []string{"", "u"} + widths := []int{8, 16, 32, 64} + + // Make test code. + var code bytes.Buffer + fmt.Fprintf(&code, "package main\n") + for _, b := range widths { + for _, s := range signs { + fmt.Fprintf(&code, "type test_%s%d struct {\n", s, b) + fmt.Fprintf(&code, " m %sint%d\n", s, b) + fmt.Fprintf(&code, " f func(%sint%d)%sint%d\n", s, b, s, b) + fmt.Fprintf(&code, "}\n") + fmt.Fprintf(&code, "var test_%s%ds []test_%s%d\n", s, b, s, b) + } + } + for _, b := range widths { + for _, s := range signs { + lo := -256 + hi := 256 + if b == 8 { + lo = -128 + hi = 127 + } + if s == "u" { + lo = 0 + } + for i := lo; i <= hi; i++ { + name := fmt.Sprintf("f_%s%d_%d", s, b, i) + name = strings.ReplaceAll(name, "-", "n") + fmt.Fprintf(&code, "func %s(x %sint%d) %sint%d {\n", name, s, b, s, b) + fmt.Fprintf(&code, " return x*%d\n", i) + fmt.Fprintf(&code, "}\n") + fmt.Fprintf(&code, "func init() {\n") + fmt.Fprintf(&code, " test_%s%ds = append(test_%s%ds, test_%s%d{%d, %s})\n", s, b, s, b, s, b, i, name) + fmt.Fprintf(&code, "}\n") + } + } + } + fmt.Fprintf(&code, "func main() {\n") + for _, b := range widths { + for _, s := range signs { + lo := -256 + hi := 256 + if s == "u" { + lo = 0 + } + fmt.Fprintf(&code, " for _, tst := range test_%s%ds {\n", s, b) + fmt.Fprintf(&code, " for x := %d; x <= %d; x++ {\n", lo, hi) + fmt.Fprintf(&code, " y := %sint%d(x)\n", s, b) + fmt.Fprintf(&code, " if tst.f(y) != y*tst.m {\n") + fmt.Fprintf(&code, " panic(tst.m)\n") + fmt.Fprintf(&code, " }\n") + fmt.Fprintf(&code, " }\n") + fmt.Fprintf(&code, " }\n") + } + } + fmt.Fprintf(&code, "}\n") + + fmt.Printf("CODE:\n%s\n", string(code.Bytes())) + + // Make test file + tmpdir := t.TempDir() + src := filepath.Join(tmpdir, "x.go") + err := os.WriteFile(src, code.Bytes(), 0644) + if err != nil { + t.Fatalf("write file failed: %v", err) + } + + cmd := testenv.Command(t, testenv.GoToolPath(t), "run", src) + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("go run failed: %v\n%s", err, out) + } + if len(out) > 0 { + t.Fatalf("got output when expecting none: %s\n", string(out)) + } +} + +// Benchmark multiplication of an integer by various constants. +// +// The comment above each sub-benchmark provides an example of how the +// target multiplication operation might be implemented using shift +// (multiplication by a power of 2), addition and subtraction +// operations. It is platform-dependent whether these transformations +// are actually applied. + +var ( + mulSinkI32 int32 + mulSinkI64 int64 + mulSinkU32 uint32 + mulSinkU64 uint64 +) + +func BenchmarkMulconstI32(b *testing.B) { + // 3x = 2x + x + b.Run("3", func(b *testing.B) { + x := int32(1) + for i := 0; i < b.N; i++ { + x *= 3 + } + mulSinkI32 = x + }) + // 5x = 4x + x + b.Run("5", func(b *testing.B) { + x := int32(1) + for i := 0; i < b.N; i++ { + x *= 5 + } + mulSinkI32 = x + }) + // 12x = 8x + 4x + b.Run("12", func(b *testing.B) { + x := int32(1) + for i := 0; i < b.N; i++ { + x *= 12 + } + mulSinkI32 = x + }) + // 120x = 128x - 8x + b.Run("120", func(b *testing.B) { + x := int32(1) + for i := 0; i < b.N; i++ { + x *= 120 + } + mulSinkI32 = x + }) + // -120x = 8x - 128x + b.Run("-120", func(b *testing.B) { + x := int32(1) + for i := 0; i < b.N; i++ { + x *= -120 + } + mulSinkI32 = x + }) + // 65537x = 65536x + x + b.Run("65537", func(b *testing.B) { + x := int32(1) + for i := 0; i < b.N; i++ { + x *= 65537 + } + mulSinkI32 = x + }) + // 65538x = 65536x + 2x + b.Run("65538", func(b *testing.B) { + x := int32(1) + for i := 0; i < b.N; i++ { + x *= 65538 + } + mulSinkI32 = x + }) +} + +func BenchmarkMulconstI64(b *testing.B) { + // 3x = 2x + x + b.Run("3", func(b *testing.B) { + x := int64(1) + for i := 0; i < b.N; i++ { + x *= 3 + } + mulSinkI64 = x + }) + // 5x = 4x + x + b.Run("5", func(b *testing.B) { + x := int64(1) + for i := 0; i < b.N; i++ { + x *= 5 + } + mulSinkI64 = x + }) + // 12x = 8x + 4x + b.Run("12", func(b *testing.B) { + x := int64(1) + for i := 0; i < b.N; i++ { + x *= 12 + } + mulSinkI64 = x + }) + // 120x = 128x - 8x + b.Run("120", func(b *testing.B) { + x := int64(1) + for i := 0; i < b.N; i++ { + x *= 120 + } + mulSinkI64 = x + }) + // -120x = 8x - 128x + b.Run("-120", func(b *testing.B) { + x := int64(1) + for i := 0; i < b.N; i++ { + x *= -120 + } + mulSinkI64 = x + }) + // 65537x = 65536x + x + b.Run("65537", func(b *testing.B) { + x := int64(1) + for i := 0; i < b.N; i++ { + x *= 65537 + } + mulSinkI64 = x + }) + // 65538x = 65536x + 2x + b.Run("65538", func(b *testing.B) { + x := int64(1) + for i := 0; i < b.N; i++ { + x *= 65538 + } + mulSinkI64 = x + }) +} + +func BenchmarkMulconstU32(b *testing.B) { + // 3x = 2x + x + b.Run("3", func(b *testing.B) { + x := uint32(1) + for i := 0; i < b.N; i++ { + x *= 3 + } + mulSinkU32 = x + }) + // 5x = 4x + x + b.Run("5", func(b *testing.B) { + x := uint32(1) + for i := 0; i < b.N; i++ { + x *= 5 + } + mulSinkU32 = x + }) + // 12x = 8x + 4x + b.Run("12", func(b *testing.B) { + x := uint32(1) + for i := 0; i < b.N; i++ { + x *= 12 + } + mulSinkU32 = x + }) + // 120x = 128x - 8x + b.Run("120", func(b *testing.B) { + x := uint32(1) + for i := 0; i < b.N; i++ { + x *= 120 + } + mulSinkU32 = x + }) + // 65537x = 65536x + x + b.Run("65537", func(b *testing.B) { + x := uint32(1) + for i := 0; i < b.N; i++ { + x *= 65537 + } + mulSinkU32 = x + }) + // 65538x = 65536x + 2x + b.Run("65538", func(b *testing.B) { + x := uint32(1) + for i := 0; i < b.N; i++ { + x *= 65538 + } + mulSinkU32 = x + }) +} + +func BenchmarkMulconstU64(b *testing.B) { + // 3x = 2x + x + b.Run("3", func(b *testing.B) { + x := uint64(1) + for i := 0; i < b.N; i++ { + x *= 3 + } + mulSinkU64 = x + }) + // 5x = 4x + x + b.Run("5", func(b *testing.B) { + x := uint64(1) + for i := 0; i < b.N; i++ { + x *= 5 + } + mulSinkU64 = x + }) + // 12x = 8x + 4x + b.Run("12", func(b *testing.B) { + x := uint64(1) + for i := 0; i < b.N; i++ { + x *= 12 + } + mulSinkU64 = x + }) + // 120x = 128x - 8x + b.Run("120", func(b *testing.B) { + x := uint64(1) + for i := 0; i < b.N; i++ { + x *= 120 + } + mulSinkU64 = x + }) + // 65537x = 65536x + x + b.Run("65537", func(b *testing.B) { + x := uint64(1) + for i := 0; i < b.N; i++ { + x *= 65537 + } + mulSinkU64 = x + }) + // 65538x = 65536x + 2x + b.Run("65538", func(b *testing.B) { + x := uint64(1) + for i := 0; i < b.N; i++ { + x *= 65538 + } + mulSinkU64 = x + }) +} diff --git a/go/src/cmd/compile/internal/test/pgo_devirtualize_test.go b/go/src/cmd/compile/internal/test/pgo_devirtualize_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a97a5799fc72c5ad1f125bba1eb0d83ff9bc9ff4 --- /dev/null +++ b/go/src/cmd/compile/internal/test/pgo_devirtualize_test.go @@ -0,0 +1,370 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "bufio" + "fmt" + "internal/testenv" + "os" + "path/filepath" + "regexp" + "testing" +) + +type devirtualization struct { + pos string + callee string +} + +const profFileName = "devirt.pprof" +const preProfFileName = "devirt.pprof.node_map" + +// testPGODevirtualize tests that specific PGO devirtualize rewrites are performed. +func testPGODevirtualize(t *testing.T, dir string, want, nowant []devirtualization, pgoProfileName string) { + testenv.MustHaveGoRun(t) + t.Parallel() + + const pkg = "example.com/pgo/devirtualize" + + // Add a go.mod so we have a consistent symbol names in this temp dir. + goMod := fmt.Sprintf(`module %s +go 1.21 +`, pkg) + if err := os.WriteFile(filepath.Join(dir, "go.mod"), []byte(goMod), 0644); err != nil { + t.Fatalf("error writing go.mod: %v", err) + } + + // Run the test without PGO to ensure that the test assertions are + // correct even in the non-optimized version. + cmd := testenv.CleanCmdEnv(testenv.Command(t, testenv.GoToolPath(t), "test", ".")) + cmd.Dir = dir + b, err := cmd.CombinedOutput() + t.Logf("Test without PGO:\n%s", b) + if err != nil { + t.Fatalf("Test failed without PGO: %v", err) + } + + // Build the test with the profile. + pprof := filepath.Join(dir, pgoProfileName) + gcflag := fmt.Sprintf("-gcflags=-m=2 -pgoprofile=%s -d=pgodebug=3", pprof) + out := filepath.Join(dir, "test.exe") + cmd = testenv.CleanCmdEnv(testenv.Command(t, testenv.GoToolPath(t), "test", "-o", out, gcflag, ".")) + cmd.Dir = dir + + pr, pw, err := os.Pipe() + if err != nil { + t.Fatalf("error creating pipe: %v", err) + } + defer pr.Close() + cmd.Stdout = pw + cmd.Stderr = pw + + err = cmd.Start() + pw.Close() + if err != nil { + t.Fatalf("error starting go test: %v", err) + } + + got := make(map[devirtualization]struct{}) + gotNoHot := make(map[devirtualization]struct{}) + + devirtualizedLine := regexp.MustCompile(`(.*): PGO devirtualizing \w+ call .* to (.*)`) + noHotLine := regexp.MustCompile(`(.*): call .*: no hot callee`) + + scanner := bufio.NewScanner(pr) + for scanner.Scan() { + line := scanner.Text() + t.Logf("child: %s", line) + + m := devirtualizedLine.FindStringSubmatch(line) + if m != nil { + d := devirtualization{ + pos: m[1], + callee: m[2], + } + got[d] = struct{}{} + continue + } + m = noHotLine.FindStringSubmatch(line) + if m != nil { + d := devirtualization{ + pos: m[1], + } + gotNoHot[d] = struct{}{} + } + } + if err := cmd.Wait(); err != nil { + t.Fatalf("error running go test: %v", err) + } + if err := scanner.Err(); err != nil { + t.Fatalf("error reading go test output: %v", err) + } + + if len(got) != len(want) { + t.Errorf("mismatched devirtualization count; got %v want %v", got, want) + } + for _, w := range want { + if _, ok := got[w]; ok { + continue + } + t.Errorf("devirtualization %v missing; got %v", w, got) + } + for _, nw := range nowant { + if _, ok := gotNoHot[nw]; !ok { + t.Errorf("unwanted devirtualization %v; got %v", nw, got) + } + } + + // Run test with PGO to ensure the assertions are still true. + cmd = testenv.CleanCmdEnv(testenv.Command(t, out)) + cmd.Dir = dir + b, err = cmd.CombinedOutput() + t.Logf("Test with PGO:\n%s", b) + if err != nil { + t.Fatalf("Test failed without PGO: %v", err) + } +} + +// TestPGODevirtualize tests that specific functions are devirtualized when PGO +// is applied to the exact source that was profiled. +func TestPGODevirtualize(t *testing.T) { + wd, err := os.Getwd() + if err != nil { + t.Fatalf("error getting wd: %v", err) + } + srcDir := filepath.Join(wd, "testdata", "pgo", "devirtualize") + + // Copy the module to a scratch location so we can add a go.mod. + dir := t.TempDir() + if err := os.Mkdir(filepath.Join(dir, "mult.pkg"), 0755); err != nil { + t.Fatalf("error creating dir: %v", err) + } + for _, file := range []string{"devirt.go", "devirt_test.go", profFileName, filepath.Join("mult.pkg", "mult.go")} { + if err := copyFile(filepath.Join(dir, file), filepath.Join(srcDir, file)); err != nil { + t.Fatalf("error copying %s: %v", file, err) + } + } + + want := []devirtualization{ + // ExerciseIface + { + pos: "./devirt.go:101:20", + callee: "mult.Mult.Multiply", + }, + { + pos: "./devirt.go:101:39", + callee: "Add.Add", + }, + // ExerciseFuncConcrete + { + pos: "./devirt.go:173:36", + callee: "AddFn", + }, + { + pos: "./devirt.go:173:15", + callee: "mult.MultFn", + }, + // ExerciseFuncField + { + pos: "./devirt.go:207:35", + callee: "AddFn", + }, + { + pos: "./devirt.go:207:19", + callee: "mult.MultFn", + }, + // ExerciseFuncClosure + // TODO(prattmic): Closure callees not implemented. + //{ + // pos: "./devirt.go:249:27", + // callee: "AddClosure.func1", + //}, + //{ + // pos: "./devirt.go:249:15", + // callee: "mult.MultClosure.func1", + //}, + } + nowant := []devirtualization{ + // ExerciseIfaceZeroWeight + { + pos: "./devirt.go:256:29", + }, + // ExerciseIndirCallZeroWeight + { + pos: "./devirt.go:282:37", + }, + } + + testPGODevirtualize(t, dir, want, nowant, profFileName) +} + +// TestPGOPreprocessDevirtualize tests that specific functions are devirtualized when PGO +// is applied to the exact source that was profiled. The input profile is PGO preprocessed file. +func TestPGOPreprocessDevirtualize(t *testing.T) { + wd, err := os.Getwd() + if err != nil { + t.Fatalf("error getting wd: %v", err) + } + srcDir := filepath.Join(wd, "testdata", "pgo", "devirtualize") + + // Copy the module to a scratch location so we can add a go.mod. + dir := t.TempDir() + if err := os.Mkdir(filepath.Join(dir, "mult.pkg"), 0755); err != nil { + t.Fatalf("error creating dir: %v", err) + } + for _, file := range []string{"devirt.go", "devirt_test.go", preProfFileName, filepath.Join("mult.pkg", "mult.go")} { + if err := copyFile(filepath.Join(dir, file), filepath.Join(srcDir, file)); err != nil { + t.Fatalf("error copying %s: %v", file, err) + } + } + + want := []devirtualization{ + // ExerciseIface + { + pos: "./devirt.go:101:20", + callee: "mult.Mult.Multiply", + }, + { + pos: "./devirt.go:101:39", + callee: "Add.Add", + }, + // ExerciseFuncConcrete + { + pos: "./devirt.go:173:36", + callee: "AddFn", + }, + { + pos: "./devirt.go:173:15", + callee: "mult.MultFn", + }, + // ExerciseFuncField + { + pos: "./devirt.go:207:35", + callee: "AddFn", + }, + { + pos: "./devirt.go:207:19", + callee: "mult.MultFn", + }, + // ExerciseFuncClosure + // TODO(prattmic): Closure callees not implemented. + //{ + // pos: "./devirt.go:249:27", + // callee: "AddClosure.func1", + //}, + //{ + // pos: "./devirt.go:249:15", + // callee: "mult.MultClosure.func1", + //}, + } + nowant := []devirtualization{ + // ExerciseIfaceZeroWeight + { + pos: "./devirt.go:256:29", + }, + // ExerciseIndirCallZeroWeight + { + pos: "./devirt.go:282:37", + }, + } + + testPGODevirtualize(t, dir, want, nowant, preProfFileName) +} + +// Regression test for https://go.dev/issue/65615. If a target function changes +// from non-generic to generic we can't devirtualize it (don't know the type +// parameters), but the compiler should not crash. +func TestLookupFuncGeneric(t *testing.T) { + wd, err := os.Getwd() + if err != nil { + t.Fatalf("error getting wd: %v", err) + } + srcDir := filepath.Join(wd, "testdata", "pgo", "devirtualize") + + // Copy the module to a scratch location so we can add a go.mod. + dir := t.TempDir() + if err := os.Mkdir(filepath.Join(dir, "mult.pkg"), 0755); err != nil { + t.Fatalf("error creating dir: %v", err) + } + for _, file := range []string{"devirt.go", "devirt_test.go", profFileName, filepath.Join("mult.pkg", "mult.go")} { + if err := copyFile(filepath.Join(dir, file), filepath.Join(srcDir, file)); err != nil { + t.Fatalf("error copying %s: %v", file, err) + } + } + + // Change MultFn from a concrete function to a parameterized function. + if err := convertMultToGeneric(filepath.Join(dir, "mult.pkg", "mult.go")); err != nil { + t.Fatalf("error editing mult.go: %v", err) + } + + // Same as TestPGODevirtualize except for MultFn, which we cannot + // devirtualize to because it has become generic. + // + // Note that the important part of this test is that the build is + // successful, not the specific devirtualizations. + want := []devirtualization{ + // ExerciseIface + { + pos: "./devirt.go:101:20", + callee: "mult.Mult.Multiply", + }, + { + pos: "./devirt.go:101:39", + callee: "Add.Add", + }, + // ExerciseFuncConcrete + { + pos: "./devirt.go:173:36", + callee: "AddFn", + }, + // ExerciseFuncField + { + pos: "./devirt.go:207:35", + callee: "AddFn", + }, + // ExerciseFuncClosure + // TODO(prattmic): Closure callees not implemented. + //{ + // pos: "./devirt.go:249:27", + // callee: "AddClosure.func1", + //}, + //{ + // pos: "./devirt.go:249:15", + // callee: "mult.MultClosure.func1", + //}, + } + nowant := []devirtualization{ + // ExerciseIfaceZeroWeight + { + pos: "./devirt.go:256:29", + }, + // ExerciseIndirCallZeroWeight + { + pos: "./devirt.go:282:37", + }, + } + + testPGODevirtualize(t, dir, want, nowant, profFileName) +} + +var multFnRe = regexp.MustCompile(`func MultFn\(a, b int64\) int64`) + +func convertMultToGeneric(path string) error { + content, err := os.ReadFile(path) + if err != nil { + return fmt.Errorf("error opening: %w", err) + } + + if !multFnRe.Match(content) { + return fmt.Errorf("MultFn not found; update regexp?") + } + + // Users of MultFn shouldn't need adjustment, type inference should + // work OK. + content = multFnRe.ReplaceAll(content, []byte(`func MultFn[T int32|int64](a, b T) T`)) + + return os.WriteFile(path, content, 0644) +} diff --git a/go/src/cmd/compile/internal/test/pgo_inl_test.go b/go/src/cmd/compile/internal/test/pgo_inl_test.go new file mode 100644 index 0000000000000000000000000000000000000000..0859431b029edf35b568c28f67f4cd276de504fc --- /dev/null +++ b/go/src/cmd/compile/internal/test/pgo_inl_test.go @@ -0,0 +1,367 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "bufio" + "bytes" + "fmt" + "internal/profile" + "internal/testenv" + "io" + "os" + "path/filepath" + "regexp" + "strings" + "testing" +) + +const profFile = "inline_hot.pprof" +const preProfFile = "inline_hot.pprof.node_map" + +func buildPGOInliningTest(t *testing.T, dir string, gcflag string) []byte { + const pkg = "example.com/pgo/inline" + + // Add a go.mod so we have a consistent symbol names in this temp dir. + goMod := fmt.Sprintf(`module %s +go 1.19 +`, pkg) + if err := os.WriteFile(filepath.Join(dir, "go.mod"), []byte(goMod), 0644); err != nil { + t.Fatalf("error writing go.mod: %v", err) + } + + exe := filepath.Join(dir, "test.exe") + args := []string{"test", "-c", "-o", exe, "-gcflags=" + gcflag} + cmd := testenv.Command(t, testenv.GoToolPath(t), args...) + cmd.Dir = dir + cmd = testenv.CleanCmdEnv(cmd) + t.Log(cmd) + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("build failed: %v, output:\n%s", err, out) + } + return out +} + +// testPGOIntendedInlining tests that specific functions are inlined. +func testPGOIntendedInlining(t *testing.T, dir string, profFile string) { + testenv.MustHaveGoRun(t) + t.Parallel() + + const pkg = "example.com/pgo/inline" + + want := []string{ + "(*BS).NS", + } + + // The functions which are not expected to be inlined are as follows. + wantNot := []string{ + // The calling edge main->A is hot and the cost of A is large + // than inlineHotCalleeMaxBudget. + "A", + // The calling edge BenchmarkA" -> benchmarkB is cold and the + // cost of A is large than inlineMaxBudget. + "benchmarkB", + } + + must := map[string]bool{ + "(*BS).NS": true, + } + + notInlinedReason := make(map[string]string) + for _, fname := range want { + fullName := pkg + "." + fname + if _, ok := notInlinedReason[fullName]; ok { + t.Errorf("duplicate func: %s", fullName) + } + notInlinedReason[fullName] = "unknown reason" + } + + // If the compiler emit "cannot inline for function A", the entry A + // in expectedNotInlinedList will be removed. + expectedNotInlinedList := make(map[string]struct{}) + for _, fname := range wantNot { + fullName := pkg + "." + fname + expectedNotInlinedList[fullName] = struct{}{} + } + + // Build the test with the profile. Use a smaller threshold to test. + // TODO: maybe adjust the test to work with default threshold. + gcflag := fmt.Sprintf("-m -m -pgoprofile=%s -d=pgoinlinebudget=160,pgoinlinecdfthreshold=90", profFile) + out := buildPGOInliningTest(t, dir, gcflag) + + scanner := bufio.NewScanner(bytes.NewReader(out)) + curPkg := "" + canInline := regexp.MustCompile(`: can inline ([^ ]*)`) + haveInlined := regexp.MustCompile(`: inlining call to ([^ ]*)`) + cannotInline := regexp.MustCompile(`: cannot inline ([^ ]*): (.*)`) + for scanner.Scan() { + line := scanner.Text() + t.Logf("child: %s", line) + if strings.HasPrefix(line, "# ") { + curPkg = line[2:] + splits := strings.Split(curPkg, " ") + curPkg = splits[0] + continue + } + if m := haveInlined.FindStringSubmatch(line); m != nil { + fname := m[1] + delete(notInlinedReason, curPkg+"."+fname) + continue + } + if m := canInline.FindStringSubmatch(line); m != nil { + fname := m[1] + fullname := curPkg + "." + fname + // If function must be inlined somewhere, being inlinable is not enough + if _, ok := must[fullname]; !ok { + delete(notInlinedReason, fullname) + continue + } + } + if m := cannotInline.FindStringSubmatch(line); m != nil { + fname, reason := m[1], m[2] + fullName := curPkg + "." + fname + if _, ok := notInlinedReason[fullName]; ok { + // cmd/compile gave us a reason why + notInlinedReason[fullName] = reason + } + delete(expectedNotInlinedList, fullName) + continue + } + } + if err := scanner.Err(); err != nil { + t.Fatalf("error reading output: %v", err) + } + for fullName, reason := range notInlinedReason { + t.Errorf("%s was not inlined: %s", fullName, reason) + } + + // If the list expectedNotInlinedList is not empty, it indicates + // the functions in the expectedNotInlinedList are marked with caninline. + for fullName, _ := range expectedNotInlinedList { + t.Errorf("%s was expected not inlined", fullName) + } +} + +// TestPGOIntendedInlining tests that specific functions are inlined when PGO +// is applied to the exact source that was profiled. +func TestPGOIntendedInlining(t *testing.T) { + wd, err := os.Getwd() + if err != nil { + t.Fatalf("error getting wd: %v", err) + } + srcDir := filepath.Join(wd, "testdata/pgo/inline") + + // Copy the module to a scratch location so we can add a go.mod. + dir := t.TempDir() + + for _, file := range []string{"inline_hot.go", "inline_hot_test.go", profFile} { + if err := copyFile(filepath.Join(dir, file), filepath.Join(srcDir, file)); err != nil { + t.Fatalf("error copying %s: %v", file, err) + } + } + + testPGOIntendedInlining(t, dir, profFile) +} + +// TestPGOPreprocessInlining tests that specific functions are inlined when PGO +// is applied to the exact source that was profiled. +func TestPGOPreprocessInlining(t *testing.T) { + wd, err := os.Getwd() + if err != nil { + t.Fatalf("error getting wd: %v", err) + } + srcDir := filepath.Join(wd, "testdata/pgo/inline") + + // Copy the module to a scratch location so we can add a go.mod. + dir := t.TempDir() + + for _, file := range []string{"inline_hot.go", "inline_hot_test.go", preProfFile} { + if err := copyFile(filepath.Join(dir, file), filepath.Join(srcDir, file)); err != nil { + t.Fatalf("error copying %s: %v", file, err) + } + } + + testPGOIntendedInlining(t, dir, preProfFile) +} + +// TestPGOIntendedInliningShiftedLines tests that specific functions are inlined when PGO +// is applied to the modified source. +func TestPGOIntendedInliningShiftedLines(t *testing.T) { + wd, err := os.Getwd() + if err != nil { + t.Fatalf("error getting wd: %v", err) + } + srcDir := filepath.Join(wd, "testdata/pgo/inline") + + // Copy the module to a scratch location so we can modify the source. + dir := t.TempDir() + + // Copy most of the files unmodified. + for _, file := range []string{"inline_hot_test.go", profFile} { + if err := copyFile(filepath.Join(dir, file), filepath.Join(srcDir, file)); err != nil { + t.Fatalf("error copying %s : %v", file, err) + } + } + + // Add some comments to the top of inline_hot.go. This adjusts the line + // numbers of all of the functions without changing the semantics. + src, err := os.Open(filepath.Join(srcDir, "inline_hot.go")) + if err != nil { + t.Fatalf("error opening src inline_hot.go: %v", err) + } + defer src.Close() + + dst, err := os.Create(filepath.Join(dir, "inline_hot.go")) + if err != nil { + t.Fatalf("error creating dst inline_hot.go: %v", err) + } + defer dst.Close() + + if _, err := io.WriteString(dst, `// Autogenerated +// Lines +`); err != nil { + t.Fatalf("error writing comments to dst: %v", err) + } + + if _, err := io.Copy(dst, src); err != nil { + t.Fatalf("error copying inline_hot.go: %v", err) + } + + dst.Close() + + testPGOIntendedInlining(t, dir, profFile) +} + +// TestPGOSingleIndex tests that the sample index can not be 1 and compilation +// will not fail. All it should care about is that the sample type is either +// CPU nanoseconds or samples count, whichever it finds first. +func TestPGOSingleIndex(t *testing.T) { + for _, tc := range []struct { + originalIndex int + }{{ + // The `testdata/pgo/inline/inline_hot.pprof` file is a standard CPU + // profile as the runtime would generate. The 0 index contains the + // value-type samples and value-unit count. The 1 index contains the + // value-type cpu and value-unit nanoseconds. These tests ensure that + // the compiler can work with profiles that only have a single index, + // but are either samples count or CPU nanoseconds. + originalIndex: 0, + }, { + originalIndex: 1, + }} { + t.Run(fmt.Sprintf("originalIndex=%d", tc.originalIndex), func(t *testing.T) { + wd, err := os.Getwd() + if err != nil { + t.Fatalf("error getting wd: %v", err) + } + srcDir := filepath.Join(wd, "testdata/pgo/inline") + + // Copy the module to a scratch location so we can add a go.mod. + dir := t.TempDir() + + originalPprofFile, err := os.Open(filepath.Join(srcDir, profFile)) + if err != nil { + t.Fatalf("error opening %v: %v", profFile, err) + } + defer originalPprofFile.Close() + + p, err := profile.Parse(originalPprofFile) + if err != nil { + t.Fatalf("error parsing %v: %v", profFile, err) + } + + // Move the samples count value-type to the 0 index. + p.SampleType = []*profile.ValueType{p.SampleType[tc.originalIndex]} + + // Ensure we only have a single set of sample values. + for _, s := range p.Sample { + s.Value = []int64{s.Value[tc.originalIndex]} + } + + modifiedPprofFile, err := os.Create(filepath.Join(dir, profFile)) + if err != nil { + t.Fatalf("error creating %v: %v", profFile, err) + } + defer modifiedPprofFile.Close() + + if err := p.Write(modifiedPprofFile); err != nil { + t.Fatalf("error writing %v: %v", profFile, err) + } + + for _, file := range []string{"inline_hot.go", "inline_hot_test.go"} { + if err := copyFile(filepath.Join(dir, file), filepath.Join(srcDir, file)); err != nil { + t.Fatalf("error copying %s: %v", file, err) + } + } + + testPGOIntendedInlining(t, dir, profFile) + }) + } +} + +func copyFile(dst, src string) error { + s, err := os.Open(src) + if err != nil { + return err + } + defer s.Close() + + d, err := os.Create(dst) + if err != nil { + return err + } + defer d.Close() + + _, err = io.Copy(d, s) + return err +} + +// TestPGOHash tests that PGO optimization decisions can be selected by pgohash. +func TestPGOHash(t *testing.T) { + testenv.MustHaveGoRun(t) + t.Parallel() + + const pkg = "example.com/pgo/inline" + + wd, err := os.Getwd() + if err != nil { + t.Fatalf("error getting wd: %v", err) + } + srcDir := filepath.Join(wd, "testdata/pgo/inline") + + // Copy the module to a scratch location so we can add a go.mod. + dir := t.TempDir() + + for _, file := range []string{"inline_hot.go", "inline_hot_test.go", profFile} { + if err := copyFile(filepath.Join(dir, file), filepath.Join(srcDir, file)); err != nil { + t.Fatalf("error copying %s: %v", file, err) + } + } + + pprof := filepath.Join(dir, profFile) + // build with -trimpath so the source location (thus the hash) + // does not depend on the temporary directory path. + gcflag0 := fmt.Sprintf("-pgoprofile=%s -trimpath %s=>%s -d=pgoinlinebudget=160,pgoinlinecdfthreshold=90,pgodebug=1", pprof, dir, pkg) + + // Check that a hash match allows PGO inlining. + const srcPos = "example.com/pgo/inline/inline_hot.go:81:19" + const hashMatch = "pgohash triggered " + srcPos + " (inline)" + pgoDebugRE := regexp.MustCompile(`hot-budget check allows inlining for call .* at ` + strings.ReplaceAll(srcPos, ".", "\\.")) + hash := "v1" // 1 matches srcPos, v for verbose (print source location) + gcflag := gcflag0 + ",pgohash=" + hash + out := buildPGOInliningTest(t, dir, gcflag) + if !bytes.Contains(out, []byte(hashMatch)) || !pgoDebugRE.Match(out) { + t.Errorf("output does not contain expected source line, out:\n%s", out) + } + + // Check that a hash mismatch turns off PGO inlining. + hash = "v0" // 0 should not match srcPos + gcflag = gcflag0 + ",pgohash=" + hash + out = buildPGOInliningTest(t, dir, gcflag) + if bytes.Contains(out, []byte(hashMatch)) || pgoDebugRE.Match(out) { + t.Errorf("output contains unexpected source line, out:\n%s", out) + } +} diff --git a/go/src/cmd/compile/internal/test/race.go b/go/src/cmd/compile/internal/test/race.go new file mode 100644 index 0000000000000000000000000000000000000000..b7215382eb2a21a56b5143c85c9d0a37c559de9d --- /dev/null +++ b/go/src/cmd/compile/internal/test/race.go @@ -0,0 +1,64 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !compiler_bootstrap + +package test + +// The racecompile builder only builds packages, but does not build +// or run tests. This is a non-test file to hold cases that (used +// to) trigger compiler data races, so they will be exercised on +// the racecompile builder. +// +// This package is not imported so functions here are not included +// in the actual compiler. + +// Issue 55357: data race when building multiple instantiations of +// generic closures with _ parameters. +func Issue55357() { + type U struct { + A int + B string + C string + } + var q T55357[U] + q.Count() + q.List() + + type M struct { + A int64 + B uint32 + C uint32 + } + var q2 T55357[M] + q2.Count() + q2.List() +} + +type T55357[T any] struct{} + +//go:noinline +func (q *T55357[T]) do(w, v bool, fn func(bk []byte, v T) error) error { + return nil +} + +func (q *T55357[T]) Count() (n int, rerr error) { + err := q.do(false, false, func(kb []byte, _ T) error { + n++ + return nil + }) + return n, err +} + +func (q *T55357[T]) List() (list []T, rerr error) { + var l []T + err := q.do(false, true, func(_ []byte, v T) error { + l = append(l, v) + return nil + }) + if err != nil { + return nil, err + } + return l, nil +} diff --git a/go/src/cmd/compile/internal/test/reproduciblebuilds_test.go b/go/src/cmd/compile/internal/test/reproduciblebuilds_test.go new file mode 100644 index 0000000000000000000000000000000000000000..466e0c3a38ae1b31236330d4220b3c18aa17bafd --- /dev/null +++ b/go/src/cmd/compile/internal/test/reproduciblebuilds_test.go @@ -0,0 +1,106 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "bytes" + "internal/testenv" + "os" + "path/filepath" + "testing" +) + +func TestReproducibleBuilds(t *testing.T) { + tests := []string{ + "issue20272.go", + "issue27013.go", + "issue30202.go", + } + + testenv.MustHaveGoBuild(t) + iters := 10 + if testing.Short() { + iters = 4 + } + t.Parallel() + for _, test := range tests { + test := test + t.Run(test, func(t *testing.T) { + t.Parallel() + var want []byte + tmp, err := os.CreateTemp("", "") + if err != nil { + t.Fatalf("temp file creation failed: %v", err) + } + defer os.Remove(tmp.Name()) + defer tmp.Close() + for i := 0; i < iters; i++ { + // Note: use -c 2 to expose any nondeterminism which is the result + // of the runtime scheduler. + out, err := testenv.Command(t, testenv.GoToolPath(t), "tool", "compile", "-p=p", "-c", "2", "-o", tmp.Name(), filepath.Join("testdata", "reproducible", test)).CombinedOutput() + if err != nil { + t.Fatalf("failed to compile: %v\n%s", err, out) + } + obj, err := os.ReadFile(tmp.Name()) + if err != nil { + t.Fatalf("failed to read object file: %v", err) + } + if i == 0 { + want = obj + } else { + if !bytes.Equal(want, obj) { + t.Fatalf("builds produced different output after %d iters (%d bytes vs %d bytes)", i, len(want), len(obj)) + } + } + } + }) + } +} + +func TestIssue38068(t *testing.T) { + testenv.MustHaveGoBuild(t) + t.Parallel() + + // Compile a small package with and without the concurrent + // backend, then check to make sure that the resulting archives + // are identical. Note: this uses "go tool compile" instead of + // "go build" since the latter will generate different build IDs + // if it sees different command line flags. + scenarios := []struct { + tag string + args string + libpath string + }{ + {tag: "serial", args: "-c=1"}, + {tag: "concurrent", args: "-c=2"}} + + tmpdir := t.TempDir() + + src := filepath.Join("testdata", "reproducible", "issue38068.go") + for i := range scenarios { + s := &scenarios[i] + s.libpath = filepath.Join(tmpdir, s.tag+".a") + // Note: use of "-p" required in order for DWARF to be generated. + cmd := testenv.Command(t, testenv.GoToolPath(t), "tool", "compile", "-p=issue38068", "-buildid=", s.args, "-o", s.libpath, src) + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("%v: %v:\n%s", cmd.Args, err, out) + } + } + + readBytes := func(fn string) []byte { + payload, err := os.ReadFile(fn) + if err != nil { + t.Fatalf("failed to read executable '%s': %v", fn, err) + } + return payload + } + + b1 := readBytes(scenarios[0].libpath) + b2 := readBytes(scenarios[1].libpath) + if !bytes.Equal(b1, b2) { + t.Fatalf("concurrent and serial builds produced different output") + } +} diff --git a/go/src/cmd/compile/internal/test/shift_test.go b/go/src/cmd/compile/internal/test/shift_test.go new file mode 100644 index 0000000000000000000000000000000000000000..d540f25c73a217eeef207fc0d18daff55c9a4fe9 --- /dev/null +++ b/go/src/cmd/compile/internal/test/shift_test.go @@ -0,0 +1,1355 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "math/bits" + "reflect" + "testing" +) + +// Tests shifts of zero. + +//go:noinline +func ofz64l64(n uint64) int64 { + var x int64 + return x << n +} + +//go:noinline +func ofz64l32(n uint32) int64 { + var x int64 + return x << n +} + +//go:noinline +func ofz64l16(n uint16) int64 { + var x int64 + return x << n +} + +//go:noinline +func ofz64l8(n uint8) int64 { + var x int64 + return x << n +} + +//go:noinline +func ofz64r64(n uint64) int64 { + var x int64 + return x >> n +} + +//go:noinline +func ofz64r32(n uint32) int64 { + var x int64 + return x >> n +} + +//go:noinline +func ofz64r16(n uint16) int64 { + var x int64 + return x >> n +} + +//go:noinline +func ofz64r8(n uint8) int64 { + var x int64 + return x >> n +} + +//go:noinline +func ofz64ur64(n uint64) uint64 { + var x uint64 + return x >> n +} + +//go:noinline +func ofz64ur32(n uint32) uint64 { + var x uint64 + return x >> n +} + +//go:noinline +func ofz64ur16(n uint16) uint64 { + var x uint64 + return x >> n +} + +//go:noinline +func ofz64ur8(n uint8) uint64 { + var x uint64 + return x >> n +} + +//go:noinline +func ofz32l64(n uint64) int32 { + var x int32 + return x << n +} + +//go:noinline +func ofz32l32(n uint32) int32 { + var x int32 + return x << n +} + +//go:noinline +func ofz32l16(n uint16) int32 { + var x int32 + return x << n +} + +//go:noinline +func ofz32l8(n uint8) int32 { + var x int32 + return x << n +} + +//go:noinline +func ofz32r64(n uint64) int32 { + var x int32 + return x >> n +} + +//go:noinline +func ofz32r32(n uint32) int32 { + var x int32 + return x >> n +} + +//go:noinline +func ofz32r16(n uint16) int32 { + var x int32 + return x >> n +} + +//go:noinline +func ofz32r8(n uint8) int32 { + var x int32 + return x >> n +} + +//go:noinline +func ofz32ur64(n uint64) uint32 { + var x uint32 + return x >> n +} + +//go:noinline +func ofz32ur32(n uint32) uint32 { + var x uint32 + return x >> n +} + +//go:noinline +func ofz32ur16(n uint16) uint32 { + var x uint32 + return x >> n +} + +//go:noinline +func ofz32ur8(n uint8) uint32 { + var x uint32 + return x >> n +} + +//go:noinline +func ofz16l64(n uint64) int16 { + var x int16 + return x << n +} + +//go:noinline +func ofz16l32(n uint32) int16 { + var x int16 + return x << n +} + +//go:noinline +func ofz16l16(n uint16) int16 { + var x int16 + return x << n +} + +//go:noinline +func ofz16l8(n uint8) int16 { + var x int16 + return x << n +} + +//go:noinline +func ofz16r64(n uint64) int16 { + var x int16 + return x >> n +} + +//go:noinline +func ofz16r32(n uint32) int16 { + var x int16 + return x >> n +} + +//go:noinline +func ofz16r16(n uint16) int16 { + var x int16 + return x >> n +} + +//go:noinline +func ofz16r8(n uint8) int16 { + var x int16 + return x >> n +} + +//go:noinline +func ofz16ur64(n uint64) uint16 { + var x uint16 + return x >> n +} + +//go:noinline +func ofz16ur32(n uint32) uint16 { + var x uint16 + return x >> n +} + +//go:noinline +func ofz16ur16(n uint16) uint16 { + var x uint16 + return x >> n +} + +//go:noinline +func ofz16ur8(n uint8) uint16 { + var x uint16 + return x >> n +} + +//go:noinline +func ofz8l64(n uint64) int8 { + var x int8 + return x << n +} + +//go:noinline +func ofz8l32(n uint32) int8 { + var x int8 + return x << n +} + +//go:noinline +func ofz8l16(n uint16) int8 { + var x int8 + return x << n +} + +//go:noinline +func ofz8l8(n uint8) int8 { + var x int8 + return x << n +} + +//go:noinline +func ofz8r64(n uint64) int8 { + var x int8 + return x >> n +} + +//go:noinline +func ofz8r32(n uint32) int8 { + var x int8 + return x >> n +} + +//go:noinline +func ofz8r16(n uint16) int8 { + var x int8 + return x >> n +} + +//go:noinline +func ofz8r8(n uint8) int8 { + var x int8 + return x >> n +} + +//go:noinline +func ofz8ur64(n uint64) uint8 { + var x uint8 + return x >> n +} + +//go:noinline +func ofz8ur32(n uint32) uint8 { + var x uint8 + return x >> n +} + +//go:noinline +func ofz8ur16(n uint16) uint8 { + var x uint8 + return x >> n +} + +//go:noinline +func ofz8ur8(n uint8) uint8 { + var x uint8 + return x >> n +} + +func TestShiftOfZero(t *testing.T) { + if got := ofz64l64(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz64l32(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz64l16(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz64l8(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz64r64(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz64r32(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz64r16(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz64r8(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz64ur64(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz64ur32(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz64ur16(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz64ur8(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + + if got := ofz32l64(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz32l32(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz32l16(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz32l8(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz32r64(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz32r32(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz32r16(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz32r8(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz32ur64(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz32ur32(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz32ur16(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz32ur8(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + + if got := ofz16l64(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz16l32(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz16l16(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz16l8(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz16r64(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz16r32(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz16r16(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz16r8(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz16ur64(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz16ur32(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz16ur16(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz16ur8(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + + if got := ofz8l64(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz8l32(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz8l16(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz8l8(5); got != 0 { + t.Errorf("0<<5 == %d, want 0", got) + } + if got := ofz8r64(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz8r32(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz8r16(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz8r8(5); got != 0 { + t.Errorf("0>>5 == %d, want 0", got) + } + if got := ofz8ur64(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz8ur32(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz8ur16(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } + if got := ofz8ur8(5); got != 0 { + t.Errorf("0>>>5 == %d, want 0", got) + } +} + +//go:noinline +func byz64l(n int64) int64 { + return n << 0 +} + +//go:noinline +func byz64r(n int64) int64 { + return n >> 0 +} + +//go:noinline +func byz64ur(n uint64) uint64 { + return n >> 0 +} + +//go:noinline +func byz32l(n int32) int32 { + return n << 0 +} + +//go:noinline +func byz32r(n int32) int32 { + return n >> 0 +} + +//go:noinline +func byz32ur(n uint32) uint32 { + return n >> 0 +} + +//go:noinline +func byz16l(n int16) int16 { + return n << 0 +} + +//go:noinline +func byz16r(n int16) int16 { + return n >> 0 +} + +//go:noinline +func byz16ur(n uint16) uint16 { + return n >> 0 +} + +//go:noinline +func byz8l(n int8) int8 { + return n << 0 +} + +//go:noinline +func byz8r(n int8) int8 { + return n >> 0 +} + +//go:noinline +func byz8ur(n uint8) uint8 { + return n >> 0 +} + +func TestShiftByZero(t *testing.T) { + { + var n int64 = 0x5555555555555555 + if got := byz64l(n); got != n { + t.Errorf("%x<<0 == %x, want %x", n, got, n) + } + if got := byz64r(n); got != n { + t.Errorf("%x>>0 == %x, want %x", n, got, n) + } + } + { + var n uint64 = 0xaaaaaaaaaaaaaaaa + if got := byz64ur(n); got != n { + t.Errorf("%x>>>0 == %x, want %x", n, got, n) + } + } + + { + var n int32 = 0x55555555 + if got := byz32l(n); got != n { + t.Errorf("%x<<0 == %x, want %x", n, got, n) + } + if got := byz32r(n); got != n { + t.Errorf("%x>>0 == %x, want %x", n, got, n) + } + } + { + var n uint32 = 0xaaaaaaaa + if got := byz32ur(n); got != n { + t.Errorf("%x>>>0 == %x, want %x", n, got, n) + } + } + + { + var n int16 = 0x5555 + if got := byz16l(n); got != n { + t.Errorf("%x<<0 == %x, want %x", n, got, n) + } + if got := byz16r(n); got != n { + t.Errorf("%x>>0 == %x, want %x", n, got, n) + } + } + { + var n uint16 = 0xaaaa + if got := byz16ur(n); got != n { + t.Errorf("%x>>>0 == %x, want %x", n, got, n) + } + } + + { + var n int8 = 0x55 + if got := byz8l(n); got != n { + t.Errorf("%x<<0 == %x, want %x", n, got, n) + } + if got := byz8r(n); got != n { + t.Errorf("%x>>0 == %x, want %x", n, got, n) + } + } + { + var n uint8 = 0x55 + if got := byz8ur(n); got != n { + t.Errorf("%x>>>0 == %x, want %x", n, got, n) + } + } +} + +//go:noinline +func two64l(x int64) int64 { + return x << 1 << 1 +} + +//go:noinline +func two64r(x int64) int64 { + return x >> 1 >> 1 +} + +//go:noinline +func two64ur(x uint64) uint64 { + return x >> 1 >> 1 +} + +//go:noinline +func two32l(x int32) int32 { + return x << 1 << 1 +} + +//go:noinline +func two32r(x int32) int32 { + return x >> 1 >> 1 +} + +//go:noinline +func two32ur(x uint32) uint32 { + return x >> 1 >> 1 +} + +//go:noinline +func two16l(x int16) int16 { + return x << 1 << 1 +} + +//go:noinline +func two16r(x int16) int16 { + return x >> 1 >> 1 +} + +//go:noinline +func two16ur(x uint16) uint16 { + return x >> 1 >> 1 +} + +//go:noinline +func two8l(x int8) int8 { + return x << 1 << 1 +} + +//go:noinline +func two8r(x int8) int8 { + return x >> 1 >> 1 +} + +//go:noinline +func two8ur(x uint8) uint8 { + return x >> 1 >> 1 +} + +func TestShiftCombine(t *testing.T) { + if got, want := two64l(4), int64(16); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := two64r(64), int64(16); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := two64ur(64), uint64(16); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := two32l(4), int32(16); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := two32r(64), int32(16); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := two32ur(64), uint32(16); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := two16l(4), int16(16); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := two16r(64), int16(16); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := two16ur(64), uint16(16); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := two8l(4), int8(16); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := two8r(64), int8(16); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := two8ur(64), uint8(16); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + +} + +//go:noinline +func three64l(x int64) int64 { + return x << 3 >> 1 << 2 +} + +//go:noinline +func three64ul(x uint64) uint64 { + return x << 3 >> 1 << 2 +} + +//go:noinline +func three64r(x int64) int64 { + return x >> 3 << 1 >> 2 +} + +//go:noinline +func three64ur(x uint64) uint64 { + return x >> 3 << 1 >> 2 +} + +//go:noinline +func three32l(x int32) int32 { + return x << 3 >> 1 << 2 +} + +//go:noinline +func three32ul(x uint32) uint32 { + return x << 3 >> 1 << 2 +} + +//go:noinline +func three32r(x int32) int32 { + return x >> 3 << 1 >> 2 +} + +//go:noinline +func three32ur(x uint32) uint32 { + return x >> 3 << 1 >> 2 +} + +//go:noinline +func three16l(x int16) int16 { + return x << 3 >> 1 << 2 +} + +//go:noinline +func three16ul(x uint16) uint16 { + return x << 3 >> 1 << 2 +} + +//go:noinline +func three16r(x int16) int16 { + return x >> 3 << 1 >> 2 +} + +//go:noinline +func three16ur(x uint16) uint16 { + return x >> 3 << 1 >> 2 +} + +//go:noinline +func three8l(x int8) int8 { + return x << 3 >> 1 << 2 +} + +//go:noinline +func three8ul(x uint8) uint8 { + return x << 3 >> 1 << 2 +} + +//go:noinline +func three8r(x int8) int8 { + return x >> 3 << 1 >> 2 +} + +//go:noinline +func three8ur(x uint8) uint8 { + return x >> 3 << 1 >> 2 +} + +func TestShiftCombine3(t *testing.T) { + if got, want := three64l(4), int64(64); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := three64ul(4), uint64(64); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := three64r(64), int64(4); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := three64ur(64), uint64(4); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := three32l(4), int32(64); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := three32ul(4), uint32(64); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := three32r(64), int32(4); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := three32ur(64), uint32(4); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := three16l(4), int16(64); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := three16ul(4), uint16(64); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := three16r(64), int16(4); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := three16ur(64), uint16(4); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := three8l(4), int8(64); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := three8ul(4), uint8(64); want != got { + t.Errorf("4<<1<<1 == %d, want %d", got, want) + } + if got, want := three8r(64), int8(4); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } + if got, want := three8ur(64), uint8(4); want != got { + t.Errorf("64>>1>>1 == %d, want %d", got, want) + } +} + +var ( + one64 int64 = 1 + one64u uint64 = 1 + one32 int32 = 1 + one32u uint32 = 1 + one16 int16 = 1 + one16u uint16 = 1 + one8 int8 = 1 + one8u uint8 = 1 +) + +func TestShiftLargeCombine(t *testing.T) { + var N uint64 = 0x8000000000000000 + if one64<>N>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one64u>>N>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one32<>N>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one32u>>N>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one16<>N>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one16u>>N>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one8<>N>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one8u>>N>>N == 1 { + t.Errorf("shift overflow mishandled") + } +} + +func TestShiftLargeCombine3(t *testing.T) { + var N uint64 = 0x8000000000000001 + if one64<>2<>2<>N<<2>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one64u>>N<<2>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one32<>2<>2<>N<<2>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one32u>>N<<2>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one16<>2<>2<>N<<2>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one16u>>N<<2>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one8<>2<>2<>N<<2>>N == 1 { + t.Errorf("shift overflow mishandled") + } + if one8u>>N<<2>>N == 1 { + t.Errorf("shift overflow mishandled") + } +} + +func TestShiftGeneric(t *testing.T) { + for _, test := range [...]struct { + valueWidth int + signed bool + shiftWidth int + left bool + f any + }{ + {64, true, 64, true, func(n int64, s uint64) int64 { return n << s }}, + {64, true, 64, false, func(n int64, s uint64) int64 { return n >> s }}, + {64, false, 64, false, func(n uint64, s uint64) uint64 { return n >> s }}, + {64, true, 32, true, func(n int64, s uint32) int64 { return n << s }}, + {64, true, 32, false, func(n int64, s uint32) int64 { return n >> s }}, + {64, false, 32, false, func(n uint64, s uint32) uint64 { return n >> s }}, + {64, true, 16, true, func(n int64, s uint16) int64 { return n << s }}, + {64, true, 16, false, func(n int64, s uint16) int64 { return n >> s }}, + {64, false, 16, false, func(n uint64, s uint16) uint64 { return n >> s }}, + {64, true, 8, true, func(n int64, s uint8) int64 { return n << s }}, + {64, true, 8, false, func(n int64, s uint8) int64 { return n >> s }}, + {64, false, 8, false, func(n uint64, s uint8) uint64 { return n >> s }}, + + {32, true, 64, true, func(n int32, s uint64) int32 { return n << s }}, + {32, true, 64, false, func(n int32, s uint64) int32 { return n >> s }}, + {32, false, 64, false, func(n uint32, s uint64) uint32 { return n >> s }}, + {32, true, 32, true, func(n int32, s uint32) int32 { return n << s }}, + {32, true, 32, false, func(n int32, s uint32) int32 { return n >> s }}, + {32, false, 32, false, func(n uint32, s uint32) uint32 { return n >> s }}, + {32, true, 16, true, func(n int32, s uint16) int32 { return n << s }}, + {32, true, 16, false, func(n int32, s uint16) int32 { return n >> s }}, + {32, false, 16, false, func(n uint32, s uint16) uint32 { return n >> s }}, + {32, true, 8, true, func(n int32, s uint8) int32 { return n << s }}, + {32, true, 8, false, func(n int32, s uint8) int32 { return n >> s }}, + {32, false, 8, false, func(n uint32, s uint8) uint32 { return n >> s }}, + + {16, true, 64, true, func(n int16, s uint64) int16 { return n << s }}, + {16, true, 64, false, func(n int16, s uint64) int16 { return n >> s }}, + {16, false, 64, false, func(n uint16, s uint64) uint16 { return n >> s }}, + {16, true, 32, true, func(n int16, s uint32) int16 { return n << s }}, + {16, true, 32, false, func(n int16, s uint32) int16 { return n >> s }}, + {16, false, 32, false, func(n uint16, s uint32) uint16 { return n >> s }}, + {16, true, 16, true, func(n int16, s uint16) int16 { return n << s }}, + {16, true, 16, false, func(n int16, s uint16) int16 { return n >> s }}, + {16, false, 16, false, func(n uint16, s uint16) uint16 { return n >> s }}, + {16, true, 8, true, func(n int16, s uint8) int16 { return n << s }}, + {16, true, 8, false, func(n int16, s uint8) int16 { return n >> s }}, + {16, false, 8, false, func(n uint16, s uint8) uint16 { return n >> s }}, + + {8, true, 64, true, func(n int8, s uint64) int8 { return n << s }}, + {8, true, 64, false, func(n int8, s uint64) int8 { return n >> s }}, + {8, false, 64, false, func(n uint8, s uint64) uint8 { return n >> s }}, + {8, true, 32, true, func(n int8, s uint32) int8 { return n << s }}, + {8, true, 32, false, func(n int8, s uint32) int8 { return n >> s }}, + {8, false, 32, false, func(n uint8, s uint32) uint8 { return n >> s }}, + {8, true, 16, true, func(n int8, s uint16) int8 { return n << s }}, + {8, true, 16, false, func(n int8, s uint16) int8 { return n >> s }}, + {8, false, 16, false, func(n uint8, s uint16) uint8 { return n >> s }}, + {8, true, 8, true, func(n int8, s uint8) int8 { return n << s }}, + {8, true, 8, false, func(n int8, s uint8) int8 { return n >> s }}, + {8, false, 8, false, func(n uint8, s uint8) uint8 { return n >> s }}, + } { + fv := reflect.ValueOf(test.f) + var args [2]reflect.Value + for i := 0; i < test.valueWidth; i++ { + // Build value to be shifted. + var n int64 = 1 + for j := 0; j < i; j++ { + n <<= 1 + } + args[0] = reflect.ValueOf(n).Convert(fv.Type().In(0)) + for s := 0; s <= test.shiftWidth; s++ { + args[1] = reflect.ValueOf(s).Convert(fv.Type().In(1)) + + // Compute desired result. We're testing variable shifts + // assuming constant shifts are correct. + r := n + var op string + switch { + case test.left: + op = "<<" + for j := 0; j < s; j++ { + r <<= 1 + } + switch test.valueWidth { + case 32: + r = int64(int32(r)) + case 16: + r = int64(int16(r)) + case 8: + r = int64(int8(r)) + } + case test.signed: + op = ">>" + switch test.valueWidth { + case 32: + r = int64(int32(r)) + case 16: + r = int64(int16(r)) + case 8: + r = int64(int8(r)) + } + for j := 0; j < s; j++ { + r >>= 1 + } + default: + op = ">>>" + for j := 0; j < s; j++ { + r = int64(uint64(r) >> 1) + } + } + + // Call function. + res := fv.Call(args[:])[0].Convert(reflect.ValueOf(r).Type()) + + if res.Int() != r { + t.Errorf("%s%dx%d(%x,%x)=%x, want %x", op, test.valueWidth, test.shiftWidth, n, s, res.Int(), r) + } + } + } + } +} + +var shiftSink64 int64 + +func BenchmarkShiftArithmeticRight(b *testing.B) { + x := shiftSink64 + for i := 0; i < b.N; i++ { + x = x >> (i & 63) + } + shiftSink64 = x +} + +//go:noinline +func incorrectRotate1(x, c uint64) uint64 { + // This should not compile to a rotate instruction. + return x<>(64-c) +} + +//go:noinline +func incorrectRotate2(x uint64) uint64 { + var c uint64 = 66 + // This should not compile to a rotate instruction. + return x<>(64-c) +} + +func TestIncorrectRotate(t *testing.T) { + if got := incorrectRotate1(1, 66); got != 0 { + t.Errorf("got %x want 0", got) + } + if got := incorrectRotate2(1); got != 0 { + t.Errorf("got %x want 0", got) + } +} + +//go:noinline +func variableShiftOverflow64x8(x int64, y, z uint8) (a, b, c int64) { + // Verify junk bits are ignored when doing a variable shift. + return x >> (y + z), x << (y + z), int64(uint64(x) >> (y + z)) +} + +//go:noinline +func variableShiftOverflow32x8(x int32, y, z uint8) (a, b, c int32) { + // Verify junk bits are ignored when doing a variable shift. + return x >> (y + z), x << (y + z), int32(uint32(x) >> (y + z)) +} + +//go:noinline +func variableShiftOverflow16x8(x int16, y, z uint8) (a, b, c int16) { + // Verify junk bits are ignored when doing a variable shift. + return x >> (y + z), x << (y + z), int16(uint16(x) >> (y + z)) +} + +//go:noinline +func variableShiftOverflow8x8(x int8, y, z uint8) (a, b, c int8) { + // Verify junk bits are ignored when doing a variable shift. + return x >> (y + z), x << (y + z), int8(uint8(x) >> (y + z)) +} + +//go:noinline +func variableShiftOverflow64x16(x int64, y, z uint16) (a, b, c int64) { + // Verify junk bits are ignored when doing a variable shift. + return x >> (y + z), x << (y + z), int64(uint64(x) >> (y + z)) +} + +//go:noinline +func variableShiftOverflow32x16(x int32, y, z uint16) (a, b, c int32) { + // Verify junk bits are ignored when doing a variable shift. + return x >> (y + z), x << (y + z), int32(uint32(x) >> (y + z)) +} + +//go:noinline +func variableShiftOverflow16x16(x int16, y, z uint16) (a, b, c int16) { + // Verify junk bits are ignored when doing a variable shift. + return x >> (y + z), x << (y + z), int16(uint16(x) >> (y + z)) +} + +//go:noinline +func variableShiftOverflow8x16(x int8, y, z uint16) (a, b, c int8) { + // Verify junk bits are ignored when doing a variable shift. + return x >> (y + z), x << (y + z), int8(uint8(x) >> (y + z)) +} + +//go:noinline +func makeU8(x uint64) uint8 { + // Ensure the upper portions of the register are clear before testing large shift values + // using non-native types (e.g uint8 on PPC64). + return uint8(x) +} + +//go:noinline +func makeU16(x uint64) uint16 { + // Ensure the upper portions of the register are clear before testing large shift values + // using non-native types (e.g uint8 on PPC64). + return uint16(x) +} + +func TestShiftOverflow(t *testing.T) { + if v, w, z := variableShiftOverflow64x8(-64, makeU8(255), 2); v != -32 || w != -128 || z != 0x7fffffffffffffe0 { + t.Errorf("got %d %d 0x%x, expected -32 -128 0x7fffffffffffffe0", v, w, z) + } + if v, w, z := variableShiftOverflow32x8(-64, makeU8(255), 2); v != -32 || w != -128 || z != 0x7fffffe0 { + t.Errorf("got %d %d 0x%x, expected -32 -128 0x7fffffe0", v, w, z) + } + if v, w, z := variableShiftOverflow16x8(-64, makeU8(255), 2); v != -32 || w != -128 || z != 0x7fe0 { + t.Errorf("got %d %d 0x%x, expected -32 -128 0x7fe0", v, w, z) + } + if v, w, z := variableShiftOverflow8x8(-64, makeU8(255), 2); v != -32 || w != -128 || z != 0x60 { + t.Errorf("got %d %d 0x%x, expected -32 -128 0x60", v, w, z) + } + if v, w, z := variableShiftOverflow64x16(-64, makeU16(0xffff), 2); v != -32 || w != -128 || z != 0x7fffffffffffffe0 { + t.Errorf("got %d %d 0x%x, expected -32 -128 0x7fffffffffffffe0", v, w, z) + } + if v, w, z := variableShiftOverflow32x16(-64, makeU16(0xffff), 2); v != -32 || w != -128 || z != 0x7fffffe0 { + t.Errorf("got %d %d 0x%x, expected -32 -128 0x7fffffe0,", v, w, z) + } + if v, w, z := variableShiftOverflow16x16(-64, makeU16(0xffff), 2); v != -32 || w != -128 || z != 0x7fe0 { + t.Errorf("got %d %d 0x%x, expected -32 -128 0x7fe0", v, w, z) + } + if v, w, z := variableShiftOverflow8x16(-64, makeU16(0xffff), 2); v != -32 || w != -128 || z != 0x60 { + t.Errorf("got %d %d 0x%x, expected -32 -128 0x60", v, w, z) + } +} + +//go:noinline +func lsh64s(n int64, k int) int64 { + return n << k +} + +//go:noinline +func lsh64u(n uint64, k int) uint64 { + return n << k +} + +//go:noinline +func lsh32s(n int32, k int) int32 { + return n << k +} + +//go:noinline +func lsh32u(n uint32, k int) uint32 { + return n << k +} + +//go:noinline +func lsh16s(n int16, k int) int16 { + return n << k +} + +//go:noinline +func lsh16u(n uint16, k int) uint16 { + return n << k +} + +//go:noinline +func lsh8s(n int8, k int) int8 { + return n << k +} + +//go:noinline +func lsh8u(n uint8, k int) uint8 { + return n << k +} + +//go:noinline +func rsh64s(n int64, k int) int64 { + return n >> k +} + +//go:noinline +func rsh64u(n uint64, k int) uint64 { + return n >> k +} + +//go:noinline +func rsh32s(n int32, k int) int32 { + return n >> k +} + +//go:noinline +func rsh32u(n uint32, k int) uint32 { + return n >> k +} + +//go:noinline +func rsh16s(n int16, k int) int16 { + return n >> k +} + +//go:noinline +func rsh16u(n uint16, k int) uint16 { + return n >> k +} + +//go:noinline +func rsh8s(n int8, k int) int8 { + return n >> k +} + +//go:noinline +func rsh8u(n uint8, k int) uint8 { + return n >> k +} + +func TestOverShiftLeft(t *testing.T) { + for _, f := range []reflect.Value{ + reflect.ValueOf(lsh64s), + reflect.ValueOf(lsh64u), + reflect.ValueOf(lsh32s), + reflect.ValueOf(lsh32u), + reflect.ValueOf(lsh16s), + reflect.ValueOf(lsh16u), + reflect.ValueOf(lsh8s), + reflect.ValueOf(lsh8u), + } { + typ := f.Type().In(0) // type of input/output + one := reflect.ValueOf(1).Convert(typ) + zero := reflect.ValueOf(0).Convert(typ).Interface() + for k := 0; k < 100; k++ { + got := f.Call([]reflect.Value{one, reflect.ValueOf(k)})[0].Interface() + if k >= int(typ.Size()*8) { + if got != zero { + t.Errorf("shifted to zero prematurely: %s %d %v", typ, k, got) + } + } else { + if got == zero { + t.Errorf("shift doesn't result in zero: %s %d %v", typ, k, got) + } + } + } + } +} + +func TestOverShiftRightU(t *testing.T) { + for _, f := range []reflect.Value{ + reflect.ValueOf(rsh64u), + reflect.ValueOf(rsh32u), + reflect.ValueOf(rsh16u), + reflect.ValueOf(rsh8u), + } { + typ := f.Type().In(0) // type of input/output + max := reflect.ValueOf(uint64(1) << (typ.Size()*8 - 1)).Convert(typ) + zero := reflect.ValueOf(0).Convert(typ).Interface() + for k := 0; k < 100; k++ { + got := f.Call([]reflect.Value{max, reflect.ValueOf(k)})[0].Interface() + if k >= int(typ.Size()*8) { + if got != zero { + t.Errorf("shifted to zero prematurely: %s %d %v", typ, k, got) + } + } else { + if got == zero { + t.Errorf("shift doesn't result in zero: %s %d %v", typ, k, got) + } + } + } + } +} +func TestOverShiftRightS(t *testing.T) { + for _, f := range []reflect.Value{ + reflect.ValueOf(rsh64s), + reflect.ValueOf(rsh32s), + reflect.ValueOf(rsh16s), + reflect.ValueOf(rsh8s), + } { + typ := f.Type().In(0) // type of input/output + maxInt := reflect.ValueOf(int64(1)<<(typ.Size()*8-1) - 1).Convert(typ) + zero := reflect.ValueOf(0).Convert(typ).Interface() + for k := 0; k < 100; k++ { + got := f.Call([]reflect.Value{maxInt, reflect.ValueOf(k)})[0].Interface() + if k < int(typ.Size()*8)-1 { + if got == zero { + t.Errorf("shifted to zero prematurely: %s %d %v", typ, k, got) + } + } else { + if got != zero { + t.Errorf("shift doesn't result in zero: %s %d %v", typ, k, got) + } + } + } + minInt := reflect.ValueOf(int64(1) << (typ.Size()*8 - 1)).Convert(typ) + negOne := reflect.ValueOf(-1).Convert(typ).Interface() + for k := 0; k < 100; k++ { + got := f.Call([]reflect.Value{minInt, reflect.ValueOf(k)})[0].Interface() + if k < int(typ.Size()*8)-1 { + if got == negOne { + t.Errorf("shifted to negative one prematurely: %s %d %v", typ, k, got) + } + } else { + if got != negOne { + t.Errorf("shift doesn't result in negative one: %s %d %v", typ, k, got) + } + } + } + } +} + +func TestNegShifts(t *testing.T) { + for i := 0; i < bits.UintSize; i++ { + k := (-1) << i + shouldPanic(func() { lsh64s(0, k) }) + shouldPanic(func() { lsh64u(0, k) }) + shouldPanic(func() { lsh32s(0, k) }) + shouldPanic(func() { lsh32u(0, k) }) + shouldPanic(func() { lsh16s(0, k) }) + shouldPanic(func() { lsh16u(0, k) }) + shouldPanic(func() { lsh8s(0, k) }) + shouldPanic(func() { lsh8u(0, k) }) + shouldPanic(func() { rsh64s(0, k) }) + shouldPanic(func() { rsh64u(0, k) }) + shouldPanic(func() { rsh32s(0, k) }) + shouldPanic(func() { rsh32u(0, k) }) + shouldPanic(func() { rsh16s(0, k) }) + shouldPanic(func() { rsh16u(0, k) }) + shouldPanic(func() { rsh8s(0, k) }) + shouldPanic(func() { rsh8u(0, k) }) + } +} +func shouldPanic(f func()) { + defer func() { + if recover() == nil { + panic("not panicking") + } + }() + f() +} diff --git a/go/src/cmd/compile/internal/test/ssa_test.go b/go/src/cmd/compile/internal/test/ssa_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7d213fcecac458b9e77931734180f4d86af836a1 --- /dev/null +++ b/go/src/cmd/compile/internal/test/ssa_test.go @@ -0,0 +1,179 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "bytes" + "fmt" + "go/ast" + "go/parser" + "go/token" + "internal/testenv" + "os" + "path/filepath" + "runtime" + "strings" + "testing" +) + +// runGenTest runs a test-generator, then runs the generated test. +// Generated test can either fail in compilation or execution. +// The environment variable parameter(s) is passed to the run +// of the generated test. +func runGenTest(t *testing.T, filename, tmpname string, ev ...string) { + testenv.MustHaveGoRun(t) + gotool := testenv.GoToolPath(t) + var stdout, stderr bytes.Buffer + cmd := testenv.Command(t, gotool, "run", filepath.Join("testdata", filename)) + cmd.Stdout = &stdout + cmd.Stderr = &stderr + if err := cmd.Run(); err != nil { + t.Fatalf("Failed: %v:\nOut: %s\nStderr: %s\n", err, &stdout, &stderr) + } + // Write stdout into a temporary file + rungo := filepath.Join(t.TempDir(), "run.go") + ok := os.WriteFile(rungo, stdout.Bytes(), 0600) + if ok != nil { + t.Fatalf("Failed to create temporary file %s", rungo) + } + + stdout.Reset() + stderr.Reset() + cmd = testenv.Command(t, gotool, "run", "-gcflags=-d=ssa/check/on", rungo) + cmd.Stdout = &stdout + cmd.Stderr = &stderr + cmd.Env = append(cmd.Env, ev...) + err := cmd.Run() + if err != nil { + t.Fatalf("Failed: %v:\nOut: %s\nStderr: %s\n", err, &stdout, &stderr) + } + if s := stderr.String(); s != "" { + t.Errorf("Stderr = %s\nWant empty", s) + } + if s := stdout.String(); s != "" { + t.Errorf("Stdout = %s\nWant empty", s) + } +} + +func TestGenFlowGraph(t *testing.T) { + if testing.Short() { + t.Skip("not run in short mode.") + } + runGenTest(t, "flowgraph_generator1.go", "ssa_fg_tmp1") +} + +// TestCode runs all the tests in the testdata directory as subtests. +// These tests are special because we want to run them with different +// compiler flags set (and thus they can't just be _test.go files in +// this directory). +func TestCode(t *testing.T) { + testenv.MustHaveGoBuild(t) + gotool := testenv.GoToolPath(t) + + // Make a temporary directory to work in. + tmpdir := t.TempDir() + + // Find all the test functions (and the files containing them). + var srcs []string // files containing Test functions + type test struct { + name string // TestFoo + usesFloat bool // might use float operations + } + var tests []test + files, err := os.ReadDir("testdata") + if err != nil { + t.Fatalf("can't read testdata directory: %v", err) + } + for _, f := range files { + if !strings.HasSuffix(f.Name(), "_test.go") { + continue + } + text, err := os.ReadFile(filepath.Join("testdata", f.Name())) + if err != nil { + t.Fatalf("can't read testdata/%s: %v", f.Name(), err) + } + fset := token.NewFileSet() + code, err := parser.ParseFile(fset, f.Name(), text, 0) + if err != nil { + t.Fatalf("can't parse testdata/%s: %v", f.Name(), err) + } + srcs = append(srcs, filepath.Join("testdata", f.Name())) + foundTest := false + for _, d := range code.Decls { + fd, ok := d.(*ast.FuncDecl) + if !ok { + continue + } + if !strings.HasPrefix(fd.Name.Name, "Test") { + continue + } + if fd.Recv != nil { + continue + } + if fd.Type.Results != nil { + continue + } + if len(fd.Type.Params.List) != 1 { + continue + } + p := fd.Type.Params.List[0] + if len(p.Names) != 1 { + continue + } + s, ok := p.Type.(*ast.StarExpr) + if !ok { + continue + } + sel, ok := s.X.(*ast.SelectorExpr) + if !ok { + continue + } + base, ok := sel.X.(*ast.Ident) + if !ok { + continue + } + if base.Name != "testing" { + continue + } + if sel.Sel.Name != "T" { + continue + } + // Found a testing function. + tests = append(tests, test{name: fd.Name.Name, usesFloat: bytes.Contains(text, []byte("float"))}) + foundTest = true + } + if !foundTest { + t.Fatalf("test file testdata/%s has no tests in it", f.Name()) + } + } + + flags := []string{""} + if runtime.GOARCH == "arm" || runtime.GOARCH == "mips" || runtime.GOARCH == "mips64" || runtime.GOARCH == "386" { + flags = append(flags, ",softfloat") + } + for _, flag := range flags { + args := []string{"test", "-c", "-gcflags=-d=ssa/check/on" + flag, "-o", filepath.Join(tmpdir, "code.test")} + args = append(args, srcs...) + out, err := testenv.Command(t, gotool, args...).CombinedOutput() + if err != nil || len(out) != 0 { + t.Fatalf("Build failed: %v\n%s\n", err, out) + } + + // Now we have a test binary. Run it with all the tests as subtests of this one. + for _, test := range tests { + test := test + if flag == ",softfloat" && !test.usesFloat { + // No point in running the soft float version if the test doesn't use floats. + continue + } + t.Run(fmt.Sprintf("%s%s", test.name[4:], flag), func(t *testing.T) { + out, err := testenv.Command(t, filepath.Join(tmpdir, "code.test"), "-test.run=^"+test.name+"$").CombinedOutput() + if err != nil || string(out) != "PASS\n" { + t.Errorf("Failed:\n%s\n", out) + } + }) + } + } +} diff --git a/go/src/cmd/compile/internal/test/stack_test.go b/go/src/cmd/compile/internal/test/stack_test.go new file mode 100644 index 0000000000000000000000000000000000000000..26c29ef1480bae5274a193e0e51fc8b0b6c00075 --- /dev/null +++ b/go/src/cmd/compile/internal/test/stack_test.go @@ -0,0 +1,62 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "internal/testenv" + "testing" + "unsafe" +) + +// Stack allocation size for variable-sized allocations. +// Matches constant of the same name in ../walk/builtin.go:walkMakeSlice. +const maxStackSize = 32 + +//go:noinline +func genericUse[T any](s []T) { + // Doesn't escape s. +} + +func TestStackAllocation(t *testing.T) { + testenv.SkipIfOptimizationOff(t) + + type testCase struct { + f func(int) + elemSize uintptr + } + + for _, tc := range []testCase{ + { + f: func(n int) { + genericUse(make([]int, n)) + }, + elemSize: unsafe.Sizeof(int(0)), + }, + { + f: func(n int) { + genericUse(make([]*byte, n)) + }, + elemSize: unsafe.Sizeof((*byte)(nil)), + }, + { + f: func(n int) { + genericUse(make([]string, n)) + }, + elemSize: unsafe.Sizeof(""), + }, + } { + max := maxStackSize / int(tc.elemSize) + if n := testing.AllocsPerRun(10, func() { + tc.f(max) + }); n != 0 { + t.Fatalf("unexpected allocation: %f", n) + } + if n := testing.AllocsPerRun(10, func() { + tc.f(max + 1) + }); n != 1 { + t.Fatalf("unexpected allocation: %f", n) + } + } +} diff --git a/go/src/cmd/compile/internal/test/switch_test.go b/go/src/cmd/compile/internal/test/switch_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1d12361cbb69545f32a7f8cf5f3c90d72c658baf --- /dev/null +++ b/go/src/cmd/compile/internal/test/switch_test.go @@ -0,0 +1,296 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "math/bits" + "testing" +) + +func BenchmarkSwitch8Predictable(b *testing.B) { + benchmarkSwitch8(b, true) +} +func BenchmarkSwitch8Unpredictable(b *testing.B) { + benchmarkSwitch8(b, false) +} +func benchmarkSwitch8(b *testing.B, predictable bool) { + n := 0 + rng := newRNG() + for i := 0; i < b.N; i++ { + rng = rng.next(predictable) + switch rng.value() & 7 { + case 0: + n += 1 + case 1: + n += 2 + case 2: + n += 3 + case 3: + n += 4 + case 4: + n += 5 + case 5: + n += 6 + case 6: + n += 7 + case 7: + n += 8 + } + } + sink = n +} + +func BenchmarkSwitch32Predictable(b *testing.B) { + benchmarkSwitch32(b, true) +} +func BenchmarkSwitch32Unpredictable(b *testing.B) { + benchmarkSwitch32(b, false) +} +func benchmarkSwitch32(b *testing.B, predictable bool) { + n := 0 + rng := newRNG() + for i := 0; i < b.N; i++ { + rng = rng.next(predictable) + switch rng.value() & 31 { + case 0, 1, 2: + n += 1 + case 4, 5, 6: + n += 2 + case 8, 9, 10: + n += 3 + case 12, 13, 14: + n += 4 + case 16, 17, 18: + n += 5 + case 20, 21, 22: + n += 6 + case 24, 25, 26: + n += 7 + case 28, 29, 30: + n += 8 + default: + n += 9 + } + } + sink = n +} + +func BenchmarkSwitchStringPredictable(b *testing.B) { + benchmarkSwitchString(b, true) +} +func BenchmarkSwitchStringUnpredictable(b *testing.B) { + benchmarkSwitchString(b, false) +} +func benchmarkSwitchString(b *testing.B, predictable bool) { + a := []string{ + "foo", + "foo1", + "foo22", + "foo333", + "foo4444", + "foo55555", + "foo666666", + "foo7777777", + } + n := 0 + rng := newRNG() + for i := 0; i < b.N; i++ { + rng = rng.next(predictable) + switch a[rng.value()&7] { + case "foo": + n += 1 + case "foo1": + n += 2 + case "foo22": + n += 3 + case "foo333": + n += 4 + case "foo4444": + n += 5 + case "foo55555": + n += 6 + case "foo666666": + n += 7 + case "foo7777777": + n += 8 + } + } + sink = n +} + +func BenchmarkSwitchTypePredictable(b *testing.B) { + benchmarkSwitchType(b, true) +} +func BenchmarkSwitchTypeUnpredictable(b *testing.B) { + benchmarkSwitchType(b, false) +} +func benchmarkSwitchType(b *testing.B, predictable bool) { + a := []any{ + int8(1), + int16(2), + int32(3), + int64(4), + uint8(5), + uint16(6), + uint32(7), + uint64(8), + } + n := 0 + rng := newRNG() + for i := 0; i < b.N; i++ { + rng = rng.next(predictable) + switch a[rng.value()&7].(type) { + case int8: + n += 1 + case int16: + n += 2 + case int32: + n += 3 + case int64: + n += 4 + case uint8: + n += 5 + case uint16: + n += 6 + case uint32: + n += 7 + case uint64: + n += 8 + } + } + sink = n +} + +func BenchmarkSwitchInterfaceTypePredictable(b *testing.B) { + benchmarkSwitchInterfaceType(b, true) +} +func BenchmarkSwitchInterfaceTypeUnpredictable(b *testing.B) { + benchmarkSwitchInterfaceType(b, false) +} + +type SI0 interface { + si0() +} +type ST0 struct { +} + +func (ST0) si0() { +} + +type SI1 interface { + si1() +} +type ST1 struct { +} + +func (ST1) si1() { +} + +type SI2 interface { + si2() +} +type ST2 struct { +} + +func (ST2) si2() { +} + +type SI3 interface { + si3() +} +type ST3 struct { +} + +func (ST3) si3() { +} + +type SI4 interface { + si4() +} +type ST4 struct { +} + +func (ST4) si4() { +} + +type SI5 interface { + si5() +} +type ST5 struct { +} + +func (ST5) si5() { +} + +type SI6 interface { + si6() +} +type ST6 struct { +} + +func (ST6) si6() { +} + +type SI7 interface { + si7() +} +type ST7 struct { +} + +func (ST7) si7() { +} + +func benchmarkSwitchInterfaceType(b *testing.B, predictable bool) { + a := []any{ + ST0{}, + ST1{}, + ST2{}, + ST3{}, + ST4{}, + ST5{}, + ST6{}, + ST7{}, + } + n := 0 + rng := newRNG() + for i := 0; i < b.N; i++ { + rng = rng.next(predictable) + switch a[rng.value()&7].(type) { + case SI0: + n += 1 + case SI1: + n += 2 + case SI2: + n += 3 + case SI3: + n += 4 + case SI4: + n += 5 + case SI5: + n += 6 + case SI6: + n += 7 + case SI7: + n += 8 + } + } + sink = n +} + +// A simple random number generator used to make switches conditionally predictable. +type rng uint64 + +func newRNG() rng { + return 1 +} +func (r rng) next(predictable bool) rng { + if predictable { + return r + 1 + } + return rng(bits.RotateLeft64(uint64(r), 13) * 0x3c374d) +} +func (r rng) value() uint64 { + return uint64(r) +} diff --git a/go/src/cmd/compile/internal/test/test.go b/go/src/cmd/compile/internal/test/test.go new file mode 100644 index 0000000000000000000000000000000000000000..195c65a9ea0312ced6f505372ab486bb06aba220 --- /dev/null +++ b/go/src/cmd/compile/internal/test/test.go @@ -0,0 +1,5 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test diff --git a/go/src/cmd/compile/internal/test/truncconst_test.go b/go/src/cmd/compile/internal/test/truncconst_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7705042ca2c84f3ef1db4ff7833035bfd22d2854 --- /dev/null +++ b/go/src/cmd/compile/internal/test/truncconst_test.go @@ -0,0 +1,63 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import "testing" + +var f52want float64 = 1.0 / (1 << 52) +var f53want float64 = 1.0 / (1 << 53) + +func TestTruncFlt(t *testing.T) { + const f52 = 1 + 1.0/(1<<52) + const f53 = 1 + 1.0/(1<<53) + + if got := f52 - 1; got != f52want { + t.Errorf("f52-1 = %g, want %g", got, f52want) + } + if got := float64(f52) - 1; got != f52want { + t.Errorf("float64(f52)-1 = %g, want %g", got, f52want) + } + if got := f53 - 1; got != f53want { + t.Errorf("f53-1 = %g, want %g", got, f53want) + } + if got := float64(f53) - 1; got != 0 { + t.Errorf("float64(f53)-1 = %g, want 0", got) + } +} + +func TestTruncCmplx(t *testing.T) { + const r52 = complex(1+1.0/(1<<52), 0) + const r53 = complex(1+1.0/(1<<53), 0) + + if got := real(r52 - 1); got != f52want { + t.Errorf("real(r52-1) = %g, want %g", got, f52want) + } + if got := real(complex128(r52) - 1); got != f52want { + t.Errorf("real(complex128(r52)-1) = %g, want %g", got, f52want) + } + if got := real(r53 - 1); got != f53want { + t.Errorf("real(r53-1) = %g, want %g", got, f53want) + } + if got := real(complex128(r53) - 1); got != 0 { + t.Errorf("real(complex128(r53)-1) = %g, want 0", got) + } + + const i52 = complex(0, 1+1.0/(1<<52)) + const i53 = complex(0, 1+1.0/(1<<53)) + + if got := imag(i52 - 1i); got != f52want { + t.Errorf("imag(i52-1i) = %g, want %g", got, f52want) + } + if got := imag(complex128(i52) - 1i); got != f52want { + t.Errorf("imag(complex128(i52)-1i) = %g, want %g", got, f52want) + } + if got := imag(i53 - 1i); got != f53want { + t.Errorf("imag(i53-1i) = %g, want %g", got, f53want) + } + if got := imag(complex128(i53) - 1i); got != 0 { + t.Errorf("imag(complex128(i53)-1i) = %g, want 0", got) + } + +} diff --git a/go/src/cmd/compile/internal/test/value_test.go b/go/src/cmd/compile/internal/test/value_test.go new file mode 100644 index 0000000000000000000000000000000000000000..bb98f4f22b31b007bae5d7eabcc6693f558c5051 --- /dev/null +++ b/go/src/cmd/compile/internal/test/value_test.go @@ -0,0 +1,41 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "cmd/compile/internal/ssa" + "cmd/compile/internal/types" + "internal/buildcfg" + "testing" +) + +// This file contains tests for ssa values, types and their utility functions. + +func TestCanSSA(t *testing.T) { + i64 := types.Types[types.TINT64] + v128 := types.TypeVec128 + s1 := mkstruct(i64, mkstruct(i64, i64, i64, i64)) + if ssa.CanSSA(s1) { + // Test size check for struct. + t.Errorf("CanSSA(%v) returned true, expected false", s1) + } + a1 := types.NewArray(s1, 1) + if ssa.CanSSA(a1) { + // Test size check for array. + t.Errorf("CanSSA(%v) returned true, expected false", a1) + } + if buildcfg.Experiment.SIMD { + s2 := mkstruct(v128, v128, v128, v128) + if !ssa.CanSSA(s2) { + // Test size check for SIMD struct special case. + t.Errorf("CanSSA(%v) returned false, expected true", s2) + } + a2 := types.NewArray(s2, 1) + if !ssa.CanSSA(a2) { + // Test size check for SIMD array special case. + t.Errorf("CanSSA(%v) returned false, expected true", a2) + } + } +} diff --git a/go/src/cmd/compile/internal/test/zerorange_test.go b/go/src/cmd/compile/internal/test/zerorange_test.go new file mode 100644 index 0000000000000000000000000000000000000000..e92b5d342fe136348e2c82d9c33eeb27702c3869 --- /dev/null +++ b/go/src/cmd/compile/internal/test/zerorange_test.go @@ -0,0 +1,184 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "testing" +) + +var glob = 3 +var globp *int64 + +// Testing compilation of arch.ZeroRange of various sizes. + +// By storing a pointer to an int64 output param in a global, the compiler must +// ensure that output param is allocated on the heap. Also, since there is a +// defer, the pointer to each output param must be zeroed in the prologue (see +// plive.go:epilogue()). So, we will get a block of one or more stack slots that +// need to be zeroed. Hence, we are testing compilation completes successfully when +// zerorange calls of various sizes (8-136 bytes) are generated. We are not +// testing runtime correctness (which is hard to do for the current uses of +// ZeroRange). + +func TestZeroRange(t *testing.T) { + testZeroRange8(t) + testZeroRange16(t) + testZeroRange32(t) + testZeroRange64(t) + testZeroRange136(t) +} + +func testZeroRange8(t *testing.T) (r int64) { + defer func() { + glob = 4 + }() + globp = &r + return +} + +func testZeroRange16(t *testing.T) (r, s int64) { + defer func() { + glob = 4 + }() + globp = &r + globp = &s + return +} + +func testZeroRange32(t *testing.T) (r, s, t2, u int64) { + defer func() { + glob = 4 + }() + globp = &r + globp = &s + globp = &t2 + globp = &u + return +} + +func testZeroRange64(t *testing.T) (r, s, t2, u, v, w, x, y int64) { + defer func() { + glob = 4 + }() + globp = &r + globp = &s + globp = &t2 + globp = &u + globp = &v + globp = &w + globp = &x + globp = &y + return +} + +func testZeroRange136(t *testing.T) (r, s, t2, u, v, w, x, y, r1, s1, t1, u1, v1, w1, x1, y1, z1 int64) { + defer func() { + glob = 4 + }() + globp = &r + globp = &s + globp = &t2 + globp = &u + globp = &v + globp = &w + globp = &x + globp = &y + globp = &r1 + globp = &s1 + globp = &t1 + globp = &u1 + globp = &v1 + globp = &w1 + globp = &x1 + globp = &y1 + globp = &z1 + return +} + +type S struct { + x [2]uint64 + p *uint64 + y [2]uint64 + q uint64 +} + +type M struct { + x [8]uint64 + p *uint64 + y [8]uint64 + q uint64 +} + +type L struct { + x [4096]uint64 + p *uint64 + y [4096]uint64 + q uint64 +} + +//go:noinline +func triggerZerorangeLarge(f, g, h uint64) (rv0 uint64) { + ll := L{p: &f} + da := f + rv0 = f + g + h + defer func(dl L, i uint64) { + rv0 += dl.q + i + }(ll, da) + return rv0 +} + +//go:noinline +func triggerZerorangeMedium(f, g, h uint64) (rv0 uint64) { + ll := M{p: &f} + rv0 = f + g + h + defer func(dm M, i uint64) { + rv0 += dm.q + i + }(ll, f) + return rv0 +} + +//go:noinline +func triggerZerorangeSmall(f, g, h uint64) (rv0 uint64) { + ll := S{p: &f} + rv0 = f + g + h + defer func(ds S, i uint64) { + rv0 += ds.q + i + }(ll, f) + return rv0 +} + +// This test was created as a follow up to issue #45372, to help +// improve coverage of the compiler's arch-specific "zerorange" +// function, which is invoked to zero out ambiguously live portions of +// the stack frame in certain specific circumstances. +// +// In the current compiler implementation, for zerorange to be +// invoked, we need to have an ambiguously live variable that needs +// zeroing. One way to trigger this is to have a function with an +// open-coded defer, where the opendefer function has an argument that +// contains a pointer (this is what's used below). +// +// At the moment this test doesn't do any specific checking for +// code sequence, or verification that things were properly set to zero, +// this seems as though it would be too tricky and would result +// in a "brittle" test. +// +// The small/medium/large scenarios below are inspired by the amd64 +// implementation of zerorange, which generates different code +// depending on the size of the thing that needs to be zeroed out +// (I've verified at the time of the writing of this test that it +// exercises the various cases). +func TestZerorange45372(t *testing.T) { + if r := triggerZerorangeLarge(101, 303, 505); r != 1010 { + t.Errorf("large: wanted %d got %d", 1010, r) + } + if r := triggerZerorangeMedium(101, 303, 505); r != 1010 { + t.Errorf("medium: wanted %d got %d", 1010, r) + } + if r := triggerZerorangeSmall(101, 303, 505); r != 1010 { + t.Errorf("small: wanted %d got %d", 1010, r) + } + +} diff --git a/go/src/cmd/compile/internal/typebits/typebits.go b/go/src/cmd/compile/internal/typebits/typebits.go new file mode 100644 index 0000000000000000000000000000000000000000..b07f4374c24efdf5e5bb920a595519974b974a3e --- /dev/null +++ b/go/src/cmd/compile/internal/typebits/typebits.go @@ -0,0 +1,96 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typebits + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/bitvec" + "cmd/compile/internal/types" +) + +// NOTE: The bitmap for a specific type t could be cached in t after +// the first run and then simply copied into bv at the correct offset +// on future calls with the same type t. +func Set(t *types.Type, off int64, bv bitvec.BitVec) { + set(t, off, bv, false) +} + +// SetNoCheck is like Set, but do not check for alignment. +func SetNoCheck(t *types.Type, off int64, bv bitvec.BitVec) { + set(t, off, bv, true) +} + +func set(t *types.Type, off int64, bv bitvec.BitVec, skip bool) { + if !skip && uint8(t.Alignment()) > 0 && off&int64(uint8(t.Alignment())-1) != 0 { + base.Fatalf("typebits.Set: invalid initial alignment: type %v has alignment %d, but offset is %v", t, uint8(t.Alignment()), off) + } + if !t.HasPointers() { + // Note: this case ensures that pointers to not-in-heap types + // are not considered pointers by garbage collection and stack copying. + return + } + + switch t.Kind() { + case types.TPTR, types.TUNSAFEPTR, types.TFUNC, types.TCHAN, types.TMAP: + if off&int64(types.PtrSize-1) != 0 { + base.Fatalf("typebits.Set: invalid alignment, %v", t) + } + bv.Set(int32(off / int64(types.PtrSize))) // pointer + + case types.TSTRING: + // struct { byte *str; intgo len; } + if off&int64(types.PtrSize-1) != 0 { + base.Fatalf("typebits.Set: invalid alignment, %v", t) + } + bv.Set(int32(off / int64(types.PtrSize))) //pointer in first slot + + case types.TINTER: + // struct { Itab *tab; void *data; } + // or, when isnilinter(t)==true: + // struct { Type *type; void *data; } + if off&int64(types.PtrSize-1) != 0 { + base.Fatalf("typebits.Set: invalid alignment, %v", t) + } + // The first word of an interface is a pointer, but we don't + // treat it as such. + // 1. If it is a non-empty interface, the pointer points to an itab + // which is always in persistentalloc space. + // 2. If it is an empty interface, the pointer points to a _type. + // a. If it is a compile-time-allocated type, it points into + // the read-only data section. + // b. If it is a reflect-allocated type, it points into the Go heap. + // Reflect is responsible for keeping a reference to + // the underlying type so it won't be GCd. + // If we ever have a moving GC, we need to change this for 2b (as + // well as scan itabs to update their itab._type fields). + bv.Set(int32(off/int64(types.PtrSize) + 1)) // pointer in second slot + + case types.TSLICE: + // struct { byte *array; uintgo len; uintgo cap; } + if off&int64(types.PtrSize-1) != 0 { + base.Fatalf("typebits.Set: invalid TARRAY alignment, %v", t) + } + bv.Set(int32(off / int64(types.PtrSize))) // pointer in first slot (BitsPointer) + + case types.TARRAY: + elt := t.Elem() + if elt.Size() == 0 { + // Short-circuit for #20739. + break + } + for i := int64(0); i < t.NumElem(); i++ { + set(elt, off, bv, skip) + off += elt.Size() + } + + case types.TSTRUCT: + for _, f := range t.Fields() { + set(f.Type, off+f.Offset, bv, skip) + } + + default: + base.Fatalf("typebits.Set: unexpected type, %v", t) + } +} diff --git a/go/src/cmd/compile/internal/typecheck/bexport.go b/go/src/cmd/compile/internal/typecheck/bexport.go new file mode 100644 index 0000000000000000000000000000000000000000..ed9a0114aff4e902d0e82c4059b3b7f9b3299f33 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/bexport.go @@ -0,0 +1,16 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +// Tags. Must be < 0. +const ( + // Objects + packageTag = -(iota + 1) + constTag + typeTag + varTag + funcTag + endTag +) diff --git a/go/src/cmd/compile/internal/typecheck/builtin.go b/go/src/cmd/compile/internal/typecheck/builtin.go new file mode 100644 index 0000000000000000000000000000000000000000..955e65e5988420b8a1c0bf4513b62ce5a4e81973 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/builtin.go @@ -0,0 +1,443 @@ +// Code generated by mkbuiltin.go. DO NOT EDIT. + +package typecheck + +import ( + "cmd/compile/internal/types" + "cmd/internal/src" +) + +// Not inlining this function removes a significant chunk of init code. +// +//go:noinline +func newSig(params, results []*types.Field) *types.Type { + return types.NewSignature(nil, params, results) +} + +func params(tlist ...*types.Type) []*types.Field { + flist := make([]*types.Field, len(tlist)) + for i, typ := range tlist { + flist[i] = types.NewField(src.NoXPos, nil, typ) + } + return flist +} + +var runtimeDecls = [...]struct { + name string + tag int + typ int +}{ + {"newobject", funcTag, 4}, + {"mallocgc", funcTag, 8}, + {"panicdivide", funcTag, 9}, + {"panicshift", funcTag, 9}, + {"panicmakeslicelen", funcTag, 9}, + {"panicmakeslicecap", funcTag, 9}, + {"throwinit", funcTag, 9}, + {"panicwrap", funcTag, 9}, + {"gopanic", funcTag, 11}, + {"gorecover", funcTag, 12}, + {"goschedguarded", funcTag, 9}, + {"goPanicIndex", funcTag, 14}, + {"goPanicIndexU", funcTag, 16}, + {"goPanicSliceAlen", funcTag, 14}, + {"goPanicSliceAlenU", funcTag, 16}, + {"goPanicSliceAcap", funcTag, 14}, + {"goPanicSliceAcapU", funcTag, 16}, + {"goPanicSliceB", funcTag, 14}, + {"goPanicSliceBU", funcTag, 16}, + {"goPanicSlice3Alen", funcTag, 14}, + {"goPanicSlice3AlenU", funcTag, 16}, + {"goPanicSlice3Acap", funcTag, 14}, + {"goPanicSlice3AcapU", funcTag, 16}, + {"goPanicSlice3B", funcTag, 14}, + {"goPanicSlice3BU", funcTag, 16}, + {"goPanicSlice3C", funcTag, 14}, + {"goPanicSlice3CU", funcTag, 16}, + {"goPanicSliceConvert", funcTag, 14}, + {"printbool", funcTag, 17}, + {"printfloat64", funcTag, 19}, + {"printfloat32", funcTag, 21}, + {"printint", funcTag, 23}, + {"printhex", funcTag, 25}, + {"printuint", funcTag, 25}, + {"printcomplex128", funcTag, 27}, + {"printcomplex64", funcTag, 29}, + {"printstring", funcTag, 31}, + {"printquoted", funcTag, 31}, + {"printpointer", funcTag, 32}, + {"printuintptr", funcTag, 33}, + {"printiface", funcTag, 32}, + {"printeface", funcTag, 32}, + {"printslice", funcTag, 32}, + {"printnl", funcTag, 9}, + {"printsp", funcTag, 9}, + {"printlock", funcTag, 9}, + {"printunlock", funcTag, 9}, + {"concatstring2", funcTag, 36}, + {"concatstring3", funcTag, 37}, + {"concatstring4", funcTag, 38}, + {"concatstring5", funcTag, 39}, + {"concatstrings", funcTag, 41}, + {"concatbyte2", funcTag, 43}, + {"concatbyte3", funcTag, 44}, + {"concatbyte4", funcTag, 45}, + {"concatbyte5", funcTag, 46}, + {"concatbytes", funcTag, 47}, + {"cmpstring", funcTag, 48}, + {"intstring", funcTag, 51}, + {"slicebytetostring", funcTag, 52}, + {"slicebytetostringtmp", funcTag, 53}, + {"slicerunetostring", funcTag, 56}, + {"stringtoslicebyte", funcTag, 57}, + {"stringtoslicerune", funcTag, 60}, + {"slicecopy", funcTag, 61}, + {"decoderune", funcTag, 62}, + {"countrunes", funcTag, 63}, + {"convT", funcTag, 64}, + {"convTnoptr", funcTag, 64}, + {"convT16", funcTag, 66}, + {"convT32", funcTag, 68}, + {"convT64", funcTag, 69}, + {"convTstring", funcTag, 70}, + {"convTslice", funcTag, 73}, + {"assertE2I", funcTag, 74}, + {"assertE2I2", funcTag, 74}, + {"panicdottypeE", funcTag, 75}, + {"panicdottypeI", funcTag, 75}, + {"panicnildottype", funcTag, 76}, + {"typeAssert", funcTag, 74}, + {"interfaceSwitch", funcTag, 77}, + {"ifaceeq", funcTag, 79}, + {"efaceeq", funcTag, 79}, + {"panicrangestate", funcTag, 80}, + {"deferrangefunc", funcTag, 12}, + {"rand", funcTag, 81}, + {"rand32", funcTag, 82}, + {"makemap64", funcTag, 84}, + {"makemap", funcTag, 85}, + {"makemap_small", funcTag, 86}, + {"mapaccess1", funcTag, 87}, + {"mapaccess1_fast32", funcTag, 88}, + {"mapaccess1_fast64", funcTag, 89}, + {"mapaccess1_faststr", funcTag, 90}, + {"mapaccess1_fat", funcTag, 91}, + {"mapaccess2", funcTag, 92}, + {"mapaccess2_fast32", funcTag, 93}, + {"mapaccess2_fast64", funcTag, 94}, + {"mapaccess2_faststr", funcTag, 95}, + {"mapaccess2_fat", funcTag, 96}, + {"mapassign", funcTag, 87}, + {"mapassign_fast32", funcTag, 88}, + {"mapassign_fast32ptr", funcTag, 97}, + {"mapassign_fast64", funcTag, 89}, + {"mapassign_fast64ptr", funcTag, 97}, + {"mapassign_faststr", funcTag, 90}, + {"mapIterStart", funcTag, 98}, + {"mapdelete", funcTag, 98}, + {"mapdelete_fast32", funcTag, 99}, + {"mapdelete_fast64", funcTag, 100}, + {"mapdelete_faststr", funcTag, 101}, + {"mapIterNext", funcTag, 102}, + {"mapclear", funcTag, 103}, + {"makechan64", funcTag, 105}, + {"makechan", funcTag, 106}, + {"chanrecv1", funcTag, 108}, + {"chanrecv2", funcTag, 109}, + {"chansend1", funcTag, 111}, + {"closechan", funcTag, 112}, + {"chanlen", funcTag, 113}, + {"chancap", funcTag, 113}, + {"writeBarrier", varTag, 115}, + {"typedmemmove", funcTag, 116}, + {"typedmemclr", funcTag, 117}, + {"typedslicecopy", funcTag, 118}, + {"selectnbsend", funcTag, 119}, + {"selectnbrecv", funcTag, 120}, + {"selectsetpc", funcTag, 121}, + {"selectgo", funcTag, 122}, + {"block", funcTag, 9}, + {"makeslice", funcTag, 123}, + {"makeslice64", funcTag, 124}, + {"makeslicecopy", funcTag, 125}, + {"growslice", funcTag, 127}, + {"growsliceBuf", funcTag, 128}, + {"growsliceBufNoAlias", funcTag, 128}, + {"growsliceNoAlias", funcTag, 127}, + {"unsafeslicecheckptr", funcTag, 129}, + {"panicunsafeslicelen", funcTag, 9}, + {"panicunsafeslicenilptr", funcTag, 9}, + {"unsafestringcheckptr", funcTag, 130}, + {"panicunsafestringlen", funcTag, 9}, + {"panicunsafestringnilptr", funcTag, 9}, + {"moveSlice", funcTag, 131}, + {"moveSliceNoScan", funcTag, 132}, + {"moveSliceNoCap", funcTag, 133}, + {"moveSliceNoCapNoScan", funcTag, 134}, + {"memmove", funcTag, 135}, + {"memclrNoHeapPointers", funcTag, 136}, + {"memclrHasPointers", funcTag, 136}, + {"memequal", funcTag, 137}, + {"memequal0", funcTag, 138}, + {"memequal8", funcTag, 138}, + {"memequal16", funcTag, 138}, + {"memequal32", funcTag, 138}, + {"memequal64", funcTag, 138}, + {"memequal128", funcTag, 138}, + {"f32equal", funcTag, 139}, + {"f64equal", funcTag, 139}, + {"c64equal", funcTag, 139}, + {"c128equal", funcTag, 139}, + {"strequal", funcTag, 139}, + {"interequal", funcTag, 139}, + {"nilinterequal", funcTag, 139}, + {"memhash", funcTag, 140}, + {"memhash0", funcTag, 141}, + {"memhash8", funcTag, 141}, + {"memhash16", funcTag, 141}, + {"memhash32", funcTag, 141}, + {"memhash64", funcTag, 141}, + {"memhash128", funcTag, 141}, + {"f32hash", funcTag, 142}, + {"f64hash", funcTag, 142}, + {"c64hash", funcTag, 142}, + {"c128hash", funcTag, 142}, + {"strhash", funcTag, 142}, + {"interhash", funcTag, 142}, + {"nilinterhash", funcTag, 142}, + {"int64div", funcTag, 143}, + {"uint64div", funcTag, 144}, + {"int64mod", funcTag, 143}, + {"uint64mod", funcTag, 144}, + {"float64toint64", funcTag, 145}, + {"float64touint64", funcTag, 146}, + {"float64touint32", funcTag, 147}, + {"int64tofloat64", funcTag, 148}, + {"int64tofloat32", funcTag, 149}, + {"uint64tofloat64", funcTag, 150}, + {"uint64tofloat32", funcTag, 151}, + {"uint32tofloat64", funcTag, 152}, + {"complex128div", funcTag, 153}, + {"racefuncenter", funcTag, 33}, + {"racefuncexit", funcTag, 9}, + {"raceread", funcTag, 33}, + {"racewrite", funcTag, 33}, + {"racereadrange", funcTag, 154}, + {"racewriterange", funcTag, 154}, + {"msanread", funcTag, 154}, + {"msanwrite", funcTag, 154}, + {"msanmove", funcTag, 155}, + {"asanread", funcTag, 154}, + {"asanwrite", funcTag, 154}, + {"checkptrAlignment", funcTag, 156}, + {"checkptrArithmetic", funcTag, 158}, + {"libfuzzerTraceCmp1", funcTag, 159}, + {"libfuzzerTraceCmp2", funcTag, 160}, + {"libfuzzerTraceCmp4", funcTag, 161}, + {"libfuzzerTraceCmp8", funcTag, 162}, + {"libfuzzerTraceConstCmp1", funcTag, 159}, + {"libfuzzerTraceConstCmp2", funcTag, 160}, + {"libfuzzerTraceConstCmp4", funcTag, 161}, + {"libfuzzerTraceConstCmp8", funcTag, 162}, + {"libfuzzerHookStrCmp", funcTag, 163}, + {"libfuzzerHookEqualFold", funcTag, 163}, + {"addCovMeta", funcTag, 165}, + {"x86HasAVX", varTag, 6}, + {"x86HasFMA", varTag, 6}, + {"x86HasPOPCNT", varTag, 6}, + {"x86HasSSE41", varTag, 6}, + {"armHasVFPv4", varTag, 6}, + {"arm64HasATOMICS", varTag, 6}, + {"loong64HasLAMCAS", varTag, 6}, + {"loong64HasLAM_BH", varTag, 6}, + {"loong64HasLSX", varTag, 6}, + {"riscv64HasZbb", varTag, 6}, + {"asanregisterglobals", funcTag, 136}, + {"KeepAlive", funcTag, 11}, +} + +func runtimeTypes() []*types.Type { + var typs [166]*types.Type + typs[0] = types.ByteType + typs[1] = types.NewPtr(typs[0]) + typs[2] = types.Types[types.TANY] + typs[3] = types.NewPtr(typs[2]) + typs[4] = newSig(params(typs[1]), params(typs[3])) + typs[5] = types.Types[types.TUINTPTR] + typs[6] = types.Types[types.TBOOL] + typs[7] = types.Types[types.TUNSAFEPTR] + typs[8] = newSig(params(typs[5], typs[1], typs[6]), params(typs[7])) + typs[9] = newSig(nil, nil) + typs[10] = types.Types[types.TINTER] + typs[11] = newSig(params(typs[10]), nil) + typs[12] = newSig(nil, params(typs[10])) + typs[13] = types.Types[types.TINT] + typs[14] = newSig(params(typs[13], typs[13]), nil) + typs[15] = types.Types[types.TUINT] + typs[16] = newSig(params(typs[15], typs[13]), nil) + typs[17] = newSig(params(typs[6]), nil) + typs[18] = types.Types[types.TFLOAT64] + typs[19] = newSig(params(typs[18]), nil) + typs[20] = types.Types[types.TFLOAT32] + typs[21] = newSig(params(typs[20]), nil) + typs[22] = types.Types[types.TINT64] + typs[23] = newSig(params(typs[22]), nil) + typs[24] = types.Types[types.TUINT64] + typs[25] = newSig(params(typs[24]), nil) + typs[26] = types.Types[types.TCOMPLEX128] + typs[27] = newSig(params(typs[26]), nil) + typs[28] = types.Types[types.TCOMPLEX64] + typs[29] = newSig(params(typs[28]), nil) + typs[30] = types.Types[types.TSTRING] + typs[31] = newSig(params(typs[30]), nil) + typs[32] = newSig(params(typs[2]), nil) + typs[33] = newSig(params(typs[5]), nil) + typs[34] = types.NewArray(typs[0], 32) + typs[35] = types.NewPtr(typs[34]) + typs[36] = newSig(params(typs[35], typs[30], typs[30]), params(typs[30])) + typs[37] = newSig(params(typs[35], typs[30], typs[30], typs[30]), params(typs[30])) + typs[38] = newSig(params(typs[35], typs[30], typs[30], typs[30], typs[30]), params(typs[30])) + typs[39] = newSig(params(typs[35], typs[30], typs[30], typs[30], typs[30], typs[30]), params(typs[30])) + typs[40] = types.NewSlice(typs[30]) + typs[41] = newSig(params(typs[35], typs[40]), params(typs[30])) + typs[42] = types.NewSlice(typs[0]) + typs[43] = newSig(params(typs[35], typs[30], typs[30]), params(typs[42])) + typs[44] = newSig(params(typs[35], typs[30], typs[30], typs[30]), params(typs[42])) + typs[45] = newSig(params(typs[35], typs[30], typs[30], typs[30], typs[30]), params(typs[42])) + typs[46] = newSig(params(typs[35], typs[30], typs[30], typs[30], typs[30], typs[30]), params(typs[42])) + typs[47] = newSig(params(typs[35], typs[40]), params(typs[42])) + typs[48] = newSig(params(typs[30], typs[30]), params(typs[13])) + typs[49] = types.NewArray(typs[0], 4) + typs[50] = types.NewPtr(typs[49]) + typs[51] = newSig(params(typs[50], typs[22]), params(typs[30])) + typs[52] = newSig(params(typs[35], typs[1], typs[13]), params(typs[30])) + typs[53] = newSig(params(typs[1], typs[13]), params(typs[30])) + typs[54] = types.RuneType + typs[55] = types.NewSlice(typs[54]) + typs[56] = newSig(params(typs[35], typs[55]), params(typs[30])) + typs[57] = newSig(params(typs[35], typs[30]), params(typs[42])) + typs[58] = types.NewArray(typs[54], 32) + typs[59] = types.NewPtr(typs[58]) + typs[60] = newSig(params(typs[59], typs[30]), params(typs[55])) + typs[61] = newSig(params(typs[3], typs[13], typs[3], typs[13], typs[5]), params(typs[13])) + typs[62] = newSig(params(typs[30], typs[13]), params(typs[54], typs[13])) + typs[63] = newSig(params(typs[30]), params(typs[13])) + typs[64] = newSig(params(typs[1], typs[3]), params(typs[7])) + typs[65] = types.Types[types.TUINT16] + typs[66] = newSig(params(typs[65]), params(typs[7])) + typs[67] = types.Types[types.TUINT32] + typs[68] = newSig(params(typs[67]), params(typs[7])) + typs[69] = newSig(params(typs[24]), params(typs[7])) + typs[70] = newSig(params(typs[30]), params(typs[7])) + typs[71] = types.Types[types.TUINT8] + typs[72] = types.NewSlice(typs[71]) + typs[73] = newSig(params(typs[72]), params(typs[7])) + typs[74] = newSig(params(typs[1], typs[1]), params(typs[1])) + typs[75] = newSig(params(typs[1], typs[1], typs[1]), nil) + typs[76] = newSig(params(typs[1]), nil) + typs[77] = newSig(params(typs[1], typs[1]), params(typs[13], typs[1])) + typs[78] = types.NewPtr(typs[5]) + typs[79] = newSig(params(typs[78], typs[7], typs[7]), params(typs[6])) + typs[80] = newSig(params(typs[13]), nil) + typs[81] = newSig(nil, params(typs[24])) + typs[82] = newSig(nil, params(typs[67])) + typs[83] = types.NewMap(typs[2], typs[2]) + typs[84] = newSig(params(typs[1], typs[22], typs[3]), params(typs[83])) + typs[85] = newSig(params(typs[1], typs[13], typs[3]), params(typs[83])) + typs[86] = newSig(nil, params(typs[83])) + typs[87] = newSig(params(typs[1], typs[83], typs[3]), params(typs[3])) + typs[88] = newSig(params(typs[1], typs[83], typs[67]), params(typs[3])) + typs[89] = newSig(params(typs[1], typs[83], typs[24]), params(typs[3])) + typs[90] = newSig(params(typs[1], typs[83], typs[30]), params(typs[3])) + typs[91] = newSig(params(typs[1], typs[83], typs[3], typs[1]), params(typs[3])) + typs[92] = newSig(params(typs[1], typs[83], typs[3]), params(typs[3], typs[6])) + typs[93] = newSig(params(typs[1], typs[83], typs[67]), params(typs[3], typs[6])) + typs[94] = newSig(params(typs[1], typs[83], typs[24]), params(typs[3], typs[6])) + typs[95] = newSig(params(typs[1], typs[83], typs[30]), params(typs[3], typs[6])) + typs[96] = newSig(params(typs[1], typs[83], typs[3], typs[1]), params(typs[3], typs[6])) + typs[97] = newSig(params(typs[1], typs[83], typs[7]), params(typs[3])) + typs[98] = newSig(params(typs[1], typs[83], typs[3]), nil) + typs[99] = newSig(params(typs[1], typs[83], typs[67]), nil) + typs[100] = newSig(params(typs[1], typs[83], typs[24]), nil) + typs[101] = newSig(params(typs[1], typs[83], typs[30]), nil) + typs[102] = newSig(params(typs[3]), nil) + typs[103] = newSig(params(typs[1], typs[83]), nil) + typs[104] = types.NewChan(typs[2], types.Cboth) + typs[105] = newSig(params(typs[1], typs[22]), params(typs[104])) + typs[106] = newSig(params(typs[1], typs[13]), params(typs[104])) + typs[107] = types.NewChan(typs[2], types.Crecv) + typs[108] = newSig(params(typs[107], typs[3]), nil) + typs[109] = newSig(params(typs[107], typs[3]), params(typs[6])) + typs[110] = types.NewChan(typs[2], types.Csend) + typs[111] = newSig(params(typs[110], typs[3]), nil) + typs[112] = newSig(params(typs[110]), nil) + typs[113] = newSig(params(typs[2]), params(typs[13])) + typs[114] = types.NewArray(typs[0], 3) + typs[115] = types.NewStruct([]*types.Field{types.NewField(src.NoXPos, Lookup("enabled"), typs[6]), types.NewField(src.NoXPos, Lookup("pad"), typs[114]), types.NewField(src.NoXPos, Lookup("cgo"), typs[6]), types.NewField(src.NoXPos, Lookup("alignme"), typs[24])}) + typs[116] = newSig(params(typs[1], typs[3], typs[3]), nil) + typs[117] = newSig(params(typs[1], typs[3]), nil) + typs[118] = newSig(params(typs[1], typs[3], typs[13], typs[3], typs[13]), params(typs[13])) + typs[119] = newSig(params(typs[110], typs[3]), params(typs[6])) + typs[120] = newSig(params(typs[3], typs[107]), params(typs[6], typs[6])) + typs[121] = newSig(params(typs[78]), nil) + typs[122] = newSig(params(typs[1], typs[1], typs[78], typs[13], typs[13], typs[6]), params(typs[13], typs[6])) + typs[123] = newSig(params(typs[1], typs[13], typs[13]), params(typs[7])) + typs[124] = newSig(params(typs[1], typs[22], typs[22]), params(typs[7])) + typs[125] = newSig(params(typs[1], typs[13], typs[13], typs[7]), params(typs[7])) + typs[126] = types.NewSlice(typs[2]) + typs[127] = newSig(params(typs[3], typs[13], typs[13], typs[13], typs[1]), params(typs[126])) + typs[128] = newSig(params(typs[3], typs[13], typs[13], typs[13], typs[1], typs[3], typs[13]), params(typs[126])) + typs[129] = newSig(params(typs[1], typs[7], typs[22]), nil) + typs[130] = newSig(params(typs[7], typs[22]), nil) + typs[131] = newSig(params(typs[1], typs[1], typs[13], typs[13]), params(typs[1], typs[13], typs[13])) + typs[132] = newSig(params(typs[5], typs[1], typs[13], typs[13]), params(typs[1], typs[13], typs[13])) + typs[133] = newSig(params(typs[1], typs[1], typs[13]), params(typs[1], typs[13], typs[13])) + typs[134] = newSig(params(typs[5], typs[1], typs[13]), params(typs[1], typs[13], typs[13])) + typs[135] = newSig(params(typs[3], typs[3], typs[5]), nil) + typs[136] = newSig(params(typs[7], typs[5]), nil) + typs[137] = newSig(params(typs[3], typs[3], typs[5]), params(typs[6])) + typs[138] = newSig(params(typs[3], typs[3]), params(typs[6])) + typs[139] = newSig(params(typs[7], typs[7]), params(typs[6])) + typs[140] = newSig(params(typs[3], typs[5], typs[5]), params(typs[5])) + typs[141] = newSig(params(typs[7], typs[5]), params(typs[5])) + typs[142] = newSig(params(typs[3], typs[5]), params(typs[5])) + typs[143] = newSig(params(typs[22], typs[22]), params(typs[22])) + typs[144] = newSig(params(typs[24], typs[24]), params(typs[24])) + typs[145] = newSig(params(typs[18]), params(typs[22])) + typs[146] = newSig(params(typs[18]), params(typs[24])) + typs[147] = newSig(params(typs[18]), params(typs[67])) + typs[148] = newSig(params(typs[22]), params(typs[18])) + typs[149] = newSig(params(typs[22]), params(typs[20])) + typs[150] = newSig(params(typs[24]), params(typs[18])) + typs[151] = newSig(params(typs[24]), params(typs[20])) + typs[152] = newSig(params(typs[67]), params(typs[18])) + typs[153] = newSig(params(typs[26], typs[26]), params(typs[26])) + typs[154] = newSig(params(typs[5], typs[5]), nil) + typs[155] = newSig(params(typs[5], typs[5], typs[5]), nil) + typs[156] = newSig(params(typs[7], typs[1], typs[5]), nil) + typs[157] = types.NewSlice(typs[7]) + typs[158] = newSig(params(typs[7], typs[157]), nil) + typs[159] = newSig(params(typs[71], typs[71], typs[15]), nil) + typs[160] = newSig(params(typs[65], typs[65], typs[15]), nil) + typs[161] = newSig(params(typs[67], typs[67], typs[15]), nil) + typs[162] = newSig(params(typs[24], typs[24], typs[15]), nil) + typs[163] = newSig(params(typs[30], typs[30], typs[15]), nil) + typs[164] = types.NewArray(typs[0], 16) + typs[165] = newSig(params(typs[7], typs[67], typs[164], typs[30], typs[13], typs[71], typs[71]), params(typs[67])) + return typs[:] +} + +var coverageDecls = [...]struct { + name string + tag int + typ int +}{ + {"initHook", funcTag, 1}, +} + +func coverageTypes() []*types.Type { + var typs [2]*types.Type + typs[0] = types.Types[types.TBOOL] + typs[1] = newSig(params(typs[0]), nil) + return typs[:] +} diff --git a/go/src/cmd/compile/internal/typecheck/builtin_test.go b/go/src/cmd/compile/internal/typecheck/builtin_test.go new file mode 100644 index 0000000000000000000000000000000000000000..3c0d6b81712ead54763294be4f3b481b8f12f0d9 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/builtin_test.go @@ -0,0 +1,31 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +import ( + "bytes" + "internal/testenv" + "os" + "testing" +) + +func TestBuiltin(t *testing.T) { + testenv.MustHaveGoRun(t) + t.Parallel() + + old, err := os.ReadFile("builtin.go") + if err != nil { + t.Fatal(err) + } + + new, err := testenv.Command(t, testenv.GoToolPath(t), "run", "mkbuiltin.go", "-stdout").Output() + if err != nil { + t.Fatal(err) + } + + if !bytes.Equal(old, new) { + t.Fatal("builtin.go out of date; run mkbuiltin.go") + } +} diff --git a/go/src/cmd/compile/internal/typecheck/const.go b/go/src/cmd/compile/internal/typecheck/const.go new file mode 100644 index 0000000000000000000000000000000000000000..6a664156af2649f43ed71fd7a4efde5e4ca253b3 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/const.go @@ -0,0 +1,467 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +import ( + "fmt" + "go/constant" + "go/token" + "math" + "math/big" + "unicode" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" +) + +func roundFloat(v constant.Value, sz int64) constant.Value { + switch sz { + case 4: + f, _ := constant.Float32Val(v) + return makeFloat64(float64(f)) + case 8: + f, _ := constant.Float64Val(v) + return makeFloat64(f) + } + base.Fatalf("unexpected size: %v", sz) + panic("unreachable") +} + +// truncate float literal fv to 32-bit or 64-bit precision +// according to type; return truncated value. +func truncfltlit(v constant.Value, t *types.Type) constant.Value { + if t.IsUntyped() { + return v + } + + return roundFloat(v, t.Size()) +} + +// truncate Real and Imag parts of Mpcplx to 32-bit or 64-bit +// precision, according to type; return truncated value. In case of +// overflow, calls Errorf but does not truncate the input value. +func trunccmplxlit(v constant.Value, t *types.Type) constant.Value { + if t.IsUntyped() { + return v + } + + fsz := t.Size() / 2 + return makeComplex(roundFloat(constant.Real(v), fsz), roundFloat(constant.Imag(v), fsz)) +} + +// TODO(mdempsky): Replace these with better APIs. +func convlit(n ir.Node, t *types.Type) ir.Node { return convlit1(n, t, false, nil) } +func DefaultLit(n ir.Node, t *types.Type) ir.Node { return convlit1(n, t, false, nil) } + +// convlit1 converts an untyped expression n to type t. If n already +// has a type, convlit1 has no effect. +// +// For explicit conversions, t must be non-nil, and integer-to-string +// conversions are allowed. +// +// For implicit conversions (e.g., assignments), t may be nil; if so, +// n is converted to its default type. +// +// If there's an error converting n to t, context is used in the error +// message. +func convlit1(n ir.Node, t *types.Type, explicit bool, context func() string) ir.Node { + if explicit && t == nil { + base.Fatalf("explicit conversion missing type") + } + if t != nil && t.IsUntyped() { + base.Fatalf("bad conversion to untyped: %v", t) + } + + if n == nil || n.Type() == nil { + // Allow sloppy callers. + return n + } + if !n.Type().IsUntyped() { + // Already typed; nothing to do. + return n + } + + // Nil is technically not a constant, so handle it specially. + if n.Type().Kind() == types.TNIL { + if n.Op() != ir.ONIL { + base.Fatalf("unexpected op: %v (%v)", n, n.Op()) + } + n = ir.Copy(n) + if t == nil { + base.Fatalf("use of untyped nil") + } + + if !t.HasNil() { + // Leave for caller to handle. + return n + } + + n.SetType(t) + return n + } + + if t == nil || !ir.OKForConst[t.Kind()] { + t = defaultType(n.Type()) + } + + switch n.Op() { + default: + base.Fatalf("unexpected untyped expression: %v", n) + + case ir.OLITERAL: + v := ConvertVal(n.Val(), t, explicit) + if v.Kind() == constant.Unknown { + n = ir.NewConstExpr(n.Val(), n) + break + } + n = ir.NewConstExpr(v, n) + n.SetType(t) + return n + + case ir.OPLUS, ir.ONEG, ir.OBITNOT, ir.ONOT, ir.OREAL, ir.OIMAG: + ot := operandType(n.Op(), t) + if ot == nil { + n = DefaultLit(n, nil) + break + } + + n := n.(*ir.UnaryExpr) + n.X = convlit(n.X, ot) + if n.X.Type() == nil { + n.SetType(nil) + return n + } + n.SetType(t) + return n + + case ir.OADD, ir.OSUB, ir.OMUL, ir.ODIV, ir.OMOD, ir.OOR, ir.OXOR, ir.OAND, ir.OANDNOT, ir.OOROR, ir.OANDAND, ir.OCOMPLEX: + ot := operandType(n.Op(), t) + if ot == nil { + n = DefaultLit(n, nil) + break + } + + var l, r ir.Node + switch n := n.(type) { + case *ir.BinaryExpr: + n.X = convlit(n.X, ot) + n.Y = convlit(n.Y, ot) + l, r = n.X, n.Y + case *ir.LogicalExpr: + n.X = convlit(n.X, ot) + n.Y = convlit(n.Y, ot) + l, r = n.X, n.Y + } + + if l.Type() == nil || r.Type() == nil { + n.SetType(nil) + return n + } + if !types.Identical(l.Type(), r.Type()) { + base.Errorf("invalid operation: %v (mismatched types %v and %v)", n, l.Type(), r.Type()) + n.SetType(nil) + return n + } + + n.SetType(t) + return n + + case ir.OEQ, ir.ONE, ir.OLT, ir.OLE, ir.OGT, ir.OGE: + n := n.(*ir.BinaryExpr) + if !t.IsBoolean() { + break + } + n.SetType(t) + return n + + case ir.OLSH, ir.ORSH: + n := n.(*ir.BinaryExpr) + n.X = convlit1(n.X, t, explicit, nil) + n.SetType(n.X.Type()) + if n.Type() != nil && !n.Type().IsInteger() { + base.Errorf("invalid operation: %v (shift of type %v)", n, n.Type()) + n.SetType(nil) + } + return n + } + + if explicit { + base.Fatalf("cannot convert %L to type %v", n, t) + } else if context != nil { + base.Fatalf("cannot use %L as type %v in %s", n, t, context()) + } else { + base.Fatalf("cannot use %L as type %v", n, t) + } + + n.SetType(nil) + return n +} + +func operandType(op ir.Op, t *types.Type) *types.Type { + switch op { + case ir.OCOMPLEX: + if t.IsComplex() { + return types.FloatForComplex(t) + } + case ir.OREAL, ir.OIMAG: + if t.IsFloat() { + return types.ComplexForFloat(t) + } + default: + if okfor[op][t.Kind()] { + return t + } + } + return nil +} + +// ConvertVal converts v into a representation appropriate for t. If +// no such representation exists, it returns constant.MakeUnknown() +// instead. +// +// If explicit is true, then conversions from integer to string are +// also allowed. +func ConvertVal(v constant.Value, t *types.Type, explicit bool) constant.Value { + switch ct := v.Kind(); ct { + case constant.Bool: + if t.IsBoolean() { + return v + } + + case constant.String: + if t.IsString() { + return v + } + + case constant.Int: + if explicit && t.IsString() { + return tostr(v) + } + fallthrough + case constant.Float, constant.Complex: + switch { + case t.IsInteger(): + v = toint(v) + return v + case t.IsFloat(): + v = toflt(v) + v = truncfltlit(v, t) + return v + case t.IsComplex(): + v = tocplx(v) + v = trunccmplxlit(v, t) + return v + } + } + + return constant.MakeUnknown() +} + +func tocplx(v constant.Value) constant.Value { + return constant.ToComplex(v) +} + +func toflt(v constant.Value) constant.Value { + if v.Kind() == constant.Complex { + v = constant.Real(v) + } + + return constant.ToFloat(v) +} + +func toint(v constant.Value) constant.Value { + if v.Kind() == constant.Complex { + v = constant.Real(v) + } + + if v := constant.ToInt(v); v.Kind() == constant.Int { + return v + } + + // The value of v cannot be represented as an integer; + // so we need to print an error message. + // Unfortunately some float values cannot be + // reasonably formatted for inclusion in an error + // message (example: 1 + 1e-100), so first we try to + // format the float; if the truncation resulted in + // something that looks like an integer we omit the + // value from the error message. + // (See issue #11371). + f := ir.BigFloat(v) + if f.MantExp(nil) > 2*ir.ConstPrec { + base.Errorf("integer too large") + } else { + var t big.Float + t.Parse(fmt.Sprint(v), 0) + if t.IsInt() { + base.Errorf("constant truncated to integer") + } else { + base.Errorf("constant %v truncated to integer", v) + } + } + + // Prevent follow-on errors. + return constant.MakeUnknown() +} + +func tostr(v constant.Value) constant.Value { + if v.Kind() == constant.Int { + r := unicode.ReplacementChar + if x, ok := constant.Uint64Val(v); ok && x <= unicode.MaxRune { + r = rune(x) + } + v = constant.MakeString(string(r)) + } + return v +} + +func makeFloat64(f float64) constant.Value { + if math.IsInf(f, 0) { + base.Fatalf("infinity is not a valid constant") + } + return constant.MakeFloat64(f) +} + +func makeComplex(real, imag constant.Value) constant.Value { + return constant.BinaryOp(constant.ToFloat(real), token.ADD, constant.MakeImag(constant.ToFloat(imag))) +} + +// DefaultLit on both nodes simultaneously; +// if they're both ideal going in they better +// get the same type going out. +// force means must assign concrete (non-ideal) type. +// The results of defaultlit2 MUST be assigned back to l and r, e.g. +// +// n.Left, n.Right = defaultlit2(n.Left, n.Right, force) +func defaultlit2(l ir.Node, r ir.Node, force bool) (ir.Node, ir.Node) { + if l.Type() == nil || r.Type() == nil { + return l, r + } + + if !l.Type().IsInterface() && !r.Type().IsInterface() { + // Can't mix bool with non-bool, string with non-string. + if l.Type().IsBoolean() != r.Type().IsBoolean() { + return l, r + } + if l.Type().IsString() != r.Type().IsString() { + return l, r + } + } + + if !l.Type().IsUntyped() { + r = convlit(r, l.Type()) + return l, r + } + + if !r.Type().IsUntyped() { + l = convlit(l, r.Type()) + return l, r + } + + if !force { + return l, r + } + + // Can't mix nil with anything untyped. + if ir.IsNil(l) || ir.IsNil(r) { + return l, r + } + t := defaultType(mixUntyped(l.Type(), r.Type())) + l = convlit(l, t) + r = convlit(r, t) + return l, r +} + +func mixUntyped(t1, t2 *types.Type) *types.Type { + if t1 == t2 { + return t1 + } + + rank := func(t *types.Type) int { + switch t { + case types.UntypedInt: + return 0 + case types.UntypedRune: + return 1 + case types.UntypedFloat: + return 2 + case types.UntypedComplex: + return 3 + } + base.Fatalf("bad type %v", t) + panic("unreachable") + } + + if rank(t2) > rank(t1) { + return t2 + } + return t1 +} + +func defaultType(t *types.Type) *types.Type { + if !t.IsUntyped() || t.Kind() == types.TNIL { + return t + } + + switch t { + case types.UntypedBool: + return types.Types[types.TBOOL] + case types.UntypedString: + return types.Types[types.TSTRING] + case types.UntypedInt: + return types.Types[types.TINT] + case types.UntypedRune: + return types.RuneType + case types.UntypedFloat: + return types.Types[types.TFLOAT64] + case types.UntypedComplex: + return types.Types[types.TCOMPLEX128] + } + + base.Fatalf("bad type %v", t) + return nil +} + +// IndexConst returns the index value of constant Node n. +func IndexConst(n ir.Node) int64 { + return ir.IntVal(types.Types[types.TINT], toint(n.Val())) +} + +// callOrChan reports whether n is a call or channel operation. +func callOrChan(n ir.Node) bool { + switch n.Op() { + case ir.OAPPEND, + ir.OCALL, + ir.OCALLFUNC, + ir.OCALLINTER, + ir.OCALLMETH, + ir.OCAP, + ir.OCLEAR, + ir.OCLOSE, + ir.OCOMPLEX, + ir.OCOPY, + ir.ODELETE, + ir.OIMAG, + ir.OLEN, + ir.OMAKE, + ir.OMAX, + ir.OMIN, + ir.ONEW, + ir.OPANIC, + ir.OPRINT, + ir.OPRINTLN, + ir.OREAL, + ir.ORECOVER, + ir.ORECV, + ir.OUNSAFEADD, + ir.OUNSAFESLICE, + ir.OUNSAFESLICEDATA, + ir.OUNSAFESTRING, + ir.OUNSAFESTRINGDATA: + return true + } + return false +} diff --git a/go/src/cmd/compile/internal/typecheck/dcl.go b/go/src/cmd/compile/internal/typecheck/dcl.go new file mode 100644 index 0000000000000000000000000000000000000000..ce3b9b4366845238f168614d44c8bcd625347e67 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/dcl.go @@ -0,0 +1,130 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +import ( + "fmt" + "sync" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +var funcStack []*ir.Func // stack of previous values of ir.CurFunc + +// DeclFunc declares the parameters for fn and adds it to +// Target.Funcs. +// +// Before returning, it sets CurFunc to fn. When the caller is done +// constructing fn, it must call FinishFuncBody to restore CurFunc. +func DeclFunc(fn *ir.Func) { + fn.DeclareParams(true) + fn.Nname.Defn = fn + Target.Funcs = append(Target.Funcs, fn) + + funcStack = append(funcStack, ir.CurFunc) + ir.CurFunc = fn +} + +// FinishFuncBody restores ir.CurFunc to its state before the last +// call to DeclFunc. +func FinishFuncBody() { + funcStack, ir.CurFunc = funcStack[:len(funcStack)-1], funcStack[len(funcStack)-1] +} + +func CheckFuncStack() { + if len(funcStack) != 0 { + base.Fatalf("funcStack is non-empty: %v", len(funcStack)) + } +} + +// TempAt makes a new Node off the books. +// +// N.B., the new Node is a function-local variable defaulting to function scope. +// It helps in some cases if an ODCL is also created and placed in a narrower scope, +// such as if the variable can be used in a loop body and potentially escape. +// TODO: Consider some mechanism to more conveniently create a block scoped temporary. +func TempAt(pos src.XPos, curfn *ir.Func, typ *types.Type) *ir.Name { + if curfn == nil { + base.FatalfAt(pos, "no curfn for TempAt") + } + if typ == nil { + base.FatalfAt(pos, "TempAt called with nil type") + } + if typ.Kind() == types.TFUNC && typ.Recv() != nil { + base.FatalfAt(pos, "misuse of method type: %v", typ) + } + types.CalcSize(typ) + + sym := &types.Sym{ + Name: autotmpname(len(curfn.Dcl)), + Pkg: types.LocalPkg, + } + name := curfn.NewLocal(pos, sym, typ) + name.SetEsc(ir.EscNever) + name.SetUsed(true) + name.SetAutoTemp(true) + + return name +} + +var ( + autotmpnamesmu sync.Mutex + autotmpnames []string +) + +// autotmpname returns the name for an autotmp variable numbered n. +func autotmpname(n int) string { + autotmpnamesmu.Lock() + defer autotmpnamesmu.Unlock() + + // Grow autotmpnames, if needed. + if n >= len(autotmpnames) { + autotmpnames = append(autotmpnames, make([]string, n+1-len(autotmpnames))...) + autotmpnames = autotmpnames[:cap(autotmpnames)] + } + + s := autotmpnames[n] + if s == "" { + // Give each tmp a different name so that they can be registerized. + // Add a preceding . to avoid clashing with legal names. + prefix := ".autotmp_%d" + + s = fmt.Sprintf(prefix, n) + autotmpnames[n] = s + } + return s +} + +// f is method type, with receiver. +// return function type, receiver as first argument (or not). +func NewMethodType(sig *types.Type, recv *types.Type) *types.Type { + nrecvs := 0 + if recv != nil { + nrecvs++ + } + + // TODO(mdempsky): Move this function to types. + // TODO(mdempsky): Preserve positions, names, and package from sig+recv. + + params := make([]*types.Field, nrecvs+sig.NumParams()) + if recv != nil { + params[0] = types.NewField(base.Pos, nil, recv) + } + for i, param := range sig.Params() { + d := types.NewField(base.Pos, nil, param.Type) + d.SetIsDDD(param.IsDDD()) + params[nrecvs+i] = d + } + + results := make([]*types.Field, sig.NumResults()) + for i, t := range sig.Results() { + results[i] = types.NewField(base.Pos, nil, t.Type) + } + + return types.NewSignature(nil, params, results) +} diff --git a/go/src/cmd/compile/internal/typecheck/export.go b/go/src/cmd/compile/internal/typecheck/export.go new file mode 100644 index 0000000000000000000000000000000000000000..585c1b78c23169345e61e0bfa0095fa3710cffa1 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/export.go @@ -0,0 +1,33 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +// importfunc declares symbol s as an imported function with type t. +func importfunc(s *types.Sym, t *types.Type) { + fn := ir.NewFunc(src.NoXPos, src.NoXPos, s, t) + importsym(fn.Nname) +} + +// importvar declares symbol s as an imported variable with type t. +func importvar(s *types.Sym, t *types.Type) { + n := ir.NewNameAt(src.NoXPos, s, t) + n.Class = ir.PEXTERN + importsym(n) +} + +func importsym(name *ir.Name) { + sym := name.Sym() + if sym.Def != nil { + base.Fatalf("importsym of symbol that already exists: %v", sym.Def) + } + sym.Def = name +} diff --git a/go/src/cmd/compile/internal/typecheck/expr.go b/go/src/cmd/compile/internal/typecheck/expr.go new file mode 100644 index 0000000000000000000000000000000000000000..7dc29636cce76f8548be97195354464f94ec5b06 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/expr.go @@ -0,0 +1,903 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +import ( + "fmt" + "go/constant" + "internal/types/errors" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +func tcShift(n, l, r ir.Node) (ir.Node, ir.Node, *types.Type) { + if l.Type() == nil || r.Type() == nil { + return l, r, nil + } + + r = DefaultLit(r, types.Types[types.TUINT]) + t := r.Type() + if !t.IsInteger() { + base.Errorf("invalid operation: %v (shift count type %v, must be integer)", n, r.Type()) + return l, r, nil + } + t = l.Type() + if t != nil && t.Kind() != types.TIDEAL && !t.IsInteger() { + base.Errorf("invalid operation: %v (shift of type %v)", n, t) + return l, r, nil + } + + // no DefaultLit for left + // the outer context gives the type + t = l.Type() + if (l.Type() == types.UntypedFloat || l.Type() == types.UntypedComplex) && r.Op() == ir.OLITERAL { + t = types.UntypedInt + } + return l, r, t +} + +// tcArith typechecks operands of a binary arithmetic expression. +// The result of tcArith MUST be assigned back to original operands, +// t is the type of the expression, and should be set by the caller. e.g: +// +// n.X, n.Y, t = tcArith(n, op, n.X, n.Y) +// n.SetType(t) +func tcArith(n ir.Node, op ir.Op, l, r ir.Node) (ir.Node, ir.Node, *types.Type) { + l, r = defaultlit2(l, r, false) + if l.Type() == nil || r.Type() == nil { + return l, r, nil + } + t := l.Type() + if t.Kind() == types.TIDEAL { + t = r.Type() + } + aop := ir.OXXX + if n.Op().IsCmp() && t.Kind() != types.TIDEAL && !types.Identical(l.Type(), r.Type()) { + // comparison is okay as long as one side is + // assignable to the other. convert so they have + // the same type. + // + // the only conversion that isn't a no-op is concrete == interface. + // in that case, check comparability of the concrete type. + // The conversion allocates, so only do it if the concrete type is huge. + converted := false + if r.Type().Kind() != types.TBLANK { + aop, _ = assignOp(l.Type(), r.Type()) + if aop != ir.OXXX { + if r.Type().IsInterface() && !l.Type().IsInterface() && !types.IsComparable(l.Type()) { + base.Errorf("invalid operation: %v (operator %v not defined on %s)", n, op, typekind(l.Type())) + return l, r, nil + } + + types.CalcSize(l.Type()) + if r.Type().IsInterface() == l.Type().IsInterface() || l.Type().Size() >= 1<<16 { + l = ir.NewConvExpr(base.Pos, aop, r.Type(), l) + l.SetTypecheck(1) + } + + t = r.Type() + converted = true + } + } + + if !converted && l.Type().Kind() != types.TBLANK { + aop, _ = assignOp(r.Type(), l.Type()) + if aop != ir.OXXX { + if l.Type().IsInterface() && !r.Type().IsInterface() && !types.IsComparable(r.Type()) { + base.Errorf("invalid operation: %v (operator %v not defined on %s)", n, op, typekind(r.Type())) + return l, r, nil + } + + types.CalcSize(r.Type()) + if r.Type().IsInterface() == l.Type().IsInterface() || r.Type().Size() >= 1<<16 { + r = ir.NewConvExpr(base.Pos, aop, l.Type(), r) + r.SetTypecheck(1) + } + + t = l.Type() + } + } + } + + if t.Kind() != types.TIDEAL && !types.Identical(l.Type(), r.Type()) { + l, r = defaultlit2(l, r, true) + if l.Type() == nil || r.Type() == nil { + return l, r, nil + } + if l.Type().IsInterface() == r.Type().IsInterface() || aop == 0 { + base.Errorf("invalid operation: %v (mismatched types %v and %v)", n, l.Type(), r.Type()) + return l, r, nil + } + } + + if t.Kind() == types.TIDEAL { + t = mixUntyped(l.Type(), r.Type()) + } + if dt := defaultType(t); !okfor[op][dt.Kind()] { + base.Errorf("invalid operation: %v (operator %v not defined on %s)", n, op, typekind(t)) + return l, r, nil + } + + // okfor allows any array == array, map == map, func == func. + // restrict to slice/map/func == nil and nil == slice/map/func. + if l.Type().IsArray() && !types.IsComparable(l.Type()) { + base.Errorf("invalid operation: %v (%v cannot be compared)", n, l.Type()) + return l, r, nil + } + + if l.Type().IsSlice() && !ir.IsNil(l) && !ir.IsNil(r) { + base.Errorf("invalid operation: %v (slice can only be compared to nil)", n) + return l, r, nil + } + + if l.Type().IsMap() && !ir.IsNil(l) && !ir.IsNil(r) { + base.Errorf("invalid operation: %v (map can only be compared to nil)", n) + return l, r, nil + } + + if l.Type().Kind() == types.TFUNC && !ir.IsNil(l) && !ir.IsNil(r) { + base.Errorf("invalid operation: %v (func can only be compared to nil)", n) + return l, r, nil + } + + if l.Type().IsStruct() { + if f := types.IncomparableField(l.Type()); f != nil { + base.Errorf("invalid operation: %v (struct containing %v cannot be compared)", n, f.Type) + return l, r, nil + } + } + + return l, r, t +} + +// The result of tcCompLit MUST be assigned back to n, e.g. +// +// n.Left = tcCompLit(n.Left) +func tcCompLit(n *ir.CompLitExpr) (res ir.Node) { + if base.EnableTrace && base.Flag.LowerT { + defer tracePrint("tcCompLit", n)(&res) + } + + lno := base.Pos + defer func() { + base.Pos = lno + }() + + ir.SetPos(n) + + t := n.Type() + base.AssertfAt(t != nil, n.Pos(), "missing type in composite literal") + + switch t.Kind() { + default: + base.Errorf("invalid composite literal type %v", t) + n.SetType(nil) + + case types.TARRAY: + typecheckarraylit(t.Elem(), t.NumElem(), n.List, "array literal") + n.SetOp(ir.OARRAYLIT) + + case types.TSLICE: + length := typecheckarraylit(t.Elem(), -1, n.List, "slice literal") + n.SetOp(ir.OSLICELIT) + n.Len = length + + case types.TMAP: + for i3, l := range n.List { + ir.SetPos(l) + if l.Op() != ir.OKEY { + n.List[i3] = Expr(l) + base.Errorf("missing key in map literal") + continue + } + l := l.(*ir.KeyExpr) + + r := l.Key + r = Expr(r) + l.Key = AssignConv(r, t.Key(), "map key") + + r = l.Value + r = Expr(r) + l.Value = AssignConv(r, t.Elem(), "map value") + } + + n.SetOp(ir.OMAPLIT) + + case types.TSTRUCT: + // Need valid field offsets for Xoffset below. + types.CalcSize(t) + + errored := false + if len(n.List) != 0 && nokeys(n.List) { + // simple list of variables + ls := n.List + for i, n1 := range ls { + ir.SetPos(n1) + n1 = Expr(n1) + ls[i] = n1 + if i >= t.NumFields() { + if !errored { + base.Errorf("too many values in %v", n) + errored = true + } + continue + } + + f := t.Field(i) + s := f.Sym + + // Do the test for assigning to unexported fields. + // But if this is an instantiated function, then + // the function has already been typechecked. In + // that case, don't do the test, since it can fail + // for the closure structs created in + // walkClosure(), because the instantiated + // function is compiled as if in the source + // package of the generic function. + if !(ir.CurFunc != nil && strings.Contains(ir.CurFunc.Nname.Sym().Name, "[")) { + if s != nil && !types.IsExported(s.Name) && s.Pkg != types.LocalPkg { + base.Errorf("implicit assignment of unexported field '%s' in %v literal", s.Name, t) + } + } + // No pushtype allowed here. Must name fields for that. + n1 = AssignConv(n1, f.Type, "field value") + ls[i] = ir.NewStructKeyExpr(base.Pos, f, n1) + } + if len(ls) < t.NumFields() { + base.Errorf("too few values in %v", n) + } + } else { + hash := make(map[string]bool) + + // keyed list + ls := n.List + for i, n := range ls { + ir.SetPos(n) + + sk, ok := n.(*ir.StructKeyExpr) + if !ok { + kv, ok := n.(*ir.KeyExpr) + if !ok { + if !errored { + base.Errorf("mixture of field:value and value initializers") + errored = true + } + ls[i] = Expr(n) + continue + } + + sk = tcStructLitKey(t, kv) + if sk == nil { + continue + } + + fielddup(sk.Sym().Name, hash) + } + + // No pushtype allowed here. Tried and rejected. + sk.Value = Expr(sk.Value) + sk.Value = AssignConv(sk.Value, sk.Field.Type, "field value") + ls[i] = sk + } + } + + n.SetOp(ir.OSTRUCTLIT) + } + + return n +} + +// tcStructLitKey typechecks an OKEY node that appeared within a +// struct literal. +func tcStructLitKey(typ *types.Type, kv *ir.KeyExpr) *ir.StructKeyExpr { + key := kv.Key + + sym := key.Sym() + + // An OXDOT uses the Sym field to hold + // the field to the right of the dot, + // so s will be non-nil, but an OXDOT + // is never a valid struct literal key. + if sym == nil || sym.Pkg != types.LocalPkg || key.Op() == ir.OXDOT || sym.IsBlank() { + base.Errorf("invalid field name %v in struct initializer", key) + return nil + } + + if f := Lookdot1(nil, sym, typ, typ.Fields(), 0); f != nil { + return ir.NewStructKeyExpr(kv.Pos(), f, kv.Value) + } + + if ci := Lookdot1(nil, sym, typ, typ.Fields(), 2); ci != nil { // Case-insensitive lookup. + if visible(ci.Sym) { + base.Errorf("unknown field '%v' in struct literal of type %v (but does have %v)", sym, typ, ci.Sym) + } else if nonexported(sym) && sym.Name == ci.Sym.Name { // Ensure exactness before the suggestion. + base.Errorf("cannot refer to unexported field '%v' in struct literal of type %v", sym, typ) + } else { + base.Errorf("unknown field '%v' in struct literal of type %v", sym, typ) + } + return nil + } + + var f *types.Field + p, _ := dotpath(sym, typ, &f, true) + if p == nil || f.IsMethod() { + base.Errorf("unknown field '%v' in struct literal of type %v", sym, typ) + return nil + } + + // dotpath returns the parent embedded types in reverse order. + var ep []string + for ei := len(p) - 1; ei >= 0; ei-- { + ep = append(ep, p[ei].field.Sym.Name) + } + ep = append(ep, sym.Name) + base.Errorf("cannot use promoted field %v in struct literal of type %v", strings.Join(ep, "."), typ) + return nil +} + +// tcConv typechecks an OCONV node. +func tcConv(n *ir.ConvExpr) ir.Node { + types.CheckSize(n.Type()) // ensure width is calculated for backend + n.X = Expr(n.X) + n.X = convlit1(n.X, n.Type(), true, nil) + t := n.X.Type() + if t == nil || n.Type() == nil { + n.SetType(nil) + return n + } + op, why := convertOp(n.X.Op() == ir.OLITERAL, t, n.Type()) + if op == ir.OXXX { + // Due to //go:nointerface, we may be stricter than types2 here (#63333). + base.ErrorfAt(n.Pos(), errors.InvalidConversion, "cannot convert %L to type %v%s", n.X, n.Type(), why) + n.SetType(nil) + return n + } + + n.SetOp(op) + switch n.Op() { + case ir.OCONVNOP: + if t.Kind() == n.Type().Kind() { + switch t.Kind() { + case types.TFLOAT32, types.TFLOAT64, types.TCOMPLEX64, types.TCOMPLEX128: + // Floating point casts imply rounding and + // so the conversion must be kept. + n.SetOp(ir.OCONV) + } + } + + // do not convert to []byte literal. See CL 125796. + // generated code and compiler memory footprint is better without it. + case ir.OSTR2BYTES: + // ok + + case ir.OSTR2RUNES: + if n.X.Op() == ir.OLITERAL { + return stringtoruneslit(n) + } + + case ir.OBYTES2STR: + if t.Elem() != types.ByteType && t.Elem() != types.Types[types.TUINT8] { + // If t is a slice of a user-defined byte type B (not uint8 + // or byte), then add an extra CONVNOP from []B to []byte, so + // that the call to slicebytetostring() added in walk will + // typecheck correctly. + n.X = ir.NewConvExpr(n.X.Pos(), ir.OCONVNOP, types.NewSlice(types.ByteType), n.X) + n.X.SetTypecheck(1) + } + + case ir.ORUNES2STR: + if t.Elem() != types.RuneType && t.Elem() != types.Types[types.TINT32] { + // If t is a slice of a user-defined rune type B (not uint32 + // or rune), then add an extra CONVNOP from []B to []rune, so + // that the call to slicerunetostring() added in walk will + // typecheck correctly. + n.X = ir.NewConvExpr(n.X.Pos(), ir.OCONVNOP, types.NewSlice(types.RuneType), n.X) + n.X.SetTypecheck(1) + } + + } + return n +} + +// DotField returns a field selector expression that selects the +// index'th field of the given expression, which must be of struct or +// pointer-to-struct type. +func DotField(pos src.XPos, x ir.Node, index int) *ir.SelectorExpr { + op, typ := ir.ODOT, x.Type() + if typ.IsPtr() { + op, typ = ir.ODOTPTR, typ.Elem() + } + if !typ.IsStruct() { + base.FatalfAt(pos, "DotField of non-struct: %L", x) + } + + // TODO(mdempsky): This is the backend's responsibility. + types.CalcSize(typ) + + field := typ.Field(index) + return dot(pos, field.Type, op, x, field) +} + +func dot(pos src.XPos, typ *types.Type, op ir.Op, x ir.Node, selection *types.Field) *ir.SelectorExpr { + n := ir.NewSelectorExpr(pos, op, x, selection.Sym) + n.Selection = selection + n.SetType(typ) + n.SetTypecheck(1) + return n +} + +// XDotField returns an expression representing the field selection +// x.sym. If any implicit field selection are necessary, those are +// inserted too. +func XDotField(pos src.XPos, x ir.Node, sym *types.Sym) *ir.SelectorExpr { + n := Expr(ir.NewSelectorExpr(pos, ir.OXDOT, x, sym)).(*ir.SelectorExpr) + if n.Op() != ir.ODOT && n.Op() != ir.ODOTPTR { + base.FatalfAt(pos, "unexpected result op: %v (%v)", n.Op(), n) + } + return n +} + +// XDotMethod returns an expression representing the method value +// x.sym (i.e., x is a value, not a type). If any implicit field +// selection are necessary, those are inserted too. +// +// If callee is true, the result is an ODOTMETH/ODOTINTER, otherwise +// an OMETHVALUE. +func XDotMethod(pos src.XPos, x ir.Node, sym *types.Sym, callee bool) *ir.SelectorExpr { + n := ir.NewSelectorExpr(pos, ir.OXDOT, x, sym) + if callee { + n = Callee(n).(*ir.SelectorExpr) + if n.Op() != ir.ODOTMETH && n.Op() != ir.ODOTINTER { + base.FatalfAt(pos, "unexpected result op: %v (%v)", n.Op(), n) + } + } else { + n = Expr(n).(*ir.SelectorExpr) + if n.Op() != ir.OMETHVALUE { + base.FatalfAt(pos, "unexpected result op: %v (%v)", n.Op(), n) + } + } + return n +} + +// tcDot typechecks an OXDOT or ODOT node. +func tcDot(n *ir.SelectorExpr, top int) ir.Node { + if n.Op() == ir.OXDOT { + n = AddImplicitDots(n) + n.SetOp(ir.ODOT) + if n.X == nil { + n.SetType(nil) + return n + } + } + + n.X = Expr(n.X) + n.X = DefaultLit(n.X, nil) + + t := n.X.Type() + if t == nil { + base.UpdateErrorDot(ir.Line(n), fmt.Sprint(n.X), fmt.Sprint(n)) + n.SetType(nil) + return n + } + + if n.X.Op() == ir.OTYPE { + base.FatalfAt(n.Pos(), "use NewMethodExpr to construct OMETHEXPR") + } + + if t.IsPtr() && !t.Elem().IsInterface() { + t = t.Elem() + if t == nil { + n.SetType(nil) + return n + } + n.SetOp(ir.ODOTPTR) + types.CheckSize(t) + } + + if n.Sel.IsBlank() { + base.Errorf("cannot refer to blank field or method") + n.SetType(nil) + return n + } + + if Lookdot(n, t, 0) == nil { + // Legitimate field or method lookup failed, try to explain the error + switch { + case t.IsEmptyInterface(): + base.Errorf("%v undefined (type %v is interface with no methods)", n, n.X.Type()) + + case t.IsPtr() && t.Elem().IsInterface(): + // Pointer to interface is almost always a mistake. + base.Errorf("%v undefined (type %v is pointer to interface, not interface)", n, n.X.Type()) + + case Lookdot(n, t, 1) != nil: + // Field or method matches by name, but it is not exported. + base.Errorf("%v undefined (cannot refer to unexported field or method %v)", n, n.Sel) + + default: + if mt := Lookdot(n, t, 2); mt != nil && visible(mt.Sym) { // Case-insensitive lookup. + base.Errorf("%v undefined (type %v has no field or method %v, but does have %v)", n, n.X.Type(), n.Sel, mt.Sym) + } else { + base.Errorf("%v undefined (type %v has no field or method %v)", n, n.X.Type(), n.Sel) + } + } + n.SetType(nil) + return n + } + + if (n.Op() == ir.ODOTINTER || n.Op() == ir.ODOTMETH) && top&ctxCallee == 0 { + n.SetOp(ir.OMETHVALUE) + n.SetType(NewMethodType(n.Type(), nil)) + } + return n +} + +// tcDotType typechecks an ODOTTYPE node. +func tcDotType(n *ir.TypeAssertExpr) ir.Node { + n.X = Expr(n.X) + n.X = DefaultLit(n.X, nil) + l := n.X + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + if !t.IsInterface() { + base.Errorf("invalid type assertion: %v (non-interface type %v on left)", n, t) + n.SetType(nil) + return n + } + + base.AssertfAt(n.Type() != nil, n.Pos(), "missing type: %v", n) + + if n.Type() != nil && !n.Type().IsInterface() { + why := ImplementsExplain(n.Type(), t) + if why != "" { + base.Fatalf("impossible type assertion:\n\t%s", why) + n.SetType(nil) + return n + } + } + return n +} + +// tcITab typechecks an OITAB node. +func tcITab(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + t := n.X.Type() + if t == nil { + n.SetType(nil) + return n + } + if !t.IsInterface() { + base.Fatalf("OITAB of %v", t) + } + n.SetType(types.NewPtr(types.Types[types.TUINTPTR])) + return n +} + +// tcIndex typechecks an OINDEX node. +func tcIndex(n *ir.IndexExpr) ir.Node { + n.X = Expr(n.X) + n.X = DefaultLit(n.X, nil) + n.X = implicitstar(n.X) + l := n.X + n.Index = Expr(n.Index) + r := n.Index + t := l.Type() + if t == nil || r.Type() == nil { + n.SetType(nil) + return n + } + switch t.Kind() { + default: + base.Errorf("invalid operation: %v (type %v does not support indexing)", n, t) + n.SetType(nil) + return n + + case types.TSTRING, types.TARRAY, types.TSLICE: + n.Index = indexlit(n.Index) + if t.IsString() { + n.SetType(types.ByteType) + } else { + n.SetType(t.Elem()) + } + why := "string" + if t.IsArray() { + why = "array" + } else if t.IsSlice() { + why = "slice" + } + + if n.Index.Type() != nil && !n.Index.Type().IsInteger() { + base.Errorf("non-integer %s index %v", why, n.Index) + return n + } + + case types.TMAP: + n.Index = AssignConv(n.Index, t.Key(), "map index") + n.SetType(t.Elem()) + n.SetOp(ir.OINDEXMAP) + n.Assigned = false + } + return n +} + +// tcLenCap typechecks an OLEN or OCAP node. +func tcLenCap(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + n.X = DefaultLit(n.X, nil) + l := n.X + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + var ok bool + if t.IsPtr() && t.Elem().IsArray() { + ok = true + } else if n.Op() == ir.OLEN { + ok = okforlen[t.Kind()] + } else { + ok = okforcap[t.Kind()] + } + if !ok { + base.Errorf("invalid argument %L for %v", l, n.Op()) + n.SetType(nil) + return n + } + + n.SetType(types.Types[types.TINT]) + return n +} + +// tcUnsafeData typechecks an OUNSAFESLICEDATA or OUNSAFESTRINGDATA node. +func tcUnsafeData(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + n.X = DefaultLit(n.X, nil) + l := n.X + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + + var kind types.Kind + if n.Op() == ir.OUNSAFESLICEDATA { + kind = types.TSLICE + } else { + /* kind is string */ + kind = types.TSTRING + } + + if t.Kind() != kind { + base.Errorf("invalid argument %L for %v", l, n.Op()) + n.SetType(nil) + return n + } + + if kind == types.TSTRING { + t = types.ByteType + } else { + t = t.Elem() + } + n.SetType(types.NewPtr(t)) + return n +} + +// tcRecv typechecks an ORECV node. +func tcRecv(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + n.X = DefaultLit(n.X, nil) + l := n.X + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + if !t.IsChan() { + base.Errorf("invalid operation: %v (receive from non-chan type %v)", n, t) + n.SetType(nil) + return n + } + + if !t.ChanDir().CanRecv() { + base.Errorf("invalid operation: %v (receive from send-only type %v)", n, t) + n.SetType(nil) + return n + } + + n.SetType(t.Elem()) + return n +} + +// tcSPtr typechecks an OSPTR node. +func tcSPtr(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + t := n.X.Type() + if t == nil { + n.SetType(nil) + return n + } + if !t.IsSlice() && !t.IsString() { + base.Fatalf("OSPTR of %v", t) + } + if t.IsString() { + n.SetType(types.NewPtr(types.Types[types.TUINT8])) + } else { + n.SetType(types.NewPtr(t.Elem())) + } + return n +} + +// tcSlice typechecks an OSLICE or OSLICE3 node. +func tcSlice(n *ir.SliceExpr) ir.Node { + n.X = DefaultLit(Expr(n.X), nil) + n.Low = indexlit(Expr(n.Low)) + n.High = indexlit(Expr(n.High)) + n.Max = indexlit(Expr(n.Max)) + hasmax := n.Op().IsSlice3() + l := n.X + if l.Type() == nil { + n.SetType(nil) + return n + } + if l.Type().IsArray() { + if !ir.IsAddressable(n.X) { + base.Errorf("invalid operation %v (slice of unaddressable value)", n) + n.SetType(nil) + return n + } + + addr := NodAddr(n.X) + addr.SetImplicit(true) + n.X = Expr(addr) + l = n.X + } + t := l.Type() + var tp *types.Type + if t.IsString() { + if hasmax { + base.Errorf("invalid operation %v (3-index slice of string)", n) + n.SetType(nil) + return n + } + n.SetType(t) + n.SetOp(ir.OSLICESTR) + } else if t.IsPtr() && t.Elem().IsArray() { + tp = t.Elem() + n.SetType(types.NewSlice(tp.Elem())) + types.CalcSize(n.Type()) + if hasmax { + n.SetOp(ir.OSLICE3ARR) + } else { + n.SetOp(ir.OSLICEARR) + } + } else if t.IsSlice() { + n.SetType(t) + } else { + base.Errorf("cannot slice %v (type %v)", l, t) + n.SetType(nil) + return n + } + + if n.Low != nil && !checksliceindex(n.Low) { + n.SetType(nil) + return n + } + if n.High != nil && !checksliceindex(n.High) { + n.SetType(nil) + return n + } + if n.Max != nil && !checksliceindex(n.Max) { + n.SetType(nil) + return n + } + return n +} + +// tcSliceHeader typechecks an OSLICEHEADER node. +func tcSliceHeader(n *ir.SliceHeaderExpr) ir.Node { + // Errors here are Fatalf instead of Errorf because only the compiler + // can construct an OSLICEHEADER node. + // Components used in OSLICEHEADER that are supplied by parsed source code + // have already been typechecked in e.g. OMAKESLICE earlier. + t := n.Type() + if t == nil { + base.Fatalf("no type specified for OSLICEHEADER") + } + + if !t.IsSlice() { + base.Fatalf("invalid type %v for OSLICEHEADER", n.Type()) + } + + if n.Ptr == nil || n.Ptr.Type() == nil || !n.Ptr.Type().IsUnsafePtr() { + base.Fatalf("need unsafe.Pointer for OSLICEHEADER") + } + + n.Ptr = Expr(n.Ptr) + n.Len = DefaultLit(Expr(n.Len), types.Types[types.TINT]) + n.Cap = DefaultLit(Expr(n.Cap), types.Types[types.TINT]) + + return n +} + +// tcStringHeader typechecks an OSTRINGHEADER node. +func tcStringHeader(n *ir.StringHeaderExpr) ir.Node { + t := n.Type() + if t == nil { + base.Fatalf("no type specified for OSTRINGHEADER") + } + + if !t.IsString() { + base.Fatalf("invalid type %v for OSTRINGHEADER", n.Type()) + } + + if n.Ptr == nil || n.Ptr.Type() == nil || !n.Ptr.Type().IsUnsafePtr() { + base.Fatalf("need unsafe.Pointer for OSTRINGHEADER") + } + + n.Ptr = Expr(n.Ptr) + n.Len = DefaultLit(Expr(n.Len), types.Types[types.TINT]) + + if ir.IsConst(n.Len, constant.Int) && ir.Int64Val(n.Len) < 0 { + base.Fatalf("len for OSTRINGHEADER must be non-negative") + } + + return n +} + +// tcStar typechecks an ODEREF node, which may be an expression or a type. +func tcStar(n *ir.StarExpr, top int) ir.Node { + n.X = typecheck(n.X, ctxExpr|ctxType) + l := n.X + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + + // TODO(mdempsky): Remove (along with ctxType above) once I'm + // confident this code path isn't needed any more. + if l.Op() == ir.OTYPE { + base.Fatalf("unexpected type in deref expression: %v", l) + } + + if !t.IsPtr() { + if top&(ctxExpr|ctxStmt) != 0 { + base.Errorf("invalid indirect of %L", n.X) + n.SetType(nil) + return n + } + base.Errorf("%v is not a type", l) + return n + } + + n.SetType(t.Elem()) + return n +} + +// tcUnaryArith typechecks a unary arithmetic expression. +func tcUnaryArith(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + l := n.X + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + if !okfor[n.Op()][defaultType(t).Kind()] { + base.Errorf("invalid operation: %v (operator %v not defined on %s)", n, n.Op(), typekind(t)) + n.SetType(nil) + return n + } + + n.SetType(t) + return n +} diff --git a/go/src/cmd/compile/internal/typecheck/func.go b/go/src/cmd/compile/internal/typecheck/func.go new file mode 100644 index 0000000000000000000000000000000000000000..57657315467abfcad370e7ef007e2ff9778d4bd0 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/func.go @@ -0,0 +1,861 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" + + "fmt" + "go/constant" + "go/token" +) + +// MakeDotArgs package all the arguments that match a ... T parameter into a []T. +func MakeDotArgs(pos src.XPos, typ *types.Type, args []ir.Node) ir.Node { + if len(args) == 0 { + return ir.NewNilExpr(pos, typ) + } + + args = append([]ir.Node(nil), args...) + lit := ir.NewCompLitExpr(pos, ir.OCOMPLIT, typ, args) + lit.SetImplicit(true) + + n := Expr(lit) + if n.Type() == nil { + base.FatalfAt(pos, "mkdotargslice: typecheck failed") + } + return n +} + +// FixVariadicCall rewrites calls to variadic functions to use an +// explicit ... argument if one is not already present. +func FixVariadicCall(call *ir.CallExpr) { + fntype := call.Fun.Type() + if !fntype.IsVariadic() || call.IsDDD { + return + } + + vi := fntype.NumParams() - 1 + vt := fntype.Param(vi).Type + + args := call.Args + extra := args[vi:] + slice := MakeDotArgs(call.Pos(), vt, extra) + for i := range extra { + extra[i] = nil // allow GC + } + + call.Args = append(args[:vi], slice) + call.IsDDD = true +} + +// FixMethodCall rewrites a method call t.M(...) into a function call T.M(t, ...). +func FixMethodCall(call *ir.CallExpr) { + if call.Fun.Op() != ir.ODOTMETH { + return + } + + dot := call.Fun.(*ir.SelectorExpr) + + fn := NewMethodExpr(dot.Pos(), dot.X.Type(), dot.Selection.Sym) + + args := make([]ir.Node, 1+len(call.Args)) + args[0] = dot.X + copy(args[1:], call.Args) + + call.SetOp(ir.OCALLFUNC) + call.Fun = fn + call.Args = args +} + +func AssertFixedCall(call *ir.CallExpr) { + if call.Fun.Type().IsVariadic() && !call.IsDDD { + base.FatalfAt(call.Pos(), "missed FixVariadicCall") + } + if call.Op() == ir.OCALLMETH { + base.FatalfAt(call.Pos(), "missed FixMethodCall") + } +} + +// ClosureType returns the struct type used to hold all the information +// needed in the closure for clo (clo must be a OCLOSURE node). +// The address of a variable of the returned type can be cast to a func. +func ClosureType(clo *ir.ClosureExpr) *types.Type { + // Create closure in the form of a composite literal. + // supposing the closure captures an int i and a string s + // and has one float64 argument and no results, + // the generated code looks like: + // + // clos = &struct{F uintptr; X0 *int; X1 *string}{func.1, &i, &s} + // + // The use of the struct provides type information to the garbage + // collector so that it can walk the closure. We could use (in this + // case) [3]unsafe.Pointer instead, but that would leave the gc in + // the dark. The information appears in the binary in the form of + // type descriptors; the struct is unnamed and uses exported field + // names so that closures in multiple packages with the same struct + // type can share the descriptor. + + fields := make([]*types.Field, 1+len(clo.Func.ClosureVars)) + fields[0] = types.NewField(base.AutogeneratedPos, types.LocalPkg.Lookup("F"), types.Types[types.TUINTPTR]) + it := NewClosureStructIter(clo.Func.ClosureVars) + i := 0 + for { + n, typ, _ := it.Next() + if n == nil { + break + } + fields[1+i] = types.NewField(base.AutogeneratedPos, types.LocalPkg.LookupNum("X", i), typ) + i++ + } + typ := types.NewStruct(fields) + typ.SetNoalg(true) + return typ +} + +// MethodValueType returns the struct type used to hold all the information +// needed in the closure for a OMETHVALUE node. The address of a variable of +// the returned type can be cast to a func. +func MethodValueType(n *ir.SelectorExpr) *types.Type { + t := types.NewStruct([]*types.Field{ + types.NewField(base.Pos, Lookup("F"), types.Types[types.TUINTPTR]), + types.NewField(base.Pos, Lookup("R"), n.X.Type()), + }) + t.SetNoalg(true) + return t +} + +// type check function definition +// To be called by typecheck, not directly. +// (Call typecheck.Func instead.) +func tcFunc(n *ir.Func) { + if base.EnableTrace && base.Flag.LowerT { + defer tracePrint("tcFunc", n)(nil) + } + + if name := n.Nname; name.Typecheck() == 0 { + base.AssertfAt(name.Type() != nil, n.Pos(), "missing type: %v", name) + name.SetTypecheck(1) + } +} + +// tcCall typechecks an OCALL node. +func tcCall(n *ir.CallExpr, top int) ir.Node { + Stmts(n.Init()) // imported rewritten f(g()) calls (#30907) + n.Fun = typecheck(n.Fun, ctxExpr|ctxType|ctxCallee) + + l := n.Fun + + if l.Op() == ir.ONAME && l.(*ir.Name).BuiltinOp != 0 { + l := l.(*ir.Name) + if n.IsDDD && l.BuiltinOp != ir.OAPPEND { + base.Errorf("invalid use of ... with builtin %v", l) + } + + // builtin: OLEN, OCAP, etc. + switch l.BuiltinOp { + default: + base.Fatalf("unknown builtin %v", l) + + case ir.OAPPEND, ir.ODELETE, ir.OMAKE, ir.OMAX, ir.OMIN, ir.OPRINT, ir.OPRINTLN, ir.ORECOVER: + n.SetOp(l.BuiltinOp) + n.Fun = nil + n.SetTypecheck(0) // re-typechecking new op is OK, not a loop + return typecheck(n, top) + + case ir.OCAP, ir.OCLEAR, ir.OCLOSE, ir.OIMAG, ir.OLEN, ir.OPANIC, ir.OREAL, ir.OUNSAFESTRINGDATA, ir.OUNSAFESLICEDATA: + typecheckargs(n) + fallthrough + case ir.ONEW: + arg, ok := needOneArg(n, "%v", n.Op()) + if !ok { + n.SetType(nil) + return n + } + u := ir.NewUnaryExpr(n.Pos(), l.BuiltinOp, arg) + return typecheck(ir.InitExpr(n.Init(), u), top) // typecheckargs can add to old.Init + + case ir.OCOMPLEX, ir.OCOPY, ir.OUNSAFEADD, ir.OUNSAFESLICE, ir.OUNSAFESTRING: + typecheckargs(n) + arg1, arg2, ok := needTwoArgs(n) + if !ok { + n.SetType(nil) + return n + } + b := ir.NewBinaryExpr(n.Pos(), l.BuiltinOp, arg1, arg2) + return typecheck(ir.InitExpr(n.Init(), b), top) // typecheckargs can add to old.Init + } + panic("unreachable") + } + + n.Fun = DefaultLit(n.Fun, nil) + l = n.Fun + if l.Op() == ir.OTYPE { + if n.IsDDD { + base.Fatalf("invalid use of ... in type conversion to %v", l.Type()) + } + + // pick off before type-checking arguments + arg, ok := needOneArg(n, "conversion to %v", l.Type()) + if !ok { + n.SetType(nil) + return n + } + + n := ir.NewConvExpr(n.Pos(), ir.OCONV, nil, arg) + n.SetType(l.Type()) + return tcConv(n) + } + + RewriteNonNameCall(n) + typecheckargs(n) + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + types.CheckSize(t) + + switch l.Op() { + case ir.ODOTINTER: + n.SetOp(ir.OCALLINTER) + + case ir.ODOTMETH: + l := l.(*ir.SelectorExpr) + n.SetOp(ir.OCALLMETH) + + // typecheckaste was used here but there wasn't enough + // information further down the call chain to know if we + // were testing a method receiver for unexported fields. + // It isn't necessary, so just do a sanity check. + tp := t.Recv().Type + + if l.X == nil || !types.Identical(l.X.Type(), tp) { + base.Fatalf("method receiver") + } + + default: + n.SetOp(ir.OCALLFUNC) + if t.Kind() != types.TFUNC { + if o := l; o.Name() != nil && types.BuiltinPkg.Lookup(o.Sym().Name).Def != nil { + // be more specific when the non-function + // name matches a predeclared function + base.Errorf("cannot call non-function %L, declared at %s", + l, base.FmtPos(o.Name().Pos())) + } else { + base.Errorf("cannot call non-function %L", l) + } + n.SetType(nil) + return n + } + } + + typecheckaste(ir.OCALL, n.Fun, n.IsDDD, t.Params(), n.Args, func() string { return fmt.Sprintf("argument to %v", n.Fun) }) + FixVariadicCall(n) + FixMethodCall(n) + if t.NumResults() == 0 { + return n + } + if t.NumResults() == 1 { + n.SetType(l.Type().Result(0).Type) + + if n.Op() == ir.OCALLFUNC && n.Fun.Op() == ir.ONAME { + if sym := n.Fun.(*ir.Name).Sym(); types.RuntimeSymName(sym) == "getg" { + // Emit code for runtime.getg() directly instead of calling function. + // Most such rewrites (for example the similar one for math.Sqrt) should be done in walk, + // so that the ordering pass can make sure to preserve the semantics of the original code + // (in particular, the exact time of the function call) by introducing temporaries. + // In this case, we know getg() always returns the same result within a given function + // and we want to avoid the temporaries, so we do the rewrite earlier than is typical. + n.SetOp(ir.OGETG) + } + } + return n + } + + // multiple return + if top&(ctxMultiOK|ctxStmt) == 0 { + base.Errorf("multiple-value %v() in single-value context", l) + return n + } + + n.SetType(l.Type().ResultsTuple()) + return n +} + +// tcAppend typechecks an OAPPEND node. +func tcAppend(n *ir.CallExpr) ir.Node { + typecheckargs(n) + args := n.Args + if len(args) == 0 { + base.Errorf("missing arguments to append") + n.SetType(nil) + return n + } + + t := args[0].Type() + if t == nil { + n.SetType(nil) + return n + } + + n.SetType(t) + if !t.IsSlice() { + if ir.IsNil(args[0]) { + base.Errorf("first argument to append must be typed slice; have untyped nil") + n.SetType(nil) + return n + } + + base.Errorf("first argument to append must be slice; have %L", t) + n.SetType(nil) + return n + } + + if n.IsDDD { + if len(args) == 1 { + base.Errorf("cannot use ... on first argument to append") + n.SetType(nil) + return n + } + + if len(args) != 2 { + base.Errorf("too many arguments to append") + n.SetType(nil) + return n + } + + // AssignConv is of args[1] not required here, as the + // types of args[0] and args[1] don't need to match + // (They will both have an underlying type which are + // slices of identical base types, or be []byte and string.) + // See issue 53888. + return n + } + + as := args[1:] + for i, n := range as { + if n.Type() == nil { + continue + } + as[i] = AssignConv(n, t.Elem(), "append") + types.CheckSize(as[i].Type()) // ensure width is calculated for backend + } + return n +} + +// tcClear typechecks an OCLEAR node. +func tcClear(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + n.X = DefaultLit(n.X, nil) + l := n.X + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + + switch { + case t.IsMap(), t.IsSlice(): + default: + base.Errorf("invalid operation: %v (argument must be a map or slice)", n) + n.SetType(nil) + return n + } + + return n +} + +// tcClose typechecks an OCLOSE node. +func tcClose(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + n.X = DefaultLit(n.X, nil) + l := n.X + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + if !t.IsChan() { + base.Errorf("invalid operation: %v (non-chan type %v)", n, t) + n.SetType(nil) + return n + } + + if !t.ChanDir().CanSend() { + base.Errorf("invalid operation: %v (cannot close receive-only channel)", n) + n.SetType(nil) + return n + } + return n +} + +// tcComplex typechecks an OCOMPLEX node. +func tcComplex(n *ir.BinaryExpr) ir.Node { + l := Expr(n.X) + r := Expr(n.Y) + if l.Type() == nil || r.Type() == nil { + n.SetType(nil) + return n + } + l, r = defaultlit2(l, r, false) + if l.Type() == nil || r.Type() == nil { + n.SetType(nil) + return n + } + n.X = l + n.Y = r + + if !types.Identical(l.Type(), r.Type()) { + base.Errorf("invalid operation: %v (mismatched types %v and %v)", n, l.Type(), r.Type()) + n.SetType(nil) + return n + } + + var t *types.Type + switch l.Type().Kind() { + default: + base.Errorf("invalid operation: %v (arguments have type %v, expected floating-point)", n, l.Type()) + n.SetType(nil) + return n + + case types.TIDEAL: + t = types.UntypedComplex + + case types.TFLOAT32: + t = types.Types[types.TCOMPLEX64] + + case types.TFLOAT64: + t = types.Types[types.TCOMPLEX128] + } + n.SetType(t) + return n +} + +// tcCopy typechecks an OCOPY node. +func tcCopy(n *ir.BinaryExpr) ir.Node { + n.SetType(types.Types[types.TINT]) + n.X = Expr(n.X) + n.X = DefaultLit(n.X, nil) + n.Y = Expr(n.Y) + n.Y = DefaultLit(n.Y, nil) + if n.X.Type() == nil || n.Y.Type() == nil { + n.SetType(nil) + return n + } + + // copy([]byte, string) + if n.X.Type().IsSlice() && n.Y.Type().IsString() { + if types.Identical(n.X.Type().Elem(), types.ByteType) { + return n + } + base.Errorf("arguments to copy have different element types: %L and string", n.X.Type()) + n.SetType(nil) + return n + } + + if !n.X.Type().IsSlice() || !n.Y.Type().IsSlice() { + if !n.X.Type().IsSlice() && !n.Y.Type().IsSlice() { + base.Errorf("arguments to copy must be slices; have %L, %L", n.X.Type(), n.Y.Type()) + } else if !n.X.Type().IsSlice() { + base.Errorf("first argument to copy should be slice; have %L", n.X.Type()) + } else { + base.Errorf("second argument to copy should be slice or string; have %L", n.Y.Type()) + } + n.SetType(nil) + return n + } + + if !types.Identical(n.X.Type().Elem(), n.Y.Type().Elem()) { + base.Errorf("arguments to copy have different element types: %L and %L", n.X.Type(), n.Y.Type()) + n.SetType(nil) + return n + } + return n +} + +// tcDelete typechecks an ODELETE node. +func tcDelete(n *ir.CallExpr) ir.Node { + typecheckargs(n) + args := n.Args + if len(args) == 0 { + base.Errorf("missing arguments to delete") + n.SetType(nil) + return n + } + + if len(args) == 1 { + base.Errorf("missing second (key) argument to delete") + n.SetType(nil) + return n + } + + if len(args) != 2 { + base.Errorf("too many arguments to delete") + n.SetType(nil) + return n + } + + l := args[0] + r := args[1] + if l.Type() != nil && !l.Type().IsMap() { + base.Errorf("first argument to delete must be map; have %L", l.Type()) + n.SetType(nil) + return n + } + + args[1] = AssignConv(r, l.Type().Key(), "delete") + return n +} + +// tcMake typechecks an OMAKE node. +func tcMake(n *ir.CallExpr) ir.Node { + args := n.Args + if len(args) == 0 { + base.Errorf("missing argument to make") + n.SetType(nil) + return n + } + + n.Args = nil + l := args[0] + l = typecheck(l, ctxType) + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + + i := 1 + var nn ir.Node + switch t.Kind() { + default: + base.Errorf("cannot make type %v", t) + n.SetType(nil) + return n + + case types.TSLICE: + if i >= len(args) { + base.Errorf("missing len argument to make(%v)", t) + n.SetType(nil) + return n + } + + l = args[i] + i++ + l = Expr(l) + var r ir.Node + if i < len(args) { + r = args[i] + i++ + r = Expr(r) + } + + if l.Type() == nil || (r != nil && r.Type() == nil) { + n.SetType(nil) + return n + } + if !checkmake(t, "len", &l) || r != nil && !checkmake(t, "cap", &r) { + n.SetType(nil) + return n + } + if ir.IsConst(l, constant.Int) && r != nil && ir.IsConst(r, constant.Int) && constant.Compare(l.Val(), token.GTR, r.Val()) { + base.Errorf("len larger than cap in make(%v)", t) + n.SetType(nil) + return n + } + nn = ir.NewMakeExpr(n.Pos(), ir.OMAKESLICE, l, r) + + case types.TMAP: + if i < len(args) { + l = args[i] + i++ + l = Expr(l) + l = DefaultLit(l, types.Types[types.TINT]) + if l.Type() == nil { + n.SetType(nil) + return n + } + if !checkmake(t, "size", &l) { + n.SetType(nil) + return n + } + } else { + l = ir.NewInt(base.Pos, 0) + } + nn = ir.NewMakeExpr(n.Pos(), ir.OMAKEMAP, l, nil) + nn.SetEsc(n.Esc()) + + case types.TCHAN: + l = nil + if i < len(args) { + l = args[i] + i++ + l = Expr(l) + l = DefaultLit(l, types.Types[types.TINT]) + if l.Type() == nil { + n.SetType(nil) + return n + } + if !checkmake(t, "buffer", &l) { + n.SetType(nil) + return n + } + } else { + l = ir.NewInt(base.Pos, 0) + } + nn = ir.NewMakeExpr(n.Pos(), ir.OMAKECHAN, l, nil) + } + + if i < len(args) { + base.Errorf("too many arguments to make(%v)", t) + n.SetType(nil) + return n + } + + nn.SetType(t) + return nn +} + +// tcMakeSliceCopy typechecks an OMAKESLICECOPY node. +func tcMakeSliceCopy(n *ir.MakeExpr) ir.Node { + // Errors here are Fatalf instead of Errorf because only the compiler + // can construct an OMAKESLICECOPY node. + // Components used in OMAKESCLICECOPY that are supplied by parsed source code + // have already been typechecked in OMAKE and OCOPY earlier. + t := n.Type() + + if t == nil { + base.Fatalf("no type specified for OMAKESLICECOPY") + } + + if !t.IsSlice() { + base.Fatalf("invalid type %v for OMAKESLICECOPY", n.Type()) + } + + if n.Len == nil { + base.Fatalf("missing len argument for OMAKESLICECOPY") + } + + if n.Cap == nil { + base.Fatalf("missing slice argument to copy for OMAKESLICECOPY") + } + + n.Len = Expr(n.Len) + n.Cap = Expr(n.Cap) + + n.Len = DefaultLit(n.Len, types.Types[types.TINT]) + + if !n.Len.Type().IsInteger() && n.Type().Kind() != types.TIDEAL { + base.Errorf("non-integer len argument in OMAKESLICECOPY") + } + + if ir.IsConst(n.Len, constant.Int) { + if ir.ConstOverflow(n.Len.Val(), types.Types[types.TINT]) { + base.Fatalf("len for OMAKESLICECOPY too large") + } + if constant.Sign(n.Len.Val()) < 0 { + base.Fatalf("len for OMAKESLICECOPY must be non-negative") + } + } + return n +} + +// tcNew typechecks an ONEW node. +func tcNew(n *ir.UnaryExpr) ir.Node { + if n.X == nil { + // Fatalf because the OCALL above checked for us, + // so this must be an internally-generated mistake. + base.Fatalf("missing argument to new") + } + l := n.X + l = typecheck(l, ctxType) + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + n.X = l + n.SetType(types.NewPtr(t)) + return n +} + +// tcPanic typechecks an OPANIC node. +func tcPanic(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + n.X = AssignConv(n.X, types.Types[types.TINTER], "argument to panic") + if n.X.Type() == nil { + n.SetType(nil) + return n + } + return n +} + +// tcPrint typechecks an OPRINT or OPRINTN node. +func tcPrint(n *ir.CallExpr) ir.Node { + typecheckargs(n) + ls := n.Args + for i1, n1 := range ls { + // Special case for print: int constant is int64, not int. + if ir.IsConst(n1, constant.Int) { + ls[i1] = DefaultLit(ls[i1], types.Types[types.TINT64]) + } else { + ls[i1] = DefaultLit(ls[i1], nil) + } + } + return n +} + +// tcMinMax typechecks an OMIN or OMAX node. +func tcMinMax(n *ir.CallExpr) ir.Node { + typecheckargs(n) + arg0 := n.Args[0] + for _, arg := range n.Args[1:] { + if !types.Identical(arg.Type(), arg0.Type()) { + base.FatalfAt(n.Pos(), "mismatched arguments: %L and %L", arg0, arg) + } + } + n.SetType(arg0.Type()) + return n +} + +// tcRealImag typechecks an OREAL or OIMAG node. +func tcRealImag(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + l := n.X + t := l.Type() + if t == nil { + n.SetType(nil) + return n + } + + // Determine result type. + switch t.Kind() { + case types.TIDEAL: + n.SetType(types.UntypedFloat) + case types.TCOMPLEX64: + n.SetType(types.Types[types.TFLOAT32]) + case types.TCOMPLEX128: + n.SetType(types.Types[types.TFLOAT64]) + default: + base.Errorf("invalid argument %L for %v", l, n.Op()) + n.SetType(nil) + return n + } + return n +} + +// tcRecover typechecks an ORECOVER node. +func tcRecover(n *ir.CallExpr) ir.Node { + if len(n.Args) != 0 { + base.Errorf("too many arguments to recover") + n.SetType(nil) + return n + } + + n.SetType(types.Types[types.TINTER]) + return n +} + +// tcUnsafeAdd typechecks an OUNSAFEADD node. +func tcUnsafeAdd(n *ir.BinaryExpr) *ir.BinaryExpr { + n.X = AssignConv(Expr(n.X), types.Types[types.TUNSAFEPTR], "argument to unsafe.Add") + n.Y = DefaultLit(Expr(n.Y), types.Types[types.TINT]) + if n.X.Type() == nil || n.Y.Type() == nil { + n.SetType(nil) + return n + } + if !n.Y.Type().IsInteger() { + n.SetType(nil) + return n + } + n.SetType(n.X.Type()) + return n +} + +// tcUnsafeSlice typechecks an OUNSAFESLICE node. +func tcUnsafeSlice(n *ir.BinaryExpr) *ir.BinaryExpr { + n.X = Expr(n.X) + n.Y = Expr(n.Y) + if n.X.Type() == nil || n.Y.Type() == nil { + n.SetType(nil) + return n + } + t := n.X.Type() + if !t.IsPtr() { + base.Errorf("first argument to unsafe.Slice must be pointer; have %L", t) + } else if t.Elem().NotInHeap() { + // TODO(mdempsky): This can be relaxed, but should only affect the + // Go runtime itself. End users should only see not-in-heap + // types due to incomplete C structs in cgo, and those types don't + // have a meaningful size anyway. + base.Errorf("unsafe.Slice of incomplete (or unallocatable) type not allowed") + } + + if !checkunsafesliceorstring(n.Op(), &n.Y) { + n.SetType(nil) + return n + } + n.SetType(types.NewSlice(t.Elem())) + return n +} + +// tcUnsafeString typechecks an OUNSAFESTRING node. +func tcUnsafeString(n *ir.BinaryExpr) *ir.BinaryExpr { + n.X = Expr(n.X) + n.Y = Expr(n.Y) + if n.X.Type() == nil || n.Y.Type() == nil { + n.SetType(nil) + return n + } + t := n.X.Type() + if !t.IsPtr() || !types.Identical(t.Elem(), types.Types[types.TUINT8]) { + base.Errorf("first argument to unsafe.String must be *byte; have %L", t) + } + + if !checkunsafesliceorstring(n.Op(), &n.Y) { + n.SetType(nil) + return n + } + n.SetType(types.Types[types.TSTRING]) + return n +} + +// ClosureStructIter iterates through a slice of closure variables returning +// their type and offset in the closure struct. +type ClosureStructIter struct { + closureVars []*ir.Name + offset int64 + next int +} + +// NewClosureStructIter creates a new ClosureStructIter for closureVars. +func NewClosureStructIter(closureVars []*ir.Name) *ClosureStructIter { + return &ClosureStructIter{ + closureVars: closureVars, + offset: int64(types.PtrSize), // PtrSize to skip past function entry PC field + next: 0, + } +} + +// Next returns the next name, type and offset of the next closure variable. +// A nil name is returned after the last closure variable. +func (iter *ClosureStructIter) Next() (n *ir.Name, typ *types.Type, offset int64) { + if iter.next >= len(iter.closureVars) { + return nil, nil, 0 + } + n = iter.closureVars[iter.next] + typ = n.Type() + if !n.Byval() { + typ = types.NewPtr(typ) + } + iter.next++ + offset = types.RoundUp(iter.offset, typ.Alignment()) + iter.offset = offset + typ.Size() + return n, typ, offset +} diff --git a/go/src/cmd/compile/internal/typecheck/iexport.go b/go/src/cmd/compile/internal/typecheck/iexport.go new file mode 100644 index 0000000000000000000000000000000000000000..f3498f600901181a256c6a8b259cf8aac2bf9d9a --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/iexport.go @@ -0,0 +1,241 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Indexed package export. +// +// The indexed export data format is an evolution of the previous +// binary export data format. Its chief contribution is introducing an +// index table, which allows efficient random access of individual +// declarations and inline function bodies. In turn, this allows +// avoiding unnecessary work for compilation units that import large +// packages. +// +// +// The top-level data format is structured as: +// +// Header struct { +// Tag byte // 'i' +// Version uvarint +// StringSize uvarint +// DataSize uvarint +// } +// +// Strings [StringSize]byte +// Data [DataSize]byte +// +// MainIndex []struct{ +// PkgPath stringOff +// PkgName stringOff +// PkgHeight uvarint +// +// Decls []struct{ +// Name stringOff +// Offset declOff +// } +// } +// +// Fingerprint [8]byte +// +// uvarint means a uint64 written out using uvarint encoding. +// +// []T means a uvarint followed by that many T objects. In other +// words: +// +// Len uvarint +// Elems [Len]T +// +// stringOff means a uvarint that indicates an offset within the +// Strings section. At that offset is another uvarint, followed by +// that many bytes, which form the string value. +// +// declOff means a uvarint that indicates an offset within the Data +// section where the associated declaration can be found. +// +// +// There are five kinds of declarations, distinguished by their first +// byte: +// +// type Var struct { +// Tag byte // 'V' +// Pos Pos +// Type typeOff +// } +// +// type Func struct { +// Tag byte // 'F' or 'G' +// Pos Pos +// TypeParams []typeOff // only present if Tag == 'G' +// Signature Signature +// } +// +// type Const struct { +// Tag byte // 'C' +// Pos Pos +// Value Value +// } +// +// type Type struct { +// Tag byte // 'T' or 'U' +// Pos Pos +// TypeParams []typeOff // only present if Tag == 'U' +// Underlying typeOff +// +// Methods []struct{ // omitted if Underlying is an interface type +// Pos Pos +// Name stringOff +// Recv Param +// Signature Signature +// } +// } +// +// type Alias struct { +// Tag byte // 'A' or 'B' +// Pos Pos +// TypeParams []typeOff // only present if Tag == 'B' +// Type typeOff +// } +// +// // "Automatic" declaration of each typeparam +// type TypeParam struct { +// Tag byte // 'P' +// Pos Pos +// Implicit bool +// Constraint typeOff +// } +// +// typeOff means a uvarint that either indicates a predeclared type, +// or an offset into the Data section. If the uvarint is less than +// predeclReserved, then it indicates the index into the predeclared +// types list (see predeclared in bexport.go for order). Otherwise, +// subtracting predeclReserved yields the offset of a type descriptor. +// +// Value means a type, kind, and type-specific value. See +// (*exportWriter).value for details. +// +// +// There are twelve kinds of type descriptors, distinguished by an itag: +// +// type DefinedType struct { +// Tag itag // definedType +// Name stringOff +// PkgPath stringOff +// } +// +// type PointerType struct { +// Tag itag // pointerType +// Elem typeOff +// } +// +// type SliceType struct { +// Tag itag // sliceType +// Elem typeOff +// } +// +// type ArrayType struct { +// Tag itag // arrayType +// Len uint64 +// Elem typeOff +// } +// +// type ChanType struct { +// Tag itag // chanType +// Dir uint64 // 1 RecvOnly; 2 SendOnly; 3 SendRecv +// Elem typeOff +// } +// +// type MapType struct { +// Tag itag // mapType +// Key typeOff +// Elem typeOff +// } +// +// type FuncType struct { +// Tag itag // signatureType +// PkgPath stringOff +// Signature Signature +// } +// +// type StructType struct { +// Tag itag // structType +// PkgPath stringOff +// Fields []struct { +// Pos Pos +// Name stringOff +// Type typeOff +// Embedded bool +// Note stringOff +// } +// } +// +// type InterfaceType struct { +// Tag itag // interfaceType +// PkgPath stringOff +// Embeddeds []struct { +// Pos Pos +// Type typeOff +// } +// Methods []struct { +// Pos Pos +// Name stringOff +// Signature Signature +// } +// } +// +// // Reference to a type param declaration +// type TypeParamType struct { +// Tag itag // typeParamType +// Name stringOff +// PkgPath stringOff +// } +// +// // Instantiation of a generic type (like List[T2] or List[int]) +// type InstanceType struct { +// Tag itag // instanceType +// Pos pos +// TypeArgs []typeOff +// BaseType typeOff +// } +// +// type UnionType struct { +// Tag itag // interfaceType +// Terms []struct { +// tilde bool +// Type typeOff +// } +// } +// +// +// +// type Signature struct { +// Params []Param +// Results []Param +// Variadic bool // omitted if Results is empty +// } +// +// type Param struct { +// Pos Pos +// Name stringOff +// Type typOff +// } +// +// +// Pos encodes a file:line:column triple, incorporating a simple delta +// encoding scheme within a data object. See exportWriter.pos for +// details. +// +// +// Compiler-specific details. +// +// cmd/compile writes out a second index for inline bodies and also +// appends additional compiler-specific details after declarations. +// Third-party tools are not expected to depend on these details and +// they're expected to change much more rapidly, so they're omitted +// here. See exportWriter's varExt/funcExt/etc methods for details. + +package typecheck + +const blankMarker = "$" + +// The name used for dictionary parameters or local variables. +const LocalDictName = ".dict" diff --git a/go/src/cmd/compile/internal/typecheck/iimport.go b/go/src/cmd/compile/internal/typecheck/iimport.go new file mode 100644 index 0000000000000000000000000000000000000000..cb3feb1e7a8691fe0e4486b5020ab82c066a402a --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/iimport.go @@ -0,0 +1,53 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Indexed package import. +// See iexport.go for the export data format. + +package typecheck + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" +) + +// HaveInlineBody reports whether we have fn's inline body available +// for inlining. +// +// It's a function literal so that it can be overridden for +// GOEXPERIMENT=unified. +var HaveInlineBody = func(fn *ir.Func) bool { + base.Fatalf("HaveInlineBody not overridden") + panic("unreachable") +} + +func SetBaseTypeIndex(t *types.Type, i, pi int64) { + if t.Obj() == nil { + base.Fatalf("SetBaseTypeIndex on non-defined type %v", t) + } + if i != -1 && pi != -1 { + typeSymIdx[t] = [2]int64{i, pi} + } +} + +// Map imported type T to the index of type descriptor symbols of T and *T, +// so we can use index to reference the symbol. +// TODO(mdempsky): Store this information directly in the Type's Name. +var typeSymIdx = make(map[*types.Type][2]int64) + +func BaseTypeIndex(t *types.Type) int64 { + tbase := t + if t.IsPtr() && t.Sym() == nil && t.Elem().Sym() != nil { + tbase = t.Elem() + } + i, ok := typeSymIdx[tbase] + if !ok { + return -1 + } + if t != tbase { + return i[1] + } + return i[0] +} diff --git a/go/src/cmd/compile/internal/typecheck/mkbuiltin.go b/go/src/cmd/compile/internal/typecheck/mkbuiltin.go new file mode 100644 index 0000000000000000000000000000000000000000..28afac5d7ab1909088f1888d05495ba03c517c05 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/mkbuiltin.go @@ -0,0 +1,254 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +// Generate builtin.go from builtin/runtime.go. + +package main + +import ( + "bytes" + "flag" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/token" + "io" + "log" + "os" + "path/filepath" + "strconv" + "strings" +) + +var stdout = flag.Bool("stdout", false, "write to stdout instead of builtin.go") +var nofmt = flag.Bool("nofmt", false, "skip formatting builtin.go") + +func main() { + flag.Parse() + + var b bytes.Buffer + fmt.Fprintln(&b, "// Code generated by mkbuiltin.go. DO NOT EDIT.") + fmt.Fprintln(&b) + fmt.Fprintln(&b, "package typecheck") + fmt.Fprintln(&b) + fmt.Fprintln(&b, `import (`) + fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) + fmt.Fprintln(&b, ` "cmd/internal/src"`) + fmt.Fprintln(&b, `)`) + + fmt.Fprintln(&b, ` +// Not inlining this function removes a significant chunk of init code. +//go:noinline +func newSig(params, results []*types.Field) *types.Type { + return types.NewSignature(nil, params, results) +} + +func params(tlist ...*types.Type) []*types.Field { + flist := make([]*types.Field, len(tlist)) + for i, typ := range tlist { + flist[i] = types.NewField(src.NoXPos, nil, typ) + } + return flist +} +`) + + mkbuiltin(&b, "runtime") + mkbuiltin(&b, "coverage") + + var err error + out := b.Bytes() + if !*nofmt { + out, err = format.Source(out) + if err != nil { + log.Fatal(err) + } + } + if *stdout { + _, err = os.Stdout.Write(out) + } else { + err = os.WriteFile("builtin.go", out, 0666) + } + if err != nil { + log.Fatal(err) + } +} + +func mkbuiltin(w io.Writer, name string) { + fset := token.NewFileSet() + f, err := parser.ParseFile(fset, filepath.Join("_builtin", name+".go"), nil, 0) + if err != nil { + log.Fatal(err) + } + + var interner typeInterner + + fmt.Fprintf(w, "var %sDecls = [...]struct { name string; tag int; typ int }{\n", name) + for _, decl := range f.Decls { + switch decl := decl.(type) { + case *ast.FuncDecl: + if decl.Recv != nil { + log.Fatal("methods unsupported") + } + if decl.Body != nil { + log.Fatal("unexpected function body") + } + fmt.Fprintf(w, "{%q, funcTag, %d},\n", decl.Name.Name, interner.intern(decl.Type)) + case *ast.GenDecl: + if decl.Tok == token.IMPORT { + if len(decl.Specs) != 1 || decl.Specs[0].(*ast.ImportSpec).Path.Value != "\"unsafe\"" { + log.Fatal("runtime cannot import other package") + } + continue + } + if decl.Tok != token.VAR { + log.Fatal("unhandled declaration kind", decl.Tok) + } + for _, spec := range decl.Specs { + spec := spec.(*ast.ValueSpec) + if len(spec.Values) != 0 { + log.Fatal("unexpected values") + } + typ := interner.intern(spec.Type) + for _, name := range spec.Names { + fmt.Fprintf(w, "{%q, varTag, %d},\n", name.Name, typ) + } + } + default: + log.Fatal("unhandled decl type", decl) + } + } + fmt.Fprintln(w, "}") + + fmt.Fprintln(w) + fmt.Fprintf(w, "func %sTypes() []*types.Type {\n", name) + fmt.Fprintf(w, "var typs [%d]*types.Type\n", len(interner.typs)) + for i, typ := range interner.typs { + fmt.Fprintf(w, "typs[%d] = %s\n", i, typ) + } + fmt.Fprintln(w, "return typs[:]") + fmt.Fprintln(w, "}") +} + +// typeInterner maps Go type expressions to compiler code that +// constructs the denoted type. It recognizes and reuses common +// subtype expressions. +type typeInterner struct { + typs []string + hash map[string]int +} + +func (i *typeInterner) intern(t ast.Expr) int { + x := i.mktype(t) + v, ok := i.hash[x] + if !ok { + v = len(i.typs) + if i.hash == nil { + i.hash = make(map[string]int) + } + i.hash[x] = v + i.typs = append(i.typs, x) + } + return v +} + +func (i *typeInterner) subtype(t ast.Expr) string { + return fmt.Sprintf("typs[%d]", i.intern(t)) +} + +func (i *typeInterner) mktype(t ast.Expr) string { + switch t := t.(type) { + case *ast.Ident: + switch t.Name { + case "byte": + return "types.ByteType" + case "rune": + return "types.RuneType" + } + return fmt.Sprintf("types.Types[types.T%s]", strings.ToUpper(t.Name)) + case *ast.SelectorExpr: + if t.X.(*ast.Ident).Name != "unsafe" || t.Sel.Name != "Pointer" { + log.Fatalf("unhandled type: %#v", t) + } + return "types.Types[types.TUNSAFEPTR]" + + case *ast.ArrayType: + if t.Len == nil { + return fmt.Sprintf("types.NewSlice(%s)", i.subtype(t.Elt)) + } + return fmt.Sprintf("types.NewArray(%s, %d)", i.subtype(t.Elt), intconst(t.Len)) + case *ast.ChanType: + dir := "types.Cboth" + switch t.Dir { + case ast.SEND: + dir = "types.Csend" + case ast.RECV: + dir = "types.Crecv" + } + return fmt.Sprintf("types.NewChan(%s, %s)", i.subtype(t.Value), dir) + case *ast.FuncType: + return fmt.Sprintf("newSig(%s, %s)", i.fields(t.Params, false), i.fields(t.Results, false)) + case *ast.InterfaceType: + if len(t.Methods.List) != 0 { + log.Fatal("non-empty interfaces unsupported") + } + return "types.Types[types.TINTER]" + case *ast.MapType: + return fmt.Sprintf("types.NewMap(%s, %s)", i.subtype(t.Key), i.subtype(t.Value)) + case *ast.StarExpr: + return fmt.Sprintf("types.NewPtr(%s)", i.subtype(t.X)) + case *ast.StructType: + return fmt.Sprintf("types.NewStruct(%s)", i.fields(t.Fields, true)) + + default: + log.Fatalf("unhandled type: %#v", t) + panic("unreachable") + } +} + +func (i *typeInterner) fields(fl *ast.FieldList, keepNames bool) string { + if fl == nil || len(fl.List) == 0 { + return "nil" + } + + var res []string + for _, f := range fl.List { + typ := i.subtype(f.Type) + if len(f.Names) == 0 { + res = append(res, typ) + } else { + for _, name := range f.Names { + if keepNames { + res = append(res, fmt.Sprintf("types.NewField(src.NoXPos, Lookup(%q), %s)", name.Name, typ)) + } else { + res = append(res, typ) + } + } + } + } + + if keepNames { + return fmt.Sprintf("[]*types.Field{%s}", strings.Join(res, ", ")) + } + return fmt.Sprintf("params(%s)", strings.Join(res, ", ")) +} + +func intconst(e ast.Expr) int64 { + switch e := e.(type) { + case *ast.BasicLit: + if e.Kind != token.INT { + log.Fatalf("expected INT, got %v", e.Kind) + } + x, err := strconv.ParseInt(e.Value, 0, 64) + if err != nil { + log.Fatal(err) + } + return x + default: + log.Fatalf("unhandled expr: %#v", e) + panic("unreachable") + } +} diff --git a/go/src/cmd/compile/internal/typecheck/stmt.go b/go/src/cmd/compile/internal/typecheck/stmt.go new file mode 100644 index 0000000000000000000000000000000000000000..2ca8e7fb8616269dd85a4b4fb14d33baa8fd6eb7 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/stmt.go @@ -0,0 +1,724 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" + "internal/types/errors" +) + +func RangeExprType(t *types.Type) *types.Type { + if t.IsPtr() && t.Elem().IsArray() { + return t.Elem() + } + return t +} + +// type check assignment. +// if this assignment is the definition of a var on the left side, +// fill in the var's type. +func tcAssign(n *ir.AssignStmt) { + if base.EnableTrace && base.Flag.LowerT { + defer tracePrint("tcAssign", n)(nil) + } + + if n.Y == nil { + n.X = AssignExpr(n.X) + return + } + + lhs, rhs := []ir.Node{n.X}, []ir.Node{n.Y} + assign(n, lhs, rhs) + n.X, n.Y = lhs[0], rhs[0] + + // TODO(mdempsky): This seems out of place. + if !ir.IsBlank(n.X) { + types.CheckSize(n.X.Type()) // ensure width is calculated for backend + } +} + +func tcAssignList(n *ir.AssignListStmt) { + if base.EnableTrace && base.Flag.LowerT { + defer tracePrint("tcAssignList", n)(nil) + } + + assign(n, n.Lhs, n.Rhs) +} + +func assign(stmt ir.Node, lhs, rhs []ir.Node) { + // delicate little dance. + // the definition of lhs may refer to this assignment + // as its definition, in which case it will call tcAssign. + // in that case, do not call typecheck back, or it will cycle. + // if the variable has a type (ntype) then typechecking + // will not look at defn, so it is okay (and desirable, + // so that the conversion below happens). + + checkLHS := func(i int, typ *types.Type) { + if n := lhs[i]; typ != nil && ir.DeclaredBy(n, stmt) && n.Type() == nil { + base.Assertf(typ.Kind() == types.TNIL, "unexpected untyped nil") + n.SetType(defaultType(typ)) + } + if lhs[i].Typecheck() == 0 { + lhs[i] = AssignExpr(lhs[i]) + } + checkassign(lhs[i]) + } + + assignType := func(i int, typ *types.Type) { + checkLHS(i, typ) + if typ != nil { + checkassignto(typ, lhs[i]) + } + } + + cr := len(rhs) + if len(rhs) == 1 { + rhs[0] = typecheck(rhs[0], ctxExpr|ctxMultiOK) + if rtyp := rhs[0].Type(); rtyp != nil && rtyp.IsFuncArgStruct() { + cr = rtyp.NumFields() + } + } else { + Exprs(rhs) + } + + // x, ok = y +assignOK: + for len(lhs) == 2 && cr == 1 { + stmt := stmt.(*ir.AssignListStmt) + r := rhs[0] + + switch r.Op() { + case ir.OINDEXMAP: + stmt.SetOp(ir.OAS2MAPR) + case ir.ORECV: + stmt.SetOp(ir.OAS2RECV) + case ir.ODOTTYPE: + r := r.(*ir.TypeAssertExpr) + stmt.SetOp(ir.OAS2DOTTYPE) + r.SetOp(ir.ODOTTYPE2) + case ir.ODYNAMICDOTTYPE: + r := r.(*ir.DynamicTypeAssertExpr) + stmt.SetOp(ir.OAS2DOTTYPE) + r.SetOp(ir.ODYNAMICDOTTYPE2) + default: + break assignOK + } + + assignType(0, r.Type()) + assignType(1, types.UntypedBool) + return + } + + if len(lhs) != cr { + if r, ok := rhs[0].(*ir.CallExpr); ok && len(rhs) == 1 { + if r.Type() != nil { + base.ErrorfAt(stmt.Pos(), errors.WrongAssignCount, "assignment mismatch: %d variable%s but %v returns %d value%s", len(lhs), plural(len(lhs)), r.Fun, cr, plural(cr)) + } + } else { + base.ErrorfAt(stmt.Pos(), errors.WrongAssignCount, "assignment mismatch: %d variable%s but %v value%s", len(lhs), plural(len(lhs)), len(rhs), plural(len(rhs))) + } + + for i := range lhs { + checkLHS(i, nil) + } + return + } + + // x,y,z = f() + if cr > len(rhs) { + stmt := stmt.(*ir.AssignListStmt) + stmt.SetOp(ir.OAS2FUNC) + r := rhs[0].(*ir.CallExpr) + rtyp := r.Type() + + mismatched := false + failed := false + for i := range lhs { + result := rtyp.Field(i).Type + assignType(i, result) + + if lhs[i].Type() == nil || result == nil { + failed = true + } else if lhs[i] != ir.BlankNode && !types.Identical(lhs[i].Type(), result) { + mismatched = true + } + } + if mismatched && !failed { + RewriteMultiValueCall(stmt, r) + } + return + } + + for i, r := range rhs { + checkLHS(i, r.Type()) + if lhs[i].Type() != nil { + rhs[i] = AssignConv(r, lhs[i].Type(), "assignment") + } + } +} + +func plural(n int) string { + if n == 1 { + return "" + } + return "s" +} + +// tcCheckNil typechecks an OCHECKNIL node. +func tcCheckNil(n *ir.UnaryExpr) ir.Node { + n.X = Expr(n.X) + if !n.X.Type().IsPtrShaped() { + base.FatalfAt(n.Pos(), "%L is not pointer shaped", n.X) + } + return n +} + +// tcFor typechecks an OFOR node. +func tcFor(n *ir.ForStmt) ir.Node { + Stmts(n.Init()) + n.Cond = Expr(n.Cond) + n.Cond = DefaultLit(n.Cond, nil) + if n.Cond != nil { + t := n.Cond.Type() + if t != nil && !t.IsBoolean() { + base.Errorf("non-bool %L used as for condition", n.Cond) + } + } + n.Post = Stmt(n.Post) + Stmts(n.Body) + return n +} + +// tcGoDefer typechecks (normalizes) an OGO/ODEFER statement. +func tcGoDefer(n *ir.GoDeferStmt) { + call := normalizeGoDeferCall(n.Pos(), n.Op(), n.Call, n.PtrInit()) + call.GoDefer = true + n.Call = call +} + +// normalizeGoDeferCall normalizes call into a normal function call +// with no arguments and no results, suitable for use in an OGO/ODEFER +// statement. +// +// For example, it normalizes: +// +// f(x, y) +// +// into: +// +// x1, y1 := x, y // added to init +// func() { f(x1, y1) }() // result +func normalizeGoDeferCall(pos src.XPos, op ir.Op, call ir.Node, init *ir.Nodes) *ir.CallExpr { + init.Append(ir.TakeInit(call)...) + + if call, ok := call.(*ir.CallExpr); ok && call.Op() == ir.OCALLFUNC { + if sig := call.Fun.Type(); sig.NumParams()+sig.NumResults() == 0 { + return call // already in normal form + } + } + + // Create a new wrapper function without parameters or results. + wrapperFn := ir.NewClosureFunc(pos, pos, op, types.NewSignature(nil, nil, nil), ir.CurFunc, Target) + wrapperFn.DeclareParams(true) + wrapperFn.SetWrapper(true) + + // argps collects the list of operands within the call expression + // that must be evaluated at the go/defer statement. + var argps []*ir.Node + + var visit func(argp *ir.Node) + visit = func(argp *ir.Node) { + arg := *argp + if arg == nil { + return + } + + // Recognize a few common expressions that can be evaluated within + // the wrapper, so we don't need to allocate space for them within + // the closure. + switch arg.Op() { + case ir.OLITERAL, ir.ONIL, ir.OMETHEXPR, ir.ONEW: + return + case ir.ONAME: + arg := arg.(*ir.Name) + if arg.Class == ir.PFUNC { + return // reference to global function + } + case ir.OADDR: + arg := arg.(*ir.AddrExpr) + if arg.X.Op() == ir.OLINKSYMOFFSET { + return // address of global symbol + } + + case ir.OCONVNOP: + arg := arg.(*ir.ConvExpr) + + // For unsafe.Pointer->uintptr conversion arguments, save the + // unsafe.Pointer argument. This is necessary to handle cases + // like fixedbugs/issue24491a.go correctly. + // + // TODO(mdempsky): Limit to static callees with + // //go:uintptr{escapes,keepalive}? + if arg.Type().IsUintptr() && arg.X.Type().IsUnsafePtr() { + visit(&arg.X) + return + } + + case ir.OARRAYLIT, ir.OSLICELIT, ir.OSTRUCTLIT: + // TODO(mdempsky): For very large slices, it may be preferable + // to construct them at the go/defer statement instead. + list := arg.(*ir.CompLitExpr).List + for i, el := range list { + switch el := el.(type) { + case *ir.KeyExpr: + visit(&el.Value) + case *ir.StructKeyExpr: + visit(&el.Value) + default: + visit(&list[i]) + } + } + return + } + + argps = append(argps, argp) + } + + visitList := func(list []ir.Node) { + for i := range list { + visit(&list[i]) + } + } + + switch call.Op() { + default: + base.Fatalf("unexpected call op: %v", call.Op()) + + case ir.OCALLFUNC: + call := call.(*ir.CallExpr) + + // If the callee is a named function, link to the original callee. + if wrapped := ir.StaticCalleeName(call.Fun); wrapped != nil { + wrapperFn.WrappedFunc = wrapped.Func + } + + visit(&call.Fun) + visitList(call.Args) + + case ir.OCALLINTER: + call := call.(*ir.CallExpr) + argps = append(argps, &call.Fun.(*ir.SelectorExpr).X) // must be first for OCHECKNIL; see below + visitList(call.Args) + + case ir.OAPPEND, ir.ODELETE, ir.OPRINT, ir.OPRINTLN, ir.ORECOVER: + call := call.(*ir.CallExpr) + visitList(call.Args) + visit(&call.RType) + + case ir.OCOPY: + call := call.(*ir.BinaryExpr) + visit(&call.X) + visit(&call.Y) + visit(&call.RType) + + case ir.OCLEAR, ir.OCLOSE, ir.OPANIC: + call := call.(*ir.UnaryExpr) + visit(&call.X) + } + + if len(argps) != 0 { + // Found one or more operands that need to be evaluated upfront + // and spilled to temporary variables, which can be captured by + // the wrapper function. + + stmtPos := base.Pos + callPos := base.Pos + + as := ir.NewAssignListStmt(callPos, ir.OAS2, make([]ir.Node, len(argps)), make([]ir.Node, len(argps))) + for i, argp := range argps { + arg := *argp + + pos := callPos + if ir.HasUniquePos(arg) { + pos = arg.Pos() + } + + // tmp := arg + tmp := TempAt(pos, ir.CurFunc, arg.Type()) + init.Append(Stmt(ir.NewDecl(pos, ir.ODCL, tmp))) + tmp.Defn = as + as.Lhs[i] = tmp + as.Rhs[i] = arg + + // Rewrite original expression to use/capture tmp. + *argp = ir.NewClosureVar(pos, wrapperFn, tmp) + } + init.Append(Stmt(as)) + + // For "go/defer iface.M()", if iface is nil, we need to panic at + // the point of the go/defer statement. + if call.Op() == ir.OCALLINTER { + iface := as.Lhs[0] + init.Append(Stmt(ir.NewUnaryExpr(stmtPos, ir.OCHECKNIL, ir.NewUnaryExpr(iface.Pos(), ir.OITAB, iface)))) + } + } + + // Move call into the wrapper function, now that it's safe to + // evaluate there. + wrapperFn.Body = []ir.Node{call} + + // Finally, construct a call to the wrapper. + return Call(call.Pos(), wrapperFn.OClosure, nil, false).(*ir.CallExpr) +} + +// tcIf typechecks an OIF node. +func tcIf(n *ir.IfStmt) ir.Node { + Stmts(n.Init()) + n.Cond = Expr(n.Cond) + n.Cond = DefaultLit(n.Cond, nil) + if n.Cond != nil { + t := n.Cond.Type() + if t != nil && !t.IsBoolean() { + base.Errorf("non-bool %L used as if condition", n.Cond) + } + } + Stmts(n.Body) + Stmts(n.Else) + return n +} + +// range +func tcRange(n *ir.RangeStmt) { + n.X = Expr(n.X) + + // delicate little dance. see tcAssignList + if n.Key != nil { + if !ir.DeclaredBy(n.Key, n) { + n.Key = AssignExpr(n.Key) + } + checkassign(n.Key) + } + if n.Value != nil { + if !ir.DeclaredBy(n.Value, n) { + n.Value = AssignExpr(n.Value) + } + checkassign(n.Value) + } + + // second half of dance + n.SetTypecheck(1) + if n.Key != nil && n.Key.Typecheck() == 0 { + n.Key = AssignExpr(n.Key) + } + if n.Value != nil && n.Value.Typecheck() == 0 { + n.Value = AssignExpr(n.Value) + } + + Stmts(n.Body) +} + +// tcReturn typechecks an ORETURN node. +func tcReturn(n *ir.ReturnStmt) ir.Node { + if ir.CurFunc == nil { + base.FatalfAt(n.Pos(), "return outside function") + } + + typecheckargs(n) + if len(n.Results) != 0 { + typecheckaste(ir.ORETURN, nil, false, ir.CurFunc.Type().Results(), n.Results, func() string { return "return argument" }) + } + return n +} + +// select +func tcSelect(sel *ir.SelectStmt) { + var def *ir.CommClause + lno := ir.SetPos(sel) + Stmts(sel.Init()) + for _, ncase := range sel.Cases { + if ncase.Comm == nil { + // default + if def != nil { + base.ErrorfAt(ncase.Pos(), errors.DuplicateDefault, "multiple defaults in select (first at %v)", ir.Line(def)) + } else { + def = ncase + } + } else { + n := Stmt(ncase.Comm) + ncase.Comm = n + oselrecv2 := func(dst, recv ir.Node, def bool) { + selrecv := ir.NewAssignListStmt(n.Pos(), ir.OSELRECV2, []ir.Node{dst, ir.BlankNode}, []ir.Node{recv}) + selrecv.Def = def + selrecv.SetTypecheck(1) + selrecv.SetInit(n.Init()) + ncase.Comm = selrecv + } + switch n.Op() { + default: + pos := n.Pos() + if n.Op() == ir.ONAME { + // We don't have the right position for ONAME nodes (see #15459 and + // others). Using ncase.Pos for now as it will provide the correct + // line number (assuming the expression follows the "case" keyword + // on the same line). This matches the approach before 1.10. + pos = ncase.Pos() + } + base.ErrorfAt(pos, errors.InvalidSelectCase, "select case must be receive, send or assign recv") + + case ir.OAS: + // convert x = <-c into x, _ = <-c + // remove implicit conversions; the eventual assignment + // will reintroduce them. + n := n.(*ir.AssignStmt) + if r := n.Y; r.Op() == ir.OCONVNOP || r.Op() == ir.OCONVIFACE { + r := r.(*ir.ConvExpr) + if r.Implicit() { + n.Y = r.X + } + } + if n.Y.Op() != ir.ORECV { + base.ErrorfAt(n.Pos(), errors.InvalidSelectCase, "select assignment must have receive on right hand side") + break + } + oselrecv2(n.X, n.Y, n.Def) + + case ir.OAS2RECV: + n := n.(*ir.AssignListStmt) + if n.Rhs[0].Op() != ir.ORECV { + base.ErrorfAt(n.Pos(), errors.InvalidSelectCase, "select assignment must have receive on right hand side") + break + } + n.SetOp(ir.OSELRECV2) + + case ir.ORECV: + // convert <-c into _, _ = <-c + n := n.(*ir.UnaryExpr) + oselrecv2(ir.BlankNode, n, false) + + case ir.OSEND: + break + } + } + + Stmts(ncase.Body) + } + + base.Pos = lno +} + +// tcSend typechecks an OSEND node. +func tcSend(n *ir.SendStmt) ir.Node { + n.Chan = Expr(n.Chan) + n.Value = Expr(n.Value) + n.Chan = DefaultLit(n.Chan, nil) + t := n.Chan.Type() + if t == nil { + return n + } + if !t.IsChan() { + base.Errorf("invalid operation: %v (send to non-chan type %v)", n, t) + return n + } + + if !t.ChanDir().CanSend() { + base.Errorf("invalid operation: %v (send to receive-only type %v)", n, t) + return n + } + + n.Value = AssignConv(n.Value, t.Elem(), "send") + if n.Value.Type() == nil { + return n + } + return n +} + +// tcSwitch typechecks a switch statement. +func tcSwitch(n *ir.SwitchStmt) { + Stmts(n.Init()) + if n.Tag != nil && n.Tag.Op() == ir.OTYPESW { + tcSwitchType(n) + } else { + tcSwitchExpr(n) + } +} + +func tcSwitchExpr(n *ir.SwitchStmt) { + t := types.Types[types.TBOOL] + if n.Tag != nil { + n.Tag = Expr(n.Tag) + n.Tag = DefaultLit(n.Tag, nil) + t = n.Tag.Type() + } + + var nilonly string + if t != nil { + switch { + case t.IsMap(): + nilonly = "map" + case t.Kind() == types.TFUNC: + nilonly = "func" + case t.IsSlice(): + nilonly = "slice" + + case !types.IsComparable(t): + if t.IsStruct() { + base.ErrorfAt(n.Pos(), errors.InvalidExprSwitch, "cannot switch on %L (struct containing %v cannot be compared)", n.Tag, types.IncomparableField(t).Type) + } else { + base.ErrorfAt(n.Pos(), errors.InvalidExprSwitch, "cannot switch on %L", n.Tag) + } + t = nil + } + } + + var defCase ir.Node + for _, ncase := range n.Cases { + ls := ncase.List + if len(ls) == 0 { // default: + if defCase != nil { + base.ErrorfAt(ncase.Pos(), errors.DuplicateDefault, "multiple defaults in switch (first at %v)", ir.Line(defCase)) + } else { + defCase = ncase + } + } + + for i := range ls { + ir.SetPos(ncase) + ls[i] = Expr(ls[i]) + ls[i] = DefaultLit(ls[i], t) + n1 := ls[i] + if t == nil || n1.Type() == nil { + continue + } + + if nilonly != "" && !ir.IsNil(n1) { + base.ErrorfAt(ncase.Pos(), errors.MismatchedTypes, "invalid case %v in switch (can only compare %s %v to nil)", n1, nilonly, n.Tag) + } else if t.IsInterface() && !n1.Type().IsInterface() && !types.IsComparable(n1.Type()) { + base.ErrorfAt(ncase.Pos(), errors.UndefinedOp, "invalid case %L in switch (incomparable type)", n1) + } else { + op1, _ := assignOp(n1.Type(), t) + op2, _ := assignOp(t, n1.Type()) + if op1 == ir.OXXX && op2 == ir.OXXX { + if n.Tag != nil { + base.ErrorfAt(ncase.Pos(), errors.MismatchedTypes, "invalid case %v in switch on %v (mismatched types %v and %v)", n1, n.Tag, n1.Type(), t) + } else { + base.ErrorfAt(ncase.Pos(), errors.MismatchedTypes, "invalid case %v in switch (mismatched types %v and bool)", n1, n1.Type()) + } + } + } + } + + Stmts(ncase.Body) + } +} + +func tcSwitchType(n *ir.SwitchStmt) { + guard := n.Tag.(*ir.TypeSwitchGuard) + guard.X = Expr(guard.X) + t := guard.X.Type() + if t != nil && !t.IsInterface() { + base.ErrorfAt(n.Pos(), errors.InvalidTypeSwitch, "cannot type switch on non-interface value %L", guard.X) + t = nil + } + + // We don't actually declare the type switch's guarded + // declaration itself. So if there are no cases, we won't + // notice that it went unused. + if v := guard.Tag; v != nil && !ir.IsBlank(v) && len(n.Cases) == 0 { + base.ErrorfAt(v.Pos(), errors.UnusedVar, "%v declared but not used", v.Sym()) + } + + var defCase, nilCase ir.Node + var ts typeSet + for _, ncase := range n.Cases { + ls := ncase.List + if len(ls) == 0 { // default: + if defCase != nil { + base.ErrorfAt(ncase.Pos(), errors.DuplicateDefault, "multiple defaults in switch (first at %v)", ir.Line(defCase)) + } else { + defCase = ncase + } + } + + for i := range ls { + ls[i] = typecheck(ls[i], ctxExpr|ctxType) + n1 := ls[i] + if t == nil || n1.Type() == nil { + continue + } + + if ir.IsNil(n1) { // case nil: + if nilCase != nil { + base.ErrorfAt(ncase.Pos(), errors.DuplicateCase, "multiple nil cases in type switch (first at %v)", ir.Line(nilCase)) + } else { + nilCase = ncase + } + continue + } + if n1.Op() == ir.ODYNAMICTYPE { + continue + } + if n1.Op() != ir.OTYPE { + base.ErrorfAt(ncase.Pos(), errors.NotAType, "%L is not a type", n1) + continue + } + if !n1.Type().IsInterface() { + why := ImplementsExplain(n1.Type(), t) + if why != "" { + base.ErrorfAt(ncase.Pos(), errors.ImpossibleAssert, "impossible type switch case: %L cannot have dynamic type %v (%s)", guard.X, n1.Type(), why) + } + continue + } + + ts.add(ncase.Pos(), n1.Type()) + } + + if ncase.Var != nil { + // Assign the clause variable's type. + vt := t + if len(ls) == 1 { + if ls[0].Op() == ir.OTYPE || ls[0].Op() == ir.ODYNAMICTYPE { + vt = ls[0].Type() + } else if !ir.IsNil(ls[0]) { + // Invalid single-type case; + // mark variable as broken. + vt = nil + } + } + + nvar := ncase.Var + nvar.SetType(vt) + if vt != nil { + nvar = AssignExpr(nvar).(*ir.Name) + } else { + // Clause variable is broken; prevent typechecking. + nvar.SetTypecheck(1) + } + ncase.Var = nvar + } + + Stmts(ncase.Body) + } +} + +type typeSet struct { + m map[string]src.XPos +} + +func (s *typeSet) add(pos src.XPos, typ *types.Type) { + if s.m == nil { + s.m = make(map[string]src.XPos) + } + + ls := typ.LinkString() + if prev, ok := s.m[ls]; ok { + base.ErrorfAt(pos, errors.DuplicateCase, "duplicate case %v in type switch\n\tprevious case at %s", typ, base.FmtPos(prev)) + return + } + s.m[ls] = pos +} diff --git a/go/src/cmd/compile/internal/typecheck/subr.go b/go/src/cmd/compile/internal/typecheck/subr.go new file mode 100644 index 0000000000000000000000000000000000000000..3b22d260bf4fafb6ca3baef0d72c7d1177d73bd6 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/subr.go @@ -0,0 +1,792 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +import ( + "fmt" + "slices" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/obj" + "cmd/internal/src" +) + +func AssignConv(n ir.Node, t *types.Type, context string) ir.Node { + return assignconvfn(n, t, func() string { return context }) +} + +// LookupNum returns types.LocalPkg.LookupNum(prefix, n). +func LookupNum(prefix string, n int) *types.Sym { + return types.LocalPkg.LookupNum(prefix, n) +} + +// Given funarg struct list, return list of fn args. +func NewFuncParams(origs []*types.Field) []*types.Field { + res := make([]*types.Field, len(origs)) + for i, orig := range origs { + p := types.NewField(orig.Pos, orig.Sym, orig.Type) + p.SetIsDDD(orig.IsDDD()) + res[i] = p + } + return res +} + +// NodAddr returns a node representing &n at base.Pos. +func NodAddr(n ir.Node) *ir.AddrExpr { + return NodAddrAt(base.Pos, n) +} + +// NodAddrAt returns a node representing &n at position pos. +func NodAddrAt(pos src.XPos, n ir.Node) *ir.AddrExpr { + return ir.NewAddrExpr(pos, Expr(n)) +} + +// LinksymAddr returns a new expression that evaluates to the address +// of lsym. typ specifies the type of the addressed memory. +func LinksymAddr(pos src.XPos, lsym *obj.LSym, typ *types.Type) *ir.AddrExpr { + n := ir.NewLinksymExpr(pos, lsym, typ) + return Expr(NodAddrAt(pos, n)).(*ir.AddrExpr) +} + +func NodNil() ir.Node { + return ir.NewNilExpr(base.Pos, types.Types[types.TNIL]) +} + +// AddImplicitDots finds missing fields in obj.field that +// will give the shortest unique addressing and +// modifies the tree with missing field names. +func AddImplicitDots(n *ir.SelectorExpr) *ir.SelectorExpr { + n.X = typecheck(n.X, ctxType|ctxExpr) + t := n.X.Type() + if t == nil { + return n + } + + if n.X.Op() == ir.OTYPE { + return n + } + + s := n.Sel + if s == nil { + return n + } + + switch path, ambig := dotpath(s, t, nil, false); { + case path != nil: + // rebuild elided dots + for c := len(path) - 1; c >= 0; c-- { + dot := ir.NewSelectorExpr(n.Pos(), ir.ODOT, n.X, path[c].field.Sym) + dot.SetImplicit(true) + dot.SetType(path[c].field.Type) + n.X = dot + } + case ambig: + base.Errorf("ambiguous selector %v", n) + n.X = nil + } + + return n +} + +// CalcMethods calculates all the methods (including embedding) of a non-interface +// type t. +func CalcMethods(t *types.Type) { + if t == nil || len(t.AllMethods()) != 0 { + return + } + + // mark top-level method symbols + // so that expand1 doesn't consider them. + for _, f := range t.Methods() { + f.Sym.SetUniq(true) + } + + // generate all reachable methods + slist = slist[:0] + expand1(t, true) + + // check each method to be uniquely reachable + var ms []*types.Field + for i, sl := range slist { + slist[i].field = nil + sl.field.Sym.SetUniq(false) + + var f *types.Field + path, _ := dotpath(sl.field.Sym, t, &f, false) + if path == nil { + continue + } + + // dotpath may have dug out arbitrary fields, we only want methods. + if !f.IsMethod() { + continue + } + + // add it to the base type method list + f = f.Copy() + f.Embedded = 1 // needs a trampoline + for _, d := range path { + if d.field.Type.IsPtr() { + f.Embedded = 2 + break + } + } + ms = append(ms, f) + } + + for _, f := range t.Methods() { + f.Sym.SetUniq(false) + } + + ms = append(ms, t.Methods()...) + slices.SortFunc(ms, types.CompareFields) + t.SetAllMethods(ms) +} + +// adddot1 returns the number of fields or methods named s at depth d in Type t. +// If exactly one exists, it will be returned in *save (if save is not nil), +// and dotlist will contain the path of embedded fields traversed to find it, +// in reverse order. If none exist, more will indicate whether t contains any +// embedded fields at depth d, so callers can decide whether to retry at +// a greater depth. +func adddot1(s *types.Sym, t *types.Type, d int, save **types.Field, ignorecase bool) (c int, more bool) { + if t.Recur() { + return + } + t.SetRecur(true) + defer t.SetRecur(false) + + var u *types.Type + d-- + if d < 0 { + // We've reached our target depth. If t has any fields/methods + // named s, then we're done. Otherwise, we still need to check + // below for embedded fields. + c = lookdot0(s, t, save, ignorecase) + if c != 0 { + return c, false + } + } + + u = t + if u.IsPtr() { + u = u.Elem() + } + if !u.IsStruct() && !u.IsInterface() { + return c, false + } + + var fields []*types.Field + if u.IsStruct() { + fields = u.Fields() + } else { + fields = u.AllMethods() + } + for _, f := range fields { + if f.Embedded == 0 || f.Sym == nil { + continue + } + if d < 0 { + // Found an embedded field at target depth. + return c, true + } + a, more1 := adddot1(s, f.Type, d, save, ignorecase) + if a != 0 && c == 0 { + dotlist[d].field = f + } + c += a + if more1 { + more = true + } + } + + return c, more +} + +// dotlist is used by adddot1 to record the path of embedded fields +// used to access a target field or method. +// Must be non-nil so that dotpath returns a non-nil slice even if d is zero. +var dotlist = make([]dlist, 10) + +// Convert node n for assignment to type t. +func assignconvfn(n ir.Node, t *types.Type, context func() string) ir.Node { + if n == nil || n.Type() == nil { + return n + } + + if t.Kind() == types.TBLANK && n.Type().Kind() == types.TNIL { + base.Errorf("use of untyped nil") + } + + n = convlit1(n, t, false, context) + if n.Type() == nil { + base.Fatalf("cannot assign %v to %v", n, t) + } + if n.Type().IsUntyped() { + base.Fatalf("%L has untyped type", n) + } + if t.Kind() == types.TBLANK { + return n + } + if types.Identical(n.Type(), t) { + return n + } + + op, why := assignOp(n.Type(), t) + if op == ir.OXXX { + base.Errorf("cannot use %L as type %v in %s%s", n, t, context(), why) + op = ir.OCONV + } + + r := ir.NewConvExpr(base.Pos, op, t, n) + r.SetTypecheck(1) + r.SetImplicit(true) + return r +} + +// Is type src assignment compatible to type dst? +// If so, return op code to use in conversion. +// If not, return OXXX. In this case, the string return parameter may +// hold a reason why. In all other cases, it'll be the empty string. +func assignOp(src, dst *types.Type) (ir.Op, string) { + if src == dst { + return ir.OCONVNOP, "" + } + if src == nil || dst == nil || src.Kind() == types.TFORW || dst.Kind() == types.TFORW || src.Underlying() == nil || dst.Underlying() == nil { + return ir.OXXX, "" + } + + // 1. src type is identical to dst. + if types.Identical(src, dst) { + return ir.OCONVNOP, "" + } + + // 2. src and dst have identical underlying types and + // a. either src or dst is not a named type, or + // b. both are empty interface types, or + // c. at least one is a gcshape type. + // For assignable but different non-empty interface types, + // we want to recompute the itab. Recomputing the itab ensures + // that itabs are unique (thus an interface with a compile-time + // type I has an itab with interface type I). + if types.Identical(src.Underlying(), dst.Underlying()) { + if src.IsEmptyInterface() { + // Conversion between two empty interfaces + // requires no code. + return ir.OCONVNOP, "" + } + if (src.Sym() == nil || dst.Sym() == nil) && !src.IsInterface() { + // Conversion between two types, at least one unnamed, + // needs no conversion. The exception is nonempty interfaces + // which need to have their itab updated. + return ir.OCONVNOP, "" + } + if src.IsShape() || dst.IsShape() { + // Conversion between a shape type and one of the types + // it represents also needs no conversion. + return ir.OCONVNOP, "" + } + } + + // 3. dst is an interface type and src implements dst. + if dst.IsInterface() && src.Kind() != types.TNIL { + if src.IsShape() { + // Shape types implement things they have already + // been typechecked to implement, even if they + // don't have the methods for them. + return ir.OCONVIFACE, "" + } + if src.HasShape() { + // Unified IR uses OCONVIFACE for converting all derived types + // to interface type, not just type arguments themselves. + return ir.OCONVIFACE, "" + } + + why := ImplementsExplain(src, dst) + if why == "" { + return ir.OCONVIFACE, "" + } + return ir.OXXX, ":\n\t" + why + } + + if isptrto(dst, types.TINTER) { + why := fmt.Sprintf(":\n\t%v is pointer to interface, not interface", dst) + return ir.OXXX, why + } + + if src.IsInterface() && dst.Kind() != types.TBLANK { + var why string + if Implements(dst, src) { + why = ": need type assertion" + } + return ir.OXXX, why + } + + // 4. src is a bidirectional channel value, dst is a channel type, + // src and dst have identical element types, and + // either src or dst is not a named type. + if src.IsChan() && src.ChanDir() == types.Cboth && dst.IsChan() { + if types.Identical(src.Elem(), dst.Elem()) && (src.Sym() == nil || dst.Sym() == nil) { + return ir.OCONVNOP, "" + } + } + + // 5. src is the predeclared identifier nil and dst is a nillable type. + if src.Kind() == types.TNIL { + switch dst.Kind() { + case types.TPTR, + types.TFUNC, + types.TMAP, + types.TCHAN, + types.TINTER, + types.TSLICE: + return ir.OCONVNOP, "" + } + } + + // 6. rule about untyped constants - already converted by DefaultLit. + + // 7. Any typed value can be assigned to the blank identifier. + if dst.Kind() == types.TBLANK { + return ir.OCONVNOP, "" + } + + return ir.OXXX, "" +} + +// Can we convert a value of type src to a value of type dst? +// If so, return op code to use in conversion (maybe OCONVNOP). +// If not, return OXXX. In this case, the string return parameter may +// hold a reason why. In all other cases, it'll be the empty string. +// srcConstant indicates whether the value of type src is a constant. +func convertOp(srcConstant bool, src, dst *types.Type) (ir.Op, string) { + if src == dst { + return ir.OCONVNOP, "" + } + if src == nil || dst == nil { + return ir.OXXX, "" + } + + // Conversions from regular to not-in-heap are not allowed + // (unless it's unsafe.Pointer). These are runtime-specific + // rules. + // (a) Disallow (*T) to (*U) where T is not-in-heap but U isn't. + if src.IsPtr() && dst.IsPtr() && dst.Elem().NotInHeap() && !src.Elem().NotInHeap() { + why := fmt.Sprintf(":\n\t%v is incomplete (or unallocatable), but %v is not", dst.Elem(), src.Elem()) + return ir.OXXX, why + } + // (b) Disallow string to []T where T is not-in-heap. + if src.IsString() && dst.IsSlice() && dst.Elem().NotInHeap() && (dst.Elem().Kind() == types.ByteType.Kind() || dst.Elem().Kind() == types.RuneType.Kind()) { + why := fmt.Sprintf(":\n\t%v is incomplete (or unallocatable)", dst.Elem()) + return ir.OXXX, why + } + + // 1. src can be assigned to dst. + op, why := assignOp(src, dst) + if op != ir.OXXX { + return op, why + } + + // The rules for interfaces are no different in conversions + // than assignments. If interfaces are involved, stop now + // with the good message from assignop. + // Otherwise clear the error. + if src.IsInterface() || dst.IsInterface() { + return ir.OXXX, why + } + + // 2. Ignoring struct tags, src and dst have identical underlying types. + if types.IdenticalIgnoreTags(src.Underlying(), dst.Underlying()) { + return ir.OCONVNOP, "" + } + + // 3. src and dst are unnamed pointer types and, ignoring struct tags, + // their base types have identical underlying types. + if src.IsPtr() && dst.IsPtr() && src.Sym() == nil && dst.Sym() == nil { + if types.IdenticalIgnoreTags(src.Elem().Underlying(), dst.Elem().Underlying()) { + return ir.OCONVNOP, "" + } + } + + // 4. src and dst are both integer or floating point types. + if (src.IsInteger() || src.IsFloat()) && (dst.IsInteger() || dst.IsFloat()) { + if types.SimType[src.Kind()] == types.SimType[dst.Kind()] { + return ir.OCONVNOP, "" + } + return ir.OCONV, "" + } + + // 5. src and dst are both complex types. + if src.IsComplex() && dst.IsComplex() { + if types.SimType[src.Kind()] == types.SimType[dst.Kind()] { + return ir.OCONVNOP, "" + } + return ir.OCONV, "" + } + + // Special case for constant conversions: any numeric + // conversion is potentially okay. We'll validate further + // within evconst. See #38117. + if srcConstant && (src.IsInteger() || src.IsFloat() || src.IsComplex()) && (dst.IsInteger() || dst.IsFloat() || dst.IsComplex()) { + return ir.OCONV, "" + } + + // 6. src is an integer or has type []byte or []rune + // and dst is a string type. + if src.IsInteger() && dst.IsString() { + return ir.ORUNESTR, "" + } + + if src.IsSlice() && dst.IsString() { + if src.Elem().Kind() == types.ByteType.Kind() { + return ir.OBYTES2STR, "" + } + if src.Elem().Kind() == types.RuneType.Kind() { + return ir.ORUNES2STR, "" + } + } + + // 7. src is a string and dst is []byte or []rune. + // String to slice. + if src.IsString() && dst.IsSlice() { + if dst.Elem().Kind() == types.ByteType.Kind() { + return ir.OSTR2BYTES, "" + } + if dst.Elem().Kind() == types.RuneType.Kind() { + return ir.OSTR2RUNES, "" + } + } + + // 8. src is a pointer or uintptr and dst is unsafe.Pointer. + if (src.IsPtr() || src.IsUintptr()) && dst.IsUnsafePtr() { + return ir.OCONVNOP, "" + } + + // 9. src is unsafe.Pointer and dst is a pointer or uintptr. + if src.IsUnsafePtr() && (dst.IsPtr() || dst.IsUintptr()) { + return ir.OCONVNOP, "" + } + + // 10. src is a slice and dst is an array or pointer-to-array. + // They must have same element type. + if src.IsSlice() { + if dst.IsArray() && types.Identical(src.Elem(), dst.Elem()) { + return ir.OSLICE2ARR, "" + } + if dst.IsPtr() && dst.Elem().IsArray() && + types.Identical(src.Elem(), dst.Elem().Elem()) { + return ir.OSLICE2ARRPTR, "" + } + } + + return ir.OXXX, "" +} + +// Code to resolve elided DOTs in embedded types. + +// A dlist stores a pointer to a TFIELD Type embedded within +// a TSTRUCT or TINTER Type. +type dlist struct { + field *types.Field +} + +// dotpath computes the unique shortest explicit selector path to fully qualify +// a selection expression x.f, where x is of type t and f is the symbol s. +// If no such path exists, dotpath returns nil. +// If there are multiple shortest paths to the same depth, ambig is true. +func dotpath(s *types.Sym, t *types.Type, save **types.Field, ignorecase bool) (path []dlist, ambig bool) { + // The embedding of types within structs imposes a tree structure onto + // types: structs parent the types they embed, and types parent their + // fields or methods. Our goal here is to find the shortest path to + // a field or method named s in the subtree rooted at t. To accomplish + // that, we iteratively perform depth-first searches of increasing depth + // until we either find the named field/method or exhaust the tree. + for d := 0; ; d++ { + if d > len(dotlist) { + dotlist = append(dotlist, dlist{}) + } + if c, more := adddot1(s, t, d, save, ignorecase); c == 1 { + return dotlist[:d], false + } else if c > 1 { + return nil, true + } else if !more { + return nil, false + } + } +} + +func expand0(t *types.Type) { + u := t + if u.IsPtr() { + u = u.Elem() + } + + if u.IsInterface() { + for _, f := range u.AllMethods() { + if f.Sym.Uniq() { + continue + } + f.Sym.SetUniq(true) + slist = append(slist, symlink{field: f}) + } + + return + } + + u = types.ReceiverBaseType(t) + if u != nil { + for _, f := range u.Methods() { + if f.Sym.Uniq() { + continue + } + f.Sym.SetUniq(true) + slist = append(slist, symlink{field: f}) + } + } +} + +func expand1(t *types.Type, top bool) { + if t.Recur() { + return + } + t.SetRecur(true) + + if !top { + expand0(t) + } + + u := t + if u.IsPtr() { + u = u.Elem() + } + + if u.IsStruct() || u.IsInterface() { + var fields []*types.Field + if u.IsStruct() { + fields = u.Fields() + } else { + fields = u.AllMethods() + } + for _, f := range fields { + if f.Embedded == 0 { + continue + } + if f.Sym == nil { + continue + } + expand1(f.Type, false) + } + } + + t.SetRecur(false) +} + +func ifacelookdot(s *types.Sym, t *types.Type, ignorecase bool) *types.Field { + if t == nil { + return nil + } + + var m *types.Field + path, _ := dotpath(s, t, &m, ignorecase) + if path == nil { + return nil + } + + if !m.IsMethod() { + return nil + } + + return m +} + +// Implements reports whether t implements the interface iface. t can be +// an interface, a type parameter, or a concrete type. +func Implements(t, iface *types.Type) bool { + var missing, have *types.Field + var ptr int + return implements(t, iface, &missing, &have, &ptr) +} + +// ImplementsExplain reports whether t implements the interface iface. t can be +// an interface, a type parameter, or a concrete type. If t does not implement +// iface, a non-empty string is returned explaining why. +func ImplementsExplain(t, iface *types.Type) string { + var missing, have *types.Field + var ptr int + if implements(t, iface, &missing, &have, &ptr) { + return "" + } + + if isptrto(t, types.TINTER) { + return fmt.Sprintf("%v is pointer to interface, not interface", t) + } else if have != nil && have.Sym == missing.Sym && have.Nointerface() { + return fmt.Sprintf("%v does not implement %v (%v method is marked 'nointerface')", t, iface, missing.Sym) + } else if have != nil && have.Sym == missing.Sym { + return fmt.Sprintf("%v does not implement %v (wrong type for %v method)\n"+ + "\t\thave %v%S\n\t\twant %v%S", t, iface, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type) + } else if ptr != 0 { + return fmt.Sprintf("%v does not implement %v (%v method has pointer receiver)", t, iface, missing.Sym) + } else if have != nil { + return fmt.Sprintf("%v does not implement %v (missing %v method)\n"+ + "\t\thave %v%S\n\t\twant %v%S", t, iface, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type) + } + return fmt.Sprintf("%v does not implement %v (missing %v method)", t, iface, missing.Sym) +} + +// implements reports whether t implements the interface iface. t can be +// an interface, a type parameter, or a concrete type. If implements returns +// false, it stores a method of iface that is not implemented in *m. If the +// method name matches but the type is wrong, it additionally stores the type +// of the method (on t) in *samename. +func implements(t, iface *types.Type, m, samename **types.Field, ptr *int) bool { + t0 := t + if t == nil { + return false + } + + if t.IsInterface() { + i := 0 + tms := t.AllMethods() + for _, im := range iface.AllMethods() { + for i < len(tms) && tms[i].Sym != im.Sym { + i++ + } + if i == len(tms) { + *m = im + *samename = nil + *ptr = 0 + return false + } + tm := tms[i] + if !types.Identical(tm.Type, im.Type) { + *m = im + *samename = tm + *ptr = 0 + return false + } + } + + return true + } + + t = types.ReceiverBaseType(t) + var tms []*types.Field + if t != nil { + CalcMethods(t) + tms = t.AllMethods() + } + i := 0 + for _, im := range iface.AllMethods() { + for i < len(tms) && tms[i].Sym != im.Sym { + i++ + } + if i == len(tms) { + *m = im + *samename = ifacelookdot(im.Sym, t, true) + *ptr = 0 + return false + } + tm := tms[i] + if tm.Nointerface() || !types.Identical(tm.Type, im.Type) { + *m = im + *samename = tm + *ptr = 0 + return false + } + + // if pointer receiver in method, + // the method does not exist for value types. + if !types.IsMethodApplicable(t0, tm) { + if false && base.Flag.LowerR != 0 { + base.Errorf("interface pointer mismatch") + } + + *m = im + *samename = nil + *ptr = 1 + return false + } + } + + return true +} + +func isptrto(t *types.Type, et types.Kind) bool { + if t == nil { + return false + } + if !t.IsPtr() { + return false + } + t = t.Elem() + if t == nil { + return false + } + if t.Kind() != et { + return false + } + return true +} + +// lookdot0 returns the number of fields or methods named s associated +// with Type t. If exactly one exists, it will be returned in *save +// (if save is not nil). +func lookdot0(s *types.Sym, t *types.Type, save **types.Field, ignorecase bool) int { + u := t + if u.IsPtr() { + u = u.Elem() + } + + c := 0 + if u.IsStruct() || u.IsInterface() { + var fields []*types.Field + if u.IsStruct() { + fields = u.Fields() + } else { + fields = u.AllMethods() + } + for _, f := range fields { + if f.Sym == s || (ignorecase && f.IsMethod() && strings.EqualFold(f.Sym.Name, s.Name)) { + if save != nil { + *save = f + } + c++ + } + } + } + + u = t + if t.Sym() != nil && t.IsPtr() && !t.Elem().IsPtr() { + // If t is a defined pointer type, then x.m is shorthand for (*x).m. + u = t.Elem() + } + u = types.ReceiverBaseType(u) + if u != nil { + for _, f := range u.Methods() { + if f.Embedded == 0 && (f.Sym == s || (ignorecase && strings.EqualFold(f.Sym.Name, s.Name))) { + if save != nil { + *save = f + } + c++ + } + } + } + + return c +} + +var slist []symlink + +// Code to help generate trampoline functions for methods on embedded +// types. These are approx the same as the corresponding AddImplicitDots +// routines except that they expect to be called with unique tasks and +// they return the actual methods. + +type symlink struct { + field *types.Field +} diff --git a/go/src/cmd/compile/internal/typecheck/syms.go b/go/src/cmd/compile/internal/typecheck/syms.go new file mode 100644 index 0000000000000000000000000000000000000000..a977b5e1101b9a34a418cd6e9b753e6566d2aa5a --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/syms.go @@ -0,0 +1,134 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +import ( + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/obj" +) + +// LookupRuntime returns a function or variable declared in +// _builtin/runtime.go. If types_ is non-empty, successive occurrences +// of the "any" placeholder type will be substituted. +func LookupRuntime(name string, types_ ...*types.Type) *ir.Name { + s := ir.Pkgs.Runtime.Lookup(name) + if s == nil || s.Def == nil { + base.Fatalf("LookupRuntime: can't find runtime.%s", name) + } + n := s.Def.(*ir.Name) + if len(types_) != 0 { + n = substArgTypes(n, types_...) + } + return n +} + +// SubstArgTypes substitutes the given list of types for +// successive occurrences of the "any" placeholder in the +// type syntax expression n.Type. +func substArgTypes(old *ir.Name, types_ ...*types.Type) *ir.Name { + for _, t := range types_ { + types.CalcSize(t) + } + n := ir.NewNameAt(old.Pos(), old.Sym(), types.SubstAny(old.Type(), &types_)) + n.Class = old.Class + n.Func = old.Func + if len(types_) > 0 { + base.Fatalf("SubstArgTypes: too many argument types") + } + return n +} + +// AutoLabel generates a new Name node for use with +// an automatically generated label. +// prefix is a short mnemonic (e.g. ".s" for switch) +// to help with debugging. +// It should begin with "." to avoid conflicts with +// user labels. +func AutoLabel(prefix string) *types.Sym { + if prefix[0] != '.' { + base.Fatalf("autolabel prefix must start with '.', have %q", prefix) + } + fn := ir.CurFunc + if ir.CurFunc == nil { + base.Fatalf("autolabel outside function") + } + n := fn.Label + fn.Label++ + return LookupNum(prefix, int(n)) +} + +func Lookup(name string) *types.Sym { + return types.LocalPkg.Lookup(name) +} + +// InitRuntime loads the definitions for the low-level runtime functions, +// so that the compiler can generate calls to them, +// but does not make them visible to user code. +func InitRuntime() { + base.Timer.Start("fe", "loadsys") + + typs := runtimeTypes() + for _, d := range &runtimeDecls { + sym := ir.Pkgs.Runtime.Lookup(d.name) + typ := typs[d.typ] + switch d.tag { + case funcTag: + importfunc(sym, typ) + case varTag: + importvar(sym, typ) + default: + base.Fatalf("unhandled declaration tag %v", d.tag) + } + } +} + +// LookupRuntimeFunc looks up Go function name in package runtime. This function +// must follow the internal calling convention. +func LookupRuntimeFunc(name string) *obj.LSym { + return LookupRuntimeABI(name, obj.ABIInternal) +} + +// LookupRuntimeVar looks up a variable (or assembly function) name in package +// runtime. If this is a function, it may have a special calling +// convention. +func LookupRuntimeVar(name string) *obj.LSym { + return LookupRuntimeABI(name, obj.ABI0) +} + +// LookupRuntimeABI looks up a name in package runtime using the given ABI. +func LookupRuntimeABI(name string, abi obj.ABI) *obj.LSym { + return base.PkgLinksym("runtime", name, abi) +} + +// InitCoverage loads the definitions for routines called +// by code coverage instrumentation (similar to InitRuntime above). +func InitCoverage() { + typs := coverageTypes() + for _, d := range &coverageDecls { + sym := ir.Pkgs.Coverage.Lookup(d.name) + typ := typs[d.typ] + switch d.tag { + case funcTag: + importfunc(sym, typ) + case varTag: + importvar(sym, typ) + default: + base.Fatalf("unhandled declaration tag %v", d.tag) + } + } +} + +// LookupCoverage looks up the Go function 'name' in package +// runtime/coverage. This function must follow the internal calling +// convention. +func LookupCoverage(name string) *ir.Name { + sym := ir.Pkgs.Coverage.Lookup(name) + if sym == nil { + base.Fatalf("LookupCoverage: can't find runtime/coverage.%s", name) + } + return sym.Def.(*ir.Name) +} diff --git a/go/src/cmd/compile/internal/typecheck/target.go b/go/src/cmd/compile/internal/typecheck/target.go new file mode 100644 index 0000000000000000000000000000000000000000..018614d68bfc4f69c4e5260efa6f29d1416710e5 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/target.go @@ -0,0 +1,12 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:generate go run mkbuiltin.go + +package typecheck + +import "cmd/compile/internal/ir" + +// Target is the package being compiled. +var Target *ir.Package diff --git a/go/src/cmd/compile/internal/typecheck/type.go b/go/src/cmd/compile/internal/typecheck/type.go new file mode 100644 index 0000000000000000000000000000000000000000..37c394393a1a733ff372ed78774477c7bcce920c --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/type.go @@ -0,0 +1,5 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck diff --git a/go/src/cmd/compile/internal/typecheck/typecheck.go b/go/src/cmd/compile/internal/typecheck/typecheck.go new file mode 100644 index 0000000000000000000000000000000000000000..d7aad9c6b96f60225c331f4fb2055770b4731af2 --- /dev/null +++ b/go/src/cmd/compile/internal/typecheck/typecheck.go @@ -0,0 +1,1258 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typecheck + +import ( + "fmt" + "go/constant" + "strings" + + "cmd/compile/internal/base" + "cmd/compile/internal/ir" + "cmd/compile/internal/types" + "cmd/internal/src" +) + +func AssignExpr(n ir.Node) ir.Node { return typecheck(n, ctxExpr|ctxAssign) } +func Expr(n ir.Node) ir.Node { return typecheck(n, ctxExpr) } +func Stmt(n ir.Node) ir.Node { return typecheck(n, ctxStmt) } + +func Exprs(exprs []ir.Node) { typecheckslice(exprs, ctxExpr) } +func Stmts(stmts []ir.Node) { typecheckslice(stmts, ctxStmt) } + +func Call(pos src.XPos, callee ir.Node, args []ir.Node, dots bool) ir.Node { + call := ir.NewCallExpr(pos, ir.OCALL, callee, args) + call.IsDDD = dots + return typecheck(call, ctxStmt|ctxExpr) +} + +func Callee(n ir.Node) ir.Node { + return typecheck(n, ctxExpr|ctxCallee) +} + +var traceIndent []byte + +func tracePrint(title string, n ir.Node) func(np *ir.Node) { + indent := traceIndent + + // guard against nil + var pos, op string + var tc uint8 + if n != nil { + pos = base.FmtPos(n.Pos()) + op = n.Op().String() + tc = n.Typecheck() + } + + types.SkipSizeForTracing = true + defer func() { types.SkipSizeForTracing = false }() + fmt.Printf("%s: %s%s %p %s %v tc=%d\n", pos, indent, title, n, op, n, tc) + traceIndent = append(traceIndent, ". "...) + + return func(np *ir.Node) { + traceIndent = traceIndent[:len(traceIndent)-2] + + // if we have a result, use that + if np != nil { + n = *np + } + + // guard against nil + // use outer pos, op so we don't get empty pos/op if n == nil (nicer output) + var tc uint8 + var typ *types.Type + if n != nil { + pos = base.FmtPos(n.Pos()) + op = n.Op().String() + tc = n.Typecheck() + typ = n.Type() + } + + types.SkipSizeForTracing = true + defer func() { types.SkipSizeForTracing = false }() + fmt.Printf("%s: %s=> %p %s %v tc=%d type=%L\n", pos, indent, n, op, n, tc, typ) + } +} + +const ( + ctxStmt = 1 << iota // evaluated at statement level + ctxExpr // evaluated in value context + ctxType // evaluated in type context + ctxCallee // call-only expressions are ok + ctxMultiOK // multivalue function returns are ok + ctxAssign // assigning to expression +) + +// type checks the whole tree of an expression. +// calculates expression types. +// evaluates compile time constants. +// marks variables that escape the local frame. +// rewrites n.Op to be more specific in some cases. + +func typecheckslice(l []ir.Node, top int) { + for i := range l { + l[i] = typecheck(l[i], top) + } +} + +var _typekind = []string{ + types.TINT: "int", + types.TUINT: "uint", + types.TINT8: "int8", + types.TUINT8: "uint8", + types.TINT16: "int16", + types.TUINT16: "uint16", + types.TINT32: "int32", + types.TUINT32: "uint32", + types.TINT64: "int64", + types.TUINT64: "uint64", + types.TUINTPTR: "uintptr", + types.TCOMPLEX64: "complex64", + types.TCOMPLEX128: "complex128", + types.TFLOAT32: "float32", + types.TFLOAT64: "float64", + types.TBOOL: "bool", + types.TSTRING: "string", + types.TPTR: "pointer", + types.TUNSAFEPTR: "unsafe.Pointer", + types.TSTRUCT: "struct", + types.TINTER: "interface", + types.TCHAN: "chan", + types.TMAP: "map", + types.TARRAY: "array", + types.TSLICE: "slice", + types.TFUNC: "func", + types.TNIL: "nil", + types.TIDEAL: "untyped number", +} + +func typekind(t *types.Type) string { + if t.IsUntyped() { + return fmt.Sprintf("%v", t) + } + et := t.Kind() + if int(et) < len(_typekind) { + s := _typekind[et] + if s != "" { + return s + } + } + return fmt.Sprintf("etype=%d", et) +} + +// typecheck type checks node n. +// The result of typecheck MUST be assigned back to n, e.g. +// +// n.Left = typecheck(n.Left, top) +func typecheck(n ir.Node, top int) (res ir.Node) { + if n == nil { + return nil + } + + // only trace if there's work to do + if base.EnableTrace && base.Flag.LowerT { + defer tracePrint("typecheck", n)(&res) + } + + lno := ir.SetPos(n) + defer func() { base.Pos = lno }() + + // Skip typecheck if already done. + // But re-typecheck ONAME/OTYPE/OLITERAL/OPACK node in case context has changed. + if n.Typecheck() == 1 || n.Typecheck() == 3 { + switch n.Op() { + case ir.ONAME: + break + + default: + return n + } + } + + if n.Typecheck() == 2 { + base.FatalfAt(n.Pos(), "typechecking loop") + } + + n.SetTypecheck(2) + n = typecheck1(n, top) + n.SetTypecheck(1) + + t := n.Type() + if t != nil && !t.IsFuncArgStruct() && n.Op() != ir.OTYPE { + switch t.Kind() { + case types.TFUNC, // might have TANY; wait until it's called + types.TANY, types.TFORW, types.TIDEAL, types.TNIL, types.TBLANK: + break + + default: + types.CheckSize(t) + } + } + + return n +} + +// indexlit implements typechecking of untyped values as +// array/slice indexes. It is almost equivalent to DefaultLit +// but also accepts untyped numeric values representable as +// value of type int (see also checkmake for comparison). +// The result of indexlit MUST be assigned back to n, e.g. +// +// n.Left = indexlit(n.Left) +func indexlit(n ir.Node) ir.Node { + if n != nil && n.Type() != nil && n.Type().Kind() == types.TIDEAL { + return DefaultLit(n, types.Types[types.TINT]) + } + return n +} + +// typecheck1 should ONLY be called from typecheck. +func typecheck1(n ir.Node, top int) ir.Node { + // Skip over parens. + for n.Op() == ir.OPAREN { + n = n.(*ir.ParenExpr).X + } + + switch n.Op() { + default: + ir.Dump("typecheck", n) + base.Fatalf("typecheck %v", n.Op()) + panic("unreachable") + + case ir.ONAME: + n := n.(*ir.Name) + if n.BuiltinOp != 0 { + if top&ctxCallee == 0 { + base.Errorf("use of builtin %v not in function call", n.Sym()) + n.SetType(nil) + return n + } + return n + } + if top&ctxAssign == 0 { + // not a write to the variable + if ir.IsBlank(n) { + base.Errorf("cannot use _ as value") + n.SetType(nil) + return n + } + n.SetUsed(true) + } + return n + + // type or expr + case ir.ODEREF: + n := n.(*ir.StarExpr) + return tcStar(n, top) + + // x op= y + case ir.OASOP: + n := n.(*ir.AssignOpStmt) + n.X, n.Y = Expr(n.X), Expr(n.Y) + checkassign(n.X) + if n.IncDec && !okforarith[n.X.Type().Kind()] { + base.Errorf("invalid operation: %v (non-numeric type %v)", n, n.X.Type()) + return n + } + switch n.AsOp { + case ir.OLSH, ir.ORSH: + n.X, n.Y, _ = tcShift(n, n.X, n.Y) + case ir.OADD, ir.OAND, ir.OANDNOT, ir.ODIV, ir.OMOD, ir.OMUL, ir.OOR, ir.OSUB, ir.OXOR: + n.X, n.Y, _ = tcArith(n, n.AsOp, n.X, n.Y) + default: + base.Fatalf("invalid assign op: %v", n.AsOp) + } + return n + + // logical operators + case ir.OANDAND, ir.OOROR: + n := n.(*ir.LogicalExpr) + n.X, n.Y = Expr(n.X), Expr(n.Y) + if n.X.Type() == nil || n.Y.Type() == nil { + n.SetType(nil) + return n + } + // For "x == x && len(s)", it's better to report that "len(s)" (type int) + // can't be used with "&&" than to report that "x == x" (type untyped bool) + // can't be converted to int (see issue #41500). + if !n.X.Type().IsBoolean() { + base.Errorf("invalid operation: %v (operator %v not defined on %s)", n, n.Op(), typekind(n.X.Type())) + n.SetType(nil) + return n + } + if !n.Y.Type().IsBoolean() { + base.Errorf("invalid operation: %v (operator %v not defined on %s)", n, n.Op(), typekind(n.Y.Type())) + n.SetType(nil) + return n + } + l, r, t := tcArith(n, n.Op(), n.X, n.Y) + n.X, n.Y = l, r + n.SetType(t) + return n + + // shift operators + case ir.OLSH, ir.ORSH: + n := n.(*ir.BinaryExpr) + n.X, n.Y = Expr(n.X), Expr(n.Y) + l, r, t := tcShift(n, n.X, n.Y) + n.X, n.Y = l, r + n.SetType(t) + return n + + // comparison operators + case ir.OEQ, ir.OGE, ir.OGT, ir.OLE, ir.OLT, ir.ONE: + n := n.(*ir.BinaryExpr) + n.X, n.Y = Expr(n.X), Expr(n.Y) + l, r, t := tcArith(n, n.Op(), n.X, n.Y) + if t != nil { + n.X, n.Y = l, r + n.SetType(types.UntypedBool) + n.X, n.Y = defaultlit2(l, r, true) + } + return n + + // binary operators + case ir.OADD, ir.OAND, ir.OANDNOT, ir.ODIV, ir.OMOD, ir.OMUL, ir.OOR, ir.OSUB, ir.OXOR: + n := n.(*ir.BinaryExpr) + n.X, n.Y = Expr(n.X), Expr(n.Y) + l, r, t := tcArith(n, n.Op(), n.X, n.Y) + if t != nil && t.Kind() == types.TSTRING && n.Op() == ir.OADD { + // create or update OADDSTR node with list of strings in x + y + z + (w + v) + ... + var add *ir.AddStringExpr + if l.Op() == ir.OADDSTR { + add = l.(*ir.AddStringExpr) + add.SetPos(n.Pos()) + } else { + add = ir.NewAddStringExpr(n.Pos(), []ir.Node{l}) + } + if r.Op() == ir.OADDSTR { + r := r.(*ir.AddStringExpr) + add.List.Append(r.List.Take()...) + } else { + add.List.Append(r) + } + add.SetType(t) + return add + } + n.X, n.Y = l, r + n.SetType(t) + return n + + case ir.OBITNOT, ir.ONEG, ir.ONOT, ir.OPLUS: + n := n.(*ir.UnaryExpr) + return tcUnaryArith(n) + + // exprs + case ir.OCOMPLIT: + return tcCompLit(n.(*ir.CompLitExpr)) + + case ir.OXDOT, ir.ODOT: + n := n.(*ir.SelectorExpr) + return tcDot(n, top) + + case ir.ODOTTYPE: + n := n.(*ir.TypeAssertExpr) + return tcDotType(n) + + case ir.OINDEX: + n := n.(*ir.IndexExpr) + return tcIndex(n) + + case ir.ORECV: + n := n.(*ir.UnaryExpr) + return tcRecv(n) + + case ir.OSEND: + n := n.(*ir.SendStmt) + return tcSend(n) + + case ir.OSLICEHEADER: + n := n.(*ir.SliceHeaderExpr) + return tcSliceHeader(n) + + case ir.OSTRINGHEADER: + n := n.(*ir.StringHeaderExpr) + return tcStringHeader(n) + + case ir.OMAKESLICECOPY: + n := n.(*ir.MakeExpr) + return tcMakeSliceCopy(n) + + case ir.OSLICE, ir.OSLICE3: + n := n.(*ir.SliceExpr) + return tcSlice(n) + + // call and call like + case ir.OCALL: + n := n.(*ir.CallExpr) + return tcCall(n, top) + + case ir.OCAP, ir.OLEN: + n := n.(*ir.UnaryExpr) + return tcLenCap(n) + + case ir.OMIN, ir.OMAX: + n := n.(*ir.CallExpr) + return tcMinMax(n) + + case ir.OREAL, ir.OIMAG: + n := n.(*ir.UnaryExpr) + return tcRealImag(n) + + case ir.OCOMPLEX: + n := n.(*ir.BinaryExpr) + return tcComplex(n) + + case ir.OCLEAR: + n := n.(*ir.UnaryExpr) + return tcClear(n) + + case ir.OCLOSE: + n := n.(*ir.UnaryExpr) + return tcClose(n) + + case ir.ODELETE: + n := n.(*ir.CallExpr) + return tcDelete(n) + + case ir.OAPPEND: + n := n.(*ir.CallExpr) + return tcAppend(n) + + case ir.OCOPY: + n := n.(*ir.BinaryExpr) + return tcCopy(n) + + case ir.OCONV: + n := n.(*ir.ConvExpr) + return tcConv(n) + + case ir.OMAKE: + n := n.(*ir.CallExpr) + return tcMake(n) + + case ir.ONEW: + n := n.(*ir.UnaryExpr) + return tcNew(n) + + case ir.OPRINT, ir.OPRINTLN: + n := n.(*ir.CallExpr) + return tcPrint(n) + + case ir.OPANIC: + n := n.(*ir.UnaryExpr) + return tcPanic(n) + + case ir.ORECOVER: + n := n.(*ir.CallExpr) + return tcRecover(n) + + case ir.OUNSAFEADD: + n := n.(*ir.BinaryExpr) + return tcUnsafeAdd(n) + + case ir.OUNSAFESLICE: + n := n.(*ir.BinaryExpr) + return tcUnsafeSlice(n) + + case ir.OUNSAFESLICEDATA: + n := n.(*ir.UnaryExpr) + return tcUnsafeData(n) + + case ir.OUNSAFESTRING: + n := n.(*ir.BinaryExpr) + return tcUnsafeString(n) + + case ir.OUNSAFESTRINGDATA: + n := n.(*ir.UnaryExpr) + return tcUnsafeData(n) + + case ir.OITAB: + n := n.(*ir.UnaryExpr) + return tcITab(n) + + case ir.OIDATA: + // Whoever creates the OIDATA node must know a priori the concrete type at that moment, + // usually by just having checked the OITAB. + n := n.(*ir.UnaryExpr) + base.Fatalf("cannot typecheck interface data %v", n) + panic("unreachable") + + case ir.OSPTR: + n := n.(*ir.UnaryExpr) + return tcSPtr(n) + + case ir.OCFUNC: + n := n.(*ir.UnaryExpr) + n.X = Expr(n.X) + n.SetType(types.Types[types.TUINTPTR]) + return n + + case ir.OGETCALLERSP: + n := n.(*ir.CallExpr) + if len(n.Args) != 0 { + base.FatalfAt(n.Pos(), "unexpected arguments: %v", n) + } + n.SetType(types.Types[types.TUINTPTR]) + return n + + case ir.OCONVNOP: + n := n.(*ir.ConvExpr) + n.X = Expr(n.X) + return n + + // statements + case ir.OAS: + n := n.(*ir.AssignStmt) + tcAssign(n) + + // Code that creates temps does not bother to set defn, so do it here. + if n.X.Op() == ir.ONAME && ir.IsAutoTmp(n.X) { + n.X.Name().Defn = n + } + return n + + case ir.OAS2: + tcAssignList(n.(*ir.AssignListStmt)) + return n + + case ir.OBREAK, + ir.OCONTINUE, + ir.ODCL, + ir.OGOTO, + ir.OFALL: + return n + + case ir.OBLOCK: + n := n.(*ir.BlockStmt) + Stmts(n.List) + return n + + case ir.OLABEL: + if n.Sym().IsBlank() { + // Empty identifier is valid but useless. + // Eliminate now to simplify life later. + // See issues 7538, 11589, 11593. + n = ir.NewBlockStmt(n.Pos(), nil) + } + return n + + case ir.ODEFER, ir.OGO: + n := n.(*ir.GoDeferStmt) + n.Call = typecheck(n.Call, ctxStmt|ctxExpr) + tcGoDefer(n) + return n + + case ir.OFOR: + n := n.(*ir.ForStmt) + return tcFor(n) + + case ir.OIF: + n := n.(*ir.IfStmt) + return tcIf(n) + + case ir.ORETURN: + n := n.(*ir.ReturnStmt) + return tcReturn(n) + + case ir.OTAILCALL: + n := n.(*ir.TailCallStmt) + n.Call = typecheck(n.Call, ctxStmt|ctxExpr).(*ir.CallExpr) + return n + + case ir.OCHECKNIL: + n := n.(*ir.UnaryExpr) + return tcCheckNil(n) + + case ir.OSELECT: + tcSelect(n.(*ir.SelectStmt)) + return n + + case ir.OSWITCH: + tcSwitch(n.(*ir.SwitchStmt)) + return n + + case ir.ORANGE: + tcRange(n.(*ir.RangeStmt)) + return n + + case ir.OTYPESW: + n := n.(*ir.TypeSwitchGuard) + base.Fatalf("use of .(type) outside type switch") + return n + + case ir.ODCLFUNC: + tcFunc(n.(*ir.Func)) + return n + } + + // No return n here! + // Individual cases can type-assert n, introducing a new one. + // Each must execute its own return n. +} + +func typecheckargs(n ir.InitNode) { + var list []ir.Node + switch n := n.(type) { + default: + base.Fatalf("typecheckargs %+v", n.Op()) + case *ir.CallExpr: + list = n.Args + if n.IsDDD { + Exprs(list) + return + } + case *ir.ReturnStmt: + list = n.Results + } + if len(list) != 1 { + Exprs(list) + return + } + + typecheckslice(list, ctxExpr|ctxMultiOK) + t := list[0].Type() + if t == nil || !t.IsFuncArgStruct() { + return + } + + // Rewrite f(g()) into t1, t2, ... = g(); f(t1, t2, ...). + RewriteMultiValueCall(n, list[0]) +} + +// RewriteNonNameCall replaces non-Name call expressions with temps, +// rewriting f()(...) to t0 := f(); t0(...). +func RewriteNonNameCall(n *ir.CallExpr) { + np := &n.Fun + if dot, ok := (*np).(*ir.SelectorExpr); ok && (dot.Op() == ir.ODOTMETH || dot.Op() == ir.ODOTINTER || dot.Op() == ir.OMETHVALUE) { + np = &dot.X // peel away method selector + } + + // Check for side effects in the callee expression. + // We explicitly special case new(T) though, because it doesn't have + // observable side effects, and keeping it in place allows better escape analysis. + if !ir.Any(*np, func(n ir.Node) bool { return n.Op() != ir.ONEW && callOrChan(n) }) { + return + } + + tmp := TempAt(base.Pos, ir.CurFunc, (*np).Type()) + as := ir.NewAssignStmt(base.Pos, tmp, *np) + as.PtrInit().Append(Stmt(ir.NewDecl(n.Pos(), ir.ODCL, tmp))) + *np = tmp + + n.PtrInit().Append(Stmt(as)) +} + +// RewriteMultiValueCall rewrites multi-valued f() to use temporaries, +// so the backend wouldn't need to worry about tuple-valued expressions. +func RewriteMultiValueCall(n ir.InitNode, call ir.Node) { + as := ir.NewAssignListStmt(base.Pos, ir.OAS2, nil, []ir.Node{call}) + results := call.Type().Fields() + list := make([]ir.Node, len(results)) + for i, result := range results { + tmp := TempAt(base.Pos, ir.CurFunc, result.Type) + as.PtrInit().Append(ir.NewDecl(base.Pos, ir.ODCL, tmp)) + as.Lhs.Append(tmp) + list[i] = tmp + } + + n.PtrInit().Append(Stmt(as)) + + switch n := n.(type) { + default: + base.Fatalf("RewriteMultiValueCall %+v", n.Op()) + case *ir.CallExpr: + n.Args = list + case *ir.ReturnStmt: + n.Results = list + case *ir.AssignListStmt: + if n.Op() != ir.OAS2FUNC { + base.Fatalf("RewriteMultiValueCall: invalid op %v", n.Op()) + } + as.SetOp(ir.OAS2FUNC) + n.SetOp(ir.OAS2) + n.Rhs = make([]ir.Node, len(list)) + for i, tmp := range list { + n.Rhs[i] = AssignConv(tmp, n.Lhs[i].Type(), "assignment") + } + } +} + +func checksliceindex(r ir.Node) bool { + t := r.Type() + if t == nil { + return false + } + if !t.IsInteger() { + base.Errorf("invalid slice index %v (type %v)", r, t) + return false + } + return true +} + +// The result of implicitstar MUST be assigned back to n, e.g. +// +// n.Left = implicitstar(n.Left) +func implicitstar(n ir.Node) ir.Node { + // insert implicit * if needed for fixed array + t := n.Type() + if t == nil || !t.IsPtr() { + return n + } + t = t.Elem() + if t == nil { + return n + } + if !t.IsArray() { + return n + } + star := ir.NewStarExpr(base.Pos, n) + star.SetImplicit(true) + return Expr(star) +} + +func needOneArg(n *ir.CallExpr, f string, args ...any) (ir.Node, bool) { + if len(n.Args) == 0 { + p := fmt.Sprintf(f, args...) + base.Errorf("missing argument to %s: %v", p, n) + return nil, false + } + + if len(n.Args) > 1 { + p := fmt.Sprintf(f, args...) + base.Errorf("too many arguments to %s: %v", p, n) + return n.Args[0], false + } + + return n.Args[0], true +} + +func needTwoArgs(n *ir.CallExpr) (ir.Node, ir.Node, bool) { + if len(n.Args) != 2 { + if len(n.Args) < 2 { + base.Errorf("not enough arguments in call to %v", n) + } else { + base.Errorf("too many arguments in call to %v", n) + } + return nil, nil, false + } + return n.Args[0], n.Args[1], true +} + +// Lookdot1 looks up the specified method s in the list fs of methods, returning +// the matching field or nil. If dostrcmp is 0, it matches the symbols. If +// dostrcmp is 1, it matches by name exactly. If dostrcmp is 2, it matches names +// with case folding. +func Lookdot1(errnode ir.Node, s *types.Sym, t *types.Type, fs []*types.Field, dostrcmp int) *types.Field { + var r *types.Field + for _, f := range fs { + if dostrcmp != 0 && f.Sym.Name == s.Name { + return f + } + if dostrcmp == 2 && strings.EqualFold(f.Sym.Name, s.Name) { + return f + } + if f.Sym != s { + continue + } + if r != nil { + if errnode != nil { + base.Errorf("ambiguous selector %v", errnode) + } else if t.IsPtr() { + base.Errorf("ambiguous selector (%v).%v", t, s) + } else { + base.Errorf("ambiguous selector %v.%v", t, s) + } + break + } + + r = f + } + + return r +} + +// NewMethodExpr returns an OMETHEXPR node representing method +// expression "recv.sym". +func NewMethodExpr(pos src.XPos, recv *types.Type, sym *types.Sym) *ir.SelectorExpr { + // Compute the method set for recv. + var ms []*types.Field + if recv.IsInterface() { + ms = recv.AllMethods() + } else { + mt := types.ReceiverBaseType(recv) + if mt == nil { + base.FatalfAt(pos, "type %v has no receiver base type", recv) + } + CalcMethods(mt) + ms = mt.AllMethods() + } + + m := Lookdot1(nil, sym, recv, ms, 0) + if m == nil { + base.FatalfAt(pos, "type %v has no method %v", recv, sym) + } + + if !types.IsMethodApplicable(recv, m) { + base.FatalfAt(pos, "invalid method expression %v.%v (needs pointer receiver)", recv, sym) + } + + n := ir.NewSelectorExpr(pos, ir.OMETHEXPR, ir.TypeNode(recv), sym) + n.Selection = m + n.SetType(NewMethodType(m.Type, recv)) + n.SetTypecheck(1) + return n +} + +func derefall(t *types.Type) *types.Type { + for t != nil && t.IsPtr() { + t = t.Elem() + } + return t +} + +// Lookdot looks up field or method n.Sel in the type t and returns the matching +// field. It transforms the op of node n to ODOTINTER or ODOTMETH, if appropriate. +// It also may add a StarExpr node to n.X as needed for access to non-pointer +// methods. If dostrcmp is 0, it matches the field/method with the exact symbol +// as n.Sel (appropriate for exported fields). If dostrcmp is 1, it matches by name +// exactly. If dostrcmp is 2, it matches names with case folding. +func Lookdot(n *ir.SelectorExpr, t *types.Type, dostrcmp int) *types.Field { + s := n.Sel + + types.CalcSize(t) + var f1 *types.Field + if t.IsStruct() { + f1 = Lookdot1(n, s, t, t.Fields(), dostrcmp) + } else if t.IsInterface() { + f1 = Lookdot1(n, s, t, t.AllMethods(), dostrcmp) + } + + var f2 *types.Field + if n.X.Type() == t || n.X.Type().Sym() == nil { + mt := types.ReceiverBaseType(t) + if mt != nil { + f2 = Lookdot1(n, s, mt, mt.Methods(), dostrcmp) + } + } + + if f1 != nil { + if dostrcmp > 1 { + // Already in the process of diagnosing an error. + return f1 + } + if f2 != nil { + base.Errorf("%v is both field and method", n.Sel) + } + if f1.Offset == types.BADWIDTH { + base.Fatalf("Lookdot badwidth t=%v, f1=%v@%p", t, f1, f1) + } + n.Selection = f1 + n.SetType(f1.Type) + if t.IsInterface() { + if n.X.Type().IsPtr() { + star := ir.NewStarExpr(base.Pos, n.X) + star.SetImplicit(true) + n.X = Expr(star) + } + + n.SetOp(ir.ODOTINTER) + } + return f1 + } + + if f2 != nil { + if dostrcmp > 1 { + // Already in the process of diagnosing an error. + return f2 + } + orig := n.X + tt := n.X.Type() + types.CalcSize(tt) + rcvr := f2.Type.Recv().Type + if !types.Identical(rcvr, tt) { + if rcvr.IsPtr() && types.Identical(rcvr.Elem(), tt) { + checklvalue(n.X, "call pointer method on") + addr := NodAddr(n.X) + addr.SetImplicit(true) + n.X = typecheck(addr, ctxType|ctxExpr) + } else if tt.IsPtr() && (!rcvr.IsPtr() || rcvr.IsPtr() && rcvr.Elem().NotInHeap()) && types.Identical(tt.Elem(), rcvr) { + star := ir.NewStarExpr(base.Pos, n.X) + star.SetImplicit(true) + n.X = typecheck(star, ctxType|ctxExpr) + } else if tt.IsPtr() && tt.Elem().IsPtr() && types.Identical(derefall(tt), derefall(rcvr)) { + base.Errorf("calling method %v with receiver %L requires explicit dereference", n.Sel, n.X) + for tt.IsPtr() { + // Stop one level early for method with pointer receiver. + if rcvr.IsPtr() && !tt.Elem().IsPtr() { + break + } + star := ir.NewStarExpr(base.Pos, n.X) + star.SetImplicit(true) + n.X = typecheck(star, ctxType|ctxExpr) + tt = tt.Elem() + } + } else { + base.Fatalf("method mismatch: %v for %v", rcvr, tt) + } + } + + // Check that we haven't implicitly dereferenced any defined pointer types. + for x := n.X; ; { + var inner ir.Node + implicit := false + switch x := x.(type) { + case *ir.AddrExpr: + inner, implicit = x.X, x.Implicit() + case *ir.SelectorExpr: + inner, implicit = x.X, x.Implicit() + case *ir.StarExpr: + inner, implicit = x.X, x.Implicit() + } + if !implicit { + break + } + if inner.Type().Sym() != nil && (x.Op() == ir.ODEREF || x.Op() == ir.ODOTPTR) { + // Found an implicit dereference of a defined pointer type. + // Restore n.X for better error message. + n.X = orig + return nil + } + x = inner + } + + n.Selection = f2 + n.SetType(f2.Type) + n.SetOp(ir.ODOTMETH) + + return f2 + } + + return nil +} + +func nokeys(l ir.Nodes) bool { + for _, n := range l { + if n.Op() == ir.OKEY || n.Op() == ir.OSTRUCTKEY { + return false + } + } + return true +} + +func hasddd(params []*types.Field) bool { + // TODO(mdempsky): Simply check the last param. + for _, tl := range params { + if tl.IsDDD() { + return true + } + } + + return false +} + +// typecheck assignment: type list = expression list +func typecheckaste(op ir.Op, call ir.Node, isddd bool, params []*types.Field, nl ir.Nodes, desc func() string) { + var t *types.Type + var i int + + lno := base.Pos + defer func() { base.Pos = lno }() + + var n ir.Node + if len(nl) == 1 { + n = nl[0] + } + + n1 := len(params) + n2 := len(nl) + if !hasddd(params) { + if isddd { + goto invalidddd + } + if n2 > n1 { + goto toomany + } + if n2 < n1 { + goto notenough + } + } else { + if !isddd { + if n2 < n1-1 { + goto notenough + } + } else { + if n2 > n1 { + goto toomany + } + if n2 < n1 { + goto notenough + } + } + } + + i = 0 + for _, tl := range params { + t = tl.Type + if tl.IsDDD() { + if isddd { + if i >= len(nl) { + goto notenough + } + if len(nl)-i > 1 { + goto toomany + } + n = nl[i] + ir.SetPos(n) + if n.Type() != nil { + nl[i] = assignconvfn(n, t, desc) + } + return + } + + // TODO(mdempsky): Make into ... call with implicit slice. + for ; i < len(nl); i++ { + n = nl[i] + ir.SetPos(n) + if n.Type() != nil { + nl[i] = assignconvfn(n, t.Elem(), desc) + } + } + return + } + + if i >= len(nl) { + goto notenough + } + n = nl[i] + ir.SetPos(n) + if n.Type() != nil { + nl[i] = assignconvfn(n, t, desc) + } + i++ + } + + if i < len(nl) { + goto toomany + } + +invalidddd: + if isddd { + if call != nil { + base.Errorf("invalid use of ... in call to %v", call) + } else { + base.Errorf("invalid use of ... in %v", op) + } + } + return + +notenough: + if n == nil || n.Type() != nil { + base.Fatalf("not enough arguments to %v", op) + } + return + +toomany: + base.Fatalf("too many arguments to %v", op) +} + +// type check composite. +func fielddup(name string, hash map[string]bool) { + if hash[name] { + base.Errorf("duplicate field name in struct literal: %s", name) + return + } + hash[name] = true +} + +// typecheckarraylit type-checks a sequence of slice/array literal elements. +func typecheckarraylit(elemType *types.Type, bound int64, elts []ir.Node, ctx string) int64 { + // If there are key/value pairs, create a map to keep seen + // keys so we can check for duplicate indices. + var indices map[int64]bool + for _, elt := range elts { + if elt.Op() == ir.OKEY { + indices = make(map[int64]bool) + break + } + } + + var key, length int64 + for i, elt := range elts { + ir.SetPos(elt) + r := elts[i] + var kv *ir.KeyExpr + if elt.Op() == ir.OKEY { + elt := elt.(*ir.KeyExpr) + elt.Key = Expr(elt.Key) + key = IndexConst(elt.Key) + kv = elt + r = elt.Value + } + + r = Expr(r) + r = AssignConv(r, elemType, ctx) + if kv != nil { + kv.Value = r + } else { + elts[i] = r + } + + if key >= 0 { + if indices != nil { + if indices[key] { + base.Errorf("duplicate index in %s: %d", ctx, key) + } else { + indices[key] = true + } + } + + if bound >= 0 && key >= bound { + base.Errorf("array index %d out of bounds [0:%d]", key, bound) + bound = -1 + } + } + + key++ + if key > length { + length = key + } + } + + return length +} + +// visible reports whether sym is exported or locally defined. +func visible(sym *types.Sym) bool { + return sym != nil && (types.IsExported(sym.Name) || sym.Pkg == types.LocalPkg) +} + +// nonexported reports whether sym is an unexported field. +func nonexported(sym *types.Sym) bool { + return sym != nil && !types.IsExported(sym.Name) +} + +func checklvalue(n ir.Node, verb string) { + if !ir.IsAddressable(n) { + base.Errorf("cannot %s %v", verb, n) + } +} + +func checkassign(n ir.Node) { + // have already complained about n being invalid + if n.Type() == nil { + if base.Errors() == 0 { + base.Fatalf("expected an error about %v", n) + } + return + } + + if ir.IsAddressable(n) { + return + } + if n.Op() == ir.OINDEXMAP { + n := n.(*ir.IndexExpr) + n.Assigned = true + return + } + + defer n.SetType(nil) + + switch { + case n.Op() == ir.ODOT && n.(*ir.SelectorExpr).X.Op() == ir.OINDEXMAP: + base.Errorf("cannot assign to struct field %v in map", n) + case (n.Op() == ir.OINDEX && n.(*ir.IndexExpr).X.Type().IsString()) || n.Op() == ir.OSLICESTR: + base.Errorf("cannot assign to %v (strings are immutable)", n) + case n.Op() == ir.OLITERAL && n.Sym() != nil && ir.IsConstNode(n): + base.Errorf("cannot assign to %v (declared const)", n) + default: + base.Errorf("cannot assign to %v", n) + } +} + +func checkassignto(src *types.Type, dst ir.Node) { + // TODO(mdempsky): Handle all untyped types correctly. + if src == types.UntypedBool && dst.Type().IsBoolean() { + return + } + + if op, why := assignOp(src, dst.Type()); op == ir.OXXX { + base.Errorf("cannot assign %v to %L in multiple assignment%s", src, dst, why) + return + } +} + +// The result of stringtoruneslit MUST be assigned back to n, e.g. +// +// n.Left = stringtoruneslit(n.Left) +func stringtoruneslit(n *ir.ConvExpr) ir.Node { + if n.X.Op() != ir.OLITERAL || n.X.Val().Kind() != constant.String { + base.Fatalf("stringtoarraylit %v", n) + } + + var l []ir.Node + i := 0 + for _, r := range ir.StringVal(n.X) { + l = append(l, ir.NewKeyExpr(base.Pos, ir.NewInt(base.Pos, int64(i)), ir.NewInt(base.Pos, int64(r)))) + i++ + } + + return Expr(ir.NewCompLitExpr(base.Pos, ir.OCOMPLIT, n.Type(), l)) +} + +func checkmake(t *types.Type, arg string, np *ir.Node) bool { + n := *np + if !n.Type().IsInteger() && n.Type().Kind() != types.TIDEAL { + base.Errorf("non-integer %s argument in make(%v) - %v", arg, t, n.Type()) + return false + } + + // DefaultLit is necessary for non-constants too: n might be 1.1< algPriority[t.alg] { + t.alg = a + } else if a != t.alg && algPriority[a] == algPriority[t.alg] { + base.Fatalf("ambiguous priority %s and %s", a, t.alg) + } +} + +// AlgType returns the AlgKind used for comparing and hashing Type t. +func AlgType(t *Type) AlgKind { + CalcSize(t) + return t.alg +} + +// TypeHasNoAlg reports whether t does not have any associated hash/eq +// algorithms because t, or some component of t, is marked Noalg. +func TypeHasNoAlg(t *Type) bool { + return AlgType(t) == ANOALG +} + +// IsComparable reports whether t is a comparable type. +func IsComparable(t *Type) bool { + a := AlgType(t) + return a != ANOEQ && a != ANOALG +} + +// IncomparableField returns an incomparable Field of struct Type t, if any. +func IncomparableField(t *Type) *Field { + for _, f := range t.Fields() { + if !IsComparable(f.Type) { + return f + } + } + return nil +} + +// IsPaddedField reports whether the i'th field of struct type t is followed +// by padding. +func IsPaddedField(t *Type, i int) bool { + if !t.IsStruct() { + base.Fatalf("IsPaddedField called non-struct %v", t) + } + end := t.width + if i+1 < t.NumFields() { + end = t.Field(i + 1).Offset + } + return t.Field(i).End() != end +} diff --git a/go/src/cmd/compile/internal/types/algkind_string.go b/go/src/cmd/compile/internal/types/algkind_string.go new file mode 100644 index 0000000000000000000000000000000000000000..ca65a72c29acd4f4008d5f9c2ffdeaf3fcd14d02 --- /dev/null +++ b/go/src/cmd/compile/internal/types/algkind_string.go @@ -0,0 +1,40 @@ +// Code generated by "stringer -type AlgKind -trimprefix A alg.go"; DO NOT EDIT. + +package types + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[AUNK-0] + _ = x[ANOEQ-1] + _ = x[ANOALG-2] + _ = x[AMEM-3] + _ = x[AMEM0-4] + _ = x[AMEM8-5] + _ = x[AMEM16-6] + _ = x[AMEM32-7] + _ = x[AMEM64-8] + _ = x[AMEM128-9] + _ = x[ASTRING-10] + _ = x[AINTER-11] + _ = x[ANILINTER-12] + _ = x[AFLOAT32-13] + _ = x[AFLOAT64-14] + _ = x[ACPLX64-15] + _ = x[ACPLX128-16] + _ = x[ASPECIAL-17] +} + +const _AlgKind_name = "UNKNOEQNOALGMEMMEM0MEM8MEM16MEM32MEM64MEM128STRINGINTERNILINTERFLOAT32FLOAT64CPLX64CPLX128SPECIAL" + +var _AlgKind_index = [...]uint8{0, 3, 7, 12, 15, 19, 23, 28, 33, 38, 44, 50, 55, 63, 70, 77, 83, 90, 97} + +func (i AlgKind) String() string { + if i < 0 || i >= AlgKind(len(_AlgKind_index)-1) { + return "AlgKind(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _AlgKind_name[_AlgKind_index[i]:_AlgKind_index[i+1]] +} diff --git a/go/src/cmd/compile/internal/types/fmt.go b/go/src/cmd/compile/internal/types/fmt.go new file mode 100644 index 0000000000000000000000000000000000000000..848720ee89686abad1544588408cb846b09dea84 --- /dev/null +++ b/go/src/cmd/compile/internal/types/fmt.go @@ -0,0 +1,650 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +import ( + "bytes" + "encoding/binary" + "fmt" + "strconv" + "sync" + + "cmd/compile/internal/base" + "cmd/internal/hash" +) + +// BuiltinPkg is a fake package that declares the universe block. +var BuiltinPkg *Pkg + +// LocalPkg is the package being compiled. +var LocalPkg *Pkg + +// UnsafePkg is package unsafe. +var UnsafePkg *Pkg + +// BlankSym is the blank (_) symbol. +var BlankSym *Sym + +// numImport tracks how often a package with a given name is imported. +// It is used to provide a better error message (by using the package +// path to disambiguate) if a package that appears multiple times with +// the same name appears in an error message. +var NumImport = make(map[string]int) + +// fmtMode represents the kind of printing being done. +// The default is regular Go syntax (fmtGo). +// fmtDebug is like fmtGo but for debugging dumps and prints the type kind too. +// fmtTypeID and fmtTypeIDName are for generating various unique representations +// of types used in hashes, the linker, and function/method instantiations. +type fmtMode int + +const ( + fmtGo fmtMode = iota + fmtDebug + fmtTypeID + fmtTypeIDName +) + +// Sym + +// Format implements formatting for a Sym. +// The valid formats are: +// +// %v Go syntax: Name for symbols in the local package, PkgName.Name for imported symbols. +// %+v Debug syntax: always include PkgName. prefix even for local names. +// %S Short syntax: Name only, no matter what. +func (s *Sym) Format(f fmt.State, verb rune) { + mode := fmtGo + switch verb { + case 'v', 'S': + if verb == 'v' && f.Flag('+') { + mode = fmtDebug + } + fmt.Fprint(f, sconv(s, verb, mode)) + + default: + fmt.Fprintf(f, "%%!%c(*types.Sym=%p)", verb, s) + } +} + +func (s *Sym) String() string { + return sconv(s, 0, fmtGo) +} + +// See #16897 for details about performance implications +// before changing the implementation of sconv. +func sconv(s *Sym, verb rune, mode fmtMode) string { + if verb == 'L' { + panic("linksymfmt") + } + + if s == nil { + return "" + } + + q := pkgqual(s.Pkg, verb, mode) + if q == "" { + return s.Name + } + + buf := fmtBufferPool.Get().(*bytes.Buffer) + buf.Reset() + defer fmtBufferPool.Put(buf) + + buf.WriteString(q) + buf.WriteByte('.') + buf.WriteString(s.Name) + return InternString(buf.Bytes()) +} + +func sconv2(b *bytes.Buffer, s *Sym, verb rune, mode fmtMode) { + if verb == 'L' { + panic("linksymfmt") + } + if s == nil { + b.WriteString("") + return + } + + symfmt(b, s, verb, mode) +} + +func symfmt(b *bytes.Buffer, s *Sym, verb rune, mode fmtMode) { + name := s.Name + if q := pkgqual(s.Pkg, verb, mode); q != "" { + b.WriteString(q) + b.WriteByte('.') + } + b.WriteString(name) +} + +// pkgqual returns the qualifier that should be used for printing +// symbols from the given package in the given mode. +// If it returns the empty string, no qualification is needed. +func pkgqual(pkg *Pkg, verb rune, mode fmtMode) string { + if pkg == nil { + return "" + } + if verb != 'S' { + switch mode { + case fmtGo: // This is for the user + if pkg == BuiltinPkg || pkg == LocalPkg { + return "" + } + + // If the name was used by multiple packages, display the full path, + if pkg.Name != "" && NumImport[pkg.Name] > 1 { + return strconv.Quote(pkg.Path) + } + return pkg.Name + + case fmtDebug: + return pkg.Name + + case fmtTypeIDName: + // dcommontype, typehash + return pkg.Name + + case fmtTypeID: + // (methodsym), typesym, weaksym + return pkg.Prefix + } + } + + return "" +} + +// Type + +var BasicTypeNames = []string{ + TINT: "int", + TUINT: "uint", + TINT8: "int8", + TUINT8: "uint8", + TINT16: "int16", + TUINT16: "uint16", + TINT32: "int32", + TUINT32: "uint32", + TINT64: "int64", + TUINT64: "uint64", + TUINTPTR: "uintptr", + TFLOAT32: "float32", + TFLOAT64: "float64", + TCOMPLEX64: "complex64", + TCOMPLEX128: "complex128", + TBOOL: "bool", + TANY: "any", + TSTRING: "string", + TNIL: "nil", + TIDEAL: "untyped number", + TBLANK: "blank", +} + +var fmtBufferPool = sync.Pool{ + New: func() any { + return new(bytes.Buffer) + }, +} + +// Format implements formatting for a Type. +// The valid formats are: +// +// %v Go syntax +// %+v Debug syntax: Go syntax with a KIND- prefix for all but builtins. +// %L Go syntax for underlying type if t is named +// %S short Go syntax: drop leading "func" in function type +// %-S special case for method receiver symbol +func (t *Type) Format(s fmt.State, verb rune) { + mode := fmtGo + switch verb { + case 'v', 'S', 'L': + if verb == 'v' && s.Flag('+') { // %+v is debug format + mode = fmtDebug + } + if verb == 'S' && s.Flag('-') { // %-S is special case for receiver - short typeid format + mode = fmtTypeID + } + fmt.Fprint(s, tconv(t, verb, mode)) + default: + fmt.Fprintf(s, "%%!%c(*Type=%p)", verb, t) + } +} + +// String returns the Go syntax for the type t. +func (t *Type) String() string { + return tconv(t, 0, fmtGo) +} + +// LinkString returns a string description of t, suitable for use in +// link symbols. +// +// The description corresponds to type identity. That is, for any pair +// of types t1 and t2, Identical(t1, t2) == (t1.LinkString() == +// t2.LinkString()) is true. Thus it's safe to use as a map key to +// implement a type-identity-keyed map. +func (t *Type) LinkString() string { + return tconv(t, 0, fmtTypeID) +} + +// NameString generates a user-readable, mostly unique string +// description of t. NameString always returns the same description +// for identical types, even across compilation units. +// +// NameString qualifies identifiers by package name, so it has +// collisions when different packages share the same names and +// identifiers. It also does not distinguish function-scope defined +// types from package-scoped defined types or from each other. +func (t *Type) NameString() string { + return tconv(t, 0, fmtTypeIDName) +} + +func tconv(t *Type, verb rune, mode fmtMode) string { + buf := fmtBufferPool.Get().(*bytes.Buffer) + buf.Reset() + defer fmtBufferPool.Put(buf) + + tconv2(buf, t, verb, mode, nil) + return InternString(buf.Bytes()) +} + +// tconv2 writes a string representation of t to b. +// flag and mode control exactly what is printed. +// Any types x that are already in the visited map get printed as @%d where %d=visited[x]. +// See #16897 before changing the implementation of tconv. +func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type]int) { + if off, ok := visited[t]; ok { + // We've seen this type before, so we're trying to print it recursively. + // Print a reference to it instead. + fmt.Fprintf(b, "@%d", off) + return + } + if t == nil { + b.WriteString("") + return + } + if t.Kind() == TSSA { + b.WriteString(t.extra.(string)) + return + } + if t.Kind() == TTUPLE { + b.WriteString(t.FieldType(0).String()) + b.WriteByte(',') + b.WriteString(t.FieldType(1).String()) + return + } + + if t.Kind() == TRESULTS { + tys := t.extra.(*Results).Types + for i, et := range tys { + if i > 0 { + b.WriteByte(',') + } + b.WriteString(et.String()) + } + return + } + + if t == AnyType || t == ByteType || t == RuneType { + // in %-T mode collapse predeclared aliases with their originals. + switch mode { + case fmtTypeIDName, fmtTypeID: + t = Types[t.Kind()] + default: + sconv2(b, t.Sym(), 'S', mode) + return + } + } + if t == ErrorType { + b.WriteString("error") + return + } + + // Unless the 'L' flag was specified, if the type has a name, just print that name. + if verb != 'L' && t.Sym() != nil && t != Types[t.Kind()] { + // Default to 'v' if verb is invalid. + if verb != 'S' { + verb = 'v' + } + + // In unified IR, function-scope defined types will have a ·N + // suffix embedded directly in their Name. Trim this off for + // non-fmtTypeID modes. + sym := t.Sym() + if mode != fmtTypeID { + base, _ := SplitVargenSuffix(sym.Name) + if len(base) < len(sym.Name) { + sym = &Sym{Pkg: sym.Pkg, Name: base} + } + } + sconv2(b, sym, verb, mode) + return + } + + if int(t.Kind()) < len(BasicTypeNames) && BasicTypeNames[t.Kind()] != "" { + var name string + switch t { + case UntypedBool: + name = "untyped bool" + case UntypedString: + name = "untyped string" + case UntypedInt: + name = "untyped int" + case UntypedRune: + name = "untyped rune" + case UntypedFloat: + name = "untyped float" + case UntypedComplex: + name = "untyped complex" + default: + name = BasicTypeNames[t.Kind()] + } + b.WriteString(name) + return + } + + if mode == fmtDebug { + b.WriteString(t.Kind().String()) + b.WriteByte('-') + tconv2(b, t, 'v', fmtGo, visited) + return + } + + // At this point, we might call tconv2 recursively. Add the current type to the visited list so we don't + // try to print it recursively. + // We record the offset in the result buffer where the type's text starts. This offset serves as a reference + // point for any later references to the same type. + // Note that we remove the type from the visited map as soon as the recursive call is done. + // This prevents encoding types like map[*int]*int as map[*int]@4. (That encoding would work, + // but I'd like to use the @ notation only when strictly necessary.) + if visited == nil { + visited = map[*Type]int{} + } + visited[t] = b.Len() + defer delete(visited, t) + + switch t.Kind() { + case TPTR: + b.WriteByte('*') + switch mode { + case fmtTypeID, fmtTypeIDName: + if verb == 'S' { + tconv2(b, t.Elem(), 'S', mode, visited) + return + } + } + tconv2(b, t.Elem(), 'v', mode, visited) + + case TARRAY: + b.WriteByte('[') + b.WriteString(strconv.FormatInt(t.NumElem(), 10)) + b.WriteByte(']') + tconv2(b, t.Elem(), 0, mode, visited) + + case TSLICE: + b.WriteString("[]") + tconv2(b, t.Elem(), 0, mode, visited) + + case TCHAN: + switch t.ChanDir() { + case Crecv: + b.WriteString("<-chan ") + tconv2(b, t.Elem(), 0, mode, visited) + case Csend: + b.WriteString("chan<- ") + tconv2(b, t.Elem(), 0, mode, visited) + default: + b.WriteString("chan ") + if t.Elem() != nil && t.Elem().IsChan() && t.Elem().Sym() == nil && t.Elem().ChanDir() == Crecv { + b.WriteByte('(') + tconv2(b, t.Elem(), 0, mode, visited) + b.WriteByte(')') + } else { + tconv2(b, t.Elem(), 0, mode, visited) + } + } + + case TMAP: + b.WriteString("map[") + tconv2(b, t.Key(), 0, mode, visited) + b.WriteByte(']') + tconv2(b, t.Elem(), 0, mode, visited) + + case TINTER: + if t.IsEmptyInterface() { + b.WriteString("interface {}") + break + } + b.WriteString("interface {") + for i, f := range t.AllMethods() { + if i != 0 { + b.WriteByte(';') + } + b.WriteByte(' ') + switch { + case f.Sym == nil: + // Check first that a symbol is defined for this type. + // Wrong interface definitions may have types lacking a symbol. + break + case IsExported(f.Sym.Name): + sconv2(b, f.Sym, 'S', mode) + default: + if mode != fmtTypeIDName { + mode = fmtTypeID + } + sconv2(b, f.Sym, 'v', mode) + } + tconv2(b, f.Type, 'S', mode, visited) + } + if len(t.AllMethods()) != 0 { + b.WriteByte(' ') + } + b.WriteByte('}') + + case TFUNC: + if verb == 'S' { + // no leading func + } else { + if t.Recv() != nil { + b.WriteString("method") + formatParams(b, t.Recvs(), mode, visited) + b.WriteByte(' ') + } + b.WriteString("func") + } + formatParams(b, t.Params(), mode, visited) + + switch t.NumResults() { + case 0: + // nothing to do + + case 1: + b.WriteByte(' ') + tconv2(b, t.Result(0).Type, 0, mode, visited) // struct->field->field's type + + default: + b.WriteByte(' ') + formatParams(b, t.Results(), mode, visited) + } + + case TSTRUCT: + if m := t.StructType().Map; m != nil { + mt := m.MapType() + // Format the bucket struct for map[x]y as map.group[x]y. + // This avoids a recursive print that generates very long names. + switch t { + case mt.Group: + b.WriteString("map.group[") + default: + base.Fatalf("unknown internal map type") + } + tconv2(b, m.Key(), 0, mode, visited) + b.WriteByte(']') + tconv2(b, m.Elem(), 0, mode, visited) + break + } + + b.WriteString("struct {") + for i, f := range t.Fields() { + if i != 0 { + b.WriteByte(';') + } + b.WriteByte(' ') + fldconv(b, f, 'L', mode, visited, false) + } + if t.NumFields() != 0 { + b.WriteByte(' ') + } + b.WriteByte('}') + + case TFORW: + b.WriteString("undefined") + if t.Sym() != nil { + b.WriteByte(' ') + sconv2(b, t.Sym(), 'v', mode) + } + + case TUNSAFEPTR: + b.WriteString("unsafe.Pointer") + + case Txxx: + b.WriteString("Txxx") + + default: + // Don't know how to handle - fall back to detailed prints + b.WriteString(t.Kind().String()) + b.WriteString(" <") + sconv2(b, t.Sym(), 'v', mode) + b.WriteString(">") + + } +} + +func formatParams(b *bytes.Buffer, params []*Field, mode fmtMode, visited map[*Type]int) { + b.WriteByte('(') + fieldVerb := 'v' + switch mode { + case fmtTypeID, fmtTypeIDName, fmtGo: + // no argument names on function signature, and no "noescape"/"nosplit" tags + fieldVerb = 'S' + } + for i, param := range params { + if i != 0 { + b.WriteString(", ") + } + fldconv(b, param, fieldVerb, mode, visited, true) + } + b.WriteByte(')') +} + +func fldconv(b *bytes.Buffer, f *Field, verb rune, mode fmtMode, visited map[*Type]int, isParam bool) { + if f == nil { + b.WriteString("") + return + } + + var name string + nameSep := " " + if verb != 'S' { + s := f.Sym + + // Using type aliases and embedded fields, it's possible to + // construct types that can't be directly represented as a + // type literal. For example, given "type Int = int" (#50190), + // it would be incorrect to format "struct{ Int }" as either + // "struct{ int }" or "struct{ Int int }", because those each + // represent other, distinct types. + // + // So for the purpose of LinkString (i.e., fmtTypeID), we use + // the non-standard syntax "struct{ Int = int }" to represent + // embedded fields that have been renamed through the use of + // type aliases. + if f.Embedded != 0 { + if mode == fmtTypeID { + nameSep = " = " + + // Compute tsym, the symbol that would normally be used as + // the field name when embedding f.Type. + // TODO(mdempsky): Check for other occurrences of this logic + // and deduplicate. + typ := f.Type + if typ.IsPtr() { + base.Assertf(typ.Sym() == nil, "embedded pointer type has name: %L", typ) + typ = typ.Elem() + } + tsym := typ.Sym() + + // If the field name matches the embedded type's name, then + // suppress printing of the field name. For example, format + // "struct{ T }" as simply that instead of "struct{ T = T }". + if tsym != nil && (s == tsym || IsExported(tsym.Name) && s.Name == tsym.Name) { + s = nil + } + } else { + // Suppress the field name for embedded fields for + // non-LinkString formats, to match historical behavior. + // TODO(mdempsky): Re-evaluate this. + s = nil + } + } + + if s != nil { + if isParam { + name = fmt.Sprint(f.Nname) + } else if verb == 'L' { + name = s.Name + if !IsExported(name) && mode != fmtTypeIDName { + name = sconv(s, 0, mode) // qualify non-exported names (used on structs, not on funarg) + } + } else { + name = sconv(s, 0, mode) + } + } + } + + if name != "" { + b.WriteString(name) + b.WriteString(nameSep) + } + + if f.IsDDD() { + var et *Type + if f.Type != nil { + et = f.Type.Elem() + } + b.WriteString("...") + tconv2(b, et, 0, mode, visited) + } else { + tconv2(b, f.Type, 0, mode, visited) + } + + if verb != 'S' && !isParam && f.Note != "" { + b.WriteString(" ") + b.WriteString(strconv.Quote(f.Note)) + } +} + +// SplitVargenSuffix returns name split into a base string and a ·N +// suffix, if any. +func SplitVargenSuffix(name string) (base, suffix string) { + i := len(name) + for i > 0 && name[i-1] >= '0' && name[i-1] <= '9' { + i-- + } + const dot = "·" + if i >= len(dot) && name[i-len(dot):i] == dot { + i -= len(dot) + return name[:i], name[i:] + } + return name, "" +} + +// TypeHash computes a hash value for type t to use in type switch statements. +func TypeHash(t *Type) uint32 { + p := t.LinkString() + + // Using a cryptographic hash is overkill but minimizes accidental collisions. + h := hash.Sum32([]byte(p)) + return binary.LittleEndian.Uint32(h[:4]) +} diff --git a/go/src/cmd/compile/internal/types/goversion.go b/go/src/cmd/compile/internal/types/goversion.go new file mode 100644 index 0000000000000000000000000000000000000000..ac08a49d0cab7c928fd2761394eba89f08912b9e --- /dev/null +++ b/go/src/cmd/compile/internal/types/goversion.go @@ -0,0 +1,88 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +import ( + "fmt" + "internal/goversion" + "internal/lazyregexp" + "log" + "strconv" + + "cmd/compile/internal/base" +) + +// A lang is a language version broken into major and minor numbers. +type lang struct { + major, minor int +} + +// langWant is the desired language version set by the -lang flag. +// If the -lang flag is not set, this is the zero value, meaning that +// any language version is supported. +var langWant lang + +// AllowsGoVersion reports whether local package is allowed +// to use Go version major.minor. +func AllowsGoVersion(major, minor int) bool { + if langWant.major == 0 && langWant.minor == 0 { + return true + } + return langWant.major > major || (langWant.major == major && langWant.minor >= minor) +} + +// ParseLangFlag verifies that the -lang flag holds a valid value, and +// exits if not. It initializes data used by AllowsGoVersion. +func ParseLangFlag() { + if base.Flag.Lang == "" { + return + } + + var err error + langWant, err = parseLang(base.Flag.Lang) + if err != nil { + log.Fatalf("invalid value %q for -lang: %v", base.Flag.Lang, err) + } + + if def := currentLang(); base.Flag.Lang != def { + defVers, err := parseLang(def) + if err != nil { + log.Fatalf("internal error parsing default lang %q: %v", def, err) + } + if langWant.major > defVers.major || (langWant.major == defVers.major && langWant.minor > defVers.minor) { + log.Fatalf("invalid value %q for -lang: max known version is %q", base.Flag.Lang, def) + } + } +} + +// parseLang parses a -lang option into a langVer. +func parseLang(s string) (lang, error) { + if s == "go1" { // cmd/go's new spelling of "go1.0" (#65528) + s = "go1.0" + } + + matches := goVersionRE.FindStringSubmatch(s) + if matches == nil { + return lang{}, fmt.Errorf(`should be something like "go1.12"`) + } + major, err := strconv.Atoi(matches[1]) + if err != nil { + return lang{}, err + } + minor, err := strconv.Atoi(matches[2]) + if err != nil { + return lang{}, err + } + return lang{major: major, minor: minor}, nil +} + +// currentLang returns the current language version. +func currentLang() string { + return fmt.Sprintf("go1.%d", goversion.Version) +} + +// goVersionRE is a regular expression that matches the valid +// arguments to the -lang flag. +var goVersionRE = lazyregexp.New(`^go([1-9]\d*)\.(0|[1-9]\d*)$`) diff --git a/go/src/cmd/compile/internal/types/identity.go b/go/src/cmd/compile/internal/types/identity.go new file mode 100644 index 0000000000000000000000000000000000000000..fa28c038bddb97f06b9c7d5f0c93bda49ff91175 --- /dev/null +++ b/go/src/cmd/compile/internal/types/identity.go @@ -0,0 +1,157 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +const ( + identIgnoreTags = 1 << iota + identStrict +) + +// Identical reports whether t1 and t2 are identical types, following the spec rules. +// Receiver parameter types are ignored. Named (defined) types are only equal if they +// are pointer-equal - i.e. there must be a unique types.Type for each specific named +// type. Also, a type containing a shape type is considered identical to another type +// (shape or not) if their underlying types are the same, or they are both pointers. +func Identical(t1, t2 *Type) bool { + return identical(t1, t2, 0, nil) +} + +// IdenticalIgnoreTags is like Identical, but it ignores struct tags +// for struct identity. +func IdenticalIgnoreTags(t1, t2 *Type) bool { + return identical(t1, t2, identIgnoreTags, nil) +} + +// IdenticalStrict is like Identical, but matches types exactly, without the +// exception for shapes. +func IdenticalStrict(t1, t2 *Type) bool { + return identical(t1, t2, identStrict, nil) +} + +type typePair struct { + t1 *Type + t2 *Type +} + +func identical(t1, t2 *Type, flags int, assumedEqual map[typePair]struct{}) bool { + if t1 == t2 { + return true + } + if t1 == nil || t2 == nil || t1.kind != t2.kind { + return false + } + if t1.obj != nil || t2.obj != nil { + if flags&identStrict == 0 && (t1.HasShape() || t2.HasShape()) { + switch t1.kind { + case TINT8, TUINT8, TINT16, TUINT16, TINT32, TUINT32, TINT64, TUINT64, TINT, TUINT, TUINTPTR, TCOMPLEX64, TCOMPLEX128, TFLOAT32, TFLOAT64, TBOOL, TSTRING, TPTR, TUNSAFEPTR: + return true + } + // fall through to unnamed type comparison for complex types. + goto cont + } + // Special case: we keep byte/uint8 and rune/int32 + // separate for error messages. Treat them as equal. + switch t1.kind { + case TUINT8: + return (t1 == Types[TUINT8] || t1 == ByteType) && (t2 == Types[TUINT8] || t2 == ByteType) + case TINT32: + return (t1 == Types[TINT32] || t1 == RuneType) && (t2 == Types[TINT32] || t2 == RuneType) + case TINTER: + // Make sure named any type matches any unnamed empty interface + // (but not a shape type, if identStrict). + isUnnamedEface := func(t *Type) bool { return t.IsEmptyInterface() && t.Sym() == nil } + if flags&identStrict != 0 { + return t1 == AnyType && isUnnamedEface(t2) && !t2.HasShape() || t2 == AnyType && isUnnamedEface(t1) && !t1.HasShape() + } + return t1 == AnyType && isUnnamedEface(t2) || t2 == AnyType && isUnnamedEface(t1) + default: + return false + } + } +cont: + + // Any cyclic type must go through a named type, and if one is + // named, it is only identical to the other if they are the + // same pointer (t1 == t2), so there's no chance of chasing + // cycles ad infinitum, so no need for a depth counter. + if assumedEqual == nil { + assumedEqual = make(map[typePair]struct{}) + } else if _, ok := assumedEqual[typePair{t1, t2}]; ok { + return true + } + assumedEqual[typePair{t1, t2}] = struct{}{} + + switch t1.kind { + case TIDEAL: + // Historically, cmd/compile used a single "untyped + // number" type, so all untyped number types were + // identical. Match this behavior. + // TODO(mdempsky): Revisit this. + return true + + case TINTER: + if len(t1.AllMethods()) != len(t2.AllMethods()) { + return false + } + for i, f1 := range t1.AllMethods() { + f2 := t2.AllMethods()[i] + if f1.Sym != f2.Sym || !identical(f1.Type, f2.Type, flags, assumedEqual) { + return false + } + } + return true + + case TSTRUCT: + if t1.NumFields() != t2.NumFields() { + return false + } + for i, f1 := range t1.Fields() { + f2 := t2.Field(i) + if f1.Sym != f2.Sym || f1.Embedded != f2.Embedded || !identical(f1.Type, f2.Type, flags, assumedEqual) { + return false + } + if (flags&identIgnoreTags) == 0 && f1.Note != f2.Note { + return false + } + } + return true + + case TFUNC: + // Check parameters and result parameters for type equality. + // We intentionally ignore receiver parameters for type + // equality, because they're never relevant. + if t1.NumParams() != t2.NumParams() || + t1.NumResults() != t2.NumResults() || + t1.IsVariadic() != t2.IsVariadic() { + return false + } + + fs1 := t1.ParamsResults() + fs2 := t2.ParamsResults() + for i, f1 := range fs1 { + if !identical(f1.Type, fs2[i].Type, flags, assumedEqual) { + return false + } + } + return true + + case TARRAY: + if t1.NumElem() != t2.NumElem() { + return false + } + + case TCHAN: + if t1.ChanDir() != t2.ChanDir() { + return false + } + + case TMAP: + if !identical(t1.Key(), t2.Key(), flags, assumedEqual) { + return false + } + } + + return identical(t1.Elem(), t2.Elem(), flags, assumedEqual) +} diff --git a/go/src/cmd/compile/internal/types/kind_string.go b/go/src/cmd/compile/internal/types/kind_string.go new file mode 100644 index 0000000000000000000000000000000000000000..1e1e84624080b08e614821c3e936c5c58daa4f01 --- /dev/null +++ b/go/src/cmd/compile/internal/types/kind_string.go @@ -0,0 +1,60 @@ +// Code generated by "stringer -type Kind -trimprefix T type.go"; DO NOT EDIT. + +package types + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Txxx-0] + _ = x[TINT8-1] + _ = x[TUINT8-2] + _ = x[TINT16-3] + _ = x[TUINT16-4] + _ = x[TINT32-5] + _ = x[TUINT32-6] + _ = x[TINT64-7] + _ = x[TUINT64-8] + _ = x[TINT-9] + _ = x[TUINT-10] + _ = x[TUINTPTR-11] + _ = x[TCOMPLEX64-12] + _ = x[TCOMPLEX128-13] + _ = x[TFLOAT32-14] + _ = x[TFLOAT64-15] + _ = x[TBOOL-16] + _ = x[TPTR-17] + _ = x[TFUNC-18] + _ = x[TSLICE-19] + _ = x[TARRAY-20] + _ = x[TSTRUCT-21] + _ = x[TCHAN-22] + _ = x[TMAP-23] + _ = x[TINTER-24] + _ = x[TFORW-25] + _ = x[TANY-26] + _ = x[TSTRING-27] + _ = x[TUNSAFEPTR-28] + _ = x[TIDEAL-29] + _ = x[TNIL-30] + _ = x[TBLANK-31] + _ = x[TFUNCARGS-32] + _ = x[TCHANARGS-33] + _ = x[TSSA-34] + _ = x[TTUPLE-35] + _ = x[TRESULTS-36] + _ = x[NTYPE-37] +} + +const _Kind_name = "xxxINT8UINT8INT16UINT16INT32UINT32INT64UINT64INTUINTUINTPTRCOMPLEX64COMPLEX128FLOAT32FLOAT64BOOLPTRFUNCSLICEARRAYSTRUCTCHANMAPINTERFORWANYSTRINGUNSAFEPTRIDEALNILBLANKFUNCARGSCHANARGSSSATUPLERESULTSNTYPE" + +var _Kind_index = [...]uint8{0, 3, 7, 12, 17, 23, 28, 34, 39, 45, 48, 52, 59, 68, 78, 85, 92, 96, 99, 103, 108, 113, 119, 123, 126, 131, 135, 138, 144, 153, 158, 161, 166, 174, 182, 185, 190, 197, 202} + +func (i Kind) String() string { + if i >= Kind(len(_Kind_index)-1) { + return "Kind(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _Kind_name[_Kind_index[i]:_Kind_index[i+1]] +} diff --git a/go/src/cmd/compile/internal/types/pkg.go b/go/src/cmd/compile/internal/types/pkg.go new file mode 100644 index 0000000000000000000000000000000000000000..9f64b84db4566c349a24f6eb5d8483ad9a6f80d0 --- /dev/null +++ b/go/src/cmd/compile/internal/types/pkg.go @@ -0,0 +1,131 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +import ( + "cmd/internal/obj" + "cmd/internal/objabi" + "fmt" + "strconv" + "sync" +) + +// pkgMap maps a package path to a package. +var pkgMap = make(map[string]*Pkg) + +type Pkg struct { + Path string // string literal used in import statement, e.g. "internal/runtime/sys" + Name string // package name, e.g. "sys" + Prefix string // escaped path for use in symbol table + Syms map[string]*Sym + Pathsym *obj.LSym + + Direct bool // imported directly +} + +// NewPkg returns a new Pkg for the given package path and name. +// Unless name is the empty string, if the package exists already, +// the existing package name and the provided name must match. +func NewPkg(path, name string) *Pkg { + if p := pkgMap[path]; p != nil { + if name != "" && p.Name != name { + panic(fmt.Sprintf("conflicting package names %s and %s for path %q", p.Name, name, path)) + } + return p + } + + p := new(Pkg) + p.Path = path + p.Name = name + if path == "go.shape" { + // Don't escape "go.shape", since it's not needed (it's a builtin + // package), and we don't want escape codes showing up in shape type + // names, which also appear in names of function/method + // instantiations. + p.Prefix = path + } else { + p.Prefix = objabi.PathToPrefix(path) + } + p.Syms = make(map[string]*Sym) + pkgMap[path] = p + + return p +} + +func PkgMap() map[string]*Pkg { + return pkgMap +} + +var nopkg = &Pkg{ + Syms: make(map[string]*Sym), +} + +func (pkg *Pkg) Lookup(name string) *Sym { + s, _ := pkg.LookupOK(name) + return s +} + +// LookupOK looks up name in pkg and reports whether it previously existed. +func (pkg *Pkg) LookupOK(name string) (s *Sym, existed bool) { + // TODO(gri) remove this check in favor of specialized lookup + if pkg == nil { + pkg = nopkg + } + if s := pkg.Syms[name]; s != nil { + return s, true + } + + s = &Sym{ + Name: name, + Pkg: pkg, + } + pkg.Syms[name] = s + return s, false +} + +func (pkg *Pkg) LookupBytes(name []byte) *Sym { + // TODO(gri) remove this check in favor of specialized lookup + if pkg == nil { + pkg = nopkg + } + if s := pkg.Syms[string(name)]; s != nil { + return s + } + str := InternString(name) + return pkg.Lookup(str) +} + +// LookupNum looks up the symbol starting with prefix and ending with +// the decimal n. If prefix is too long, LookupNum panics. +func (pkg *Pkg) LookupNum(prefix string, n int) *Sym { + var buf [20]byte // plenty long enough for all current users + copy(buf[:], prefix) + b := strconv.AppendInt(buf[:len(prefix)], int64(n), 10) + return pkg.LookupBytes(b) +} + +// Selector looks up a selector identifier. +func (pkg *Pkg) Selector(name string) *Sym { + if IsExported(name) { + pkg = LocalPkg + } + return pkg.Lookup(name) +} + +var ( + internedStringsmu sync.Mutex // protects internedStrings + internedStrings = map[string]string{} +) + +func InternString(b []byte) string { + internedStringsmu.Lock() + s, ok := internedStrings[string(b)] // string(b) here doesn't allocate + if !ok { + s = string(b) + internedStrings[s] = s + } + internedStringsmu.Unlock() + return s +} diff --git a/go/src/cmd/compile/internal/types/size.go b/go/src/cmd/compile/internal/types/size.go new file mode 100644 index 0000000000000000000000000000000000000000..1acb041e357ad7546bb55f8b269b30bc0d3383e2 --- /dev/null +++ b/go/src/cmd/compile/internal/types/size.go @@ -0,0 +1,721 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +import ( + "math" + "slices" + + "cmd/compile/internal/base" + "cmd/internal/src" + "internal/buildcfg" + "internal/types/errors" +) + +var PtrSize int + +var RegSize int + +// Slices in the runtime are represented by three components: +// +// type slice struct { +// ptr unsafe.Pointer +// len int +// cap int +// } +// +// Strings in the runtime are represented by two components: +// +// type string struct { +// ptr unsafe.Pointer +// len int +// } +// +// These variables are the offsets of fields and sizes of these structs. +var ( + SlicePtrOffset int64 + SliceLenOffset int64 + SliceCapOffset int64 + + SliceSize int64 + StringSize int64 +) + +var SkipSizeForTracing bool + +// typePos returns the position associated with t. +// This is where t was declared or where it appeared as a type expression. +func typePos(t *Type) src.XPos { + if pos := t.Pos(); pos.IsKnown() { + return pos + } + base.Fatalf("bad type: %v", t) + panic("unreachable") +} + +// MaxWidth is the maximum size of a value on the target architecture. +var MaxWidth int64 + +// CalcSizeDisabled indicates whether it is safe +// to calculate Types' widths and alignments. See CalcSize. +var CalcSizeDisabled bool + +// machine size and rounding alignment is dictated around +// the size of a pointer, set in gc.Main (see ../gc/main.go). +var defercalc int + +// RoundUp rounds o to a multiple of r, r is a power of 2. +func RoundUp(o int64, r int64) int64 { + if r < 1 || r > 8 || r&(r-1) != 0 { + base.Fatalf("Round %d", r) + } + return (o + r - 1) &^ (r - 1) +} + +// expandiface computes the method set for interface type t by +// expanding embedded interfaces. +func expandiface(t *Type) { + seen := make(map[*Sym]*Field) + var methods []*Field + + addMethod := func(m *Field, explicit bool) { + switch prev := seen[m.Sym]; { + case prev == nil: + seen[m.Sym] = m + case !explicit && Identical(m.Type, prev.Type): + return + default: + base.ErrorfAt(m.Pos, errors.DuplicateDecl, "duplicate method %s", m.Sym.Name) + } + methods = append(methods, m) + } + + { + methods := t.Methods() + slices.SortStableFunc(methods, func(a, b *Field) int { + // Sort embedded types by type name (if any). + if a.Sym == nil && b.Sym == nil { + return CompareSyms(a.Type.Sym(), b.Type.Sym()) + } + + // Sort methods before embedded types. + if a.Sym == nil { + return -1 + } else if b.Sym == nil { + return +1 + } + + // Sort methods by symbol name. + return CompareSyms(a.Sym, b.Sym) + }) + } + + for _, m := range t.Methods() { + if m.Sym == nil { + continue + } + + CheckSize(m.Type) + addMethod(m, true) + } + + for _, m := range t.Methods() { + if m.Sym != nil || m.Type == nil { + continue + } + + // In 1.18, embedded types can be anything. In Go 1.17, we disallow + // embedding anything other than interfaces. This requirement was caught + // by types2 already, so allow non-interface here. + if !m.Type.IsInterface() { + continue + } + + // Embedded interface: duplicate all methods + // and add to t's method set. + for _, t1 := range m.Type.AllMethods() { + f := NewField(m.Pos, t1.Sym, t1.Type) + addMethod(f, false) + + // Clear position after typechecking, for consistency with types2. + f.Pos = src.NoXPos + } + + // Clear position after typechecking, for consistency with types2. + m.Pos = src.NoXPos + } + + slices.SortFunc(methods, CompareFields) + + if int64(len(methods)) >= MaxWidth/int64(PtrSize) { + base.ErrorfAt(typePos(t), 0, "interface too large") + } + for i, m := range methods { + m.Offset = int64(i) * int64(PtrSize) + } + + t.SetAllMethods(methods) +} + +// calcStructOffset computes the offsets of a sequence of fields, +// starting at the given offset. It returns the resulting offset and +// maximum field alignment. +func calcStructOffset(t *Type, fields []*Field, offset int64) int64 { + for _, f := range fields { + CalcSize(f.Type) + offset = RoundUp(offset, int64(f.Type.align)) + + if t.IsStruct() { // param offsets depend on ABI + f.Offset = offset + + // If type T contains a field F marked as not-in-heap, + // then T must also be a not-in-heap type. Otherwise, + // you could heap allocate T and then get a pointer F, + // which would be a heap pointer to a not-in-heap type. + if f.Type.NotInHeap() { + t.SetNotInHeap(true) + } + } + + offset += f.Type.width + + maxwidth := MaxWidth + // On 32-bit systems, reflect tables impose an additional constraint + // that each field start offset must fit in 31 bits. + if maxwidth < 1<<32 { + maxwidth = 1<<31 - 1 + } + if offset >= maxwidth { + base.ErrorfAt(typePos(t), 0, "type %L too large", t) + offset = 8 // small but nonzero + } + } + + return offset +} + +func isAtomicStdPkg(p *Pkg) bool { + if p.Prefix == `""` { + panic("bad package prefix") + } + return p.Prefix == "sync/atomic" || p.Prefix == "internal/runtime/atomic" +} + +// CalcSize calculates and stores the size, alignment, eq/hash algorithm, +// and ptrBytes for t. +// If CalcSizeDisabled is set, and the size/alignment +// have not already been calculated, it calls Fatal. +// This is used to prevent data races in the back end. +func CalcSize(t *Type) { + // Calling CalcSize when typecheck tracing enabled is not safe. + // See issue #33658. + if base.EnableTrace && SkipSizeForTracing { + return + } + if PtrSize == 0 { + // Assume this is a test. + return + } + + if t == nil { + return + } + + if t.width == -2 { + t.width = 0 + t.align = 1 + base.Fatalf("invalid recursive type %v", t) + return + } + + if t.widthCalculated() { + return + } + + if CalcSizeDisabled { + base.Fatalf("width not calculated: %v", t) + } + + // defer CheckSize calls until after we're done + DeferCheckSize() + + lno := base.Pos + if pos := t.Pos(); pos.IsKnown() { + base.Pos = pos + } + + t.width = -2 + t.align = 0 // 0 means use t.Width, below + t.alg = AMEM // default + // default t.ptrBytes is 0. + if t.Noalg() { + t.setAlg(ANOALG) + } + + et := t.Kind() + switch et { + case TFUNC, TCHAN, TMAP, TSTRING: + break + + // SimType == 0 during bootstrap + default: + if SimType[t.Kind()] != 0 { + et = SimType[t.Kind()] + } + } + + var w int64 + switch et { + default: + base.Fatalf("CalcSize: unknown type: %v", t) + + // compiler-specific stuff + case TINT8, TUINT8, TBOOL: + // bool is int8 + w = 1 + t.intRegs = 1 + + case TINT16, TUINT16: + w = 2 + t.intRegs = 1 + + case TINT32, TUINT32: + w = 4 + t.intRegs = 1 + + case TINT64, TUINT64: + w = 8 + t.align = uint8(RegSize) + t.intRegs = uint8(8 / RegSize) + + case TFLOAT32: + w = 4 + t.floatRegs = 1 + t.setAlg(AFLOAT32) + + case TFLOAT64: + w = 8 + t.align = uint8(RegSize) + t.floatRegs = 1 + t.setAlg(AFLOAT64) + + case TCOMPLEX64: + w = 8 + t.align = 4 + t.floatRegs = 2 + t.setAlg(ACPLX64) + + case TCOMPLEX128: + w = 16 + t.align = uint8(RegSize) + t.floatRegs = 2 + t.setAlg(ACPLX128) + + case TPTR: + w = int64(PtrSize) + t.intRegs = 1 + CheckSize(t.Elem()) + t.ptrBytes = int64(PtrSize) // See PtrDataSize + + case TUNSAFEPTR: + w = int64(PtrSize) + t.intRegs = 1 + t.ptrBytes = int64(PtrSize) + + case TINTER: // implemented as 2 pointers + w = 2 * int64(PtrSize) + t.align = uint8(PtrSize) + t.intRegs = 2 + expandiface(t) + if len(t.allMethods.Slice()) == 0 { + t.setAlg(ANILINTER) + } else { + t.setAlg(AINTER) + } + t.ptrBytes = int64(2 * PtrSize) + + case TCHAN: // implemented as pointer + w = int64(PtrSize) + t.intRegs = 1 + t.ptrBytes = int64(PtrSize) + + CheckSize(t.Elem()) + + // Make fake type to trigger channel element size check after + // any top-level recursive type has been completed. + t1 := NewChanArgs(t) + CheckSize(t1) + + case TCHANARGS: + t1 := t.ChanArgs() + CalcSize(t1) // just in case + // Make sure size of t1.Elem() is calculated at this point. We can + // use CalcSize() here rather than CheckSize(), because the top-level + // (possibly recursive) type will have been calculated before the fake + // chanargs is handled. + CalcSize(t1.Elem()) + if t1.Elem().width >= 1<<16 { + base.Errorf("channel element type too large (>64kB)") + } + w = 1 // anything will do + + case TMAP: // implemented as pointer + w = int64(PtrSize) + t.intRegs = 1 + CheckSize(t.Elem()) + CheckSize(t.Key()) + t.setAlg(ANOEQ) + t.ptrBytes = int64(PtrSize) + + case TFORW: // should have been filled in + base.Fatalf("invalid recursive type %v", t) + + case TANY: // not a real type; should be replaced before use. + base.Fatalf("CalcSize any") + + case TSTRING: + if StringSize == 0 { + base.Fatalf("early CalcSize string") + } + w = StringSize + t.align = uint8(PtrSize) + t.intRegs = 2 + t.setAlg(ASTRING) + t.ptrBytes = int64(PtrSize) + + case TARRAY: + if t.Elem() == nil { + break + } + CalcArraySize(t) + w = t.width + + case TSLICE: + if t.Elem() == nil { + break + } + w = SliceSize + CheckSize(t.Elem()) + t.align = uint8(PtrSize) + t.intRegs = 3 + t.setAlg(ANOEQ) + if !t.Elem().NotInHeap() { + t.ptrBytes = int64(PtrSize) + } + + case TSTRUCT: + if t.IsFuncArgStruct() { + base.Fatalf("CalcSize fn struct %v", t) + } + CalcStructSize(t) + w = t.width + + // make fake type to check later to + // trigger function argument computation. + case TFUNC: + t1 := NewFuncArgs(t) + CheckSize(t1) + w = int64(PtrSize) // width of func type is pointer + t.intRegs = 1 + t.setAlg(ANOEQ) + t.ptrBytes = int64(PtrSize) + + // function is 3 cated structures; + // compute their widths as side-effect. + case TFUNCARGS: + t1 := t.FuncArgs() + // TODO(mdempsky): Should package abi be responsible for computing argwid? + w = calcStructOffset(t1, t1.Recvs(), 0) + w = calcStructOffset(t1, t1.Params(), w) + w = RoundUp(w, int64(RegSize)) + w = calcStructOffset(t1, t1.Results(), w) + w = RoundUp(w, int64(RegSize)) + t1.extra.(*Func).Argwid = w + t.align = 1 + } + + if PtrSize == 4 && w != int64(int32(w)) { + base.Errorf("type %v too large", t) + } + + t.width = w + if t.align == 0 { + if w == 0 || w > 8 || w&(w-1) != 0 { + base.Fatalf("invalid alignment for %v", t) + } + t.align = uint8(w) + } + + base.Pos = lno + + ResumeCheckSize() +} + +// simdify marks as type as "SIMD", either as a tag field, +// or having the SIMD attribute. The tag field is a marker +// type used to identify a struct that is not really a struct. +// A SIMD type is allocated to a vector register (on amd64, +// xmm, ymm, or zmm). The fields of a SIMD type are ignored +// by the compiler except for the space that they reserve. +func simdify(st *Type, isTag bool) { + st.align = 8 + st.alg = ANOALG // not comparable with == + st.intRegs = 0 + st.isSIMD = true + if isTag { + st.width = 0 + st.isSIMDTag = true + st.floatRegs = 0 + } else { + st.floatRegs = 1 + } +} + +// CalcStructSize calculates the size of t, +// filling in t.width, t.align, t.intRegs, and t.floatRegs, +// even if size calculation is otherwise disabled. +func CalcStructSize(t *Type) { + var maxAlign uint8 = 1 + + // Recognize special types. This logic is duplicated in go/types and + // cmd/compile/internal/types2. + if sym := t.Sym(); sym != nil { + switch { + case sym.Name == "align64" && isAtomicStdPkg(sym.Pkg): + maxAlign = 8 + + case buildcfg.Experiment.SIMD && (sym.Pkg.Path == "simd/archsimd") && len(t.Fields()) >= 1: + // This gates the experiment -- without it, no user-visible types can be "simd". + // The SSA-visible SIMD types remain. + switch sym.Name { + case "v128": + simdify(t, true) + return + case "v256": + simdify(t, true) + return + case "v512": + simdify(t, true) + return + } + } + } + + fields := t.Fields() + + size := calcStructOffset(t, fields, 0) + + // For non-zero-sized structs which end in a zero-sized field, we + // add an extra byte of padding to the type. This padding ensures + // that taking the address of a zero-sized field can't manufacture a + // pointer to the next object in the heap. See issue 9401. + if size > 0 && fields[len(fields)-1].Type.width == 0 { + size++ + } + + var intRegs, floatRegs uint64 + for _, field := range fields { + typ := field.Type + + // The alignment of a struct type is the maximum alignment of its + // field types. + if align := typ.align; align > maxAlign { + maxAlign = align + } + + // Each field needs its own registers. + // We sum in uint64 to avoid possible overflows. + intRegs += uint64(typ.intRegs) + floatRegs += uint64(typ.floatRegs) + } + + // Final size includes trailing padding. + size = RoundUp(size, int64(maxAlign)) + + if intRegs > math.MaxUint8 || floatRegs > math.MaxUint8 { + intRegs = math.MaxUint8 + floatRegs = math.MaxUint8 + } + + t.width = size + t.align = maxAlign + t.intRegs = uint8(intRegs) + t.floatRegs = uint8(floatRegs) + + // Compute eq/hash algorithm type. + t.alg = AMEM // default + if t.Noalg() { + t.setAlg(ANOALG) + } + if len(fields) == 1 && !fields[0].Sym.IsBlank() { + // One-field struct is same as that one field alone. + t.setAlg(fields[0].Type.alg) + } else { + for i, f := range fields { + a := f.Type.alg + switch a { + case ANOEQ, ANOALG: + case AMEM: + // Blank fields and padded fields need a special compare. + if f.Sym.IsBlank() || IsPaddedField(t, i) { + a = ASPECIAL + } + default: + // Fields with non-memory equality need a special compare. + a = ASPECIAL + } + t.setAlg(a) + } + } + // Compute ptrBytes. + for i := len(fields) - 1; i >= 0; i-- { + f := fields[i] + if size := PtrDataSize(f.Type); size > 0 { + t.ptrBytes = f.Offset + size + break + } + } + + if len(t.Fields()) >= 1 && t.Fields()[0].Type.isSIMDTag { + // this catches `type Foo simd.Whatever` -- Foo is also SIMD. + simdify(t, false) + } +} + +// CalcArraySize calculates the size of t, +// filling in t.width, t.align, t.alg, and t.ptrBytes, +// even if size calculation is otherwise disabled. +func CalcArraySize(t *Type) { + elem := t.Elem() + n := t.NumElem() + CalcSize(elem) + t.SetNotInHeap(elem.NotInHeap()) + if elem.width != 0 { + cap := (uint64(MaxWidth) - 1) / uint64(elem.width) + if uint64(n) > cap { + base.Errorf("type %L larger than address space", t) + } + } + + t.width = elem.width * n + t.align = elem.align + // ABIInternal only allows "trivial" arrays (i.e., length 0 or 1) + // to be passed by register. + switch n { + case 0: + t.intRegs = 0 + t.floatRegs = 0 + case 1: + t.intRegs = elem.intRegs + t.floatRegs = elem.floatRegs + default: + t.intRegs = math.MaxUint8 + t.floatRegs = math.MaxUint8 + } + t.alg = AMEM // default + if t.Noalg() { + t.setAlg(ANOALG) + } + switch a := elem.alg; a { + case AMEM, ANOEQ, ANOALG: + t.setAlg(a) + default: + switch n { + case 0: + // We checked above that the element type is comparable. + t.setAlg(AMEM) + case 1: + // Single-element array is same as its lone element. + t.setAlg(a) + default: + t.setAlg(ASPECIAL) + } + } + if n > 0 { + x := PtrDataSize(elem) + if x > 0 { + t.ptrBytes = elem.width*(n-1) + x + } + } +} + +func (t *Type) widthCalculated() bool { + return t.align > 0 +} + +// when a type's width should be known, we call CheckSize +// to compute it. during a declaration like +// +// type T *struct { next T } +// +// it is necessary to defer the calculation of the struct width +// until after T has been initialized to be a pointer to that struct. +// similarly, during import processing structs may be used +// before their definition. in those situations, calling +// DeferCheckSize() stops width calculations until +// ResumeCheckSize() is called, at which point all the +// CalcSizes that were deferred are executed. +// CalcSize should only be called when the type's size +// is needed immediately. CheckSize makes sure the +// size is evaluated eventually. + +var deferredTypeStack []*Type + +func CheckSize(t *Type) { + if t == nil { + return + } + + // function arg structs should not be checked + // outside of the enclosing function. + if t.IsFuncArgStruct() { + base.Fatalf("CheckSize %v", t) + } + + if defercalc == 0 { + CalcSize(t) + return + } + + // if type has not yet been pushed on deferredTypeStack yet, do it now + if !t.Deferwidth() { + t.SetDeferwidth(true) + deferredTypeStack = append(deferredTypeStack, t) + } +} + +func DeferCheckSize() { + defercalc++ +} + +func ResumeCheckSize() { + if defercalc == 1 { + for len(deferredTypeStack) > 0 { + t := deferredTypeStack[len(deferredTypeStack)-1] + deferredTypeStack = deferredTypeStack[:len(deferredTypeStack)-1] + t.SetDeferwidth(false) + CalcSize(t) + } + } + + defercalc-- +} + +// PtrDataSize returns the length in bytes of the prefix of t +// containing pointer data. Anything after this offset is scalar data. +// +// PtrDataSize is only defined for actual Go types. It's an error to +// use it on compiler-internal types (e.g., TSSA, TRESULTS). +func PtrDataSize(t *Type) int64 { + CalcSize(t) + x := t.ptrBytes + if t.Kind() == TPTR && t.Elem().NotInHeap() { + // Note: this is done here instead of when we're setting + // the ptrBytes field, because at that time (in NewPtr, usually) + // the NotInHeap bit of the element type might not be set yet. + x = 0 + } + return x +} diff --git a/go/src/cmd/compile/internal/types/sizeof_test.go b/go/src/cmd/compile/internal/types/sizeof_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1b80659c8edb0ba6212144bf76b6c55cc34c6638 --- /dev/null +++ b/go/src/cmd/compile/internal/types/sizeof_test.go @@ -0,0 +1,48 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +import ( + "reflect" + "testing" + "unsafe" +) + +// Assert that the size of important structures do not change unexpectedly. + +func TestSizeof(t *testing.T) { + const _64bit = unsafe.Sizeof(uintptr(0)) == 8 + + var tests = []struct { + val any // type as a value + _32bit uintptr // size on 32bit platforms + _64bit uintptr // size on 64bit platforms + }{ + {Sym{}, 32, 64}, + {Type{}, 60, 96}, + {Map{}, 12, 24}, + {Forward{}, 20, 32}, + {Func{}, 32, 56}, + {Struct{}, 12, 24}, + {Interface{}, 0, 0}, + {Chan{}, 8, 16}, + {Array{}, 12, 16}, + {FuncArgs{}, 4, 8}, + {ChanArgs{}, 4, 8}, + {Ptr{}, 4, 8}, + {Slice{}, 4, 8}, + } + + for _, tt := range tests { + want := tt._32bit + if _64bit { + want = tt._64bit + } + got := reflect.TypeOf(tt.val).Size() + if want != got { + t.Errorf("unsafe.Sizeof(%T) = %d, want %d", tt.val, got, want) + } + } +} diff --git a/go/src/cmd/compile/internal/types/sym.go b/go/src/cmd/compile/internal/types/sym.go new file mode 100644 index 0000000000000000000000000000000000000000..97175d745c1f5b331741f2946497b97c0887827f --- /dev/null +++ b/go/src/cmd/compile/internal/types/sym.go @@ -0,0 +1,143 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +import ( + "cmd/compile/internal/base" + "cmd/internal/obj" + "strings" + "unicode" + "unicode/utf8" +) + +// Sym represents an object name in a segmented (pkg, name) namespace. +// Most commonly, this is a Go identifier naming an object declared within a package, +// but Syms are also used to name internal synthesized objects. +// +// As an exception, field and method names that are exported use the Sym +// associated with localpkg instead of the package that declared them. This +// allows using Sym pointer equality to test for Go identifier uniqueness when +// handling selector expressions. +// +// Ideally, Sym should be used for representing Go language constructs, +// while cmd/internal/obj.LSym is used for representing emitted artifacts. +// +// NOTE: In practice, things can be messier than the description above +// for various reasons (historical, convenience). +type Sym struct { + Linkname string // link name + + Pkg *Pkg + Name string // object name + + // The unique ONAME, OTYPE, OPACK, or OLITERAL node that this symbol is + // bound to within the current scope. (Most parts of the compiler should + // prefer passing the Node directly, rather than relying on this field.) + // + // Deprecated: New code should avoid depending on Sym.Def. Add + // mdempsky@ as a reviewer for any CLs involving Sym.Def. + Def Object + + flags bitset8 +} + +const ( + symOnExportList = 1 << iota // added to exportlist (no need to add again) + symUniq + symSiggen // type symbol has been generated + symAsm // on asmlist, for writing to -asmhdr + symFunc // function symbol +) + +func (sym *Sym) OnExportList() bool { return sym.flags&symOnExportList != 0 } +func (sym *Sym) Uniq() bool { return sym.flags&symUniq != 0 } +func (sym *Sym) Siggen() bool { return sym.flags&symSiggen != 0 } +func (sym *Sym) Asm() bool { return sym.flags&symAsm != 0 } +func (sym *Sym) Func() bool { return sym.flags&symFunc != 0 } + +func (sym *Sym) SetOnExportList(b bool) { sym.flags.set(symOnExportList, b) } +func (sym *Sym) SetUniq(b bool) { sym.flags.set(symUniq, b) } +func (sym *Sym) SetSiggen(b bool) { sym.flags.set(symSiggen, b) } +func (sym *Sym) SetAsm(b bool) { sym.flags.set(symAsm, b) } +func (sym *Sym) SetFunc(b bool) { sym.flags.set(symFunc, b) } + +func (sym *Sym) IsBlank() bool { + return sym != nil && sym.Name == "_" +} + +// Deprecated: This method should not be used directly. Instead, use a +// higher-level abstraction that directly returns the linker symbol +// for a named object. For example, reflectdata.TypeLinksym(t) instead +// of reflectdata.TypeSym(t).Linksym(). +func (sym *Sym) Linksym() *obj.LSym { + abi := obj.ABI0 + if sym.Func() { + abi = obj.ABIInternal + } + return sym.LinksymABI(abi) +} + +// Deprecated: This method should not be used directly. Instead, use a +// higher-level abstraction that directly returns the linker symbol +// for a named object. For example, (*ir.Name).LinksymABI(abi) instead +// of (*ir.Name).Sym().LinksymABI(abi). +func (sym *Sym) LinksymABI(abi obj.ABI) *obj.LSym { + if sym == nil { + base.Fatalf("nil symbol") + } + if sym.Linkname != "" { + return base.Linkname(sym.Linkname, abi) + } + return base.PkgLinksym(sym.Pkg.Prefix, sym.Name, abi) +} + +// CompareSyms return the ordering of a and b, as for [cmp.Compare]. +// +// Symbols are ordered exported before non-exported, then by name, and +// finally (for non-exported symbols) by package path. +func CompareSyms(a, b *Sym) int { + if a == b { + return 0 + } + + // Nil before non-nil. + if a == nil { + return -1 + } + if b == nil { + return +1 + } + + // Exported symbols before non-exported. + ea := IsExported(a.Name) + eb := IsExported(b.Name) + if ea != eb { + if ea { + return -1 + } else { + return +1 + } + } + + // Order by name and then (for non-exported names) by package + // height and path. + if r := strings.Compare(a.Name, b.Name); r != 0 { + return r + } + if !ea { + return strings.Compare(a.Pkg.Path, b.Pkg.Path) + } + return 0 +} + +// IsExported reports whether name is an exported Go symbol (that is, +// whether it begins with an upper-case letter). +func IsExported(name string) bool { + if r := name[0]; r < utf8.RuneSelf { + return 'A' <= r && r <= 'Z' + } + r, _ := utf8.DecodeRuneInString(name) + return unicode.IsUpper(r) +} diff --git a/go/src/cmd/compile/internal/types/sym_test.go b/go/src/cmd/compile/internal/types/sym_test.go new file mode 100644 index 0000000000000000000000000000000000000000..cdb17c36f57cc7662e879ed5f2ec9eeeeede4e5f --- /dev/null +++ b/go/src/cmd/compile/internal/types/sym_test.go @@ -0,0 +1,59 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types_test + +import ( + "cmd/compile/internal/types" + "reflect" + "slices" + "testing" +) + +func TestSymCompare(t *testing.T) { + var ( + local = types.NewPkg("", "") + abc = types.NewPkg("abc", "") + uvw = types.NewPkg("uvw", "") + xyz = types.NewPkg("xyz", "") + gr = types.NewPkg("gr", "") + ) + + data := []*types.Sym{ + abc.Lookup("b"), + local.Lookup("B"), + local.Lookup("C"), + uvw.Lookup("c"), + local.Lookup("C"), + gr.Lookup("φ"), + local.Lookup("Φ"), + xyz.Lookup("b"), + abc.Lookup("a"), + local.Lookup("B"), + } + want := []*types.Sym{ + local.Lookup("B"), + local.Lookup("B"), + local.Lookup("C"), + local.Lookup("C"), + local.Lookup("Φ"), + abc.Lookup("a"), + abc.Lookup("b"), + xyz.Lookup("b"), + uvw.Lookup("c"), + gr.Lookup("φ"), + } + if len(data) != len(want) { + t.Fatal("want and data must match") + } + if reflect.DeepEqual(data, want) { + t.Fatal("data must be shuffled") + } + slices.SortFunc(data, types.CompareSyms) + if !reflect.DeepEqual(data, want) { + t.Logf("want: %#v", want) + t.Logf("data: %#v", data) + t.Errorf("sorting failed") + } +} diff --git a/go/src/cmd/compile/internal/types/type.go b/go/src/cmd/compile/internal/types/type.go new file mode 100644 index 0000000000000000000000000000000000000000..6663c49dd8d8a9ec9cf77f4713887ddd433bfc6b --- /dev/null +++ b/go/src/cmd/compile/internal/types/type.go @@ -0,0 +1,1989 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +import ( + "cmd/compile/internal/base" + "cmd/internal/objabi" + "cmd/internal/src" + "fmt" + "go/constant" + "internal/types/errors" + "sync" +) + +// Object represents an ir.Node, but without needing to import cmd/compile/internal/ir, +// which would cause an import cycle. The uses in other packages must type assert +// values of type Object to ir.Node or a more specific type. +type Object interface { + Pos() src.XPos + Sym() *Sym + Type() *Type +} + +//go:generate stringer -type Kind -trimprefix T type.go + +// Kind describes a kind of type. +type Kind uint8 + +const ( + Txxx Kind = iota + + TINT8 + TUINT8 + TINT16 + TUINT16 + TINT32 + TUINT32 + TINT64 + TUINT64 + TINT + TUINT + TUINTPTR + + TCOMPLEX64 + TCOMPLEX128 + + TFLOAT32 + TFLOAT64 + + TBOOL + + TPTR + TFUNC + TSLICE + TARRAY + TSTRUCT + TCHAN + TMAP + TINTER + TFORW + TANY + TSTRING + TUNSAFEPTR + + // pseudo-types for literals + TIDEAL // untyped numeric constants + TNIL + TBLANK + + // pseudo-types used temporarily only during frame layout (CalcSize()) + TFUNCARGS + TCHANARGS + + // SSA backend types + TSSA // internal types used by SSA backend (flags, memory, etc.) + TTUPLE // a pair of types, used by SSA backend + TRESULTS // multiple types; the result of calling a function or method, with a memory at the end. + + NTYPE +) + +// ChanDir is whether a channel can send, receive, or both. +type ChanDir uint8 + +func (c ChanDir) CanRecv() bool { return c&Crecv != 0 } +func (c ChanDir) CanSend() bool { return c&Csend != 0 } + +const ( + // types of channel + // must match ../../../../reflect/type.go:/ChanDir + Crecv ChanDir = 1 << 0 + Csend ChanDir = 1 << 1 + Cboth ChanDir = Crecv | Csend +) + +// Types stores pointers to predeclared named types. +// +// It also stores pointers to several special types: +// - Types[TANY] is the placeholder "any" type recognized by SubstArgTypes. +// - Types[TBLANK] represents the blank variable's type. +// - Types[TINTER] is the canonical "interface{}" type. +// - Types[TNIL] represents the predeclared "nil" value's type. +// - Types[TUNSAFEPTR] is package unsafe's Pointer type. +var Types [NTYPE]*Type + +var ( + // Predeclared alias types. These are actually created as distinct + // defined types for better error messages, but are then specially + // treated as identical to their respective underlying types. + AnyType *Type + ByteType *Type + RuneType *Type + + // Predeclared error interface type. + ErrorType *Type + // Predeclared comparable interface type. + ComparableType *Type + + // Types to represent untyped string and boolean constants. + UntypedString = newType(TSTRING) + UntypedBool = newType(TBOOL) + + // Types to represent untyped numeric constants. + UntypedInt = newType(TIDEAL) + UntypedRune = newType(TIDEAL) + UntypedFloat = newType(TIDEAL) + UntypedComplex = newType(TIDEAL) +) + +// UntypedTypes maps from a constant.Kind to its untyped Type +// representation. +var UntypedTypes = [...]*Type{ + constant.Bool: UntypedBool, + constant.String: UntypedString, + constant.Int: UntypedInt, + constant.Float: UntypedFloat, + constant.Complex: UntypedComplex, +} + +// DefaultKinds maps from a constant.Kind to its default Kind. +var DefaultKinds = [...]Kind{ + constant.Bool: TBOOL, + constant.String: TSTRING, + constant.Int: TINT, + constant.Float: TFLOAT64, + constant.Complex: TCOMPLEX128, +} + +// A Type represents a Go type. +// +// There may be multiple unnamed types with identical structure. However, there must +// be a unique Type object for each unique named (defined) type. After noding, a +// package-level type can be looked up by building its unique symbol sym (sym = +// package.Lookup(name)) and checking sym.Def. If sym.Def is non-nil, the type +// already exists at package scope and is available at sym.Def.(*ir.Name).Type(). +// Local types (which may have the same name as a package-level type) are +// distinguished by their vargen, which is embedded in their symbol name. +type Type struct { + // extra contains extra etype-specific fields. + // As an optimization, those etype-specific structs which contain exactly + // one pointer-shaped field are stored as values rather than pointers when possible. + // + // TMAP: *Map + // TFORW: *Forward + // TFUNC: *Func + // TSTRUCT: *Struct + // TINTER: *Interface + // TFUNCARGS: FuncArgs + // TCHANARGS: ChanArgs + // TCHAN: *Chan + // TPTR: Ptr + // TARRAY: *Array + // TSLICE: Slice + // TSSA: string + extra any + + // width is the width of this Type in bytes. + width int64 // valid if Align > 0 + + // list of base methods (excluding embedding) + methods fields + // list of all methods (including embedding) + allMethods fields + + // canonical OTYPE node for a named type (should be an ir.Name node with same sym) + obj Object + // the underlying type (type literal or predeclared type) for a defined type + underlying *Type + + // Cache of composite types, with this type being the element type. + cache struct { + ptr *Type // *T, or nil + slice *Type // []T, or nil + } + + kind Kind // kind of type + align uint8 // the required alignment of this type, in bytes (0 means Width and Align have not yet been computed) + + intRegs, floatRegs uint8 // registers needed for ABIInternal + + flags bitset8 + alg AlgKind // valid if Align > 0 + isSIMDTag, isSIMD bool // tag is the marker type, isSIMD means has marker type + + // size of prefix of object that contains all pointers. valid if Align > 0. + // Note that for pointers, this is always PtrSize even if the element type + // is NotInHeap. See size.go:PtrDataSize for details. + ptrBytes int64 +} + +// Registers returns the number of integer and floating-point +// registers required to represent a parameter of this type under the +// ABIInternal calling conventions. +// +// If t must be passed by memory, Registers returns (math.MaxUint8, +// math.MaxUint8). +func (t *Type) Registers() (uint8, uint8) { + CalcSize(t) + return t.intRegs, t.floatRegs +} + +func (*Type) CanBeAnSSAAux() {} + +const ( + typeNotInHeap = 1 << iota // type cannot be heap allocated + typeNoalg // suppress hash and eq algorithm generation + typeDeferwidth // width computation has been deferred and type is on deferredTypeStack + typeRecur + typeIsShape // represents a set of closely related types, for generics + typeHasShape // there is a shape somewhere in the type + // typeIsFullyInstantiated reports whether a type is fully instantiated generic type; i.e. + // an instantiated generic type where all type arguments are non-generic or fully instantiated generic types. + typeIsFullyInstantiated +) + +func (t *Type) NotInHeap() bool { return t.flags&typeNotInHeap != 0 } +func (t *Type) Noalg() bool { return t.flags&typeNoalg != 0 } +func (t *Type) Deferwidth() bool { return t.flags&typeDeferwidth != 0 } +func (t *Type) Recur() bool { return t.flags&typeRecur != 0 } +func (t *Type) IsShape() bool { return t.flags&typeIsShape != 0 } +func (t *Type) HasShape() bool { return t.flags&typeHasShape != 0 } +func (t *Type) IsFullyInstantiated() bool { return t.flags&typeIsFullyInstantiated != 0 } + +func (t *Type) SetNotInHeap(b bool) { t.flags.set(typeNotInHeap, b) } +func (t *Type) SetNoalg(b bool) { t.flags.set(typeNoalg, b) } +func (t *Type) SetDeferwidth(b bool) { t.flags.set(typeDeferwidth, b) } +func (t *Type) SetRecur(b bool) { t.flags.set(typeRecur, b) } +func (t *Type) SetIsFullyInstantiated(b bool) { t.flags.set(typeIsFullyInstantiated, b) } + +// Should always do SetHasShape(true) when doing SetIsShape(true). +func (t *Type) SetIsShape(b bool) { t.flags.set(typeIsShape, b) } +func (t *Type) SetHasShape(b bool) { t.flags.set(typeHasShape, b) } + +// Kind returns the kind of type t. +func (t *Type) Kind() Kind { return t.kind } + +// Sym returns the name of type t. +func (t *Type) Sym() *Sym { + if t.obj != nil { + return t.obj.Sym() + } + return nil +} + +// Underlying returns the underlying type of type t. +func (t *Type) Underlying() *Type { return t.underlying } + +// Pos returns a position associated with t, if any. +// This should only be used for diagnostics. +func (t *Type) Pos() src.XPos { + if t.obj != nil { + return t.obj.Pos() + } + return src.NoXPos +} + +// Map contains Type fields specific to maps. +type Map struct { + Key *Type // Key type + Elem *Type // Val (elem) type + + Group *Type // internal struct type representing a slot group +} + +// MapType returns t's extra map-specific fields. +func (t *Type) MapType() *Map { + t.wantEtype(TMAP) + return t.extra.(*Map) +} + +// Forward contains Type fields specific to forward types. +type Forward struct { + Copyto []*Type // where to copy the eventual value to + Embedlineno src.XPos // first use of this type as an embedded type +} + +// forwardType returns t's extra forward-type-specific fields. +func (t *Type) forwardType() *Forward { + t.wantEtype(TFORW) + return t.extra.(*Forward) +} + +// Func contains Type fields specific to func types. +type Func struct { + allParams []*Field // slice of all parameters, in receiver/params/results order + + startParams int // index of the start of the (regular) parameters section + startResults int // index of the start of the results section + + resultsTuple *Type // struct-like type representing multi-value results + + // Argwid is the total width of the function receiver, params, and results. + // It gets calculated via a temporary TFUNCARGS type. + // Note that TFUNC's Width is Widthptr. + Argwid int64 +} + +func (ft *Func) recvs() []*Field { return ft.allParams[:ft.startParams] } +func (ft *Func) params() []*Field { return ft.allParams[ft.startParams:ft.startResults] } +func (ft *Func) results() []*Field { return ft.allParams[ft.startResults:] } +func (ft *Func) recvParams() []*Field { return ft.allParams[:ft.startResults] } +func (ft *Func) paramsResults() []*Field { return ft.allParams[ft.startParams:] } + +// funcType returns t's extra func-specific fields. +func (t *Type) funcType() *Func { + t.wantEtype(TFUNC) + return t.extra.(*Func) +} + +// Struct contains Type fields specific to struct types. +type Struct struct { + fields fields + + // Maps have three associated internal structs (see struct MapType). + // Map links such structs back to their map type. + Map *Type + + ParamTuple bool // whether this struct is actually a tuple of signature parameters +} + +// StructType returns t's extra struct-specific fields. +func (t *Type) StructType() *Struct { + t.wantEtype(TSTRUCT) + return t.extra.(*Struct) +} + +// Interface contains Type fields specific to interface types. +type Interface struct { +} + +// Ptr contains Type fields specific to pointer types. +type Ptr struct { + Elem *Type // element type +} + +// ChanArgs contains Type fields specific to TCHANARGS types. +type ChanArgs struct { + T *Type // reference to a chan type whose elements need a width check +} + +// FuncArgs contains Type fields specific to TFUNCARGS types. +type FuncArgs struct { + T *Type // reference to a func type whose elements need a width check +} + +// Chan contains Type fields specific to channel types. +type Chan struct { + Elem *Type // element type + Dir ChanDir // channel direction +} + +// chanType returns t's extra channel-specific fields. +func (t *Type) chanType() *Chan { + t.wantEtype(TCHAN) + return t.extra.(*Chan) +} + +type Tuple struct { + first *Type + second *Type + // Any tuple with a memory type must put that memory type second. +} + +// Results are the output from calls that will be late-expanded. +type Results struct { + Types []*Type // Last element is memory output from call. +} + +// Array contains Type fields specific to array types. +type Array struct { + Elem *Type // element type + Bound int64 // number of elements; <0 if unknown yet +} + +// Slice contains Type fields specific to slice types. +type Slice struct { + Elem *Type // element type +} + +// A Field is a (Sym, Type) pairing along with some other information, and, +// depending on the context, is used to represent: +// - a field in a struct +// - a method in an interface or associated with a named type +// - a function parameter +type Field struct { + flags bitset8 + + Embedded uint8 // embedded field + + Pos src.XPos + + // Name of field/method/parameter. Can be nil for interface fields embedded + // in interfaces and unnamed parameters. + Sym *Sym + Type *Type // field type + Note string // literal string annotation + + // For fields that represent function parameters, Nname points to the + // associated ONAME Node. For fields that represent methods, Nname points to + // the function name node. + Nname Object + + // Offset in bytes of this field or method within its enclosing struct + // or interface Type. For parameters, this is BADWIDTH. + Offset int64 +} + +const ( + fieldIsDDD = 1 << iota // field is ... argument + fieldNointerface +) + +func (f *Field) IsDDD() bool { return f.flags&fieldIsDDD != 0 } +func (f *Field) Nointerface() bool { return f.flags&fieldNointerface != 0 } + +func (f *Field) SetIsDDD(b bool) { f.flags.set(fieldIsDDD, b) } +func (f *Field) SetNointerface(b bool) { f.flags.set(fieldNointerface, b) } + +// End returns the offset of the first byte immediately after this field. +func (f *Field) End() int64 { + return f.Offset + f.Type.width +} + +// IsMethod reports whether f represents a method rather than a struct field. +func (f *Field) IsMethod() bool { + return f.Type.kind == TFUNC && f.Type.Recv() != nil +} + +// CompareFields compares two Field values by name. +func CompareFields(a, b *Field) int { + return CompareSyms(a.Sym, b.Sym) +} + +// fields is a pointer to a slice of *Field. +// This saves space in Types that do not have fields or methods +// compared to a simple slice of *Field. +type fields struct { + s *[]*Field +} + +// Slice returns the entries in f as a slice. +// Changes to the slice entries will be reflected in f. +func (f *fields) Slice() []*Field { + if f.s == nil { + return nil + } + return *f.s +} + +// Set sets f to a slice. +// This takes ownership of the slice. +func (f *fields) Set(s []*Field) { + if len(s) == 0 { + f.s = nil + } else { + // Copy s and take address of t rather than s to avoid + // allocation in the case where len(s) == 0. + t := s + f.s = &t + } +} + +// newType returns a new Type of the specified kind. +func newType(et Kind) *Type { + t := &Type{ + kind: et, + width: BADWIDTH, + } + t.underlying = t + // TODO(josharian): lazily initialize some of these? + switch t.kind { + case TMAP: + t.extra = new(Map) + case TFORW: + t.extra = new(Forward) + case TFUNC: + t.extra = new(Func) + case TSTRUCT: + t.extra = new(Struct) + case TINTER: + t.extra = new(Interface) + case TPTR: + t.extra = Ptr{} + case TCHANARGS: + t.extra = ChanArgs{} + case TFUNCARGS: + t.extra = FuncArgs{} + case TCHAN: + t.extra = new(Chan) + case TTUPLE: + t.extra = new(Tuple) + case TRESULTS: + t.extra = new(Results) + } + return t +} + +// NewArray returns a new fixed-length array Type. +func NewArray(elem *Type, bound int64) *Type { + if bound < 0 { + base.Fatalf("NewArray: invalid bound %v", bound) + } + t := newType(TARRAY) + t.extra = &Array{Elem: elem, Bound: bound} + if elem.HasShape() { + t.SetHasShape(true) + } + if elem.NotInHeap() { + t.SetNotInHeap(true) + } + return t +} + +// NewSlice returns the slice Type with element type elem. +func NewSlice(elem *Type) *Type { + if t := elem.cache.slice; t != nil { + if t.Elem() != elem { + base.Fatalf("elem mismatch") + } + if elem.HasShape() != t.HasShape() { + base.Fatalf("Incorrect HasShape flag for cached slice type") + } + return t + } + + t := newType(TSLICE) + t.extra = Slice{Elem: elem} + elem.cache.slice = t + if elem.HasShape() { + t.SetHasShape(true) + } + return t +} + +// NewChan returns a new chan Type with direction dir. +func NewChan(elem *Type, dir ChanDir) *Type { + t := newType(TCHAN) + ct := t.chanType() + ct.Elem = elem + ct.Dir = dir + if elem.HasShape() { + t.SetHasShape(true) + } + return t +} + +func NewTuple(t1, t2 *Type) *Type { + t := newType(TTUPLE) + t.extra.(*Tuple).first = t1 + t.extra.(*Tuple).second = t2 + if t1.HasShape() || t2.HasShape() { + t.SetHasShape(true) + } + return t +} + +func newResults(types []*Type) *Type { + t := newType(TRESULTS) + t.extra.(*Results).Types = types + return t +} + +func NewResults(types []*Type) *Type { + if len(types) == 1 && types[0] == TypeMem { + return TypeResultMem + } + return newResults(types) +} + +func newSSA(name string) *Type { + t := newType(TSSA) + t.extra = name + return t +} + +func newSIMD(name string) *Type { + t := newSSA(name) + t.isSIMD = true + return t +} + +// NewMap returns a new map Type with key type k and element (aka value) type v. +func NewMap(k, v *Type) *Type { + t := newType(TMAP) + mt := t.MapType() + mt.Key = k + mt.Elem = v + if k.HasShape() || v.HasShape() { + t.SetHasShape(true) + } + return t +} + +// NewPtrCacheEnabled controls whether *T Types are cached in T. +// Caching is disabled just before starting the backend. +// This allows the backend to run concurrently. +var NewPtrCacheEnabled = true + +// NewPtr returns the pointer type pointing to t. +func NewPtr(elem *Type) *Type { + if elem == nil { + base.Fatalf("NewPtr: pointer to elem Type is nil") + } + + if t := elem.cache.ptr; t != nil { + if t.Elem() != elem { + base.Fatalf("NewPtr: elem mismatch") + } + if elem.HasShape() != t.HasShape() { + base.Fatalf("Incorrect HasShape flag for cached pointer type") + } + return t + } + + t := newType(TPTR) + t.extra = Ptr{Elem: elem} + t.width = int64(PtrSize) + t.align = uint8(PtrSize) + t.intRegs = 1 + if NewPtrCacheEnabled { + elem.cache.ptr = t + } + if elem.HasShape() { + t.SetHasShape(true) + } + t.alg = AMEM + if elem.Noalg() { + t.SetNoalg(true) + t.alg = ANOALG + } + // Note: we can't check elem.NotInHeap here because it might + // not be set yet. See size.go:PtrDataSize. + t.ptrBytes = int64(PtrSize) + return t +} + +// NewChanArgs returns a new TCHANARGS type for channel type c. +func NewChanArgs(c *Type) *Type { + t := newType(TCHANARGS) + t.extra = ChanArgs{T: c} + return t +} + +// NewFuncArgs returns a new TFUNCARGS type for func type f. +func NewFuncArgs(f *Type) *Type { + t := newType(TFUNCARGS) + t.extra = FuncArgs{T: f} + return t +} + +func NewField(pos src.XPos, sym *Sym, typ *Type) *Field { + f := &Field{ + Pos: pos, + Sym: sym, + Type: typ, + Offset: BADWIDTH, + } + if typ == nil { + base.Fatalf("typ is nil") + } + return f +} + +// SubstAny walks t, replacing instances of "any" with successive +// elements removed from types. It returns the substituted type. +func SubstAny(t *Type, types *[]*Type) *Type { + if t == nil { + return nil + } + + switch t.kind { + default: + // Leave the type unchanged. + + case TANY: + if len(*types) == 0 { + base.Fatalf("SubstArgTypes: not enough argument types") + } + t = (*types)[0] + *types = (*types)[1:] + + case TPTR: + elem := SubstAny(t.Elem(), types) + if elem != t.Elem() { + t = t.copy() + t.extra = Ptr{Elem: elem} + } + + case TARRAY: + elem := SubstAny(t.Elem(), types) + if elem != t.Elem() { + t = t.copy() + t.extra.(*Array).Elem = elem + } + + case TSLICE: + elem := SubstAny(t.Elem(), types) + if elem != t.Elem() { + t = t.copy() + t.extra = Slice{Elem: elem} + } + + case TCHAN: + elem := SubstAny(t.Elem(), types) + if elem != t.Elem() { + t = t.copy() + t.extra.(*Chan).Elem = elem + } + + case TMAP: + key := SubstAny(t.Key(), types) + elem := SubstAny(t.Elem(), types) + if key != t.Key() || elem != t.Elem() { + t = t.copy() + t.extra.(*Map).Key = key + t.extra.(*Map).Elem = elem + } + + case TFUNC: + ft := t.funcType() + allParams := substFields(ft.allParams, types) + + t = t.copy() + ft = t.funcType() + ft.allParams = allParams + + rt := ft.resultsTuple + rt = rt.copy() + ft.resultsTuple = rt + rt.setFields(t.Results()) + + case TSTRUCT: + // Make a copy of all fields, including ones whose type does not change. + // This prevents aliasing across functions, which can lead to later + // fields getting their Offset incorrectly overwritten. + nfs := substFields(t.Fields(), types) + t = t.copy() + t.setFields(nfs) + } + + return t +} + +func substFields(fields []*Field, types *[]*Type) []*Field { + nfs := make([]*Field, len(fields)) + for i, f := range fields { + nft := SubstAny(f.Type, types) + nfs[i] = f.Copy() + nfs[i].Type = nft + } + return nfs +} + +// copy returns a shallow copy of the Type. +func (t *Type) copy() *Type { + if t == nil { + return nil + } + nt := *t + // copy any *T Extra fields, to avoid aliasing + switch t.kind { + case TMAP: + x := *t.extra.(*Map) + nt.extra = &x + case TFORW: + x := *t.extra.(*Forward) + nt.extra = &x + case TFUNC: + x := *t.extra.(*Func) + nt.extra = &x + case TSTRUCT: + x := *t.extra.(*Struct) + nt.extra = &x + case TINTER: + x := *t.extra.(*Interface) + nt.extra = &x + case TCHAN: + x := *t.extra.(*Chan) + nt.extra = &x + case TARRAY: + x := *t.extra.(*Array) + nt.extra = &x + case TTUPLE, TSSA, TRESULTS: + base.Fatalf("ssa types cannot be copied") + } + // TODO(mdempsky): Find out why this is necessary and explain. + if t.underlying == t { + nt.underlying = &nt + } + return &nt +} + +func (f *Field) Copy() *Field { + nf := *f + return &nf +} + +func (t *Type) wantEtype(et Kind) { + if t.kind != et { + base.Fatalf("want %v, but have %v", et, t) + } +} + +// ResultsTuple returns the result type of signature type t as a tuple. +// This can be used as the type of multi-valued call expressions. +func (t *Type) ResultsTuple() *Type { return t.funcType().resultsTuple } + +// Recvs returns a slice of receiver parameters of signature type t. +// The returned slice always has length 0 or 1. +func (t *Type) Recvs() []*Field { return t.funcType().recvs() } + +// Params returns a slice of regular parameters of signature type t. +func (t *Type) Params() []*Field { return t.funcType().params() } + +// Results returns a slice of result parameters of signature type t. +func (t *Type) Results() []*Field { return t.funcType().results() } + +// RecvParamsResults returns a slice containing all of the +// signature's parameters in receiver (if any), (normal) parameters, +// and then results. +func (t *Type) RecvParamsResults() []*Field { return t.funcType().allParams } + +// RecvParams returns a slice containing the signature's receiver (if +// any) followed by its (normal) parameters. +func (t *Type) RecvParams() []*Field { return t.funcType().recvParams() } + +// ParamsResults returns a slice containing the signature's (normal) +// parameters followed by its results. +func (t *Type) ParamsResults() []*Field { return t.funcType().paramsResults() } + +func (t *Type) NumRecvs() int { return len(t.Recvs()) } +func (t *Type) NumParams() int { return len(t.Params()) } +func (t *Type) NumResults() int { return len(t.Results()) } + +// IsVariadic reports whether function type t is variadic. +func (t *Type) IsVariadic() bool { + n := t.NumParams() + return n > 0 && t.Param(n-1).IsDDD() +} + +// Recv returns the receiver of function type t, if any. +func (t *Type) Recv() *Field { + if s := t.Recvs(); len(s) == 1 { + return s[0] + } + return nil +} + +// Param returns the i'th parameter of signature type t. +func (t *Type) Param(i int) *Field { return t.Params()[i] } + +// Result returns the i'th result of signature type t. +func (t *Type) Result(i int) *Field { return t.Results()[i] } + +// Key returns the key type of map type t. +func (t *Type) Key() *Type { + t.wantEtype(TMAP) + return t.extra.(*Map).Key +} + +// Elem returns the type of elements of t. +// Usable with pointers, channels, arrays, slices, and maps. +func (t *Type) Elem() *Type { + switch t.kind { + case TPTR: + return t.extra.(Ptr).Elem + case TARRAY: + return t.extra.(*Array).Elem + case TSLICE: + return t.extra.(Slice).Elem + case TCHAN: + return t.extra.(*Chan).Elem + case TMAP: + return t.extra.(*Map).Elem + } + base.Fatalf("Type.Elem %s", t.kind) + return nil +} + +// ChanArgs returns the channel type for TCHANARGS type t. +func (t *Type) ChanArgs() *Type { + t.wantEtype(TCHANARGS) + return t.extra.(ChanArgs).T +} + +// FuncArgs returns the func type for TFUNCARGS type t. +func (t *Type) FuncArgs() *Type { + t.wantEtype(TFUNCARGS) + return t.extra.(FuncArgs).T +} + +// IsFuncArgStruct reports whether t is a struct representing function parameters or results. +func (t *Type) IsFuncArgStruct() bool { + return t.kind == TSTRUCT && t.extra.(*Struct).ParamTuple +} + +// Methods returns a pointer to the base methods (excluding embedding) for type t. +// These can either be concrete methods (for non-interface types) or interface +// methods (for interface types). +func (t *Type) Methods() []*Field { + return t.methods.Slice() +} + +// AllMethods returns a pointer to all the methods (including embedding) for type t. +// For an interface type, this is the set of methods that are typically iterated +// over. For non-interface types, AllMethods() only returns a valid result after +// CalcMethods() has been called at least once. +func (t *Type) AllMethods() []*Field { + if t.kind == TINTER { + // Calculate the full method set of an interface type on the fly + // now, if not done yet. + CalcSize(t) + } + return t.allMethods.Slice() +} + +// SetMethods sets the direct method set for type t (i.e., *not* +// including promoted methods from embedded types). +func (t *Type) SetMethods(fs []*Field) { + t.methods.Set(fs) +} + +// SetAllMethods sets the set of all methods for type t (i.e., +// including promoted methods from embedded types). +func (t *Type) SetAllMethods(fs []*Field) { + t.allMethods.Set(fs) +} + +// fields returns the fields of struct type t. +func (t *Type) fields() *fields { + t.wantEtype(TSTRUCT) + return &t.extra.(*Struct).fields +} + +// Field returns the i'th field of struct type t. +func (t *Type) Field(i int) *Field { return t.Fields()[i] } + +// Fields returns a slice of containing all fields of +// a struct type t. +func (t *Type) Fields() []*Field { return t.fields().Slice() } + +// setFields sets struct type t's fields to fields. +func (t *Type) setFields(fields []*Field) { + // If we've calculated the width of t before, + // then some other type such as a function signature + // might now have the wrong type. + // Rather than try to track and invalidate those, + // enforce that SetFields cannot be called once + // t's width has been calculated. + if t.widthCalculated() { + base.Fatalf("SetFields of %v: width previously calculated", t) + } + t.wantEtype(TSTRUCT) + t.fields().Set(fields) +} + +// SetInterface sets the base methods of an interface type t. +func (t *Type) SetInterface(methods []*Field) { + t.wantEtype(TINTER) + t.methods.Set(methods) +} + +// ArgWidth returns the total aligned argument size for a function. +// It includes the receiver, parameters, and results. +func (t *Type) ArgWidth() int64 { + t.wantEtype(TFUNC) + return t.extra.(*Func).Argwid +} + +// Size returns the width of t in bytes. +func (t *Type) Size() int64 { + if t.kind == TSSA { + return t.width + } + CalcSize(t) + return t.width +} + +// Alignment returns the alignment of t in bytes. +func (t *Type) Alignment() int64 { + CalcSize(t) + return int64(t.align) +} + +func (t *Type) SimpleString() string { + return t.kind.String() +} + +// Cmp is a comparison between values a and b. +// +// -1 if a < b +// 0 if a == b +// 1 if a > b +type Cmp int8 + +const ( + CMPlt = Cmp(-1) + CMPeq = Cmp(0) + CMPgt = Cmp(1) +) + +// Compare compares types for purposes of the SSA back +// end, returning a Cmp (one of CMPlt, CMPeq, CMPgt). +// The answers are correct for an optimizer +// or code generator, but not necessarily typechecking. +// The order chosen is arbitrary, only consistency and division +// into equivalence classes (Types that compare CMPeq) matters. +func (t *Type) Compare(x *Type) Cmp { + if x == t { + return CMPeq + } + return t.cmp(x) +} + +func cmpForNe(x bool) Cmp { + if x { + return CMPlt + } + return CMPgt +} + +func (r *Sym) cmpsym(s *Sym) Cmp { + if r == s { + return CMPeq + } + if r == nil { + return CMPlt + } + if s == nil { + return CMPgt + } + // Fast sort, not pretty sort + if len(r.Name) != len(s.Name) { + return cmpForNe(len(r.Name) < len(s.Name)) + } + if r.Pkg != s.Pkg { + if len(r.Pkg.Prefix) != len(s.Pkg.Prefix) { + return cmpForNe(len(r.Pkg.Prefix) < len(s.Pkg.Prefix)) + } + if r.Pkg.Prefix != s.Pkg.Prefix { + return cmpForNe(r.Pkg.Prefix < s.Pkg.Prefix) + } + } + if r.Name != s.Name { + return cmpForNe(r.Name < s.Name) + } + return CMPeq +} + +// cmp compares two *Types t and x, returning CMPlt, +// CMPeq, CMPgt as tx, for an arbitrary +// and optimizer-centric notion of comparison. +// TODO(josharian): make this safe for recursive interface types +// and use in signatlist sorting. See issue 19869. +func (t *Type) cmp(x *Type) Cmp { + // This follows the structure of function identical in identity.go + // with two exceptions. + // 1. Symbols are compared more carefully because a <,=,> result is desired. + // 2. Maps are treated specially to avoid endless recursion -- maps + // contain an internal data type not expressible in Go source code. + if t == x { + return CMPeq + } + if t == nil { + return CMPlt + } + if x == nil { + return CMPgt + } + + if t.kind != x.kind { + return cmpForNe(t.kind < x.kind) + } + + if t.obj != nil || x.obj != nil { + // Special case: we keep byte and uint8 separate + // for error messages. Treat them as equal. + switch t.kind { + case TUINT8: + if (t == Types[TUINT8] || t == ByteType) && (x == Types[TUINT8] || x == ByteType) { + return CMPeq + } + + case TINT32: + if (t == Types[RuneType.kind] || t == RuneType) && (x == Types[RuneType.kind] || x == RuneType) { + return CMPeq + } + + case TINTER: + // Make sure named any type matches any empty interface. + if t == AnyType && x.IsEmptyInterface() || x == AnyType && t.IsEmptyInterface() { + return CMPeq + } + } + } + + if c := t.Sym().cmpsym(x.Sym()); c != CMPeq { + return c + } + + if x.obj != nil { + return CMPeq + } + // both syms nil, look at structure below. + + switch t.kind { + case TBOOL, TFLOAT32, TFLOAT64, TCOMPLEX64, TCOMPLEX128, TUNSAFEPTR, TUINTPTR, + TINT8, TINT16, TINT32, TINT64, TINT, TUINT8, TUINT16, TUINT32, TUINT64, TUINT: + return CMPeq + + case TSSA: + tname := t.extra.(string) + xname := x.extra.(string) + // desire fast sorting, not pretty sorting. + if len(tname) == len(xname) { + if tname == xname { + return CMPeq + } + if tname < xname { + return CMPlt + } + return CMPgt + } + if len(tname) > len(xname) { + return CMPgt + } + return CMPlt + + case TTUPLE: + xtup := x.extra.(*Tuple) + ttup := t.extra.(*Tuple) + if c := ttup.first.Compare(xtup.first); c != CMPeq { + return c + } + return ttup.second.Compare(xtup.second) + + case TRESULTS: + xResults := x.extra.(*Results) + tResults := t.extra.(*Results) + xl, tl := len(xResults.Types), len(tResults.Types) + if tl != xl { + if tl < xl { + return CMPlt + } + return CMPgt + } + for i := 0; i < tl; i++ { + if c := tResults.Types[i].Compare(xResults.Types[i]); c != CMPeq { + return c + } + } + return CMPeq + + case TMAP: + if c := t.Key().cmp(x.Key()); c != CMPeq { + return c + } + return t.Elem().cmp(x.Elem()) + + case TPTR, TSLICE: + // No special cases for these, they are handled + // by the general code after the switch. + + case TSTRUCT: + // Is this a map group type? + if t.StructType().Map == nil { + if x.StructType().Map != nil { + return CMPlt // nil < non-nil + } + // to the general case + } else if x.StructType().Map == nil { + return CMPgt // nil > non-nil + } + // Both have non-nil Map, fallthrough to the general + // case. Note that the map type does not directly refer + // to the group type (it uses unsafe.Pointer). If it + // did, this would need special handling to avoid + // infinite recursion. + + tfs := t.Fields() + xfs := x.Fields() + for i := 0; i < len(tfs) && i < len(xfs); i++ { + t1, x1 := tfs[i], xfs[i] + if t1.Embedded != x1.Embedded { + return cmpForNe(t1.Embedded < x1.Embedded) + } + if t1.Note != x1.Note { + return cmpForNe(t1.Note < x1.Note) + } + if c := t1.Sym.cmpsym(x1.Sym); c != CMPeq { + return c + } + if c := t1.Type.cmp(x1.Type); c != CMPeq { + return c + } + } + if len(tfs) != len(xfs) { + return cmpForNe(len(tfs) < len(xfs)) + } + return CMPeq + + case TINTER: + tfs := t.AllMethods() + xfs := x.AllMethods() + for i := 0; i < len(tfs) && i < len(xfs); i++ { + t1, x1 := tfs[i], xfs[i] + if c := t1.Sym.cmpsym(x1.Sym); c != CMPeq { + return c + } + if c := t1.Type.cmp(x1.Type); c != CMPeq { + return c + } + } + if len(tfs) != len(xfs) { + return cmpForNe(len(tfs) < len(xfs)) + } + return CMPeq + + case TFUNC: + if tn, xn := t.NumRecvs(), x.NumRecvs(); tn != xn { + return cmpForNe(tn < xn) + } + if tn, xn := t.NumParams(), x.NumParams(); tn != xn { + return cmpForNe(tn < xn) + } + if tn, xn := t.NumResults(), x.NumResults(); tn != xn { + return cmpForNe(tn < xn) + } + if tv, xv := t.IsVariadic(), x.IsVariadic(); tv != xv { + return cmpForNe(!tv) + } + + tfs := t.RecvParamsResults() + xfs := x.RecvParamsResults() + for i, tf := range tfs { + if c := tf.Type.cmp(xfs[i].Type); c != CMPeq { + return c + } + } + return CMPeq + + case TARRAY: + if t.NumElem() != x.NumElem() { + return cmpForNe(t.NumElem() < x.NumElem()) + } + + case TCHAN: + if t.ChanDir() != x.ChanDir() { + return cmpForNe(t.ChanDir() < x.ChanDir()) + } + + default: + e := fmt.Sprintf("Do not know how to compare %v with %v", t, x) + panic(e) + } + + // Common element type comparison for TARRAY, TCHAN, TPTR, and TSLICE. + return t.Elem().cmp(x.Elem()) +} + +// IsKind reports whether t is a Type of the specified kind. +func (t *Type) IsKind(et Kind) bool { + return t != nil && t.kind == et +} + +func (t *Type) IsBoolean() bool { + return t.kind == TBOOL +} + +var unsignedEType = [...]Kind{ + TINT8: TUINT8, + TUINT8: TUINT8, + TINT16: TUINT16, + TUINT16: TUINT16, + TINT32: TUINT32, + TUINT32: TUINT32, + TINT64: TUINT64, + TUINT64: TUINT64, + TINT: TUINT, + TUINT: TUINT, + TUINTPTR: TUINTPTR, +} + +// ToUnsigned returns the unsigned equivalent of integer type t. +func (t *Type) ToUnsigned() *Type { + if !t.IsInteger() { + base.Fatalf("unsignedType(%v)", t) + } + return Types[unsignedEType[t.kind]] +} + +func (t *Type) IsInteger() bool { + switch t.kind { + case TINT8, TUINT8, TINT16, TUINT16, TINT32, TUINT32, TINT64, TUINT64, TINT, TUINT, TUINTPTR: + return true + } + return t == UntypedInt || t == UntypedRune +} + +func (t *Type) IsSigned() bool { + switch t.kind { + case TINT8, TINT16, TINT32, TINT64, TINT: + return true + } + return false +} + +func (t *Type) IsUnsigned() bool { + switch t.kind { + case TUINT8, TUINT16, TUINT32, TUINT64, TUINT, TUINTPTR: + return true + } + return false +} + +func (t *Type) IsFloat() bool { + return t.kind == TFLOAT32 || t.kind == TFLOAT64 || t == UntypedFloat +} + +func (t *Type) IsComplex() bool { + return t.kind == TCOMPLEX64 || t.kind == TCOMPLEX128 || t == UntypedComplex +} + +// IsPtr reports whether t is a regular Go pointer type. +// This does not include unsafe.Pointer. +func (t *Type) IsPtr() bool { + return t.kind == TPTR +} + +// IsPtrElem reports whether t is the element of a pointer (to t). +func (t *Type) IsPtrElem() bool { + return t.cache.ptr != nil +} + +// IsUnsafePtr reports whether t is an unsafe pointer. +func (t *Type) IsUnsafePtr() bool { + return t.kind == TUNSAFEPTR +} + +// IsUintptr reports whether t is a uintptr. +func (t *Type) IsUintptr() bool { + return t.kind == TUINTPTR +} + +// IsPtrShaped reports whether t is represented by a single machine pointer. +// In addition to regular Go pointer types, this includes map, channel, and +// function types and unsafe.Pointer. It does not include array or struct types +// that consist of a single pointer shaped type. +// TODO(mdempsky): Should it? See golang.org/issue/15028. +func (t *Type) IsPtrShaped() bool { + return t.kind == TPTR || t.kind == TUNSAFEPTR || + t.kind == TMAP || t.kind == TCHAN || t.kind == TFUNC +} + +// HasNil reports whether the set of values determined by t includes nil. +func (t *Type) HasNil() bool { + switch t.kind { + case TCHAN, TFUNC, TINTER, TMAP, TNIL, TPTR, TSLICE, TUNSAFEPTR: + return true + } + return false +} + +func (t *Type) IsString() bool { + return t.kind == TSTRING +} + +func (t *Type) IsMap() bool { + return t.kind == TMAP +} + +func (t *Type) IsChan() bool { + return t.kind == TCHAN +} + +func (t *Type) IsSlice() bool { + return t.kind == TSLICE +} + +func (t *Type) IsArray() bool { + return t.kind == TARRAY +} + +func (t *Type) IsStruct() bool { + return t.kind == TSTRUCT +} + +func (t *Type) IsInterface() bool { + return t.kind == TINTER +} + +// IsEmptyInterface reports whether t is an empty interface type. +func (t *Type) IsEmptyInterface() bool { + return t.IsInterface() && len(t.AllMethods()) == 0 +} + +// IsScalar reports whether 't' is a scalar Go type, e.g. +// bool/int/float/complex. Note that struct and array types consisting +// of a single scalar element are not considered scalar, likewise +// pointer types are also not considered scalar. +func (t *Type) IsScalar() bool { + switch t.kind { + case TBOOL, TINT8, TUINT8, TINT16, TUINT16, TINT32, + TUINT32, TINT64, TUINT64, TINT, TUINT, + TUINTPTR, TCOMPLEX64, TCOMPLEX128, TFLOAT32, TFLOAT64: + return true + } + return false +} + +func (t *Type) PtrTo() *Type { + return NewPtr(t) +} + +func (t *Type) NumFields() int { + if t.kind == TRESULTS { + return len(t.extra.(*Results).Types) + } + return len(t.Fields()) +} +func (t *Type) FieldType(i int) *Type { + if t.kind == TTUPLE { + switch i { + case 0: + return t.extra.(*Tuple).first + case 1: + return t.extra.(*Tuple).second + default: + panic("bad tuple index") + } + } + if t.kind == TRESULTS { + return t.extra.(*Results).Types[i] + } + return t.Field(i).Type +} +func (t *Type) FieldOff(i int) int64 { + return t.Field(i).Offset +} +func (t *Type) FieldName(i int) string { + return t.Field(i).Sym.Name +} + +// OffsetOf reports the offset of the field of a struct. +// The field is looked up by name. +func (t *Type) OffsetOf(name string) int64 { + if t.kind != TSTRUCT { + base.Fatalf("can't call OffsetOf on non-struct %v", t) + } + for _, f := range t.Fields() { + if f.Sym.Name == name { + return f.Offset + } + } + base.Fatalf("couldn't find field %s in %v", name, t) + return -1 +} + +func (t *Type) NumElem() int64 { + t.wantEtype(TARRAY) + return t.extra.(*Array).Bound +} + +type componentsIncludeBlankFields bool + +const ( + IgnoreBlankFields componentsIncludeBlankFields = false + CountBlankFields componentsIncludeBlankFields = true +) + +// NumComponents returns the number of primitive elements that compose t. +// Struct and array types are flattened for the purpose of counting. +// All other types (including string, slice, and interface types) count as one element. +// If countBlank is IgnoreBlankFields, then blank struct fields +// (and their comprised elements) are excluded from the count. +// struct { x, y [3]int } has six components; [10]struct{ x, y string } has twenty. +func (t *Type) NumComponents(countBlank componentsIncludeBlankFields) int64 { + switch t.kind { + case TSTRUCT: + if t.IsFuncArgStruct() { + base.Fatalf("NumComponents func arg struct") + } + var n int64 + for _, f := range t.Fields() { + if countBlank == IgnoreBlankFields && f.Sym.IsBlank() { + continue + } + n += f.Type.NumComponents(countBlank) + } + return n + case TARRAY: + return t.NumElem() * t.Elem().NumComponents(countBlank) + } + return 1 +} + +// SoleComponent returns the only primitive component in t, +// if there is exactly one. Otherwise, it returns nil. +// Components are counted as in NumComponents, including blank fields. +// Keep in sync with cmd/compile/internal/walk/convert.go:soleComponent. +func (t *Type) SoleComponent() *Type { + switch t.kind { + case TSTRUCT: + if t.IsFuncArgStruct() { + base.Fatalf("SoleComponent func arg struct") + } + if t.NumFields() != 1 { + return nil + } + return t.Field(0).Type.SoleComponent() + case TARRAY: + if t.NumElem() != 1 { + return nil + } + return t.Elem().SoleComponent() + } + return t +} + +// ChanDir returns the direction of a channel type t. +// The direction will be one of Crecv, Csend, or Cboth. +func (t *Type) ChanDir() ChanDir { + t.wantEtype(TCHAN) + return t.extra.(*Chan).Dir +} + +func (t *Type) IsMemory() bool { + if t == TypeMem || t.kind == TTUPLE && t.extra.(*Tuple).second == TypeMem { + return true + } + if t.kind == TRESULTS { + if types := t.extra.(*Results).Types; len(types) > 0 && types[len(types)-1] == TypeMem { + return true + } + } + return false +} +func (t *Type) IsFlags() bool { return t == TypeFlags } +func (t *Type) IsVoid() bool { return t == TypeVoid } +func (t *Type) IsTuple() bool { return t.kind == TTUPLE } +func (t *Type) IsResults() bool { return t.kind == TRESULTS } + +// IsUntyped reports whether t is an untyped type. +func (t *Type) IsUntyped() bool { + if t == nil { + return false + } + if t == UntypedString || t == UntypedBool { + return true + } + switch t.kind { + case TNIL, TIDEAL: + return true + } + return false +} + +// HasPointers reports whether t contains a heap pointer. +// Note that this function ignores pointers to not-in-heap types. +func (t *Type) HasPointers() bool { + return PtrDataSize(t) > 0 +} + +var recvType *Type + +// FakeRecvType returns the singleton type used for interface method receivers. +func FakeRecvType() *Type { + if recvType == nil { + recvType = NewPtr(newType(TSTRUCT)) + } + return recvType +} + +func FakeRecv() *Field { + return NewField(base.AutogeneratedPos, nil, FakeRecvType()) +} + +var ( + // TSSA types. HasPointers assumes these are pointer-free. + TypeInvalid = newSSA("invalid") + TypeMem = newSSA("mem") + TypeFlags = newSSA("flags") + TypeVoid = newSSA("void") + TypeInt128 = newSSA("int128") + TypeVec128 = newSIMD("vec128") + TypeVec256 = newSIMD("vec256") + TypeVec512 = newSIMD("vec512") + TypeMask = newSIMD("mask") // not a vector, not 100% sure what this should be. + TypeResultMem = newResults([]*Type{TypeMem}) +) + +func init() { + TypeInt128.width = 16 + TypeInt128.align = 8 + + TypeVec128.width = 16 + TypeVec128.align = 8 + TypeVec256.width = 32 + TypeVec256.align = 8 + TypeVec512.width = 64 + TypeVec512.align = 8 + + TypeMask.width = 8 // This will depend on the architecture; spilling will be "interesting". + TypeMask.align = 8 +} + +// NewNamed returns a new named type for the given type name. obj should be an +// ir.Name. The new type is incomplete (marked as TFORW kind), and the underlying +// type should be set later via SetUnderlying(). References to the type are +// maintained until the type is filled in, so those references can be updated when +// the type is complete. +func NewNamed(obj Object) *Type { + t := newType(TFORW) + t.obj = obj + sym := obj.Sym() + if sym.Pkg == ShapePkg { + t.SetIsShape(true) + t.SetHasShape(true) + } + if sym.Pkg.Path == "internal/runtime/sys" && sym.Name == "nih" { + // Recognize the special not-in-heap type. Any type including + // this type will also be not-in-heap. + // This logic is duplicated in go/types and + // cmd/compile/internal/types2. + t.SetNotInHeap(true) + } + return t +} + +// Obj returns the canonical type name node for a named type t, nil for an unnamed type. +func (t *Type) Obj() Object { + return t.obj +} + +// SetUnderlying sets the underlying type of an incomplete type (i.e. type whose kind +// is currently TFORW). SetUnderlying automatically updates any types that were waiting +// for this type to be completed. +func (t *Type) SetUnderlying(underlying *Type) { + if underlying.kind == TFORW { + // This type isn't computed yet; when it is, update n. + underlying.forwardType().Copyto = append(underlying.forwardType().Copyto, t) + return + } + + ft := t.forwardType() + + // TODO(mdempsky): Fix Type rekinding. + t.kind = underlying.kind + t.extra = underlying.extra + t.width = underlying.width + t.align = underlying.align + t.alg = underlying.alg + t.ptrBytes = underlying.ptrBytes + t.intRegs = underlying.intRegs + t.floatRegs = underlying.floatRegs + t.underlying = underlying.underlying + + if underlying.NotInHeap() { + t.SetNotInHeap(true) + } + if underlying.HasShape() { + t.SetHasShape(true) + } + + // spec: "The declared type does not inherit any methods bound + // to the existing type, but the method set of an interface + // type [...] remains unchanged." + if t.IsInterface() { + t.methods = underlying.methods + t.allMethods = underlying.allMethods + } + + // Update types waiting on this type. + for _, w := range ft.Copyto { + w.SetUnderlying(t) + } + + // Double-check use of type as embedded type. + if ft.Embedlineno.IsKnown() { + if t.IsPtr() || t.IsUnsafePtr() { + base.ErrorfAt(ft.Embedlineno, errors.InvalidPtrEmbed, "embedded type cannot be a pointer") + } + } +} + +func fieldsHasShape(fields []*Field) bool { + for _, f := range fields { + if f.Type != nil && f.Type.HasShape() { + return true + } + } + return false +} + +// NewInterface returns a new interface for the given methods and +// embedded types. Embedded types are specified as fields with no Sym. +func NewInterface(methods []*Field) *Type { + t := newType(TINTER) + t.SetInterface(methods) + for _, f := range methods { + // f.Type could be nil for a broken interface declaration + if f.Type != nil && f.Type.HasShape() { + t.SetHasShape(true) + break + } + } + return t +} + +// NewSignature returns a new function type for the given receiver, +// parameters, and results, any of which may be nil. +func NewSignature(recv *Field, params, results []*Field) *Type { + startParams := 0 + if recv != nil { + startParams = 1 + } + startResults := startParams + len(params) + + allParams := make([]*Field, startResults+len(results)) + if recv != nil { + allParams[0] = recv + } + copy(allParams[startParams:], params) + copy(allParams[startResults:], results) + + t := newType(TFUNC) + ft := t.funcType() + + funargs := func(fields []*Field) *Type { + s := NewStruct(fields) + s.StructType().ParamTuple = true + return s + } + + ft.allParams = allParams + ft.startParams = startParams + ft.startResults = startResults + + ft.resultsTuple = funargs(allParams[startResults:]) + + if fieldsHasShape(allParams) { + t.SetHasShape(true) + } + + return t +} + +// NewStruct returns a new struct with the given fields. +func NewStruct(fields []*Field) *Type { + t := newType(TSTRUCT) + t.setFields(fields) + if fieldsHasShape(fields) { + t.SetHasShape(true) + } + for _, f := range fields { + if f.Type.NotInHeap() { + t.SetNotInHeap(true) + break + } + } + + return t +} + +var ( + IsInt [NTYPE]bool + IsFloat [NTYPE]bool + IsComplex [NTYPE]bool + IsSimple [NTYPE]bool +) + +var IsOrdered [NTYPE]bool + +// IsReflexive reports whether t has a reflexive equality operator. +// That is, if x==x for all x of type t. +func IsReflexive(t *Type) bool { + switch t.Kind() { + case TBOOL, + TINT, + TUINT, + TINT8, + TUINT8, + TINT16, + TUINT16, + TINT32, + TUINT32, + TINT64, + TUINT64, + TUINTPTR, + TPTR, + TUNSAFEPTR, + TSTRING, + TCHAN: + return true + + case TFLOAT32, + TFLOAT64, + TCOMPLEX64, + TCOMPLEX128, + TINTER: + return false + + case TARRAY: + return IsReflexive(t.Elem()) + + case TSTRUCT: + for _, t1 := range t.Fields() { + if !IsReflexive(t1.Type) { + return false + } + } + return true + + default: + base.Fatalf("bad type for map key: %v", t) + return false + } +} + +// Can this type be stored directly in an interface word? +// Yes, if the representation is a single pointer. +func IsDirectIface(t *Type) bool { + return t.Size() == int64(PtrSize) && PtrDataSize(t) == int64(PtrSize) +} + +// IsInterfaceMethod reports whether (field) m is +// an interface method. Such methods have the +// special receiver type types.FakeRecvType(). +func IsInterfaceMethod(f *Type) bool { + return f.Recv().Type == FakeRecvType() +} + +// IsMethodApplicable reports whether method m can be called on a +// value of type t. This is necessary because we compute a single +// method set for both T and *T, but some *T methods are not +// applicable to T receivers. +func IsMethodApplicable(t *Type, m *Field) bool { + return t.IsPtr() || !m.Type.Recv().Type.IsPtr() || IsInterfaceMethod(m.Type) || m.Embedded == 2 +} + +// RuntimeSymName returns the name of s if it's in package "runtime"; otherwise +// it returns "". +func RuntimeSymName(s *Sym) string { + if s.Pkg.Path == "runtime" { + return s.Name + } + return "" +} + +// ReflectSymName returns the name of s if it's in package "reflect"; otherwise +// it returns "". +func ReflectSymName(s *Sym) string { + if s.Pkg.Path == "reflect" { + return s.Name + } + return "" +} + +// IsNoInstrumentPkg reports whether p is a package that +// should not be instrumented. +func IsNoInstrumentPkg(p *Pkg) bool { + return objabi.LookupPkgSpecial(p.Path).NoInstrument +} + +// IsNoRacePkg reports whether p is a package that +// should not be race instrumented. +func IsNoRacePkg(p *Pkg) bool { + return objabi.LookupPkgSpecial(p.Path).NoRaceFunc +} + +// IsRuntimePkg reports whether p is a runtime package. +func IsRuntimePkg(p *Pkg) bool { + return objabi.LookupPkgSpecial(p.Path).Runtime +} + +// ReceiverBaseType returns the underlying type, if any, +// that owns methods with receiver parameter t. +// The result is either a named type or an anonymous struct. +func ReceiverBaseType(t *Type) *Type { + if t == nil { + return nil + } + + // Strip away pointer if it's there. + if t.IsPtr() { + if t.Sym() != nil { + return nil + } + t = t.Elem() + if t == nil { + return nil + } + } + + // Must be a named type or anonymous struct. + if t.Sym() == nil && !t.IsStruct() { + return nil + } + + // Check types. + if IsSimple[t.Kind()] { + return t + } + switch t.Kind() { + case TARRAY, TCHAN, TFUNC, TMAP, TSLICE, TSTRING, TSTRUCT: + return t + } + return nil +} + +func FloatForComplex(t *Type) *Type { + switch t.Kind() { + case TCOMPLEX64: + return Types[TFLOAT32] + case TCOMPLEX128: + return Types[TFLOAT64] + } + base.Fatalf("unexpected type: %v", t) + return nil +} + +func ComplexForFloat(t *Type) *Type { + switch t.Kind() { + case TFLOAT32: + return Types[TCOMPLEX64] + case TFLOAT64: + return Types[TCOMPLEX128] + } + base.Fatalf("unexpected type: %v", t) + return nil +} + +func TypeSym(t *Type) *Sym { + return TypeSymLookup(TypeSymName(t)) +} + +func TypeSymLookup(name string) *Sym { + typepkgmu.Lock() + s := typepkg.Lookup(name) + typepkgmu.Unlock() + return s +} + +func TypeSymName(t *Type) string { + name := t.LinkString() + // Use a separate symbol name for Noalg types for #17752. + if TypeHasNoAlg(t) { + name = "noalg." + name + } + return name +} + +// Fake package for runtime type info (headers) +// Don't access directly, use typeLookup below. +var ( + typepkgmu sync.Mutex // protects typepkg lookups + typepkg = NewPkg("type", "type") +) + +var SimType [NTYPE]Kind + +// Fake package for shape types (see typecheck.Shapify()). +var ShapePkg = NewPkg("go.shape", "go.shape") + +func (t *Type) IsSIMD() bool { + return t.isSIMD +} diff --git a/go/src/cmd/compile/internal/types/type_test.go b/go/src/cmd/compile/internal/types/type_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1fd05b3f5e8c7677beebde97c47b622f5ac0431c --- /dev/null +++ b/go/src/cmd/compile/internal/types/type_test.go @@ -0,0 +1,27 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +import ( + "testing" +) + +func TestSSACompare(t *testing.T) { + a := []*Type{ + TypeInvalid, + TypeMem, + TypeFlags, + TypeVoid, + TypeInt128, + } + for _, x := range a { + for _, y := range a { + c := x.Compare(y) + if x == y && c != CMPeq || x != y && c == CMPeq { + t.Errorf("%s compare %s == %d\n", x.extra, y.extra, c) + } + } + } +} diff --git a/go/src/cmd/compile/internal/types/universe.go b/go/src/cmd/compile/internal/types/universe.go new file mode 100644 index 0000000000000000000000000000000000000000..d1800f217c96ad305b014a9007a8c2961b44faf5 --- /dev/null +++ b/go/src/cmd/compile/internal/types/universe.go @@ -0,0 +1,154 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +import ( + "cmd/compile/internal/base" + "cmd/internal/src" +) + +var basicTypes = [...]struct { + name string + etype Kind +}{ + {"int8", TINT8}, + {"int16", TINT16}, + {"int32", TINT32}, + {"int64", TINT64}, + {"uint8", TUINT8}, + {"uint16", TUINT16}, + {"uint32", TUINT32}, + {"uint64", TUINT64}, + {"float32", TFLOAT32}, + {"float64", TFLOAT64}, + {"complex64", TCOMPLEX64}, + {"complex128", TCOMPLEX128}, + {"bool", TBOOL}, + {"string", TSTRING}, +} + +var typedefs = [...]struct { + name string + etype Kind + sameas32 Kind + sameas64 Kind +}{ + {"int", TINT, TINT32, TINT64}, + {"uint", TUINT, TUINT32, TUINT64}, + {"uintptr", TUINTPTR, TUINT32, TUINT64}, +} + +func InitTypes(defTypeName func(sym *Sym, typ *Type) Object) { + if PtrSize == 0 { + base.Fatalf("InitTypes called before PtrSize was set") + } + + SlicePtrOffset = 0 + SliceLenOffset = RoundUp(SlicePtrOffset+int64(PtrSize), int64(PtrSize)) + SliceCapOffset = RoundUp(SliceLenOffset+int64(PtrSize), int64(PtrSize)) + SliceSize = RoundUp(SliceCapOffset+int64(PtrSize), int64(PtrSize)) + + // string is same as slice wo the cap + StringSize = RoundUp(SliceLenOffset+int64(PtrSize), int64(PtrSize)) + + for et := Kind(0); et < NTYPE; et++ { + SimType[et] = et + } + + Types[TANY] = newType(TANY) // note: an old placeholder type, NOT the new builtin 'any' alias for interface{} + Types[TINTER] = NewInterface(nil) + CheckSize(Types[TINTER]) + + defBasic := func(kind Kind, pkg *Pkg, name string) *Type { + typ := newType(kind) + obj := defTypeName(pkg.Lookup(name), typ) + typ.obj = obj + if kind != TANY { + CheckSize(typ) + } + return typ + } + + for _, s := range &basicTypes { + Types[s.etype] = defBasic(s.etype, BuiltinPkg, s.name) + } + + for _, s := range &typedefs { + sameas := s.sameas32 + if PtrSize == 8 { + sameas = s.sameas64 + } + SimType[s.etype] = sameas + + Types[s.etype] = defBasic(s.etype, BuiltinPkg, s.name) + } + + // We create separate byte and rune types for better error messages + // rather than just creating type alias *Sym's for the uint8 and + // int32 Hence, (bytetype|runtype).Sym.isAlias() is false. + // TODO(gri) Should we get rid of this special case (at the cost + // of less informative error messages involving bytes and runes)? + // NOTE(rsc): No, the error message quality is important. + // (Alternatively, we could introduce an OTALIAS node representing + // type aliases, albeit at the cost of having to deal with it everywhere). + ByteType = defBasic(TUINT8, BuiltinPkg, "byte") + RuneType = defBasic(TINT32, BuiltinPkg, "rune") + + // error type + DeferCheckSize() + ErrorType = defBasic(TFORW, BuiltinPkg, "error") + ErrorType.SetUnderlying(makeErrorInterface()) + ResumeCheckSize() + + // comparable type (interface) + DeferCheckSize() + ComparableType = defBasic(TFORW, BuiltinPkg, "comparable") + ComparableType.SetUnderlying(makeComparableInterface()) + ResumeCheckSize() + + // any type (interface) + DeferCheckSize() + AnyType = defBasic(TFORW, BuiltinPkg, "any") + AnyType.SetUnderlying(NewInterface(nil)) + ResumeCheckSize() + + Types[TUNSAFEPTR] = defBasic(TUNSAFEPTR, UnsafePkg, "Pointer") + + Types[TBLANK] = newType(TBLANK) + Types[TNIL] = newType(TNIL) + + // simple aliases + SimType[TMAP] = TPTR + SimType[TCHAN] = TPTR + SimType[TFUNC] = TPTR + SimType[TUNSAFEPTR] = TPTR + + for et := TINT8; et <= TUINT64; et++ { + IsInt[et] = true + } + IsInt[TINT] = true + IsInt[TUINT] = true + IsInt[TUINTPTR] = true + + IsFloat[TFLOAT32] = true + IsFloat[TFLOAT64] = true + + IsComplex[TCOMPLEX64] = true + IsComplex[TCOMPLEX128] = true +} + +func makeErrorInterface() *Type { + sig := NewSignature(FakeRecv(), nil, []*Field{ + NewField(src.NoXPos, nil, Types[TSTRING]), + }) + method := NewField(src.NoXPos, LocalPkg.Lookup("Error"), sig) + return NewInterface([]*Field{method}) +} + +// makeComparableInterface makes the predefined "comparable" interface in the +// built-in package. It has a unique name, but no methods. +func makeComparableInterface() *Type { + return NewInterface(nil) +} diff --git a/go/src/cmd/compile/internal/types/utils.go b/go/src/cmd/compile/internal/types/utils.go new file mode 100644 index 0000000000000000000000000000000000000000..f9f629ca3ea6cf5bd878387b6cab1a7892e1685b --- /dev/null +++ b/go/src/cmd/compile/internal/types/utils.go @@ -0,0 +1,17 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types + +const BADWIDTH = -1000000000 + +type bitset8 uint8 + +func (f *bitset8) set(mask uint8, b bool) { + if b { + *(*uint8)(f) |= mask + } else { + *(*uint8)(f) &^= mask + } +} diff --git a/go/src/cmd/compile/internal/types2/alias.go b/go/src/cmd/compile/internal/types2/alias.go new file mode 100644 index 0000000000000000000000000000000000000000..d306600ebd2710eb975fc9212432ad49390f1b7b --- /dev/null +++ b/go/src/cmd/compile/internal/types2/alias.go @@ -0,0 +1,166 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2 + +import ( + "cmd/compile/internal/syntax" +) + +// An Alias represents an alias type. +// +// Alias types are created by alias declarations such as: +// +// type A = int +// +// The type on the right-hand side of the declaration can be accessed +// using [Alias.Rhs]. This type may itself be an alias. +// Call [Unalias] to obtain the first non-alias type in a chain of +// alias type declarations. +// +// Like a defined ([Named]) type, an alias type has a name. +// Use the [Alias.Obj] method to access its [TypeName] object. +// +// Historically, Alias types were not materialized so that, in the example +// above, A's type was represented by a Basic (int), not an Alias +// whose [Alias.Rhs] is int. But Go 1.24 allows you to declare an +// alias type with type parameters or arguments: +// +// type Set[K comparable] = map[K]bool +// s := make(Set[String]) +// +// and this requires that Alias types be materialized. Use the +// [Alias.TypeParams] and [Alias.TypeArgs] methods to access them. +// +// To ease the transition, the Alias type was introduced in go1.22, +// but the type-checker would not construct values of this type unless +// the GODEBUG=gotypesalias=1 environment variable was provided. +// Starting in go1.23, this variable is enabled by default. +// This setting also causes the predeclared type "any" to be +// represented as an Alias, not a bare [Interface]. +type Alias struct { + obj *TypeName // corresponding declared alias object + orig *Alias // original, uninstantiated alias + tparams *TypeParamList // type parameters, or nil + targs *TypeList // type arguments, or nil + fromRHS Type // RHS of type alias declaration; may be an alias + actual Type // actual (aliased) type; never an alias +} + +// NewAlias creates a new Alias type with the given type name and rhs. +// If rhs is nil, the alias is incomplete. +func NewAlias(obj *TypeName, rhs Type) *Alias { + alias := (*Checker)(nil).newAlias(obj, rhs) + // Ensure that alias.actual is set (#65455). + alias.cleanup() + return alias +} + +// Obj returns the type name for the declaration defining the alias type a. +// For instantiated types, this is same as the type name of the origin type. +func (a *Alias) Obj() *TypeName { return a.orig.obj } + +func (a *Alias) String() string { return TypeString(a, nil) } + +// Underlying returns the [underlying type] of the alias type a, which is the +// underlying type of the aliased type. Underlying types are never Named, +// TypeParam, or Alias types. +// +// [underlying type]: https://go.dev/ref/spec#Underlying_types. +func (a *Alias) Underlying() Type { return unalias(a).Underlying() } + +// Origin returns the generic Alias type of which a is an instance. +// If a is not an instance of a generic alias, Origin returns a. +func (a *Alias) Origin() *Alias { return a.orig } + +// TypeParams returns the type parameters of the alias type a, or nil. +// A generic Alias and its instances have the same type parameters. +func (a *Alias) TypeParams() *TypeParamList { return a.tparams } + +// SetTypeParams sets the type parameters of the alias type a. +// The alias a must not have type arguments. +func (a *Alias) SetTypeParams(tparams []*TypeParam) { + assert(a.targs == nil) + a.tparams = bindTParams(tparams) +} + +// TypeArgs returns the type arguments used to instantiate the Alias type. +// If a is not an instance of a generic alias, the result is nil. +func (a *Alias) TypeArgs() *TypeList { return a.targs } + +// Rhs returns the type R on the right-hand side of an alias +// declaration "type A = R", which may be another alias. +func (a *Alias) Rhs() Type { return a.fromRHS } + +// Unalias returns t if it is not an alias type; +// otherwise it follows t's alias chain until it +// reaches a non-alias type which is then returned. +// Consequently, the result is never an alias type. +// Returns nil if the alias is incomplete. +func Unalias(t Type) Type { + if a0, _ := t.(*Alias); a0 != nil { + return unalias(a0) + } + return t +} + +func unalias(a0 *Alias) Type { + if a0.actual != nil { + return a0.actual + } + var t Type + for a := a0; a != nil; a, _ = t.(*Alias) { + t = a.fromRHS + } + // It's fine to memoize nil types since it's the zero value for actual. + // It accomplishes nothing. + a0.actual = t + return t +} + +// asNamed returns t as *Named if that is t's +// actual type. It returns nil otherwise. +func asNamed(t Type) *Named { + n, _ := Unalias(t).(*Named) + return n +} + +// newAlias creates a new Alias type with the given type name and rhs. +// If rhs is nil, the alias is incomplete. +func (check *Checker) newAlias(obj *TypeName, rhs Type) *Alias { + a := new(Alias) + a.obj = obj + a.orig = a + a.fromRHS = rhs + if obj.typ == nil { + obj.typ = a + } + + // Ensure that a.actual is set at the end of type checking. + if check != nil { + check.needsCleanup(a) + } + + return a +} + +// newAliasInstance creates a new alias instance for the given origin and type +// arguments, recording pos as the position of its synthetic object (for error +// reporting). +func (check *Checker) newAliasInstance(pos syntax.Pos, orig *Alias, targs []Type, expanding *Named, ctxt *Context) *Alias { + assert(len(targs) > 0) + obj := NewTypeName(pos, orig.obj.pkg, orig.obj.name, nil) + rhs := check.subst(pos, orig.fromRHS, makeSubstMap(orig.TypeParams().list(), targs), expanding, ctxt) + res := check.newAlias(obj, rhs) + res.orig = orig + res.tparams = orig.tparams + res.targs = newTypeList(targs) + return res +} + +func (a *Alias) cleanup() { + // Ensure a.actual is set before types are published, + // so unalias is a pure "getter", not a "setter". + unalias(a) +} diff --git a/go/src/cmd/compile/internal/types2/api.go b/go/src/cmd/compile/internal/types2/api.go new file mode 100644 index 0000000000000000000000000000000000000000..8752eff99212e66802fe74ec53167ba063536bfd --- /dev/null +++ b/go/src/cmd/compile/internal/types2/api.go @@ -0,0 +1,485 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package types2 declares the data types and implements +// the algorithms for type-checking of Go packages. Use +// Config.Check to invoke the type checker for a package. +// Alternatively, create a new type checker with NewChecker +// and invoke it incrementally by calling Checker.Files. +// +// Type-checking consists of several interdependent phases: +// +// Name resolution maps each identifier (syntax.Name) in the program to the +// language object (Object) it denotes. +// Use Info.{Defs,Uses,Implicits} for the results of name resolution. +// +// Constant folding computes the exact constant value (constant.Value) +// for every expression (syntax.Expr) that is a compile-time constant. +// Use Info.Types[expr].Value for the results of constant folding. +// +// Type inference computes the type (Type) of every expression (syntax.Expr) +// and checks for compliance with the language specification. +// Use Info.Types[expr].Type for the results of type inference. +package types2 + +import ( + "cmd/compile/internal/syntax" + "fmt" + "go/constant" + . "internal/types/errors" + "strings" +) + +// An Error describes a type-checking error; it implements the error interface. +// A "soft" error is an error that still permits a valid interpretation of a +// package (such as "unused variable"); "hard" errors may lead to unpredictable +// behavior if ignored. +type Error struct { + Pos syntax.Pos // error position + Msg string // default error message, user-friendly + Full string // full error message, for debugging (may contain internal details) + Soft bool // if set, error is "soft" + Code Code // error code +} + +// Error returns an error string formatted as follows: +// filename:line:column: message +func (err Error) Error() string { + return fmt.Sprintf("%s: %s", err.Pos, err.Msg) +} + +// FullError returns an error string like Error, buy it may contain +// type-checker internal details such as subscript indices for type +// parameters and more. Useful for debugging. +func (err Error) FullError() string { + return fmt.Sprintf("%s: %s", err.Pos, err.Full) +} + +// An ArgumentError holds an error associated with an argument index. +type ArgumentError struct { + Index int + Err error +} + +func (e *ArgumentError) Error() string { return e.Err.Error() } +func (e *ArgumentError) Unwrap() error { return e.Err } + +// An Importer resolves import paths to Packages. +// +// CAUTION: This interface does not support the import of locally +// vendored packages. See https://golang.org/s/go15vendor. +// If possible, external implementations should implement ImporterFrom. +type Importer interface { + // Import returns the imported package for the given import path. + // The semantics is like for ImporterFrom.ImportFrom except that + // dir and mode are ignored (since they are not present). + Import(path string) (*Package, error) +} + +// ImportMode is reserved for future use. +type ImportMode int + +// An ImporterFrom resolves import paths to packages; it +// supports vendoring per https://golang.org/s/go15vendor. +// Use go/importer to obtain an ImporterFrom implementation. +type ImporterFrom interface { + // Importer is present for backward-compatibility. Calling + // Import(path) is the same as calling ImportFrom(path, "", 0); + // i.e., locally vendored packages may not be found. + // The types package does not call Import if an ImporterFrom + // is present. + Importer + + // ImportFrom returns the imported package for the given import + // path when imported by a package file located in dir. + // If the import failed, besides returning an error, ImportFrom + // is encouraged to cache and return a package anyway, if one + // was created. This will reduce package inconsistencies and + // follow-on type checker errors due to the missing package. + // The mode value must be 0; it is reserved for future use. + // Two calls to ImportFrom with the same path and dir must + // return the same package. + ImportFrom(path, dir string, mode ImportMode) (*Package, error) +} + +// A Config specifies the configuration for type checking. +// The zero value for Config is a ready-to-use default configuration. +type Config struct { + // Context is the context used for resolving global identifiers. If nil, the + // type checker will initialize this field with a newly created context. + Context *Context + + // GoVersion describes the accepted Go language version. The string must + // start with a prefix of the form "go%d.%d" (e.g. "go1.20", "go1.21rc1", or + // "go1.21.0") or it must be empty; an empty string disables Go language + // version checks. If the format is invalid, invoking the type checker will + // result in an error. + GoVersion string + + // If IgnoreFuncBodies is set, function bodies are not + // type-checked. + IgnoreFuncBodies bool + + // If FakeImportC is set, `import "C"` (for packages requiring Cgo) + // declares an empty "C" package and errors are omitted for qualified + // identifiers referring to package C (which won't find an object). + // This feature is intended for the standard library cmd/api tool. + // + // Caution: Effects may be unpredictable due to follow-on errors. + // Do not use casually! + FakeImportC bool + + // If IgnoreBranchErrors is set, branch/label errors are ignored. + IgnoreBranchErrors bool + + // If go115UsesCgo is set, the type checker expects the + // _cgo_gotypes.go file generated by running cmd/cgo to be + // provided as a package source file. Qualified identifiers + // referring to package C will be resolved to cgo-provided + // declarations within _cgo_gotypes.go. + // + // It is an error to set both FakeImportC and go115UsesCgo. + go115UsesCgo bool + + // If Trace is set, a debug trace is printed to stdout. + Trace bool + + // If Error != nil, it is called with each error found + // during type checking; err has dynamic type Error. + // Secondary errors (for instance, to enumerate all types + // involved in an invalid recursive type declaration) have + // error strings that start with a '\t' character. + // If Error == nil, type-checking stops with the first + // error found. + Error func(err error) + + // An importer is used to import packages referred to from + // import declarations. + // If the installed importer implements ImporterFrom, the type + // checker calls ImportFrom instead of Import. + // The type checker reports an error if an importer is needed + // but none was installed. + Importer Importer + + // If Sizes != nil, it provides the sizing functions for package unsafe. + // Otherwise SizesFor("gc", "amd64") is used instead. + Sizes Sizes + + // If DisableUnusedImportCheck is set, packages are not checked + // for unused imports. + DisableUnusedImportCheck bool + + // If a non-empty ErrorURL format string is provided, it is used + // to format an error URL link that is appended to the first line + // of an error message. ErrorURL must be a format string containing + // exactly one "%s" format, e.g. "[go.dev/e/%s]". + ErrorURL string + + // If EnableAlias is set, alias declarations produce an Alias type. Otherwise + // the alias information is only in the type name, which points directly to + // the actual (aliased) type. + // + // This setting must not differ among concurrent type-checking operations, + // since it affects the behavior of Universe.Lookup("any"). + // + // This flag will eventually be removed (with Go 1.24 at the earliest). + EnableAlias bool +} + +// Info holds result type information for a type-checked package. +// Only the information for which a map is provided is collected. +// If the package has type errors, the collected information may +// be incomplete. +type Info struct { + // Types maps expressions to their types, and for constant + // expressions, also their values. Invalid expressions are + // omitted. + // + // For (possibly parenthesized) identifiers denoting built-in + // functions, the recorded signatures are call-site specific: + // if the call result is not a constant, the recorded type is + // an argument-specific signature. Otherwise, the recorded type + // is invalid. + // + // The Types map does not record the type of every identifier, + // only those that appear where an arbitrary expression is + // permitted. For instance: + // - an identifier f in a selector expression x.f is found + // only in the Selections map; + // - an identifier z in a variable declaration 'var z int' + // is found only in the Defs map; + // - an identifier p denoting a package in a qualified + // identifier p.X is found only in the Uses map. + // + // Similarly, no type is recorded for the (synthetic) FuncType + // node in a FuncDecl.Type field, since there is no corresponding + // syntactic function type expression in the source in this case + // Instead, the function type is found in the Defs.map entry for + // the corresponding function declaration. + Types map[syntax.Expr]TypeAndValue + + // If StoreTypesInSyntax is set, type information identical to + // that which would be put in the Types map, will be set in + // syntax.Expr.TypeAndValue (independently of whether Types + // is nil or not). + StoreTypesInSyntax bool + + // Instances maps identifiers denoting generic types or functions to their + // type arguments and instantiated type. + // + // For example, Instances will map the identifier for 'T' in the type + // instantiation T[int, string] to the type arguments [int, string] and + // resulting instantiated *Named type. Given a generic function + // func F[A any](A), Instances will map the identifier for 'F' in the call + // expression F(int(1)) to the inferred type arguments [int], and resulting + // instantiated *Signature. + // + // Invariant: Instantiating Uses[id].Type() with Instances[id].TypeArgs + // results in an equivalent of Instances[id].Type. + Instances map[*syntax.Name]Instance + + // Defs maps identifiers to the objects they define (including + // package names, dots "." of dot-imports, and blank "_" identifiers). + // For identifiers that do not denote objects (e.g., the package name + // in package clauses, or symbolic variables t in t := x.(type) of + // type switch headers), the corresponding objects are nil. + // + // For an embedded field, Defs returns the field *Var it defines. + // + // Invariant: Defs[id] == nil || Defs[id].Pos() == id.Pos() + Defs map[*syntax.Name]Object + + // Uses maps identifiers to the objects they denote. + // + // For an embedded field, Uses returns the *TypeName it denotes. + // + // Invariant: Uses[id].Pos() != id.Pos() + Uses map[*syntax.Name]Object + + // Implicits maps nodes to their implicitly declared objects, if any. + // The following node and object types may appear: + // + // node declared object + // + // *syntax.ImportDecl *PkgName for imports without renames + // *syntax.CaseClause type-specific *Var for each type switch case clause (incl. default) + // *syntax.Field anonymous parameter *Var (incl. unnamed results) + // + Implicits map[syntax.Node]Object + + // Selections maps selector expressions (excluding qualified identifiers) + // to their corresponding selections. + Selections map[*syntax.SelectorExpr]*Selection + + // Scopes maps syntax.Nodes to the scopes they define. Package scopes are not + // associated with a specific node but with all files belonging to a package. + // Thus, the package scope can be found in the type-checked Package object. + // Scopes nest, with the Universe scope being the outermost scope, enclosing + // the package scope, which contains (one or more) files scopes, which enclose + // function scopes which in turn enclose statement and function literal scopes. + // Note that even though package-level functions are declared in the package + // scope, the function scopes are embedded in the file scope of the file + // containing the function declaration. + // + // The Scope of a function contains the declarations of any + // type parameters, parameters, and named results, plus any + // local declarations in the body block. + // It is coextensive with the complete extent of the + // function's syntax ([*ast.FuncDecl] or [*ast.FuncLit]). + // The Scopes mapping does not contain an entry for the + // function body ([*ast.BlockStmt]); the function's scope is + // associated with the [*ast.FuncType]. + // + // The following node types may appear in Scopes: + // + // *syntax.File + // *syntax.FuncType + // *syntax.TypeDecl + // *syntax.BlockStmt + // *syntax.IfStmt + // *syntax.SwitchStmt + // *syntax.CaseClause + // *syntax.CommClause + // *syntax.ForStmt + // + Scopes map[syntax.Node]*Scope + + // InitOrder is the list of package-level initializers in the order in which + // they must be executed. Initializers referring to variables related by an + // initialization dependency appear in topological order, the others appear + // in source order. Variables without an initialization expression do not + // appear in this list. + InitOrder []*Initializer + + // FileVersions maps a file to its Go version string. + // If the file doesn't specify a version, the reported + // string is Config.GoVersion. + // Version strings begin with “go”, like “go1.21”, and + // are suitable for use with the [go/version] package. + FileVersions map[*syntax.PosBase]string +} + +func (info *Info) recordTypes() bool { + return info.Types != nil || info.StoreTypesInSyntax +} + +// TypeOf returns the type of expression e, or nil if not found. +// Precondition 1: the Types map is populated or StoreTypesInSyntax is set. +// Precondition 2: Uses and Defs maps are populated. +func (info *Info) TypeOf(e syntax.Expr) Type { + if info.Types != nil { + if t, ok := info.Types[e]; ok { + return t.Type + } + } else if info.StoreTypesInSyntax { + if tv := e.GetTypeInfo(); tv.Type != nil { + return tv.Type + } + } + + if id, _ := e.(*syntax.Name); id != nil { + if obj := info.ObjectOf(id); obj != nil { + return obj.Type() + } + } + return nil +} + +// ObjectOf returns the object denoted by the specified id, +// or nil if not found. +// +// If id is an embedded struct field, ObjectOf returns the field (*Var) +// it defines, not the type (*TypeName) it uses. +// +// Precondition: the Uses and Defs maps are populated. +func (info *Info) ObjectOf(id *syntax.Name) Object { + if obj := info.Defs[id]; obj != nil { + return obj + } + return info.Uses[id] +} + +// PkgNameOf returns the local package name defined by the import, +// or nil if not found. +// +// For dot-imports, the package name is ".". +// +// Precondition: the Defs and Implicts maps are populated. +func (info *Info) PkgNameOf(imp *syntax.ImportDecl) *PkgName { + var obj Object + if imp.LocalPkgName != nil { + obj = info.Defs[imp.LocalPkgName] + } else { + obj = info.Implicits[imp] + } + pkgname, _ := obj.(*PkgName) + return pkgname +} + +// TypeAndValue reports the type and value (for constants) +// of the corresponding expression. +type TypeAndValue struct { + mode operandMode + Type Type + Value constant.Value +} + +// IsVoid reports whether the corresponding expression +// is a function call without results. +func (tv TypeAndValue) IsVoid() bool { + return tv.mode == novalue +} + +// IsType reports whether the corresponding expression specifies a type. +func (tv TypeAndValue) IsType() bool { + return tv.mode == typexpr +} + +// IsBuiltin reports whether the corresponding expression denotes +// a (possibly parenthesized) built-in function. +func (tv TypeAndValue) IsBuiltin() bool { + return tv.mode == builtin +} + +// IsValue reports whether the corresponding expression is a value. +// Builtins are not considered values. Constant values have a non- +// nil Value. +func (tv TypeAndValue) IsValue() bool { + switch tv.mode { + case constant_, variable, mapindex, value, nilvalue, commaok, commaerr: + return true + } + return false +} + +// IsNil reports whether the corresponding expression denotes the +// predeclared value nil. Depending on context, it may have been +// given a type different from UntypedNil. +func (tv TypeAndValue) IsNil() bool { + return tv.mode == nilvalue +} + +// Addressable reports whether the corresponding expression +// is addressable (https://golang.org/ref/spec#Address_operators). +func (tv TypeAndValue) Addressable() bool { + return tv.mode == variable +} + +// Assignable reports whether the corresponding expression +// is assignable to (provided a value of the right type). +func (tv TypeAndValue) Assignable() bool { + return tv.mode == variable || tv.mode == mapindex +} + +// HasOk reports whether the corresponding expression may be +// used on the rhs of a comma-ok assignment. +func (tv TypeAndValue) HasOk() bool { + return tv.mode == commaok || tv.mode == mapindex +} + +// Instance reports the type arguments and instantiated type for type and +// function instantiations. For type instantiations, Type will be of dynamic +// type *Named. For function instantiations, Type will be of dynamic type +// *Signature. +type Instance struct { + TypeArgs *TypeList + Type Type +} + +// An Initializer describes a package-level variable, or a list of variables in case +// of a multi-valued initialization expression, and the corresponding initialization +// expression. +type Initializer struct { + Lhs []*Var // var Lhs = Rhs + Rhs syntax.Expr +} + +func (init *Initializer) String() string { + var buf strings.Builder + for i, lhs := range init.Lhs { + if i > 0 { + buf.WriteString(", ") + } + buf.WriteString(lhs.Name()) + } + buf.WriteString(" = ") + syntax.Fprint(&buf, init.Rhs, syntax.ShortForm) + return buf.String() +} + +// Check type-checks a package and returns the resulting package object and +// the first error if any. Additionally, if info != nil, Check populates each +// of the non-nil maps in the Info struct. +// +// The package is marked as complete if no errors occurred, otherwise it is +// incomplete. See Config.Error for controlling behavior in the presence of +// errors. +// +// The package is specified by a list of *syntax.Files and corresponding +// file set, and the package path the package is identified with. +// The clean path must not be empty or dot ("."). +func (conf *Config) Check(path string, files []*syntax.File, info *Info) (*Package, error) { + pkg := NewPackage(path, "") + return pkg, NewChecker(conf, pkg, info).Files(files) +} diff --git a/go/src/cmd/compile/internal/types2/api_predicates.go b/go/src/cmd/compile/internal/types2/api_predicates.go new file mode 100644 index 0000000000000000000000000000000000000000..d2473804c067a66a44d2bc0667122e38a434c629 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/api_predicates.go @@ -0,0 +1,96 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements exported type predicates. + +package types2 + +// AssertableTo reports whether a value of type V can be asserted to have type T. +// +// The behavior of AssertableTo is unspecified in three cases: +// - if T is Typ[Invalid] +// - if V is a generalized interface; i.e., an interface that may only be used +// as a type constraint in Go code +// - if T is an uninstantiated generic type +func AssertableTo(V *Interface, T Type) bool { + // Checker.newAssertableTo suppresses errors for invalid types, so we need special + // handling here. + if !isValid(T.Underlying()) { + return false + } + return (*Checker)(nil).newAssertableTo(V, T, nil) +} + +// AssignableTo reports whether a value of type V is assignable to a variable +// of type T. +// +// The behavior of AssignableTo is unspecified if V or T is Typ[Invalid] or an +// uninstantiated generic type. +func AssignableTo(V, T Type) bool { + x := operand{mode: value, typ: V} + ok, _ := x.assignableTo(nil, T, nil) // check not needed for non-constant x + return ok +} + +// ConvertibleTo reports whether a value of type V is convertible to a value of +// type T. +// +// The behavior of ConvertibleTo is unspecified if V or T is Typ[Invalid] or an +// uninstantiated generic type. +func ConvertibleTo(V, T Type) bool { + x := operand{mode: value, typ: V} + return x.convertibleTo(nil, T, nil) // check not needed for non-constant x +} + +// Implements reports whether type V implements interface T. +// +// The behavior of Implements is unspecified if V is Typ[Invalid] or an uninstantiated +// generic type. +func Implements(V Type, T *Interface) bool { + if T.Empty() { + // All types (even Typ[Invalid]) implement the empty interface. + return true + } + // Checker.implements suppresses errors for invalid types, so we need special + // handling here. + if !isValid(V.Underlying()) { + return false + } + return (*Checker)(nil).implements(V, T, false, nil) +} + +// Satisfies reports whether type V satisfies the constraint T. +// +// The behavior of Satisfies is unspecified if V is Typ[Invalid] or an uninstantiated +// generic type. +func Satisfies(V Type, T *Interface) bool { + return (*Checker)(nil).implements(V, T, true, nil) +} + +// Identical reports whether x and y are identical types. +// Receivers of [Signature] types are ignored. +// +// Predicates such as [Identical], [Implements], and +// [Satisfies] assume that both operands belong to a +// consistent collection of symbols ([Object] values). +// For example, two [Named] types can be identical only if their +// [Named.Obj] methods return the same [TypeName] symbol. +// A collection of symbols is consistent if, for each logical +// package whose path is P, the creation of those symbols +// involved at most one call to [NewPackage](P, ...). +// To ensure consistency, use a single [Importer] for +// all loaded packages and their dependencies. +// For more information, see https://github.com/golang/go/issues/57497. +func Identical(x, y Type) bool { + var c comparer + return c.identical(x, y, nil) +} + +// IdenticalIgnoreTags reports whether x and y are identical types if tags are ignored. +// Receivers of [Signature] types are ignored. +func IdenticalIgnoreTags(x, y Type) bool { + var c comparer + c.ignoreTags = true + return c.identical(x, y, nil) +} diff --git a/go/src/cmd/compile/internal/types2/api_test.go b/go/src/cmd/compile/internal/types2/api_test.go new file mode 100644 index 0000000000000000000000000000000000000000..4b7012e6c45e9f96a94a5763a126c0d5ea48b306 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/api_test.go @@ -0,0 +1,3114 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2_test + +import ( + "cmd/compile/internal/syntax" + "errors" + "fmt" + "internal/goversion" + "internal/testenv" + "slices" + "sort" + "strings" + "sync" + "testing" + + . "cmd/compile/internal/types2" +) + +// nopos indicates an unknown position +var nopos syntax.Pos + +func mustParse(src string) *syntax.File { + f, err := syntax.Parse(syntax.NewFileBase(pkgName(src)), strings.NewReader(src), nil, nil, 0) + if err != nil { + panic(err) // so we don't need to pass *testing.T + } + return f +} + +func typecheck(src string, conf *Config, info *Info) (*Package, error) { + f := mustParse(src) + if conf == nil { + conf = &Config{ + Error: func(err error) {}, // collect all errors + Importer: defaultImporter(), + } + } + return conf.Check(f.PkgName.Value, []*syntax.File{f}, info) +} + +func mustTypecheck(src string, conf *Config, info *Info) *Package { + pkg, err := typecheck(src, conf, info) + if err != nil { + panic(err) // so we don't need to pass *testing.T + } + return pkg +} + +// pkgName extracts the package name from src, which must contain a package header. +func pkgName(src string) string { + const kw = "package " + if i := strings.Index(src, kw); i >= 0 { + after := src[i+len(kw):] + n := len(after) + if i := strings.IndexAny(after, "\n\t ;/"); i >= 0 { + n = i + } + return after[:n] + } + panic("missing package header: " + src) +} + +func TestValuesInfo(t *testing.T) { + var tests = []struct { + src string + expr string // constant expression + typ string // constant type + val string // constant value + }{ + {`package a0; const _ = false`, `false`, `untyped bool`, `false`}, + {`package a1; const _ = 0`, `0`, `untyped int`, `0`}, + {`package a2; const _ = 'A'`, `'A'`, `untyped rune`, `65`}, + {`package a3; const _ = 0.`, `0.`, `untyped float`, `0`}, + {`package a4; const _ = 0i`, `0i`, `untyped complex`, `(0 + 0i)`}, + {`package a5; const _ = "foo"`, `"foo"`, `untyped string`, `"foo"`}, + + {`package b0; var _ = false`, `false`, `bool`, `false`}, + {`package b1; var _ = 0`, `0`, `int`, `0`}, + {`package b2; var _ = 'A'`, `'A'`, `rune`, `65`}, + {`package b3; var _ = 0.`, `0.`, `float64`, `0`}, + {`package b4; var _ = 0i`, `0i`, `complex128`, `(0 + 0i)`}, + {`package b5; var _ = "foo"`, `"foo"`, `string`, `"foo"`}, + + {`package c0a; var _ = bool(false)`, `false`, `bool`, `false`}, + {`package c0b; var _ = bool(false)`, `bool(false)`, `bool`, `false`}, + {`package c0c; type T bool; var _ = T(false)`, `T(false)`, `c0c.T`, `false`}, + + {`package c1a; var _ = int(0)`, `0`, `int`, `0`}, + {`package c1b; var _ = int(0)`, `int(0)`, `int`, `0`}, + {`package c1c; type T int; var _ = T(0)`, `T(0)`, `c1c.T`, `0`}, + + {`package c2a; var _ = rune('A')`, `'A'`, `rune`, `65`}, + {`package c2b; var _ = rune('A')`, `rune('A')`, `rune`, `65`}, + {`package c2c; type T rune; var _ = T('A')`, `T('A')`, `c2c.T`, `65`}, + + {`package c3a; var _ = float32(0.)`, `0.`, `float32`, `0`}, + {`package c3b; var _ = float32(0.)`, `float32(0.)`, `float32`, `0`}, + {`package c3c; type T float32; var _ = T(0.)`, `T(0.)`, `c3c.T`, `0`}, + + {`package c4a; var _ = complex64(0i)`, `0i`, `complex64`, `(0 + 0i)`}, + {`package c4b; var _ = complex64(0i)`, `complex64(0i)`, `complex64`, `(0 + 0i)`}, + {`package c4c; type T complex64; var _ = T(0i)`, `T(0i)`, `c4c.T`, `(0 + 0i)`}, + + {`package c5a; var _ = string("foo")`, `"foo"`, `string`, `"foo"`}, + {`package c5b; var _ = string("foo")`, `string("foo")`, `string`, `"foo"`}, + {`package c5c; type T string; var _ = T("foo")`, `T("foo")`, `c5c.T`, `"foo"`}, + {`package c5d; var _ = string(65)`, `65`, `untyped int`, `65`}, + {`package c5e; var _ = string('A')`, `'A'`, `untyped rune`, `65`}, + {`package c5f; type T string; var _ = T('A')`, `'A'`, `untyped rune`, `65`}, + + {`package d0; var _ = []byte("foo")`, `"foo"`, `string`, `"foo"`}, + {`package d1; var _ = []byte(string("foo"))`, `"foo"`, `string`, `"foo"`}, + {`package d2; var _ = []byte(string("foo"))`, `string("foo")`, `string`, `"foo"`}, + {`package d3; type T []byte; var _ = T("foo")`, `"foo"`, `string`, `"foo"`}, + + {`package e0; const _ = float32( 1e-200)`, `float32(1e-200)`, `float32`, `0`}, + {`package e1; const _ = float32(-1e-200)`, `float32(-1e-200)`, `float32`, `0`}, + {`package e2; const _ = float64( 1e-2000)`, `float64(1e-2000)`, `float64`, `0`}, + {`package e3; const _ = float64(-1e-2000)`, `float64(-1e-2000)`, `float64`, `0`}, + {`package e4; const _ = complex64( 1e-200)`, `complex64(1e-200)`, `complex64`, `(0 + 0i)`}, + {`package e5; const _ = complex64(-1e-200)`, `complex64(-1e-200)`, `complex64`, `(0 + 0i)`}, + {`package e6; const _ = complex128( 1e-2000)`, `complex128(1e-2000)`, `complex128`, `(0 + 0i)`}, + {`package e7; const _ = complex128(-1e-2000)`, `complex128(-1e-2000)`, `complex128`, `(0 + 0i)`}, + + {`package f0 ; var _ float32 = 1e-200`, `1e-200`, `float32`, `0`}, + {`package f1 ; var _ float32 = -1e-200`, `-1e-200`, `float32`, `0`}, + {`package f2a; var _ float64 = 1e-2000`, `1e-2000`, `float64`, `0`}, + {`package f3a; var _ float64 = -1e-2000`, `-1e-2000`, `float64`, `0`}, + {`package f2b; var _ = 1e-2000`, `1e-2000`, `float64`, `0`}, + {`package f3b; var _ = -1e-2000`, `-1e-2000`, `float64`, `0`}, + {`package f4 ; var _ complex64 = 1e-200 `, `1e-200`, `complex64`, `(0 + 0i)`}, + {`package f5 ; var _ complex64 = -1e-200 `, `-1e-200`, `complex64`, `(0 + 0i)`}, + {`package f6a; var _ complex128 = 1e-2000i`, `1e-2000i`, `complex128`, `(0 + 0i)`}, + {`package f7a; var _ complex128 = -1e-2000i`, `-1e-2000i`, `complex128`, `(0 + 0i)`}, + {`package f6b; var _ = 1e-2000i`, `1e-2000i`, `complex128`, `(0 + 0i)`}, + {`package f7b; var _ = -1e-2000i`, `-1e-2000i`, `complex128`, `(0 + 0i)`}, + + {`package g0; const (a = len([iota]int{}); b; c); const _ = c`, `c`, `int`, `2`}, // go.dev/issue/22341 + {`package g1; var(j int32; s int; n = 1.0< 1 { + t.Errorf("package %s: %d Implicits entries found", name, len(info.Implicits)) + continue + } + + // extract Implicits entry, if any + var got string + for n, obj := range info.Implicits { + switch x := n.(type) { + case *syntax.ImportDecl: + got = "importSpec" + case *syntax.CaseClause: + got = "caseClause" + case *syntax.Field: + got = "field" + default: + t.Fatalf("package %s: unexpected %T", name, x) + } + got += ": " + obj.String() + } + + // verify entry + if got != test.want { + t.Errorf("package %s: got %q; want %q", name, got, test.want) + } + } +} + +func TestPkgNameOf(t *testing.T) { + testenv.MustHaveGoBuild(t) + + const src = ` +package p + +import ( + . "os" + _ "io" + "math" + "path/filepath" + snort "sort" +) + +// avoid imported and not used errors +var ( + _ = Open // os.Open + _ = math.Sin + _ = filepath.Abs + _ = snort.Ints +) +` + + var tests = []struct { + path string // path string enclosed in "'s + want string + }{ + {`"os"`, "."}, + {`"io"`, "_"}, + {`"math"`, "math"}, + {`"path/filepath"`, "filepath"}, + {`"sort"`, "snort"}, + } + + f := mustParse(src) + info := Info{ + Defs: make(map[*syntax.Name]Object), + Implicits: make(map[syntax.Node]Object), + } + var conf Config + conf.Importer = defaultImporter() + _, err := conf.Check("p", []*syntax.File{f}, &info) + if err != nil { + t.Fatal(err) + } + + // map import paths to importDecl + imports := make(map[string]*syntax.ImportDecl) + for _, d := range f.DeclList { + if imp, _ := d.(*syntax.ImportDecl); imp != nil { + imports[imp.Path.Value] = imp + } + } + + for _, test := range tests { + imp := imports[test.path] + if imp == nil { + t.Fatalf("invalid test case: import path %s not found", test.path) + } + got := info.PkgNameOf(imp) + if got == nil { + t.Fatalf("import %s: package name not found", test.path) + } + if got.Name() != test.want { + t.Errorf("import %s: got %s; want %s", test.path, got.Name(), test.want) + } + } + + // test non-existing importDecl + if got := info.PkgNameOf(new(syntax.ImportDecl)); got != nil { + t.Errorf("got %s for non-existing import declaration", got.Name()) + } +} + +func predString(tv TypeAndValue) string { + var buf strings.Builder + pred := func(b bool, s string) { + if b { + if buf.Len() > 0 { + buf.WriteString(", ") + } + buf.WriteString(s) + } + } + + pred(tv.IsVoid(), "void") + pred(tv.IsType(), "type") + pred(tv.IsBuiltin(), "builtin") + pred(tv.IsValue() && tv.Value != nil, "const") + pred(tv.IsValue() && tv.Value == nil, "value") + pred(tv.IsNil(), "nil") + pred(tv.Addressable(), "addressable") + pred(tv.Assignable(), "assignable") + pred(tv.HasOk(), "hasOk") + + if buf.Len() == 0 { + return "invalid" + } + return buf.String() +} + +func TestPredicatesInfo(t *testing.T) { + testenv.MustHaveGoBuild(t) + + var tests = []struct { + src string + expr string + pred string + }{ + // void + {`package n0; func f() { f() }`, `f()`, `void`}, + + // types + {`package t0; type _ int`, `int`, `type`}, + {`package t1; type _ []int`, `[]int`, `type`}, + {`package t2; type _ func()`, `func()`, `type`}, + {`package t3; type _ func(int)`, `int`, `type`}, + {`package t3; type _ func(...int)`, `...int`, `type`}, + + // built-ins + {`package b0; var _ = len("")`, `len`, `builtin`}, + {`package b1; var _ = (len)("")`, `(len)`, `builtin`}, + + // constants + {`package c0; var _ = 42`, `42`, `const`}, + {`package c1; var _ = "foo" + "bar"`, `"foo" + "bar"`, `const`}, + {`package c2; const (i = 1i; _ = i)`, `i`, `const`}, + + // values + {`package v0; var (a, b int; _ = a + b)`, `a + b`, `value`}, + {`package v1; var _ = &[]int{1}`, `[]int{…}`, `value`}, + {`package v2; var _ = func(){}`, `func() {}`, `value`}, + {`package v4; func f() { _ = f }`, `f`, `value`}, + {`package v3; var _ *int = nil`, `nil`, `value, nil`}, + {`package v3; var _ *int = (nil)`, `(nil)`, `value, nil`}, + + // addressable (and thus assignable) operands + {`package a0; var (x int; _ = x)`, `x`, `value, addressable, assignable`}, + {`package a1; var (p *int; _ = *p)`, `*p`, `value, addressable, assignable`}, + {`package a2; var (s []int; _ = s[0])`, `s[0]`, `value, addressable, assignable`}, + {`package a3; var (s struct{f int}; _ = s.f)`, `s.f`, `value, addressable, assignable`}, + {`package a4; var (a [10]int; _ = a[0])`, `a[0]`, `value, addressable, assignable`}, + {`package a5; func _(x int) { _ = x }`, `x`, `value, addressable, assignable`}, + {`package a6; func _()(x int) { _ = x; return }`, `x`, `value, addressable, assignable`}, + {`package a7; type T int; func (x T) _() { _ = x }`, `x`, `value, addressable, assignable`}, + // composite literals are not addressable + + // assignable but not addressable values + {`package s0; var (m map[int]int; _ = m[0])`, `m[0]`, `value, assignable, hasOk`}, + {`package s1; var (m map[int]int; _, _ = m[0])`, `m[0]`, `value, assignable, hasOk`}, + + // hasOk expressions + {`package k0; var (ch chan int; _ = <-ch)`, `<-ch`, `value, hasOk`}, + {`package k1; var (ch chan int; _, _ = <-ch)`, `<-ch`, `value, hasOk`}, + + // missing entries + // - package names are collected in the Uses map + // - identifiers being declared are collected in the Defs map + {`package m0; import "os"; func _() { _ = os.Stdout }`, `os`, ``}, + {`package m1; import p "os"; func _() { _ = p.Stdout }`, `p`, ``}, + {`package m2; const c = 0`, `c`, ``}, + {`package m3; type T int`, `T`, ``}, + {`package m4; var v int`, `v`, ``}, + {`package m5; func f() {}`, `f`, ``}, + {`package m6; func _(x int) {}`, `x`, ``}, + {`package m6; func _()(x int) { return }`, `x`, ``}, + {`package m6; type T int; func (x T) _() {}`, `x`, ``}, + } + + for _, test := range tests { + info := Info{Types: make(map[syntax.Expr]TypeAndValue)} + name := mustTypecheck(test.src, nil, &info).Name() + + // look for expression predicates + got := "" + for e, tv := range info.Types { + //println(name, ExprString(e)) + if ExprString(e) == test.expr { + got = predString(tv) + break + } + } + + if got != test.pred { + t.Errorf("package %s: got %s; want %s", name, got, test.pred) + } + } +} + +func TestScopesInfo(t *testing.T) { + testenv.MustHaveGoBuild(t) + + var tests = []struct { + src string + scopes []string // list of scope descriptors of the form kind:varlist + }{ + {`package p0`, []string{ + "file:", + }}, + {`package p1; import ( "fmt"; m "math"; _ "os" ); var ( _ = fmt.Println; _ = m.Pi )`, []string{ + "file:fmt m", + }}, + {`package p2; func _() {}`, []string{ + "file:", "func:", + }}, + {`package p3; func _(x, y int) {}`, []string{ + "file:", "func:x y", + }}, + {`package p4; func _(x, y int) { x, z := 1, 2; _ = z }`, []string{ + "file:", "func:x y z", // redeclaration of x + }}, + {`package p5; func _(x, y int) (u, _ int) { return }`, []string{ + "file:", "func:u x y", + }}, + {`package p6; func _() { { var x int; _ = x } }`, []string{ + "file:", "func:", "block:x", + }}, + {`package p7; func _() { if true {} }`, []string{ + "file:", "func:", "if:", "block:", + }}, + {`package p8; func _() { if x := 0; x < 0 { y := x; _ = y } }`, []string{ + "file:", "func:", "if:x", "block:y", + }}, + {`package p9; func _() { switch x := 0; x {} }`, []string{ + "file:", "func:", "switch:x", + }}, + {`package p10; func _() { switch x := 0; x { case 1: y := x; _ = y; default: }}`, []string{ + "file:", "func:", "switch:x", "case:y", "case:", + }}, + {`package p11; func _(t interface{}) { switch t.(type) {} }`, []string{ + "file:", "func:t", "switch:", + }}, + {`package p12; func _(t interface{}) { switch t := t; t.(type) {} }`, []string{ + "file:", "func:t", "switch:t", + }}, + {`package p13; func _(t interface{}) { switch x := t.(type) { case int: _ = x } }`, []string{ + "file:", "func:t", "switch:", "case:x", // x implicitly declared + }}, + {`package p14; func _() { select{} }`, []string{ + "file:", "func:", + }}, + {`package p15; func _(c chan int) { select{ case <-c: } }`, []string{ + "file:", "func:c", "comm:", + }}, + {`package p16; func _(c chan int) { select{ case i := <-c: x := i; _ = x} }`, []string{ + "file:", "func:c", "comm:i x", + }}, + {`package p17; func _() { for{} }`, []string{ + "file:", "func:", "for:", "block:", + }}, + {`package p18; func _(n int) { for i := 0; i < n; i++ { _ = i } }`, []string{ + "file:", "func:n", "for:i", "block:", + }}, + {`package p19; func _(a []int) { for i := range a { _ = i} }`, []string{ + "file:", "func:a", "for:i", "block:", + }}, + {`package p20; var s int; func _(a []int) { for i, x := range a { s += x; _ = i } }`, []string{ + "file:", "func:a", "for:i x", "block:", + }}, + } + + for _, test := range tests { + info := Info{Scopes: make(map[syntax.Node]*Scope)} + name := mustTypecheck(test.src, nil, &info).Name() + + // number of scopes must match + if len(info.Scopes) != len(test.scopes) { + t.Errorf("package %s: got %d scopes; want %d", name, len(info.Scopes), len(test.scopes)) + } + + // scope descriptions must match + for node, scope := range info.Scopes { + var kind string + switch node.(type) { + case *syntax.File: + kind = "file" + case *syntax.FuncType: + kind = "func" + case *syntax.BlockStmt: + kind = "block" + case *syntax.IfStmt: + kind = "if" + case *syntax.SwitchStmt: + kind = "switch" + case *syntax.SelectStmt: + kind = "select" + case *syntax.CaseClause: + kind = "case" + case *syntax.CommClause: + kind = "comm" + case *syntax.ForStmt: + kind = "for" + default: + kind = fmt.Sprintf("%T", node) + } + + // look for matching scope description + desc := kind + ":" + strings.Join(scope.Names(), " ") + if !slices.Contains(test.scopes, desc) { + t.Errorf("package %s: no matching scope found for %s", name, desc) + } + } + } +} + +func TestInitOrderInfo(t *testing.T) { + var tests = []struct { + src string + inits []string + }{ + {`package p0; var (x = 1; y = x)`, []string{ + "x = 1", "y = x", + }}, + {`package p1; var (a = 1; b = 2; c = 3)`, []string{ + "a = 1", "b = 2", "c = 3", + }}, + {`package p2; var (a, b, c = 1, 2, 3)`, []string{ + "a = 1", "b = 2", "c = 3", + }}, + {`package p3; var _ = f(); func f() int { return 1 }`, []string{ + "_ = f()", // blank var + }}, + {`package p4; var (a = 0; x = y; y = z; z = 0)`, []string{ + "a = 0", "z = 0", "y = z", "x = y", + }}, + {`package p5; var (a, _ = m[0]; m map[int]string)`, []string{ + "a, _ = m[0]", // blank var + }}, + {`package p6; var a, b = f(); func f() (_, _ int) { return z, z }; var z = 0`, []string{ + "z = 0", "a, b = f()", + }}, + {`package p7; var (a = func() int { return b }(); b = 1)`, []string{ + "b = 1", "a = func() int {…}()", + }}, + {`package p8; var (a, b = func() (_, _ int) { return c, c }(); c = 1)`, []string{ + "c = 1", "a, b = func() (_, _ int) {…}()", + }}, + {`package p9; type T struct{}; func (T) m() int { _ = y; return 0 }; var x, y = T.m, 1`, []string{ + "y = 1", "x = T.m", + }}, + {`package p10; var (d = c + b; a = 0; b = 0; c = 0)`, []string{ + "a = 0", "b = 0", "c = 0", "d = c + b", + }}, + {`package p11; var (a = e + c; b = d + c; c = 0; d = 0; e = 0)`, []string{ + "c = 0", "d = 0", "b = d + c", "e = 0", "a = e + c", + }}, + // emit an initializer for n:1 initializations only once (not for each node + // on the lhs which may appear in different order in the dependency graph) + {`package p12; var (a = x; b = 0; x, y = m[0]; m map[int]int)`, []string{ + "b = 0", "x, y = m[0]", "a = x", + }}, + // test case from spec section on package initialization + {`package p12 + + var ( + a = c + b + b = f() + c = f() + d = 3 + ) + + func f() int { + d++ + return d + }`, []string{ + "d = 3", "b = f()", "c = f()", "a = c + b", + }}, + // test case for go.dev/issue/7131 + {`package main + + var counter int + func next() int { counter++; return counter } + + var _ = makeOrder() + func makeOrder() []int { return []int{f, b, d, e, c, a} } + + var a = next() + var b, c = next(), next() + var d, e, f = next(), next(), next() + `, []string{ + "a = next()", "b = next()", "c = next()", "d = next()", "e = next()", "f = next()", "_ = makeOrder()", + }}, + // test case for go.dev/issue/10709 + {`package p13 + + var ( + v = t.m() + t = makeT(0) + ) + + type T struct{} + + func (T) m() int { return 0 } + + func makeT(n int) T { + if n > 0 { + return makeT(n-1) + } + return T{} + }`, []string{ + "t = makeT(0)", "v = t.m()", + }}, + // test case for go.dev/issue/10709: same as test before, but variable decls swapped + {`package p14 + + var ( + t = makeT(0) + v = t.m() + ) + + type T struct{} + + func (T) m() int { return 0 } + + func makeT(n int) T { + if n > 0 { + return makeT(n-1) + } + return T{} + }`, []string{ + "t = makeT(0)", "v = t.m()", + }}, + // another candidate possibly causing problems with go.dev/issue/10709 + {`package p15 + + var y1 = f1() + + func f1() int { return g1() } + func g1() int { f1(); return x1 } + + var x1 = 0 + + var y2 = f2() + + func f2() int { return g2() } + func g2() int { return x2 } + + var x2 = 0`, []string{ + "x1 = 0", "y1 = f1()", "x2 = 0", "y2 = f2()", + }}, + } + + for _, test := range tests { + info := Info{} + name := mustTypecheck(test.src, nil, &info).Name() + + // number of initializers must match + if len(info.InitOrder) != len(test.inits) { + t.Errorf("package %s: got %d initializers; want %d", name, len(info.InitOrder), len(test.inits)) + continue + } + + // initializers must match + for i, want := range test.inits { + got := info.InitOrder[i].String() + if got != want { + t.Errorf("package %s, init %d: got %s; want %s", name, i, got, want) + continue + } + } + } +} + +func TestMultiFileInitOrder(t *testing.T) { + fileA := mustParse(`package main; var a = 1`) + fileB := mustParse(`package main; var b = 2`) + + // The initialization order must not depend on the parse + // order of the files, only on the presentation order to + // the type-checker. + for _, test := range []struct { + files []*syntax.File + want string + }{ + {[]*syntax.File{fileA, fileB}, "[a = 1 b = 2]"}, + {[]*syntax.File{fileB, fileA}, "[b = 2 a = 1]"}, + } { + var info Info + if _, err := new(Config).Check("main", test.files, &info); err != nil { + t.Fatal(err) + } + if got := fmt.Sprint(info.InitOrder); got != test.want { + t.Fatalf("got %s; want %s", got, test.want) + } + } +} + +func TestFiles(t *testing.T) { + var sources = []string{ + "package p; type T struct{}; func (T) m1() {}", + "package p; func (T) m2() {}; var x interface{ m1(); m2() } = T{}", + "package p; func (T) m3() {}; var y interface{ m1(); m2(); m3() } = T{}", + "package p", + } + + var conf Config + pkg := NewPackage("p", "p") + var info Info + check := NewChecker(&conf, pkg, &info) + + for _, src := range sources { + if err := check.Files([]*syntax.File{mustParse(src)}); err != nil { + t.Error(err) + } + } + + // check InitOrder is [x y] + var vars []string + for _, init := range info.InitOrder { + for _, v := range init.Lhs { + vars = append(vars, v.Name()) + } + } + if got, want := fmt.Sprint(vars), "[x y]"; got != want { + t.Errorf("InitOrder == %s, want %s", got, want) + } +} + +type testImporter map[string]*Package + +func (m testImporter) Import(path string) (*Package, error) { + if pkg := m[path]; pkg != nil { + return pkg, nil + } + return nil, fmt.Errorf("package %q not found", path) +} + +func TestSelection(t *testing.T) { + selections := make(map[*syntax.SelectorExpr]*Selection) + + imports := make(testImporter) + conf := Config{Importer: imports} + makePkg := func(path, src string) { + pkg := mustTypecheck(src, &conf, &Info{Selections: selections}) + imports[path] = pkg + } + + const libSrc = ` +package lib +type T float64 +const C T = 3 +var V T +func F() {} +func (T) M() {} +` + const mainSrc = ` +package main +import "lib" + +type A struct { + *B + C +} + +type B struct { + b int +} + +func (B) f(int) + +type C struct { + c int +} + +type G[P any] struct { + p P +} + +func (G[P]) m(P) {} + +var Inst G[int] + +func (C) g() +func (*C) h() + +func main() { + // qualified identifiers + var _ lib.T + _ = lib.C + _ = lib.F + _ = lib.V + _ = lib.T.M + + // fields + _ = A{}.B + _ = new(A).B + + _ = A{}.C + _ = new(A).C + + _ = A{}.b + _ = new(A).b + + _ = A{}.c + _ = new(A).c + + _ = Inst.p + _ = G[string]{}.p + + // methods + _ = A{}.f + _ = new(A).f + _ = A{}.g + _ = new(A).g + _ = new(A).h + + _ = B{}.f + _ = new(B).f + + _ = C{}.g + _ = new(C).g + _ = new(C).h + _ = Inst.m + + // method expressions + _ = A.f + _ = (*A).f + _ = B.f + _ = (*B).f + _ = G[string].m +}` + + wantOut := map[string][2]string{ + "lib.T.M": {"method expr (lib.T) M(lib.T)", ".[0]"}, + + "A{}.B": {"field (main.A) B *main.B", ".[0]"}, + "new(A).B": {"field (*main.A) B *main.B", "->[0]"}, + "A{}.C": {"field (main.A) C main.C", ".[1]"}, + "new(A).C": {"field (*main.A) C main.C", "->[1]"}, + "A{}.b": {"field (main.A) b int", "->[0 0]"}, + "new(A).b": {"field (*main.A) b int", "->[0 0]"}, + "A{}.c": {"field (main.A) c int", ".[1 0]"}, + "new(A).c": {"field (*main.A) c int", "->[1 0]"}, + "Inst.p": {"field (main.G[int]) p int", ".[0]"}, + + "A{}.f": {"method (main.A) f(int)", "->[0 0]"}, + "new(A).f": {"method (*main.A) f(int)", "->[0 0]"}, + "A{}.g": {"method (main.A) g()", ".[1 0]"}, + "new(A).g": {"method (*main.A) g()", "->[1 0]"}, + "new(A).h": {"method (*main.A) h()", "->[1 1]"}, // TODO(gri) should this report .[1 1] ? + "B{}.f": {"method (main.B) f(int)", ".[0]"}, + "new(B).f": {"method (*main.B) f(int)", "->[0]"}, + "C{}.g": {"method (main.C) g()", ".[0]"}, + "new(C).g": {"method (*main.C) g()", "->[0]"}, + "new(C).h": {"method (*main.C) h()", "->[1]"}, // TODO(gri) should this report .[1] ? + "Inst.m": {"method (main.G[int]) m(int)", ".[0]"}, + + "A.f": {"method expr (main.A) f(main.A, int)", "->[0 0]"}, + "(*A).f": {"method expr (*main.A) f(*main.A, int)", "->[0 0]"}, + "B.f": {"method expr (main.B) f(main.B, int)", ".[0]"}, + "(*B).f": {"method expr (*main.B) f(*main.B, int)", "->[0]"}, + "G[string].m": {"method expr (main.G[string]) m(main.G[string], string)", ".[0]"}, + "G[string]{}.p": {"field (main.G[string]) p string", ".[0]"}, + } + + makePkg("lib", libSrc) + makePkg("main", mainSrc) + + for e, sel := range selections { + _ = sel.String() // assertion: must not panic + + start := indexFor(mainSrc, syntax.StartPos(e)) + end := indexFor(mainSrc, syntax.EndPos(e)) + segment := mainSrc[start:end] // (all SelectorExprs are in main, not lib) + + direct := "." + if sel.Indirect() { + direct = "->" + } + got := [2]string{ + sel.String(), + fmt.Sprintf("%s%v", direct, sel.Index()), + } + want := wantOut[segment] + if want != got { + t.Errorf("%s: got %q; want %q", segment, got, want) + } + delete(wantOut, segment) + + // We must explicitly assert properties of the + // Signature's receiver since it doesn't participate + // in Identical() or String(). + sig, _ := sel.Type().(*Signature) + if sel.Kind() == MethodVal { + got := sig.Recv().Type() + want := sel.Recv() + if !Identical(got, want) { + t.Errorf("%s: Recv() = %s, want %s", segment, got, want) + } + } else if sig != nil && sig.Recv() != nil { + t.Errorf("%s: signature has receiver %s", sig, sig.Recv().Type()) + } + } + // Assert that all wantOut entries were used exactly once. + for segment := range wantOut { + t.Errorf("no syntax.Selection found with syntax %q", segment) + } +} + +// indexFor returns the index into s corresponding to the position pos. +func indexFor(s string, pos syntax.Pos) int { + i, line := 0, 1 // string index and corresponding line + target := int(pos.Line()) + for line < target && i < len(s) { + if s[i] == '\n' { + line++ + } + i++ + } + return i + int(pos.Col()-1) // columns are 1-based +} + +func TestIssue8518(t *testing.T) { + imports := make(testImporter) + conf := Config{ + Error: func(err error) { t.Log(err) }, // don't exit after first error + Importer: imports, + } + makePkg := func(path, src string) { + imports[path], _ = conf.Check(path, []*syntax.File{mustParse(src)}, nil) // errors logged via conf.Error + } + + const libSrc = ` +package a +import "missing" +const C1 = foo +const C2 = missing.C +` + + const mainSrc = ` +package main +import "a" +var _ = a.C1 +var _ = a.C2 +` + + makePkg("a", libSrc) + makePkg("main", mainSrc) // don't crash when type-checking this package +} + +func TestIssue59603(t *testing.T) { + imports := make(testImporter) + conf := Config{ + Error: func(err error) { t.Log(err) }, // don't exit after first error + Importer: imports, + } + makePkg := func(path, src string) { + imports[path], _ = conf.Check(path, []*syntax.File{mustParse(src)}, nil) // errors logged via conf.Error + } + + const libSrc = ` +package a +const C = foo +` + + const mainSrc = ` +package main +import "a" +const _ = a.C +` + + makePkg("a", libSrc) + makePkg("main", mainSrc) // don't crash when type-checking this package +} + +func TestLookupFieldOrMethodOnNil(t *testing.T) { + // LookupFieldOrMethod on a nil type is expected to produce a run-time panic. + defer func() { + const want = "LookupFieldOrMethod on nil type" + p := recover() + if s, ok := p.(string); !ok || s != want { + t.Fatalf("got %v, want %s", p, want) + } + }() + LookupFieldOrMethod(nil, false, nil, "") +} + +func TestLookupFieldOrMethod(t *testing.T) { + // Test cases assume a lookup of the form a.f or x.f, where a stands for an + // addressable value, and x for a non-addressable value (even though a variable + // for ease of test case writing). + var tests = []struct { + src string + found bool + index []int + indirect bool + }{ + // field lookups + {"var x T; type T struct{}", false, nil, false}, + {"var x T; type T struct{ f int }", true, []int{0}, false}, + {"var x T; type T struct{ a, b, f, c int }", true, []int{2}, false}, + + // field lookups on a generic type + {"var x T[int]; type T[P any] struct{}", false, nil, false}, + {"var x T[int]; type T[P any] struct{ f P }", true, []int{0}, false}, + {"var x T[int]; type T[P any] struct{ a, b, f, c P }", true, []int{2}, false}, + + // method lookups + {"var a T; type T struct{}; func (T) f() {}", true, []int{0}, false}, + {"var a *T; type T struct{}; func (T) f() {}", true, []int{0}, true}, + {"var a T; type T struct{}; func (*T) f() {}", true, []int{0}, false}, + {"var a *T; type T struct{}; func (*T) f() {}", true, []int{0}, true}, // TODO(gri) should this report indirect = false? + + // method lookups on a generic type + {"var a T[int]; type T[P any] struct{}; func (T[P]) f() {}", true, []int{0}, false}, + {"var a *T[int]; type T[P any] struct{}; func (T[P]) f() {}", true, []int{0}, true}, + {"var a T[int]; type T[P any] struct{}; func (*T[P]) f() {}", true, []int{0}, false}, + {"var a *T[int]; type T[P any] struct{}; func (*T[P]) f() {}", true, []int{0}, true}, // TODO(gri) should this report indirect = false? + + // collisions + {"type ( E1 struct{ f int }; E2 struct{ f int }; x struct{ E1; *E2 })", false, []int{1, 0}, false}, + {"type ( E1 struct{ f int }; E2 struct{}; x struct{ E1; *E2 }); func (E2) f() {}", false, []int{1, 0}, false}, + + // collisions on a generic type + {"type ( E1[P any] struct{ f P }; E2[P any] struct{ f P }; x struct{ E1[int]; *E2[int] })", false, []int{1, 0}, false}, + {"type ( E1[P any] struct{ f P }; E2[P any] struct{}; x struct{ E1[int]; *E2[int] }); func (E2[P]) f() {}", false, []int{1, 0}, false}, + + // outside methodset + // (*T).f method exists, but value of type T is not addressable + {"var x T; type T struct{}; func (*T) f() {}", false, nil, true}, + + // outside method set of a generic type + {"var x T[int]; type T[P any] struct{}; func (*T[P]) f() {}", false, nil, true}, + + // recursive generic types; see go.dev/issue/52715 + {"var a T[int]; type ( T[P any] struct { *N[P] }; N[P any] struct { *T[P] } ); func (N[P]) f() {}", true, []int{0, 0}, true}, + {"var a T[int]; type ( T[P any] struct { *N[P] }; N[P any] struct { *T[P] } ); func (T[P]) f() {}", true, []int{0}, false}, + } + + for _, test := range tests { + pkg := mustTypecheck("package p;"+test.src, nil, nil) + + obj := pkg.Scope().Lookup("a") + if obj == nil { + if obj = pkg.Scope().Lookup("x"); obj == nil { + t.Errorf("%s: incorrect test case - no object a or x", test.src) + continue + } + } + + f, index, indirect := LookupFieldOrMethod(obj.Type(), obj.Name() == "a", pkg, "f") + if (f != nil) != test.found { + if f == nil { + t.Errorf("%s: got no object; want one", test.src) + } else { + t.Errorf("%s: got object = %v; want none", test.src, f) + } + } + if !slices.Equal(index, test.index) { + t.Errorf("%s: got index = %v; want %v", test.src, index, test.index) + } + if indirect != test.indirect { + t.Errorf("%s: got indirect = %v; want %v", test.src, indirect, test.indirect) + } + } +} + +// Test for go.dev/issue/52715 +func TestLookupFieldOrMethod_RecursiveGeneric(t *testing.T) { + const src = ` +package pkg + +type Tree[T any] struct { + *Node[T] +} + +func (*Tree[R]) N(r R) R { return r } + +type Node[T any] struct { + *Tree[T] +} + +type Instance = *Tree[int] +` + + f := mustParse(src) + pkg := NewPackage("pkg", f.PkgName.Value) + if err := NewChecker(nil, pkg, nil).Files([]*syntax.File{f}); err != nil { + panic(err) + } + + T := pkg.Scope().Lookup("Instance").Type() + _, _, _ = LookupFieldOrMethod(T, false, pkg, "M") // verify that LookupFieldOrMethod terminates +} + +// newDefined creates a new defined type named T with the given underlying type. +func newDefined(underlying Type) *Named { + tname := NewTypeName(nopos, nil, "T", nil) + return NewNamed(tname, underlying, nil) +} + +func TestConvertibleTo(t *testing.T) { + for _, test := range []struct { + v, t Type + want bool + }{ + {Typ[Int], Typ[Int], true}, + {Typ[Int], Typ[Float32], true}, + {Typ[Int], Typ[String], true}, + {newDefined(Typ[Int]), Typ[Int], true}, + {newDefined(new(Struct)), new(Struct), true}, + {newDefined(Typ[Int]), new(Struct), false}, + {Typ[UntypedInt], Typ[Int], true}, + {NewSlice(Typ[Int]), NewArray(Typ[Int], 10), true}, + {NewSlice(Typ[Int]), NewArray(Typ[Uint], 10), false}, + {NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Int], 10)), true}, + {NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Uint], 10)), false}, + // Untyped string values are not permitted by the spec, so the behavior below is undefined. + {Typ[UntypedString], Typ[String], true}, + } { + if got := ConvertibleTo(test.v, test.t); got != test.want { + t.Errorf("ConvertibleTo(%v, %v) = %t, want %t", test.v, test.t, got, test.want) + } + } +} + +func TestAssignableTo(t *testing.T) { + for _, test := range []struct { + v, t Type + want bool + }{ + {Typ[Int], Typ[Int], true}, + {Typ[Int], Typ[Float32], false}, + {newDefined(Typ[Int]), Typ[Int], false}, + {newDefined(new(Struct)), new(Struct), true}, + {Typ[UntypedBool], Typ[Bool], true}, + {Typ[UntypedString], Typ[Bool], false}, + // Neither untyped string nor untyped numeric assignments arise during + // normal type checking, so the below behavior is technically undefined by + // the spec. + {Typ[UntypedString], Typ[String], true}, + {Typ[UntypedInt], Typ[Int], true}, + } { + if got := AssignableTo(test.v, test.t); got != test.want { + t.Errorf("AssignableTo(%v, %v) = %t, want %t", test.v, test.t, got, test.want) + } + } +} + +func TestIdentical(t *testing.T) { + // For each test, we compare the types of objects X and Y in the source. + tests := []struct { + src string + want bool + }{ + // Basic types. + {"var X int; var Y int", true}, + {"var X int; var Y string", false}, + + // TODO: add more tests for complex types. + + // Named types. + {"type X int; type Y int", false}, + + // Aliases. + {"type X = int; type Y = int", true}, + + // Functions. + {`func X(int) string { return "" }; func Y(int) string { return "" }`, true}, + {`func X() string { return "" }; func Y(int) string { return "" }`, false}, + {`func X(int) string { return "" }; func Y(int) {}`, false}, + + // Generic functions. Type parameters should be considered identical modulo + // renaming. See also go.dev/issue/49722. + {`func X[P ~int](){}; func Y[Q ~int]() {}`, true}, + {`func X[P1 any, P2 ~*P1](){}; func Y[Q1 any, Q2 ~*Q1]() {}`, true}, + {`func X[P1 any, P2 ~[]P1](){}; func Y[Q1 any, Q2 ~*Q1]() {}`, false}, + {`func X[P ~int](P){}; func Y[Q ~int](Q) {}`, true}, + {`func X[P ~string](P){}; func Y[Q ~int](Q) {}`, false}, + {`func X[P ~int]([]P){}; func Y[Q ~int]([]Q) {}`, true}, + } + + for _, test := range tests { + pkg := mustTypecheck("package p;"+test.src, nil, nil) + X := pkg.Scope().Lookup("X") + Y := pkg.Scope().Lookup("Y") + if X == nil || Y == nil { + t.Fatal("test must declare both X and Y") + } + if got := Identical(X.Type(), Y.Type()); got != test.want { + t.Errorf("Identical(%s, %s) = %t, want %t", X.Type(), Y.Type(), got, test.want) + } + } +} + +func TestIdentical_issue15173(t *testing.T) { + // Identical should allow nil arguments and be symmetric. + for _, test := range []struct { + x, y Type + want bool + }{ + {Typ[Int], Typ[Int], true}, + {Typ[Int], nil, false}, + {nil, Typ[Int], false}, + {nil, nil, true}, + } { + if got := Identical(test.x, test.y); got != test.want { + t.Errorf("Identical(%v, %v) = %t", test.x, test.y, got) + } + } +} + +func TestIdenticalUnions(t *testing.T) { + tname := NewTypeName(nopos, nil, "myInt", nil) + myInt := NewNamed(tname, Typ[Int], nil) + tmap := map[string]*Term{ + "int": NewTerm(false, Typ[Int]), + "~int": NewTerm(true, Typ[Int]), + "string": NewTerm(false, Typ[String]), + "~string": NewTerm(true, Typ[String]), + "myInt": NewTerm(false, myInt), + } + makeUnion := func(s string) *Union { + parts := strings.Split(s, "|") + var terms []*Term + for _, p := range parts { + term := tmap[p] + if term == nil { + t.Fatalf("missing term %q", p) + } + terms = append(terms, term) + } + return NewUnion(terms) + } + for _, test := range []struct { + x, y string + want bool + }{ + // These tests are just sanity checks. The tests for type sets and + // interfaces provide much more test coverage. + {"int|~int", "~int", true}, + {"myInt|~int", "~int", true}, + {"int|string", "string|int", true}, + {"int|int|string", "string|int", true}, + {"myInt|string", "int|string", false}, + } { + x := makeUnion(test.x) + y := makeUnion(test.y) + if got := Identical(x, y); got != test.want { + t.Errorf("Identical(%v, %v) = %t", test.x, test.y, got) + } + } +} + +func TestIssue61737(t *testing.T) { + // This test verifies that it is possible to construct invalid interfaces + // containing duplicate methods using the go/types API. + // + // It must be possible for importers to construct such invalid interfaces. + // Previously, this panicked. + + sig1 := NewSignatureType(nil, nil, nil, NewTuple(NewParam(nopos, nil, "", Typ[Int])), nil, false) + sig2 := NewSignatureType(nil, nil, nil, NewTuple(NewParam(nopos, nil, "", Typ[String])), nil, false) + + methods := []*Func{ + NewFunc(nopos, nil, "M", sig1), + NewFunc(nopos, nil, "M", sig2), + } + + embeddedMethods := []*Func{ + NewFunc(nopos, nil, "M", sig2), + } + embedded := NewInterfaceType(embeddedMethods, nil) + iface := NewInterfaceType(methods, []Type{embedded}) + iface.NumMethods() // unlike go/types, there is no Complete() method, so we complete implicitly +} + +func TestNewAlias_Issue65455(t *testing.T) { + obj := NewTypeName(nopos, nil, "A", nil) + alias := NewAlias(obj, Typ[Int]) + alias.Underlying() // must not panic +} + +func TestIssue15305(t *testing.T) { + const src = "package p; func f() int16; var _ = f(undef)" + f := mustParse(src) + conf := Config{ + Error: func(err error) {}, // allow errors + } + info := &Info{ + Types: make(map[syntax.Expr]TypeAndValue), + } + conf.Check("p", []*syntax.File{f}, info) // ignore result + for e, tv := range info.Types { + if _, ok := e.(*syntax.CallExpr); ok { + if tv.Type != Typ[Int16] { + t.Errorf("CallExpr has type %v, want int16", tv.Type) + } + return + } + } + t.Errorf("CallExpr has no type") +} + +// TestCompositeLitTypes verifies that Info.Types registers the correct +// types for composite literal expressions and composite literal type +// expressions. +func TestCompositeLitTypes(t *testing.T) { + for i, test := range []struct { + lit, typ string + }{ + {`[16]byte{}`, `[16]byte`}, + {`[...]byte{}`, `[0]byte`}, // test for go.dev/issue/14092 + {`[...]int{1, 2, 3}`, `[3]int`}, // test for go.dev/issue/14092 + {`[...]int{90: 0, 98: 1, 2}`, `[100]int`}, // test for go.dev/issue/14092 + {`[]int{}`, `[]int`}, + {`map[string]bool{"foo": true}`, `map[string]bool`}, + {`struct{}{}`, `struct{}`}, + {`struct{x, y int; z complex128}{}`, `struct{x int; y int; z complex128}`}, + } { + f := mustParse(fmt.Sprintf("package p%d; var _ = %s", i, test.lit)) + types := make(map[syntax.Expr]TypeAndValue) + if _, err := new(Config).Check("p", []*syntax.File{f}, &Info{Types: types}); err != nil { + t.Fatalf("%s: %v", test.lit, err) + } + + cmptype := func(x syntax.Expr, want string) { + tv, ok := types[x] + if !ok { + t.Errorf("%s: no Types entry found", test.lit) + return + } + if tv.Type == nil { + t.Errorf("%s: type is nil", test.lit) + return + } + if got := tv.Type.String(); got != want { + t.Errorf("%s: got %v, want %s", test.lit, got, want) + } + } + + // test type of composite literal expression + rhs := f.DeclList[0].(*syntax.VarDecl).Values + cmptype(rhs, test.typ) + + // test type of composite literal type expression + cmptype(rhs.(*syntax.CompositeLit).Type, test.typ) + } +} + +// TestObjectParents verifies that objects have parent scopes or not +// as specified by the Object interface. +func TestObjectParents(t *testing.T) { + const src = ` +package p + +const C = 0 + +type T1 struct { + a, b int + T2 +} + +type T2 interface { + im1() + im2() +} + +func (T1) m1() {} +func (*T1) m2() {} + +func f(x int) { y := x; print(y) } +` + + f := mustParse(src) + + info := &Info{ + Defs: make(map[*syntax.Name]Object), + } + if _, err := new(Config).Check("p", []*syntax.File{f}, info); err != nil { + t.Fatal(err) + } + + for ident, obj := range info.Defs { + if obj == nil { + // only package names and implicit vars have a nil object + // (in this test we only need to handle the package name) + if ident.Value != "p" { + t.Errorf("%v has nil object", ident) + } + continue + } + + // struct fields, type-associated and interface methods + // have no parent scope + wantParent := true + switch obj := obj.(type) { + case *Var: + if obj.IsField() { + wantParent = false + } + case *Func: + if obj.Type().(*Signature).Recv() != nil { // method + wantParent = false + } + } + + gotParent := obj.Parent() != nil + switch { + case gotParent && !wantParent: + t.Errorf("%v: want no parent, got %s", ident, obj.Parent()) + case !gotParent && wantParent: + t.Errorf("%v: no parent found", ident) + } + } +} + +// TestFailedImport tests that we don't get follow-on errors +// elsewhere in a package due to failing to import a package. +func TestFailedImport(t *testing.T) { + testenv.MustHaveGoBuild(t) + + const src = ` +package p + +import foo "go/types/thisdirectorymustnotexistotherwisethistestmayfail/foo" // should only see an error here + +const c = foo.C +type T = foo.T +var v T = c +func f(x T) T { return foo.F(x) } +` + f := mustParse(src) + files := []*syntax.File{f} + + // type-check using all possible importers + for _, compiler := range []string{"gc", "gccgo", "source"} { + errcount := 0 + conf := Config{ + Error: func(err error) { + // we should only see the import error + if errcount > 0 || !strings.Contains(err.Error(), "could not import") { + t.Errorf("for %s importer, got unexpected error: %v", compiler, err) + } + errcount++ + }, + //Importer: importer.For(compiler, nil), + } + + info := &Info{ + Uses: make(map[*syntax.Name]Object), + } + pkg, _ := conf.Check("p", files, info) + if pkg == nil { + t.Errorf("for %s importer, type-checking failed to return a package", compiler) + continue + } + + imports := pkg.Imports() + if len(imports) != 1 { + t.Errorf("for %s importer, got %d imports, want 1", compiler, len(imports)) + continue + } + imp := imports[0] + if imp.Name() != "foo" { + t.Errorf(`for %s importer, got %q, want "foo"`, compiler, imp.Name()) + continue + } + + // verify that all uses of foo refer to the imported package foo (imp) + for ident, obj := range info.Uses { + if ident.Value == "foo" { + if obj, ok := obj.(*PkgName); ok { + if obj.Imported() != imp { + t.Errorf("%s resolved to %v; want %v", ident.Value, obj.Imported(), imp) + } + } else { + t.Errorf("%s resolved to %v; want package name", ident.Value, obj) + } + } + } + } +} + +func TestInstantiate(t *testing.T) { + // eventually we like more tests but this is a start + const src = "package p; type T[P any] *T[P]" + pkg := mustTypecheck(src, nil, nil) + + // type T should have one type parameter + T := pkg.Scope().Lookup("T").Type().(*Named) + if n := T.TypeParams().Len(); n != 1 { + t.Fatalf("expected 1 type parameter; found %d", n) + } + + // instantiation should succeed (no endless recursion) + // even with a nil *Checker + res, err := Instantiate(nil, T, []Type{Typ[Int]}, false) + if err != nil { + t.Fatal(err) + } + + // instantiated type should point to itself + if p := res.Underlying().(*Pointer).Elem(); p != res { + t.Fatalf("unexpected result type: %s points to %s", res, p) + } +} + +func TestInstantiateConcurrent(t *testing.T) { + const src = `package p + +type I[P any] interface { + m(P) + n() P +} + +type J = I[int] + +type Nested[P any] *interface{b(P)} + +type K = Nested[string] +` + pkg := mustTypecheck(src, nil, nil) + + insts := []*Interface{ + pkg.Scope().Lookup("J").Type().Underlying().(*Interface), + pkg.Scope().Lookup("K").Type().Underlying().(*Pointer).Elem().(*Interface), + } + + // Use the interface instances concurrently. + for _, inst := range insts { + var ( + counts [2]int // method counts + methods [2][]string // method strings + ) + var wg sync.WaitGroup + for i := 0; i < 2; i++ { + i := i + wg.Add(1) + go func() { + defer wg.Done() + + counts[i] = inst.NumMethods() + for mi := 0; mi < counts[i]; mi++ { + methods[i] = append(methods[i], inst.Method(mi).String()) + } + }() + } + wg.Wait() + + if counts[0] != counts[1] { + t.Errorf("mismatching method counts for %s: %d vs %d", inst, counts[0], counts[1]) + continue + } + for i := 0; i < counts[0]; i++ { + if m0, m1 := methods[0][i], methods[1][i]; m0 != m1 { + t.Errorf("mismatching methods for %s: %s vs %s", inst, m0, m1) + } + } + } +} + +func TestInstantiateErrors(t *testing.T) { + tests := []struct { + src string // by convention, T must be the type being instantiated + targs []Type + wantAt int // -1 indicates no error + }{ + {"type T[P interface{~string}] int", []Type{Typ[Int]}, 0}, + {"type T[P1 interface{int}, P2 interface{~string}] int", []Type{Typ[Int], Typ[Int]}, 1}, + {"type T[P1 any, P2 interface{~[]P1}] int", []Type{Typ[Int], NewSlice(Typ[String])}, 1}, + {"type T[P1 interface{~[]P2}, P2 any] int", []Type{NewSlice(Typ[String]), Typ[Int]}, 0}, + } + + for _, test := range tests { + src := "package p; " + test.src + pkg := mustTypecheck(src, nil, nil) + + T := pkg.Scope().Lookup("T").Type().(*Named) + + _, err := Instantiate(nil, T, test.targs, true) + if err == nil { + t.Fatalf("Instantiate(%v, %v) returned nil error, want non-nil", T, test.targs) + } + + argErr, ok := errors.AsType[*ArgumentError](err) + if !ok { + t.Fatalf("Instantiate(%v, %v): error is not an *ArgumentError", T, test.targs) + } + + if argErr.Index != test.wantAt { + t.Errorf("Instantiate(%v, %v): error at index %d, want index %d", T, test.targs, argErr.Index, test.wantAt) + } + } +} + +func TestArgumentErrorUnwrapping(t *testing.T) { + var err error = &ArgumentError{ + Index: 1, + Err: Error{Msg: "test"}, + } + e, ok := errors.AsType[Error](err) + if !ok { + t.Fatalf("error %v does not wrap types.Error", err) + } + if e.Msg != "test" { + t.Errorf("e.Msg = %q, want %q", e.Msg, "test") + } +} + +func TestInstanceIdentity(t *testing.T) { + imports := make(testImporter) + conf := Config{Importer: imports} + makePkg := func(src string) { + f := mustParse(src) + name := f.PkgName.Value + pkg, err := conf.Check(name, []*syntax.File{f}, nil) + if err != nil { + t.Fatal(err) + } + imports[name] = pkg + } + makePkg(`package lib; type T[P any] struct{}`) + makePkg(`package a; import "lib"; var A lib.T[int]`) + makePkg(`package b; import "lib"; var B lib.T[int]`) + a := imports["a"].Scope().Lookup("A") + b := imports["b"].Scope().Lookup("B") + if !Identical(a.Type(), b.Type()) { + t.Errorf("mismatching types: a.A: %s, b.B: %s", a.Type(), b.Type()) + } +} + +// TestInstantiatedObjects verifies properties of instantiated objects. +func TestInstantiatedObjects(t *testing.T) { + const src = ` +package p + +type T[P any] struct { + field P +} + +func (recv *T[Q]) concreteMethod(mParam Q) (mResult Q) { return } + +type FT[P any] func(ftParam P) (ftResult P) + +func F[P any](fParam P) (fResult P){ return } + +type I[P any] interface { + interfaceMethod(P) +} + +type R[P any] T[P] + +func (R[P]) m() {} // having a method triggers expansion of R + +var ( + t T[int] + ft FT[int] + f = F[int] + i I[int] +) + +func fn() { + var r R[int] + _ = r +} +` + info := &Info{ + Defs: make(map[*syntax.Name]Object), + } + f := mustParse(src) + conf := Config{} + pkg, err := conf.Check(f.PkgName.Value, []*syntax.File{f}, info) + if err != nil { + t.Fatal(err) + } + + lookup := func(name string) Type { return pkg.Scope().Lookup(name).Type() } + fnScope := pkg.Scope().Lookup("fn").(*Func).Scope() + + tests := []struct { + name string + obj Object + }{ + // Struct fields + {"field", lookup("t").Underlying().(*Struct).Field(0)}, + {"field", fnScope.Lookup("r").Type().Underlying().(*Struct).Field(0)}, + + // Methods and method fields + {"concreteMethod", lookup("t").(*Named).Method(0)}, + {"recv", lookup("t").(*Named).Method(0).Type().(*Signature).Recv()}, + {"mParam", lookup("t").(*Named).Method(0).Type().(*Signature).Params().At(0)}, + {"mResult", lookup("t").(*Named).Method(0).Type().(*Signature).Results().At(0)}, + + // Interface methods + {"interfaceMethod", lookup("i").Underlying().(*Interface).Method(0)}, + + // Function type fields + {"ftParam", lookup("ft").Underlying().(*Signature).Params().At(0)}, + {"ftResult", lookup("ft").Underlying().(*Signature).Results().At(0)}, + + // Function fields + {"fParam", lookup("f").(*Signature).Params().At(0)}, + {"fResult", lookup("f").(*Signature).Results().At(0)}, + } + + // Collect all identifiers by name. + idents := make(map[string][]*syntax.Name) + syntax.Inspect(f, func(n syntax.Node) bool { + if id, ok := n.(*syntax.Name); ok { + idents[id.Value] = append(idents[id.Value], id) + } + return true + }) + + for _, test := range tests { + test := test + t.Run(test.name, func(t *testing.T) { + if got := len(idents[test.name]); got != 1 { + t.Fatalf("found %d identifiers named %s, want 1", got, test.name) + } + ident := idents[test.name][0] + def := info.Defs[ident] + if def == test.obj { + t.Fatalf("info.Defs[%s] contains the test object", test.name) + } + if orig := originObject(test.obj); def != orig { + t.Errorf("info.Defs[%s] does not match obj.Origin()", test.name) + } + if def.Pkg() != test.obj.Pkg() { + t.Errorf("Pkg() = %v, want %v", def.Pkg(), test.obj.Pkg()) + } + if def.Name() != test.obj.Name() { + t.Errorf("Name() = %v, want %v", def.Name(), test.obj.Name()) + } + if def.Pos() != test.obj.Pos() { + t.Errorf("Pos() = %v, want %v", def.Pos(), test.obj.Pos()) + } + if def.Parent() != test.obj.Parent() { + t.Fatalf("Parent() = %v, want %v", def.Parent(), test.obj.Parent()) + } + if def.Exported() != test.obj.Exported() { + t.Fatalf("Exported() = %v, want %v", def.Exported(), test.obj.Exported()) + } + if def.Id() != test.obj.Id() { + t.Fatalf("Id() = %v, want %v", def.Id(), test.obj.Id()) + } + // String and Type are expected to differ. + }) + } +} + +func originObject(obj Object) Object { + switch obj := obj.(type) { + case *Var: + return obj.Origin() + case *Func: + return obj.Origin() + } + return obj +} + +func TestImplements(t *testing.T) { + const src = ` +package p + +type EmptyIface interface{} + +type I interface { + m() +} + +type C interface { + m() + ~int +} + +type Integer interface{ + int8 | int16 | int32 | int64 +} + +type EmptyTypeSet interface{ + Integer + ~string +} + +type N1 int +func (N1) m() {} + +type N2 int +func (*N2) m() {} + +type N3 int +func (N3) m(int) {} + +type N4 string +func (N4) m() + +type Bad Bad // invalid type +` + + f := mustParse(src) + conf := Config{Error: func(error) {}} + pkg, _ := conf.Check(f.PkgName.Value, []*syntax.File{f}, nil) + + lookup := func(tname string) Type { return pkg.Scope().Lookup(tname).Type() } + var ( + EmptyIface = lookup("EmptyIface").Underlying().(*Interface) + I = lookup("I").(*Named) + II = I.Underlying().(*Interface) + C = lookup("C").(*Named) + CI = C.Underlying().(*Interface) + Integer = lookup("Integer").Underlying().(*Interface) + EmptyTypeSet = lookup("EmptyTypeSet").Underlying().(*Interface) + N1 = lookup("N1") + N1p = NewPointer(N1) + N2 = lookup("N2") + N2p = NewPointer(N2) + N3 = lookup("N3") + N4 = lookup("N4") + Bad = lookup("Bad") + ) + + tests := []struct { + V Type + T *Interface + want bool + }{ + {I, II, true}, + {I, CI, false}, + {C, II, true}, + {C, CI, true}, + {Typ[Int8], Integer, true}, + {Typ[Int64], Integer, true}, + {Typ[String], Integer, false}, + {EmptyTypeSet, II, true}, + {EmptyTypeSet, EmptyTypeSet, true}, + {Typ[Int], EmptyTypeSet, false}, + {N1, II, true}, + {N1, CI, true}, + {N1p, II, true}, + {N1p, CI, false}, + {N2, II, false}, + {N2, CI, false}, + {N2p, II, true}, + {N2p, CI, false}, + {N3, II, false}, + {N3, CI, false}, + {N4, II, true}, + {N4, CI, false}, + {Bad, II, false}, + {Bad, CI, false}, + {Bad, EmptyIface, true}, + } + + for _, test := range tests { + if got := Implements(test.V, test.T); got != test.want { + t.Errorf("Implements(%s, %s) = %t, want %t", test.V, test.T, got, test.want) + } + + // The type assertion x.(T) is valid if T is an interface or if T implements the type of x. + // The assertion is never valid if T is a bad type. + V := test.T + T := test.V + want := false + if _, ok := T.Underlying().(*Interface); (ok || Implements(T, V)) && T != Bad { + want = true + } + if got := AssertableTo(V, T); got != want { + t.Errorf("AssertableTo(%s, %s) = %t, want %t", V, T, got, want) + } + } +} + +func TestMissingMethodAlternative(t *testing.T) { + const src = ` +package p +type T interface { + m() +} + +type V0 struct{} +func (V0) m() {} + +type V1 struct{} + +type V2 struct{} +func (V2) m() int + +type V3 struct{} +func (*V3) m() + +type V4 struct{} +func (V4) M() +` + + pkg := mustTypecheck(src, nil, nil) + + T := pkg.Scope().Lookup("T").Type().Underlying().(*Interface) + lookup := func(name string) (*Func, bool) { + return MissingMethod(pkg.Scope().Lookup(name).Type(), T, true) + } + + // V0 has method m with correct signature. Should not report wrongType. + method, wrongType := lookup("V0") + if method != nil || wrongType { + t.Fatalf("V0: got method = %v, wrongType = %v", method, wrongType) + } + + checkMissingMethod := func(tname string, reportWrongType bool) { + method, wrongType := lookup(tname) + if method == nil || method.Name() != "m" || wrongType != reportWrongType { + t.Fatalf("%s: got method = %v, wrongType = %v", tname, method, wrongType) + } + } + + // V1 has no method m. Should not report wrongType. + checkMissingMethod("V1", false) + + // V2 has method m with wrong signature type (ignoring receiver). Should report wrongType. + checkMissingMethod("V2", true) + + // V3 has no method m but it exists on *V3. Should report wrongType. + checkMissingMethod("V3", true) + + // V4 has no method m but has M. Should not report wrongType. + checkMissingMethod("V4", false) +} + +func TestErrorURL(t *testing.T) { + conf := Config{ErrorURL: " [go.dev/e/%s]"} + + // test case for a one-line error + const src1 = ` +package p +var _ T +` + _, err := typecheck(src1, &conf, nil) + if err == nil || !strings.HasSuffix(err.Error(), " [go.dev/e/UndeclaredName]") { + t.Errorf("src1: unexpected error: got %v", err) + } + + // test case for a multi-line error + const src2 = ` +package p +func f() int { return 0 } +var _ = f(1, 2) +` + _, err = typecheck(src2, &conf, nil) + if err == nil || !strings.Contains(err.Error(), " [go.dev/e/WrongArgCount]\n") { + t.Errorf("src1: unexpected error: got %v", err) + } +} + +func TestModuleVersion(t *testing.T) { + // version go1.dd must be able to typecheck go1.dd.0, go1.dd.1, etc. + goversion := fmt.Sprintf("go1.%d", goversion.Version) + for _, v := range []string{ + goversion, + goversion + ".0", + goversion + ".1", + goversion + ".rc", + } { + conf := Config{GoVersion: v} + pkg := mustTypecheck("package p", &conf, nil) + if pkg.GoVersion() != conf.GoVersion { + t.Errorf("got %s; want %s", pkg.GoVersion(), conf.GoVersion) + } + } +} + +func TestFileVersions(t *testing.T) { + for _, test := range []struct { + goVersion string + fileVersion string + wantVersion string + }{ + {"", "", ""}, // no versions specified + {"go1.19", "", "go1.19"}, // module version specified + {"", "go1.20", "go1.21"}, // file version specified below minimum of 1.21 + {"go1", "", "go1"}, // no file version specified + {"go1", "goo1.22", "go1"}, // invalid file version specified + {"go1", "go1.19", "go1.21"}, // file version specified below minimum of 1.21 + {"go1", "go1.20", "go1.21"}, // file version specified below minimum of 1.21 + {"go1", "go1.21", "go1.21"}, // file version specified at 1.21 + {"go1", "go1.22", "go1.22"}, // file version specified above 1.21 + {"go1.19", "", "go1.19"}, // no file version specified + {"go1.19", "goo1.22", "go1.19"}, // invalid file version specified + {"go1.19", "go1.20", "go1.21"}, // file version specified below minimum of 1.21 + {"go1.19", "go1.21", "go1.21"}, // file version specified at 1.21 + {"go1.19", "go1.22", "go1.22"}, // file version specified above 1.21 + {"go1.20", "", "go1.20"}, // no file version specified + {"go1.20", "goo1.22", "go1.20"}, // invalid file version specified + {"go1.20", "go1.19", "go1.21"}, // file version specified below minimum of 1.21 + {"go1.20", "go1.20", "go1.21"}, // file version specified below minimum of 1.21 + {"go1.20", "go1.21", "go1.21"}, // file version specified at 1.21 + {"go1.20", "go1.22", "go1.22"}, // file version specified above 1.21 + {"go1.21", "", "go1.21"}, // no file version specified + {"go1.21", "goo1.22", "go1.21"}, // invalid file version specified + {"go1.21", "go1.19", "go1.21"}, // file version specified below minimum of 1.21 + {"go1.21", "go1.20", "go1.21"}, // file version specified below minimum of 1.21 + {"go1.21", "go1.21", "go1.21"}, // file version specified at 1.21 + {"go1.21", "go1.22", "go1.22"}, // file version specified above 1.21 + {"go1.22", "", "go1.22"}, // no file version specified + {"go1.22", "goo1.22", "go1.22"}, // invalid file version specified + {"go1.22", "go1.19", "go1.21"}, // file version specified below minimum of 1.21 + {"go1.22", "go1.20", "go1.21"}, // file version specified below minimum of 1.21 + {"go1.22", "go1.21", "go1.21"}, // file version specified at 1.21 + {"go1.22", "go1.22", "go1.22"}, // file version specified above 1.21 + + // versions containing release numbers + // (file versions containing release numbers are considered invalid) + {"go1.19.0", "", "go1.19.0"}, // no file version specified + {"go1.20.1", "go1.19.1", "go1.20.1"}, // invalid file version + {"go1.20.1", "go1.21.1", "go1.20.1"}, // invalid file version + {"go1.21.1", "go1.19.1", "go1.21.1"}, // invalid file version + {"go1.21.1", "go1.21.1", "go1.21.1"}, // invalid file version + {"go1.22.1", "go1.19.1", "go1.22.1"}, // invalid file version + {"go1.22.1", "go1.21.1", "go1.22.1"}, // invalid file version + } { + var src string + if test.fileVersion != "" { + src = "//go:build " + test.fileVersion + "\n" + } + src += "package p" + + conf := Config{GoVersion: test.goVersion} + versions := make(map[*syntax.PosBase]string) + var info Info + info.FileVersions = versions + mustTypecheck(src, &conf, &info) + + n := 0 + for _, v := range info.FileVersions { + want := test.wantVersion + if v != want { + t.Errorf("%q: unexpected file version: got %v, want %v", src, v, want) + } + n++ + } + if n != 1 { + t.Errorf("%q: incorrect number of map entries: got %d", src, n) + } + } +} + +// TestTooNew ensures that "too new" errors are emitted when the file +// or module is tagged with a newer version of Go than this go/types. +func TestTooNew(t *testing.T) { + for _, test := range []struct { + goVersion string // package's Go version (as if derived from go.mod file) + fileVersion string // file's Go version (becomes a build tag) + wantErr string // expected substring of concatenation of all errors + }{ + {"go1.98", "", "package requires newer Go version go1.98"}, + {"", "go1.99", "p:2:9: file requires newer Go version go1.99"}, + {"go1.98", "go1.99", "package requires newer Go version go1.98"}, // (two + {"go1.98", "go1.99", "file requires newer Go version go1.99"}, // errors) + } { + var src string + if test.fileVersion != "" { + src = "//go:build " + test.fileVersion + "\n" + } + src += "package p; func f()" + + var errs []error + conf := Config{ + GoVersion: test.goVersion, + Error: func(err error) { errs = append(errs, err) }, + } + info := &Info{Defs: make(map[*syntax.Name]Object)} + typecheck(src, &conf, info) + got := fmt.Sprint(errs) + if !strings.Contains(got, test.wantErr) { + t.Errorf("%q: unexpected error: got %q, want substring %q", + src, got, test.wantErr) + } + + // Assert that declarations were type checked nonetheless. + var gotObjs []string + for id, obj := range info.Defs { + if obj != nil { + objStr := strings.ReplaceAll(fmt.Sprintf("%s:%T", id.Value, obj), "types2", "types") + gotObjs = append(gotObjs, objStr) + } + } + wantObjs := "f:*types.Func" + if !strings.Contains(fmt.Sprint(gotObjs), wantObjs) { + t.Errorf("%q: got %s, want substring %q", + src, gotObjs, wantObjs) + } + } +} + +// This is a regression test for #66704. +func TestUnaliasTooSoonInCycle(t *testing.T) { + t.Setenv("GODEBUG", "gotypesalias=1") + const src = `package a + +var x T[B] // this appears to cause Unalias to be called on B while still Invalid + +type T[_ any] struct{} +type A T[B] +type B = T[A] +` + pkg := mustTypecheck(src, nil, nil) + B := pkg.Scope().Lookup("B") + + got, want := Unalias(B.Type()).String(), "a.T[a.A]" + if got != want { + t.Errorf("Unalias(type B = T[A]) = %q, want %q", got, want) + } +} + +func TestAlias_Rhs(t *testing.T) { + const src = `package p + +type A = B +type B = C +type C = int +` + + pkg := mustTypecheck(src, &Config{EnableAlias: true}, nil) + A := pkg.Scope().Lookup("A") + + got, want := A.Type().(*Alias).Rhs().String(), "p.B" + if got != want { + t.Errorf("A.Rhs = %s, want %s", got, want) + } +} + +// Test the hijacking described of "any" described in golang/go#66921, for +// (concurrent) type checking. +func TestAnyHijacking_Check(t *testing.T) { + for _, enableAlias := range []bool{false, true} { + t.Run(fmt.Sprintf("EnableAlias=%t", enableAlias), func(t *testing.T) { + var wg sync.WaitGroup + for i := 0; i < 10; i++ { + wg.Add(1) + go func() { + defer wg.Done() + pkg := mustTypecheck("package p; var x any", &Config{EnableAlias: enableAlias}, nil) + x := pkg.Scope().Lookup("x") + if _, gotAlias := x.Type().(*Alias); gotAlias != enableAlias { + t.Errorf(`Lookup("x").Type() is %T: got Alias: %t, want %t`, x.Type(), gotAlias, enableAlias) + } + }() + } + wg.Wait() + }) + } +} + +// This test function only exists for go/types. +// func TestVersionIssue69477(t *testing.T) + +// TestVersionWithoutPos is a regression test for issue #69477, +// in which the type checker would use position information +// to compute which file it is "in" based on syntax position. +// +// As a rule the type checker should not depend on position +// information for correctness, only for error messages and +// Object.Pos. (Scope.LookupParent was a mistake.) +// +// The Checker now holds the effective version in a state variable. +func TestVersionWithoutPos(t *testing.T) { + f := mustParse("//go:build go1.22\n\npackage p; var _ int") + + // Splice in a decl from another file. Its pos will be wrong. + f.DeclList[0] = mustParse("package q; func _(s func(func() bool)) { for range s {} }").DeclList[0] + + // Type check. The checker will consult the effective + // version (1.22) for the for-range stmt to know whether + // range-over-func are permitted: they are not. + // (Previously, no error was reported.) + pkg := NewPackage("p", "p") + check := NewChecker(&Config{}, pkg, nil) + err := check.Files([]*syntax.File{f}) + got := fmt.Sprint(err) + want := "range over s (variable of type func(func() bool)): requires go1.23" + if !strings.Contains(got, want) { + t.Errorf("check error was %q, want substring %q", got, want) + } +} + +func TestVarKind(t *testing.T) { + f := mustParse(`package p + +var global int + +type T struct { field int } + +func (recv T) f(param int) (result int) { + var local int + local2 := 0 + switch local3 := any(local).(type) { + default: + _ = local3 + } + return local2 +} +`) + + pkg := NewPackage("p", "p") + info := &Info{Defs: make(map[*syntax.Name]Object)} + check := NewChecker(&Config{}, pkg, info) + if err := check.Files([]*syntax.File{f}); err != nil { + t.Fatal(err) + } + var got []string + for _, obj := range info.Defs { + if v, ok := obj.(*Var); ok { + got = append(got, fmt.Sprintf("%s: %v", v.Name(), v.Kind())) + } + } + sort.Strings(got) + want := []string{ + "field: FieldVar", + "global: PackageVar", + "local2: LocalVar", + "local: LocalVar", + "param: ParamVar", + "recv: RecvVar", + "result: ResultVar", + } + if !slices.Equal(got, want) { + t.Errorf("got:\n%s\nwant:\n%s", got, want) + } +} diff --git a/go/src/cmd/compile/internal/types2/array.go b/go/src/cmd/compile/internal/types2/array.go new file mode 100644 index 0000000000000000000000000000000000000000..502d49bc25770f7bdcb3f03ba89652e64318b3c8 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/array.go @@ -0,0 +1,25 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2 + +// An Array represents an array type. +type Array struct { + len int64 + elem Type +} + +// NewArray returns a new array type for the given element type and length. +// A negative length indicates an unknown length. +func NewArray(elem Type, len int64) *Array { return &Array{len: len, elem: elem} } + +// Len returns the length of array a. +// A negative result indicates an unknown length. +func (a *Array) Len() int64 { return a.len } + +// Elem returns element type of array a. +func (a *Array) Elem() Type { return a.elem } + +func (a *Array) Underlying() Type { return a } +func (a *Array) String() string { return TypeString(a, nil) } diff --git a/go/src/cmd/compile/internal/types2/assignments.go b/go/src/cmd/compile/internal/types2/assignments.go new file mode 100644 index 0000000000000000000000000000000000000000..87f5c8beeafcafaeffeec812a727ea1887337a41 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/assignments.go @@ -0,0 +1,603 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements initialization and assignment checks. + +package types2 + +import ( + "cmd/compile/internal/syntax" + "fmt" + . "internal/types/errors" + "strings" +) + +// assignment reports whether x can be assigned to a variable of type T, +// if necessary by attempting to convert untyped values to the appropriate +// type. context describes the context in which the assignment takes place. +// Use T == nil to indicate assignment to an untyped blank identifier. +// If the assignment check fails, x.mode is set to invalid. +func (check *Checker) assignment(x *operand, T Type, context string) { + check.singleValue(x) + + switch x.mode { + case invalid: + return // error reported before + case nilvalue: + assert(isTypes2) + // ok + case constant_, variable, mapindex, value, commaok, commaerr: + // ok + default: + // we may get here because of other problems (go.dev/issue/39634, crash 12) + // TODO(gri) do we need a new "generic" error code here? + check.errorf(x, IncompatibleAssign, "cannot assign %s to %s in %s", x, T, context) + x.mode = invalid + return + } + + if isUntyped(x.typ) { + target := T + // spec: "If an untyped constant is assigned to a variable of interface + // type or the blank identifier, the constant is first converted to type + // bool, rune, int, float64, complex128 or string respectively, depending + // on whether the value is a boolean, rune, integer, floating-point, + // complex, or string constant." + if isTypes2 { + if x.isNil() { + if T == nil { + check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context) + x.mode = invalid + return + } + } else if T == nil || isNonTypeParamInterface(T) { + target = Default(x.typ) + } + } else { // go/types + if T == nil || isNonTypeParamInterface(T) { + if T == nil && x.typ == Typ[UntypedNil] { + check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context) + x.mode = invalid + return + } + target = Default(x.typ) + } + } + newType, val, code := check.implicitTypeAndValue(x, target) + if code != 0 { + msg := check.sprintf("cannot use %s as %s value in %s", x, target, context) + switch code { + case TruncatedFloat: + msg += " (truncated)" + case NumericOverflow: + msg += " (overflows)" + default: + code = IncompatibleAssign + } + check.error(x, code, msg) + x.mode = invalid + return + } + if val != nil { + x.val = val + check.updateExprVal(x.expr, val) + } + if newType != x.typ { + x.typ = newType + check.updateExprType(x.expr, newType, false) + } + } + // x.typ is typed + + // A generic (non-instantiated) function value cannot be assigned to a variable. + if sig, _ := x.typ.Underlying().(*Signature); sig != nil && sig.TypeParams().Len() > 0 { + check.errorf(x, WrongTypeArgCount, "cannot use generic function %s without instantiation in %s", x, context) + x.mode = invalid + return + } + + // spec: "If a left-hand side is the blank identifier, any typed or + // non-constant value except for the predeclared identifier nil may + // be assigned to it." + if T == nil { + return + } + + cause := "" + if ok, code := x.assignableTo(check, T, &cause); !ok { + if cause != "" { + check.errorf(x, code, "cannot use %s as %s value in %s: %s", x, T, context, cause) + } else { + check.errorf(x, code, "cannot use %s as %s value in %s", x, T, context) + } + x.mode = invalid + } +} + +func (check *Checker) initConst(lhs *Const, x *operand) { + if x.mode == invalid || !isValid(x.typ) || !isValid(lhs.typ) { + if lhs.typ == nil { + lhs.typ = Typ[Invalid] + } + return + } + + // rhs must be a constant + if x.mode != constant_ { + check.errorf(x, InvalidConstInit, "%s is not constant", x) + if lhs.typ == nil { + lhs.typ = Typ[Invalid] + } + return + } + assert(isConstType(x.typ)) + + // If the lhs doesn't have a type yet, use the type of x. + if lhs.typ == nil { + lhs.typ = x.typ + } + + check.assignment(x, lhs.typ, "constant declaration") + if x.mode == invalid { + return + } + + lhs.val = x.val +} + +// initVar checks the initialization lhs = x in a variable declaration. +// If lhs doesn't have a type yet, it is given the type of x, +// or Typ[Invalid] in case of an error. +// If the initialization check fails, x.mode is set to invalid. +func (check *Checker) initVar(lhs *Var, x *operand, context string) { + if x.mode == invalid || !isValid(x.typ) || !isValid(lhs.typ) { + if lhs.typ == nil { + lhs.typ = Typ[Invalid] + } + x.mode = invalid + return + } + + // If lhs doesn't have a type yet, use the type of x. + if lhs.typ == nil { + typ := x.typ + if isUntyped(typ) { + // convert untyped types to default types + if typ == Typ[UntypedNil] { + check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context) + lhs.typ = Typ[Invalid] + x.mode = invalid + return + } + typ = Default(typ) + } + lhs.typ = typ + } + + check.assignment(x, lhs.typ, context) +} + +// lhsVar checks a lhs variable in an assignment and returns its type. +// lhsVar takes care of not counting a lhs identifier as a "use" of +// that identifier. The result is nil if it is the blank identifier, +// and Typ[Invalid] if it is an invalid lhs expression. +func (check *Checker) lhsVar(lhs syntax.Expr) Type { + // Determine if the lhs is a (possibly parenthesized) identifier. + ident, _ := syntax.Unparen(lhs).(*syntax.Name) + + // Don't evaluate lhs if it is the blank identifier. + if ident != nil && ident.Value == "_" { + check.recordDef(ident, nil) + return nil + } + + // If the lhs is an identifier denoting a variable v, this reference + // is not a 'use' of v. Remember current value of v.used and restore + // after evaluating the lhs via check.expr. + var v *Var + var v_used bool + if ident != nil { + if obj := check.lookup(ident.Value); obj != nil { + // It's ok to mark non-local variables, but ignore variables + // from other packages to avoid potential race conditions with + // dot-imported variables. + if w, _ := obj.(*Var); w != nil && w.pkg == check.pkg { + v = w + v_used = check.usedVars[v] + } + } + } + + var x operand + check.expr(nil, &x, lhs) + + if v != nil { + check.usedVars[v] = v_used // restore v.used + } + + if x.mode == invalid || !isValid(x.typ) { + return Typ[Invalid] + } + + // spec: "Each left-hand side operand must be addressable, a map index + // expression, or the blank identifier. Operands may be parenthesized." + switch x.mode { + case invalid: + return Typ[Invalid] + case variable, mapindex: + // ok + default: + if sel, ok := x.expr.(*syntax.SelectorExpr); ok { + var op operand + check.expr(nil, &op, sel.X) + if op.mode == mapindex { + check.errorf(&x, UnaddressableFieldAssign, "cannot assign to struct field %s in map", ExprString(x.expr)) + return Typ[Invalid] + } + } + check.errorf(&x, UnassignableOperand, "cannot assign to %s (neither addressable nor a map index expression)", x.expr) + return Typ[Invalid] + } + + return x.typ +} + +// assignVar checks the assignment lhs = rhs (if x == nil), or lhs = x (if x != nil). +// If x != nil, it must be the evaluation of rhs (and rhs will be ignored). +// If the assignment check fails and x != nil, x.mode is set to invalid. +func (check *Checker) assignVar(lhs, rhs syntax.Expr, x *operand, context string) { + T := check.lhsVar(lhs) // nil if lhs is _ + if !isValid(T) { + if x != nil { + x.mode = invalid + } else { + check.use(rhs) + } + return + } + + if x == nil { + var target *target + // avoid calling ExprString if not needed + if T != nil { + if _, ok := T.Underlying().(*Signature); ok { + target = newTarget(T, ExprString(lhs)) + } + } + x = new(operand) + check.expr(target, x, rhs) + } + + if T == nil && context == "assignment" { + context = "assignment to _ identifier" + } + check.assignment(x, T, context) +} + +// operandTypes returns the list of types for the given operands. +func operandTypes(list []*operand) (res []Type) { + for _, x := range list { + res = append(res, x.typ) + } + return res +} + +// varTypes returns the list of types for the given variables. +func varTypes(list []*Var) (res []Type) { + for _, x := range list { + res = append(res, x.typ) + } + return res +} + +// typesSummary returns a string of the form "(t1, t2, ...)" where the +// ti's are user-friendly string representations for the given types. +// If variadic is set and the last type is a slice, its string is of +// the form "...E" where E is the slice's element type. +// If hasDots is set, the last argument string is of the form "T..." +// where T is the last type. +// Only one of variadic and hasDots may be set. +func (check *Checker) typesSummary(list []Type, variadic, hasDots bool) string { + assert(!(variadic && hasDots)) + var res []string + for i, t := range list { + var s string + switch { + case t == nil: + fallthrough // should not happen but be cautious + case !isValid(t): + s = "unknown type" + case isUntyped(t): // => *Basic + if isNumeric(t) { + // Do not imply a specific type requirement: + // "have number, want float64" is better than + // "have untyped int, want float64" or + // "have int, want float64". + s = "number" + } else { + // If we don't have a number, omit the "untyped" qualifier + // for compactness. + s = strings.ReplaceAll(t.(*Basic).name, "untyped ", "") + } + default: + s = check.sprintf("%s", t) + } + // handle ... parameters/arguments + if i == len(list)-1 { + switch { + case variadic: + // In correct code, the parameter type is a slice, but be careful. + if t, _ := t.(*Slice); t != nil { + s = check.sprintf("%s", t.elem) + } + s = "..." + s + case hasDots: + s += "..." + } + } + res = append(res, s) + } + return "(" + strings.Join(res, ", ") + ")" +} + +func measure(x int, unit string) string { + if x != 1 { + unit += "s" + } + return fmt.Sprintf("%d %s", x, unit) +} + +func (check *Checker) assignError(rhs []syntax.Expr, l, r int) { + vars := measure(l, "variable") + vals := measure(r, "value") + rhs0 := rhs[0] + + if len(rhs) == 1 { + if call, _ := syntax.Unparen(rhs0).(*syntax.CallExpr); call != nil { + check.errorf(rhs0, WrongAssignCount, "assignment mismatch: %s but %s returns %s", vars, call.Fun, vals) + return + } + } + check.errorf(rhs0, WrongAssignCount, "assignment mismatch: %s but %s", vars, vals) +} + +func (check *Checker) returnError(at poser, lhs []*Var, rhs []*operand) { + l, r := len(lhs), len(rhs) + qualifier := "not enough" + if r > l { + at = rhs[l] // report at first extra value + qualifier = "too many" + } else if r > 0 { + at = rhs[r-1] // report at last value + } + err := check.newError(WrongResultCount) + err.addf(at, "%s return values", qualifier) + err.addf(nopos, "have %s", check.typesSummary(operandTypes(rhs), false, false)) + err.addf(nopos, "want %s", check.typesSummary(varTypes(lhs), false, false)) + err.report() +} + +// initVars type-checks assignments of initialization expressions orig_rhs +// to variables lhs. +// If returnStmt is non-nil, initVars type-checks the implicit assignment +// of result expressions orig_rhs to function result parameters lhs. +func (check *Checker) initVars(lhs []*Var, orig_rhs []syntax.Expr, returnStmt syntax.Stmt) { + context := "assignment" + if returnStmt != nil { + context = "return statement" + } + + l, r := len(lhs), len(orig_rhs) + + // If l == 1 and the rhs is a single call, for a better + // error message don't handle it as n:n mapping below. + isCall := false + if r == 1 { + _, isCall = syntax.Unparen(orig_rhs[0]).(*syntax.CallExpr) + } + + // If we have a n:n mapping from lhs variable to rhs expression, + // each value can be assigned to its corresponding variable. + if l == r && !isCall { + var x operand + for i, lhs := range lhs { + desc := lhs.name + if returnStmt != nil && desc == "" { + desc = "result variable" + } + check.expr(newTarget(lhs.typ, desc), &x, orig_rhs[i]) + check.initVar(lhs, &x, context) + } + return + } + + // If we don't have an n:n mapping, the rhs must be a single expression + // resulting in 2 or more values; otherwise we have an assignment mismatch. + if r != 1 { + // Only report a mismatch error if there are no other errors on the rhs. + if check.use(orig_rhs...) { + if returnStmt != nil { + rhs := check.exprList(orig_rhs) + check.returnError(returnStmt, lhs, rhs) + } else { + check.assignError(orig_rhs, l, r) + } + } + // ensure that LHS variables have a type + for _, v := range lhs { + if v.typ == nil { + v.typ = Typ[Invalid] + } + } + return + } + + rhs, commaOk := check.multiExpr(orig_rhs[0], l == 2 && returnStmt == nil) + r = len(rhs) + if l == r { + for i, lhs := range lhs { + check.initVar(lhs, rhs[i], context) + } + // Only record comma-ok expression if both initializations succeeded + // (go.dev/issue/59371). + if commaOk && rhs[0].mode != invalid && rhs[1].mode != invalid { + check.recordCommaOkTypes(orig_rhs[0], rhs) + } + return + } + + // In all other cases we have an assignment mismatch. + // Only report a mismatch error if there are no other errors on the rhs. + if rhs[0].mode != invalid { + if returnStmt != nil { + check.returnError(returnStmt, lhs, rhs) + } else { + check.assignError(orig_rhs, l, r) + } + } + // ensure that LHS variables have a type + for _, v := range lhs { + if v.typ == nil { + v.typ = Typ[Invalid] + } + } + // orig_rhs[0] was already evaluated +} + +// assignVars type-checks assignments of expressions orig_rhs to variables lhs. +func (check *Checker) assignVars(lhs, orig_rhs []syntax.Expr) { + l, r := len(lhs), len(orig_rhs) + + // If l == 1 and the rhs is a single call, for a better + // error message don't handle it as n:n mapping below. + isCall := false + if r == 1 { + _, isCall = syntax.Unparen(orig_rhs[0]).(*syntax.CallExpr) + } + + // If we have a n:n mapping from lhs variable to rhs expression, + // each value can be assigned to its corresponding variable. + if l == r && !isCall { + for i, lhs := range lhs { + check.assignVar(lhs, orig_rhs[i], nil, "assignment") + } + return + } + + // If we don't have an n:n mapping, the rhs must be a single expression + // resulting in 2 or more values; otherwise we have an assignment mismatch. + if r != 1 { + // Only report a mismatch error if there are no other errors on the lhs or rhs. + okLHS := check.useLHS(lhs...) + okRHS := check.use(orig_rhs...) + if okLHS && okRHS { + check.assignError(orig_rhs, l, r) + } + return + } + + rhs, commaOk := check.multiExpr(orig_rhs[0], l == 2) + r = len(rhs) + if l == r { + for i, lhs := range lhs { + check.assignVar(lhs, nil, rhs[i], "assignment") + } + // Only record comma-ok expression if both assignments succeeded + // (go.dev/issue/59371). + if commaOk && rhs[0].mode != invalid && rhs[1].mode != invalid { + check.recordCommaOkTypes(orig_rhs[0], rhs) + } + return + } + + // In all other cases we have an assignment mismatch. + // Only report a mismatch error if there are no other errors on the rhs. + if rhs[0].mode != invalid { + check.assignError(orig_rhs, l, r) + } + check.useLHS(lhs...) + // orig_rhs[0] was already evaluated +} + +func (check *Checker) shortVarDecl(pos poser, lhs, rhs []syntax.Expr) { + top := len(check.delayed) + scope := check.scope + + // collect lhs variables + seen := make(map[string]bool, len(lhs)) + lhsVars := make([]*Var, len(lhs)) + newVars := make([]*Var, 0, len(lhs)) + hasErr := false + for i, lhs := range lhs { + ident, _ := lhs.(*syntax.Name) + if ident == nil { + check.useLHS(lhs) + // TODO(gri) This is redundant with a go/parser error. Consider omitting in go/types? + check.errorf(lhs, BadDecl, "non-name %s on left side of :=", lhs) + hasErr = true + continue + } + + name := ident.Value + if name != "_" { + if seen[name] { + check.errorf(lhs, RepeatedDecl, "%s repeated on left side of :=", lhs) + hasErr = true + continue + } + seen[name] = true + } + + // Use the correct obj if the ident is redeclared. The + // variable's scope starts after the declaration; so we + // must use Scope.Lookup here and call Scope.Insert + // (via check.declare) later. + if alt := scope.Lookup(name); alt != nil { + check.recordUse(ident, alt) + // redeclared object must be a variable + if obj, _ := alt.(*Var); obj != nil { + lhsVars[i] = obj + } else { + check.errorf(lhs, UnassignableOperand, "cannot assign to %s", lhs) + hasErr = true + } + continue + } + + // declare new variable + obj := newVar(LocalVar, ident.Pos(), check.pkg, name, nil) + lhsVars[i] = obj + if name != "_" { + newVars = append(newVars, obj) + } + check.recordDef(ident, obj) + } + + // create dummy variables where the lhs is invalid + for i, obj := range lhsVars { + if obj == nil { + lhsVars[i] = newVar(LocalVar, lhs[i].Pos(), check.pkg, "_", nil) + } + } + + check.initVars(lhsVars, rhs, nil) + + // process function literals in rhs expressions before scope changes + check.processDelayed(top) + + if len(newVars) == 0 && !hasErr { + check.softErrorf(pos, NoNewVar, "no new variables on left side of :=") + return + } + + // declare new variables + // spec: "The scope of a constant or variable identifier declared inside + // a function begins at the end of the ConstSpec or VarSpec (ShortVarDecl + // for short variable declarations) and ends at the end of the innermost + // containing block." + scopePos := endPos(rhs[len(rhs)-1]) + for _, obj := range newVars { + check.declare(scope, nil, obj, scopePos) // id = nil: recordDef already called + } +} diff --git a/go/src/cmd/compile/internal/types2/basic.go b/go/src/cmd/compile/internal/types2/basic.go new file mode 100644 index 0000000000000000000000000000000000000000..2fd973cafbc5e66022c8455e9073237e15de2c64 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/basic.go @@ -0,0 +1,82 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2 + +// BasicKind describes the kind of basic type. +type BasicKind int + +const ( + Invalid BasicKind = iota // type is invalid + + // predeclared types + Bool + Int + Int8 + Int16 + Int32 + Int64 + Uint + Uint8 + Uint16 + Uint32 + Uint64 + Uintptr + Float32 + Float64 + Complex64 + Complex128 + String + UnsafePointer + + // types for untyped values + UntypedBool + UntypedInt + UntypedRune + UntypedFloat + UntypedComplex + UntypedString + UntypedNil + + // aliases + Byte = Uint8 + Rune = Int32 +) + +// BasicInfo is a set of flags describing properties of a basic type. +type BasicInfo int + +// Properties of basic types. +const ( + IsBoolean BasicInfo = 1 << iota + IsInteger + IsUnsigned + IsFloat + IsComplex + IsString + IsUntyped + + IsOrdered = IsInteger | IsFloat | IsString + IsNumeric = IsInteger | IsFloat | IsComplex + IsConstType = IsBoolean | IsNumeric | IsString +) + +// A Basic represents a basic type. +type Basic struct { + kind BasicKind + info BasicInfo + name string +} + +// Kind returns the kind of basic type b. +func (b *Basic) Kind() BasicKind { return b.kind } + +// Info returns information about properties of basic type b. +func (b *Basic) Info() BasicInfo { return b.info } + +// Name returns the name of basic type b. +func (b *Basic) Name() string { return b.name } + +func (b *Basic) Underlying() Type { return b } +func (b *Basic) String() string { return TypeString(b, nil) } diff --git a/go/src/cmd/compile/internal/types2/builtins.go b/go/src/cmd/compile/internal/types2/builtins.go new file mode 100644 index 0000000000000000000000000000000000000000..c0073c5136b0c705aa81f4bf3587fae6954910b6 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/builtins.go @@ -0,0 +1,1124 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements typechecking of builtin function calls. + +package types2 + +import ( + "cmd/compile/internal/syntax" + "go/constant" + "go/token" + . "internal/types/errors" +) + +// builtin type-checks a call to the built-in specified by id and +// reports whether the call is valid, with *x holding the result; +// but x.expr is not set. If the call is invalid, the result is +// false, and *x is undefined. +func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (_ bool) { + argList := call.ArgList + + // append is the only built-in that permits the use of ... for the last argument + bin := predeclaredFuncs[id] + if hasDots(call) && id != _Append { + check.errorf(dddErrPos(call), + InvalidDotDotDot, + invalidOp+"invalid use of ... with built-in %s", bin.name) + check.use(argList...) + return + } + + // For len(x) and cap(x) we need to know if x contains any function calls or + // receive operations. Save/restore current setting and set hasCallOrRecv to + // false for the evaluation of x so that we can check it afterwards. + // Note: We must do this _before_ calling exprList because exprList evaluates + // all arguments. + if id == _Len || id == _Cap { + defer func(b bool) { + check.hasCallOrRecv = b + }(check.hasCallOrRecv) + check.hasCallOrRecv = false + } + + // Evaluate arguments for built-ins that use ordinary (value) arguments. + // For built-ins with special argument handling (make, new, etc.), + // evaluation is done by the respective built-in code. + var args []*operand // not valid for _Make, _New, _Offsetof, _Trace + var nargs int + switch id { + default: + // check all arguments + args = check.exprList(argList) + nargs = len(args) + for _, a := range args { + if a.mode == invalid { + return + } + } + // first argument is always in x + if nargs > 0 { + *x = *args[0] + } + case _Make, _New, _Offsetof, _Trace: + // arguments require special handling + nargs = len(argList) + } + + // check argument count + { + msg := "" + if nargs < bin.nargs { + msg = "not enough" + } else if !bin.variadic && nargs > bin.nargs { + msg = "too many" + } + if msg != "" { + check.errorf(argErrPos(call), WrongArgCount, invalidOp+"%s arguments for %v (expected %d, found %d)", msg, call, bin.nargs, nargs) + return + } + } + + switch id { + case _Append: + // append(s S, x ...E) S, where E is the element type of S + // spec: "The variadic function append appends zero or more values x to + // a slice s of type S and returns the resulting slice, also of type S. + // The values x are passed to a parameter of type ...E where E is the + // element type of S and the respective parameter passing rules apply. + // As a special case, append also accepts a first argument assignable + // to type []byte with a second argument of string type followed by ... . + // This form appends the bytes of the string." + + // In either case, the first argument must be a slice; in particular it + // cannot be the predeclared nil value. Note that nil is not excluded by + // the assignability requirement alone for the special case (go.dev/issue/76220). + // spec: "If S is a type parameter, all types in its type set + // must have the same underlying slice type []E." + E, err := sliceElem(x) + if err != nil { + check.errorf(x, InvalidAppend, "invalid append: %s", err.format(check)) + return + } + + // Handle append(bytes, y...) special case, where + // the type set of y is {string} or {string, []byte}. + var sig *Signature + if nargs == 2 && hasDots(call) { + if ok, _ := x.assignableTo(check, NewSlice(universeByte), nil); ok { + y := args[1] + hasString := false + for _, u := range typeset(y.typ) { + if s, _ := u.(*Slice); s != nil && Identical(s.elem, universeByte) { + // typeset ⊇ {[]byte} + } else if u != nil && isString(u) { + // typeset ⊇ {string} + hasString = true + } else { + y = nil + break + } + } + if y != nil && hasString { + // setting the signature also signals that we're done + sig = makeSig(x.typ, x.typ, y.typ) + sig.variadic = true + } + } + } + + // general case + if sig == nil { + // check arguments by creating custom signature + sig = makeSig(x.typ, x.typ, NewSlice(E)) // []E required for variadic signature + sig.variadic = true + check.arguments(call, sig, nil, nil, args, nil) // discard result (we know the result type) + // ok to continue even if check.arguments reported errors + } + + if check.recordTypes() { + check.recordBuiltinType(call.Fun, sig) + } + x.mode = value + // x.typ is unchanged + + case _Cap, _Len: + // cap(x) + // len(x) + mode := invalid + var val constant.Value + switch t := arrayPtrDeref(x.typ.Underlying()).(type) { + case *Basic: + if isString(t) && id == _Len { + if x.mode == constant_ { + mode = constant_ + val = constant.MakeInt64(int64(len(constant.StringVal(x.val)))) + } else { + mode = value + } + } + + case *Array: + mode = value + // spec: "The expressions len(s) and cap(s) are constants + // if the type of s is an array or pointer to an array and + // the expression s does not contain channel receives or + // function calls; in this case s is not evaluated." + if !check.hasCallOrRecv { + mode = constant_ + if t.len >= 0 { + val = constant.MakeInt64(t.len) + } else { + val = constant.MakeUnknown() + } + } + + case *Slice, *Chan: + mode = value + + case *Map: + if id == _Len { + mode = value + } + + case *Interface: + if !isTypeParam(x.typ) { + break + } + if underIs(x.typ, func(u Type) bool { + switch t := arrayPtrDeref(u).(type) { + case *Basic: + if isString(t) && id == _Len { + return true + } + case *Array, *Slice, *Chan: + return true + case *Map: + if id == _Len { + return true + } + } + return false + }) { + mode = value + } + } + + if mode == invalid { + // avoid error if underlying type is invalid + if isValid(x.typ.Underlying()) { + code := InvalidCap + if id == _Len { + code = InvalidLen + } + check.errorf(x, code, invalidArg+"%s for built-in %s", x, bin.name) + } + return + } + + // record the signature before changing x.typ + if check.recordTypes() && mode != constant_ { + check.recordBuiltinType(call.Fun, makeSig(Typ[Int], x.typ)) + } + + x.mode = mode + x.typ = Typ[Int] + x.val = val + + case _Clear: + // clear(m) + check.verifyVersionf(call.Fun, go1_21, "clear") + + if !underIs(x.typ, func(u Type) bool { + switch u.(type) { + case *Map, *Slice: + return true + } + check.errorf(x, InvalidClear, invalidArg+"cannot clear %s: argument must be (or constrained by) map or slice", x) + return false + }) { + return + } + + x.mode = novalue + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(nil, x.typ)) + } + + case _Close: + // close(c) + if !underIs(x.typ, func(u Type) bool { + uch, _ := u.(*Chan) + if uch == nil { + check.errorf(x, InvalidClose, invalidOp+"cannot close non-channel %s", x) + return false + } + if uch.dir == RecvOnly { + check.errorf(x, InvalidClose, invalidOp+"cannot close receive-only channel %s", x) + return false + } + return true + }) { + return + } + x.mode = novalue + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(nil, x.typ)) + } + + case _Complex: + // complex(x, y floatT) complexT + y := args[1] + + // convert or check untyped arguments + d := 0 + if isUntyped(x.typ) { + d |= 1 + } + if isUntyped(y.typ) { + d |= 2 + } + switch d { + case 0: + // x and y are typed => nothing to do + case 1: + // only x is untyped => convert to type of y + check.convertUntyped(x, y.typ) + case 2: + // only y is untyped => convert to type of x + check.convertUntyped(y, x.typ) + case 3: + // x and y are untyped => + // 1) if both are constants, convert them to untyped + // floating-point numbers if possible, + // 2) if one of them is not constant (possible because + // it contains a shift that is yet untyped), convert + // both of them to float64 since they must have the + // same type to succeed (this will result in an error + // because shifts of floats are not permitted) + if x.mode == constant_ && y.mode == constant_ { + toFloat := func(x *operand) { + if isNumeric(x.typ) && constant.Sign(constant.Imag(x.val)) == 0 { + x.typ = Typ[UntypedFloat] + } + } + toFloat(x) + toFloat(y) + } else { + check.convertUntyped(x, Typ[Float64]) + check.convertUntyped(y, Typ[Float64]) + // x and y should be invalid now, but be conservative + // and check below + } + } + if x.mode == invalid || y.mode == invalid { + return + } + + // both argument types must be identical + if !Identical(x.typ, y.typ) { + check.errorf(x, InvalidComplex, invalidOp+"%v (mismatched types %s and %s)", call, x.typ, y.typ) + return + } + + // the argument types must be of floating-point type + // (applyTypeFunc never calls f with a type parameter) + f := func(typ Type) Type { + assert(!isTypeParam(typ)) + if t, _ := typ.Underlying().(*Basic); t != nil { + switch t.kind { + case Float32: + return Typ[Complex64] + case Float64: + return Typ[Complex128] + case UntypedFloat: + return Typ[UntypedComplex] + } + } + return nil + } + resTyp := check.applyTypeFunc(f, x, id) + if resTyp == nil { + check.errorf(x, InvalidComplex, invalidArg+"arguments have type %s, expected floating-point", x.typ) + return + } + + // if both arguments are constants, the result is a constant + if x.mode == constant_ && y.mode == constant_ { + x.val = constant.BinaryOp(constant.ToFloat(x.val), token.ADD, constant.MakeImag(constant.ToFloat(y.val))) + } else { + x.mode = value + } + + if check.recordTypes() && x.mode != constant_ { + check.recordBuiltinType(call.Fun, makeSig(resTyp, x.typ, x.typ)) + } + + x.typ = resTyp + + case _Copy: + // copy(x, y []E) int + // spec: "The function copy copies slice elements from a source src to a destination + // dst and returns the number of elements copied. Both arguments must have identical + // element type E and must be assignable to a slice of type []E. + // The number of elements copied is the minimum of len(src) and len(dst). + // As a special case, copy also accepts a destination argument assignable to type + // []byte with a source argument of a string type. + // This form copies the bytes from the string into the byte slice." + + // get special case out of the way + y := args[1] + var special bool + if ok, _ := x.assignableTo(check, NewSlice(universeByte), nil); ok { + special = true + for _, u := range typeset(y.typ) { + if s, _ := u.(*Slice); s != nil && Identical(s.elem, universeByte) { + // typeset ⊇ {[]byte} + } else if u != nil && isString(u) { + // typeset ⊇ {string} + } else { + special = false + break + } + } + } + + // general case + if !special { + // spec: "If the type of one or both arguments is a type parameter, all types + // in their respective type sets must have the same underlying slice type []E." + dstE, err := sliceElem(x) + if err != nil { + check.errorf(x, InvalidCopy, "invalid copy: %s", err.format(check)) + return + } + srcE, err := sliceElem(y) + if err != nil { + // If we have a string, for a better error message proceed with byte element type. + if !allString(y.typ) { + check.errorf(y, InvalidCopy, "invalid copy: %s", err.format(check)) + return + } + srcE = universeByte + } + if !Identical(dstE, srcE) { + check.errorf(x, InvalidCopy, "invalid copy: arguments %s and %s have different element types %s and %s", x, y, dstE, srcE) + return + } + } + + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(Typ[Int], x.typ, y.typ)) + } + x.mode = value + x.typ = Typ[Int] + + case _Delete: + // delete(map_, key) + // map_ must be a map type or a type parameter describing map types. + // The key cannot be a type parameter for now. + map_ := x.typ + var key Type + if !underIs(map_, func(u Type) bool { + map_, _ := u.(*Map) + if map_ == nil { + check.errorf(x, InvalidDelete, invalidArg+"%s is not a map", x) + return false + } + if key != nil && !Identical(map_.key, key) { + check.errorf(x, InvalidDelete, invalidArg+"maps of %s must have identical key types", x) + return false + } + key = map_.key + return true + }) { + return + } + + *x = *args[1] // key + check.assignment(x, key, "argument to delete") + if x.mode == invalid { + return + } + + x.mode = novalue + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(nil, map_, key)) + } + + case _Imag, _Real: + // imag(complexT) floatT + // real(complexT) floatT + + // convert or check untyped argument + if isUntyped(x.typ) { + if x.mode == constant_ { + // an untyped constant number can always be considered + // as a complex constant + if isNumeric(x.typ) { + x.typ = Typ[UntypedComplex] + } + } else { + // an untyped non-constant argument may appear if + // it contains a (yet untyped non-constant) shift + // expression: convert it to complex128 which will + // result in an error (shift of complex value) + check.convertUntyped(x, Typ[Complex128]) + // x should be invalid now, but be conservative and check + if x.mode == invalid { + return + } + } + } + + // the argument must be of complex type + // (applyTypeFunc never calls f with a type parameter) + f := func(typ Type) Type { + assert(!isTypeParam(typ)) + if t, _ := typ.Underlying().(*Basic); t != nil { + switch t.kind { + case Complex64: + return Typ[Float32] + case Complex128: + return Typ[Float64] + case UntypedComplex: + return Typ[UntypedFloat] + } + } + return nil + } + resTyp := check.applyTypeFunc(f, x, id) + if resTyp == nil { + code := InvalidImag + if id == _Real { + code = InvalidReal + } + check.errorf(x, code, invalidArg+"argument has type %s, expected complex type", x.typ) + return + } + + // if the argument is a constant, the result is a constant + if x.mode == constant_ { + if id == _Real { + x.val = constant.Real(x.val) + } else { + x.val = constant.Imag(x.val) + } + } else { + x.mode = value + } + + if check.recordTypes() && x.mode != constant_ { + check.recordBuiltinType(call.Fun, makeSig(resTyp, x.typ)) + } + + x.typ = resTyp + + case _Make: + // make(T, n) + // make(T, n, m) + // (no argument evaluated yet) + arg0 := argList[0] + T := check.varType(arg0) + if !isValid(T) { + return + } + + u, err := commonUnder(T, func(_, u Type) *typeError { + switch u.(type) { + case *Slice, *Map, *Chan: + return nil // ok + case nil: + return typeErrorf("no specific type") + default: + return typeErrorf("type must be slice, map, or channel") + } + }) + if err != nil { + check.errorf(arg0, InvalidMake, invalidArg+"cannot make %s: %s", arg0, err.format(check)) + return + } + + var min int // minimum number of arguments + switch u.(type) { + case *Slice: + min = 2 + case *Map, *Chan: + min = 1 + default: + // any other type was excluded above + panic("unreachable") + } + if nargs < min || min+1 < nargs { + check.errorf(call, WrongArgCount, invalidOp+"%v expects %d or %d arguments; found %d", call, min, min+1, nargs) + return + } + + types := []Type{T} + var sizes []int64 // constant integer arguments, if any + for _, arg := range argList[1:] { + typ, size := check.index(arg, -1) // ok to continue with typ == Typ[Invalid] + types = append(types, typ) + if size >= 0 { + sizes = append(sizes, size) + } + } + if len(sizes) == 2 && sizes[0] > sizes[1] { + check.error(argList[1], SwappedMakeArgs, invalidArg+"length and capacity swapped") + // safe to continue + } + x.mode = value + x.typ = T + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(x.typ, types...)) + } + + case _Max, _Min: + // max(x, ...) + // min(x, ...) + check.verifyVersionf(call.Fun, go1_21, "built-in %s", bin.name) + + op := token.LSS + if id == _Max { + op = token.GTR + } + + for i, a := range args { + if a.mode == invalid { + return + } + + if !allOrdered(a.typ) { + check.errorf(a, InvalidMinMaxOperand, invalidArg+"%s cannot be ordered", a) + return + } + + // The first argument is already in x and there's nothing left to do. + if i > 0 { + check.matchTypes(x, a) + if x.mode == invalid { + return + } + + if !Identical(x.typ, a.typ) { + check.errorf(a, MismatchedTypes, invalidArg+"mismatched types %s (previous argument) and %s (type of %s)", x.typ, a.typ, a.expr) + return + } + + if x.mode == constant_ && a.mode == constant_ { + if constant.Compare(a.val, op, x.val) { + *x = *a + } + } else { + x.mode = value + } + } + } + + // If nargs == 1, make sure x.mode is either a value or a constant. + if x.mode != constant_ { + x.mode = value + // A value must not be untyped. + check.assignment(x, &emptyInterface, "argument to built-in "+bin.name) + if x.mode == invalid { + return + } + } + + // Use the final type computed above for all arguments. + for _, a := range args { + check.updateExprType(a.expr, x.typ, true) + } + + if check.recordTypes() && x.mode != constant_ { + types := make([]Type, nargs) + for i := range types { + types[i] = x.typ + } + check.recordBuiltinType(call.Fun, makeSig(x.typ, types...)) + } + + case _New: + // new(T) or new(expr) + // (no argument evaluated yet) + arg := argList[0] + check.exprOrType(x, arg, false) + check.exclude(x, 1< 0 { + // function has result parameters + p := check.isPanic + if p == nil { + // allocate lazily + p = make(map[*syntax.CallExpr]bool) + check.isPanic = p + } + p[call] = true + } + + check.assignment(x, &emptyInterface, "argument to panic") + if x.mode == invalid { + return + } + + x.mode = novalue + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(nil, &emptyInterface)) + } + + case _Print, _Println: + // print(x, y, ...) + // println(x, y, ...) + var params []Type + if nargs > 0 { + params = make([]Type, nargs) + for i, a := range args { + check.assignment(a, nil, "argument to built-in "+predeclaredFuncs[id].name) + if a.mode == invalid { + return + } + params[i] = a.typ + } + } + + x.mode = novalue + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(nil, params...)) + } + + case _Recover: + // recover() interface{} + x.mode = value + x.typ = &emptyInterface + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(x.typ)) + } + + case _Add: + // unsafe.Add(ptr unsafe.Pointer, len IntegerType) unsafe.Pointer + check.verifyVersionf(call.Fun, go1_17, "unsafe.Add") + + check.assignment(x, Typ[UnsafePointer], "argument to unsafe.Add") + if x.mode == invalid { + return + } + + y := args[1] + if !check.isValidIndex(y, InvalidUnsafeAdd, "length", true) { + return + } + + x.mode = value + x.typ = Typ[UnsafePointer] + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(x.typ, x.typ, y.typ)) + } + + case _Alignof: + // unsafe.Alignof(x T) uintptr + check.assignment(x, nil, "argument to unsafe.Alignof") + if x.mode == invalid { + return + } + + if hasVarSize(x.typ, nil) { + x.mode = value + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], x.typ)) + } + } else { + x.mode = constant_ + x.val = constant.MakeInt64(check.conf.alignof(x.typ)) + // result is constant - no need to record signature + } + x.typ = Typ[Uintptr] + + case _Offsetof: + // unsafe.Offsetof(x T) uintptr, where x must be a selector + // (no argument evaluated yet) + arg0 := argList[0] + selx, _ := syntax.Unparen(arg0).(*syntax.SelectorExpr) + if selx == nil { + check.errorf(arg0, BadOffsetofSyntax, invalidArg+"%s is not a selector expression", arg0) + check.use(arg0) + return + } + + check.expr(nil, x, selx.X) + if x.mode == invalid { + return + } + + base := derefStructPtr(x.typ) + sel := selx.Sel.Value + obj, index, indirect := lookupFieldOrMethod(base, false, check.pkg, sel, false) + switch obj.(type) { + case nil: + check.errorf(x, MissingFieldOrMethod, invalidArg+"%s has no single field %s", base, sel) + return + case *Func: + // TODO(gri) Using derefStructPtr may result in methods being found + // that don't actually exist. An error either way, but the error + // message is confusing. See: https://play.golang.org/p/al75v23kUy , + // but go/types reports: "invalid argument: x.m is a method value". + check.errorf(arg0, InvalidOffsetof, invalidArg+"%s is a method value", arg0) + return + } + if indirect { + check.errorf(x, InvalidOffsetof, invalidArg+"field %s is embedded via a pointer in %s", sel, base) + return + } + + // TODO(gri) Should we pass x.typ instead of base (and have indirect report if derefStructPtr indirected)? + check.recordSelection(selx, FieldVal, base, obj, index, false) + + // record the selector expression (was bug - go.dev/issue/47895) + { + mode := value + if x.mode == variable || indirect { + mode = variable + } + check.record(&operand{mode, selx, obj.Type(), nil, 0}) + } + + // The field offset is considered a variable even if the field is declared before + // the part of the struct which is variable-sized. This makes both the rules + // simpler and also permits (or at least doesn't prevent) a compiler from re- + // arranging struct fields if it wanted to. + if hasVarSize(base, nil) { + x.mode = value + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], obj.Type())) + } + } else { + offs := check.conf.offsetof(base, index) + if offs < 0 { + check.errorf(x, TypeTooLarge, "%s is too large", x) + return + } + x.mode = constant_ + x.val = constant.MakeInt64(offs) + // result is constant - no need to record signature + } + x.typ = Typ[Uintptr] + + case _Sizeof: + // unsafe.Sizeof(x T) uintptr + check.assignment(x, nil, "argument to unsafe.Sizeof") + if x.mode == invalid { + return + } + + if hasVarSize(x.typ, nil) { + x.mode = value + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], x.typ)) + } + } else { + size := check.conf.sizeof(x.typ) + if size < 0 { + check.errorf(x, TypeTooLarge, "%s is too large", x) + return + } + x.mode = constant_ + x.val = constant.MakeInt64(size) + // result is constant - no need to record signature + } + x.typ = Typ[Uintptr] + + case _Slice: + // unsafe.Slice(ptr *T, len IntegerType) []T + check.verifyVersionf(call.Fun, go1_17, "unsafe.Slice") + + u, _ := commonUnder(x.typ, nil) + ptr, _ := u.(*Pointer) + if ptr == nil { + check.errorf(x, InvalidUnsafeSlice, invalidArg+"%s is not a pointer", x) + return + } + + y := args[1] + if !check.isValidIndex(y, InvalidUnsafeSlice, "length", false) { + return + } + + x.mode = value + x.typ = NewSlice(ptr.base) + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(x.typ, ptr, y.typ)) + } + + case _SliceData: + // unsafe.SliceData(slice []T) *T + check.verifyVersionf(call.Fun, go1_20, "unsafe.SliceData") + + u, _ := commonUnder(x.typ, nil) + slice, _ := u.(*Slice) + if slice == nil { + check.errorf(x, InvalidUnsafeSliceData, invalidArg+"%s is not a slice", x) + return + } + + x.mode = value + x.typ = NewPointer(slice.elem) + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(x.typ, slice)) + } + + case _String: + // unsafe.String(ptr *byte, len IntegerType) string + check.verifyVersionf(call.Fun, go1_20, "unsafe.String") + + check.assignment(x, NewPointer(universeByte), "argument to unsafe.String") + if x.mode == invalid { + return + } + + y := args[1] + if !check.isValidIndex(y, InvalidUnsafeString, "length", false) { + return + } + + x.mode = value + x.typ = Typ[String] + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(x.typ, NewPointer(universeByte), y.typ)) + } + + case _StringData: + // unsafe.StringData(str string) *byte + check.verifyVersionf(call.Fun, go1_20, "unsafe.StringData") + + check.assignment(x, Typ[String], "argument to unsafe.StringData") + if x.mode == invalid { + return + } + + x.mode = value + x.typ = NewPointer(universeByte) + if check.recordTypes() { + check.recordBuiltinType(call.Fun, makeSig(x.typ, Typ[String])) + } + + case _Assert: + // assert(pred) causes a typechecker error if pred is false. + // The result of assert is the value of pred if there is no error. + // Note: assert is only available in self-test mode. + if x.mode != constant_ || !isBoolean(x.typ) { + check.errorf(x, Test, invalidArg+"%s is not a boolean constant", x) + return + } + if x.val.Kind() != constant.Bool { + check.errorf(x, Test, "internal error: value of %s should be a boolean constant", x) + return + } + if !constant.BoolVal(x.val) { + check.errorf(call, Test, "%v failed", call) + // compile-time assertion failure - safe to continue + } + // result is constant - no need to record signature + + case _Trace: + // trace(x, y, z, ...) dumps the positions, expressions, and + // values of its arguments. The result of trace is the value + // of the first argument. + // Note: trace is only available in self-test mode. + // (no argument evaluated yet) + if nargs == 0 { + check.dump("%v: trace() without arguments", atPos(call)) + x.mode = novalue + break + } + var t operand + x1 := x + for _, arg := range argList { + check.rawExpr(nil, x1, arg, nil, false) // permit trace for types, e.g.: new(trace(T)) + check.dump("%v: %s", atPos(x1), x1) + x1 = &t // use incoming x only for first argument + } + if x.mode == invalid { + return + } + // trace is only available in test mode - no need to record signature + + default: + panic("unreachable") + } + + assert(x.mode != invalid) + return true +} + +// sliceElem returns the slice element type for a slice operand x +// or a type error if x is not a slice (or a type set of slices). +func sliceElem(x *operand) (Type, *typeError) { + var E Type + for _, u := range typeset(x.typ) { + s, _ := u.(*Slice) + if s == nil { + if x.isNil() { + // Printing x in this case would just print "nil". + // Special case this so we can emphasize "untyped". + return nil, typeErrorf("argument must be a slice; have untyped nil") + } else { + return nil, typeErrorf("argument must be a slice; have %s", x) + } + } + if E == nil { + E = s.elem + } else if !Identical(E, s.elem) { + return nil, typeErrorf("mismatched slice element types %s and %s in %s", E, s.elem, x) + } + } + return E, nil +} + +// hasVarSize reports if the size of type t is variable due to type parameters +// or if the type is infinitely-sized due to a cycle for which the type has not +// yet been checked. +func hasVarSize(t Type, seen map[*Named]bool) (varSized bool) { + // Cycles are only possible through *Named types. + // The seen map is used to detect cycles and track + // the results of previously seen types. + if named := asNamed(t); named != nil { + if v, ok := seen[named]; ok { + return v + } + if seen == nil { + seen = make(map[*Named]bool) + } + seen[named] = true // possibly cyclic until proven otherwise + defer func() { + seen[named] = varSized // record final determination for named + }() + } + + switch u := t.Underlying().(type) { + case *Array: + return hasVarSize(u.elem, seen) + case *Struct: + for _, f := range u.fields { + if hasVarSize(f.typ, seen) { + return true + } + } + case *Interface: + return isTypeParam(t) + case *Named, *Union: + panic("unreachable") + } + return false +} + +// applyTypeFunc applies f to x. If x is a type parameter, +// the result is a type parameter constrained by a new +// interface bound. The type bounds for that interface +// are computed by applying f to each of the type bounds +// of x. If any of these applications of f return nil, +// applyTypeFunc returns nil. +// If x is not a type parameter, the result is f(x). +func (check *Checker) applyTypeFunc(f func(Type) Type, x *operand, id builtinId) Type { + if tp, _ := Unalias(x.typ).(*TypeParam); tp != nil { + // Test if t satisfies the requirements for the argument + // type and collect possible result types at the same time. + var terms []*Term + if !tp.is(func(t *term) bool { + if t == nil { + return false + } + if r := f(t.typ); r != nil { + terms = append(terms, NewTerm(t.tilde, r)) + return true + } + return false + }) { + return nil + } + + // We can type-check this fine but we're introducing a synthetic + // type parameter for the result. It's not clear what the API + // implications are here. Report an error for 1.18 (see go.dev/issue/50912), + // but continue type-checking. + var code Code + switch id { + case _Real: + code = InvalidReal + case _Imag: + code = InvalidImag + case _Complex: + code = InvalidComplex + default: + panic("unreachable") + } + check.softErrorf(x, code, "%s not supported as argument to built-in %s for go1.18 (see go.dev/issue/50937)", x, predeclaredFuncs[id].name) + + // Construct a suitable new type parameter for the result type. + // The type parameter is placed in the current package so export/import + // works as expected. + tpar := NewTypeName(nopos, check.pkg, tp.obj.name, nil) + ptyp := check.newTypeParam(tpar, NewInterfaceType(nil, []Type{NewUnion(terms)})) // assigns type to tpar as a side-effect + ptyp.index = tp.index + + return ptyp + } + + return f(x.typ) +} + +// makeSig makes a signature for the given argument and result types. +// Default types are used for untyped arguments, and res may be nil. +func makeSig(res Type, args ...Type) *Signature { + list := make([]*Var, len(args)) + for i, param := range args { + list[i] = NewParam(nopos, nil, "", Default(param)) + } + params := NewTuple(list...) + var result *Tuple + if res != nil { + assert(!isUntyped(res)) + result = NewTuple(newVar(ResultVar, nopos, nil, "", res)) + } + return &Signature{params: params, results: result} +} + +// arrayPtrDeref returns A if typ is of the form *A and A is an array; +// otherwise it returns typ. +func arrayPtrDeref(typ Type) Type { + if p, ok := Unalias(typ).(*Pointer); ok { + if a, _ := p.base.Underlying().(*Array); a != nil { + return a + } + } + return typ +} diff --git a/go/src/cmd/compile/internal/types2/builtins_test.go b/go/src/cmd/compile/internal/types2/builtins_test.go new file mode 100644 index 0000000000000000000000000000000000000000..2b4854b6f7ec0b1d1b8c24fff8803bce1fb85071 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/builtins_test.go @@ -0,0 +1,250 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2_test + +import ( + "cmd/compile/internal/syntax" + "fmt" + "testing" + + . "cmd/compile/internal/types2" +) + +var builtinCalls = []struct { + name, src, sig string +}{ + {"append", `var s []int; _ = append(s)`, `func([]int, ...int) []int`}, + {"append", `var s []int; _ = append(s, 0)`, `func([]int, ...int) []int`}, + {"append", `var s []int; _ = (append)(s, 0)`, `func([]int, ...int) []int`}, + {"append", `var s []byte; _ = ((append))(s, 0)`, `func([]byte, ...byte) []byte`}, + {"append", `var s []byte; _ = append(s, "foo"...)`, `func([]byte, string...) []byte`}, + {"append", `type T []byte; var s T; var str string; _ = append(s, str...)`, `func(p.T, string...) p.T`}, + {"append", `type T []byte; type U string; var s T; var str U; _ = append(s, str...)`, `func(p.T, p.U...) p.T`}, + + {"cap", `var s [10]int; _ = cap(s)`, `invalid type`}, // constant + {"cap", `var s [10]int; _ = cap(&s)`, `invalid type`}, // constant + {"cap", `var s []int64; _ = cap(s)`, `func([]int64) int`}, + {"cap", `var c chan<-bool; _ = cap(c)`, `func(chan<- bool) int`}, + {"cap", `type S []byte; var s S; _ = cap(s)`, `func(p.S) int`}, + {"cap", `var s P; _ = cap(s)`, `func(P) int`}, + + {"len", `_ = len("foo")`, `invalid type`}, // constant + {"len", `var s string; _ = len(s)`, `func(string) int`}, + {"len", `var s [10]int; _ = len(s)`, `invalid type`}, // constant + {"len", `var s [10]int; _ = len(&s)`, `invalid type`}, // constant + {"len", `var s []int64; _ = len(s)`, `func([]int64) int`}, + {"len", `var c chan<-bool; _ = len(c)`, `func(chan<- bool) int`}, + {"len", `var m map[string]float32; _ = len(m)`, `func(map[string]float32) int`}, + {"len", `type S []byte; var s S; _ = len(s)`, `func(p.S) int`}, + {"len", `var s P; _ = len(s)`, `func(P) int`}, + + {"clear", `var m map[float64]int; clear(m)`, `func(map[float64]int)`}, + {"clear", `var s []byte; clear(s)`, `func([]byte)`}, + + {"close", `var c chan int; close(c)`, `func(chan int)`}, + {"close", `var c chan<- chan string; close(c)`, `func(chan<- chan string)`}, + + {"complex", `_ = complex(1, 0)`, `invalid type`}, // constant + {"complex", `var re float32; _ = complex(re, 1.0)`, `func(float32, float32) complex64`}, + {"complex", `var im float64; _ = complex(1, im)`, `func(float64, float64) complex128`}, + {"complex", `type F32 float32; var re, im F32; _ = complex(re, im)`, `func(p.F32, p.F32) complex64`}, + {"complex", `type F64 float64; var re, im F64; _ = complex(re, im)`, `func(p.F64, p.F64) complex128`}, + + {"copy", `var src, dst []byte; copy(dst, src)`, `func([]byte, []byte) int`}, + {"copy", `type T [][]int; var src, dst T; _ = copy(dst, src)`, `func(p.T, p.T) int`}, + {"copy", `var src string; var dst []byte; copy(dst, src)`, `func([]byte, string) int`}, + {"copy", `type T string; type U []byte; var src T; var dst U; copy(dst, src)`, `func(p.U, p.T) int`}, + {"copy", `var dst []byte; copy(dst, "hello")`, `func([]byte, string) int`}, + + {"delete", `var m map[string]bool; delete(m, "foo")`, `func(map[string]bool, string)`}, + {"delete", `type (K string; V int); var m map[K]V; delete(m, "foo")`, `func(map[p.K]p.V, p.K)`}, + + {"imag", `_ = imag(1i)`, `invalid type`}, // constant + {"imag", `var c complex64; _ = imag(c)`, `func(complex64) float32`}, + {"imag", `var c complex128; _ = imag(c)`, `func(complex128) float64`}, + {"imag", `type C64 complex64; var c C64; _ = imag(c)`, `func(p.C64) float32`}, + {"imag", `type C128 complex128; var c C128; _ = imag(c)`, `func(p.C128) float64`}, + + {"real", `_ = real(1i)`, `invalid type`}, // constant + {"real", `var c complex64; _ = real(c)`, `func(complex64) float32`}, + {"real", `var c complex128; _ = real(c)`, `func(complex128) float64`}, + {"real", `type C64 complex64; var c C64; _ = real(c)`, `func(p.C64) float32`}, + {"real", `type C128 complex128; var c C128; _ = real(c)`, `func(p.C128) float64`}, + + {"make", `_ = make([]int, 10)`, `func([]int, int) []int`}, + {"make", `type T []byte; _ = make(T, 10, 20)`, `func(p.T, int, int) p.T`}, + + // go.dev/issue/37349 + {"make", ` _ = make([]int, 0 )`, `func([]int, int) []int`}, + {"make", `var l int; _ = make([]int, l )`, `func([]int, int) []int`}, + {"make", ` _ = make([]int, 0, 0)`, `func([]int, int, int) []int`}, + {"make", `var l int; _ = make([]int, l, 0)`, `func([]int, int, int) []int`}, + {"make", `var c int; _ = make([]int, 0, c)`, `func([]int, int, int) []int`}, + {"make", `var l, c int; _ = make([]int, l, c)`, `func([]int, int, int) []int`}, + + // go.dev/issue/37393 + {"make", ` _ = make([]int , 0 )`, `func([]int, int) []int`}, + {"make", `var l byte ; _ = make([]int8 , l )`, `func([]int8, byte) []int8`}, + {"make", ` _ = make([]int16 , 0, 0)`, `func([]int16, int, int) []int16`}, + {"make", `var l int16; _ = make([]string , l, 0)`, `func([]string, int16, int) []string`}, + {"make", `var c int32; _ = make([]float64 , 0, c)`, `func([]float64, int, int32) []float64`}, + {"make", `var l, c uint ; _ = make([]complex128, l, c)`, `func([]complex128, uint, uint) []complex128`}, + + // go.dev/issue/45667 + {"make", `const l uint = 1; _ = make([]int, l)`, `func([]int, uint) []int`}, + + {"max", ` _ = max(0 )`, `invalid type`}, // constant + {"max", `var x int ; _ = max(x )`, `func(int) int`}, + {"max", `var x int ; _ = max(0, x )`, `func(int, int) int`}, + {"max", `var x string ; _ = max("a", x )`, `func(string, string) string`}, + {"max", `var x float32; _ = max(0, 1.0, x)`, `func(float32, float32, float32) float32`}, + + {"min", ` _ = min(0 )`, `invalid type`}, // constant + {"min", `var x int ; _ = min(x )`, `func(int) int`}, + {"min", `var x int ; _ = min(0, x )`, `func(int, int) int`}, + {"min", `var x string ; _ = min("a", x )`, `func(string, string) string`}, + {"min", `var x float32; _ = min(0, 1.0, x)`, `func(float32, float32, float32) float32`}, + + {"new", `_ = new(int)`, `func(int) *int`}, + {"new", `type T struct{}; _ = new(T)`, `func(p.T) *p.T`}, + + {"panic", `panic(0)`, `func(interface{})`}, + {"panic", `panic("foo")`, `func(interface{})`}, + + {"print", `print()`, `func()`}, + {"print", `print(0)`, `func(int)`}, + {"print", `print(1, 2.0, "foo", true)`, `func(int, float64, string, bool)`}, + + {"println", `println()`, `func()`}, + {"println", `println(0)`, `func(int)`}, + {"println", `println(1, 2.0, "foo", true)`, `func(int, float64, string, bool)`}, + + {"recover", `recover()`, `func() interface{}`}, + {"recover", `_ = recover()`, `func() interface{}`}, + + {"Add", `var p unsafe.Pointer; _ = unsafe.Add(p, -1.0)`, `func(unsafe.Pointer, int) unsafe.Pointer`}, + {"Add", `var p unsafe.Pointer; var n uintptr; _ = unsafe.Add(p, n)`, `func(unsafe.Pointer, uintptr) unsafe.Pointer`}, + {"Add", `_ = unsafe.Add(nil, 0)`, `func(unsafe.Pointer, int) unsafe.Pointer`}, + + {"Alignof", `_ = unsafe.Alignof(0)`, `invalid type`}, // constant + {"Alignof", `var x struct{}; _ = unsafe.Alignof(x)`, `invalid type`}, // constant + {"Alignof", `var x P; _ = unsafe.Alignof(x)`, `func(P) uintptr`}, + + {"Offsetof", `var x struct{f bool}; _ = unsafe.Offsetof(x.f)`, `invalid type`}, // constant + {"Offsetof", `var x struct{_ int; f bool}; _ = unsafe.Offsetof((&x).f)`, `invalid type`}, // constant + {"Offsetof", `var x struct{_ int; f P}; _ = unsafe.Offsetof((&x).f)`, `func(P) uintptr`}, + + {"Sizeof", `_ = unsafe.Sizeof(0)`, `invalid type`}, // constant + {"Sizeof", `var x struct{}; _ = unsafe.Sizeof(x)`, `invalid type`}, // constant + {"Sizeof", `var x P; _ = unsafe.Sizeof(x)`, `func(P) uintptr`}, + + {"Slice", `var p *int; _ = unsafe.Slice(p, 1)`, `func(*int, int) []int`}, + {"Slice", `var p *byte; var n uintptr; _ = unsafe.Slice(p, n)`, `func(*byte, uintptr) []byte`}, + {"Slice", `type B *byte; var b B; _ = unsafe.Slice(b, 0)`, `func(*byte, int) []byte`}, + + {"SliceData", "var s []int; _ = unsafe.SliceData(s)", `func([]int) *int`}, + {"SliceData", "type S []int; var s S; _ = unsafe.SliceData(s)", `func([]int) *int`}, + + {"String", `var p *byte; _ = unsafe.String(p, 1)`, `func(*byte, int) string`}, + {"String", `type B *byte; var b B; _ = unsafe.String(b, 0)`, `func(*byte, int) string`}, + + {"StringData", `var s string; _ = unsafe.StringData(s)`, `func(string) *byte`}, + {"StringData", `_ = unsafe.StringData("foo")`, `func(string) *byte`}, + + {"assert", `assert(true)`, `invalid type`}, // constant + {"assert", `type B bool; const pred B = 1 < 2; assert(pred)`, `invalid type`}, // constant + + // no tests for trace since it produces output as a side-effect +} + +func TestBuiltinSignatures(t *testing.T) { + DefPredeclaredTestFuncs() + + seen := map[string]bool{"trace": true} // no test for trace built-in; add it manually + for _, call := range builtinCalls { + testBuiltinSignature(t, call.name, call.src, call.sig) + seen[call.name] = true + } + + // make sure we didn't miss one + for _, name := range Universe.Names() { + if _, ok := Universe.Lookup(name).(*Builtin); ok && !seen[name] { + t.Errorf("missing test for %s", name) + } + } + for _, name := range Unsafe.Scope().Names() { + if _, ok := Unsafe.Scope().Lookup(name).(*Builtin); ok && !seen[name] { + t.Errorf("missing test for unsafe.%s", name) + } + } +} + +func testBuiltinSignature(t *testing.T, name, src0, want string) { + src := fmt.Sprintf(`package p; import "unsafe"; type _ unsafe.Pointer /* use unsafe */; func _[P ~[]byte]() { %s }`, src0) + + uses := make(map[*syntax.Name]Object) + types := make(map[syntax.Expr]TypeAndValue) + mustTypecheck(src, nil, &Info{Uses: uses, Types: types}) + + // find called function + n := 0 + var fun syntax.Expr + for x := range types { + if call, _ := x.(*syntax.CallExpr); call != nil { + fun = call.Fun + n++ + } + } + if n != 1 { + t.Errorf("%s: got %d CallExprs; want 1", src0, n) + return + } + + // check recorded types for fun and descendents (may be parenthesized) + for { + // the recorded type for the built-in must match the wanted signature + typ := types[fun].Type + if typ == nil { + t.Errorf("%s: no type recorded for %s", src0, ExprString(fun)) + return + } + if got := typ.String(); got != want { + t.Errorf("%s: got type %s; want %s", src0, got, want) + return + } + + // called function must be a (possibly parenthesized, qualified) + // identifier denoting the expected built-in + switch p := fun.(type) { + case *syntax.Name: + obj := uses[p] + if obj == nil { + t.Errorf("%s: no object found for %s", src0, p.Value) + return + } + bin, _ := obj.(*Builtin) + if bin == nil { + t.Errorf("%s: %s does not denote a built-in", src0, p.Value) + return + } + if bin.Name() != name { + t.Errorf("%s: got built-in %s; want %s", src0, bin.Name(), name) + return + } + return // we're done + + case *syntax.ParenExpr: + fun = p.X // unpack + + case *syntax.SelectorExpr: + // built-in from package unsafe - ignore details + return // we're done + + default: + t.Errorf("%s: invalid function call", src0) + return + } + } +} diff --git a/go/src/cmd/compile/internal/types2/call.go b/go/src/cmd/compile/internal/types2/call.go new file mode 100644 index 0000000000000000000000000000000000000000..3461c890a8b7ddb84cce52c46612943bad9edd9a --- /dev/null +++ b/go/src/cmd/compile/internal/types2/call.go @@ -0,0 +1,991 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements typechecking of call and selector expressions. + +package types2 + +import ( + "cmd/compile/internal/syntax" + . "internal/types/errors" + "strings" +) + +// funcInst type-checks a function instantiation. +// The incoming x must be a generic function. +// If inst != nil, it provides some or all of the type arguments (inst.Index). +// If target != nil, it may be used to infer missing type arguments of x, if any. +// At least one of T or inst must be provided. +// +// There are two modes of operation: +// +// 1. If infer == true, funcInst infers missing type arguments as needed and +// instantiates the function x. The returned results are nil. +// +// 2. If infer == false and inst provides all type arguments, funcInst +// instantiates the function x. The returned results are nil. +// If inst doesn't provide enough type arguments, funcInst returns the +// available arguments; x remains unchanged. +// +// If an error (other than a version error) occurs in any case, it is reported +// and x.mode is set to invalid. +func (check *Checker) funcInst(T *target, pos syntax.Pos, x *operand, inst *syntax.IndexExpr, infer bool) []Type { + assert(T != nil || inst != nil) + + var instErrPos poser + if inst != nil { + instErrPos = inst.Pos() + x.expr = inst // if we don't have an index expression, keep the existing expression of x + } else { + instErrPos = pos + } + versionErr := !check.verifyVersionf(instErrPos, go1_18, "function instantiation") + + // targs and xlist are the type arguments and corresponding type expressions, or nil. + var targs []Type + var xlist []syntax.Expr + if inst != nil { + xlist = syntax.UnpackListExpr(inst.Index) + targs = check.typeList(xlist) + if targs == nil { + x.mode = invalid + return nil + } + assert(len(targs) == len(xlist)) + } + + // Check the number of type arguments (got) vs number of type parameters (want). + // Note that x is a function value, not a type expression, so we don't need to + // call Underlying below. + sig := x.typ.(*Signature) + got, want := len(targs), sig.TypeParams().Len() + if got > want { + // Providing too many type arguments is always an error. + check.errorf(xlist[got-1], WrongTypeArgCount, "got %d type arguments but want %d", got, want) + x.mode = invalid + return nil + } + + if got < want { + if !infer { + return targs + } + + // If the uninstantiated or partially instantiated function x is used in + // an assignment (tsig != nil), infer missing type arguments by treating + // the assignment + // + // var tvar tsig = x + // + // like a call g(tvar) of the synthetic generic function g + // + // func g[type_parameters_of_x](func_type_of_x) + // + var args []*operand + var params []*Var + var reverse bool + if T != nil && sig.tparams != nil { + if !versionErr && !check.allowVersion(go1_21) { + if inst != nil { + check.versionErrorf(instErrPos, go1_21, "partially instantiated function in assignment") + } else { + check.versionErrorf(instErrPos, go1_21, "implicitly instantiated function in assignment") + } + } + gsig := NewSignatureType(nil, nil, nil, sig.params, sig.results, sig.variadic) + params = []*Var{NewParam(x.Pos(), check.pkg, "", gsig)} + // The type of the argument operand is tsig, which is the type of the LHS in an assignment + // or the result type in a return statement. Create a pseudo-expression for that operand + // that makes sense when reported in error messages from infer, below. + expr := syntax.NewName(x.Pos(), T.desc) + args = []*operand{{mode: value, expr: expr, typ: T.sig}} + reverse = true + } + + // Rename type parameters to avoid problems with recursive instantiations. + // Note that NewTuple(params...) below is (*Tuple)(nil) if len(params) == 0, as desired. + tparams, params2 := check.renameTParams(pos, sig.TypeParams().list(), NewTuple(params...)) + + err := check.newError(CannotInferTypeArgs) + targs = check.infer(pos, tparams, targs, params2.(*Tuple), args, reverse, err) + if targs == nil { + if !err.empty() { + err.report() + } + x.mode = invalid + return nil + } + got = len(targs) + } + assert(got == want) + + // instantiate function signature + sig = check.instantiateSignature(x.Pos(), x.expr, sig, targs, xlist) + + x.typ = sig + x.mode = value + return nil +} + +func (check *Checker) instantiateSignature(pos syntax.Pos, expr syntax.Expr, typ *Signature, targs []Type, xlist []syntax.Expr) (res *Signature) { + assert(check != nil) + assert(len(targs) == typ.TypeParams().Len()) + + if check.conf.Trace { + check.trace(pos, "-- instantiating signature %s with %s", typ, targs) + check.indent++ + defer func() { + check.indent-- + check.trace(pos, "=> %s (under = %s)", res, res.Underlying()) + }() + } + + // For signatures, Checker.instance will always succeed because the type argument + // count is correct at this point (see assertion above); hence the type assertion + // to *Signature will always succeed. + inst := check.instance(pos, typ, targs, nil, check.context()).(*Signature) + assert(inst.TypeParams().Len() == 0) // signature is not generic anymore + check.recordInstance(expr, targs, inst) + assert(len(xlist) <= len(targs)) + + // verify instantiation lazily (was go.dev/issue/50450) + check.later(func() { + tparams := typ.TypeParams().list() + // check type constraints + if i, err := check.verify(pos, tparams, targs, check.context()); err != nil { + // best position for error reporting + pos := pos + if i < len(xlist) { + pos = syntax.StartPos(xlist[i]) + } + check.softErrorf(pos, InvalidTypeArg, "%s", err) + } else { + check.mono.recordInstance(check.pkg, pos, tparams, targs, xlist) + } + }).describef(pos, "verify instantiation") + + return inst +} + +func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind { + var inst *syntax.IndexExpr // function instantiation, if any + if iexpr, _ := call.Fun.(*syntax.IndexExpr); iexpr != nil { + if check.indexExpr(x, iexpr) { + // Delay function instantiation to argument checking, + // where we combine type and value arguments for type + // inference. + assert(x.mode == value) + inst = iexpr + } + x.expr = iexpr + check.record(x) + } else { + check.exprOrType(x, call.Fun, true) + } + // x.typ may be generic + + switch x.mode { + case invalid: + check.use(call.ArgList...) + x.expr = call + return statement + + case typexpr: + // conversion + check.nonGeneric(nil, x) + if x.mode == invalid { + return conversion + } + T := x.typ + x.mode = invalid + switch n := len(call.ArgList); n { + case 0: + check.errorf(call, WrongArgCount, "missing argument in conversion to %s", T) + case 1: + check.expr(nil, x, call.ArgList[0]) + if x.mode != invalid { + if t, _ := T.Underlying().(*Interface); t != nil && !isTypeParam(T) { + if !t.IsMethodSet() { + check.errorf(call, MisplacedConstraintIface, "cannot use interface %s in conversion (contains specific type constraints or is comparable)", T) + break + } + } + if hasDots(call) { + check.errorf(call.ArgList[0], BadDotDotDotSyntax, "invalid use of ... in conversion to %s", T) + break + } + check.conversion(x, T) + } + default: + check.use(call.ArgList...) + check.errorf(call.ArgList[n-1], WrongArgCount, "too many arguments in conversion to %s", T) + } + x.expr = call + return conversion + + case builtin: + // no need to check for non-genericity here + id := x.id + if !check.builtin(x, call, id) { + x.mode = invalid + } + x.expr = call + // a non-constant result implies a function call + if x.mode != invalid && x.mode != constant_ { + check.hasCallOrRecv = true + } + return predeclaredFuncs[id].kind + } + + // ordinary function/method call + // signature may be generic + cgocall := x.mode == cgofunc + + // If the operand type is a type parameter, all types in its type set + // must have a common underlying type, which must be a signature. + u, err := commonUnder(x.typ, func(t, u Type) *typeError { + if _, ok := u.(*Signature); u != nil && !ok { + return typeErrorf("%s is not a function", t) + } + return nil + }) + if err != nil { + check.errorf(x, InvalidCall, invalidOp+"cannot call %s: %s", x, err.format(check)) + x.mode = invalid + x.expr = call + return statement + } + sig := u.(*Signature) // u must be a signature per the commonUnder condition + + // Capture wasGeneric before sig is potentially instantiated below. + wasGeneric := sig.TypeParams().Len() > 0 + + // evaluate type arguments, if any + var xlist []syntax.Expr + var targs []Type + if inst != nil { + xlist = syntax.UnpackListExpr(inst.Index) + targs = check.typeList(xlist) + if targs == nil { + check.use(call.ArgList...) + x.mode = invalid + x.expr = call + return statement + } + assert(len(targs) == len(xlist)) + + // check number of type arguments (got) vs number of type parameters (want) + got, want := len(targs), sig.TypeParams().Len() + if got > want { + check.errorf(xlist[want], WrongTypeArgCount, "got %d type arguments but want %d", got, want) + check.use(call.ArgList...) + x.mode = invalid + x.expr = call + return statement + } + + // If sig is generic and all type arguments are provided, preempt function + // argument type inference by explicitly instantiating the signature. This + // ensures that we record accurate type information for sig, even if there + // is an error checking its arguments (for example, if an incorrect number + // of arguments is supplied). + if got == want && want > 0 { + check.verifyVersionf(inst, go1_18, "function instantiation") + sig = check.instantiateSignature(inst.Pos(), inst, sig, targs, xlist) + // targs have been consumed; proceed with checking arguments of the + // non-generic signature. + targs = nil + xlist = nil + } + } + + // evaluate arguments + args, atargs := check.genericExprList(call.ArgList) + sig = check.arguments(call, sig, targs, xlist, args, atargs) + + if wasGeneric && sig.TypeParams().Len() == 0 { + // update the recorded type of call.Fun to its instantiated type + check.recordTypeAndValue(call.Fun, value, sig, nil) + } + + // determine result + switch sig.results.Len() { + case 0: + x.mode = novalue + case 1: + if cgocall { + x.mode = commaerr + } else { + x.mode = value + } + x.typ = sig.results.vars[0].typ // unpack tuple + default: + x.mode = value + x.typ = sig.results + } + x.expr = call + check.hasCallOrRecv = true + + // if type inference failed, a parameterized result must be invalidated + // (operands cannot have a parameterized type) + if x.mode == value && sig.TypeParams().Len() > 0 && isParameterized(sig.TypeParams().list(), x.typ) { + x.mode = invalid + } + + return statement +} + +// exprList evaluates a list of expressions and returns the corresponding operands. +// A single-element expression list may evaluate to multiple operands. +func (check *Checker) exprList(elist []syntax.Expr) (xlist []*operand) { + if n := len(elist); n == 1 { + xlist, _ = check.multiExpr(elist[0], false) + } else if n > 1 { + // multiple (possibly invalid) values + xlist = make([]*operand, n) + for i, e := range elist { + var x operand + check.expr(nil, &x, e) + xlist[i] = &x + } + } + return +} + +// genericExprList is like exprList but result operands may be uninstantiated or partially +// instantiated generic functions (where constraint information is insufficient to infer +// the missing type arguments) for Go 1.21 and later. +// For each non-generic or uninstantiated generic operand, the corresponding targsList and +// elements do not exist (targsList is nil) or the elements are nil. +// For each partially instantiated generic function operand, the corresponding +// targsList elements are the operand's partial type arguments. +func (check *Checker) genericExprList(elist []syntax.Expr) (resList []*operand, targsList [][]Type) { + if debug { + defer func() { + // type arguments must only exist for partially instantiated functions + for i, x := range resList { + if i < len(targsList) { + if n := len(targsList[i]); n > 0 { + // x must be a partially instantiated function + assert(n < x.typ.(*Signature).TypeParams().Len()) + } + } + } + }() + } + + // Before Go 1.21, uninstantiated or partially instantiated argument functions are + // nor permitted. Checker.funcInst must infer missing type arguments in that case. + infer := true // for -lang < go1.21 + n := len(elist) + if n > 0 && check.allowVersion(go1_21) { + infer = false + } + + if n == 1 { + // single value (possibly a partially instantiated function), or a multi-valued expression + e := elist[0] + var x operand + if inst, _ := e.(*syntax.IndexExpr); inst != nil && check.indexExpr(&x, inst) { + // x is a generic function. + targs := check.funcInst(nil, x.Pos(), &x, inst, infer) + if targs != nil { + // x was not instantiated: collect the (partial) type arguments. + targsList = [][]Type{targs} + // Update x.expr so that we can record the partially instantiated function. + x.expr = inst + } else { + // x was instantiated: we must record it here because we didn't + // use the usual expression evaluators. + check.record(&x) + } + resList = []*operand{&x} + } else { + // x is not a function instantiation (it may still be a generic function). + check.rawExpr(nil, &x, e, nil, true) + check.exclude(&x, 1< 1 { + // multiple values + resList = make([]*operand, n) + targsList = make([][]Type, n) + for i, e := range elist { + var x operand + if inst, _ := e.(*syntax.IndexExpr); inst != nil && check.indexExpr(&x, inst) { + // x is a generic function. + targs := check.funcInst(nil, x.Pos(), &x, inst, infer) + if targs != nil { + // x was not instantiated: collect the (partial) type arguments. + targsList[i] = targs + // Update x.expr so that we can record the partially instantiated function. + x.expr = inst + } else { + // x was instantiated: we must record it here because we didn't + // use the usual expression evaluators. + check.record(&x) + } + } else { + // x is exactly one value (possibly invalid or uninstantiated generic function). + check.genericExpr(&x, e) + } + resList[i] = &x + } + } + + return +} + +// arguments type-checks arguments passed to a function call with the given signature. +// The function and its arguments may be generic, and possibly partially instantiated. +// targs and xlist are the function's type arguments (and corresponding expressions). +// args are the function arguments. If an argument args[i] is a partially instantiated +// generic function, atargs[i] are the corresponding type arguments. +// If the callee is variadic, arguments adjusts its signature to match the provided +// arguments. The type parameters and arguments of the callee and all its arguments +// are used together to infer any missing type arguments, and the callee and argument +// functions are instantiated as necessary. +// The result signature is the (possibly adjusted and instantiated) function signature. +// If an error occurred, the result signature is the incoming sig. +func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []Type, xlist []syntax.Expr, args []*operand, atargs [][]Type) (rsig *Signature) { + rsig = sig + + // Function call argument/parameter count requirements + // + // | standard call | dotdotdot call | + // --------------+------------------+----------------+ + // standard func | nargs == npars | invalid | + // --------------+------------------+----------------+ + // variadic func | nargs >= npars-1 | nargs == npars | + // --------------+------------------+----------------+ + + nargs := len(args) + npars := sig.params.Len() + ddd := hasDots(call) + + // set up parameters + sigParams := sig.params // adjusted for variadic functions (may be nil for empty parameter lists!) + adjusted := false // indicates if sigParams is different from sig.params + if sig.variadic { + if ddd { + // variadic_func(a, b, c...) + if len(call.ArgList) == 1 && nargs > 1 { + // f()... is not permitted if f() is multi-valued + //check.errorf(call.Ellipsis, "cannot use ... with %d-valued %s", nargs, call.ArgList[0]) + check.errorf(call, InvalidDotDotDot, "cannot use ... with %d-valued %s", nargs, call.ArgList[0]) + return + } + } else { + // variadic_func(a, b, c) + if nargs >= npars-1 { + // Create custom parameters for arguments: keep + // the first npars-1 parameters and add one for + // each argument mapping to the ... parameter. + vars := make([]*Var, npars-1) // npars > 0 for variadic functions + copy(vars, sig.params.vars) + last := sig.params.vars[npars-1] + typ := last.typ.(*Slice).elem + for len(vars) < nargs { + vars = append(vars, NewParam(last.pos, last.pkg, last.name, typ)) + } + sigParams = NewTuple(vars...) // possibly nil! + adjusted = true + npars = nargs + } else { + // nargs < npars-1 + npars-- // for correct error message below + } + } + } else { + if ddd { + // standard_func(a, b, c...) + //check.errorf(call.Ellipsis, "cannot use ... in call to non-variadic %s", call.Fun) + check.errorf(call, NonVariadicDotDotDot, "cannot use ... in call to non-variadic %s", call.Fun) + return + } + // standard_func(a, b, c) + } + + // check argument count + if nargs != npars { + var at poser = call + qualifier := "not enough" + if nargs > npars { + at = args[npars].expr // report at first extra argument + qualifier = "too many" + } else if nargs > 0 { + at = args[nargs-1].expr // report at last argument + } + // take care of empty parameter lists represented by nil tuples + var params []*Var + if sig.params != nil { + params = sig.params.vars + } + err := check.newError(WrongArgCount) + err.addf(at, "%s arguments in call to %s", qualifier, call.Fun) + err.addf(nopos, "have %s", check.typesSummary(operandTypes(args), false, ddd)) + err.addf(nopos, "want %s", check.typesSummary(varTypes(params), sig.variadic, false)) + err.report() + return + } + + // collect type parameters of callee and generic function arguments + var tparams []*TypeParam + + // collect type parameters of callee + n := sig.TypeParams().Len() + if n > 0 { + if !check.allowVersion(go1_18) { + if iexpr, _ := call.Fun.(*syntax.IndexExpr); iexpr != nil { + check.versionErrorf(iexpr, go1_18, "function instantiation") + } else { + check.versionErrorf(call, go1_18, "implicit function instantiation") + } + } + // rename type parameters to avoid problems with recursive calls + var tmp Type + tparams, tmp = check.renameTParams(call.Pos(), sig.TypeParams().list(), sigParams) + sigParams = tmp.(*Tuple) + // make sure targs and tparams have the same length + for len(targs) < len(tparams) { + targs = append(targs, nil) + } + } + assert(len(tparams) == len(targs)) + + // collect type parameters from generic function arguments + var genericArgs []int // indices of generic function arguments + if enableReverseTypeInference { + for i, arg := range args { + // generic arguments cannot have a defined (*Named) type - no need for underlying type below + if asig, _ := arg.typ.(*Signature); asig != nil && asig.TypeParams().Len() > 0 { + // The argument type is a generic function signature. This type is + // pointer-identical with (it's copied from) the type of the generic + // function argument and thus the function object. + // Before we change the type (type parameter renaming, below), make + // a clone of it as otherwise we implicitly modify the object's type + // (go.dev/issues/63260). + asig = clone(asig) + // Rename type parameters for cases like f(g, g); this gives each + // generic function argument a unique type identity (go.dev/issues/59956). + // TODO(gri) Consider only doing this if a function argument appears + // multiple times, which is rare (possible optimization). + atparams, tmp := check.renameTParams(call.Pos(), asig.TypeParams().list(), asig) + asig = tmp.(*Signature) + asig.tparams = &TypeParamList{atparams} // renameTParams doesn't touch associated type parameters + arg.typ = asig // new type identity for the function argument + tparams = append(tparams, atparams...) + // add partial list of type arguments, if any + if i < len(atargs) { + targs = append(targs, atargs[i]...) + } + // make sure targs and tparams have the same length + for len(targs) < len(tparams) { + targs = append(targs, nil) + } + genericArgs = append(genericArgs, i) + } + } + } + assert(len(tparams) == len(targs)) + + // at the moment we only support implicit instantiations of argument functions + _ = len(genericArgs) > 0 && check.verifyVersionf(args[genericArgs[0]], go1_21, "implicitly instantiated function as argument") + + // tparams holds the type parameters of the callee and generic function arguments, if any: + // the first n type parameters belong to the callee, followed by mi type parameters for each + // of the generic function arguments, where mi = args[i].typ.(*Signature).TypeParams().Len(). + + // infer missing type arguments of callee and function arguments + if len(tparams) > 0 { + err := check.newError(CannotInferTypeArgs) + targs = check.infer(call.Pos(), tparams, targs, sigParams, args, false, err) + if targs == nil { + // TODO(gri) If infer inferred the first targs[:n], consider instantiating + // the call signature for better error messages/gopls behavior. + // Perhaps instantiate as much as we can, also for arguments. + // This will require changes to how infer returns its results. + if !err.empty() { + check.errorf(err.pos(), CannotInferTypeArgs, "in call to %s, %s", call.Fun, err.msg()) + } + return + } + + // update result signature: instantiate if needed + if n > 0 { + rsig = check.instantiateSignature(call.Pos(), call.Fun, sig, targs[:n], xlist) + // If the callee's parameter list was adjusted we need to update (instantiate) + // it separately. Otherwise we can simply use the result signature's parameter + // list. + if adjusted { + sigParams = check.subst(call.Pos(), sigParams, makeSubstMap(tparams[:n], targs[:n]), nil, check.context()).(*Tuple) + } else { + sigParams = rsig.params + } + } + + // compute argument signatures: instantiate if needed + j := n + for _, i := range genericArgs { + arg := args[i] + asig := arg.typ.(*Signature) + k := j + asig.TypeParams().Len() + // targs[j:k] are the inferred type arguments for asig + arg.typ = check.instantiateSignature(call.Pos(), arg.expr, asig, targs[j:k], nil) // TODO(gri) provide xlist if possible (partial instantiations) + check.record(arg) // record here because we didn't use the usual expr evaluators + j = k + } + } + + // check arguments + if len(args) > 0 { + context := check.sprintf("argument to %s", call.Fun) + for i, a := range args { + check.assignment(a, sigParams.vars[i].typ, context) + } + } + + return +} + +var cgoPrefixes = [...]string{ + "_Ciconst_", + "_Cfconst_", + "_Csconst_", + "_Ctype_", + "_Cvar_", // actually a pointer to the var + "_Cfpvar_fp_", + "_Cfunc_", + "_Cmacro_", // function to evaluate the expanded expression +} + +func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool) { + // these must be declared before the "goto Error" statements + var ( + obj Object + index []int + indirect bool + ) + + sel := e.Sel.Value + // If the identifier refers to a package, handle everything here + // so we don't need a "package" mode for operands: package names + // can only appear in qualified identifiers which are mapped to + // selector expressions. + if ident, ok := e.X.(*syntax.Name); ok { + obj := check.lookup(ident.Value) + if pname, _ := obj.(*PkgName); pname != nil { + assert(pname.pkg == check.pkg) + check.recordUse(ident, pname) + check.usedPkgNames[pname] = true + pkg := pname.imported + + var exp Object + funcMode := value + if pkg.cgo { + // cgo special cases C.malloc: it's + // rewritten to _CMalloc and does not + // support two-result calls. + if sel == "malloc" { + sel = "_CMalloc" + } else { + funcMode = cgofunc + } + for _, prefix := range cgoPrefixes { + // cgo objects are part of the current package (in file + // _cgo_gotypes.go). Use regular lookup. + exp = check.lookup(prefix + sel) + if exp != nil { + break + } + } + if exp == nil { + if isValidName(sel) { + check.errorf(e.Sel, UndeclaredImportedName, "undefined: %s", syntax.Expr(e)) // cast to syntax.Expr to silence vet + } + goto Error + } + check.objDecl(exp) + } else { + exp = pkg.scope.Lookup(sel) + if exp == nil { + if !pkg.fake && isValidName(sel) { + // Try to give a better error message when selector matches an object name ignoring case. + exps := pkg.scope.lookupIgnoringCase(sel, true) + if len(exps) >= 1 { + // report just the first one + check.errorf(e.Sel, UndeclaredImportedName, "undefined: %s (but have %s)", syntax.Expr(e), exps[0].Name()) + } else { + check.errorf(e.Sel, UndeclaredImportedName, "undefined: %s", syntax.Expr(e)) + } + } + goto Error + } + if !exp.Exported() { + check.errorf(e.Sel, UnexportedName, "name %s not exported by package %s", sel, pkg.name) + // ok to continue + } + } + check.recordUse(e.Sel, exp) + + // Simplified version of the code for *syntax.Names: + // - imported objects are always fully initialized + switch exp := exp.(type) { + case *Const: + assert(exp.Val() != nil) + x.mode = constant_ + x.typ = exp.typ + x.val = exp.val + case *TypeName: + x.mode = typexpr + x.typ = exp.typ + case *Var: + x.mode = variable + x.typ = exp.typ + if pkg.cgo && strings.HasPrefix(exp.name, "_Cvar_") { + x.typ = x.typ.(*Pointer).base + } + case *Func: + x.mode = funcMode + x.typ = exp.typ + if pkg.cgo && strings.HasPrefix(exp.name, "_Cmacro_") { + x.mode = value + x.typ = x.typ.(*Signature).results.vars[0].typ + } + case *Builtin: + x.mode = builtin + x.typ = exp.typ + x.id = exp.id + default: + check.dump("%v: unexpected object %v", atPos(e.Sel), exp) + panic("unreachable") + } + x.expr = e + return + } + } + + check.exprOrType(x, e.X, false) + switch x.mode { + case builtin: + check.errorf(e.Pos(), UncalledBuiltin, "invalid use of %s in selector expression", x) + goto Error + case invalid: + goto Error + } + + // Avoid crashing when checking an invalid selector in a method declaration + // (i.e., where def is not set): + // + // type S[T any] struct{} + // type V = S[any] + // func (fs *S[T]) M(x V.M) {} + // + // All codepaths below return a non-type expression. If we get here while + // expecting a type expression, it is an error. + // + // See go.dev/issue/57522 for more details. + // + // TODO(rfindley): We should do better by refusing to check selectors in all cases where + // x.typ is incomplete. + if wantType { + check.errorf(e.Sel, NotAType, "%s is not a type", syntax.Expr(e)) + goto Error + } + + obj, index, indirect = lookupFieldOrMethod(x.typ, x.mode == variable, check.pkg, sel, false) + if obj == nil { + // Don't report another error if the underlying type was invalid (go.dev/issue/49541). + if !isValid(x.typ.Underlying()) { + goto Error + } + + if index != nil { + // TODO(gri) should provide actual type where the conflict happens + check.errorf(e.Sel, AmbiguousSelector, "ambiguous selector %s.%s", x.expr, sel) + goto Error + } + + if indirect { + if x.mode == typexpr { + check.errorf(e.Sel, InvalidMethodExpr, "invalid method expression %s.%s (needs pointer receiver (*%s).%s)", x.typ, sel, x.typ, sel) + } else { + check.errorf(e.Sel, InvalidMethodExpr, "cannot call pointer method %s on %s", sel, x.typ) + } + goto Error + } + + var why string + if isInterfacePtr(x.typ) { + why = check.interfacePtrError(x.typ) + } else { + alt, _, _ := lookupFieldOrMethod(x.typ, x.mode == variable, check.pkg, sel, true) + why = check.lookupError(x.typ, sel, alt, false) + } + check.errorf(e.Sel, MissingFieldOrMethod, "%s.%s undefined (%s)", x.expr, sel, why) + goto Error + } + + // methods may not have a fully set up signature yet + if m, _ := obj.(*Func); m != nil { + check.objDecl(m) + } + + if x.mode == typexpr { + // method expression + m, _ := obj.(*Func) + if m == nil { + check.errorf(e.Sel, MissingFieldOrMethod, "%s.%s undefined (type %s has no method %s)", x.expr, sel, x.typ, sel) + goto Error + } + + check.recordSelection(e, MethodExpr, x.typ, m, index, indirect) + + sig := m.typ.(*Signature) + if sig.recv == nil { + check.error(e, InvalidDeclCycle, "illegal cycle in method declaration") + goto Error + } + + // The receiver type becomes the type of the first function + // argument of the method expression's function type. + var params []*Var + if sig.params != nil { + params = sig.params.vars + } + // Be consistent about named/unnamed parameters. This is not needed + // for type-checking, but the newly constructed signature may appear + // in an error message and then have mixed named/unnamed parameters. + // (An alternative would be to not print parameter names in errors, + // but it's useful to see them; this is cheap and method expressions + // are rare.) + name := "" + if len(params) > 0 && params[0].name != "" { + // name needed + name = sig.recv.name + if name == "" { + name = "_" + } + } + params = append([]*Var{NewParam(sig.recv.pos, sig.recv.pkg, name, x.typ)}, params...) + x.mode = value + x.typ = &Signature{ + tparams: sig.tparams, + params: NewTuple(params...), + results: sig.results, + variadic: sig.variadic, + } + + check.addDeclDep(m) + + } else { + // regular selector + switch obj := obj.(type) { + case *Var: + check.recordSelection(e, FieldVal, x.typ, obj, index, indirect) + if x.mode == variable || indirect { + x.mode = variable + } else { + x.mode = value + } + x.typ = obj.typ + + case *Func: + // TODO(gri) If we needed to take into account the receiver's + // addressability, should we report the type &(x.typ) instead? + check.recordSelection(e, MethodVal, x.typ, obj, index, indirect) + + x.mode = value + + // remove receiver + sig := *obj.typ.(*Signature) + sig.recv = nil + x.typ = &sig + + check.addDeclDep(obj) + + default: + panic("unreachable") + } + } + + // everything went well + x.expr = e + return + +Error: + x.mode = invalid + x.typ = Typ[Invalid] + x.expr = e +} + +// use type-checks each argument. +// Useful to make sure expressions are evaluated +// (and variables are "used") in the presence of +// other errors. Arguments may be nil. +// Reports if all arguments evaluated without error. +func (check *Checker) use(args ...syntax.Expr) bool { return check.useN(args, false) } + +// useLHS is like use, but doesn't "use" top-level identifiers. +// It should be called instead of use if the arguments are +// expressions on the lhs of an assignment. +func (check *Checker) useLHS(args ...syntax.Expr) bool { return check.useN(args, true) } + +func (check *Checker) useN(args []syntax.Expr, lhs bool) bool { + ok := true + for _, e := range args { + if !check.use1(e, lhs) { + ok = false + } + } + return ok +} + +func (check *Checker) use1(e syntax.Expr, lhs bool) bool { + var x operand + x.mode = value // anything but invalid + switch n := syntax.Unparen(e).(type) { + case nil: + // nothing to do + case *syntax.Name: + // don't report an error evaluating blank + if n.Value == "_" { + break + } + // If the lhs is an identifier denoting a variable v, this assignment + // is not a 'use' of v. Remember current value of v.used and restore + // after evaluating the lhs via check.rawExpr. + var v *Var + var v_used bool + if lhs { + if obj := check.lookup(n.Value); obj != nil { + // It's ok to mark non-local variables, but ignore variables + // from other packages to avoid potential race conditions with + // dot-imported variables. + if w, _ := obj.(*Var); w != nil && w.pkg == check.pkg { + v = w + v_used = check.usedVars[v] + } + } + } + check.exprOrType(&x, n, true) + if v != nil { + check.usedVars[v] = v_used // restore v.used + } + case *syntax.ListExpr: + return check.useN(n.ElemList, lhs) + default: + check.rawExpr(nil, &x, e, nil, true) + } + return x.mode != invalid +} diff --git a/go/src/cmd/compile/internal/types2/chan.go b/go/src/cmd/compile/internal/types2/chan.go new file mode 100644 index 0000000000000000000000000000000000000000..77650dfb09daad6b56df0138063676b381b84fcc --- /dev/null +++ b/go/src/cmd/compile/internal/types2/chan.go @@ -0,0 +1,35 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2 + +// A Chan represents a channel type. +type Chan struct { + dir ChanDir + elem Type +} + +// A ChanDir value indicates a channel direction. +type ChanDir int + +// The direction of a channel is indicated by one of these constants. +const ( + SendRecv ChanDir = iota + SendOnly + RecvOnly +) + +// NewChan returns a new channel type for the given direction and element type. +func NewChan(dir ChanDir, elem Type) *Chan { + return &Chan{dir: dir, elem: elem} +} + +// Dir returns the direction of channel c. +func (c *Chan) Dir() ChanDir { return c.dir } + +// Elem returns the element type of channel c. +func (c *Chan) Elem() Type { return c.elem } + +func (c *Chan) Underlying() Type { return c } +func (c *Chan) String() string { return TypeString(c, nil) } diff --git a/go/src/cmd/compile/internal/types2/check.go b/go/src/cmd/compile/internal/types2/check.go new file mode 100644 index 0000000000000000000000000000000000000000..42218b4cafe75c7139255d23da7766f45eed272d --- /dev/null +++ b/go/src/cmd/compile/internal/types2/check.go @@ -0,0 +1,664 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements the Check function, which drives type-checking. + +package types2 + +import ( + "cmd/compile/internal/syntax" + "fmt" + "go/constant" + . "internal/types/errors" + "os" + "sync/atomic" +) + +// nopos indicates an unknown position +var nopos syntax.Pos + +// debugging/development support +const debug = false // leave on during development + +// position tracing for panics during type checking +const tracePos = true + +// _aliasAny changes the behavior of [Scope.Lookup] for "any" in the +// [Universe] scope. +// +// This is necessary because while Alias creation is controlled by +// [Config.EnableAlias], the representation of "any" is a global. In +// [Scope.Lookup], we select this global representation based on the result of +// [aliasAny], but as a result need to guard against this behavior changing +// during the type checking pass. Therefore we implement the following rule: +// any number of goroutines can type check concurrently with the same +// EnableAlias value, but if any goroutine tries to type check concurrently +// with a different EnableAlias value, we panic. +// +// To achieve this, _aliasAny is a state machine: +// +// 0: no type checking is occurring +// negative: type checking is occurring without EnableAlias set +// positive: type checking is occurring with EnableAlias set +var _aliasAny int32 + +func aliasAny() bool { + return atomic.LoadInt32(&_aliasAny) >= 0 // default true +} + +// exprInfo stores information about an untyped expression. +type exprInfo struct { + isLhs bool // expression is lhs operand of a shift with delayed type-check + mode operandMode + typ *Basic + val constant.Value // constant value; or nil (if not a constant) +} + +// An environment represents the environment within which an object is +// type-checked. +type environment struct { + decl *declInfo // package-level declaration whose init expression/function body is checked + scope *Scope // top-most scope for lookups + version goVersion // current accepted language version; changes across files + iota constant.Value // value of iota in a constant declaration; nil otherwise + errpos syntax.Pos // if valid, identifier position of a constant with inherited initializer + inTParamList bool // set if inside a type parameter list + sig *Signature // function signature if inside a function; nil otherwise + isPanic map[*syntax.CallExpr]bool // set of panic call expressions (used for termination check) + hasLabel bool // set if a function makes use of labels (only ~1% of functions); unused outside functions + hasCallOrRecv bool // set if an expression contains a function call or channel receive operation +} + +// lookupScope looks up name in the current environment and if an object +// is found it returns the scope containing the object and the object. +// Otherwise it returns (nil, nil). +// +// Note that obj.Parent() may be different from the returned scope if the +// object was inserted into the scope and already had a parent at that +// time (see Scope.Insert). This can only happen for dot-imported objects +// whose parent is the scope of the package that exported them. +func (env *environment) lookupScope(name string) (*Scope, Object) { + for s := env.scope; s != nil; s = s.parent { + if obj := s.Lookup(name); obj != nil { + return s, obj + } + } + return nil, nil +} + +// lookup is like lookupScope but it only returns the object (or nil). +func (env *environment) lookup(name string) Object { + _, obj := env.lookupScope(name) + return obj +} + +// An importKey identifies an imported package by import path and source directory +// (directory containing the file containing the import). In practice, the directory +// may always be the same, or may not matter. Given an (import path, directory), an +// importer must always return the same package (but given two different import paths, +// an importer may still return the same package by mapping them to the same package +// paths). +type importKey struct { + path, dir string +} + +// A dotImportKey describes a dot-imported object in the given scope. +type dotImportKey struct { + scope *Scope + name string +} + +// An action describes a (delayed) action. +type action struct { + version goVersion // applicable language version + f func() // action to be executed + desc *actionDesc // action description; may be nil, requires debug to be set +} + +// If debug is set, describef sets a printf-formatted description for action a. +// Otherwise, it is a no-op. +func (a *action) describef(pos poser, format string, args ...any) { + if debug { + a.desc = &actionDesc{pos, format, args} + } +} + +// An actionDesc provides information on an action. +// For debugging only. +type actionDesc struct { + pos poser + format string + args []any +} + +// A Checker maintains the state of the type checker. +// It must be created with NewChecker. +type Checker struct { + // package information + // (initialized by NewChecker, valid for the life-time of checker) + conf *Config + ctxt *Context // context for de-duplicating instances + pkg *Package + *Info + nextID uint64 // unique Id for type parameters (first valid Id is 1) + objMap map[Object]*declInfo // maps package-level objects and (non-interface) methods to declaration info + objList []Object // source-ordered keys of objMap + impMap map[importKey]*Package // maps (import path, source directory) to (complete or fake) package + // see TODO in validtype.go + // valids instanceLookup // valid *Named (incl. instantiated) types per the validType check + + // pkgPathMap maps package names to the set of distinct import paths we've + // seen for that name, anywhere in the import graph. It is used for + // disambiguating package names in error messages. + // + // pkgPathMap is allocated lazily, so that we don't pay the price of building + // it on the happy path. seenPkgMap tracks the packages that we've already + // walked. + pkgPathMap map[string]map[string]bool + seenPkgMap map[*Package]bool + + // information collected during type-checking of a set of package files + // (initialized by Files, valid only for the duration of check.Files; + // maps and lists are allocated on demand) + files []*syntax.File // list of package files + versions map[*syntax.PosBase]string // maps files to version strings (each file has an entry); shared with Info.FileVersions if present; may be unaltered Config.GoVersion + imports []*PkgName // list of imported packages + dotImportMap map[dotImportKey]*PkgName // maps dot-imported objects to the package they were dot-imported through + brokenAliases map[*TypeName]bool // set of aliases with broken (not yet determined) types + unionTypeSets map[*Union]*_TypeSet // computed type sets for union types + usedVars map[*Var]bool // set of used variables + usedPkgNames map[*PkgName]bool // set of used package names + mono monoGraph // graph for detecting non-monomorphizable instantiation loops + + firstErr error // first error encountered + methods map[*TypeName][]*Func // maps package scope type names to associated non-blank (non-interface) methods + untyped map[syntax.Expr]exprInfo // map of expressions without final type + delayed []action // stack of delayed action segments; segments are processed in FIFO order + objPath []Object // path of object dependencies during type-checking (for cycle reporting) + objPathIdx map[Object]int // map of object to object path index during type-checking (for cycle reporting) + cleaners []cleaner // list of types that may need a final cleanup at the end of type-checking + + // environment within which the current object is type-checked (valid only + // for the duration of type-checking a specific object) + environment + + // debugging + posStack []syntax.Pos // stack of source positions seen; used for panic tracing + indent int // indentation for tracing +} + +// addDeclDep adds the dependency edge (check.decl -> to) if check.decl exists +func (check *Checker) addDeclDep(to Object) { + from := check.decl + if from == nil { + return // not in a package-level init expression + } + if _, found := check.objMap[to]; !found { + return // to is not a package-level object + } + from.addDep(to) +} + +// Note: The following three alias-related functions are only used +// when Alias types are not enabled. + +// brokenAlias records that alias doesn't have a determined type yet. +// It also sets alias.typ to Typ[Invalid]. +// Not used if check.conf.EnableAlias is set. +func (check *Checker) brokenAlias(alias *TypeName) { + assert(!check.conf.EnableAlias) + if check.brokenAliases == nil { + check.brokenAliases = make(map[*TypeName]bool) + } + check.brokenAliases[alias] = true + alias.typ = Typ[Invalid] +} + +// validAlias records that alias has the valid type typ (possibly Typ[Invalid]). +func (check *Checker) validAlias(alias *TypeName, typ Type) { + assert(!check.conf.EnableAlias) + delete(check.brokenAliases, alias) + alias.typ = typ +} + +// isBrokenAlias reports whether alias doesn't have a determined type yet. +func (check *Checker) isBrokenAlias(alias *TypeName) bool { + assert(!check.conf.EnableAlias) + return check.brokenAliases[alias] +} + +func (check *Checker) rememberUntyped(e syntax.Expr, lhs bool, mode operandMode, typ *Basic, val constant.Value) { + m := check.untyped + if m == nil { + m = make(map[syntax.Expr]exprInfo) + check.untyped = m + } + m[e] = exprInfo{lhs, mode, typ, val} +} + +// later pushes f on to the stack of actions that will be processed later; +// either at the end of the current statement, or in case of a local constant +// or variable declaration, before the constant or variable is in scope +// (so that f still sees the scope before any new declarations). +// later returns the pushed action so one can provide a description +// via action.describef for debugging, if desired. +func (check *Checker) later(f func()) *action { + i := len(check.delayed) + check.delayed = append(check.delayed, action{version: check.version, f: f}) + return &check.delayed[i] +} + +// push pushes obj onto the object path and records its index in the path index map. +func (check *Checker) push(obj Object) { + if check.objPathIdx == nil { + check.objPathIdx = make(map[Object]int) + } + check.objPathIdx[obj] = len(check.objPath) + check.objPath = append(check.objPath, obj) +} + +// pop pops an object from the object path and removes it from the path index map. +func (check *Checker) pop() { + i := len(check.objPath) - 1 + obj := check.objPath[i] + check.objPath[i] = nil // help the garbage collector + check.objPath = check.objPath[:i] + delete(check.objPathIdx, obj) +} + +type cleaner interface { + cleanup() +} + +// needsCleanup records objects/types that implement the cleanup method +// which will be called at the end of type-checking. +func (check *Checker) needsCleanup(c cleaner) { + check.cleaners = append(check.cleaners, c) +} + +// NewChecker returns a new Checker instance for a given package. +// Package files may be added incrementally via checker.Files. +func NewChecker(conf *Config, pkg *Package, info *Info) *Checker { + // make sure we have a configuration + if conf == nil { + conf = new(Config) + } + + // make sure we have an info struct + if info == nil { + info = new(Info) + } + + // Note: clients may call NewChecker with the Unsafe package, which is + // globally shared and must not be mutated. Therefore NewChecker must not + // mutate *pkg. + // + // (previously, pkg.goVersion was mutated here: go.dev/issue/61212) + + return &Checker{ + conf: conf, + ctxt: conf.Context, + pkg: pkg, + Info: info, + objMap: make(map[Object]*declInfo), + impMap: make(map[importKey]*Package), + usedVars: make(map[*Var]bool), + usedPkgNames: make(map[*PkgName]bool), + } +} + +// initFiles initializes the files-specific portion of checker. +// The provided files must all belong to the same package. +func (check *Checker) initFiles(files []*syntax.File) { + // start with a clean slate (check.Files may be called multiple times) + // TODO(gri): what determines which fields are zeroed out here, vs at the end + // of checkFiles? + check.files = nil + check.imports = nil + check.dotImportMap = nil + + check.firstErr = nil + check.methods = nil + check.untyped = nil + check.delayed = nil + check.objPath = nil + check.objPathIdx = nil + check.cleaners = nil + + // We must initialize usedVars and usedPkgNames both here and in NewChecker, + // because initFiles is not called in the CheckExpr or Eval codepaths, yet we + // want to free this memory at the end of Files ('used' predicates are + // only needed in the context of a given file). + check.usedVars = make(map[*Var]bool) + check.usedPkgNames = make(map[*PkgName]bool) + + // determine package name and collect valid files + pkg := check.pkg + for _, file := range files { + switch name := file.PkgName.Value; pkg.name { + case "": + if name != "_" { + pkg.name = name + } else { + check.error(file.PkgName, BlankPkgName, "invalid package name _") + } + fallthrough + + case name: + check.files = append(check.files, file) + + default: + check.errorf(file, MismatchedPkgName, "package %s; expected package %s", name, pkg.name) + // ignore this file + } + } + + // reuse Info.FileVersions if provided + versions := check.Info.FileVersions + if versions == nil { + versions = make(map[*syntax.PosBase]string) + } + check.versions = versions + + pkgVersion := asGoVersion(check.conf.GoVersion) + if pkgVersion.isValid() && len(files) > 0 && pkgVersion.cmp(go_current) > 0 { + check.errorf(files[0], TooNew, "package requires newer Go version %v (application built with %v)", + pkgVersion, go_current) + } + + // determine Go version for each file + for _, file := range check.files { + // use unaltered Config.GoVersion by default + // (This version string may contain dot-release numbers as in go1.20.1, + // unlike file versions which are Go language versions only, if valid.) + v := check.conf.GoVersion + + // If the file specifies a version, use max(fileVersion, go1.21). + if fileVersion := asGoVersion(file.GoVersion); fileVersion.isValid() { + // Go 1.21 introduced the feature of allowing //go:build lines + // to sometimes set the Go version in a given file. Versions Go 1.21 and later + // can be set backwards compatibly as that was the first version + // files with go1.21 or later build tags could be built with. + // + // Set the version to max(fileVersion, go1.21): That will allow a + // downgrade to a version before go1.22, where the for loop semantics + // change was made, while being backwards compatible with versions of + // go before the new //go:build semantics were introduced. + v = string(versionMax(fileVersion, go1_21)) + + // Report a specific error for each tagged file that's too new. + // (Normally the build system will have filtered files by version, + // but clients can present arbitrary files to the type checker.) + if fileVersion.cmp(go_current) > 0 { + // Use position of 'package [p]' for types/types2 consistency. + // (Ideally we would use the //build tag itself.) + check.errorf(file.PkgName, TooNew, "file requires newer Go version %v", fileVersion) + } + } + versions[file.Pos().FileBase()] = v // file.Pos().FileBase() may be nil for tests + } +} + +func versionMax(a, b goVersion) goVersion { + if a.cmp(b) > 0 { + return a + } + return b +} + +// pushPos pushes pos onto the pos stack. +func (check *Checker) pushPos(pos syntax.Pos) { + check.posStack = append(check.posStack, pos) +} + +// popPos pops from the pos stack. +func (check *Checker) popPos() { + check.posStack = check.posStack[:len(check.posStack)-1] +} + +// A bailout panic is used for early termination. +type bailout struct{} + +func (check *Checker) handleBailout(err *error) { + switch p := recover().(type) { + case nil, bailout: + // normal return or early exit + *err = check.firstErr + default: + if len(check.posStack) > 0 { + doPrint := func(ps []syntax.Pos) { + for i := len(ps) - 1; i >= 0; i-- { + fmt.Fprintf(os.Stderr, "\t%v\n", ps[i]) + } + } + + fmt.Fprintln(os.Stderr, "The following panic happened checking types near:") + if len(check.posStack) <= 10 { + doPrint(check.posStack) + } else { + // if it's long, truncate the middle; it's least likely to help + doPrint(check.posStack[len(check.posStack)-5:]) + fmt.Fprintln(os.Stderr, "\t...") + doPrint(check.posStack[:5]) + } + } + + // re-panic + panic(p) + } +} + +// Files checks the provided files as part of the checker's package. +func (check *Checker) Files(files []*syntax.File) (err error) { + if check.pkg == Unsafe { + // Defensive handling for Unsafe, which cannot be type checked, and must + // not be mutated. See https://go.dev/issue/61212 for an example of where + // Unsafe is passed to NewChecker. + return nil + } + + // Avoid early returns here! Nearly all errors can be + // localized to a piece of syntax and needn't prevent + // type-checking of the rest of the package. + + defer check.handleBailout(&err) + check.checkFiles(files) + return +} + +// checkFiles type-checks the specified files. Errors are reported as +// a side effect, not by returning early, to ensure that well-formed +// syntax is properly type annotated even in a package containing +// errors. +func (check *Checker) checkFiles(files []*syntax.File) { + // Ensure that EnableAlias is consistent among concurrent type checking + // operations. See the documentation of [_aliasAny] for details. + if check.conf.EnableAlias { + if atomic.AddInt32(&_aliasAny, 1) <= 0 { + panic("EnableAlias set while !EnableAlias type checking is ongoing") + } + defer atomic.AddInt32(&_aliasAny, -1) + } else { + if atomic.AddInt32(&_aliasAny, -1) >= 0 { + panic("!EnableAlias set while EnableAlias type checking is ongoing") + } + defer atomic.AddInt32(&_aliasAny, 1) + } + + print := func(msg string) { + if check.conf.Trace { + fmt.Println() + fmt.Println(msg) + } + } + + print("== initFiles ==") + check.initFiles(files) + + print("== collectObjects ==") + check.collectObjects() + + print("== sortObjects ==") + check.sortObjects() + + print("== directCycles ==") + check.directCycles() + + print("== packageObjects ==") + check.packageObjects() + + print("== processDelayed ==") + check.processDelayed(0) // incl. all functions + + print("== cleanup ==") + check.cleanup() + + print("== initOrder ==") + check.initOrder() + + if !check.conf.DisableUnusedImportCheck { + print("== unusedImports ==") + check.unusedImports() + } + + print("== recordUntyped ==") + check.recordUntyped() + + if check.firstErr == nil { + // TODO(mdempsky): Ensure monomorph is safe when errors exist. + check.monomorph() + } + + check.pkg.goVersion = check.conf.GoVersion + check.pkg.complete = true + + // no longer needed - release memory + check.imports = nil + check.dotImportMap = nil + check.pkgPathMap = nil + check.seenPkgMap = nil + check.brokenAliases = nil + check.unionTypeSets = nil + check.usedVars = nil + check.usedPkgNames = nil + check.ctxt = nil + + // TODO(gri): shouldn't the cleanup above occur after the bailout? + // TODO(gri) There's more memory we should release at this point. +} + +// processDelayed processes all delayed actions pushed after top. +func (check *Checker) processDelayed(top int) { + // If each delayed action pushes a new action, the + // stack will continue to grow during this loop. + // However, it is only processing functions (which + // are processed in a delayed fashion) that may + // add more actions (such as nested functions), so + // this is a sufficiently bounded process. + savedVersion := check.version + for i := top; i < len(check.delayed); i++ { + a := &check.delayed[i] + if check.conf.Trace { + if a.desc != nil { + check.trace(a.desc.pos.Pos(), "-- "+a.desc.format, a.desc.args...) + } else { + check.trace(nopos, "-- delayed %p", a.f) + } + } + check.version = a.version // reestablish the effective Go version captured earlier + a.f() // may append to check.delayed + if check.conf.Trace { + fmt.Println() + } + } + assert(top <= len(check.delayed)) // stack must not have shrunk + check.delayed = check.delayed[:top] + check.version = savedVersion +} + +// cleanup runs cleanup for all collected cleaners. +func (check *Checker) cleanup() { + // Don't use a range clause since Named.cleanup may add more cleaners. + for i := 0; i < len(check.cleaners); i++ { + check.cleaners[i].cleanup() + } + check.cleaners = nil +} + +// types2-specific support for recording type information in the syntax tree. +func (check *Checker) recordTypeAndValueInSyntax(x syntax.Expr, mode operandMode, typ Type, val constant.Value) { + if check.StoreTypesInSyntax { + tv := TypeAndValue{mode, typ, val} + stv := syntax.TypeAndValue{Type: typ, Value: val} + if tv.IsVoid() { + stv.SetIsVoid() + } + if tv.IsType() { + stv.SetIsType() + } + if tv.IsBuiltin() { + stv.SetIsBuiltin() + } + if tv.IsValue() { + stv.SetIsValue() + } + if tv.IsNil() { + stv.SetIsNil() + } + if tv.Addressable() { + stv.SetAddressable() + } + if tv.Assignable() { + stv.SetAssignable() + } + if tv.HasOk() { + stv.SetHasOk() + } + x.SetTypeInfo(stv) + } +} + +// types2-specific support for recording type information in the syntax tree. +func (check *Checker) recordCommaOkTypesInSyntax(x syntax.Expr, t0, t1 Type) { + if check.StoreTypesInSyntax { + // Note: this loop is duplicated because the type of tv is different. + // Above it is types2.TypeAndValue, here it is syntax.TypeAndValue. + for { + tv := x.GetTypeInfo() + assert(tv.Type != nil) // should have been recorded already + pos := x.Pos() + tv.Type = NewTuple( + NewParam(pos, check.pkg, "", t0), + NewParam(pos, check.pkg, "", t1), + ) + x.SetTypeInfo(tv) + p, _ := x.(*syntax.ParenExpr) + if p == nil { + break + } + x = p.X + } + } +} + +// instantiatedIdent determines the identifier of the type instantiated in expr. +// Helper function for recordInstance in recording.go. +func instantiatedIdent(expr syntax.Expr) *syntax.Name { + var selOrIdent syntax.Expr + switch e := expr.(type) { + case *syntax.IndexExpr: + selOrIdent = e.X + case *syntax.SelectorExpr, *syntax.Name: + selOrIdent = e + } + switch x := selOrIdent.(type) { + case *syntax.Name: + return x + case *syntax.SelectorExpr: + return x.Sel + } + + // extra debugging of go.dev/issue/63933 + panic(sprintf(nil, true, "instantiated ident not found; please report: %s", expr)) +} diff --git a/go/src/cmd/compile/internal/types2/check_test.go b/go/src/cmd/compile/internal/types2/check_test.go new file mode 100644 index 0000000000000000000000000000000000000000..8b97a9f676e0734230ad0da24d9b7a74092687f9 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/check_test.go @@ -0,0 +1,465 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements a typechecker test harness. The packages specified +// in tests are typechecked. Error messages reported by the typechecker are +// compared against the errors expected in the test files. +// +// Expected errors are indicated in the test files by putting comments +// of the form /* ERROR pattern */ or /* ERRORx pattern */ (or a similar +// //-style line comment) immediately following the tokens where errors +// are reported. There must be exactly one blank before and after the +// ERROR/ERRORx indicator, and the pattern must be a properly quoted Go +// string. +// +// The harness will verify that each ERROR pattern is a substring of the +// error reported at that source position, and that each ERRORx pattern +// is a regular expression matching the respective error. +// Consecutive comments may be used to indicate multiple errors reported +// at the same position. +// +// For instance, the following test source indicates that an "undeclared" +// error should be reported for the undeclared variable x: +// +// package p +// func f() { +// _ = x /* ERROR "undeclared" */ + 1 +// } + +package types2_test + +import ( + "bytes" + "cmd/compile/internal/syntax" + "flag" + "fmt" + "internal/buildcfg" + "internal/testenv" + "os" + "path/filepath" + "reflect" + "regexp" + "runtime" + "strconv" + "strings" + "testing" + + . "cmd/compile/internal/types2" +) + +var ( + haltOnError = flag.Bool("halt", false, "halt on error") + verifyErrors = flag.Bool("verify", false, "verify errors (rather than list them) in TestManual") +) + +func parseFiles(t *testing.T, filenames []string, srcs [][]byte, mode syntax.Mode) ([]*syntax.File, []error) { + var files []*syntax.File + var errlist []error + errh := func(err error) { errlist = append(errlist, err) } + for i, filename := range filenames { + base := syntax.NewFileBase(filename) + r := bytes.NewReader(srcs[i]) + file, err := syntax.Parse(base, r, errh, nil, mode) + if file == nil { + t.Fatalf("%s: %s", filename, err) + } + files = append(files, file) + } + return files, errlist +} + +func unpackError(err error) (syntax.Pos, string) { + switch err := err.(type) { + case syntax.Error: + return err.Pos, err.Msg + case Error: + return err.Pos, err.Msg + default: + return nopos, err.Error() + } +} + +// absDiff returns the absolute difference between x and y. +func absDiff(x, y uint) uint { + if x < y { + return y - x + } + return x - y +} + +// parseFlags parses flags from the first line of the given source if the line +// starts with "//" (line comment) followed by "-" (possibly with spaces +// between). Otherwise the line is ignored. +func parseFlags(src []byte, flags *flag.FlagSet) error { + // we must have a line comment that starts with a "-" + const prefix = "//" + if !bytes.HasPrefix(src, []byte(prefix)) { + return nil // first line is not a line comment + } + src = src[len(prefix):] + if i := bytes.Index(src, []byte("-")); i < 0 || len(bytes.TrimSpace(src[:i])) != 0 { + return nil // comment doesn't start with a "-" + } + end := bytes.Index(src, []byte("\n")) + const maxLen = 256 + if end < 0 || end > maxLen { + return fmt.Errorf("flags comment line too long") + } + + return flags.Parse(strings.Fields(string(src[:end]))) +} + +// testFiles type-checks the package consisting of the given files, and +// compares the resulting errors with the ERROR annotations in the source. +// Except for manual tests, each package is type-checked twice, once without +// use of Alias types, and once with Alias types. +// +// The srcs slice contains the file content for the files named in the +// filenames slice. The colDelta parameter specifies the tolerance for position +// mismatch when comparing errors. The manual parameter specifies whether this +// is a 'manual' test. +// +// If provided, opts may be used to mutate the Config before type-checking. +func testFiles(t *testing.T, filenames []string, srcs [][]byte, colDelta uint, manual bool, opts ...func(*Config)) { + enableAlias := true + opts = append(opts, func(conf *Config) { conf.EnableAlias = enableAlias }) + testFilesImpl(t, filenames, srcs, colDelta, manual, opts...) + if !manual { + enableAlias = false + testFilesImpl(t, filenames, srcs, colDelta, manual, opts...) + } +} + +func testFilesImpl(t *testing.T, filenames []string, srcs [][]byte, colDelta uint, manual bool, opts ...func(*Config)) { + if len(filenames) == 0 { + t.Fatal("no source files") + } + + // parse files + files, errlist := parseFiles(t, filenames, srcs, 0) + pkgName := "" + if len(files) > 0 { + pkgName = files[0].PkgName.Value + } + listErrors := manual && !*verifyErrors + if listErrors && len(errlist) > 0 { + t.Errorf("--- %s:", pkgName) + for _, err := range errlist { + t.Error(err) + } + } + + // set up typechecker + var conf Config + conf.Trace = manual && testing.Verbose() + conf.Importer = defaultImporter() + conf.Error = func(err error) { + if *haltOnError { + defer panic(err) + } + if listErrors { + t.Error(err) + return + } + errlist = append(errlist, err) + } + + // apply custom configuration + for _, opt := range opts { + opt(&conf) + } + + // apply flag setting (overrides custom configuration) + var goexperiment, gotypesalias string + flags := flag.NewFlagSet("", flag.PanicOnError) + flags.StringVar(&conf.GoVersion, "lang", "", "") + flags.StringVar(&goexperiment, "goexperiment", "", "") + flags.BoolVar(&conf.FakeImportC, "fakeImportC", false, "") + flags.StringVar(&gotypesalias, "gotypesalias", "", "") + if err := parseFlags(srcs[0], flags); err != nil { + t.Fatal(err) + } + + if goexperiment != "" { + revert := setGOEXPERIMENT(goexperiment) + defer revert() + } + + // By default, gotypesalias is not set. + if gotypesalias != "" { + conf.EnableAlias = gotypesalias != "0" + } + + // Provide Config.Info with all maps so that info recording is tested. + info := Info{ + Types: make(map[syntax.Expr]TypeAndValue), + Instances: make(map[*syntax.Name]Instance), + Defs: make(map[*syntax.Name]Object), + Uses: make(map[*syntax.Name]Object), + Implicits: make(map[syntax.Node]Object), + Selections: make(map[*syntax.SelectorExpr]*Selection), + Scopes: make(map[syntax.Node]*Scope), + FileVersions: make(map[*syntax.PosBase]string), + } + + // typecheck + conf.Check(pkgName, files, &info) + if listErrors { + return + } + + // collect expected errors + errmap := make(map[string]map[uint][]syntax.Error) + for i, filename := range filenames { + if m := syntax.CommentMap(bytes.NewReader(srcs[i]), regexp.MustCompile("^ ERRORx? ")); len(m) > 0 { + errmap[filename] = m + } + } + + // match against found errors + var indices []int // list indices of matching errors, reused for each error + for _, err := range errlist { + gotPos, gotMsg := unpackError(err) + + // find list of errors for the respective error line + filename := gotPos.Base().Filename() + filemap := errmap[filename] + line := gotPos.Line() + var errList []syntax.Error + if filemap != nil { + errList = filemap[line] + } + + // At least one of the errors in errList should match the current error. + indices = indices[:0] + for i, want := range errList { + pattern, substr := strings.CutPrefix(want.Msg, " ERROR ") + if !substr { + var found bool + pattern, found = strings.CutPrefix(want.Msg, " ERRORx ") + if !found { + panic("unreachable") + } + } + unquoted, err := strconv.Unquote(strings.TrimSpace(pattern)) + if err != nil { + t.Errorf("%s:%d:%d: invalid ERROR pattern (cannot unquote %s)", filename, line, want.Pos.Col(), pattern) + continue + } + if substr { + if !strings.Contains(gotMsg, unquoted) { + continue + } + } else { + rx, err := regexp.Compile(unquoted) + if err != nil { + t.Errorf("%s:%d:%d: %v", filename, line, want.Pos.Col(), err) + continue + } + if !rx.MatchString(gotMsg) { + continue + } + } + indices = append(indices, i) + } + if len(indices) == 0 { + t.Errorf("%s: no error expected: %q", gotPos, gotMsg) + continue + } + // len(indices) > 0 + + // If there are multiple matching errors, select the one with the closest column position. + index := -1 // index of matching error + var delta uint + for _, i := range indices { + if d := absDiff(gotPos.Col(), errList[i].Pos.Col()); index < 0 || d < delta { + index, delta = i, d + } + } + + // The closest column position must be within expected colDelta. + if delta > colDelta { + t.Errorf("%s: got col = %d; want %d", gotPos, gotPos.Col(), errList[index].Pos.Col()) + } + + // eliminate from errList + if n := len(errList) - 1; n > 0 { + // not the last entry - slide entries down (don't reorder) + copy(errList[index:], errList[index+1:]) + filemap[line] = errList[:n] + } else { + // last entry - remove errList from filemap + delete(filemap, line) + } + + // if filemap is empty, eliminate from errmap + if len(filemap) == 0 { + delete(errmap, filename) + } + } + + // there should be no expected errors left + if len(errmap) > 0 { + t.Errorf("--- %s: unreported errors:", pkgName) + for filename, filemap := range errmap { + for line, errList := range filemap { + for _, err := range errList { + t.Errorf("%s:%d:%d: %s", filename, line, err.Pos.Col(), err.Msg) + } + } + } + } +} + +// boolFieldAddr(conf, name) returns the address of the boolean field conf.. +// For accessing unexported fields. +func boolFieldAddr(conf *Config, name string) *bool { + v := reflect.Indirect(reflect.ValueOf(conf)) + return (*bool)(v.FieldByName(name).Addr().UnsafePointer()) +} + +// setGOEXPERIMENT overwrites the existing buildcfg.Experiment with a new one +// based on the provided goexperiment string. Calling the result function +// (typically via defer), reverts buildcfg.Experiment to the prior value. +// For testing use, only. +func setGOEXPERIMENT(goexperiment string) func() { + exp, err := buildcfg.ParseGOEXPERIMENT(runtime.GOOS, runtime.GOARCH, goexperiment) + if err != nil { + panic(err) + } + old := buildcfg.Experiment + buildcfg.Experiment = *exp + return func() { buildcfg.Experiment = old } +} + +// TestManual is for manual testing of a package - either provided +// as a list of filenames belonging to the package, or a directory +// name containing the package files - after the test arguments +// (and a separating "--"). For instance, to test the package made +// of the files foo.go and bar.go, use: +// +// go test -run Manual -- foo.go bar.go +// +// If no source arguments are provided, the file testdata/manual.go +// is used instead. +// Provide the -verify flag to verify errors against ERROR comments +// in the input files rather than having a list of errors reported. +// The accepted Go language version can be controlled with the -lang +// flag. +func TestManual(t *testing.T) { + testenv.MustHaveGoBuild(t) + + filenames := flag.Args() + if len(filenames) == 0 { + filenames = []string{filepath.FromSlash("testdata/manual.go")} + } + + info, err := os.Stat(filenames[0]) + if err != nil { + t.Fatalf("TestManual: %v", err) + } + + DefPredeclaredTestFuncs() + if info.IsDir() { + if len(filenames) > 1 { + t.Fatal("TestManual: must have only one directory argument") + } + testDir(t, filenames[0], 0, true) + } else { + testPkg(t, filenames, 0, true) + } +} + +func TestLongConstants(t *testing.T) { + format := `package longconst; const _ = %s /* ERROR "constant overflow" */; const _ = %s // ERROR "excessively long constant"` + src := fmt.Sprintf(format, strings.Repeat("1", 9999), strings.Repeat("1", 10001)) + testFiles(t, []string{"longconst.go"}, [][]byte{[]byte(src)}, 0, false) +} + +func withSizes(sizes Sizes) func(*Config) { + return func(cfg *Config) { + cfg.Sizes = sizes + } +} + +// TestIndexRepresentability tests that constant index operands must +// be representable as int even if they already have a type that can +// represent larger values. +func TestIndexRepresentability(t *testing.T) { + const src = `package index; var s []byte; var _ = s[int64 /* ERRORx "int64\\(1\\) << 40 \\(.*\\) overflows int" */ (1) << 40]` + testFiles(t, []string{"index.go"}, [][]byte{[]byte(src)}, 0, false, withSizes(&StdSizes{4, 4})) +} + +func TestIssue47243_TypedRHS(t *testing.T) { + // The RHS of the shift expression below overflows uint on 32bit platforms, + // but this is OK as it is explicitly typed. + const src = `package issue47243; var a uint64; var _ = a << uint64(4294967296)` // uint64(1<<32) + testFiles(t, []string{"p.go"}, [][]byte{[]byte(src)}, 0, false, withSizes(&StdSizes{4, 4})) +} + +func TestCheck(t *testing.T) { + DefPredeclaredTestFuncs() + testDirFiles(t, "../../../../internal/types/testdata/check", 50, false) // TODO(gri) narrow column tolerance +} +func TestSpec(t *testing.T) { testDirFiles(t, "../../../../internal/types/testdata/spec", 20, false) } // TODO(gri) narrow column tolerance +func TestExamples(t *testing.T) { + testDirFiles(t, "../../../../internal/types/testdata/examples", 125, false) +} // TODO(gri) narrow column tolerance +func TestFixedbugs(t *testing.T) { + testDirFiles(t, "../../../../internal/types/testdata/fixedbugs", 100, false) +} // TODO(gri) narrow column tolerance +func TestLocal(t *testing.T) { testDirFiles(t, "testdata/local", 0, false) } + +func testDirFiles(t *testing.T, dir string, colDelta uint, manual bool) { + testenv.MustHaveGoBuild(t) + dir = filepath.FromSlash(dir) + + fis, err := os.ReadDir(dir) + if err != nil { + t.Error(err) + return + } + + for _, fi := range fis { + path := filepath.Join(dir, fi.Name()) + + // If fi is a directory, its files make up a single package. + if fi.IsDir() { + testDir(t, path, colDelta, manual) + } else { + t.Run(filepath.Base(path), func(t *testing.T) { + testPkg(t, []string{path}, colDelta, manual) + }) + } + } +} + +func testDir(t *testing.T, dir string, colDelta uint, manual bool) { + fis, err := os.ReadDir(dir) + if err != nil { + t.Error(err) + return + } + + var filenames []string + for _, fi := range fis { + filenames = append(filenames, filepath.Join(dir, fi.Name())) + } + + t.Run(filepath.Base(dir), func(t *testing.T) { + testPkg(t, filenames, colDelta, manual) + }) +} + +func testPkg(t *testing.T, filenames []string, colDelta uint, manual bool) { + srcs := make([][]byte, len(filenames)) + for i, filename := range filenames { + src, err := os.ReadFile(filename) + if err != nil { + t.Fatalf("could not read %s: %v", filename, err) + } + srcs[i] = src + } + testFiles(t, filenames, srcs, colDelta, manual) +} diff --git a/go/src/cmd/compile/internal/types2/compiler_internal.go b/go/src/cmd/compile/internal/types2/compiler_internal.go new file mode 100644 index 0000000000000000000000000000000000000000..7b976625ef8cef8b4d4f493c10431738c6a7805e --- /dev/null +++ b/go/src/cmd/compile/internal/types2/compiler_internal.go @@ -0,0 +1,50 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2 + +import ( + "cmd/compile/internal/syntax" + "fmt" +) + +// This file should not be copied to go/types. See go.dev/issue/67477 + +// RenameResult takes an array of (result) fields and an index, and if the indexed field +// does not have a name and if the result in the signature also does not have a name, +// then the signature and field are renamed to +// +// fmt.Sprintf("#rv%d", i+1) +// +// the newly named object is inserted into the signature's scope, +// and the object and new field name are returned. +// +// The intended use for RenameResult is to allow rangefunc to assign results within a closure. +// This is a hack, as narrowly targeted as possible to discourage abuse. +func (s *Signature) RenameResult(results []*syntax.Field, i int) (*Var, *syntax.Name) { + a := results[i] + obj := s.Results().At(i) + + if !(obj.name == "" || obj.name == "_" && a.Name == nil || a.Name.Value == "_") { + panic("Cannot change an existing name") + } + + pos := a.Pos() + typ := a.Type.GetTypeInfo().Type + + name := fmt.Sprintf("#rv%d", i+1) + obj.name = name + s.scope.Insert(obj) + obj.setScopePos(pos) + + tv := syntax.TypeAndValue{Type: typ} + tv.SetIsValue() + + n := syntax.NewName(pos, obj.Name()) + n.SetTypeInfo(tv) + + a.Name = n + + return obj, n +} diff --git a/go/src/cmd/compile/internal/types2/compilersupport.go b/go/src/cmd/compile/internal/types2/compilersupport.go new file mode 100644 index 0000000000000000000000000000000000000000..d29241a2ed70b9013fd8877e373e291db82a4622 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/compilersupport.go @@ -0,0 +1,33 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Helper functions exported for the compiler. +// Do not use internally. + +package types2 + +// If t is a pointer, AsPointer returns that type, otherwise it returns nil. +func AsPointer(t Type) *Pointer { + u, _ := t.Underlying().(*Pointer) + return u +} + +// If typ is a type parameter, CoreType returns the single underlying +// type of all types in the corresponding type constraint if it exists, or +// nil otherwise. If the type set contains only unrestricted and restricted +// channel types (with identical element types), the single underlying type +// is the restricted channel type if the restrictions are always the same. +// If typ is not a type parameter, CoreType returns the underlying type. +func CoreType(t Type) Type { + u, _ := commonUnder(t, nil) + return u +} + +// RangeKeyVal returns the key and value types for a range over typ. +// It panics if range over typ is invalid. +func RangeKeyVal(typ Type) (Type, Type) { + key, val, _, ok := rangeKeyVal(nil, typ, nil) + assert(ok) + return key, val +} diff --git a/go/src/cmd/compile/internal/types2/const.go b/go/src/cmd/compile/internal/types2/const.go new file mode 100644 index 0000000000000000000000000000000000000000..b68d72de4d27f4ebfada127f1d3e227b097cd0c8 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/const.go @@ -0,0 +1,306 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements functions for untyped constant operands. + +package types2 + +import ( + "cmd/compile/internal/syntax" + "go/constant" + "go/token" + . "internal/types/errors" + "math" +) + +// overflow checks that the constant x is representable by its type. +// For untyped constants, it checks that the value doesn't become +// arbitrarily large. +func (check *Checker) overflow(x *operand, opPos syntax.Pos) { + assert(x.mode == constant_) + + if x.val.Kind() == constant.Unknown { + // TODO(gri) We should report exactly what went wrong. At the + // moment we don't have the (go/constant) API for that. + // See also TODO in go/constant/value.go. + check.error(atPos(opPos), InvalidConstVal, "constant result is not representable") + return + } + + // Typed constants must be representable in + // their type after each constant operation. + // x.typ cannot be a type parameter (type + // parameters cannot be constant types). + if isTyped(x.typ) { + check.representable(x, x.typ.Underlying().(*Basic)) + return + } + + // Untyped integer values must not grow arbitrarily. + const prec = 512 // 512 is the constant precision + if x.val.Kind() == constant.Int && constant.BitLen(x.val) > prec { + op := opName(x.expr) + if op != "" { + op += " " + } + check.errorf(atPos(opPos), InvalidConstVal, "constant %soverflow", op) + x.val = constant.MakeUnknown() + } +} + +// representableConst reports whether x can be represented as +// value of the given basic type and for the configuration +// provided (only needed for int/uint sizes). +// +// If rounded != nil, *rounded is set to the rounded value of x for +// representable floating-point and complex values, and to an Int +// value for integer values; it is left alone otherwise. +// It is ok to provide the addressof the first argument for rounded. +// +// The check parameter may be nil if representableConst is invoked +// (indirectly) through an exported API call (AssignableTo, ConvertibleTo) +// because we don't need the Checker's config for those calls. +func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *constant.Value) bool { + if x.Kind() == constant.Unknown { + return true // avoid follow-up errors + } + + var conf *Config + if check != nil { + conf = check.conf + } + + sizeof := func(T Type) int64 { + s := conf.sizeof(T) + return s + } + + switch { + case isInteger(typ): + x := constant.ToInt(x) + if x.Kind() != constant.Int { + return false + } + if rounded != nil { + *rounded = x + } + if x, ok := constant.Int64Val(x); ok { + switch typ.kind { + case Int: + var s = uint(sizeof(typ)) * 8 + return int64(-1)<<(s-1) <= x && x <= int64(1)<<(s-1)-1 + case Int8: + const s = 8 + return -1<<(s-1) <= x && x <= 1<<(s-1)-1 + case Int16: + const s = 16 + return -1<<(s-1) <= x && x <= 1<<(s-1)-1 + case Int32: + const s = 32 + return -1<<(s-1) <= x && x <= 1<<(s-1)-1 + case Int64, UntypedInt: + return true + case Uint, Uintptr: + if s := uint(sizeof(typ)) * 8; s < 64 { + return 0 <= x && x <= int64(1)<= 0 && n <= int(s) + case Uint64: + return constant.Sign(x) >= 0 && n <= 64 + case UntypedInt: + return true + } + + case isFloat(typ): + x := constant.ToFloat(x) + if x.Kind() != constant.Float { + return false + } + switch typ.kind { + case Float32: + if rounded == nil { + return fitsFloat32(x) + } + r := roundFloat32(x) + if r != nil { + *rounded = r + return true + } + case Float64: + if rounded == nil { + return fitsFloat64(x) + } + r := roundFloat64(x) + if r != nil { + *rounded = r + return true + } + case UntypedFloat: + return true + default: + panic("unreachable") + } + + case isComplex(typ): + x := constant.ToComplex(x) + if x.Kind() != constant.Complex { + return false + } + switch typ.kind { + case Complex64: + if rounded == nil { + return fitsFloat32(constant.Real(x)) && fitsFloat32(constant.Imag(x)) + } + re := roundFloat32(constant.Real(x)) + im := roundFloat32(constant.Imag(x)) + if re != nil && im != nil { + *rounded = constant.BinaryOp(re, token.ADD, constant.MakeImag(im)) + return true + } + case Complex128: + if rounded == nil { + return fitsFloat64(constant.Real(x)) && fitsFloat64(constant.Imag(x)) + } + re := roundFloat64(constant.Real(x)) + im := roundFloat64(constant.Imag(x)) + if re != nil && im != nil { + *rounded = constant.BinaryOp(re, token.ADD, constant.MakeImag(im)) + return true + } + case UntypedComplex: + return true + default: + panic("unreachable") + } + + case isString(typ): + return x.Kind() == constant.String + + case isBoolean(typ): + return x.Kind() == constant.Bool + } + + return false +} + +func fitsFloat32(x constant.Value) bool { + f32, _ := constant.Float32Val(x) + f := float64(f32) + return !math.IsInf(f, 0) +} + +func roundFloat32(x constant.Value) constant.Value { + f32, _ := constant.Float32Val(x) + f := float64(f32) + if !math.IsInf(f, 0) { + return constant.MakeFloat64(f) + } + return nil +} + +func fitsFloat64(x constant.Value) bool { + f, _ := constant.Float64Val(x) + return !math.IsInf(f, 0) +} + +func roundFloat64(x constant.Value) constant.Value { + f, _ := constant.Float64Val(x) + if !math.IsInf(f, 0) { + return constant.MakeFloat64(f) + } + return nil +} + +// representable checks that a constant operand is representable in the given +// basic type. +func (check *Checker) representable(x *operand, typ *Basic) { + v, code := check.representation(x, typ) + if code != 0 { + check.invalidConversion(code, x, typ) + x.mode = invalid + return + } + assert(v != nil) + x.val = v +} + +// representation returns the representation of the constant operand x as the +// basic type typ. +// +// If no such representation is possible, it returns a non-zero error code. +func (check *Checker) representation(x *operand, typ *Basic) (constant.Value, Code) { + assert(x.mode == constant_) + v := x.val + if !representableConst(x.val, check, typ, &v) { + if isNumeric(x.typ) && isNumeric(typ) { + // numeric conversion : error msg + // + // integer -> integer : overflows + // integer -> float : overflows (actually not possible) + // float -> integer : truncated + // float -> float : overflows + // + if !isInteger(x.typ) && isInteger(typ) { + return nil, TruncatedFloat + } else { + return nil, NumericOverflow + } + } + return nil, InvalidConstVal + } + return v, 0 +} + +func (check *Checker) invalidConversion(code Code, x *operand, target Type) { + msg := "cannot convert %s to type %s" + switch code { + case TruncatedFloat: + msg = "%s truncated to %s" + case NumericOverflow: + msg = "%s overflows %s" + } + check.errorf(x, code, msg, x, target) +} + +// convertUntyped attempts to set the type of an untyped value to the target type. +func (check *Checker) convertUntyped(x *operand, target Type) { + newType, val, code := check.implicitTypeAndValue(x, target) + if code != 0 { + t := target + if !isTypeParam(target) { + t = safeUnderlying(target) + } + check.invalidConversion(code, x, t) + x.mode = invalid + return + } + if val != nil { + x.val = val + check.updateExprVal(x.expr, val) + } + if newType != x.typ { + x.typ = newType + check.updateExprType(x.expr, newType, false) + } +} diff --git a/go/src/cmd/compile/internal/types2/context.go b/go/src/cmd/compile/internal/types2/context.go new file mode 100644 index 0000000000000000000000000000000000000000..23efd065867021c3c131054c001044938a83d727 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/context.go @@ -0,0 +1,144 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2 + +import ( + "bytes" + "fmt" + "strconv" + "strings" + "sync" +) + +// This file contains a definition of the type-checking context; an opaque type +// that may be supplied by users during instantiation. +// +// Contexts serve two purposes: +// - reduce the duplication of identical instances +// - short-circuit instantiation cycles +// +// For the latter purpose, we must always have a context during instantiation, +// whether or not it is supplied by the user. For both purposes, it must be the +// case that hashing a pointer-identical type produces consistent results +// (somewhat obviously). +// +// However, neither of these purposes require that our hash is perfect, and so +// this was not an explicit design goal of the context type. In fact, due to +// concurrent use it is convenient not to guarantee de-duplication. +// +// Nevertheless, in the future it could be helpful to allow users to leverage +// contexts to canonicalize instances, and it would probably be possible to +// achieve such a guarantee. + +// A Context is an opaque type checking context. It may be used to share +// identical type instances across type-checked packages or calls to +// Instantiate. Contexts are safe for concurrent use. +// +// The use of a shared context does not guarantee that identical instances are +// deduplicated in all cases. +type Context struct { + mu sync.Mutex + typeMap map[string][]ctxtEntry // type hash -> instances entries + nextID int // next unique ID + originIDs map[Type]int // origin type -> unique ID +} + +type ctxtEntry struct { + orig Type + targs []Type + instance Type // = orig[targs] +} + +// NewContext creates a new Context. +func NewContext() *Context { + return &Context{ + typeMap: make(map[string][]ctxtEntry), + originIDs: make(map[Type]int), + } +} + +// instanceHash returns a string representation of typ instantiated with targs. +// The hash should be a perfect hash, though out of caution the type checker +// does not assume this. The result is guaranteed to not contain blanks. +func (ctxt *Context) instanceHash(orig Type, targs []Type) string { + assert(ctxt != nil) + assert(orig != nil) + var buf bytes.Buffer + + h := newTypeHasher(&buf, ctxt) + h.string(strconv.Itoa(ctxt.getID(orig))) + // Because we've already written the unique origin ID this call to h.typ is + // unnecessary, but we leave it for hash readability. It can be removed later + // if performance is an issue. + h.typ(orig) + if len(targs) > 0 { + // TODO(rfindley): consider asserting on isGeneric(typ) here, if and when + // isGeneric handles *Signature types. + h.typeList(targs) + } + + return strings.ReplaceAll(buf.String(), " ", "#") +} + +// lookup returns an existing instantiation of orig with targs, if it exists. +// Otherwise, it returns nil. +func (ctxt *Context) lookup(h string, orig Type, targs []Type) Type { + ctxt.mu.Lock() + defer ctxt.mu.Unlock() + + for _, e := range ctxt.typeMap[h] { + if identicalInstance(orig, targs, e.orig, e.targs) { + return e.instance + } + if debug { + // Panic during development to surface any imperfections in our hash. + panic(fmt.Sprintf("non-identical instances: (orig: %s, targs: %v) and %s", orig, targs, e.instance)) + } + } + + return nil +} + +// update de-duplicates inst against previously seen types with the hash h. +// If an identical type is found with the type hash h, the previously seen +// type is returned. Otherwise, inst is returned, and recorded in the Context +// for the hash h. +func (ctxt *Context) update(h string, orig Type, targs []Type, inst Type) Type { + assert(inst != nil) + + ctxt.mu.Lock() + defer ctxt.mu.Unlock() + + for _, e := range ctxt.typeMap[h] { + if inst == nil || Identical(inst, e.instance) { + return e.instance + } + if debug { + // Panic during development to surface any imperfections in our hash. + panic(fmt.Sprintf("%s and %s are not identical", inst, e.instance)) + } + } + + ctxt.typeMap[h] = append(ctxt.typeMap[h], ctxtEntry{ + orig: orig, + targs: targs, + instance: inst, + }) + + return inst +} + +// getID returns a unique ID for the type t. +func (ctxt *Context) getID(t Type) int { + ctxt.mu.Lock() + defer ctxt.mu.Unlock() + id, ok := ctxt.originIDs[t] + if !ok { + id = ctxt.nextID + ctxt.originIDs[t] = id + ctxt.nextID++ + } + return id +} diff --git a/go/src/cmd/compile/internal/types2/context_test.go b/go/src/cmd/compile/internal/types2/context_test.go new file mode 100644 index 0000000000000000000000000000000000000000..2c5c0d8ef3424ad6a3311f2d3fca2232b410db7b --- /dev/null +++ b/go/src/cmd/compile/internal/types2/context_test.go @@ -0,0 +1,69 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2 + +import ( + "testing" +) + +func TestContextHashCollisions(t *testing.T) { + if debug { + t.Skip("hash collisions are expected, and would fail debug assertions") + } + // Unit test the de-duplication fall-back logic in Context. + // + // We can't test this via Instantiate because this is only a fall-back in + // case our hash is imperfect. + // + // These lookups and updates use reasonable looking types in an attempt to + // make them robust to internal type assertions, but could equally well use + // arbitrary types. + + // Create some distinct origin types. nullaryP and nullaryQ have no + // parameters and are identical (but have different type parameter names). + // unaryP has a parameter. + var nullaryP, nullaryQ, unaryP Type + { + // type nullaryP = func[P any]() + tparam := NewTypeParam(NewTypeName(nopos, nil, "P", nil), &emptyInterface) + nullaryP = NewSignatureType(nil, nil, []*TypeParam{tparam}, nil, nil, false) + } + { + // type nullaryQ = func[Q any]() + tparam := NewTypeParam(NewTypeName(nopos, nil, "Q", nil), &emptyInterface) + nullaryQ = NewSignatureType(nil, nil, []*TypeParam{tparam}, nil, nil, false) + } + { + // type unaryP = func[P any](_ P) + tparam := NewTypeParam(NewTypeName(nopos, nil, "P", nil), &emptyInterface) + params := NewTuple(NewParam(nopos, nil, "_", tparam)) + unaryP = NewSignatureType(nil, nil, []*TypeParam{tparam}, params, nil, false) + } + + ctxt := NewContext() + + // Update the context with an instantiation of nullaryP. + inst := NewSignatureType(nil, nil, nil, nil, nil, false) + if got := ctxt.update("", nullaryP, []Type{Typ[Int]}, inst); got != inst { + t.Error("bad") + } + + // unaryP is not identical to nullaryP, so we should not get inst when + // instantiated with identical type arguments. + if got := ctxt.lookup("", unaryP, []Type{Typ[Int]}); got != nil { + t.Error("bad") + } + + // nullaryQ is identical to nullaryP, so we *should* get inst when + // instantiated with identical type arguments. + if got := ctxt.lookup("", nullaryQ, []Type{Typ[Int]}); got != inst { + t.Error("bad") + } + + // ...but verify we don't get inst with different type arguments. + if got := ctxt.lookup("", nullaryQ, []Type{Typ[String]}); got != nil { + t.Error("bad") + } +} diff --git a/go/src/cmd/compile/internal/types2/conversions.go b/go/src/cmd/compile/internal/types2/conversions.go new file mode 100644 index 0000000000000000000000000000000000000000..d0920d7ef1006d75a8f0110c7b4b4ddd31c2bc95 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/conversions.go @@ -0,0 +1,315 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements typechecking of conversions. + +package types2 + +import ( + "go/constant" + . "internal/types/errors" + "unicode" +) + +// conversion type-checks the conversion T(x). +// The result is in x. +func (check *Checker) conversion(x *operand, T Type) { + constArg := x.mode == constant_ + + constConvertibleTo := func(T Type, val *constant.Value) bool { + switch t, _ := T.Underlying().(*Basic); { + case t == nil: + // nothing to do + case representableConst(x.val, check, t, val): + return true + case isInteger(x.typ) && isString(t): + codepoint := unicode.ReplacementChar + if i, ok := constant.Uint64Val(x.val); ok && i <= unicode.MaxRune { + codepoint = rune(i) + } + if val != nil { + *val = constant.MakeString(string(codepoint)) + } + return true + } + return false + } + + var ok bool + var cause string + switch { + case constArg && isConstType(T): + // constant conversion + ok = constConvertibleTo(T, &x.val) + // A conversion from an integer constant to an integer type + // can only fail if there's overflow. Give a concise error. + // (go.dev/issue/63563) + if !ok && isInteger(x.typ) && isInteger(T) { + check.errorf(x, InvalidConversion, "constant %s overflows %s", x.val, T) + x.mode = invalid + return + } + case constArg && isTypeParam(T): + // x is convertible to T if it is convertible + // to each specific type in the type set of T. + // If T's type set is empty, or if it doesn't + // have specific types, constant x cannot be + // converted. + ok = underIs(T, func(u Type) bool { + // u is nil if there are no specific type terms + if u == nil { + cause = check.sprintf("%s does not contain specific types", T) + return false + } + if isString(x.typ) && isBytesOrRunes(u) { + return true + } + if !constConvertibleTo(u, nil) { + if isInteger(x.typ) && isInteger(u) { + // see comment above on constant conversion + cause = check.sprintf("constant %s overflows %s (in %s)", x.val, u, T) + } else { + cause = check.sprintf("cannot convert %s to type %s (in %s)", x, u, T) + } + return false + } + return true + }) + x.mode = value // type parameters are not constants + case x.convertibleTo(check, T, &cause): + // non-constant conversion + ok = true + x.mode = value + } + + if !ok { + if cause != "" { + check.errorf(x, InvalidConversion, "cannot convert %s to type %s: %s", x, T, cause) + } else { + check.errorf(x, InvalidConversion, "cannot convert %s to type %s", x, T) + } + x.mode = invalid + return + } + + // The conversion argument types are final. For untyped values the + // conversion provides the type, per the spec: "A constant may be + // given a type explicitly by a constant declaration or conversion,...". + if isUntyped(x.typ) { + final := T + // - For conversions to interfaces, except for untyped nil arguments + // and isTypes2, use the argument's default type. + // - For conversions of untyped constants to non-constant types, also + // use the default type (e.g., []byte("foo") should report string + // not []byte as type for the constant "foo"). + // - If !isTypes2, keep untyped nil for untyped nil arguments. + // - For constant integer to string conversions, keep the argument type. + // (See also the TODO below.) + if isTypes2 && x.typ == Typ[UntypedNil] { + // ok + } else if isNonTypeParamInterface(T) || constArg && !isConstType(T) || !isTypes2 && x.isNil() { + final = Default(x.typ) // default type of untyped nil is untyped nil + } else if x.mode == constant_ && isInteger(x.typ) && allString(T) { + final = x.typ + } + check.updateExprType(x.expr, final, true) + } + + x.typ = T +} + +// TODO(gri) convertibleTo checks if T(x) is valid. It assumes that the type +// of x is fully known, but that's not the case for say string(1<= 0 : tname has been seen but is not done (grey); the value is the path index +// - value is < 0 : tname has been seen and is done (black) +// +// When directCycle returns, the pathIdx entries for all type names on the path +// that starts at tname are marked black, regardless of whether there was a cycle. +// This ensures that a type name is traversed only once. +func (check *Checker) directCycle(tname *TypeName, pathIdx map[*TypeName]int) { + if debug && check.conf.Trace { + check.trace(tname.Pos(), "-- check direct cycle for %s", tname) + } + + var path []*TypeName + for { + start, found := pathIdx[tname] + if start < 0 { + // tname is marked black - do not traverse it again. + // (start can only be < 0 if it was found in the first place) + break + } + + if found { + // tname is marked grey - we have a cycle on the path beginning at start. + // Mark tname as invalid. + tname.setType(Typ[Invalid]) + + // collect type names on cycle + var cycle []Object + for _, tname := range path[start:] { + cycle = append(cycle, tname) + } + + check.cycleError(cycle, firstInSrc(cycle)) + break + } + + // tname is marked white - mark it grey and add it to the path. + pathIdx[tname] = len(path) + path = append(path, tname) + + // For direct cycle detection, we don't care about whether we have an alias or not. + // If the associated type is not a name, we're at the end of the path and we're done. + rhs, ok := check.objMap[tname].tdecl.Type.(*syntax.Name) + if !ok { + break + } + + // Determine the RHS type. If it is not found in the package scope, we either + // have an error (which will be reported later), or the type exists elsewhere + // (universe scope, file scope via dot-import) and a cycle is not possible in + // the first place. If it is not a type name, we cannot have a direct cycle + // either. In all these cases we can stop. + tname1, ok := check.pkg.scope.Lookup(rhs.Value).(*TypeName) + if !ok { + break + } + + // Otherwise, continue with the RHS. + tname = tname1 + } + + // Mark all traversed type names black. + // (ensure that pathIdx doesn't contain any grey entries upon returning) + for _, tname := range path { + pathIdx[tname] = -1 + } + + if debug { + for _, i := range pathIdx { + assert(i < 0) + } + } +} + +// TODO(markfreeman): Can the value cached on Named be used in validType / hasVarSize? + +// finiteSize returns whether a type has finite size. +func (check *Checker) finiteSize(t Type) bool { + switch t := Unalias(t).(type) { + case *Named: + if t.stateHas(hasFinite) { + return t.finite + } + + if i, ok := check.objPathIdx[t.obj]; ok { + cycle := check.objPath[i:] + check.cycleError(cycle, firstInSrc(cycle)) + return false + } + check.push(t.obj) + defer check.pop() + + isFinite := check.finiteSize(t.fromRHS) + + t.mu.Lock() + defer t.mu.Unlock() + // Careful, t.finite has lock-free readers. Since we might be racing + // another call to finiteSize, we have to avoid overwriting t.finite. + // Otherwise, the race detector will be tripped. + if !t.stateHas(hasFinite) { + t.finite = isFinite + t.setState(hasFinite) + } + + return isFinite + + case *Array: + // The array length is already computed. If it was a valid length, it + // is finite; else, an error was reported in the computation. + return check.finiteSize(t.elem) + + case *Struct: + for _, f := range t.fields { + if !check.finiteSize(f.typ) { + return false + } + } + } + + return true +} diff --git a/go/src/cmd/compile/internal/types2/decl.go b/go/src/cmd/compile/internal/types2/decl.go new file mode 100644 index 0000000000000000000000000000000000000000..25152545ece07232a607bde7e69405f954ae8351 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/decl.go @@ -0,0 +1,885 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2 + +import ( + "cmd/compile/internal/syntax" + "fmt" + "go/constant" + . "internal/types/errors" + "slices" +) + +func (check *Checker) declare(scope *Scope, id *syntax.Name, obj Object, pos syntax.Pos) { + // spec: "The blank identifier, represented by the underscore + // character _, may be used in a declaration like any other + // identifier but the declaration does not introduce a new + // binding." + if obj.Name() != "_" { + if alt := scope.Insert(obj); alt != nil { + err := check.newError(DuplicateDecl) + err.addf(obj, "%s redeclared in this block", obj.Name()) + err.addAltDecl(alt) + err.report() + return + } + obj.setScopePos(pos) + } + if id != nil { + check.recordDef(id, obj) + } +} + +// pathString returns a string of the form a->b-> ... ->g for a path [a, b, ... g]. +func pathString(path []Object) string { + var s string + for i, p := range path { + if i > 0 { + s += "->" + } + s += p.Name() + } + return s +} + +// objDecl type-checks the declaration of obj in its respective (file) environment. +func (check *Checker) objDecl(obj Object) { + if tracePos { + check.pushPos(obj.Pos()) + defer func() { + // If we're panicking, keep stack of source positions. + if p := recover(); p != nil { + panic(p) + } + check.popPos() + }() + } + + if check.conf.Trace && obj.Type() == nil { + if check.indent == 0 { + fmt.Println() // empty line between top-level objects for readability + } + check.trace(obj.Pos(), "-- checking %s (objPath = %s)", obj, pathString(check.objPath)) + check.indent++ + defer func() { + check.indent-- + check.trace(obj.Pos(), "=> %s", obj) + }() + } + + // Checking the declaration of an object means determining its type + // (and also its value for constants). An object (and thus its type) + // may be in 1 of 3 states: + // + // - not in Checker.objPathIdx and type == nil : type is not yet known (white) + // - in Checker.objPathIdx : type is pending (grey) + // - not in Checker.objPathIdx and type != nil : type is known (black) + // + // During type-checking, an object changes from white to grey to black. + // Predeclared objects start as black (their type is known without checking). + // + // A black object may only depend on (refer to) to other black objects. White + // and grey objects may depend on white or black objects. A dependency on a + // grey object indicates a (possibly invalid) cycle. + // + // When an object is marked grey, it is pushed onto the object path (a stack) + // and its index in the path is recorded in the path index map. It is popped + // and removed from the map when its type is determined (and marked black). + + // If this object is grey, we have a (possibly invalid) cycle. This is signaled + // by a non-nil type for the object, except for constants and variables whose + // type may be non-nil (known), or nil if it depends on a not-yet known + // initialization value. + // + // In the former case, set the type to Typ[Invalid] because we have an + // initialization cycle. The cycle error will be reported later, when + // determining initialization order. + // + // TODO(gri) Report cycle here and simplify initialization order code. + if _, ok := check.objPathIdx[obj]; ok { + switch obj := obj.(type) { + case *Const, *Var: + if !check.validCycle(obj) || obj.Type() == nil { + obj.setType(Typ[Invalid]) + } + case *TypeName: + if !check.validCycle(obj) { + obj.setType(Typ[Invalid]) + } + case *Func: + if !check.validCycle(obj) { + // Don't set type to Typ[Invalid]; plenty of code asserts that + // functions have a *Signature type. Instead, leave the type + // as an empty signature, which makes it impossible to + // initialize a variable with the function. + } + default: + panic("unreachable") + } + + assert(obj.Type() != nil) + return + } + + if obj.Type() != nil { // black, meaning it's already type-checked + return + } + + // white, meaning it must be type-checked + + check.push(obj) + defer check.pop() + + d, ok := check.objMap[obj] + assert(ok) + + // save/restore current environment and set up object environment + defer func(env environment) { + check.environment = env + }(check.environment) + check.environment = environment{scope: d.file, version: d.version} + + // Const and var declarations must not have initialization + // cycles. We track them by remembering the current declaration + // in check.decl. Initialization expressions depending on other + // consts, vars, or functions, add dependencies to the current + // check.decl. + switch obj := obj.(type) { + case *Const: + check.decl = d // new package-level const decl + check.constDecl(obj, d.vtyp, d.init, d.inherited) + case *Var: + check.decl = d // new package-level var decl + check.varDecl(obj, d.lhs, d.vtyp, d.init) + case *TypeName: + // invalid recursive types are detected via path + check.typeDecl(obj, d.tdecl) + check.collectMethods(obj) // methods can only be added to top-level types + case *Func: + // functions may be recursive - no need to track dependencies + check.funcDecl(obj, d) + default: + panic("unreachable") + } +} + +// validCycle reports whether the cycle starting with obj is valid and +// reports an error if it is not. +func (check *Checker) validCycle(obj Object) (valid bool) { + // The object map contains the package scope objects and the non-interface methods. + if debug { + info := check.objMap[obj] + inObjMap := info != nil && (info.fdecl == nil || info.fdecl.Recv == nil) // exclude methods + isPkgObj := obj.Parent() == check.pkg.scope + if isPkgObj != inObjMap { + check.dump("%v: inconsistent object map for %s (isPkgObj = %v, inObjMap = %v)", obj.Pos(), obj, isPkgObj, inObjMap) + panic("unreachable") + } + } + + // Count cycle objects. + start, found := check.objPathIdx[obj] + assert(found) + cycle := check.objPath[start:] + tparCycle := false // if set, the cycle is through a type parameter list + nval := 0 // number of (constant or variable) values in the cycle + ndef := 0 // number of type definitions in the cycle +loop: + for _, obj := range cycle { + switch obj := obj.(type) { + case *Const, *Var: + nval++ + case *TypeName: + // If we reach a generic type that is part of a cycle + // and we are in a type parameter list, we have a cycle + // through a type parameter list. + if check.inTParamList && isGeneric(obj.typ) { + tparCycle = true + break loop + } + + // Determine if the type name is an alias or not. For + // package-level objects, use the object map which + // provides syntactic information (which doesn't rely + // on the order in which the objects are set up). For + // local objects, we can rely on the order, so use + // the object's predicate. + // TODO(gri) It would be less fragile to always access + // the syntactic information. We should consider storing + // this information explicitly in the object. + var alias bool + if check.conf.EnableAlias { + alias = obj.IsAlias() + } else { + if d := check.objMap[obj]; d != nil { + alias = d.tdecl.Alias // package-level object + } else { + alias = obj.IsAlias() // function local object + } + } + if !alias { + ndef++ + } + case *Func: + // ignored for now + default: + panic("unreachable") + } + } + + if check.conf.Trace { + check.trace(obj.Pos(), "## cycle detected: objPath = %s->%s (len = %d)", pathString(cycle), obj.Name(), len(cycle)) + if tparCycle { + check.trace(obj.Pos(), "## cycle contains: generic type in a type parameter list") + } else { + check.trace(obj.Pos(), "## cycle contains: %d values, %d type definitions", nval, ndef) + } + defer func() { + if valid { + check.trace(obj.Pos(), "=> cycle is valid") + } else { + check.trace(obj.Pos(), "=> error: cycle is invalid") + } + }() + } + + // Cycles through type parameter lists are ok (go.dev/issue/68162). + if tparCycle { + return true + } + + // A cycle involving only constants and variables is invalid but we + // ignore them here because they are reported via the initialization + // cycle check. + if nval == len(cycle) { + return true + } + + // A cycle involving only types (and possibly functions) must have at least + // one type definition to be permitted: If there is no type definition, we + // have a sequence of alias type names which will expand ad infinitum. + if nval == 0 && ndef > 0 { + return true + } + + check.cycleError(cycle, firstInSrc(cycle)) + return false +} + +// cycleError reports a declaration cycle starting with the object at cycle[start]. +func (check *Checker) cycleError(cycle []Object, start int) { + // name returns the (possibly qualified) object name. + // This is needed because with generic types, cycles + // may refer to imported types. See go.dev/issue/50788. + // TODO(gri) This functionality is used elsewhere. Factor it out. + name := func(obj Object) string { + return packagePrefix(obj.Pkg(), check.qualifier) + obj.Name() + } + + // If obj is a type alias, mark it as valid (not broken) in order to avoid follow-on errors. + obj := cycle[start] + tname, _ := obj.(*TypeName) + if tname != nil { + if check.conf.EnableAlias { + if a, ok := tname.Type().(*Alias); ok { + a.fromRHS = Typ[Invalid] + } + } else { + if tname.IsAlias() { + check.validAlias(tname, Typ[Invalid]) + } + } + } + + // report a more concise error for self references + if len(cycle) == 1 { + if tname != nil { + check.errorf(obj, InvalidDeclCycle, "invalid recursive type: %s refers to itself", name(obj)) + } else { + check.errorf(obj, InvalidDeclCycle, "invalid cycle in declaration: %s refers to itself", name(obj)) + } + return + } + + err := check.newError(InvalidDeclCycle) + if tname != nil { + err.addf(obj, "invalid recursive type %s", name(obj)) + } else { + err.addf(obj, "invalid cycle in declaration of %s", name(obj)) + } + // "cycle[i] refers to cycle[j]" for (i,j) = (s,s+1), (s+1,s+2), ..., (n-1,0), (0,1), ..., (s-1,s) for len(cycle) = n, s = start. + for i := range cycle { + next := cycle[(start+i+1)%len(cycle)] + err.addf(obj, "%s refers to %s", name(obj), name(next)) + obj = next + } + err.report() +} + +// firstInSrc reports the index of the object with the "smallest" +// source position in path. path must not be empty. +func firstInSrc(path []Object) int { + fst, pos := 0, path[0].Pos() + for i, t := range path[1:] { + if cmpPos(t.Pos(), pos) < 0 { + fst, pos = i+1, t.Pos() + } + } + return fst +} + +func (check *Checker) constDecl(obj *Const, typ, init syntax.Expr, inherited bool) { + assert(obj.typ == nil) + + // use the correct value of iota and errpos + defer func(iota constant.Value, errpos syntax.Pos) { + check.iota = iota + check.errpos = errpos + }(check.iota, check.errpos) + check.iota = obj.val + check.errpos = nopos + + // provide valid constant value under all circumstances + obj.val = constant.MakeUnknown() + + // determine type, if any + if typ != nil { + t := check.typ(typ) + if !isConstType(t) { + // don't report an error if the type is an invalid C (defined) type + // (go.dev/issue/22090) + if isValid(t.Underlying()) { + check.errorf(typ, InvalidConstType, "invalid constant type %s", t) + } + obj.typ = Typ[Invalid] + return + } + obj.typ = t + } + + // check initialization + var x operand + if init != nil { + if inherited { + // The initialization expression is inherited from a previous + // constant declaration, and (error) positions refer to that + // expression and not the current constant declaration. Use + // the constant identifier position for any errors during + // init expression evaluation since that is all we have + // (see issues go.dev/issue/42991, go.dev/issue/42992). + check.errpos = obj.pos + } + check.expr(nil, &x, init) + } + check.initConst(obj, &x) +} + +func (check *Checker) varDecl(obj *Var, lhs []*Var, typ, init syntax.Expr) { + assert(obj.typ == nil) + + // determine type, if any + if typ != nil { + obj.typ = check.varType(typ) + // We cannot spread the type to all lhs variables if there + // are more than one since that would mark them as checked + // (see Checker.objDecl) and the assignment of init exprs, + // if any, would not be checked. + // + // TODO(gri) If we have no init expr, we should distribute + // a given type otherwise we need to re-evaluate the type + // expr for each lhs variable, leading to duplicate work. + } + + // check initialization + if init == nil { + if typ == nil { + // error reported before by arityMatch + obj.typ = Typ[Invalid] + } + return + } + + if lhs == nil || len(lhs) == 1 { + assert(lhs == nil || lhs[0] == obj) + var x operand + check.expr(newTarget(obj.typ, obj.name), &x, init) + check.initVar(obj, &x, "variable declaration") + return + } + + if debug { + // obj must be one of lhs + if !slices.Contains(lhs, obj) { + panic("inconsistent lhs") + } + } + + // We have multiple variables on the lhs and one init expr. + // Make sure all variables have been given the same type if + // one was specified, otherwise they assume the type of the + // init expression values (was go.dev/issue/15755). + if typ != nil { + for _, lhs := range lhs { + lhs.typ = obj.typ + } + } + + check.initVars(lhs, []syntax.Expr{init}, nil) +} + +// isImportedConstraint reports whether typ is an imported type constraint. +func (check *Checker) isImportedConstraint(typ Type) bool { + named := asNamed(typ) + if named == nil || named.obj.pkg == check.pkg || named.obj.pkg == nil { + return false + } + u, _ := named.Underlying().(*Interface) + return u != nil && !u.IsMethodSet() +} + +func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl) { + assert(obj.typ == nil) + + // Only report a version error if we have not reported one already. + versionErr := false + + var rhs Type + check.later(func() { + if t := asNamed(obj.typ); t != nil { // type may be invalid + check.validType(t) + } + // If typ is local, an error was already reported where typ is specified/defined. + _ = !versionErr && check.isImportedConstraint(rhs) && check.verifyVersionf(tdecl.Type, go1_18, "using type constraint %s", rhs) + }).describef(obj, "validType(%s)", obj.Name()) + + // First type parameter, or nil. + var tparam0 *syntax.Field + if len(tdecl.TParamList) > 0 { + tparam0 = tdecl.TParamList[0] + } + + // alias declaration + if tdecl.Alias { + // Report highest version requirement first so that fixing a version issue + // avoids possibly two -lang changes (first to Go 1.9 and then to Go 1.23). + if !versionErr && tparam0 != nil && !check.verifyVersionf(tparam0, go1_23, "generic type alias") { + versionErr = true + } + if !versionErr && !check.verifyVersionf(tdecl, go1_9, "type alias") { + versionErr = true + } + + if check.conf.EnableAlias { + alias := check.newAlias(obj, nil) + + // If we could not type the RHS, set it to invalid. This should + // only ever happen if we panic before setting. + defer func() { + if alias.fromRHS == nil { + alias.fromRHS = Typ[Invalid] + unalias(alias) + } + }() + + // handle type parameters even if not allowed (Alias type is supported) + if tparam0 != nil { + check.openScope(tdecl, "type parameters") + defer check.closeScope() + check.collectTypeParams(&alias.tparams, tdecl.TParamList) + } + + rhs = check.declaredType(tdecl.Type, obj) + assert(rhs != nil) + alias.fromRHS = rhs + + // spec: In an alias declaration the given type cannot be a type parameter declared in the same declaration." + // (see also go.dev/issue/75884, go.dev/issue/#75885) + if tpar, ok := rhs.(*TypeParam); ok && alias.tparams != nil && slices.Index(alias.tparams.list(), tpar) >= 0 { + check.error(tdecl.Type, MisplacedTypeParam, "cannot use type parameter declared in alias declaration as RHS") + alias.fromRHS = Typ[Invalid] + } + } else { + if !versionErr && tparam0 != nil { + check.error(tdecl, UnsupportedFeature, "generic type alias requires GODEBUG=gotypesalias=1 or unset") + versionErr = true + } + + check.brokenAlias(obj) + rhs = check.typ(tdecl.Type) + check.validAlias(obj, rhs) + } + return + } + + // type definition or generic type declaration + if !versionErr && tparam0 != nil && !check.verifyVersionf(tparam0, go1_18, "type parameter") { + versionErr = true + } + + named := check.newNamed(obj, nil, nil) + + // The RHS of a named N can be nil if, for example, N is defined as a cycle of aliases with + // gotypesalias=0. Consider: + // + // type D N // N.unpack() will panic + // type N A + // type A = N // N.fromRHS is not set before N.unpack(), since A does not call setDefType + // + // There is likely a better way to detect such cases, but it may not be worth the effort. + // Instead, we briefly permit a nil N.fromRHS while type-checking D. + named.allowNilRHS = true + defer (func() { named.allowNilRHS = false })() + + if tdecl.TParamList != nil { + check.openScope(tdecl, "type parameters") + defer check.closeScope() + check.collectTypeParams(&named.tparams, tdecl.TParamList) + } + + rhs = check.declaredType(tdecl.Type, obj) + assert(rhs != nil) + named.fromRHS = rhs + + // spec: "In a type definition the given type cannot be a type parameter." + // (See also go.dev/issue/45639.) + if isTypeParam(rhs) { + check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration") + named.fromRHS = Typ[Invalid] + } +} + +func (check *Checker) collectTypeParams(dst **TypeParamList, list []*syntax.Field) { + tparams := make([]*TypeParam, len(list)) + + // Declare type parameters up-front. + // The scope of type parameters starts at the beginning of the type parameter + // list (so we can have mutually recursive parameterized type bounds). + if len(list) > 0 { + scopePos := list[0].Pos() + for i, f := range list { + tparams[i] = check.declareTypeParam(f.Name, scopePos) + } + } + + // Set the type parameters before collecting the type constraints because + // the parameterized type may be used by the constraints (go.dev/issue/47887). + // Example: type T[P T[P]] interface{} + *dst = bindTParams(tparams) + + // Signal to cycle detection that we are in a type parameter list. + // We can only be inside one type parameter list at any given time: + // function closures may appear inside a type parameter list but they + // cannot be generic, and their bodies are processed in delayed and + // sequential fashion. Note that with each new declaration, we save + // the existing environment and restore it when done; thus inTParamList + // is true exactly only when we are in a specific type parameter list. + assert(!check.inTParamList) + check.inTParamList = true + defer func() { + check.inTParamList = false + }() + + // Keep track of bounds for later validation. + var bound Type + for i, f := range list { + // Optimization: Re-use the previous type bound if it hasn't changed. + // This also preserves the grouped output of type parameter lists + // when printing type strings. + if i == 0 || f.Type != list[i-1].Type { + bound = check.bound(f.Type) + if isTypeParam(bound) { + // We may be able to allow this since it is now well-defined what + // the underlying type and thus type set of a type parameter is. + // But we may need some additional form of cycle detection within + // type parameter lists. + check.error(f.Type, MisplacedTypeParam, "cannot use a type parameter as constraint") + bound = Typ[Invalid] + } + } + tparams[i].bound = bound + } +} + +func (check *Checker) bound(x syntax.Expr) Type { + // A type set literal of the form ~T and A|B may only appear as constraint; + // embed it in an implicit interface so that only interface type-checking + // needs to take care of such type expressions. + if op, _ := x.(*syntax.Operation); op != nil && (op.Op == syntax.Tilde || op.Op == syntax.Or) { + t := check.typ(&syntax.InterfaceType{MethodList: []*syntax.Field{{Type: x}}}) + // mark t as implicit interface if all went well + if t, _ := t.(*Interface); t != nil { + t.implicit = true + } + return t + } + return check.typ(x) +} + +func (check *Checker) declareTypeParam(name *syntax.Name, scopePos syntax.Pos) *TypeParam { + // Use Typ[Invalid] for the type constraint to ensure that a type + // is present even if the actual constraint has not been assigned + // yet. + // TODO(gri) Need to systematically review all uses of type parameter + // constraints to make sure we don't rely on them if they + // are not properly set yet. + tname := NewTypeName(name.Pos(), check.pkg, name.Value, nil) + tpar := check.newTypeParam(tname, Typ[Invalid]) // assigns type to tname as a side-effect + check.declare(check.scope, name, tname, scopePos) + return tpar +} + +func (check *Checker) collectMethods(obj *TypeName) { + // get associated methods + // (Checker.collectObjects only collects methods with non-blank names; + // Checker.resolveBaseTypeName ensures that obj is not an alias name + // if it has attached methods.) + methods := check.methods[obj] + if methods == nil { + return + } + delete(check.methods, obj) + assert(!check.objMap[obj].tdecl.Alias) // don't use TypeName.IsAlias (requires fully set up object) + + // use an objset to check for name conflicts + var mset objset + + // spec: "If the base type is a struct type, the non-blank method + // and field names must be distinct." + base := asNamed(obj.typ) // shouldn't fail but be conservative + if base != nil { + assert(base.TypeArgs().Len() == 0) // collectMethods should not be called on an instantiated type + + // See go.dev/issue/52529: we must delay the expansion of underlying here, as + // base may not be fully set-up. + check.later(func() { + check.checkFieldUniqueness(base) + }).describef(obj, "verifying field uniqueness for %v", base) + + // Checker.Files may be called multiple times; additional package files + // may add methods to already type-checked types. Add pre-existing methods + // so that we can detect redeclarations. + for i := 0; i < base.NumMethods(); i++ { + m := base.Method(i) + assert(m.name != "_") + assert(mset.insert(m) == nil) + } + } + + // add valid methods + for _, m := range methods { + // spec: "For a base type, the non-blank names of methods bound + // to it must be unique." + assert(m.name != "_") + if alt := mset.insert(m); alt != nil { + if alt.Pos().IsKnown() { + check.errorf(m.pos, DuplicateMethod, "method %s.%s already declared at %v", obj.Name(), m.name, alt.Pos()) + } else { + check.errorf(m.pos, DuplicateMethod, "method %s.%s already declared", obj.Name(), m.name) + } + continue + } + + if base != nil { + base.AddMethod(m) + } + } +} + +func (check *Checker) checkFieldUniqueness(base *Named) { + if t, _ := base.Underlying().(*Struct); t != nil { + var mset objset + for i := 0; i < base.NumMethods(); i++ { + m := base.Method(i) + assert(m.name != "_") + assert(mset.insert(m) == nil) + } + + // Check that any non-blank field names of base are distinct from its + // method names. + for _, fld := range t.fields { + if fld.name != "_" { + if alt := mset.insert(fld); alt != nil { + // Struct fields should already be unique, so we should only + // encounter an alternate via collision with a method name. + _ = alt.(*Func) + + // For historical consistency, we report the primary error on the + // method, and the alt decl on the field. + err := check.newError(DuplicateFieldAndMethod) + err.addf(alt, "field and method with the same name %s", fld.name) + err.addAltDecl(fld) + err.report() + } + } + } + } +} + +func (check *Checker) funcDecl(obj *Func, decl *declInfo) { + assert(obj.typ == nil) + + // func declarations cannot use iota + assert(check.iota == nil) + + sig := new(Signature) + obj.typ = sig // guard against cycles + + fdecl := decl.fdecl + check.funcType(sig, fdecl.Recv, fdecl.TParamList, fdecl.Type) + + // Set the scope's extent to the complete "func (...) { ... }" + // so that Scope.Innermost works correctly. + sig.scope.pos = fdecl.Pos() + sig.scope.end = syntax.EndPos(fdecl) + + if len(fdecl.TParamList) > 0 && fdecl.Body == nil { + check.softErrorf(fdecl, BadDecl, "generic function is missing function body") + } + + // function body must be type-checked after global declarations + // (functions implemented elsewhere have no body) + if !check.conf.IgnoreFuncBodies && fdecl.Body != nil { + check.later(func() { + check.funcBody(decl, obj.name, sig, fdecl.Body, nil) + }).describef(obj, "func %s", obj.name) + } +} + +func (check *Checker) declStmt(list []syntax.Decl) { + pkg := check.pkg + + first := -1 // index of first ConstDecl in the current group, or -1 + var last *syntax.ConstDecl // last ConstDecl with init expressions, or nil + for index, decl := range list { + if _, ok := decl.(*syntax.ConstDecl); !ok { + first = -1 // we're not in a constant declaration + } + + switch s := decl.(type) { + case *syntax.ConstDecl: + top := len(check.delayed) + + // iota is the index of the current constDecl within the group + if first < 0 || s.Group == nil || list[index-1].(*syntax.ConstDecl).Group != s.Group { + first = index + last = nil + } + iota := constant.MakeInt64(int64(index - first)) + + // determine which initialization expressions to use + inherited := true + switch { + case s.Type != nil || s.Values != nil: + last = s + inherited = false + case last == nil: + last = new(syntax.ConstDecl) // make sure last exists + inherited = false + } + + // declare all constants + lhs := make([]*Const, len(s.NameList)) + values := syntax.UnpackListExpr(last.Values) + for i, name := range s.NameList { + obj := NewConst(name.Pos(), pkg, name.Value, nil, iota) + lhs[i] = obj + + var init syntax.Expr + if i < len(values) { + init = values[i] + } + + check.constDecl(obj, last.Type, init, inherited) + } + + // Constants must always have init values. + check.arity(s.Pos(), s.NameList, values, true, inherited) + + // process function literals in init expressions before scope changes + check.processDelayed(top) + + // spec: "The scope of a constant or variable identifier declared + // inside a function begins at the end of the ConstSpec or VarSpec + // (ShortVarDecl for short variable declarations) and ends at the + // end of the innermost containing block." + scopePos := syntax.EndPos(s) + for i, name := range s.NameList { + check.declare(check.scope, name, lhs[i], scopePos) + } + + case *syntax.VarDecl: + top := len(check.delayed) + + lhs0 := make([]*Var, len(s.NameList)) + for i, name := range s.NameList { + lhs0[i] = newVar(LocalVar, name.Pos(), pkg, name.Value, nil) + } + + // initialize all variables + values := syntax.UnpackListExpr(s.Values) + for i, obj := range lhs0 { + var lhs []*Var + var init syntax.Expr + switch len(values) { + case len(s.NameList): + // lhs and rhs match + init = values[i] + case 1: + // rhs is expected to be a multi-valued expression + lhs = lhs0 + init = values[0] + default: + if i < len(values) { + init = values[i] + } + } + check.varDecl(obj, lhs, s.Type, init) + if len(values) == 1 { + // If we have a single lhs variable we are done either way. + // If we have a single rhs expression, it must be a multi- + // valued expression, in which case handling the first lhs + // variable will cause all lhs variables to have a type + // assigned, and we are done as well. + if debug { + for _, obj := range lhs0 { + assert(obj.typ != nil) + } + } + break + } + } + + // If we have no type, we must have values. + if s.Type == nil || values != nil { + check.arity(s.Pos(), s.NameList, values, false, false) + } + + // process function literals in init expressions before scope changes + check.processDelayed(top) + + // declare all variables + // (only at this point are the variable scopes (parents) set) + scopePos := syntax.EndPos(s) // see constant declarations + for i, name := range s.NameList { + // see constant declarations + check.declare(check.scope, name, lhs0[i], scopePos) + } + + case *syntax.TypeDecl: + obj := NewTypeName(s.Name.Pos(), pkg, s.Name.Value, nil) + // spec: "The scope of a type identifier declared inside a function + // begins at the identifier in the TypeSpec and ends at the end of + // the innermost containing block." + scopePos := s.Name.Pos() + check.declare(check.scope, s.Name, obj, scopePos) + check.push(obj) // mark as grey + check.typeDecl(obj, s) + check.pop() + + default: + check.errorf(s, InvalidSyntaxTree, "unknown syntax.Decl node %T", s) + } + } +} diff --git a/go/src/cmd/compile/internal/types2/errorcalls_test.go b/go/src/cmd/compile/internal/types2/errorcalls_test.go new file mode 100644 index 0000000000000000000000000000000000000000..ba4dc87b6ae8b8a55a146f1424e9c40d4c361416 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/errorcalls_test.go @@ -0,0 +1,95 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2_test + +import ( + "cmd/compile/internal/syntax" + "strconv" + "testing" +) + +const ( + errorfMinArgCount = 4 + errorfFormatIndex = 2 +) + +// TestErrorCalls makes sure that check.errorf calls have at least +// errorfMinArgCount arguments (otherwise we should use check.error) +// and use balanced parentheses/brackets. +func TestErrorCalls(t *testing.T) { + files, err := pkgFiles(".") + if err != nil { + t.Fatal(err) + } + + for _, file := range files { + syntax.Inspect(file, func(n syntax.Node) bool { + call, _ := n.(*syntax.CallExpr) + if call == nil { + return true + } + selx, _ := call.Fun.(*syntax.SelectorExpr) + if selx == nil { + return true + } + if !(isName(selx.X, "check") && isName(selx.Sel, "errorf")) { + return true + } + // check.errorf calls should have at least errorfMinArgCount arguments: + // position, code, format string, and arguments to format + if n := len(call.ArgList); n < errorfMinArgCount { + t.Errorf("%s: got %d arguments, want at least %d", call.Pos(), n, errorfMinArgCount) + return false + } + format := call.ArgList[errorfFormatIndex] + syntax.Inspect(format, func(n syntax.Node) bool { + if lit, _ := n.(*syntax.BasicLit); lit != nil && lit.Kind == syntax.StringLit { + if s, err := strconv.Unquote(lit.Value); err == nil { + if !balancedParentheses(s) { + t.Errorf("%s: unbalanced parentheses/brackets", lit.Pos()) + } + } + return false + } + return true + }) + return false + }) + } +} + +func isName(n syntax.Node, name string) bool { + if n, ok := n.(*syntax.Name); ok { + return n.Value == name + } + return false +} + +func balancedParentheses(s string) bool { + var stack []byte + for _, ch := range s { + var open byte + switch ch { + case '(', '[', '{': + stack = append(stack, byte(ch)) + continue + case ')': + open = '(' + case ']': + open = '[' + case '}': + open = '{' + default: + continue + } + // closing parenthesis/bracket must have matching opening + top := len(stack) - 1 + if top < 0 || stack[top] != open { + return false + } + stack = stack[:top] + } + return len(stack) == 0 +} diff --git a/go/src/cmd/compile/internal/types2/errors.go b/go/src/cmd/compile/internal/types2/errors.go new file mode 100644 index 0000000000000000000000000000000000000000..e2f5508a1a430c00aa85a22aa07ab3a2035183b2 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/errors.go @@ -0,0 +1,256 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements error reporting. + +package types2 + +import ( + "cmd/compile/internal/syntax" + "fmt" + . "internal/types/errors" + "runtime" + "strings" +) + +func assert(p bool) { + if !p { + msg := "assertion failed" + // Include information about the assertion location. Due to panic recovery, + // this location is otherwise buried in the middle of the panicking stack. + if _, file, line, ok := runtime.Caller(1); ok { + msg = fmt.Sprintf("%s:%d: %s", file, line, msg) + } + panic(msg) + } +} + +// An errorDesc describes part of a type-checking error. +type errorDesc struct { + pos syntax.Pos + msg string +} + +// An error_ represents a type-checking error. +// A new error_ is created with Checker.newError. +// To report an error_, call error_.report. +type error_ struct { + check *Checker + desc []errorDesc + code Code + soft bool // TODO(gri) eventually determine this from an error code +} + +// newError returns a new error_ with the given error code. +func (check *Checker) newError(code Code) *error_ { + if code == 0 { + panic("error code must not be 0") + } + return &error_{check: check, code: code} +} + +// addf adds formatted error information to err. +// It may be called multiple times to provide additional information. +// The position of the first call to addf determines the position of the reported Error. +// Subsequent calls to addf provide additional information in the form of additional lines +// in the error message (types2) or continuation errors identified by a tab-indented error +// message (go/types). +func (err *error_) addf(at poser, format string, args ...any) { + err.desc = append(err.desc, errorDesc{atPos(at), err.check.sprintf(format, args...)}) +} + +// addAltDecl is a specialized form of addf reporting another declaration of obj. +func (err *error_) addAltDecl(obj Object) { + if pos := obj.Pos(); pos.IsKnown() { + // We use "other" rather than "previous" here because + // the first declaration seen may not be textually + // earlier in the source. + err.addf(obj, "other declaration of %s", obj.Name()) + } +} + +func (err *error_) empty() bool { + return err.desc == nil +} + +func (err *error_) pos() syntax.Pos { + if err.empty() { + return nopos + } + return err.desc[0].pos +} + +// msg returns the formatted error message without the primary error position pos(). +func (err *error_) msg() string { + if err.empty() { + return "no error" + } + + var buf strings.Builder + for i := range err.desc { + p := &err.desc[i] + if i > 0 { + fmt.Fprint(&buf, "\n\t") + if p.pos.IsKnown() { + fmt.Fprintf(&buf, "%s: ", p.pos) + } + } + buf.WriteString(p.msg) + } + return buf.String() +} + +// report reports the error err, setting check.firstError if necessary. +func (err *error_) report() { + if err.empty() { + panic("no error") + } + + // Cheap trick: Don't report errors with messages containing + // "invalid operand" or "invalid type" as those tend to be + // follow-on errors which don't add useful information. Only + // exclude them if these strings are not at the beginning, + // and only if we have at least one error already reported. + check := err.check + if check.firstErr != nil { + // It is sufficient to look at the first sub-error only. + msg := err.desc[0].msg + if strings.Index(msg, "invalid operand") > 0 || strings.Index(msg, "invalid type") > 0 { + return + } + } + + if check.conf.Trace { + check.trace(err.pos(), "ERROR: %s (code = %d)", err.desc[0].msg, err.code) + } + + // In go/types, if there is a sub-error with a valid position, + // call the typechecker error handler for each sub-error. + // Otherwise, call it once, with a single combined message. + multiError := false + if !isTypes2 { + for i := 1; i < len(err.desc); i++ { + if err.desc[i].pos.IsKnown() { + multiError = true + break + } + } + } + + if multiError { + for i := range err.desc { + p := &err.desc[i] + check.handleError(i, p.pos, err.code, p.msg, err.soft) + } + } else { + check.handleError(0, err.pos(), err.code, err.msg(), err.soft) + } + + // make sure the error is not reported twice + err.desc = nil +} + +// handleError should only be called by error_.report. +func (check *Checker) handleError(index int, pos syntax.Pos, code Code, msg string, soft bool) { + assert(code != 0) + + if index == 0 { + // If we are encountering an error while evaluating an inherited + // constant initialization expression, pos is the position of + // the original expression, and not of the currently declared + // constant identifier. Use the provided errpos instead. + // TODO(gri) We may also want to augment the error message and + // refer to the position (pos) in the original expression. + if check.errpos.Pos().IsKnown() { + assert(check.iota != nil) + pos = check.errpos + } + + // Report invalid syntax trees explicitly. + if code == InvalidSyntaxTree { + msg = "invalid syntax tree: " + msg + } + + // If we have a URL for error codes, add a link to the first line. + if check.conf.ErrorURL != "" { + url := fmt.Sprintf(check.conf.ErrorURL, code) + if i := strings.Index(msg, "\n"); i >= 0 { + msg = msg[:i] + url + msg[i:] + } else { + msg += url + } + } + } else { + // Indent sub-error. + // Position information is passed explicitly to Error, below. + msg = "\t" + msg + } + + e := Error{ + Pos: pos, + Msg: stripAnnotations(msg), + Full: msg, + Soft: soft, + Code: code, + } + + if check.firstErr == nil { + check.firstErr = e + } + + f := check.conf.Error + if f == nil { + panic(bailout{}) // record first error and exit + } + f(e) +} + +const ( + invalidArg = "invalid argument: " + invalidOp = "invalid operation: " +) + +// The poser interface is used to extract the position of type-checker errors. +type poser interface { + Pos() syntax.Pos +} + +func (check *Checker) error(at poser, code Code, msg string) { + err := check.newError(code) + err.addf(at, "%s", msg) + err.report() +} + +func (check *Checker) errorf(at poser, code Code, format string, args ...any) { + err := check.newError(code) + err.addf(at, format, args...) + err.report() +} + +func (check *Checker) softErrorf(at poser, code Code, format string, args ...any) { + err := check.newError(code) + err.addf(at, format, args...) + err.soft = true + err.report() +} + +func (check *Checker) versionErrorf(at poser, v goVersion, format string, args ...any) { + msg := check.sprintf(format, args...) + err := check.newError(UnsupportedFeature) + err.addf(at, "%s requires %s or later", msg, v) + err.report() +} + +// atPos reports the left (= start) position of at. +func atPos(at poser) syntax.Pos { + switch x := at.(type) { + case *operand: + if x.expr != nil { + return syntax.StartPos(x.expr) + } + case syntax.Node: + return syntax.StartPos(x) + } + return at.Pos() +} diff --git a/go/src/cmd/compile/internal/types2/errors_test.go b/go/src/cmd/compile/internal/types2/errors_test.go new file mode 100644 index 0000000000000000000000000000000000000000..cfa52472b29e6aba5beb544c43493061297e5f1d --- /dev/null +++ b/go/src/cmd/compile/internal/types2/errors_test.go @@ -0,0 +1,44 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2 + +import "testing" + +func TestError(t *testing.T) { + var err error_ + want := "no error" + if got := err.msg(); got != want { + t.Errorf("empty error: got %q, want %q", got, want) + } + + want = "foo 42" + err.addf(nopos, "foo %d", 42) + if got := err.msg(); got != want { + t.Errorf("simple error: got %q, want %q", got, want) + } + + want = "foo 42\n\tbar 43" + err.addf(nopos, "bar %d", 43) + if got := err.msg(); got != want { + t.Errorf("simple error: got %q, want %q", got, want) + } +} + +func TestStripAnnotations(t *testing.T) { + for _, test := range []struct { + in, want string + }{ + {"", ""}, + {" ", " "}, + {"foo", "foo"}, + {"foo₀", "foo"}, + {"foo(T₀)", "foo(T)"}, + } { + got := stripAnnotations(test.in) + if got != test.want { + t.Errorf("%q: got %q; want %q", test.in, got, test.want) + } + } +} diff --git a/go/src/cmd/compile/internal/types2/errsupport.go b/go/src/cmd/compile/internal/types2/errsupport.go new file mode 100644 index 0000000000000000000000000000000000000000..168150f6790e31d97a3bdc9609a965f2ffb2fe52 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/errsupport.go @@ -0,0 +1,113 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements support functions for error messages. + +package types2 + +// lookupError returns a case-specific error when a lookup of selector sel in the +// given type fails but an object with alternative spelling (case folding) is found. +// If structLit is set, the error message is specifically for struct literal fields. +func (check *Checker) lookupError(typ Type, sel string, obj Object, structLit bool) string { + // Provide more detail if there is an unexported object, or one with different capitalization. + // If selector and object are in the same package (==), export doesn't matter, otherwise (!=) it does. + // Messages depend on whether it's a general lookup or a field lookup in a struct literal. + // + // case sel pkg have message (examples for general lookup) + // --------------------------------------------------------------------------------------------------------- + // ok x.Foo == Foo + // misspelled x.Foo == FoO type X has no field or method Foo, but does have field FoO + // misspelled x.Foo == foo type X has no field or method Foo, but does have field foo + // misspelled x.Foo == foO type X has no field or method Foo, but does have field foO + // + // misspelled x.foo == Foo type X has no field or method foo, but does have field Foo + // misspelled x.foo == FoO type X has no field or method foo, but does have field FoO + // ok x.foo == foo + // misspelled x.foo == foO type X has no field or method foo, but does have field foO + // + // ok x.Foo != Foo + // misspelled x.Foo != FoO type X has no field or method Foo, but does have field FoO + // unexported x.Foo != foo type X has no field or method Foo, but does have unexported field foo + // missing x.Foo != foO type X has no field or method Foo + // + // misspelled x.foo != Foo type X has no field or method foo, but does have field Foo + // missing x.foo != FoO type X has no field or method foo + // inaccessible x.foo != foo cannot refer to unexported field foo + // missing x.foo != foO type X has no field or method foo + + const ( + ok = iota + missing // no object found + misspelled // found object with different spelling + unexported // found object with name differing only in first letter + inaccessible // found object with matching name but inaccessible from the current package + ) + + // determine case + e := missing + var alt string // alternative spelling of selector; if any + if obj != nil { + alt = obj.Name() + if obj.Pkg() == check.pkg { + assert(alt != sel) // otherwise there is no lookup error + e = misspelled + } else if isExported(sel) { + if isExported(alt) { + e = misspelled + } else if tail(sel) == tail(alt) { + e = unexported + } + } else if isExported(alt) { + if tail(sel) == tail(alt) { + e = misspelled + } + } else if sel == alt { + e = inaccessible + } + } + + if structLit { + switch e { + case missing: + return check.sprintf("unknown field %s in struct literal of type %s", sel, typ) + case misspelled: + return check.sprintf("unknown field %s in struct literal of type %s, but does have %s", sel, typ, alt) + case unexported: + return check.sprintf("unknown field %s in struct literal of type %s, but does have unexported %s", sel, typ, alt) + case inaccessible: + return check.sprintf("cannot refer to unexported field %s in struct literal of type %s", alt, typ) + } + } else { + what := "object" + switch obj.(type) { + case *Var: + what = "field" + case *Func: + what = "method" + } + switch e { + case missing: + return check.sprintf("type %s has no field or method %s", typ, sel) + case misspelled: + return check.sprintf("type %s has no field or method %s, but does have %s %s", typ, sel, what, alt) + case unexported: + return check.sprintf("type %s has no field or method %s, but does have unexported %s %s", typ, sel, what, alt) + case inaccessible: + return check.sprintf("cannot refer to unexported %s %s", what, alt) + } + } + + panic("unreachable") +} + +// tail returns the string s without its first (UTF-8) character. +// If len(s) == 0, the result is s. +func tail(s string) string { + for i, _ := range s { + if i > 0 { + return s[i:] + } + } + return s +} diff --git a/go/src/cmd/compile/internal/types2/example_test.go b/go/src/cmd/compile/internal/types2/example_test.go new file mode 100644 index 0000000000000000000000000000000000000000..9e673137f3544cef639334ca2be5e5365d5847b2 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/example_test.go @@ -0,0 +1,250 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Only run where builders (build.golang.org) have +// access to compiled packages for import. +// +//go:build !android && !ios && !js && !wasip1 + +package types2_test + +// This file shows examples of basic usage of the go/types API. +// +// To locate a Go package, use (*go/build.Context).Import. +// To load, parse, and type-check a complete Go program +// from source, use golang.org/x/tools/go/loader. + +import ( + "cmd/compile/internal/syntax" + "cmd/compile/internal/types2" + "fmt" + "log" + "regexp" + "slices" + "strings" +) + +// ExampleScope prints the tree of Scopes of a package created from a +// set of parsed files. +func ExampleScope() { + // Parse the source files for a package. + var files []*syntax.File + for _, src := range []string{ + `package main +import "fmt" +func main() { + freezing := FToC(-18) + fmt.Println(freezing, Boiling) } +`, + `package main +import "fmt" +type Celsius float64 +func (c Celsius) String() string { return fmt.Sprintf("%g°C", c) } +func FToC(f float64) Celsius { return Celsius(f - 32 / 9 * 5) } +const Boiling Celsius = 100 +func Unused() { {}; {{ var x int; _ = x }} } // make sure empty block scopes get printed +`, + } { + files = append(files, mustParse(src)) + } + + // Type-check a package consisting of these files. + // Type information for the imported "fmt" package + // comes from $GOROOT/pkg/$GOOS_$GOOARCH/fmt.a. + conf := types2.Config{Importer: defaultImporter()} + pkg, err := conf.Check("temperature", files, nil) + if err != nil { + log.Fatal(err) + } + + // Print the tree of scopes. + // For determinism, we redact addresses. + var buf strings.Builder + pkg.Scope().WriteTo(&buf, 0, true) + rx := regexp.MustCompile(` 0x[a-fA-F\d]*`) + fmt.Println(rx.ReplaceAllString(buf.String(), "")) + + // Output: + // package "temperature" scope { + // . const temperature.Boiling temperature.Celsius + // . type temperature.Celsius float64 + // . func temperature.FToC(f float64) temperature.Celsius + // . func temperature.Unused() + // . func temperature.main() + // . main scope { + // . . package fmt + // . . function scope { + // . . . var freezing temperature.Celsius + // . . } + // . } + // . main scope { + // . . package fmt + // . . function scope { + // . . . var c temperature.Celsius + // . . } + // . . function scope { + // . . . var f float64 + // . . } + // . . function scope { + // . . . block scope { + // . . . } + // . . . block scope { + // . . . . block scope { + // . . . . . var x int + // . . . . } + // . . . } + // . . } + // . } + // } +} + +// ExampleInfo prints various facts recorded by the type checker in a +// types2.Info struct: definitions of and references to each named object, +// and the type, value, and mode of every expression in the package. +func ExampleInfo() { + // Parse a single source file. + const input = ` +package fib + +type S string + +var a, b, c = len(b), S(c), "hello" + +func fib(x int) int { + if x < 2 { + return x + } + return fib(x-1) - fib(x-2) +}` + // Type-check the package. + // We create an empty map for each kind of input + // we're interested in, and Check populates them. + info := types2.Info{ + Types: make(map[syntax.Expr]types2.TypeAndValue), + Defs: make(map[*syntax.Name]types2.Object), + Uses: make(map[*syntax.Name]types2.Object), + } + pkg := mustTypecheck(input, nil, &info) + + // Print package-level variables in initialization order. + fmt.Printf("InitOrder: %v\n\n", info.InitOrder) + + // For each named object, print the line and + // column of its definition and each of its uses. + fmt.Println("Defs and Uses of each named object:") + usesByObj := make(map[types2.Object][]string) + for id, obj := range info.Uses { + posn := id.Pos() + lineCol := fmt.Sprintf("%d:%d", posn.Line(), posn.Col()) + usesByObj[obj] = append(usesByObj[obj], lineCol) + } + var items []string + for obj, uses := range usesByObj { + slices.Sort(uses) + item := fmt.Sprintf("%s:\n defined at %s\n used at %s", + types2.ObjectString(obj, types2.RelativeTo(pkg)), + obj.Pos(), + strings.Join(uses, ", ")) + items = append(items, item) + } + slices.Sort(items) // sort by line:col, in effect + fmt.Println(strings.Join(items, "\n")) + fmt.Println() + + fmt.Println("Types and Values of each expression:") + items = nil + for expr, tv := range info.Types { + var buf strings.Builder + posn := syntax.StartPos(expr) + tvstr := tv.Type.String() + if tv.Value != nil { + tvstr += " = " + tv.Value.String() + } + // line:col | expr | mode : type = value + fmt.Fprintf(&buf, "%2d:%2d | %-19s | %-7s : %s", + posn.Line(), posn.Col(), types2.ExprString(expr), + mode(tv), tvstr) + items = append(items, buf.String()) + } + slices.Sort(items) + fmt.Println(strings.Join(items, "\n")) + + // Output: + // InitOrder: [c = "hello" b = S(c) a = len(b)] + // + // Defs and Uses of each named object: + // builtin len: + // defined at + // used at 6:15 + // func fib(x int) int: + // defined at fib:8:6 + // used at 12:20, 12:9 + // type S string: + // defined at fib:4:6 + // used at 6:23 + // type int: + // defined at + // used at 8:12, 8:17 + // type string: + // defined at + // used at 4:8 + // var b S: + // defined at fib:6:8 + // used at 6:19 + // var c string: + // defined at fib:6:11 + // used at 6:25 + // var x int: + // defined at fib:8:10 + // used at 10:10, 12:13, 12:24, 9:5 + // + // Types and Values of each expression: + // 4: 8 | string | type : string + // 6:15 | len | builtin : func(fib.S) int + // 6:15 | len(b) | value : int + // 6:19 | b | var : fib.S + // 6:23 | S | type : fib.S + // 6:23 | S(c) | value : fib.S + // 6:25 | c | var : string + // 6:29 | "hello" | value : string = "hello" + // 8:12 | int | type : int + // 8:17 | int | type : int + // 9: 5 | x | var : int + // 9: 5 | x < 2 | value : untyped bool + // 9: 9 | 2 | value : int = 2 + // 10:10 | x | var : int + // 12: 9 | fib | value : func(x int) int + // 12: 9 | fib(x - 1) | value : int + // 12: 9 | fib(x - 1) - fib(x - 2) | value : int + // 12:13 | x | var : int + // 12:13 | x - 1 | value : int + // 12:15 | 1 | value : int = 1 + // 12:20 | fib | value : func(x int) int + // 12:20 | fib(x - 2) | value : int + // 12:24 | x | var : int + // 12:24 | x - 2 | value : int + // 12:26 | 2 | value : int = 2 +} + +func mode(tv types2.TypeAndValue) string { + switch { + case tv.IsVoid(): + return "void" + case tv.IsType(): + return "type" + case tv.IsBuiltin(): + return "builtin" + case tv.IsNil(): + return "nil" + case tv.Assignable(): + if tv.Addressable() { + return "var" + } + return "mapindex" + case tv.IsValue(): + return "value" + default: + return "unknown" + } +} diff --git a/go/src/cmd/compile/internal/types2/expr.go b/go/src/cmd/compile/internal/types2/expr.go new file mode 100644 index 0000000000000000000000000000000000000000..e3ef1af1ce35ca33f1aedab4bbffbb1a576653d4 --- /dev/null +++ b/go/src/cmd/compile/internal/types2/expr.go @@ -0,0 +1,1458 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements typechecking of expressions. + +package types2 + +import ( + "cmd/compile/internal/syntax" + "fmt" + "go/constant" + "go/token" + . "internal/types/errors" +) + +/* +Basic algorithm: + +Expressions are checked recursively, top down. Expression checker functions +are generally of the form: + + func f(x *operand, e *syntax.Expr, ...) + +where e is the expression to be checked, and x is the result of the check. +The check performed by f may fail in which case x.mode == invalid, and +related error messages will have been issued by f. + +If a hint argument is present, it is the composite literal element type +of an outer composite literal; it is used to type-check composite literal +elements that have no explicit type specification in the source +(e.g.: []T{{...}, {...}}, the hint is the type T in this case). + +All expressions are checked via rawExpr, which dispatches according +to expression kind. Upon returning, rawExpr is recording the types and +constant values for all expressions that have an untyped type (those types +may change on the way up in the expression tree). Usually these are constants, +but the results of comparisons or non-constant shifts of untyped constants +may also be untyped, but not constant. + +Untyped expressions may eventually become fully typed (i.e., not untyped), +typically when the value is assigned to a variable, or is used otherwise. +The updateExprType method is used to record this final type and update +the recorded types: the type-checked expression tree is again traversed down, +and the new type is propagated as needed. Untyped constant expression values +that become fully typed must now be representable by the full type (constant +sub-expression trees are left alone except for their roots). This mechanism +ensures that a client sees the actual (run-time) type an untyped value would +have. It also permits type-checking of lhs shift operands "as if the shift +were not present": when updateExprType visits an untyped lhs shift operand +and assigns it it's final type, that type must be an integer type, and a +constant lhs must be representable as an integer. + +When an expression gets its final type, either on the way out from rawExpr, +on the way down in updateExprType, or at the end of the type checker run, +the type (and constant value, if any) is recorded via Info.Types, if present. +*/ + +type opPredicates map[syntax.Operator]func(Type) bool + +var unaryOpPredicates opPredicates + +func init() { + // Setting unaryOpPredicates in init avoids declaration cycles. + unaryOpPredicates = opPredicates{ + syntax.Add: allNumeric, + syntax.Sub: allNumeric, + syntax.Xor: allInteger, + syntax.Not: allBoolean, + } +} + +func (check *Checker) op(m opPredicates, x *operand, op syntax.Operator) bool { + if pred := m[op]; pred != nil { + if !pred(x.typ) { + check.errorf(x, UndefinedOp, invalidOp+"operator %s not defined on %s", op, x) + return false + } + } else { + check.errorf(x, InvalidSyntaxTree, "unknown operator %s", op) + return false + } + return true +} + +// opPos returns the position of the operator if x is an operation; +// otherwise it returns the start position of x. +func opPos(x syntax.Expr) syntax.Pos { + switch op := x.(type) { + case nil: + return nopos // don't crash + case *syntax.Operation: + return op.Pos() + default: + return syntax.StartPos(x) + } +} + +// opName returns the name of the operation if x is an operation +// that might overflow; otherwise it returns the empty string. +func opName(x syntax.Expr) string { + if e, _ := x.(*syntax.Operation); e != nil { + op := int(e.Op) + if e.Y == nil { + if op < len(op2str1) { + return op2str1[op] + } + } else { + if op < len(op2str2) { + return op2str2[op] + } + } + } + return "" +} + +var op2str1 = [...]string{ + syntax.Xor: "bitwise complement", +} + +// This is only used for operations that may cause overflow. +var op2str2 = [...]string{ + syntax.Add: "addition", + syntax.Sub: "subtraction", + syntax.Xor: "bitwise XOR", + syntax.Mul: "multiplication", + syntax.Shl: "shift", +} + +func (check *Checker) unary(x *operand, e *syntax.Operation) { + check.expr(nil, x, e.X) + if x.mode == invalid { + return + } + + op := e.Op + switch op { + case syntax.And: + // spec: "As an exception to the addressability + // requirement x may also be a composite literal." + if _, ok := syntax.Unparen(e.X).(*syntax.CompositeLit); !ok && x.mode != variable { + check.errorf(x, UnaddressableOperand, invalidOp+"cannot take address of %s", x) + x.mode = invalid + return + } + x.mode = value + x.typ = &Pointer{base: x.typ} + return + + case syntax.Recv: + if elem := check.chanElem(x, x, true); elem != nil { + x.mode = commaok + x.typ = elem + check.hasCallOrRecv = true + return + } + x.mode = invalid + return + + case syntax.Tilde: + // Provide a better error position and message than what check.op below would do. + if !allInteger(x.typ) { + check.error(e, UndefinedOp, "cannot use ~ outside of interface or type constraint") + x.mode = invalid + return + } + check.error(e, UndefinedOp, "cannot use ~ outside of interface or type constraint (use ^ for bitwise complement)") + op = syntax.Xor + } + + if !check.op(unaryOpPredicates, x, op) { + x.mode = invalid + return + } + + if x.mode == constant_ { + if x.val.Kind() == constant.Unknown { + // nothing to do (and don't cause an error below in the overflow check) + return + } + var prec uint + if isUnsigned(x.typ) { + prec = uint(check.conf.sizeof(x.typ) * 8) + } + x.val = constant.UnaryOp(op2tok[op], x.val, prec) + x.expr = e + check.overflow(x, opPos(x.expr)) + return + } + + x.mode = value + // x.typ remains unchanged +} + +// chanElem returns the channel element type of x for a receive from x (recv == true) +// or send to x (recv == false) operation. If the operation is not valid, chanElem +// reports an error and returns nil. +func (check *Checker) chanElem(pos poser, x *operand, recv bool) Type { + u, err := commonUnder(x.typ, func(t, u Type) *typeError { + if u == nil { + return typeErrorf("no specific channel type") + } + ch, _ := u.(*Chan) + if ch == nil { + return typeErrorf("non-channel %s", t) + } + if recv && ch.dir == SendOnly { + return typeErrorf("send-only channel %s", t) + } + if !recv && ch.dir == RecvOnly { + return typeErrorf("receive-only channel %s", t) + } + return nil + }) + + if u != nil { + return u.(*Chan).elem + } + + cause := err.format(check) + if recv { + if isTypeParam(x.typ) { + check.errorf(pos, InvalidReceive, invalidOp+"cannot receive from %s: %s", x, cause) + } else { + // In this case, only the non-channel and send-only channel error are possible. + check.errorf(pos, InvalidReceive, invalidOp+"cannot receive from %s %s", cause, x) + } + } else { + if isTypeParam(x.typ) { + check.errorf(pos, InvalidSend, invalidOp+"cannot send to %s: %s", x, cause) + } else { + // In this case, only the non-channel and receive-only channel error are possible. + check.errorf(pos, InvalidSend, invalidOp+"cannot send to %s %s", cause, x) + } + } + return nil +} + +func isShift(op syntax.Operator) bool { + return op == syntax.Shl || op == syntax.Shr +} + +func isComparison(op syntax.Operator) bool { + // Note: tokens are not ordered well to make this much easier + switch op { + case syntax.Eql, syntax.Neq, syntax.Lss, syntax.Leq, syntax.Gtr, syntax.Geq: + return true + } + return false +} + +// updateExprType updates the type of x to typ and invokes itself +// recursively for the operands of x, depending on expression kind. +// If typ is still an untyped and not the final type, updateExprType +// only updates the recorded untyped type for x and possibly its +// operands. Otherwise (i.e., typ is not an untyped type anymore, +// or it is the final type for x), the type and value are recorded. +// Also, if x is a constant, it must be representable as a value of typ, +// and if x is the (formerly untyped) lhs operand of a non-constant +// shift, it must be an integer value. +func (check *Checker) updateExprType(x syntax.Expr, typ Type, final bool) { + old, found := check.untyped[x] + if !found { + return // nothing to do + } + + // update operands of x if necessary + switch x := x.(type) { + case *syntax.BadExpr, + *syntax.FuncLit, + *syntax.CompositeLit, + *syntax.IndexExpr, + *syntax.SliceExpr, + *syntax.AssertExpr, + *syntax.ListExpr, + //*syntax.StarExpr, + *syntax.KeyValueExpr, + *syntax.ArrayType, + *syntax.StructType, + *syntax.FuncType, + *syntax.InterfaceType, + *syntax.MapType, + *syntax.ChanType: + // These expression are never untyped - nothing to do. + // The respective sub-expressions got their final types + // upon assignment or use. + if debug { + check.dump("%v: found old type(%s): %s (new: %s)", atPos(x), x, old.typ, typ) + panic("unreachable") + } + return + + case *syntax.CallExpr: + // Resulting in an untyped constant (e.g., built-in complex). + // The respective calls take care of calling updateExprType + // for the arguments if necessary. + + case *syntax.Name, *syntax.BasicLit, *syntax.SelectorExpr: + // An identifier denoting a constant, a constant literal, + // or a qualified identifier (imported untyped constant). + // No operands to take care of. + + case *syntax.ParenExpr: + check.updateExprType(x.X, typ, final) + + // case *syntax.UnaryExpr: + // // If x is a constant, the operands were constants. + // // The operands don't need to be updated since they + // // never get "materialized" into a typed value. If + // // left in the untyped map, they will be processed + // // at the end of the type check. + // if old.val != nil { + // break + // } + // check.updateExprType(x.X, typ, final) + + case *syntax.Operation: + if x.Y == nil { + // unary expression + if x.Op == syntax.Mul { + // see commented out code for StarExpr above + // TODO(gri) needs cleanup + if debug { + panic("unimplemented") + } + return + } + // If x is a constant, the operands were constants. + // The operands don't need to be updated since they + // never get "materialized" into a typed value. If + // left in the untyped map, they will be processed + // at the end of the type check. + if old.val != nil { + break + } + check.updateExprType(x.X, typ, final) + break + } + + // binary expression + if old.val != nil { + break // see comment for unary expressions + } + if isComparison(x.Op) { + // The result type is independent of operand types + // and the operand types must have final types. + } else if isShift(x.Op) { + // The result type depends only on lhs operand. + // The rhs type was updated when checking the shift. + check.updateExprType(x.X, typ, final) + } else { + // The operand types match the result type. + check.updateExprType(x.X, typ, final) + check.updateExprType(x.Y, typ, final) + } + + default: + panic("unreachable") + } + + // If the new type is not final and still untyped, just + // update the recorded type. + if !final && isUntyped(typ) { + old.typ = typ.Underlying().(*Basic) + check.untyped[x] = old + return + } + + // Otherwise we have the final (typed or untyped type). + // Remove it from the map of yet untyped expressions. + delete(check.untyped, x) + + if old.isLhs { + // If x is the lhs of a shift, its final type must be integer. + // We already know from the shift check that it is representable + // as an integer if it is a constant. + if !allInteger(typ) { + check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s (type %s) must be integer", x, typ) + return + } + // Even if we have an integer, if the value is a constant we + // still must check that it is representable as the specific + // int type requested (was go.dev/issue/22969). Fall through here. + } + if old.val != nil { + // If x is a constant, it must be representable as a value of typ. + c := operand{old.mode, x, old.typ, old.val, 0} + check.convertUntyped(&c, typ) + if c.mode == invalid { + return + } + } + + // Everything's fine, record final type and value for x. + check.recordTypeAndValue(x, old.mode, typ, old.val) +} + +// updateExprVal updates the value of x to val. +func (check *Checker) updateExprVal(x syntax.Expr, val constant.Value) { + if info, ok := check.untyped[x]; ok { + info.val = val + check.untyped[x] = info + } +} + +// implicitTypeAndValue returns the implicit type of x when used in a context +// where the target type is expected. If no such implicit conversion is +// possible, it returns a nil Type and non-zero error code. +// +// If x is a constant operand, the returned constant.Value will be the +// representation of x in this context. +func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, constant.Value, Code) { + if x.mode == invalid || isTyped(x.typ) || !isValid(target) { + return x.typ, nil, 0 + } + // x is untyped + + if isUntyped(target) { + // both x and target are untyped + if m := maxType(x.typ, target); m != nil { + return m, nil, 0 + } + return nil, nil, InvalidUntypedConversion + } + + if x.isNil() { + assert(isUntyped(x.typ)) + if hasNil(target) { + return target, nil, 0 + } + return nil, nil, InvalidUntypedConversion + } + + switch u := target.Underlying().(type) { + case *Basic: + if x.mode == constant_ { + v, code := check.representation(x, u) + if code != 0 { + return nil, nil, code + } + return target, v, code + } + // Non-constant untyped values may appear as the + // result of comparisons (untyped bool), intermediate + // (delayed-checked) rhs operands of shifts, and as + // the value nil. + switch x.typ.(*Basic).kind { + case UntypedBool: + if !isBoolean(target) { + return nil, nil, InvalidUntypedConversion + } + case UntypedInt, UntypedRune, UntypedFloat, UntypedComplex: + if !isNumeric(target) { + return nil, nil, InvalidUntypedConversion + } + case UntypedString: + // Non-constant untyped string values are not permitted by the spec and + // should not occur during normal typechecking passes, but this path is + // reachable via the AssignableTo API. + if !isString(target) { + return nil, nil, InvalidUntypedConversion + } + default: + return nil, nil, InvalidUntypedConversion + } + case *Interface: + if isTypeParam(target) { + if !underIs(target, func(u Type) bool { + if u == nil { + return false + } + t, _, _ := check.implicitTypeAndValue(x, u) + return t != nil + }) { + return nil, nil, InvalidUntypedConversion + } + break + } + // Update operand types to the default type rather than the target + // (interface) type: values must have concrete dynamic types. + // Untyped nil was handled upfront. + if !u.Empty() { + return nil, nil, InvalidUntypedConversion // cannot assign untyped values to non-empty interfaces + } + return Default(x.typ), nil, 0 // default type for nil is nil + default: + return nil, nil, InvalidUntypedConversion + } + return target, nil, 0 +} + +// If switchCase is true, the operator op is ignored. +func (check *Checker) comparison(x, y *operand, op syntax.Operator, switchCase bool) { + // Avoid spurious errors if any of the operands has an invalid type (go.dev/issue/54405). + if !isValid(x.typ) || !isValid(y.typ) { + x.mode = invalid + return + } + + if switchCase { + op = syntax.Eql + } + + errOp := x // operand for which error is reported, if any + cause := "" // specific error cause, if any + + // spec: "In any comparison, the first operand must be assignable + // to the type of the second operand, or vice versa." + code := MismatchedTypes + ok, _ := x.assignableTo(check, y.typ, nil) + if !ok { + ok, _ = y.assignableTo(check, x.typ, nil) + } + if !ok { + // Report the error on the 2nd operand since we only + // know after seeing the 2nd operand whether we have + // a type mismatch. + errOp = y + cause = check.sprintf("mismatched types %s and %s", x.typ, y.typ) + goto Error + } + + // check if comparison is defined for operands + code = UndefinedOp + switch op { + case syntax.Eql, syntax.Neq: + // spec: "The equality operators == and != apply to operands that are comparable." + switch { + case x.isNil() || y.isNil(): + // Comparison against nil requires that the other operand type has nil. + typ := x.typ + if x.isNil() { + typ = y.typ + } + if !hasNil(typ) { + // This case should only be possible for "nil == nil". + // Report the error on the 2nd operand since we only + // know after seeing the 2nd operand whether we have + // an invalid comparison. + errOp = y + goto Error + } + + case !Comparable(x.typ): + errOp = x + cause = check.incomparableCause(x.typ) + goto Error + + case !Comparable(y.typ): + errOp = y + cause = check.incomparableCause(y.typ) + goto Error + } + + case syntax.Lss, syntax.Leq, syntax.Gtr, syntax.Geq: + // spec: The ordering operators <, <=, >, and >= apply to operands that are ordered." + switch { + case !allOrdered(x.typ): + errOp = x + goto Error + case !allOrdered(y.typ): + errOp = y + goto Error + } + + default: + panic("unreachable") + } + + // comparison is ok + if x.mode == constant_ && y.mode == constant_ { + x.val = constant.MakeBool(constant.Compare(x.val, op2tok[op], y.val)) + // The operands are never materialized; no need to update + // their types. + } else { + x.mode = value + // The operands have now their final types, which at run- + // time will be materialized. Update the expression trees. + // If the current types are untyped, the materialized type + // is the respective default type. + check.updateExprType(x.expr, Default(x.typ), true) + check.updateExprType(y.expr, Default(y.typ), true) + } + + // spec: "Comparison operators compare two operands and yield + // an untyped boolean value." + x.typ = Typ[UntypedBool] + return + +Error: + // We have an offending operand errOp and possibly an error cause. + if cause == "" { + if isTypeParam(x.typ) || isTypeParam(y.typ) { + // TODO(gri) should report the specific type causing the problem, if any + if !isTypeParam(x.typ) { + errOp = y + } + cause = check.sprintf("type parameter %s cannot use operator %s", errOp.typ, op) + } else { + // catch-all: neither x nor y is a type parameter + what := compositeKind(errOp.typ) + if what == "" { + what = check.sprintf("%s", errOp.typ) + } + cause = check.sprintf("operator %s not defined on %s", op, what) + } + } + if switchCase { + check.errorf(x, code, "invalid case %s in switch on %s (%s)", x.expr, y.expr, cause) // error position always at 1st operand + } else { + check.errorf(errOp, code, invalidOp+"%s %s %s (%s)", x.expr, op, y.expr, cause) + } + x.mode = invalid +} + +// incomparableCause returns a more specific cause why typ is not comparable. +// If there is no more specific cause, the result is "". +func (check *Checker) incomparableCause(typ Type) string { + switch typ.Underlying().(type) { + case *Slice, *Signature, *Map: + return compositeKind(typ) + " can only be compared to nil" + } + // see if we can extract a more specific error + return comparableType(typ, true, nil).format(check) +} + +// If e != nil, it must be the shift expression; it may be nil for non-constant shifts. +func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) { + // TODO(gri) This function seems overly complex. Revisit. + + var xval constant.Value + if x.mode == constant_ { + xval = constant.ToInt(x.val) + } + + if allInteger(x.typ) || isUntyped(x.typ) && xval != nil && xval.Kind() == constant.Int { + // The lhs is of integer type or an untyped constant representable + // as an integer. Nothing to do. + } else { + // shift has no chance + check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s must be integer", x) + x.mode = invalid + return + } + + // spec: "The right operand in a shift expression must have integer type + // or be an untyped constant representable by a value of type uint." + + // Check that constants are representable by uint, but do not convert them + // (see also go.dev/issue/47243). + var yval constant.Value + if y.mode == constant_ { + // Provide a good error message for negative shift counts. + yval = constant.ToInt(y.val) // consider -1, 1.0, but not -1.1 + if yval.Kind() == constant.Int && constant.Sign(yval) < 0 { + check.errorf(y, InvalidShiftCount, invalidOp+"negative shift count %s", y) + x.mode = invalid + return + } + + if isUntyped(y.typ) { + // Caution: Check for representability here, rather than in the switch + // below, because isInteger includes untyped integers (was bug go.dev/issue/43697). + check.representable(y, Typ[Uint]) + if y.mode == invalid { + x.mode = invalid + return + } + } + } else { + // Check that RHS is otherwise at least of integer type. + switch { + case allInteger(y.typ): + if !allUnsigned(y.typ) && !check.verifyVersionf(y, go1_13, invalidOp+"signed shift count %s", y) { + x.mode = invalid + return + } + case isUntyped(y.typ): + // This is incorrect, but preserves pre-existing behavior. + // See also go.dev/issue/47410. + check.convertUntyped(y, Typ[Uint]) + if y.mode == invalid { + x.mode = invalid + return + } + default: + check.errorf(y, InvalidShiftCount, invalidOp+"shift count %s must be integer", y) + x.mode = invalid + return + } + } + + if x.mode == constant_ { + if y.mode == constant_ { + // if either x or y has an unknown value, the result is unknown + if x.val.Kind() == constant.Unknown || y.val.Kind() == constant.Unknown { + x.val = constant.MakeUnknown() + // ensure the correct type - see comment below + if !isInteger(x.typ) { + x.typ = Typ[UntypedInt] + } + return + } + // rhs must be within reasonable bounds in constant shifts + const shiftBound = 1023 - 1 + 52 // so we can express smallestFloat64 (see go.dev/issue/44057) + s, ok := constant.Uint64Val(yval) + if !ok || s > shiftBound { + check.errorf(y, InvalidShiftCount, invalidOp+"invalid shift count %s", y) + x.mode = invalid + return + } + // The lhs is representable as an integer but may not be an integer + // (e.g., 2.0, an untyped float) - this can only happen for untyped + // non-integer numeric constants. Correct the type so that the shift + // result is of integer type. + if !isInteger(x.typ) { + x.typ = Typ[UntypedInt] + } + // x is a constant so xval != nil and it must be of Int kind. + x.val = constant.Shift(xval, op2tok[op], uint(s)) + x.expr = e + check.overflow(x, opPos(x.expr)) + return + } + + // non-constant shift with constant lhs + if isUntyped(x.typ) { + // spec: "If the left operand of a non-constant shift + // expression is an untyped constant, the type of the + // constant is what it would be if the shift expression + // were replaced by its left operand alone.". + // + // Delay operand checking until we know the final type + // by marking the lhs expression as lhs shift operand. + // + // Usually (in correct programs), the lhs expression + // is in the untyped map. However, it is possible to + // create incorrect programs where the same expression + // is evaluated twice (via a declaration cycle) such + // that the lhs expression type is determined in the + // first round and thus deleted from the map, and then + // not found in the second round (double insertion of + // the same expr node still just leads to one entry for + // that node, and it can only be deleted once). + // Be cautious and check for presence of entry. + // Example: var e, f = int(1<<""[f]) // go.dev/issue/11347 + if info, found := check.untyped[x.expr]; found { + info.isLhs = true + check.untyped[x.expr] = info + } + // keep x's type + x.mode = value + return + } + } + + // non-constant shift - lhs must be an integer + if !allInteger(x.typ) { + check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s must be integer", x) + x.mode = invalid + return + } + + x.mode = value +} + +var binaryOpPredicates opPredicates + +func init() { + // Setting binaryOpPredicates in init avoids declaration cycles. + binaryOpPredicates = opPredicates{ + syntax.Add: allNumericOrString, + syntax.Sub: allNumeric, + syntax.Mul: allNumeric, + syntax.Div: allNumeric, + syntax.Rem: allInteger, + + syntax.And: allInteger, + syntax.Or: allInteger, + syntax.Xor: allInteger, + syntax.AndNot: allInteger, + + syntax.AndAnd: allBoolean, + syntax.OrOr: allBoolean, + } +} + +// If e != nil, it must be the binary expression; it may be nil for non-constant expressions +// (when invoked for an assignment operation where the binary expression is implicit). +func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op syntax.Operator) { + var y operand + + check.expr(nil, x, lhs) + check.expr(nil, &y, rhs) + + if x.mode == invalid { + return + } + if y.mode == invalid { + x.mode = invalid + x.expr = y.expr + return + } + + if isShift(op) { + check.shift(x, &y, e, op) + return + } + + check.matchTypes(x, &y) + if x.mode == invalid { + return + } + + if isComparison(op) { + check.comparison(x, &y, op, false) + return + } + + if !Identical(x.typ, y.typ) { + // only report an error if we have valid types + // (otherwise we had an error reported elsewhere already) + if isValid(x.typ) && isValid(y.typ) { + if e != nil { + check.errorf(x, MismatchedTypes, invalidOp+"%s (mismatched types %s and %s)", e, x.typ, y.typ) + } else { + check.errorf(x, MismatchedTypes, invalidOp+"%s %s= %s (mismatched types %s and %s)", lhs, op, rhs, x.typ, y.typ) + } + } + x.mode = invalid + return + } + + if !check.op(binaryOpPredicates, x, op) { + x.mode = invalid + return + } + + if op == syntax.Div || op == syntax.Rem { + // check for zero divisor + if (x.mode == constant_ || allInteger(x.typ)) && y.mode == constant_ && constant.Sign(y.val) == 0 { + check.error(&y, DivByZero, invalidOp+"division by zero") + x.mode = invalid + return + } + + // check for divisor underflow in complex division (see go.dev/issue/20227) + if x.mode == constant_ && y.mode == constant_ && isComplex(x.typ) { + re, im := constant.Real(y.val), constant.Imag(y.val) + re2, im2 := constant.BinaryOp(re, token.MUL, re), constant.BinaryOp(im, token.MUL, im) + if constant.Sign(re2) == 0 && constant.Sign(im2) == 0 { + check.error(&y, DivByZero, invalidOp+"division by zero") + x.mode = invalid + return + } + } + } + + if x.mode == constant_ && y.mode == constant_ { + // if either x or y has an unknown value, the result is unknown + if x.val.Kind() == constant.Unknown || y.val.Kind() == constant.Unknown { + x.val = constant.MakeUnknown() + // x.typ is unchanged + return + } + // force integer division for integer operands + tok := op2tok[op] + if op == syntax.Div && isInteger(x.typ) { + tok = token.QUO_ASSIGN + } + x.val = constant.BinaryOp(x.val, tok, y.val) + x.expr = e + check.overflow(x, opPos(x.expr)) + return + } + + x.mode = value + // x.typ is unchanged +} + +// matchTypes attempts to convert any untyped types x and y such that they match. +// If an error occurs, x.mode is set to invalid. +func (check *Checker) matchTypes(x, y *operand) { + // mayConvert reports whether the operands x and y may + // possibly have matching types after converting one + // untyped operand to the type of the other. + // If mayConvert returns true, we try to convert the + // operands to each other's types, and if that fails + // we report a conversion failure. + // If mayConvert returns false, we continue without an + // attempt at conversion, and if the operand types are + // not compatible, we report a type mismatch error. + mayConvert := func(x, y *operand) bool { + // If both operands are typed, there's no need for an implicit conversion. + if isTyped(x.typ) && isTyped(y.typ) { + return false + } + // A numeric type can only convert to another numeric type. + if allNumeric(x.typ) != allNumeric(y.typ) { + return false + } + // An untyped operand may convert to its default type when paired with an empty interface + // TODO(gri) This should only matter for comparisons (the only binary operation that is + // valid with interfaces), but in that case the assignability check should take + // care of the conversion. Verify and possibly eliminate this extra test. + if isNonTypeParamInterface(x.typ) || isNonTypeParamInterface(y.typ) { + return true + } + // A boolean type can only convert to another boolean type. + if allBoolean(x.typ) != allBoolean(y.typ) { + return false + } + // A string type can only convert to another string type. + if allString(x.typ) != allString(y.typ) { + return false + } + // Untyped nil can only convert to a type that has a nil. + if x.isNil() { + return hasNil(y.typ) + } + if y.isNil() { + return hasNil(x.typ) + } + // An untyped operand cannot convert to a pointer. + // TODO(gri) generalize to type parameters + if isPointer(x.typ) || isPointer(y.typ) { + return false + } + return true + } + + if mayConvert(x, y) { + check.convertUntyped(x, y.typ) + if x.mode == invalid { + return + } + check.convertUntyped(y, x.typ) + if y.mode == invalid { + x.mode = invalid + return + } + } +} + +// exprKind describes the kind of an expression; the kind +// determines if an expression is valid in 'statement context'. +type exprKind int + +const ( + conversion exprKind = iota + expression + statement +) + +// target represent the (signature) type and description of the LHS +// variable of an assignment, or of a function result variable. +type target struct { + sig *Signature + desc string +} + +// newTarget creates a new target for the given type and description. +// The result is nil if typ is not a signature. +func newTarget(typ Type, desc string) *target { + if typ != nil { + if sig, _ := typ.Underlying().(*Signature); sig != nil { + return &target{sig, desc} + } + } + return nil +} + +// rawExpr typechecks expression e and initializes x with the expression +// value or type. If an error occurred, x.mode is set to invalid. +// If a non-nil target T is given and e is a generic function, +// T is used to infer the type arguments for e. +// If hint != nil, it is the type of a composite literal element. +// If allowGeneric is set, the operand type may be an uninstantiated +// parameterized type or function value. +func (check *Checker) rawExpr(T *target, x *operand, e syntax.Expr, hint Type, allowGeneric bool) exprKind { + if check.conf.Trace { + check.trace(e.Pos(), "-- expr %s", e) + check.indent++ + defer func() { + check.indent-- + check.trace(e.Pos(), "=> %s", x) + }() + } + + kind := check.exprInternal(T, x, e, hint) + + if !allowGeneric { + check.nonGeneric(T, x) + } + + // Here, x is a value, meaning it has a type. If that type is pending, then we have + // a cycle. As an example: + // + // type T [unsafe.Sizeof(T{})]int + // + // has a cycle T->T which is deemed valid (by decl.go), but which is in fact invalid. + check.pendingType(x) + check.record(x) + + return kind +} + +// If x is a generic type, or a generic function whose type arguments cannot be inferred +// from a non-nil target T, nonGeneric reports an error and invalidates x.mode and x.typ. +// Otherwise it leaves x alone. +func (check *Checker) nonGeneric(T *target, x *operand) { + if x.mode == invalid || x.mode == novalue { + return + } + var what string + switch t := x.typ.(type) { + case *Alias, *Named: + if isGeneric(t) { + what = "type" + } + case *Signature: + if t.tparams != nil { + if enableReverseTypeInference && T != nil { + check.funcInst(T, x.Pos(), x, nil, true) + return + } + what = "function" + } + } + if what != "" { + check.errorf(x.expr, WrongTypeArgCount, "cannot use generic %s %s without instantiation", what, x.expr) + x.mode = invalid + x.typ = Typ[Invalid] + } +} + +// If x has a pending type (i.e. its declaring object is on the object path), pendingType +// reports an error and invalidates x.mode and x.typ. +// Otherwise it leaves x alone. +func (check *Checker) pendingType(x *operand) { + if x.mode == invalid || x.mode == novalue { + return + } + if !check.finiteSize(x.typ) { + x.mode = invalid + x.typ = Typ[Invalid] + } +} + +// exprInternal contains the core of type checking of expressions. +// Must only be called by rawExpr. +// (See rawExpr for an explanation of the parameters.) +func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Type) exprKind { + // make sure x has a valid state in case of bailout + // (was go.dev/issue/5770) + x.mode = invalid + x.typ = Typ[Invalid] + + switch e := e.(type) { + case nil: + panic("unreachable") + + case *syntax.BadExpr: + goto Error // error was reported before + + case *syntax.Name: + check.ident(x, e, false) + + case *syntax.DotsType: + // dots are handled explicitly where they are valid + check.error(e, InvalidSyntaxTree, "invalid use of ...") + goto Error + + case *syntax.BasicLit: + if e.Bad { + goto Error // error reported during parsing + } + check.basicLit(x, e) + if x.mode == invalid { + goto Error + } + + case *syntax.FuncLit: + check.funcLit(x, e) + if x.mode == invalid { + goto Error + } + + case *syntax.CompositeLit: + check.compositeLit(x, e, hint) + if x.mode == invalid { + goto Error + } + + case *syntax.ParenExpr: + // type inference doesn't go past parentheses (target type T = nil) + kind := check.rawExpr(nil, x, e.X, nil, false) + x.expr = e + return kind + + case *syntax.SelectorExpr: + check.selector(x, e, false) + + case *syntax.IndexExpr: + if check.indexExpr(x, e) { + if !enableReverseTypeInference { + T = nil + } + check.funcInst(T, e.Pos(), x, e, true) + } + if x.mode == invalid { + goto Error + } + + case *syntax.SliceExpr: + check.sliceExpr(x, e) + if x.mode == invalid { + goto Error + } + + case *syntax.AssertExpr: + check.expr(nil, x, e.X) + if x.mode == invalid { + goto Error + } + // x.(type) expressions are encoded via TypeSwitchGuards + if e.Type == nil { + check.error(e, InvalidSyntaxTree, "invalid use of AssertExpr") + goto Error + } + if isTypeParam(x.typ) { + check.errorf(x, InvalidAssert, invalidOp+"cannot use type assertion on type parameter value %s", x) + goto Error + } + if _, ok := x.typ.Underlying().(*Interface); !ok { + check.errorf(x, InvalidAssert, invalidOp+"%s is not an interface", x) + goto Error + } + T := check.varType(e.Type) + if !isValid(T) { + goto Error + } + check.typeAssertion(e, x, T, false) + x.mode = commaok + x.typ = T + + case *syntax.TypeSwitchGuard: + // x.(type) expressions are handled explicitly in type switches + check.error(e, InvalidSyntaxTree, "use of .(type) outside type switch") + check.use(e.X) + goto Error + + case *syntax.CallExpr: + return check.callExpr(x, e) + + case *syntax.ListExpr: + // catch-all for unexpected expression lists + check.error(e, InvalidSyntaxTree, "unexpected list of expressions") + goto Error + + // case *syntax.UnaryExpr: + // check.expr(x, e.X) + // if x.mode == invalid { + // goto Error + // } + // check.unary(x, e, e.Op) + // if x.mode == invalid { + // goto Error + // } + // if e.Op == token.ARROW { + // x.expr = e + // return statement // receive operations may appear in statement context + // } + + // case *syntax.BinaryExpr: + // check.binary(x, e, e.X, e.Y, e.Op) + // if x.mode == invalid { + // goto Error + // } + + case *syntax.Operation: + if e.Y == nil { + // unary expression + if e.Op == syntax.Mul { + // pointer indirection + check.exprOrType(x, e.X, false) + switch x.mode { + case invalid: + goto Error + case typexpr: + check.validVarType(e.X, x.typ) + x.typ = &Pointer{base: x.typ} + default: + var base Type + if !underIs(x.typ, func(u Type) bool { + p, _ := u.(*Pointer) + if p == nil { + check.errorf(x, InvalidIndirection, invalidOp+"cannot indirect %s", x) + return false + } + if base != nil && !Identical(p.base, base) { + check.errorf(x, InvalidIndirection, invalidOp+"pointers of %s must have identical base types", x) + return false + } + base = p.base + return true + }) { + goto Error + } + x.mode = variable + x.typ = base + } + break + } + + check.unary(x, e) + if x.mode == invalid { + goto Error + } + if e.Op == syntax.Recv { + x.expr = e + return statement // receive operations may appear in statement context + } + break + } + + // binary expression + check.binary(x, e, e.X, e.Y, e.Op) + if x.mode == invalid { + goto Error + } + + case *syntax.KeyValueExpr: + // key:value expressions are handled in composite literals + check.error(e, InvalidSyntaxTree, "no key:value expected") + goto Error + + case *syntax.ArrayType, *syntax.SliceType, *syntax.StructType, *syntax.FuncType, + *syntax.InterfaceType, *syntax.MapType, *syntax.ChanType: + x.mode = typexpr + x.typ = check.typ(e) + // Note: rawExpr (caller of exprInternal) will call check.recordTypeAndValue + // even though check.typ has already called it. This is fine as both + // times the same expression and type are recorded. It is also not a + // performance issue because we only reach here for composite literal + // types, which are comparatively rare. + + default: + panic(fmt.Sprintf("%s: unknown expression type %T", atPos(e), e)) + } + + // everything went well + x.expr = e + return expression + +Error: + x.mode = invalid + x.expr = e + return statement // avoid follow-up errors +} + +// keyVal maps a complex, float, integer, string or boolean constant value +// to the corresponding complex128, float64, int64, uint64, string, or bool +// Go value if possible; otherwise it returns x. +// A complex constant that can be represented as a float (such as 1.2 + 0i) +// is returned as a floating point value; if a floating point value can be +// represented as an integer (such as 1.0) it is returned as an integer value. +// This ensures that constants of different kind but equal value (such as +// 1.0 + 0i, 1.0, 1) result in the same value. +func keyVal(x constant.Value) any { + switch x.Kind() { + case constant.Complex: + f := constant.ToFloat(x) + if f.Kind() != constant.Float { + r, _ := constant.Float64Val(constant.Real(x)) + i, _ := constant.Float64Val(constant.Imag(x)) + return complex(r, i) + } + x = f + fallthrough + case constant.Float: + i := constant.ToInt(x) + if i.Kind() != constant.Int { + v, _ := constant.Float64Val(x) + return v + } + x = i + fallthrough + case constant.Int: + if v, ok := constant.Int64Val(x); ok { + return v + } + if v, ok := constant.Uint64Val(x); ok { + return v + } + case constant.String: + return constant.StringVal(x) + case constant.Bool: + return constant.BoolVal(x) + } + return x +} + +// typeAssertion checks x.(T). The type of x must be an interface. +func (check *Checker) typeAssertion(e syntax.Expr, x *operand, T Type, typeSwitch bool) { + var cause string + if check.assertableTo(x.typ, T, &cause) { + return // success + } + + if typeSwitch { + check.errorf(e, ImpossibleAssert, "impossible type switch case: %s\n\t%s cannot have dynamic type %s %s", e, x, T, cause) + return + } + + check.errorf(e, ImpossibleAssert, "impossible type assertion: %s\n\t%s does not implement %s %s", e, T, x.typ, cause) +} + +// expr typechecks expression e and initializes x with the expression value. +// If a non-nil target T is given and e is a generic function or +// a function call, T is used to infer the type arguments for e. +// The result must be a single value. +// If an error occurred, x.mode is set to invalid. +func (check *Checker) expr(T *target, x *operand, e syntax.Expr) { + check.rawExpr(T, x, e, nil, false) + check.exclude(x, 1<'. +To run a specific script foo.txt + + go test cmd/ -run=Script/^foo$ + +In general script files should have short names: a few words, + not whole sentences. +The first word should be the general category of behavior being tested, +often the name of a go subcommand (build, link, compile, ...) or concept (vendor, pattern). + +Each script is a text archive (go doc internal/txtar). +The script begins with an actual command script to run +followed by the content of zero or more supporting files to +create in the script's temporary file system before it starts executing. + +As an example, run_hello.txt says: + + # hello world + go run hello.go + stderr 'hello world' + ! stdout . + + -- hello.go -- + package main + func main() { println("hello world") } + +Each script runs in a fresh temporary work directory tree, available to scripts as $WORK. +Scripts also have access to other environment variables, including: + + GOARCH= + GOOS= + TMPDIR=$WORK/tmp + devnull= + goversion= + +On Plan 9, the variables $path and $home are set instead of $PATH and $HOME. +On Windows, the variables $USERPROFILE and $TMP are set instead of +$HOME and $TMPDIR. + +The lines at the top of the script are a sequence of commands to be executed by +a small script engine configured in .../cmd/internal/script/scripttest/run.go (not the system shell). + +Each line of a script is parsed into a sequence of space-separated command +words, with environment variable expansion within each word and # marking +an end-of-line comment. Additional variables named ':' and '/' are expanded +within script arguments (expanding to the value of os.PathListSeparator and +os.PathSeparator respectively) but are not inherited in subprocess environments. + +Adding single quotes around text keeps spaces in that text from being treated +as word separators and also disables environment variable expansion. Inside a +single-quoted block of text, a repeated single quote indicates a literal single +quote, as in: + + 'Don''t communicate by sharing memory.' + +A line beginning with # is a comment and conventionally explains what is being +done or tested at the start of a new section of the script. + +Commands are executed one at a time, and errors are checked for each command; +if any command fails unexpectedly, no subsequent commands in the script are +executed. The command prefix ! indicates that the command on the rest of the +line (typically go or a matching predicate) must fail instead of succeeding. +The command prefix ? indicates that the command may or may not succeed, but the +script should continue regardless. + +The command prefix [cond] indicates that the command on the rest of the line +should only run when the condition is satisfied. + +A condition can be negated: [!root] means to run the rest of the line only if +the user is not root. Multiple conditions may be given for a single command, +for example, '[linux] [amd64] skip'. The command will run if all conditions are +satisfied. + +When TestScript runs a script and the script fails, by default TestScript shows +the execution of the most recent phase of the script (since the last # comment) +and only shows the # comments for earlier phases. + +Note also that in reported output, the actual name of the per-script temporary directory +has been consistently replaced with the literal string $WORK. + +The available commands are: +cat files... + concatenate files and print to the script's stdout buffer + + +cc args... + run the platform C compiler + + +cd dir + change the working directory + + +chmod perm paths... + change file mode bits + + Changes the permissions of the named files or directories to + be equal to perm. + Only numerical permissions are supported. + +cmp [-q] file1 file2 + compare files for differences + + By convention, file1 is the actual data and file2 is the + expected data. + The command succeeds if the file contents are identical. + File1 can be 'stdout' or 'stderr' to compare the stdout or + stderr buffer from the most recent command. + +cmpenv [-q] file1 file2 + compare files for differences, with environment expansion + + By convention, file1 is the actual data and file2 is the + expected data. + The command succeeds if the file contents are identical + after substituting variables from the script environment. + File1 can be 'stdout' or 'stderr' to compare the script's + stdout or stderr buffer. + +cp src... dst + copy files to a target file or directory + + src can include 'stdout' or 'stderr' to copy from the + script's stdout or stderr buffer. + +echo string... + display a line of text + + +env [key[=value]...] + set or log the values of environment variables + + With no arguments, print the script environment to the log. + Otherwise, add the listed key=value pairs to the environment + or print the listed keys. + +exec program [args...] [&] + run an executable program with arguments + + Note that 'exec' does not terminate the script (unlike Unix + shells). + +exists [-readonly] [-exec] file... + check that files exist + + +go [args...] [&] + run the 'go' program provided by the script host + + +grep [-count=N] [-q] 'pattern' file + find lines in a file that match a pattern + + The command succeeds if at least one match (or the exact + count, if given) is found. + The -q flag suppresses printing of matches. + +help [-v] name... + log help text for commands and conditions + + To display help for a specific condition, enclose it in + brackets: 'help [amd64]'. + To display complete documentation when listing all commands, + pass the -v flag. + +mkdir path... + create directories, if they do not already exist + + Unlike Unix mkdir, parent directories are always created if + needed. + +mv old new + rename a file or directory to a new path + + OS-specific restrictions may apply when old and new are in + different directories. + +replace [old new]... file + replace strings in a file + + The 'old' and 'new' arguments are unquoted as if in quoted + Go strings. + +rm path... + remove a file or directory + + If the path is a directory, its contents are removed + recursively. + +skip [msg] + skip the current test + + +sleep duration [&] + sleep for a specified duration + + The duration must be given as a Go time.Duration string. + +stderr [-count=N] [-q] 'pattern' file + find lines in the stderr buffer that match a pattern + + The command succeeds if at least one match (or the exact + count, if given) is found. + The -q flag suppresses printing of matches. + +stdout [-count=N] [-q] 'pattern' file + find lines in the stdout buffer that match a pattern + + The command succeeds if at least one match (or the exact + count, if given) is found. + The -q flag suppresses printing of matches. + +stop [msg] + stop execution of the script + + The message is written to the script log, but no error is + reported from the script engine. + +symlink path -> target + create a symlink + + Creates path as a symlink to target. + The '->' token (like in 'ls -l' output on Unix) is required. + +wait + wait for completion of background commands + + Waits for all background commands to complete. + The output (and any error) from each command is printed to + the log in the order in which the commands were started. + After the call to 'wait', the script's stdout and stderr + buffers contain the concatenation of the background + commands' outputs. + + + +The available conditions are: +[GOARCH:*] + runtime.GOARCH == +[GODEBUG:*] + GODEBUG contains +[GOEXPERIMENT:*] + GOEXPERIMENT is enabled +[GOOS:*] + runtime.GOOS == +[asan] + GOOS/GOARCH supports -asan +[buildmode:*] + go supports -buildmode= +[cgo] + host CGO_ENABLED +[cgolinkext] + platform requires external linking for cgo +[compiler:*] + runtime.Compiler == +[cross] + cmd/go GOOS/GOARCH != GOHOSTOS/GOHOSTARCH +[exec:*] + names an executable in the test binary's PATH +[fuzz] + GOOS/GOARCH supports -fuzz +[fuzz-instrumented] + GOOS/GOARCH supports -fuzz with instrumentation +[go-builder] + GO_BUILDER_NAME is non-empty +[link] + testenv.HasLink() +[msan] + GOOS/GOARCH supports -msan +[mustlinkext] + platform always requires external linking +[pielinkext] + platform requires external linking for PIE +[race] + GOOS/GOARCH supports -race +[root] + os.Geteuid() == 0 +[short] + testing.Short() +[symlink] + testenv.HasSymlink() +[verbose] + testing.Verbose() + diff --git a/go/src/cmd/compile/testdata/script/dwarf5_gen_assembly_and_go.txt b/go/src/cmd/compile/testdata/script/dwarf5_gen_assembly_and_go.txt new file mode 100644 index 0000000000000000000000000000000000000000..2acbe0139be0bd51d8914e975c607efd522cffab --- /dev/null +++ b/go/src/cmd/compile/testdata/script/dwarf5_gen_assembly_and_go.txt @@ -0,0 +1,1345 @@ + +# Regression test case for bug #72810. Uses a build with +# Go source files and assembly source files. + +go build + +-- go.mod -- +module uses.asm + +go 1.25 +-- a.go -- +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +package main + +func main() { + t0() + t1() + t2() + t3() + t4() + t5() + t6() + t7() + t8() + t9() + t10() + t11() + t12() + t13() + t14() + t15() + t16() + t17() + t18() + t19() + t20() + t21() + t22() + t23() + t24() + t25() + t26() + t27() + t28() + t29() + t30() + t31() + t32() + t33() + t34() + t35() + t36() + t37() + t38() + t39() + t40() + t41() + t42() + t43() + t44() + t45() + t46() + t47() + t48() + t49() + t50() + t51() + t52() + t53() + t54() + t55() + t56() + t57() + t58() + t59() + t60() + t61() + t62() + t63() + t64() + t65() + t66() + t67() + t68() + t69() + t70() + t71() + t72() + t73() + t74() + t75() + t76() + t77() + t78() + t79() + t80() + t81() + t82() + t83() + t84() + t85() + t86() + t87() + t88() + t89() + t90() + t91() + t92() + t93() + t94() + t95() + t96() + t97() + t98() + t99() + t100() + t101() + t102() + t103() + t104() + t105() + t106() + t107() + t108() + t109() + t110() + t111() + t112() + t113() + t114() + t115() + t116() + t117() + t118() + t119() + t120() + t121() + t122() + t123() + t124() + t125() + t126() + t127() + t128() + t129() + t130() + t131() + t132() + t133() + t134() + t135() + t136() + t137() + t138() + t139() + t140() + t141() + t142() + t143() + t144() + t145() + t146() + t147() + t148() + t149() + t150() + t151() + t152() + t153() + t154() + t155() + t156() + t157() + t158() + t159() + t160() + t161() + t162() + t163() + t164() + t165() + t166() + t167() + t168() + t169() + t170() + t171() + t172() + t173() + t174() + t175() + t176() + t177() + t178() + t179() + t180() + t181() + t182() + t183() + t184() + t185() + t186() + t187() + t188() + t189() + t190() + t191() + t192() + t193() + t194() + t195() + t196() + t197() + t198() + t199() + t200() + t201() + t202() + t203() + t204() + t205() + t206() + t207() + t208() + t209() + t210() + t211() + t212() + t213() + t214() + t215() + t216() + t217() + t218() + t219() + t220() + t221() + t222() + t223() + t224() + t225() + t226() + t227() + t228() + t229() + t230() + t231() + t232() + t233() + t234() + t235() + t236() + t237() + t238() + t239() + t240() + t241() + t242() + t243() + t244() + t245() + t246() + t247() + t248() + t249() + t250() + t251() + t252() + t253() + t254() +} + +func t0() +func t1() +func t2() +func t3() +func t4() +func t5() +func t6() +func t7() +func t8() +func t9() +func t10() +func t11() +func t12() +func t13() +func t14() +func t15() +func t16() +func t17() +func t18() +func t19() +func t20() +func t21() +func t22() +func t23() +func t24() +func t25() +func t26() +func t27() +func t28() +func t29() +func t30() +func t31() +func t32() +func t33() +func t34() +func t35() +func t36() +func t37() +func t38() +func t39() +func t40() +func t41() +func t42() +func t43() +func t44() +func t45() +func t46() +func t47() +func t48() +func t49() +func t50() +func t51() +func t52() +func t53() +func t54() +func t55() +func t56() +func t57() +func t58() +func t59() +func t60() +func t61() +func t62() +func t63() +func t64() +func t65() +func t66() +func t67() +func t68() +func t69() +func t70() +func t71() +func t72() +func t73() +func t74() +func t75() +func t76() +func t77() +func t78() +func t79() +func t80() +func t81() +func t82() +func t83() +func t84() +func t85() +func t86() +func t87() +func t88() +func t89() +func t90() +func t91() +func t92() +func t93() +func t94() +func t95() +func t96() +func t97() +func t98() +func t99() +func t100() +func t101() +func t102() +func t103() +func t104() +func t105() +func t106() +func t107() +func t108() +func t109() +func t110() +func t111() +func t112() +func t113() +func t114() +func t115() +func t116() +func t117() +func t118() +func t119() +func t120() +func t121() +func t122() +func t123() +func t124() +func t125() +func t126() +func t127() +func t128() +func t129() +func t130() +func t131() +func t132() +func t133() +func t134() +func t135() +func t136() +func t137() +func t138() +func t139() +func t140() +func t141() +func t142() +func t143() +func t144() +func t145() +func t146() +func t147() +func t148() +func t149() +func t150() +func t151() +func t152() +func t153() +func t154() +func t155() +func t156() +func t157() +func t158() +func t159() +func t160() +func t161() +func t162() +func t163() +func t164() +func t165() +func t166() +func t167() +func t168() +func t169() +func t170() +func t171() +func t172() +func t173() +func t174() +func t175() +func t176() +func t177() +func t178() +func t179() +func t180() +func t181() +func t182() +func t183() +func t184() +func t185() +func t186() +func t187() +func t188() +func t189() +func t190() +func t191() +func t192() +func t193() +func t194() +func t195() +func t196() +func t197() +func t198() +func t199() +func t200() +func t201() +func t202() +func t203() +func t204() +func t205() +func t206() +func t207() +func t208() +func t209() +func t210() +func t211() +func t212() +func t213() +func t214() +func t215() +func t216() +func t217() +func t218() +func t219() +func t220() +func t221() +func t222() +func t223() +func t224() +func t225() +func t226() +func t227() +func t228() +func t229() +func t230() +func t231() +func t232() +func t233() +func t234() +func t235() +func t236() +func t237() +func t238() +func t239() +func t240() +func t241() +func t242() +func t243() +func t244() +func t245() +func t246() +func t247() +func t248() +func t249() +func t250() +func t251() +func t252() +func t253() +func t254() + +-- a.s -- +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +TEXT ·t0(SB),0,$0 + RET + +TEXT ·t1(SB),0,$0 + RET + +TEXT ·t2(SB),0,$0 + RET + +TEXT ·t3(SB),0,$0 + RET + +TEXT ·t4(SB),0,$0 + RET + +TEXT ·t5(SB),0,$0 + RET + +TEXT ·t6(SB),0,$0 + RET + +TEXT ·t7(SB),0,$0 + RET + +TEXT ·t8(SB),0,$0 + RET + +TEXT ·t9(SB),0,$0 + RET + +TEXT ·t10(SB),0,$0 + RET + +TEXT ·t11(SB),0,$0 + RET + +TEXT ·t12(SB),0,$0 + RET + +TEXT ·t13(SB),0,$0 + RET + +TEXT ·t14(SB),0,$0 + RET + +TEXT ·t15(SB),0,$0 + RET + +TEXT ·t16(SB),0,$0 + RET + +TEXT ·t17(SB),0,$0 + RET + +TEXT ·t18(SB),0,$0 + RET + +TEXT ·t19(SB),0,$0 + RET + +TEXT ·t20(SB),0,$0 + RET + +TEXT ·t21(SB),0,$0 + RET + +TEXT ·t22(SB),0,$0 + RET + +TEXT ·t23(SB),0,$0 + RET + +TEXT ·t24(SB),0,$0 + RET + +TEXT ·t25(SB),0,$0 + RET + +TEXT ·t26(SB),0,$0 + RET + +TEXT ·t27(SB),0,$0 + RET + +TEXT ·t28(SB),0,$0 + RET + +TEXT ·t29(SB),0,$0 + RET + +TEXT ·t30(SB),0,$0 + RET + +TEXT ·t31(SB),0,$0 + RET + +TEXT ·t32(SB),0,$0 + RET + +TEXT ·t33(SB),0,$0 + RET + +TEXT ·t34(SB),0,$0 + RET + +TEXT ·t35(SB),0,$0 + RET + +TEXT ·t36(SB),0,$0 + RET + +TEXT ·t37(SB),0,$0 + RET + +TEXT ·t38(SB),0,$0 + RET + +TEXT ·t39(SB),0,$0 + RET + +TEXT ·t40(SB),0,$0 + RET + +TEXT ·t41(SB),0,$0 + RET + +TEXT ·t42(SB),0,$0 + RET + +TEXT ·t43(SB),0,$0 + RET + +TEXT ·t44(SB),0,$0 + RET + +TEXT ·t45(SB),0,$0 + RET + +TEXT ·t46(SB),0,$0 + RET + +TEXT ·t47(SB),0,$0 + RET + +TEXT ·t48(SB),0,$0 + RET + +TEXT ·t49(SB),0,$0 + RET + +TEXT ·t50(SB),0,$0 + RET + +TEXT ·t51(SB),0,$0 + RET + +TEXT ·t52(SB),0,$0 + RET + +TEXT ·t53(SB),0,$0 + RET + +TEXT ·t54(SB),0,$0 + RET + +TEXT ·t55(SB),0,$0 + RET + +TEXT ·t56(SB),0,$0 + RET + +TEXT ·t57(SB),0,$0 + RET + +TEXT ·t58(SB),0,$0 + RET + +TEXT ·t59(SB),0,$0 + RET + +TEXT ·t60(SB),0,$0 + RET + +TEXT ·t61(SB),0,$0 + RET + +TEXT ·t62(SB),0,$0 + RET + +TEXT ·t63(SB),0,$0 + RET + +TEXT ·t64(SB),0,$0 + RET + +TEXT ·t65(SB),0,$0 + RET + +TEXT ·t66(SB),0,$0 + RET + +TEXT ·t67(SB),0,$0 + RET + +TEXT ·t68(SB),0,$0 + RET + +TEXT ·t69(SB),0,$0 + RET + +TEXT ·t70(SB),0,$0 + RET + +TEXT ·t71(SB),0,$0 + RET + +TEXT ·t72(SB),0,$0 + RET + +TEXT ·t73(SB),0,$0 + RET + +TEXT ·t74(SB),0,$0 + RET + +TEXT ·t75(SB),0,$0 + RET + +TEXT ·t76(SB),0,$0 + RET + +TEXT ·t77(SB),0,$0 + RET + +TEXT ·t78(SB),0,$0 + RET + +TEXT ·t79(SB),0,$0 + RET + +TEXT ·t80(SB),0,$0 + RET + +TEXT ·t81(SB),0,$0 + RET + +TEXT ·t82(SB),0,$0 + RET + +TEXT ·t83(SB),0,$0 + RET + +TEXT ·t84(SB),0,$0 + RET + +TEXT ·t85(SB),0,$0 + RET + +TEXT ·t86(SB),0,$0 + RET + +TEXT ·t87(SB),0,$0 + RET + +TEXT ·t88(SB),0,$0 + RET + +TEXT ·t89(SB),0,$0 + RET + +TEXT ·t90(SB),0,$0 + RET + +TEXT ·t91(SB),0,$0 + RET + +TEXT ·t92(SB),0,$0 + RET + +TEXT ·t93(SB),0,$0 + RET + +TEXT ·t94(SB),0,$0 + RET + +TEXT ·t95(SB),0,$0 + RET + +TEXT ·t96(SB),0,$0 + RET + +TEXT ·t97(SB),0,$0 + RET + +TEXT ·t98(SB),0,$0 + RET + +TEXT ·t99(SB),0,$0 + RET + +TEXT ·t100(SB),0,$0 + RET + +TEXT ·t101(SB),0,$0 + RET + +TEXT ·t102(SB),0,$0 + RET + +TEXT ·t103(SB),0,$0 + RET + +TEXT ·t104(SB),0,$0 + RET + +TEXT ·t105(SB),0,$0 + RET + +TEXT ·t106(SB),0,$0 + RET + +TEXT ·t107(SB),0,$0 + RET + +TEXT ·t108(SB),0,$0 + RET + +TEXT ·t109(SB),0,$0 + RET + +TEXT ·t110(SB),0,$0 + RET + +TEXT ·t111(SB),0,$0 + RET + +TEXT ·t112(SB),0,$0 + RET + +TEXT ·t113(SB),0,$0 + RET + +TEXT ·t114(SB),0,$0 + RET + +TEXT ·t115(SB),0,$0 + RET + +TEXT ·t116(SB),0,$0 + RET + +TEXT ·t117(SB),0,$0 + RET + +TEXT ·t118(SB),0,$0 + RET + +TEXT ·t119(SB),0,$0 + RET + +TEXT ·t120(SB),0,$0 + RET + +TEXT ·t121(SB),0,$0 + RET + +TEXT ·t122(SB),0,$0 + RET + +TEXT ·t123(SB),0,$0 + RET + +TEXT ·t124(SB),0,$0 + RET + +TEXT ·t125(SB),0,$0 + RET + +TEXT ·t126(SB),0,$0 + RET + +TEXT ·t127(SB),0,$0 + RET + +TEXT ·t128(SB),0,$0 + RET + +TEXT ·t129(SB),0,$0 + RET + +TEXT ·t130(SB),0,$0 + RET + +TEXT ·t131(SB),0,$0 + RET + +TEXT ·t132(SB),0,$0 + RET + +TEXT ·t133(SB),0,$0 + RET + +TEXT ·t134(SB),0,$0 + RET + +TEXT ·t135(SB),0,$0 + RET + +TEXT ·t136(SB),0,$0 + RET + +TEXT ·t137(SB),0,$0 + RET + +TEXT ·t138(SB),0,$0 + RET + +TEXT ·t139(SB),0,$0 + RET + +TEXT ·t140(SB),0,$0 + RET + +TEXT ·t141(SB),0,$0 + RET + +TEXT ·t142(SB),0,$0 + RET + +TEXT ·t143(SB),0,$0 + RET + +TEXT ·t144(SB),0,$0 + RET + +TEXT ·t145(SB),0,$0 + RET + +TEXT ·t146(SB),0,$0 + RET + +TEXT ·t147(SB),0,$0 + RET + +TEXT ·t148(SB),0,$0 + RET + +TEXT ·t149(SB),0,$0 + RET + +TEXT ·t150(SB),0,$0 + RET + +TEXT ·t151(SB),0,$0 + RET + +TEXT ·t152(SB),0,$0 + RET + +TEXT ·t153(SB),0,$0 + RET + +TEXT ·t154(SB),0,$0 + RET + +TEXT ·t155(SB),0,$0 + RET + +TEXT ·t156(SB),0,$0 + RET + +TEXT ·t157(SB),0,$0 + RET + +TEXT ·t158(SB),0,$0 + RET + +TEXT ·t159(SB),0,$0 + RET + +TEXT ·t160(SB),0,$0 + RET + +TEXT ·t161(SB),0,$0 + RET + +TEXT ·t162(SB),0,$0 + RET + +TEXT ·t163(SB),0,$0 + RET + +TEXT ·t164(SB),0,$0 + RET + +TEXT ·t165(SB),0,$0 + RET + +TEXT ·t166(SB),0,$0 + RET + +TEXT ·t167(SB),0,$0 + RET + +TEXT ·t168(SB),0,$0 + RET + +TEXT ·t169(SB),0,$0 + RET + +TEXT ·t170(SB),0,$0 + RET + +TEXT ·t171(SB),0,$0 + RET + +TEXT ·t172(SB),0,$0 + RET + +TEXT ·t173(SB),0,$0 + RET + +TEXT ·t174(SB),0,$0 + RET + +TEXT ·t175(SB),0,$0 + RET + +TEXT ·t176(SB),0,$0 + RET + +TEXT ·t177(SB),0,$0 + RET + +TEXT ·t178(SB),0,$0 + RET + +TEXT ·t179(SB),0,$0 + RET + +TEXT ·t180(SB),0,$0 + RET + +TEXT ·t181(SB),0,$0 + RET + +TEXT ·t182(SB),0,$0 + RET + +TEXT ·t183(SB),0,$0 + RET + +TEXT ·t184(SB),0,$0 + RET + +TEXT ·t185(SB),0,$0 + RET + +TEXT ·t186(SB),0,$0 + RET + +TEXT ·t187(SB),0,$0 + RET + +TEXT ·t188(SB),0,$0 + RET + +TEXT ·t189(SB),0,$0 + RET + +TEXT ·t190(SB),0,$0 + RET + +TEXT ·t191(SB),0,$0 + RET + +TEXT ·t192(SB),0,$0 + RET + +TEXT ·t193(SB),0,$0 + RET + +TEXT ·t194(SB),0,$0 + RET + +TEXT ·t195(SB),0,$0 + RET + +TEXT ·t196(SB),0,$0 + RET + +TEXT ·t197(SB),0,$0 + RET + +TEXT ·t198(SB),0,$0 + RET + +TEXT ·t199(SB),0,$0 + RET + +TEXT ·t200(SB),0,$0 + RET + +TEXT ·t201(SB),0,$0 + RET + +TEXT ·t202(SB),0,$0 + RET + +TEXT ·t203(SB),0,$0 + RET + +TEXT ·t204(SB),0,$0 + RET + +TEXT ·t205(SB),0,$0 + RET + +TEXT ·t206(SB),0,$0 + RET + +TEXT ·t207(SB),0,$0 + RET + +TEXT ·t208(SB),0,$0 + RET + +TEXT ·t209(SB),0,$0 + RET + +TEXT ·t210(SB),0,$0 + RET + +TEXT ·t211(SB),0,$0 + RET + +TEXT ·t212(SB),0,$0 + RET + +TEXT ·t213(SB),0,$0 + RET + +TEXT ·t214(SB),0,$0 + RET + +TEXT ·t215(SB),0,$0 + RET + +TEXT ·t216(SB),0,$0 + RET + +TEXT ·t217(SB),0,$0 + RET + +TEXT ·t218(SB),0,$0 + RET + +TEXT ·t219(SB),0,$0 + RET + +TEXT ·t220(SB),0,$0 + RET + +TEXT ·t221(SB),0,$0 + RET + +TEXT ·t222(SB),0,$0 + RET + +TEXT ·t223(SB),0,$0 + RET + +TEXT ·t224(SB),0,$0 + RET + +TEXT ·t225(SB),0,$0 + RET + +TEXT ·t226(SB),0,$0 + RET + +TEXT ·t227(SB),0,$0 + RET + +TEXT ·t228(SB),0,$0 + RET + +TEXT ·t229(SB),0,$0 + RET + +TEXT ·t230(SB),0,$0 + RET + +TEXT ·t231(SB),0,$0 + RET + +TEXT ·t232(SB),0,$0 + RET + +TEXT ·t233(SB),0,$0 + RET + +TEXT ·t234(SB),0,$0 + RET + +TEXT ·t235(SB),0,$0 + RET + +TEXT ·t236(SB),0,$0 + RET + +TEXT ·t237(SB),0,$0 + RET + +TEXT ·t238(SB),0,$0 + RET + +TEXT ·t239(SB),0,$0 + RET + +TEXT ·t240(SB),0,$0 + RET + +TEXT ·t241(SB),0,$0 + RET + +TEXT ·t242(SB),0,$0 + RET + +TEXT ·t243(SB),0,$0 + RET + +TEXT ·t244(SB),0,$0 + RET + +TEXT ·t245(SB),0,$0 + RET + +TEXT ·t246(SB),0,$0 + RET + +TEXT ·t247(SB),0,$0 + RET + +TEXT ·t248(SB),0,$0 + RET + +TEXT ·t249(SB),0,$0 + RET + +TEXT ·t250(SB),0,$0 + RET + +TEXT ·t251(SB),0,$0 + RET + +TEXT ·t252(SB),0,$0 + RET + +TEXT ·t253(SB),0,$0 + RET + +TEXT ·t254(SB),0,$0 + RET + +-- gen.sh -- +#!/bin/sh +# Generator script (for posterity, in case we need to +# recreate or modify). +N=255 +function cophdr() { + local F=$1 + cat > $F <> a.go +echo "func main() { " >> a.go +I=0 +while [ $I -lt $N ]; do + echo " t${I}()" >> a.go + I=`expr $I + 1` +done +echo "}" >> a.go +go +echo >> a.go +I=0 +while [ $I -lt $N ]; do + echo "func t${I}() " >> a.go + I=`expr $I + 1` +done +#SALT=`date '+%Y%M%d%h%m%s'` +#echo "var foofoo = \"${SALT}\"" >> a.go +gofmt -w a.go +# +# Assembly sources +# +cophdr a.s +I=0 +while [ $I -lt $N ]; do + echo "TEXT ·t${I}(SB),0,\$0" >> a.s + echo " RET" >> a.s + echo >> a.s + I=`expr $I + 1` +done diff --git a/go/src/cmd/compile/testdata/script/embedbad.txt b/go/src/cmd/compile/testdata/script/embedbad.txt new file mode 100644 index 0000000000000000000000000000000000000000..09e4254561690a2c1ac970d34ee53c56968d8f54 --- /dev/null +++ b/go/src/cmd/compile/testdata/script/embedbad.txt @@ -0,0 +1,19 @@ +# Check that compiler does not silently crash at bad embed error. + +! go build +stderr 'multiple files for type string' +stderr 'multiple files for type \[\]byte' + +-- go.mod -- +module m + +-- x.go -- +package p + +import _ "embed" + +//go:embed x.go go.mod +var s string + +//go:embed x.go go.mod +var b []byte diff --git a/go/src/cmd/compile/testdata/script/issue70173.txt b/go/src/cmd/compile/testdata/script/issue70173.txt new file mode 100644 index 0000000000000000000000000000000000000000..20d4b4fcbe9689aabeb737e727b7b8702341e6a1 --- /dev/null +++ b/go/src/cmd/compile/testdata/script/issue70173.txt @@ -0,0 +1,23 @@ +go run main.go +! stdout . +! stderr . + +-- main.go -- + +package main + +func main() { + switch { + case true: + _: + fallthrough + default: + } + switch { + case true: + _: + _: + fallthrough + default: + } +} diff --git a/go/src/cmd/compile/testdata/script/issue73947.txt b/go/src/cmd/compile/testdata/script/issue73947.txt new file mode 100644 index 0000000000000000000000000000000000000000..f888ae2bfa5e04cf45f5463e2d5d1dd23349a618 --- /dev/null +++ b/go/src/cmd/compile/testdata/script/issue73947.txt @@ -0,0 +1,125 @@ +go build main.go +! stdout . +! stderr . + +-- main.go -- + +package main + +import ( + "p/b" +) + +func main() { + f() +} + +func f() { + typ := indexedPageType{newIndexedType(nil)} + page := newPage(typ.indexedType) + page.Data() +} + +func newPage(typ *indexedType) Page { + values := typ.NewValues(nil, nil) + return &indexedPage{ + typ: typ, + values: values.Int32(), + columnIndex: ^0, + } +} + +type Type interface { + NewPage(columnIndex, numValues int, data b.Values) Page + NewValues(values []byte, offsets []uint32) b.Values +} + +type Page interface { + Type() Type + Data() b.Values +} + +type indexedPage struct { + typ *indexedType + values []int32 + columnIndex int16 +} + +func (page *indexedPage) Type() Type { return indexedPageType{page.typ} } + +func (page *indexedPage) Data() b.Values { return b.Int32Values(page.values) } + +type indexedType struct { + Type +} + +func newIndexedType(typ Type) *indexedType { + return &indexedType{Type: typ} +} + +type indexedPageType struct{ *indexedType } + +func (t indexedPageType) NewValues(values []byte, _ []uint32) b.Values { + return b.Int32ValuesFromBytes(values) +} + +-- go.mod -- +module p + +go 1.24 + +-- internal/a/a.go -- +package a + +import "unsafe" + +type slice struct { + ptr unsafe.Pointer + len int + cap int +} + +func Slice[To, From any](data []From) []To { + // This function could use unsafe.Slice but it would drop the capacity + // information, so instead we implement the type conversion. + var zf From + var zt To + var s = slice{ + ptr: unsafe.Pointer(unsafe.SliceData(data)), + len: int((uintptr(len(data)) * unsafe.Sizeof(zf)) / unsafe.Sizeof(zt)), + cap: int((uintptr(cap(data)) * unsafe.Sizeof(zf)) / unsafe.Sizeof(zt)), + } + return *(*[]To)(unsafe.Pointer(&s)) +} + +-- b/b.go -- +package b + +import "p/internal/a" + +type Kind int32 + +const Int32 Kind = iota + 2 + +type Values struct { + kind Kind + size int32 + data []byte + offsets []uint32 +} + +func (v *Values) Int32() []int32 { + return a.Slice[int32](v.data) +} + +func makeValues[T any](kind Kind, values []T) Values { + return Values{kind: kind, data: a.Slice[byte](values)} +} + +func Int32Values(values []int32) Values { + return makeValues(Int32, values) +} + +func Int32ValuesFromBytes(values []byte) Values { + return Values{kind: Int32, data: values} +} diff --git a/go/src/cmd/compile/testdata/script/issue75461.txt b/go/src/cmd/compile/testdata/script/issue75461.txt new file mode 100644 index 0000000000000000000000000000000000000000..05f0fd4cfae3043352934cf1e625dd8c823aea03 --- /dev/null +++ b/go/src/cmd/compile/testdata/script/issue75461.txt @@ -0,0 +1,78 @@ +go build main.go +! stdout . +! stderr . + +-- main.go -- +package main + +import ( + "demo/registry" +) + +func main() { + _ = registry.NewUserRegistry() +} + +-- go.mod -- +module demo + +go 1.24 + +-- model/user.go -- +package model + +type User struct { + ID int +} + +func (c *User) String() string { + return "" +} + +-- ordered/map.go -- +package ordered + +type OrderedMap[K comparable, V any] struct { + m map[K]V +} + +func New[K comparable, V any](options ...any) *OrderedMap[K, V] { + orderedMap := &OrderedMap[K, V]{} + return orderedMap +} + +-- registry/user.go -- +package registry + +import ( + "demo/model" + "demo/ordered" +) + +type baseRegistry = Registry[model.User, *model.User] + +type UserRegistry struct { + *baseRegistry +} + +type Registry[T any, P PStringer[T]] struct { + m *ordered.OrderedMap[string, P] +} + +type PStringer[T any] interface { + *T + String() string +} + +func NewRegistry[T any, P PStringer[T]]() *Registry[T, P] { + r := &Registry[T, P]{ + m: ordered.New[string, P](), + } + return r +} + +func NewUserRegistry() *UserRegistry { + return &UserRegistry{ + baseRegistry: NewRegistry[model.User](), + } +} diff --git a/go/src/cmd/compile/testdata/script/issue77033.txt b/go/src/cmd/compile/testdata/script/issue77033.txt new file mode 100644 index 0000000000000000000000000000000000000000..3b977e54401e4f00e022d8dd86e915824f04aeb8 --- /dev/null +++ b/go/src/cmd/compile/testdata/script/issue77033.txt @@ -0,0 +1,40 @@ +go test -bench=Foo -cpuprofile=default.pgo +go test -bench=Foo -pgo=default.pgo +! stdout 'FAIL' + +-- main_test.go -- +package main + +import ( + "testing" +) + +var a int + +func save(x int) { + a = x +} + +func foo() { + for i := range yield1 { + defer save(i) + } +} + +func yield1(yield func(int) bool) { + yield(1) +} + +func BenchmarkFoo(b *testing.B) { + for i := 0; i < b.N; i++ { + foo() + } + if a != 1 { + b.Fatalf("a = %d; want 1", a) + } +} + +-- go.mod -- +module demo + +go 1.24 diff --git a/go/src/cmd/compile/testdata/script/script_test_basics.txt b/go/src/cmd/compile/testdata/script/script_test_basics.txt new file mode 100644 index 0000000000000000000000000000000000000000..7fe99dbbc2f042aa514fdecb9443114fbc307c13 --- /dev/null +++ b/go/src/cmd/compile/testdata/script/script_test_basics.txt @@ -0,0 +1,25 @@ + +# Test of the linker's script test harness. + +go build +[!cgo] skip +cc -c testdata/mumble.c +[GOEXPERIMENT:fieldtrack] help exec + +-- go.mod -- +module main + +go 1.20 + +-- main.go -- +package main + +func main() { + println("Hi mom!") +} + +-- testdata/mumble.c -- + +int x; + + diff --git a/go/src/cmd/covdata/testdata/dep.go b/go/src/cmd/covdata/testdata/dep.go new file mode 100644 index 0000000000000000000000000000000000000000..2127ab24f6acdbbf9a00ad8a7de7122bee449c80 --- /dev/null +++ b/go/src/cmd/covdata/testdata/dep.go @@ -0,0 +1,17 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package dep + +func Dep1() int { + return 42 +} + +func PDep(x int) { + if x != 1010101 { + println(x) + } else { + panic("bad") + } +} diff --git a/go/src/cmd/covdata/testdata/prog1.go b/go/src/cmd/covdata/testdata/prog1.go new file mode 100644 index 0000000000000000000000000000000000000000..76e9e912cc3929b8ff2a64b60278f5614d384588 --- /dev/null +++ b/go/src/cmd/covdata/testdata/prog1.go @@ -0,0 +1,48 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "os" + "prog/dep" +) + +//go:noinline +func first() { + println("whee") +} + +//go:noinline +func second() { + println("oy") +} + +//go:noinline +func third(x int) int { + if x != 0 { + return 42 + } + println("blarg") + return 0 +} + +//go:noinline +func fourth() int { + return 99 +} + +func main() { + println(dep.Dep1()) + dep.PDep(2) + if len(os.Args) > 1 { + second() + third(1) + } else if len(os.Args) > 2 { + fourth() + } else { + first() + third(0) + } +} diff --git a/go/src/cmd/covdata/testdata/prog2.go b/go/src/cmd/covdata/testdata/prog2.go new file mode 100644 index 0000000000000000000000000000000000000000..e51e78672bb8ea0447b4690fc825fde0e70eec64 --- /dev/null +++ b/go/src/cmd/covdata/testdata/prog2.go @@ -0,0 +1,29 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "os" + "prog/dep" +) + +//go:noinline +func fifth() { + println("hubba") +} + +//go:noinline +func sixth() { + println("wha?") +} + +func main() { + println(dep.Dep1()) + if len(os.Args) > 1 { + fifth() + } else { + sixth() + } +} diff --git a/go/src/cmd/cover/testdata/directives.go b/go/src/cmd/cover/testdata/directives.go new file mode 100644 index 0000000000000000000000000000000000000000..dfb7b8ec33fa86e192ff9c46fa1e5cc5d3ba6db6 --- /dev/null +++ b/go/src/cmd/cover/testdata/directives.go @@ -0,0 +1,40 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file is processed by the cover command, then a test verifies that +// all compiler directives are preserved and positioned appropriately. + +//go:a + +//go:b +package main + +//go:c1 + +//go:c2 +//doc +func c() { +} + +//go:d1 + +//doc +//go:d2 +type d int + +//go:e1 + +//doc +//go:e2 +type ( + e int + f int +) + +//go:_empty1 +//doc +//go:_empty2 +type () + +//go:f diff --git a/go/src/cmd/cover/testdata/html/html.go b/go/src/cmd/cover/testdata/html/html.go new file mode 100644 index 0000000000000000000000000000000000000000..20578259a5c826859bdcdda7bdef5e89fbc8b78c --- /dev/null +++ b/go/src/cmd/cover/testdata/html/html.go @@ -0,0 +1,30 @@ +package html + +import "fmt" + +// This file is tested by html_test.go. +// The comments below are markers for extracting the annotated source +// from the HTML output. + +// This is a regression test for incorrect sorting of boundaries +// that coincide, specifically for empty select clauses. +// START f +func f() { + ch := make(chan int) + select { + case <-ch: + default: + } +} + +// END f + +// https://golang.org/issue/25767 +// START g +func g() { + if false { + fmt.Printf("Hello") + } +} + +// END g diff --git a/go/src/cmd/cover/testdata/html/html.golden b/go/src/cmd/cover/testdata/html/html.golden new file mode 100644 index 0000000000000000000000000000000000000000..84377d1e2035a93485605e123a2d742613d7c625 --- /dev/null +++ b/go/src/cmd/cover/testdata/html/html.golden @@ -0,0 +1,18 @@ +// START f +func f() { + ch := make(chan int) + select { + case <-ch: + default: + } +} + +// END f +// START g +func g() { + if false { + fmt.Printf("Hello") + } +} + +// END g diff --git a/go/src/cmd/cover/testdata/html/html_test.go b/go/src/cmd/cover/testdata/html/html_test.go new file mode 100644 index 0000000000000000000000000000000000000000..c15561fe4a92fd9e743b1b81dd08292157ae3d45 --- /dev/null +++ b/go/src/cmd/cover/testdata/html/html_test.go @@ -0,0 +1,8 @@ +package html + +import "testing" + +func TestAll(t *testing.T) { + f() + g() +} diff --git a/go/src/cmd/cover/testdata/main.go b/go/src/cmd/cover/testdata/main.go new file mode 100644 index 0000000000000000000000000000000000000000..be74b4aa6559422f6aa33ddf1152a88e5627347b --- /dev/null +++ b/go/src/cmd/cover/testdata/main.go @@ -0,0 +1,116 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test runner for coverage test. This file is not coverage-annotated; test.go is. +// It knows the coverage counter is called +// "thisNameMustBeVeryLongToCauseOverflowOfCounterIncrementStatementOntoNextLineForTest". + +package main + +import ( + "fmt" + "os" +) + +func main() { + testAll() + verify() +} + +type block struct { + count uint32 + line uint32 +} + +var counters = make(map[block]bool) + +// shorthand for the long counter variable. +var coverTest = &thisNameMustBeVeryLongToCauseOverflowOfCounterIncrementStatementOntoNextLineForTest + +// check records the location and expected value for a counter. +func check(line, count uint32) { + b := block{ + count, + line, + } + counters[b] = true +} + +// checkVal is a version of check that returns its extra argument, +// so it can be used in conditionals. +func checkVal(line, count uint32, val int) int { + b := block{ + count, + line, + } + counters[b] = true + return val +} + +var PASS = true + +// verify checks the expected counts against the actual. It runs after the test has completed. +func verify() { + for b := range counters { + got, index := count(b.line) + if b.count == anything && got != 0 { + got = anything + } + if got != b.count { + fmt.Fprintf(os.Stderr, "test_go:%d expected count %d got %d [counter %d]\n", b.line, b.count, got, index) + PASS = false + } + } + verifyPanic() + if !PASS { + fmt.Fprintf(os.Stderr, "FAIL\n") + os.Exit(2) + } +} + +// verifyPanic is a special check for the known counter that should be +// after the panic call in testPanic. +func verifyPanic() { + if coverTest.Count[panicIndex-1] != 1 { + // Sanity check for test before panic. + fmt.Fprintf(os.Stderr, "bad before panic") + PASS = false + } + if coverTest.Count[panicIndex] != 0 { + fmt.Fprintf(os.Stderr, "bad at panic: %d should be 0\n", coverTest.Count[panicIndex]) + PASS = false + } + if coverTest.Count[panicIndex+1] != 1 { + fmt.Fprintf(os.Stderr, "bad after panic") + PASS = false + } +} + +// count returns the count and index for the counter at the specified line. +func count(line uint32) (uint32, int) { + // Linear search is fine. Choose perfect fit over approximate. + // We can have a closing brace for a range on the same line as a condition for an "else if" + // and we don't want that brace to steal the count for the condition on the "if". + // Therefore we test for a perfect (lo==line && hi==line) match, but if we can't + // find that we take the first imperfect match. + index := -1 + indexLo := uint32(1e9) + for i := range coverTest.Count { + lo, hi := coverTest.Pos[3*i], coverTest.Pos[3*i+1] + if lo == line && line == hi { + return coverTest.Count[i], i + } + // Choose the earliest match (the counters are in unpredictable order). + if lo <= line && line <= hi && indexLo > lo { + index = i + indexLo = lo + } + } + if index == -1 { + fmt.Fprintln(os.Stderr, "cover_test: no counter for line", line) + PASS = false + return 0, 0 + } + return coverTest.Count[index], index +} diff --git a/go/src/cmd/cover/testdata/p.go b/go/src/cmd/cover/testdata/p.go new file mode 100644 index 0000000000000000000000000000000000000000..ce3a8c061206f0210cc698ec5964404170197f1a --- /dev/null +++ b/go/src/cmd/cover/testdata/p.go @@ -0,0 +1,27 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// A package such that there are 3 functions with zero total and covered lines. +// And one with 1 total and covered lines. Reproduces issue #20515. +package p + +//go:noinline +func A() { + +} + +//go:noinline +func B() { + +} + +//go:noinline +func C() { + +} + +//go:noinline +func D() int64 { + return 42 +} diff --git a/go/src/cmd/cover/testdata/pkgcfg/a/a.go b/go/src/cmd/cover/testdata/pkgcfg/a/a.go new file mode 100644 index 0000000000000000000000000000000000000000..44c380b37930c4d3f05158536ec65728adf80b73 --- /dev/null +++ b/go/src/cmd/cover/testdata/pkgcfg/a/a.go @@ -0,0 +1,28 @@ +package a + +type Atyp int + +func (ap *Atyp) Set(q int) { + *ap = Atyp(q) +} + +func (ap Atyp) Get() int { + inter := func(q Atyp) int { + return int(q) + } + return inter(ap) +} + +var afunc = func(x int) int { + return x + 1 +} +var Avar = afunc(42) + +func A(x int) int { + if x == 0 { + return 22 + } else if x == 1 { + return 33 + } + return 44 +} diff --git a/go/src/cmd/cover/testdata/pkgcfg/a/a2.go b/go/src/cmd/cover/testdata/pkgcfg/a/a2.go new file mode 100644 index 0000000000000000000000000000000000000000..e6b2fc10f7a056fe75949c7c61bcf08ff2e41f22 --- /dev/null +++ b/go/src/cmd/cover/testdata/pkgcfg/a/a2.go @@ -0,0 +1,8 @@ +package a + +func A2() { + { + } + { + } +} diff --git a/go/src/cmd/cover/testdata/pkgcfg/a/a_test.go b/go/src/cmd/cover/testdata/pkgcfg/a/a_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a1608e0bdd9020da4993f7318be8853e730e159d --- /dev/null +++ b/go/src/cmd/cover/testdata/pkgcfg/a/a_test.go @@ -0,0 +1,14 @@ +package a_test + +import ( + "cfg/a" + "testing" +) + +func TestA(t *testing.T) { + a.A(0) + var aat a.Atyp + at := &aat + at.Set(42) + println(at.Get()) +} diff --git a/go/src/cmd/cover/testdata/pkgcfg/noFuncsNoTests/nfnt.go b/go/src/cmd/cover/testdata/pkgcfg/noFuncsNoTests/nfnt.go new file mode 100644 index 0000000000000000000000000000000000000000..52df23c8c9dfba0b244c26380fcef2c40063b803 --- /dev/null +++ b/go/src/cmd/cover/testdata/pkgcfg/noFuncsNoTests/nfnt.go @@ -0,0 +1,8 @@ +package noFuncsNoTests + +const foo = 1 + +var G struct { + x int + y bool +} diff --git a/go/src/cmd/cover/testdata/pkgcfg/yesFuncsNoTests/yfnt.go b/go/src/cmd/cover/testdata/pkgcfg/yesFuncsNoTests/yfnt.go new file mode 100644 index 0000000000000000000000000000000000000000..4e536b043867ea6891ddaff70a81f1727173a213 --- /dev/null +++ b/go/src/cmd/cover/testdata/pkgcfg/yesFuncsNoTests/yfnt.go @@ -0,0 +1,13 @@ +package yesFuncsNoTests + +func F1() { + println("hi") +} + +func F2(x int) int { + if x < 0 { + return 9 + } else { + return 10 + } +} diff --git a/go/src/cmd/cover/testdata/profile.cov b/go/src/cmd/cover/testdata/profile.cov new file mode 100644 index 0000000000000000000000000000000000000000..db08602d5abb8c65c930d6e73a792eb83505a2de --- /dev/null +++ b/go/src/cmd/cover/testdata/profile.cov @@ -0,0 +1,5 @@ +mode: set +./testdata/p.go:10.10,12.2 0 0 +./testdata/p.go:15.10,17.2 0 0 +./testdata/p.go:20.10,22.2 0 0 +./testdata/p.go:25.16,27.2 1 1 diff --git a/go/src/cmd/cover/testdata/test.go b/go/src/cmd/cover/testdata/test.go new file mode 100644 index 0000000000000000000000000000000000000000..0e1dbc61943112cda78141572962d9434d7f7618 --- /dev/null +++ b/go/src/cmd/cover/testdata/test.go @@ -0,0 +1,300 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This program is processed by the cover command, and then testAll is called. +// The test driver in main.go can then compare the coverage statistics with expectation. + +// The word LINE is replaced by the line number in this file. When the file is executed, +// the coverage processing has changed the line numbers, so we can't use runtime.Caller. + +package main + +import _ "unsafe" // for go:linkname + +//go:linkname some_name some_name +var some_name int + +const anything = 1e9 // Just some unlikely value that means "we got here, don't care how often" + +func testAll() { + testSimple() + testBlockRun() + testIf() + testFor() + testRange() + testSwitch() + testTypeSwitch() + testSelect1() + testSelect2() + testPanic() + testEmptySwitches() + testFunctionLiteral() + testGoto() +} + +// The indexes of the counters in testPanic are known to main.go +const panicIndex = 3 + +// This test appears first because the index of its counters is known to main.go +func testPanic() { + defer func() { + recover() + }() + check(LINE, 1) + panic("should not get next line") + check(LINE, 0) // this is GoCover.Count[panicIndex] + // The next counter is in testSimple and it will be non-zero. + // If the panic above does not trigger a counter, the test will fail + // because GoCover.Count[panicIndex] will be the one in testSimple. +} + +func testSimple() { + check(LINE, 1) +} + +func testIf() { + if true { + check(LINE, 1) + } else { + check(LINE, 0) + } + if false { + check(LINE, 0) + } else { + check(LINE, 1) + } + for i := 0; i < 3; i++ { + if checkVal(LINE, 3, i) <= 2 { + check(LINE, 3) + } + if checkVal(LINE, 3, i) <= 1 { + check(LINE, 2) + } + if checkVal(LINE, 3, i) <= 0 { + check(LINE, 1) + } + } + for i := 0; i < 3; i++ { + if checkVal(LINE, 3, i) <= 1 { + check(LINE, 2) + } else { + check(LINE, 1) + } + } + for i := 0; i < 3; i++ { + if checkVal(LINE, 3, i) <= 0 { + check(LINE, 1) + } else if checkVal(LINE, 2, i) <= 1 { + check(LINE, 1) + } else if checkVal(LINE, 1, i) <= 2 { + check(LINE, 1) + } else if checkVal(LINE, 0, i) <= 3 { + check(LINE, 0) + } + } + if func(a, b int) bool { return a < b }(3, 4) { + check(LINE, 1) + } +} + +func testFor() { + for i := 0; i < 10; func() { i++; check(LINE, 10) }() { + check(LINE, 10) + } +} + +func testRange() { + for _, f := range []func(){ + func() { check(LINE, 1) }, + } { + f() + check(LINE, 1) + } +} + +func testBlockRun() { + check(LINE, 1) + { + check(LINE, 1) + } + { + check(LINE, 1) + } + check(LINE, 1) + { + check(LINE, 1) + } + { + check(LINE, 1) + } + check(LINE, 1) +} + +func testSwitch() { + for i := 0; i < 5; func() { i++; check(LINE, 5) }() { + goto label2 + label1: + goto label1 + label2: + switch i { + case 0: + check(LINE, 1) + case 1: + check(LINE, 1) + case 2: + check(LINE, 1) + default: + check(LINE, 2) + } + } +} + +func testTypeSwitch() { + var x = []any{1, 2.0, "hi"} + for _, v := range x { + switch func() { check(LINE, 3) }(); v.(type) { + case int: + check(LINE, 1) + case float64: + check(LINE, 1) + case string: + check(LINE, 1) + case complex128: + check(LINE, 0) + default: + check(LINE, 0) + } + } +} + +func testSelect1() { + c := make(chan int) + go func() { + for i := 0; i < 1000; i++ { + c <- i + } + }() + for { + select { + case <-c: + check(LINE, anything) + case <-c: + check(LINE, anything) + default: + check(LINE, 1) + return + } + } +} + +func testSelect2() { + c1 := make(chan int, 1000) + c2 := make(chan int, 1000) + for i := 0; i < 1000; i++ { + c1 <- i + c2 <- i + } + for { + select { + case <-c1: + check(LINE, 1000) + case <-c2: + check(LINE, 1000) + default: + check(LINE, 1) + return + } + } +} + +// Empty control statements created syntax errors. This function +// is here just to be sure that those are handled correctly now. +func testEmptySwitches() { + check(LINE, 1) + switch 3 { + } + check(LINE, 1) + switch i := (any)(3).(int); i { + } + check(LINE, 1) + c := make(chan int) + go func() { + check(LINE, 1) + c <- 1 + select {} + }() + <-c + check(LINE, 1) +} + +func testFunctionLiteral() { + a := func(f func()) error { + f() + f() + return nil + } + + b := func(f func()) bool { + f() + f() + return true + } + + check(LINE, 1) + a(func() { + check(LINE, 2) + }) + + if err := a(func() { + check(LINE, 2) + }); err != nil { + } + + switch b(func() { + check(LINE, 2) + }) { + } + + x := 2 + switch x { + case func() int { check(LINE, 1); return 1 }(): + check(LINE, 0) + panic("2=1") + case func() int { check(LINE, 1); return 2 }(): + check(LINE, 1) + case func() int { check(LINE, 0); return 3 }(): + check(LINE, 0) + panic("2=3") + } +} + +func testGoto() { + for i := 0; i < 2; i++ { + if i == 0 { + goto Label + } + check(LINE, 1) + Label: + check(LINE, 2) + } + // Now test that we don't inject empty statements + // between a label and a loop. +loop: + for { + check(LINE, 1) + break loop + } +} + +// This comment didn't appear in generated go code. +func haha() { + // Needed for cover to add counter increment here. + _ = 42 +} + +// Some someFunction. +// +//go:nosplit +func someFunction() { +} diff --git a/go/src/cmd/go/internal/auth/auth.go b/go/src/cmd/go/internal/auth/auth.go new file mode 100644 index 0000000000000000000000000000000000000000..8f2bded32029d1689ae9de54591eb935b76cfab9 --- /dev/null +++ b/go/src/cmd/go/internal/auth/auth.go @@ -0,0 +1,179 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package auth provides access to user-provided authentication credentials. +package auth + +import ( + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "fmt" + "log" + "net/http" + "os" + "path/filepath" + "slices" + "strings" + "sync" +) + +var ( + credentialCache sync.Map // prefix → http.Header + authOnce sync.Once +) + +// AddCredentials populates the request header with the user's credentials +// as specified by the GOAUTH environment variable. +// It returns whether any matching credentials were found. +// req must use HTTPS or this function will panic. +// res is used for the custom GOAUTH command's stdin. +func AddCredentials(client *http.Client, req *http.Request, res *http.Response, url string) bool { + if req.URL.Scheme != "https" { + panic("GOAUTH called without https") + } + if cfg.GOAUTH == "off" { + return false + } + // Run all GOAUTH commands at least once. + authOnce.Do(func() { + runGoAuth(client, res, "") + }) + if url != "" { + // First fetch must have failed; re-invoke GOAUTH commands with url. + runGoAuth(client, res, url) + } + return loadCredential(req, req.URL.String()) +} + +// runGoAuth executes authentication commands specified by the GOAUTH +// environment variable handling 'off', 'netrc', and 'git' methods specially, +// and storing retrieved credentials for future access. +func runGoAuth(client *http.Client, res *http.Response, url string) { + var cmdErrs []error // store GOAUTH command errors to log later. + goAuthCmds := strings.Split(cfg.GOAUTH, ";") + // The GOAUTH commands are processed in reverse order to prioritize + // credentials in the order they were specified. + slices.Reverse(goAuthCmds) + for _, command := range goAuthCmds { + command = strings.TrimSpace(command) + words := strings.Fields(command) + if len(words) == 0 { + base.Fatalf("go: GOAUTH encountered an empty command (GOAUTH=%s)", cfg.GOAUTH) + } + switch words[0] { + case "off": + if len(goAuthCmds) != 1 { + base.Fatalf("go: GOAUTH=off cannot be combined with other authentication commands (GOAUTH=%s)", cfg.GOAUTH) + } + return + case "netrc": + lines, err := readNetrc() + if err != nil { + cmdErrs = append(cmdErrs, fmt.Errorf("GOAUTH=%s: %v", command, err)) + continue + } + // Process lines in reverse so that if the same machine is listed + // multiple times, we end up saving the earlier one + // (overwriting later ones). This matches the way the go command + // worked before GOAUTH. + for i := len(lines) - 1; i >= 0; i-- { + l := lines[i] + r := http.Request{Header: make(http.Header)} + r.SetBasicAuth(l.login, l.password) + storeCredential(l.machine, r.Header) + } + case "git": + if len(words) != 2 { + base.Fatalf("go: GOAUTH=git dir method requires an absolute path to the git working directory") + } + dir := words[1] + if !filepath.IsAbs(dir) { + base.Fatalf("go: GOAUTH=git dir method requires an absolute path to the git working directory, dir is not absolute") + } + fs, err := os.Stat(dir) + if err != nil { + base.Fatalf("go: GOAUTH=git encountered an error; cannot stat %s: %v", dir, err) + } + if !fs.IsDir() { + base.Fatalf("go: GOAUTH=git dir method requires an absolute path to the git working directory, dir is not a directory") + } + + if url == "" { + // Skip the initial GOAUTH run since we need to provide an + // explicit url to runGitAuth. + continue + } + prefix, header, err := runGitAuth(client, dir, url) + if err != nil { + // Save the error, but don't print it yet in case another + // GOAUTH command might succeed. + cmdErrs = append(cmdErrs, fmt.Errorf("GOAUTH=%s: %v", command, err)) + } else { + storeCredential(prefix, header) + } + default: + credentials, err := runAuthCommand(command, url, res) + if err != nil { + // Save the error, but don't print it yet in case another + // GOAUTH command might succeed. + cmdErrs = append(cmdErrs, fmt.Errorf("GOAUTH=%s: %v", command, err)) + continue + } + for prefix := range credentials { + storeCredential(prefix, credentials[prefix]) + } + } + } + // If no GOAUTH command provided a credential for the given url + // and an error occurred, log the error. + if cfg.BuildX && url != "" { + req := &http.Request{Header: make(http.Header)} + if ok := loadCredential(req, url); !ok && len(cmdErrs) > 0 { + log.Printf("GOAUTH encountered errors for %s:", url) + for _, err := range cmdErrs { + log.Printf(" %v", err) + } + } + } +} + +// loadCredential retrieves cached credentials for the given url and adds +// them to the request headers. +func loadCredential(req *http.Request, url string) bool { + currentPrefix := strings.TrimPrefix(url, "https://") + currentPrefix = strings.TrimSuffix(currentPrefix, "/") + + // Iteratively try prefixes, moving up the path hierarchy. + // E.g. example.com/foo/bar, example.com/foo, example.com + for { + headers, ok := credentialCache.Load(currentPrefix) + if !ok { + lastSlash := strings.LastIndexByte(currentPrefix, '/') + if lastSlash == -1 { + return false + } + currentPrefix = currentPrefix[:lastSlash] + continue + } + for key, values := range headers.(http.Header) { + for _, value := range values { + req.Header.Add(key, value) + } + } + return true + } +} + +// storeCredential caches or removes credentials (represented by HTTP headers) +// associated with given URL prefixes. +func storeCredential(prefix string, header http.Header) { + // Trim "https://" prefix to match the format used in .netrc files. + prefix = strings.TrimPrefix(prefix, "https://") + prefix = strings.TrimSuffix(prefix, "/") + if len(header) == 0 { + credentialCache.Delete(prefix) + } else { + credentialCache.Store(prefix, header) + } +} diff --git a/go/src/cmd/go/internal/auth/auth_test.go b/go/src/cmd/go/internal/auth/auth_test.go new file mode 100644 index 0000000000000000000000000000000000000000..599030fd13bafc623e8596cdc78b5aef8a580f26 --- /dev/null +++ b/go/src/cmd/go/internal/auth/auth_test.go @@ -0,0 +1,90 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package auth + +import ( + "net/http" + "reflect" + "testing" +) + +func TestCredentialCache(t *testing.T) { + testCases := []netrcLine{ + {"api.github.com", "user", "pwd"}, + {"test.host", "user2", "pwd2"}, + {"oneline", "user3", "pwd3"}, + {"hasmacro.too", "user4", "pwd4"}, + {"hasmacro.too", "user5", "pwd5"}, + } + for _, tc := range testCases { + want := http.Request{Header: make(http.Header)} + want.SetBasicAuth(tc.login, tc.password) + storeCredential(tc.machine, want.Header) + got := &http.Request{Header: make(http.Header)} + ok := loadCredential(got, tc.machine) + if !ok || !reflect.DeepEqual(got.Header, want.Header) { + t.Errorf("loadCredential(%q):\nhave %q\nwant %q", tc.machine, got.Header, want.Header) + } + } + + // Having stored those credentials, we should be able to look up longer URLs too. + extraCases := []netrcLine{ + {"https://api.github.com/foo", "user", "pwd"}, + {"https://api.github.com/foo/bar/baz", "user", "pwd"}, + {"https://example.com/abc", "", ""}, + {"https://example.com/?/../api.github.com/", "", ""}, + {"https://example.com/?/../api.github.com", "", ""}, + {"https://example.com/../api.github.com/", "", ""}, + {"https://example.com/../api.github.com", "", ""}, + } + for _, tc := range extraCases { + want := http.Request{Header: make(http.Header)} + if tc.login != "" { + want.SetBasicAuth(tc.login, tc.password) + } + got := &http.Request{Header: make(http.Header)} + loadCredential(got, tc.machine) + if !reflect.DeepEqual(got.Header, want.Header) { + t.Errorf("loadCredential(%q):\nhave %q\nwant %q", tc.machine, got.Header, want.Header) + } + } +} + +func TestCredentialCacheDelete(t *testing.T) { + // Store a credential for api.github.com + want := http.Request{Header: make(http.Header)} + want.SetBasicAuth("user", "pwd") + storeCredential("api.github.com", want.Header) + got := &http.Request{Header: make(http.Header)} + ok := loadCredential(got, "api.github.com") + if !ok || !reflect.DeepEqual(got.Header, want.Header) { + t.Errorf("parseNetrc:\nhave %q\nwant %q", got.Header, want.Header) + } + // Providing an empty header for api.github.com should clear credentials. + want = http.Request{Header: make(http.Header)} + storeCredential("api.github.com", want.Header) + got = &http.Request{Header: make(http.Header)} + ok = loadCredential(got, "api.github.com") + if ok { + t.Errorf("loadCredential:\nhave %q\nwant %q", got.Header, want.Header) + } +} + +func TestCredentialCacheTrailingSlash(t *testing.T) { + // Store a credential for api.github.com/foo/bar + want := http.Request{Header: make(http.Header)} + want.SetBasicAuth("user", "pwd") + storeCredential("api.github.com/foo", want.Header) + got := &http.Request{Header: make(http.Header)} + ok := loadCredential(got, "api.github.com/foo/bar") + if !ok || !reflect.DeepEqual(got.Header, want.Header) { + t.Errorf("parseNetrc:\nhave %q\nwant %q", got.Header, want.Header) + } + got2 := &http.Request{Header: make(http.Header)} + ok = loadCredential(got2, "https://api.github.com/foo/bar/") + if !ok || !reflect.DeepEqual(got2.Header, want.Header) { + t.Errorf("parseNetrc:\nhave %q\nwant %q", got2.Header, want.Header) + } +} diff --git a/go/src/cmd/go/internal/auth/gitauth.go b/go/src/cmd/go/internal/auth/gitauth.go new file mode 100644 index 0000000000000000000000000000000000000000..f11cd2fbf057d728569b092d472b03d1d9eb8db4 --- /dev/null +++ b/go/src/cmd/go/internal/auth/gitauth.go @@ -0,0 +1,152 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// gitauth uses 'git credential' to implement the GOAUTH protocol. +// +// See https://git-scm.com/docs/gitcredentials or run 'man gitcredentials' for +// information on how to configure 'git credential'. + +package auth + +import ( + "bytes" + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/web/intercept" + "fmt" + "log" + "net/http" + "net/url" + "os/exec" + "strings" +) + +const maxTries = 3 + +// runGitAuth retrieves credentials for the given url using +// 'git credential fill', validates them with a HEAD request +// (using the provided client) and updates the credential helper's cache. +// It returns the matching credential prefix, the http.Header with the +// Basic Authentication header set, or an error. +// The caller must not mutate the header. +func runGitAuth(client *http.Client, dir, url string) (string, http.Header, error) { + if url == "" { + // No explicit url was passed, but 'git credential' + // provides no way to enumerate existing credentials. + // Wait for a request for a specific url. + return "", nil, fmt.Errorf("no explicit url was passed") + } + if dir == "" { + // Prevent config-injection attacks by requiring an explicit working directory. + // See https://golang.org/issue/29230 for details. + panic("'git' invoked in an arbitrary directory") // this should be caught earlier. + } + cmd := exec.Command("git", "credential", "fill") + cmd.Dir = dir + cmd.Stdin = strings.NewReader(fmt.Sprintf("url=%s\n", url)) + out, err := cmd.CombinedOutput() + if err != nil { + return "", nil, fmt.Errorf("'git credential fill' failed (url=%s): %w\n%s", url, err, out) + } + parsedPrefix, username, password := parseGitAuth(out) + if parsedPrefix == "" { + return "", nil, fmt.Errorf("'git credential fill' failed for url=%s, could not parse url\n", url) + } + // Check that the URL Git gave us is a prefix of the one we requested. + if !strings.HasPrefix(url, parsedPrefix) { + return "", nil, fmt.Errorf("requested a credential for %s, but 'git credential fill' provided one for %s\n", url, parsedPrefix) + } + req, err := http.NewRequest("HEAD", parsedPrefix, nil) + if err != nil { + return "", nil, fmt.Errorf("internal error constructing HTTP HEAD request: %v\n", err) + } + req.SetBasicAuth(username, password) + // Asynchronously validate the provided credentials using a HEAD request, + // allowing the git credential helper to update its cache without blocking. + // This avoids repeatedly prompting the user for valid credentials. + // This is a best-effort update; the primary validation will still occur + // with the caller's client. + // The request is intercepted for testing purposes to simulate interactions + // with the credential helper. + intercept.Request(req) + go updateGitCredentialHelper(client, req, out) + + // Return the parsed prefix and headers, even if credential validation fails. + // The caller is responsible for the primary validation. + return parsedPrefix, req.Header, nil +} + +// parseGitAuth parses the output of 'git credential fill', extracting +// the URL prefix, user, and password. +// Any of these values may be empty if parsing fails. +func parseGitAuth(data []byte) (parsedPrefix, username, password string) { + prefix := new(url.URL) + for line := range strings.SplitSeq(string(data), "\n") { + key, value, ok := strings.Cut(strings.TrimSpace(line), "=") + if !ok { + continue + } + switch key { + case "protocol": + prefix.Scheme = value + case "host": + prefix.Host = value + case "path": + prefix.Path = value + case "username": + username = value + case "password": + password = value + case "url": + // Write to a local variable instead of updating prefix directly: + // if the url field is malformed, we don't want to invalidate + // information parsed from the protocol, host, and path fields. + u, err := url.ParseRequestURI(value) + if err != nil { + if cfg.BuildX { + log.Printf("malformed URL from 'git credential fill' (%v): %q\n", err, value) + // Proceed anyway: we might be able to parse the prefix from other fields of the response. + } + continue + } + prefix = u + } + } + return prefix.String(), username, password +} + +// updateGitCredentialHelper validates the given credentials by sending a HEAD request +// and updates the git credential helper's cache accordingly. It retries the +// request up to maxTries times. +func updateGitCredentialHelper(client *http.Client, req *http.Request, credentialOutput []byte) { + for range maxTries { + release, err := base.AcquireNet() + if err != nil { + return + } + res, err := client.Do(req) + if err != nil { + release() + continue + } + res.Body.Close() + release() + if res.StatusCode == http.StatusOK || res.StatusCode == http.StatusUnauthorized { + approveOrRejectCredential(credentialOutput, res.StatusCode == http.StatusOK) + break + } + } +} + +// approveOrRejectCredential approves or rejects the provided credential using +// 'git credential approve/reject'. +func approveOrRejectCredential(credentialOutput []byte, approve bool) { + action := "reject" + if approve { + action = "approve" + } + cmd := exec.Command("git", "credential", action) + cmd.Stdin = bytes.NewReader(credentialOutput) + cmd.Run() // ignore error +} diff --git a/go/src/cmd/go/internal/auth/gitauth_test.go b/go/src/cmd/go/internal/auth/gitauth_test.go new file mode 100644 index 0000000000000000000000000000000000000000..2ba93ad2c25f17907d8817fe5be778c59cfd586c --- /dev/null +++ b/go/src/cmd/go/internal/auth/gitauth_test.go @@ -0,0 +1,159 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package auth + +import ( + "strings" + "testing" +) + +func TestParseGitAuth(t *testing.T) { + testCases := []struct { + gitauth string // contents of 'git credential fill' + wantPrefix string + wantUsername string + wantPassword string + }{ + { // Standard case. + gitauth: ` +protocol=https +host=example.com +username=bob +password=secr3t +`, + wantPrefix: "https://example.com", + wantUsername: "bob", + wantPassword: "secr3t", + }, + { // Should not use an invalid url. + gitauth: ` +protocol=https +host=example.com +username=bob +password=secr3t +url=invalid +`, + wantPrefix: "https://example.com", + wantUsername: "bob", + wantPassword: "secr3t", + }, + { // Should use the new url. + gitauth: ` +protocol=https +host=example.com +username=bob +password=secr3t +url=https://go.dev +`, + wantPrefix: "https://go.dev", + wantUsername: "bob", + wantPassword: "secr3t", + }, + { // Empty data. + gitauth: ` +`, + wantPrefix: "", + wantUsername: "", + wantPassword: "", + }, + { // Does not follow the '=' format. + gitauth: ` +protocol:https +host:example.com +username:bob +password:secr3t +`, + wantPrefix: "", + wantUsername: "", + wantPassword: "", + }, + } + for _, tc := range testCases { + parsedPrefix, username, password := parseGitAuth([]byte(tc.gitauth)) + if parsedPrefix != tc.wantPrefix { + t.Errorf("parseGitAuth(%s):\nhave %q\nwant %q", tc.gitauth, parsedPrefix, tc.wantPrefix) + } + if username != tc.wantUsername { + t.Errorf("parseGitAuth(%s):\nhave %q\nwant %q", tc.gitauth, username, tc.wantUsername) + } + if password != tc.wantPassword { + t.Errorf("parseGitAuth(%s):\nhave %q\nwant %q", tc.gitauth, password, tc.wantPassword) + } + } +} + +func BenchmarkParseGitAuth(b *testing.B) { + // Define different test scenarios to benchmark + testCases := []struct { + name string + data []byte + }{{ + // Standard scenario with all basic fields present + name: "standard", + data: []byte(` +protocol=https +host=example.com +username=bob +password=secr3t +`), + }, { + // Scenario with URL field included + name: "with_url", + data: []byte(` +protocol=https +host=example.com +username=bob +password=secr3t +url=https://example.com/repo +`), + }, { + // Minimal scenario with only required fields + name: "minimal", + data: []byte(` +protocol=https +host=example.com +`), + }, { + // Complex scenario with longer values and extra fields + name: "complex", + data: func() []byte { + var builder strings.Builder + builder.WriteString("protocol=https\n") + builder.WriteString("host=example.com\n") + builder.WriteString("username=longusernamenamename\n") + builder.WriteString("password=longpasswordwithmanycharacters123456789\n") + builder.WriteString("url=https://example.com/very/long/path/to/repository\n") + builder.WriteString("extra1=value1\n") + builder.WriteString("extra2=value2\n") + return []byte(builder.String()) + }(), + }, { + // Scenario with empty input + name: "empty", + data: []byte(``), + }, { + // Scenario with malformed input (using colon instead of equals) + name: "malformed", + data: []byte(` +protocol:https +host:example.com +username:bob +password:secr3t +`), + }} + + for _, tc := range testCases { + b.Run(tc.name, func(b *testing.B) { + b.ResetTimer() + for b.Loop() { + prefix, username, password := parseGitAuth(tc.data) + + _ = prefix + _ = username + _ = password + } + }) + } +} diff --git a/go/src/cmd/go/internal/auth/httputils.go b/go/src/cmd/go/internal/auth/httputils.go new file mode 100644 index 0000000000000000000000000000000000000000..7f7bf03669ecadb628d8ded761fdd6193ee68a1a --- /dev/null +++ b/go/src/cmd/go/internal/auth/httputils.go @@ -0,0 +1,174 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code copied from x/net/http/httpguts/httplex.go + +package auth + +var isTokenTable = [256]bool{ + '!': true, + '#': true, + '$': true, + '%': true, + '&': true, + '\'': true, + '*': true, + '+': true, + '-': true, + '.': true, + '0': true, + '1': true, + '2': true, + '3': true, + '4': true, + '5': true, + '6': true, + '7': true, + '8': true, + '9': true, + 'A': true, + 'B': true, + 'C': true, + 'D': true, + 'E': true, + 'F': true, + 'G': true, + 'H': true, + 'I': true, + 'J': true, + 'K': true, + 'L': true, + 'M': true, + 'N': true, + 'O': true, + 'P': true, + 'Q': true, + 'R': true, + 'S': true, + 'T': true, + 'U': true, + 'W': true, + 'V': true, + 'X': true, + 'Y': true, + 'Z': true, + '^': true, + '_': true, + '`': true, + 'a': true, + 'b': true, + 'c': true, + 'd': true, + 'e': true, + 'f': true, + 'g': true, + 'h': true, + 'i': true, + 'j': true, + 'k': true, + 'l': true, + 'm': true, + 'n': true, + 'o': true, + 'p': true, + 'q': true, + 'r': true, + 's': true, + 't': true, + 'u': true, + 'v': true, + 'w': true, + 'x': true, + 'y': true, + 'z': true, + '|': true, + '~': true, +} + +// isLWS reports whether b is linear white space, according +// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 +// +// LWS = [CRLF] 1*( SP | HT ) +func isLWS(b byte) bool { return b == ' ' || b == '\t' } + +// isCTL reports whether b is a control byte, according +// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 +// +// CTL = +func isCTL(b byte) bool { + const del = 0x7f // a CTL + return b < ' ' || b == del +} + +// validHeaderFieldName reports whether v is a valid HTTP/1.x header name. +// HTTP/2 imposes the additional restriction that uppercase ASCII +// letters are not allowed. +// +// RFC 7230 says: +// +// header-field = field-name ":" OWS field-value OWS +// field-name = token +// token = 1*tchar +// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / +// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA +func validHeaderFieldName(v string) bool { + if len(v) == 0 { + return false + } + for i := 0; i < len(v); i++ { + if !isTokenTable[v[i]] { + return false + } + } + return true +} + +// validHeaderFieldValue reports whether v is a valid "field-value" according to +// http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 : +// +// message-header = field-name ":" [ field-value ] +// field-value = *( field-content | LWS ) +// field-content = +// +// http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 : +// +// TEXT = +// LWS = [CRLF] 1*( SP | HT ) +// CTL = +// +// RFC 7230 says: +// +// field-value = *( field-content / obs-fold ) +// obj-fold = N/A to http2, and deprecated +// field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] +// field-vchar = VCHAR / obs-text +// obs-text = %x80-FF +// VCHAR = "any visible [USASCII] character" +// +// http2 further says: "Similarly, HTTP/2 allows header field values +// that are not valid. While most of the values that can be encoded +// will not alter header field parsing, carriage return (CR, ASCII +// 0xd), line feed (LF, ASCII 0xa), and the zero character (NUL, ASCII +// 0x0) might be exploited by an attacker if they are translated +// verbatim. Any request or response that contains a character not +// permitted in a header field value MUST be treated as malformed +// (Section 8.1.2.6). Valid characters are defined by the +// field-content ABNF rule in Section 3.2 of [RFC7230]." +// +// This function does not (yet?) properly handle the rejection of +// strings that begin or end with SP or HTAB. +func validHeaderFieldValue(v string) bool { + for i := 0; i < len(v); i++ { + b := v[i] + if isCTL(b) && !isLWS(b) { + return false + } + } + return true +} diff --git a/go/src/cmd/go/internal/auth/netrc.go b/go/src/cmd/go/internal/auth/netrc.go new file mode 100644 index 0000000000000000000000000000000000000000..78c884b31bd54101a5fbb60444c2060483b61c5a --- /dev/null +++ b/go/src/cmd/go/internal/auth/netrc.go @@ -0,0 +1,113 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package auth + +import ( + "os" + "path/filepath" + "runtime" + "strings" + "sync" +) + +type netrcLine struct { + machine string + login string + password string +} + +func parseNetrc(data string) []netrcLine { + // See https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html + // for documentation on the .netrc format. + var nrc []netrcLine + var l netrcLine + inMacro := false + for line := range strings.SplitSeq(data, "\n") { + if inMacro { + if line == "" { + inMacro = false + } + continue + } + + f := strings.Fields(line) + i := 0 + for ; i < len(f)-1; i += 2 { + // Reset at each "machine" token. + // “The auto-login process searches the .netrc file for a machine token + // that matches […]. Once a match is made, the subsequent .netrc tokens + // are processed, stopping when the end of file is reached or another + // machine or a default token is encountered.” + switch f[i] { + case "machine": + l = netrcLine{machine: f[i+1]} + case "default": + break + case "login": + l.login = f[i+1] + case "password": + l.password = f[i+1] + case "macdef": + // “A macro is defined with the specified name; its contents begin with + // the next .netrc line and continue until a null line (consecutive + // new-line characters) is encountered.” + inMacro = true + } + if l.machine != "" && l.login != "" && l.password != "" { + nrc = append(nrc, l) + l = netrcLine{} + } + } + + if i < len(f) && f[i] == "default" { + // “There can be only one default token, and it must be after all machine tokens.” + break + } + } + + return nrc +} + +func netrcPath() (string, error) { + if env := os.Getenv("NETRC"); env != "" { + return env, nil + } + dir, err := os.UserHomeDir() + if err != nil { + return "", err + } + + // Prioritize _netrc on Windows for compatibility. + if runtime.GOOS == "windows" { + legacyPath := filepath.Join(dir, "_netrc") + _, err := os.Stat(legacyPath) + if err == nil { + return legacyPath, nil + } + if !os.IsNotExist(err) { + return "", err + } + + } + // Use the .netrc file (fall back to it if we're on Windows). + return filepath.Join(dir, ".netrc"), nil +} + +var readNetrc = sync.OnceValues(func() ([]netrcLine, error) { + path, err := netrcPath() + if err != nil { + return nil, err + } + + data, err := os.ReadFile(path) + if err != nil { + if os.IsNotExist(err) { + err = nil + } + return nil, err + } + + return parseNetrc(string(data)), nil +}) diff --git a/go/src/cmd/go/internal/auth/netrc_test.go b/go/src/cmd/go/internal/auth/netrc_test.go new file mode 100644 index 0000000000000000000000000000000000000000..e06c545390e0e9c465eef8ecb9ef7773a7516778 --- /dev/null +++ b/go/src/cmd/go/internal/auth/netrc_test.go @@ -0,0 +1,58 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package auth + +import ( + "reflect" + "testing" +) + +var testNetrc = ` +machine incomplete +password none + +machine api.github.com + login user + password pwd + +machine incomlete.host + login justlogin + +machine test.host +login user2 +password pwd2 + +machine oneline login user3 password pwd3 + +machine ignore.host macdef ignore + login nobody + password nothing + +machine hasmacro.too macdef ignore-next-lines login user4 password pwd4 + login nobody + password nothing + +default +login anonymous +password gopher@golang.org + +machine after.default +login oops +password too-late-in-file +` + +func TestParseNetrc(t *testing.T) { + lines := parseNetrc(testNetrc) + want := []netrcLine{ + {"api.github.com", "user", "pwd"}, + {"test.host", "user2", "pwd2"}, + {"oneline", "user3", "pwd3"}, + {"hasmacro.too", "user4", "pwd4"}, + } + + if !reflect.DeepEqual(lines, want) { + t.Errorf("parseNetrc:\nhave %q\nwant %q", lines, want) + } +} diff --git a/go/src/cmd/go/internal/auth/userauth.go b/go/src/cmd/go/internal/auth/userauth.go new file mode 100644 index 0000000000000000000000000000000000000000..44c0b3cff0993dd51e9fa1498e4f50c7c67f106d --- /dev/null +++ b/go/src/cmd/go/internal/auth/userauth.go @@ -0,0 +1,126 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package auth + +import ( + "cmd/internal/quoted" + "fmt" + "maps" + "net/http" + "net/url" + "os/exec" + "strings" +) + +// runAuthCommand executes a user provided GOAUTH command, parses its output, and +// returns a mapping of prefix → http.Header. +// It uses the client to verify the credential and passes the status to the +// command's stdin. +// res is used for the GOAUTH command's stdin. +func runAuthCommand(command string, url string, res *http.Response) (map[string]http.Header, error) { + if command == "" { + panic("GOAUTH invoked an empty authenticator command:" + command) // This should be caught earlier. + } + cmd, err := buildCommand(command) + if err != nil { + return nil, err + } + if url != "" { + cmd.Args = append(cmd.Args, url) + } + cmd.Stderr = new(strings.Builder) + if res != nil && writeResponseToStdin(cmd, res) != nil { + return nil, fmt.Errorf("could not run command %s: %v\n%s", command, err, cmd.Stderr) + } + out, err := cmd.Output() + if err != nil { + return nil, fmt.Errorf("could not run command %s: %v\n%s", command, err, cmd.Stderr) + } + credentials, err := parseUserAuth(string(out)) + if err != nil { + return nil, fmt.Errorf("cannot parse output of GOAUTH command %s: %v", command, err) + } + return credentials, nil +} + +// parseUserAuth parses the output from a GOAUTH command and +// returns a mapping of prefix → http.Header without the leading "https://" +// or an error if the data does not follow the expected format. +// Returns a nil error and an empty map if the data is empty. +// See the expected format in 'go help goauth'. +func parseUserAuth(data string) (map[string]http.Header, error) { + credentials := make(map[string]http.Header) + for data != "" { + var line string + var ok bool + var urls []string + // Parse URLS first. + for { + line, data, ok = strings.Cut(data, "\n") + if !ok { + return nil, fmt.Errorf("invalid format: missing empty line after URLs") + } + if line == "" { + break + } + u, err := url.ParseRequestURI(line) + if err != nil { + return nil, fmt.Errorf("could not parse URL %s: %v", line, err) + } + urls = append(urls, u.String()) + } + // Parse Headers second. + header := make(http.Header) + for { + line, data, ok = strings.Cut(data, "\n") + if !ok { + return nil, fmt.Errorf("invalid format: missing empty line after headers") + } + if line == "" { + break + } + name, value, ok := strings.Cut(line, ": ") + value = strings.TrimSpace(value) + if !ok || !validHeaderFieldName(name) || !validHeaderFieldValue(value) { + return nil, fmt.Errorf("invalid format: invalid header line") + } + header.Add(name, value) + } + maps.Copy(credentials, mapHeadersToPrefixes(urls, header)) + } + return credentials, nil +} + +// mapHeadersToPrefixes returns a mapping of prefix → http.Header without +// the leading "https://". +func mapHeadersToPrefixes(prefixes []string, header http.Header) map[string]http.Header { + prefixToHeaders := make(map[string]http.Header, len(prefixes)) + for _, p := range prefixes { + p = strings.TrimPrefix(p, "https://") + prefixToHeaders[p] = header.Clone() // Clone the header to avoid sharing + } + return prefixToHeaders +} + +func buildCommand(command string) (*exec.Cmd, error) { + words, err := quoted.Split(command) + if err != nil { + return nil, fmt.Errorf("cannot parse GOAUTH command %s: %v", command, err) + } + cmd := exec.Command(words[0], words[1:]...) + return cmd, nil +} + +// writeResponseToStdin writes the HTTP response to the command's stdin. +func writeResponseToStdin(cmd *exec.Cmd, res *http.Response) error { + var output strings.Builder + output.WriteString(res.Proto + " " + res.Status + "\n") + for k, v := range res.Header { + output.WriteString(k + ": " + strings.Join(v, ", ") + "\n") + } + output.WriteString("\n") + cmd.Stdin = strings.NewReader(output.String()) + return nil +} diff --git a/go/src/cmd/go/internal/auth/userauth_test.go b/go/src/cmd/go/internal/auth/userauth_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1b281ed3cdef45d2a9fb5c20cce2b935944d649e --- /dev/null +++ b/go/src/cmd/go/internal/auth/userauth_test.go @@ -0,0 +1,213 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package auth + +import ( + "net/http" + "reflect" + "testing" +) + +func TestParseUserAuth(t *testing.T) { + data := `https://example.com + +Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l +Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb + +https://hello.com + +Authorization: Basic GVuc2VzYW1lYWxhZGRpbjpvc +Authorization: Basic 1lYWxhZGRplW1lYWxhZGRpbs +Data: Test567 + +` + // Build the expected header + header1 := http.Header{ + "Authorization": []string{ + "Basic YWxhZGRpbjpvcGVuc2VzYW1l", + "Basic jpvcGVuc2VzYW1lYWxhZGRpb", + }, + } + header2 := http.Header{ + "Authorization": []string{ + "Basic GVuc2VzYW1lYWxhZGRpbjpvc", + "Basic 1lYWxhZGRplW1lYWxhZGRpbs", + }, + "Data": []string{ + "Test567", + }, + } + credentials, err := parseUserAuth(data) + if err != nil { + t.Errorf("parseUserAuth(%s): %v", data, err) + } + gotHeader, ok := credentials["example.com"] + if !ok || !reflect.DeepEqual(gotHeader, header1) { + t.Errorf("parseUserAuth(%s):\nhave %q\nwant %q", data, gotHeader, header1) + } + gotHeader, ok = credentials["hello.com"] + if !ok || !reflect.DeepEqual(gotHeader, header2) { + t.Errorf("parseUserAuth(%s):\nhave %q\nwant %q", data, gotHeader, header2) + } +} + +func TestParseUserAuthInvalid(t *testing.T) { + testCases := []string{ + // Missing new line after url. + `https://example.com +Authorization: Basic AVuc2VzYW1lYWxhZGRpbjpvc + +`, + // Missing url. + `Authorization: Basic AVuc2VzYW1lYWxhZGRpbjpvc + +`, + // Missing url. + `https://example.com + +Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l +Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb + +Authorization: Basic GVuc2VzYW1lYWxhZGRpbjpvc +Authorization: Basic 1lYWxhZGRplW1lYWxhZGRpbs +Data: Test567 + +`, + // Wrong order. + `Authorization: Basic AVuc2VzYW1lYWxhZGRpbjpvc + +https://example.com + +`, + // Missing new lines after URL. + `https://example.com +`, + // Missing new line after empty header. + `https://example.com + +`, + // Missing new line between blocks. + `https://example.com + +Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l +Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb +https://hello.com + +Authorization: Basic GVuc2VzYW1lYWxhZGRpbjpvc +Authorization: Basic 1lYWxhZGRplW1lYWxhZGRpbs +Data: Test567 + +`, + // Continuation in URL line + `https://example.com/ + Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l +`, + + // Continuation in header line + `https://example.com + +Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l + Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb +`, + + // Continuation in multiple header lines + `https://example.com + +Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l + Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb + Authorization: Basic dGhpc2lzYWxvbmdzdHJpbmc= +`, + + // Continuation with mixed spacing + `https://example.com + +Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l + Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb +`, + + // Continuation with tab character + `https://example.com + +Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l + Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb +`, + // Continuation at the start of a block + ` https://example.com + +Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l +`, + + // Continuation after a blank line + `https://example.com + + +Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l +`, + } + for _, tc := range testCases { + if credentials, err := parseUserAuth(tc); err == nil { + t.Errorf("parseUserAuth(%s) should have failed, but got: %v", tc, credentials) + } + } +} + +func TestParseUserAuthDuplicated(t *testing.T) { + data := `https://example.com + +Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l +Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb + +https://example.com + +Authorization: Basic GVuc2VzYW1lYWxhZGRpbjpvc +Authorization: Basic 1lYWxhZGRplW1lYWxhZGRpbs +Data: Test567 + +` + // Build the expected header + header := http.Header{ + "Authorization": []string{ + "Basic GVuc2VzYW1lYWxhZGRpbjpvc", + "Basic 1lYWxhZGRplW1lYWxhZGRpbs", + }, + "Data": []string{ + "Test567", + }, + } + credentials, err := parseUserAuth(data) + if err != nil { + t.Errorf("parseUserAuth(%s): %v", data, err) + } + gotHeader, ok := credentials["example.com"] + if !ok || !reflect.DeepEqual(gotHeader, header) { + t.Errorf("parseUserAuth(%s):\nhave %q\nwant %q", data, gotHeader, header) + } +} + +func TestParseUserAuthEmptyHeader(t *testing.T) { + data := "https://example.com\n\n\n" + // Build the expected header + header := http.Header{} + credentials, err := parseUserAuth(data) + if err != nil { + t.Errorf("parseUserAuth(%s): %v", data, err) + } + gotHeader, ok := credentials["example.com"] + if !ok || !reflect.DeepEqual(gotHeader, header) { + t.Errorf("parseUserAuth(%s):\nhave %q\nwant %q", data, gotHeader, header) + } +} + +func TestParseUserAuthEmpty(t *testing.T) { + data := `` + // Build the expected header + credentials, err := parseUserAuth(data) + if err != nil { + t.Errorf("parseUserAuth(%s) should have succeeded", data) + } + if credentials == nil { + t.Errorf("parseUserAuth(%s) should have returned a non-nil credential map, but got %v", data, credentials) + } +} diff --git a/go/src/cmd/go/internal/base/base.go b/go/src/cmd/go/internal/base/base.go new file mode 100644 index 0000000000000000000000000000000000000000..d5d5f8d36e11330c5982e63799c05296b4de69df --- /dev/null +++ b/go/src/cmd/go/internal/base/base.go @@ -0,0 +1,251 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package base defines shared basic pieces of the go command, +// in particular logging and the Command structure. +package base + +import ( + "context" + "flag" + "fmt" + "log" + "os" + "os/exec" + "reflect" + "slices" + "strings" + "sync" + "time" + + "cmd/go/internal/cfg" + "cmd/go/internal/str" +) + +// A Command is an implementation of a go command +// like go build or go fix. +type Command struct { + // Run runs the command. + // The args are the arguments after the command name. + Run func(ctx context.Context, cmd *Command, args []string) + + // UsageLine is the one-line usage message. + // The words between "go" and the first flag or argument in the line are taken to be the command name. + UsageLine string + + // Short is the short description shown in the 'go help' output. + Short string + + // Long is the long message shown in the 'go help ' output. + Long string + + // Flag is a set of flags specific to this command. + Flag flag.FlagSet + + // CustomFlags indicates that the command will do its own + // flag parsing. + CustomFlags bool + + // Commands lists the available commands and help topics. + // The order here is the order in which they are printed by 'go help'. + // Note that subcommands are in general best avoided. + Commands []*Command +} + +var Go = &Command{ + UsageLine: "go", + Long: `Go is a tool for managing Go source code.`, + // Commands initialized in package main +} + +// Lookup returns the subcommand with the given name, if any. +// Otherwise it returns nil. +// +// Lookup ignores any subcommand `sub` that has len(sub.Commands) == 0 and sub.Run == nil. +// Such subcommands are only for use as arguments to "help". +func (c *Command) Lookup(name string) *Command { + for _, sub := range c.Commands { + if sub.Name() == name && (len(sub.Commands) > 0 || sub.Runnable()) { + return sub + } + } + return nil +} + +// hasFlag reports whether a command or any of its subcommands contain the given +// flag. +func hasFlag(c *Command, name string) bool { + if f := c.Flag.Lookup(name); f != nil { + return true + } + for _, sub := range c.Commands { + if hasFlag(sub, name) { + return true + } + } + return false +} + +// LongName returns the command's long name: all the words in the usage line between "go" and a flag or argument, +func (c *Command) LongName() string { + name := c.UsageLine + if i := strings.Index(name, " ["); i >= 0 { + name = name[:i] + } + if name == "go" { + return "" + } + return strings.TrimPrefix(name, "go ") +} + +// Name returns the command's short name: the last word in the usage line before a flag or argument. +func (c *Command) Name() string { + name := c.LongName() + if i := strings.LastIndex(name, " "); i >= 0 { + name = name[i+1:] + } + return name +} + +func (c *Command) Usage() { + fmt.Fprintf(os.Stderr, "usage: %s\n", c.UsageLine) + fmt.Fprintf(os.Stderr, "Run 'go help %s' for details.\n", c.LongName()) + SetExitStatus(2) + Exit() +} + +// Runnable reports whether the command can be run; otherwise +// it is a documentation pseudo-command such as importpath. +func (c *Command) Runnable() bool { + return c.Run != nil +} + +var atExitFuncs []func() + +func AtExit(f func()) { + atExitFuncs = append(atExitFuncs, f) +} + +func Exit() { + for _, f := range atExitFuncs { + f() + } + os.Exit(exitStatus) +} + +func Fatalf(format string, args ...any) { + Errorf(format, args...) + Exit() +} + +func Errorf(format string, args ...any) { + log.Printf(format, args...) + SetExitStatus(1) +} + +func ExitIfErrors() { + if exitStatus != 0 { + Exit() + } +} + +func Error(err error) { + // We use errors.Join to return multiple errors from various routines. + // If we receive multiple errors joined with a basic errors.Join, + // handle each one separately so that they all have the leading "go: " prefix. + // A plain interface check is not good enough because there might be + // other kinds of structured errors that are logically one unit and that + // add other context: only handling the wrapped errors would lose + // that context. + if err != nil && reflect.TypeOf(err).String() == "*errors.joinError" { + for _, e := range err.(interface{ Unwrap() []error }).Unwrap() { + Error(e) + } + return + } + Errorf("go: %v", err) +} + +func Fatal(err error) { + Error(err) + Exit() +} + +var exitStatus = 0 +var exitMu sync.Mutex + +func SetExitStatus(n int) { + exitMu.Lock() + if exitStatus < n { + exitStatus = n + } + exitMu.Unlock() +} + +func GetExitStatus() int { + return exitStatus +} + +// Run runs the command, with stdout and stderr +// connected to the go command's own stdout and stderr. +// If the command fails, Run reports the error using Errorf. +func Run(cmdargs ...any) { + if err := RunErr(cmdargs...); err != nil { + Errorf("%v", err) + } +} + +// Run runs the command, with stdout and stderr +// connected to the go command's own stdout and stderr. +// If the command fails, RunErr returns the error, which +// may be an *exec.ExitError. +func RunErr(cmdargs ...any) error { + cmdline := str.StringList(cmdargs...) + if cfg.BuildN || cfg.BuildX { + fmt.Printf("%s\n", strings.Join(cmdline, " ")) + if cfg.BuildN { + return nil + } + } + + cmd := exec.Command(cmdline[0], cmdline[1:]...) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + return cmd.Run() +} + +// RunStdin is like run but connects Stdin. It retries if it encounters an ETXTBSY. +func RunStdin(cmdline []string) { + env := slices.Clip(cfg.OrigEnv) + env = AppendPATH(env) + for try := range 3 { + cmd := exec.Command(cmdline[0], cmdline[1:]...) + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Env = env + StartSigHandlers() + err := cmd.Run() + if err == nil { + break // success + } + + if !IsETXTBSY(err) { + Errorf("%v", err) + break // failure + } + + // The error was an ETXTBSY. Sleep and try again. It's possible that + // another go command instance was racing against us to write the executable + // to the executable cache. In that case it may still have the file open, and + // we may get an ETXTBSY. That should resolve once that process closes the file + // so attempt a couple more times. See the discussion in #22220 and also + // (*runTestActor).Act in cmd/go/internal/test, which does something similar. + time.Sleep(100 * time.Millisecond << uint(try)) + } +} + +// Usage is the usage-reporting function, filled in by package main +// but here for reference by other packages. +var Usage func() diff --git a/go/src/cmd/go/internal/base/env.go b/go/src/cmd/go/internal/base/env.go new file mode 100644 index 0000000000000000000000000000000000000000..20ae06d67b4cb1b6883ec23baee945937dc92df8 --- /dev/null +++ b/go/src/cmd/go/internal/base/env.go @@ -0,0 +1,46 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "cmd/go/internal/cfg" + "fmt" + "os" + "path/filepath" + "runtime" +) + +// AppendPWD returns the result of appending PWD=dir to the environment base. +// +// The resulting environment makes os.Getwd more efficient for a subprocess +// running in dir, and also improves the accuracy of paths relative to dir +// if one or more elements of dir is a symlink. +func AppendPWD(base []string, dir string) []string { + // POSIX requires PWD to be absolute. + // Internally we only use absolute paths, so dir should already be absolute. + if !filepath.IsAbs(dir) { + panic(fmt.Sprintf("AppendPWD with relative path %q", dir)) + } + return append(base, "PWD="+dir) +} + +// AppendPATH returns the result of appending PATH=$GOROOT/bin:$PATH +// (or the platform equivalent) to the environment base. +func AppendPATH(base []string) []string { + if cfg.GOROOTbin == "" { + return base + } + + pathVar := "PATH" + if runtime.GOOS == "plan9" { + pathVar = "path" + } + + path := os.Getenv(pathVar) + if path == "" { + return append(base, pathVar+"="+cfg.GOROOTbin) + } + return append(base, pathVar+"="+cfg.GOROOTbin+string(os.PathListSeparator)+path) +} diff --git a/go/src/cmd/go/internal/base/error_notunix.go b/go/src/cmd/go/internal/base/error_notunix.go new file mode 100644 index 0000000000000000000000000000000000000000..c7780fa300a8a1547131635c1f3c85f6ee07ccae --- /dev/null +++ b/go/src/cmd/go/internal/base/error_notunix.go @@ -0,0 +1,12 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !unix + +package base + +func IsETXTBSY(err error) bool { + // syscall.ETXTBSY is only meaningful on Unix platforms. + return false +} diff --git a/go/src/cmd/go/internal/base/error_unix.go b/go/src/cmd/go/internal/base/error_unix.go new file mode 100644 index 0000000000000000000000000000000000000000..2dcd75e5f3687ae6f66a7f57a6972ff67fa6411a --- /dev/null +++ b/go/src/cmd/go/internal/base/error_unix.go @@ -0,0 +1,16 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix + +package base + +import ( + "errors" + "syscall" +) + +func IsETXTBSY(err error) bool { + return errors.Is(err, syscall.ETXTBSY) +} diff --git a/go/src/cmd/go/internal/base/flag.go b/go/src/cmd/go/internal/base/flag.go new file mode 100644 index 0000000000000000000000000000000000000000..74e1275cfd077f59f19f2bb5e0813d6252dfe28a --- /dev/null +++ b/go/src/cmd/go/internal/base/flag.go @@ -0,0 +1,85 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "flag" + "fmt" + + "cmd/go/internal/cfg" + "cmd/go/internal/fsys" + "cmd/internal/quoted" +) + +// A StringsFlag is a command-line flag that interprets its argument +// as a space-separated list of possibly-quoted strings. +type StringsFlag []string + +func (v *StringsFlag) Set(s string) error { + var err error + *v, err = quoted.Split(s) + if *v == nil { + *v = []string{} + } + return err +} + +func (v *StringsFlag) String() string { + return "" +} + +// explicitStringFlag is like a regular string flag, but it also tracks whether +// the string was set explicitly to a non-empty value. +type explicitStringFlag struct { + value *string + explicit *bool +} + +func (f explicitStringFlag) String() string { + if f.value == nil { + return "" + } + return *f.value +} + +func (f explicitStringFlag) Set(v string) error { + *f.value = v + if v != "" { + *f.explicit = true + } + return nil +} + +// AddBuildFlagsNX adds the -n and -x build flags to the flag set. +func AddBuildFlagsNX(flags *flag.FlagSet) { + flags.BoolVar(&cfg.BuildN, "n", false, "") + flags.BoolVar(&cfg.BuildX, "x", false, "") +} + +// AddChdirFlag adds the -C flag to the flag set. +func AddChdirFlag(flags *flag.FlagSet) { + // The usage message is never printed, but it's used in chdir_test.go + // to identify that the -C flag is from AddChdirFlag. + flags.Func("C", "AddChdirFlag", ChdirFlag) +} + +// AddModFlag adds the -mod build flag to the flag set. +func AddModFlag(flags *flag.FlagSet) { + flags.Var(explicitStringFlag{value: &cfg.BuildMod, explicit: &cfg.BuildModExplicit}, "mod", "") +} + +// AddModCommonFlags adds the module-related flags common to build commands +// and 'go mod' subcommands. +func AddModCommonFlags(flags *flag.FlagSet) { + flags.BoolVar(&cfg.ModCacheRW, "modcacherw", false, "") + flags.StringVar(&cfg.ModFile, "modfile", "", "") + flags.StringVar(&fsys.OverlayFile, "overlay", "", "") +} + +func ChdirFlag(s string) error { + // main handles -C by removing it from the command line. + // If we see one during flag parsing, that's an error. + return fmt.Errorf("-C flag must be first flag on command line") +} diff --git a/go/src/cmd/go/internal/base/goflags.go b/go/src/cmd/go/internal/base/goflags.go new file mode 100644 index 0000000000000000000000000000000000000000..eced2c5d5822682792727bb6335589ea14f88707 --- /dev/null +++ b/go/src/cmd/go/internal/base/goflags.go @@ -0,0 +1,162 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "flag" + "fmt" + "runtime" + "strings" + + "cmd/go/internal/cfg" + "cmd/internal/quoted" +) + +var goflags []string // cached $GOFLAGS list; can be -x or --x form + +// GOFLAGS returns the flags from $GOFLAGS. +// The list can be assumed to contain one string per flag, +// with each string either beginning with -name or --name. +func GOFLAGS() []string { + InitGOFLAGS() + return goflags +} + +// InitGOFLAGS initializes the goflags list from $GOFLAGS. +// If goflags is already initialized, it does nothing. +func InitGOFLAGS() { + if goflags != nil { // already initialized + return + } + + // Ignore bad flag in go env and go bug, because + // they are what people reach for when debugging + // a problem, and maybe they're debugging GOFLAGS. + // (Both will show the GOFLAGS setting if let succeed.) + hideErrors := cfg.CmdName == "env" || cfg.CmdName == "bug" + + var err error + goflags, err = quoted.Split(cfg.Getenv("GOFLAGS")) + if err != nil { + if hideErrors { + return + } + Fatalf("go: parsing $GOFLAGS: %v", err) + } + + if len(goflags) == 0 { + // nothing to do; avoid work on later InitGOFLAGS call + goflags = []string{} + return + } + + // Each of the words returned by strings.Fields must be its own flag. + // To set flag arguments use -x=value instead of -x value. + // For boolean flags, -x is fine instead of -x=true. + for _, f := range goflags { + // Check that every flag looks like -x --x -x=value or --x=value. + if !strings.HasPrefix(f, "-") || f == "-" || f == "--" || strings.HasPrefix(f, "---") || strings.HasPrefix(f, "-=") || strings.HasPrefix(f, "--=") { + if hideErrors { + continue + } + Fatalf("go: parsing $GOFLAGS: non-flag %q", f) + } + + name := f[1:] + if name[0] == '-' { + name = name[1:] + } + if i := strings.Index(name, "="); i >= 0 { + name = name[:i] + } + if !hasFlag(Go, name) { + if hideErrors { + continue + } + Fatalf("go: parsing $GOFLAGS: unknown flag -%s", name) + } + } +} + +// boolFlag is the optional interface for flag.Value known to the flag package. +// (It is not clear why package flag does not export this interface.) +type boolFlag interface { + flag.Value + IsBoolFlag() bool +} + +// SetFromGOFLAGS sets the flags in the given flag set using settings in $GOFLAGS. +func SetFromGOFLAGS(flags *flag.FlagSet) { + InitGOFLAGS() + + // This loop is similar to flag.Parse except that it ignores + // unknown flags found in goflags, so that setting, say, GOFLAGS=-ldflags=-w + // does not break commands that don't have a -ldflags. + // It also adjusts the output to be clear that the reported problem is from $GOFLAGS. + where := "$GOFLAGS" + if runtime.GOOS == "windows" { + where = "%GOFLAGS%" + } + for _, goflag := range goflags { + name, value, hasValue := goflag, "", false + // Ignore invalid flags like '=' or '=value'. + // If it is not reported in InitGOFlags it means we don't want to report it. + if i := strings.Index(goflag, "="); i == 0 { + continue + } else if i > 0 { + name, value, hasValue = goflag[:i], goflag[i+1:], true + } + if strings.HasPrefix(name, "--") { + name = name[1:] + } + f := flags.Lookup(name[1:]) + if f == nil { + continue + } + + // Use flags.Set consistently (instead of f.Value.Set) so that a subsequent + // call to flags.Visit will correctly visit the flags that have been set. + + if fb, ok := f.Value.(boolFlag); ok && fb.IsBoolFlag() { + if hasValue { + if err := flags.Set(f.Name, value); err != nil { + fmt.Fprintf(flags.Output(), "go: invalid boolean value %q for flag %s (from %s): %v\n", value, name, where, err) + flags.Usage() + } + } else { + if err := flags.Set(f.Name, "true"); err != nil { + fmt.Fprintf(flags.Output(), "go: invalid boolean flag %s (from %s): %v\n", name, where, err) + flags.Usage() + } + } + } else { + if !hasValue { + fmt.Fprintf(flags.Output(), "go: flag needs an argument: %s (from %s)\n", name, where) + flags.Usage() + } + if err := flags.Set(f.Name, value); err != nil { + fmt.Fprintf(flags.Output(), "go: invalid value %q for flag %s (from %s): %v\n", value, name, where, err) + flags.Usage() + } + } + } +} + +// InGOFLAGS returns whether GOFLAGS contains the given flag, such as "-mod". +func InGOFLAGS(flag string) bool { + for _, goflag := range GOFLAGS() { + name := goflag + if strings.HasPrefix(name, "--") { + name = name[1:] + } + if i := strings.Index(name, "="); i >= 0 { + name = name[:i] + } + if name == flag { + return true + } + } + return false +} diff --git a/go/src/cmd/go/internal/base/limit.go b/go/src/cmd/go/internal/base/limit.go new file mode 100644 index 0000000000000000000000000000000000000000..a90b700a031e3a1bc58dae943a31ca151ec5aced --- /dev/null +++ b/go/src/cmd/go/internal/base/limit.go @@ -0,0 +1,86 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "fmt" + "internal/godebug" + "runtime" + "strconv" + "sync" +) + +var NetLimitGodebug = godebug.New("#cmdgonetlimit") + +// NetLimit returns the limit on concurrent network operations +// configured by GODEBUG=cmdgonetlimit, if any. +// +// A limit of 0 (indicated by 0, true) means that network operations should not +// be allowed. +func NetLimit() (int, bool) { + netLimitOnce.Do(func() { + s := NetLimitGodebug.Value() + if s == "" { + return + } + + n, err := strconv.Atoi(s) + if err != nil { + Fatalf("invalid %s: %v", NetLimitGodebug.Name(), err) + } + if n < 0 { + // Treat negative values as unlimited. + return + } + netLimitSem = make(chan struct{}, n) + }) + + return cap(netLimitSem), netLimitSem != nil +} + +// AcquireNet acquires a semaphore token for a network operation. +func AcquireNet() (release func(), err error) { + hasToken := false + if n, ok := NetLimit(); ok { + if n == 0 { + return nil, fmt.Errorf("network disabled by %v=%v", NetLimitGodebug.Name(), NetLimitGodebug.Value()) + } + netLimitSem <- struct{}{} + hasToken = true + } + + checker := new(netTokenChecker) + cleanup := runtime.AddCleanup(checker, func(_ int) { panic("internal error: net token acquired but not released") }, 0) + + return func() { + if checker.released { + panic("internal error: net token released twice") + } + checker.released = true + if hasToken { + <-netLimitSem + } + cleanup.Stop() + + // checker may be dead at the moment after we last access + // it in this function, so the cleanup can fire before Stop + // completes. Keep checker alive while we call Stop. See + // the documentation for runtime.Cleanup.Stop. + runtime.KeepAlive(checker) + }, nil +} + +var ( + netLimitOnce sync.Once + netLimitSem chan struct{} +) + +type netTokenChecker struct { + released bool + // We want to use a finalizer to check that all acquired tokens are returned, + // so we arbitrarily pad the tokens with a string to defeat the runtime's + // “tiny allocator”. + unusedAvoidTinyAllocator string +} diff --git a/go/src/cmd/go/internal/base/path.go b/go/src/cmd/go/internal/base/path.go new file mode 100644 index 0000000000000000000000000000000000000000..a7577f62e768985806601f42f5f36980e150c4fb --- /dev/null +++ b/go/src/cmd/go/internal/base/path.go @@ -0,0 +1,93 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "errors" + "io/fs" + "os" + "path/filepath" + "runtime" + "strings" + "sync" +) + +// UncachedCwd returns the current working directory. +// Most callers should use Cwd, which caches the result for future use. +// UncachedCwd is appropriate to call early in program startup before flag parsing, +// because the -C flag may change the current directory. +func UncachedCwd() string { + wd, err := os.Getwd() + if err != nil { + Fatalf("cannot determine current directory: %v", err) + } + return wd +} + +var cwdOnce = sync.OnceValue(UncachedCwd) + +// Cwd returns the current working directory at the time of the first call. +func Cwd() string { + return cwdOnce() +} + +// ShortPath returns an absolute or relative name for path, whatever is shorter. +// ShortPath should only be used when formatting paths for error messages. +func ShortPath(path string) string { + if rel, err := filepath.Rel(Cwd(), path); err == nil && len(rel) < len(path) && sameFile(rel, path) { + return rel + } + return path +} + +func sameFile(path1, path2 string) bool { + fi1, err1 := os.Stat(path1) + fi2, err2 := os.Stat(path2) + if err1 != nil || err2 != nil { + // If there were errors statting the files return false, + // unless both of the files don't exist. + return os.IsNotExist(err1) && os.IsNotExist(err2) + } + return os.SameFile(fi1, fi2) +} + +// ShortPathError rewrites the path in err using base.ShortPath, if err is a wrapped PathError. +func ShortPathError(err error) error { + if pe, ok := errors.AsType[*fs.PathError](err); ok { + pe.Path = ShortPath(pe.Path) + } + return err +} + +// RelPaths returns a copy of paths with absolute paths +// made relative to the current directory if they would be shorter. +func RelPaths(paths []string) []string { + out := make([]string, 0, len(paths)) + for _, p := range paths { + out = append(out, ShortPath(p)) + } + return out +} + +// IsTestFile reports whether the source file is a set of tests and should therefore +// be excluded from coverage analysis. +func IsTestFile(file string) bool { + // We don't cover tests, only the code they test. + return strings.HasSuffix(file, "_test.go") +} + +// IsNull reports whether the path is a common name for the null device. +// It returns true for /dev/null on Unix, or NUL (case-insensitive) on Windows. +func IsNull(path string) bool { + if path == os.DevNull { + return true + } + if runtime.GOOS == "windows" { + if strings.EqualFold(path, "NUL") { + return true + } + } + return false +} diff --git a/go/src/cmd/go/internal/base/signal.go b/go/src/cmd/go/internal/base/signal.go new file mode 100644 index 0000000000000000000000000000000000000000..c15dd47b7d57148d2fce4b43f950f3002b776bd4 --- /dev/null +++ b/go/src/cmd/go/internal/base/signal.go @@ -0,0 +1,31 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "os" + "os/signal" + "sync" +) + +// Interrupted is closed when the go command receives an interrupt signal. +var Interrupted = make(chan struct{}) + +// processSignals setups signal handler. +func processSignals() { + sig := make(chan os.Signal, 1) + signal.Notify(sig, signalsToIgnore...) + go func() { + <-sig + close(Interrupted) + }() +} + +var processSignalsOnce = sync.OnceFunc(processSignals) + +// StartSigHandlers starts the signal handlers. +func StartSigHandlers() { + processSignalsOnce() +} diff --git a/go/src/cmd/go/internal/base/signal_notunix.go b/go/src/cmd/go/internal/base/signal_notunix.go new file mode 100644 index 0000000000000000000000000000000000000000..682705f9b2cb41e3a6fc81fd74536a3aa4e42104 --- /dev/null +++ b/go/src/cmd/go/internal/base/signal_notunix.go @@ -0,0 +1,17 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build plan9 || windows + +package base + +import ( + "os" +) + +var signalsToIgnore = []os.Signal{os.Interrupt} + +// SignalTrace is the signal to send to make a Go program +// crash with a stack trace (no such signal in this case). +var SignalTrace os.Signal = nil diff --git a/go/src/cmd/go/internal/base/signal_unix.go b/go/src/cmd/go/internal/base/signal_unix.go new file mode 100644 index 0000000000000000000000000000000000000000..0905971932606911be61e82a084f863e2e65982c --- /dev/null +++ b/go/src/cmd/go/internal/base/signal_unix.go @@ -0,0 +1,18 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix || js || wasip1 + +package base + +import ( + "os" + "syscall" +) + +var signalsToIgnore = []os.Signal{os.Interrupt, syscall.SIGQUIT} + +// SignalTrace is the signal to send to make a Go program +// crash with a stack trace. +var SignalTrace os.Signal = syscall.SIGQUIT diff --git a/go/src/cmd/go/internal/base/tool.go b/go/src/cmd/go/internal/base/tool.go new file mode 100644 index 0000000000000000000000000000000000000000..f2fc0ff7435f86e6c50e6a7eed49149a726bc889 --- /dev/null +++ b/go/src/cmd/go/internal/base/tool.go @@ -0,0 +1,55 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package base + +import ( + "fmt" + "go/build" + "os" + "path/filepath" + + "cmd/go/internal/cfg" + "cmd/internal/par" +) + +// Tool returns the path to the named builtin tool (for example, "vet"). +// If the tool cannot be found, Tool exits the process. +func Tool(toolName string) string { + toolPath, err := ToolPath(toolName) + if err != nil && len(cfg.BuildToolexec) == 0 { + // Give a nice message if there is no tool with that name. + fmt.Fprintf(os.Stderr, "go: no such tool %q\n", toolName) + SetExitStatus(2) + Exit() + } + return toolPath +} + +// ToolPath returns the path at which we expect to find the named tool +// (for example, "vet"), and the error (if any) from statting that path. +func ToolPath(toolName string) (string, error) { + if !ValidToolName(toolName) { + return "", fmt.Errorf("bad tool name: %q", toolName) + } + toolPath := filepath.Join(build.ToolDir, toolName) + cfg.ToolExeSuffix() + err := toolStatCache.Do(toolPath, func() error { + _, err := os.Stat(toolPath) + return err + }) + return toolPath, err +} + +func ValidToolName(toolName string) bool { + for _, c := range toolName { + switch { + case 'a' <= c && c <= 'z', '0' <= c && c <= '9', c == '_': + default: + return false + } + } + return true +} + +var toolStatCache par.Cache[string, error] diff --git a/go/src/cmd/go/internal/bug/bug.go b/go/src/cmd/go/internal/bug/bug.go new file mode 100644 index 0000000000000000000000000000000000000000..f967e9a8ef572540f8d17e51f0184018c6b4a25e --- /dev/null +++ b/go/src/cmd/go/internal/bug/bug.go @@ -0,0 +1,226 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package bug implements the “go bug” command. +package bug + +import ( + "bytes" + "context" + "fmt" + "io" + urlpkg "net/url" + "os" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/envcmd" + "cmd/go/internal/modload" + "cmd/go/internal/web" + "cmd/go/internal/work" +) + +var CmdBug = &base.Command{ + Run: runBug, + UsageLine: "go bug", + Short: "start a bug report", + Long: ` +Bug opens the default browser and starts a new bug report. +The report includes useful system information. + `, +} + +func init() { + CmdBug.Flag.BoolVar(&cfg.BuildV, "v", false, "") + base.AddChdirFlag(&CmdBug.Flag) +} + +func runBug(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + if len(args) > 0 { + base.Fatalf("go: bug takes no arguments") + } + work.BuildInit(moduleLoaderState) + + var buf strings.Builder + buf.WriteString(bugHeader) + printGoVersion(&buf) + buf.WriteString("### Does this issue reproduce with the latest release?\n\n\n") + printEnvDetails(moduleLoaderState, &buf) + buf.WriteString(bugFooter) + + body := buf.String() + url := "https://github.com/golang/go/issues/new?body=" + urlpkg.QueryEscape(body) + if !web.OpenBrowser(url) { + fmt.Print("Please file a new issue at golang.org/issue/new using this template:\n\n") + fmt.Print(body) + } +} + +const bugHeader = ` + +` +const bugFooter = `### What did you do? + + + + + +### What did you expect to see? + + + +### What did you see instead? + +` + +func printGoVersion(w io.Writer) { + fmt.Fprintf(w, "### What version of Go are you using (`go version`)?\n\n") + fmt.Fprintf(w, "
    \n")
    +	fmt.Fprintf(w, "$ go version\n")
    +	fmt.Fprintf(w, "go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
    +	fmt.Fprintf(w, "
    \n") + fmt.Fprintf(w, "\n") +} + +func printEnvDetails(loaderstate *modload.State, w io.Writer) { + fmt.Fprintf(w, "### What operating system and processor architecture are you using (`go env`)?\n\n") + fmt.Fprintf(w, "
    go env Output
    \n")
    +	fmt.Fprintf(w, "$ go env\n")
    +	printGoEnv(loaderstate, w)
    +	printGoDetails(w)
    +	printOSDetails(w)
    +	printCDetails(w)
    +	fmt.Fprintf(w, "
    \n\n") +} + +func printGoEnv(loaderstate *modload.State, w io.Writer) { + env := envcmd.MkEnv() + env = append(env, envcmd.ExtraEnvVars(loaderstate)...) + env = append(env, envcmd.ExtraEnvVarsCostly(loaderstate)...) + envcmd.PrintEnv(w, env, false) +} + +func printGoDetails(w io.Writer) { + gocmd := filepath.Join(runtime.GOROOT(), "bin/go") + printCmdOut(w, "GOROOT/bin/go version: ", gocmd, "version") + printCmdOut(w, "GOROOT/bin/go tool compile -V: ", gocmd, "tool", "compile", "-V") +} + +func printOSDetails(w io.Writer) { + switch runtime.GOOS { + case "darwin", "ios": + printCmdOut(w, "uname -v: ", "uname", "-v") + printCmdOut(w, "", "sw_vers") + case "linux": + printCmdOut(w, "uname -sr: ", "uname", "-sr") + printCmdOut(w, "", "lsb_release", "-a") + printGlibcVersion(w) + case "openbsd", "netbsd", "freebsd", "dragonfly": + printCmdOut(w, "uname -v: ", "uname", "-v") + case "illumos", "solaris": + // Be sure to use the OS-supplied uname, in "/usr/bin": + printCmdOut(w, "uname -srv: ", "/usr/bin/uname", "-srv") + out, err := os.ReadFile("/etc/release") + if err == nil { + fmt.Fprintf(w, "/etc/release: %s\n", out) + } else { + if cfg.BuildV { + fmt.Printf("failed to read /etc/release: %v\n", err) + } + } + } +} + +func printCDetails(w io.Writer) { + printCmdOut(w, "lldb --version: ", "lldb", "--version") + cmd := exec.Command("gdb", "--version") + out, err := cmd.Output() + if err == nil { + // There's apparently no combination of command line flags + // to get gdb to spit out its version without the license and warranty. + // Print up to the first newline. + fmt.Fprintf(w, "gdb --version: %s\n", firstLine(out)) + } else { + if cfg.BuildV { + fmt.Printf("failed to run gdb --version: %v\n", err) + } + } +} + +// printCmdOut prints the output of running the given command. +// It ignores failures; 'go bug' is best effort. +func printCmdOut(w io.Writer, prefix, path string, args ...string) { + cmd := exec.Command(path, args...) + out, err := cmd.Output() + if err != nil { + if cfg.BuildV { + fmt.Printf("%s %s: %v\n", path, strings.Join(args, " "), err) + } + return + } + fmt.Fprintf(w, "%s%s\n", prefix, bytes.TrimSpace(out)) +} + +// firstLine returns the first line of a given byte slice. +func firstLine(buf []byte) []byte { + idx := bytes.IndexByte(buf, '\n') + if idx > 0 { + buf = buf[:idx] + } + return bytes.TrimSpace(buf) +} + +// printGlibcVersion prints information about the glibc version. +// It ignores failures. +func printGlibcVersion(w io.Writer) { + tempdir, err := os.MkdirTemp("", "") + if err != nil { + return + } + src := []byte(`int main() {}`) + srcfile := filepath.Join(tempdir, "go-bug.c") + outfile := filepath.Join(tempdir, "go-bug") + err = os.WriteFile(srcfile, src, 0644) + if err != nil { + return + } + defer os.Remove(srcfile) + cmd := exec.Command("gcc", "-o", outfile, srcfile) + if _, err = cmd.CombinedOutput(); err != nil { + return + } + defer os.Remove(outfile) + + cmd = exec.Command("ldd", outfile) + out, err := cmd.CombinedOutput() + if err != nil { + return + } + re := regexp.MustCompile(`libc\.so[^ ]* => ([^ ]+)`) + m := re.FindStringSubmatch(string(out)) + if m == nil { + return + } + cmd = exec.Command(m[1]) + out, err = cmd.Output() + if err != nil { + return + } + fmt.Fprintf(w, "%s: %s\n", m[1], firstLine(out)) + + // print another line (the one containing version string) in case of musl libc + if idx := bytes.IndexByte(out, '\n'); bytes.Contains(out, []byte("musl")) && idx > -1 { + fmt.Fprintf(w, "%s\n", firstLine(out[idx+1:])) + } +} diff --git a/go/src/cmd/go/internal/cache/cache.go b/go/src/cmd/go/internal/cache/cache.go new file mode 100644 index 0000000000000000000000000000000000000000..67f8202c06a55c99cfb88467574aadc0494f9b1f --- /dev/null +++ b/go/src/cmd/go/internal/cache/cache.go @@ -0,0 +1,720 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package cache implements a build artifact cache. +package cache + +import ( + "bytes" + "crypto/sha256" + "encoding/hex" + "errors" + "fmt" + "internal/godebug" + "io" + "io/fs" + "os" + "path/filepath" + "strconv" + "strings" + "time" + + "cmd/go/internal/base" + "cmd/go/internal/lockedfile" + "cmd/go/internal/mmap" +) + +// An ActionID is a cache action key, the hash of a complete description of a +// repeatable computation (command line, environment variables, +// input file contents, executable contents). +type ActionID [HashSize]byte + +// An OutputID is a cache output key, the hash of an output of a computation. +type OutputID [HashSize]byte + +// Cache is the interface as used by the cmd/go. +type Cache interface { + // Get returns the cache entry for the provided ActionID. + // On miss, the error type should be of type *entryNotFoundError. + // + // After a successful call to Get, OutputFile(Entry.OutputID) must + // exist on disk until Close is called (at the end of the process). + Get(ActionID) (Entry, error) + + // Put adds an item to the cache. + // + // The seeker is only used to seek to the beginning. After a call to Put, + // the seek position is not guaranteed to be in any particular state. + // + // As a special case, if the ReadSeeker is of type noVerifyReadSeeker, + // the verification from GODEBUG=goverifycache=1 is skipped. + // + // After a successful call to Put, OutputFile(OutputID) must + // exist on disk until Close is called (at the end of the process). + Put(ActionID, io.ReadSeeker) (_ OutputID, size int64, _ error) + + // Close is called at the end of the go process. Implementations can do + // cache cleanup work at this phase, or wait for and report any errors from + // background cleanup work started earlier. Any cache trimming in one + // process should not cause the invariants of this interface to be + // violated in another process. Namely, a cache trim from one process should + // not delete an OutputID from disk that was recently Get or Put from + // another process. As a rule of thumb, don't trim things used in the last + // day. + Close() error + + // OutputFile returns the path on disk where OutputID is stored. + // + // It's only called after a successful get or put call so it doesn't need + // to return an error; it's assumed that if the previous get or put succeeded, + // it's already on disk. + OutputFile(OutputID) string + + // FuzzDir returns where fuzz files are stored. + FuzzDir() string +} + +// A Cache is a package cache, backed by a file system directory tree. +type DiskCache struct { + dir string + now func() time.Time +} + +// Open opens and returns the cache in the given directory. +// +// It is safe for multiple processes on a single machine to use the +// same cache directory in a local file system simultaneously. +// They will coordinate using operating system file locks and may +// duplicate effort but will not corrupt the cache. +// +// However, it is NOT safe for multiple processes on different machines +// to share a cache directory (for example, if the directory were stored +// in a network file system). File locking is notoriously unreliable in +// network file systems and may not suffice to protect the cache. +func Open(dir string) (*DiskCache, error) { + info, err := os.Stat(dir) + if err != nil { + return nil, err + } + if !info.IsDir() { + return nil, &fs.PathError{Op: "open", Path: dir, Err: fmt.Errorf("not a directory")} + } + for i := 0; i < 256; i++ { + name := filepath.Join(dir, fmt.Sprintf("%02x", i)) + if err := os.MkdirAll(name, 0o777); err != nil { + return nil, err + } + } + c := &DiskCache{ + dir: dir, + now: time.Now, + } + return c, nil +} + +// fileName returns the name of the file corresponding to the given id. +func (c *DiskCache) fileName(id [HashSize]byte, key string) string { + return filepath.Join(c.dir, fmt.Sprintf("%02x", id[0]), fmt.Sprintf("%x", id)+"-"+key) +} + +// An entryNotFoundError indicates that a cache entry was not found, with an +// optional underlying reason. +type entryNotFoundError struct { + Err error +} + +func (e *entryNotFoundError) Error() string { + if e.Err == nil { + return "cache entry not found" + } + return fmt.Sprintf("cache entry not found: %v", e.Err) +} + +func (e *entryNotFoundError) Unwrap() error { + return e.Err +} + +const ( + // action entry file is "v1 \n" + hexSize = HashSize * 2 + entrySize = 2 + 1 + hexSize + 1 + hexSize + 1 + 20 + 1 + 20 + 1 +) + +// verify controls whether to run the cache in verify mode. +// In verify mode, the cache always returns errMissing from Get +// but then double-checks in Put that the data being written +// exactly matches any existing entry. This provides an easy +// way to detect program behavior that would have been different +// had the cache entry been returned from Get. +// +// verify is enabled by setting the environment variable +// GODEBUG=gocacheverify=1. +var verify = false + +var errVerifyMode = errors.New("gocacheverify=1") + +// DebugTest is set when GODEBUG=gocachetest=1 is in the environment. +var DebugTest = false + +func init() { initEnv() } + +var ( + gocacheverify = godebug.New("gocacheverify") + gocachehash = godebug.New("gocachehash") + gocachetest = godebug.New("gocachetest") +) + +func initEnv() { + if gocacheverify.Value() == "1" { + gocacheverify.IncNonDefault() + verify = true + } + if gocachehash.Value() == "1" { + gocachehash.IncNonDefault() + debugHash = true + } + if gocachetest.Value() == "1" { + gocachetest.IncNonDefault() + DebugTest = true + } +} + +// Get looks up the action ID in the cache, +// returning the corresponding output ID and file size, if any. +// Note that finding an output ID does not guarantee that the +// saved file for that output ID is still available. +func (c *DiskCache) Get(id ActionID) (Entry, error) { + if verify { + return Entry{}, &entryNotFoundError{Err: errVerifyMode} + } + return c.get(id) +} + +type Entry struct { + OutputID OutputID + Size int64 + Time time.Time // when added to cache +} + +// get is Get but does not respect verify mode, so that Put can use it. +func (c *DiskCache) get(id ActionID) (Entry, error) { + missing := func(reason error) (Entry, error) { + return Entry{}, &entryNotFoundError{Err: reason} + } + f, err := os.Open(c.fileName(id, "a")) + if err != nil { + return missing(err) + } + defer f.Close() + entry := make([]byte, entrySize+1) // +1 to detect whether f is too long + if n, err := io.ReadFull(f, entry); n > entrySize { + return missing(errors.New("too long")) + } else if err != io.ErrUnexpectedEOF { + if err == io.EOF { + return missing(errors.New("file is empty")) + } + return missing(err) + } else if n < entrySize { + return missing(errors.New("entry file incomplete")) + } + if entry[0] != 'v' || entry[1] != '1' || entry[2] != ' ' || entry[3+hexSize] != ' ' || entry[3+hexSize+1+hexSize] != ' ' || entry[3+hexSize+1+hexSize+1+20] != ' ' || entry[entrySize-1] != '\n' { + return missing(errors.New("invalid header")) + } + eid, entry := entry[3:3+hexSize], entry[3+hexSize:] + eout, entry := entry[1:1+hexSize], entry[1+hexSize:] + esize, entry := entry[1:1+20], entry[1+20:] + etime, entry := entry[1:1+20], entry[1+20:] + var buf [HashSize]byte + if _, err := hex.Decode(buf[:], eid); err != nil { + return missing(fmt.Errorf("decoding ID: %v", err)) + } else if buf != id { + return missing(errors.New("mismatched ID")) + } + if _, err := hex.Decode(buf[:], eout); err != nil { + return missing(fmt.Errorf("decoding output ID: %v", err)) + } + i := 0 + for i < len(esize) && esize[i] == ' ' { + i++ + } + size, err := strconv.ParseInt(string(esize[i:]), 10, 64) + if err != nil { + return missing(fmt.Errorf("parsing size: %v", err)) + } else if size < 0 { + return missing(errors.New("negative size")) + } + i = 0 + for i < len(etime) && etime[i] == ' ' { + i++ + } + tm, err := strconv.ParseInt(string(etime[i:]), 10, 64) + if err != nil { + return missing(fmt.Errorf("parsing timestamp: %v", err)) + } else if tm < 0 { + return missing(errors.New("negative timestamp")) + } + + c.markUsed(c.fileName(id, "a")) + + return Entry{buf, size, time.Unix(0, tm)}, nil +} + +// GetFile looks up the action ID in the cache and returns +// the name of the corresponding data file. +func GetFile(c Cache, id ActionID) (file string, entry Entry, err error) { + entry, err = c.Get(id) + if err != nil { + return "", Entry{}, err + } + file = c.OutputFile(entry.OutputID) + info, err := os.Stat(file) + if err != nil { + return "", Entry{}, &entryNotFoundError{Err: err} + } + if info.Size() != entry.Size { + return "", Entry{}, &entryNotFoundError{Err: errors.New("file incomplete")} + } + return file, entry, nil +} + +// GetBytes looks up the action ID in the cache and returns +// the corresponding output bytes. +// GetBytes should only be used for data that can be expected to fit in memory. +func GetBytes(c Cache, id ActionID) ([]byte, Entry, error) { + entry, err := c.Get(id) + if err != nil { + return nil, entry, err + } + data, _ := os.ReadFile(c.OutputFile(entry.OutputID)) + if sha256.Sum256(data) != entry.OutputID { + return nil, entry, &entryNotFoundError{Err: errors.New("bad checksum")} + } + return data, entry, nil +} + +// GetMmap looks up the action ID in the cache and returns +// the corresponding output bytes. +// GetMmap should only be used for data that can be expected to fit in memory. +// The boolean result indicates whether the file was opened. +// If it is true, the caller should avoid attempting +// to write to the file on Windows, because Windows locks +// the open file, and writes to it will fail. +func GetMmap(c Cache, id ActionID) ([]byte, Entry, bool, error) { + entry, err := c.Get(id) + if err != nil { + return nil, entry, false, err + } + md, opened, err := mmap.Mmap(c.OutputFile(entry.OutputID)) + if err != nil { + return nil, Entry{}, opened, err + } + if int64(len(md.Data)) != entry.Size { + return nil, Entry{}, true, &entryNotFoundError{Err: errors.New("file incomplete")} + } + return md.Data, entry, true, nil +} + +// OutputFile returns the name of the cache file storing output with the given OutputID. +func (c *DiskCache) OutputFile(out OutputID) string { + file := c.fileName(out, "d") + isDir := c.markUsed(file) + if isDir { // => cached executable + entries, err := os.ReadDir(file) + if err != nil { + return fmt.Sprintf("DO NOT USE - missing binary cache entry: %v", err) + } + if len(entries) != 1 { + return "DO NOT USE - invalid binary cache entry" + } + return filepath.Join(file, entries[0].Name()) + } + return file +} + +// Time constants for cache expiration. +// +// We set the mtime on a cache file on each use, but at most one per mtimeInterval (1 hour), +// to avoid causing many unnecessary inode updates. The mtimes therefore +// roughly reflect "time of last use" but may in fact be older by at most an hour. +// +// We scan the cache for entries to delete at most once per trimInterval (1 day). +// +// When we do scan the cache, we delete entries that have not been used for +// at least trimLimit (5 days). Statistics gathered from a month of usage by +// Go developers found that essentially all reuse of cached entries happened +// within 5 days of the previous reuse. See golang.org/issue/22990. +const ( + mtimeInterval = 1 * time.Hour + trimInterval = 24 * time.Hour + trimLimit = 5 * 24 * time.Hour +) + +// markUsed makes a best-effort attempt to update mtime on file, +// so that mtime reflects cache access time. +// +// Because the reflection only needs to be approximate, +// and to reduce the amount of disk activity caused by using +// cache entries, used only updates the mtime if the current +// mtime is more than an hour old. This heuristic eliminates +// nearly all of the mtime updates that would otherwise happen, +// while still keeping the mtimes useful for cache trimming. +// +// markUsed reports whether the file is a directory (an executable cache entry). +func (c *DiskCache) markUsed(file string) (isDir bool) { + info, err := os.Stat(file) + if err != nil { + return false + } + if now := c.now(); now.Sub(info.ModTime()) >= mtimeInterval { + os.Chtimes(file, now, now) + } + return info.IsDir() +} + +func (c *DiskCache) Close() error { return c.Trim() } + +// Trim removes old cache entries that are likely not to be reused. +func (c *DiskCache) Trim() error { + now := c.now() + + // We maintain in dir/trim.txt the time of the last completed cache trim. + // If the cache has been trimmed recently enough, do nothing. + // This is the common case. + // If the trim file is corrupt, detected if the file can't be parsed, or the + // trim time is too far in the future, attempt the trim anyway. It's possible that + // the cache was full when the corruption happened. Attempting a trim on + // an empty cache is cheap, so there wouldn't be a big performance hit in that case. + skipTrim := func(data []byte) bool { + if t, err := strconv.ParseInt(strings.TrimSpace(string(data)), 10, 64); err == nil { + lastTrim := time.Unix(t, 0) + if d := now.Sub(lastTrim); d < trimInterval && d > -mtimeInterval { + return true + } + } + return false + } + // Check to see if we need a trim. Do this check separately from the lockedfile.Transform + // so that we can skip getting an exclusive lock in the common case. + if data, err := lockedfile.Read(filepath.Join(c.dir, "trim.txt")); err == nil { + if skipTrim(data) { + return nil + } + } + + errFileChanged := errors.New("file changed") + + // Write the new timestamp before we start trimming to reduce the chance that multiple invocations + // try to trim at the same time, causing contention in CI (#76314). + err := lockedfile.Transform(filepath.Join(c.dir, "trim.txt"), func(data []byte) ([]byte, error) { + if skipTrim(data) { + // The timestamp in the file no longer meets the criteria for us to + // do a trim. It must have been updated by another go command invocation + // since we last read it. Skip the trim. + return nil, errFileChanged + } + return fmt.Appendf(nil, "%d", now.Unix()), nil + }) + if errors.Is(err, errors.ErrUnsupported) { + return err + } + if errors.Is(err, errFileChanged) { + // Skip the trim because we don't need it anymore. + return nil + } + + // Trim each of the 256 subdirectories. + // We subtract an additional mtimeInterval + // to account for the imprecision of our "last used" mtimes. + cutoff := now.Add(-trimLimit - mtimeInterval) + for i := 0; i < 256; i++ { + subdir := filepath.Join(c.dir, fmt.Sprintf("%02x", i)) + c.trimSubdir(subdir, cutoff) + } + + return nil +} + +// trimSubdir trims a single cache subdirectory. +func (c *DiskCache) trimSubdir(subdir string, cutoff time.Time) { + // Read all directory entries from subdir before removing + // any files, in case removing files invalidates the file offset + // in the directory scan. Also, ignore error from f.Readdirnames, + // because we don't care about reporting the error and we still + // want to process any entries found before the error. + f, err := os.Open(subdir) + if err != nil { + return + } + names, _ := f.Readdirnames(-1) + f.Close() + + for _, name := range names { + // Remove only cache entries (xxxx-a and xxxx-d). + if !strings.HasSuffix(name, "-a") && !strings.HasSuffix(name, "-d") { + continue + } + entry := filepath.Join(subdir, name) + info, err := os.Stat(entry) + if err == nil && info.ModTime().Before(cutoff) { + if info.IsDir() { // executable cache entry + os.RemoveAll(entry) + continue + } + os.Remove(entry) + } + } +} + +// putIndexEntry adds an entry to the cache recording that executing the action +// with the given id produces an output with the given output id (hash) and size. +func (c *DiskCache) putIndexEntry(id ActionID, out OutputID, size int64, allowVerify bool) error { + // Note: We expect that for one reason or another it may happen + // that repeating an action produces a different output hash + // (for example, if the output contains a time stamp or temp dir name). + // While not ideal, this is also not a correctness problem, so we + // don't make a big deal about it. In particular, we leave the action + // cache entries writable specifically so that they can be overwritten. + // + // Setting GODEBUG=gocacheverify=1 does make a big deal: + // in verify mode we are double-checking that the cache entries + // are entirely reproducible. As just noted, this may be unrealistic + // in some cases but the check is also useful for shaking out real bugs. + entry := fmt.Sprintf("v1 %x %x %20d %20d\n", id, out, size, time.Now().UnixNano()) + if verify && allowVerify { + old, err := c.get(id) + if err == nil && (old.OutputID != out || old.Size != size) { + // panic to show stack trace, so we can see what code is generating this cache entry. + msg := fmt.Sprintf("go: internal cache error: cache verify failed: id=%x changed:<<<\n%s\n>>>\nold: %x %d\nnew: %x %d", id, reverseHash(id), out, size, old.OutputID, old.Size) + panic(msg) + } + } + file := c.fileName(id, "a") + + // Copy file to cache directory. + mode := os.O_WRONLY | os.O_CREATE + f, err := os.OpenFile(file, mode, 0o666) + if err != nil { + return err + } + _, err = f.WriteString(entry) + if err == nil { + // Truncate the file only *after* writing it. + // (This should be a no-op, but truncate just in case of previous corruption.) + // + // This differs from os.WriteFile, which truncates to 0 *before* writing + // via os.O_TRUNC. Truncating only after writing ensures that a second write + // of the same content to the same file is idempotent, and does not — even + // temporarily! — undo the effect of the first write. + err = f.Truncate(int64(len(entry))) + } + if closeErr := f.Close(); err == nil { + err = closeErr + } + if err != nil { + // TODO(bcmills): This Remove potentially races with another go command writing to file. + // Can we eliminate it? + os.Remove(file) + return err + } + os.Chtimes(file, c.now(), c.now()) // mainly for tests + + return nil +} + +// noVerifyReadSeeker is an io.ReadSeeker wrapper sentinel type +// that says that Cache.Put should skip the verify check +// (from GODEBUG=goverifycache=1). +type noVerifyReadSeeker struct { + io.ReadSeeker +} + +// Put stores the given output in the cache as the output for the action ID. +// It may read file twice. The content of file must not change between the two passes. +func (c *DiskCache) Put(id ActionID, file io.ReadSeeker) (OutputID, int64, error) { + wrapper, isNoVerify := file.(noVerifyReadSeeker) + if isNoVerify { + file = wrapper.ReadSeeker + } + return c.put(id, "", file, !isNoVerify) +} + +// PutExecutable is used to store the output as the output for the action ID into a +// file with the given base name, with the executable mode bit set. +// It may read file twice. The content of file must not change between the two passes. +func (c *DiskCache) PutExecutable(id ActionID, name string, file io.ReadSeeker) (OutputID, int64, error) { + if name == "" { + panic("PutExecutable called without a name") + } + wrapper, isNoVerify := file.(noVerifyReadSeeker) + if isNoVerify { + file = wrapper.ReadSeeker + } + return c.put(id, name, file, !isNoVerify) +} + +// PutNoVerify is like Put but disables the verify check +// when GODEBUG=goverifycache=1 is set. +// It is meant for data that is OK to cache but that we expect to vary slightly from run to run, +// like test output containing times and the like. +func PutNoVerify(c Cache, id ActionID, file io.ReadSeeker) (OutputID, int64, error) { + return c.Put(id, noVerifyReadSeeker{file}) +} + +func (c *DiskCache) put(id ActionID, executableName string, file io.ReadSeeker, allowVerify bool) (OutputID, int64, error) { + // Compute output ID. + h := sha256.New() + if _, err := file.Seek(0, 0); err != nil { + return OutputID{}, 0, err + } + size, err := io.Copy(h, file) + if err != nil { + return OutputID{}, 0, err + } + var out OutputID + h.Sum(out[:0]) + + // Copy to cached output file (if not already present). + fileMode := fs.FileMode(0o666) + if executableName != "" { + fileMode = 0o777 + } + if err := c.copyFile(file, executableName, out, size, fileMode); err != nil { + return out, size, err + } + + // Add to cache index. + return out, size, c.putIndexEntry(id, out, size, allowVerify) +} + +// PutBytes stores the given bytes in the cache as the output for the action ID. +func PutBytes(c Cache, id ActionID, data []byte) error { + _, _, err := c.Put(id, bytes.NewReader(data)) + return err +} + +// copyFile copies file into the cache, expecting it to have the given +// output ID and size, if that file is not present already. +func (c *DiskCache) copyFile(file io.ReadSeeker, executableName string, out OutputID, size int64, perm os.FileMode) error { + name := c.fileName(out, "d") // TODO(matloob): use a different suffix for the executable cache? + info, err := os.Stat(name) + if executableName != "" { + // This is an executable file. The file at name won't hold the output itself, but will + // be a directory that holds the output, named according to executableName. Check to see + // if the directory already exists, and if it does not, create it. Then reset name + // to the name we want the output written to. + if err != nil { + if !os.IsNotExist(err) { + return err + } + if err := os.Mkdir(name, 0o777); err != nil { + return err + } + if info, err = os.Stat(name); err != nil { + return err + } + } + if !info.IsDir() { + return errors.New("internal error: invalid binary cache entry: not a directory") + } + + // directory exists. now set name to the inner file + name = filepath.Join(name, executableName) + info, err = os.Stat(name) + } + if err == nil && info.Size() == size { + // Check hash. + if f, err := os.Open(name); err == nil { + h := sha256.New() + io.Copy(h, f) + f.Close() + var out2 OutputID + h.Sum(out2[:0]) + if out == out2 { + return nil + } + } + // Hash did not match. Fall through and rewrite file. + } + + // Copy file to cache directory. + mode := os.O_RDWR | os.O_CREATE + if err == nil && info.Size() > size { // shouldn't happen but fix in case + mode |= os.O_TRUNC + } + f, err := os.OpenFile(name, mode, perm) + if err != nil { + if base.IsETXTBSY(err) { + // This file is being used by an executable. It must have + // already been written by another go process and then run. + // return without an error. + return nil + } + return err + } + defer f.Close() + if size == 0 { + // File now exists with correct size. + // Only one possible zero-length file, so contents are OK too. + // Early return here makes sure there's a "last byte" for code below. + return nil + } + + // From here on, if any of the I/O writing the file fails, + // we make a best-effort attempt to truncate the file f + // before returning, to avoid leaving bad bytes in the file. + + // Copy file to f, but also into h to double-check hash. + if _, err := file.Seek(0, 0); err != nil { + f.Truncate(0) + return err + } + h := sha256.New() + w := io.MultiWriter(f, h) + if _, err := io.CopyN(w, file, size-1); err != nil { + f.Truncate(0) + return err + } + // Check last byte before writing it; writing it will make the size match + // what other processes expect to find and might cause them to start + // using the file. + buf := make([]byte, 1) + if _, err := file.Read(buf); err != nil { + f.Truncate(0) + return err + } + h.Write(buf) + sum := h.Sum(nil) + if !bytes.Equal(sum, out[:]) { + f.Truncate(0) + return fmt.Errorf("file content changed underfoot") + } + + // Commit cache file entry. + if _, err := f.Write(buf); err != nil { + f.Truncate(0) + return err + } + if err := f.Close(); err != nil { + // Data might not have been written, + // but file may look like it is the right size. + // To be extra careful, remove cached file. + os.Remove(name) + return err + } + os.Chtimes(name, c.now(), c.now()) // mainly for tests + + return nil +} + +// FuzzDir returns a subdirectory within the cache for storing fuzzing data. +// The subdirectory may not exist. +// +// This directory is managed by the internal/fuzz package. Files in this +// directory aren't removed by the 'go clean -cache' command or by Trim. +// They may be removed with 'go clean -fuzzcache'. +// +// TODO(#48526): make Trim remove unused files from this directory. +func (c *DiskCache) FuzzDir() string { + return filepath.Join(c.dir, "fuzz") +} diff --git a/go/src/cmd/go/internal/cache/cache_test.go b/go/src/cmd/go/internal/cache/cache_test.go new file mode 100644 index 0000000000000000000000000000000000000000..4d8112ab3b9284bffb31758135296cc6f45931d8 --- /dev/null +++ b/go/src/cmd/go/internal/cache/cache_test.go @@ -0,0 +1,264 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package cache + +import ( + "bytes" + "encoding/binary" + "fmt" + "internal/testenv" + "os" + "path/filepath" + "testing" + "time" +) + +func init() { + verify = false // even if GODEBUG is set +} + +func TestBasic(t *testing.T) { + dir := t.TempDir() + _, err := Open(filepath.Join(dir, "notexist")) + if err == nil { + t.Fatal(`Open("tmp/notexist") succeeded, want failure`) + } + + cdir := filepath.Join(dir, "c1") + if err := os.Mkdir(cdir, 0777); err != nil { + t.Fatal(err) + } + + c1, err := Open(cdir) + if err != nil { + t.Fatalf("Open(c1) (create): %v", err) + } + if err := c1.putIndexEntry(dummyID(1), dummyID(12), 13, true); err != nil { + t.Fatalf("addIndexEntry: %v", err) + } + if err := c1.putIndexEntry(dummyID(1), dummyID(2), 3, true); err != nil { // overwrite entry + t.Fatalf("addIndexEntry: %v", err) + } + if entry, err := c1.Get(dummyID(1)); err != nil || entry.OutputID != dummyID(2) || entry.Size != 3 { + t.Fatalf("c1.Get(1) = %x, %v, %v, want %x, %v, nil", entry.OutputID, entry.Size, err, dummyID(2), 3) + } + + c2, err := Open(cdir) + if err != nil { + t.Fatalf("Open(c2) (reuse): %v", err) + } + if entry, err := c2.Get(dummyID(1)); err != nil || entry.OutputID != dummyID(2) || entry.Size != 3 { + t.Fatalf("c2.Get(1) = %x, %v, %v, want %x, %v, nil", entry.OutputID, entry.Size, err, dummyID(2), 3) + } + if err := c2.putIndexEntry(dummyID(2), dummyID(3), 4, true); err != nil { + t.Fatalf("addIndexEntry: %v", err) + } + if entry, err := c1.Get(dummyID(2)); err != nil || entry.OutputID != dummyID(3) || entry.Size != 4 { + t.Fatalf("c1.Get(2) = %x, %v, %v, want %x, %v, nil", entry.OutputID, entry.Size, err, dummyID(3), 4) + } +} + +func TestGrowth(t *testing.T) { + c, err := Open(t.TempDir()) + if err != nil { + t.Fatalf("Open: %v", err) + } + + n := 10000 + if testing.Short() { + n = 10 + } + + for i := 0; i < n; i++ { + if err := c.putIndexEntry(dummyID(i), dummyID(i*99), int64(i)*101, true); err != nil { + t.Fatalf("addIndexEntry: %v", err) + } + id := ActionID(dummyID(i)) + entry, err := c.Get(id) + if err != nil { + t.Fatalf("Get(%x): %v", id, err) + } + if entry.OutputID != dummyID(i*99) || entry.Size != int64(i)*101 { + t.Errorf("Get(%x) = %x, %d, want %x, %d", id, entry.OutputID, entry.Size, dummyID(i*99), int64(i)*101) + } + } + for i := 0; i < n; i++ { + id := ActionID(dummyID(i)) + entry, err := c.Get(id) + if err != nil { + t.Fatalf("Get2(%x): %v", id, err) + } + if entry.OutputID != dummyID(i*99) || entry.Size != int64(i)*101 { + t.Errorf("Get2(%x) = %x, %d, want %x, %d", id, entry.OutputID, entry.Size, dummyID(i*99), int64(i)*101) + } + } +} + +func TestVerifyPanic(t *testing.T) { + os.Setenv("GODEBUG", "gocacheverify=1") + initEnv() + defer func() { + os.Unsetenv("GODEBUG") + verify = false + }() + + if !verify { + t.Fatal("initEnv did not set verify") + } + + c, err := Open(t.TempDir()) + if err != nil { + t.Fatalf("Open: %v", err) + } + + id := ActionID(dummyID(1)) + if err := PutBytes(c, id, []byte("abc")); err != nil { + t.Fatal(err) + } + + defer func() { + if err := recover(); err != nil { + t.Log(err) + return + } + }() + PutBytes(c, id, []byte("def")) + t.Fatal("mismatched Put did not panic in verify mode") +} + +func dummyID(x int) [HashSize]byte { + var out [HashSize]byte + binary.LittleEndian.PutUint64(out[:], uint64(x)) + return out +} + +func TestCacheTrim(t *testing.T) { + dir := t.TempDir() + c, err := Open(dir) + if err != nil { + t.Fatalf("Open: %v", err) + } + const start = 1000000000 + now := int64(start) + c.now = func() time.Time { return time.Unix(now, 0) } + + checkTime := func(name string, mtime int64) { + t.Helper() + file := filepath.Join(c.dir, name[:2], name) + info, err := os.Stat(file) + if err != nil { + t.Fatal(err) + } + if info.ModTime().Unix() != mtime { + t.Fatalf("%s mtime = %d, want %d", name, info.ModTime().Unix(), mtime) + } + } + + id := ActionID(dummyID(1)) + PutBytes(c, id, []byte("abc")) + entry, _ := c.Get(id) + PutBytes(c, ActionID(dummyID(2)), []byte("def")) + mtime := now + checkTime(fmt.Sprintf("%x-a", id), mtime) + checkTime(fmt.Sprintf("%x-d", entry.OutputID), mtime) + + // Get should not change recent mtimes. + now = start + 10 + c.Get(id) + checkTime(fmt.Sprintf("%x-a", id), mtime) + checkTime(fmt.Sprintf("%x-d", entry.OutputID), mtime) + + // Get should change distant mtimes. + now = start + 5000 + mtime2 := now + if _, err := c.Get(id); err != nil { + t.Fatal(err) + } + c.OutputFile(entry.OutputID) + checkTime(fmt.Sprintf("%x-a", id), mtime2) + checkTime(fmt.Sprintf("%x-d", entry.OutputID), mtime2) + + // Trim should leave everything alone: it's all too new. + if err := c.Trim(); err != nil { + if testenv.SyscallIsNotSupported(err) { + t.Skipf("skipping: Trim is unsupported (%v)", err) + } + t.Fatal(err) + } + if _, err := c.Get(id); err != nil { + t.Fatal(err) + } + c.OutputFile(entry.OutputID) + data, err := os.ReadFile(filepath.Join(dir, "trim.txt")) + if err != nil { + t.Fatal(err) + } + checkTime(fmt.Sprintf("%x-a", dummyID(2)), start) + + // Trim less than a day later should not do any work at all. + now = start + 80000 + if err := c.Trim(); err != nil { + t.Fatal(err) + } + if _, err := c.Get(id); err != nil { + t.Fatal(err) + } + c.OutputFile(entry.OutputID) + data2, err := os.ReadFile(filepath.Join(dir, "trim.txt")) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(data, data2) { + t.Fatalf("second trim did work: %q -> %q", data, data2) + } + + // Fast forward and do another trim just before the 5 day cutoff. + // Note that because of usedQuantum the cutoff is actually 5 days + 1 hour. + // We used c.Get(id) just now, so 5 days later it should still be kept. + // On the other hand almost a full day has gone by since we wrote dummyID(2) + // and we haven't looked at it since, so 5 days later it should be gone. + now += 5 * 86400 + checkTime(fmt.Sprintf("%x-a", dummyID(2)), start) + if err := c.Trim(); err != nil { + t.Fatal(err) + } + if _, err := c.Get(id); err != nil { + t.Fatal(err) + } + c.OutputFile(entry.OutputID) + mtime3 := now + if _, err := c.Get(dummyID(2)); err == nil { // haven't done a Get for this since original write above + t.Fatalf("Trim did not remove dummyID(2)") + } + + // The c.Get(id) refreshed id's mtime again. + // Check that another 5 days later it is still not gone, + // but check by using checkTime, which doesn't bring mtime forward. + now += 5 * 86400 + if err := c.Trim(); err != nil { + t.Fatal(err) + } + checkTime(fmt.Sprintf("%x-a", id), mtime3) + checkTime(fmt.Sprintf("%x-d", entry.OutputID), mtime3) + + // Half a day later Trim should still be a no-op, because there was a Trim recently. + // Even though the entry for id is now old enough to be trimmed, + // it gets a reprieve until the time comes for a new Trim scan. + now += 86400 / 2 + if err := c.Trim(); err != nil { + t.Fatal(err) + } + checkTime(fmt.Sprintf("%x-a", id), mtime3) + checkTime(fmt.Sprintf("%x-d", entry.OutputID), mtime3) + + // Another half a day later, Trim should actually run, and it should remove id. + now += 86400/2 + 1 + if err := c.Trim(); err != nil { + t.Fatal(err) + } + if _, err := c.Get(dummyID(1)); err == nil { + t.Fatal("Trim did not remove dummyID(1)") + } +} diff --git a/go/src/cmd/go/internal/cache/default.go b/go/src/cmd/go/internal/cache/default.go new file mode 100644 index 0000000000000000000000000000000000000000..cc4e0517b4a12d09c858b66fa5caa92a32d4b0be --- /dev/null +++ b/go/src/cmd/go/internal/cache/default.go @@ -0,0 +1,105 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package cache + +import ( + "fmt" + "os" + "path/filepath" + "sync" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" +) + +// Default returns the default cache to use. +// It never returns nil. +func Default() Cache { + return initDefaultCacheOnce() +} + +var initDefaultCacheOnce = sync.OnceValue(initDefaultCache) + +// cacheREADME is a message stored in a README in the cache directory. +// Because the cache lives outside the normal Go trees, we leave the +// README as a courtesy to explain where it came from. +const cacheREADME = `This directory holds cached build artifacts from the Go build system. +Run "go clean -cache" if the directory is getting too large. +Run "go clean -fuzzcache" to delete the fuzz cache. +See go.dev to learn more about Go. +` + +// initDefaultCache does the work of finding the default cache +// the first time Default is called. +func initDefaultCache() Cache { + dir, _, err := DefaultDir() + if err != nil { + base.Fatalf("build cache is required, but could not be located: %v", err) + } + if dir == "off" { + base.Fatalf("build cache is disabled by GOCACHE=off, but required as of Go 1.12") + } + if err := os.MkdirAll(dir, 0o777); err != nil { + base.Fatalf("failed to initialize build cache at %s: %s\n", dir, err) + } + if _, err := os.Stat(filepath.Join(dir, "README")); err != nil { + // Best effort. + os.WriteFile(filepath.Join(dir, "README"), []byte(cacheREADME), 0666) + } + + diskCache, err := Open(dir) + if err != nil { + base.Fatalf("failed to initialize build cache at %s: %s\n", dir, err) + } + + if cfg.GOCACHEPROG != "" { + return startCacheProg(cfg.GOCACHEPROG, diskCache) + } + + return diskCache +} + +var ( + defaultDirOnce sync.Once + defaultDir string + defaultDirChanged bool // effective value differs from $GOCACHE + defaultDirErr error +) + +// DefaultDir returns the effective GOCACHE setting. +// It returns "off" if the cache is disabled, +// and reports whether the effective value differs from GOCACHE. +func DefaultDir() (string, bool, error) { + // Save the result of the first call to DefaultDir for later use in + // initDefaultCache. cmd/go/main.go explicitly sets GOCACHE so that + // subprocesses will inherit it, but that means initDefaultCache can't + // otherwise distinguish between an explicit "off" and a UserCacheDir error. + + defaultDirOnce.Do(func() { + // Compute default location. + dir, err := os.UserCacheDir() + if err != nil { + defaultDir = "off" + defaultDirErr = fmt.Errorf("GOCACHE is not defined and %v", err) + } else { + defaultDir = filepath.Join(dir, "go-build") + } + + newDir := cfg.Getenv("GOCACHE") + if newDir != "" { + defaultDirErr = nil + defaultDirChanged = newDir != defaultDir + defaultDir = newDir + if filepath.IsAbs(defaultDir) || defaultDir == "off" { + return + } + defaultDir = "off" + defaultDirErr = fmt.Errorf("GOCACHE is not an absolute path") + return + } + }) + + return defaultDir, defaultDirChanged, defaultDirErr +} diff --git a/go/src/cmd/go/internal/cache/hash.go b/go/src/cmd/go/internal/cache/hash.go new file mode 100644 index 0000000000000000000000000000000000000000..27d275644a4bd0cdafe3ef30104f35a3f4a15926 --- /dev/null +++ b/go/src/cmd/go/internal/cache/hash.go @@ -0,0 +1,193 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package cache + +import ( + "bytes" + "crypto/sha256" + "fmt" + "hash" + "io" + "os" + "runtime" + "strings" + "sync" +) + +var debugHash = false // set when GODEBUG=gocachehash=1 + +// HashSize is the number of bytes in a hash. +const HashSize = 32 + +// A Hash provides access to the canonical hash function used to index the cache. +// The current implementation uses salted SHA256, but clients must not assume this. +type Hash struct { + h hash.Hash + name string // for debugging + buf *bytes.Buffer // for verify +} + +// hashSalt is a salt string added to the beginning of every hash +// created by NewHash. Using the Go version makes sure that different +// versions of the go command (or even different Git commits during +// work on the development branch) do not address the same cache +// entries, so that a bug in one version does not affect the execution +// of other versions. This salt will result in additional ActionID files +// in the cache, but not additional copies of the large output files, +// which are still addressed by unsalted SHA256. +// +// We strip any GOEXPERIMENTs the go tool was built with from this +// version string on the assumption that they shouldn't affect go tool +// execution. This allows bootstrapping to converge faster: dist builds +// go_bootstrap without any experiments, so by stripping experiments +// go_bootstrap and the final go binary will use the same salt. +var hashSalt = []byte(stripExperiment(runtime.Version())) + +// stripExperiment strips any GOEXPERIMENT configuration from the Go +// version string. +func stripExperiment(version string) string { + if i := strings.Index(version, " X:"); i >= 0 { + return version[:i] + } + if i := strings.Index(version, "-X:"); i >= 0 { + return version[:i] + } + return version +} + +// Subkey returns an action ID corresponding to mixing a parent +// action ID with a string description of the subkey. +func Subkey(parent ActionID, desc string) ActionID { + h := sha256.New() + h.Write([]byte("subkey:")) + h.Write(parent[:]) + h.Write([]byte(desc)) + var out ActionID + h.Sum(out[:0]) + if debugHash { + fmt.Fprintf(os.Stderr, "HASH subkey %x %q = %x\n", parent, desc, out) + } + if verify { + hashDebug.Lock() + hashDebug.m[out] = fmt.Sprintf("subkey %x %q", parent, desc) + hashDebug.Unlock() + } + return out +} + +// NewHash returns a new Hash. +// The caller is expected to Write data to it and then call Sum. +func NewHash(name string) *Hash { + h := &Hash{h: sha256.New(), name: name} + if debugHash { + fmt.Fprintf(os.Stderr, "HASH[%s]\n", h.name) + } + h.Write(hashSalt) + if verify { + h.buf = new(bytes.Buffer) + } + return h +} + +// Write writes data to the running hash. +func (h *Hash) Write(b []byte) (int, error) { + if debugHash { + fmt.Fprintf(os.Stderr, "HASH[%s]: %q\n", h.name, b) + } + if h.buf != nil { + h.buf.Write(b) + } + return h.h.Write(b) +} + +// Sum returns the hash of the data written previously. +func (h *Hash) Sum() [HashSize]byte { + var out [HashSize]byte + h.h.Sum(out[:0]) + if debugHash { + fmt.Fprintf(os.Stderr, "HASH[%s]: %x\n", h.name, out) + } + if h.buf != nil { + hashDebug.Lock() + if hashDebug.m == nil { + hashDebug.m = make(map[[HashSize]byte]string) + } + hashDebug.m[out] = h.buf.String() + hashDebug.Unlock() + } + return out +} + +// In GODEBUG=gocacheverify=1 mode, +// hashDebug holds the input to every computed hash ID, +// so that we can work backward from the ID involved in a +// cache entry mismatch to a description of what should be there. +var hashDebug struct { + sync.Mutex + m map[[HashSize]byte]string +} + +// reverseHash returns the input used to compute the hash id. +func reverseHash(id [HashSize]byte) string { + hashDebug.Lock() + s := hashDebug.m[id] + hashDebug.Unlock() + return s +} + +var hashFileCache struct { + sync.Mutex + m map[string][HashSize]byte +} + +// FileHash returns the hash of the named file. +// It caches repeated lookups for a given file, +// and the cache entry for a file can be initialized +// using SetFileHash. +// The hash used by FileHash is not the same as +// the hash used by NewHash. +func FileHash(file string) ([HashSize]byte, error) { + hashFileCache.Lock() + out, ok := hashFileCache.m[file] + hashFileCache.Unlock() + + if ok { + return out, nil + } + + h := sha256.New() + f, err := os.Open(file) + if err != nil { + if debugHash { + fmt.Fprintf(os.Stderr, "HASH %s: %v\n", file, err) + } + return [HashSize]byte{}, err + } + _, err = io.Copy(h, f) + f.Close() + if err != nil { + if debugHash { + fmt.Fprintf(os.Stderr, "HASH %s: %v\n", file, err) + } + return [HashSize]byte{}, err + } + h.Sum(out[:0]) + if debugHash { + fmt.Fprintf(os.Stderr, "HASH %s: %x\n", file, out) + } + + SetFileHash(file, out) + return out, nil +} + +// SetFileHash sets the hash returned by FileHash for file. +func SetFileHash(file string, sum [HashSize]byte) { + hashFileCache.Lock() + if hashFileCache.m == nil { + hashFileCache.m = make(map[string][HashSize]byte) + } + hashFileCache.m[file] = sum + hashFileCache.Unlock() +} diff --git a/go/src/cmd/go/internal/cache/hash_test.go b/go/src/cmd/go/internal/cache/hash_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a0356771cac829a66df8efc27e1ee295acc44c02 --- /dev/null +++ b/go/src/cmd/go/internal/cache/hash_test.go @@ -0,0 +1,51 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package cache + +import ( + "fmt" + "os" + "testing" +) + +func TestHash(t *testing.T) { + oldSalt := hashSalt + hashSalt = nil + defer func() { + hashSalt = oldSalt + }() + + h := NewHash("alice") + h.Write([]byte("hello world")) + sum := fmt.Sprintf("%x", h.Sum()) + want := "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" + if sum != want { + t.Errorf("hash(hello world) = %v, want %v", sum, want) + } +} + +func TestHashFile(t *testing.T) { + f, err := os.CreateTemp("", "cmd-go-test-") + if err != nil { + t.Fatal(err) + } + name := f.Name() + fmt.Fprintf(f, "hello world") + defer os.Remove(name) + if err := f.Close(); err != nil { + t.Fatal(err) + } + + var h ActionID // make sure hash result is assignable to ActionID + h, err = FileHash(name) + if err != nil { + t.Fatal(err) + } + sum := fmt.Sprintf("%x", h) + want := "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" + if sum != want { + t.Errorf("hash(hello world) = %v, want %v", sum, want) + } +} diff --git a/go/src/cmd/go/internal/cache/prog.go b/go/src/cmd/go/internal/cache/prog.go new file mode 100644 index 0000000000000000000000000000000000000000..74e9dc9de534e1fbdce41f01180eeef826fb959f --- /dev/null +++ b/go/src/cmd/go/internal/cache/prog.go @@ -0,0 +1,374 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package cache + +import ( + "bufio" + "cmd/go/internal/base" + "cmd/go/internal/cacheprog" + "cmd/internal/quoted" + "context" + "crypto/sha256" + "encoding/base64" + "encoding/json" + "errors" + "fmt" + "io" + "log" + "os" + "os/exec" + "sync" + "sync/atomic" + "time" +) + +// ProgCache implements Cache via JSON messages over stdin/stdout to a child +// helper process which can then implement whatever caching policy/mechanism it +// wants. +// +// See https://github.com/golang/go/issues/59719 +type ProgCache struct { + cmd *exec.Cmd + stdout io.ReadCloser // from the child process + stdin io.WriteCloser // to the child process + bw *bufio.Writer // to stdin + jenc *json.Encoder // to bw + + // can are the commands that the child process declared that it supports. + // This is effectively the versioning mechanism. + can map[cacheprog.Cmd]bool + + // fuzzDirCache is another Cache implementation to use for the FuzzDir + // method. In practice this is the default GOCACHE disk-based + // implementation. + // + // TODO(bradfitz): maybe this isn't ideal. But we'd need to extend the Cache + // interface and the fuzzing callers to be less disk-y to do more here. + fuzzDirCache Cache + + closing atomic.Bool + ctx context.Context // valid until Close via ctxClose + ctxCancel context.CancelFunc // called on Close + readLoopDone chan struct{} // closed when readLoop returns + + mu sync.Mutex // guards following fields + nextID int64 + inFlight map[int64]chan<- *cacheprog.Response + outputFile map[OutputID]string // object => abs path on disk + + // writeMu serializes writing to the child process. + // It must never be held at the same time as mu. + writeMu sync.Mutex +} + +// startCacheProg starts the prog binary (with optional space-separated flags) +// and returns a Cache implementation that talks to it. +// +// It blocks a few seconds to wait for the child process to successfully start +// and advertise its capabilities. +func startCacheProg(progAndArgs string, fuzzDirCache Cache) Cache { + if fuzzDirCache == nil { + panic("missing fuzzDirCache") + } + args, err := quoted.Split(progAndArgs) + if err != nil { + base.Fatalf("GOCACHEPROG args: %v", err) + } + var prog string + if len(args) > 0 { + prog = args[0] + args = args[1:] + } + + ctx, ctxCancel := context.WithCancel(context.Background()) + + cmd := exec.CommandContext(ctx, prog, args...) + out, err := cmd.StdoutPipe() + if err != nil { + base.Fatalf("StdoutPipe to GOCACHEPROG: %v", err) + } + in, err := cmd.StdinPipe() + if err != nil { + base.Fatalf("StdinPipe to GOCACHEPROG: %v", err) + } + cmd.Stderr = os.Stderr + // On close, we cancel the context. Rather than killing the helper, + // close its stdin. + cmd.Cancel = in.Close + + if err := cmd.Start(); err != nil { + base.Fatalf("error starting GOCACHEPROG program %q: %v", prog, err) + } + + pc := &ProgCache{ + ctx: ctx, + ctxCancel: ctxCancel, + fuzzDirCache: fuzzDirCache, + cmd: cmd, + stdout: out, + stdin: in, + bw: bufio.NewWriter(in), + inFlight: make(map[int64]chan<- *cacheprog.Response), + outputFile: make(map[OutputID]string), + readLoopDone: make(chan struct{}), + } + + // Register our interest in the initial protocol message from the child to + // us, saying what it can do. + capResc := make(chan *cacheprog.Response, 1) + pc.inFlight[0] = capResc + + pc.jenc = json.NewEncoder(pc.bw) + go pc.readLoop(pc.readLoopDone) + + // Give the child process a few seconds to report its capabilities. This + // should be instant and not require any slow work by the program. + timer := time.NewTicker(5 * time.Second) + defer timer.Stop() + for { + select { + case <-timer.C: + log.Printf("# still waiting for GOCACHEPROG %v ...", prog) + case capRes := <-capResc: + can := map[cacheprog.Cmd]bool{} + for _, cmd := range capRes.KnownCommands { + can[cmd] = true + } + if len(can) == 0 { + base.Fatalf("GOCACHEPROG %v declared no supported commands", prog) + } + pc.can = can + return pc + } + } +} + +func (c *ProgCache) readLoop(readLoopDone chan<- struct{}) { + defer close(readLoopDone) + jd := json.NewDecoder(c.stdout) + for { + res := new(cacheprog.Response) + if err := jd.Decode(res); err != nil { + if c.closing.Load() { + c.mu.Lock() + for _, ch := range c.inFlight { + close(ch) + } + c.inFlight = nil + c.mu.Unlock() + return // quietly + } + if err == io.EOF { + c.mu.Lock() + inFlight := len(c.inFlight) + c.mu.Unlock() + base.Fatalf("GOCACHEPROG exited pre-Close with %v pending requests", inFlight) + } + base.Fatalf("error reading JSON from GOCACHEPROG: %v", err) + } + c.mu.Lock() + ch, ok := c.inFlight[res.ID] + delete(c.inFlight, res.ID) + c.mu.Unlock() + if ok { + ch <- res + } else { + base.Fatalf("GOCACHEPROG sent response for unknown request ID %v", res.ID) + } + } +} + +var errCacheprogClosed = errors.New("GOCACHEPROG program closed unexpectedly") + +func (c *ProgCache) send(ctx context.Context, req *cacheprog.Request) (*cacheprog.Response, error) { + resc := make(chan *cacheprog.Response, 1) + if err := c.writeToChild(req, resc); err != nil { + return nil, err + } + select { + case res := <-resc: + if res == nil { + return nil, errCacheprogClosed + } + if res.Err != "" { + return nil, errors.New(res.Err) + } + return res, nil + case <-ctx.Done(): + return nil, ctx.Err() + } +} + +func (c *ProgCache) writeToChild(req *cacheprog.Request, resc chan<- *cacheprog.Response) (err error) { + c.mu.Lock() + if c.inFlight == nil { + return errCacheprogClosed + } + c.nextID++ + req.ID = c.nextID + c.inFlight[req.ID] = resc + c.mu.Unlock() + + defer func() { + if err != nil { + c.mu.Lock() + if c.inFlight != nil { + delete(c.inFlight, req.ID) + } + c.mu.Unlock() + } + }() + + c.writeMu.Lock() + defer c.writeMu.Unlock() + + if err := c.jenc.Encode(req); err != nil { + return err + } + if err := c.bw.WriteByte('\n'); err != nil { + return err + } + if req.Body != nil && req.BodySize > 0 { + if err := c.bw.WriteByte('"'); err != nil { + return err + } + e := base64.NewEncoder(base64.StdEncoding, c.bw) + wrote, err := io.Copy(e, req.Body) + if err != nil { + return err + } + if err := e.Close(); err != nil { + return nil + } + if wrote != req.BodySize { + return fmt.Errorf("short write writing body to GOCACHEPROG for action %x, output %x: wrote %v; expected %v", + req.ActionID, req.OutputID, wrote, req.BodySize) + } + if _, err := c.bw.WriteString("\"\n"); err != nil { + return err + } + } + if err := c.bw.Flush(); err != nil { + return err + } + return nil +} + +func (c *ProgCache) Get(a ActionID) (Entry, error) { + if !c.can[cacheprog.CmdGet] { + // They can't do a "get". Maybe they're a write-only cache. + // + // TODO(bradfitz,bcmills): figure out the proper error type here. Maybe + // errors.ErrUnsupported? Is entryNotFoundError even appropriate? There + // might be places where we rely on the fact that a recent Put can be + // read through a corresponding Get. Audit callers and check, and document + // error types on the Cache interface. + return Entry{}, &entryNotFoundError{} + } + res, err := c.send(c.ctx, &cacheprog.Request{ + Command: cacheprog.CmdGet, + ActionID: a[:], + }) + if err != nil { + return Entry{}, err // TODO(bradfitz): or entryNotFoundError? Audit callers. + } + if res.Miss { + return Entry{}, &entryNotFoundError{} + } + e := Entry{ + Size: res.Size, + } + if res.Time != nil { + e.Time = *res.Time + } else { + e.Time = time.Now() + } + if res.DiskPath == "" { + return Entry{}, &entryNotFoundError{errors.New("GOCACHEPROG didn't populate DiskPath on get hit")} + } + if copy(e.OutputID[:], res.OutputID) != len(res.OutputID) { + return Entry{}, &entryNotFoundError{errors.New("incomplete ProgResponse OutputID")} + } + c.noteOutputFile(e.OutputID, res.DiskPath) + return e, nil +} + +func (c *ProgCache) noteOutputFile(o OutputID, diskPath string) { + c.mu.Lock() + defer c.mu.Unlock() + c.outputFile[o] = diskPath +} + +func (c *ProgCache) OutputFile(o OutputID) string { + c.mu.Lock() + defer c.mu.Unlock() + return c.outputFile[o] +} + +func (c *ProgCache) Put(a ActionID, file io.ReadSeeker) (_ OutputID, size int64, _ error) { + // Compute output ID. + h := sha256.New() + if _, err := file.Seek(0, 0); err != nil { + return OutputID{}, 0, err + } + size, err := io.Copy(h, file) + if err != nil { + return OutputID{}, 0, err + } + var out OutputID + h.Sum(out[:0]) + + if _, err := file.Seek(0, 0); err != nil { + return OutputID{}, 0, err + } + + if !c.can[cacheprog.CmdPut] { + // Child is a read-only cache. Do nothing. + return out, size, nil + } + + res, err := c.send(c.ctx, &cacheprog.Request{ + Command: cacheprog.CmdPut, + ActionID: a[:], + OutputID: out[:], + Body: file, + BodySize: size, + }) + if err != nil { + return OutputID{}, 0, err + } + if res.DiskPath == "" { + return OutputID{}, 0, errors.New("GOCACHEPROG didn't return DiskPath in put response") + } + c.noteOutputFile(out, res.DiskPath) + return out, size, err +} + +func (c *ProgCache) Close() error { + c.closing.Store(true) + var err error + + // First write a "close" message to the child so it can exit nicely + // and clean up if it wants. Only after that exchange do we cancel + // the context that kills the process. + if c.can[cacheprog.CmdClose] { + _, err = c.send(c.ctx, &cacheprog.Request{Command: cacheprog.CmdClose}) + if errors.Is(err, errCacheprogClosed) { + // Allow the child to quit without responding to close. + err = nil + } + } + // Cancel the context, which will close the helper's stdin. + c.ctxCancel() + // Wait until the helper closes its stdout. + <-c.readLoopDone + return err +} + +func (c *ProgCache) FuzzDir() string { + // TODO(bradfitz): figure out what to do here. For now just use the + // disk-based default. + return c.fuzzDirCache.FuzzDir() +} diff --git a/go/src/cmd/go/internal/cacheprog/cacheprog.go b/go/src/cmd/go/internal/cacheprog/cacheprog.go new file mode 100644 index 0000000000000000000000000000000000000000..9379636e5ab6628025d187f7ce877a07dfd95ffb --- /dev/null +++ b/go/src/cmd/go/internal/cacheprog/cacheprog.go @@ -0,0 +1,126 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package cacheprog defines the protocol for a GOCACHEPROG program. +// +// By default, the go command manages a build cache stored in the file system +// itself. GOCACHEPROG can be set to the name of a command (with optional +// space-separated flags) that implements the go command build cache externally. +// This permits defining a different cache policy. +// +// The go command will start the GOCACHEPROG as a subprocess and communicate +// with it via JSON messages over stdin/stdout. The subprocess's stderr will be +// connected to the go command's stderr. +// +// The subprocess should immediately send a [Response] with its capabilities. +// After that, the go command will send a stream of [Request] messages and the +// subprocess should reply to each [Request] with a [Response] message. +package cacheprog + +import ( + "io" + "time" +) + +// Cmd is a command that can be issued to a child process. +// +// If the interface needs to grow, the go command can add new commands or new +// versioned commands like "get2" in the future. The initial [Response] from +// the child process indicates which commands it supports. +type Cmd string + +const ( + // CmdPut tells the cache program to store an object in the cache. + // + // [Request.ActionID] is the cache key of this object. The cache should + // store [Request.OutputID] and [Request.Body] under this key for a + // later "get" request. It must also store the Body in a file in the local + // file system and return the path to that file in [Response.DiskPath], + // which must exist at least until a "close" request. + CmdPut = Cmd("put") + + // CmdGet tells the cache program to retrieve an object from the cache. + // + // [Request.ActionID] specifies the key of the object to get. If the + // cache does not contain this object, it should set [Response.Miss] to + // true. Otherwise, it should populate the fields of [Response], + // including setting [Response.OutputID] to the OutputID of the original + // "put" request and [Response.DiskPath] to the path of a local file + // containing the Body of the original "put" request. That file must + // continue to exist at least until a "close" request. + CmdGet = Cmd("get") + + // CmdClose requests that the cache program exit gracefully. + // + // The cache program should reply to this request and then exit + // (thus closing its stdout). + CmdClose = Cmd("close") +) + +// Request is the JSON-encoded message that's sent from the go command to +// the GOCACHEPROG child process over stdin. Each JSON object is on its own +// line. A ProgRequest of Type "put" with BodySize > 0 will be followed by a +// line containing a base64-encoded JSON string literal of the body. +type Request struct { + // ID is a unique number per process across all requests. + // It must be echoed in the Response from the child. + ID int64 + + // Command is the type of request. + // The go command will only send commands that were declared + // as supported by the child. + Command Cmd + + // ActionID is the cache key for "put" and "get" requests. + ActionID []byte `json:",omitempty"` // or nil if not used + + // OutputID is stored with the body for "put" requests. + OutputID []byte `json:",omitempty"` // or nil if not used + + // Body is the body for "put" requests. It's sent after the JSON object + // as a base64-encoded JSON string when BodySize is non-zero. + // It's sent as a separate JSON value instead of being a struct field + // send in this JSON object so large values can be streamed in both directions. + // The base64 string body of a Request will always be written + // immediately after the JSON object and a newline. + Body io.Reader `json:"-"` + + // BodySize is the number of bytes of Body. If zero, the body isn't written. + BodySize int64 `json:",omitempty"` +} + +// Response is the JSON response from the child process to the go command. +// +// With the exception of the first protocol message that the child writes to its +// stdout with ID==0 and KnownCommands populated, these are only sent in +// response to a Request from the go command. +// +// Responses can be sent in any order. The ID must match the request they're +// replying to. +type Response struct { + ID int64 // that corresponds to Request; they can be answered out of order + Err string `json:",omitempty"` // if non-empty, the error + + // KnownCommands is included in the first message that cache helper program + // writes to stdout on startup (with ID==0). It includes the + // Request.Command types that are supported by the program. + // + // This lets the go command extend the protocol gracefully over time (adding + // "get2", etc), or fail gracefully when needed. It also lets the go command + // verify the program wants to be a cache helper. + KnownCommands []Cmd `json:",omitempty"` + + // For "get" requests. + + Miss bool `json:",omitempty"` // cache miss + OutputID []byte `json:",omitempty"` // the OutputID stored with the body + Size int64 `json:",omitempty"` // body size in bytes + Time *time.Time `json:",omitempty"` // when the object was put in the cache (optional; used for cache expiration) + + // For "get" and "put" requests. + + // DiskPath is the absolute path on disk of the body corresponding to a + // "get" (on cache hit) or "put" request's ActionID. + DiskPath string `json:",omitempty"` +} diff --git a/go/src/cmd/go/internal/cfg/bench_test.go b/go/src/cmd/go/internal/cfg/bench_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1ed663125a64417e1d5ac9f7c6f626774200bde0 --- /dev/null +++ b/go/src/cmd/go/internal/cfg/bench_test.go @@ -0,0 +1,22 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package cfg + +import ( + "cmd/internal/pathcache" + "internal/testenv" + "testing" +) + +func BenchmarkLookPath(b *testing.B) { + testenv.MustHaveExecPath(b, "go") + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := pathcache.LookPath("go") + if err != nil { + b.Fatal(err) + } + } +} diff --git a/go/src/cmd/go/internal/cfg/cfg.go b/go/src/cmd/go/internal/cfg/cfg.go new file mode 100644 index 0000000000000000000000000000000000000000..a4edd854f1d35a787b4768c00ed3688a42948d5e --- /dev/null +++ b/go/src/cmd/go/internal/cfg/cfg.go @@ -0,0 +1,705 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package cfg holds configuration shared by multiple parts +// of the go command. +package cfg + +import ( + "bytes" + "context" + "fmt" + "go/build" + "internal/buildcfg" + "internal/cfg" + "internal/platform" + "io" + "io/fs" + "os" + "path/filepath" + "runtime" + "strings" + "sync" + "time" + + "cmd/go/internal/fsys" + "cmd/internal/pathcache" +) + +// Global build parameters (used during package load) +var ( + Goos = envOr("GOOS", build.Default.GOOS) + Goarch = envOr("GOARCH", build.Default.GOARCH) + + ExeSuffix = exeSuffix() + + // ModulesEnabled specifies whether the go command is running + // in module-aware mode (as opposed to GOPATH mode). + // It is equal to modload.Enabled, but not all packages can import modload. + ModulesEnabled bool +) + +func exeSuffix() string { + if Goos == "windows" { + return ".exe" + } + return "" +} + +// Configuration for tools installed to GOROOT/bin. +// Normally these match runtime.GOOS and runtime.GOARCH, +// but when testing a cross-compiled cmd/go they will +// indicate the GOOS and GOARCH of the installed cmd/go +// rather than the test binary. +var ( + installedGOOS string + installedGOARCH string +) + +// ToolExeSuffix returns the suffix for executables installed +// in build.ToolDir. +func ToolExeSuffix() string { + if installedGOOS == "windows" { + return ".exe" + } + return "" +} + +// These are general "build flags" used by build and other commands. +var ( + BuildA bool // -a flag + BuildBuildmode string // -buildmode flag + BuildBuildvcs = "auto" // -buildvcs flag: "true", "false", or "auto" + BuildContext = defaultContext() + BuildMod string // -mod flag + BuildModExplicit bool // whether -mod was set explicitly + BuildModReason string // reason -mod was set, if set by default + BuildLinkshared bool // -linkshared flag + BuildMSan bool // -msan flag + BuildASan bool // -asan flag + BuildCover bool // -cover flag + BuildCoverMode string // -covermode flag + BuildCoverPkg []string // -coverpkg flag + BuildJSON bool // -json flag + BuildN bool // -n flag + BuildO string // -o flag + BuildP = runtime.GOMAXPROCS(0) // -p flag + BuildPGO string // -pgo flag + BuildPkgdir string // -pkgdir flag + BuildRace bool // -race flag + BuildToolexec []string // -toolexec flag + BuildToolchainName string + BuildToolchainCompiler func() string + BuildToolchainLinker func() string + BuildTrimpath bool // -trimpath flag + BuildV bool // -v flag + BuildWork bool // -work flag + BuildX bool // -x flag + + ModCacheRW bool // -modcacherw flag + ModFile string // -modfile flag + + CmdName string // "build", "install", "list", "mod tidy", etc. + + DebugActiongraph string // -debug-actiongraph flag (undocumented, unstable) + DebugTrace string // -debug-trace flag + DebugRuntimeTrace string // -debug-runtime-trace flag (undocumented, unstable) + + // GoPathError is set when GOPATH is not set. it contains an + // explanation why GOPATH is unset. + GoPathError string + GOPATHChanged bool + CGOChanged bool +) + +func defaultContext() build.Context { + ctxt := build.Default + + ctxt.JoinPath = filepath.Join // back door to say "do not use go command" + + // Override defaults computed in go/build with defaults + // from go environment configuration file, if known. + ctxt.GOPATH, GOPATHChanged = EnvOrAndChanged("GOPATH", gopath(ctxt)) + ctxt.GOOS = Goos + ctxt.GOARCH = Goarch + + // Clear the GOEXPERIMENT-based tool tags, which we will recompute later. + var save []string + for _, tag := range ctxt.ToolTags { + if !strings.HasPrefix(tag, "goexperiment.") { + save = append(save, tag) + } + } + ctxt.ToolTags = save + + // The go/build rule for whether cgo is enabled is: + // 1. If $CGO_ENABLED is set, respect it. + // 2. Otherwise, if this is a cross-compile, disable cgo. + // 3. Otherwise, use built-in default for GOOS/GOARCH. + // + // Recreate that logic here with the new GOOS/GOARCH setting. + // We need to run steps 2 and 3 to determine what the default value + // of CgoEnabled would be for computing CGOChanged. + defaultCgoEnabled := false + if buildcfg.DefaultCGO_ENABLED == "1" { + defaultCgoEnabled = true + } else if buildcfg.DefaultCGO_ENABLED == "0" { + } else if runtime.GOARCH == ctxt.GOARCH && runtime.GOOS == ctxt.GOOS { + defaultCgoEnabled = platform.CgoSupported(ctxt.GOOS, ctxt.GOARCH) + // Use built-in default cgo setting for GOOS/GOARCH. + // Note that ctxt.GOOS/GOARCH are derived from the preference list + // (1) environment, (2) go/env file, (3) runtime constants, + // while go/build.Default.GOOS/GOARCH are derived from the preference list + // (1) environment, (2) runtime constants. + // + // We know ctxt.GOOS/GOARCH == runtime.GOOS/GOARCH; + // no matter how that happened, go/build.Default will make the + // same decision (either the environment variables are set explicitly + // to match the runtime constants, or else they are unset, in which + // case go/build falls back to the runtime constants), so + // go/build.Default.GOOS/GOARCH == runtime.GOOS/GOARCH. + // So ctxt.CgoEnabled (== go/build.Default.CgoEnabled) is correct + // as is and can be left unmodified. + // + // All that said, starting in Go 1.20 we layer one more rule + // on top of the go/build decision: if CC is unset and + // the default C compiler we'd look for is not in the PATH, + // we automatically default cgo to off. + // This makes go builds work automatically on systems + // without a C compiler installed. + if ctxt.CgoEnabled { + if os.Getenv("CC") == "" { + cc := DefaultCC(ctxt.GOOS, ctxt.GOARCH) + if _, err := pathcache.LookPath(cc); err != nil { + defaultCgoEnabled = false + } + } + } + } + ctxt.CgoEnabled = defaultCgoEnabled + if v := Getenv("CGO_ENABLED"); v == "0" || v == "1" { + ctxt.CgoEnabled = v[0] == '1' + } + CGOChanged = ctxt.CgoEnabled != defaultCgoEnabled + + ctxt.OpenFile = func(path string) (io.ReadCloser, error) { + return fsys.Open(path) + } + ctxt.ReadDir = func(path string) ([]fs.FileInfo, error) { + // Convert []fs.DirEntry to []fs.FileInfo using dirInfo. + dirs, err := fsys.ReadDir(path) + infos := make([]fs.FileInfo, len(dirs)) + for i, dir := range dirs { + infos[i] = &dirInfo{dir} + } + return infos, err + } + ctxt.IsDir = func(path string) bool { + isDir, err := fsys.IsDir(path) + return err == nil && isDir + } + + return ctxt +} + +func init() { + SetGOROOT(Getenv("GOROOT"), false) +} + +// ForceHost forces GOOS and GOARCH to runtime.GOOS and runtime.GOARCH. +// This is used by go tool to build tools for the go command's own +// GOOS and GOARCH. +func ForceHost() { + Goos = runtime.GOOS + Goarch = runtime.GOARCH + ExeSuffix = exeSuffix() + GO386 = buildcfg.DefaultGO386 + GOAMD64 = buildcfg.DefaultGOAMD64 + GOARM = buildcfg.DefaultGOARM + GOARM64 = buildcfg.DefaultGOARM64 + GOMIPS = buildcfg.DefaultGOMIPS + GOMIPS64 = buildcfg.DefaultGOMIPS64 + GOPPC64 = buildcfg.DefaultGOPPC64 + GORISCV64 = buildcfg.DefaultGORISCV64 + GOWASM = "" + + // Recompute the build context using Goos and Goarch to + // set the correct value for ctx.CgoEnabled. + BuildContext = defaultContext() + // Call SetGOROOT to properly set the GOROOT on the new context. + SetGOROOT(Getenv("GOROOT"), false) + // Recompute experiments: the settings determined depend on GOOS and GOARCH. + // This will also update the BuildContext's tool tags to include the new + // experiment tags. + computeExperiment() +} + +// SetGOROOT sets GOROOT and associated variables to the given values. +// +// If isTestGo is true, build.ToolDir is set based on the TESTGO_GOHOSTOS and +// TESTGO_GOHOSTARCH environment variables instead of runtime.GOOS and +// runtime.GOARCH. +func SetGOROOT(goroot string, isTestGo bool) { + BuildContext.GOROOT = goroot + + GOROOT = goroot + if goroot == "" { + GOROOTbin = "" + GOROOTpkg = "" + GOROOTsrc = "" + } else { + GOROOTbin = filepath.Join(goroot, "bin") + GOROOTpkg = filepath.Join(goroot, "pkg") + GOROOTsrc = filepath.Join(goroot, "src") + } + + installedGOOS = runtime.GOOS + installedGOARCH = runtime.GOARCH + if isTestGo { + if testOS := os.Getenv("TESTGO_GOHOSTOS"); testOS != "" { + installedGOOS = testOS + } + if testArch := os.Getenv("TESTGO_GOHOSTARCH"); testArch != "" { + installedGOARCH = testArch + } + } + + if runtime.Compiler != "gccgo" { + if goroot == "" { + build.ToolDir = "" + } else { + // Note that we must use the installed OS and arch here: the tool + // directory does not move based on environment variables, and even if we + // are testing a cross-compiled cmd/go all of the installed packages and + // tools would have been built using the native compiler and linker (and + // would spuriously appear stale if we used a cross-compiled compiler and + // linker). + // + // This matches the initialization of ToolDir in go/build, except for + // using ctxt.GOROOT and the installed GOOS and GOARCH rather than the + // GOROOT, GOOS, and GOARCH reported by the runtime package. + build.ToolDir = filepath.Join(GOROOTpkg, "tool", installedGOOS+"_"+installedGOARCH) + } + } +} + +// Experiment configuration. +var ( + // RawGOEXPERIMENT is the GOEXPERIMENT value set by the user. + RawGOEXPERIMENT = envOr("GOEXPERIMENT", buildcfg.DefaultGOEXPERIMENT) + // CleanGOEXPERIMENT is the minimal GOEXPERIMENT value needed to reproduce the + // experiments enabled by RawGOEXPERIMENT. + CleanGOEXPERIMENT = RawGOEXPERIMENT + + Experiment *buildcfg.ExperimentFlags + ExperimentErr error +) + +func init() { + computeExperiment() +} + +func computeExperiment() { + Experiment, ExperimentErr = buildcfg.ParseGOEXPERIMENT(Goos, Goarch, RawGOEXPERIMENT) + if ExperimentErr != nil { + return + } + + // GOEXPERIMENT is valid, so convert it to canonical form. + CleanGOEXPERIMENT = Experiment.String() + + // Add build tags based on the experiments in effect. + exps := Experiment.Enabled() + expTags := make([]string, 0, len(exps)+len(BuildContext.ToolTags)) + for _, exp := range exps { + expTags = append(expTags, "goexperiment."+exp) + } + BuildContext.ToolTags = append(expTags, BuildContext.ToolTags...) +} + +// An EnvVar is an environment variable Name=Value. +type EnvVar struct { + Name string + Value string + Changed bool // effective Value differs from default +} + +// OrigEnv is the original environment of the program at startup. +var OrigEnv []string + +// CmdEnv is the new environment for running go tool commands. +// User binaries (during go test or go run) are run with OrigEnv, +// not CmdEnv. +var CmdEnv []EnvVar + +var envCache struct { + once sync.Once + m map[string]string + goroot map[string]string +} + +// EnvFile returns the name of the Go environment configuration file, +// and reports whether the effective value differs from the default. +func EnvFile() (string, bool, error) { + if file := os.Getenv("GOENV"); file != "" { + if file == "off" { + return "", false, fmt.Errorf("GOENV=off") + } + return file, true, nil + } + dir, err := os.UserConfigDir() + if err != nil { + return "", false, err + } + if dir == "" { + return "", false, fmt.Errorf("missing user-config dir") + } + return filepath.Join(dir, "go/env"), false, nil +} + +func initEnvCache() { + envCache.m = make(map[string]string) + envCache.goroot = make(map[string]string) + if file, _, _ := EnvFile(); file != "" { + readEnvFile(file, "user") + } + goroot := findGOROOT(envCache.m["GOROOT"]) + if goroot != "" { + readEnvFile(filepath.Join(goroot, "go.env"), "GOROOT") + } + + // Save the goroot for func init calling SetGOROOT, + // and also overwrite anything that might have been in go.env. + // It makes no sense for GOROOT/go.env to specify + // a different GOROOT. + envCache.m["GOROOT"] = goroot +} + +func readEnvFile(file string, source string) { + if file == "" { + return + } + data, err := os.ReadFile(file) + if err != nil { + return + } + + for len(data) > 0 { + // Get next line. + line := data + i := bytes.IndexByte(data, '\n') + if i >= 0 { + line, data = line[:i], data[i+1:] + } else { + data = nil + } + + i = bytes.IndexByte(line, '=') + if i < 0 || line[0] < 'A' || 'Z' < line[0] { + // Line is missing = (or empty) or a comment or not a valid env name. Ignore. + // This should not happen in the user file, since the file should be maintained almost + // exclusively by "go env -w", but better to silently ignore than to make + // the go command unusable just because somehow the env file has + // gotten corrupted. + // In the GOROOT/go.env file, we expect comments. + continue + } + key, val := line[:i], line[i+1:] + + if source == "GOROOT" { + envCache.goroot[string(key)] = string(val) + // In the GOROOT/go.env file, do not overwrite fields loaded from the user's go/env file. + if _, ok := envCache.m[string(key)]; ok { + continue + } + } + envCache.m[string(key)] = string(val) + } +} + +// Getenv gets the value for the configuration key. +// It consults the operating system environment +// and then the go/env file. +// If Getenv is called for a key that cannot be set +// in the go/env file (for example GODEBUG), it panics. +// This ensures that CanGetenv is accurate, so that +// 'go env -w' stays in sync with what Getenv can retrieve. +func Getenv(key string) string { + if !CanGetenv(key) { + switch key { + case "CGO_TEST_ALLOW", "CGO_TEST_DISALLOW", "CGO_test_ALLOW", "CGO_test_DISALLOW": + // used by internal/work/security_test.go; allow + default: + panic("internal error: invalid Getenv " + key) + } + } + val := os.Getenv(key) + if val != "" { + return val + } + envCache.once.Do(initEnvCache) + return envCache.m[key] +} + +// CanGetenv reports whether key is a valid go/env configuration key. +func CanGetenv(key string) bool { + envCache.once.Do(initEnvCache) + if _, ok := envCache.m[key]; ok { + // Assume anything in the user file or go.env file is valid. + return true + } + return strings.Contains(cfg.KnownEnv, "\t"+key+"\n") +} + +var ( + GOROOT string + + // Either empty or produced by filepath.Join(GOROOT, …). + GOROOTbin string + GOROOTpkg string + GOROOTsrc string + + GOBIN = Getenv("GOBIN") + GOCACHEPROG, GOCACHEPROGChanged = EnvOrAndChanged("GOCACHEPROG", "") + GOMODCACHE, GOMODCACHEChanged = EnvOrAndChanged("GOMODCACHE", gopathDir("pkg/mod")) + + // Used in envcmd.MkEnv and build ID computations. + GOARM64, goARM64Changed = EnvOrAndChanged("GOARM64", buildcfg.DefaultGOARM64) + GOARM, goARMChanged = EnvOrAndChanged("GOARM", buildcfg.DefaultGOARM) + GO386, go386Changed = EnvOrAndChanged("GO386", buildcfg.DefaultGO386) + GOAMD64, goAMD64Changed = EnvOrAndChanged("GOAMD64", buildcfg.DefaultGOAMD64) + GOMIPS, goMIPSChanged = EnvOrAndChanged("GOMIPS", buildcfg.DefaultGOMIPS) + GOMIPS64, goMIPS64Changed = EnvOrAndChanged("GOMIPS64", buildcfg.DefaultGOMIPS64) + GOPPC64, goPPC64Changed = EnvOrAndChanged("GOPPC64", buildcfg.DefaultGOPPC64) + GORISCV64, goRISCV64Changed = EnvOrAndChanged("GORISCV64", buildcfg.DefaultGORISCV64) + GOWASM, goWASMChanged = EnvOrAndChanged("GOWASM", fmt.Sprint(buildcfg.GOWASM)) + + GOFIPS140, GOFIPS140Changed = EnvOrAndChanged("GOFIPS140", buildcfg.DefaultGOFIPS140) + GOPROXY, GOPROXYChanged = EnvOrAndChanged("GOPROXY", "") + GOSUMDB, GOSUMDBChanged = EnvOrAndChanged("GOSUMDB", "") + GOPRIVATE = Getenv("GOPRIVATE") + GONOPROXY, GONOPROXYChanged = EnvOrAndChanged("GONOPROXY", GOPRIVATE) + GONOSUMDB, GONOSUMDBChanged = EnvOrAndChanged("GONOSUMDB", GOPRIVATE) + GOINSECURE = Getenv("GOINSECURE") + GOVCS = Getenv("GOVCS") + GOAUTH, GOAUTHChanged = EnvOrAndChanged("GOAUTH", "netrc") +) + +// EnvOrAndChanged returns the environment variable value +// and reports whether it differs from the default value. +func EnvOrAndChanged(name, def string) (v string, changed bool) { + val := Getenv(name) + if val != "" { + v = val + if g, ok := envCache.goroot[name]; ok { + changed = val != g + } else { + changed = val != def + } + return v, changed + } + return def, false +} + +var SumdbDir = gopathDir("pkg/sumdb") + +// GetArchEnv returns the name and setting of the +// GOARCH-specific architecture environment variable. +// If the current architecture has no GOARCH-specific variable, +// GetArchEnv returns empty key and value. +func GetArchEnv() (key, val string, changed bool) { + switch Goarch { + case "arm": + return "GOARM", GOARM, goARMChanged + case "arm64": + return "GOARM64", GOARM64, goARM64Changed + case "386": + return "GO386", GO386, go386Changed + case "amd64": + return "GOAMD64", GOAMD64, goAMD64Changed + case "mips", "mipsle": + return "GOMIPS", GOMIPS, goMIPSChanged + case "mips64", "mips64le": + return "GOMIPS64", GOMIPS64, goMIPS64Changed + case "ppc64", "ppc64le": + return "GOPPC64", GOPPC64, goPPC64Changed + case "riscv64": + return "GORISCV64", GORISCV64, goRISCV64Changed + case "wasm": + return "GOWASM", GOWASM, goWASMChanged + } + return "", "", false +} + +// envOr returns Getenv(key) if set, or else def. +func envOr(key, def string) string { + val := Getenv(key) + if val == "" { + val = def + } + return val +} + +// There is a copy of findGOROOT, isSameDir, and isGOROOT in +// x/tools/cmd/godoc/goroot.go. +// Try to keep them in sync for now. + +// findGOROOT returns the GOROOT value, using either an explicitly +// provided environment variable, a GOROOT that contains the current +// os.Executable value, or else the GOROOT that the binary was built +// with from runtime.GOROOT(). +// +// There is a copy of this code in x/tools/cmd/godoc/goroot.go. +func findGOROOT(env string) string { + if env == "" { + // Not using Getenv because findGOROOT is called + // to find the GOROOT/go.env file. initEnvCache + // has passed in the setting from the user go/env file. + env = os.Getenv("GOROOT") + } + if env != "" { + return filepath.Clean(env) + } + def := "" + if r := runtime.GOROOT(); r != "" { + def = filepath.Clean(r) + } + if runtime.Compiler == "gccgo" { + // gccgo has no real GOROOT, and it certainly doesn't + // depend on the executable's location. + return def + } + + // canonical returns a directory path that represents + // the same directory as dir, + // preferring the spelling in def if the two are the same. + canonical := func(dir string) string { + if isSameDir(def, dir) { + return def + } + return dir + } + + exe, err := os.Executable() + if err == nil { + exe, err = filepath.Abs(exe) + if err == nil { + // cmd/go may be installed in GOROOT/bin or GOROOT/bin/GOOS_GOARCH, + // depending on whether it was cross-compiled with a different + // GOHOSTOS (see https://go.dev/issue/62119). Try both. + if dir := filepath.Join(exe, "../.."); isGOROOT(dir) { + return canonical(dir) + } + if dir := filepath.Join(exe, "../../.."); isGOROOT(dir) { + return canonical(dir) + } + + // Depending on what was passed on the command line, it is possible + // that os.Executable is a symlink (like /usr/local/bin/go) referring + // to a binary installed in a real GOROOT elsewhere + // (like /usr/lib/go/bin/go). + // Try to find that GOROOT by resolving the symlinks. + exe, err = filepath.EvalSymlinks(exe) + if err == nil { + if dir := filepath.Join(exe, "../.."); isGOROOT(dir) { + return canonical(dir) + } + if dir := filepath.Join(exe, "../../.."); isGOROOT(dir) { + return canonical(dir) + } + } + } + } + return def +} + +// isSameDir reports whether dir1 and dir2 are the same directory. +func isSameDir(dir1, dir2 string) bool { + if dir1 == dir2 { + return true + } + info1, err1 := os.Stat(dir1) + info2, err2 := os.Stat(dir2) + return err1 == nil && err2 == nil && os.SameFile(info1, info2) +} + +// isGOROOT reports whether path looks like a GOROOT. +// +// It does this by looking for the path/pkg/tool directory, +// which is necessary for useful operation of the cmd/go tool, +// and is not typically present in a GOPATH. +// +// There is a copy of this code in x/tools/cmd/godoc/goroot.go. +func isGOROOT(path string) bool { + stat, err := os.Stat(filepath.Join(path, "pkg", "tool")) + if err != nil { + return false + } + return stat.IsDir() +} + +func gopathDir(rel string) string { + list := filepath.SplitList(BuildContext.GOPATH) + if len(list) == 0 || list[0] == "" { + return "" + } + return filepath.Join(list[0], rel) +} + +// Keep consistent with go/build.defaultGOPATH. +func gopath(ctxt build.Context) string { + if len(ctxt.GOPATH) > 0 { + return ctxt.GOPATH + } + env := "HOME" + if runtime.GOOS == "windows" { + env = "USERPROFILE" + } else if runtime.GOOS == "plan9" { + env = "home" + } + if home := os.Getenv(env); home != "" { + def := filepath.Join(home, "go") + if filepath.Clean(def) == filepath.Clean(runtime.GOROOT()) { + GoPathError = "cannot set GOROOT as GOPATH" + } + return "" + } + GoPathError = fmt.Sprintf("%s is not set", env) + return "" +} + +// WithBuildXWriter returns a Context in which BuildX output is written +// to given io.Writer. +func WithBuildXWriter(ctx context.Context, xLog io.Writer) context.Context { + return context.WithValue(ctx, buildXContextKey{}, xLog) +} + +type buildXContextKey struct{} + +// BuildXWriter returns nil if BuildX is false, or +// the writer to which BuildX output should be written otherwise. +func BuildXWriter(ctx context.Context) (io.Writer, bool) { + if !BuildX { + return nil, false + } + if v := ctx.Value(buildXContextKey{}); v != nil { + return v.(io.Writer), true + } + return os.Stderr, true +} + +// A dirInfo implements fs.FileInfo from fs.DirEntry. +// We know that go/build doesn't use the non-DirEntry parts, +// so we can panic instead of doing difficult work. +type dirInfo struct { + dir fs.DirEntry +} + +func (d *dirInfo) Name() string { return d.dir.Name() } +func (d *dirInfo) IsDir() bool { return d.dir.IsDir() } +func (d *dirInfo) Mode() fs.FileMode { return d.dir.Type() } + +func (d *dirInfo) Size() int64 { panic("dirInfo.Size") } +func (d *dirInfo) ModTime() time.Time { panic("dirInfo.ModTime") } +func (d *dirInfo) Sys() any { panic("dirInfo.Sys") } diff --git a/go/src/cmd/go/internal/cfg/zdefaultcc.go b/go/src/cmd/go/internal/cfg/zdefaultcc.go new file mode 100644 index 0000000000000000000000000000000000000000..c03a1b0d2a45784d9b9a91f066fdada35ed09f1b --- /dev/null +++ b/go/src/cmd/go/internal/cfg/zdefaultcc.go @@ -0,0 +1,23 @@ +// Code generated by go tool dist; DO NOT EDIT. + +package cfg + +const DefaultPkgConfig = `pkg-config` +func DefaultCC(goos, goarch string) string { + switch goos+`/`+goarch { + } + switch goos { + case "darwin", "ios", "freebsd", "openbsd": + return "clang" + } + return "gcc" +} +func DefaultCXX(goos, goarch string) string { + switch goos+`/`+goarch { + } + switch goos { + case "darwin", "ios", "freebsd", "openbsd": + return "clang++" + } + return "g++" +} diff --git a/go/src/cmd/go/internal/clean/clean.go b/go/src/cmd/go/internal/clean/clean.go new file mode 100644 index 0000000000000000000000000000000000000000..51581c27e161484a80e6fab38cc2debfd5644835 --- /dev/null +++ b/go/src/cmd/go/internal/clean/clean.go @@ -0,0 +1,443 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package clean implements the “go clean” command. +package clean + +import ( + "context" + "errors" + "fmt" + "io" + "io/fs" + "os" + "path/filepath" + "runtime" + "strconv" + "strings" + "time" + + "cmd/go/internal/base" + "cmd/go/internal/cache" + "cmd/go/internal/cfg" + "cmd/go/internal/load" + "cmd/go/internal/lockedfile" + "cmd/go/internal/modfetch" + "cmd/go/internal/modload" + "cmd/go/internal/str" + "cmd/go/internal/work" +) + +var CmdClean = &base.Command{ + UsageLine: "go clean [-i] [-r] [-cache] [-testcache] [-modcache] [-fuzzcache] [build flags] [packages]", + Short: "remove object files and cached files", + Long: ` +Clean removes object files from package source directories. +The go command builds most objects in a temporary directory, +so go clean is mainly concerned with object files left by other +tools or by manual invocations of go build. + +If a package argument is given or the -i or -r flag is set, +clean removes the following files from each of the +source directories corresponding to the import paths: + + _obj/ old object directory, left from Makefiles + _test/ old test directory, left from Makefiles + _testmain.go old gotest file, left from Makefiles + test.out old test log, left from Makefiles + build.out old test log, left from Makefiles + *.[568ao] object files, left from Makefiles + + DIR(.exe) from go build + DIR.test(.exe) from go test -c + MAINFILE(.exe) from go build MAINFILE.go + *.so from SWIG + +In the list, DIR represents the final path element of the +directory, and MAINFILE is the base name of any Go source +file in the directory that is not included when building +the package. + +The -i flag causes clean to remove the corresponding installed +archive or binary (what 'go install' would create). + +The -n flag causes clean to print the remove commands it would execute, +but not run them. + +The -r flag causes clean to be applied recursively to all the +dependencies of the packages named by the import paths. + +The -x flag causes clean to print remove commands as it executes them. + +The -cache flag causes clean to remove the entire go build cache. + +The -testcache flag causes clean to expire all test results in the +go build cache. + +The -modcache flag causes clean to remove the entire module +download cache, including unpacked source code of versioned +dependencies. + +The -fuzzcache flag causes clean to remove files stored in the Go build +cache for fuzz testing. The fuzzing engine caches files that expand +code coverage, so removing them may make fuzzing less effective until +new inputs are found that provide the same coverage. These files are +distinct from those stored in testdata directory; clean does not remove +those files. + +For more about build flags, see 'go help build'. + +For more about specifying packages, see 'go help packages'. + `, +} + +var ( + cleanI bool // clean -i flag + cleanR bool // clean -r flag + cleanCache bool // clean -cache flag + cleanFuzzcache bool // clean -fuzzcache flag + cleanModcache bool // clean -modcache flag + cleanTestcache bool // clean -testcache flag +) + +func init() { + // break init cycle + CmdClean.Run = runClean + + CmdClean.Flag.BoolVar(&cleanI, "i", false, "") + CmdClean.Flag.BoolVar(&cleanR, "r", false, "") + CmdClean.Flag.BoolVar(&cleanCache, "cache", false, "") + CmdClean.Flag.BoolVar(&cleanFuzzcache, "fuzzcache", false, "") + CmdClean.Flag.BoolVar(&cleanModcache, "modcache", false, "") + CmdClean.Flag.BoolVar(&cleanTestcache, "testcache", false, "") + + // -n and -x are important enough to be + // mentioned explicitly in the docs but they + // are part of the build flags. + + work.AddBuildFlags(CmdClean, work.OmitBuildOnlyFlags) +} + +func runClean(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + moduleLoaderState.InitWorkfile() + if len(args) > 0 { + cacheFlag := "" + switch { + case cleanCache: + cacheFlag = "-cache" + case cleanTestcache: + cacheFlag = "-testcache" + case cleanFuzzcache: + cacheFlag = "-fuzzcache" + case cleanModcache: + cacheFlag = "-modcache" + } + if cacheFlag != "" { + base.Fatalf("go: clean %s cannot be used with package arguments", cacheFlag) + } + } + + // golang.org/issue/29925: only load packages before cleaning if + // either the flags and arguments explicitly imply a package, + // or no other target (such as a cache) was requested to be cleaned. + cleanPkg := len(args) > 0 || cleanI || cleanR + if (!moduleLoaderState.Enabled() || moduleLoaderState.HasModRoot()) && + !cleanCache && !cleanModcache && !cleanTestcache && !cleanFuzzcache { + cleanPkg = true + } + + if cleanPkg { + for _, pkg := range load.PackagesAndErrors(moduleLoaderState, ctx, load.PackageOpts{}, args) { + clean(pkg) + } + } + + sh := work.NewShell("", &load.TextPrinter{Writer: os.Stdout}) + + if cleanCache { + dir, _, err := cache.DefaultDir() + if err != nil { + base.Fatal(err) + } + if dir != "off" { + // Remove the cache subdirectories but not the top cache directory. + // The top cache directory may have been created with special permissions + // and not something that we want to remove. Also, we'd like to preserve + // the access log for future analysis, even if the cache is cleared. + subdirs, _ := filepath.Glob(filepath.Join(str.QuoteGlob(dir), "[0-9a-f][0-9a-f]")) + printedErrors := false + if len(subdirs) > 0 { + if err := sh.RemoveAll(subdirs...); err != nil && !printedErrors { + printedErrors = true + base.Error(err) + } + } + + logFile := filepath.Join(dir, "log.txt") + if err := sh.RemoveAll(logFile); err != nil && !printedErrors { + printedErrors = true + base.Error(err) + } + } + } + + if cleanTestcache && !cleanCache { + // Instead of walking through the entire cache looking for test results, + // we write a file to the cache indicating that all test results from before + // right now are to be ignored. + dir, _, err := cache.DefaultDir() + if err != nil { + base.Fatal(err) + } + if dir != "off" { + f, err := lockedfile.Edit(filepath.Join(dir, "testexpire.txt")) + if err == nil { + now := time.Now().UnixNano() + buf, _ := io.ReadAll(f) + prev, _ := strconv.ParseInt(strings.TrimSpace(string(buf)), 10, 64) + if now > prev { + if err = f.Truncate(0); err == nil { + if _, err = f.Seek(0, 0); err == nil { + _, err = fmt.Fprintf(f, "%d\n", now) + } + } + } + if closeErr := f.Close(); err == nil { + err = closeErr + } + } + if err != nil { + if _, statErr := os.Stat(dir); !os.IsNotExist(statErr) { + base.Error(err) + } + } + } + } + + if cleanModcache { + if cfg.GOMODCACHE == "" { + base.Fatalf("go: cannot clean -modcache without a module cache") + } + if cfg.BuildN || cfg.BuildX { + sh.ShowCmd("", "rm -rf %s", cfg.GOMODCACHE) + } + if !cfg.BuildN { + if err := modfetch.RemoveAll(cfg.GOMODCACHE); err != nil { + base.Error(err) + + // Add extra logging for the purposes of debugging #68087. + // We're getting ENOTEMPTY errors on openbsd from RemoveAll. + // Check for os.ErrExist, which can match syscall.ENOTEMPTY + // and syscall.EEXIST, because syscall.ENOTEMPTY is not defined + // on all platforms. + if runtime.GOOS == "openbsd" && errors.Is(err, fs.ErrExist) { + logFilesInGOMODCACHE() + } + } + } + } + + if cleanFuzzcache { + fuzzDir := cache.Default().FuzzDir() + if err := sh.RemoveAll(fuzzDir); err != nil { + base.Error(err) + } + } +} + +// logFilesInGOMODCACHE reports the file names and modes for the files in GOMODCACHE using base.Error. +func logFilesInGOMODCACHE() { + var found []string + werr := filepath.WalkDir(cfg.GOMODCACHE, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + var mode string + info, err := d.Info() + if err == nil { + mode = info.Mode().String() + } else { + mode = fmt.Sprintf("", info.Mode()) + } + found = append(found, fmt.Sprintf("%s (mode: %s)", path, mode)) + return nil + }) + if werr != nil { + base.Errorf("walking files in GOMODCACHE (for debugging go.dev/issue/68087): %v", werr) + } + base.Errorf("files in GOMODCACHE (for debugging go.dev/issue/68087):\n%s", strings.Join(found, "\n")) +} + +var cleaned = map[*load.Package]bool{} + +// TODO: These are dregs left by Makefile-based builds. +// Eventually, can stop deleting these. +var cleanDir = map[string]bool{ + "_test": true, + "_obj": true, +} + +var cleanFile = map[string]bool{ + "_testmain.go": true, + "test.out": true, + "build.out": true, + "a.out": true, +} + +var cleanExt = map[string]bool{ + ".5": true, + ".6": true, + ".8": true, + ".a": true, + ".o": true, + ".so": true, +} + +func clean(p *load.Package) { + if cleaned[p] { + return + } + cleaned[p] = true + + if p.Dir == "" { + base.Errorf("%v", p.Error) + return + } + dirs, err := os.ReadDir(p.Dir) + if err != nil { + base.Errorf("go: %s: %v", p.Dir, err) + return + } + + sh := work.NewShell("", &load.TextPrinter{Writer: os.Stdout}) + + packageFile := map[string]bool{} + if p.Name != "main" { + // Record which files are not in package main. + // The others are. + keep := func(list []string) { + for _, f := range list { + packageFile[f] = true + } + } + keep(p.GoFiles) + keep(p.CgoFiles) + keep(p.TestGoFiles) + keep(p.XTestGoFiles) + } + + _, elem := filepath.Split(p.Dir) + var allRemove []string + + // Remove dir-named executable only if this is package main. + if p.Name == "main" { + allRemove = append(allRemove, + elem, + elem+".exe", + p.DefaultExecName(), + p.DefaultExecName()+".exe", + ) + } + + // Remove package test executables. + allRemove = append(allRemove, + elem+".test", + elem+".test.exe", + p.DefaultExecName()+".test", + p.DefaultExecName()+".test.exe", + ) + + // Remove a potential executable, test executable for each .go file in the directory that + // is not part of the directory's package. + for _, dir := range dirs { + name := dir.Name() + if packageFile[name] { + continue + } + + if dir.IsDir() { + continue + } + + if base, found := strings.CutSuffix(name, "_test.go"); found { + allRemove = append(allRemove, base+".test", base+".test.exe") + } + + if base, found := strings.CutSuffix(name, ".go"); found { + // TODO(adg,rsc): check that this .go file is actually + // in "package main", and therefore capable of building + // to an executable file. + allRemove = append(allRemove, base, base+".exe") + } + } + + if cfg.BuildN || cfg.BuildX { + sh.ShowCmd(p.Dir, "rm -f %s", strings.Join(allRemove, " ")) + } + + toRemove := map[string]bool{} + for _, name := range allRemove { + toRemove[name] = true + } + for _, dir := range dirs { + name := dir.Name() + if dir.IsDir() { + // TODO: Remove once Makefiles are forgotten. + if cleanDir[name] { + if err := sh.RemoveAll(filepath.Join(p.Dir, name)); err != nil { + base.Error(err) + } + } + continue + } + + if cfg.BuildN { + continue + } + + if cleanFile[name] || cleanExt[filepath.Ext(name)] || toRemove[name] { + removeFile(filepath.Join(p.Dir, name)) + } + } + + if cleanI && p.Target != "" { + if cfg.BuildN || cfg.BuildX { + sh.ShowCmd("", "rm -f %s", p.Target) + } + if !cfg.BuildN { + removeFile(p.Target) + } + } + + if cleanR { + for _, p1 := range p.Internal.Imports { + clean(p1) + } + } +} + +// removeFile tries to remove file f, if error other than file doesn't exist +// occurs, it will report the error. +func removeFile(f string) { + err := os.Remove(f) + if err == nil || os.IsNotExist(err) { + return + } + // Windows does not allow deletion of a binary file while it is executing. + if runtime.GOOS == "windows" { + // Remove lingering ~ file from last attempt. + if _, err2 := os.Stat(f + "~"); err2 == nil { + os.Remove(f + "~") + } + // Try to move it out of the way. If the move fails, + // which is likely, we'll try again the + // next time we do an install of this binary. + if err2 := os.Rename(f, f+"~"); err2 == nil { + os.Remove(f + "~") + return + } + } + base.Error(err) +} diff --git a/go/src/cmd/go/internal/cmdflag/flag.go b/go/src/cmd/go/internal/cmdflag/flag.go new file mode 100644 index 0000000000000000000000000000000000000000..86e33ea111eb4b432bc453be8fb83b97438c63c1 --- /dev/null +++ b/go/src/cmd/go/internal/cmdflag/flag.go @@ -0,0 +1,122 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package cmdflag handles flag processing common to several go tools. +package cmdflag + +import ( + "errors" + "flag" + "fmt" + "strings" +) + +// The flag handling part of go commands such as test is large and distracting. +// We can't use the standard flag package because some of the flags from +// our command line are for us, and some are for the binary we're running, +// and some are for both. + +// ErrFlagTerminator indicates the distinguished token "--", which causes the +// flag package to treat all subsequent arguments as non-flags. +var ErrFlagTerminator = errors.New("flag terminator") + +// A FlagNotDefinedError indicates a flag-like argument that does not correspond +// to any registered flag in a FlagSet. +type FlagNotDefinedError struct { + RawArg string // the original argument, like --foo or -foo=value + Name string + HasValue bool // is this the -foo=value or --foo=value form? + Value string // only provided if HasValue is true +} + +func (e FlagNotDefinedError) Error() string { + return fmt.Sprintf("flag provided but not defined: -%s", e.Name) +} + +// A NonFlagError indicates an argument that is not a syntactically-valid flag. +type NonFlagError struct { + RawArg string +} + +func (e NonFlagError) Error() string { + return fmt.Sprintf("not a flag: %q", e.RawArg) +} + +// ParseOne sees if args[0] is present in the given flag set and if so, +// sets its value and returns the flag along with the remaining (unused) arguments. +// +// ParseOne always returns either a non-nil Flag or a non-nil error, +// and always consumes at least one argument (even on error). +// +// Unlike (*flag.FlagSet).Parse, ParseOne does not log its own errors. +func ParseOne(fs *flag.FlagSet, args []string) (f *flag.Flag, remainingArgs []string, err error) { + // This function is loosely derived from (*flag.FlagSet).parseOne. + + raw, args := args[0], args[1:] + arg := raw + if strings.HasPrefix(arg, "--") { + if arg == "--" { + return nil, args, ErrFlagTerminator + } + arg = arg[1:] // reduce two minuses to one + } + + switch arg { + case "-?", "-h", "-help": + return nil, args, flag.ErrHelp + } + if len(arg) < 2 || arg[0] != '-' || arg[1] == '-' || arg[1] == '=' { + return nil, args, NonFlagError{RawArg: raw} + } + + name, value, hasValue := strings.Cut(arg[1:], "=") + + f = fs.Lookup(name) + if f == nil { + return nil, args, FlagNotDefinedError{ + RawArg: raw, + Name: name, + HasValue: hasValue, + Value: value, + } + } + + // Use fs.Set instead of f.Value.Set below so that any subsequent call to + // fs.Visit will correctly visit the flags that have been set. + + failf := func(format string, a ...any) (*flag.Flag, []string, error) { + return f, args, fmt.Errorf(format, a...) + } + + if fv, ok := f.Value.(boolFlag); ok && fv.IsBoolFlag() { // special case: doesn't need an arg + if hasValue { + if err := fs.Set(name, value); err != nil { + return failf("invalid boolean value %q for -%s: %v", value, name, err) + } + } else { + if err := fs.Set(name, "true"); err != nil { + return failf("invalid boolean flag %s: %v", name, err) + } + } + } else { + // It must have a value, which might be the next argument. + if !hasValue && len(args) > 0 { + // value is the next arg + hasValue = true + value, args = args[0], args[1:] + } + if !hasValue { + return failf("flag needs an argument: -%s", name) + } + if err := fs.Set(name, value); err != nil { + return failf("invalid value %q for flag -%s: %v", value, name, err) + } + } + + return f, args, nil +} + +type boolFlag interface { + IsBoolFlag() bool +} diff --git a/go/src/cmd/go/internal/doc/dirs.go b/go/src/cmd/go/internal/doc/dirs.go new file mode 100644 index 0000000000000000000000000000000000000000..5efd40b1d5a48bb6a710ee26bca350169463e27b --- /dev/null +++ b/go/src/cmd/go/internal/doc/dirs.go @@ -0,0 +1,320 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package doc + +import ( + "bytes" + "fmt" + "log" + "os" + "os/exec" + "path/filepath" + "regexp" + "strings" + "sync" + + "golang.org/x/mod/semver" +) + +// A Dir describes a directory holding code by specifying +// the expected import path and the file system directory. +type Dir struct { + importPath string // import path for that dir + dir string // file system directory + inModule bool +} + +// Dirs is a structure for scanning the directory tree. +// Its Next method returns the next Go source directory it finds. +// Although it can be used to scan the tree multiple times, it +// only walks the tree once, caching the data it finds. +type Dirs struct { + scan chan Dir // Directories generated by walk. + hist []Dir // History of reported Dirs. + offset int // Counter for Next. +} + +var dirs Dirs + +// dirsInit starts the scanning of package directories in GOROOT and GOPATH. Any +// extra paths passed to it are included in the channel. +func dirsInit(extra ...Dir) { + if buildCtx.GOROOT == "" { + stdout, err := exec.Command("go", "env", "GOROOT").Output() + if err != nil { + if ee, ok := err.(*exec.ExitError); ok && len(ee.Stderr) > 0 { + log.Fatalf("failed to determine GOROOT: $GOROOT is not set and 'go env GOROOT' failed:\n%s", ee.Stderr) + } + log.Fatalf("failed to determine GOROOT: $GOROOT is not set and could not run 'go env GOROOT':\n\t%s", err) + } + buildCtx.GOROOT = string(bytes.TrimSpace(stdout)) + } + + dirs.hist = make([]Dir, 0, 1000) + dirs.hist = append(dirs.hist, extra...) + dirs.scan = make(chan Dir) + go dirs.walk(codeRoots()) +} + +// goCmd returns the "go" command path corresponding to buildCtx.GOROOT. +func goCmd() string { + if buildCtx.GOROOT == "" { + return "go" + } + return filepath.Join(buildCtx.GOROOT, "bin", "go") +} + +// Reset puts the scan back at the beginning. +func (d *Dirs) Reset() { + d.offset = 0 +} + +// Next returns the next directory in the scan. The boolean +// is false when the scan is done. +func (d *Dirs) Next() (Dir, bool) { + if d.offset < len(d.hist) { + dir := d.hist[d.offset] + d.offset++ + return dir, true + } + dir, ok := <-d.scan + if !ok { + return Dir{}, false + } + d.hist = append(d.hist, dir) + d.offset++ + return dir, ok +} + +// walk walks the trees in GOROOT and GOPATH. +func (d *Dirs) walk(roots []Dir) { + for _, root := range roots { + d.bfsWalkRoot(root) + } + close(d.scan) +} + +// bfsWalkRoot walks a single directory hierarchy in breadth-first lexical order. +// Each Go source directory it finds is delivered on d.scan. +func (d *Dirs) bfsWalkRoot(root Dir) { + root.dir = filepath.Clean(root.dir) // because filepath.Join will do it anyway + + // this is the queue of directories to examine in this pass. + this := []string{} + // next is the queue of directories to examine in the next pass. + next := []string{root.dir} + + for len(next) > 0 { + this, next = next, this[0:0] + for _, dir := range this { + fd, err := os.Open(dir) + if err != nil { + log.Print(err) + continue + } + entries, err := fd.Readdir(0) + fd.Close() + if err != nil { + log.Print(err) + continue + } + hasGoFiles := false + for _, entry := range entries { + name := entry.Name() + // For plain files, remember if this directory contains any .go + // source files, but ignore them otherwise. + if !entry.IsDir() { + if !hasGoFiles && strings.HasSuffix(name, ".go") { + hasGoFiles = true + } + continue + } + // Entry is a directory. + + // The go tool ignores directories starting with ., _, or named "testdata". + if name[0] == '.' || name[0] == '_' || name == "testdata" { + continue + } + // When in a module, ignore vendor directories and stop at module boundaries. + if root.inModule { + if name == "vendor" { + continue + } + if fi, err := os.Stat(filepath.Join(dir, name, "go.mod")); err == nil && !fi.IsDir() { + continue + } + } + // Remember this (fully qualified) directory for the next pass. + next = append(next, filepath.Join(dir, name)) + } + if hasGoFiles { + // It's a candidate. + importPath := root.importPath + if len(dir) > len(root.dir) { + if importPath != "" { + importPath += "/" + } + importPath += filepath.ToSlash(dir[len(root.dir)+1:]) + } + d.scan <- Dir{importPath, dir, root.inModule} + } + } + + } +} + +var testGOPATH = false // force GOPATH use for testing + +// codeRoots returns the code roots to search for packages. +// In GOPATH mode this is GOROOT/src and GOPATH/src, with empty import paths. +// In module mode, this is each module root, with an import path set to its module path. +func codeRoots() []Dir { + codeRootsCache.once.Do(func() { + codeRootsCache.roots = findCodeRoots() + }) + return codeRootsCache.roots +} + +var codeRootsCache struct { + once sync.Once + roots []Dir +} + +var usingModules bool + +func findCodeRoots() []Dir { + var list []Dir + if !testGOPATH { + // Check for use of modules by 'go env GOMOD', + // which reports a go.mod file path if modules are enabled. + stdout, _ := exec.Command(goCmd(), "env", "GOMOD").Output() + gomod := string(bytes.TrimSpace(stdout)) + + usingModules = len(gomod) > 0 + if usingModules && buildCtx.GOROOT != "" { + list = append(list, + Dir{dir: filepath.Join(buildCtx.GOROOT, "src"), inModule: true}, + Dir{importPath: "cmd", dir: filepath.Join(buildCtx.GOROOT, "src", "cmd"), inModule: true}) + } + + if gomod == os.DevNull { + // Modules are enabled, but the working directory is outside any module. + // We can still access std, cmd, and packages specified as source files + // on the command line, but there are no module roots. + // Avoid 'go list -m all' below, since it will not work. + return list + } + } + + if !usingModules { + if buildCtx.GOROOT != "" { + list = append(list, Dir{dir: filepath.Join(buildCtx.GOROOT, "src")}) + } + for _, root := range splitGopath() { + list = append(list, Dir{dir: filepath.Join(root, "src")}) + } + return list + } + + // Find module root directories from go list. + // Eventually we want golang.org/x/tools/go/packages + // to handle the entire file system search and become go/packages, + // but for now enumerating the module roots lets us fit modules + // into the current code with as few changes as possible. + mainMod, vendorEnabled, err := vendorEnabled() + if err != nil { + return list + } + if vendorEnabled { + // Add the vendor directory to the search path ahead of "std". + // That way, if the main module *is* "std", we will identify the path + // without the "vendor/" prefix before the one with that prefix. + list = append([]Dir{{dir: filepath.Join(mainMod.Dir, "vendor"), inModule: false}}, list...) + if mainMod.Path != "std" { + list = append(list, Dir{importPath: mainMod.Path, dir: mainMod.Dir, inModule: true}) + } + return list + } + + cmd := exec.Command(goCmd(), "list", "-m", "-f={{.Path}}\t{{.Dir}}", "all") + cmd.Stderr = os.Stderr + out, _ := cmd.Output() + for line := range strings.SplitSeq(string(out), "\n") { + path, dir, _ := strings.Cut(line, "\t") + if dir != "" { + list = append(list, Dir{importPath: path, dir: dir, inModule: true}) + } + } + + return list +} + +// The functions below are derived from x/tools/internal/imports at CL 203017. + +type moduleJSON struct { + Path, Dir, GoVersion string +} + +var modFlagRegexp = regexp.MustCompile(`-mod[ =](\w+)`) + +// vendorEnabled indicates if vendoring is enabled. +// Inspired by setDefaultBuildMod in modload/init.go +func vendorEnabled() (*moduleJSON, bool, error) { + mainMod, go114, err := getMainModuleAnd114() + if err != nil { + return nil, false, err + } + + stdout, _ := exec.Command(goCmd(), "env", "GOFLAGS").Output() + goflags := string(bytes.TrimSpace(stdout)) + matches := modFlagRegexp.FindStringSubmatch(goflags) + var modFlag string + if len(matches) != 0 { + modFlag = matches[1] + } + if modFlag != "" { + // Don't override an explicit '-mod=' argument. + return mainMod, modFlag == "vendor", nil + } + if mainMod == nil || !go114 { + return mainMod, false, nil + } + // Check 1.14's automatic vendor mode. + if fi, err := os.Stat(filepath.Join(mainMod.Dir, "vendor")); err == nil && fi.IsDir() { + if mainMod.GoVersion != "" && semver.Compare("v"+mainMod.GoVersion, "v1.14") >= 0 { + // The Go version is at least 1.14, and a vendor directory exists. + // Set -mod=vendor by default. + return mainMod, true, nil + } + } + return mainMod, false, nil +} + +// getMainModuleAnd114 gets the main module's information and whether the +// go command in use is 1.14+. This is the information needed to figure out +// if vendoring should be enabled. +func getMainModuleAnd114() (*moduleJSON, bool, error) { + const format = `{{.Path}} +{{.Dir}} +{{.GoVersion}} +{{range context.ReleaseTags}}{{if eq . "go1.14"}}{{.}}{{end}}{{end}} +` + cmd := exec.Command(goCmd(), "list", "-m", "-f", format) + cmd.Stderr = os.Stderr + stdout, err := cmd.Output() + if err != nil { + return nil, false, nil + } + lines := strings.Split(string(stdout), "\n") + if len(lines) < 5 { + return nil, false, fmt.Errorf("unexpected stdout: %q", stdout) + } + mod := &moduleJSON{ + Path: lines[0], + Dir: lines[1], + GoVersion: lines[2], + } + return mod, lines[3] == "go1.14", nil +} diff --git a/go/src/cmd/go/internal/doc/doc.go b/go/src/cmd/go/internal/doc/doc.go new file mode 100644 index 0000000000000000000000000000000000000000..fceeaf101efd62292551dd4f64e62116105b0a0f --- /dev/null +++ b/go/src/cmd/go/internal/doc/doc.go @@ -0,0 +1,575 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package doc implements the “go doc” command. +package doc + +import ( + "bytes" + "context" + "flag" + "fmt" + "go/build" + "go/token" + "io" + "log" + "os" + "os/exec" + "path" + "path/filepath" + "strings" + + "cmd/go/internal/base" + "cmd/internal/telemetry/counter" +) + +var CmdDoc = &base.Command{ + Run: runDoc, + UsageLine: "go doc [doc flags] [package|[package.]symbol[.methodOrField]]", + CustomFlags: true, + Short: "show documentation for package or symbol", + Long: ` +Doc prints the documentation comments associated with the item identified by its +arguments (a package, const, func, type, var, method, or struct field) +followed by a one-line summary of each of the first-level items "under" +that item (package-level declarations for a package, methods for a type, +etc.). + +Doc accepts zero, one, or two arguments. + +Given no arguments, that is, when run as + + go doc + +it prints the package documentation for the package in the current directory. +If the package is a command (package main), the exported symbols of the package +are elided from the presentation unless the -cmd flag is provided. + +When run with one argument, the argument is treated as a Go-syntax-like +representation of the item to be documented. What the argument selects depends +on what is installed in GOROOT and GOPATH, as well as the form of the argument, +which is schematically one of these: + + go doc + go doc [.] + go doc [.][.] + go doc [.][.] + +The first item in this list matched by the argument is the one whose documentation +is printed. (See the examples below.) However, if the argument starts with a capital +letter it is assumed to identify a symbol or method in the current directory. + +For packages, the order of scanning is determined lexically in breadth-first order. +That is, the package presented is the one that matches the search and is nearest +the root and lexically first at its level of the hierarchy. The GOROOT tree is +always scanned in its entirety before GOPATH. + +If there is no package specified or matched, the package in the current +directory is selected, so "go doc Foo" shows the documentation for symbol Foo in +the current package. + +The package path must be either a qualified path or a proper suffix of a +path. The go tool's usual package mechanism does not apply: package path +elements like . and ... are not implemented by go doc. + +When run with two arguments, the first is a package path (full path or suffix), +and the second is a symbol, or symbol with method or struct field: + + go doc [.] + +In all forms, when matching symbols, lower-case letters in the argument match +either case but upper-case letters match exactly. This means that there may be +multiple matches of a lower-case argument in a package if different symbols have +different cases. If this occurs, documentation for all matches is printed. + +Examples: + go doc + Show documentation for current package. + go doc -http + Serve HTML documentation over HTTP for the current package. + go doc Foo + Show documentation for Foo in the current package. + (Foo starts with a capital letter so it cannot match + a package path.) + go doc encoding/json + Show documentation for the encoding/json package. + go doc json + Shorthand for encoding/json. + go doc json.Number (or go doc json.number) + Show documentation and method summary for json.Number. + go doc json.Number.Int64 (or go doc json.number.int64) + Show documentation for json.Number's Int64 method. + go doc cmd/doc + Show package docs for the doc command. + go doc -cmd cmd/doc + Show package docs and exported symbols within the doc command. + go doc template.new + Show documentation for html/template's New function. + (html/template is lexically before text/template) + go doc text/template.new # One argument + Show documentation for text/template's New function. + go doc text/template new # Two arguments + Show documentation for text/template's New function. + + At least in the current tree, these invocations all print the + documentation for json.Decoder's Decode method: + + go doc json.Decoder.Decode + go doc json.decoder.decode + go doc json.decode + cd go/src/encoding/json; go doc decode + +Flags: + -all + Show all the documentation for the package. + -c + Respect case when matching symbols. + -cmd + Treat a command (package main) like a regular package. + Otherwise package main's exported symbols are hidden + when showing the package's top-level documentation. + -http + Serve HTML docs over HTTP. + -short + One-line representation for each symbol. + -src + Show the full source code for the symbol. This will + display the full Go source of its declaration and + definition, such as a function definition (including + the body), type declaration or enclosing const + block. The output may therefore include unexported + details. + -u + Show documentation for unexported as well as exported + symbols, methods, and fields. +`, +} + +func runDoc(ctx context.Context, cmd *base.Command, args []string) { + log.SetFlags(0) + log.SetPrefix("doc: ") + dirsInit() + var flagSet flag.FlagSet + err := do(os.Stdout, &flagSet, args) + if err != nil { + log.Fatal(err) + } +} + +var ( + unexported bool // -u flag + matchCase bool // -c flag + chdir string // -C flag + showAll bool // -all flag + showCmd bool // -cmd flag + showSrc bool // -src flag + short bool // -short flag + serveHTTP bool // -http flag +) + +// usage is a replacement usage function for the flags package. +func usage(flagSet *flag.FlagSet) { + fmt.Fprintf(os.Stderr, "Usage of [go] doc:\n") + fmt.Fprintf(os.Stderr, "\tgo doc\n") + fmt.Fprintf(os.Stderr, "\tgo doc \n") + fmt.Fprintf(os.Stderr, "\tgo doc [.]\n") + fmt.Fprintf(os.Stderr, "\tgo doc [.][.]\n") + fmt.Fprintf(os.Stderr, "\tgo doc [.][.]\n") + fmt.Fprintf(os.Stderr, "\tgo doc [.]\n") + fmt.Fprintf(os.Stderr, "For more information run\n") + fmt.Fprintf(os.Stderr, "\tgo help doc\n\n") + fmt.Fprintf(os.Stderr, "Flags:\n") + flagSet.PrintDefaults() + os.Exit(2) +} + +// do is the workhorse, broken out of runDoc to make testing easier. +func do(writer io.Writer, flagSet *flag.FlagSet, args []string) (err error) { + flagSet.Usage = func() { usage(flagSet) } + unexported = false + matchCase = false + flagSet.StringVar(&chdir, "C", "", "change to `dir` before running command") + flagSet.BoolVar(&unexported, "u", false, "show unexported symbols as well as exported") + flagSet.BoolVar(&matchCase, "c", false, "symbol matching honors case (paths not affected)") + flagSet.BoolVar(&showAll, "all", false, "show all documentation for package") + flagSet.BoolVar(&showCmd, "cmd", false, "show symbols with package docs even if package is a command") + flagSet.BoolVar(&showSrc, "src", false, "show source code for symbol") + flagSet.BoolVar(&short, "short", false, "one-line representation for each symbol") + flagSet.BoolVar(&serveHTTP, "http", false, "serve HTML docs over HTTP") + flagSet.Parse(args) + counter.CountFlags("doc/flag:", *flag.CommandLine) + if chdir != "" { + if err := os.Chdir(chdir); err != nil { + return err + } + } + if serveHTTP { + // Special case: if there are no arguments, try to go to an appropriate page + // depending on whether we're in a module or workspace. The pkgsite homepage + // is often not the most useful page. + if len(flagSet.Args()) == 0 { + mod, err := runCmd(append(os.Environ(), "GOWORK=off"), "go", "list", "-m") + if err == nil && mod != "" && mod != "command-line-arguments" { + // If there's a module, go to the module's doc page. + return doPkgsite(mod, "") + } + gowork, err := runCmd(nil, "go", "env", "GOWORK") + if err == nil && gowork != "" { + // Outside a module, but in a workspace, go to the home page + // with links to each of the modules' pages. + return doPkgsite("", "") + } + // Outside a module or workspace, go to the documentation for the standard library. + return doPkgsite("std", "") + } + + // If args are provided, we need to figure out which page to open on the pkgsite + // instance. Run the logic below to determine a match for a symbol, method, + // or field, but don't actually print the documentation to the output. + writer = io.Discard + } + var paths []string + var symbol, method string + // Loop until something is printed. + dirs.Reset() + for i := 0; ; i++ { + buildPackage, userPath, sym, more := parseArgs(flagSet, flagSet.Args()) + if i > 0 && !more { // Ignore the "more" bit on the first iteration. + return failMessage(paths, symbol, method) + } + if buildPackage == nil { + return fmt.Errorf("no such package: %s", userPath) + } + + // The builtin package needs special treatment: its symbols are lower + // case but we want to see them, always. + if buildPackage.ImportPath == "builtin" { + unexported = true + } + + symbol, method = parseSymbol(flagSet, sym) + pkg := parsePackage(writer, buildPackage, userPath) + paths = append(paths, pkg.prettyPath()) + + defer func() { + pkg.flush() + e := recover() + if e == nil { + return + } + pkgError, ok := e.(PackageError) + if ok { + err = pkgError + return + } + panic(e) + }() + + var found bool + switch { + case symbol == "": + pkg.packageDoc() // The package exists, so we got some output. + found = true + case method == "": + if pkg.symbolDoc(symbol) { + found = true + } + case pkg.printMethodDoc(symbol, method): + found = true + case pkg.printFieldDoc(symbol, method): + found = true + } + if found { + if serveHTTP { + path, fragment, err := objectPath(userPath, pkg, symbol, method) + if err != nil { + return err + } + return doPkgsite(path, fragment) + } + return nil + } + } +} + +func runCmd(env []string, cmdline ...string) (string, error) { + var stdout, stderr strings.Builder + cmd := exec.Command(cmdline[0], cmdline[1:]...) + cmd.Env = env + cmd.Stdout = &stdout + cmd.Stderr = &stderr + if err := cmd.Run(); err != nil { + return "", fmt.Errorf("go doc: %s: %v\n%s\n", strings.Join(cmdline, " "), err, stderr.String()) + } + return strings.TrimSpace(stdout.String()), nil +} + +// returns a path followed by a fragment (or an error) +func objectPath(userPath string, pkg *Package, symbol, method string) (string, string, error) { + var err error + path := pkg.build.ImportPath + if path == "." { + // go/build couldn't determine the import path, probably + // because this was a relative path into a module. Use + // go list to get the import path. + path, err = runCmd(nil, "go", "list", userPath) + if err != nil { + return "", "", err + } + } + + object := symbol + if symbol != "" && method != "" { + object = symbol + "." + method + } + return path, object, nil +} + +// failMessage creates a nicely formatted error message when there is no result to show. +func failMessage(paths []string, symbol, method string) error { + var b bytes.Buffer + if len(paths) > 1 { + b.WriteString("s") + } + b.WriteString(" ") + for i, path := range paths { + if i > 0 { + b.WriteString(", ") + } + b.WriteString(path) + } + if method == "" { + return fmt.Errorf("no symbol %s in package%s", symbol, &b) + } + return fmt.Errorf("no method or field %s.%s in package%s", symbol, method, &b) +} + +// parseArgs analyzes the arguments (if any) and returns the package +// it represents, the part of the argument the user used to identify +// the path (or "" if it's the current package) and the symbol +// (possibly with a .method) within that package. +// parseSymbol is used to analyze the symbol itself. +// The boolean final argument reports whether it is possible that +// there may be more directories worth looking at. It will only +// be true if the package path is a partial match for some directory +// and there may be more matches. For example, if the argument +// is rand.Float64, we must scan both crypto/rand and math/rand +// to find the symbol, and the first call will return crypto/rand, true. +func parseArgs(flagSet *flag.FlagSet, args []string) (pkg *build.Package, path, symbol string, more bool) { + wd, err := os.Getwd() + if err != nil { + log.Fatal(err) + } + if len(args) == 0 { + // Easy: current directory. + return importDir(wd), "", "", false + } + arg := args[0] + // We have an argument. If it is a directory name beginning with . or .., + // use the absolute path name. This discriminates "./errors" from "errors" + // if the current directory contains a non-standard errors package. + if isDotSlash(arg) { + arg = filepath.Join(wd, arg) + } + switch len(args) { + default: + usage(flagSet) + case 1: + // Done below. + case 2: + // Package must be findable and importable. + pkg, err := build.Import(args[0], wd, build.ImportComment) + if err == nil { + return pkg, args[0], args[1], false + } + for { + packagePath, ok := findNextPackage(arg) + if !ok { + break + } + if pkg, err := build.ImportDir(packagePath, build.ImportComment); err == nil { + return pkg, arg, args[1], true + } + } + return nil, args[0], args[1], false + } + // Usual case: one argument. + // If it contains slashes, it begins with either a package path + // or an absolute directory. + // First, is it a complete package path as it is? If so, we are done. + // This avoids confusion over package paths that have other + // package paths as their prefix. + var importErr error + if filepath.IsAbs(arg) { + pkg, importErr = build.ImportDir(arg, build.ImportComment) + if importErr == nil { + return pkg, arg, "", false + } + } else { + pkg, importErr = build.Import(arg, wd, build.ImportComment) + if importErr == nil { + return pkg, arg, "", false + } + } + // Another disambiguator: If the argument starts with an upper + // case letter, it can only be a symbol in the current directory. + // Kills the problem caused by case-insensitive file systems + // matching an upper case name as a package name. + if !strings.ContainsAny(arg, `/\`) && token.IsExported(arg) { + pkg, err := build.ImportDir(".", build.ImportComment) + if err == nil { + return pkg, "", arg, false + } + } + // If it has a slash, it must be a package path but there is a symbol. + // It's the last package path we care about. + slash := strings.LastIndex(arg, "/") + // There may be periods in the package path before or after the slash + // and between a symbol and method. + // Split the string at various periods to see what we find. + // In general there may be ambiguities but this should almost always + // work. + var period int + // slash+1: if there's no slash, the value is -1 and start is 0; otherwise + // start is the byte after the slash. + for start := slash + 1; start < len(arg); start = period + 1 { + period = strings.Index(arg[start:], ".") + symbol := "" + if period < 0 { + period = len(arg) + } else { + period += start + symbol = arg[period+1:] + } + // Have we identified a package already? + pkg, err := build.Import(arg[0:period], wd, build.ImportComment) + if err == nil { + return pkg, arg[0:period], symbol, false + } + // See if we have the basename or tail of a package, as in json for encoding/json + // or ivy/value for robpike.io/ivy/value. + pkgName := arg[:period] + for { + path, ok := findNextPackage(pkgName) + if !ok { + break + } + if pkg, err = build.ImportDir(path, build.ImportComment); err == nil { + return pkg, arg[0:period], symbol, true + } + } + dirs.Reset() // Next iteration of for loop must scan all the directories again. + } + // If it has a slash, we've failed. + if slash >= 0 { + // build.Import should always include the path in its error message, + // and we should avoid repeating it. Unfortunately, build.Import doesn't + // return a structured error. That can't easily be fixed, since it + // invokes 'go list' and returns the error text from the loaded package. + // TODO(golang.org/issue/34750): load using golang.org/x/tools/go/packages + // instead of go/build. + importErrStr := importErr.Error() + if strings.Contains(importErrStr, arg[:period]) { + log.Fatal(importErrStr) + } else { + log.Fatalf("no such package %s: %s", arg[:period], importErrStr) + } + } + // Guess it's a symbol in the current directory. + return importDir(wd), "", arg, false +} + +// dotPaths lists all the dotted paths legal on Unix-like and +// Windows-like file systems. We check them all, as the chance +// of error is minute and even on Windows people will use ./ +// sometimes. +var dotPaths = []string{ + `./`, + `../`, + `.\`, + `..\`, +} + +// isDotSlash reports whether the path begins with a reference +// to the local . or .. directory. +func isDotSlash(arg string) bool { + if arg == "." || arg == ".." { + return true + } + for _, dotPath := range dotPaths { + if strings.HasPrefix(arg, dotPath) { + return true + } + } + return false +} + +// importDir is just an error-catching wrapper for build.ImportDir. +func importDir(dir string) *build.Package { + pkg, err := build.ImportDir(dir, build.ImportComment) + if err != nil { + log.Fatal(err) + } + return pkg +} + +// parseSymbol breaks str apart into a symbol and method. +// Both may be missing or the method may be missing. +// If present, each must be a valid Go identifier. +func parseSymbol(flagSet *flag.FlagSet, str string) (symbol, method string) { + if str == "" { + return + } + elem := strings.Split(str, ".") + switch len(elem) { + case 1: + case 2: + method = elem[1] + default: + log.Printf("too many periods in symbol specification") + usage(flagSet) + } + symbol = elem[0] + return +} + +// isExported reports whether the name is an exported identifier. +// If the unexported flag (-u) is true, isExported returns true because +// it means that we treat the name as if it is exported. +func isExported(name string) bool { + return unexported || token.IsExported(name) +} + +// findNextPackage returns the next full file name path that matches the +// (perhaps partial) package path pkg. The boolean reports if any match was found. +func findNextPackage(pkg string) (string, bool) { + if filepath.IsAbs(pkg) { + if dirs.offset == 0 { + dirs.offset = -1 + return pkg, true + } + return "", false + } + if pkg == "" || token.IsExported(pkg) { // Upper case symbol cannot be a package name. + return "", false + } + pkg = path.Clean(pkg) + pkgSuffix := "/" + pkg + for { + d, ok := dirs.Next() + if !ok { + return "", false + } + if d.importPath == pkg || strings.HasSuffix(d.importPath, pkgSuffix) { + return d.dir, true + } + } +} + +var buildCtx = build.Default + +// splitGopath splits $GOPATH into a list of roots. +func splitGopath() []string { + return filepath.SplitList(buildCtx.GOPATH) +} diff --git a/go/src/cmd/go/internal/doc/doc_test.go b/go/src/cmd/go/internal/doc/doc_test.go new file mode 100644 index 0000000000000000000000000000000000000000..21b6da149a6d2f82722d38f32d8c55c5746c41dd --- /dev/null +++ b/go/src/cmd/go/internal/doc/doc_test.go @@ -0,0 +1,1132 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package doc + +import ( + "bytes" + "flag" + "go/build" + "internal/testenv" + "log" + "os" + "path/filepath" + "regexp" + "runtime" + "strings" + "testing" +) + +func TestMain(m *testing.M) { + // Clear GOPATH so we don't access the user's own packages in the test. + buildCtx.GOPATH = "" + testGOPATH = true // force GOPATH mode; module test is in cmd/go/testdata/script/mod_doc.txt + + // Set GOROOT in case runtime.GOROOT is wrong (for example, if the test was + // built with -trimpath). dirsInit would identify it using 'go env GOROOT', + // but we can't be sure that the 'go' in $PATH is the right one either. + buildCtx.GOROOT = testenv.GOROOT(nil) + build.Default.GOROOT = testenv.GOROOT(nil) + + // Add $GOROOT/src/cmd/go/internal/doc/testdata explicitly so we can access its contents in the test. + // Normally testdata directories are ignored, but sending it to dirs.scan directly is + // a hack that works around the check. + testdataDir, err := filepath.Abs("testdata") + if err != nil { + panic(err) + } + dirsInit( + Dir{importPath: "testdata", dir: testdataDir}, + Dir{importPath: "testdata/nested", dir: filepath.Join(testdataDir, "nested")}, + Dir{importPath: "testdata/nested/nested", dir: filepath.Join(testdataDir, "nested", "nested")}) + + os.Exit(m.Run()) +} + +func maybeSkip(t *testing.T) { + if runtime.GOOS == "ios" { + t.Skip("iOS does not have a full file tree") + } +} + +type isDotSlashTest struct { + str string + result bool +} + +var isDotSlashTests = []isDotSlashTest{ + {``, false}, + {`x`, false}, + {`...`, false}, + {`.../`, false}, + {`...\`, false}, + + {`.`, true}, + {`./`, true}, + {`.\`, true}, + {`./x`, true}, + {`.\x`, true}, + + {`..`, true}, + {`../`, true}, + {`..\`, true}, + {`../x`, true}, + {`..\x`, true}, +} + +func TestIsDotSlashPath(t *testing.T) { + for _, test := range isDotSlashTests { + if result := isDotSlash(test.str); result != test.result { + t.Errorf("isDotSlash(%q) = %t; expected %t", test.str, result, test.result) + } + } +} + +type test struct { + name string + args []string // Arguments to "[go] doc". + yes []string // Regular expressions that should match. + no []string // Regular expressions that should not match. +} + +const p = "cmd/go/internal/doc/testdata" + +var tests = []test{ + // Sanity check. + { + "sanity check", + []string{p}, + []string{`type ExportedType struct`}, + nil, + }, + + // Package dump includes import, package statement. + { + "package clause", + []string{p}, + []string{`package pkg.*cmd/go/internal/doc/testdata`}, + nil, + }, + + // Constants. + // Package dump + { + "full package", + []string{p}, + []string{ + `Package comment`, + `const ExportedConstant = 1`, // Simple constant. + `const ConstOne = 1`, // First entry in constant block. + `const ConstFive ...`, // From block starting with unexported constant. + `var ExportedVariable = 1`, // Simple variable. + `var VarOne = 1`, // First entry in variable block. + `func ExportedFunc\(a int\) bool`, // Function. + `func ReturnUnexported\(\) unexportedType`, // Function with unexported return type. + `type ExportedType struct{ ... }`, // Exported type. + `const ExportedTypedConstant ExportedType = iota`, // Typed constant. + `const ExportedTypedConstant_unexported unexportedType`, // Typed constant, exported for unexported type. + `const ConstLeft2 uint64 ...`, // Typed constant using unexported iota. + `const ConstGroup1 unexportedType = iota ...`, // Typed constant using unexported type. + `const ConstGroup4 ExportedType = ExportedType{}`, // Typed constant using exported type. + `const MultiLineConst = ...`, // Multi line constant. + `var MultiLineVar = map\[struct{ ... }\]struct{ ... }{ ... }`, // Multi line variable. + `func MultiLineFunc\(x interface{ ... }\) \(r struct{ ... }\)`, // Multi line function. + `var LongLine = newLongLine\(("someArgument[1-4]", ){4}...\)`, // Long list of arguments. + `type T1 = T2`, // Type alias + `type SimpleConstraint interface{ ... }`, + `type TildeConstraint interface{ ... }`, + `type StructConstraint interface{ ... }`, + }, + []string{ + `const internalConstant = 2`, // No internal constants. + `var internalVariable = 2`, // No internal variables. + `func internalFunc(a int) bool`, // No internal functions. + `Comment about exported constant`, // No comment for single constant. + `Comment about exported variable`, // No comment for single variable. + `Comment about block of constants`, // No comment for constant block. + `Comment about block of variables`, // No comment for variable block. + `Comment before ConstOne`, // No comment for first entry in constant block. + `Comment before VarOne`, // No comment for first entry in variable block. + `ConstTwo = 2`, // No second entry in constant block. + `VarTwo = 2`, // No second entry in variable block. + `VarFive = 5`, // From block starting with unexported variable. + `type unexportedType`, // No unexported type. + `unexportedTypedConstant`, // No unexported typed constant. + `\bField`, // No fields. + `Method`, // No methods. + `someArgument[5-8]`, // No truncated arguments. + `type T1 T2`, // Type alias does not display as type declaration. + `ignore:directive`, // Directives should be dropped. + }, + }, + // Package dump -all + { + "full package", + []string{"-all", p}, + []string{ + `package pkg .*import`, + `Package comment`, + `CONSTANTS`, + `Comment before ConstOne`, + `ConstOne = 1`, + `ConstTwo = 2 // Comment on line with ConstTwo`, + `ConstFive`, + `ConstSix`, + `Const block where first entry is unexported`, + `ConstLeft2, constRight2 uint64`, + `constLeft3, ConstRight3`, + `ConstLeft4, ConstRight4`, + `Duplicate = iota`, + `const CaseMatch = 1`, + `const Casematch = 2`, + `const ExportedConstant = 1`, + `const MultiLineConst = `, + `MultiLineString1`, + `VARIABLES`, + `Comment before VarOne`, + `VarOne = 1`, + `Comment about block of variables`, + `VarFive = 5`, + `var ExportedVariable = 1`, + `var ExportedVarOfUnExported unexportedType`, + `var LongLine = newLongLine\(`, + `var MultiLineVar = map\[struct {`, + `FUNCTIONS`, + `func ExportedFunc\(a int\) bool`, + `Comment about exported function`, + `func MultiLineFunc\(x interface`, + `func ReturnUnexported\(\) unexportedType`, + `TYPES`, + `type ExportedInterface interface`, + `type ExportedStructOneField struct`, + `type ExportedType struct`, + `Comment about exported type`, + `const ConstGroup4 ExportedType = ExportedType`, + `ExportedTypedConstant ExportedType = iota`, + `Constants tied to ExportedType`, + `func ExportedTypeConstructor\(\) \*ExportedType`, + `Comment about constructor for exported type`, + `func ReturnExported\(\) ExportedType`, + `func \(ExportedType\) ExportedMethod\(a int\) bool`, + `Comment about exported method`, + `type T1 = T2`, + `type T2 int`, + `type SimpleConstraint interface {`, + `type TildeConstraint interface {`, + `type StructConstraint interface {`, + `BUG: function body note`, + }, + []string{ + `constThree`, + `_, _ uint64 = 2 \* iota, 1 << iota`, + `constLeft1, constRight1`, + `duplicate`, + `varFour`, + `func internalFunc`, + `unexportedField`, + `func \(unexportedType\)`, + `ignore:directive`, + }, + }, + // Package with just the package declaration. Issue 31457. + { + "only package declaration", + []string{"-all", p + "/nested/empty"}, + []string{`package empty .*import`}, + nil, + }, + // Package dump -short + { + "full package with -short", + []string{`-short`, p}, + []string{ + `const ExportedConstant = 1`, // Simple constant. + `func ReturnUnexported\(\) unexportedType`, // Function with unexported return type. + }, + []string{ + `MultiLine(String|Method|Field)`, // No data from multi line portions. + }, + }, + // Package dump -u + { + "full package with u", + []string{`-u`, p}, + []string{ + `const ExportedConstant = 1`, // Simple constant. + `const internalConstant = 2`, // Internal constants. + `func internalFunc\(a int\) bool`, // Internal functions. + `func ReturnUnexported\(\) unexportedType`, // Function with unexported return type. + }, + []string{ + `Comment about exported constant`, // No comment for simple constant. + `Comment about block of constants`, // No comment for constant block. + `Comment about internal function`, // No comment for internal function. + `MultiLine(String|Method|Field)`, // No data from multi line portions. + `ignore:directive`, + }, + }, + // Package dump -u -all + { + "full package", + []string{"-u", "-all", p}, + []string{ + `package pkg .*import`, + `Package comment`, + `CONSTANTS`, + `Comment before ConstOne`, + `ConstOne += 1`, + `ConstTwo += 2 // Comment on line with ConstTwo`, + `constThree = 3 // Comment on line with constThree`, + `ConstFive`, + `const internalConstant += 2`, + `Comment about internal constant`, + `VARIABLES`, + `Comment before VarOne`, + `VarOne += 1`, + `Comment about block of variables`, + `varFour += 4`, + `VarFive += 5`, + `varSix += 6`, + `var ExportedVariable = 1`, + `var LongLine = newLongLine\(`, + `var MultiLineVar = map\[struct {`, + `var internalVariable = 2`, + `Comment about internal variable`, + `FUNCTIONS`, + `func ExportedFunc\(a int\) bool`, + `Comment about exported function`, + `func MultiLineFunc\(x interface`, + `func internalFunc\(a int\) bool`, + `Comment about internal function`, + `func newLongLine\(ss .*string\)`, + `TYPES`, + `type ExportedType struct`, + `type T1 = T2`, + `type T2 int`, + `type unexportedType int`, + `Comment about unexported type`, + `ConstGroup1 unexportedType = iota`, + `ConstGroup2`, + `ConstGroup3`, + `ExportedTypedConstant_unexported unexportedType = iota`, + `Constants tied to unexportedType`, + `const unexportedTypedConstant unexportedType = 1`, + `func ReturnUnexported\(\) unexportedType`, + `func \(unexportedType\) ExportedMethod\(\) bool`, + `func \(unexportedType\) unexportedMethod\(\) bool`, + }, + []string{ + `ignore:directive`, + }, + }, + + // Single constant. + { + "single constant", + []string{p, `ExportedConstant`}, + []string{ + `Comment about exported constant`, // Include comment. + `const ExportedConstant = 1`, + }, + nil, + }, + // Single constant -u. + { + "single constant with -u", + []string{`-u`, p, `internalConstant`}, + []string{ + `Comment about internal constant`, // Include comment. + `const internalConstant = 2`, + }, + nil, + }, + // Block of constants. + { + "block of constants", + []string{p, `ConstTwo`}, + []string{ + `Comment before ConstOne.\n.*ConstOne = 1`, // First... + `ConstTwo = 2.*Comment on line with ConstTwo`, // And second show up. + `Comment about block of constants`, // Comment does too. + }, + []string{ + `constThree`, // No unexported constant. + }, + }, + // Block of constants -u. + { + "block of constants with -u", + []string{"-u", p, `constThree`}, + []string{ + `constThree = 3.*Comment on line with constThree`, + }, + nil, + }, + // Block of constants -src. + { + "block of constants with -src", + []string{"-src", p, `ConstTwo`}, + []string{ + `Comment about block of constants`, // Top comment. + `ConstOne.*=.*1`, // Each constant seen. + `ConstTwo.*=.*2.*Comment on line with ConstTwo`, + `constThree`, // Even unexported constants. + }, + nil, + }, + // Block of constants with carryover type from unexported field. + { + "block of constants with carryover type", + []string{p, `ConstLeft2`}, + []string{ + `ConstLeft2, constRight2 uint64`, + `constLeft3, ConstRight3`, + `ConstLeft4, ConstRight4`, + }, + nil, + }, + // Block of constants -u with carryover type from unexported field. + { + "block of constants with carryover type", + []string{"-u", p, `ConstLeft2`}, + []string{ + `_, _ uint64 = 2 \* iota, 1 << iota`, + `constLeft1, constRight1`, + `ConstLeft2, constRight2`, + `constLeft3, ConstRight3`, + `ConstLeft4, ConstRight4`, + }, + nil, + }, + + // Single variable. + { + "single variable", + []string{p, `ExportedVariable`}, + []string{ + `ExportedVariable`, // Include comment. + `var ExportedVariable = 1`, + }, + nil, + }, + // Single variable -u. + { + "single variable with -u", + []string{`-u`, p, `internalVariable`}, + []string{ + `Comment about internal variable`, // Include comment. + `var internalVariable = 2`, + }, + nil, + }, + // Block of variables. + { + "block of variables", + []string{p, `VarTwo`}, + []string{ + `Comment before VarOne.\n.*VarOne = 1`, // First... + `VarTwo = 2.*Comment on line with VarTwo`, // And second show up. + `Comment about block of variables`, // Comment does too. + }, + []string{ + `varThree= 3`, // No unexported variable. + }, + }, + // Block of variables -u. + { + "block of variables with -u", + []string{"-u", p, `varThree`}, + []string{ + `varThree = 3.*Comment on line with varThree`, + }, + nil, + }, + + // Function. + { + "function", + []string{p, `ExportedFunc`}, + []string{ + `Comment about exported function`, // Include comment. + `func ExportedFunc\(a int\) bool`, + }, + nil, + }, + // Function -u. + { + "function with -u", + []string{"-u", p, `internalFunc`}, + []string{ + `Comment about internal function`, // Include comment. + `func internalFunc\(a int\) bool`, + }, + nil, + }, + // Function with -src. + { + "function with -src", + []string{"-src", p, `ExportedFunc`}, + []string{ + `Comment about exported function`, // Include comment. + `func ExportedFunc\(a int\) bool`, + `return true != false`, // Include body. + }, + nil, + }, + + // Type. + { + "type", + []string{p, `ExportedType`}, + []string{ + `Comment about exported type`, // Include comment. + `type ExportedType struct`, // Type definition. + `Comment before exported field.*\n.*ExportedField +int` + + `.*Comment on line with exported field`, + `ExportedEmbeddedType.*Comment on line with exported embedded field`, + `Has unexported fields`, + `func \(ExportedType\) ExportedMethod\(a int\) bool`, + `const ExportedTypedConstant ExportedType = iota`, // Must include associated constant. + `func ExportedTypeConstructor\(\) \*ExportedType`, // Must include constructor. + `io.Reader.*Comment on line with embedded Reader`, + }, + []string{ + `unexportedField`, // No unexported field. + `int.*embedded`, // No unexported embedded field. + `Comment about exported method`, // No comment about exported method. + `unexportedMethod`, // No unexported method. + `unexportedTypedConstant`, // No unexported constant. + `error`, // No embedded error. + }, + }, + // Type with -src. Will see unexported fields. + { + "type", + []string{"-src", p, `ExportedType`}, + []string{ + `Comment about exported type`, // Include comment. + `type ExportedType struct`, // Type definition. + `Comment before exported field`, + `ExportedField.*Comment on line with exported field`, + `ExportedEmbeddedType.*Comment on line with exported embedded field`, + `unexportedType.*Comment on line with unexported embedded field`, + `func \(ExportedType\) ExportedMethod\(a int\) bool`, + `const ExportedTypedConstant ExportedType = iota`, // Must include associated constant. + `func ExportedTypeConstructor\(\) \*ExportedType`, // Must include constructor. + `io.Reader.*Comment on line with embedded Reader`, + }, + []string{ + `Comment about exported method`, // No comment about exported method. + `unexportedMethod`, // No unexported method. + `unexportedTypedConstant`, // No unexported constant. + }, + }, + // Type -all. + { + "type", + []string{"-all", p, `ExportedType`}, + []string{ + `type ExportedType struct {`, // Type definition as source. + `Comment about exported type`, // Include comment afterwards. + `const ConstGroup4 ExportedType = ExportedType\{\}`, // Related constants. + `ExportedTypedConstant ExportedType = iota`, + `Constants tied to ExportedType`, + `func ExportedTypeConstructor\(\) \*ExportedType`, + `Comment about constructor for exported type.`, + `func ReturnExported\(\) ExportedType`, + `func \(ExportedType\) ExportedMethod\(a int\) bool`, + `Comment about exported method.`, + `func \(ExportedType\) Uncommented\(a int\) bool\n\n`, // Ensure line gap after method with no comment + }, + []string{ + `unexportedType`, + }, + }, + // Type T1 dump (alias). + { + "type T1", + []string{p + ".T1"}, + []string{ + `type T1 = T2`, + }, + []string{ + `type T1 T2`, + `type ExportedType`, + }, + }, + // Type -u with unexported fields. + { + "type with unexported fields and -u", + []string{"-u", p, `ExportedType`}, + []string{ + `Comment about exported type`, // Include comment. + `type ExportedType struct`, // Type definition. + `Comment before exported field.*\n.*ExportedField +int`, + `unexportedField.*int.*Comment on line with unexported field`, + `ExportedEmbeddedType.*Comment on line with exported embedded field`, + `\*ExportedEmbeddedType.*Comment on line with exported embedded \*field`, + `\*qualified.ExportedEmbeddedType.*Comment on line with exported embedded \*selector.field`, + `unexportedType.*Comment on line with unexported embedded field`, + `\*unexportedType.*Comment on line with unexported embedded \*field`, + `io.Reader.*Comment on line with embedded Reader`, + `error.*Comment on line with embedded error`, + `func \(ExportedType\) unexportedMethod\(a int\) bool`, + `unexportedTypedConstant`, + }, + []string{ + `Has unexported fields`, + }, + }, + // Unexported type with -u. + { + "unexported type with -u", + []string{"-u", p, `unexportedType`}, + []string{ + `Comment about unexported type`, // Include comment. + `type unexportedType int`, // Type definition. + `func \(unexportedType\) ExportedMethod\(\) bool`, + `func \(unexportedType\) unexportedMethod\(\) bool`, + `ExportedTypedConstant_unexported unexportedType = iota`, + `const unexportedTypedConstant unexportedType = 1`, + }, + nil, + }, + + // Interface. + { + "interface type", + []string{p, `ExportedInterface`}, + []string{ + `Comment about exported interface`, // Include comment. + `type ExportedInterface interface`, // Interface definition. + `Comment before exported method.\n.*//\n.*// // Code block showing how to use ExportedMethod\n.*// func DoSomething\(\) error {\n.*// ExportedMethod\(\)\n.*// return nil\n.*// }\n.*//.*\n.*ExportedMethod\(\)` + + `.*Comment on line with exported method`, + `io.Reader.*Comment on line with embedded Reader`, + `error.*Comment on line with embedded error`, + `Has unexported methods`, + }, + []string{ + `unexportedField`, // No unexported field. + `Comment about exported method`, // No comment about exported method. + `unexportedMethod`, // No unexported method. + `unexportedTypedConstant`, // No unexported constant. + }, + }, + // Interface -u with unexported methods. + { + "interface type with unexported methods and -u", + []string{"-u", p, `ExportedInterface`}, + []string{ + `Comment about exported interface`, // Include comment. + `type ExportedInterface interface`, // Interface definition. + `Comment before exported method.\n.*//\n.*// // Code block showing how to use ExportedMethod\n.*// func DoSomething\(\) error {\n.*// ExportedMethod\(\)\n.*// return nil\n.*// }\n.*//.*\n.*ExportedMethod\(\)` + `.*Comment on line with exported method`, + `unexportedMethod\(\).*Comment on line with unexported method`, + `io.Reader.*Comment on line with embedded Reader`, + `error.*Comment on line with embedded error`, + }, + []string{ + `Has unexported methods`, + }, + }, + // Interface with comparable constraint. + { + "interface type with comparable", + []string{p, `ExportedComparableInterface`}, + []string{ + `Comment about exported interface with comparable`, // Include comment. + `type ExportedComparableInterface interface`, // Interface definition. + `comparable.*Comment on line with comparable`, // Comparable should be shown. + `ExportedMethod\(\).*Comment on line with exported method`, + `Has unexported methods`, + }, + []string{ + `unexportedMethod`, // No unexported method. + }, + }, + // Interface with only comparable (no unexported methods). + { + "interface type with comparable only", + []string{p, `ExportedComparableOnlyInterface`}, + []string{ + `ExportedComparableOnlyInterface has only comparable`, // Include comment. + `type ExportedComparableOnlyInterface interface`, // Interface definition. + `comparable.*Comment on line with comparable`, // Comparable should be shown. + `ExportedMethod\(\).*Comment on line with exported method`, + }, + []string{ + `Has unexported methods`, // Should NOT appear - no unexported methods. + }, + }, + + // Interface method. + { + "interface method", + []string{p, `ExportedInterface.ExportedMethod`}, + []string{ + `Comment before exported method.\n.*//\n.*// // Code block showing how to use ExportedMethod\n.*// func DoSomething\(\) error {\n.*// ExportedMethod\(\)\n.*// return nil\n.*// }\n.*//.*\n.*ExportedMethod\(\)` + + `.*Comment on line with exported method`, + }, + []string{ + `Comment about exported interface`, + }, + }, + // Interface method at package level. + { + "interface method at package level", + []string{p, `ExportedMethod`}, + []string{ + `func \(ExportedType\) ExportedMethod\(a int\) bool`, + `Comment about exported method`, + }, + []string{ + `Comment before exported method.*\n.*ExportedMethod\(\)` + + `.*Comment on line with exported method`, + }, + }, + + // Method. + { + "method", + []string{p, `ExportedType.ExportedMethod`}, + []string{ + `func \(ExportedType\) ExportedMethod\(a int\) bool`, + `Comment about exported method`, + }, + nil, + }, + // Method with -u. + { + "method with -u", + []string{"-u", p, `ExportedType.unexportedMethod`}, + []string{ + `func \(ExportedType\) unexportedMethod\(a int\) bool`, + `Comment about unexported method`, + }, + nil, + }, + // Method with -src. + { + "method with -src", + []string{"-src", p, `ExportedType.ExportedMethod`}, + []string{ + `func \(ExportedType\) ExportedMethod\(a int\) bool`, + `Comment about exported method`, + `return true != true`, + }, + nil, + }, + + // Field. + { + "field", + []string{p, `ExportedType.ExportedField`}, + []string{ + `type ExportedType struct`, + `ExportedField int`, + `Comment before exported field`, + `Comment on line with exported field`, + `other fields elided`, + }, + nil, + }, + + // Field with -u. + { + "method with -u", + []string{"-u", p, `ExportedType.unexportedField`}, + []string{ + `unexportedField int`, + `Comment on line with unexported field`, + }, + nil, + }, + + // Field of struct with only one field. + { + "single-field struct", + []string{p, `ExportedStructOneField.OnlyField`}, + []string{`the only field`}, + []string{`other fields elided`}, + }, + + // Case matching off. + { + "case matching off", + []string{p, `casematch`}, + []string{ + `CaseMatch`, + `Casematch`, + }, + nil, + }, + + // Case matching on. + { + "case matching on", + []string{"-c", p, `Casematch`}, + []string{ + `Casematch`, + }, + []string{ + `CaseMatch`, + }, + }, + + // Merging comments with -src. + { + "merge comments with -src A", + []string{"-src", p + "/merge", `A`}, + []string{ + `A doc`, + `func A`, + `A comment`, + }, + []string{ + `Package A doc`, + `Package B doc`, + `B doc`, + `B comment`, + `B doc`, + }, + }, + { + "merge comments with -src B", + []string{"-src", p + "/merge", `B`}, + []string{ + `B doc`, + `func B`, + `B comment`, + }, + []string{ + `Package A doc`, + `Package B doc`, + `A doc`, + `A comment`, + `A doc`, + }, + }, + + // No dups with -u. Issue 21797. + { + "case matching on, no dups", + []string{"-u", p, `duplicate`}, + []string{ + `Duplicate`, + `duplicate`, + }, + []string{ + "\\)\n+const", // This will appear if the const decl appears twice. + }, + }, + { + "non-imported: pkg.sym", + []string{"nested.Foo"}, + []string{"Foo struct"}, + nil, + }, + { + "non-imported: pkg only", + []string{"nested"}, + []string{"Foo struct"}, + nil, + }, + { + "non-imported: pkg sym", + []string{"nested", "Foo"}, + []string{"Foo struct"}, + nil, + }, + { + "formatted doc on function", + []string{p, "ExportedFormattedDoc"}, + []string{ + `func ExportedFormattedDoc\(a int\) bool`, + ` Comment about exported function with formatting\. + + Example + + fmt\.Println\(FormattedDoc\(\)\) + + Text after pre-formatted block\.`, + }, + nil, + }, + { + "formatted doc on type field", + []string{p, "ExportedFormattedType.ExportedField"}, + []string{ + `type ExportedFormattedType struct`, + ` // Comment before exported field with formatting\. + //[ ] + // Example + //[ ] + // a\.ExportedField = 123 + //[ ] + // Text after pre-formatted block\.`, + `ExportedField int`, + }, + []string{"ignore:directive"}, + }, + { + "formatted doc on entire type", + []string{p, "ExportedFormattedType"}, + []string{ + `type ExportedFormattedType struct`, + ` // Comment before exported field with formatting\. + // + // Example + // + // a\.ExportedField = 123 + // + // Text after pre-formatted block\.`, + `ExportedField int`, + }, + []string{"ignore:directive"}, + }, + { + "formatted doc on entire type with -all", + []string{"-all", p, "ExportedFormattedType"}, + []string{ + `type ExportedFormattedType struct`, + ` // Comment before exported field with formatting\. + // + // Example + // + // a\.ExportedField = 123 + // + // Text after pre-formatted block\.`, + `ExportedField int`, + }, + []string{"ignore:directive"}, + }, +} + +func TestDoc(t *testing.T) { + maybeSkip(t) + defer log.SetOutput(log.Writer()) + for _, test := range tests { + var b bytes.Buffer + var flagSet flag.FlagSet + var logbuf bytes.Buffer + log.SetOutput(&logbuf) + err := do(&b, &flagSet, test.args) + if err != nil { + t.Fatalf("%s %v: %s\n", test.name, test.args, err) + } + if logbuf.Len() > 0 { + t.Errorf("%s %v: unexpected log messages:\n%s", test.name, test.args, logbuf.Bytes()) + } + output := b.Bytes() + failed := false + for j, yes := range test.yes { + re, err := regexp.Compile(yes) + if err != nil { + t.Fatalf("%s.%d: compiling %#q: %s", test.name, j, yes, err) + } + if !re.Match(output) { + t.Errorf("%s.%d: no match for %s %#q", test.name, j, test.args, yes) + failed = true + } + } + for j, no := range test.no { + re, err := regexp.Compile(no) + if err != nil { + t.Fatalf("%s.%d: compiling %#q: %s", test.name, j, no, err) + } + if re.Match(output) { + t.Errorf("%s.%d: incorrect match for %s %#q", test.name, j, test.args, no) + failed = true + } + } + if bytes.Count(output, []byte("TYPES\n")) > 1 { + t.Fatalf("%s: repeating headers", test.name) + } + if failed { + t.Logf("\n%s", output) + } + } +} + +// Test the code to try multiple packages. Our test case is +// +// go doc rand.Float64 +// +// This needs to find math/rand.Float64; however crypto/rand, which doesn't +// have the symbol, usually appears first in the directory listing. +func TestMultiplePackages(t *testing.T) { + if testing.Short() { + t.Skip("scanning file system takes too long") + } + maybeSkip(t) + var b bytes.Buffer // We don't care about the output. + // Make sure crypto/rand does not have the symbol. + { + var flagSet flag.FlagSet + err := do(&b, &flagSet, []string{"crypto/rand.float64"}) + if err == nil { + t.Errorf("expected error from crypto/rand.float64") + } else if !strings.Contains(err.Error(), "no symbol float64") { + t.Errorf("unexpected error %q from crypto/rand.float64", err) + } + } + // Make sure math/rand does have the symbol. + { + var flagSet flag.FlagSet + err := do(&b, &flagSet, []string{"math/rand.float64"}) + if err != nil { + t.Errorf("unexpected error %q from math/rand.float64", err) + } + } + // Try the shorthand. + { + var flagSet flag.FlagSet + err := do(&b, &flagSet, []string{"rand.float64"}) + if err != nil { + t.Errorf("unexpected error %q from rand.float64", err) + } + } + // Now try a missing symbol. We should see both packages in the error. + { + var flagSet flag.FlagSet + err := do(&b, &flagSet, []string{"rand.doesnotexit"}) + if err == nil { + t.Errorf("expected error from rand.doesnotexit") + } else { + errStr := err.Error() + if !strings.Contains(errStr, "no symbol") { + t.Errorf("error %q should contain 'no symbol", errStr) + } + if !strings.Contains(errStr, "crypto/rand") { + t.Errorf("error %q should contain crypto/rand", errStr) + } + if !strings.Contains(errStr, "math/rand") { + t.Errorf("error %q should contain math/rand", errStr) + } + } + } +} + +// Test the code to look up packages when given two args. First test case is +// +// go doc binary BigEndian +// +// This needs to find encoding/binary.BigEndian, which means +// finding the package encoding/binary given only "binary". +// Second case is +// +// go doc rand Float64 +// +// which again needs to find math/rand and not give up after crypto/rand, +// which has no such function. +func TestTwoArgLookup(t *testing.T) { + if testing.Short() { + t.Skip("scanning file system takes too long") + } + maybeSkip(t) + var b bytes.Buffer // We don't care about the output. + { + var flagSet flag.FlagSet + err := do(&b, &flagSet, []string{"binary", "BigEndian"}) + if err != nil { + t.Errorf("unexpected error %q from binary BigEndian", err) + } + } + { + var flagSet flag.FlagSet + err := do(&b, &flagSet, []string{"rand", "Float64"}) + if err != nil { + t.Errorf("unexpected error %q from rand Float64", err) + } + } + { + var flagSet flag.FlagSet + err := do(&b, &flagSet, []string{"bytes", "Foo"}) + if err == nil { + t.Errorf("expected error from bytes Foo") + } else if !strings.Contains(err.Error(), "no symbol Foo") { + t.Errorf("unexpected error %q from bytes Foo", err) + } + } + { + var flagSet flag.FlagSet + err := do(&b, &flagSet, []string{"nosuchpackage", "Foo"}) + if err == nil { + // actually present in the user's filesystem + } else if !strings.Contains(err.Error(), "no such package") { + t.Errorf("unexpected error %q from nosuchpackage Foo", err) + } + } +} + +// Test the code to look up packages when the first argument starts with "./". +// Our test case is in effect "cd src/text; doc ./template". This should get +// text/template but before Issue 23383 was fixed would give html/template. +func TestDotSlashLookup(t *testing.T) { + if testing.Short() { + t.Skip("scanning file system takes too long") + } + maybeSkip(t) + t.Chdir(filepath.Join(buildCtx.GOROOT, "src", "text")) + + var b strings.Builder + var flagSet flag.FlagSet + err := do(&b, &flagSet, []string{"./template"}) + if err != nil { + t.Errorf("unexpected error %q from ./template", err) + } + // The output should contain information about the text/template package. + const want = `package template // import "text/template"` + output := b.String() + if !strings.HasPrefix(output, want) { + t.Fatalf("wrong package: %.*q...", len(want), output) + } +} + +// Test that we don't print spurious package clauses +// when there should be no output at all. Issue 37969. +func TestNoPackageClauseWhenNoMatch(t *testing.T) { + maybeSkip(t) + var b strings.Builder + var flagSet flag.FlagSet + err := do(&b, &flagSet, []string{"template.ZZZ"}) + // Expect an error. + if err == nil { + t.Error("expect an error for template.zzz") + } + // And the output should not contain any package clauses. + const dontWant = `package template // import ` + output := b.String() + if strings.Contains(output, dontWant) { + t.Fatalf("improper package clause printed:\n%s", output) + } +} + +type trimTest struct { + path string + prefix string + result string + ok bool +} + +var trimTests = []trimTest{ + {"", "", "", true}, + {"/usr/gopher", "/usr/gopher", "/usr/gopher", true}, + {"/usr/gopher/bar", "/usr/gopher", "bar", true}, + {"/usr/gopherflakes", "/usr/gopher", "/usr/gopherflakes", false}, + {"/usr/gopher/bar", "/usr/zot", "/usr/gopher/bar", false}, +} + +func TestTrim(t *testing.T) { + for _, test := range trimTests { + result, ok := trim(test.path, test.prefix) + if ok != test.ok { + t.Errorf("%s %s expected %t got %t", test.path, test.prefix, test.ok, ok) + continue + } + if result != test.result { + t.Errorf("%s %s expected %q got %q", test.path, test.prefix, test.result, result) + continue + } + } +} diff --git a/go/src/cmd/go/internal/doc/pkg.go b/go/src/cmd/go/internal/doc/pkg.go new file mode 100644 index 0000000000000000000000000000000000000000..3c36d0e05cfffcc0c072417def01b82cb66d0564 --- /dev/null +++ b/go/src/cmd/go/internal/doc/pkg.go @@ -0,0 +1,1168 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package doc + +import ( + "bufio" + "bytes" + "fmt" + "go/ast" + "go/build" + "go/doc" + "go/format" + "go/parser" + "go/printer" + "go/token" + "io" + "io/fs" + "log" + "path/filepath" + "strings" + "unicode" + "unicode/utf8" +) + +const ( + punchedCardWidth = 80 + indent = " " +) + +type Package struct { + writer io.Writer // Destination for output. + name string // Package name, json for encoding/json. + userPath string // String the user used to find this package. + pkg *ast.Package // Parsed package. + file *ast.File // Merged from all files in the package + doc *doc.Package + build *build.Package + typedValue map[*doc.Value]bool // Consts and vars related to types. + constructor map[*doc.Func]bool // Constructors. + fs *token.FileSet // Needed for printing. + buf pkgBuffer +} + +func (pkg *Package) ToText(w io.Writer, text, prefix, codePrefix string) { + d := pkg.doc.Parser().Parse(text) + pr := pkg.doc.Printer() + pr.TextPrefix = prefix + pr.TextCodePrefix = codePrefix + w.Write(pr.Text(d)) +} + +// pkgBuffer is a wrapper for bytes.Buffer that prints a package clause the +// first time Write is called. +type pkgBuffer struct { + pkg *Package + printed bool // Prevent repeated package clauses. + bytes.Buffer +} + +func (pb *pkgBuffer) Write(p []byte) (int, error) { + pb.packageClause() + return pb.Buffer.Write(p) +} + +func (pb *pkgBuffer) packageClause() { + if !pb.printed { + pb.printed = true + // Only show package clause for commands if requested explicitly. + if pb.pkg.pkg.Name != "main" || showCmd { + pb.pkg.packageClause() + } + } +} + +type PackageError string // type returned by pkg.Fatalf. + +func (p PackageError) Error() string { + return string(p) +} + +// prettyPath returns a version of the package path that is suitable for an +// error message. It obeys the import comment if present. Also, since +// pkg.build.ImportPath is sometimes the unhelpful "" or ".", it looks for a +// directory name in GOROOT or GOPATH if that happens. +func (pkg *Package) prettyPath() string { + path := pkg.build.ImportComment + if path == "" { + path = pkg.build.ImportPath + } + if path != "." && path != "" { + return path + } + // Convert the source directory into a more useful path. + // Also convert everything to slash-separated paths for uniform handling. + path = filepath.Clean(filepath.ToSlash(pkg.build.Dir)) + // Can we find a decent prefix? + if buildCtx.GOROOT != "" { + goroot := filepath.Join(buildCtx.GOROOT, "src") + if p, ok := trim(path, filepath.ToSlash(goroot)); ok { + return p + } + } + for _, gopath := range splitGopath() { + if p, ok := trim(path, filepath.ToSlash(gopath)); ok { + return p + } + } + return path +} + +// trim trims the directory prefix from the path, paying attention +// to the path separator. If they are the same string or the prefix +// is not present the original is returned. The boolean reports whether +// the prefix is present. That path and prefix have slashes for separators. +func trim(path, prefix string) (string, bool) { + if !strings.HasPrefix(path, prefix) { + return path, false + } + if path == prefix { + return path, true + } + if path[len(prefix)] == '/' { + return path[len(prefix)+1:], true + } + return path, false // Textual prefix but not a path prefix. +} + +// pkg.Fatalf is like log.Fatalf, but panics so it can be recovered in the +// main do function, so it doesn't cause an exit. Allows testing to work +// without running a subprocess. The log prefix will be added when +// logged in main; it is not added here. +func (pkg *Package) Fatalf(format string, args ...any) { + panic(PackageError(fmt.Sprintf(format, args...))) +} + +// parsePackage turns the build package we found into a parsed package +// we can then use to generate documentation. +func parsePackage(writer io.Writer, pkg *build.Package, userPath string) *Package { + // include tells parser.ParseDir which files to include. + // That means the file must be in the build package's GoFiles or CgoFiles + // list only (no tag-ignored files, tests, swig or other non-Go files). + include := func(info fs.FileInfo) bool { + for _, name := range pkg.GoFiles { + if name == info.Name() { + return true + } + } + for _, name := range pkg.CgoFiles { + if name == info.Name() { + return true + } + } + return false + } + fset := token.NewFileSet() + pkgs, err := parser.ParseDir(fset, pkg.Dir, include, parser.ParseComments) + if err != nil { + log.Fatal(err) + } + // Make sure they are all in one package. + if len(pkgs) == 0 { + log.Fatalf("no source-code package in directory %s", pkg.Dir) + } + if len(pkgs) > 1 { + log.Fatalf("multiple packages in directory %s", pkg.Dir) + } + astPkg := pkgs[pkg.Name] + + // TODO: go/doc does not include typed constants in the constants + // list, which is what we want. For instance, time.Sunday is of type + // time.Weekday, so it is defined in the type but not in the + // Consts list for the package. This prevents + // go doc time.Sunday + // from finding the symbol. Work around this for now, but we + // should fix it in go/doc. + // A similar story applies to factory functions. + mode := doc.AllDecls + if showSrc { + mode |= doc.PreserveAST // See comment for Package.emit. + } + docPkg := doc.New(astPkg, pkg.ImportPath, mode) + typedValue := make(map[*doc.Value]bool) + constructor := make(map[*doc.Func]bool) + for _, typ := range docPkg.Types { + docPkg.Consts = append(docPkg.Consts, typ.Consts...) + docPkg.Vars = append(docPkg.Vars, typ.Vars...) + docPkg.Funcs = append(docPkg.Funcs, typ.Funcs...) + if isExported(typ.Name) { + for _, value := range typ.Consts { + typedValue[value] = true + } + for _, value := range typ.Vars { + typedValue[value] = true + } + for _, fun := range typ.Funcs { + // We don't count it as a constructor bound to the type + // if the type itself is not exported. + constructor[fun] = true + } + } + } + + p := &Package{ + writer: writer, + name: pkg.Name, + userPath: userPath, + pkg: astPkg, + file: ast.MergePackageFiles(astPkg, 0), + doc: docPkg, + typedValue: typedValue, + constructor: constructor, + build: pkg, + fs: fset, + } + p.buf.pkg = p + return p +} + +func (pkg *Package) Printf(format string, args ...any) { + fmt.Fprintf(&pkg.buf, format, args...) +} + +func (pkg *Package) flush() { + _, err := pkg.writer.Write(pkg.buf.Bytes()) + if err != nil { + log.Fatal(err) + } + pkg.buf.Reset() // Not needed, but it's a flush. +} + +var newlineBytes = []byte("\n\n") // We never ask for more than 2. + +// newlines guarantees there are n newlines at the end of the buffer. +func (pkg *Package) newlines(n int) { + for !bytes.HasSuffix(pkg.buf.Bytes(), newlineBytes[:n]) { + pkg.buf.WriteRune('\n') + } +} + +// emit prints the node. If showSrc is true, it ignores the provided comment, +// assuming the comment is in the node itself. Otherwise, the go/doc package +// clears the stuff we don't want to print anyway. It's a bit of a magic trick. +func (pkg *Package) emit(comment string, node ast.Node) { + if node != nil { + var arg any = node + if showSrc { + // Need an extra little dance to get internal comments to appear. + arg = &printer.CommentedNode{ + Node: node, + Comments: pkg.file.Comments, + } + } + err := format.Node(&pkg.buf, pkg.fs, arg) + if err != nil { + log.Fatal(err) + } + if comment != "" && !showSrc { + pkg.newlines(1) + pkg.ToText(&pkg.buf, comment, indent, indent+indent) + pkg.newlines(2) // Blank line after comment to separate from next item. + } else { + pkg.newlines(1) + } + } +} + +// oneLineNode returns a one-line summary of the given input node. +func (pkg *Package) oneLineNode(node ast.Node) string { + const maxDepth = 10 + return pkg.oneLineNodeDepth(node, maxDepth) +} + +// oneLineNodeDepth returns a one-line summary of the given input node. +// The depth specifies the maximum depth when traversing the AST. +func (pkg *Package) oneLineNodeDepth(node ast.Node, depth int) string { + const dotDotDot = "..." + if depth == 0 { + return dotDotDot + } + depth-- + + switch n := node.(type) { + case nil: + return "" + + case *ast.GenDecl: + // Formats const and var declarations. + trailer := "" + if len(n.Specs) > 1 { + trailer = " " + dotDotDot + } + + // Find the first relevant spec. + typ := "" + for i, spec := range n.Specs { + valueSpec := spec.(*ast.ValueSpec) // Must succeed; we can't mix types in one GenDecl. + + // The type name may carry over from a previous specification in the + // case of constants and iota. + if valueSpec.Type != nil { + typ = fmt.Sprintf(" %s", pkg.oneLineNodeDepth(valueSpec.Type, depth)) + } else if len(valueSpec.Values) > 0 { + typ = "" + } + + if !isExported(valueSpec.Names[0].Name) { + continue + } + val := "" + if i < len(valueSpec.Values) && valueSpec.Values[i] != nil { + val = fmt.Sprintf(" = %s", pkg.oneLineNodeDepth(valueSpec.Values[i], depth)) + } + return fmt.Sprintf("%s %s%s%s%s", n.Tok, valueSpec.Names[0], typ, val, trailer) + } + return "" + + case *ast.FuncDecl: + // Formats func declarations. + name := n.Name.Name + recv := pkg.oneLineNodeDepth(n.Recv, depth) + if len(recv) > 0 { + recv = "(" + recv + ") " + } + fnc := pkg.oneLineNodeDepth(n.Type, depth) + fnc = strings.TrimPrefix(fnc, "func") + return fmt.Sprintf("func %s%s%s", recv, name, fnc) + + case *ast.TypeSpec: + sep := " " + if n.Assign.IsValid() { + sep = " = " + } + tparams := pkg.formatTypeParams(n.TypeParams, depth) + return fmt.Sprintf("type %s%s%s%s", n.Name.Name, tparams, sep, pkg.oneLineNodeDepth(n.Type, depth)) + + case *ast.FuncType: + var params []string + if n.Params != nil { + for _, field := range n.Params.List { + params = append(params, pkg.oneLineField(field, depth)) + } + } + needParens := false + var results []string + if n.Results != nil { + needParens = needParens || len(n.Results.List) > 1 + for _, field := range n.Results.List { + needParens = needParens || len(field.Names) > 0 + results = append(results, pkg.oneLineField(field, depth)) + } + } + + tparam := pkg.formatTypeParams(n.TypeParams, depth) + param := joinStrings(params) + if len(results) == 0 { + return fmt.Sprintf("func%s(%s)", tparam, param) + } + result := joinStrings(results) + if !needParens { + return fmt.Sprintf("func%s(%s) %s", tparam, param, result) + } + return fmt.Sprintf("func%s(%s) (%s)", tparam, param, result) + + case *ast.StructType: + if n.Fields == nil || len(n.Fields.List) == 0 { + return "struct{}" + } + return "struct{ ... }" + + case *ast.InterfaceType: + if n.Methods == nil || len(n.Methods.List) == 0 { + return "interface{}" + } + return "interface{ ... }" + + case *ast.FieldList: + if n == nil || len(n.List) == 0 { + return "" + } + if len(n.List) == 1 { + return pkg.oneLineField(n.List[0], depth) + } + return dotDotDot + + case *ast.FuncLit: + return pkg.oneLineNodeDepth(n.Type, depth) + " { ... }" + + case *ast.CompositeLit: + typ := pkg.oneLineNodeDepth(n.Type, depth) + if len(n.Elts) == 0 { + return fmt.Sprintf("%s{}", typ) + } + return fmt.Sprintf("%s{ %s }", typ, dotDotDot) + + case *ast.ArrayType: + length := pkg.oneLineNodeDepth(n.Len, depth) + element := pkg.oneLineNodeDepth(n.Elt, depth) + return fmt.Sprintf("[%s]%s", length, element) + + case *ast.MapType: + key := pkg.oneLineNodeDepth(n.Key, depth) + value := pkg.oneLineNodeDepth(n.Value, depth) + return fmt.Sprintf("map[%s]%s", key, value) + + case *ast.CallExpr: + fnc := pkg.oneLineNodeDepth(n.Fun, depth) + var args []string + for _, arg := range n.Args { + args = append(args, pkg.oneLineNodeDepth(arg, depth)) + } + return fmt.Sprintf("%s(%s)", fnc, joinStrings(args)) + + case *ast.UnaryExpr: + return fmt.Sprintf("%s%s", n.Op, pkg.oneLineNodeDepth(n.X, depth)) + + case *ast.Ident: + return n.Name + + default: + // As a fallback, use default formatter for all unknown node types. + buf := new(strings.Builder) + format.Node(buf, pkg.fs, node) + s := buf.String() + if strings.Contains(s, "\n") { + return dotDotDot + } + return s + } +} + +func (pkg *Package) formatTypeParams(list *ast.FieldList, depth int) string { + if list.NumFields() == 0 { + return "" + } + var tparams []string + for _, field := range list.List { + tparams = append(tparams, pkg.oneLineField(field, depth)) + } + return "[" + joinStrings(tparams) + "]" +} + +// oneLineField returns a one-line summary of the field. +func (pkg *Package) oneLineField(field *ast.Field, depth int) string { + var names []string + for _, name := range field.Names { + names = append(names, name.Name) + } + if len(names) == 0 { + return pkg.oneLineNodeDepth(field.Type, depth) + } + return joinStrings(names) + " " + pkg.oneLineNodeDepth(field.Type, depth) +} + +// joinStrings formats the input as a comma-separated list, +// but truncates the list at some reasonable length if necessary. +func joinStrings(ss []string) string { + var n int + for i, s := range ss { + n += len(s) + len(", ") + if n > punchedCardWidth { + ss = append(ss[:i:i], "...") + break + } + } + return strings.Join(ss, ", ") +} + +// printHeader prints a header for the section named s, adding a blank line on each side. +func (pkg *Package) printHeader(s string) { + pkg.Printf("\n%s\n\n", s) +} + +// constsDoc prints all const documentation, if any, including a header. +// The one argument is the valueDoc registry. +func (pkg *Package) constsDoc(printed map[*ast.GenDecl]bool) { + var header bool + for _, value := range pkg.doc.Consts { + // Constants and variables come in groups, and valueDoc prints + // all the items in the group. We only need to find one exported symbol. + for _, name := range value.Names { + if isExported(name) && !pkg.typedValue[value] { + if !header { + pkg.printHeader("CONSTANTS") + header = true + } + pkg.valueDoc(value, printed) + break + } + } + } +} + +// varsDoc prints all var documentation, if any, including a header. +// Printed is the valueDoc registry. +func (pkg *Package) varsDoc(printed map[*ast.GenDecl]bool) { + var header bool + for _, value := range pkg.doc.Vars { + // Constants and variables come in groups, and valueDoc prints + // all the items in the group. We only need to find one exported symbol. + for _, name := range value.Names { + if isExported(name) && !pkg.typedValue[value] { + if !header { + pkg.printHeader("VARIABLES") + header = true + } + pkg.valueDoc(value, printed) + break + } + } + } +} + +// funcsDoc prints all func documentation, if any, including a header. +func (pkg *Package) funcsDoc() { + var header bool + for _, fun := range pkg.doc.Funcs { + if isExported(fun.Name) && !pkg.constructor[fun] { + if !header { + pkg.printHeader("FUNCTIONS") + header = true + } + pkg.emit(fun.Doc, fun.Decl) + } + } +} + +// typesDoc prints all type documentation, if any, including a header. +func (pkg *Package) typesDoc() { + var header bool + for _, typ := range pkg.doc.Types { + if isExported(typ.Name) { + if !header { + pkg.printHeader("TYPES") + header = true + } + pkg.typeDoc(typ) + } + } +} + +// packageDoc prints the docs for the package. +func (pkg *Package) packageDoc() { + pkg.Printf("") // Trigger the package clause; we know the package exists. + if showAll || !short { + pkg.ToText(&pkg.buf, pkg.doc.Doc, "", indent) + pkg.newlines(1) + } + + switch { + case showAll: + printed := make(map[*ast.GenDecl]bool) // valueDoc registry + pkg.constsDoc(printed) + pkg.varsDoc(printed) + pkg.funcsDoc() + pkg.typesDoc() + + case pkg.pkg.Name == "main" && !showCmd: + // Show only package docs for commands. + return + + default: + if !short { + pkg.newlines(2) // Guarantee blank line before the components. + } + pkg.valueSummary(pkg.doc.Consts, false) + pkg.valueSummary(pkg.doc.Vars, false) + pkg.funcSummary(pkg.doc.Funcs, false) + pkg.typeSummary() + } + + if !short { + pkg.bugs() + } +} + +// packageClause prints the package clause. +func (pkg *Package) packageClause() { + if short { + return + } + importPath := pkg.build.ImportComment + if importPath == "" { + importPath = pkg.build.ImportPath + } + + // If we're using modules, the import path derived from module code locations wins. + // If we did a file system scan, we knew the import path when we found the directory. + // But if we started with a directory name, we never knew the import path. + // Either way, we don't know it now, and it's cheap to (re)compute it. + if usingModules { + for _, root := range codeRoots() { + if pkg.build.Dir == root.dir { + importPath = root.importPath + break + } + if strings.HasPrefix(pkg.build.Dir, root.dir+string(filepath.Separator)) { + suffix := filepath.ToSlash(pkg.build.Dir[len(root.dir)+1:]) + if root.importPath == "" { + importPath = suffix + } else { + importPath = root.importPath + "/" + suffix + } + break + } + } + } + + pkg.Printf("package %s // import %q\n\n", pkg.name, importPath) + if !usingModules && importPath != pkg.build.ImportPath { + pkg.Printf("WARNING: package source is installed in %q\n", pkg.build.ImportPath) + } +} + +// valueSummary prints a one-line summary for each set of values and constants. +// If all the types in a constant or variable declaration belong to the same +// type they can be printed by typeSummary, and so can be suppressed here. +func (pkg *Package) valueSummary(values []*doc.Value, showGrouped bool) { + var isGrouped map[*doc.Value]bool + if !showGrouped { + isGrouped = make(map[*doc.Value]bool) + for _, typ := range pkg.doc.Types { + if !isExported(typ.Name) { + continue + } + for _, c := range typ.Consts { + isGrouped[c] = true + } + for _, v := range typ.Vars { + isGrouped[v] = true + } + } + } + + for _, value := range values { + if !isGrouped[value] { + if decl := pkg.oneLineNode(value.Decl); decl != "" { + pkg.Printf("%s\n", decl) + } + } + } +} + +// funcSummary prints a one-line summary for each function. Constructors +// are printed by typeSummary, below, and so can be suppressed here. +func (pkg *Package) funcSummary(funcs []*doc.Func, showConstructors bool) { + for _, fun := range funcs { + // Exported functions only. The go/doc package does not include methods here. + if isExported(fun.Name) { + if showConstructors || !pkg.constructor[fun] { + pkg.Printf("%s\n", pkg.oneLineNode(fun.Decl)) + } + } + } +} + +// typeSummary prints a one-line summary for each type, followed by its constructors. +func (pkg *Package) typeSummary() { + for _, typ := range pkg.doc.Types { + for _, spec := range typ.Decl.Specs { + typeSpec := spec.(*ast.TypeSpec) // Must succeed. + if isExported(typeSpec.Name.Name) { + pkg.Printf("%s\n", pkg.oneLineNode(typeSpec)) + // Now print the consts, vars, and constructors. + for _, c := range typ.Consts { + if decl := pkg.oneLineNode(c.Decl); decl != "" { + pkg.Printf(indent+"%s\n", decl) + } + } + for _, v := range typ.Vars { + if decl := pkg.oneLineNode(v.Decl); decl != "" { + pkg.Printf(indent+"%s\n", decl) + } + } + for _, constructor := range typ.Funcs { + if isExported(constructor.Name) { + pkg.Printf(indent+"%s\n", pkg.oneLineNode(constructor.Decl)) + } + } + } + } + } +} + +// bugs prints the BUGS information for the package. +// TODO: Provide access to TODOs and NOTEs as well (very noisy so off by default)? +func (pkg *Package) bugs() { + if pkg.doc.Notes["BUG"] == nil { + return + } + pkg.Printf("\n") + for _, note := range pkg.doc.Notes["BUG"] { + pkg.Printf("%s: %v\n", "BUG", note.Body) + } +} + +// findValues finds the doc.Values that describe the symbol. +func (pkg *Package) findValues(symbol string, docValues []*doc.Value) (values []*doc.Value) { + for _, value := range docValues { + for _, name := range value.Names { + if match(symbol, name) { + values = append(values, value) + } + } + } + return +} + +// findFuncs finds the doc.Funcs that describes the symbol. +func (pkg *Package) findFuncs(symbol string) (funcs []*doc.Func) { + for _, fun := range pkg.doc.Funcs { + if match(symbol, fun.Name) { + funcs = append(funcs, fun) + } + } + return +} + +// findTypes finds the doc.Types that describes the symbol. +// If symbol is empty, it finds all exported types. +func (pkg *Package) findTypes(symbol string) (types []*doc.Type) { + for _, typ := range pkg.doc.Types { + if symbol == "" && isExported(typ.Name) || match(symbol, typ.Name) { + types = append(types, typ) + } + } + return +} + +// findTypeSpec returns the ast.TypeSpec within the declaration that defines the symbol. +// The name must match exactly. +func (pkg *Package) findTypeSpec(decl *ast.GenDecl, symbol string) *ast.TypeSpec { + for _, spec := range decl.Specs { + typeSpec := spec.(*ast.TypeSpec) // Must succeed. + if symbol == typeSpec.Name.Name { + return typeSpec + } + } + return nil +} + +// symbolDoc prints the docs for symbol. There may be multiple matches. +// If symbol matches a type, output includes its methods factories and associated constants. +// If there is no top-level symbol, symbolDoc looks for methods that match. +func (pkg *Package) symbolDoc(symbol string) bool { + found := false + // Functions. + for _, fun := range pkg.findFuncs(symbol) { + // Symbol is a function. + decl := fun.Decl + pkg.emit(fun.Doc, decl) + found = true + } + // Constants and variables behave the same. + values := pkg.findValues(symbol, pkg.doc.Consts) + values = append(values, pkg.findValues(symbol, pkg.doc.Vars)...) + printed := make(map[*ast.GenDecl]bool) // valueDoc registry + for _, value := range values { + pkg.valueDoc(value, printed) + found = true + } + // Types. + for _, typ := range pkg.findTypes(symbol) { + pkg.typeDoc(typ) + found = true + } + if !found { + // See if there are methods. + if !pkg.printMethodDoc("", symbol) { + return false + } + } + return true +} + +// valueDoc prints the docs for a constant or variable. The printed map records +// which values have been printed already to avoid duplication. Otherwise, a +// declaration like: +// +// const ( c = 1; C = 2 ) +// +// … could be printed twice if the -u flag is set, as it matches twice. +func (pkg *Package) valueDoc(value *doc.Value, printed map[*ast.GenDecl]bool) { + if printed[value.Decl] { + return + } + // Print each spec only if there is at least one exported symbol in it. + // (See issue 11008.) + // TODO: Should we elide unexported symbols from a single spec? + // It's an unlikely scenario, probably not worth the trouble. + // TODO: Would be nice if go/doc did this for us. + specs := make([]ast.Spec, 0, len(value.Decl.Specs)) + var typ ast.Expr + for _, spec := range value.Decl.Specs { + vspec := spec.(*ast.ValueSpec) + + // The type name may carry over from a previous specification in the + // case of constants and iota. + if vspec.Type != nil { + typ = vspec.Type + } + + for _, ident := range vspec.Names { + if showSrc || isExported(ident.Name) { + if vspec.Type == nil && vspec.Values == nil && typ != nil { + // This a standalone identifier, as in the case of iota usage. + // Thus, assume the type comes from the previous type. + vspec.Type = &ast.Ident{ + Name: pkg.oneLineNode(typ), + NamePos: vspec.End() - 1, + } + } + + specs = append(specs, vspec) + typ = nil // Only inject type on first exported identifier + break + } + } + } + if len(specs) == 0 { + return + } + value.Decl.Specs = specs + pkg.emit(value.Doc, value.Decl) + printed[value.Decl] = true +} + +// typeDoc prints the docs for a type, including constructors and other items +// related to it. +func (pkg *Package) typeDoc(typ *doc.Type) { + decl := typ.Decl + spec := pkg.findTypeSpec(decl, typ.Name) + trimUnexportedElems(spec) + // If there are multiple types defined, reduce to just this one. + if len(decl.Specs) > 1 { + decl.Specs = []ast.Spec{spec} + } + pkg.emit(typ.Doc, decl) + pkg.newlines(2) + // Show associated methods, constants, etc. + if showAll { + printed := make(map[*ast.GenDecl]bool) // valueDoc registry + // We can use append here to print consts, then vars. Ditto for funcs and methods. + values := typ.Consts + values = append(values, typ.Vars...) + for _, value := range values { + for _, name := range value.Names { + if isExported(name) { + pkg.valueDoc(value, printed) + break + } + } + } + funcs := typ.Funcs + funcs = append(funcs, typ.Methods...) + for _, fun := range funcs { + if isExported(fun.Name) { + pkg.emit(fun.Doc, fun.Decl) + if fun.Doc == "" { + pkg.newlines(2) + } + } + } + } else { + pkg.valueSummary(typ.Consts, true) + pkg.valueSummary(typ.Vars, true) + pkg.funcSummary(typ.Funcs, true) + pkg.funcSummary(typ.Methods, true) + } +} + +// trimUnexportedElems modifies spec in place to elide unexported fields from +// structs and methods from interfaces (unless the unexported flag is set or we +// are asked to show the original source). +func trimUnexportedElems(spec *ast.TypeSpec) { + if showSrc { + return + } + switch typ := spec.Type.(type) { + case *ast.StructType: + typ.Fields = trimUnexportedFields(typ.Fields, false) + case *ast.InterfaceType: + typ.Methods = trimUnexportedFields(typ.Methods, true) + } +} + +// trimUnexportedFields returns the field list trimmed of unexported fields. +func trimUnexportedFields(fields *ast.FieldList, isInterface bool) *ast.FieldList { + what := "methods" + if !isInterface { + what = "fields" + } + + trimmed := false + list := make([]*ast.Field, 0, len(fields.List)) + for _, field := range fields.List { + // When printing fields we normally print field.Doc. + // Here we are going to pass the AST to go/format, + // which will print the comments from the AST, + // not field.Doc which is from go/doc. + // The two are similar but not identical; + // for example, field.Doc does not include directives. + // In order to consistently print field.Doc, + // we replace the comment in the AST with field.Doc. + // That will cause go/format to print what we want. + // See issue #56592. + if field.Doc != nil { + doc := field.Doc + text := doc.Text() + + trailingBlankLine := len(doc.List[len(doc.List)-1].Text) == 2 + if !trailingBlankLine { + // Remove trailing newline. + lt := len(text) + if lt > 0 && text[lt-1] == '\n' { + text = text[:lt-1] + } + } + + start := doc.List[0].Slash + doc.List = doc.List[:0] + for line := range strings.SplitSeq(text, "\n") { + prefix := "// " + if len(line) > 0 && line[0] == '\t' { + prefix = "//" + } + doc.List = append(doc.List, &ast.Comment{ + Text: prefix + line, + }) + } + doc.List[0].Slash = start + } + + names := field.Names + if len(names) == 0 { + // Embedded type. Use the name of the type. It must be of the form ident or + // pkg.ident (for structs and interfaces), or *ident or *pkg.ident (structs only). + // Or a type embedded in a constraint. + // Nothing else is allowed. + ty := field.Type + if se, ok := field.Type.(*ast.StarExpr); !isInterface && ok { + // The form *ident or *pkg.ident is only valid on + // embedded types in structs. + ty = se.X + } + constraint := false + switch ident := ty.(type) { + case *ast.Ident: + if isInterface && ident.Obj == nil && + (ident.Name == "error" || ident.Name == "comparable") { + // For documentation purposes, we consider the builtin error + // and comparable types special when embedded in an interface, + // such that they always get shown publicly. + list = append(list, field) + continue + } + names = []*ast.Ident{ident} + case *ast.SelectorExpr: + // An embedded type may refer to a type in another package. + names = []*ast.Ident{ident.Sel} + default: + // An approximation or union or type + // literal in an interface. + constraint = true + } + if names == nil && !constraint { + // Can only happen if AST is incorrect. Safe to continue with a nil list. + log.Print("invalid program: unexpected type for embedded field") + } + } + // Trims if any is unexported. Good enough in practice. + ok := true + if !unexported { + for _, name := range names { + if !isExported(name.Name) { + trimmed = true + ok = false + break + } + } + } + if ok { + list = append(list, field) + } + } + if !trimmed { + return fields + } + unexportedField := &ast.Field{ + Type: &ast.Ident{ + // Hack: printer will treat this as a field with a named type. + // Setting Name and NamePos to ("", fields.Closing-1) ensures that + // when Pos and End are called on this field, they return the + // position right before closing '}' character. + Name: "", + NamePos: fields.Closing - 1, + }, + Comment: &ast.CommentGroup{ + List: []*ast.Comment{{Text: fmt.Sprintf("// Has unexported %s.\n", what)}}, + }, + } + return &ast.FieldList{ + Opening: fields.Opening, + List: append(list, unexportedField), + Closing: fields.Closing, + } +} + +// printMethodDoc prints the docs for matches of symbol.method. +// If symbol is empty, it prints all methods for any concrete type +// that match the name. It reports whether it found any methods. +func (pkg *Package) printMethodDoc(symbol, method string) bool { + types := pkg.findTypes(symbol) + if types == nil { + if symbol == "" { + return false + } + pkg.Fatalf("symbol %s is not a type in package %s installed in %q", symbol, pkg.name, pkg.build.ImportPath) + } + found := false + for _, typ := range types { + if len(typ.Methods) > 0 { + for _, meth := range typ.Methods { + if match(method, meth.Name) { + decl := meth.Decl + pkg.emit(meth.Doc, decl) + found = true + } + } + continue + } + if symbol == "" { + continue + } + // Type may be an interface. The go/doc package does not attach + // an interface's methods to the doc.Type. We need to dig around. + spec := pkg.findTypeSpec(typ.Decl, typ.Name) + inter, ok := spec.Type.(*ast.InterfaceType) + if !ok { + // Not an interface type. + continue + } + + // Collect and print only the methods that match. + var methods []*ast.Field + for _, iMethod := range inter.Methods.List { + // This is an interface, so there can be only one name. + // TODO: Anonymous methods (embedding) + if len(iMethod.Names) == 0 { + continue + } + name := iMethod.Names[0].Name + if match(method, name) { + methods = append(methods, iMethod) + found = true + } + } + if found { + pkg.Printf("type %s ", spec.Name) + inter.Methods.List, methods = methods, inter.Methods.List + err := format.Node(&pkg.buf, pkg.fs, inter) + if err != nil { + log.Fatal(err) + } + pkg.newlines(1) + // Restore the original methods. + inter.Methods.List = methods + } + } + return found +} + +// printFieldDoc prints the docs for matches of symbol.fieldName. +// It reports whether it found any field. +// Both symbol and fieldName must be non-empty or it returns false. +func (pkg *Package) printFieldDoc(symbol, fieldName string) bool { + if symbol == "" || fieldName == "" { + return false + } + types := pkg.findTypes(symbol) + if types == nil { + pkg.Fatalf("symbol %s is not a type in package %s installed in %q", symbol, pkg.name, pkg.build.ImportPath) + } + found := false + numUnmatched := 0 + for _, typ := range types { + // Type must be a struct. + spec := pkg.findTypeSpec(typ.Decl, typ.Name) + structType, ok := spec.Type.(*ast.StructType) + if !ok { + // Not a struct type. + continue + } + for _, field := range structType.Fields.List { + // TODO: Anonymous fields. + for _, name := range field.Names { + if !match(fieldName, name.Name) { + numUnmatched++ + continue + } + if !found { + pkg.Printf("type %s struct {\n", typ.Name) + } + if field.Doc != nil { + // To present indented blocks in comments correctly, process the comment as + // a unit before adding the leading // to each line. + docBuf := new(bytes.Buffer) + pkg.ToText(docBuf, field.Doc.Text(), "", indent) + scanner := bufio.NewScanner(docBuf) + for scanner.Scan() { + fmt.Fprintf(&pkg.buf, "%s// %s\n", indent, scanner.Bytes()) + } + } + s := pkg.oneLineNode(field.Type) + lineComment := "" + if field.Comment != nil { + lineComment = fmt.Sprintf(" %s", field.Comment.List[0].Text) + } + pkg.Printf("%s%s %s%s\n", indent, name, s, lineComment) + found = true + } + } + } + if found { + if numUnmatched > 0 { + pkg.Printf("\n // ... other fields elided ...\n") + } + pkg.Printf("}\n") + } + return found +} + +// match reports whether the user's symbol matches the program's. +// A lower-case character in the user's string matches either case in the program's. +// The program string must be exported. +func match(user, program string) bool { + if !isExported(program) { + return false + } + if matchCase { + return user == program + } + for _, u := range user { + p, w := utf8.DecodeRuneInString(program) + program = program[w:] + if u == p { + continue + } + if unicode.IsLower(u) && simpleFold(u) == simpleFold(p) { + continue + } + return false + } + return program == "" +} + +// simpleFold returns the minimum rune equivalent to r +// under Unicode-defined simple case folding. +func simpleFold(r rune) rune { + for { + r1 := unicode.SimpleFold(r) + if r1 <= r { + return r1 // wrapped around, found min + } + r = r1 + } +} diff --git a/go/src/cmd/go/internal/doc/pkgsite.go b/go/src/cmd/go/internal/doc/pkgsite.go new file mode 100644 index 0000000000000000000000000000000000000000..dc344cbbcac4ccae742984a988e6198df902748d --- /dev/null +++ b/go/src/cmd/go/internal/doc/pkgsite.go @@ -0,0 +1,95 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cmd_go_bootstrap + +package doc + +import ( + "errors" + "fmt" + "net" + "net/url" + "os" + "os/exec" + "os/signal" + "path/filepath" + "strings" +) + +// pickUnusedPort finds an unused port by trying to listen on port 0 +// and letting the OS pick a port, then closing that connection and +// returning that port number. +// This is inherently racy. +func pickUnusedPort() (int, error) { + l, err := net.Listen("tcp", "localhost:0") + if err != nil { + return 0, err + } + port := l.Addr().(*net.TCPAddr).Port + if err := l.Close(); err != nil { + return 0, err + } + return port, nil +} + +func doPkgsite(urlPath, fragment string) error { + port, err := pickUnusedPort() + if err != nil { + return fmt.Errorf("failed to find port for documentation server: %v", err) + } + addr := fmt.Sprintf("localhost:%d", port) + path, err := url.JoinPath("http://"+addr, urlPath) + if err != nil { + return fmt.Errorf("internal error: failed to construct url: %v", err) + } + if fragment != "" { + path += "#" + fragment + } + + // Turn off the default signal handler for SIGINT (and SIGQUIT on Unix) + // and instead wait for the child process to handle the signal and + // exit before exiting ourselves. + signal.Ignore(signalsToIgnore...) + + // Prepend the local download cache to GOPROXY to get around deprecation checks. + env := os.Environ() + vars, err := runCmd(env, goCmd(), "env", "GOPROXY", "GOMODCACHE") + fields := strings.Fields(vars) + if err == nil && len(fields) == 2 { + goproxy, gomodcache := fields[0], fields[1] + gomodcache = filepath.Join(gomodcache, "cache", "download") + // Convert absolute path to file URL. pkgsite will not accept + // Windows absolute paths because they look like a host:path remote. + // TODO(golang.org/issue/32456): use url.FromFilePath when implemented. + if strings.HasPrefix(gomodcache, "/") { + gomodcache = "file://" + gomodcache + } else { + gomodcache = "file:///" + filepath.ToSlash(gomodcache) + } + env = append(env, "GOPROXY="+gomodcache+","+goproxy) + } + + const version = "v0.0.0-20251223195805-1a3bd3c788fe" + cmd := exec.Command(goCmd(), "run", "golang.org/x/pkgsite/cmd/internal/doc@"+version, + "-gorepo", buildCtx.GOROOT, + "-http", addr, + "-open", path) + cmd.Env = env + cmd.Stdout = os.Stderr + cmd.Stderr = os.Stderr + + if err := cmd.Run(); err != nil { + if ee, ok := errors.AsType[*exec.ExitError](err); ok { + // Exit with the same exit status as pkgsite to avoid + // printing of "exit status" error messages. + // Any relevant messages have already been printed + // to stdout or stderr. + os.Exit(ee.ExitCode()) + } + return err + } + + return nil +} diff --git a/go/src/cmd/go/internal/doc/pkgsite_bootstrap.go b/go/src/cmd/go/internal/doc/pkgsite_bootstrap.go new file mode 100644 index 0000000000000000000000000000000000000000..3c9f546957e5a02dd78b588555cb4aa793b46453 --- /dev/null +++ b/go/src/cmd/go/internal/doc/pkgsite_bootstrap.go @@ -0,0 +1,11 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build cmd_go_bootstrap + +// Don't build the pkgsite code into go_bootstrap because it depends on net. + +package doc + +func doPkgsite(string, string) error { return nil } diff --git a/go/src/cmd/go/internal/doc/signal_notunix.go b/go/src/cmd/go/internal/doc/signal_notunix.go new file mode 100644 index 0000000000000000000000000000000000000000..b91a67eb5fbff0256fb61c04737ded9614397c97 --- /dev/null +++ b/go/src/cmd/go/internal/doc/signal_notunix.go @@ -0,0 +1,13 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build plan9 || windows + +package doc + +import ( + "os" +) + +var signalsToIgnore = []os.Signal{os.Interrupt} diff --git a/go/src/cmd/go/internal/doc/signal_unix.go b/go/src/cmd/go/internal/doc/signal_unix.go new file mode 100644 index 0000000000000000000000000000000000000000..f30612ce9dce458d18599c25cddd079621ee0a17 --- /dev/null +++ b/go/src/cmd/go/internal/doc/signal_unix.go @@ -0,0 +1,14 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix || js || wasip1 + +package doc + +import ( + "os" + "syscall" +) + +var signalsToIgnore = []os.Signal{os.Interrupt, syscall.SIGQUIT} diff --git a/go/src/cmd/go/internal/doc/testdata/merge/aa.go b/go/src/cmd/go/internal/doc/testdata/merge/aa.go new file mode 100644 index 0000000000000000000000000000000000000000..f8ab92dfd07f74751cb698fe4e87beed6239d618 --- /dev/null +++ b/go/src/cmd/go/internal/doc/testdata/merge/aa.go @@ -0,0 +1,7 @@ +// Package comment A. +package merge + +// A doc. +func A() { + // A comment. +} diff --git a/go/src/cmd/go/internal/doc/testdata/merge/bb.go b/go/src/cmd/go/internal/doc/testdata/merge/bb.go new file mode 100644 index 0000000000000000000000000000000000000000..fd8cf3c446a4dd5b071a264b151799d1b4ddd185 --- /dev/null +++ b/go/src/cmd/go/internal/doc/testdata/merge/bb.go @@ -0,0 +1,7 @@ +// Package comment B. +package merge + +// B doc. +func B() { + // B comment. +} diff --git a/go/src/cmd/go/internal/doc/testdata/nested/empty/empty.go b/go/src/cmd/go/internal/doc/testdata/nested/empty/empty.go new file mode 100644 index 0000000000000000000000000000000000000000..609cf0e0a0c0bb54d70599c4a7e45ebd6ef422d4 --- /dev/null +++ b/go/src/cmd/go/internal/doc/testdata/nested/empty/empty.go @@ -0,0 +1 @@ +package empty diff --git a/go/src/cmd/go/internal/doc/testdata/nested/ignore.go b/go/src/cmd/go/internal/doc/testdata/nested/ignore.go new file mode 100644 index 0000000000000000000000000000000000000000..5fa811d0a859c192c3a34713e970e604b2f93da3 --- /dev/null +++ b/go/src/cmd/go/internal/doc/testdata/nested/ignore.go @@ -0,0 +1,5 @@ +//go:build ignore +// +build ignore + +// Ignored package +package nested diff --git a/go/src/cmd/go/internal/doc/testdata/nested/nested/real.go b/go/src/cmd/go/internal/doc/testdata/nested/nested/real.go new file mode 100644 index 0000000000000000000000000000000000000000..1e5546081ce03a6eedaf59a0a3dd92b94f0807cf --- /dev/null +++ b/go/src/cmd/go/internal/doc/testdata/nested/nested/real.go @@ -0,0 +1,4 @@ +package nested + +type Foo struct { +} diff --git a/go/src/cmd/go/internal/doc/testdata/pkg.go b/go/src/cmd/go/internal/doc/testdata/pkg.go new file mode 100644 index 0000000000000000000000000000000000000000..53b018318f3cc738a0025fdacb15a8b69402306a --- /dev/null +++ b/go/src/cmd/go/internal/doc/testdata/pkg.go @@ -0,0 +1,267 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package comment. +package pkg + +import "io" + +// Constants + +// Comment about exported constant. +const ExportedConstant = 1 + +// Comment about internal constant. +const internalConstant = 2 + +// Comment about block of constants. +const ( + // Comment before ConstOne. + ConstOne = 1 + ConstTwo = 2 // Comment on line with ConstTwo. + constThree = 3 // Comment on line with constThree. +) + +// Const block where first entry is unexported. +const ( + constFour = iota + ConstFive + ConstSix +) + +// Variables + +// Comment about exported variable. +var ExportedVariable = 1 + +var ExportedVarOfUnExported unexportedType + +// Comment about internal variable. +var internalVariable = 2 + +// Comment about block of variables. +var ( + // Comment before VarOne. + VarOne = 1 + VarTwo = 2 // Comment on line with VarTwo. + varThree = 3 // Comment on line with varThree. +) + +// Var block where first entry is unexported. +var ( + varFour = 4 + VarFive = 5 + varSix = 6 +) + +// Comment about exported function. +func ExportedFunc(a int) bool { + // BUG(me): function body note + return true != false +} + +// Comment about internal function. +func internalFunc(a int) bool + +// Comment about exported type. +type ExportedType struct { + // Comment before exported field. + ExportedField int // Comment on line with exported field. + unexportedField int // Comment on line with unexported field. + ExportedEmbeddedType // Comment on line with exported embedded field. + *ExportedEmbeddedType // Comment on line with exported embedded *field. + *qualified.ExportedEmbeddedType // Comment on line with exported embedded *selector.field. + unexportedType // Comment on line with unexported embedded field. + *unexportedType // Comment on line with unexported embedded *field. + io.Reader // Comment on line with embedded Reader. + error // Comment on line with embedded error. +} + +// Comment about exported method. +func (ExportedType) ExportedMethod(a int) bool { + return true != true +} + +func (ExportedType) Uncommented(a int) bool { + return true != true +} + +// Comment about unexported method. +func (ExportedType) unexportedMethod(a int) bool { + return true +} + +type ExportedStructOneField struct { + OnlyField int // the only field +} + +// Constants tied to ExportedType. (The type is a struct so this isn't valid Go, +// but it parses and that's all we need.) +const ( + ExportedTypedConstant ExportedType = iota +) + +// Comment about constructor for exported type. +func ExportedTypeConstructor() *ExportedType { + return nil +} + +const unexportedTypedConstant ExportedType = 1 // In a separate section to test -u. + +// Comment about exported interface. +type ExportedInterface interface { + // Comment before exported method. + // + // // Code block showing how to use ExportedMethod + // func DoSomething() error { + // ExportedMethod() + // return nil + // } + // + ExportedMethod() // Comment on line with exported method. + unexportedMethod() // Comment on line with unexported method. + io.Reader // Comment on line with embedded Reader. + error // Comment on line with embedded error. +} + +// Comment about unexported type. +type unexportedType int + +func (unexportedType) ExportedMethod() bool { + return true +} + +func (unexportedType) unexportedMethod() bool { + return true +} + +// Constants tied to unexportedType. +const ( + ExportedTypedConstant_unexported unexportedType = iota +) + +const unexportedTypedConstant unexportedType = 1 // In a separate section to test -u. + +// For case matching. +const CaseMatch = 1 +const Casematch = 2 + +func ReturnUnexported() unexportedType { return 0 } +func ReturnExported() ExportedType { return ExportedType{} } + +const MultiLineConst = ` + MultiLineString1 + MultiLineString2 + MultiLineString3 +` + +func MultiLineFunc(x interface { + MultiLineMethod1() int + MultiLineMethod2() int + MultiLineMethod3() int +}) (r struct { + MultiLineField1 int + MultiLineField2 int + MultiLineField3 int +}) { + return r +} + +var MultiLineVar = map[struct { + MultiLineField1 string + MultiLineField2 uint64 +}]struct { + MultiLineField3 error + MultiLineField2 error +}{ + {"FieldVal1", 1}: {}, + {"FieldVal2", 2}: {}, + {"FieldVal3", 3}: {}, +} + +const ( + _, _ uint64 = 2 * iota, 1 << iota + constLeft1, constRight1 + ConstLeft2, constRight2 + constLeft3, ConstRight3 + ConstLeft4, ConstRight4 +) + +const ( + ConstGroup1 unexportedType = iota + ConstGroup2 + ConstGroup3 +) + +const ConstGroup4 ExportedType = ExportedType{} + +func newLongLine(ss ...string) + +var LongLine = newLongLine( + "someArgument1", + "someArgument2", + "someArgument3", + "someArgument4", + "someArgument5", + "someArgument6", + "someArgument7", + "someArgument8", +) + +type T2 int + +type T1 = T2 + +const ( + Duplicate = iota + duplicate +) + +// Comment about exported function with formatting. +// +// Example +// +// fmt.Println(FormattedDoc()) +// +// Text after pre-formatted block. +func ExportedFormattedDoc(a int) bool { + return true +} + +type ExportedFormattedType struct { + // Comment before exported field with formatting. + // + // Example + // + // a.ExportedField = 123 + // + // Text after pre-formatted block. + //ignore:directive + ExportedField int +} + +type SimpleConstraint interface { + ~int | ~float64 +} + +type TildeConstraint interface { + ~int +} + +type StructConstraint interface { + struct { F int } +} + +// Comment about exported interface with comparable. +type ExportedComparableInterface interface { + comparable // Comment on line with comparable. + ExportedMethod() // Comment on line with exported method. + unexportedMethod() // Comment on line with unexported method. +} + +// ExportedComparableOnlyInterface has only comparable and exported method (no unexported). +type ExportedComparableOnlyInterface interface { + comparable // Comment on line with comparable. + ExportedMethod() // Comment on line with exported method. +} diff --git a/go/src/cmd/go/internal/envcmd/env.go b/go/src/cmd/go/internal/envcmd/env.go new file mode 100644 index 0000000000000000000000000000000000000000..d345a36863232ef0f0334443699b893b5c132421 --- /dev/null +++ b/go/src/cmd/go/internal/envcmd/env.go @@ -0,0 +1,764 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package envcmd implements the “go env” command. +package envcmd + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "go/build" + "internal/buildcfg" + "io" + "os" + "path/filepath" + "runtime" + "slices" + "sort" + "strings" + "unicode" + "unicode/utf8" + + "cmd/go/internal/base" + "cmd/go/internal/cache" + "cmd/go/internal/cfg" + "cmd/go/internal/fsys" + "cmd/go/internal/load" + "cmd/go/internal/modload" + "cmd/go/internal/work" + "cmd/internal/quoted" + "cmd/internal/telemetry" +) + +var CmdEnv = &base.Command{ + UsageLine: "go env [-json] [-changed] [-u] [-w] [var ...]", + Short: "print Go environment information", + Long: ` +Env prints Go environment information. + +By default env prints information as a shell script +(on Windows, a batch file). If one or more variable +names is given as arguments, env prints the value of +each named variable on its own line. + +The -json flag prints the environment in JSON format +instead of as a shell script. + +The -u flag requires one or more arguments and unsets +the default setting for the named environment variables, +if one has been set with 'go env -w'. + +The -w flag requires one or more arguments of the +form NAME=VALUE and changes the default settings +of the named environment variables to the given values. + +The -changed flag prints only those settings whose effective +value differs from the default value that would be obtained in +an empty environment with no prior uses of the -w flag. + +For more about environment variables, see 'go help environment'. + `, +} + +func init() { + CmdEnv.Run = runEnv // break init cycle + base.AddChdirFlag(&CmdEnv.Flag) + base.AddBuildFlagsNX(&CmdEnv.Flag) +} + +var ( + envJson = CmdEnv.Flag.Bool("json", false, "") + envU = CmdEnv.Flag.Bool("u", false, "") + envW = CmdEnv.Flag.Bool("w", false, "") + envChanged = CmdEnv.Flag.Bool("changed", false, "") +) + +func MkEnv() []cfg.EnvVar { + envFile, envFileChanged, _ := cfg.EnvFile() + env := []cfg.EnvVar{ + // NOTE: Keep this list (and in general, all lists in source code) sorted by name. + {Name: "GO111MODULE", Value: cfg.Getenv("GO111MODULE")}, + {Name: "GOARCH", Value: cfg.Goarch, Changed: cfg.Goarch != runtime.GOARCH}, + {Name: "GOAUTH", Value: cfg.GOAUTH, Changed: cfg.GOAUTHChanged}, + {Name: "GOBIN", Value: cfg.GOBIN}, + {Name: "GOCACHE"}, + {Name: "GOCACHEPROG", Value: cfg.GOCACHEPROG, Changed: cfg.GOCACHEPROGChanged}, + {Name: "GODEBUG", Value: os.Getenv("GODEBUG")}, + {Name: "GOENV", Value: envFile, Changed: envFileChanged}, + {Name: "GOEXE", Value: cfg.ExeSuffix}, + + // List the raw value of GOEXPERIMENT, not the cleaned one. + // The set of default experiments may change from one release + // to the next, so a GOEXPERIMENT setting that is redundant + // with the current toolchain might actually be relevant with + // a different version (for example, when bisecting a regression). + {Name: "GOEXPERIMENT", Value: cfg.RawGOEXPERIMENT}, + + {Name: "GOFIPS140", Value: cfg.GOFIPS140, Changed: cfg.GOFIPS140Changed}, + {Name: "GOFLAGS", Value: cfg.Getenv("GOFLAGS")}, + {Name: "GOHOSTARCH", Value: runtime.GOARCH}, + {Name: "GOHOSTOS", Value: runtime.GOOS}, + {Name: "GOINSECURE", Value: cfg.GOINSECURE}, + {Name: "GOMODCACHE", Value: cfg.GOMODCACHE, Changed: cfg.GOMODCACHEChanged}, + {Name: "GONOPROXY", Value: cfg.GONOPROXY, Changed: cfg.GONOPROXYChanged}, + {Name: "GONOSUMDB", Value: cfg.GONOSUMDB, Changed: cfg.GONOSUMDBChanged}, + {Name: "GOOS", Value: cfg.Goos, Changed: cfg.Goos != runtime.GOOS}, + {Name: "GOPATH", Value: cfg.BuildContext.GOPATH, Changed: cfg.GOPATHChanged}, + {Name: "GOPRIVATE", Value: cfg.GOPRIVATE}, + {Name: "GOPROXY", Value: cfg.GOPROXY, Changed: cfg.GOPROXYChanged}, + {Name: "GOROOT", Value: cfg.GOROOT}, + {Name: "GOSUMDB", Value: cfg.GOSUMDB, Changed: cfg.GOSUMDBChanged}, + {Name: "GOTELEMETRY", Value: telemetry.Mode()}, + {Name: "GOTELEMETRYDIR", Value: telemetry.Dir()}, + {Name: "GOTMPDIR", Value: cfg.Getenv("GOTMPDIR")}, + {Name: "GOTOOLCHAIN"}, + {Name: "GOTOOLDIR", Value: build.ToolDir}, + {Name: "GOVCS", Value: cfg.GOVCS}, + {Name: "GOVERSION", Value: runtime.Version()}, + } + + for i := range env { + switch env[i].Name { + case "GO111MODULE": + if env[i].Value != "on" && env[i].Value != "" { + env[i].Changed = true + } + case "GOBIN", "GOEXPERIMENT", "GOFLAGS", "GOINSECURE", "GOPRIVATE", "GOTMPDIR", "GOVCS": + if env[i].Value != "" { + env[i].Changed = true + } + case "GOCACHE": + env[i].Value, env[i].Changed, _ = cache.DefaultDir() + case "GOTOOLCHAIN": + env[i].Value, env[i].Changed = cfg.EnvOrAndChanged("GOTOOLCHAIN", "") + case "GODEBUG": + env[i].Changed = env[i].Value != "" + } + } + + if work.GccgoBin != "" { + env = append(env, cfg.EnvVar{Name: "GCCGO", Value: work.GccgoBin, Changed: true}) + } else { + env = append(env, cfg.EnvVar{Name: "GCCGO", Value: work.GccgoName, Changed: work.GccgoChanged}) + } + + goarch, val, changed := cfg.GetArchEnv() + if goarch != "" { + env = append(env, cfg.EnvVar{Name: goarch, Value: val, Changed: changed}) + } + + cc := cfg.Getenv("CC") + ccChanged := true + if cc == "" { + ccChanged = false + cc = cfg.DefaultCC(cfg.Goos, cfg.Goarch) + } + cxx := cfg.Getenv("CXX") + cxxChanged := true + if cxx == "" { + cxxChanged = false + cxx = cfg.DefaultCXX(cfg.Goos, cfg.Goarch) + } + ar, arChanged := cfg.EnvOrAndChanged("AR", "ar") + env = append(env, cfg.EnvVar{Name: "AR", Value: ar, Changed: arChanged}) + env = append(env, cfg.EnvVar{Name: "CC", Value: cc, Changed: ccChanged}) + env = append(env, cfg.EnvVar{Name: "CXX", Value: cxx, Changed: cxxChanged}) + + if cfg.BuildContext.CgoEnabled { + env = append(env, cfg.EnvVar{Name: "CGO_ENABLED", Value: "1", Changed: cfg.CGOChanged}) + } else { + env = append(env, cfg.EnvVar{Name: "CGO_ENABLED", Value: "0", Changed: cfg.CGOChanged}) + } + + return env +} + +func findEnv(env []cfg.EnvVar, name string) string { + for _, e := range env { + if e.Name == name { + return e.Value + } + } + if cfg.CanGetenv(name) { + return cfg.Getenv(name) + } + return "" +} + +// ExtraEnvVars returns environment variables that should not leak into child processes. +func ExtraEnvVars(loaderstate *modload.State) []cfg.EnvVar { + gomod := "" + modload.Init(loaderstate) + if loaderstate.HasModRoot() { + gomod = loaderstate.ModFilePath() + } else if loaderstate.Enabled() { + gomod = os.DevNull + } + loaderstate.InitWorkfile() + gowork := modload.WorkFilePath(loaderstate) + // As a special case, if a user set off explicitly, report that in GOWORK. + if cfg.Getenv("GOWORK") == "off" { + gowork = "off" + } + return []cfg.EnvVar{ + {Name: "GOMOD", Value: gomod}, + {Name: "GOWORK", Value: gowork}, + } +} + +// ExtraEnvVarsCostly returns environment variables that should not leak into child processes +// but are costly to evaluate. +func ExtraEnvVarsCostly(loaderstate *modload.State) []cfg.EnvVar { + b := work.NewBuilder("", loaderstate.VendorDirOrEmpty) + defer func() { + if err := b.Close(); err != nil { + base.Fatal(err) + } + }() + + cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{}) + if err != nil { + // Should not happen - b.CFlags was given an empty package. + fmt.Fprintf(os.Stderr, "go: invalid cflags: %v\n", err) + return nil + } + cmd := b.GccCmd(".", "") + + join := func(s []string) string { + q, err := quoted.Join(s) + if err != nil { + return strings.Join(s, " ") + } + return q + } + + ret := []cfg.EnvVar{ + // Note: Update the switch in runEnv below when adding to this list. + {Name: "CGO_CFLAGS", Value: join(cflags)}, + {Name: "CGO_CPPFLAGS", Value: join(cppflags)}, + {Name: "CGO_CXXFLAGS", Value: join(cxxflags)}, + {Name: "CGO_FFLAGS", Value: join(fflags)}, + {Name: "CGO_LDFLAGS", Value: join(ldflags)}, + {Name: "PKG_CONFIG", Value: b.PkgconfigCmd()}, + {Name: "GOGCCFLAGS", Value: join(cmd[3:])}, + } + + for i := range ret { + ev := &ret[i] + switch ev.Name { + case "GOGCCFLAGS": // GOGCCFLAGS cannot be modified + case "CGO_CPPFLAGS": + ev.Changed = ev.Value != "" + case "PKG_CONFIG": + ev.Changed = ev.Value != cfg.DefaultPkgConfig + case "CGO_CXXFLAGS", "CGO_CFLAGS", "CGO_FFLAGS", "CGO_LDFLAGS": + ev.Changed = ev.Value != work.DefaultCFlags + } + } + + return ret +} + +// argKey returns the KEY part of the arg KEY=VAL, or else arg itself. +func argKey(arg string) string { + i := strings.Index(arg, "=") + if i < 0 { + return arg + } + return arg[:i] +} + +func runEnv(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + if *envJson && *envU { + base.Fatalf("go: cannot use -json with -u") + } + if *envJson && *envW { + base.Fatalf("go: cannot use -json with -w") + } + if *envU && *envW { + base.Fatalf("go: cannot use -u with -w") + } + + // Handle 'go env -w' and 'go env -u' before calling buildcfg.Check, + // so they can be used to recover from an invalid configuration. + if *envW { + runEnvW(args) + return + } + + if *envU { + runEnvU(args) + return + } + + buildcfg.Check() + if cfg.ExperimentErr != nil { + base.Fatal(cfg.ExperimentErr) + } + + for _, arg := range args { + if strings.Contains(arg, "=") { + base.Fatalf("go: invalid variable name %q (use -w to set variable)", arg) + } + } + + env := cfg.CmdEnv + env = append(env, ExtraEnvVars(moduleLoaderState)...) + + if err := fsys.Init(); err != nil { + base.Fatal(err) + } + + // Do we need to call ExtraEnvVarsCostly, which is a bit expensive? + needCostly := false + if len(args) == 0 { + // We're listing all environment variables ("go env"), + // including the expensive ones. + needCostly = true + } else { + needCostly = false + checkCostly: + for _, arg := range args { + switch argKey(arg) { + case "CGO_CFLAGS", + "CGO_CPPFLAGS", + "CGO_CXXFLAGS", + "CGO_FFLAGS", + "CGO_LDFLAGS", + "PKG_CONFIG", + "GOGCCFLAGS": + needCostly = true + break checkCostly + } + } + } + if needCostly { + work.BuildInit(moduleLoaderState) + env = append(env, ExtraEnvVarsCostly(moduleLoaderState)...) + } + + if len(args) > 0 { + // Show only the named vars. + if !*envChanged { + if *envJson { + es := make([]cfg.EnvVar, 0, len(args)) + for _, name := range args { + e := cfg.EnvVar{Name: name, Value: findEnv(env, name)} + es = append(es, e) + } + env = es + } else { + // Print just the values, without names. + for _, name := range args { + fmt.Printf("%s\n", findEnv(env, name)) + } + return + } + } else { + // Show only the changed, named vars. + var es []cfg.EnvVar + for _, name := range args { + for _, e := range env { + if e.Name == name { + es = append(es, e) + break + } + } + } + env = es + } + } + + // print + if *envJson { + printEnvAsJSON(env, *envChanged) + } else { + PrintEnv(os.Stdout, env, *envChanged) + } +} + +func runEnvW(args []string) { + // Process and sanity-check command line. + if len(args) == 0 { + base.Fatalf("go: no KEY=VALUE arguments given") + } + osEnv := make(map[string]string) + for _, e := range cfg.OrigEnv { + if i := strings.Index(e, "="); i >= 0 { + osEnv[e[:i]] = e[i+1:] + } + } + add := make(map[string]string) + for _, arg := range args { + key, val, found := strings.Cut(arg, "=") + if !found { + base.Fatalf("go: arguments must be KEY=VALUE: invalid argument: %s", arg) + } + if err := checkEnvWrite(key, val); err != nil { + base.Fatal(err) + } + if _, ok := add[key]; ok { + base.Fatalf("go: multiple values for key: %s", key) + } + add[key] = val + if osVal := osEnv[key]; osVal != "" && osVal != val { + fmt.Fprintf(os.Stderr, "warning: go env -w %s=... does not override conflicting OS environment variable\n", key) + } + } + + if err := checkBuildConfig(add, nil); err != nil { + base.Fatal(err) + } + + gotmp, okGOTMP := add["GOTMPDIR"] + if okGOTMP { + if !filepath.IsAbs(gotmp) && gotmp != "" { + base.Fatalf("go: GOTMPDIR must be an absolute path") + } + } + + updateEnvFile(add, nil) +} + +func runEnvU(args []string) { + // Process and sanity-check command line. + if len(args) == 0 { + base.Fatalf("go: 'go env -u' requires an argument") + } + del := make(map[string]bool) + for _, arg := range args { + if err := checkEnvWrite(arg, ""); err != nil { + base.Fatal(err) + } + del[arg] = true + } + + if err := checkBuildConfig(nil, del); err != nil { + base.Fatal(err) + } + + updateEnvFile(nil, del) +} + +// checkBuildConfig checks whether the build configuration is valid +// after the specified configuration environment changes are applied. +func checkBuildConfig(add map[string]string, del map[string]bool) error { + // get returns the value for key after applying add and del and + // reports whether it changed. cur should be the current value + // (i.e., before applying changes) and def should be the default + // value (i.e., when no environment variables are provided at all). + get := func(key, cur, def string) (string, bool) { + if val, ok := add[key]; ok { + return val, true + } + if del[key] { + val := getOrigEnv(key) + if val == "" { + val = def + } + return val, true + } + return cur, false + } + + goos, okGOOS := get("GOOS", cfg.Goos, build.Default.GOOS) + goarch, okGOARCH := get("GOARCH", cfg.Goarch, build.Default.GOARCH) + if okGOOS || okGOARCH { + if err := work.CheckGOOSARCHPair(goos, goarch); err != nil { + return err + } + } + + goexperiment, okGOEXPERIMENT := get("GOEXPERIMENT", cfg.RawGOEXPERIMENT, buildcfg.DefaultGOEXPERIMENT) + if okGOEXPERIMENT { + if _, err := buildcfg.ParseGOEXPERIMENT(goos, goarch, goexperiment); err != nil { + return err + } + } + + return nil +} + +// PrintEnv prints the environment variables to w. +func PrintEnv(w io.Writer, env []cfg.EnvVar, onlyChanged bool) { + env = slices.Clone(env) + slices.SortFunc(env, func(x, y cfg.EnvVar) int { return strings.Compare(x.Name, y.Name) }) + + for _, e := range env { + if e.Name != "TERM" { + if runtime.GOOS != "plan9" && bytes.Contains([]byte(e.Value), []byte{0}) { + base.Fatalf("go: internal error: encountered null byte in environment variable %s on non-plan9 platform", e.Name) + } + if onlyChanged && !e.Changed { + continue + } + switch runtime.GOOS { + default: + fmt.Fprintf(w, "%s=%s\n", e.Name, shellQuote(e.Value)) + case "plan9": + if strings.IndexByte(e.Value, '\x00') < 0 { + fmt.Fprintf(w, "%s='%s'\n", e.Name, strings.ReplaceAll(e.Value, "'", "''")) + } else { + v := strings.Split(e.Value, "\x00") + fmt.Fprintf(w, "%s=(", e.Name) + for x, s := range v { + if x > 0 { + fmt.Fprintf(w, " ") + } + fmt.Fprintf(w, "'%s'", strings.ReplaceAll(s, "'", "''")) + } + fmt.Fprintf(w, ")\n") + } + case "windows": + if hasNonGraphic(e.Value) { + base.Errorf("go: stripping unprintable or unescapable characters from %%%q%%", e.Name) + } + fmt.Fprintf(w, "set %s=%s\n", e.Name, batchEscape(e.Value)) + } + } + } +} + +// isWindowsUnquotableRune reports whether r can't be quoted in a +// Windows "set" command. +// These runes will be replaced by the Unicode replacement character. +func isWindowsUnquotableRune(r rune) bool { + if r == '\r' || r == '\n' { + return true + } + return !unicode.IsGraphic(r) && !unicode.IsSpace(r) +} + +func hasNonGraphic(s string) bool { + return strings.ContainsFunc(s, isWindowsUnquotableRune) +} + +func shellQuote(s string) string { + var sb strings.Builder + sb.WriteByte('\'') + for _, r := range s { + if r == '\'' { + // Close the single quoted string, add an escaped single quote, + // and start another single quoted string. + sb.WriteString(`'\''`) + } else { + sb.WriteRune(r) + } + } + sb.WriteByte('\'') + return sb.String() +} + +func batchEscape(s string) string { + var sb strings.Builder + for _, r := range s { + if isWindowsUnquotableRune(r) { + sb.WriteRune(unicode.ReplacementChar) + continue + } + switch r { + case '%': + sb.WriteString("%%") + case '<', '>', '|', '&', '^': + // These are special characters that need to be escaped with ^. See + // https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set_1. + sb.WriteByte('^') + sb.WriteRune(r) + default: + sb.WriteRune(r) + } + } + return sb.String() +} + +func printEnvAsJSON(env []cfg.EnvVar, onlyChanged bool) { + m := make(map[string]string) + for _, e := range env { + if e.Name == "TERM" { + continue + } + if onlyChanged && !e.Changed { + continue + } + m[e.Name] = e.Value + } + enc := json.NewEncoder(os.Stdout) + enc.SetIndent("", "\t") + if err := enc.Encode(m); err != nil { + base.Fatalf("go: %s", err) + } +} + +func getOrigEnv(key string) string { + for _, v := range cfg.OrigEnv { + if v, found := strings.CutPrefix(v, key+"="); found { + return v + } + } + return "" +} + +func checkEnvWrite(key, val string) error { + switch key { + case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOWORK", "GOTOOLDIR", "GOVERSION", "GOTELEMETRY", "GOTELEMETRYDIR": + return fmt.Errorf("%s cannot be modified", key) + case "GOENV", "GODEBUG": + return fmt.Errorf("%s can only be set using the OS environment", key) + } + + // To catch typos and the like, check that we know the variable. + // If it's already in the env file, we assume it's known. + if !cfg.CanGetenv(key) { + return fmt.Errorf("unknown go command variable %s", key) + } + + // Some variables can only have one of a few valid values. If set to an + // invalid value, the next cmd/go invocation might fail immediately, + // even 'go env -w' itself. + switch key { + case "GO111MODULE": + switch val { + case "", "auto", "on", "off": + default: + return fmt.Errorf("invalid %s value %q", key, val) + } + case "GOPATH": + if strings.HasPrefix(val, "~") { + return fmt.Errorf("GOPATH entry cannot start with shell metacharacter '~': %q", val) + } + if !filepath.IsAbs(val) && val != "" { + return fmt.Errorf("GOPATH entry is relative; must be absolute path: %q", val) + } + case "GOMODCACHE": + if !filepath.IsAbs(val) && val != "" { + return fmt.Errorf("GOMODCACHE entry is relative; must be absolute path: %q", val) + } + case "CC", "CXX": + if val == "" { + break + } + args, err := quoted.Split(val) + if err != nil { + return fmt.Errorf("invalid %s: %v", key, err) + } + if len(args) == 0 { + return fmt.Errorf("%s entry cannot contain only space", key) + } + if !filepath.IsAbs(args[0]) && args[0] != filepath.Base(args[0]) { + return fmt.Errorf("%s entry is relative; must be absolute path: %q", key, args[0]) + } + } + + if !utf8.ValidString(val) { + return fmt.Errorf("invalid UTF-8 in %s=... value", key) + } + if strings.Contains(val, "\x00") { + return fmt.Errorf("invalid NUL in %s=... value", key) + } + if strings.ContainsAny(val, "\v\r\n") { + return fmt.Errorf("invalid newline in %s=... value", key) + } + return nil +} + +func readEnvFileLines(mustExist bool) []string { + file, _, err := cfg.EnvFile() + if file == "" { + if mustExist { + base.Fatalf("go: cannot find go env config: %v", err) + } + return nil + } + data, err := os.ReadFile(file) + if err != nil && (!os.IsNotExist(err) || mustExist) { + base.Fatalf("go: reading go env config: %v", err) + } + lines := strings.SplitAfter(string(data), "\n") + if lines[len(lines)-1] == "" { + lines = lines[:len(lines)-1] + } else { + lines[len(lines)-1] += "\n" + } + return lines +} + +func updateEnvFile(add map[string]string, del map[string]bool) { + lines := readEnvFileLines(len(add) == 0) + + // Delete all but last copy of any duplicated variables, + // since the last copy is the one that takes effect. + prev := make(map[string]int) + for l, line := range lines { + if key := lineToKey(line); key != "" { + if p, ok := prev[key]; ok { + lines[p] = "" + } + prev[key] = l + } + } + + // Add variables (go env -w). Update existing lines in file if present, add to end otherwise. + for key, val := range add { + if p, ok := prev[key]; ok { + lines[p] = key + "=" + val + "\n" + delete(add, key) + } + } + for key, val := range add { + lines = append(lines, key+"="+val+"\n") + } + + // Delete requested variables (go env -u). + for key := range del { + if p, ok := prev[key]; ok { + lines[p] = "" + } + } + + // Sort runs of KEY=VALUE lines + // (that is, blocks of lines where blocks are separated + // by comments, blank lines, or invalid lines). + start := 0 + for i := 0; i <= len(lines); i++ { + if i == len(lines) || lineToKey(lines[i]) == "" { + sortKeyValues(lines[start:i]) + start = i + 1 + } + } + + file, _, err := cfg.EnvFile() + if file == "" { + base.Fatalf("go: cannot find go env config: %v", err) + } + data := []byte(strings.Join(lines, "")) + err = os.WriteFile(file, data, 0666) + if err != nil { + // Try creating directory. + os.MkdirAll(filepath.Dir(file), 0777) + err = os.WriteFile(file, data, 0666) + if err != nil { + base.Fatalf("go: writing go env config: %v", err) + } + } +} + +// lineToKey returns the KEY part of the line KEY=VALUE or else an empty string. +func lineToKey(line string) string { + i := strings.Index(line, "=") + if i < 0 || strings.Contains(line[:i], "#") { + return "" + } + return line[:i] +} + +// sortKeyValues sorts a sequence of lines by key. +// It differs from sort.Strings in that GO386= sorts after GO=. +func sortKeyValues(lines []string) { + sort.Slice(lines, func(i, j int) bool { + return lineToKey(lines[i]) < lineToKey(lines[j]) + }) +} diff --git a/go/src/cmd/go/internal/envcmd/env_test.go b/go/src/cmd/go/internal/envcmd/env_test.go new file mode 100644 index 0000000000000000000000000000000000000000..2f6470b87165db9c9aba9626dcbe765dd76837a9 --- /dev/null +++ b/go/src/cmd/go/internal/envcmd/env_test.go @@ -0,0 +1,93 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix || windows + +package envcmd + +import ( + "bytes" + "cmd/go/internal/cfg" + "fmt" + "internal/testenv" + "os" + "os/exec" + "path/filepath" + "runtime" + "testing" + "unicode" +) + +func FuzzPrintEnvEscape(f *testing.F) { + f.Add(`$(echo 'cc"'; echo 'OOPS="oops')`) + f.Add("$(echo shell expansion 1>&2)") + f.Add("''") + f.Add(`C:\"Program Files"\`) + f.Add(`\\"Quoted Host"\\share`) + f.Add("\xfb") + f.Add("0") + f.Add("") + f.Add("''''''''") + f.Add("\r") + f.Add("\n") + f.Add("E,%") + f.Fuzz(func(t *testing.T, s string) { + t.Parallel() + + for _, c := range []byte(s) { + if c == 0 { + t.Skipf("skipping %q: contains a null byte. Null bytes can't occur in the environment"+ + " outside of Plan 9, which has different code path than Windows and Unix that this test"+ + " isn't testing.", s) + } + if c > unicode.MaxASCII { + t.Skipf("skipping %#q: contains a non-ASCII character %q", s, c) + } + if !unicode.IsGraphic(rune(c)) && !unicode.IsSpace(rune(c)) { + t.Skipf("skipping %#q: contains non-graphic character %q", s, c) + } + if runtime.GOOS == "windows" && c == '\r' || c == '\n' { + t.Skipf("skipping %#q on Windows: contains unescapable character %q", s, c) + } + } + + var b bytes.Buffer + if runtime.GOOS == "windows" { + b.WriteString("@echo off\n") + } + PrintEnv(&b, []cfg.EnvVar{{Name: "var", Value: s}}, false) + var want string + if runtime.GOOS == "windows" { + fmt.Fprintf(&b, "echo \"%%var%%\"\n") + want += "\"" + s + "\"\r\n" + } else { + fmt.Fprintf(&b, "printf '%%s\\n' \"$var\"\n") + want += s + "\n" + } + scriptfilename := "script.sh" + if runtime.GOOS == "windows" { + scriptfilename = "script.bat" + } + var cmd *exec.Cmd + if runtime.GOOS == "windows" { + scriptfile := filepath.Join(t.TempDir(), scriptfilename) + if err := os.WriteFile(scriptfile, b.Bytes(), 0777); err != nil { + t.Fatal(err) + } + cmd = testenv.Command(t, "cmd.exe", "/C", scriptfile) + } else { + cmd = testenv.Command(t, "sh", "-c", b.String()) + } + out, err := cmd.Output() + t.Log(string(out)) + if err != nil { + t.Fatal(err) + } + + if string(out) != want { + t.Fatalf("output of running PrintEnv script and echoing variable: got: %q, want: %q", + string(out), want) + } + }) +} diff --git a/go/src/cmd/go/internal/fips140/fips140.go b/go/src/cmd/go/internal/fips140/fips140.go new file mode 100644 index 0000000000000000000000000000000000000000..09e4141f9975bff843de62f227b8289fcee2578a --- /dev/null +++ b/go/src/cmd/go/internal/fips140/fips140.go @@ -0,0 +1,258 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package fips implements support for the GOFIPS140 build setting. +// +// The GOFIPS140 build setting controls two aspects of the build: +// +// - Whether binaries are built to default to running in FIPS-140 mode, +// meaning whether they default to GODEBUG=fips140=on or =off. +// +// - Which copy of the crypto/internal/fips140 source code to use. +// The default is obviously GOROOT/src/crypto/internal/fips140, +// but earlier snapshots that have differing levels of external +// validation and certification are stored in GOROOT/lib/fips140 +// and can be substituted into the build instead. +// +// This package provides the logic needed by the rest of the go command +// to make those decisions and implement the resulting policy. +// +// [Init] must be called to initialize the FIPS logic. It may fail and +// call base.Fatalf. +// +// When GOFIPS140=off, [Enabled] returns false, and the build is +// unchanged from its usual behaviors. +// +// When GOFIPS140 is anything else, [Enabled] returns true, and the build +// sets the default GODEBUG to include fips140=on. This will make +// binaries change their behavior at runtime to confirm to various +// FIPS-140 details. [cmd/go/internal/load.defaultGODEBUG] calls +// [fips.Enabled] when preparing the default settings. +// +// For all builds, FIPS code and data is laid out in contiguous regions +// that are conceptually concatenated into a "fips object file" that the +// linker hashes and then binaries can re-hash at startup to detect +// corruption of those symbols. When [Enabled] is true, the link step +// passes -fipso={a.Objdir}/fips.o to the linker to save a copy of the +// fips.o file. Since the first build target always uses a.Objdir set to +// $WORK/b001, a build like +// +// GOFIPS140=latest go build -work my/binary +// +// will leave fips.o behind in $WORK/b001 +// (unless the build result is cached, of course). +// +// When GOFIPS140 is set to something besides off and latest, [Snapshot] +// returns true, indicating that the build should replace the latest copy +// of crypto/internal/fips140 with an earlier snapshot. The reason to do +// this is to use a copy that has been through additional lab validation +// (an "in-process" module) or NIST certification (a "certified" module). +// The snapshots are stored in GOROOT/lib/fips140 in module zip form. +// When a snapshot is being used, Init unpacks it into the module cache +// and then uses that directory as the source location. +// +// A FIPS snapshot like v1.2.3 is integrated into the build in two different ways. +// +// First, the snapshot's fips140 directory replaces crypto/internal/fips140 +// using fsys.Bind. The effect is to appear to have deleted crypto/internal/fips140 +// and everything below it, replacing it with the single subdirectory +// crypto/internal/fips140/v1.2.3, which now has the FIPS packages. +// This virtual file system replacement makes patterns like std and crypto... +// automatically see the snapshot packages instead of the original packages +// as they walk GOROOT/src/crypto/internal/fips140. +// +// Second, ResolveImport is called to resolve an import like crypto/internal/fips140/sha256. +// When snapshot v1.2.3 is being used, ResolveImport translates that path to +// crypto/internal/fips140/v1.2.3/sha256 and returns the actual source directory +// in the unpacked snapshot. Using the actual directory instead of the +// virtual directory GOROOT/src/crypto/internal/fips140/v1.2.3 makes sure +// that other tools using go list -json output can find the sources, +// as well as making sure builds have a real directory in which to run the +// assembler, compiler, and so on. The translation of the import path happens +// in the same code that handles mapping golang.org/x/mod to +// cmd/vendor/golang.org/x/mod when building commands. +// +// It is not strictly required to include v1.2.3 in the import path when using +// a snapshot - we could make things work without doing that - but including +// the v1.2.3 gives a different version of the code a different name, which is +// always a good general rule. In particular, it will mean that govulncheck need +// not have any special cases for crypto/internal/fips140 at all. The reports simply +// need to list the relevant symbols in a given Go version. (For example, if a bug +// is only in the in-tree copy but not the snapshots, it doesn't list the snapshot +// symbols; if it's in any snapshots, it has to list the specific snapshot symbols +// in addition to the “normal” symbol.) +package fips140 + +import ( + "context" + "os" + "path" + "path/filepath" + "slices" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/fsys" + "cmd/go/internal/modfetch" + "cmd/go/internal/str" + + "golang.org/x/mod/module" + "golang.org/x/mod/semver" +) + +// Init initializes the FIPS settings. +// It must be called before using any other functions in this package. +// If initialization fails, Init calls base.Fatalf. +func Init() { + if initDone { + return + } + initDone = true + initVersion() + initDir() + if Snapshot() { + fsys.Bind(Dir(), filepath.Join(cfg.GOROOT, "src/crypto/internal/fips140")) + } + + // ExperimentErr != nil if GOEXPERIMENT failed to parse. Typically + // cmd/go main will exit in this case, but it is allowed during + // toolchain selection, as the GOEXPERIMENT may be valid for the + // selected toolchain version. + if cfg.ExperimentErr == nil && cfg.Experiment.BoringCrypto && Enabled() { + base.Fatalf("go: cannot use GOFIPS140 with GOEXPERIMENT=boringcrypto") + } + if slices.Contains(cfg.BuildContext.BuildTags, "purego") && Enabled() { + base.Fatalf("go: cannot use GOFIPS140 with the purego build tag") + } +} + +var initDone bool + +// checkInit panics if Init has not been called. +func checkInit() { + if !initDone { + panic("fips: not initialized") + } +} + +// Version reports the GOFIPS140 version in use, +// which is either "off", "latest", or a version like "v1.2.3". +// If GOFIPS140 is set to an alias like "inprocess" or "certified", +// Version returns the underlying version. +func Version() string { + checkInit() + return version +} + +// Enabled reports whether FIPS mode is enabled at all. +// That is, it reports whether GOFIPS140 is set to something besides "off". +func Enabled() bool { + checkInit() + return version != "off" +} + +// Snapshot reports whether FIPS mode is using a source snapshot +// rather than $GOROOT/src/crypto/internal/fips140. +// That is, it reports whether GOFIPS140 is set to something besides "latest" or "off". +func Snapshot() bool { + checkInit() + return version != "latest" && version != "off" +} + +var version string + +func initVersion() { + // For off and latest, use the local source tree. + v := cfg.GOFIPS140 + if v == "off" || v == "" { + version = "off" + return + } + if v == "latest" { + version = "latest" + return + } + + // Otherwise version must exist in lib/fips140, either as + // a .zip (a source snapshot like v1.2.0.zip) + // or a .txt (a redirect like inprocess.txt, containing a version number). + if strings.Contains(v, "/") || strings.Contains(v, `\`) || strings.Contains(v, "..") { + base.Fatalf("go: malformed GOFIPS140 version %q", cfg.GOFIPS140) + } + if cfg.GOROOT == "" { + base.Fatalf("go: missing GOROOT for GOFIPS140") + } + + file := filepath.Join(cfg.GOROOT, "lib", "fips140", v) + if data, err := os.ReadFile(file + ".txt"); err == nil { + v = strings.TrimSpace(string(data)) + file = filepath.Join(cfg.GOROOT, "lib", "fips140", v) + if _, err := os.Stat(file + ".zip"); err != nil { + base.Fatalf("go: unknown GOFIPS140 version %q (from %q)", v, cfg.GOFIPS140) + } + } + + if _, err := os.Stat(file + ".zip"); err == nil { + // Found version. Add a build tag. + cfg.BuildContext.BuildTags = append(cfg.BuildContext.BuildTags, "fips140"+semver.MajorMinor(v)) + version = v + return + } + + base.Fatalf("go: unknown GOFIPS140 version %q", v) +} + +// Dir reports the directory containing the crypto/internal/fips140 source code. +// If Snapshot() is false, Dir returns GOROOT/src/crypto/internal/fips140. +// Otherwise Dir ensures that the snapshot has been unpacked into the +// module cache and then returns the directory in the module cache +// corresponding to the crypto/internal/fips140 directory. +func Dir() string { + checkInit() + return dir +} + +var dir string + +func initDir() { + v := version + if v == "latest" || v == "off" { + dir = filepath.Join(cfg.GOROOT, "src/crypto/internal/fips140") + return + } + + mod := module.Version{Path: "golang.org/fips140", Version: v} + file := filepath.Join(cfg.GOROOT, "lib/fips140", v+".zip") + zdir, err := modfetch.NewFetcher().Unzip(context.Background(), mod, file) + if err != nil { + base.Fatalf("go: unpacking GOFIPS140=%v: %v", v, err) + } + dir = filepath.Join(zdir, "fips140") +} + +// ResolveImport resolves the import path imp. +// If it is of the form crypto/internal/fips140/foo +// (not crypto/internal/fips140/v1.2.3/foo) +// and we are using a snapshot, then LookupImport +// rewrites the path to crypto/internal/fips140/v1.2.3/foo +// and returns that path and its location in the unpacked +// FIPS snapshot. +func ResolveImport(imp string) (newPath, dir string, ok bool) { + checkInit() + const fips = "crypto/internal/fips140" + if !Snapshot() || !str.HasPathPrefix(imp, fips) { + return "", "", false + } + fipsv := path.Join(fips, version) + var sub string + if str.HasPathPrefix(imp, fipsv) { + sub = "." + imp[len(fipsv):] + } else { + sub = "." + imp[len(fips):] + } + newPath = path.Join(fips, version, sub) + dir = filepath.Join(Dir(), version, sub) + return newPath, dir, true +} diff --git a/go/src/cmd/go/internal/fips140/fips_test.go b/go/src/cmd/go/internal/fips140/fips_test.go new file mode 100644 index 0000000000000000000000000000000000000000..53f0c9ab5822608278a14fbccab54fb58cacae17 --- /dev/null +++ b/go/src/cmd/go/internal/fips140/fips_test.go @@ -0,0 +1,102 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package fips140 + +import ( + "crypto/sha256" + "flag" + "fmt" + "internal/testenv" + "maps" + "os" + "path/filepath" + "slices" + "strings" + "testing" +) + +var update = flag.Bool("update", false, "update GOROOT/lib/fips140/fips140.sum") + +func TestSums(t *testing.T) { + lib := filepath.Join(testenv.GOROOT(t), "lib/fips140") + file := filepath.Join(lib, "fips140.sum") + sums, err := os.ReadFile(file) + if err != nil { + t.Fatal(err) + } + lines := strings.SplitAfter(string(sums), "\n") + + zips, err := filepath.Glob(filepath.Join(lib, "*.zip")) + if err != nil { + t.Fatal(err) + } + + format := func(name string, sum [32]byte) string { + return fmt.Sprintf("%s %x\n", name, sum[:]) + } + + want := make(map[string]string) + for _, zip := range zips { + data, err := os.ReadFile(zip) + if err != nil { + t.Fatal(err) + } + name := filepath.Base(zip) + want[name] = format(name, sha256.Sum256(data)) + } + + // Process diff, deleting or correcting stale lines. + var diff []string + have := make(map[string]bool) + for i, line := range lines { + if line == "" { + continue + } + if strings.HasPrefix(line, "#") || line == "\n" { + // comment, preserve + diff = append(diff, " "+line) + continue + } + name, _, _ := strings.Cut(line, " ") + if want[name] == "" { + lines[i] = "" + diff = append(diff, "-"+line) + continue + } + have[name] = true + fixed := want[name] + delete(want, name) + if line == fixed { + diff = append(diff, " "+line) + } else { + // zip hashes should never change once listed + t.Errorf("policy violation: zip file hash is changing:\n-%s+%s", line, fixed) + lines[i] = fixed + diff = append(diff, "-"+line, "+"+fixed) + } + } + + // Add missing lines. + // Sort keys to avoid non-determinism, but overall file is not sorted. + // It will end up time-ordered instead. + for _, name := range slices.Sorted(maps.Keys(want)) { + line := want[name] + lines = append(lines, line) + diff = append(diff, "+"+line) + } + + // Show diffs or update file. + fixed := strings.Join(lines, "") + if fixed != string(sums) { + if *update && !t.Failed() { + t.Logf("updating GOROOT/lib/fips140/fips140.sum:\n%s", strings.Join(diff, "")) + if err := os.WriteFile(file, []byte(fixed), 0666); err != nil { + t.Fatal(err) + } + return + } + t.Errorf("GOROOT/lib/fips140/fips140.sum out of date. changes needed:\n%s", strings.Join(diff, "")) + } +} diff --git a/go/src/cmd/go/internal/fips140/mkzip.go b/go/src/cmd/go/internal/fips140/mkzip.go new file mode 100644 index 0000000000000000000000000000000000000000..a139a0f2e256f7b710c217171dc46ec617d0babd --- /dev/null +++ b/go/src/cmd/go/internal/fips140/mkzip.go @@ -0,0 +1,159 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +// Mkzip creates a FIPS snapshot zip file. +// See GOROOT/lib/fips140/README.md and GOROOT/lib/fips140/Makefile +// for more details about when and why to use this. +// +// Usage: +// +// cd GOROOT/lib/fips140 +// go run ../../src/cmd/go/internal/fips140/mkzip.go [-b branch] v1.2.3 +// +// Mkzip creates a zip file named for the version on the command line +// using the sources in the named branch (default origin/master, +// to avoid accidentally including local commits). +package main + +import ( + "archive/zip" + "bytes" + "flag" + "fmt" + "io" + "log" + "os" + "path/filepath" + "strings" + + "golang.org/x/mod/module" + "golang.org/x/mod/semver" + modzip "golang.org/x/mod/zip" +) + +var flagBranch = flag.String("b", "origin/master", "branch to use") + +func usage() { + fmt.Fprintf(os.Stderr, "usage: go run mkzip.go [-b branch] vX.Y.Z\n") + os.Exit(2) +} + +func main() { + log.SetFlags(0) + log.SetPrefix("mkzip: ") + flag.Usage = usage + flag.Parse() + if flag.NArg() != 1 { + usage() + } + + // Must run in the lib/fips140 directory, where the snapshots live. + wd, err := os.Getwd() + if err != nil { + log.Fatal(err) + } + if !strings.HasSuffix(filepath.ToSlash(wd), "lib/fips140") { + log.Fatalf("must be run in lib/fips140 directory") + } + + // Must have valid version, and must not overwrite existing file. + version := flag.Arg(0) + if semver.Canonical(version) != version { + log.Fatalf("invalid version %q; must be vX.Y.Z", version) + } + if _, err := os.Stat(version + ".zip"); err == nil { + log.Fatalf("%s.zip already exists", version) + } + + // Make standard module zip file in memory. + // The module path "golang.org/fips140" needs to be a valid module name, + // and it is the path where the zip file will be unpacked in the module cache. + // The path must begin with a domain name to satisfy the module validation rules, + // but otherwise the path is not used. The cmd/go code using these zips + // knows that the zip contains crypto/internal/fips140. + goroot := "../.." + var zbuf bytes.Buffer + err = modzip.CreateFromVCS(&zbuf, + module.Version{Path: "golang.org/fips140", Version: version}, + goroot, *flagBranch, "src/crypto/internal/fips140") + if err != nil { + log.Fatal(err) + } + + // Write new zip file with longer paths: fips140/v1.2.3/foo.go instead of foo.go. + // That way we can bind the fips140 directory onto the + // GOROOT/src/crypto/internal/fips140 directory and get a + // crypto/internal/fips140/v1.2.3 with the snapshot code + // and an otherwise empty crypto/internal/fips140 directory. + zr, err := zip.NewReader(bytes.NewReader(zbuf.Bytes()), int64(zbuf.Len())) + if err != nil { + log.Fatal(err) + } + + var zbuf2 bytes.Buffer + zw := zip.NewWriter(&zbuf2) + foundVersion := false + for _, f := range zr.File { + // golang.org/fips140@v1.2.3/dir/file.go -> + // golang.org/fips140@v1.2.3/fips140/v1.2.3/dir/file.go + if f.Name != "golang.org/fips140@"+version+"/LICENSE" { + f.Name = "golang.org/fips140@" + version + "/fips140/" + version + + strings.TrimPrefix(f.Name, "golang.org/fips140@"+version) + } + // Inject version in [crypto/internal/fips140.Version]. + if f.Name == "golang.org/fips140@"+version+"/fips140/"+version+"/fips140.go" { + rf, err := f.Open() + if err != nil { + log.Fatal(err) + } + contents, err := io.ReadAll(rf) + if err != nil { + log.Fatal(err) + } + returnLine := `return "latest" //mkzip:version` + if !bytes.Contains(contents, []byte(returnLine)) { + log.Fatalf("did not find %q in fips140.go", returnLine) + } + // Use only the vX.Y.Z part of a possible vX.Y.Z-hash version. + v, _, _ := strings.Cut(version, "-") + newLine := `return "` + v + `"` + contents = bytes.ReplaceAll(contents, []byte(returnLine), []byte(newLine)) + wf, err := zw.Create(f.Name) + if err != nil { + log.Fatal(err) + } + if _, err := wf.Write(contents); err != nil { + log.Fatal(err) + } + foundVersion = true + continue + } + wf, err := zw.CreateRaw(&f.FileHeader) + if err != nil { + log.Fatal(err) + } + rf, err := f.OpenRaw() + if err != nil { + log.Fatal(err) + } + if _, err := io.Copy(wf, rf); err != nil { + log.Fatal(err) + } + } + if err := zw.Close(); err != nil { + log.Fatal(err) + } + if !foundVersion { + log.Fatal("did not find fips140.go file") + } + + err = os.WriteFile(version+".zip", zbuf2.Bytes(), 0666) + if err != nil { + log.Fatal(err) + } + + log.Printf("wrote %s.zip", version) +} diff --git a/go/src/cmd/go/internal/fmtcmd/fmt.go b/go/src/cmd/go/internal/fmtcmd/fmt.go new file mode 100644 index 0000000000000000000000000000000000000000..fe356bdc081456bb26cb10a3f7b019f00bdda442 --- /dev/null +++ b/go/src/cmd/go/internal/fmtcmd/fmt.go @@ -0,0 +1,115 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package fmtcmd implements the “go fmt” command. +package fmtcmd + +import ( + "context" + "errors" + "fmt" + "os" + "path/filepath" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/load" + "cmd/go/internal/modload" + "cmd/internal/sys" +) + +func init() { + base.AddBuildFlagsNX(&CmdFmt.Flag) + base.AddChdirFlag(&CmdFmt.Flag) + base.AddModFlag(&CmdFmt.Flag) + base.AddModCommonFlags(&CmdFmt.Flag) +} + +var CmdFmt = &base.Command{ + Run: runFmt, + UsageLine: "go fmt [-n] [-x] [packages]", + Short: "gofmt (reformat) package sources", + Long: ` +Fmt runs the command 'gofmt -l -w' on the packages named +by the import paths. It prints the names of the files that are modified. + +For more about gofmt, see 'go doc cmd/gofmt'. +For more about specifying packages, see 'go help packages'. + +The -n flag prints commands that would be executed. +The -x flag prints commands as they are executed. + +The -mod flag's value sets which module download mode +to use: readonly or vendor. See 'go help modules' for more. + +To run gofmt with specific options, run gofmt itself. + +See also: go fix, go vet. + `, +} + +func runFmt(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + printed := false + gofmt := gofmtPath() + + gofmtArgs := []string{gofmt, "-l", "-w"} + gofmtArgLen := len(gofmt) + len(" -l -w") + + baseGofmtArgs := len(gofmtArgs) + baseGofmtArgLen := gofmtArgLen + + for _, pkg := range load.PackagesAndErrors(moduleLoaderState, ctx, load.PackageOpts{}, args) { + if moduleLoaderState.Enabled() && pkg.Module != nil && !pkg.Module.Main { + if !printed { + fmt.Fprintf(os.Stderr, "go: not formatting packages in dependency modules\n") + printed = true + } + continue + } + if pkg.Error != nil { + if _, ok := errors.AsType[*load.NoGoError](pkg.Error); ok { + // Skip this error, as we will format all files regardless. + } else if _, ok := errors.AsType[*load.EmbedError](pkg.Error); ok && len(pkg.InternalAllGoFiles()) > 0 { + // Skip this error, as we will format all files regardless. + } else { + base.Errorf("%v", pkg.Error) + continue + } + } + // Use pkg.gofiles instead of pkg.Dir so that + // the command only applies to this package, + // not to packages in subdirectories. + files := base.RelPaths(pkg.InternalAllGoFiles()) + for _, file := range files { + gofmtArgs = append(gofmtArgs, file) + gofmtArgLen += 1 + len(file) // plus separator + if gofmtArgLen >= sys.ExecArgLengthLimit { + base.Run(gofmtArgs) + gofmtArgs = gofmtArgs[:baseGofmtArgs] + gofmtArgLen = baseGofmtArgLen + } + } + } + if len(gofmtArgs) > baseGofmtArgs { + base.Run(gofmtArgs) + } +} + +func gofmtPath() string { + gofmt := "gofmt" + cfg.ToolExeSuffix() + + gofmtPath := filepath.Join(cfg.GOBIN, gofmt) + if _, err := os.Stat(gofmtPath); err == nil { + return gofmtPath + } + + gofmtPath = filepath.Join(cfg.GOROOT, "bin", gofmt) + if _, err := os.Stat(gofmtPath); err == nil { + return gofmtPath + } + + // fallback to looking for gofmt in $PATH + return "gofmt" +} diff --git a/go/src/cmd/go/internal/fsys/fsys.go b/go/src/cmd/go/internal/fsys/fsys.go new file mode 100644 index 0000000000000000000000000000000000000000..0e0821a35f0822085ae079791df144f6b4501190 --- /dev/null +++ b/go/src/cmd/go/internal/fsys/fsys.go @@ -0,0 +1,734 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package fsys implements a virtual file system that the go command +// uses to read source file trees. The virtual file system redirects some +// OS file paths to other OS file paths, according to an overlay file. +// Editors can use this overlay support to invoke the go command on +// temporary files that have been edited but not yet saved into their +// final locations. +package fsys + +import ( + "cmd/go/internal/str" + "encoding/json" + "errors" + "fmt" + "internal/godebug" + "io" + "io/fs" + "iter" + "log" + "maps" + "os" + pathpkg "path" + "path/filepath" + "runtime/debug" + "slices" + "strings" + "sync" + "time" +) + +// Trace emits a trace event for the operation and file path to the trace log, +// but only when $GODEBUG contains gofsystrace=1. +// The traces are appended to the file named by the $GODEBUG setting gofsystracelog, or else standard error. +// For debugging, if the $GODEBUG setting gofsystracestack is non-empty, then trace events for paths +// matching that glob pattern (using path.Match) will be followed by a full stack trace. +func Trace(op, path string) { + if !doTrace { + return + } + traceMu.Lock() + defer traceMu.Unlock() + fmt.Fprintf(traceFile, "%d gofsystrace %s %s\n", os.Getpid(), op, path) + if pattern := gofsystracestack.Value(); pattern != "" { + if match, _ := pathpkg.Match(pattern, path); match { + traceFile.Write(debug.Stack()) + } + } +} + +var ( + doTrace bool + traceFile *os.File + traceMu sync.Mutex + + gofsystrace = godebug.New("#gofsystrace") + gofsystracelog = godebug.New("#gofsystracelog") + gofsystracestack = godebug.New("#gofsystracestack") +) + +func init() { + if gofsystrace.Value() != "1" { + return + } + doTrace = true + if f := gofsystracelog.Value(); f != "" { + // Note: No buffering on writes to this file, so no need to worry about closing it at exit. + var err error + traceFile, err = os.OpenFile(f, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666) + if err != nil { + log.Fatal(err) + } + } else { + traceFile = os.Stderr + } +} + +// OverlayFile is the -overlay flag value. +// It names a file containing the JSON for an overlayJSON struct. +var OverlayFile string + +// overlayJSON is the format for the -overlay file. +type overlayJSON struct { + // Replace maps file names observed by Go tools + // to the actual files that should be used when those are read. + // If the actual name is "", the file should appear to be deleted. + Replace map[string]string +} + +// overlay is a list of replacements to be applied, sorted by cmp of the from field. +// cmp sorts the filepath.Separator less than any other byte so that x is always +// just before any children x/a, x/b, and so on, before x.go. (This would not +// be the case with byte-wise sorting, which would produce x, x.go, x/a.) +// The sorting lets us find the relevant overlay entry quickly even if it is for a +// parent of the path being searched. +var overlay []replace + +// A replace represents a single replaced path. +type replace struct { + // from is the old path being replaced. + // It is an absolute path returned by abs. + from string + + // to is the replacement for the old path. + // It is an absolute path returned by abs. + // If it is the empty string, the old path appears deleted. + // Otherwise the old path appears to be the file named by to. + // If to ends in a trailing slash, the overlay code below treats + // it as a directory replacement, akin to a bind mount. + // However, our processing of external overlay maps removes + // such paths by calling abs, except for / or C:\. + to string +} + +var binds []replace + +// Bind makes the virtual file system use dir as if it were mounted at mtpt, +// like Plan 9's “bind” or Linux's “mount --bind”, or like os.Symlink +// but without the symbolic link. +// +// For now, the behavior of using Bind on multiple overlapping +// mountpoints (for example Bind("x", "/a") and Bind("y", "/a/b")) +// is undefined. +func Bind(dir, mtpt string) { + if dir == "" || mtpt == "" { + panic("Bind of empty directory") + } + binds = append(binds, replace{abs(mtpt), abs(dir)}) +} + +// cwd returns the current directory, caching it on first use. +var cwd = sync.OnceValue(cwdOnce) + +func cwdOnce() string { + wd, err := os.Getwd() + if err != nil { + // Note: cannot import base, so using log.Fatal. + log.Fatalf("cannot determine current directory: %v", err) + } + return wd +} + +// abs returns the absolute form of path, for looking up in the overlay map. +// For the most part, this is filepath.Abs and filepath.Clean, +// except that Windows requires special handling, as always. +func abs(path string) string { + if path == "" { + return "" + } + if filepath.IsAbs(path) { + return filepath.Clean(path) + } + + dir := cwd() + if vol := filepath.VolumeName(dir); vol != "" && (path[0] == '\\' || path[0] == '/') { + // path is volume-relative, like `\Temp`. + // Connect to volume name to make absolute path. + // See go.dev/issue/8130. + return filepath.Join(vol, path) + } + + return filepath.Join(dir, path) +} + +func searchcmp(r replace, t string) int { + return cmp(r.from, t) +} + +// info is a summary of the known information about a path +// being looked up in the virtual file system. +type info struct { + abs string + deleted bool + replaced bool + dir bool // must be dir + file bool // must be file + actual string +} + +// stat returns info about the path in the virtual file system. +func stat(path string) info { + apath := abs(path) + if path == "" { + return info{abs: apath, actual: path} + } + + // Apply bind replacements before applying overlay. + replaced := false + for _, r := range binds { + if str.HasFilePathPrefix(apath, r.from) { + // apath is below r.from. + // Replace prefix with r.to and fall through to overlay. + apath = r.to + apath[len(r.from):] + path = apath + replaced = true + break + } + if str.HasFilePathPrefix(r.from, apath) { + // apath is above r.from. + // Synthesize a directory in case one does not exist. + return info{abs: apath, replaced: true, dir: true, actual: path} + } + } + + // Binary search for apath to find the nearest relevant entry in the overlay. + i, ok := slices.BinarySearchFunc(overlay, apath, searchcmp) + if ok { + // Exact match; overlay[i].from == apath. + r := overlay[i] + if r.to == "" { + // Deleted. + return info{abs: apath, deleted: true} + } + if strings.HasSuffix(r.to, string(filepath.Separator)) { + // Replacement ends in slash, denoting directory. + // Note that this is impossible in current overlays since we call abs + // and it strips the trailing slashes. But we could support it in the future. + return info{abs: apath, replaced: true, dir: true, actual: path} + } + // Replaced file. + return info{abs: apath, replaced: true, file: true, actual: r.to} + } + if i < len(overlay) && str.HasFilePathPrefix(overlay[i].from, apath) { + // Replacement for child path; infer existence of parent directory. + return info{abs: apath, replaced: true, dir: true, actual: path} + } + if i > 0 && str.HasFilePathPrefix(apath, overlay[i-1].from) { + // Replacement for parent. + r := overlay[i-1] + if strings.HasSuffix(r.to, string(filepath.Separator)) { + // Parent replaced by directory; apply replacement in our path. + // Note that this is impossible in current overlays since we call abs + // and it strips the trailing slashes. But we could support it in the future. + p := r.to + apath[len(r.from)+1:] + return info{abs: apath, replaced: true, actual: p} + } + // Parent replaced by file; path is deleted. + return info{abs: apath, deleted: true} + } + return info{abs: apath, replaced: replaced, actual: path} +} + +// children returns a sequence of (name, info) +// for all the children of the directory i +// implied by the overlay. +func (i *info) children() iter.Seq2[string, info] { + return func(yield func(string, info) bool) { + // Build list of directory children implied by the binds. + // Binds are not sorted, so just loop over them. + var dirs []string + for _, m := range binds { + if str.HasFilePathPrefix(m.from, i.abs) && m.from != i.abs { + name := m.from[len(i.abs)+1:] + if i := strings.IndexByte(name, filepath.Separator); i >= 0 { + name = name[:i] + } + dirs = append(dirs, name) + } + } + if len(dirs) > 1 { + slices.Sort(dirs) + str.Uniq(&dirs) + } + + // Loop looking for next possible child in sorted overlay, + // which is previous child plus "\x00". + target := i.abs + string(filepath.Separator) + "\x00" + for { + // Search for next child: first entry in overlay >= target. + j, _ := slices.BinarySearchFunc(overlay, target, func(r replace, t string) int { + return cmp(r.from, t) + }) + + Loop: + // Skip subdirectories with deleted children (but not direct deleted children). + for j < len(overlay) && overlay[j].to == "" && str.HasFilePathPrefix(overlay[j].from, i.abs) && strings.Contains(overlay[j].from[len(i.abs)+1:], string(filepath.Separator)) { + j++ + } + if j >= len(overlay) { + // Nothing found at all. + break + } + r := overlay[j] + if !str.HasFilePathPrefix(r.from, i.abs) { + // Next entry in overlay is beyond the directory we want; all done. + break + } + + // Found the next child in the directory. + // Yield it and its info. + name := r.from[len(i.abs)+1:] + actual := r.to + dir := false + if j := strings.IndexByte(name, filepath.Separator); j >= 0 { + // Child is multiple levels down, so name must be a directory, + // and there is no actual replacement. + name = name[:j] + dir = true + actual = "" + } + deleted := !dir && r.to == "" + ci := info{ + abs: filepath.Join(i.abs, name), + deleted: deleted, + replaced: !deleted, + dir: dir || strings.HasSuffix(r.to, string(filepath.Separator)), + actual: actual, + } + for ; len(dirs) > 0 && dirs[0] < name; dirs = dirs[1:] { + if !yield(dirs[0], info{abs: filepath.Join(i.abs, dirs[0]), replaced: true, dir: true}) { + return + } + } + if len(dirs) > 0 && dirs[0] == name { + dirs = dirs[1:] + } + if !yield(name, ci) { + return + } + + // Next target is first name after the one we just returned. + target = ci.abs + "\x00" + + // Optimization: Check whether the very next element + // is the next child. If so, skip the binary search. + if j+1 < len(overlay) && cmp(overlay[j+1].from, target) >= 0 { + j++ + goto Loop + } + } + + for _, dir := range dirs { + if !yield(dir, info{abs: filepath.Join(i.abs, dir), replaced: true, dir: true}) { + return + } + } + } +} + +// Init initializes the overlay, if one is being used. +func Init() error { + if overlay != nil { + // already initialized + return nil + } + + if OverlayFile == "" { + return nil + } + + Trace("ReadFile", OverlayFile) + b, err := os.ReadFile(OverlayFile) + if err != nil { + return fmt.Errorf("reading overlay: %v", err) + } + return initFromJSON(b) +} + +func initFromJSON(js []byte) error { + var ojs overlayJSON + if err := json.Unmarshal(js, &ojs); err != nil { + return fmt.Errorf("parsing overlay JSON: %v", err) + } + + seen := make(map[string]string) + var list []replace + for _, from := range slices.Sorted(maps.Keys(ojs.Replace)) { + if from == "" { + return fmt.Errorf("empty string key in overlay map") + } + afrom := abs(from) + if old, ok := seen[afrom]; ok { + return fmt.Errorf("duplicate paths %s and %s in overlay map", old, from) + } + seen[afrom] = from + list = append(list, replace{from: afrom, to: abs(ojs.Replace[from])}) + } + + slices.SortFunc(list, func(x, y replace) int { return cmp(x.from, y.from) }) + + for i, r := range list { + if r.to == "" { // deleted + continue + } + // have file for r.from; look for child file implying r.from is a directory + prefix := r.from + string(filepath.Separator) + for _, next := range list[i+1:] { + if !strings.HasPrefix(next.from, prefix) { + break + } + if next.to != "" { + // found child file + return fmt.Errorf("inconsistent files %s and %s in overlay map", r.from, next.from) + } + } + } + + overlay = list + return nil +} + +// IsDir returns true if path is a directory on disk or in the +// overlay. +func IsDir(path string) (bool, error) { + Trace("IsDir", path) + + switch info := stat(path); { + case info.dir: + return true, nil + case info.deleted, info.replaced: + return false, nil + } + + info, err := os.Stat(path) + if err != nil { + return false, err + } + return info.IsDir(), nil +} + +// errNotDir is used to communicate from ReadDir to IsGoDir +// that the argument is not a directory, so that IsGoDir doesn't +// return an error. +var errNotDir = errors.New("not a directory") + +// osReadDir is like os.ReadDir corrects the error to be errNotDir +// if the problem is that name exists but is not a directory. +func osReadDir(name string) ([]fs.DirEntry, error) { + dirs, err := os.ReadDir(name) + if err != nil && !os.IsNotExist(err) { + if info, err := os.Stat(name); err == nil && !info.IsDir() { + return nil, &fs.PathError{Op: "ReadDir", Path: name, Err: errNotDir} + } + } + return dirs, err +} + +// ReadDir reads the named directory in the virtual file system. +func ReadDir(name string) ([]fs.DirEntry, error) { + Trace("ReadDir", name) + + info := stat(name) + if info.deleted { + return nil, &fs.PathError{Op: "read", Path: name, Err: fs.ErrNotExist} + } + if !info.replaced { + return osReadDir(name) + } + if info.file { + return nil, &fs.PathError{Op: "read", Path: name, Err: errNotDir} + } + + // Start with normal disk listing. + dirs, err := osReadDir(info.actual) + if err != nil && !os.IsNotExist(err) && !errors.Is(err, errNotDir) { + return nil, err + } + dirErr := err + + // Merge disk listing and overlay entries in map. + all := make(map[string]fs.DirEntry) + for _, d := range dirs { + all[d.Name()] = d + } + for cname, cinfo := range info.children() { + if cinfo.dir { + all[cname] = fs.FileInfoToDirEntry(fakeDir(cname)) + continue + } + if cinfo.deleted { + delete(all, cname) + continue + } + + // Overlay is not allowed to have targets that are directories. + // And we hide symlinks, although it's not clear it helps callers. + cinfo, err := os.Stat(cinfo.actual) + if err != nil { + all[cname] = fs.FileInfoToDirEntry(missingFile(cname)) + continue + } + if cinfo.IsDir() { + return nil, &fs.PathError{Op: "read", Path: name, Err: fmt.Errorf("overlay maps child %s to directory", cname)} + } + all[cname] = fs.FileInfoToDirEntry(fakeFile{cname, cinfo}) + } + + // Rebuild list using same storage. + dirs = dirs[:0] + for _, d := range all { + dirs = append(dirs, d) + } + slices.SortFunc(dirs, func(x, y fs.DirEntry) int { return strings.Compare(x.Name(), y.Name()) }) + + if len(dirs) == 0 { + return nil, dirErr + } + return dirs, nil +} + +// Actual returns the actual file system path for the named file. +// It returns the empty string if name has been deleted in the virtual file system. +func Actual(name string) string { + info := stat(name) + if info.deleted { + return "" + } + if info.dir || info.replaced { + return info.actual + } + return name +} + +// Replaced reports whether the named file has been modified +// in the virtual file system compared to the OS file system. +func Replaced(name string) bool { + info := stat(name) + return info.deleted || info.replaced && !info.dir +} + +// DirContainsReplacement reports whether the named directory is affected by a replacement, +// either because a parent directory has been replaced, it has been replaced, or a file or +// directory under it has been replaced. +// It is meant to be used to detect cases where GOMODCACHE has been replaced. That replacement +// is not supported (GOMODCACHE is meant to be immutable) and the caller will use the +// information to return an error. +func DirContainsReplacement(name string) (string, bool) { + apath := abs(name) + + // Check the overlay using similar logic to what stat uses. + i, ok := slices.BinarySearchFunc(overlay, apath, searchcmp) + if ok { + // The named directory itself has been replaced. + return overlay[i].from, true + } + if i < len(overlay) && str.HasFilePathPrefix(overlay[i].from, apath) { + // A file or directory contained in the named directory has been replaced. + return overlay[i].from, true + } + if i > 0 && str.HasFilePathPrefix(apath, overlay[i-1].from) { + // A parent of the named directory has been replaced. + return overlay[i-1].from, true + } + return "", false +} + +// Open opens the named file in the virtual file system. +// It must be an ordinary file, not a directory. +func Open(name string) (*os.File, error) { + Trace("Open", name) + + bad := func(msg string) (*os.File, error) { + return nil, &fs.PathError{ + Op: "Open", + Path: name, + Err: errors.New(msg), + } + } + + info := stat(name) + if info.deleted { + return bad("deleted in overlay") + } + if info.dir { + return bad("cannot open directory in overlay") + } + if info.replaced { + name = info.actual + } + + return os.Open(name) +} + +// ReadFile reads the named file from the virtual file system +// and returns the contents. +func ReadFile(name string) ([]byte, error) { + f, err := Open(name) + if err != nil { + return nil, err + } + defer f.Close() + + return io.ReadAll(f) +} + +// IsGoDir reports whether the named directory in the virtual file system +// is a directory containing one or more Go source files. +func IsGoDir(name string) (bool, error) { + Trace("IsGoDir", name) + fis, err := ReadDir(name) + if os.IsNotExist(err) || errors.Is(err, errNotDir) { + return false, nil + } + if err != nil { + return false, err + } + + var firstErr error + for _, d := range fis { + if d.IsDir() || !strings.HasSuffix(d.Name(), ".go") { + continue + } + if d.Type().IsRegular() { + return true, nil + } + + // d is a non-directory, non-regular .go file. + // Stat to see if it is a symlink, which we allow. + if actual := Actual(filepath.Join(name, d.Name())); actual != "" { + fi, err := os.Stat(actual) + if err == nil && fi.Mode().IsRegular() { + return true, nil + } + if err != nil && firstErr == nil { + firstErr = err + } + } + } + + // No go files found in directory. + return false, firstErr +} + +// Lstat returns a FileInfo describing the named file in the virtual file system. +// It does not follow symbolic links +func Lstat(name string) (fs.FileInfo, error) { + Trace("Lstat", name) + return overlayStat("lstat", name, os.Lstat) +} + +// Stat returns a FileInfo describing the named file in the virtual file system. +// It follows symbolic links. +func Stat(name string) (fs.FileInfo, error) { + Trace("Stat", name) + return overlayStat("stat", name, os.Stat) +} + +// overlayStat implements lstat or Stat (depending on whether os.Lstat or os.Stat is passed in). +func overlayStat(op, path string, osStat func(string) (fs.FileInfo, error)) (fs.FileInfo, error) { + info := stat(path) + if info.deleted { + return nil, &fs.PathError{Op: op, Path: path, Err: fs.ErrNotExist} + } + if info.dir { + return fakeDir(filepath.Base(path)), nil + } + if info.replaced { + // To keep the data model simple, if the overlay contains a symlink we + // always stat through it (using Stat, not Lstat). That way we don't need to + // worry about the interaction between Lstat and directories: if a symlink + // in the overlay points to a directory, we reject it like an ordinary + // directory. + ainfo, err := os.Stat(info.actual) + if err != nil { + return nil, err + } + if ainfo.IsDir() { + return nil, &fs.PathError{Op: op, Path: path, Err: fmt.Errorf("overlay maps to directory")} + } + return fakeFile{name: filepath.Base(path), real: ainfo}, nil + } + return osStat(path) +} + +// fakeFile provides an fs.FileInfo implementation for an overlaid file, +// so that the file has the name of the overlaid file, but takes all +// other characteristics of the replacement file. +type fakeFile struct { + name string + real fs.FileInfo +} + +func (f fakeFile) Name() string { return f.name } +func (f fakeFile) Size() int64 { return f.real.Size() } +func (f fakeFile) Mode() fs.FileMode { return f.real.Mode() } +func (f fakeFile) ModTime() time.Time { return f.real.ModTime() } +func (f fakeFile) IsDir() bool { return f.real.IsDir() } +func (f fakeFile) Sys() any { return f.real.Sys() } + +func (f fakeFile) String() string { + return fs.FormatFileInfo(f) +} + +// missingFile provides an fs.FileInfo for an overlaid file where the +// destination file in the overlay doesn't exist. It returns zero values +// for the fileInfo methods other than Name, set to the file's name, and Mode +// set to ModeIrregular. +type missingFile string + +func (f missingFile) Name() string { return string(f) } +func (f missingFile) Size() int64 { return 0 } +func (f missingFile) Mode() fs.FileMode { return fs.ModeIrregular } +func (f missingFile) ModTime() time.Time { return time.Unix(0, 0) } +func (f missingFile) IsDir() bool { return false } +func (f missingFile) Sys() any { return nil } + +func (f missingFile) String() string { + return fs.FormatFileInfo(f) +} + +// fakeDir provides an fs.FileInfo implementation for directories that are +// implicitly created by overlaid files. Each directory in the +// path of an overlaid file is considered to exist in the overlay filesystem. +type fakeDir string + +func (f fakeDir) Name() string { return string(f) } +func (f fakeDir) Size() int64 { return 0 } +func (f fakeDir) Mode() fs.FileMode { return fs.ModeDir | 0500 } +func (f fakeDir) ModTime() time.Time { return time.Unix(0, 0) } +func (f fakeDir) IsDir() bool { return true } +func (f fakeDir) Sys() any { return nil } + +func (f fakeDir) String() string { + return fs.FormatFileInfo(f) +} + +func cmp(x, y string) int { + for i := 0; i < len(x) && i < len(y); i++ { + xi := int(x[i]) + yi := int(y[i]) + if xi == filepath.Separator { + xi = -1 + } + if yi == filepath.Separator { + yi = -1 + } + if xi != yi { + return xi - yi + } + } + return len(x) - len(y) +} diff --git a/go/src/cmd/go/internal/fsys/fsys_test.go b/go/src/cmd/go/internal/fsys/fsys_test.go new file mode 100644 index 0000000000000000000000000000000000000000..575eae1e61b8f90f553505c969e5894793d09eee --- /dev/null +++ b/go/src/cmd/go/internal/fsys/fsys_test.go @@ -0,0 +1,1337 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package fsys + +import ( + "errors" + "internal/testenv" + "internal/txtar" + "io" + "io/fs" + "os" + "path/filepath" + "reflect" + "runtime" + "slices" + "strings" + "sync" + "testing" +) + +func resetForTesting() { + cwd = sync.OnceValue(cwdOnce) + overlay = nil + binds = nil +} + +// initOverlay resets the overlay state to reflect the config. +// config should be a text archive string. The comment is the overlay config +// json, and the files, in the archive are laid out in a temp directory +// that cwd is set to. +func initOverlay(t *testing.T, config string) { + t.Helper() + t.Chdir(t.TempDir()) + resetForTesting() + t.Cleanup(resetForTesting) + cwd := cwd() + + a := txtar.Parse([]byte(config)) + for _, f := range a.Files { + name := filepath.Join(cwd, f.Name) + if err := os.MkdirAll(filepath.Dir(name), 0777); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(name, f.Data, 0666); err != nil { + t.Fatal(err) + } + } + + if err := initFromJSON(a.Comment); err != nil { + t.Fatal(err) + } +} + +var statInfoOverlay = `{"Replace": { + "x": "replace/x", + "a/b/c": "replace/c", + "d/e": "" +}}` + +var statInfoTests = []struct { + path string + info info +}{ + {"foo", info{abs: "/tmp/foo", actual: "foo"}}, + {"foo/bar/baz/quux", info{abs: "/tmp/foo/bar/baz/quux", actual: "foo/bar/baz/quux"}}, + {"x", info{abs: "/tmp/x", replaced: true, file: true, actual: "/tmp/replace/x"}}, + {"/tmp/x", info{abs: "/tmp/x", replaced: true, file: true, actual: "/tmp/replace/x"}}, + {"x/y", info{abs: "/tmp/x/y", deleted: true}}, + {"a", info{abs: "/tmp/a", replaced: true, dir: true, actual: "a"}}, + {"a/b", info{abs: "/tmp/a/b", replaced: true, dir: true, actual: "a/b"}}, + {"a/b/c", info{abs: "/tmp/a/b/c", replaced: true, file: true, actual: "/tmp/replace/c"}}, + {"d/e", info{abs: "/tmp/d/e", deleted: true}}, + {"d", info{abs: "/tmp/d", replaced: true, dir: true, actual: "d"}}, +} + +var statInfoChildrenTests = []struct { + path string + children []info +}{ + {"foo", nil}, + {"foo/bar", nil}, + {"foo/bar/baz", nil}, + {"x", nil}, + {"x/y", nil}, + {"a", []info{{abs: "/tmp/a/b", replaced: true, dir: true, actual: ""}}}, + {"a/b", []info{{abs: "/tmp/a/b/c", replaced: true, actual: "/tmp/replace/c"}}}, + {"d", []info{{abs: "/tmp/d/e", deleted: true}}}, + {"d/e", nil}, + {".", []info{ + {abs: "/tmp/a", replaced: true, dir: true, actual: ""}, + // {abs: "/tmp/d", replaced: true, dir: true, actual: ""}, + {abs: "/tmp/x", replaced: true, actual: "/tmp/replace/x"}, + }}, +} + +func TestStatInfo(t *testing.T) { + tmp := "/tmp" + if runtime.GOOS == "windows" { + tmp = `C:\tmp` + } + cwd = sync.OnceValue(func() string { return tmp }) + + winFix := func(s string) string { + if runtime.GOOS == "windows" { + s = strings.ReplaceAll(s, `/tmp`, tmp) // fix tmp + s = strings.ReplaceAll(s, `/`, `\`) // use backslashes + } + return s + } + + overlay := statInfoOverlay + overlay = winFix(overlay) + overlay = strings.ReplaceAll(overlay, `\`, `\\`) // JSON escaping + if err := initFromJSON([]byte(overlay)); err != nil { + t.Fatal(err) + } + + for _, tt := range statInfoTests { + tt.path = winFix(tt.path) + tt.info.abs = winFix(tt.info.abs) + tt.info.actual = winFix(tt.info.actual) + info := stat(tt.path) + if info != tt.info { + t.Errorf("stat(%#q):\nhave %+v\nwant %+v", tt.path, info, tt.info) + } + } + + for _, tt := range statInfoChildrenTests { + tt.path = winFix(tt.path) + for i, info := range tt.children { + info.abs = winFix(info.abs) + info.actual = winFix(info.actual) + tt.children[i] = info + } + parent := stat(winFix(tt.path)) + var children []info + for name, child := range parent.children() { + if name != filepath.Base(child.abs) { + t.Errorf("stat(%#q): child %#q has inconsistent abs %#q", tt.path, name, child.abs) + } + children = append(children, child) + } + slices.SortFunc(children, func(x, y info) int { return cmp(x.abs, y.abs) }) + if !slices.Equal(children, tt.children) { + t.Errorf("stat(%#q) children:\nhave %+v\nwant %+v", tt.path, children, tt.children) + } + } +} + +func TestIsDir(t *testing.T) { + initOverlay(t, ` +{ + "Replace": { + "subdir2/file2.txt": "overlayfiles/subdir2_file2.txt", + "subdir4": "overlayfiles/subdir4", + "subdir3/file3b.txt": "overlayfiles/subdir3_file3b.txt", + "subdir5": "", + "subdir6": "" + } +} +-- subdir1/file1.txt -- + +-- subdir3/file3a.txt -- +33 +-- subdir4/file4.txt -- +444 +-- overlayfiles/subdir2_file2.txt -- +2 +-- overlayfiles/subdir3_file3b.txt -- +66666 +-- overlayfiles/subdir4 -- +x +-- subdir6/file6.txt -- +six +`) + + cwd := cwd() + testCases := []struct { + path string + want, wantErr bool + }{ + {"", true, true}, + {".", true, false}, + {cwd, true, false}, + {cwd + string(filepath.Separator), true, false}, + // subdir1 is only on disk + {filepath.Join(cwd, "subdir1"), true, false}, + {"subdir1", true, false}, + {"subdir1" + string(filepath.Separator), true, false}, + {"subdir1/file1.txt", false, false}, + {"subdir1/doesntexist.txt", false, true}, + {"doesntexist", false, true}, + // subdir2 is only in overlay + {filepath.Join(cwd, "subdir2"), true, false}, + {"subdir2", true, false}, + {"subdir2" + string(filepath.Separator), true, false}, + {"subdir2/file2.txt", false, false}, + {"subdir2/doesntexist.txt", false, true}, + // subdir3 has files on disk and in overlay + {filepath.Join(cwd, "subdir3"), true, false}, + {"subdir3", true, false}, + {"subdir3" + string(filepath.Separator), true, false}, + {"subdir3/file3a.txt", false, false}, + {"subdir3/file3b.txt", false, false}, + {"subdir3/doesntexist.txt", false, true}, + // subdir4 is overlaid with a file + {filepath.Join(cwd, "subdir4"), false, false}, + {"subdir4", false, false}, + {"subdir4" + string(filepath.Separator), false, false}, + {"subdir4/file4.txt", false, false}, + {"subdir4/doesntexist.txt", false, false}, + // subdir5 doesn't exist, and is overlaid with a "delete" entry + {filepath.Join(cwd, "subdir5"), false, false}, + {"subdir5", false, false}, + {"subdir5" + string(filepath.Separator), false, false}, + {"subdir5/file5.txt", false, false}, + {"subdir5/doesntexist.txt", false, false}, + // subdir6 does exist, and is overlaid with a "delete" entry + {filepath.Join(cwd, "subdir6"), false, false}, + {"subdir6", false, false}, + {"subdir6" + string(filepath.Separator), false, false}, + {"subdir6/file6.txt", false, false}, + {"subdir6/doesntexist.txt", false, false}, + } + + for _, tc := range testCases { + got, err := IsDir(tc.path) + if err != nil { + if !tc.wantErr { + t.Errorf("IsDir(%q): got error with string %q, want no error", tc.path, err.Error()) + } + continue + } + if tc.wantErr { + t.Errorf("IsDir(%q): got no error, want error", tc.path) + } + if tc.want != got { + t.Errorf("IsDir(%q) = %v, want %v", tc.path, got, tc.want) + } + } +} + +const readDirOverlay = ` +{ + "Replace": { + "subdir2/file2.txt": "overlayfiles/subdir2_file2.txt", + "subdir4": "overlayfiles/subdir4", + "subdir3/file3b.txt": "overlayfiles/subdir3_file3b.txt", + "subdir5": "", + "subdir6/asubsubdir/afile.txt": "overlayfiles/subdir6_asubsubdir_afile.txt", + "subdir6/asubsubdir/zfile.txt": "overlayfiles/subdir6_asubsubdir_zfile.txt", + "subdir6/zsubsubdir/file.txt": "overlayfiles/subdir6_zsubsubdir_file.txt", + "subdir7/asubsubdir/file.txt": "overlayfiles/subdir7_asubsubdir_file.txt", + "subdir7/zsubsubdir/file.txt": "overlayfiles/subdir7_zsubsubdir_file.txt", + "subdir8/doesntexist": "this_file_doesnt_exist_anywhere", + "other/pointstodir": "overlayfiles/this_is_a_directory", + "parentoverwritten/subdir1": "overlayfiles/parentoverwritten_subdir1", + "subdir9/this_file_is_overlaid.txt": "overlayfiles/subdir9_this_file_is_overlaid.txt", + "subdir10/only_deleted_file.txt": "", + "subdir11/deleted.txt": "", + "subdir11": "overlayfiles/subdir11", + "textfile.txt/file.go": "overlayfiles/textfile_txt_file.go" + } +} +-- subdir1/file1.txt -- + +-- subdir3/file3a.txt -- +33 +-- subdir4/file4.txt -- +444 +-- subdir6/file.txt -- +-- subdir6/asubsubdir/file.txt -- +-- subdir6/anothersubsubdir/file.txt -- +-- subdir9/this_file_is_overlaid.txt -- +-- subdir10/only_deleted_file.txt -- +this will be deleted in overlay +-- subdir11/deleted.txt -- +-- parentoverwritten/subdir1/subdir2/subdir3/file.txt -- +-- textfile.txt -- +this will be overridden by textfile.txt/file.go +-- overlayfiles/subdir2_file2.txt -- +2 +-- overlayfiles/subdir3_file3b.txt -- +66666 +-- overlayfiles/subdir4 -- +x +-- overlayfiles/subdir6_asubsubdir_afile.txt -- +-- overlayfiles/subdir6_asubsubdir_zfile.txt -- +-- overlayfiles/subdir6_zsubsubdir_file.txt -- +-- overlayfiles/subdir7_asubsubdir_file.txt -- +-- overlayfiles/subdir7_zsubsubdir_file.txt -- +-- overlayfiles/parentoverwritten_subdir1 -- +x +-- overlayfiles/subdir9_this_file_is_overlaid.txt -- +99999999 +-- overlayfiles/subdir11 -- +-- overlayfiles/this_is_a_directory/file.txt -- +-- overlayfiles/textfile_txt_file.go -- +x +` + +func TestReadDir(t *testing.T) { + initOverlay(t, readDirOverlay) + + type entry struct { + name string + size int64 + isDir bool + } + + testCases := []struct { + dir string + want []entry + }{ + { + ".", []entry{ + {"other", 0, true}, + {"overlayfiles", 0, true}, + {"parentoverwritten", 0, true}, + {"subdir1", 0, true}, + {"subdir10", 0, true}, + {"subdir11", 0, false}, + {"subdir2", 0, true}, + {"subdir3", 0, true}, + {"subdir4", 2, false}, + // no subdir5. + {"subdir6", 0, true}, + {"subdir7", 0, true}, + {"subdir8", 0, true}, + {"subdir9", 0, true}, + {"textfile.txt", 0, true}, + }, + }, + { + "subdir1", []entry{ + {"file1.txt", 1, false}, + }, + }, + { + "subdir2", []entry{ + {"file2.txt", 2, false}, + }, + }, + { + "subdir3", []entry{ + {"file3a.txt", 3, false}, + {"file3b.txt", 6, false}, + }, + }, + { + "subdir6", []entry{ + {"anothersubsubdir", 0, true}, + {"asubsubdir", 0, true}, + {"file.txt", 0, false}, + {"zsubsubdir", 0, true}, + }, + }, + { + "subdir6/asubsubdir", []entry{ + {"afile.txt", 0, false}, + {"file.txt", 0, false}, + {"zfile.txt", 0, false}, + }, + }, + { + "subdir8", []entry{ + {"doesntexist", 0, false}, // entry is returned even if destination file doesn't exist + }, + }, + { + // check that read dir actually redirects files that already exist + // the original this_file_is_overlaid.txt is empty + "subdir9", []entry{ + {"this_file_is_overlaid.txt", 9, false}, + }, + }, + { + "subdir10", []entry{}, + }, + { + "parentoverwritten", []entry{ + {"subdir1", 2, false}, + }, + }, + { + "textfile.txt", []entry{ + {"file.go", 2, false}, + }, + }, + } + + for _, tc := range testCases { + dir, want := tc.dir, tc.want + infos, err := ReadDir(dir) + if err != nil { + t.Errorf("ReadDir(%q): %v", dir, err) + continue + } + // Sorted diff of want and infos. + for len(infos) > 0 || len(want) > 0 { + switch { + case len(want) == 0 || len(infos) > 0 && infos[0].Name() < want[0].name: + t.Errorf("ReadDir(%q): unexpected entry: %s IsDir=%v", dir, infos[0].Name(), infos[0].IsDir()) + infos = infos[1:] + case len(infos) == 0 || len(want) > 0 && want[0].name < infos[0].Name(): + t.Errorf("ReadDir(%q): missing entry: %s IsDir=%v", dir, want[0].name, want[0].isDir) + want = want[1:] + default: + if infos[0].IsDir() != want[0].isDir { + t.Errorf("ReadDir(%q): %s: IsDir=%v, want IsDir=%v", dir, want[0].name, infos[0].IsDir(), want[0].isDir) + } + infos = infos[1:] + want = want[1:] + } + } + } + + errCases := []string{ + "subdir1/file1.txt", // regular file on disk + "subdir2/file2.txt", // regular file in overlay + "subdir4", // directory overlaid with regular file + "subdir5", // directory deleted in overlay + "parentoverwritten/subdir1/subdir2/subdir3", // parentoverwritten/subdir1 overlaid with regular file + "parentoverwritten/subdir1/subdir2", // parentoverwritten/subdir1 overlaid with regular file + "subdir11", // directory with deleted child, overlaid with regular file + "other/pointstodir", + } + + for _, dir := range errCases { + _, err := ReadDir(dir) + if _, ok := err.(*fs.PathError); !ok { + t.Errorf("ReadDir(%q): err = %T (%v), want fs.PathError", dir, err, err) + } + } +} + +func TestGlob(t *testing.T) { + initOverlay(t, readDirOverlay) + + testCases := []struct { + pattern string + match []string + }{ + { + "*o*", + []string{ + "other", + "overlayfiles", + "parentoverwritten", + }, + }, + { + "subdir2/file2.txt", + []string{ + "subdir2/file2.txt", + }, + }, + { + "*/*.txt", + []string{ + "overlayfiles/subdir2_file2.txt", + "overlayfiles/subdir3_file3b.txt", + "overlayfiles/subdir6_asubsubdir_afile.txt", + "overlayfiles/subdir6_asubsubdir_zfile.txt", + "overlayfiles/subdir6_zsubsubdir_file.txt", + "overlayfiles/subdir7_asubsubdir_file.txt", + "overlayfiles/subdir7_zsubsubdir_file.txt", + "overlayfiles/subdir9_this_file_is_overlaid.txt", + "subdir1/file1.txt", + "subdir2/file2.txt", + "subdir3/file3a.txt", + "subdir3/file3b.txt", + "subdir6/file.txt", + "subdir9/this_file_is_overlaid.txt", + }, + }, + } + + for _, tc := range testCases { + pattern := tc.pattern + match, err := Glob(pattern) + if err != nil { + t.Errorf("Glob(%q): %v", pattern, err) + continue + } + want := tc.match + for i, name := range want { + if name != tc.pattern { + want[i] = filepath.FromSlash(name) + } + } + for len(match) > 0 || len(want) > 0 { + switch { + case len(match) == 0 || len(want) > 0 && want[0] < match[0]: + t.Errorf("Glob(%q): missing match: %s", pattern, want[0]) + want = want[1:] + case len(want) == 0 || len(match) > 0 && match[0] < want[0]: + t.Errorf("Glob(%q): extra match: %s", pattern, match[0]) + match = match[1:] + default: + want = want[1:] + match = match[1:] + } + } + } +} + +func TestActual(t *testing.T) { + initOverlay(t, ` +{ + "Replace": { + "subdir2/file2.txt": "overlayfiles/subdir2_file2.txt", + "subdir3/doesntexist": "this_file_doesnt_exist_anywhere", + "subdir4/this_file_is_overlaid.txt": "overlayfiles/subdir4_this_file_is_overlaid.txt", + "subdir5/deleted.txt": "", + "parentoverwritten/subdir1": "" + } +} +-- subdir1/file1.txt -- +file 1 +-- subdir4/this_file_is_overlaid.txt -- +these contents are replaced by the overlay +-- parentoverwritten/subdir1/subdir2/subdir3/file.txt -- +-- subdir5/deleted.txt -- +deleted +-- overlayfiles/subdir2_file2.txt -- +file 2 +-- overlayfiles/subdir4_this_file_is_overlaid.txt -- +99999999 +`) + + cwd := cwd() + testCases := []struct { + path string + wantPath string + wantOK bool + }{ + {"subdir1/file1.txt", "subdir1/file1.txt", false}, + // Actual returns false for directories + {"subdir2", "subdir2", false}, + {"subdir2/file2.txt", filepath.Join(cwd, "overlayfiles/subdir2_file2.txt"), true}, + // Actual doesn't stat a file to see if it exists, so it happily returns + // the 'to' path and true even if the 'to' path doesn't exist on disk. + {"subdir3/doesntexist", filepath.Join(cwd, "this_file_doesnt_exist_anywhere"), true}, + // Like the subdir2/file2.txt case above, but subdir4 exists on disk, but subdir2 does not. + {"subdir4/this_file_is_overlaid.txt", filepath.Join(cwd, "overlayfiles/subdir4_this_file_is_overlaid.txt"), true}, + {"subdir5", "subdir5", false}, + {"subdir5/deleted.txt", "", true}, + } + + for _, tc := range testCases { + path := Actual(tc.path) + ok := Replaced(tc.path) + + if path != tc.wantPath { + t.Errorf("Actual(%q) = %q, want %q", tc.path, path, tc.wantPath) + } + if ok != tc.wantOK { + t.Errorf("Replaced(%q) = %v, want %v", tc.path, ok, tc.wantOK) + } + } +} + +func TestOpen(t *testing.T) { + initOverlay(t, ` +{ + "Replace": { + "subdir2/file2.txt": "overlayfiles/subdir2_file2.txt", + "subdir3/doesntexist": "this_file_doesnt_exist_anywhere", + "subdir4/this_file_is_overlaid.txt": "overlayfiles/subdir4_this_file_is_overlaid.txt", + "subdir5/deleted.txt": "", + "parentoverwritten/subdir1": "", + "childoverlay/subdir1.txt/child.txt": "overlayfiles/child.txt", + "subdir11/deleted.txt": "", + "subdir11": "overlayfiles/subdir11", + "parentdeleted": "", + "parentdeleted/file.txt": "overlayfiles/parentdeleted_file.txt" + } +} +-- subdir11/deleted.txt -- +-- subdir1/file1.txt -- +file 1 +-- subdir4/this_file_is_overlaid.txt -- +these contents are replaced by the overlay +-- parentoverwritten/subdir1/subdir2/subdir3/file.txt -- +-- childoverlay/subdir1.txt -- +this file doesn't exist because the path +childoverlay/subdir1.txt/child.txt is in the overlay +-- subdir5/deleted.txt -- +deleted +-- parentdeleted -- +this will be deleted so that parentdeleted/file.txt can exist +-- overlayfiles/subdir2_file2.txt -- +file 2 +-- overlayfiles/subdir4_this_file_is_overlaid.txt -- +99999999 +-- overlayfiles/child.txt -- +-- overlayfiles/subdir11 -- +11 +-- overlayfiles/parentdeleted_file.txt -- +this can exist because the parent directory is deleted +`) + + testCases := []struct { + path string + wantContents string + isErr bool + }{ + {"subdir1/file1.txt", "file 1\n", false}, + {"subdir2/file2.txt", "file 2\n", false}, + {"subdir3/doesntexist", "", true}, + {"subdir4/this_file_is_overlaid.txt", "99999999\n", false}, + {"subdir5/deleted.txt", "", true}, + {"parentoverwritten/subdir1/subdir2/subdir3/file.txt", "", true}, + {"childoverlay/subdir1.txt", "", true}, + {"subdir11", "11\n", false}, + {"parentdeleted/file.txt", "this can exist because the parent directory is deleted\n", false}, + } + + for _, tc := range testCases { + f, err := Open(tc.path) + if tc.isErr { + if err == nil { + f.Close() + t.Errorf("Open(%q): got no error, but want error", tc.path) + } + continue + } + if err != nil { + t.Errorf("Open(%q): got error %v, want nil", tc.path, err) + continue + } + contents, err := io.ReadAll(f) + if err != nil { + t.Errorf("unexpected error reading contents of file: %v", err) + } + if string(contents) != tc.wantContents { + t.Errorf("contents of file opened with Open(%q): got %q, want %q", + tc.path, contents, tc.wantContents) + } + f.Close() + } +} + +func TestIsGoDir(t *testing.T) { + initOverlay(t, ` +{ + "Replace": { + "goinoverlay/file.go": "dummy", + "directory/removed/by/file": "dummy", + "directory_with_go_dir/dir.go/file.txt": "dummy", + "otherdirectory/deleted.go": "", + "nonexistentdirectory/deleted.go": "", + "textfile.txt/file.go": "dummy" + } +} +-- dummy -- +a destination file for the overlay entries to point to +contents don't matter for this test +-- nogo/file.txt -- +-- goondisk/file.go -- +-- goinoverlay/file.txt -- +-- directory/removed/by/file/in/overlay/file.go -- +-- otherdirectory/deleted.go -- +-- textfile.txt -- +`) + + testCases := []struct { + dir string + want bool + wantErr bool + }{ + {"nogo", false, false}, + {"goondisk", true, false}, + {"goinoverlay", true, false}, + {"directory/removed/by/file/in/overlay", false, false}, + {"directory_with_go_dir", false, false}, + {"otherdirectory", false, false}, + {"nonexistentdirectory", false, false}, + {"textfile.txt", true, false}, + } + + for _, tc := range testCases { + got, gotErr := IsGoDir(tc.dir) + if tc.wantErr { + if gotErr == nil { + t.Errorf("IsGoDir(%q): got %v, %v; want non-nil error", tc.dir, got, gotErr) + } + continue + } + if gotErr != nil { + t.Errorf("IsGoDir(%q): got %v, %v; want nil error", tc.dir, got, gotErr) + } + if got != tc.want { + t.Errorf("IsGoDir(%q) = %v; want %v", tc.dir, got, tc.want) + } + } +} + +func TestWalk(t *testing.T) { + // The root of the walk must be a name with an actual basename, not just ".". + // Walk uses Lstat to obtain the name of the root, and Lstat on platforms + // other than Plan 9 reports the name "." instead of the actual base name of + // the directory. (See https://golang.org/issue/42115.) + + type file struct { + path string + name string + size int64 + mode fs.FileMode + isDir bool + } + testCases := []struct { + name string + overlay string + root string + wantFiles []file + }{ + {"no overlay", ` +{} +-- dir/file.txt -- +`, + "dir", + []file{ + {"dir", "dir", 0, fs.ModeDir | 0700, true}, + {"dir/file.txt", "file.txt", 0, 0600, false}, + }, + }, + {"overlay with different file", ` +{ + "Replace": { + "dir/file.txt": "dir/other.txt" + } +} +-- dir/file.txt -- +-- dir/other.txt -- +contents of other file +`, + "dir", + []file{ + {"dir", "dir", 0, fs.ModeDir | 0500, true}, + {"dir/file.txt", "file.txt", 23, 0600, false}, + {"dir/other.txt", "other.txt", 23, 0600, false}, + }, + }, + {"overlay with new file", ` +{ + "Replace": { + "dir/file.txt": "dir/other.txt" + } +} +-- dir/other.txt -- +contents of other file +`, + "dir", + []file{ + {"dir", "dir", 0, fs.ModeDir | 0500, true}, + {"dir/file.txt", "file.txt", 23, 0600, false}, + {"dir/other.txt", "other.txt", 23, 0600, false}, + }, + }, + {"overlay with new directory", ` +{ + "Replace": { + "dir/subdir/file.txt": "dir/other.txt" + } +} +-- dir/other.txt -- +contents of other file +`, + "dir", + []file{ + {"dir", "dir", 0, fs.ModeDir | 0500, true}, + {"dir/other.txt", "other.txt", 23, 0600, false}, + {"dir/subdir", "subdir", 0, fs.ModeDir | 0500, true}, + {"dir/subdir/file.txt", "file.txt", 23, 0600, false}, + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + initOverlay(t, tc.overlay) + + var got []file + WalkDir(tc.root, func(path string, d fs.DirEntry, err error) error { + info, err := d.Info() + if err != nil { + t.Fatal(err) + } + if info.Name() != d.Name() { + t.Errorf("walk %s: d.Name() = %q, but info.Name() = %q", path, d.Name(), info.Name()) + } + if info.IsDir() != d.IsDir() { + t.Errorf("walk %s: d.IsDir() = %v, but info.IsDir() = %v", path, d.IsDir(), info.IsDir()) + } + if info.Mode().Type() != d.Type() { + t.Errorf("walk %s: d.Type() = %v, but info.Mode().Type() = %v", path, d.Type(), info.Mode().Type()) + } + got = append(got, file{path, d.Name(), info.Size(), info.Mode(), d.IsDir()}) + return nil + }) + + if len(got) != len(tc.wantFiles) { + t.Errorf("Walk: saw %#v in walk; want %#v", got, tc.wantFiles) + } + for i := 0; i < len(got) && i < len(tc.wantFiles); i++ { + wantPath := filepath.FromSlash(tc.wantFiles[i].path) + if got[i].path != wantPath { + t.Errorf("walk #%d: path = %q, want %q", i, got[i].path, wantPath) + } + if got[i].name != tc.wantFiles[i].name { + t.Errorf("walk %s: Name = %q, want %q", got[i].path, got[i].name, tc.wantFiles[i].name) + } + if got[i].mode&(fs.ModeDir|0700) != tc.wantFiles[i].mode { + t.Errorf("walk %s: Mode = %q, want %q", got[i].path, got[i].mode&(fs.ModeDir|0700), tc.wantFiles[i].mode) + } + if got[i].isDir != tc.wantFiles[i].isDir { + t.Errorf("walk %s: IsDir = %v, want %v", got[i].path, got[i].isDir, tc.wantFiles[i].isDir) + } + } + }) + } +} + +func TestWalkSkipDir(t *testing.T) { + initOverlay(t, ` +{ + "Replace": { + "dir/skip/file.go": "dummy.txt", + "dir/dontskip/file.go": "dummy.txt", + "dir/dontskip/skip/file.go": "dummy.txt" + } +} +-- dummy.txt -- +`) + + var seen []string + WalkDir("dir", func(path string, d fs.DirEntry, err error) error { + seen = append(seen, filepath.ToSlash(path)) + if d.Name() == "skip" { + return filepath.SkipDir + } + return nil + }) + + wantSeen := []string{"dir", "dir/dontskip", "dir/dontskip/file.go", "dir/dontskip/skip", "dir/skip"} + + if len(seen) != len(wantSeen) { + t.Errorf("paths seen in walk: got %v entries; want %v entries", len(seen), len(wantSeen)) + } + + for i := 0; i < len(seen) && i < len(wantSeen); i++ { + if seen[i] != wantSeen[i] { + t.Errorf("path #%v seen walking tree: want %q, got %q", i, seen[i], wantSeen[i]) + } + } +} + +func TestWalkSkipAll(t *testing.T) { + initOverlay(t, ` +{ + "Replace": { + "dir/subdir1/foo1": "dummy.txt", + "dir/subdir1/foo2": "dummy.txt", + "dir/subdir1/foo3": "dummy.txt", + "dir/subdir2/foo4": "dummy.txt", + "dir/zzlast": "dummy.txt" + } +} +-- dummy.txt -- +`) + + var seen []string + WalkDir("dir", func(path string, d fs.DirEntry, err error) error { + seen = append(seen, filepath.ToSlash(path)) + if d.Name() == "foo2" { + return filepath.SkipAll + } + return nil + }) + + wantSeen := []string{"dir", "dir/subdir1", "dir/subdir1/foo1", "dir/subdir1/foo2"} + + if len(seen) != len(wantSeen) { + t.Errorf("paths seen in walk: got %v entries; want %v entries", len(seen), len(wantSeen)) + } + + for i := 0; i < len(seen) && i < len(wantSeen); i++ { + if seen[i] != wantSeen[i] { + t.Errorf("path %#v seen walking tree: got %q, want %q", i, seen[i], wantSeen[i]) + } + } +} + +func TestWalkError(t *testing.T) { + initOverlay(t, "{}") + + alreadyCalled := false + err := WalkDir("foo", func(path string, d fs.DirEntry, err error) error { + if alreadyCalled { + t.Fatal("expected walk function to be called exactly once, but it was called more than once") + } + alreadyCalled = true + return errors.New("returned from function") + }) + if !alreadyCalled { + t.Fatal("expected walk function to be called exactly once, but it was never called") + + } + if err == nil { + t.Fatalf("Walk: got no error, want error") + } + if err.Error() != "returned from function" { + t.Fatalf("Walk: got error %v, want \"returned from function\" error", err) + } +} + +func TestWalkSymlink(t *testing.T) { + testenv.MustHaveSymlink(t) + + initOverlay(t, `{ + "Replace": {"overlay_symlink/file": "symlink/file"} +} +-- dir/file --`) + + // Create symlink + if err := os.Symlink("dir", "symlink"); err != nil { + t.Error(err) + } + + testCases := []struct { + name string + dir string + wantFiles []string + }{ + {"control", "dir", []string{"dir", filepath.Join("dir", "file")}}, + // ensure Walk doesn't walk into the directory pointed to by the symlink + // (because it's supposed to use Lstat instead of Stat). + {"symlink_to_dir", "symlink", []string{"symlink"}}, + {"overlay_to_symlink_to_dir", "overlay_symlink", []string{"overlay_symlink", filepath.Join("overlay_symlink", "file")}}, + + // However, adding filepath.Separator should cause the link to be resolved. + {"symlink_with_slash", "symlink" + string(filepath.Separator), []string{"symlink" + string(filepath.Separator), filepath.Join("symlink", "file")}}, + {"overlay_to_symlink_to_dir", "overlay_symlink" + string(filepath.Separator), []string{"overlay_symlink" + string(filepath.Separator), filepath.Join("overlay_symlink", "file")}}, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + var got []string + + err := WalkDir(tc.dir, func(path string, d fs.DirEntry, err error) error { + t.Logf("walk %q", path) + got = append(got, path) + if err != nil { + t.Errorf("walkfn: got non nil err argument: %v, want nil err argument", err) + } + return nil + }) + if err != nil { + t.Errorf("Walk: got error %q, want nil", err) + } + + if !reflect.DeepEqual(got, tc.wantFiles) { + t.Errorf("files examined by walk: got %v, want %v", got, tc.wantFiles) + } + }) + } + +} + +func TestLstat(t *testing.T) { + type file struct { + name string + size int64 + mode fs.FileMode // mode & (fs.ModeDir|0x700): only check 'user' permissions + isDir bool + } + + testCases := []struct { + name string + overlay string + path string + + want file + wantErr bool + }{ + { + "regular_file", + `{} +-- file.txt -- +contents`, + "file.txt", + file{"file.txt", 9, 0600, false}, + false, + }, + { + "new_file_in_overlay", + `{"Replace": {"file.txt": "dummy.txt"}} +-- dummy.txt -- +contents`, + "file.txt", + file{"file.txt", 9, 0600, false}, + false, + }, + { + "file_replaced_in_overlay", + `{"Replace": {"file.txt": "dummy.txt"}} +-- file.txt -- +-- dummy.txt -- +contents`, + "file.txt", + file{"file.txt", 9, 0600, false}, + false, + }, + { + "file_cant_exist", + `{"Replace": {"deleted": "dummy.txt"}} +-- deleted/file.txt -- +-- dummy.txt -- +`, + "deleted/file.txt", + file{}, + true, + }, + { + "deleted", + `{"Replace": {"deleted": ""}} +-- deleted -- +`, + "deleted", + file{}, + true, + }, + { + "dir_on_disk", + `{} +-- dir/foo.txt -- +`, + "dir", + file{"dir", 0, 0700 | fs.ModeDir, true}, + false, + }, + { + "dir_in_overlay", + `{"Replace": {"dir/file.txt": "dummy.txt"}} +-- dummy.txt -- +`, + "dir", + file{"dir", 0, 0500 | fs.ModeDir, true}, + false, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + initOverlay(t, tc.overlay) + got, err := Lstat(tc.path) + if tc.wantErr { + if err == nil { + t.Errorf("lstat(%q): got no error, want error", tc.path) + } + return + } + if err != nil { + t.Fatalf("lstat(%q): got error %v, want no error", tc.path, err) + } + if got.Name() != tc.want.name { + t.Errorf("lstat(%q).Name(): got %q, want %q", tc.path, got.Name(), tc.want.name) + } + if got.Mode()&(fs.ModeDir|0700) != tc.want.mode { + t.Errorf("lstat(%q).Mode()&(fs.ModeDir|0700): got %v, want %v", tc.path, got.Mode()&(fs.ModeDir|0700), tc.want.mode) + } + if got.IsDir() != tc.want.isDir { + t.Errorf("lstat(%q).IsDir(): got %v, want %v", tc.path, got.IsDir(), tc.want.isDir) + } + if tc.want.isDir { + return // don't check size for directories + } + if got.Size() != tc.want.size { + t.Errorf("lstat(%q).Size(): got %v, want %v", tc.path, got.Size(), tc.want.size) + } + }) + } +} + +func TestStat(t *testing.T) { + testenv.MustHaveSymlink(t) + + type file struct { + name string + size int64 + mode os.FileMode // mode & (os.ModeDir|0x700): only check 'user' permissions + isDir bool + } + + testCases := []struct { + name string + overlay string + path string + + want file + wantErr bool + }{ + { + "regular_file", + `{} +-- file.txt -- +contents`, + "file.txt", + file{"file.txt", 9, 0600, false}, + false, + }, + { + "new_file_in_overlay", + `{"Replace": {"file.txt": "dummy.txt"}} +-- dummy.txt -- +contents`, + "file.txt", + file{"file.txt", 9, 0600, false}, + false, + }, + { + "file_replaced_in_overlay", + `{"Replace": {"file.txt": "dummy.txt"}} +-- file.txt -- +-- dummy.txt -- +contents`, + "file.txt", + file{"file.txt", 9, 0600, false}, + false, + }, + { + "file_cant_exist", + `{"Replace": {"deleted": "dummy.txt"}} +-- deleted/file.txt -- +-- dummy.txt -- +`, + "deleted/file.txt", + file{}, + true, + }, + { + "deleted", + `{"Replace": {"deleted": ""}} +-- deleted -- +`, + "deleted", + file{}, + true, + }, + { + "dir_on_disk", + `{} +-- dir/foo.txt -- +`, + "dir", + file{"dir", 0, 0700 | os.ModeDir, true}, + false, + }, + { + "dir_in_overlay", + `{"Replace": {"dir/file.txt": "dummy.txt"}} +-- dummy.txt -- +`, + "dir", + file{"dir", 0, 0500 | os.ModeDir, true}, + false, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + initOverlay(t, tc.overlay) + got, err := Stat(tc.path) + if tc.wantErr { + if err == nil { + t.Errorf("Stat(%q): got no error, want error", tc.path) + } + return + } + if err != nil { + t.Fatalf("Stat(%q): got error %v, want no error", tc.path, err) + } + if got.Name() != tc.want.name { + t.Errorf("Stat(%q).Name(): got %q, want %q", tc.path, got.Name(), tc.want.name) + } + if got.Mode()&(os.ModeDir|0700) != tc.want.mode { + t.Errorf("Stat(%q).Mode()&(os.ModeDir|0700): got %v, want %v", tc.path, got.Mode()&(os.ModeDir|0700), tc.want.mode) + } + if got.IsDir() != tc.want.isDir { + t.Errorf("Stat(%q).IsDir(): got %v, want %v", tc.path, got.IsDir(), tc.want.isDir) + } + if tc.want.isDir { + return // don't check size for directories + } + if got.Size() != tc.want.size { + t.Errorf("Stat(%q).Size(): got %v, want %v", tc.path, got.Size(), tc.want.size) + } + }) + } +} + +func TestStatSymlink(t *testing.T) { + testenv.MustHaveSymlink(t) + + initOverlay(t, `{ + "Replace": {"file.go": "symlink"} +} +-- to.go -- +0123456789 +`) + + // Create symlink + if err := os.Symlink("to.go", "symlink"); err != nil { + t.Error(err) + } + + f := "file.go" + fi, err := Stat(f) + if err != nil { + t.Errorf("Stat(%q): got error %q, want nil error", f, err) + } + + if !fi.Mode().IsRegular() { + t.Errorf("Stat(%q).Mode(): got %v, want regular mode", f, fi.Mode()) + } + + if fi.Size() != 11 { + t.Errorf("Stat(%q).Size(): got %v, want 11", f, fi.Size()) + } +} + +func TestBindOverlay(t *testing.T) { + initOverlay(t, `{"Replace": {"mtpt/x.go": "xx.go"}} +-- mtpt/x.go -- +mtpt/x.go +-- mtpt/y.go -- +mtpt/y.go +-- mtpt2/x.go -- +mtpt/x.go +-- replaced/x.go -- +replaced/x.go +-- replaced/x/y/z.go -- +replaced/x/y/z.go +-- xx.go -- +xx.go +`) + + testReadFile(t, "mtpt/x.go", "xx.go\n") + + Bind("replaced", "mtpt") + testReadFile(t, "mtpt/x.go", "replaced/x.go\n") + testReadDir(t, "mtpt/x", "y/") + testReadDir(t, "mtpt/x/y", "z.go") + testReadFile(t, "mtpt/x/y/z.go", "replaced/x/y/z.go\n") + testReadFile(t, "mtpt/y.go", "ERROR") + + Bind("replaced", "mtpt2/a/b") + testReadDir(t, "mtpt2", "a/", "x.go") + testReadDir(t, "mtpt2/a", "b/") + testReadDir(t, "mtpt2/a/b", "x/", "x.go") + testReadFile(t, "mtpt2/a/b/x.go", "replaced/x.go\n") +} + +var badOverlayTests = []struct { + json string + err string +}{ + {`{`, + "parsing overlay JSON: unexpected end of JSON input"}, + {`{"Replace": {"":"a"}}`, + "empty string key in overlay map"}, + {`{"Replace": {"/tmp/x": "y", "x": "y"}}`, + `duplicate paths /tmp/x and x in overlay map`}, + {`{"Replace": {"/tmp/x/z": "z", "x":"y"}}`, + `inconsistent files /tmp/x and /tmp/x/z in overlay map`}, + {`{"Replace": {"/tmp/x/z/z2": "z", "x":"y"}}`, + `inconsistent files /tmp/x and /tmp/x/z/z2 in overlay map`}, + {`{"Replace": {"/tmp/x": "y", "x/z/z2": "z"}}`, + `inconsistent files /tmp/x and /tmp/x/z/z2 in overlay map`}, +} + +func TestBadOverlay(t *testing.T) { + tmp := "/tmp" + if runtime.GOOS == "windows" { + tmp = `C:\tmp` + } + cwd = sync.OnceValue(func() string { return tmp }) + defer resetForTesting() + + for i, tt := range badOverlayTests { + if runtime.GOOS == "windows" { + tt.json = strings.ReplaceAll(tt.json, `/tmp`, tmp) // fix tmp + tt.json = strings.ReplaceAll(tt.json, `/`, `\`) // use backslashes + tt.json = strings.ReplaceAll(tt.json, `\`, `\\`) // JSON escaping + tt.err = strings.ReplaceAll(tt.err, `/tmp`, tmp) // fix tmp + tt.err = strings.ReplaceAll(tt.err, `/`, `\`) // use backslashes + } + err := initFromJSON([]byte(tt.json)) + if err == nil || err.Error() != tt.err { + t.Errorf("#%d: err=%v, want %q", i, err, tt.err) + } + } +} + +func testReadFile(t *testing.T, name string, want string) { + t.Helper() + data, err := ReadFile(name) + if want == "ERROR" { + if data != nil || err == nil { + t.Errorf("ReadFile(%q) = %q, %v, want nil, error", name, data, err) + } + return + } + if string(data) != want || err != nil { + t.Errorf("ReadFile(%q) = %q, %v, want %q, nil", name, data, err, want) + } +} + +func testReadDir(t *testing.T, name string, want ...string) { + t.Helper() + dirs, err := ReadDir(name) + var names []string + for _, d := range dirs { + name := d.Name() + if d.IsDir() { + name += "/" + } + names = append(names, name) + } + if !slices.Equal(names, want) || err != nil { + t.Errorf("ReadDir(%q) = %q, %v, want %q, nil", name, names, err, want) + } +} diff --git a/go/src/cmd/go/internal/fsys/glob.go b/go/src/cmd/go/internal/fsys/glob.go new file mode 100644 index 0000000000000000000000000000000000000000..082adc7b1f0ba622038e90d025ec2d1ade43b4d5 --- /dev/null +++ b/go/src/cmd/go/internal/fsys/glob.go @@ -0,0 +1,178 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package fsys + +import ( + "os" + "path/filepath" + "runtime" + "sort" + "strings" +) + +// Copied from path/filepath. + +// Glob is like filepath.Glob but uses the overlay file system. +func Glob(pattern string) (matches []string, err error) { + Trace("Glob", pattern) + // Check pattern is well-formed. + if _, err := filepath.Match(pattern, ""); err != nil { + return nil, err + } + if !hasMeta(pattern) { + if _, err = Lstat(pattern); err != nil { + return nil, nil + } + return []string{pattern}, nil + } + + dir, file := filepath.Split(pattern) + volumeLen := 0 + if runtime.GOOS == "windows" { + volumeLen, dir = cleanGlobPathWindows(dir) + } else { + dir = cleanGlobPath(dir) + } + + if !hasMeta(dir[volumeLen:]) { + return glob(dir, file, nil) + } + + // Prevent infinite recursion. See issue 15879. + if dir == pattern { + return nil, filepath.ErrBadPattern + } + + var m []string + m, err = Glob(dir) + if err != nil { + return + } + for _, d := range m { + matches, err = glob(d, file, matches) + if err != nil { + return + } + } + return +} + +// cleanGlobPath prepares path for glob matching. +func cleanGlobPath(path string) string { + switch path { + case "": + return "." + case string(filepath.Separator): + // do nothing to the path + return path + default: + return path[0 : len(path)-1] // chop off trailing separator + } +} + +func volumeNameLen(path string) int { + isSlash := func(c uint8) bool { + return c == '\\' || c == '/' + } + if len(path) < 2 { + return 0 + } + // with drive letter + c := path[0] + if path[1] == ':' && ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') { + return 2 + } + // is it UNC? https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file + if l := len(path); l >= 5 && isSlash(path[0]) && isSlash(path[1]) && + !isSlash(path[2]) && path[2] != '.' { + // first, leading `\\` and next shouldn't be `\`. its server name. + for n := 3; n < l-1; n++ { + // second, next '\' shouldn't be repeated. + if isSlash(path[n]) { + n++ + // third, following something characters. its share name. + if !isSlash(path[n]) { + if path[n] == '.' { + break + } + for ; n < l; n++ { + if isSlash(path[n]) { + break + } + } + return n + } + break + } + } + } + return 0 +} + +// cleanGlobPathWindows is windows version of cleanGlobPath. +func cleanGlobPathWindows(path string) (prefixLen int, cleaned string) { + vollen := volumeNameLen(path) + switch { + case path == "": + return 0, "." + case vollen+1 == len(path) && os.IsPathSeparator(path[len(path)-1]): // /, \, C:\ and C:/ + // do nothing to the path + return vollen + 1, path + case vollen == len(path) && len(path) == 2: // C: + return vollen, path + "." // convert C: into C:. + default: + if vollen >= len(path) { + vollen = len(path) - 1 + } + return vollen, path[0 : len(path)-1] // chop off trailing separator + } +} + +// glob searches for files matching pattern in the directory dir +// and appends them to matches. If the directory cannot be +// opened, it returns the existing matches. New matches are +// added in lexicographical order. +func glob(dir, pattern string, matches []string) (m []string, e error) { + m = matches + fi, err := Stat(dir) + if err != nil { + return // ignore I/O error + } + if !fi.IsDir() { + return // ignore I/O error + } + + list, err := ReadDir(dir) + if err != nil { + return // ignore I/O error + } + + names := make([]string, 0, len(list)) + for _, info := range list { + names = append(names, info.Name()) + } + sort.Strings(names) + + for _, n := range names { + matched, err := filepath.Match(pattern, n) + if err != nil { + return m, err + } + if matched { + m = append(m, filepath.Join(dir, n)) + } + } + return +} + +// hasMeta reports whether path contains any of the magic characters +// recognized by filepath.Match. +func hasMeta(path string) bool { + magicChars := `*?[` + if runtime.GOOS != "windows" { + magicChars = `*?[\` + } + return strings.ContainsAny(path, magicChars) +} diff --git a/go/src/cmd/go/internal/fsys/walk.go b/go/src/cmd/go/internal/fsys/walk.go new file mode 100644 index 0000000000000000000000000000000000000000..2fcaa948a7858a69dd90b073bd7dc9fc163fae2d --- /dev/null +++ b/go/src/cmd/go/internal/fsys/walk.go @@ -0,0 +1,60 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package fsys + +import ( + "io/fs" + "path/filepath" +) + +// Copied from path/filepath. + +// WalkDir is like filepath.WalkDir but over the virtual file system. +func WalkDir(root string, fn fs.WalkDirFunc) error { + info, err := Lstat(root) + if err != nil { + err = fn(root, nil, err) + } else { + err = walkDir(root, fs.FileInfoToDirEntry(info), fn) + } + if err == filepath.SkipDir || err == filepath.SkipAll { + return nil + } + return err +} + +// walkDir recursively descends path, calling walkDirFn. +func walkDir(path string, d fs.DirEntry, walkDirFn fs.WalkDirFunc) error { + if err := walkDirFn(path, d, nil); err != nil || !d.IsDir() { + if err == filepath.SkipDir && d.IsDir() { + // Successfully skipped directory. + err = nil + } + return err + } + + dirs, err := ReadDir(path) + if err != nil { + // Second call, to report ReadDir error. + err = walkDirFn(path, d, err) + if err != nil { + if err == filepath.SkipDir && d.IsDir() { + err = nil + } + return err + } + } + + for _, d1 := range dirs { + path1 := filepath.Join(path, d1.Name()) + if err := walkDir(path1, d1, walkDirFn); err != nil { + if err == filepath.SkipDir { + break + } + return err + } + } + return nil +} diff --git a/go/src/cmd/go/internal/generate/generate.go b/go/src/cmd/go/internal/generate/generate.go new file mode 100644 index 0000000000000000000000000000000000000000..59142859c1f445ffe475f8205e24745a3f18c911 --- /dev/null +++ b/go/src/cmd/go/internal/generate/generate.go @@ -0,0 +1,512 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package generate implements the “go generate” command. +package generate + +import ( + "bufio" + "bytes" + "context" + "fmt" + "go/parser" + "go/token" + "io" + "log" + "os" + "os/exec" + "path/filepath" + "regexp" + "slices" + "strconv" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/load" + "cmd/go/internal/modload" + "cmd/go/internal/str" + "cmd/go/internal/work" + "cmd/internal/pathcache" +) + +var CmdGenerate = &base.Command{ + Run: runGenerate, + UsageLine: "go generate [-run regexp] [-n] [-v] [-x] [build flags] [file.go... | packages]", + Short: "generate Go files by processing source", + Long: ` +Generate runs commands described by directives within existing +files. Those commands can run any process but the intent is to +create or update Go source files. + +Go generate is never run automatically by go build, go test, +and so on. It must be run explicitly. + +Go generate scans the file for directives, which are lines of +the form, + + //go:generate command argument... + +(note: no leading spaces and no space in "//go") where command +is the generator to be run, corresponding to an executable file +that can be run locally. It must either be in the shell path +(gofmt), a fully qualified path (/usr/you/bin/mytool), or a +command alias, described below. + +Note that go generate does not parse the file, so lines that look +like directives in comments or multiline strings will be treated +as directives. + +The arguments to the directive are space-separated tokens or +double-quoted strings passed to the generator as individual +arguments when it is run. + +Quoted strings use Go syntax and are evaluated before execution; a +quoted string appears as a single argument to the generator. + +To convey to humans and machine tools that code is generated, +generated source should have a line that matches the following +regular expression (in Go syntax): + + ^// Code generated .* DO NOT EDIT\.$ + +This line must appear before the first non-comment, non-blank +text in the file. + +Go generate sets several variables when it runs the generator: + + $GOARCH + The execution architecture (arm, amd64, etc.) + $GOOS + The execution operating system (linux, windows, etc.) + $GOFILE + The base name of the file. + $GOLINE + The line number of the directive in the source file. + $GOPACKAGE + The name of the package of the file containing the directive. + $GOROOT + The GOROOT directory for the 'go' command that invoked the + generator, containing the Go toolchain and standard library. + $DOLLAR + A dollar sign. + $PATH + The $PATH of the parent process, with $GOROOT/bin + placed at the beginning. This causes generators + that execute 'go' commands to use the same 'go' + as the parent 'go generate' command. + +Other than variable substitution and quoted-string evaluation, no +special processing such as "globbing" is performed on the command +line. + +As a last step before running the command, any invocations of any +environment variables with alphanumeric names, such as $GOFILE or +$HOME, are expanded throughout the command line. The syntax for +variable expansion is $NAME on all operating systems. Due to the +order of evaluation, variables are expanded even inside quoted +strings. If the variable NAME is not set, $NAME expands to the +empty string. + +A directive of the form, + + //go:generate -command xxx args... + +specifies, for the remainder of this source file only, that the +string xxx represents the command identified by the arguments. This +can be used to create aliases or to handle multiword generators. +For example, + + //go:generate -command foo go tool foo + +specifies that the command "foo" represents the generator +"go tool foo". + +Generate processes packages in the order given on the command line, +one at a time. If the command line lists .go files from a single directory, +they are treated as a single package. Within a package, generate processes the +source files in a package in file name order, one at a time. Within +a source file, generate runs generators in the order they appear +in the file, one at a time. The go generate tool also sets the build +tag "generate" so that files may be examined by go generate but ignored +during build. + +For packages with invalid code, generate processes only source files with a +valid package clause. + +If any generator returns an error exit status, "go generate" skips +all further processing for that package. + +The generator is run in the package's source directory. + +Go generate accepts two specific flags: + + -run="" + if non-empty, specifies a regular expression to select + directives whose full original source text (excluding + any trailing spaces and final newline) matches the + expression. + + -skip="" + if non-empty, specifies a regular expression to suppress + directives whose full original source text (excluding + any trailing spaces and final newline) matches the + expression. If a directive matches both the -run and + the -skip arguments, it is skipped. + +It also accepts the standard build flags including -v, -n, and -x. +The -v flag prints the names of packages and files as they are +processed. +The -n flag prints commands that would be executed. +The -x flag prints commands as they are executed. + +For more about build flags, see 'go help build'. + +For more about specifying packages, see 'go help packages'. + `, +} + +var ( + generateRunFlag string // generate -run flag + generateRunRE *regexp.Regexp // compiled expression for -run + + generateSkipFlag string // generate -skip flag + generateSkipRE *regexp.Regexp // compiled expression for -skip +) + +func init() { + work.AddBuildFlags(CmdGenerate, work.OmitBuildOnlyFlags) + CmdGenerate.Flag.StringVar(&generateRunFlag, "run", "", "") + CmdGenerate.Flag.StringVar(&generateSkipFlag, "skip", "", "") +} + +func runGenerate(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + moduleLoaderState.InitWorkfile() + + if generateRunFlag != "" { + var err error + generateRunRE, err = regexp.Compile(generateRunFlag) + if err != nil { + log.Fatalf("generate: %s", err) + } + } + if generateSkipFlag != "" { + var err error + generateSkipRE, err = regexp.Compile(generateSkipFlag) + if err != nil { + log.Fatalf("generate: %s", err) + } + } + + cfg.BuildContext.BuildTags = append(cfg.BuildContext.BuildTags, "generate") + + // Even if the arguments are .go files, this loop suffices. + printed := false + pkgOpts := load.PackageOpts{IgnoreImports: true} + for _, pkg := range load.PackagesAndErrors(moduleLoaderState, ctx, pkgOpts, args) { + if moduleLoaderState.Enabled() && pkg.Module != nil && !pkg.Module.Main { + if !printed { + fmt.Fprintf(os.Stderr, "go: not generating in packages in dependency modules\n") + printed = true + } + continue + } + + if pkg.Error != nil && len(pkg.InternalAllGoFiles()) == 0 { + // A directory only contains a Go package if it has at least + // one .go source file, so the fact that there are no files + // implies that the package couldn't be found. + base.Errorf("%v", pkg.Error) + } + + for _, file := range pkg.InternalGoFiles() { + if !generate(file) { + break + } + } + + for _, file := range pkg.InternalXGoFiles() { + if !generate(file) { + break + } + } + } + base.ExitIfErrors() +} + +// generate runs the generation directives for a single file. +func generate(absFile string) bool { + src, err := os.ReadFile(absFile) + if err != nil { + log.Fatalf("generate: %s", err) + } + + // Parse package clause + filePkg, err := parser.ParseFile(token.NewFileSet(), "", src, parser.PackageClauseOnly) + if err != nil { + // Invalid package clause - ignore file. + return true + } + + g := &Generator{ + r: bytes.NewReader(src), + path: absFile, + pkg: filePkg.Name.String(), + commands: make(map[string][]string), + } + return g.run() +} + +// A Generator represents the state of a single Go source file +// being scanned for generator commands. +type Generator struct { + r io.Reader + path string // full rooted path name. + dir string // full rooted directory of file. + file string // base name of file. + pkg string + commands map[string][]string + lineNum int // current line number. + env []string +} + +// run runs the generators in the current file. +func (g *Generator) run() (ok bool) { + // Processing below here calls g.errorf on failure, which does panic(stop). + // If we encounter an error, we abort the package. + defer func() { + e := recover() + if e != nil { + ok = false + if e != stop { + panic(e) + } + base.SetExitStatus(1) + } + }() + g.dir, g.file = filepath.Split(g.path) + g.dir = filepath.Clean(g.dir) // No final separator please. + if cfg.BuildV { + fmt.Fprintf(os.Stderr, "%s\n", base.ShortPath(g.path)) + } + + // Scan for lines that start "//go:generate". + // Can't use bufio.Scanner because it can't handle long lines, + // which are likely to appear when using generate. + input := bufio.NewReader(g.r) + var err error + // One line per loop. + for { + g.lineNum++ // 1-indexed. + var buf []byte + buf, err = input.ReadSlice('\n') + if err == bufio.ErrBufferFull { + // Line too long - consume and ignore. + if isGoGenerate(buf) { + g.errorf("directive too long") + } + for err == bufio.ErrBufferFull { + _, err = input.ReadSlice('\n') + } + if err != nil { + break + } + continue + } + + if err != nil { + // Check for marker at EOF without final \n. + if err == io.EOF && isGoGenerate(buf) { + err = io.ErrUnexpectedEOF + } + break + } + + if !isGoGenerate(buf) { + continue + } + if generateRunFlag != "" && !generateRunRE.Match(bytes.TrimSpace(buf)) { + continue + } + if generateSkipFlag != "" && generateSkipRE.Match(bytes.TrimSpace(buf)) { + continue + } + + g.setEnv() + words := g.split(string(buf)) + if len(words) == 0 { + g.errorf("no arguments to directive") + } + if words[0] == "-command" { + g.setShorthand(words) + continue + } + // Run the command line. + if cfg.BuildN || cfg.BuildX { + fmt.Fprintf(os.Stderr, "%s\n", strings.Join(words, " ")) + } + if cfg.BuildN { + continue + } + g.exec(words) + } + if err != nil && err != io.EOF { + g.errorf("error reading %s: %s", base.ShortPath(g.path), err) + } + return true +} + +func isGoGenerate(buf []byte) bool { + return bytes.HasPrefix(buf, []byte("//go:generate ")) || bytes.HasPrefix(buf, []byte("//go:generate\t")) +} + +// setEnv sets the extra environment variables used when executing a +// single go:generate command. +func (g *Generator) setEnv() { + env := []string{ + "GOROOT=" + cfg.GOROOT, + "GOARCH=" + cfg.BuildContext.GOARCH, + "GOOS=" + cfg.BuildContext.GOOS, + "GOFILE=" + g.file, + "GOLINE=" + strconv.Itoa(g.lineNum), + "GOPACKAGE=" + g.pkg, + "DOLLAR=" + "$", + } + env = base.AppendPATH(env) + env = base.AppendPWD(env, g.dir) + g.env = env +} + +// split breaks the line into words, evaluating quoted +// strings and evaluating environment variables. +// The initial //go:generate element is present in line. +func (g *Generator) split(line string) []string { + // Parse line, obeying quoted strings. + var words []string + line = line[len("//go:generate ") : len(line)-1] // Drop preamble and final newline. + // There may still be a carriage return. + if len(line) > 0 && line[len(line)-1] == '\r' { + line = line[:len(line)-1] + } + // One (possibly quoted) word per iteration. +Words: + for { + line = strings.TrimLeft(line, " \t") + if len(line) == 0 { + break + } + if line[0] == '"' { + for i := 1; i < len(line); i++ { + c := line[i] // Only looking for ASCII so this is OK. + switch c { + case '\\': + if i+1 == len(line) { + g.errorf("bad backslash") + } + i++ // Absorb next byte (If it's a multibyte we'll get an error in Unquote). + case '"': + word, err := strconv.Unquote(line[0 : i+1]) + if err != nil { + g.errorf("bad quoted string") + } + words = append(words, word) + line = line[i+1:] + // Check the next character is space or end of line. + if len(line) > 0 && line[0] != ' ' && line[0] != '\t' { + g.errorf("expect space after quoted argument") + } + continue Words + } + } + g.errorf("mismatched quoted string") + } + i := strings.IndexAny(line, " \t") + if i < 0 { + i = len(line) + } + words = append(words, line[0:i]) + line = line[i:] + } + // Substitute command if required. + if len(words) > 0 && g.commands[words[0]] != nil { + // Replace 0th word by command substitution. + // + // Force a copy of the command definition to + // ensure words doesn't end up as a reference + // to the g.commands content. + tmpCmdWords := append([]string(nil), (g.commands[words[0]])...) + words = append(tmpCmdWords, words[1:]...) + } + // Substitute environment variables. + for i, word := range words { + words[i] = os.Expand(word, g.expandVar) + } + return words +} + +var stop = fmt.Errorf("error in generation") + +// errorf logs an error message prefixed with the file and line number. +// It then exits the program (with exit status 1) because generation stops +// at the first error. +func (g *Generator) errorf(format string, args ...any) { + fmt.Fprintf(os.Stderr, "%s:%d: %s\n", base.ShortPath(g.path), g.lineNum, + fmt.Sprintf(format, args...)) + panic(stop) +} + +// expandVar expands the $XXX invocation in word. It is called +// by os.Expand. +func (g *Generator) expandVar(word string) string { + w := word + "=" + for _, e := range g.env { + if strings.HasPrefix(e, w) { + return e[len(w):] + } + } + return os.Getenv(word) +} + +// setShorthand installs a new shorthand as defined by a -command directive. +func (g *Generator) setShorthand(words []string) { + // Create command shorthand. + if len(words) == 1 { + g.errorf("no command specified for -command") + } + command := words[1] + if g.commands[command] != nil { + g.errorf("command %q multiply defined", command) + } + g.commands[command] = slices.Clip(words[2:]) +} + +// exec runs the command specified by the argument. The first word is +// the command name itself. +func (g *Generator) exec(words []string) { + path := words[0] + if path != "" && !strings.Contains(path, string(os.PathSeparator)) { + // If a generator says '//go:generate go run ' it almost certainly + // intends to use the same 'go' as 'go generate' itself. + // Prefer to resolve the binary from GOROOT/bin, and for consistency + // prefer to resolve any other commands there too. + gorootBinPath, err := pathcache.LookPath(filepath.Join(cfg.GOROOTbin, path)) + if err == nil { + path = gorootBinPath + } + } + cmd := exec.Command(path, words[1:]...) + cmd.Args[0] = words[0] // Overwrite with the original in case it was rewritten above. + + // Standard in and out of generator should be the usual. + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + // Run the command in the package directory. + cmd.Dir = g.dir + cmd.Env = str.StringList(cfg.OrigEnv, g.env) + err := cmd.Run() + if err != nil { + g.errorf("running %q: %s", words[0], err) + } +} diff --git a/go/src/cmd/go/internal/generate/generate_test.go b/go/src/cmd/go/internal/generate/generate_test.go new file mode 100644 index 0000000000000000000000000000000000000000..b11ed505450ba8a30adeccc4c92bf7ab086851ce --- /dev/null +++ b/go/src/cmd/go/internal/generate/generate_test.go @@ -0,0 +1,259 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package generate + +import ( + "internal/testenv" + "os" + "path/filepath" + "reflect" + "runtime" + "testing" +) + +type splitTest struct { + in string + out []string +} + +// Same as above, except including source line number to set +type splitTestWithLine struct { + in string + out []string + lineNumber int +} + +const anyLineNo = 0 + +var splitTests = []splitTest{ + {"", nil}, + {"x", []string{"x"}}, + {" a b\tc ", []string{"a", "b", "c"}}, + {` " a " `, []string{" a "}}, + {"$GOARCH", []string{runtime.GOARCH}}, + {"$GOOS", []string{runtime.GOOS}}, + {"$GOFILE", []string{"proc.go"}}, + {"$GOPACKAGE", []string{"sys"}}, + {"a $XXNOTDEFINEDXX b", []string{"a", "", "b"}}, + {"/$XXNOTDEFINED/", []string{"//"}}, + {"/$DOLLAR/", []string{"/$/"}}, + {"yacc -o $GOARCH/yacc_$GOFILE", []string{"go", "tool", "yacc", "-o", runtime.GOARCH + "/yacc_proc.go"}}, +} + +func TestGenerateCommandParse(t *testing.T) { + dir := filepath.Join(testenv.GOROOT(t), "src", "sys") + g := &Generator{ + r: nil, // Unused here. + path: filepath.Join(dir, "proc.go"), + dir: dir, + file: "proc.go", + pkg: "sys", + commands: make(map[string][]string), + } + g.setEnv() + g.setShorthand([]string{"-command", "yacc", "go", "tool", "yacc"}) + for _, test := range splitTests { + // First with newlines. + got := g.split("//go:generate " + test.in + "\n") + if !reflect.DeepEqual(got, test.out) { + t.Errorf("split(%q): got %q expected %q", test.in, got, test.out) + } + // Then with CRLFs, thank you Windows. + got = g.split("//go:generate " + test.in + "\r\n") + if !reflect.DeepEqual(got, test.out) { + t.Errorf("split(%q): got %q expected %q", test.in, got, test.out) + } + } +} + +// These environment variables will be undefined before the splitTestWithLine tests +var undefEnvList = []string{ + "_XYZZY_", +} + +// These environment variables will be defined before the splitTestWithLine tests +var defEnvMap = map[string]string{ + "_PLUGH_": "SomeVal", + "_X": "Y", +} + +// TestGenerateCommandShorthand - similar to TestGenerateCommandParse, +// except: +// 1. if the result starts with -command, record that shorthand +// before moving on to the next test. +// 2. If a source line number is specified, set that in the parser +// before executing the test. i.e., execute the split as if it +// processing that source line. +func TestGenerateCommandShorthand(t *testing.T) { + dir := filepath.Join(testenv.GOROOT(t), "src", "sys") + g := &Generator{ + r: nil, // Unused here. + path: filepath.Join(dir, "proc.go"), + dir: dir, + file: "proc.go", + pkg: "sys", + commands: make(map[string][]string), + } + + var inLine string + var expected, got []string + + g.setEnv() + + // Set up the system environment variables + for i := range undefEnvList { + os.Unsetenv(undefEnvList[i]) + } + for k := range defEnvMap { + os.Setenv(k, defEnvMap[k]) + } + + // simple command from environment variable + inLine = "//go:generate -command CMD0 \"ab${_X}cd\"" + expected = []string{"-command", "CMD0", "abYcd"} + got = g.split(inLine + "\n") + + if !reflect.DeepEqual(got, expected) { + t.Errorf("split(%q): got %q expected %q", inLine, got, expected) + } + + // try again, with an extra level of indirection (should leave variable in command) + inLine = "//go:generate -command CMD0 \"ab${DOLLAR}{_X}cd\"" + expected = []string{"-command", "CMD0", "ab${_X}cd"} + got = g.split(inLine + "\n") + + if !reflect.DeepEqual(got, expected) { + t.Errorf("split(%q): got %q expected %q", inLine, got, expected) + } + + // Now the interesting part, record that output as a command + g.setShorthand(got) + + // see that the command still substitutes correctly from env. variable + inLine = "//go:generate CMD0" + expected = []string{"abYcd"} + got = g.split(inLine + "\n") + + if !reflect.DeepEqual(got, expected) { + t.Errorf("split(%q): got %q expected %q", inLine, got, expected) + } + + // Now change the value of $X and see if the recorded definition is + // still intact (vs. having the $_X already substituted out) + + os.Setenv("_X", "Z") + inLine = "//go:generate CMD0" + expected = []string{"abZcd"} + got = g.split(inLine + "\n") + + if !reflect.DeepEqual(got, expected) { + t.Errorf("split(%q): got %q expected %q", inLine, got, expected) + } + + // What if the variable is now undefined? Should be empty substitution. + + os.Unsetenv("_X") + inLine = "//go:generate CMD0" + expected = []string{"abcd"} + got = g.split(inLine + "\n") + + if !reflect.DeepEqual(got, expected) { + t.Errorf("split(%q): got %q expected %q", inLine, got, expected) + } + + // Try another undefined variable as an extra check + os.Unsetenv("_Z") + inLine = "//go:generate -command CMD1 \"ab${_Z}cd\"" + expected = []string{"-command", "CMD1", "abcd"} + got = g.split(inLine + "\n") + + if !reflect.DeepEqual(got, expected) { + t.Errorf("split(%q): got %q expected %q", inLine, got, expected) + } + + g.setShorthand(got) + + inLine = "//go:generate CMD1" + expected = []string{"abcd"} + got = g.split(inLine + "\n") + + if !reflect.DeepEqual(got, expected) { + t.Errorf("split(%q): got %q expected %q", inLine, got, expected) + } + + const val = "someNewValue" + os.Setenv("_Z", val) + + // try again with the properly-escaped variable. + + inLine = "//go:generate -command CMD2 \"ab${DOLLAR}{_Z}cd\"" + expected = []string{"-command", "CMD2", "ab${_Z}cd"} + got = g.split(inLine + "\n") + + if !reflect.DeepEqual(got, expected) { + t.Errorf("split(%q): got %q expected %q", inLine, got, expected) + } + + g.setShorthand(got) + + inLine = "//go:generate CMD2" + expected = []string{"ab" + val + "cd"} + got = g.split(inLine + "\n") + + if !reflect.DeepEqual(got, expected) { + t.Errorf("split(%q): got %q expected %q", inLine, got, expected) + } +} + +// Command-related tests for TestGenerateCommandShortHand2 +// -- Note line numbers included to check substitutions from "built-in" variable - $GOLINE +var splitTestsLines = []splitTestWithLine{ + {"-command TEST1 $GOLINE", []string{"-command", "TEST1", "22"}, 22}, + {"-command TEST2 ${DOLLAR}GOLINE", []string{"-command", "TEST2", "$GOLINE"}, 26}, + {"TEST1", []string{"22"}, 33}, + {"TEST2", []string{"66"}, 66}, + {"TEST1 ''", []string{"22", "''"}, 99}, + {"TEST2 ''", []string{"44", "''"}, 44}, +} + +// TestGenerateCommandShortHand2 - similar to TestGenerateCommandParse, +// except: +// 1. if the result starts with -command, record that shorthand +// before moving on to the next test. +// 2. If a source line number is specified, set that in the parser +// before executing the test. i.e., execute the split as if it +// processing that source line. +func TestGenerateCommandShortHand2(t *testing.T) { + dir := filepath.Join(testenv.GOROOT(t), "src", "sys") + g := &Generator{ + r: nil, // Unused here. + path: filepath.Join(dir, "proc.go"), + dir: dir, + file: "proc.go", + pkg: "sys", + commands: make(map[string][]string), + } + g.setEnv() + for _, test := range splitTestsLines { + // if the test specified a line number, reflect that + if test.lineNumber != anyLineNo { + g.lineNum = test.lineNumber + g.setEnv() + } + // First with newlines. + got := g.split("//go:generate " + test.in + "\n") + if !reflect.DeepEqual(got, test.out) { + t.Errorf("split(%q): got %q expected %q", test.in, got, test.out) + } + // Then with CRLFs, thank you Windows. + got = g.split("//go:generate " + test.in + "\r\n") + if !reflect.DeepEqual(got, test.out) { + t.Errorf("split(%q): got %q expected %q", test.in, got, test.out) + } + if got[0] == "-command" { // record commands + g.setShorthand(got) + } + } +} diff --git a/go/src/cmd/go/internal/gover/gomod.go b/go/src/cmd/go/internal/gover/gomod.go new file mode 100644 index 0000000000000000000000000000000000000000..4a4ae5302908b5936817f9051547e1801100d6ee --- /dev/null +++ b/go/src/cmd/go/internal/gover/gomod.go @@ -0,0 +1,43 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gover + +import ( + "bytes" + "strings" +) + +var nl = []byte("\n") + +// GoModLookup takes go.mod or go.work content, +// finds the first line in the file starting with the given key, +// and returns the value associated with that key. +// +// Lookup should only be used with non-factored verbs +// such as "go" and "toolchain", usually to find versions +// or version-like strings. +func GoModLookup(gomod []byte, key string) string { + for len(gomod) > 0 { + var line []byte + line, gomod, _ = bytes.Cut(gomod, nl) + line = bytes.TrimSpace(line) + if v, ok := parseKey(line, key); ok { + return v + } + } + return "" +} + +func parseKey(line []byte, key string) (string, bool) { + if !strings.HasPrefix(string(line), key) { + return "", false + } + s := strings.TrimPrefix(string(line), key) + if len(s) == 0 || (s[0] != ' ' && s[0] != '\t') { + return "", false + } + s, _, _ = strings.Cut(s, "//") // strip comments + return strings.TrimSpace(s), true +} diff --git a/go/src/cmd/go/internal/gover/gover.go b/go/src/cmd/go/internal/gover/gover.go new file mode 100644 index 0000000000000000000000000000000000000000..19c6f670c5d8eda90b1750a53d4a605115c91a57 --- /dev/null +++ b/go/src/cmd/go/internal/gover/gover.go @@ -0,0 +1,75 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package gover implements support for Go toolchain versions like 1.21.0 and 1.21rc1. +// (For historical reasons, Go does not use semver for its toolchains.) +// This package provides the same basic analysis that golang.org/x/mod/semver does for semver. +// It also provides some helpers for extracting versions from go.mod files +// and for dealing with module.Versions that may use Go versions or semver +// depending on the module path. +package gover + +import ( + "internal/gover" +) + +// Compare returns -1, 0, or +1 depending on whether +// x < y, x == y, or x > y, interpreted as toolchain versions. +// The versions x and y must not begin with a "go" prefix: just "1.21" not "go1.21". +// Malformed versions compare less than well-formed versions and equal to each other. +// The language version "1.21" compares less than the release candidate and eventual releases "1.21rc1" and "1.21.0". +func Compare(x, y string) int { + return gover.Compare(x, y) +} + +// Max returns the maximum of x and y interpreted as toolchain versions, +// compared using Compare. +// If x and y compare equal, Max returns x. +func Max(x, y string) string { + return gover.Max(x, y) +} + +// IsLang reports whether v denotes the overall Go language version +// and not a specific release. Starting with the Go 1.21 release, "1.x" denotes +// the overall language version; the first release is "1.x.0". +// The distinction is important because the relative ordering is +// +// 1.21 < 1.21rc1 < 1.21.0 +// +// meaning that Go 1.21rc1 and Go 1.21.0 will both handle go.mod files that +// say "go 1.21", but Go 1.21rc1 will not handle files that say "go 1.21.0". +func IsLang(x string) bool { + return gover.IsLang(x) +} + +// Lang returns the Go language version. For example, Lang("1.2.3") == "1.2". +func Lang(x string) string { + return gover.Lang(x) +} + +// IsPrerelease reports whether v denotes a Go prerelease version. +func IsPrerelease(x string) bool { + return gover.Parse(x).Kind != "" +} + +// Prev returns the Go major release immediately preceding v, +// or v itself if v is the first Go major release (1.0) or not a supported +// Go version. +// +// Examples: +// +// Prev("1.2") = "1.1" +// Prev("1.3rc4") = "1.2" +func Prev(x string) string { + v := gover.Parse(x) + if gover.CmpInt(v.Minor, "1") <= 0 { + return v.Major + } + return v.Major + "." + gover.DecInt(v.Minor) +} + +// IsValid reports whether the version x is valid. +func IsValid(x string) bool { + return gover.IsValid(x) +} diff --git a/go/src/cmd/go/internal/gover/gover_test.go b/go/src/cmd/go/internal/gover/gover_test.go new file mode 100644 index 0000000000000000000000000000000000000000..68fd56f31dee210dd619db6a303d70257f97259f --- /dev/null +++ b/go/src/cmd/go/internal/gover/gover_test.go @@ -0,0 +1,142 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gover + +import ( + "reflect" + "testing" +) + +func TestCompare(t *testing.T) { test2(t, compareTests, "Compare", Compare) } + +var compareTests = []testCase2[string, string, int]{ + {"", "", 0}, + {"x", "x", 0}, + {"", "x", 0}, + {"1", "1.1", -1}, + {"1.5", "1.6", -1}, + {"1.5", "1.10", -1}, + {"1.6", "1.6.1", -1}, + {"1.19", "1.19.0", 0}, + {"1.19rc1", "1.19", -1}, + {"1.20", "1.20.0", 0}, + {"1.20rc1", "1.20", -1}, + {"1.21", "1.21.0", -1}, + {"1.21", "1.21rc1", -1}, + {"1.21rc1", "1.21.0", -1}, + {"1.6", "1.19", -1}, + {"1.19", "1.19.1", -1}, + {"1.19rc1", "1.19", -1}, + {"1.19rc1", "1.19.1", -1}, + {"1.19rc1", "1.19rc2", -1}, + {"1.19.0", "1.19.1", -1}, + {"1.19rc1", "1.19.0", -1}, + {"1.19alpha3", "1.19beta2", -1}, + {"1.19beta2", "1.19rc1", -1}, + {"1.1", "1.99999999999999998", -1}, + {"1.99999999999999998", "1.99999999999999999", -1}, +} + +func TestLang(t *testing.T) { test1(t, langTests, "Lang", Lang) } + +var langTests = []testCase1[string, string]{ + {"1.2rc3", "1.2"}, + {"1.2.3", "1.2"}, + {"1.2", "1.2"}, + {"1", "1"}, + {"1.999testmod", "1.999"}, +} + +func TestIsLang(t *testing.T) { test1(t, isLangTests, "IsLang", IsLang) } + +var isLangTests = []testCase1[string, bool]{ + {"1.2rc3", false}, + {"1.2.3", false}, + {"1.999testmod", false}, + {"1.22", true}, + {"1.21", true}, + {"1.20", false}, // == 1.20.0 + {"1.19", false}, // == 1.20.0 + {"1.3", false}, // == 1.3.0 + {"1.2", false}, // == 1.2.0 + {"1", false}, // == 1.0.0 +} + +func TestPrev(t *testing.T) { test1(t, prevTests, "Prev", Prev) } + +var prevTests = []testCase1[string, string]{ + {"", ""}, + {"0", "0"}, + {"1.3rc4", "1.2"}, + {"1.3.5", "1.2"}, + {"1.3", "1.2"}, + {"1", "1"}, + {"1.99999999999999999", "1.99999999999999998"}, + {"1.40000000000000000", "1.39999999999999999"}, +} + +func TestIsValid(t *testing.T) { test1(t, isValidTests, "IsValid", IsValid) } + +var isValidTests = []testCase1[string, bool]{ + {"1.2rc3", true}, + {"1.2.3", true}, + {"1.999testmod", true}, + {"1.600+auto", false}, + {"1.22", true}, + {"1.21.0", true}, + {"1.21rc2", true}, + {"1.21", true}, + {"1.20.0", true}, + {"1.20", true}, + {"1.19", true}, + {"1.3", true}, + {"1.2", true}, + {"1", true}, +} + +type testCase1[In, Out any] struct { + in In + out Out +} + +type testCase2[In1, In2, Out any] struct { + in1 In1 + in2 In2 + out Out +} + +type testCase3[In1, In2, In3, Out any] struct { + in1 In1 + in2 In2 + in3 In3 + out Out +} + +func test1[In, Out any](t *testing.T, tests []testCase1[In, Out], name string, f func(In) Out) { + t.Helper() + for _, tt := range tests { + if out := f(tt.in); !reflect.DeepEqual(out, tt.out) { + t.Errorf("%s(%v) = %v, want %v", name, tt.in, out, tt.out) + } + } +} + +func test2[In1, In2, Out any](t *testing.T, tests []testCase2[In1, In2, Out], name string, f func(In1, In2) Out) { + t.Helper() + for _, tt := range tests { + if out := f(tt.in1, tt.in2); !reflect.DeepEqual(out, tt.out) { + t.Errorf("%s(%+v, %+v) = %+v, want %+v", name, tt.in1, tt.in2, out, tt.out) + } + } +} + +func test3[In1, In2, In3, Out any](t *testing.T, tests []testCase3[In1, In2, In3, Out], name string, f func(In1, In2, In3) Out) { + t.Helper() + for _, tt := range tests { + if out := f(tt.in1, tt.in2, tt.in3); !reflect.DeepEqual(out, tt.out) { + t.Errorf("%s(%+v, %+v, %+v) = %+v, want %+v", name, tt.in1, tt.in2, tt.in3, out, tt.out) + } + } +} diff --git a/go/src/cmd/go/internal/gover/local.go b/go/src/cmd/go/internal/gover/local.go new file mode 100644 index 0000000000000000000000000000000000000000..8183a5c3d47497d4f70f4af5b4a8dc2e8d2b0da1 --- /dev/null +++ b/go/src/cmd/go/internal/gover/local.go @@ -0,0 +1,42 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gover + +import ( + "internal/goversion" + "runtime" + "strconv" +) + +// TestVersion is initialized in the go command test binary +// to be $TESTGO_VERSION, to allow tests to override the +// go command's idea of its own version as returned by Local. +var TestVersion string + +// Local returns the local Go version, the one implemented by this go command. +func Local() string { + v, _ := local() + return v +} + +// LocalToolchain returns the local toolchain name, the one implemented by this go command. +func LocalToolchain() string { + _, t := local() + return t +} + +func local() (goVers, toolVers string) { + toolVers = runtime.Version() + if TestVersion != "" { + toolVers = TestVersion + } + goVers = FromToolchain(toolVers) + if goVers == "" { + // Development branch. Use "Dev" version with just 1.N, no rc1 or .0 suffix. + goVers = "1." + strconv.Itoa(goversion.Version) + toolVers = "go" + goVers + } + return goVers, toolVers +} diff --git a/go/src/cmd/go/internal/gover/mod.go b/go/src/cmd/go/internal/gover/mod.go new file mode 100644 index 0000000000000000000000000000000000000000..3ac5ae8824b2337e219060720034499cc3056c8f --- /dev/null +++ b/go/src/cmd/go/internal/gover/mod.go @@ -0,0 +1,130 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gover + +import ( + "sort" + "strings" + + "golang.org/x/mod/module" + "golang.org/x/mod/semver" +) + +// IsToolchain reports whether the module path corresponds to the +// virtual, non-downloadable module tracking go or toolchain directives in the go.mod file. +// +// Note that IsToolchain only matches "go" and "toolchain", not the +// real, downloadable module "golang.org/toolchain" containing toolchain files. +// +// IsToolchain("go") = true +// IsToolchain("toolchain") = true +// IsToolchain("golang.org/x/tools") = false +// IsToolchain("golang.org/toolchain") = false +func IsToolchain(path string) bool { + return path == "go" || path == "toolchain" +} + +// ModCompare returns the result of comparing the versions x and y +// for the module with the given path. +// The path is necessary because the "go" and "toolchain" modules +// use a different version syntax and semantics (gover, this package) +// than most modules (semver). +func ModCompare(path string, x, y string) int { + if path == "go" { + return Compare(x, y) + } + if path == "toolchain" { + return Compare(maybeToolchainVersion(x), maybeToolchainVersion(y)) + } + return semver.Compare(x, y) +} + +// ModSort is like module.Sort but understands the "go" and "toolchain" +// modules and their version ordering. +func ModSort(list []module.Version) { + sort.Slice(list, func(i, j int) bool { + mi := list[i] + mj := list[j] + if mi.Path != mj.Path { + return mi.Path < mj.Path + } + // To help go.sum formatting, allow version/file. + // Compare semver prefix by semver rules, + // file by string order. + vi := mi.Version + vj := mj.Version + var fi, fj string + if k := strings.Index(vi, "/"); k >= 0 { + vi, fi = vi[:k], vi[k:] + } + if k := strings.Index(vj, "/"); k >= 0 { + vj, fj = vj[:k], vj[k:] + } + if vi != vj { + return ModCompare(mi.Path, vi, vj) < 0 + } + return fi < fj + }) +} + +// ModIsValid reports whether vers is a valid version syntax for the module with the given path. +func ModIsValid(path, vers string) bool { + if IsToolchain(path) { + if path == "toolchain" { + return IsValid(FromToolchain(vers)) + } + return IsValid(vers) + } + return semver.IsValid(vers) +} + +// ModIsPrefix reports whether v is a valid version syntax prefix for the module with the given path. +// The caller is assumed to have checked that ModIsValid(path, vers) is true. +func ModIsPrefix(path, vers string) bool { + if IsToolchain(path) { + if path == "toolchain" { + return IsLang(FromToolchain(vers)) + } + return IsLang(vers) + } + // Semver + dots := 0 + for i := 0; i < len(vers); i++ { + switch vers[i] { + case '-', '+': + return false + case '.': + dots++ + if dots >= 2 { + return false + } + } + } + return true +} + +// ModIsPrerelease reports whether v is a prerelease version for the module with the given path. +// The caller is assumed to have checked that ModIsValid(path, vers) is true. +func ModIsPrerelease(path, vers string) bool { + if IsToolchain(path) { + if path == "toolchain" { + return IsPrerelease(FromToolchain(vers)) + } + return IsPrerelease(vers) + } + return semver.Prerelease(vers) != "" +} + +// ModMajorMinor returns the "major.minor" truncation of the version v, +// for use as a prefix in "@patch" queries. +func ModMajorMinor(path, vers string) string { + if IsToolchain(path) { + if path == "toolchain" { + return "go" + Lang(FromToolchain(vers)) + } + return Lang(vers) + } + return semver.MajorMinor(vers) +} diff --git a/go/src/cmd/go/internal/gover/mod_test.go b/go/src/cmd/go/internal/gover/mod_test.go new file mode 100644 index 0000000000000000000000000000000000000000..c92169cb32d50caa013d695f0a6a20b5b1e38494 --- /dev/null +++ b/go/src/cmd/go/internal/gover/mod_test.go @@ -0,0 +1,72 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gover + +import ( + "slices" + "strings" + "testing" + + "golang.org/x/mod/module" +) + +func TestIsToolchain(t *testing.T) { test1(t, isToolchainTests, "IsToolchain", IsToolchain) } + +var isToolchainTests = []testCase1[string, bool]{ + {"go", true}, + {"toolchain", true}, + {"anything", false}, + {"golang.org/toolchain", false}, +} + +func TestModCompare(t *testing.T) { test3(t, modCompareTests, "ModCompare", ModCompare) } + +var modCompareTests = []testCase3[string, string, string, int]{ + {"go", "1.2", "1.3", -1}, + {"go", "v1.2", "v1.3", 0}, // equal because invalid + {"go", "1.2", "1.2", 0}, + {"toolchain", "go1.2", "go1.3", -1}, + {"toolchain", "go1.2", "go1.2", 0}, + {"toolchain", "1.2", "1.3", -1}, // accepted but non-standard + {"toolchain", "v1.2", "v1.3", 0}, // equal because invalid + {"rsc.io/quote", "v1.2", "v1.3", -1}, + {"rsc.io/quote", "1.2", "1.3", 0}, // equal because invalid +} + +func TestModIsValid(t *testing.T) { test2(t, modIsValidTests, "ModIsValid", ModIsValid) } + +var modIsValidTests = []testCase2[string, string, bool]{ + {"go", "1.2", true}, + {"go", "v1.2", false}, + {"toolchain", "go1.2", true}, + {"toolchain", "v1.2", false}, + {"rsc.io/quote", "v1.2", true}, + {"rsc.io/quote", "1.2", false}, +} + +func TestModSort(t *testing.T) { + test1(t, modSortTests, "ModSort", func(list []module.Version) []module.Version { + out := slices.Clone(list) + ModSort(out) + return out + }) +} + +var modSortTests = []testCase1[[]module.Version, []module.Version]{ + { + mvl(`z v1.1; a v1.2; a v1.1; go 1.3; toolchain 1.3; toolchain 1.2; go 1.2`), + mvl(`a v1.1; a v1.2; go 1.2; go 1.3; toolchain 1.2; toolchain 1.3; z v1.1`), + }, +} + +func mvl(s string) []module.Version { + var list []module.Version + for _, f := range strings.Split(s, ";") { + f = strings.TrimSpace(f) + path, vers, _ := strings.Cut(f, " ") + list = append(list, module.Version{Path: path, Version: vers}) + } + return list +} diff --git a/go/src/cmd/go/internal/gover/toolchain.go b/go/src/cmd/go/internal/gover/toolchain.go new file mode 100644 index 0000000000000000000000000000000000000000..a24df98168056b771a8eca885349e845f89f7621 --- /dev/null +++ b/go/src/cmd/go/internal/gover/toolchain.go @@ -0,0 +1,98 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gover + +import ( + "cmd/go/internal/base" + "context" + "errors" + "fmt" + "strings" +) + +// FromToolchain returns the Go version for the named toolchain, +// derived from the name itself (not by running the toolchain). +// A toolchain is named "goVERSION". +// A suffix after the VERSION introduced by a -, space, or tab is removed. +// Examples: +// +// FromToolchain("go1.2.3") == "1.2.3" +// FromToolchain("go1.2.3-bigcorp") == "1.2.3" +// FromToolchain("invalid") == "" +func FromToolchain(name string) string { + if strings.ContainsAny(name, "\\/") { + // The suffix must not include a path separator, since that would cause + // exec.LookPath to resolve it from a relative directory instead of from + // $PATH. + return "" + } + + var v string + if strings.HasPrefix(name, "go") { + v = name[2:] + } else { + return "" + } + // Some builds use custom suffixes; strip them. + if i := strings.IndexAny(v, " \t-"); i >= 0 { + v = v[:i] + } + if !IsValid(v) { + return "" + } + return v +} + +func maybeToolchainVersion(name string) string { + if IsValid(name) { + return name + } + return FromToolchain(name) +} + +// Startup records the information that went into the startup-time version switch. +// It is initialized by switchGoToolchain. +var Startup struct { + GOTOOLCHAIN string // $GOTOOLCHAIN setting + AutoFile string // go.mod or go.work file consulted + AutoGoVersion string // go line found in file + AutoToolchain string // toolchain line found in file +} + +// A TooNewError explains that a module is too new for this version of Go. +type TooNewError struct { + What string + GoVersion string + Toolchain string // for callers if they want to use it, but not printed +} + +func (e *TooNewError) Error() string { + var explain string + if Startup.GOTOOLCHAIN != "" && Startup.GOTOOLCHAIN != "auto" { + explain = "; GOTOOLCHAIN=" + Startup.GOTOOLCHAIN + } + if Startup.AutoFile != "" && (Startup.AutoGoVersion != "" || Startup.AutoToolchain != "") { + explain += fmt.Sprintf("; %s sets ", base.ShortPath(Startup.AutoFile)) + if Startup.AutoToolchain != "" { + explain += "toolchain " + Startup.AutoToolchain + } else { + explain += "go " + Startup.AutoGoVersion + } + } + return fmt.Sprintf("%v requires go >= %v (running go %v%v)", e.What, e.GoVersion, Local(), explain) +} + +var ErrTooNew = errors.New("module too new") + +func (e *TooNewError) Is(err error) bool { + return err == ErrTooNew +} + +// A Switcher provides the ability to switch to a new toolchain in response to TooNewErrors. +// See [cmd/go/internal/toolchain.Switcher] for documentation. +type Switcher interface { + Error(err error) + Switch(ctx context.Context) +} diff --git a/go/src/cmd/go/internal/gover/toolchain_test.go b/go/src/cmd/go/internal/gover/toolchain_test.go new file mode 100644 index 0000000000000000000000000000000000000000..d1c22fbc37cb9cecc61852ad01031bc3d9810b6f --- /dev/null +++ b/go/src/cmd/go/internal/gover/toolchain_test.go @@ -0,0 +1,19 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gover + +import "testing" + +func TestFromToolchain(t *testing.T) { test1(t, fromToolchainTests, "FromToolchain", FromToolchain) } + +var fromToolchainTests = []testCase1[string, string]{ + {"go1.2.3", "1.2.3"}, + {"1.2.3", ""}, + {"go1.2.3+bigcorp", ""}, + {"go1.2.3-bigcorp", "1.2.3"}, + {"go1.2.3-bigcorp more text", "1.2.3"}, + {"gccgo-go1.23rc4", ""}, + {"gccgo-go1.23rc4-bigdwarf", ""}, +} diff --git a/go/src/cmd/go/internal/gover/version.go b/go/src/cmd/go/internal/gover/version.go new file mode 100644 index 0000000000000000000000000000000000000000..15c712a4392825648faf13d6225c94a64ec2bec0 --- /dev/null +++ b/go/src/cmd/go/internal/gover/version.go @@ -0,0 +1,78 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gover + +import "golang.org/x/mod/modfile" + +const ( + // narrowAllVersion is the Go version at which the + // module-module "all" pattern no longer closes over the dependencies of + // tests outside of the main module. + NarrowAllVersion = "1.16" + + // DefaultGoModVersion is the Go version to assume for go.mod files + // that do not declare a Go version. The go command has been + // writing go versions to modules since Go 1.12, so a go.mod + // without a version is either very old or recently hand-written. + // Since we can't tell which, we have to assume it's very old. + // The semantics of the go.mod changed at Go 1.17 to support + // graph pruning. If see a go.mod without a go line, we have to + // assume Go 1.16 so that we interpret the requirements correctly. + // Note that this default must stay at Go 1.16; it cannot be moved forward. + DefaultGoModVersion = "1.16" + + // DefaultGoWorkVersion is the Go version to assume for go.work files + // that do not declare a Go version. Workspaces were added in Go 1.18, + // so use that. + DefaultGoWorkVersion = "1.18" + + // ExplicitIndirectVersion is the Go version at which a + // module's go.mod file is expected to list explicit requirements on every + // module that provides any package transitively imported by that module. + // + // Other indirect dependencies of such a module can be safely pruned out of + // the module graph; see https://golang.org/ref/mod#graph-pruning. + ExplicitIndirectVersion = "1.17" + + // separateIndirectVersion is the Go version at which + // "// indirect" dependencies are added in a block separate from the direct + // ones. See https://golang.org/issue/45965. + SeparateIndirectVersion = "1.17" + + // tidyGoModSumVersion is the Go version at which + // 'go mod tidy' preserves go.mod checksums needed to build test dependencies + // of packages in "all", so that 'go test all' can be run without checksum + // errors. + // See https://go.dev/issue/56222. + TidyGoModSumVersion = "1.21" + + // goStrictVersion is the Go version at which the Go versions + // became "strict" in the sense that, restricted to modules at this version + // or later, every module must have a go version line ≥ all its dependencies. + // It is also the version after which "too new" a version is considered a fatal error. + GoStrictVersion = "1.21" + + // ExplicitModulesTxtImportVersion is the Go version at which vendored packages need to be present + // in modules.txt to be imported. + ExplicitModulesTxtImportVersion = "1.23" +) + +// FromGoMod returns the go version from the go.mod file. +// It returns DefaultGoModVersion if the go.mod file does not contain a go line or if mf is nil. +func FromGoMod(mf *modfile.File) string { + if mf == nil || mf.Go == nil { + return DefaultGoModVersion + } + return mf.Go.Version +} + +// FromGoWork returns the go version from the go.mod file. +// It returns DefaultGoWorkVersion if the go.mod file does not contain a go line or if wf is nil. +func FromGoWork(wf *modfile.WorkFile) string { + if wf == nil || wf.Go == nil { + return DefaultGoWorkVersion + } + return wf.Go.Version +} diff --git a/go/src/cmd/go/internal/help/help.go b/go/src/cmd/go/internal/help/help.go new file mode 100644 index 0000000000000000000000000000000000000000..4f2607fef2b89f082f96f22b01346226d48ceb3c --- /dev/null +++ b/go/src/cmd/go/internal/help/help.go @@ -0,0 +1,192 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package help implements the “go help” command. +package help + +import ( + "bufio" + "fmt" + "io" + "os" + "strings" + "text/template" + "unicode" + "unicode/utf8" + + "cmd/go/internal/base" + "cmd/internal/telemetry/counter" +) + +var counterErrorsHelpUnknownTopic = counter.New("go/errors:help-unknown-topic") + +// Help implements the 'help' command. +func Help(w io.Writer, args []string) { + // 'go help documentation' generates doc.go. + if len(args) == 1 && args[0] == "documentation" { + fmt.Fprintln(w, "// Copyright 2011 The Go Authors. All rights reserved.") + fmt.Fprintln(w, "// Use of this source code is governed by a BSD-style") + fmt.Fprintln(w, "// license that can be found in the LICENSE file.") + fmt.Fprintln(w) + fmt.Fprintln(w, "// Code generated by 'go test cmd/go -v -run=^TestDocsUpToDate$ -fixdocs'; DO NOT EDIT.") + fmt.Fprintln(w, "// Edit the documentation in other files and then execute 'go generate cmd/go' to generate this one.") + fmt.Fprintln(w) + buf := new(strings.Builder) + PrintUsage(buf, base.Go) + usage := &base.Command{Long: buf.String()} + cmds := []*base.Command{usage} + for _, cmd := range base.Go.Commands { + cmds = append(cmds, cmd) + cmds = append(cmds, cmd.Commands...) + } + tmpl(&commentWriter{W: w}, documentationTemplate, cmds) + fmt.Fprintln(w, "package main") + return + } + + cmd := base.Go +Args: + for i, arg := range args { + for _, sub := range cmd.Commands { + if sub.Name() == arg { + cmd = sub + continue Args + } + } + + // helpSuccess is the help command using as many args as possible that would succeed. + helpSuccess := "go help" + if i > 0 { + helpSuccess += " " + strings.Join(args[:i], " ") + } + counterErrorsHelpUnknownTopic.Inc() + fmt.Fprintf(os.Stderr, "go help %s: unknown help topic. Run '%s'.\n", strings.Join(args, " "), helpSuccess) + base.SetExitStatus(2) // failed at 'go help cmd' + base.Exit() + } + + if len(cmd.Commands) > 0 { + PrintUsage(os.Stdout, cmd) + } else { + tmpl(os.Stdout, helpTemplate, cmd) + } + // not exit 2: succeeded at 'go help cmd'. + return +} + +var usageTemplate = `{{.Long | trim}} + +Usage: + + {{.UsageLine}} [arguments] + +The commands are: +{{range .Commands}}{{if or (.Runnable) .Commands}} + {{.Name | printf "%-11s"}} {{.Short}}{{end}}{{end}} + +Use "go help{{with .LongName}} {{.}}{{end}} " for more information about a command. +{{if eq (.UsageLine) "go"}} +Additional help topics: +{{range .Commands}}{{if and (not .Runnable) (not .Commands)}} + {{.Name | printf "%-15s"}} {{.Short}}{{end}}{{end}} + +Use "go help{{with .LongName}} {{.}}{{end}} " for more information about that topic. +{{end}} +` + +var helpTemplate = `{{if .Runnable}}usage: {{.UsageLine}} + +{{end}}{{.Long | trim}} +` + +var documentationTemplate = `{{range .}}{{if .Short}}{{.Short | capitalize}} + +{{end}}{{if .Commands}}` + usageTemplate + `{{else}}{{if .Runnable}}Usage: + + {{.UsageLine}} + +{{end}}{{.Long | trim}} + + +{{end}}{{end}}` + +// commentWriter writes a Go comment to the underlying io.Writer, +// using line comment form (//). +type commentWriter struct { + W io.Writer + wroteSlashes bool // Wrote "//" at the beginning of the current line. +} + +func (c *commentWriter) Write(p []byte) (int, error) { + var n int + for i, b := range p { + if !c.wroteSlashes { + s := "//" + if b != '\n' { + s = "// " + } + if _, err := io.WriteString(c.W, s); err != nil { + return n, err + } + c.wroteSlashes = true + } + n0, err := c.W.Write(p[i : i+1]) + n += n0 + if err != nil { + return n, err + } + if b == '\n' { + c.wroteSlashes = false + } + } + return len(p), nil +} + +// An errWriter wraps a writer, recording whether a write error occurred. +type errWriter struct { + w io.Writer + err error +} + +func (w *errWriter) Write(b []byte) (int, error) { + n, err := w.w.Write(b) + if err != nil { + w.err = err + } + return n, err +} + +// tmpl executes the given template text on data, writing the result to w. +func tmpl(w io.Writer, text string, data any) { + t := template.New("top") + t.Funcs(template.FuncMap{"trim": strings.TrimSpace, "capitalize": capitalize}) + template.Must(t.Parse(text)) + ew := &errWriter{w: w} + err := t.Execute(ew, data) + if ew.err != nil { + // I/O error writing. Ignore write on closed pipe. + if strings.Contains(ew.err.Error(), "pipe") { + base.SetExitStatus(1) + base.Exit() + } + base.Fatalf("writing output: %v", ew.err) + } + if err != nil { + panic(err) + } +} + +func capitalize(s string) string { + if s == "" { + return s + } + r, n := utf8.DecodeRuneInString(s) + return string(unicode.ToTitle(r)) + s[n:] +} + +func PrintUsage(w io.Writer, cmd *base.Command) { + bw := bufio.NewWriter(w) + tmpl(bw, usageTemplate, cmd) + bw.Flush() +} diff --git a/go/src/cmd/go/internal/help/helpdoc.go b/go/src/cmd/go/internal/help/helpdoc.go new file mode 100644 index 0000000000000000000000000000000000000000..1d3ffefc9752057729757be850f3cf0a1bdefb5f --- /dev/null +++ b/go/src/cmd/go/internal/help/helpdoc.go @@ -0,0 +1,1137 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package help + +import "cmd/go/internal/base" + +var HelpC = &base.Command{ + UsageLine: "c", + Short: "calling between Go and C", + Long: ` +There are two different ways to call between Go and C/C++ code. + +The first is the cgo tool, which is part of the Go distribution. For +information on how to use it see the cgo documentation (go doc cmd/cgo). + +The second is the SWIG program, which is a general tool for +interfacing between languages. For information on SWIG see +https://swig.org/. When running go build, any file with a .swig +extension will be passed to SWIG. Any file with a .swigcxx extension +will be passed to SWIG with the -c++ option. A package can't be just +a .swig or .swigcxx file; there must be at least one .go file, even if +it has just a package clause. + +When either cgo or SWIG is used, go build will pass any .c, .m, .s, .S +or .sx files to the C compiler, and any .cc, .cpp, .cxx files to the C++ +compiler. The CC or CXX environment variables may be set to determine +the C or C++ compiler, respectively, to use. + `, +} + +var HelpPackages = &base.Command{ + UsageLine: "packages", + Short: "package lists and patterns", + Long: ` +Many commands apply to a set of packages: + + go [packages] + +Usually, [packages] is a list of import paths. + +An import path that is a rooted path or that begins with +a . or .. element is interpreted as a file system path and +denotes the package in that directory. + +Otherwise, the import path P denotes the package found in +the directory DIR/src/P for some DIR listed in the GOPATH +environment variable (For more details see: 'go help gopath'). + +If no import paths are given, the action applies to the +package in the current directory. + +There are five reserved names for paths that should not be used +for packages to be built with the go tool: + +- "main" denotes the top-level package in a stand-alone executable. + +- "all" expands to all packages in the main module (or workspace modules) and +their dependencies, including dependencies needed by tests of any of those. In +GOPATH mode, "all" expands to all packages found in all the GOPATH trees. + +- "std" is like all but expands to just the packages in the standard +Go library. + +- "cmd" expands to the Go repository's commands and their +internal libraries. + +- "tool" expands to the tools defined in the current module's go.mod file. + +Package names match against fully-qualified import paths or patterns that +match against any number of import paths. For instance, "fmt" refers to the +standard library's package fmt, but "http" alone for package http would not +match the import path "net/http" from the standard library. Instead, the +complete import path "net/http" must be used. + +Import paths beginning with "cmd/" only match source code in +the Go repository. + +An import path is a pattern if it includes one or more "..." wildcards, +each of which can match any string, including the empty string and +strings containing slashes. Such a pattern expands to all package +directories found in the GOPATH trees with names matching the +patterns. + +To make common patterns more convenient, there are two special cases. +First, /... at the end of the pattern can match an empty string, +so that net/... matches both net and packages in its subdirectories, like net/http. +Second, any slash-separated pattern element containing a wildcard never +participates in a match of the "vendor" element in the path of a vendored +package, so that ./... does not match packages in subdirectories of +./vendor or ./mycode/vendor, but ./vendor/... and ./mycode/vendor/... do. +Note, however, that a directory named vendor that itself contains code +is not a vendored package: cmd/vendor would be a command named vendor, +and the pattern cmd/... matches it. +See golang.org/s/go15vendor for more about vendoring. + +An import path can also name a package to be downloaded from +a remote repository. Run 'go help importpath' for details. + +Every package in a program must have a unique import path. +By convention, this is arranged by starting each path with a +unique prefix that belongs to you. For example, paths used +internally at Google all begin with 'google', and paths +denoting remote repositories begin with the path to the code, +such as 'github.com/user/repo'. Package patterns should include this prefix. +For instance, a package called 'http' residing under 'github.com/user/repo', +would be addressed with the fully-qualified pattern: +'github.com/user/repo/http'. + +Packages in a program need not have unique package names, +but there are two reserved package names with special meaning. +The name main indicates a command, not a library. +Commands are built into binaries and cannot be imported. +The name documentation indicates documentation for +a non-Go program in the directory. Files in package documentation +are ignored by the go command. + +As a special case, if the package list is a list of .go files from a +single directory, the command is applied to a single synthesized +package made up of exactly those files, ignoring any build constraints +in those files and ignoring any other files in the directory. + +Directory and file names that begin with "." or "_" are ignored +by the go tool, as are directories named "testdata". + `, +} + +var HelpImportPath = &base.Command{ + UsageLine: "importpath", + Short: "import path syntax", + Long: ` + +An import path (see 'go help packages') denotes a package stored in the local +file system. In general, an import path denotes either a standard package (such +as "unicode/utf8") or a package found in one of the work spaces (For more +details see: 'go help gopath'). + +Relative import paths + +An import path beginning with ./ or ../ is called a relative path. +The toolchain supports relative import paths as a shortcut in two ways. + +First, a relative path can be used as a shorthand on the command line. +If you are working in the directory containing the code imported as +"unicode" and want to run the tests for "unicode/utf8", you can type +"go test ./utf8" instead of needing to specify the full path. +Similarly, in the reverse situation, "go test .." will test "unicode" from +the "unicode/utf8" directory. Relative patterns are also allowed, like +"go test ./..." to test all subdirectories. See 'go help packages' for details +on the pattern syntax. + +Second, if you are compiling a Go program not in a work space, +you can use a relative path in an import statement in that program +to refer to nearby code also not in a work space. +This makes it easy to experiment with small multipackage programs +outside of the usual work spaces, but such programs cannot be +installed with "go install" (there is no work space in which to install them), +so they are rebuilt from scratch each time they are built. +To avoid ambiguity, Go programs cannot use relative import paths +within a work space. + +Remote import paths + +Certain import paths also +describe how to obtain the source code for the package using +a revision control system. + +A few common code hosting sites have special syntax: + + Bitbucket (Git, Mercurial) + + import "bitbucket.org/user/project" + import "bitbucket.org/user/project/sub/directory" + + GitHub (Git) + + import "github.com/user/project" + import "github.com/user/project/sub/directory" + + Launchpad (Bazaar) + + import "launchpad.net/project" + import "launchpad.net/project/series" + import "launchpad.net/project/series/sub/directory" + + import "launchpad.net/~user/project/branch" + import "launchpad.net/~user/project/branch/sub/directory" + + IBM DevOps Services (Git) + + import "hub.jazz.net/git/user/project" + import "hub.jazz.net/git/user/project/sub/directory" + +For code hosted on other servers, import paths may either be qualified +with the version control type, or the go tool can dynamically fetch +the import path over https/http and discover where the code resides +from a tag in the HTML. + +To declare the code location, an import path of the form + + repository.vcs/path + +specifies the given repository, with or without the .vcs suffix, +using the named version control system, and then the path inside +that repository. The supported version control systems are: + + Bazaar .bzr + Fossil .fossil + Git .git + Mercurial .hg + Subversion .svn + +For example, + + import "example.org/user/foo.hg" + +denotes the root directory of the Mercurial repository at +example.org/user/foo, and + + import "example.org/repo.git/foo/bar" + +denotes the foo/bar directory of the Git repository at +example.org/repo. + +When a version control system supports multiple protocols, +each is tried in turn when downloading. For example, a Git +download tries https://, then git+ssh://. + +By default, downloads are restricted to known secure protocols +(e.g. https, ssh). To override this setting for Git downloads, the +GIT_ALLOW_PROTOCOL environment variable can be set (For more details see: +'go help environment'). + +If the import path is not a known code hosting site and also lacks a +version control qualifier, the go tool attempts to fetch the import +over https/http and looks for a tag in the document's HTML +. + +The meta tag has the form: + + + +Starting in Go 1.25, an optional subdirectory will be recognized by the +go command: + + + +The import-prefix is the import path corresponding to the repository +root. It must be a prefix or an exact match of the package being +fetched with "go get". If it's not an exact match, another http +request is made at the prefix to verify the tags match. + +The meta tag should appear as early in the file as possible. +In particular, it should appear before any raw JavaScript or CSS, +to avoid confusing the go command's restricted parser. + +The vcs is one of "bzr", "fossil", "git", "hg", "svn". + +The repo-root is the root of the version control system +containing a scheme and not containing a .vcs qualifier. + +The subdir specifies the directory within the repo-root where the +Go module's root (including its go.mod file) is located. It allows +you to organize your repository with the Go module code in a subdirectory +rather than directly at the repository's root. +If set, all vcs tags must be prefixed with "subdir". i.e. "subdir/v1.2.3" + +For example, + + import "example.org/pkg/foo" + +will result in the following requests: + + https://example.org/pkg/foo?go-get=1 (preferred) + http://example.org/pkg/foo?go-get=1 (fallback, only with use of correctly set GOINSECURE) + +If that page contains the meta tag + + + +the go tool will verify that https://example.org/?go-get=1 contains the +same meta tag and then download the code from the Git repository at https://code.org/r/p/exproj + +If that page contains the meta tag + + + +the go tool will verify that https://example.org/?go-get=1 contains the same meta +tag and then download the code from the "foo/subdir" subdirectory within the Git repository +at https://code.org/r/p/exproj + +Downloaded packages are stored in the module cache. +See https://golang.org/ref/mod#module-cache. + +When using modules, an additional variant of the go-import meta tag is +recognized and is preferred over those listing version control systems. +That variant uses "mod" as the vcs in the content value, as in: + + + +This tag means to fetch modules with paths beginning with example.org +from the module proxy available at the URL https://code.org/moduleproxy. +See https://golang.org/ref/mod#goproxy-protocol for details about the +proxy protocol. + +Import path checking + +When the custom import path feature described above redirects to a +known code hosting site, each of the resulting packages has two possible +import paths, using the custom domain or the known hosting site. + +A package statement is said to have an "import comment" if it is immediately +followed (before the next newline) by a comment of one of these two forms: + + package math // import "path" + package math /* import "path" */ + +The go command will refuse to install a package with an import comment +unless it is being referred to by that import path. In this way, import comments +let package authors make sure the custom import path is used and not a +direct path to the underlying code hosting site. + +Import path checking is disabled for code found within vendor trees. +This makes it possible to copy code into alternate locations in vendor trees +without needing to update import comments. + +Import path checking is also disabled when using modules. +Import path comments are obsoleted by the go.mod file's module statement. + +See https://golang.org/s/go14customimport for details. + `, +} + +var HelpGopath = &base.Command{ + UsageLine: "gopath", + Short: "GOPATH environment variable", + Long: ` +The Go path is used to resolve import statements. +It is implemented by and documented in the go/build package. + +The GOPATH environment variable lists places to look for Go code. +On Unix, the value is a colon-separated string. +On Windows, the value is a semicolon-separated string. +On Plan 9, the value is a list. + +If the environment variable is unset, GOPATH defaults +to a subdirectory named "go" in the user's home directory +($HOME/go on Unix, %USERPROFILE%\go on Windows), +unless that directory holds a Go distribution. +Run "go env GOPATH" to see the current GOPATH. + +See https://golang.org/wiki/SettingGOPATH to set a custom GOPATH. + +Each directory listed in GOPATH must have a prescribed structure: + +The src directory holds source code. The path below src +determines the import path or executable name. + +The pkg directory holds installed package objects. +As in the Go tree, each target operating system and +architecture pair has its own subdirectory of pkg +(pkg/GOOS_GOARCH). + +If DIR is a directory listed in the GOPATH, a package with +source in DIR/src/foo/bar can be imported as "foo/bar" and +has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a". + +The bin directory holds compiled commands. +Each command is named for its source directory, but only +the final element, not the entire path. That is, the +command with source in DIR/src/foo/quux is installed into +DIR/bin/quux, not DIR/bin/foo/quux. The "foo/" prefix is stripped +so that you can add DIR/bin to your PATH to get at the +installed commands. If the GOBIN environment variable is +set, commands are installed to the directory it names instead +of DIR/bin. GOBIN must be an absolute path. + +Here's an example directory layout: + + GOPATH=/home/user/go + + /home/user/go/ + src/ + foo/ + bar/ (go code in package bar) + x.go + quux/ (go code in package main) + y.go + bin/ + quux (installed command) + pkg/ + linux_amd64/ + foo/ + bar.a (installed package object) + +Go searches each directory listed in GOPATH to find source code, +but new packages are always downloaded into the first directory +in the list. + +See https://golang.org/doc/code.html for an example. + +GOPATH and Modules + +When using modules, GOPATH is no longer used for resolving imports. +However, it is still used to store downloaded source code (in GOPATH/pkg/mod) +and compiled commands (in GOPATH/bin). + +Internal Directories + +Code in or below a directory named "internal" is importable only +by code in the directory tree rooted at the parent of "internal". +Here's an extended version of the directory layout above: + + /home/user/go/ + src/ + crash/ + bang/ (go code in package bang) + b.go + foo/ (go code in package foo) + f.go + bar/ (go code in package bar) + x.go + internal/ + baz/ (go code in package baz) + z.go + quux/ (go code in package main) + y.go + + +The code in z.go is imported as "foo/internal/baz", but that +import statement can only appear in source files in the subtree +rooted at foo. The source files foo/f.go, foo/bar/x.go, and +foo/quux/y.go can all import "foo/internal/baz", but the source file +crash/bang/b.go cannot. + +See https://golang.org/s/go14internal for details. + +Vendor Directories + +Go 1.6 includes support for using local copies of external dependencies +to satisfy imports of those dependencies, often referred to as vendoring. + +Code below a directory named "vendor" is importable only +by code in the directory tree rooted at the parent of "vendor", +and only using an import path that omits the prefix up to and +including the vendor element. + +Here's the example from the previous section, +but with the "internal" directory renamed to "vendor" +and a new foo/vendor/crash/bang directory added: + + /home/user/go/ + src/ + crash/ + bang/ (go code in package bang) + b.go + foo/ (go code in package foo) + f.go + bar/ (go code in package bar) + x.go + vendor/ + crash/ + bang/ (go code in package bang) + b.go + baz/ (go code in package baz) + z.go + quux/ (go code in package main) + y.go + +The same visibility rules apply as for internal, but the code +in z.go is imported as "baz", not as "foo/vendor/baz". + +Code in vendor directories deeper in the source tree shadows +code in higher directories. Within the subtree rooted at foo, an import +of "crash/bang" resolves to "foo/vendor/crash/bang", not the +top-level "crash/bang". + +Code in vendor directories is not subject to import path +checking (see 'go help importpath'). + +When 'go get' checks out or updates a git repository, it now also +updates submodules. + +Vendor directories do not affect the placement of new repositories +being checked out for the first time by 'go get': those are always +placed in the main GOPATH, never in a vendor subtree. + +See https://golang.org/s/go15vendor for details. + `, +} + +var HelpEnvironment = &base.Command{ + UsageLine: "environment", + Short: "environment variables", + Long: ` + +The go command and the tools it invokes consult environment variables +for configuration. If an environment variable is unset or empty, the go +command uses a sensible default setting. To see the effective setting of +the variable , run 'go env '. To change the default setting, +run 'go env -w ='. Defaults changed using 'go env -w' +are recorded in a Go environment configuration file stored in the +per-user configuration directory, as reported by os.UserConfigDir. +The location of the configuration file can be changed by setting +the environment variable GOENV, and 'go env GOENV' prints the +effective location, but 'go env -w' cannot change the default location. +See 'go help env' for details. + +General-purpose environment variables: + + GCCGO + The gccgo command to run for 'go build -compiler=gccgo'. + GO111MODULE + Controls whether the go command runs in module-aware mode or GOPATH mode. + May be "off", "on", or "auto". + See https://golang.org/ref/mod#mod-commands. + GOARCH + The architecture, or processor, for which to compile code. + Examples are amd64, 386, arm, ppc64. + GOAUTH + Controls authentication for go-import and HTTPS module mirror interactions. + See 'go help goauth'. + GOBIN + The directory where 'go install' will install a command. + GOCACHE + The directory where the go command will store cached + information for reuse in future builds. Must be an absolute path. + GOCACHEPROG + A command (with optional space-separated flags) that implements an + external go command build cache. + See 'go doc cmd/go/internal/cacheprog'. + GODEBUG + Enable various debugging facilities for programs built with Go, + including the go command. Cannot be set using 'go env -w'. + See https://go.dev/doc/godebug for details. + GOENV + The location of the Go environment configuration file. + Cannot be set using 'go env -w'. + Setting GOENV=off in the environment disables the use of the + default configuration file. + GOFLAGS + A space-separated list of -flag=value settings to apply + to go commands by default, when the given flag is known by + the current command. Each entry must be a standalone flag. + Because the entries are space-separated, flag values must + not contain spaces. Flags listed on the command line + are applied after this list and therefore override it. + GOINSECURE + Comma-separated list of glob patterns (in the syntax of Go's path.Match) + of module path prefixes that should always be fetched in an insecure + manner. Only applies to dependencies that are being fetched directly. + GOINSECURE does not disable checksum database validation. GOPRIVATE or + GONOSUMDB may be used to achieve that. + GOMODCACHE + The directory where the go command will store downloaded modules. + GOOS + The operating system for which to compile code. + Examples are linux, darwin, windows, netbsd. + GOPATH + Controls where various files are stored. See: 'go help gopath'. + GOPRIVATE, GONOPROXY, GONOSUMDB + Comma-separated list of glob patterns (in the syntax of Go's path.Match) + of module path prefixes that should always be fetched directly + or that should not be compared against the checksum database. + See https://golang.org/ref/mod#private-modules. + GOPROXY + URL of Go module proxy. See https://golang.org/ref/mod#environment-variables + and https://golang.org/ref/mod#module-proxy for details. + GOROOT + The root of the go tree. + GOSUMDB + The name of checksum database to use and optionally its public key and + URL. See https://golang.org/ref/mod#authenticating. + GOTMPDIR + Temporary directory used by the go command and testing package. + Overrides the platform-specific temporary directory such as "/tmp". + The go command and testing package will write temporary source files, + packages, and binaries here. + GOTOOLCHAIN + Controls which Go toolchain is used. See https://go.dev/doc/toolchain. + GOVCS + Lists version control commands that may be used with matching servers. + See 'go help vcs'. + GOWORK + In module aware mode, use the given go.work file as a workspace file. + By default or when GOWORK is "auto", the go command searches for a + file named go.work in the current directory and then containing directories + until one is found. If a valid go.work file is found, the modules + specified will collectively be used as the main modules. If GOWORK + is "off", or a go.work file is not found in "auto" mode, workspace + mode is disabled. + +Environment variables for use with cgo: + + AR + The command to use to manipulate library archives when + building with the gccgo compiler. + The default is 'ar'. + CC + The command to use to compile C code. + CGO_CFLAGS + Flags that cgo will pass to the compiler when compiling + C code. + CGO_CFLAGS_ALLOW + A regular expression specifying additional flags to allow + to appear in #cgo CFLAGS source code directives. + Does not apply to the CGO_CFLAGS environment variable. + CGO_CFLAGS_DISALLOW + A regular expression specifying flags that must be disallowed + from appearing in #cgo CFLAGS source code directives. + Does not apply to the CGO_CFLAGS environment variable. + CGO_CPPFLAGS, CGO_CPPFLAGS_ALLOW, CGO_CPPFLAGS_DISALLOW + Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, + but for the C preprocessor. + CGO_CXXFLAGS, CGO_CXXFLAGS_ALLOW, CGO_CXXFLAGS_DISALLOW + Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, + but for the C++ compiler. + CGO_ENABLED + Whether the cgo command is supported. Either 0 or 1. + CGO_FFLAGS, CGO_FFLAGS_ALLOW, CGO_FFLAGS_DISALLOW + Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, + but for the Fortran compiler. + CGO_LDFLAGS, CGO_LDFLAGS_ALLOW, CGO_LDFLAGS_DISALLOW + Like CGO_CFLAGS, CGO_CFLAGS_ALLOW, and CGO_CFLAGS_DISALLOW, + but for the linker. + CXX + The command to use to compile C++ code. + FC + The command to use to compile Fortran code. + PKG_CONFIG + Path to pkg-config tool. + +Architecture-specific environment variables: + + GO386 + For GOARCH=386, how to implement floating point instructions. + Valid values are sse2 (default), softfloat. + GOAMD64 + For GOARCH=amd64, the microarchitecture level for which to compile. + Valid values are v1 (default), v2, v3, v4. + See https://golang.org/wiki/MinimumRequirements#amd64 + GOARM + For GOARCH=arm, the ARM architecture for which to compile. + Valid values are 5, 6, 7. + When the Go tools are built on an arm system, + the default value is set based on what the build system supports. + When the Go tools are not built on an arm system + (that is, when building a cross-compiler), + the default value is 7. + The value can be followed by an option specifying how to implement floating point instructions. + Valid options are ,softfloat (default for 5) and ,hardfloat (default for 6 and 7). + GOARM64 + For GOARCH=arm64, the ARM64 architecture for which to compile. + Valid values are v8.0 (default), v8.{1-9}, v9.{0-5}. + The value can be followed by an option specifying extensions implemented by target hardware. + Valid options are ,lse and ,crypto. + Note that some extensions are enabled by default starting from a certain GOARM64 version; + for example, lse is enabled by default starting from v8.1. + GOMIPS + For GOARCH=mips{,le}, whether to use floating point instructions. + Valid values are hardfloat (default), softfloat. + GOMIPS64 + For GOARCH=mips64{,le}, whether to use floating point instructions. + Valid values are hardfloat (default), softfloat. + GOPPC64 + For GOARCH=ppc64{,le}, the target ISA (Instruction Set Architecture). + Valid values are power8 (default), power9, power10. + GORISCV64 + For GOARCH=riscv64, the RISC-V user-mode application profile for which + to compile. Valid values are rva20u64 (default), rva22u64, rva23u64. + See https://github.com/riscv/riscv-profiles/blob/main/src/profiles.adoc + and https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc + GOWASM + For GOARCH=wasm, comma-separated list of experimental WebAssembly features to use. + Valid values are satconv, signext. + +Environment variables for use with code coverage: + + GOCOVERDIR + Directory into which to write code coverage data files + generated by running a "go build -cover" binary. + +Special-purpose environment variables: + + GCCGOTOOLDIR + If set, where to find gccgo tools, such as cgo. + The default is based on how gccgo was configured. + GOEXPERIMENT + Comma-separated list of toolchain experiments to enable or disable. + The list of available experiments may change arbitrarily over time. + See GOROOT/src/internal/goexperiment/flags.go for currently valid values. + Warning: This variable is provided for the development and testing + of the Go toolchain itself. Use beyond that purpose is unsupported. + GOFIPS140 + The FIPS-140 cryptography mode to use when building binaries. + The default is GOFIPS140=off, which makes no FIPS-140 changes at all. + Other values enable FIPS-140 compliance measures and select alternate + versions of the cryptography source code. + See https://go.dev/doc/security/fips140 for details. + GO_EXTLINK_ENABLED + Whether the linker should use external linking mode + when using -linkmode=auto with code that uses cgo. + Set to 0 to disable external linking mode, 1 to enable it. + GIT_ALLOW_PROTOCOL + Defined by Git. A colon-separated list of schemes that are allowed + to be used with git fetch/clone. If set, any scheme not explicitly + mentioned will be considered insecure by 'go get'. + Because the variable is defined by Git, the default value cannot + be set using 'go env -w'. + +Additional information available from 'go env' but not read from the environment: + + GOEXE + The executable file name suffix (".exe" on Windows, "" on other systems). + GOGCCFLAGS + A space-separated list of arguments supplied to the CC command. + GOHOSTARCH + The architecture (GOARCH) of the Go toolchain binaries. + GOHOSTOS + The operating system (GOOS) of the Go toolchain binaries. + GOMOD + The absolute path to the go.mod of the main module. + If module-aware mode is enabled, but there is no go.mod, GOMOD will be + os.DevNull ("/dev/null" on Unix-like systems, "NUL" on Windows). + If module-aware mode is disabled, GOMOD will be the empty string. + GOTELEMETRY + The current Go telemetry mode ("off", "local", or "on"). + See "go help telemetry" for more information. + GOTELEMETRYDIR + The directory Go telemetry data is written is written to. + GOTOOLDIR + The directory where the go tools (compile, cover, doc, etc...) are installed. + GOVERSION + The version of the installed Go tree, as reported by runtime.Version. + `, +} + +var HelpFileType = &base.Command{ + UsageLine: "filetype", + Short: "file types", + Long: ` +The go command examines the contents of a restricted set of files +in each directory. It identifies which files to examine based on +the extension of the file name. These extensions are: + + .go + Go source files. + .c, .h + C source files. + If the package uses cgo or SWIG, these will be compiled with the + OS-native compiler (typically gcc); otherwise they will + trigger an error. + .cc, .cpp, .cxx, .hh, .hpp, .hxx + C++ source files. Only useful with cgo or SWIG, and always + compiled with the OS-native compiler. + .m + Objective-C source files. Only useful with cgo, and always + compiled with the OS-native compiler. + .s, .S, .sx + Assembler source files. + If the package uses cgo or SWIG, these will be assembled with the + OS-native assembler (typically gcc (sic)); otherwise they + will be assembled with the Go assembler. + .swig, .swigcxx + SWIG definition files. + .syso + System object files. + +Files of each of these types except .syso may contain build +constraints, but the go command stops scanning for build constraints +at the first item in the file that is not a blank line or //-style +line comment. See the go/build package documentation for +more details. + `, +} + +var HelpBuildmode = &base.Command{ + UsageLine: "buildmode", + Short: "build modes", + Long: ` +The 'go build' and 'go install' commands take a -buildmode argument which +indicates which kind of object file is to be built. Currently supported values +are: + + -buildmode=archive + Build the listed non-main packages into .a files. Packages named + main are ignored. + + -buildmode=c-archive + Build the listed main package, plus all packages it imports, + into a C archive file. The only callable symbols will be those + functions exported using a cgo //export comment. Requires + exactly one main package to be listed. + + -buildmode=c-shared + Build the listed main package, plus all packages it imports, + into a C shared library. The only callable symbols will + be those functions exported using a cgo //export comment. + On wasip1, this mode builds it to a WASI reactor/library, + of which the callable symbols are those functions exported + using a //go:wasmexport directive. Requires exactly one + main package to be listed. + + -buildmode=default + Listed main packages are built into executables and listed + non-main packages are built into .a files (the default + behavior). + + -buildmode=shared + Combine all the listed non-main packages into a single shared + library that will be used when building with the -linkshared + option. Packages named main are ignored. + + -buildmode=exe + Build the listed main packages and everything they import into + executables. Packages not named main are ignored. + + -buildmode=pie + Build the listed main packages and everything they import into + position independent executables (PIE). Packages not named + main are ignored. + + -buildmode=plugin + Build the listed main packages, plus all packages that they + import, into a Go plugin. Packages not named main are ignored. + +On AIX, when linking a C program that uses a Go archive built with +-buildmode=c-archive, you must pass -Wl,-bnoobjreorder to the C compiler. +`, +} + +var HelpCache = &base.Command{ + UsageLine: "cache", + Short: "build and test caching", + Long: ` +The go command caches build outputs for reuse in future builds. +The default location for cache data is a subdirectory named go-build +in the standard user cache directory for the current operating system. +The cache is safe for concurrent invocations of the go command. +Setting the GOCACHE environment variable overrides this default, +and running 'go env GOCACHE' prints the current cache directory. + +The go command periodically deletes cached data that has not been +used recently. Running 'go clean -cache' deletes all cached data. + +The build cache correctly accounts for changes to Go source files, +compilers, compiler options, and so on: cleaning the cache explicitly +should not be necessary in typical use. However, the build cache +does not detect changes to C libraries imported with cgo. +If you have made changes to the C libraries on your system, you +will need to clean the cache explicitly or else use the -a build flag +(see 'go help build') to force rebuilding of packages that +depend on the updated C libraries. + +The go command also caches successful package test results. +See 'go help test' for details. Running 'go clean -testcache' removes +all cached test results (but not cached build results). + +The go command also caches values used in fuzzing with 'go test -fuzz', +specifically, values that expanded code coverage when passed to a +fuzz function. These values are not used for regular building and +testing, but they're stored in a subdirectory of the build cache. +Running 'go clean -fuzzcache' removes all cached fuzzing values. +This may make fuzzing less effective, temporarily. + +The GODEBUG environment variable can enable printing of debugging +information about the state of the cache: + +GODEBUG=gocacheverify=1 causes the go command to bypass the +use of any cache entries and instead rebuild everything and check +that the results match existing cache entries. + +GODEBUG=gocachehash=1 causes the go command to print the inputs +for all of the content hashes it uses to construct cache lookup keys. +The output is voluminous but can be useful for debugging the cache. + +GODEBUG=gocachetest=1 causes the go command to print details of its +decisions about whether to reuse a cached test result. +`, +} + +var HelpBuildConstraint = &base.Command{ + UsageLine: "buildconstraint", + Short: "build constraints", + Long: ` +A build constraint, also known as a build tag, is a condition under which a +file should be included in the package. Build constraints are given by a +line comment that begins + + //go:build + +Build constraints can also be used to downgrade the language version +used to compile a file. + +Constraints may appear in any kind of source file (not just Go), but +they must appear near the top of the file, preceded +only by blank lines and other comments. These rules mean that in Go +files a build constraint must appear before the package clause. + +To distinguish build constraints from package documentation, +a build constraint should be followed by a blank line. + +A build constraint comment is evaluated as an expression containing +build tags combined by ||, &&, and ! operators and parentheses. +Operators have the same meaning as in Go. + +For example, the following build constraint constrains a file to +build when the "linux" and "386" constraints are satisfied, or when +"darwin" is satisfied and "cgo" is not: + + //go:build (linux && 386) || (darwin && !cgo) + +It is an error for a file to have more than one //go:build line. + +During a particular build, the following build tags are satisfied: + + - the target operating system, as spelled by runtime.GOOS, set with the + GOOS environment variable. + - the target architecture, as spelled by runtime.GOARCH, set with the + GOARCH environment variable. + - any architecture features, in the form GOARCH.feature + (for example, "amd64.v2"), as detailed below. + - "unix", if GOOS is a Unix or Unix-like system. + - the compiler being used, either "gc" or "gccgo" + - "cgo", if the cgo command is supported (see CGO_ENABLED in + 'go help environment'). + - a term for each Go major release, through the current version: + "go1.1" from Go version 1.1 onward, "go1.12" from Go 1.12, and so on. + - any additional tags given by the -tags flag (see 'go help build'). + +There are no separate build tags for beta or minor releases. + +If a file's name, after stripping the extension and a possible _test suffix, +matches any of the following patterns: + *_GOOS + *_GOARCH + *_GOOS_GOARCH +(example: source_windows_amd64.go) where GOOS and GOARCH represent +any known operating system and architecture values respectively, then +the file is considered to have an implicit build constraint requiring +those terms (in addition to any explicit constraints in the file). + +Using GOOS=android matches build tags and files as for GOOS=linux +in addition to android tags and files. + +Using GOOS=illumos matches build tags and files as for GOOS=solaris +in addition to illumos tags and files. + +Using GOOS=ios matches build tags and files as for GOOS=darwin +in addition to ios tags and files. + +The defined architecture feature build tags are: + + - For GOARCH=386, GO386=387 and GO386=sse2 + set the 386.387 and 386.sse2 build tags, respectively. + - For GOARCH=amd64, GOAMD64=v1, v2, and v3 + correspond to the amd64.v1, amd64.v2, and amd64.v3 feature build tags. + - For GOARCH=arm, GOARM=5, 6, and 7 + correspond to the arm.5, arm.6, and arm.7 feature build tags. + - For GOARCH=arm64, GOARM64=v8.{0-9} and v9.{0-5} + correspond to the arm64.v8.{0-9} and arm64.v9.{0-5} feature build tags. + - For GOARCH=mips or mipsle, + GOMIPS=hardfloat and softfloat + correspond to the mips.hardfloat and mips.softfloat + (or mipsle.hardfloat and mipsle.softfloat) feature build tags. + - For GOARCH=mips64 or mips64le, + GOMIPS64=hardfloat and softfloat + correspond to the mips64.hardfloat and mips64.softfloat + (or mips64le.hardfloat and mips64le.softfloat) feature build tags. + - For GOARCH=ppc64 or ppc64le, + GOPPC64=power8, power9, and power10 correspond to the + ppc64.power8, ppc64.power9, and ppc64.power10 + (or ppc64le.power8, ppc64le.power9, and ppc64le.power10) + feature build tags. + - For GOARCH=riscv64, + GORISCV64=rva20u64, rva22u64 and rva23u64 correspond to the riscv64.rva20u64, + riscv64.rva22u64 and riscv64.rva23u64 build tags. + - For GOARCH=wasm, GOWASM=satconv and signext + correspond to the wasm.satconv and wasm.signext feature build tags. + +For GOARCH=amd64, arm, ppc64, ppc64le, and riscv64, a particular feature level +sets the feature build tags for all previous levels as well. +For example, GOAMD64=v2 sets the amd64.v1 and amd64.v2 feature flags. +This ensures that code making use of v2 features continues to compile +when, say, GOAMD64=v4 is introduced. +Code handling the absence of a particular feature level +should use a negation: + + //go:build !amd64.v2 + +To keep a file from being considered for any build: + + //go:build ignore + +(Any other unsatisfied word will work as well, but "ignore" is conventional.) + +To build a file only when using cgo, and only on Linux and OS X: + + //go:build cgo && (linux || darwin) + +Such a file is usually paired with another file implementing the +default functionality for other systems, which in this case would +carry the constraint: + + //go:build !(cgo && (linux || darwin)) + +Naming a file dns_windows.go will cause it to be included only when +building the package for Windows; similarly, math_386.s will be included +only when building the package for 32-bit x86. + +By convention, packages with assembly implementations may provide a go-only +version under the "purego" build constraint. This does not limit the use of +cgo (use the "cgo" build constraint) or unsafe. For example: + + //go:build purego + +Go versions 1.16 and earlier used a different syntax for build constraints, +with a "// +build" prefix. The gofmt command will add an equivalent //go:build +constraint when encountering the older syntax. + +In modules with a Go version of 1.21 or later, if a file's build constraint +has a term for a Go major release, the language version used when compiling +the file will be the minimum version implied by the build constraint. +`, +} + +var HelpGoAuth = &base.Command{ + UsageLine: "goauth", + Short: "GOAUTH environment variable", + Long: ` +GOAUTH is a semicolon-separated list of authentication commands for go-import and +HTTPS module mirror interactions. The default is netrc. + +The supported authentication commands are: + +off + Disables authentication. +netrc + Uses credentials from NETRC or the .netrc file in your home directory. +git dir + Runs 'git credential fill' in dir and uses its credentials. The + go command will run 'git credential approve/reject' to update + the credential helper's cache. +command + Executes the given command (a space-separated argument list) and attaches + the provided headers to HTTPS requests. + The command must produce output in the following format: + Response = { CredentialSet } . + CredentialSet = URLLine { URLLine } BlankLine { HeaderLine } BlankLine . + URLLine = /* URL that starts with "https://" */ '\n' . + HeaderLine = /* HTTP Request header */ '\n' . + BlankLine = '\n' . + + Example: + https://example.com + https://example.net/api/ + + Authorization: Basic + + https://another-example.org/ + + Example: Data + + If the server responds with any 4xx code, the go command will write the + following to the program's stdin: + Response = StatusLine { HeaderLine } BlankLine . + StatusLine = Protocol Space Status '\n' . + Protocol = /* HTTP protocol */ . + Space = ' ' . + Status = /* HTTP status code */ . + BlankLine = '\n' . + HeaderLine = /* HTTP Response's header */ '\n' . + + Example: + HTTP/1.1 401 Unauthorized + Content-Length: 19 + Content-Type: text/plain; charset=utf-8 + Date: Thu, 07 Nov 2024 18:43:09 GMT + + Note: it is safe to use net/http.ReadResponse to parse this input. + +Before the first HTTPS fetch, the go command will invoke each GOAUTH +command in the list with no additional arguments and no input. +If the server responds with any 4xx code, the go command will invoke the +GOAUTH commands again with the URL as an additional command-line argument +and the HTTP Response to the program's stdin. +If the server responds with an error again, the fetch fails: a URL-specific +GOAUTH will only be attempted once per fetch. +`, +} + +var HelpBuildJSON = &base.Command{ + UsageLine: "buildjson", + Short: "build -json encoding", + Long: ` +The 'go build', 'go install', and 'go test' commands take a -json flag that +reports build output and failures as structured JSON output on standard +output. + +The JSON stream is a newline-separated sequence of BuildEvent objects +corresponding to the Go struct: + + type BuildEvent struct { + ImportPath string + Action string + Output string + } + +The ImportPath field gives the package ID of the package being built. +This matches the Package.ImportPath field of go list -json and the +TestEvent.FailedBuild field of go test -json. Note that it does not +match TestEvent.Package. + +The Action field is one of the following: + + build-output - The toolchain printed output + build-fail - The build failed + +The Output field is set for Action == "build-output" and is a portion of +the build's output. The concatenation of the Output fields of all output +events is the exact output of the build. A single event may contain one +or more lines of output and there may be more than one output event for +a given ImportPath. This matches the definition of the TestEvent.Output +field produced by go test -json. + +For go test -json, this struct is designed so that parsers can distinguish +interleaved TestEvents and BuildEvents by inspecting the Action field. +Furthermore, as with TestEvent, parsers can simply concatenate the Output +fields of all events to reconstruct the text format output, as it would +have appeared from go build without the -json flag. + +Note that there may also be non-JSON error text on standard error, even +with the -json flag. Typically, this indicates an early, serious error. +Consumers should be robust to this. + `, +} diff --git a/go/src/cmd/go/internal/imports/build.go b/go/src/cmd/go/internal/imports/build.go new file mode 100644 index 0000000000000000000000000000000000000000..6a8b7a84cd41531d11a61febc6ee74f54c872625 --- /dev/null +++ b/go/src/cmd/go/internal/imports/build.go @@ -0,0 +1,309 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copied from Go distribution src/go/build/build.go, syslist.go. +// That package does not export the ability to process raw file data, +// although we could fake it with an appropriate build.Context +// and a lot of unwrapping. +// More importantly, that package does not implement the tags["*"] +// special case, in which both tag and !tag are considered to be true +// for essentially all tags (except "ignore"). +// +// If we added this API to go/build directly, we wouldn't need this +// file anymore, but this API is not terribly general-purpose and we +// don't really want to commit to any public form of it, nor do we +// want to move the core parts of go/build into a top-level internal package. +// These details change very infrequently, so the copy is fine. + +package imports + +import ( + "bytes" + "cmd/go/internal/cfg" + "errors" + "fmt" + "go/build/constraint" + "internal/syslist" + "strings" + "unicode" +) + +var ( + bSlashSlash = []byte("//") + bStarSlash = []byte("*/") + bSlashStar = []byte("/*") + bPlusBuild = []byte("+build") + + goBuildComment = []byte("//go:build") + + errMultipleGoBuild = errors.New("multiple //go:build comments") +) + +func isGoBuildComment(line []byte) bool { + if !bytes.HasPrefix(line, goBuildComment) { + return false + } + line = bytes.TrimSpace(line) + rest := line[len(goBuildComment):] + return len(rest) == 0 || len(bytes.TrimSpace(rest)) < len(rest) +} + +// ShouldBuild reports whether it is okay to use this file, +// The rule is that in the file's leading run of // comments +// and blank lines, which must be followed by a blank line +// (to avoid including a Go package clause doc comment), +// lines beginning with '// +build' are taken as build directives. +// +// The file is accepted only if each such line lists something +// matching the file. For example: +// +// // +build windows linux +// +// marks the file as applicable only on Windows and Linux. +// +// If tags["*"] is true, then ShouldBuild will consider every +// build tag except "ignore" to be both true and false for +// the purpose of satisfying build tags, in order to estimate +// (conservatively) whether a file could ever possibly be used +// in any build. +func ShouldBuild(content []byte, tags map[string]bool) bool { + // Identify leading run of // comments and blank lines, + // which must be followed by a blank line. + // Also identify any //go:build comments. + content, goBuild, _, err := parseFileHeader(content) + if err != nil { + return false + } + + // If //go:build line is present, it controls. + // Otherwise fall back to +build processing. + var shouldBuild bool + switch { + case goBuild != nil: + x, err := constraint.Parse(string(goBuild)) + if err != nil { + return false + } + shouldBuild = eval(x, tags, true) + + default: + shouldBuild = true + p := content + for len(p) > 0 { + line := p + if i := bytes.IndexByte(line, '\n'); i >= 0 { + line, p = line[:i], p[i+1:] + } else { + p = p[len(p):] + } + line = bytes.TrimSpace(line) + if !bytes.HasPrefix(line, bSlashSlash) || !bytes.Contains(line, bPlusBuild) { + continue + } + text := string(line) + if !constraint.IsPlusBuild(text) { + continue + } + if x, err := constraint.Parse(text); err == nil { + if !eval(x, tags, true) { + shouldBuild = false + } + } + } + } + + return shouldBuild +} + +func parseFileHeader(content []byte) (trimmed, goBuild []byte, sawBinaryOnly bool, err error) { + end := 0 + p := content + ended := false // found non-blank, non-// line, so stopped accepting // +build lines + inSlashStar := false // in /* */ comment + +Lines: + for len(p) > 0 { + line := p + if i := bytes.IndexByte(line, '\n'); i >= 0 { + line, p = line[:i], p[i+1:] + } else { + p = p[len(p):] + } + line = bytes.TrimSpace(line) + if len(line) == 0 && !ended { // Blank line + // Remember position of most recent blank line. + // When we find the first non-blank, non-// line, + // this "end" position marks the latest file position + // where a // +build line can appear. + // (It must appear _before_ a blank line before the non-blank, non-// line. + // Yes, that's confusing, which is part of why we moved to //go:build lines.) + // Note that ended==false here means that inSlashStar==false, + // since seeing a /* would have set ended==true. + end = len(content) - len(p) + continue Lines + } + if !bytes.HasPrefix(line, bSlashSlash) { // Not comment line + ended = true + } + + if !inSlashStar && isGoBuildComment(line) { + if goBuild != nil { + return nil, nil, false, errMultipleGoBuild + } + goBuild = line + } + + Comments: + for len(line) > 0 { + if inSlashStar { + if i := bytes.Index(line, bStarSlash); i >= 0 { + inSlashStar = false + line = bytes.TrimSpace(line[i+len(bStarSlash):]) + continue Comments + } + continue Lines + } + if bytes.HasPrefix(line, bSlashSlash) { + continue Lines + } + if bytes.HasPrefix(line, bSlashStar) { + inSlashStar = true + line = bytes.TrimSpace(line[len(bSlashStar):]) + continue Comments + } + // Found non-comment text. + break Lines + } + } + + return content[:end], goBuild, sawBinaryOnly, nil +} + +// matchTag reports whether the tag name is valid and tags[name] is true. +// As a special case, if tags["*"] is true and name is not empty or ignore, +// then matchTag will return prefer instead of the actual answer, +// which allows the caller to pretend in that case that most tags are +// both true and false. +func matchTag(name string, tags map[string]bool, prefer bool) bool { + // Tags must be letters, digits, underscores or dots. + // Unlike in Go identifiers, all digits are fine (e.g., "386"). + for _, c := range name { + if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '_' && c != '.' { + return false + } + } + + if tags["*"] && name != "" && name != "ignore" { + // Special case for gathering all possible imports: + // if we put * in the tags map then all tags + // except "ignore" are considered both present and not + // (so we return true no matter how 'want' is set). + return prefer + } + + if tags[name] { + return true + } + + switch name { + case "linux": + return tags["android"] + case "solaris": + return tags["illumos"] + case "darwin": + return tags["ios"] + case "unix": + return syslist.UnixOS[cfg.BuildContext.GOOS] + default: + return false + } +} + +// eval is like +// +// x.Eval(func(tag string) bool { return matchTag(tag, tags) }) +// +// except that it implements the special case for tags["*"] meaning +// all tags are both true and false at the same time. +func eval(x constraint.Expr, tags map[string]bool, prefer bool) bool { + switch x := x.(type) { + case *constraint.TagExpr: + return matchTag(x.Tag, tags, prefer) + case *constraint.NotExpr: + return !eval(x.X, tags, !prefer) + case *constraint.AndExpr: + return eval(x.X, tags, prefer) && eval(x.Y, tags, prefer) + case *constraint.OrExpr: + return eval(x.X, tags, prefer) || eval(x.Y, tags, prefer) + } + panic(fmt.Sprintf("unexpected constraint expression %T", x)) +} + +// Eval is like +// +// x.Eval(func(tag string) bool { return matchTag(tag, tags) }) +// +// except that it implements the special case for tags["*"] meaning +// all tags are both true and false at the same time. +func Eval(x constraint.Expr, tags map[string]bool, prefer bool) bool { + return eval(x, tags, prefer) +} + +// MatchFile returns false if the name contains a $GOOS or $GOARCH +// suffix which does not match the current system. +// The recognized name formats are: +// +// name_$(GOOS).* +// name_$(GOARCH).* +// name_$(GOOS)_$(GOARCH).* +// name_$(GOOS)_test.* +// name_$(GOARCH)_test.* +// name_$(GOOS)_$(GOARCH)_test.* +// +// Exceptions: +// +// if GOOS=android, then files with GOOS=linux are also matched. +// if GOOS=illumos, then files with GOOS=solaris are also matched. +// if GOOS=ios, then files with GOOS=darwin are also matched. +// +// If tags["*"] is true, then MatchFile will consider all possible +// GOOS and GOARCH to be available and will consequently +// always return true. +func MatchFile(name string, tags map[string]bool) bool { + if tags["*"] { + return true + } + if dot := strings.Index(name, "."); dot != -1 { + name = name[:dot] + } + + // Before Go 1.4, a file called "linux.go" would be equivalent to having a + // build tag "linux" in that file. For Go 1.4 and beyond, we require this + // auto-tagging to apply only to files with a non-empty prefix, so + // "foo_linux.go" is tagged but "linux.go" is not. This allows new operating + // systems, such as android, to arrive without breaking existing code with + // innocuous source code in "android.go". The easiest fix: cut everything + // in the name before the initial _. + i := strings.Index(name, "_") + if i < 0 { + return true + } + name = name[i:] // ignore everything before first _ + + l := strings.Split(name, "_") + if n := len(l); n > 0 && l[n-1] == "test" { + l = l[:n-1] + } + n := len(l) + if n >= 2 && syslist.KnownOS[l[n-2]] && syslist.KnownArch[l[n-1]] { + return matchTag(l[n-2], tags, true) && matchTag(l[n-1], tags, true) + } + if n >= 1 && syslist.KnownOS[l[n-1]] { + return matchTag(l[n-1], tags, true) + } + if n >= 1 && syslist.KnownArch[l[n-1]] { + return matchTag(l[n-1], tags, true) + } + return true +} diff --git a/go/src/cmd/go/internal/imports/read.go b/go/src/cmd/go/internal/imports/read.go new file mode 100644 index 0000000000000000000000000000000000000000..70d5190450502d042c2a2d0ed3d17105d50e6dbc --- /dev/null +++ b/go/src/cmd/go/internal/imports/read.go @@ -0,0 +1,263 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copied from Go distribution src/go/build/read.go. + +package imports + +import ( + "bufio" + "bytes" + "errors" + "io" + "unicode/utf8" +) + +type importReader struct { + b *bufio.Reader + buf []byte + peek byte + err error + eof bool + nerr int +} + +var bom = []byte{0xef, 0xbb, 0xbf} + +func newImportReader(b *bufio.Reader) *importReader { + // Remove leading UTF-8 BOM. + // Per https://golang.org/ref/spec#Source_code_representation: + // a compiler may ignore a UTF-8-encoded byte order mark (U+FEFF) + // if it is the first Unicode code point in the source text. + if leadingBytes, err := b.Peek(3); err == nil && bytes.Equal(leadingBytes, bom) { + b.Discard(3) + } + return &importReader{b: b} +} + +func isIdent(c byte) bool { + return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9' || c == '_' || c >= utf8.RuneSelf +} + +var ( + errSyntax = errors.New("syntax error") + errNUL = errors.New("unexpected NUL in input") +) + +// syntaxError records a syntax error, but only if an I/O error has not already been recorded. +func (r *importReader) syntaxError() { + if r.err == nil { + r.err = errSyntax + } +} + +// readByte reads the next byte from the input, saves it in buf, and returns it. +// If an error occurs, readByte records the error in r.err and returns 0. +func (r *importReader) readByte() byte { + c, err := r.b.ReadByte() + if err == nil { + r.buf = append(r.buf, c) + if c == 0 { + err = errNUL + } + } + if err != nil { + if err == io.EOF { + r.eof = true + } else if r.err == nil { + r.err = err + } + c = 0 + } + return c +} + +// peekByte returns the next byte from the input reader but does not advance beyond it. +// If skipSpace is set, peekByte skips leading spaces and comments. +func (r *importReader) peekByte(skipSpace bool) byte { + if r.err != nil { + if r.nerr++; r.nerr > 10000 { + panic("go/build: import reader looping") + } + return 0 + } + + // Use r.peek as first input byte. + // Don't just return r.peek here: it might have been left by peekByte(false) + // and this might be peekByte(true). + c := r.peek + if c == 0 { + c = r.readByte() + } + for r.err == nil && !r.eof { + if skipSpace { + // For the purposes of this reader, semicolons are never necessary to + // understand the input and are treated as spaces. + switch c { + case ' ', '\f', '\t', '\r', '\n', ';': + c = r.readByte() + continue + + case '/': + c = r.readByte() + if c == '/' { + for c != '\n' && r.err == nil && !r.eof { + c = r.readByte() + } + } else if c == '*' { + var c1 byte + for (c != '*' || c1 != '/') && r.err == nil { + if r.eof { + r.syntaxError() + } + c, c1 = c1, r.readByte() + } + } else { + r.syntaxError() + } + c = r.readByte() + continue + } + } + break + } + r.peek = c + return r.peek +} + +// nextByte is like peekByte but advances beyond the returned byte. +func (r *importReader) nextByte(skipSpace bool) byte { + c := r.peekByte(skipSpace) + r.peek = 0 + return c +} + +// readKeyword reads the given keyword from the input. +// If the keyword is not present, readKeyword records a syntax error. +func (r *importReader) readKeyword(kw string) { + r.peekByte(true) + for i := 0; i < len(kw); i++ { + if r.nextByte(false) != kw[i] { + r.syntaxError() + return + } + } + if isIdent(r.peekByte(false)) { + r.syntaxError() + } +} + +// readIdent reads an identifier from the input. +// If an identifier is not present, readIdent records a syntax error. +func (r *importReader) readIdent() { + c := r.peekByte(true) + if !isIdent(c) { + r.syntaxError() + return + } + for isIdent(r.peekByte(false)) { + r.peek = 0 + } +} + +// readString reads a quoted string literal from the input. +// If an identifier is not present, readString records a syntax error. +func (r *importReader) readString(save *[]string) { + switch r.nextByte(true) { + case '`': + start := len(r.buf) - 1 + for r.err == nil { + if r.nextByte(false) == '`' { + if save != nil { + *save = append(*save, string(r.buf[start:])) + } + break + } + if r.eof { + r.syntaxError() + } + } + case '"': + start := len(r.buf) - 1 + for r.err == nil { + c := r.nextByte(false) + if c == '"' { + if save != nil { + *save = append(*save, string(r.buf[start:])) + } + break + } + if r.eof || c == '\n' { + r.syntaxError() + } + if c == '\\' { + r.nextByte(false) + } + } + default: + r.syntaxError() + } +} + +// readImport reads an import clause - optional identifier followed by quoted string - +// from the input. +func (r *importReader) readImport(imports *[]string) { + c := r.peekByte(true) + if c == '.' { + r.peek = 0 + } else if isIdent(c) { + r.readIdent() + } + r.readString(imports) +} + +// ReadComments is like io.ReadAll, except that it only reads the leading +// block of comments in the file. +func ReadComments(f io.Reader) ([]byte, error) { + r := newImportReader(bufio.NewReader(f)) + r.peekByte(true) + if r.err == nil && !r.eof { + // Didn't reach EOF, so must have found a non-space byte. Remove it. + r.buf = r.buf[:len(r.buf)-1] + } + return r.buf, r.err +} + +// ReadImports is like io.ReadAll, except that it expects a Go file as input +// and stops reading the input once the imports have completed. +func ReadImports(f io.Reader, reportSyntaxError bool, imports *[]string) ([]byte, error) { + r := newImportReader(bufio.NewReader(f)) + + r.readKeyword("package") + r.readIdent() + for r.peekByte(true) == 'i' { + r.readKeyword("import") + if r.peekByte(true) == '(' { + r.nextByte(false) + for r.peekByte(true) != ')' && r.err == nil { + r.readImport(imports) + } + r.nextByte(false) + } else { + r.readImport(imports) + } + } + + // If we stopped successfully before EOF, we read a byte that told us we were done. + // Return all but that last byte, which would cause a syntax error if we let it through. + if r.err == nil && !r.eof { + return r.buf[:len(r.buf)-1], nil + } + + // If we stopped for a syntax error, consume the whole file so that + // we are sure we don't change the errors that go/parser returns. + if r.err == errSyntax && !reportSyntaxError { + r.err = nil + for r.err == nil && !r.eof { + r.readByte() + } + } + + return r.buf, r.err +} diff --git a/go/src/cmd/go/internal/imports/read_test.go b/go/src/cmd/go/internal/imports/read_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6a1a6524a116d50c8036baa0b0ff3d60e08ccf1a --- /dev/null +++ b/go/src/cmd/go/internal/imports/read_test.go @@ -0,0 +1,254 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copied from Go distribution src/go/build/read.go. + +package imports + +import ( + "io" + "strings" + "testing" +) + +const quote = "`" + +type readTest struct { + // Test input contains ℙ where readImports should stop. + in string + err string +} + +var readImportsTests = []readTest{ + { + `package p`, + "", + }, + { + `package p; import "x"`, + "", + }, + { + `package p; import . "x"`, + "", + }, + { + `package p; import "x";ℙvar x = 1`, + "", + }, + { + `package p + + // comment + + import "x" + import _ "x" + import a "x" + + /* comment */ + + import ( + "x" /* comment */ + _ "x" + a "x" // comment + ` + quote + `x` + quote + ` + _ /*comment*/ ` + quote + `x` + quote + ` + a ` + quote + `x` + quote + ` + ) + import ( + ) + import () + import()import()import() + import();import();import() + + ℙvar x = 1 + `, + "", + }, + { + "\ufeff𝔻" + `package p; import "x";ℙvar x = 1`, + "", + }, +} + +var readCommentsTests = []readTest{ + { + `ℙpackage p`, + "", + }, + { + `ℙpackage p; import "x"`, + "", + }, + { + `ℙpackage p; import . "x"`, + "", + }, + { + "\ufeff𝔻" + `ℙpackage p; import . "x"`, + "", + }, + { + `// foo + + /* bar */ + + /* quux */ // baz + + /*/ zot */ + + // asdf + ℙHello, world`, + "", + }, + { + "\ufeff𝔻" + `// foo + + /* bar */ + + /* quux */ // baz + + /*/ zot */ + + // asdf + ℙHello, world`, + "", + }, +} + +func testRead(t *testing.T, tests []readTest, read func(io.Reader) ([]byte, error)) { + for i, tt := range tests { + var in, testOut string + j := strings.Index(tt.in, "ℙ") + if j < 0 { + in = tt.in + testOut = tt.in + } else { + in = tt.in[:j] + tt.in[j+len("ℙ"):] + testOut = tt.in[:j] + } + d := strings.Index(tt.in, "𝔻") + if d >= 0 { + in = in[:d] + in[d+len("𝔻"):] + testOut = testOut[d+len("𝔻"):] + } + r := strings.NewReader(in) + buf, err := read(r) + if err != nil { + if tt.err == "" { + t.Errorf("#%d: err=%q, expected success (%q)", i, err, string(buf)) + continue + } + if !strings.Contains(err.Error(), tt.err) { + t.Errorf("#%d: err=%q, expected %q", i, err, tt.err) + continue + } + continue + } + if err == nil && tt.err != "" { + t.Errorf("#%d: success, expected %q", i, tt.err) + continue + } + + out := string(buf) + if out != testOut { + t.Errorf("#%d: wrong output:\nhave %q\nwant %q\n", i, out, testOut) + } + } +} + +func TestReadImports(t *testing.T) { + testRead(t, readImportsTests, func(r io.Reader) ([]byte, error) { return ReadImports(r, true, nil) }) +} + +func TestReadComments(t *testing.T) { + testRead(t, readCommentsTests, ReadComments) +} + +var readFailuresTests = []readTest{ + { + `package`, + "syntax error", + }, + { + "package p\n\x00\nimport `math`\n", + "unexpected NUL in input", + }, + { + `package p; import`, + "syntax error", + }, + { + `package p; import "`, + "syntax error", + }, + { + "package p; import ` \n\n", + "syntax error", + }, + { + `package p; import "x`, + "syntax error", + }, + { + `package p; import _`, + "syntax error", + }, + { + `package p; import _ "`, + "syntax error", + }, + { + `package p; import _ "x`, + "syntax error", + }, + { + `package p; import .`, + "syntax error", + }, + { + `package p; import . "`, + "syntax error", + }, + { + `package p; import . "x`, + "syntax error", + }, + { + `package p; import (`, + "syntax error", + }, + { + `package p; import ("`, + "syntax error", + }, + { + `package p; import ("x`, + "syntax error", + }, + { + `package p; import ("x"`, + "syntax error", + }, +} + +func TestReadFailures(t *testing.T) { + // Errors should be reported (true arg to readImports). + testRead(t, readFailuresTests, func(r io.Reader) ([]byte, error) { return ReadImports(r, true, nil) }) +} + +func TestReadFailuresIgnored(t *testing.T) { + // Syntax errors should not be reported (false arg to readImports). + // Instead, entire file should be the output and no error. + // Convert tests not to return syntax errors. + tests := make([]readTest, len(readFailuresTests)) + copy(tests, readFailuresTests) + for i := range tests { + tt := &tests[i] + if !strings.Contains(tt.err, "NUL") { + tt.err = "" + } + } + testRead(t, tests, func(r io.Reader) ([]byte, error) { return ReadImports(r, false, nil) }) +} diff --git a/go/src/cmd/go/internal/imports/scan.go b/go/src/cmd/go/internal/imports/scan.go new file mode 100644 index 0000000000000000000000000000000000000000..5ad438c6749f201d7227436717e706c4830c9482 --- /dev/null +++ b/go/src/cmd/go/internal/imports/scan.go @@ -0,0 +1,108 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package imports + +import ( + "fmt" + "io/fs" + "path/filepath" + "sort" + "strconv" + "strings" + + "cmd/go/internal/fsys" +) + +func ScanDir(path string, tags map[string]bool) ([]string, []string, error) { + dirs, err := fsys.ReadDir(path) + if err != nil { + return nil, nil, err + } + var files []string + for _, dir := range dirs { + name := dir.Name() + + // If the directory entry is a symlink, stat it to obtain the info for the + // link target instead of the link itself. + if dir.Type()&fs.ModeSymlink != 0 { + info, err := fsys.Stat(filepath.Join(path, name)) + if err != nil { + continue // Ignore broken symlinks. + } + dir = fs.FileInfoToDirEntry(info) + } + + if dir.Type().IsRegular() && !strings.HasPrefix(name, "_") && !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go") && MatchFile(name, tags) { + files = append(files, filepath.Join(path, name)) + } + } + return scanFiles(files, tags, false) +} + +func ScanFiles(files []string, tags map[string]bool) ([]string, []string, error) { + return scanFiles(files, tags, true) +} + +func scanFiles(files []string, tags map[string]bool, explicitFiles bool) ([]string, []string, error) { + imports := make(map[string]bool) + testImports := make(map[string]bool) + numFiles := 0 +Files: + for _, name := range files { + r, err := fsys.Open(name) + if err != nil { + return nil, nil, err + } + var list []string + data, err := ReadImports(r, false, &list) + r.Close() + if err != nil { + return nil, nil, fmt.Errorf("reading %s: %v", name, err) + } + + // import "C" is implicit requirement of cgo tag. + // When listing files on the command line (explicitFiles=true) + // we do not apply build tag filtering but we still do apply + // cgo filtering, so no explicitFiles check here. + // Why? Because we always have, and it's not worth breaking + // that behavior now. + for _, path := range list { + if path == `"C"` && !tags["cgo"] && !tags["*"] { + continue Files + } + } + + if !explicitFiles && !ShouldBuild(data, tags) { + continue + } + numFiles++ + m := imports + if strings.HasSuffix(name, "_test.go") { + m = testImports + } + for _, p := range list { + q, err := strconv.Unquote(p) + if err != nil { + continue + } + m[q] = true + } + } + if numFiles == 0 { + return nil, nil, ErrNoGo + } + return keys(imports), keys(testImports), nil +} + +var ErrNoGo = fmt.Errorf("no Go source files") + +func keys(m map[string]bool) []string { + list := make([]string, 0, len(m)) + for k := range m { + list = append(list, k) + } + sort.Strings(list) + return list +} diff --git a/go/src/cmd/go/internal/imports/scan_test.go b/go/src/cmd/go/internal/imports/scan_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6284da2337781cdfaafe17ffc75a9f6d337d3a2e --- /dev/null +++ b/go/src/cmd/go/internal/imports/scan_test.go @@ -0,0 +1,93 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package imports + +import ( + "bytes" + "internal/testenv" + "os" + "path" + "path/filepath" + "strings" + "testing" +) + +func TestScan(t *testing.T) { + testenv.MustHaveGoBuild(t) + + imports, testImports, err := ScanDir(filepath.Join(testenv.GOROOT(t), "src/cmd/go/internal/imports/testdata/test"), Tags()) + if err != nil { + t.Fatal(err) + } + foundFmt := false + for _, p := range imports { + if p == "fmt" { + foundFmt = true // test package imports fmt directly + } + if p == "encoding/binary" { + // A dependency but not an import + t.Errorf("testdata/test reported as importing encoding/binary but does not") + } + if p == "net/http" { + // A test import but not an import + t.Errorf("testdata/test reported as importing net/http but does not") + } + } + if !foundFmt { + t.Errorf("testdata/test missing import fmt (%q)", imports) + } + + foundHTTP := false + for _, p := range testImports { + if p == "net/http" { + foundHTTP = true + } + if p == "fmt" { + // A package import but not a test import + t.Errorf("testdata/test reported as test-importing fmt but does not") + } + } + if !foundHTTP { + t.Errorf("testdata/test missing test import net/http (%q)", testImports) + } +} +func TestScanDir(t *testing.T) { + testenv.MustHaveGoBuild(t) + + dirs, err := os.ReadDir("testdata") + if err != nil { + t.Fatal(err) + } + for _, dir := range dirs { + if !dir.IsDir() || strings.HasPrefix(dir.Name(), ".") { + continue + } + t.Run(dir.Name(), func(t *testing.T) { + tagsData, err := os.ReadFile(filepath.Join("testdata", dir.Name(), "tags.txt")) + if err != nil { + t.Fatalf("error reading tags: %v", err) + } + tags := make(map[string]bool) + for _, t := range strings.Fields(string(tagsData)) { + tags[t] = true + } + + wantData, err := os.ReadFile(filepath.Join("testdata", dir.Name(), "want.txt")) + if err != nil { + t.Fatalf("error reading want: %v", err) + } + want := string(bytes.TrimSpace(wantData)) + + imports, _, err := ScanDir(path.Join("testdata", dir.Name()), tags) + if err != nil { + t.Fatal(err) + } + got := strings.Join(imports, "\n") + if got != want { + t.Errorf("ScanDir: got imports:\n%s\n\nwant:\n%s", got, want) + } + }) + } +} diff --git a/go/src/cmd/go/internal/imports/tags.go b/go/src/cmd/go/internal/imports/tags.go new file mode 100644 index 0000000000000000000000000000000000000000..42b25af7b6fe00862af3961245d69bc975f5fbca --- /dev/null +++ b/go/src/cmd/go/internal/imports/tags.go @@ -0,0 +1,51 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package imports + +import ( + "cmd/go/internal/cfg" + "sync" +) + +// Tags returns a set of build tags that are true for the target platform. +// It includes GOOS, GOARCH, the compiler, possibly "cgo", +// release tags like "go1.13", and user-specified build tags. +func Tags() map[string]bool { + return loadTagsOnce() +} + +var loadTagsOnce = sync.OnceValue(loadTags) + +func loadTags() map[string]bool { + tags := map[string]bool{ + cfg.BuildContext.GOOS: true, + cfg.BuildContext.GOARCH: true, + cfg.BuildContext.Compiler: true, + } + if cfg.BuildContext.CgoEnabled { + tags["cgo"] = true + } + for _, tag := range cfg.BuildContext.BuildTags { + tags[tag] = true + } + for _, tag := range cfg.BuildContext.ToolTags { + tags[tag] = true + } + for _, tag := range cfg.BuildContext.ReleaseTags { + tags[tag] = true + } + return tags +} + +// AnyTags returns a special set of build tags that satisfy nearly all +// build tag expressions. Only "ignore" and malformed build tag requirements +// are considered false. +func AnyTags() map[string]bool { + return anyTagsOnce() +} + +var anyTagsOnce = sync.OnceValue(func() map[string]bool { + return map[string]bool{"*": true} +}) diff --git a/go/src/cmd/go/internal/imports/testdata/android/.h.go b/go/src/cmd/go/internal/imports/testdata/android/.h.go new file mode 100644 index 0000000000000000000000000000000000000000..53c529e7774a6dcf883c17b2e9556fa3d3b1a726 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/android/.h.go @@ -0,0 +1,3 @@ +package android + +import _ "h" diff --git a/go/src/cmd/go/internal/imports/testdata/android/a_android.go b/go/src/cmd/go/internal/imports/testdata/android/a_android.go new file mode 100644 index 0000000000000000000000000000000000000000..2ed972eca57cbd68bf94e254c891b9927c2225c6 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/android/a_android.go @@ -0,0 +1,3 @@ +package android + +import _ "a" diff --git a/go/src/cmd/go/internal/imports/testdata/android/b_android_arm64.go b/go/src/cmd/go/internal/imports/testdata/android/b_android_arm64.go new file mode 100644 index 0000000000000000000000000000000000000000..ee9c312b5d7497ae2df10291317b8a8b1be36fcb --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/android/b_android_arm64.go @@ -0,0 +1,3 @@ +package android + +import _ "b" diff --git a/go/src/cmd/go/internal/imports/testdata/android/c_linux.go b/go/src/cmd/go/internal/imports/testdata/android/c_linux.go new file mode 100644 index 0000000000000000000000000000000000000000..91624ce637ffc0d6bdebb995893e941bc2c7c354 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/android/c_linux.go @@ -0,0 +1,3 @@ +package android + +import _ "c" diff --git a/go/src/cmd/go/internal/imports/testdata/android/d_linux_arm64.go b/go/src/cmd/go/internal/imports/testdata/android/d_linux_arm64.go new file mode 100644 index 0000000000000000000000000000000000000000..34e07df2477b727d3175fcca9773cc945439b525 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/android/d_linux_arm64.go @@ -0,0 +1,3 @@ +package android + +import _ "d" diff --git a/go/src/cmd/go/internal/imports/testdata/android/e.go b/go/src/cmd/go/internal/imports/testdata/android/e.go new file mode 100644 index 0000000000000000000000000000000000000000..f1b9c888c2cafdd83ab651a52f75b31bb1f83516 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/android/e.go @@ -0,0 +1,6 @@ +//go:build android +// +build android + +package android + +import _ "e" diff --git a/go/src/cmd/go/internal/imports/testdata/android/f.go b/go/src/cmd/go/internal/imports/testdata/android/f.go new file mode 100644 index 0000000000000000000000000000000000000000..bb0ff7b73f67c15fffeb5ea95f0628047a794cdf --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/android/f.go @@ -0,0 +1,6 @@ +//go:build linux +// +build linux + +package android + +import _ "f" diff --git a/go/src/cmd/go/internal/imports/testdata/android/g.go b/go/src/cmd/go/internal/imports/testdata/android/g.go new file mode 100644 index 0000000000000000000000000000000000000000..ee19424890a963fa1618310d2875de3438df2a0e --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/android/g.go @@ -0,0 +1,6 @@ +//go:build !android +// +build !android + +package android + +import _ "g" diff --git a/go/src/cmd/go/internal/imports/testdata/android/tags.txt b/go/src/cmd/go/internal/imports/testdata/android/tags.txt new file mode 100644 index 0000000000000000000000000000000000000000..aaf5a6b91d7fa9bc3fd3b0be1dc163f000abbe1f --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/android/tags.txt @@ -0,0 +1 @@ +android arm64 \ No newline at end of file diff --git a/go/src/cmd/go/internal/imports/testdata/android/want.txt b/go/src/cmd/go/internal/imports/testdata/android/want.txt new file mode 100644 index 0000000000000000000000000000000000000000..0fdf397db08b5cecda1b6394d4fef7395c1933ba --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/android/want.txt @@ -0,0 +1,6 @@ +a +b +c +d +e +f diff --git a/go/src/cmd/go/internal/imports/testdata/illumos/.h.go b/go/src/cmd/go/internal/imports/testdata/illumos/.h.go new file mode 100644 index 0000000000000000000000000000000000000000..53c529e7774a6dcf883c17b2e9556fa3d3b1a726 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/illumos/.h.go @@ -0,0 +1,3 @@ +package android + +import _ "h" diff --git a/go/src/cmd/go/internal/imports/testdata/illumos/a_illumos.go b/go/src/cmd/go/internal/imports/testdata/illumos/a_illumos.go new file mode 100644 index 0000000000000000000000000000000000000000..2e6cb50805a491c88a0e26c83da6921e42f10651 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/illumos/a_illumos.go @@ -0,0 +1,3 @@ +package illumos + +import _ "a" diff --git a/go/src/cmd/go/internal/imports/testdata/illumos/b_illumos_amd64.go b/go/src/cmd/go/internal/imports/testdata/illumos/b_illumos_amd64.go new file mode 100644 index 0000000000000000000000000000000000000000..2834d80660c9db23846a518227cbb20ab1724315 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/illumos/b_illumos_amd64.go @@ -0,0 +1,3 @@ +package illumos + +import _ "b" diff --git a/go/src/cmd/go/internal/imports/testdata/illumos/c_solaris.go b/go/src/cmd/go/internal/imports/testdata/illumos/c_solaris.go new file mode 100644 index 0000000000000000000000000000000000000000..d7f9462f159cb35754fe68c40ed1461a08ccf064 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/illumos/c_solaris.go @@ -0,0 +1,3 @@ +package illumos + +import _ "c" diff --git a/go/src/cmd/go/internal/imports/testdata/illumos/d_solaris_amd64.go b/go/src/cmd/go/internal/imports/testdata/illumos/d_solaris_amd64.go new file mode 100644 index 0000000000000000000000000000000000000000..0f52c2bb484fdfa7ed0672008dd5dbc4a5a597e7 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/illumos/d_solaris_amd64.go @@ -0,0 +1,3 @@ +package illumos + +import _ "d" diff --git a/go/src/cmd/go/internal/imports/testdata/illumos/e.go b/go/src/cmd/go/internal/imports/testdata/illumos/e.go new file mode 100644 index 0000000000000000000000000000000000000000..fddf2c429909b7776cd4cdddce2ed70f0cd35542 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/illumos/e.go @@ -0,0 +1,6 @@ +//go:build illumos +// +build illumos + +package illumos + +import _ "e" diff --git a/go/src/cmd/go/internal/imports/testdata/illumos/f.go b/go/src/cmd/go/internal/imports/testdata/illumos/f.go new file mode 100644 index 0000000000000000000000000000000000000000..4b6d528e4c2225f29ed67e382a3561586b4f2170 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/illumos/f.go @@ -0,0 +1,6 @@ +//go:build solaris +// +build solaris + +package illumos + +import _ "f" diff --git a/go/src/cmd/go/internal/imports/testdata/illumos/g.go b/go/src/cmd/go/internal/imports/testdata/illumos/g.go new file mode 100644 index 0000000000000000000000000000000000000000..1bf826b81510b42fafb4a11a0e9e92c7ad8d0860 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/illumos/g.go @@ -0,0 +1,6 @@ +//go:build !illumos +// +build !illumos + +package illumos + +import _ "g" diff --git a/go/src/cmd/go/internal/imports/testdata/illumos/tags.txt b/go/src/cmd/go/internal/imports/testdata/illumos/tags.txt new file mode 100644 index 0000000000000000000000000000000000000000..b6386a32605da28470daea37889bc67ac633db2f --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/illumos/tags.txt @@ -0,0 +1 @@ +illumos amd64 diff --git a/go/src/cmd/go/internal/imports/testdata/illumos/want.txt b/go/src/cmd/go/internal/imports/testdata/illumos/want.txt new file mode 100644 index 0000000000000000000000000000000000000000..0fdf397db08b5cecda1b6394d4fef7395c1933ba --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/illumos/want.txt @@ -0,0 +1,6 @@ +a +b +c +d +e +f diff --git a/go/src/cmd/go/internal/imports/testdata/star/tags.txt b/go/src/cmd/go/internal/imports/testdata/star/tags.txt new file mode 100644 index 0000000000000000000000000000000000000000..f59ec20aabf5842d237244ece8c81ab184faeac1 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/star/tags.txt @@ -0,0 +1 @@ +* \ No newline at end of file diff --git a/go/src/cmd/go/internal/imports/testdata/star/want.txt b/go/src/cmd/go/internal/imports/testdata/star/want.txt new file mode 100644 index 0000000000000000000000000000000000000000..139f5f49755c40f251f28e427f1a112c8eae12f9 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/star/want.txt @@ -0,0 +1,4 @@ +import1 +import2 +import3 +import4 diff --git a/go/src/cmd/go/internal/imports/testdata/star/x.go b/go/src/cmd/go/internal/imports/testdata/star/x.go new file mode 100644 index 0000000000000000000000000000000000000000..98f9191053bc3d970c7ef2c6f881e48e4f858ebc --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/star/x.go @@ -0,0 +1,3 @@ +package x + +import "import1" diff --git a/go/src/cmd/go/internal/imports/testdata/star/x1.go b/go/src/cmd/go/internal/imports/testdata/star/x1.go new file mode 100644 index 0000000000000000000000000000000000000000..eaaea979e9dc82285ab0f830cbc676295d0732d1 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/star/x1.go @@ -0,0 +1,6 @@ +//go:build blahblh && linux && !linux && windows && darwin +// +build blahblh,linux,!linux,windows,darwin + +package x + +import "import4" diff --git a/go/src/cmd/go/internal/imports/testdata/star/x_darwin.go b/go/src/cmd/go/internal/imports/testdata/star/x_darwin.go new file mode 100644 index 0000000000000000000000000000000000000000..a0c3fdd21b5f5cc2ce45bb9dc0272e7123f61b18 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/star/x_darwin.go @@ -0,0 +1,3 @@ +package xxxx + +import "import3" diff --git a/go/src/cmd/go/internal/imports/testdata/star/x_windows.go b/go/src/cmd/go/internal/imports/testdata/star/x_windows.go new file mode 100644 index 0000000000000000000000000000000000000000..63c508248fbff9ce6e7ca9defb380209943cbaf7 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/star/x_windows.go @@ -0,0 +1,3 @@ +package x + +import "import2" diff --git a/go/src/cmd/go/internal/imports/testdata/test/child/child.go b/go/src/cmd/go/internal/imports/testdata/test/child/child.go new file mode 100644 index 0000000000000000000000000000000000000000..44919db3d6b64032efb8ff8c34f3122d179f1c76 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/test/child/child.go @@ -0,0 +1,5 @@ +package child + +import "encoding/binary" + +var V = binary.MaxVarintLen16 diff --git a/go/src/cmd/go/internal/imports/testdata/test/tags.txt b/go/src/cmd/go/internal/imports/testdata/test/tags.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/go/src/cmd/go/internal/imports/testdata/test/test.go b/go/src/cmd/go/internal/imports/testdata/test/test.go new file mode 100644 index 0000000000000000000000000000000000000000..74e76a07228d1a2dddd74e4c1db9cee2e66eed61 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/test/test.go @@ -0,0 +1,10 @@ +package test + +import ( + "cmd/go/internal/imports/testdata/test/child" + "fmt" +) + +func F() { + fmt.Println(child.V) +} diff --git a/go/src/cmd/go/internal/imports/testdata/test/test_test.go b/go/src/cmd/go/internal/imports/testdata/test/test_test.go new file mode 100644 index 0000000000000000000000000000000000000000..ca7c501cb2741e9c1f01654707a93b50aeebfd1d --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/test/test_test.go @@ -0,0 +1,9 @@ +package test_test + +import ( + _ "net/http" + "testing" +) + +func Test(t *testing.T) { +} diff --git a/go/src/cmd/go/internal/imports/testdata/test/want.txt b/go/src/cmd/go/internal/imports/testdata/test/want.txt new file mode 100644 index 0000000000000000000000000000000000000000..7c7c8c67ee27bc53c965d1c077ebb0c161ab8978 --- /dev/null +++ b/go/src/cmd/go/internal/imports/testdata/test/want.txt @@ -0,0 +1,2 @@ +cmd/go/internal/imports/testdata/test/child +fmt diff --git a/go/src/cmd/go/internal/list/context.go b/go/src/cmd/go/internal/list/context.go new file mode 100644 index 0000000000000000000000000000000000000000..9d6494cfba01699b2b60f95778e49e2238117253 --- /dev/null +++ b/go/src/cmd/go/internal/list/context.go @@ -0,0 +1,39 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package list + +import ( + "go/build" +) + +type Context struct { + GOARCH string `json:",omitempty"` // target architecture + GOOS string `json:",omitempty"` // target operating system + GOROOT string `json:",omitempty"` // Go root + GOPATH string `json:",omitempty"` // Go path + CgoEnabled bool `json:",omitempty"` // whether cgo can be used + UseAllFiles bool `json:",omitempty"` // use files regardless of //go:build lines, file names + Compiler string `json:",omitempty"` // compiler to assume when computing target paths + BuildTags []string `json:",omitempty"` // build constraints to match in +build lines + ToolTags []string `json:",omitempty"` // toolchain-specific build constraints + ReleaseTags []string `json:",omitempty"` // releases the current release is compatible with + InstallSuffix string `json:",omitempty"` // suffix to use in the name of the install dir +} + +func newContext(c *build.Context) *Context { + return &Context{ + GOARCH: c.GOARCH, + GOOS: c.GOOS, + GOROOT: c.GOROOT, + GOPATH: c.GOPATH, + CgoEnabled: c.CgoEnabled, + UseAllFiles: c.UseAllFiles, + Compiler: c.Compiler, + BuildTags: c.BuildTags, + ToolTags: c.ToolTags, + ReleaseTags: c.ReleaseTags, + InstallSuffix: c.InstallSuffix, + } +} diff --git a/go/src/cmd/go/internal/list/list.go b/go/src/cmd/go/internal/list/list.go new file mode 100644 index 0000000000000000000000000000000000000000..81ac4ebaf9cf688ac30d412cc11497848ec28d65 --- /dev/null +++ b/go/src/cmd/go/internal/list/list.go @@ -0,0 +1,1003 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package list implements the “go list” command. +package list + +import ( + "bufio" + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "os" + "reflect" + "runtime" + "sort" + "strconv" + "strings" + "sync" + "text/template" + + "golang.org/x/sync/semaphore" + + "cmd/go/internal/base" + "cmd/go/internal/cache" + "cmd/go/internal/cfg" + "cmd/go/internal/load" + "cmd/go/internal/modinfo" + "cmd/go/internal/modload" + "cmd/go/internal/str" + "cmd/go/internal/work" +) + +var CmdList = &base.Command{ + // Note: -f -json -m are listed explicitly because they are the most common list flags. + // Do not send CLs removing them because they're covered by [list flags]. + UsageLine: "go list [-f format] [-json] [-m] [list flags] [build flags] [packages]", + Short: "list packages or modules", + Long: ` +List lists the named packages, one per line. +The most commonly-used flags are -f and -json, which control the form +of the output printed for each package. Other list flags, documented below, +control more specific details. + +The default output shows the package import path: + + bytes + encoding/json + github.com/gorilla/mux + golang.org/x/net/html + +The -f flag specifies an alternate format for the list, using the +syntax of package template. The default output is equivalent +to -f '{{.ImportPath}}'. The struct being passed to the template is: + + type Package struct { + Dir string // directory containing package sources + ImportPath string // import path of package in dir + ImportComment string // path in import comment on package statement + Name string // package name + Doc string // package documentation string + Target string // install path + Shlib string // the shared library that contains this package (only set when -linkshared) + Goroot bool // is this package in the Go root? + Standard bool // is this package part of the standard Go library? + Stale bool // would 'go install' do anything for this package? + StaleReason string // explanation for Stale==true + Root string // Go root or Go path dir containing this package + ConflictDir string // this directory shadows Dir in $GOPATH + BinaryOnly bool // binary-only package (no longer supported) + ForTest string // package is only for use in named test + Export string // file containing export data (when using -export) + BuildID string // build ID of the compiled package (when using -export) + Module *Module // info about package's containing module, if any (can be nil) + Match []string // command-line patterns matching this package + DepOnly bool // package is only a dependency, not explicitly listed + DefaultGODEBUG string // default GODEBUG setting, for main packages + + // Source files + GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles) + CgoFiles []string // .go source files that import "C" + CompiledGoFiles []string // .go files presented to compiler (when using -compiled) + IgnoredGoFiles []string // .go source files ignored due to build constraints + IgnoredOtherFiles []string // non-.go source files ignored due to build constraints + CFiles []string // .c source files + CXXFiles []string // .cc, .cxx and .cpp source files + MFiles []string // .m source files + HFiles []string // .h, .hh, .hpp and .hxx source files + FFiles []string // .f, .F, .for and .f90 Fortran source files + SFiles []string // .s source files + SwigFiles []string // .swig files + SwigCXXFiles []string // .swigcxx files + SysoFiles []string // .syso object files to add to archive + TestGoFiles []string // _test.go files in package + XTestGoFiles []string // _test.go files outside package + + // Embedded files + EmbedPatterns []string // //go:embed patterns + EmbedFiles []string // files matched by EmbedPatterns + TestEmbedPatterns []string // //go:embed patterns in TestGoFiles + TestEmbedFiles []string // files matched by TestEmbedPatterns + XTestEmbedPatterns []string // //go:embed patterns in XTestGoFiles + XTestEmbedFiles []string // files matched by XTestEmbedPatterns + + // Cgo directives + CgoCFLAGS []string // cgo: flags for C compiler + CgoCPPFLAGS []string // cgo: flags for C preprocessor + CgoCXXFLAGS []string // cgo: flags for C++ compiler + CgoFFLAGS []string // cgo: flags for Fortran compiler + CgoLDFLAGS []string // cgo: flags for linker + CgoPkgConfig []string // cgo: pkg-config names + + // Dependency information + Imports []string // import paths used by this package + ImportMap map[string]string // map from source import to ImportPath (identity entries omitted) + Deps []string // all (recursively) imported dependencies + TestImports []string // imports from TestGoFiles + XTestImports []string // imports from XTestGoFiles + + // Error information + Incomplete bool // this package or a dependency has an error + Error *PackageError // error loading package + DepsErrors []*PackageError // errors loading dependencies + } + +Packages stored in vendor directories report an ImportPath that includes the +path to the vendor directory (for example, "d/vendor/p" instead of "p"), +so that the ImportPath uniquely identifies a given copy of a package. +The Imports, Deps, TestImports, and XTestImports lists also contain these +expanded import paths. See golang.org/s/go15vendor for more about vendoring. + +The error information, if any, is + + type PackageError struct { + ImportStack []string // shortest path from package named on command line to this one + Pos string // position of error (if present, file:line:col) + Err string // the error itself + } + +The module information is a Module struct, defined in the discussion +of list -m below. + +The template function "join" calls strings.Join. + +The template function "context" returns the build context, defined as: + + type Context struct { + GOARCH string // target architecture + GOOS string // target operating system + GOROOT string // Go root + GOPATH string // Go path + CgoEnabled bool // whether cgo can be used + UseAllFiles bool // use files regardless of //go:build lines, file names + Compiler string // compiler to assume when computing target paths + BuildTags []string // build constraints to match in //go:build lines + ToolTags []string // toolchain-specific build constraints + ReleaseTags []string // releases the current release is compatible with + InstallSuffix string // suffix to use in the name of the install dir + } + +For more information about the meaning of these fields see the documentation +for the go/build package's Context type. + +The -json flag causes the package data to be printed in JSON format +instead of using the template format. The JSON flag can optionally be +provided with a set of comma-separated required field names to be output. +If so, those required fields will always appear in JSON output, but +others may be omitted to save work in computing the JSON struct. + +The -compiled flag causes list to set CompiledGoFiles to the Go source +files presented to the compiler. Typically this means that it repeats +the files listed in GoFiles and then also adds the Go code generated +by processing CgoFiles and SwigFiles. The Imports list contains the +union of all imports from both GoFiles and CompiledGoFiles. + +The -deps flag causes list to iterate over not just the named packages +but also all their dependencies. It visits them in a depth-first post-order +traversal, so that a package is listed only after all its dependencies. +Packages not explicitly listed on the command line will have the DepOnly +field set to true. + +The -e flag changes the handling of erroneous packages, those that +cannot be found or are malformed. By default, the list command +prints an error to standard error for each erroneous package and +omits the packages from consideration during the usual printing. +With the -e flag, the list command never prints errors to standard +error and instead processes the erroneous packages with the usual +printing. Erroneous packages will have a non-empty ImportPath and +a non-nil Error field; other information may or may not be missing +(zeroed). + +The -export flag causes list to set the Export field to the name of a +file containing up-to-date export information for the given package, +and the BuildID field to the build ID of the compiled package. + +The -find flag causes list to identify the named packages but not +resolve their dependencies: the Imports and Deps lists will be empty. +With the -find flag, the -deps, -test and -export commands cannot be +used. + +The -test flag causes list to report not only the named packages +but also their test binaries (for packages with tests), to convey to +source code analysis tools exactly how test binaries are constructed. +The reported import path for a test binary is the import path of +the package followed by a ".test" suffix, as in "math/rand.test". +When building a test, it is sometimes necessary to rebuild certain +dependencies specially for that test (most commonly the tested +package itself). The reported import path of a package recompiled +for a particular test binary is followed by a space and the name of +the test binary in brackets, as in "math/rand [math/rand.test]" +or "regexp [sort.test]". The ForTest field is also set to the name +of the package being tested ("math/rand" or "sort" in the previous +examples). + +The Dir, Target, Shlib, Root, ConflictDir, and Export file paths +are all absolute paths. + +By default, the lists GoFiles, CgoFiles, and so on hold names of files in Dir +(that is, paths relative to Dir, not absolute paths). +The generated files added when using the -compiled and -test flags +are absolute paths referring to cached copies of generated Go source files. +Although they are Go source files, the paths may not end in ".go". + +The -m flag causes list to list modules instead of packages. + +When listing modules, the -f flag still specifies a format template +applied to a Go struct, but now a Module struct: + + type Module struct { + Path string // module path + Query string // version query corresponding to this version + Version string // module version + Versions []string // available module versions + Replace *Module // replaced by this module + Time *time.Time // time version was created + Update *Module // available update (with -u) + Main bool // is this the main module? + Indirect bool // module is only indirectly needed by main module + Dir string // directory holding local copy of files, if any + GoMod string // path to go.mod file describing module, if any + GoVersion string // go version used in module + Retracted []string // retraction information, if any (with -retracted or -u) + Deprecated string // deprecation message, if any (with -u) + Error *ModuleError // error loading module + Sum string // checksum for path, version (as in go.sum) + GoModSum string // checksum for go.mod (as in go.sum) + Origin any // provenance of module + Reuse bool // reuse of old module info is safe + } + + type ModuleError struct { + Err string // the error itself + } + +The file GoMod refers to may be outside the module directory if the +module is in the module cache or if the -modfile flag is used. + +The default output is to print the module path and then +information about the version and replacement if any. +For example, 'go list -m all' might print: + + my/main/module + golang.org/x/text v0.3.0 => /tmp/text + rsc.io/pdf v0.1.1 + +The Module struct has a String method that formats this +line of output, so that the default format is equivalent +to -f '{{.String}}'. + +Note that when a module has been replaced, its Replace field +describes the replacement module, and its Dir field is set to +the replacement's source code, if present. (That is, if Replace +is non-nil, then Dir is set to Replace.Dir, with no access to +the replaced source code.) + +The -u flag adds information about available upgrades. +When the latest version of a given module is newer than +the current one, list -u sets the Module's Update field +to information about the newer module. list -u will also set +the module's Retracted field if the current version is retracted. +The Module's String method indicates an available upgrade by +formatting the newer version in brackets after the current version. +If a version is retracted, the string "(retracted)" will follow it. +For example, 'go list -m -u all' might print: + + my/main/module + golang.org/x/text v0.3.0 [v0.4.0] => /tmp/text + rsc.io/pdf v0.1.1 (retracted) [v0.1.2] + +(For tools, 'go list -m -u -json all' may be more convenient to parse.) + +The -versions flag causes list to set the Module's Versions field +to a list of all known versions of that module, ordered according +to semantic versioning, earliest to latest. The flag also changes +the default output format to display the module path followed by the +space-separated version list. + +The -retracted flag causes list to report information about retracted +module versions. When -retracted is used with -f or -json, the Retracted +field explains why the version was retracted. +The strings are taken from comments on the retract directive in the +module's go.mod file. When -retracted is used with -versions, retracted +versions are listed together with unretracted versions. The -retracted +flag may be used with or without -m. + +The arguments to list -m are interpreted as a list of modules, not packages. +The main module is the module containing the current directory. +The active modules are the main module and its dependencies. +With no arguments, list -m shows the main module. +With arguments, list -m shows the modules specified by the arguments. +Any of the active modules can be specified by its module path. +The special pattern "all" specifies all the active modules, first the main +module and then dependencies sorted by module path. +A pattern containing "..." specifies the active modules whose +module paths match the pattern. +A query of the form path@version specifies the result of that query, +which is not limited to active modules. +See 'go help modules' for more about module queries. + +The template function "module" takes a single string argument +that must be a module path or query and returns the specified +module as a Module struct. If an error occurs, the result will +be a Module struct with a non-nil Error field. + +When using -m, the -reuse=old.json flag accepts the name of file containing +the JSON output of a previous 'go list -m -json' invocation with the +same set of modifier flags (such as -u, -retracted, and -versions). +The go command may use this file to determine that a module is unchanged +since the previous invocation and avoid redownloading information about it. +Modules that are not redownloaded will be marked in the new output by +setting the Reuse field to true. Normally the module cache provides this +kind of reuse automatically; the -reuse flag can be useful on systems that +do not preserve the module cache. + +For more about build flags, see 'go help build'. + +For more about specifying packages, see 'go help packages'. + +For more about modules, see https://golang.org/ref/mod. + `, +} + +func init() { + CmdList.Run = runList // break init cycle + // Omit build -json because list has its own -json + work.AddBuildFlags(CmdList, work.OmitJSONFlag) + work.AddCoverFlags(CmdList, nil) + CmdList.Flag.Var(&listJsonFields, "json", "") +} + +var ( + listCompiled = CmdList.Flag.Bool("compiled", false, "") + listDeps = CmdList.Flag.Bool("deps", false, "") + listE = CmdList.Flag.Bool("e", false, "") + listExport = CmdList.Flag.Bool("export", false, "") + listFmt = CmdList.Flag.String("f", "", "") + listFind = CmdList.Flag.Bool("find", false, "") + listJson bool + listJsonFields jsonFlag // If not empty, only output these fields. + listM = CmdList.Flag.Bool("m", false, "") + listRetracted = CmdList.Flag.Bool("retracted", false, "") + listReuse = CmdList.Flag.String("reuse", "", "") + listTest = CmdList.Flag.Bool("test", false, "") + listU = CmdList.Flag.Bool("u", false, "") + listVersions = CmdList.Flag.Bool("versions", false, "") +) + +// A StringsFlag is a command-line flag that interprets its argument +// as a space-separated list of possibly-quoted strings. +type jsonFlag map[string]bool + +func (v *jsonFlag) Set(s string) error { + if v, err := strconv.ParseBool(s); err == nil { + listJson = v + return nil + } + listJson = true + if *v == nil { + *v = make(map[string]bool) + } + for f := range strings.SplitSeq(s, ",") { + (*v)[f] = true + } + return nil +} + +func (v *jsonFlag) String() string { + fields := make([]string, 0, len(*v)) + for f := range *v { + fields = append(fields, f) + } + sort.Strings(fields) + return strings.Join(fields, ",") +} + +func (v *jsonFlag) IsBoolFlag() bool { + return true +} + +func (v *jsonFlag) needAll() bool { + return len(*v) == 0 +} + +func (v *jsonFlag) needAny(fields ...string) bool { + if v.needAll() { + return true + } + for _, f := range fields { + if (*v)[f] { + return true + } + } + return false +} + +var nl = []byte{'\n'} + +func runList(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + moduleLoaderState.InitWorkfile() + + if *listFmt != "" && listJson { + base.Fatalf("go list -f cannot be used with -json") + } + if *listReuse != "" && !*listM { + base.Fatalf("go list -reuse cannot be used without -m") + } + if *listReuse != "" && moduleLoaderState.HasModRoot() { + base.Fatalf("go list -reuse cannot be used inside a module") + } + + work.BuildInit(moduleLoaderState) + out := newTrackingWriter(os.Stdout) + defer out.w.Flush() + + if *listFmt == "" { + if *listM { + *listFmt = "{{.String}}" + if *listVersions { + *listFmt = `{{.Path}}{{range .Versions}} {{.}}{{end}}{{if .Deprecated}} (deprecated){{end}}` + } + } else { + *listFmt = "{{.ImportPath}}" + } + } + + var do func(x any) + if listJson { + do = func(x any) { + if !listJsonFields.needAll() { + // Set x to a copy of itself with all non-requested fields cleared. + v := reflect.New(reflect.TypeOf(x).Elem()).Elem() // do is always called with a non-nil pointer. + v.Set(reflect.ValueOf(x).Elem()) + for i := 0; i < v.NumField(); i++ { + if !listJsonFields.needAny(v.Type().Field(i).Name) { + v.Field(i).SetZero() + } + } + x = v.Interface() + } + b, err := json.MarshalIndent(x, "", "\t") + if err != nil { + out.Flush() + base.Fatalf("%s", err) + } + out.Write(b) + out.Write(nl) + } + } else { + var cachedCtxt *Context + context := func() *Context { + if cachedCtxt == nil { + cachedCtxt = newContext(&cfg.BuildContext) + } + return cachedCtxt + } + fm := template.FuncMap{ + "join": strings.Join, + "context": context, + "module": func(path string) *modinfo.ModulePublic { return modload.ModuleInfo(moduleLoaderState, ctx, path) }, + } + tmpl, err := template.New("main").Funcs(fm).Parse(*listFmt) + if err != nil { + base.Fatalf("%s", err) + } + do = func(x any) { + if err := tmpl.Execute(out, x); err != nil { + out.Flush() + base.Fatalf("%s", err) + } + if out.NeedNL() { + out.Write(nl) + } + } + } + + modload.Init(moduleLoaderState) + if *listRetracted { + if cfg.BuildMod == "vendor" { + base.Fatalf("go list -retracted cannot be used when vendoring is enabled") + } + if !moduleLoaderState.Enabled() { + base.Fatalf("go list -retracted can only be used in module-aware mode") + } + } + + if *listM { + // Module mode. + if *listCompiled { + base.Fatalf("go list -compiled cannot be used with -m") + } + if *listDeps { + // TODO(rsc): Could make this mean something with -m. + base.Fatalf("go list -deps cannot be used with -m") + } + if *listExport { + base.Fatalf("go list -export cannot be used with -m") + } + if *listFind { + base.Fatalf("go list -find cannot be used with -m") + } + if *listTest { + base.Fatalf("go list -test cannot be used with -m") + } + + if modload.Init(moduleLoaderState); !moduleLoaderState.Enabled() { + base.Fatalf("go: list -m cannot be used with GO111MODULE=off") + } + + modload.LoadModFile(moduleLoaderState, ctx) // Sets cfg.BuildMod as a side-effect. + if cfg.BuildMod == "vendor" { + const actionDisabledFormat = "go: can't %s using the vendor directory\n\t(Use -mod=mod or -mod=readonly to bypass.)" + + if *listVersions { + base.Fatalf(actionDisabledFormat, "determine available versions") + } + if *listU { + base.Fatalf(actionDisabledFormat, "determine available upgrades") + } + + for _, arg := range args { + // In vendor mode, the module graph is incomplete: it contains only the + // explicit module dependencies and the modules that supply packages in + // the import graph. Reject queries that imply more information than that. + if arg == "all" { + base.Fatalf(actionDisabledFormat, "compute 'all'") + } + if strings.Contains(arg, "...") { + base.Fatalf(actionDisabledFormat, "match module patterns") + } + } + } + + var mode modload.ListMode + if *listU { + mode |= modload.ListU | modload.ListRetracted | modload.ListDeprecated + } + if *listRetracted { + mode |= modload.ListRetracted + } + if *listVersions { + mode |= modload.ListVersions + if *listRetracted { + mode |= modload.ListRetractedVersions + } + } + if *listReuse != "" && len(args) == 0 { + base.Fatalf("go: list -m -reuse only has an effect with module@version arguments") + } + mods, err := modload.ListModules(moduleLoaderState, ctx, args, mode, *listReuse) + if !*listE { + for _, m := range mods { + if m.Error != nil { + base.Error(errors.New(m.Error.Err)) + } + } + if err != nil { + base.Error(err) + } + base.ExitIfErrors() + } + for _, m := range mods { + do(m) + } + return + } + + // Package mode (not -m). + if *listU { + base.Fatalf("go list -u can only be used with -m") + } + if *listVersions { + base.Fatalf("go list -versions can only be used with -m") + } + + // These pairings make no sense. + if *listFind && *listDeps { + base.Fatalf("go list -deps cannot be used with -find") + } + if *listFind && *listTest { + base.Fatalf("go list -test cannot be used with -find") + } + if *listFind && *listExport { + base.Fatalf("go list -export cannot be used with -find") + } + + pkgOpts := load.PackageOpts{ + IgnoreImports: *listFind, + ModResolveTests: *listTest, + AutoVCS: true, + SuppressBuildInfo: !*listExport && !listJsonFields.needAny("Stale", "StaleReason"), + SuppressEmbedFiles: !*listExport && !listJsonFields.needAny("EmbedFiles", "TestEmbedFiles", "XTestEmbedFiles"), + } + pkgs := load.PackagesAndErrors(moduleLoaderState, ctx, pkgOpts, args) + if !*listE { + w := 0 + for _, pkg := range pkgs { + if pkg.Error != nil { + base.Errorf("%v", pkg.Error) + continue + } + pkgs[w] = pkg + w++ + } + pkgs = pkgs[:w] + base.ExitIfErrors() + } + + if *listTest { + c := cache.Default() + // Add test binaries to packages to be listed. + + var wg sync.WaitGroup + sema := semaphore.NewWeighted(int64(runtime.GOMAXPROCS(0))) + type testPackageSet struct { + p, pmain, ptest, pxtest *load.Package + } + var testPackages []testPackageSet + for _, p := range pkgs { + if len(p.TestGoFiles)+len(p.XTestGoFiles) > 0 { + var pmain, ptest, pxtest *load.Package + if *listE { + sema.Acquire(ctx, 1) + wg.Add(1) + done := func() { + sema.Release(1) + wg.Done() + } + pmain, ptest, pxtest = load.TestPackagesAndErrors(moduleLoaderState, ctx, done, pkgOpts, p, nil) + } else { + var perr *load.Package + pmain, ptest, pxtest, perr = load.TestPackagesFor(moduleLoaderState, ctx, pkgOpts, p, nil) + if perr != nil { + base.Fatalf("go: can't load test package: %s", perr.Error) + } + } + testPackages = append(testPackages, testPackageSet{p, pmain, ptest, pxtest}) + } + } + wg.Wait() + for _, pkgset := range testPackages { + p, pmain, ptest, pxtest := pkgset.p, pkgset.pmain, pkgset.ptest, pkgset.pxtest + if pmain != nil { + pkgs = append(pkgs, pmain) + data := *pmain.Internal.TestmainGo + sema.Acquire(ctx, 1) + wg.Add(1) + go func() { + h := cache.NewHash("testmain") + h.Write([]byte("testmain\n")) + h.Write(data) + out, _, err := c.Put(h.Sum(), bytes.NewReader(data)) + if err != nil { + base.Fatalf("%s", err) + } + pmain.GoFiles[0] = c.OutputFile(out) + sema.Release(1) + wg.Done() + }() + + } + if ptest != nil && ptest != p { + pkgs = append(pkgs, ptest) + } + if pxtest != nil { + pkgs = append(pkgs, pxtest) + } + } + + wg.Wait() + } + + // Remember which packages are named on the command line. + cmdline := make(map[*load.Package]bool) + for _, p := range pkgs { + cmdline[p] = true + } + + if *listDeps { + // Note: This changes the order of the listed packages + // from "as written on the command line" to + // "a depth-first post-order traversal". + // (The dependency exploration order for a given node + // is alphabetical, same as listed in .Deps.) + // Note that -deps is applied after -test, + // so that you only get descriptions of tests for the things named + // explicitly on the command line, not for all dependencies. + pkgs = loadPackageList(pkgs) + } + + // Do we need to run a build to gather information? + needStale := (listJson && listJsonFields.needAny("Stale", "StaleReason")) || strings.Contains(*listFmt, ".Stale") + if needStale || *listExport || *listCompiled { + b := work.NewBuilder("", moduleLoaderState.VendorDirOrEmpty) + if *listE { + b.AllowErrors = true + } + defer func() { + if err := b.Close(); err != nil { + base.Fatal(err) + } + }() + + b.IsCmdList = true + b.NeedExport = *listExport + b.NeedCompiledGoFiles = *listCompiled + if cfg.BuildCover { + load.PrepareForCoverageBuild(moduleLoaderState, pkgs) + } + a := &work.Action{} + // TODO: Use pkgsFilter? + for _, p := range pkgs { + if len(p.GoFiles)+len(p.CgoFiles) > 0 { + a.Deps = append(a.Deps, b.AutoAction(moduleLoaderState, work.ModeInstall, work.ModeInstall, p)) + } + } + b.Do(ctx, a) + } + + for _, p := range pkgs { + // Show vendor-expanded paths in listing + p.TestImports = p.Resolve(moduleLoaderState, p.TestImports) + p.XTestImports = p.Resolve(moduleLoaderState, p.XTestImports) + p.DepOnly = !cmdline[p] + + if *listCompiled { + p.Imports = str.StringList(p.Imports, p.Internal.CompiledImports) + } + } + + if *listTest || (cfg.BuildPGO == "auto" && len(cmdline) > 1) { + all := pkgs + if !*listDeps { + all = loadPackageList(pkgs) + } + // Update import paths to distinguish the real package p + // from p recompiled for q.test, or to distinguish between + // p compiled with different PGO profiles. + // This must happen only once the build code is done + // looking at import paths, because it will get very confused + // if it sees these. + old := make(map[string]string) + for _, p := range all { + if p.ForTest != "" || p.Internal.ForMain != "" { + new := p.Desc() + old[new] = p.ImportPath + p.ImportPath = new + } + p.DepOnly = !cmdline[p] + } + // Update import path lists to use new strings. + m := make(map[string]string) + for _, p := range all { + for _, p1 := range p.Internal.Imports { + if p1.ForTest != "" || p1.Internal.ForMain != "" { + m[old[p1.ImportPath]] = p1.ImportPath + } + } + for i, old := range p.Imports { + if new := m[old]; new != "" { + p.Imports[i] = new + } + } + clear(m) + } + } + + if listJsonFields.needAny("Deps", "DepsErrors") { + all := pkgs + // Make sure we iterate through packages in a postorder traversal, + // which load.PackageList guarantees. If *listDeps, then all is + // already in PackageList order. Otherwise, calling load.PackageList + // provides the guarantee. In the case of an import cycle, the last package + // visited in the cycle, importing the first encountered package in the cycle, + // is visited first. The cycle import error will be bubbled up in the traversal + // order up to the first package in the cycle, covering all the packages + // in the cycle. + if !*listDeps { + all = load.PackageList(pkgs) + } + if listJsonFields.needAny("Deps") { + for _, p := range all { + collectDeps(p) + } + } + if listJsonFields.needAny("DepsErrors") { + for _, p := range all { + collectDepsErrors(p) + } + } + } + + // TODO(golang.org/issue/40676): This mechanism could be extended to support + // -u without -m. + if *listRetracted { + // Load retractions for modules that provide packages that will be printed. + // TODO(golang.org/issue/40775): Packages from the same module refer to + // distinct ModulePublic instance. It would be nice if they could all point + // to the same instance. This would require additional global state in + // modload.loaded, so that should be refactored first. For now, we update + // all instances. + modToArg := make(map[*modinfo.ModulePublic]string) + argToMods := make(map[string][]*modinfo.ModulePublic) + var args []string + addModule := func(mod *modinfo.ModulePublic) { + if mod.Version == "" { + return + } + arg := fmt.Sprintf("%s@%s", mod.Path, mod.Version) + if argToMods[arg] == nil { + args = append(args, arg) + } + argToMods[arg] = append(argToMods[arg], mod) + modToArg[mod] = arg + } + for _, p := range pkgs { + if p.Module == nil { + continue + } + addModule(p.Module) + if p.Module.Replace != nil { + addModule(p.Module.Replace) + } + } + + if len(args) > 0 { + var mode modload.ListMode + if *listRetracted { + mode |= modload.ListRetracted + } + rmods, err := modload.ListModules(moduleLoaderState, ctx, args, mode, *listReuse) + if err != nil && !*listE { + base.Error(err) + } + for i, arg := range args { + rmod := rmods[i] + for _, mod := range argToMods[arg] { + mod.Retracted = rmod.Retracted + if rmod.Error != nil && mod.Error == nil { + mod.Error = rmod.Error + } + } + } + } + } + + // Record non-identity import mappings in p.ImportMap. + for _, p := range pkgs { + nRaw := len(p.Internal.RawImports) + for i, path := range p.Imports { + var srcPath string + if i < nRaw { + srcPath = p.Internal.RawImports[i] + } else { + // This path is not within the raw imports, so it must be an import + // found only within CompiledGoFiles. Those paths are found in + // CompiledImports. + srcPath = p.Internal.CompiledImports[i-nRaw] + } + + if path != srcPath { + if p.ImportMap == nil { + p.ImportMap = make(map[string]string) + } + p.ImportMap[srcPath] = path + } + } + } + + for _, p := range pkgs { + do(&p.PackagePublic) + } +} + +// loadPackageList is like load.PackageList, but prints error messages and exits +// with nonzero status if listE is not set and any package in the expanded list +// has errors. +func loadPackageList(roots []*load.Package) []*load.Package { + pkgs := load.PackageList(roots) + + if !*listE { + for _, pkg := range pkgs { + if pkg.Error != nil { + base.Errorf("%v", pkg.Error) + } + } + } + + return pkgs +} + +// collectDeps populates p.Deps by iterating over p.Internal.Imports. +// collectDeps must be called on all of p's Imports before being called on p. +func collectDeps(p *load.Package) { + deps := make(map[string]bool) + + for _, p := range p.Internal.Imports { + deps[p.ImportPath] = true + for _, q := range p.Deps { + deps[q] = true + } + } + + p.Deps = make([]string, 0, len(deps)) + for dep := range deps { + p.Deps = append(p.Deps, dep) + } + sort.Strings(p.Deps) +} + +// collectDepsErrors populates p.DepsErrors by iterating over p.Internal.Imports. +// collectDepsErrors must be called on all of p's Imports before being called on p. +func collectDepsErrors(p *load.Package) { + depsErrors := make(map[*load.PackageError]bool) + + for _, p := range p.Internal.Imports { + if p.Error != nil { + depsErrors[p.Error] = true + } + for _, q := range p.DepsErrors { + depsErrors[q] = true + } + } + + p.DepsErrors = make([]*load.PackageError, 0, len(depsErrors)) + for deperr := range depsErrors { + p.DepsErrors = append(p.DepsErrors, deperr) + } + // Sort packages by the package on the top of the stack, which should be + // the package the error was produced for. Each package can have at most + // one error set on it. + sort.Slice(p.DepsErrors, func(i, j int) bool { + stki, stkj := p.DepsErrors[i].ImportStack, p.DepsErrors[j].ImportStack + // Some packages are missing import stacks. To ensure deterministic + // sort order compare two errors that are missing import stacks by + // their errors' error texts. + if len(stki) == 0 { + if len(stkj) != 0 { + return true + } + + return p.DepsErrors[i].Err.Error() < p.DepsErrors[j].Err.Error() + } else if len(stkj) == 0 { + return false + } + pathi, pathj := stki[len(stki)-1], stkj[len(stkj)-1] + return pathi.Pkg < pathj.Pkg + }) +} + +// TrackingWriter tracks the last byte written on every write so +// we can avoid printing a newline if one was already written or +// if there is no output at all. +type TrackingWriter struct { + w *bufio.Writer + last byte +} + +func newTrackingWriter(w io.Writer) *TrackingWriter { + return &TrackingWriter{ + w: bufio.NewWriter(w), + last: '\n', + } +} + +func (t *TrackingWriter) Write(p []byte) (n int, err error) { + n, err = t.w.Write(p) + if n > 0 { + t.last = p[n-1] + } + return +} + +func (t *TrackingWriter) Flush() { + t.w.Flush() +} + +func (t *TrackingWriter) NeedNL() bool { + return t.last != '\n' +} diff --git a/go/src/cmd/go/internal/load/flag.go b/go/src/cmd/go/internal/load/flag.go new file mode 100644 index 0000000000000000000000000000000000000000..a9188db0fd2828b7f3f80e5f31b05c4b1521df2b --- /dev/null +++ b/go/src/cmd/go/internal/load/flag.go @@ -0,0 +1,100 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package load + +import ( + "cmd/go/internal/base" + "cmd/go/internal/modload" + "cmd/internal/quoted" + "fmt" + "strings" +) + +var ( + BuildAsmflags PerPackageFlag // -asmflags + BuildGcflags PerPackageFlag // -gcflags + BuildLdflags PerPackageFlag // -ldflags + BuildGccgoflags PerPackageFlag // -gccgoflags +) + +// A PerPackageFlag is a command-line flag implementation (a flag.Value) +// that allows specifying different effective flags for different packages. +// See 'go help build' for more details about per-package flags. +type PerPackageFlag struct { + raw string + present bool + values []ppfValue +} + +// A ppfValue is a single = per-package flag value. +type ppfValue struct { + match func(*modload.State, *Package) bool // compiled pattern + flags []string +} + +// Set is called each time the flag is encountered on the command line. +func (f *PerPackageFlag) Set(v string) error { + return f.set(v, base.Cwd()) +} + +// set is the implementation of Set, taking a cwd (current working directory) for easier testing. +func (f *PerPackageFlag) set(v, cwd string) error { + f.raw = v + f.present = true + match := func(_ *modload.State, p *Package) bool { return p.Internal.CmdlinePkg || p.Internal.CmdlineFiles } // default predicate with no pattern + // For backwards compatibility with earlier flag splitting, ignore spaces around flags. + v = strings.TrimSpace(v) + if v == "" { + // Special case: -gcflags="" means no flags for command-line arguments + // (overrides previous -gcflags="-whatever"). + f.values = append(f.values, ppfValue{match, []string{}}) + return nil + } + if !strings.HasPrefix(v, "-") { + i := strings.Index(v, "=") + if i < 0 { + return fmt.Errorf("missing = in =") + } + if i == 0 { + return fmt.Errorf("missing in =") + } + if v[0] == '\'' || v[0] == '"' { + return fmt.Errorf("parameter may not start with quote character %c", v[0]) + } + pattern := strings.TrimSpace(v[:i]) + match = MatchPackage(pattern, cwd) + v = v[i+1:] + } + flags, err := quoted.Split(v) + if err != nil { + return err + } + if flags == nil { + flags = []string{} + } + f.values = append(f.values, ppfValue{match, flags}) + return nil +} + +func (f *PerPackageFlag) String() string { return f.raw } + +// Present reports whether the flag appeared on the command line. +func (f *PerPackageFlag) Present() bool { + return f.present +} + +// For returns the flags to use for the given package. +// +// The module loader state is used by the matcher to know if certain +// patterns match packages within the state's MainModules. +func (f *PerPackageFlag) For(s *modload.State, p *Package) []string { + flags := []string{} + for _, v := range f.values { + if v.match(s, p) { + flags = v.flags + } + } + return flags +} diff --git a/go/src/cmd/go/internal/load/flag_test.go b/go/src/cmd/go/internal/load/flag_test.go new file mode 100644 index 0000000000000000000000000000000000000000..0c2363cb79025f778cb754276e2053735f32cda7 --- /dev/null +++ b/go/src/cmd/go/internal/load/flag_test.go @@ -0,0 +1,136 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package load + +import ( + "cmd/go/internal/modload" + "fmt" + "path/filepath" + "reflect" + "testing" +) + +type ppfTestPackage struct { + path string + dir string + cmdline bool + flags []string +} + +type ppfTest struct { + args []string + pkgs []ppfTestPackage +} + +var ppfTests = []ppfTest{ + // -gcflags=-S applies only to packages on command line. + { + args: []string{"-S"}, + pkgs: []ppfTestPackage{ + {cmdline: true, flags: []string{"-S"}}, + {cmdline: false, flags: []string{}}, + }, + }, + + // -gcflags=-S -gcflags= overrides the earlier -S. + { + args: []string{"-S", ""}, + pkgs: []ppfTestPackage{ + {cmdline: true, flags: []string{}}, + }, + }, + + // -gcflags=net=-S applies only to package net + { + args: []string{"net=-S"}, + pkgs: []ppfTestPackage{ + {path: "math", cmdline: true, flags: []string{}}, + {path: "net", flags: []string{"-S"}}, + }, + }, + + // -gcflags=net=-S -gcflags=net= also overrides the earlier -S + { + args: []string{"net=-S", "net="}, + pkgs: []ppfTestPackage{ + {path: "net", flags: []string{}}, + }, + }, + + // -gcflags=net/...=-S net math + // applies -S to net and net/http but not math + { + args: []string{"net/...=-S"}, + pkgs: []ppfTestPackage{ + {path: "net", flags: []string{"-S"}}, + {path: "net/http", flags: []string{"-S"}}, + {path: "math", flags: []string{}}, + }, + }, + + // -gcflags=net/...=-S -gcflags=-m net math + // applies -m to net and math and -S to other packages matching net/... + // (net matches too, but it was grabbed by the later -gcflags). + { + args: []string{"net/...=-S", "-m"}, + pkgs: []ppfTestPackage{ + {path: "net", cmdline: true, flags: []string{"-m"}}, + {path: "math", cmdline: true, flags: []string{"-m"}}, + {path: "net", cmdline: false, flags: []string{"-S"}}, + {path: "net/http", flags: []string{"-S"}}, + {path: "math", flags: []string{}}, + }, + }, + + // relative path patterns + // ppfDirTest(pattern, n, dirs...) says the first n dirs should match and the others should not. + ppfDirTest(".", 1, "/my/test/dir", "/my/test", "/my/test/other", "/my/test/dir/sub"), + ppfDirTest("..", 1, "/my/test", "/my/test/dir", "/my/test/other", "/my/test/dir/sub"), + ppfDirTest("./sub", 1, "/my/test/dir/sub", "/my/test", "/my/test/dir", "/my/test/other", "/my/test/dir/sub/sub"), + ppfDirTest("../other", 1, "/my/test/other", "/my/test", "/my/test/dir", "/my/test/other/sub", "/my/test/dir/other", "/my/test/dir/sub"), + ppfDirTest("./...", 3, "/my/test/dir", "/my/test/dir/sub", "/my/test/dir/sub/sub", "/my/test/other", "/my/test/other/sub"), + ppfDirTest("../...", 4, "/my/test/dir", "/my/test/other", "/my/test/dir/sub", "/my/test/other/sub", "/my/other/test"), + ppfDirTest("../...sub...", 3, "/my/test/dir/sub", "/my/test/othersub", "/my/test/yellowsubmarine", "/my/other/test"), +} + +func ppfDirTest(pattern string, nmatch int, dirs ...string) ppfTest { + var pkgs []ppfTestPackage + for i, d := range dirs { + flags := []string{} + if i < nmatch { + flags = []string{"-S"} + } + pkgs = append(pkgs, ppfTestPackage{path: "p", dir: d, flags: flags}) + } + return ppfTest{args: []string{pattern + "=-S"}, pkgs: pkgs} +} + +func TestPerPackageFlag(t *testing.T) { + nativeDir := func(d string) string { + if filepath.Separator == '\\' { + return `C:` + filepath.FromSlash(d) + } + return d + } + + for i, tt := range ppfTests { + t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) { + ppFlags := new(PerPackageFlag) + for _, arg := range tt.args { + t.Logf("set(%s)", arg) + if err := ppFlags.set(arg, nativeDir("/my/test/dir")); err != nil { + t.Fatal(err) + } + } + for _, p := range tt.pkgs { + dir := nativeDir(p.dir) + flags := ppFlags.For(modload.NewState(), &Package{PackagePublic: PackagePublic{ImportPath: p.path, Dir: dir}, Internal: PackageInternal{CmdlinePkg: p.cmdline}}) + if !reflect.DeepEqual(flags, p.flags) { + t.Errorf("For(%v, %v, %v) = %v, want %v", p.path, dir, p.cmdline, flags, p.flags) + } + } + }) + } +} diff --git a/go/src/cmd/go/internal/load/godebug.go b/go/src/cmd/go/internal/load/godebug.go new file mode 100644 index 0000000000000000000000000000000000000000..817cc4faebf7b477cd07d5506a4aafa41e4d02a9 --- /dev/null +++ b/go/src/cmd/go/internal/load/godebug.go @@ -0,0 +1,150 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package load + +import ( + "errors" + "fmt" + "go/build" + "internal/godebugs" + "maps" + "sort" + "strconv" + "strings" + + "cmd/go/internal/fips140" + "cmd/go/internal/gover" + "cmd/go/internal/modload" +) + +var ErrNotGoDebug = errors.New("not //go:debug line") + +func ParseGoDebug(text string) (key, value string, err error) { + if !strings.HasPrefix(text, "//go:debug") { + return "", "", ErrNotGoDebug + } + i := strings.IndexAny(text, " \t") + if i < 0 { + if strings.TrimSpace(text) == "//go:debug" { + return "", "", fmt.Errorf("missing key=value") + } + return "", "", ErrNotGoDebug + } + k, v, ok := strings.Cut(strings.TrimSpace(text[i:]), "=") + if !ok { + return "", "", fmt.Errorf("missing key=value") + } + if err := modload.CheckGodebug("//go:debug setting", k, v); err != nil { + return "", "", err + } + return k, v, nil +} + +// defaultGODEBUG returns the default GODEBUG setting for the main package p. +// When building a test binary, directives, testDirectives, and xtestDirectives +// list additional directives from the package under test. +func defaultGODEBUG(loaderstate *modload.State, p *Package, directives, testDirectives, xtestDirectives []build.Directive) string { + if p.Name != "main" { + return "" + } + goVersion := loaderstate.MainModules.GoVersion(loaderstate) + if loaderstate.RootMode == modload.NoRoot && p.Module != nil { + // This is go install pkg@version or go run pkg@version. + // Use the Go version from the package. + // If there isn't one, then assume Go 1.20, + // the last version before GODEBUGs were introduced. + goVersion = p.Module.GoVersion + if goVersion == "" { + goVersion = "1.20" + } + } + + var m map[string]string + + // If GOFIPS140 is set to anything but "off", + // default to GODEBUG=fips140=on. + if fips140.Enabled() { + if m == nil { + m = make(map[string]string) + } + m["fips140"] = "on" + } + + // Add directives from main module go.mod. + for _, g := range loaderstate.MainModules.Godebugs(loaderstate) { + if m == nil { + m = make(map[string]string) + } + m[g.Key] = g.Value + } + + // Add directives from packages. + for _, list := range [][]build.Directive{p.Internal.Build.Directives, directives, testDirectives, xtestDirectives} { + for _, d := range list { + k, v, err := ParseGoDebug(d.Text) + if err != nil { + continue + } + if m == nil { + m = make(map[string]string) + } + m[k] = v + } + } + if v, ok := m["default"]; ok { + delete(m, "default") + v = strings.TrimPrefix(v, "go") + if gover.IsValid(v) { + goVersion = v + } + } + + defaults := godebugForGoVersion(goVersion) + if defaults != nil { + // Apply m on top of defaults. + maps.Copy(defaults, m) + m = defaults + } + + keys := make([]string, 0, len(m)) + for k := range m { + keys = append(keys, k) + } + sort.Strings(keys) + var b strings.Builder + for _, k := range keys { + if b.Len() > 0 { + b.WriteString(",") + } + b.WriteString(k) + b.WriteString("=") + b.WriteString(m[k]) + } + return b.String() +} + +func godebugForGoVersion(v string) map[string]string { + if strings.Count(v, ".") >= 2 { + i := strings.Index(v, ".") + j := i + 1 + strings.Index(v[i+1:], ".") + v = v[:j] + } + + if !strings.HasPrefix(v, "1.") { + return nil + } + n, err := strconv.Atoi(v[len("1."):]) + if err != nil { + return nil + } + + def := make(map[string]string) + for _, info := range godebugs.All { + if n < info.Changed { + def[info.Name] = info.Old + } + } + return def +} diff --git a/go/src/cmd/go/internal/load/path.go b/go/src/cmd/go/internal/load/path.go new file mode 100644 index 0000000000000000000000000000000000000000..584cdff89163253c02dbc76ee34b72587e0f798f --- /dev/null +++ b/go/src/cmd/go/internal/load/path.go @@ -0,0 +1,18 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package load + +import ( + "path/filepath" +) + +// expandPath returns the symlink-expanded form of path. +func expandPath(p string) string { + x, err := filepath.EvalSymlinks(p) + if err == nil { + return x + } + return p +} diff --git a/go/src/cmd/go/internal/load/pkg.go b/go/src/cmd/go/internal/load/pkg.go new file mode 100644 index 0000000000000000000000000000000000000000..e2a77d7d7df85b66fe4af562ec7387547f63b738 --- /dev/null +++ b/go/src/cmd/go/internal/load/pkg.go @@ -0,0 +1,3618 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package load loads packages. +package load + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "go/build" + "go/scanner" + "go/token" + "internal/godebug" + "internal/platform" + "io/fs" + "os" + pathpkg "path" + "path/filepath" + "runtime" + "runtime/debug" + "slices" + "sort" + "strconv" + "strings" + "time" + "unicode" + "unicode/utf8" + + "cmd/internal/objabi" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/fips140" + "cmd/go/internal/fsys" + "cmd/go/internal/gover" + "cmd/go/internal/imports" + "cmd/go/internal/modfetch" + "cmd/go/internal/modindex" + "cmd/go/internal/modinfo" + "cmd/go/internal/modload" + "cmd/go/internal/search" + "cmd/go/internal/str" + "cmd/go/internal/trace" + "cmd/go/internal/vcs" + "cmd/internal/par" + "cmd/internal/pathcache" + "cmd/internal/pkgpattern" + + "golang.org/x/mod/modfile" + "golang.org/x/mod/module" +) + +// A Package describes a single package found in a directory. +type Package struct { + PackagePublic // visible in 'go list' + Internal PackageInternal // for use inside go command only +} + +type PackagePublic struct { + // Note: These fields are part of the go command's public API. + // See list.go. It is okay to add fields, but not to change or + // remove existing ones. Keep in sync with ../list/list.go + Dir string `json:",omitempty"` // directory containing package sources + ImportPath string `json:",omitempty"` // import path of package in dir + ImportComment string `json:",omitempty"` // path in import comment on package statement + Name string `json:",omitempty"` // package name + Doc string `json:",omitempty"` // package documentation string + Target string `json:",omitempty"` // installed target for this package (may be executable) + Shlib string `json:",omitempty"` // the shared library that contains this package (only set when -linkshared) + Root string `json:",omitempty"` // Go root, Go path dir, or module root dir containing this package + ConflictDir string `json:",omitempty"` // Dir is hidden by this other directory + ForTest string `json:",omitempty"` // package is only for use in named test + Export string `json:",omitempty"` // file containing export data (set by go list -export) + BuildID string `json:",omitempty"` // build ID of the compiled package (set by go list -export) + Module *modinfo.ModulePublic `json:",omitempty"` // info about package's module, if any + Match []string `json:",omitempty"` // command-line patterns matching this package + Goroot bool `json:",omitempty"` // is this package found in the Go root? + Standard bool `json:",omitempty"` // is this package part of the standard Go library? + DepOnly bool `json:",omitempty"` // package is only as a dependency, not explicitly listed + BinaryOnly bool `json:",omitempty"` // package cannot be recompiled + Incomplete bool `json:",omitempty"` // was there an error loading this package or dependencies? + + DefaultGODEBUG string `json:",omitempty"` // default GODEBUG setting (only for Name=="main") + + // Stale and StaleReason remain here *only* for the list command. + // They are only initialized in preparation for list execution. + // The regular build determines staleness on the fly during action execution. + Stale bool `json:",omitempty"` // would 'go install' do anything for this package? + StaleReason string `json:",omitempty"` // why is Stale true? + + // Source files + // If you add to this list you MUST add to p.AllFiles (below) too. + // Otherwise file name security lists will not apply to any new additions. + GoFiles []string `json:",omitempty"` // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles) + CgoFiles []string `json:",omitempty"` // .go source files that import "C" + CompiledGoFiles []string `json:",omitempty"` // .go output from running cgo on CgoFiles + IgnoredGoFiles []string `json:",omitempty"` // .go source files ignored due to build constraints + InvalidGoFiles []string `json:",omitempty"` // .go source files with detected problems (parse error, wrong package name, and so on) + IgnoredOtherFiles []string `json:",omitempty"` // non-.go source files ignored due to build constraints + CFiles []string `json:",omitempty"` // .c source files + CXXFiles []string `json:",omitempty"` // .cc, .cpp and .cxx source files + MFiles []string `json:",omitempty"` // .m source files + HFiles []string `json:",omitempty"` // .h, .hh, .hpp and .hxx source files + FFiles []string `json:",omitempty"` // .f, .F, .for and .f90 Fortran source files + SFiles []string `json:",omitempty"` // .s source files + SwigFiles []string `json:",omitempty"` // .swig files + SwigCXXFiles []string `json:",omitempty"` // .swigcxx files + SysoFiles []string `json:",omitempty"` // .syso system object files added to package + + // Embedded files + EmbedPatterns []string `json:",omitempty"` // //go:embed patterns + EmbedFiles []string `json:",omitempty"` // files matched by EmbedPatterns + + // Cgo directives + CgoCFLAGS []string `json:",omitempty"` // cgo: flags for C compiler + CgoCPPFLAGS []string `json:",omitempty"` // cgo: flags for C preprocessor + CgoCXXFLAGS []string `json:",omitempty"` // cgo: flags for C++ compiler + CgoFFLAGS []string `json:",omitempty"` // cgo: flags for Fortran compiler + CgoLDFLAGS []string `json:",omitempty"` // cgo: flags for linker + CgoPkgConfig []string `json:",omitempty"` // cgo: pkg-config names + + // Dependency information + Imports []string `json:",omitempty"` // import paths used by this package + ImportMap map[string]string `json:",omitempty"` // map from source import to ImportPath (identity entries omitted) + Deps []string `json:",omitempty"` // all (recursively) imported dependencies + + // Error information + // Incomplete is above, packed into the other bools + Error *PackageError `json:",omitempty"` // error loading this package (not dependencies) + DepsErrors []*PackageError `json:",omitempty"` // errors loading dependencies, collected by go list before output + + // Test information + // If you add to this list you MUST add to p.AllFiles (below) too. + // Otherwise file name security lists will not apply to any new additions. + TestGoFiles []string `json:",omitempty"` // _test.go files in package + TestImports []string `json:",omitempty"` // imports from TestGoFiles + TestEmbedPatterns []string `json:",omitempty"` // //go:embed patterns + TestEmbedFiles []string `json:",omitempty"` // files matched by TestEmbedPatterns + XTestGoFiles []string `json:",omitempty"` // _test.go files outside package + XTestImports []string `json:",omitempty"` // imports from XTestGoFiles + XTestEmbedPatterns []string `json:",omitempty"` // //go:embed patterns + XTestEmbedFiles []string `json:",omitempty"` // files matched by XTestEmbedPatterns +} + +// AllFiles returns the names of all the files considered for the package. +// This is used for sanity and security checks, so we include all files, +// even IgnoredGoFiles, because some subcommands consider them. +// The go/build package filtered others out (like foo_wrongGOARCH.s) +// and that's OK. +func (p *Package) AllFiles() []string { + files := str.StringList( + p.GoFiles, + p.CgoFiles, + // no p.CompiledGoFiles, because they are from GoFiles or generated by us + p.IgnoredGoFiles, + // no p.InvalidGoFiles, because they are from GoFiles + p.IgnoredOtherFiles, + p.CFiles, + p.CXXFiles, + p.MFiles, + p.HFiles, + p.FFiles, + p.SFiles, + p.SwigFiles, + p.SwigCXXFiles, + p.SysoFiles, + p.TestGoFiles, + p.XTestGoFiles, + ) + + // EmbedFiles may overlap with the other files. + // Dedup, but delay building the map as long as possible. + // Only files in the current directory (no slash in name) + // need to be checked against the files variable above. + var have map[string]bool + for _, file := range p.EmbedFiles { + if !strings.Contains(file, "/") { + if have == nil { + have = make(map[string]bool) + for _, file := range files { + have[file] = true + } + } + if have[file] { + continue + } + } + files = append(files, file) + } + return files +} + +// Desc returns the package "description", for use in b.showOutput. +func (p *Package) Desc() string { + if p.ForTest != "" { + return p.ImportPath + " [" + p.ForTest + ".test]" + } + if p.Internal.ForMain != "" { + return p.ImportPath + " [" + p.Internal.ForMain + "]" + } + return p.ImportPath +} + +// IsTestOnly reports whether p is a test-only package. +// +// A “test-only” package is one that: +// - is a test-only variant of an ordinary package, or +// - is a synthesized "main" package for a test binary, or +// - contains only _test.go files. +func (p *Package) IsTestOnly() bool { + return p.ForTest != "" || + p.Internal.TestmainGo != nil || + len(p.TestGoFiles)+len(p.XTestGoFiles) > 0 && len(p.GoFiles)+len(p.CgoFiles) == 0 +} + +type PackageInternal struct { + // Unexported fields are not part of the public API. + Build *build.Package + Imports []*Package // this package's direct imports + CompiledImports []string // additional Imports necessary when using CompiledGoFiles (all from standard library); 1:1 with the end of PackagePublic.Imports + RawImports []string // this package's original imports as they appear in the text of the program; 1:1 with the end of PackagePublic.Imports + ForceLibrary bool // this package is a library (even if named "main") + CmdlineFiles bool // package built from files listed on command line + CmdlinePkg bool // package listed on command line + CmdlinePkgLiteral bool // package listed as literal on command line (not via wildcard) + Local bool // imported via local path (./ or ../) + LocalPrefix string // interpret ./ and ../ imports relative to this prefix + ExeName string // desired name for temporary executable + FuzzInstrument bool // package should be instrumented for fuzzing + Cover CoverSetup // coverage mode and other setup info of -cover is being applied to this package + OmitDebug bool // tell linker not to write debug information + GobinSubdir bool // install target would be subdir of GOBIN + BuildInfo *debug.BuildInfo // add this info to package main + TestmainGo *[]byte // content for _testmain.go + Embed map[string][]string // //go:embed comment mapping + OrigImportPath string // original import path before adding '_test' suffix + PGOProfile string // path to PGO profile + ForMain string // the main package if this package is built specifically for it + + Asmflags []string // -asmflags for this package + Gcflags []string // -gcflags for this package + Ldflags []string // -ldflags for this package + Gccgoflags []string // -gccgoflags for this package +} + +// A NoGoError indicates that no Go files for the package were applicable to the +// build for that package. +// +// That may be because there were no files whatsoever, or because all files were +// excluded, or because all non-excluded files were test sources. +type NoGoError struct { + Package *Package +} + +func (e *NoGoError) Error() string { + if len(e.Package.IgnoredGoFiles) > 0 { + // Go files exist, but they were ignored due to build constraints. + return "build constraints exclude all Go files in " + e.Package.Dir + } + if len(e.Package.TestGoFiles)+len(e.Package.XTestGoFiles) > 0 { + // Test Go files exist, but we're not interested in them. + // The double-negative is unfortunate but we want e.Package.Dir + // to appear at the end of error message. + return "no non-test Go files in " + e.Package.Dir + } + return "no Go files in " + e.Package.Dir +} + +// setLoadPackageDataError presents an error found when loading package data +// as a *PackageError. It has special cases for some common errors to improve +// messages shown to users and reduce redundancy. +// +// setLoadPackageDataError returns true if it's safe to load information about +// imported packages, for example, if there was a parse error loading imports +// in one file, but other files are okay. +func (p *Package) setLoadPackageDataError(err error, path string, stk *ImportStack, importPos []token.Position) { + matchErr, isMatchErr := err.(*search.MatchError) + if isMatchErr && matchErr.Match.Pattern() == path { + if matchErr.Match.IsLiteral() { + // The error has a pattern has a pattern similar to the import path. + // It may be slightly different (./foo matching example.com/foo), + // but close enough to seem redundant. + // Unwrap the error so we don't show the pattern. + err = matchErr.Err + } + } + + // Replace (possibly wrapped) *build.NoGoError with *load.NoGoError. + // The latter is more specific about the cause. + nogoErr, ok := errors.AsType[*build.NoGoError](err) + if ok { + if p.Dir == "" && nogoErr.Dir != "" { + p.Dir = nogoErr.Dir + } + err = &NoGoError{Package: p} + } + + // Take only the first error from a scanner.ErrorList. PackageError only + // has room for one position, so we report the first error with a position + // instead of all of the errors without a position. + var pos string + var isScanErr bool + if scanErr, ok := err.(scanner.ErrorList); ok && len(scanErr) > 0 { + isScanErr = true // For stack push/pop below. + + scanPos := scanErr[0].Pos + scanPos.Filename = base.ShortPath(scanPos.Filename) + pos = scanPos.String() + err = errors.New(scanErr[0].Msg) + } + + // Report the error on the importing package if the problem is with the import declaration + // for example, if the package doesn't exist or if the import path is malformed. + // On the other hand, don't include a position if the problem is with the imported package, + // for example there are no Go files (NoGoError), or there's a problem in the imported + // package's source files themselves (scanner errors). + // + // TODO(matloob): Perhaps make each of those the errors in the first group + // (including modload.ImportMissingError, ImportMissingSumError, and the + // corresponding "cannot find package %q in any of" GOPATH-mode error + // produced in build.(*Context).Import; modload.AmbiguousImportError, + // and modload.PackageNotInModuleError; and the malformed module path errors + // produced in golang.org/x/mod/module.CheckMod) implement an interface + // to make it easier to check for them? That would save us from having to + // move the modload errors into this package to avoid a package import cycle, + // and from having to export an error type for the errors produced in build. + if !isMatchErr && (nogoErr != nil || isScanErr) { + stk.Push(ImportInfo{Pkg: path, Pos: extractFirstImport(importPos)}) + defer stk.Pop() + } + + p.Error = &PackageError{ + ImportStack: stk.Copy(), + Pos: pos, + Err: err, + } + p.Incomplete = true + + top, ok := stk.Top() + if ok && path != top.Pkg { + p.Error.setPos(importPos) + } +} + +// Resolve returns the resolved version of imports, +// which should be p.TestImports or p.XTestImports, NOT p.Imports. +// The imports in p.TestImports and p.XTestImports are not recursively +// loaded during the initial load of p, so they list the imports found in +// the source file, but most processing should be over the vendor-resolved +// import paths. We do this resolution lazily both to avoid file system work +// and because the eventual real load of the test imports (during 'go test') +// can produce better error messages if it starts with the original paths. +// The initial load of p loads all the non-test imports and rewrites +// the vendored paths, so nothing should ever call p.vendored(p.Imports). +func (p *Package) Resolve(s *modload.State, imports []string) []string { + if len(imports) > 0 && len(p.Imports) > 0 && &imports[0] == &p.Imports[0] { + panic("internal error: p.Resolve(p.Imports) called") + } + seen := make(map[string]bool) + var all []string + for _, path := range imports { + path = ResolveImportPath(s, p, path) + if !seen[path] { + seen[path] = true + all = append(all, path) + } + } + sort.Strings(all) + return all +} + +// CoverSetup holds parameters related to coverage setup for a given package (covermode, etc). +type CoverSetup struct { + Mode string // coverage mode for this package + Cfg string // path to config file to pass to "go tool cover" + GenMeta bool // ask cover tool to emit a static meta data if set +} + +func (p *Package) copyBuild(opts PackageOpts, pp *build.Package) { + p.Internal.Build = pp + + if pp.PkgTargetRoot != "" && cfg.BuildPkgdir != "" { + old := pp.PkgTargetRoot + pp.PkgRoot = cfg.BuildPkgdir + pp.PkgTargetRoot = cfg.BuildPkgdir + if pp.PkgObj != "" { + pp.PkgObj = filepath.Join(cfg.BuildPkgdir, strings.TrimPrefix(pp.PkgObj, old)) + } + } + + p.Dir = pp.Dir + p.ImportPath = pp.ImportPath + p.ImportComment = pp.ImportComment + p.Name = pp.Name + p.Doc = pp.Doc + p.Root = pp.Root + p.ConflictDir = pp.ConflictDir + p.BinaryOnly = pp.BinaryOnly + + // TODO? Target + p.Goroot = pp.Goroot || fips140.Snapshot() && str.HasFilePathPrefix(p.Dir, fips140.Dir()) + p.Standard = p.Goroot && p.ImportPath != "" && search.IsStandardImportPath(p.ImportPath) + p.GoFiles = pp.GoFiles + p.CgoFiles = pp.CgoFiles + p.IgnoredGoFiles = pp.IgnoredGoFiles + p.InvalidGoFiles = pp.InvalidGoFiles + p.IgnoredOtherFiles = pp.IgnoredOtherFiles + p.CFiles = pp.CFiles + p.CXXFiles = pp.CXXFiles + p.MFiles = pp.MFiles + p.HFiles = pp.HFiles + p.FFiles = pp.FFiles + p.SFiles = pp.SFiles + p.SwigFiles = pp.SwigFiles + p.SwigCXXFiles = pp.SwigCXXFiles + p.SysoFiles = pp.SysoFiles + if cfg.BuildMSan { + // There's no way for .syso files to be built both with and without + // support for memory sanitizer. Assume they are built without, + // and drop them. + p.SysoFiles = nil + } + p.CgoCFLAGS = pp.CgoCFLAGS + p.CgoCPPFLAGS = pp.CgoCPPFLAGS + p.CgoCXXFLAGS = pp.CgoCXXFLAGS + p.CgoFFLAGS = pp.CgoFFLAGS + p.CgoLDFLAGS = pp.CgoLDFLAGS + p.CgoPkgConfig = pp.CgoPkgConfig + // We modify p.Imports in place, so make copy now. + p.Imports = make([]string, len(pp.Imports)) + copy(p.Imports, pp.Imports) + p.Internal.RawImports = pp.Imports + p.TestGoFiles = pp.TestGoFiles + p.TestImports = pp.TestImports + p.XTestGoFiles = pp.XTestGoFiles + p.XTestImports = pp.XTestImports + if opts.IgnoreImports { + p.Imports = nil + p.Internal.RawImports = nil + p.TestImports = nil + p.XTestImports = nil + } + p.EmbedPatterns = pp.EmbedPatterns + p.TestEmbedPatterns = pp.TestEmbedPatterns + p.XTestEmbedPatterns = pp.XTestEmbedPatterns + p.Internal.OrigImportPath = pp.ImportPath +} + +// A PackageError describes an error loading information about a package. +type PackageError struct { + ImportStack ImportStack // shortest path from package named on command line to this one with position + Pos string // position of error + Err error // the error itself + IsImportCycle bool // the error is an import cycle + alwaysPrintStack bool // whether to always print the ImportStack +} + +func (p *PackageError) Error() string { + // TODO(#43696): decide when to print the stack or the position based on + // the error type and whether the package is in the main module. + // Document the rationale. + if p.Pos != "" && (len(p.ImportStack) == 0 || !p.alwaysPrintStack) { + // Omit import stack. The full path to the file where the error + // is the most important thing. + return p.Pos + ": " + p.Err.Error() + } + + // If the error is an ImportPathError, and the last path on the stack appears + // in the error message, omit that path from the stack to avoid repetition. + // If an ImportPathError wraps another ImportPathError that matches the + // last path on the stack, we don't omit the path. An error like + // "package A imports B: error loading C caused by B" would not be clearer + // if "imports B" were omitted. + if len(p.ImportStack) == 0 { + return p.Err.Error() + } + var optpos string + if p.Pos != "" { + optpos = "\n\t" + p.Pos + } + imports := p.ImportStack.Pkgs() + if p.IsImportCycle { + imports = p.ImportStack.PkgsWithPos() + } + return "package " + strings.Join(imports, "\n\timports ") + optpos + ": " + p.Err.Error() +} + +func (p *PackageError) Unwrap() error { return p.Err } + +// PackageError implements MarshalJSON so that Err is marshaled as a string +// and non-essential fields are omitted. +func (p *PackageError) MarshalJSON() ([]byte, error) { + perr := struct { + ImportStack []string // use []string for package names + Pos string + Err string + }{p.ImportStack.Pkgs(), p.Pos, p.Err.Error()} + return json.Marshal(perr) +} + +func (p *PackageError) setPos(posList []token.Position) { + if len(posList) == 0 { + return + } + pos := posList[0] + pos.Filename = base.ShortPath(pos.Filename) + p.Pos = pos.String() +} + +// ImportPathError is a type of error that prevents a package from being loaded +// for a given import path. When such a package is loaded, a *Package is +// returned with Err wrapping an ImportPathError: the error is attached to +// the imported package, not the importing package. +// +// The string returned by ImportPath must appear in the string returned by +// Error. Errors that wrap ImportPathError (such as PackageError) may omit +// the import path. +type ImportPathError interface { + error + ImportPath() string +} + +var ( + _ ImportPathError = (*importError)(nil) + _ ImportPathError = (*mainPackageError)(nil) + _ ImportPathError = (*modload.ImportMissingError)(nil) + _ ImportPathError = (*modload.ImportMissingSumError)(nil) + _ ImportPathError = (*modload.DirectImportFromImplicitDependencyError)(nil) +) + +type importError struct { + importPath string + err error // created with fmt.Errorf +} + +func ImportErrorf(path, format string, args ...any) ImportPathError { + err := &importError{importPath: path, err: fmt.Errorf(format, args...)} + if errStr := err.Error(); !strings.Contains(errStr, path) && !strings.Contains(errStr, strconv.Quote(path)) { + panic(fmt.Sprintf("path %q not in error %q", path, errStr)) + } + return err +} + +func (e *importError) Error() string { + return e.err.Error() +} + +func (e *importError) Unwrap() error { + // Don't return e.err directly, since we're only wrapping an error if %w + // was passed to ImportErrorf. + return errors.Unwrap(e.err) +} + +func (e *importError) ImportPath() string { + return e.importPath +} + +type ImportInfo struct { + Pkg string + Pos *token.Position +} + +// An ImportStack is a stack of import paths, possibly with the suffix " (test)" appended. +// The import path of a test package is the import path of the corresponding +// non-test package with the suffix "_test" added. +type ImportStack []ImportInfo + +func NewImportInfo(pkg string, pos *token.Position) ImportInfo { + return ImportInfo{Pkg: pkg, Pos: pos} +} + +func (s *ImportStack) Push(p ImportInfo) { + *s = append(*s, p) +} + +func (s *ImportStack) Pop() { + *s = (*s)[0 : len(*s)-1] +} + +func (s *ImportStack) Copy() ImportStack { + return slices.Clone(*s) +} + +func (s *ImportStack) Pkgs() []string { + ss := make([]string, 0, len(*s)) + for _, v := range *s { + ss = append(ss, v.Pkg) + } + return ss +} + +func (s *ImportStack) PkgsWithPos() []string { + ss := make([]string, 0, len(*s)) + for _, v := range *s { + if v.Pos != nil { + ss = append(ss, v.Pkg+" from "+filepath.Base(v.Pos.Filename)) + } else { + ss = append(ss, v.Pkg) + } + } + return ss +} + +func (s *ImportStack) Top() (ImportInfo, bool) { + if len(*s) == 0 { + return ImportInfo{}, false + } + return (*s)[len(*s)-1], true +} + +// shorterThan reports whether sp is shorter than t. +// We use this to record the shortest import sequence +// that leads to a particular package. +func (sp *ImportStack) shorterThan(t []string) bool { + s := *sp + if len(s) != len(t) { + return len(s) < len(t) + } + // If they are the same length, settle ties using string ordering. + for i := range s { + siPkg := s[i].Pkg + if siPkg != t[i] { + return siPkg < t[i] + } + } + return false // they are equal +} + +// packageCache is a lookup cache for LoadImport, +// so that if we look up a package multiple times +// we return the same pointer each time. +var packageCache = map[string]*Package{} + +// dirToImportPath returns the pseudo-import path we use for a package +// outside the Go path. It begins with _/ and then contains the full path +// to the directory. If the package lives in c:\home\gopher\my\pkg then +// the pseudo-import path is _/c_/home/gopher/my/pkg. +// Using a pseudo-import path like this makes the ./ imports no longer +// a special case, so that all the code to deal with ordinary imports works +// automatically. +func dirToImportPath(dir string) string { + return pathpkg.Join("_", strings.Map(makeImportValid, filepath.ToSlash(dir))) +} + +func makeImportValid(r rune) rune { + // Should match Go spec, compilers, and ../../go/parser/parser.go:/isValidImport. + const illegalChars = `!"#$%&'()*,:;<=>?[\]^{|}` + "`\uFFFD" + if !unicode.IsGraphic(r) || unicode.IsSpace(r) || strings.ContainsRune(illegalChars, r) { + return '_' + } + return r +} + +// Mode flags for loadImport and download (in get.go). +const ( + // ResolveImport means that loadImport should do import path expansion. + // That is, ResolveImport means that the import path came from + // a source file and has not been expanded yet to account for + // vendoring or possible module adjustment. + // Every import path should be loaded initially with ResolveImport, + // and then the expanded version (for example with the /vendor/ in it) + // gets recorded as the canonical import path. At that point, future loads + // of that package must not pass ResolveImport, because + // disallowVendor will reject direct use of paths containing /vendor/. + ResolveImport = 1 << iota + + // ResolveModule is for download (part of "go get") and indicates + // that the module adjustment should be done, but not vendor adjustment. + ResolveModule + + // GetTestDeps is for download (part of "go get") and indicates + // that test dependencies should be fetched too. + GetTestDeps + + // The remainder are internal modes for calls to loadImport. + + // cmdlinePkg is for a package mentioned on the command line. + cmdlinePkg + + // cmdlinePkgLiteral is for a package mentioned on the command line + // without using any wildcards or meta-patterns. + cmdlinePkgLiteral +) + +// LoadPackage does Load import, but without a parent package load context +func LoadPackage(loaderstate *modload.State, ctx context.Context, opts PackageOpts, path, srcDir string, stk *ImportStack, importPos []token.Position, mode int) *Package { + p, err := loadImport(loaderstate, ctx, opts, nil, path, srcDir, nil, stk, importPos, mode) + if err != nil { + base.Fatalf("internal error: loadImport of %q with nil parent returned an error", path) + } + return p +} + +// loadImport scans the directory named by path, which must be an import path, +// but possibly a local import path (an absolute file system path or one beginning +// with ./ or ../). A local relative path is interpreted relative to srcDir. +// It returns a *Package describing the package found in that directory. +// loadImport does not set tool flags and should only be used by +// this package, as part of a bigger load operation. +// The returned PackageError, if any, describes why parent is not allowed +// to import the named package, with the error referring to importPos. +// The PackageError can only be non-nil when parent is not nil. +func loadImport(loaderstate *modload.State, ctx context.Context, opts PackageOpts, pre *preload, path, srcDir string, parent *Package, stk *ImportStack, importPos []token.Position, mode int) (*Package, *PackageError) { + ctx, span := trace.StartSpan(ctx, "modload.loadImport "+path) + defer span.Done() + + if path == "" { + panic("LoadImport called with empty package path") + } + + var parentPath, parentRoot string + parentIsStd := false + if parent != nil { + parentPath = parent.ImportPath + parentRoot = parent.Root + parentIsStd = parent.Standard + } + bp, loaded, err := loadPackageData(loaderstate, ctx, path, parentPath, srcDir, parentRoot, parentIsStd, mode) + if loaded && pre != nil && !opts.IgnoreImports { + pre.preloadImports(loaderstate, ctx, opts, bp.Imports, bp) + } + if bp == nil { + p := &Package{ + PackagePublic: PackagePublic{ + ImportPath: path, + Incomplete: true, + }, + } + if importErr, ok := err.(ImportPathError); !ok || importErr.ImportPath() != path { + // Only add path to the error's import stack if it's not already present + // in the error. + // + // TODO(bcmills): setLoadPackageDataError itself has a similar Push / Pop + // sequence that empirically doesn't trigger for these errors, guarded by + // a somewhat complex condition. Figure out how to generalize that + // condition and eliminate the explicit calls here. + stk.Push(ImportInfo{Pkg: path, Pos: extractFirstImport(importPos)}) + defer stk.Pop() + } + p.setLoadPackageDataError(err, path, stk, nil) + return p, nil + } + + setCmdline := func(p *Package) { + if mode&cmdlinePkg != 0 { + p.Internal.CmdlinePkg = true + } + if mode&cmdlinePkgLiteral != 0 { + p.Internal.CmdlinePkgLiteral = true + } + } + + importPath := bp.ImportPath + p := packageCache[importPath] + if p != nil { + stk.Push(ImportInfo{Pkg: path, Pos: extractFirstImport(importPos)}) + p = reusePackage(p, stk) + stk.Pop() + setCmdline(p) + } else { + p = new(Package) + p.Internal.Local = build.IsLocalImport(path) + p.ImportPath = importPath + packageCache[importPath] = p + + setCmdline(p) + + // Load package. + // loadPackageData may return bp != nil even if an error occurs, + // in order to return partial information. + p.load(loaderstate, ctx, opts, path, stk, importPos, bp, err) + + if !cfg.ModulesEnabled && path != cleanImport(path) { + p.Error = &PackageError{ + ImportStack: stk.Copy(), + Err: ImportErrorf(path, "non-canonical import path %q: should be %q", path, pathpkg.Clean(path)), + } + p.Incomplete = true + p.Error.setPos(importPos) + } + } + + // Checked on every import because the rules depend on the code doing the importing. + if perr := disallowInternal(loaderstate, ctx, srcDir, parent, parentPath, p, stk); perr != nil { + perr.setPos(importPos) + return p, perr + } + if mode&ResolveImport != 0 { + if perr := disallowVendor(srcDir, path, parentPath, p, stk); perr != nil { + perr.setPos(importPos) + return p, perr + } + } + + if p.Name == "main" && parent != nil && parent.Dir != p.Dir { + perr := &PackageError{ + ImportStack: stk.Copy(), + Err: ImportErrorf(path, "import %q is a program, not an importable package", path), + } + perr.setPos(importPos) + return p, perr + } + + if p.Internal.Local && parent != nil && !parent.Internal.Local { + var err error + if path == "." { + err = ImportErrorf(path, "%s: cannot import current directory", path) + } else { + err = ImportErrorf(path, "local import %q in non-local package", path) + } + perr := &PackageError{ + ImportStack: stk.Copy(), + Err: err, + } + perr.setPos(importPos) + return p, perr + } + + return p, nil +} + +func extractFirstImport(importPos []token.Position) *token.Position { + if len(importPos) == 0 { + return nil + } + return &importPos[0] +} + +// loadPackageData loads information needed to construct a *Package. The result +// is cached, and later calls to loadPackageData for the same package will return +// the same data. +// +// loadPackageData returns a non-nil package even if err is non-nil unless +// the package path is malformed (for example, the path contains "mod/" or "@"). +// +// loadPackageData returns a boolean, loaded, which is true if this is the +// first time the package was loaded. Callers may preload imports in this case. +func loadPackageData(loaderstate *modload.State, ctx context.Context, path, parentPath, parentDir, parentRoot string, parentIsStd bool, mode int) (bp *build.Package, loaded bool, err error) { + ctx, span := trace.StartSpan(ctx, "load.loadPackageData "+path) + defer span.Done() + + if path == "" { + panic("loadPackageData called with empty package path") + } + + if strings.HasPrefix(path, "mod/") { + // Paths beginning with "mod/" might accidentally + // look in the module cache directory tree in $GOPATH/pkg/mod/. + // This prefix is owned by the Go core for possible use in the + // standard library (since it does not begin with a domain name), + // so it's OK to disallow entirely. + return nil, false, fmt.Errorf("disallowed import path %q", path) + } + + if strings.Contains(path, "@") { + return nil, false, errors.New("can only use path@version syntax with 'go get' and 'go install' in module-aware mode") + } + + // Determine canonical package path and directory. + // For a local import the identifier is the pseudo-import path + // we create from the full directory to the package. + // Otherwise it is the usual import path. + // For vendored imports, it is the expanded form. + // + // Note that when modules are enabled, local import paths are normally + // canonicalized by modload.LoadPackages before now. However, if there's an + // error resolving a local path, it will be returned untransformed + // so that 'go list -e' reports something useful. + importKey := importSpec{ + path: path, + parentPath: parentPath, + parentDir: parentDir, + parentRoot: parentRoot, + parentIsStd: parentIsStd, + mode: mode, + } + r := resolvedImportCache.Do(importKey, func() resolvedImport { + var r resolvedImport + if newPath, dir, ok := fips140.ResolveImport(path); ok { + r.path = newPath + r.dir = dir + } else if cfg.ModulesEnabled { + r.dir, r.path, r.err = modload.Lookup(loaderstate, parentPath, parentIsStd, path) + } else if build.IsLocalImport(path) { + r.dir = filepath.Join(parentDir, path) + r.path = dirToImportPath(r.dir) + } else if mode&ResolveImport != 0 { + // We do our own path resolution, because we want to + // find out the key to use in packageCache without the + // overhead of repeated calls to buildContext.Import. + // The code is also needed in a few other places anyway. + r.path = resolveImportPath(loaderstate, path, parentPath, parentDir, parentRoot, parentIsStd) + } else if mode&ResolveModule != 0 { + r.path = moduleImportPath(path, parentPath, parentDir, parentRoot) + } + if r.path == "" { + r.path = path + } + return r + }) + // Invariant: r.path is set to the resolved import path. If the path cannot + // be resolved, r.path is set to path, the source import path. + // r.path is never empty. + + // Load the package from its directory. If we already found the package's + // directory when resolving its import path, use that. + p, err := packageDataCache.Do(r.path, func() (*build.Package, error) { + loaded = true + var data struct { + p *build.Package + err error + } + if r.dir != "" { + var buildMode build.ImportMode + buildContext := cfg.BuildContext + if !cfg.ModulesEnabled { + buildMode = build.ImportComment + } else { + buildContext.GOPATH = "" // Clear GOPATH so packages are imported as pure module packages + } + modroot := modload.PackageModRoot(loaderstate, ctx, r.path) + if modroot == "" && str.HasPathPrefix(r.dir, cfg.GOROOTsrc) { + modroot = cfg.GOROOTsrc + gorootSrcCmd := filepath.Join(cfg.GOROOTsrc, "cmd") + if str.HasPathPrefix(r.dir, gorootSrcCmd) { + modroot = gorootSrcCmd + } + } + if modroot != "" { + if rp, err := modindex.GetPackage(modroot, r.dir); err == nil { + data.p, data.err = rp.Import(cfg.BuildContext, buildMode) + goto Happy + } else if !errors.Is(err, modindex.ErrNotIndexed) { + base.Fatal(err) + } + } + data.p, data.err = buildContext.ImportDir(r.dir, buildMode) + Happy: + if cfg.ModulesEnabled { + // Override data.p.Root, since ImportDir sets it to $GOPATH, if + // the module is inside $GOPATH/src. + if info := modload.PackageModuleInfo(loaderstate, ctx, path); info != nil { + data.p.Root = info.Dir + } + } + if r.err != nil { + if data.err != nil { + // ImportDir gave us one error, and the module loader gave us another. + // We arbitrarily choose to keep the error from ImportDir because + // that's what our tests already expect, and it seems to provide a bit + // more detail in most cases. + } else if errors.Is(r.err, imports.ErrNoGo) { + // ImportDir said there were files in the package, but the module + // loader said there weren't. Which one is right? + // Without this special-case hack, the TestScript/test_vet case fails + // on the vetfail/p1 package (added in CL 83955). + // Apparently, imports.ShouldBuild biases toward rejecting files + // with invalid build constraints, whereas ImportDir biases toward + // accepting them. + // + // TODO(#41410: Figure out how this actually ought to work and fix + // this mess). + } else { + data.err = r.err + } + } + } else if r.err != nil { + data.p = new(build.Package) + data.err = r.err + } else if cfg.ModulesEnabled && path != "unsafe" { + data.p = new(build.Package) + data.err = fmt.Errorf("unknown import path %q: internal error: module loader did not resolve import", r.path) + } else { + buildMode := build.ImportComment + if mode&ResolveImport == 0 || r.path != path { + // Not vendoring, or we already found the vendored path. + buildMode |= build.IgnoreVendor + } + data.p, data.err = cfg.BuildContext.Import(r.path, parentDir, buildMode) + } + data.p.ImportPath = r.path + + // Set data.p.BinDir in cases where go/build.Context.Import + // may give us a path we don't want. + if !data.p.Goroot { + if cfg.GOBIN != "" { + data.p.BinDir = cfg.GOBIN + } else if cfg.ModulesEnabled { + data.p.BinDir = modload.BinDir(loaderstate) + } + } + + if !cfg.ModulesEnabled && data.err == nil && + data.p.ImportComment != "" && data.p.ImportComment != path && + !strings.Contains(path, "/vendor/") && !strings.HasPrefix(path, "vendor/") { + data.err = fmt.Errorf("code in directory %s expects import %q", data.p.Dir, data.p.ImportComment) + } + return data.p, data.err + }) + + return p, loaded, err +} + +// importSpec describes an import declaration in source code. It is used as a +// cache key for resolvedImportCache. +type importSpec struct { + path string + parentPath, parentDir, parentRoot string + parentIsStd bool + mode int +} + +// resolvedImport holds a canonical identifier for a package. It may also contain +// a path to the package's directory and an error if one occurred. resolvedImport +// is the value type in resolvedImportCache. +type resolvedImport struct { + path, dir string + err error +} + +// resolvedImportCache maps import strings to canonical package names. +var resolvedImportCache par.Cache[importSpec, resolvedImport] + +// packageDataCache maps canonical package names (string) to package metadata. +var packageDataCache par.ErrCache[string, *build.Package] + +// preloadWorkerCount is the number of concurrent goroutines that can load +// packages. Experimentally, there are diminishing returns with more than +// 4 workers. This was measured on the following machines. +// +// * MacBookPro with a 4-core Intel Core i7 CPU +// * Linux workstation with 6-core Intel Xeon CPU +// * Linux workstation with 24-core Intel Xeon CPU +// +// It is very likely (though not confirmed) that this workload is limited +// by memory bandwidth. We don't have a good way to determine the number of +// workers that would saturate the bus though, so runtime.GOMAXPROCS +// seems like a reasonable default. +var preloadWorkerCount = runtime.GOMAXPROCS(0) + +// preload holds state for managing concurrent preloading of package data. +// +// A preload should be created with newPreload before loading a large +// package graph. flush must be called when package loading is complete +// to ensure preload goroutines are no longer active. This is necessary +// because of global mutable state that cannot safely be read and written +// concurrently. In particular, packageDataCache may be cleared by "go get" +// in GOPATH mode, and modload.loaded (accessed via modload.Lookup) may be +// modified by modload.LoadPackages. +type preload struct { + cancel chan struct{} + sema chan struct{} +} + +// newPreload creates a new preloader. flush must be called later to avoid +// accessing global state while it is being modified. +func newPreload() *preload { + pre := &preload{ + cancel: make(chan struct{}), + sema: make(chan struct{}, preloadWorkerCount), + } + return pre +} + +// preloadMatches loads data for package paths matched by patterns. +// When preloadMatches returns, some packages may not be loaded yet, but +// loadPackageData and loadImport are always safe to call. +func (pre *preload) preloadMatches(loaderstate *modload.State, ctx context.Context, opts PackageOpts, matches []*search.Match) { + for _, m := range matches { + for _, pkg := range m.Pkgs { + select { + case <-pre.cancel: + return + case pre.sema <- struct{}{}: + go func(pkg string) { + mode := 0 // don't use vendoring or module import resolution + bp, loaded, err := loadPackageData(loaderstate, ctx, pkg, "", base.Cwd(), "", false, mode) + <-pre.sema + if bp != nil && loaded && err == nil && !opts.IgnoreImports { + pre.preloadImports(loaderstate, ctx, opts, bp.Imports, bp) + } + }(pkg) + } + } + } +} + +// preloadImports queues a list of imports for preloading. +// When preloadImports returns, some packages may not be loaded yet, +// but loadPackageData and loadImport are always safe to call. +func (pre *preload) preloadImports(loaderstate *modload.State, ctx context.Context, opts PackageOpts, imports []string, parent *build.Package) { + parentIsStd := parent.Goroot && parent.ImportPath != "" && search.IsStandardImportPath(parent.ImportPath) + for _, path := range imports { + if path == "C" || path == "unsafe" { + continue + } + select { + case <-pre.cancel: + return + case pre.sema <- struct{}{}: + go func(path string) { + bp, loaded, err := loadPackageData(loaderstate, ctx, path, parent.ImportPath, parent.Dir, parent.Root, parentIsStd, ResolveImport) + <-pre.sema + if bp != nil && loaded && err == nil && !opts.IgnoreImports { + pre.preloadImports(loaderstate, ctx, opts, bp.Imports, bp) + } + }(path) + } + } +} + +// flush stops pending preload operations. flush blocks until preload calls to +// loadPackageData have completed. The preloader will not make any new calls +// to loadPackageData. +func (pre *preload) flush() { + // flush is usually deferred. + // Don't hang program waiting for workers on panic. + if v := recover(); v != nil { + panic(v) + } + + close(pre.cancel) + for i := 0; i < preloadWorkerCount; i++ { + pre.sema <- struct{}{} + } +} + +func cleanImport(path string) string { + orig := path + path = pathpkg.Clean(path) + if strings.HasPrefix(orig, "./") && path != ".." && !strings.HasPrefix(path, "../") { + path = "./" + path + } + return path +} + +var isDirCache par.Cache[string, bool] + +func isDir(path string) bool { + return isDirCache.Do(path, func() bool { + fi, err := fsys.Stat(path) + return err == nil && fi.IsDir() + }) +} + +// ResolveImportPath returns the true meaning of path when it appears in parent. +// There are two different resolutions applied. +// First, there is Go 1.5 vendoring (golang.org/s/go15vendor). +// If vendor expansion doesn't trigger, then the path is also subject to +// Go 1.11 module legacy conversion (golang.org/issue/25069). +func ResolveImportPath(s *modload.State, parent *Package, path string) (found string) { + var parentPath, parentDir, parentRoot string + parentIsStd := false + if parent != nil { + parentPath = parent.ImportPath + parentDir = parent.Dir + parentRoot = parent.Root + parentIsStd = parent.Standard + } + return resolveImportPath(s, path, parentPath, parentDir, parentRoot, parentIsStd) +} + +func resolveImportPath(s *modload.State, path, parentPath, parentDir, parentRoot string, parentIsStd bool) (found string) { + if cfg.ModulesEnabled { + if _, p, e := modload.Lookup(s, parentPath, parentIsStd, path); e == nil { + return p + } + return path + } + found = vendoredImportPath(path, parentPath, parentDir, parentRoot) + if found != path { + return found + } + return moduleImportPath(path, parentPath, parentDir, parentRoot) +} + +// dirAndRoot returns the source directory and workspace root +// for the package p, guaranteeing that root is a path prefix of dir. +func dirAndRoot(path string, dir, root string) (string, string) { + origDir, origRoot := dir, root + dir = filepath.Clean(dir) + root = filepath.Join(root, "src") + if !str.HasFilePathPrefix(dir, root) || path != "command-line-arguments" && filepath.Join(root, path) != dir { + // Look for symlinks before reporting error. + dir = expandPath(dir) + root = expandPath(root) + } + + if !str.HasFilePathPrefix(dir, root) || len(dir) <= len(root) || dir[len(root)] != filepath.Separator || path != "command-line-arguments" && !build.IsLocalImport(path) && filepath.Join(root, path) != dir { + debug.PrintStack() + base.Fatalf("unexpected directory layout:\n"+ + " import path: %s\n"+ + " root: %s\n"+ + " dir: %s\n"+ + " expand root: %s\n"+ + " expand dir: %s\n"+ + " separator: %s", + path, + filepath.Join(origRoot, "src"), + filepath.Clean(origDir), + origRoot, + origDir, + string(filepath.Separator)) + } + + return dir, root +} + +// vendoredImportPath returns the vendor-expansion of path when it appears in parent. +// If parent is x/y/z, then path might expand to x/y/z/vendor/path, x/y/vendor/path, +// x/vendor/path, vendor/path, or else stay path if none of those exist. +// vendoredImportPath returns the expanded path or, if no expansion is found, the original. +func vendoredImportPath(path, parentPath, parentDir, parentRoot string) (found string) { + if parentRoot == "" { + return path + } + + dir, root := dirAndRoot(parentPath, parentDir, parentRoot) + + vpath := "vendor/" + path + for i := len(dir); i >= len(root); i-- { + if i < len(dir) && dir[i] != filepath.Separator { + continue + } + // Note: checking for the vendor directory before checking + // for the vendor/path directory helps us hit the + // isDir cache more often. It also helps us prepare a more useful + // list of places we looked, to report when an import is not found. + if !isDir(filepath.Join(dir[:i], "vendor")) { + continue + } + targ := filepath.Join(dir[:i], vpath) + if isDir(targ) && hasGoFiles(targ) { + importPath := parentPath + if importPath == "command-line-arguments" { + // If parent.ImportPath is 'command-line-arguments'. + // set to relative directory to root (also chopped root directory) + importPath = dir[len(root)+1:] + } + // We started with parent's dir c:\gopath\src\foo\bar\baz\quux\xyzzy. + // We know the import path for parent's dir. + // We chopped off some number of path elements and + // added vendor\path to produce c:\gopath\src\foo\bar\baz\vendor\path. + // Now we want to know the import path for that directory. + // Construct it by chopping the same number of path elements + // (actually the same number of bytes) from parent's import path + // and then append /vendor/path. + chopped := len(dir) - i + if chopped == len(importPath)+1 { + // We walked up from c:\gopath\src\foo\bar + // and found c:\gopath\src\vendor\path. + // We chopped \foo\bar (length 8) but the import path is "foo/bar" (length 7). + // Use "vendor/path" without any prefix. + return vpath + } + return importPath[:len(importPath)-chopped] + "/" + vpath + } + } + return path +} + +var ( + modulePrefix = []byte("\nmodule ") + goModPathCache par.Cache[string, string] +) + +// goModPath returns the module path in the go.mod in dir, if any. +func goModPath(dir string) (path string) { + return goModPathCache.Do(dir, func() string { + data, err := os.ReadFile(filepath.Join(dir, "go.mod")) + if err != nil { + return "" + } + var i int + if bytes.HasPrefix(data, modulePrefix[1:]) { + i = 0 + } else { + i = bytes.Index(data, modulePrefix) + if i < 0 { + return "" + } + i++ + } + line := data[i:] + + // Cut line at \n, drop trailing \r if present. + if j := bytes.IndexByte(line, '\n'); j >= 0 { + line = line[:j] + } + if line[len(line)-1] == '\r' { + line = line[:len(line)-1] + } + line = line[len("module "):] + + // If quoted, unquote. + path = strings.TrimSpace(string(line)) + if path != "" && path[0] == '"' { + s, err := strconv.Unquote(path) + if err != nil { + return "" + } + path = s + } + return path + }) +} + +// findVersionElement returns the slice indices of the final version element /vN in path. +// If there is no such element, it returns -1, -1. +func findVersionElement(path string) (i, j int) { + j = len(path) + for i = len(path) - 1; i >= 0; i-- { + if path[i] == '/' { + if isVersionElement(path[i+1 : j]) { + return i, j + } + j = i + } + } + return -1, -1 +} + +// isVersionElement reports whether s is a well-formed path version element: +// v2, v3, v10, etc, but not v0, v05, v1. +func isVersionElement(s string) bool { + if len(s) < 2 || s[0] != 'v' || s[1] == '0' || s[1] == '1' && len(s) == 2 { + return false + } + for i := 1; i < len(s); i++ { + if s[i] < '0' || '9' < s[i] { + return false + } + } + return true +} + +// moduleImportPath translates import paths found in go modules +// back down to paths that can be resolved in ordinary builds. +// +// Define “new” code as code with a go.mod file in the same directory +// or a parent directory. If an import in new code says x/y/v2/z but +// x/y/v2/z does not exist and x/y/go.mod says “module x/y/v2”, +// then go build will read the import as x/y/z instead. +// See golang.org/issue/25069. +func moduleImportPath(path, parentPath, parentDir, parentRoot string) (found string) { + if parentRoot == "" { + return path + } + + // If there are no vN elements in path, leave it alone. + // (The code below would do the same, but only after + // some other file system accesses that we can avoid + // here by returning early.) + if i, _ := findVersionElement(path); i < 0 { + return path + } + + dir, root := dirAndRoot(parentPath, parentDir, parentRoot) + + // Consider dir and parents, up to and including root. + for i := len(dir); i >= len(root); i-- { + if i < len(dir) && dir[i] != filepath.Separator { + continue + } + if goModPath(dir[:i]) != "" { + goto HaveGoMod + } + } + // This code is not in a tree with a go.mod, + // so apply no changes to the path. + return path + +HaveGoMod: + // This import is in a tree with a go.mod. + // Allow it to refer to code in GOPATH/src/x/y/z as x/y/v2/z + // if GOPATH/src/x/y/go.mod says module "x/y/v2", + + // If x/y/v2/z exists, use it unmodified. + if bp, _ := cfg.BuildContext.Import(path, "", build.IgnoreVendor); bp.Dir != "" { + return path + } + + // Otherwise look for a go.mod supplying a version element. + // Some version-like elements may appear in paths but not + // be module versions; we skip over those to look for module + // versions. For example the module m/v2 might have a + // package m/v2/api/v1/foo. + limit := len(path) + for limit > 0 { + i, j := findVersionElement(path[:limit]) + if i < 0 { + return path + } + if bp, _ := cfg.BuildContext.Import(path[:i], "", build.IgnoreVendor); bp.Dir != "" { + if mpath := goModPath(bp.Dir); mpath != "" { + // Found a valid go.mod file, so we're stopping the search. + // If the path is m/v2/p and we found m/go.mod that says + // "module m/v2", then we return "m/p". + if mpath == path[:j] { + return path[:i] + path[j:] + } + // Otherwise just return the original path. + // We didn't find anything worth rewriting, + // and the go.mod indicates that we should + // not consider parent directories. + return path + } + } + limit = i + } + return path +} + +// hasGoFiles reports whether dir contains any files with names ending in .go. +// For a vendor check we must exclude directories that contain no .go files. +// Otherwise it is not possible to vendor just a/b/c and still import the +// non-vendored a/b. See golang.org/issue/13832. +func hasGoFiles(dir string) bool { + files, _ := os.ReadDir(dir) + for _, f := range files { + if !f.IsDir() && strings.HasSuffix(f.Name(), ".go") { + return true + } + } + return false +} + +// reusePackage reuses package p to satisfy the import at the top +// of the import stack stk. If this use causes an import loop, +// reusePackage updates p's error information to record the loop. +func reusePackage(p *Package, stk *ImportStack) *Package { + // We use p.Internal.Imports==nil to detect a package that + // is in the midst of its own loadPackage call + // (all the recursion below happens before p.Internal.Imports gets set). + if p.Internal.Imports == nil { + if p.Error == nil { + p.Error = &PackageError{ + ImportStack: stk.Copy(), + Err: errors.New("import cycle not allowed"), + IsImportCycle: true, + } + } else if !p.Error.IsImportCycle { + // If the error is already set, but it does not indicate that + // we are in an import cycle, set IsImportCycle so that we don't + // end up stuck in a loop down the road. + p.Error.IsImportCycle = true + } + p.Incomplete = true + } + // Don't rewrite the import stack in the error if we have an import cycle. + // If we do, we'll lose the path that describes the cycle. + if p.Error != nil && p.Error.ImportStack != nil && + !p.Error.IsImportCycle && stk.shorterThan(p.Error.ImportStack.Pkgs()) { + p.Error.ImportStack = stk.Copy() + } + return p +} + +// disallowInternal checks that srcDir (containing package importerPath, if non-empty) +// is allowed to import p. +// If the import is allowed, disallowInternal returns the original package p. +// If not, it returns a new package containing just an appropriate error. +func disallowInternal(loaderstate *modload.State, ctx context.Context, srcDir string, importer *Package, importerPath string, p *Package, stk *ImportStack) *PackageError { + // golang.org/s/go14internal: + // An import of a path containing the element “internal” + // is disallowed if the importing code is outside the tree + // rooted at the parent of the “internal” directory. + + // There was an error loading the package; stop here. + if p.Error != nil { + return nil + } + + // The generated 'testmain' package is allowed to access testing/internal/..., + // as if it were generated into the testing directory tree + // (it's actually in a temporary directory outside any Go tree). + // This cleans up a former kludge in passing functionality to the testing package. + if str.HasPathPrefix(p.ImportPath, "testing/internal") && importerPath == "testmain" { + return nil + } + + // We can't check standard packages with gccgo. + if cfg.BuildContext.Compiler == "gccgo" && p.Standard { + return nil + } + + // The sort package depends on internal/reflectlite, but during bootstrap + // the path rewriting causes the normal internal checks to fail. + // Instead, just ignore the internal rules during bootstrap. + if p.Standard && strings.HasPrefix(importerPath, "bootstrap/") { + return nil + } + + // importerPath is empty: we started + // with a name given on the command line, not an + // import. Anything listed on the command line is fine. + if importerPath == "" { + return nil + } + + // Check for "internal" element: three cases depending on begin of string and/or end of string. + i, ok := findInternal(p.ImportPath) + if !ok { + return nil + } + + // Internal is present. + // Map import path back to directory corresponding to parent of internal. + if i > 0 { + i-- // rewind over slash in ".../internal" + } + + // FIPS-140 snapshots are special, because they comes from a non-GOROOT + // directory, so the usual directory rules don't work apply, or rather they + // apply differently depending on whether we are using a snapshot or the + // in-tree copy of the code. We apply a consistent rule here: + // crypto/internal/fips140 can only see crypto/internal, never top-of-tree internal. + // Similarly, crypto/... can see crypto/internal/fips140 even though the usual rules + // would not allow it in snapshot mode. + if str.HasPathPrefix(importerPath, "crypto") && str.HasPathPrefix(p.ImportPath, "crypto/internal/fips140") { + return nil // crypto can use crypto/internal/fips140 + } + if str.HasPathPrefix(importerPath, "crypto/internal/fips140") { + if str.HasPathPrefix(p.ImportPath, "crypto/internal") { + return nil // crypto/internal/fips140 can use crypto/internal + } + goto Error + } + + if p.Module == nil { + parent := p.Dir[:i+len(p.Dir)-len(p.ImportPath)] + + if str.HasFilePathPrefix(filepath.Clean(srcDir), filepath.Clean(parent)) { + return nil + } + + // Look for symlinks before reporting error. + srcDir = expandPath(srcDir) + parent = expandPath(parent) + if str.HasFilePathPrefix(filepath.Clean(srcDir), filepath.Clean(parent)) { + return nil + } + } else { + // p is in a module, so make it available based on the importer's import path instead + // of the file path (https://golang.org/issue/23970). + if importer.Internal.CmdlineFiles { + // The importer is a list of command-line files. + // Pretend that the import path is the import path of the + // directory containing them. + // If the directory is outside the main modules, this will resolve to ".", + // which is not a prefix of any valid module. + importerPath, _ = loaderstate.MainModules.DirImportPath(loaderstate, ctx, importer.Dir) + } + parentOfInternal := p.ImportPath[:i] + if str.HasPathPrefix(importerPath, parentOfInternal) { + return nil + } + } + +Error: + // Internal is present, and srcDir is outside parent's tree. Not allowed. + perr := &PackageError{ + alwaysPrintStack: true, + ImportStack: stk.Copy(), + Err: ImportErrorf(p.ImportPath, "use of internal package %s not allowed", p.ImportPath), + } + return perr +} + +// findInternal looks for the final "internal" path element in the given import path. +// If there isn't one, findInternal returns ok=false. +// Otherwise, findInternal returns ok=true and the index of the "internal". +func findInternal(path string) (index int, ok bool) { + // Three cases, depending on internal at start/end of string or not. + // The order matters: we must return the index of the final element, + // because the final one produces the most restrictive requirement + // on the importer. + switch { + case strings.HasSuffix(path, "/internal"): + return len(path) - len("internal"), true + case strings.Contains(path, "/internal/"): + return strings.LastIndex(path, "/internal/") + 1, true + case path == "internal", strings.HasPrefix(path, "internal/"): + return 0, true + } + return 0, false +} + +// disallowVendor checks that srcDir is allowed to import p as path. +// If the import is allowed, disallowVendor returns the original package p. +// If not, it returns a PackageError. +func disallowVendor(srcDir string, path string, importerPath string, p *Package, stk *ImportStack) *PackageError { + // If the importerPath is empty, we started + // with a name given on the command line, not an + // import. Anything listed on the command line is fine. + if importerPath == "" { + return nil + } + + if perr := disallowVendorVisibility(srcDir, p, importerPath, stk); perr != nil { + return perr + } + + // Paths like x/vendor/y must be imported as y, never as x/vendor/y. + if i, ok := FindVendor(path); ok { + perr := &PackageError{ + ImportStack: stk.Copy(), + Err: ImportErrorf(path, "%s must be imported as %s", path, path[i+len("vendor/"):]), + } + return perr + } + + return nil +} + +// disallowVendorVisibility checks that srcDir is allowed to import p. +// The rules are the same as for /internal/ except that a path ending in /vendor +// is not subject to the rules, only subdirectories of vendor. +// This allows people to have packages and commands named vendor, +// for maximal compatibility with existing source trees. +func disallowVendorVisibility(srcDir string, p *Package, importerPath string, stk *ImportStack) *PackageError { + // The stack does not include p.ImportPath. + // If there's nothing on the stack, we started + // with a name given on the command line, not an + // import. Anything listed on the command line is fine. + if importerPath == "" { + return nil + } + + // Check for "vendor" element. + i, ok := FindVendor(p.ImportPath) + if !ok { + return nil + } + + // Vendor is present. + // Map import path back to directory corresponding to parent of vendor. + if i > 0 { + i-- // rewind over slash in ".../vendor" + } + truncateTo := i + len(p.Dir) - len(p.ImportPath) + if truncateTo < 0 || len(p.Dir) < truncateTo { + return nil + } + parent := p.Dir[:truncateTo] + if str.HasFilePathPrefix(filepath.Clean(srcDir), filepath.Clean(parent)) { + return nil + } + + // Look for symlinks before reporting error. + srcDir = expandPath(srcDir) + parent = expandPath(parent) + if str.HasFilePathPrefix(filepath.Clean(srcDir), filepath.Clean(parent)) { + return nil + } + + // Vendor is present, and srcDir is outside parent's tree. Not allowed. + + perr := &PackageError{ + ImportStack: stk.Copy(), + Err: errors.New("use of vendored package not allowed"), + } + return perr +} + +// FindVendor looks for the last non-terminating "vendor" path element in the given import path. +// If there isn't one, FindVendor returns ok=false. +// Otherwise, FindVendor returns ok=true and the index of the "vendor". +// +// Note that terminating "vendor" elements don't count: "x/vendor" is its own package, +// not the vendored copy of an import "" (the empty import path). +// This will allow people to have packages or commands named vendor. +// This may help reduce breakage, or it may just be confusing. We'll see. +func FindVendor(path string) (index int, ok bool) { + // Two cases, depending on internal at start of string or not. + // The order matters: we must return the index of the final element, + // because the final one is where the effective import path starts. + switch { + case strings.Contains(path, "/vendor/"): + return strings.LastIndex(path, "/vendor/") + 1, true + case strings.HasPrefix(path, "vendor/"): + return 0, true + } + return 0, false +} + +type TargetDir int + +const ( + ToTool TargetDir = iota // to GOROOT/pkg/tool (default for cmd/*) + ToBin // to bin dir inside package root (default for non-cmd/*) + StalePath // an old import path; fail to build +) + +// InstallTargetDir reports the target directory for installing the command p. +func InstallTargetDir(p *Package) TargetDir { + if strings.HasPrefix(p.ImportPath, "code.google.com/p/go.tools/cmd/") { + return StalePath + } + if p.Goroot && strings.HasPrefix(p.ImportPath, "cmd/") && p.Name == "main" { + switch p.ImportPath { + case "cmd/go", "cmd/gofmt": + return ToBin + } + return ToTool + } + return ToBin +} + +var cgoExclude = map[string]bool{ + "runtime/cgo": true, +} + +var cgoSyscallExclude = map[string]bool{ + "runtime/cgo": true, + "runtime/race": true, + "runtime/msan": true, + "runtime/asan": true, +} + +var foldPath = make(map[string]string) + +// exeFromImportPath returns an executable name +// for a package using the import path. +// +// The executable name is the last element of the import path. +// In module-aware mode, an additional rule is used on import paths +// consisting of two or more path elements. If the last element is +// a vN path element specifying the major version, then the +// second last element of the import path is used instead. +func (p *Package) exeFromImportPath() string { + _, elem := pathpkg.Split(p.ImportPath) + if cfg.ModulesEnabled { + // If this is example.com/mycmd/v2, it's more useful to + // install it as mycmd than as v2. See golang.org/issue/24667. + if elem != p.ImportPath && isVersionElement(elem) { + _, elem = pathpkg.Split(pathpkg.Dir(p.ImportPath)) + } + } + return elem +} + +// exeFromFiles returns an executable name for a package +// using the first element in GoFiles or CgoFiles collections without the prefix. +// +// Returns empty string in case of empty collection. +func (p *Package) exeFromFiles() string { + var src string + if len(p.GoFiles) > 0 { + src = p.GoFiles[0] + } else if len(p.CgoFiles) > 0 { + src = p.CgoFiles[0] + } else { + return "" + } + _, elem := filepath.Split(src) + return elem[:len(elem)-len(".go")] +} + +// DefaultExecName returns the default executable name for a package +func (p *Package) DefaultExecName() string { + if p.Internal.CmdlineFiles { + return p.exeFromFiles() + } + return p.exeFromImportPath() +} + +// load populates p using information from bp, err, which should +// be the result of calling build.Context.Import. +// stk contains the import stack, not including path itself. +func (p *Package) load(loaderstate *modload.State, ctx context.Context, opts PackageOpts, path string, stk *ImportStack, importPos []token.Position, bp *build.Package, err error) { + p.copyBuild(opts, bp) + + // The localPrefix is the path we interpret ./ imports relative to, + // if we support them at all (not in module mode!). + // Synthesized main packages sometimes override this. + if p.Internal.Local && !cfg.ModulesEnabled { + p.Internal.LocalPrefix = dirToImportPath(p.Dir) + } + + // setError sets p.Error if it hasn't already been set. We may proceed + // after encountering some errors so that 'go list -e' has more complete + // output. If there's more than one error, we should report the first. + setError := func(err error) { + if p.Error == nil { + p.Error = &PackageError{ + ImportStack: stk.Copy(), + Err: err, + } + p.Incomplete = true + + // Add the importer's position information if the import position exists, and + // the current package being examined is the importer. + // If we have not yet accepted package p onto the import stack, + // then the cause of the error is not within p itself: the error + // must be either in an explicit command-line argument, + // or on the importer side (indicated by a non-empty importPos). + top, ok := stk.Top() + if ok && path != top.Pkg && len(importPos) > 0 { + p.Error.setPos(importPos) + } + } + } + + if err != nil { + p.Incomplete = true + p.setLoadPackageDataError(err, path, stk, importPos) + } + + useBindir := p.Name == "main" + if !p.Standard { + switch cfg.BuildBuildmode { + case "c-archive", "c-shared", "plugin": + useBindir = false + } + } + + if useBindir { + // Report an error when the old code.google.com/p/go.tools paths are used. + if InstallTargetDir(p) == StalePath { + // TODO(matloob): remove this branch, and StalePath itself. code.google.com/p/go is so + // old, even this code checking for it is stale now! + newPath := strings.Replace(p.ImportPath, "code.google.com/p/go.", "golang.org/x/", 1) + e := ImportErrorf(p.ImportPath, "the %v command has moved; use %v instead.", p.ImportPath, newPath) + setError(e) + return + } + elem := p.DefaultExecName() + cfg.ExeSuffix + full := filepath.Join(cfg.BuildContext.GOOS+"_"+cfg.BuildContext.GOARCH, elem) + if cfg.BuildContext.GOOS != runtime.GOOS || cfg.BuildContext.GOARCH != runtime.GOARCH { + // Install cross-compiled binaries to subdirectories of bin. + elem = full + } + if p.Internal.Build.BinDir == "" && cfg.ModulesEnabled { + p.Internal.Build.BinDir = modload.BinDir(loaderstate) + } + if p.Internal.Build.BinDir != "" { + // Install to GOBIN or bin of GOPATH entry. + p.Target = filepath.Join(p.Internal.Build.BinDir, elem) + if !p.Goroot && strings.Contains(elem, string(filepath.Separator)) && cfg.GOBIN != "" { + // Do not create $GOBIN/goos_goarch/elem. + p.Target = "" + p.Internal.GobinSubdir = true + } + } + if InstallTargetDir(p) == ToTool { + // This is for 'go tool'. + // Override all the usual logic and force it into the tool directory. + if cfg.BuildToolchainName == "gccgo" { + p.Target = filepath.Join(build.ToolDir, elem) + } else { + p.Target = filepath.Join(cfg.GOROOTpkg, "tool", full) + } + } + } else if p.Internal.Local { + // Local import turned into absolute path. + // No permanent install target. + p.Target = "" + } else if p.Standard && cfg.BuildContext.Compiler == "gccgo" { + // gccgo has a preinstalled standard library that cmd/go cannot rebuild. + p.Target = "" + } else { + p.Target = p.Internal.Build.PkgObj + if cfg.BuildBuildmode == "shared" && p.Internal.Build.PkgTargetRoot != "" { + // TODO(matloob): This shouldn't be necessary, but the cmd/cgo/internal/testshared + // test fails without Target set for this condition. Figure out why and + // fix it. + p.Target = filepath.Join(p.Internal.Build.PkgTargetRoot, p.ImportPath+".a") + } + if cfg.BuildLinkshared && p.Internal.Build.PkgTargetRoot != "" { + // TODO(bcmills): The reliance on PkgTargetRoot implies that -linkshared does + // not work for any package that lacks a PkgTargetRoot — such as a non-main + // package in module mode. We should probably fix that. + targetPrefix := filepath.Join(p.Internal.Build.PkgTargetRoot, p.ImportPath) + p.Target = targetPrefix + ".a" + shlibnamefile := targetPrefix + ".shlibname" + shlib, err := os.ReadFile(shlibnamefile) + if err != nil && !os.IsNotExist(err) { + base.Fatalf("reading shlibname: %v", err) + } + if err == nil { + libname := strings.TrimSpace(string(shlib)) + if cfg.BuildContext.Compiler == "gccgo" { + p.Shlib = filepath.Join(p.Internal.Build.PkgTargetRoot, "shlibs", libname) + } else { + p.Shlib = filepath.Join(p.Internal.Build.PkgTargetRoot, libname) + } + } + } + } + + // Build augmented import list to add implicit dependencies. + // Be careful not to add imports twice, just to avoid confusion. + importPaths := p.Imports + addImport := func(path string, forCompiler bool) { + for _, p := range importPaths { + if path == p { + return + } + } + importPaths = append(importPaths, path) + if forCompiler { + p.Internal.CompiledImports = append(p.Internal.CompiledImports, path) + } + } + + if !opts.IgnoreImports { + // Cgo translation adds imports of "unsafe", "runtime/cgo" and "syscall", + // except for certain packages, to avoid circular dependencies. + if p.UsesCgo() { + addImport("unsafe", true) + } + if p.UsesCgo() && (!p.Standard || !cgoExclude[p.ImportPath]) && cfg.BuildContext.Compiler != "gccgo" { + addImport("runtime/cgo", true) + } + if p.UsesCgo() && (!p.Standard || !cgoSyscallExclude[p.ImportPath]) { + addImport("syscall", true) + } + + // SWIG adds imports of some standard packages. + if p.UsesSwig() { + addImport("unsafe", true) + if cfg.BuildContext.Compiler != "gccgo" { + addImport("runtime/cgo", true) + } + addImport("syscall", true) + addImport("sync", true) + + // TODO: The .swig and .swigcxx files can use + // %go_import directives to import other packages. + } + + // The linker loads implicit dependencies. + if p.Name == "main" && !p.Internal.ForceLibrary { + ldDeps, err := LinkerDeps(loaderstate, p) + if err != nil { + setError(err) + return + } + for _, dep := range ldDeps { + addImport(dep, false) + } + } + } + + // Check for case-insensitive collisions of import paths. + // If modifying, consider changing checkPathCollisions() in + // src/cmd/go/internal/modcmd/vendor.go + fold := str.ToFold(p.ImportPath) + if other := foldPath[fold]; other == "" { + foldPath[fold] = p.ImportPath + } else if other != p.ImportPath { + setError(ImportErrorf(p.ImportPath, "case-insensitive import collision: %q and %q", p.ImportPath, other)) + return + } + + if !SafeArg(p.ImportPath) { + setError(ImportErrorf(p.ImportPath, "invalid import path %q", p.ImportPath)) + return + } + + // Errors after this point are caused by this package, not the importing + // package. Pushing the path here prevents us from reporting the error + // with the position of the import declaration. + stk.Push(ImportInfo{Pkg: path, Pos: extractFirstImport(importPos)}) + defer stk.Pop() + + pkgPath := p.ImportPath + if p.Internal.CmdlineFiles { + pkgPath = "command-line-arguments" + } + if cfg.ModulesEnabled { + p.Module = modload.PackageModuleInfo(loaderstate, ctx, pkgPath) + } + p.DefaultGODEBUG = defaultGODEBUG(loaderstate, p, nil, nil, nil) + + if !opts.SuppressEmbedFiles { + p.EmbedFiles, p.Internal.Embed, err = resolveEmbed(p.Dir, p.EmbedPatterns) + if err != nil { + p.Incomplete = true + setError(err) + embedErr := err.(*EmbedError) + p.Error.setPos(p.Internal.Build.EmbedPatternPos[embedErr.Pattern]) + } + } + + // Check for case-insensitive collision of input files. + // To avoid problems on case-insensitive files, we reject any package + // where two different input files have equal names under a case-insensitive + // comparison. + inputs := p.AllFiles() + f1, f2 := str.FoldDup(inputs) + if f1 != "" { + setError(fmt.Errorf("case-insensitive file name collision: %q and %q", f1, f2)) + return + } + + // If first letter of input file is ASCII, it must be alphanumeric. + // This avoids files turning into flags when invoking commands, + // and other problems we haven't thought of yet. + // Also, _cgo_ files must be generated by us, not supplied. + // They are allowed to have //go:cgo_ldflag directives. + // The directory scan ignores files beginning with _, + // so we shouldn't see any _cgo_ files anyway, but just be safe. + for _, file := range inputs { + if !SafeArg(file) || strings.HasPrefix(file, "_cgo_") { + setError(fmt.Errorf("invalid input file name %q", file)) + return + } + } + if name := pathpkg.Base(p.ImportPath); !SafeArg(name) { + setError(fmt.Errorf("invalid input directory name %q", name)) + return + } + if strings.ContainsAny(p.Dir, "\r\n") { + setError(fmt.Errorf("invalid package directory %q", p.Dir)) + return + } + + // Build list of imported packages and full dependency list. + imports := make([]*Package, 0, len(p.Imports)) + for i, path := range importPaths { + if path == "C" { + continue + } + p1, err := loadImport(loaderstate, ctx, opts, nil, path, p.Dir, p, stk, p.Internal.Build.ImportPos[path], ResolveImport) + if err != nil && p.Error == nil { + p.Error = err + p.Incomplete = true + } + + path = p1.ImportPath + importPaths[i] = path + if i < len(p.Imports) { + p.Imports[i] = path + } + + imports = append(imports, p1) + if p1.Incomplete { + p.Incomplete = true + } + } + p.Internal.Imports = imports + if p.Error == nil && p.Name == "main" && !p.Internal.ForceLibrary && !p.Incomplete && !opts.SuppressBuildInfo { + // TODO(bcmills): loading VCS metadata can be fairly slow. + // Consider starting this as a background goroutine and retrieving the result + // asynchronously when we're actually ready to build the package, or when we + // actually need to evaluate whether the package's metadata is stale. + p.setBuildInfo(ctx, loaderstate.Fetcher(), opts.AutoVCS) + } + + // If cgo is not enabled, ignore cgo supporting sources + // just as we ignore go files containing import "C". + if !cfg.BuildContext.CgoEnabled { + p.CFiles = nil + p.CXXFiles = nil + p.MFiles = nil + p.SwigFiles = nil + p.SwigCXXFiles = nil + // Note that SFiles are okay (they go to the Go assembler) + // and HFiles are okay (they might be used by the SFiles). + // Also Sysofiles are okay (they might not contain object + // code; see issue #16050). + } + + // The gc toolchain only permits C source files with cgo or SWIG. + if len(p.CFiles) > 0 && !p.UsesCgo() && !p.UsesSwig() && cfg.BuildContext.Compiler == "gc" { + setError(fmt.Errorf("C source files not allowed when not using cgo or SWIG: %s", strings.Join(p.CFiles, " "))) + return + } + + // C++, Objective-C, and Fortran source files are permitted only with cgo or SWIG, + // regardless of toolchain. + if len(p.CXXFiles) > 0 && !p.UsesCgo() && !p.UsesSwig() { + setError(fmt.Errorf("C++ source files not allowed when not using cgo or SWIG: %s", strings.Join(p.CXXFiles, " "))) + return + } + if len(p.MFiles) > 0 && !p.UsesCgo() && !p.UsesSwig() { + setError(fmt.Errorf("Objective-C source files not allowed when not using cgo or SWIG: %s", strings.Join(p.MFiles, " "))) + return + } + if len(p.FFiles) > 0 && !p.UsesCgo() && !p.UsesSwig() { + setError(fmt.Errorf("Fortran source files not allowed when not using cgo or SWIG: %s", strings.Join(p.FFiles, " "))) + return + } +} + +// An EmbedError indicates a problem with a go:embed directive. +type EmbedError struct { + Pattern string + Err error +} + +func (e *EmbedError) Error() string { + return fmt.Sprintf("pattern %s: %v", e.Pattern, e.Err) +} + +func (e *EmbedError) Unwrap() error { + return e.Err +} + +// ResolveEmbed resolves //go:embed patterns and returns only the file list. +// For use by go mod vendor to find embedded files it should copy into the +// vendor directory. +// TODO(#42504): Once go mod vendor uses load.PackagesAndErrors, just +// call (*Package).ResolveEmbed +func ResolveEmbed(dir string, patterns []string) ([]string, error) { + files, _, err := resolveEmbed(dir, patterns) + return files, err +} + +var embedfollowsymlinks = godebug.New("embedfollowsymlinks") + +// resolveEmbed resolves //go:embed patterns to precise file lists. +// It sets files to the list of unique files matched (for go list), +// and it sets pmap to the more precise mapping from +// patterns to files. +func resolveEmbed(pkgdir string, patterns []string) (files []string, pmap map[string][]string, err error) { + var pattern string + defer func() { + if err != nil { + err = &EmbedError{ + Pattern: pattern, + Err: err, + } + } + }() + + // TODO(rsc): All these messages need position information for better error reports. + pmap = make(map[string][]string) + have := make(map[string]int) + dirOK := make(map[string]bool) + pid := 0 // pattern ID, to allow reuse of have map + for _, pattern = range patterns { + pid++ + + glob, all := strings.CutPrefix(pattern, "all:") + // Check pattern is valid for //go:embed. + if _, err := pathpkg.Match(glob, ""); err != nil || !validEmbedPattern(glob) { + return nil, nil, fmt.Errorf("invalid pattern syntax") + } + + // Glob to find matches. + match, err := fsys.Glob(str.QuoteGlob(str.WithFilePathSeparator(pkgdir)) + filepath.FromSlash(glob)) + if err != nil { + return nil, nil, err + } + + // Filter list of matches down to the ones that will still exist when + // the directory is packaged up as a module. (If p.Dir is in the module cache, + // only those files exist already, but if p.Dir is in the current module, + // then there may be other things lying around, like symbolic links or .git directories.) + var list []string + for _, file := range match { + // relative path to p.Dir which begins without prefix slash + rel := filepath.ToSlash(str.TrimFilePathPrefix(file, pkgdir)) + + what := "file" + info, err := fsys.Lstat(file) + if err != nil { + return nil, nil, err + } + if info.IsDir() { + what = "directory" + } + + // Check that directories along path do not begin a new module + // (do not contain a go.mod). + for dir := file; len(dir) > len(pkgdir)+1 && !dirOK[dir]; dir = filepath.Dir(dir) { + if _, err := fsys.Stat(filepath.Join(dir, "go.mod")); err == nil { + return nil, nil, fmt.Errorf("cannot embed %s %s: in different module", what, rel) + } + if dir != file { + if info, err := fsys.Lstat(dir); err == nil && !info.IsDir() { + return nil, nil, fmt.Errorf("cannot embed %s %s: in non-directory %s", what, rel, dir[len(pkgdir)+1:]) + } + } + dirOK[dir] = true + if elem := filepath.Base(dir); isBadEmbedName(elem) { + if dir == file { + return nil, nil, fmt.Errorf("cannot embed %s %s: invalid name %s", what, rel, elem) + } else { + return nil, nil, fmt.Errorf("cannot embed %s %s: in invalid directory %s", what, rel, elem) + } + } + } + + switch { + default: + return nil, nil, fmt.Errorf("cannot embed irregular file %s", rel) + + case info.Mode().IsRegular(): + if have[rel] != pid { + have[rel] = pid + list = append(list, rel) + } + + // If the embedfollowsymlinks GODEBUG is set to 1, allow the leaf file to be a + // symlink (#59924). We don't allow directories to be symlinks and have already + // checked that none of the parent directories of the file are symlinks in the + // loop above. The file pointed to by the symlink must be a regular file. + case embedfollowsymlinks.Value() == "1" && info.Mode()&fs.ModeType == fs.ModeSymlink: + info, err := fsys.Stat(file) + if err != nil { + return nil, nil, err + } + if !info.Mode().IsRegular() { + return nil, nil, fmt.Errorf("cannot embed irregular file %s", rel) + } + if have[rel] != pid { + embedfollowsymlinks.IncNonDefault() + have[rel] = pid + list = append(list, rel) + } + + case info.IsDir(): + // Gather all files in the named directory, stopping at module boundaries + // and ignoring files that wouldn't be packaged into a module. + count := 0 + err := fsys.WalkDir(file, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + rel := filepath.ToSlash(str.TrimFilePathPrefix(path, pkgdir)) + name := d.Name() + if path != file && (isBadEmbedName(name) || ((name[0] == '.' || name[0] == '_') && !all)) { + // Avoid hidden files that user may not know about. + // See golang.org/issue/42328. + if d.IsDir() { + return fs.SkipDir + } + // Ignore hidden files. + if name[0] == '.' || name[0] == '_' { + return nil + } + // Error on bad embed names. + // See golang.org/issue/54003. + if isBadEmbedName(name) { + return fmt.Errorf("cannot embed file %s: invalid name %s", rel, name) + } + return nil + } + if d.IsDir() { + if _, err := fsys.Stat(filepath.Join(path, "go.mod")); err == nil { + return filepath.SkipDir + } + return nil + } + if !d.Type().IsRegular() { + return nil + } + count++ + if have[rel] != pid { + have[rel] = pid + list = append(list, rel) + } + return nil + }) + if err != nil { + return nil, nil, err + } + if count == 0 { + return nil, nil, fmt.Errorf("cannot embed directory %s: contains no embeddable files", rel) + } + } + } + + if len(list) == 0 { + return nil, nil, fmt.Errorf("no matching files found") + } + sort.Strings(list) + pmap[pattern] = list + } + + for file := range have { + files = append(files, file) + } + sort.Strings(files) + return files, pmap, nil +} + +func validEmbedPattern(pattern string) bool { + return pattern != "." && fs.ValidPath(pattern) +} + +// isBadEmbedName reports whether name is the base name of a file that +// can't or won't be included in modules and therefore shouldn't be treated +// as existing for embedding. +func isBadEmbedName(name string) bool { + if err := module.CheckFilePath(name); err != nil { + return true + } + switch name { + // Empty string should be impossible but make it bad. + case "": + return true + // Version control directories won't be present in module. + case ".bzr", ".hg", ".git", ".svn": + return true + } + return false +} + +// vcsStatusCache maps repository directories (string) +// to their VCS information. +var vcsStatusCache par.ErrCache[string, vcs.Status] + +func appendBuildSetting(info *debug.BuildInfo, key, value string) { + value = strings.ReplaceAll(value, "\n", " ") // make value safe + info.Settings = append(info.Settings, debug.BuildSetting{Key: key, Value: value}) +} + +// setBuildInfo gathers build information and sets it into +// p.Internal.BuildInfo, which will later be formatted as a string and embedded +// in the binary. setBuildInfo should only be called on a main package with no +// errors. +// +// This information can be retrieved using debug.ReadBuildInfo. +// +// Note that the GoVersion field is not set here to avoid encoding it twice. +// It is stored separately in the binary, mostly for historical reasons. +func (p *Package) setBuildInfo(ctx context.Context, f *modfetch.Fetcher, autoVCS bool) { + setPkgErrorf := func(format string, args ...any) { + if p.Error == nil { + p.Error = &PackageError{Err: fmt.Errorf(format, args...)} + p.Incomplete = true + } + } + + var debugModFromModinfo func(*modinfo.ModulePublic) *debug.Module + debugModFromModinfo = func(mi *modinfo.ModulePublic) *debug.Module { + version := mi.Version + if version == "" { + version = "(devel)" + } + dm := &debug.Module{ + Path: mi.Path, + Version: version, + } + if mi.Replace != nil { + dm.Replace = debugModFromModinfo(mi.Replace) + } else if mi.Version != "" && cfg.BuildMod != "vendor" { + dm.Sum = modfetch.Sum(ctx, module.Version{Path: mi.Path, Version: mi.Version}) + } + return dm + } + + var main debug.Module + if p.Module != nil { + main = *debugModFromModinfo(p.Module) + } + + visited := make(map[*Package]bool) + mdeps := make(map[module.Version]*debug.Module) + var q []*Package + q = append(q, p.Internal.Imports...) + for len(q) > 0 { + p1 := q[0] + q = q[1:] + if visited[p1] { + continue + } + visited[p1] = true + if p1.Module != nil { + m := module.Version{Path: p1.Module.Path, Version: p1.Module.Version} + if p1.Module.Path != main.Path && mdeps[m] == nil { + mdeps[m] = debugModFromModinfo(p1.Module) + } + } + q = append(q, p1.Internal.Imports...) + } + sortedMods := make([]module.Version, 0, len(mdeps)) + for mod := range mdeps { + sortedMods = append(sortedMods, mod) + } + gover.ModSort(sortedMods) + deps := make([]*debug.Module, len(sortedMods)) + for i, mod := range sortedMods { + deps[i] = mdeps[mod] + } + + pkgPath := p.ImportPath + if p.Internal.CmdlineFiles { + pkgPath = "command-line-arguments" + } + info := &debug.BuildInfo{ + Path: pkgPath, + Main: main, + Deps: deps, + } + appendSetting := func(key, value string) { + appendBuildSetting(info, key, value) + } + + // Add command-line flags relevant to the build. + // This is informational, not an exhaustive list. + // Please keep the list sorted. + if cfg.BuildASan { + appendSetting("-asan", "true") + } + if BuildAsmflags.present { + appendSetting("-asmflags", BuildAsmflags.String()) + } + buildmode := cfg.BuildBuildmode + if buildmode == "default" { + if p.Name == "main" { + buildmode = "exe" + } else { + buildmode = "archive" + } + } + appendSetting("-buildmode", buildmode) + appendSetting("-compiler", cfg.BuildContext.Compiler) + if gccgoflags := BuildGccgoflags.String(); gccgoflags != "" && cfg.BuildContext.Compiler == "gccgo" { + appendSetting("-gccgoflags", gccgoflags) + } + if gcflags := BuildGcflags.String(); gcflags != "" && cfg.BuildContext.Compiler == "gc" { + appendSetting("-gcflags", gcflags) + } + if ldflags := BuildLdflags.String(); ldflags != "" { + // https://go.dev/issue/52372: only include ldflags if -trimpath is not set, + // since it can include system paths through various linker flags (notably + // -extar, -extld, and -extldflags). + // + // TODO: since we control cmd/link, in theory we can parse ldflags to + // determine whether they may refer to system paths. If we do that, we can + // redact only those paths from the recorded -ldflags setting and still + // record the system-independent parts of the flags. + if !cfg.BuildTrimpath { + appendSetting("-ldflags", ldflags) + } + } + if cfg.BuildCover { + appendSetting("-cover", "true") + } + if cfg.BuildMSan { + appendSetting("-msan", "true") + } + // N.B. -pgo added later by setPGOProfilePath. + if cfg.BuildRace { + appendSetting("-race", "true") + } + if tags := cfg.BuildContext.BuildTags; len(tags) > 0 { + appendSetting("-tags", strings.Join(tags, ",")) + } + if cfg.BuildTrimpath { + appendSetting("-trimpath", "true") + } + if p.DefaultGODEBUG != "" { + appendSetting("DefaultGODEBUG", p.DefaultGODEBUG) + } + cgo := "0" + if cfg.BuildContext.CgoEnabled { + cgo = "1" + } + appendSetting("CGO_ENABLED", cgo) + // https://go.dev/issue/52372: only include CGO flags if -trimpath is not set. + // (If -trimpath is set, it is possible that these flags include system paths.) + // If cgo is involved, reproducibility is already pretty well ruined anyway, + // given that we aren't stamping header or library versions. + // + // TODO(bcmills): perhaps we could at least parse the flags and stamp the + // subset of flags that are known not to be paths? + if cfg.BuildContext.CgoEnabled && !cfg.BuildTrimpath { + for _, name := range []string{"CGO_CFLAGS", "CGO_CPPFLAGS", "CGO_CXXFLAGS", "CGO_LDFLAGS"} { + appendSetting(name, cfg.Getenv(name)) + } + } + appendSetting("GOARCH", cfg.BuildContext.GOARCH) + if cfg.RawGOEXPERIMENT != "" { + appendSetting("GOEXPERIMENT", cfg.RawGOEXPERIMENT) + } + if fips140.Enabled() { + appendSetting("GOFIPS140", fips140.Version()) + } + appendSetting("GOOS", cfg.BuildContext.GOOS) + if key, val, _ := cfg.GetArchEnv(); key != "" && val != "" { + appendSetting(key, val) + } + + // Add VCS status if all conditions are true: + // + // - -buildvcs is enabled. + // - p is a non-test contained within a main module (there may be multiple + // main modules in a workspace, but local replacements don't count). + // - Both the current directory and p's module's root directory are contained + // in the same local repository. + // - We know the VCS commands needed to get the status. + setVCSError := func(err error) { + setPkgErrorf("error obtaining VCS status: %v\n\tUse -buildvcs=false to disable VCS stamping.", err) + } + + var repoDir string + var vcsCmd *vcs.Cmd + var err error + + wantVCS := false + switch cfg.BuildBuildvcs { + case "true": + wantVCS = true // Include VCS metadata even for tests if requested explicitly; see https://go.dev/issue/52648. + case "auto": + wantVCS = autoVCS && !p.IsTestOnly() + case "false": + default: + panic(fmt.Sprintf("unexpected value for cfg.BuildBuildvcs: %q", cfg.BuildBuildvcs)) + } + + if wantVCS && p.Module != nil && p.Module.Version == "" && !p.Standard { + if p.Module.Path == "bootstrap" && cfg.GOROOT == os.Getenv("GOROOT_BOOTSTRAP") { + // During bootstrapping, the bootstrap toolchain is built in module + // "bootstrap" (instead of "std"), with GOROOT set to GOROOT_BOOTSTRAP + // (so the bootstrap toolchain packages don't even appear to be in GOROOT). + goto omitVCS + } + repoDir, vcsCmd, err = vcs.FromDir(base.Cwd(), "") + if err != nil && !errors.Is(err, os.ErrNotExist) { + setVCSError(err) + return + } + if !str.HasFilePathPrefix(p.Module.Dir, repoDir) && + !str.HasFilePathPrefix(repoDir, p.Module.Dir) { + // The module containing the main package does not overlap with the + // repository containing the working directory. Don't include VCS info. + // If the repo contains the module or vice versa, but they are not + // the same directory, it's likely an error (see below). + goto omitVCS + } + if cfg.BuildBuildvcs == "auto" && vcsCmd != nil && vcsCmd.Cmd != "" { + if _, err := pathcache.LookPath(vcsCmd.Cmd); err != nil { + // We fould a repository, but the required VCS tool is not present. + // "-buildvcs=auto" means that we should silently drop the VCS metadata. + goto omitVCS + } + } + } + if repoDir != "" && vcsCmd.Status != nil { + // Check that the current directory, package, and module are in the same + // repository. vcs.FromDir disallows nested VCS and multiple VCS in the + // same repository, unless the GODEBUG allowmultiplevcs is set. The + // current directory may be outside p.Module.Dir when a workspace is + // used. + pkgRepoDir, _, err := vcs.FromDir(p.Dir, "") + if err != nil { + setVCSError(err) + return + } + if pkgRepoDir != repoDir { + if cfg.BuildBuildvcs != "auto" { + setVCSError(fmt.Errorf("main package is in repository %q but current directory is in repository %q", pkgRepoDir, repoDir)) + return + } + goto omitVCS + } + modRepoDir, _, err := vcs.FromDir(p.Module.Dir, "") + if err != nil { + setVCSError(err) + return + } + if modRepoDir != repoDir { + if cfg.BuildBuildvcs != "auto" { + setVCSError(fmt.Errorf("main module is in repository %q but current directory is in repository %q", modRepoDir, repoDir)) + return + } + goto omitVCS + } + + st, err := vcsStatusCache.Do(repoDir, func() (vcs.Status, error) { + return vcsCmd.Status(vcsCmd, repoDir) + }) + if err != nil { + setVCSError(err) + return + } + + appendSetting("vcs", vcsCmd.Cmd) + if st.Revision != "" { + appendSetting("vcs.revision", st.Revision) + } + if !st.CommitTime.IsZero() { + stamp := st.CommitTime.UTC().Format(time.RFC3339Nano) + appendSetting("vcs.time", stamp) + } + appendSetting("vcs.modified", strconv.FormatBool(st.Uncommitted)) + // Determine the correct version of this module at the current revision and update the build metadata accordingly. + rootModPath := goModPath(repoDir) + // If no root module is found, skip embedding VCS data since we cannot determine the module path of the root. + if rootModPath == "" { + goto omitVCS + } + codeRoot, _, ok := module.SplitPathVersion(rootModPath) + if !ok { + goto omitVCS + } + repo := f.LookupLocal(ctx, codeRoot, p.Module.Path, repoDir) + revInfo, err := repo.Stat(ctx, st.Revision) + if err != nil { + goto omitVCS + } + vers := revInfo.Version + if vers != "" { + if st.Uncommitted { + // SemVer build metadata is dot-separated https://semver.org/#spec-item-10 + if strings.HasSuffix(vers, "+incompatible") { + vers += ".dirty" + } else { + vers += "+dirty" + } + } + info.Main.Version = vers + } + } +omitVCS: + + p.Internal.BuildInfo = info +} + +// SafeArg reports whether arg is a "safe" command-line argument, +// meaning that when it appears in a command-line, it probably +// doesn't have some special meaning other than its own name. +// Obviously args beginning with - are not safe (they look like flags). +// Less obviously, args beginning with @ are not safe (they look like +// GNU binutils flagfile specifiers, sometimes called "response files"). +// To be conservative, we reject almost any arg beginning with non-alphanumeric ASCII. +// We accept leading . _ and / as likely in file system paths. +// There is a copy of this function in cmd/compile/internal/gc/noder.go. +func SafeArg(name string) bool { + if name == "" { + return false + } + c := name[0] + return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '.' || c == '_' || c == '/' || c >= utf8.RuneSelf +} + +// LinkerDeps returns the list of linker-induced dependencies for main package p. +func LinkerDeps(s *modload.State, p *Package) ([]string, error) { + // Everything links runtime. + deps := []string{"runtime"} + + // External linking mode forces an import of runtime/cgo. + if what := externalLinkingReason(s, p); what != "" && cfg.BuildContext.Compiler != "gccgo" { + if !cfg.BuildContext.CgoEnabled { + return nil, fmt.Errorf("%s requires external (cgo) linking, but cgo is not enabled", what) + } + deps = append(deps, "runtime/cgo") + } + // On ARM with GOARM=5, it forces an import of math, for soft floating point. + if cfg.Goarch == "arm" { + deps = append(deps, "math") + } + // Using the race detector forces an import of runtime/race. + if cfg.BuildRace { + deps = append(deps, "runtime/race") + } + // Using memory sanitizer forces an import of runtime/msan. + if cfg.BuildMSan { + deps = append(deps, "runtime/msan") + } + // Using address sanitizer forces an import of runtime/asan. + if cfg.BuildASan { + deps = append(deps, "runtime/asan") + } + // Building for coverage forces an import of runtime/coverage. + if cfg.BuildCover { + deps = append(deps, "runtime/coverage") + } + + return deps, nil +} + +// externalLinkingReason reports the reason external linking is required +// even for programs that do not use cgo, or the empty string if external +// linking is not required. +func externalLinkingReason(s *modload.State, p *Package) (what string) { + // Some targets must use external linking even inside GOROOT. + if platform.MustLinkExternal(cfg.Goos, cfg.Goarch, false) { + return cfg.Goos + "/" + cfg.Goarch + } + + // Some build modes always require external linking. + switch cfg.BuildBuildmode { + case "c-shared": + if cfg.BuildContext.GOARCH == "wasm" { + break + } + fallthrough + case "plugin": + return "-buildmode=" + cfg.BuildBuildmode + } + + // Using -linkshared always requires external linking. + if cfg.BuildLinkshared { + return "-linkshared" + } + + // Decide whether we are building a PIE, + // bearing in mind that some systems default to PIE. + isPIE := false + if cfg.BuildBuildmode == "pie" { + isPIE = true + } else if cfg.BuildBuildmode == "default" && platform.DefaultPIE(cfg.BuildContext.GOOS, cfg.BuildContext.GOARCH, cfg.BuildRace) { + isPIE = true + } + // If we are building a PIE, and we are on a system + // that does not support PIE with internal linking mode, + // then we must use external linking. + if isPIE && !platform.InternalLinkPIESupported(cfg.BuildContext.GOOS, cfg.BuildContext.GOARCH) { + if cfg.BuildBuildmode == "pie" { + return "-buildmode=pie" + } + return "default PIE binary" + } + + // Using -ldflags=-linkmode=external forces external linking. + // If there are multiple -linkmode options, the last one wins. + if p != nil { + ldflags := BuildLdflags.For(s, p) + for i := len(ldflags) - 1; i >= 0; i-- { + a := ldflags[i] + if a == "-linkmode=external" || + a == "-linkmode" && i+1 < len(ldflags) && ldflags[i+1] == "external" { + return a + } else if a == "-linkmode=internal" || + a == "-linkmode" && i+1 < len(ldflags) && ldflags[i+1] == "internal" { + return "" + } + } + } + + return "" +} + +// mkAbs rewrites list, which must be paths relative to p.Dir, +// into a sorted list of absolute paths. It edits list in place but for +// convenience also returns list back to its caller. +func (p *Package) mkAbs(list []string) []string { + for i, f := range list { + list[i] = filepath.Join(p.Dir, f) + } + sort.Strings(list) + return list +} + +// InternalGoFiles returns the list of Go files being built for the package, +// using absolute paths. +func (p *Package) InternalGoFiles() []string { + return p.mkAbs(str.StringList(p.GoFiles, p.CgoFiles, p.TestGoFiles)) +} + +// InternalXGoFiles returns the list of Go files being built for the XTest package, +// using absolute paths. +func (p *Package) InternalXGoFiles() []string { + return p.mkAbs(p.XTestGoFiles) +} + +// InternalAllGoFiles returns the list of all Go files possibly relevant for the package, +// using absolute paths. "Possibly relevant" means that files are not excluded +// due to build tags, but files with names beginning with . or _ are still excluded. +func (p *Package) InternalAllGoFiles() []string { + return p.mkAbs(str.StringList(p.IgnoredGoFiles, p.GoFiles, p.CgoFiles, p.TestGoFiles, p.XTestGoFiles)) +} + +// UsesSwig reports whether the package needs to run SWIG. +func (p *Package) UsesSwig() bool { + return len(p.SwigFiles) > 0 || len(p.SwigCXXFiles) > 0 +} + +// UsesCgo reports whether the package needs to run cgo +func (p *Package) UsesCgo() bool { + return len(p.CgoFiles) > 0 +} + +// PackageList returns the list of packages in the dag rooted at roots +// as visited in a depth-first post-order traversal. +func PackageList(roots []*Package) []*Package { + seen := map[*Package]bool{} + all := []*Package{} + var walk func(*Package) + walk = func(p *Package) { + if seen[p] { + return + } + seen[p] = true + for _, p1 := range p.Internal.Imports { + walk(p1) + } + all = append(all, p) + } + for _, root := range roots { + walk(root) + } + return all +} + +// TestPackageList returns the list of packages in the dag rooted at roots +// as visited in a depth-first post-order traversal, including the test +// imports of the roots. This ignores errors in test packages. +func TestPackageList(loaderstate *modload.State, ctx context.Context, opts PackageOpts, roots []*Package) []*Package { + seen := map[*Package]bool{} + all := []*Package{} + var walk func(*Package) + walk = func(p *Package) { + if seen[p] { + return + } + seen[p] = true + for _, p1 := range p.Internal.Imports { + walk(p1) + } + all = append(all, p) + } + walkTest := func(root *Package, path string) { + var stk ImportStack + p1, err := loadImport(loaderstate, ctx, opts, nil, path, root.Dir, root, &stk, root.Internal.Build.TestImportPos[path], ResolveImport) + if err != nil && root.Error == nil { + // Assign error importing the package to the importer. + root.Error = err + root.Incomplete = true + } + if p1.Error == nil { + walk(p1) + } + } + for _, root := range roots { + walk(root) + for _, path := range root.TestImports { + walkTest(root, path) + } + for _, path := range root.XTestImports { + walkTest(root, path) + } + } + return all +} + +// LoadImportWithFlags loads the package with the given import path and +// sets tool flags on that package. This function is useful loading implicit +// dependencies (like sync/atomic for coverage). +// TODO(jayconrod): delete this function and set flags automatically +// in LoadImport instead. +func LoadImportWithFlags(loaderstate *modload.State, path, srcDir string, parent *Package, stk *ImportStack, importPos []token.Position, mode int) (*Package, *PackageError) { + p, err := loadImport(loaderstate, context.TODO(), PackageOpts{}, nil, path, srcDir, parent, stk, importPos, mode) + setToolFlags(loaderstate, p) + return p, err +} + +// LoadPackageWithFlags is the same as LoadImportWithFlags but without a parent. +// It's then guaranteed to not return an error +func LoadPackageWithFlags(loaderstate *modload.State, path, srcDir string, stk *ImportStack, importPos []token.Position, mode int) *Package { + p := LoadPackage(loaderstate, context.TODO(), PackageOpts{}, path, srcDir, stk, importPos, mode) + setToolFlags(loaderstate, p) + return p +} + +// PackageOpts control the behavior of PackagesAndErrors and other package +// loading functions. +type PackageOpts struct { + // IgnoreImports controls whether we ignore explicit and implicit imports + // when loading packages. Implicit imports are added when supporting Cgo + // or SWIG and when linking main packages. + IgnoreImports bool + + // ModResolveTests indicates whether calls to the module loader should also + // resolve test dependencies of the requested packages. + // + // If ModResolveTests is true, then the module loader needs to resolve test + // dependencies at the same time as packages; otherwise, the test dependencies + // of those packages could be missing, and resolving those missing dependencies + // could change the selected versions of modules that provide other packages. + ModResolveTests bool + + // MainOnly is true if the caller only wants to load main packages. + // For a literal argument matching a non-main package, a stub may be returned + // with an error. For a non-literal argument (with "..."), non-main packages + // are not be matched, and their dependencies may not be loaded. A warning + // may be printed for non-literal arguments that match no main packages. + MainOnly bool + + // AutoVCS controls whether we also load version-control metadata for main packages + // when -buildvcs=auto (the default). + AutoVCS bool + + // SuppressBuildInfo is true if the caller does not need p.Stale, p.StaleReason, or p.Internal.BuildInfo + // to be populated on the package. + SuppressBuildInfo bool + + // SuppressEmbedFiles is true if the caller does not need any embed files to be populated on the + // package. + SuppressEmbedFiles bool +} + +// PackagesAndErrors returns the packages named by the command line arguments +// 'patterns'. If a named package cannot be loaded, PackagesAndErrors returns +// a *Package with the Error field describing the failure. If errors are found +// loading imported packages, the DepsErrors field is set. The Incomplete field +// may be set as well. +// +// To obtain a flat list of packages, use PackageList. +// To report errors loading packages, use ReportPackageErrors. +func PackagesAndErrors(loaderstate *modload.State, ctx context.Context, opts PackageOpts, patterns []string) []*Package { + ctx, span := trace.StartSpan(ctx, "load.PackagesAndErrors") + defer span.Done() + + for _, p := range patterns { + // Listing is only supported with all patterns referring to either: + // - Files that are part of the same directory. + // - Explicit package paths or patterns. + if strings.HasSuffix(p, ".go") { + // We need to test whether the path is an actual Go file and not a + // package path or pattern ending in '.go' (see golang.org/issue/34653). + if fi, err := fsys.Stat(p); err == nil && !fi.IsDir() { + pkgs := []*Package{GoFilesPackage(loaderstate, ctx, opts, patterns)} + setPGOProfilePath(pkgs) + return pkgs + } + } + } + + var matches []*search.Match + if modload.Init(loaderstate); cfg.ModulesEnabled { + modOpts := modload.PackageOpts{ + ResolveMissingImports: true, + LoadTests: opts.ModResolveTests, + SilencePackageErrors: true, + } + matches, _ = modload.LoadPackages(loaderstate, ctx, modOpts, patterns...) + } else { + matches = search.ImportPaths(patterns) + } + + var ( + pkgs []*Package + stk ImportStack + seenPkg = make(map[*Package]bool) + ) + + pre := newPreload() + defer pre.flush() + pre.preloadMatches(loaderstate, ctx, opts, matches) + + for _, m := range matches { + for _, pkg := range m.Pkgs { + if pkg == "" { + panic(fmt.Sprintf("ImportPaths returned empty package for pattern %s", m.Pattern())) + } + mode := cmdlinePkg + if m.IsLiteral() { + // Note: do not set = m.IsLiteral unconditionally + // because maybe we'll see p matching both + // a literal and also a non-literal pattern. + mode |= cmdlinePkgLiteral + } + p, perr := loadImport(loaderstate, ctx, opts, pre, pkg, base.Cwd(), nil, &stk, nil, mode) + if perr != nil { + base.Fatalf("internal error: loadImport of %q with nil parent returned an error", pkg) + } + p.Match = append(p.Match, m.Pattern()) + if seenPkg[p] { + continue + } + seenPkg[p] = true + pkgs = append(pkgs, p) + } + + if len(m.Errs) > 0 { + // In addition to any packages that were actually resolved from the + // pattern, there was some error in resolving the pattern itself. + // Report it as a synthetic package. + p := new(Package) + p.ImportPath = m.Pattern() + // Pass an empty ImportStack and nil importPos: the error arose from a pattern, not an import. + var stk ImportStack + var importPos []token.Position + p.setLoadPackageDataError(m.Errs[0], m.Pattern(), &stk, importPos) + p.Incomplete = true + p.Match = append(p.Match, m.Pattern()) + p.Internal.CmdlinePkg = true + if m.IsLiteral() { + p.Internal.CmdlinePkgLiteral = true + } + pkgs = append(pkgs, p) + } + } + + if opts.MainOnly { + pkgs = mainPackagesOnly(pkgs, matches) + } + + // Now that CmdlinePkg is set correctly, + // compute the effective flags for all loaded packages + // (not just the ones matching the patterns but also + // their dependencies). + setToolFlags(loaderstate, pkgs...) + + setPGOProfilePath(pkgs) + + return pkgs +} + +// setPGOProfilePath sets the PGO profile path for pkgs. +// In -pgo=auto mode, it finds the default PGO profile. +func setPGOProfilePath(pkgs []*Package) { + updateBuildInfo := func(p *Package, file string) { + // Don't create BuildInfo for packages that didn't already have it. + if p.Internal.BuildInfo == nil { + return + } + + if cfg.BuildTrimpath { + appendBuildSetting(p.Internal.BuildInfo, "-pgo", filepath.Base(file)) + } else { + appendBuildSetting(p.Internal.BuildInfo, "-pgo", file) + } + // Adding -pgo breaks the sort order in BuildInfo.Settings. Restore it. + slices.SortFunc(p.Internal.BuildInfo.Settings, func(x, y debug.BuildSetting) int { + return strings.Compare(x.Key, y.Key) + }) + } + + switch cfg.BuildPGO { + case "off": + return + + case "auto": + // Locate PGO profiles from the main packages, and + // attach the profile to the main package and its + // dependencies. + // If we're building multiple main packages, they may + // have different profiles. We may need to split (unshare) + // the dependency graph so they can attach different + // profiles. + for _, p := range pkgs { + if p.Name != "main" { + continue + } + pmain := p + file := filepath.Join(pmain.Dir, "default.pgo") + if _, err := os.Stat(file); err != nil { + continue // no profile + } + + // Packages already visited. The value should replace + // the key, as it may be a forked copy of the original + // Package. + visited := make(map[*Package]*Package) + var split func(p *Package) *Package + split = func(p *Package) *Package { + if p1 := visited[p]; p1 != nil { + return p1 + } + + if len(pkgs) > 1 && p != pmain { + // Make a copy, then attach profile. + // No need to copy if there is only one root package (we can + // attach profile directly in-place). + // Also no need to copy the main package. + if p.Internal.PGOProfile != "" { + panic("setPGOProfilePath: already have profile") + } + p1 := new(Package) + *p1 = *p + // Unalias the Imports and Internal.Imports slices, + // which we're going to modify. We don't copy other slices as + // we don't change them. + p1.Imports = slices.Clone(p.Imports) + p1.Internal.Imports = slices.Clone(p.Internal.Imports) + p1.Internal.ForMain = pmain.ImportPath + visited[p] = p1 + p = p1 + } else { + visited[p] = p + } + p.Internal.PGOProfile = file + updateBuildInfo(p, file) + // Recurse to dependencies. + for i, pp := range p.Internal.Imports { + p.Internal.Imports[i] = split(pp) + } + return p + } + + // Replace the package and imports with the PGO version. + split(pmain) + } + + default: + // Profile specified from the command line. + // Make it absolute path, as the compiler runs on various directories. + file, err := filepath.Abs(cfg.BuildPGO) + if err != nil { + base.Fatalf("fail to get absolute path of PGO file %s: %v", cfg.BuildPGO, err) + } + + for _, p := range PackageList(pkgs) { + p.Internal.PGOProfile = file + updateBuildInfo(p, file) + } + } +} + +// CheckPackageErrors prints errors encountered loading pkgs and their +// dependencies, then exits with a non-zero status if any errors were found. +func CheckPackageErrors(pkgs []*Package) { + PackageErrors(pkgs, func(p *Package) { + DefaultPrinter().Errorf(p, "%v", p.Error) + }) + base.ExitIfErrors() +} + +// PackageErrors calls report for errors encountered loading pkgs and their dependencies. +func PackageErrors(pkgs []*Package, report func(*Package)) { + var anyIncomplete, anyErrors bool + for _, pkg := range pkgs { + if pkg.Incomplete { + anyIncomplete = true + } + } + if anyIncomplete { + all := PackageList(pkgs) + for _, p := range all { + if p.Error != nil { + report(p) + anyErrors = true + } + } + } + if anyErrors { + return + } + + // Check for duplicate loads of the same package. + // That should be impossible, but if it does happen then + // we end up trying to build the same package twice, + // usually in parallel overwriting the same files, + // which doesn't work very well. + seen := map[string]bool{} + reported := map[string]bool{} + for _, pkg := range PackageList(pkgs) { + // -pgo=auto with multiple main packages can cause a package being + // built multiple times (with different profiles). + // We check that package import path + profile path is unique. + key := pkg.ImportPath + if pkg.Internal.PGOProfile != "" { + key += " pgo:" + pkg.Internal.PGOProfile + } + if seen[key] && !reported[key] { + reported[key] = true + base.Errorf("internal error: duplicate loads of %s", pkg.ImportPath) + } + seen[key] = true + } + if len(reported) > 0 { + base.ExitIfErrors() + } +} + +// mainPackagesOnly filters out non-main packages matched only by arguments +// containing "..." and returns the remaining main packages. +// +// Packages with missing, invalid, or ambiguous names may be treated as +// possibly-main packages. +// +// mainPackagesOnly sets a non-main package's Error field and returns it if it +// is named by a literal argument. +// +// mainPackagesOnly prints warnings for non-literal arguments that only match +// non-main packages. +func mainPackagesOnly(pkgs []*Package, matches []*search.Match) []*Package { + treatAsMain := map[string]bool{} + for _, m := range matches { + if m.IsLiteral() { + for _, path := range m.Pkgs { + treatAsMain[path] = true + } + } + } + + var mains []*Package + for _, pkg := range pkgs { + if pkg.Name == "main" || (pkg.Name == "" && pkg.Error != nil) { + treatAsMain[pkg.ImportPath] = true + mains = append(mains, pkg) + continue + } + + if len(pkg.InvalidGoFiles) > 0 { // TODO(#45999): && pkg.Name == "", but currently go/build sets pkg.Name arbitrarily if it is ambiguous. + // The package has (or may have) conflicting names, and we can't easily + // tell whether one of them is "main". So assume that it could be, and + // report an error for the package. + treatAsMain[pkg.ImportPath] = true + } + if treatAsMain[pkg.ImportPath] { + if pkg.Error == nil { + pkg.Error = &PackageError{Err: &mainPackageError{importPath: pkg.ImportPath}} + pkg.Incomplete = true + } + mains = append(mains, pkg) + } + } + + for _, m := range matches { + if m.IsLiteral() || len(m.Pkgs) == 0 { + continue + } + foundMain := false + for _, path := range m.Pkgs { + if treatAsMain[path] { + foundMain = true + break + } + } + if !foundMain { + fmt.Fprintf(os.Stderr, "go: warning: %q matched only non-main packages\n", m.Pattern()) + } + } + + return mains +} + +type mainPackageError struct { + importPath string +} + +func (e *mainPackageError) Error() string { + return fmt.Sprintf("package %s is not a main package", e.importPath) +} + +func (e *mainPackageError) ImportPath() string { + return e.importPath +} + +func setToolFlags(loaderstate *modload.State, pkgs ...*Package) { + for _, p := range PackageList(pkgs) { + p.Internal.Asmflags = BuildAsmflags.For(loaderstate, p) + p.Internal.Gcflags = BuildGcflags.For(loaderstate, p) + p.Internal.Ldflags = BuildLdflags.For(loaderstate, p) + p.Internal.Gccgoflags = BuildGccgoflags.For(loaderstate, p) + } +} + +// GoFilesPackage creates a package for building a collection of Go files +// (typically named on the command line). The target is named p.a for +// package p or named after the first Go file for package main. +func GoFilesPackage(loaderstate *modload.State, ctx context.Context, opts PackageOpts, gofiles []string) *Package { + modload.Init(loaderstate) + + for _, f := range gofiles { + if !strings.HasSuffix(f, ".go") { + pkg := new(Package) + pkg.Internal.Local = true + pkg.Internal.CmdlineFiles = true + pkg.Name = f + pkg.Error = &PackageError{ + Err: fmt.Errorf("named files must be .go files: %s", pkg.Name), + } + pkg.Incomplete = true + return pkg + } + } + + var stk ImportStack + ctxt := cfg.BuildContext + ctxt.UseAllFiles = true + + // Synthesize fake "directory" that only shows the named files, + // to make it look like this is a standard package or + // command directory. So that local imports resolve + // consistently, the files must all be in the same directory. + var dirent []fs.FileInfo + var dir string + for _, file := range gofiles { + fi, err := fsys.Stat(file) + if err != nil { + base.Fatalf("%s", err) + } + if fi.IsDir() { + base.Fatalf("%s is a directory, should be a Go file", file) + } + dir1 := filepath.Dir(file) + if dir == "" { + dir = dir1 + } else if dir != dir1 { + base.Fatalf("named files must all be in one directory; have %s and %s", dir, dir1) + } + dirent = append(dirent, fi) + } + ctxt.ReadDir = func(string) ([]fs.FileInfo, error) { return dirent, nil } + + if cfg.ModulesEnabled { + modload.ImportFromFiles(loaderstate, ctx, gofiles) + } + + var err error + if dir == "" { + dir = base.Cwd() + } + dir, err = filepath.Abs(dir) + if err != nil { + base.Fatalf("%s", err) + } + + bp, err := ctxt.ImportDir(dir, 0) + pkg := new(Package) + pkg.Internal.Local = true + pkg.Internal.CmdlineFiles = true + pkg.load(loaderstate, ctx, opts, "command-line-arguments", &stk, nil, bp, err) + if !cfg.ModulesEnabled { + pkg.Internal.LocalPrefix = dirToImportPath(dir) + } + pkg.ImportPath = "command-line-arguments" + pkg.Target = "" + pkg.Match = gofiles + + if pkg.Name == "main" { + exe := pkg.DefaultExecName() + cfg.ExeSuffix + + if cfg.GOBIN != "" { + pkg.Target = filepath.Join(cfg.GOBIN, exe) + } else if cfg.ModulesEnabled { + pkg.Target = filepath.Join(modload.BinDir(loaderstate), exe) + } + } + + if opts.MainOnly && pkg.Name != "main" && pkg.Error == nil { + pkg.Error = &PackageError{Err: &mainPackageError{importPath: pkg.ImportPath}} + pkg.Incomplete = true + } + setToolFlags(loaderstate, pkg) + + return pkg +} + +// PackagesAndErrorsOutsideModule is like PackagesAndErrors but runs in +// module-aware mode and ignores the go.mod file in the current directory or any +// parent directory, if there is one. This is used in the implementation of 'go +// install pkg@version' and other commands that support similar forms. +// +// modload.ForceUseModules must be true, and modload.RootMode must be NoRoot +// before calling this function. +// +// PackagesAndErrorsOutsideModule imposes several constraints to avoid +// ambiguity. All arguments must have the same version suffix (not just a suffix +// that resolves to the same version). They must refer to packages in the same +// module, which must not be std or cmd. That module is not considered the main +// module, but its go.mod file (if it has one) must not contain directives that +// would cause it to be interpreted differently if it were the main module +// (replace, exclude). +func PackagesAndErrorsOutsideModule(loaderstate *modload.State, ctx context.Context, opts PackageOpts, args []string) ([]*Package, error) { + if !loaderstate.ForceUseModules { + panic("modload.ForceUseModules must be true") + } + if loaderstate.RootMode != modload.NoRoot { + panic("modload.RootMode must be NoRoot") + } + + // Check that the arguments satisfy syntactic constraints. + var version string + var firstPath string + for _, arg := range args { + if i := strings.Index(arg, "@"); i >= 0 { + firstPath, version = arg[:i], arg[i+1:] + if version == "" { + return nil, fmt.Errorf("%s: version must not be empty", arg) + } + break + } + } + patterns := make([]string, len(args)) + for i, arg := range args { + p, found := strings.CutSuffix(arg, "@"+version) + if !found { + return nil, fmt.Errorf("%s: all arguments must refer to packages in the same module at the same version (@%s)", arg, version) + } + switch { + case build.IsLocalImport(p): + return nil, fmt.Errorf("%s: argument must be a package path, not a relative path", arg) + case filepath.IsAbs(p): + return nil, fmt.Errorf("%s: argument must be a package path, not an absolute path", arg) + case search.IsMetaPackage(p): + return nil, fmt.Errorf("%s: argument must be a package path, not a meta-package", arg) + case pathpkg.Clean(p) != p: + return nil, fmt.Errorf("%s: argument must be a clean package path", arg) + case !strings.Contains(p, "...") && search.IsStandardImportPath(p) && modindex.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, p): + return nil, fmt.Errorf("%s: argument must not be a package in the standard library", arg) + default: + patterns[i] = p + } + } + patterns = search.CleanPatterns(patterns) + + // Query the module providing the first argument, load its go.mod file, and + // check that it doesn't contain directives that would cause it to be + // interpreted differently if it were the main module. + // + // If multiple modules match the first argument, accept the longest match + // (first result). It's possible this module won't provide packages named by + // later arguments, and other modules would. Let's not try to be too + // magical though. + allowed := loaderstate.CheckAllowed + if modload.IsRevisionQuery(firstPath, version) { + // Don't check for retractions if a specific revision is requested. + allowed = nil + } + noneSelected := func(path string) (version string) { return "none" } + qrs, err := modload.QueryPackages(loaderstate, ctx, patterns[0], version, noneSelected, allowed) + if err != nil { + return nil, fmt.Errorf("%s: %w", args[0], err) + } + rootMod := qrs[0].Mod + deprecation, err := modload.CheckDeprecation(loaderstate, ctx, rootMod) + if err != nil { + return nil, fmt.Errorf("%s: %w", args[0], err) + } + if deprecation != "" { + fmt.Fprintf(os.Stderr, "go: module %s is deprecated: %s\n", rootMod.Path, modload.ShortMessage(deprecation, "")) + } + data, err := loaderstate.Fetcher().GoMod(ctx, rootMod.Path, rootMod.Version) + if err != nil { + return nil, fmt.Errorf("%s: %w", args[0], err) + } + f, err := modfile.Parse("go.mod", data, nil) + if err != nil { + return nil, fmt.Errorf("%s (in %s): %w", args[0], rootMod, err) + } + directiveFmt := "%s (in %s):\n" + + "\tThe go.mod file for the module providing named packages contains one or\n" + + "\tmore %s directives. It must not contain directives that would cause\n" + + "\tit to be interpreted differently than if it were the main module." + if len(f.Replace) > 0 { + return nil, fmt.Errorf(directiveFmt, args[0], rootMod, "replace") + } + if len(f.Exclude) > 0 { + return nil, fmt.Errorf(directiveFmt, args[0], rootMod, "exclude") + } + + // Since we are in NoRoot mode, the build list initially contains only + // the dummy command-line-arguments module. Add a requirement on the + // module that provides the packages named on the command line. + if _, err := modload.EditBuildList(loaderstate, ctx, nil, []module.Version{rootMod}); err != nil { + return nil, fmt.Errorf("%s: %w", args[0], err) + } + + // Load packages for all arguments. + pkgs := PackagesAndErrors(loaderstate, ctx, opts, patterns) + + // Check that named packages are all provided by the same module. + for _, pkg := range pkgs { + var pkgErr error + if pkg.Module == nil { + // Packages in std, cmd, and their vendored dependencies + // don't have this field set. + pkgErr = fmt.Errorf("package %s not provided by module %s", pkg.ImportPath, rootMod) + } else if pkg.Module.Path != rootMod.Path || pkg.Module.Version != rootMod.Version { + pkgErr = fmt.Errorf("package %s provided by module %s@%s\n\tAll packages must be provided by the same module (%s).", pkg.ImportPath, pkg.Module.Path, pkg.Module.Version, rootMod) + } + if pkgErr != nil && pkg.Error == nil { + pkg.Error = &PackageError{Err: pkgErr} + pkg.Incomplete = true + } + } + + matchers := make([]func(string) bool, len(patterns)) + for i, p := range patterns { + if strings.Contains(p, "...") { + matchers[i] = pkgpattern.MatchPattern(p) + } + } + return pkgs, nil +} + +// EnsureImport ensures that package p imports the named package. +func EnsureImport(s *modload.State, p *Package, pkg string) { + for _, d := range p.Internal.Imports { + if d.Name == pkg { + return + } + } + + p1, err := LoadImportWithFlags(s, pkg, p.Dir, p, &ImportStack{}, nil, 0) + if err != nil { + base.Fatalf("load %s: %v", pkg, err) + } + if p1.Error != nil { + base.Fatalf("load %s: %v", pkg, p1.Error) + } + + p.Internal.Imports = append(p.Internal.Imports, p1) +} + +// PrepareForCoverageBuild is a helper invoked for "go install +// -cover", "go run -cover", and "go build -cover" (but not used by +// "go test -cover"). It walks through the packages being built (and +// dependencies) and marks them for coverage instrumentation when +// appropriate, and possibly adding additional deps where needed. +func PrepareForCoverageBuild(s *modload.State, pkgs []*Package) { + var match []func(*modload.State, *Package) bool + + matchMainModAndCommandLine := func(_ *modload.State, p *Package) bool { + // note that p.Standard implies p.Module == nil below. + return p.Internal.CmdlineFiles || p.Internal.CmdlinePkg || (p.Module != nil && p.Module.Main) + } + + if len(cfg.BuildCoverPkg) != 0 { + // If -coverpkg has been specified, then we instrument only + // the specific packages selected by the user-specified pattern(s). + match = make([]func(*modload.State, *Package) bool, len(cfg.BuildCoverPkg)) + for i := range cfg.BuildCoverPkg { + match[i] = MatchPackage(cfg.BuildCoverPkg[i], base.Cwd()) + } + } else { + // Without -coverpkg, instrument only packages in the main module + // (if any), as well as packages/files specifically named on the + // command line. + match = []func(*modload.State, *Package) bool{matchMainModAndCommandLine} + } + + // Visit the packages being built or installed, along with all of + // their dependencies, and mark them to be instrumented, taking + // into account the matchers we've set up in the sequence above. + SelectCoverPackages(s, PackageList(pkgs), match, "build") +} + +func SelectCoverPackages(s *modload.State, roots []*Package, match []func(*modload.State, *Package) bool, op string) []*Package { + var warntag string + var includeMain bool + switch op { + case "build": + warntag = "built" + includeMain = true + case "test": + warntag = "tested" + default: + panic("internal error, bad mode passed to SelectCoverPackages") + } + + covered := []*Package{} + matched := make([]bool, len(match)) + for _, p := range roots { + haveMatch := false + for i := range match { + if match[i](s, p) { + matched[i] = true + haveMatch = true + } + } + if !haveMatch { + continue + } + + // There is nothing to cover in package unsafe; it comes from + // the compiler. + if p.ImportPath == "unsafe" { + continue + } + + // A package which only has test files can't be imported as a + // dependency, and at the moment we don't try to instrument it + // for coverage. There isn't any technical reason why + // *_test.go files couldn't be instrumented, but it probably + // doesn't make much sense to lump together coverage metrics + // (ex: percent stmts covered) of *_test.go files with + // non-test Go code. + if len(p.GoFiles)+len(p.CgoFiles) == 0 { + continue + } + + // Silently ignore attempts to run coverage on sync/atomic + // and/or internal/runtime/atomic when using atomic coverage + // mode. Atomic coverage mode uses sync/atomic, so we can't + // also do coverage on it. + if cfg.BuildCoverMode == "atomic" && p.Standard && + (p.ImportPath == "sync/atomic" || p.ImportPath == "internal/runtime/atomic") { + continue + } + + // If using the race detector, silently ignore attempts to run + // coverage on the runtime packages. It will cause the race + // detector to be invoked before it has been initialized. Note + // the use of "regonly" instead of just ignoring the package + // completely-- we do this due to the requirements of the + // package ID numbering scheme. See the comment in + // $GOROOT/src/internal/coverage/pkid.go dealing with + // hard-coding of runtime package IDs. + cmode := cfg.BuildCoverMode + if cfg.BuildRace && p.Standard && objabi.LookupPkgSpecial(p.ImportPath).Runtime { + cmode = "regonly" + } + + // If -coverpkg is in effect and for some reason we don't want + // coverage data for the main package, make sure that we at + // least process it for registration hooks. + if includeMain && p.Name == "main" && !haveMatch { + haveMatch = true + cmode = "regonly" + } + + // Mark package for instrumentation. + p.Internal.Cover.Mode = cmode + covered = append(covered, p) + + // Force import of sync/atomic into package if atomic mode. + if cfg.BuildCoverMode == "atomic" { + EnsureImport(s, p, "sync/atomic") + } + } + + // Warn about -coverpkg arguments that are not actually used. + for i := range cfg.BuildCoverPkg { + if !matched[i] { + fmt.Fprintf(os.Stderr, "warning: no packages being %s depend on matches for pattern %s\n", warntag, cfg.BuildCoverPkg[i]) + } + } + + return covered +} diff --git a/go/src/cmd/go/internal/load/pkg_test.go b/go/src/cmd/go/internal/load/pkg_test.go new file mode 100644 index 0000000000000000000000000000000000000000..3bcddee30bcaef91d7ddeef0d1068986f575099a --- /dev/null +++ b/go/src/cmd/go/internal/load/pkg_test.go @@ -0,0 +1,82 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package load + +import ( + "cmd/go/internal/cfg" + "testing" +) + +func TestPkgDefaultExecName(t *testing.T) { + oldModulesEnabled := cfg.ModulesEnabled + defer func() { cfg.ModulesEnabled = oldModulesEnabled }() + for _, tt := range []struct { + in string + files []string + wantMod string + wantGopath string + }{ + {"example.com/mycmd", []string{}, "mycmd", "mycmd"}, + {"example.com/mycmd/v0", []string{}, "v0", "v0"}, + {"example.com/mycmd/v1", []string{}, "v1", "v1"}, + {"example.com/mycmd/v2", []string{}, "mycmd", "v2"}, // Semantic import versioning, use second last element in module mode. + {"example.com/mycmd/v3", []string{}, "mycmd", "v3"}, // Semantic import versioning, use second last element in module mode. + {"mycmd", []string{}, "mycmd", "mycmd"}, + {"mycmd/v0", []string{}, "v0", "v0"}, + {"mycmd/v1", []string{}, "v1", "v1"}, + {"mycmd/v2", []string{}, "mycmd", "v2"}, // Semantic import versioning, use second last element in module mode. + {"v0", []string{}, "v0", "v0"}, + {"v1", []string{}, "v1", "v1"}, + {"v2", []string{}, "v2", "v2"}, + {"command-line-arguments", []string{"output.go", "foo.go"}, "output", "output"}, + } { + { + cfg.ModulesEnabled = true + pkg := new(Package) + pkg.ImportPath = tt.in + pkg.GoFiles = tt.files + pkg.Internal.CmdlineFiles = len(tt.files) > 0 + gotMod := pkg.DefaultExecName() + if gotMod != tt.wantMod { + t.Errorf("pkg.DefaultExecName with ImportPath = %q in module mode = %v; want %v", tt.in, gotMod, tt.wantMod) + } + } + { + cfg.ModulesEnabled = false + pkg := new(Package) + pkg.ImportPath = tt.in + pkg.GoFiles = tt.files + pkg.Internal.CmdlineFiles = len(tt.files) > 0 + gotGopath := pkg.DefaultExecName() + if gotGopath != tt.wantGopath { + t.Errorf("pkg.DefaultExecName with ImportPath = %q in gopath mode = %v; want %v", tt.in, gotGopath, tt.wantGopath) + } + } + } +} + +func TestIsVersionElement(t *testing.T) { + t.Parallel() + for _, tt := range []struct { + in string + want bool + }{ + {"v0", false}, + {"v05", false}, + {"v1", false}, + {"v2", true}, + {"v3", true}, + {"v9", true}, + {"v10", true}, + {"v11", true}, + {"v", false}, + {"vx", false}, + } { + got := isVersionElement(tt.in) + if got != tt.want { + t.Errorf("isVersionElement(%q) = %v; want %v", tt.in, got, tt.want) + } + } +} diff --git a/go/src/cmd/go/internal/load/printer.go b/go/src/cmd/go/internal/load/printer.go new file mode 100644 index 0000000000000000000000000000000000000000..d698a78aa2d92be2948a7064fe37e0ed137d60df --- /dev/null +++ b/go/src/cmd/go/internal/load/printer.go @@ -0,0 +1,126 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package load + +import ( + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "encoding/json" + "fmt" + "io" + "os" + "strings" + "sync" +) + +// A Printer reports output about a Package. +type Printer interface { + // Printf reports output from building pkg. The arguments are of the form + // expected by [fmt.Printf]. + // + // pkg may be nil if this output is not associated with the build of a + // particular package. + // + // The caller is responsible for checking if printing output is appropriate, + // for example by checking cfg.BuildN or cfg.BuildV. + Printf(pkg *Package, format string, args ...any) + + // Errorf prints output in the form of `log.Errorf` and reports that + // building pkg failed. + // + // This ensures the output is terminated with a new line if there's any + // output, but does not do any other formatting. Callers should generally + // use a higher-level output abstraction, such as (*Shell).reportCmd. + // + // pkg may be nil if this output is not associated with the build of a + // particular package. + // + // This sets the process exit status to 1. + Errorf(pkg *Package, format string, args ...any) +} + +// DefaultPrinter returns the default Printer. +func DefaultPrinter() Printer { + return defaultPrinter() +} + +var defaultPrinter = sync.OnceValue(func() Printer { + if cfg.BuildJSON { + return NewJSONPrinter(os.Stdout) + } + return &TextPrinter{os.Stderr} +}) + +func ensureNewline(s string) string { + if s == "" { + return "" + } + if strings.HasSuffix(s, "\n") { + return s + } + return s + "\n" +} + +// A TextPrinter emits text format output to Writer. +type TextPrinter struct { + Writer io.Writer +} + +func (p *TextPrinter) Printf(_ *Package, format string, args ...any) { + fmt.Fprintf(p.Writer, format, args...) +} + +func (p *TextPrinter) Errorf(_ *Package, format string, args ...any) { + fmt.Fprint(p.Writer, ensureNewline(fmt.Sprintf(format, args...))) + base.SetExitStatus(1) +} + +// A JSONPrinter emits output about a build in JSON format. +type JSONPrinter struct { + enc *json.Encoder +} + +func NewJSONPrinter(w io.Writer) *JSONPrinter { + return &JSONPrinter{json.NewEncoder(w)} +} + +type jsonBuildEvent struct { + ImportPath string + Action string + Output string `json:",omitempty"` // Non-empty if Action == “build-output” +} + +func (p *JSONPrinter) Printf(pkg *Package, format string, args ...any) { + ev := &jsonBuildEvent{ + Action: "build-output", + Output: fmt.Sprintf(format, args...), + } + if ev.Output == "" { + // There's no point in emitting a completely empty output event. + return + } + if pkg != nil { + ev.ImportPath = pkg.Desc() + } + p.enc.Encode(ev) +} + +func (p *JSONPrinter) Errorf(pkg *Package, format string, args ...any) { + s := ensureNewline(fmt.Sprintf(format, args...)) + // For clarity, emit each line as a separate output event. + for len(s) > 0 { + i := strings.IndexByte(s, '\n') + p.Printf(pkg, "%s", s[:i+1]) + s = s[i+1:] + } + ev := &jsonBuildEvent{ + Action: "build-fail", + } + if pkg != nil { + ev.ImportPath = pkg.Desc() + } + p.enc.Encode(ev) + base.SetExitStatus(1) +} diff --git a/go/src/cmd/go/internal/load/search.go b/go/src/cmd/go/internal/load/search.go new file mode 100644 index 0000000000000000000000000000000000000000..749a00e8485f4d01816aef24d48a46374761b8f5 --- /dev/null +++ b/go/src/cmd/go/internal/load/search.go @@ -0,0 +1,70 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package load + +import ( + "path/filepath" + "strings" + + "cmd/go/internal/modload" + "cmd/go/internal/search" + "cmd/internal/pkgpattern" +) + +// MatchPackage(pattern, cwd)(p) reports whether package p matches pattern in the working directory cwd. +func MatchPackage(pattern, cwd string) func(*modload.State, *Package) bool { + switch { + case search.IsRelativePath(pattern): + // Split pattern into leading pattern-free directory path + // (including all . and .. elements) and the final pattern. + var dir string + i := strings.Index(pattern, "...") + if i < 0 { + dir, pattern = pattern, "" + } else { + j := strings.LastIndex(pattern[:i], "/") + dir, pattern = pattern[:j], pattern[j+1:] + } + dir = filepath.Join(cwd, dir) + if pattern == "" { + return func(_ *modload.State, p *Package) bool { return p.Dir == dir } + } + matchPath := pkgpattern.MatchPattern(pattern) + return func(_ *modload.State, p *Package) bool { + // Compute relative path to dir and see if it matches the pattern. + rel, err := filepath.Rel(dir, p.Dir) + if err != nil { + // Cannot make relative - e.g. different drive letters on Windows. + return false + } + rel = filepath.ToSlash(rel) + if rel == ".." || strings.HasPrefix(rel, "../") { + return false + } + return matchPath(rel) + } + case pattern == "all": + // This is slightly inaccurate: it matches every package, which isn't the same + // as matching the "all" package pattern. + // TODO(matloob): Should we make this more accurate? Does anyone depend on this behavior? + return func(_ *modload.State, p *Package) bool { return true } + case pattern == "std": + return func(_ *modload.State, p *Package) bool { return p.Standard } + case pattern == "cmd": + return func(_ *modload.State, p *Package) bool { return p.Standard && strings.HasPrefix(p.ImportPath, "cmd/") } + default: + return func(s *modload.State, p *Package) bool { + switch { + case pattern == "tool" && s.Enabled(): + return s.MainModules.Tools()[p.ImportPath] + case pattern == "work" && s.Enabled(): + return p.Module != nil && s.MainModules.Contains(p.Module.Path) + default: + matchPath := pkgpattern.MatchPattern(pattern) + return matchPath(p.ImportPath) + } + } + } +} diff --git a/go/src/cmd/go/internal/load/test.go b/go/src/cmd/go/internal/load/test.go new file mode 100644 index 0000000000000000000000000000000000000000..e5c074fa1930373779003804ccc63c20c383627f --- /dev/null +++ b/go/src/cmd/go/internal/load/test.go @@ -0,0 +1,862 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package load + +import ( + "bytes" + "context" + "errors" + "fmt" + "go/ast" + "go/build" + "go/doc" + "go/parser" + "go/token" + "internal/lazytemplate" + "maps" + "path/filepath" + "slices" + "sort" + "strings" + "unicode" + "unicode/utf8" + + "cmd/go/internal/fsys" + "cmd/go/internal/modload" + "cmd/go/internal/str" + "cmd/go/internal/trace" +) + +var TestMainDeps = []string{ + // Dependencies for testmain. + "os", + "reflect", + "testing", + "testing/internal/testdeps", +} + +type TestCover struct { + Mode string + Local bool + Pkgs []*Package + Paths []string +} + +// TestPackagesFor is like TestPackagesAndErrors but it returns +// the package containing an error if the test packages or +// their dependencies have errors. +// Only test packages without errors are returned. +func TestPackagesFor(loaderstate *modload.State, ctx context.Context, opts PackageOpts, p *Package, cover *TestCover) (pmain, ptest, pxtest, perr *Package) { + pmain, ptest, pxtest = TestPackagesAndErrors(loaderstate, ctx, nil, opts, p, cover) + for _, p1 := range []*Package{ptest, pxtest, pmain} { + if p1 == nil { + // pxtest may be nil + continue + } + if p1.Error != nil { + perr = p1 + break + } + if p1.Incomplete { + ps := PackageList([]*Package{p1}) + for _, p := range ps { + if p.Error != nil { + perr = p + break + } + } + break + } + } + if pmain.Error != nil || pmain.Incomplete { + pmain = nil + } + if ptest.Error != nil || ptest.Incomplete { + ptest = nil + } + if pxtest != nil && (pxtest.Error != nil || pxtest.Incomplete) { + pxtest = nil + } + return pmain, ptest, pxtest, perr +} + +// TestPackagesAndErrors returns three packages: +// - pmain, the package main corresponding to the test binary (running tests in ptest and pxtest). +// - ptest, the package p compiled with added "package p" test files. +// - pxtest, the result of compiling any "package p_test" (external) test files. +// +// If the package has no "package p_test" test files, pxtest will be nil. +// If the non-test compilation of package p can be reused +// (for example, if there are no "package p" test files and +// package p need not be instrumented for coverage or any other reason), +// then the returned ptest == p. +// +// If done is non-nil, TestPackagesAndErrors will finish filling out the returned +// package structs in a goroutine and call done once finished. The members of the +// returned packages should not be accessed until done is called. +// +// The caller is expected to have checked that len(p.TestGoFiles)+len(p.XTestGoFiles) > 0, +// or else there's no point in any of this. +func TestPackagesAndErrors(loaderstate *modload.State, ctx context.Context, done func(), opts PackageOpts, p *Package, cover *TestCover) (pmain, ptest, pxtest *Package) { + ctx, span := trace.StartSpan(ctx, "load.TestPackagesAndErrors") + defer span.Done() + + pre := newPreload() + defer pre.flush() + allImports := append([]string{}, p.TestImports...) + allImports = append(allImports, p.XTestImports...) + pre.preloadImports(loaderstate, ctx, opts, allImports, p.Internal.Build) + + var ptestErr, pxtestErr *PackageError + var imports, ximports []*Package + var stk ImportStack + var testEmbed, xtestEmbed map[string][]string + var incomplete bool + stk.Push(ImportInfo{Pkg: p.ImportPath + " (test)"}) + rawTestImports := str.StringList(p.TestImports) + for i, path := range p.TestImports { + p1, err := loadImport(loaderstate, ctx, opts, pre, path, p.Dir, p, &stk, p.Internal.Build.TestImportPos[path], ResolveImport) + if err != nil && ptestErr == nil { + ptestErr = err + incomplete = true + } + if p1.Incomplete { + incomplete = true + } + p.TestImports[i] = p1.ImportPath + imports = append(imports, p1) + } + var err error + p.TestEmbedFiles, testEmbed, err = resolveEmbed(p.Dir, p.TestEmbedPatterns) + if err != nil { + ptestErr = &PackageError{ + ImportStack: stk.Copy(), + Err: err, + } + incomplete = true + embedErr := err.(*EmbedError) + ptestErr.setPos(p.Internal.Build.TestEmbedPatternPos[embedErr.Pattern]) + } + stk.Pop() + + stk.Push(ImportInfo{Pkg: p.ImportPath + "_test"}) + pxtestNeedsPtest := false + var pxtestIncomplete bool + rawXTestImports := str.StringList(p.XTestImports) + for i, path := range p.XTestImports { + p1, err := loadImport(loaderstate, ctx, opts, pre, path, p.Dir, p, &stk, p.Internal.Build.XTestImportPos[path], ResolveImport) + if err != nil && pxtestErr == nil { + pxtestErr = err + } + if p1.Incomplete { + pxtestIncomplete = true + } + if p1.ImportPath == p.ImportPath { + pxtestNeedsPtest = true + } else { + ximports = append(ximports, p1) + } + p.XTestImports[i] = p1.ImportPath + } + p.XTestEmbedFiles, xtestEmbed, err = resolveEmbed(p.Dir, p.XTestEmbedPatterns) + if err != nil && pxtestErr == nil { + pxtestErr = &PackageError{ + ImportStack: stk.Copy(), + Err: err, + } + embedErr := err.(*EmbedError) + pxtestErr.setPos(p.Internal.Build.XTestEmbedPatternPos[embedErr.Pattern]) + } + pxtestIncomplete = pxtestIncomplete || pxtestErr != nil + stk.Pop() + + // Test package. + if len(p.TestGoFiles) > 0 || p.Name == "main" || cover != nil && cover.Local { + ptest = new(Package) + *ptest = *p + if ptest.Error == nil { + ptest.Error = ptestErr + } + ptest.Incomplete = ptest.Incomplete || incomplete + ptest.ForTest = p.ImportPath + ptest.GoFiles = nil + ptest.GoFiles = append(ptest.GoFiles, p.GoFiles...) + ptest.GoFiles = append(ptest.GoFiles, p.TestGoFiles...) + ptest.Target = "" + // Note: The preparation of the vet config requires that common + // indexes in ptest.Imports and ptest.Internal.RawImports + // all line up (but RawImports can be shorter than the others). + // That is, for 0 ≤ i < len(RawImports), + // RawImports[i] is the import string in the program text, and + // Imports[i] is the expanded import string (vendoring applied or relative path expanded away). + // Any implicitly added imports appear in Imports and Internal.Imports + // but not RawImports (because they were not in the source code). + // We insert TestImports, imports, and rawTestImports at the start of + // these lists to preserve the alignment. + // Note that p.Internal.Imports may not be aligned with p.Imports/p.Internal.RawImports, + // but we insert at the beginning there too just for consistency. + ptest.Imports = str.StringList(p.TestImports, p.Imports) + ptest.Internal.Imports = append(imports, p.Internal.Imports...) + ptest.Internal.RawImports = str.StringList(rawTestImports, p.Internal.RawImports) + ptest.Internal.ForceLibrary = true + ptest.Internal.BuildInfo = nil + ptest.Internal.Build = new(build.Package) + *ptest.Internal.Build = *p.Internal.Build + m := map[string][]token.Position{} + for k, v := range p.Internal.Build.ImportPos { + m[k] = append(m[k], v...) + } + for k, v := range p.Internal.Build.TestImportPos { + m[k] = append(m[k], v...) + } + ptest.Internal.Build.ImportPos = m + if testEmbed == nil && len(p.Internal.Embed) > 0 { + testEmbed = map[string][]string{} + } + maps.Copy(testEmbed, p.Internal.Embed) + ptest.Internal.Embed = testEmbed + ptest.EmbedFiles = str.StringList(p.EmbedFiles, p.TestEmbedFiles) + ptest.Internal.OrigImportPath = p.Internal.OrigImportPath + ptest.Internal.PGOProfile = p.Internal.PGOProfile + ptest.Internal.Build.Directives = append(slices.Clip(p.Internal.Build.Directives), p.Internal.Build.TestDirectives...) + } else { + ptest = p + } + + // External test package. + if len(p.XTestGoFiles) > 0 { + pxtest = &Package{ + PackagePublic: PackagePublic{ + Name: p.Name + "_test", + ImportPath: p.ImportPath + "_test", + Root: p.Root, + Dir: p.Dir, + Goroot: p.Goroot, + GoFiles: p.XTestGoFiles, + Imports: p.XTestImports, + ForTest: p.ImportPath, + Module: p.Module, + Error: pxtestErr, + Incomplete: pxtestIncomplete, + EmbedFiles: p.XTestEmbedFiles, + }, + Internal: PackageInternal{ + LocalPrefix: p.Internal.LocalPrefix, + Build: &build.Package{ + ImportPos: p.Internal.Build.XTestImportPos, + Directives: p.Internal.Build.XTestDirectives, + }, + Imports: ximports, + RawImports: rawXTestImports, + + Asmflags: p.Internal.Asmflags, + Gcflags: p.Internal.Gcflags, + Ldflags: p.Internal.Ldflags, + Gccgoflags: p.Internal.Gccgoflags, + Embed: xtestEmbed, + OrigImportPath: p.Internal.OrigImportPath, + PGOProfile: p.Internal.PGOProfile, + }, + } + if pxtestNeedsPtest { + pxtest.Internal.Imports = append(pxtest.Internal.Imports, ptest) + } + } + + // Arrange for testing.Testing to report true. + ldflags := append(p.Internal.Ldflags, "-X", "testing.testBinary=1") + gccgoflags := append(p.Internal.Gccgoflags, "-Wl,--defsym,testing.gccgoTestBinary=1") + + // Build main package. + pmain = &Package{ + PackagePublic: PackagePublic{ + Name: "main", + Dir: p.Dir, + GoFiles: []string{"_testmain.go"}, + ImportPath: p.ImportPath + ".test", + Root: p.Root, + Imports: str.StringList(TestMainDeps), + Module: p.Module, + }, + Internal: PackageInternal{ + Build: &build.Package{Name: "main"}, + BuildInfo: p.Internal.BuildInfo, + Asmflags: p.Internal.Asmflags, + Gcflags: p.Internal.Gcflags, + Ldflags: ldflags, + Gccgoflags: gccgoflags, + OrigImportPath: p.Internal.OrigImportPath, + PGOProfile: p.Internal.PGOProfile, + }, + } + + pb := p.Internal.Build + pmain.DefaultGODEBUG = defaultGODEBUG(loaderstate, pmain, pb.Directives, pb.TestDirectives, pb.XTestDirectives) + if pmain.Internal.BuildInfo == nil || pmain.DefaultGODEBUG != p.DefaultGODEBUG { + // Either we didn't generate build info for the package under test (because it wasn't package main), or + // the DefaultGODEBUG used to build the test main package is different from the DefaultGODEBUG + // used to build the package under test. If we didn't set build info for the package under test + // pmain won't have buildinfo set (since we copy it from the package under test). If the default GODEBUG + // used for the package under test is different from that of the test main, the BuildInfo assigned above from the package + // under test incorrect for the test main package. Either set or correct pmain's build info. + pmain.setBuildInfo(ctx, loaderstate.Fetcher(), opts.AutoVCS) + } + + // The generated main also imports testing, regexp, and os. + // Also the linker introduces implicit dependencies reported by LinkerDeps. + stk.Push(ImportInfo{Pkg: "testmain"}) + deps := TestMainDeps // cap==len, so safe for append + if cover != nil { + deps = append(deps, "internal/coverage/cfile") + } + ldDeps, err := LinkerDeps(loaderstate, p) + if err != nil && pmain.Error == nil { + pmain.Error = &PackageError{Err: err} + } + for _, d := range ldDeps { + deps = append(deps, d) + } + for _, dep := range deps { + if dep == ptest.ImportPath { + pmain.Internal.Imports = append(pmain.Internal.Imports, ptest) + } else { + p1, err := loadImport(loaderstate, ctx, opts, pre, dep, "", nil, &stk, nil, 0) + if err != nil && pmain.Error == nil { + pmain.Error = err + pmain.Incomplete = true + } + pmain.Internal.Imports = append(pmain.Internal.Imports, p1) + } + } + stk.Pop() + + parallelizablePart := func() { + allTestImports := make([]*Package, 0, len(pmain.Internal.Imports)+len(imports)+len(ximports)) + allTestImports = append(allTestImports, pmain.Internal.Imports...) + allTestImports = append(allTestImports, imports...) + allTestImports = append(allTestImports, ximports...) + setToolFlags(loaderstate, allTestImports...) + + // Do initial scan for metadata needed for writing _testmain.go + // Use that metadata to update the list of imports for package main. + // The list of imports is used by recompileForTest and by the loop + // afterward that gathers t.Cover information. + t, err := loadTestFuncs(p) + if err != nil && pmain.Error == nil { + pmain.setLoadPackageDataError(err, p.ImportPath, &stk, nil) + } + t.Cover = cover + if len(ptest.GoFiles)+len(ptest.CgoFiles) > 0 { + pmain.Internal.Imports = append(pmain.Internal.Imports, ptest) + pmain.Imports = append(pmain.Imports, ptest.ImportPath) + t.ImportTest = true + } + if pxtest != nil { + pmain.Internal.Imports = append(pmain.Internal.Imports, pxtest) + pmain.Imports = append(pmain.Imports, pxtest.ImportPath) + t.ImportXtest = true + } + + // Sort and dedup pmain.Imports. + // Only matters for go list -test output. + sort.Strings(pmain.Imports) + w := 0 + for _, path := range pmain.Imports { + if w == 0 || path != pmain.Imports[w-1] { + pmain.Imports[w] = path + w++ + } + } + pmain.Imports = pmain.Imports[:w] + pmain.Internal.RawImports = str.StringList(pmain.Imports) + + // Replace pmain's transitive dependencies with test copies, as necessary. + cycleErr := recompileForTest(pmain, p, ptest, pxtest) + if cycleErr != nil { + ptest.Error = cycleErr + ptest.Incomplete = true + } + + if cover != nil { + // Here ptest needs to inherit the proper coverage mode (since + // it contains p's Go files), whereas pmain contains only + // test harness code (don't want to instrument it, and + // we don't want coverage hooks in the pkg init). + ptest.Internal.Cover.Mode = p.Internal.Cover.Mode + pmain.Internal.Cover.Mode = "testmain" + + // Should we apply coverage analysis locally, only for this + // package and only for this test? Yes, if -cover is on but + // -coverpkg has not specified a list of packages for global + // coverage. + if cover.Local { + ptest.Internal.Cover.Mode = cover.Mode + } + } + + data, err := formatTestmain(t) + if err != nil && pmain.Error == nil { + pmain.Error = &PackageError{Err: err} + pmain.Incomplete = true + } + // Set TestmainGo even if it is empty: the presence of a TestmainGo + // indicates that this package is, in fact, a test main. + pmain.Internal.TestmainGo = &data + } + + if done != nil { + go func() { + parallelizablePart() + done() + }() + } else { + parallelizablePart() + } + + return pmain, ptest, pxtest +} + +// recompileForTest copies and replaces certain packages in pmain's dependency +// graph. This is necessary for two reasons. First, if ptest is different than +// preal, packages that import the package under test should get ptest instead +// of preal. This is particularly important if pxtest depends on functionality +// exposed in test sources in ptest. Second, if there is a main package +// (other than pmain) anywhere, we need to set p.Internal.ForceLibrary and +// clear p.Internal.BuildInfo in the test copy to prevent link conflicts. +// This may happen if both -coverpkg and the command line patterns include +// multiple main packages. +func recompileForTest(pmain, preal, ptest, pxtest *Package) *PackageError { + // The "test copy" of preal is ptest. + // For each package that depends on preal, make a "test copy" + // that depends on ptest. And so on, up the dependency tree. + testCopy := map[*Package]*Package{preal: ptest} + for _, p := range PackageList([]*Package{pmain}) { + if p == preal { + continue + } + // Copy on write. + didSplit := p == pmain || p == pxtest || p == ptest + split := func() { + if didSplit { + return + } + didSplit = true + if testCopy[p] != nil { + panic("recompileForTest loop") + } + p1 := new(Package) + testCopy[p] = p1 + *p1 = *p + p1.ForTest = preal.ImportPath + p1.Internal.Imports = make([]*Package, len(p.Internal.Imports)) + copy(p1.Internal.Imports, p.Internal.Imports) + p1.Imports = make([]string, len(p.Imports)) + copy(p1.Imports, p.Imports) + p = p1 + p.Target = "" + p.Internal.BuildInfo = nil + p.Internal.ForceLibrary = true + p.Internal.PGOProfile = preal.Internal.PGOProfile + } + + // Update p.Internal.Imports to use test copies. + for i, imp := range p.Internal.Imports { + if p1 := testCopy[imp]; p1 != nil && p1 != imp { + split() + + // If the test dependencies cause a cycle with pmain, this is + // where it is introduced. + // (There are no cycles in the graph until this assignment occurs.) + p.Internal.Imports[i] = p1 + } + } + + // Force main packages the test imports to be built as libraries. + // Normal imports of main packages are forbidden by the package loader, + // but this can still happen if -coverpkg patterns include main packages: + // covered packages are imported by pmain. Linking multiple packages + // compiled with '-p main' causes duplicate symbol errors. + // See golang.org/issue/30907, golang.org/issue/34114. + if p.Name == "main" && p != pmain && p != ptest { + split() + } + // Split and attach PGO information to test dependencies if preal + // is built with PGO. + if preal.Internal.PGOProfile != "" && p.Internal.PGOProfile == "" { + split() + } + } + + // Do search to find cycle. + // importerOf maps each import path to its importer nearest to p. + importerOf := map[*Package]*Package{} + for _, p := range ptest.Internal.Imports { + importerOf[p] = nil + } + + // q is a breadth-first queue of packages to search for target. + // Every package added to q has a corresponding entry in pathTo. + // + // We search breadth-first for two reasons: + // + // 1. We want to report the shortest cycle. + // + // 2. If p contains multiple cycles, the first cycle we encounter might not + // contain target. To ensure termination, we have to break all cycles + // other than the first. + q := slices.Clip(ptest.Internal.Imports) + for len(q) > 0 { + p := q[0] + q = q[1:] + if p == ptest { + // The stack is supposed to be in the order x imports y imports z. + // We collect in the reverse order: z is imported by y is imported + // by x, and then we reverse it. + var stk ImportStack + for p != nil { + importer, ok := importerOf[p] + if importer == nil && ok { // we set importerOf[p] == nil for the initial set of packages p that are imports of ptest + importer = ptest + } + stk = append(stk, ImportInfo{ + Pkg: p.ImportPath, + Pos: extractFirstImport(importer.Internal.Build.ImportPos[p.ImportPath]), + }) + p = importerOf[p] + } + // complete the cycle: we set importer[p] = nil to break the cycle + // in importerOf, it's an implicit importerOf[p] == pTest. Add it + // back here since we reached nil in the loop above to demonstrate + // the cycle as (for example) package p imports package q imports package r + // imports package p. + stk = append(stk, ImportInfo{ + Pkg: ptest.ImportPath, + }) + slices.Reverse(stk) + return &PackageError{ + ImportStack: stk, + Err: errors.New("import cycle not allowed in test"), + IsImportCycle: true, + } + } + for _, dep := range p.Internal.Imports { + if _, ok := importerOf[dep]; !ok { + importerOf[dep] = p + q = append(q, dep) + } + } + } + + return nil +} + +// isTestFunc tells whether fn has the type of a testing function. arg +// specifies the parameter type we look for: B, F, M or T. +func isTestFunc(fn *ast.FuncDecl, arg string) bool { + if fn.Type.Results != nil && len(fn.Type.Results.List) > 0 || + fn.Type.Params.List == nil || + len(fn.Type.Params.List) != 1 || + len(fn.Type.Params.List[0].Names) > 1 { + return false + } + ptr, ok := fn.Type.Params.List[0].Type.(*ast.StarExpr) + if !ok { + return false + } + // We can't easily check that the type is *testing.M + // because we don't know how testing has been imported, + // but at least check that it's *M or *something.M. + // Same applies for B, F and T. + if name, ok := ptr.X.(*ast.Ident); ok && name.Name == arg { + return true + } + if sel, ok := ptr.X.(*ast.SelectorExpr); ok && sel.Sel.Name == arg { + return true + } + return false +} + +// isTest tells whether name looks like a test (or benchmark, according to prefix). +// It is a Test (say) if there is a character after Test that is not a lower-case letter. +// We don't want TesticularCancer. +func isTest(name, prefix string) bool { + if !strings.HasPrefix(name, prefix) { + return false + } + if len(name) == len(prefix) { // "Test" is ok + return true + } + rune, _ := utf8.DecodeRuneInString(name[len(prefix):]) + return !unicode.IsLower(rune) +} + +// loadTestFuncs returns the testFuncs describing the tests that will be run. +// The returned testFuncs is always non-nil, even if an error occurred while +// processing test files. +func loadTestFuncs(ptest *Package) (*testFuncs, error) { + t := &testFuncs{ + Package: ptest, + } + var err error + for _, file := range ptest.TestGoFiles { + if lerr := t.load(filepath.Join(ptest.Dir, file), "_test", &t.ImportTest, &t.NeedTest); lerr != nil && err == nil { + err = lerr + } + } + for _, file := range ptest.XTestGoFiles { + if lerr := t.load(filepath.Join(ptest.Dir, file), "_xtest", &t.ImportXtest, &t.NeedXtest); lerr != nil && err == nil { + err = lerr + } + } + return t, err +} + +// formatTestmain returns the content of the _testmain.go file for t. +func formatTestmain(t *testFuncs) ([]byte, error) { + var buf bytes.Buffer + tmpl := testmainTmpl + if err := tmpl.Execute(&buf, t); err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +type testFuncs struct { + Tests []testFunc + Benchmarks []testFunc + FuzzTargets []testFunc + Examples []testFunc + TestMain *testFunc + Package *Package + ImportTest bool + NeedTest bool + ImportXtest bool + NeedXtest bool + Cover *TestCover +} + +// ImportPath returns the import path of the package being tested, if it is within GOPATH. +// This is printed by the testing package when running benchmarks. +func (t *testFuncs) ImportPath() string { + pkg := t.Package.ImportPath + if strings.HasPrefix(pkg, "_/") { + return "" + } + if pkg == "command-line-arguments" { + return "" + } + return pkg +} + +func (t *testFuncs) ModulePath() string { + m := t.Package.Module + if m == nil { + return "" + } + return m.Path +} + +// Covered returns a string describing which packages are being tested for coverage. +// If the covered package is the same as the tested package, it returns the empty string. +// Otherwise it is a comma-separated human-readable list of packages beginning with +// " in", ready for use in the coverage message. +func (t *testFuncs) Covered() string { + if t.Cover == nil || t.Cover.Paths == nil { + return "" + } + return " in " + strings.Join(t.Cover.Paths, ", ") +} + +func (t *testFuncs) CoverSelectedPackages() string { + if t.Cover == nil || t.Cover.Paths == nil { + return `[]string{"` + t.Package.ImportPath + `"}` + } + var sb strings.Builder + fmt.Fprintf(&sb, "[]string{") + for k, p := range t.Cover.Pkgs { + if k != 0 { + sb.WriteString(", ") + } + fmt.Fprintf(&sb, `"%s"`, p.ImportPath) + } + sb.WriteString("}") + return sb.String() +} + +// Tested returns the name of the package being tested. +func (t *testFuncs) Tested() string { + return t.Package.Name +} + +type testFunc struct { + Package string // imported package name (_test or _xtest) + Name string // function name + Output string // output, for examples + Unordered bool // output is allowed to be unordered. +} + +var testFileSet = token.NewFileSet() + +func (t *testFuncs) load(filename, pkg string, doImport, seen *bool) error { + // Pass in the overlaid source if we have an overlay for this file. + src, err := fsys.Open(filename) + if err != nil { + return err + } + defer src.Close() + f, err := parser.ParseFile(testFileSet, filename, src, parser.ParseComments|parser.SkipObjectResolution) + if err != nil { + return err + } + for _, d := range f.Decls { + n, ok := d.(*ast.FuncDecl) + if !ok { + continue + } + if n.Recv != nil { + continue + } + name := n.Name.String() + switch { + case name == "TestMain": + if isTestFunc(n, "T") { + t.Tests = append(t.Tests, testFunc{pkg, name, "", false}) + *doImport, *seen = true, true + continue + } + err := checkTestFunc(n, "M") + if err != nil { + return err + } + if t.TestMain != nil { + return errors.New("multiple definitions of TestMain") + } + t.TestMain = &testFunc{pkg, name, "", false} + *doImport, *seen = true, true + case isTest(name, "Test"): + err := checkTestFunc(n, "T") + if err != nil { + return err + } + t.Tests = append(t.Tests, testFunc{pkg, name, "", false}) + *doImport, *seen = true, true + case isTest(name, "Benchmark"): + err := checkTestFunc(n, "B") + if err != nil { + return err + } + t.Benchmarks = append(t.Benchmarks, testFunc{pkg, name, "", false}) + *doImport, *seen = true, true + case isTest(name, "Fuzz"): + err := checkTestFunc(n, "F") + if err != nil { + return err + } + t.FuzzTargets = append(t.FuzzTargets, testFunc{pkg, name, "", false}) + *doImport, *seen = true, true + } + } + ex := doc.Examples(f) + sort.Slice(ex, func(i, j int) bool { return ex[i].Order < ex[j].Order }) + for _, e := range ex { + *doImport = true // import test file whether executed or not + if e.Output == "" && !e.EmptyOutput { + // Don't run examples with no output. + continue + } + t.Examples = append(t.Examples, testFunc{pkg, "Example" + e.Name, e.Output, e.Unordered}) + *seen = true + } + return nil +} + +func checkTestFunc(fn *ast.FuncDecl, arg string) error { + var why string + if !isTestFunc(fn, arg) { + why = fmt.Sprintf("must be: func %s(%s *testing.%s)", fn.Name.String(), strings.ToLower(arg), arg) + } + if fn.Type.TypeParams.NumFields() > 0 { + why = "test functions cannot have type parameters" + } + if why != "" { + pos := testFileSet.Position(fn.Pos()) + return fmt.Errorf("%s: wrong signature for %s, %s", pos, fn.Name.String(), why) + } + return nil +} + +var testmainTmpl = lazytemplate.New("main", ` +// Code generated by 'go test'. DO NOT EDIT. + +package main + +import ( + "os" +{{if .TestMain}} + "reflect" +{{end}} + "testing" + "testing/internal/testdeps" +{{if .Cover}} + "internal/coverage/cfile" +{{end}} + +{{if .ImportTest}} + {{if .NeedTest}}_test{{else}}_{{end}} {{.Package.ImportPath | printf "%q"}} +{{end}} +{{if .ImportXtest}} + {{if .NeedXtest}}_xtest{{else}}_{{end}} {{.Package.ImportPath | printf "%s_test" | printf "%q"}} +{{end}} +) + +var tests = []testing.InternalTest{ +{{range .Tests}} + {"{{.Name}}", {{.Package}}.{{.Name}}}, +{{end}} +} + +var benchmarks = []testing.InternalBenchmark{ +{{range .Benchmarks}} + {"{{.Name}}", {{.Package}}.{{.Name}}}, +{{end}} +} + +var fuzzTargets = []testing.InternalFuzzTarget{ +{{range .FuzzTargets}} + {"{{.Name}}", {{.Package}}.{{.Name}}}, +{{end}} +} + +var examples = []testing.InternalExample{ +{{range .Examples}} + {"{{.Name}}", {{.Package}}.{{.Name}}, {{.Output | printf "%q"}}, {{.Unordered}}}, +{{end}} +} + +func init() { +{{if .Cover}} + testdeps.CoverMode = {{printf "%q" .Cover.Mode}} + testdeps.Covered = {{printf "%q" .Covered}} + testdeps.CoverSelectedPackages = {{printf "%s" .CoverSelectedPackages}} + testdeps.CoverSnapshotFunc = cfile.Snapshot + testdeps.CoverProcessTestDirFunc = cfile.ProcessCoverTestDir + testdeps.CoverMarkProfileEmittedFunc = cfile.MarkProfileEmitted + +{{end}} + testdeps.ModulePath = {{.ModulePath | printf "%q"}} + testdeps.ImportPath = {{.ImportPath | printf "%q"}} +} + +func main() { + m := testing.MainStart(testdeps.TestDeps{}, tests, benchmarks, fuzzTargets, examples) +{{with .TestMain}} + {{.Package}}.{{.Name}}(m) + os.Exit(int(reflect.ValueOf(m).Elem().FieldByName("exitCode").Int())) +{{else}} + os.Exit(m.Run()) +{{end}} +} + +`) diff --git a/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock.go b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock.go new file mode 100644 index 0000000000000000000000000000000000000000..f0452f014777f9892f282811bd8ec3fe131408c8 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock.go @@ -0,0 +1,75 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package filelock provides a platform-independent API for advisory file +// locking. Calls to functions in this package on platforms that do not support +// advisory locks will return errors for which IsNotSupported returns true. +package filelock + +import ( + "io/fs" +) + +// A File provides the minimal set of methods required to lock an open file. +// File implementations must be usable as map keys. +// The usual implementation is *os.File. +type File interface { + // Name returns the name of the file. + Name() string + + // Fd returns a valid file descriptor. + // (If the File is an *os.File, it must not be closed.) + Fd() uintptr + + // Stat returns the FileInfo structure describing file. + Stat() (fs.FileInfo, error) +} + +// Lock places an advisory write lock on the file, blocking until it can be +// locked. +// +// If Lock returns nil, no other process will be able to place a read or write +// lock on the file until this process exits, closes f, or calls Unlock on it. +// +// If f's descriptor is already read- or write-locked, the behavior of Lock is +// unspecified. +// +// Closing the file may or may not release the lock promptly. Callers should +// ensure that Unlock is always called when Lock succeeds. +func Lock(f File) error { + return lock(f, writeLock) +} + +// RLock places an advisory read lock on the file, blocking until it can be locked. +// +// If RLock returns nil, no other process will be able to place a write lock on +// the file until this process exits, closes f, or calls Unlock on it. +// +// If f is already read- or write-locked, the behavior of RLock is unspecified. +// +// Closing the file may or may not release the lock promptly. Callers should +// ensure that Unlock is always called if RLock succeeds. +func RLock(f File) error { + return lock(f, readLock) +} + +// Unlock removes an advisory lock placed on f by this process. +// +// The caller must not attempt to unlock a file that is not locked. +func Unlock(f File) error { + return unlock(f) +} + +// String returns the name of the function corresponding to lt +// (Lock, RLock, or Unlock). +func (lt lockType) String() string { + switch lt { + case readLock: + return "RLock" + case writeLock: + return "Lock" + default: + return "Unlock" + } +} diff --git a/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go new file mode 100644 index 0000000000000000000000000000000000000000..8a62839734e02fddac5531b767d3fc5f05433840 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go @@ -0,0 +1,210 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build aix || (solaris && !illumos) + +// This code implements the filelock API using POSIX 'fcntl' locks, which attach +// to an (inode, process) pair rather than a file descriptor. To avoid unlocking +// files prematurely when the same file is opened through different descriptors, +// we allow only one read-lock at a time. +// +// Most platforms provide some alternative API, such as an 'flock' system call +// or an F_OFD_SETLK command for 'fcntl', that allows for better concurrency and +// does not require per-inode bookkeeping in the application. + +package filelock + +import ( + "errors" + "io" + "io/fs" + "math/rand" + "sync" + "syscall" + "time" +) + +type lockType int16 + +const ( + readLock lockType = syscall.F_RDLCK + writeLock lockType = syscall.F_WRLCK +) + +type inode = uint64 // type of syscall.Stat_t.Ino + +type inodeLock struct { + owner File + queue []<-chan File +} + +var ( + mu sync.Mutex + inodes = map[File]inode{} + locks = map[inode]inodeLock{} +) + +func lock(f File, lt lockType) (err error) { + // POSIX locks apply per inode and process, and the lock for an inode is + // released when *any* descriptor for that inode is closed. So we need to + // synchronize access to each inode internally, and must serialize lock and + // unlock calls that refer to the same inode through different descriptors. + fi, err := f.Stat() + if err != nil { + return err + } + ino := fi.Sys().(*syscall.Stat_t).Ino + + mu.Lock() + if i, dup := inodes[f]; dup && i != ino { + mu.Unlock() + return &fs.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: errors.New("inode for file changed since last Lock or RLock"), + } + } + inodes[f] = ino + + var wait chan File + l := locks[ino] + if l.owner == f { + // This file already owns the lock, but the call may change its lock type. + } else if l.owner == nil { + // No owner: it's ours now. + l.owner = f + } else { + // Already owned: add a channel to wait on. + wait = make(chan File) + l.queue = append(l.queue, wait) + } + locks[ino] = l + mu.Unlock() + + if wait != nil { + wait <- f + } + + // Spurious EDEADLK errors arise on platforms that compute deadlock graphs at + // the process, rather than thread, level. Consider processes P and Q, with + // threads P.1, P.2, and Q.3. The following trace is NOT a deadlock, but will be + // reported as a deadlock on systems that consider only process granularity: + // + // P.1 locks file A. + // Q.3 locks file B. + // Q.3 blocks on file A. + // P.2 blocks on file B. (This is erroneously reported as a deadlock.) + // P.1 unlocks file A. + // Q.3 unblocks and locks file A. + // Q.3 unlocks files A and B. + // P.2 unblocks and locks file B. + // P.2 unlocks file B. + // + // These spurious errors were observed in practice on AIX and Solaris in + // cmd/go: see https://golang.org/issue/32817. + // + // We work around this bug by treating EDEADLK as always spurious. If there + // really is a lock-ordering bug between the interacting processes, it will + // become a livelock instead, but that's not appreciably worse than if we had + // a proper flock implementation (which generally does not even attempt to + // diagnose deadlocks). + // + // In the above example, that changes the trace to: + // + // P.1 locks file A. + // Q.3 locks file B. + // Q.3 blocks on file A. + // P.2 spuriously fails to lock file B and goes to sleep. + // P.1 unlocks file A. + // Q.3 unblocks and locks file A. + // Q.3 unlocks files A and B. + // P.2 wakes up and locks file B. + // P.2 unlocks file B. + // + // We know that the retry loop will not introduce a *spurious* livelock + // because, according to the POSIX specification, EDEADLK is only to be + // returned when “the lock is blocked by a lock from another process”. + // If that process is blocked on some lock that we are holding, then the + // resulting livelock is due to a real deadlock (and would manifest as such + // when using, for example, the flock implementation of this package). + // If the other process is *not* blocked on some other lock that we are + // holding, then it will eventually release the requested lock. + + nextSleep := 1 * time.Millisecond + const maxSleep = 500 * time.Millisecond + for { + err = setlkw(f.Fd(), lt) + if err != syscall.EDEADLK { + break + } + time.Sleep(nextSleep) + + nextSleep += nextSleep + if nextSleep > maxSleep { + nextSleep = maxSleep + } + // Apply 10% jitter to avoid synchronizing collisions when we finally unblock. + nextSleep += time.Duration((0.1*rand.Float64() - 0.05) * float64(nextSleep)) + } + + if err != nil { + unlock(f) + return &fs.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: err, + } + } + + return nil +} + +func unlock(f File) error { + var owner File + + mu.Lock() + ino, ok := inodes[f] + if ok { + owner = locks[ino].owner + } + mu.Unlock() + + if owner != f { + panic("unlock called on a file that is not locked") + } + + err := setlkw(f.Fd(), syscall.F_UNLCK) + + mu.Lock() + l := locks[ino] + if len(l.queue) == 0 { + // No waiters: remove the map entry. + delete(locks, ino) + } else { + // The first waiter is sending us their file now. + // Receive it and update the queue. + l.owner = <-l.queue[0] + l.queue = l.queue[1:] + locks[ino] = l + } + delete(inodes, f) + mu.Unlock() + + return err +} + +// setlkw calls FcntlFlock with F_SETLKW for the entire file indicated by fd. +func setlkw(fd uintptr, lt lockType) error { + for { + err := syscall.FcntlFlock(fd, syscall.F_SETLKW, &syscall.Flock_t{ + Type: int16(lt), + Whence: io.SeekStart, + Start: 0, + Len: 0, // All bytes. + }) + if err != syscall.EINTR { + return err + } + } +} diff --git a/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go new file mode 100644 index 0000000000000000000000000000000000000000..b16709ed51b1e263cd579fe60e2f8715d7dbf032 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go @@ -0,0 +1,35 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !unix && !windows + +package filelock + +import ( + "errors" + "io/fs" +) + +type lockType int8 + +const ( + readLock = iota + 1 + writeLock +) + +func lock(f File, lt lockType) error { + return &fs.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: errors.ErrUnsupported, + } +} + +func unlock(f File) error { + return &fs.PathError{ + Op: "Unlock", + Path: f.Name(), + Err: errors.ErrUnsupported, + } +} diff --git a/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go new file mode 100644 index 0000000000000000000000000000000000000000..c1423e60875ca57476b22a3637a53bef7325a12a --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go @@ -0,0 +1,210 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !js && !plan9 && !wasip1 + +package filelock_test + +import ( + "fmt" + "internal/testenv" + "os" + "path/filepath" + "runtime" + "testing" + "time" + + "cmd/go/internal/lockedfile/internal/filelock" +) + +func lock(t *testing.T, f *os.File) { + t.Helper() + err := filelock.Lock(f) + t.Logf("Lock(fd %d) = %v", f.Fd(), err) + if err != nil { + t.Fail() + } +} + +func rLock(t *testing.T, f *os.File) { + t.Helper() + err := filelock.RLock(f) + t.Logf("RLock(fd %d) = %v", f.Fd(), err) + if err != nil { + t.Fail() + } +} + +func unlock(t *testing.T, f *os.File) { + t.Helper() + err := filelock.Unlock(f) + t.Logf("Unlock(fd %d) = %v", f.Fd(), err) + if err != nil { + t.Fail() + } +} + +func mustTempFile(t *testing.T) (f *os.File, remove func()) { + t.Helper() + + base := filepath.Base(t.Name()) + f, err := os.CreateTemp("", base) + if err != nil { + t.Fatalf(`os.CreateTemp("", %q) = %v`, base, err) + } + t.Logf("fd %d = %s", f.Fd(), f.Name()) + + return f, func() { + f.Close() + os.Remove(f.Name()) + } +} + +func mustOpen(t *testing.T, name string) *os.File { + t.Helper() + + f, err := os.OpenFile(name, os.O_RDWR, 0) + if err != nil { + t.Fatalf("os.OpenFile(%q) = %v", name, err) + } + + t.Logf("fd %d = os.OpenFile(%q)", f.Fd(), name) + return f +} + +const ( + quiescent = 10 * time.Millisecond + probablyStillBlocked = 10 * time.Second +) + +func mustBlock(t *testing.T, op string, f *os.File) (wait func(*testing.T)) { + t.Helper() + + desc := fmt.Sprintf("%s(fd %d)", op, f.Fd()) + + done := make(chan struct{}) + go func() { + t.Helper() + switch op { + case "Lock": + lock(t, f) + case "RLock": + rLock(t, f) + default: + panic("invalid op: " + op) + } + close(done) + }() + + select { + case <-done: + t.Fatalf("%s unexpectedly did not block", desc) + return nil + + case <-time.After(quiescent): + t.Logf("%s is blocked (as expected)", desc) + return func(t *testing.T) { + t.Helper() + select { + case <-time.After(probablyStillBlocked): + t.Fatalf("%s is unexpectedly still blocked", desc) + case <-done: + } + } + } +} + +func TestLockExcludesLock(t *testing.T) { + t.Parallel() + + f, remove := mustTempFile(t) + defer remove() + + other := mustOpen(t, f.Name()) + defer other.Close() + + lock(t, f) + lockOther := mustBlock(t, "Lock", other) + unlock(t, f) + lockOther(t) + unlock(t, other) +} + +func TestLockExcludesRLock(t *testing.T) { + t.Parallel() + + f, remove := mustTempFile(t) + defer remove() + + other := mustOpen(t, f.Name()) + defer other.Close() + + lock(t, f) + rLockOther := mustBlock(t, "RLock", other) + unlock(t, f) + rLockOther(t) + unlock(t, other) +} + +func TestRLockExcludesOnlyLock(t *testing.T) { + t.Parallel() + + f, remove := mustTempFile(t) + defer remove() + rLock(t, f) + + f2 := mustOpen(t, f.Name()) + defer f2.Close() + + doUnlockTF := false + switch runtime.GOOS { + case "aix", "solaris": + // When using POSIX locks (as on Solaris), we can't safely read-lock the + // same inode through two different descriptors at the same time: when the + // first descriptor is closed, the second descriptor would still be open but + // silently unlocked. So a second RLock must block instead of proceeding. + lockF2 := mustBlock(t, "RLock", f2) + unlock(t, f) + lockF2(t) + default: + rLock(t, f2) + doUnlockTF = true + } + + other := mustOpen(t, f.Name()) + defer other.Close() + lockOther := mustBlock(t, "Lock", other) + + unlock(t, f2) + if doUnlockTF { + unlock(t, f) + } + lockOther(t) + unlock(t, other) +} + +func TestLockNotDroppedByExecCommand(t *testing.T) { + testenv.MustHaveExec(t) + + f, remove := mustTempFile(t) + defer remove() + + lock(t, f) + + other := mustOpen(t, f.Name()) + defer other.Close() + + // Some kinds of file locks are dropped when a duplicated or forked file + // descriptor is unlocked. Double-check that the approach used by os/exec does + // not accidentally drop locks. + cmd := testenv.Command(t, testenv.Executable(t), "-test.run=^$") + if err := cmd.Run(); err != nil { + t.Fatalf("exec failed: %v", err) + } + + lockOther := mustBlock(t, "Lock", other) + unlock(t, f) + lockOther(t) + unlock(t, other) +} diff --git a/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go new file mode 100644 index 0000000000000000000000000000000000000000..6f73b1bfeea9bb89f338e1770f2c9d9754368217 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go @@ -0,0 +1,40 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build darwin || dragonfly || freebsd || illumos || linux || netbsd || openbsd + +package filelock + +import ( + "io/fs" + "syscall" +) + +type lockType int16 + +const ( + readLock lockType = syscall.LOCK_SH + writeLock lockType = syscall.LOCK_EX +) + +func lock(f File, lt lockType) (err error) { + for { + err = syscall.Flock(int(f.Fd()), int(lt)) + if err != syscall.EINTR { + break + } + } + if err != nil { + return &fs.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: err, + } + } + return nil +} + +func unlock(f File) error { + return lock(f, syscall.LOCK_UN) +} diff --git a/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go new file mode 100644 index 0000000000000000000000000000000000000000..647ee9921d2592ab8f52ae0c5699fa63fb967bd4 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go @@ -0,0 +1,57 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build windows + +package filelock + +import ( + "internal/syscall/windows" + "io/fs" + "syscall" +) + +type lockType uint32 + +const ( + readLock lockType = 0 + writeLock lockType = windows.LOCKFILE_EXCLUSIVE_LOCK +) + +const ( + reserved = 0 + allBytes = ^uint32(0) +) + +func lock(f File, lt lockType) error { + // Per https://golang.org/issue/19098, “Programs currently expect the Fd + // method to return a handle that uses ordinary synchronous I/O.” + // However, LockFileEx still requires an OVERLAPPED structure, + // which contains the file offset of the beginning of the lock range. + // We want to lock the entire file, so we leave the offset as zero. + ol := new(syscall.Overlapped) + + err := windows.LockFileEx(syscall.Handle(f.Fd()), uint32(lt), reserved, allBytes, allBytes, ol) + if err != nil { + return &fs.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: err, + } + } + return nil +} + +func unlock(f File) error { + ol := new(syscall.Overlapped) + err := windows.UnlockFileEx(syscall.Handle(f.Fd()), reserved, allBytes, allBytes, ol) + if err != nil { + return &fs.PathError{ + Op: "Unlock", + Path: f.Name(), + Err: err, + } + } + return nil +} diff --git a/go/src/cmd/go/internal/lockedfile/lockedfile.go b/go/src/cmd/go/internal/lockedfile/lockedfile.go new file mode 100644 index 0000000000000000000000000000000000000000..f48124ffbc0d3ea2a439ca3f18babf7c1c74f2d7 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/lockedfile.go @@ -0,0 +1,194 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package lockedfile creates and manipulates files whose contents should only +// change atomically. +package lockedfile + +import ( + "fmt" + "io" + "io/fs" + "os" + "runtime" +) + +// A File is a locked *os.File. +// +// Closing the file releases the lock. +// +// If the program exits while a file is locked, the operating system releases +// the lock but may not do so promptly: callers must ensure that all locked +// files are closed before exiting. +type File struct { + osFile + closed bool + // cleanup panics when the file is no longer referenced and it has not been closed. + cleanup runtime.Cleanup +} + +// osFile embeds a *os.File while keeping the pointer itself unexported. +// (When we close a File, it must be the same file descriptor that we opened!) +type osFile struct { + *os.File +} + +// OpenFile is like os.OpenFile, but returns a locked file. +// If flag includes os.O_WRONLY or os.O_RDWR, the file is write-locked; +// otherwise, it is read-locked. +func OpenFile(name string, flag int, perm fs.FileMode) (*File, error) { + var ( + f = new(File) + err error + ) + f.osFile.File, err = openFile(name, flag, perm) + if err != nil { + return nil, err + } + + // Although the operating system will drop locks for open files when the go + // command exits, we want to hold locks for as little time as possible, and we + // especially don't want to leave a file locked after we're done with it. Our + // Close method is what releases the locks, so use a cleanup to report + // missing Close calls on a best-effort basis. + f.cleanup = runtime.AddCleanup(f, func(fileName string) { + panic(fmt.Sprintf("lockedfile.File %s became unreachable without a call to Close", fileName)) + }, f.Name()) + + return f, nil +} + +// Open is like os.Open, but returns a read-locked file. +func Open(name string) (*File, error) { + return OpenFile(name, os.O_RDONLY, 0) +} + +// Create is like os.Create, but returns a write-locked file. +func Create(name string) (*File, error) { + return OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) +} + +// Edit creates the named file with mode 0666 (before umask), +// but does not truncate existing contents. +// +// If Edit succeeds, methods on the returned File can be used for I/O. +// The associated file descriptor has mode O_RDWR and the file is write-locked. +func Edit(name string) (*File, error) { + return OpenFile(name, os.O_RDWR|os.O_CREATE, 0666) +} + +// Close unlocks and closes the underlying file. +// +// Close may be called multiple times; all calls after the first will return a +// non-nil error. +func (f *File) Close() error { + if f.closed { + return &fs.PathError{ + Op: "close", + Path: f.Name(), + Err: fs.ErrClosed, + } + } + f.closed = true + + err := closeFile(f.osFile.File) + f.cleanup.Stop() + // f may be dead at the moment after we access f.cleanup, + // so the cleanup can fire before Stop completes. Keep f + // alive while we call Stop. See the documentation for + // runtime.Cleanup.Stop. + runtime.KeepAlive(f) + return err +} + +// Read opens the named file with a read-lock and returns its contents. +func Read(name string) ([]byte, error) { + f, err := Open(name) + if err != nil { + return nil, err + } + defer f.Close() + + return io.ReadAll(f) +} + +// Write opens the named file (creating it with the given permissions if needed), +// then write-locks it and overwrites it with the given content. +func Write(name string, content io.Reader, perm fs.FileMode) (err error) { + f, err := OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm) + if err != nil { + return err + } + + _, err = io.Copy(f, content) + if closeErr := f.Close(); err == nil { + err = closeErr + } + return err +} + +// Transform invokes t with the result of reading the named file, with its lock +// still held. +// +// If t returns a nil error, Transform then writes the returned contents back to +// the file, making a best effort to preserve existing contents on error. +// +// t must not modify the slice passed to it. +func Transform(name string, t func([]byte) ([]byte, error)) (err error) { + f, err := Edit(name) + if err != nil { + return err + } + defer f.Close() + + old, err := io.ReadAll(f) + if err != nil { + return err + } + + new, err := t(old) + if err != nil { + return err + } + + if len(new) > len(old) { + // The overall file size is increasing, so write the tail first: if we're + // about to run out of space on the disk, we would rather detect that + // failure before we have overwritten the original contents. + if _, err := f.WriteAt(new[len(old):], int64(len(old))); err != nil { + // Make a best effort to remove the incomplete tail. + f.Truncate(int64(len(old))) + return err + } + } + + // We're about to overwrite the old contents. In case of failure, make a best + // effort to roll back before we close the file. + defer func() { + if err != nil { + if _, err := f.WriteAt(old, 0); err == nil { + f.Truncate(int64(len(old))) + } + } + }() + + if len(new) >= len(old) { + if _, err := f.WriteAt(new[:len(old)], 0); err != nil { + return err + } + } else { + if _, err := f.WriteAt(new, 0); err != nil { + return err + } + // The overall file size is decreasing, so shrink the file to its final size + // after writing. We do this after writing (instead of before) so that if + // the write fails, enough filesystem space will likely still be reserved + // to contain the previous contents. + if err := f.Truncate(int64(len(new))); err != nil { + return err + } + } + + return nil +} diff --git a/go/src/cmd/go/internal/lockedfile/lockedfile_filelock.go b/go/src/cmd/go/internal/lockedfile/lockedfile_filelock.go new file mode 100644 index 0000000000000000000000000000000000000000..1a677a7fe4a60d3a98866a846bbd6e39b057cbe9 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/lockedfile_filelock.go @@ -0,0 +1,65 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !plan9 + +package lockedfile + +import ( + "io/fs" + "os" + + "cmd/go/internal/lockedfile/internal/filelock" +) + +func openFile(name string, flag int, perm fs.FileMode) (*os.File, error) { + // On BSD systems, we could add the O_SHLOCK or O_EXLOCK flag to the OpenFile + // call instead of locking separately, but we have to support separate locking + // calls for Linux and Windows anyway, so it's simpler to use that approach + // consistently. + + f, err := os.OpenFile(name, flag&^os.O_TRUNC, perm) + if err != nil { + return nil, err + } + + switch flag & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR) { + case os.O_WRONLY, os.O_RDWR: + err = filelock.Lock(f) + default: + err = filelock.RLock(f) + } + if err != nil { + f.Close() + return nil, err + } + + if flag&os.O_TRUNC == os.O_TRUNC { + if err := f.Truncate(0); err != nil { + // The documentation for os.O_TRUNC says “if possible, truncate file when + // opened”, but doesn't define “possible” (golang.org/issue/28699). + // We'll treat regular files (and symlinks to regular files) as “possible” + // and ignore errors for the rest. + if fi, statErr := f.Stat(); statErr != nil || fi.Mode().IsRegular() { + filelock.Unlock(f) + f.Close() + return nil, err + } + } + } + + return f, nil +} + +func closeFile(f *os.File) error { + // Since locking syscalls operate on file descriptors, we must unlock the file + // while the descriptor is still valid — that is, before the file is closed — + // and avoid unlocking files that are already closed. + err := filelock.Unlock(f) + + if closeErr := f.Close(); err == nil { + err = closeErr + } + return err +} diff --git a/go/src/cmd/go/internal/lockedfile/lockedfile_plan9.go b/go/src/cmd/go/internal/lockedfile/lockedfile_plan9.go new file mode 100644 index 0000000000000000000000000000000000000000..a2ce794b967521af86975f9fe86f280ac0bc0dd0 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/lockedfile_plan9.go @@ -0,0 +1,94 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build plan9 + +package lockedfile + +import ( + "io/fs" + "math/rand" + "os" + "strings" + "time" +) + +// Opening an exclusive-use file returns an error. +// The expected error strings are: +// +// - "open/create -- file is locked" (cwfs, kfs) +// - "exclusive lock" (fossil) +// - "exclusive use file already open" (ramfs) +var lockedErrStrings = [...]string{ + "file is locked", + "exclusive lock", + "exclusive use file already open", +} + +// Even though plan9 doesn't support the Lock/RLock/Unlock functions to +// manipulate already-open files, IsLocked is still meaningful: os.OpenFile +// itself may return errors that indicate that a file with the ModeExclusive bit +// set is already open. +func isLocked(err error) bool { + s := err.Error() + + for _, frag := range lockedErrStrings { + if strings.Contains(s, frag) { + return true + } + } + + return false +} + +func openFile(name string, flag int, perm fs.FileMode) (*os.File, error) { + // Plan 9 uses a mode bit instead of explicit lock/unlock syscalls. + // + // Per http://man.cat-v.org/plan_9/5/stat: “Exclusive use files may be open + // for I/O by only one fid at a time across all clients of the server. If a + // second open is attempted, it draws an error.” + // + // So we can try to open a locked file, but if it fails we're on our own to + // figure out when it becomes available. We'll use exponential backoff with + // some jitter and an arbitrary limit of 500ms. + + // If the file was unpacked or created by some other program, it might not + // have the ModeExclusive bit set. Set it before we call OpenFile, so that we + // can be confident that a successful OpenFile implies exclusive use. + if fi, err := os.Stat(name); err == nil { + if fi.Mode()&fs.ModeExclusive == 0 { + if err := os.Chmod(name, fi.Mode()|fs.ModeExclusive); err != nil { + return nil, err + } + } + } else if !os.IsNotExist(err) { + return nil, err + } + + nextSleep := 1 * time.Millisecond + const maxSleep = 500 * time.Millisecond + for { + f, err := os.OpenFile(name, flag, perm|fs.ModeExclusive) + if err == nil { + return f, nil + } + + if !isLocked(err) { + return nil, err + } + + time.Sleep(nextSleep) + + nextSleep += nextSleep + if nextSleep > maxSleep { + nextSleep = maxSleep + } + // Apply 10% jitter to avoid synchronizing collisions. + nextSleep += time.Duration((0.1*rand.Float64() - 0.05) * float64(nextSleep)) + } +} + +func closeFile(f *os.File) error { + return f.Close() +} diff --git a/go/src/cmd/go/internal/lockedfile/lockedfile_test.go b/go/src/cmd/go/internal/lockedfile/lockedfile_test.go new file mode 100644 index 0000000000000000000000000000000000000000..514d0a316c165ca2776977b67dc52aefaf6b9576 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/lockedfile_test.go @@ -0,0 +1,262 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// js and wasip1 do not support inter-process file locking. +// +//go:build !js && !wasip1 + +package lockedfile_test + +import ( + "fmt" + "internal/testenv" + "os" + "path/filepath" + "testing" + "time" + + "cmd/go/internal/lockedfile" +) + +const ( + quiescent = 10 * time.Millisecond + probablyStillBlocked = 10 * time.Second +) + +func mustBlock(t *testing.T, desc string, f func()) (wait func(*testing.T)) { + t.Helper() + + done := make(chan struct{}) + go func() { + f() + close(done) + }() + + timer := time.NewTimer(quiescent) + defer timer.Stop() + select { + case <-done: + t.Fatalf("%s unexpectedly did not block", desc) + case <-timer.C: + } + + return func(t *testing.T) { + logTimer := time.NewTimer(quiescent) + defer logTimer.Stop() + + select { + case <-logTimer.C: + // We expect the operation to have unblocked by now, + // but maybe it's just slow. Write to the test log + // in case the test times out, but don't fail it. + t.Helper() + t.Logf("%s is unexpectedly still blocked after %v", desc, quiescent) + + // Wait for the operation to actually complete, no matter how long it + // takes. If the test has deadlocked, this will cause the test to time out + // and dump goroutines. + <-done + + case <-done: + } + } +} + +func TestMutexExcludes(t *testing.T) { + t.Parallel() + + path := filepath.Join(t.TempDir(), "lock") + mu := lockedfile.MutexAt(path) + t.Logf("mu := MutexAt(_)") + + unlock, err := mu.Lock() + if err != nil { + t.Fatalf("mu.Lock: %v", err) + } + t.Logf("unlock, _ := mu.Lock()") + + mu2 := lockedfile.MutexAt(mu.Path) + t.Logf("mu2 := MutexAt(mu.Path)") + + wait := mustBlock(t, "mu2.Lock()", func() { + unlock2, err := mu2.Lock() + if err != nil { + t.Errorf("mu2.Lock: %v", err) + return + } + t.Logf("unlock2, _ := mu2.Lock()") + t.Logf("unlock2()") + unlock2() + }) + + t.Logf("unlock()") + unlock() + wait(t) +} + +func TestReadWaitsForLock(t *testing.T) { + t.Parallel() + + path := filepath.Join(t.TempDir(), "timestamp.txt") + f, err := lockedfile.Create(path) + if err != nil { + t.Fatalf("Create: %v", err) + } + defer f.Close() + + const ( + part1 = "part 1\n" + part2 = "part 2\n" + ) + _, err = f.WriteString(part1) + if err != nil { + t.Fatalf("WriteString: %v", err) + } + t.Logf("WriteString(%q) = ", part1) + + wait := mustBlock(t, "Read", func() { + b, err := lockedfile.Read(path) + if err != nil { + t.Errorf("Read: %v", err) + return + } + + const want = part1 + part2 + got := string(b) + if got == want { + t.Logf("Read(_) = %q", got) + } else { + t.Errorf("Read(_) = %q, _; want %q", got, want) + } + }) + + _, err = f.WriteString(part2) + if err != nil { + t.Errorf("WriteString: %v", err) + } else { + t.Logf("WriteString(%q) = ", part2) + } + f.Close() + + wait(t) +} + +func TestCanLockExistingFile(t *testing.T) { + t.Parallel() + + path := filepath.Join(t.TempDir(), "existing.txt") + if err := os.WriteFile(path, []byte("ok"), 0777); err != nil { + t.Fatalf("os.WriteFile: %v", err) + } + + f, err := lockedfile.Edit(path) + if err != nil { + t.Fatalf("first Edit: %v", err) + } + + wait := mustBlock(t, "Edit", func() { + other, err := lockedfile.Edit(path) + if err != nil { + t.Errorf("second Edit: %v", err) + } + other.Close() + }) + + f.Close() + wait(t) +} + +// TestSpuriousEDEADLK verifies that the spurious EDEADLK reported in +// https://golang.org/issue/32817 no longer occurs. +func TestSpuriousEDEADLK(t *testing.T) { + // P.1 locks file A. + // Q.3 locks file B. + // Q.3 blocks on file A. + // P.2 blocks on file B. (Spurious EDEADLK occurs here.) + // P.1 unlocks file A. + // Q.3 unblocks and locks file A. + // Q.3 unlocks files A and B. + // P.2 unblocks and locks file B. + // P.2 unlocks file B. + + dirVar := t.Name() + "DIR" + + if dir := os.Getenv(dirVar); dir != "" { + // Q.3 locks file B. + b, err := lockedfile.Edit(filepath.Join(dir, "B")) + if err != nil { + t.Fatal(err) + } + defer b.Close() + + if err := os.WriteFile(filepath.Join(dir, "locked"), []byte("ok"), 0666); err != nil { + t.Fatal(err) + } + + // Q.3 blocks on file A. + a, err := lockedfile.Edit(filepath.Join(dir, "A")) + // Q.3 unblocks and locks file A. + if err != nil { + t.Fatal(err) + } + defer a.Close() + + // Q.3 unlocks files A and B. + return + } + + dir := t.TempDir() + + // P.1 locks file A. + a, err := lockedfile.Edit(filepath.Join(dir, "A")) + if err != nil { + t.Fatal(err) + } + + cmd := testenv.Command(t, testenv.Executable(t), "-test.run=^"+t.Name()+"$") + cmd.Env = append(os.Environ(), fmt.Sprintf("%s=%s", dirVar, dir)) + + qDone := make(chan struct{}) + waitQ := mustBlock(t, "Edit A and B in subprocess", func() { + out, err := cmd.CombinedOutput() + if err != nil { + t.Errorf("%v:\n%s", err, out) + } + close(qDone) + }) + + // Wait until process Q has either failed or locked file B. + // Otherwise, P.2 might not block on file B as intended. +locked: + for { + if _, err := os.Stat(filepath.Join(dir, "locked")); !os.IsNotExist(err) { + break locked + } + timer := time.NewTimer(1 * time.Millisecond) + select { + case <-qDone: + timer.Stop() + break locked + case <-timer.C: + } + } + + waitP2 := mustBlock(t, "Edit B", func() { + // P.2 blocks on file B. (Spurious EDEADLK occurs here.) + b, err := lockedfile.Edit(filepath.Join(dir, "B")) + // P.2 unblocks and locks file B. + if err != nil { + t.Error(err) + return + } + // P.2 unlocks file B. + b.Close() + }) + + // P.1 unlocks file A. + a.Close() + + waitQ(t) + waitP2(t) +} diff --git a/go/src/cmd/go/internal/lockedfile/mutex.go b/go/src/cmd/go/internal/lockedfile/mutex.go new file mode 100644 index 0000000000000000000000000000000000000000..180a36c62016ba045f1829680e91182ac6d716a7 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/mutex.go @@ -0,0 +1,67 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package lockedfile + +import ( + "fmt" + "os" + "sync" +) + +// A Mutex provides mutual exclusion within and across processes by locking a +// well-known file. Such a file generally guards some other part of the +// filesystem: for example, a Mutex file in a directory might guard access to +// the entire tree rooted in that directory. +// +// Mutex does not implement sync.Locker: unlike a sync.Mutex, a lockedfile.Mutex +// can fail to lock (e.g. if there is a permission error in the filesystem). +// +// Like a sync.Mutex, a Mutex may be included as a field of a larger struct but +// must not be copied after first use. The Path field must be set before first +// use and must not be change thereafter. +type Mutex struct { + Path string // The path to the well-known lock file. Must be non-empty. + mu sync.Mutex // A redundant mutex. The race detector doesn't know about file locking, so in tests we may need to lock something that it understands. +} + +// MutexAt returns a new Mutex with Path set to the given non-empty path. +func MutexAt(path string) *Mutex { + if path == "" { + panic("lockedfile.MutexAt: path must be non-empty") + } + return &Mutex{Path: path} +} + +func (mu *Mutex) String() string { + return fmt.Sprintf("lockedfile.Mutex(%s)", mu.Path) +} + +// Lock attempts to lock the Mutex. +// +// If successful, Lock returns a non-nil unlock function: it is provided as a +// return-value instead of a separate method to remind the caller to check the +// accompanying error. (See https://golang.org/issue/20803.) +func (mu *Mutex) Lock() (unlock func(), err error) { + if mu.Path == "" { + panic("lockedfile.Mutex: missing Path during Lock") + } + + // We could use either O_RDWR or O_WRONLY here. If we choose O_RDWR and the + // file at mu.Path is write-only, the call to OpenFile will fail with a + // permission error. That's actually what we want: if we add an RLock method + // in the future, it should call OpenFile with O_RDONLY and will require the + // files must be readable, so we should not let the caller make any + // assumptions about Mutex working with write-only files. + f, err := OpenFile(mu.Path, os.O_RDWR|os.O_CREATE, 0666) + if err != nil { + return nil, err + } + mu.mu.Lock() + + return func() { + mu.mu.Unlock() + f.Close() + }, nil +} diff --git a/go/src/cmd/go/internal/lockedfile/transform_test.go b/go/src/cmd/go/internal/lockedfile/transform_test.go new file mode 100644 index 0000000000000000000000000000000000000000..b174b311c3a2db9a6a3e7c434ece7aac632244d1 --- /dev/null +++ b/go/src/cmd/go/internal/lockedfile/transform_test.go @@ -0,0 +1,103 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// js and wasip1 do not support inter-process file locking. +// +//go:build !js && !wasip1 + +package lockedfile_test + +import ( + "bytes" + "encoding/binary" + "math/rand" + "path/filepath" + "testing" + "time" + + "cmd/go/internal/lockedfile" +) + +func isPowerOf2(x int) bool { + return x > 0 && x&(x-1) == 0 +} + +func roundDownToPowerOf2(x int) int { + if x <= 0 { + panic("nonpositive x") + } + bit := 1 + for x != bit { + x = x &^ bit + bit <<= 1 + } + return x +} + +func TestTransform(t *testing.T) { + path := filepath.Join(t.TempDir(), "blob.bin") + + const maxChunkWords = 8 << 10 + buf := make([]byte, 2*maxChunkWords*8) + for i := uint64(0); i < 2*maxChunkWords; i++ { + binary.LittleEndian.PutUint64(buf[i*8:], i) + } + if err := lockedfile.Write(path, bytes.NewReader(buf[:8]), 0666); err != nil { + t.Fatal(err) + } + + var attempts int64 = 128 + if !testing.Short() { + attempts *= 16 + } + const parallel = 32 + + var sem = make(chan bool, parallel) + + for n := attempts; n > 0; n-- { + sem <- true + go func() { + defer func() { <-sem }() + + time.Sleep(time.Duration(rand.Intn(100)) * time.Microsecond) + chunkWords := roundDownToPowerOf2(rand.Intn(maxChunkWords) + 1) + offset := rand.Intn(chunkWords) + + err := lockedfile.Transform(path, func(data []byte) (chunk []byte, err error) { + chunk = buf[offset*8 : (offset+chunkWords)*8] + + if len(data)&^7 != len(data) { + t.Errorf("read %d bytes, but each write is an integer multiple of 8 bytes", len(data)) + return chunk, nil + } + + words := len(data) / 8 + if !isPowerOf2(words) { + t.Errorf("read %d 8-byte words, but each write is a power-of-2 number of words", words) + return chunk, nil + } + + u := binary.LittleEndian.Uint64(data) + for i := 1; i < words; i++ { + next := binary.LittleEndian.Uint64(data[i*8:]) + if next != u+1 { + t.Errorf("wrote sequential integers, but read integer out of sequence at offset %d", i) + return chunk, nil + } + u = next + } + + return chunk, nil + }) + + if err != nil { + t.Errorf("unexpected error from Transform: %v", err) + } + }() + } + + for n := parallel; n > 0; n-- { + sem <- true + } +} diff --git a/go/src/cmd/go/internal/mmap/mmap.go b/go/src/cmd/go/internal/mmap/mmap.go new file mode 100644 index 0000000000000000000000000000000000000000..cd7ea80f2dd1f94ad7531050471ba55a8e66e8f9 --- /dev/null +++ b/go/src/cmd/go/internal/mmap/mmap.go @@ -0,0 +1,51 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This package is a lightly modified version of the mmap code +// in github.com/google/codesearch/index. + +// The mmap package provides an abstraction for memory mapping files +// on different platforms. +package mmap + +import ( + "os" +) + +// Data is mmap'ed read-only data from a file. +// The backing file is never closed, so Data +// remains valid for the lifetime of the process. +type Data struct { + f *os.File + Data []byte +} + +// Mmap maps the given file into memory. +// The boolean result indicates whether the file was opened. +// If it is true, the caller should avoid attempting +// to write to the file on Windows, because Windows locks +// the open file, and writes to it will fail. +func Mmap(file string) (Data, bool, error) { + f, err := os.Open(file) + if err != nil { + return Data{}, false, err + } + data, err := mmapFile(f) + + // Closing the file causes it not to count against this process's + // limit on open files; however, the mapping still counts against + // the system-wide limit, which is typically higher. Examples: + // + // macOS process (sysctl kern.maxfilesperproc): 61440 + // macOS system (sysctl kern.maxfiles): 122880 + // linux process (ulimit -n) 1048576 + // linux system (/proc/sys/fs/file-max) 100000 + if cerr := f.Close(); cerr != nil && err == nil { + return data, true, cerr + } + + // The file is still considered to be in use on Windows after + // it's closed because of the mapping. + return data, true, err +} diff --git a/go/src/cmd/go/internal/mmap/mmap_other.go b/go/src/cmd/go/internal/mmap/mmap_other.go new file mode 100644 index 0000000000000000000000000000000000000000..4d2844fc3731355df9feb8a6f1ca7d36fdf1d375 --- /dev/null +++ b/go/src/cmd/go/internal/mmap/mmap_other.go @@ -0,0 +1,21 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build (js && wasm) || wasip1 || plan9 + +package mmap + +import ( + "io" + "os" +) + +// mmapFile on other systems doesn't mmap the file. It just reads everything. +func mmapFile(f *os.File) (Data, error) { + b, err := io.ReadAll(f) + if err != nil { + return Data{}, err + } + return Data{f, b}, nil +} diff --git a/go/src/cmd/go/internal/mmap/mmap_test.go b/go/src/cmd/go/internal/mmap/mmap_test.go new file mode 100644 index 0000000000000000000000000000000000000000..3f4b63caf19bd2a62ecc3bf59ed6992e9ba9825f --- /dev/null +++ b/go/src/cmd/go/internal/mmap/mmap_test.go @@ -0,0 +1,32 @@ +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mmap + +import ( + "bytes" + "testing" +) + +// TestMmap does a round trip to make sure the slice returned by +// mmap contains the same data as was written to the file. It's +// a test on one of the issues in #71059: on Windows we were +// returning a slice containing all the data in the mmapped pages, +// which could be longer than the file. +func TestMmap(t *testing.T) { + // Use an already existing file as our test data. Avoid creating + // a temporary file so that we don't have to close the mapping on + // Windows before deleting the file during test cleanup. + f := "testdata/small_file.txt" + + want := []byte("This file is shorter than 4096 bytes.\n") + + data, _, err := Mmap(f) + if err != nil { + t.Fatalf("calling Mmap: %v", err) + } + if !bytes.Equal(data.Data, want) { + t.Fatalf("mmapped data slice: got %q; want %q", data.Data, want) + } +} diff --git a/go/src/cmd/go/internal/mmap/mmap_unix.go b/go/src/cmd/go/internal/mmap/mmap_unix.go new file mode 100644 index 0000000000000000000000000000000000000000..5dce87236870bc5967d990cfed6fa14791d9aab9 --- /dev/null +++ b/go/src/cmd/go/internal/mmap/mmap_unix.go @@ -0,0 +1,36 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix + +package mmap + +import ( + "fmt" + "io/fs" + "os" + "syscall" +) + +func mmapFile(f *os.File) (Data, error) { + st, err := f.Stat() + if err != nil { + return Data{}, err + } + size := st.Size() + pagesize := int64(os.Getpagesize()) + if int64(int(size+(pagesize-1))) != size+(pagesize-1) { + return Data{}, fmt.Errorf("%s: too large for mmap", f.Name()) + } + n := int(size) + if n == 0 { + return Data{f, nil}, nil + } + mmapLength := int(((size + pagesize - 1) / pagesize) * pagesize) // round up to page size + data, err := syscall.Mmap(int(f.Fd()), 0, mmapLength, syscall.PROT_READ, syscall.MAP_SHARED) + if err != nil { + return Data{}, &fs.PathError{Op: "mmap", Path: f.Name(), Err: err} + } + return Data{f, data[:n]}, nil +} diff --git a/go/src/cmd/go/internal/mmap/mmap_windows.go b/go/src/cmd/go/internal/mmap/mmap_windows.go new file mode 100644 index 0000000000000000000000000000000000000000..4163484b1a351026231cb378ef0c83b2b3a5133d --- /dev/null +++ b/go/src/cmd/go/internal/mmap/mmap_windows.go @@ -0,0 +1,47 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mmap + +import ( + "fmt" + "os" + "syscall" + "unsafe" + + "internal/syscall/windows" +) + +func mmapFile(f *os.File) (Data, error) { + st, err := f.Stat() + if err != nil { + return Data{}, err + } + size := st.Size() + if size == 0 { + return Data{f, nil}, nil + } + h, err := syscall.CreateFileMapping(syscall.Handle(f.Fd()), nil, syscall.PAGE_READONLY, 0, 0, nil) + if err != nil { + return Data{}, fmt.Errorf("CreateFileMapping %s: %w", f.Name(), err) + } + + addr, err := syscall.MapViewOfFile(h, syscall.FILE_MAP_READ, 0, 0, 0) + if err != nil { + return Data{}, fmt.Errorf("MapViewOfFile %s: %w", f.Name(), err) + } + var info windows.MemoryBasicInformation + err = windows.VirtualQuery(addr, &info, unsafe.Sizeof(info)) + if err != nil { + return Data{}, fmt.Errorf("VirtualQuery %s: %w", f.Name(), err) + } + data := unsafe.Slice((*byte)(unsafe.Pointer(addr)), int(info.RegionSize)) + if len(data) < int(size) { + // In some cases, especially on 386, we may not receive a in incomplete mapping: + // one that is shorter than the file itself. Return an error in those cases because + // incomplete mappings are not useful. + return Data{}, fmt.Errorf("mmapFile: received incomplete mapping of file") + } + return Data{f, data[:int(size)]}, nil +} diff --git a/go/src/cmd/go/internal/mmap/testdata/small_file.txt b/go/src/cmd/go/internal/mmap/testdata/small_file.txt new file mode 100644 index 0000000000000000000000000000000000000000..10bb609f2ab33483fd59145634f8df156acf6dc3 --- /dev/null +++ b/go/src/cmd/go/internal/mmap/testdata/small_file.txt @@ -0,0 +1 @@ +This file is shorter than 4096 bytes. diff --git a/go/src/cmd/go/internal/modcmd/download.go b/go/src/cmd/go/internal/modcmd/download.go new file mode 100644 index 0000000000000000000000000000000000000000..661cddcd79de64b38273b4db74bd18ddedf45f73 --- /dev/null +++ b/go/src/cmd/go/internal/modcmd/download.go @@ -0,0 +1,390 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modcmd + +import ( + "context" + "encoding/json" + "errors" + "os" + "runtime" + "sync" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/modfetch" + "cmd/go/internal/modfetch/codehost" + "cmd/go/internal/modload" + "cmd/go/internal/toolchain" + + "golang.org/x/mod/module" +) + +var cmdDownload = &base.Command{ + UsageLine: "go mod download [-x] [-json] [-reuse=old.json] [modules]", + Short: "download modules to local cache", + Long: ` +Download downloads the named modules, which can be module patterns selecting +dependencies of the main module or module queries of the form path@version. + +With no arguments, download applies to the modules needed to build and test +the packages in the main module: the modules explicitly required by the main +module if it is at 'go 1.17' or higher, or all transitively-required modules +if at 'go 1.16' or lower. + +The go command will automatically download modules as needed during ordinary +execution. The "go mod download" command is useful mainly for pre-filling +the local cache or to compute the answers for a Go module proxy. + +By default, download writes nothing to standard output. It may print progress +messages and errors to standard error. + +The -json flag causes download to print a sequence of JSON objects +to standard output, describing each downloaded module (or failure), +corresponding to this Go struct: + + type Module struct { + Path string // module path + Query string // version query corresponding to this version + Version string // module version + Error string // error loading module + Info string // absolute path to cached .info file + GoMod string // absolute path to cached .mod file + Zip string // absolute path to cached .zip file + Dir string // absolute path to cached source root directory + Sum string // checksum for path, version (as in go.sum) + GoModSum string // checksum for go.mod (as in go.sum) + Origin any // provenance of module + Reuse bool // reuse of old module info is safe + } + +The -reuse flag accepts the name of file containing the JSON output of a +previous 'go mod download -json' invocation. The go command may use this +file to determine that a module is unchanged since the previous invocation +and avoid redownloading it. Modules that are not redownloaded will be marked +in the new output by setting the Reuse field to true. Normally the module +cache provides this kind of reuse automatically; the -reuse flag can be +useful on systems that do not preserve the module cache. + +The -x flag causes download to print the commands download executes. + +See https://golang.org/ref/mod#go-mod-download for more about 'go mod download'. + +See https://golang.org/ref/mod#version-queries for more about version queries. + `, +} + +var ( + downloadJSON = cmdDownload.Flag.Bool("json", false, "") + downloadReuse = cmdDownload.Flag.String("reuse", "", "") +) + +func init() { + cmdDownload.Run = runDownload // break init cycle + + // TODO(jayconrod): https://golang.org/issue/35849 Apply -x to other 'go mod' commands. + cmdDownload.Flag.BoolVar(&cfg.BuildX, "x", false, "") + base.AddChdirFlag(&cmdDownload.Flag) + base.AddModCommonFlags(&cmdDownload.Flag) +} + +// A ModuleJSON describes the result of go mod download. +type ModuleJSON struct { + Path string `json:",omitempty"` + Version string `json:",omitempty"` + Query string `json:",omitempty"` + Error string `json:",omitempty"` + Info string `json:",omitempty"` + GoMod string `json:",omitempty"` + Zip string `json:",omitempty"` + Dir string `json:",omitempty"` + Sum string `json:",omitempty"` + GoModSum string `json:",omitempty"` + + Origin *codehost.Origin `json:",omitempty"` + Reuse bool `json:",omitempty"` +} + +func runDownload(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + moduleLoaderState.InitWorkfile() + + // Check whether modules are enabled and whether we're in a module. + moduleLoaderState.ForceUseModules = true + modload.ExplicitWriteGoMod = true + haveExplicitArgs := len(args) > 0 + + if moduleLoaderState.HasModRoot() || modload.WorkFilePath(moduleLoaderState) != "" { + modload.LoadModFile(moduleLoaderState, ctx) // to fill MainModules + + if haveExplicitArgs { + for _, mainModule := range moduleLoaderState.MainModules.Versions() { + targetAtUpgrade := mainModule.Path + "@upgrade" + targetAtPatch := mainModule.Path + "@patch" + for _, arg := range args { + switch arg { + case mainModule.Path, targetAtUpgrade, targetAtPatch: + os.Stderr.WriteString("go: skipping download of " + arg + " that resolves to the main module\n") + } + } + } + } else if modload.WorkFilePath(moduleLoaderState) != "" { + // TODO(#44435): Think about what the correct query is to download the + // right set of modules. Also see code review comment at + // https://go-review.googlesource.com/c/go/+/359794/comments/ce946a80_6cf53992. + args = []string{"all"} + } else { + mainModule := moduleLoaderState.MainModules.Versions()[0] + modFile := moduleLoaderState.MainModules.ModFile(mainModule) + if modFile.Go == nil || gover.Compare(modFile.Go.Version, gover.ExplicitIndirectVersion) < 0 { + if len(modFile.Require) > 0 { + args = []string{"all"} + } + } else { + // As of Go 1.17, the go.mod file explicitly requires every module + // that provides any package imported by the main module. + // 'go mod download' is typically run before testing packages in the + // main module, so by default we shouldn't download the others + // (which are presumed irrelevant to the packages in the main module). + // See https://golang.org/issue/44435. + // + // However, we also need to load the full module graph, to ensure that + // we have downloaded enough of the module graph to run 'go list all', + // 'go mod graph', and similar commands. + _, err := modload.LoadModGraph(moduleLoaderState, ctx, "") + if err != nil { + // TODO(#64008): call base.Fatalf instead of toolchain.SwitchOrFatal + // here, since we can only reach this point with an outdated toolchain + // if the go.mod file is inconsistent. + toolchain.SwitchOrFatal(moduleLoaderState, ctx, err) + } + + for _, m := range modFile.Require { + args = append(args, m.Mod.Path) + } + } + } + } + + if len(args) == 0 { + if moduleLoaderState.HasModRoot() { + os.Stderr.WriteString("go: no module dependencies to download\n") + } else { + base.Errorf("go: no modules specified (see 'go help mod download')") + } + base.Exit() + } + + if *downloadReuse != "" && moduleLoaderState.HasModRoot() { + base.Fatalf("go mod download -reuse cannot be used inside a module") + } + + var mods []*ModuleJSON + type token struct{} + sem := make(chan token, runtime.GOMAXPROCS(0)) + infos, infosErr := modload.ListModules(moduleLoaderState, ctx, args, 0, *downloadReuse) + + // There is a bit of a chicken-and-egg problem here: ideally we need to know + // which Go version to switch to download the requested modules, but if we + // haven't downloaded the module's go.mod file yet the GoVersion field of its + // info struct is not yet populated. + // + // We also need to be careful to only print the info for each module once + // if the -json flag is set. + // + // In theory we could go through each module in the list, attempt to download + // its go.mod file, and record the maximum version (either from the file or + // from the resulting TooNewError), all before we try the actual full download + // of each module. + // + // For now, we go ahead and try all the downloads and collect the errors, and + // if any download failed due to a TooNewError, we switch toolchains and try + // again. Any downloads that already succeeded will still be in cache. + // That won't give optimal concurrency (we'll do two batches of concurrent + // downloads instead of all in one batch), and it might add a little overhead + // to look up the downloads from the first batch in the module cache when + // we see them again in the second batch. On the other hand, it's way simpler + // to implement, and not really any more expensive if the user is requesting + // no explicit arguments (their go.mod file should already list an appropriate + // toolchain version) or only one module (as is used by the Go Module Proxy). + + if infosErr != nil { + sw := toolchain.NewSwitcher(moduleLoaderState) + sw.Error(infosErr) + if sw.NeedSwitch() { + sw.Switch(ctx) + } + // Otherwise, wait to report infosErr after we have downloaded + // when we can. + } + + if !haveExplicitArgs && modload.WorkFilePath(moduleLoaderState) == "" { + // 'go mod download' is sometimes run without arguments to pre-populate the + // module cache. In modules that aren't at go 1.17 or higher, it may fetch + // modules that aren't needed to build packages in the main module. This is + // usually not intended, so don't save sums for downloaded modules + // (golang.org/issue/45332). We do still fix inconsistencies in go.mod + // though. + // + // TODO(#64008): In the future, report an error if go.mod or go.sum need to + // be updated after loading the build list. This may require setting + // the mode to "mod" or "readonly" depending on haveExplicitArgs. + if err := modload.WriteGoMod(moduleLoaderState, ctx, modload.WriteOpts{}); err != nil { + base.Fatal(err) + } + } + + var downloadErrs sync.Map + for _, info := range infos { + if info.Replace != nil { + info = info.Replace + } + if info.Version == "" && info.Error == nil { + // main module or module replaced with file path. + // Nothing to download. + continue + } + m := &ModuleJSON{ + Path: info.Path, + Version: info.Version, + Query: info.Query, + Reuse: info.Reuse, + Origin: info.Origin, + } + mods = append(mods, m) + if info.Error != nil { + m.Error = info.Error.Err + continue + } + if m.Reuse { + continue + } + sem <- token{} + go func() { + err := DownloadModule(ctx, moduleLoaderState.Fetcher(), m) + if err != nil { + downloadErrs.Store(m, err) + m.Error = err.Error() + } + <-sem + }() + } + + // Fill semaphore channel to wait for goroutines to finish. + for n := cap(sem); n > 0; n-- { + sem <- token{} + } + + // If there were explicit arguments + // (like 'go mod download golang.org/x/tools@latest'), + // check whether we need to upgrade the toolchain in order to download them. + // + // (If invoked without arguments, we expect the module graph to already + // be tidy and the go.mod file to declare a 'go' version that satisfies + // transitive requirements. If that invariant holds, then we should have + // already upgraded when we loaded the module graph, and should not need + // an additional check here. See https://go.dev/issue/45551.) + // + // We also allow upgrades if in a workspace because in workspace mode + // with no arguments we download the module pattern "all", + // which may include dependencies that are normally pruned out + // of the individual modules in the workspace. + if haveExplicitArgs || modload.WorkFilePath(moduleLoaderState) != "" { + sw := toolchain.NewSwitcher(moduleLoaderState) + // Add errors to the Switcher in deterministic order so that they will be + // logged deterministically. + for _, m := range mods { + if erri, ok := downloadErrs.Load(m); ok { + sw.Error(erri.(error)) + } + } + // Only call sw.Switch if it will actually switch. + // Otherwise, we may want to write the errors as JSON + // (instead of using base.Error as sw.Switch would), + // and we may also have other errors to report from the + // initial infos returned by ListModules. + if sw.NeedSwitch() { + sw.Switch(ctx) + } + } + + if *downloadJSON { + for _, m := range mods { + b, err := json.MarshalIndent(m, "", "\t") + if err != nil { + base.Fatal(err) + } + os.Stdout.Write(append(b, '\n')) + if m.Error != "" { + base.SetExitStatus(1) + } + } + } else { + for _, m := range mods { + if m.Error != "" { + base.Error(errors.New(m.Error)) + } + } + base.ExitIfErrors() + } + + // If there were explicit arguments, update go.mod and especially go.sum. + // 'go mod download mod@version' is a useful way to add a sum without using + // 'go get mod@version', which may have other side effects. We print this in + // some error message hints. + // + // If we're in workspace mode, update go.work.sum with checksums for all of + // the modules we downloaded that aren't already recorded. Since a requirement + // in one module may upgrade a dependency of another, we can't be sure that + // the import graph matches the import graph of any given module in isolation, + // so we may end up needing to load packages from modules that wouldn't + // otherwise be relevant. + // + // TODO(#44435): If we adjust the set of modules downloaded in workspace mode, + // we may also need to adjust the logic for saving checksums here. + // + // Don't save sums for 'go mod download' without arguments unless we're in + // workspace mode; see comment above. + if haveExplicitArgs || modload.WorkFilePath(moduleLoaderState) != "" { + if err := modload.WriteGoMod(moduleLoaderState, ctx, modload.WriteOpts{}); err != nil { + base.Error(err) + } + } + + // If there was an error matching some of the requested packages, emit it now + // (after we've written the checksums for the modules that were downloaded + // successfully). + if infosErr != nil { + base.Error(infosErr) + } +} + +// DownloadModule runs 'go mod download' for m.Path@m.Version, +// leaving the results (including any error) in m itself. +func DownloadModule(ctx context.Context, f *modfetch.Fetcher, m *ModuleJSON) error { + var err error + _, file, err := f.InfoFile(ctx, m.Path, m.Version) + if err != nil { + return err + } + m.Info = file + m.GoMod, err = f.GoModFile(ctx, m.Path, m.Version) + if err != nil { + return err + } + m.GoModSum, err = f.GoModSum(ctx, m.Path, m.Version) + if err != nil { + return err + } + mod := module.Version{Path: m.Path, Version: m.Version} + m.Zip, err = f.DownloadZip(ctx, mod) + if err != nil { + return err + } + m.Sum = modfetch.Sum(ctx, mod) + m.Dir, err = f.Download(ctx, mod) + return err +} diff --git a/go/src/cmd/go/internal/modcmd/edit.go b/go/src/cmd/go/internal/modcmd/edit.go new file mode 100644 index 0000000000000000000000000000000000000000..cd15b822ade0f14eaa2cd82268d25aaee439a680 --- /dev/null +++ b/go/src/cmd/go/internal/modcmd/edit.go @@ -0,0 +1,681 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// go mod edit + +package modcmd + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "os" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/gover" + "cmd/go/internal/lockedfile" + "cmd/go/internal/modfetch" + "cmd/go/internal/modload" + + "golang.org/x/mod/modfile" + "golang.org/x/mod/module" +) + +var cmdEdit = &base.Command{ + UsageLine: "go mod edit [editing flags] [-fmt|-print|-json] [go.mod]", + Short: "edit go.mod from tools or scripts", + Long: ` +Edit provides a command-line interface for editing go.mod, +for use primarily by tools or scripts. It reads only go.mod; +it does not look up information about the modules involved. +By default, edit reads and writes the go.mod file of the main module, +but a different target file can be specified after the editing flags. + +The editing flags specify a sequence of editing operations. + +The -fmt flag reformats the go.mod file without making other changes. +This reformatting is also implied by any other modifications that use or +rewrite the go.mod file. The only time this flag is needed is if no other +flags are specified, as in 'go mod edit -fmt'. + +The -module flag changes the module's path (the go.mod file's module line). + +The -godebug=key=value flag adds a godebug key=value line, +replacing any existing godebug lines with the given key. + +The -dropgodebug=key flag drops any existing godebug lines +with the given key. + +The -require=path@version and -droprequire=path flags +add and drop a requirement on the given module path and version. +Note that -require overrides any existing requirements on path. +These flags are mainly for tools that understand the module graph. +Users should prefer 'go get path@version' or 'go get path@none', +which make other go.mod adjustments as needed to satisfy +constraints imposed by other modules. + +The -go=version flag sets the expected Go language version. +This flag is mainly for tools that understand Go version dependencies. +Users should prefer 'go get go@version'. + +The -toolchain=version flag sets the Go toolchain to use. +This flag is mainly for tools that understand Go version dependencies. +Users should prefer 'go get toolchain@version'. + +The -exclude=path@version and -dropexclude=path@version flags +add and drop an exclusion for the given module path and version. +Note that -exclude=path@version is a no-op if that exclusion already exists. + +The -replace=old[@v]=new[@v] flag adds a replacement of the given +module path and version pair. If the @v in old@v is omitted, a +replacement without a version on the left side is added, which applies +to all versions of the old module path. If the @v in new@v is omitted, +the new path should be a local module root directory, not a module +path. Note that -replace overrides any redundant replacements for old[@v], +so omitting @v will drop existing replacements for specific versions. + +The -dropreplace=old[@v] flag drops a replacement of the given +module path and version pair. If the @v is omitted, a replacement without +a version on the left side is dropped. + +The -retract=version and -dropretract=version flags add and drop a +retraction on the given version. The version may be a single version +like "v1.2.3" or a closed interval like "[v1.1.0,v1.1.9]". Note that +-retract=version is a no-op if that retraction already exists. + +The -tool=path and -droptool=path flags add and drop a tool declaration +for the given path. + +The -ignore=path and -dropignore=path flags add and drop a ignore declaration +for the given path. + +The -godebug, -dropgodebug, -require, -droprequire, -exclude, -dropexclude, +-replace, -dropreplace, -retract, -dropretract, -tool, -droptool, -ignore, +and -dropignore editing flags may be repeated, and the changes are applied +in the order given. + +The -print flag prints the final go.mod in its text format instead of +writing it back to go.mod. + +The -json flag prints the final go.mod file in JSON format instead of +writing it back to go.mod. The JSON output corresponds to these Go types: + + type GoMod struct { + Module ModPath + Go string + Toolchain string + Godebug []Godebug + Require []Require + Exclude []Module + Replace []Replace + Retract []Retract + Tool []Tool + Ignore []Ignore + } + + type Module struct { + Path string + Version string + } + + type ModPath struct { + Path string + Deprecated string + } + + type Godebug struct { + Key string + Value string + } + + type Require struct { + Path string + Version string + Indirect bool + } + + type Replace struct { + Old Module + New Module + } + + type Retract struct { + Low string + High string + Rationale string + } + + type Tool struct { + Path string + } + + type Ignore struct { + Path string + } + +Retract entries representing a single version (not an interval) will have +the "Low" and "High" fields set to the same value. + +Note that this only describes the go.mod file itself, not other modules +referred to indirectly. For the full set of modules available to a build, +use 'go list -m -json all'. + +Edit also provides the -C, -n, and -x build flags. + +See https://golang.org/ref/mod#go-mod-edit for more about 'go mod edit'. + `, +} + +var ( + editFmt = cmdEdit.Flag.Bool("fmt", false, "") + editGo = cmdEdit.Flag.String("go", "", "") + editToolchain = cmdEdit.Flag.String("toolchain", "", "") + editJSON = cmdEdit.Flag.Bool("json", false, "") + editPrint = cmdEdit.Flag.Bool("print", false, "") + editModule = cmdEdit.Flag.String("module", "", "") + edits []func(*modfile.File) // edits specified in flags +) + +type flagFunc func(string) + +func (f flagFunc) String() string { return "" } +func (f flagFunc) Set(s string) error { f(s); return nil } + +func init() { + cmdEdit.Run = runEdit // break init cycle + + cmdEdit.Flag.Var(flagFunc(flagGodebug), "godebug", "") + cmdEdit.Flag.Var(flagFunc(flagDropGodebug), "dropgodebug", "") + cmdEdit.Flag.Var(flagFunc(flagRequire), "require", "") + cmdEdit.Flag.Var(flagFunc(flagDropRequire), "droprequire", "") + cmdEdit.Flag.Var(flagFunc(flagExclude), "exclude", "") + cmdEdit.Flag.Var(flagFunc(flagDropExclude), "dropexclude", "") + cmdEdit.Flag.Var(flagFunc(flagReplace), "replace", "") + cmdEdit.Flag.Var(flagFunc(flagDropReplace), "dropreplace", "") + cmdEdit.Flag.Var(flagFunc(flagRetract), "retract", "") + cmdEdit.Flag.Var(flagFunc(flagDropRetract), "dropretract", "") + cmdEdit.Flag.Var(flagFunc(flagTool), "tool", "") + cmdEdit.Flag.Var(flagFunc(flagDropTool), "droptool", "") + cmdEdit.Flag.Var(flagFunc(flagIgnore), "ignore", "") + cmdEdit.Flag.Var(flagFunc(flagDropIgnore), "dropignore", "") + + base.AddBuildFlagsNX(&cmdEdit.Flag) + base.AddChdirFlag(&cmdEdit.Flag) + base.AddModCommonFlags(&cmdEdit.Flag) +} + +func runEdit(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + anyFlags := *editModule != "" || + *editGo != "" || + *editToolchain != "" || + *editJSON || + *editPrint || + *editFmt || + len(edits) > 0 + + if !anyFlags { + base.Fatalf("go: no flags specified (see 'go help mod edit').") + } + + if *editJSON && *editPrint { + base.Fatalf("go: cannot use both -json and -print") + } + + if len(args) > 1 { + base.Fatalf("go: too many arguments") + } + var gomod string + if len(args) == 1 { + gomod = args[0] + } else { + gomod = moduleLoaderState.ModFilePath() + } + + if *editModule != "" { + err := module.CheckImportPath(*editModule) + if err == nil { + err = modload.CheckReservedModulePath(*editModule) + } + if err != nil { + base.Fatalf("go: invalid -module: %v", err) + } + } + + if *editGo != "" && *editGo != "none" { + if !modfile.GoVersionRE.MatchString(*editGo) { + base.Fatalf(`go mod: invalid -go option; expecting something like "-go %s"`, gover.Local()) + } + } + if *editToolchain != "" && *editToolchain != "none" { + if !modfile.ToolchainRE.MatchString(*editToolchain) { + base.Fatalf(`go mod: invalid -toolchain option; expecting something like "-toolchain go%s"`, gover.Local()) + } + } + + data, err := lockedfile.Read(gomod) + if err != nil { + base.Fatal(err) + } + + modFile, err := modfile.Parse(gomod, data, nil) + if err != nil { + base.Fatalf("go: errors parsing %s:\n%s", base.ShortPath(gomod), err) + } + + if *editModule != "" { + modFile.AddModuleStmt(*editModule) + } + + if *editGo == "none" { + modFile.DropGoStmt() + } else if *editGo != "" { + if err := modFile.AddGoStmt(*editGo); err != nil { + base.Fatalf("go: internal error: %v", err) + } + } + if *editToolchain == "none" { + modFile.DropToolchainStmt() + } else if *editToolchain != "" { + if err := modFile.AddToolchainStmt(*editToolchain); err != nil { + base.Fatalf("go: internal error: %v", err) + } + } + + if len(edits) > 0 { + for _, edit := range edits { + edit(modFile) + } + } + modFile.SortBlocks() + modFile.Cleanup() // clean file after edits + + if *editJSON { + editPrintJSON(modFile) + return + } + + out, err := modFile.Format() + if err != nil { + base.Fatal(err) + } + + if *editPrint { + os.Stdout.Write(out) + return + } + + // Make a best-effort attempt to acquire the side lock, only to exclude + // previous versions of the 'go' command from making simultaneous edits. + if unlock, err := modfetch.SideLock(ctx); err == nil { + defer unlock() + } + + err = lockedfile.Transform(gomod, func(lockedData []byte) ([]byte, error) { + if !bytes.Equal(lockedData, data) { + return nil, errors.New("go.mod changed during editing; not overwriting") + } + return out, nil + }) + if err != nil { + base.Fatal(err) + } +} + +// parsePathVersion parses -flag=arg expecting arg to be path@version. +func parsePathVersion(flag, arg string) (path, version string) { + before, after, found, err := modload.ParsePathVersion(arg) + if err != nil { + base.Fatalf("go: -%s=%s: %v", flag, arg, err) + } + if !found { + base.Fatalf("go: -%s=%s: need path@version", flag, arg) + } + path, version = strings.TrimSpace(before), strings.TrimSpace(after) + if err := module.CheckImportPath(path); err != nil { + base.Fatalf("go: -%s=%s: invalid path: %v", flag, arg, err) + } + + if !allowedVersionArg(version) { + base.Fatalf("go: -%s=%s: invalid version %q", flag, arg, version) + } + + return path, version +} + +// parsePath parses -flag=arg expecting arg to be path (not path@version). +func parsePath(flag, arg string) (path string) { + if strings.Contains(arg, "@") { + base.Fatalf("go: -%s=%s: need just path, not path@version", flag, arg) + } + path = arg + if err := module.CheckImportPath(path); err != nil { + base.Fatalf("go: -%s=%s: invalid path: %v", flag, arg, err) + } + return path +} + +// parsePathVersionOptional parses path[@version], using adj to +// describe any errors. +func parsePathVersionOptional(adj, arg string, allowDirPath bool) (path, version string, err error) { + if allowDirPath && modfile.IsDirectoryPath(arg) { + return arg, "", nil + } + before, after, found, err := modload.ParsePathVersion(arg) + if err != nil { + return "", "", err + } + if !found { + path = arg + } else { + path, version = strings.TrimSpace(before), strings.TrimSpace(after) + } + if err := module.CheckImportPath(path); err != nil { + return path, version, fmt.Errorf("invalid %s path: %v", adj, err) + } + if path != arg && !allowedVersionArg(version) { + return path, version, fmt.Errorf("invalid %s version: %q", adj, version) + } + return path, version, nil +} + +// parseVersionInterval parses a single version like "v1.2.3" or a closed +// interval like "[v1.2.3,v1.4.5]". Note that a single version has the same +// representation as an interval with equal upper and lower bounds: both +// Low and High are set. +func parseVersionInterval(arg string) (modfile.VersionInterval, error) { + if !strings.HasPrefix(arg, "[") { + if !allowedVersionArg(arg) { + return modfile.VersionInterval{}, fmt.Errorf("invalid version: %q", arg) + } + return modfile.VersionInterval{Low: arg, High: arg}, nil + } + if !strings.HasSuffix(arg, "]") { + return modfile.VersionInterval{}, fmt.Errorf("invalid version interval: %q", arg) + } + s := arg[1 : len(arg)-1] + before, after, found := strings.Cut(s, ",") + if !found { + return modfile.VersionInterval{}, fmt.Errorf("invalid version interval: %q", arg) + } + low := strings.TrimSpace(before) + high := strings.TrimSpace(after) + if !allowedVersionArg(low) || !allowedVersionArg(high) { + return modfile.VersionInterval{}, fmt.Errorf("invalid version interval: %q", arg) + } + return modfile.VersionInterval{Low: low, High: high}, nil +} + +// allowedVersionArg returns whether a token may be used as a version in go.mod. +// We don't call modfile.CheckPathVersion, because that insists on versions +// being in semver form, but here we want to allow versions like "master" or +// "1234abcdef", which the go command will resolve the next time it runs (or +// during -fix). Even so, we need to make sure the version is a valid token. +func allowedVersionArg(arg string) bool { + return !modfile.MustQuote(arg) +} + +// flagGodebug implements the -godebug flag. +func flagGodebug(arg string) { + key, value, ok := strings.Cut(arg, "=") + if !ok || strings.ContainsAny(arg, "\"`',") { + base.Fatalf("go: -godebug=%s: need key=value", arg) + } + edits = append(edits, func(f *modfile.File) { + if err := f.AddGodebug(key, value); err != nil { + base.Fatalf("go: -godebug=%s: %v", arg, err) + } + }) +} + +// flagDropGodebug implements the -dropgodebug flag. +func flagDropGodebug(arg string) { + edits = append(edits, func(f *modfile.File) { + if err := f.DropGodebug(arg); err != nil { + base.Fatalf("go: -dropgodebug=%s: %v", arg, err) + } + }) +} + +// flagRequire implements the -require flag. +func flagRequire(arg string) { + path, version := parsePathVersion("require", arg) + edits = append(edits, func(f *modfile.File) { + if err := f.AddRequire(path, version); err != nil { + base.Fatalf("go: -require=%s: %v", arg, err) + } + }) +} + +// flagDropRequire implements the -droprequire flag. +func flagDropRequire(arg string) { + path := parsePath("droprequire", arg) + edits = append(edits, func(f *modfile.File) { + if err := f.DropRequire(path); err != nil { + base.Fatalf("go: -droprequire=%s: %v", arg, err) + } + }) +} + +// flagExclude implements the -exclude flag. +func flagExclude(arg string) { + path, version := parsePathVersion("exclude", arg) + edits = append(edits, func(f *modfile.File) { + if err := f.AddExclude(path, version); err != nil { + base.Fatalf("go: -exclude=%s: %v", arg, err) + } + }) +} + +// flagDropExclude implements the -dropexclude flag. +func flagDropExclude(arg string) { + path, version := parsePathVersion("dropexclude", arg) + edits = append(edits, func(f *modfile.File) { + if err := f.DropExclude(path, version); err != nil { + base.Fatalf("go: -dropexclude=%s: %v", arg, err) + } + }) +} + +// flagReplace implements the -replace flag. +func flagReplace(arg string) { + before, after, found := strings.Cut(arg, "=") + if !found { + base.Fatalf("go: -replace=%s: need old[@v]=new[@w] (missing =)", arg) + } + old, new := strings.TrimSpace(before), strings.TrimSpace(after) + if strings.HasPrefix(new, ">") { + base.Fatalf("go: -replace=%s: separator between old and new is =, not =>", arg) + } + oldPath, oldVersion, err := parsePathVersionOptional("old", old, false) + if err != nil { + base.Fatalf("go: -replace=%s: %v", arg, err) + } + newPath, newVersion, err := parsePathVersionOptional("new", new, true) + if err != nil { + base.Fatalf("go: -replace=%s: %v", arg, err) + } + if newPath == new && !modfile.IsDirectoryPath(new) { + base.Fatalf("go: -replace=%s: unversioned new path must be local directory", arg) + } + + edits = append(edits, func(f *modfile.File) { + if err := f.AddReplace(oldPath, oldVersion, newPath, newVersion); err != nil { + base.Fatalf("go: -replace=%s: %v", arg, err) + } + }) +} + +// flagDropReplace implements the -dropreplace flag. +func flagDropReplace(arg string) { + path, version, err := parsePathVersionOptional("old", arg, true) + if err != nil { + base.Fatalf("go: -dropreplace=%s: %v", arg, err) + } + edits = append(edits, func(f *modfile.File) { + if err := f.DropReplace(path, version); err != nil { + base.Fatalf("go: -dropreplace=%s: %v", arg, err) + } + }) +} + +// flagRetract implements the -retract flag. +func flagRetract(arg string) { + vi, err := parseVersionInterval(arg) + if err != nil { + base.Fatalf("go: -retract=%s: %v", arg, err) + } + edits = append(edits, func(f *modfile.File) { + if err := f.AddRetract(vi, ""); err != nil { + base.Fatalf("go: -retract=%s: %v", arg, err) + } + }) +} + +// flagDropRetract implements the -dropretract flag. +func flagDropRetract(arg string) { + vi, err := parseVersionInterval(arg) + if err != nil { + base.Fatalf("go: -dropretract=%s: %v", arg, err) + } + edits = append(edits, func(f *modfile.File) { + if err := f.DropRetract(vi); err != nil { + base.Fatalf("go: -dropretract=%s: %v", arg, err) + } + }) +} + +// flagTool implements the -tool flag. +func flagTool(arg string) { + path := parsePath("tool", arg) + edits = append(edits, func(f *modfile.File) { + if err := f.AddTool(path); err != nil { + base.Fatalf("go: -tool=%s: %v", arg, err) + } + }) +} + +// flagDropTool implements the -droptool flag. +func flagDropTool(arg string) { + path := parsePath("droptool", arg) + edits = append(edits, func(f *modfile.File) { + if err := f.DropTool(path); err != nil { + base.Fatalf("go: -droptool=%s: %v", arg, err) + } + }) +} + +// flagIgnore implements the -ignore flag. +func flagIgnore(arg string) { + edits = append(edits, func(f *modfile.File) { + if err := f.AddIgnore(arg); err != nil { + base.Fatalf("go: -ignore=%s: %v", arg, err) + } + }) +} + +// flagDropIgnore implements the -dropignore flag. +func flagDropIgnore(arg string) { + edits = append(edits, func(f *modfile.File) { + if err := f.DropIgnore(arg); err != nil { + base.Fatalf("go: -dropignore=%s: %v", arg, err) + } + }) +} + +// fileJSON is the -json output data structure. +type fileJSON struct { + Module editModuleJSON + Go string `json:",omitempty"` + Toolchain string `json:",omitempty"` + GoDebug []debugJSON `json:",omitempty"` + Require []requireJSON + Exclude []module.Version + Replace []replaceJSON + Retract []retractJSON + Tool []toolJSON + Ignore []ignoreJSON +} + +type editModuleJSON struct { + Path string + Deprecated string `json:",omitempty"` +} + +type debugJSON struct { + Key string + Value string +} + +type requireJSON struct { + Path string + Version string `json:",omitempty"` + Indirect bool `json:",omitempty"` +} + +type replaceJSON struct { + Old module.Version + New module.Version +} + +type retractJSON struct { + Low string `json:",omitempty"` + High string `json:",omitempty"` + Rationale string `json:",omitempty"` +} + +type toolJSON struct { + Path string +} + +type ignoreJSON struct { + Path string +} + +// editPrintJSON prints the -json output. +func editPrintJSON(modFile *modfile.File) { + var f fileJSON + if modFile.Module != nil { + f.Module = editModuleJSON{ + Path: modFile.Module.Mod.Path, + Deprecated: modFile.Module.Deprecated, + } + } + if modFile.Go != nil { + f.Go = modFile.Go.Version + } + if modFile.Toolchain != nil { + f.Toolchain = modFile.Toolchain.Name + } + for _, r := range modFile.Require { + f.Require = append(f.Require, requireJSON{Path: r.Mod.Path, Version: r.Mod.Version, Indirect: r.Indirect}) + } + for _, x := range modFile.Exclude { + f.Exclude = append(f.Exclude, x.Mod) + } + for _, r := range modFile.Replace { + f.Replace = append(f.Replace, replaceJSON{r.Old, r.New}) + } + for _, r := range modFile.Retract { + f.Retract = append(f.Retract, retractJSON{r.Low, r.High, r.Rationale}) + } + for _, t := range modFile.Tool { + f.Tool = append(f.Tool, toolJSON{t.Path}) + } + for _, i := range modFile.Ignore { + f.Ignore = append(f.Ignore, ignoreJSON{i.Path}) + } + for _, d := range modFile.Godebug { + f.GoDebug = append(f.GoDebug, debugJSON{d.Key, d.Value}) + } + data, err := json.MarshalIndent(&f, "", "\t") + if err != nil { + base.Fatalf("go: internal error: %v", err) + } + data = append(data, '\n') + os.Stdout.Write(data) +} diff --git a/go/src/cmd/go/internal/modcmd/graph.go b/go/src/cmd/go/internal/modcmd/graph.go new file mode 100644 index 0000000000000000000000000000000000000000..307c6ee4b56f15bba0b0e8b18259aa22deb48931 --- /dev/null +++ b/go/src/cmd/go/internal/modcmd/graph.go @@ -0,0 +1,97 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// go mod graph + +package modcmd + +import ( + "bufio" + "context" + "os" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/modload" + "cmd/go/internal/toolchain" + + "golang.org/x/mod/module" +) + +var cmdGraph = &base.Command{ + UsageLine: "go mod graph [-go=version] [-x]", + Short: "print module requirement graph", + Long: ` +Graph prints the module requirement graph (with replacements applied) +in text form. Each line in the output has two space-separated fields: a module +and one of its requirements. Each module is identified as a string of the form +path@version, except for the main module, which has no @version suffix. + +The -go flag causes graph to report the module graph as loaded by the +given Go version, instead of the version indicated by the 'go' directive +in the go.mod file. + +The -x flag causes graph to print the commands graph executes. + +See https://golang.org/ref/mod#go-mod-graph for more about 'go mod graph'. + `, + Run: runGraph, +} + +var ( + graphGo goVersionFlag +) + +func init() { + cmdGraph.Flag.Var(&graphGo, "go", "") + cmdGraph.Flag.BoolVar(&cfg.BuildX, "x", false, "") + base.AddChdirFlag(&cmdGraph.Flag) + base.AddModCommonFlags(&cmdGraph.Flag) +} + +func runGraph(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + moduleLoaderState.InitWorkfile() + + if len(args) > 0 { + base.Fatalf("go: 'go mod graph' accepts no arguments") + } + moduleLoaderState.ForceUseModules = true + moduleLoaderState.RootMode = modload.NeedRoot + + goVersion := graphGo.String() + if goVersion != "" && gover.Compare(gover.Local(), goVersion) < 0 { + toolchain.SwitchOrFatal(moduleLoaderState, ctx, &gover.TooNewError{ + What: "-go flag", + GoVersion: goVersion, + }) + } + + mg, err := modload.LoadModGraph(moduleLoaderState, ctx, goVersion) + if err != nil { + base.Fatal(err) + } + + w := bufio.NewWriter(os.Stdout) + defer w.Flush() + + format := func(m module.Version) { + w.WriteString(m.Path) + if m.Version != "" { + w.WriteString("@") + w.WriteString(m.Version) + } + } + + mg.WalkBreadthFirst(func(m module.Version) { + reqs, _ := mg.RequiredBy(m) + for _, r := range reqs { + format(m) + w.WriteByte(' ') + format(r) + w.WriteByte('\n') + } + }) +} diff --git a/go/src/cmd/go/internal/modcmd/init.go b/go/src/cmd/go/internal/modcmd/init.go new file mode 100644 index 0000000000000000000000000000000000000000..e8db3d005f7c589a25f2c2c890f09eb83c669748 --- /dev/null +++ b/go/src/cmd/go/internal/modcmd/init.go @@ -0,0 +1,49 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// go mod init + +package modcmd + +import ( + "cmd/go/internal/base" + "cmd/go/internal/modload" + "context" +) + +var cmdInit = &base.Command{ + UsageLine: "go mod init [module-path]", + Short: "initialize new module in current directory", + Long: ` +Init initializes and writes a new go.mod file in the current directory, in +effect creating a new module rooted at the current directory. The go.mod file +must not already exist. + +Init accepts one optional argument, the module path for the new module. If the +module path argument is omitted, init will attempt to infer the module path +using import comments in .go files and the current directory (if in GOPATH). + +See https://golang.org/ref/mod#go-mod-init for more about 'go mod init'. +`, + Run: runInit, +} + +func init() { + base.AddChdirFlag(&cmdInit.Flag) + base.AddModCommonFlags(&cmdInit.Flag) +} + +func runInit(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + if len(args) > 1 { + base.Fatalf("go: 'go mod init' accepts at most one argument") + } + var modPath string + if len(args) == 1 { + modPath = args[0] + } + + moduleLoaderState.ForceUseModules = true + modload.CreateModFile(moduleLoaderState, ctx, modPath) // does all the hard work +} diff --git a/go/src/cmd/go/internal/modcmd/mod.go b/go/src/cmd/go/internal/modcmd/mod.go new file mode 100644 index 0000000000000000000000000000000000000000..125ba336a0edda95e7570253c5ec40b962a91c56 --- /dev/null +++ b/go/src/cmd/go/internal/modcmd/mod.go @@ -0,0 +1,33 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package modcmd implements the “go mod” command. +package modcmd + +import ( + "cmd/go/internal/base" +) + +var CmdMod = &base.Command{ + UsageLine: "go mod", + Short: "module maintenance", + Long: `Go mod provides access to operations on modules. + +Note that support for modules is built into all the go commands, +not just 'go mod'. For example, day-to-day adding, removing, upgrading, +and downgrading of dependencies should be done using 'go get'. +See 'go help modules' for an overview of module functionality. + `, + + Commands: []*base.Command{ + cmdDownload, + cmdEdit, + cmdGraph, + cmdInit, + cmdTidy, + cmdVendor, + cmdVerify, + cmdWhy, + }, +} diff --git a/go/src/cmd/go/internal/modcmd/tidy.go b/go/src/cmd/go/internal/modcmd/tidy.go new file mode 100644 index 0000000000000000000000000000000000000000..3ac0109625e67493b7a04050b9f1b417f65f020d --- /dev/null +++ b/go/src/cmd/go/internal/modcmd/tidy.go @@ -0,0 +1,147 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// go mod tidy + +package modcmd + +import ( + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/imports" + "cmd/go/internal/modload" + "cmd/go/internal/toolchain" + "context" + "fmt" + + "golang.org/x/mod/modfile" +) + +var cmdTidy = &base.Command{ + UsageLine: "go mod tidy [-e] [-v] [-x] [-diff] [-go=version] [-compat=version]", + Short: "add missing and remove unused modules", + Long: ` +Tidy makes sure go.mod matches the source code in the module. +It adds any missing modules necessary to build the current module's +packages and dependencies, and it removes unused modules that +don't provide any relevant packages. It also adds any missing entries +to go.sum and removes any unnecessary ones. + +The -v flag causes tidy to print information about removed modules +to standard error. + +The -e flag causes tidy to attempt to proceed despite errors +encountered while loading packages. + +The -diff flag causes tidy not to modify go.mod or go.sum but +instead print the necessary changes as a unified diff. It exits +with a non-zero code if the diff is not empty. + +The -go flag causes tidy to update the 'go' directive in the go.mod +file to the given version, which may change which module dependencies +are retained as explicit requirements in the go.mod file. +(Go versions 1.17 and higher retain more requirements in order to +support lazy module loading.) + +The -compat flag preserves any additional checksums needed for the +'go' command from the indicated major Go release to successfully load +the module graph, and causes tidy to error out if that version of the +'go' command would load any imported package from a different module +version. By default, tidy acts as if the -compat flag were set to the +version prior to the one indicated by the 'go' directive in the go.mod +file. + +The -x flag causes tidy to print the commands download executes. + +See https://golang.org/ref/mod#go-mod-tidy for more about 'go mod tidy'. + `, + Run: runTidy, +} + +var ( + tidyE bool // if true, report errors but proceed anyway. + tidyDiff bool // if true, do not update go.mod or go.sum and show changes. Return corresponding exit code. + tidyGo goVersionFlag // go version to write to the tidied go.mod file (toggles lazy loading) + tidyCompat goVersionFlag // go version for which the tidied go.mod and go.sum files should be “compatible” +) + +func init() { + cmdTidy.Flag.BoolVar(&cfg.BuildV, "v", false, "") + cmdTidy.Flag.BoolVar(&cfg.BuildX, "x", false, "") + cmdTidy.Flag.BoolVar(&tidyE, "e", false, "") + cmdTidy.Flag.BoolVar(&tidyDiff, "diff", false, "") + cmdTidy.Flag.Var(&tidyGo, "go", "") + cmdTidy.Flag.Var(&tidyCompat, "compat", "") + base.AddChdirFlag(&cmdTidy.Flag) + base.AddModCommonFlags(&cmdTidy.Flag) +} + +// A goVersionFlag is a flag.Value representing a supported Go version. +// +// (Note that the -go argument to 'go mod edit' is *not* a goVersionFlag. +// It intentionally allows newer-than-supported versions as arguments.) +type goVersionFlag struct { + v string +} + +func (f *goVersionFlag) String() string { return f.v } +func (f *goVersionFlag) Get() any { return f.v } + +func (f *goVersionFlag) Set(s string) error { + if s != "" { + latest := gover.Local() + if !modfile.GoVersionRE.MatchString(s) { + return fmt.Errorf("expecting a Go version like %q", latest) + } + if gover.Compare(s, latest) > 0 { + return fmt.Errorf("maximum supported Go version is %s", latest) + } + } + + f.v = s + return nil +} + +func runTidy(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + if len(args) > 0 { + base.Fatalf("go: 'go mod tidy' accepts no arguments") + } + + // Tidy aims to make 'go test' reproducible for any package in 'all', so we + // need to include test dependencies. For modules that specify go 1.15 or + // earlier this is a no-op (because 'all' saturates transitive test + // dependencies). + // + // However, with lazy loading (go 1.16+) 'all' includes only the packages that + // are transitively imported by the main module, not the test dependencies of + // those packages. In order to make 'go test' reproducible for the packages + // that are in 'all' but outside of the main module, we must explicitly + // request that their test dependencies be included. + moduleLoaderState.ForceUseModules = true + moduleLoaderState.RootMode = modload.NeedRoot + + goVersion := tidyGo.String() + if goVersion != "" && gover.Compare(gover.Local(), goVersion) < 0 { + toolchain.SwitchOrFatal(moduleLoaderState, ctx, &gover.TooNewError{ + What: "-go flag", + GoVersion: goVersion, + }) + } + + modload.LoadPackages(moduleLoaderState, ctx, modload.PackageOpts{ + TidyGoVersion: tidyGo.String(), + Tags: imports.AnyTags(), + Tidy: true, + TidyDiff: tidyDiff, + TidyCompatibleVersion: tidyCompat.String(), + VendorModulesInGOROOTSrc: true, + ResolveMissingImports: true, + LoadTests: true, + AllowErrors: tidyE, + SilenceMissingStdImports: true, + Switcher: toolchain.NewSwitcher(moduleLoaderState), + }, "all") +} diff --git a/go/src/cmd/go/internal/modcmd/vendor.go b/go/src/cmd/go/internal/modcmd/vendor.go new file mode 100644 index 0000000000000000000000000000000000000000..5782f4e79448c67edb114f494976fb8d549fc368 --- /dev/null +++ b/go/src/cmd/go/internal/modcmd/vendor.go @@ -0,0 +1,516 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modcmd + +import ( + "bytes" + "context" + "errors" + "fmt" + "go/build" + "io" + "io/fs" + "os" + "path" + "path/filepath" + "sort" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/fsys" + "cmd/go/internal/gover" + "cmd/go/internal/imports" + "cmd/go/internal/load" + "cmd/go/internal/modload" + "cmd/go/internal/str" + + "golang.org/x/mod/module" +) + +var cmdVendor = &base.Command{ + UsageLine: "go mod vendor [-e] [-v] [-o outdir]", + Short: "make vendored copy of dependencies", + Long: ` +Vendor resets the main module's vendor directory to include all packages +needed to build and test all the main module's packages. +It does not include test code for vendored packages. + +The -v flag causes vendor to print the names of vendored +modules and packages to standard error. + +The -e flag causes vendor to attempt to proceed despite errors +encountered while loading packages. + +The -o flag causes vendor to create the vendor directory at the given +path instead of "vendor". The go command can only use a vendor directory +named "vendor" within the module root directory, so this flag is +primarily useful for other tools. + +See https://golang.org/ref/mod#go-mod-vendor for more about 'go mod vendor'. + `, + Run: runVendor, +} + +var vendorE bool // if true, report errors but proceed anyway +var vendorO string // if set, overrides the default output directory + +func init() { + cmdVendor.Flag.BoolVar(&cfg.BuildV, "v", false, "") + cmdVendor.Flag.BoolVar(&vendorE, "e", false, "") + cmdVendor.Flag.StringVar(&vendorO, "o", "", "") + base.AddChdirFlag(&cmdVendor.Flag) + base.AddModCommonFlags(&cmdVendor.Flag) +} + +func runVendor(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + moduleLoaderState.InitWorkfile() + if modload.WorkFilePath(moduleLoaderState) != "" { + base.Fatalf("go: 'go mod vendor' cannot be run in workspace mode. Run 'go work vendor' to vendor the workspace or set 'GOWORK=off' to exit workspace mode.") + } + RunVendor(moduleLoaderState, ctx, vendorE, vendorO, args) +} + +func RunVendor(loaderstate *modload.State, ctx context.Context, vendorE bool, vendorO string, args []string) { + if len(args) != 0 { + base.Fatalf("go: 'go mod vendor' accepts no arguments") + } + loaderstate.ForceUseModules = true + loaderstate.RootMode = modload.NeedRoot + + loadOpts := modload.PackageOpts{ + Tags: imports.AnyTags(), + VendorModulesInGOROOTSrc: true, + ResolveMissingImports: true, + UseVendorAll: true, + AllowErrors: vendorE, + SilenceMissingStdImports: true, + } + _, pkgs := modload.LoadPackages(loaderstate, ctx, loadOpts, "all") + + var vdir string + switch { + case filepath.IsAbs(vendorO): + vdir = vendorO + case vendorO != "": + vdir = filepath.Join(base.Cwd(), vendorO) + default: + vdir = filepath.Join(modload.VendorDir(loaderstate)) + } + if err := os.RemoveAll(vdir); err != nil { + base.Fatal(err) + } + + modpkgs := make(map[module.Version][]string) + for _, pkg := range pkgs { + m := modload.PackageModule(pkg) + if m.Path == "" || loaderstate.MainModules.Contains(m.Path) { + continue + } + modpkgs[m] = append(modpkgs[m], pkg) + } + checkPathCollisions(modpkgs) + + includeAllReplacements := false + includeGoVersions := false + isExplicit := map[module.Version]bool{} + gv := loaderstate.MainModules.GoVersion(loaderstate) + if gover.Compare(gv, "1.14") >= 0 && (loaderstate.FindGoWork(base.Cwd()) != "" || modload.ModFile(loaderstate).Go != nil) { + // If the Go version is at least 1.14, annotate all explicit 'require' and + // 'replace' targets found in the go.mod file so that we can perform a + // stronger consistency check when -mod=vendor is set. + for _, m := range loaderstate.MainModules.Versions() { + if modFile := loaderstate.MainModules.ModFile(m); modFile != nil { + for _, r := range modFile.Require { + isExplicit[r.Mod] = true + } + } + + } + includeAllReplacements = true + } + if gover.Compare(gv, "1.17") >= 0 { + // If the Go version is at least 1.17, annotate all modules with their + // 'go' version directives. + includeGoVersions = true + } + + var vendorMods []module.Version + for m := range isExplicit { + vendorMods = append(vendorMods, m) + } + for m := range modpkgs { + if !isExplicit[m] { + vendorMods = append(vendorMods, m) + } + } + gover.ModSort(vendorMods) + + var ( + buf bytes.Buffer + w io.Writer = &buf + ) + if cfg.BuildV { + w = io.MultiWriter(&buf, os.Stderr) + } + + if loaderstate.MainModules.WorkFile() != nil { + fmt.Fprintf(w, "## workspace\n") + } + + replacementWritten := make(map[module.Version]bool) + for _, m := range vendorMods { + replacement := modload.Replacement(loaderstate, m) + line := moduleLine(m, replacement) + replacementWritten[m] = true + io.WriteString(w, line) + + goVersion := "" + if includeGoVersions { + goVersion = modload.ModuleInfo(loaderstate, ctx, m.Path).GoVersion + } + switch { + case isExplicit[m] && goVersion != "": + fmt.Fprintf(w, "## explicit; go %s\n", goVersion) + case isExplicit[m]: + io.WriteString(w, "## explicit\n") + case goVersion != "": + fmt.Fprintf(w, "## go %s\n", goVersion) + } + + pkgs := modpkgs[m] + sort.Strings(pkgs) + for _, pkg := range pkgs { + fmt.Fprintf(w, "%s\n", pkg) + vendorPkg(loaderstate, vdir, pkg) + } + } + + if includeAllReplacements { + // Record unused and wildcard replacements at the end of the modules.txt file: + // without access to the complete build list, the consumer of the vendor + // directory can't otherwise determine that those replacements had no effect. + for _, m := range loaderstate.MainModules.Versions() { + if workFile := loaderstate.MainModules.WorkFile(); workFile != nil { + for _, r := range workFile.Replace { + if replacementWritten[r.Old] { + // We already recorded this replacement. + continue + } + replacementWritten[r.Old] = true + + line := moduleLine(r.Old, r.New) + buf.WriteString(line) + if cfg.BuildV { + os.Stderr.WriteString(line) + } + } + } + if modFile := loaderstate.MainModules.ModFile(m); modFile != nil { + for _, r := range modFile.Replace { + if replacementWritten[r.Old] { + // We already recorded this replacement. + continue + } + replacementWritten[r.Old] = true + rNew := modload.Replacement(loaderstate, r.Old) + if rNew == (module.Version{}) { + // There is no replacement. Don't try to write it. + continue + } + + line := moduleLine(r.Old, rNew) + buf.WriteString(line) + if cfg.BuildV { + os.Stderr.WriteString(line) + } + } + } + } + } + + if buf.Len() == 0 { + fmt.Fprintf(os.Stderr, "go: no dependencies to vendor\n") + return + } + + if err := os.MkdirAll(vdir, 0777); err != nil { + base.Fatal(err) + } + + if err := os.WriteFile(filepath.Join(vdir, "modules.txt"), buf.Bytes(), 0666); err != nil { + base.Fatal(err) + } +} + +func moduleLine(m, r module.Version) string { + b := new(strings.Builder) + b.WriteString("# ") + b.WriteString(m.Path) + if m.Version != "" { + b.WriteString(" ") + b.WriteString(m.Version) + } + if r.Path != "" { + if str.HasFilePathPrefix(filepath.Clean(r.Path), "vendor") { + base.Fatalf("go: replacement path %s inside vendor directory", r.Path) + } + b.WriteString(" => ") + b.WriteString(r.Path) + if r.Version != "" { + b.WriteString(" ") + b.WriteString(r.Version) + } + } + b.WriteString("\n") + return b.String() +} + +func vendorPkg(s *modload.State, vdir, pkg string) { + src, realPath, _ := modload.Lookup(s, "", false, pkg) + if src == "" { + base.Errorf("internal error: no pkg for %s\n", pkg) + return + } + if realPath != pkg { + // TODO(#26904): Revisit whether this behavior still makes sense. + // This should actually be impossible today, because the import map is the + // identity function for packages outside of the standard library. + // + // Part of the purpose of the vendor directory is to allow the packages in + // the module to continue to build in GOPATH mode, and GOPATH-mode users + // won't know about replacement aliasing. How important is it to maintain + // compatibility? + fmt.Fprintf(os.Stderr, "warning: %s imported as both %s and %s; making two copies.\n", realPath, realPath, pkg) + } + + copiedFiles := make(map[string]bool) + dst := filepath.Join(vdir, pkg) + matcher := func(dir string, info fs.DirEntry) bool { + goVersion := s.MainModules.GoVersion(s) + return matchPotentialSourceFile(dir, info, goVersion) + } + copyDir(dst, src, matcher, copiedFiles) + if m := modload.PackageModule(realPath); m.Path != "" { + copyMetadata(m.Path, realPath, dst, src, copiedFiles) + } + + ctx := build.Default + ctx.UseAllFiles = true + bp, err := ctx.ImportDir(src, build.IgnoreVendor) + // Because UseAllFiles is set on the build.Context, it's possible ta get + // a MultiplePackageError on an otherwise valid package: the package could + // have different names for GOOS=windows and GOOS=mac for example. On the + // other hand if there's a NoGoError, the package might have source files + // specifying "//go:build ignore" those packages should be skipped because + // embeds from ignored files can't be used. + // TODO(#42504): Find a better way to avoid errors from ImportDir. We'll + // need to figure this out when we switch to PackagesAndErrors as per the + // TODO above. + var multiplePackageError *build.MultiplePackageError + var noGoError *build.NoGoError + if err != nil { + if errors.As(err, &noGoError) { + return // No source files in this package are built. Skip embeds in ignored files. + } else if !errors.As(err, &multiplePackageError) { // multiplePackageErrors are OK, but others are not. + base.Fatalf("internal error: failed to find embedded files of %s: %v\n", pkg, err) + } + } + var embedPatterns []string + if gover.Compare(s.MainModules.GoVersion(s), "1.22") >= 0 { + embedPatterns = bp.EmbedPatterns + } else { + // Maintain the behavior of https://github.com/golang/go/issues/63473 + // so that we continue to agree with older versions of the go command + // about the contents of vendor directories in existing modules + embedPatterns = str.StringList(bp.EmbedPatterns, bp.TestEmbedPatterns, bp.XTestEmbedPatterns) + } + embeds, err := load.ResolveEmbed(bp.Dir, embedPatterns) + if err != nil { + format := "go: resolving embeds in %s: %v\n" + if vendorE { + fmt.Fprintf(os.Stderr, format, pkg, err) + } else { + base.Errorf(format, pkg, err) + } + return + } + for _, embed := range embeds { + embedDst := filepath.Join(dst, embed) + if copiedFiles[embedDst] { + continue + } + + // Copy the file as is done by copyDir below. + err := func() error { + r, err := os.Open(filepath.Join(src, embed)) + if err != nil { + return err + } + if err := os.MkdirAll(filepath.Dir(embedDst), 0777); err != nil { + return err + } + w, err := os.Create(embedDst) + if err != nil { + return err + } + if _, err := io.Copy(w, r); err != nil { + return err + } + r.Close() + return w.Close() + }() + if err != nil { + if vendorE { + fmt.Fprintf(os.Stderr, "go: %v\n", err) + } else { + base.Error(err) + } + } + } +} + +type metakey struct { + modPath string + dst string +} + +var copiedMetadata = make(map[metakey]bool) + +// copyMetadata copies metadata files from parents of src to parents of dst, +// stopping after processing the src parent for modPath. +func copyMetadata(modPath, pkg, dst, src string, copiedFiles map[string]bool) { + for parent := 0; ; parent++ { + if copiedMetadata[metakey{modPath, dst}] { + break + } + copiedMetadata[metakey{modPath, dst}] = true + if parent > 0 { + copyDir(dst, src, matchMetadata, copiedFiles) + } + if modPath == pkg { + break + } + pkg = path.Dir(pkg) + dst = filepath.Dir(dst) + src = filepath.Dir(src) + } +} + +// metaPrefixes is the list of metadata file prefixes. +// Vendoring copies metadata files from parents of copied directories. +// Note that this list could be arbitrarily extended, and it is longer +// in other tools (such as godep or dep). By using this limited set of +// prefixes and also insisting on capitalized file names, we are trying +// to nudge people toward more agreement on the naming +// and also trying to avoid false positives. +var metaPrefixes = []string{ + "AUTHORS", + "CONTRIBUTORS", + "COPYLEFT", + "COPYING", + "COPYRIGHT", + "LEGAL", + "LICENSE", + "NOTICE", + "PATENTS", +} + +// matchMetadata reports whether info is a metadata file. +func matchMetadata(dir string, info fs.DirEntry) bool { + name := info.Name() + for _, p := range metaPrefixes { + if strings.HasPrefix(name, p) { + return true + } + } + return false +} + +// matchPotentialSourceFile reports whether info may be relevant to a build operation. +func matchPotentialSourceFile(dir string, info fs.DirEntry, goVersion string) bool { + if strings.HasSuffix(info.Name(), "_test.go") { + return false + } + if info.Name() == "go.mod" || info.Name() == "go.sum" { + if gover.Compare(goVersion, "1.17") >= 0 { + // As of Go 1.17, we strip go.mod and go.sum files from dependency modules. + // Otherwise, 'go' commands invoked within the vendor subtree may misidentify + // an arbitrary directory within the vendor tree as a module root. + // (See https://golang.org/issue/42970.) + return false + } + } + if strings.HasSuffix(info.Name(), ".go") { + f, err := fsys.Open(filepath.Join(dir, info.Name())) + if err != nil { + base.Fatal(err) + } + defer f.Close() + + content, err := imports.ReadImports(f, false, nil) + if err == nil && !imports.ShouldBuild(content, imports.AnyTags()) { + // The file is explicitly tagged "ignore", so it can't affect the build. + // Leave it out. + return false + } + return true + } + + // We don't know anything about this file, so optimistically assume that it is + // needed. + return true +} + +// copyDir copies all regular files satisfying match(info) from src to dst. +func copyDir(dst, src string, match func(dir string, info fs.DirEntry) bool, copiedFiles map[string]bool) { + files, err := os.ReadDir(src) + if err != nil { + base.Fatal(err) + } + if err := os.MkdirAll(dst, 0777); err != nil { + base.Fatal(err) + } + for _, file := range files { + if file.IsDir() || !file.Type().IsRegular() || !match(src, file) { + continue + } + copiedFiles[file.Name()] = true + r, err := os.Open(filepath.Join(src, file.Name())) + if err != nil { + base.Fatal(err) + } + dstPath := filepath.Join(dst, file.Name()) + copiedFiles[dstPath] = true + w, err := os.Create(dstPath) + if err != nil { + base.Fatal(err) + } + if _, err := io.Copy(w, r); err != nil { + base.Fatal(err) + } + r.Close() + if err := w.Close(); err != nil { + base.Fatal(err) + } + } +} + +// checkPathCollisions will fail if case-insensitive collisions are present. +// The reason why we do this check in go mod vendor is to keep consistency +// with go build. If modifying, consider changing load() in +// src/cmd/go/internal/load/pkg.go +func checkPathCollisions(modpkgs map[module.Version][]string) { + var foldPath = make(map[string]string, len(modpkgs)) + for m := range modpkgs { + fold := str.ToFold(m.Path) + if other := foldPath[fold]; other == "" { + foldPath[fold] = m.Path + } else if other != m.Path { + base.Fatalf("go.mod: case-insensitive import collision: %q and %q", m.Path, other) + } + } +} diff --git a/go/src/cmd/go/internal/modcmd/verify.go b/go/src/cmd/go/internal/modcmd/verify.go new file mode 100644 index 0000000000000000000000000000000000000000..d654ba26a4b57c4c61d7cfdfd0bad656b2520593 --- /dev/null +++ b/go/src/cmd/go/internal/modcmd/verify.go @@ -0,0 +1,144 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modcmd + +import ( + "bytes" + "context" + "errors" + "fmt" + "io/fs" + "os" + "runtime" + + "cmd/go/internal/base" + "cmd/go/internal/gover" + "cmd/go/internal/modfetch" + "cmd/go/internal/modload" + + "golang.org/x/mod/module" + "golang.org/x/mod/sumdb/dirhash" +) + +var cmdVerify = &base.Command{ + UsageLine: "go mod verify", + Short: "verify dependencies have expected content", + Long: ` +Verify checks that the dependencies of the current module, +which are stored in a local downloaded source cache, have not been +modified since being downloaded. If all the modules are unmodified, +verify prints "all modules verified." Otherwise it reports which +modules have been changed and causes 'go mod' to exit with a +non-zero status. + +See https://golang.org/ref/mod#go-mod-verify for more about 'go mod verify'. + `, + Run: runVerify, +} + +func init() { + base.AddChdirFlag(&cmdVerify.Flag) + base.AddModCommonFlags(&cmdVerify.Flag) +} + +func runVerify(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + moduleLoaderState.InitWorkfile() + + if len(args) != 0 { + // NOTE(rsc): Could take a module pattern. + base.Fatalf("go: verify takes no arguments") + } + moduleLoaderState.ForceUseModules = true + moduleLoaderState.RootMode = modload.NeedRoot + + // Only verify up to GOMAXPROCS zips at once. + type token struct{} + sem := make(chan token, runtime.GOMAXPROCS(0)) + + mg, err := modload.LoadModGraph(moduleLoaderState, ctx, "") + if err != nil { + base.Fatal(err) + } + mods := mg.BuildList() + // Use a slice of result channels, so that the output is deterministic. + errsChans := make([]<-chan []error, len(mods)) + + for i, mod := range mods { + sem <- token{} + errsc := make(chan []error, 1) + errsChans[i] = errsc + mod := mod // use a copy to avoid data races + go func() { + errsc <- verifyMod(moduleLoaderState, ctx, mod) + <-sem + }() + } + + ok := true + for _, errsc := range errsChans { + errs := <-errsc + for _, err := range errs { + base.Errorf("%s", err) + ok = false + } + } + if ok { + fmt.Printf("all modules verified\n") + } +} + +func verifyMod(loaderstate *modload.State, ctx context.Context, mod module.Version) []error { + if gover.IsToolchain(mod.Path) { + // "go" and "toolchain" have no disk footprint; nothing to verify. + return nil + } + if loaderstate.MainModules.Contains(mod.Path) { + return nil + } + var errs []error + zip, zipErr := modfetch.CachePath(ctx, mod, "zip") + if zipErr == nil { + _, zipErr = os.Stat(zip) + } + dir, dirErr := modfetch.DownloadDir(ctx, mod) + data, err := os.ReadFile(zip + "hash") + if err != nil { + if zipErr != nil && errors.Is(zipErr, fs.ErrNotExist) && + dirErr != nil && errors.Is(dirErr, fs.ErrNotExist) { + // Nothing downloaded yet. Nothing to verify. + return nil + } + errs = append(errs, fmt.Errorf("%s %s: missing ziphash: %v", mod.Path, mod.Version, err)) + return errs + } + h := string(bytes.TrimSpace(data)) + + if zipErr != nil && errors.Is(zipErr, fs.ErrNotExist) { + // ok + } else { + hZ, err := dirhash.HashZip(zip, dirhash.DefaultHash) + if err != nil { + errs = append(errs, fmt.Errorf("%s %s: %v", mod.Path, mod.Version, err)) + return errs + } else if hZ != h { + errs = append(errs, fmt.Errorf("%s %s: zip has been modified (%v)", mod.Path, mod.Version, zip)) + } + } + if dirErr != nil && errors.Is(dirErr, fs.ErrNotExist) { + // ok + } else { + hD, err := dirhash.HashDir(dir, mod.Path+"@"+mod.Version, dirhash.DefaultHash) + if err != nil { + + errs = append(errs, fmt.Errorf("%s %s: %v", mod.Path, mod.Version, err)) + return errs + } + if hD != h { + errs = append(errs, fmt.Errorf("%s %s: dir has been modified (%v)", mod.Path, mod.Version, dir)) + } + } + return errs +} diff --git a/go/src/cmd/go/internal/modcmd/why.go b/go/src/cmd/go/internal/modcmd/why.go new file mode 100644 index 0000000000000000000000000000000000000000..b52b9354c29c72ffdc41823ece7747ae1e73e2ee --- /dev/null +++ b/go/src/cmd/go/internal/modcmd/why.go @@ -0,0 +1,144 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modcmd + +import ( + "context" + "fmt" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/imports" + "cmd/go/internal/modload" +) + +var cmdWhy = &base.Command{ + UsageLine: "go mod why [-m] [-vendor] packages...", + Short: "explain why packages or modules are needed", + Long: ` +Why shows a shortest path in the import graph from the main module to +each of the listed packages. If the -m flag is given, why treats the +arguments as a list of modules and finds a path to any package in each +of the modules. + +By default, why queries the graph of packages matched by "go list all", +which includes tests for reachable packages. The -vendor flag causes why +to exclude tests of dependencies. + +The output is a sequence of stanzas, one for each package or module +name on the command line, separated by blank lines. Each stanza begins +with a comment line "# package" or "# module" giving the target +package or module. Subsequent lines give a path through the import +graph, one package per line. If the package or module is not +referenced from the main module, the stanza will display a single +parenthesized note indicating that fact. + +For example: + + $ go mod why golang.org/x/text/language golang.org/x/text/encoding + # golang.org/x/text/language + rsc.io/quote + rsc.io/sampler + golang.org/x/text/language + + # golang.org/x/text/encoding + (main module does not need package golang.org/x/text/encoding) + $ + +See https://golang.org/ref/mod#go-mod-why for more about 'go mod why'. + `, +} + +var ( + whyM = cmdWhy.Flag.Bool("m", false, "") + whyVendor = cmdWhy.Flag.Bool("vendor", false, "") +) + +func init() { + cmdWhy.Run = runWhy // break init cycle + base.AddChdirFlag(&cmdWhy.Flag) + base.AddModCommonFlags(&cmdWhy.Flag) +} + +func runWhy(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + moduleLoaderState.InitWorkfile() + moduleLoaderState.ForceUseModules = true + moduleLoaderState.RootMode = modload.NeedRoot + modload.ExplicitWriteGoMod = true // don't write go.mod in ListModules + + loadOpts := modload.PackageOpts{ + Tags: imports.AnyTags(), + VendorModulesInGOROOTSrc: true, + LoadTests: !*whyVendor, + SilencePackageErrors: true, + UseVendorAll: *whyVendor, + } + + if *whyM { + for _, arg := range args { + if strings.Contains(arg, "@") { + base.Fatalf("go: %s: 'go mod why' requires a module path, not a version query", arg) + } + } + + mods, err := modload.ListModules(moduleLoaderState, ctx, args, 0, "") + if err != nil { + base.Fatal(err) + } + + byModule := make(map[string][]string) + _, pkgs := modload.LoadPackages(moduleLoaderState, ctx, loadOpts, "all") + for _, path := range pkgs { + m := modload.PackageModule(path) + if m.Path != "" { + byModule[m.Path] = append(byModule[m.Path], path) + } + } + sep := "" + for _, m := range mods { + best := "" + bestDepth := 1000000000 + for _, path := range byModule[m.Path] { + d := modload.WhyDepth(path) + if d > 0 && d < bestDepth { + best = path + bestDepth = d + } + } + why := modload.Why(best) + if why == "" { + vendoring := "" + if *whyVendor { + vendoring = " to vendor" + } + why = "(main module does not need" + vendoring + " module " + m.Path + ")\n" + } + fmt.Printf("%s# %s\n%s", sep, m.Path, why) + sep = "\n" + } + } else { + // Resolve to packages. + matches, _ := modload.LoadPackages(moduleLoaderState, ctx, loadOpts, args...) + + modload.LoadPackages(moduleLoaderState, ctx, loadOpts, "all") // rebuild graph, from main module (not from named packages) + + sep := "" + for _, m := range matches { + for _, path := range m.Pkgs { + why := modload.Why(path) + if why == "" { + vendoring := "" + if *whyVendor { + vendoring = " to vendor" + } + why = "(main module does not need" + vendoring + " package " + path + ")\n" + } + fmt.Printf("%s# %s\n%s", sep, path, why) + sep = "\n" + } + } + } +} diff --git a/go/src/cmd/go/internal/modfetch/bootstrap.go b/go/src/cmd/go/internal/modfetch/bootstrap.go new file mode 100644 index 0000000000000000000000000000000000000000..e23669fb00c76b7bb5d6a1f20523051354f2f3f5 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/bootstrap.go @@ -0,0 +1,17 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build cmd_go_bootstrap + +package modfetch + +import "golang.org/x/mod/module" + +func useSumDB(mod module.Version) bool { + return false +} + +func lookupSumDB(mod module.Version) (string, []string, error) { + panic("bootstrap") +} diff --git a/go/src/cmd/go/internal/modfetch/cache.go b/go/src/cmd/go/internal/modfetch/cache.go new file mode 100644 index 0000000000000000000000000000000000000000..f035c359b13aec12017291bb098440df5ad730f1 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/cache.go @@ -0,0 +1,828 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modfetch + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "io/fs" + "math/rand" + "os" + "path/filepath" + "strconv" + "strings" + "sync" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/lockedfile" + "cmd/go/internal/modfetch/codehost" + "cmd/internal/par" + "cmd/internal/robustio" + "cmd/internal/telemetry/counter" + + "golang.org/x/mod/module" + "golang.org/x/mod/semver" +) + +func cacheDir(ctx context.Context, path string) (string, error) { + if err := checkCacheDir(ctx); err != nil { + return "", err + } + enc, err := module.EscapePath(path) + if err != nil { + return "", err + } + return filepath.Join(cfg.GOMODCACHE, "cache/download", enc, "/@v"), nil +} + +func CachePath(ctx context.Context, m module.Version, suffix string) (string, error) { + if gover.IsToolchain(m.Path) { + return "", ErrToolchain + } + dir, err := cacheDir(ctx, m.Path) + if err != nil { + return "", err + } + if !gover.ModIsValid(m.Path, m.Version) { + return "", fmt.Errorf("non-semver module version %q", m.Version) + } + if module.CanonicalVersion(m.Version) != m.Version { + return "", fmt.Errorf("non-canonical module version %q", m.Version) + } + encVer, err := module.EscapeVersion(m.Version) + if err != nil { + return "", err + } + return filepath.Join(dir, encVer+"."+suffix), nil +} + +// DownloadDir returns the directory to which m should have been downloaded. +// An error will be returned if the module path or version cannot be escaped. +// An error satisfying errors.Is(err, fs.ErrNotExist) will be returned +// along with the directory if the directory does not exist or if the directory +// is not completely populated. +func DownloadDir(ctx context.Context, m module.Version) (string, error) { + if gover.IsToolchain(m.Path) { + return "", ErrToolchain + } + if err := checkCacheDir(ctx); err != nil { + return "", err + } + enc, err := module.EscapePath(m.Path) + if err != nil { + return "", err + } + if !gover.ModIsValid(m.Path, m.Version) { + return "", fmt.Errorf("non-semver module version %q", m.Version) + } + if module.CanonicalVersion(m.Version) != m.Version { + return "", fmt.Errorf("non-canonical module version %q", m.Version) + } + encVer, err := module.EscapeVersion(m.Version) + if err != nil { + return "", err + } + + // Check whether the directory itself exists. + dir := filepath.Join(cfg.GOMODCACHE, enc+"@"+encVer) + if fi, err := os.Stat(dir); os.IsNotExist(err) { + return dir, err + } else if err != nil { + return dir, &DownloadDirPartialError{dir, err} + } else if !fi.IsDir() { + return dir, &DownloadDirPartialError{dir, errors.New("not a directory")} + } + + // Check if a .partial file exists. This is created at the beginning of + // a download and removed after the zip is extracted. + partialPath, err := CachePath(ctx, m, "partial") + if err != nil { + return dir, err + } + if _, err := os.Stat(partialPath); err == nil { + return dir, &DownloadDirPartialError{dir, errors.New("not completely extracted")} + } else if !os.IsNotExist(err) { + return dir, err + } + + // Special case: ziphash is not required for the golang.org/fips140 module, + // because it is unpacked from a file in GOROOT, not downloaded. + // We've already checked that it's not a partial unpacking, so we're happy. + if m.Path == "golang.org/fips140" { + return dir, nil + } + + // Check if a .ziphash file exists. It should be created before the + // zip is extracted, but if it was deleted (by another program?), we need + // to re-calculate it. Note that checkMod will repopulate the ziphash + // file if it doesn't exist, but if the module is excluded by checks + // through GONOSUMDB or GOPRIVATE, that check and repopulation won't happen. + ziphashPath, err := CachePath(ctx, m, "ziphash") + if err != nil { + return dir, err + } + if _, err := os.Stat(ziphashPath); os.IsNotExist(err) { + return dir, &DownloadDirPartialError{dir, errors.New("ziphash file is missing")} + } else if err != nil { + return dir, err + } + return dir, nil +} + +// DownloadDirPartialError is returned by DownloadDir if a module directory +// exists but was not completely populated. +// +// DownloadDirPartialError is equivalent to fs.ErrNotExist. +type DownloadDirPartialError struct { + Dir string + Err error +} + +func (e *DownloadDirPartialError) Error() string { return fmt.Sprintf("%s: %v", e.Dir, e.Err) } +func (e *DownloadDirPartialError) Is(err error) bool { return err == fs.ErrNotExist } + +// lockVersion locks a file within the module cache that guards the downloading +// and extraction of the zipfile for the given module version. +func lockVersion(ctx context.Context, mod module.Version) (unlock func(), err error) { + path, err := CachePath(ctx, mod, "lock") + if err != nil { + return nil, err + } + if err := os.MkdirAll(filepath.Dir(path), 0o777); err != nil { + return nil, err + } + return lockedfile.MutexAt(path).Lock() +} + +// SideLock locks a file within the module cache that previously guarded +// edits to files outside the cache, such as go.sum and go.mod files in the +// user's working directory. +// If err is nil, the caller MUST eventually call the unlock function. +func SideLock(ctx context.Context) (unlock func(), err error) { + if err := checkCacheDir(ctx); err != nil { + return nil, err + } + + path := filepath.Join(cfg.GOMODCACHE, "cache", "lock") + if err := os.MkdirAll(filepath.Dir(path), 0o777); err != nil { + return nil, fmt.Errorf("failed to create cache directory: %w", err) + } + + return lockedfile.MutexAt(path).Lock() +} + +// A cachingRepo is a cache around an underlying Repo, +// avoiding redundant calls to ModulePath, Versions, Stat, Latest, and GoMod (but not CheckReuse or Zip). +// It is also safe for simultaneous use by multiple goroutines +// (so that it can be returned from Lookup multiple times). +// It serializes calls to the underlying Repo. +type cachingRepo struct { + path string + versionsCache par.ErrCache[string, *Versions] + statCache par.ErrCache[string, *RevInfo] + latestCache par.ErrCache[struct{}, *RevInfo] + gomodCache par.ErrCache[string, []byte] + + once sync.Once + initRepo func(context.Context) (Repo, error) + r Repo + fetcher *Fetcher +} + +func newCachingRepo(ctx context.Context, fetcher *Fetcher, path string, initRepo func(context.Context) (Repo, error)) *cachingRepo { + return &cachingRepo{ + path: path, + initRepo: initRepo, + fetcher: fetcher, + } +} + +func (r *cachingRepo) repo(ctx context.Context) Repo { + r.once.Do(func() { + var err error + r.r, err = r.initRepo(ctx) + if err != nil { + r.r = errRepo{r.path, err} + } + }) + return r.r +} + +func (r *cachingRepo) CheckReuse(ctx context.Context, old *codehost.Origin) error { + return r.repo(ctx).CheckReuse(ctx, old) +} + +func (r *cachingRepo) ModulePath() string { + return r.path +} + +func (r *cachingRepo) Versions(ctx context.Context, prefix string) (*Versions, error) { + v, err := r.versionsCache.Do(prefix, func() (*Versions, error) { + return r.repo(ctx).Versions(ctx, prefix) + }) + if err != nil { + return nil, err + } + return &Versions{ + Origin: v.Origin, + List: append([]string(nil), v.List...), + }, nil +} + +type cachedInfo struct { + info *RevInfo + err error +} + +func (r *cachingRepo) Stat(ctx context.Context, rev string) (*RevInfo, error) { + if gover.IsToolchain(r.path) { + // Skip disk cache; the underlying golang.org/toolchain repo is cached instead. + return r.repo(ctx).Stat(ctx, rev) + } + info, err := r.statCache.Do(rev, func() (*RevInfo, error) { + file, info, err := readDiskStat(ctx, r.path, rev) + if err == nil { + return info, err + } + + info, err = r.repo(ctx).Stat(ctx, rev) + if err == nil { + // If we resolved, say, 1234abcde to v0.0.0-20180604122334-1234abcdef78, + // then save the information under the proper version, for future use. + if info.Version != rev { + file, _ = CachePath(ctx, module.Version{Path: r.path, Version: info.Version}, "info") + r.statCache.Do(info.Version, func() (*RevInfo, error) { + return info, nil + }) + } + + if err := writeDiskStat(ctx, file, info); err != nil { + fmt.Fprintf(os.Stderr, "go: writing stat cache: %v\n", err) + } + } + return info, err + }) + if info != nil { + copy := *info + info = © + } + return info, err +} + +func (r *cachingRepo) Latest(ctx context.Context) (*RevInfo, error) { + if gover.IsToolchain(r.path) { + // Skip disk cache; the underlying golang.org/toolchain repo is cached instead. + return r.repo(ctx).Latest(ctx) + } + info, err := r.latestCache.Do(struct{}{}, func() (*RevInfo, error) { + info, err := r.repo(ctx).Latest(ctx) + + // Save info for likely future Stat call. + if err == nil { + r.statCache.Do(info.Version, func() (*RevInfo, error) { + return info, nil + }) + if file, _, err := readDiskStat(ctx, r.path, info.Version); err != nil { + writeDiskStat(ctx, file, info) + } + } + + return info, err + }) + if info != nil { + copy := *info + info = © + } + return info, err +} + +func (r *cachingRepo) GoMod(ctx context.Context, version string) ([]byte, error) { + if gover.IsToolchain(r.path) { + // Skip disk cache; the underlying golang.org/toolchain repo is cached instead. + return r.repo(ctx).GoMod(ctx, version) + } + text, err := r.gomodCache.Do(version, func() ([]byte, error) { + file, text, err := r.fetcher.readDiskGoMod(ctx, r.path, version) + if err == nil { + // Note: readDiskGoMod already called checkGoMod. + return text, nil + } + + text, err = r.repo(ctx).GoMod(ctx, version) + if err == nil { + if err := checkGoMod(r.fetcher, r.path, version, text); err != nil { + return text, err + } + if err := writeDiskGoMod(ctx, file, text); err != nil { + fmt.Fprintf(os.Stderr, "go: writing go.mod cache: %v\n", err) + } + } + return text, err + }) + if err != nil { + return nil, err + } + return append([]byte(nil), text...), nil +} + +func (r *cachingRepo) Zip(ctx context.Context, dst io.Writer, version string) error { + if gover.IsToolchain(r.path) { + return ErrToolchain + } + return r.repo(ctx).Zip(ctx, dst, version) +} + +// InfoFile is like Lookup(ctx, path).Stat(version) but also returns the name of the file +// containing the cached information. +func (f *Fetcher) InfoFile(ctx context.Context, path, version string) (*RevInfo, string, error) { + if !gover.ModIsValid(path, version) { + return nil, "", fmt.Errorf("invalid version %q", version) + } + + if file, info, err := readDiskStat(ctx, path, version); err == nil { + return info, file, nil + } + + var info *RevInfo + var err2info map[error]*RevInfo + err := TryProxies(func(proxy string) error { + i, err := f.Lookup(ctx, proxy, path).Stat(ctx, version) + if err == nil { + info = i + } else { + if err2info == nil { + err2info = make(map[error]*RevInfo) + } + err2info[err] = info + } + return err + }) + if err != nil { + return err2info[err], "", err + } + + // Stat should have populated the disk cache for us. + file, err := CachePath(ctx, module.Version{Path: path, Version: version}, "info") + if err != nil { + return nil, "", err + } + return info, file, nil +} + +// GoMod is like Lookup(ctx, path).GoMod(rev) but avoids the +// repository path resolution in Lookup if the result is +// already cached on local disk. +func (f *Fetcher) GoMod(ctx context.Context, path, rev string) ([]byte, error) { + // Convert commit hash to pseudo-version + // to increase cache hit rate. + if !gover.ModIsValid(path, rev) { + if _, info, err := readDiskStat(ctx, path, rev); err == nil { + rev = info.Version + } else { + if errors.Is(err, statCacheErr) { + return nil, err + } + err := TryProxies(func(proxy string) error { + info, err := f.Lookup(ctx, proxy, path).Stat(ctx, rev) + if err == nil { + rev = info.Version + } + return err + }) + if err != nil { + return nil, err + } + } + } + + _, data, err := f.readDiskGoMod(ctx, path, rev) + if err == nil { + return data, nil + } + + err = TryProxies(func(proxy string) (err error) { + data, err = f.Lookup(ctx, proxy, path).GoMod(ctx, rev) + return err + }) + return data, err +} + +// GoModFile is like GoMod but returns the name of the file containing +// the cached information. +func (f *Fetcher) GoModFile(ctx context.Context, path, version string) (string, error) { + if !gover.ModIsValid(path, version) { + return "", fmt.Errorf("invalid version %q", version) + } + if _, err := f.GoMod(ctx, path, version); err != nil { + return "", err + } + // GoMod should have populated the disk cache for us. + file, err := CachePath(ctx, module.Version{Path: path, Version: version}, "mod") + if err != nil { + return "", err + } + return file, nil +} + +// GoModSum returns the go.sum entry for the module version's go.mod file. +// (That is, it returns the entry listed in go.sum as "path version/go.mod".) +func (f *Fetcher) GoModSum(ctx context.Context, path, version string) (string, error) { + if !gover.ModIsValid(path, version) { + return "", fmt.Errorf("invalid version %q", version) + } + data, err := f.GoMod(ctx, path, version) + if err != nil { + return "", err + } + sum, err := goModSum(data) + if err != nil { + return "", err + } + return sum, nil +} + +var errNotCached = fmt.Errorf("not in cache") + +// readDiskStat reads a cached stat result from disk, +// returning the name of the cache file and the result. +// If the read fails, the caller can use +// writeDiskStat(file, info) to write a new cache entry. +func readDiskStat(ctx context.Context, path, rev string) (file string, info *RevInfo, err error) { + if gover.IsToolchain(path) { + return "", nil, errNotCached + } + file, data, err := readDiskCache(ctx, path, rev, "info") + if err != nil { + // If the cache already contains a pseudo-version with the given hash, we + // would previously return that pseudo-version without checking upstream. + // However, that produced an unfortunate side-effect: if the author added a + // tag to the repository, 'go get' would not pick up the effect of that new + // tag on the existing commits, and 'go' commands that referred to those + // commits would use the previous name instead of the new one. + // + // That's especially problematic if the original pseudo-version starts with + // v0.0.0-, as was the case for all pseudo-versions during vgo development, + // since a v0.0.0- pseudo-version has lower precedence than pretty much any + // tagged version. + // + // In practice, we're only looking up by hash during initial conversion of a + // legacy config and during an explicit 'go get', and a little extra latency + // for those operations seems worth the benefit of picking up more accurate + // versions. + // + // Fall back to this resolution scheme only if the GOPROXY setting prohibits + // us from resolving upstream tags. + if cfg.GOPROXY == "off" { + if file, info, err := readDiskStatByHash(ctx, path, rev); err == nil { + return file, info, nil + } + } + return file, nil, err + } + info = new(RevInfo) + if err := json.Unmarshal(data, info); err != nil { + return file, nil, errNotCached + } + // The disk might have stale .info files that have Name and Short fields set. + // We want to canonicalize to .info files with those fields omitted. + // Remarshal and update the cache file if needed. + data2, err := json.Marshal(info) + if err == nil && !bytes.Equal(data2, data) { + writeDiskCache(ctx, file, data) + } + return file, info, nil +} + +// readDiskStatByHash is a fallback for readDiskStat for the case +// where rev is a commit hash instead of a proper semantic version. +// In that case, we look for a cached pseudo-version that matches +// the commit hash. If we find one, we use it. +// This matters most for converting legacy package management +// configs, when we are often looking up commits by full hash. +// Without this check we'd be doing network I/O to the remote repo +// just to find out about a commit we already know about +// (and have cached under its pseudo-version). +func readDiskStatByHash(ctx context.Context, path, rev string) (file string, info *RevInfo, err error) { + if gover.IsToolchain(path) { + return "", nil, errNotCached + } + if cfg.GOMODCACHE == "" { + // Do not download to current directory. + return "", nil, errNotCached + } + + if !codehost.AllHex(rev) || len(rev) < 12 { + return "", nil, errNotCached + } + rev = rev[:12] + cdir, err := cacheDir(ctx, path) + if err != nil { + return "", nil, errNotCached + } + dir, err := os.Open(cdir) + if err != nil { + return "", nil, errNotCached + } + names, err := dir.Readdirnames(-1) + dir.Close() + if err != nil { + return "", nil, errNotCached + } + + // A given commit hash may map to more than one pseudo-version, + // depending on which tags are present on the repository. + // Take the highest such version. + var maxVersion string + suffix := "-" + rev + ".info" + err = errNotCached + for _, name := range names { + if strings.HasSuffix(name, suffix) { + v := strings.TrimSuffix(name, ".info") + if module.IsPseudoVersion(v) && semver.Compare(v, maxVersion) > 0 { + maxVersion = v + file, info, err = readDiskStat(ctx, path, strings.TrimSuffix(name, ".info")) + } + } + } + return file, info, err +} + +// oldVgoPrefix is the prefix in the old auto-generated cached go.mod files. +// We stopped trying to auto-generate the go.mod files. Now we use a trivial +// go.mod with only a module line, and we've dropped the version prefix +// entirely. If we see a version prefix, that means we're looking at an old copy +// and should ignore it. +var oldVgoPrefix = []byte("//vgo 0.0.") + +// readDiskGoMod reads a cached go.mod file from disk, +// returning the name of the cache file and the result. +// If the read fails, the caller can use +// writeDiskGoMod(file, data) to write a new cache entry. +func (f *Fetcher) readDiskGoMod(ctx context.Context, path, rev string) (file string, data []byte, err error) { + if gover.IsToolchain(path) { + return "", nil, errNotCached + } + file, data, err = readDiskCache(ctx, path, rev, "mod") + + // If the file has an old auto-conversion prefix, pretend it's not there. + if bytes.HasPrefix(data, oldVgoPrefix) { + err = errNotCached + data = nil + } + + if err == nil { + if err := checkGoMod(f, path, rev, data); err != nil { + return "", nil, err + } + } + + return file, data, err +} + +// readDiskCache is the generic "read from a cache file" implementation. +// It takes the revision and an identifying suffix for the kind of data being cached. +// It returns the name of the cache file and the content of the file. +// If the read fails, the caller can use +// writeDiskCache(file, data) to write a new cache entry. +func readDiskCache(ctx context.Context, path, rev, suffix string) (file string, data []byte, err error) { + if gover.IsToolchain(path) { + return "", nil, errNotCached + } + file, err = CachePath(ctx, module.Version{Path: path, Version: rev}, suffix) + if err != nil { + return "", nil, errNotCached + } + data, err = robustio.ReadFile(file) + if err != nil { + return file, nil, errNotCached + } + return file, data, nil +} + +// writeDiskStat writes a stat result cache entry. +// The file name must have been returned by a previous call to readDiskStat. +func writeDiskStat(ctx context.Context, file string, info *RevInfo) error { + if file == "" { + return nil + } + + if info.Origin != nil { + // Clean the origin information, which might have too many + // validation criteria, for example if we are saving the result of + // m@master as m@pseudo-version. + clean := *info + info = &clean + o := *info.Origin + info.Origin = &o + + // Tags and RepoSum never matter if you are starting with a semver version, + // as we would be when finding this cache entry. + o.TagSum = "" + o.TagPrefix = "" + o.RepoSum = "" + // Ref doesn't matter if you have a pseudoversion. + if module.IsPseudoVersion(info.Version) { + o.Ref = "" + } + } + + js, err := json.Marshal(info) + if err != nil { + return err + } + return writeDiskCache(ctx, file, js) +} + +// writeDiskGoMod writes a go.mod cache entry. +// The file name must have been returned by a previous call to readDiskGoMod. +func writeDiskGoMod(ctx context.Context, file string, text []byte) error { + return writeDiskCache(ctx, file, text) +} + +// writeDiskCache is the generic "write to a cache file" implementation. +// The file must have been returned by a previous call to readDiskCache. +func writeDiskCache(ctx context.Context, file string, data []byte) error { + if file == "" { + return nil + } + // Make sure directory for file exists. + if err := os.MkdirAll(filepath.Dir(file), 0o777); err != nil { + return err + } + + // Write the file to a temporary location, and then rename it to its final + // path to reduce the likelihood of a corrupt file existing at that final path. + f, err := tempFile(ctx, filepath.Dir(file), filepath.Base(file), 0o666) + if err != nil { + return err + } + defer func() { + // Only call os.Remove on f.Name() if we failed to rename it: otherwise, + // some other process may have created a new file with the same name after + // the rename completed. + if err != nil { + f.Close() + os.Remove(f.Name()) + } + }() + + if _, err := f.Write(data); err != nil { + return err + } + if err := f.Close(); err != nil { + return err + } + if err := robustio.Rename(f.Name(), file); err != nil { + return err + } + + if strings.HasSuffix(file, ".mod") { + rewriteVersionList(ctx, filepath.Dir(file)) + } + return nil +} + +// tempFile creates a new temporary file with given permission bits. +func tempFile(ctx context.Context, dir, prefix string, perm fs.FileMode) (f *os.File, err error) { + for i := 0; i < 10000; i++ { + name := filepath.Join(dir, prefix+strconv.Itoa(rand.Intn(1000000000))+".tmp") + f, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, perm) + if os.IsExist(err) { + if ctx.Err() != nil { + return nil, ctx.Err() + } + continue + } + break + } + return +} + +// rewriteVersionList rewrites the version list in dir +// after a new *.mod file has been written. +func rewriteVersionList(ctx context.Context, dir string) (err error) { + if filepath.Base(dir) != "@v" { + base.Fatalf("go: internal error: misuse of rewriteVersionList") + } + + listFile := filepath.Join(dir, "list") + + // Lock listfile when writing to it to try to avoid corruption to the file. + // Under rare circumstances, for instance, if the system loses power in the + // middle of a write it is possible for corrupt data to be written. This is + // not a problem for the go command itself, but may be an issue if the + // cache is being served by a GOPROXY HTTP server. This will be corrected + // the next time a new version of the module is fetched and the file is rewritten. + // TODO(matloob): golang.org/issue/43313 covers adding a go mod verify + // command that removes module versions that fail checksums. It should also + // remove list files that are detected to be corrupt. + f, err := lockedfile.Edit(listFile) + if err != nil { + return err + } + defer func() { + if cerr := f.Close(); cerr != nil && err == nil { + err = cerr + } + }() + infos, err := os.ReadDir(dir) + if err != nil { + return err + } + var list []string + for _, info := range infos { + // We look for *.mod files on the theory that if we can't supply + // the .mod file then there's no point in listing that version, + // since it's unusable. (We can have *.info without *.mod.) + // We don't require *.zip files on the theory that for code only + // involved in module graph construction, many *.zip files + // will never be requested. + name := info.Name() + if v, found := strings.CutSuffix(name, ".mod"); found { + if v != "" && module.CanonicalVersion(v) == v { + list = append(list, v) + } + } + } + semver.Sort(list) + + var buf bytes.Buffer + for _, v := range list { + buf.WriteString(v) + buf.WriteString("\n") + } + if fi, err := f.Stat(); err == nil && int(fi.Size()) == buf.Len() { + old := make([]byte, buf.Len()+1) + if n, err := f.ReadAt(old, 0); err == io.EOF && n == buf.Len() && bytes.Equal(buf.Bytes(), old) { + return nil // No edit needed. + } + } + // Remove existing contents, so that when we truncate to the actual size it will zero-fill, + // and we will be able to detect (some) incomplete writes as files containing trailing NUL bytes. + if err := f.Truncate(0); err != nil { + return err + } + // Reserve the final size and zero-fill. + if err := f.Truncate(int64(buf.Len())); err != nil { + return err + } + // Write the actual contents. If this fails partway through, + // the remainder of the file should remain as zeroes. + if _, err := f.Write(buf.Bytes()); err != nil { + f.Truncate(0) + return err + } + + return nil +} + +var ( + statCacheOnce sync.Once + statCacheErr error + + counterErrorsGOMODCACHEEntryRelative = counter.New("go/errors:gomodcache-entry-relative") +) + +// checkCacheDir checks if the directory specified by GOMODCACHE exists. An +// error is returned if it does not. +func checkCacheDir(ctx context.Context) error { + if cfg.GOMODCACHE == "" { + // modload.Init exits if GOPATH[0] is empty, and cfg.GOMODCACHE + // is set to GOPATH[0]/pkg/mod if GOMODCACHE is empty, so this should never happen. + return fmt.Errorf("module cache not found: neither GOMODCACHE nor GOPATH is set") + } + if !filepath.IsAbs(cfg.GOMODCACHE) { + counterErrorsGOMODCACHEEntryRelative.Inc() + return fmt.Errorf("GOMODCACHE entry is relative; must be absolute path: %q.\n", cfg.GOMODCACHE) + } + + // os.Stat is slow on Windows, so we only call it once to prevent unnecessary + // I/O every time this function is called. + statCacheOnce.Do(func() { + fi, err := os.Stat(cfg.GOMODCACHE) + if err != nil { + if !os.IsNotExist(err) { + statCacheErr = fmt.Errorf("could not create module cache: %w", err) + return + } + if err := os.MkdirAll(cfg.GOMODCACHE, 0o777); err != nil { + statCacheErr = fmt.Errorf("could not create module cache: %w", err) + return + } + return + } + if !fi.IsDir() { + statCacheErr = fmt.Errorf("could not create module cache: %q is not a directory", cfg.GOMODCACHE) + return + } + }) + return statCacheErr +} diff --git a/go/src/cmd/go/internal/modfetch/cache_test.go b/go/src/cmd/go/internal/modfetch/cache_test.go new file mode 100644 index 0000000000000000000000000000000000000000..578615ae330cb699249d0317726a6e1e3efd2e5e --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/cache_test.go @@ -0,0 +1,21 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modfetch + +import ( + "context" + "path/filepath" + "testing" +) + +func TestWriteDiskCache(t *testing.T) { + ctx := context.Background() + + tmpdir := t.TempDir() + err := writeDiskCache(ctx, filepath.Join(tmpdir, "file"), []byte("data")) + if err != nil { + t.Fatal(err) + } +} diff --git a/go/src/cmd/go/internal/modfetch/codehost/codehost.go b/go/src/cmd/go/internal/modfetch/codehost/codehost.go new file mode 100644 index 0000000000000000000000000000000000000000..08b1216d6bfa29403e041158594ecc9967b474a3 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/codehost/codehost.go @@ -0,0 +1,391 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package codehost defines the interface implemented by a code hosting source, +// along with support code for use by implementations. +package codehost + +import ( + "bytes" + "context" + "crypto/sha256" + "fmt" + "io" + "io/fs" + "os" + "os/exec" + "path/filepath" + "strings" + "sync" + "time" + + "cmd/go/internal/cfg" + "cmd/go/internal/lockedfile" + "cmd/go/internal/str" + + "golang.org/x/mod/module" + "golang.org/x/mod/semver" +) + +// Downloaded size limits. +const ( + MaxGoMod = 16 << 20 // maximum size of go.mod file + MaxLICENSE = 16 << 20 // maximum size of LICENSE file + MaxZipFile = 500 << 20 // maximum size of downloaded zip file +) + +// A Repo represents a code hosting source. +// Typical implementations include local version control repositories, +// remote version control servers, and code hosting sites. +// +// A Repo must be safe for simultaneous use by multiple goroutines, +// and callers must not modify returned values, which may be cached and shared. +type Repo interface { + // CheckReuse checks whether the old origin information + // remains up to date. If so, whatever cached object it was + // taken from can be reused. + // The subdir gives subdirectory name where the module root is expected to be found, + // "" for the root or "sub/dir" for a subdirectory (no trailing slash). + CheckReuse(ctx context.Context, old *Origin, subdir string) error + + // Tags lists all tags with the given prefix. + Tags(ctx context.Context, prefix string) (*Tags, error) + + // Stat returns information about the revision rev. + // A revision can be any identifier known to the underlying service: + // commit hash, branch, tag, and so on. + Stat(ctx context.Context, rev string) (*RevInfo, error) + + // Latest returns the latest revision on the default branch, + // whatever that means in the underlying implementation. + Latest(ctx context.Context) (*RevInfo, error) + + // ReadFile reads the given file in the file tree corresponding to revision rev. + // It should refuse to read more than maxSize bytes. + // + // If the requested file does not exist it should return an error for which + // os.IsNotExist(err) returns true. + ReadFile(ctx context.Context, rev, file string, maxSize int64) (data []byte, err error) + + // ReadZip downloads a zip file for the subdir subdirectory + // of the given revision to a new file in a given temporary directory. + // It should refuse to read more than maxSize bytes. + // It returns a ReadCloser for a streamed copy of the zip file. + // All files in the zip file are expected to be + // nested in a single top-level directory, whose name is not specified. + ReadZip(ctx context.Context, rev, subdir string, maxSize int64) (zip io.ReadCloser, err error) + + // RecentTag returns the most recent tag on rev or one of its predecessors + // with the given prefix. allowed may be used to filter out unwanted versions. + RecentTag(ctx context.Context, rev, prefix string, allowed func(tag string) bool) (tag string, err error) + + // DescendsFrom reports whether rev or any of its ancestors has the given tag. + // + // DescendsFrom must return true for any tag returned by RecentTag for the + // same revision. + DescendsFrom(ctx context.Context, rev, tag string) (bool, error) +} + +// An Origin describes the provenance of a given repo method result. +// It can be passed to CheckReuse (usually in a different go command invocation) +// to see whether the result remains up-to-date. +type Origin struct { + VCS string `json:",omitempty"` // "git" etc + URL string `json:",omitempty"` // URL of repository + Subdir string `json:",omitempty"` // subdirectory in repo + + Hash string `json:",omitempty"` // commit hash or ID + + // If TagSum is non-empty, then the resolution of this module version + // depends on the set of tags present in the repo, specifically the tags + // of the form TagPrefix + a valid semver version. + // If the matching repo tags and their commit hashes still hash to TagSum, + // the Origin is still valid (at least as far as the tags are concerned). + // The exact checksum is up to the Repo implementation; see (*gitRepo).Tags. + TagPrefix string `json:",omitempty"` + TagSum string `json:",omitempty"` + + // If Ref is non-empty, then the resolution of this module version + // depends on Ref resolving to the revision identified by Hash. + // If Ref still resolves to Hash, the Origin is still valid (at least as far as Ref is concerned). + // For Git, the Ref is a full ref like "refs/heads/main" or "refs/tags/v1.2.3", + // and the Hash is the Git object hash the ref maps to. + // Other VCS might choose differently, but the idea is that Ref is the name + // with a mutable meaning while Hash is a name with an immutable meaning. + Ref string `json:",omitempty"` + + // If RepoSum is non-empty, then the resolution of this module version + // depends on the entire state of the repo, which RepoSum summarizes. + // For Git, this is a hash of all the refs and their hashes, and the RepoSum + // is only needed for module versions that don't exist. + // For Mercurial, this is a hash of all the branches and their heads' hashes, + // since the set of available tags is dervied from .hgtags files in those branches, + // and the RepoSum is used for all module versions, available and not, + RepoSum string `json:",omitempty"` +} + +// A Tags describes the available tags in a code repository. +type Tags struct { + Origin *Origin + List []Tag +} + +// A Tag describes a single tag in a code repository. +type Tag struct { + Name string + Hash string // content hash identifying tag's content, if available +} + +// isOriginTag reports whether tag should be preserved +// in the Tags method's Origin calculation. +// We can safely ignore tags that are not look like pseudo-versions, +// because ../coderepo.go's (*codeRepo).Versions ignores them too. +// We can also ignore non-semver tags, but we have to include semver +// tags with extra suffixes, because the pseudo-version base finder uses them. +func isOriginTag(tag string) bool { + // modfetch.(*codeRepo).Versions uses Canonical == tag, + // but pseudo-version calculation has a weaker condition that + // the canonical is a prefix of the tag. + // Include those too, so that if any new one appears, we'll invalidate the cache entry. + // This will lead to spurious invalidation of version list results, + // but tags of this form being created should be fairly rare + // (and invalidate pseudo-version results anyway). + c := semver.Canonical(tag) + return c != "" && strings.HasPrefix(tag, c) && !module.IsPseudoVersion(tag) +} + +// A RevInfo describes a single revision in a source code repository. +type RevInfo struct { + Origin *Origin + Name string // complete ID in underlying repository + Short string // shortened ID, for use in pseudo-version + Version string // version used in lookup + Time time.Time // commit time + Tags []string // known tags for commit +} + +// UnknownRevisionError is an error equivalent to fs.ErrNotExist, but for a +// revision rather than a file. +type UnknownRevisionError struct { + Rev string +} + +func (e *UnknownRevisionError) Error() string { + return "unknown revision " + e.Rev +} +func (UnknownRevisionError) Is(err error) bool { + return err == fs.ErrNotExist +} + +// ErrNoCommits is an error equivalent to fs.ErrNotExist indicating that a given +// repository or module contains no commits. +var ErrNoCommits error = noCommitsError{} + +type noCommitsError struct{} + +func (noCommitsError) Error() string { + return "no commits" +} +func (noCommitsError) Is(err error) bool { + return err == fs.ErrNotExist +} + +// AllHex reports whether the revision rev is entirely lower-case hexadecimal digits. +func AllHex(rev string) bool { + for i := 0; i < len(rev); i++ { + c := rev[i] + if '0' <= c && c <= '9' || 'a' <= c && c <= 'f' { + continue + } + return false + } + return true +} + +// ShortenSHA1 shortens a SHA1 hash (40 hex digits) to the canonical length +// used in pseudo-versions (12 hex digits). +func ShortenSHA1(rev string) string { + if AllHex(rev) && len(rev) == 40 { + return rev[:12] + } + return rev +} + +// WorkDir returns the name of the cached work directory to use for the +// given repository type and name. +func WorkDir(ctx context.Context, typ, name string) (dir, lockfile string, err error) { + if cfg.GOMODCACHE == "" { + return "", "", fmt.Errorf("neither GOPATH nor GOMODCACHE are set") + } + + // We name the work directory for the SHA256 hash of the type and name. + // We intentionally avoid the actual name both because of possible + // conflicts with valid file system paths and because we want to ensure + // that one checkout is never nested inside another. That nesting has + // led to security problems in the past. + if strings.Contains(typ, ":") { + return "", "", fmt.Errorf("codehost.WorkDir: type cannot contain colon") + } + key := typ + ":" + name + dir = filepath.Join(cfg.GOMODCACHE, "cache/vcs", fmt.Sprintf("%x", sha256.Sum256([]byte(key)))) + + xLog, buildX := cfg.BuildXWriter(ctx) + if buildX { + fmt.Fprintf(xLog, "mkdir -p %s # %s %s\n", filepath.Dir(dir), typ, name) + } + if err := os.MkdirAll(filepath.Dir(dir), 0777); err != nil { + return "", "", err + } + + lockfile = dir + ".lock" + if buildX { + fmt.Fprintf(xLog, "# lock %s\n", lockfile) + } + + unlock, err := lockedfile.MutexAt(lockfile).Lock() + if err != nil { + return "", "", fmt.Errorf("codehost.WorkDir: can't find or create lock file: %v", err) + } + defer unlock() + + data, err := os.ReadFile(dir + ".info") + info, err2 := os.Stat(dir) + if err == nil && err2 == nil && info.IsDir() { + // Info file and directory both already exist: reuse. + have := strings.TrimSuffix(string(data), "\n") + if have != key { + return "", "", fmt.Errorf("%s exists with wrong content (have %q want %q)", dir+".info", have, key) + } + if buildX { + fmt.Fprintf(xLog, "# %s for %s %s\n", dir, typ, name) + } + return dir, lockfile, nil + } + + // Info file or directory missing. Start from scratch. + if xLog != nil { + fmt.Fprintf(xLog, "mkdir -p %s # %s %s\n", dir, typ, name) + } + os.RemoveAll(dir) + if err := os.MkdirAll(dir, 0777); err != nil { + return "", "", err + } + if err := os.WriteFile(dir+".info", []byte(key), 0666); err != nil { + os.RemoveAll(dir) + return "", "", err + } + return dir, lockfile, nil +} + +type RunError struct { + Cmd string + Err error + Stderr []byte + HelpText string +} + +func (e *RunError) Error() string { + text := e.Cmd + ": " + e.Err.Error() + stderr := bytes.TrimRight(e.Stderr, "\n") + if len(stderr) > 0 { + text += ":\n\t" + strings.ReplaceAll(string(stderr), "\n", "\n\t") + } + if len(e.HelpText) > 0 { + text += "\n" + e.HelpText + } + return text +} + +var dirLock sync.Map + +type RunArgs struct { + cmdline []any // the command to run + dir string // the directory to run the command in + local bool // true if the VCS information is local + env []string // environment variables for the command + stdin io.Reader +} + +// Run runs the command line in the given directory +// (an empty dir means the current directory). +// It returns the standard output and, for a non-zero exit, +// a *RunError indicating the command, exit status, and standard error. +// Standard error is unavailable for commands that exit successfully. +func Run(ctx context.Context, dir string, cmdline ...any) ([]byte, error) { + return run(ctx, RunArgs{cmdline: cmdline, dir: dir}) +} + +// RunWithArgs is the same as Run but it also accepts additional arguments. +func RunWithArgs(ctx context.Context, args RunArgs) ([]byte, error) { + return run(ctx, args) +} + +// bashQuoter escapes characters that have special meaning in double-quoted strings in the bash shell. +// See https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html. +var bashQuoter = strings.NewReplacer(`"`, `\"`, `$`, `\$`, "`", "\\`", `\`, `\\`) + +func run(ctx context.Context, args RunArgs) ([]byte, error) { + if args.dir != "" { + muIface, ok := dirLock.Load(args.dir) + if !ok { + muIface, _ = dirLock.LoadOrStore(args.dir, new(sync.Mutex)) + } + mu := muIface.(*sync.Mutex) + mu.Lock() + defer mu.Unlock() + } + + cmd := str.StringList(args.cmdline...) + if os.Getenv("TESTGOVCSREMOTE") == "panic" && !args.local { + panic(fmt.Sprintf("use of remote vcs: %v", cmd)) + } + if xLog, ok := cfg.BuildXWriter(ctx); ok { + text := new(strings.Builder) + if args.dir != "" { + text.WriteString("cd ") + text.WriteString(args.dir) + text.WriteString("; ") + } + for i, arg := range cmd { + if i > 0 { + text.WriteByte(' ') + } + switch { + case strings.ContainsAny(arg, "'"): + // Quote args that could be mistaken for quoted args. + text.WriteByte('"') + text.WriteString(bashQuoter.Replace(arg)) + text.WriteByte('"') + case strings.ContainsAny(arg, "$`\\*?[\"\t\n\v\f\r \u0085\u00a0"): + // Quote args that contain special characters, glob patterns, or spaces. + text.WriteByte('\'') + text.WriteString(arg) + text.WriteByte('\'') + default: + text.WriteString(arg) + } + } + fmt.Fprintf(xLog, "%s\n", text) + start := time.Now() + defer func() { + fmt.Fprintf(xLog, "%.3fs # %s\n", time.Since(start).Seconds(), text) + }() + } + // TODO: Impose limits on command output size. + // TODO: Set environment to get English error messages. + var stderr bytes.Buffer + var stdout bytes.Buffer + c := exec.CommandContext(ctx, cmd[0], cmd[1:]...) + c.Cancel = func() error { return c.Process.Signal(os.Interrupt) } + c.Dir = args.dir + c.Stdin = args.stdin + c.Stderr = &stderr + c.Stdout = &stdout + c.Env = append(c.Environ(), args.env...) + err := c.Run() + if err != nil { + err = &RunError{Cmd: strings.Join(cmd, " ") + " in " + args.dir, Stderr: stderr.Bytes(), Err: err} + } + return stdout.Bytes(), err +} diff --git a/go/src/cmd/go/internal/modfetch/codehost/git.go b/go/src/cmd/go/internal/modfetch/codehost/git.go new file mode 100644 index 0000000000000000000000000000000000000000..6eb61772db8a04283fb2889de291f5d0eea40fcc --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/codehost/git.go @@ -0,0 +1,1020 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package codehost + +import ( + "bytes" + "context" + "crypto/sha256" + "encoding/base64" + "errors" + "fmt" + "io" + "io/fs" + "net/url" + "os" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "slices" + "sort" + "strconv" + "strings" + "sync" + "time" + + "cmd/go/internal/base" + "cmd/go/internal/lockedfile" + "cmd/go/internal/web" + "cmd/internal/par" + + "golang.org/x/mod/semver" +) + +// A notExistError wraps another error to retain its original text +// but makes it opaquely equivalent to fs.ErrNotExist. +type notExistError struct { + err error +} + +func (e notExistError) Error() string { return e.err.Error() } +func (notExistError) Is(err error) bool { return err == fs.ErrNotExist } + +const gitWorkDirType = "git3" + +func newGitRepo(ctx context.Context, remote string, local bool) (Repo, error) { + r := &gitRepo{remote: remote, local: local} + if local { + if strings.Contains(remote, "://") { // Local flag, but URL provided + return nil, fmt.Errorf("git remote (%s) lookup disabled", remote) + } + info, err := os.Stat(remote) + if err != nil { + return nil, err + } + if !info.IsDir() { + return nil, fmt.Errorf("%s exists but is not a directory", remote) + } + r.dir = remote + r.mu.Path = r.dir + ".lock" + r.sha256Hashes = r.checkConfigSHA256(ctx) + return r, nil + } + // This is a remote path lookup. + if !strings.Contains(remote, "://") { // No URL scheme, could be host:path + if strings.Contains(remote, ":") { + return nil, fmt.Errorf("git remote (%s) must not be local directory (use URL syntax not host:path syntax)", remote) + } + return nil, fmt.Errorf("git remote (%s) must not be local directory", remote) + } + var err error + r.dir, r.mu.Path, err = WorkDir(ctx, gitWorkDirType, r.remote) + if err != nil { + return nil, err + } + + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + + if _, err := os.Stat(filepath.Join(r.dir, "objects")); err != nil { + repoSha256Hash := false + if refs, lrErr := r.loadRefs(ctx); lrErr == nil { + // Check any ref's hash, it doesn't matter which; they won't be mixed + // between sha1 and sha256 for the moment. + for _, refHash := range refs { + repoSha256Hash = len(refHash) == (256 / 4) + break + } + } + gitSupportsSHA256, gitVersErr := gitSupportsSHA256() + if gitVersErr != nil { + return nil, fmt.Errorf("unable to resolve git version: %w", gitVersErr) + } + objFormatFlag := []string{} + // If git is sufficiently recent to support sha256, + // always initialize with an explicit object-format. + if repoSha256Hash { + // We always set --object-format=sha256 if the repo + // we're cloning uses sha256 hashes because if the git + // version is too old, it'll fail either way, so we + // might as well give it one last chance. + objFormatFlag = []string{"--object-format=sha256"} + } else if gitSupportsSHA256 { + objFormatFlag = []string{"--object-format=sha1"} + } + if _, err := Run(ctx, r.dir, "git", "init", "--bare", objFormatFlag); err != nil { + os.RemoveAll(r.dir) + return nil, err + } + // We could just say git fetch https://whatever later, + // but this lets us say git fetch origin instead, which + // is a little nicer. More importantly, using a named remote + // avoids a problem with Git LFS. See golang.org/issue/25605. + if _, err := r.runGit(ctx, "git", "remote", "add", "origin", "--", r.remote); err != nil { + os.RemoveAll(r.dir) + return nil, err + } + if runtime.GOOS == "windows" { + // Git for Windows by default does not support paths longer than + // MAX_PATH (260 characters) because that may interfere with navigation + // in some Windows programs. However, cmd/go should be able to handle + // long paths just fine, and we expect people to use 'go clean' to + // manipulate the module cache, so it should be harmless to set here, + // and in some cases may be necessary in order to download modules with + // long branch names. + // + // See https://github.com/git-for-windows/git/wiki/Git-cannot-create-a-file-or-directory-with-a-long-path. + if _, err := r.runGit(ctx, "git", "config", "core.longpaths", "true"); err != nil { + os.RemoveAll(r.dir) + return nil, err + } + } + } + r.sha256Hashes = r.checkConfigSHA256(ctx) + r.remoteURL = r.remote + r.remote = "origin" + return r, nil +} + +type gitRepo struct { + ctx context.Context + + remote, remoteURL string + local bool // local only lookups; no remote fetches + dir string + + // Repo uses the SHA256 for hashes, so expect the hashes to be 256/4 == 64-bytes in hex. + sha256Hashes bool + + mu lockedfile.Mutex // protects fetchLevel and git repo state + + fetchLevel int + + statCache par.ErrCache[string, *RevInfo] + + refsOnce sync.Once + // refs maps branch and tag refs (e.g., "HEAD", "refs/heads/master") + // to commits (e.g., "37ffd2e798afde829a34e8955b716ab730b2a6d6") + refs map[string]string + refsErr error + + localTagsOnce sync.Once + localTags sync.Map // map[string]bool +} + +const ( + // How much have we fetched into the git repo (in this process)? + fetchNone = iota // nothing yet + fetchSome // shallow fetches of individual hashes + fetchAll // "fetch -t origin": get all remote branches and tags +) + +// loadLocalTags loads tag references from the local git cache +// into the map r.localTags. +func (r *gitRepo) loadLocalTags(ctx context.Context) { + // The git protocol sends all known refs and ls-remote filters them on the client side, + // so we might as well record both heads and tags in one shot. + // Most of the time we only care about tags but sometimes we care about heads too. + out, err := r.runGit(ctx, "git", "tag", "-l") + if err != nil { + return + } + + for line := range strings.SplitSeq(string(out), "\n") { + if line != "" { + r.localTags.Store(line, true) + } + } +} + +func (r *gitRepo) CheckReuse(ctx context.Context, old *Origin, subdir string) error { + if old == nil { + return fmt.Errorf("missing origin") + } + if old.VCS != "git" || old.URL != r.remoteURL { + return fmt.Errorf("origin moved from %v %q to %v %q", old.VCS, old.URL, "git", r.remoteURL) + } + if old.Subdir != subdir { + return fmt.Errorf("origin moved from %v %q %q to %v %q %q", old.VCS, old.URL, old.Subdir, "git", r.remoteURL, subdir) + } + + // Note: Can have Hash with no Ref and no TagSum and no RepoSum, + // meaning the Hash simply has to remain in the repo. + // In that case we assume it does in the absence of any real way to check. + // But if neither Hash nor TagSum is present, we have nothing to check, + // which we take to mean we didn't record enough information to be sure. + if old.Hash == "" && old.TagSum == "" && old.RepoSum == "" { + return fmt.Errorf("non-specific origin") + } + + r.loadRefs(ctx) + if r.refsErr != nil { + return r.refsErr + } + + if old.Ref != "" { + hash, ok := r.refs[old.Ref] + if !ok { + return fmt.Errorf("ref %q deleted", old.Ref) + } + if hash != old.Hash { + return fmt.Errorf("ref %q moved from %s to %s", old.Ref, old.Hash, hash) + } + } + if old.TagSum != "" { + tags, err := r.Tags(ctx, old.TagPrefix) + if err != nil { + return err + } + if tags.Origin.TagSum != old.TagSum { + return fmt.Errorf("tags changed") + } + } + if old.RepoSum != "" { + if r.repoSum(r.refs) != old.RepoSum { + return fmt.Errorf("refs changed") + } + } + return nil +} + +// loadRefs loads heads and tags references from the remote into the map r.refs. +// The result is cached in memory. +func (r *gitRepo) loadRefs(ctx context.Context) (map[string]string, error) { + if r.local { // Return results from the cache if local only. + // In the future, we could consider loading r.refs using local git commands + // if desired. + return nil, nil + } + r.refsOnce.Do(func() { + // The git protocol sends all known refs and ls-remote filters them on the client side, + // so we might as well record both heads and tags in one shot. + // Most of the time we only care about tags but sometimes we care about heads too. + release, err := base.AcquireNet() + if err != nil { + r.refsErr = err + return + } + out, gitErr := r.runGit(ctx, "git", "ls-remote", "-q", "--end-of-options", r.remote) + release() + + if gitErr != nil { + if rerr, ok := gitErr.(*RunError); ok { + if bytes.Contains(rerr.Stderr, []byte("fatal: could not read Username")) { + rerr.HelpText = "Confirm the import path was entered correctly.\nIf this is a private repository, see https://golang.org/doc/faq#git_https for additional information." + } + } + + // If the remote URL doesn't exist at all, ideally we should treat the whole + // repository as nonexistent by wrapping the error in a notExistError. + // For HTTP and HTTPS, that's easy to detect: we'll try to fetch the URL + // ourselves and see what code it serves. + if u, err := url.Parse(r.remoteURL); err == nil && (u.Scheme == "http" || u.Scheme == "https") { + if _, err := web.GetBytes(u); errors.Is(err, fs.ErrNotExist) { + gitErr = notExistError{gitErr} + } + } + + r.refsErr = gitErr + return + } + + refs := make(map[string]string) + for line := range strings.SplitSeq(string(out), "\n") { + f := strings.Fields(line) + if len(f) != 2 { + continue + } + if f[1] == "HEAD" || strings.HasPrefix(f[1], "refs/heads/") || strings.HasPrefix(f[1], "refs/tags/") { + refs[f[1]] = f[0] + } + } + for ref, hash := range refs { + if k, found := strings.CutSuffix(ref, "^{}"); found { // record unwrapped annotated tag as value of tag + refs[k] = hash + delete(refs, ref) + } + } + r.refs = refs + }) + return r.refs, r.refsErr +} + +func (r *gitRepo) Tags(ctx context.Context, prefix string) (*Tags, error) { + refs, err := r.loadRefs(ctx) + if err != nil { + return nil, err + } + + tags := &Tags{ + Origin: &Origin{ + VCS: "git", + URL: r.remoteURL, + TagPrefix: prefix, + }, + List: []Tag{}, + } + for ref, hash := range refs { + if !strings.HasPrefix(ref, "refs/tags/") { + continue + } + tag := ref[len("refs/tags/"):] + if !strings.HasPrefix(tag, prefix) { + continue + } + tags.List = append(tags.List, Tag{tag, hash}) + } + sort.Slice(tags.List, func(i, j int) bool { + return tags.List[i].Name < tags.List[j].Name + }) + + dir := prefix[:strings.LastIndex(prefix, "/")+1] + h := sha256.New() + for _, tag := range tags.List { + if isOriginTag(strings.TrimPrefix(tag.Name, dir)) { + fmt.Fprintf(h, "%q %s\n", tag.Name, tag.Hash) + } + } + tags.Origin.TagSum = "t1:" + base64.StdEncoding.EncodeToString(h.Sum(nil)) + return tags, nil +} + +// repoSum returns a checksum of the entire repo state, +// which can be checked (as Origin.RepoSum) to cache +// the absence of a specific module version. +// The caller must supply refs, the result of a successful r.loadRefs. +func (r *gitRepo) repoSum(refs map[string]string) string { + list := make([]string, 0, len(refs)) + for ref := range refs { + list = append(list, ref) + } + sort.Strings(list) + h := sha256.New() + for _, ref := range list { + fmt.Fprintf(h, "%q %s\n", ref, refs[ref]) + } + return "r1:" + base64.StdEncoding.EncodeToString(h.Sum(nil)) +} + +// unknownRevisionInfo returns a RevInfo containing an Origin containing a RepoSum of refs, +// for use when returning an UnknownRevisionError. +func (r *gitRepo) unknownRevisionInfo(refs map[string]string) *RevInfo { + return &RevInfo{ + Origin: &Origin{ + VCS: "git", + URL: r.remoteURL, + RepoSum: r.repoSum(refs), + }, + } +} + +func (r *gitRepo) Latest(ctx context.Context) (*RevInfo, error) { + refs, err := r.loadRefs(ctx) + if err != nil { + return nil, err + } + if refs["HEAD"] == "" { + return nil, ErrNoCommits + } + statInfo, err := r.Stat(ctx, refs["HEAD"]) + if err != nil { + return nil, err + } + + // Stat may return cached info, so make a copy to modify here. + info := new(RevInfo) + *info = *statInfo + info.Origin = new(Origin) + if statInfo.Origin != nil { + *info.Origin = *statInfo.Origin + } + info.Origin.Ref = "HEAD" + info.Origin.Hash = refs["HEAD"] + + return info, nil +} + +func (r *gitRepo) checkConfigSHA256(ctx context.Context) bool { + if hashType, sha256CfgErr := r.runGit(ctx, "git", "config", "extensions.objectformat"); sha256CfgErr == nil { + return strings.TrimSpace(string(hashType)) == "sha256" + } + return false +} + +func (r *gitRepo) hexHashLen() int { + if !r.sha256Hashes { + return 160 / 4 + } + return 256 / 4 +} + +// shortenObjectHash shortens a SHA1 or SHA256 hash (40 or 64 hex digits) to +// the canonical length used in pseudo-versions (12 hex digits). +func (r *gitRepo) shortenObjectHash(rev string) string { + if !r.sha256Hashes { + return ShortenSHA1(rev) + } + if AllHex(rev) && len(rev) == 256/4 { + return rev[:12] + } + return rev +} + +// minHashDigits is the minimum number of digits to require +// before accepting a hex digit sequence as potentially identifying +// a specific commit in a git repo. (Of course, users can always +// specify more digits, and many will paste in all 40 digits, +// but many of git's commands default to printing short hashes +// as 7 digits.) +const minHashDigits = 7 + +// stat stats the given rev in the local repository, +// or else it fetches more info from the remote repository and tries again. +func (r *gitRepo) stat(ctx context.Context, rev string) (info *RevInfo, err error) { + // Fast path: maybe rev is a hash we already have locally. + didStatLocal := false + if len(rev) >= minHashDigits && len(rev) <= r.hexHashLen() && AllHex(rev) { + if info, err := r.statLocal(ctx, rev, rev); err == nil { + return info, nil + } + didStatLocal = true + } + + // Maybe rev is a tag we already have locally. + // (Note that we're excluding branches, which can be stale.) + r.localTagsOnce.Do(func() { r.loadLocalTags(ctx) }) + if _, ok := r.localTags.Load(rev); ok { + return r.statLocal(ctx, rev, "refs/tags/"+rev) + } + + // Maybe rev is the name of a tag or branch on the remote server. + // Or maybe it's the prefix of a hash of a named ref. + // Try to resolve to both a ref (git name) and full (40-hex-digit for + // sha1 64 for sha256) commit hash. + refs, err := r.loadRefs(ctx) + if err != nil { + return nil, err + } + // loadRefs may return an error if git fails, for example segfaults, or + // could not load a private repo, but defer checking to the else block + // below, in case we already have the rev in question in the local cache. + var ref, hash string + if refs["refs/tags/"+rev] != "" { + ref = "refs/tags/" + rev + hash = refs[ref] + // Keep rev as is: tags are assumed not to change meaning. + } else if refs["refs/heads/"+rev] != "" { + ref = "refs/heads/" + rev + hash = refs[ref] + rev = hash // Replace rev, because meaning of refs/heads/foo can change. + } else if rev == "HEAD" && refs["HEAD"] != "" { + ref = "HEAD" + hash = refs[ref] + rev = hash // Replace rev, because meaning of HEAD can change. + } else if len(rev) >= minHashDigits && len(rev) <= r.hexHashLen() && AllHex(rev) { + // At the least, we have a hash prefix we can look up after the fetch below. + // Maybe we can map it to a full hash using the known refs. + prefix := rev + // Check whether rev is prefix of known ref hash. + for k, h := range refs { + if strings.HasPrefix(h, prefix) { + if hash != "" && hash != h { + // Hash is an ambiguous hash prefix. + // More information will not change that. + return nil, fmt.Errorf("ambiguous revision %s", rev) + } + if ref == "" || ref > k { // Break ties deterministically when multiple refs point at same hash. + ref = k + } + rev = h + hash = h + } + } + if hash == "" && len(rev) == r.hexHashLen() { // Didn't find a ref, but rev is a full hash. + hash = rev + } + } else { + return r.unknownRevisionInfo(refs), &UnknownRevisionError{Rev: rev} + } + + defer func() { + if info != nil { + info.Origin.Hash = info.Name + // There's a ref = hash below; don't write that hash down as Origin.Ref. + if ref != info.Origin.Hash { + info.Origin.Ref = ref + } + } + }() + + // Protect r.fetchLevel and the "fetch more and more" sequence. + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + + // Perhaps r.localTags did not have the ref when we loaded local tags, + // but we've since done fetches that pulled down the hash we need + // (or already have the hash we need, just without its tag). + // Either way, try a local stat before falling back to network I/O. + if !didStatLocal { + if info, err := r.statLocal(ctx, rev, hash); err == nil { + tag, fromTag := strings.CutPrefix(ref, "refs/tags/") + if fromTag && !slices.Contains(info.Tags, tag) { + // The local repo includes the commit hash we want, but it is missing + // the corresponding tag. Add that tag and try again. + _, err := r.runGit(ctx, "git", "tag", "--end-of-options", tag, hash) + if err != nil { + return nil, err + } + r.localTags.Store(tag, true) + return r.statLocal(ctx, rev, ref) + } + return info, err + } + } + + if r.local { // at this point, we have determined that we need to fetch rev, fail early if local only mode. + return nil, fmt.Errorf("revision does not exist locally: %s", rev) + } + + // If we know a specific commit we need and its ref, fetch it. + // We do NOT fetch arbitrary hashes (when we don't know the ref) + // because we want to avoid ever importing a commit that isn't + // reachable from refs/tags/* or refs/heads/* or HEAD. + // Both Gerrit and GitHub expose every CL/PR as a named ref, + // and we don't want those commits masquerading as being real + // pseudo-versions in the main repo. + if r.fetchLevel <= fetchSome && ref != "" && hash != "" { + r.fetchLevel = fetchSome + var refspec string + if ref == "HEAD" { + // Fetch the hash but give it a local name (refs/dummy), + // because that triggers the fetch behavior of creating any + // other known remote tags for the hash. We never use + // refs/dummy (it's not refs/tags/dummy) and it will be + // overwritten in the next command, and that's fine. + ref = hash + refspec = hash + ":refs/dummy" + } else { + // If we do know the ref name, save the mapping locally + // so that (if it is a tag) it can show up in localTags + // on a future call. Also, some servers refuse to allow + // full hashes in ref specs, so prefer a ref name if known. + refspec = ref + ":" + ref + } + + release, err := base.AcquireNet() + if err != nil { + return nil, err + } + // We explicitly set protocol.version=2 for this command to work around + // an apparent Git bug introduced in Git 2.21 (commit 61c771), + // which causes the handler for protocol version 1 to sometimes miss + // tags that point to the requested commit (see https://go.dev/issue/56881). + _, err = r.runGit(ctx, "git", "-c", "protocol.version=2", "fetch", "-f", "--depth=1", "--end-of-options", r.remote, refspec) + release() + + if err == nil { + return r.statLocal(ctx, rev, ref) + } + // Don't try to be smart about parsing the error. + // It's too complex and varies too much by git version. + // No matter what went wrong, fall back to a complete fetch. + } + + // Last resort. + // Fetch all heads and tags and hope the hash we want is in the history. + if err := r.fetchRefsLocked(ctx); err != nil { + return nil, err + } + + return r.statLocal(ctx, rev, rev) +} + +// fetchRefsLocked fetches all heads and tags from the origin, along with the +// ancestors of those commits. +// +// We only fetch heads and tags, not arbitrary other commits: we don't want to +// pull in off-branch commits (such as rejected GitHub pull requests) that the +// server may be willing to provide. (See the comments within the stat method +// for more detail.) +// +// fetchRefsLocked requires that r.mu remain locked for the duration of the call. +func (r *gitRepo) fetchRefsLocked(ctx context.Context) error { + if r.local { + panic("go: fetchRefsLocked called in local only mode.") + } + if r.fetchLevel < fetchAll { + // NOTE: To work around a bug affecting Git clients up to at least 2.23.0 + // (2019-08-16), we must first expand the set of local refs, and only then + // unshallow the repository as a separate fetch operation. (See + // golang.org/issue/34266 and + // https://github.com/git/git/blob/4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a/transport.c#L1303-L1309.) + + release, err := base.AcquireNet() + if err != nil { + return err + } + defer release() + + if _, err := r.runGit(ctx, "git", "fetch", "-f", "--end-of-options", r.remote, "refs/heads/*:refs/heads/*", "refs/tags/*:refs/tags/*"); err != nil { + return err + } + + if _, err := os.Stat(filepath.Join(r.dir, "shallow")); err == nil { + if _, err := r.runGit(ctx, "git", "fetch", "--unshallow", "-f", "--end-of-options", r.remote); err != nil { + return err + } + } + + r.fetchLevel = fetchAll + } + return nil +} + +// statLocal returns a new RevInfo describing rev in the local git repository. +// It uses version as info.Version. +func (r *gitRepo) statLocal(ctx context.Context, version, rev string) (*RevInfo, error) { + out, err := r.runGit(ctx, "git", "-c", "log.showsignature=false", "log", "--no-decorate", "-n1", "--format=format:%H %ct %D", "--end-of-options", rev, "--") + if err != nil { + // Return info with Origin.RepoSum if possible to allow caching of negative lookup. + var info *RevInfo + if refs, err := r.loadRefs(ctx); err == nil { + info = r.unknownRevisionInfo(refs) + } + return info, &UnknownRevisionError{Rev: rev} + } + f := strings.Fields(string(out)) + if len(f) < 2 { + return nil, fmt.Errorf("unexpected response from git log: %q", out) + } + hash := f[0] + if strings.HasPrefix(hash, version) { + version = hash // extend to full hash + } + t, err := strconv.ParseInt(f[1], 10, 64) + if err != nil { + return nil, fmt.Errorf("invalid time from git log: %q", out) + } + + info := &RevInfo{ + Origin: &Origin{ + VCS: "git", + URL: r.remoteURL, + Hash: hash, + }, + Name: hash, + Short: r.shortenObjectHash(hash), + Time: time.Unix(t, 0).UTC(), + Version: hash, + } + if !strings.HasPrefix(hash, rev) { + info.Origin.Ref = rev + } + + // Add tags. Output looks like: + // ede458df7cd0fdca520df19a33158086a8a68e81 1523994202 HEAD -> master, tag: v1.2.4-annotated, tag: v1.2.3, origin/master, origin/HEAD + for i := 2; i < len(f); i++ { + if f[i] == "tag:" { + i++ + if i < len(f) { + info.Tags = append(info.Tags, strings.TrimSuffix(f[i], ",")) + } + } + } + + // Git 2.47.1 does not send the tags during shallow clone anymore + // (perhaps the exact version that changed behavior is an earlier one), + // so we have to also add tags from the refs list we fetched with ls-remote. + if refs, err := r.loadRefs(ctx); err == nil { + for ref, h := range refs { + if h == hash { + if tag, found := strings.CutPrefix(ref, "refs/tags/"); found { + info.Tags = append(info.Tags, tag) + } + } + } + } + slices.Sort(info.Tags) + info.Tags = slices.Compact(info.Tags) + + // Used hash as info.Version above. + // Use caller's suggested version if it appears in the tag list + // (filters out branch names, HEAD). + for _, tag := range info.Tags { + if version == tag { + info.Version = version + } + } + + return info, nil +} + +func (r *gitRepo) Stat(ctx context.Context, rev string) (*RevInfo, error) { + if rev == "latest" { + return r.Latest(ctx) + } + return r.statCache.Do(rev, func() (*RevInfo, error) { + return r.stat(ctx, rev) + }) +} + +func (r *gitRepo) ReadFile(ctx context.Context, rev, file string, maxSize int64) ([]byte, error) { + // TODO: Could use git cat-file --batch. + info, err := r.Stat(ctx, rev) // download rev into local git repo + if err != nil { + return nil, err + } + out, err := r.runGit(ctx, "git", "cat-file", "--end-of-options", "blob", info.Name+":"+file) + if err != nil { + return nil, fs.ErrNotExist + } + return out, nil +} + +func (r *gitRepo) RecentTag(ctx context.Context, rev, prefix string, allowed func(tag string) bool) (tag string, err error) { + info, err := r.Stat(ctx, rev) + if err != nil { + return "", err + } + rev = info.Name // expand hash prefixes + + // describe sets tag and err using 'git for-each-ref' and reports whether the + // result is definitive. + describe := func() (definitive bool) { + var out []byte + out, err = r.runGit(ctx, "git", "for-each-ref", "--format=%(refname)", "--merged="+rev) + if err != nil { + return true + } + + // prefixed tags aren't valid semver tags so compare without prefix, but only tags with correct prefix + var highest string + for line := range strings.SplitSeq(string(out), "\n") { + line = strings.TrimSpace(line) + // git do support lstrip in for-each-ref format, but it was added in v2.13.0. Stripping here + // instead gives support for git v2.7.0. + if !strings.HasPrefix(line, "refs/tags/") { + continue + } + line = line[len("refs/tags/"):] + + if !strings.HasPrefix(line, prefix) { + continue + } + if !allowed(line) { + continue + } + + semtag := line[len(prefix):] + if semver.Compare(semtag, highest) > 0 { + highest = semtag + } + } + + if highest != "" { + tag = prefix + highest + } + + return tag != "" && !AllHex(tag) + } + + if describe() { + return tag, err + } + + // Git didn't find a version tag preceding the requested rev. + // See whether any plausible tag exists. + tags, err := r.Tags(ctx, prefix+"v") + if err != nil { + return "", err + } + if len(tags.List) == 0 { + return "", nil + } + + if r.local { // at this point, we have determined that we need to fetch rev, fail early if local only mode. + return "", fmt.Errorf("revision does not exist locally: %s", rev) + } + // There are plausible tags, but we don't know if rev is a descendent of any of them. + // Fetch the history to find out. + + // Note: do not use defer unlock, because describe calls allowed, + // which uses retracted, which calls ReadFile, which may end up + // back at a method that acquires r.mu. + unlock, err := r.mu.Lock() + if err != nil { + return "", err + } + if err := r.fetchRefsLocked(ctx); err != nil { + unlock() + return "", err + } + unlock() + + // If we've reached this point, we have all of the commits that are reachable + // from all heads and tags. + // + // The only refs we should be missing are those that are no longer reachable + // (or never were reachable) from any branch or tag, including the master + // branch, and we don't want to resolve them anyway (they're probably + // unreachable for a reason). + // + // Try one last time in case some other goroutine fetched rev while we were + // waiting on the lock. + describe() + return tag, err +} + +func (r *gitRepo) DescendsFrom(ctx context.Context, rev, tag string) (bool, error) { + // The "--is-ancestor" flag was added to "git merge-base" in version 1.8.0, so + // this won't work with Git 1.7.1. According to golang.org/issue/28550, cmd/go + // already doesn't work with Git 1.7.1, so at least it's not a regression. + // + // git merge-base --is-ancestor exits with status 0 if rev is an ancestor, or + // 1 if not. + _, err := r.runGit(ctx, "git", "merge-base", "--is-ancestor", "--", tag, rev) + + // Git reports "is an ancestor" with exit code 0 and "not an ancestor" with + // exit code 1. + // Unfortunately, if we've already fetched rev with a shallow history, git + // merge-base has been observed to report a false-negative, so don't stop yet + // even if the exit code is 1! + if err == nil { + return true, nil + } + + // See whether the tag and rev even exist. + tags, err := r.Tags(ctx, tag) + if err != nil { + return false, err + } + if len(tags.List) == 0 { + return false, nil + } + + // NOTE: r.stat is very careful not to fetch commits that we shouldn't know + // about, like rejected GitHub pull requests, so don't try to short-circuit + // that here. + if _, err = r.stat(ctx, rev); err != nil { + return false, err + } + + if r.local { // at this point, we have determined that we need to fetch rev, fail early if local only mode. + return false, fmt.Errorf("revision does not exist locally: %s", rev) + } + + // Now fetch history so that git can search for a path. + unlock, err := r.mu.Lock() + if err != nil { + return false, err + } + defer unlock() + + if r.fetchLevel < fetchAll { + // Fetch the complete history for all refs and heads. It would be more + // efficient to only fetch the history from rev to tag, but that's much more + // complicated, and any kind of shallow fetch is fairly likely to trigger + // bugs in JGit servers and/or the go command anyway. + if err := r.fetchRefsLocked(ctx); err != nil { + return false, err + } + } + + _, err = r.runGit(ctx, "git", "merge-base", "--is-ancestor", "--", tag, rev) + if err == nil { + return true, nil + } + if ee, ok := err.(*RunError).Err.(*exec.ExitError); ok && ee.ExitCode() == 1 { + return false, nil + } + return false, err +} + +func (r *gitRepo) ReadZip(ctx context.Context, rev, subdir string, maxSize int64) (zip io.ReadCloser, err error) { + // TODO: Use maxSize or drop it. + args := []string{} + if subdir != "" { + args = append(args, subdir) + } + info, err := r.Stat(ctx, rev) // download rev into local git repo + if err != nil { + return nil, err + } + + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + + if err := ensureGitAttributes(r.dir); err != nil { + return nil, err + } + + // Incredibly, git produces different archives depending on whether + // it is running on a Windows system or not, in an attempt to normalize + // text file line endings. Setting -c core.autocrlf=input means only + // translate files on the way into the repo, not on the way out (archive). + // The -c core.eol=lf should be unnecessary but set it anyway. + archive, err := r.runGit(ctx, "git", "-c", "core.autocrlf=input", "-c", "core.eol=lf", "archive", "--format=zip", "--prefix=prefix/", "--end-of-options", info.Name, args) + if err != nil { + if bytes.Contains(err.(*RunError).Stderr, []byte("did not match any files")) { + return nil, fs.ErrNotExist + } + return nil, err + } + + return io.NopCloser(bytes.NewReader(archive)), nil +} + +// ensureGitAttributes makes sure export-subst and export-ignore features are +// disabled for this repo. This is intended to be run prior to running git +// archive so that zip files are generated that produce consistent ziphashes +// for a given revision, independent of variables such as git version and the +// size of the repo. +// +// See: https://github.com/golang/go/issues/27153 +func ensureGitAttributes(repoDir string) (err error) { + const attr = "\n* -export-subst -export-ignore\n" + + d := repoDir + "/info" + p := d + "/attributes" + + if err := os.MkdirAll(d, 0755); err != nil { + return err + } + + f, err := os.OpenFile(p, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0666) + if err != nil { + return err + } + defer func() { + closeErr := f.Close() + if closeErr != nil { + err = closeErr + } + }() + + b, err := io.ReadAll(f) + if err != nil { + return err + } + if !bytes.HasSuffix(b, []byte(attr)) { + _, err := f.WriteString(attr) + return err + } + + return nil +} + +func (r *gitRepo) runGit(ctx context.Context, cmdline ...any) ([]byte, error) { + args := RunArgs{cmdline: cmdline, dir: r.dir, local: r.local} + if !r.local { + // Manually supply GIT_DIR so Git works with safe.bareRepository=explicit set. + // This is necessary only for remote repositories as they are initialized with git init --bare. + args.env = []string{"GIT_DIR=" + r.dir} + } + return RunWithArgs(ctx, args) +} + +// Capture the major, minor and (optionally) patch version, but ignore anything later +var gitVersLineExtract = regexp.MustCompile(`git version\s+(\d+\.\d+(?:\.\d+)?)`) + +func gitVersion() (string, error) { + gitOut, runErr := exec.Command("git", "version").CombinedOutput() + if runErr != nil { + return "v0", fmt.Errorf("failed to execute git version: %w", runErr) + } + return extractGitVersion(gitOut) +} + +func extractGitVersion(gitOut []byte) (string, error) { + matches := gitVersLineExtract.FindSubmatch(gitOut) + if len(matches) < 2 { + return "v0", fmt.Errorf("git version extraction regexp did not match version line: %q", gitOut) + } + return "v" + string(matches[1]), nil +} + +func hasAtLeastGitVersion(minVers string) (bool, error) { + gitVers, gitVersErr := gitVersion() + if gitVersErr != nil { + return false, gitVersErr + } + return semver.Compare(minVers, gitVers) <= 0, nil +} + +const minGitSHA256Vers = "v2.29" + +func gitSupportsSHA256() (bool, error) { + return hasAtLeastGitVersion(minGitSHA256Vers) +} diff --git a/go/src/cmd/go/internal/modfetch/codehost/git_test.go b/go/src/cmd/go/internal/modfetch/codehost/git_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1c950686bf057909a94ee68c9d928ab782239199 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/codehost/git_test.go @@ -0,0 +1,1107 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package codehost + +import ( + "archive/zip" + "bytes" + "cmd/go/internal/cfg" + "cmd/go/internal/vcweb/vcstest" + "context" + "flag" + "internal/testenv" + "io" + "io/fs" + "log" + "os" + "path" + "path/filepath" + "reflect" + "runtime" + "strings" + "sync" + "testing" + "time" + + "golang.org/x/mod/semver" +) + +func TestMain(m *testing.M) { + flag.Parse() + if err := testMain(m); err != nil { + log.Fatal(err) + } +} + +var gitrepo1, gitsha256repo, hgrepo1, vgotest1 string + +var altRepos = func() []string { + return []string{ + "localGitRepo", + hgrepo1, + } +} + +// TODO: Convert gitrepo1 to svn, bzr, fossil and add tests. +// For now, at least the hgrepo1 tests check the general vcs.go logic. + +// localGitRepo is like gitrepo1 but allows archive access +// (although that doesn't really matter after CL 120041), +// and has a file:// URL instead of http:// or https:// +// (which might still matter). +var localGitRepo string + +// localGitURL initializes the repo in localGitRepo and returns its URL. +func localGitURL(t testing.TB) string { + testenv.MustHaveExecPath(t, "git") + if runtime.GOOS == "android" && strings.HasSuffix(testenv.Builder(), "-corellium") { + testenv.SkipFlaky(t, 59940) + } + + localGitURLOnce.Do(func() { + // Clone gitrepo1 into a local directory. + // If we use a file:// URL to access the local directory, + // then git starts up all the usual protocol machinery, + // which will let us test remote git archive invocations. + _, localGitURLErr = Run(context.Background(), "", "git", "clone", "--mirror", gitrepo1, localGitRepo) + if localGitURLErr != nil { + return + } + repo := gitRepo{dir: localGitRepo} + _, localGitURLErr = repo.runGit(context.Background(), "git", "config", "daemon.uploadarch", "true") + // TODO(david.finkel): do the same with the git repo using sha256 object hashes + }) + + if localGitURLErr != nil { + t.Fatal(localGitURLErr) + } + // Convert absolute path to file URL. LocalGitRepo will not accept + // Windows absolute paths because they look like a host:path remote. + // TODO(golang.org/issue/32456): use url.FromFilePath when implemented. + if strings.HasPrefix(localGitRepo, "/") { + return "file://" + localGitRepo + } else { + return "file:///" + filepath.ToSlash(localGitRepo) + } +} + +var ( + localGitURLOnce sync.Once + localGitURLErr error +) + +func testMain(m *testing.M) (err error) { + cfg.BuildX = testing.Verbose() + + srv, err := vcstest.NewServer() + if err != nil { + return err + } + defer func() { + if closeErr := srv.Close(); err == nil { + err = closeErr + } + }() + + gitrepo1 = srv.HTTP.URL + "/git/gitrepo1" + gitsha256repo = srv.HTTP.URL + "/git/gitrepo-sha256" + hgrepo1 = srv.HTTP.URL + "/hg/hgrepo1" + vgotest1 = srv.HTTP.URL + "/git/vgotest1" + + dir, err := os.MkdirTemp("", "gitrepo-test-") + if err != nil { + return err + } + defer func() { + if rmErr := os.RemoveAll(dir); err == nil { + err = rmErr + } + }() + + localGitRepo = filepath.Join(dir, "gitrepo2") + + // Redirect the module cache to a fresh directory to avoid crosstalk, and make + // it read/write so that the test can still clean it up easily when done. + cfg.GOMODCACHE = filepath.Join(dir, "modcache") + cfg.ModCacheRW = true + + m.Run() + return nil +} + +func testContext(t testing.TB) context.Context { + w := newTestWriter(t) + return cfg.WithBuildXWriter(context.Background(), w) +} + +// A testWriter is an io.Writer that writes to a test's log. +// +// The writer batches written data until the last byte of a write is a newline +// character, then flushes the batched data as a single call to Logf. +// Any remaining unflushed data is logged during Cleanup. +type testWriter struct { + t testing.TB + + mu sync.Mutex + buf bytes.Buffer +} + +func newTestWriter(t testing.TB) *testWriter { + w := &testWriter{t: t} + + t.Cleanup(func() { + w.mu.Lock() + defer w.mu.Unlock() + if b := w.buf.Bytes(); len(b) > 0 { + w.t.Logf("%s", b) + w.buf.Reset() + } + }) + + return w +} + +func (w *testWriter) Write(p []byte) (int, error) { + w.mu.Lock() + defer w.mu.Unlock() + n, err := w.buf.Write(p) + if b := w.buf.Bytes(); len(b) > 0 && b[len(b)-1] == '\n' { + w.t.Logf("%s", b) + w.buf.Reset() + } + return n, err +} + +func testRepo(ctx context.Context, t *testing.T, remote string) (Repo, error) { + if remote == "localGitRepo" { + return NewRepo(ctx, "git", localGitURL(t), false) + } + vcsName := "git" + for _, k := range []string{"hg"} { + if strings.Contains(remote, "/"+k+"/") { + vcsName = k + } + } + if testing.Short() && vcsName == "hg" { + t.Skipf("skipping hg test in short mode: hg is slow") + } + testenv.MustHaveExecPath(t, vcsName) + if runtime.GOOS == "android" && strings.HasSuffix(testenv.Builder(), "-corellium") { + testenv.SkipFlaky(t, 59940) + } + return NewRepo(ctx, vcsName, remote, false) +} + +func TestExtractGitVersion(t *testing.T) { + t.Parallel() + for _, tbl := range []struct { + in, exp string + }{ + {in: "git version 2.52.0.rc2", exp: "v2.52.0"}, + {in: "git version 2.52.0.38.g5e6e4854e0", exp: "v2.52.0"}, + {in: "git version 2.51.2", exp: "v2.51.2"}, + {in: "git version 1.5.0.5.GIT", exp: "v1.5.0"}, + {in: "git version 1.5.1-rc3.GIT", exp: "v1.5.1"}, + {in: "git version 1.5.2.GIT", exp: "v1.5.2"}, + {in: "git version 2.43.0.rc2.23.gc3cc3e1da7", exp: "v2.43.0"}, + } { + t.Run(tbl.exp, func(t *testing.T) { + out, extrErr := extractGitVersion([]byte(tbl.in)) + if extrErr != nil { + t.Errorf("failed to extract git version from %q: %s", tbl.in, extrErr) + } + if out != tbl.exp { + t.Errorf("unexpected git version extractGitVersion(%q) = %q; want %q", tbl.in, out, tbl.exp) + } + }) + } +} + +func TestTags(t *testing.T) { + + gitVers, gitVersErr := gitVersion() + if gitVersErr != nil { + t.Logf("git version check failed: %s", gitVersErr) + } + + type tagsTest struct { + repo string + prefix string + tags []Tag + // Override the git default hash for a few cases to make sure + // we handle all 3 reasonable states. + defGitHash string + } + + runTest := func(tt tagsTest) func(*testing.T) { + return func(t *testing.T) { + if tt.repo == gitsha256repo && semver.Compare(gitVers, minGitSHA256Vers) < 0 { + t.Skipf("git version is too old (%+v); skipping git sha256 test", gitVers) + } + ctx := testContext(t) + if tt.defGitHash != "" { + t.Setenv("GIT_DEFAULT_HASH", tt.defGitHash) + } + + r, err := testRepo(ctx, t, tt.repo) + if err != nil { + t.Fatal(err) + } + tags, err := r.Tags(ctx, tt.prefix) + if err != nil { + t.Fatal(err) + } + if tags == nil || !reflect.DeepEqual(tags.List, tt.tags) { + t.Errorf("Tags(%q): incorrect tags\nhave %v\nwant %v", tt.prefix, tags, tt.tags) + } + } + } + + for _, tt := range []tagsTest{ + {gitrepo1, "xxx", []Tag{}, ""}, + {gitrepo1, "xxx", []Tag{}, "sha256"}, + {gitrepo1, "xxx", []Tag{}, "sha1"}, + {gitrepo1, "", []Tag{ + {"v1.2.3", "ede458df7cd0fdca520df19a33158086a8a68e81"}, + {"v1.2.4-annotated", "ede458df7cd0fdca520df19a33158086a8a68e81"}, + {"v2.0.1", "76a00fb249b7f93091bc2c89a789dab1fc1bc26f"}, + {"v2.0.2", "9d02800338b8a55be062c838d1f02e0c5780b9eb"}, + {"v2.3", "76a00fb249b7f93091bc2c89a789dab1fc1bc26f"}, + }, ""}, + {gitrepo1, "v", []Tag{ + {"v1.2.3", "ede458df7cd0fdca520df19a33158086a8a68e81"}, + {"v1.2.4-annotated", "ede458df7cd0fdca520df19a33158086a8a68e81"}, + {"v2.0.1", "76a00fb249b7f93091bc2c89a789dab1fc1bc26f"}, + {"v2.0.2", "9d02800338b8a55be062c838d1f02e0c5780b9eb"}, + {"v2.3", "76a00fb249b7f93091bc2c89a789dab1fc1bc26f"}, + }, ""}, + {gitrepo1, "v1", []Tag{ + {"v1.2.3", "ede458df7cd0fdca520df19a33158086a8a68e81"}, + {"v1.2.4-annotated", "ede458df7cd0fdca520df19a33158086a8a68e81"}, + }, ""}, + {gitrepo1, "v1", []Tag{ + {"v1.2.3", "ede458df7cd0fdca520df19a33158086a8a68e81"}, + {"v1.2.4-annotated", "ede458df7cd0fdca520df19a33158086a8a68e81"}, + }, "sha256"}, + {gitrepo1, "v1", []Tag{ + {"v1.2.3", "ede458df7cd0fdca520df19a33158086a8a68e81"}, + {"v1.2.4-annotated", "ede458df7cd0fdca520df19a33158086a8a68e81"}, + }, "sha1"}, + {gitrepo1, "2", []Tag{}, ""}, + {gitsha256repo, "xxx", []Tag{}, ""}, + {gitsha256repo, "", []Tag{ + {"v1.2.3", "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c"}, + {"v1.2.4-annotated", "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c"}, + {"v1.3.0", "a9157cad2aa6dc2f78aa31fced5887f04e758afa8703f04d0178702ebf04ee17"}, + {"v2.0.1", "b7550fd9d2129c724c39ae0536e8b2fae4364d8c82bb8b0880c9b71f67295d09"}, + {"v2.0.2", "1401e4e1fdb4169b51d44a1ff62af63ccc708bf5c12d15051268b51bbb6cbd82"}, + {"v2.3", "b7550fd9d2129c724c39ae0536e8b2fae4364d8c82bb8b0880c9b71f67295d09"}, + }, ""}, + {gitsha256repo, "v", []Tag{ + {"v1.2.3", "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c"}, + {"v1.2.4-annotated", "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c"}, + {"v1.3.0", "a9157cad2aa6dc2f78aa31fced5887f04e758afa8703f04d0178702ebf04ee17"}, + {"v2.0.1", "b7550fd9d2129c724c39ae0536e8b2fae4364d8c82bb8b0880c9b71f67295d09"}, + {"v2.0.2", "1401e4e1fdb4169b51d44a1ff62af63ccc708bf5c12d15051268b51bbb6cbd82"}, + {"v2.3", "b7550fd9d2129c724c39ae0536e8b2fae4364d8c82bb8b0880c9b71f67295d09"}, + }, ""}, + {gitsha256repo, "v1", []Tag{ + {"v1.2.3", "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c"}, + {"v1.2.4-annotated", "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c"}, + {"v1.3.0", "a9157cad2aa6dc2f78aa31fced5887f04e758afa8703f04d0178702ebf04ee17"}, + }, ""}, + {gitsha256repo, "v1", []Tag{ + {"v1.2.3", "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c"}, + {"v1.2.4-annotated", "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c"}, + {"v1.3.0", "a9157cad2aa6dc2f78aa31fced5887f04e758afa8703f04d0178702ebf04ee17"}, + }, "sha1"}, + {gitsha256repo, "v1", []Tag{ + {"v1.2.3", "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c"}, + {"v1.2.4-annotated", "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c"}, + {"v1.3.0", "a9157cad2aa6dc2f78aa31fced5887f04e758afa8703f04d0178702ebf04ee17"}, + }, "sha256"}, + {gitsha256repo, "2", []Tag{}, ""}, + } { + t.Run(path.Base(tt.repo)+"/"+tt.prefix, runTest(tt)) + if tt.repo == gitrepo1 { + // Clear hashes. + clearTags := []Tag{} + for _, tag := range tt.tags { + clearTags = append(clearTags, Tag{tag.Name, ""}) + } + tags := tt.tags + for _, tt.repo = range altRepos() { + if strings.Contains(tt.repo, "Git") { + tt.tags = tags + } else { + tt.tags = clearTags + } + t.Run(path.Base(tt.repo)+"/"+tt.prefix, runTest(tt)) + } + } + } +} + +func TestLatest(t *testing.T) { + t.Parallel() + + gitVers, gitVersErr := gitVersion() + if gitVersErr != nil { + t.Logf("git version check failed: %s", gitVersErr) + } + + type latestTest struct { + repo string + info *RevInfo + } + runTest := func(tt latestTest) func(*testing.T) { + return func(t *testing.T) { + t.Parallel() + ctx := testContext(t) + + if tt.repo == gitsha256repo && semver.Compare(gitVers, minGitSHA256Vers) < 0 { + t.Skipf("git version is too old (%+v); skipping git sha256 test", gitVers) + } + + r, err := testRepo(ctx, t, tt.repo) + if err != nil { + t.Fatal(err) + } + info, err := r.Latest(ctx) + if err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(info, tt.info) { + t.Errorf("Latest: incorrect info\nhave %+v (origin %+v)\nwant %+v (origin %+v)", info, info.Origin, tt.info, tt.info.Origin) + } + } + } + + for _, tt := range []latestTest{ + { + gitrepo1, + &RevInfo{ + Origin: &Origin{ + VCS: "git", + URL: gitrepo1, + Ref: "HEAD", + Hash: "ede458df7cd0fdca520df19a33158086a8a68e81", + }, + Name: "ede458df7cd0fdca520df19a33158086a8a68e81", + Short: "ede458df7cd0", + Version: "ede458df7cd0fdca520df19a33158086a8a68e81", + Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + Tags: []string{"v1.2.3", "v1.2.4-annotated"}, + }, + }, + { + gitsha256repo, + &RevInfo{ + Origin: &Origin{ + VCS: "git", + URL: gitsha256repo, + Ref: "HEAD", + Hash: "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c", + }, + Name: "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c", + Short: "47b8b51b2a2d", + Version: "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c", + Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + Tags: []string{"v1.2.3", "v1.2.4-annotated"}, + }, + }, + { + hgrepo1, + &RevInfo{ + Origin: &Origin{ + VCS: "hg", + URL: hgrepo1, + Ref: "tip", + Hash: "745aacc8b24decc44ac2b13870f5472b479f4d72", + }, + Name: "745aacc8b24decc44ac2b13870f5472b479f4d72", + Short: "745aacc8b24d", + Version: "745aacc8b24decc44ac2b13870f5472b479f4d72", + Time: time.Date(2018, 6, 27, 16, 16, 10, 0, time.UTC), + }, + }, + } { + t.Run(path.Base(tt.repo), runTest(tt)) + if tt.repo == gitrepo1 { + tt.repo = "localGitRepo" + info := *tt.info + tt.info = &info + o := *info.Origin + info.Origin = &o + o.URL = localGitURL(t) + t.Run(path.Base(tt.repo), runTest(tt)) + } + } +} + +func TestReadFile(t *testing.T) { + t.Parallel() + + gitVers, gitVersErr := gitVersion() + if gitVersErr != nil { + t.Logf("git version check failed: %s", gitVersErr) + } + + type readFileTest struct { + repo string + rev string + file string + err string + data string + } + runTest := func(tt readFileTest) func(*testing.T) { + return func(t *testing.T) { + t.Parallel() + ctx := testContext(t) + + if tt.repo == gitsha256repo && semver.Compare(gitVers, minGitSHA256Vers) < 0 { + t.Skipf("git version is too old (%+v); skipping git sha256 test", gitVers) + } + + r, err := testRepo(ctx, t, tt.repo) + if err != nil { + t.Fatal(err) + } + data, err := r.ReadFile(ctx, tt.rev, tt.file, 100) + if err != nil { + if tt.err == "" { + t.Fatalf("ReadFile: unexpected error %v", err) + } + if !strings.Contains(err.Error(), tt.err) { + t.Fatalf("ReadFile: wrong error %q, want %q", err, tt.err) + } + if len(data) != 0 { + t.Errorf("ReadFile: non-empty data %q with error %v", data, err) + } + return + } + if tt.err != "" { + t.Fatalf("ReadFile: no error, wanted %v", tt.err) + } + if string(data) != tt.data { + t.Errorf("ReadFile: incorrect data\nhave %q\nwant %q", data, tt.data) + } + } + } + + for _, tt := range []readFileTest{ + { + repo: gitrepo1, + rev: "latest", + file: "README", + data: "", + }, + { + repo: gitrepo1, + rev: "v2", + file: "another.txt", + data: "another\n", + }, + { + repo: gitrepo1, + rev: "v2.3.4", + file: "another.txt", + err: fs.ErrNotExist.Error(), + }, + { + repo: gitsha256repo, + rev: "latest", + file: "README", + data: "", + }, + { + repo: gitsha256repo, + rev: "v2", + file: "another.txt", + data: "another\n", + }, + { + repo: gitsha256repo, + rev: "v2.3.4", + file: "another.txt", + err: fs.ErrNotExist.Error(), + }, + } { + t.Run(path.Base(tt.repo)+"/"+tt.rev+"/"+tt.file, runTest(tt)) + if tt.repo == gitrepo1 { + for _, tt.repo = range altRepos() { + t.Run(path.Base(tt.repo)+"/"+tt.rev+"/"+tt.file, runTest(tt)) + } + } + } +} + +type zipFile struct { + name string + size int64 +} + +func TestReadZip(t *testing.T) { + t.Parallel() + + gitVers, gitVersErr := gitVersion() + if gitVersErr != nil { + t.Logf("git version check failed: %s", gitVersErr) + } + + type readZipTest struct { + repo string + rev string + subdir string + err string + files map[string]uint64 + } + runTest := func(tt readZipTest) func(*testing.T) { + return func(t *testing.T) { + t.Parallel() + ctx := testContext(t) + + if tt.repo == gitsha256repo && semver.Compare(gitVers, minGitSHA256Vers) < 0 { + t.Skipf("git version is too old (%+v); skipping git sha256 test", gitVers) + } + + r, err := testRepo(ctx, t, tt.repo) + if err != nil { + t.Fatal(err) + } + rc, err := r.ReadZip(ctx, tt.rev, tt.subdir, 100000) + if err != nil { + if tt.err == "" { + t.Fatalf("ReadZip: unexpected error %v", err) + } + if !strings.Contains(err.Error(), tt.err) { + t.Fatalf("ReadZip: wrong error %q, want %q", err, tt.err) + } + if rc != nil { + t.Errorf("ReadZip: non-nil io.ReadCloser with error %v", err) + } + return + } + defer rc.Close() + if tt.err != "" { + t.Fatalf("ReadZip: no error, wanted %v", tt.err) + } + zipdata, err := io.ReadAll(rc) + if err != nil { + t.Fatal(err) + } + z, err := zip.NewReader(bytes.NewReader(zipdata), int64(len(zipdata))) + if err != nil { + t.Fatalf("ReadZip: cannot read zip file: %v", err) + } + have := make(map[string]bool) + for _, f := range z.File { + size, ok := tt.files[f.Name] + if !ok { + t.Errorf("ReadZip: unexpected file %s", f.Name) + continue + } + have[f.Name] = true + if size != ^uint64(0) && f.UncompressedSize64 != size { + t.Errorf("ReadZip: file %s has unexpected size %d != %d", f.Name, f.UncompressedSize64, size) + } + } + for name := range tt.files { + if !have[name] { + t.Errorf("ReadZip: missing file %s", name) + } + } + } + } + + for _, tt := range []readZipTest{ + { + repo: gitrepo1, + rev: "v2.3.4", + subdir: "", + files: map[string]uint64{ + "prefix/": 0, + "prefix/README": 0, + "prefix/v2": 3, + }, + }, + { + repo: gitsha256repo, + rev: "v2.3.4", + subdir: "", + files: map[string]uint64{ + "prefix/": 0, + "prefix/README": 0, + "prefix/v2": 3, + }, + }, + { + repo: hgrepo1, + rev: "v2.3.4", + subdir: "", + files: map[string]uint64{ + "prefix/.hg_archival.txt": ^uint64(0), + "prefix/README": 0, + "prefix/v2": 3, + }, + }, + + { + repo: gitrepo1, + rev: "v2", + subdir: "", + files: map[string]uint64{ + "prefix/": 0, + "prefix/README": 0, + "prefix/v2": 3, + "prefix/another.txt": 8, + "prefix/foo.txt": 13, + }, + }, + { + repo: gitsha256repo, + rev: "v2", + subdir: "", + files: map[string]uint64{ + "prefix/": 0, + "prefix/README": 0, + "prefix/v2": 3, + "prefix/another.txt": 8, + "prefix/foo.txt": 13, + }, + }, + { + repo: hgrepo1, + rev: "v2", + subdir: "", + files: map[string]uint64{ + "prefix/.hg_archival.txt": ^uint64(0), + "prefix/README": 0, + "prefix/v2": 3, + "prefix/another.txt": 8, + "prefix/foo.txt": 13, + }, + }, + + { + repo: gitrepo1, + rev: "v3", + subdir: "", + files: map[string]uint64{ + "prefix/": 0, + "prefix/v3/": 0, + "prefix/v3/sub/": 0, + "prefix/v3/sub/dir/": 0, + "prefix/v3/sub/dir/file.txt": 16, + "prefix/README": 0, + }, + }, + { + repo: gitsha256repo, + rev: "v3", + subdir: "", + files: map[string]uint64{ + "prefix/": 0, + "prefix/v3/": 0, + "prefix/v3/sub/": 0, + "prefix/v3/sub/dir/": 0, + "prefix/v3/sub/dir/file.txt": 16, + "prefix/README": 0, + }, + }, + { + repo: hgrepo1, + rev: "v3", + subdir: "", + files: map[string]uint64{ + "prefix/.hg_archival.txt": ^uint64(0), + "prefix/v3/sub/dir/file.txt": 16, + "prefix/README": 0, + }, + }, + + { + repo: gitrepo1, + rev: "v3", + subdir: "v3/sub/dir", + files: map[string]uint64{ + "prefix/": 0, + "prefix/v3/": 0, + "prefix/v3/sub/": 0, + "prefix/v3/sub/dir/": 0, + "prefix/v3/sub/dir/file.txt": 16, + }, + }, + { + repo: gitsha256repo, + rev: "v3", + subdir: "v3/sub/dir", + files: map[string]uint64{ + "prefix/": 0, + "prefix/v3/": 0, + "prefix/v3/sub/": 0, + "prefix/v3/sub/dir/": 0, + "prefix/v3/sub/dir/file.txt": 16, + }, + }, + { + repo: hgrepo1, + rev: "v3", + subdir: "v3/sub/dir", + files: map[string]uint64{ + "prefix/v3/sub/dir/file.txt": 16, + }, + }, + + { + repo: gitrepo1, + rev: "v3", + subdir: "v3/sub", + files: map[string]uint64{ + "prefix/": 0, + "prefix/v3/": 0, + "prefix/v3/sub/": 0, + "prefix/v3/sub/dir/": 0, + "prefix/v3/sub/dir/file.txt": 16, + }, + }, + { + repo: gitsha256repo, + rev: "v3", + subdir: "v3/sub", + files: map[string]uint64{ + "prefix/": 0, + "prefix/v3/": 0, + "prefix/v3/sub/": 0, + "prefix/v3/sub/dir/": 0, + "prefix/v3/sub/dir/file.txt": 16, + }, + }, + { + repo: hgrepo1, + rev: "v3", + subdir: "v3/sub", + files: map[string]uint64{ + "prefix/v3/sub/dir/file.txt": 16, + }, + }, + + { + repo: gitrepo1, + rev: "aaaaaaaaab", + subdir: "", + err: "unknown revision", + }, + { + repo: gitsha256repo, + rev: "aaaaaaaaab", + subdir: "", + err: "unknown revision", + }, + { + repo: hgrepo1, + rev: "aaaaaaaaab", + subdir: "", + err: "unknown revision", + }, + + { + repo: vgotest1, + rev: "submod/v1.0.4", + subdir: "submod", + files: map[string]uint64{ + "prefix/": 0, + "prefix/submod/": 0, + "prefix/submod/go.mod": 53, + "prefix/submod/pkg/": 0, + "prefix/submod/pkg/p.go": 31, + }, + }, + } { + t.Run(path.Base(tt.repo)+"/"+tt.rev+"/"+tt.subdir, runTest(tt)) + if tt.repo == gitrepo1 { + tt.repo = "localGitRepo" + t.Run(path.Base(tt.repo)+"/"+tt.rev+"/"+tt.subdir, runTest(tt)) + } + } +} + +var hgmap = map[string]string{ + "HEAD": "c0186fb00e50985709b12266419f50bf11860166", + "9d02800338b8a55be062c838d1f02e0c5780b9eb": "b1ed98abc2683d326f89b924875bf14bd584898e", // v2.0.2, v2 + "76a00fb249b7f93091bc2c89a789dab1fc1bc26f": "a546811101e11d6aff2ac72072d2d439b3a88f33", // v2.3, v2.0.1 + "ede458df7cd0fdca520df19a33158086a8a68e81": "c0186fb00e50985709b12266419f50bf11860166", // v1.2.3, v1.2.4-annotated + "97f6aa59c81c623494825b43d39e445566e429a4": "c1638e3673b121d9c83e92166fce2a25dcadd6cb", // foo.txt commit on v2.3.4 branch +} + +func TestStat(t *testing.T) { + t.Parallel() + + gitVers, gitVersErr := gitVersion() + if gitVersErr != nil { + t.Logf("git version check failed: %s", gitVersErr) + } + + type statTest struct { + repo string + rev string + err string + info *RevInfo + } + runTest := func(tt statTest) func(*testing.T) { + return func(t *testing.T) { + t.Parallel() + ctx := testContext(t) + + if tt.repo == gitsha256repo && semver.Compare(gitVers, minGitSHA256Vers) < 0 { + t.Skipf("git version is too old (%+v); skipping git sha256 test", gitVers) + } + + r, err := testRepo(ctx, t, tt.repo) + if err != nil { + t.Fatal(err) + } + info, err := r.Stat(ctx, tt.rev) + if err != nil { + if tt.err == "" { + t.Fatalf("Stat: unexpected error %v", err) + } + if !strings.Contains(err.Error(), tt.err) { + t.Fatalf("Stat: wrong error %q, want %q", err, tt.err) + } + if info != nil && info.Origin == nil { + t.Errorf("Stat: non-nil info with nil Origin with error %q", err) + } + return + } + info.Origin = nil // TestLatest and ../../../testdata/script/reuse_git.txt test Origin well enough + if !reflect.DeepEqual(info, tt.info) { + t.Errorf("Stat: incorrect info\nhave %+v\nwant %+v", *info, *tt.info) + } + } + } + + for _, tt := range []statTest{ + { + repo: gitrepo1, + rev: "HEAD", + info: &RevInfo{ + Name: "ede458df7cd0fdca520df19a33158086a8a68e81", + Short: "ede458df7cd0", + Version: "ede458df7cd0fdca520df19a33158086a8a68e81", + Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + Tags: []string{"v1.2.3", "v1.2.4-annotated"}, + }, + }, + { + repo: gitrepo1, + rev: "v2", // branch + info: &RevInfo{ + Name: "9d02800338b8a55be062c838d1f02e0c5780b9eb", + Short: "9d02800338b8", + Version: "9d02800338b8a55be062c838d1f02e0c5780b9eb", + Time: time.Date(2018, 4, 17, 20, 00, 32, 0, time.UTC), + Tags: []string{"v2.0.2"}, + }, + }, + { + repo: gitrepo1, + rev: "v2.3.4", // badly-named branch (semver should be a tag) + info: &RevInfo{ + Name: "76a00fb249b7f93091bc2c89a789dab1fc1bc26f", + Short: "76a00fb249b7", + Version: "76a00fb249b7f93091bc2c89a789dab1fc1bc26f", + Time: time.Date(2018, 4, 17, 19, 45, 48, 0, time.UTC), + Tags: []string{"v2.0.1", "v2.3"}, + }, + }, + { + repo: gitrepo1, + rev: "v2.3", // badly-named tag (we only respect full semver v2.3.0) + info: &RevInfo{ + Name: "76a00fb249b7f93091bc2c89a789dab1fc1bc26f", + Short: "76a00fb249b7", + Version: "v2.3", + Time: time.Date(2018, 4, 17, 19, 45, 48, 0, time.UTC), + Tags: []string{"v2.0.1", "v2.3"}, + }, + }, + { + repo: gitrepo1, + rev: "v1.2.3", // tag + info: &RevInfo{ + Name: "ede458df7cd0fdca520df19a33158086a8a68e81", + Short: "ede458df7cd0", + Version: "v1.2.3", + Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + Tags: []string{"v1.2.3", "v1.2.4-annotated"}, + }, + }, + { + repo: gitrepo1, + rev: "ede458df", // hash prefix in refs + info: &RevInfo{ + Name: "ede458df7cd0fdca520df19a33158086a8a68e81", + Short: "ede458df7cd0", + Version: "ede458df7cd0fdca520df19a33158086a8a68e81", + Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + Tags: []string{"v1.2.3", "v1.2.4-annotated"}, + }, + }, + { + repo: gitrepo1, + rev: "97f6aa59", // hash prefix not in refs + info: &RevInfo{ + Name: "97f6aa59c81c623494825b43d39e445566e429a4", + Short: "97f6aa59c81c", + Version: "97f6aa59c81c623494825b43d39e445566e429a4", + Time: time.Date(2018, 4, 17, 20, 0, 19, 0, time.UTC), + }, + }, + { + repo: gitrepo1, + rev: "v1.2.4-annotated", // annotated tag uses unwrapped commit hash + info: &RevInfo{ + Name: "ede458df7cd0fdca520df19a33158086a8a68e81", + Short: "ede458df7cd0", + Version: "v1.2.4-annotated", + Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + Tags: []string{"v1.2.3", "v1.2.4-annotated"}, + }, + }, + { + repo: gitrepo1, + rev: "aaaaaaaaab", + err: "unknown revision", + }, + { + repo: gitsha256repo, + rev: "HEAD", + info: &RevInfo{ + Name: "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c", + Short: "47b8b51b2a2d", + Version: "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c", + Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + Tags: []string{"v1.2.3", "v1.2.4-annotated"}, + }, + }, + { + repo: gitsha256repo, + rev: "v2", // branch + info: &RevInfo{ + Name: "1401e4e1fdb4169b51d44a1ff62af63ccc708bf5c12d15051268b51bbb6cbd82", + Short: "1401e4e1fdb4", + Version: "1401e4e1fdb4169b51d44a1ff62af63ccc708bf5c12d15051268b51bbb6cbd82", + Time: time.Date(2018, 4, 17, 20, 00, 32, 0, time.UTC), + Tags: []string{"v2.0.2"}, + }, + }, + { + repo: gitsha256repo, + rev: "v2.3.4", // badly-named branch (semver should be a tag) + info: &RevInfo{ + Name: "b7550fd9d2129c724c39ae0536e8b2fae4364d8c82bb8b0880c9b71f67295d09", + Short: "b7550fd9d212", + Version: "b7550fd9d2129c724c39ae0536e8b2fae4364d8c82bb8b0880c9b71f67295d09", + Time: time.Date(2018, 4, 17, 19, 45, 48, 0, time.UTC), + Tags: []string{"v2.0.1", "v2.3"}, + }, + }, + { + repo: gitsha256repo, + rev: "v2.3", // badly-named tag (we only respect full semver v2.3.0) + info: &RevInfo{ + Name: "b7550fd9d2129c724c39ae0536e8b2fae4364d8c82bb8b0880c9b71f67295d09", + Short: "b7550fd9d212", + Version: "v2.3", + Time: time.Date(2018, 4, 17, 19, 45, 48, 0, time.UTC), + Tags: []string{"v2.0.1", "v2.3"}, + }, + }, + { + repo: gitsha256repo, + rev: "v1.2.3", // tag + info: &RevInfo{ + Name: "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c", + Short: "47b8b51b2a2d", + Version: "v1.2.3", + Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + Tags: []string{"v1.2.3", "v1.2.4-annotated"}, + }, + }, + { + repo: gitsha256repo, + rev: "47b8b51b", // hash prefix in refs + info: &RevInfo{ + Name: "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c", + Short: "47b8b51b2a2d", + Version: "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c", + Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + Tags: []string{"v1.2.3", "v1.2.4-annotated"}, + }, + }, + { + repo: gitsha256repo, + rev: "0be440b6", // hash prefix not in refs + info: &RevInfo{ + Name: "0be440b60b6c81be26c7256781d8e57112ec46c8cd1a9481a8e78a283f10570c", + Short: "0be440b60b6c", + Version: "0be440b60b6c81be26c7256781d8e57112ec46c8cd1a9481a8e78a283f10570c", + Time: time.Date(2018, 4, 17, 20, 0, 19, 0, time.UTC), + }, + }, + { + repo: gitsha256repo, + rev: "v1.2.4-annotated", // annotated tag uses unwrapped commit hash + info: &RevInfo{ + Name: "47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c", + Short: "47b8b51b2a2d", + Version: "v1.2.4-annotated", + Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + Tags: []string{"v1.2.3", "v1.2.4-annotated"}, + }, + }, + { + repo: gitsha256repo, + rev: "aaaaaaaaab", + err: "unknown revision", + }, + } { + t.Run(path.Base(tt.repo)+"/"+tt.rev, runTest(tt)) + if tt.repo == gitrepo1 { + for _, tt.repo = range altRepos() { + old := tt + var m map[string]string + if tt.repo == hgrepo1 { + m = hgmap + } + if tt.info != nil { + info := *tt.info + tt.info = &info + tt.info.Name = remap(tt.info.Name, m) + tt.info.Version = remap(tt.info.Version, m) + tt.info.Short = remap(tt.info.Short, m) + } + tt.rev = remap(tt.rev, m) + t.Run(path.Base(tt.repo)+"/"+tt.rev, runTest(tt)) + tt = old + } + } + } +} + +func remap(name string, m map[string]string) string { + if m[name] != "" { + return m[name] + } + if AllHex(name) { + for k, v := range m { + if strings.HasPrefix(k, name) { + return v[:len(name)] + } + } + } + return name +} diff --git a/go/src/cmd/go/internal/modfetch/codehost/shell.go b/go/src/cmd/go/internal/modfetch/codehost/shell.go new file mode 100644 index 0000000000000000000000000000000000000000..eaa01950b95ef395e57ac6f8d85036c44b6ff911 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/codehost/shell.go @@ -0,0 +1,141 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +// Interactive debugging shell for codehost.Repo implementations. + +package main + +import ( + "archive/zip" + "bufio" + "bytes" + "flag" + "fmt" + "io" + "log" + "os" + "strings" + "time" + + "cmd/go/internal/cfg" + "cmd/go/internal/modfetch/codehost" +) + +func usage() { + fmt.Fprintf(os.Stderr, "usage: go run shell.go vcs remote\n") + os.Exit(2) +} + +func main() { + cfg.GOMODCACHE = "/tmp/vcswork" + log.SetFlags(0) + log.SetPrefix("shell: ") + flag.Usage = usage + flag.Parse() + if flag.NArg() != 2 { + usage() + } + + repo, err := codehost.NewRepo(flag.Arg(0), flag.Arg(1)) + if err != nil { + log.Fatal(err) + } + + b := bufio.NewReader(os.Stdin) + for { + fmt.Fprintf(os.Stderr, ">>> ") + line, err := b.ReadString('\n') + if err != nil { + log.Fatal(err) + } + f := strings.Fields(line) + if len(f) == 0 { + continue + } + switch f[0] { + default: + fmt.Fprintf(os.Stderr, "?unknown command\n") + continue + case "tags": + prefix := "" + if len(f) == 2 { + prefix = f[1] + } + if len(f) > 2 { + fmt.Fprintf(os.Stderr, "?usage: tags [prefix]\n") + continue + } + tags, err := repo.Tags(prefix) + if err != nil { + fmt.Fprintf(os.Stderr, "?%s\n", err) + continue + } + for _, tag := range tags { + fmt.Printf("%s\n", tag) + } + + case "stat": + if len(f) != 2 { + fmt.Fprintf(os.Stderr, "?usage: stat rev\n") + continue + } + info, err := repo.Stat(f[1]) + if err != nil { + fmt.Fprintf(os.Stderr, "?%s\n", err) + continue + } + fmt.Printf("name=%s short=%s version=%s time=%s\n", info.Name, info.Short, info.Version, info.Time.UTC().Format(time.RFC3339)) + + case "read": + if len(f) != 3 { + fmt.Fprintf(os.Stderr, "?usage: read rev file\n") + continue + } + data, err := repo.ReadFile(f[1], f[2], 10<<20) + if err != nil { + fmt.Fprintf(os.Stderr, "?%s\n", err) + continue + } + os.Stdout.Write(data) + + case "zip": + if len(f) != 4 { + fmt.Fprintf(os.Stderr, "?usage: zip rev subdir output\n") + continue + } + subdir := f[2] + if subdir == "-" { + subdir = "" + } + rc, err := repo.ReadZip(f[1], subdir, 10<<20) + if err != nil { + fmt.Fprintf(os.Stderr, "?%s\n", err) + continue + } + data, err := io.ReadAll(rc) + rc.Close() + if err != nil { + fmt.Fprintf(os.Stderr, "?%s\n", err) + continue + } + + if f[3] != "-" { + if err := os.WriteFile(f[3], data, 0666); err != nil { + fmt.Fprintf(os.Stderr, "?%s\n", err) + continue + } + } + z, err := zip.NewReader(bytes.NewReader(data), int64(len(data))) + if err != nil { + fmt.Fprintf(os.Stderr, "?%s\n", err) + continue + } + for _, f := range z.File { + fmt.Printf("%s %d\n", f.Name, f.UncompressedSize64) + } + } + } +} diff --git a/go/src/cmd/go/internal/modfetch/codehost/svn.go b/go/src/cmd/go/internal/modfetch/codehost/svn.go new file mode 100644 index 0000000000000000000000000000000000000000..9c1c10097bb437486f394b5a0304d487732edf78 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/codehost/svn.go @@ -0,0 +1,168 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package codehost + +import ( + "archive/zip" + "context" + "encoding/xml" + "fmt" + "io" + "os" + "path" + "path/filepath" + "strconv" + "time" + + "cmd/go/internal/base" +) + +func svnParseStat(rev, out string) (*RevInfo, error) { + var log struct { + Logentry struct { + Revision int64 `xml:"revision,attr"` + Date string `xml:"date"` + } `xml:"logentry"` + } + if err := xml.Unmarshal([]byte(out), &log); err != nil { + return nil, vcsErrorf("unexpected response from svn log --xml: %v\n%s", err, out) + } + + t, err := time.Parse(time.RFC3339, log.Logentry.Date) + if err != nil { + return nil, vcsErrorf("unexpected response from svn log --xml: %v\n%s", err, out) + } + + info := &RevInfo{ + Name: strconv.FormatInt(log.Logentry.Revision, 10), + Short: fmt.Sprintf("%012d", log.Logentry.Revision), + Time: t.UTC(), + Version: rev, + } + return info, nil +} + +func svnReadZip(ctx context.Context, dst io.Writer, workDir, rev, subdir, remote string) (err error) { + // The subversion CLI doesn't provide a command to write the repository + // directly to an archive, so we need to export it to the local filesystem + // instead. Unfortunately, the local filesystem might apply arbitrary + // normalization to the filenames, so we need to obtain those directly. + // + // 'svn export' prints the filenames as they are written, but from reading the + // svn source code (as of revision 1868933), those filenames are encoded using + // the system locale rather than preserved byte-for-byte from the origin. For + // our purposes, that won't do, but we don't want to go mucking around with + // the user's locale settings either — that could impact error messages, and + // we don't know what locales the user has available or what LC_* variables + // their platform supports. + // + // Instead, we'll do a two-pass export: first we'll run 'svn list' to get the + // canonical filenames, then we'll 'svn export' and look for those filenames + // in the local filesystem. (If there is an encoding problem at that point, we + // would probably reject the resulting module anyway.) + + remotePath := remote + if subdir != "" { + remotePath += "/" + subdir + } + + release, err := base.AcquireNet() + if err != nil { + return err + } + out, err := Run(ctx, workDir, []string{ + "svn", "list", + "--non-interactive", + "--xml", + "--incremental", + "--recursive", + "--revision", rev, + "--", remotePath, + }) + release() + if err != nil { + return err + } + + type listEntry struct { + Kind string `xml:"kind,attr"` + Name string `xml:"name"` + Size int64 `xml:"size"` + } + var list struct { + Entries []listEntry `xml:"entry"` + } + if err := xml.Unmarshal(out, &list); err != nil { + return vcsErrorf("unexpected response from svn list --xml: %v\n%s", err, out) + } + + exportDir := filepath.Join(workDir, "export") + // Remove any existing contents from a previous (failed) run. + if err := os.RemoveAll(exportDir); err != nil { + return err + } + defer os.RemoveAll(exportDir) // best-effort + + release, err = base.AcquireNet() + if err != nil { + return err + } + _, err = Run(ctx, workDir, []string{ + "svn", "export", + "--non-interactive", + "--quiet", + + // Suppress any platform- or host-dependent transformations. + "--native-eol", "LF", + "--ignore-externals", + "--ignore-keywords", + + "--revision", rev, + "--", remotePath, + exportDir, + }) + release() + if err != nil { + return err + } + + // Scrape the exported files out of the filesystem and encode them in the zipfile. + + // “All files in the zip file are expected to be + // nested in a single top-level directory, whose name is not specified.” + // We'll (arbitrarily) choose the base of the remote path. + basePath := path.Join(path.Base(remote), subdir) + + zw := zip.NewWriter(dst) + for _, e := range list.Entries { + if e.Kind != "file" { + continue + } + + zf, err := zw.Create(path.Join(basePath, e.Name)) + if err != nil { + return err + } + + f, err := os.Open(filepath.Join(exportDir, e.Name)) + if err != nil { + if os.IsNotExist(err) { + return vcsErrorf("file reported by 'svn list', but not written by 'svn export': %s", e.Name) + } + return fmt.Errorf("error opening file created by 'svn export': %v", err) + } + + n, err := io.Copy(zf, f) + f.Close() + if err != nil { + return err + } + if n != e.Size { + return vcsErrorf("file size differs between 'svn list' and 'svn export': file %s listed as %v bytes, but exported as %v bytes", e.Name, e.Size, n) + } + } + + return zw.Close() +} diff --git a/go/src/cmd/go/internal/modfetch/codehost/vcs.go b/go/src/cmd/go/internal/modfetch/codehost/vcs.go new file mode 100644 index 0000000000000000000000000000000000000000..59264a3b90eb416e57b721fb8a03d8d2be384d2b --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/codehost/vcs.go @@ -0,0 +1,835 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package codehost + +import ( + "context" + "errors" + "fmt" + "internal/lazyregexp" + "io" + "io/fs" + "os" + "path/filepath" + "sort" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/lockedfile" + "cmd/go/internal/str" + "cmd/internal/par" + + "golang.org/x/mod/semver" +) + +// A VCSError indicates an error using a version control system. +// The implication of a VCSError is that we know definitively where +// to get the code, but we can't access it due to the error. +// The caller should report this error instead of continuing to probe +// other possible module paths. +// +// TODO(golang.org/issue/31730): See if we can invert this. (Return a +// distinguished error for “repo not found” and treat everything else +// as terminal.) +type VCSError struct { + Err error +} + +func (e *VCSError) Error() string { return e.Err.Error() } + +func (e *VCSError) Unwrap() error { return e.Err } + +func vcsErrorf(format string, a ...any) error { + return &VCSError{Err: fmt.Errorf(format, a...)} +} + +type vcsCacheKey struct { + vcs string + remote string + local bool +} + +func NewRepo(ctx context.Context, vcs, remote string, local bool) (Repo, error) { + return vcsRepoCache.Do(vcsCacheKey{vcs, remote, local}, func() (Repo, error) { + repo, err := newVCSRepo(ctx, vcs, remote, local) + if err != nil { + return nil, &VCSError{err} + } + return repo, nil + }) +} + +var vcsRepoCache par.ErrCache[vcsCacheKey, Repo] + +type vcsRepo struct { + mu lockedfile.Mutex // protects all commands, so we don't have to decide which are safe on a per-VCS basis + + remote string + cmd *vcsCmd + dir string + local bool + + tagsOnce sync.Once + tags map[string]bool + + branchesOnce sync.Once + branches map[string]bool + + fetchOnce sync.Once + fetchErr error + fetched atomic.Bool + + repoSumOnce sync.Once + repoSum string +} + +func newVCSRepo(ctx context.Context, vcs, remote string, local bool) (Repo, error) { + if vcs == "git" { + return newGitRepo(ctx, remote, local) + } + r := &vcsRepo{remote: remote, local: local} + cmd := vcsCmds[vcs] + if cmd == nil { + return nil, fmt.Errorf("unknown vcs: %s %s", vcs, remote) + } + r.cmd = cmd + if local { + info, err := os.Stat(remote) + if err != nil { + return nil, err + } + if !info.IsDir() { + return nil, fmt.Errorf("%s exists but is not a directory", remote) + } + r.dir = remote + r.mu.Path = r.dir + ".lock" + return r, nil + } + if !strings.Contains(remote, "://") { + return nil, fmt.Errorf("invalid vcs remote: %s %s", vcs, remote) + } + var err error + r.dir, r.mu.Path, err = WorkDir(ctx, vcsWorkDirType+vcs, r.remote) + if err != nil { + return nil, err + } + + if cmd.init == nil { + return r, nil + } + + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + + if _, err := os.Stat(filepath.Join(r.dir, "."+vcs)); err != nil { + release, err := base.AcquireNet() + if err != nil { + return nil, err + } + _, err = Run(ctx, r.dir, cmd.init(r.remote)) + if err == nil && cmd.postInit != nil { + err = cmd.postInit(ctx, r) + } + release() + + if err != nil { + os.RemoveAll(r.dir) + return nil, err + } + } + return r, nil +} + +const vcsWorkDirType = "vcs1." + +type vcsCmd struct { + vcs string // vcs name "hg" + init func(remote string) []string // cmd to init repo to track remote + postInit func(context.Context, *vcsRepo) error // func to init repo after .init runs + repoSum func(remote string) []string // cmd to calculate reposum of remote repo + lookupRef func(remote, ref string) []string // cmd to look up ref in remote repo + tags func(remote string) []string // cmd to list local tags + tagsNeedsFetch bool // run fetch before tags + tagRE *lazyregexp.Regexp // regexp to extract tag names from output of tags cmd + branches func(remote string) []string // cmd to list local branches + branchesNeedsFetch bool // run branches before tags + branchRE *lazyregexp.Regexp // regexp to extract branch names from output of tags cmd + badLocalRevRE *lazyregexp.Regexp // regexp of names that must not be served out of local cache without doing fetch first + statLocal func(rev, remote string) []string // cmd to stat local rev + parseStat func(rev, out string) (*RevInfo, error) // func to parse output of statLocal + fetch []string // cmd to fetch everything from remote + latest string // name of latest commit on remote (tip, HEAD, etc) + descendsFrom func(rev, tag string) []string // cmd to check whether rev descends from tag + recentTags func(rev string) []string // cmd to print tag ancestors of rev + readFile func(rev, file, remote string) []string // cmd to read rev's file + readZip func(rev, subdir, remote, target string) []string // cmd to read rev's subdir as zip file + + // arbitrary function to read rev's subdir as zip file + doReadZip func(ctx context.Context, dst io.Writer, workDir, rev, subdir, remote string) error +} + +var re = lazyregexp.New + +var vcsCmds = map[string]*vcsCmd{ + "hg": { + vcs: "hg", + repoSum: func(remote string) []string { + return []string{ + "hg", + "--config=extensions.goreposum=" + filepath.Join(cfg.GOROOT, "lib/hg/goreposum.py"), + "goreposum", + "--", + remote, + } + }, + lookupRef: func(remote, ref string) []string { + return []string{ + "hg", + "--config=extensions.goreposum=" + filepath.Join(cfg.GOROOT, "lib/hg/goreposum.py"), + "golookup", + "--", + remote, + ref, + } + }, + init: func(remote string) []string { + return []string{"hg", "init", "."} + }, + postInit: hgAddRemote, + tags: func(remote string) []string { + return []string{"hg", "tags", "-q"} + }, + tagsNeedsFetch: true, + tagRE: re(`(?m)^[^\n]+$`), + branches: func(remote string) []string { + return []string{"hg", "branches", "-c", "-q"} + }, + branchesNeedsFetch: true, + branchRE: re(`(?m)^[^\n]+$`), + badLocalRevRE: re(`(?m)^(tip)$`), + statLocal: func(rev, remote string) []string { + return []string{"hg", "log", "-l1", fmt.Sprintf("--rev=%s", rev), "--template", "{node} {date|hgdate} {tags}"} + }, + parseStat: hgParseStat, + fetch: []string{"hg", "pull", "-f"}, + latest: "tip", + descendsFrom: func(rev, tag string) []string { + return []string{"hg", "log", "--rev=ancestors(" + rev + ") and " + tag} + }, + recentTags: func(rev string) []string { + return []string{"hg", "log", "--rev=ancestors(" + rev + ") and tag()", "--template", "{tags}\n"} + }, + readFile: func(rev, file, remote string) []string { + return []string{"hg", "cat", fmt.Sprintf("--rev=%s", rev), "--", file} + }, + readZip: func(rev, subdir, remote, target string) []string { + pattern := []string{} + if subdir != "" { + pattern = []string{fmt.Sprintf("--include=%s", subdir+"/**")} + } + return str.StringList("hg", "archive", "-t", "zip", "--no-decode", fmt.Sprintf("--rev=%s", rev), "--prefix=prefix/", pattern, "--", target) + }, + }, + + "svn": { + vcs: "svn", + init: nil, // no local checkout + tags: func(remote string) []string { + return []string{"svn", "list", "--", strings.TrimSuffix(remote, "/trunk") + "/tags"} + }, + tagRE: re(`(?m)^(.*?)/?$`), + statLocal: func(rev, remote string) []string { + suffix := "@" + rev + if rev == "latest" { + suffix = "" + } + return []string{"svn", "log", "-l1", "--xml", "--", remote + suffix} + }, + parseStat: svnParseStat, + latest: "latest", + readFile: func(rev, file, remote string) []string { + return []string{"svn", "cat", "--", remote + "/" + file + "@" + rev} + }, + doReadZip: svnReadZip, + }, + + "bzr": { + vcs: "bzr", + init: func(remote string) []string { + return []string{"bzr", "branch", "--use-existing-dir", "--", remote, "."} + }, + fetch: []string{ + "bzr", "pull", "--overwrite-tags", + }, + tags: func(remote string) []string { + return []string{"bzr", "tags"} + }, + tagRE: re(`(?m)^\S+`), + badLocalRevRE: re(`^revno:-`), + statLocal: func(rev, remote string) []string { + return []string{"bzr", "log", "-l1", "--long", "--show-ids", fmt.Sprintf("--revision=%s", rev)} + }, + parseStat: bzrParseStat, + latest: "revno:-1", + readFile: func(rev, file, remote string) []string { + return []string{"bzr", "cat", fmt.Sprintf("--revision=%s", rev), "--", file} + }, + readZip: func(rev, subdir, remote, target string) []string { + extra := []string{} + if subdir != "" { + extra = []string{"./" + subdir} + } + return str.StringList("bzr", "export", "--format=zip", fmt.Sprintf("--revision=%s", rev), "--root=prefix/", "--", target, extra) + }, + }, + + "fossil": { + vcs: "fossil", + init: func(remote string) []string { + return []string{"fossil", "clone", "--", remote, ".fossil"} + }, + fetch: []string{"fossil", "pull", "-R", ".fossil"}, + tags: func(remote string) []string { + return []string{"fossil", "tag", "-R", ".fossil", "list"} + }, + tagRE: re(`XXXTODO`), + statLocal: func(rev, remote string) []string { + return []string{"fossil", "info", "-R", ".fossil", "--", rev} + }, + parseStat: fossilParseStat, + latest: "trunk", + readFile: func(rev, file, remote string) []string { + return []string{"fossil", "cat", "-R", ".fossil", fmt.Sprintf("-r=%s", rev), "--", file} + }, + readZip: func(rev, subdir, remote, target string) []string { + extra := []string{} + if subdir != "" && !strings.ContainsAny(subdir, "*?[],") { + extra = []string{fmt.Sprintf("--include=%s", subdir)} + } + // Note that vcsRepo.ReadZip below rewrites this command + // to run in a different directory, to work around a fossil bug. + return str.StringList("fossil", "zip", "-R", ".fossil", "--name", "prefix", extra, "--", rev, target) + }, + }, +} + +func (r *vcsRepo) loadTags(ctx context.Context) { + if r.cmd.tagsNeedsFetch { + r.fetchOnce.Do(func() { r.fetch(ctx) }) + } + + out, err := Run(ctx, r.dir, r.cmd.tags(r.remote)) + if err != nil { + return + } + + // Run tag-listing command and extract tags. + r.tags = make(map[string]bool) + for _, tag := range r.cmd.tagRE.FindAllString(string(out), -1) { + if r.cmd.badLocalRevRE != nil && r.cmd.badLocalRevRE.MatchString(tag) { + continue + } + r.tags[tag] = true + } +} + +func (r *vcsRepo) loadBranches(ctx context.Context) { + if r.cmd.branches == nil { + return + } + + if r.cmd.branchesNeedsFetch { + r.fetchOnce.Do(func() { r.fetch(ctx) }) + } + + out, err := Run(ctx, r.dir, r.cmd.branches(r.remote)) + if err != nil { + return + } + + r.branches = make(map[string]bool) + for _, branch := range r.cmd.branchRE.FindAllString(string(out), -1) { + if r.cmd.badLocalRevRE != nil && r.cmd.badLocalRevRE.MatchString(branch) { + continue + } + r.branches[branch] = true + } +} + +func (r *vcsRepo) loadRepoSum(ctx context.Context) { + if r.cmd.repoSum == nil { + return + } + where := r.remote + if r.fetched.Load() { + where = "." // use local repo + } + out, err := Run(ctx, r.dir, r.cmd.repoSum(where)) + if err != nil { + return + } + r.repoSum = strings.TrimSpace(string(out)) +} + +func (r *vcsRepo) lookupRef(ctx context.Context, ref string) (string, error) { + if r.cmd.lookupRef == nil { + return "", fmt.Errorf("no lookupRef") + } + out, err := Run(ctx, r.dir, r.cmd.lookupRef(r.remote, ref)) + if err != nil { + return "", err + } + return strings.TrimSpace(string(out)), nil +} + +// repoSumOrigin returns an Origin containing a RepoSum. +func (r *vcsRepo) repoSumOrigin(ctx context.Context) *Origin { + origin := &Origin{ + VCS: r.cmd.vcs, + URL: r.remote, + RepoSum: r.repoSum, + } + r.repoSumOnce.Do(func() { r.loadRepoSum(ctx) }) + origin.RepoSum = r.repoSum + return origin +} + +func (r *vcsRepo) CheckReuse(ctx context.Context, old *Origin, subdir string) error { + if old == nil { + return fmt.Errorf("missing origin") + } + if old.VCS != r.cmd.vcs || old.URL != r.remote { + return fmt.Errorf("origin moved from %v %q to %v %q", old.VCS, old.URL, r.cmd.vcs, r.remote) + } + if old.Subdir != subdir { + return fmt.Errorf("origin moved from %v %q %q to %v %q %q", old.VCS, old.URL, old.Subdir, r.cmd.vcs, r.remote, subdir) + } + + if old.Ref == "" && old.RepoSum == "" && old.Hash != "" { + // Hash has to remain in repo. + hash, err := r.lookupRef(ctx, old.Hash) + if err == nil && hash == old.Hash { + return nil + } + if err != nil { + return fmt.Errorf("looking up hash: %v", err) + } + return fmt.Errorf("hash changed") // weird but maybe they made a tag + } + + if old.Ref != "" && old.RepoSum == "" { + hash, err := r.lookupRef(ctx, old.Ref) + if err == nil && hash != "" && hash == old.Hash { + return nil + } + } + + r.repoSumOnce.Do(func() { r.loadRepoSum(ctx) }) + if r.repoSum != "" { + if old.RepoSum == "" { + return fmt.Errorf("non-specific origin") + } + if old.RepoSum != r.repoSum { + return fmt.Errorf("repo changed") + } + return nil + } + return fmt.Errorf("vcs %s: CheckReuse: %w", r.cmd.vcs, errors.ErrUnsupported) +} + +func (r *vcsRepo) Tags(ctx context.Context, prefix string) (*Tags, error) { + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + + r.tagsOnce.Do(func() { r.loadTags(ctx) }) + tags := &Tags{ + Origin: r.repoSumOrigin(ctx), + List: []Tag{}, + } + for tag := range r.tags { + if strings.HasPrefix(tag, prefix) { + tags.List = append(tags.List, Tag{tag, ""}) + } + } + sort.Slice(tags.List, func(i, j int) bool { + return tags.List[i].Name < tags.List[j].Name + }) + return tags, nil +} + +func (r *vcsRepo) Stat(ctx context.Context, rev string) (*RevInfo, error) { + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + + if rev == "latest" { + rev = r.cmd.latest + } + r.branchesOnce.Do(func() { r.loadBranches(ctx) }) + if r.local { + // Ignore the badLocalRevRE precondition in local only mode. + // We cannot fetch latest upstream changes so only serve what's in the local cache. + return r.statLocal(ctx, rev) + } + revOK := (r.cmd.badLocalRevRE == nil || !r.cmd.badLocalRevRE.MatchString(rev)) && !r.branches[rev] + if revOK { + if info, err := r.statLocal(ctx, rev); err == nil { + return info, nil + } + } + + r.fetchOnce.Do(func() { r.fetch(ctx) }) + if r.fetchErr != nil { + return nil, r.fetchErr + } + info, err := r.statLocal(ctx, rev) + if err != nil { + return info, err + } + if !revOK { + info.Version = info.Name + } + return info, nil +} + +func (r *vcsRepo) fetch(ctx context.Context) { + if len(r.cmd.fetch) > 0 { + release, err := base.AcquireNet() + if err != nil { + r.fetchErr = err + return + } + _, r.fetchErr = Run(ctx, r.dir, r.cmd.fetch) + release() + r.fetched.Store(true) + } +} + +func (r *vcsRepo) statLocal(ctx context.Context, rev string) (*RevInfo, error) { + out, err := Run(ctx, r.dir, r.cmd.statLocal(rev, r.remote)) + if err != nil { + info := &RevInfo{Origin: r.repoSumOrigin(ctx)} + return info, &UnknownRevisionError{Rev: rev} + } + info, err := r.cmd.parseStat(rev, string(out)) + if err != nil { + return nil, err + } + if info.Origin == nil { + info.Origin = new(Origin) + } + info.Origin.VCS = r.cmd.vcs + info.Origin.URL = r.remote + info.Origin.Ref = rev + if strings.HasPrefix(info.Name, rev) && len(rev) >= 12 { + info.Origin.Ref = "" // duplicates Hash + } + return info, nil +} + +func (r *vcsRepo) Latest(ctx context.Context) (*RevInfo, error) { + return r.Stat(ctx, "latest") +} + +func (r *vcsRepo) ReadFile(ctx context.Context, rev, file string, maxSize int64) ([]byte, error) { + if rev == "latest" { + rev = r.cmd.latest + } + _, err := r.Stat(ctx, rev) // download rev into local repo + if err != nil { + return nil, err + } + + // r.Stat acquires r.mu, so lock after that. + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + + out, err := Run(ctx, r.dir, r.cmd.readFile(rev, file, r.remote)) + if err != nil { + return nil, fs.ErrNotExist + } + return out, nil +} + +func (r *vcsRepo) RecentTag(ctx context.Context, rev, prefix string, allowed func(string) bool) (tag string, err error) { + // Only lock for the subprocess execution, not for the tag scan. + // allowed may call other methods that acquire the lock. + unlock, err := r.mu.Lock() + if err != nil { + return "", err + } + + if r.cmd.recentTags == nil { + unlock() + return "", vcsErrorf("vcs %s: RecentTag: %w", r.cmd.vcs, errors.ErrUnsupported) + } + out, err := Run(ctx, r.dir, r.cmd.recentTags(rev)) + unlock() + if err != nil { + return "", err + } + + highest := "" + for _, tag := range strings.Fields(string(out)) { + if !strings.HasPrefix(tag, prefix) || !allowed(tag) { + continue + } + semtag := tag[len(prefix):] + if semver.Compare(semtag, highest) > 0 { + highest = semtag + } + } + if highest != "" { + return prefix + highest, nil + } + return "", nil +} + +func (r *vcsRepo) DescendsFrom(ctx context.Context, rev, tag string) (bool, error) { + unlock, err := r.mu.Lock() + if err != nil { + return false, err + } + defer unlock() + + if r.cmd.descendsFrom == nil { + return false, vcsErrorf("vcs %s: DescendsFrom: %w", r.cmd.vcs, errors.ErrUnsupported) + } + + out, err := Run(ctx, r.dir, r.cmd.descendsFrom(rev, tag)) + if err != nil { + return false, err + } + return strings.TrimSpace(string(out)) != "", nil +} + +func (r *vcsRepo) ReadZip(ctx context.Context, rev, subdir string, maxSize int64) (zip io.ReadCloser, err error) { + if r.cmd.readZip == nil && r.cmd.doReadZip == nil { + return nil, vcsErrorf("vcs %s: ReadZip: %w", r.cmd.vcs, errors.ErrUnsupported) + } + + if rev == "latest" { + rev = r.cmd.latest + } + _, err = r.Stat(ctx, rev) // download rev into local repo + if err != nil { + return nil, err + } + + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + + f, err := os.CreateTemp("", "go-readzip-*.zip") + if err != nil { + return nil, err + } + if r.cmd.doReadZip != nil { + lw := &limitedWriter{ + W: f, + N: maxSize, + ErrLimitReached: errors.New("ReadZip: encoded file exceeds allowed size"), + } + err = r.cmd.doReadZip(ctx, lw, r.dir, rev, subdir, r.remote) + if err == nil { + _, err = f.Seek(0, io.SeekStart) + } + } else if r.cmd.vcs == "fossil" { + // If you run + // fossil zip -R .fossil --name prefix trunk /tmp/x.zip + // fossil fails with "unable to create directory /tmp" [sic]. + // Change the command to run in /tmp instead, + // replacing the -R argument with an absolute path. + args := r.cmd.readZip(rev, subdir, r.remote, filepath.Base(f.Name())) + for i := range args { + if args[i] == ".fossil" { + args[i] = filepath.Join(r.dir, ".fossil") + } + } + _, err = Run(ctx, filepath.Dir(f.Name()), args) + } else { + _, err = Run(ctx, r.dir, r.cmd.readZip(rev, subdir, r.remote, f.Name())) + } + if err != nil { + f.Close() + os.Remove(f.Name()) + return nil, err + } + return &deleteCloser{f}, nil +} + +// deleteCloser is a file that gets deleted on Close. +type deleteCloser struct { + *os.File +} + +func (d *deleteCloser) Close() error { + defer os.Remove(d.File.Name()) + return d.File.Close() +} + +func hgAddRemote(ctx context.Context, r *vcsRepo) error { + // Write .hg/hgrc with remote URL in it. + return os.WriteFile(filepath.Join(r.dir, ".hg/hgrc"), []byte(fmt.Sprintf("[paths]\ndefault = %s\n", r.remote)), 0666) +} + +func hgParseStat(rev, out string) (*RevInfo, error) { + f := strings.Fields(out) + if len(f) < 3 { + return nil, vcsErrorf("unexpected response from hg log: %q", out) + } + hash := f[0] + version := rev + if strings.HasPrefix(hash, version) { + version = hash // extend to full hash + } + t, err := strconv.ParseInt(f[1], 10, 64) + if err != nil { + return nil, vcsErrorf("invalid time from hg log: %q", out) + } + + var tags []string + for _, tag := range f[3:] { + if tag != "tip" { + tags = append(tags, tag) + } + } + sort.Strings(tags) + + info := &RevInfo{ + Origin: &Origin{Hash: hash}, + Name: hash, + Short: ShortenSHA1(hash), + Time: time.Unix(t, 0).UTC(), + Version: version, + Tags: tags, + } + return info, nil +} + +func bzrParseStat(rev, out string) (*RevInfo, error) { + var revno int64 + var tm time.Time + var tags []string + for line := range strings.SplitSeq(out, "\n") { + if line == "" || line[0] == ' ' || line[0] == '\t' { + // End of header, start of commit message. + break + } + if line[0] == '-' { + continue + } + before, after, found := strings.Cut(line, ":") + if !found { + // End of header, start of commit message. + break + } + key, val := before, strings.TrimSpace(after) + switch key { + case "revno": + if j := strings.Index(val, " "); j >= 0 { + val = val[:j] + } + i, err := strconv.ParseInt(val, 10, 64) + if err != nil { + return nil, vcsErrorf("unexpected revno from bzr log: %q", line) + } + revno = i + case "timestamp": + j := strings.Index(val, " ") + if j < 0 { + return nil, vcsErrorf("unexpected timestamp from bzr log: %q", line) + } + t, err := time.Parse("2006-01-02 15:04:05 -0700", val[j+1:]) + if err != nil { + return nil, vcsErrorf("unexpected timestamp from bzr log: %q", line) + } + tm = t.UTC() + case "tags": + tags = strings.Split(val, ", ") + } + } + if revno == 0 || tm.IsZero() { + return nil, vcsErrorf("unexpected response from bzr log: %q", out) + } + + info := &RevInfo{ + Name: strconv.FormatInt(revno, 10), + Short: fmt.Sprintf("%012d", revno), + Time: tm, + Version: rev, + Tags: tags, + } + return info, nil +} + +func fossilParseStat(rev, out string) (*RevInfo, error) { + for line := range strings.SplitSeq(out, "\n") { + if strings.HasPrefix(line, "uuid:") || strings.HasPrefix(line, "hash:") { + f := strings.Fields(line) + if len(f) != 5 || len(f[1]) != 40 || f[4] != "UTC" { + return nil, vcsErrorf("unexpected response from fossil info: %q", line) + } + t, err := time.Parse(time.DateTime, f[2]+" "+f[3]) + if err != nil { + return nil, vcsErrorf("unexpected response from fossil info: %q", line) + } + hash := f[1] + version := rev + if strings.HasPrefix(hash, version) { + version = hash // extend to full hash + } + info := &RevInfo{ + Origin: &Origin{Hash: hash}, + Name: hash, + Short: ShortenSHA1(hash), + Time: t, + Version: version, + } + return info, nil + } + } + return nil, vcsErrorf("unexpected response from fossil info: %q", out) +} + +type limitedWriter struct { + W io.Writer + N int64 + ErrLimitReached error +} + +func (l *limitedWriter) Write(p []byte) (n int, err error) { + if l.N > 0 { + max := len(p) + if l.N < int64(max) { + max = int(l.N) + } + n, err = l.W.Write(p[:max]) + l.N -= int64(n) + if err != nil || n >= len(p) { + return n, err + } + } + + return n, l.ErrLimitReached +} diff --git a/go/src/cmd/go/internal/modfetch/coderepo.go b/go/src/cmd/go/internal/modfetch/coderepo.go new file mode 100644 index 0000000000000000000000000000000000000000..7cec96a307012d8a52fa2f3660fc97bc442020e9 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/coderepo.go @@ -0,0 +1,1229 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modfetch + +import ( + "archive/zip" + "bytes" + "context" + "errors" + "fmt" + "io" + "io/fs" + "os" + "path" + "path/filepath" + "sort" + "strings" + "time" + + "cmd/go/internal/gover" + "cmd/go/internal/modfetch/codehost" + + "golang.org/x/mod/modfile" + "golang.org/x/mod/module" + "golang.org/x/mod/semver" + modzip "golang.org/x/mod/zip" +) + +// A codeRepo implements modfetch.Repo using an underlying codehost.Repo. +type codeRepo struct { + modPath string + + // code is the repository containing this module. + code codehost.Repo + // codeRoot is the import path at the root of code. + codeRoot string + // codeDir is the directory (relative to root) at which we expect to find the module. + // If pathMajor is non-empty and codeRoot is not the full modPath, + // then we look in both codeDir and codeDir/pathMajor[1:]. + codeDir string + + // pathMajor is the suffix of modPath that indicates its major version, + // or the empty string if modPath is at major version 0 or 1. + // + // pathMajor is typically of the form "/vN", but possibly ".vN", or + // ".vN-unstable" for modules resolved using gopkg.in. + pathMajor string + // pathPrefix is the prefix of modPath that excludes pathMajor. + // It is used only for logging. + pathPrefix string + + // pseudoMajor is the major version prefix to require when generating + // pseudo-versions for this module, derived from the module path. pseudoMajor + // is empty if the module path does not include a version suffix (that is, + // accepts either v0 or v1). + pseudoMajor string +} + +// newCodeRepo returns a Repo that reads the source code for the module with the +// given path, from the repo stored in code. +// codeRoot gives the import path corresponding to the root of the repository, +// and subdir gives the subdirectory within the repo containing the module. +// If subdir is empty, the module is at the root of the repo. +func newCodeRepo(code codehost.Repo, codeRoot, subdir, path string) (Repo, error) { + if !hasPathPrefix(path, codeRoot) { + return nil, fmt.Errorf("mismatched repo: found %s for %s", codeRoot, path) + } + pathPrefix, pathMajor, ok := module.SplitPathVersion(path) + if !ok { + return nil, fmt.Errorf("invalid module path %q", path) + } + if codeRoot == path { + pathPrefix = path + } + pseudoMajor := module.PathMajorPrefix(pathMajor) + + // Compute codeDir = bar, the subdirectory within the repo + // corresponding to the module root. + // + // At this point we might have: + // path = github.com/rsc/foo/bar/v2 + // codeRoot = github.com/rsc/foo + // pathPrefix = github.com/rsc/foo/bar + // pathMajor = /v2 + // pseudoMajor = v2 + // + // which gives + // codeDir = bar + // + // We know that pathPrefix is a prefix of path, and codeRoot is a prefix of + // path, but codeRoot may or may not be a prefix of pathPrefix, because + // codeRoot may be the entire path (in which case codeDir should be empty). + // That occurs in two situations. + // + // One is when a go-import meta tag resolves the complete module path, + // including the pathMajor suffix: + // path = nanomsg.org/go/mangos/v2 + // codeRoot = nanomsg.org/go/mangos/v2 + // pathPrefix = nanomsg.org/go/mangos + // pathMajor = /v2 + // pseudoMajor = v2 + // + // The other is similar: for gopkg.in only, the major version is encoded + // with a dot rather than a slash, and thus can't be in a subdirectory. + // path = gopkg.in/yaml.v2 + // codeRoot = gopkg.in/yaml.v2 + // pathPrefix = gopkg.in/yaml + // pathMajor = .v2 + // pseudoMajor = v2 + // + // Starting in 1.25, subdir may be passed in by the go-import meta tag. + // So it may be the case that: + // path = github.com/rsc/foo/v2 + // codeRoot = github.com/rsc/foo + // subdir = bar/subdir + // pathPrefix = github.com/rsc/foo + // pathMajor = /v2 + // pseudoMajor = v2 + // which means that codeDir = bar/subdir + + codeDir := "" + if codeRoot != path { + if !hasPathPrefix(pathPrefix, codeRoot) { + return nil, fmt.Errorf("repository rooted at %s cannot contain module %s", codeRoot, path) + } + codeDir = strings.Trim(pathPrefix[len(codeRoot):], "/") + } + if subdir != "" { + codeDir = filepath.ToSlash(filepath.Join(codeDir, subdir)) + } + + r := &codeRepo{ + modPath: path, + code: code, + codeRoot: codeRoot, + codeDir: codeDir, + pathPrefix: pathPrefix, + pathMajor: pathMajor, + pseudoMajor: pseudoMajor, + } + + return r, nil +} + +func (r *codeRepo) ModulePath() string { + return r.modPath +} + +func (r *codeRepo) CheckReuse(ctx context.Context, old *codehost.Origin) error { + return r.code.CheckReuse(ctx, old, r.codeDir) +} + +func (r *codeRepo) Versions(ctx context.Context, prefix string) (*Versions, error) { + // Special case: gopkg.in/macaroon-bakery.v2-unstable + // does not use the v2 tags (those are for macaroon-bakery.v2). + // It has no possible tags at all. + if strings.HasPrefix(r.modPath, "gopkg.in/") && strings.HasSuffix(r.modPath, "-unstable") { + return &Versions{}, nil + } + + p := prefix + if r.codeDir != "" { + p = r.codeDir + "/" + p + } + tags, err := r.code.Tags(ctx, p) + if err != nil { + return nil, &module.ModuleError{ + Path: r.modPath, + Err: err, + } + } + if tags.Origin != nil { + tags.Origin.Subdir = r.codeDir + } + + var list, incompatible []string + for _, tag := range tags.List { + if !strings.HasPrefix(tag.Name, p) { + continue + } + v := tag.Name + if r.codeDir != "" { + v = v[len(r.codeDir)+1:] + } + // Note: ./codehost/codehost.go's isOriginTag knows about these conditions too. + // If these are relaxed, isOriginTag will need to be relaxed as well. + if v == "" || v != semver.Canonical(v) { + // Ignore non-canonical tags: Stat rewrites those to canonical + // pseudo-versions. Note that we compare against semver.Canonical here + // instead of module.CanonicalVersion: revToRev strips "+incompatible" + // suffixes before looking up tags, so a tag like "v2.0.0+incompatible" + // would not resolve at all. (The Go version string "v2.0.0+incompatible" + // refers to the "v2.0.0" version tag, which we handle below.) + continue + } + if module.IsPseudoVersion(v) { + // Ignore tags that look like pseudo-versions: Stat rewrites those + // unambiguously to the underlying commit, and tagToVersion drops them. + continue + } + + if err := module.CheckPathMajor(v, r.pathMajor); err != nil { + if r.codeDir == "" && r.pathMajor == "" && semver.Major(v) > "v1" { + incompatible = append(incompatible, v) + } + continue + } + + list = append(list, v) + } + semver.Sort(list) + semver.Sort(incompatible) + + return r.appendIncompatibleVersions(ctx, tags.Origin, list, incompatible) +} + +// appendIncompatibleVersions appends "+incompatible" versions to list if +// appropriate, returning the final list. +// +// The incompatible list contains candidate versions without the '+incompatible' +// prefix. +// +// Both list and incompatible must be sorted in semantic order. +func (r *codeRepo) appendIncompatibleVersions(ctx context.Context, origin *codehost.Origin, list, incompatible []string) (*Versions, error) { + versions := &Versions{ + Origin: origin, + List: list, + } + if len(incompatible) == 0 || r.pathMajor != "" { + // No +incompatible versions are possible, so no need to check them. + return versions, nil + } + + versionHasGoMod := func(v string) (bool, error) { + _, err := r.code.ReadFile(ctx, v, "go.mod", codehost.MaxGoMod) + if err == nil { + return true, nil + } + if !os.IsNotExist(err) { + return false, &module.ModuleError{ + Path: r.modPath, + Err: err, + } + } + return false, nil + } + + if len(list) > 0 { + ok, err := versionHasGoMod(list[len(list)-1]) + if err != nil { + return nil, err + } + if ok { + // The latest compatible version has a go.mod file, so assume that all + // subsequent versions do as well, and do not include any +incompatible + // versions. Even if we are wrong, the author clearly intends module + // consumers to be on the v0/v1 line instead of a higher +incompatible + // version. (See https://golang.org/issue/34189.) + // + // We know of at least two examples where this behavior is desired + // (github.com/russross/blackfriday@v2.0.0 and + // github.com/libp2p/go-libp2p@v6.0.23), and (as of 2019-10-29) have no + // concrete examples for which it is undesired. + return versions, nil + } + } + + var ( + lastMajor string + lastMajorHasGoMod bool + ) + for i, v := range incompatible { + major := semver.Major(v) + + if major != lastMajor { + rem := incompatible[i:] + j := sort.Search(len(rem), func(j int) bool { + return semver.Major(rem[j]) != major + }) + latestAtMajor := rem[j-1] + + var err error + lastMajor = major + lastMajorHasGoMod, err = versionHasGoMod(latestAtMajor) + if err != nil { + return nil, err + } + } + + if lastMajorHasGoMod { + // The latest release of this major version has a go.mod file, so it is + // not allowed as +incompatible. It would be confusing to include some + // minor versions of this major version as +incompatible but require + // semantic import versioning for others, so drop all +incompatible + // versions for this major version. + // + // If we're wrong about a minor version in the middle, users will still be + // able to 'go get' specific tags for that version explicitly — they just + // won't appear in 'go list' or as the results for queries with inequality + // bounds. + continue + } + versions.List = append(versions.List, v+"+incompatible") + } + + return versions, nil +} + +func (r *codeRepo) Stat(ctx context.Context, rev string) (*RevInfo, error) { + if rev == "latest" { + return r.Latest(ctx) + } + codeRev := r.revToRev(rev) + info, err := r.code.Stat(ctx, codeRev) + if err != nil { + // Note: info may be non-nil to supply Origin for caching error. + var revInfo *RevInfo + if info != nil { + revInfo = &RevInfo{ + Origin: info.Origin, + Version: rev, + } + } + return revInfo, &module.ModuleError{ + Path: r.modPath, + Err: &module.InvalidVersionError{ + Version: rev, + Err: err, + }, + } + } + return r.convert(ctx, info, rev) +} + +func (r *codeRepo) Latest(ctx context.Context) (*RevInfo, error) { + info, err := r.code.Latest(ctx) + if err != nil { + if info != nil { + return &RevInfo{Origin: info.Origin}, err + } + return nil, err + } + return r.convert(ctx, info, "") +} + +// convert converts a version as reported by the code host to a version as +// interpreted by the module system. +// +// If statVers is a valid module version, it is used for the Version field. +// Otherwise, the Version is derived from the passed-in info and recent tags. +func (r *codeRepo) convert(ctx context.Context, info *codehost.RevInfo, statVers string) (revInfo *RevInfo, err error) { + defer func() { + if info.Origin == nil { + return + } + if revInfo == nil { + revInfo = new(RevInfo) + } else if revInfo.Origin != nil { + panic("internal error: RevInfo Origin unexpectedly already populated") + } + + origin := *info.Origin + revInfo.Origin = &origin + origin.Subdir = r.codeDir + + v := revInfo.Version + if module.IsPseudoVersion(v) && (v != statVers || !strings.HasPrefix(v, "v0.0.0-")) { + // Add tags that are relevant to pseudo-version calculation to origin. + prefix := r.codeDir + if prefix != "" { + prefix += "/" + } + if r.pathMajor != "" { // "/v2" or "/.v2" + prefix += r.pathMajor[1:] + "." // += "v2." + } + tags, tagsErr := r.code.Tags(ctx, prefix) + if tagsErr != nil { + revInfo.Origin = nil + if err == nil { + err = tagsErr + } + } else { + origin.TagPrefix = tags.Origin.TagPrefix + origin.TagSum = tags.Origin.TagSum + if tags.Origin.RepoSum != "" { + origin.RepoSum = tags.Origin.RepoSum + } + } + } + }() + + // If this is a plain tag (no dir/ prefix) + // and the module path is unversioned, + // and if the underlying file tree has no go.mod, + // then allow using the tag with a +incompatible suffix. + // + // (If the version is +incompatible, then the go.mod file must not exist: + // +incompatible is not an ongoing opt-out from semantic import versioning.) + incompatibleOk := map[string]bool{} + canUseIncompatible := func(v string) bool { + if r.codeDir != "" || r.pathMajor != "" { + // A non-empty codeDir indicates a module within a subdirectory, + // which necessarily has a go.mod file indicating the module boundary. + // A non-empty pathMajor indicates a module path with a major-version + // suffix, which must match. + return false + } + + ok, seen := incompatibleOk[""] + if !seen { + _, errGoMod := r.code.ReadFile(ctx, info.Name, "go.mod", codehost.MaxGoMod) + ok = (errGoMod != nil) + incompatibleOk[""] = ok + } + if !ok { + // A go.mod file exists at the repo root. + return false + } + + // Per https://go.dev/issue/51324, previous versions of the 'go' command + // didn't always check for go.mod files in subdirectories, so if the user + // requests a +incompatible version explicitly, we should continue to allow + // it. Otherwise, if vN/go.mod exists, expect that release tags for that + // major version are intended for the vN module. + if v != "" && !strings.HasSuffix(statVers, "+incompatible") { + major := semver.Major(v) + ok, seen = incompatibleOk[major] + if !seen { + _, errGoModSub := r.code.ReadFile(ctx, info.Name, path.Join(major, "go.mod"), codehost.MaxGoMod) + ok = (errGoModSub != nil) + incompatibleOk[major] = ok + } + if !ok { + return false + } + } + + return true + } + + // checkCanonical verifies that the canonical version v is compatible with the + // module path represented by r, adding a "+incompatible" suffix if needed. + // + // If statVers is also canonical, checkCanonical also verifies that v is + // either statVers or statVers with the added "+incompatible" suffix. + checkCanonical := func(v string) (*RevInfo, error) { + // If r.codeDir is non-empty, then the go.mod file must exist: the module + // author — not the module consumer, — gets to decide how to carve up the repo + // into modules. + // + // Conversely, if the go.mod file exists, the module author — not the module + // consumer — gets to determine the module's path + // + // r.findDir verifies both of these conditions. Execute it now so that + // r.Stat will correctly return a notExistError if the go.mod location or + // declared module path doesn't match. + _, _, _, err := r.findDir(ctx, v) + if err != nil { + // TODO: It would be nice to return an error like "not a module". + // Right now we return "missing go.mod", which is a little confusing. + return nil, &module.ModuleError{ + Path: r.modPath, + Err: &module.InvalidVersionError{ + Version: v, + Err: notExistError{err: err}, + }, + } + } + + invalidf := func(format string, args ...any) error { + return &module.ModuleError{ + Path: r.modPath, + Err: &module.InvalidVersionError{ + Version: v, + Err: fmt.Errorf(format, args...), + }, + } + } + + // Add the +incompatible suffix if needed or requested explicitly, and + // verify that its presence or absence is appropriate for this version + // (which depends on whether it has an explicit go.mod file). + + if v == strings.TrimSuffix(statVers, "+incompatible") { + v = statVers + } + base := strings.TrimSuffix(v, "+incompatible") + var errIncompatible error + if !module.MatchPathMajor(base, r.pathMajor) { + if canUseIncompatible(base) { + v = base + "+incompatible" + } else { + if r.pathMajor != "" { + errIncompatible = invalidf("module path includes a major version suffix, so major version must match") + } else { + errIncompatible = invalidf("module contains a go.mod file, so module path must match major version (%q)", path.Join(r.pathPrefix, semver.Major(v))) + } + } + } else if strings.HasSuffix(v, "+incompatible") { + errIncompatible = invalidf("+incompatible suffix not allowed: major version %s is compatible", semver.Major(v)) + } + + if statVers != "" && statVers == module.CanonicalVersion(statVers) { + // Since the caller-requested version is canonical, it would be very + // confusing to resolve it to anything but itself, possibly with a + // "+incompatible" suffix. Error out explicitly. + if statBase := strings.TrimSuffix(statVers, "+incompatible"); statBase != base { + return nil, &module.ModuleError{ + Path: r.modPath, + Err: &module.InvalidVersionError{ + Version: statVers, + Err: fmt.Errorf("resolves to version %v (%s is not a tag)", v, statBase), + }, + } + } + } + + if errIncompatible != nil { + return nil, errIncompatible + } + + return &RevInfo{ + Name: info.Name, + Short: info.Short, + Time: info.Time, + Version: v, + }, nil + } + + // Determine version. + + if module.IsPseudoVersion(statVers) { + // Validate the go.mod location and major version before + // we check for an ancestor tagged with the pseudo-version base. + // + // We can rule out an invalid subdirectory or major version with only + // shallow commit information, but checking the pseudo-version base may + // require downloading a (potentially more expensive) full history. + revInfo, err = checkCanonical(statVers) + if err != nil { + return revInfo, err + } + if err := r.validatePseudoVersion(ctx, info, statVers); err != nil { + return nil, err + } + return revInfo, nil + } + + // statVers is not a pseudo-version, so we need to either resolve it to a + // canonical version or verify that it is already a canonical tag + // (not a branch). + + // Derive or verify a version from a code repo tag. + // Tag must have a prefix matching codeDir. + tagPrefix := "" + if r.codeDir != "" { + tagPrefix = r.codeDir + "/" + } + + isRetracted, err := r.retractedVersions(ctx) + if err != nil { + isRetracted = func(string) bool { return false } + } + + // tagToVersion returns the version obtained by trimming tagPrefix from tag. + // If the tag is invalid, retracted, or a pseudo-version, tagToVersion returns + // an empty version. + tagToVersion := func(tag string) (v string, tagIsCanonical bool) { + if !strings.HasPrefix(tag, tagPrefix) { + return "", false + } + trimmed := tag[len(tagPrefix):] + // Tags that look like pseudo-versions would be confusing. Ignore them. + if module.IsPseudoVersion(tag) { + return "", false + } + + v = semver.Canonical(trimmed) // Not module.Canonical: we don't want to pick up an explicit "+incompatible" suffix from the tag. + if v == "" || !strings.HasPrefix(trimmed, v) { + return "", false // Invalid or incomplete version (just vX or vX.Y). + } + if v == trimmed { + tagIsCanonical = true + } + return v, tagIsCanonical + } + + // If the VCS gave us a valid version, use that. + if v, tagIsCanonical := tagToVersion(info.Version); tagIsCanonical { + if info, err := checkCanonical(v); err == nil { + return info, err + } + } + + // Look through the tags on the revision for either a usable canonical version + // or an appropriate base for a pseudo-version. + var ( + highestCanonical string + pseudoBase string + ) + for _, pathTag := range info.Tags { + v, tagIsCanonical := tagToVersion(pathTag) + if statVers != "" && semver.Compare(v, statVers) == 0 { + // The tag is equivalent to the version requested by the user. + if tagIsCanonical { + // This tag is the canonical form of the requested version, + // not some other form with extra build metadata. + // Use this tag so that the resolved version will match exactly. + // (If it isn't actually allowed, we'll error out in checkCanonical.) + return checkCanonical(v) + } else { + // The user explicitly requested something equivalent to this tag. We + // can't use the version from the tag directly: since the tag is not + // canonical, it could be ambiguous. For example, tags v0.0.1+a and + // v0.0.1+b might both exist and refer to different revisions. + // + // The tag is otherwise valid for the module, so we can at least use it as + // the base of an unambiguous pseudo-version. + // + // If multiple tags match, tagToVersion will canonicalize them to the same + // base version. + pseudoBase = v + } + } + // Save the highest non-retracted canonical tag for the revision. + // If we don't find a better match, we'll use it as the canonical version. + if tagIsCanonical && semver.Compare(highestCanonical, v) < 0 && !isRetracted(v) { + if module.MatchPathMajor(v, r.pathMajor) || canUseIncompatible(v) { + highestCanonical = v + } + } + } + + // If we found a valid canonical tag for the revision, return it. + // Even if we found a good pseudo-version base, a canonical version is better. + if highestCanonical != "" { + return checkCanonical(highestCanonical) + } + + // Find the highest tagged version in the revision's history, subject to + // major version and +incompatible constraints. Use that version as the + // pseudo-version base so that the pseudo-version sorts higher. Ignore + // retracted versions. + tagAllowed := func(tag string) bool { + v, _ := tagToVersion(tag) + if v == "" { + return false + } + if !module.MatchPathMajor(v, r.pathMajor) && !canUseIncompatible(v) { + return false + } + return !isRetracted(v) + } + if pseudoBase == "" { + tag, err := r.code.RecentTag(ctx, info.Name, tagPrefix, tagAllowed) + if err != nil && !errors.Is(err, errors.ErrUnsupported) { + return nil, err + } + if tag != "" { + pseudoBase, _ = tagToVersion(tag) + } + } + + return checkCanonical(module.PseudoVersion(r.pseudoMajor, pseudoBase, info.Time, info.Short)) +} + +// validatePseudoVersion checks that version has a major version compatible with +// r.modPath and encodes a base version and commit metadata that agrees with +// info. +// +// Note that verifying a nontrivial base version in particular may be somewhat +// expensive: in order to do so, r.code.DescendsFrom will need to fetch at least +// enough of the commit history to find a path between version and its base. +// Fortunately, many pseudo-versions — such as those for untagged repositories — +// have trivial bases! +func (r *codeRepo) validatePseudoVersion(ctx context.Context, info *codehost.RevInfo, version string) (err error) { + defer func() { + if err != nil { + if _, ok := err.(*module.ModuleError); !ok { + if _, ok := err.(*module.InvalidVersionError); !ok { + err = &module.InvalidVersionError{Version: version, Pseudo: true, Err: err} + } + err = &module.ModuleError{Path: r.modPath, Err: err} + } + } + }() + + rev, err := module.PseudoVersionRev(version) + if err != nil { + return err + } + if rev != info.Short { + switch { + case strings.HasPrefix(rev, info.Short): + return fmt.Errorf("revision is longer than canonical (expected %s)", info.Short) + case strings.HasPrefix(info.Short, rev): + return fmt.Errorf("revision is shorter than canonical (expected %s)", info.Short) + default: + return fmt.Errorf("does not match short name of revision (expected %s)", info.Short) + } + } + + t, err := module.PseudoVersionTime(version) + if err != nil { + return err + } + if !t.Equal(info.Time.Truncate(time.Second)) { + return fmt.Errorf("does not match version-control timestamp (expected %s)", info.Time.UTC().Format(module.PseudoVersionTimestampFormat)) + } + + tagPrefix := "" + if r.codeDir != "" { + tagPrefix = r.codeDir + "/" + } + + // A pseudo-version should have a precedence just above its parent revisions, + // and no higher. Otherwise, it would be possible for library authors to "pin" + // dependency versions (and bypass the usual minimum version selection) by + // naming an extremely high pseudo-version rather than an accurate one. + // + // Moreover, if we allow a pseudo-version to use any arbitrary pre-release + // tag, we end up with infinitely many possible names for each commit. Each + // name consumes resources in the module cache and proxies, so we want to + // restrict them to a finite set under control of the module author. + // + // We address both of these issues by requiring the tag upon which the + // pseudo-version is based to refer to some ancestor of the revision. We + // prefer the highest such tag when constructing a new pseudo-version, but do + // not enforce that property when resolving existing pseudo-versions: we don't + // know when the parent tags were added, and the highest-tagged parent may not + // have existed when the pseudo-version was first resolved. + base, err := module.PseudoVersionBase(strings.TrimSuffix(version, "+incompatible")) + if err != nil { + return err + } + if base == "" { + if r.pseudoMajor == "" && semver.Major(version) == "v1" { + return fmt.Errorf("major version without preceding tag must be v0, not v1") + } + return nil + } else { + for _, tag := range info.Tags { + versionOnly := strings.TrimPrefix(tag, tagPrefix) + if versionOnly == base { + // The base version is canonical, so if the version from the tag is + // literally equal (not just equivalent), then the tag is canonical too. + // + // We allow pseudo-versions to be derived from non-canonical tags on the + // same commit, so that tags like "v1.1.0+some-metadata" resolve as + // close as possible to the canonical version ("v1.1.0") while still + // enforcing a total ordering ("v1.1.1-0.[…]" with a unique suffix). + // + // However, canonical tags already have a total ordering, so there is no + // reason not to use the canonical tag directly, and we know that the + // canonical tag must already exist because the pseudo-version is + // derived from it. In that case, referring to the revision by a + // pseudo-version derived from its own canonical tag is just confusing. + return fmt.Errorf("tag (%s) found on revision %s is already canonical, so should not be replaced with a pseudo-version derived from that tag", tag, rev) + } + } + } + + tags, err := r.code.Tags(ctx, tagPrefix+base) + if err != nil { + return err + } + + var lastTag string // Prefer to log some real tag rather than a canonically-equivalent base. + ancestorFound := false + for _, tag := range tags.List { + versionOnly := strings.TrimPrefix(tag.Name, tagPrefix) + if semver.Compare(versionOnly, base) == 0 { + lastTag = tag.Name + ancestorFound, err = r.code.DescendsFrom(ctx, info.Name, tag.Name) + if ancestorFound { + break + } + } + } + + if lastTag == "" { + return fmt.Errorf("preceding tag (%s) not found", base) + } + + if !ancestorFound { + if err != nil { + return err + } + rev, err := module.PseudoVersionRev(version) + if err != nil { + return fmt.Errorf("not a descendent of preceding tag (%s)", lastTag) + } + return fmt.Errorf("revision %s is not a descendent of preceding tag (%s)", rev, lastTag) + } + return nil +} + +func (r *codeRepo) revToRev(rev string) string { + if semver.IsValid(rev) { + if module.IsPseudoVersion(rev) { + r, _ := module.PseudoVersionRev(rev) + return r + } + if semver.Build(rev) == "+incompatible" { + rev = rev[:len(rev)-len("+incompatible")] + } + if r.codeDir == "" { + return rev + } + return r.codeDir + "/" + rev + } + return rev +} + +func (r *codeRepo) versionToRev(version string) (rev string, err error) { + if !semver.IsValid(version) { + return "", &module.ModuleError{ + Path: r.modPath, + Err: &module.InvalidVersionError{ + Version: version, + Err: errors.New("syntax error"), + }, + } + } + return r.revToRev(version), nil +} + +// findDir locates the directory within the repo containing the module. +// +// If r.pathMajor is non-empty, this can be either r.codeDir or — if a go.mod +// file exists — r.codeDir/r.pathMajor[1:]. +func (r *codeRepo) findDir(ctx context.Context, version string) (rev, dir string, gomod []byte, err error) { + rev, err = r.versionToRev(version) + if err != nil { + return "", "", nil, err + } + + // Load info about go.mod but delay consideration + // (except I/O error) until we rule out v2/go.mod. + file1 := path.Join(r.codeDir, "go.mod") + gomod1, err1 := r.code.ReadFile(ctx, rev, file1, codehost.MaxGoMod) + if err1 != nil && !os.IsNotExist(err1) { + return "", "", nil, fmt.Errorf("reading %s/%s at revision %s: %v", r.codeRoot, file1, rev, err1) + } + mpath1 := modfile.ModulePath(gomod1) + found1 := err1 == nil && (isMajor(mpath1, r.pathMajor) || r.canReplaceMismatchedVersionDueToBug(mpath1)) + + var file2 string + if r.pathMajor != "" && r.codeRoot != r.modPath && !strings.HasPrefix(r.pathMajor, ".") { + // Suppose pathMajor is "/v2". + // Either go.mod should claim v2 and v2/go.mod should not exist, + // or v2/go.mod should exist and claim v2. Not both. + // Note that we don't check the full path, just the major suffix, + // because of replacement modules. This might be a fork of + // the real module, found at a different path, usable only in + // a replace directive. + dir2 := path.Join(r.codeDir, r.pathMajor[1:]) + file2 = path.Join(dir2, "go.mod") + gomod2, err2 := r.code.ReadFile(ctx, rev, file2, codehost.MaxGoMod) + if err2 != nil && !os.IsNotExist(err2) { + return "", "", nil, fmt.Errorf("reading %s/%s at revision %s: %v", r.codeRoot, file2, rev, err2) + } + mpath2 := modfile.ModulePath(gomod2) + found2 := err2 == nil && isMajor(mpath2, r.pathMajor) + + if found1 && found2 { + return "", "", nil, fmt.Errorf("%s/%s and ...%s/go.mod both have ...%s module paths at revision %s", r.pathPrefix, file1, r.pathMajor, r.pathMajor, rev) + } + if found2 { + return rev, dir2, gomod2, nil + } + if err2 == nil { + if mpath2 == "" { + return "", "", nil, fmt.Errorf("%s/%s is missing module path at revision %s", r.codeRoot, file2, rev) + } + return "", "", nil, fmt.Errorf("%s/%s has non-...%s module path %q at revision %s", r.codeRoot, file2, r.pathMajor, mpath2, rev) + } + } + + // Not v2/go.mod, so it's either go.mod or nothing. Which is it? + if found1 { + // Explicit go.mod with matching major version ok. + return rev, r.codeDir, gomod1, nil + } + if err1 == nil { + // Explicit go.mod with non-matching major version disallowed. + suffix := "" + if file2 != "" { + suffix = fmt.Sprintf(" (and ...%s/go.mod does not exist)", r.pathMajor) + } + if mpath1 == "" { + return "", "", nil, fmt.Errorf("%s is missing module path%s at revision %s", file1, suffix, rev) + } + if r.pathMajor != "" { // ".v1", ".v2" for gopkg.in + return "", "", nil, fmt.Errorf("%s has non-...%s module path %q%s at revision %s", file1, r.pathMajor, mpath1, suffix, rev) + } + if _, _, ok := module.SplitPathVersion(mpath1); !ok { + return "", "", nil, fmt.Errorf("%s has malformed module path %q%s at revision %s", file1, mpath1, suffix, rev) + } + return "", "", nil, fmt.Errorf("%s has post-%s module path %q%s at revision %s", file1, semver.Major(version), mpath1, suffix, rev) + } + + if r.codeDir == "" && (r.pathMajor == "" || strings.HasPrefix(r.pathMajor, ".")) { + // Implicit go.mod at root of repo OK for v0/v1 and for gopkg.in. + return rev, "", nil, nil + } + + // Implicit go.mod below root of repo or at v2+ disallowed. + // Be clear about possibility of using either location for v2+. + if file2 != "" { + return "", "", nil, fmt.Errorf("missing %s/go.mod and ...%s/go.mod at revision %s", r.pathPrefix, r.pathMajor, rev) + } + return "", "", nil, fmt.Errorf("missing %s/go.mod at revision %s", r.pathPrefix, rev) +} + +// isMajor reports whether the versions allowed for mpath are compatible with +// the major version(s) implied by pathMajor, or false if mpath has an invalid +// version suffix. +func isMajor(mpath, pathMajor string) bool { + if mpath == "" { + // If we don't have a path, we don't know what version(s) it is compatible with. + return false + } + _, mpathMajor, ok := module.SplitPathVersion(mpath) + if !ok { + // An invalid module path is not compatible with any version. + return false + } + if pathMajor == "" { + // All of the valid versions for a gopkg.in module that requires major + // version v0 or v1 are compatible with the "v0 or v1" implied by an empty + // pathMajor. + switch module.PathMajorPrefix(mpathMajor) { + case "", "v0", "v1": + return true + default: + return false + } + } + if mpathMajor == "" { + // Even if pathMajor is ".v0" or ".v1", we can't be sure that a module + // without a suffix is tagged appropriately. Besides, we don't expect clones + // of non-gopkg.in modules to have gopkg.in paths, so a non-empty, + // non-gopkg.in mpath is probably the wrong module for any such pathMajor + // anyway. + return false + } + // If both pathMajor and mpathMajor are non-empty, then we only care that they + // have the same major-version validation rules. A clone fetched via a /v2 + // path might replace a module with path gopkg.in/foo.v2-unstable, and that's + // ok. + return pathMajor[1:] == mpathMajor[1:] +} + +// canReplaceMismatchedVersionDueToBug reports whether versions of r +// could replace versions of mpath with otherwise-mismatched major versions +// due to a historical bug in the Go command (golang.org/issue/34254). +func (r *codeRepo) canReplaceMismatchedVersionDueToBug(mpath string) bool { + // The bug caused us to erroneously accept unversioned paths as replacements + // for versioned gopkg.in paths. + unversioned := r.pathMajor == "" + replacingGopkgIn := strings.HasPrefix(mpath, "gopkg.in/") + return unversioned && replacingGopkgIn +} + +func (r *codeRepo) GoMod(ctx context.Context, version string) (data []byte, err error) { + if version != module.CanonicalVersion(version) { + return nil, fmt.Errorf("version %s is not canonical", version) + } + + if module.IsPseudoVersion(version) { + // findDir ignores the metadata encoded in a pseudo-version, + // only using the revision at the end. + // Invoke Stat to verify the metadata explicitly so we don't return + // a bogus file for an invalid version. + _, err := r.Stat(ctx, version) + if err != nil { + return nil, err + } + } + + rev, dir, gomod, err := r.findDir(ctx, version) + if err != nil { + return nil, err + } + if gomod != nil { + return gomod, nil + } + data, err = r.code.ReadFile(ctx, rev, path.Join(dir, "go.mod"), codehost.MaxGoMod) + if err != nil { + if os.IsNotExist(err) { + return LegacyGoMod(r.modPath), nil + } + return nil, err + } + return data, nil +} + +// LegacyGoMod generates a fake go.mod file for a module that doesn't have one. +// The go.mod file contains a module directive and nothing else: no go version, +// no requirements. +// +// We used to try to build a go.mod reflecting pre-existing +// package management metadata files, but the conversion +// was inherently imperfect (because those files don't have +// exactly the same semantics as go.mod) and, when done +// for dependencies in the middle of a build, impossible to +// correct. So we stopped. +func LegacyGoMod(modPath string) []byte { + return fmt.Appendf(nil, "module %s\n", modfile.AutoQuote(modPath)) +} + +func (r *codeRepo) retractedVersions(ctx context.Context) (func(string) bool, error) { + vs, err := r.Versions(ctx, "") + if err != nil { + return nil, err + } + versions := vs.List + + for i, v := range versions { + if strings.HasSuffix(v, "+incompatible") { + // We're looking for the latest release tag that may list retractions in a + // go.mod file. +incompatible versions necessarily do not, and they start + // at major version 2 — which is higher than any version that could + // validly contain a go.mod file. + versions = versions[:i] + break + } + } + if len(versions) == 0 { + return func(string) bool { return false }, nil + } + + var highest string + for i := len(versions) - 1; i >= 0; i-- { + v := versions[i] + if semver.Prerelease(v) == "" { + highest = v + break + } + } + if highest == "" { + highest = versions[len(versions)-1] + } + + data, err := r.GoMod(ctx, highest) + if err != nil { + return nil, err + } + f, err := modfile.ParseLax("go.mod", data, nil) + if err != nil { + return nil, err + } + retractions := make([]modfile.VersionInterval, 0, len(f.Retract)) + for _, r := range f.Retract { + retractions = append(retractions, r.VersionInterval) + } + + return func(v string) bool { + for _, r := range retractions { + if semver.Compare(r.Low, v) <= 0 && semver.Compare(v, r.High) <= 0 { + return true + } + } + return false + }, nil +} + +func (r *codeRepo) Zip(ctx context.Context, dst io.Writer, version string) error { + if version != module.CanonicalVersion(version) { + return fmt.Errorf("version %s is not canonical", version) + } + + if module.IsPseudoVersion(version) { + // findDir ignores the metadata encoded in a pseudo-version, + // only using the revision at the end. + // Invoke Stat to verify the metadata explicitly so we don't return + // a bogus file for an invalid version. + _, err := r.Stat(ctx, version) + if err != nil { + return err + } + } + + rev, subdir, _, err := r.findDir(ctx, version) + if err != nil { + return err + } + + if gomod, err := r.code.ReadFile(ctx, rev, filepath.Join(subdir, "go.mod"), codehost.MaxGoMod); err == nil { + goVers := gover.GoModLookup(gomod, "go") + if gover.Compare(goVers, gover.Local()) > 0 { + return &gover.TooNewError{What: r.ModulePath() + "@" + version, GoVersion: goVers} + } + } else if !errors.Is(err, fs.ErrNotExist) { + return err + } + + dl, err := r.code.ReadZip(ctx, rev, subdir, codehost.MaxZipFile) + if err != nil { + return err + } + defer dl.Close() + subdir = strings.Trim(subdir, "/") + + // Spool to local file. + f, err := os.CreateTemp("", "go-codehost-") + if err != nil { + dl.Close() + return err + } + defer os.Remove(f.Name()) + defer f.Close() + maxSize := int64(codehost.MaxZipFile) + lr := &io.LimitedReader{R: dl, N: maxSize + 1} + if _, err := io.Copy(f, lr); err != nil { + dl.Close() + return err + } + dl.Close() + if lr.N <= 0 { + return fmt.Errorf("downloaded zip file too large") + } + size := (maxSize + 1) - lr.N + if _, err := f.Seek(0, 0); err != nil { + return err + } + + // Translate from zip file we have to zip file we want. + zr, err := zip.NewReader(f, size) + if err != nil { + return err + } + + var files []modzip.File + if subdir != "" { + subdir += "/" + } + haveLICENSE := false + topPrefix := "" + for _, zf := range zr.File { + if topPrefix == "" { + i := strings.Index(zf.Name, "/") + if i < 0 { + return fmt.Errorf("missing top-level directory prefix") + } + topPrefix = zf.Name[:i+1] + } + var name string + var found bool + if name, found = strings.CutPrefix(zf.Name, topPrefix); !found { + return fmt.Errorf("zip file contains more than one top-level directory") + } + + if name, found = strings.CutPrefix(name, subdir); !found { + continue + } + + if name == "" || strings.HasSuffix(name, "/") { + continue + } + files = append(files, zipFile{name: name, f: zf}) + if name == "LICENSE" { + haveLICENSE = true + } + } + + if !haveLICENSE && subdir != "" { + data, err := r.code.ReadFile(ctx, rev, "LICENSE", codehost.MaxLICENSE) + if err == nil { + files = append(files, dataFile{name: "LICENSE", data: data}) + } + } + + return modzip.Create(dst, module.Version{Path: r.modPath, Version: version}, files) +} + +type zipFile struct { + name string + f *zip.File +} + +func (f zipFile) Path() string { return f.name } +func (f zipFile) Lstat() (fs.FileInfo, error) { return f.f.FileInfo(), nil } +func (f zipFile) Open() (io.ReadCloser, error) { return f.f.Open() } + +type dataFile struct { + name string + data []byte +} + +func (f dataFile) Path() string { return f.name } +func (f dataFile) Lstat() (fs.FileInfo, error) { return dataFileInfo{f}, nil } +func (f dataFile) Open() (io.ReadCloser, error) { + return io.NopCloser(bytes.NewReader(f.data)), nil +} + +type dataFileInfo struct { + f dataFile +} + +func (fi dataFileInfo) Name() string { return path.Base(fi.f.name) } +func (fi dataFileInfo) Size() int64 { return int64(len(fi.f.data)) } +func (fi dataFileInfo) Mode() fs.FileMode { return 0644 } +func (fi dataFileInfo) ModTime() time.Time { return time.Time{} } +func (fi dataFileInfo) IsDir() bool { return false } +func (fi dataFileInfo) Sys() any { return nil } + +func (fi dataFileInfo) String() string { + return fs.FormatFileInfo(fi) +} + +// hasPathPrefix reports whether the path s begins with the +// elements in prefix. +func hasPathPrefix(s, prefix string) bool { + switch { + default: + return false + case len(s) == len(prefix): + return s == prefix + case len(s) > len(prefix): + if prefix != "" && prefix[len(prefix)-1] == '/' { + return strings.HasPrefix(s, prefix) + } + return s[len(prefix)] == '/' && s[:len(prefix)] == prefix + } +} diff --git a/go/src/cmd/go/internal/modfetch/coderepo_test.go b/go/src/cmd/go/internal/modfetch/coderepo_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a403e83b847bf088cb6f1864ae78d93d72839a0b --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/coderepo_test.go @@ -0,0 +1,975 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modfetch + +import ( + "archive/zip" + "context" + "crypto/sha256" + "encoding/hex" + "flag" + "hash" + "internal/testenv" + "io" + "log" + "os" + "path/filepath" + "reflect" + "strings" + "testing" + "time" + + "cmd/go/internal/cfg" + "cmd/go/internal/modfetch/codehost" + "cmd/go/internal/vcweb/vcstest" + + "golang.org/x/mod/sumdb/dirhash" +) + +func TestMain(m *testing.M) { + flag.Parse() + if err := testMain(m); err != nil { + log.Fatal(err) + } +} + +func testMain(m *testing.M) (err error) { + cfg.GOPROXY = "direct" + + // The sum database is populated using a released version of the go command, + // but this test may include fixes for additional modules that previously + // could not be fetched. Since this test isn't executing any of the resolved + // code, bypass the sum database. + cfg.GOSUMDB = "off" + + dir, err := os.MkdirTemp("", "gitrepo-test-") + if err != nil { + return err + } + defer func() { + if rmErr := os.RemoveAll(dir); err == nil { + err = rmErr + } + }() + + cfg.GOMODCACHE = filepath.Join(dir, "modcache") + if err := os.Mkdir(cfg.GOMODCACHE, 0o755); err != nil { + return err + } + + srv, err := vcstest.NewServer() + if err != nil { + return err + } + defer func() { + if closeErr := srv.Close(); err == nil { + err = closeErr + } + }() + + m.Run() + return nil +} + +const ( + vgotest1git = "github.com/rsc/vgotest1" + vgotest1hg = "vcs-test.golang.org/hg/vgotest1.hg" +) + +var altVgotests = map[string]string{ + "hg": vgotest1hg, +} + +type codeRepoTest struct { + vcs string + path string + mpath string + rev string + err string + version string + name string + short string + time time.Time + gomod string + gomodErr string + zip []string + zipErr string + zipSum string + zipFileHash string +} + +var codeRepoTests = []codeRepoTest{ + { + vcs: "git", + path: "github.com/rsc/vgotest1", + rev: "v0.0.0", + version: "v0.0.0", + name: "80d85c5d4d17598a0e9055e7c175a32b415d6128", + short: "80d85c5d4d17", + time: time.Date(2018, 2, 19, 23, 10, 6, 0, time.UTC), + zip: []string{ + "LICENSE", + "README.md", + "pkg/p.go", + }, + zipSum: "h1:zVEjciLdlk/TPWCOyZo7k24T+tOKRQC+u8MKq/xS80I=", + zipFileHash: "738a00ddbfe8c329dce6b48e1f23c8e22a92db50f3cfb2653caa0d62676bc09c", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1", + rev: "v0.0.0-20180219231006-80d85c5d4d17", + version: "v0.0.0-20180219231006-80d85c5d4d17", + name: "80d85c5d4d17598a0e9055e7c175a32b415d6128", + short: "80d85c5d4d17", + time: time.Date(2018, 2, 19, 23, 10, 6, 0, time.UTC), + zip: []string{ + "LICENSE", + "README.md", + "pkg/p.go", + }, + zipSum: "h1:nOznk2xKsLGkTnXe0q9t1Ewt9jxK+oadtafSUqHM3Ec=", + zipFileHash: "bacb08f391e29d2eaaef8281b5c129ee6d890e608ee65877e0003c0181a766c8", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1", + rev: "v0.0.1-0.20180219231006-80d85c5d4d17", + err: `github.com/rsc/vgotest1@v0.0.1-0.20180219231006-80d85c5d4d17: invalid pseudo-version: tag (v0.0.0) found on revision 80d85c5d4d17 is already canonical, so should not be replaced with a pseudo-version derived from that tag`, + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1", + rev: "v1.0.0", + version: "v1.0.0", + name: "80d85c5d4d17598a0e9055e7c175a32b415d6128", + short: "80d85c5d4d17", + time: time.Date(2018, 2, 19, 23, 10, 6, 0, time.UTC), + zip: []string{ + "LICENSE", + "README.md", + "pkg/p.go", + }, + zipSum: "h1:e040hOoWGeuJLawDjK9DW6med+cz9FxMFYDMOVG8ctQ=", + zipFileHash: "74caab65cfbea427c341fa815f3bb0378681d8f0e3cf62a7f207014263ec7be3", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/v2", + rev: "v2.0.0", + version: "v2.0.0", + name: "45f53230a74ad275c7127e117ac46914c8126160", + short: "45f53230a74a", + time: time.Date(2018, 7, 19, 1, 21, 27, 0, time.UTC), + err: "missing github.com/rsc/vgotest1/go.mod and .../v2/go.mod at revision v2.0.0", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1", + rev: "80d85c5", + version: "v1.0.0", + name: "80d85c5d4d17598a0e9055e7c175a32b415d6128", + short: "80d85c5d4d17", + time: time.Date(2018, 2, 19, 23, 10, 6, 0, time.UTC), + zip: []string{ + "LICENSE", + "README.md", + "pkg/p.go", + }, + zipSum: "h1:e040hOoWGeuJLawDjK9DW6med+cz9FxMFYDMOVG8ctQ=", + zipFileHash: "74caab65cfbea427c341fa815f3bb0378681d8f0e3cf62a7f207014263ec7be3", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1", + rev: "mytag", + version: "v1.0.0", + name: "80d85c5d4d17598a0e9055e7c175a32b415d6128", + short: "80d85c5d4d17", + time: time.Date(2018, 2, 19, 23, 10, 6, 0, time.UTC), + zip: []string{ + "LICENSE", + "README.md", + "pkg/p.go", + }, + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/v2", + rev: "45f53230a", + version: "v2.0.0", + name: "45f53230a74ad275c7127e117ac46914c8126160", + short: "45f53230a74a", + time: time.Date(2018, 7, 19, 1, 21, 27, 0, time.UTC), + err: "missing github.com/rsc/vgotest1/go.mod and .../v2/go.mod at revision v2.0.0", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/v54321", + rev: "80d85c5", + version: "v54321.0.0-20180219231006-80d85c5d4d17", + name: "80d85c5d4d17598a0e9055e7c175a32b415d6128", + short: "80d85c5d4d17", + time: time.Date(2018, 2, 19, 23, 10, 6, 0, time.UTC), + err: "missing github.com/rsc/vgotest1/go.mod and .../v54321/go.mod at revision 80d85c5d4d17", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/submod", + rev: "v1.0.0", + err: "unknown revision submod/v1.0.0", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/submod", + rev: "v1.0.3", + err: "unknown revision submod/v1.0.3", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/submod", + rev: "v1.0.4", + version: "v1.0.4", + name: "8afe2b2efed96e0880ecd2a69b98a53b8c2738b6", + short: "8afe2b2efed9", + time: time.Date(2018, 2, 19, 23, 12, 7, 0, time.UTC), + gomod: "module \"github.com/vgotest1/submod\" // submod/go.mod\n", + zip: []string{ + "go.mod", + "pkg/p.go", + "LICENSE", + }, + zipSum: "h1:iMsJ/9uQsk6MnZNnJK311f11QiSlmN92Q2aSjCywuJY=", + zipFileHash: "95801bfa69c5197ae809af512946d22f22850068527cd78100ae3f176bc8043b", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1", + rev: "v1.1.0", + version: "v1.1.0", + name: "b769f2de407a4db81af9c5de0a06016d60d2ea09", + short: "b769f2de407a", + time: time.Date(2018, 2, 19, 23, 13, 36, 0, time.UTC), + gomod: "module \"github.com/rsc/vgotest1\" // root go.mod\nrequire \"github.com/rsc/vgotest1/submod\" v1.0.5\n", + zip: []string{ + "LICENSE", + "README.md", + "go.mod", + "pkg/p.go", + }, + zipSum: "h1:M69k7q+8bQ+QUpHov45Z/NoR8rj3DsQJUnXLWvf01+Q=", + zipFileHash: "58af45fb248d320ea471f568e006379e2b8d71d6d1663f9b19b2e00fd9ac9265", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/v2", + rev: "v2.0.1", + version: "v2.0.1", + name: "ea65f87c8f52c15ea68f3bdd9925ef17e20d91e9", + short: "ea65f87c8f52", + time: time.Date(2018, 2, 19, 23, 14, 23, 0, time.UTC), + gomod: "module \"github.com/rsc/vgotest1/v2\" // root go.mod\n", + zipSum: "h1:QmgYy/zt+uoWhDpcsgrSVzYFvKtBEjl5zT/FRz9GTzA=", + zipFileHash: "1aedf1546d322a0121879ddfd6d0e8bfbd916d2cafbeb538ddb440e04b04b9ef", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/v2", + rev: "v2.0.3", + version: "v2.0.3", + name: "f18795870fb14388a21ef3ebc1d75911c8694f31", + short: "f18795870fb1", + time: time.Date(2018, 2, 19, 23, 16, 4, 0, time.UTC), + err: "github.com/rsc/vgotest1/v2/go.mod has non-.../v2 module path \"github.com/rsc/vgotest\" at revision v2.0.3", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/v2", + rev: "v2.0.4", + version: "v2.0.4", + name: "1f863feb76bc7029b78b21c5375644838962f88d", + short: "1f863feb76bc", + time: time.Date(2018, 2, 20, 0, 3, 38, 0, time.UTC), + err: "github.com/rsc/vgotest1/go.mod and .../v2/go.mod both have .../v2 module paths at revision v2.0.4", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/v2", + rev: "v2.0.5", + version: "v2.0.5", + name: "2f615117ce481c8efef46e0cc0b4b4dccfac8fea", + short: "2f615117ce48", + time: time.Date(2018, 2, 20, 0, 3, 59, 0, time.UTC), + gomod: "module \"github.com/rsc/vgotest1/v2\" // v2/go.mod\n", + zipSum: "h1:RIEb9q1SUSEQOzMn0zfl/LQxGFWlhWEAdeEguf1MLGU=", + zipFileHash: "7d92c2c328c5e9b0694101353705d5843746ec1d93a1e986d0da54c8a14dfe6d", + }, + { + // redirect to github + vcs: "git", + path: "rsc.io/quote", + rev: "v1.0.0", + version: "v1.0.0", + name: "f488df80bcdbd3e5bafdc24ad7d1e79e83edd7e6", + short: "f488df80bcdb", + time: time.Date(2018, 2, 14, 0, 45, 20, 0, time.UTC), + gomod: "module \"rsc.io/quote\"\n", + zipSum: "h1:haUSojyo3j2M9g7CEUFG8Na09dtn7QKxvPGaPVQdGwM=", + zipFileHash: "5c08ba2c09a364f93704aaa780e7504346102c6ef4fe1333a11f09904a732078", + }, + { + // redirect to static hosting proxy + vcs: "mod", + path: "swtch.com/testmod", + rev: "v1.0.0", + version: "v1.0.0", + // NO name or short - we intentionally ignore those in the proxy protocol + time: time.Date(1972, 7, 18, 12, 34, 56, 0, time.UTC), + gomod: "module \"swtch.com/testmod\"\n", + }, + { + // redirect to googlesource + vcs: "git", + path: "golang.org/x/text", + rev: "4e4a3210bb", + version: "v0.3.1-0.20180208041248-4e4a3210bb54", + name: "4e4a3210bb54bb31f6ab2cdca2edcc0b50c420c1", + short: "4e4a3210bb54", + time: time.Date(2018, 2, 8, 4, 12, 48, 0, time.UTC), + zipSum: "h1:Yxu6pHX9X2RECiuw/Q5/4uvajuaowck8zOFKXgbfNBk=", + zipFileHash: "ac2c165a5c10aa5a7545dea60a08e019270b982fa6c8bdcb5943931de64922fe", + }, + { + vcs: "git", + path: "github.com/pkg/errors", + rev: "v0.8.0", + version: "v0.8.0", + name: "645ef00459ed84a119197bfb8d8205042c6df63d", + short: "645ef00459ed", + time: time.Date(2016, 9, 29, 1, 48, 1, 0, time.UTC), + zipSum: "h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=", + zipFileHash: "e4fa69ba057356614edbc1da881a7d3ebb688505be49f65965686bcb859e2fae", + }, + { + // package in subdirectory - custom domain + // In general we can't reject these definitively in Lookup, + // but gopkg.in is special. + vcs: "git", + path: "gopkg.in/yaml.v2/abc", + err: "invalid module path \"gopkg.in/yaml.v2/abc\"", + }, + { + // package in subdirectory - github + // Because it's a package, Stat should fail entirely. + vcs: "git", + path: "github.com/rsc/quote/buggy", + rev: "c4d4236f", + err: "missing github.com/rsc/quote/buggy/go.mod at revision c4d4236f9242", + }, + { + vcs: "git", + path: "gopkg.in/yaml.v2", + rev: "d670f940", + version: "v2.0.0", + name: "d670f9405373e636a5a2765eea47fac0c9bc91a4", + short: "d670f9405373", + time: time.Date(2018, 1, 9, 11, 43, 31, 0, time.UTC), + gomod: "module gopkg.in/yaml.v2\n", + zipSum: "h1:uUkhRGrsEyx/laRdeS6YIQKIys8pg+lRSRdVMTYjivs=", + zipFileHash: "7b0a141b1b0b49772ab4eecfd11dfd6609a94a5e868cab04a3abb1861ffaa877", + }, + { + vcs: "git", + path: "gopkg.in/check.v1", + rev: "20d25e280405", + version: "v1.0.0-20161208181325-20d25e280405", + name: "20d25e2804050c1cd24a7eea1e7a6447dd0e74ec", + short: "20d25e280405", + time: time.Date(2016, 12, 8, 18, 13, 25, 0, time.UTC), + gomod: "module gopkg.in/check.v1\n", + zipSum: "h1:829vOVxxusYHC+IqBtkX5mbKtsY9fheQiQn0MZRVLfQ=", + zipFileHash: "9e7cb3f4f1e66d722306442b0dbe1f6f43d74d1736d54c510537bdfb1d6f432f", + }, + { + vcs: "git", + path: "vcs-test.golang.org/go/mod/gitrepo1", + rev: "master", + version: "v1.2.4-annotated", + name: "ede458df7cd0fdca520df19a33158086a8a68e81", + short: "ede458df7cd0", + time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC), + gomod: "module vcs-test.golang.org/go/mod/gitrepo1\n", + zipSum: "h1:YJYZRsM9BHFTlVr8YADjT0cJH8uFIDtoc5NLiVqZEx8=", + zipFileHash: "c15e49d58b7a4c37966cbe5bc01a0330cd5f2927e990e1839bda1d407766d9c5", + }, + { + vcs: "git", + path: "gopkg.in/natefinch/lumberjack.v2", + // This repo has a v2.1 tag. + // We only allow semver references to tags that are fully qualified, as in v2.1.0. + // Because we can't record v2.1.0 (the actual tag is v2.1), we record a pseudo-version + // instead, same as if the tag were any other non-version-looking string. + // We use a v2 pseudo-version here because of the .v2 in the path, not because + // of the v2 in the rev. + rev: "v2.1", // non-canonical semantic version turns into pseudo-version + version: "v2.0.0-20170531160350-a96e63847dc3", + name: "a96e63847dc3c67d17befa69c303767e2f84e54f", + short: "a96e63847dc3", + time: time.Date(2017, 5, 31, 16, 3, 50, 0, time.UTC), + gomod: "module gopkg.in/natefinch/lumberjack.v2\n", + }, + { + vcs: "git", + path: "vcs-test.golang.org/go/v2module/v2", + rev: "v2.0.0", + version: "v2.0.0", + name: "203b91c896acd173aa719e4cdcb7d463c4b090fa", + short: "203b91c896ac", + time: time.Date(2019, 4, 3, 15, 52, 15, 0, time.UTC), + gomod: "module vcs-test.golang.org/go/v2module/v2\n\ngo 1.12\n", + zipSum: "h1:JItBZ+gwA5WvtZEGEbuDL4lUttGtLrs53lmdurq3bOg=", + zipFileHash: "9ea9ae1673cffcc44b7fdd3cc89953d68c102449b46c982dbf085e4f2e394da5", + }, + { + // Git branch with a semver name, +incompatible version, and no go.mod file. + vcs: "git", + path: "vcs-test.golang.org/go/mod/gitrepo1", + rev: "v2.3.4+incompatible", + err: `resolves to version v2.0.1+incompatible (v2.3.4 is not a tag)`, + }, + { + // Git branch with a semver name, matching go.mod file, and compatible version. + vcs: "git", + path: "vcs-test.golang.org/git/semver-branch.git", + rev: "v1.0.0", + err: `resolves to version v0.1.1-0.20220202191944-09c4d8f6938c (v1.0.0 is not a tag)`, + }, + { + // Git branch with a semver name, matching go.mod file, and disallowed +incompatible version. + // The version/tag mismatch takes precedence over the +incompatible mismatched. + vcs: "git", + path: "vcs-test.golang.org/git/semver-branch.git", + rev: "v2.0.0+incompatible", + err: `resolves to version v0.1.0 (v2.0.0 is not a tag)`, + }, + { + // Git branch with a semver name, matching go.mod file, and mismatched version. + // The version/tag mismatch takes precedence over the +incompatible mismatched. + vcs: "git", + path: "vcs-test.golang.org/git/semver-branch.git", + rev: "v2.0.0", + err: `resolves to version v0.1.0 (v2.0.0 is not a tag)`, + }, + { + // v3.0.0-devel is the same as tag v4.0.0-beta.1, but v4.0.0-beta.1 would + // not be allowed because it is incompatible and a go.mod file exists. + // The error message should refer to a valid pseudo-version, not the + // unusable semver tag. + vcs: "git", + path: "vcs-test.golang.org/git/semver-branch.git", + rev: "v3.0.0-devel", + err: `resolves to version v0.1.1-0.20220203155313-d59622f6e4d7 (v3.0.0-devel is not a tag)`, + }, + + // If v2/go.mod exists, then we should prefer to match the "v2" + // pseudo-versions to the nested module, and resolve the module in the parent + // directory to only compatible versions. + // + // However (https://go.dev/issue/51324), previous versions of the 'go' command + // didn't always do so, so if the user explicitly requests a +incompatible + // version (as would be present in an existing go.mod file), we should + // continue to allow it. + { + vcs: "git", + path: "vcs-test.golang.org/git/v2sub.git", + rev: "80beb17a1603", + version: "v0.0.0-20220222205507-80beb17a1603", + name: "80beb17a16036f17a5aedd1bb5bd6d407b3c6dc5", + short: "80beb17a1603", + time: time.Date(2022, 2, 22, 20, 55, 7, 0, time.UTC), + }, + { + vcs: "git", + path: "vcs-test.golang.org/git/v2sub.git", + rev: "v2.0.0", + err: `module contains a go.mod file, so module path must match major version ("vcs-test.golang.org/git/v2sub.git/v2")`, + }, + { + vcs: "git", + path: "vcs-test.golang.org/git/v2sub.git", + rev: "v2.0.1-0.20220222205507-80beb17a1603", + err: `module contains a go.mod file, so module path must match major version ("vcs-test.golang.org/git/v2sub.git/v2")`, + }, + { + vcs: "git", + path: "vcs-test.golang.org/git/v2sub.git", + rev: "v2.0.0+incompatible", + version: "v2.0.0+incompatible", + name: "5fcd3eaeeb391d399f562fd45a50dac9fc34ae8b", + short: "5fcd3eaeeb39", + time: time.Date(2022, 2, 22, 20, 53, 33, 0, time.UTC), + }, + { + vcs: "git", + path: "vcs-test.golang.org/git/v2sub.git", + rev: "v2.0.1-0.20220222205507-80beb17a1603+incompatible", + version: "v2.0.1-0.20220222205507-80beb17a1603+incompatible", + name: "80beb17a16036f17a5aedd1bb5bd6d407b3c6dc5", + short: "80beb17a1603", + time: time.Date(2022, 2, 22, 20, 55, 7, 0, time.UTC), + }, + + // A version tag with explicit build metadata is valid but not canonical. + // It should resolve to a pseudo-version based on the same tag. + { + vcs: "git", + path: "vcs-test.golang.org/git/odd-tags.git", + rev: "v0.1.0+build-metadata", + version: "v0.1.1-0.20220223184835-9d863d525bbf", + name: "9d863d525bbfcc8eda09364738c4032393711a56", + short: "9d863d525bbf", + time: time.Date(2022, 2, 23, 18, 48, 35, 0, time.UTC), + }, + { + vcs: "git", + path: "vcs-test.golang.org/git/odd-tags.git", + rev: "9d863d525bbf", + version: "v0.1.1-0.20220223184835-9d863d525bbf", + name: "9d863d525bbfcc8eda09364738c4032393711a56", + short: "9d863d525bbf", + time: time.Date(2022, 2, 23, 18, 48, 35, 0, time.UTC), + }, + { + vcs: "git", + path: "vcs-test.golang.org/git/odd-tags.git", + rev: "latest", + version: "v0.1.1-0.20220223184835-9d863d525bbf", + name: "9d863d525bbfcc8eda09364738c4032393711a56", + short: "9d863d525bbf", + time: time.Date(2022, 2, 23, 18, 48, 35, 0, time.UTC), + }, + + // A version tag with an erroneous "+incompatible" suffix should resolve using + // only the prefix before the "+incompatible" suffix, not the "+incompatible" + // tag itself. (Otherwise, we would potentially have two different commits + // both named "v2.0.0+incompatible".) However, the tag is still valid semver + // and can still be used as the base for an unambiguous pseudo-version. + { + vcs: "git", + path: "vcs-test.golang.org/git/odd-tags.git", + rev: "v2.0.0+incompatible", + err: `unknown revision v2.0.0`, + }, + { + vcs: "git", + path: "vcs-test.golang.org/git/odd-tags.git", + rev: "12d19af20458", + version: "v2.0.1-0.20220223184802-12d19af20458+incompatible", + name: "12d19af204585b0db3d2a876ceddf5b9323f5a4a", + short: "12d19af20458", + time: time.Date(2022, 2, 23, 18, 48, 2, 0, time.UTC), + }, + + // Similarly, a pseudo-version must resolve to the named commit, even if a tag + // matching that pseudo-version is present on a *different* commit. + { + vcs: "git", + path: "vcs-test.golang.org/git/odd-tags.git", + rev: "v3.0.0-20220223184802-12d19af20458", + version: "v3.0.0-20220223184802-12d19af20458+incompatible", + name: "12d19af204585b0db3d2a876ceddf5b9323f5a4a", + short: "12d19af20458", + time: time.Date(2022, 2, 23, 18, 48, 2, 0, time.UTC), + }, +} + +func TestCodeRepo(t *testing.T) { + testenv.MustHaveExternalNetwork(t) + tmpdir := t.TempDir() + fetcher := NewFetcher() + + for _, tt := range codeRepoTests { + f := func(tt codeRepoTest) func(t *testing.T) { + return func(t *testing.T) { + if strings.Contains(tt.path, "gopkg.in") { + testenv.SkipFlaky(t, 54503) + } + + t.Parallel() + if tt.vcs != "mod" { + testenv.MustHaveExecPath(t, tt.vcs) + } + ctx := context.Background() + + repo := fetcher.Lookup(ctx, "direct", tt.path) + + if tt.mpath == "" { + tt.mpath = tt.path + } + if mpath := repo.ModulePath(); mpath != tt.mpath { + t.Errorf("repo.ModulePath() = %q, want %q", mpath, tt.mpath) + } + + info, err := repo.Stat(ctx, tt.rev) + if err != nil { + if tt.err != "" { + if !strings.Contains(err.Error(), tt.err) { + t.Fatalf("repoStat(%q): %v, wanted %q", tt.rev, err, tt.err) + } + return + } + t.Fatalf("repo.Stat(%q): %v", tt.rev, err) + } + if tt.err != "" { + t.Errorf("repo.Stat(%q): success, wanted error", tt.rev) + } + if info.Version != tt.version { + t.Errorf("info.Version = %q, want %q", info.Version, tt.version) + } + if info.Name != tt.name { + t.Errorf("info.Name = %q, want %q", info.Name, tt.name) + } + if info.Short != tt.short { + t.Errorf("info.Short = %q, want %q", info.Short, tt.short) + } + if !info.Time.Equal(tt.time) { + t.Errorf("info.Time = %v, want %v", info.Time, tt.time) + } + + if tt.gomod != "" || tt.gomodErr != "" { + data, err := repo.GoMod(ctx, tt.version) + if err != nil && tt.gomodErr == "" { + t.Errorf("repo.GoMod(%q): %v", tt.version, err) + } else if err != nil && tt.gomodErr != "" { + if err.Error() != tt.gomodErr { + t.Errorf("repo.GoMod(%q): %v, want %q", tt.version, err, tt.gomodErr) + } + } else if tt.gomodErr != "" { + t.Errorf("repo.GoMod(%q) = %q, want error %q", tt.version, data, tt.gomodErr) + } else if string(data) != tt.gomod { + t.Errorf("repo.GoMod(%q) = %q, want %q", tt.version, data, tt.gomod) + } + } + + needHash := !testing.Short() && (tt.zipFileHash != "" || tt.zipSum != "") + if tt.zip != nil || tt.zipErr != "" || needHash { + f, err := os.CreateTemp(tmpdir, tt.version+".zip.") + if err != nil { + t.Fatalf("os.CreateTemp: %v", err) + } + zipfile := f.Name() + defer func() { + f.Close() + os.Remove(zipfile) + }() + + var w io.Writer + var h hash.Hash + if needHash { + h = sha256.New() + w = io.MultiWriter(f, h) + } else { + w = f + } + err = repo.Zip(ctx, w, tt.version) + f.Close() + if err != nil { + if tt.zipErr != "" { + if err.Error() == tt.zipErr { + return + } + t.Fatalf("repo.Zip(%q): %v, want error %q", tt.version, err, tt.zipErr) + } + t.Fatalf("repo.Zip(%q): %v", tt.version, err) + } + if tt.zipErr != "" { + t.Errorf("repo.Zip(%q): success, want error %q", tt.version, tt.zipErr) + } + + if tt.zip != nil { + prefix := tt.path + "@" + tt.version + "/" + z, err := zip.OpenReader(zipfile) + if err != nil { + t.Fatalf("open zip %s: %v", zipfile, err) + } + var names []string + for _, file := range z.File { + if !strings.HasPrefix(file.Name, prefix) { + t.Errorf("zip entry %v does not start with prefix %v", file.Name, prefix) + continue + } + names = append(names, file.Name[len(prefix):]) + } + z.Close() + if !reflect.DeepEqual(names, tt.zip) { + t.Fatalf("zip = %v\nwant %v\n", names, tt.zip) + } + } + + if needHash { + sum, err := dirhash.HashZip(zipfile, dirhash.Hash1) + if err != nil { + t.Errorf("repo.Zip(%q): %v", tt.version, err) + } else if sum != tt.zipSum { + t.Errorf("repo.Zip(%q): got file with sum %q, want %q", tt.version, sum, tt.zipSum) + } else if zipFileHash := hex.EncodeToString(h.Sum(nil)); zipFileHash != tt.zipFileHash { + t.Errorf("repo.Zip(%q): got file with hash %q, want %q (but content has correct sum)", tt.version, zipFileHash, tt.zipFileHash) + } + } + } + } + } + t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.rev, f(tt)) + if strings.HasPrefix(tt.path, vgotest1git) { + for vcs, alt := range altVgotests { + altTest := tt + altTest.vcs = vcs + altTest.path = alt + strings.TrimPrefix(altTest.path, vgotest1git) + if strings.HasPrefix(altTest.mpath, vgotest1git) { + altTest.mpath = alt + strings.TrimPrefix(altTest.mpath, vgotest1git) + } + var m map[string]string + if alt == vgotest1hg { + m = hgmap + } + altTest.version = remap(altTest.version, m) + altTest.name = remap(altTest.name, m) + altTest.short = remap(altTest.short, m) + altTest.rev = remap(altTest.rev, m) + altTest.err = remap(altTest.err, m) + altTest.gomodErr = remap(altTest.gomodErr, m) + altTest.zipErr = remap(altTest.zipErr, m) + altTest.zipSum = "" + altTest.zipFileHash = "" + t.Run(strings.ReplaceAll(altTest.path, "/", "_")+"/"+altTest.rev, f(altTest)) + } + } + } +} + +var hgmap = map[string]string{ + "github.com/rsc/vgotest1": "vcs-test.golang.org/hg/vgotest1.hg", + "f18795870fb14388a21ef3ebc1d75911c8694f31": "a9ad6d1d14eb544f459f446210c7eb3b009807c6", + "ea65f87c8f52c15ea68f3bdd9925ef17e20d91e9": "f1fc0f22021b638d073d31c752847e7bf385def7", + "b769f2de407a4db81af9c5de0a06016d60d2ea09": "92c7eb888b4fac17f1c6bd2e1060a1b881a3b832", + "8afe2b2efed96e0880ecd2a69b98a53b8c2738b6": "4e58084d459ae7e79c8c2264d0e8e9a92eb5cd44", + "2f615117ce481c8efef46e0cc0b4b4dccfac8fea": "879ea98f7743c8eff54f59a918f3a24123d1cf46", + "80d85c5d4d17598a0e9055e7c175a32b415d6128": "e125018e286a4b09061079a81e7b537070b7ff71", + "1f863feb76bc7029b78b21c5375644838962f88d": "bf63880162304a9337477f3858f5b7e255c75459", + "45f53230a74ad275c7127e117ac46914c8126160": "814fce58e83abd5bf2a13892e0b0e1198abefcd4", +} + +func remap(name string, m map[string]string) string { + if m[name] != "" { + return m[name] + } + if codehost.AllHex(name) { + for k, v := range m { + if strings.HasPrefix(k, name) { + return v[:len(name)] + } + } + } + for k, v := range m { + name = strings.ReplaceAll(name, k, v) + if codehost.AllHex(k) { + name = strings.ReplaceAll(name, k[:12], v[:12]) + } + } + return name +} + +var codeRepoVersionsTests = []struct { + vcs string + path string + prefix string + versions []string +}{ + { + vcs: "git", + path: "github.com/rsc/vgotest1", + versions: []string{"v0.0.0", "v0.0.1", "v1.0.0", "v1.0.1", "v1.0.2", "v1.0.3", "v1.1.0"}, + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1", + prefix: "v1.0", + versions: []string{"v1.0.0", "v1.0.1", "v1.0.2", "v1.0.3"}, + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/v2", + versions: []string{"v2.0.0", "v2.0.1", "v2.0.2", "v2.0.3", "v2.0.4", "v2.0.5", "v2.0.6"}, + }, + { + vcs: "mod", + path: "swtch.com/testmod", + versions: []string{"v1.0.0", "v1.1.1"}, + }, + { + vcs: "git", + path: "vcs-test.golang.org/git/odd-tags.git", + versions: nil, + }, +} + +func TestCodeRepoVersions(t *testing.T) { + testenv.MustHaveExternalNetwork(t) + fetcher := NewFetcher() + for _, tt := range codeRepoVersionsTests { + tt := tt + t.Run(strings.ReplaceAll(tt.path, "/", "_"), func(t *testing.T) { + if strings.Contains(tt.path, "gopkg.in") { + testenv.SkipFlaky(t, 54503) + } + + t.Parallel() + if tt.vcs != "mod" { + testenv.MustHaveExecPath(t, tt.vcs) + } + ctx := context.Background() + + repo := fetcher.Lookup(ctx, "direct", tt.path) + list, err := repo.Versions(ctx, tt.prefix) + if err != nil { + t.Fatalf("Versions(%q): %v", tt.prefix, err) + } + if !reflect.DeepEqual(list.List, tt.versions) { + t.Fatalf("Versions(%q):\nhave %v\nwant %v", tt.prefix, list, tt.versions) + } + }) + } +} + +var latestTests = []struct { + vcs string + path string + version string + err string +}{ + { + vcs: "git", + path: "github.com/rsc/empty", + err: "no commits", + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1", + err: `github.com/rsc/vgotest1@v0.0.0-20180219223237-a08abb797a67: invalid version: go.mod has post-v0 module path "github.com/vgotest1/v2" at revision a08abb797a67`, + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/v2", + err: `github.com/rsc/vgotest1/v2@v2.0.0-20180219223237-a08abb797a67: invalid version: github.com/rsc/vgotest1/go.mod and .../v2/go.mod both have .../v2 module paths at revision a08abb797a67`, + }, + { + vcs: "git", + path: "github.com/rsc/vgotest1/subdir", + err: "github.com/rsc/vgotest1/subdir@v0.0.0-20180219223237-a08abb797a67: invalid version: missing github.com/rsc/vgotest1/subdir/go.mod at revision a08abb797a67", + }, + { + vcs: "git", + path: "vcs-test.golang.org/git/commit-after-tag.git", + version: "v1.0.1-0.20190715211727-b325d8217783", + }, + { + vcs: "git", + path: "vcs-test.golang.org/git/no-tags.git", + version: "v0.0.0-20190715212047-e706ba1d9f6d", + }, + { + vcs: "mod", + path: "swtch.com/testmod", + version: "v1.1.1", + }, + { + vcs: "git", + path: "vcs-test.golang.org/go/gitreposubdir", + version: "v1.2.3", + }, + { + vcs: "git", + path: "vcs-test.golang.org/go/gitreposubdirv2/v2", + version: "v2.0.0", + }, +} + +func TestLatest(t *testing.T) { + testenv.MustHaveExternalNetwork(t) + fetcher := NewFetcher() + for _, tt := range latestTests { + name := strings.ReplaceAll(tt.path, "/", "_") + t.Run(name, func(t *testing.T) { + tt := tt + t.Parallel() + if tt.vcs != "mod" { + testenv.MustHaveExecPath(t, tt.vcs) + } + ctx := context.Background() + + repo := fetcher.Lookup(ctx, "direct", tt.path) + info, err := repo.Latest(ctx) + if err != nil { + if tt.err != "" { + if err.Error() == tt.err { + return + } + t.Fatalf("Latest(): %v, want %q", err, tt.err) + } + t.Fatalf("Latest(): %v", err) + } + if tt.err != "" { + t.Fatalf("Latest() = %v, want error %q", info.Version, tt.err) + } + if info.Version != tt.version { + t.Fatalf("Latest() = %v, want %v", info.Version, tt.version) + } + }) + } +} + +// fixedTagsRepo is a fake codehost.Repo that returns a fixed list of tags +type fixedTagsRepo struct { + tags []string + codehost.Repo +} + +func (ch *fixedTagsRepo) Tags(ctx context.Context, prefix string) (*codehost.Tags, error) { + tags := &codehost.Tags{} + for _, t := range ch.tags { + tags.List = append(tags.List, codehost.Tag{Name: t}) + } + return tags, nil +} + +func TestNonCanonicalSemver(t *testing.T) { + t.Parallel() + ctx := context.Background() + + root := "golang.org/x/issue24476" + ch := &fixedTagsRepo{ + tags: []string{ + "", "huh?", "1.0.1", + // what about "version 1 dot dogcow"? + "v1.🐕.🐄", + "v1", "v0.1", + // and one normal one that should pass through + "v1.0.1", + }, + } + + cr, err := newCodeRepo(ch, root, "", root) + if err != nil { + t.Fatal(err) + } + + v, err := cr.Versions(ctx, "") + if err != nil { + t.Fatal(err) + } + if len(v.List) != 1 || v.List[0] != "v1.0.1" { + t.Fatal("unexpected versions returned:", v) + } +} diff --git a/go/src/cmd/go/internal/modfetch/fetch.go b/go/src/cmd/go/internal/modfetch/fetch.go new file mode 100644 index 0000000000000000000000000000000000000000..ed384c3c43fb755d8a52eec97cae4a5b98130d19 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/fetch.go @@ -0,0 +1,1164 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modfetch + +import ( + "archive/zip" + "bytes" + "context" + "crypto/sha256" + "encoding/base64" + "errors" + "fmt" + "io" + "io/fs" + "os" + "path/filepath" + "sort" + "strings" + "sync" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/fsys" + "cmd/go/internal/gover" + "cmd/go/internal/lockedfile" + "cmd/go/internal/str" + "cmd/go/internal/trace" + "cmd/internal/par" + "cmd/internal/robustio" + + "golang.org/x/mod/module" + "golang.org/x/mod/sumdb/dirhash" + modzip "golang.org/x/mod/zip" +) + +var ErrToolchain = errors.New("internal error: invalid operation on toolchain module") + +// Download downloads the specific module version to the +// local download cache and returns the name of the directory +// corresponding to the root of the module's file tree. +func (f *Fetcher) Download(ctx context.Context, mod module.Version) (dir string, err error) { + if gover.IsToolchain(mod.Path) { + return "", ErrToolchain + } + if err := checkCacheDir(ctx); err != nil { + base.Fatal(err) + } + + // The par.Cache here avoids duplicate work. + return f.downloadCache.Do(mod, func() (string, error) { + dir, err := f.download(ctx, mod) + if err != nil { + return "", err + } + f.checkMod(ctx, mod) + + // If go.mod exists (not an old legacy module), check version is not too new. + if data, err := os.ReadFile(filepath.Join(dir, "go.mod")); err == nil { + goVersion := gover.GoModLookup(data, "go") + if gover.Compare(goVersion, gover.Local()) > 0 { + return "", &gover.TooNewError{What: mod.String(), GoVersion: goVersion} + } + } else if !errors.Is(err, fs.ErrNotExist) { + return "", err + } + + return dir, nil + }) +} + +// Unzip is like Download but is given the explicit zip file to use, +// rather than downloading it. This is used for the GOFIPS140 zip files, +// which ship in the Go distribution itself. +func (f *Fetcher) Unzip(ctx context.Context, mod module.Version, zipfile string) (dir string, err error) { + if err := checkCacheDir(ctx); err != nil { + base.Fatal(err) + } + + return f.downloadCache.Do(mod, func() (string, error) { + ctx, span := trace.StartSpan(ctx, "modfetch.Unzip "+mod.String()) + defer span.Done() + + dir, err = DownloadDir(ctx, mod) + if err == nil { + // The directory has already been completely extracted (no .partial file exists). + return dir, nil + } else if dir == "" || !errors.Is(err, fs.ErrNotExist) { + return "", err + } + + return unzip(ctx, mod, zipfile) + }) +} + +func (f *Fetcher) download(ctx context.Context, mod module.Version) (dir string, err error) { + ctx, span := trace.StartSpan(ctx, "modfetch.download "+mod.String()) + defer span.Done() + + dir, err = DownloadDir(ctx, mod) + if err == nil { + // The directory has already been completely extracted (no .partial file exists). + return dir, nil + } else if dir == "" || !errors.Is(err, fs.ErrNotExist) { + return "", err + } + + // To avoid cluttering the cache with extraneous files, + // DownloadZip uses the same lockfile as Download. + // Invoke DownloadZip before locking the file. + zipfile, err := f.DownloadZip(ctx, mod) + if err != nil { + return "", err + } + + return unzip(ctx, mod, zipfile) +} + +func unzip(ctx context.Context, mod module.Version, zipfile string) (dir string, err error) { + unlock, err := lockVersion(ctx, mod) + if err != nil { + return "", err + } + defer unlock() + + ctx, span := trace.StartSpan(ctx, "unzip "+zipfile) + defer span.Done() + + // Check whether the directory was populated while we were waiting on the lock. + dir, dirErr := DownloadDir(ctx, mod) + if dirErr == nil { + return dir, nil + } + _, dirExists := dirErr.(*DownloadDirPartialError) + + // Clean up any remaining temporary directories created by old versions + // (before 1.16), as well as partially extracted directories (indicated by + // DownloadDirPartialError, usually because of a .partial file). This is only + // safe to do because the lock file ensures that their writers are no longer + // active. + parentDir := filepath.Dir(dir) + tmpPrefix := filepath.Base(dir) + ".tmp-" + if old, err := filepath.Glob(filepath.Join(str.QuoteGlob(parentDir), str.QuoteGlob(tmpPrefix)+"*")); err == nil { + for _, path := range old { + RemoveAll(path) // best effort + } + } + if dirExists { + if err := RemoveAll(dir); err != nil { + return "", err + } + } + + partialPath, err := CachePath(ctx, mod, "partial") + if err != nil { + return "", err + } + + // Extract the module zip directory at its final location. + // + // To prevent other processes from reading the directory if we crash, + // create a .partial file before extracting the directory, and delete + // the .partial file afterward (all while holding the lock). + // + // Before Go 1.16, we extracted to a temporary directory with a random name + // then renamed it into place with os.Rename. On Windows, this failed with + // ERROR_ACCESS_DENIED when another process (usually an anti-virus scanner) + // opened files in the temporary directory. + // + // Go 1.14.2 and higher respect .partial files. Older versions may use + // partially extracted directories. 'go mod verify' can detect this, + // and 'go clean -modcache' can fix it. + if err := os.MkdirAll(parentDir, 0o777); err != nil { + return "", err + } + if err := os.WriteFile(partialPath, nil, 0o666); err != nil { + return "", err + } + if err := modzip.Unzip(dir, mod, zipfile); err != nil { + fmt.Fprintf(os.Stderr, "-> %s\n", err) + if rmErr := RemoveAll(dir); rmErr == nil { + os.Remove(partialPath) + } + return "", err + } + if err := os.Remove(partialPath); err != nil { + return "", err + } + + if !cfg.ModCacheRW { + makeDirsReadOnly(dir) + } + return dir, nil +} + +var downloadZipCache par.ErrCache[module.Version, string] + +// DownloadZip downloads the specific module version to the +// local zip cache and returns the name of the zip file. +func (f *Fetcher) DownloadZip(ctx context.Context, mod module.Version) (zipfile string, err error) { + // The par.Cache here avoids duplicate work. + return downloadZipCache.Do(mod, func() (string, error) { + zipfile, err := CachePath(ctx, mod, "zip") + if err != nil { + return "", err + } + ziphashfile := zipfile + "hash" + + // Return early if the zip and ziphash files exist. + if _, err := os.Stat(zipfile); err == nil { + if _, err := os.Stat(ziphashfile); err == nil { + if !HaveSum(f, mod) { + f.checkMod(ctx, mod) + } + return zipfile, nil + } + } + + // The zip or ziphash file does not exist. Acquire the lock and create them. + if cfg.CmdName != "mod download" { + vers := mod.Version + if mod.Path == "golang.org/toolchain" { + // Shorten v0.0.1-go1.13.1.darwin-amd64 to go1.13.1.darwin-amd64 + _, vers, _ = strings.Cut(vers, "-") + if i := strings.LastIndex(vers, "."); i >= 0 { + goos, goarch, _ := strings.Cut(vers[i+1:], "-") + vers = vers[:i] + " (" + goos + "/" + goarch + ")" + } + fmt.Fprintf(os.Stderr, "go: downloading %s\n", vers) + } else { + fmt.Fprintf(os.Stderr, "go: downloading %s %s\n", mod.Path, vers) + } + } + unlock, err := lockVersion(ctx, mod) + if err != nil { + return "", err + } + defer unlock() + + if err := f.downloadZip(ctx, mod, zipfile); err != nil { + return "", err + } + return zipfile, nil + }) +} + +func (f *Fetcher) downloadZip(ctx context.Context, mod module.Version, zipfile string) (err error) { + ctx, span := trace.StartSpan(ctx, "modfetch.downloadZip "+zipfile) + defer span.Done() + + // Double-check that the zipfile was not created while we were waiting for + // the lock in DownloadZip. + ziphashfile := zipfile + "hash" + var zipExists, ziphashExists bool + if _, err := os.Stat(zipfile); err == nil { + zipExists = true + } + if _, err := os.Stat(ziphashfile); err == nil { + ziphashExists = true + } + if zipExists && ziphashExists { + return nil + } + + // Create parent directories. + if err := os.MkdirAll(filepath.Dir(zipfile), 0o777); err != nil { + return err + } + + // Clean up any remaining tempfiles from previous runs. + // This is only safe to do because the lock file ensures that their + // writers are no longer active. + tmpPattern := filepath.Base(zipfile) + "*.tmp" + if old, err := filepath.Glob(filepath.Join(str.QuoteGlob(filepath.Dir(zipfile)), tmpPattern)); err == nil { + for _, path := range old { + os.Remove(path) // best effort + } + } + + // If the zip file exists, the ziphash file must have been deleted + // or lost after a file system crash. Re-hash the zip without downloading. + if zipExists { + return hashZip(f, mod, zipfile, ziphashfile) + } + + // From here to the os.Rename call below is functionally almost equivalent to + // renameio.WriteToFile, with one key difference: we want to validate the + // contents of the file (by hashing it) before we commit it. Because the file + // is zip-compressed, we need an actual file — or at least an io.ReaderAt — to + // validate it: we can't just tee the stream as we write it. + file, err := tempFile(ctx, filepath.Dir(zipfile), filepath.Base(zipfile), 0o666) + if err != nil { + return err + } + defer func() { + if err != nil { + file.Close() + os.Remove(file.Name()) + } + }() + + var unrecoverableErr error + err = TryProxies(func(proxy string) error { + if unrecoverableErr != nil { + return unrecoverableErr + } + repo := f.Lookup(ctx, proxy, mod.Path) + err := repo.Zip(ctx, file, mod.Version) + if err != nil { + // Zip may have partially written to f before failing. + // (Perhaps the server crashed while sending the file?) + // Since we allow fallback on error in some cases, we need to fix up the + // file to be empty again for the next attempt. + if _, err := file.Seek(0, io.SeekStart); err != nil { + unrecoverableErr = err + return err + } + if err := file.Truncate(0); err != nil { + unrecoverableErr = err + return err + } + } + return err + }) + if err != nil { + return err + } + + // Double-check that the paths within the zip file are well-formed. + // + // TODO(bcmills): There is a similar check within the Unzip function. Can we eliminate one? + fi, err := file.Stat() + if err != nil { + return err + } + z, err := zip.NewReader(file, fi.Size()) + if err != nil { + return err + } + prefix := mod.Path + "@" + mod.Version + "/" + for _, zf := range z.File { + if !strings.HasPrefix(zf.Name, prefix) { + return fmt.Errorf("zip for %s has unexpected file %s", prefix[:len(prefix)-1], zf.Name) + } + } + + if err := file.Close(); err != nil { + return err + } + + // Hash the zip file and check the sum before renaming to the final location. + if err := hashZip(f, mod, file.Name(), ziphashfile); err != nil { + return err + } + if err := os.Rename(file.Name(), zipfile); err != nil { + return err + } + + // TODO(bcmills): Should we make the .zip and .ziphash files read-only to discourage tampering? + + return nil +} + +// hashZip reads the zip file opened in f, then writes the hash to ziphashfile, +// overwriting that file if it exists. +// +// If the hash does not match go.sum (or the sumdb if enabled), hashZip returns +// an error and does not write ziphashfile. +func hashZip(f *Fetcher, mod module.Version, zipfile, ziphashfile string) (err error) { + hash, err := dirhash.HashZip(zipfile, dirhash.DefaultHash) + if err != nil { + return err + } + if err := checkModSum(f, mod, hash); err != nil { + return err + } + hf, err := lockedfile.Create(ziphashfile) + if err != nil { + return err + } + defer func() { + if closeErr := hf.Close(); err == nil && closeErr != nil { + err = closeErr + } + }() + if err := hf.Truncate(int64(len(hash))); err != nil { + return err + } + if _, err := hf.WriteAt([]byte(hash), 0); err != nil { + return err + } + return nil +} + +// makeDirsReadOnly makes a best-effort attempt to remove write permissions for dir +// and its transitive contents. +func makeDirsReadOnly(dir string) { + type pathMode struct { + path string + mode fs.FileMode + } + var dirs []pathMode // in lexical order + filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { + if err == nil && d.IsDir() { + info, err := d.Info() + if err == nil && info.Mode()&0o222 != 0 { + dirs = append(dirs, pathMode{path, info.Mode()}) + } + } + return nil + }) + + // Run over list backward to chmod children before parents. + for i := len(dirs) - 1; i >= 0; i-- { + os.Chmod(dirs[i].path, dirs[i].mode&^0o222) + } +} + +// RemoveAll removes a directory written by Download or Unzip, first applying +// any permission changes needed to do so. +func RemoveAll(dir string) error { + // Module cache has 0555 directories; make them writable in order to remove content. + filepath.WalkDir(dir, func(path string, info fs.DirEntry, err error) error { + if err != nil { + return nil // ignore errors walking in file system + } + if info.IsDir() { + os.Chmod(path, 0o777) + } + return nil + }) + return robustio.RemoveAll(dir) +} + +// The GoSumFile, WorkspaceGoSumFiles, and goSum are global state that must not be +// accessed by any of the exported functions of this package after they return, because +// they can be modified by the non-thread-safe SetState function. + +type modSum struct { + mod module.Version + sum string +} + +type sumState struct { + m map[module.Version][]string // content of go.sum file + w map[string]map[module.Version][]string // sum file in workspace -> content of that sum file + status map[modSum]modSumStatus // state of sums in m + overwrite bool // if true, overwrite go.sum without incorporating its contents + enabled bool // whether to use go.sum at all +} + +type modSumStatus struct { + used, dirty bool +} + +// Fetcher holds a snapshot of the global state of the modfetch package. +type Fetcher struct { + // path to go.sum; set by package modload + goSumFile string + // path to module go.sums in workspace; set by package modload + workspaceGoSumFiles []string + // The Lookup cache is used cache the work done by Lookup. + // It is important that the global functions of this package that access it do not + // do so after they return. + lookupCache *par.Cache[lookupCacheKey, Repo] + // The downloadCache is used to cache the operation of downloading a module to disk + // (if it's not already downloaded) and getting the directory it was downloaded to. + // It is important that downloadCache must not be accessed by any of the exported + // functions of this package after they return, because it can be modified by the + // non-thread-safe SetState function. + downloadCache *par.ErrCache[module.Version, string] // version → directory; + + mu sync.Mutex + sumState sumState +} + +func NewFetcher() *Fetcher { + f := new(Fetcher) + f.lookupCache = new(par.Cache[lookupCacheKey, Repo]) + f.downloadCache = new(par.ErrCache[module.Version, string]) + return f +} + +func (f *Fetcher) GoSumFile() string { + return f.goSumFile +} + +func (f *Fetcher) SetGoSumFile(str string) { + f.goSumFile = str +} + +func (f *Fetcher) AddWorkspaceGoSumFile(file string) { + f.workspaceGoSumFiles = append(f.workspaceGoSumFiles, file) +} + +// Reset resets globals in the modfetch package, so previous loads don't affect +// contents of go.sum files. +func (f *Fetcher) Reset() { + f.SetState(NewFetcher()) +} + +// SetState sets the global state of the modfetch package to the newState, and returns the previous +// global state. newState should have been returned by SetState, or be an empty State. +// There should be no concurrent calls to any of the exported functions of this package with +// a call to SetState because it will modify the global state in a non-thread-safe way. +func (f *Fetcher) SetState(newState *Fetcher) (oldState *Fetcher) { + if newState.lookupCache == nil { + newState.lookupCache = new(par.Cache[lookupCacheKey, Repo]) + } + if newState.downloadCache == nil { + newState.downloadCache = new(par.ErrCache[module.Version, string]) + } + + f.mu.Lock() + defer f.mu.Unlock() + + oldState = &Fetcher{ + goSumFile: f.goSumFile, + workspaceGoSumFiles: f.workspaceGoSumFiles, + lookupCache: f.lookupCache, + downloadCache: f.downloadCache, + sumState: f.sumState, + } + + f.SetGoSumFile(newState.goSumFile) + f.workspaceGoSumFiles = newState.workspaceGoSumFiles + // Uses of lookupCache and downloadCache both can call checkModSum, + // which in turn sets the used bit on goSum.status for modules. + // Set (or reset) them so used can be computed properly. + f.lookupCache = newState.lookupCache + f.downloadCache = newState.downloadCache + // Set, or reset all fields on goSum. If being reset to empty, it will be initialized later. + f.sumState = newState.sumState + + return oldState +} + +// initGoSum initializes the go.sum data. +// The boolean it returns reports whether the +// use of go.sum is now enabled. +// The goSum lock must be held. +func (f *Fetcher) initGoSum() (bool, error) { + if f.goSumFile == "" { + return false, nil + } + if f.sumState.m != nil { + return true, nil + } + + f.sumState.m = make(map[module.Version][]string) + f.sumState.status = make(map[modSum]modSumStatus) + f.sumState.w = make(map[string]map[module.Version][]string) + + for _, fn := range f.workspaceGoSumFiles { + f.sumState.w[fn] = make(map[module.Version][]string) + _, err := readGoSumFile(f.sumState.w[fn], fn) + if err != nil { + return false, err + } + } + + enabled, err := readGoSumFile(f.sumState.m, f.goSumFile) + f.sumState.enabled = enabled + return enabled, err +} + +func readGoSumFile(dst map[module.Version][]string, file string) (bool, error) { + var ( + data []byte + err error + ) + if fsys.Replaced(file) { + // Don't lock go.sum if it's part of the overlay. + // On Plan 9, locking requires chmod, and we don't want to modify any file + // in the overlay. See #44700. + data, err = os.ReadFile(fsys.Actual(file)) + } else { + data, err = lockedfile.Read(file) + } + if err != nil && !os.IsNotExist(err) { + return false, err + } + readGoSum(dst, file, data) + + return true, nil +} + +// emptyGoModHash is the hash of a 1-file tree containing a 0-length go.mod. +// A bug caused us to write these into go.sum files for non-modules. +// We detect and remove them. +const emptyGoModHash = "h1:G7mAYYxgmS0lVkHyy2hEOLQCFB0DlQFTMLWggykrydY=" + +// readGoSum parses data, which is the content of file, +// and adds it to goSum.m. The goSum lock must be held. +func readGoSum(dst map[module.Version][]string, file string, data []byte) { + lineno := 0 + for len(data) > 0 { + var line []byte + lineno++ + i := bytes.IndexByte(data, '\n') + if i < 0 { + line, data = data, nil + } else { + line, data = data[:i], data[i+1:] + } + f := strings.Fields(string(line)) + if len(f) == 0 { + // blank line; skip it + continue + } + if len(f) != 3 { + if cfg.CmdName == "mod tidy" { + // ignore malformed line so that go mod tidy can fix go.sum + continue + } else { + base.Fatalf("malformed go.sum:\n%s:%d: wrong number of fields %v\n", file, lineno, len(f)) + } + } + if f[2] == emptyGoModHash { + // Old bug; drop it. + continue + } + mod := module.Version{Path: f[0], Version: f[1]} + dst[mod] = append(dst[mod], f[2]) + } +} + +// HaveSum returns true if the go.sum file contains an entry for mod. +// The entry's hash must be generated with a known hash algorithm. +// mod.Version may have a "/go.mod" suffix to distinguish sums for +// .mod and .zip files. +func HaveSum(f *Fetcher, mod module.Version) bool { + f.mu.Lock() + defer f.mu.Unlock() + inited, err := f.initGoSum() + if err != nil || !inited { + return false + } + for _, goSums := range f.sumState.w { + for _, h := range goSums[mod] { + if !strings.HasPrefix(h, "h1:") { + continue + } + if !f.sumState.status[modSum{mod, h}].dirty { + return true + } + } + } + for _, h := range f.sumState.m[mod] { + if !strings.HasPrefix(h, "h1:") { + continue + } + if !f.sumState.status[modSum{mod, h}].dirty { + return true + } + } + return false +} + +// RecordedSum returns the sum if the go.sum file contains an entry for mod. +// The boolean reports true if an entry was found or +// false if no entry found or two conflicting sums are found. +// The entry's hash must be generated with a known hash algorithm. +// mod.Version may have a "/go.mod" suffix to distinguish sums for +// .mod and .zip files. +func (f *Fetcher) RecordedSum(mod module.Version) (sum string, ok bool) { + f.mu.Lock() + defer f.mu.Unlock() + inited, err := f.initGoSum() + foundSum := "" + if err != nil || !inited { + return "", false + } + for _, goSums := range f.sumState.w { + for _, h := range goSums[mod] { + if !strings.HasPrefix(h, "h1:") { + continue + } + if !f.sumState.status[modSum{mod, h}].dirty { + if foundSum != "" && foundSum != h { // conflicting sums exist + return "", false + } + foundSum = h + } + } + } + for _, h := range f.sumState.m[mod] { + if !strings.HasPrefix(h, "h1:") { + continue + } + if !f.sumState.status[modSum{mod, h}].dirty { + if foundSum != "" && foundSum != h { // conflicting sums exist + return "", false + } + foundSum = h + } + } + return foundSum, true +} + +// checkMod checks the given module's checksum and Go version. +func (f *Fetcher) checkMod(ctx context.Context, mod module.Version) { + // Do the file I/O before acquiring the go.sum lock. + ziphash, err := CachePath(ctx, mod, "ziphash") + if err != nil { + base.Fatalf("verifying %v", module.VersionError(mod, err)) + } + data, err := lockedfile.Read(ziphash) + if err != nil { + base.Fatalf("verifying %v", module.VersionError(mod, err)) + } + data = bytes.TrimSpace(data) + if !isValidSum(data) { + // Recreate ziphash file from zip file and use that to check the mod sum. + zip, err := CachePath(ctx, mod, "zip") + if err != nil { + base.Fatalf("verifying %v", module.VersionError(mod, err)) + } + err = hashZip(f, mod, zip, ziphash) + if err != nil { + base.Fatalf("verifying %v", module.VersionError(mod, err)) + } + return + } + h := string(data) + if !strings.HasPrefix(h, "h1:") { + base.Fatalf("verifying %v", module.VersionError(mod, fmt.Errorf("unexpected ziphash: %q", h))) + } + + if err := checkModSum(f, mod, h); err != nil { + base.Fatalf("%s", err) + } +} + +// goModSum returns the checksum for the go.mod contents. +func goModSum(data []byte) (string, error) { + return dirhash.Hash1([]string{"go.mod"}, func(string) (io.ReadCloser, error) { + return io.NopCloser(bytes.NewReader(data)), nil + }) +} + +// checkGoMod checks the given module's go.mod checksum; +// data is the go.mod content. +func checkGoMod(f *Fetcher, path, version string, data []byte) error { + h, err := goModSum(data) + if err != nil { + return &module.ModuleError{Path: path, Version: version, Err: fmt.Errorf("verifying go.mod: %v", err)} + } + + return checkModSum(f, module.Version{Path: path, Version: version + "/go.mod"}, h) +} + +// checkModSum checks that the recorded checksum for mod is h. +// +// mod.Version may have the additional suffix "/go.mod" to request the checksum +// for the module's go.mod file only. +func checkModSum(f *Fetcher, mod module.Version, h string) error { + // We lock goSum when manipulating it, + // but we arrange to release the lock when calling checkSumDB, + // so that parallel calls to checkModHash can execute parallel calls + // to checkSumDB. + + // Check whether mod+h is listed in go.sum already. If so, we're done. + f.mu.Lock() + inited, err := f.initGoSum() + if err != nil { + f.mu.Unlock() + return err + } + done := inited && haveModSumLocked(f, mod, h) + if inited { + st := f.sumState.status[modSum{mod, h}] + st.used = true + f.sumState.status[modSum{mod, h}] = st + } + f.mu.Unlock() + + if done { + return nil + } + + // Not listed, so we want to add them. + // Consult checksum database if appropriate. + if useSumDB(mod) { + // Calls base.Fatalf if mismatch detected. + if err := checkSumDB(mod, h); err != nil { + return err + } + } + + // Add mod+h to go.sum, if it hasn't appeared already. + if inited { + f.mu.Lock() + addModSumLocked(f, mod, h) + st := f.sumState.status[modSum{mod, h}] + st.dirty = true + f.sumState.status[modSum{mod, h}] = st + f.mu.Unlock() + } + return nil +} + +// haveModSumLocked reports whether the pair mod,h is already listed in go.sum. +// If it finds a conflicting pair instead, it calls base.Fatalf. +// goSum.mu must be locked. +func haveModSumLocked(f *Fetcher, mod module.Version, h string) bool { + sumFileName := "go.sum" + if strings.HasSuffix(f.goSumFile, "go.work.sum") { + sumFileName = "go.work.sum" + } + for _, vh := range f.sumState.m[mod] { + if h == vh { + return true + } + if strings.HasPrefix(vh, "h1:") { + base.Fatalf("verifying %s@%s: checksum mismatch\n\tdownloaded: %v\n\t%s: %v"+goSumMismatch, mod.Path, mod.Version, h, sumFileName, vh) + } + } + // Also check workspace sums. + foundMatch := false + // Check sums from all files in case there are conflicts between + // the files. + for goSumFile, goSums := range f.sumState.w { + for _, vh := range goSums[mod] { + if h == vh { + foundMatch = true + } else if strings.HasPrefix(vh, "h1:") { + base.Fatalf("verifying %s@%s: checksum mismatch\n\tdownloaded: %v\n\t%s: %v"+goSumMismatch, mod.Path, mod.Version, h, goSumFile, vh) + } + } + } + return foundMatch +} + +// addModSumLocked adds the pair mod,h to go.sum. +// goSum.mu must be locked. +func addModSumLocked(f *Fetcher, mod module.Version, h string) { + if haveModSumLocked(f, mod, h) { + return + } + if len(f.sumState.m[mod]) > 0 { + fmt.Fprintf(os.Stderr, "warning: verifying %s@%s: unknown hashes in go.sum: %v; adding %v"+hashVersionMismatch, mod.Path, mod.Version, strings.Join(f.sumState.m[mod], ", "), h) + } + f.sumState.m[mod] = append(f.sumState.m[mod], h) +} + +// checkSumDB checks the mod, h pair against the Go checksum database. +// It calls base.Fatalf if the hash is to be rejected. +func checkSumDB(mod module.Version, h string) error { + modWithoutSuffix := mod + noun := "module" + if before, found := strings.CutSuffix(mod.Version, "/go.mod"); found { + noun = "go.mod" + modWithoutSuffix.Version = before + } + + db, lines, err := lookupSumDB(mod) + if err != nil { + return module.VersionError(modWithoutSuffix, fmt.Errorf("verifying %s: %v", noun, err)) + } + + have := mod.Path + " " + mod.Version + " " + h + prefix := mod.Path + " " + mod.Version + " h1:" + for _, line := range lines { + if line == have { + return nil + } + if strings.HasPrefix(line, prefix) { + return module.VersionError(modWithoutSuffix, fmt.Errorf("verifying %s: checksum mismatch\n\tdownloaded: %v\n\t%s: %v"+sumdbMismatch, noun, h, db, line[len(prefix)-len("h1:"):])) + } + } + return module.VersionError(modWithoutSuffix, fmt.Errorf("verifying %s: checksum missing from sumdb response"+sumdbAbsent, noun)) +} + +// Sum returns the checksum for the downloaded copy of the given module, +// if present in the download cache. +func Sum(ctx context.Context, mod module.Version) string { + if cfg.GOMODCACHE == "" { + // Do not use current directory. + return "" + } + + ziphash, err := CachePath(ctx, mod, "ziphash") + if err != nil { + return "" + } + data, err := lockedfile.Read(ziphash) + if err != nil { + return "" + } + data = bytes.TrimSpace(data) + if !isValidSum(data) { + return "" + } + return string(data) +} + +// isValidSum returns true if data is the valid contents of a zip hash file. +// Certain critical files are written to disk by first truncating +// then writing the actual bytes, so that if the write fails +// the corrupt file should contain at least one of the null +// bytes written by the truncate operation. +func isValidSum(data []byte) bool { + if bytes.IndexByte(data, '\000') >= 0 { + return false + } + + if len(data) != len("h1:")+base64.StdEncoding.EncodedLen(sha256.Size) { + return false + } + + return true +} + +var ErrGoSumDirty = errors.New("updates to go.sum needed, disabled by -mod=readonly") + +// WriteGoSum writes the go.sum file if it needs to be updated. +// +// keep is used to check whether a newly added sum should be saved in go.sum. +// It should have entries for both module content sums and go.mod sums +// (version ends with "/go.mod"). Existing sums will be preserved unless they +// have been marked for deletion with TrimGoSum. +func (f *Fetcher) WriteGoSum(ctx context.Context, keep map[module.Version]bool, readonly bool) error { + f.mu.Lock() + defer f.mu.Unlock() + + // If we haven't read the go.sum file yet, don't bother writing it. + if !f.sumState.enabled { + return nil + } + + // Check whether we need to add sums for which keep[m] is true or remove + // unused sums marked with TrimGoSum. If there are no changes to make, + // just return without opening go.sum. + dirty := false +Outer: + for m, hs := range f.sumState.m { + for _, h := range hs { + st := f.sumState.status[modSum{m, h}] + if st.dirty && (!st.used || keep[m]) { + dirty = true + break Outer + } + } + } + if !dirty { + return nil + } + if readonly { + return ErrGoSumDirty + } + if fsys.Replaced(f.goSumFile) { + base.Fatalf("go: updates to go.sum needed, but go.sum is part of the overlay specified with -overlay") + } + + // Make a best-effort attempt to acquire the side lock, only to exclude + // previous versions of the 'go' command from making simultaneous edits. + if unlock, err := SideLock(ctx); err == nil { + defer unlock() + } + + err := lockedfile.Transform(f.goSumFile, func(data []byte) ([]byte, error) { + tidyGoSum := tidyGoSum(f, data, keep) + return tidyGoSum, nil + }) + if err != nil { + return fmt.Errorf("updating go.sum: %w", err) + } + + f.sumState.status = make(map[modSum]modSumStatus) + f.sumState.overwrite = false + return nil +} + +// TidyGoSum returns a tidy version of the go.sum file. +// A missing go.sum file is treated as if empty. +func (f *Fetcher) TidyGoSum(keep map[module.Version]bool) (before, after []byte) { + f.mu.Lock() + defer f.mu.Unlock() + before, err := lockedfile.Read(f.goSumFile) + if err != nil && !errors.Is(err, fs.ErrNotExist) { + base.Fatalf("reading go.sum: %v", err) + } + after = tidyGoSum(f, before, keep) + return before, after +} + +// tidyGoSum returns a tidy version of the go.sum file. +// The goSum lock must be held. +func tidyGoSum(f *Fetcher, data []byte, keep map[module.Version]bool) []byte { + if !f.sumState.overwrite { + // Incorporate any sums added by other processes in the meantime. + // Add only the sums that we actually checked: the user may have edited or + // truncated the file to remove erroneous hashes, and we shouldn't restore + // them without good reason. + f.sumState.m = make(map[module.Version][]string, len(f.sumState.m)) + readGoSum(f.sumState.m, f.goSumFile, data) + for ms, st := range f.sumState.status { + if st.used && !sumInWorkspaceModulesLocked(f, ms.mod) { + addModSumLocked(f, ms.mod, ms.sum) + } + } + } + + mods := make([]module.Version, 0, len(f.sumState.m)) + for m := range f.sumState.m { + mods = append(mods, m) + } + module.Sort(mods) + + var buf bytes.Buffer + for _, m := range mods { + list := f.sumState.m[m] + sort.Strings(list) + str.Uniq(&list) + for _, h := range list { + st := f.sumState.status[modSum{m, h}] + if (!st.dirty || (st.used && keep[m])) && !sumInWorkspaceModulesLocked(f, m) { + fmt.Fprintf(&buf, "%s %s %s\n", m.Path, m.Version, h) + } + } + } + return buf.Bytes() +} + +func sumInWorkspaceModulesLocked(f *Fetcher, m module.Version) bool { + for _, goSums := range f.sumState.w { + if _, ok := goSums[m]; ok { + return true + } + } + return false +} + +// TrimGoSum trims go.sum to contain only the modules needed for reproducible +// builds. +// +// keep is used to check whether a sum should be retained in go.mod. It should +// have entries for both module content sums and go.mod sums (version ends +// with "/go.mod"). +func (f *Fetcher) TrimGoSum(keep map[module.Version]bool) { + f.mu.Lock() + defer f.mu.Unlock() + inited, err := f.initGoSum() + if err != nil { + base.Fatalf("%s", err) + } + if !inited { + return + } + + for m, hs := range f.sumState.m { + if !keep[m] { + for _, h := range hs { + f.sumState.status[modSum{m, h}] = modSumStatus{used: false, dirty: true} + } + f.sumState.overwrite = true + } + } +} + +const goSumMismatch = ` + +SECURITY ERROR +This download does NOT match an earlier download recorded in go.sum. +The bits may have been replaced on the origin server, or an attacker may +have intercepted the download attempt. + +For more information, see 'go help module-auth'. +` + +const sumdbMismatch = ` + +SECURITY ERROR +This download does NOT match the one reported by the checksum server. +The bits may have been replaced on the origin server, or an attacker may +have intercepted the download attempt. + +For more information, see 'go help module-auth'. +` + +const sumdbAbsent = ` + +SECURITY ERROR +This download does NOT match one reported by the checksum server. +The checksum server has provided checksums, but the checksums do +not contain an entry for the download. +The checksum server may be malfunctioning, or an attacker may have +intercepted the checksum request. +The download cannot be verified. + +For more information, see 'go help module-auth'. +` + +const hashVersionMismatch = ` + +SECURITY WARNING +This download is listed in go.sum, but using an unknown hash algorithm. +The download cannot be verified. + +For more information, see 'go help module-auth'. + +` + +var HelpModuleAuth = &base.Command{ + UsageLine: "module-auth", + Short: "module authentication using go.sum", + Long: ` +When the go command downloads a module zip file or go.mod file into the +module cache, it computes a cryptographic hash and compares it with a known +value to verify the file hasn't changed since it was first downloaded. Known +hashes are stored in a file in the module root directory named go.sum. Hashes +may also be downloaded from the checksum database depending on the values of +GOSUMDB, GOPRIVATE, and GONOSUMDB. + +For details, see https://golang.org/ref/mod#authenticating. +`, +} + +var HelpPrivate = &base.Command{ + UsageLine: "private", + Short: "configuration for downloading non-public code", + Long: ` +The go command defaults to downloading modules from the public Go module +mirror at proxy.golang.org. It also defaults to validating downloaded modules, +regardless of source, against the public Go checksum database at sum.golang.org. +These defaults work well for publicly available source code. + +The GOPRIVATE environment variable controls which modules the go command +considers to be private (not available publicly) and should therefore not use +the proxy or checksum database. The variable is a comma-separated list of +glob patterns (in the syntax of Go's path.Match) of module path prefixes. +For example, + + GOPRIVATE=*.corp.example.com,rsc.io/private + +causes the go command to treat as private any module with a path prefix +matching either pattern, including git.corp.example.com/xyzzy, rsc.io/private, +and rsc.io/private/quux. + +For fine-grained control over module download and validation, the GONOPROXY +and GONOSUMDB environment variables accept the same kind of glob list +and override GOPRIVATE for the specific decision of whether to use the proxy +and checksum database, respectively. + +For example, if a company ran a module proxy serving private modules, +users would configure go using: + + GOPRIVATE=*.corp.example.com + GOPROXY=proxy.example.com + GONOPROXY=none + +The GOPRIVATE variable is also used to define the "public" and "private" +patterns for the GOVCS variable; see 'go help vcs'. For that usage, +GOPRIVATE applies even in GOPATH mode. In that case, it matches import paths +instead of module paths. + +The 'go env -w' command (see 'go help env') can be used to set these variables +for future go command invocations. + +For more details, see https://golang.org/ref/mod#private-modules. +`, +} diff --git a/go/src/cmd/go/internal/modfetch/key.go b/go/src/cmd/go/internal/modfetch/key.go new file mode 100644 index 0000000000000000000000000000000000000000..06f9989b9d4373c6ae8e477d8eb864ffece1677d --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/key.go @@ -0,0 +1,9 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modfetch + +var knownGOSUMDB = map[string]string{ + "sum.golang.org": "sum.golang.org+033de0ae+Ac4zctda0e5eza+HJyk9SxEdh+s3Ux18htTTAD8OuAn8", +} diff --git a/go/src/cmd/go/internal/modfetch/proxy.go b/go/src/cmd/go/internal/modfetch/proxy.go new file mode 100644 index 0000000000000000000000000000000000000000..896f310bdf77ca4c7a0fec561b13a467072e9218 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/proxy.go @@ -0,0 +1,452 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modfetch + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io" + "io/fs" + "net/url" + pathpkg "path" + "path/filepath" + "strings" + "sync" + "time" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/modfetch/codehost" + "cmd/go/internal/web" + + "golang.org/x/mod/module" + "golang.org/x/mod/semver" +) + +var HelpGoproxy = &base.Command{ + UsageLine: "goproxy", + Short: "module proxy protocol", + Long: ` +A Go module proxy is any web server that can respond to GET requests for +URLs of a specified form. The requests have no query parameters, so even +a site serving from a fixed file system (including a file:/// URL) +can be a module proxy. + +For details on the GOPROXY protocol, see +https://golang.org/ref/mod#goproxy-protocol. +`, +} + +var proxyOnce struct { + sync.Once + list []proxySpec + err error +} + +type proxySpec struct { + // url is the proxy URL or one of "off", "direct", "noproxy". + url string + + // fallBackOnError is true if a request should be attempted on the next proxy + // in the list after any error from this proxy. If fallBackOnError is false, + // the request will only be attempted on the next proxy if the error is + // equivalent to os.ErrNotFound, which is true for 404 and 410 responses. + fallBackOnError bool +} + +func proxyList() ([]proxySpec, error) { + proxyOnce.Do(func() { + if cfg.GONOPROXY != "" && cfg.GOPROXY != "direct" { + proxyOnce.list = append(proxyOnce.list, proxySpec{url: "noproxy"}) + } + + goproxy := cfg.GOPROXY + for goproxy != "" { + var url string + fallBackOnError := false + if i := strings.IndexAny(goproxy, ",|"); i >= 0 { + url = goproxy[:i] + fallBackOnError = goproxy[i] == '|' + goproxy = goproxy[i+1:] + } else { + url = goproxy + goproxy = "" + } + + url = strings.TrimSpace(url) + if url == "" { + continue + } + if url == "off" { + // "off" always fails hard, so can stop walking list. + proxyOnce.list = append(proxyOnce.list, proxySpec{url: "off"}) + break + } + if url == "direct" { + proxyOnce.list = append(proxyOnce.list, proxySpec{url: "direct"}) + // For now, "direct" is the end of the line. We may decide to add some + // sort of fallback behavior for them in the future, so ignore + // subsequent entries for forward-compatibility. + break + } + + // Single-word tokens are reserved for built-in behaviors, and anything + // containing the string ":/" or matching an absolute file path must be a + // complete URL. For all other paths, implicitly add "https://". + if strings.ContainsAny(url, ".:/") && !strings.Contains(url, ":/") && !filepath.IsAbs(url) && !pathpkg.IsAbs(url) { + url = "https://" + url + } + + // Check that newProxyRepo accepts the URL. + // It won't do anything with the path. + if _, err := newProxyRepo(url, "golang.org/x/text"); err != nil { + proxyOnce.err = err + return + } + + proxyOnce.list = append(proxyOnce.list, proxySpec{ + url: url, + fallBackOnError: fallBackOnError, + }) + } + + if len(proxyOnce.list) == 0 || + len(proxyOnce.list) == 1 && proxyOnce.list[0].url == "noproxy" { + // There were no proxies, other than the implicit "noproxy" added when + // GONOPROXY is set. This can happen if GOPROXY is a non-empty string + // like "," or " ". + proxyOnce.err = fmt.Errorf("GOPROXY list is not the empty string, but contains no entries") + } + }) + + return proxyOnce.list, proxyOnce.err +} + +// TryProxies iterates f over each configured proxy (including "noproxy" and +// "direct" if applicable) until f returns no error or until f returns an +// error that is not equivalent to fs.ErrNotExist on a proxy configured +// not to fall back on errors. +// +// TryProxies then returns that final error. +// +// If GOPROXY is set to "off", TryProxies invokes f once with the argument +// "off". +func TryProxies(f func(proxy string) error) error { + proxies, err := proxyList() + if err != nil { + return err + } + if len(proxies) == 0 { + panic("GOPROXY list is empty") + } + + // We try to report the most helpful error to the user. "direct" and "noproxy" + // errors are best, followed by proxy errors other than ErrNotExist, followed + // by ErrNotExist. + // + // Note that errProxyOff, errNoproxy, and errUseProxy are equivalent to + // ErrNotExist. errUseProxy should only be returned if "noproxy" is the only + // proxy. errNoproxy should never be returned, since there should always be a + // more useful error from "noproxy" first. + const ( + notExistRank = iota + proxyRank + directRank + ) + var bestErr error + bestErrRank := notExistRank + for _, proxy := range proxies { + err := f(proxy.url) + if err == nil { + return nil + } + isNotExistErr := errors.Is(err, fs.ErrNotExist) + + if proxy.url == "direct" || (proxy.url == "noproxy" && err != errUseProxy) { + bestErr = err + bestErrRank = directRank + } else if bestErrRank <= proxyRank && !isNotExistErr { + bestErr = err + bestErrRank = proxyRank + } else if bestErrRank == notExistRank { + bestErr = err + } + + if !proxy.fallBackOnError && !isNotExistErr { + break + } + } + return bestErr +} + +type proxyRepo struct { + url *url.URL // The combined module proxy URL joined with the module path. + path string // The module path (unescaped). + redactedBase string // The base module proxy URL in [url.URL.Redacted] form. + + listLatestOnce sync.Once + listLatest *RevInfo + listLatestErr error +} + +func newProxyRepo(baseURL, path string) (Repo, error) { + // Parse the base proxy URL. + base, err := url.Parse(baseURL) + if err != nil { + return nil, err + } + redactedBase := base.Redacted() + switch base.Scheme { + case "http", "https": + // ok + case "file": + if *base != (url.URL{Scheme: base.Scheme, Path: base.Path, RawPath: base.RawPath}) { + return nil, fmt.Errorf("invalid file:// proxy URL with non-path elements: %s", redactedBase) + } + case "": + return nil, fmt.Errorf("invalid proxy URL missing scheme: %s", redactedBase) + default: + return nil, fmt.Errorf("invalid proxy URL scheme (must be https, http, file): %s", redactedBase) + } + + // Append the module path to the URL. + url := base + enc, err := module.EscapePath(path) + if err != nil { + return nil, err + } + url.Path = strings.TrimSuffix(base.Path, "/") + "/" + enc + url.RawPath = strings.TrimSuffix(base.RawPath, "/") + "/" + pathEscape(enc) + + return &proxyRepo{url, path, redactedBase, sync.Once{}, nil, nil}, nil +} + +func (p *proxyRepo) ModulePath() string { + return p.path +} + +var errProxyReuse = fmt.Errorf("proxy does not support CheckReuse") + +func (p *proxyRepo) CheckReuse(ctx context.Context, old *codehost.Origin) error { + return errProxyReuse +} + +// versionError returns err wrapped in a ModuleError for p.path. +func (p *proxyRepo) versionError(version string, err error) error { + if version != "" && version != module.CanonicalVersion(version) { + return &module.ModuleError{ + Path: p.path, + Err: &module.InvalidVersionError{ + Version: version, + Pseudo: module.IsPseudoVersion(version), + Err: err, + }, + } + } + + return &module.ModuleError{ + Path: p.path, + Version: version, + Err: err, + } +} + +func (p *proxyRepo) getBytes(ctx context.Context, path string) ([]byte, error) { + body, redactedURL, err := p.getBody(ctx, path) + if err != nil { + return nil, err + } + defer body.Close() + + b, err := io.ReadAll(body) + if err != nil { + // net/http doesn't add context to Body read errors, so add it here. + // (See https://go.dev/issue/52727.) + return b, &url.Error{Op: "read", URL: redactedURL, Err: err} + } + return b, nil +} + +func (p *proxyRepo) getBody(ctx context.Context, path string) (r io.ReadCloser, redactedURL string, err error) { + fullPath := pathpkg.Join(p.url.Path, path) + + target := *p.url + target.Path = fullPath + target.RawPath = pathpkg.Join(target.RawPath, pathEscape(path)) + + resp, err := web.Get(web.DefaultSecurity, &target) + if err != nil { + return nil, "", err + } + if err := resp.Err(); err != nil { + resp.Body.Close() + return nil, "", err + } + return resp.Body, resp.URL, nil +} + +func (p *proxyRepo) Versions(ctx context.Context, prefix string) (*Versions, error) { + data, err := p.getBytes(ctx, "@v/list") + if err != nil { + p.listLatestOnce.Do(func() { + p.listLatest, p.listLatestErr = nil, p.versionError("", err) + }) + return nil, p.versionError("", err) + } + var list []string + allLine := strings.Split(string(data), "\n") + for _, line := range allLine { + f := strings.Fields(line) + if len(f) >= 1 && semver.IsValid(f[0]) && strings.HasPrefix(f[0], prefix) && !module.IsPseudoVersion(f[0]) { + list = append(list, f[0]) + } + } + p.listLatestOnce.Do(func() { + p.listLatest, p.listLatestErr = p.latestFromList(ctx, allLine) + }) + semver.Sort(list) + return &Versions{List: list}, nil +} + +func (p *proxyRepo) latest(ctx context.Context) (*RevInfo, error) { + p.listLatestOnce.Do(func() { + data, err := p.getBytes(ctx, "@v/list") + if err != nil { + p.listLatestErr = p.versionError("", err) + return + } + list := strings.Split(string(data), "\n") + p.listLatest, p.listLatestErr = p.latestFromList(ctx, list) + }) + return p.listLatest, p.listLatestErr +} + +func (p *proxyRepo) latestFromList(ctx context.Context, allLine []string) (*RevInfo, error) { + var ( + bestTime time.Time + bestVersion string + ) + for _, line := range allLine { + f := strings.Fields(line) + if len(f) >= 1 && semver.IsValid(f[0]) { + // If the proxy includes timestamps, prefer the timestamp it reports. + // Otherwise, derive the timestamp from the pseudo-version. + var ( + ft time.Time + ) + if len(f) >= 2 { + ft, _ = time.Parse(time.RFC3339, f[1]) + } else if module.IsPseudoVersion(f[0]) { + ft, _ = module.PseudoVersionTime(f[0]) + } else { + // Repo.Latest promises that this method is only called where there are + // no tagged versions. Ignore any tagged versions that were added in the + // meantime. + continue + } + if bestTime.Before(ft) { + bestTime = ft + bestVersion = f[0] + } + } + } + if bestVersion == "" { + return nil, p.versionError("", codehost.ErrNoCommits) + } + + // Call Stat to get all the other fields, including Origin information. + return p.Stat(ctx, bestVersion) +} + +func (p *proxyRepo) Stat(ctx context.Context, rev string) (*RevInfo, error) { + encRev, err := module.EscapeVersion(rev) + if err != nil { + return nil, p.versionError(rev, err) + } + data, err := p.getBytes(ctx, "@v/"+encRev+".info") + if err != nil { + return nil, p.versionError(rev, err) + } + info := new(RevInfo) + if err := json.Unmarshal(data, info); err != nil { + return nil, p.versionError(rev, fmt.Errorf("invalid response from proxy %q: %w", p.redactedBase, err)) + } + if info.Version != rev && rev == module.CanonicalVersion(rev) && module.Check(p.path, rev) == nil { + // If we request a correct, appropriate version for the module path, the + // proxy must return either exactly that version or an error — not some + // arbitrary other version. + return nil, p.versionError(rev, fmt.Errorf("proxy returned info for version %s instead of requested version", info.Version)) + } + return info, nil +} + +func (p *proxyRepo) Latest(ctx context.Context) (*RevInfo, error) { + data, err := p.getBytes(ctx, "@latest") + if err != nil { + if !errors.Is(err, fs.ErrNotExist) { + return nil, p.versionError("", err) + } + return p.latest(ctx) + } + info := new(RevInfo) + if err := json.Unmarshal(data, info); err != nil { + return nil, p.versionError("", fmt.Errorf("invalid response from proxy %q: %w", p.redactedBase, err)) + } + return info, nil +} + +func (p *proxyRepo) GoMod(ctx context.Context, version string) ([]byte, error) { + if version != module.CanonicalVersion(version) { + return nil, p.versionError(version, fmt.Errorf("internal error: version passed to GoMod is not canonical")) + } + + encVer, err := module.EscapeVersion(version) + if err != nil { + return nil, p.versionError(version, err) + } + data, err := p.getBytes(ctx, "@v/"+encVer+".mod") + if err != nil { + return nil, p.versionError(version, err) + } + return data, nil +} + +func (p *proxyRepo) Zip(ctx context.Context, dst io.Writer, version string) error { + if version != module.CanonicalVersion(version) { + return p.versionError(version, fmt.Errorf("internal error: version passed to Zip is not canonical")) + } + + encVer, err := module.EscapeVersion(version) + if err != nil { + return p.versionError(version, err) + } + path := "@v/" + encVer + ".zip" + body, redactedURL, err := p.getBody(ctx, path) + if err != nil { + return p.versionError(version, err) + } + defer body.Close() + + lr := &io.LimitedReader{R: body, N: codehost.MaxZipFile + 1} + if _, err := io.Copy(dst, lr); err != nil { + // net/http doesn't add context to Body read errors, so add it here. + // (See https://go.dev/issue/52727.) + err = &url.Error{Op: "read", URL: redactedURL, Err: err} + return p.versionError(version, err) + } + if lr.N <= 0 { + return p.versionError(version, fmt.Errorf("downloaded zip file too large")) + } + return nil +} + +// pathEscape escapes s so it can be used in a path. +// That is, it escapes things like ? and # (which really shouldn't appear anyway). +// It does not escape / to %2F: our REST API is designed so that / can be left as is. +func pathEscape(s string) string { + return strings.ReplaceAll(url.PathEscape(s), "%2F", "/") +} diff --git a/go/src/cmd/go/internal/modfetch/repo.go b/go/src/cmd/go/internal/modfetch/repo.go new file mode 100644 index 0000000000000000000000000000000000000000..5ed2f259a00dba691ce446552d2f5a9031f39c7b --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/repo.go @@ -0,0 +1,438 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modfetch + +import ( + "context" + "fmt" + "io" + "io/fs" + "os" + "strconv" + "time" + + "cmd/go/internal/cfg" + "cmd/go/internal/modfetch/codehost" + "cmd/go/internal/vcs" + web "cmd/go/internal/web" + "cmd/internal/par" + + "golang.org/x/mod/module" +) + +const traceRepo = false // trace all repo actions, for debugging + +// A Repo represents a repository storing all versions of a single module. +// It must be safe for simultaneous use by multiple goroutines. +type Repo interface { + // ModulePath returns the module path. + ModulePath() string + + // CheckReuse checks whether the validation criteria in the origin + // are still satisfied on the server corresponding to this module. + // If so, the caller can reuse any cached Versions or RevInfo containing + // this origin rather than redownloading those from the server. + CheckReuse(ctx context.Context, old *codehost.Origin) error + + // Versions lists all known versions with the given prefix. + // Pseudo-versions are not included. + // + // Versions should be returned sorted in semver order + // (implementations can use semver.Sort). + // + // Versions returns a non-nil error only if there was a problem + // fetching the list of versions: it may return an empty list + // along with a nil error if the list of matching versions + // is known to be empty. + // + // If the underlying repository does not exist, + // Versions returns an error matching errors.Is(_, os.NotExist). + Versions(ctx context.Context, prefix string) (*Versions, error) + + // Stat returns information about the revision rev. + // A revision can be any identifier known to the underlying service: + // commit hash, branch, tag, and so on. + Stat(ctx context.Context, rev string) (*RevInfo, error) + + // Latest returns the latest revision on the default branch, + // whatever that means in the underlying source code repository. + // It is only used when there are no tagged versions. + Latest(ctx context.Context) (*RevInfo, error) + + // GoMod returns the go.mod file for the given version. + GoMod(ctx context.Context, version string) (data []byte, err error) + + // Zip writes a zip file for the given version to dst. + Zip(ctx context.Context, dst io.Writer, version string) error +} + +// A Versions describes the available versions in a module repository. +type Versions struct { + Origin *codehost.Origin `json:",omitempty"` // origin information for reuse + + List []string // semver versions +} + +// A RevInfo describes a single revision in a module repository. +type RevInfo struct { + Version string // suggested version string for this revision + Time time.Time // commit time + + // These fields are used for Stat of arbitrary rev, + // but they are not recorded when talking about module versions. + Name string `json:"-"` // complete ID in underlying repository + Short string `json:"-"` // shortened ID, for use in pseudo-version + + Origin *codehost.Origin `json:",omitempty"` // provenance for reuse +} + +// Re: module paths, import paths, repository roots, and lookups +// +// A module is a collection of Go packages stored in a file tree +// with a go.mod file at the root of the tree. +// The go.mod defines the module path, which is the import path +// corresponding to the root of the file tree. +// The import path of a directory within that file tree is the module path +// joined with the name of the subdirectory relative to the root. +// +// For example, the module with path rsc.io/qr corresponds to the +// file tree in the repository https://github.com/rsc/qr. +// That file tree has a go.mod that says "module rsc.io/qr". +// The package in the root directory has import path "rsc.io/qr". +// The package in the gf256 subdirectory has import path "rsc.io/qr/gf256". +// In this example, "rsc.io/qr" is both a module path and an import path. +// But "rsc.io/qr/gf256" is only an import path, not a module path: +// it names an importable package, but not a module. +// +// As a special case to incorporate code written before modules were +// introduced, if a path p resolves using the pre-module "go get" lookup +// to the root of a source code repository without a go.mod file, +// that repository is treated as if it had a go.mod in its root directory +// declaring module path p. +// +// The presentation so far ignores the fact that a source code repository +// has many different versions of a file tree, and those versions may +// differ in whether a particular go.mod exists and what it contains. +// In fact there is a well-defined mapping only from a module path, version +// pair - often written path@version - to a particular file tree. +// For example rsc.io/qr@v0.1.0 depends on the "implicit go.mod at root of +// repository" rule, while rsc.io/qr@v0.2.0 has an explicit go.mod. +// Because the "go get" import paths rsc.io/qr and github.com/rsc/qr +// both redirect to the Git repository https://github.com/rsc/qr, +// github.com/rsc/qr@v0.1.0 is the same file tree as rsc.io/qr@v0.1.0 +// but a different module (a different name). In contrast, since v0.2.0 +// of that repository has an explicit go.mod that declares path rsc.io/qr, +// github.com/rsc/qr@v0.2.0 is an invalid module path, version pair. +// Before modules, import comments would have had the same effect. +// +// The set of import paths associated with a given module path is +// clearly not fixed: at the least, new directories with new import paths +// can always be added. But another potential operation is to split a +// subtree out of a module into its own module. If done carefully, +// this operation can be done while preserving compatibility for clients. +// For example, suppose that we want to split rsc.io/qr/gf256 into its +// own module, so that there would be two modules rsc.io/qr and rsc.io/qr/gf256. +// Then we can simultaneously issue rsc.io/qr v0.3.0 (dropping the gf256 subdirectory) +// and rsc.io/qr/gf256 v0.1.0, including in their respective go.mod +// cyclic requirements pointing at each other: rsc.io/qr v0.3.0 requires +// rsc.io/qr/gf256 v0.1.0 and vice versa. Then a build can be +// using an older rsc.io/qr module that includes the gf256 package, but if +// it adds a requirement on either the newer rsc.io/qr or the newer +// rsc.io/qr/gf256 module, it will automatically add the requirement +// on the complementary half, ensuring both that rsc.io/qr/gf256 is +// available for importing by the build and also that it is only defined +// by a single module. The gf256 package could move back into the +// original by another simultaneous release of rsc.io/qr v0.4.0 including +// the gf256 subdirectory and an rsc.io/qr/gf256 v0.2.0 with no code +// in its root directory, along with a new requirement cycle. +// The ability to shift module boundaries in this way is expected to be +// important in large-scale program refactorings, similar to the ones +// described in https://talks.golang.org/2016/refactor.article. +// +// The possibility of shifting module boundaries reemphasizes +// that you must know both the module path and its version +// to determine the set of packages provided directly by that module. +// +// On top of all this, it is possible for a single code repository +// to contain multiple modules, either in branches or subdirectories, +// as a limited kind of monorepo. For example rsc.io/qr/v2, +// the v2.x.x continuation of rsc.io/qr, is expected to be found +// in v2-tagged commits in https://github.com/rsc/qr, either +// in the root or in a v2 subdirectory, disambiguated by go.mod. +// Again the precise file tree corresponding to a module +// depends on which version we are considering. +// +// It is also possible for the underlying repository to change over time, +// without changing the module path. If I copy the github repo over +// to https://bitbucket.org/rsc/qr and update https://rsc.io/qr?go-get=1, +// then clients of all versions should start fetching from bitbucket +// instead of github. That is, in contrast to the exact file tree, +// the location of the source code repository associated with a module path +// does not depend on the module version. (This is by design, as the whole +// point of these redirects is to allow package authors to establish a stable +// name that can be updated as code moves from one service to another.) +// +// All of this is important background for the lookup APIs defined in this +// file. +// +// The Lookup function takes a module path and returns a Repo representing +// that module path. Lookup can do only a little with the path alone. +// It can check that the path is well-formed (see semver.CheckPath) +// and it can check that the path can be resolved to a target repository. +// To avoid version control access except when absolutely necessary, +// Lookup does not attempt to connect to the repository itself. + +type lookupCacheKey struct { + proxy, path string +} + +// Lookup returns the module with the given module path, +// fetched through the given proxy. +// +// The distinguished proxy "direct" indicates that the path should be fetched +// from its origin, and "noproxy" indicates that the patch should be fetched +// directly only if GONOPROXY matches the given path. +// +// For the distinguished proxy "off", Lookup always returns a Repo that returns +// a non-nil error for every method call. +// +// A successful return does not guarantee that the module +// has any defined versions. +func (f *Fetcher) Lookup(ctx context.Context, proxy, path string) Repo { + if traceRepo { + defer logCall("Lookup(%q, %q)", proxy, path)() + } + + return f.lookupCache.Do(lookupCacheKey{proxy, path}, func() Repo { + return newCachingRepo(ctx, f, path, func(ctx context.Context) (Repo, error) { + r, err := lookup(f, ctx, proxy, path) + if err == nil && traceRepo { + r = newLoggingRepo(r) + } + return r, err + }) + }) +} + +var lookupLocalCache = new(par.Cache[string, Repo]) // path, Repo + +// LookupLocal returns a Repo that accesses local VCS information. +// +// codeRoot is the module path of the root module in the repository. +// path is the module path of the module being looked up. +// dir is the file system path of the repository containing the module. +func (f *Fetcher) LookupLocal(ctx context.Context, codeRoot string, path string, dir string) Repo { + if traceRepo { + defer logCall("LookupLocal(%q)", path)() + } + + return lookupLocalCache.Do(path, func() Repo { + return newCachingRepo(ctx, f, path, func(ctx context.Context) (Repo, error) { + repoDir, vcsCmd, err := vcs.FromDir(dir, "") + if err != nil { + return nil, err + } + code, err := lookupCodeRepo(ctx, &vcs.RepoRoot{Repo: repoDir, Root: repoDir, VCS: vcsCmd}, true) + if err != nil { + return nil, err + } + r, err := newCodeRepo(code, codeRoot, "", path) + if err == nil && traceRepo { + r = newLoggingRepo(r) + } + return r, err + }) + }) +} + +// lookup returns the module with the given module path. +func lookup(fetcher_ *Fetcher, ctx context.Context, proxy, path string) (r Repo, err error) { + if cfg.BuildMod == "vendor" { + return nil, errLookupDisabled + } + + switch path { + case "go", "toolchain": + return &toolchainRepo{path, fetcher_.Lookup(ctx, proxy, "golang.org/toolchain")}, nil + } + + if module.MatchPrefixPatterns(cfg.GONOPROXY, path) { + switch proxy { + case "noproxy", "direct": + return lookupDirect(ctx, path) + default: + return nil, errNoproxy + } + } + + switch proxy { + case "off": + return errRepo{path, errProxyOff}, nil + case "direct": + return lookupDirect(ctx, path) + case "noproxy": + return nil, errUseProxy + default: + return newProxyRepo(proxy, path) + } +} + +type lookupDisabledError struct{} + +func (lookupDisabledError) Error() string { + if cfg.BuildModReason == "" { + return fmt.Sprintf("module lookup disabled by -mod=%s", cfg.BuildMod) + } + return fmt.Sprintf("module lookup disabled by -mod=%s\n\t(%s)", cfg.BuildMod, cfg.BuildModReason) +} + +var errLookupDisabled error = lookupDisabledError{} + +var ( + errProxyOff = notExistErrorf("module lookup disabled by GOPROXY=off") + errNoproxy error = notExistErrorf("disabled by GOPRIVATE/GONOPROXY") + errUseProxy error = notExistErrorf("path does not match GOPRIVATE/GONOPROXY") +) + +func lookupDirect(ctx context.Context, path string) (Repo, error) { + security := web.SecureOnly + + if module.MatchPrefixPatterns(cfg.GOINSECURE, path) { + security = web.Insecure + } + rr, err := vcs.RepoRootForImportPath(path, vcs.PreferMod, security) + if err != nil { + // We don't know where to find code for a module with this path. + return nil, notExistError{err: err} + } + + if rr.VCS.Name == "mod" { + // Fetch module from proxy with base URL rr.Repo. + return newProxyRepo(rr.Repo, path) + } + + code, err := lookupCodeRepo(ctx, rr, false) + if err != nil { + return nil, err + } + return newCodeRepo(code, rr.Root, rr.SubDir, path) +} + +func lookupCodeRepo(ctx context.Context, rr *vcs.RepoRoot, local bool) (codehost.Repo, error) { + code, err := codehost.NewRepo(ctx, rr.VCS.Cmd, rr.Repo, local) + if err != nil { + if _, ok := err.(*codehost.VCSError); ok { + return nil, err + } + return nil, fmt.Errorf("lookup %s: %v", rr.Root, err) + } + return code, nil +} + +// A loggingRepo is a wrapper around an underlying Repo +// that prints a log message at the start and end of each call. +// It can be inserted when debugging. +type loggingRepo struct { + r Repo +} + +func newLoggingRepo(r Repo) *loggingRepo { + return &loggingRepo{r} +} + +// logCall prints a log message using format and args and then +// also returns a function that will print the same message again, +// along with the elapsed time. +// Typical usage is: +// +// defer logCall("hello %s", arg)() +// +// Note the final (). +func logCall(format string, args ...any) func() { + start := time.Now() + fmt.Fprintf(os.Stderr, "+++ %s\n", fmt.Sprintf(format, args...)) + return func() { + fmt.Fprintf(os.Stderr, "%.3fs %s\n", time.Since(start).Seconds(), fmt.Sprintf(format, args...)) + } +} + +func (l *loggingRepo) ModulePath() string { + return l.r.ModulePath() +} + +func (l *loggingRepo) CheckReuse(ctx context.Context, old *codehost.Origin) (err error) { + defer func() { + logCall("CheckReuse[%s]: %v", l.r.ModulePath(), err) + }() + return l.r.CheckReuse(ctx, old) +} + +func (l *loggingRepo) Versions(ctx context.Context, prefix string) (*Versions, error) { + defer logCall("Repo[%s]: Versions(%q)", l.r.ModulePath(), prefix)() + return l.r.Versions(ctx, prefix) +} + +func (l *loggingRepo) Stat(ctx context.Context, rev string) (*RevInfo, error) { + defer logCall("Repo[%s]: Stat(%q)", l.r.ModulePath(), rev)() + return l.r.Stat(ctx, rev) +} + +func (l *loggingRepo) Latest(ctx context.Context) (*RevInfo, error) { + defer logCall("Repo[%s]: Latest()", l.r.ModulePath())() + return l.r.Latest(ctx) +} + +func (l *loggingRepo) GoMod(ctx context.Context, version string) ([]byte, error) { + defer logCall("Repo[%s]: GoMod(%q)", l.r.ModulePath(), version)() + return l.r.GoMod(ctx, version) +} + +func (l *loggingRepo) Zip(ctx context.Context, dst io.Writer, version string) error { + dstName := "_" + if dst, ok := dst.(interface{ Name() string }); ok { + dstName = strconv.Quote(dst.Name()) + } + defer logCall("Repo[%s]: Zip(%s, %q)", l.r.ModulePath(), dstName, version)() + return l.r.Zip(ctx, dst, version) +} + +// errRepo is a Repo that returns the same error for all operations. +// +// It is useful in conjunction with caching, since cache hits will not attempt +// the prohibited operations. +type errRepo struct { + modulePath string + err error +} + +func (r errRepo) ModulePath() string { return r.modulePath } + +func (r errRepo) CheckReuse(ctx context.Context, old *codehost.Origin) error { return r.err } +func (r errRepo) Versions(ctx context.Context, prefix string) (*Versions, error) { return nil, r.err } +func (r errRepo) Stat(ctx context.Context, rev string) (*RevInfo, error) { return nil, r.err } +func (r errRepo) Latest(ctx context.Context) (*RevInfo, error) { return nil, r.err } +func (r errRepo) GoMod(ctx context.Context, version string) ([]byte, error) { return nil, r.err } +func (r errRepo) Zip(ctx context.Context, dst io.Writer, version string) error { return r.err } + +// A notExistError is like fs.ErrNotExist, but with a custom message +type notExistError struct { + err error +} + +func notExistErrorf(format string, args ...any) error { + return notExistError{fmt.Errorf(format, args...)} +} + +func (e notExistError) Error() string { + return e.err.Error() +} + +func (notExistError) Is(target error) bool { + return target == fs.ErrNotExist +} + +func (e notExistError) Unwrap() error { + return e.err +} diff --git a/go/src/cmd/go/internal/modfetch/sumdb.go b/go/src/cmd/go/internal/modfetch/sumdb.go new file mode 100644 index 0000000000000000000000000000000000000000..ea7d561d7b9e0bd76a9808405bacbc2525fa3061 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/sumdb.go @@ -0,0 +1,315 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Go checksum database lookup + +//go:build !cmd_go_bootstrap + +package modfetch + +import ( + "bytes" + "errors" + "fmt" + "io" + "io/fs" + "net/url" + "os" + "path/filepath" + "strings" + "sync" + "time" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/lockedfile" + "cmd/go/internal/web" + + "golang.org/x/mod/module" + "golang.org/x/mod/sumdb" + "golang.org/x/mod/sumdb/note" +) + +// useSumDB reports whether to use the Go checksum database for the given module. +func useSumDB(mod module.Version) bool { + if mod.Path == "golang.org/toolchain" { + must := true + // Downloaded toolchains cannot be listed in go.sum, + // so we require checksum database lookups even if + // GOSUMDB=off or GONOSUMDB matches the pattern. + // If GOSUMDB=off, then the eventual lookup will fail + // with a good error message. + + // Exception #1: using GOPROXY=file:// to test a distpack. + if strings.HasPrefix(cfg.GOPROXY, "file://") && !strings.ContainsAny(cfg.GOPROXY, ",|") { + must = false + } + // Exception #2: the Go proxy+checksum database cannot check itself + // while doing the initial download. + if strings.Contains(os.Getenv("GIT_HTTP_USER_AGENT"), "proxy.golang.org") { + must = false + } + + // Another potential exception would be GOPROXY=direct, + // but that would make toolchain downloads only as secure + // as HTTPS, and in particular they'd be susceptible to MITM + // attacks on systems with less-than-trustworthy root certificates. + // The checksum database provides a stronger guarantee, + // so we don't make that exception. + + // Otherwise, require the checksum database. + if must { + return true + } + } + return cfg.GOSUMDB != "off" && !module.MatchPrefixPatterns(cfg.GONOSUMDB, mod.Path) +} + +// lookupSumDB returns the Go checksum database's go.sum lines for the given module, +// along with the name of the database. +func lookupSumDB(mod module.Version) (dbname string, lines []string, err error) { + dbOnce.Do(func() { + dbName, db, dbErr = dbDial() + }) + if dbErr != nil { + return "", nil, dbErr + } + lines, err = db.Lookup(mod.Path, mod.Version) + return dbName, lines, err +} + +var ( + dbOnce sync.Once + dbName string + db *sumdb.Client + dbErr error +) + +func dbDial() (dbName string, db *sumdb.Client, err error) { + // $GOSUMDB can be "key" or "key url", + // and the key can be a full verifier key + // or a host on our list of known keys. + + // Special case: sum.golang.google.cn + // is an alias, reachable inside mainland China, + // for sum.golang.org. If there are more + // of these we should add a map like knownGOSUMDB. + gosumdb := cfg.GOSUMDB + if gosumdb == "sum.golang.google.cn" { + gosumdb = "sum.golang.org https://sum.golang.google.cn" + } + + if gosumdb == "off" { + return "", nil, fmt.Errorf("checksum database disabled by GOSUMDB=off") + } + + key := strings.Fields(gosumdb) + if len(key) >= 1 { + if k := knownGOSUMDB[key[0]]; k != "" { + key[0] = k + } + } + if len(key) == 0 { + return "", nil, fmt.Errorf("missing GOSUMDB") + } + if len(key) > 2 { + return "", nil, fmt.Errorf("invalid GOSUMDB: too many fields") + } + vkey, err := note.NewVerifier(key[0]) + if err != nil { + return "", nil, fmt.Errorf("invalid GOSUMDB: %v", err) + } + name := vkey.Name() + + // No funny business in the database name. + direct, err := url.Parse("https://" + name) + if err != nil || strings.HasSuffix(name, "/") || *direct != (url.URL{Scheme: "https", Host: direct.Host, Path: direct.Path, RawPath: direct.RawPath}) || direct.RawPath != "" || direct.Host == "" { + return "", nil, fmt.Errorf("invalid sumdb name (must be host[/path]): %s %+v", name, *direct) + } + + // Determine how to get to database. + var base *url.URL + if len(key) >= 2 { + // Use explicit alternate URL listed in $GOSUMDB, + // bypassing both the default URL derivation and any proxies. + u, err := url.Parse(key[1]) + if err != nil { + return "", nil, fmt.Errorf("invalid GOSUMDB URL: %v", err) + } + base = u + } + + return name, sumdb.NewClient(&dbClient{key: key[0], name: name, direct: direct, base: base}), nil +} + +type dbClient struct { + key string + name string + direct *url.URL + + once sync.Once + base *url.URL + baseErr error +} + +func (c *dbClient) ReadRemote(path string) ([]byte, error) { + c.once.Do(c.initBase) + if c.baseErr != nil { + return nil, c.baseErr + } + + var data []byte + start := time.Now() + targ := web.Join(c.base, path) + data, err := web.GetBytes(targ) + if false { + fmt.Fprintf(os.Stderr, "%.3fs %s\n", time.Since(start).Seconds(), targ.Redacted()) + } + return data, err +} + +// initBase determines the base URL for connecting to the database. +// Determining the URL requires sending network traffic to proxies, +// so this work is delayed until we need to download something from +// the database. If everything we need is in the local cache and +// c.ReadRemote is never called, we will never do this work. +func (c *dbClient) initBase() { + if c.base != nil { + return + } + + // Try proxies in turn until we find out how to connect to this database. + // + // Before accessing any checksum database URL using a proxy, the proxy + // client should first fetch /sumdb//supported. + // + // If that request returns a successful (HTTP 200) response, then the proxy + // supports proxying checksum database requests. In that case, the client + // should use the proxied access method only, never falling back to a direct + // connection to the database. + // + // If the /sumdb//supported check fails with a “not found” (HTTP + // 404) or “gone” (HTTP 410) response, or if the proxy is configured to fall + // back on errors, the client will try the next proxy. If there are no + // proxies left or if the proxy is "direct" or "off", the client should + // connect directly to that database. + // + // Any other response is treated as the database being unavailable. + // + // See https://golang.org/design/25530-sumdb#proxying-a-checksum-database. + err := TryProxies(func(proxy string) error { + switch proxy { + case "noproxy": + return errUseProxy + case "direct", "off": + return errProxyOff + default: + proxyURL, err := url.Parse(proxy) + if err != nil { + return err + } + if _, err := web.GetBytes(web.Join(proxyURL, "sumdb/"+c.name+"/supported")); err != nil { + return err + } + // Success! This proxy will help us. + c.base = web.Join(proxyURL, "sumdb/"+c.name) + return nil + } + }) + if errors.Is(err, fs.ErrNotExist) { + // No proxies, or all proxies failed (with 404, 410, or were allowed + // to fall back), or we reached an explicit "direct" or "off". + c.base = c.direct + } else if err != nil { + c.baseErr = err + } +} + +// ReadConfig reads the key from c.key +// and otherwise reads the config (a latest tree head) from GOPATH/pkg/sumdb/. +func (c *dbClient) ReadConfig(file string) (data []byte, err error) { + if file == "key" { + return []byte(c.key), nil + } + + if cfg.SumdbDir == "" { + return nil, fmt.Errorf("could not locate sumdb file: missing $GOPATH: %s", + cfg.GoPathError) + } + targ := filepath.Join(cfg.SumdbDir, file) + data, err = lockedfile.Read(targ) + if errors.Is(err, fs.ErrNotExist) { + // Treat non-existent as empty, to bootstrap the "latest" file + // the first time we connect to a given database. + return []byte{}, nil + } + return data, err +} + +// WriteConfig rewrites the latest tree head. +func (*dbClient) WriteConfig(file string, old, new []byte) error { + if file == "key" { + // Should not happen. + return fmt.Errorf("cannot write key") + } + if cfg.SumdbDir == "" { + return fmt.Errorf("could not locate sumdb file: missing $GOPATH: %s", + cfg.GoPathError) + } + targ := filepath.Join(cfg.SumdbDir, file) + os.MkdirAll(filepath.Dir(targ), 0777) + f, err := lockedfile.Edit(targ) + if err != nil { + return err + } + defer f.Close() + data, err := io.ReadAll(f) + if err != nil { + return err + } + if len(data) > 0 && !bytes.Equal(data, old) { + return sumdb.ErrWriteConflict + } + if _, err := f.Seek(0, 0); err != nil { + return err + } + if err := f.Truncate(0); err != nil { + return err + } + if _, err := f.Write(new); err != nil { + return err + } + return f.Close() +} + +// ReadCache reads cached lookups or tiles from +// GOPATH/pkg/mod/cache/download/sumdb, +// which will be deleted by "go clean -modcache". +func (*dbClient) ReadCache(file string) ([]byte, error) { + targ := filepath.Join(cfg.GOMODCACHE, "cache/download/sumdb", file) + data, err := lockedfile.Read(targ) + // lockedfile.Write does not atomically create the file with contents. + // There is a moment between file creation and locking the file for writing, + // during which the empty file can be locked for reading. + // Treat observing an empty file as file not found. + if err == nil && len(data) == 0 { + err = &fs.PathError{Op: "read", Path: targ, Err: fs.ErrNotExist} + } + return data, err +} + +// WriteCache updates cached lookups or tiles. +func (*dbClient) WriteCache(file string, data []byte) { + targ := filepath.Join(cfg.GOMODCACHE, "cache/download/sumdb", file) + os.MkdirAll(filepath.Dir(targ), 0777) + lockedfile.Write(targ, bytes.NewReader(data), 0666) +} + +func (*dbClient) Log(msg string) { + // nothing for now +} + +func (*dbClient) SecurityError(msg string) { + base.Fatalf("%s", msg) +} diff --git a/go/src/cmd/go/internal/modfetch/toolchain.go b/go/src/cmd/go/internal/modfetch/toolchain.go new file mode 100644 index 0000000000000000000000000000000000000000..0d7cfcfe7d10734caa8c4616cf7492b13b21a855 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/toolchain.go @@ -0,0 +1,181 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modfetch + +import ( + "context" + "fmt" + "io" + "sort" + "strings" + + "cmd/go/internal/gover" + "cmd/go/internal/modfetch/codehost" +) + +// A toolchainRepo is a synthesized repository reporting Go toolchain versions. +// It has path "go" or "toolchain". The "go" repo reports versions like "1.2". +// The "toolchain" repo reports versions like "go1.2". +// +// Note that the repo ONLY reports versions. It does not actually support +// downloading of the actual toolchains. Instead, that is done using +// the regular repo code with "golang.org/toolchain". +// The naming conflict is unfortunate: "golang.org/toolchain" +// should perhaps have been "go.dev/dl", but it's too late. +// +// For clarity, this file refers to golang.org/toolchain as the "DL" repo, +// the one you can actually download. +type toolchainRepo struct { + path string // either "go" or "toolchain" + repo Repo // underlying DL repo +} + +func (r *toolchainRepo) ModulePath() string { + return r.path +} + +func (r *toolchainRepo) Versions(ctx context.Context, prefix string) (*Versions, error) { + // Read DL repo list and convert to "go" or "toolchain" version list. + versions, err := r.repo.Versions(ctx, "") + if err != nil { + return nil, err + } + versions.Origin = nil + var list []string + have := make(map[string]bool) + goPrefix := "" + if r.path == "toolchain" { + goPrefix = "go" + } + for _, v := range versions.List { + v, ok := dlToGo(v) + if !ok { + continue + } + if !have[v] { + have[v] = true + list = append(list, goPrefix+v) + } + } + + // Always include our own version. + // This means that the development branch of Go 1.21 (say) will allow 'go get go@1.21' + // even though there are no Go 1.21 releases yet. + // Once there is a release, 1.21 will be treated as a query matching the latest available release. + // Before then, 1.21 will be treated as a query that resolves to this entry we are adding (1.21). + if v := gover.Local(); !have[v] { + list = append(list, goPrefix+v) + } + + if r.path == "go" { + sort.Slice(list, func(i, j int) bool { + return gover.Compare(list[i], list[j]) < 0 + }) + } else { + sort.Slice(list, func(i, j int) bool { + return gover.Compare(gover.FromToolchain(list[i]), gover.FromToolchain(list[j])) < 0 + }) + } + versions.List = list + return versions, nil +} + +func (r *toolchainRepo) Stat(ctx context.Context, rev string) (*RevInfo, error) { + // Convert rev to DL version and stat that to make sure it exists. + // In theory the go@ versions should be like 1.21.0 + // and the toolchain@ versions should be like go1.21.0 + // but people will type the wrong one, and so we accept + // both and silently correct it to the standard form. + prefix := "" + v := rev + v = strings.TrimPrefix(v, "go") + if r.path == "toolchain" { + prefix = "go" + } + + if !gover.IsValid(v) { + return nil, fmt.Errorf("invalid %s version %s", r.path, rev) + } + + // If we're asking about "go" (not "toolchain"), pretend to have + // all earlier Go versions available without network access: + // we will provide those ourselves, at least in GOTOOLCHAIN=auto mode. + if r.path == "go" && gover.Compare(v, gover.Local()) <= 0 { + return &RevInfo{Version: prefix + v}, nil + } + + // Similarly, if we're asking about *exactly* the current toolchain, + // we don't need to access the network to know that it exists. + if r.path == "toolchain" && v == gover.Local() { + return &RevInfo{Version: prefix + v}, nil + } + + if gover.IsLang(v) { + // We can only use a language (development) version if the current toolchain + // implements that version, and the two checks above have ruled that out. + return nil, fmt.Errorf("go language version %s is not a toolchain version", rev) + } + + // Check that the underlying toolchain exists. + // We always ask about linux-amd64 because that one + // has always existed and is likely to always exist in the future. + // This avoids different behavior validating go versions on different + // architectures. The eventual download uses the right GOOS-GOARCH. + info, err := r.repo.Stat(ctx, goToDL(v, "linux", "amd64")) + if err != nil { + return nil, err + } + + // Return the info using the canonicalized rev + // (toolchain 1.2 => toolchain go1.2). + return &RevInfo{Version: prefix + v, Time: info.Time}, nil +} + +func (r *toolchainRepo) Latest(ctx context.Context) (*RevInfo, error) { + versions, err := r.Versions(ctx, "") + if err != nil { + return nil, err + } + var max string + for _, v := range versions.List { + if max == "" || gover.ModCompare(r.path, v, max) > 0 { + max = v + } + } + return r.Stat(ctx, max) +} + +func (r *toolchainRepo) GoMod(ctx context.Context, version string) (data []byte, err error) { + return []byte("module " + r.path + "\n"), nil +} + +func (r *toolchainRepo) Zip(ctx context.Context, dst io.Writer, version string) error { + return fmt.Errorf("invalid use of toolchainRepo: Zip") +} + +func (r *toolchainRepo) CheckReuse(ctx context.Context, old *codehost.Origin) error { + return fmt.Errorf("invalid use of toolchainRepo: CheckReuse") +} + +// goToDL converts a Go version like "1.2" to a DL module version like "v0.0.1-go1.2.linux-amd64". +func goToDL(v, goos, goarch string) string { + return "v0.0.1-go" + v + ".linux-amd64" +} + +// dlToGo converts a DL module version like "v0.0.1-go1.2.linux-amd64" to a Go version like "1.2". +func dlToGo(v string) (string, bool) { + // v0.0.1-go1.19.7.windows-amd64 + // cut v0.0.1- + _, v, ok := strings.Cut(v, "-") + if !ok { + return "", false + } + // cut .windows-amd64 + i := strings.LastIndex(v, ".") + if i < 0 || !strings.Contains(v[i+1:], "-") { + return "", false + } + return strings.TrimPrefix(v[:i], "go"), true +} diff --git a/go/src/cmd/go/internal/modfetch/zip_sum_test/testdata/zip_sums.csv b/go/src/cmd/go/internal/modfetch/zip_sum_test/testdata/zip_sums.csv new file mode 100644 index 0000000000000000000000000000000000000000..0906975f5537e632815a18f1a217a9ebdf1ed591 --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/zip_sum_test/testdata/zip_sums.csv @@ -0,0 +1,2119 @@ +9fans.net/go,v0.0.2,h1:RYM6lWITV8oADrwLfdzxmt8ucfW6UtP9v1jg4qAbqts=,2c42aad9ed60e24046fbf5720f438884942897197cb790ce58cccdacedd9532d +aahframe.work,v0.12.3,h1:hc3chv+f49yLYVT/aSEhgpoqd8bS0rDKEew1un8AkSo=,0c7e3fab03920a79ace8e0a9ddf4517225f595ce39f2124ec3d9353508da5dbd +aahframework.org/essentials.v0,v0.8.0,h1:R/lcfOuhvZptG4IWX/CzAtpiVJFUjbCxLao6DfmeWBA=,d640fe6b83a31ffe09d12eea37de000be7ec8d7330c0a1d7413d6e31a675628d +bazil.org/fuse,v0.0.0-20180421153158-65cc252bf669,h1:FNCRpXiquG1aoyqcIWVFmpTSKVcx2bQD38uZZeGtdlw=,fce7ed008451861ba30974e95468d716f5ff4fde14e9605dbc2db5fac935c71d +bitbucket.org/abex/go-optional,v0.0.0-20150902044611-5304370459de,h1:iGmurCCO42qFsQ46DzROSsZJFf8/7AKFH/VpRGd2PBw=,02e1b23db09fb6945ba4ca57c0af8125b608fceae125fe625f6536b9e466e7e0 +bitbucket.org/abex/pathfinder,v0.0.0-20170507112819-bdce8b2efbc9,h1:M1jjfmrcOcmWy2/aABpm3k9h/M6NccmjgLtE5gVl+y8=,8469c0a656a895863d4714a658ee4a9634e78547142fa7239331e15d0143c679 +bitbucket.org/abex/sliceconv,v0.0.0-20151017061159-594a23261816,h1:7XPf5/Oar0LfWbnUY29doBDzSr6ToseiJRqkZtb0YOo=,e2433a32246bd5e2fb5d52bf6dc36188a75c4b59b98f76eb7607035b8525dd37 +bitbucket.org/abex/yumeko,v0.0.0-20190825151534-d98ca20ac08c,h1:ES4kIm83Q1RYr9uhhpQhqh/tqjt8H+Xz4xuSAv5Crcw=,1d352a11b3ed5850a425fde048cafa65b2c079c4e9647c52a339b28276065ba9 +bitbucket.org/liamstask/goose,v0.0.0-20150115234039-8488cc47d90c,h1:bkb2NMGo3/Du52wvYj9Whth5KZfMV6d3O0Vbr3nz/UE=,3d64cac7774bf87a9d050222b87387c112bcb6ef0ea0e2b3324a95330573a0c5 +bitbucket.org/ww/goautoneg,v0.0.0-20120707110453-75cd24fc2f2c,h1:t+Ra932MCC0eeyD/vigXqMbZTzgZjd4JOfBJWC6VSMI=,8ad2afdee1dc46b2c78e986bc2cce89cd0b8815b278a01879ef08d56585c247f +bou.ke/monkey,v1.0.1,h1:zEMLInw9xvNakzUUPjfS4Ds6jYPqCFx3m7bRmG5NH2U=,20cb7da509322267189d32a125d7e0f782264508bc8e17306c80424514e797ce +cloud.google.com/go,v0.47.0,h1:1JUtpcY9E7+eTospEwWS2QXP3DEn7poB3E2j0jN74mM=,7739fd24e36a536488115ef0ec9d739e608ee68448f8a469e84855c008b00ecd +cloud.google.com/go/bigquery,v1.0.1,h1:hL+ycaJpVE9M7nLoiXb/Pn10ENE2u+oddxbD8uu0ZVU=,738d1f726ce24f618ee7563f6c9419e6307f8814548f45ad8a227cffbb1448c0 +cloud.google.com/go/datastore,v1.0.0,h1:Kt+gOPPp2LEPWp8CSfxhsM8ik9CcyE/gYu+0r+RnZvM=,41e93ec9526ae580da90300d7e421a6d39d79cb6118d62ad1d3c06422d8a71bf +cloud.google.com/go/pubsub,v1.0.1,h1:W9tAK3E57P75u0XLLR82LZyw8VpAnhmyTOxW9qzmyj8=,8bca46a7c5f0dcd576d23fa9a5f107955316d6f0d8f306ee1d6faa7de99c3d29 +cloud.google.com/go/spanner,v1.0.0,h1:jLKThep5kbWLeBhLgtEfm/OPT08n1z7itVTR82WUBQg=,90579f16545e352c662ae9f62dd02dddf834fe10b33d1dbcfbf0a8aadfcd21f8 +cloud.google.com/go/storage,v1.0.0,h1:VV2nUM3wwLLGh9lSABFgZMjInyUbJeaRSE64WuAIQ+4=,baec4756c573ede58f19eb7ae4acaebd7ac3f0c56413ecbbd216ad46a589a5da +code.cloudfoundry.org/clock,v0.0.0-20180518195852-02e53af36e6c,h1:5eeuG0BHx1+DHeT3AP+ISKZ2ht1UjGhm581ljqYpVeQ=,61785787db7dadaf695506636dcb98c26bbdd0c847f589aa1fb4bbe9ef0e4455 +code.cloudfoundry.org/gofileutils,v0.0.0-20170111115228-4d0c80011a0f,h1:UrKzEwTgeiff9vxdrfdqxibzpWjxLnuXDI5m6z3GJAk=,ec71ca818158525773e53568f71db38f63423822a426e1a18f7d34318e97eb3e +code.cloudfoundry.org/lager,v2.0.0+incompatible,h1:WZwDKDB2PLd/oL+USK4b4aEjUymIej9My2nUQ9oWEwQ=,ce1da175885c2587ca091532a937108ed646e3bd6bd902640891f75ae70adb8b +code.gitea.io/gitea,v1.9.5,h1:Q3PROlfPth1NlLGaeYcr6YVqyfAy7txnFpDKe1BXo7Q=,c7b63394004fb8f355d859f11a007ff17126eac092f90507a80392335351a6df +code.gitea.io/sdk,v0.0.0-20191030144301-2a5a0e75e5cf,h1:uXUz7lXbs33QAYIu1rF0o8tNsa3DlDDSMYek/3CldIo=,6472a2b30b8108cae9b6a4914ce986d61e9ed37baade5ad35cb337270602b70a +code.gitea.io/sdk/gitea,v0.0.0-20191030144301-2a5a0e75e5cf,h1:aAwV+RyellgKMACMu21Vyv/XgSHipLvbJsXDoXP1Yv0=,62570a621e1bf13724fb1f45d7ea95c48de02abb00468cf1da4b35820203d3b4 +contrib.go.opencensus.io/exporter/aws,v0.0.0-20181029163544-2befc13012d0,h1:YsbWYxDZkC7x2OxlsDEYvvEXZ3cBI3qBgUK5BqkZvRw=,3e351a39c3caf9ce263155f2d6e5a4e0cd84177661e1bf40f0d8fd06854831e9 +contrib.go.opencensus.io/exporter/ocagent,v0.6.0,h1:Z1n6UAyr0QwM284yUuh5Zd8JlvxUGAhFZcgMJkMPrGM=,e526ae16b06c682c3661738938f912a2e301a5e2d0ba875c7a0ec40fde825491 +contrib.go.opencensus.io/exporter/stackdriver,v0.12.8,h1:iXI5hr7pUwMx0IwMphpKz5Q3If/G5JiWFVZ5MPPxP9E=,db745d331f8a0455abbbcfeb4bb33dbc5cbb73a119b4e86f833cd497cfc72559 +contrib.go.opencensus.io/integrations/ocsql,v0.1.4,h1:kfg5Yyy1nYUrqzyfW5XX+dzMASky8IJXhtHe0KTYNS4=,0a4be97a579c5212bd83d21a177b279bc5b0c04350a63c56e8f8e611ffcba09c +contrib.go.opencensus.io/resource,v0.1.1,h1:4r2CANuYhKGmYWP02+5E94rLRcS/YeD+KlxSrOsMxk0=,07ad3d36f96cb86ecba376353d02730855e117db3ffac5c2ab2c7cdf4eca25dc +cuelang.org/go,v0.0.11,h1:t7s006dOWh6tgnwPifvO3l704eg8oPuIH7AR1hfTFYk=,69bdc6b3f1000308d399f166dd0d46576019f68cbf37765bd30821584b1296de +dmitri.shuralyov.com/app/changes,v0.0.0-20180602232624-0a106ad413e3,h1:hJiie5Bf3QucGRa4ymsAUOxyhYwGEz1xrsVk0P8erlw=,a4d9079d5550094191f608c628ff2eb6999e0d0b6aea894ba59d063107777dfa +dmitri.shuralyov.com/gpu/mtl,v0.0.0-20190408044501-666a987793e9,h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY=,ca5330901fcda83d09553ac362576d196c531157bc9c502e76b237cca262b400 +dmitri.shuralyov.com/html/belt,v0.0.0-20180602232347-f7d459c86be0,h1:SPOUaucgtVls75mg+X7CXigS71EnsfVUK/2CgVrwqgw=,bd6b059cceaea8ab23e65b8118fab5d22f82149417fcc5fcf930ef9a52d582f1 +dmitri.shuralyov.com/service/change,v0.0.0-20181023043359-a85b471d5412,h1:GvWw74lx5noHocd+f6HBMXK6DuggBB1dhVkuGZbv7qM=,8a1ba9c7ba7eea08389c15315a23485d19fc7166d30b5b47a35fab949c4bf886 +dmitri.shuralyov.com/state,v0.0.0-20190403024436-2cf192113e66,h1:/74W9PTF+vJhgRsWpPWlZT77+phX7vXPcelX7JXFu5s=,eda200c06f669f06c56e1d53a1879b88dd7ee99eea1f56d329028fa773cfc2dd +docker.io/go-docker,v1.0.0,h1:VdXS/aNYQxyA9wdLD5z8Q8Ro688/hG8HzKxYVEVbE6s=,b162036b1af6e1e5434e2e5a35faa7191014529259fbf2f4f1b3e7de6b816516 +fyne.io/fyne,v1.1.2,h1:a9YLFXxqN7lKNqTrk+ocw3/3ROrn6aFiofix8ATVOBc=,dc2d7fd4a4ee9852328fc79c52459a53d94d26f6ac3282ebcacc0c6cd6688d23 +git.apache.org/thrift.git,v0.13.0,h1:/3bz5WZ+sqYArk7MBBBbDufMxKKOA56/6JO6psDpUDY=,10412b7bc503ef2a7cc3bf58fe69e5a2d2594354ae3cc5ab2baa2b3ecc8c4f1d +git.fd.io/govpp.git,v0.1.0,h1:fV5H9ghURFfmNAjk7Scb/aG3OGwevLayHfSdS8GsYjE=,0a023d4b5b36131a4fde2c3d19047bbd4f5c3a7cc07c1ccf40bfb75a501f51b3 +git.torproject.org/pluggable-transports/goptlib.git,v1.1.0,h1:LMQAA8pAho+QtYrrVNimJQiINNEwcwuuD99vezD/PAo=,f6769c4813dedf933071289bfd9381aa5eb3a012b3a32d1da02aa9bebd3a3b5b +gitee.com/nggs/util,v0.0.0-20190830024003-3e49d2efc84b,h1:6KQpPEs326uPrICQy9x/PxmR8U0v/XsFzpt0k1nFKcY=,a062c99c2b560a36168fe51eab8f17f4fadf5d534238881628e83d8d61e51c2a +github.com/1and1/oneandone-cloudserver-sdk-go,v1.0.1,h1:RMTyvS5bjvSWiUcfqfr/E2pxHEMrALvU+E12n6biymg=,7f068808fc0857d7de8c8f829cc380dce1c6611a3fc819daf4421e9bcb75a07c +github.com/99designs/gqlgen,v0.10.1,h1:1BgB6XKGTHq7uH4G1/PYyKe2Kz7/vw3AlvMZlD3TEEY=,04b9e7d8a3df6543cd870325b1140ce9ac3f4bbfd8c90ebecec4f908dd420d08 +github.com/AndreasBriese/bbloom,v0.0.0-20190306092124-e2d15f34fcf9,h1:HD8gA2tkByhMAwYaFAX9w2l7vxvBQ5NMoxDrkhqhtn4=,6d7c1af06f8597fde1e86166f26416057392f1b0bdb84f2af555aa461282dd18 +github.com/AsynkronIT/goconsole,v0.0.0-20160504192649-bfa12eebf716,h1:Pk/Kzi5O0T4QxfqvbaUsh8UklbJ9BklZ/ClZBptX5WU=,5a2507b89bb4436881718d785a0ef383652aa99782508b7444cf20255082dab9 +github.com/Azure/azure-amqp-common-go,v1.1.4,h1:DmPXxmLZwi/71CgRTZIKR6yiKEW3eC42S4gSBhfG7y0=,4b800793ff4fefa86a427c445e3a4671b8d1dcd87a44075f6309cace6b0e01e2 +github.com/Azure/azure-amqp-common-go/v2,v2.1.0,h1:+QbFgmWCnPzdaRMfsI0Yb6GrRdBj5jVL8N3EXuEUcBQ=,9a91c6ac9656faea0ddfb0bb497c109451faaba09b85ce3237309f5982b095a3 +github.com/Azure/azure-pipeline-go,v0.2.2,h1:6oiIS9yaG6XCCzhgAgKFfIWyo4LLCiDhZot6ltoThhY=,3e4f90f6ec86d4875e8758f01947adece11c1b4317b448fe0197188765c83efc +github.com/Azure/azure-sdk-for-go,v36.0.0+incompatible,h1:XIaBmA4pgKqQ7jInQPaNJQ4pOHrdJjw9gYXhbyiChaU=,71db17c798b784b96a45efdbabd18ad86d03e5f490701081a2f7bf19efa67c13 +github.com/Azure/azure-service-bus-go,v0.9.1,h1:G1qBLQvHCFDv9pcpgwgFkspzvnGknJRR0PYJ9ytY/JA=,81e42ed51354d71b53daf93b5b9f0f2c20fb7d2923f45ab88eea22419bfbc63a +github.com/Azure/azure-storage-blob-go,v0.8.0,h1:53qhf0Oxa0nOjgbDeeYPUeyiNmafAFEY95rZLK0Tj6o=,3b02b720c25bbb6cdaf77f45a29a21e374e087081dedfeac2700aed6147b4b35 +github.com/Azure/go-ansiterm,v0.0.0-20170929234023-d6e3b3328b78,h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=,b7a14d18891abef8b8a2e622f62a3cebeac32f9f1223dc9d62a6f8769861aaf2 +github.com/Azure/go-autorest,v13.3.0+incompatible,h1:8Ix0VdeOllBx9jEcZ2Wb1uqWUpE1awmJiaHztwaJCPk=,44fdf420bd96bb97df7910806efb25f2fae701078c39f5592f5c4131ffce41e6 +github.com/Azure/go-autorest/autorest,v0.9.2,h1:6AWuh3uWrsZJcNoCHrCF/+g4aKPCU39kaMO6/qrnK/4=,26df5fc6c03e8c66021dd272b04242f6c2ce2a5975f87799dfcf1b9597800dba +github.com/Azure/go-autorest/autorest/adal,v0.8.0,h1:CxTzQrySOxDnKpLjFJeZAS5Qrv/qFPkgLjx5bOAi//I=,af59c00ec7e19cda9b960babaee7bfe27cf3d5f7415ac3afdb4cddc73d4b5743 +github.com/Azure/go-autorest/autorest/azure/auth,v0.4.0,h1:18ld/uw9Rr7VkNie7a7RMAcFIWrJdlUL59TWGfcu530=,2fe394de946f42c2ea8ad07f1b282eac6bb56e372f5c2a35e49dfef0cf015ccb +github.com/Azure/go-autorest/autorest/azure/cli,v0.3.0,h1:5PAqnv+CSTwW9mlZWZAizmzrazFWEgZykEZXpr2hDtY=,729d09b69a1912faa7c2395389bbf67ec22a420d42c15414823d43a380a2f09a +github.com/Azure/go-autorest/autorest/date,v0.2.0,h1:yW+Zlqf26583pE43KhfnhFcdmSWlm5Ew6bxipnr/tbM=,9ec7b48c865a185b72d3822ac2dff7e0163315a23911c87a479a3db616af9853 +github.com/Azure/go-autorest/autorest/mocks,v0.3.0,h1:qJumjCaCudz+OcqE9/XtEPfvtOjOmKaui4EOpFI6zZc=,d5daf74cf531c37b27b39d3bf65b6930aee4b226b5fb4ea91a87be93aaf37f10 +github.com/Azure/go-autorest/autorest/to,v0.3.0,h1:zebkZaadz7+wIQYgC7GXaz3Wb28yKYfVkkBKwc38VF8=,955ee6bde8af1314d22b51f265799147f42f7c705714b1cc1c51144441d5fa9c +github.com/Azure/go-autorest/autorest/validation,v0.2.0,h1:15vMO4y76dehZSq7pAaOLQxC6dZYsSrj2GQpflyM/L4=,10f40b0d943d4d1a0a1cbcb9fdb058b8a3a59a55ae26583566dfaa82883f86ea +github.com/Azure/go-autorest/logger,v0.1.0,h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY=,5e0804944db0707502c9d29defb54961c281a19311c9eb321a246ba054ac5256 +github.com/Azure/go-autorest/tracing,v0.5.0,h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k=,4951b0f4a88a44b7ed4e4834654e4e01922ade35d97899b8596998184abbc652 +github.com/Azure/go-ntlmssp,v0.0.0-20180810175552-4a21cbd618b4,h1:pSm8mp0T2OH2CPmPDPtwHPr3VAQaOwVF/JbllOPP4xA=,64cd585589154ce18d7557ccfd8d26e2c2f5c4ecf13b17bdbfb913e17863d280 +github.com/BurntSushi/locker,v0.0.0-20171006230638-a6e239ea1c69,h1:+tu3HOoMXB7RXEINRVIpxJCT+KdYiI7LAEAUrOw3dIU=,836038343df9e9126b59d54201951191898bd875ec32d93c2018d759f358fcfb +github.com/BurntSushi/toml,v0.3.1,h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=,815c6e594745f2d8842ff9a4b0569c6695e6cdfd5e07e5b3d98d06b72ca41e3c +github.com/BurntSushi/xgb,v0.0.0-20160522181843-27f122750802,h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=,f52962c7fbeca81ea8a777d1f8b1f1d25803dc437fbb490f253344232884328e +github.com/BurntSushi/xgbutil,v0.0.0-20190907113008-ad855c713046,h1:O/r2Sj+8QcMF7V5IcmiE2sMFV2q3J47BEirxbXJAdzA=,492ce6b11d7faaec4e15d1279d81e28d2e0e9844ad117f9de9411286a5b0e305 +github.com/ChrisTrenkamp/goxpath,v0.0.0-20170922090931-c385f95c6022,h1:y8Gs8CzNfDF5AZvjr+5UyGQvQEBL7pwo+v+wX6q9JI8=,8d79cd78a309a1b0f22790d354b9c4c929c64d03c7e572627ba430908fbb9d78 +github.com/CodisLabs/codis,v0.0.0-20181104082235-de1ad026e329,h1:KyRmPlfd2xewxb54vIBPNILFyCh2R3zNDwLZURDxT0E=,f61ae85688d10dddf0d62c30aaaa2701373fc11851dae4435de0212513c578c1 +github.com/DATA-DOG/go-sqlmock,v1.3.3,h1:CWUqKXe0s8A2z6qCgkP4Kru7wC11YoAnoupUKFDnH08=,5dc430c2836af3bfc85f590366a6e284a251978e9397d0d54fa97db913263461 +github.com/DataDog/datadog-go,v3.2.0+incompatible,h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4=,ede4a024d3c106b2f57ca04d7bfc7610e0c83f4d8a3bace2cf87b42fd5cf66cd +github.com/DataDog/zstd,v1.4.0,h1:vhoV+DUHnRZdKW1i5UMjAk2G4JY8wN4ayRfYDNdEhwo=,601f6fe1f4138d676946f4b27f7a714bbedea8c1785d10c1b74a03c68ad13070 +github.com/FiloSottile/b2,v0.0.0-20170207175032-b197f7a2c317,h1:1GuMjC4tjfwnWBdoTS7YqtQ3JIsEft6NRcdmXdzvYYc=,6ff3cfed3f510fc69b47f263936642950afc7892f557ed716dd8c5584f187411 +github.com/GeertJohan/go-sourcepath,v0.0.0-20150925135350-83e8b8723a9b,h1:D4H5C4VvURnduTQydyEhA6OWnNcZTLUlNX4YBw5yelY=,8bdcf0b6cc58f5ec1cef031b4052e6d699683bf1daf4a1a20f92f67d5be06b82 +github.com/GeertJohan/go.incremental,v1.0.0,h1:7AH+pY1XUgQE4Y1HcXYaMqAI0m9yrFqo/jt0CW30vsg=,ce46b3b717f8d2927046bcfb99c6f490b1b547a681e6b23240ac2c2292a891e8 +github.com/GeertJohan/go.rice,v1.0.0,h1:KkI6O9uMaQU3VEKaj01ulavtF7o1fWT7+pk/4voiMLQ=,2fc48b9422bf356c18ed3fe32ec52f6a8b87ac168f83d2eed249afaebcc3eeb8 +github.com/GoogleCloudPlatform/cloudsql-proxy,v0.0.0-20191017031552-46c5533ff5ba,h1:ZNYxMf89tMi+NydPAq7yGAxMfMNaMHgG+7WL1CEabjc=,25a1fe9f189e6a4d6e108f22abaec7dd36edc819ab5af1a3e448450b73026271 +github.com/GoogleCloudPlatform/docker-credential-gcr,v1.5.0,h1:wykTgKwhVr2t2qs+xI020s6W5dt614QqCHV+7W9dg64=,4acfcaddfe2aa53e1e643ea13ff3534a2fca1e043d008ab5bba5a0910db1f7c2 +github.com/IBM/go-sdk-core,v1.0.1,h1:vF9Lsoih6fxrAxzJp2fWqnO6Mg8x8O8fzwQAdFoUdok=,e063c8f79f94936a165355f61bdc6f2c404975472ad6be5e47bfdb87fb393c72 +github.com/Jeffail/gabs,v1.4.0,h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo=,cb193b1477109c19b0d2521fc61735619202e58ac4699605f72313d70884ca9e +github.com/Joker/hpp,v0.0.0-20180418125244-6893e659854a,h1:PiDAizhfJbwZMISZ1Itx1ZTFeOFCml89Ofmz3V8rhoU=,4e99372a7576c587c107fb16d1ae0e8662111e2ca5e5127f7cd93bb01cd02076 +github.com/Joker/jade,v1.0.0,h1:lOCEPvTAtWfLpSZYMOv/g44MGQFAolbKh2khHHGu0Kc=,c4a7f39e7483446ff7b0d7e213a4cd813c783108d6d2e7c6e9a8e968789b18bc +github.com/Knetic/govaluate,v3.0.1-0.20171022003610-9aa49832a739+incompatible,h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw=,d1d4ac5b4f5759726368f68b0d47f3c17c6d8689243ec66272311359d28a865b +github.com/Kodeworks/golang-image-ico,v0.0.0-20141118225523-73f0f4cfade9,h1:1ltqoej5GtaWF8jaiA49HwsZD459jqm9YFz9ZtMFpQA=,1d677069e35c4a3e4f290e68c6e2391f6237aee9ce3f39448ed09a2ddab274b0 +github.com/Kubuxu/go-os-helper,v0.0.1,h1:EJiD2VUQyh5A9hWJLmc6iWg6yIcJ7jpBcwC8GMGXfDk=,90a16f95a8a238910ab0dc9004cb6e56242a10810bf1e296a263d2e385f002e0 +github.com/KyleBanks/depth,v1.2.1,h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=,8f3e9af2e038f561d9c34b631fddc7db39e39992a121fd087f0bf980026464d9 +github.com/MakeNowJust/heredoc,v1.0.0,h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=,062afe6e11aa3c3ac0035d08907b80d5e5b7563905603391ee774bda440abf16 +github.com/Masterminds/goutils,v1.1.0,h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=,b9520e8d2775ac1ff3fbf18c93dbc4b921133f957ae274f5b047965e9359d27d +github.com/Masterminds/semver,v1.5.0,h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=,15f6b54a695c15ffb205d5719e5ed50fab9ba9a739e1b4bdf3a0a319f51a7202 +github.com/Masterminds/semver/v3,v3.0.1,h1:2kKm5lb7dKVrt5TYUiAavE6oFc1cFT0057UVGT+JqLk=,f1eef1a1b6489d895eb32326f3369bd1615812a4c5fbfe60b2b6cc774c6340f0 +github.com/Masterminds/sprig,v2.22.0+incompatible,h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=,1b4d772334cc94e5703291b5f0fe4ac4965ac265424b1060baf18ef5ff9d845c +github.com/Masterminds/squirrel,v1.1.0,h1:baP1qLdoQCeTw3ifCdOq2dkYc6vGcmRdaociKLbEJXs=,cede1b0a054e000a5e6a8000cb02de7ab64ddca9e0f4153732274627adeed0ae +github.com/Microsoft/go-winio,v0.4.14,h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=,7a86644691d3c86c77ae0b639fa27029706552f00cd51b445389a61694576f6b +github.com/Microsoft/hcsshim,v0.8.6,h1:ZfF0+zZeYdzMIVMZHKtDKJvLHj76XCuVae/jNkjj0IA=,900feaaec1c41d4e111a66bbde330b41fc78902c70c0af37d611505bf42e0632 +github.com/NYTimes/gziphandler,v1.1.1,h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=,2948d9f70e4388f13f4ed9400df41dca60841059f7dcc30cf909c82796cc705a +github.com/NaverCloudPlatform/ncloud-sdk-go,v0.0.0-20180110055012-c2e73f942591,h1:/P9HCl71+Eh6vDbKNyRu+rpIIR70UCZWNOGexVV3e6k=,2e9eacfe3e6785beef75391bcebc14a6a082687c0f0582bc441c3d0106b8bf5c +github.com/NebulousLabs/entropy-mnemonics,v0.0.0-20181203154559-bc7e13c5ccd8,h1:wPFCU8DwC4k5C2LfJc/rVp4cmTqzF3vyydxRR3b3HhQ=,6a65ca779cd216db7bf326ebbb5a26a87d85ff6a6ba832eec281c5c09a8294e3 +github.com/Netflix/go-expect,v0.0.0-20180615182759-c93bf25de8e8,h1:xzYJEypr/85nBpB11F9br+3HUrpgb+fcm5iADzXXYEw=,fbe7b2f58ecb0e1067a6670bbcf0718d54ec407aab81790cc9e58db9a6774775 +github.com/NickBall/go-aes-key-wrap,v0.0.0-20170929221519-1c3aa3e4dfc5,h1:5BIUS5hwyLM298mOf8e8TEgD3cCYqc86uaJdQCYZo/o=,fd78212ec77052b032b9fc308c028e8fc166de3d6ae4494f5eb3254930728a0b +github.com/Nvveen/Gotty,v0.0.0-20120604004816-cd527374f1e5,h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=,362ac7b59d74231419471b65b60079d167785b97fd4aa0de71575088cd192b1e +github.com/OneOfOne/xxhash,v1.2.5,h1:zl/OfRA6nftbBK9qTohYBJ5xvw6C/oNKizR7cZGl3cI=,7ab3c6a0e7c16c987a589e50a9a353e8877cfffea02bf9e04e370fd26a0c85e1 +github.com/OpenBazaar/jsonpb,v0.0.0-20171123000858-37d32ddf4eef,h1:+aqKrHtCJTRp8ziyrjfHbTF5puPQZfgRt65+iM7FD2w=,5f6ea1466b9d27f016c1bf2650669c788db623142cdc8a1794bc1784fc80fc4e +github.com/OpenBazaar/wallet-interface,v0.0.0-20190807004547-aa8e214acd9b,h1:KjQH45msWRtDhb5JAbBW+eU4M/9xIm11rsOSgAaqDOs=,f7ac40d665241766533b1a49a726068d9dfea5e02c7fd426df81f9e390a7003e +github.com/OpenDNS/vegadns2client,v0.0.0-20180418235048-a3fa4a771d87,h1:xPMsUicZ3iosVPSIP7bW5EcGUzjiiMl1OYTe14y/R24=,b73d6b37d519c7bf181e502b92962f1bf961bb0ca3a9ef7057c3d9a8a3c2f3cd +github.com/OwnLocal/goes,v1.0.0,h1:81QQ3z6dvLhgXlkNpLkaYhk8jiKS7saFG01xy039KaU=,ebb6c7e2c12577c590d2d5546b7a4b4e6fa75c9a408ae5244b5ba2cf09dec1d6 +github.com/PuerkitoBio/goquery,v1.5.0,h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP7EJk=,f0064ad35f21c2b9d1377b94f09ead56ec1862da3807e78c26b99c4b3a04f5e6 +github.com/PuerkitoBio/purell,v1.1.1,h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=,59e636760d7f2ab41c2f80c1784b1c73d381d44888d1999228dedd634ddcf5ed +github.com/PuerkitoBio/urlesc,v0.0.0-20170810143723-de5bf2ad4578,h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=,1793124273dd94e7089e95716d40529bcf70b9e87162d60218f68dde4d6aeb9d +github.com/Quasilyte/inltest,v0.7.0,h1:yHvFAaoXn+6iK2uKtb8mXB9KURz6SDPyszoyBAC0Xk4=,8fb4273cea3514742aec06ed58f20cea1214cc542799c70c331a80865aaf3988 +github.com/RangelReale/osin,v1.0.1,h1:JcqBe8ljQq9WQJPtioXGxBWyIcfuVMw0BX6yJ9E4HKw=,edbcc6208879bffa533369bbf417db41c1322193ca05d0deecf13075972c9d57 +github.com/RangelReale/osincli,v0.0.0-20160924135400-fababb0555f2,h1:x8Brv0YNEe6jY3V/hQglIG2nd8g5E2Zj5ubGKkPQctQ=,82fc65bad3da9fc26cc77b485e10ee117459e830547ce89592c41d92871e1129 +github.com/Rican7/retry,v0.1.0,h1:FqK94z34ly8Baa6K+G8Mmza9rYWTKOJk+yckIBB5qVk=,c0e956967f2f632ffc889eeae5b82e437f30e9be409870cdd1e7998def458843 +github.com/RoaringBitmap/roaring,v0.4.7,h1:eGUudvFzvF7Kxh7JjYvXfI1f7l22/2duFby7r5+d4oc=,515892d9b8e4350e5ac5b7a487da94d5d9ab9641071e002b778dd864b7a31c2a +github.com/SAP/go-hdb,v0.14.1,h1:hkw4ozGZ/i4eak7ZuGkY5e0hxiXFdNUBNhr4AvZVNFE=,273de28a254c39e9f24293b864c1d664488e4a5d44d535755a5e5b68ae7eed8d +github.com/Sereal/Sereal,v0.0.0-20190529075751-4d99287c2c28,h1:kmfzzWpCZIrVhxx4V/2oSGhGnhtX+/JijVIlPuKYfHg=,eebfe79e62b5a07f98a367d8a84bcf33ed69818c031e70c3ebc6e9fc34361466 +github.com/SermoDigital/jose,v0.0.0-20180104203859-803625baeddc,h1:LkkwnbY+S8WmwkWq1SVyRWMH9nYWO1P5XN3OD1tts/w=,1711f20ec5b1498c98e46b96e578f39b723557ab50183d644702d40f44a1a345 +github.com/Shopify/go-lua,v0.0.0-20181106184032-48449c60c0a9,h1:+2M9NEk3+xSg0+bWzt1kxsL6EtoEg7sgtT11CZjGwq8=,3e399584ff4a876314243c01be3cba5b98b46bba483d6996dd2d0e7f161b7ad8 +github.com/Shopify/goreferrer,v0.0.0-20181106222321-ec9c9a553398,h1:WDC6ySpJzbxGWFh4aMxFFC28wwGp5pEuoTtvA4q/qQ4=,e47cdf750e6aa39707b90e62f4f87e97abb8d64b2525a16c021c82efb24f9969 +github.com/Shopify/sarama,v1.24.1,h1:svn9vfN3R1Hz21WR2Gj0VW9ehaDGkiOS+VqlIcZOkMI=,c5e06f9c835846eeb5cbbbc540ab949f9775ff37c08cab503dd820b858b1f2e7 +github.com/Shopify/toxiproxy,v2.1.4+incompatible,h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc=,9427e70698ee6a906904dfa0652624f640619acef40652a1e5490e13b31e7f61 +github.com/Sirupsen/logrus,v1.0.6,h1:HCAGQRk48dRVPA5Y+Yh0qdCSTzPOyU1tBJ7Q9YzotII=,dc69c77019152ace477a7f5c0cd97fd25d6ab866e01e1dd06f391722f4f9fba9 +github.com/StackExchange/wmi,v0.0.0-20190523213315-cbe66965904d,h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=,68f499ad4c3f45fc6c286fd2a5966e8e15c0f3abc1f96fbf4a979245df936e16 +github.com/Stebalien/go-bitfield,v0.0.1,h1:X3kbSSPUaJK60wV2hjOPZwmpljr6VGCqdq4cBLhbQBo=,9b17a2749922c810f3598606b87b5f2ba0f3c6abc70966911a8c32f0533ee827 +github.com/Telmate/proxmox-api-go,v0.0.0-20190815172943-ef9222844e60,h1:iEmbIRk4brAP3wevhCr5MGAqxHUbbIDHvE+6D1/7pRA=,55dd16e2cd8e6c1464c6456007cdc5d8676b8b096e90230312daa8c84b57b34d +github.com/TheThingsNetwork/api,v0.0.0-20190522113053-d844e8c040fc,h1:hDk+SAT2tV584ye1hqMN5+NHL6RHJDIbe97cNot6/WQ=,7931f7c4699cd1019c950a68361e3b3fec8bbb8e9204c65c08b50bd588ac506a +github.com/TheThingsNetwork/go-account-lib,v2.0.3+incompatible,h1:pnDIalIqac/VlXenPr+L1XEEf3gIq1eIoZ78S5AP1/s=,e62dcb784cbd28bcec55cf332f7dc06779c75c7df66299f4ce542cd6852358b4 +github.com/TheThingsNetwork/go-cayenne-lib,v1.0.0,h1:be7h6E/69+qaYs1iwQ2xjGjSFPXzvU3q6AWBCWayG2Y=,17091b77ac39b8e73ca6ac3f39f34909bc6a3770098ff2dd534b59a10f6e66ad +github.com/TheThingsNetwork/go-utils,v0.0.0-20190813113035-8715cf82e887,h1:DF/1gkOPk3jtwWa9dFd5tUtwb6z3bLw9tZ/UALbS5Ck=,be4c7c2955630b63300f21773efcdc991d5ff201a53b01d92b2f20fede77065c +github.com/TheThingsNetwork/ttn,v2.10.1+incompatible,h1:LQw+g+kinajii5DHJ6I2o82ObaU/Ws+YYgdLkF5eF54=,4a803fe23636f9c99926e6b5a2b956fb42e84ca38c98458a12bd7fe1c22f7439 +github.com/TheThingsNetwork/ttn/api,v0.0.0-20190516081709-034d40b328bd,h1:vCjDYImJDdW+39EXwij00yzDi1pd3TmP6XtCteDJBd0=,9cda2f899f15f57e8f649bbffb955a8153d6c25a13a4e969df8898bb61559a44 +github.com/TheThingsNetwork/ttn/core/types,v0.0.0-20191015060859-00a6f7874bb9,h1:tlWwCxI3/Zu4vJ4dLWb2wMOYSkeMBvLAxQGwJDCFXi8=,7b3895805d6ac341e5df44c2c8154b374b4bed4c8f54e248ea967abfc37186e7 +github.com/TheThingsNetwork/ttn/utils/errors,v0.0.0-20190516081709-034d40b328bd,h1:ITXOJpmUR4Jhp3Xb/xNUIJH4WR0h2/NsxZkSDzFIFiU=,d64decf456c10fdbbb887212ea63749b495264c40bb5ac047b9f0e5ccd7e540b +github.com/TheThingsNetwork/ttn/utils/random,v0.0.0-20190516081709-034d40b328bd,h1:zKTRK1r3K55XxHuUGxnqYg9aiPDduYeilHUEHua+F+Y=,c504030254919a902b3957267b7ce1870f909cbdd65f0f927819f60710e41d9b +github.com/TheThingsNetwork/ttn/utils/security,v0.0.0-20190516081709-034d40b328bd,h1:og10Wq5S/QC+f4ziON4vrxlYKv9gfEKxG8v/MDs00xw=,e6f013adee3a7a212a6f892db59c8efaf715fe49413e6dbca22229fa04f0d006 +github.com/Unknwon/cae,v0.0.0-20160715032808-c6aac99ea2ca,h1:xU8R31tsvj6TesCBog973+UgI3TXjh/LqN5clki6hcc=,15a1394a603423c5bcd4659275be09d7696774990d5f127500f4156c1a78eb85 +github.com/Unknwon/com,v0.0.0-20190321035513-0fed4efef755,h1:1B7wb36fHLSwZfHg6ngZhhtIEHQjiC5H4p7qQGBEffg=,2cfba36da8f59c6dd8c7a20af59e5ccf9558f42bde7e0918a64a9b68dafcf271 +github.com/Unknwon/i18n,v0.0.0-20171114194641-b64d33658966,h1:Mp8GNJ/tdTZIEdLdZfykEJaL3mTyEYrSzYNcdoQKpJk=,a5ce1436582e797d60e967d853fd22458fc7edeb31bd390d6ace979133bedb78 +github.com/Unknwon/paginater,v0.0.0-20170405233947-45e5d631308e,h1:HnbTtNLKnRmwn85vBmyl7nNJCXUw4rh6X3UeIX5nvko=,60e3af4ba9b482892127f829ec7cc837977ca9e9e634be855d599cc08230e606 +github.com/VividCortex/ewma,v1.1.1,h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=,eebee7c0f20e96abbda1611ed2a3d26b4c2c10393caa6a2dfd1605763a5c1a12 +github.com/VividCortex/gohistogram,v1.0.0,h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=,16ebeceeb7e4066f90edbfb90282cd90d4dad0f71339199551de3fbdc7e8c545 +github.com/Workiva/go-datastructures,v1.0.50,h1:slDmfW6KCHcC7U+LP3DDBbm4fqTwZGn1beOFPfGaLvo=,1ac8c9334b63ee2b089b7ecc3b6c8d45793cc4ef4c460f6ebbfd6ecea3ee83bc +github.com/a8m/mark,v0.1.1-0.20170507133748-44f2db618845,h1:hIjQrEARcc9LcH8igte3JBpWBZ7+SpinU70dOjU/afo=,048bfeb7427ff5622874d874a52d7215a2cea99f9741c031e9963348785103c2 +github.com/abbot/go-http-auth,v0.4.0,h1:QjmvZ5gSC7jm3Zg54DqWE/T5m1t2AfDu6QlXJT0EVT0=,8204bca24734f55f179dd1c0b820ae5be83151268693a147086f33cd2d4d473c +github.com/abdullin/seq,v0.0.0-20160510034733-d5467c17e7af,h1:DBNMBMuMiWYu0b+8KMJuWmfCkcxl09JwdlqwDZZ6U14=,bcbe9a2c1e3ac0b981ee436cd1bbb2da8220527511b3cea6517a28a881636814 +github.com/abronan/valkeyrie,v0.0.0-20191010124425-1ae9442de16e,h1:4SrbWyef51DHDc957/8Ms/fDM4D+3bkbXqg6OTnIEAo=,553dce6f5ff57f7ccc5ed6a94e6bf29b38b8773236f3b85bb4025dc0d10d2a92 +github.com/aead/siphash,v1.0.1,h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg=,25da04ff418e0b2871b1193a3478977b4aa66c20737b9ca70a5040b876b6d3d9 +github.com/aerogo/http,v1.0.12,h1:1o5QW6TQLNuutQLuPCX0Tn7g/sSH3JMHv79UGIBpvkw=,a58d344ff2010737d2418050f4188339087cfb369c903bd31e20ccba388304a1 +github.com/afex/hystrix-go,v0.0.0-20180502004556-fa1af6a1f4f5,h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw=,c0e0ea63b57e95784eeeb18ab8988ac2c3d3a17dc729d557c963f391f372301c +github.com/agext/levenshtein,v1.2.2,h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=,07caaae8fcdb7c83195a0afffc03c9df76275b1e9a7b69dabfe0d2f47729bc7c +github.com/agl/ed25519,v0.0.0-20170116200512-5312a6153412,h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI=,98c1510ac20b7d61bf4e2c76e7184fcbd0a8b78b0fc667c2b772777912963d3f +github.com/agnivade/levenshtein,v1.0.1,h1:3oJU7J3FGFmyhn8KHjmVaZCN5hxTr7GxgRue+sxIXdQ=,cb0e7f070ba2b6a10e1c600d71f06508404801ff45046853001b83be6ebedac3 +github.com/ajg/form,v1.5.1,h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=,b063b07639670ce9b6a0065b4dc35ef9e4cebc0c601be27f5494a3e6a87eb78b +github.com/ajstarks/svgo,v0.0.0-20190826172357-de52242f3d65,h1:kZegOsPGxfV9mM8WzfllNZOx3MvM5zItmhQlvITKVvA=,1459a44f9162f463b59eacf58e4bb8873e612c5b3df45fc6e34074310d2269ae +github.com/akamai/AkamaiOPEN-edgegrid-golang,v0.9.0,h1:rXPPPxDA4GCPN0YWwyVHMzcxVpVg8gai2uGhJ3VqOSs=,91c3a4743d959b3bb2bb7359790df4688021830e482d393ea6d4f3a27aebd63d +github.com/akavel/rsrc,v0.8.0,h1:zjWn7ukO9Kc5Q62DOJCcxGpXC18RawVtYAGdz2aLlfw=,13954a09edc3a680d633c5ea7b4be902df3a70ca1720b349faadca44dc0c7ecc +github.com/akyoto/assert,v0.2.3,h1:ftENRGDEK5AKuKmZb9LtbDIHeE8p8cIYI4M92CbA9nE=,f0a31d5859109c37568b8702fcf92cd3a49ec4892dace74d113df5fd49491975 +github.com/akyoto/color,v1.8.11,h1:uCQi+uRyngo1cJhJSv28PQmduGFiOAGNF6F9MFoRDek=,0fa16c51743ca03e108fde20eabb070d17d25111cb287e15f8567268d439098a +github.com/akyoto/colorable,v0.1.7,h1:ge91E25hiOiT/Zu47ij/rTO3cks7wMlTrcQspua1hFM=,07c2dd4d994d9ff1dad97ad2e2650ff60d90f50ecd52380f357e562efda99613 +github.com/akyoto/stringutils,v0.2.6,h1:IP+7jtH8uofpan8MYlV/WMNaLDGBRbzgiTKYnxcAwkw=,802a3b54f91b930c1e8f2376bebf783b16894da626fc7c8064268b07ab567f7c +github.com/akyoto/tty,v0.1.3,h1:AdnLETzgooimWLvoBQLn5bT1j+i0yiB4E596BfFKnmA=,749381ec9dce8bc96bec66c5dfb0874db917a008f9685d9c65c15da43ede964c +github.com/alcortesm/tgz,v0.0.0-20161220082320-9c5fe88206d7,h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=,ccedffb2c46724216b787fb1a79ae33fb0dfdd672c669db000c4ed5a68b08014 +github.com/alecthomas/assert,v0.0.0-20170929043011-405dbfeb8e38,h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=,873d257170b1363142cbf5e16b49c6a21cccb3e4aaceb9d370c3b78b051a5663 +github.com/alecthomas/chroma,v0.6.8,h1:TW4JJaIdbAbMyUtGEd6BukFlOKYvVQz3vVhLBEUNwMU=,ebc5202e6a0ededc5a2c7396b01b76c050331bead9d047f31fe648cb63e68aa3 +github.com/alecthomas/colour,v0.0.0-20160524082231-60882d9e2721,h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=,334101c562d2e74338f6baab1de04f3bbff89021d24f4206c551ef47b96a2bfe +github.com/alecthomas/kingpin,v2.2.6+incompatible,h1:5svnBTFgJjZvGKyYBtMB0+m5wvrbUHiqye8wRJMlnYI=,a88daee47262ffeca1f6e348399c16c9be160f3c5e972c0b6c9dc275d85bcdc6 +github.com/alecthomas/kong,v0.2.1-0.20190708041108-0548c6b1afae,h1:C4Q9m+oXOxcSWwYk9XzzafY2xAVAaeubZbUHJkw3PlY=,4292d9b6903d67f060d3bd57ffca0a4ebca359824ce2d32a512ac1b963fa3dc0 +github.com/alecthomas/kong-hcl,v0.1.8-0.20190615233001-b21fea9723c8,h1:atLL+K8Hg0e8863K2X+k7qu+xz3M2a/mWFIACAPf55M=,21a34d6ee62e3419601d0e083b8829001a9833899dd3c2d27a82c794426fd0ee +github.com/alecthomas/log4go,v0.0.0-20180109082532-d146e6b86faa,h1:0zdYOLyuQ3TWIgWNgEH+LnmZNMmkO1ze3wriQt093Mk=,04bdaa7d57a681072316927175c21ca7c9e7a19bd7fee2102b5f40e5b01a7559 +github.com/alecthomas/repr,v0.0.0-20181024024818-d37bc2a10ba1,h1:GDQdwm/gAcJcLAKQQZGOJ4knlw+7rfEQQcmwTbt4p5E=,c01a833ec56f68113f6cd7ed82b7da9bfaec641a10e929e0e3e5e5dadb1a85ad +github.com/alecthomas/template,v0.0.0-20190718012654-fb15b899a751,h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=,25e3be7192932d130d0af31ce5bcddae887647ba4afcfb32009c3b9b79dbbdb3 +github.com/alecthomas/units,v0.0.0-20190924025748-f65c72e2690d,h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=,e6b0ccb38bfba85d90092d1c57671d5f7996757bd71f6f1970c6ae2f9dae3f6e +github.com/alicebob/gopher-json,v0.0.0-20180125190556-5a6b3ba71ee6,h1:45bxf7AZMwWcqkLzDAQugVEwedisr5nRJ1r+7LYnv0U=,2374b534198621157afb9466a52d361b6eed33dcf9bb0674019515e64b16129e +github.com/alicebob/miniredis,v0.0.0-20180911162847-3657542c8629,h1:gLoh8jzwIxdisBnHiWRIuReqtH9cpslSE2564UWXun0=,14b5e988ec6d8357a25ba19a7adbdb34920f5f91401b2b26eb25f04fed9893b0 +github.com/aliyun/alibaba-cloud-sdk-go,v0.0.0-20191031111935-12810c79403d,h1:CmGtZPPsr0C31ZBrzdP+D2oczTbyEBbO3bYg6z5EIDY=,4f0f25f45d954ab970b24783e31b716b619b128081acc9ed7b00727cd7c2d536 +github.com/aliyun/aliyun-oss-go-sdk,v2.0.3+incompatible,h1:724q2AmQ3m1mrdD9kYqK5+1+Zr77vS21jdQ9iF9t4b8=,47ede6a440ad4bb1a1c33d71bd12f76f44aa2487f676b8770152130be3021657 +github.com/aliyun/aliyun-tablestore-go-sdk,v4.1.2+incompatible,h1:ABQ7FF+IxSFHDMOTtjCfmMDMHiCq6EsAoCV/9sFinaM=,82c8ced9cd377462c6ea5070258f97c77ffddd66621e8960b08184eb58416846 +github.com/allegro/bigcache,v1.2.1,h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKSc=,9250edab8c7851cfa0c6c173e721cf70831e90742a7485c2eba1d6e2cc8c71eb +github.com/anacrolix/envpprof,v1.1.0,h1:hz8QWMN1fA01YNQsUtVvl9hBXQWWMxSnHHoOK9IdrNY=,97f2340bcb169956bad97c59fdc17bbd2eb7c0acefe4e2ae327c7d6bd5a5f6cf +github.com/anacrolix/log,v0.3.0,h1:Btxh7GkT4JYWvWJ1uKOwgobf+7q/1eFQaDdCUXCtssw=,e8bc14381d8746426c7e272228780047e0594d695d02e188269f1e86ef1644d4 +github.com/anacrolix/missinggo,v1.2.1,h1:0IE3TqX5y5D0IxeMwTyIgqdDew4QrzcXaaEnJQyjHvw=,2fb8cba1f6eaf69989ca5c522c2d4afd6c1071ad9459f940b6058dbfc2f3b285 +github.com/anacrolix/missinggo/perf,v1.0.0,h1:7ZOGYziGEBytW49+KmYGTaNfnwUqP1HBsy6BqESAJVw=,f4271e6359cf3dd5cba81bcf1436e8abc5d0c96c11820b881544708caa131713 +github.com/anacrolix/sync,v0.0.0-20180808010631-44578de4e778,h1:XpCDEixzXOB8yaTW/4YBzKrJdMcFI0DzpPTYNv75wzk=,bef95f54e1b17e4e7666cbf552e541e670f29fc3fd354aba0ebeee73f744ea24 +github.com/anacrolix/tagflag,v1.0.1,h1:Yd3d5DaKbRA70k7CoFuBsbmfSWIsvtZ9t80xW/x4vQY=,8fc0a5b5607cde223bacd9e4fa3b26f6166c09a09bfabe2c2c803e45e17971fa +github.com/anacrolix/utp,v0.0.0-20180219060659-9e0e1d1d0572,h1:kpt6TQTVi6gognY+svubHfxxpq0DLU9AfTQyZVc3UOc=,35c47428844d10f077225195f9a6c7587c671b7fc70bbaf59ef74cd6d8834e32 +github.com/andreyvit/diff,v0.0.0-20170406064948-c7f18ee00883,h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=,d39614ff930006640ec15865bca0bb6bf8e1ed145bccf30bab08b88c1d90f670 +github.com/andybalholm/cascadia,v1.0.0,h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o=,7fd82e560ca1a453974a64c9bf6514b17322d1b7392bad730a5006d929996906 +github.com/andygrunwald/go-jira,v1.5.0,h1:/1CyYLNdwus7TvB/DHyD3udb52K12aYL9m7WaGAO9m4=,3ee973941f400bf95005cada54e09e319cb4943cd6c8d66480243d3b40895821 +github.com/anmitsu/go-shlex,v0.0.0-20161002113705-648efa622239,h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=,3b8376ff631f30d47e0348a8f847050b97c3db89483f45d1cd8f11d23c7c56a2 +github.com/antchfx/htmlquery,v1.0.0,h1:O5IXz8fZF3B3MW+B33MZWbTHBlYmcfw0BAxgErHuaMA=,81c86507bf2a226d5a3d20db547503d490f1e3b77035f267056e80cd73e240e2 +github.com/antchfx/xmlquery,v1.0.0,h1:YuEPqexGG2opZKNc9JU3Zw6zFXwC47wNcy6/F8oKsrM=,969fc21438fe076aee032574578158ac7e030979153dcf7b5ff5c133cbfa4d86 +github.com/antchfx/xpath,v0.0.0-20190129040759-c8489ed3251e,h1:ptBAamGVd6CfRsUtyHD+goy2JGhv1QC32v3gqM8mYAM=,22cb767dc0cafecba39e1b0322cc8aebbc6fd912e4b0fcda8c2c1dde2d80c4d2 +github.com/antchfx/xquery,v0.0.0-20180515051857-ad5b8c7a47b0,h1:JaCC8jz0zdMLk2m+qCCVLLLM/PL93p84w4pK3aJWj60=,9ddc9d830f2d6c7a22604035f0c621228ffa4ed6ff1f1d34655ee477c203c899 +github.com/antihax/optional,v0.0.0-20180407024304-ca021399b1a6,h1:uZuxRZCz65cG1o6K/xUqImNcYKtmk9ylqaH0itMSvzA=,7b0a2bf3eb029d9abe761db1874a501b60f267e675d72ae8c4b8c6f406ddcfd0 +github.com/apache/arrow/go/arrow,v0.0.0-20191024131854-af6fa24be0db,h1:nxAtV4VajJDhKysp2kdcJZsq8Ss1xSA0vZTkVHHJd0E=,4bd8443c24bc06843c0270df4f08f98b3eee6116604ff16d14dce34b242783cf +github.com/apache/thrift,v0.13.0,h1:5hryIiq9gtn+MiLVn0wP37kb/uTeRZgN08WoCsAhIhI=,d75265e363da943c24e7ed69104bf018429024a50968421e48a6ab3e624733c2 +github.com/apex/log,v1.1.1,h1:BwhRZ0qbjYtTob0I+2M+smavV0kOC8XgcnGZcyL9liA=,5bb0f19e5c68b104ed32a311ea9c6f6e2a5e8fa597b342695e069468e2248d83 +github.com/aphistic/golf,v0.0.0-20180712155816-02c07f170c5a,h1:2KLQMJ8msqoPHIPDufkxVcoTtcmE5+1sL9950m4R9Pk=,a0ca77a50520037607c3a2a798b66aee1d5df63f4800b4236f51be2f1e3c1d70 +github.com/aphistic/gomol,v0.0.0-20190314031446-1546845ba714,h1:ml3df+ybkktxzxTLInLXEDqfoFQUMC8kQtdfv8iwI+M=,c2fd1a9db2fb7a5ca7ba9132fbddb5d8efd64babcff7c0f66d41d3cf97b8caab +github.com/aphistic/gomol-console,v0.0.0-20180111152223-9fa1742697a8,h1:tzgowv45TOFALtZLJ9y3k+krzOh2J8IkCvJ8T//6VAU=,26a1b99db9a92a7f5d088e529c43db6de957a3a1650c27d7a872495f73a52880 +github.com/aphistic/gomol-gelf,v0.0.0-20170516042314-573e82a82082,h1:PgPqI/JnStmzwTof+PtT53Pz53dlrz2BmF7cn5CAwQM=,e44d4de8d62391c1e0e70c3b27f4c341bb0398083f33b99be46e29144fad3c50 +github.com/aphistic/gomol-json,v1.1.0,h1:XJWwW8PxYOHf0f0FquuBWcgvZBvQ89nPxZsqQ9pfpro=,0e1ab66a46afe81c4662f8a49ca38042f0c6bc8645895336399adef1eedaff59 +github.com/aphistic/sweet,v0.2.0,h1:I4z+fAUqvKfvZV/CHi5dV0QuwbmIvYYFDjG0Ss5QpAs=,02bebcef905b02cf7195137d9b20920367bb5f8c635a6e5a112b787596414f51 +github.com/aphistic/sweet-junit,v0.0.0-20190314030539-8d7e248096c2,h1:qDCG/a4+mCcRqj+QHTc1RNncar6rpg0oGz9ynH4IRME=,6a3ab195b97bd1981f2ae87a172bc24ecfb44ffbd8d28428f97bfa46e66f559b +github.com/apparentlymart/go-cidr,v1.0.1,h1:NmIwLZ/KdsjIUlhf+/Np40atNXm/+lZ5txfTJ/SpF+U=,5af128e1ecdf5f2203fda104a653f13fb2e46acc3f68b2d7634a760a8f556ea0 +github.com/apparentlymart/go-dump,v0.0.0-20190214190832-042adf3cf4a0,h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=,3506757fd2dcbcf8e77aa962c923d9ceaf918538bf9b117f98aa562bc83c77ef +github.com/apparentlymart/go-textseg,v1.0.0,h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0=,2572a77af285125f1980e9b751e5a7c3ae59b73c4fc97e7c2407681609991142 +github.com/appc/spec,v0.8.11,h1:BFwMCTHSDwanDlAA3ONbsLllTw4pCW85kVm290dNrV4=,4a17d699b3e2c3cc8b301de260a45c8fc31054fbb5c689e567f24e3e63bf8f79 +github.com/apple/foundationdb/bindings/go,v0.0.0-20190411004307-cd5c9d91fad2,h1:VoHKYIXEQU5LWoambPBOvYxyLqZYHuj+rj5DVnMUc3k=,a2dc6bd23d9066d3acf174c9b33378c08ae4a95cfd017abc70a16388e74ea2c3 +github.com/approvals/go-approval-tests,v0.0.0-20160714161514-ad96e53bea43,h1:ePCAQPf5tUc5IMcUvu6euhSGna7jzs7eiXtJXHig6Zc=,e3b51ab88c4f3b1c4aea2fadd0b3d3e2ec178d37232066b9fe3b0177e1c6e9aa +github.com/aquasecurity/fanal,v0.0.0-20191031102512-c1c079886da6,h1:B84l/SNXzzcqwgIORAmEv7gs4K4l+DJkdliI6ib/zNw=,7247188e1746360364e7ff77aa0c531df69074c49b23e7f67d65134ca577b0e0 +github.com/aquasecurity/go-dep-parser,v0.0.0-20190819075924-ea223f0ef24b,h1:55Ulc/gvfWm4ylhVaR7MxOwujRjA6et7KhmUbSgUFf4=,73ce01b48b9aa56349d928a27bdd4b77c149541385e645951b2e25f1d6ab5d26 +github.com/araddon/dateparse,v0.0.0-20190622164848-0fb0a474d195,h1:c4mLfegoDw6OhSJXTd2jUEQgZUQuJWtocudb97Qn9EM=,3b88bff198316e2795d11340862ef873387cd7dba97eeb17f106f41deb00d602 +github.com/araddon/gou,v0.0.0-20190110011759-c797efecbb61,h1:Xz25cuW4REGC5W5UtpMU3QItMIImag615HiQcRbxqKQ=,936e20f4c9eaa45f54586ab86bce911f0b1f935d0410dd683dc647797ed7225d +github.com/aristanetworks/fsnotify,v1.4.2,h1:it2ydpY6k0aXB7qjb4vGhOYOL6YDC/sr8vhqwokFQwQ=,9c0dd5427e82f044a9e5808a3436b43472ff032f23ac853829e5c166171044a3 +github.com/aristanetworks/glog,v0.0.0-20180419172825-c15b03b3054f,h1:Gj+4e4j6g8zOhckHfGbZnpa0k8yDrc0XRmiyQj2jzlU=,496dd08756b324a7925b670a907328433f1477763a229b76a4eef8ed254c9683 +github.com/aristanetworks/goarista,v0.0.0-20191023202215-f096da5361bb,h1:gXDS2cX8AS8KbnP32J6XMSjzC1FhHEdHfUUCy018VrA=,2c348fcdf827ac0d1238fb556f66ad1f13f05d8c5a6d2b3efe5f94be40af5021 +github.com/aristanetworks/splunk-hec-go,v0.3.3,h1:O7zlcm4ve7JvqTyEK3vSBh1LngLezraqcxv8Ya6tQFY=,545adec43ebdf1c9cdc65cd3d738d131f1b02706d25876de1fda65c4989195af +github.com/armon/circbuf,v0.0.0-20190214190532-5111143e8da2,h1:7Ip0wMmLHLRJdrloDxZfhMm0xrLXZS8+COSu2bXmEQs=,c8b7ba977844b5378a2413c123c3e55d0885fb67f64ad6cf06575a791a36b827 +github.com/armon/consul-api,v0.0.0-20180202201655-eb2c6b5be1b6,h1:G1bPvciwNyF7IUmKXNt9Ak3m6u9DE1rF+RmtIkBpVdA=,091b79667f16ae245785956c490fe05ee26970a89f8ecdbe858ae3510d725088 +github.com/armon/go-metrics,v0.0.0-20190430140413-ec5e00d3c878,h1:EFSB7Zo9Eg91v7MJPVsifUysc/wPdN+NOnVe6bWbdBM=,3d48bc38dda0cff4dbf0b56b9b6e2e8fc3e6be2282f2a612a96a6702cc8a9fc5 +github.com/armon/go-proxyproto,v0.0.0-20190211145416-68259f75880e,h1:h0gP0hBU6DsA5IQduhLWGOEfIUKzJS5hhXQBSgHuF/g=,1004212be9a343c99e1849425845af1ec5e3e35cc4917483721cb03620982d58 +github.com/armon/go-radix,v1.0.0,h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=,df93c816505baf12c3efe61328dc6f8fa42438f68f80b0b3725cae957d021c90 +github.com/armon/go-socks5,v0.0.0-20160902184237-e75332964ef5,h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=,f473e6dce826a0552639833cf72cfaa8bc7141daa7b537622d7f78eacfd9dfb3 +github.com/asaskevich/govalidator,v0.0.0-20190424111038-f61b66f89f4a,h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA=,b5dfb936e0256459bc633c8acf433f4a01a468868db9bd6e390a67f4678185f5 +github.com/asdine/storm,v2.1.2+incompatible,h1:dczuIkyqwY2LrtXPz8ixMrU/OFgZp71kbKTHGrXYt/Q=,ffea8b759006a871732554e1e0a42753fb9a5dd9884eb150e1b42806d51cd5fd +github.com/assetsadapterstore/tivalue-adapter,v1.0.3,h1:zcFcT1x1rWDYQEaA3wI7Hr7F25Cspy+O1cr+vUMjrks=,c42adddd544495ef0ebe1d8730bad20c4251c7646e1782542782bc946c839eca +github.com/astaxie/beego,v1.12.0,h1:MRhVoeeye5N+Flul5PoVfD9CslfdoH+xqC/xvSQ5u2Y=,1f14eb5d216170c027754bea1129bbcdafc06a035650e635375c61a17be6f316 +github.com/asticode/go-astilog,v1.0.0,h1:l9tek0K7KoQCmhZ7cvBTtVu0NsKpS9hB6jBLtQyxWYk=,49fe2b286073848e780a9326f7d37771372e61827ff07b80db89667e6ac4d1d4 +github.com/aws/amazon-ssm-agent,v0.0.0-20191011205301-04bb0617297b,h1:xv695CeRjoBS0baQSS5UfQkeo63GiMjmDwiAeY09bSw=,08ede8d7aa20210a4738e0ea033f1bf8fd1ce13bba6c375431c8c1e7a8565c37 +github.com/aws/aws-lambda-go,v1.13.2,h1:8lYuRVn6rESoUNZXdbCmtGB4bBk4vcVYojiHjE4mMrM=,05b1633366a8df9e313df4409d003a277ff7ae46f1079b3ad7f6b48c0dabfb75 +github.com/aws/aws-sdk-go,v1.25.25,h1:j3HLOqcDWjNox1DyvJRs+kVQF42Ghtv6oL6cVBfXS3U=,c34d718d97487766a9a8ac818d37dd135d75d747a8d191a616b75425c32456f2 +github.com/aybabtme/rgbterm,v0.0.0-20170906152045-cc83f3b3ce59,h1:WWB576BN5zNSZc/M9d/10pqEx5VHNhaQ/yOVAkmj5Yo=,a4456a42277e0c987de99e9c4ba141db064107ce737ad1dd2e050aeb1149b67e +github.com/aymerick/raymond,v2.0.2+incompatible,h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=,df6e22632cb314b76ab10dd6a1c2c66a79da44200bfec9f5e4f321100d90dc64 +github.com/baiyubin/aliyun-sts-go-sdk,v0.0.0-20180326062324-cfa1a18b161f,h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA=,0965da027355d9b385358331ec359cf729ec4571ec4ca86339da925364c13559 +github.com/bartekn/go-bip39,v0.0.0-20171116152956-a05967ea095d,h1:1aAija9gr0Hyv4KfQcRcwlmFIrhkDmIj2dz5bkg/s/8=,6a278508499838d4c57c1dbdafcfc9f9f909e7358c518a8699728053b695d0c5 +github.com/bazelbuild/buildtools,v0.0.0-20191024175656-9f3978593d3e,h1:QdfIPgk+fJY8AcfjVk2/tdc2dNtl6d+7x8dhVBP72Ik=,f768dd2a38a1dedc924740f9b7a3194ca68d8a24db8fb840c547aee3911162d3 +github.com/bbangert/toml,v0.0.0-20130821181452-a2063ce2e5cf,h1:SGoM2ypzNnI+hMs01svW6wRddndk7eWRs1Bx1zOGRTI=,63690dcb3fcf13b55193cfe263b4a4fdbbe2ee9d7f93440375815dac28d34cb9 +github.com/bcext/cashutil,v0.0.0-20190126062106-1194a0af0582,h1:+sgikGWB0jvS9rzLlPww+SSFoieOLB8yieXyX9DRCF4=,4d5b42e5d472015edeef1b6bf54e253a85bab6df1ac16aabea7fd0dea4aa85e3 +github.com/bcext/gcash,v0.0.0-20190404152342-2e38815af4f2,h1:XVuqYNixmuo81vR/PnBRDDiTH7596mAwQlQ8BucvGnM=,6b24e00369a493c32e730a4d78d8c4fd122ffe0ce319c5d72f3c7d2f12ede4b7 +github.com/beego/goyaml2,v0.0.0-20130207012346-5545475820dd,h1:jZtX5jh5IOMu0fpOTC3ayh6QGSPJ/KWOv1lgPvbRw1M=,aaa4165412caaacbb2df4427207a206e09215c3f7a19f8309e9222ca9ff80691 +github.com/beego/x2j,v0.0.0-20131220205130-a0352aadc542,h1:nYXb+3jF6Oq/j8R/y90XrKpreCxIalBWfeyeKymgOPk=,f9a32026b2107f3cc3610ac6b75c4c64818646a316c35e648c8811d4276a9993 +github.com/beevik/etree,v1.1.0,h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs=,614a33736f8b9262a809f101df5bf71f47777879b1191165b6247d6b67c7468c +github.com/beevik/guid,v0.0.0-20170504223318-d0ea8faecee0,h1:oLd/YLOTOgA4D4aAUhIE8vhl/LAP1ZJrj0mDQpl7GB8=,5add94fcade6c7afa236112c8da300d47ec499ad1789a5e805c8198062dd0749 +github.com/beevik/ntp,v0.2.0,h1:sGsd+kAXzT0bfVfzJfce04g+dSRfrs+tbQW8lweuYgw=,42e14f30c23ba2f5ddaff76101016d87f0f0a0f1d96d3d20e42fd02842091c76 +github.com/beorn7/perks,v1.0.1,h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=,25bd9e2d94aca770e6dbc1f53725f84f6af4432f631d35dd2c46f96ef0512f1a +github.com/bep/debounce,v1.2.0,h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo=,ddc0a77e4819b6b826d69fdf1a5a153f3f867a31e030cfe28296355b670adf21 +github.com/bep/gitmap,v1.1.1,h1:Nf8ySnC3I7/xPjuWeCwzukUFv185iTUQ6nOvLy9gCJA=,364163e67741ae331d164fd881964160f19fdbdfe094e0e762314cc37aac646a +github.com/bep/go-tocss,v0.6.0,h1:lJf+nIjsQDpifUr+NgHi9QMBnrr9cFvMvEBT+uV9Q9E=,40e7175da9564796e184e4383bfce703f63244b850999b5a54fd5792bfc5baf5 +github.com/bep/tmc,v0.5.0,h1:AP43LlBcCeJuXqwuQkVbTUOG6gQCo04Et4dHqOOx4hA=,f8e0be71fb845a4ca22825f5b9c51c1a66c29e9ccff723e063781ee64c664c66 +github.com/bgentry/go-netrc,v0.0.0-20140422174119-9fd32a8b3d3d,h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=,59fbb1e8e307ccd7052f77186990d744284b186e8b1c5ebdfb12405ae8d7f935 +github.com/bgentry/speakeasy,v0.1.0,h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=,d4bfd48b9bf68c87f92c94478ac910bcdab272e15eb909d58f1fb939233f75f0 +github.com/bifurcation/mint,v0.0.0-20180715133206-93c51c6ce115,h1:fUjoj2bT6dG8LoEe+uNsKk8J+sLkDbQkJnB6Z1F02Bc=,40a4bd02b9e3477271638bc17ae8537e2675ace0a9b85d753820e979dbf97f36 +github.com/binance-chain/go-sdk,v1.0.8,h1:mC1Tai9diqIWuKTJmrFLal90OCsgtDvyLEItMvglaHA=,3d0f86f959b38f11174d8ee574e77e5d80d2c672d0720dee519f3708e873b0ca +github.com/binance-chain/ledger-cosmos-go,v0.9.9-binance.1,h1:8mAtw1Tp/BhhTrsXmXM60H1fihcvcKLfo2ZSxShaXKw=,f6dc2bfb4d29db01cad72815615301e089d727110d1d5a0de43e829953e45041 +github.com/biogo/hts,v0.0.0-20160420073057-50da7d4131a3,h1:3b+p838vN4sc37brz9W2HDphtSwZFcXZwFLyzm5Vk28=,93be93b79da8920fb5f02bb2e50a364e2b33dc831229d163e7be70c1010cdb9e +github.com/bitcoinsv/bsvd,v0.0.0-20190609155523-4c29707f7173,h1:2yTIV9u7H0BhRDGXH5xrAwAz7XibWJtX2dNezMeNsUo=,8e1e554ddc232e763fac27ddc0661cfe543163802b0d6bb9a2904bf24756ddc3 +github.com/bitcoinsv/bsvlog,v0.0.0-20181216181007-cb81b076bf2e,h1:6f+gRvaPE/4h0g39dqTNPr9/P4mikw0aB+dhiExaWN8=,89f0c34e6936d82a1629d5d255923ff27c0adeb99709269cf62071e48cb5fbd8 +github.com/bitcoinsv/bsvutil,v0.0.0-20181216182056-1d77cf353ea9,h1:hFI8rT84FCA0FFy3cFrkW5Nz4FyNKlIdCvEvvTNySKg=,4d4923e8743012e1f8ed1a1ef721786fc2d5249cc5dafd96fdd350c485378cfe +github.com/bitly/go-hostpool,v0.0.0-20171023180738-a3a6125de932,h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=,9a55584d7fa2c1639d0ea11cd5b437786c2eadc2401d825e699ad6445fc8e476 +github.com/bitly/go-simplejson,v0.5.0,h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y=,53930281dc7fba8947c1b1f07c82952a38dcaefae23bd3c8e71d70a6daa6cb40 +github.com/blackducksoftware/horizon,v0.0.0-20190625151958-16cafa9109a3,h1:noI1RY2cUFZfdZMIz1+1LzT8ZeuWK703gwmH/ZC2YnQ=,ece353e9e973ce03d131b29c6c00aea53f1b2e507960b389cdfeb2cc317897ef +github.com/blacktear23/go-proxyprotocol,v0.0.0-20180807104634-af7a81e8dd0d,h1:rQlvB2AYWme2bIB18r/SipGiMEVJYE9U0z+MGoU/LtQ=,123c82a455309b3a3118504c0a70771352292abced294dca39a570b89e48adba +github.com/blakesmith/ar,v0.0.0-20190502131153-809d4375e1fb,h1:m935MPodAbYS46DG4pJSv7WO+VECIWUQ7OJYSoTrMh4=,015878daba57ba5ce7228f772b843fffa847d99c7afeb308089bef77f433c510 +github.com/blang/semver,v3.5.1+incompatible,h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=,8d032399cf835b93f7cf641b5477a31a002059eed7888a775f97bd3e9677ad3c +github.com/blevesearch/bleve,v0.8.1,h1:20zBREtGe8dvBxCC+717SaxKcUVQOWk3/Fm75vabKpU=,58a5b5ade8123d54b7510e463c25e1e59e6cd3d98acdcb4d582c42db67c03519 +github.com/blevesearch/blevex,v0.0.0-20180227211930-4b158bb555a3,h1:U6vnxZrTfItfiUiYx0lf/LgHjRSfaKK5QHSom3lEbnA=,defa5966f802eab571cc8d9315323104b776751dd13caae9d8fc0476576d57ca +github.com/blevesearch/go-porterstemmer,v0.0.0-20141230013033-23a2c8e5cf1f,h1:J9ZVHbB2X6JNxbKw/f3Y4E9Xq+Ro+zPiivzgmi3RTvg=,e13cc37d08c58870cdbad544b726934cd62ca6aa2ae35f02598f72e30d7c0f59 +github.com/blevesearch/segment,v0.0.0-20160105220820-db70c57796cc,h1:7OfDAkuAGx71ruzOIFqCkHqGIsVZU0C7PMw5u1bIrwU=,21278826e6ba0f63024a953c480467bf41d6717ae4a87c3021a9f74d2f2ae618 +github.com/blocktree/arkecosystem-adapter,v1.0.4,h1:TkZWCzAgi20CjAMlOpwTDppt6XO7X8Fn5EjSUsuB6kI=,22346af6957b0b8fae47d982605f565e5e16e86bc52a9fdd234b023067896cf2 +github.com/blocktree/bitshares-adapter,v1.0.5,h1:mzYlpip0crtYaDaXbKqtGLAxad83p19HLTVa9LLW3fc=,03ce80398ab59af79feb92b054e5da02a290ef27aef5facb93cdd86de2e0df91 +github.com/blocktree/ddmchain-adapter,v1.0.5,h1:Lx8zD0lOHb9TJ7EcGJQhyvpDkYko6OoV8uwudKRKlJA=,81e65ed5692152fcaa1dbf997f71dc43192abc72dad6fb78b721d742c05c1a7a +github.com/blocktree/eosio-adapter,v1.0.0,h1:cncKE4QbQxDsr8B+HlhU7tywbCtZRsWMln2ek8I5lbc=,cc658d6f9fa5470c5affb4caad58e17637a6d46f8e5d1b3730ed06e570e61959 +github.com/blocktree/ethereum-adapter,v1.1.10,h1:PkmQeRT5ljyCOQZPT0diJo+4G9OqOcJsnRcXeF5fitU=,cf8465db958e214c8196e6311fd5db24f8d28265a37914c2cf9d2dac54a5fd1a +github.com/blocktree/futurepia-adapter,v1.0.12,h1:mL1rDvcM55hKwLhHOkg1v2GwnCEsDniUrqrMG3PK/+4=,ae29bbdb9a4a1ec345f7d220d6a736ed827a307454d0466bb065dacf3d94200d +github.com/blocktree/go-owcdrivers,v1.1.18,h1:KCNm+HczpDfxyUf+Wrvbj/iWwQDJ+ca/FBjm3H06rIY=,65bcca1918d8b9e1048bac14b1393dec246402320b6a5dde20ee6afe84585736 +github.com/blocktree/go-owcrypt,v1.0.3,h1:qfAwJsWYp7WaI26hAwPuFUrMXhD9bWwuGXYWBOLsVes=,f365daad6adfcc5aee14faa1455f772b5e39b1c9ff3598afb1c3645587cb6b2e +github.com/blocktree/moacchain-adapter,v1.0.3,h1:k9drMeekvBsXORortW/zJXaO6CokXVv2EL0/YK3c1/A=,66c87656369c5246bad1527f7385d1cb98bbeda431383f154a23e9bf821a05a2 +github.com/blocktree/nulsio-adapter,v1.1.7,h1:d0xuovBqodBAv8BE/CPZjfe5CNma6FFSP6W3ynJRD0U=,c814c05686483abc345bf4fb997fc61595e738b99cc8a8d36742414f93e948b0 +github.com/blocktree/ontology-adapter,v1.0.8,h1:Lej35ZPPgjS6nP5CEumIUskRNASMZswgrByYSxrWPe0=,fcdeb4c6d8f37a22f52e2938ebc51b4ff1f4cf4116eebce8ecc7591995236853 +github.com/blocktree/openwallet,v1.5.3,h1:6hNj61wLfzEGqbbY0ZOeqGAjSj9snoRSBikgSlWPqZI=,1f169b69cd3ec4a4f82836c2b2178eb162464d6413c09f8170f73a838d28650b +github.com/blocktree/ripple-adapter,v1.0.13,h1:zgJt7onq5+V6pvQ7Kl3xiiSkk3uxuCF07OpwCtJTM8w=,bb7f515a6573eb185da0bebb28bf57364d175ee7f937e18af5b2eac98741464f +github.com/blocktree/virtualeconomy-adapter,v1.1.5,h1:YJ2JKUifSsCjCneM0NUky3WbG0LEm7IKUBmf9EAmAXc=,7a5085b8b0b114e2491032ec6f95e300c28fa309ec5883044d8b954d7d4db06e +github.com/blocktree/waykichain-adapter,v1.0.3,h1:qY/Txh+n4iIJA49rDMj41qpIUj3McjBir8Ls+sX8c3w=,62ea2ff873c84a32d3482c8ec1687221a1e46055b9be18fcd25be584cf2cac5d +github.com/bluele/gcache,v0.0.0-20190518031135-bc40bd653833,h1:yCfXxYaelOyqnia8F/Yng47qhmfC9nKTRIbYRrRueq4=,334accb65479b1b18fb569b08d14eebceb6478ea16abe9fbad2f1c6b6586deb6 +github.com/bluele/slack,v0.0.0-20180528010058-b4b4d354a079,h1:dm7wU6Dyf+rVGryOAB8/J/I+pYT/9AdG8dstD3kdMWU=,2b0055c292b7baa49f56eb9fc710f35f005747ddbef16427d5c985617c3b697d +github.com/bmatcuk/doublestar,v1.1.5,h1:2bNwBOmhyFEFcoB3tGvTD5xanq+4kyOZlB8wFYbMjkk=,81f592b11277591e943b91522497c323fcf0c6b4f3099f495de10f83e8c3e697 +github.com/bmizerany/assert,v0.0.0-20160611221934-b7ed37b82869,h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=,2532a167df77ade7e8012f07c0e3db4d4c15abdb7ffa7b05e1d961408da9a539 +github.com/bmizerany/pat,v0.0.0-20170815010413-6226ea591a40,h1:y4B3+GPxKlrigF1ha5FFErxK+sr6sWxQovRMzwMhejo=,ed04bed4d193e25371ebc6524984da4af9ece5c107fcc82d5aa4914b726706d2 +github.com/bndr/gotabulate,v1.1.2,h1:yC9izuZEphojb9r+KYL4W9IJKO/ceIO8HDwxMA24U4c=,2c1ecc544368e40010082f800c1ee24eaf1b8e0f96fa76a56e4f61dda4cd0d60 +github.com/boltdb/bolt,v1.3.1,h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=,ecaf17b0dbe7c85a017704c72667b2526b492b1a753ce7302a27dd2fb2e6ee79 +github.com/boombuler/barcode,v1.0.0,h1:s1TvRnXwL2xJRaccrdcBQMZxq6X7DvsMogtmJeHDdrc=,ef3832c4d22a09377323980bacd9f5f2ab43d0d20da115e1cfb139e093d7bb9b +github.com/bradfitz/go-smtpd,v0.0.0-20170404230938-deb6d6237625,h1:ckJgFhFWywOx+YLEMIJsTb+NV6NexWICk5+AMSuz3ss=,0a06dd547fed38e2744800b5f4ebae5ac00ee08717ded281510a8d319b8db8f3 +github.com/bradfitz/gomemcache,v0.0.0-20190913173617-a41fca850d0b,h1:L/QXpzIa3pOvUGt1D1lA5KjYhPBAN/3iWdP7xeFS9F0=,eb71acfac0c4ce5f0b6537d8029de98902d83fd38fdcbfd757f06697c6323f78 +github.com/bradfitz/iter,v0.0.0-20190303215204-33e6a9893b0c,h1:FUUopH4brHNO2kJoNN3pV+OBEYmgraLT/KHZrMM69r0=,6883ce0960849ca9c024a4a4e7508ff521da2a3bb66d1974ea2f970a5265ea39 +github.com/bradfitz/latlong,v0.0.0-20140711231157-b74550508561,h1:mz4equOOUOnI4q5E7dyHlRx1x63YEaYwhlVluCDila4=,d1c124508f1825697a2bdb9fac48d2b8805b41f8e546d262fc487d8450962cec +github.com/bradhe/stopwatch,v0.0.0-20180424000511-fd55e776a960,h1:YJWTgxlTgeHlvhe7tZJm0yBcg2GhjDQs8zig5O5vup8=,c2926a4febee7eea0f523b3d4fcaa414c27effc2abc053137a3dbf0b3a4fa324 +github.com/briankassouf/jose,v0.9.2-0.20180619214549-d2569464773f,h1:ZMEzE7R0WNqgbHplzSBaYJhJi5AZWTCK9baU0ebzG6g=,c0b50157ec3c39fbd6ded9d5e6bc763890e6d909db38b337a72876124c2baeeb +github.com/brocaar/lorawan,v0.0.0-20190925120821-154a30dbdce2,h1:51WcQ+VAc/6jZ/8GBJiQ3B7FrT2aXI+YsUx2iG9tJlw=,0082cebaf26ed36c901f9b44b6d785eccc2a0c123088642eac7c9b5711b7d0ca +github.com/bsm/go-vlq,v0.0.0-20150828105119-ec6e8d4f5f4e,h1:D64GF/Xr5zSUnM3q1Jylzo4sK7szhP/ON+nb2DB5XJA=,61fc03674cd72d5a4c55413e8b58fc8eafc58fbb71fb89c719225650754b3469 +github.com/bsm/sarama-cluster,v2.1.15+incompatible,h1:RkV6WiNRnqEEbp81druK8zYhmnIgdOjqSVi0+9Cnl2A=,a8a4867f09704222362b75fa00c9894106a928dc7cf905f1b80ca7bbd1a3b8e5 +github.com/btcsuite/btclog,v0.0.0-20170628155309-84c8d2346e9f,h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=,74ad4defbabf48c98bbb547be1c40c11fa2c286f599412c774d1c5604dc1808d +github.com/btcsuite/btcutil,v0.0.0-20190425235716-9e5f4b9a998d,h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng=,de1ee450ff2cfec2df220fec0d3e265cc812f214892bfad601e142632e2cf3f9 +github.com/btcsuite/go-socks,v0.0.0-20170105172521-4720035b7bfd,h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw=,cc27776f56f7c58c2808af55781e9b3f7d0eb0dc08e4c19c38c6bdf2465ce0e7 +github.com/btcsuite/goleveldb,v1.0.0,h1:Tvd0BfvqX9o823q1j2UZ/epQo09eJh6dTcRp79ilIN4=,13e37462cb2fe5976221f57d357051c1c3cc63a9b0e67e6ed97f98af795d0815 +github.com/btcsuite/snappy-go,v1.0.0,h1:ZxaA6lo2EpxGddsA8JwWOcxlzRybb444sgmeJQMJGQE=,d136165bdbf91780ded5d3ebaba9026f900595e56c19aa0ef29896015eae9627 +github.com/btcsuite/websocket,v0.0.0-20150119174127-31079b680792,h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc=,d45ac16f59082ac369e61c7bbe23153e289cad03619ab8041963d54cd700d6f0 +github.com/btcsuite/winsvc,v1.0.0,h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk=,6893f7a62faec17d7b0856c7464754cab14c4d913e27af5276f6a98b25f3c779 +github.com/buger/jsonparser,v0.0.0-20191004114745-ee4c978eae7e,h1:oJCXMss/3rg5F6Poy9wG3JQusc58Mzk5B9Z6wSnssNE=,7e2dda4c1b4217408903f3b4a1f2cdd93d71bc7682387ba860cfa0cc9fcf88be +github.com/bugsnag/bugsnag-go,v1.5.3,h1:yeRUT3mUE13jL1tGwvoQsKdVbAsQx9AJ+fqahKveP04=,8aaf02df2c1a4e8a5725eea1d91af69c4f9e157c2559a3452388f64a977534c0 +github.com/bugsnag/panicwrap,v1.2.0,h1:OzrKrRvXis8qEvOkfcxNcYbOd2O7xXS2nnKMEMABFQA=,75357d3a5cd89dc04f1f101e02686fc1ef33b4a4f67edb82b3fa63fded3f47e9 +github.com/bwmarrin/discordgo,v0.20.1,h1:Ihh3/mVoRwy3otmaoPDUioILBJq4fdWkpsi83oj2Lmk=,616d49cc107ccd85872b6008f028c4aca021f66381828bb921f15f9e8149988a +github.com/bwmarrin/snowflake,v0.0.0-20180412010544-68117e6bbede,h1:lTJlWdyhwqq7h29GtuIDHW/xi+sMN+JOLMgYAwQ5O74=,2e13ad82f7ae64821f9851a66b4800f1589e413b27b469f28d21970957a3c6da +github.com/c-bata/go-prompt,v0.2.2,h1:uyKRz6Z6DUyj49QVijyM339UJV9yhbr70gESwbNU3e0=,ffe765d86d90afdf8519def13cb027c94a1fbafea7a18e9625210786663436c4 +github.com/c2h5oh/datasize,v0.0.0-20171227191756-4eba002a5eae,h1:2Zmk+8cNvAGuY8AyvZuWpUdpQUAXwfom4ReVMe/CTIo=,b5543f3e104a84e35ac51780968282b455dd30c88730d0da166d8d6512301da6 +github.com/caarlos0/ctrlc,v1.0.0,h1:2DtF8GSIcajgffDFJzyG15vO+1PuBWOMUdFut7NnXhw=,e4b5e9dd37cee2d47ff1c5eeba9a4b6e2b778c349a3615ca9653531f035a3ca6 +github.com/cactus/go-statsd-client/statsd,v0.0.0-20191030180650-a68a2246f89c,h1:rrLWPlpOKwnBpVUXitbgM3+Nie1eBaFfBZqfiPpxVj8=,cbb94149ec688419a91406b374955946c3679b1dde0752d7c0ffdc87432cd0b3 +github.com/caddyserver/caddy,v1.0.3,h1:i9gRhBgvc5ifchwWtSe7pDpsdS9+Q0Rw9oYQmYUTw1w=,029f14052f1ec9937c4028f3231899bf5391d5eeb7f58795d5d470a6f4c338a7 +github.com/campoy/unique,v0.0.0-20180121183637-88950e537e7e,h1:V9a67dfYqPLAvzk5hMQOXYJlZ4SLIXgyKIE+ZiHzgGQ=,4bc20f70e0b170ecdabd740a5de012d05f4c9149e2882fbdb303dc1b1793a77e +github.com/casbin/casbin,v1.9.1,h1:ucjbS5zTrmSLtH4XogqOG920Poe6QatdXtz1FEbApeM=,e2ef71d15eb595374d27961d255941b50691f9eaa91b5590f081fe3a4ab195c2 +github.com/cavaliercoder/go-cpio,v0.0.0-20180626203310-925f9528c45e,h1:hHg27A0RSSp2Om9lubZpiMgVbvn39bsUmW9U5h0twqc=,08b68e1d424b545418828c05c46bce5d795bbb8b534871667650ec6b3e7b33a6 +github.com/cenk/backoff,v2.2.1+incompatible,h1:djdFT7f4gF2ttuzRKPbMOWgZajgesItGLwG5FTQKmmE=,e3d1c641f85f548370aedc6bae3d4b975b09e3b2d1d9060f0e72bd5e2710d4c9 +github.com/cenkalti/backoff,v2.2.1+incompatible,h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=,f8196815a1b4d25e5b8158029d5264801fc8aa5ff128ccf30752fd169693d43b +github.com/cenkalti/backoff/v3,v3.0.0,h1:ske+9nBpD9qZsTBoF41nW5L+AIuFBKMeze18XQ3eG1c=,c69bf77e7b43cb3935d763c24af3810d9869a664bbcd26ffad9d3dc1bf602006 +github.com/census-instrumentation/opencensus-proto,v0.2.1,h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=,b3c09f3e635d47b4138695a547d1f2c7138f382cbe5a8b5865b66a8e08233461 +github.com/centrify/cloud-golang-sdk,v0.0.0-20190214225812-119110094d0f,h1:gJzxrodnNd/CtPXjO3WYiakyNzHg3rtAi7rO74ejHYU=,dc3de1393d7ae63ce35393630417ff8c5421a2a03cbf1a20680c7d57a74cd311 +github.com/certifi/gocertifi,v0.0.0-20180118203423-deb3ae2ef261,h1:6/yVvBsKeAw05IUj4AzvrxaCnDjN4nUqKjW9+w5wixg=,054d6c3a6f8d78fba2f08fbc2f23ec839d5a4aead4a184270d87d095c80eb6dc +github.com/cespare/cp,v1.1.1,h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU=,25f2ed5bac9ac3c1891ff364b213f6b7b0ee2e7aed13510738ced93ea71860e3 +github.com/cespare/xxhash,v1.1.0,h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=,fe98c56670b21631f7fd3305a29a3b17e86a6cce3876a2119460717a18538e2e +github.com/cespare/xxhash/v2,v2.1.0,h1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReGkA=,655feb22a395d9f56315280770d386eb99cdca79a97970812dbd3b30a7940638 +github.com/chaseadamsio/goorgeous,v0.0.0-20170901132237-098da33fde5f,h1:REH9VH5ubNR0skLaOxK7TRJeRbE2dDfvaouQo8FsRcA=,f81f4ef8ac52852b232ea971d009ec88007f1258c29e10e49918a31a99c6c4cc +github.com/checkpoint-restore/go-criu,v0.0.0-20190109184317-bdb7599cd87b,h1:T4nWG1TXIxeor8mAu5bFguPJgSIGhZqv/f0z55KCrJM=,1d1f5c6e529c87259305d8ed6bf4d381dabbf85458de187981204339e251a5be +github.com/cheekybits/genny,v1.0.0,h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE=,770f3e01425b9b0a87a5e0b29fc6ac2cfa67a3f1265aafb16c96a47bafc304e4 +github.com/cheekybits/is,v0.0.0-20150225183255-68e9c0620927,h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764=,f7bf9ac5b1fc574ef5a373382909af550ef1a7f01182469eaa12e18c7c5fc7cb +github.com/cheggaaa/pb,v2.0.7+incompatible,h1:gLKifR1UkZ/kLkda5gC0K6c8g+jU2sINPtBeOiNlMhU=,383b717f271a2471e57ac52f64dbb77304ec1c0b53c5efeb7a1392668f59d0b4 +github.com/cheggaaa/pb/v3,v3.0.1,h1:m0BngUk2LuSRYdx4fujDKNRXNDpbNCfptPfVT2m6OJY=,781be3118614dfaeb2df44d31d8af36c703c2aaed18e9ca49fa4ef9ba1539236 +github.com/chewxy/hm,v1.0.0,h1:zy/TSv3LV2nD3dwUEQL2VhXeoXbb9QkpmdRAVUFiA6k=,68ab03d9f8cb3d92d6c8234cfd879004be2fd69457d2c9fa6834d1c6ddb22b43 +github.com/chewxy/math32,v1.0.4,h1:dfqy3+BbCmet2zCkaDaIQv9fpMxnmYYlAEV2Iqe3DZo=,7885f637bb90729d04f125e030542b9a6999f9e5dffd3294baffbcdd548bbc3e +github.com/chrismalek/oktasdk-go,v0.0.0-20181212195951-3430665dfaa0,h1:CWU8piLyqoi9qXEUwzOh5KFKGgmSU5ZhktJyYcq6ryQ=,094a132bc1e950677f75e570b17a52f103edd6acd3ec1c0943cf9cda3cd6355a +github.com/chromedp/cdproto,v0.0.0-20191009033829-c22f49c9ff0a,h1:AuIGvB6IuWpMEdfKQ+t77D6dzLpNftzxAsktehYyWn8=,bf85eeebdc65b1e90d851b42f56a3dbf5bcff4923aa426692a1c0d0a1727a522 +github.com/chromedp/chromedp,v0.5.1,h1:PAqhoCWCHzRphYnmmxLSiYk7EEwDplCm4woTCCaV2cQ=,59cd1ab42eeb90e32cc60e77a8fbb19ca629603200d5bd40d611f780e646062b +github.com/chzyer/logex,v1.1.10,h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=,2c94771c1e335a2c58a96444b3768b8e00297747d6ce7e7c14bab2e8b39d91bd +github.com/chzyer/readline,v0.0.0-20180603132655-2972be24d48e,h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=,3dc842677887278fb33d25078d375ae6a7a94bb77a8d205ee2230b581b6947a6 +github.com/chzyer/test,v0.0.0-20180213035817-a1ea475d72b1,h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=,ad8550bed3c4a94bbef57b9fc5bb15806eaceda00925716404320580d60e2f7d +github.com/cihub/seelog,v0.0.0-20170130134532-f561c5e57575,h1:kHaBemcxl8o/pQ5VM1c8PVE1PubbNx3mjUr09OqWGCs=,fc279208e6094fb22c8ea651c6e9794844069693c9b916c225276c54f7e76bfe +github.com/circonus-labs/circonus-gometrics,v2.3.1+incompatible,h1:C29Ae4G5GtYyYMm1aztcyj/J5ckgJm2zwdDajFbx1NY=,d8081141497e3cd34844df66af016c7900d58b324fb689e17e57bc053d91c9ba +github.com/circonus-labs/circonusllhist,v0.1.3,h1:TJH+oke8D16535+jHExHj4nQvzlZrj7ug5D7I/orNUA=,4dc805d9735dd9ca9b8875c0ad23126abb5bc969c5a40c61b5bc891808dbdcb6 +github.com/clbanning/mxj,v1.8.4,h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=,8947cf617bdd9efc62817c8ddb17bafe497f35abdf10a3c60f295e387f633f70 +github.com/client9/misspell,v0.3.4,h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=,a3af206372e131dd10a68ac470c66a1b18eaf51c6afacb55b2e2a06e39b90728 +github.com/cloudflare/backoff,v0.0.0-20161212185259-647f3cdfc87a,h1:8d1CEOF1xldesKds5tRG3tExBsMOgWYownMHNCsev54=,2aea6d1528c42cf5f111e035bba564fd0481cb4ddb3b50f783f2481d855947cb +github.com/cloudflare/cfssl,v1.4.0,h1:TdyQbj/bDUMUHf2IkcHU2EHUmzCmRLuJ3fFd8EYMg1E=,845fc5f4a7f4c2356d676916fdd7b4b2217b76c8f9b7a960290ab8884d6f8e0e +github.com/cloudflare/cloudflare-go,v0.10.4,h1:7C1D9mtcNFZLCqmhkHK2BlwKKm9fi4cBqY6qpYtQv5E=,e8f6ee817c9b807c98559ff87d4ed7a284738d9dc253b6db7520911d93bd81e3 +github.com/cloudflare/go-metrics,v0.0.0-20151117154305-6a9aea36fb41,h1:/8sZyuGTAU2+fYv0Sz9lBcipqX0b7i4eUl8pSStk/4g=,9176a680ad7a72cf717e3e01ee1ca6b292cb576b543e12ff1770cc58957bc222 +github.com/cloudflare/golz4,v0.0.0-20150217214814-ef862a3cdc58,h1:F1EaeKL/ta07PY/k9Os/UFtwERei2/XzGemhpGnBKNg=,75832d1c2989b2a0d7eb8d2cec300f6d457254d42927a23f522b164833e791d4 +github.com/cloudflare/redoctober,v0.0.0-20171127175943-746a508df14c,h1:p0Q1GvgWtVf46XpMMibupKiE7aQxPYUIb+/jLTTK2kM=,e69334393aec994f9ba55bbdfa8a65c0cfa46080230068c44ca16a85c0a74079 +github.com/cloudfoundry-community/go-cfclient,v0.0.0-20190201205600-f136f9222381,h1:rdRS5BT13Iae9ssvcslol66gfOOXjaLYwqerEn/cl9s=,f01d41c3c911b59bf717674690799c978f3a841ef695c7ee09f4afe5f7c96e64 +github.com/cloudfoundry-incubator/candiedyaml,v0.0.0-20170901234223-a41693b7b7af,h1:6Cpkahw28+gcBdnXQL7LcMTX488+6jl6hfoTMRT6Hm4=,325af9d6827b8d120a72992c38ba776187fbd947a39c9f1928a43a1a2b262453 +github.com/cloudfoundry/bosh-agent,v2.271.0+incompatible,h1:277mM9hsUzyrd5Qd/5e1LFwiobIYorE7vTBRZohRV8s=,42e253b855d03655ec2cf59ab01a14aa0037f25029517be595dda26ff9a2a552 +github.com/cloudfoundry/bosh-utils,v0.0.0-20191026100324-0b6803ec5382,h1:Rrpgz+K2Zso//XUmqbGlnYi9rw6EtYJ4uLlTNSnSBIw=,c08bbf97e510b2de271fd64f5b2acedfa011b4fd3f30092804992084c67b68b7 +github.com/cloudfoundry/gosigar,v1.1.0,h1:V/dVCzhKOdIU3WRB5inQU20s4yIgL9Dxx/Mhi0SF8eM=,53acb43e5111c6af6af138e1144907bb5f9bf8abc28e71a703502f92c13ba274 +github.com/cloudfoundry/sonde-go,v0.0.0-20171206171820-b33733203bb4,h1:cWfya7mo/zbnwYVio6eWGsFJHqYw4/k/uhwIJ1eqRPI=,6124fdcac54e1baf09703ed2b938a4e2bb55d9cd20f78451f25c16638a95f62d +github.com/cockroachdb/apd,v1.1.0,h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=,fef7ec2fae220f84bfacb17fbfc1b04a666ab7f6fc04f3ff6d2b1e05c380777d +github.com/cockroachdb/apd/v2,v2.0.1,h1:y1Rh3tEU89D+7Tgbw+lp52T6p/GJLpDmNvr10UWqLTE=,9f1c35b8118f70f08150bf5e9da225fa1201f5d0f8c22f326468ea22ab6b791d +github.com/cockroachdb/cockroach-go,v0.0.0-20190916165215-ad57a61cc915,h1:QX2Zc22B15gdWwDCwS7BXmbeD/SWdcRK12gOfZ5BsIs=,e3faa1cdf2a15357d1e2eb200b3bdb81dae3fb084cb04534e0caf27a68487a88 +github.com/cockroachdb/datadriven,v0.0.0-20190809214429-80d97fb3cbaa,h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y=,170480bf3daa133144f2578e3f051f0fd98313666642cab64cef3359753a5c32 +github.com/codahale/hdrhistogram,v0.0.0-20161010025455-3a0bb77429bd,h1:qMd81Ts1T2OTKmB4acZcyKaMtRnY5Y44NuXGX2GFJ1w=,e7e117da64da2f921b1f9dc57c524430a7f74a78c4b0bad718d85b08e8374e78 +github.com/codegangsta/inject,v0.0.0-20150114235600-33e0aa1cb7c0,h1:sDMmm+q/3+BukdIpxwO365v/Rbspp2Nt5XntgQRXq8Q=,0a324d56992bffd288fa70a6d10eb9b8a9467665b0b1eb749ac6ae80e8977ee2 +github.com/codegangsta/negroni,v1.0.0,h1:+aYywywx4bnKXWvoWtRfJ91vC59NbEhEY03sZjQhbVY=,2e6301aa682a7c38305f2ee72b276181cd0990f224f9fe115a433a5beb138488 +github.com/codeskyblue/go-sh,v0.0.0-20190412065543-76bd3d59ff27,h1:HHUr4P/aKh4quafGxDT9LDasjGdlGkzLbfmmrlng3kA=,77348ab27860460a015d0e65d08f18ed2194c13981f5fd722143a6e0c2dbb589 +github.com/confluentinc/confluent-kafka-go,v1.1.0,h1:HIW7Nkm8IeKRotC34mGY06DwQMf9Mp9PZMyqDxid2wI=,bc9aee1c8052340809bc43bf015a183985ec3426d404c34acfa3970e3b245340 +github.com/container-storage-interface/spec,v1.2.0,h1:bD9KIVgaVKKkQ/UbVUY9kCaH/CJbhNxe0eeB4JeJV2s=,86ecb02d57af97c9a4de8f2f3cacbceb5c7f2f96ee007133e0cfb9525ce45177 +github.com/containerd/cgroups,v0.0.0-20191011165608-5fbad35c2a7e,h1:3bt+8T1I/CuYx+a5ww32+UT4fc9x8iRiXrhfduFTlBU=,4646f14f27a365ff08abb1266b7ca4dffc1acd5e8e74b57211acbba22b496d46 +github.com/containerd/console,v0.0.0-20181022165439-0650fd9eeb50,h1:WMpHmC6AxwWb9hMqhudkqG7A/p14KiMnl6d3r1iUMjU=,62a7f1da11b3be4c0ef4f9f03b99dcf59dc988f062749f35e4e6bb585fb4e4fe +github.com/containerd/containerd,v1.3.0,h1:xjvXQWABwS2uiv3TWgQt5Uth60Gu86LTGZXMJkjc7rY=,e3f529147f2c909c85ac461126ad092a3c5d5a2abcc4f3c22600685af6dc2f08 +github.com/containerd/continuity,v0.0.0-20190827140505-75bee3e2ccb6,h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=,ef1a3a4c2c1508d293eb2730e47e9601cba19d939393b1018d8e476b30dfd90b +github.com/containerd/fifo,v0.0.0-20190816180239-bda0ff6ed73c,h1:KFbqHhDeaHM7IfFtXHfUHMDaUStpM2YwBR+iJCIOsKk=,0c1b858ee9dd28bd915a3f7bd108b98b1d689be3c14535e7e8aee4a60c4a72c0 +github.com/containerd/go-runc,v0.0.0-20190923131748-a2952bc25f51,h1:vmF3zULCGpZ4QJCCLsGUXX7tNXW+0x3r9owerRAmRaU=,76ce6296dc07f1f5957867e9a5925cf9e16c69ad2b635f74a4ec471e6672ee51 +github.com/containerd/ttrpc,v0.0.0-20191028202541-4f1b8fe65a5c,h1:+RqLdWzn0xFunb+sxXaEzHOg8NuEG/eaI+9C1xXX8Mw=,f43884f8f37259c4b50a4413092064f35abd03b9db3bbe2ca3264b5a4b591b04 +github.com/containerd/typeurl,v0.0.0-20190911142611-5eb25027c9fd,h1:bRLyitWw3PT/2YuVaCKTPg0cA5dOFKFwKtkfcP2dLsA=,aa4e0823acf7b686a9521617134a171c5b5813de302e3fba742cd3b7f43ba944 +github.com/containernetworking/cni,v0.7.1,h1:fE3r16wpSEyaqY4Z4oFrLMmIGfBYIKpPrHK31EJ9FzE=,b83f1b8e9bba747e41512737383da57e517cf425beb1bd58882904dae9348b1d +github.com/containers/image,v3.0.2+incompatible,h1:B1lqAE8MUPCrsBLE86J0gnXleeRq8zJnQryhiiGQNyE=,dadc25bfff923d4f2c8b570471be3b0fd1449f42251fb6c318b68e04f6d47b3a +github.com/containers/storage,v1.12.13,h1:GtaLCY8p1Drlk1Oew581jGvB137UaO+kpz0HII67T0A=,08f5ee958be629b73ff02296eb11f4b0698dbd90e585ce019c5428a8e1d371d4 +github.com/containous/flaeg,v1.4.1,h1:VTouP7EF2JeowNvknpP3fJAJLUDsQ1lDHq/QQTQc1xc=,d097191570bb92f920cd15500a93205e6e93b5ee4723a51c9b8e3bfbcfaae505 +github.com/corbym/gocrest,v1.0.3,h1:gwEdq6RkTmq+09CTuM29DfKOCtZ7G7bcyxs3IZ6EVdU=,f13221d177442318b04f468fa57ea92bd9892d86e7cf7bb7299e0c58cea9df48 +github.com/coredns/coredns,v1.1.2,h1:bAFHrSsBeTeRG5W3Nf2su3lUGw7Npw2UKeCJm/3A638=,cbf720a9af4fdc5be08b0eea67fe219bb08c75292e22dca90095bf45cbd4a926 +github.com/coreos/bbolt,v1.3.3,h1:n6AiVyVRKQFNb6mJlwESEvvLoDyiTzXX7ORAUlkeBdY=,63ea574f28bd03b6d2a82304e0f7c96dcb30fa048311a4c8c3ad512dbacc4630 +github.com/coreos/clair,v0.0.0-20180919182544-44ae4bc9590a,h1:glxUtT0RlaVJU86kg78ygzfhwW6D+uj5H+aOK01QDgI=,3bc8c4b06a61c5673fcc69d5278b3a5313633fca1166e94a7140c363399c3dc6 +github.com/coreos/etcd,v3.3.17+incompatible,h1:f/Z3EoDSx1yjaIjLQGo1diYUlQYSBrrAQ5vP8NjwXwo=,d7ca8db509166ce05482c9b3e80cfb8d1086691901e80202f571d152da912153 +github.com/coreos/go-etcd,v2.0.0+incompatible,h1:bXhRBIXoTm9BYHS3gE0TtQuyNZyeEMux2sDi4oo5YOo=,4b226732835b9298af65db5d075024a5971aa11ef4b456899a3830bccd435b07 +github.com/coreos/go-iptables,v0.4.3,h1:jJg1aFuhCqWbgBl1VTqgTHG5faPM60A5JDMjQ2HYv+A=,4626df8f719f93e5d66bd995d586ae3540c24b2203c0d2aab7c6d5e60f89a3dc +github.com/coreos/go-oidc,v2.1.0+incompatible,h1:sdJrfw8akMnCuUlaZU3tE/uYXFgfqom8DBE9so9EBsM=,e2e123270614dd7d47d95ae1fce80a9102df019f9e820d4f5cf5c92c64e1ad91 +github.com/coreos/go-semver,v0.3.0,h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=,b2fc075395ffc34cff4b964681d0ae3cd22096cfcadd2970eeaa877596ceb210 +github.com/coreos/go-systemd,v0.0.0-20190719114852-fd7a80b32e1f,h1:JOrtw2xFKzlg+cbHpyrpLDmnN1HqhBfnX7WDiW7eG2c=,22237f0aed3ab6018a1025c65f4f45b4c05f9aa0c0bb9ec880294273b9a15bf2 +github.com/coreos/pkg,v0.0.0-20180928190104-399ea9e2e55f,h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=,7fe161d49439a9b4136c932233cb4b803b9e3ac7ee46f39ce247defc4f4ea8d7 +github.com/coreos/rkt,v1.30.0,h1:Kkt6sYeEGKxA3Y7SCrY+nHoXkWed6Jr2BBY42GqMymM=,436e294b735bada49407ad3c066ae251ef105ce59076ef8f0f732c586a72970e +github.com/cosiner/argv,v0.0.0-20170225145430-13bacc38a0a5,h1:rIXlvz2IWiupMFlC45cZCXZFvKX/ExBcSLrDy2G0Lp8=,deb11c1c7a2fa44b3497731d497b3d7be5a51cf696ed43280e01822e2eed9b96 +github.com/cosmos/cosmos-sdk,v0.35.0,h1:EPeie1aKHwnXtTzKggvabG7aAPN+DDmju2xquvjFwao=,ccc975b48e3b40f4eb054e28e9243ecb48c0d8ecdf52b9512da26a8200cc7c43 +github.com/cosmos/go-bip39,v0.0.0-20180819234021-555e2067c45d,h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=,e41d7ea781b15421a4690bedf78543f2eaad00c36c439dd4973131dec1985177 +github.com/cosmos/ledger-cosmos-go,v0.10.3,h1:Qhi5yTR5Pg1CaTpd00pxlGwNl4sFRdtK1J96OTjeFFc=,f1089701d8868e4ff3fd9e9a4104476963f725a713ee2a476b4ef8094a0bca20 +github.com/cosmos/ledger-go,v0.9.2,h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI=,a77b2063a64133d8dda638d5d602071429d7e2500576bfff5c1763f8572a8517 +github.com/couchbase/go-couchbase,v0.0.0-20191031153726-96c2e23d589a,h1:eKnoG+AQQQIxHEcBIbudmwLJv3S9UQU6oGHzvqhttqE=,5dd3e610f24adb44b31e7ecc6a80a8974b769bd622d569c69fb98bd02610bbef +github.com/couchbase/gomemcached,v0.0.0-20191004160342-7b5da2ec40b2,h1:vZryARwW4PSFXd9arwegEywvMTvPuXL3/oa+4L5NTe8=,5b9a280cd2d546cd0d70fbd6828e73fa0b07fb9d3c0b6bff88d8e23d8e4256f4 +github.com/couchbase/goutils,v0.0.0-20190315194238-f9d42b11473b,h1:bZ9rKU2/V8sY+NulSfxDOnXTWcs1rySqdF1sVepihvo=,a2820e0f01d8c944b70c70515b9924f41b450f3688d19ad4d506b2b9b367c433 +github.com/couchbase/vellum,v0.0.0-20190111184608-e91b68ff3efe,h1:2o6Y7KMjJNsuMTF8f2H2eTKRhqH7+bQbjr+D+LnhE5M=,06e3ca28a98c95bcdfd909168e1dcf45a6667ef59ad59112a01e6bbdcf591e84 +github.com/couchbaselabs/go-couchbase,v0.0.0-20190708161019-23e7ca2ce2b7,h1:1XjEY/gnjQ+AfXef2U6dxCquhiRzkEpxZuWqs+QxTL8=,3429eb55dd38b07bab5e9a57a3e2451449b49bdbc6f16585f8b7557067572499 +github.com/cpu/goacmedns,v0.0.1,h1:GeIU5chKys9zmHgOAgP+bstRaLqcGQ6HJh/hLw9hrus=,12acca48bb444f3832a87b8d238e573bbfa60e5c25dfcf6787a003dfacaf055d +github.com/cpuguy83/go-md2man,v1.0.10,h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=,b9b153bb97e2a702ec5c41f6815985d4295524cdf4f2a9e5633f98e9739f4d6e +github.com/cpuguy83/go-md2man/v2,v2.0.0,h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=,f2fdd06287a80f1bea5552f572d7f2314ec829285a3040b63469e0635f66fb6d +github.com/creack/goselect,v0.1.0,h1:4QiXIhcpSQF50XGaBsFzesjwX/1qOY5bOveQPmN9CXY=,24d8028970032b1a45091ad8ff9b9c280693def1433cb5948ed92c0c975226ea +github.com/creack/pty,v1.1.7,h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A=,e7ea3403784d186aefbe84caed958f8cba2e72a04f30cdb291ece19bec39c8f3 +github.com/cskr/pubsub,v1.0.2,h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0=,39e40a42c10058c188f331ed0bb660a0504d7c2ddd9e835a9970786fdc35feb0 +github.com/cupcake/rdb,v0.0.0-20161107195141-43ba34106c76,h1:Lgdd/Qp96Qj8jqLpq2cI1I1X7BJnu06efS+XkhRoLUQ=,019a246ac0d7f6fcf3758587a031767730cfb824003c311686a4eb552a1dcc57 +github.com/cweill/gotests,v1.5.3,h1:k3t4wW/x/YNixWZJhUIn+mivmK5iV1tJVOwVYkx0UcU=,7ced96d4223a0afcd41922c4d3ae064493dd5bedbc72f6541716fce1cab24b7d +github.com/cxr29/aliyun-openapi-go-sdk,v0.0.0-20151123082822-0b043e4d1e0c,h1:WEWetvNRZlk7JW3M4fycSA3f/2xZGxRdrwmpgRkGoQc=,6c80128745e3acdd01f59bc6c6e3a1f24193e89eb627ad6dcc615e763878b6e4 +github.com/cyphar/filepath-securejoin,v0.2.2,h1:jCwT2GTP+PY5nBz3c/YL5PAIbusElVrPujOBSCj8xRg=,d022873dbb9e8d3b7a43c9dedbea54dfc9a6c15f9632ba522a1257e8b948c100 +github.com/cznic/b,v0.0.0-20181122101859-a26611c4d92d,h1:SwD98825d6bdB+pEuTxWOXiSjBrHdOl/UVp75eI7JT8=,1c34b27ce98f70cb0e97c2bbe0bdae216cc1ea6b2617b0e984e2ce30adc06338 +github.com/cznic/fileutil,v0.0.0-20181122101858-4d67cfea8c87,h1:94XgeeTZ+3Xi9zsdgBjP1Byx/wywCImjF8FzQ7OaKdU=,109b4c91722a0f9a4f941d77eff34270684e53ca36e7d14ab2cd4a4e80841d73 +github.com/cznic/golex,v0.0.0-20181122101858-9c343928389c,h1:G8zTsaqyVfIHpgMFcGgdbhHSFhlNc77rAKkhVbQ9kQg=,d2b11a6e0e1de5125a2d550650b4cbb7bf44280ebf1cda74ef4a63e3cfa11012 +github.com/cznic/internal,v0.0.0-20181122101858-3279554c546e,h1:58AcyflCe84EONph4gkyo3eDOEQcW5HIPfQBrD76W68=,bc177d001529bca3f46aa84855db4e783a041c188d3ba237f68fa4522bdca74b +github.com/cznic/kv,v0.0.0-20181122101858-e9cdcade440e,h1:8ji4rZgRKWMQUJlPNEzfzCkX7yFAZFR829Mrh7PXxLA=,4f992bdaf6d17487c7b16669b6d55afa76b321e63f8e4b6a6d1126b44b18b0d9 +github.com/cznic/lldb,v1.1.0,h1:AIA+ham6TSJ+XkMe8imQ/g8KPzMUVWAwqUQQdtuMsHs=,ddec7228568547a5fbfbc6a91208cbcafeed4338a38c41d483448957e4bec186 +github.com/cznic/mathutil,v0.0.0-20181122101859-297441e03548,h1:iwZdTE0PVqJCos1vaoKsclOGD3ADKpshg3SRtYBbwso=,8f69a36f60d885e011b0a90b91246a7e88223cb2883dc6e71eab3f42d653231b +github.com/cznic/parser,v0.0.0-20181122101858-d773202d5b1f,h1:DUtr2TvhM9rmiHKVJWoLqDY2+MdxljW9hlaS/oYoi1c=,18b746a4090720bd9dfe219d0f7bb7fb28565df70417208d7e99dfd79f1ea264 +github.com/cznic/ql,v1.2.0,h1:lcKp95ZtdF0XkWhGnVIXGF8dVD2X+ClS08tglKtf+ak=,05164e379d43eaada0efdd763a50a9ef8f4b7f73a5de7ab866093bb25a4fb747 +github.com/cznic/sortutil,v0.0.0-20181122101858-f5f958428db8,h1:LpMLYGyy67BoAFGda1NeOBQwqlv7nUXpm+rIVHGxZZ4=,67783879c1ae4472fdabb377b1772e4e4c5ced181528c2fc4569b565cb47a57b +github.com/cznic/strutil,v0.0.0-20181122101858-275e90344537,h1:MZRmHqDBd0vxNwenEbKSQqRVT24d3C05ft8kduSwlqM=,867902276444cbffca84d9d5f63754e8b22092d93a94480d8dfebd234ac8ffbd +github.com/cznic/y,v0.0.0-20181122101901-b05e8c2e8d7b,h1:gvFsf4zJcnW6GRN+HPGTxwuw+7sTwzmoeoBQQCZDEnk=,8c84f5e4f9dc5f0809d8ad22d057e404c3e8644dc28e8fc52abbb1d2350f8d3e +github.com/cznic/zappy,v0.0.0-20181122101859-ca47d358d4b1,h1:ytLS5Cgkxq6jObotJ+a13nsejdqzLFPliDf8CQ8OkAA=,505c19b52924ee21b65611bc45640d3ff4671e50ee04f7c17c38342190645595 +github.com/d2g/dhcp4,v0.0.0-20170904100407-a1d1b6c41b1c,h1:Xo2rK1pzOm0jO6abTPIQwbAmqBIOj132otexc1mmzFc=,15df9468cf548a626e1319e92d550432512c4319cf555bf278ea9215de3504e3 +github.com/daaku/go.zipexe,v1.0.0,h1:VSOgZtH418pH9L16hC/JrgSNJbbAL26pj7lmD1+CGdY=,74d7a0242c03c3c03220e56a59da5f97d3478743250740df538e05e6b609f553 +github.com/danwakefield/fnmatch,v0.0.0-20160403171240-cbb64ac3d964,h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=,f601e8d25a43ed32e00851e1686a93b0175dadea8f4e32c8af2f1533f20736bc +github.com/dave/jennifer,v1.2.0,h1:S15ZkFMRoJ36mGAQgWL1tnr0NQJh9rZ8qatseX/VbBc=,85b37a1b99b7d67664389b8c11b7174f521a396bb59d4e0e766df16336a7f112 +github.com/dave/services,v0.1.0,h1:7isGzpZHJWmOYTV+Pn3f6gpQUmrveJqsQpAkH0HXFbU=,e52a7ffba3aa07cca4888e08248771211abd139928b5cde9b228a61da88eddcc +github.com/davecgh/go-spew,v1.1.1,h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=,6b44a843951f371b7010c754ecc3cabefe815d5ced1c5b9409fb2d697e8a890d +github.com/davecgh/go-xdr,v0.0.0-20161123171359-e6a2ba005892,h1:qg9VbHo1TlL0KDM0vYvBG9EY0X0Yku5WYIPoFWt8f6o=,11cb87912b5288e13534cb396935694c257eb9164ffc20ce21e3bc9955edd82a +github.com/daviddengcn/go-colortext,v0.0.0-20180409174941-186a3d44e920,h1:d/cVoZOrJPJHKH1NdeUjyVAWKp4OpOT+Q+6T1sH7jeU=,159d727adf4f0763ec3dc6156fd46531a2afbffdc17feeb6b5ffe2eb54b35d41 +github.com/davyxu/cellnet,v4.1.0+incompatible,h1:zDRqhkFRhBTD7ajra2888aoRLN1qlv8LV8+qHg/emO4=,f085f088b68b2e379a6dc37501ef2c9809836cfac147a30ed3025571c2d57df7 +github.com/davyxu/golog,v0.1.0,h1:SsV3m2x37sCzFaQzq5OHc5S+PE2VMiL7XUx34JCa7mo=,a3c240bc4b958fa4b4e73caa59c28fc658afbabdb1f28b237874803ca96dcb1f +github.com/dchest/blake256,v1.0.0,h1:6gUgI5MHdz9g0TdrgKqXsoDX+Zjxmm1Sc6OsoGru50I=,9a9ed00a3024f2f7480b59c7b2ee1013cae3026d7dc2f065ce225dcce8cf357e +github.com/dchest/siphash,v1.2.1,h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4=,877a468e533e28c777c59b3dfea175b38a1f0bc1f8551e3a9e1739b1821c7e3e +github.com/dchest/uniuri,v0.0.0-20160212164326-8902c56451e9,h1:74lLNRzvsdIlkTgfDSMuaPjBr4cf6k7pwQQANm/yLKU=,41db9fb52a841d11d8592a1d4f56e8a440e3991b699ae0f95ab5f5a7b2aeb24c +github.com/deckarep/golang-set,v1.7.1,h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ=,86606609df42529fda55a15475b495f993f0c1cc4be6e1e50a9165a514d1ed71 +github.com/decker502/dnspod-go,v0.2.0,h1:6dwhUFCYbC5bgpebLKn7PrI43e/5mn9tpUL9YcYCdTU=,381fb0bb29ac973f318db3d464f76e5d3016d4963c78ccd7df7dbc4231a68455 +github.com/decred/base58,v1.0.0,h1:BVi1FQCThIjZ0ehG+I99NJ51o0xcc9A/fDKhmJxY6+w=,75b1a2c78759ee2e8755156806ce770c9199464c2d58541388d5ec7c000c99e1 +github.com/decred/dcrd/chaincfg,v1.5.1,h1:u1Xbq0VTnAXIHW5ECqrWe0VYSgf5vWHqpSiwoLBzxAQ=,7344cd4dc90a82342c90811c8180b1fef6c79e9c49caa38135f271cf0ecb056f +github.com/decred/dcrd/chaincfg/chainhash,v1.0.2,h1:rt5Vlq/jM3ZawwiacWjPa+smINyLRN07EO0cNBV6DGU=,a8b24e2c4e64015430b8a6502f9e8c3eeea246021638884dc510508eccda31a0 +github.com/decred/dcrd/chaincfg/v2,v2.0.2,h1:VeGY52lHuYT01tIGbvYj+OO0GaGxGaJmnh+4vGca1+U=,906dec975cf574c55f2eb588dc91a4ddd6be273eaddfbeb45288ea6aebcc6306 +github.com/decred/dcrd/crypto/blake256,v1.0.0,h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=,cd8bbdae14641f0ba44430fc66990dd37bbfcf1e21a965a9fd1871d16cac127d +github.com/decred/dcrd/dcrec,v1.0.0,h1:W+z6Es+Rai3MXYVoPAxYr5U1DGis0Co33scJ6uH2J6o=,a1e16c5ef3633f2dfa23c052778552cf9300821197f5b2dc547e20dd9d45756b +github.com/decred/dcrd/dcrec/edwards,v1.0.0,h1:UDcPNzclKiJlWqV3x1Fl8xMCJrolo4PB4X9t8LwKDWU=,7ed52f3316f5a47c5925e23bebf5016ecfd75e7ac340714b4b94b0e25bdf0611 +github.com/decred/dcrd/dcrec/secp256k1,v1.0.2,h1:awk7sYJ4pGWmtkiGHFfctztJjHMKGLV8jctGQhAbKe0=,5fa2c17fd611665a39e6435283445ec3b46a5b52d14661e04bd1f7ef295ba9d3 +github.com/decred/dcrd/dcrutil,v1.4.0,h1:xD5aUqysGQnsnP1c9J0kGeW8lDIwFGC3ja/gE3HnpCs=,6de50428375fca174f4861f8aa45549360e7733bca0184a882448f0b9f94be2e +github.com/decred/dcrd/dcrutil/v2,v2.0.0,h1:HTqn2tZ8eqBF4y3hJwjyKBmJt16y7/HjzpE82E/crhY=,fa91eb7c5062e0f3f6e7d1b9d8e1a89698f6ee6e7f8f4941929f6d89a293ec76 +github.com/decred/dcrd/wire,v1.3.0,h1:X76I2/a8esUmxXmFpJpAvXEi014IA4twgwcOBeIS8lE=,e17b78d19d0056503627826a0e599ed14a7a4fc8aa2c31c47b12ffc1864aedb1 +github.com/decred/slog,v1.0.0,h1:Dl+W8O6/JH6n2xIFN2p3DNjCmjYwvrXsjlSJTQQ4MhE=,1c27399a3f38fb7b581f4dbe11a0b3e3d5d8afcc8109880771c0e44135388bb0 +github.com/denisenkom/go-mssqldb,v0.0.0-20191001013358-cfbb681360f0,h1:epsH3lb7KVbXHYk7LYGN5EiE0MxcevHU85CKITJ0wUY=,ff2349c73cee9e54cd61e85af75d7d0537fb5f070da5a737b5abede1f7d579ac +github.com/denkhaus/bitshares,v0.6.1-0.20190502142618-5ae8c00cb394,h1:PpFS6pvAoRwH13WlqnX/mrxesu6LNFtiVwoWgfNLCeY=,af76695d3e546cad6a8b56d9d5e431bfeb12bfce643a395fb45d8827409dd9ff +github.com/denkhaus/gojson,v1.0.0,h1:p1hAlN/yAvRvzbdO1HNDQvmBslfyk64IMt3O3DtftPU=,5c0d8d98a53be88e2801d90124e28ba781d2c6a09aaf9a57272df92c5c0e0fe2 +github.com/denkhaus/logging,v0.0.0-20180714213349-14bfb935047c,h1:imM7UU8JD1sNuk2tVEk3QvrY2RZ5f/DOB+UA7c5ThGs=,5a1bb81f35dc7847b0cb8efe3f1e3bac3a34c9f11950a7c7643115c952fa3166 +github.com/denverdino/aliyungo,v0.0.0-20170926055100-d3308649c661,h1:lrWnAyy/F72MbxIxFUzKmcMCdt9Oi8RzpAxzTNQHD7o=,e6ca432bab5a7b1d233c9c1495d32668d31b18803d65f3af27f1d8240b6547d4 +github.com/detached/gorocket,v0.0.0-20170629192631-d44bbd3f26d2,h1:zwp9mAr+YvsgLCFIVJ3/m61Z+NRX35jbD0HBa62ryHY=,f54c9dc20ba925f0b2a726cc1a22466c6e05d7e0080f6e4b5f26e60c15938712 +github.com/detailyang/go-fallocate,v0.0.0-20180908115635-432fa640bd2e,h1:lj77EKYUpYXTd8CD/+QMIf8b6OIOTsfEBSXiAzuEHTU=,dcc45102d034d78825d1aa9d2f61720b4b0d9f76314a7a53b32cf032713a0bde +github.com/devfeel/dotweb,v1.7.3,h1:tt7YtCIp9JPmAS2yksVIsw6CiUkUSz3kVLSiCzRaWDw=,7cdb6d4872bb4c82fc333722fb2be3e39fe391b121550421d240d3008c8e00a0 +github.com/devigned/tab,v0.1.1,h1:3mD6Kb1mUOYeLpJvTVSDwSg5ZsfSxfvxGRTxRsJsITA=,528e21b578f28a998453551c51abfdeed154c981486d49a8ad7c149743ea450f +github.com/dghubble/oauth1,v0.6.0,h1:m1yC01Ohc/eF38jwZ8JUjL1a+XHHXtGQgK+MxQbmSx0=,6d4be6cfc2771fab15e47d2aa9c40d347dab7166f2cae3c248aeb51b10c88b4a +github.com/dghubble/sling,v1.3.0,h1:pZHjCJq4zJvc6qVQ5wN1jo5oNZlNE0+8T/h0XeXBUKU=,880e7f44ee68eae979a34afb2f95ab1c7555712153c45be01d15cbc5991a5fe6 +github.com/dgraph-io/badger,v1.6.0,h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo=,8329ae390aebec6ae360356e77a2743357ad4e0d0bd4c3ae03b7d17e01ad70aa +github.com/dgraph-io/dgo,v1.0.0,h1:DRuI66G+j0XWDOXly4v5PSk2dGkbIopAZIirRjq7lzI=,dae0ee7690b0c58d72be328263d55394f88a4924a8274017021736d702be9cee +github.com/dgrijalva/jwt-go,v3.2.0+incompatible,h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=,26b028eb2d9ee3aef26a96d6790e101f4088ef901008ebab17096966bf6522ad +github.com/dgryski/go-farm,v0.0.0-20190423205320-6a90982ecee2,h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=,d1fb60f1ce562acb07569d53b43353b73f439911c27eecef716305cd2d730258 +github.com/dgryski/go-jump,v0.0.0-20170409065014-e1f439676b57,h1:qZNIK8jjHgLFHAW2wzCWPEv0ZIgcBhU7X3oDt/p3Sv0=,92666f8caf4843c5a9b6bdb0f48f261922595683351958b0909884adf064cfb2 +github.com/dgryski/go-metro,v0.0.0-20180109044635-280f6062b5bc,h1:8WFBn63wegobsYAX0YjD+8suexZDga5CctH4CCTx2+8=,3f97b3cdeaee7b4fbf4fa06b7c52e3ee6bca461a100077892e861c6c8fc03722 +github.com/dgryski/go-sip13,v0.0.0-20190329191031-25c5027a8c7b,h1:Yqiad0+sloMPdd/0Fg22actpFx0dekpzt1xJmVNVkU0=,81d318bf94b85b240278c35d7ef6015510751e31ffa89eb6287d6d236493551e +github.com/digitalocean/go-libvirt,v0.0.0-20190626172931-4d226dd6c437,h1:phR13shVFOIpa1pnLBmewI9p16NEladLPvVylLPeexo=,7748e819d19524170969d2a470c212bb3936778ff630f833adc286e8c21e37cc +github.com/digitalocean/go-qemu,v0.0.0-20181112162955-dd7bb9c771b8,h1:N7nH2py78LcMqYY3rZjjrsX6N7uCN7sjvaosgpXN9Ow=,7530507881e53214ed3c0fb770fb3faed36a57ca6eb376bd2cec91a0e5d575a6 +github.com/digitalocean/godo,v1.11.1,h1:OsTh37YFKk+g6DnAOrkXJ9oDArTkRx5UTkBJ2EWAO38=,5d1ad5b25ad252fb1a02366087fe6e94845ec2dce64dc6e875ed3253a7e0f8ff +github.com/dimchansky/utfbom,v1.1.0,h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4=,27fed73a62fcf06d4ceb28846e5d40786b7e81213aa0d1f4d840e89d25f285f7 +github.com/dimfeld/httppath,v0.0.0-20170720192232-ee938bf73598,h1:MGKhKyiYrvMDZsmLR/+RGffQSXwEkXgfLSA08qDn9AI=,ff59ff07643eccf8a166cc9693fbd18c42869e0bfcc0a9c979435847a7ae4fb1 +github.com/dimfeld/httptreemux,v5.0.1+incompatible,h1:Qj3gVcDNoOthBAqftuD596rm4wg/adLLz5xh5CmpiCA=,031da29a128234db595fdce84301cfe5ff13b4be03c1e344cfe7daadb68559e9 +github.com/disintegration/gift,v1.2.1,h1:Y005a1X4Z7Uc+0gLpSAsKhWi4qLtsdEcMIbbdvdZ6pc=,d9a688a552dc8f5b2319325541e2bbc5c0af66b6e78273058893b259fcca5a0f +github.com/disintegration/imaging,v1.6.1,h1:JnBbK6ECIZb1NsWIikP9pd8gIlTIRx7fuDNpU9fsxOE=,209474c4c0348672c6747a7a73ff887a6d9458b67df78ff342ee3fd628156412 +github.com/djherbis/atime,v1.0.0,h1:ySLvBAM0EvOGaX7TI4dAM5lWj+RdJUCKtGSEHN8SGBg=,fe677e5c1a8bb168904c0856010bed33a770d49eda9edc6dc1b567940bf20afc +github.com/dlclark/regexp2,v1.2.0,h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk=,61054c243455e034d7a81e2f6a888cab5a81056a0cc43463cb3536b42cfe7cc1 +github.com/dmotylev/goproperties,v0.0.0-20140630191356-7cbffbaada47,h1:sP2APvSdZpfBiousrppBZNOvu+TE79Myq4kkmmrtSuI=,8afdf7b2989dff361cc80e560c1bd17e5c4ad37826b5caf4b65af8e152cdc6cb +github.com/dnaeon/go-vcr,v1.0.1,h1:r8L/HqC0Hje5AXMu1ooW8oyQyOFv4GxqpL0nRP7SLLY=,8f586f95ce5567ef2ae702cf98e56a09ea0cc6171f5cd959e6fcf7502e00dabc +github.com/dnsimple/dnsimple-go,v0.30.0,h1:IBIrn9jMKRMwporIRwdFyKdnHXVmwy6obnguB+ZMDIY=,5821d521b402f93dc19f6eb332d5f4159800336f53626c6dedd99ce4c351a55a +github.com/dnstap/golang-dnstap,v0.1.0,h1:hKtRrSTEHuTmG0vCLgKU8WJkXCARoAJMDrlXHTTPBK8=,fe23fd626917c7f45ead63cef4a4bd1bb366bb30ba5873d9ee5432e79b971349 +github.com/docker/cli,v0.0.0-20191031185610-968ce1ae4d45,h1:KJ4FsevlLR30Q2H1aCACmL3CEoUTAZf16PMAJj+ofXI=,145fef54aa162edc123d514ed7a20bc14564581ad95bb6aae7294c3c08df55fd +github.com/docker/distribution,v2.7.1+incompatible,h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=,be78bc43d74873b67afe05a6b244490088680dab75bdfaf26d0fd4d054595bc7 +github.com/docker/docker,v1.13.1,h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=,1decea9f21d4165bc134de72c51055612ff6992409cd56f3c35b7f78f3b542bd +github.com/docker/docker-ce,v0.0.0-20180924210327-f53bd8bb8e43,h1:gZ4lWixV821UVbYtr+oz1ZPCHkbtE+ivfmHyZRgyl2Y=,d670d1c5faec51ee82dbc5d479a7fca60916c1b30547994c206622ab338a735a +github.com/docker/docker-credential-helpers,v0.6.3,h1:zI2p9+1NQYdnG6sMU26EX4aVGlqbInSQxQXLvzJ4RPQ=,4dd2971b28524442b7a01e118a8040c3ab90eca50d55a7a232af514d18187324 +github.com/docker/engine-api,v0.4.0,h1:D0Osr6+45yAlQqLyoczv5qJtAu+P0HB0rLCddck03wY=,0db5d01c8401192b4eee6d2f9c34aa297d1a892f25230b470efd73f8f7ab59a4 +github.com/docker/go,v1.5.1-1,h1:hr4w35acWBPhGBXlzPoHpmZ/ygPjnmFVxGxxGnMyP7k=,fd626ee84b1eaea11c2a374fda5ed5ca8ad820bb4746ee31519efeb5038077b5 +github.com/docker/go-connections,v0.4.0,h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=,570ebcee7e6fd844e00c89eeab2b1922081d6969df76078dfe4ffacd3db56ada +github.com/docker/go-events,v0.0.0-20190806004212-e31b211e4f1c,h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8=,0f654eb0e7e07c237a229935ea3488728ddb5b082af2918b64452a1129dccae3 +github.com/docker/go-metrics,v0.0.1,h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8=,4efab3706215f5b2d29ba823d3991fd6e2f81c02ce45ef0c73c019ebc90e020b +github.com/docker/go-units,v0.4.0,h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=,0f2be7dce7b1a0ba6a4a786eb144a3398e9a61afc0eec5799a1520d9906fc58c +github.com/docker/libkv,v0.2.1,h1:PNXYaftMVCFS5CmnDtDWTg3wbBO61Q/cEo3KX1oKxto=,7a0c81782d38b550acc2c0ef0ce397adfc13716f483be6a47d0b97fbc6eea0d5 +github.com/docker/libnetwork,v0.5.6,h1:hnGiypBsZR6PW1I8lqaBHh06U6LCJbI3IhOvfsZiymY=,7aea42c405304c495bf159e5004674eb503eb0120eb4c5d1275fdba65d88cc53 +github.com/docker/libtrust,v0.0.0-20160708172513-aabc10ec26b7,h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4=,bf1c1230a3b5c0dadb2c9366aabc99181e708369d735dc83c3eb89f597f42adb +github.com/docker/machine,v0.16.2,h1:jyF9k3Zg+oIGxxSdYKPScyj3HqFZ6FjgA/3sblcASiU=,1c13210831cafddba1abbf9ef034135233252c62927df396fee6fa0a45efcb43 +github.com/docker/notary,v0.6.1,h1:6BO5SNujR+CIuj2jwT2/yD6LdD+N9f5VbzR+nfzB5ZA=,439fd6664fb75323d78c5a362483f3375a6ac61a3dd08438a503df470a34f300 +github.com/docker/spdystream,v0.0.0-20160310174837-449fdfce4d96,h1:cenwrSVm+Z7QLSV/BsnenAOcDXdX4cMv4wP0B/5QbPg=,70964f9eef29843634539b8d6e09c8b51ed6aa96b5deda28b7a44613327a22f2 +github.com/docker/swarmkit,v1.12.0,h1:vcbNXevt9xOod0miQxkp9WZ70IsOCe8geXkmFnXP2e0=,b9d09ff080beb0db2d4d4ebca93438dd080769266eb7aab6d5182e1ad7ba2c3a +github.com/docopt/docopt-go,v0.0.0-20180111231733-ee0de3bc6815,h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=,00aad861d150c62598ca4fb01cfbe15c2eefb5186df7e5d4a59286dcf09556c8 +github.com/documize/community,v3.2.0+incompatible,h1:ilePrhqxjc+BWpDRsXPyLyMEE1BrGlqCPMg3T577mzQ=,e9e06bdbef4500c0d2cc609164fe23bc05f8234c2c8483c8c9bc3ffffe22bbf7 +github.com/dogmatiq/dogma,v0.6.0,h1:HdJ0cTcORIxZRTB5Z7RdsBXEr18gB3so7FMIHYiAhEQ=,db91004377004aa3c5f0c462205beea995e93a0be13d7d99d3232dc03209f65c +github.com/donovanhide/eventsource,v0.0.0-20171031113327-3ed64d21fb0b,h1:eR1P/A4QMYF2/LpHRhYAts9wyYEtF7qNk/tVNiYCWc8=,2b911efc5101522ce50399cd7831ef931896541893955441168783666811a1d1 +github.com/dop251/goja,v0.0.0-20190912223329-aa89e6a4c733,h1:cyNc40Dx5YNEO94idePU8rhVd3dn+sd04Arh0kDBAaw=,485156ad52ca9651f728a6039af63f9f11c5bf49846e513635d5fa35d8d39097 +github.com/dotcloud/docker,v1.13.1,h1:jjwxeyQYDwROaGy/YEodF+srQW5hJAnNnaTcfcKoU+0=,83884e41d26b32eae2387080b245792ac8fc0200f645aef02656cb5e4b3d0595 +github.com/drone/go-scm,v1.6.0,h1:PZZWLeSHHwdc6zbSQpg9n0CNoRB+8DAINzX9X/wJifY=,e26d2bc63c53a66252ab24a1b45ced06825bb4101cbd746c581683cf39e520b6 +github.com/dsnet/compress,v0.0.0-20171208185109-cc9eb1d7ad76,h1:eX+pdPPlD279OWgdx7f6KqIRSONuK7egk+jDx7OM3Ac=,25f6bcccb4c1cf6d97ad69253a394bd0a52a633caa623d75b30729aed495a73d +github.com/dsnet/golib/unitconv,v0.0.0-20190531212259-571cdbcff553,h1:mE6azeVhLnKfk6DH3Zcg56L87yJ/uv9HZ5YJOQcPC4s=,603b60f7278fe7299f59d716da2bd287441f1321b5a663828d894e67bc274bed +github.com/duosecurity/duo_api_golang,v0.0.0-20190308151101-6c680f768e74,h1:2MIhn2R6oXQbgW5yHfS+d6YqyMfXiu2L55rFZC4UD/M=,75c90bdd92362e2cc36297193a543fe0cd75c07f82182940ad6158a1d470cc8b +github.com/dustin/go-humanize,v1.0.0,h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=,e01916e082a6646ea12d7800d77af43045c27284ff2a0a77e3484509989cc107 +github.com/dylanmei/iso8601,v0.1.0,h1:812NGQDBcqquTfH5Yeo7lwR0nzx/cKdsmf3qMjPURUI=,1e682968bfcac2115e1fd706ec6bd09a0b676d7d224514d8f8dff9cadbf87e79 +github.com/dylanmei/winrmtest,v0.0.0-20190225150635-99b7fe2fddf1,h1:r1oACdS2XYiAWcfF8BJXkoU8l1J71KehGR+d99yWEDA=,5607cb987ec0a699003eeec5952f0280792fd5db7099ca277bdfae26e93b0ef3 +github.com/eapache/go-resiliency,v1.1.0,h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU=,a64ebe539335e126b30f79f0f00f39ffe083e794995500a67e0a2156b334788e +github.com/eapache/go-xerial-snappy,v0.0.0-20180814174437-776d5712da21,h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw=,785264afffdcfe50573a1cb0df85ff4186e9e7e4e3a04513752f52d3da1054af +github.com/eapache/queue,v1.1.0,h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=,1dc1b4972e8505c4763c65424b19604c65c944911d16c18c5cbd35aae45626fb +github.com/eclipse/paho.mqtt.golang,v1.2.0,h1:1F8mhG9+aO5/xpdtFkW4SxOJB67ukuDC3t2y2qayIX0=,d36337c4b5a2752b91bcd437bd74e0907bf6c9e6c611dab88407bcca8462e918 +github.com/edgexfoundry/go-mod-core-contracts,v0.1.33,h1:lQbLbRhymV0/QDDDGU26idZ9Kv+Q0IETn81hLpHxi68=,a7a8792a8692d64daea343577a49934be6ba64acbe114b3c24262537b5a9157f +github.com/edsrzf/mmap-go,v1.0.0,h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw=,851a1d4d6e30f97ab23b7e4a6a7da9d1842f126d738f7386010c6ee7bf82518e +github.com/edwingeng/doublejump,v0.0.0-20190102103700-461a0155c7be,h1:FnUE/uuuegwvhGE9z61q9krL5km5Mnwlusq3BT06yy8=,a9cb92422f0bbdd56c80d9873a8f7af6fd2d8d8154a7a11d7cb9232d9146f07c +github.com/efarrer/iothrottler,v0.0.0-20141121142253-60e7e547c7fe,h1:WAx1vRufH0I2pTWldQkXPzpc+jndCOi2FH334LFQ1PI=,04291e6136b933fd2cdcc29f3af78090a9d678534a94823590eb63f1f318db1d +github.com/efritz/backoff,v1.0.0,h1:r1DfNhA1J7p8kZ185J/hLPz2Bl5ezTicUr9KamEAOYw=,064d92e7f3e46079d158cac717e1c9bf96a230a5f31bf28940bd4a99bb91657e +github.com/efritz/glock,v0.0.0-20181228234553-f184d69dff2c,h1:Q3HKbZogL9GGZVdO3PiVCOxZmRCsQAgV1xfelXJF/dY=,716200eb117905f4df509b7260869bb97bf8833c160d2ff1d328d01aa3874bc9 +github.com/eknkc/amber,v0.0.0-20171010120322-cdade1c07385,h1:clC1lXBpe2kTj2VHdaIu9ajZQe4kcEY9j0NsnDDBZ3o=,b1dde9f3713742ad0961825a2d962bd99d9390daf8596e7680dfb5f395e54e22 +github.com/elastic/go-sysinfo,v1.0.1,h1:lzGPX2sIXaETeMXitXL2XZU8K4B7k7JBhIKWxdOdUt8=,fe0cd64aa3ac73edbb4240dcbcb660c4ec004f07c36371be6d78543c3b215d92 +github.com/elastic/go-windows,v1.0.0,h1:qLURgZFkkrYyTTkvYpsZIgf83AUsdIHfvlJaqaZ7aSY=,e487e6f1e269766b5815c36e93614b87a185ddc33f7a6f4bf23e5ee6d0d0e3c1 +github.com/elastic/gosigar,v0.10.5,h1:GzPQ+78RaAb4J63unidA/JavQRKrB6s8IOzN6Ib59jo=,a139252942b5ca82ddc3d9ced1daa262de0149a413149d3f0234b43dc3635acf +github.com/elazarl/go-bindata-assetfs,v1.0.0,h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=,3aa225ae5ae4a8059a671fa656d8567f09861f88b88dbef9e06a291efd90013a +github.com/elazarl/goproxy,v0.0.0-20191011121108-aa519ddbe484,h1:pEtiCjIXx3RvGjlUJuCNxNOw0MNblyR9Wi+vJGBFh+8=,6c224ac5720959a46f6d88e0b15dda732c7eb180b3103a826cf6d5459a5e112f +github.com/elazarl/goproxy/ext,v0.0.0-20190711103511-473e67f1d7d2,h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM=,7244c1fe7490460503559e24e0e478540bc10481d1d8f3afd0a1f6b1a470b52f +github.com/emicklei/go-restful,v2.11.1+incompatible,h1:CjKsv3uWcCMvySPQYKxO8XX3f9zD4FeZRsW4G0B4ffE=,9befcac63629841301235124e728206a96170afd83c78b632d271acafc9acccf +github.com/emicklei/go-restful-swagger12,v0.0.0-20170926063155-7524189396c6,h1:V94anc0ZG3Pa/cAMwP2m1aQW3+/FF8Qmw/GsFyTJAp4=,07fd41dbe765b7d340df21d6353db8bef782f9b6742a93696b6f4133ef1d8955 +github.com/emicklei/proto,v1.6.15,h1:XbpwxmuOPrdES97FrSfpyy67SSCV/wBIKXqgJzh6hNw=,162ad34010e5f81ebed962a33c91ee6356e19631c7a7030bc9b173e85ca34678 +github.com/emirpasic/gods,v1.12.0,h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=,729ea0bda86bf801b61ff66eb019e5b9adc559cd217944abf10bb103fca573ee +github.com/endophage/gotuf,v0.0.0-20151124190824-3b700e20e376,h1:rPyHFhsuPZMEJAe1Oj2vpRC8277wpDJJ+aabkmlHF1A=,2cd5e6d0e748e0625e8c4a08a3b9f74e311e6654a1c5411fa3a9720f5f67cf40 +github.com/envoyproxy/go-control-plane,v0.9.0,h1:67WMNTvGrl7V1dWdKCeTwxDr7nio9clKoTlLhwIPnT4=,07b3a43081c9e1cdccb95c657cba7f483d5099f9ce07b5e3f3e28ce557687521 +github.com/envoyproxy/protoc-gen-validate,v0.1.0,h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=,ec5261f3bbc426d71e2be4c76063ba12460c5d27845d630763e9e911ec4768af +github.com/eoscanada/eos-go,v0.8.10,h1:QUwHRBHEFag/qyW4PR2S9++0se0V4LjPLk1/KsNtXlo=,f1c48e793d1c7864288871a944af4b4ee3363ad6ae5298e9c2f9f42202e6d77c +github.com/erikstmartin/go-testdb,v0.0.0-20160219214506-8d10e4a1bae5,h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=,471feb426b2a7ec1df29cc21c66aef34c9e7aabea751328644d1362593983d21 +github.com/ernesto-jimenez/gogen,v0.0.0-20180125220232-d7d4131e6607,h1:cTavhURetDkezJCvxFggiyLeP40Mrk/TtVg2+ycw1Es=,1f3030cfc89653ba791ae312b19e420dc8eaf1bef51f59dca6aa390f3cd1f3d0 +github.com/etcd-io/bbolt,v1.3.3,h1:gSJmxrs37LgTqR/oyJBWok6k6SvXEUerFTbltIhXkBM=,6630d7aad4b10f76aea88ee6d9086a1edffe371651cc2432edfd0de6beb99120 +github.com/ethantkoenig/rupture,v0.0.0-20180203182544-0a76f03a811a,h1:M1bRpaZAn4GSsqu3hdK2R8H0AH9O6vqCTCbm2oAFGfE=,8559344c496621c06b612453de587e8e4c45c0fbc348a955f8eda7ea2b3d09c8 +github.com/ethereum/go-ethereum,v1.9.6,h1:EacwxMGKZezZi+m3in0Tlyk0veDQgnfZ9BjQqHAaQLM=,778c9bf77dd96bfaf5c3ea84498611490999782fb37edf8257680e27dd8976e8 +github.com/euank/go-kmsg-parser,v2.0.0+incompatible,h1:cHD53+PLQuuQyLZeriD1V/esuG4MuU0Pjs5y6iknohY=,43cadfa5ab226f89ca7a715add32ba23c554a5dfafd3a55449856a6b7012f946 +github.com/evanphx/json-patch,v4.5.0+incompatible,h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M=,5508e810685a5081a3e880aeb24e501bd87920241baa317bfb5f3946b4fa417c +github.com/exoscale/egoscale,v0.18.1,h1:1FNZVk8jHUx0AvWhOZxLEDNlacTU0chMXUUNkm9EZaI=,8cb4f10504b54d31c71bc4a670171a074f7abbab67d939fd404b62ad36cb6aed +github.com/facebookgo/atomicfile,v0.0.0-20151019160806-2de1f203e7d5,h1:BBso6MBKW8ncyZLv37o+KNyy0HrrHgfnOaGQC2qvN+A=,3c9bdee73452cc12c2936b4050d638d36302a958091ceb49c45ffbaff8954218 +github.com/facebookgo/clock,v0.0.0-20150410010913-600d898af40a,h1:yDWHCSQ40h88yih2JAcL6Ls/kVkSE8GFACTGVnMPruw=,5d6b671bd5afef8459fb7561d19bcf7c7f378da9943722d36676735b3c6272fa +github.com/facebookgo/ensure,v0.0.0-20160127193407-b4ab57deab51,h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ=,a96c69c2b5902e0383139ee7089877a5ae2ddcd4eba42a595d13b570907d3fdc +github.com/facebookgo/freeport,v0.0.0-20150612182905-d4adf43b75b9,h1:wWke/RUCl7VRjQhwPlR/v0glZXNYzBHdNUzf/Am2Nmg=,0f717d7eb52e276aec2138a971b091cd04da95826c8f451a20e8e78c4bb8f915 +github.com/facebookgo/grace,v0.0.0-20160926231715-5729e484473f,h1:0mlfEUWnUDVZnqWEVHGerL5bKYDKMEmT/Qk/W/3nGuo=,79f9f73ef925d457d2b70d37b12c3cec97a2e84e73a932397d2f569ec8702ee7 +github.com/facebookgo/httpdown,v0.0.0-20160323221027-a3b1354551a2,h1:3Zvf9wRhl1cOhckN1oRGWPOkIhOketmEcrQ4TeFAoR4=,dbbccf963238c5f80c54edb19aeb016f486f42dcd922fc0be5b832af9449ca4b +github.com/facebookgo/inject,v0.0.0-20161006174721-cc1aa653e50f,h1:jK9r9Ofgc/Yzdlod77G23LfYtwqAmkQCZ9MaP6779OI=,6292702ff520e1fb14231f29bb2639d8f39edc08de479d76757ad97dafbb9174 +github.com/facebookgo/stack,v0.0.0-20160209184415-751773369052,h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=,0afd18a8394caa29e94bd58a42e0d2be07939f9daf190a9ba2a947f9cbd4ba1a +github.com/facebookgo/stats,v0.0.0-20151006221625-1b76add642e4,h1:0YtRCqIZs2+Tz49QuH6cJVw/IFqzo39gEqZ0iYLxD2M=,d87443825721dc1dd5c358cd9e55b917ee1c3b6b10ab9557375f59d563b628cb +github.com/facebookgo/structtag,v0.0.0-20150214074306-217e25fb9691,h1:KnnwHN59Jxec0htA2pe/i0/WI9vxXLQifdhBrP3lqcQ=,3a9c84e9dc2b9960f1de3cc7a61d91fe2978e64e4e4859a9383259092ec91c5e +github.com/facebookgo/subset,v0.0.0-20150612182917-8dac2c3c4870,h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y=,bb18c678177e1aaaae209a2de9c28b5b7acc34e58fe00517b847a9460bd42df2 +github.com/farsightsec/golang-framestream,v0.0.0-20190425193708-fa4b164d59b8,h1:/iPdQppoAsTfML+yqFSq2EBChiEMnRkh5WvhFgtWwcU=,084f0ac3684b180e3d87db3e7b36a412c750397fbf009579e126c304528c1738 +github.com/fatih/camelcase,v1.0.0,h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=,54664f64f1f24097b80c64b9f606cbe8d8bc410a755ce6cda4f45e46f1141984 +github.com/fatih/color,v1.7.0,h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=,6036f0b31167280b696b5efb43603e71bce31420fb3428afdf74a68bb3a3ebef +github.com/fatih/structs,v1.1.0,h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=,a361ecc95ad12000c66ee143d26b2aa0a4e5de3b045fd5d18a52564622a59148 +github.com/fatih/structtag,v1.0.0,h1:pTHj65+u3RKWYPSGaU290FpI/dXxTaHdVwVwbcPKmEc=,347fce3911900f5947735c12ccb4c6fbe0199c6df040bcaa4d74a8587af896d0 +github.com/fd/go-nat,v1.0.0,h1:DPyQ97sxA9ThrWYRPcWUz/z9TnpTIGRYODIQc/dy64M=,bdf011af97da57ef3c58a091ae760eb885a6322faa3539d3c37bf76d4fff536a +github.com/fernet/fernet-go,v0.0.0-20180830025343-9eac43b88a5e,h1:P10tZmVD2XclAaT9l7OduMH1OLFzTa1wUuUqHZnEdI0=,a484a3172222095507a7f1901a91ab741c28278ea6b878c21c1151c0fd40f46d +github.com/flosch/pongo2,v0.0.0-20190707114632-bbf5a6c351f4,h1:GY1+t5Dr9OKADM64SYnQjw/w99HMYvQ0A8/JoUkxVmc=,814b52f668d2e2528fe9af917506cda4894d22c927283cfb8aaf6857503dfc5a +github.com/flynn/go-shlex,v0.0.0-20150515145356-3f9db97f8568,h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=,ea68a1d391e59ebc04ce986b88e000327bb141e5e8e80ef93af950bca42bb4cc +github.com/fogleman/gg,v1.3.0,h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=,792f7a3ea9eea31b7947dabaf9d5a307389245069078e4bf435d76cb0505439c +github.com/forestgiant/sliceutil,v0.0.0-20160425183142-94783f95db6c,h1:pBgVXWDXju1m8W4lnEeIqTHPOzhTUO81a7yknM/xQR4=,bedd47c23670847642576777cc8b53b9dd8a5a8e7b0a6f2299ebc6fa3b7b6f00 +github.com/fortytw2/leaktest,v1.3.0,h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=,867e6d131510751ba6055c51e7746b0056a6b3dcb1a1b2dfdc694251cd7eb8b3 +github.com/francoispqt/gojay,v1.2.13,h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk=,f41e3e4f3086400448dbce1c06c59f5848a6c5983e5466689965e3a2cabcba7c +github.com/frankban/quicktest,v1.5.0,h1:Tb4jWdSpdjKzTUicPnY61PZxKbDoGa7ABbrReT3gQVY=,515b5b2b9320b2982193ad6bd118907aaab9ff62189870e00be459cc4097073c +github.com/fsnotify/fsnotify,v1.4.7,h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=,1d09ad8f3dc41cb6e0288023b47272c1c9393ca411e48f4b5009bca6662dc3ad +github.com/fsouza/fake-gcs-server,v1.2.0,h1:FZUL/EJlyAlHxpUWZs23ae4zNwBwmHM1p5TykkoP85A=,83b547a0780693f154c30137b1eeaf0c0e9628798ae4b7e1d74ebfb8efaf61fc +github.com/fsouza/go-dockerclient,v1.5.0,h1:7OtayOe5HnoG+KWMHgyyPymwaodnB2IDYuVfseKyxbA=,c7025b816e0ba28041a88b1063003f4e31097346d06cf69811f9d55505d3d46c +github.com/fullsailor/pkcs7,v0.0.0-20190404230743-d7302db945fa,h1:RDBNVkRviHZtvDvId8XSGPu3rmpmSe+wKRcEWNgsfWU=,ba36a8fc855d6eecef329d26f8e82132e38d45d06f79f88d3b0bde6d718c8fb2 +github.com/fuyufjh/splunk-hec-go,v0.3.3,h1:7PLVIODblK9FXfuAy8iPZg0lcw1YNzSQHfC+0NYgUxU=,9517f63386f64e0dceca9352f45eb7f160452682a07fa04d3c1ff90eb19ac83d +github.com/gabriel-samfira/sys,v0.0.0-20150608132119-9ddc60d56b51,h1:rUp9t/FbeJM3R3BSYkJfViN3CNQcmk44H20SqkJ/y+k=,1be262d101bd9079bb859639ad6d5eaee80646b6db0fcbeb7146d9381949d2a8 +github.com/gammazero/deque,v0.0.0-20190130191400-2afb3858e9c7,h1:D2LrfOPgGHQprIxmsTpxtzhpmF66HoM6rXSmcqaX7h8=,a1fe4ec3258f68685ee45b68e1d9188d79726af46a1b93281cf11ddc6045a864 +github.com/gammazero/workerpool,v0.0.0-20190406235159-88d534f22b56,h1:VzbudKn/nvxYKOdzgkEBS6SSreRjAgoJ+ZeS4wPFkgc=,cbb92fdf8d457e27923dc6515af4458a55af932ccf468415c8b36bf49845fc00 +github.com/garyburd/go-oauth,v0.0.0-20180319155456-bca2e7f09a17,h1:GOfMz6cRgTJ9jWV0qAezv642OhPnKEG7gtUjJSdStHE=,be051ba0d52eaced1c1985ebdf2dece3f7127ad392645b42fd06c2af9c9caea2 +github.com/garyburd/redigo,v1.6.0,h1:0VruCpn7yAIIu7pWVClQC8wxCJEcG3nyzpMSHKi1PQc=,68f0d2b454f7a9a000c3335fc0f409123637e4711c6461a4c75e2f128f68f283 +github.com/gavv/monotime,v0.0.0-20161010190848-47d58efa6955,h1:gmtGRvSexPU4B1T/yYo0sLOKzER1YT+b4kPxPpm0Ty4=,c97324768edc8170e05b8925b0551778909c8e15817d4327ac405a4e0b6071f4 +github.com/gcash/bchd,v0.14.7,h1:n3gMXCT4VhU/emiCq61kmKBPADLxBzpX5IlXPnGuR2c=,871644f504d6c3f19dcfc8a7a6e6aa623e6642275a48dfffe770ec61368c2032 +github.com/gcash/bchlog,v0.0.0-20180913005452-b4f036f92fa6,h1:3pZvWJ8MSfWstGrb8Hfh4ZpLyZNcXypcGx2Ju4ZibVM=,d400c8e944edf2a67f46e75335f55c14170c523691804ea71e1a348ad45bc7e7 +github.com/gcash/bchutil,v0.0.0-20191012211144-98e73ec336ba,h1:KVa96lSrJGMYZ414NtYuAlbtCgrmW9kDnjvYXcLrr5A=,7b829a35d22ead0ee82d8a98b1e06da5e63fd07b2798fce8ba87c8da670ef04a +github.com/gcla/gowid,v1.0.0,h1:78Xf5G9+lb4/g3KCB3hX8UJ8VorymMH5PXu9Npvwf8s=,eaa7e0b7bb0912c6b24c98dee0073a2de754c24e1347ce7c5bfc63397ccf0fa6 +github.com/gdamore/encoding,v1.0.0,h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=,638a9832e2f62d118d7c511d86bdae1622a51f331de48a01d929fd24ebe6a2a6 +github.com/gdamore/tcell,v1.3.0,h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM=,97c1e828ff9de0cef3a5bbdb3f3def8a351ad6ca65a780d4dd4141b0ee23c88e +github.com/genuinetools/pkg,v0.0.0-20180910213200-1c141f661797,h1:SGpZXDd/CFeDIY4Rq5cFO8K/uqDblHUxjlzOmjFpvRg=,c15cbe95e0a7e38cc0a790b0098170c103ba84d56e7cbaf744a6df10c00efa45 +github.com/genuinetools/reg,v0.16.0,h1:ZhLZPT+aUGHLfy45Ub5FLWik+3Dij1iwaj8A/GyAZBw=,a505ff5357d6095540c89ee27d207a3a4dc7c73840fb6bc9a2f0f3a81e498341 +github.com/gernest/wow,v0.1.0,h1:g9xdwCwP0+xgVYlA2sopI0gZHqXe7HjI/7/LykG4fks=,b49d5efc34e19469e7319df09b35438de307ba7cd8c9333ecba190f457ca8e22 +github.com/getgauge/common,v0.0.0-20190514095629-619e107433ce,h1:/ofMj8gIhPYdb/JEXKj8iYe5Yxl3mrK8YA7yl/06t6Y=,04ab4fb7e8dcf693c3b79028693130cd51fe54f5a16f12622975a7c3eb7705f7 +github.com/getlantern/context,v0.0.0-20190109183933-c447772a6520,h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4=,27515ae761018c4cfc83043194904170bef0cac037c48ff96fc497502b9bab14 +github.com/getlantern/errors,v0.0.0-20190325191628-abdb3e3e36f7,h1:6uJ+sZ/e03gkbqZ0kUG6mfKoqDb4XMAzMIwlajq19So=,a48d7684463e8c496fea4a2595ca71012c3b222bc77de7c2ddfbe78bc4595ac5 +github.com/getlantern/fdcount,v0.0.0-20170105153814-6a6cb5839bc5,h1:8Q9iN/V24EG01IgXEKVScth/rTXpplBxCYio/yIKtUw=,b24c26d5ede197fd6b7f981cf5db300124e22f48667942c948a9750f7a908c94 +github.com/getlantern/golog,v0.0.0-20190830074920-4ef2e798c2d7,h1:guBYzEaLz0Vfc/jv0czrr2z7qyzTOGC9hiQ0VC+hKjk=,1eeabfbc56105f3d751e1947405f5296db5ded7e25900209fe7327f1b5d785e6 +github.com/getlantern/hex,v0.0.0-20190417191902-c6586a6fe0b7,h1:micT5vkcr9tOVk1FiH8SWKID8ultN44Z+yzd2y/Vyb0=,ea5a13f98a82c1919c59b655de531cbb35ac7dfff3c99072b43b8bfd1c29b774 +github.com/getlantern/hidden,v0.0.0-20190325191715-f02dbb02be55,h1:XYzSdCbkzOC0FDNrgJqGRo8PCMFOBFL9py72DRs7bmc=,c901f2e702114d6268446a381a27737c6123e50191197fd84f17b339238191b4 +github.com/getlantern/idletiming,v0.0.0-20190529182719-d2fbc83372a5,h1:laM1s/bxUH8xbbC9TBGWsOc7A0KCAPZMa4pdwO5e6Vw=,35de51b383e926042d3f8f4859e2d961582cf9964d3b7bb513ac4733cc43162f +github.com/getlantern/mockconn,v0.0.0-20190403061815-a8ffa60494a6,h1:+aO65ByJw74kV8vXqvkj49P5RtIqyUObyeRTIxMz218=,a4a1ccdc9ec68dea571d9603d4a36150b6ccaea447ca88965e088ff0b9eeaa0d +github.com/getlantern/mtime,v0.0.0-20170117193331-ba114e4a82b0,h1:1VNkP55LM/W2IwWN+qi+5X3gZcEQHfj8X9E+FNxVgM4=,5af0b20838a808b86a2a9c87c254d47185d38d5935780dade3bc7a54dc2880f4 +github.com/getlantern/netx,v0.0.0-20190110220209-9912de6f94fd,h1:mn98vs69Kqw56iKhR82mjk16Q1q5aDFFW0E89/QbXkQ=,cb386d0527fb6f549fa0266c770a68d7d83a88bab2194d25b55355f59198fdf0 +github.com/getlantern/ops,v0.0.0-20190325191751-d70cb0d6f85f,h1:wrYrQttPS8FHIRSlsrcuKazukx/xqO/PpLZzZXsF+EA=,321694d3d2f31415653a7b9d97a4a701f36f10ccfbbdb94449f1211137d6f215 +github.com/getsentry/raven-go,v0.2.0,h1:no+xWJRb5ZI7eE8TWgIq1jLulQiIoLG0IfYxv5JYMGs=,eaffe69939612cd05f95e1846b8ddb4043655571be34cdb6412a66b41b6826eb +github.com/gf-third/mysql,v1.4.2,h1:f1M5CNFUG3WkE07UOomtu4o0n/KJKeuUUf5Nc9ZFXs4=,14a08134ce02bd0d07667da91a89c9098d18bad8c790414e37aba906895a5a3e +github.com/gf-third/yaml,v1.0.1,h1:pqD4ix+65DqGphU1MDnToPZfGYk0tuuwRzuTSl3g0d0=,6354a95d7faa222d2e653485bc9dd555aad61a75eb5a5f970de531391ed77a2f +github.com/ghetzel/go-defaults,v1.2.0,h1:U1T64bxhBc6nVZ68QXch1hoHq43h6isqgbvG7kxY9Uc=,f339e441d08af3af184a21f518227db7c705851be82f3fcea611e762ebb633a1 +github.com/ghetzel/go-stockutil,v1.8.6,h1:VgqpePUGGXMHjgArUH5mSAYFC35aiFgkU/TdTU/ts80=,aa0cce06af82b7d1f98a20deaafd6997fa7c3d36fba9a204a34e5d91a2096fa0 +github.com/ghetzel/testify,v1.4.1,h1:wpJirdM+znAnxWruGDBdIys5aU+wGJHNUTkgEo4PYwk=,90206efc10ad71a33bf314ef768d16c6186d23ccb5aa8172663437d497dbfdd7 +github.com/ghetzel/uuid,v0.0.0-20171129191014-dec09d789f3d,h1:YVJe7KwVYazt90hCc/q2dYJVS3062AY6QdT6iHd+Kh8=,924f39fe83589fa269e652c8ca4f7b0dbc59023baada8a55c24692fe5223b67a +github.com/ghodss/yaml,v1.0.1-0.20190212211648-25d852aebe32,h1:Mn26/9ZMNWSw9C9ERFA1PUxfmGpolnw2v0bKOREu5ew=,9771720da98bbdd80dacdefb47b9a0e36faa75caa4745149d150325ba5390e4b +github.com/gin-contrib/gzip,v0.0.1,h1:ezvKOL6jH+jlzdHNE4h9h8q8uMpDQjyl0NN0Jd7jozc=,e994ecc5881938978d6d031e3d0c1bc5968bfe5de2a307aed7c63aecba459ecd +github.com/gin-contrib/sse,v0.1.0,h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=,512c8672f26405172077e764c4817ed8f66edc632d1bed205b5e1b8d282816ab +github.com/gin-gonic/gin,v1.4.0,h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ=,b9bc661bf658179d53fee9e7c587eba4df8326d0c26ad29f785739a78313fc4b +github.com/glacjay/goini,v0.0.0-20161120062552-fd3024d87ee2,h1:+SEORW3KptcFnlhTbn7N0drG3AFnrcmBDWDyQ3Bt06o=,061319068788a9eeef67d4e5cf84a87c4649005aaa4f37c983a868c357e3df3c +github.com/gliderlabs/ssh,v0.2.2,h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=,f9f12d766ceeab9e2134504520de75819d1eeb6733b8b619b7bcd4aac4cca983 +github.com/globalsign/mgo,v0.0.0-20181015135952-eeefdecb41b8,h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is=,c07f09e0c93e6410076edfd621d2decbd361361c536c3e33ba097fa51708f360 +github.com/glycerine/go-unsnap-stream,v0.0.0-20180323001048-9f0cb55181dd,h1:r04MMPyLHj/QwZuMJ5+7tJcBr1AQjpiAK/rZWRrQT7o=,9a66d6f9bb1a268f4b824d6fe7adcd55dc17ed504683bdf2dbf67b32028d9b88 +github.com/glycerine/goconvey,v0.0.0-20190315024820-982ee783a72e,h1:SiEs4J3BKVIeaWrH3tKaz3QLZhJ68iJ/A4xrzIoE5+Y=,344fb699344a5ab09464c0283a65402ae0fe6bd6fac7d40e9c4d403cf4a7714f +github.com/gmallard/stompngo,v1.0.12,h1:uj1Bl9o+dqn0qSR33xHmaKw21W5LzhWo4Q4hS1MCpQU=,88498e4da4e0f7f3923d758a464d53f550921617b1047643def2a973c86dfd03 +github.com/go-aah/forge,v0.8.0,h1:sk4Z523B9ay3JQF4At97U7kecB5yTIm0J2UM/qRVXbQ=,e883adcfb380d6187de84c59a0f8bb3b34931487151873d7a326a1b4df556e48 +github.com/go-acme/lego,v2.7.2+incompatible,h1:ThhpPBgf6oa9X/vRd0kEmWOsX7+vmYdckmGZSb+FEp0=,1a597873ff61c0fbdab6b4f1027141d2e8dbe739bd2018473559bec954f3e651 +github.com/go-acme/lego/v3,v3.1.0,h1:yanYFoYW8azFkCvJfIk7edWWfjkYkhDxe45ZsxoW4Xk=,fbb3cfe2619281c3ccd456b213b5f8c7bf695f82ecac6c97f747dc4159dfe4b2 +github.com/go-ble/ble,v0.0.0-20190521171521-147700f13610,h1:eWay3GzFqTJUEYN1BrbqdDTFeFUGmYLps8SQkn1D7Yo=,a5fb6440935dd7ef8bb3569bc7260bd1ad44e01d41bbb684dbb96cc677fb2234 +github.com/go-chassis/foundation,v0.0.0-20190621030543-c3b63f787f4c,h1:p+Y6yq7RwHmYjEr/vwdVYGacBqFCc2lPQfNRIC3vRIs=,db38c108455e57b3f8f062c22872554d5af9dfa03a723c9fea263a009f3002e6 +github.com/go-chassis/go-archaius,v0.24.0,h1:ubNgs3Rv067PI7t37ZJoIMaPPHIBWV+ni/e7XAdW1hU=,37b0c60692eaed91abd3d2c6a0fc9366a54882f3a6b5ef81f3cc20d14882a13d +github.com/go-chassis/go-chassis,v1.7.3,h1:7fcfaE9Ij+oBbf2lHoHHIvxT9objtt1EHpwRPBUkDhw=,38f8393558528b0212674268f6dc507d5db716fc5745eff09bccf1cd98b86eb7 +github.com/go-chassis/go-chassis-config,v0.14.0,h1:OnM9sx2GalDC7vEIhPecRpQlVa8hz10NOB41+9tii5A=,afc7506eec8591a5ccbb08f073ba19312bc03d87ec15c1532f5daba02f090e00 +github.com/go-chassis/go-restful-swagger20,v1.0.1,h1:HdGto0xroWGK504XN0Um7JBc0OPMHDlWwedkd2mTGII=,2c41388f71dc766088fc3e47e91a2f8c2d7936e40f6a64afff53a12ef73e0d05 +github.com/go-chassis/paas-lager,v1.0.2-0.20190328010332-cf506050ddb2,h1:iORWPbIQ81tJPKWs9TNvcjCQnqvyTlL41F9ILgiTcyM=,a74c06554cf6835e98c4fa548a4aa3dcc317ca93567af893b89a4dba88b783af +github.com/go-chat-bot/bot,v0.0.0-20191022130543-3da6cae45477,h1:JfUELmxvEz/MXI3/iSn2UcB/5CCAvMsxKi88j783ssk=,a059cd1d050747bd0adcd3d4ba91e12b0ace2c038187484726c3d551169d9fa4 +github.com/go-chat-bot/plugins,v0.0.0-20181006134258-491b3f9878d6,h1:qNYjVQnDwznjLk+OnNdczA5SXwEa/RwjPTZSQCKofF4=,b19527108aef487fa1f4856e354f4777644a574248cc7e891bacf1bfb38bd12d +github.com/go-chat-bot/plugins-br,v0.0.0-20170316122923-eb41b30907dc,h1:v/poG4Y4O/z1cUm2cWxiIkFFgRsT3Fe1u1A33evx89g=,6b613e62d3f389f3d6f8f262903bc31c4f1eb4b3ca8d192606f78199b1af0d43 +github.com/go-check/check,v0.0.0-20190902080502-41f04d3bba15,h1:xJdCV5uP69sUzCIIzmhAw6EKKdVk3Tu48oLzM86+XPI=,93bbc1f982dd553e279fb4c7fbc060032096e2b5d0537385ae80247492a6433e +github.com/go-chi/chi,v4.0.2+incompatible,h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs=,25c94ccd43f18002c2dd07e87da1dc393ff87d615441e559bda425ea0979715b +github.com/go-cmd/cmd,v1.0.5,h1:IK23uTRWxq6UJnNWp8nKO7mVCwnPfbaxA2lhzEKfNj0=,2623aa43dbf68c24362bcfb7a216b83c2e7473d4a3e49e7955c3fa5f28b4974c +github.com/go-delve/delve,v1.3.2,h1:K8VjV+Q2YnBYlPq0ctjrvc9h7h03wXszlszzfGW5Tog=,b8a250f2b3ef87da34fbfc655bb23a051b43672bea7a8abc4e083a2b214faf09 +github.com/go-errors/errors,v1.0.1,h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=,bdbee3143e1798eadff4df919479c28ec2d3299a97d445917bc64d6eb6a3b95a +github.com/go-gl/gl,v0.0.0-20181026044259-55b76b7df9d2,h1:78Hza2KHn2PX1jdydQnffaU2A/xM0g3Nx1xmMdep9Gk=,499822d1b3bcc34b82df0fcc13ac9a0ea273c5d68b3e183e18fa76dab9793954 +github.com/go-gl/glfw,v0.0.0-20190409004039-e6da0acd62b1,h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=,96c694c42e7b866ea8e26dc48b612c4daa8582ce61fdeefbe92c1a4c46163169 +github.com/go-gl/mathgl,v0.0.0-20190713194549-592312d8590a,h1:yoAEv7yeWqfL/l9A/J5QOndXIJCldv+uuQB1DSNQbS0=,39948d90a5672c7866b5b1c01e9e8ce6c80c099306ed80e9e138350840f82110 +github.com/go-ini/ini,v1.49.0,h1:ymWFBUkwN3JFPjvjcJJ5TSTwh84M66QrH+8vOytLgRY=,4820559fd3640c6b5361a7077e8b5c1a4318a06a59df7a095cbf96514d46d432 +github.com/go-kit/kit,v0.9.0,h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk=,f3da9b35b100dd32e7b10c37a0630af60d54afa37c61291e7df94bc0ac31ed03 +github.com/go-ldap/ldap,v3.0.3+incompatible,h1:HTeSZO8hWMS1Rgb2Ziku6b8a7qRIZZMHjsvuZyatzwk=,4197e5fbebc7a1805be236cf75dea301f0b8e15a857e2373653b76157c649f93 +github.com/go-log/log,v0.1.0,h1:wudGTNsiGzrD5ZjgIkVZ517ugi2XRe9Q/xRCzwEO4/U=,ec5845d33a6d7ede81970833cfc3179d53b99019da1ebffef5e71005ff94be43 +github.com/go-logfmt/logfmt,v0.4.0,h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA=,d678198dc0eeaed28736e0d71b919a0bd98501b7275c69a7917122f6de9e0d1c +github.com/go-logr/logr,v0.1.0,h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg=,4c14b7c05eaa48b7f8dbf2ca38c3603dce446f4184a4c0af2f569b046d66201e +github.com/go-logr/zapr,v0.1.0,h1:h+WVe9j6HAA01niTJPA/kKH0i7e0rLZBCwauQFcRE54=,7b60c74f722b8f215711503dd63576845987eff81ef5f9dc052fc9158d1c57e2 +github.com/go-macaron/binding,v1.0.0,h1:ILEIP1e9GaXz//fZIl1zXgHVbM9j1SN89aTGOq8340Y=,3887f50d442cd8f9eeeb0e7710c7cba41c185d8e5a82404ff33e7cbd4e16d0c7 +github.com/go-macaron/cache,v0.0.0-20151013081102-561735312776,h1:UYIHS1r0WotqB5cIa0PAiV0m6GzD9rDBcn4alp5JgCw=,a854b7844fff9ec69025db12a2b03834a2eac570a366962c4eb83984813a9fdb +github.com/go-macaron/captcha,v0.0.0-20190710000913-8dc5911259df,h1:MdgvtI3Y1u/DHNj7xUGOqAv+KGoTikjy8xQtCm12L78=,fb1c643c72ba9ef2c5d613e324e47dbb17ce45a28cbee8cb540ea48a0b3d6a23 +github.com/go-macaron/cors,v0.0.0-20190418220122-6fd6a9bfe14e,h1:auESkcVctNZnNl4EH0TuoCSJMJ7Q7ShU8FS6lDEsAC4=,0f3043631d54efca5615fe7ed819523bbe0c18726ce9e4b0cdc0ef2879aa6044 +github.com/go-macaron/csrf,v0.0.0-20180426211211-503617c6b372,h1:acrx8CnDmlKl+BPoOOLEK9Ko+SrWFB5pxRuGkKj4iqo=,90b5cbd86ff3708d41be70ad3cde77fdedd5ef485b960cc3a9ffea6f0a14902c +github.com/go-macaron/gzip,v0.0.0-20191101043656-b5609500c6fc,h1:z3gfrCJUPhdRHtd8kftnNBzI5ayZ1zQhWARPeL83JNQ=,dfcc1200b66bcb581c6984da9fa4aefc92facc3a07d182c7c37f0978b41b868f +github.com/go-macaron/i18n,v0.0.0-20160612092837-ef57533c3b0f,h1:wDKrZFc9pYJlqFOf7EzGbFMrSFFtyHt3plr2uTdo8Rg=,6c1d5fe7ed23e05ca1af7462e6deac2d993ddacd099ad794faad5c685337742d +github.com/go-macaron/inject,v0.0.0-20160627170012-d8a0b8677191,h1:NjHlg70DuOkcAMqgt0+XA+NHwtu66MkTVVgR4fFWbcI=,666bb04a5df1271326b4fcdbbdc3276400ae7e54f4ed6233792cd6e519676491 +github.com/go-macaron/session,v0.0.0-20191101041208-c5d57a35f512,h1:7ndsXTX42iYHryQz98zUsBJfStJ0kXFKgDrPmRvR400=,3581a7eb19a2a60d41aba7e85afa576c35a97659e162b83292ff67396f899845 +github.com/go-macaron/toolbox,v0.0.0-20180818072302-a77f45a7ce90,h1:3wYKrRg9IjUMfaf3H0Hh7M5Li9ge79Y7aw2yujHa2jQ=,43f2a06502408404c3b1231c3642693632cf20bc4f2cb45881bd2292b1eed714 +github.com/go-martini/martini,v0.0.0-20170121215854-22fa46961aab,h1:xveKWz2iaueeTaUgdetzel+U7exyigDYBryyVfV/rZk=,0561a4dadd68dbc1b38c09ed95bbfc5073b0a7708b9a787d38533ebd48040ec2 +github.com/go-mesh/openlogging,v1.0.1,h1:6raaXo8SK+wuQX1VoNi6QJCSf1fTOFWh7f5f6b2ZEmY=,3606bad571f959cc24382381f7d50fb321819958df37911f6ad6aa5ac3e02181 +github.com/go-ole/go-ole,v1.2.4,h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI=,c8b3ef1187d2d7dbfddc4badefcc992c029cd377ae07bff2fa05ec8972836612 +github.com/go-openapi/analysis,v0.19.5,h1:8b2ZgKfKIUTVQpTb77MoRDIMEIwvDVw40o3aOXdfYzI=,22e5ff3f88802059aa86835d8f7c25386afed1159d4e951ef0f87ef62ab4a253 +github.com/go-openapi/errors,v0.19.2,h1:a2kIyV3w+OS3S97zxUndRVD46+FhGOUBDFY7nmu4CsY=,e02e448e5a2c1ff2a011f74d41d505a2f32b369551064940630d6660c600bf3d +github.com/go-openapi/inflect,v0.19.0,h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=,fbcca36e347a2f560f50ac1c9c63f7d6cd97c8dff9800f08f370b5ce09b77c57 +github.com/go-openapi/jsonpointer,v0.19.3,h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=,1fe6122c9c9d10837439398976a2ff55e8ed905fa7e4a66f3fb0e857c6e06582 +github.com/go-openapi/jsonreference,v0.19.2,h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w=,00b2457c2d091a9817f91f55655a334bed8f75b2d6499ba9192f12564dd51dd9 +github.com/go-openapi/loads,v0.19.4,h1:5I4CCSqoWzT+82bBkNIvmLc0UOsoKKQ4Fz+3VxOB7SY=,adffcd0e2900bf0cca893e6bf014db55ebf161476367ac4dd365f8481c12616f +github.com/go-openapi/runtime,v0.19.7,h1:b2zcE9GCjDVtguugU7+S95vkHjwQEjz/lB+8LOuA9Nw=,4017d9c69d9d2789d0a3b50c6af509831c0f24bfc545f1b43224df2fc5194dbd +github.com/go-openapi/spec,v0.19.4,h1:ixzUSnHTd6hCemgtAJgluaTSGYpLNpJY4mA2DIkdOAo=,7c12cf07de1b65175474fdde12110716ab237fa862694e4e5051eb15541a964e +github.com/go-openapi/strfmt,v0.19.3,h1:eRfyY5SkaNJCAwmmMcADjY31ow9+N7MCLW7oRkbsINA=,07b9c9b2da9dffc0a830e6536b705282fd17023fe8d04aa909fe1e4e3b6306f5 +github.com/go-openapi/swag,v0.19.5,h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=,54aec6bdc63d1d6609c32b140fe74d099f8b9628d362689556537506724eaeda +github.com/go-openapi/validate,v0.19.4,h1:LGjO87VyXY3bIKjlYpXSFuLRG2mTeuYlZyeNwFFWpyM=,2b1b2612db93ed3fb411cc798150821af5c031b120097bbe6578dc4ce2d6d1df +github.com/go-playground/locales,v0.13.0,h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=,9c4b65273e135b1bdb9bafc7c0b5180a6c5936f54edecbc8807c57a9d107c6b9 +github.com/go-playground/overalls,v0.0.0-20180201144345-22ec1a223b7c,h1:3bjbKXoj7jBYdHpQFbKL2546c4dtltTHzjo+5i4CHBU=,7972d7c49470ee2e187868b30d3157ca58201f50a934caa75ce4d5b134a2a644 +github.com/go-playground/universal-translator,v0.16.0,h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM=,316fba5fa26a586e39fc11698c16e67edabd122efe26f7fff71091a00a59883a +github.com/go-redis/redis,v6.15.6+incompatible,h1:H9evprGPLI8+ci7fxQx6WNZHJSb7be8FqJQRhdQZ5Sg=,e277bbc2acb8462aca5e20ef7569a733501bc765f65303a6e5153a86e6e3090c +github.com/go-sourcemap/sourcemap,v2.1.2+incompatible,h1:0b/xya7BKGhXuqFESKM4oIiRo9WOt2ebz7KxfreD6ug=,1bdaec84a31896eee149acb563f8af0b3ce7899d916383e0b597d6b480b6a622 +github.com/go-sql-driver/mysql,v1.4.1,h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=,f128045df19d340743a155ef282116130d27e27cbc62de160b6072c751b435ba +github.com/go-stack/stack,v1.8.0,h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=,78c2667c710f811307038634ffa43af442619acfeaf1efb593aa4e0ded9df48f +github.com/go-swagger/go-swagger,v0.20.1,h1:37XFujv7lYHLOKawfzLDg4STwwgB5zhPjodN33asJto=,79cc2c57c4e9d03a9399577b942eface46073ee6fa289b86651f1c5d0c513484 +github.com/go-swagger/scan-repo-boundary,v0.0.0-20180623220736-973b3573c013,h1:l9rI6sNaZgNC0LnF3MiE+qTmyBA/tZAg1rtyrGbUMK0=,51aed4b67bce9d988d64ca6be9de2169f709a29d5ea83e78ffb1c2432b346ec6 +github.com/go-telegram-bot-api/telegram-bot-api,v4.6.4+incompatible,h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU=,a0d2549e07c67e066337cc6eadd8be2a961d13b493d4325603010d4e35e519df +github.com/go-test/deep,v1.0.3,h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=,d199ce762552766bd3baf37ae4b0255bb6a6fecf144e8ae5fa3a94f1ce30a180 +github.com/go-xorm/builder,v0.3.4,h1:FxkeGB4Cggdw3tPwutLCpfjng2jugfkg6LDMrd/KsoY=,81028f69e261c29566c24f4717458d04dbe92aebc4eb93a41c1cfeef13b7c5dd +github.com/go-xorm/core,v0.6.0,h1:tp6hX+ku4OD9khFZS8VGBDRY3kfVCtelPfmkgCyHxL0=,8a8c43c039422f38e1775a835bda46e62f4a055b4b38d57967c0e7a6c9b21d23 +github.com/go-xorm/sqlfiddle,v0.0.0-20180821085327-62ce714f951a,h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=,e539a37b8fb0d23c21e9eb1fe34db0ffcf19e5e4ae3d3b7049bb23c722c4b382 +github.com/go-xorm/xorm,v0.7.9,h1:LZze6n1UvRmM5gpL9/U9Gucwqo6aWlFVlfcHKH10qA0=,8836904c60cf227804fc843c707cd3e99122b95a97801d09dd2bddce4ed5a29f +github.com/go-yaml/yaml,v2.1.0+incompatible,h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o=,842989ea2e54ba8e4ef49cca914a5cd37176c44ccd3bb3e8c44fcbc10cb7832e +github.com/gobuffalo/attrs,v0.1.0,h1:LY6/rbhPD/hfa+AfviaMXBmZBGb0fGHF12yg7f3dPQA=,06c6c210a26c85ae291efe9d54cab9cab26fd1453f4f48962e04c89760e775d0 +github.com/gobuffalo/buffalo,v0.15.0,h1:VsxIcfJaDm4u2UirLHGgMfQpfHVwJP3JoDmGyeeNnc0=,f4553c8809a6764cefac8eefce9a868a42ee7538bdef4eadfcc06075b865a087 +github.com/gobuffalo/buffalo-docker,v1.0.7,h1:kj+AfChcev54v4N8N6PzNFWyiVSenzu6djrgxTBvbTk=,d84d8bea93f017e3ff07eddab57e0fd7007cf2516250d6fea86c8811c36cf786 +github.com/gobuffalo/buffalo-plugins,v1.14.1,h1:ZL22sNZif+k/0I9X7LB8cpVMWh7zcVjfpiqxFlH4xSY=,556641c2c1b3a9d679a3fc46727d41da225f33c63cfbf1ff721203b24e0a9b82 +github.com/gobuffalo/buffalo-pop,v1.23.1,h1:AnxJQZu/ZN7HCm3L8YBJoNWc2UiwSe6UHv5S4DfXUDA=,00dea8b0e63d3f4110b8bd9d32c086163229f56845a9f8b221e0093876065a05 +github.com/gobuffalo/clara,v0.9.1,h1:LYjwmKG0VwwW/nOG2f5jNamvAcfdm2Ysokc/eoVhtZ8=,319f607092c02686dfed2eb047d500c332ddd962341012bdcd91202bb46d37a9 +github.com/gobuffalo/depgen,v0.2.0,h1:CYuqsR8sq+L9G9+A6uUcTEuaK8AGenAjtYOm238fN3M=,efb3db0d05f712580bc8d3dce2967bd09d6c90140ac7bca1fbd5c5c4a28e1836 +github.com/gobuffalo/envy,v1.7.1,h1:OQl5ys5MBea7OGCdvPbBJWRgnhC/fGona6QKfvFeau8=,14ac6a5cd617dc05abfcb136586800f05f861d4a03d8fa66819a18c0d9eddeec +github.com/gobuffalo/events,v1.4.0,h1:Vje/vgTWs+dyhIS0U03oLpvx1SUdAqutv/hDWIz2ErM=,f6d99c722115631805f04fcf22e8edb7a4116bc65d698ac05c58b6a7f768efdc +github.com/gobuffalo/fizz,v1.9.5,h1:Qh0GkP7MYtJs9RZwBkPJ0CzEXynVowdNfrjg8b+TOxA=,2f645d789550f8f97039e1c4ce3e3f09dfeec28d85c8977c2b20caa06cd75b0c +github.com/gobuffalo/flect,v0.1.6,h1:D7KWNRFiCknJKA495/e1BO7oxqf8tbieaLv/ehoZ/+g=,a7011c8d3f59bac18512c76de610bf1a1f022a01ac6695e0c5af7498d33be613 +github.com/gobuffalo/genny,v0.4.1,h1:ylgRyFoVGtfq92Ziq0kyi0Sdwh//pqWEwg+vD3eK1ZA=,4ecf29587a8cbe069fc6b298d9a3cb674a8008ca4e08233904a8cba91d1ba21b +github.com/gobuffalo/gitgen,v0.0.0-20190315122116-cc086187d211,h1:mSVZ4vj4khv+oThUfS+SQU3UuFIZ5Zo6UNcvK8E8Mz8=,c79975f91dd2fd691d70e29678034eb2dc94b5da2f01b0790a919de9d2a632ac +github.com/gobuffalo/github_flavored_markdown,v1.1.0,h1:8Zzj4fTRl/OP2R7sGerzSf6g2nEJnaBEJe7UAOiEvbQ=,2d73a2baad09dc0d0f0c01549c35e83ab0c18c97f859191e54a632c2fb0eaad2 +github.com/gobuffalo/gogen,v0.2.0,h1:Xx7NCe+/y++eII2aWAFZ09/81MhDCsZwvMzIFJoQRnU=,f60900e595a3779b95b299ca9e74c517523860994a0477b360ac447d3318ccbd +github.com/gobuffalo/helpers,v0.4.0,h1:DR/iYihrVCXv1cYeIGSK3EZz2CljO+DqDLQPWZAod9c=,17ae2b069c0ca73b11b4ace6793617e0620f8d8ef171b0010b91e243c4a3bbe3 +github.com/gobuffalo/here,v0.2.3,h1:1xamq7i4CKjGgICCXY0qpxPeXGdB8oVNSevkpqwd5X4=,3808d0fbc11c58cfb0e7b430b9fc30024ba3781febe8e2601a8e2b8f76e48c00 +github.com/gobuffalo/httptest,v1.4.0,h1:DaoTl/2iFRTk9Uau6b0Lh644tcbRtBNMHcWg6WhieS8=,9d1b48f3e525ab4661d02b3fac86f89fe27f648b1ff8e607f39a353c60c0f315 +github.com/gobuffalo/licenser,v1.4.0,h1:S8WY0nLT9zkBTjFYcbJ0E9MEK7SgE86aMfjsnuThQjY=,3e126adeb06dcaee29376804b463ed33af2b821579162039e8a16e45d0334cdc +github.com/gobuffalo/logger,v1.0.1,h1:ZEgyRGgAm4ZAhAO45YXMs5Fp+bzGLESFewzAVBMKuTg=,43510255e52f7472ec17a76847ca42cebab6efe0b573a5dcfd8261e00d86d3b7 +github.com/gobuffalo/makr,v1.2.0,h1:TA6ThoZEcq0F9FCrc/7xS1ycdCIL0K6Ux+5wmwYV7BY=,113259ce8e945acf3dd184534ab6135240fde6b57d5c6ee3787e7c124e313502 +github.com/gobuffalo/mapi,v1.1.0,h1:VEhxtd2aoPXFqVmliLXGSmqPh541OprxYYZFwgNcjn4=,162640cc01d04543030d55ed51841d673cb8257fd78b069a79010e52ec996b73 +github.com/gobuffalo/meta,v0.2.0,h1:QSDlR2nbGewl0OVL9kqtU8SeKq6zSonrKWB6G3EgADs=,6a44e2a02126c65d2e2f09de5f732327001ac05d542abcabb8dc286422469e9a +github.com/gobuffalo/mw-basicauth,v1.0.7,h1:9zTxCpu0ozzwpwvw5MO31w8nEoySNRNfZwM1YAWfGZs=,da5e2767a9d91e14efb25209c9b9dcf5ad07b551d6d54670c43c6225c8e94084 +github.com/gobuffalo/mw-contenttype,v0.0.0-20190129203934-2554e742333b,h1:6LKJWRvshByPo/dvV4B1E2wvsqXp1uoynVndvuuOZZc=,f9e2f7cce4e88ff8d6f86bc61076179b4f23a85eb5fd0a5f28793ef1e7889fab +github.com/gobuffalo/mw-csrf,v0.0.0-20190129204204-25460a055517,h1:pOOXwl1xPLLP8oZw3e3t2wwrc/KSzmlRBcaQwGpG9oo=,b47a0879eadba5c6774ad37c66afea4998767d9df1295b7b17f3469282cc92f2 +github.com/gobuffalo/mw-forcessl,v0.0.0-20180802152810-73921ae7a130,h1:v94+IGhlBro0Lz1gOR3lrdAVSZ0mJF2NxsdppKd7FnI=,533187beeb18b977c8436d0a5596c1bd420b30cce55589cb11af592df063470c +github.com/gobuffalo/mw-i18n,v0.0.0-20190129204410-552713a3ebb4,h1:c1fFPCxA7SozZPqMhpfZoOVa3wUpCl11gyCEZ4nYqUE=,96a1754eff9c9a75c6b48fc3bc9ab102bbf5d23c103b37a82cc88c666c0dbf9b +github.com/gobuffalo/mw-paramlogger,v0.0.0-20190129202837-395da1998525,h1:2QoD5giw2UrYJu65UKDEo9HFcz9yun387twL2zzn+/Q=,d2e3b1baa234032585cc0e7dc1950681dbc05d960ee958578e470df9fa3b8f18 +github.com/gobuffalo/mw-tokenauth,v0.0.0-20190129201951-95847f29c5c8,h1:dqwRMSzfhe3rL0vMDaRvc2ozLqxapWFBEDH6/f0nQT0=,eb6f82200a81da34baa366475479069f08ed797d5edd4976c9f2af1027d37f1c +github.com/gobuffalo/nulls,v0.1.0,h1:pR3SDzXyFcQrzyPreZj+OzNHSxI4DphSOFaQuidxrfw=,a77a09fd75234e7e5589640fae5d261c03ede9ab5ec626406f24c89dfeba2b38 +github.com/gobuffalo/packd,v0.3.0,h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4=,c7a9263fd464b9f5629bf161521f420b2c40f7780ed6a9ce88184dc4136787a5 +github.com/gobuffalo/packr,v1.30.1,h1:hu1fuVR3fXEZR7rXNW3h8rqSML8EVAf6KNm0NKO/wKg=,20aeea726f6db2ffc8b6dd90b1dce8991f0fd66152a270efdd21c0905b12d5f5 +github.com/gobuffalo/packr/v2,v2.7.1,h1:n3CIW5T17T8v4GGK5sWXLVWJhCz7b5aNLSxW6gYim4o=,60cd83772938a617b37c26a4924ee1f95008d53481724f801eee647e68ce22b1 +github.com/gobuffalo/plush,v3.8.3+incompatible,h1:kzvUTnFPhwyfPEsx7U7LI05/IIslZVGnAlMA1heWub8=,312e219c9827bb7d2dfc954f03fcaa275a3d9eb70687a62ecebad84ede4c51a7 +github.com/gobuffalo/plushgen,v0.1.2,h1:s4yAgNdfNMyMQ7o+Is4f1VlH2L1tKosT+m7BF28C8H4=,0efa90fac0c464409201fa74cace63c4307ac3700a23b3df7c9a9c1c976f0875 +github.com/gobuffalo/pop,v4.12.2+incompatible,h1:WFHMzzHbVLulZnEium1VlYRnWkzHz39FzVLov6rZdDI=,de2837b63e54b15d99234202839e0394183c4ff7c45b9d99162a407c95574003 +github.com/gobuffalo/release,v1.14.0,h1:+Jy7eLN5md6Fg+AMuFRUiK4sTNq4+zXxRho7/wJe1HU=,a0f34f0d3f02ea43434436936766f185b97204a073a605e720190c433c30aaa5 +github.com/gobuffalo/shoulders,v1.2.0,h1:XcPmWbzN7944VXS/I//R7o2eupUHEp3mLFWbUlk1Sco=,4c129ae195bd14520a38c608ba3a27aca674745c1f79fbcce03dacf829802ac6 +github.com/gobuffalo/syncx,v0.0.0-20190224160051-33c29581e754,h1:tpom+2CJmpzAWj5/VEHync2rJGi+epHNIeRSWjzGA+4=,ad9a571b43d72ecce24b8bed85636091710f22d8b06051e1e19ef2051f3e00da +github.com/gobuffalo/tags,v2.1.6+incompatible,h1:xaWOM48Xz8lBh+C8l5R7vSmLAZJK4KeWcLo+0pJ516g=,99bd74d4144bcdfba45fa501cd8d6dec78dc5b0404bbbfebf5bced5b976bb911 +github.com/gobuffalo/uuid,v2.0.5+incompatible,h1:c5uWRuEnYggYCrT9AJm0U2v1QTG7OVDAvxhj8tIV5Gc=,6ab82616cbb02ddd78b9b7db14f580e2e212ceeadcfccff387a973b04be8db37 +github.com/gobuffalo/validate,v2.0.3+incompatible,h1:6f4JCEz11Zi6iIlexMv7Jz10RBPvgI795AOaubtCwTE=,53d876ba454e5e0604ab8078bfb1fca54dcd3ddd859c850cafce757c5f40153d +github.com/gobuffalo/x,v0.0.0-20190224155809-6bb134105960,h1:DoUD23uwnzKJ3t5HH2SeTIszWmc13AV9TAdMhtXQts8=,2435ac54f3ea5c024aea1d4db42a87011bb877f18f0f273f7b3e19b7093c3cfd +github.com/gobwas/glob,v0.2.3,h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=,0cfe486cd63d45ed4cb5863ff1cbd14b15e4b9380dcbf80ff26991b4049f4fdf +github.com/gobwas/httphead,v0.0.0-20180130184737-2c6c146eadee,h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=,5a43ed4a7cd2b063b634f0df5311c0dfa6576683bfc1339f2c5b1b1127fc392b +github.com/gobwas/pool,v0.2.0,h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=,52604b1456b92bb310461167a3e6515562f0f4214f01ed6440e3105f78be188f +github.com/gobwas/ws,v1.0.2,h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=,f9e5c26e83278f19958c68be7b76ad6711c806b6dae766fad7692d2af867bedd +github.com/gocolly/colly,v1.2.0,h1:qRz9YAn8FIH0qzgNUw+HT9UN7wm1oF9OBAilwEWpyrI=,82f210242c4efda461bb6d2cd0543bbadf322c23b840043f236dc1fd74af9325 +github.com/gocql/gocql,v0.0.0-20191018090344-07ace3bab0f8,h1:ZyxBBeTImqFLu9mLtQUnXrO8K/SryXE/xjG/ygl0DxQ=,d38e5bd51d411bc942f295950d87d80e607a8eb186d51b445cc6c2b985681b18 +github.com/godbus/dbus,v4.1.0+incompatible,h1:WqqLRTsQic3apZUK9qC5sGNfXthmPXzUZ7nQPrNITa4=,107ef979cca9f2720633f118263afeb9acb0bf0703cc1e860098d5ec48efccb8 +github.com/gofrs/flock,v0.7.1,h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc=,ee433032ec18df1e38d2385d7f9448820c5a017d895cb930cd8801401940137c +github.com/gofrs/uuid,v3.2.0+incompatible,h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=,4139fd148a7a9389629659253722b302791146583e0db94e351a325ecd06abbf +github.com/gogf/gf,v1.9.10,h1:lPBf0EOxv6AXVWN46EKLID0GMHDGOrs4ZAi/RUJbt+c=,83a8cf0cc2557c1e1b3cdb2112953ca303a09cb6d457d2102b3921db1bfd6fe5 +github.com/gogits/chardet,v0.0.0-20150115103509-2404f7772561,h1:deE7ritpK04PgtpyVOS2TYcQEld9qLCD5b5EbVNOuLA=,4b5c6d4b26d381d37b9a5538b9f2dc29d11f422653b19a2047e439a268c3f5ba +github.com/gogits/cron,v0.0.0-20160810035002-7f3990acf183,h1:EBTlva3AOSb80G3JSwY6ZMdILEZJ1JKuewrbqrNjWuE=,746b3b98243fc5ae7127c5102f9ba4f0b88238d081e9cb113d61be2ec16a6241 +github.com/gogo/googleapis,v1.3.0,h1:M695OaDJ5ipWvDPcoAg/YL9c3uORAegkEfBqTQF/fTQ=,ee9e1dda02a5a415c41b5bdff7f6835e929ea89ff3dc1c766510ee909e03c6c3 +github.com/gogo/protobuf,v1.3.1,h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=,4b63e18981e30565f60b7305e3de71ff9aa42cfccf15b88b3813dd2ba6c27be1 +github.com/gogs/chardet,v0.0.0-20150115103509-2404f7772561,h1:aBzukfDxQlCTVS0NBUjI5YA3iVeaZ9Tb5PxNrrIP1xs=,53b6234983c0828d620ba418be5b4e467ef8c9d634bb3d0a2bd4056e3dfa38b3 +github.com/gogs/cron,v0.0.0-20171120032916-9f6c956d3e14,h1:yXtpJr/LV6PFu4nTLgfjQdcMdzjbqqXMEnHfq0Or6p8=,913889f3018853808015c9198e6d3a25f586d88d88493c3de36530eef967664c +github.com/gogs/git-module,v0.8.2,h1:fCi0Lt8VZuFgjCXeLpkhC3irKLArK4oZ69gFvrDXx/s=,e4010dd8fdfe88a65fa8af6ecf97d7e16d4235d0eeb6a0b4b1f4e4d201c70d23 +github.com/gogs/go-gogs-client,v0.0.0-20190710002546-4c3c18947c15,h1:tgEyCCe4+o8A2K/PEi9lF0QMA6XK+Y/j/WN01LnNbbo=,cc5dcea1cca3d3d3e90a0ad548a660250b1299a61519f6dda5dcd7f2f1412daf +github.com/gogs/go-libravatar,v0.0.0-20161120025154-cd1abbd55d09,h1:UdOSIHZpkYcajRbfebBYzFDsL3SuqObH3bvKYBqgKmI=,f81991af4a649aa273bc0c3e7251f107ba0967f5d83553f5a18ed688d937eff0 +github.com/gogs/gogs,v0.11.91,h1:p8kTD9Sn6a/14u6ain6j0dPENMZ0gVEiM7phSIAL29E=,b41695c115f4e2dfc96bfbc7443fa6f91a6d2c8b32d32db4262e6977f5d55fa7 +github.com/gogs/minwinsvc,v0.0.0-20170301035411-95be6356811a,h1:8DZwxETOVWIinYxDK+i6L+rMb7eGATGaakD6ZucfHVk=,fb48a56a9f610b061af186008072fbd6e51055a12c168e1e347ecf9a05f25767 +github.com/gohugoio/hugo,v0.59.1,h1:nxaeKEY52cdpx3wZN/EcY6dEqbgeFsZaeNkDL8azeZ8=,508257b11bfc1ec77d3993a13929de63fa08e70ae26cd7c53f03857b3db9bbdf +github.com/gohugoio/testmodBuilder/mods,v0.0.0-20190520184928-c56af20f2e95,h1:sgew0XCnZwnzpWxTt3V8LLiCO7OQi3C6dycaE67wfkU=,0d6eabbeb381b08c84e7191fcecc49027ad3382997441180b2d6eea3fafc81b6 +github.com/goji/httpauth,v0.0.0-20160601135302-2da839ab0f4d,h1:lBXNCxVENCipq4D1Is42JVOP4eQjlB8TQ6H69Yx5J9Q=,8467ed1df8ffba8da7ead144b656b6281469ab4d122adf3edf496175ad870192 +github.com/goki/freetype,v0.0.0-20181231101311-fa8a33aabaff,h1:W71vTCKoxtdXgnm1ECDFkfQnpdqAO00zzGXLA5yaEX8=,80884151cd73d38904e4370afba3b870345a883a77c395194582202d805d7d74 +github.com/goki/ki,v0.9.8,h1:SzVTxJrd0ZcnkRTinZdbc41nIFmocJ7pyllEyBzNmys=,ce62e162090d566e2f9cb5b1659327a84c646dced32729e24b420cde4d5cb714 +github.com/goki/prof,v0.0.0-20180502205428-54bc71b5d09b,h1:3zU6niF8uvEaNtRBhOkmgbE/Fx7D6xuALotArTpycNc=,f46b93b6c42a97f06a2f658e49243972f4bd469b296f1010609c8d649163b73f +github.com/golang-collections/collections,v0.0.0-20130729185459-604e922904d3,h1:zN2lZNZRflqFyxVaTIU61KNKQ9C0055u9CAfpmqUvo4=,7847b09c355215616db6309597757ff6be2cf44781d800cdad1628f141dc82ee +github.com/golang-migrate/migrate/v3,v3.5.2,h1:SUWSv6PD8Lr2TGx1lmVW7W2lRoQiVny3stM4He6jczQ=,5086537ee116e958cf9647e28f843a0ac17f5de75ab642e5aef1fe2b360b0e30 +github.com/golang-sql/civil,v0.0.0-20190719163853-cb61b32ac6fe,h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=,22fcd1e01cabf6ec75c6b6c8e443de029611c9dd5cc4673818d52dac465ac688 +github.com/golang/freetype,v0.0.0-20170609003504-e2365dfdc4a0,h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=,cdcb9e6a14933dcbf167b44dcd5083fc6a2e52c4fae8fb79747c691efeb7d84e +github.com/golang/gddo,v0.0.0-20180828051604-96d2a289f41e,h1:8sV50nrSGwclVxkCGHxgWfJhY6cyXS2plGjGvUzrMIw=,9a0683005c7700bb1b7ac155597592d15d02f510a0d2c334f8564c43b9072107 +github.com/golang/glog,v0.0.0-20160126235308-23def4e6c14b,h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=,36b3c522c8102dfe74ca96e474c4c361750bf2bb85bc3cefe4f074c07d6825a9 +github.com/golang/groupcache,v0.0.0-20191027212112-611e8accdfc9,h1:uHTyIjqVhYRhLbJ8nIiOJHkEZZ+5YoOsAbD3sk82NiE=,a4815d7048e9a1dd79a72a09d4c9a946ccff837695d046c7f0f5c24037ce18b3 +github.com/golang/lint,v0.0.0-20180702182130-06c8688daad7,h1:2hRPrmiwPrp3fQX967rNJIhQPtiGXdlQWAxKbKw3VHA=,66e95adf2c1feb4de316d2c0ba9e04a22322df010a67b1054ad3d4fb2f9a1791 +github.com/golang/mock,v1.3.1,h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=,3209f2030646855a3644736b5d7ce2cd9076856cac2f50360805a19c38b7bc45 +github.com/golang/protobuf,v1.3.2,h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=,a004ba3acb85e012cb9e468e1d445a81cfeeb4b4db7e9802f30aa500a8341851 +github.com/golang/snappy,v0.0.1,h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=,0a9a73d55340a8e6d17e72684cf90618b275b6034ce83299abb55ed8fb3860bd +github.com/golangplus/bytes,v0.0.0-20160111154220-45c989fe5450,h1:7xqw01UYS+KCI25bMrPxwNYkSns2Db1ziQPpVq99FpE=,2904c49772d1bade7c81ddae2fa70e42bdce7b006c871c8106d1feb14fe2982b +github.com/golangplus/fmt,v0.0.0-20150411045040-2a5d6d7d2995,h1:f5gsjBiF9tRRVomCvrkGMMWI8W1f2OBFar2c5oakAP0=,2afd341a4d32c84532d6d44574718e1b8000aa57cfc21ced284612fc92b61217 +github.com/golangplus/testing,v0.0.0-20180327235837-af21d9c3145e,h1:KhcknUwkWHKZPbFy2P7jH5LKJ3La+0ZeknkkmrSgqb0=,fc111aa59d03741dad00f05ce869fcb44f5d75b841413e21e7301bc538a0255e +github.com/gomodule/redigo,v2.0.0+incompatible,h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=,77342da7b962489363b3661803ee2fba72b23b8e97af0241877ce6ab8a95d194 +github.com/gonum/blas,v0.0.0-20181208220705-f22b278b28ac,h1:Q0Jsdxl5jbxouNs1TQYt0gxesYMU4VXRbsTlgDloZ50=,bfcad082317ace0d0bdc0832f0835d95aaa90f91cf3fce5d2d81ccdd70c38620 +github.com/gonum/floats,v0.0.0-20181209220543-c233463c7e82,h1:EvokxLQsaaQjcWVWSV38221VAK7qc2zhaO17bKys/18=,52afb5e33a03b027f8f451e23618c2decbe4443f996a203e332858c1a348a627 +github.com/gonum/graph,v0.0.0-20190426092945-678096d81a4b,h1:LilU5ERRFWL+2D6yR1PL2oeS4n+xyTq1vfv39LFVaeE=,411fd86d898ad7ea8c1145610a27f0f13153c86b3ef5e78cb80431125082b5a6 +github.com/gonum/internal,v0.0.0-20181124074243-f884aa714029,h1:8jtTdc+Nfj9AR+0soOeia9UZSvYBvETVHZrugUowJ7M=,e7f40a97eee3574c826a1e75f80ecd94c27853feaab5c43fde7dd95ba516c9dc +github.com/gonum/lapack,v0.0.0-20181123203213-e4cdc5a0bff9,h1:7qnwS9+oeSiOIsiUMajT+0R7HR6hw5NegnKPmn/94oI=,f38b72e072728121b9acf5ae26d947aacc0024dddc09d19e382bacd8669f5997 +github.com/gonum/matrix,v0.0.0-20181209220409-c518dec07be9,h1:V2IgdyerlBa/MxaEFRbV5juy/C3MGdj4ePi+g6ePIp4=,9cea355e35e3f5718b2c69f65712b2c08a1bec13b3cfadf168d98b41b043dd63 +github.com/google/btree,v1.0.0,h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=,8dbcb36f92c7a6dc5f6aef5c26358d98b72caee69829b5b33dddabada2047785 +github.com/google/cadvisor,v0.34.0,h1:No7G6U/TasplR9uNqyc5Jj0Bet5VSYsK5xLygOf4pUw=,5a3807f43a14e6a03b7ceb9ea11f8ac241a42286be90c3b2cba49ee811111848 +github.com/google/certificate-transparency-go,v1.0.21,h1:Yf1aXowfZ2nuboBsg7iYGLmwsOARdV86pfH3g95wXmE=,7ddb21b272632236d5fb35b35c837f39d38390ea8dcb97c9f0f5d5aa561c3366 +github.com/google/flatbuffers,v1.11.0,h1:O7CEyB8Cb3/DmtxODGtLHcEvpr81Jm5qLg/hsHnxA2A=,ff61e5077ecc7d46a2020c1b42e0a6405b50271f396d4dcc50c683345059af76 +github.com/google/go-cmp,v0.3.2-0.20191028172631-481baca67f93,h1:VvBteXw2zOXEgm0o3PgONTWf+bhUGsCaiNn3pbkU9LA=,6682f890f076aaa03f2c2afb6bc7304c9d602b9e23ff212f8a9a64f44f432dbc +github.com/google/go-containerregistry,v0.0.0-20191029173801-50b26ee28691,h1:9fkqC5Bq8l2FQgcW6FQbPDUeZvExyg7okl+s4Gg9Jrs=,7bef2c87f7ca8a39e04c770b38160dd5cfdd508546f96fab427225d12d40d85a +github.com/google/go-github,v17.0.0+incompatible,h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=,9831222a466bec73a21627e0c3525da9cadd969468e31d10ecae8580b0568d0e +github.com/google/go-github/v21,v21.0.0,h1:tn4/tmCgPAsezJFwZcMnE7U0R9/AtKRBGX4s4LFdDzI=,0b25aebca5386cdb52515402b81a8e0a676ac30f9843feb0a47a1944b7c8b527 +github.com/google/go-github/v24,v24.0.1,h1:KCt1LjMJEey1qvPXxa9SjaWxwTsCWSq6p2Ju57UR4Q4=,4dd0a57a527a1cc52e6619e9d2e1936534439426f0eb065bfbe1e7c03b60d465 +github.com/google/go-github/v28,v28.1.1,h1:kORf5ekX5qwXO2mGzXXOjMe/g6ap8ahVe0sBEulhSxo=,621cca7f4889897317c18ed021fe0f55c279769f11357d90eb21a29c5ea78d04 +github.com/google/go-querystring,v1.0.0,h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=,1c0a0b81b921ee270e47e05cf0bf8df4475de850671e553c07740849068d4f9f +github.com/google/go-replayers/grpcreplay,v0.1.0,h1:eNb1y9rZFmY4ax45uEEECSa8fsxGRU+8Bil52ASAwic=,794ad7fb2669ea1d1305cf7717a1329146635637739bf2e26d858a318e87f99b +github.com/google/go-replayers/httpreplay,v0.1.0,h1:AX7FUb4BjrrzNvblr/OlgwrmFiep6soj5K2QSDW7BGk=,cf6d3e2262e94db5bad86d944f2f97507b1ffc2943e4385f140eb6f9a01f8e7b +github.com/google/go-tpm,v0.2.0,h1:3Z5ZjNRQ0CsUj3yWXtbbx4Vfb/sQapdSeZJvuaKuQzc=,7e90cb155fa3e7759caa1fe5df1ca43520a7f8e1a31e540573cc8290ff523a23 +github.com/google/go-tpm-tools,v0.0.0-20190906225433-1614c142f845,h1:2WNNKKRI+a5OZi5xiJVfDoOiUyfK/BU1D4w+N6967F4=,2e41ca1e24a1ba5eedf980331527d6a5ad09b8ef653bbd040321572899eff8a2 +github.com/google/gofuzz,v1.0.0,h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=,752570262575bbcb5f0107dbd80a463abacaf51e94e15f96f5bc4166ff2d33e1 +github.com/google/gopacket,v1.1.17,h1:rMrlX2ZY2UbvT+sdz3+6J+pp2z+msCq9MxTU6ymxbBY=,008645038244e12a1bfbda2317372ec34a514250741139b8e4842de7f98639d4 +github.com/google/gxui,v0.0.0-20151028112939-f85e0a97b3a4,h1:OL2d27ueTKnlQJoqLW2fc9pWYulFnJYLWzomGV7HqZo=,be209ad45b16077b010faef4a7bcbf0723dfbe47869a6f4c0aacd534e7fcbfb1 +github.com/google/martian,v2.1.1-0.20190517191504-25dcb96d9e51+incompatible,h1:xmapqc1AyLoB+ddYT6r04bD9lIjlOqGaREovi0SzFaE=,dfc5eac3877863c1f231457f96c54c915ea1c86f86c590710b7477f96e1ba0f3 +github.com/google/netstack,v0.0.0-20191031000057-4787376a6744,h1:wKeh74w+ydKcE1Eo44WDzIOcPHWmxxmtAzkAL0Mlspc=,dd74d0c9fadfb29db3bd09da657cb95300255d562ce596e88c865a71ee5d2519 +github.com/google/pprof,v0.0.0-20191028172815-5e965273ee43,h1:59gkLC5pLENSgzw9Gx73BQQho5i//80XwgIIYWxZjp4=,667012da0f67eb7822d16f532e850091a58c1efebeef5047df9a02e972112484 +github.com/google/readahead,v0.0.0-20161222183148-eaceba169032,h1:6Be3nkuJFyRfCgr6qTIzmRp8y9QwDIbqy/nYr9WDPos=,3a2435123538463dc3412a2eb1be033b7cf8105775c1ff3524351ec405fa1469 +github.com/google/renameio,v0.1.0,h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=,b8510bb34078691a20b8e4902d371afe0eb171b2daf953f67cb3960d1926ccf3 +github.com/google/rpmpack,v0.0.0-20191101142923-13d81472ccfe,h1:P1WflKHEgTAYe39btxYzeds84DhxQSLj4hfoNn0tCyQ=,5144bdeda051f10f407f1f798502ec0d7599f9c4a7e0a79c3711fe2b79f5cae4 +github.com/google/shlex,v0.0.0-20181106134648-c34317bd91bf,h1:7+FW5aGwISbqUtkfmIpZJGRgNFg2ioYPvFaUxdqpDsg=,250fc48c105475c54cc8c9fe5c110e31986590433de2608740d6592d0dc0a4c6 +github.com/google/subcommands,v1.0.1,h1:/eqq+otEXm5vhfBrbREPCSVQbvofip6kIz+mX5TUH7k=,de4249d9823a0509df32ebad2787d5e54c9b53c1059592bd9a3bb0c4cf58034d +github.com/google/uuid,v1.1.1,h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=,2b0cbc45fb0e21c8bfebbae9b04babc196d9f06d9f3b9dec5e2adc8cfd0c1b81 +github.com/google/wire,v0.3.0,h1:imGQZGEVEHpje5056+K+cgdO72p0LQv2xIIFXNGUf60=,38eb402dbe84aee2f891df0e62623f9ff5615dfeb1e4f631eaac5cf1859c9ea6 +github.com/googleapis/gax-go,v2.0.2+incompatible,h1:silFMLAnr330+NRuag/VjIGF7TLp/LBrV2CJKFLWEww=,36fe8c993c8f90067bffbba78f1325ff45ae60c8a85b778d798c56067e55c19e +github.com/googleapis/gax-go/v2,v2.0.5,h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=,846b017e21fc01f408774051d4a10bfccd7c294e10a1ad5d725278889d5f1d42 +github.com/googleapis/gnostic,v0.3.1,h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk=,33277bd9aab84cf04d058a5e2e1dbb5f3c023ba30c6127b4cc8a6662a776de53 +github.com/gopackage/ddp,v0.0.0-20170117053602-652027933df4,h1:4EZlYQIiyecYJlUbVkFXCXHz1QPhVXcHnQKAzBTPfQo=,76b2493aae8a5513b707e4f6c529f57175cca6c834dd19072a51ed3974cd77bc +github.com/gophercloud/gophercloud,v0.6.0,h1:Xb2lcqZtml1XjgYZxbeayEemq7ASbeTp09m36gQFpEU=,f5be75a3b128c9de7385dd7e2a8ec9fba18fb46dcf57624d88249ae99e188ed2 +github.com/gophercloud/utils,v0.0.0-20190128072930-fbb6ab446f01,h1:OgCNGSnEalfkRpn//WGJHhpo7fkP+LhTpvEITZ7CkK4=,c98b6d529b47679302d175f04d7b635824c292edc8a5ede807f9ba8145517ce7 +github.com/gopherjs/gopherjs,v0.0.0-20190915194858-d3ddacdb130f,h1:TyqzGm2z1h3AGhjOoRYyeLcW4WlW81MDQkWa+rx/000=,ff395ad20350783713974a6b4d03254b811d83c0c0caa13bcb329462a7263f70 +github.com/gopherjs/jquery,v0.0.0-20180404123100-3ba2b901425e,h1:Tf0PnEo36tq56/JezxbbiFpEce0pmK6tY7hS6PNS7tI=,26fb481ef7f7010ec901990527d7ef7b06bc18c38cb617db77f8b61263b5b453 +github.com/gopherjs/jsbuiltin,v0.0.0-20180426082241-50091555e127,h1:atBEgNR1C5+LFkl8ipQtLee9RStheS8YeCSkiYqBhOg=,603151a77e4be25c8389014b06449520c2ad5856f0161590a5de5f01bee28912 +github.com/goreleaser/goreleaser,v0.120.5,h1:N3VirNAK9u30Wj7xulfE9/cCvptO0vl+CLhaMEVGbGs=,9c516d6e8db8c6800102ca68e3f674a62dd42877d7785607f56c22f6dc9b5a9e +github.com/goreleaser/nfpm,v1.1.2,h1:9+hnNm/h/ANQWLxZixNO562w4tIO/8VlgCwOKwwZTX4=,9781a05527458d352a744a524c94473d2a72694fd54bc559a5888158bb4fa1fb +github.com/gorhill/cronexpr,v0.0.0-20180427100037-88b0669f7d75,h1:f0n1xnMSmBLzVfsMMvriDyA75NB/oBgILX2GcHXIQzY=,742d8957d3f9fe773150fb3164868a755b2af5b705b38c72c45ca5386715c617 +github.com/gorilla/context,v1.1.1,h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=,4ec8e01fe741a931edeebdee9348ffb49b5cc565ca245551d0d20b67062e6f0b +github.com/gorilla/csrf,v1.6.0,h1:60oN1cFdncCE8tjwQ3QEkFND5k37lQPcRjnlvm7CIJ0=,6fa6b9d34ba1c2409e6575db396f57607c5283e397d38a271b6930c666f166b0 +github.com/gorilla/handlers,v1.4.2,h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg=,9e47491112a46d32e372be827899e8678a881f6407f290564c63e8725b5e9a19 +github.com/gorilla/mux,v1.7.3,h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=,9ffc6c6c1194cb2b9f39237ff90b20eb4a55273404c97364ed9a6500e9571fe3 +github.com/gorilla/pat,v1.0.1,h1:OeSoj6sffw4/majibAY2BAUsXjNP7fEE+w30KickaL4=,e0dedacf6f405854b94932a59b410bbda64d4fff8111b674db987ce242bc9d57 +github.com/gorilla/rpc,v1.1.0,h1:marKfvVP0Gpd/jHlVBKCQ8RAoUPdX7K1Nuh6l1BNh7A=,0e83ae0cbc4164cdaf0b808413f97fed7a90e2096095c14f5495b6dbfaa34266 +github.com/gorilla/schema,v1.1.0,h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY=,42a6d7dc873e8ba1822551b4e15304d5654a11f6da3cccdc270be847148bbfaf +github.com/gorilla/securecookie,v1.1.1,h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=,dd83a4230e11568159756bbea4d343c88df0cd1415bbbc7cd5badad6cd2ed903 +github.com/gorilla/sessions,v1.2.0,h1:S7P+1Hm5V/AT9cjEcUD5uDaQSX0OE577aCXgoaKpYbQ=,8753d00ae6cf8ea0e28c195d4b87875384e2ed79df7eba4cf210fdf9ab0294df +github.com/gorilla/websocket,v1.4.1,h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=,86eb427567de9e2dc84da52ee4f4315496c5ffc2152928df0e3ac4ce8a359ff7 +github.com/gosimple/slug,v1.9.0,h1:r5vDcYrFz9BmfIAMC829un9hq7hKM4cHUrsv36LbEqs=,0f72d897e3decea434cdc68c7d0226afbda7d6b1908e955bf406333e7d6bb4a7 +github.com/gosuri/uitable,v0.0.3,h1:9ZY4qCODg6JL1Ui4dL9LqCF4ghWnAOSV2h7xG98SkHE=,1316f88b6b2689d941a4727889818705a289c72d7f1f4d2d9cf5cd06fecd0b7b +github.com/gotestyourself/gotestyourself,v2.2.0+incompatible,h1:AQwinXlbQR2HvPjQZOmDhRqsv5mZf+Jb1RnSLxcqZcI=,653f8ec3ed62f8d235ab67cfc56e7c814d4ac6f56f24000802b32728523c074c +github.com/gotnospirit/makeplural,v0.0.0-20180622080156-a5f48d94d976,h1:b70jEaX2iaJSPZULSUxKtm73LBfsCrMsIlYCUgNGSIs=,5750c916115b851f4881b76d90128802d090558958aa821c691d4fa378018093 +github.com/gotnospirit/messageformat,v0.0.0-20180622080451-0eab1176a3fb,h1:akgcoKcMcMOlzb6fdycEck1Vc3+y7ubUjO6hgAOyqC8=,7189231c806aa1988b50a82019c5f972a5f1b82e61c94776999728ec1894cd29 +github.com/graarh/golang-socketio,v0.0.0-20170510162725-2c44953b9b5f,h1:utzdm9zUvVWGRtIpkdE4+36n+Gv60kNb7mFvgGxLElY=,f41faefdf625d1c04113636d467a9fa47fe083148d7393fa65c0f08e3a4078c3 +github.com/grafana/globalconf,v0.0.0-20181214112547-7a1aae0695d9,h1:2/Bz5A5zR4TMGd9yvgGMal7nhQwHBt5/dfp0sbJFfes=,0393f4fa690096ea26c76373e99f9d9f3bfc9b34e5acd08d639b68f68af7b5e2 +github.com/grandcat/zeroconf,v0.0.0-20190424104450-85eadb44205c,h1:svzQzfVE9t7Y1CGULS5PsMWs4/H4Au/ZTJzU/0CKgqc=,2d364bea1939e3ec55b732cae452feb3182fc1d8ffa30f35aa42c0181709d138 +github.com/graph-gophers/graphql-go,v0.0.0-20190225005345-3e8838d4614c,h1:YyFUsspLqAt3noyPCLz7EFK/o1LpC1j/6MjU0bSVOQ4=,fad60e1061e15848aff79c6620f1cf55a9dd87d58ca2f57fea50c35322c817ac +github.com/graphql-go/graphql,v0.7.9-0.20190403165646-199d20bbfed7,h1:E45QFM7IqRdFnuyFk8GSamb42EckUSyJ55rtVB/w8VQ=,6e9d51c4dc431d2d7c1348fa2b3358ed8e57338a07750177698bde29c913e786 +github.com/gravitational/trace,v0.0.0-20190726142706-a535a178675f,h1:68WxnfBzJRYktZ30fmIjGQ74RsXYLoeH2/NITPktTMY=,6fb8317692ac3aa8280cd4b4749970ec6652ecbe2c629cd43b52005f9a992197 +github.com/graymeta/stow,v0.2.4,h1:qDGstknYXqcnmBQ5TRJtxD9Qv1MuRbYRhLoSMeUDs7U=,67b4e728448b89c2233da14c22f18fe6c720e88a858dff2cd3c7405c7ea10493 +github.com/gregjones/httpcache,v0.0.0-20190611155906-901d90724c79,h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=,73d773791d582cad0d90942e7d92f52d82f13119dd78e849bbd77fae2acc0276 +github.com/grokify/html-strip-tags-go,v0.0.0-20190921062105-daaa06bf1aaf,h1:wIOAyJMMen0ELGiFzlmqxdcV1yGbkyHBAB6PolcNbLA=,0bb5eaff16e4119a9251bb0a26b4190a8e36cbacce8daee8c77df76022e1087c +github.com/grpc-ecosystem/go-grpc-middleware,v1.1.0,h1:THDBEeQ9xZ8JEaCLyLQqXMMdRqNr0QAUJTIkQAUtFjg=,def2c3ec1d07264489b79fa0e8e7a5c23545f16ba3c6e613f5cdba2ae8fe2768 +github.com/grpc-ecosystem/go-grpc-prometheus,v1.2.1-0.20191002090509-6af20e3a5340,h1:uGoIog/wiQHI9GAxXO5TJbT0wWKH3O9HhOJW1F9c3fY=,bca256c9eee3d43fe310c205866c69de454e71346f18ea2b05a32bd2f6018c84 +github.com/grpc-ecosystem/grpc-gateway,v1.11.3,h1:h8+NsYENhxNTuq+dobk3+ODoJtwY4Fu0WQXsxJfL8aM=,d96a88c820576b8b6989944cbe15f4f2d94d2884f29f2f683b975a03a5bdc5fc +github.com/grpc-ecosystem/grpc-opentracing,v0.0.0-20180507213350-8e809c8a8645,h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU=,0606bde24e978e9cd91ae45ca9e5222ce695c21a07ae02e77546496bf23b1c62 +github.com/gucumber/gucumber,v0.0.0-20180127021336-7d5c79e832a2,h1:iR8wSrr/JCzL1Ul+dRVxtIOnP8DGg/m02nHZJ9PH6P0=,4feb5116e650552868f056ee74d179e91239bf166d365267f32e903ccc495dbb +github.com/guptarohit/asciigraph,v0.4.1,h1:YHmCMN8VH81BIUIgTg2Fs3B52QDxNZw2RQ6j5pGoSxo=,976279cdbc5425609c272b2116a92fb5871a40164ae64c51dedffea7b550d2d4 +github.com/guregu/null,v2.1.3-0.20151024101046-79c5bd36b615+incompatible,h1:SZmF1M6CdAm4MmTPYYTG+x9EC8D3FOxUq9S4D37irQg=,1adcbf87f6c55963b0d020ccbac0ebd07e8aca5e0ff22469ac708c6574d7333f +github.com/gxed/go-shellwords,v1.0.3,h1:2TP32H4TAklZUdz84oj95BJhVnIrRasyx2j1cqH5K38=,c63674c66949c0442402bceca8b7768684875a667140ea0b32afdd46fc094a7f +github.com/gxed/hashland/keccakpg,v0.0.1,h1:wrk3uMNaMxbXiHibbPO4S0ymqJMm41WiudyFSs7UnsU=,c77522ff0820feb7b5be4e1c74d7c64b3aa5afe3452e1dd2f54d1ffa067c6b2d +github.com/gxed/hashland/murmur3,v0.0.1,h1:SheiaIt0sda5K+8FLz952/1iWS9zrnKsEJaOJu4ZbSc=,4576d7ae9b5d2f4ebd238de84f3b52b9d4ae4d41822ac0eabd404d346eace067 +github.com/gxed/pubsub,v0.0.0-20180201040156-26ebdf44f824,h1:TF4mX7zXpeyz/xintezebSa7ZDxAGBnqDwcoobvaz2o=,718b183cca4e30a97d3fa06457060b4d3be66742838d98a39b02ea710693d9eb +github.com/h2non/filetype,v1.0.8,h1:le8gpf+FQA0/DlDABbtisA1KiTS0Xi+YSC/E8yY3Y14=,534a477c811032fceb0c8e1ad7a15f35ff95f1d038d41164bb4d265860cc42c3 +github.com/h2non/gock,v1.0.9,h1:17gCehSo8ZOgEsFKpQgqHiR7VLyjxdAG3lkhVvO9QZU=,ab5679329b0c26b523254dd728cad1b4e6e2e7bf11569df73a1dcaa468a46cd6 +github.com/h2non/parth,v0.0.0-20190131123155-b4df798d6542,h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=,3b7b7e4bb3c2d0e22075e13443af78d03fb2ed54b3eb5bb1fa6f528c7ebe3ac0 +github.com/hailocab/go-hostpool,v0.0.0-20160125115350-e80d13ce29ed,h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=,faf2b985681cda77ab928976b620b790585e364b6aff351483227d474db85e9a +github.com/hanwen/go-fuse,v1.0.0,h1:GxS9Zrn6c35/BnfiVsZVWmsG803xwE7eVRDvcf/BEVc=,4b94d038e80959f816a18b34cdcbb5244e87b73956b220aac213483999b54c84 +github.com/hashicorp/aws-sdk-go-base,v0.4.0,h1:zH9hNUdsS+2G0zJaU85ul8D59BGnZBaKM+KMNPAHGwk=,967c057aecede32de140c88b6527149d2441216569620b9d9350522d0f309bdc +github.com/hashicorp/consul,v1.6.1,h1:ISPgwOO8/vPYrCXQNyx63eJAYjPGRnmFsXK7aj2XICs=,0ca8c5046df99a7a6607ab68b6604340af58d1696c7901088adfd9618850629f +github.com/hashicorp/consul/api,v1.2.0,h1:oPsuzLp2uk7I7rojPKuncWbZ+m5TMoD4Ivs+2Rkeh4Y=,2833a78c39a4fa869a928e1218f3aa83130e4f5c03b4d4e355fb76b91fa75946 +github.com/hashicorp/consul/sdk,v0.2.0,h1:GWFYFmry/k4b1hEoy7kSkmU8e30GAyI4VZHk0fRxeL4=,3f0b677061f7e79191cc0d2f8184895c20051166959566a2e48e511b1fab222c +github.com/hashicorp/errwrap,v1.0.0,h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=,ccdf4c90f894d8a5fde4e79d5828c5d27a13e9f7ce3006dd72ce76e6e17cdeb2 +github.com/hashicorp/go-azure-helpers,v0.0.0-20190129193224-166dfd221bb2,h1:VBRx+yPYUZaobnn5ANBcOUf4hhWpTHSQgftG4TcDkhI=,dd17ed56e4b541cffa69679557074071372ab70682f695d8b61126c9393f92dc +github.com/hashicorp/go-bexpr,v0.1.2,h1:ijMXI4qERbzxbCnkxmfUtwMyjrrk3y+Vt0MxojNCbBs=,ac79086a2900ebf2f5414fe54b5799f24b3ddf953a28299f46831a11b10b1df0 +github.com/hashicorp/go-checkpoint,v0.5.0,h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=,1baf63010271d6c8abc0f4edc9e9d41483cb55218e4e399ca4c70ef225415f36 +github.com/hashicorp/go-cleanhttp,v0.5.1,h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=,e3cc9964b0bc80c6156d6fb064abcb62ff8c00df8be8009b6f6d3aefc2776a23 +github.com/hashicorp/go-discover,v0.0.0-20190403160810-22221edb15cd,h1:SynRxs8h2h7lLSA5py5a3WWkYpImhREtju0CuRd97wc=,c58ed5375890c98a836234f5166cf88b73ad7595899edaa43c775d650043b4b3 +github.com/hashicorp/go-gcp-common,v0.5.0,h1:kkIQTjNTopn4eXQ1+lCiHYZXUtgIZvbc6YtAQkMnTos=,a1fee55619b3579e5fe89b6f944dce87e190b8ea1526f24622ba5941d664b639 +github.com/hashicorp/go-getter,v1.4.0,h1:ENHNi8494porjD0ZhIrjlAHnveSFhY7hvOJrV/fsKkw=,cbae7b8a5f018c78bb304c47840c390b3c3be98b712b90b33d16304f1b427eb1 +github.com/hashicorp/go-hclog,v0.9.2,h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=,e1a873d9fa828038b5b2c93e0f49f9e8187b4f5255d0a3d7989d3ac178807af4 +github.com/hashicorp/go-immutable-radix,v1.1.0,h1:vN9wG1D6KG6YHRTWr8512cxGOVgTMEfgEdSj/hr8MPc=,c23ca92f0fb7dce35b86d35ccf9cfa871db97379d2ca8a0fcc15fde32ff369bb +github.com/hashicorp/go-memdb,v1.0.4,h1:sIdJHAEtV3//iXcUb4LumSQeorYos5V0ptvqvQvFgDA=,c3eedd68e60f3db16499dff27fe4d4e874978c250bab152044965a475cb47c72 +github.com/hashicorp/go-msgpack,v0.5.5,h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI=,fb47605669b0ddd75292aac788208475fecd54e0ea3e9a282d8a98ae8c60d1f5 +github.com/hashicorp/go-multierror,v1.0.0,h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=,a66a1b9dff26a9a7fcaa5aa5e658c13f94c0daeb572536b1ecc7ebe51f4d0be7 +github.com/hashicorp/go-oracle-terraform,v0.0.0-20181016190316-007121241b79,h1:RKu7yAXZTaQsxj1K9GDsh+QVw0+Wu1SWHxtbFN0n+hE=,5b3ab30e1aef56e38d750a5dc344f1ab996859408a6b76a9f48f5f75747fd712 +github.com/hashicorp/go-plugin,v1.0.1,h1:4OtAfUGbnKC6yS48p0CtMX2oFYtzFZVv6rok3cRWgnE=,0853effcccdb7bfac1c122f72cd3a1241b4e0934609541c409e9f59b441ae01e +github.com/hashicorp/go-raftchunking,v0.6.2,h1:imj6CVkwXj6VzgXZQvzS+fSrkbFCzlJ2t00F3PacnuU=,f5c55a3679c8a8f63d798d2b67552bfcd198dc5b9473d81c3ce1b353a055bc5c +github.com/hashicorp/go-retryablehttp,v0.6.3,h1:tuulM+WnToeqa05z83YLmKabZxrySOmJAd4mJ+s2Nfg=,69cb67f4821e97ca8f04b0cb710c61a5acfaa948dda59b949b40fd6fae8e7dec +github.com/hashicorp/go-rootcerts,v1.0.1,h1:DMo4fmknnz0E0evoNYnV48RjWndOsmd6OW+09R3cEP8=,3f558b1a436ed6fb15872383545109227f9552bf5daa95583e9402bbd3a24fff +github.com/hashicorp/go-safetemp,v1.0.0,h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=,6843a6b60d650ae9be836add0ab5ac1b1719a101bf12fe4ca6678fcd87baa19a +github.com/hashicorp/go-slug,v0.4.0,h1:YSz3afoEZZJVVB46NITf0+opd2cHpaYJ1XSojOyP0x8=,b6a027a2d69ae8786a6830239a79ceac487463237b49e03250a9b1e116f0a5ac +github.com/hashicorp/go-sockaddr,v1.0.2,h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc=,50c1b60863b0cd31d03b26d3975f76cab55466666c067cd1823481a61f19af33 +github.com/hashicorp/go-syslog,v1.0.0,h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE=,a0ca8b61ea365e9ecdca513b94f200aef3ff68b4c95d9dabc88ca25fcb33bce6 +github.com/hashicorp/go-tfe,v0.3.25,h1:4rPk/9rSYuRoujKk5FsxSvtC/AjJCQphLS/57yr6wUM=,5ade1d16517697c7bd04b556f852264eef33906c52d32bd6702c47838c1c1c04 +github.com/hashicorp/go-uuid,v1.0.1,h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=,a05417b988b047d55fca8ad4fec6bde56c3907f679fece48f97d608e61e82a5c +github.com/hashicorp/go-version,v1.2.0,h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E=,a3231adb6bf029750970de2955e82e41e4c062b94eb73683e9111aa0c0841008 +github.com/hashicorp/go.net,v0.0.1,h1:sNCoNyDEvN1xa+X0baata4RdcpKwcMS6DH+xwfqPgjw=,71564aa3cb6e2820ee31e4d9e264e4ed889c7916f958b2f54c6f3004d4fcd8d2 +github.com/hashicorp/golang-lru,v0.5.3,h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk=,ac6e8bdc76a1275e3496f1ab2484e28ab4be2c81e2da78b8cdd1c2d269b931e4 +github.com/hashicorp/hcl,v1.0.0,h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=,54149a2e5121b3e81f961c79210e63d6798eb63de28d2599ee59ade1fa76c82b +github.com/hashicorp/hcl/v2,v2.0.0,h1:efQznTz+ydmQXq3BOnRa3AXzvCeTq1P4dKj/z5GLlY8=,6275e2af8b3247c6de72baab13b3be531431f695e001e4d36c920e412a715032 +github.com/hashicorp/hcl2,v0.0.0-20191002203319-fb75b3253c80,h1:PFfGModn55JA0oBsvFghhj0v93me+Ctr3uHC/UmFAls=,42811f77c4da1d31371c51076cbcecc99042fc7a74c6e2622b11bea96043a777 +github.com/hashicorp/hil,v0.0.0-20190212112733-ab17b08d6590,h1:2yzhWGdgQUWZUCNK+AoO35V+HTsgEmcM4J9IkArh7PI=,cb2b110c86a312b7c60094c9b11853ae288945c34fa5861b67ff2d97edaab292 +github.com/hashicorp/logutils,v1.0.0,h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=,0e88424578d1d6b7793b63d30c180a353ce8041701d25dc7c3bcd9841c36db5b +github.com/hashicorp/mdns,v1.0.1,h1:XFSOubp8KWB+Jd2PDyaX5xUd5bhSP/+pTDZVDMzZJM8=,0f4b33961638b1273ace80b64c6fc7e54a1064484b2a1e182ab3d38a35dbc94f +github.com/hashicorp/memberlist,v0.1.5,h1:AYBsgJOW9gab/toO5tEB8lWetVgDKZycqkebJ8xxpqM=,51054573cad1655b1b349553a8d455eedc15b49f0277edd2e693bc5d0503af62 +github.com/hashicorp/net-rpc-msgpackrpc,v0.0.0-20151116020338-a14192a58a69,h1:lc3c72qGlIMDqQpQH82Y4vaglRMMFdJbziYWriR4UcE=,b0c3a5ec955b0dfb85b39a6aa1d10fe0e810dd78493c0a14ea5760bac1cadd32 +github.com/hashicorp/nomad/api,v0.0.0-20190412184103-1c38ced33adf,h1:U/40PQvWkaXCDdK9QHKf1pVDVcA+NIDVbzzonFGkgIA=,b9e994cd47eed80531b93d9f64be426cbdc6fc6e58323f6b26ae53b1fd692bbd +github.com/hashicorp/packer,v1.4.4,h1:ee+jewbEfTKV77+YtRR0m2Q8suTiXnr010bBFt5vJSA=,d2fc7c22b3528a4acb321fda24575cf2f88df8f5085b3b5da559e44d8b12295a +github.com/hashicorp/raft,v1.1.1,h1:HJr7UE1x/JrJSc9Oy6aDBHtNHUUBHjcQjTgvUVihoZs=,b6a10aa04b5f45486a6111d4a50cb65ee179b091f04a047e316b85f38ebbf873 +github.com/hashicorp/raft-boltdb,v0.0.0-20191021154308-4207f1bf0617,h1:CJDRE/2tBNFOrcoexD2nvTRbQEox3FDxl4NxIezp1b8=,e2008570aed06ba72cd783d6bc729b67b7e0cecd2219a8420dd24dcef82e64f8 +github.com/hashicorp/raft-snapshot,v1.0.1,h1:cx002JsTEAfAP0pIuANlDtTXg/pi2Db6YbRRmLQTQKw=,3d40d03f6793fe87464359f28b136b920daf7aa8544a98270470d04cef132a77 +github.com/hashicorp/serf,v0.8.5,h1:ZynDUIQiA8usmRgPdGPHFdPnb1wgGI9tK3mO9hcAJjc=,88623d0f1a155bb2fe254210f68f1603b42162f031fbf51256f1465b36bc7769 +github.com/hashicorp/terraform,v0.12.13,h1:LACXUTZvAGf8W/6wehHjOgi6YEMN7ejDUpnpll2qbJ0=,4dbe6d0c15f4d934fd583fc20bec55326ffc79cf0d5b7fd28978ba14d178fe8d +github.com/hashicorp/terraform-config-inspect,v0.0.0-20190821133035-82a99dc22ef4,h1:fTkL0YwjohGyN7AqsDhz6bwcGBpT+xBqi3Qhpw58Juw=,1261dc9b65805f9be029f6a42d9e0ddccc89c4d0c50e5fa2895b1b53198195c3 +github.com/hashicorp/terraform-svchost,v0.0.0-20191011084731-65d371908596,h1:hjyO2JsNZUKT1ym+FAdlBEkGPevazYsmVgIMw7dVELg=,8055e9f82b0484eb70594ca682bcf4401d2286c2021ffc72c6c3b6ad9ac9a024 +github.com/hashicorp/vault,v1.2.0-rc1,h1:GFYP6ck5f0EaJsGMD4PARIX5HaHREUxMbTaVPy+dFEg=,89c84474c97b1400ca858fe1b6e0eb3bd91dac17a4aff4336bd95104381e8b2b +github.com/hashicorp/vault-plugin-auth-alicloud,v0.5.2-0.20190725165955-db428c1b0976,h1:f+r1gXVvQJ0+2pfxgBDP1zZUC6lUmPNM0xp7AKupyBg=,3bc95606713215c3ae25f9be06ed2186f8f2e5e9ad8e025fafd332d97045ed09 +github.com/hashicorp/vault-plugin-auth-azure,v0.5.2-0.20190725170003-0fc4bd518aa2,h1:Ua6AFhJYkdNGC5s4uDL7EGVBD/jPUOcnubDkPsaG7K8=,bfa988cf4a3e33e7db3caf2ecad55c2f7c2e3f39088243767927ac8ed8d2556e +github.com/hashicorp/vault-plugin-auth-centrify,v0.5.2-0.20190725170023-9d8d5e0b03e6,h1:UXM3yxzNaruvgaccRjFXKcKnsTTHzp213MJ045wto6A=,165cf5f7daa0e4c286bad12f09eeac648062554399f18890bf35789b6b16e9c7 +github.com/hashicorp/vault-plugin-auth-gcp,v0.5.2-0.20190725170032-0aa7d1c92039,h1:uqYbah1dntV8OccHCbY3bBzYX/zLtjmG0ZIZPV+x6EM=,e9f9ccc7ca02c40291bb27012f2dd1fead86d2de2ab85a6d07b0aa7d98533f49 +github.com/hashicorp/vault-plugin-auth-jwt,v0.5.2-0.20190725170041-1cfee03e8d3a,h1:zdhacnLMH4P47PdSPJo0omNh+IkSvPj0LbiHLQu0aVk=,2b04c80c6d2000558b63ced2c9ba60a4a2ffe4c76d2d58d5fe121f714a3cf291 +github.com/hashicorp/vault-plugin-auth-kubernetes,v0.5.2-0.20190725170047-354505be0ecf,h1:il4UUQC9zfsSRNR2EAQVqC+DzrvzZpFmJReQ7p6/bKw=,d95794ab78e644a95799a3505a83af58a83c6bf775e69832b3660ca47c042d5a +github.com/hashicorp/vault-plugin-auth-oci,v0.0.0-20190904175623-97c0c0187c5c,h1:z6LQZvs1OtoVy2XgbgNhiDgp0U62Xbstn7/cgNZvh6g=,b23f2afa7fab5368d83a01be865e2dddf7ba6c7e8804ac205ccc1701a9239d51 +github.com/hashicorp/vault-plugin-auth-pcf,v0.0.0-20190725170053-826a135618c1,h1:mPyQ1+jB/ztcqebEdmNhSuYq4XVOpB5TUyyi0118T40=,c444159df670a1aba7e59029bf928989091886fa45970f751fe644d243d43744 +github.com/hashicorp/vault-plugin-database-elasticsearch,v0.0.0-20190725170059-5c0d558eb59d,h1:VUD1T3aI5GL8uoSSDhHncHP8ksgepZsvSLhsRG8MJ3s=,b151c27f632b8e05686473b4936b480cec694498c1e446dc5208b4db05c559f1 +github.com/hashicorp/vault-plugin-secrets-ad,v0.5.3-0.20190725170108-e1b17ad0c772,h1:N219G3MUxPRhtOBMFVdsSQWU47MrvivSHLmTAPpHcs4=,c8801ee5f030fa6cb36045f1e321d964224f9a2b4a17100140cafca7a6d8daf5 +github.com/hashicorp/vault-plugin-secrets-alicloud,v0.5.2-0.20190725170114-7d66a3fa0600,h1:kyHR0JOKFDAaC4sjQ3iD1lTH6uaIfmTk4rQ+JOGW5Zo=,f816c029601c9e7235f798e9591246ac935d3b1e330abfb23af59afa6bc08e0d +github.com/hashicorp/vault-plugin-secrets-azure,v0.5.2-0.20190725170121-541440395211,h1:hZ21h0DWWKkoeMW7zkYaPVLxGZtKfYyIcE9G8xug4YQ=,5d71ad3ef26fd40b3afaf852913f38e5be0a1db8844bf21cb787e204cdbc48e4 +github.com/hashicorp/vault-plugin-secrets-gcp,v0.5.3-0.20190725170127-aa49df112140,h1:gSvWU9aYAsHxqKU0ohJD9njlNQ1/qLFPRs85u+xJFv4=,9b209e3ef7b8d7c41e823705cc190699540bbd2076f82344a83c106fa7e4ac98 +github.com/hashicorp/vault-plugin-secrets-gcpkms,v0.5.2-0.20190725170135-aaf270943731,h1:zP2vqetYhON59Mf5FTV9KmyKSnY1cLFzdNW0YYnNKbo=,5d3bc6de4bdad4725c4348a0d6861bce3e80a9eb13d4b05179cd663b47f46545 +github.com/hashicorp/vault-plugin-secrets-kv,v0.5.2-0.20190725170141-1c4dac87f383,h1:4IqT7JQt/GyYKr0HGemkUlYpF45ZALHSN9rHy7Sipos=,10f03c6d8a51714692b43ab69c2cb5f041ac611210aa9804237a9345e930f018 +github.com/hashicorp/vault/api,v1.0.4,h1:j08Or/wryXT4AcHj1oCbMd7IijXcKzYUGw59LGu9onU=,a885d16e067a5586e55914cd8e40f250a28fe94b3b864de47d495ad1f71c4251 +github.com/hashicorp/vault/sdk,v0.1.14-0.20190909201848-e0fbf9b652e2,h1:b65cSyZqljnCPzzsUXvR4P0eXypo1xahQyG809+IySk=,0aca8708570b724605514cab6dbbc9cc7bce5d27786a4b2da87553c437c42463 +github.com/hashicorp/vic,v1.5.1-0.20190403131502-bbfe86ec9443,h1:O/pT5C1Q3mVXMyuqg7yuAWUg/jMZR1/0QTzTRdNR6Uw=,9c09a35b14d797812e6714073471b3472c16f9cb4deb430f9e2dd15fa8d25e32 +github.com/hashicorp/yamux,v0.0.0-20190923154419-df201c70410d,h1:W+SIwDdl3+jXWeidYySAgzytE3piq6GumXeBjFBG67c=,d8a888d6a4ecbc09f2f3663cb47aa2d064298eeb1491f4761a43ae95e93ba035 +github.com/herenow/go-crate,v0.0.0-20190617151714-6f2215a33eca,h1:kk1qCxy+FS5McLJ69dSpB6Y6kHCMa23UwHyglIzJ/bk=,aa618858b9c03e47962afb2a4098ad6cca8ecd09904cdbc5eb62c5a1d74befca +github.com/hetznercloud/hcloud-go,v1.15.1,h1:G8Q+xyAqQ5IUY7yq4HKZgkabFa0S/VXJXq3TGCeT8JM=,028402928c1bc1db686cab5738e6fb91a61252c1236258e2d911dd8da21f8af5 +github.com/hinshun/vt10x,v0.0.0-20180616224451-1954e6464174,h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ=,4afc77bd4950db746c68d23e6ed681d31cd952559d712c1400da476084567cf6 +github.com/hjfreyer/taglib-go,v0.0.0-20151027170453-0ef8bba9c41b,h1:Q4OOFmH18aIjnDJlvYm4BXmpHKXk1zTJP0QZ0otNwPs=,e7735f2cdbb7441dbe6bbc303cff9b9a20d9845dc901e31f6e29e3ef83613390 +github.com/howeyc/fsnotify,v0.9.0,h1:0gtV5JmOKH4A8SsFxG2BczSeXWWPvcMT0euZt5gDAxY=,a72f2f092433c8b53e095d6db3d3e18517db1a5a9814a78ed97194239145740f +github.com/howeyc/gopass,v0.0.0-20190910152052-7cb4b85ec19c,h1:aY2hhxLhjEAbfXOx2nRJxCXezC6CO2V/yN+OCr1srtk=,83560b6c9a6220bcbb4ad2f043e5a190ab11a013b77c1bbff9a3a67ed74d4b37 +github.com/hpcloud/tail,v1.0.0,h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=,3cba484748e2e2919d72663599b8cc6454058976fbca96f9ac78d84f195b922a +github.com/huandu/xstrings,v1.2.0,h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=,fe7011ad569e464d6ff81bdb1d80c4ebdb5baac5c89d17c1644a23cac0c48828 +github.com/huin/goupnp,v1.0.0,h1:wg75sLpL6DZqwHQN6E1Cfk6mtfzS45z8OV+ic+DtHRo=,9685536729d9860766846ad4e56fb961b246d5afa209e4058ee0d021aec37827 +github.com/huin/goutil,v0.0.0-20170803182201-1ca381bf3150,h1:vlNjIqmUZ9CMAWsbURYl3a6wZbw7q5RHVvlXTNS/Bs8=,d887199bd2f388075ff7aaf1d3061b13b92c20e01ccd6337c864fd409fe78831 +github.com/hybridgroup/go-ardrone,v0.0.0-20140402002621-b9750d8d7b78,h1:7of6LJZ4LF9AvF4bTiMr2I72KxodBf1BXrSD9Tz0lWU=,997e0efef1b73cc1930ad67cd649268ff864393fa85dedf32672ecca78647021 +github.com/hybridgroup/mjpeg,v0.0.0-20140228234708-4680f319790e,h1:xCcwD5FOXul+j1dn8xD16nbrhJkkum/Cn+jTd/u1LhY=,d9134203da596f895c55c3a9fd0aea32ad26501ca88e646cbe9f82136f592c0f +github.com/hyperledger/fabric,v1.4.3,h1:6MmYhcDbxhd0TvpvHLR3c5m3fVjaX97690H8TRjpJNA=,067d2bd69094dc9f693d9b00c8bea810f61f6a8a3d0ac640830b468934e22023 +github.com/hyperonecom/h1-client-go,v0.0.0-20190122232013-cf38e8387775,h1:MIteIoIQ5nFoOmwEHPDsqng8d0dtKj3lCnQCwGvtxXc=,135625f81c1c6c62b296269829a74f1266928600545fedec0825cb97284264f6 +github.com/iancoleman/strcase,v0.0.0-20190422225806-e506e3ef7365,h1:ECW73yc9MY7935nNYXUkK7Dz17YuSUI9yqRqYS8aBww=,f93e74faf2e05699180c40ef21204629a1c6bd382658f1059c80631c377c5246 +github.com/ianlancetaylor/demangle,v0.0.0-20181102032728-5e5cf60278f6,h1:UDMh68UUwekSh5iP2OMhRRZJiiBccgV7axzUG8vi56c=,73ae40ed96af2703f85cd4c552cf6b14551ceb782348be8185b730f44c842ab9 +github.com/iij/doapi,v0.0.0-20190504054126-0bbf12d6d7df,h1:MZf03xP9WdakyXhOWuAD5uPK3wHh96wCsqe3hCMKh8E=,7e33155961c2cba072047deb34d19a7d863a713e502abe8bdc31ab91424bd226 +github.com/ijc/Gotty,v0.0.0-20170406111628-a8b993ba6abd,h1:anPrsicrIi2ColgWTVPk+TrN42hJIWlfPHSBP9S0ZkM=,b8b9a99b3632feb3449d1fb8950d292333f8a7f494b182320ecdb0479d78442f +github.com/imdario/mergo,v0.3.8,h1:CGgOkSJeqMRmt0D9XLWExdT4m4F1vd3FV3VPt+0VxkQ=,579cad1ed913cfcb424deb97e7016749abcc9d585bad07d14f19550df052cec5 +github.com/imkira/go-interpol,v1.1.0,h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk=,de5111f7694700ea056beeb7c1ca1a827075d423422f251076ee17bd869477d9 +github.com/improbable-eng/grpc-web,v0.9.1,h1:tenDg9Lg+zYXeS/ojbKyfwVO5TVYh5FFGsrXNAblF1o=,3a287ae758b41feea9f26ec1b8757628d4742b87376fa40b29d878ee651bfe62 +github.com/imroc/req,v0.2.3,h1:ElMCifcqg/1GonGloyyTUrj6D6IITL6EiNEKHUl4xZM=,951172f0969fa0bad31ebbe9b17699ea3909b09eaf8df39ccd78e48097682c78 +github.com/inconshreveable/go-update,v0.0.0-20160112193335-8152e7eb6ccf,h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=,adf856fb49e7c5059b2edb42a31daf4a536dc698fe0728835b018150a884b678 +github.com/inconshreveable/log15,v0.0.0-20180818164646-67afb5ed74ec,h1:CGkYB1Q7DSsH/ku+to+foV4agt2F2miquaLUgF6L178=,31875747bcd198c39714d38747ac77e585620f2f37d1b1e1a03b164af6762995 +github.com/inconshreveable/mousetrap,v1.0.0,h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=,c3fa0813e78f5cef10dc0e9912c43e68e06ff970a98e98c4050fe14dbbfd18c7 +github.com/influxdata/changelog,v1.1.0,h1:HXhmLZDrbuC+Ca5YX7g8B8cH5DmJpaOjd844d9Y7aTQ=,19e60d9b658aaecca4e075126c996c1abd5e369003c14bbe575edc4ba2b9c182 +github.com/influxdata/flux,v0.52.0,h1:R91uUXbHzoiyYF7Xhm+wP3a0iSnl43iYJrN93nBhuP0=,e0121889c46cc4ad22f1662e68df7dbdfbb361c3da6809add4d1409cef764be9 +github.com/influxdata/influxdb,v1.7.9,h1:uSeBTNO4rBkbp1Be5FKRsAmglM9nlx25TzVQRQt1An4=,b49a72374a14f726229e71152e74e8a132c2913137c4457f31bae8c7735e812c +github.com/influxdata/influxdb1-client,v0.0.0-20190809212627-fc22c7df067e,h1:txQltCyjXAqVVSZDArPEhUTg35hKwVIuXwtQo7eAMNQ=,fc41ea93bf2b06b231823b116dc11b0ed89badf1ce6a4c848a33c77dcf2c123a +github.com/influxdata/influxql,v1.0.1,h1:6PGG0SunRmptIMIreNRolhQ38Sq4qDfi2dS3BS1YD8Y=,2a697984d1cd82656f69901bfe1771676493411c1370d77271bde3ab3c917a1e +github.com/influxdata/line-protocol,v0.0.0-20180522152040-32c6aa80de5e,h1:/o3vQtpWJhvnIbXley4/jwzzqNeigJK9z+LZcJZ9zfM=,6111b5e459106f7003477186aa2e34423dbe0c53983944a07d8b835ff8c7757c +github.com/influxdata/promql/v2,v2.12.0,h1:kXn3p0D7zPw16rOtfDR+wo6aaiH8tSMfhPwONTxrlEc=,b928626f2eb81eed0046ef23a83a77a28dd140d369a0d2538c94e85d1055877f +github.com/influxdata/tdigest,v0.0.0-20181121200506-bf2b5ad3c0a9,h1:MHTrDWmQpHq/hkq+7cw9oYAt2PqUw52TZazRA0N7PGE=,5d6b056d98d1e7e9cd884aea4e73934cc8ea89218eb43ee1d5140d3ccb34ed52 +github.com/influxdb/influxdb,v1.7.9,h1:KMBwwvyJyBppIwrg5t0662p+Yei/ucnIkqUl8txiQdQ=,ad251d4cc00aec767465dc60d6b702a3635b68402123a4ee5d1ee2b5006310b3 +github.com/iotexproject/go-pkgs,v0.1.1,h1:AyWJf8jqOg4aMSrxi+MInFFBZhTvSm0LCu1o08heijk=,c5099edde7450b4f8b9a0f49c42697f5e9bcb92d2bf58395aa0681f3ef6b583d +github.com/iotexproject/iotex-address,v0.2.1,h1:ZJH2ajx5OBrbaRJ0ZWlWUo685zr5kjWijVjtmUrm42E=,53c7ce4d7fbc55ee79e92e9e0b31ee3b3ba0e6e5d3e24cd43e0a58c766568c9d +github.com/iotexproject/iotex-proto,v0.2.5,h1:SYdl9Lqb0LYfFf3sfw92fN8GY3bthfCvGmltz+2uvDQ=,546cb070e92286601aee16d03383712172061c8fe78e53cf04498a9358470a78 +github.com/ipfs/bbloom,v0.0.4,h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=,92993c175552cc626ef6b1ab6cf887f0f640311748c47e7615df29a966c1b774 +github.com/ipfs/go-bitswap,v0.1.3,h1:jAl9Z/TYObpGeGATUemnOZ7RYb0F/kzNVlhcYZesz+0=,ee26d57b2765f808ebebca8aa18695bfa02b738f47b4b5db5efce5c91f28fbcd +github.com/ipfs/go-block-format,v0.0.2,h1:qPDvcP19izTjU8rgo6p7gTXZlkMkF5bz5G3fqIsSCPE=,02ad9fa29f97073ece45a5da7a92e59e6c6b856e9a03bd853361b8107296c020 +github.com/ipfs/go-blockservice,v0.1.2,h1:fqFeeu1EG0lGVrqUo+BVJv7LZV31I4ZsyNthCOMAJRc=,31c5ff02d71ee454bebea3944d7e06c2ffd6f1c4cfdddf71c5122e982f261c7d +github.com/ipfs/go-cid,v0.0.3,h1:UIAh32wymBpStoe83YCzwVQQ5Oy/H0FdxvUS6DJDzms=,f8bd60f8bbd79ed1fa5c8c113f6e17addb12257b0d925d3327ee7c25a7733591 +github.com/ipfs/go-datastore,v0.1.1,h1:F4k0TkTAZGLFzBOrVKDAvch6JZtuN4NHkfdcEZL50aI=,be724f5e3a459cf6ae9e68d2fa14e27cc92c53ae775979f2412b4f5b3f2b0336 +github.com/ipfs/go-detect-race,v0.0.1,h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=,c00c97cacb355cb0569bee75775eff6b656d95dd7d0855ed97c2ee44666b72cd +github.com/ipfs/go-ds-badger,v0.0.7,h1:NMyh88Q50HG6/S2YD58DLkq0c0/ZQPMbSojONH+PRf4=,26a453fc19eb26fe6077f12310ff1ad7230fe31b31a0c17fb47abba75379ee61 +github.com/ipfs/go-ds-leveldb,v0.1.0,h1:OsCuIIh1LMTk4WIQ1UJH7e3j01qlOP+KWVhNS6lBDZY=,43085f79b999edef0b8b49dea1ed35d47cc1c453ef401634825c0be5b62ac6d9 +github.com/ipfs/go-hamt-ipld,v0.0.13,h1:Jbt5ALTYnrzbcOBka11kAkgn3auvkQBGkKWjGRsQrio=,e16acbc3f203616ccd9119415b9db28a6f18c72f053259842f7db50aa1193cf8 +github.com/ipfs/go-ipfs-blockstore,v0.1.0,h1:V1GZorHFUIB6YgTJQdq7mcaIpUfCM3fCyVi+MTo9O88=,19a45734b2615632b180b59032d39c04c50fc735c7f9fd27c5547b0facb4ef8f +github.com/ipfs/go-ipfs-blocksutil,v0.0.1,h1:Eh/H4pc1hsvhzsQoMEP3Bke/aW5P5rVM1IWFJMcGIPQ=,3fcf4221d4d59af5807040f209ff0d28d81f6974d61ac279b43a44b2f46d8182 +github.com/ipfs/go-ipfs-chunker,v0.0.1,h1:cHUUxKFQ99pozdahi+uSC/3Y6HeRpi9oTeUHbE27SEw=,02a0e4766162345a5bea8962c315b4bab8f2550aa1b760dcece96794b3ba22ef +github.com/ipfs/go-ipfs-config,v0.0.11,h1:5/4nas2CQXiKr2/MLxU24GDGTBvtstQIQezuk7ltOQQ=,e26bdd6db98c4ccf932440aa22a1aa2d550903a0f6f9da82f1ff5902ebbe260e +github.com/ipfs/go-ipfs-delay,v0.0.1,h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ=,bc3a4494d27cd7fabdeb7036e2edadd27f0edbd2b7d3cf49d14e3402c17c3ab6 +github.com/ipfs/go-ipfs-ds-help,v0.0.1,h1:QBg+Ts2zgeemK/dB0saiF/ykzRGgfoFMT90Rzo0OnVU=,52d0d886ebb65366abb35f19b76c4f6f349464eaedf092da95c661a451b2bf06 +github.com/ipfs/go-ipfs-exchange-interface,v0.0.1,h1:LJXIo9W7CAmugqI+uofioIpRb6rY30GUu7G6LUfpMvM=,0a593df65586ff592255eb69923a43d413b24ad56454e14e94f5e722756fb102 +github.com/ipfs/go-ipfs-exchange-offline,v0.0.1,h1:P56jYKZF7lDDOLx5SotVh5KFxoY6C81I1NSHW1FxGew=,04b69dc6dd34a2c5c2d1f0df8777fcaa8590aa528b960cc26178af6f609e29cf +github.com/ipfs/go-ipfs-files,v0.0.6,h1:sMRtPiSmDrTA2FEiFTtk1vWgO2Dkg7bxXKJ+s8/cDAc=,442fa790aba0beff3a79503064a35dceab2a29dc4ab8edcca690c7f61ef6c6c0 +github.com/ipfs/go-ipfs-flags,v0.0.1,h1:OH5cEkJYL0QgA+bvD55TNG9ud8HA2Nqaav47b2c/UJk=,61ac13bc74f89286ac30db2ce79b26adfba63a0676cbc430ad750df2d516565a +github.com/ipfs/go-ipfs-posinfo,v0.0.1,h1:Esoxj+1JgSjX0+ylc0hUmJCOv6V2vFoZiETLR6OtpRs=,149f52f33d8ffd4f82056b4ea1dae2f25024a2e8df0ff555789c549468d998e7 +github.com/ipfs/go-ipfs-pq,v0.0.1,h1:zgUotX8dcAB/w/HidJh1zzc1yFq6Vm8J7T2F4itj/RU=,4eda59f4f898933265b82d381cc1ea5a3d3c75752618f46496a2d150c09aeb2d +github.com/ipfs/go-ipfs-routing,v0.1.0,h1:gAJTT1cEeeLj6/DlLX6t+NxD9fQe2ymTO6qWRDI/HQQ=,e2281e568eed0ee5621886d28802eefd8a9d0806cbd1db80c01550ad59ec54c7 +github.com/ipfs/go-ipfs-util,v0.0.1,h1:Wz9bL2wB2YBJqggkA4dD7oSmqB4cAnpNbGrlHJulv50=,6d3af4d6dcb95047b64fc74972cdcd84f199c6bad467a7de3543c3eaa0d4ee49 +github.com/ipfs/go-ipld-cbor,v0.0.3,h1:ENsxvybwkmke7Z/QJOmeJfoguj6GH3Y0YOaGrfy9Q0I=,4087b9930a8e2899c3540e61bd8e7f04c8bdd8670f68ddbfcf10f45a0e619cef +github.com/ipfs/go-ipld-format,v0.0.2,h1:OVAGlyYT6JPZ0pEfGntFPS40lfrDmaDbQwNHEY2G9Zs=,3da08ede588080b6ec81c5ad8fbfb1c9ea306a038be41dc06b1f3a1a101ebe50 +github.com/ipfs/go-log,v0.0.1,h1:9XTUN/rW64BCG1YhPK9Hoy3q8nr4gOmHHBpgFdfw6Lc=,9165a91716b11b432f8bf303d59fc019bf91872f1b9ca7e12d666c11ba6e6676 +github.com/ipfs/go-merkledag,v0.2.4,h1:ZSHQSe9BENfixUjT+MaLeHEeZGxrZQfgo3KT3SLosF8=,ed269e045c613cc7b9bba3593797fe09cdf84c906726bef9261c74bd8c470404 +github.com/ipfs/go-metrics-interface,v0.0.1,h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg=,e83f0c01b084000492db0c0e1a28ff900c3f6d11eea8defdbe8bdd1a04c33fd0 +github.com/ipfs/go-mfs,v0.1.1,h1:tjYEWFIl0W6vRFuM/EnySHaaYzPmDcQWwTjtYWMGQ1A=,1db35113aff60e645544cc64cbbddbf0608332b1f2208615744098af59b97fee +github.com/ipfs/go-path,v0.0.7,h1:H06hKMquQ0aYtHiHryOMLpQC1qC3QwXwkahcEVD51Ho=,96c607c0253c24ed0cb37016007f34420a3a83c37cdd68b6d4391126418835c4 +github.com/ipfs/go-peertaskqueue,v0.1.1,h1:+gPjbI+V3NktXZOqJA1kzbms2pYmhjgQQal0MzZrOAY=,5fa92b0302d8e72e8c4d74517a68fad04c1d89d90f0a6314a5e30662dda5d359 +github.com/ipfs/go-unixfs,v0.2.2,h1:eTkDT9F0dn4qHmBMVRMZbziwyqLRcogjtPYqMgZYmQs=,77f7f6b2de604b592018dd914a6606084069d22efa70ea95e0dd623a04e4453c +github.com/ipfs/go-verifcid,v0.0.1,h1:m2HI7zIuR5TFyQ1b79Da5N9dnnCP1vcu2QqawmWlK2E=,1f808a29fcd38406325435c7a6a02b253aee28832704f0032600c2b41ef3b8f1 +github.com/ipfs/interface-go-ipfs-core,v0.2.4,h1:oQiJ3Mj3rqVJohdi316K3+VSyiADto3Z35ukj7z+UGg=,e1030de5fc1ee1868a87386708be313fc0fcbbe137d5a71d71f28621393f70a2 +github.com/ipfs/iptb,v1.4.0,h1:YFYTrCkLMRwk/35IMyC6+yjoQSHTEcNcefBStLJzgvo=,0b00d0279c700ad687cfbba073f504cc4c8a17ff731550c3784fcb3e24b0c6d5 +github.com/iris-contrib/blackfriday,v2.0.0+incompatible,h1:o5sHQHHm0ToHUlAJSTjW9UWicjJSDDauOOQ2AHuIVp4=,936679f49251da75fde84b8f38884dbce89747b96f8206f7a4675bfcc7dd165d +github.com/iris-contrib/formBinder,v5.0.0+incompatible,h1:jL+H+cCSEV8yzLwVbBI+tLRN/PpVatZtUZGK9ldi3bU=,6f1fef9e533a1f57a8b033f8c0a135ed038524d7535dd16ba22e9494e3096e3b +github.com/iris-contrib/go.uuid,v2.0.0+incompatible,h1:XZubAYg61/JwnJNbZilGjf3b3pB80+OQg2qf6c8BfWE=,c6bae86643c2d6047c68c25226a1e75c5331c03466532ee6c943705743949bd9 +github.com/issue9/assert,v1.3.2,h1:IaTa37u4m1fUuTH9K9ldO5IONKVDXjLiUO1T9vj0OF0=,f4349cbd5af134fce10b399717aa4b455b5c73df6c20c1057c6e45973f24a06d +github.com/issue9/identicon,v0.0.0-20160320065130-d36b54562f4c,h1:A/PDn117UYld5mlxe58EpMguqpkeTMw5/FCo0ZPS/Ko=,5a837560a10469ab524b185a092edf67be85aff5ed794e1fcaaa084cf4540336 +github.com/itchio/arkive,v0.0.0-20190702114012-1bb6c7241ec3,h1:UcZnU7qzWTmZf8v7F3mC79H98I0b77pZz+99vqHFwtI=,dad4e3a988e6834d4ce1c3fb650a8dbb9aedd116ba8b3556c8f8babecdd17ead +github.com/itchio/dskompress,v0.0.0-20190702113811-5e6f499be697,h1:u3Q2WkrIPYlGEw4fjcImSOrkivWd6SVb0BF0Ehoih9c=,d8379b7e4219f001b61e5c2b3b34b2a6b69f8a55dc1acde2919be3050a7c84f5 +github.com/itchio/go-brotli,v0.0.0-20190702114328-3f28d645a45c,h1:Jf20xV/yR/O6eSUqLTuXhka/+54YR59sGwN7b3MkxYk=,6bab2adfb10a8ae7132e02ed10823df2e91c42dd08a1f3e1835679390ea69927 +github.com/itchio/headway,v0.0.0-20190702175331-a4c65c5306de,h1:RQW9xPqYtvjdHHRZR95XsaEA9B4URCuNHK78IuJcc+Y=,54e63fd6f25217e272e196f6213915515196a5b17a1923a666c05b4f49c82ef3 +github.com/itchio/httpkit,v0.0.0-20190702184704-639fe5edf1f1,h1:mViP/A8hAP04YWbbZR7Kcm7rTkUeT2HLcn3BBiK+CwM=,e56bf70a53a305f6866631d1272a3f3543abd45a68c50d202ddc80796b58c461 +github.com/itchio/kompress,v0.0.0-20190702090658-5e2558a00102,h1:QXEwRXrrx+7CxU+Y+G4GpDk4mUeHbP7grMXHhydk8qU=,cadec4996aed4026c0e0321f90b5bb11d9b8d1de3665752b2e862c6ddbfa229d +github.com/itchio/ox,v0.0.0-20190925154941-b613e528fc7d,h1:EcmVffUYduCSFCEM12YpSXoVXvyeq8Ro4Q+rwc60TIo=,81c3dfe8e91eb13815bf5b7f159f24a3cb1bd7028a395f691e9cefc1c3a71d01 +github.com/itchio/randsource,v0.0.0-20190702184213-a7635a4cb94b,h1:fG+9RlMeggMG/C2FH80HTfJmm+eOjAve2pFSv6Uio8A=,2375b07785c2738527c864dfb1bee0082b1f89c51e200157165bcd36f5c2933f +github.com/itchio/savior,v0.0.0-20190925162935-b92976a0b402,h1:a51wRxkLoJWu5NqnVDkI6cE50S0mDpJfOXkCp4ltvr8=,1454524a51fa6492ee593fb7d648dc037fec7c32d90e2d21c149b6e724a74838 +github.com/iwind/TeaGo,v0.0.0-20191007090339-daba0bb6607e,h1:bxD34HpyJWx6bnGdahZo6uN6XnuOvMa8LrzfC+eZqes=,bec78c179e2676d51bb1a07122896661d4ae7727d325e9fa91682361e0321161 +github.com/jackc/chunkreader,v1.0.0,h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=,e204c917e2652ffe047f5c8b031192757321f568654e3df8408bf04178df1408 +github.com/jackc/chunkreader/v2,v2.0.0,h1:DUwgMQuuPnS0rhMXenUtZpqZqrR/30NWY+qQvTpSvEs=,cae1df6cc4f52abdf31d9c7c9869714f5c2e2dddc8047eb6d335409489e76031 +github.com/jackc/fake,v0.0.0-20150926172116-812a484cc733,h1:vr3AYkKovP8uR8AvSGGUK1IDqRa5lAAvEkZG1LKaCRc=,bf8b5b51ae03f572a70a0582dc663c5733bba9aca785d39bb0367797148e6d64 +github.com/jackc/pgconn,v1.0.1,h1:ZANo4pIkeHKIVD1cQMcxu8fwrwIICLblzi9HCjooZeQ=,4b7e033c80207f032275845f7d366b51b46e3434cafebd13599a351f01f68b86 +github.com/jackc/pgio,v1.0.0,h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=,1a83c03d53f6a40339364cafcbbabb44238203c79ca0c9b98bf582d0df0e0468 +github.com/jackc/pgmock,v0.0.0-20190831213851-13a1b77aafa2,h1:JVX6jT/XfzNqIjye4717ITLaNwV9mWbJx0dLCpcRzdA=,5d8117d8fb79d3a41998bec8dca93d450eba9edf3cf0b8c36881e0ea6140b406 +github.com/jackc/pgpassfile,v1.0.0,h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=,1cc79fb0b80f54b568afd3f4648dd1c349f746ad7c379df8d7f9e0eb1cac938b +github.com/jackc/pgproto3,v1.1.0,h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A=,e3766bee50ed74e49a067b2c4797a2c69015cf104bf3f3624cd483a9e940b4ee +github.com/jackc/pgproto3/v2,v2.0.0,h1:FApgMJ/GtaXfI0s8Lvd0kaLaRwMOhs4VH92pwkwQQvU=,22635755552d1363817a9c9f192cf464034dfc31593e4975982a85de8295dcf4 +github.com/jackc/pgtype,v0.0.0-20190828014616-a8802b16cc59,h1:xOamcCJ9MFJTxR5bvw3ZXmiP8evQMohdt2VJ57C0W8Q=,30822259b27010e41850fde5f75166abc90028b9c57e2a77976cab119e01295f +github.com/jackc/pgx,v3.6.0+incompatible,h1:bJeo4JdVbDAW8KB2m8XkFeo8CPipREoG37BwEoKGz+Q=,07a0cc87069e38acac988cc48e5a6cfd1bfd02b4b843d0e8931e48bb8c25d821 +github.com/jackc/pgx/v4,v4.0.0-pre1.0.20190824185557-6972a5742186,h1:ZQM8qLT/E/CGD6XX0E6q9FAwxJYmWpJufzmLMaFuzgQ=,1782863d2118cd0e63cc50cca24bd79cbea5674bac3b798bf12148400590128d +github.com/jackc/puddle,v0.0.0-20190608224051-11cab39313c9,h1:KLBBPU++1T3DHtm1B1QaIHy80Vhu0wNMErIFCNgAL8Y=,a780306bb3ad76174eca1d83a6d925fb3f7a13981cda6249e51be64476c76f15 +github.com/jackmordaunt/icns,v0.0.0-20181231085925-4f16af745526,h1:NfuKjkj/Xc2z1xZIj+EmNCm5p1nKJPyw3F4E20usXvg=,06f511df7637fd1424b6f099d7ce7ecf7378e62adc9d13133ce7df419e51faf0 +github.com/jackpal/gateway,v1.0.5,h1:qzXWUJfuMdlLMtt0a3Dgt+xkWQiA5itDEITVJtuSwMc=,adab846630d73763e5a3b984c8264d6503c8cb0b2914df559dacd41f6380e4ef +github.com/jackpal/go-nat-pmp,v1.0.1,h1:i0LektDkO1QlrTm/cSuP+PyBCDnYvjPLGl4LdWEMiaA=,d7f2409f72895a01e0d11b457eac015dbcd94c2657f95d508e53867ca6b07db1 +github.com/jacobsa/crypto,v0.0.0-20190317225127-9f44e2d11115,h1:YuDUUFNM21CAbyPOpOP8BicaTD/0klJEKt5p8yuw+uY=,ec4d2a1fc28e1d99c68557e38cd77527df5a9f5090aa12876ab4aa6f9137a3d5 +github.com/jacobsa/oglematchers,v0.0.0-20150720000706-141901ea67cd,h1:9GCSedGjMcLZCrusBZuo4tyKLpKUPenUUqi34AkuFmA=,bcd70357107c45c3177c913b718624376b692d39672c157708fe2cd9aa78fcb5 +github.com/jacobsa/oglemock,v0.0.0-20150831005832-e94d794d06ff,h1:2xRHTvkpJ5zJmglXLRqHiZQNjUoOkhUyhTAhEQvPAWw=,5159f5f22d0e130b1fbfdbc96eb9d4653b32bd463439cb0f3c98e179de5daf80 +github.com/jacobsa/ogletest,v0.0.0-20170503003838-80d50a735a11,h1:BMb8s3ENQLt5ulwVIHVDWFHp8eIXmbfSExkvdn9qMXI=,69d96e3ea6e055d68ed46c0c1044a5dfa18064c9d45bc68d5946aa55e048af6b +github.com/jacobsa/reqtrace,v0.0.0-20150505043853-245c9e0234cb,h1:uSWBjJdMf47kQlXMwWEfmc864bA1wAC+Kl3ApryuG9Y=,a7efb54142e39f4acab39d22db692d5734f818723783646f6727269228deea83 +github.com/jaegertracing/jaeger,v1.14.0,h1:C0En+gfcxf3NsAriMAvQ6LcSFrQ5VQGXddqfty1EpTI=,5f6245d1b0c986c44cc37c7c950f3cf9c2cfd1e0d540905cd4fab9a164684ecd +github.com/jarcoal/httpmock,v1.0.4,h1:jp+dy/+nonJE4g4xbVtl9QdrUNbn6/3hDT5R4nDIZnA=,5c7d051f237633573a168713760758005724c268242484d982cb0c76dc3f3ee7 +github.com/jaytaylor/html2text,v0.0.0-20190408195923-01ec452cbe43,h1:jTkyeF7NZ5oIr0ESmcrpiDgAfoidCBF4F5kJhjtaRwE=,2369830967f1c18c382cbee77a510431b42275f1f368e3b5cbbdaa782ae24c0d +github.com/jbenet/go-base58,v0.0.0-20150317085156-6237cf65f3a6,h1:4zOlv2my+vf98jT1nQt4bT/yKWUImevYPJ2H344CloE=,e686d369d490d6728f6e63b1680db3b567c9e884545f8c47ca656f0d944299b7 +github.com/jbenet/go-cienv,v0.1.0,h1:Vc/s0QbQtoxX8MwwSLWWh+xNNZvM3Lw7NsTcHrvvhMc=,3de5dadf2add50bf7fbdf88db4e6d008ba1848516585f7f9dfbf53cb6dc1705c +github.com/jbenet/go-context,v0.0.0-20150711004518-d14ea06fba99,h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=,4cd0955abeea43dc4b5a08b8769e696109e0376f2a113a9b8eff13cc90cac1c7 +github.com/jbenet/go-temp-err-catcher,v0.0.0-20150120210811-aac704a3f4f2,h1:vhC1OXXiT9R2pczegwz6moDvuRpggaroAXhPIseh57A=,9299671a264400f8f0e145da442aa3216394f324c50f045ef2ed2b898b3945c9 +github.com/jbenet/goprocess,v0.1.3,h1:YKyIEECS/XvcfHtBzxtjBBbWK+MbvA6dG8ASiqwvr10=,026bb36c2d4316ad327f8b2e623f172c01140f699d57ec8609f702df5cdf021d +github.com/jcmturner/gofork,v1.0.0,h1:J7uCkflzTEhUZ64xqKnkDxq3kzc96ajM1Gli5ktUem8=,5e015dd9b038f1dded0b2ded77e529d2f6ba0bed228a98831af5a3610eefcb52 +github.com/jdcloud-api/jdcloud-sdk-go,v1.9.1-0.20190605102154-3d81a50ca961,h1:a2/K4HRhg31A5vafiz5yYiGMjaCxwRpyjJStfVquKds=,93754c3fe6c00591fcd499cf73ad7f66e4ed864619579ff726872a2f50b53dfa +github.com/jdkato/prose,v1.1.0,h1:LpvmDGwbKGTgdCH3a8VJL56sr7p/wOFPw/R4lM4PfFg=,4e07b4f2012b46465fcc262d907b1cb81699bc61e6fb7a59ee47ea262e4986d1 +github.com/jeffchao/backoff,v0.0.0-20140404060208-9d7fd7aa17f2,h1:mex1izRBCD+7WjieGgRdy7e651vD/lvB1bD9vNE/3K4=,e6daeed2ffbf793cbdab5e21e9ba47ced708e7c594d4155e1964109903bd199f +github.com/jefferai/isbadcipher,v0.0.0-20190226160619-51d2077c035f,h1:E87tDTVS5W65euzixn7clSzK66puSt1H4I5SC0EmHH4=,c438b15316e4af2487ba2c818288aa15ba19e39b3bf2f83651dcc9d451af6c5b +github.com/jefferai/jsonx,v1.0.0,h1:Xoz0ZbmkpBvED5W9W1B5B/zc3Oiq7oXqiW7iRV3B6EI=,e8ccf27ffc8d4560e7db02f8a1663fd4605c5996a025f90721f8157fde332be7 +github.com/jellevandenhooff/dkim,v0.0.0-20150330215556-f50fe3d243e1,h1:ujPKutqRlJtcfWk6toYVYagwra7HQHbXOaS171b4Tg8=,8a3ba94d93fb61070bee24ffca5043eb32b4a6aafa9b84e4950a5f8f34328659 +github.com/jessevdk/go-flags,v1.4.0,h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=,a26e72c3f4c220df8b65ac6eb3d358a8ad2efc300b212318582893ea882726f9 +github.com/jfrazelle/go,v1.5.1-1,h1:EJWkn/L/VOoena+VQryO7xEkxz7J6lHvPXAe+Z3Q6Gc=,ff67181f47086da85e0d0896aeffb52142f6f45bd3bbf75b94cd7546365bf140 +github.com/jfrog/gofrog,v1.0.5,h1:pEJmKZ9XgvQH2a8WCqAEeUDSXBCKBMN90QzOiOhBTIs=,bb6267655de882922977dca0860020c4c781bf7b3d6aba3fddc206a21c13784c +github.com/jfrog/jfrog-client-go,v0.5.5,h1:dYoajyMXcmc13YpZ/NLye0KL7r+QfpP9l8+WriZNZbE=,3d62cf613d821eb41b8b62ff01e09d8d4eed781f4deb52d3dd96e5a636967732 +github.com/jhump/protoreflect,v1.5.0,h1:NgpVT+dX71c8hZnxHof2M7QDK7QtohIJ7DYycjnkyfc=,a6f0926d31ed98d63d04f2aa60a5579cca471e7544cb701202ba5a5fd3134256 +github.com/jimstudt/http-authentication,v0.0.0-20140401203705-3eca13d6893a,h1:BcF8coBl0QFVhe8vAMMlD+CV8EISiu9MGKLoj6ZEyJA=,0bcf35e1ca69658b70fe05050f436b18ae141a08863cf6011afb39edef5c4013 +github.com/jinzhu/copier,v0.0.0-20190924061706-b57f9002281a,h1:zPPuIq2jAWWPTrGt70eK/BSch+gFAGrNzecsoENgu2o=,c05742c031370bace7c0d5b4101d437e59ad4613bb707fda49c365b3e6af8ad2 +github.com/jinzhu/gorm,v1.9.11,h1:gaHGvE+UnWGlbWG4Y3FUwY1EcZ5n6S9WtqBA/uySMLE=,87f36225e1108c93f299d9b7e4cda23c2f9469ce3db0de59df90691c1e740565 +github.com/jinzhu/inflection,v1.0.0,h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=,cf1087a6f6653ed5f366f85cf0110bbbf581d4e9bc8a4d1a9b56765d94b546c3 +github.com/jinzhu/now,v1.0.1,h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=,5900b34a1d8daa959798e342e684c4237f60ffaebd1aa4201e29a7d3a98d32b7 +github.com/jlaffaye/ftp,v0.0.0-20190126081051-8019e6774408,h1:9AeqmB6KVEJ7GQU985MGQc7Mtxz1+C+JZkgqBnUWqMU=,b1b8b0e10084219eaf1a829778c1b53c049eeb77249a5660b62291cc3b454e6b +github.com/jmcvetta/neoism,v1.3.1,h1:GCFSl/90OYwEQH5LML/Vy6UlwK4SZ2OIO278UI4K7DE=,93e9ce5946ab71d9d0970e3709716a2b9cc96b4d03cfc708dfba8f062e870885 +github.com/jmcvetta/randutil,v0.0.0-20150817122601-2bb1b664bcff,h1:6NvhExg4omUC9NfA+l4Oq3ibNNeJUdiAF3iBVB0PlDk=,742cb157c8eb74da05a7972de646034cf0ddaba7c89d8aac625ed73027e778c1 +github.com/jmespath/go-jmespath,v0.0.0-20180206201540-c2b33e8439af,h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=,5c18f15c2bcfbbdb4fd15c0598ea5d3a373991a7b46a8f2405d00ac8b6121629 +github.com/jmhodges/clock,v0.0.0-20160418191101-880ee4c33548,h1:dYTbLf4m0a5u0KLmPfB6mgxbcV7588bOCx79hxa5Sr4=,f66a541ce3f97b4696d65282a332e8d08dee3f15271b7c2066050aeb5b7334b7 +github.com/jmhodges/levigo,v1.0.0,h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U=,7f43feb409c9650336152a959d7dc4d8e5a260c92e0212b1d2e0f0a7d3de6d87 +github.com/jmoiron/sqlx,v1.2.0,h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=,c8000fe80e86eea575e0d3dd0737f6399c1880a420ce2a9d833ca0e0cfc9c875 +github.com/joefitzgerald/rainbow-reporter,v0.1.0,h1:AuMG652zjdzI0YCCnXAqATtRBpGXMcAnrajcaTrSeuo=,889ea7a751c043bd0ea0ee31734011938be19ecbf08e652d53fc41f3eade9435 +github.com/joeshaw/multierror,v0.0.0-20140124173710-69b34d4ec901,h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4=,e31f735c5f42ac65aef51a70ba1a32b5ac34067a7ba0624192dd41e5ea03aa1e +github.com/joho/godotenv,v1.3.0,h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=,acef5a394fbd1193f52d0d19690b0bfe82728d18dd3bf67730dc5031c22d563f +github.com/jonas-p/go-shp,v0.1.1,h1:LY81nN67DBCz6VNFn2kS64CjmnDo9IP8rmSkTvhO9jE=,ac1706c486b7ea7e83eecd1f773259098569d2fe3ad2a53cc32ff89a68915a8f +github.com/jonboulle/clockwork,v0.1.0,h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=,930d355d1ced60a668bcbca6154bb5671120ba11a34119505d1c0677f7bbbf97 +github.com/joncalhoun/qson,v0.0.0-20170526102502-8a9cab3a62b1,h1:lnrOS18wZBYrzdDmnUeg1OVk+kQ3rxG8mZWU89DpMIA=,062b14a6986be3fb833eb9dd907acb7e563d5b6cfcaee1a04120a9b1fcc2d451 +github.com/josephspurrier/goversioninfo,v0.0.0-20190124120936-8611f5a5ff3f,h1:wBb8/KQrr2tWYffdugrpxOdWyOPSBRNzAR76aF9Nn3Y=,50be4b48f9fb8fbe79a013a791c015c13d7294c5de8f9bee586eaadd6f479459 +github.com/joyent/triton-go,v0.0.0-20190112182421-51ffac552869,h1:BvV6PYcRz0yGnWXNZrd5wginNT1GfFfPvvWpPbjfFL8=,5e875a04efd7f844211b68657d21313ae16b479cb01dc7161811c2c39ac19b18 +github.com/jpillora/backoff,v1.0.0,h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=,f856692c725143c49b9cceabfbca8bc93d3dbde84a0aaa53fb26ed3774c220cc +github.com/jrick/logrotate,v1.0.0,h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI=,b87ee434f9e2cfda719b639cd5bd0a52523f920f64d23336f88070e9d3765d54 +github.com/jsimonetti/rtnetlink,v0.0.0-20190606172950-9527aa82566a,h1:84IpUNXj4mCR9CuCEvSiCArMbzr/TMbuPIadKDwypkI=,97d995d4ca858da8955aefcead01425d12a91188d6f9b36b5cb63aa35a4ea674 +github.com/json-iterator/go,v1.1.8,h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46Ok=,0de8f316729fb05ba608361323b178aa32944154e77aa208ad2818848b0628e2 +github.com/jstemmer/go-junit-report,v0.0.0-20190106144839-af01ea7f8024,h1:rBMNdlhTLzJjJSDIjNEXX1Pz3Hmwmz91v+zycvx9PJc=,b623acfae0dcc440f81ae14f3c5bc3ca40b1a674660ad549127980f892ab165e +github.com/jteeuwen/go-bindata,v3.0.7+incompatible,h1:91Uy4d9SYVr1kyTJ15wJsog+esAZZl7JmEfTkwmhJts=,03f794b47c49da98a4eab6c3a7cc49d286f012d64ab832f783b76b9fcd3bd8b2 +github.com/jtolds/gls,v4.20.0+incompatible,h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=,2f51f8cb610e846dc4bd9b3c0fbf6bebab24bb06d866db7804e123a61b0bd9ec +github.com/jtolds/go-luar,v0.0.0-20170419063437-0786921db8c0,h1:UyVaeqfY1fLPMt1iUTaWsxUNxYAzZVyK+7G+a3sRfhk=,1ed97930b5dfc7f89c84ff3c5ea5a7de9964ccca970f45853d42a13a138b644e +github.com/jtolds/monkit-hw,v0.0.0-20190108155550-0f753668cf20,h1:XK96humQhnPbQ24uKtSHKbdShDgrKYqlWBNKJTcIKbg=,5d84e6f3f559b67e00b08a5e93e1017866695a4590b97ccb23a82e3ce792ad04 +github.com/juju/ansiterm,v0.0.0-20180109212912-720a0952cc2a,h1:FaWFmfWdAUKbSCtOU2QjDaorUexogfaMgbipgYATUMU=,17d1e05fd6f1c8fdce7ba7495af54f4dac1e155febff56bd6450593b016655c2 +github.com/juju/clock,v0.0.0-20190205081909-9c5c9712527c,h1:3UvYABOQRhJAApj9MdCN+Ydv841ETSoy6xLzdmmr/9A=,f57579c0c104add5228b279c4673f592d5756033d33b085185ef72a3d2f83bfe +github.com/juju/cmd,v0.0.0-20190815094254-0c5c82a8dfc6,h1:rPqkdymtMRLcCSYKOeIxuw5mmd8dWx8jSq+t9EGBgtA=,c603f2311cf6524a74535eb9d416a83959c03e6ad52ab4ec081cbc7343734af6 +github.com/juju/collections,v0.0.0-20180717171555-9be91dc79b7c,h1:m/Uo8B7nrH3K6nvk66Y67T7cbHcyY101rW24vGuMON8=,18275066d75835f37845565980c0ac818f9c29145f756b1eeacb6496dac3ebd3 +github.com/juju/errors,v0.0.0-20190930114154-d42613fe1ab9,h1:hJix6idebFclqlfZCHE7EUX7uqLCyb70nHNHH1XKGBg=,2519c885f89cfba663da3bd9a1ff2532e3ae948bdea3e44b42603d8f91cc0796 +github.com/juju/gnuflag,v0.0.0-20171113085948-2ce1bb71843d,h1:c93kUJDtVAXFEhsCh5jSxyOJmFHuzcihnslQiX8Urwo=,47cdfb1bf94a2719e97e03caf4e0dc1cb89ba27c35ed7ce7020701fe8ee2c353 +github.com/juju/gojsonpointer,v0.0.0-20150204194629-afe8b77aa08f,h1:QzpKmMsaP06HVZnYNlcy1CLIXPytsj2NuzfCHitxuus=,0e75303c5dc230f30a629963589376030c3c2a1152a40b9e2075a084224eb173 +github.com/juju/gojsonreference,v0.0.0-20150204194633-f0d24ac5ee33,h1:huRsqE0iXmVPTML75YvFBOiaNj4ZiCZgKVnkRQ06d3w=,d1648b2f71dfbb02acc4a18c55711c721e0f6b50a5280d852cd9c0a639e8ebe6 +github.com/juju/gojsonschema,v0.0.0-20150312170016-e1ad140384f2,h1:VqIDC6dRE0C7wEtTdT6zx2zP5omaoJiZXp2g/dBHRcE=,a9f736e7cb462ccf3b2cb03aa8a133db13dc8d938a2753329a7a1274bdca2656 +github.com/juju/httpprof,v0.0.0-20141217160036-14bf14c30767,h1:COsaGcfAONDdIDnGS8yFdxOyReP7zKQEr7jFzCHKDkM=,9a8c77f887765536c312c89d73d7568126393c7d38c473a50addbec30f8c80ec +github.com/juju/httprequest,v2.0.0+incompatible,h1:+WtiSbRkEwdqKRBi+4JH8PTdNxBa/h8U8RIzdYaMENI=,0d2ae765c01f7956da6896b7c7d8bb1ad4065e960b93c09a644e2e61a0acaa52 +github.com/juju/jsonschema,v0.0.0-20161102181919-a0ef8b74ebcf,h1:SGTxyCG74uh2dYdBJCUJOo2FSx0fRHP7nMRH7s5JVeQ=,a5681c88d87b34d10dcf701b10d149303fa6d152ee224dc1bd7bd7680da80bfa +github.com/juju/loggo,v0.0.0-20190526231331-6e530bcce5d8,h1:UUHMLvzt/31azWTN/ifGWef4WUqvXk0iRqdhdy/2uzI=,3db058c07ced25b8689f5d3e462d344ffb965c6f371eabc0396ce94d927e6206 +github.com/juju/lru,v0.0.0-20190314140547-92a0afabdc41,h1:/ucixsNZ+l94agL5LZioJ4ECyOz7kOYY+DKb/0NN6ME=,8f41907249beb66ba4dee5df1f53c37f387506e21568cc89db4b72493b970e85 +github.com/juju/os,v0.0.0-20191022170002-da411304426c,h1:iJZl5krsl2AqkgU7IiJ2/jNAchctLFa3BiKdyOUvK+g=,b236cb3d90b3fae0f83e767feef3a17b472ab0fe238ac08810c4f9c1d683c14d +github.com/juju/proxy,v0.0.0-20180523025733-5f8741c297b4,h1:y2eoq0Uof/dWLAXRyKKGOJuF0TEkauPscQI7Q1XQqvM=,443cd58a22392e66576d883b9d04c17faebafa37a406a346b671f7e994436c34 +github.com/juju/pubsub,v0.0.0-20190419131051-c1f7536b9cc6,h1:2aARJxmMC2IF9GqVtt5PYcIy4jyuAcR44byqwXKTK0o=,b908f7985f6250270708c2c46ca0ccfc17a3705fea4a27da6f1277a9f6b5404c +github.com/juju/qthttptest,v0.0.1,h1:pR8nTl6Uo/iI6/ynQf5Cxy9FEICXzaa83NtrBdGMCVQ=,4ba292a46e27af468c181118214f7eb1bfc015f289e90841d7746b954f20ba49 +github.com/juju/ratelimit,v1.0.1,h1:+7AIFJVQ0EQgq/K9+0Krm7m530Du7tIz0METWzN0RgY=,c9af5c6719ce3b6912579a029cb2a651707aa25daa1921488f9cae9c4f8ed334 +github.com/juju/retry,v0.0.0-20180821225755-9058e192b216,h1:/eQL7EJQKFHByJe3DeE8Z36yqManj9UY5zppDoQi4FU=,c5b2437ff128cf13f2d6f3cc3b7e226f2c0119e22caed286946245150b9428e7 +github.com/juju/schema,v1.0.0,h1:sZvJ7iQXHhMw/lJ4YfUmq+fe7R2ZSUzZzd/eSokaB3M=,746bcab557bed4e05456419e5012573dc8481dc8740309100e4bd901ff282a39 +github.com/juju/testing,v0.0.0-20191001232224-ce9dec17d28b,h1:Rrp0ByJXEjhREMPGTt3aWYjoIsUGCbt21ekbeJcTWv0=,317de254f343f9aff6e1226b4ea225cab92fee84667db8e72d541667715ea610 +github.com/juju/txn,v0.0.0-20190612234757-afeb83d59782,h1:FcaMWAFKHuxS7UAaB/GuLWrqI9L7f20m6aXaxg+t5lY=,4656c1c5f0e3dac641999feba77879c7206aff1d606513d7bdb3be7d17a6635c +github.com/juju/utils,v0.0.0-20180820210520-bf9cc5bdd62d,h1:irPlN9z5VCe6BTsqVsxheCZH99OFSmqSVyTigW4mEoY=,8edd8a74c692eb717156a2bb689e1e24a446656677760dc7dc06b761ee451df5 +github.com/juju/version,v0.0.0-20180108022336-b64dbd566305,h1:lQxPJ1URr2fjsKnJRt/BxiIxjLt9IKGvS+0injMHbag=,73312c50c8b4f6f8644aaccc09b71a2235c8083cfc6c99425540f3c0a3c29e64 +github.com/juju/webbrowser,v1.0.0,h1:JLdmbFtCGY6Qf2jmS6bVaenJFGIFkdF1/BjUm76af78=,7b38f053656e4a883bc122589994e4ec34eae3f833e899450650752d5b72eec8 +github.com/juliangruber/go-intersect,v1.0.0,h1:0XNPNaEoPd7PZljVNZLk4qrRkR153Sjk2ZL1426zFQ0=,e7f539e6b13470da34009d3ab44c6ba84a6b9bb9f6e92d315551919287a25e3c +github.com/julienschmidt/httprouter,v1.3.0,h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=,e457dccd7015f340664e3b8cfd41997471382da2f4a743ee55be539abc6ca1f9 +github.com/jung-kurt/gofpdf,v1.0.3-0.20190309125859-24315acbbda5,h1:PJr+ZMXIecYc1Ey2zucXdR73SMBtgjPgwa31099IMv0=,f0fa70ade137185bbff2f016831a2a456eaadc8d14bc7bf24f0229211820c078 +github.com/justinas/alice,v0.0.0-20171023064455-03f45bd4b7da,h1:5y58+OCjoHCYB8182mpf/dEsq0vwTKPOo4zGfH0xW9A=,3d6623831901bb973db882bbaffcff3f55849724100ee72c5bf8d0fdfa927ae4 +github.com/jzelinskie/whirlpool,v0.0.0-20170603002051-c19460b8caa6,h1:RyOL4+OIUc6u5ac2LclitlZvFES6k+sg18fBMfxFUUs=,ca0115fcfaaa03f1973f65d05c6d6aefdbdeca6507cdda4359fdf55fd0be2c48 +github.com/k0kubun/colorstring,v0.0.0-20150214042306-9440f1994b88,h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM=,32a2eac0ffb69c6882b32ccfcdd76968cb9dfee9d9dc3d469fc405775399167c +github.com/k0kubun/pp,v3.0.1+incompatible,h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40=,2b91f559df17a49554094e4befd7e1c7d32ba4519417b1b36796d9b49d7328c5 +github.com/kami-zh/go-capturer,v0.0.0-20171211120116-e492ea43421d,h1:cVtBfNW5XTHiKQe7jDaDBSh/EVM4XLPutLAGboIXuM0=,fb1ef7d18f4cec39e9115fb200fbf7d5cff65674afe6ecc63ad57d413f503830 +github.com/kamilsk/retry/v4,v4.3.1,h1:hNQmK1xAgybAVsadNAGvCNutFLS2h+Ycpw317u4d+i0=,74181d82f9bba5b7c313c6b338f127668fffbede70f5495a4a2ef8fddaa6c20f +github.com/kardianos/osext,v0.0.0-20190222173326-2bc1f35cddc0,h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=,10976c39b58f218a6e29687d19763845e7650d04ac86096cd67ace58f4e56346 +github.com/karrick/godirwalk,v1.13.0,h1:GJq8GHQEAPsjwqfGhLNXBO5P0dS2HYdDRVWe+P4E/EQ=,9652ac9eb85bf13594ba9c41a86864ec5236e429a65f6bbb19c6897d1e335092 +github.com/kataras/golog,v0.0.9,h1:J7Dl82843nbKQDrQM/abbNJZvQjS6PfmkkffhOTXEpM=,bb4d1476d5cbe33088190116a5af7b355fd62858127a8ea9d30d77701279350e +github.com/kataras/iris,v11.1.1+incompatible,h1:c2iRKvKLpTYMXKdVB8YP/+A67NtZFt9kFFy+ZwBhWD0=,9aba6b1128d42ee2b63a9319e28c1b665b7e82dde1b10763ee7510bcc6427a25 +github.com/kataras/pio,v0.0.0-20190103105442-ea782b38602d,h1:V5Rs9ztEWdp58oayPq/ulmlqJJZeJP6pP79uP3qjcao=,70a50855f07ff59d96db9633a0cf729280a8b9f7af72b936fe8a28e48406432f +github.com/kavu/go_reuseport,v1.4.0,h1:YIp/96RZ3sJfn0LN+FFkkXIq3H3dfVOdRUtNejhDcxc=,b08d4f774766e1136fd256484f2584d42cd568b5edc7dbc7b19e1259b5dbb75c +github.com/kballard/go-shellquote,v0.0.0-20180428030007-95032a82bc51,h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=,ae4cb7b097dc4eb0c248dff00ed3bbf0f36984c4162ad1d615266084e58bd6cc +github.com/kellydunn/golang-geo,v0.7.0,h1:A5j0/BvNgGwY6Yb6inXQxzYwlPHc6WVZR+MrarZYNNg=,4f4699636a450e20bd107fb81894fcdcc8ceeddbac7062e9457c67326c1fb036 +github.com/kelseyhightower/envconfig,v1.4.0,h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=,af674112c38290862e5f59fc2867b81f7b0e623ec2fd1465cd3812e538b351d3 +github.com/kennygrant/sanitize,v1.2.4,h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8NzpJ3o=,733211913a22ff6eb5843455345fde8c0c3cff25cc5e8e8225c330fb4c6a72df +github.com/kevinburke/ssh_config,v0.0.0-20190725054713-01f96b0aa0cd,h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=,ebd98d4bfd0deb1825d9a54689560b42a17d87385222971117ad72e7ad2f36fa +github.com/keybase/go-crypto,v0.0.0-20190403132359-d65b6b94177f,h1:Gsc9mVHLRqBjMgdQCghN9NObCcRncDqxJvBvEaIIQEo=,a839bacd8eb0a61a72f84678d568d8df899b512510a326e06db0f191e8c1c5a1 +github.com/kisielk/errcheck,v1.2.0,h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E=,709eeca978804f41720a94bc69ee3cfa8277f7d15016478a3ebda86606a286c5 +github.com/kisielk/gotool,v1.0.0,h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=,089dbba6e3aa09944fdb40d72acc86694e8bdde01cfc0f40fe0248309eb80a3f +github.com/kisielk/sqlstruct,v0.0.0-20150923205031-648daed35d49,h1:o/c0aWEP/m6n61xlYW2QP4t9424qlJOsxugn5Zds2Rg=,dbff9241f676de69e88bc006004da6087576433457b306f53cb952d0313ccb78 +github.com/kisom/goutils,v1.1.0,h1:z4HEOgAnFq+e1+O4QdVsyDPatJDu5Ei/7w7DRbYjsIA=,a0b58731f8e1144c013107294885891c44b7fd3235da0ec20776f4d644b4eaa4 +github.com/kkdai/bstream,v1.0.0,h1:Se5gHwgp2VT2uHfDrkbbgbgEvV9cimLELwrPJctSjg8=,dc1d546e0df6ef040963bc9d483834d6e56c77e0e4f6c48e574ac360e7723121 +github.com/klauspost/compress,v1.8.2,h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs=,4dc2632696a9cd93cc32c1564e1a6aa4aecfcb5c995a077d45c6f92116e1711d +github.com/klauspost/cpuid,v1.2.1,h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=,8367d6c97e74f88b149ba9de708ff321273e0114aeb71a45e62e5ac296412420 +github.com/klauspost/crc32,v0.0.0-20161016154125-cb6bfca970f6,h1:KAZ1BW2TCmT6PRihDPpocIy1QTtsAsrx6TneU/4+CMg=,6b632853a19f039138f251f94dbbdfdb72809adc3a02da08e4301d3d48275b06 +github.com/klauspost/pgzip,v1.2.1,h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM=,a482336aa4b0e4e9368b15d75629ae741b44ef290b7d16430ba05ce561846213 +github.com/klauspost/reedsolomon,v1.9.2,h1:E9CMS2Pqbv+C7tsrYad4YC9MfhnMVWhMRsTi7U0UB18=,ea8a4d6d994088dae0308843fd6bddb7541cf36306463a696fd4a29097496705 +github.com/knative/pkg,v0.0.0-20191031171713-d4ce00139499,h1:ha5eqzJaPg1CZroomqWxHqspOqpqpRMO3fDtgF1fvIM=,a8d19fc2196a1aec7869ca45df44ba9c5de5b81b6094f0579d25989eb7967660 +github.com/kniren/gota,v0.9.0,h1:ywFrdNxkBD5Xypk5BxjCaKiH507oQVXIf31pTvRhC4I=,062182a345c456c9c0fd7ce9644900708f7f9c08707d64fe2438b9d295dad6dd +github.com/knq/sysutil,v0.0.0-20191005231841-15668db23d08,h1:V0an7KRw92wmJysvFvtqtKMAPmvS5O0jtB0nYo6t+gs=,81ec4ac93dba6a6161264a0575f20235d8932abab0cd6b9777b4be936f5c2af5 +github.com/knqyf263/berkeleydb,v0.0.0-20190501065933-fafe01fb9662,h1:UGS0RbPHwXJkq8tcba8OD0nvVUWLf2h7uUJznuHPPB0=,1e575b5fdc170e0318ab06841873ae6d115978fbaffc3779290d7ba3aadbdf0e +github.com/knqyf263/go-deb-version,v0.0.0-20190517075300-09fca494f03d,h1:X4cedH4Kn3JPupAwwWuo4AzYp16P0OyLO9d7OnMZc/c=,4a09d0533768cf6f9d929858aa2e79b6942685569c2db00b8d4688590a89ba3d +github.com/knqyf263/go-rpmdb,v0.0.0-20190501070121-10a1c42a10dc,h1:pumO9pqmRAjvic6oove22RGh9wDZQnj96XQjJSbSEPs=,33a3568289d22672dfcb0ba7c5b8aa7f9223d5303003368e7dbe8c9718a803b4 +github.com/knqyf263/nested,v0.0.1,h1:Sv26CegUMhjt19zqbBKntjwESdxe5hxVPSk0+AKjdUc=,c0e123844a174b1e9929d4368d8a8bb2f5ecef578ee9dee692c5971a47a633ff +github.com/koki/structurederrors,v0.0.0-20180506174113-6b997eb5e2ca,h1:KmXUVzyPjXzd3kY0feNFsWOGVDYFT4MjjgG8QJx0m6k=,1efa717c181722fd1c6807919571dc559b48d17120f5eeb4638a322fb882411a +github.com/kolo/xmlrpc,v0.0.0-20190717152603-07c4ee3fd181,h1:TrxPzApUukas24OMMVDUMlCs1XCExJtnGaDEiIAR4oQ=,9d37c94f50784536aa8ef9a7623ec7bcac9e5bc67b18f7a801efc7cbbe6b1ab0 +github.com/konsorten/go-windows-terminal-sequences,v1.0.2,h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=,4d00d71b8de60bcaf454f8f867210ebcd05e75c0a7c2725904f71aa2f20fb08e +github.com/koron/go-ssdp,v0.0.0-20180514024734-4a0ed625a78b,h1:wxtKgYHEncAU00muMD06dzLiahtGM1eouRNOzVV7tdQ=,3a99f050b7a668291942cada4e38213965fa0ae3794469bb29ad0d6d9677db23 +github.com/kr/fs,v0.1.0,h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=,d376bd98e81aea34585fc3b04bab76363e9e87cde69383964e57e9779f2af81e +github.com/kr/logfmt,v0.0.0-20140226030751-b84e30acd515,h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=,ebd95653aaca6182184a1b9b309a65d55eb4c7c833c5e790aee11efd73d4722c +github.com/kr/pretty,v0.1.0,h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=,06063d21457e06dc2aba4a5bd09771147ec3d8ab40b224f26e55c5a76089ca43 +github.com/kr/pty,v1.1.8,h1:AkaSdXYQOWeaO3neb8EM634ahkXXe3jYbVh/F9lq+GI=,d66e6fbc65e772289a7ff8c58ab2cdfb886253053b0cea11ba3ca1738b2d6bc6 +github.com/kr/text,v0.1.0,h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=,9363a4c8f1f3387a36014de51b477b831a13981fc59a5665f9d21609bea9e77c +github.com/kshvakov/clickhouse,v1.3.4,h1:p/yqvOmeDRH+KyCH6NtwExelr4rimLBBfKW2a/wBN94=,01a0d1a90e0545da94350319a52c051257fee64c838e2632ec40ef8d89a2f153 +github.com/kylelemons/go-gypsy,v0.0.0-20160905020020-08cad365cd28,h1:mkl3tvPHIuPaWsLtmHTybJeoVEW7cbePK73Ir8VtruA=,321087246482a680bd3f06de64075fb843430da544596ad216a4a63d5b8dafa3 +github.com/kylelemons/godebug,v1.1.0,h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=,dbbd0ce8c2f4932bb03704d73026b21af12bd68d5b8f4798dbf10a487a2b6d13 +github.com/kyokomi/emoji,v2.1.0+incompatible,h1:+DYU2RgpI6OHG4oQkM5KlqD3Wd3UPEsX8jamTo1Mp6o=,0721a2fc643e49e002bd8a3e604b5d2f0f3e242cc279d14d76f90a55f8aeebf7 +github.com/labbsr0x/bindman-dns-webhook,v1.0.2,h1:I7ITbmQPAVwrDdhd6dHKi+MYJTJqPCK0jE6YNBAevnk=,d1a327ab22f62486250f50f98990c0d9e1a5fdece6a496fbbb85d4e123df3244 +github.com/labbsr0x/goh,v1.0.1,h1:97aBJkDjpyBZGPbQuOK5/gHcSFbcr5aRsq3RSRJFpPk=,84c91135623961c7c400bf8b646da76c0ce2941fe8706d5aef5650be9a5e37dd +github.com/labstack/echo,v3.3.10+incompatible,h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg=,29634743cf44c47079b74812ecf5aa7074630507886c4ff40b60c397c45af524 +github.com/labstack/gommon,v0.3.0,h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=,2783ed1c24d09a5539bc35954f71f41d270d78dc656be256c98a8ede2cbbe451 +github.com/lafriks/xormstore,v1.0.0,h1:P/IJzNSIpjXl/Up3o2Td5ZU/x4v6DEKLMaPQJGtmJCk=,0e347e24ab91f62e1b69bab5d78cbba77569f087b483569ef37761e1f93a3f46 +github.com/lann/builder,v0.0.0-20180802200727-47ae307949d0,h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=,1fe7a88079ff2bbe90fb4724fb5c353ecb6af4cd7e011440354c804f678895ee +github.com/lann/ps,v0.0.0-20150810152359-62de8c46ede0,h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=,76756d46634f44edd3facdb01e7271ddf23a1b51a8423de55d3a2bf685ff032a +github.com/leanovate/gopter,v0.2.4,h1:U4YLBggDFhJdqQsG4Na2zX7joVTky9vHaj/AGEwSuXU=,99b27788411d478764bf7c51e4f6e84e5ccd60f3959a88a03e96b2a1d519a45d +github.com/leodido/go-urn,v1.2.0,h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=,8a854d784171000a69b79babb2cd3da9b8fccb1e1b6bb102c7a6d2b52380d08a +github.com/lestrrat-go/jspointer,v0.0.0-20181205001929-82fadba7561c,h1:pGh5EFIfczeDHwgMHgfwjhZzL+8/E3uZF6T7vER/W8c=,a64de11dd2840c3251906c5fe5f61719713af52a41287411007434684745af39 +github.com/lestrrat-go/jsref,v0.0.0-20181205001954-1b590508f37d,h1:1eeFdKL5ySmmYevvKv7iECIc4dTATeKTtBqP4/nXxDk=,1acee9b59501460f5063a82bc2c05f1a11cd24077198fc08ba100ee642d3db72 +github.com/lestrrat-go/jsschema,v0.0.0-20181205002244-5c81c58ffcc3,h1:TSKrrGm89gmmVlrG34ZzCIOMNVk5kkSV1P88Dt38DiE=,1b7552a5ecd193bdd07995226f58fe48de0aadedbcb42f3a5b135fd7b3538ea4 +github.com/lestrrat-go/jsval,v0.0.0-20181205002323-20277e9befc0,h1:w4rIjeCV/gQpxtn3i1voyF6Hd7v1mRGIB63F7RZOk1U=,f060af1b36e0f156546436dcc9b1569600871185d69e9daf214f24e0e2934784 +github.com/lestrrat-go/pdebug,v0.0.0-20180220043849-39f9a71bcabe,h1:S7XSBlgc/eI2v47LkPPVa+infH3FuTS4tPJbqCtJovo=,17690c72219264e0a195dac69ae6ed12bbadf309242dbaa21609339dfa74b3a5 +github.com/lestrrat-go/structinfo,v0.0.0-20190212233437-acd51874663b,h1:YUFRoeHK/mvRjBR0bBRDC7ZGygYchoQ8j1xMENlObro=,8dd77f51595dea974553558e0d249059b9047a39354548b5bbd88b32cf3df75a +github.com/lestrrat/go-jsschema,v0.0.0-20181205002244-5c81c58ffcc3,h1:UaOmzcaCH2ziMcSbQFBq/3Iuz/E/Jr/GOGtV80jpFII=,ce0f1e04d70eadcc75f96d70703b53231e1c5be7d9fd832c144e0135bfd5afb4 +github.com/lib/pq,v1.2.0,h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=,cb1028c395747cacafb6c3c6ad5fa244563ce641aae45cf7742f98b6764b1fde +github.com/libp2p/go-addr-util,v0.0.1,h1:TpTQm9cXVRVSKsYbgQ7GKc3KbbHVTnbostgGaDEP+88=,d49a37e15540c8b95f845dde6cdf802e7af490bc13fd88fec3da318d08464f7b +github.com/libp2p/go-buffer-pool,v0.0.2,h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs=,fef932705b72198df3d50befd9d2aa157aea1b5f3d23712b09d627d02cfe841e +github.com/libp2p/go-conn-security,v0.0.1,h1:4kMMrqrt9EUNCNjX1xagSJC+bq16uqjMe9lk1KBMVNs=,e7b58f887c8a8a2ed0178d2f0d6b4ad36bdd7b8cf52ca4d66bafc108b80d095c +github.com/libp2p/go-conn-security-multistream,v0.1.0,h1:aqGmto+ttL/uJgX0JtQI0tD21CIEy5eYd1Hlp0juHY0=,597b249bd51de097142815318b13c339752532f15131887492d9d3e3407ab92e +github.com/libp2p/go-eventbus,v0.1.0,h1:mlawomSAjjkk97QnYiEmHsLu7E136+2oCWSHRUvMfzQ=,1b02c8340d2740f99d67078a8c8823c6b9212b92dd9ca7eaf2a38adf2bfd6b56 +github.com/libp2p/go-flow-metrics,v0.0.1,h1:0gxuFd2GuK7IIP5pKljLwps6TvcuYgvG7Atqi3INF5s=,f783542a7fce8382de9cea6940049b106cc35f9714126a1e3d61925c29db8617 +github.com/libp2p/go-libp2p-autonat,v0.1.0,h1:aCWAu43Ri4nU0ZPO7NyLzUvvfqd0nE3dX0R/ZGYVgOU=,11e86ef0b36125a7cd6aa447ffe488f7f3ab00e441bdf8cf30a832a41da4342c +github.com/libp2p/go-libp2p-blankhost,v0.1.4,h1:I96SWjR4rK9irDHcHq3XHN6hawCRTPUADzkJacgZLvk=,9cd5abe8ad2f137c13309a9dbdd213376bbec03f9685cf8cde7fbfe2e5783e7d +github.com/libp2p/go-libp2p-circuit,v0.1.0,h1:eniLL3Y9aq/sryfyV1IAHj5rlvuyj3b7iz8tSiZpdhY=,24ee6c7851f4f0072922ae497c230718a0f44beab890d0403261b38a2946a866 +github.com/libp2p/go-libp2p-core,v0.2.4,h1:Et6ykkTwI6PU44tr8qUF9k43vP0aduMNniShAbUJJw8=,d521cc1bffba8afc8b8057901cf22c2f6ffd88faec0274426e13c4e7c12c756c +github.com/libp2p/go-libp2p-crypto,v0.1.0,h1:k9MFy+o2zGDNGsaoZl0MA3iZ75qXxr9OOoAZF+sD5OQ=,14ef1867bd8b0ef8fc528f5069ef267270dd0de8cf89a235beb9fbd79e4bed8d +github.com/libp2p/go-libp2p-discovery,v0.2.0,h1:1p3YSOq7VsgaL+xVHPi8XAmtGyas6D2J6rWBEfz/aiY=,d1c0800b601cbe6833522727b249567379422e9f324b7d0a0866bd86c74fb930 +github.com/libp2p/go-libp2p-host,v0.1.0,h1:OZwENiFm6JOK3YR5PZJxkXlJE8a5u8g4YvAUrEV2MjM=,d26bf1db299917f080a13ace37ef4363c08c2407c126cee59e642b1372d2b211 +github.com/libp2p/go-libp2p-interface-connmgr,v0.0.5,h1:KG/KNYL2tYzXAfMvQN5K1aAGTYSYUMJ1prgYa2/JI1E=,fe1e74365cc5c155161e5500671a8e9a85a90efdad9f5630bdfdc15bdfc52fe5 +github.com/libp2p/go-libp2p-interface-pnet,v0.0.1,h1:7GnzRrBTJHEsofi1ahFdPN9Si6skwXQE9UqR2S+Pkh8=,9767f78f87f54bdf3fb1f0f9b5f67e907463b445a00a566402bacca85749c8fe +github.com/libp2p/go-libp2p-loggables,v0.1.0,h1:h3w8QFfCt2UJl/0/NW4K829HX/0S4KD31PQ7m8UXXO8=,351c87c02c2b147193fac5c441d8767d2b247cd3f3c420fa205da2ccd1c3f00f +github.com/libp2p/go-libp2p-metrics,v0.1.0,h1:v7YMUTHNobFaQeqaMfJJMbnK3EPlZeb6/KFm4gE9dks=,a86fe0ae6cda820fd6a0e576bcd94a22360439819f344a9121086b31c651caaf +github.com/libp2p/go-libp2p-mplex,v0.2.1,h1:E1xaJBQnbSiTHGI1gaBKmKhu1TUKkErKJnE8iGvirYI=,f11961ef5114e57eb176740a066e1535132c8c238bd444ed53d94fad36ba7708 +github.com/libp2p/go-libp2p-nat,v0.0.4,h1:+KXK324yaY701On8a0aGjTnw8467kW3ExKcqW2wwmyw=,4c3db4e0f7f714439364ca0853f63d426bba67924da6fd050fd0184abdfec2df +github.com/libp2p/go-libp2p-net,v0.1.0,h1:3t23V5cR4GXcNoFriNoZKFdUZEUDZgUkvfwkD2INvQE=,4140afd418393c2a4ecccca97d80b4752d20da6f34fac15fbdc4f0566f7b8cea +github.com/libp2p/go-libp2p-netutil,v0.1.0,h1:zscYDNVEcGxyUpMd0JReUZTrpMfia8PmLKcKF72EAMQ=,c98ad0a3ffab37b6a0bc80aefba4e4cb442b09c01277a7dcc0086c4a004e649a +github.com/libp2p/go-libp2p-peer,v0.2.0,h1:EQ8kMjaCUwt/Y5uLgjT8iY2qg0mGUT0N1zUjer50DsY=,5b400d6b6337cc759846d7ddf50ec2d761148e1447a86982696687ef1e792c1a +github.com/libp2p/go-libp2p-peerstore,v0.1.4,h1:d23fvq5oYMJ/lkkbO4oTwBp/JP+I/1m5gZJobNXCE/k=,1606c0bb56c31d0249980b8a0c0e5dda9212687b1994ef47cfd42039d4cf1847 +github.com/libp2p/go-libp2p-protocol,v0.1.0,h1:HdqhEyhg0ToCaxgMhnOmUO8snQtt/kQlcjVk3UoJU3c=,4560018136a73817e03eed49af46d97dd561b3eeffb1ff00559152acf9a74627 +github.com/libp2p/go-libp2p-pubsub,v0.2.0,h1:4UXcjpQdpam/RsGhfWyT/4u5f6F42ods/WgDAaocYxA=,bde7bb50d950b8ea7902c523a696eff4ad7b5d0daac808356358ff6d53aecb14 +github.com/libp2p/go-libp2p-record,v0.1.1,h1:ZJK2bHXYUBqObHX+rHLSNrM3M8fmJUlUHrodDPPATmY=,27a3e94e144b893cbb5ceaddfa7a4e456052e173f807db52945e06920f62d0b3 +github.com/libp2p/go-libp2p-routing,v0.1.0,h1:hFnj3WR3E2tOcKaGpyzfP4gvFZ3t8JkQmbapN0Ct+oU=,4241980dadf216e937a42a572a9c5b5eb28ff62458380ad37892c5b5095de270 +github.com/libp2p/go-libp2p-secio,v0.2.0,h1:ywzZBsWEEz2KNTn5RtzauEDq5RFEefPsttXYwAWqHng=,979a82829f3188d4ca8d20d194923c5620ff12a161d13c945c1630b7b9d050ff +github.com/libp2p/go-libp2p-swarm,v0.2.2,h1:T4hUpgEs2r371PweU3DuH7EOmBIdTBCwWs+FLcgx3bQ=,b920f69fbfaa8805047b958c6d45d944a195181dd6dddab36bead5fe68f2f1e4 +github.com/libp2p/go-libp2p-testing,v0.1.0,h1:WaFRj/t3HdMZGNZqnU2pS7pDRBmMeoDx7/HDNpeyT9U=,e1c7fa467d88b33f2fc519542cc19aa48bcade304f579f10ab402a19c38d0aa6 +github.com/libp2p/go-libp2p-transport,v0.0.5,h1:pV6+UlRxyDpASSGD+60vMvdifSCby6JkJDfi+yUMHac=,df7bc96a5d76c351fd3a6ee29995f4974013d9709904edd9608b86f4fa089ad2 +github.com/libp2p/go-libp2p-transport-upgrader,v0.1.1,h1:PZMS9lhjK9VytzMCW3tWHAXtKXmlURSc3ZdvwEcKCzw=,60ea73fa42536178798c3d4a36c5f9cffb185b6c1629c23c3faff5919f9e9cad +github.com/libp2p/go-libp2p-yamux,v0.2.1,h1:Q3XYNiKCC2vIxrvUJL+Jg1kiyeEaIDNKLjgEjo3VQdI=,849f0097fd7203b5c6d590463b7fb17573af8d12136413768706188a39b34b21 +github.com/libp2p/go-maddr-filter,v0.0.5,h1:CW3AgbMO6vUvT4kf87y4N+0P8KUl2aqLYhrGyDUbLSg=,19c76e021879aab85a8858b53d706220e9e3277a96dead161db152f5a1d17219 +github.com/libp2p/go-mplex,v0.1.0,h1:/nBTy5+1yRyY82YaO6HXQRnO5IAGsXTjEJaR3LdTPc0=,3340a423ea89310360810973a77a97c217fe7b35e1c18189a3628e35fe1275e0 +github.com/libp2p/go-msgio,v0.0.4,h1:agEFehY3zWJFUHK6SEMR7UYmk2z6kC3oeCM7ybLhguA=,ec22f703203a2a443c57896b2082c02fe9c54d372aad091cdca144709d244721 +github.com/libp2p/go-nat,v0.0.3,h1:l6fKV+p0Xa354EqQOQP+d8CivdLM4kl5GxC1hSc/UeI=,d642c9dd697176ec69c4a5faeff1fc3b5472ef9f32c2c40e21c42f81ceef86b9 +github.com/libp2p/go-openssl,v0.0.3,h1:wjlG7HvQkt4Fq4cfH33Ivpwp0omaElYEi9z26qaIkIk=,f2eb05d710fe960ba12d5f640cefe7d31d24f1fab0d9a52faf5f2923a19c6f13 +github.com/libp2p/go-reuseport,v0.0.1,h1:7PhkfH73VXfPJYKQ6JwS5I/eVcoyYi9IMNGc6FWpFLw=,274ade934c7f26ffae86d3f4d34352371c3eca7ead080392f6f35698ec5f0a3f +github.com/libp2p/go-reuseport-transport,v0.0.2,h1:WglMwyXyBu61CMkjCCtnmqNqnjib0GIEjMiHTwR/KN4=,866f45bfa6c2e65d563955a28050bcfbc6ed11df6ded7c551e92ff98ba98a2d8 +github.com/libp2p/go-stream-muxer,v0.1.0,h1:3ToDXUzx8pDC6RfuOzGsUYP5roMDthbUKRdMRRhqAqY=,d42dab9fb102b3e56cc555eb9aacb742e4230120dd356078cc723f8817200d43 +github.com/libp2p/go-stream-muxer-multistream,v0.2.0,h1:714bRJ4Zy9mdhyTLJ+ZKiROmAFwUHpeRidG+q7LTQOg=,a4ca5d0422d55ee7b4e74b040ca85799365b05684b7b6687adfa79a345049a9d +github.com/libp2p/go-tcp-transport,v0.1.1,h1:yGlqURmqgNA2fvzjSgZNlHcsd/IulAnKM8Ncu+vlqnw=,147dc8d50aab944666c1a7a371ba3e351480506313be298ebf8dcdb9dc51b1b4 +github.com/libp2p/go-testutil,v0.1.0,h1:4QhjaWGO89udplblLVpgGDOQjzFlRavZOjuEnz2rLMc=,9fa6fa5741f541a6309e8a5fa6031c51f97fcd3086fe3a3b371b74f9d8e9a4b8 +github.com/libp2p/go-ws-transport,v0.1.0,h1:F+0OvvdmPTDsVc4AjPHjV7L7Pk1B7D5QwtDcKE2oag4=,30cfd8011bb8de03c23680d2249120ea9ba29879e855ca5c35311f8fa874d094 +github.com/libp2p/go-yamux,v1.2.3,h1:xX8A36vpXb59frIzWFdEgptLMsOANMFq2K7fPRlunYI=,97947a07c9430184c3be45e87580abcdea18c9b7435adb8048b08aebce0fea50 +github.com/liggitt/tabwriter,v0.0.0-20181228230101-89fcab3d43de,h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=,41b6869255915ffdfd32575ba14d52732d62d34b47d904df4890e165489ec77d +github.com/linkedin/goavro,v2.1.0+incompatible,h1:DV2aUlj2xZiuxQyvag8Dy7zjY69ENjS66bWkSfdpddY=,25d4ccde4ece770196fbf6f09ca4184df581944224be5d64a263eb2c7f9a24fc +github.com/linode/linodego,v0.10.0,h1:AMdb82HVgY8o3mjBXJcUv9B+fnJjfDMn2rNRGbX+jvM=,4c4e8829c0290c473e36bacdce8b490833d1f6247b1a4290062db30ba2b21568 +github.com/liquidweb/liquidweb-go,v1.6.0,h1:vIj1I/Wf97fUnyirD+bi6Y63c0GiXk9nKI1+sFFl3G0=,19e08fe2aa62655eb3cb209b37d532a267dd3078e5d262c4c45e7e09134b079c +github.com/lithammer/dedent,v1.1.0,h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffktY=,4ec56a3fef0d7dd1536046e540827e60419a935dde49d87d21f5856174cadba2 +github.com/logrusorgru/aurora,v0.0.0-20180419164547-d694e6f975a9,h1:KQdwUNlTDGyS6e+2rjAxfHSpBFIOHXqgDceNDqb55+4=,3b9d5caeede8553ead48405de57cd25bf6276b12531dae582c3ee089474aaf95 +github.com/loov/hrtime,v0.0.0-20181214195526-37a208e8344e,h1:UC+nLCm+w3WL+ibAW/wsWbQC3KAz7LLawR2hgX0eR9s=,f077796a9f39c579d356ac8f99831c56b3b2c52b70526f97730eccdc5ce558b2 +github.com/loov/plot,v0.0.0-20180510142208-e59891ae1271,h1:51ToN6N0TDtCruf681gufYuEhO9qFHQzM3RFTS/n6XE=,eb57dc24113d92cda1d0eecd6280603a2f1a98eececde895db4b060a7208659a +github.com/lovoo/gcloud-opentracing,v0.3.0,h1:nAeKG70rIsog0TelcEtt6KU0Y1s5qXtsDLnHp0urPLU=,7bead4937d23976e07caf4bf7a7f302724cda9155aa8ac4de7baa2e10976eacc +github.com/lsegal/gucumber,v0.0.0-20180127021336-7d5c79e832a2,h1:Gg0dt1q5bB+3R3qu+BucR+1f5ZhKm3OzPPo53dZ3Hxs=,2e5cd235f8c80ae078b3115b41fb765682c796d62fa54ecbb2096b159b0294bd +github.com/lucas-clemente/aes12,v0.0.0-20171027163421-cd47fb39b79f,h1:sSeNEkJrs+0F9TUau0CgWTTNEwF23HST3Eq0A+QIx+A=,074a3c40044c8f07dbe93129fe30bfd4a12f6283f393e7300664d59924a8af2b +github.com/lucas-clemente/quic-clients,v0.1.0,h1:/P9n0nICT/GnQJkZovtBqridjxU0ao34m7DpMts79qY=,b916edbd87d45fd375b0f81f905453102eb4e7e724ca0fc8ac5be323fe5958b8 +github.com/lucas-clemente/quic-go,v0.12.1,h1:BPITli+6KnKogtTxBk2aS4okr5dUHz2LtIDAP1b8UL4=,144443ffb6231cabbe6da1496c5851eb73f03fff33d7bd94aa394f8d1e3c73b3 +github.com/lucas-clemente/quic-go-certificates,v0.0.0-20160823095156-d2f86524cced,h1:zqEC1GJZFbGZA0tRyNZqRjep92K5fujFtFsu5ZW7Aug=,d9eff929a62711fc36f9655008e144863cd816ad2b59d25eb00a248c96178ce5 +github.com/lucasb-eyer/go-colorful,v1.0.2,h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4=,c0e388db91f217be87f8d508ac9f495adc5a33ffda78849e2d0a89a8e8dae28c +github.com/lunixbochs/struc,v0.0.0-20190916212049-a5c72983bc42,h1:PzBD7QuxXSgSu61TKXxRwVGzWO5d9QZ0HxFFpndZMCg=,8a7db31161ec3a3bcc7b52e25975d0299b9c0bb465f076014d303f112b5cb9e1 +github.com/lunixbochs/vtclean,v1.0.0,h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8=,4d73f9678abde21c67dd8cb4ed8d7f63bcdd9413b6093b53cec4d26ce1be5b88 +github.com/lunny/dingtalk_webhook,v0.0.0-20171025031554-e3534c89ef96,h1:uNwtsDp7ci48vBTTxDuwcoTXz4lwtDTe7TjCQ0noaWY=,b94d4c7cacca0c289b3fbbeae6cc9e66f2eec4a3210fbbfd208316337ff2f1e3 +github.com/lunny/levelqueue,v0.0.0-20190217115915-02b525a4418e,h1:GSprKUrG9wNgwQgROvjPGXmcZrg4OLslOuZGB0uJjx8=,8f62ece23811c3c2be0d1c8d10057ab564641b2f73dc5a9910dd5f8462954f19 +github.com/lunny/log,v0.0.0-20160921050905-7887c61bf0de,h1:nyxwRdWHAVxpFcDThedEgQ07DbcRc5xgNObtbTp76fk=,0d551b83dcb0c4a3e0f97febf74e8f69b58a419791e217a7d2fd3d79a1e5877b +github.com/lunny/nodb,v0.0.0-20160621015157-fc1ef06ad4af,h1:UaWHNBdukWrSG3DRvHFR/hyfg681fceqQDYVTBncKfQ=,a0f6632294f1eec60e2651fa2d4b3590f3a1a8e2f7692dcc77251b945906a701 +github.com/lusis/go-artifactory,v0.0.0-20160115162124-7e4ce345df82,h1:wnfcqULT+N2seWf6y4yHzmi7GD2kNx4Ute0qArktD48=,487d2ef1720bd49c5a36efc8893fdb0a76bd5f8b064c2a98974a78b3e35f5763 +github.com/lusis/go-slackbot,v0.0.0-20180109053408-401027ccfef5,h1:AsEBgzv3DhuYHI/GiQh2HxvTP71HCCE9E/tzGUzGdtU=,0bb7feaeb5a4e83486234c1c8fbe2f73b94213f511aaf6b8ef1f0fc96dd7b4fa +github.com/lusis/outputter,v0.0.0-20171130132426-5a3b464a163f,h1:JY0YSH+YvMGmq83g5qILMAkJDFv7qIiHalhlQXal9V0=,e3b54ad36707730681b10a3838d89c346bf2d2c52cb61a241b178bcb0fc96e0f +github.com/lusis/slack-test,v0.0.0-20190426140909-c40012f20018,h1:MNApn+Z+fIT4NPZopPfCc1obT6aY3SVM6DOctz1A9ZU=,019aa5a65d7fc369730c089a8af985f8d4760297a0058dd0c352fb662e8a0cfc +github.com/lyft/protoc-gen-star,v0.4.11,h1:zW6fJQBtCtVeSiO/Kbpzv32GO0J/Z8egSLeohES202w=,673c0c53ce301a5589d4aab2b389c6ab52c8312193bae9b491e75e4938475277 +github.com/lyft/protoc-gen-validate,v0.1.0,h1:NytKd9K7UW7Szxn+9PYNsaJ/98TL/WsDq4ro4ZVuh5o=,2e452d4298aa5f2be8d4eda3e55522a4c020d0f23dac6b33ecf9942be09bf082 +github.com/magefile/mage,v1.4.0,h1:RI7B1CgnPAuu2O9lWszwya61RLmfL0KCdo+QyyI/Bhk=,55862155e89367536d665080ac028decc98ce68c5651ccc4238d7e34ddf1cbc2 +github.com/magiconair/properties,v1.8.1,h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=,c0f0378f5949db2e7976d6822a0dfac1786acd34190e83ab253d6505542d0128 +github.com/mailgun/mailgun-go,v0.0.0-20171127222028-17e8bd11e87c,h1:5huPh/MfWW65cx8KWNVD4mCCnwIrNiX4bFJR5OeONg0=,33250edd00795e387f2de671003b8ef8f2d940d24b12a9ce90c6b49dd6094231 +github.com/mailgun/minheap,v0.0.0-20170619185613-3dbe6c6bf55f,h1:aOqSQstfwSx9+tcM/xiKTio3IVjs7ZL2vU8kI9bI6bM=,26930b2a6dc2f2b442e28ecc5dcbb22c2e7da3d151b3388d0bc604370bd9df77 +github.com/mailgun/multibuf,v0.0.0-20150714184110-565402cd71fb,h1:m2FGM8K2LC9Zyt/7zbQNn5Uvf/YV7vFWKtoMcC7hHU8=,7dbb280e8bc981732510ee72e124e931991d06c317531de709fd7922e38a5339 +github.com/mailgun/timetools,v0.0.0-20170619190023-f3a7b8ffff47,h1:jlyJPTyctWqANbaxi/nXRrxX4WeeAGMPaHPj9XlO0Rw=,a4d961cefbfbe858f4ba5a5824d91ad8713a736707f5c259cf0d7307a07ac83e +github.com/mailgun/ttlmap,v0.0.0-20170619185759-c1c17f74874f,h1:ZZYhg16XocqSKPGNQAe0aeweNtFxuedbwwb4fSlg7h4=,35308e95ed02635049d1804b85f16407f3109fc60c38df541f0401dbba66dc8d +github.com/mailru/easyjson,v0.7.0,h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=,c36c8ab36aab9ba2ca776d1c71cbd9c30fce7c4e8e62be6611f4c2d1e98e86ae +github.com/manucorporat/sse,v0.0.0-20160126180136-ee05b128a739,h1:ykXz+pRRTibcSjG1yRhpdSHInF8yZY/mfn+Rz2Nd1rE=,cd90f350cca3a6536432afb4cd2355ff25124ef89fc23a52392e5189733b0359 +github.com/manveru/faker,v0.0.0-20171103152722-9fbc68a78c4d,h1:Zj+PHjnhRYWBK6RqCDBcAhLXoi3TzC27Zad/Vn+gnVQ=,80bc3e8ca50e89d3a6139d1709fbf4680c26231079d297d237902d3c23f4c1e8 +github.com/manveru/gobdd,v0.0.0-20131210092515-f1a17fdd710b,h1:3E44bLeN8uKYdfQqVQycPnaVviZdBLbizFhU49mtbe4=,39811c3d6c7de66195a29a78b235dead57fb866e61082301fe68d51cf04a5200 +github.com/markbates/deplist,v1.3.0,h1:uPgoloPraPBPYtNSxj2UwZBh2EHW9TmMvQCP2FBiRlU=,e0b1903fb33c324721565076e2061d7f54e29ba098afb80af4fe2ccdd02ed178 +github.com/markbates/going,v1.0.3,h1:mY45T5TvW+Xz5A6jY7lf4+NLg9D8+iuStIHyR7M8qsE=,61efe687a56d3141284be7bdb83bb5ae86e1df694ababa5937c4d3e30f3b60f1 +github.com/markbates/goth,v1.49.0,h1:qQ4Ti4WaqAxNAggOC+4s5M85sMVfMJwQn/Xkp73wfgI=,39a0244d07f47d7b91215590900a7754c4700e875c0866b1e65568133471478a +github.com/markbates/grift,v1.1.0,h1:DsljFKUSK1ELpU22ZE+Gi93jiQI3cYD/RQ+vHM/PpY8=,29aa2fa782f9d8730bde2df024c40ba749f1812dd3bbab489b4197a1faa78627 +github.com/markbates/hmax,v1.1.0,h1:MswE0ks4Iv1UAQNlvAyFpsyFQSBHolckas95gRUkka4=,8c7557798a88c74594f27137be859e99195427e2e04f0835f48781b0bde5c73a +github.com/markbates/inflect,v1.0.4,h1:5fh1gzTFhfae06u3hzHYO9xe3l3v3nW5Pwt3naLTP5g=,0da6e75f6cd27672255a41f5dfab418d2746897239ad601e5d8d78d6354b5665 +github.com/markbates/oncer,v1.0.0,h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY=,9a774885bfa4c9a96c438fdb51768833e1c7003f35cd27961137ff4096b1a764 +github.com/markbates/refresh,v1.8.0,h1:ELMS9kKyO/H6cJrqFo6qCyE0cRx2JeHWC9yusDkVeM8=,7ac81390a898cfd1cdc097ffb1e05321c415183165b7341749de41160c47e504 +github.com/markbates/safe,v1.0.1,h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI=,d5a98e8242318d4e88844ddbbfebe91f67f41e5aa1f6a96a58fa2fa94e0ae9ef +github.com/markbates/sigtx,v1.0.0,h1:y/xtkBvNPRjD4KeEplf4w9rJVSc23/xl+jXYGowTwy0=,e3b591a1a2b4dcec7b86d59e504b0bbf87ec3663efad818cd9b00471a33a0345 +github.com/markbates/willie,v1.0.9,h1:394PpHImWjScL9X2VRCDXJAcc77sHsSr3w3sOnL/DVc=,a6c3eda44d765eeb1370b0ddeb739df86e900b78eb365688da143f1c0c0e9bc0 +github.com/marstr/guid,v1.1.0,h1:/M4H/1G4avsieL6BbUwCOBzulmoeKVP5ux/3mQNnbyI=,7db3cd8020c72ba260d1a20183bf5a030c696d6442eccaff2b31f72b194fc571 +github.com/marten-seemann/qpack,v0.1.0,h1:/0M7lkda/6mus9B8u34Asqm8ZhHAAt9Ho0vniNuVSVg=,46c42087e554edae4e19f79b785722d27316e23278889bf78a0c8f43fc387f2e +github.com/marten-seemann/qtls,v0.3.2,h1:O7awy4bHEzSX/K3h+fZig3/Vo03s/RxlxgsAk9sYamI=,ff5245b3d5a1e65754d4a740e09ff02c738e9043c6e2bc02c59d5851c1fc1e2d +github.com/martini-contrib/render,v0.0.0-20150707142108-ec18f8345a11,h1:YFh+sjyJTMQSYjKwM4dFKhJPJC/wfo98tPUc17HdoYw=,2edd7f64b2f1f053f86a51856cd0f02b1f762af61a458a2e282dab76ad093d70 +github.com/martinlindhe/unit,v0.0.0-20190604142932-3b6be53d49af,h1:4bEyeobv/dO+lT1Qp1hr+/DcNjy6Ob8BDaSrxX6nQsQ=,ee5001e908fb9997e5918c909dcb0cc078f1a91719f4df3d62243d5e88dc07c6 +github.com/martinusso/go-docs,v0.0.0-20161215163720-81905d575a58,h1:VmcrkkMjTdCGOsuuMnn7P2X9dGh3meUNASx6kHIpe7A=,70ad43a3172287882f904657184af77133a578c6d1ec968c5ce3e27259100a06 +github.com/maruel/panicparse,v0.0.0-20171209025017-c0182c169410,h1:1ROIrlLvFoHKX+i48KdRauq21irSOXPyfQw4T/PrINY=,5fd98b2b0a8346ffcba1858775e93db0582ead6b3329b974595d5ab448c95f28 +github.com/maruel/ut,v1.0.0,h1:Tg5f5waOijrohsOwnMlr1bZmv+wHEbuMEacNBE8kQ7k=,a7c90a5020071c66efe2ccae7f3859c60f17840d4ae2972ee9c9a38ae071fb3e +github.com/masterzen/azure-sdk-for-go,v0.0.0-20161014135628-ee4f0065d00c,h1:FMUOnVGy8nWk1cvlMCAoftRItQGMxI0vzJ3dQjeZTCE=,de40198aee773ecaf502d59b8f29fe5d1564fb9a68900b6bfed2369e169e193a +github.com/masterzen/simplexml,v0.0.0-20190410153822-31eea3082786,h1:2ZKn+w/BJeL43sCxI2jhPLRv73oVVOjEKZjKkflyqxg=,a9e4548a5c7e098c89273c470e4e9d18cb0beb530629f2e512f6f105fd9cbc88 +github.com/masterzen/winrm,v0.0.0-20190223112901-5e5c9a7fe54b,h1:/1RFh2SLCJ+tEnT73+Fh5R2AO89sQqs8ba7o+hx1G0Y=,28f8e69baadf7f220842a5cd4269ccebdb175a835c0b43819a6b15670ae5403c +github.com/matryer/moq,v0.0.0-20190312154309-6cfb0558e1bd,h1:HvFwW+cm9bCbZ/+vuGNq7CRWXql8c0y8nGeYpqmpvmk=,b9fb2bc3d0894dfaa3cc4298f49c97346ccb66f2f0e6911f4f224ffc9acc3972 +github.com/matryer/try,v0.0.0-20161228173917-9ac251b645a2,h1:JAEbJn3j/FrhdWA9jW8B5ajsLIjeuEHLi8xE4fk997o=,f1afa36a4bd0bf09a1290f3afef954058e334d6b275aae6a591d8dad276f5e2f +github.com/mattbaird/elastigo,v0.0.0-20170123220020-2fe47fd29e4b,h1:v29yPGHhOqw7VHEnTeQFAth3SsBrmwc8JfuhNY0G34k=,f6a94deccbe4d008d265bb4b5cbaee7893e5994a82bc49b44438675a0ca8d8f3 +github.com/mattbaird/jsonpatch,v0.0.0-20171005235357-81af80346b1a,h1:+J2gw7Bw77w/fbK7wnNJJDKmw1IbWft2Ul5BzrG1Qm8=,55abaf4d26d8ad7f81c230f38a6e482b6b416d9b5777a6c3b1a5c140465a5235 +github.com/mattermost/mattermost-server,v5.11.1+incompatible,h1:LPzKY0+2Tic/ik67qIg6VrydRCgxNXZQXOeaiJ2rMBY=,1f601d79e647a248f9e711891e015b1709f3af37e6a45d5e97827f074c40398e +github.com/mattn/go-colorable,v0.1.4,h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=,02ad42bc54adf7c52030b6ab903277af8fb7163aad4f7f8d8703ecfdc62597de +github.com/mattn/go-ieproxy,v0.0.0-20190805055040-f9202b1cfdeb,h1:hXqqXzQtJbENrsb+rsIqkVqcg4FUJL0SQFGw08Dgivw=,5914c18852b0be63008f7ccaf1bd3a8214a82fae78f8afe2e7d774ff96a410ff +github.com/mattn/go-isatty,v0.0.10,h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=,dca893515dccb58e21f9b08837470c5512e0ecd1275767ed996912bb46933c91 +github.com/mattn/go-mastodon,v0.0.5-0.20190517015615-8f6192e26b66,h1:TbnaLJhq+sFuqZ1wxdfF5Uk7A2J41iOobCCFnLI+RPE=,b290b77b6e5556bba70cf18ac815c13ed9a80ffa4cb03627d73187e99cd15d42 +github.com/mattn/go-oci8,v0.0.0-20190320171441-14ba190cf52d,h1:m+dSK37rFf2fqppZhg15yI2IwC9BtucBiRwSDm9VL8g=,eb3bd1fa93c8a341ad43176cb6e4d8540d7a91d3edd7eb98c1388cf2f4c3515c +github.com/mattn/go-runewidth,v0.0.5,h1:jrGtp51JOKTWgvLFzfG6OtZOJcK2sEnzc/U+zw7TtbA=,3b34033634b059bfa31ac552d2150d8c0d6e530dd1c0ead2ce0806e1d7cc754a +github.com/mattn/go-shellwords,v1.0.6,h1:9Jok5pILi5S1MnDirGVTufYGtksUs/V2BWUP3ZkeUUI=,374285b205f0659ab4be3f8ce346cfd3291cd42f47b12bda15174c42c462b1a6 +github.com/mattn/go-sqlite3,v1.11.0,h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q=,7fec79c50206f5faa759d1b64500fb0d082e22ef23f10e2d4cbce24e4fc2d5c1 +github.com/mattn/go-tty,v0.0.0-20190424173100-523744f04859,h1:smQbSzmT3EHl4EUwtFwFGmGIpiYgIiiPeVv1uguIQEE=,76f28f59927667d2d750fa6ffdefeb3f0c41034cb593e4545a206995c76c619f +github.com/mattn/go-xmpp,v0.0.0-20190124093244-6093f50721ed,h1:A1hEQg5M0b3Wg06pm3q/B0wdZsPjVQ/a2IgauQ8wCZo=,2c39b78184ea27890be56f593353c8fe6b3d6efa53db20e800ff8793bc665199 +github.com/mattn/go-zglob,v0.0.1,h1:xsEx/XUoVlI6yXjqBK062zYhRTZltCNmYPx6v+8DNaY=,8decd6c1916188ab4fa1001e3da3f22d7c9fb6218215fd25053c901979930feb +github.com/mattn/goveralls,v0.0.2,h1:7eJB6EqsPhRVxvwEXGnqdO2sJI0PTsrWoTMXEk9/OQc=,3df5b7ebfb61edd9a098895aae7009a927a2fe91f73f38f48467a7b9e6c006f7 +github.com/matttproud/golang_protobuf_extensions,v1.0.1,h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=,e64dc58023f4b8c4472d05a44f2719b84d6c2cc364cc682820c9f72b233c9cdc +github.com/maxbrunsfeld/counterfeiter/v6,v6.2.2,h1:g+4J5sZg6osfvEfkRZxJ1em0VT95/UOZgi/l7zi1/oE=,c185793a7e749ff2557f4557628f5b5d8d9edbf72ca6bd2cb94503f4817c01d2 +github.com/mcuadros/go-version,v0.0.0-20190830083331-035f6764e8d2,h1:YocNLcTBdEdvY3iDK6jfWXvEaM5OCKkjxPKoJRdB3Gg=,ff2364bda8605ad94051c576ffa601e1a9aedabc8a1fda588eb04c3371a845ea +github.com/mdlayher/dhcp6,v0.0.0-20190311162359-2a67805d7d0b,h1:r12blE3QRYlW1WBiBEe007O6NrTb/P54OjR5d4WLEGk=,fba7b2f01311e2d41bb4ebe15409d4e0a605a79d2f05156bb0f4adbc20f557bc +github.com/mdlayher/netlink,v0.0.0-20191009155606-de872b0d824b,h1:W3er9pI7mt2gOqOWzwvx20iJ8Akiqz1mUMTxU6wdvl8=,9be201b393fe866f855e5ebb20ef33e86a0e6a99b6b76209531b93615fcbac7c +github.com/mesos/mesos-go,v0.0.10,h1:+M/7Zlkvw4MolkLvXHfj6hkDsLLHOOU54CmOkOUaNBc=,f18d5601dc6a5234b9c2d65cb96b8d30ab877e3117dd52dd47e31a353ed887d1 +github.com/mgutz/ansi,v0.0.0-20170206155736-9520e82c474b,h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=,d7c0ff88c53dfca384bb82108a6e5fdc9e11b358d68b67144ff6a285be20a16a +github.com/mgutz/logxi,v0.0.0-20161027140823-aebf8a7d67ab,h1:n8cgpHzJ5+EDyDri2s/GC7a9+qK3/YEGnBsd0uS/8PY=,0a7837d5246591fe1fd341e48a72786c0b61fff8d3ebfea0e9c789176c3e75d5 +github.com/mgutz/str,v1.2.0,h1:4IzWSdIz9qPQWLfKZ0rJcV0jcUDpxvP4JVZ4GXQyvSw=,bf640c2048957f183e72664ff08745ae3d016f64072a5967f5269ccb5fc4b318 +github.com/mholt/archiver,v3.1.1+incompatible,h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU=,6cbad83ecd8a2bcb013fb1ac163a6551e6f948b103df9b258788612c72551184 +github.com/mholt/certmagic,v0.7.5,h1:1ZGHwUI4+zg1S17tPUj5Xxb9Q1ghTjLcUZE5G4yV5SM=,a85c14ecbb135636c8e4701a25b8d2884f091d948269c0a3187918af83e11db3 +github.com/michaelklishin/rabbit-hole,v1.5.0,h1:Bex27BiFDsijCM9D0ezSHqyy0kehpYHuNKaPqq/a4RM=,1fdb62e985c4b1be24632875668720ed687455ece54cb2c77079488784e06e69 +github.com/micro-plat/gmq,v1.0.1,h1:ai1PiCEfgBmiqzmZ4iWE3l2Vuz7rOTWOakqRWqi/Hgo=,63c4a02b87b31c0f5cfcdfee5df2fa05e77eeaa2aab93b0ef217c57f6b37b38a +github.com/micro-plat/lib4go,v0.2.1,h1:NBTIq0DvpRzTChnYShBagPmsYM4k1NgvkE8OYhgMDt8=,ae1056cc76eee3fccb14b0d8723b6444d8f31d2575a0caa1d3723bc54b91496b +github.com/micro/cli,v0.2.0,h1:ut3rV5JWqZjsXIa2MvGF+qMUP8DAUTvHX9Br5gO4afA=,09e532e4616aa7827d1a1f249bc80ebb01fe8c63978f4b14605246c6be596b82 +github.com/micro/go-log,v0.1.0,h1:szYSR+yyTsomZM2jyinJC5562DlqffSjHmTZFaeZ2vY=,5ec9ba1cfb781edd3695dc9c28afb520cced5e1cf7eabb5faafd4bd8db6953ea +github.com/micro/go-micro,v1.14.0,h1:lptn9DBbsNCB3RC3PMwxTJGqCUgU8Rf23nAMaRuOcOA=,2278cfa86f7bf97df81ea79535127cf87bf03aba29e7603f2feeb48b2d1a3334 +github.com/micro/go-rcache,v0.2.0,h1:g51QJW+lj+dAOXwRlYNZPQQ8ueHLptgoUzZE3iRwJMg=,fa96add40dac8fb14cf08f7a8c96d05c902da40b27b2c4e586cf3304e4ef6533 +github.com/micro/h2c,v1.0.0,h1:ejw6MS5+WaUoMHRtqkVCCrrVzLMzOFEH52rEyd8Fl2I=,6fea0303cbaa2bc6c45098ce5ad0ae2aa7f9c54ce2ff90160549756f8c7a2b07 +github.com/micro/mdns,v0.3.0,h1:bYycYe+98AXR3s8Nq5qvt6C573uFTDPIYzJemWON0QE=,a40ecbd32a2170698f0f49f8961b39e88e7c3e958546a401a59653231b51f1b2 +github.com/micro/micro,v1.14.0,h1:Uol1+Yg5frzneACpzoHEDsyNTN+/+yLrlGMuxR3RVRQ=,0fd330788ad610cc2cb3eb2224f1ca403d9888ad40e78628f250c885373d739c +github.com/micro/util,v0.2.0,h1:6u0cPj1TeixEk5cAR9jbcVRUWDQsmCaZvDBiM3zFZuA=,3e61d5232a3a91d521ade483ab64b53a7b8760d0635978d72b4920eba52f8f79 +github.com/microcosm-cc/bluemonday,v1.0.2,h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s=,9cfac37098da75ab1c278740e8f0f7741891d8843e14afb256574596ad786f83 +github.com/miekg/dns,v1.1.22,h1:Jm64b3bO9kP43ddLjL2EY3Io6bmy1qGb9Xxz6TqS6rc=,54f1f62de314150df163bbe1de91acc922cdce70c5c8a43dfeb7f4af24711d38 +github.com/miekg/mmark,v1.3.6,h1:t47x5vThdwgLJzofNsbsAl7gmIiJ7kbDQN5BxwBmwvY=,8d1b05ee1c0a28093c678af2ed9d0aac9dfc30dce728ccd21fe1506762b54cee +github.com/mindprince/gonvml,v0.0.0-20190828220739-9ebdce4bb989,h1:PS1dLCGtD8bb9RPKJrc8bS7qHL6JnW1CZvwzH9dPoUs=,6702f94187c4e2994ffbdc318c94a04d4bc67081a402e968a2c362a74c81263f +github.com/minio/blake2b-simd,v0.0.0-20160723061019-3f5f724cb5b1,h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=,ab10edfe994b513e2d03cdd8122b352f31a1eb246fe884617b3f2f6195a3ca0c +github.com/minio/cli,v1.22.0,h1:VTQm7lmXm3quxO917X3p+el1l0Ca5X3S4PM2ruUYO68=,33533a4e0a2b1a698d0f899cb5b84d9fc199e7723b971d1408e4b5ee797c9a50 +github.com/minio/dsync,v0.0.0-20180124070302-439a0961af70,h1:pRHQdPOlUhelWqNUF3icFrBSC6VYH1hvF6HigVfgMoI=,850e5b400afc4301a1860debf934c5e8e67565d4937ac45f9a37132b31a09941 +github.com/minio/highwayhash,v0.0.0-20180501080913-85fc8a2dacad,h1:L+8skVz2lusCbtlalLXmJp+TK8XaGAsZ3utSC3k5Jc0=,7393dfe736668f9ab98fcf2d264f9bd20bbf4f98538f02ff15df9604f747cdb1 +github.com/minio/lsync,v0.0.0-20180328070428-f332c3883f63,h1:utJHim4C0K4CmD+Qgod/tgHvo7QNOlH6HN5O8QUvPEI=,417c4bdd4fc5d50da2d81e8890b03af4b80ce9fbd5e4c196731a3d76a09913c1 +github.com/minio/mc,v0.0.0-20180926130011-a215fbb71884,h1:co3kRW9cEI65yolYtcLcNxp2a9yk5T/eEt7gw14tJVs=,37300de5179e1085559c6f317b331d261cc4508ba0e4febbd93cbbfef42d7fc9 +github.com/minio/minio,v0.0.0-20180508161510-54cd29b51c38,h1:F7p0ZU9AQuxlA6SWwhXr0H/rYrA9fOiBk2OzOj7GtfM=,6421e5cf72b35a2948e5edd2b189f37ad1896b8637d5b9bcf7cd40b7ab63dfd4 +github.com/minio/minio-go,v6.0.14+incompatible,h1:fnV+GD28LeqdN6vT2XdGKW8Qe/IfjJDswNVuni6km9o=,3bc396d5e1c0c6f3497743140eaf16ebb97c5f1ca815ba12c4f431e804fb737d +github.com/minio/minio-go/v6,v6.0.27-0.20190529152532-de69c0e465ed,h1:g3DRJpu22jEjs14fSeJ7Crn9vdreiRsn4RtrEsXH/6A=,34d85b6b915ef5876f9c262f260583fabec147c37dcb82e1f42374dd088b9096 +github.com/minio/sha256-simd,v0.1.1,h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU=,0ecfa6532265e139d5d9406c0a803c7ef45b1d8d0f0c1b1d55f7b81969294bfc +github.com/minio/sio,v0.0.0-20180327104954-6a41828a60f0,h1:ys4bbOlPvaUBlA0byjm6TqydsXZu614ZIUTfF+4MRY0=,6c46bc4a68353d7b41f6e91eb276c9b21560cad4f75419baaee01764927fb7e8 +github.com/mistifyio/go-zfs,v2.1.1+incompatible,h1:gAMO1HM9xBRONLHHYnu5iFsOJUiJdNZo6oqSENd4eW8=,545764e34ed40473380ea1b08af9f0aea1715d15a0a56fc937e6c3b1bda0d9a3 +github.com/mitchellh/cli,v1.0.0,h1:iGBIsUe3+HZ/AD/Vd7DErOt5sU9fa8Uj7A2s1aggv1Y=,74199f2c2e1735a45e9f5c2ca049d352b0cc73d945823540e54ca9975ce35752 +github.com/mitchellh/colorstring,v0.0.0-20190213212951-d06e56a500db,h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=,d0733284b20567055e374b420373f5508fa47e95204e59e4b8a66834e7e3964d +github.com/mitchellh/copystructure,v1.0.0,h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=,4a2c9eb367a7781864e8edbd3b11781897766bcf6120f77a717d54a575392eee +github.com/mitchellh/go-fs,v0.0.0-20180402234041-7b48fa161ea7,h1:PXPMDtfqV+rZJshQHOiwUFqlqErXaAcuWy+/ZmyRfNc=,21c34fee3df3dc1ddad5e774ddf9e05998061177420709fb68a958c6c113a90b +github.com/mitchellh/go-homedir,v1.1.0,h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=,fffec361fc7e776bb71433560c285ee2982d2c140b8f5bfba0db6033c0ade184 +github.com/mitchellh/go-linereader,v0.0.0-20190213213312-1b945b3263eb,h1:GRiLv4rgyqjqzxbhJke65IYUf4NCOOvrPOJbV/sPxkM=,7b83ef857c71fe8d4937b57923923176dd43c7b1b7632a9779bac411924e87e1 +github.com/mitchellh/go-ps,v0.0.0-20190716172923-621e5597135b,h1:9+ke9YJ9KGWw5ANXK6ozjoK47uI3uNbXv4YVINBnGm8=,06090b6c22dedf800259eb5d9b5f35bfb7b38e22888c0345631dc54366b21f89 +github.com/mitchellh/go-testing-interface,v1.0.0,h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=,255871a399420cd3513b12f50738d290e251637deb23e21a4332192584ecf9c7 +github.com/mitchellh/go-vnc,v0.0.0-20150629162542-723ed9867aed,h1:FI2NIv6fpef6BQl2u3IZX/Cj20tfypRF4yd+uaHOMtI=,2d65ac584e1a17421265fe97f83bd1cbff447ca6a911fa8d91414fa2115e3e74 +github.com/mitchellh/go-wordwrap,v1.0.0,h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=,9ea185f97dfe616da351b63b229a5a212b14ac0e23bd3f943e39590eadb38031 +github.com/mitchellh/gox,v1.0.1,h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI=,30a69e17ba5cafe6f1ac436bcc99368a5a34f0a0763926d2c6780a781f8e9e95 +github.com/mitchellh/hashstructure,v1.0.0,h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9dGS02Q3Y=,3b79b07860631d05645ea3f54830b7e1997dbcf477e84a8adfe4979be3abdfde +github.com/mitchellh/iochan,v1.0.0,h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=,f3eede01adb24c22945bf71b4f84ae25e3744a12b9d8bd7c016705adc0d778b8 +github.com/mitchellh/mapstructure,v1.1.2,h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=,cd86d8586cbc333de28f6a46989069487877fae437df4c2cc417668d203c7305 +github.com/mitchellh/panicwrap,v0.0.0-20190213213626-17011010aaa4,h1:jw9tsdJ1FQmUkyTXdIF/nByTX+mMnnp16glnvGZMsC4=,b9ab07bbacf733cc24f9f7f53eec19f9bf999cbb35180ad0b615fe437640de6e +github.com/mitchellh/pointerstructure,v0.0.0-20190430161007-f252a8fd71c8,h1:1CO5wil3HuiVLrUQ2ovSTO+6AfNOA5EMkHHVyHE9IwA=,658a3e14e4983f3c8a04c8da4a56d4d8a86e2b4fcaa6b1eefab150efcd742848 +github.com/mitchellh/prefixedio,v0.0.0-20190213213902-5733675afd51,h1:eD92Am0Qf3rqhsOeA1zwBHSfRkoHrt4o6uORamdmJP8=,d3209d88b3b5b05ecd48f469bc16811666f786685c49273664a5496d5dd69018 +github.com/mitchellh/reflectwalk,v1.0.1,h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE=,bf1d4540bf05ea244e65fca3e9f859d8129c381adaeebe7f22703959aadc4210 +github.com/mjibson/esc,v0.2.0,h1:k96hdaR9Z+nMcnDwNrOvhdBqtjyMrbVyxLpsRCdP2mA=,9f090786bd43dddb5c0d798b449d5e8aede4cb7d106f56dcac0aebd8fd1929cc +github.com/mndrix/ps,v0.0.0-20131111202200-33ddf69629c1,h1:kCroTjOY+wyp+iHA2lZOV5aJ6WfBVjGnW8bCYmXmLPo=,30b12b7a2467d4a1aa64aa31c715cb45d570d36e31ae70719101d686363d2685 +github.com/mndrix/tap-go,v0.0.0-20171203230836-629fa407e90b,h1:Ga1nclDSe8gOw37MVLMhfu2QKWtD6gvtQ298zsKVh8g=,c6f65bd8d977e53fa083d9d0309cffb0dbfaaae69a5a64a352fb2f7d079ce73d +github.com/modern-go/concurrent,v0.0.0-20180306012644-bacd9c7ef1dd,h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=,91ef49599bec459869d94ff3dec128871ab66bd2dfa61041f1e1169f9b4a8073 +github.com/modern-go/reflect2,v1.0.1,h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=,6af8268206d037428a4197bd421bbe5399c19450ef53ae8309a083f34fb7ac05 +github.com/mohae/deepcopy,v0.0.0-20170929034955-c48cc78d4826,h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=,41ba726508a213f4af89e7d58937263ff778e352d591edd422d3a3dc3272585c +github.com/mongodb/grip,v0.0.0-20191008181606-ee248dc03622,h1:pPoJByX3B56ydhWGUMard1QQ2skLNTw/s1W5VuLLAtA=,08fcfea928382f428dc1fceeada1c264e7f6dc7256dbe05c5c0ba41dca16a42c +github.com/monoculum/formam,v0.0.0-20190830100315-7ff9597b1407,h1:ZU5O9BawmEx9Mu1lxn9NLIwO9DrqRfjE+HWKU+e9GKQ=,5a04e3907fb1008c1e6640e8a0e9394c752aab4ebf7e3be01cd3ee55c2659121 +github.com/montanaflynn/stats,v0.5.0,h1:2EkzeTSqBB4V4bJwWrt5gIIrZmpJBcoIRGS2kWLgzmk=,05527945351f54f4e8c48666bce277fbace34026eed22ac7d88a50a6730767f1 +github.com/morikuni/aec,v1.0.0,h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=,c14eeff6945b854edd8b91a83ac760fbd95068f33dc17d102c18f2e8e86bcced +github.com/moul/anonuuid,v0.0.0-20160222162117-609b752a95ef,h1:E/seV1Rtsnr2juBw1Dfz4iDPT3/5s1H/BATx+ePmSyo=,ec103e75b93231b5b858a2fc9985da39d6b7c35644a689a20e60f3a6ad6b1396 +github.com/moul/gotty-client,v0.0.0-20180327180212-b26a57ebc215,h1:y6FZWUBBt1iPmJyGbGza3ncvVBMKzgd32oFChRZR7Do=,265c4cbad4789e267f283b9012ad174c89e378e59ad9c64ac28729402eb60afe +github.com/moul/http2curl,v0.0.0-20161031194548-4e24498b31db,h1:eZgFHVkk9uOTaOQLC6tgjkzdp7Ays8eEVecBcfHZlJQ=,2ff4e19b14d84f6d181afc79f28668c6171d6dea79c43a1918c0428a265137c1 +github.com/mozilla-services/heka,v0.10.0,h1:w+y6RPJkU6ZKeNbG1VvK9aSqJm0sru5TYcwOj6ejv8U=,f325891304f9acc654944d9a2297b8816a0a86440b2f035c4996ec38fcfa0eed +github.com/mozillazg/go-cos,v0.12.0,h1:b9hUd5HjrDe10BUfkyiLYI1+z4M2kAgKasktszx9pO4=,5376eaf13e10fed6d73b713fbabc4a159d204239579120c410ea74de33dd6d71 +github.com/mozillazg/go-httpheader,v0.2.1,h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ=,50b7a36360fc1ec1a85fd40fe45f8db02fc734fc2af0514a60a068f0a2708122 +github.com/mozillazg/go-unidecode,v0.1.1,h1:uiRy1s4TUqLbcROUrnCN/V85Jlli2AmDF6EeAXOeMHE=,812d3bc9f03cb6a8552bfadd9e0d1b44a57807a3af2e8667a42861510bb2b20c +github.com/mpvl/unique,v0.0.0-20150818121801-cbe035fff7de,h1:D5x39vF5KCwKQaw+OC9ZPiLVHXz3UFw2+psEX+gYcto=,af2bcc8a61a6881e0703afee2217dd1e75c8b34f4e49947c0d7f6e87af574e0e +github.com/mr-tron/base58,v1.1.2,h1:ZEw4I2EgPKDJ2iEw0cNmLB3ROrEmkOtXIkaG7wZg+78=,c2b362db55d8266ce02a161b7f73cad646432d2dae98511385b88481380c4e86 +github.com/mreiferson/go-httpclient,v0.0.0-20160630210159-31f0106b4474,h1:oKIteTqeSpenyTrOVj5zkiyCaflLa8B+CD0324otT+o=,e94cbe43c052831323c59ff186c830ea2e271065f7f8b2794ade7aaf88a37a85 +github.com/mrjones/oauth,v0.0.0-20180629183705-f4e24b6d100c,h1:3wkDRdxK92dF+c1ke2dtj7ZzemFWBHB9plnJOtlwdFA=,4c1fef02b34241008ba6bc33fb5d01b4cfb3b7e7544fb7f70823fe74b9b21362 +github.com/mrunalp/fileutils,v0.0.0-20171103030105-7d4729fb3618,h1:7InQ7/zrOh6SlFjaXFubv0xX0HsuC9qJsdqm7bNQpYM=,c32d691ce15012ba21fbe69db3558df0c97326426c14ef747b8a1e02652ca7b3 +github.com/mschoch/smat,v0.0.0-20160514031455-90eadee771ae,h1:VeRdUYdCw49yizlSbMEn2SZ+gT+3IUKx8BqxyQdz+BY=,488e193897c7d8e3b3758cbeb8a5bc1b58b9619f3f14288a2ea9e0baa5ed9b3e +github.com/msteinert/pam,v0.0.0-20151204160544-02ccfbfaf0cc,h1:z1PgdCCmYYVL0BoJTUgmAq1p7ca8fzYIPsNyfsN3xAU=,315d911c41d88a22bf8831b174bbd15310bc403626507095f98b9780ddcf9174 +github.com/muesli/smartcrop,v0.0.0-20180228075044-f6ebaa786a12,h1:l0X/8IDy2UoK+oXcQFMRSIOcyuYb5iEPytPGplnM41Y=,5857e4d0ed238d8c6f8f41294b98771f1c21874a80ea5f2e75b4a49cbcf1d3e0 +github.com/multiformats/go-base32,v0.0.3,h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI=,658875e4980370db6180f99835b3a48158a697eef69e7c3eb86b0b4f5c1c19ed +github.com/multiformats/go-multiaddr,v0.1.1,h1:rVAztJYMhCQ7vEFr8FvxW3mS+HF2eY/oPbOMeS0ZDnE=,ba4849fc68453c3e812e850f40e6d5acef671060ed79f203c2d179d395d20fc5 +github.com/multiformats/go-multiaddr-dns,v0.0.2,h1:/Bbsgsy3R6e3jf2qBahzNHzww6usYaZ0NhNH3sqdFS8=,219f855f485aa198d36305f2f43012a73bd40f15caa3e606324cee9f117e5b89 +github.com/multiformats/go-multiaddr-fmt,v0.1.0,h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E=,d83537dc1f83185dfb60b190ea4b3c7b05c552a75ad7cfaddd0b987c00ff0cff +github.com/multiformats/go-multiaddr-net,v0.1.1,h1:jFFKUuXTXv+3ARyHZi3XUqQO+YWMKgBdhEvuGRfnL6s=,241c47d621bcb9a40d33284f407a7fdf458cb3f87ef02db68735cc6b9002afed +github.com/multiformats/go-multibase,v0.0.1,h1:PN9/v21eLywrFWdFNsFKaU04kLJzuYzmrJR+ubhT9qA=,ed39145efcf5e8c99deaa183071aed246239730f5781b291bad7de5d1fc12d81 +github.com/multiformats/go-multihash,v0.0.8,h1:wrYcW5yxSi3dU07n5jnuS5PrNwyHy0zRHGVoUugWvXg=,44fae6e8771331f54f267d9440a9d520e7daeb91817ff61e26b8494099ae046a +github.com/multiformats/go-multistream,v0.1.0,h1:UpO6jrsjqs46mqAK3n6wKRYFhugss9ArzbyUzU+4wkQ=,f720be6e29845f0a41c1241a24f19c08adf762f9e7e972b4096416776c603b15 +github.com/munnerz/goautoneg,v0.0.0-20191010083416-a7dc8b61c822,h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=,3d7ce17916779890be02ea6b3dd6345c3c30c1df502ad9d8b5b9b310e636afd9 +github.com/mwitkow/go-conntrack,v0.0.0-20190716064945-2f068394615f,h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=,d6fc513490d5c73e3f64ede3cf18ba973a4f8ef4c39c9816cc6080e39c8c480a +github.com/mwitkow/go-grpc-middleware,v1.0.0,h1:XraEe8LhUuB33YeV4NWfLh2KUZicskSZ2lMhVRnDvTQ=,074f46f92d7a0043c5b283f1af224123cc48e21f96b259e62f77b6da72240812 +github.com/mxk/go-flowrate,v0.0.0-20140419014527-cca7078d478f,h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=,bd0701ef9115469a661c07a3e9c2e572114126eb2d098b01eda34ebf62548492 +github.com/myesui/uuid,v1.0.0,h1:xCBmH4l5KuvLYc5L7AS7SZg9/jKdIFubM7OVoLqaQUI=,3055c4b167daeb9984ccd7c8eeba154e3d84afa6fdf06a3151280ef120d1633d +github.com/myitcv/gobin,v0.0.8,h1:hQORun03Mlnm8yp/OgKX8UYSIVZQ8ebTWf3aahY1u+s=,015311e9db646cb9e5f63a0586c466c9eb5bc5f45661282644f8a5b549607e72 +github.com/myitcv/vbash,v0.0.2,h1:8R+91eSlfcgoRjEbnUgvbXYOmfh+p0+7i5klFOM5VMA=,08dcf62b94843e7fd115cd0605158d948fb361ca8c958db1958c5d2feef9c2d1 +github.com/namedotcom/go,v0.0.0-20180403034216-08470befbe04,h1:o6uBwrhM5C8Ll3MAAxrQxRHEu7FkapwTuI2WmL1rw4g=,0c6ea2c994e982c25e44ccba2ead1a9655cd2f253986eedb73253c30ad21b42f +github.com/naoina/go-stringutil,v0.1.0,h1:rCUeRUHjBjGTSHl0VC00jUPLz8/F9dDzYI70Hzifhks=,4cfea6f0ebfecb5e6297f8a6eee0e9ef9fe254883eb75dd6179133995a219c58 +github.com/naoina/toml,v0.1.1,h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=,8e34d510563d9e8b3f2dbdf0927bf5108b669144bdbe2fda4fcb44e7e2e55268 +github.com/natefinch/lumberjack,v2.0.0+incompatible,h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=,1f6e7c9e0b915c45151d8780a8711426b19d16d04c9cf0e7995b29035d6b500f +github.com/nats-io/gnatsd,v1.3.0,h1:+5d80klu3QaJgNbdavVBjWJP7cHd11U2CLnRTFM9ICI=,85fa90b3eaef17698734d398a9939b8bb94df1b9f35bc92c8d31cb7a349c1e97 +github.com/nats-io/go-nats,v1.6.0,h1:FznPwMfrVwGnSCh7JTXyJDRW0TIkD4Tr+M1LPJt9T70=,8c63be6f10479802a40c66c0999f724e492bcb9863d5517038c6472e585a76aa +github.com/nats-io/go-nats-streaming,v0.4.2,h1:e7Fs4yxvFTs8N5xKFoJyw0sVW2heJwYvrUWfdf9VQlE=,62dd1d6ba18f3b7686766116e3beaaf9f62b89b58a6efb0b8f1ad04d3ddfb026 +github.com/nats-io/jwt,v0.3.0,h1:xdnzwFETV++jNc4W1mw//qFyJGb2ABOombmZJQS4+Qo=,e131314c7cf6a714ec10ca3b6f95f8af6a41f5cdaf72a364f7c71b33e97314db +github.com/nats-io/nats,v1.6.0,h1:U5b2apHOTZlUou+NGfCRWG4ZEeivbt2hpsZO4kHKIVU=,12cc70ed3477472d110d4b4bc109fbe20218e8199629669ad5f617c199fbf9d2 +github.com/nats-io/nats-server/v2,v2.1.0,h1:Yi0+ZhRPtPAGeIxFn5erIeJIV9wXA+JznfSxK621Fbk=,a5897b8f5302ae38894de2c240f31d33ab7b2f3d4e88a2c212fc9b31f2d4f444 +github.com/nats-io/nats-streaming-server,v0.12.2,h1:EpyLfUBZgwu5c0mdSSytQsapm615AyitPssq7jgafdw=,48605f61f74903ba1322f11aa17806b57f71cebf2557b7dd8620d4193abc868d +github.com/nats-io/nats.go,v1.9.1,h1:ik3HbLhZ0YABLto7iX80pZLPw/6dx3T+++MZJwLnMrQ=,34a735d158d70685faad1fc3153f08da0ddc21c0ae42f6a0cb09430d638364b2 +github.com/nats-io/nkeys,v0.1.0,h1:qMd4+pRHgdr1nAClu+2h/2a5F2TmKcCzjCDazVgRoX4=,dbc82abacf752e532ffd67db230a97f52a5f92070b04b4028cb79534d2ab0ef6 +github.com/nats-io/nuid,v1.0.1,h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=,809d144fbd16f91651a433e28d2008d339e19dafc450c5995e2ed92f1c17c1f3 +github.com/nats-io/stan.go,v0.5.0,h1:ZaSPMb6jnDXsSlOACynJrUiB3Evleg3ZyyX+rnf3TlQ=,1dcb14e2ef8ad30dd1ee61a63b0a3bfbaa48e9c3d13f69458a149956a14bbab7 +github.com/nbio/st,v0.0.0-20140626010706-e9e8d9816f32,h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=,e6cd27bd360be27d0f7efd3c4c41c4e14e659e60086b0bc4f09fb09cfd02a50d +github.com/ncw/swift,v1.0.49,h1:eQaKIjSt/PXLKfYgzg01nevmO+CMXfXGRhB1gOhDs7E=,b2be24cad8923c9171835547df2d621d2aa2029ceb9fa770d6ecf3bf70c2c029 +github.com/neelance/astrewrite,v0.0.0-20160511093645-99348263ae86,h1:D6paGObi5Wud7xg83MaEFyjxQB1W5bz5d0IFppr+ymk=,815811c2140669e55e99d59d4bdd2fcf4c810610a9d278fd25cc2c3480c002d4 +github.com/neelance/sourcemap,v0.0.0-20151028013722-8c68805598ab,h1:eFXv9Nu1lGbrNbj619aWwZfVF5HBrm9Plte8aNptuTI=,ce5499f29779a604233bb76f36925c3326a8a8f270533df8d3dff1107b7aa066 +github.com/neurosnap/sentences,v1.0.6,h1:iBVUivNtlwGkYsJblWV8GGVFmXzZzak907Ci8aA0VTE=,9dbe86e291937eba92847454650d1c65338527ff89dec5daccb99aaf7e03865b +github.com/newrelic/go-agent,v2.15.0+incompatible,h1:IB0Fy+dClpBq9aEoIrLyQXzU34JyI1xVTanPLB/+jvU=,4c541c5f7b10055c37cf22843edbb9b0fcb06ad3504e8d6eae3d9c37ff3c64c6 +github.com/nf/cr2,v0.0.0-20140528043846-05d46fef4f2f,h1:nyKdx+jcykIdxGNrbgo/TGjdGi99EY9FKBCjYAUS4bU=,665afbe7830424dd9815cae42aa7762b657484686d671f88704257ea7c9736be +github.com/nfnt/resize,v0.0.0-20180221191011-83c6a9932646,h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=,b8e97cb14e5e5ef29d762d2dff890f6279a125990ddf9cb7ae5c4d2a015b109c +github.com/ngaut/pools,v0.0.0-20180318154953-b7bc8c42aac7,h1:7KAv7KMGTTqSmYZtNdcNTgsos+vFzULLwyElndwn+5c=,26342833d7a5b91a52f8451e8e34bc9ffc5069d342666ab0b478628c41a86d44 +github.com/ngaut/sync2,v0.0.0-20141008032647-7a24ed77b2ef,h1:K0Fn+DoFqNqktdZtdV3bPQ/0cuYh2H4rkg0tytX/07k=,2635d6120b6172c190f84b57b5fc878f9158b768b4bd6bd4468bfa98a73061a4 +github.com/nicksnyder/go-i18n,v2.0.2+incompatible,h1:Xt6dluut3s2zBUha8/3sj6atWMQbFioi9OMqUGH9khg=,687be9dc953545d390761e5464e07c38f313d19c1f695f7d7702d954afcf6b66 +github.com/nicolai86/scaleway-sdk,v1.10.2-0.20180628010248-798f60e20bb2,h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s=,a2e992324edd4396f24e0b6a165c4d1057eeefdecdc9f7472b0de8a30f3be729 +github.com/niklasfasching/go-org,v0.1.6,h1:F521WcqRNl8OJumlgAnekZgERaTA2HpfOYYfVEKOeI8=,c938afb1ad7f567524686395c9de66da75220eaa60fe8917c02b97aa1e2cbbb1 +github.com/nkovacs/streamquote,v0.0.0-20170412213628-49af9bddb229,h1:E2B8qYyeSgv5MXpmzZXRNp8IAQ4vjxIjhpAf5hv/tAg=,679a789b4b1409ea81054cb12e5f8441199f5fb17d4a2d3510c51f3aa5f3f0cc +github.com/nlopes/slack,v0.6.0,h1:jt0jxVQGhssx1Ib7naAOZEZcGdtIhTzkP0nopK0AsRA=,048ddfddd4a66407f26b069a65d4d8f3d6d0368adcd52fd5a0dc6d86fe012f47 +github.com/nrdcg/auroradns,v1.0.0,h1:b+NpSqNG6HzMqX2ohGQe4Q/G0WQq8pduWCiZ19vdLY8=,81e3564b38ca27024b6e981a03ae70afcf435d5f8d35a2113321dfd3a220f00b +github.com/nrdcg/goinwx,v0.6.1,h1:AJnjoWPELyCtofhGcmzzcEMFd9YdF2JB/LgutWsWt/s=,8e1e3ea7d38f5b9b21603350d97a583c9108d380f5cc08bf93a4c69d6968dc8a +github.com/nrdcg/namesilo,v0.2.1,h1:kLjCjsufdW/IlC+iSfAqj0iQGgKjlbUUeDJio5Y6eMg=,e20a47d9257fcf7ce95254b14bb84ba290b5f4867e4d63027b669f5a55aaab6c +github.com/nsf/jsondiff,v0.0.0-20160203110537-7de28ed2b6e3,h1:OqFSgO6CJ8heZRAbXLpT+ojX+jnnGij4qZwUz/SJJ9I=,9652618358184592fb7a4657e2c51748cbe0bf5bbf97150a2c6e95ecf65b126b +github.com/nsf/termbox-go,v0.0.0-20190817171036-93860e161317,h1:hhGN4SFXgXo61Q4Sjj/X9sBjyeSa2kdpaOzCO+8EVQw=,a64e374836a25ab74ece4eb5314d79617d8b828bd6d13c654d95bed920c82784 +github.com/nsqio/go-nsq,v1.0.7,h1:O0pIZJYTf+x7cZBA0UMY8WxFG79lYTURmWzAAh48ljY=,5acb7902bf31355fa7d77f507ed42847368834eb378fbf407d82ae3e4211e248 +github.com/nu7hatch/gouuid,v0.0.0-20131221200532-179d4d0c4d8d,h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=,0889a0ac13cfa9f32f986a88a82bb24380070932299131ae7d7180a389d08ca7 +github.com/nullstyle/go-xdr,v0.0.0-20180726165426-f4c839f75077,h1:A804awGqaW7i61y8KnbtHmh3scqbNuTJqcycq3u5ZAU=,0ab4f958f0420027d40b53c98bcb8f3cbe1e106dfb49d3e91415cb1c512a552c +github.com/nutmegdevelopment/sumologic,v0.0.0-20160817160817-42ed9b372fa3,h1:xOEJG5C3e8CvgAYsnkgoSBzCr0No+m++aB6v7A2WScY=,a33916e02e1159304145b621ffdf284120e50f618c684f38776a8bab7ae7b3fe +github.com/nwaples/rardecode,v0.0.0-20171029023500-e06696f847ae,h1:UF9xsJn7AeQ72TCus3eRO1lh08Id3AoF37vl+qigL/w=,5598a02308af3b04418b15854ff940be49cf31ce7238ce23c10409110364d40f +github.com/ogier/pflag,v0.0.1,h1:RW6JSWSu/RkSatfcLtogGfFgpim5p7ARQ10ECk5O750=,c4db0ecff32deb3205c705d72a616bce01e1f6a1948c851d30b52deeec3fbf91 +github.com/oklog/run,v1.0.0,h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=,108d409b7d235d61b82cfb6e1df139501123fcd8fa68fe94ddb024b53335cb48 +github.com/oklog/ulid,v1.3.1,h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=,40e502c064a922d5eb7f2bc2cda9c6a2a929ec0fc76c9aae4db54fb7b6b611ae +github.com/olekukonko/tablewriter,v0.0.1,h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88=,7e5cc8a9b5a51126a0cb46ac96b274d92a8b1cc24b2321832c38d60c0ea4cc9c +github.com/oliamb/cutter,v0.2.2,h1:Lfwkya0HHNU1YLnGv2hTkzHfasrSMkgv4Dn+5rmlk3k=,9174c2374109a7d3aeb2c59b5f4b744ec5f65752aab797f0d50beb26cfc7d857 +github.com/olivere/elastic,v6.2.25+incompatible,h1:X34sPAlSpZVlnuSjOYwbMbiCMU+WKK7YUxrunuNSdG8=,bf3b4cc7ea89a716e91002a31b33f55ec3168ce5ab36ffe5c02ff68d94b9aad5 +github.com/olivere/env,v1.1.0,h1:owp/uwMwhru5668JjMDp8UTG3JGT27GTCk4ufYQfaTw=,f486deab73b3d7866e762e1ad34fe63c88e9ac38f41d811414361fb6490bbb2c +github.com/onsi/ginkgo,v1.10.3,h1:OoxbjfXVZyod1fmWYhI7SEyaD8B00ynP3T+D5GiyHOY=,088314495acb90d1e520519b243f4dbdd17b43469e6fb83bd45d600796856e63 +github.com/onsi/gomega,v1.7.1,h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ=,0a245e719f17cc2bc399aa7c2005cca84f1cfba5373b0c96f5c64673f758a712 +github.com/op/go-logging,v0.0.0-20160315200505-970db520ece7,h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88=,c506eace74028656eb28677a4c162f9c023ce2f9c0207354ba80cca89f11b461 +github.com/openconfig/gnmi,v0.0.0-20190823184014-89b2bf29312c,h1:a380JP+B7xlMbEQOlha1buKhzBPXFqgFXplyWCEIGEY=,f52967c7b194daa57252042f6ccf9d26f8c599a7e13aca26043f948d5139b91a +github.com/openconfig/reference,v0.0.0-20190727015836-8dfd928c9696,h1:yHCGAHg2zMaW8olLrqEt3SAHGcEx2aJPEQWMRCyravY=,040cf32cee7256a08716313dd7ea4f8c44f1d644ae872ecf2dd381c35b12125c +github.com/opencontainers/go-digest,v1.0.0-rc1,h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=,25fd455029e8a1bbe15ed2eeafc67222372c6f305a47b4ec157d8a1a2849c15c +github.com/opencontainers/image-spec,v1.0.1,h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=,ebb2dca711a137fbfb717158b0368792f834000f4308d9ea259d06c6804c677c +github.com/opencontainers/runc,v0.1.1,h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJGY8Y=,aa212163f009190d0f4f3dbe64f71fcda06d7896b67863d7f7b185fee6a68ea6 +github.com/opencontainers/runtime-spec,v1.0.1,h1:wY4pOY8fBdSIvs9+IDHC55thBuEulhzfSgKeC1yFvzQ=,1958458b00ce912425f5c7d2ee836431b296a3f9320d565512d8c96b107fffbf +github.com/opencontainers/runtime-tools,v0.9.0,h1:FYgwVsKRI/H9hU32MJ/4MLOzXWodKK5zsQavY8NPMkU=,53c720dbb7452cfb2fd3945e37c26b5a0140cb1012d35a2b72a5e035f28a32c4 +github.com/opencontainers/selinux,v1.3.0,h1:xsI95WzPZu5exzA6JzkLSfdr/DilzOhCJOqGe5TgR0g=,88286825b32cd46a0469e578f378a185032da2d5b03893623861ef3af59359d8 +github.com/openshift/client-go,v3.9.0+incompatible,h1:13k3Ok0B7TA2hA3bQW2aFqn6y04JaJWdk7ITTyg+Ek0=,661b7f28b4905f1936dd58e373374513d54663ec85aecafede1c7d9c260e9369 +github.com/openshift/library-go,v0.0.0-20191101161407-e7c97b468b83,h1:wwR+laNaFKVGiizoIDL/cAKIZVoKXJ9jbjUoUlq2p5I=,c74f8134013f978ef154d6accf9b4b0c5126941f2d45e6eb223db7098f7ab2a4 +github.com/opentracing-contrib/go-observer,v0.0.0-20170622124052-a52f23424492,h1:lM6RxxfUMrYL/f8bWEUqdXrANWtrL7Nndbm9iFN0DlU=,50023eee1ef04412410f43d8b5dcf3ef481c0fc39067add27799654705fa84b2 +github.com/opentracing-contrib/go-stdlib,v0.0.0-20190519235532-cf7a6c988dc9,h1:QsgXACQhd9QJhEmRumbsMQQvBtmdS0mafoVEBplWXEg=,966cdf6d869ff62c35edf1ea00113465cc9b90f34838c6a6990a1f776e7d1152 +github.com/opentracing/basictracer-go,v1.0.0,h1:YyUAhaEfjoWXclZVJ9sGoNct7j4TVk7lZWlQw5UXuoo=,a908957c8e55b7b036b4761fb64c643806fcb9b59d4e7c6fcd03fca1105a9156 +github.com/opentracing/opentracing-go,v1.1.0,h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=,3e0f42d035019fa037991d340da9677a802f8182792770c38e87906d33e06629 +github.com/openzipkin-contrib/zipkin-go-opentracing,v0.4.4,h1:bzTJRoOZEN7uI1gq594S5HhMYNSud4FKUEwd4aFbsEI=,8a4688f80cd67140aa4edb91506d440ecea4d8ec01634caab5c95991af011c5d +github.com/openzipkin/zipkin-go,v0.2.2,h1:nY8Hti+WKaP0cRsSeQ026wU03QsM762XBeCXBb9NAWI=,dfc610dc52d9299df49172a9e61fcc772d85450b6b6f82e8f43cf23562232a4c +github.com/oracle/oci-go-sdk,v7.0.0+incompatible,h1:oj5ESjXwwkFRdhZSnPlShvLWYdt/IZ65RQxveYM3maA=,941cd26813b22873477f1c6bb86fed929bdc85379d435bd9707d923f57d070dc +github.com/orcaman/concurrent-map,v0.0.0-20190826125027-8c72a8bb44f6,h1:lNCW6THrCKBiJBpz8kbVGjC7MgdCGKwuvBgc7LoD6sw=,ec80830c751199283290a8d398ebf28ca5169e866a70347b39856d2c1178f2cb +github.com/ory/dockertest,v3.3.4+incompatible,h1:VrpM6Gqg7CrPm3bL4Wm1skO+zFWLbh7/Xb5kGEbJRh8=,cbcc7ba21c846d38229aa06a2d7cf35b99ac219eb2694bd9a1ceeac89667e475 +github.com/ory/herodot,v0.6.2,h1:zOb5MsuMn7AH9/Ewc/EK83yqcNViK1m1l3C2UuP3RcA=,caf465ffb73c7537212ba4fd58a4c2c41fe7ca69737404a28e84ceff90c340ea +github.com/otiai10/copy,v0.0.0-20180813032824-7e9a647135a1,h1:A7kMXwDPBTfIVRv2l6XV3U6Su3SzLUzZjxnDDQVZDIY=,67d0e4f6ba369653e30257882fbbb20c28b560bc837e1847a42c48e868f1c81c +github.com/otiai10/curr,v0.0.0-20150429015615-9b4961190c95,h1:+OLn68pqasWca0z5ryit9KGfp3sUsW4Lqg32iRMJyzs=,7cf2143067d9bb3e7d54d2906766bb24c11d76f1bb0b0c5069574e9a0d8ae93d +github.com/otiai10/mint,v1.2.3,h1:PsrRBmrxR68kyNu6YlqYHbNlItc5vOkuS6LBEsNttVA=,0b82a05ca43810c9aa8299ddae1663feeb178d699aeb5242c3bdeb61cb5a54fb +github.com/outscale/osc-go,v0.0.1,h1:hvBtORyu7sWSKW1norGlfIP8C7c2aegI2Vkq75SRPCE=,2a988384c564fdba8b8c496024aafc212140e4b996654be7a92a3b0c7a962632 +github.com/ovh/go-ovh,v0.0.0-20181109152953-ba5adb4cf014,h1:37VE5TYj2m/FLA9SNr4z0+A0JefvTmR60Zwf8XSEV7c=,0fa35e8026a9b3aebd804739f31ffe07e553b84e2b8ea145b2f2ebaa0dd7c08f +github.com/oxtoacart/bpool,v0.0.0-20190530202638-03653db5a59c,h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=,6816ec3a6f197cbee0ba6ddb9ec70958bc28870e59864b24e43da0c858079a1b +github.com/packer-community/winrmcp,v0.0.0-20180921204643-0fd363d6159a,h1:A3QMuteviunoaY/8ex+RKFqwhcZJ/Cf3fCW3IwL2wx4=,4a48fa503853d129e7e32ca81f069b9e09a9e3249739781f61fae70bb02d098b +github.com/packethost/packngo,v0.1.1-0.20180711074735-b9cb5096f54c,h1:vwpFWvAO8DeIZfFeqASzZfsxuWPno9ncAebBEP0N3uE=,6dac4e55c104df58ace636ef31d5dd6173a36747c4fd79299252ba8826127491 +github.com/parnurzeal/gorequest,v0.2.16,h1:T/5x+/4BT+nj+3eSknXmCTnEVGSzFzPGdpqmUVVZXHQ=,cc7b7d56e2e4c3fa0709e0e547875807746ac067b2a5c4b740b3088c1fdf941d +github.com/pascaldekloe/goe,v0.1.0,h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=,37b73886f1eec9b093143e7b03f547b90ab55d8d5c9aa3966e90f9df2d07353c +github.com/patrickmn/go-cache,v2.1.0+incompatible,h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=,d5d1c13e3c9cfeb04a943f656333ec68627dd6ce136af67e2aa5881ad7353c55 +github.com/pborman/uuid,v1.2.0,h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=,b888ff5d33651a1f5f6b8094acc434dd6dc284e2fe5052754a7993cebd539437 +github.com/pelletier/go-buffruneio,v0.2.0,h1:U4t4R6YkofJ5xHm3dJzuRpPZ0mr5MMCoAWooScCR7aA=,70593688607f4d48192776fe257ab9298689267ebcdd7b155bfe40d893735f38 +github.com/pelletier/go-toml,v1.6.0,h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4=,cc6dce19df6c6c30abd67594d17ea6015d1210aa6dd8c6096c6429eec06fdab4 +github.com/peterbourgon/diskv,v2.0.1+incompatible,h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=,1eeff260bd1ad71cd1611078995db99e1c7eba28628e7d6f24c79039536ea1cb +github.com/peterbourgon/g2s,v0.0.0-20170223122336-d4e7ad98afea,h1:sKwxy1H95npauwu8vtF95vG/syrL0p8fSZo/XlDg5gk=,41526f42b4fe3019581ab3745afea18271d7f037eb55a6e9fb3e32fd09ff9b8d +github.com/petergtz/pegomock,v2.7.0+incompatible,h1:42rJ5wIOBAg9OGdkLaPW9PlF/RtqDc5aGl6PcTCXl3o=,dc93e4483e8de4eb429e007aad17348822197ea7a3adde283b7752bc4544dfbb +github.com/peterh/liner,v1.1.0,h1:f+aAedNJA6uk7+6rXsYBnhdo4Xux7ESLe+kcuVUF5os=,5cdc45c19901db8d8295c139bb382d7eea150e8fd96bd26de10384685728a461 +github.com/peterhellberg/link,v1.0.0,h1:mUWkiegowUXEcmlb+ybF75Q/8D2Y0BjZtR8cxoKhaQo=,d320f4204fbe886e1cefc0b677af2bfaba855e9e6556a6e92e43bcd80c3bb7a5 +github.com/petermattis/goid,v0.0.0-20180202154549-b0b1615b78e5,h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=,5134a176e306f9b973ff670a33c7536b59bf4114d83fd94f74c736ff0cc10ef0 +github.com/phayes/freeport,v0.0.0-20180830031419-95f893ade6f2,h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc=,4ac97358de55a9b1ac60f13fdb223c5309a129fb3fb7bf731062f9c095a0796c +github.com/philhofer/fwd,v1.0.0,h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ=,b4e79b1f5fdfe8c44bf6dae3dd593c62862930114411a30968f304084de1d0b3 +github.com/pierrec/lz4,v2.3.0+incompatible,h1:CZzRn4Ut9GbUkHlQ7jqBXeZQV41ZSKWFc302ZU6lUTk=,775487f2be5ddf23034b59bc862cb0d5767155c5e08d1186665d117092ceb50f +github.com/pingcap/check,v0.0.0-20190102082844-67f458068fc8,h1:USx2/E1bX46VG32FIw034Au6seQ2fY9NEILmNh/UlQg=,b8eeddacc35915d8c40b42e9af4db468ed309a506412a767ba6bb03bb7ce4627 +github.com/pingcap/errors,v0.11.4,h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=,df62e548162429501a88d936a3e8330f2379ddfcd4d23c22b78bc1b157e05b97 +github.com/pingcap/gofail,v0.0.0-20181217135706-6a951c1e42c3,h1:04yuCf5NMvLU8rB2m4Qs3rynH7EYpMno3lHkewIOdMo=,444866a53b7429e80a8a16791e39555de8103c7514cd322fe191c902b8071360 +github.com/pingcap/goleveldb,v0.0.0-20171020122428-b9ff6c35079e,h1:P73/4dPCL96rGrobssy1nVy2VaVpNCuLpCbr+FEaTA8=,08ec0ffe5d0d74bdc543695f975316af6a63c17e36644ae56d42e30b0d1f8777 +github.com/pingcap/kvproto,v0.0.0-20191101062931-76b56d6eb466,h1:C5nV9osqA+R/R2fxYxVfqAUlCi3Oo5yJ/JSKDeHSAOk=,0d834c10c217c5de2c9ef79049891a69e73e102c4dbcd130173c3650e96da570 +github.com/pingcap/log,v0.0.0-20191012051959-b742a5d432e9,h1:AJD9pZYm72vMgPcQDww9rkZ1DnWfl0pXV3BOWlkYIjA=,eaece6f27792a39ccff08152050d4eb7905c250bf36877cacdd7e74c79d80472 +github.com/pingcap/parser,v0.0.0-20191101070347-94a5ef60f10b,h1:TLljHrSTC9MCTiUA6nMhV68my/D/FI3VNkUs94Wo3DE=,94e6857f4d2bf653edf4c2881cb8fb6b3abdf9efaec7d1f49159deec77580df2 +github.com/pingcap/pd,v2.1.17+incompatible,h1:mpfJYffRC14jeAfiq0jbHkqXVc8ZGNV0Lr2xG1sJslw=,b75266cd20abe6b1ccbb777a2f71d74dfcf231a06276b602df08bf27a9ea36f1 +github.com/pingcap/tidb-tools,v2.1.4+incompatible,h1:dkB4FMJcSk9GYRB2ICupU/lsTLf4mHLfkBE6fAsLdJ4=,c5c8e2b5c69c21bba2050c75d3a4582eda26308a355557036f058365d4583e5f +github.com/pingcap/tipb,v0.0.0-20191030045153-07a0962bbc64,h1:wUSHIp4dura5/YAepdgDBEdf2zz20MHXyNtMi1TcaDE=,8ac8e775e3d5fd255b7a8f07460f3b19bebb04cb50a3c0f5d6f64cc2fd585177 +github.com/pkg/browser,v0.0.0-20180916011732-0a3d74bf9ce4,h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=,b845f84fbf08bba75401a4eff94c01c9e2c668fa1b43016e835bd60c6a8b4e87 +github.com/pkg/errors,v0.8.1,h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=,4e47d021340b7396a7dee454f527552faf7360a9fc34038b1dc32ba3b5a951d8 +github.com/pkg/profile,v1.3.0,h1:OQIvuDgm00gWVWGTf4m4mCt6W1/0YqU7Ntg0mySWgaI=,5f20c007ac81019900f06cf1e4d451ce8e1d981460e39e04794fbcc60639f851 +github.com/pkg/sftp,v1.10.1,h1:VasscCm72135zRysgrJDKsntdmPN+OuU3+nnHYA9wyc=,4e30f0455865434be7b83d4010ab97667217dafd0017caa651faafa2cc6aed64 +github.com/pkg/term,v0.0.0-20180730021639-bffc007b7fd5,h1:tFwafIEMf0B7NlcxV/zJ6leBIa81D3hgGSgsE5hCkOQ=,165bb00eeab26fe65c64e0e13bc29abc7ea18ac28d288e2218c137cd0bd91d9b +github.com/plaid/plaid-go,v0.0.0-20161222051224-02b6af68061b,h1:Don6I/E8nLCT6gdBi1sKB9hYxkx/24YD7XWwSly8IEo=,bd900ff0acd2968150f60770ab4e870d9f6b92c129a49eac0c9620a8043f901e +github.com/pmezard/go-difflib,v1.0.0,h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=,de04cecc1a4b8d53e4357051026794bcbc54f2e6a260cfac508ce69d5d6457a0 +github.com/polydawn/refmt,v0.0.0-20190408063855-01bf1e26dd14,h1:2m16U/rLwVaRdz7ANkHtHTodP3zTP3N451MADg64x5k=,a92440a944006fd3e0b6f1717fce4c2ea490cf2c4af93b56675216204f138c3a +github.com/portworx/kvdb,v0.0.0-20190911174000-a0108bddd091,h1:DqGiNhvCpvhWW/HJ1naJa0DudtlckvzQ9hEXSsOyv8Y=,d6fa957e1469a1b47ccbebc805034bafc5ed24798a1bef8675f751f9c4ed961e +github.com/portworx/sched-ops,v0.0.0-20191101005636-ded833c86f1e,h1:emQnaLwLEYN3Hner2ekVuZfrcChdN3H3J4Lxu5mPe64=,43ff366e97ff640a34a566c81dd7d63537c2864da85d33b49d5261417cd8d4b0 +github.com/posener/complete,v1.2.1,h1:LrvDIY//XNo65Lq84G/akBuMGlawHvGBABv8f/ZN6DI=,a97f73829e0b71ae7a8f17a4884d5dcbb2c3499d8d3a077c2a8d7c2596f68d37 +github.com/pquerna/cachecontrol,v0.0.0-20180517163645-1555304b9b35,h1:J9b7z+QKAmPf4YLrFg6oQUotqHQeUNWwkvo7jZp1GLU=,0e5185ab4dab1bb2241e9e23e36ebde5713f3fb1e47767c3eb44001b7e17644f +github.com/pquerna/ffjson,v0.0.0-20190930134022-aa0246cd15f7,h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20=,377b4667540f620eae19722b5346f6f1efdea5688f9eedda97f2c659dad131f9 +github.com/pquerna/otp,v1.1.0,h1:q2gMsMuMl3JzneUaAX1MRGxLvOG6bzXV51hivBaStf0=,d46d289853f801387dfc514fd50133de30b684a6af34031b27caa877cbb7f687 +github.com/profitbricks/profitbricks-sdk-go,v4.0.2+incompatible,h1:ZoVHH6voxW9Onzo6z2yLtocVoN6mBocyDoqoyAMHokE=,b0baf185752eb96f8890f3e9adf856b13f5c43b5346387b659e2b1deb1d087c7 +github.com/project-flogo/core,v0.9.3,h1:uZXHR9j1Byqt+x3faNnOqB8NlEfwE2gpCh40iQ+44oA=,d1c43e3bc517bb438a9d313d976e327ba219232418064d439fb20671341832a2 +github.com/projectcalico/libcalico-go,v1.7.3,h1:qcbxAhsq/5zqZqpHE24VqMHfmoBVdXZV0Kf82+5rbqU=,4f638d56eb47ff8e1763f65131050294f7d2c828139276fe86127a803245ae8c +github.com/prometheus/alertmanager,v0.18.0,h1:sPppYFge7kdf9O96KIh3fd093D1xN8JxIp03wW6yAEE=,45e122e7c2ac69577d63844313798060673a28b2e86ec8a0197f330c584b379b +github.com/prometheus/client_golang,v1.2.1,h1:JnMpQc6ppsNgw9QPAGF6Dod479itz7lvlsMzzNayLOI=,174c921fe3e154adddd8e0dc572323dd04901bcad0965de614174241981da57c +github.com/prometheus/client_model,v0.0.0-20190812154241-14fe0d1b01d4,h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=,5d4719be47f4f69ab5bf36a04c75eb078a0f69b43a335f400c2d688ac9e61795 +github.com/prometheus/common,v0.7.0,h1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY=,f2640a94b18b115552df41ee33effa013e10536aca51e09a971d1503a20e186a +github.com/prometheus/procfs,v0.0.5,h1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8=,f45b90c72f8c2e4c84e5314092ee1ccf7d6ace1cc14b2f483c82f7c1e6d0d0d4 +github.com/prometheus/prom2json,v1.1.0,h1:/fEL2DK7EEyHVeGMG4TV+gSS9Sw53yYKt//QRL0IIYE=,166f5f98c62d0b90139947d1464ee747f8143772b9e926c7b51c53a4420380ff +github.com/prometheus/prometheus,v2.5.0+incompatible,h1:7QPitgO2kOFG8ecuRn9O/4L9+10He72rVRJvMXrE9Hg=,ede73f6ccabd60365549986a6c7ae152c1952129006c8ae521c86ff45c4aadcc +github.com/prometheus/tsdb,v0.10.0,h1:If5rVCMTp6W2SiRAQFlbpJNgVlgMEd+U2GZckwK38ic=,34e98f0e9ba55e7290774ee40569737745b395e32811e5940d2ed124a20f927c +github.com/pyinx/gorocket,v0.0.0-20170810024322-78ae1353729f,h1:N1r6pSlez3lLsqaNHbtrHW9ZuzrilETIabr9jPNj3Zs=,dcd920b789a98157bbe1ed7fff249255c1dd4d2fd80f7edc39b3a49fc08db13a +github.com/qor/admin,v0.0.0-20191021122103-f3db8244d2d2,h1:IWw22+hlihdss/qI93QH48jTBUEOD/fsBqj+0z61z/Y=,722e243550878791adcdb3bcea66ab8e7a185637c8a7ad0a752713951aef2a91 +github.com/qor/assetfs,v0.0.0-20170713023933-ff57fdc13a14,h1:JRpyNNSRAkwNHd4WgyPcalTAhxOCh3eFNMoQkxWhjSw=,7fe36875e7e59afd9154f827babbffaa7f67ac54b7790df5a4a4a376c78b2282 +github.com/qor/middlewares,v0.0.0-20170822143614-781378b69454,h1:+WCc1IigwWpWBxMFsmLUsIF230TakGHstDajd8aKDAc=,4c2ed9a2f7b24dfa64464091b2c01ce9fc947524bb834d77aeb9ceaf8610e5fc +github.com/qor/qor,v0.0.0-20191022064424-b3deff729f68,h1:MSbP9P4HnmEyH+uGQAW+V0HoTzlZ9SRq7kdCaRiZEmU=,9053796b8a7afe21483262affaf5b35bac8bf3387e24531448a4833d7b758978 +github.com/qor/render,v1.1.1,h1:DaGaKlf0OzpOB+hJUEiOTbZ40mg+n+LlSJx20/KUfes=,8f957a13173ef1a22d0caeea1cc6d198b064d242676444e00e2f597c405928c9 +github.com/qor/responder,v0.0.0-20171031032654-b6def473574f,h1:sKELSAyL+z5BRHFe97Bx71z197cBEobVJ6rASKTMSqU=,b69784649ec65ec2580d7640af25ec66973d59d82ec5391498cfe4c3076e5f6f +github.com/qor/roles,v0.0.0-20171127035124-d6375609fe3e,h1:F0BNcPJKfubM/+IIILu/GbrH9v2vPZWQ5/StSRKUfK4=,1a35a5480c7169e86025eb19dbcddc13fd00472e6b4ade7574e62c290cf09100 +github.com/qor/session,v0.0.0-20170907035918-8206b0adab70,h1:8l21EEdlZ9R0AA3FbeUAANc5NAx8Y3tn1VKbyAgjYlI=,7c759bc736c4936a602ca1f0ebad9a324d8332ffd342e1e3acd80355180fc858 +github.com/qor/validations,v0.0.0-20171228122639-f364bca61b46,h1:dRlsVUhwD1pwrasuVbNooGQITYjKzmXK5eYoEEvBGQI=,b29360c4a4e9cc8d0ff682d8bf1f446a5d61d5a4f8d3cf2fc6d8cc077e5d810f +github.com/racker/perigee,v0.1.0,h1:8RjBm1YGJKVVjUfO02Uok+npegz8lSSEVqjimDqlFYc=,d43613102ed67445c9fc81b621959b58f827c187189b09cec236c3bac5ce1ccb +github.com/raff/goble,v0.0.0-20190909174656-72afc67d6a99,h1:JtoVdxWJ3tgyqtnPq3r4hJ9aULcIDDnPXBWxZsdmqWU=,ef5dde1af55d451c37ddf13e17ae339d299903cb7e67567fc6d1e69688a789e1 +github.com/rai-project/config,v0.0.0-20190926180509-3bd01e698aad,h1:o0056EwcQBeyaVb2my+T0TvMR5FpEY0CGNgWkbj/xEo=,27c2311ad1fdc185e08f2e1703893482b7d26caf64854ed371bf38f3a9303f92 +github.com/rai-project/godotenv,v0.0.0-20180619160704-a501614c3b8d,h1:reVy+ViZcrx1ILo+L8wa3dGf6hSd4qlY62VqxZxEgWs=,f4d9ecb56f20667fbb09bd5256d0c6b81b9e8cbca8f6476240c5d1800ffb07ed +github.com/rai-project/logger,v0.0.0-20190701163301-49978a80bf96,h1:GeXSVSRfXOBN5XHNA+wq5G+sfq99mhpwn6U5kcGwSeg=,53d7677e7d7dab6b1f83591ec10491301289752e337641403f8413c0749b84d8 +github.com/rai-project/utils,v0.0.0-20180619204045-c582bb171808,h1:cHOS6oMEt8wi93zm5V7cHVnWgOhaAUCpjRDEZHBsckg=,6d43ccc901ad2f19744696f6c3d04ee28b4496cef7fe72ce7eccb89af0d8bfac +github.com/rai-project/vipertags,v0.0.0-20190404224953-d63b0a674aa9,h1:3o86f/tK0DBZdPcUBjzFu1mEZsRCzjSgi5PNHope4AQ=,9aa8cdd1a3369382d28bad0f4581250fbecae51602aa8566cbe68dfadc8f7785 +github.com/raintank/schema,v1.0.0,h1:tK0zKHceZd5nkCUI5Soip1pA2BAvoc4qzloVEsK0y+Q=,9ffc30e882b1cfed3152bab9c8c95e00c984dc0d8895426c95d96a184e09ffe3 +github.com/rainycape/memcache,v0.0.0-20150622160815-1031fa0ce2f2,h1:dq90+d51/hQRaHEqRAsQ1rE/pC1GUS4sc2rCbbFsAIY=,2d42bb018c6b0531f93e2dc862c87374966c64c9a88863612ab5e676a32661fa +github.com/rainycape/unidecode,v0.0.0-20150907023854-cb7f23ec59be,h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=,0ab56010a3ef93c20bb6d8c486e3b447b4004052053e280ea6eabf2a5138bdce +github.com/rakyll/statik,v0.1.6,h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=,58cc0c07f8e9dd17ad5c4e0f89c03d8a3ed420aac0e76b79adf7ebd1d48c5893 +github.com/rcrowley/go-metrics,v0.0.0-20190826022208-cac0b30c2563,h1:dY6ETXrvDG7Sa4vE8ZQG4yqWg6UnOcbqTAahkV813vQ=,22e944d960aec1a1e62e8cc2daaa70abefbbe989dd9c233060ab533de5f6e724 +github.com/remyoudompheng/bigfft,v0.0.0-20190512091148-babf20351dd7,h1:FUL3b97ZY2EPqg2NbXKuMHs5pXJB9hjj1fDHnF2vl28=,73f78c7e36c32822221f9f676b65ebe7ccb92ab6ff221035ace35c184e165c0d +github.com/renier/xmlrpc,v0.0.0-20170708154548-ce4a1a486c03,h1:Wdi9nwnhFNAlseAOekn6B5G/+GMtks9UKbvRU/CMM/o=,f9c07652c6de1aecf5baaa3b93c1e6c23379458e30553400d5f96ac8b3ea85c4 +github.com/renstrom/fuzzysearch,v0.0.0-20160331204855-2d205ac6ec17,h1:4qPms2txLWMLXKzqlnYSulKRS4cS9aYgPtAEpUelQok=,01782a5d1682a72614126da402171253030c0de60485bc18a3e63b07d977c094 +github.com/retr0h/go-gilt,v0.0.0-20190206215556-f73826b37af2,h1:vZ42M1tDiMLtirFA1K5k2QVFhWRqR4BjdSw0IMclzH4=,e7956b01b3ccea41395f1f641a0f9045f214c1075d7ecc25553b72383009274e +github.com/revel/config,v0.21.0,h1:Bw4iXLGAuD/Di2HEhPSOyDywrTlFIXUMbds91lXTtTU=,22842698f6c646b9b89649b432d0f24deae1c5a3779c49819ec99c5db6e4b5a0 +github.com/revel/log15,v2.11.20+incompatible,h1:JkA4tbwIo/UGEMumY50zndKq816RQW3LQ0wIpRc+32U=,28e4263b0320a07dd2ae71ba09aef1f9b4af44258a8c0f1dfb1d63300f93c401 +github.com/revel/pathtree,v0.0.0-20140121041023-41257a1839e9,h1:/d6kfjzjyx19ieWqMOXHSTLFuRxLOH15ZubtcAXExKw=,de658b8de908c9c090343447e66e6bbdfe99656fcfa5889997486b0594c2a719 +github.com/revel/revel,v0.21.0,h1:E6kDJmpJSDb0F8XwbyG5h4ayzpZ+8Wcw2IiPZW/2qSc=,c66570c338f37e95626646909af1086f0bf31d8432fe982d24c415d14bc1dc9c +github.com/rivo/tview,v0.0.0-20191018125527-685bf6da76c2,h1:GVXSfgXOMAeLvFH7IrpY3yYM8H3YekZEFcZ14q9gQXM=,000538d9517bd5f28cfe377e63183f7093043acf8bb913eb493adb29518eb6b8 +github.com/rivo/uniseg,v0.1.0,h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=,cb701df81f36acfbb2627a78662fdcaa150ee1ac00d0796a7f3eafbdb6218128 +github.com/rjeczalik/notify,v0.9.2,h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8=,e8b9b93870f7ed17f30c617acb55f5fa78e7931518c88999c3d1b5b048f51482 +github.com/rkt/rkt,v1.30.0,h1:ZI5RQtSibfjicSttV/HLiHuWreYClEJA2Or5XKAdJb0=,ca2e00335dbeae7e0fbe2c45535d2bb8fce72c2bb6045b0bdf25bc6b8b59179e +github.com/robertkrimen/otto,v0.0.0-20180617131154-15f95af6e78d,h1:1VUlQbCfkoSGv7qP7Y+ro3ap1P1pPZxgdGVqiTVy5C4=,7adbe73b0db5319bae0421a0ed7fc5619002d6e9a2be87dc8c673c8541dfd949 +github.com/robfig/cron,v1.2.0,h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=,0811a1a5a4e1f45824ac520deb2002326a659dbb4918cdfea47d80560a23211d +github.com/robfig/cron/v3,v3.0.0,h1:kQ6Cb7aHOHTSzNVNEhmp8EcWKLb4CbiMW9h9VyIhO4E=,5e29b4f7f4ba62293420b918fb2309823523a583c2adaf6eddb059f525f05496 +github.com/rogpeppe/fastuuid,v1.2.0,h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=,f9b8293f5e20270e26fb4214ca7afec864de92c73d03ff62b5ee29d1db4e72a1 +github.com/rogpeppe/go-charset,v0.0.0-20180617210344-2471d30d28b4,h1:BN/Nyn2nWMoqGRA7G7paDNDqTXE30mXGqzzybrfo05w=,a28b06534aa71873d08578d69b08512dab54caa0ffd9e2943b3479166049eddd +github.com/rogpeppe/go-internal,v1.4.0,h1:LUa41nrWTQNGhzdsZ5lTnkwbNjj6rXTdazA1cSdjkOY=,fb7d843253301d3ea9793f90e6bea16a8f2970a01b361f490ee66b36f81e03a5 +github.com/rpcx-ecosystem/quic-conn,v0.0.0-20190920095804-3967ef162525,h1:Awv5A28rrxuHf1+9+N08cnBa6JuKbhHswmNdfj65Bzo=,b40886ad7129eff9e517187b527467330db3705207349cdaa8f35c0dc8445c08 +github.com/rs/cors,v1.7.0,h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=,67815316761fddc4acfaad852965cf04ec88674abe3a05c6c332519556c55855 +github.com/rs/xhandler,v0.0.0-20160618193221-ed27b6fd6521,h1:3hxavr+IHMsQBrYUPQM5v0CgENFktkkbg1sfpgM3h20=,665ae95533e1a046cf470c7341c59e64b3e2a795cdaaf307368f69a0ba547f2c +github.com/rs/xid,v1.2.1,h1:mhH9Nq+C1fY2l1XIpgxIiUOfNpRBYH1kKcr+qfKgjRc=,4abdedc4de69adcb9a4575f99c59d8ab542191e1800b6a91e12a4e9ea8da0026 +github.com/rs/zerolog,v1.16.0,h1:AaELmZdcJHT8m6oZ5py4213cdFK8XGXkB3dFdAQ+P7Q=,64e248c1fa3c62e2d904868b49acf906d0cb04a00a323d2562ea9ce7c6f154e1 +github.com/rubenv/sql-migrate,v0.0.0-20191025130928-9355dd04f4b3,h1:lwDYefgiwhjuAuVnMVUYknoF+Yg9CBUykYGvYoPCNnQ=,4d4e9e2c7387542b26a1cd9fbfcbdab7b75dce807877d5a0a501180b584c60f2 +github.com/rubyist/circuitbreaker,v2.2.1+incompatible,h1:KUKd/pV8Geg77+8LNDwdow6rVCAYOp8+kHUyFvL6Mhk=,fc1125d9260a471d349c94a251340c437f98743b42324706482596f303c28b11 +github.com/russross/blackfriday,v2.0.0+incompatible,h1:cBXrhZNUf9C+La9/YpS+UHpUT8YD6Td9ZMSU9APFcsk=,836047aa9cbd223efba85b892e6897cf7a3b5ee3f2e6ad36b189d40842f703df +github.com/russross/blackfriday/v2,v2.0.1,h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=,496079bbc8c4831cd0507213e059a925d2c22bd1ea9ada4dd85815d51b485228 +github.com/rwcarlsen/goexif,v0.0.0-20190401172101-9e8deecbddbd,h1:CmH9+J6ZSsIjUK3dcGsnCnO41eRBOnY12zwkn5qVwgc=,98e8ce7bf484716bdf272f31ee01354599f4ec4b4ece7c04156c15b264d8f6ec +github.com/ryanuber/columnize,v2.1.0+incompatible,h1:j1Wcmh8OrK4Q7GXY+V7SVSY8nUWQxHW5TkBe7YUl+2s=,ff687e133db2e470640e511c90cf474154941537a94cd97bb0cf7a28a7d00dc7 +github.com/ryanuber/go-glob,v1.0.0,h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=,2084f36ead38a505489fdb46329502fb627f568224dcc22ef11ec173b61fc2cf +github.com/ryszard/goskiplist,v0.0.0-20150312221310-2dfbae5fcf46,h1:GHRpF1pTW19a8tTFrMLUcfWwyC0pnifVo2ClaLq+hP8=,12c65729fc31d5a9bf246eb387bd4c268d0d68bf33b913cccd81bebd47d6f80d +github.com/sacloud/libsacloud,v1.26.1,h1:td3Kd7lvpSAxxHEVpnaZ9goHmmhi0D/RfP0Rqqf/kek=,4f0e24194ce3566707df5862177cb0f697debe3d5b799decb2685ee8d07dbe11 +github.com/saintfish/chardet,v0.0.0-20120816061221-3af4cd4741ca,h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI=,d9cb0e35c88fbf91a409db0626f2e8ae9db305cf95dc3469dc7d089a8432c9c3 +github.com/samuel/go-zookeeper,v0.0.0-20190923202752-2cc03de413da,h1:p3Vo3i64TCLY7gIfzeQaUJ+kppEO5WQG3cL8iE8tGHU=,499f8144de8a6839b2d70c8869d88f294604188ec501e928ca17446043147d40 +github.com/sanity-io/litter,v1.1.0,h1:BllcKWa3VbZmOZbDCoszYLk7zCsKHz5Beossi8SUcTc=,c4bbddbf1bd7bb4ef74a3c2cac98f4a78a2a3a5a6b8dd140bd31a5d38c459217 +github.com/santhosh-tekuri/jsonschema,v1.2.4,h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis=,1c946415ee3395181090664a37779c296b540ca7eec58844ad0283fef11fec00 +github.com/sasha-s/go-deadlock,v0.2.0,h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y=,6c3f90c7947da1090f545438f4b3fd461cfeec79ee1c6e5e83a0eed7258622b1 +github.com/sassoftware/go-rpmutils,v0.0.0-20190420191620-a8f1baeba37b,h1:+gCnWOZV8Z/8jehJ2CdqB47Z3S+SREmQcuXkRFLNsiI=,88264dbd268c88bc8a57e4b4a261f22058fa6e03eb2883b0a82375f854e15188 +github.com/satori/go.uuid,v1.2.0,h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=,4f741306a0cbe97581e34a638531bcafe3c2848150539a2ec2ba12c5e3e6cbdd +github.com/satori/uuid,v1.2.0,h1:6TFY4nxn5XwBx0gDfzbEMCNT6k4N/4FNIuN8RACZ0KI=,bfd4d3d619e3ad4dd915e05fec5bf10949d8af9bc5c19b840db35ec0f21172ad +github.com/scaleway/scaleway-cli,v0.0.0-20180921094345-7b12c9699d70,h1:DaqC32ZwOuO4ctgg9qAdKnlQxwFPkKmCOEqwSNwYy7c=,05566d6711de08738803132b8522f7051fccd3b3bf2c739dde421fffdfa75eaf +github.com/sclevine/agouti,v3.0.0+incompatible,h1:8IBJS6PWz3uTlMP3YBIR5f+KAldcGuOeFkFbUWfBgK4=,b20c8a6a2c1fda0ae6a9cd6d319e78a7a5afea4bc90810cd46b99246d8219d23 +github.com/sclevine/spec,v1.2.0,h1:1Jwdf9jSfDl9NVmt8ndHqbTZ7XCCPbh1jI3hkDBHVYA=,582017cd824cf3cdf6803ec7db2250304f66efea705feb69cbabab416928b8f4 +github.com/sean-/conswriter,v0.0.0-20180208195008-f5ae3917a627,h1:Tn2Iev07a4oOcAuFna8AJxDOF/M+6OkNbpEZLX30D6M=,0637d2fc0eb4627827e4b73dbe3a72479708641df8fc71a06e7bc481f6a7f39b +github.com/sean-/pager,v0.0.0-20180208200047-666be9bf53b5,h1:D07EBYJLI26GmLRKNtrs47p8vs/5QqpUX3VcwsAPkEo=,a4288f9116ea01c34efd65b7dce4357ba6f9c02ad984ca758fea0d0aebb605c9 +github.com/sean-/seed,v0.0.0-20170313163322-e2103e2c3529,h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=,0bc8e6e0a07e554674b0bb92ef4eb7de1650056b50878eed8d5d631aec9b6362 +github.com/sebest/xff,v0.0.0-20150611211316-7a36e3a787b5,h1:MqIPVG2sHTgcQxFwZ+iHZSQ869PVP42SgEEeI1+X4Y8=,8cbe518a78ab7998550c509bd9fadc95a1aef8e86b1022cb3d265348ad370cde +github.com/seccomp/libseccomp-golang,v0.9.1,h1:NJjM5DNFOs0s3kYE1WUOr6G8V97sdt46rlXTMfXGWBo=,5989692d87ef4c377fbc60d441795a90d9453b9e357d019e44d9033ab39ca888 +github.com/segmentio/go-loggly,v0.5.1-0.20171222203950-eb91657e62b2,h1:S4OC0+OBKz6mJnzuHioeEat74PuQ4Sgvbf8eus695sc=,5e071d0b6923a0fa78895bf7e673f5a4e482d39d4603b7dabd4056a506923ca7 +github.com/segmentio/go-prompt,v1.2.1-0.20161017233205-f0d19b6901ad,h1:EqOdoSJGI7CsBQczPcIgmpm3hJE7X8Hj3jrgI002whs=,b86fcda4b8afd5a3893ea333431368e60ea5ebee302a3014aee6d2020233bf31 +github.com/segmentio/kafka-go,v0.1.0,h1:IXCHG+sXPNiIR5pC/vTEItZduPKu4cnpr85YgxpxlW0=,e0b749b974d3277438d09dd6178928c3ad6c3760313f7ad45ec5cd88d8eb14b9 +github.com/serenize/snaker,v0.0.0-20171204205717-a683aaf2d516,h1:ofR1ZdrNSkiWcMsRrubK9tb2/SlZVWttAfqUjJi6QYc=,67272dde9cf92af80704869dea59346be1c37098373200dd8eea6e0e034079b4 +github.com/sergi/go-diff,v1.0.0,h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=,287218ffcd136dbb28ce99a2f162048d8dfa6f97b524c17797964aacde2f8f52 +github.com/serialx/hashring,v0.0.0-20180504054112-49a4782e9908,h1:RRpyb4kheanCQVyYfOhkZoD/cwClvn12RzHex2ZmHxw=,4184e14faf8e39222109eb2b7fa3aee2e0a544b66785ad0b7058318483ff76bb +github.com/sethgrid/pester,v0.0.0-20190127155807-68a33a018ad0,h1:X9XMOYjxEfAYSy3xK1DzO5dMkkWhs9E9UCcS1IERx2k=,ddcaf31e63aaf1ac003af97e667bedaa0fc89956e19aeb032c5658629da29800 +github.com/shiena/ansicolor,v0.0.0-20151119151921-a422bbe96644,h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=,60da6dc53662eb72063784f3bf609edb7aa317c552f81651164bc657754902a6 +github.com/shirou/gopsutil,v2.19.10+incompatible,h1:lA4Pi29JEVIQIgATSeftHSY0rMGI9CLrl2ZvDLiahto=,e5afa6f0b690ecc3ff12458663c6337920a759f27c3d9692a0836644337e4e85 +github.com/shirou/w32,v0.0.0-20160930032740-bb4de0191aa4,h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U=,3ed6741a7e1470feffb50031ecf9919f30b5f573f993683b6574488756ef65c1 +github.com/shopspring/decimal,v0.0.0-20191009025716-f1972eb1d1f5,h1:Gojs/hac/DoYEM7WEICT45+hNWczIeuL5D21e5/HPAw=,91a0ee539fb6f3de1550cdf93c73434fc8a16bab37be693997b20317510331a9 +github.com/shurcooL/component,v0.0.0-20170202220835-f88ec8f54cc4,h1:Fth6mevc5rX7glNLpbAMJnqKlfIkcTjZCSHEeqvKbcI=,2dd1cfac518def9fc8c6ac69022a85b0413269caf93d9532f77dca7375e1d645 +github.com/shurcooL/events,v0.0.0-20181021180414-410e4ca65f48,h1:vabduItPAIz9px5iryD5peyx7O3Ya8TBThapgXim98o=,1dcade8d00ba3945f5d1bc56c09a84e2d51fa20d20ef4fa6f867e5e4cd918e9d +github.com/shurcooL/github_flavored_markdown,v0.0.0-20181002035957-2122de532470,h1:qb9IthCFBmROJ6YBS31BEMeSYjOscSiG+EO+JVNTz64=,d984dc45e823f4c99e89841d675e34d2d35d3b334f1b3690fde05de30a66929f +github.com/shurcooL/githubv4,v0.0.0-20191006152017-6d1ea27df521,h1:ARaYJO1zp2afVv0s28fq7uxgee4WLop35FWrOoSZyak=,7f5c88b38760c5090bffe582a40abe7dc17a789f9041549e5c17e3d71df2d75d +github.com/shurcooL/go,v0.0.0-20180423040247-9e1955d9fb6e,h1:MZM7FHLqUHYI0Y/mQAt3d2aYa0SiNms/hFqC9qJYolM=,350e4c547dbeb657bb3b2eab428f1c29a80808e8096ff87324fd84744f914766 +github.com/shurcooL/go-goon,v0.0.0-20170922171312-37c2f522c041,h1:llrF3Fs4018ePo4+G/HV/uQUqEI1HMDjCeOf2V6puPc=,31cb3f736521597c56f962b9d7d21073620fbb1da845305aba743960f09e4115 +github.com/shurcooL/gofontwoff,v0.0.0-20180329035133-29b52fc0a18d,h1:Yoy/IzG4lULT6qZg62sVC+qyBL8DQkmD2zv6i7OImrc=,685dedb79602bb41403a7b5198f5c9d0ffbc99a68d7f99160ecf08a71475e5f4 +github.com/shurcooL/gopherjslib,v0.0.0-20160914041154-feb6d3990c2c,h1:UOk+nlt1BJtTcH15CT7iNO7YVWTfTv/DNwEAQHLIaDQ=,ea6c396c92724a8028793bde957dbe9a1c594b8af085035e652d4335e6aa30e1 +github.com/shurcooL/graphql,v0.0.0-20181231061246-d48a9a75455f,h1:tygelZueB1EtXkPI6mQ4o9DQ0+FKW41hTbunoXZCTqk=,eb1b45dc90aed0edcfc4cacffdc2645121dda8155702440eada1bcafefddcbba +github.com/shurcooL/highlight_diff,v0.0.0-20170515013008-09bb4053de1b,h1:vYEG87HxbU6dXj5npkeulCS96Dtz5xg3jcfCgpcvbIw=,b4bcb7f3e50a99623d5f39c4e054964fc60d5e4b34543408582a0a984a67b630 +github.com/shurcooL/highlight_go,v0.0.0-20181028180052-98c3abbbae20,h1:7pDq9pAMCQgRohFmd25X8hIH8VxmT3TaDm+r9LHxgBk=,9f879b051c8eadb6dc063ca3ff6856d0e64cd30b5ad545e580b77b4f8ef9ddd7 +github.com/shurcooL/home,v0.0.0-20181020052607-80b7ffcb30f9,h1:MPblCbqA5+z6XARjScMfz1TqtJC7TuTRj0U9VqIBs6k=,0042d859afa3221fd4b4049b350a2d6ffcc674e4c4177bb0c232dc120b410ee6 +github.com/shurcooL/htmlg,v0.0.0-20190503024804-b6326af49ef6,h1:kXXs9Xnfv5gU7KLKiOE3AQgaRUUXchcXnO2rP3fZ5Ao=,52485f17bba8920b37a70124b90eea9d43037a9764a785c97a7e531ca09ed5a5 +github.com/shurcooL/httperror,v0.0.0-20190506043526-2e76094aa70e,h1:QTph/PpT1aDtFHk0sVJoVG/Vfox0YZkq70sW/tvXJM0=,7807129d1577611bdf803b7a4dd3253f45e4b63a77c1a73bed48a0c838c463c6 +github.com/shurcooL/httpfs,v0.0.0-20190707220628-8d4bc4ba7749,h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk=,a2079dbd8c236262ecbb22312467265fbbddd9b5ee789531c5f7f24fbdda174b +github.com/shurcooL/httpgzip,v0.0.0-20190720172056-320755c1c1b0,h1:mj/nMDAwTBiaCqMEs4cYCqF7pO6Np7vhy1D1wcQGz+E=,70ef73fce2f89d622f828cb439fd6c7b48a7fe63600410a8c0a936042c0e4631 +github.com/shurcooL/issues,v0.0.0-20190705005435-6a96395fbb66,h1:kls/E9JqtKEj8tWx2PwKCWqEWmwzsX7cnj9QkaEhUpM=,dd1ace2ad69b6c130a9294c3eb4032090e73c3b7dace098a5a7e1ad154f8e911 +github.com/shurcooL/issuesapp,v0.0.0-20180602232740-048589ce2241,h1:Y+TeIabU8sJD10Qwd/zMty2/LEaT9GNDaA6nyZf+jgo=,ac947684d3f13beef9433724deddc2c7ddb6d19921d6902f4789dd4ce1af5f3c +github.com/shurcooL/notifications,v0.0.0-20181111060504-bcc2b3082a7a,h1:bQX0+HfDylIQCtf1tzyrxQ+BqIV08ZjkjgspFWiIYhc=,c1c77700f490d0211cec00fd5fd0ee80debf66e0e41de1dc68b24dc726db5409 +github.com/shurcooL/octicon,v0.0.0-20190930024621-43309dfb482e,h1:C2+alklsN4yRHXaOX3v9TuCGlTSwZQjSnN88nLGVhg8=,88953a9951a14e24afd2d1040e9de0b4fbe194805fdc7ec9d9d9bbcd8c2f3448 +github.com/shurcooL/reactions,v0.0.0-20181222204718-145cd5e7f3d1,h1:hHIhW4KrmPQ/hJ7AuKNNvVPVE2k/LVE5NTFsQ68taBw=,fd5f9a0c6e7e292bdfa81fcad767f61c95dc84f18bf4f9f02a4fe02f75327d37 +github.com/shurcooL/sanitized_anchor_name,v1.0.0,h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=,0af034323e0627a9e94367f87aa50ce29e5b165d54c8da2926cbaffd5834f757 +github.com/shurcooL/users,v0.0.0-20180125191416-49c67e49c537,h1:YGaxtkYjb8mnTvtufv2LKLwCQu2/C7qFB7UtrOlTWOY=,3f17089e996438a88a478d38807ce4f3c045a91114830946a1bdc760eb2b7c58 +github.com/shurcooL/vfsgen,v0.0.0-20181202132449-6a9ea43bcacd,h1:ug7PpSOB5RBPK1Kg6qskGBoP3Vnj/aNYFTznWvlkGo0=,8a093681b21159514a1742b1a49e88fa2cf562673a5a0055e9abeb7ff590ee19 +github.com/shurcooL/webdavfs,v0.0.0-20170829043945-18c3829fa133,h1:JtcyT0rk/9PKOdnKQzuDR+FSjh7SGtJwpgVpfZBRKlQ=,bb70104152800cbb490c480bead0d2ef24176be9e1304e6701ab161115484863 +github.com/siddontang/go,v0.0.0-20180604090527-bdc77568d726,h1:xT+JlYxNGqyT+XcU8iUrN18JYed2TvG9yN5ULG2jATM=,ef97fabc8a96a758fac273b01dff6be7957ed44c4b6c6a8316f43741329a0049 +github.com/siddontang/go-snappy,v0.0.0-20140704025258-d8f7bb82a96d,h1:qQWKKOvHN7Q9c6GdmUteCef2F9ubxMpxY1IKwpIKz68=,faf83d6459d06f5f4a9acd09e23e284e11792d14de331bd7b87852b18f9cf5c3 +github.com/siddontang/ledisdb,v0.0.0-20190202134119-8ceb77e66a92,h1:qvsJwGToa8rxb42cDRhkbKeX2H5N8BH+s2aUikGt8mI=,dab81c0bdfc62063a340f61dfab19c065d2d10b1245cd56cc04832130a6bbea5 +github.com/siddontang/rdb,v0.0.0-20150307021120-fc89ed2e418d,h1:NVwnfyR3rENtlz62bcrkXME3INVUa4lcdGt+opvxExs=,93bf89960d84b8732e648cb413dced692c1d3d9000997e99826538a5f20b1d82 +github.com/sigurn/crc8,v0.0.0-20160107002456-e55481d6f45c,h1:hk0Jigjfq59yDMgd6bzi22Das5tyxU0CtOkh7a9io84=,12916a0da94e747b99653138a25112e24b082db53bc0d5cffe62214ce3fb884d +github.com/sigurn/utils,v0.0.0-20190728110027-e1fefb11a144,h1:ccb8W1+mYuZvlpn/mJUMAbsFHTMCpcJBS78AsBQxNcY=,694bb4cbe9dd17447c1e0054ef327eebd9bed8682aa39f5f4d282fb9b1717299 +github.com/sirupsen/logrus,v1.4.2,h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=,9a8e55830261a4b1c9350d7c45db029c8586c0b2d934d1224cde469425031edd +github.com/skratchdot/open-golang,v0.0.0-20190402232053-79abb63cd66e,h1:VAzdS5Nw68fbf5RZ8RDVlUvPXNU6Z3jtPCK/qvm4FoQ=,242db3338b172ecb58bdf3406b4cafecfa738cfb7b8cd71698d23831aedd94b0 +github.com/skyrings/skyring-common,v0.0.0-20160929130248-d1c0bb1cbd5e,h1:jrZSSgPUDtBeJbGXqgGUeupQH8I+ZvGXfhpIahye2Bc=,d5010d4900d7417c05d4863399e5509e82dfaca9c09c31ac9e5ebdcaf109e833 +github.com/smallnest/libkv-etcdv3-store,v0.0.0-20191101045330-f92940446965,h1:YQtdLz+7JQdKn7f5cG+xSrSbI7X4jObx0Jy6ZzffGew=,b9fb22d7d67e16cd3a1d7c7a5b2faf6c35c690ae1c3bcf70dbf77813db7dc563 +github.com/smallnest/rpcx,v0.0.0-20191101045608-2a801682117a,h1:Fzp1HLqyYg8koEELgwfSEUgkE6QPvrN9qCkHZ8tikFY=,0d2255c9ffc429e32936dbb9e51c79bbf2b76a7dec95c5d9dc1668053d5642bc +github.com/smallnest/valkeyrie,v0.0.0-20191030064635-54a884e4b303,h1:NDOAHb1sE8pYWd0Dge8W6bGQ63FHfa0/QjClXG2hrgw=,b846d492aaf7053115b2e143b7c7696299b852ec670d261bd78b5cd996eacde3 +github.com/smartystreets/assertions,v1.0.1,h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w=,2e3d9f61f68cdf7b48653582640ef88744c1a3bdd4257ac68f621579a2f807dd +github.com/smartystreets/go-aws-auth,v0.0.0-20180515143844-0c1422d1fdb9,h1:hp2CYQUINdZMHdvTdXtPOY2ainKl4IoMcpAXEf2xj3Q=,d9441cfbef2c680269ced67f8e1d99af9cf649e11a7f133a5b0685be0277ca7d +github.com/smartystreets/goconvey,v0.0.0-20190731233626-505e41936337,h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=,fd90be078397b45806e4dfaca367235aef6d6133871c8a6cc6d3d579280d8d03 +github.com/smartystreets/gunit,v1.0.0,h1:RyPDUFcJbvtXlhJPk7v+wnxZRY2EUokhEYl2EJOPToI=,36cf43529cfadeb297ce1537c7d0fca8373a95936806121ce7ce0bf653e959ee +github.com/smola/gocompat,v0.2.0,h1:6b1oIMlUXIpz//VKEDzPVBK8KG7beVwmHIUEBIs/Pns=,7812934f407beeab20aa289b0056234ae6637b30b301ebf97a5d7a9fd8e665fc +github.com/snikch/goodman,v0.0.0-20171125024755-10e37e294daa,h1:YJfZp12Z3AFhSBeXOlv4BO55RMwPn2NoQeDsrdWnBtY=,ab939c56cb7afcff213aef4568f40c9ddeae30166e34a2fa7f5718a47227c2e1 +github.com/softlayer/softlayer-go,v0.0.0-20180806151055-260589d94c7d,h1:bVQRCxQvfjNUeRqaY/uT0tFuvuFY0ulgnczuR684Xic=,63ad57bc2d4c27db3dcab7cf545a075bb4d7ea66aba57c284c07a2c938220f8c +github.com/soheilhy/cmux,v0.1.4,h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=,6d6cadade0e186f84b5f8e7ddf8f4256601b21e49b0ca49fd003a7e570ae1885 +github.com/songtianyi/rrframework,v0.0.0-20180901111106-4caefe307b3f,h1:o3QHyJEW1U+8oyEZeaXFcYqdhhiZjrs25/8AZmsWjiU=,b1cf04474a48de1ed7ae535ae4a2d5b17a0df4ce0d3b953c5268f42ee34cb17d +github.com/soniakeys/unit,v1.0.0,h1:UMIgu6dxDQaK6tYaQV6dJn5oovB6035KRxCS0O7Jiec=,565c64fe777e1140d82422e9b8d29ce8de82d7916e50dac2f7591d2c6f2d79e7 +github.com/sony/gobreaker,v0.4.1,h1:oMnRNZXX5j85zso6xCPRNPtmAycat+WcoKbklScLDgQ=,eab9bf8f98b16b051d7d13c4f5c70d6d1039347e380e0a12cb9ff6e33200d784 +github.com/sourcegraph/annotate,v0.0.0-20160123013949-f4cad6c6324d,h1:yKm7XZV6j9Ev6lojP2XaIshpT4ymkqhMeSghO5Ps00E=,2a58cbf2485b2e97e49d7c3e83e81385d1418bfbab2b846dabec041a3d402b3e +github.com/sourcegraph/syntaxhighlight,v0.0.0-20170531221838-bd320f5d308e,h1:qpG93cPwA5f7s/ZPBJnGOYQNK/vKsaDaseuKT5Asee8=,c0e6323ed7a5dcddcdd7686f2d7c68dff44a8ecbfd6818db3bdb33a7af422792 +github.com/spacemonkeygo/errors,v0.0.0-20171212215202-9064522e9fd1,h1:xHQewZjohU9/wUsyC99navCjQDNHtTgUOM/J1jAbzfw=,b360a46f9534dd46d2b2c27c84ba8bbe3942832e74aa4ceb16acaa6ba30620be +github.com/spacemonkeygo/monotime,v0.0.0-20180824235756-e3f48a95f98a,h1:8+cCjxhToanKmxLIbuyBNe2EnpgwhiivsIaRJstDRFA=,4a55e556811ab93b23b46907b354e53fc553eb93314cf0b524933f37ac1437f8 +github.com/spacemonkeygo/openssl,v0.0.0-20181017203307-c2dcc5cca94a,h1:/eS3yfGjQKG+9kayBkj0ip1BGhq6zJ3eaVksphxAaek=,23031c8d37bbaa5aace338eed65af68c7d72bf134d7d0e09c963ed4974c56e58 +github.com/spacemonkeygo/spacelog,v0.0.0-20180420211403-2296661a0572,h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU=,91eb98e80c44d42e6f3ff7ddf84f825d20eb55669452d752fb8ed3adeb723be7 +github.com/spaolacci/murmur3,v1.1.0,h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=,60bd43ada88cc70823b31fd678a8b906d48631b47145300544d45219ee6a17bc +github.com/spf13/afero,v1.2.2,h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=,81d51799397212c9adb2cea6cf3a96a2b50f1baff8aff7bd410128a84f2a9e73 +github.com/spf13/cast,v1.3.0,h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=,001ed519a3ec007e76e639f72bd9560be70497d499acbf1a32ccf32dc4647d91 +github.com/spf13/cobra,v0.0.5,h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=,6c6739f11d69fa1e5b60ba1e04529f355f8a30e1aa2b137ba26260de8fa7a647 +github.com/spf13/fsync,v0.9.0,h1:f9CEt3DOB2mnHxZaftmEOFWjABEvKM/xpf3cUwJrGOY=,d470c73c6e821d6c8f47ce05be3360f4d686d9079dd5af1585420c73e4725c56 +github.com/spf13/jwalterweatherman,v1.1.0,h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=,43cc5f056caf66dc8225dca36637bfc18509521b103a69ca76fbc2b6519194a3 +github.com/spf13/pflag,v1.0.5,h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=,fc6e704f2f6a84ddcdce6de0404e5340fa20c8676181bf5d381b17888107ba84 +github.com/spf13/viper,v1.5.0,h1:GpsTwfsQ27oS/Aha/6d1oD7tpKIqWnOA6tgOX9HHkt4=,7f3513d0a1186b765937c788f0ac751076067b7a0abc82420171b6f262787ac5 +github.com/src-d/envconfig,v1.0.0,h1:/AJi6DtjFhZKNx3OB2qMsq7y4yT5//AeSZIe7rk+PX8=,c694b1440b6969dfd4ebcba669faea8a05bdc7791ac78dcfbe29f153b0a8f0cd +github.com/src-d/gcfg,v1.4.0,h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=,2aa52404cbeec89c0a976d333448d1a4a6e113f03e000a715ce9006c84eb2e32 +github.com/srwiley/oksvg,v0.0.0-20190829233741-58e08c8fe40e,h1:LJUrNHytcMXWKxnULIHPe5SCb1jDpO9o672VB1x2EuQ=,e29e85accb2169d2f0f4dc90c22c446c24d244d68e0bbe038ba9df63381916c5 +github.com/srwiley/rasterx,v0.0.0-20181219215540-696f7edb7a7e,h1:FFotfUvew9Eg02LYRl8YybAnm0HCwjjfY5JlOI1oB00=,8a4b0686258a3e1b4f8b3e5f25efbaaefe7919d4e47e89eb36a6779504f8b116 +github.com/ssdb/gossdb,v0.0.0-20180723034631-88f6b59b84ec,h1:q6XVwXmKvCRHRqesF3cSv6lNqqHi0QWOvgDlSohg8UA=,2c20531d93416fa34ee9039308166c869c72c16fff715c73c05a3977157fdc2d +github.com/ssor/bom,v0.0.0-20170718123548-6386211fdfcf,h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=,7622ce25bbc5d5376ccb113f267f3d68bf2363963b02d04c053dfbc252f62c4a +github.com/steakknife/bloomfilter,v0.0.0-20180922174646-6819c0d2a570,h1:gIlAHnH1vJb5vwEjIp5kBj/eu99p/bl0Ay2goiPe5xE=,fb001f6df1197d462e7dfdbeded863aebd85bb904da5075117174a027a1b8cb1 +github.com/steakknife/hamming,v0.0.0-20180906055917-c99c65617cd3,h1:njlZPzLwU639dk2kqnCPPv+wNjq7Xb6EfUxe/oX0/NM=,e42bd1bc7073772613c2b4879110dd5330fded46a8cdf9269ff03cb6a82d1108 +github.com/stellar/go,v0.0.0-20191031165136-ed88b67b723d,h1:0pucQZ9fngYUl/tIGO/H96N3F5NL5ySjM3fuz+XEFSY=,d9d23bd5fc8cae6e65d4bb0d87e3cb582bc684eac1a519ca787b187a175999a5 +github.com/stellar/go-xdr,v0.0.0-20180917104419-0bc96f33a18e,h1:n/hfey8pO+RYMoGXyvyzuw5pdO8IFDoyAL/g5OiCesY=,5122e57a861bd0c38a3a3607f13576a150face8cacf9cafaf24e21e38a104b87 +github.com/stellar/throttled,v2.2.3-0.20190823235211-89d75816f59d+incompatible,h1:jMXXAcz6xTarGDQ4VtVbtERogcmDQw4RaE85Cr9CgoQ=,a89e929d8d8ba24e621c479708378263714861d8fce137085108da9f0cc8805a +github.com/steveyen/gtreap,v0.0.0-20150807155958-0abe01ef9be2,h1:JNEGSiWg6D3lcBCMCBqN3ELniXujt+0QNHLhNnO0w3s=,64b6a1f094784f1a843a6787bd159a103b9bebd2e85cc09a7e8445cc9e3ffc03 +github.com/streadway/amqp,v0.0.0-20190827072141-edfb9018d271,h1:WhxRHzgeVGETMlmVfqhRn8RIeeNoPr2Czh33I4Zdccw=,66bd109504bf565a4a777c20a8cf6a1c5d05cd87b59baa50da8b6f2b0da4c494 +github.com/stretchr/objx,v0.2.0,h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=,5517d43cfb7e628b9c2c64010b934e346cd24726e3d6eaf02b7f86e10752e968 +github.com/stretchr/testify,v1.4.0,h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=,0400c42ab95389bb4f4577bc09917a040a97f0f4251db2a54a7f6f5e65065b73 +github.com/stripe/stripe-go,v66.1.1+incompatible,h1:D8qUD1rxv+RdXi2qo+IdDELkDevxYUQDfje20bGQPiw=,471de64dbc99da2b83fc1822ff9b4627b1b0738a8e3ee9ffb038510ce84e4baf +github.com/struCoder/pidusage,v0.1.2,h1:fFPTThlcWFQyizv3xKs5Lyq1lpG5lZ36arEGNhWz2Vs=,6ae03cd6cab9014ca7c0326fc233b27d942556c9753d2da87a93dd0fecbb9986 +github.com/stumble/gorocksdb,v0.0.3,h1:9UU+QA1pqFYJuf9+5p7z1IqdE5k0mma4UAeu2wmX8kA=,8bf18874189196133dabeb8fb7444633a0961e8983f8b2d8588d522d6aa679de +github.com/subosito/gotenv,v1.2.0,h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=,21474df92536f36de6f91dfbf466995289445cc4e5a5900d9c40ae8776b8b0cf +github.com/svanharmelen/jsonapi,v0.0.0-20180618144545-0c0828c3f16d,h1:Z4EH+5EffvBEhh37F0C0DnpklTMh00JOkjW5zK3ofBI=,482b13f426a15f3cb64ae5cb1a5fd2f27ca142465a174e24a2cc356812a3ed28 +github.com/swaggo/files,v0.0.0-20190704085106-630677cd5c14,h1:PyYN9JH5jY9j6av01SpfRMb+1DWg/i3MbGOKPxJ2wjM=,e1fe1ffca3a181bede3787e75797345bc69a583a67d8bb10b934f7a140516162 +github.com/swaggo/gin-swagger,v1.2.0,h1:YskZXEiv51fjOMTsXrOetAjrMDfFaXD79PEoQBOe2W0=,7ba6476ca79affa95429821a187b7cb3458305737ac2d1b86340814c3f276f71 +github.com/swaggo/swag,v1.6.3,h1:N+uVPGP4H2hXoss2pt5dctoSUPKKRInr6qcTMOm0usI=,1adbe98538a3f1b5e64fdf08f86cea4502a2c0d0cf1b047a27af6acf764f8c17 +github.com/syndtr/gocapability,v0.0.0-20180916011248-d98352740cb2,h1:b6uOv7YOFK0TYG7HtkIgExQo+2RdLuwRft63jn2HWj8=,ece41bcca6ca06202649ccee0d2ab62667217ceb70f3a84794c3751c16b75cee +github.com/syndtr/goleveldb,v1.0.1-0.20190318030020-c3a204f8e965,h1:1oFLiOyVl+W7bnBzGhf7BbIv9loSFQcieWWYIjLqcAw=,b0dbd1bdec73ea70eb1db85322046d202bcbfe901bc821d6a50ffc182c276306 +github.com/tarm/serial,v0.0.0-20180830185346-98f6abe2eb07,h1:UyzmZLoiDWMRywV4DUYb9Fbt8uiOSooupjTq10vpvnU=,cd962b3b9ef46158abad455c95ed92f2632cdb9217df2b7690171cc3db507add +github.com/tatsushid/go-fastping,v0.0.0-20160109021039-d7bb493dee3e,h1:nt2877sKfojlHCTOBXbpWjBkuWKritFaGIfgQwbQUls=,1c25333d4ca05ca13828835e07876c0efdd90a1c32a715527aa722b3c63c2d48 +github.com/tchap/go-patricia,v2.3.0+incompatible,h1:GkY4dP3cEfEASBPPkWd+AmjYxhmDkqO9/zg7R0lSQRs=,19db63cf16ba944ea853c18397e4336342f1e95e4b2cb12127405bb64c67cf73 +github.com/tdewolff/minify,v2.3.6+incompatible,h1:2hw5/9ZvxhWLvBUnHE06gElGYz+Jv9R4Eys0XUzItYo=,8cabb8163bd65e43b42c5842b700d55e2daeae60c82b019007aceb1ae63638d5 +github.com/tdewolff/minify/v2,v2.5.2,h1:If/q1brvT+91oWiWnIMEGuFcwWtpB6AtLTxba78tvMs=,0af37ec252d094917a1ff4178659fe9f4539fdc3dca108bbeb9c0c2f86499eb9 +github.com/tdewolff/parse,v2.3.4+incompatible,h1:x05/cnGwIMf4ceLuDMBOdQ1qGniMoxpP46ghf0Qzh38=,f290dda8150ebdc2b9586f509770a6c82093ac9027329aeb9f3004a0b26de8e9 +github.com/tdewolff/parse/v2,v2.3.9,h1:d8/K6XOLy5JVpLTG9Kx+SxA72rlm5OowFmVSVgtOlmM=,5f517cbecd071b97ed822e8f88f96ba7d8b5a8accc49fc515298210ac088e7ef +github.com/tdewolff/test,v1.0.4,h1:ih38SXuQJ32Hng5EtSW32xqEsVeMnPp6nNNRPhBBDE8=,807205136d8f39bb7533d10b72932a183f15b45c385cd5464ae9d06e4af43337 +github.com/tealeg/xlsx,v1.0.5,h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=,ff32f4336aed03df7c9cb7a4df9f1f42a1c64fe5d17c34566159511943d24bde +github.com/tecbot/gorocksdb,v0.0.0-20181010114359-8752a9433481,h1:HOxvxvnntLiPn123Fk+twfUhCQdMDaqmb0cclArW0T0=,26c0e94162340c7b4d1da3ee4c71ca03f9d6638711cf440d6835e1a8f07e4fb4 +github.com/technoweenie/multipartstreamer,v1.0.1,h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=,5a9aff85522275b125767b746869d24f4e2f776d5031631bf6e29641d99344dc +github.com/tedsuo/ifrit,v0.0.0-20191009134036-9a97d0632f00,h1:mujcChM89zOHwgZBBNr5WZ77mBXP1yR+gLThGCYZgAg=,1c502a5584dfbce25ff99c1a5689e2d106a138989e4a03249221ca4818674098 +github.com/tedsuo/rata,v1.0.0,h1:Sf9aZrYy6ElSTncjnGkyC2yuVvz5YJetBIUKJ4CmeKE=,f6745fd8ef8ee098410b31b1219def2c4e86c337ba6ff1319f086419b928f134 +github.com/temoto/robotstxt,v1.1.1,h1:Gh8RCs8ouX3hRSxxK7B1mO5RFByQ4CmJZDwgom++JaA=,c37f16f826a27512b7ae683ed32be5124a0252d1c7a8c4a00fd4e27d01c563d4 +github.com/templexxx/cpufeat,v0.0.0-20180724012125-cef66df7f161,h1:89CEmDvlq/F7SJEOqkIdNDGJXrQIhuIx9D2DBXjavSU=,c29bd644943d69b238da1936593421373d2db675a0fce54090d1c8b7eab7397b +github.com/templexxx/xor,v0.0.0-20181023030647-4e92f724b73b,h1:mnG1fcsIB1d/3vbkBak2MM0u+vhGhlQwpeimUi7QncM=,578ab42785a74d1a5dd3e65bf0979138b3a98bf877de4767b8eae5701a2342e1 +github.com/tencentcloud/tencentcloud-sdk-go,v3.0.71+incompatible,h1:9sIWfe6ZC7xoSlshYWNGicPqomK7N+CsHMa1YFWBCWU=,33a9526ee0244844270e532358a22616d821cc7f8f0638e33c60f722f84c5e42 +github.com/tendermint/btcd,v0.1.1,h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s=,1967aa3cbabfb9e9780c0371a5359cc21ed77e5673b64e7dd5b234e838c82e62 +github.com/tendermint/crypto,v0.0.0-20180820045704-3764759f34a5,h1:u8i49c+BxloX3XQ55cvzFNXplizZP/q00i+IlttUjAU=,49ad334d452402d59757d3a415602f57bd7b66962d6115262f5c7413112d61bb +github.com/tendermint/ed25519,v0.0.0-20171027050219-d8387025d2b9,h1:zccWau0P8FELSb4HTDJ88hRo+WVNMbIbg27rFqDrhCE=,7c4a6e57c787df7c6e990c35bb31df3f4a5aa89f45c3b3df4a25dfb70c01f7e3 +github.com/tendermint/go-amino,v0.15.1,h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ=,e91cde0d10d5a8ea6ab726fbab02ef737ba52f47e207cf675440f625153d3205 +github.com/tendermint/iavl,v0.12.2,h1:Ls5p5VINCM1HRT9g5Vvs2zmDOCU/CCIvIHzd/pZ8P0E=,a56011434929c4003fd735cbef8147e8aca3d241983c5fa7a006f5753e123020 +github.com/tendermint/tendermint,v0.32.7,h1:Szu5Fm1L3pvn3t4uQxPAcP+7ndZEQKgLie/yokM56rU=,495a31dc762d79a689ce00cdd52f66b6b4071fc2b738ce4b3d1c2a9447389ecc +github.com/tendermint/tm-db,v0.2.0,h1:rJxgdqn6fIiVJZy4zLpY1qVlyD0TU6vhkT4kEf71TQQ=,99b7c1a00ee483b97e73126a25327b75da9a5bc6e34bf9fb1ecd6b83832fe13e +github.com/tent/http-link-go,v0.0.0-20130702225549-ac974c61c2f9,h1:/Bsw4C+DEdqPjt8vAqaC9LAqpAQnaCQQqmolqq3S1T4=,a4fe19fdbf8fbc30fe866e2cbb8761ee179f4a83bda63a0a6d30a651f3700ec2 +github.com/terraform-providers/terraform-provider-openstack,v1.15.0,h1:adpjqej+F8BAX9dHmuPF47sUIkgifeqBu6p7iCsyj0Y=,9c7419845747d0c4e3a9432f50788d8adec7ed6fca93ec9ffbf99e8c8b1cf0c3 +github.com/testcontainers/testcontainers-go,v0.0.8,h1:71E+jJpE9dSgydCfn5aWESVM7+l8giw/DBWaTy35TTU=,bceec8989a3beb9f14802c13c496c9158509f6b4cee6f855c0fb06b01e7da150 +github.com/tevino/abool,v0.0.0-20170917061928-9b9efcf221b5,h1:hNna6Fi0eP1f2sMBe/rJicDmaHmoXGe1Ta84FPYHLuE=,924168edd97fe37d4af80990d69c1d11d06b8e9236ebae65b9b68ba0261baaf1 +github.com/tgulacsi/picago,v0.0.0-20171229130838-9e1ac2306c70,h1:elvpffAnrLcWnsunBkvTwxr+Q79bPSNT1+2/pOFkCj0=,68e0cb434718215eae670723ce9327ec16d462a6403007ca22b6af71346445c5 +github.com/thanos-io/thanos,v0.3.2,h1:gNWga6sqv5kZp6ltaA7oUIFj+tTG2ohq4W9SQ4YU6ds=,99491658e5ed421ba1563818dd7c01034803fa1e0c4e5d7c28b06f3d3ed2a570 +github.com/theplant/cldr,v0.0.0-20190423050709-9f76f7ce4ee8,h1:di0cR5qqo2DllBMwmP75kZpUX6dAXhsn1O2dshQfMaA=,214ea2cc1e66f278928d0b5b1b40a3e12358b7a71e0fa6d6ea606c4d687e8eef +github.com/theupdateframework/notary,v0.6.1,h1:7wshjstgS9x9F5LuB1L5mBI2xNMObWqjz+cjWoom6l0=,f921dfb3d54538118367d9018d9abacc3c0c026951442140d669443977180b66 +github.com/thoj/go-ircevent,v0.0.0-20180816043103-14f3614f28c3,h1:389FrrKIAlxqQMTscCQ7VH3JAVuxb/pe53v2LBiA7z8=,32edd7a9e219bdff36d2aac0c6c5f3ac982c2daf4869e6e0718e917efb23b3de +github.com/tiancaiamao/appdash,v0.0.0-20181126055449-889f96f722a2,h1:mbAskLJ0oJfDRtkanvQPiooDH8HvJ2FBh+iKT/OmiQQ=,a9961e6079339aec983f97fdb39d5d7258bf8d2031da68482e58e17b27a93a78 +github.com/tidwall/gjson,v1.3.3,h1:wM/XREVc9c0LbRLcNMgVcGpI16r0pbbTJpltR4jJjh0=,17da724ffc86cfb3132bd9c7ac3eb860ca43a2748be519a59aa50b436c147bc6 +github.com/tidwall/match,v1.0.1,h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=,a1b9d52b9a4c7574f46068665279522f2084be26bac71594630786f6ee9a70f2 +github.com/tidwall/pretty,v1.0.0,h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=,3b25a1a0fe7688989326aaa1ca1c74c972b30152ef2a756fbf2d217a827fc07d +github.com/tidwall/sjson,v1.0.4,h1:UcdIRXff12Lpnu3OLtZvnc03g4vH2suXDXhBwBqmzYg=,cb47595016d45d72e6ee0f5585a86247aaeb93d9efa74e07676d32f60e8a7398 +github.com/tildeleb/cuckoo,v0.0.0-20190627040100-71059d5a2b62,h1:rXSNik45VDd1hfRLUAZwDLCY0FWvn2KlCeXjbd1yAI0=,f81f44544ec771ab630ddd5d65f4735ba2acc7619e41ccbc4bfad2473c21dc2f +github.com/timewasted/linode,v0.0.0-20160829202747-37e84520dcf7,h1:CpHxIaZzVy26GqJn8ptRyto8fuoYOd1v0fXm9bG3wQ8=,9a3190b3751964a3d47449265d48e2d3a76b23c66a7cb402cc9bdf3d732d82b4 +github.com/tinylib/msgp,v1.1.0,h1:9fQd+ICuRIu/ue4vxJZu6/LzxN0HwMds2nq/0cFvxHU=,61bd58489c555b30abffbe1175565b6f8460583349118e9ee12025fd17b67ea4 +github.com/tj/assert,v0.0.0-20171129193455-018094318fb0,h1:Rw8kxzWo1mr6FSaYXjQELRe88y2KdfynXdnK72rdjtA=,59a81d1883aac9635ac15d8a6a6e0630cf0a4122328116f921289dab840374b7 +github.com/tj/cobra,v0.0.0-20160702192511-5e2db986a612,h1:eiUtRvCN5HSnOg9AyX5z5od5VWy/ukyJ2oTboInm9MM=,493ac2ac61730652fcdd0b9b4c1e0c63855666df7fcaa02821b63982a5a7ccdf +github.com/tj/go-elastic,v0.0.0-20171221160941-36157cbbebc2,h1:eGaGNxrtoZf/mBURsnNQKDR7u50Klgcf2eFDQEnc8Bc=,a0df933432e9c7ec276cbc0edbb941375726cf5a39c663aafe0e945f9ba3079f +github.com/tj/go-kinesis,v0.0.0-20171128231115-08b17f58cb1b,h1:m74UWYy+HBs+jMFR9mdZU6shPewugMyH5+GV6LNgW8w=,0885f4631d33a20b5447ebbe12a0d23eb5ea3394de4bbc849cfe54ad19cadb2a +github.com/tj/go-spin,v1.1.0,h1:lhdWZsvImxvZ3q1C5OIB7d72DuOwP4O2NdBg9PyzNds=,060d09c35b1db5992747cde71ccbdaefe596ada06a6fe146e0ef10dc67d817dd +github.com/tj/pflag,v0.0.0-20160702191705-e367e44eec04,h1:RAPJe7XUQhTjVUKvYegzhXnWkJd/1daXdoiXjvkSURU=,2156357bb17b30ccb893b8f7013168c85c1eb265b7156aca845d06fb35805257 +github.com/tjfoc/gmsm,v1.0.1,h1:R11HlqhXkDospckjZEihx9SW/2VW0RgdwrykyWMFOQU=,f8fe3c4d02f0dc90fd873278957d57c4c45f1c53b1fee3969216b67844efabb1 +github.com/tmc/grpc-websocket-proxy,v0.0.0-20190109142713-0ad062ec5ee5,h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=,dadf62266d259ffb6aa1d707892b97fa36c3f39df5cae99f54d3ef7682995376 +github.com/tomnomnom/linkheader,v0.0.0-20180905144013-02ca5825eb80,h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y=,558504ea96d4312be0fe5faa6de13fb6abd8f1b2ac154123c67b623a5f219cdb +github.com/toqueteos/webbrowser,v1.2.0,h1:tVP/gpK69Fx+qMJKsLE7TD8LuGWPnEV71wBN9rrstGQ=,1227d3ebeab16d8232a304a10b087984a96ad30f7439b6687bab2f5747d308cf +github.com/transip/gotransip,v0.0.0-20190812104329-6d8d9179b66f,h1:clyOmELPZd2LuFEyuo1mP6RXpbAW75PwD+RfDj4kBm0=,38b593cbdeb59e64d042533c1ce6196d89662de3282373de0d3c0749fe4c4856 +github.com/trivago/tgo,v1.0.5,h1:ihzy8zFF/LPsd8oxsjYOE8CmyOTNViyFCy0EaFreUIk=,06dc60662735374365cd525e2f4f4d1580f348125546e1f3e0d92d2deca4fa9a +github.com/tstranex/u2f,v1.0.0,h1:HhJkSzDDlVSVIVt7pDJwCHQj67k7A5EeBgPmeD+pVsQ=,325e3db32035ce38a5981bfaa35fb6d9b5cb4b960cfa0285b92448d21d29f379 +github.com/tsuru/config,v0.0.0-20180418191556-87403ee7da02,h1:mHuZ6JOixltE9fJmS+W1xLi4t/uDuR6Nl7w/e4uj0+I=,0255268934770d67b9d101a030ed7ed578938e346a279a273ab3983b0eee53fb +github.com/ttacon/chalk,v0.0.0-20160626202418-22c06c80ed31,h1:OXcKh35JaYsGMRzpvFkLv/MEyPuL49CThT1pZ8aSml4=,325521131515e4840e0083bc62cd9553da0b8d2480820f7e92ca89ae324f4c23 +github.com/tus/tusd,v1.0.1,h1:jb0SDf8zCUvlWv5SuHalOuRn684aW6WIvhfWRHC/XB8=,9a91d59123262b9bb1c43d39588a26d7560513b9e3c18254cd321890e8975083 +github.com/tv42/httpunix,v0.0.0-20150427012821-b75d8614f926,h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8=,8246ebc82e0d9d3142f5aeb50d4fcd67f3f435fb5464120c356a4e5d57ef4aa0 +github.com/twinj/uuid,v1.0.0,h1:fzz7COZnDrXGTAOHGuUGYd6sG+JMq+AoE7+Jlu0przk=,842c314d6d2ef9cb95b0f3f1b4cf998715680e836cfab8c2a7f75e351765a345 +github.com/twitchtv/twirp,v5.8.0+incompatible,h1:DTfGS9u/jHbo34cBB+qhzVHRaAq+tRois71j8pvjQ5M=,a4137792083eedd9ac04e88918d8952a841120b11e71161d2d444065b8e65d79 +github.com/tyler-smith/go-bip39,v1.0.2,h1:+t3w+KwLXO6154GNJY+qUtIxLTmFjfUmpguQT1OlOT8=,6173ded455fa17cddd889bf3bc123be2343a09aeb60f83e2b63823dd9ce94e09 +github.com/tylerb/graceful,v1.2.15,h1:B0x01Y8fsJpogzZTkDg6BDi6eMf03s01lEKGdrv83oA=,770bd36defb9463ebe8b190f508e47c37bbb6bedf23a32c675066f8edbd7aa8d +github.com/u-root/dhcp4,v0.0.0-20190206235119-03363dc71ec8,h1:F9cRXeXZ95CzG7352mm+yfgloHFrjpr1L+CQFiCH/iU=,1db09816d65071cfc5dbf25d5dbf11b2b48c3442495d30777cc0714bb4cf4163 +github.com/u-root/u-root,v6.0.0+incompatible,h1:YqPGmRoRyYmeg17KIWFRSyVq6LX5T6GSzawyA6wG6EE=,f3ec29d4b285e50d7b3116e121caca0d722535346a0ddf189d4c7d8e7e0a07d3 +github.com/uber-go/atomic,v1.4.0,h1:yOuPqEq4ovnhEjpHmfFwsqBXDYbQeT6Nb0bwD6XnD5o=,f380292d46ebec89bf53939e4d7d19d617327cbcdf2978e30e6c39bc77df5e73 +github.com/uber/jaeger-client-go,v2.19.0+incompatible,h1:pbwbYfHUoaase0oPQOdZ1GcaUjImYGimUXSQ/+8+Z8Q=,d4928d51ce4440c825df67b4a54f851ead075701e67ece4b07fbc5c5857c091c +github.com/uber/jaeger-lib,v2.2.0+incompatible,h1:MxZXOiR2JuoANZ3J6DE/U0kSFv/eJ/GfSYVCjK7dyaw=,496f63f6df32c28ceb6574959c70969da2b609abc8f9f3b3a709466f862054bf +github.com/uber/tchannel-go,v1.16.0,h1:B7dirDs15/vJJYDeoHpv3xaEUjuRZ38Rvt1qq9g7pSo=,64a37a5e89dd111ab943d94a1670f9addc0d2d41d34d630c95b0a756df916e01 +github.com/ucloud/ucloud-sdk-go,v0.8.7,h1:BmXOb5RivI0Uu4oZRpjI6SQ9/y7n/H9wxTGR1txIE8o=,d94766624c6f676880de354d4ed5c62c9ee7755c3d59cdf106ac0f5a070c0ece +github.com/ugorji/go,v1.1.7,h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=,d02959e71c59b273d5b099697c058426941a862feef66c191c63e2934db7a2ff +github.com/ugorji/go/codec,v1.1.7,h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=,8d482061c55b4c4fbf78de9fbf98a8d1b295f5904769679c73a2dc0b06a1a102 +github.com/ulikunitz/xz,v0.5.6,h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8=,19ebb331e7ae7a542ed58597d13ab703fc423acf93a1e3c4db86476b0322049a +github.com/unixpickle/anyvec,v0.0.0-20170908190750-59aa66ba0472,h1:eVBSKiY98Zth6cEYVzeu0CYagakYqbSWgpWqjZFiUvI=,4159f95762f7a99ee540397e78c7a60da788e6775ad9eca7fc1bd07d332a88f1 +github.com/unixpickle/autofunc,v0.0.0-20170112172612-f27a3f82164a,h1:ZUrHljv3rPkFyTYzUmBH8gBFjDwCIHc4a2DdPCWRjl0=,b39c092ab522c2ca3e8889dfbff281223628c08590b361242e72cc29015da9df +github.com/unixpickle/essentials,v0.0.0-20180916162721-ae02bc395f1d,h1:mRwAxGRBEFcoKSWDoX5CROMJo6xmXBh4rNqOmyhpRi0=,7aa26b2cbcbac91669e88903f1e05b7696b32a6d8194d66c0fe7d93c613c2f5f +github.com/unixpickle/num-analysis,v0.0.0-20161229165253-c45203c63047,h1:gipJz9DZGU3fgBjoaiNg+5CG9UdE7MmlBvSwNp1ulnY=,c1dac9bfeb72d39bb0b445f0f0b2af61753e5b11ff66e69bc196886189b7d50a +github.com/unixpickle/serializer,v0.0.0-20170723202158-c6c092dc55bb,h1:kdurEYFZ2P58xnfWtmxKWkVtFPyK80BMIaJ2zW5uskY=,2cbf6cce1b2a57307c2c675a283ce9b46adcb9d18c3a9317d3ee20772175ae40 +github.com/unknwon/com,v1.0.1,h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs=,f6264780f210f130a0edeafe4ffb0753c64b5168771f2d6cd1613999a7b79cd1 +github.com/unrolled/render,v1.0.1,h1:VDDnQQVfBMsOsp3VaCJszSO0nkBIVEYoPWeRThk9spY=,5b0ace5c3798f8989322a32b75c3eeabce7f6568533f808065cacf92425dd867 +github.com/unrolled/secure,v0.0.0-20190103195806-76e6d4e9b90c,h1:ZY4dowVsuIAQtXXwKJ9ezfonDQ2YT7pcXRpPF2iAy3Y=,1aba4f13fe4199198f9b59bbfd337773d049bad06f68360483a5f4c5431bdce4 +github.com/urfave/cli,v1.22.1,h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=,116fc1fba7db091617cd47c2b83c78d22489deeaf8390a6d3509da7fc9217d57 +github.com/urfave/cli/v2,v2.0.0-alpha.2,h1:2OVOKijPPhkA1cJA5SABACE8TT3Cwx9T0N6VtI8LJSI=,57250f97530fcb6fef7abc87cde3fbaf11ea45830adf98e3f1c986e2674e3b5f +github.com/urfave/negroni,v1.0.0,h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=,7b50615961d34d748866565b8885edd7013e33812acdbaed47502d7cc73a4bbd +github.com/valyala/bytebufferpool,v1.0.0,h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=,7f59f32c568539afee9a21a665a4156962b019beaac8404e26ba37af056b4f1e +github.com/valyala/fasthttp,v1.6.0,h1:uWF8lgKmeaIewWVPwi4GRq2P6+R46IgYZdxWtM+GtEY=,b15a953ed5395599871097c94977d21c026205e6ca7ad6e340cd595096d5840e +github.com/valyala/fastrand,v1.0.0,h1:LUKT9aKer2dVQNUi3waewTbKV+7H17kvWFNKs2ObdkI=,ed2166483141b4f3d59ee07975a5d91990e4c17f36c919565b8063c0cb02f7ed +github.com/valyala/fasttemplate,v1.0.1,h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8=,b4d9f77c6c15a0404952925ad59b759102c0ff48426b6fc88d6bfd347fe243b8 +github.com/valyala/tcplisten,v0.0.0-20161114210144-ceec8f93295a,h1:0R4NLDRDZX6JcmhJgXi5E4b8Wg84ihbmUKp/GvSPEzc=,07066d5b879a94d6bc1feed20ad4003c62865975dd1f4c062673178be406206a +github.com/vbatts/tar-split,v0.11.1,h1:0Odu65rhcZ3JZaPHxl7tCI3V/C/Q9Zf82UFravl02dE=,73136db95ff35c2547c49be43727aa3f67da2d8837e1475954db910b41b1fa18 +github.com/veandco/go-sdl2,v0.3.3,h1:4/TirgB2MQ7oww3pM3Yfgf1YbChMlAQAmiCPe5koK0I=,d19e162daa2a6cc72569eb052adfd3d757fd069ee461a64803e9e8f2e9bb87a7 +github.com/vektah/dataloaden,v0.2.1-0.20190515034641-a19b9a6e7c9e,h1:+w0Zm/9gaWpEAyDlU1eKOuk5twTjAjuevXqcJJw8hrg=,92fe72fa4962bb2f375fae83f7a44a804e398ec08818f7d018724e0a23394ae3 +github.com/vektah/gqlparser,v1.1.2,h1:ZsyLGn7/7jDNI+y4SEhI4yAxRChlv15pUHMjijT+e68=,cdd0119855b98641e7af60dce5b2848b31f8ef03dfcf097c06912309b86fc97c +github.com/viant/assertly,v0.4.8,h1:5x1GzBaRteIwTr5RAGFVG14uNeRFxVNbXPWrK2qAgpc=,253a5e53bb09bf94be7131d5034a6ba19c6eb1f9b8c7fa66182d577bd7b2d6cd +github.com/viant/toolbox,v0.24.0,h1:6TteTDQ68CjgcCe8wH3D3ZhUQQOJXMTbj/D9rkk2a1k=,d6773a06b59de043eff2003bb97567056a1910eb0fd514f5503873b8f23309f4 +github.com/vimeo/go-util,v1.2.0,h1:YHzwOnM+V2tc6r67K9fXpYqUiRwXp0TgFKuyj+A5bsg=,85e52371bcf8299d47d8242546bc06e9e0c9c555b719008096889cd081a69173 +github.com/vincent-petithory/dataurl,v0.0.0-20160330182126-9a301d65acbb,h1:lyL3z7vYwTWXf4/bI+A01+cCSnfhKIBhy+SQ46Z/ml8=,5d5fa46ce0f88ba0734f52d0b0bcaa8a427770ef13cd1bfd7995e4d2a8439abb +github.com/vishvananda/netlink,v1.0.0,h1:bqNY2lgheFIu1meHUFSH3d7vG93AFyqg3oGbJCOJgSM=,6fb7184280eb1321e1857171862bdb624eae29876496f1cb56932fbc0064020f +github.com/vishvananda/netns,v0.0.0-20190625233234-7109fa855b0f,h1:nBX3nTcmxEtHSERBJaIo1Qa26VwRaopnZmfDQUXsF4I=,a99a67e03a35e1d02d1a17900185a1c38c513a79b2b325ad826553dc078a90de +github.com/vivint/infectious,v0.0.0-20190108171102-2455b059135b,h1:dLkqBELopfQNhe8S9ucnSf+HhiUCgK/hPIjVG0f9GlY=,f5d948bf34ac58786ad20df4fd6e99f990f72458dd2825558bf2e3c871f3f37a +github.com/vmihailenco/msgpack,v4.0.4+incompatible,h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=,918f7dd7883105b9c55728c704a3bc54c80568b2b09583890b51508c03391356 +github.com/vmware/govmomi,v0.21.0,h1:jc8uMuxpcV2xMAA/cnEDlnsIjvqcMra5Y8onh/U3VuY=,75ca40f34da851e95d7e63685adbaf1ec5c7f659fb0b47096c85da44f098c4a3 +github.com/vmware/vic,v1.5.4,h1:y546pkye0aes2j2h2n6fWz++v8WxMZTLFl1mLOMzqYQ=,2a6f0c20be8acb3b467c78d3de18009ccd0ab2429a997266089d14341e43115c +github.com/vmware/vmw-guestinfo,v0.0.0-20170707015358-25eff159a728,h1:sH9mEk+flyDxiUa5BuPiuhDETMbzrt9A20I2wktMvRQ=,29c73ba44ac315461640797d6ebfda2d906c28dbe21c20656c6e5fa1f515f220 +github.com/vulcand/oxy,v1.0.0,h1:7vL5/pjDFzHGbtBEhmlHITUi6KLH4xXTDF33/wrdRKw=,148843b55ed01813f8920aab70a799aa10cfdccc0bbd55e270cde78e1ad23b88 +github.com/vulcand/predicate,v1.1.0,h1:Gq/uWopa4rx/tnZu2opOSBqHK63Yqlou/SzrbwdJiNg=,3dd716f2436651429ce7f5fdd59fa1a9944ab4d57fdbae5fef00ef01baf7c4be +github.com/vultr/govultr,v0.1.4,h1:UnNMixYFVO0p80itc8PcweoVENyo1PasfvwKhoasR9U=,7281fa718c076b84610b155fb0dec34503ea1ae5f2930cc714ed7772e475bb08 +github.com/warpfork/go-wish,v0.0.0-20190328234359-8b3e70f8e830,h1:8kxMKmKzXXL4Ru1nyhvdms/JjWt+3YLpvRb/bAjO/y0=,77a9eefa3edf38cb90eba443f282bd73ffcb6f1b87aebe8f891d8c8b38124d95 +github.com/weaveworks/common,v0.0.0-20190917143411-a2b2a6303c33,h1:UAh7j96ZXQID3shhQsrtfJsrQ2uO3tyRxCuXvh+kipw=,e1ceacd5b24c6414ae664f4b09e295dc25e48d3a1dcd5100d8c98dd405a0d162 +github.com/weaveworks/mesh,v0.0.0-20191031093817-8e3db2fe8f47,h1:RUdrWPah1Xu+efIGqN0YGTv7gQeyR5qwBq9uL4HloKw=,05f5d769f7ff6af1c098f0e42983227d6a86f5d8d1f8453cb0566450cad49358 +github.com/wellington/go-libsass,v0.9.3-0.20181113175235-c63644206701,h1:9vG9vvVNVupO4Y7uwFkRgIMNe9rdaJMCINDe8vhAhLo=,2ae95ed360950fab28eff3bedf1c1a6f5f81b73078000d3a0bd67443d38df87f +github.com/wendal/errors,v0.0.0-20130201093226-f66c77a7882b,h1:0Ve0/CCjiAiyKddUMUn3RwIGlq2iTW4GuVzyoKBYO/8=,f7722558c5c450fa02e800ce7bf4d0bc1d2a0e1696d3fc50ff1489bcd02ff3b3 +github.com/weppos/publicsuffix-go,v0.5.0,h1:rutRtjBJViU/YjcI5d80t4JAVvDltS6bciJg2K1HrLU=,bd8365c8501b307a1fbd62501bc3332ff97721bef51921a99e67a3f8b96318fc +github.com/whyrusleeping/cbor-gen,v0.0.0-20190910031516-c1cbffdb01bb,h1:8yBVx6dgk1GfkiWOQ+RbeDDBLCOZxOtmZ949O2uj5H4=,9d5ab8362eaffa07bc2700d9a9e967c1ecf394e3233a6e7141efb48970bfd4e5 +github.com/whyrusleeping/chunker,v0.0.0-20181014151217-fe64bd25879f,h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E=,b28fdb03b69be216c423967e9dee2481aa10c3e39c71d3bfc8911940dadb26a9 +github.com/whyrusleeping/go-keyspace,v0.0.0-20160322163242-5b898ac5add1,h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k=,9416f8227e6c516294b9b938fcf2347bebe2cdab4377454150ba60dcd86c2990 +github.com/whyrusleeping/go-logging,v0.0.0-20170515211332-0457bb6b88fc,h1:9lDbC6Rz4bwmou+oE6Dt4Cb2BGMur5eR/GYptkKUVHo=,125b1a836936436354791583be42ae19f7c04a636b5c0c96135645d52aaa72ea +github.com/whyrusleeping/go-notifier,v0.0.0-20170827234753-097c5d47330f,h1:M/lL30eFZTKnomXY6huvM6G0+gVquFNf6mxghaWlFUg=,08dddb594554c3b35791893207e66dd3c04e4da24d0e0df001bb185f97dec6cc +github.com/whyrusleeping/go-smux-multiplex,v3.0.16+incompatible,h1:iqksILj8STw03EJQe7Laj4ubnw+ojOyik18cd5vPL1o=,e16e3da58e283e71955b21725c384d180a2999bc2a50cb0490b5e2f7a74b5fc6 +github.com/whyrusleeping/go-smux-multistream,v2.0.2+incompatible,h1:BdYHctE9HJZLquG9tpTdwWcbG4FaX6tVKPGjCGgiVxo=,9a783c4a1b69f6002ac4e0af684f4d5c4d360b7107fbbdde48faf38f7e23e998 +github.com/whyrusleeping/go-smux-yamux,v2.0.9+incompatible,h1:nVkExQ7pYlN9e45LcqTCOiDD0904fjtm0flnHZGbXkw=,3f44f41fc7b133085bba08d52e7615e9a8eb92f55fde6a07d3cd7804117e9985 +github.com/whyrusleeping/mafmt,v1.2.8,h1:TCghSl5kkwEE0j+sU/gudyhVMRlpBin8fMBBHg59EbA=,e5d5783d2bc35f7c23f2034fd52c5750ad0590773115c10b4e15360575322c69 +github.com/whyrusleeping/mdns,v0.0.0-20180901202407-ef14215e6b30,h1:nMCC9Pwz1pxfC1Y6mYncdk+kq8d5aLx0Q+/gyZGE44M=,fc2e4d2365ba40d52d03126ea490e712762b4ad398c8d6adb2a1a08699a10eb1 +github.com/whyrusleeping/multiaddr-filter,v0.0.0-20160516205228-e903e4adabd7,h1:E9S12nwJwEOXe2d6gT6qxdvqMnNq+VnSsKPgm2ZZNds=,14e8963464dab0f6277f596985be5ea419bc3bae8bf4f4f139cce456e1815faf +github.com/whyrusleeping/timecache,v0.0.0-20160911033111-cfcb2f1abfee,h1:lYbXeSvJi5zk5GLKVuid9TVjS9a0OmLIDKTfoZBL6Ow=,c33dfc5ac935582261bf5ddbab31bb07febc471a9c26eb3e1a895eddd574d3e8 +github.com/whyrusleeping/yamux,v1.1.5,h1:4CK3aUUJQu0qpKZv5gEWJjNOQtdbdDhVVS6PJ+HimdE=,658f9e704cbe1cac295ed34471bb096a4d2713f69ffbb8140fbf50b8ff6420e0 +github.com/willf/bitset,v1.1.9,h1:GBtFynGY9ZWZmEC9sWuu41/7VBXPFCOAbCbqTflOg9c=,ddd687772ccfd6774e55e7e9d9e71dab86d85a64b98ce1d864d9661f5b0767e4 +github.com/x-cray/logrus-prefixed-formatter,v0.5.2,h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=,00719eeb4f9eadb9431dd9f763fa4013dc52b37a8803a973c6d0c1ce8281e14b +github.com/xanzy/go-cloudstack,v0.0.0-20190526095453-42f262b63ed0,h1:NJrcIkdzq0C3I8ypAZwFE9RHtGbfp+mJvqIcoFATZuk=,34b46eae351e4916015ce2a43ed501403937e4079cf69dae98a9544bfeec8092 +github.com/xanzy/go-gitlab,v0.21.0,h1:Ru55sR4TBoDNsAKwCOpzeaGtbiWj7xTksVmzBJbLu6c=,12ae6fa35c19fffc31d1fa2891f386875caac8077d19f3f09f49b5e2e51b1755 +github.com/xanzy/ssh-agent,v0.2.1,h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=,7011c1771f8ad9b65795f8a85113e4518c9a2c7493029c4c988bc802b63d9e28 +github.com/xdg/scram,v0.0.0-20180814205039-7eeb5667e42c,h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk=,33884d438b686676ceaa2a439634a108f7fe763ce974342d2aa811c22b34112c +github.com/xdg/stringprep,v1.0.0,h1:d9X0esnoa3dFsV0FG35rAT0RIhYFlPq7MiP+DW89La0=,2b262e4e8e9655100c98e2b7e75b517e3e83e2155818174c63ea09d3cce22721 +github.com/xeipuuv/gojsonpointer,v0.0.0-20180127040702-4e3ac2762d5f,h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=,5b1a4bcc8e003f214c92b3fa52959d9eb0e3af1c0c529efa55815db951146e48 +github.com/xeipuuv/gojsonreference,v0.0.0-20180127040603-bd5ef7bd5415,h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=,7ec98f4df894413f4dc58c8df330ca8b24ff425b05a8e1074c3028c99f7e45e7 +github.com/xeipuuv/gojsonschema,v1.2.0,h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=,55c8ce068257aa0d263aad7470113dafcd50f955ee754fc853c2fdcd31ad096f +github.com/xenolf/lego,v2.7.2+incompatible,h1:aGxxYqhnQLQ71HsvEAjJVw6ao14APwPpRk0mpFroPXk=,25c2495e4fc2f5fea8c70b442add86c049f2f8810235e1ee94f29d8e0267ad2c +github.com/xeonx/timeago,v1.0.0-rc4,h1:9rRzv48GlJC0vm+iBpLcWAr8YbETyN9Vij+7h2ammz4=,b06f4ede554b35387394827ca0350b628a72228a8002653817826991867e1fdd +github.com/xi2/xz,v0.0.0-20171230120015-48954b6210f8,h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=,1ffe8f24af5118966084d41eca2c9bee7a831a07deb4356e4d707d208da22e8e +github.com/xiang90/probing,v0.0.0-20190116061207-43a291ad63a2,h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=,437bdc666239fda4581b592b068001f08269c68c70699a721bff9334412d4181 +github.com/xlab/treeprint,v0.0.0-20181112141820-a009c3971eca,h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI=,d14ebea967caa835f25e4c3980c60719e07f0e36375b74dc48928613fca5b2ff +github.com/xo/dburl,v0.0.0-20191005012637-293c3298d6c0,h1:6DtWz8hNS4qbq0OCRPhdBMG9E2qKTSDKlwnP3dmZvuA=,1fb150cf2144a4b7a571360af52d9b22dfe53e2ba9ab3e56584fdb0eb282d315 +github.com/xordataexchange/crypt,v0.0.3-0.20170626215501-b2862e3d0a77,h1:ESFSdwYZvkeru3RtdrYueztKhOBCSAAzS4Gf+k0tEow=,46dc29ef77d77a2bc3e7bd70c94dbaeec0062dd3bd6fcacbaab785c15dcd625b +github.com/xtaci/kcp-go,v5.4.5+incompatible,h1:CdPonwNu3RKu7HcXSno5r0GXfTViDY2iFV2RDOao/4U=,98e77493d94b33bfec990bd5791d15a09add1a0ba2f3281f26bdc98c1815d9a7 +github.com/xtaci/lossyconn,v0.0.0-20190602105132-8df528c0c9ae,h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM=,75cc8c3e14cf812dcc56a1e8cecafd8affd9b2843d39540ab67929f7ce3d1abc +github.com/xtgo/set,v1.0.0,h1:6BCNBRv3ORNDQ7fyoJXRv+tstJz3m1JVFQErfeZz2pY=,6b70026a5ea66bc0be7efb2247afa53ae970b9535c7a8541795750ef9b640217 +github.com/yalp/jsonpath,v0.0.0-20150812003900-31a79c7593bb,h1:06WAhQa+mYv7BiOk13B/ywyTlkoE/S7uu6TBKU6FHnE=,d2041be5f19a3dbcd4b384dbbf5782cdb96d80ad9c60c8c9b887f2c5170cb25f +github.com/yandex-cloud/go-genproto,v0.0.0-20190928220815-a36c849d0fc1,h1:GDyRNvsi/tOZj1ssPkk+kocO1djpbmLSpDKg4XeRPy4=,5502c680146902518514935af5ab5b554a80f5ebe2e79d491db3120911f5498d +github.com/yandex-cloud/go-sdk,v0.0.0-20190916101744-c781afa45829,h1:2FGwbx03GpP1Ulzg/L46tSoKh9t4yg8BhMKQl/Ff1x8=,4b375b871ce7501943a26ba02c348ad4fdf2cb112520513628566a15a98a4796 +github.com/yohcop/openid-go,v0.0.0-20160914080427-2c050d2dae53,h1:HsIQ6yAjfjQ3IxPGrTusxp6Qxn92gNVq2x5CbvQvx3w=,8c4f676193e3aa5ec012e0661d0e552a3e5d5d96086a73901dcfbf0bd4a6d2e9 +github.com/yookoala/realpath,v1.0.0,h1:7OA9pj4FZd+oZDsyvXWQvjn5oBdcHRTV44PpdMSuImQ=,9fe8b06f8efabb7df08608f18edc77d284e04ad06d490af9f55196e4184c339f +github.com/yosssi/ace,v0.0.5,h1:tUkIP/BLdKqrlrPwcmH0shwEEhTRHoGnc1wFIWmaBUA=,96157dbef72f2f69a900e09b3e58093ee24f7df341ac287bddfb15f8c3f530db +github.com/yosssi/gmq,v0.0.1,h1:GhlDVaAQoi3Mvjul/qJXXGfL4JBeE0GQwbWp3eIsja8=,d06bbe96ba0e8c3c79bfb0b9191a02a19d8d3d3c181eba62df6d94c0602c784e +github.com/youtube/vitess,v2.1.1+incompatible,h1:SE+P7DNX/jw5RHFs5CHRhZQjq402EJFCD33JhzQMdDw=,2eb3c516c8b24a72b8cb14f76f39562638acf0cd7fc3858002163d28047607f2 +github.com/yudai/gojsondiff,v0.0.0-20170107030110-7b1b7adf999d,h1:yJIizrfO599ot2kQ6Af1enICnwBD3XoxgX3MrMwot2M=,3f61230fe62a6fe2e93a75264d176bda3f62323063c1e9bfb87c0be31ac5d269 +github.com/yudai/golcs,v0.0.0-20150405163532-d1c525dea8ce,h1:888GrqRxabUce7lj4OaoShPxodm3kXOMpSa85wdYzfY=,ff1f3899e710574a08aaa51051a36c523ecf850180ad0564d55eec611c3cff72 +github.com/yudai/pp,v2.0.1+incompatible,h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI=,ecfda4152182e295f2b21a7b2726e2865a9415fc135a955ce42e039db29e7a20 +github.com/yuin/gopher-lua,v0.0.0-20190514113301-1cd887cd7036,h1:1b6PAtenNyhsmo/NKXVe34h7JEZKva1YB/ne7K7mqKM=,fd157d5d26c336c44837eceef5c6fc4b442a56b25931d4afae3c4080932a7aa7 +github.com/zach-klippenstein/goregen,v0.0.0-20160303162051-795b5e3961ea,h1:CyhwejzVGvZ3Q2PSbQ4NRRYn+ZWv5eS1vlaEusT+bAI=,6f523a11fcb80dca31c3bae99c8c4a59b7e5a4176e36cad0e3f1e64e1b9a7b11 +github.com/zclconf/go-cty,v1.1.0,h1:uJwc9HiBOCpoKIObTQaLR+tsEXx1HBHnOsOOpcdhZgw=,024660decfe11e74a9fab80f1447b79c61e328baf6418629a15c74e183b95e95 +github.com/zclconf/go-cty-yaml,v1.0.1,h1:up11wlgAaDvlAGENcFDnZgkn0qUJurso7k6EpURKNF8=,2502da37ac6d9105b07748c4252f970aa6a7ffc8929b92a0b85abb81b804e9b7 +github.com/zeebo/admission,v0.0.0-20180821192747-f24f2a94a40c,h1:WoYvMZp+keiJz+ZogLAhwsUZvWe81W+mCnpfdgEUOl4=,b62a80509cfa84e697b23dd6b1b314a264e6f68586661ecd84026625f7753cb1 +github.com/zeebo/assert,v1.0.0,h1:qw3LXzO7lbptWIQ6DsemJIUOoaqyKbgY3M8b8yvlaaY=,bb31d428cc59a322975ab6b5757832e62507655f3e2c467a88345b21d7431d98 +github.com/zeebo/errs,v1.2.2,h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g=,d2fa293e275c21bfb413e2968d79036931a55f503d8b62381563ed189b523cd2 +github.com/zeebo/float16,v0.1.0,h1:kRqxv5og6z1emEyz5FpW0/BVHe5VfxEAw6b1ljCZlUc=,ffc6b2a7bce5e37798bc3ac53448b6190039a77f2e7d589779680fbd3cb53a48 +github.com/zeebo/incenc,v0.0.0-20180505221441-0d92902eec54,h1:+cwNE5KJ3pika4HuzmDHkDlK5myo0G9Sv+eO7WWxnUQ=,141b997c5ece8f136f43644f5a2526305563128c4ecce280d9a54ce1ae506ba2 +github.com/zeebo/structs,v1.0.2,h1:kvcd7s2LqXuO9cdV5LqrGHCOAfCBXaZpKCA3jD9SJIc=,0495c69abfeb2ffa0911f4c44ba145d81b04ec76d2311e2eedfc2b3e2efd66c9 +github.com/zenazn/goji,v0.9.0,h1:RSQQAbXGArQ0dIDEq+PI6WqN6if+5KHu6x2Cx/GXLTQ=,0807a255d9d715d18427a6eedd8e4f5a22670b09e5f45fddd229c1ae38da25a9 +github.com/ziutek/mymysql,v1.5.4,h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=,1ea104186e0990a3d97a1e67fcd31177849c975de4abd9399270ab0a04c025de +github.com/zkfy/cron,v0.0.0-20170309132418-df38d32658d8,h1:jxPemXnLeekMXItoaw4jZtDfe8HmvFmviUm2L5tEBhE=,81a903448f6bc140e07bc4ff70762f0a46e750388f4b92f700d358331b1ca8d5 +github.com/zkfy/go-metrics,v0.0.0-20161128210544-1f30fe9094a5,h1:Rb2qQMbEon+BI3IXGh4eW3u/iTLPA3+Y6kNK+gHO32w=,07f9078cbc233559128dc4ae80d69505dd1a07d47d33135fc8f4969829fd6ee8 +github.com/zkfy/jwt-go,v3.0.0+incompatible,h1:5hZNIkrRRa0mrkRiXoPFdLJWpMDByIZ6VIbX9aWhwmk=,8306a4a65059e17be035dd47f45d83aac503c50c954716c83e481d0b6530aed6 +github.com/zkfy/log,v0.0.0-20180312054228-b2704c3ef896,h1:nktyhX5ycnu+WA489Ei7SUi00bF+LW8TF2N7se5gQ/o=,dd0acb5ccceb2225c89f0f50dc8eea9f1cae0971b731750ea7a1b186c194d9bc +github.com/zkfy/stompngo,v0.0.0-20170803022748-9378e70ca481,h1:dqbWcJVZJv06ZR7zK8yN9w8oNOHL23eylL4o9Xj9Zn0=,9e643fbfd166421cb186275742bafc663fc350da83e59e9d88c06feb12ec4462 +github.com/zmap/rc2,v0.0.0-20131011165748-24b9757f5521,h1:kKCF7VX/wTmdg2ZjEaqlq99Bjsoiz7vH6sFniF/vI4M=,fd70713ed40c95220e95c7c47f7e15051e8dc909d39253f403bb694f45fbe789 +github.com/zmap/zcertificate,v0.0.0-20180516150559-0e3d58b1bac4,h1:17HHAgFKlLcZsDOjBOUrd5hDihb1ggf+1a5dTbkgkIY=,7dc2c0bedccfdeb9c42ef41ef502f404befa9ef073c35db3b15c99cae6697b41 +github.com/zmap/zcrypto,v0.0.0-20190729165852-9051775e6a2e,h1:mvOa4+/DXStR4ZXOks/UsjeFdn5O5JpLUtzqk9U8xXw=,871979cf16453ddb4db7f153f449af4e346f68b51355c74b5eee832225618ff0 +github.com/zmap/zlint,v0.0.0-20190806154020-fd021b4cfbeb,h1:vxqkjztXSaPVDc8FQCdHTaejm2x747f6yPbnu1h2xkg=,e62f5cd5f434d84f53d336261e3a6e50c8902152ce8f2f5ce918270d6d201cab +github.com/zondax/hid,v0.9.0,h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8=,9c72a6bdbf03d9465dfdf1ba876eabf5fa923d5bb9e726c9e4a994098dc9bd79 +github.com/zondax/ledger-go,v0.9.0,h1:oTrtFqPFA4VdCPRvqMaN45mQnJxkPc0JxoVZfCoUpjI=,6c6a7e036f9a621ce951939d7d13ae1f0c098f58829307c78f9312e02e78e438 +github.com/zquestz/grab,v0.0.0-20190224022517-abcee96e61b1,h1:1qKTeMTSIEvRIjvVYzgcRp0xVp0eoiRTTiHSncb5gD8=,4decd67f1252df4ee34968cb0cb4e7dc6010302b24ce8edd418f1c2520f1c351 +gitlab.com/NebulousLabs/errors,v0.0.0-20171229012116-7ead97ef90b8,h1:gZfMjx7Jr6N8b7iJO4eUjDsn6xJqoyXg8D+ogdoAfKY=,b355474f1a2ef2722ae450ef6df7209d223188ae413706be122b472fcc053c48 +gitlab.com/NebulousLabs/fastrand,v0.0.0-20181126182046-603482d69e40,h1:dizWJqTWjwyD8KGcMOwgrkqu1JIkofYgKkmDeNE7oAs=,a56acdda993c7a4795028fe38844d54de9b1877d22e8ae09f205e488ce2284bc +go.bug.st/serial.v1,v0.0.0-20180827123349-5f7892a7bb45,h1:mACY1anK6HNCZtm/DK2Rf2ZPHggVqeB0+7rY9Gl6wyI=,f0ea4cd4c51228f1a3cf14c6b92888169944f267e1ee778909512a4c8ac4762f +go.cryptoscope.co/luigi,v0.3.4,h1:eDrtCoUL5Vl2Atr5ty2dq0uFbzFCc6Pz1HEqU1e7I1I=,949612e92dcb2fc919e506740f36d0cfe0797c1f85579a98763aad0135a4580a +go.dedis.ch/fixbuf,v1.0.3,h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs=,dfa737543a5873b14cdfd0eec675c63044b16d3dbe481b2289c758ae4186ae95 +go.dedis.ch/kyber/v3,v3.0.8,h1:qnHzOBaxEO3+ZYuZAfwPTOPzX+F6QMmWGo8YJvENh68=,d69db17bd37bf14c4e508eb84974c3df9a82b8cb30b55ddc3ac0ee2784abcbac +go.dedis.ch/kyber/v4,v4.0.0-pre1,h1:1f5OPESkyxK6kPaCSV3J9BlpnoysIpbGLNujX9Ov8m4=,d082a41e2178f7e18c088e414e020928794245a9dae41d07da842ebb667a337e +go.dedis.ch/onet/v3,v3.0.26,h1:wQhVGB+SCdG7B0tbo6ZeZINQKWkU4u9TNMkGBH16EEM=,a41978897a3371f2eaaab5c84c354c95b4fdbd7b8207afa7c79f32b85f857d5d +go.elastic.co/apm,v1.5.0,h1:arba7i+CVc36Jptww3R1ttW+O10ydvnBtidyd85DLpg=,447a5954db3f7fc61575c83782be0b6d69e453f1e667b0534d3bf5336039238a +go.elastic.co/apm/module/apmhttp,v1.5.0,h1:sxntP97oENyWWi+6GAwXUo05oEpkwbiarZLqrzLRA4o=,1e6bc42b2e3ab10165036afd95a8a4d910acadce451c0b4e7c998cbb5c06da73 +go.elastic.co/apm/module/apmot,v1.5.0,h1:rPyHRI6Ooqjwny67au6e2eIxLZshqd7bJfAUpdgOw/4=,235fb0c1d0e107ffb7c5056e49226152063ac87ebc657428ea410d5170804d2e +go.elastic.co/fastjson,v1.0.0,h1:ooXV/ABvf+tBul26jcVViPT3sBir0PvXgibYB1IQQzg=,451e29b2854f9e09c58e3fe4c1b3a72d9b2ee293628ab4c4323e8192af015c6c +go.etcd.io/bbolt,v1.3.3,h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk=,1ea076dbe18dabe78909e1fb7ec2954fc2d58cd72e7730ad69b35248a30049fd +go.etcd.io/etcd,v3.3.17+incompatible,h1:g8iRku1SID8QAW8cDlV0L/PkZlw63LSiYEHYHoE6j/s=,7bd292878f70e154a061ed6b85fc70502aa270fcf0072340cbde1a0cb35b0d2d +go.mongodb.org/mongo-driver,v1.1.2,h1:jxcFYjlkl8xaERsgLo+RNquI0epW6zuy/ZRQs6jnrFA=,6b3141ced32d7a41ebd0539df957b76331fc3efdca22eae68da54d41aad23fed +go.opencensus.io,v0.22.1,h1:8dP3SGL7MPB94crU3bEPplMPe83FI4EouesJUeFHv50=,b8d9a5fca5e714c4bf66f6497dd905992113cfd6aae948bb7fad5ce987a520ed +go.starlark.net,v0.0.0-20191021185836-28350e608555,h1:FhmD1D59MmncMfRVTRa889iERZG3jdaKj/1FtOQB1G0=,add124cd355e714f076a385eb3f2ddcfb8ce0c7c8e6611e2e03acc427a4c32bf +go.uber.org/atomic,v1.5.0,h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY=,7e32f8f75b2029aa53399c2cd6e581398ac4e971c17a763980377279ede95c77 +go.uber.org/automaxprocs,v1.2.0,h1:+RUihKM+nmYUoB9w0D0Ov5TJ2PpFO2FgenTxMJiZBZA=,4c7bf41eab5dd7781c69130aa37011427531dee231ffbdc3c9ed4267c06aa93c +go.uber.org/multierr,v1.3.0,h1:sFPn2GLc3poCkfrpIXGhBD2X0CMIo4Q/zSULXrj/+uc=,29b25df332dea2dbfaaa308013fc6d3673ecd3d9ee09c666c69df504533d0714 +go.uber.org/ratelimit,v0.1.0,h1:U2AruXqeTb4Eh9sYQSTrMhH8Cb7M0Ian2ibBOnBcnAw=,78f82854809625c784088b9dec5dfb4810fbbd09c24891b8aaf2c2679212dfd8 +go.uber.org/thriftrw,v1.20.2,h1:0JlCE7dOyWHEQdfDm0MWIbgTn6vXkiMA6LNIe8FQXjw=,148b93f97a6ab865e2dbe0eb09b9f9504248808efc437e20efc1bf9b7896de9a +go.uber.org/tools,v0.0.0-20190618225709-2cfd321de3ee,h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=,988dba9c5074080240d33d98e8ce511532f728698db7a9a4ac316c02c94030d6 +go.uber.org/zap,v1.12.0,h1:dySoUQPFBGj6xwjmBzageVL8jGi8uxc6bEmJQjA06bw=,d4b304046a3f9443e4abe217889b5b2a4ecef35d52f175bcacf2baff18646595 +go4.org,v0.0.0-20191010144846-132d2879e1e9,h1:zHLoVtbywceo2hE4Wqv8CmIufe7jDERQ2KJHZoSDfCU=,21811f50d48c55047df1d6bf68db778087afe9116f1f32faf79f8ca459d29d89 +gobot.io/x/gobot,v1.14.0,h1:IJv4A9f5/lUz4JQaS37UW8bRVl3lG+jCGUcNmJ2F0vE=,95ad64d1bf33ee46816b2c87edb10d7b3bfe118b6f7026bf4b5f762867d1e776 +gocloud.dev,v0.17.0,h1:UuDiCphYsiNhRNLtgHVL/eZheQeCt00hL3XjDfbt820=,0df8e26a2356735d596e8a3917ec4b69f61fb5e9f6f291b51f6145a51b646a9b +gocv.io/x/gocv,v0.21.0,h1:dVjagrupZrfCRY0qPEaYWgoNMRpBel6GYDH4mvQOK8Y=,9e1a70258d72b873d9605a2939b38f9e560650472d70b97f5dd0fc2657eaf35f +golang.org/x/arch,v0.0.0-20191101135251-a0d8588395bd,h1:e1iK2rWppIPlzzqtjXT/p6WR/+ritGZ8xkfL8uDZb0g=,daba41c9150ebf192ce54952d69ef12fe47c5c6250a33c01f0624befea35354e +golang.org/x/build,v0.0.0-20191031202223-0706ea4fce0c,h1:jjNoDZTS0vmbqBhqD5MPXauZW+kcGyflfDDFBNCPSVI=,a675f674bcee677f1dc9a15ca4d84bb2e842c29d745b165ba3e5423c09367d29 +golang.org/x/crypto,v0.0.0-20191029031824-8986dd9e96cf,h1:fnPsqIDRbCSgumaMCRpoIoF2s4qxv0xSSS0BVZUE/ss=,0a303100f9afba8628988bef45404b23c2e0c6aa73b5ad4ac9259af14a0e53ae +golang.org/x/exp,v0.0.0-20191030013958-a1ab85dbe136,h1:A1gGSx58LAGVHUUsOf7IiR0u8Xb6W51gRwfDBhkdcaw=,18ff05b39d29a3fd4c7f9071e7013264994ac18f7faa72f66b2f514fcdd141b0 +golang.org/x/image,v0.0.0-20191009234506-e7c1f5e7dbb8,h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U=,aebca4c096dac7c20d9024b73bd0b4a87a85f4c6b50aae7615dec504c5f478c8 +golang.org/x/lint,v0.0.0-20190930215403-16217165b5de,h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=,91323fe1a77f13de722a0ce8efc5c5f2da4f26216d858acec64cb23c956fa163 +golang.org/x/mobile,v0.0.0-20191031020345-0945064e013a,h1:CrJ8+QyIm2tcw/zt9Rp/vGFsey+jndL1y5EnFwzgGOg=,5ee0c7eed83b64cc851d6ddb76346413d7c43213ea1241385b588c66e2169854 +golang.org/x/mod,v0.1.0,h1:sfUMP1Gu8qASkorDVjnMuvgJzwFbTZSeXFiGBYAVdl4=,e0d9b32f6f66103f777e8357b5b60f94a486330d46c6c8ea87789dab1a14cefa +golang.org/x/net,v0.0.0-20191101175033-0deb6923b6d9,h1:DPz9iiH3YoKiKhX/ijjoZvT0VFwK2c6CWYWQ7Zyr8TU=,b07094a5589a436fd98c6700cd5898f2094d9c02f8385f9331a7ace46305c7ae +golang.org/x/oauth2,v0.0.0-20190604053449-0f29369cfe45,h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=,f72b6c3c2b734ad053fadf5fa2adb2ad23024cfeacd567fec31a751526d1dfe0 +golang.org/x/perf,v0.0.0-20180704124530-6e6d33e29852,h1:xYq6+9AtI+xP3M4r0N1hCkHrInHDBohhquRgx9Kk6gI=,a2c7d02cc94c4ba767b6322f70ddcba4941cb5f60fed1bada3aa7a4d3a8128f1 +golang.org/x/sync,v0.0.0-20190911185100-cd5d95a43a6e,h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=,9c63fe51b0c533b258d3acc30d9319fe78679ce1a051109c9dea3105b93e2eef +golang.org/x/sys,v0.0.0-20191029155521-f43be2a4598c,h1:S/FtSvpNLtFBgjTqcKsRpsa6aVsI6iztaz1bQd9BJwE=,c5a8efb84e706e4ec1e1fa5cda44d1d571e8b3f46afe165d5e93b90e777a15fc +golang.org/x/text,v0.3.2,h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=,f755c0e7f4693f170e2f03c161f500b33f82accb8184a38dcfda63fed883f13c +golang.org/x/time,v0.0.0-20191024005414-555d28b269f0,h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=,e0ca5eceb4840bcc264237408ff8942044e19b503d6e8e5546ed9f7e1f4bf82e +golang.org/x/tools,v0.0.0-20191101200257-8dbcdeb83d3f,h1:+QO45yvqhfD79HVNFPAgvstYLFye8zA+rd0mHFsGV9s=,c3beb2acb726571e4cca3e922dd1eb037dcb6ef66ca562e9544716a53b6a1026 +golang.org/x/xerrors,v0.0.0-20191011141410-1b5146add898,h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=,5059c7b7e95f139b8c42d9001972fa5fa688b3581ef946c912c1dbc52415ff16 +gomodules.xyz/envconfig,v1.3.0,h1:w1laMNVtP05uOKqmRAY6Vx7HvfPL9yc388gcVtUiI/M=,ae5b4ee26eeb143c16bfb5316eb97e8ff4418bce379ae74e2a0bba367706d69c +gomodules.xyz/jsonpatch/v2,v2.0.1,h1:xyiBuvkD2g5n7cYzx6u2sxQvsAy4QJsZFCzGVdzOXZ0=,3c97ac5b7cfa3388f3dc157e20e6ad7b7a5789a4df1d5257a39589cf66edd462 +gonum.org/v1/gonum,v0.6.0,h1:DJy6UzXbahnGUf1ujUNkh/NEtK14qMo2nvlBPs4U5yw=,98857b431471c87facf3cd779eadc5d33760c9edee4b56a8228af4b383b90aa2 +gonum.org/v1/netlib,v0.0.0-20190331212654-76723241ea4e,h1:jRyg0XfpwWlhEV8mDfdNGBeSJM2fuyh9Yjrnd8kF2Ts=,ed4dca5026c9ab5410d23bbe21c089433ca58a19bd2902311c6a91791142a687 +gonum.org/v1/plot,v0.0.0-20191004082913-159cd04f920c,h1:Ssc2Jy4xun3/JMt2asledr/xSPAvX7ZZ7HimX2Gwz1w=,9246b6f7a9299061b31d99e50b2ac2685853dc478a6c2c730fada016c7268ea1 +google.golang.org/api,v0.13.0,h1:Q3Ui3V3/CVinFWFiW39Iw0kMuVrRzYX0wN6OPFp0lTA=,4c853034281c673829b7a7f3e39c62640d01895d20a666f003f855ad5f55ec30 +google.golang.org/appengine,v1.6.5,h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=,24ddb4adf72189738dc8340b28f9493a385515e680eb0bfbffe08951412b6655 +google.golang.org/genproto,v0.0.0-20191028173616-919d9bdd9fe6,h1:UXl+Zk3jqqcbEVV7ace5lrt4YdA4tXiz3f/KbmD29Vo=,cb4eec9cf94aa450efbb0d131cf1484f6334f1e8c1e1475b76c3ab2dea76c72a +google.golang.org/grpc,v1.24.0,h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s=,eb4433685a85e20f934c2a98e35d104db2d77abe438a242d75d5aae9f78898fb +google.golang.org/protobuf,v0.0.0-20191101204728-ef19a2a99470,h1:wSgCzfaFwg6Q4Eh+T7XknFfgswhFaeYkEs8t5endA/c=,73a49a6e5fd3330de7364564ab0954146e25ad8bbdff0ea6180f8ace153b0c1b +gopkg.in/Acconut/lockfile.v1,v1.1.0,h1:c5AMZOxgM1y+Zl8eSbaCENzVYp/LCaWosbQSXzb3FVI=,66e89c98908e2b9295de1a32cdd90f626a2468c256ce6182d6339e6659548e71 +gopkg.in/AlecAivazis/survey.v1,v1.8.7,h1:oBJqtgsyBLg9K5FK9twNUbcPnbCPoh+R9a+7nag3qJM=,c924df9f9d79f015cc619b1ecede52c92618c0ab8d020cd63e2c783f46b3907d +gopkg.in/DataDog/dd-trace-go.v1,v1.19.0,h1:aFSFd6oDMdvPYiToGqTv7/ERA6QrPhGaXSuueRCaM88=,f8eb14519d62c80eea88fca1daa69b274a0b492aa8b775890424b48d362c32b3 +gopkg.in/Shopify/sarama.v1,v1.18.0,h1:f9aTXuIEFEjVvLG9p+kMSk01dMfFumHsySRk1okTdqU=,beeb8546c4202289f282529630bc3db4452dc5f7eb69c3d8546196470c7d8be3 +gopkg.in/VividCortex/ewma.v1,v1.1.1,h1:tWHEKkKq802K/JT9RiqGCBU5fW3raAPnJGTE9ostZvg=,fe7800182ce944f2b28834d6cf60c620de0cbba1d691d9442f3473baf2a3d50d +gopkg.in/airbrake/gobrake.v2,v2.0.9,h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo=,2db903664908e5a9afafefba94821b9579bbf271e2929c1f0b7b1fdd23f7bbcf +gopkg.in/alecthomas/gometalinter.v2,v2.0.12,h1:/xBWwtjmOmVxn8FXfIk9noV8m2E2Id9jFfUY/Mh9QAI=,7e6b56f4b985a08d11c1494f9dcc2b595676e787afe7a1caa9c522d41cab9487 +gopkg.in/alecthomas/kingpin.v2,v2.2.6,h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=,638080591aefe7d2642f2575b627d534c692606f02ea54ba89f42db112ba8839 +gopkg.in/alecthomas/kingpin.v3-unstable,v3.0.0-20180810215634-df19058c872c,h1:vTxShRUnK60yd8DZU+f95p1zSLj814+5CuEh7NjF2/Y=,0e35a5bb02770611e4c53c611529b95b96d0bc573f05d10bb43f7441abef2fde +gopkg.in/alexcesaro/quotedprintable.v3,v3.0.0-20150716171945-2caba252f4dc,h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=,1a310c5e55038937be3e69765276449601ca582f681129f7d9d47e052846cafc +gopkg.in/asn1-ber.v1,v1.0.0-20181015200546-f715ec2f112d,h1:TxyelI5cVkbREznMhfzycHdkp5cLA7DpE+GKjSslYhM=,fee158570ba9cbfc11156afbe9b9ab0833ab00d0f1a2a2af29a6325984a79903 +gopkg.in/bblfsh/sdk.v1,v1.17.0,h1:Ez/4P0S0Zaq30iZKfiTlhOtqMx6dfQHMTYpqKFvnv4A=,172521b9f2bdd4180751ed5122971c9c37a8c0bca2e0710bc255bc0e5ff8c106 +gopkg.in/bblfsh/sdk.v2,v2.16.4,h1:Ta/kBVRGXf8UOBYDw/ih8mw13/8NND+AdR0JiXBQrOw=,eb7a8a7d08bd80cd0673a6b9c90fa524bda9db24242bd6ef82fb414941c4ef0f +gopkg.in/bsm/ratelimit.v1,v1.0.0-20160220154919-db14e161995a,h1:stTHdEoWg1pQ8riaP5ROrjS6zy6wewH/Q2iwnLCQUXY=,fea8af18591a0ac50d29c8db124d13a43da6bee7a624c411b7449a99ee87b489 +gopkg.in/bufio.v1,v1.0.0-20140618132640-567b2bfa514e,h1:wGA78yza6bu/mWcc4QfBuIEHEtc06xdiU0X8sY36yUU=,9d63fe986f79edba7fca9bcd3bee0c7dcff7787cd30b43b5f2ae8a59feae512c +gopkg.in/check.v1,v1.0.0-20190902080502-41f04d3bba15,h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=,004537cb19dbe45954ec1605f331705f6685ccc267eddd4289c1eb27513ab817 +gopkg.in/cheggaaa/pb.v1,v1.0.28,h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk=,39725f9f37aac44dd55bdc9ade65a2d066953a090456298d34203257fc7e8ee9 +gopkg.in/cheggaaa/pb.v2,v2.0.7,h1:beaAg8eacCdMQS9Y7obFEtkY7gQl0uZ6Zayb3ry41VY=,a6ba73f81893f0eca8c0a60c238a705a12bae499a44fe6217a4471687766ef02 +gopkg.in/clog.v1,v1.2.0,h1:BHfwHRNQy497iBNsRBassPixSAxRbn2z5KVkdBFbwxc=,51eb8901943d1cec850b55556a9989e21488a9636ac692d6f7575db057804f3d +gopkg.in/editorconfig/editorconfig-core-go.v1,v1.3.0,h1:oxOEwvhxLMpWpN+0pb2r9TWrM0DCFBHxbuIlS27tmFg=,b5371885f56b40c03da4fd05006c717fabdfb8ee9ea1ceef4cc5b7caeda35041 +gopkg.in/errgo.v1,v1.0.1,h1:oQFRXzZ7CkBGdm1XZm/EbQYaYNNEElNBOd09M6cqNso=,32f45f7cfacfc04ae9e7e8c9fc55a53812554799da7c2bd17b043068b5fd5171 +gopkg.in/errgo.v2,v2.1.0,h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=,6b8954819a20ec52982a206fd3eb94629ff53c5790aa77534e6d8daf7de01bee +gopkg.in/fatih/color.v1,v1.7.0,h1:bYGjb+HezBM6j/QmgBfgm1adxHpzzrss6bj4r9ROppk=,ed20c58de8c575144c2cc1c924121ee1a240e0621c77918231547b576d46d3ce +gopkg.in/fatih/set.v0,v0.2.1,h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY=,d743141e21d20f6d5ae8e784dd4644c0947948103b63404a878b0298f14a9e62 +gopkg.in/fsnotify.v1,v1.4.7,h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=,ce003d540f42b3c0a3dec385deb387b255b536b25ea4438baa65b89458b28f75 +gopkg.in/fsnotify/fsnotify.v1,v1.4.7,h1:XNNYLJHt73EyYiCZi6+xjupS9CpvmiDgjPTAjrBlQbo=,6f74f844c970ff3059d1639c8a850d9ba7029dd059b5d9a305f87bd307c05491 +gopkg.in/gavv/httpexpect.v1,v1.0.0-20170111145843-40724cf1e4a0,h1:r5ptJ1tBxVAeqw4CrYWhXIMr0SybY3CDHuIbCg5CFVw=,4fe4a5e78a26ac5b60fc16405d3a5918d83cd645d36bd9dc0d558824136930b6 +gopkg.in/gcfg.v1,v1.2.3,h1:m8OOJ4ccYHnx2f4gQwpno8nAX5OGOh7RLaaz0pj3Ogs=,06cdad29610507bafb35e2e73d64fd7aa6c5c2ce1e5feff30a622af5475bca3b +gopkg.in/gemnasium/logrus-airbrake-hook.v2,v2.1.2,h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0=,ce35c69d2a1f49d8672447bced4833c02cc7af036aa9df94d5a6a0f5d871cccd +gopkg.in/go-playground/assert.v1,v1.2.1,h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=,11da2f608d82304df2384a2301e0155fe72e8414e1a17776f1966c3a4c403bc4 +gopkg.in/go-playground/validator.v8,v8.18.2,h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ=,fea7482c7122c2573d964b7d294a78f2162fa206ccd4b808d0c82f3d87b4d159 +gopkg.in/go-playground/validator.v9,v9.30.0,h1:Wk0Z37oBmKj9/n+tPyBHZmeL19LaCoK3Qq48VwYENss=,f4769db84ddc2db880bc190a5420762ef45f80ebbce678b622c4fa82b422b890 +gopkg.in/gobwas/glob.v0,v0.2.3,h1:uLMy+ys6BqRCutdUNyWLlmEnd7VULqh1nsxxV1kj0qQ=,3a5fe045be1ff9b47c5e21a9f97bdefaada31463f365503d6b176b76e18a0257 +gopkg.in/gographics/imagick.v3,v3.2.0,h1:eUwlkCw2fa20OGu47G39Im8c50S9n/CVkh8PwtOKExA=,99695d22cf7d5609887609cc9dc63ca1031b5a3238c26f6b779f32e39d572a01 +gopkg.in/gomail.v2,v2.0.0-20160411212932-81ebce5c23df,h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=,08b3372836aef3a403b0a01e6867a3a2252a07f65c28e0d33fe9c4b1b3ac517a +gopkg.in/gorp.v1,v1.7.2,h1:j3DWlAyGVv8whO7AcIWznQ2Yj7yJkn34B8s63GViAAw=,eaad3325e8b5358d5d54a1ca8b1e6aa19d16968a1f11f3dc45671588d914ef25 +gopkg.in/guregu/null.v3,v3.4.0,h1:AOpMtZ85uElRhQjEDsFx21BkXqFPwA7uoJukd4KErIs=,b38d62a816c5905933396a02eb11e23cbe2c17f8837563cc10794274e5af7e6e +gopkg.in/h2non/gentleman.v2,v2.0.3,h1:exsUPKJDFwNjJykboVj8+BKPWMNOxR/AmPL3f7Hutwo=,7a71dc2dd74e413832782e4478f85cc0617aed125e078e308b46207f34d6a500 +gopkg.in/h2non/gock.v1,v1.0.15,h1:SzLqcIlb/fDfg7UvukMpNcWsu7sI5tWwL+KCATZqks0=,c6a3d33e638b56ddd050c1dc6c1c6c8e9007c70cacfcc29e778fcf421f1fc029 +gopkg.in/httprequest.v1,v1.2.0,h1:YTGV1oXzaoKI6oPzQ0knoIPcrrVzeRG3amkoxoP7Xng=,3960019870090d0de3fca818633111186d46a908b4bcac6d87e5f08e7fb58770 +gopkg.in/inconshreveable/log15.v2,v2.0.0-20180818164646-67afb5ed74ec,h1:RlWgLqCMMIYYEVcAR5MDsuHlVkaIPDAF+5Dehzg8L5A=,799307ed46ca30ca0ac2dc0332f3673814b8ff6cc1ee905a462ccfd438e8e695 +gopkg.in/inf.v0,v0.9.1,h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=,08abac18c95cc43b725d4925f63309398d618beab68b4669659b61255e5374a0 +gopkg.in/ini.v1,v1.49.0,h1:MW0aLMiezbm/Ray0gJJ+nQFE2uOC9EpK2p5zPN3NqpM=,579074067ceacbf11e938940d65647094da4f23f627645b5c58218bf05c060f0 +gopkg.in/jarcoal/httpmock.v1,v1.0.0-20181117152235-275e9df93516,h1:H6trpavCIuipdInWrab8l34Mf+GGVfphniHostMdMaQ=,5b896c9e5e44146260a066533409c1b86268458301a7155624ef27f784e5d94a +gopkg.in/jcmturner/aescts.v1,v1.0.1,h1:cVVZBK2b1zY26haWB4vbBiZrfFQnfbTVrE3xZq6hrEw=,8bfd83c7204032fb16946202d5d643bd9a7e618005bd39578f29030a7d51dcf9 +gopkg.in/jcmturner/dnsutils.v1,v1.0.1,h1:cIuC1OLRGZrld+16ZJvvZxVJeKPsvd5eUIvxfoN5hSM=,4fb8b6a5471cb6dda1d0aabd1e01e4d54cb5ee83c395849916392b19153f5203 +gopkg.in/jcmturner/goidentity.v3,v3.0.0,h1:1duIyWiTaYvVx3YX2CYtpJbUFd7/UuPYCfgXtQ3VTbI=,1be44bee93d9080ce89f40827c57e8a396b7c801e2d19a1f5446a4325afa755e +gopkg.in/jcmturner/gokrb5.v7,v7.2.3,h1:hHMV/yKPwMnJhPuPx7pH2Uw/3Qyf+thJYlisUc44010=,3eec5b25adb89633174beb9798d8092e91ff4eed146a4b4cb950dd02414bd75e +gopkg.in/jcmturner/rpc.v1,v1.1.0,h1:QHIUxTX1ISuAv9dD2wJ9HWQVuWDX/Zc0PfeC2tjc4rU=,83d897b60ecb5a66d25232b775ed04c182ca8e02431f351b3768d4d2876d07ae +gopkg.in/jmcvetta/napping.v3,v3.2.0,h1:NpSZLAL6VgiyhdqaOkxwVtHXOLrQJZ6fFOMQgp7G8PQ=,887358529a8cd287b6a8232b43cc48636463fa266bac5ba48328cb0609d1dcb6 +gopkg.in/juju/charm.v6,v6.0.0-20191031115626-f595bfd8a049,h1:+isWLR3tDZyDacru13gHH0ooIuuDB28kuZJjSc8kOqU=,8d404b146f31d35148015de3f5bd4d25260f0a4b9f22a540a9167864d9e5d082 +gopkg.in/juju/charmrepo.v3,v3.0.1,h1:mm7/CwCczsO7JYHlYkw4iCUYR7X8upEOaY5bYj7eUkw=,8f673109a6d98e4abe4ef612f85dea26bdbd7de5c66b6722c546a08aefb548fc +gopkg.in/juju/environschema.v1,v1.0.0,h1:51vT1bzbP9fntQ0I9ECSlku2p19Szj/N2beZFeIH2kM=,46ae8efc5a450745fea959dc8532d2a013aa741ab7193d3cea8b0735f09c6e8a +gopkg.in/juju/names.v2,v2.0.0-20190813004204-e057c73bd1be,h1:xDxN+Fe8olIH8sTqvFJBMsuflBYzeHVeYC4Iz97+f5M=,72ac554c125260751aadf6d41eb82d85de22ef8bff1d59c6602e9e0f5b84a28c +gopkg.in/juju/worker.v1,v1.0.0-20191018043616-19a698a7150f,h1:UAHa7z4EdrOcMN+9p5P+ojJshcIC34vwi0hCmEL6Qf8=,2e0da8053029ca9da961f8e6f1037a9d7ba12623e5c16fc5f88bf1a724c5dd23 +gopkg.in/karalabe/cookiejar.v2,v2.0.0-20150724131613-8dcd6a7f4951,h1:DMTcQRFbEH62YPRWwOI647s2e5mHda3oBPMHfrLs2bw=,07aae15601f54a5806705d218e313794118d54d9dda7addc1bf4bda4332dfc16 +gopkg.in/kothar/go-backblaze.v0,v0.0.0-20190520213052-702d4e7eb465,h1:DKgyTtKkmpZZesLue2fz/LxEhzBDUWg4N8u/BVRJqlA=,215300ce3726c40f51ee43c41a27c204441e756c8cb4f4b76b1a4dd08f509eef +gopkg.in/ldap.v2,v2.5.1,h1:wiu0okdNfjlBzg6UWvd1Hn8Y+Ux17/u/4nlk4CQr6tU=,4fd426691e674164a701ef3ec3548596574f95447cde1fa331018f7d73f8399b +gopkg.in/ldap.v3,v3.0.2,h1:R6RBtabK6e1GO0eQKtkyOFbAHO73QesLzI2w2DZ6b9w=,f79d1cb87a0a6d571e671c2028409056d65e6bfa7d3d0563ded0edbe8ff0998e +gopkg.in/macaron.v1,v1.3.4,h1:HvIscOwxhFhx3swWM/979wh2QMYyuXrNmrF9l+j3HZs=,f9aca15b099dada4382e47898516d500876aae45d36895314cde86700636c05c +gopkg.in/macaroon-bakery.v2,v2.1.0,h1:9Jw/+9XHBSutkaeVpWhDx38IcSNLJwWUICkOK98DHls=,0a12f46df7290b131ee74ec6a4d4760170192920a091939aa2d7a39a4d0fb310 +gopkg.in/macaroon-bakery.v2-unstable,v2.0.0-20171026135619-38b77b89a624,h1:FIOL4YpoNbXH6K+LnOoAEMa/1ebliK7B9mj5NuJHmiA=,51476e40e03bd1f64fd3cdf936d1cde4b8c1395884af9376ff65755041c247aa +gopkg.in/macaroon.v2,v2.1.0,h1:HZcsjBCzq9t0eBPMKqTN/uSN6JOm78ZJ2INbqcBQOUI=,ae47a93d20ce5c053eafc9d6a76c01b2b06784f9886137dc73a99302928046eb +gopkg.in/macaroon.v2-unstable,v2.0.0-20180319203259-5c9beabe0e9e,h1:yPxshueS06kvTVlsymSbHvk6VQ1WhX1Ou3hCqqWBp/s=,e09a1f8268d65e3dc28da85c75e78f15f1f742d1dcd31cce427fd885b1962bc4 +gopkg.in/mail.v2,v2.0.0-20180731213649-a0242b2233b4,h1:a3llQg4+Czqaf+QH4diHuHiKv4j1abMwuRXwaRNHTPU=,d7d60701b95fd7f62d3f83bc026f42c0fa69c3f16cc445d2b20497c9dd182ff6 +gopkg.in/mattes/migrate.v1,v1.3.2,h1:tWus4MPMhDY/htX+NCvASiQVRU2pj4Jyj4T8AIv6vUw=,c50f590108871c25d55631addd6bc267f311830d4306ff4d36a6feaad0b23255 +gopkg.in/mattn/go-colorable.v0,v0.1.0,h1:WYuADWvfvYC07fm8ygYB3LMcsc5CunpxfMGKawHkAos=,337a25f7f87a87097e5fb853313c1fac3d3126ed0eb9bb88511d52ba9a0eb4e0 +gopkg.in/mattn/go-isatty.v0,v0.0.4,h1:NtS1rQGQr4IaFWBGz4Cz4BhB///gyys4gDVtKA7hIsc=,18500935e08e5b74487537b8b78a30778a5b2304a138f53aa8758b86266773ff +gopkg.in/mattn/go-runewidth.v0,v0.0.4,h1:r0P71TnzQDlNIcizCqvPSSANoFa3WVGtcNJf3TWurcY=,e0307a435e39658f761b7526dda9149e7664b7250958494c1a4eebd14884b82d +gopkg.in/mcuadros/go-syslog.v2,v2.2.1,h1:60g8zx1BijSVSgLTzLCW9UC4/+i1Ih9jJ1DR5Tgp9vE=,1f444e24504b6a21c0d204441a84336ab1240f77a1280b60e48f68ea1b99da7b +gopkg.in/mgo.v2,v2.0.0-20190816093944-a6b53ec6cb22,h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw=,14edbec0d97107b0e0980b66166400f8a4c3844b03bd3240fc57be2b82734b16 +gopkg.in/natefinch/lumberjack.v2,v2.0.0,h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=,8c268e36660d6ce36af808d74b9be80207c05463679703e93d857e954c637aaa +gopkg.in/neurosnap/sentences.v1,v1.0.6,h1:v7ElyP020iEZQONyLld3fHILHWOPs+ntzuQTNPkul8E=,e3df38d6fc6097f9d1d76ee13e24fec69103c43248ca6a7f3ade2afec5e85bdd +gopkg.in/ns1/ns1-go.v2,v2.0.0-20190730140822-b51389932cbc,h1:GAcf+t0o8gdJAdSFYdE9wChu4bIyguMVqz0RHiFL5VY=,c51d0889ff5eb72df2f9e4adc28e9f3602e6eb567c3824bebb3c7d315a60710a +gopkg.in/olivere/elastic.v2,v2.0.61,h1:7cpl3MW8ysa4GYFBXklpo5mspe4NK0rpZTdyZ+QcD4U=,0a20d84f6003850343937ef79179cabe99feef9b038c281fd65ec32ec6c7e85c +gopkg.in/olivere/elastic.v5,v5.0.82,h1:QH7ere4lvOAWnnOd0VLJ54W8LzExZszoGIRijnb1h2Y=,3c66a7606b226d19f61651b3ad58aecda3155edc802029bd21cd4b8724bd0c9f +gopkg.in/ory-am/dockertest.v3,v3.3.4,h1:oen8RiwxVNxtQ1pRoV4e4jqh6UjNsOuIZ1NXns6jdcw=,73b01a1d025d30c8f11def182179b873410eae72f7b2fd9f9394b0fcf4683c93 +gopkg.in/redis.v2,v2.3.2,h1:GPVIIB/JnL1wvfULefy3qXmPu1nfNu2d0yA09FHgwfs=,abe2fa39afa36f8186ee287bcf82f9f4bc083aa35d17dd82a2ccbf5850ecdde8 +gopkg.in/redis.v3,v3.6.4,h1:u7XgPH1rWwsdZnR+azldXC6x9qDU2luydOIeU/l52fE=,749ef3e08eb4eda43969f88135040ae4517b450b27dbd48aefb9bf5e72465621 +gopkg.in/redis.v4,v4.2.4,h1:y3XbwQAiHwgNLUng56mgWYK39vsPqo8sT84XTEcxjr0=,6403d2b45edf2804bfd07b6d697184fc97377168589ad43ad19b2433e1dcee34 +gopkg.in/redis.v5,v5.2.9,h1:MNZYOLPomQzZMfpN3ZtD1uyJ2IDonTTlxYiV/pEApiw=,3c30e42670d1ef5f0b33876928b3bd5693ef3b5be1df6b2710d48c2667ca7133 +gopkg.in/resty.v1,v1.12.0,h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI=,43487bb0bb40626d16502b1fe9e719cf751e7a5b4e4233276971873e7863d3cf +gopkg.in/robfig/cron.v2,v2.0.0-20150107220207-be2e0b0deed5,h1:E846t8CnR+lv5nE+VuiKTDG/v1U2stad0QzddfJC7kY=,b25da9b8747e664334044e581d1a8fb700237239e7f182fd226d6296e6180bc0 +gopkg.in/satori/go.uuid.v1,v1.2.0,h1:AH9uksa7bGe9rluapecRKBCpZvxaBEyu0RepitcD0Hw=,794cefc3062e09b17f4300eb6b02622ac348af9d368341ff71a655a15884547f +gopkg.in/sourcemap.v1,v1.0.5,h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI=,05b5f382bfa60212f444c7207168e9eb0c722e26b57a688123cb8bbf234de692 +gopkg.in/spacemonkeygo/monkit.v2,v2.0.0-20190623001553-09813957f0a8,h1:nyw4hxw2zz4S0EHqr5nQfA3zGbMFJDRJlQPM4PCb7O4=,4a8e607c4f16b32bb9ee380627716979b19ac3df74ca2a4f80aefbaf0b411784 +gopkg.in/square/go-jose.v2,v2.4.0,h1:0kXPskUMGAXXWJlP05ktEMOV0vmzFQUWw6d+aZJQU8A=,d00c4af5a633ab9cf7645b68f6fa389c8f0d9ffebc486742c7a5292280cae84b +gopkg.in/src-d/go-billy.v4,v4.3.2,h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=,c49871e1d08bba07b2261626b929096b6dc5c839e781adfc24fcc410067cc2bf +gopkg.in/src-d/go-cli.v0,v0.0.0-20181105080154-d492247bbc0d,h1:mXa4inJUuWOoA4uEROxtJ3VMELMlVkIxIfcR0HBekAM=,86042ffc0c8492845917453682c5bdba46beb2f0c067b61e495a92b9a8621076 +gopkg.in/src-d/go-errors.v1,v1.0.0,h1:cooGdZnCjYbeS1zb1s6pVAAimTdKceRrpn7aKOnNIfc=,f7d9f00c057d4b49bc6e57167561a7fb508ebb113a1946cb2b6f71dac5b14cfb +gopkg.in/src-d/go-git-fixtures.v3,v3.5.0,h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=,282dc6474c5ecf62c1169d04ad1f6d75e6058922897b4709a16a1007a5f22eb7 +gopkg.in/src-d/go-git.v4,v4.13.1,h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=,13364fe60f2316a179e912fb4eb6c576e2aabd67e8d390651a155e85c69146d2 +gopkg.in/src-d/go-log.v1,v1.0.1,h1:heWvX7J6qbGWbeFS/aRmiy1eYaT+QMV6wNvHDyMjQV4=,48f6c8a7bdc5436d296f388cd5d40ffb9c749e1e4ab1e455984efc61008fd5d7 +gopkg.in/stack.v0,v0.0.0-20141108040640-9b43fcefddd0,h1:lMH45EKqD8Nf6LwoF+43YOKjOAEEHQRVgDyG8RCV4MU=,a88c4cb4af34bb5c4dd69d0c771829331be7416d2f18d58ff599126f7b291984 +gopkg.in/stretchr/testify.v1,v1.2.2,h1:yhQC6Uy5CqibAIlk1wlusa/MJ3iAN49/BsR/dCCKz3M=,0126e73e5f2ce5687dec597bb276e11dc4031dbdf199e68de735bc67bf808149 +gopkg.in/telegram-bot-api.v3,v3.0.0,h1:Y6QmqOMwRKv5NUdlvzEBtEZChjsrqdTS6O858cvuCww=,03c58e32567a5cc4ec631cc226ecc99dd1113a7a98bab4778b02cde073ab5ed4 +gopkg.in/telegram-bot-api.v4,v4.6.4,h1:hpHWhzn4jTCsAJZZ2loNKfy2QWyPDRJVl3aTFXeMW8g=,01a91b240fb416bf83bcaaa07133cafac28fd8eb8f0f251f6a616beec88c92ac +gopkg.in/testfixtures.v2,v2.5.0,h1:N08B7l2GzFQenyYbzqthDnKAA+cmb17iAZhhFxr7JHw=,05baac4af6e2855d296a5c045b27deb1b33d0a04cd0df96f029927f0742765a3 +gopkg.in/tomb.v1,v1.0.0-20141024135613-dd632973f1e7,h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=,34898dc0e38ba7a792ab74a3e0fa113116313fd9142ffb444b011fd392762186 +gopkg.in/tomb.v2,v2.0.0-20161208151619-d5d1b5820637,h1:yiW+nvdHb9LVqSHQBXfZCieqV4fzYhNBql77zY0ykqs=,15d93d96e1e8b2d8daf7b9e57a2a9193c0e676a2c6b63d9325bf34b53e93db00 +gopkg.in/tylerb/graceful.v1,v1.2.15,h1:1JmOyhKqAyX3BgTXMI84LwT6FOJ4tP2N9e2kwTCM0nQ=,0a8639cfe62508438ebf2cae721468b64d8cd2992fc0f80439c83c718f4608e0 +gopkg.in/urfave/cli.v1,v1.20.0,h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0=,413704688402027dc0f51666bac42152eb1668a73fa0e33858c3d2123c0592e5 +gopkg.in/warnings.v0,v0.1.2,h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=,c412b1f704c1e8ba59b6cfdb1072f8be847c03f77d6507c692913d6d9454e51c +gopkg.in/yaml.v1,v1.0.0-20140924161607-9f9df34309c0,h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU=,7abff7973fdab7386de5a1e9e197d8dc50d41ded9d24ff914685900caa0eb742 +gopkg.in/yaml.v2,v2.2.4,h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=,815be785649ae218b51efd8e40b3b75de8f9b57dd43162386ffe3e76709f2a5d +gorgonia.org/tensor,v0.9.2,h1:bVTWB68apbLfdrAlz5Ev3daGhfOhKuPkVFacMSNzpHs=,17562e7c1c6477b8b530d6236ab9a61228edbabe01c1cfb9ba23286c2394ba4c +gorgonia.org/vecf32,v0.9.0,h1:PClazic1r+JVJ1dEzRXgeiVl4g1/Hf/w+wUSqnco1Xg=,618df2e604236a2d143958a3571f9939c8264ab2aaae7d8c71b897b728240a23 +gorgonia.org/vecf64,v0.9.0,h1:bgZDP5x0OzBF64PjMGC3EvTdOoMEcmfAh1VCUnZFm1A=,f57695832a12a6f1fbcc04cdaa267ed01fb6b8105f518590d64b2c63b9ac4c61 +gotest.tools,v2.2.0+incompatible,h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=,55fab831b2660201183b54d742602563d4e17e7125ee75788a309a4f6cb7285e +grpc.go4.org,v0.0.0-20170609214715-11d0a25b4919,h1:tmXTu+dfa+d9Evp8NpJdgOy6+rt8/x4yG7qPBrtNfLY=,58b5c3cccf3e765d0f42918d458cddcd03fc28ff5d701790783677513a8446e3 +h12.io/socks,v1.0.0,h1:oiFI7YXv4h/0kBNcmAb5EkkoFJgYsOF88EQjMBxjitc=,3bf83125284ccabf811aa238954b442e39f53e3e068d4ddb6bf679ba2be28bbe +honnef.co/go/js/dom,v0.0.0-20190526011328-ebc4cf92d81f,h1:b3Q9PqH+5NYHfIjNUEN+f8lYvBh9A25AX+kPh8dpYmc=,a65720d9c0339450c8818226693a85986549fb156ee4df65913682c350bd4d60 +honnef.co/go/js/util,v0.0.0-20150216223935-96b8dd9d1621,h1:QBApQyt1KyR3SvDWU8sHcIXeWTSCUamO7xQopvwuLWI=,db5638addc7638cc5cf2245cb9bcb19cf04a5912120330560149b54b4575ae50 +honnef.co/go/js/xhr,v0.0.0-20150307031022-00e3346113ae,h1:2dIKMawnBWvHzZrS8STyu/KdhYIOpnKQpp1WZm+K7TE=,d2a4a85c43fb4ccd9b5be6521450d272406a1722f7547f188f4a1d0cc65c4e13 +honnef.co/go/tools,v0.0.1-2019.2.3,h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=,539825114c487680f99df80f6107410e1e53bbfd5deb931b84d1faf2d221638e +howett.net/plist,v0.0.0-20181124034731-591f970eefbb,h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=,58c94cd949be714c0ee320d1be0cff3116fc829c412b9e7b816b03fb3c85f463 +istio.io/api,v0.0.0-20191029012234-9fe6a7da3673,h1:wxFykuQoScKAnEtKujAPqjwR8Aqo2LNtkoIvodxyCSs=,9ba545b9c5411725b709287b590082d140d3b29d924be351e38942f46c33ff55 +istio.io/gogo-genproto,v0.0.0-20190930162913-45029607206a,h1:w7zILua2dnYo9CxImhpNW4NE/8ZxEoc/wfBfHrhUhrE=,3b5a81f1807f48117d6691c8d007402a94b648f45f4446841a3f56229aa94aba +istio.io/pkg,v0.0.0-20191029184635-5c2f5ef63692,h1:MT7e5hpQ8cGtKCeWIjtdluEVkIhkN2tw4iVkAzhWHYA=,887882f7e721e6d00dee301f0b029792bd04bd38c455ab7e5cf4f2bc5bf309df +k8s.io/api,v0.0.0-20191031065753-b19d8caf39be,h1:X0MqzqUHuZj50SrMQFExejJfy67RKPf30Vt2nnpa4AA=,00a67ed9b84be18f621701796b42cee630c770c858582753fe0eb9c146ef93ff +k8s.io/apiextensions-apiserver,v0.0.0-20191028232452-c47e10e6d5a3,h1:XxkWdWvPKTParJ1sXpUIvHJsJ2iIIj5Ebjxxy5YU1Zo=,2cb12eb8b2b0f95fb5d69b1f80b754b32ae46ef1f9636333fe27c6b17b1a6e19 +k8s.io/apimachinery,v0.0.0-20191030190112-bb31b70367b7,h1:81UYA9Qq3JXPpZMmRBnq6T3qU+b71Dvnm6sV3NSQTVk=,4c16a440acf7559b0974d99650c876969ad4811ddc76f9f5b7aa43afc34f66ec +k8s.io/apiserver,v0.0.0-20191031110436-8cb875160ee0,h1:BGkQMPpKpx07hvq9AW64gifbf+zbAh/xUbB5OYXPvQ0=,baefad9177a1f8077c94a2d88b7e85deb7df79317d3d6d6afe8ca0be8261b1ae +k8s.io/cli-runtime,v0.0.0-20191025231729-08207da42a69,h1:05z+vSvn9yPr7GTAt3MXpVc9VeU4D80HHwvJU6jC3D4=,46264219a6e1c8263acd610841a156086bbbdd43436a836effcd7285c37b0e8a +k8s.io/client-go,v11.0.0+incompatible,h1:LBbX2+lOwY9flffWlJM7f1Ct8V2SRNiMRDFeiwnJo9o=,70925f536d409accf4f6ae3f20dafd81370ac096f848e99009141bea971103c2 +k8s.io/cloud-provider,v0.0.0-20191025232453-66dd06a864dd,h1:CxSfhPPmLwYFZquskmKvODMeEm82ZLc4eph47AdUp+o=,55623701c005f824ae847ecad409c6e61ef5fcfc6588b8dd2995a4a0991eeae8 +k8s.io/cluster-bootstrap,v0.0.0-20191025232351-410fafc3baf5,h1:P1mMVQngKW9pj1haVjyAtqViIBqkJmsITXsfuaHGRko=,ff50816340cdb73313e7233c3ff6df383c350102762b88ea0cc744910053c7bd +k8s.io/code-generator,v0.0.0-20191029223907-9f431a56fdbc,h1:klQ4aWfZ3uk4UiSLkZZt5qQDI+7DwSdvbvyL5QUBHsQ=,1f63d3191c255d8fcc47ad24b3bd979865a3c12eca678b39f278c194c2ae560a +k8s.io/component-base,v0.0.0-20191029070825-5e0e35147053,h1:W9/+uFw7olz+qQOCmSOG92c6j2YgIwagxqR9RWai/cE=,45bd9877048a57c3dfe7eb9c98bc1939775c73fdd6451afd055d7e4f7b9659bc +k8s.io/cri-api,v0.0.0-20191025232916-446748cffdda,h1:HVTA1bXCQek+NF0xTZkryScnkGYWHkoeYAQVEVs73r8=,7aea277309740df8d1fad1c620901d60633569d755d2d0715d97bc553988d7be +k8s.io/csi-api,v0.0.0-20190313123203-94ac839bf26c,h1:m3xih+9aI7l7Z/PvwzizV1J4vBvaUpkHrmagnGa5UNg=,0579fba2111dfd5b3cb62d7d234e52c54051176d9564ae3f0f2fdc69b31872b0 +k8s.io/gengo,v0.0.0-20191010091904-7fa3014cb28f,h1:eW/6wVuHNZgQJmFesyAxu0cvj0WAHHUuGaLbPcmNY3Q=,7fe69109e947204ee0b95705626e3c3b540faefb947d3426260f2991d1e4c036 +k8s.io/helm,v2.15.2+incompatible,h1:UjEb+c5BUZDGR9zU3dWG3OXASLIeqLeY0FCIx6ZyfTY=,377860d9db9fb1d45ffa90fe6ee79d7cfc4e91e5bc04183921480a823cf79ede +k8s.io/klog,v1.0.0,h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=,a564b06078ddf014c5b793a7d36643d6fda31fc131e36b95cdea94ff838b99be +k8s.io/kube-aggregator,v0.0.0-20191025230902-aa872b06629d,h1:ls0BmbSFkF5BhZN7grE+W5/X49QMU42RH6J9DWdP7UQ=,9a51f29a98f603acde33e3a10625e9ab603d7db29b3c2b2256d145adf7396393 +k8s.io/kube-controller-manager,v0.0.0-20191025232249-6de08162fd59,h1:bTAKwqwK2HvJVmpowb/ccyeV3wsxQZUtFQE1AqhMZ6I=,a1183bb172f19f6ae319da09c111a3f5dded663a9be85e18b9bceb131f03a342 +k8s.io/kube-openapi,v0.0.0-20190918143330-0270cf2f1c1d,h1:Xpe6sK+RY4ZgCTyZ3y273UmFmURhjtoJiwOMbQsXitY=,fb1dcd1508144991be0a243cea9a066944775ba4e9fa23c7ea038822e4e8e232 +k8s.io/kubelet,v0.0.0-20191025232041-e9c3b1e8a9ed,h1:ISiRMWhiLjmSsx24QQ6NJSgW1oKmAN59LCFzB7llrSk=,8c409ac5922dfb4cb0b8e6bb52823b2132e82faa3756dc3a94cdeabeaa3ff51e +k8s.io/kubernetes,v1.11.10,h1:wCo67+wmguioiYv0ipIiTaXbVPfFBBjOTgIngeGGG+A=,7c8ca4ca473e9f2b5c6586a714209e98d99f193af84cdb3e8536a3d1e26be4bf +k8s.io/metrics,v0.0.0-20191026071343-a166cc0bce8f,h1:D4AcfwGLY2gFDQaeK2QVyb8g4fy4Xzs0GopdwAgfSGc=,f4243455881a38d4962483ba5f2888220743a6ddece179c2b8f706815b75778f +k8s.io/node-api,v0.0.0-20191025232816-761e5a80fde0,h1:V3FaBxwSQWPjPScXd5ioFx9+aREXGU24yFl8Gm7ib8w=,cb8718b6e148a66097f8cae4e4544dc55c674748202f9c21d07a2139b6e83fd1 +k8s.io/sample-apiserver,v0.0.0-20191030110742-cbfc6c263d7e,h1:9bsKcUCncu1Qg3A4pB5ZySTM0JMEZW4qgybjVhmaS4A=,91d701af12da2ff6cde6f07d53547885faafa32c2eadfa8d4614b4d814a854b9 +k8s.io/sample-controller,v0.0.0-20191025231305-d7b8b8302943,h1:ZYb6if7+Qa5kXFidUsQRLFDyZjCjRyG1sFf6GpZaA70=,07c3e3a95d0fac07a247a98c38448a8fc4ab0069ad599ec06ac9405df88b470b +k8s.io/utils,v0.0.0-20191030222137-2b95a09bc58d,h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8=,e21be6d971127d4650bd13525a2d2627b2a98dbb8589f168b734a45d50f3ea22 +launchpad.net/gocheck,v0.0.0-20140225173054-000000000087,h1:Izowp2XBH6Ya6rv+hqbceQyw/gSGoXfH/UPoTGduL54=,1a1d9b10f2c69564e69993e4340d5299392a518d895ec06502e842e6c69f4857 +layeh.com/radius,v0.0.0-20190322222518-890bc1058917,h1:BDXFaFzUt5EIqe/4wrTc4AcYZWP6iC6Ult+jQWLh5eU=,5eb6b6a05a5f89bc114f37085deda268f895a46621aee2e36649b8d80061357e +leb.io/aeshash,v0.0.0-20190627052759-9e6b40329b3b,h1:MG17Tc0pA3XmFTsPwklMMEfcos3pTFnVYM4A0YfVSbU=,a78b48ac18e98ea68dacce16cd94c9074688a0b125f824f047313a33b264ea88 +leb.io/hashland,v0.0.0-20171003003232-07375b562dea,h1:s9IkzZTqYqw77voO6taUZHc0C1B096h4T/kQtujGApE=,0698177f24cbde0a7b45495e7fe976fe7623f2b9205995b7d91fd2e7b0f0e243 +leb.io/hrff,v0.0.0-20170927164517-757f8bd43e20,h1:9CHS8LIq9MDwUsAaCHUsbUq7zb5lSjLQYWlJ/AbMZKg=,538008712599401a903a7982714c0a9ae745221042d3dfb1437bc508d8fb9e96 +modernc.org/cc,v1.0.0,h1:nPibNuDEx6tvYrUAtvDTTw98rx5juGsa5zuDnKwEEQQ=,24711e9b28b0d79dd32438eeb7debd86b850350f5f7749b7af640422ecf6b93b +modernc.org/golex,v1.0.0,h1:wWpDlbK8ejRfSyi0frMyhilD3JBvtcx2AdGDnU+JtsE=,335133038991d7feaba5349ac2385db7b49601bba0904abf680803ee2d3c99df +modernc.org/mathutil,v1.0.0,h1:93vKjrJopTPrtTNpZ8XIovER7iCIH1QU7wNbOQXC60I=,766ad95195543fe1ac217ce9f54e1fb43119c25db2b89013b9ef5477ad2dd9d1 +modernc.org/strutil,v1.0.0,h1:XVFtQwFVwc02Wk+0L/Z/zDDXO81r5Lhe6iMKmGX3KhE=,4bbca362df97450c6f24b90b7dc80b97ecf19e5f0f5954655b26f335a0b8f378 +modernc.org/xc,v1.0.0,h1:7ccXrupWZIS3twbUGrtKmHS2DXY6xegFua+6O3xgAFU=,ef80e60acacc023cd294eef2555bd348f74c1bcd22c8cfbbd2472cb91e35900d +moul.io/http2curl,v1.0.0,h1:6XwpyZOYsgZJrU8exnG87ncVkU1FVCcTRpwzOkTDUi8=,422e2b8833089b001da02c6d7235ecb4c0591bb585fee125cbd0d72b1371dba5 +mvdan.cc/sh,v2.6.0+incompatible,h1:BLDuJ+D75OCaBF7W70+2oALi8aKAjcAiDBNmmwR8BQA=,c5c335f4ae8f1c4228a01710b84ba8f847709b1920d2beeddc4648e62cdd25f7 +mvdan.cc/sh/v3,v3.0.0-alpha1,h1:ao/4li6H9nZe5HDXA14cynXoq90+DLZz0HmjZE/qjhA=,5da16556569786a039c24229b55eb0f76049c2293ac96a9b978cede87676962e +mvdan.cc/xurls/v2,v2.0.0,h1:r1zSOSNS/kqtpmATyMMMvaZ4/djsesbYz5kr0+qMRWc=,67e609a744e93b7ba05adee985d7e3471e6d414cea611ac73206e007a5e03082 +myitcv.io,v0.0.0-20190927111909-7837eed0ff8e,h1:aTqeLMcNZAhWxtvBgs0fbjTxg5BuNvHYnLo1lhSq9hE=,0d734b4e576c5c34dd9788481761864faef6cacdd735296d22f885b211fe9c70 +pack.ag/amqp,v0.11.2,h1:cuNDWLUTbKRtEZwhB0WQBXf9pGbm87pUBXQhvcFxBWg=,7cdc81d1aeef4ad24c4a49f6227aac060ee193587c95d48bfe4437beaf08310a +periph.io/x/periph,v3.6.2+incompatible,h1:B9vqhYVuhKtr6bXua8N9GeBEvD7yanczCvE0wU2LEqw=,aeb77a51a9e20e0414e7ea7c9a3a30302fcb5ffc5cf4dd41c3455ec0c3d7b1bc +perkeep.org,v0.0.0-20190926184543-d342b0e26632,h1:6ZKRr0VZtsfdHyYDJ/G9rCy7z8jGfrpmYANf0BR+vJM=,fd9e06dfc30d3bcb49399fd062094dfdf364a8344d409541896cb96d36465ade +rsc.io/binaryregexp,v0.2.0,h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=,b3e706aa278fa7f880d32fa1cc40ef8282d1fc7d6e00356579ed0db88f3b0047 +rsc.io/goversion,v1.2.0,h1:SPn+NLTiAG7w30IRK/DKp1BjvpWabYgxlLp/+kx5J8w=,f8426f6078b1d1b4e29a8c6223603680169c7c0a8789d2aee7e401a46ff6343f +rsc.io/pdf,v0.1.1,h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4=,79bf310e399cf0e2d8aa61536750d2a6999c5ca884e7a27faf88d3701cd5ba8f +rsc.io/qr,v0.1.0,h1:M/sAxsU2J5mlQ4W84Bxga2EgdQqOaAliipcjPmMUM5Q=,fd09c124eb71d01dab3a0116eac47a6fce78f34bbdd84620b2dc01b90582b11c +sigs.k8s.io/cluster-api,v0.2.7,h1:WjhtuvyjnMgo62kKlVizhI/nYs4DJxHNf+ZMSk/uUsM=,1e3767e7d0f655b72a52eab40e122779ccd1f734c06b9c6488ea9615a3db7b24 +sigs.k8s.io/controller-runtime,v0.3.0,h1:ZtdgqJXVHsIytjdmDuk0QjagnzyLq9FjojXRqIp+dU4=,f37a21668e57315e7248169bec6d4a71f86bcf53d7528c9752e7b459ee74efe0 +sigs.k8s.io/kustomize,v2.0.3+incompatible,h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=,e0f6ad3aaaf7160abcb5e7b16f711c13aebe876833ae9e6ad6f858f31641bf62 +sigs.k8s.io/structured-merge-diff,v0.0.0-20191023203907-336d3378ca53,h1:WCMuuk4OLJ1WdEK3fx+hroiutCODdAGwDlL2Dj4mpa0=,b389a2eafcce0dcef4ca1052942980f26b62030da007b3a84a653de5c0f91668 +sigs.k8s.io/testing_frameworks,v0.1.2-0.20190130140139-57f07443c2d4,h1:GtDhkj3cF4A4IW+A9LScsuxvJqA9DE7G7PGH1f8B07U=,bfb65beb3dda386efc0c0ff9237a07877cec71922f4d3dc1f4a40d5fcaa090a9 +sigs.k8s.io/yaml,v1.1.0,h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=,a0d39252e8665a428a8cb9d4dfc9cbea07b7ae90ae62e7cf3651be719adf515a +sofastack.io/sofa-mosn,v0.0.0-20191101130505-becc7a6dc50c,h1:8IAozA6SkwfqCAF7fVyy8gu4FdyJvH5iBC12WhiocB8=,0ed9cc5b20e6233051bb4de2ffee5c7f3365704fe01d28e87237d9e8041a786d +sourcegraph.com/sourcegraph/appdash,v0.0.0-20190107175209-d9ea5c54f7dc,h1:lmf242UNy8ucQUSUse9oXtyxHb6kaF82XRLqeVDXXhA=,49e3fd73d6218c97f49266f0e32bbdab1b6352f2f40da8d1aa98ee8dfdeec072 +sourcegraph.com/sourcegraph/appdash-data,v0.0.0-20151005221446-73f23eafcf67,h1:e1sMhtVq9AfcEy8AXNb8eSg6gbzfdpYhoNqnPJa+GzI=,382adefecd62bb79172e2552bcfb7d45f47122f9bd22259b0566b26fb2627b87 +sourcegraph.com/sourcegraph/go-diff,v0.5.0,h1:eTiIR0CoWjGzJcnQ3OkhIl/b9GJovq4lSAVRt0ZFEG8=,2c5eaad1d3743b3d4bd6de70459a413e62d1753673d5b96402dda27508454b3b +sourcegraph.com/sqs/pbtypes,v0.0.0-20180604144634-d3ebe8f20ae4,h1:JPJh2pk3+X4lXAkZIk2RuE/7/FoK9maXw+TNPJhVS/c=,6750f8618ecbde1668de332800ec01d713debb145dee395c23fc9a373c207fe3 +storj.io/drpc,v0.0.7-0.20191021224058-08e7133752cd,h1:Oh7Nww1cgFA3fhrCOheDwQ0VcUKFcO1LsBSJEgiGgUQ=,51befd9e6e3aa6cfb9f5b56e47b3cd59715dbe656d0a12cfbb0282609b5456dd +storj.io/storj,v0.24.5,h1:dWqApMsdhPoUufrljPQC1gZWkYcSTjRr5AoZ7mrSjCw=,ce0628bdcce2b8f0241d27993431d343d212b2e55323510bf657928001c2fb26 +strk.kbt.io/projects/go/libravatar,v0.0.0-20160628055650-5eed7bff870a,h1:8q33ShxKXRwQ7JVd1ZnhIU3hZhwwn0Le+4fTeAackuM=,be48b3949775d6ba0dd3105d7d31d338fede9fbd1471b41fe861f1cfcabbf85c +v.io/x/lib,v0.1.4,h1:PCDfluqBeRbA7OgDIs9tIpT+z6ZNZ5VMeR+t7h/K2ig=,411c5ded56ba1b69269c37748d184954089c320f43ee76beb0c53f7c598baeaf +vbom.ml/util,v0.0.0-20180919145318-efcd4e0f9787,h1:O69FD9pJA4WUZlEwYatBEEkRWKQ5cKodWpdKTrCS/iQ=,abbc7a9ac1d820f336ccbe247404800d0f79859b4e4412f0d107aebbb564f920 +vitess.io/vitess,v2.1.1+incompatible,h1:nuuGHiWYWpudD3gOCLeGzol2EJ25e/u5Wer2wV1O130=,8f823ede6775b4f5b3f6cd4c04b3b6be453416e124362a8d68fa2e829429fa68 +xorm.io/builder,v0.3.6,h1:ha28mQ2M+TFx96Hxo+iq6tQgnkC9IZkM6D8w9sKHHF8=,8f16bb96bf2f75b4813be77072a966d1f2248a38f2c7afff4132b666876310a7 +xorm.io/core,v0.7.2,h1:mEO22A2Z7a3fPaZMk6gKL/jMD80iiyNwRrX5HOv3XLw=,24c93962a78b2a177ff5c66cd43921eb1e8b13290d0e8a4d87c6f075a81c4531 diff --git a/go/src/cmd/go/internal/modfetch/zip_sum_test/zip_sum_test.go b/go/src/cmd/go/internal/modfetch/zip_sum_test/zip_sum_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6b2312cbed0aa9447bf1be59942b561f140baedb --- /dev/null +++ b/go/src/cmd/go/internal/modfetch/zip_sum_test/zip_sum_test.go @@ -0,0 +1,231 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package zip_sum_test tests that the module zip files produced by modfetch +// have consistent content sums. Ideally the zip files themselves are also +// stable over time, though this is not strictly necessary. +// +// This test loads a table from testdata/zip_sums.csv. The table has columns +// for module path, version, content sum, and zip file hash. The table +// includes a large number of real modules. The test downloads these modules +// in direct mode and verifies the zip files. +// +// This test is very slow, and it depends on outside modules that change +// frequently, so this is a manual test. To enable it, pass the -zipsum flag. +package zip_sum_test + +import ( + "context" + "crypto/sha256" + "encoding/csv" + "encoding/hex" + "flag" + "fmt" + "internal/testenv" + "io" + "os" + "path/filepath" + "strings" + "testing" + + "cmd/go/internal/cfg" + "cmd/go/internal/modfetch" + + "golang.org/x/mod/module" +) + +var ( + updateTestData = flag.Bool("u", false, "when set, tests may update files in testdata instead of failing") + enableZipSum = flag.Bool("zipsum", false, "enable TestZipSums") + debugZipSum = flag.Bool("testwork", false, "when set, TestZipSums will preserve its test directory") + modCacheDir = flag.String("zipsumcache", "", "module cache to use instead of temp directory") + shardCount = flag.Int("zipsumshardcount", 1, "number of shards to divide TestZipSums into") + shardIndex = flag.Int("zipsumshard", 0, "index of TestZipSums shard to test (0 <= zipsumshard < zipsumshardcount)") +) + +const zipSumsPath = "testdata/zip_sums.csv" + +type zipSumTest struct { + m module.Version + wantSum, wantFileHash string +} + +func TestZipSums(t *testing.T) { + if !*enableZipSum { + // This test is very slow and heavily dependent on external repositories. + // Only run it explicitly. + t.Skip("TestZipSum not enabled with -zipsum") + } + if *shardCount < 1 { + t.Fatal("-zipsumshardcount must be a positive integer") + } + if *shardIndex < 0 || *shardCount <= *shardIndex { + t.Fatal("-zipsumshard must be between 0 and -zipsumshardcount") + } + + testenv.MustHaveGoBuild(t) + testenv.MustHaveExternalNetwork(t) + testenv.MustHaveExecPath(t, "bzr") + testenv.MustHaveExecPath(t, "git") + // TODO(jayconrod): add hg, svn, and fossil modules to testdata. + // Could not find any for now. + + tests, err := readZipSumTests() + if err != nil { + t.Fatal(err) + } + + if *modCacheDir != "" { + cfg.BuildContext.GOPATH = *modCacheDir + } else { + tmpDir, err := os.MkdirTemp("", "TestZipSums") + if err != nil { + t.Fatal(err) + } + if *debugZipSum { + fmt.Fprintf(os.Stderr, "TestZipSums: modCacheDir: %s\n", tmpDir) + } else { + defer os.RemoveAll(tmpDir) + } + cfg.BuildContext.GOPATH = tmpDir + } + + cfg.GOPROXY = "direct" + cfg.GOSUMDB = "off" + + // Shard tests by downloading only every nth module when shard flags are set. + // This makes it easier to test small groups of modules quickly. We avoid + // testing similarly named modules together (the list is sorted by module + // path and version). + if *shardCount > 1 { + r := *shardIndex + w := 0 + for r < len(tests) { + tests[w] = tests[r] + w++ + r += *shardCount + } + tests = tests[:w] + } + + // Download modules with a rate limit. We may run out of file descriptors + // or cause timeouts without a limit. + needUpdate := false + fetcher := modfetch.NewFetcher() + for i := range tests { + test := &tests[i] + name := fmt.Sprintf("%s@%s", strings.ReplaceAll(test.m.Path, "/", "_"), test.m.Version) + t.Run(name, func(t *testing.T) { + t.Parallel() + ctx := context.Background() + + zipPath, err := fetcher.DownloadZip(ctx, test.m) + if err != nil { + if *updateTestData { + t.Logf("%s: could not download module: %s (will remove from testdata)", test.m, err) + test.m.Path = "" // mark for deletion + needUpdate = true + } else { + t.Errorf("%s: could not download module: %s", test.m, err) + } + return + } + + sum := modfetch.Sum(ctx, test.m) + if sum != test.wantSum { + if *updateTestData { + t.Logf("%s: updating content sum to %s", test.m, sum) + test.wantSum = sum + needUpdate = true + } else { + t.Errorf("%s: got content sum %s; want sum %s", test.m, sum, test.wantSum) + return + } + } + + h := sha256.New() + f, err := os.Open(zipPath) + if err != nil { + t.Errorf("%s: %v", test.m, err) + } + defer f.Close() + if _, err := io.Copy(h, f); err != nil { + t.Errorf("%s: %v", test.m, err) + } + zipHash := hex.EncodeToString(h.Sum(nil)) + if zipHash != test.wantFileHash { + if *updateTestData { + t.Logf("%s: updating zip file hash to %s", test.m, zipHash) + test.wantFileHash = zipHash + needUpdate = true + } else { + t.Errorf("%s: got zip file hash %s; want hash %s (but content sum matches)", test.m, zipHash, test.wantFileHash) + } + } + }) + } + + if needUpdate { + // Remove tests marked for deletion + r, w := 0, 0 + for r < len(tests) { + if tests[r].m.Path != "" { + tests[w] = tests[r] + w++ + } + r++ + } + tests = tests[:w] + + if err := writeZipSumTests(tests); err != nil { + t.Error(err) + } + } +} + +func readZipSumTests() ([]zipSumTest, error) { + f, err := os.Open(filepath.FromSlash(zipSumsPath)) + if err != nil { + return nil, err + } + defer f.Close() + r := csv.NewReader(f) + + var tests []zipSumTest + for { + line, err := r.Read() + if err == io.EOF { + break + } else if err != nil { + return nil, err + } else if len(line) != 4 { + return nil, fmt.Errorf("%s:%d: malformed line", f.Name(), len(tests)+1) + } + test := zipSumTest{m: module.Version{Path: line[0], Version: line[1]}, wantSum: line[2], wantFileHash: line[3]} + tests = append(tests, test) + } + return tests, nil +} + +func writeZipSumTests(tests []zipSumTest) (err error) { + f, err := os.Create(filepath.FromSlash(zipSumsPath)) + if err != nil { + return err + } + defer func() { + if cerr := f.Close(); err == nil && cerr != nil { + err = cerr + } + }() + w := csv.NewWriter(f) + line := make([]string, 0, 4) + for _, test := range tests { + line = append(line[:0], test.m.Path, test.m.Version, test.wantSum, test.wantFileHash) + if err := w.Write(line); err != nil { + return err + } + } + w.Flush() + return nil +} diff --git a/go/src/cmd/go/internal/modget/get.go b/go/src/cmd/go/internal/modget/get.go new file mode 100644 index 0000000000000000000000000000000000000000..b731ccc047d91b7543b8e2111355a45d3d7677e0 --- /dev/null +++ b/go/src/cmd/go/internal/modget/get.go @@ -0,0 +1,2147 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package modget implements the module-aware “go get” command. +package modget + +// The arguments to 'go get' are patterns with optional version queries, with +// the version queries defaulting to "upgrade". +// +// The patterns are normally interpreted as package patterns. However, if a +// pattern cannot match a package, it is instead interpreted as a *module* +// pattern. For version queries such as "upgrade" and "patch" that depend on the +// selected version of a module (or of the module containing a package), +// whether a pattern denotes a package or module may change as updates are +// applied (see the example in mod_get_patchmod.txt). +// +// There are a few other ambiguous cases to resolve, too. A package can exist in +// two different modules at the same version: for example, the package +// example.com/foo might be found in module example.com and also in module +// example.com/foo, and those modules may have independent v0.1.0 tags — so the +// input 'example.com/foo@v0.1.0' could syntactically refer to the variant of +// the package loaded from either module! (See mod_get_ambiguous_pkg.txt.) +// If the argument is ambiguous, the user can often disambiguate by specifying +// explicit versions for *all* of the potential module paths involved. + +import ( + "context" + "errors" + "fmt" + "os" + "path/filepath" + "runtime" + "sort" + "strconv" + "strings" + "sync" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/imports" + "cmd/go/internal/modfetch" + "cmd/go/internal/modload" + "cmd/go/internal/search" + "cmd/go/internal/toolchain" + "cmd/go/internal/work" + "cmd/internal/par" + + "golang.org/x/mod/modfile" + "golang.org/x/mod/module" +) + +var CmdGet = &base.Command{ + // Note: flags below are listed explicitly because they're the most common. + // Do not send CLs removing them because they're covered by [get flags]. + UsageLine: "go get [-t] [-u] [-tool] [build flags] [packages]", + Short: "add dependencies to current module and install them", + Long: ` +Get resolves its command-line arguments to packages at specific module versions, +updates go.mod to require those versions, and downloads source code into the +module cache. + +To add a dependency for a package or upgrade it to its latest version: + + go get example.com/pkg + +To upgrade or downgrade a package to a specific version: + + go get example.com/pkg@v1.2.3 + +To remove a dependency on a module and downgrade modules that require it: + + go get example.com/mod@none + +To upgrade the minimum required Go version to the latest released Go version: + + go get go@latest + +To upgrade the Go toolchain to the latest patch release of the current Go toolchain: + + go get toolchain@patch + +See https://golang.org/ref/mod#go-get for details. + +In earlier versions of Go, 'go get' was used to build and install packages. +Now, 'go get' is dedicated to adjusting dependencies in go.mod. 'go install' +may be used to build and install commands instead. When a version is specified, +'go install' runs in module-aware mode and ignores the go.mod file in the +current directory. For example: + + go install example.com/pkg@v1.2.3 + go install example.com/pkg@latest + +See 'go help install' or https://golang.org/ref/mod#go-install for details. + +'go get' accepts the following flags. + +The -t flag instructs get to consider modules needed to build tests of +packages specified on the command line. + +The -u flag instructs get to update modules providing dependencies +of packages named on the command line to use newer minor or patch +releases when available. + +The -u=patch flag (not -u patch) also instructs get to update dependencies, +but changes the default to select patch releases. + +When the -t and -u flags are used together, get will update +test dependencies as well. + +The -tool flag instructs go to add a matching tool line to go.mod for each +listed package. If -tool is used with @none, the line will be removed. + +The -x flag prints commands as they are executed. This is useful for +debugging version control commands when a module is downloaded directly +from a repository. + +For more about build flags, see 'go help build'. + +For more about modules, see https://golang.org/ref/mod. + +For more about using 'go get' to update the minimum Go version and +suggested Go toolchain, see https://go.dev/doc/toolchain. + +For more about specifying packages, see 'go help packages'. + +See also: go build, go install, go clean, go mod. + `, +} + +var HelpVCS = &base.Command{ + UsageLine: "vcs", + Short: "controlling version control with GOVCS", + Long: ` +The 'go get' command can run version control commands like git +to download imported code. This functionality is critical to the decentralized +Go package ecosystem, in which code can be imported from any server, +but it is also a potential security problem, if a malicious server finds a +way to cause the invoked version control command to run unintended code. + +To balance the functionality and security concerns, the 'go get' command +by default will only use git and hg to download code from public servers. +But it will use any known version control system (bzr, fossil, git, hg, svn) +to download code from private servers, defined as those hosting packages +matching the GOPRIVATE variable (see 'go help private'). The rationale behind +allowing only Git and Mercurial is that these two systems have had the most +attention to issues of being run as clients of untrusted servers. In contrast, +Bazaar, Fossil, and Subversion have primarily been used in trusted, +authenticated environments and are not as well scrutinized as attack surfaces. + +The version control command restrictions only apply when using direct version +control access to download code. When downloading modules from a proxy, +'go get' uses the proxy protocol instead, which is always permitted. +By default, the 'go get' command uses the Go module mirror (proxy.golang.org) +for public packages and only falls back to version control for private +packages or when the mirror refuses to serve a public package (typically for +legal reasons). Therefore, clients can still access public code served from +Bazaar, Fossil, or Subversion repositories by default, because those downloads +use the Go module mirror, which takes on the security risk of running the +version control commands using a custom sandbox. + +The GOVCS variable can be used to change the allowed version control systems +for specific packages (identified by a module or import path). +The GOVCS variable applies when building package in both module-aware mode +and GOPATH mode. When using modules, the patterns match against the module path. +When using GOPATH, the patterns match against the import path corresponding to +the root of the version control repository. + +The general form of the GOVCS setting is a comma-separated list of +pattern:vcslist rules. The pattern is a glob pattern that must match +one or more leading elements of the module or import path. The vcslist +is a pipe-separated list of allowed version control commands, or "all" +to allow use of any known command, or "off" to disallow all commands. +Note that if a module matches a pattern with vcslist "off", it may still be +downloaded if the origin server uses the "mod" scheme, which instructs the +go command to download the module using the GOPROXY protocol. +The earliest matching pattern in the list applies, even if later patterns +might also match. + +For example, consider: + + GOVCS=github.com:git,evil.com:off,*:git|hg + +With this setting, code with a module or import path beginning with +github.com/ can only use git; paths on evil.com cannot use any version +control command, and all other paths (* matches everything) can use +only git or hg. + +The special patterns "public" and "private" match public and private +module or import paths. A path is private if it matches the GOPRIVATE +variable; otherwise it is public. + +If no rules in the GOVCS variable match a particular module or import path, +the 'go get' command applies its default rule, which can now be summarized +in GOVCS notation as 'public:git|hg,private:all'. + +To allow unfettered use of any version control system for any package, use: + + GOVCS=*:all + +To disable all use of version control, use: + + GOVCS=*:off + +The 'go env -w' command (see 'go help env') can be used to set the GOVCS +variable for future go command invocations. +`, +} + +var ( + getD dFlag + getF = CmdGet.Flag.Bool("f", false, "") + getFix = CmdGet.Flag.Bool("fix", false, "") + getM = CmdGet.Flag.Bool("m", false, "") + getT = CmdGet.Flag.Bool("t", false, "") + getU upgradeFlag + getTool = CmdGet.Flag.Bool("tool", false, "") + getInsecure = CmdGet.Flag.Bool("insecure", false, "") +) + +// upgradeFlag is a custom flag.Value for -u. +type upgradeFlag struct { + rawVersion string + version string +} + +func (*upgradeFlag) IsBoolFlag() bool { return true } // allow -u + +func (v *upgradeFlag) Set(s string) error { + if s == "false" { + v.version = "" + v.rawVersion = "" + } else if s == "true" { + v.version = "upgrade" + v.rawVersion = "" + } else { + v.version = s + v.rawVersion = s + } + return nil +} + +func (v *upgradeFlag) String() string { return "" } + +// dFlag is a custom flag.Value for the deprecated -d flag +// which will be used to provide warnings or errors if -d +// is provided. +type dFlag struct { + value bool + set bool +} + +func (v *dFlag) IsBoolFlag() bool { return true } + +func (v *dFlag) Set(s string) error { + v.set = true + value, err := strconv.ParseBool(s) + if err != nil { + err = errors.New("parse error") + } + v.value = value + return err +} + +func (b *dFlag) String() string { return "" } + +func init() { + work.AddBuildFlags(CmdGet, work.OmitModFlag) + CmdGet.Run = runGet // break init loop + CmdGet.Flag.Var(&getD, "d", "") + CmdGet.Flag.Var(&getU, "u", "") +} + +func runGet(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + switch getU.version { + case "", "upgrade", "patch": + // ok + default: + base.Fatalf("go: unknown upgrade flag -u=%s", getU.rawVersion) + } + if getD.set { + if !getD.value { + base.Fatalf("go: -d flag may not be set to false") + } + fmt.Fprintf(os.Stderr, "go: -d flag is deprecated. -d=true is a no-op\n") + } + if *getF { + fmt.Fprintf(os.Stderr, "go: -f flag is a no-op\n") + } + if *getFix { + fmt.Fprintf(os.Stderr, "go: -fix flag is a no-op\n") + } + if *getM { + base.Fatalf("go: -m flag is no longer supported") + } + if *getInsecure { + base.Fatalf("go: -insecure flag is no longer supported; use GOINSECURE instead") + } + + moduleLoaderState.ForceUseModules = true + + // Do not allow any updating of go.mod until we've applied + // all the requested changes and checked that the result matches + // what was requested. + modload.ExplicitWriteGoMod = true + + // Allow looking up modules for import paths when outside of a module. + // 'go get' is expected to do this, unlike other commands. + moduleLoaderState.AllowMissingModuleImports() + + // 'go get' no longer builds or installs packages, so there's nothing to do + // if there's no go.mod file. + // TODO(#40775): make modload.Init return ErrNoModRoot instead of exiting. + // We could handle that here by printing a different message. + modload.Init(moduleLoaderState) + if !moduleLoaderState.HasModRoot() { + base.Fatalf("go: go.mod file not found in current directory or any parent directory.\n" + + "\t'go get' is no longer supported outside a module.\n" + + "\tTo build and install a command, use 'go install' with a version,\n" + + "\tlike 'go install example.com/cmd@latest'\n" + + "\tFor more information, see https://golang.org/doc/go-get-install-deprecation\n" + + "\tor run 'go help get' or 'go help install'.") + } + + dropToolchain, queries := parseArgs(moduleLoaderState, ctx, args) + opts := modload.WriteOpts{ + DropToolchain: dropToolchain, + } + for _, q := range queries { + if q.pattern == "toolchain" { + opts.ExplicitToolchain = true + } + } + + r := newResolver(moduleLoaderState, ctx, queries) + r.performLocalQueries(moduleLoaderState, ctx) + r.performPathQueries(moduleLoaderState, ctx) + r.performToolQueries(moduleLoaderState, ctx) + r.performWorkQueries(moduleLoaderState, ctx) + + for { + r.performWildcardQueries(moduleLoaderState, ctx) + r.performPatternAllQueries(moduleLoaderState, ctx) + + if changed := r.resolveQueries(moduleLoaderState, ctx, queries); changed { + // 'go get' arguments can be (and often are) package patterns rather than + // (just) modules. A package can be provided by any module with a prefix + // of its import path, and a wildcard can even match packages in modules + // with totally different paths. Because of these effects, and because any + // change to the selected version of a module can bring in entirely new + // module paths as dependencies, we need to reissue queries whenever we + // change the build list. + // + // The result of any version query for a given module — even "upgrade" or + // "patch" — is always relative to the build list at the start of + // the 'go get' command, not an intermediate state, and is therefore + // deterministic and therefore cacheable, and the constraints on the + // selected version of each module can only narrow as we iterate. + // + // "all" is functionally very similar to a wildcard pattern. The set of + // packages imported by the main module does not change, and the query + // result for the module containing each such package also does not change + // (it is always relative to the initial build list, before applying + // queries). So the only way that the result of an "all" query can change + // is if some matching package moves from one module in the build list + // to another, which should not happen very often. + continue + } + + // When we load imports, we detect the following conditions: + // + // - missing transitive dependencies that need to be resolved from outside the + // current build list (note that these may add new matches for existing + // pattern queries!) + // + // - transitive dependencies that didn't match any other query, + // but need to be upgraded due to the -u flag + // + // - ambiguous import errors. + // TODO(#27899): Try to resolve ambiguous import errors automatically. + upgrades := r.findAndUpgradeImports(moduleLoaderState, ctx, queries) + if changed := r.applyUpgrades(moduleLoaderState, ctx, upgrades); changed { + continue + } + + r.findMissingWildcards(moduleLoaderState, ctx) + if changed := r.resolveQueries(moduleLoaderState, ctx, r.wildcardQueries); changed { + continue + } + + break + } + + r.checkWildcardVersions(moduleLoaderState, ctx) + + var pkgPatterns []string + for _, q := range queries { + if q.matchesPackages { + pkgPatterns = append(pkgPatterns, q.pattern) + } + } + + // If a workspace applies, checkPackageProblems will switch to the workspace + // using modload.EnterWorkspace when doing the final load, and then switch back. + r.checkPackageProblems(moduleLoaderState, ctx, pkgPatterns) + + if *getTool { + updateTools(moduleLoaderState, ctx, queries, &opts) + } + + // Everything succeeded. Update go.mod. + oldReqs := reqsFromGoMod(modload.ModFile(moduleLoaderState)) + + if err := modload.WriteGoMod(moduleLoaderState, ctx, opts); err != nil { + // A TooNewError can happen for 'go get go@newversion' + // when all the required modules are old enough + // but the command line is not. + // TODO(bcmills): modload.EditBuildList should catch this instead, + // and then this can be changed to base.Fatal(err). + toolchain.SwitchOrFatal(moduleLoaderState, ctx, err) + } + + newReqs := reqsFromGoMod(modload.ModFile(moduleLoaderState)) + r.reportChanges(oldReqs, newReqs) + + if gowork := moduleLoaderState.FindGoWork(base.Cwd()); gowork != "" { + wf, err := modload.ReadWorkFile(gowork) + if err == nil && modload.UpdateWorkGoVersion(wf, moduleLoaderState.MainModules.GoVersion(moduleLoaderState)) { + modload.WriteWorkFile(gowork, wf) + } + } +} + +func updateTools(loaderstate *modload.State, ctx context.Context, queries []*query, opts *modload.WriteOpts) { + pkgOpts := modload.PackageOpts{ + VendorModulesInGOROOTSrc: true, + LoadTests: *getT, + ResolveMissingImports: false, + AllowErrors: true, + SilenceNoGoErrors: true, + } + patterns := []string{} + for _, q := range queries { + if search.IsMetaPackage(q.pattern) || q.pattern == "toolchain" { + base.Fatalf("go: go get -tool does not work with \"%s\".", q.pattern) + } + patterns = append(patterns, q.pattern) + } + + matches, _ := modload.LoadPackages(loaderstate, ctx, pkgOpts, patterns...) + for i, m := range matches { + if queries[i].version == "none" { + opts.DropTools = append(opts.DropTools, m.Pkgs...) + } else { + opts.AddTools = append(opts.AddTools, m.Pkgs...) + } + } +} + +// parseArgs parses command-line arguments and reports errors. +// +// The command-line arguments are of the form path@version or simply path, with +// implicit @upgrade. path@none is "downgrade away". +func parseArgs(loaderstate *modload.State, ctx context.Context, rawArgs []string) (dropToolchain bool, queries []*query) { + defer base.ExitIfErrors() + + for _, arg := range search.CleanPatterns(rawArgs) { + q, err := newQuery(loaderstate, arg) + if err != nil { + base.Error(err) + continue + } + + if q.version == "none" { + switch q.pattern { + case "go": + base.Errorf("go: cannot use go@none") + continue + case "toolchain": + dropToolchain = true + continue + } + } + + // If there were no arguments, CleanPatterns returns ".". Set the raw + // string back to "" for better errors. + if len(rawArgs) == 0 { + q.raw = "" + } + + // Guard against 'go get x.go', a common mistake. + // Note that package and module paths may end with '.go', so only print an error + // if the argument has no version and either has no slash or refers to an existing file. + if strings.HasSuffix(q.raw, ".go") && q.rawVersion == "" { + if !strings.Contains(q.raw, "/") { + base.Errorf("go: %s: arguments must be package or module paths", q.raw) + continue + } + if fi, err := os.Stat(q.raw); err == nil && !fi.IsDir() { + base.Errorf("go: %s exists as a file, but 'go get' requires package arguments", q.raw) + continue + } + } + + queries = append(queries, q) + } + + return dropToolchain, queries +} + +type resolver struct { + localQueries []*query // queries for absolute or relative paths + pathQueries []*query // package path literal queries in original order + wildcardQueries []*query // path wildcard queries in original order + patternAllQueries []*query // queries with the pattern "all" + workQueries []*query // queries with the pattern "work" + toolQueries []*query // queries with the pattern "tool" + + // Indexed "none" queries. These are also included in the slices above; + // they are indexed here to speed up noneForPath. + nonesByPath map[string]*query // path-literal "@none" queries indexed by path + wildcardNones []*query // wildcard "@none" queries + + // resolvedVersion maps each module path to the version of that module that + // must be selected in the final build list, along with the first query + // that resolved the module to that version (the “reason”). + resolvedVersion map[string]versionReason + + buildList []module.Version + buildListVersion map[string]string // index of buildList (module path → version) + + initialVersion map[string]string // index of the initial build list at the start of 'go get' + + missing []pathSet // candidates for missing transitive dependencies + + work *par.Queue + + matchInModuleCache par.ErrCache[matchInModuleKey, []string] + + // workspace is used to check whether, in workspace mode, any of the workspace + // modules would contain a package. + workspace *workspace +} + +type versionReason struct { + version string + reason *query +} + +type matchInModuleKey struct { + pattern string + m module.Version +} + +func newResolver(loaderstate *modload.State, ctx context.Context, queries []*query) *resolver { + // LoadModGraph also sets modload.Target, which is needed by various resolver + // methods. + mg, err := modload.LoadModGraph(loaderstate, ctx, "") + if err != nil { + toolchain.SwitchOrFatal(loaderstate, ctx, err) + } + + buildList := mg.BuildList() + initialVersion := make(map[string]string, len(buildList)) + for _, m := range buildList { + initialVersion[m.Path] = m.Version + } + + r := &resolver{ + work: par.NewQueue(runtime.GOMAXPROCS(0)), + resolvedVersion: map[string]versionReason{}, + buildList: buildList, + buildListVersion: initialVersion, + initialVersion: initialVersion, + nonesByPath: map[string]*query{}, + workspace: loadWorkspace(loaderstate.FindGoWork(base.Cwd())), + } + + for _, q := range queries { + if q.pattern == "all" { + r.patternAllQueries = append(r.patternAllQueries, q) + } else if q.pattern == "work" { + r.workQueries = append(r.workQueries, q) + } else if q.pattern == "tool" { + r.toolQueries = append(r.toolQueries, q) + } else if q.patternIsLocal { + r.localQueries = append(r.localQueries, q) + } else if q.isWildcard() { + r.wildcardQueries = append(r.wildcardQueries, q) + } else { + r.pathQueries = append(r.pathQueries, q) + } + + if q.version == "none" { + // Index "none" queries to make noneForPath more efficient. + if q.isWildcard() { + r.wildcardNones = append(r.wildcardNones, q) + } else { + // All "@none" queries for the same path are identical; we only + // need to index one copy. + r.nonesByPath[q.pattern] = q + } + } + } + + return r +} + +// initialSelected returns the version of the module with the given path that +// was selected at the start of this 'go get' invocation. +func (r *resolver) initialSelected(mPath string) (version string) { + v, ok := r.initialVersion[mPath] + if !ok { + return "none" + } + return v +} + +// selected returns the version of the module with the given path that is +// selected in the resolver's current build list. +func (r *resolver) selected(mPath string) (version string) { + v, ok := r.buildListVersion[mPath] + if !ok { + return "none" + } + return v +} + +// noneForPath returns a "none" query matching the given module path, +// or found == false if no such query exists. +func (r *resolver) noneForPath(mPath string) (nq *query, found bool) { + if nq = r.nonesByPath[mPath]; nq != nil { + return nq, true + } + for _, nq := range r.wildcardNones { + if nq.matchesPath(mPath) { + return nq, true + } + } + return nil, false +} + +// queryModule wraps modload.Query, substituting r.checkAllowedOr to decide +// allowed versions. +func (r *resolver) queryModule(loaderstate *modload.State, ctx context.Context, mPath, query string, selected func(string) string) (module.Version, error) { + current := r.initialSelected(mPath) + rev, err := modload.Query(loaderstate, ctx, mPath, query, current, r.checkAllowedOr(loaderstate, query, selected)) + if err != nil { + return module.Version{}, err + } + return module.Version{Path: mPath, Version: rev.Version}, nil +} + +// queryPackages wraps modload.QueryPackage, substituting r.checkAllowedOr to +// decide allowed versions. +func (r *resolver) queryPackages(loaderstate *modload.State, ctx context.Context, pattern, query string, selected func(string) string) (pkgMods []module.Version, err error) { + results, err := modload.QueryPackages(loaderstate, ctx, pattern, query, selected, r.checkAllowedOr(loaderstate, query, selected)) + if len(results) > 0 { + pkgMods = make([]module.Version, 0, len(results)) + for _, qr := range results { + pkgMods = append(pkgMods, qr.Mod) + } + } + return pkgMods, err +} + +// queryPattern wraps modload.QueryPattern, substituting r.checkAllowedOr to +// decide allowed versions. +func (r *resolver) queryPattern(loaderstate *modload.State, ctx context.Context, pattern, query string, selected func(string) string) (pkgMods []module.Version, mod module.Version, err error) { + results, modOnly, err := modload.QueryPattern(loaderstate, ctx, pattern, query, selected, r.checkAllowedOr(loaderstate, query, selected)) + if len(results) > 0 { + pkgMods = make([]module.Version, 0, len(results)) + for _, qr := range results { + pkgMods = append(pkgMods, qr.Mod) + } + } + if modOnly != nil { + mod = modOnly.Mod + } + return pkgMods, mod, err +} + +// checkAllowedOr is like modload.CheckAllowed, but it always allows the requested +// and current versions (even if they are retracted or otherwise excluded). +func (r *resolver) checkAllowedOr(s *modload.State, requested string, selected func(string) string) modload.AllowedFunc { + return func(ctx context.Context, m module.Version) error { + if m.Version == requested { + return s.CheckExclusions(ctx, m) + } + if (requested == "upgrade" || requested == "patch") && m.Version == selected(m.Path) { + return nil + } + return s.CheckAllowed(ctx, m) + } +} + +// matchInModule is a caching wrapper around modload.MatchInModule. +func (r *resolver) matchInModule(loaderstate *modload.State, ctx context.Context, pattern string, m module.Version) (packages []string, err error) { + return r.matchInModuleCache.Do(matchInModuleKey{pattern, m}, func() ([]string, error) { + match := modload.MatchInModule(loaderstate, ctx, pattern, m, imports.AnyTags()) + if len(match.Errs) > 0 { + return match.Pkgs, match.Errs[0] + } + return match.Pkgs, nil + }) +} + +// queryNone adds a candidate set to q for each module matching q.pattern. +// Each candidate set has only one possible module version: the matched +// module at version "none". +// +// We interpret arguments to 'go get' as packages first, and fall back to +// modules second. However, no module exists at version "none", and therefore no +// package exists at that version either: we know that the argument cannot match +// any packages, and thus it must match modules instead. +func (r *resolver) queryNone(loaderstate *modload.State, ctx context.Context, q *query) { + if search.IsMetaPackage(q.pattern) { + panic(fmt.Sprintf("internal error: queryNone called with pattern %q", q.pattern)) + } + + if !q.isWildcard() { + q.pathOnce(q.pattern, func() pathSet { + hasModRoot := loaderstate.HasModRoot() + if hasModRoot && loaderstate.MainModules.Contains(q.pattern) { + v := module.Version{Path: q.pattern} + // The user has explicitly requested to downgrade their own module to + // version "none". This is not an entirely unreasonable request: it + // could plausibly mean “downgrade away everything that depends on any + // explicit version of the main module”, or “downgrade away the + // package with the same path as the main module, found in a module + // with a prefix of the main module's path”. + // + // However, neither of those behaviors would be consistent with the + // plain meaning of the query. To try to reduce confusion, reject the + // query explicitly. + return errSet(&modload.QueryMatchesMainModulesError{ + MainModules: []module.Version{v}, + Pattern: q.pattern, + Query: q.version, + PatternIsModule: loaderstate.MainModules.Contains(q.pattern), + }) + } + + return pathSet{mod: module.Version{Path: q.pattern, Version: "none"}} + }) + } + + for _, curM := range r.buildList { + if !q.matchesPath(curM.Path) { + continue + } + q.pathOnce(curM.Path, func() pathSet { + if loaderstate.HasModRoot() && curM.Version == "" && loaderstate.MainModules.Contains(curM.Path) { + return errSet(&modload.QueryMatchesMainModulesError{ + MainModules: []module.Version{curM}, + Pattern: q.pattern, + Query: q.version, + PatternIsModule: loaderstate.MainModules.Contains(q.pattern), + }) + } + return pathSet{mod: module.Version{Path: curM.Path, Version: "none"}} + }) + } +} + +func (r *resolver) performLocalQueries(loaderstate *modload.State, ctx context.Context) { + for _, q := range r.localQueries { + q.pathOnce(q.pattern, func() pathSet { + absDetail := "" + if !filepath.IsAbs(q.pattern) { + if absPath, err := filepath.Abs(q.pattern); err == nil { + absDetail = fmt.Sprintf(" (%s)", absPath) + } + } + + // Absolute paths like C:\foo and relative paths like ../foo... are + // restricted to matching packages in the main module. + pkgPattern, mainModule := loaderstate.MainModules.DirImportPath(loaderstate, ctx, q.pattern) + if pkgPattern == "." { + loaderstate.MustHaveModRoot() + versions := loaderstate.MainModules.Versions() + modRoots := make([]string, 0, len(versions)) + for _, m := range versions { + modRoots = append(modRoots, loaderstate.MainModules.ModRoot(m)) + } + var plural string + if len(modRoots) != 1 { + plural = "s" + } + return errSet(fmt.Errorf("%s%s is not within module%s rooted at %s", q.pattern, absDetail, plural, strings.Join(modRoots, ", "))) + } + + match := modload.MatchInModule(loaderstate, ctx, pkgPattern, mainModule, imports.AnyTags()) + if len(match.Errs) > 0 { + return pathSet{err: match.Errs[0]} + } + + if len(match.Pkgs) == 0 { + if q.raw == "" || q.raw == "." { + return errSet(fmt.Errorf("no package to get in current directory")) + } + if !q.isWildcard() { + loaderstate.MustHaveModRoot() + return errSet(fmt.Errorf("%s%s is not a package in module rooted at %s", q.pattern, absDetail, loaderstate.MainModules.ModRoot(mainModule))) + } + search.WarnUnmatched([]*search.Match{match}) + return pathSet{} + } + + return pathSet{pkgMods: []module.Version{mainModule}} + }) + } +} + +// performWildcardQueries populates the candidates for each query whose pattern +// is a wildcard. +// +// The candidates for a given module path matching (or containing a package +// matching) a wildcard query depend only on the initial build list, but the set +// of modules may be expanded by other queries, so wildcard queries need to be +// re-evaluated whenever a potentially-matching module path is added to the +// build list. +func (r *resolver) performWildcardQueries(loaderstate *modload.State, ctx context.Context) { + for _, q := range r.wildcardQueries { + q := q + r.work.Add(func() { + if q.version == "none" { + r.queryNone(loaderstate, ctx, q) + } else { + r.queryWildcard(loaderstate, ctx, q) + } + }) + } + <-r.work.Idle() +} + +// queryWildcard adds a candidate set to q for each module for which: +// - some version of the module is already in the build list, and +// - that module exists at some version matching q.version, and +// - either the module path itself matches q.pattern, or some package within +// the module at q.version matches q.pattern. +func (r *resolver) queryWildcard(loaderstate *modload.State, ctx context.Context, q *query) { + // For wildcard patterns, modload.QueryPattern only identifies modules + // matching the prefix of the path before the wildcard. However, the build + // list may already contain other modules with matching packages, and we + // should consider those modules to satisfy the query too. + // We want to match any packages in existing dependencies, but we only want to + // resolve new dependencies if nothing else turns up. + for _, curM := range r.buildList { + if !q.canMatchInModule(curM.Path) { + continue + } + q.pathOnce(curM.Path, func() pathSet { + if _, hit := r.noneForPath(curM.Path); hit { + // This module is being removed, so it will no longer be in the build list + // (and thus will no longer match the pattern). + return pathSet{} + } + + if loaderstate.MainModules.Contains(curM.Path) && !versionOkForMainModule(q.version) { + if q.matchesPath(curM.Path) { + return errSet(&modload.QueryMatchesMainModulesError{ + MainModules: []module.Version{curM}, + Pattern: q.pattern, + Query: q.version, + PatternIsModule: loaderstate.MainModules.Contains(q.pattern), + }) + } + + packages, err := r.matchInModule(loaderstate, ctx, q.pattern, curM) + if err != nil { + return errSet(err) + } + if len(packages) > 0 { + return errSet(&modload.QueryMatchesPackagesInMainModuleError{ + Pattern: q.pattern, + Query: q.version, + Packages: packages, + }) + } + + return r.tryWildcard(loaderstate, ctx, q, curM) + } + + m, err := r.queryModule(loaderstate, ctx, curM.Path, q.version, r.initialSelected) + if err != nil { + if !isNoSuchModuleVersion(err) { + // We can't tell whether a matching version exists. + return errSet(err) + } + // There is no version of curM.Path matching the query. + + // We haven't checked whether curM contains any matching packages at its + // currently-selected version, or whether curM.Path itself matches q. If + // either of those conditions holds, *and* no other query changes the + // selected version of curM, then we will fail in checkWildcardVersions. + // (This could be an error, but it's too soon to tell.) + // + // However, even then the transitive requirements of some other query + // may downgrade this module out of the build list entirely, in which + // case the pattern will no longer include it and it won't be an error. + // + // Either way, punt on the query rather than erroring out just yet. + return pathSet{} + } + + return r.tryWildcard(loaderstate, ctx, q, m) + }) + } + + // Even if no modules matched, we shouldn't query for a new module to provide + // the pattern yet: some other query may yet induce a new requirement that + // will match the wildcard. Instead, we'll check in findMissingWildcards. +} + +// tryWildcard returns a pathSet for module m matching query q. +// If m does not actually match q, tryWildcard returns an empty pathSet. +func (r *resolver) tryWildcard(loaderstate *modload.State, ctx context.Context, q *query, m module.Version) pathSet { + mMatches := q.matchesPath(m.Path) + packages, err := r.matchInModule(loaderstate, ctx, q.pattern, m) + if err != nil { + return errSet(err) + } + if len(packages) > 0 { + return pathSet{pkgMods: []module.Version{m}} + } + if mMatches { + return pathSet{mod: m} + } + return pathSet{} +} + +// findMissingWildcards adds a candidate set for each query in r.wildcardQueries +// that has not yet resolved to any version containing packages. +func (r *resolver) findMissingWildcards(loaderstate *modload.State, ctx context.Context) { + for _, q := range r.wildcardQueries { + if q.version == "none" || q.matchesPackages { + continue // q is not “missing” + } + r.work.Add(func() { + q.pathOnce(q.pattern, func() pathSet { + pkgMods, mod, err := r.queryPattern(loaderstate, ctx, q.pattern, q.version, r.initialSelected) + if err != nil { + if isNoSuchPackageVersion(err) && len(q.resolved) > 0 { + // q already resolved one or more modules but matches no packages. + // That's ok: this pattern is just a module pattern, and we don't + // need to add any more modules to satisfy it. + return pathSet{} + } + return errSet(err) + } + + return pathSet{pkgMods: pkgMods, mod: mod} + }) + }) + } + <-r.work.Idle() +} + +// checkWildcardVersions reports an error if any module in the build list has a +// path (or contains a package) matching a query with a wildcard pattern, but +// has a selected version that does *not* match the query. +func (r *resolver) checkWildcardVersions(loaderstate *modload.State, ctx context.Context) { + defer base.ExitIfErrors() + + for _, q := range r.wildcardQueries { + for _, curM := range r.buildList { + if !q.canMatchInModule(curM.Path) { + continue + } + if !q.matchesPath(curM.Path) { + packages, err := r.matchInModule(loaderstate, ctx, q.pattern, curM) + if len(packages) == 0 { + if err != nil { + reportError(q, err) + } + continue // curM is not relevant to q. + } + } + + rev, err := r.queryModule(loaderstate, ctx, curM.Path, q.version, r.initialSelected) + if err != nil { + reportError(q, err) + continue + } + if rev.Version == curM.Version { + continue // curM already matches q. + } + + if !q.matchesPath(curM.Path) { + m := module.Version{Path: curM.Path, Version: rev.Version} + packages, err := r.matchInModule(loaderstate, ctx, q.pattern, m) + if err != nil { + reportError(q, err) + continue + } + if len(packages) == 0 { + // curM at its original version contains a path matching q.pattern, + // but at rev.Version it does not, so (somewhat paradoxically) if + // we changed the version of curM it would no longer match the query. + var version any = m + if rev.Version != q.version { + version = fmt.Sprintf("%s@%s (%s)", m.Path, q.version, m.Version) + } + reportError(q, fmt.Errorf("%v matches packages in %v but not %v: specify a different version for module %s", q, curM, version, m.Path)) + continue + } + } + + // Since queryModule succeeded and either curM or one of the packages it + // contains matches q.pattern, we should have either selected the version + // of curM matching q, or reported a conflict error (and exited). + // If we're still here and the version doesn't match, + // something has gone very wrong. + reportError(q, fmt.Errorf("internal error: selected %v instead of %v", curM, rev.Version)) + } + } +} + +// performPathQueries populates the candidates for each query whose pattern is +// a path literal. +// +// The candidate packages and modules for path literals depend only on the +// initial build list, not the current build list, so we only need to query path +// literals once. +func (r *resolver) performPathQueries(loaderstate *modload.State, ctx context.Context) { + for _, q := range r.pathQueries { + q := q + r.work.Add(func() { + if q.version == "none" { + r.queryNone(loaderstate, ctx, q) + } else { + r.queryPath(loaderstate, ctx, q) + } + }) + } + <-r.work.Idle() +} + +// queryPath adds a candidate set to q for the package with path q.pattern. +// The candidate set consists of all modules that could provide q.pattern +// and have a version matching q, plus (if it exists) the module whose path +// is itself q.pattern (at a matching version). +func (r *resolver) queryPath(loaderstate *modload.State, ctx context.Context, q *query) { + q.pathOnce(q.pattern, func() pathSet { + if search.IsMetaPackage(q.pattern) || q.isWildcard() { + panic(fmt.Sprintf("internal error: queryPath called with pattern %q", q.pattern)) + } + if q.version == "none" { + panic(`internal error: queryPath called with version "none"`) + } + + if search.IsStandardImportPath(q.pattern) { + stdOnly := module.Version{} + packages, _ := r.matchInModule(loaderstate, ctx, q.pattern, stdOnly) + if len(packages) > 0 { + if q.rawVersion != "" { + return errSet(fmt.Errorf("can't request explicit version %q of standard library package %s", q.version, q.pattern)) + } + + q.matchesPackages = true + return pathSet{} // No module needed for standard library. + } + } + + pkgMods, mod, err := r.queryPattern(loaderstate, ctx, q.pattern, q.version, r.initialSelected) + if err != nil { + return errSet(err) + } + return pathSet{pkgMods: pkgMods, mod: mod} + }) +} + +// performToolQueries populates the candidates for each query whose +// pattern is "tool". +func (r *resolver) performToolQueries(loaderstate *modload.State, ctx context.Context) { + for _, q := range r.toolQueries { + for tool := range loaderstate.MainModules.Tools() { + q.pathOnce(tool, func() pathSet { + pkgMods, err := r.queryPackages(loaderstate, ctx, tool, q.version, r.initialSelected) + return pathSet{pkgMods: pkgMods, err: err} + }) + } + } +} + +// performWorkQueries populates the candidates for each query whose pattern is "work". +// The candidate module to resolve the work pattern is exactly the single main module. +func (r *resolver) performWorkQueries(loaderstate *modload.State, ctx context.Context) { + for _, q := range r.workQueries { + q.pathOnce(q.pattern, func() pathSet { + // TODO(matloob): Maybe export MainModules.mustGetSingleMainModule and call that. + // There are a few other places outside the modload package where we expect + // a single main module. + if len(loaderstate.MainModules.Versions()) != 1 { + panic("internal error: number of main modules is not exactly one in resolution phase of go get") + } + mainModule := loaderstate.MainModules.Versions()[0] + + // We know what the result is going to be, assuming the main module is not + // empty, (it's the main module itself) but first check to see that there + // are packages in the main module, so that if there aren't any, we can + // return the expected warning that the pattern matched no packages. + match := modload.MatchInModule(loaderstate, ctx, q.pattern, mainModule, imports.AnyTags()) + if len(match.Errs) > 0 { + return pathSet{err: match.Errs[0]} + } + if len(match.Pkgs) == 0 { + search.WarnUnmatched([]*search.Match{match}) + return pathSet{} // There are no packages in the main module, so the main module isn't needed to resolve them. + } + + return pathSet{pkgMods: []module.Version{mainModule}} + }) + } +} + +// performPatternAllQueries populates the candidates for each query whose +// pattern is "all". +// +// The candidate modules for a given package in "all" depend only on the initial +// build list, but we cannot follow the dependencies of a given package until we +// know which candidate is selected — and that selection may depend on the +// results of other queries. We need to re-evaluate the "all" queries whenever +// the module for one or more packages in "all" are resolved. +func (r *resolver) performPatternAllQueries(loaderstate *modload.State, ctx context.Context) { + if len(r.patternAllQueries) == 0 { + return + } + + findPackage := func(ctx context.Context, path string, m module.Version) (versionOk bool) { + versionOk = true + for _, q := range r.patternAllQueries { + q.pathOnce(path, func() pathSet { + pkgMods, err := r.queryPackages(loaderstate, ctx, path, q.version, r.initialSelected) + if len(pkgMods) != 1 || pkgMods[0] != m { + // There are candidates other than m for the given path, so we can't + // be certain that m will actually be the module selected to provide + // the package. Don't load its dependencies just yet, because they + // might no longer be dependencies after we resolve the correct + // version. + versionOk = false + } + return pathSet{pkgMods: pkgMods, err: err} + }) + } + return versionOk + } + + r.loadPackages(loaderstate, ctx, []string{"all"}, findPackage) + + // Since we built up the candidate lists concurrently, they may be in a + // nondeterministic order. We want 'go get' to be fully deterministic, + // including in which errors it chooses to report, so sort the candidates + // into a deterministic-but-arbitrary order. + for _, q := range r.patternAllQueries { + sort.Slice(q.candidates, func(i, j int) bool { + return q.candidates[i].path < q.candidates[j].path + }) + } +} + +// findAndUpgradeImports returns a pathSet for each package that is not yet +// in the build list but is transitively imported by the packages matching the +// given queries (which must already have been resolved). +// +// If the getU flag ("-u") is set, findAndUpgradeImports also returns a +// pathSet for each module that is not constrained by any other +// command-line argument and has an available matching upgrade. +func (r *resolver) findAndUpgradeImports(loaderstate *modload.State, ctx context.Context, queries []*query) (upgrades []pathSet) { + patterns := make([]string, 0, len(queries)) + for _, q := range queries { + if q.matchesPackages { + patterns = append(patterns, q.pattern) + } + } + if len(patterns) == 0 { + return nil + } + + // mu guards concurrent writes to upgrades, which will be sorted + // (to restore determinism) after loading. + var mu sync.Mutex + + findPackage := func(ctx context.Context, path string, m module.Version) (versionOk bool) { + version := "latest" + if m.Path != "" { + if getU.version == "" { + // The user did not request that we upgrade transitive dependencies. + return true + } + if _, ok := r.resolvedVersion[m.Path]; ok { + // We cannot upgrade m implicitly because its version is determined by + // an explicit pattern argument. + return true + } + version = getU.version + } + + // Unlike other queries, the "-u" flag upgrades relative to the build list + // after applying changes so far, not the initial build list. + // This is for two reasons: + // + // - The "-u" flag intentionally applies to transitive dependencies, + // which may not be known or even resolved in advance of applying + // other version changes. + // + // - The "-u" flag, unlike other arguments, does not cause version + // conflicts with other queries. (The other query always wins.) + + pkgMods, err := r.queryPackages(loaderstate, ctx, path, version, r.selected) + for _, u := range pkgMods { + if u == m { + // The selected package version is already upgraded appropriately; there + // is no need to change it. + return true + } + } + + if err != nil { + if isNoSuchPackageVersion(err) || (m.Path == "" && module.CheckPath(path) != nil) { + // We can't find the package because it doesn't — or can't — even exist + // in any module at the latest version. (Note that invalid module paths + // could in general exist due to replacements, so we at least need to + // run the query to check those.) + // + // There is no version change we can make to fix the package, so leave + // it unresolved. Either some other query (perhaps a wildcard matching a + // newly-added dependency for some other missing package) will fill in + // the gaps, or we will report an error (with a better import stack) in + // the final LoadPackages call. + return true + } + } + + mu.Lock() + upgrades = append(upgrades, pathSet{path: path, pkgMods: pkgMods, err: err}) + mu.Unlock() + return false + } + + r.loadPackages(loaderstate, ctx, patterns, findPackage) + + // Since we built up the candidate lists concurrently, they may be in a + // nondeterministic order. We want 'go get' to be fully deterministic, + // including in which errors it chooses to report, so sort the candidates + // into a deterministic-but-arbitrary order. + sort.Slice(upgrades, func(i, j int) bool { + return upgrades[i].path < upgrades[j].path + }) + return upgrades +} + +// loadPackages loads the packages matching the given patterns, invoking the +// findPackage function for each package that may require a change to the +// build list. +// +// loadPackages invokes the findPackage function for each package loaded from a +// module outside the main module. If the module or version that supplies that +// package needs to be changed due to a query, findPackage may return false +// and the imports of that package will not be loaded. +// +// loadPackages also invokes the findPackage function for each imported package +// that is neither present in the standard library nor in any module in the +// build list. +func (r *resolver) loadPackages(loaderstate *modload.State, ctx context.Context, patterns []string, findPackage func(ctx context.Context, path string, m module.Version) (versionOk bool)) { + opts := modload.PackageOpts{ + Tags: imports.AnyTags(), + VendorModulesInGOROOTSrc: true, + LoadTests: *getT, + AssumeRootsImported: true, // After 'go get foo', imports of foo should build. + SilencePackageErrors: true, // May be fixed by subsequent upgrades or downgrades. + Switcher: toolchain.NewSwitcher(loaderstate), + } + + opts.AllowPackage = func(ctx context.Context, path string, m module.Version) error { + if m.Path == "" || m.Version == "" { + // Packages in the standard library and main modules are already at their + // latest (and only) available versions. + return nil + } + if ok := findPackage(ctx, path, m); !ok { + return errVersionChange + } + return nil + } + + _, pkgs := modload.LoadPackages(loaderstate, ctx, opts, patterns...) + for _, pkgPath := range pkgs { + const ( + parentPath = "" + parentIsStd = false + ) + _, _, err := modload.Lookup(loaderstate, parentPath, parentIsStd, pkgPath) + if err == nil { + continue + } + if errors.Is(err, errVersionChange) { + // We already added candidates during loading. + continue + } + if r.workspace != nil && r.workspace.hasPackage(pkgPath) { + // Don't try to resolve imports that are in the resolver's associated workspace. (#73654) + continue + } + + if _, ok := errors.AsType[*modload.ImportMissingError](err); !ok { + if _, ok := errors.AsType[*modload.AmbiguousImportError](err); !ok { + // The package, which is a dependency of something we care about, has some + // problem that we can't resolve with a version change. + // Leave the error for the final LoadPackages call. + continue + } + } + + path := pkgPath + r.work.Add(func() { + findPackage(ctx, path, module.Version{}) + }) + } + <-r.work.Idle() +} + +// errVersionChange is a sentinel error indicating that a module's version needs +// to be updated before its dependencies can be loaded. +var errVersionChange = errors.New("version change needed") + +// resolveQueries resolves candidate sets that are attached to the given +// queries and/or needed to provide the given missing-package dependencies. +// +// resolveQueries starts by resolving one module version from each +// unambiguous pathSet attached to the given queries. +// +// If no unambiguous query results in a change to the build list, +// resolveQueries revisits the ambiguous query candidates and resolves them +// arbitrarily in order to guarantee forward progress. +// +// If all pathSets are resolved without any changes to the build list, +// resolveQueries returns with changed=false. +func (r *resolver) resolveQueries(loaderstate *modload.State, ctx context.Context, queries []*query) (changed bool) { + defer base.ExitIfErrors() + + // Note: this is O(N²) with the number of pathSets in the worst case. + // + // We could perhaps get it down to O(N) if we were to index the pathSets + // by module path, so that we only revisit a given pathSet when the + // version of some module in its containingPackage list has been determined. + // + // However, N tends to be small, and most candidate sets will include only one + // candidate module (so they will be resolved in the first iteration), so for + // now we'll stick to the simple O(N²) approach. + + resolved := 0 + for { + prevResolved := resolved + + // If we found modules that were too new, find the max of the required versions + // and then try to switch to a newer toolchain. + sw := toolchain.NewSwitcher(loaderstate) + for _, q := range queries { + for _, cs := range q.candidates { + sw.Error(cs.err) + } + } + // Only switch if we need a newer toolchain. + // Otherwise leave the cs.err for reporting later. + if sw.NeedSwitch() { + sw.Switch(ctx) + // If NeedSwitch is true and Switch returns, Switch has failed to locate a newer toolchain. + // It printed the errors along with one more about not finding a good toolchain. + base.Exit() + } + + for _, q := range queries { + unresolved := q.candidates[:0] + + for _, cs := range q.candidates { + if cs.err != nil { + reportError(q, cs.err) + resolved++ + continue + } + + filtered, isPackage, m, unique := r.disambiguate(loaderstate, cs) + if !unique { + unresolved = append(unresolved, filtered) + continue + } + + if m.Path == "" { + // The query is not viable. Choose an arbitrary candidate from + // before filtering and “resolve” it to report a conflict. + isPackage, m = r.chooseArbitrarily(cs) + } + if isPackage { + q.matchesPackages = true + } + r.resolve(loaderstate, q, m) + resolved++ + } + + q.candidates = unresolved + } + + base.ExitIfErrors() + if resolved == prevResolved { + break // No unambiguous candidate remains. + } + } + + if resolved > 0 { + if changed = r.updateBuildList(loaderstate, ctx, nil); changed { + // The build list has changed, so disregard any remaining ambiguous queries: + // they might now be determined by requirements in the build list, which we + // would prefer to use instead of arbitrary versions. + return true + } + } + + // The build list will be the same on the next iteration as it was on this + // iteration, so any ambiguous queries will remain so. In order to make + // progress, resolve them arbitrarily but deterministically. + // + // If that results in conflicting versions, the user can re-run 'go get' + // with additional explicit versions for the conflicting packages or + // modules. + resolvedArbitrarily := 0 + for _, q := range queries { + for _, cs := range q.candidates { + isPackage, m := r.chooseArbitrarily(cs) + if isPackage { + q.matchesPackages = true + } + r.resolve(loaderstate, q, m) + resolvedArbitrarily++ + } + } + if resolvedArbitrarily > 0 { + changed = r.updateBuildList(loaderstate, ctx, nil) + } + return changed +} + +// applyUpgrades disambiguates candidate sets that are needed to upgrade (or +// provide) transitive dependencies imported by previously-resolved packages. +// +// applyUpgrades modifies the build list by adding one module version from each +// pathSet in upgrades, then downgrading (or further upgrading) those modules as +// needed to maintain any already-resolved versions of other modules. +// applyUpgrades does not mark the new versions as resolved, so they can still +// be further modified by other queries (such as wildcards). +// +// If all pathSets are resolved without any changes to the build list, +// applyUpgrades returns with changed=false. +func (r *resolver) applyUpgrades(loaderstate *modload.State, ctx context.Context, upgrades []pathSet) (changed bool) { + defer base.ExitIfErrors() + + // Arbitrarily add a "latest" version that provides each missing package, but + // do not mark the version as resolved: we still want to allow the explicit + // queries to modify the resulting versions. + var tentative []module.Version + for _, cs := range upgrades { + if cs.err != nil { + base.Error(cs.err) + continue + } + + filtered, _, m, unique := r.disambiguate(loaderstate, cs) + if !unique { + _, m = r.chooseArbitrarily(filtered) + } + if m.Path == "" { + // There is no viable candidate for the missing package. + // Leave it unresolved. + continue + } + tentative = append(tentative, m) + } + base.ExitIfErrors() + + changed = r.updateBuildList(loaderstate, ctx, tentative) + return changed +} + +// disambiguate eliminates candidates from cs that conflict with other module +// versions that have already been resolved. If there is only one (unique) +// remaining candidate, disambiguate returns that candidate, along with +// an indication of whether that result interprets cs.path as a package +// +// Note: we're only doing very simple disambiguation here. The goal is to +// reproduce the user's intent, not to find a solution that a human couldn't. +// In the vast majority of cases, we expect only one module per pathSet, +// but we want to give some minimal additional tools so that users can add an +// extra argument or two on the command line to resolve simple ambiguities. +func (r *resolver) disambiguate(s *modload.State, cs pathSet) (filtered pathSet, isPackage bool, m module.Version, unique bool) { + if len(cs.pkgMods) == 0 && cs.mod.Path == "" { + panic("internal error: resolveIfUnambiguous called with empty pathSet") + } + + for _, m := range cs.pkgMods { + if _, ok := r.noneForPath(m.Path); ok { + // A query with version "none" forces the candidate module to version + // "none", so we cannot use any other version for that module. + continue + } + + if s.MainModules.Contains(m.Path) { + if m.Version == "" { + return pathSet{}, true, m, true + } + // A main module can only be set to its own version. + continue + } + + vr, ok := r.resolvedVersion[m.Path] + if !ok { + // m is a viable answer to the query, but other answers may also + // still be viable. + filtered.pkgMods = append(filtered.pkgMods, m) + continue + } + + if vr.version != m.Version { + // Some query forces the candidate module to a version other than this + // one. + // + // The command could be something like + // + // go get example.com/foo/bar@none example.com/foo/bar/baz@latest + // + // in which case we *cannot* resolve the package from + // example.com/foo/bar (because it is constrained to version + // "none") and must fall through to module example.com/foo@latest. + continue + } + + // Some query forces the candidate module *to* the candidate version. + // As a result, this candidate is the only viable choice to provide + // its package(s): any other choice would result in an ambiguous import + // for this path. + // + // For example, consider the command + // + // go get example.com/foo@latest example.com/foo/bar/baz@latest + // + // If modules example.com/foo and example.com/foo/bar both provide + // package example.com/foo/bar/baz, then we *must* resolve the package + // from example.com/foo: if we instead resolved it from + // example.com/foo/bar, we would have two copies of the package. + return pathSet{}, true, m, true + } + + if cs.mod.Path != "" { + vr, ok := r.resolvedVersion[cs.mod.Path] + if !ok || vr.version == cs.mod.Version { + filtered.mod = cs.mod + } + } + + if len(filtered.pkgMods) == 1 && + (filtered.mod.Path == "" || filtered.mod == filtered.pkgMods[0]) { + // Exactly one viable module contains the package with the given path + // (by far the common case), so we can resolve it unambiguously. + return pathSet{}, true, filtered.pkgMods[0], true + } + + if len(filtered.pkgMods) == 0 { + // All modules that could provide the path as a package conflict with other + // resolved arguments. If it can refer to a module instead, return that; + // otherwise, this pathSet cannot be resolved (and we will return the + // zero module.Version). + return pathSet{}, false, filtered.mod, true + } + + // The query remains ambiguous: there are at least two different modules + // to which cs.path could refer. + return filtered, false, module.Version{}, false +} + +// chooseArbitrarily returns an arbitrary (but deterministic) module version +// from among those in the given set. +// +// chooseArbitrarily prefers module paths that were already in the build list at +// the start of 'go get', prefers modules that provide packages over those that +// do not, and chooses the first module meeting those criteria (so biases toward +// longer paths). +func (r *resolver) chooseArbitrarily(cs pathSet) (isPackage bool, m module.Version) { + // Prefer to upgrade some module that was already in the build list. + for _, m := range cs.pkgMods { + if r.initialSelected(m.Path) != "none" { + return true, m + } + } + + // Otherwise, arbitrarily choose the first module that provides the package. + if len(cs.pkgMods) > 0 { + return true, cs.pkgMods[0] + } + + return false, cs.mod +} + +// checkPackageProblems reloads packages for the given patterns and reports +// missing and ambiguous package errors. It also reports retractions and +// deprecations for resolved modules and modules needed to build named packages. +// It also adds a sum for each updated module in the build list if we had one +// before and didn't get one while loading packages. +// +// We skip missing-package errors earlier in the process, since we want to +// resolve pathSets ourselves, but at that point, we don't have enough context +// to log the package-import chains leading to each error. +func (r *resolver) checkPackageProblems(loaderstate *modload.State, ctx context.Context, pkgPatterns []string) { + defer base.ExitIfErrors() + + // Enter workspace mode, if the current main module would belong to it, when + // doing the workspace load. We want to check that the workspace loads properly + // and doesn't have missing or ambiguous imports (rather than checking the module + // by itself) because the module may have unreleased dependencies in the workspace. + // We'll also report issues for retracted and deprecated modules using the workspace + // info, but switch back to single module mode when fetching sums so that we update + // the single module's go.sum file. + var exitWorkspace func() + if r.workspace != nil && r.workspace.hasModule(loaderstate.MainModules.Versions()[0].Path) { + var err error + exitWorkspace, err = modload.EnterWorkspace(loaderstate, ctx) + if err != nil { + // A TooNewError can happen for + // go get go@newversion when all the required modules + // are old enough but the go command itself is not new + // enough. See the related comment on the SwitchOrFatal + // in runGet when WriteGoMod returns an error. + toolchain.SwitchOrFatal(loaderstate, ctx, err) + } + } + + // Gather information about modules we might want to load retractions and + // deprecations for. Loading this metadata requires at least one version + // lookup per module, and we don't want to load information that's neither + // relevant nor actionable. + type modFlags int + const ( + resolved modFlags = 1 << iota // version resolved by 'go get' + named // explicitly named on command line or provides a named package + hasPkg // needed to build named packages + direct // provides a direct dependency of the main module or workspace modules + ) + relevantMods := make(map[module.Version]modFlags) + for path, reason := range r.resolvedVersion { + m := module.Version{Path: path, Version: reason.version} + relevantMods[m] |= resolved + } + + // Reload packages, reporting errors for missing and ambiguous imports. + if len(pkgPatterns) > 0 { + // LoadPackages will print errors (since it has more context) but will not + // exit, since we need to load retractions later. + pkgOpts := modload.PackageOpts{ + VendorModulesInGOROOTSrc: true, + LoadTests: *getT, + ResolveMissingImports: false, + AllowErrors: true, + SilenceNoGoErrors: true, + } + matches, pkgs := modload.LoadPackages(loaderstate, ctx, pkgOpts, pkgPatterns...) + for _, m := range matches { + if len(m.Errs) > 0 { + base.SetExitStatus(1) + break + } + } + for _, pkg := range pkgs { + if dir, _, err := modload.Lookup(loaderstate, "", false, pkg); err != nil { + if dir != "" && errors.Is(err, imports.ErrNoGo) { + // Since dir is non-empty, we must have located source files + // associated with either the package or its test — ErrNoGo must + // indicate that none of those source files happen to apply in this + // configuration. If we are actually building the package (no -d + // flag), we will report the problem then; otherwise, assume that the + // user is going to build or test this package in some other + // configuration and suppress the error. + continue + } + + base.SetExitStatus(1) + if ambiguousErr, ok := errors.AsType[*modload.AmbiguousImportError](err); ok { + for _, m := range ambiguousErr.Modules { + relevantMods[m] |= hasPkg + } + } + } + if m := modload.PackageModule(pkg); m.Path != "" { + relevantMods[m] |= hasPkg + } + } + for _, match := range matches { + for _, pkg := range match.Pkgs { + m := modload.PackageModule(pkg) + relevantMods[m] |= named + } + } + } + + reqs := modload.LoadModFile(loaderstate, ctx) + for m := range relevantMods { + if reqs.IsDirect(m.Path) { + relevantMods[m] |= direct + } + } + + // Load retractions for modules mentioned on the command line and modules + // needed to build named packages. We care about retractions of indirect + // dependencies, since we might be able to upgrade away from them. + type modMessage struct { + m module.Version + message string + } + retractions := make([]modMessage, 0, len(relevantMods)) + for m, flags := range relevantMods { + if flags&(resolved|named|hasPkg) != 0 { + retractions = append(retractions, modMessage{m: m}) + } + } + sort.Slice(retractions, func(i, j int) bool { return retractions[i].m.Path < retractions[j].m.Path }) + for i := range retractions { + i := i + r.work.Add(func() { + err := loaderstate.CheckRetractions(ctx, retractions[i].m) + if _, ok := errors.AsType[*modload.ModuleRetractedError](err); ok { + retractions[i].message = err.Error() + } + }) + } + + // Load deprecations for modules mentioned on the command line. Only load + // deprecations for indirect dependencies if they're also direct dependencies + // of the main module or workspace modules. Deprecations of purely indirect + // dependencies are not actionable. + deprecations := make([]modMessage, 0, len(relevantMods)) + for m, flags := range relevantMods { + if flags&(resolved|named) != 0 || flags&(hasPkg|direct) == hasPkg|direct { + deprecations = append(deprecations, modMessage{m: m}) + } + } + sort.Slice(deprecations, func(i, j int) bool { return deprecations[i].m.Path < deprecations[j].m.Path }) + for i := range deprecations { + i := i + r.work.Add(func() { + deprecation, err := modload.CheckDeprecation(loaderstate, ctx, deprecations[i].m) + if err != nil || deprecation == "" { + return + } + deprecations[i].message = modload.ShortMessage(deprecation, "") + }) + } + + // exit the workspace if we had entered it earlier. We want to add the sums + // to the go.sum file for the module we're running go get from. + if exitWorkspace != nil { + // Wait for retraction and deprecation checks (that depend on the global + // modload state containing the workspace) to finish before we reset the + // state back to single module mode. + <-r.work.Idle() + exitWorkspace() + } + + // Load sums for updated modules that had sums before. When we update a + // module, we may update another module in the build list that provides a + // package in 'all' that wasn't loaded as part of this 'go get' command. + // If we don't add a sum for that module, builds may fail later. + // Note that an incidentally updated package could still import packages + // from unknown modules or from modules in the build list that we didn't + // need previously. We can't handle that case without loading 'all'. + sumErrs := make([]error, len(r.buildList)) + for i := range r.buildList { + i := i + m := r.buildList[i] + mActual := m + if mRepl := modload.Replacement(loaderstate, m); mRepl.Path != "" { + mActual = mRepl + } + old := module.Version{Path: m.Path, Version: r.initialVersion[m.Path]} + if old.Version == "" { + continue + } + oldActual := old + if oldRepl := modload.Replacement(loaderstate, old); oldRepl.Path != "" { + oldActual = oldRepl + } + if mActual == oldActual || mActual.Version == "" || !modfetch.HaveSum(loaderstate.Fetcher(), oldActual) { + continue + } + r.work.Add(func() { + if _, err := loaderstate.Fetcher().DownloadZip(ctx, mActual); err != nil { + verb := "upgraded" + if gover.ModCompare(m.Path, m.Version, old.Version) < 0 { + verb = "downgraded" + } + replaced := "" + if mActual != m { + replaced = fmt.Sprintf(" (replaced by %s)", mActual) + } + err = fmt.Errorf("%s %s %s => %s%s: error finding sum for %s: %v", verb, m.Path, old.Version, m.Version, replaced, mActual, err) + sumErrs[i] = err + } + }) + } + + <-r.work.Idle() + + // Report deprecations, then retractions, then errors fetching sums. + // Only errors fetching sums are hard errors. + for _, mm := range deprecations { + if mm.message != "" { + fmt.Fprintf(os.Stderr, "go: module %s is deprecated: %s\n", mm.m.Path, mm.message) + } + } + var retractPath string + for _, mm := range retractions { + if mm.message != "" { + fmt.Fprintf(os.Stderr, "go: warning: %v\n", mm.message) + if retractPath == "" { + retractPath = mm.m.Path + } else { + retractPath = "" + } + } + } + if retractPath != "" { + fmt.Fprintf(os.Stderr, "go: to switch to the latest unretracted version, run:\n\tgo get %s@latest\n", retractPath) + } + for _, err := range sumErrs { + if err != nil { + base.Error(err) + } + } +} + +// reportChanges logs version changes to os.Stderr. +// +// reportChanges only logs changes to modules named on the command line and to +// explicitly required modules in go.mod. Most changes to indirect requirements +// are not relevant to the user and are not logged. +// +// reportChanges should be called after WriteGoMod. +func (r *resolver) reportChanges(oldReqs, newReqs []module.Version) { + type change struct { + path, old, new string + } + changes := make(map[string]change) + + // Collect changes in modules matched by command line arguments. + for path, reason := range r.resolvedVersion { + if gover.IsToolchain(path) { + continue + } + old := r.initialVersion[path] + new := reason.version + if old != new && (old != "" || new != "none") { + changes[path] = change{path, old, new} + } + } + + // Collect changes to explicit requirements in go.mod. + for _, req := range oldReqs { + if gover.IsToolchain(req.Path) { + continue + } + path := req.Path + old := req.Version + new := r.buildListVersion[path] + if old != new { + changes[path] = change{path, old, new} + } + } + for _, req := range newReqs { + if gover.IsToolchain(req.Path) { + continue + } + path := req.Path + old := r.initialVersion[path] + new := req.Version + if old != new { + changes[path] = change{path, old, new} + } + } + + // Toolchain diffs are easier than requirements: diff old and new directly. + toolchainVersions := func(reqs []module.Version) (goV, toolchain string) { + for _, req := range reqs { + if req.Path == "go" { + goV = req.Version + } + if req.Path == "toolchain" { + toolchain = req.Version + } + } + return + } + oldGo, oldToolchain := toolchainVersions(oldReqs) + newGo, newToolchain := toolchainVersions(newReqs) + if oldGo != newGo { + changes["go"] = change{"go", oldGo, newGo} + } + if oldToolchain != newToolchain { + changes["toolchain"] = change{"toolchain", oldToolchain, newToolchain} + } + + sortedChanges := make([]change, 0, len(changes)) + for _, c := range changes { + sortedChanges = append(sortedChanges, c) + } + sort.Slice(sortedChanges, func(i, j int) bool { + pi := sortedChanges[i].path + pj := sortedChanges[j].path + if pi == pj { + return false + } + // go first; toolchain second + switch { + case pi == "go": + return true + case pj == "go": + return false + case pi == "toolchain": + return true + case pj == "toolchain": + return false + } + return pi < pj + }) + + for _, c := range sortedChanges { + if c.old == "" { + fmt.Fprintf(os.Stderr, "go: added %s %s\n", c.path, c.new) + } else if c.new == "none" || c.new == "" { + fmt.Fprintf(os.Stderr, "go: removed %s %s\n", c.path, c.old) + } else if gover.ModCompare(c.path, c.new, c.old) > 0 { + fmt.Fprintf(os.Stderr, "go: upgraded %s %s => %s\n", c.path, c.old, c.new) + if c.path == "go" && gover.Compare(c.old, gover.ExplicitIndirectVersion) < 0 && gover.Compare(c.new, gover.ExplicitIndirectVersion) >= 0 { + fmt.Fprintf(os.Stderr, "\tnote: expanded dependencies to upgrade to go %s or higher; run 'go mod tidy' to clean up\n", gover.ExplicitIndirectVersion) + } + + } else { + fmt.Fprintf(os.Stderr, "go: downgraded %s %s => %s\n", c.path, c.old, c.new) + } + } + + // TODO(golang.org/issue/33284): attribute changes to command line arguments. + // For modules matched by command line arguments, this probably isn't + // necessary, but it would be useful for unmatched direct dependencies of + // the main module. +} + +// resolve records that module m must be at its indicated version (which may be +// "none") due to query q. If some other query forces module m to be at a +// different version, resolve reports a conflict error. +func (r *resolver) resolve(s *modload.State, q *query, m module.Version) { + if m.Path == "" { + panic("internal error: resolving a module.Version with an empty path") + } + + if s.MainModules.Contains(m.Path) && m.Version != "" { + reportError(q, &modload.QueryMatchesMainModulesError{ + MainModules: []module.Version{{Path: m.Path}}, + Pattern: q.pattern, + Query: q.version, + PatternIsModule: s.MainModules.Contains(q.pattern), + }) + return + } + + vr, ok := r.resolvedVersion[m.Path] + if ok && vr.version != m.Version { + reportConflict(q, m, vr) + return + } + r.resolvedVersion[m.Path] = versionReason{m.Version, q} + q.resolved = append(q.resolved, m) +} + +// updateBuildList updates the module loader's global build list to be +// consistent with r.resolvedVersion, and to include additional modules +// provided that they do not conflict with the resolved versions. +// +// If the additional modules conflict with the resolved versions, they will be +// downgraded to a non-conflicting version (possibly "none"). +// +// If the resulting build list is the same as the one resulting from the last +// call to updateBuildList, updateBuildList returns with changed=false. +func (r *resolver) updateBuildList(loaderstate *modload.State, ctx context.Context, additions []module.Version) (changed bool) { + defer base.ExitIfErrors() + + resolved := make([]module.Version, 0, len(r.resolvedVersion)) + for mPath, rv := range r.resolvedVersion { + if !loaderstate.MainModules.Contains(mPath) { + resolved = append(resolved, module.Version{Path: mPath, Version: rv.version}) + } + } + + changed, err := modload.EditBuildList(loaderstate, ctx, additions, resolved) + if err != nil { + if errors.Is(err, gover.ErrTooNew) { + toolchain.SwitchOrFatal(loaderstate, ctx, err) + } + + constraint, ok := errors.AsType[*modload.ConstraintError](err) + if !ok { + base.Fatal(err) + } + + if cfg.BuildV { + // Log complete paths for the conflicts before we summarize them. + for _, c := range constraint.Conflicts { + fmt.Fprintf(os.Stderr, "go: %v\n", c.String()) + } + } + + // modload.EditBuildList reports constraint errors at + // the module level, but 'go get' operates on packages. + // Rewrite the errors to explain them in terms of packages. + reason := func(m module.Version) string { + rv, ok := r.resolvedVersion[m.Path] + if !ok { + return fmt.Sprintf("(INTERNAL ERROR: no reason found for %v)", m) + } + return rv.reason.ResolvedString(module.Version{Path: m.Path, Version: rv.version}) + } + for _, c := range constraint.Conflicts { + adverb := "" + if len(c.Path) > 2 { + adverb = "indirectly " + } + firstReason := reason(c.Path[0]) + last := c.Path[len(c.Path)-1] + if c.Err != nil { + base.Errorf("go: %v %srequires %v: %v", firstReason, adverb, last, c.UnwrapModuleError()) + } else { + base.Errorf("go: %v %srequires %v, not %v", firstReason, adverb, last, reason(c.Constraint)) + } + } + return false + } + if !changed { + return false + } + + mg, err := modload.LoadModGraph(loaderstate, ctx, "") + if err != nil { + toolchain.SwitchOrFatal(loaderstate, ctx, err) + } + + r.buildList = mg.BuildList() + r.buildListVersion = make(map[string]string, len(r.buildList)) + for _, m := range r.buildList { + r.buildListVersion[m.Path] = m.Version + } + return true +} + +func reqsFromGoMod(f *modfile.File) []module.Version { + reqs := make([]module.Version, len(f.Require), 2+len(f.Require)) + for i, r := range f.Require { + reqs[i] = r.Mod + } + if f.Go != nil { + reqs = append(reqs, module.Version{Path: "go", Version: f.Go.Version}) + } + if f.Toolchain != nil { + reqs = append(reqs, module.Version{Path: "toolchain", Version: f.Toolchain.Name}) + } + return reqs +} + +// isNoSuchModuleVersion reports whether err indicates that the requested module +// does not exist at the requested version, either because the module does not +// exist at all or because it does not include that specific version. +func isNoSuchModuleVersion(err error) bool { + if errors.Is(err, os.ErrNotExist) { + return true + } + _, ok := errors.AsType[*modload.NoMatchingVersionError](err) + return ok +} + +// isNoSuchPackageVersion reports whether err indicates that the requested +// package does not exist at the requested version, either because no module +// that could contain it exists at that version, or because every such module +// that does exist does not actually contain the package. +func isNoSuchPackageVersion(err error) bool { + if isNoSuchModuleVersion(err) { + return true + } + _, ok := errors.AsType[*modload.PackageNotInModuleError](err) + return ok +} + +// workspace represents the set of modules in a workspace. +// It can be used +type workspace struct { + modules map[string]string // path -> modroot +} + +// loadWorkspace loads infomation about a workspace using a go.work +// file path. +func loadWorkspace(workFilePath string) *workspace { + if workFilePath == "" { + // Return the empty workspace checker. All HasPackage checks will return false. + return nil + } + + _, modRoots, err := modload.LoadWorkFile(workFilePath) + if err != nil { + return nil + } + + w := &workspace{modules: make(map[string]string)} + for _, modRoot := range modRoots { + modFile := filepath.Join(modRoot, "go.mod") + _, f, err := modload.ReadModFile(modFile, nil) + if err != nil { + continue // Error will be reported in the final load of the workspace. + } + w.modules[f.Module.Mod.Path] = modRoot + } + + return w +} + +// hasPackage reports whether there is a workspace module that could +// provide the package with the given path. +func (w *workspace) hasPackage(pkgpath string) bool { + for modPath, modroot := range w.modules { + if modload.PkgIsInLocalModule(pkgpath, modPath, modroot) { + return true + } + } + return false +} + +// hasModule reports whether there is a workspace module with the given +// path. +func (w *workspace) hasModule(modPath string) bool { + _, ok := w.modules[modPath] + return ok +} diff --git a/go/src/cmd/go/internal/modget/query.go b/go/src/cmd/go/internal/modget/query.go new file mode 100644 index 0000000000000000000000000000000000000000..e9807edda520c4c2c500ddb9abc9a888d78bf917 --- /dev/null +++ b/go/src/cmd/go/internal/modget/query.go @@ -0,0 +1,370 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modget + +import ( + "fmt" + "path/filepath" + "regexp" + "strings" + "sync" + "unicode/utf8" + + "cmd/go/internal/base" + "cmd/go/internal/gover" + "cmd/go/internal/modload" + "cmd/go/internal/search" + "cmd/go/internal/str" + "cmd/internal/pkgpattern" + + "golang.org/x/mod/module" +) + +// A query describes a command-line argument and the modules and/or packages +// to which that argument may resolve.. +type query struct { + // raw is the original argument, to be printed in error messages. + raw string + + // rawVersion is the portion of raw corresponding to version, if any + rawVersion string + + // pattern is the part of the argument before "@" (or the whole argument + // if there is no "@"), which may match either packages (preferred) or + // modules (if no matching packages). + // + // The pattern may also be "-u", for the synthetic query representing the -u + // (“upgrade”)flag. + pattern string + + // patternIsLocal indicates whether pattern is restricted to match only paths + // local to the main module, such as absolute filesystem paths or paths + // beginning with './'. + // + // A local pattern must resolve to one or more packages in the main module. + patternIsLocal bool + + // version is the part of the argument after "@", or an implied + // "upgrade" or "patch" if there is no "@". version specifies the + // module version to get. + version string + + // matchWildcard, if non-nil, reports whether pattern, which must be a + // wildcard (with the substring "..."), matches the given package or module + // path. + matchWildcard func(path string) bool + + // canMatchWildcardInModule, if non-nil, reports whether the module with the given + // path could lexically contain a package matching pattern, which must be a + // wildcard. + canMatchWildcardInModule func(mPath string) bool + + // conflict is the first query identified as incompatible with this one. + // conflict forces one or more of the modules matching this query to a + // version that does not match version. + conflict *query + + // candidates is a list of sets of alternatives for a path that matches (or + // contains packages that match) the pattern. The query can be resolved by + // choosing exactly one alternative from each set in the list. + // + // A path-literal query results in only one set: the path itself, which + // may resolve to either a package path or a module path. + // + // A wildcard query results in one set for each matching module path, each + // module for which the matching version contains at least one matching + // package, and (if no other modules match) one candidate set for the pattern + // overall if no existing match is identified in the build list. + // + // A query for pattern "all" results in one set for each package transitively + // imported by the main module. + // + // The special query for the "-u" flag results in one set for each + // otherwise-unconstrained package that has available upgrades. + candidates []pathSet + candidatesMu sync.Mutex + + // pathSeen ensures that only one pathSet is added to the query per + // unique path. + pathSeen sync.Map + + // resolved contains the set of modules whose versions have been determined by + // this query, in the order in which they were determined. + // + // The resolver examines the candidate sets for each query, resolving one + // module per candidate set in a way that attempts to avoid obvious conflicts + // between the versions resolved by different queries. + resolved []module.Version + + // matchesPackages is true if the resolved modules provide at least one + // package matching q.pattern. + matchesPackages bool +} + +// A pathSet describes the possible options for resolving a specific path +// to a package and/or module. +type pathSet struct { + // path is a package (if "all" or "-u" or a non-wildcard) or module (if + // wildcard) path that could be resolved by adding any of the modules in this + // set. For a wildcard pattern that so far matches no packages, the path is + // the wildcard pattern itself. + // + // Each path must occur only once in a query's candidate sets, and the path is + // added implicitly to each pathSet returned to pathOnce. + path string + + // pkgMods is a set of zero or more modules, each of which contains the + // package with the indicated path. Due to the requirement that imports be + // unambiguous, only one such module can be in the build list, and all others + // must be excluded. + pkgMods []module.Version + + // mod is either the zero Version, or a module that does not contain any + // packages matching the query but for which the module path itself + // matches the query pattern. + // + // We track this module separately from pkgMods because, all else equal, we + // prefer to match a query to a package rather than just a module. Also, + // unlike the modules in pkgMods, this module does not inherently exclude + // any other module in pkgMods. + mod module.Version + + err error +} + +// errSet returns a pathSet containing the given error. +func errSet(err error) pathSet { return pathSet{err: err} } + +// newQuery returns a new query parsed from the raw argument, +// which must be either path or path@version. +func newQuery(loaderstate *modload.State, raw string) (*query, error) { + pattern, rawVers, found, err := modload.ParsePathVersion(raw) + if err != nil { + return nil, err + } + if found && (strings.Contains(rawVers, "@") || rawVers == "") { + return nil, fmt.Errorf("invalid module version syntax %q", raw) + } + + // If no version suffix is specified, assume @upgrade. + // If -u=patch was specified, assume @patch instead. + version := rawVers + if version == "" { + if getU.version == "" { + version = "upgrade" + } else { + version = getU.version + } + } + + q := &query{ + raw: raw, + rawVersion: rawVers, + pattern: pattern, + patternIsLocal: filepath.IsAbs(pattern) || search.IsRelativePath(pattern), + version: version, + } + if strings.Contains(q.pattern, "...") { + q.matchWildcard = pkgpattern.MatchPattern(q.pattern) + q.canMatchWildcardInModule = pkgpattern.TreeCanMatchPattern(q.pattern) + } + if err := q.validate(loaderstate); err != nil { + return q, err + } + return q, nil +} + +// validate reports a non-nil error if q is not sensible and well-formed. +func (q *query) validate(loaderstate *modload.State) error { + if q.patternIsLocal { + if q.rawVersion != "" { + return fmt.Errorf("can't request explicit version %q of path %q in main module", q.rawVersion, q.pattern) + } + return nil + } + + if q.pattern == "all" { + // If there is no main module, "all" is not meaningful. + if !loaderstate.HasModRoot() { + return fmt.Errorf(`cannot match "all": %v`, modload.NewNoMainModulesError(loaderstate)) + } + if !versionOkForMainModule(q.version) { + // TODO(bcmills): "all@none" seems like a totally reasonable way to + // request that we remove all module requirements, leaving only the main + // module and standard library. Perhaps we should implement that someday. + return &modload.QueryUpgradesAllError{ + MainModules: loaderstate.MainModules.Versions(), + Query: q.version, + } + } + } + + if search.IsMetaPackage(q.pattern) && q.pattern != "all" { + if q.pattern != q.raw { + if q.pattern == "tool" { + return fmt.Errorf("can't request explicit version of \"tool\" pattern") + } + return fmt.Errorf("can't request explicit version of standard-library pattern %q", q.pattern) + } + } + + return nil +} + +// String returns the original argument from which q was parsed. +func (q *query) String() string { return q.raw } + +// ResolvedString returns a string describing m as a resolved match for q. +func (q *query) ResolvedString(m module.Version) string { + if m.Path != q.pattern { + if m.Version != q.version { + return fmt.Sprintf("%v (matching %s@%s)", m, q.pattern, q.version) + } + return fmt.Sprintf("%v (matching %v)", m, q) + } + if m.Version != q.version { + return fmt.Sprintf("%s@%s (%s)", q.pattern, q.version, m.Version) + } + return q.String() +} + +// isWildcard reports whether q is a pattern that can match multiple paths. +func (q *query) isWildcard() bool { + return q.matchWildcard != nil || (q.patternIsLocal && strings.Contains(q.pattern, "...")) +} + +// matchesPath reports whether the given path matches q.pattern. +func (q *query) matchesPath(path string) bool { + if q.matchWildcard != nil && !gover.IsToolchain(path) { + return q.matchWildcard(path) + } + return path == q.pattern +} + +// canMatchInModule reports whether the given module path can potentially +// contain q.pattern. +func (q *query) canMatchInModule(mPath string) bool { + if gover.IsToolchain(mPath) { + return false + } + if q.canMatchWildcardInModule != nil { + return q.canMatchWildcardInModule(mPath) + } + return str.HasPathPrefix(q.pattern, mPath) +} + +// pathOnce invokes f to generate the pathSet for the given path, +// if one is still needed. +// +// Note that, unlike sync.Once, pathOnce does not guarantee that a concurrent +// call to f for the given path has completed on return. +// +// pathOnce is safe for concurrent use by multiple goroutines, but note that +// multiple concurrent calls will result in the sets being added in +// nondeterministic order. +func (q *query) pathOnce(path string, f func() pathSet) { + if _, dup := q.pathSeen.LoadOrStore(path, nil); dup { + return + } + + cs := f() + + if len(cs.pkgMods) > 0 || cs.mod != (module.Version{}) || cs.err != nil { + cs.path = path + q.candidatesMu.Lock() + q.candidates = append(q.candidates, cs) + q.candidatesMu.Unlock() + } +} + +// reportError logs err concisely using base.Errorf. +func reportError(q *query, err error) { + errStr := err.Error() + + // If err already mentions all of the relevant parts of q, just log err to + // reduce stutter. Otherwise, log both q and err. + // + // TODO(bcmills): Use errors.AsType to unpack these errors instead of parsing + // strings with regular expressions. + + if !utf8.ValidString(q.pattern) || !utf8.ValidString(q.version) { + base.Errorf("go: %s", errStr) + return + } + + patternRE := regexp.MustCompile("(?m)(?:[ \t(\"`]|^)" + regexp.QuoteMeta(q.pattern) + "(?:[ @:;)\"`]|$)") + if patternRE.MatchString(errStr) { + if q.rawVersion == "" { + base.Errorf("go: %s", errStr) + return + } + + versionRE := regexp.MustCompile("(?m)(?:[ @(\"`]|^)" + regexp.QuoteMeta(q.version) + "(?:[ :;)\"`]|$)") + if versionRE.MatchString(errStr) { + base.Errorf("go: %s", errStr) + return + } + } + + if qs := q.String(); qs != "" { + base.Errorf("go: %s: %s", qs, errStr) + } else { + base.Errorf("go: %s", errStr) + } +} + +func reportConflict(pq *query, m module.Version, conflict versionReason) { + if pq.conflict != nil { + // We've already reported a conflict for the proposed query. + // Don't report it again, even if it has other conflicts. + return + } + pq.conflict = conflict.reason + + proposed := versionReason{ + version: m.Version, + reason: pq, + } + if pq.isWildcard() && !conflict.reason.isWildcard() { + // Prefer to report the specific path first and the wildcard second. + proposed, conflict = conflict, proposed + } + reportError(pq, &conflictError{ + mPath: m.Path, + proposed: proposed, + conflict: conflict, + }) +} + +type conflictError struct { + mPath string + proposed versionReason + conflict versionReason +} + +func (e *conflictError) Error() string { + argStr := func(q *query, v string) string { + if v != q.version { + return fmt.Sprintf("%s@%s (%s)", q.pattern, q.version, v) + } + return q.String() + } + + pq := e.proposed.reason + rq := e.conflict.reason + modDetail := "" + if e.mPath != pq.pattern { + modDetail = fmt.Sprintf("for module %s, ", e.mPath) + } + + return fmt.Sprintf("%s%s conflicts with %s", + modDetail, + argStr(pq, e.proposed.version), + argStr(rq, e.conflict.version)) +} + +func versionOkForMainModule(version string) bool { + return version == "upgrade" || version == "patch" +} diff --git a/go/src/cmd/go/internal/modindex/build.go b/go/src/cmd/go/internal/modindex/build.go new file mode 100644 index 0000000000000000000000000000000000000000..053e04dfe599e9bfcddb8cb368d77f3af9f8e114 --- /dev/null +++ b/go/src/cmd/go/internal/modindex/build.go @@ -0,0 +1,755 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file is a lightly modified copy go/build/build.go with unused parts +// removed. + +package modindex + +import ( + "bytes" + "cmd/go/internal/fsys" + "errors" + "fmt" + "go/ast" + "go/build" + "go/build/constraint" + "go/token" + "internal/syslist" + "io" + "io/fs" + "path/filepath" + "slices" + "sort" + "strings" + "unicode" + "unicode/utf8" +) + +// A Context specifies the supporting context for a build. +type Context struct { + GOARCH string // target architecture + GOOS string // target operating system + GOROOT string // Go root + GOPATH string // Go paths + + // Dir is the caller's working directory, or the empty string to use + // the current directory of the running process. In module mode, this is used + // to locate the main module. + // + // If Dir is non-empty, directories passed to Import and ImportDir must + // be absolute. + Dir string + + CgoEnabled bool // whether cgo files are included + UseAllFiles bool // use files regardless of //go:build lines, file names + Compiler string // compiler to assume when computing target paths + + // The build, tool, and release tags specify build constraints + // that should be considered satisfied when processing +build lines. + // Clients creating a new context may customize BuildTags, which + // defaults to empty, but it is usually an error to customize ToolTags or ReleaseTags. + // ToolTags defaults to build tags appropriate to the current Go toolchain configuration. + // ReleaseTags defaults to the list of Go releases the current release is compatible with. + // BuildTags is not set for the Default build Context. + // In addition to the BuildTags, ToolTags, and ReleaseTags, build constraints + // consider the values of GOARCH and GOOS as satisfied tags. + // The last element in ReleaseTags is assumed to be the current release. + BuildTags []string + ToolTags []string + ReleaseTags []string + + // The install suffix specifies a suffix to use in the name of the installation + // directory. By default it is empty, but custom builds that need to keep + // their outputs separate can set InstallSuffix to do so. For example, when + // using the race detector, the go command uses InstallSuffix = "race", so + // that on a Linux/386 system, packages are written to a directory named + // "linux_386_race" instead of the usual "linux_386". + InstallSuffix string + + // By default, Import uses the operating system's file system calls + // to read directories and files. To read from other sources, + // callers can set the following functions. They all have default + // behaviors that use the local file system, so clients need only set + // the functions whose behaviors they wish to change. + + // JoinPath joins the sequence of path fragments into a single path. + // If JoinPath is nil, Import uses filepath.Join. + JoinPath func(elem ...string) string + + // SplitPathList splits the path list into a slice of individual paths. + // If SplitPathList is nil, Import uses filepath.SplitList. + SplitPathList func(list string) []string + + // IsAbsPath reports whether path is an absolute path. + // If IsAbsPath is nil, Import uses filepath.IsAbs. + IsAbsPath func(path string) bool + + // IsDir reports whether the path names a directory. + // If IsDir is nil, Import calls os.Stat and uses the result's IsDir method. + IsDir func(path string) bool + + // HasSubdir reports whether dir is lexically a subdirectory of + // root, perhaps multiple levels below. It does not try to check + // whether dir exists. + // If so, HasSubdir sets rel to a slash-separated path that + // can be joined to root to produce a path equivalent to dir. + // If HasSubdir is nil, Import uses an implementation built on + // filepath.EvalSymlinks. + HasSubdir func(root, dir string) (rel string, ok bool) + + // ReadDir returns a slice of fs.FileInfo, sorted by Name, + // describing the content of the named directory. + // If ReadDir is nil, Import uses ioutil.ReadDir. + ReadDir func(dir string) ([]fs.FileInfo, error) + + // OpenFile opens a file (not a directory) for reading. + // If OpenFile is nil, Import uses os.Open. + OpenFile func(path string) (io.ReadCloser, error) +} + +// joinPath calls ctxt.JoinPath (if not nil) or else filepath.Join. +func (ctxt *Context) joinPath(elem ...string) string { + if f := ctxt.JoinPath; f != nil { + return f(elem...) + } + return filepath.Join(elem...) +} + +// isDir reports whether path is a directory. +func isDir(path string) bool { + fi, err := fsys.Stat(path) + return err == nil && fi.IsDir() +} + +var defaultToolTags, defaultReleaseTags []string + +// NoGoError is the error used by Import to describe a directory +// containing no buildable Go source files. (It may still contain +// test files, files hidden by build tags, and so on.) +type NoGoError struct { + Dir string +} + +func (e *NoGoError) Error() string { + return "no buildable Go source files in " + e.Dir +} + +// MultiplePackageError describes a directory containing +// multiple buildable Go source files for multiple packages. +type MultiplePackageError struct { + Dir string // directory containing files + Packages []string // package names found + Files []string // corresponding files: Files[i] declares package Packages[i] +} + +func (e *MultiplePackageError) Error() string { + // Error string limited to two entries for compatibility. + return fmt.Sprintf("found packages %s (%s) and %s (%s) in %s", e.Packages[0], e.Files[0], e.Packages[1], e.Files[1], e.Dir) +} + +func nameExt(name string) string { + i := strings.LastIndex(name, ".") + if i < 0 { + return "" + } + return name[i:] +} + +func fileListForExt(p *build.Package, ext string) *[]string { + switch ext { + case ".c": + return &p.CFiles + case ".cc", ".cpp", ".cxx": + return &p.CXXFiles + case ".m": + return &p.MFiles + case ".h", ".hh", ".hpp", ".hxx": + return &p.HFiles + case ".f", ".F", ".for", ".f90": + return &p.FFiles + case ".s", ".S", ".sx": + return &p.SFiles + case ".swig": + return &p.SwigFiles + case ".swigcxx": + return &p.SwigCXXFiles + case ".syso": + return &p.SysoFiles + } + return nil +} + +var ( + slashSlash = []byte("//") + slashStar = []byte("/*") + starSlash = []byte("*/") +) + +var dummyPkg build.Package + +// fileInfo records information learned about a file included in a build. +type fileInfo struct { + name string // full name including dir + header []byte + fset *token.FileSet + parsed *ast.File + parseErr error + imports []fileImport + embeds []fileEmbed + directives []build.Directive + + // Additional fields added to go/build's fileinfo for the purposes of the modindex package. + binaryOnly bool + goBuildConstraint string + plusBuildConstraints []string +} + +type fileImport struct { + path string + pos token.Pos + doc *ast.CommentGroup +} + +type fileEmbed struct { + pattern string + pos token.Position +} + +var errNonSource = errors.New("non source file") + +// getFileInfo extracts the information needed from each go file for the module +// index. +// +// If Name denotes a Go program, matchFile reads until the end of the +// Imports and returns that section of the file in the FileInfo's Header field, +// even though it only considers text until the first non-comment +// for +build lines. +// +// getFileInfo will return errNonSource if the file is not a source or object +// file and shouldn't even be added to IgnoredFiles. +func getFileInfo(dir, name string, fset *token.FileSet) (*fileInfo, error) { + if strings.HasPrefix(name, "_") || + strings.HasPrefix(name, ".") { + return nil, nil + } + + i := strings.LastIndex(name, ".") + if i < 0 { + i = len(name) + } + ext := name[i:] + + if ext != ".go" && fileListForExt(&dummyPkg, ext) == nil { + // skip + return nil, errNonSource + } + + info := &fileInfo{name: filepath.Join(dir, name), fset: fset} + if ext == ".syso" { + // binary, no reading + return info, nil + } + + f, err := fsys.Open(info.name) + if err != nil { + return nil, err + } + + // TODO(matloob) should we decide whether to ignore binary only here or earlier + // when we create the index file? + var ignoreBinaryOnly bool + if strings.HasSuffix(name, ".go") { + err = readGoInfo(f, info) + if strings.HasSuffix(name, "_test.go") { + ignoreBinaryOnly = true // ignore //go:binary-only-package comments in _test.go files + } + } else { + info.header, err = readComments(f) + } + f.Close() + if err != nil { + return nil, fmt.Errorf("read %s: %v", info.name, err) + } + + // Look for +build comments to accept or reject the file. + info.goBuildConstraint, info.plusBuildConstraints, info.binaryOnly, err = getConstraints(info.header) + if err != nil { + return nil, fmt.Errorf("%s: %v", name, err) + } + + if ignoreBinaryOnly && info.binaryOnly { + info.binaryOnly = false // override info.binaryOnly + } + + return info, nil +} + +func cleanDecls(m map[string][]token.Position) ([]string, map[string][]token.Position) { + all := make([]string, 0, len(m)) + for path := range m { + all = append(all, path) + } + sort.Strings(all) + return all, m +} + +var ( + bSlashSlash = slashSlash + bStarSlash = starSlash + bSlashStar = slashStar + bPlusBuild = []byte("+build") + + goBuildComment = []byte("//go:build") + + errMultipleGoBuild = errors.New("multiple //go:build comments") +) + +func isGoBuildComment(line []byte) bool { + if !bytes.HasPrefix(line, goBuildComment) { + return false + } + line = bytes.TrimSpace(line) + rest := line[len(goBuildComment):] + return len(rest) == 0 || len(bytes.TrimSpace(rest)) < len(rest) +} + +// Special comment denoting a binary-only package. +// See https://golang.org/design/2775-binary-only-packages +// for more about the design of binary-only packages. +var binaryOnlyComment = []byte("//go:binary-only-package") + +func getConstraints(content []byte) (goBuild string, plusBuild []string, binaryOnly bool, err error) { + // Identify leading run of // comments and blank lines, + // which must be followed by a blank line. + // Also identify any //go:build comments. + content, goBuildBytes, sawBinaryOnly, err := parseFileHeader(content) + if err != nil { + return "", nil, false, err + } + + // If //go:build line is present, it controls, so no need to look for +build . + // Otherwise, get plusBuild constraints. + if goBuildBytes == nil { + p := content + for len(p) > 0 { + line := p + if i := bytes.IndexByte(line, '\n'); i >= 0 { + line, p = line[:i], p[i+1:] + } else { + p = p[len(p):] + } + line = bytes.TrimSpace(line) + if !bytes.HasPrefix(line, bSlashSlash) || !bytes.Contains(line, bPlusBuild) { + continue + } + text := string(line) + if !constraint.IsPlusBuild(text) { + continue + } + plusBuild = append(plusBuild, text) + } + } + + return string(goBuildBytes), plusBuild, sawBinaryOnly, nil +} + +func parseFileHeader(content []byte) (trimmed, goBuild []byte, sawBinaryOnly bool, err error) { + end := 0 + p := content + ended := false // found non-blank, non-// line, so stopped accepting // +build lines + inSlashStar := false // in /* */ comment + +Lines: + for len(p) > 0 { + line := p + if i := bytes.IndexByte(line, '\n'); i >= 0 { + line, p = line[:i], p[i+1:] + } else { + p = p[len(p):] + } + line = bytes.TrimSpace(line) + if len(line) == 0 && !ended { // Blank line + // Remember position of most recent blank line. + // When we find the first non-blank, non-// line, + // this "end" position marks the latest file position + // where a // +build line can appear. + // (It must appear _before_ a blank line before the non-blank, non-// line. + // Yes, that's confusing, which is part of why we moved to //go:build lines.) + // Note that ended==false here means that inSlashStar==false, + // since seeing a /* would have set ended==true. + end = len(content) - len(p) + continue Lines + } + if !bytes.HasPrefix(line, slashSlash) { // Not comment line + ended = true + } + + if !inSlashStar && isGoBuildComment(line) { + if goBuild != nil { + return nil, nil, false, errMultipleGoBuild + } + goBuild = line + } + if !inSlashStar && bytes.Equal(line, binaryOnlyComment) { + sawBinaryOnly = true + } + + Comments: + for len(line) > 0 { + if inSlashStar { + if i := bytes.Index(line, starSlash); i >= 0 { + inSlashStar = false + line = bytes.TrimSpace(line[i+len(starSlash):]) + continue Comments + } + continue Lines + } + if bytes.HasPrefix(line, bSlashSlash) { + continue Lines + } + if bytes.HasPrefix(line, bSlashStar) { + inSlashStar = true + line = bytes.TrimSpace(line[len(bSlashStar):]) + continue Comments + } + // Found non-comment text. + break Lines + } + } + + return content[:end], goBuild, sawBinaryOnly, nil +} + +// saveCgo saves the information from the #cgo lines in the import "C" comment. +// These lines set CFLAGS, CPPFLAGS, CXXFLAGS and LDFLAGS and pkg-config directives +// that affect the way cgo's C code is built. +func (ctxt *Context) saveCgo(filename string, di *build.Package, text string) error { + for line := range strings.SplitSeq(text, "\n") { + orig := line + + // Line is + // #cgo [GOOS/GOARCH...] LDFLAGS: stuff + // + line = strings.TrimSpace(line) + if len(line) < 5 || line[:4] != "#cgo" || (line[4] != ' ' && line[4] != '\t') { + continue + } + + // #cgo (nocallback|noescape) + if fields := strings.Fields(line); len(fields) == 3 && (fields[1] == "nocallback" || fields[1] == "noescape") { + continue + } + + // Split at colon. + line, argstr, ok := strings.Cut(strings.TrimSpace(line[4:]), ":") + if !ok { + return fmt.Errorf("%s: invalid #cgo line: %s", filename, orig) + } + + // Parse GOOS/GOARCH stuff. + f := strings.Fields(line) + if len(f) < 1 { + return fmt.Errorf("%s: invalid #cgo line: %s", filename, orig) + } + + cond, verb := f[:len(f)-1], f[len(f)-1] + if len(cond) > 0 { + ok := false + for _, c := range cond { + if ctxt.matchAuto(c, nil) { + ok = true + break + } + } + if !ok { + continue + } + } + + args, err := splitQuoted(argstr) + if err != nil { + return fmt.Errorf("%s: invalid #cgo line: %s", filename, orig) + } + for i, arg := range args { + if arg, ok = expandSrcDir(arg, di.Dir); !ok { + return fmt.Errorf("%s: malformed #cgo argument: %s", filename, arg) + } + args[i] = arg + } + + switch verb { + case "CFLAGS", "CPPFLAGS", "CXXFLAGS", "FFLAGS", "LDFLAGS": + // Change relative paths to absolute. + ctxt.makePathsAbsolute(args, di.Dir) + } + + switch verb { + case "CFLAGS": + di.CgoCFLAGS = append(di.CgoCFLAGS, args...) + case "CPPFLAGS": + di.CgoCPPFLAGS = append(di.CgoCPPFLAGS, args...) + case "CXXFLAGS": + di.CgoCXXFLAGS = append(di.CgoCXXFLAGS, args...) + case "FFLAGS": + di.CgoFFLAGS = append(di.CgoFFLAGS, args...) + case "LDFLAGS": + di.CgoLDFLAGS = append(di.CgoLDFLAGS, args...) + case "pkg-config": + di.CgoPkgConfig = append(di.CgoPkgConfig, args...) + default: + return fmt.Errorf("%s: invalid #cgo verb: %s", filename, orig) + } + } + return nil +} + +// expandSrcDir expands any occurrence of ${SRCDIR}, making sure +// the result is safe for the shell. +func expandSrcDir(str string, srcdir string) (string, bool) { + // "\" delimited paths cause safeCgoName to fail + // so convert native paths with a different delimiter + // to "/" before starting (eg: on windows). + srcdir = filepath.ToSlash(srcdir) + + chunks := strings.Split(str, "${SRCDIR}") + if len(chunks) < 2 { + return str, safeCgoName(str) + } + ok := true + for _, chunk := range chunks { + ok = ok && (chunk == "" || safeCgoName(chunk)) + } + ok = ok && (srcdir == "" || safeCgoName(srcdir)) + res := strings.Join(chunks, srcdir) + return res, ok && res != "" +} + +// makePathsAbsolute looks for compiler options that take paths and +// makes them absolute. We do this because through the 1.8 release we +// ran the compiler in the package directory, so any relative -I or -L +// options would be relative to that directory. In 1.9 we changed to +// running the compiler in the build directory, to get consistent +// build results (issue #19964). To keep builds working, we change any +// relative -I or -L options to be absolute. +// +// Using filepath.IsAbs and filepath.Join here means the results will be +// different on different systems, but that's OK: -I and -L options are +// inherently system-dependent. +func (ctxt *Context) makePathsAbsolute(args []string, srcDir string) { + nextPath := false + for i, arg := range args { + if nextPath { + if !filepath.IsAbs(arg) { + args[i] = filepath.Join(srcDir, arg) + } + nextPath = false + } else if strings.HasPrefix(arg, "-I") || strings.HasPrefix(arg, "-L") { + if len(arg) == 2 { + nextPath = true + } else { + if !filepath.IsAbs(arg[2:]) { + args[i] = arg[:2] + filepath.Join(srcDir, arg[2:]) + } + } + } + } +} + +// NOTE: $ is not safe for the shell, but it is allowed here because of linker options like -Wl,$ORIGIN. +// We never pass these arguments to a shell (just to programs we construct argv for), so this should be okay. +// See golang.org/issue/6038. +// The @ is for OS X. See golang.org/issue/13720. +// The % is for Jenkins. See golang.org/issue/16959. +// The ! is because module paths may use them. See golang.org/issue/26716. +// The ~ and ^ are for sr.ht. See golang.org/issue/32260. +const safeString = "+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:$@%! ~^" + +func safeCgoName(s string) bool { + if s == "" { + return false + } + for i := 0; i < len(s); i++ { + if c := s[i]; c < utf8.RuneSelf && strings.IndexByte(safeString, c) < 0 { + return false + } + } + return true +} + +// splitQuoted splits the string s around each instance of one or more consecutive +// white space characters while taking into account quotes and escaping, and +// returns an array of substrings of s or an empty list if s contains only white space. +// Single quotes and double quotes are recognized to prevent splitting within the +// quoted region, and are removed from the resulting substrings. If a quote in s +// isn't closed err will be set and r will have the unclosed argument as the +// last element. The backslash is used for escaping. +// +// For example, the following string: +// +// a b:"c d" 'e''f' "g\"" +// +// Would be parsed as: +// +// []string{"a", "b:c d", "ef", `g"`} +func splitQuoted(s string) (r []string, err error) { + var args []string + arg := make([]rune, len(s)) + escaped := false + quoted := false + quote := '\x00' + i := 0 + for _, rune := range s { + switch { + case escaped: + escaped = false + case rune == '\\': + escaped = true + continue + case quote != '\x00': + if rune == quote { + quote = '\x00' + continue + } + case rune == '"' || rune == '\'': + quoted = true + quote = rune + continue + case unicode.IsSpace(rune): + if quoted || i > 0 { + quoted = false + args = append(args, string(arg[:i])) + i = 0 + } + continue + } + arg[i] = rune + i++ + } + if quoted || i > 0 { + args = append(args, string(arg[:i])) + } + if quote != 0 { + err = errors.New("unclosed quote") + } else if escaped { + err = errors.New("unfinished escaping") + } + return args, err +} + +// matchAuto interprets text as either a +build or //go:build expression (whichever works), +// reporting whether the expression matches the build context. +// +// matchAuto is only used for testing of tag evaluation +// and in #cgo lines, which accept either syntax. +func (ctxt *Context) matchAuto(text string, allTags map[string]bool) bool { + if strings.ContainsAny(text, "&|()") { + text = "//go:build " + text + } else { + text = "// +build " + text + } + x, err := constraint.Parse(text) + if err != nil { + return false + } + return ctxt.eval(x, allTags) +} + +func (ctxt *Context) eval(x constraint.Expr, allTags map[string]bool) bool { + return x.Eval(func(tag string) bool { return ctxt.matchTag(tag, allTags) }) +} + +// matchTag reports whether the name is one of: +// +// cgo (if cgo is enabled) +// $GOOS +// $GOARCH +// boringcrypto +// ctxt.Compiler +// linux (if GOOS == android) +// solaris (if GOOS == illumos) +// tag (if tag is listed in ctxt.BuildTags or ctxt.ReleaseTags) +// +// It records all consulted tags in allTags. +func (ctxt *Context) matchTag(name string, allTags map[string]bool) bool { + if allTags != nil { + allTags[name] = true + } + + // special tags + if ctxt.CgoEnabled && name == "cgo" { + return true + } + if name == ctxt.GOOS || name == ctxt.GOARCH || name == ctxt.Compiler { + return true + } + if ctxt.GOOS == "android" && name == "linux" { + return true + } + if ctxt.GOOS == "illumos" && name == "solaris" { + return true + } + if ctxt.GOOS == "ios" && name == "darwin" { + return true + } + if name == "unix" && syslist.UnixOS[ctxt.GOOS] { + return true + } + if name == "boringcrypto" { + name = "goexperiment.boringcrypto" // boringcrypto is an old name for goexperiment.boringcrypto + } + + // other tags + return slices.Contains(ctxt.BuildTags, name) || slices.Contains(ctxt.ToolTags, name) || + slices.Contains(ctxt.ReleaseTags, name) +} + +// goodOSArchFile returns false if the name contains a $GOOS or $GOARCH +// suffix which does not match the current system. +// The recognized name formats are: +// +// name_$(GOOS).* +// name_$(GOARCH).* +// name_$(GOOS)_$(GOARCH).* +// name_$(GOOS)_test.* +// name_$(GOARCH)_test.* +// name_$(GOOS)_$(GOARCH)_test.* +// +// Exceptions: +// if GOOS=android, then files with GOOS=linux are also matched. +// if GOOS=illumos, then files with GOOS=solaris are also matched. +// if GOOS=ios, then files with GOOS=darwin are also matched. +func (ctxt *Context) goodOSArchFile(name string, allTags map[string]bool) bool { + name, _, _ = strings.Cut(name, ".") + + // Before Go 1.4, a file called "linux.go" would be equivalent to having a + // build tag "linux" in that file. For Go 1.4 and beyond, we require this + // auto-tagging to apply only to files with a non-empty prefix, so + // "foo_linux.go" is tagged but "linux.go" is not. This allows new operating + // systems, such as android, to arrive without breaking existing code with + // innocuous source code in "android.go". The easiest fix: cut everything + // in the name before the initial _. + i := strings.Index(name, "_") + if i < 0 { + return true + } + name = name[i:] // ignore everything before first _ + + l := strings.Split(name, "_") + if n := len(l); n > 0 && l[n-1] == "test" { + l = l[:n-1] + } + n := len(l) + if n >= 2 && syslist.KnownOS[l[n-2]] && syslist.KnownArch[l[n-1]] { + if allTags != nil { + // In case we short-circuit on l[n-1]. + allTags[l[n-2]] = true + } + return ctxt.matchTag(l[n-1], allTags) && ctxt.matchTag(l[n-2], allTags) + } + if n >= 1 && (syslist.KnownOS[l[n-1]] || syslist.KnownArch[l[n-1]]) { + return ctxt.matchTag(l[n-1], allTags) + } + return true +} diff --git a/go/src/cmd/go/internal/modindex/build_read.go b/go/src/cmd/go/internal/modindex/build_read.go new file mode 100644 index 0000000000000000000000000000000000000000..f2e48f36cdff549f35766c3dc17805fce7583633 --- /dev/null +++ b/go/src/cmd/go/internal/modindex/build_read.go @@ -0,0 +1,423 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file is a lightly modified copy go/build/read.go with unused parts +// removed. + +package modindex + +import ( + "bufio" + "bytes" + "errors" + "fmt" + "go/ast" + "go/build" + "go/parser" + "go/scanner" + "go/token" + "io" + "strconv" + "strings" + "unicode" + "unicode/utf8" +) + +type importReader struct { + b *bufio.Reader + buf []byte + peek byte + err error + eof bool + nerr int + pos token.Position +} + +var bom = []byte{0xef, 0xbb, 0xbf} + +func newImportReader(name string, r io.Reader) *importReader { + b := bufio.NewReader(r) + // Remove leading UTF-8 BOM. + // Per https://golang.org/ref/spec#Source_code_representation: + // a compiler may ignore a UTF-8-encoded byte order mark (U+FEFF) + // if it is the first Unicode code point in the source text. + if leadingBytes, err := b.Peek(3); err == nil && bytes.Equal(leadingBytes, bom) { + b.Discard(3) + } + return &importReader{ + b: b, + pos: token.Position{ + Filename: name, + Line: 1, + Column: 1, + }, + } +} + +func isIdent(c byte) bool { + return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9' || c == '_' || c >= utf8.RuneSelf +} + +var ( + errSyntax = errors.New("syntax error") + errNUL = errors.New("unexpected NUL in input") +) + +// syntaxError records a syntax error, but only if an I/O error has not already been recorded. +func (r *importReader) syntaxError() { + if r.err == nil { + r.err = errSyntax + } +} + +// readByte reads the next byte from the input, saves it in buf, and returns it. +// If an error occurs, readByte records the error in r.err and returns 0. +func (r *importReader) readByte() byte { + c, err := r.b.ReadByte() + if err == nil { + r.buf = append(r.buf, c) + if c == 0 { + err = errNUL + } + } + if err != nil { + if err == io.EOF { + r.eof = true + } else if r.err == nil { + r.err = err + } + c = 0 + } + return c +} + +// readRest reads the entire rest of the file into r.buf. +func (r *importReader) readRest() { + for { + if len(r.buf) == cap(r.buf) { + // Grow the buffer + r.buf = append(r.buf, 0)[:len(r.buf)] + } + n, err := r.b.Read(r.buf[len(r.buf):cap(r.buf)]) + r.buf = r.buf[:len(r.buf)+n] + if err != nil { + if err == io.EOF { + r.eof = true + } else if r.err == nil { + r.err = err + } + break + } + } +} + +// peekByte returns the next byte from the input reader but does not advance beyond it. +// If skipSpace is set, peekByte skips leading spaces and comments. +func (r *importReader) peekByte(skipSpace bool) byte { + if r.err != nil { + if r.nerr++; r.nerr > 10000 { + panic("go/build: import reader looping") + } + return 0 + } + + // Use r.peek as first input byte. + // Don't just return r.peek here: it might have been left by peekByte(false) + // and this might be peekByte(true). + c := r.peek + if c == 0 { + c = r.readByte() + } + for r.err == nil && !r.eof { + if skipSpace { + // For the purposes of this reader, semicolons are never necessary to + // understand the input and are treated as spaces. + switch c { + case ' ', '\f', '\t', '\r', '\n', ';': + c = r.readByte() + continue + + case '/': + c = r.readByte() + if c == '/' { + for c != '\n' && r.err == nil && !r.eof { + c = r.readByte() + } + } else if c == '*' { + var c1 byte + for (c != '*' || c1 != '/') && r.err == nil { + if r.eof { + r.syntaxError() + } + c, c1 = c1, r.readByte() + } + } else { + r.syntaxError() + } + c = r.readByte() + continue + } + } + break + } + r.peek = c + return r.peek +} + +// nextByte is like peekByte but advances beyond the returned byte. +func (r *importReader) nextByte(skipSpace bool) byte { + c := r.peekByte(skipSpace) + r.peek = 0 + return c +} + +// readKeyword reads the given keyword from the input. +// If the keyword is not present, readKeyword records a syntax error. +func (r *importReader) readKeyword(kw string) { + r.peekByte(true) + for i := 0; i < len(kw); i++ { + if r.nextByte(false) != kw[i] { + r.syntaxError() + return + } + } + if isIdent(r.peekByte(false)) { + r.syntaxError() + } +} + +// readIdent reads an identifier from the input. +// If an identifier is not present, readIdent records a syntax error. +func (r *importReader) readIdent() { + c := r.peekByte(true) + if !isIdent(c) { + r.syntaxError() + return + } + for isIdent(r.peekByte(false)) { + r.peek = 0 + } +} + +// readString reads a quoted string literal from the input. +// If an identifier is not present, readString records a syntax error. +func (r *importReader) readString() { + switch r.nextByte(true) { + case '`': + for r.err == nil { + if r.nextByte(false) == '`' { + break + } + if r.eof { + r.syntaxError() + } + } + case '"': + for r.err == nil { + c := r.nextByte(false) + if c == '"' { + break + } + if r.eof || c == '\n' { + r.syntaxError() + } + if c == '\\' { + r.nextByte(false) + } + } + default: + r.syntaxError() + } +} + +// readImport reads an import clause - optional identifier followed by quoted string - +// from the input. +func (r *importReader) readImport() { + c := r.peekByte(true) + if c == '.' { + r.peek = 0 + } else if isIdent(c) { + r.readIdent() + } + r.readString() +} + +// readComments is like io.ReadAll, except that it only reads the leading +// block of comments in the file. +func readComments(f io.Reader) ([]byte, error) { + r := newImportReader("", f) + r.peekByte(true) + if r.err == nil && !r.eof { + // Didn't reach EOF, so must have found a non-space byte. Remove it. + r.buf = r.buf[:len(r.buf)-1] + } + return r.buf, r.err +} + +// readGoInfo expects a Go file as input and reads the file up to and including the import section. +// It records what it learned in *info. +// If info.fset is non-nil, readGoInfo parses the file and sets info.parsed, info.parseErr, +// info.imports and info.embeds. +// +// It only returns an error if there are problems reading the file, +// not for syntax errors in the file itself. +func readGoInfo(f io.Reader, info *fileInfo) error { + r := newImportReader(info.name, f) + + r.readKeyword("package") + r.readIdent() + for r.peekByte(true) == 'i' { + r.readKeyword("import") + if r.peekByte(true) == '(' { + r.nextByte(false) + for r.peekByte(true) != ')' && r.err == nil { + r.readImport() + } + r.nextByte(false) + } else { + r.readImport() + } + } + + info.header = r.buf + + // If we stopped successfully before EOF, we read a byte that told us we were done. + // Return all but that last byte, which would cause a syntax error if we let it through. + if r.err == nil && !r.eof { + info.header = r.buf[:len(r.buf)-1] + } + + // If we stopped for a syntax error, consume the whole file so that + // we are sure we don't change the errors that go/parser returns. + if r.err == errSyntax { + r.err = nil + r.readRest() + info.header = r.buf + } + if r.err != nil { + return r.err + } + + if info.fset == nil { + return nil + } + + // Parse file header & record imports. + info.parsed, info.parseErr = parser.ParseFile(info.fset, info.name, info.header, parser.ImportsOnly|parser.ParseComments) + if info.parseErr != nil { + return nil + } + + hasEmbed := false + for _, decl := range info.parsed.Decls { + d, ok := decl.(*ast.GenDecl) + if !ok { + continue + } + for _, dspec := range d.Specs { + spec, ok := dspec.(*ast.ImportSpec) + if !ok { + continue + } + quoted := spec.Path.Value + path, err := strconv.Unquote(quoted) + if err != nil { + return fmt.Errorf("parser returned invalid quoted string: <%s>", quoted) + } + if !isValidImport(path) { + // The parser used to return a parse error for invalid import paths, but + // no longer does, so check for and create the error here instead. + info.parseErr = scanner.Error{Pos: info.fset.Position(spec.Pos()), Msg: "invalid import path: " + path} + info.imports = nil + return nil + } + if path == "embed" { + hasEmbed = true + } + + doc := spec.Doc + if doc == nil && len(d.Specs) == 1 { + doc = d.Doc + } + info.imports = append(info.imports, fileImport{path, spec.Pos(), doc}) + } + } + + // Extract directives. + for _, group := range info.parsed.Comments { + if group.Pos() >= info.parsed.Package { + break + } + for _, c := range group.List { + if strings.HasPrefix(c.Text, "//go:") { + info.directives = append(info.directives, build.Directive{Text: c.Text, Pos: info.fset.Position(c.Slash)}) + } + } + } + + // If the file imports "embed", + // we have to look for //go:embed comments + // in the remainder of the file. + // The compiler will enforce the mapping of comments to + // declared variables. We just need to know the patterns. + // If there were //go:embed comments earlier in the file + // (near the package statement or imports), the compiler + // will reject them. They can be (and have already been) ignored. + if hasEmbed { + r.readRest() + fset := token.NewFileSet() + file := fset.AddFile(r.pos.Filename, -1, len(r.buf)) + var sc scanner.Scanner + sc.Init(file, r.buf, nil, scanner.ScanComments) + for { + pos, tok, lit := sc.Scan() + if tok == token.EOF { + break + } + if tok == token.COMMENT && strings.HasPrefix(lit, "//go:embed") { + // Ignore badly-formed lines - the compiler will report them when it finds them, + // and we can pretend they are not there to help go list succeed with what it knows. + embs, err := parseGoEmbed(fset, pos, lit) + if err == nil { + info.embeds = append(info.embeds, embs...) + } + } + } + } + + return nil +} + +// isValidImport checks if the import is a valid import using the more strict +// checks allowed by the implementation restriction in https://go.dev/ref/spec#Import_declarations. +// It was ported from the function of the same name that was removed from the +// parser in CL 424855, when the parser stopped doing these checks. +func isValidImport(s string) bool { + const illegalChars = `!"#$%&'()*,:;<=>?[\]^{|}` + "`\uFFFD" + for _, r := range s { + if !unicode.IsGraphic(r) || unicode.IsSpace(r) || strings.ContainsRune(illegalChars, r) { + return false + } + } + return s != "" +} + +// parseGoEmbed parses a "//go:embed" to extract the glob patterns. +// It accepts unquoted space-separated patterns as well as double-quoted and back-quoted Go strings. +// This must match the behavior of cmd/compile/internal/noder.go. +func parseGoEmbed(fset *token.FileSet, pos token.Pos, comment string) ([]fileEmbed, error) { + dir, ok := ast.ParseDirective(pos, comment) + if !ok || dir.Tool != "go" || dir.Name != "embed" { + return nil, nil + } + args, err := dir.ParseArgs() + if err != nil { + return nil, err + } + var list []fileEmbed + for _, arg := range args { + list = append(list, fileEmbed{arg.Arg, fset.Position(arg.Pos)}) + } + return list, nil +} diff --git a/go/src/cmd/go/internal/modindex/index_format.txt b/go/src/cmd/go/internal/modindex/index_format.txt new file mode 100644 index 0000000000000000000000000000000000000000..8b1d2c6bc5b871d4828fca2aac31bda460ae8f26 --- /dev/null +++ b/go/src/cmd/go/internal/modindex/index_format.txt @@ -0,0 +1,63 @@ +This file documents the index format that is read and written by this package. +The index format is an encoding of a series of RawPackage structs + +Field names refer to fields on RawPackage and rawFile. +The file uses little endian encoding for the uint32s. +Strings are written into the string table at the end of the file. +Each string is prefixed with a uvarint-encoded length. +Bools are written as uint32s: 0 for false and 1 for true. + +The following is the format for a full module: + +“go index v2\n” +str uint32 - offset of string table +n uint32 - number of packages +for each rawPackage: + dirname - string offset + package - offset where package begins +for each rawPackage: + error uint32 - string offset // error is produced by fsys.ReadDir or fmt.Errorf + dir uint32 - string offset (directory path relative to module root) + len(sourceFiles) uint32 + sourceFiles [n]uint32 - offset to source file (relative to start of index file) + for each sourceFile: + error - string offset // error is either produced by fmt.Errorf,errors.New or is io.EOF + parseError - string offset // if non-empty, a json-encoded parseError struct (see below). Is either produced by io.ReadAll,os.ReadFile,errors.New or is scanner.Error,scanner.ErrorList + synopsis - string offset + name - string offset + pkgName - string offset + ignoreFile - int32 bool // report the file in Ignored(Go|Other)Files because there was an error reading it or parsing its build constraints. + binaryOnly uint32 bool + cgoDirectives string offset // the #cgo directive lines in the comment on import "C" + goBuildConstraint - string offset + len(plusBuildConstraints) - uint32 + plusBuildConstraints - [n]uint32 (string offsets) + len(imports) uint32 + for each rawImport: + path - string offset + position - file, offset, line, column - uint32 + len(embeds) uint32 + for each embed: + pattern - string offset + position - file, offset, line, column - uint32 + len(directives) uint32 + for each directive: + text - string offset + position - file, offset, line, column - uint32 +[string table] +0xFF (marker) + +The following is the format for a single indexed package: + +“go index v0\n” +str uint32 - offset of string table +for the single RawPackage: + [same RawPackage format as above] +[string table] + +The following is the definition of the json-serialized parseError struct: + +type parseError struct { + ErrorList *scanner.ErrorList // non-nil if the error was an ErrorList, nil otherwise + ErrorString string // non-empty for all other cases +} diff --git a/go/src/cmd/go/internal/modindex/index_test.go b/go/src/cmd/go/internal/modindex/index_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6bc62f393fad5fd0b20d6577b98d20cb61caace0 --- /dev/null +++ b/go/src/cmd/go/internal/modindex/index_test.go @@ -0,0 +1,104 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modindex + +import ( + "encoding/hex" + "encoding/json" + "go/build" + "internal/diff" + "path/filepath" + "reflect" + "runtime" + "testing" +) + +func init() { + isTest = true + enabled = true // to allow GODEBUG=goindex=0 go test, when things are very broken +} + +func TestIndex(t *testing.T) { + src := filepath.Join(runtime.GOROOT(), "src") + checkPkg := func(t *testing.T, m *Module, pkg string, data []byte) { + p := m.Package(pkg) + bp, err := p.Import(build.Default, build.ImportComment) + if err != nil { + t.Fatal(err) + } + bp1, err := build.Default.Import(".", filepath.Join(src, pkg), build.ImportComment) + if err != nil { + t.Fatal(err) + } + + if !reflect.DeepEqual(bp, bp1) { + t.Errorf("mismatch") + t.Logf("index:\n%s", hex.Dump(data)) + + js, err := json.MarshalIndent(bp, "", "\t") + if err != nil { + t.Fatal(err) + } + js1, err := json.MarshalIndent(bp1, "", "\t") + if err != nil { + t.Fatal(err) + } + t.Logf("diff:\n%s", diff.Diff("index", js, "correct", js1)) + t.FailNow() + } + } + + // Check packages in increasing complexity, one at a time. + pkgs := []string{ + "crypto", + "encoding", + "unsafe", + "encoding/json", + "runtime", + "net", + } + var raws []*rawPackage + for _, pkg := range pkgs { + raw := importRaw(src, pkg) + raws = append(raws, raw) + t.Run(pkg, func(t *testing.T) { + data := encodeModuleBytes([]*rawPackage{raw}) + m, err := fromBytes(src, data) + if err != nil { + t.Fatal(err) + } + checkPkg(t, m, pkg, data) + }) + } + + // Check that a multi-package index works too. + t.Run("all", func(t *testing.T) { + data := encodeModuleBytes(raws) + m, err := fromBytes(src, data) + if err != nil { + t.Fatal(err) + } + for _, pkg := range pkgs { + checkPkg(t, m, pkg, data) + } + }) +} + +func TestImportRaw_IgnoreNonGo(t *testing.T) { + path := filepath.Join("testdata", "ignore_non_source") + p := importRaw(path, ".") + + wantFiles := []string{"a.syso", "b.go", "c.c"} + + var gotFiles []string + for i := range p.sourceFiles { + gotFiles = append(gotFiles, p.sourceFiles[i].name) + } + + if !reflect.DeepEqual(gotFiles, wantFiles) { + t.Errorf("names of files in importRaw(testdata/ignore_non_source): got %v; want %v", + gotFiles, wantFiles) + } +} diff --git a/go/src/cmd/go/internal/modindex/read.go b/go/src/cmd/go/internal/modindex/read.go new file mode 100644 index 0000000000000000000000000000000000000000..399e89eca3cf47d859469cadd0b8a4ced07ee3d5 --- /dev/null +++ b/go/src/cmd/go/internal/modindex/read.go @@ -0,0 +1,1050 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modindex + +import ( + "bytes" + "encoding/binary" + "errors" + "fmt" + "go/build" + "go/build/constraint" + "go/token" + "internal/godebug" + "internal/goroot" + "path" + "path/filepath" + "runtime" + "runtime/debug" + "sort" + "strings" + "sync" + "time" + "unsafe" + + "cmd/go/internal/base" + "cmd/go/internal/cache" + "cmd/go/internal/cfg" + "cmd/go/internal/fsys" + "cmd/go/internal/imports" + "cmd/go/internal/str" + "cmd/internal/par" +) + +// enabled is used to flag off the behavior of the module index on tip, for debugging. +var enabled = godebug.New("#goindex").Value() != "0" + +// Module represents and encoded module index file. It is used to +// do the equivalent of build.Import of packages in the module and answer other +// questions based on the index file's data. +type Module struct { + modroot string + d *decoder + n int // number of packages +} + +// moduleHash returns an ActionID corresponding to the state of the module +// located at filesystem path modroot. +func moduleHash(modroot string, ismodcache bool) (cache.ActionID, error) { + // We expect modules stored within the module cache to be checksummed and + // immutable, and we expect released modules within GOROOT to change only + // infrequently (when the Go version changes). + if !ismodcache { + // The contents of this module may change over time. We don't want to pay + // the cost to detect changes and re-index whenever they occur, so just + // don't index it at all. + // + // Note that this is true even for modules in GOROOT/src: non-release builds + // of the Go toolchain may have arbitrary development changes on top of the + // commit reported by runtime.Version, or could be completely artificial due + // to lacking a `git` binary (like "devel gomote.XXXXX", as synthesized by + // "gomote push" as of 2022-06-15). (Release builds shouldn't have + // modifications, but we don't want to use a behavior for releases that we + // haven't tested during development.) + return cache.ActionID{}, ErrNotIndexed + } + + h := cache.NewHash("moduleIndex") + // TODO(bcmills): Since modules in the index are checksummed, we could + // probably improve the cache hit rate by keying off of the module + // path@version (perhaps including the checksum?) instead of the module root + // directory. + fmt.Fprintf(h, "module index %s %s %v\n", runtime.Version(), indexVersion, modroot) + return h.Sum(), nil +} + +const modTimeCutoff = 2 * time.Second + +// dirHash returns an ActionID corresponding to the state of the package +// located at filesystem path pkgdir. +func dirHash(modroot, pkgdir string) (cache.ActionID, error) { + h := cache.NewHash("moduleIndex") + fmt.Fprintf(h, "modroot %s\n", modroot) + fmt.Fprintf(h, "package %s %s %v\n", runtime.Version(), indexVersion, pkgdir) + dirs, err := fsys.ReadDir(pkgdir) + if err != nil { + // pkgdir might not be a directory. give up on hashing. + return cache.ActionID{}, ErrNotIndexed + } + cutoff := time.Now().Add(-modTimeCutoff) + for _, d := range dirs { + if d.IsDir() { + continue + } + + if !d.Type().IsRegular() { + return cache.ActionID{}, ErrNotIndexed + } + // To avoid problems for very recent files where a new + // write might not change the mtime due to file system + // mtime precision, reject caching if a file was read that + // is less than modTimeCutoff old. + // + // This is the same strategy used for hashing test inputs. + // See hashOpen in cmd/go/internal/test/test.go for the + // corresponding code. + info, err := d.Info() + if err != nil { + return cache.ActionID{}, ErrNotIndexed + } + if info.ModTime().After(cutoff) { + return cache.ActionID{}, ErrNotIndexed + } + + fmt.Fprintf(h, "file %v %v %v\n", info.Name(), info.ModTime(), info.Size()) + } + return h.Sum(), nil +} + +var ErrNotIndexed = errors.New("not in module index") + +var ( + errDisabled = fmt.Errorf("%w: module indexing disabled", ErrNotIndexed) + errNotFromModuleCache = fmt.Errorf("%w: not from module cache", ErrNotIndexed) + errFIPS140 = fmt.Errorf("%w: fips140 snapshots not indexed", ErrNotIndexed) +) + +// GetPackage returns the IndexPackage for the directory at the given path. +// It will return ErrNotIndexed if the directory should be read without +// using the index, for instance because the index is disabled, or the package +// is not in a module. +func GetPackage(modroot, pkgdir string) (*IndexPackage, error) { + mi, err := GetModule(modroot) + if err == nil { + return mi.Package(relPath(pkgdir, modroot)), nil + } + if !errors.Is(err, errNotFromModuleCache) { + return nil, err + } + if cfg.BuildContext.Compiler == "gccgo" && str.HasPathPrefix(modroot, cfg.GOROOTsrc) { + return nil, err // gccgo has no sources for GOROOT packages. + } + // The pkgdir for fips140 has been replaced in the fsys overlay, + // but the module index does not see that. Do not try to use the module index. + if strings.Contains(filepath.ToSlash(pkgdir), "internal/fips140/v") { + return nil, errFIPS140 + } + modroot = filepath.Clean(modroot) + pkgdir = filepath.Clean(pkgdir) + return openIndexPackage(modroot, pkgdir) +} + +// GetModule returns the Module for the given modroot. +// It will return ErrNotIndexed if the directory should be read without +// using the index, for instance because the index is disabled, or the package +// is not in a module. +func GetModule(modroot string) (*Module, error) { + dir, _, _ := cache.DefaultDir() + if !enabled || dir == "off" { + return nil, errDisabled + } + if modroot == "" { + panic("modindex.GetPackage called with empty modroot") + } + if cfg.BuildMod == "vendor" { + // Even if the main module is in the module cache, + // its vendored dependencies are not loaded from their + // usual cached locations. + return nil, errNotFromModuleCache + } + modroot = filepath.Clean(modroot) + if str.HasFilePathPrefix(modroot, cfg.GOROOTsrc) || !str.HasFilePathPrefix(modroot, cfg.GOMODCACHE) { + return nil, errNotFromModuleCache + } + return openIndexModule(modroot, true) +} + +var mcache par.ErrCache[string, *Module] + +// openIndexModule returns the module index for modPath. +// It will return ErrNotIndexed if the module can not be read +// using the index because it contains symlinks. +func openIndexModule(modroot string, ismodcache bool) (*Module, error) { + return mcache.Do(modroot, func() (*Module, error) { + fsys.Trace("openIndexModule", modroot) + id, err := moduleHash(modroot, ismodcache) + if err != nil { + return nil, err + } + data, _, opened, err := cache.GetMmap(cache.Default(), id) + if err != nil { + // Couldn't read from modindex. Assume we couldn't read from + // the index because the module hasn't been indexed yet. + // But double check on Windows that we haven't opened the file yet, + // because once mmap opens the file, we can't close it, and + // Windows won't let us open an already opened file. + data, err = indexModule(modroot) + if err != nil { + return nil, err + } + if runtime.GOOS != "windows" || !opened { + if err = cache.PutBytes(cache.Default(), id, data); err != nil { + return nil, err + } + } + } + mi, err := fromBytes(modroot, data) + if err != nil { + return nil, err + } + return mi, nil + }) +} + +var pcache par.ErrCache[[2]string, *IndexPackage] + +func openIndexPackage(modroot, pkgdir string) (*IndexPackage, error) { + return pcache.Do([2]string{modroot, pkgdir}, func() (*IndexPackage, error) { + fsys.Trace("openIndexPackage", pkgdir) + id, err := dirHash(modroot, pkgdir) + if err != nil { + return nil, err + } + data, _, opened, err := cache.GetMmap(cache.Default(), id) + if err != nil { + // Couldn't read from index. Assume we couldn't read from + // the index because the package hasn't been indexed yet. + // But double check on Windows that we haven't opened the file yet, + // because once mmap opens the file, we can't close it, and + // Windows won't let us open an already opened file. + data = indexPackage(modroot, pkgdir) + if runtime.GOOS != "windows" || !opened { + if err = cache.PutBytes(cache.Default(), id, data); err != nil { + return nil, err + } + } + } + pkg, err := packageFromBytes(modroot, data) + if err != nil { + return nil, err + } + return pkg, nil + }) +} + +var errCorrupt = errors.New("corrupt index") + +// protect marks the start of a large section of code that accesses the index. +// It should be used as: +// +// defer unprotect(protect, &err) +// +// It should not be used for trivial accesses which would be +// dwarfed by the overhead of the defer. +func protect() bool { + return debug.SetPanicOnFault(true) +} + +var isTest = false + +// unprotect marks the end of a large section of code that accesses the index. +// It should be used as: +// +// defer unprotect(protect, &err) +// +// end looks for panics due to errCorrupt or bad mmap accesses. +// When it finds them, it adds explanatory text, consumes the panic, and sets *errp instead. +// If errp is nil, end adds the explanatory text but then calls base.Fatalf. +func unprotect(old bool, errp *error) { + // SetPanicOnFault's errors _may_ satisfy this interface. Even though it's not guaranteed + // that all its errors satisfy this interface, we'll only check for these errors so that + // we don't suppress panics that could have been produced from other sources. + type addrer interface { + Addr() uintptr + } + + debug.SetPanicOnFault(old) + + if e := recover(); e != nil { + if _, ok := e.(addrer); ok || e == errCorrupt { + // This panic was almost certainly caused by SetPanicOnFault or our panic(errCorrupt). + err := fmt.Errorf("error reading module index: %v", e) + if errp != nil { + *errp = err + return + } + if isTest { + panic(err) + } + base.Fatalf("%v", err) + } + // The panic was likely not caused by SetPanicOnFault. + panic(e) + } +} + +// fromBytes returns a *Module given the encoded representation. +func fromBytes(moddir string, data []byte) (m *Module, err error) { + if !enabled { + panic("use of index") + } + + defer unprotect(protect(), &err) + + if !bytes.HasPrefix(data, []byte(indexVersion+"\n")) { + return nil, errCorrupt + } + + const hdr = len(indexVersion + "\n") + d := &decoder{data: data} + str := d.intAt(hdr) + if str < hdr+8 || len(d.data) < str { + return nil, errCorrupt + } + d.data, d.str = data[:str], d.data[str:] + // Check that string table looks valid. + // First string is empty string (length 0), + // and we leave a marker byte 0xFF at the end + // just to make sure that the file is not truncated. + if len(d.str) == 0 || d.str[0] != 0 || d.str[len(d.str)-1] != 0xFF { + return nil, errCorrupt + } + + n := d.intAt(hdr + 4) + if n < 0 || n > (len(d.data)-8)/8 { + return nil, errCorrupt + } + + m = &Module{ + moddir, + d, + n, + } + return m, nil +} + +// packageFromBytes returns a *IndexPackage given the encoded representation. +func packageFromBytes(modroot string, data []byte) (p *IndexPackage, err error) { + m, err := fromBytes(modroot, data) + if err != nil { + return nil, err + } + if m.n != 1 { + return nil, fmt.Errorf("corrupt single-package index") + } + return m.pkg(0), nil +} + +// pkgDir returns the dir string of the i'th package in the index. +func (m *Module) pkgDir(i int) string { + if i < 0 || i >= m.n { + panic(errCorrupt) + } + return m.d.stringAt(12 + 8 + 8*i) +} + +// pkgOff returns the offset of the data for the i'th package in the index. +func (m *Module) pkgOff(i int) int { + if i < 0 || i >= m.n { + panic(errCorrupt) + } + return m.d.intAt(12 + 8 + 8*i + 4) +} + +// Walk calls f for each package in the index, passing the path to that package relative to the module root. +func (m *Module) Walk(f func(path string)) { + defer unprotect(protect(), nil) + for i := 0; i < m.n; i++ { + f(m.pkgDir(i)) + } +} + +// relPath returns the path relative to the module's root. +func relPath(path, modroot string) string { + return str.TrimFilePathPrefix(filepath.Clean(path), filepath.Clean(modroot)) +} + +var installgorootAll = godebug.New("installgoroot").Value() == "all" + +// Import is the equivalent of build.Import given the information in Module. +func (rp *IndexPackage) Import(bctxt build.Context, mode build.ImportMode) (p *build.Package, err error) { + defer unprotect(protect(), &err) + + ctxt := (*Context)(&bctxt) + + p = &build.Package{} + + p.ImportPath = "." + p.Dir = filepath.Join(rp.modroot, rp.dir) + + var pkgerr error + switch ctxt.Compiler { + case "gccgo", "gc": + default: + // Save error for end of function. + pkgerr = fmt.Errorf("import %q: unknown compiler %q", p.Dir, ctxt.Compiler) + } + + if p.Dir == "" { + return p, fmt.Errorf("import %q: import of unknown directory", p.Dir) + } + + // goroot and gopath + inTestdata := func(sub string) bool { + return strings.Contains(sub, "/testdata/") || strings.HasSuffix(sub, "/testdata") || str.HasPathPrefix(sub, "testdata") + } + var pkga string + if !inTestdata(rp.dir) { + // In build.go, p.Root should only be set in the non-local-import case, or in + // GOROOT or GOPATH. Since module mode only calls Import with path set to "." + // and the module index doesn't apply outside modules, the GOROOT case is + // the only case where p.Root needs to be set. + if ctxt.GOROOT != "" && str.HasFilePathPrefix(p.Dir, cfg.GOROOTsrc) && p.Dir != cfg.GOROOTsrc { + p.Root = ctxt.GOROOT + p.Goroot = true + modprefix := str.TrimFilePathPrefix(rp.modroot, cfg.GOROOTsrc) + p.ImportPath = rp.dir + if modprefix != "" { + p.ImportPath = filepath.Join(modprefix, p.ImportPath) + } + + // Set GOROOT-specific fields (sometimes for modules in a GOPATH directory). + // The fields set below (SrcRoot, PkgRoot, BinDir, PkgTargetRoot, and PkgObj) + // are only set in build.Import if p.Root != "". + var pkgtargetroot string + suffix := "" + if ctxt.InstallSuffix != "" { + suffix = "_" + ctxt.InstallSuffix + } + switch ctxt.Compiler { + case "gccgo": + pkgtargetroot = "pkg/gccgo_" + ctxt.GOOS + "_" + ctxt.GOARCH + suffix + dir, elem := path.Split(p.ImportPath) + pkga = pkgtargetroot + "/" + dir + "lib" + elem + ".a" + case "gc": + pkgtargetroot = "pkg/" + ctxt.GOOS + "_" + ctxt.GOARCH + suffix + pkga = pkgtargetroot + "/" + p.ImportPath + ".a" + } + p.SrcRoot = ctxt.joinPath(p.Root, "src") + p.PkgRoot = ctxt.joinPath(p.Root, "pkg") + p.BinDir = ctxt.joinPath(p.Root, "bin") + if pkga != "" { + // Always set PkgTargetRoot. It might be used when building in shared + // mode. + p.PkgTargetRoot = ctxt.joinPath(p.Root, pkgtargetroot) + + // Set the install target if applicable. + if !p.Goroot || (installgorootAll && p.ImportPath != "unsafe" && p.ImportPath != "builtin") { + p.PkgObj = ctxt.joinPath(p.Root, pkga) + } + } + } + } + + if rp.error != nil { + if errors.Is(rp.error, errCannotFindPackage) && ctxt.Compiler == "gccgo" && p.Goroot { + return p, nil + } + return p, rp.error + } + + if mode&build.FindOnly != 0 { + return p, pkgerr + } + + // We need to do a second round of bad file processing. + var badGoError error + badGoFiles := make(map[string]bool) + badGoFile := func(name string, err error) { + if badGoError == nil { + badGoError = err + } + if !badGoFiles[name] { + p.InvalidGoFiles = append(p.InvalidGoFiles, name) + badGoFiles[name] = true + } + } + + var Sfiles []string // files with ".S"(capital S)/.sx(capital s equivalent for case insensitive filesystems) + var firstFile string + embedPos := make(map[string][]token.Position) + testEmbedPos := make(map[string][]token.Position) + xTestEmbedPos := make(map[string][]token.Position) + importPos := make(map[string][]token.Position) + testImportPos := make(map[string][]token.Position) + xTestImportPos := make(map[string][]token.Position) + allTags := make(map[string]bool) + for _, tf := range rp.sourceFiles { + name := tf.name() + // Check errors for go files and call badGoFiles to put them in + // InvalidGoFiles if they do have an error. + if strings.HasSuffix(name, ".go") { + if error := tf.error(); error != "" { + badGoFile(name, errors.New(tf.error())) + continue + } else if parseError := tf.parseError(); parseError != "" { + badGoFile(name, parseErrorFromString(tf.parseError())) + // Fall through: we still want to list files with parse errors. + } + } + + var shouldBuild = true + if !ctxt.goodOSArchFile(name, allTags) && !ctxt.UseAllFiles { + shouldBuild = false + } else if goBuildConstraint := tf.goBuildConstraint(); goBuildConstraint != "" { + x, err := constraint.Parse(goBuildConstraint) + if err != nil { + return p, fmt.Errorf("%s: parsing //go:build line: %v", name, err) + } + shouldBuild = ctxt.eval(x, allTags) + } else if plusBuildConstraints := tf.plusBuildConstraints(); len(plusBuildConstraints) > 0 { + for _, text := range plusBuildConstraints { + if x, err := constraint.Parse(text); err == nil { + if !ctxt.eval(x, allTags) { + shouldBuild = false + } + } + } + } + + ext := nameExt(name) + if !shouldBuild || tf.ignoreFile() { + if ext == ".go" { + p.IgnoredGoFiles = append(p.IgnoredGoFiles, name) + } else if fileListForExt(p, ext) != nil { + p.IgnoredOtherFiles = append(p.IgnoredOtherFiles, name) + } + continue + } + + // Going to save the file. For non-Go files, can stop here. + switch ext { + case ".go": + // keep going + case ".S", ".sx": + // special case for cgo, handled at end + Sfiles = append(Sfiles, name) + continue + default: + if list := fileListForExt(p, ext); list != nil { + *list = append(*list, name) + } + continue + } + + pkg := tf.pkgName() + if pkg == "documentation" { + p.IgnoredGoFiles = append(p.IgnoredGoFiles, name) + continue + } + isTest := strings.HasSuffix(name, "_test.go") + isXTest := false + if isTest && strings.HasSuffix(tf.pkgName(), "_test") && p.Name != tf.pkgName() { + isXTest = true + pkg = pkg[:len(pkg)-len("_test")] + } + + if !isTest && tf.binaryOnly() { + p.BinaryOnly = true + } + + if p.Name == "" { + p.Name = pkg + firstFile = name + } else if pkg != p.Name { + // TODO(#45999): The choice of p.Name is arbitrary based on file iteration + // order. Instead of resolving p.Name arbitrarily, we should clear out the + // existing Name and mark the existing files as also invalid. + badGoFile(name, &MultiplePackageError{ + Dir: p.Dir, + Packages: []string{p.Name, pkg}, + Files: []string{firstFile, name}, + }) + } + // Grab the first package comment as docs, provided it is not from a test file. + if p.Doc == "" && !isTest && !isXTest { + if synopsis := tf.synopsis(); synopsis != "" { + p.Doc = synopsis + } + } + + // Record Imports and information about cgo. + isCgo := false + imports := tf.imports() + for _, imp := range imports { + if imp.path == "C" { + if isTest { + badGoFile(name, fmt.Errorf("use of cgo in test %s not supported", name)) + continue + } + isCgo = true + } + } + if directives := tf.cgoDirectives(); directives != "" { + if err := ctxt.saveCgo(name, p, directives); err != nil { + badGoFile(name, err) + } + } + + var fileList *[]string + var importMap, embedMap map[string][]token.Position + var directives *[]build.Directive + switch { + case isCgo: + allTags["cgo"] = true + if ctxt.CgoEnabled { + fileList = &p.CgoFiles + importMap = importPos + embedMap = embedPos + directives = &p.Directives + } else { + // Ignore Imports and Embeds from cgo files if cgo is disabled. + fileList = &p.IgnoredGoFiles + } + case isXTest: + fileList = &p.XTestGoFiles + importMap = xTestImportPos + embedMap = xTestEmbedPos + directives = &p.XTestDirectives + case isTest: + fileList = &p.TestGoFiles + importMap = testImportPos + embedMap = testEmbedPos + directives = &p.TestDirectives + default: + fileList = &p.GoFiles + importMap = importPos + embedMap = embedPos + directives = &p.Directives + } + *fileList = append(*fileList, name) + if importMap != nil { + for _, imp := range imports { + importMap[imp.path] = append(importMap[imp.path], imp.position) + } + } + if embedMap != nil { + for _, e := range tf.embeds() { + embedMap[e.pattern] = append(embedMap[e.pattern], e.position) + } + } + if directives != nil { + *directives = append(*directives, tf.directives()...) + } + } + + p.EmbedPatterns, p.EmbedPatternPos = cleanDecls(embedPos) + p.TestEmbedPatterns, p.TestEmbedPatternPos = cleanDecls(testEmbedPos) + p.XTestEmbedPatterns, p.XTestEmbedPatternPos = cleanDecls(xTestEmbedPos) + + p.Imports, p.ImportPos = cleanDecls(importPos) + p.TestImports, p.TestImportPos = cleanDecls(testImportPos) + p.XTestImports, p.XTestImportPos = cleanDecls(xTestImportPos) + + for tag := range allTags { + p.AllTags = append(p.AllTags, tag) + } + sort.Strings(p.AllTags) + + if len(p.CgoFiles) > 0 { + p.SFiles = append(p.SFiles, Sfiles...) + sort.Strings(p.SFiles) + } else { + p.IgnoredOtherFiles = append(p.IgnoredOtherFiles, Sfiles...) + sort.Strings(p.IgnoredOtherFiles) + } + + if badGoError != nil { + return p, badGoError + } + if len(p.GoFiles)+len(p.CgoFiles)+len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 { + return p, &build.NoGoError{Dir: p.Dir} + } + return p, pkgerr +} + +// IsStandardPackage reports whether path is a standard package +// for the goroot and compiler using the module index if possible, +// and otherwise falling back to internal/goroot.IsStandardPackage +func IsStandardPackage(goroot_, compiler, path string) bool { + if !enabled || compiler != "gc" { + return goroot.IsStandardPackage(goroot_, compiler, path) + } + + reldir := filepath.FromSlash(path) // relative dir path in module index for package + modroot := filepath.Join(goroot_, "src") + if str.HasFilePathPrefix(reldir, "cmd") { + reldir = str.TrimFilePathPrefix(reldir, "cmd") + modroot = filepath.Join(modroot, "cmd") + } + if pkg, err := GetPackage(modroot, filepath.Join(modroot, reldir)); err == nil { + hasGo, err := pkg.IsGoDir() + return err == nil && hasGo + } else if errors.Is(err, ErrNotIndexed) { + // Fall back because package isn't indexable. (Probably because + // a file was modified recently) + return goroot.IsStandardPackage(goroot_, compiler, path) + } + return false +} + +// IsGoDir is the equivalent of fsys.IsGoDir using the information in the index. +func (rp *IndexPackage) IsGoDir() (_ bool, err error) { + defer func() { + if e := recover(); e != nil { + err = fmt.Errorf("error reading module index: %v", e) + } + }() + for _, sf := range rp.sourceFiles { + if strings.HasSuffix(sf.name(), ".go") { + return true, nil + } + } + return false, nil +} + +// ScanDir implements imports.ScanDir using the information in the index. +func (rp *IndexPackage) ScanDir(tags map[string]bool) (sortedImports []string, sortedTestImports []string, err error) { + // TODO(matloob) dir should eventually be relative to indexed directory + // TODO(matloob): skip reading raw package and jump straight to data we need? + + defer func() { + if e := recover(); e != nil { + err = fmt.Errorf("error reading module index: %v", e) + } + }() + + imports_ := make(map[string]bool) + testImports := make(map[string]bool) + numFiles := 0 + +Files: + for _, sf := range rp.sourceFiles { + name := sf.name() + if strings.HasPrefix(name, "_") || strings.HasPrefix(name, ".") || !strings.HasSuffix(name, ".go") || !imports.MatchFile(name, tags) { + continue + } + + // The following section exists for backwards compatibility reasons: + // scanDir ignores files with import "C" when collecting the list + // of imports unless the "cgo" tag is provided. The following comment + // is copied from the original. + // + // import "C" is implicit requirement of cgo tag. + // When listing files on the command line (explicitFiles=true) + // we do not apply build tag filtering but we still do apply + // cgo filtering, so no explicitFiles check here. + // Why? Because we always have, and it's not worth breaking + // that behavior now. + imps := sf.imports() // TODO(matloob): directly read import paths to avoid the extra strings? + for _, imp := range imps { + if imp.path == "C" && !tags["cgo"] && !tags["*"] { + continue Files + } + } + + if !shouldBuild(sf, tags) { + continue + } + numFiles++ + m := imports_ + if strings.HasSuffix(name, "_test.go") { + m = testImports + } + for _, p := range imps { + m[p.path] = true + } + } + if numFiles == 0 { + return nil, nil, imports.ErrNoGo + } + return keys(imports_), keys(testImports), nil +} + +func keys(m map[string]bool) []string { + list := make([]string, 0, len(m)) + for k := range m { + list = append(list, k) + } + sort.Strings(list) + return list +} + +// implements imports.ShouldBuild in terms of an index sourcefile. +func shouldBuild(sf *sourceFile, tags map[string]bool) bool { + if goBuildConstraint := sf.goBuildConstraint(); goBuildConstraint != "" { + x, err := constraint.Parse(goBuildConstraint) + if err != nil { + return false + } + return imports.Eval(x, tags, true) + } + + plusBuildConstraints := sf.plusBuildConstraints() + for _, text := range plusBuildConstraints { + if x, err := constraint.Parse(text); err == nil { + if !imports.Eval(x, tags, true) { + return false + } + } + } + + return true +} + +// IndexPackage holds the information in the index +// needed to load a package in a specific directory. +type IndexPackage struct { + error error + dir string // directory of the package relative to the modroot + + modroot string + + // Source files + sourceFiles []*sourceFile +} + +var errCannotFindPackage = errors.New("cannot find package") + +// Package and returns finds the package with the given path (relative to the module root). +// If the package does not exist, Package returns an IndexPackage that will return an +// appropriate error from its methods. +func (m *Module) Package(path string) *IndexPackage { + defer unprotect(protect(), nil) + + i, ok := sort.Find(m.n, func(i int) int { + return strings.Compare(path, m.pkgDir(i)) + }) + if !ok { + return &IndexPackage{error: fmt.Errorf("%w %q in:\n\t%s", errCannotFindPackage, path, filepath.Join(m.modroot, path))} + } + return m.pkg(i) +} + +// pkg returns the i'th IndexPackage in m. +func (m *Module) pkg(i int) *IndexPackage { + r := m.d.readAt(m.pkgOff(i)) + p := new(IndexPackage) + if errstr := r.string(); errstr != "" { + p.error = errors.New(errstr) + } + p.dir = r.string() + p.sourceFiles = make([]*sourceFile, r.int()) + for i := range p.sourceFiles { + p.sourceFiles[i] = &sourceFile{ + d: m.d, + pos: r.int(), + } + } + p.modroot = m.modroot + return p +} + +// sourceFile represents the information of a given source file in the module index. +type sourceFile struct { + d *decoder // encoding of this source file + pos int // start of sourceFile encoding in d + onceReadImports sync.Once + savedImports []rawImport // saved imports so that they're only read once +} + +// Offsets for fields in the sourceFile. +const ( + sourceFileError = 4 * iota + sourceFileParseError + sourceFileSynopsis + sourceFileName + sourceFilePkgName + sourceFileIgnoreFile + sourceFileBinaryOnly + sourceFileCgoDirectives + sourceFileGoBuildConstraint + sourceFileNumPlusBuildConstraints +) + +func (sf *sourceFile) error() string { + return sf.d.stringAt(sf.pos + sourceFileError) +} +func (sf *sourceFile) parseError() string { + return sf.d.stringAt(sf.pos + sourceFileParseError) +} +func (sf *sourceFile) synopsis() string { + return sf.d.stringAt(sf.pos + sourceFileSynopsis) +} +func (sf *sourceFile) name() string { + return sf.d.stringAt(sf.pos + sourceFileName) +} +func (sf *sourceFile) pkgName() string { + return sf.d.stringAt(sf.pos + sourceFilePkgName) +} +func (sf *sourceFile) ignoreFile() bool { + return sf.d.boolAt(sf.pos + sourceFileIgnoreFile) +} +func (sf *sourceFile) binaryOnly() bool { + return sf.d.boolAt(sf.pos + sourceFileBinaryOnly) +} +func (sf *sourceFile) cgoDirectives() string { + return sf.d.stringAt(sf.pos + sourceFileCgoDirectives) +} +func (sf *sourceFile) goBuildConstraint() string { + return sf.d.stringAt(sf.pos + sourceFileGoBuildConstraint) +} + +func (sf *sourceFile) plusBuildConstraints() []string { + pos := sf.pos + sourceFileNumPlusBuildConstraints + n := sf.d.intAt(pos) + pos += 4 + ret := make([]string, n) + for i := 0; i < n; i++ { + ret[i] = sf.d.stringAt(pos) + pos += 4 + } + return ret +} + +func (sf *sourceFile) importsOffset() int { + pos := sf.pos + sourceFileNumPlusBuildConstraints + n := sf.d.intAt(pos) + // each build constraint is 1 uint32 + return pos + 4 + n*4 +} + +func (sf *sourceFile) embedsOffset() int { + pos := sf.importsOffset() + n := sf.d.intAt(pos) + // each import is 5 uint32s (string + tokpos) + return pos + 4 + n*(4*5) +} + +func (sf *sourceFile) directivesOffset() int { + pos := sf.embedsOffset() + n := sf.d.intAt(pos) + // each embed is 5 uint32s (string + tokpos) + return pos + 4 + n*(4*5) +} + +func (sf *sourceFile) imports() []rawImport { + sf.onceReadImports.Do(func() { + importsOffset := sf.importsOffset() + r := sf.d.readAt(importsOffset) + numImports := r.int() + ret := make([]rawImport, numImports) + for i := 0; i < numImports; i++ { + ret[i] = rawImport{r.string(), r.tokpos()} + } + sf.savedImports = ret + }) + return sf.savedImports +} + +func (sf *sourceFile) embeds() []embed { + embedsOffset := sf.embedsOffset() + r := sf.d.readAt(embedsOffset) + numEmbeds := r.int() + ret := make([]embed, numEmbeds) + for i := range ret { + ret[i] = embed{r.string(), r.tokpos()} + } + return ret +} + +func (sf *sourceFile) directives() []build.Directive { + directivesOffset := sf.directivesOffset() + r := sf.d.readAt(directivesOffset) + numDirectives := r.int() + ret := make([]build.Directive, numDirectives) + for i := range ret { + ret[i] = build.Directive{Text: r.string(), Pos: r.tokpos()} + } + return ret +} + +func asString(b []byte) string { + return unsafe.String(unsafe.SliceData(b), len(b)) +} + +// A decoder helps decode the index format. +type decoder struct { + data []byte // data after header + str []byte // string table +} + +// intAt returns the int at the given offset in d.data. +func (d *decoder) intAt(off int) int { + if off < 0 || len(d.data)-off < 4 { + panic(errCorrupt) + } + i := binary.LittleEndian.Uint32(d.data[off : off+4]) + if int32(i)>>31 != 0 { + panic(errCorrupt) + } + return int(i) +} + +// boolAt returns the bool at the given offset in d.data. +func (d *decoder) boolAt(off int) bool { + return d.intAt(off) != 0 +} + +// stringAt returns the string pointed at by the int at the given offset in d.data. +func (d *decoder) stringAt(off int) string { + return d.stringTableAt(d.intAt(off)) +} + +// stringTableAt returns the string at the given offset in the string table d.str. +func (d *decoder) stringTableAt(off int) string { + if off < 0 || off >= len(d.str) { + panic(errCorrupt) + } + s := d.str[off:] + v, n := binary.Uvarint(s) + if n <= 0 || v > uint64(len(s[n:])) { + panic(errCorrupt) + } + return asString(s[n : n+int(v)]) +} + +// A reader reads sequential fields from a section of the index format. +type reader struct { + d *decoder + pos int +} + +// readAt returns a reader starting at the given position in d. +func (d *decoder) readAt(pos int) *reader { + return &reader{d, pos} +} + +// int reads the next int. +func (r *reader) int() int { + i := r.d.intAt(r.pos) + r.pos += 4 + return i +} + +// string reads the next string. +func (r *reader) string() string { + return r.d.stringTableAt(r.int()) +} + +// tokpos reads the next token.Position. +func (r *reader) tokpos() token.Position { + return token.Position{ + Filename: r.string(), + Offset: r.int(), + Line: r.int(), + Column: r.int(), + } +} diff --git a/go/src/cmd/go/internal/modindex/scan.go b/go/src/cmd/go/internal/modindex/scan.go new file mode 100644 index 0000000000000000000000000000000000000000..beded695bfc873f75cb5096818c5964c2cba5581 --- /dev/null +++ b/go/src/cmd/go/internal/modindex/scan.go @@ -0,0 +1,290 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modindex + +import ( + "cmd/go/internal/base" + "cmd/go/internal/fsys" + "cmd/go/internal/str" + "encoding/json" + "errors" + "fmt" + "go/build" + "go/doc" + "go/scanner" + "go/token" + "io/fs" + "path/filepath" + "strings" +) + +// moduleWalkErr returns filepath.SkipDir if the directory isn't relevant +// when indexing a module or generating a filehash, ErrNotIndexed, +// if the module shouldn't be indexed, and nil otherwise. +func moduleWalkErr(root string, path string, d fs.DirEntry, err error) error { + if err != nil { + return ErrNotIndexed + } + // stop at module boundaries + if d.IsDir() && path != root { + if info, err := fsys.Stat(filepath.Join(path, "go.mod")); err == nil && !info.IsDir() { + return filepath.SkipDir + } + } + if d.Type()&fs.ModeSymlink != 0 { + if target, err := fsys.Stat(path); err == nil && target.IsDir() { + // return an error to make the module hash invalid. + // Symlink directories in modules are tricky, so we won't index + // modules that contain them. + // TODO(matloob): perhaps don't return this error if the symlink leads to + // a directory with a go.mod file. + return ErrNotIndexed + } + } + return nil +} + +// indexModule indexes the module at the given directory and returns its +// encoded representation. It returns ErrNotIndexed if the module can't +// be indexed because it contains symlinks. +func indexModule(modroot string) ([]byte, error) { + fsys.Trace("indexModule", modroot) + var packages []*rawPackage + + // If the root itself is a symlink to a directory, + // we want to follow it (see https://go.dev/issue/50807). + // Add a trailing separator to force that to happen. + root := str.WithFilePathSeparator(modroot) + err := fsys.WalkDir(root, func(path string, d fs.DirEntry, err error) error { + if err := moduleWalkErr(root, path, d, err); err != nil { + return err + } + + if !d.IsDir() { + return nil + } + if !strings.HasPrefix(path, root) { + panic(fmt.Errorf("path %v in walk doesn't have modroot %v as prefix", path, modroot)) + } + rel := path[len(root):] + packages = append(packages, importRaw(modroot, rel)) + return nil + }) + if err != nil { + return nil, err + } + return encodeModuleBytes(packages), nil +} + +// indexPackage indexes the package at the given directory and returns its +// encoded representation. It returns ErrNotIndexed if the package can't +// be indexed. +func indexPackage(modroot, pkgdir string) []byte { + fsys.Trace("indexPackage", pkgdir) + p := importRaw(modroot, relPath(pkgdir, modroot)) + return encodePackageBytes(p) +} + +// rawPackage holds the information from each package that's needed to +// fill a build.Package once the context is available. +type rawPackage struct { + error string + dir string // directory containing package sources, relative to the module root + + // Source files + sourceFiles []*rawFile +} + +type parseError struct { + ErrorList *scanner.ErrorList + ErrorString string +} + +// parseErrorToString converts the error from parsing the file into a string +// representation. A nil error is converted to an empty string, and all other +// errors are converted to a JSON-marshaled parseError struct, with ErrorList +// set for errors of type scanner.ErrorList, and ErrorString set to the error's +// string representation for all other errors. +func parseErrorToString(err error) string { + if err == nil { + return "" + } + var p parseError + if errlist, ok := err.(scanner.ErrorList); ok { + p.ErrorList = &errlist + } else { + p.ErrorString = err.Error() + } + s, err := json.Marshal(p) + if err != nil { + panic(err) // This should be impossible because scanner.Error contains only strings and ints. + } + return string(s) +} + +// parseErrorFromString converts a string produced by parseErrorToString back +// to an error. An empty string is converted to a nil error, and all +// other strings are expected to be JSON-marshaled parseError structs. +// The two functions are meant to preserve the structure of an +// error of type scanner.ErrorList in a round trip, but may not preserve the +// structure of other errors. +func parseErrorFromString(s string) error { + if s == "" { + return nil + } + var p parseError + if err := json.Unmarshal([]byte(s), &p); err != nil { + base.Fatalf(`go: invalid parse error value in index: %q. This indicates a corrupted index. Run "go clean -cache" to reset the module cache.`, s) + } + if p.ErrorList != nil { + return *p.ErrorList + } + return errors.New(p.ErrorString) +} + +// rawFile is the struct representation of the file holding all +// information in its fields. +type rawFile struct { + error string + parseError string + + name string + synopsis string // doc.Synopsis of package comment... Compute synopsis on all of these? + pkgName string + ignoreFile bool // starts with _ or . or should otherwise always be ignored + binaryOnly bool // cannot be rebuilt from source (has //go:binary-only-package comment) + cgoDirectives string // the #cgo directive lines in the comment on import "C" + goBuildConstraint string + plusBuildConstraints []string + imports []rawImport + embeds []embed + directives []build.Directive +} + +type rawImport struct { + path string + position token.Position +} + +type embed struct { + pattern string + position token.Position +} + +// importRaw fills the rawPackage from the package files in srcDir. +// dir is the package's path relative to the modroot. +func importRaw(modroot, reldir string) *rawPackage { + p := &rawPackage{ + dir: reldir, + } + + absdir := filepath.Join(modroot, reldir) + + // We still haven't checked + // that p.dir directory exists. This is the right time to do that check. + // We can't do it earlier, because we want to gather partial information for the + // non-nil *build.Package returned when an error occurs. + // We need to do this before we return early on FindOnly flag. + if !isDir(absdir) { + // package was not found + p.error = fmt.Errorf("cannot find package in:\n\t%s", absdir).Error() + return p + } + + entries, err := fsys.ReadDir(absdir) + if err != nil { + p.error = err.Error() + return p + } + + fset := token.NewFileSet() + for _, d := range entries { + if d.IsDir() { + continue + } + if d.Type()&fs.ModeSymlink != 0 { + if isDir(filepath.Join(absdir, d.Name())) { + // Symlinks to directories are not source files. + continue + } + } + + name := d.Name() + ext := nameExt(name) + + if strings.HasPrefix(name, "_") || strings.HasPrefix(name, ".") { + continue + } + info, err := getFileInfo(absdir, name, fset) + if err == errNonSource { + // not a source or object file. completely ignore in the index + continue + } else if err != nil { + p.sourceFiles = append(p.sourceFiles, &rawFile{name: name, error: err.Error()}) + continue + } else if info == nil { + p.sourceFiles = append(p.sourceFiles, &rawFile{name: name, ignoreFile: true}) + continue + } + rf := &rawFile{ + name: name, + goBuildConstraint: info.goBuildConstraint, + plusBuildConstraints: info.plusBuildConstraints, + binaryOnly: info.binaryOnly, + directives: info.directives, + } + if info.parsed != nil { + rf.pkgName = info.parsed.Name.Name + } + + // Going to save the file. For non-Go files, can stop here. + p.sourceFiles = append(p.sourceFiles, rf) + if ext != ".go" { + continue + } + + if info.parseErr != nil { + rf.parseError = parseErrorToString(info.parseErr) + // Fall through: we might still have a partial AST in info.Parsed, + // and we want to list files with parse errors anyway. + } + + if info.parsed != nil && info.parsed.Doc != nil { + rf.synopsis = doc.Synopsis(info.parsed.Doc.Text()) + } + + var cgoDirectives []string + for _, imp := range info.imports { + if imp.path == "C" { + cgoDirectives = append(cgoDirectives, extractCgoDirectives(imp.doc.Text())...) + } + rf.imports = append(rf.imports, rawImport{path: imp.path, position: fset.Position(imp.pos)}) + } + rf.cgoDirectives = strings.Join(cgoDirectives, "\n") + for _, emb := range info.embeds { + rf.embeds = append(rf.embeds, embed{emb.pattern, emb.pos}) + } + + } + return p +} + +// extractCgoDirectives filters only the lines containing #cgo directives from the input, +// which is the comment on import "C". +func extractCgoDirectives(doc string) []string { + var out []string + for line := range strings.SplitSeq(doc, "\n") { + // Line is + // #cgo [GOOS/GOARCH...] LDFLAGS: stuff + // + line = strings.TrimSpace(line) + if len(line) < 5 || line[:4] != "#cgo" || (line[4] != ' ' && line[4] != '\t') { + continue + } + + out = append(out, line) + } + return out +} diff --git a/go/src/cmd/go/internal/modindex/syslist_test.go b/go/src/cmd/go/internal/modindex/syslist_test.go new file mode 100644 index 0000000000000000000000000000000000000000..1a61562deffafcfb3898cfddf6fde2d64c6de83d --- /dev/null +++ b/go/src/cmd/go/internal/modindex/syslist_test.go @@ -0,0 +1,65 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file is a lightly modified copy go/build/syslist_test.go. + +package modindex + +import ( + "go/build" + "runtime" + "testing" +) + +var ( + thisOS = runtime.GOOS + thisArch = runtime.GOARCH + otherOS = anotherOS() + otherArch = anotherArch() +) + +func anotherOS() string { + if thisOS != "darwin" && thisOS != "ios" { + return "darwin" + } + return "linux" +} + +func anotherArch() string { + if thisArch != "amd64" { + return "amd64" + } + return "386" +} + +type GoodFileTest struct { + name string + result bool +} + +var tests = []GoodFileTest{ + {"file.go", true}, + {"file.c", true}, + {"file_foo.go", true}, + {"file_" + thisArch + ".go", true}, + {"file_" + otherArch + ".go", false}, + {"file_" + thisOS + ".go", true}, + {"file_" + otherOS + ".go", false}, + {"file_" + thisOS + "_" + thisArch + ".go", true}, + {"file_" + otherOS + "_" + thisArch + ".go", false}, + {"file_" + thisOS + "_" + otherArch + ".go", false}, + {"file_" + otherOS + "_" + otherArch + ".go", false}, + {"file_foo_" + thisArch + ".go", true}, + {"file_foo_" + otherArch + ".go", false}, + {"file_" + thisOS + ".c", true}, + {"file_" + otherOS + ".c", false}, +} + +func TestGoodOSArch(t *testing.T) { + for _, test := range tests { + if (*Context)(&build.Default).goodOSArchFile(test.name, make(map[string]bool)) != test.result { + t.Fatalf("goodOSArchFile(%q) != %v", test.name, test.result) + } + } +} diff --git a/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/a.syso b/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/a.syso new file mode 100644 index 0000000000000000000000000000000000000000..9527d05936c460a35a9b875e1dc722988d0079d6 --- /dev/null +++ b/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/a.syso @@ -0,0 +1 @@ +package ignore_non_source diff --git a/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/b.go b/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/b.go new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/bar.json b/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/bar.json new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/baz.log b/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/baz.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/c.c b/go/src/cmd/go/internal/modindex/testdata/ignore_non_source/c.c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/go/src/cmd/go/internal/modindex/write.go b/go/src/cmd/go/internal/modindex/write.go new file mode 100644 index 0000000000000000000000000000000000000000..cd18ad96dd19c3f22e5abe502f379e574591944d --- /dev/null +++ b/go/src/cmd/go/internal/modindex/write.go @@ -0,0 +1,164 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modindex + +import ( + "cmd/go/internal/base" + "encoding/binary" + "go/token" + "sort" +) + +const indexVersion = "go index v2" // 11 bytes (plus \n), to align uint32s in index + +// encodeModuleBytes produces the encoded representation of the module index. +// encodeModuleBytes may modify the packages slice. +func encodeModuleBytes(packages []*rawPackage) []byte { + e := newEncoder() + e.Bytes([]byte(indexVersion + "\n")) + stringTableOffsetPos := e.Pos() // fill this at the end + e.Uint32(0) // string table offset + sort.Slice(packages, func(i, j int) bool { + return packages[i].dir < packages[j].dir + }) + e.Int(len(packages)) + packagesPos := e.Pos() + for _, p := range packages { + e.String(p.dir) + e.Int(0) + } + for i, p := range packages { + e.IntAt(e.Pos(), packagesPos+8*i+4) + encodePackage(e, p) + } + e.IntAt(e.Pos(), stringTableOffsetPos) + e.Bytes(e.stringTable) + e.Bytes([]byte{0xFF}) // end of string table marker + return e.b +} + +func encodePackageBytes(p *rawPackage) []byte { + return encodeModuleBytes([]*rawPackage{p}) +} + +func encodePackage(e *encoder, p *rawPackage) { + e.String(p.error) + e.String(p.dir) + e.Int(len(p.sourceFiles)) // number of source files + sourceFileOffsetPos := e.Pos() // the pos of the start of the source file offsets + for range p.sourceFiles { + e.Int(0) + } + for i, f := range p.sourceFiles { + e.IntAt(e.Pos(), sourceFileOffsetPos+4*i) + encodeFile(e, f) + } +} + +func encodeFile(e *encoder, f *rawFile) { + e.String(f.error) + e.String(f.parseError) + e.String(f.synopsis) + e.String(f.name) + e.String(f.pkgName) + e.Bool(f.ignoreFile) + e.Bool(f.binaryOnly) + e.String(f.cgoDirectives) + e.String(f.goBuildConstraint) + + e.Int(len(f.plusBuildConstraints)) + for _, s := range f.plusBuildConstraints { + e.String(s) + } + + e.Int(len(f.imports)) + for _, m := range f.imports { + e.String(m.path) + e.Position(m.position) + } + + e.Int(len(f.embeds)) + for _, embed := range f.embeds { + e.String(embed.pattern) + e.Position(embed.position) + } + + e.Int(len(f.directives)) + for _, d := range f.directives { + e.String(d.Text) + e.Position(d.Pos) + } +} + +func newEncoder() *encoder { + e := &encoder{strings: make(map[string]int)} + + // place the empty string at position 0 in the string table + e.stringTable = append(e.stringTable, 0) + e.strings[""] = 0 + + return e +} + +func (e *encoder) Position(position token.Position) { + e.String(position.Filename) + e.Int(position.Offset) + e.Int(position.Line) + e.Int(position.Column) +} + +type encoder struct { + b []byte + stringTable []byte + strings map[string]int +} + +func (e *encoder) Pos() int { + return len(e.b) +} + +func (e *encoder) Bytes(b []byte) { + e.b = append(e.b, b...) +} + +func (e *encoder) String(s string) { + if n, ok := e.strings[s]; ok { + e.Int(n) + return + } + pos := len(e.stringTable) + e.strings[s] = pos + e.Int(pos) + e.stringTable = binary.AppendUvarint(e.stringTable, uint64(len(s))) + e.stringTable = append(e.stringTable, s...) +} + +func (e *encoder) Bool(b bool) { + if b { + e.Uint32(1) + } else { + e.Uint32(0) + } +} + +func (e *encoder) Uint32(n uint32) { + e.b = binary.LittleEndian.AppendUint32(e.b, n) +} + +// Int encodes n. Note that all ints are written to the index as uint32s, +// and to avoid problems on 32-bit systems we require fitting into a 32-bit int. +func (e *encoder) Int(n int) { + if n < 0 || int(int32(n)) != n { + base.Fatalf("go: attempting to write an int to the index that overflows int32") + } + e.Uint32(uint32(n)) +} + +func (e *encoder) IntAt(n int, at int) { + if n < 0 || int(int32(n)) != n { + base.Fatalf("go: attempting to write an int to the index that overflows int32") + } + binary.LittleEndian.PutUint32(e.b[at:], uint32(n)) +} diff --git a/go/src/cmd/go/internal/modinfo/info.go b/go/src/cmd/go/internal/modinfo/info.go new file mode 100644 index 0000000000000000000000000000000000000000..ee73c5e07b7fa95c0c9c8d42d1a93896532f8722 --- /dev/null +++ b/go/src/cmd/go/internal/modinfo/info.go @@ -0,0 +1,86 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modinfo + +import ( + "cmd/go/internal/modfetch/codehost" + "encoding/json" + "time" +) + +// Note that these structs are publicly visible (part of go list's API) +// and the fields are documented in the help text in ../list/list.go + +type ModulePublic struct { + Path string `json:",omitempty"` // module path + Version string `json:",omitempty"` // module version + Query string `json:",omitempty"` // version query corresponding to this version + Versions []string `json:",omitempty"` // available module versions + Replace *ModulePublic `json:",omitempty"` // replaced by this module + Time *time.Time `json:",omitempty"` // time version was created + Update *ModulePublic `json:",omitempty"` // available update (with -u) + Main bool `json:",omitempty"` // is this the main module? + Indirect bool `json:",omitempty"` // module is only indirectly needed by main module + Dir string `json:",omitempty"` // directory holding local copy of files, if any + GoMod string `json:",omitempty"` // path to go.mod file describing module, if any + GoVersion string `json:",omitempty"` // go version used in module + Retracted []string `json:",omitempty"` // retraction information, if any (with -retracted or -u) + Deprecated string `json:",omitempty"` // deprecation message, if any (with -u) + Error *ModuleError `json:",omitempty"` // error loading module + Sum string `json:",omitempty"` // checksum for path, version (as in go.sum) + GoModSum string `json:",omitempty"` // checksum for go.mod (as in go.sum) + Origin *codehost.Origin `json:",omitempty"` // provenance of module + Reuse bool `json:",omitempty"` // reuse of old module info is safe +} + +type ModuleError struct { + Err string // error text +} + +type moduleErrorNoMethods ModuleError + +// UnmarshalJSON accepts both {"Err":"text"} and "text", +// so that the output of go mod download -json can still +// be unmarshaled into a ModulePublic during -reuse processing. +func (e *ModuleError) UnmarshalJSON(data []byte) error { + if len(data) > 0 && data[0] == '"' { + return json.Unmarshal(data, &e.Err) + } + return json.Unmarshal(data, (*moduleErrorNoMethods)(e)) +} + +func (m *ModulePublic) String() string { + s := m.Path + versionString := func(mm *ModulePublic) string { + v := mm.Version + if len(mm.Retracted) == 0 { + return v + } + return v + " (retracted)" + } + + if m.Version != "" { + s += " " + versionString(m) + if m.Update != nil { + s += " [" + versionString(m.Update) + "]" + } + } + if m.Deprecated != "" { + s += " (deprecated)" + } + if m.Replace != nil { + s += " => " + m.Replace.Path + if m.Replace.Version != "" { + s += " " + versionString(m.Replace) + if m.Replace.Update != nil { + s += " [" + versionString(m.Replace.Update) + "]" + } + } + if m.Replace.Deprecated != "" { + s += " (deprecated)" + } + } + return s +} diff --git a/go/src/cmd/go/internal/modload/build.go b/go/src/cmd/go/internal/modload/build.go new file mode 100644 index 0000000000000000000000000000000000000000..cb4371357c1e8a025a1b40eb41da49bfc3bb61ce --- /dev/null +++ b/go/src/cmd/go/internal/modload/build.go @@ -0,0 +1,478 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "context" + "encoding/hex" + "errors" + "fmt" + "io/fs" + "os" + "path/filepath" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/modfetch" + "cmd/go/internal/modfetch/codehost" + "cmd/go/internal/modindex" + "cmd/go/internal/modinfo" + "cmd/go/internal/search" + + "golang.org/x/mod/module" +) + +var ( + infoStart, _ = hex.DecodeString("3077af0c9274080241e1c107e6d618e6") + infoEnd, _ = hex.DecodeString("f932433186182072008242104116d8f2") +) + +func isStandardImportPath(path string) bool { + return findStandardImportPath(path) != "" +} + +func findStandardImportPath(path string) string { + if path == "" { + panic("findStandardImportPath called with empty path") + } + if search.IsStandardImportPath(path) { + if modindex.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, path) { + return filepath.Join(cfg.GOROOT, "src", path) + } + } + return "" +} + +// PackageModuleInfo returns information about the module that provides +// a given package. If modules are not enabled or if the package is in the +// standard library or if the package was not successfully loaded with +// LoadPackages or ImportFromFiles, nil is returned. +func PackageModuleInfo(loaderstate *State, ctx context.Context, pkgpath string) *modinfo.ModulePublic { + if isStandardImportPath(pkgpath) || !loaderstate.Enabled() { + return nil + } + m, ok := findModule(loaded, pkgpath) + if !ok { + return nil + } + + rs := LoadModFile(loaderstate, ctx) + return moduleInfo(loaderstate, ctx, rs, m, 0, nil) +} + +// PackageModRoot returns the module root directory for the module that provides +// a given package. If modules are not enabled or if the package is in the +// standard library or if the package was not successfully loaded with +// LoadPackages or ImportFromFiles, the empty string is returned. +func PackageModRoot(loaderstate *State, ctx context.Context, pkgpath string) string { + if isStandardImportPath(pkgpath) || !loaderstate.Enabled() || cfg.BuildMod == "vendor" { + return "" + } + m, ok := findModule(loaded, pkgpath) + if !ok { + return "" + } + root, _, err := fetch(loaderstate, ctx, m) + if err != nil { + return "" + } + return root +} + +func ModuleInfo(loaderstate *State, ctx context.Context, path string) *modinfo.ModulePublic { + if !loaderstate.Enabled() { + return nil + } + + path, vers, found, err := ParsePathVersion(path) + if err != nil { + return &modinfo.ModulePublic{ + Path: path, + Error: &modinfo.ModuleError{ + Err: err.Error(), + }, + } + } + if found { + m := module.Version{Path: path, Version: vers} + return moduleInfo(loaderstate, ctx, nil, m, 0, nil) + } + + rs := LoadModFile(loaderstate, ctx) + + var ( + v string + ok bool + ) + if rs.pruning == pruned { + v, ok = rs.rootSelected(loaderstate, path) + } + if !ok { + mg, err := rs.Graph(loaderstate, ctx) + if err != nil { + base.Fatal(err) + } + v = mg.Selected(path) + } + + if v == "none" { + return &modinfo.ModulePublic{ + Path: path, + Error: &modinfo.ModuleError{ + Err: "module not in current build", + }, + } + } + + return moduleInfo(loaderstate, ctx, rs, module.Version{Path: path, Version: v}, 0, nil) +} + +// addUpdate fills in m.Update if an updated version is available. +func addUpdate(loaderstate *State, ctx context.Context, m *modinfo.ModulePublic) { + if m.Version == "" { + return + } + + info, err := Query(loaderstate, ctx, m.Path, "upgrade", m.Version, loaderstate.CheckAllowed) + if _, ok := errors.AsType[*NoMatchingVersionError](err); ok || + errors.Is(err, fs.ErrNotExist) || + errors.Is(err, ErrDisallowed) { + // Ignore "no matching version" and "not found" errors. + // This means the proxy has no matching version or no versions at all. + // + // Ignore "disallowed" errors. This means the current version is + // excluded or retracted and there are no higher allowed versions. + // + // We should report other errors though. An attacker that controls the + // network shouldn't be able to hide versions by interfering with + // the HTTPS connection. An attacker that controls the proxy may still + // hide versions, since the "list" and "latest" endpoints are not + // authenticated. + return + } else if err != nil { + if m.Error == nil { + m.Error = &modinfo.ModuleError{Err: err.Error()} + } + return + } + + if gover.ModCompare(m.Path, info.Version, m.Version) > 0 { + m.Update = &modinfo.ModulePublic{ + Path: m.Path, + Version: info.Version, + Time: &info.Time, + } + } +} + +// mergeOrigin returns the union of data from two origins, +// returning either a new origin or one of its unmodified arguments. +// If the two origins conflict including if either is nil, +// mergeOrigin returns nil. +func mergeOrigin(m1, m2 *codehost.Origin) *codehost.Origin { + if m1 == nil || m2 == nil { + return nil + } + + if m2.VCS != m1.VCS || + m2.URL != m1.URL || + m2.Subdir != m1.Subdir { + return nil + } + + merged := *m1 + if m2.Hash != "" { + if m1.Hash != "" && m1.Hash != m2.Hash { + return nil + } + merged.Hash = m2.Hash + } + if m2.TagSum != "" { + if m1.TagSum != "" && (m1.TagSum != m2.TagSum || m1.TagPrefix != m2.TagPrefix) { + return nil + } + merged.TagSum = m2.TagSum + merged.TagPrefix = m2.TagPrefix + } + if m2.RepoSum != "" { + if m1.RepoSum != "" && m1.RepoSum != m2.RepoSum { + return nil + } + merged.RepoSum = m2.RepoSum + } + if m2.Ref != "" { + if m1.Ref != "" && m1.Ref != m2.Ref { + return nil + } + merged.Ref = m2.Ref + } + + switch { + case merged == *m1: + return m1 + case merged == *m2: + return m2 + default: + // Clone the result to avoid an alloc for merged + // if the result is equal to one of the arguments. + clone := merged + return &clone + } +} + +// addVersions fills in m.Versions with the list of known versions. +// Excluded versions will be omitted. If listRetracted is false, retracted +// versions will also be omitted. +func addVersions(loaderstate *State, ctx context.Context, m *modinfo.ModulePublic, listRetracted bool) { + // TODO(bcmills): Would it make sense to check for reuse here too? + // Perhaps that doesn't buy us much, though: we would always have to fetch + // all of the version tags to list the available versions anyway. + + allowed := loaderstate.CheckAllowed + if listRetracted { + allowed = loaderstate.CheckExclusions + } + v, origin, err := versions(loaderstate, ctx, m.Path, allowed) + if err != nil && m.Error == nil { + m.Error = &modinfo.ModuleError{Err: err.Error()} + } + m.Versions = v + m.Origin = mergeOrigin(m.Origin, origin) +} + +// addRetraction fills in m.Retracted if the module was retracted by its author. +// m.Error is set if there's an error loading retraction information. +func addRetraction(loaderstate *State, ctx context.Context, m *modinfo.ModulePublic) { + if m.Version == "" { + return + } + + err := loaderstate.CheckRetractions(ctx, module.Version{Path: m.Path, Version: m.Version}) + if err == nil { + return + } else if _, ok := errors.AsType[*NoMatchingVersionError](err); ok || errors.Is(err, fs.ErrNotExist) { + // Ignore "no matching version" and "not found" errors. + // This means the proxy has no matching version or no versions at all. + // + // We should report other errors though. An attacker that controls the + // network shouldn't be able to hide versions by interfering with + // the HTTPS connection. An attacker that controls the proxy may still + // hide versions, since the "list" and "latest" endpoints are not + // authenticated. + return + } else if retractErr, ok := errors.AsType[*ModuleRetractedError](err); ok { + if len(retractErr.Rationale) == 0 { + m.Retracted = []string{"retracted by module author"} + } else { + m.Retracted = retractErr.Rationale + } + } else if m.Error == nil { + m.Error = &modinfo.ModuleError{Err: err.Error()} + } +} + +// addDeprecation fills in m.Deprecated if the module was deprecated by its +// author. m.Error is set if there's an error loading deprecation information. +func addDeprecation(loaderstate *State, ctx context.Context, m *modinfo.ModulePublic) { + deprecation, err := CheckDeprecation(loaderstate, ctx, module.Version{Path: m.Path, Version: m.Version}) + if _, ok := errors.AsType[*NoMatchingVersionError](err); ok || errors.Is(err, fs.ErrNotExist) { + // Ignore "no matching version" and "not found" errors. + // This means the proxy has no matching version or no versions at all. + // + // We should report other errors though. An attacker that controls the + // network shouldn't be able to hide versions by interfering with + // the HTTPS connection. An attacker that controls the proxy may still + // hide versions, since the "list" and "latest" endpoints are not + // authenticated. + return + } + if err != nil { + if m.Error == nil { + m.Error = &modinfo.ModuleError{Err: err.Error()} + } + return + } + m.Deprecated = deprecation +} + +// moduleInfo returns information about module m, loaded from the requirements +// in rs (which may be nil to indicate that m was not loaded from a requirement +// graph). +func moduleInfo(loaderstate *State, ctx context.Context, rs *Requirements, m module.Version, mode ListMode, reuse map[module.Version]*modinfo.ModulePublic) *modinfo.ModulePublic { + if m.Version == "" && loaderstate.MainModules.Contains(m.Path) { + info := &modinfo.ModulePublic{ + Path: m.Path, + Version: m.Version, + Main: true, + } + if v, ok := rawGoVersion.Load(m); ok { + info.GoVersion = v.(string) + } else { + panic("internal error: GoVersion not set for main module") + } + if modRoot := loaderstate.MainModules.ModRoot(m); modRoot != "" { + info.Dir = modRoot + info.GoMod = modFilePath(modRoot) + } + return info + } + + info := &modinfo.ModulePublic{ + Path: m.Path, + Version: m.Version, + Indirect: rs != nil && !rs.direct[m.Path], + } + if v, ok := rawGoVersion.Load(m); ok { + info.GoVersion = v.(string) + } + + // completeFromModCache fills in the extra fields in m using the module cache. + completeFromModCache := func(m *modinfo.ModulePublic) { + if gover.IsToolchain(m.Path) { + return + } + + checksumOk := func(suffix string) bool { + return rs == nil || m.Version == "" || !mustHaveSums(loaderstate) || + modfetch.HaveSum(loaderstate.Fetcher(), module.Version{Path: m.Path, Version: m.Version + suffix}) + } + + mod := module.Version{Path: m.Path, Version: m.Version} + + if m.Version != "" { + if old := reuse[mod]; old != nil { + if err := checkReuse(loaderstate, ctx, mod, old.Origin); err == nil { + *m = *old + m.Query = "" + m.Dir = "" + return + } + } + + if q, err := Query(loaderstate, ctx, m.Path, m.Version, "", nil); err != nil { + m.Error = &modinfo.ModuleError{Err: err.Error()} + } else { + m.Version = q.Version + m.Time = &q.Time + } + } + + if m.GoVersion == "" && checksumOk("/go.mod") { + // Load the go.mod file to determine the Go version, since it hasn't + // already been populated from rawGoVersion. + if summary, err := rawGoModSummary(loaderstate, mod); err == nil && summary.goVersion != "" { + m.GoVersion = summary.goVersion + } + } + + if m.Version != "" { + if checksumOk("/go.mod") { + gomod, err := modfetch.CachePath(ctx, mod, "mod") + if err == nil { + if info, err := os.Stat(gomod); err == nil && info.Mode().IsRegular() { + m.GoMod = gomod + } + } + if gomodsum, ok := loaderstate.fetcher.RecordedSum(modkey(mod)); ok { + m.GoModSum = gomodsum + } + } + if checksumOk("") { + dir, err := modfetch.DownloadDir(ctx, mod) + if err == nil { + m.Dir = dir + } + if sum, ok := loaderstate.fetcher.RecordedSum(mod); ok { + m.Sum = sum + } + } + + if mode&ListRetracted != 0 { + addRetraction(loaderstate, ctx, m) + } + } + } + + if rs == nil { + // If this was an explicitly-versioned argument to 'go mod download' or + // 'go list -m', report the actual requested version, not its replacement. + completeFromModCache(info) // Will set m.Error in vendor mode. + return info + } + + r := Replacement(loaderstate, m) + if r.Path == "" { + if cfg.BuildMod == "vendor" { + // It's tempting to fill in the "Dir" field to point within the vendor + // directory, but that would be misleading: the vendor directory contains + // a flattened package tree, not complete modules, and it can even + // interleave packages from different modules if one module path is a + // prefix of the other. + } else { + completeFromModCache(info) + } + return info + } + + // Don't hit the network to fill in extra data for replaced modules. + // The original resolved Version and Time don't matter enough to be + // worth the cost, and we're going to overwrite the GoMod and Dir from the + // replacement anyway. See https://golang.org/issue/27859. + info.Replace = &modinfo.ModulePublic{ + Path: r.Path, + Version: r.Version, + } + if v, ok := rawGoVersion.Load(m); ok { + info.Replace.GoVersion = v.(string) + } + if r.Version == "" { + if filepath.IsAbs(r.Path) { + info.Replace.Dir = r.Path + } else { + info.Replace.Dir = filepath.Join(replaceRelativeTo(loaderstate), r.Path) + } + info.Replace.GoMod = filepath.Join(info.Replace.Dir, "go.mod") + } + if cfg.BuildMod != "vendor" { + completeFromModCache(info.Replace) + info.Dir = info.Replace.Dir + info.GoMod = info.Replace.GoMod + info.Retracted = info.Replace.Retracted + } + info.GoVersion = info.Replace.GoVersion + return info +} + +// findModule searches for the module that contains the package at path. +// If the package was loaded, its containing module and true are returned. +// Otherwise, module.Version{} and false are returned. +func findModule(ld *loader, path string) (module.Version, bool) { + if pkg, ok := ld.pkgCache.Get(path); ok { + return pkg.mod, pkg.mod != module.Version{} + } + return module.Version{}, false +} + +func ModInfoProg(info string, isgccgo bool) []byte { + // Inject an init function to set runtime.modinfo. + // This is only used for gccgo - with gc we hand the info directly to the linker. + // The init function has the drawback that packages may want to + // look at the module info in their init functions (see issue 29628), + // which won't work. See also issue 30344. + if isgccgo { + return fmt.Appendf(nil, `package main +import _ "unsafe" +//go:linkname __set_debug_modinfo__ runtime.setmodinfo +func __set_debug_modinfo__(string) +func init() { __set_debug_modinfo__(%q) } +`, ModInfoData(info)) + } + return nil +} + +func ModInfoData(info string) []byte { + return []byte(string(infoStart) + info + string(infoEnd)) +} diff --git a/go/src/cmd/go/internal/modload/buildlist.go b/go/src/cmd/go/internal/modload/buildlist.go new file mode 100644 index 0000000000000000000000000000000000000000..37c2a6c759f0db761fbc0b480877aa663171091e --- /dev/null +++ b/go/src/cmd/go/internal/modload/buildlist.go @@ -0,0 +1,1495 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "context" + "errors" + "fmt" + "maps" + "os" + "runtime" + "runtime/debug" + "slices" + "strings" + "sync" + "sync/atomic" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/mvs" + "cmd/internal/par" + + "golang.org/x/mod/module" +) + +// A Requirements represents a logically-immutable set of root module requirements. +type Requirements struct { + // pruning is the pruning at which the requirement graph is computed. + // + // If unpruned, the graph includes all transitive requirements regardless + // of whether the requiring module supports pruning. + // + // If pruned, the graph includes only the root modules, the explicit + // requirements of those root modules, and the transitive requirements of only + // the root modules that do not support pruning. + // + // If workspace, the graph includes only the workspace modules, the explicit + // requirements of the workspace modules, and the transitive requirements of + // the workspace modules that do not support pruning. + pruning modPruning + + // rootModules is the set of root modules of the graph, sorted and capped to + // length. It may contain duplicates, and may contain multiple versions for a + // given module path. The root modules of the graph are the set of main + // modules in workspace mode, and the main module's direct requirements + // outside workspace mode. + // + // The roots are always expected to contain an entry for the "go" module, + // indicating the Go language version in use. + rootModules []module.Version + maxRootVersion map[string]string + + // direct is the set of module paths for which we believe the module provides + // a package directly imported by a package or test in the main module. + // + // The "direct" map controls which modules are annotated with "// indirect" + // comments in the go.mod file, and may impact which modules are listed as + // explicit roots (vs. indirect-only dependencies). However, it should not + // have a semantic effect on the build list overall. + // + // The initial direct map is populated from the existing "// indirect" + // comments (or lack thereof) in the go.mod file. It is updated by the + // package loader: dependencies may be promoted to direct if new + // direct imports are observed, and may be demoted to indirect during + // 'go mod tidy' or 'go mod vendor'. + // + // The direct map is keyed by module paths, not module versions. When a + // module's selected version changes, we assume that it remains direct if the + // previous version was a direct dependency. That assumption might not hold in + // rare cases (such as if a dependency splits out a nested module, or merges a + // nested module back into a parent module). + direct map[string]bool + + graphOnce sync.Once // guards writes to (but not reads from) graph + graph atomic.Pointer[cachedGraph] +} + +// A cachedGraph is a non-nil *ModuleGraph, together with any error discovered +// while loading that graph. +type cachedGraph struct { + mg *ModuleGraph + err error // If err is non-nil, mg may be incomplete (but must still be non-nil). +} + +func mustHaveGoRoot(roots []module.Version) { + for _, m := range roots { + if m.Path == "go" { + return + } + } + panic("go: internal error: missing go root module") +} + +// newRequirements returns a new requirement set with the given root modules. +// The dependencies of the roots will be loaded lazily at the first call to the +// Graph method. +// +// The rootModules slice must be sorted according to gover.ModSort. +// The caller must not modify the rootModules slice or direct map after passing +// them to newRequirements. +// +// If vendoring is in effect, the caller must invoke initVendor on the returned +// *Requirements before any other method. +func newRequirements(loaderstate *State, pruning modPruning, rootModules []module.Version, direct map[string]bool) *Requirements { + mustHaveGoRoot(rootModules) + + if pruning != workspace { + if loaderstate.workFilePath != "" { + panic("in workspace mode, but pruning is not workspace in newRequirements") + } + } + + if pruning != workspace { + if loaderstate.workFilePath != "" { + panic("in workspace mode, but pruning is not workspace in newRequirements") + } + for i, m := range rootModules { + if m.Version == "" && loaderstate.MainModules.Contains(m.Path) { + panic(fmt.Sprintf("newRequirements called with untrimmed build list: rootModules[%v] is a main module", i)) + } + if m.Path == "" || m.Version == "" { + panic(fmt.Sprintf("bad requirement: rootModules[%v] = %v", i, m)) + } + } + } + + rs := &Requirements{ + pruning: pruning, + rootModules: rootModules, + maxRootVersion: make(map[string]string, len(rootModules)), + direct: direct, + } + + for i, m := range rootModules { + if i > 0 { + prev := rootModules[i-1] + if prev.Path > m.Path || (prev.Path == m.Path && gover.ModCompare(m.Path, prev.Version, m.Version) > 0) { + panic(fmt.Sprintf("newRequirements called with unsorted roots: %v", rootModules)) + } + } + + if v, ok := rs.maxRootVersion[m.Path]; ok && gover.ModCompare(m.Path, v, m.Version) >= 0 { + continue + } + rs.maxRootVersion[m.Path] = m.Version + } + + if rs.maxRootVersion["go"] == "" { + panic(`newRequirements called without a "go" version`) + } + return rs +} + +// String returns a string describing the Requirements for debugging. +func (rs *Requirements) String() string { + return fmt.Sprintf("{%v %v}", rs.pruning, rs.rootModules) +} + +// initVendor initializes rs.graph from the given list of vendored module +// dependencies, overriding the graph that would normally be loaded from module +// requirements. +func (rs *Requirements) initVendor(loaderstate *State, vendorList []module.Version) { + rs.graphOnce.Do(func() { + roots := loaderstate.MainModules.Versions() + if loaderstate.inWorkspaceMode() { + // Use rs.rootModules to pull in the go and toolchain roots + // from the go.work file and preserve the invariant that all + // of rs.rootModules are in mg.g. + roots = rs.rootModules + } + mg := &ModuleGraph{ + g: mvs.NewGraph(cmpVersion, roots), + } + + if rs.pruning == pruned { + mainModule := loaderstate.MainModules.mustGetSingleMainModule(loaderstate) + // The roots of a single pruned module should already include every module in the + // vendor list, because the vendored modules are the same as those needed + // for graph pruning. + // + // Just to be sure, we'll double-check that here. + inconsistent := false + for _, m := range vendorList { + if v, ok := rs.rootSelected(loaderstate, m.Path); !ok || v != m.Version { + base.Errorf("go: vendored module %v should be required explicitly in go.mod", m) + inconsistent = true + } + } + if inconsistent { + base.Fatal(errGoModDirty) + } + + // Now we can treat the rest of the module graph as effectively “pruned + // out”, as though we are viewing the main module from outside: in vendor + // mode, the root requirements *are* the complete module graph. + mg.g.Require(mainModule, rs.rootModules) + } else { + // The transitive requirements of the main module are not in general available + // from the vendor directory, and we don't actually know how we got from + // the roots to the final build list. + // + // Instead, we'll inject a fake "vendor/modules.txt" module that provides + // those transitive dependencies, and mark it as a dependency of the main + // module. That allows us to elide the actual structure of the module + // graph, but still distinguishes between direct and indirect + // dependencies. + vendorMod := module.Version{Path: "vendor/modules.txt", Version: ""} + if loaderstate.inWorkspaceMode() { + for _, m := range loaderstate.MainModules.Versions() { + reqs, _ := rootsFromModFile(loaderstate, m, loaderstate.MainModules.ModFile(m), omitToolchainRoot) + mg.g.Require(m, append(reqs, vendorMod)) + } + mg.g.Require(vendorMod, vendorList) + + } else { + mainModule := loaderstate.MainModules.mustGetSingleMainModule(loaderstate) + mg.g.Require(mainModule, append(rs.rootModules, vendorMod)) + mg.g.Require(vendorMod, vendorList) + } + } + + rs.graph.Store(&cachedGraph{mg, nil}) + }) +} + +// GoVersion returns the Go language version for the Requirements. +func (rs *Requirements) GoVersion(loaderstate *State) string { + v, _ := rs.rootSelected(loaderstate, "go") + if v == "" { + panic("internal error: missing go version in modload.Requirements") + } + return v +} + +// rootSelected returns the version of the root dependency with the given module +// path, or the zero module.Version and ok=false if the module is not a root +// dependency. +func (rs *Requirements) rootSelected(loaderstate *State, path string) (version string, ok bool) { + if loaderstate.MainModules.Contains(path) { + return "", true + } + if v, ok := rs.maxRootVersion[path]; ok { + return v, true + } + return "", false +} + +// hasRedundantRoot returns true if the root list contains multiple requirements +// of the same module or a requirement on any version of the main module. +// Redundant requirements should be pruned, but they may influence version +// selection. +func (rs *Requirements) hasRedundantRoot(loaderstate *State) bool { + for i, m := range rs.rootModules { + if loaderstate.MainModules.Contains(m.Path) || (i > 0 && m.Path == rs.rootModules[i-1].Path) { + return true + } + } + return false +} + +// Graph returns the graph of module requirements loaded from the current +// root modules (as reported by RootModules). +// +// Graph always makes a best effort to load the requirement graph despite any +// errors, and always returns a non-nil *ModuleGraph. +// +// If the requirements of any relevant module fail to load, Graph also +// returns a non-nil error of type *mvs.BuildListError. +func (rs *Requirements) Graph(loaderstate *State, ctx context.Context) (*ModuleGraph, error) { + rs.graphOnce.Do(func() { + mg, mgErr := readModGraph(loaderstate, ctx, rs.pruning, rs.rootModules, nil) + rs.graph.Store(&cachedGraph{mg, mgErr}) + }) + cached := rs.graph.Load() + return cached.mg, cached.err +} + +// IsDirect returns whether the given module provides a package directly +// imported by a package or test in the main module. +func (rs *Requirements) IsDirect(path string) bool { + return rs.direct[path] +} + +// A ModuleGraph represents the complete graph of module dependencies +// of a main module. +// +// If the main module supports module graph pruning, the graph does not include +// transitive dependencies of non-root (implicit) dependencies. +type ModuleGraph struct { + g *mvs.Graph + loadCache par.ErrCache[module.Version, *modFileSummary] + + buildListOnce sync.Once + buildList []module.Version +} + +var readModGraphDebugOnce sync.Once + +// readModGraph reads and returns the module dependency graph starting at the +// given roots. +// +// The requirements of the module versions found in the unprune map are included +// in the graph even if they would normally be pruned out. +// +// Unlike LoadModGraph, readModGraph does not attempt to diagnose or update +// inconsistent roots. +func readModGraph(loaderstate *State, ctx context.Context, pruning modPruning, roots []module.Version, unprune map[module.Version]bool) (*ModuleGraph, error) { + mustHaveGoRoot(roots) + if pruning == pruned { + // Enable diagnostics for lazy module loading + // (https://golang.org/ref/mod#lazy-loading) only if the module graph is + // pruned. + // + // In unpruned modules,we load the module graph much more aggressively (in + // order to detect inconsistencies that wouldn't be feasible to spot-check), + // so it wouldn't be useful to log when that occurs (because it happens in + // normal operation all the time). + readModGraphDebugOnce.Do(func() { + for f := range strings.SplitSeq(os.Getenv("GODEBUG"), ",") { + switch f { + case "lazymod=log": + debug.PrintStack() + fmt.Fprintf(os.Stderr, "go: read full module graph.\n") + case "lazymod=strict": + debug.PrintStack() + base.Fatalf("go: read full module graph (forbidden by GODEBUG=lazymod=strict).") + } + } + }) + } + + var graphRoots []module.Version + if loaderstate.inWorkspaceMode() { + graphRoots = roots + } else { + graphRoots = loaderstate.MainModules.Versions() + } + var ( + mu sync.Mutex // guards mg.g and hasError during loading + hasError bool + mg = &ModuleGraph{ + g: mvs.NewGraph(cmpVersion, graphRoots), + } + ) + + if pruning != workspace { + if loaderstate.inWorkspaceMode() { + panic("pruning is not workspace in workspace mode") + } + mg.g.Require(loaderstate.MainModules.mustGetSingleMainModule(loaderstate), roots) + } + + type dedupKey struct { + m module.Version + pruning modPruning + } + var ( + loadQueue = par.NewQueue(runtime.GOMAXPROCS(0)) + loading sync.Map // dedupKey → nil; the set of modules that have been or are being loaded + ) + + // loadOne synchronously loads the explicit requirements for module m. + // It does not load the transitive requirements of m even if the go version in + // m's go.mod file indicates that it supports graph pruning. + loadOne := func(m module.Version) (*modFileSummary, error) { + return mg.loadCache.Do(m, func() (*modFileSummary, error) { + summary, err := goModSummary(loaderstate, m) + + mu.Lock() + if err == nil { + mg.g.Require(m, summary.require) + } else { + hasError = true + } + mu.Unlock() + + return summary, err + }) + } + + var enqueue func(m module.Version, pruning modPruning) + enqueue = func(m module.Version, pruning modPruning) { + if m.Version == "none" { + return + } + + if _, dup := loading.LoadOrStore(dedupKey{m, pruning}, nil); dup { + // m has already been enqueued for loading. Since unpruned loading may + // follow cycles in the requirement graph, we need to return early + // to avoid making the load queue infinitely long. + return + } + + loadQueue.Add(func() { + summary, err := loadOne(m) + if err != nil { + return // findError will report the error later. + } + + // If the version in m's go.mod file does not support pruning, then we + // cannot assume that the explicit requirements of m (added by loadOne) + // are sufficient to build the packages it contains. We must load its full + // transitive dependency graph to be sure that we see all relevant + // dependencies. In addition, we must load the requirements of any module + // that is explicitly marked as unpruned. + nextPruning := summary.pruning + if pruning == unpruned { + nextPruning = unpruned + } + for _, r := range summary.require { + if pruning != pruned || summary.pruning == unpruned || unprune[r] { + enqueue(r, nextPruning) + } + } + }) + } + + mustHaveGoRoot(roots) + for _, m := range roots { + enqueue(m, pruning) + } + <-loadQueue.Idle() + + // Reload any dependencies of the main modules which are not + // at their selected versions at workspace mode, because the + // requirements don't accurately reflect the transitive imports. + if pruning == workspace { + // hasDepsInAll contains the set of modules that need to be loaded + // at workspace pruning because any of their dependencies may + // provide packages in all. + hasDepsInAll := make(map[string]bool) + seen := map[module.Version]bool{} + for _, m := range roots { + hasDepsInAll[m.Path] = true + } + // This loop will terminate because it will call enqueue on each version of + // each dependency of the modules in hasDepsInAll at most once (and only + // calls enqueue on successively increasing versions of each dependency). + for { + needsEnqueueing := map[module.Version]bool{} + for p := range hasDepsInAll { + m := module.Version{Path: p, Version: mg.g.Selected(p)} + if !seen[m] { + needsEnqueueing[m] = true + continue + } + reqs, _ := mg.g.RequiredBy(m) + for _, r := range reqs { + s := module.Version{Path: r.Path, Version: mg.g.Selected(r.Path)} + if gover.ModCompare(r.Path, s.Version, r.Version) > 0 && !seen[s] { + needsEnqueueing[s] = true + } + } + } + // add all needs enqueueing to paths we care about + if len(needsEnqueueing) == 0 { + break + } + + for p := range needsEnqueueing { + enqueue(p, workspace) + seen[p] = true + hasDepsInAll[p.Path] = true + } + <-loadQueue.Idle() + } + } + + if hasError { + return mg, mg.findError() + } + return mg, nil +} + +// RequiredBy returns the dependencies required by module m in the graph, +// or ok=false if module m's dependencies are pruned out. +// +// The caller must not modify the returned slice, but may safely append to it +// and may rely on it not to be modified. +func (mg *ModuleGraph) RequiredBy(m module.Version) (reqs []module.Version, ok bool) { + return mg.g.RequiredBy(m) +} + +// Selected returns the selected version of the module with the given path. +// +// If no version is selected, Selected returns version "none". +func (mg *ModuleGraph) Selected(path string) (version string) { + return mg.g.Selected(path) +} + +// WalkBreadthFirst invokes f once, in breadth-first order, for each module +// version other than "none" that appears in the graph, regardless of whether +// that version is selected. +func (mg *ModuleGraph) WalkBreadthFirst(f func(m module.Version)) { + mg.g.WalkBreadthFirst(f) +} + +// BuildList returns the selected versions of all modules present in the graph, +// beginning with the main modules. +// +// The order of the remaining elements in the list is deterministic +// but arbitrary. +// +// The caller must not modify the returned list, but may safely append to it +// and may rely on it not to be modified. +func (mg *ModuleGraph) BuildList() []module.Version { + mg.buildListOnce.Do(func() { + mg.buildList = slices.Clip(mg.g.BuildList()) + }) + return mg.buildList +} + +func (mg *ModuleGraph) findError() error { + errStack := mg.g.FindPath(func(m module.Version) bool { + _, err := mg.loadCache.Get(m) + return err != nil && err != par.ErrCacheEntryNotFound + }) + if len(errStack) > 0 { + _, err := mg.loadCache.Get(errStack[len(errStack)-1]) + var noUpgrade func(from, to module.Version) bool + return mvs.NewBuildListError(err, errStack, noUpgrade) + } + + return nil +} + +func (mg *ModuleGraph) allRootsSelected(loaderstate *State) bool { + var roots []module.Version + if loaderstate.inWorkspaceMode() { + roots = loaderstate.MainModules.Versions() + } else { + roots, _ = mg.g.RequiredBy(loaderstate.MainModules.mustGetSingleMainModule(loaderstate)) + } + for _, m := range roots { + if mg.Selected(m.Path) != m.Version { + return false + } + } + return true +} + +// LoadModGraph loads and returns the graph of module dependencies of the main module, +// without loading any packages. +// +// If the goVersion string is non-empty, the returned graph is the graph +// as interpreted by the given Go version (instead of the version indicated +// in the go.mod file). +// +// Modules are loaded automatically (and lazily) in LoadPackages: +// LoadModGraph need only be called if LoadPackages is not, +// typically in commands that care about modules but no particular package. +func LoadModGraph(loaderstate *State, ctx context.Context, goVersion string) (*ModuleGraph, error) { + rs, err := loadModFile(loaderstate, ctx, nil) + if err != nil { + return nil, err + } + + if goVersion != "" { + v, _ := rs.rootSelected(loaderstate, "go") + if gover.Compare(v, gover.GoStrictVersion) >= 0 && gover.Compare(goVersion, v) < 0 { + return nil, fmt.Errorf("requested Go version %s cannot load module graph (requires Go >= %s)", goVersion, v) + } + + pruning := pruningForGoVersion(goVersion) + if pruning == unpruned && rs.pruning != unpruned { + // Use newRequirements instead of convertDepth because convertDepth + // also updates roots; here, we want to report the unmodified roots + // even though they may seem inconsistent. + rs = newRequirements(loaderstate, unpruned, rs.rootModules, rs.direct) + } + + return rs.Graph(loaderstate, ctx) + } + + rs, mg, err := expandGraph(loaderstate, ctx, rs) + if err != nil { + return nil, err + } + loaderstate.requirements = rs + return mg, nil +} + +// expandGraph loads the complete module graph from rs. +// +// If the complete graph reveals that some root of rs is not actually the +// selected version of its path, expandGraph computes a new set of roots that +// are consistent. (With a pruned module graph, this may result in upgrades to +// other modules due to requirements that were previously pruned out.) +// +// expandGraph returns the updated roots, along with the module graph loaded +// from those roots and any error encountered while loading that graph. +// expandGraph returns non-nil requirements and a non-nil graph regardless of +// errors. On error, the roots might not be updated to be consistent. +func expandGraph(loaderstate *State, ctx context.Context, rs *Requirements) (*Requirements, *ModuleGraph, error) { + mg, mgErr := rs.Graph(loaderstate, ctx) + if mgErr != nil { + // Without the graph, we can't update the roots: we don't know which + // versions of transitive dependencies would be selected. + return rs, mg, mgErr + } + + if !mg.allRootsSelected(loaderstate) { + // The roots of rs are not consistent with the rest of the graph. Update + // them. In an unpruned module this is a no-op for the build list as a whole — + // it just promotes what were previously transitive requirements to be + // roots — but in a pruned module it may pull in previously-irrelevant + // transitive dependencies. + + newRS, rsErr := updateRoots(loaderstate, ctx, rs.direct, rs, nil, nil, false) + if rsErr != nil { + // Failed to update roots, perhaps because of an error in a transitive + // dependency needed for the update. Return the original Requirements + // instead. + return rs, mg, rsErr + } + rs = newRS + mg, mgErr = rs.Graph(loaderstate, ctx) + } + + return rs, mg, mgErr +} + +// EditBuildList edits the global build list by first adding every module in add +// to the existing build list, then adjusting versions (and adding or removing +// requirements as needed) until every module in mustSelect is selected at the +// given version. +// +// (Note that the newly-added modules might not be selected in the resulting +// build list: they could be lower than existing requirements or conflict with +// versions in mustSelect.) +// +// If the versions listed in mustSelect are mutually incompatible (due to one of +// the listed modules requiring a higher version of another), EditBuildList +// returns a *ConstraintError and leaves the build list in its previous state. +// +// On success, EditBuildList reports whether the selected version of any module +// in the build list may have been changed (possibly to or from "none") as a +// result. +func EditBuildList(loaderstate *State, ctx context.Context, add, mustSelect []module.Version) (changed bool, err error) { + rs, changed, err := editRequirements(loaderstate, ctx, LoadModFile(loaderstate, ctx), add, mustSelect) + if err != nil { + return false, err + } + loaderstate.requirements = rs + return changed, nil +} + +func overrideRoots(loaderstate *State, ctx context.Context, rs *Requirements, replace []module.Version) *Requirements { + drop := make(map[string]bool) + for _, m := range replace { + drop[m.Path] = true + } + var roots []module.Version + for _, m := range rs.rootModules { + if !drop[m.Path] { + roots = append(roots, m) + } + } + roots = append(roots, replace...) + gover.ModSort(roots) + return newRequirements(loaderstate, rs.pruning, roots, rs.direct) +} + +// A ConstraintError describes inconsistent constraints in EditBuildList +type ConstraintError struct { + // Conflict lists the source of the conflict for each version in mustSelect + // that could not be selected due to the requirements of some other version in + // mustSelect. + Conflicts []Conflict +} + +func (e *ConstraintError) Error() string { + b := new(strings.Builder) + b.WriteString("version constraints conflict:") + for _, c := range e.Conflicts { + fmt.Fprintf(b, "\n\t%s", c.Summary()) + } + return b.String() +} + +// A Conflict is a path of requirements starting at a root or proposed root in +// the requirement graph, explaining why that root either causes a module passed +// in the mustSelect list to EditBuildList to be unattainable, or introduces an +// unresolvable error in loading the requirement graph. +type Conflict struct { + // Path is a path of requirements starting at some module version passed in + // the mustSelect argument and ending at a module whose requirements make that + // version unacceptable. (Path always has len ≥ 1.) + Path []module.Version + + // If Err is nil, Constraint is a module version passed in the mustSelect + // argument that has the same module path as, and a lower version than, + // the last element of the Path slice. + Constraint module.Version + + // If Constraint is unset, Err is an error encountered when loading the + // requirements of the last element in Path. + Err error +} + +// UnwrapModuleError returns c.Err, but unwraps it if it is a module.ModuleError +// with a version and path matching the last entry in the Path slice. +func (c Conflict) UnwrapModuleError() error { + me, ok := c.Err.(*module.ModuleError) + if ok && len(c.Path) > 0 { + last := c.Path[len(c.Path)-1] + if me.Path == last.Path && me.Version == last.Version { + return me.Err + } + } + return c.Err +} + +// Summary returns a string that describes only the first and last modules in +// the conflict path. +func (c Conflict) Summary() string { + if len(c.Path) == 0 { + return "(internal error: invalid Conflict struct)" + } + first := c.Path[0] + last := c.Path[len(c.Path)-1] + if len(c.Path) == 1 { + if c.Err != nil { + return fmt.Sprintf("%s: %v", first, c.UnwrapModuleError()) + } + return fmt.Sprintf("%s is above %s", first, c.Constraint.Version) + } + + adverb := "" + if len(c.Path) > 2 { + adverb = "indirectly " + } + if c.Err != nil { + return fmt.Sprintf("%s %srequires %s: %v", first, adverb, last, c.UnwrapModuleError()) + } + return fmt.Sprintf("%s %srequires %s, but %s is requested", first, adverb, last, c.Constraint.Version) +} + +// String returns a string that describes the full conflict path. +func (c Conflict) String() string { + if len(c.Path) == 0 { + return "(internal error: invalid Conflict struct)" + } + b := new(strings.Builder) + fmt.Fprintf(b, "%v", c.Path[0]) + if len(c.Path) == 1 { + fmt.Fprintf(b, " found") + } else { + for _, r := range c.Path[1:] { + fmt.Fprintf(b, " requires\n\t%v", r) + } + } + if c.Constraint != (module.Version{}) { + fmt.Fprintf(b, ", but %v is requested", c.Constraint.Version) + } + if c.Err != nil { + fmt.Fprintf(b, ": %v", c.UnwrapModuleError()) + } + return b.String() +} + +// tidyRoots trims the root dependencies to the minimal requirements needed to +// both retain the same versions of all packages in pkgs and satisfy the +// graph-pruning invariants (if applicable). +func tidyRoots(loaderstate *State, ctx context.Context, rs *Requirements, pkgs []*loadPkg) (*Requirements, error) { + mainModule := loaderstate.MainModules.mustGetSingleMainModule(loaderstate) + if rs.pruning == unpruned { + return tidyUnprunedRoots(loaderstate, ctx, mainModule, rs, pkgs) + } + return tidyPrunedRoots(loaderstate, ctx, mainModule, rs, pkgs) +} + +func updateRoots(loaderstate *State, ctx context.Context, direct map[string]bool, rs *Requirements, pkgs []*loadPkg, add []module.Version, rootsImported bool) (*Requirements, error) { + switch rs.pruning { + case unpruned: + return updateUnprunedRoots(loaderstate, ctx, direct, rs, add) + case pruned: + return updatePrunedRoots(loaderstate, ctx, direct, rs, pkgs, add, rootsImported) + case workspace: + return updateWorkspaceRoots(loaderstate, ctx, direct, rs, add) + default: + panic(fmt.Sprintf("unsupported pruning mode: %v", rs.pruning)) + } +} + +func updateWorkspaceRoots(loaderstate *State, ctx context.Context, direct map[string]bool, rs *Requirements, add []module.Version) (*Requirements, error) { + if len(add) != 0 { + // add should be empty in workspace mode because workspace mode implies + // -mod=readonly, which in turn implies no new requirements. The code path + // that would result in add being non-empty returns an error before it + // reaches this point: The set of modules to add comes from + // resolveMissingImports, which in turn resolves each package by calling + // queryImport. But queryImport explicitly checks for -mod=readonly, and + // return an error. + panic("add is not empty") + } + return newRequirements(loaderstate, workspace, rs.rootModules, direct), nil +} + +// tidyPrunedRoots returns a minimal set of root requirements that maintains the +// invariants of the go.mod file needed to support graph pruning for the given +// packages: +// +// 1. For each package marked with pkgInAll, the module path that provided that +// package is included as a root. +// 2. For all packages, the module that provided that package either remains +// selected at the same version or is upgraded by the dependencies of a +// root. +// +// If any module that provided a package has been upgraded above its previous +// version, the caller may need to reload and recompute the package graph. +// +// To ensure that the loading process eventually converges, the caller should +// add any needed roots from the tidy root set (without removing existing untidy +// roots) until the set of roots has converged. +func tidyPrunedRoots(loaderstate *State, ctx context.Context, mainModule module.Version, old *Requirements, pkgs []*loadPkg) (*Requirements, error) { + var ( + roots []module.Version + pathIsRoot = map[string]bool{mainModule.Path: true} + ) + if v, ok := old.rootSelected(loaderstate, "go"); ok { + roots = append(roots, module.Version{Path: "go", Version: v}) + pathIsRoot["go"] = true + } + if v, ok := old.rootSelected(loaderstate, "toolchain"); ok { + roots = append(roots, module.Version{Path: "toolchain", Version: v}) + pathIsRoot["toolchain"] = true + } + // We start by adding roots for every package in "all". + // + // Once that is done, we may still need to add more roots to cover upgraded or + // otherwise-missing test dependencies for packages in "all". For those test + // dependencies, we prefer to add roots for packages with shorter import + // stacks first, on the theory that the module requirements for those will + // tend to fill in the requirements for their transitive imports (which have + // deeper import stacks). So we add the missing dependencies for one depth at + // a time, starting with the packages actually in "all" and expanding outwards + // until we have scanned every package that was loaded. + var ( + queue []*loadPkg + queued = map[*loadPkg]bool{} + ) + for _, pkg := range pkgs { + if !pkg.flags.has(pkgInAll) { + continue + } + if pkg.fromExternalModule(loaderstate) && !pathIsRoot[pkg.mod.Path] { + roots = append(roots, pkg.mod) + pathIsRoot[pkg.mod.Path] = true + } + queue = append(queue, pkg) + queued[pkg] = true + } + gover.ModSort(roots) + tidy := newRequirements(loaderstate, pruned, roots, old.direct) + + for len(queue) > 0 { + roots = tidy.rootModules + mg, err := tidy.Graph(loaderstate, ctx) + if err != nil { + return nil, err + } + + prevQueue := queue + queue = nil + for _, pkg := range prevQueue { + m := pkg.mod + if m.Path == "" { + continue + } + for _, dep := range pkg.imports { + if !queued[dep] { + queue = append(queue, dep) + queued[dep] = true + } + } + if pkg.test != nil && !queued[pkg.test] { + queue = append(queue, pkg.test) + queued[pkg.test] = true + } + + if !pathIsRoot[m.Path] { + if s := mg.Selected(m.Path); gover.ModCompare(m.Path, s, m.Version) < 0 { + roots = append(roots, m) + pathIsRoot[m.Path] = true + } + } + } + + if len(roots) > len(tidy.rootModules) { + gover.ModSort(roots) + tidy = newRequirements(loaderstate, pruned, roots, tidy.direct) + } + } + + roots = tidy.rootModules + _, err := tidy.Graph(loaderstate, ctx) + if err != nil { + return nil, err + } + + // We try to avoid adding explicit requirements for test-only dependencies of + // packages in external modules. However, if we drop the explicit + // requirements, that may change an import from unambiguous (due to lazy + // module loading) to ambiguous (because lazy module loading no longer + // disambiguates it). For any package that has become ambiguous, we try + // to fix it by promoting its module to an explicit root. + // (See https://go.dev/issue/60313.) + q := par.NewQueue(runtime.GOMAXPROCS(0)) + for { + var disambiguateRoot sync.Map + for _, pkg := range pkgs { + if pkg.mod.Path == "" || pathIsRoot[pkg.mod.Path] { + // Lazy module loading will cause pkg.mod to be checked before any other modules + // that are only indirectly required. It is as unambiguous as possible. + continue + } + pkg := pkg + q.Add(func() { + skipModFile := true + _, _, _, _, err := importFromModules(loaderstate, ctx, pkg.path, tidy, nil, skipModFile) + if _, ok := errors.AsType[*AmbiguousImportError](err); ok { + disambiguateRoot.Store(pkg.mod, true) + } + }) + } + <-q.Idle() + + disambiguateRoot.Range(func(k, _ any) bool { + m := k.(module.Version) + roots = append(roots, m) + pathIsRoot[m.Path] = true + return true + }) + + if len(roots) > len(tidy.rootModules) { + module.Sort(roots) + tidy = newRequirements(loaderstate, pruned, roots, tidy.direct) + _, err = tidy.Graph(loaderstate, ctx) + if err != nil { + return nil, err + } + // Adding these roots may have pulled additional modules into the module + // graph, causing additional packages to become ambiguous. Keep iterating + // until we reach a fixed point. + continue + } + + break + } + + return tidy, nil +} + +// updatePrunedRoots returns a set of root requirements that maintains the +// invariants of the go.mod file needed to support graph pruning: +// +// 1. The selected version of the module providing each package marked with +// either pkgInAll or pkgIsRoot is included as a root. +// Note that certain root patterns (such as '...') may explode the root set +// to contain every module that provides any package imported (or merely +// required) by any other module. +// 2. Each root appears only once, at the selected version of its path +// (if rs.graph is non-nil) or at the highest version otherwise present as a +// root (otherwise). +// 3. Every module path that appears as a root in rs remains a root. +// 4. Every version in add is selected at its given version unless upgraded by +// (the dependencies of) an existing root or another module in add. +// +// The packages in pkgs are assumed to have been loaded from either the roots of +// rs or the modules selected in the graph of rs. +// +// The above invariants together imply the graph-pruning invariants for the +// go.mod file: +// +// 1. (The import invariant.) Every module that provides a package transitively +// imported by any package or test in the main module is included as a root. +// This follows by induction from (1) and (3) above. Transitively-imported +// packages loaded during this invocation are marked with pkgInAll (1), +// and by hypothesis any transitively-imported packages loaded in previous +// invocations were already roots in rs (3). +// +// 2. (The argument invariant.) Every module that provides a package matching +// an explicit package pattern is included as a root. This follows directly +// from (1): packages matching explicit package patterns are marked with +// pkgIsRoot. +// +// 3. (The completeness invariant.) Every module that contributed any package +// to the build is required by either the main module or one of the modules +// it requires explicitly. This invariant is left up to the caller, who must +// not load packages from outside the module graph but may add roots to the +// graph, but is facilitated by (3). If the caller adds roots to the graph in +// order to resolve missing packages, then updatePrunedRoots will retain them, +// the selected versions of those roots cannot regress, and they will +// eventually be written back to the main module's go.mod file. +// +// (See https://golang.org/design/36460-lazy-module-loading#invariants for more +// detail.) +func updatePrunedRoots(loaderstate *State, ctx context.Context, direct map[string]bool, rs *Requirements, pkgs []*loadPkg, add []module.Version, rootsImported bool) (*Requirements, error) { + roots := rs.rootModules + rootsUpgraded := false + + spotCheckRoot := map[module.Version]bool{} + + // “The selected version of the module providing each package marked with + // either pkgInAll or pkgIsRoot is included as a root.” + needSort := false + for _, pkg := range pkgs { + if !pkg.fromExternalModule(loaderstate) { + // pkg was not loaded from a module dependency, so we don't need + // to do anything special to maintain that dependency. + continue + } + + switch { + case pkg.flags.has(pkgInAll): + // pkg is transitively imported by a package or test in the main module. + // We need to promote the module that maintains it to a root: if some + // other module depends on the main module, and that other module also + // uses a pruned module graph, it will expect to find all of our + // transitive dependencies by reading just our go.mod file, not the go.mod + // files of everything we depend on. + // + // (This is the “import invariant” that makes graph pruning possible.) + + case rootsImported && pkg.flags.has(pkgFromRoot): + // pkg is a transitive dependency of some root, and we are treating the + // roots as if they are imported by the main module (as in 'go get'). + + case pkg.flags.has(pkgIsRoot): + // pkg is a root of the package-import graph. (Generally this means that + // it matches a command-line argument.) We want future invocations of the + // 'go' command — such as 'go test' on the same package — to continue to + // use the same versions of its dependencies that we are using right now. + // So we need to bring this package's dependencies inside the pruned + // module graph. + // + // Making the module containing this package a root of the module graph + // does exactly that: if the module containing the package supports graph + // pruning then it should satisfy the import invariant itself, so all of + // its dependencies should be in its go.mod file, and if the module + // containing the package does not support pruning then if we make it a + // root we will load all of its (unpruned) transitive dependencies into + // the module graph. + // + // (This is the “argument invariant”, and is important for + // reproducibility.) + + default: + // pkg is a dependency of some other package outside of the main module. + // As far as we know it's not relevant to the main module (and thus not + // relevant to consumers of the main module either), and its dependencies + // should already be in the module graph — included in the dependencies of + // the package that imported it. + continue + } + + if _, ok := rs.rootSelected(loaderstate, pkg.mod.Path); ok { + // It is possible that the main module's go.mod file is incomplete or + // otherwise erroneous — for example, perhaps the author forgot to 'git + // add' their updated go.mod file after adding a new package import, or + // perhaps they made an edit to the go.mod file using a third-party tool + // ('git merge'?) that doesn't maintain consistency for module + // dependencies. If that happens, ideally we want to detect the missing + // requirements and fix them up here. + // + // However, we also need to be careful not to be too aggressive. For + // transitive dependencies of external tests, the go.mod file for the + // module containing the test itself is expected to provide all of the + // relevant dependencies, and we explicitly don't want to pull in + // requirements on *irrelevant* requirements that happen to occur in the + // go.mod files for these transitive-test-only dependencies. (See the test + // in mod_lazy_test_horizon.txt for a concrete example). + // + // The “goldilocks zone” seems to be to spot-check exactly the same + // modules that we promote to explicit roots: namely, those that provide + // packages transitively imported by the main module, and those that + // provide roots of the package-import graph. That will catch erroneous + // edits to the main module's go.mod file and inconsistent requirements in + // dependencies that provide imported packages, but will ignore erroneous + // or misleading requirements in dependencies that aren't obviously + // relevant to the packages in the main module. + spotCheckRoot[pkg.mod] = true + } else { + roots = append(roots, pkg.mod) + rootsUpgraded = true + // The roots slice was initially sorted because rs.rootModules was sorted, + // but the root we just added could be out of order. + needSort = true + } + } + + for _, m := range add { + if v, ok := rs.rootSelected(loaderstate, m.Path); !ok || gover.ModCompare(m.Path, v, m.Version) < 0 { + roots = append(roots, m) + rootsUpgraded = true + needSort = true + } + } + if needSort { + gover.ModSort(roots) + } + + // "Each root appears only once, at the selected version of its path ….” + for { + var mg *ModuleGraph + if rootsUpgraded { + // We've added or upgraded one or more roots, so load the full module + // graph so that we can update those roots to be consistent with other + // requirements. + if mustHaveCompleteRequirements(loaderstate) { + // Our changes to the roots may have moved dependencies into or out of + // the graph-pruning horizon, which could in turn change the selected + // versions of other modules. (For pruned modules adding or removing an + // explicit root is a semantic change, not just a cosmetic one.) + return rs, errGoModDirty + } + + rs = newRequirements(loaderstate, pruned, roots, direct) + var err error + mg, err = rs.Graph(loaderstate, ctx) + if err != nil { + return rs, err + } + } else { + // Since none of the roots have been upgraded, we have no reason to + // suspect that they are inconsistent with the requirements of any other + // roots. Only look at the full module graph if we've already loaded it; + // otherwise, just spot-check the explicit requirements of the roots from + // which we loaded packages. + if rs.graph.Load() != nil { + // We've already loaded the full module graph, which includes the + // requirements of all of the root modules — even the transitive + // requirements, if they are unpruned! + mg, _ = rs.Graph(loaderstate, ctx) + } else if cfg.BuildMod == "vendor" { + // We can't spot-check the requirements of other modules because we + // don't in general have their go.mod files available in the vendor + // directory. (Fortunately this case is impossible, because mg.graph is + // always non-nil in vendor mode!) + panic("internal error: rs.graph is unexpectedly nil with -mod=vendor") + } else if !spotCheckRoots(loaderstate, ctx, rs, spotCheckRoot) { + // We spot-checked the explicit requirements of the roots that are + // relevant to the packages we've loaded. Unfortunately, they're + // inconsistent in some way; we need to load the full module graph + // so that we can fix the roots properly. + var err error + mg, err = rs.Graph(loaderstate, ctx) + if err != nil { + return rs, err + } + } + } + + roots = make([]module.Version, 0, len(rs.rootModules)) + rootsUpgraded = false + inRootPaths := make(map[string]bool, len(rs.rootModules)+1) + for _, mm := range loaderstate.MainModules.Versions() { + inRootPaths[mm.Path] = true + } + for _, m := range rs.rootModules { + if inRootPaths[m.Path] { + // This root specifies a redundant path. We already retained the + // selected version of this path when we saw it before, so omit the + // redundant copy regardless of its version. + // + // When we read the full module graph, we include the dependencies of + // every root even if that root is redundant. That better preserves + // reproducibility if, say, some automated tool adds a redundant + // 'require' line and then runs 'go mod tidy' to try to make everything + // consistent, since the requirements of the older version are carried + // over. + // + // So omitting a root that was previously present may *reduce* the + // selected versions of non-roots, but merely removing a requirement + // cannot *increase* the selected versions of other roots as a result — + // we don't need to mark this change as an upgrade. (This particular + // change cannot invalidate any other roots.) + continue + } + + var v string + if mg == nil { + v, _ = rs.rootSelected(loaderstate, m.Path) + } else { + v = mg.Selected(m.Path) + } + roots = append(roots, module.Version{Path: m.Path, Version: v}) + inRootPaths[m.Path] = true + if v != m.Version { + rootsUpgraded = true + } + } + // Note that rs.rootModules was already sorted by module path and version, + // and we appended to the roots slice in the same order and guaranteed that + // each path has only one version, so roots is also sorted by module path + // and (trivially) version. + + if !rootsUpgraded { + if cfg.BuildMod != "mod" { + // The only changes to the root set (if any) were to remove duplicates. + // The requirements are consistent (if perhaps redundant), so keep the + // original rs to preserve its ModuleGraph. + return rs, nil + } + // The root set has converged: every root going into this iteration was + // already at its selected version, although we have removed other + // (redundant) roots for the same path. + break + } + } + + if rs.pruning == pruned && slices.Equal(roots, rs.rootModules) && maps.Equal(direct, rs.direct) { + // The root set is unchanged and rs was already pruned, so keep rs to + // preserve its cached ModuleGraph (if any). + return rs, nil + } + return newRequirements(loaderstate, pruned, roots, direct), nil +} + +// spotCheckRoots reports whether the versions of the roots in rs satisfy the +// explicit requirements of the modules in mods. +func spotCheckRoots(loaderstate *State, ctx context.Context, rs *Requirements, mods map[module.Version]bool) bool { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + work := par.NewQueue(runtime.GOMAXPROCS(0)) + for m := range mods { + m := m + work.Add(func() { + if ctx.Err() != nil { + return + } + + summary, err := goModSummary(loaderstate, m) + if err != nil { + cancel() + return + } + + for _, r := range summary.require { + if v, ok := rs.rootSelected(loaderstate, r.Path); ok && gover.ModCompare(r.Path, v, r.Version) < 0 { + cancel() + return + } + } + }) + } + <-work.Idle() + + if ctx.Err() != nil { + // Either we failed a spot-check, or the caller no longer cares about our + // answer anyway. + return false + } + + return true +} + +// tidyUnprunedRoots returns a minimal set of root requirements that maintains +// the selected version of every module that provided or lexically could have +// provided a package in pkgs, and includes the selected version of every such +// module in direct as a root. +func tidyUnprunedRoots(loaderstate *State, ctx context.Context, mainModule module.Version, old *Requirements, pkgs []*loadPkg) (*Requirements, error) { + var ( + // keep is a set of modules that provide packages or are needed to + // disambiguate imports. + keep []module.Version + keptPath = map[string]bool{} + + // rootPaths is a list of module paths that provide packages directly + // imported from the main module. They should be included as roots. + rootPaths []string + inRootPaths = map[string]bool{} + + // altMods is a set of paths of modules that lexically could have provided + // imported packages. It may be okay to remove these from the list of + // explicit requirements if that removes them from the module graph. If they + // are present in the module graph reachable from rootPaths, they must not + // be at a lower version. That could cause a missing sum error or a new + // import ambiguity. + // + // For example, suppose a developer rewrites imports from example.com/m to + // example.com/m/v2, then runs 'go mod tidy'. Tidy may delete the + // requirement on example.com/m if there is no other transitive requirement + // on it. However, if example.com/m were downgraded to a version not in + // go.sum, when package example.com/m/v2/p is loaded, we'd get an error + // trying to disambiguate the import, since we can't check example.com/m + // without its sum. See #47738. + altMods = map[string]string{} + ) + if v, ok := old.rootSelected(loaderstate, "go"); ok { + keep = append(keep, module.Version{Path: "go", Version: v}) + keptPath["go"] = true + } + if v, ok := old.rootSelected(loaderstate, "toolchain"); ok { + keep = append(keep, module.Version{Path: "toolchain", Version: v}) + keptPath["toolchain"] = true + } + for _, pkg := range pkgs { + if !pkg.fromExternalModule(loaderstate) { + continue + } + if m := pkg.mod; !keptPath[m.Path] { + keep = append(keep, m) + keptPath[m.Path] = true + if old.direct[m.Path] && !inRootPaths[m.Path] { + rootPaths = append(rootPaths, m.Path) + inRootPaths[m.Path] = true + } + } + for _, m := range pkg.altMods { + altMods[m.Path] = m.Version + } + } + + // Construct a build list with a minimal set of roots. + // This may remove or downgrade modules in altMods. + reqs := &mvsReqs{loaderstate: loaderstate, roots: keep} + min, err := mvs.Req(mainModule, rootPaths, reqs) + if err != nil { + return nil, err + } + buildList, err := mvs.BuildList([]module.Version{mainModule}, reqs) + if err != nil { + return nil, err + } + + // Check if modules in altMods were downgraded but not removed. + // If so, add them to roots, which will retain an "// indirect" requirement + // in go.mod. See comment on altMods above. + keptAltMod := false + for _, m := range buildList { + if v, ok := altMods[m.Path]; ok && gover.ModCompare(m.Path, m.Version, v) < 0 { + keep = append(keep, module.Version{Path: m.Path, Version: v}) + keptAltMod = true + } + } + if keptAltMod { + // We must run mvs.Req again instead of simply adding altMods to min. + // It's possible that a requirement in altMods makes some other + // explicit indirect requirement unnecessary. + reqs.roots = keep + min, err = mvs.Req(mainModule, rootPaths, reqs) + if err != nil { + return nil, err + } + } + + return newRequirements(loaderstate, unpruned, min, old.direct), nil +} + +// updateUnprunedRoots returns a set of root requirements that includes the selected +// version of every module path in direct as a root, and maintains the selected +// version of every module selected in the graph of rs. +// +// The roots are updated such that: +// +// 1. The selected version of every module path in direct is included as a root +// (if it is not "none"). +// 2. Each root is the selected version of its path. (We say that such a root +// set is “consistent”.) +// 3. Every version selected in the graph of rs remains selected unless upgraded +// by a dependency in add. +// 4. Every version in add is selected at its given version unless upgraded by +// (the dependencies of) an existing root or another module in add. +func updateUnprunedRoots(loaderstate *State, ctx context.Context, direct map[string]bool, rs *Requirements, add []module.Version) (*Requirements, error) { + mg, err := rs.Graph(loaderstate, ctx) + if err != nil { + // We can't ignore errors in the module graph even if the user passed the -e + // flag to try to push past them. If we can't load the complete module + // dependencies, then we can't reliably compute a minimal subset of them. + return rs, err + } + + if mustHaveCompleteRequirements(loaderstate) { + // Instead of actually updating the requirements, just check that no updates + // are needed. + if rs == nil { + // We're being asked to reconstruct the requirements from scratch, + // but we aren't even allowed to modify them. + return rs, errGoModDirty + } + for _, m := range rs.rootModules { + if m.Version != mg.Selected(m.Path) { + // The root version v is misleading: the actual selected version is higher. + return rs, errGoModDirty + } + } + for _, m := range add { + if m.Version != mg.Selected(m.Path) { + return rs, errGoModDirty + } + } + for mPath := range direct { + if _, ok := rs.rootSelected(loaderstate, mPath); !ok { + // Module m is supposed to be listed explicitly, but isn't. + // + // Note that this condition is also detected (and logged with more + // detail) earlier during package loading, so it shouldn't actually be + // possible at this point — this is just a defense in depth. + return rs, errGoModDirty + } + } + + // No explicit roots are missing and all roots are already at the versions + // we want to keep. Any other changes we would make are purely cosmetic, + // such as pruning redundant indirect dependencies. Per issue #34822, we + // ignore cosmetic changes when we cannot update the go.mod file. + return rs, nil + } + + var ( + rootPaths []string // module paths that should be included as roots + inRootPaths = map[string]bool{} + ) + for _, root := range rs.rootModules { + // If the selected version of the root is the same as what was already + // listed in the go.mod file, retain it as a root (even if redundant) to + // avoid unnecessary churn. (See https://golang.org/issue/34822.) + // + // We do this even for indirect requirements, since we don't know why they + // were added and they could become direct at any time. + if !inRootPaths[root.Path] && mg.Selected(root.Path) == root.Version { + rootPaths = append(rootPaths, root.Path) + inRootPaths[root.Path] = true + } + } + + // “The selected version of every module path in direct is included as a root.” + // + // This is only for convenience and clarity for end users: in an unpruned module, + // the choice of explicit vs. implicit dependency has no impact on MVS + // selection (for itself or any other module). + keep := append(mg.BuildList()[loaderstate.MainModules.Len():], add...) + for _, m := range keep { + if direct[m.Path] && !inRootPaths[m.Path] { + rootPaths = append(rootPaths, m.Path) + inRootPaths[m.Path] = true + } + } + + var roots []module.Version + for _, mainModule := range loaderstate.MainModules.Versions() { + min, err := mvs.Req(mainModule, rootPaths, &mvsReqs{loaderstate: loaderstate, roots: keep}) + if err != nil { + return rs, err + } + roots = append(roots, min...) + } + if loaderstate.MainModules.Len() > 1 { + gover.ModSort(roots) + } + if rs.pruning == unpruned && slices.Equal(roots, rs.rootModules) && maps.Equal(direct, rs.direct) { + // The root set is unchanged and rs was already unpruned, so keep rs to + // preserve its cached ModuleGraph (if any). + return rs, nil + } + + return newRequirements(loaderstate, unpruned, roots, direct), nil +} + +// convertPruning returns a version of rs with the given pruning behavior. +// If rs already has the given pruning, convertPruning returns rs unmodified. +func convertPruning(loaderstate *State, ctx context.Context, rs *Requirements, pruning modPruning) (*Requirements, error) { + if rs.pruning == pruning { + return rs, nil + } else if rs.pruning == workspace || pruning == workspace { + panic("attempting to convert to/from workspace pruning and another pruning type") + } + + if pruning == unpruned { + // We are converting a pruned module to an unpruned one. The roots of a + // pruned module graph are a superset of the roots of an unpruned one, so + // we don't need to add any new roots — we just need to drop the ones that + // are redundant, which is exactly what updateUnprunedRoots does. + return updateUnprunedRoots(loaderstate, ctx, rs.direct, rs, nil) + } + + // We are converting an unpruned module to a pruned one. + // + // An unpruned module graph includes the transitive dependencies of every + // module in the build list. As it turns out, we can express that as a pruned + // root set! “Include the transitive dependencies of every module in the build + // list” is exactly what happens in a pruned module if we promote every module + // in the build list to a root. + mg, err := rs.Graph(loaderstate, ctx) + if err != nil { + return rs, err + } + return newRequirements(loaderstate, pruned, mg.BuildList()[loaderstate.MainModules.Len():], rs.direct), nil +} diff --git a/go/src/cmd/go/internal/modload/edit.go b/go/src/cmd/go/internal/modload/edit.go new file mode 100644 index 0000000000000000000000000000000000000000..8038a77b0b35d8be6f3ddb18a85e79e6fcf4c548 --- /dev/null +++ b/go/src/cmd/go/internal/modload/edit.go @@ -0,0 +1,864 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "context" + "errors" + "fmt" + "maps" + "os" + "slices" + + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/mvs" + "cmd/internal/par" + + "golang.org/x/mod/module" +) + +// editRequirements returns an edited version of rs such that: +// +// 1. Each module version in mustSelect is selected. +// +// 2. Each module version in tryUpgrade is upgraded toward the indicated +// version as far as can be done without violating (1). +// (Other upgrades are also allowed if they are caused by +// transitive requirements of versions in mustSelect or +// tryUpgrade.) +// +// 3. Each module version in rs.rootModules (or rs.graph, if rs is unpruned) +// is downgraded or upgraded from its original version only to the extent +// needed to satisfy (1) and (2). +// +// Generally, the module versions in mustSelect are due to the module or a +// package within the module matching an explicit command line argument to 'go +// get', and the versions in tryUpgrade are transitive dependencies that are +// either being upgraded by 'go get -u' or being added to satisfy some +// otherwise-missing package import. +// +// If pruning is enabled, the roots of the edited requirements include an +// explicit entry for each module path in tryUpgrade, mustSelect, and the roots +// of rs, unless the selected version for the module path is "none". +func editRequirements(loaderstate *State, ctx context.Context, rs *Requirements, tryUpgrade, mustSelect []module.Version) (edited *Requirements, changed bool, err error) { + if rs.pruning == workspace { + panic("editRequirements cannot edit workspace requirements") + } + + orig := rs + // If we already know what go version we will end up on after the edit, and + // the pruning for that version is different, go ahead and apply it now. + // + // If we are changing from pruned to unpruned, then we MUST check the unpruned + // graph for conflicts from the start. (Checking only for pruned conflicts + // would miss some that would be introduced later.) + // + // If we are changing from unpruned to pruned, then we would like to avoid + // unnecessary downgrades due to conflicts that would be pruned out of the + // final graph anyway. + // + // Note that even if we don't find a go version in mustSelect, it is possible + // that we will switch from unpruned to pruned (but not the other way around!) + // after applying the edits if we find a dependency that requires a high + // enough go version to trigger an upgrade. + rootPruning := orig.pruning + for _, m := range mustSelect { + if m.Path == "go" { + rootPruning = pruningForGoVersion(m.Version) + break + } else if m.Path == "toolchain" && pruningForGoVersion(gover.FromToolchain(m.Version)) == unpruned { + // We don't know exactly what go version we will end up at, but we know + // that it must be a version supported by the requested toolchain, and + // that toolchain does not support pruning. + // + // TODO(bcmills): 'go get' ought to reject explicit toolchain versions + // older than gover.GoStrictVersion. Once that is fixed, is this still + // needed? + rootPruning = unpruned + break + } + } + + if rootPruning != rs.pruning { + rs, err = convertPruning(loaderstate, ctx, rs, rootPruning) + if err != nil { + return orig, false, err + } + } + + // selectedRoot records the edited version (possibly "none") for each module + // path that would be a root in the edited requirements. + var selectedRoot map[string]string // module path → edited version + if rootPruning == pruned { + selectedRoot = maps.Clone(rs.maxRootVersion) + } else { + // In a module without graph pruning, modules that provide packages imported + // by the main module may either be explicit roots or implicit transitive + // dependencies. To the extent possible, we want to preserve those implicit + // dependencies, so we need to treat everything in the build list as + // potentially relevant — that is, as what would be a “root” in a module + // with graph pruning enabled. + mg, err := rs.Graph(loaderstate, ctx) + if err != nil { + // If we couldn't load the graph, we don't know what its requirements were + // to begin with, so we can't edit those requirements in a coherent way. + return orig, false, err + } + bl := mg.BuildList()[loaderstate.MainModules.Len():] + selectedRoot = make(map[string]string, len(bl)) + for _, m := range bl { + selectedRoot[m.Path] = m.Version + } + } + + for _, r := range tryUpgrade { + if v, ok := selectedRoot[r.Path]; ok && gover.ModCompare(r.Path, v, r.Version) >= 0 { + continue + } + if cfg.BuildV { + fmt.Fprintf(os.Stderr, "go: trying upgrade to %v\n", r) + } + selectedRoot[r.Path] = r.Version + } + + // conflicts is a list of conflicts that we cannot resolve without violating + // some version in mustSelect. It may be incomplete, but we want to report + // as many conflicts as we can so that the user can solve more of them at once. + var conflicts []Conflict + + // mustSelectVersion is an index of the versions in mustSelect. + mustSelectVersion := make(map[string]string, len(mustSelect)) + for _, r := range mustSelect { + if v, ok := mustSelectVersion[r.Path]; ok && v != r.Version { + prev := module.Version{Path: r.Path, Version: v} + if gover.ModCompare(r.Path, v, r.Version) > 0 { + conflicts = append(conflicts, Conflict{Path: []module.Version{prev}, Constraint: r}) + } else { + conflicts = append(conflicts, Conflict{Path: []module.Version{r}, Constraint: prev}) + } + continue + } + + mustSelectVersion[r.Path] = r.Version + selectedRoot[r.Path] = r.Version + } + + // We've indexed all of the data we need and we've computed the initial + // versions of the roots. Now we need to load the actual module graph and + // restore the invariant that every root is the selected version of its path. + // + // For 'go mod tidy' we would do that using expandGraph, which upgrades the + // roots until their requirements are internally consistent and then drops out + // the old roots. However, here we need to do more: we also need to make sure + // the modules in mustSelect don't get upgraded above their intended versions. + // To do that, we repeatedly walk the module graph, identify paths of + // requirements that result in versions that are too high, and downgrade the + // roots that lead to those paths. When no conflicts remain, we're done. + // + // Since we want to report accurate paths to each conflict, we don't drop out + // older-than-selected roots until the process completes. That might mean that + // we do some extra downgrades when they could be skipped, but for the benefit + // of being able to explain the reason for every downgrade that seems + // worthwhile. + // + // Graph pruning adds an extra wrinkle: a given node in the module graph + // may be reached from a root whose dependencies are pruned, and from a root + // whose dependencies are not pruned. It may be the case that the path from + // the unpruned root leads to a conflict, while the path from the pruned root + // prunes out the requirements that would lead to that conflict. + // So we need to track the two kinds of paths independently. + // They join back together at the roots of the graph: if a root r1 with pruned + // requirements depends on a root r2 with unpruned requirements, then + // selecting r1 would cause r2 to become a root and pull in all of its + // unpruned dependencies. + // + // The dqTracker type implements the logic for propagating conflict paths + // through the pruned and unpruned parts of the module graph. + // + // We make a best effort to fix incompatibilities, subject to two properties: + // + // 1. If the user runs 'go get' with a set of mutually-compatible module + // versions, we should accept those versions. + // + // 2. If we end up upgrading or downgrading a module, it should be + // clear why we did so. + // + // We don't try to find an optimal SAT solution, + // especially given the complex interactions with graph pruning. + + var ( + roots []module.Version // the current versions in selectedRoot, in sorted order + rootsDirty = true // true if roots does not match selectedRoot + ) + + // rejectedRoot records the set of module versions that have been disqualified + // as roots of the module graph. When downgrading due to a conflict or error, + // we skip any version that has already been rejected. + // + // NOTE(bcmills): I am not sure that the rejectedRoot map is really necessary, + // since we normally only downgrade roots or accept indirect upgrades to + // known-good versions. However, I am having trouble proving that accepting an + // indirect upgrade never introduces a conflict that leads to further + // downgrades. I really want to be able to prove that editRequirements + // terminates, and the easiest way to prove it is to add this map. + // + // Then the proof of termination is this: + // On every iteration where we mark the roots as dirty, we add some new module + // version to the map. The universe of module versions is finite, so we must + // eventually reach a state in which we do not add any version to the map. + // In that state, we either report a conflict or succeed in the edit. + rejectedRoot := map[module.Version]bool{} + + for rootsDirty && len(conflicts) == 0 { + roots = roots[:0] + for p, v := range selectedRoot { + if v != "none" { + roots = append(roots, module.Version{Path: p, Version: v}) + } + } + gover.ModSort(roots) + + // First, we extend the graph so that it includes the selected version + // of every root. The upgraded roots are in addition to the original + // roots, so we will have enough information to trace a path to each + // conflict we discover from one or more of the original roots. + mg, upgradedRoots, err := extendGraph(loaderstate, ctx, rootPruning, roots, selectedRoot) + if err != nil { + if mg == nil { + return orig, false, err + } + if _, ok := errors.AsType[*gover.TooNewError](err); ok { + return orig, false, err + } + // We're about to walk the entire extended module graph, so we will find + // any error then — and we will either try to resolve it by downgrading + // something or report it as a conflict with more detail. + } + + // extendedRootPruning is an index of the pruning used to load each root in + // the extended module graph. + extendedRootPruning := make(map[module.Version]modPruning, len(roots)+len(upgradedRoots)) + findPruning := func(m module.Version) modPruning { + if rootPruning == pruned { + summary, _ := mg.loadCache.Get(m) + if summary != nil && summary.pruning == unpruned { + return unpruned + } + } + return rootPruning + } + for _, m := range roots { + extendedRootPruning[m] = findPruning(m) + } + for m := range upgradedRoots { + extendedRootPruning[m] = findPruning(m) + } + + // Now check the resulting extended graph for errors and incompatibilities. + t := dqTracker{extendedRootPruning: extendedRootPruning} + mg.g.WalkBreadthFirst(func(m module.Version) { + if max, ok := mustSelectVersion[m.Path]; ok && gover.ModCompare(m.Path, m.Version, max) > 0 { + // m itself violates mustSelect, so it cannot appear in the module graph + // even if its transitive dependencies would be pruned out. + t.disqualify(m, pruned, dqState{dep: m}) + return + } + + summary, err := mg.loadCache.Get(m) + if err != nil && err != par.ErrCacheEntryNotFound { + // We can't determine the requirements of m, so we don't know whether + // they would be allowed. This may be a transient error reaching the + // repository, rather than a permanent error with the retrieved version. + // + // TODO(golang.org/issue/31730, golang.org/issue/30134): + // decide what to do based on the actual error. + t.disqualify(m, pruned, dqState{err: err}) + return + } + + reqs, ok := mg.RequiredBy(m) + if !ok { + // The dependencies of m do not appear in the module graph, so they + // can't be causing any problems this time. + return + } + + if summary == nil { + if m.Version != "" { + panic(fmt.Sprintf("internal error: %d reqs present for %v, but summary is nil", len(reqs), m)) + } + // m is the main module: we are editing its dependencies, so it cannot + // become disqualified. + return + } + + // Before we check for problems due to transitive dependencies, first + // check m's direct requirements. A requirement on a version r that + // violates mustSelect disqualifies m, even if the requirements of r are + // themselves pruned out. + for _, r := range reqs { + if max, ok := mustSelectVersion[r.Path]; ok && gover.ModCompare(r.Path, r.Version, max) > 0 { + t.disqualify(m, pruned, dqState{dep: r}) + return + } + } + for _, r := range reqs { + if !t.require(m, r) { + break + } + } + }) + + // We have now marked all of the versions in the graph that have conflicts, + // with a path to each conflict from one or more roots that introduce it. + // Now we need to identify those roots and change their versions + // (if possible) in order to resolve the conflicts. + rootsDirty = false + for _, m := range roots { + path, err := t.path(m, extendedRootPruning[m]) + if len(path) == 0 && err == nil { + continue // Nothing wrong with m; we can keep it. + } + + // path leads to a module with a problem: either it violates a constraint, + // or some error prevents us from determining whether it violates a + // constraint. We might end up logging or returning the conflict + // information, so go ahead and fill in the details about it. + conflict := Conflict{ + Path: path, + Err: err, + } + if err == nil { + var last module.Version = path[len(path)-1] + mustV, ok := mustSelectVersion[last.Path] + if !ok { + fmt.Fprintf(os.Stderr, "go: %v\n", conflict) + panic("internal error: found a version conflict, but no constraint it violates") + } + conflict.Constraint = module.Version{ + Path: last.Path, + Version: mustV, + } + } + + if v, ok := mustSelectVersion[m.Path]; ok && v == m.Version { + // m is in mustSelect, but is marked as disqualified due to a transitive + // dependency. + // + // In theory we could try removing module paths that don't appear in + // mustSelect (added by tryUpgrade or already present in rs) in order to + // get graph pruning to take effect, but (a) it is likely that 'go mod + // tidy' would re-add those roots and reintroduce unwanted upgrades, + // causing confusion, and (b) deciding which roots to try to eliminate + // would add a lot of complexity. + // + // Instead, we report the path to the conflict as an error. + // If users want to explicitly prune out nodes from the dependency + // graph, they can always add an explicit 'exclude' directive. + conflicts = append(conflicts, conflict) + continue + } + + // If m is not the selected version of its path, we have two options: we + // can either upgrade to the version that actually is selected (dropping m + // itself out of the bottom of the module graph), or we can try + // downgrading it. + // + // If the version we would be upgrading to is ok to use, we will just plan + // to do that and avoid the overhead of trying to find some lower version + // to downgrade to. + // + // However, it is possible that m depends on something that leads to its + // own upgrade, so if the upgrade isn't viable we should go ahead and try + // to downgrade (like with any other root). + if v := mg.Selected(m.Path); v != m.Version { + u := module.Version{Path: m.Path, Version: v} + uPruning, ok := t.extendedRootPruning[m] + if !ok { + fmt.Fprintf(os.Stderr, "go: %v\n", conflict) + panic(fmt.Sprintf("internal error: selected version of root %v is %v, but it was not expanded as a new root", m, u)) + } + if !t.check(u, uPruning).isDisqualified() && !rejectedRoot[u] { + // Applying the upgrade from m to u will resolve the conflict, + // so plan to do that if there are no other conflicts to resolve. + continue + } + } + + // Figure out what version of m's path was present before we started + // the edit. We want to make sure we consider keeping it as-is, + // even if it wouldn't normally be included. (For example, it might + // be a pseudo-version or pre-release.) + origMG, _ := orig.Graph(loaderstate, ctx) + origV := origMG.Selected(m.Path) + + if conflict.Err != nil && origV == m.Version { + // This version of m.Path was already in the module graph before we + // started editing, and the problem with it is that we can't load its + // (transitive) requirements. + // + // If this conflict was just one step in a longer chain of downgrades, + // then we would want to keep going past it until we find a version + // that doesn't have that problem. However, we only want to downgrade + // away from an *existing* requirement if we can confirm that it actually + // conflicts with mustSelect. (For example, we don't want + // 'go get -u ./...' to incidentally downgrade some dependency whose + // go.mod file is unavailable or has a bad checksum.) + conflicts = append(conflicts, conflict) + continue + } + + // We need to downgrade m's path to some lower version to try to resolve + // the conflict. Find the next-lowest candidate and apply it. + rejectedRoot[m] = true + prev := m + for { + prev, err = previousVersion(loaderstate, ctx, prev) + if gover.ModCompare(m.Path, m.Version, origV) > 0 && (gover.ModCompare(m.Path, prev.Version, origV) < 0 || err != nil) { + // previousVersion skipped over origV. Insert it into the order. + prev.Version = origV + } else if err != nil { + // We don't know the next downgrade to try. Give up. + return orig, false, err + } + if rejectedRoot[prev] { + // We already rejected prev in a previous round. + // To ensure that this algorithm terminates, don't try it again. + continue + } + pruning := rootPruning + if pruning == pruned { + if summary, err := mg.loadCache.Get(m); err == nil { + pruning = summary.pruning + } + } + if t.check(prev, pruning).isDisqualified() { + // We found a problem with prev this round that would also disqualify + // it as a root. Don't bother trying it next round. + rejectedRoot[prev] = true + continue + } + break + } + selectedRoot[m.Path] = prev.Version + rootsDirty = true + + // If this downgrade is potentially interesting, log the reason for it. + if conflict.Err != nil || cfg.BuildV { + var action string + if prev.Version == "none" { + action = fmt.Sprintf("removing %s", m) + } else if prev.Version == origV { + action = fmt.Sprintf("restoring %s", prev) + } else { + action = fmt.Sprintf("trying %s", prev) + } + fmt.Fprintf(os.Stderr, "go: %s\n\t%s\n", conflict.Summary(), action) + } + } + if rootsDirty { + continue + } + + // We didn't resolve any issues by downgrading, but we may still need to + // resolve some conflicts by locking in upgrades. Do that now. + // + // We don't do these upgrades until we're done downgrading because the + // downgrade process might reveal or remove conflicts (by changing which + // requirement edges are pruned out). + var upgradedFrom []module.Version // for logging only + for p, v := range selectedRoot { + if _, ok := mustSelectVersion[p]; !ok { + if actual := mg.Selected(p); actual != v { + if cfg.BuildV { + upgradedFrom = append(upgradedFrom, module.Version{Path: p, Version: v}) + } + selectedRoot[p] = actual + // Accepting the upgrade to m.Path might cause the selected versions + // of other modules to fall, because they were being increased by + // dependencies of m that are no longer present in the graph. + // + // TODO(bcmills): Can removing m as a root also cause the selected + // versions of other modules to rise? I think not: we're strictly + // removing non-root nodes from the module graph, which can't cause + // any root to decrease (because they're roots), and the dependencies + // of non-roots don't matter because they're either always unpruned or + // always pruned out. + // + // At any rate, it shouldn't cost much to reload the module graph one + // last time and confirm that it is stable. + rootsDirty = true + } + } + } + if rootsDirty { + if cfg.BuildV { + gover.ModSort(upgradedFrom) // Make logging deterministic. + for _, m := range upgradedFrom { + fmt.Fprintf(os.Stderr, "go: accepting indirect upgrade from %v to %s\n", m, selectedRoot[m.Path]) + } + } + continue + } + break + } + if len(conflicts) > 0 { + return orig, false, &ConstraintError{Conflicts: conflicts} + } + + if rootPruning == unpruned { + // An unpruned go.mod file lists only a subset of the requirements needed + // for building packages. Figure out which requirements need to be explicit. + var rootPaths []string + + // The modules in mustSelect are always promoted to be explicit. + for _, m := range mustSelect { + if m.Version != "none" && !loaderstate.MainModules.Contains(m.Path) { + rootPaths = append(rootPaths, m.Path) + } + } + + for _, m := range roots { + if v, ok := rs.rootSelected(loaderstate, m.Path); ok && (v == m.Version || rs.direct[m.Path]) { + // m.Path was formerly a root, and either its version hasn't changed or + // we believe that it provides a package directly imported by a package + // or test in the main module. For now we'll assume that it is still + // relevant enough to remain a root. If we actually load all of the + // packages and tests in the main module (which we are not doing here), + // we can revise the explicit roots at that point. + rootPaths = append(rootPaths, m.Path) + } + } + + roots, err = mvs.Req(loaderstate.MainModules.mustGetSingleMainModule(loaderstate), rootPaths, &mvsReqs{loaderstate: loaderstate, roots: roots}) + if err != nil { + return nil, false, err + } + } + + changed = rootPruning != orig.pruning || !slices.Equal(roots, orig.rootModules) + if !changed { + // Because the roots we just computed are unchanged, the entire graph must + // be the same as it was before. Save the original rs, since we have + // probably already loaded its requirement graph. + return orig, false, nil + } + + // A module that is not even in the build list necessarily cannot provide + // any imported packages. Mark as direct only the direct modules that are + // still in the build list. (We assume that any module path that provided a + // direct import before the edit continues to do so after. There are a few + // edge cases where that can change, such as if a package moves into or out of + // a nested module or disappears entirely. If that happens, the user can run + // 'go mod tidy' to clean up the direct/indirect annotations.) + // + // TODO(bcmills): Would it make more sense to leave the direct map as-is + // but allow it to refer to modules that are no longer in the build list? + // That might complicate updateRoots, but it may be cleaner in other ways. + direct := make(map[string]bool, len(rs.direct)) + for _, m := range roots { + if rs.direct[m.Path] { + direct[m.Path] = true + } + } + edited = newRequirements(loaderstate, rootPruning, roots, direct) + + // If we ended up adding a dependency that upgrades our go version far enough + // to activate pruning, we must convert the edited Requirements in order to + // avoid dropping transitive dependencies from the build list the next time + // someone uses the updated go.mod file. + // + // Note that it isn't possible to go in the other direction (from pruned to + // unpruned) unless the "go" or "toolchain" module is explicitly listed in + // mustSelect, which we already handled at the very beginning of the edit. + // That is because the virtual "go" module only requires a "toolchain", + // and the "toolchain" module never requires anything else, which means that + // those two modules will never be downgraded due to a conflict with any other + // constraint. + if rootPruning == unpruned { + if v, ok := edited.rootSelected(loaderstate, "go"); ok && pruningForGoVersion(v) == pruned { + // Since we computed the edit with the unpruned graph, and the pruned + // graph is a strict subset of the unpruned graph, this conversion + // preserves the exact (edited) build list that we already computed. + // + // However, it does that by shoving the whole build list into the roots of + // the graph. 'go get' will check for that sort of transition and log a + // message reminding the user how to clean up this mess we're about to + // make. 😅 + edited, err = convertPruning(loaderstate, ctx, edited, pruned) + if err != nil { + return orig, false, err + } + } + } + return edited, true, nil +} + +// extendGraph loads the module graph from roots, and iteratively extends it by +// unpruning the selected version of each module path that is a root in rs or in +// the roots slice until the graph reaches a fixed point. +// +// The graph is guaranteed to converge to a fixed point because unpruning a +// module version can only increase (never decrease) the selected versions, +// and the set of versions for each module is finite. +// +// The extended graph is useful for diagnosing version conflicts: for each +// selected module version, it can provide a complete path of requirements from +// some root to that version. +func extendGraph(loaderstate *State, ctx context.Context, rootPruning modPruning, roots []module.Version, selectedRoot map[string]string) (mg *ModuleGraph, upgradedRoot map[module.Version]bool, err error) { + for { + mg, err = readModGraph(loaderstate, ctx, rootPruning, roots, upgradedRoot) + // We keep on going even if err is non-nil until we reach a steady state. + // (Note that readModGraph returns a non-nil *ModuleGraph even in case of + // errors.) The caller may be able to fix the errors by adjusting versions, + // so we really want to return as complete a result as we can. + + if rootPruning == unpruned { + // Everything is already unpruned, so there isn't anything we can do to + // extend it further. + break + } + + nPrevRoots := len(upgradedRoot) + for p := range selectedRoot { + // Since p is a root path, when we fix up the module graph to be + // consistent with the selected versions, p will be promoted to a root, + // which will pull in its dependencies. Ensure that its dependencies are + // included in the module graph. + v := mg.g.Selected(p) + if v == "none" { + // Version “none” always has no requirements, so it doesn't need + // an explicit node in the module graph. + continue + } + m := module.Version{Path: p, Version: v} + if _, ok := mg.g.RequiredBy(m); !ok && !upgradedRoot[m] { + // The dependencies of the selected version of p were not loaded. + // Mark it as an upgrade so that we will load its dependencies + // in the next iteration. + // + // Note that we don't remove any of the existing roots, even if they are + // no longer the selected version: with graph pruning in effect this may + // leave some spurious dependencies in the graph, but it at least + // preserves enough of the graph to explain why each upgrade occurred: + // this way, we can report a complete path from the passed-in roots + // to every node in the module graph. + // + // This process is guaranteed to reach a fixed point: since we are only + // adding roots (never removing them), the selected version of each module + // can only increase, never decrease, and the set of module versions in the + // universe is finite. + if upgradedRoot == nil { + upgradedRoot = make(map[module.Version]bool) + } + upgradedRoot[m] = true + } + } + if len(upgradedRoot) == nPrevRoots { + break + } + } + + return mg, upgradedRoot, err +} + +type perPruning[T any] struct { + pruned T + unpruned T +} + +func (pp perPruning[T]) from(p modPruning) T { + if p == unpruned { + return pp.unpruned + } + return pp.pruned +} + +// A dqTracker tracks and propagates the reason that each module version +// cannot be included in the module graph. +type dqTracker struct { + // extendedRootPruning is the modPruning given the go.mod file for each root + // in the extended module graph. + extendedRootPruning map[module.Version]modPruning + + // dqReason records whether and why each encountered version is + // disqualified in a pruned or unpruned context. + dqReason map[module.Version]perPruning[dqState] + + // requiring maps each not-yet-disqualified module version to the versions + // that would cause that module's requirements to be included in a pruned or + // unpruned context. If that version becomes disqualified, the + // disqualification will be propagated to all of the versions in the + // corresponding list. + // + // This map is similar to the module requirement graph, but includes more + // detail about whether a given dependency edge appears in a pruned or + // unpruned context. (Other commands do not need this level of detail.) + requiring map[module.Version][]module.Version +} + +// A dqState indicates whether and why a module version is “disqualified” from +// being used in a way that would incorporate its requirements. +// +// The zero dqState indicates that the module version is not known to be +// disqualified, either because it is ok or because we are currently traversing +// a cycle that includes it. +type dqState struct { + err error // if non-nil, disqualified because the requirements of the module could not be read + dep module.Version // disqualified because the module is or requires dep +} + +func (dq dqState) isDisqualified() bool { + return dq != dqState{} +} + +func (dq dqState) String() string { + if dq.err != nil { + return dq.err.Error() + } + if dq.dep != (module.Version{}) { + return dq.dep.String() + } + return "(no conflict)" +} + +// require records that m directly requires r, in case r becomes disqualified. +// (These edges are in the opposite direction from the edges in an mvs.Graph.) +// +// If r is already disqualified, require propagates the disqualification to m +// and returns the reason for the disqualification. +func (t *dqTracker) require(m, r module.Version) (ok bool) { + rdq := t.dqReason[r] + rootPruning, isRoot := t.extendedRootPruning[r] + if isRoot && rdq.from(rootPruning).isDisqualified() { + // When we pull in m's dependencies, we will have an edge from m to r, and r + // is disqualified (it is a root, which causes its problematic dependencies + // to always be included). So we cannot pull in m's dependencies at all: + // m is completely disqualified. + t.disqualify(m, pruned, dqState{dep: r}) + return false + } + + if dq := rdq.from(unpruned); dq.isDisqualified() { + t.disqualify(m, unpruned, dqState{dep: r}) + if _, ok := t.extendedRootPruning[m]; !ok { + // Since m is not a root, its dependencies can't be included in the pruned + // part of the module graph, and will never be disqualified from a pruned + // reason. We've already disqualified everything that matters. + return false + } + } + + // Record that m is a dependent of r, so that if r is later disqualified + // m will be disqualified as well. + if t.requiring == nil { + t.requiring = make(map[module.Version][]module.Version) + } + t.requiring[r] = append(t.requiring[r], m) + return true +} + +// disqualify records why the dependencies of m cannot be included in the module +// graph if reached from a part of the graph with the given pruning. +// +// Since the pruned graph is a subgraph of the unpruned graph, disqualifying a +// module from a pruned part of the graph also disqualifies it in the unpruned +// parts. +func (t *dqTracker) disqualify(m module.Version, fromPruning modPruning, reason dqState) { + if !reason.isDisqualified() { + panic("internal error: disqualify called with a non-disqualifying dqState") + } + + dq := t.dqReason[m] + if dq.from(fromPruning).isDisqualified() { + return // Already disqualified for some other reason; don't overwrite it. + } + rootPruning, isRoot := t.extendedRootPruning[m] + if fromPruning == pruned { + dq.pruned = reason + if !dq.unpruned.isDisqualified() { + // Since the pruned graph of m is a subgraph of the unpruned graph, if it + // is disqualified due to something in the pruned graph, it is certainly + // disqualified in the unpruned graph from the same reason. + dq.unpruned = reason + } + } else { + dq.unpruned = reason + if dq.pruned.isDisqualified() { + panic(fmt.Sprintf("internal error: %v is marked as disqualified when pruned, but not when unpruned", m)) + } + if isRoot && rootPruning == unpruned { + // Since m is a root that is always unpruned, any other roots — even + // pruned ones! — that cause it to be selected would also cause the reason + // for is disqualification to be included in the module graph. + dq.pruned = reason + } + } + if t.dqReason == nil { + t.dqReason = make(map[module.Version]perPruning[dqState]) + } + t.dqReason[m] = dq + + if isRoot && (fromPruning == pruned || rootPruning == unpruned) { + // Either m is disqualified even when its dependencies are pruned, + // or m's go.mod file causes its dependencies to *always* be unpruned. + // Everything that depends on it must be disqualified. + for _, p := range t.requiring[m] { + t.disqualify(p, pruned, dqState{dep: m}) + // Note that since the pruned graph is a subset of the unpruned graph, + // disqualifying p in the pruned graph also disqualifies it in the + // unpruned graph. + } + // Everything in t.requiring[m] is now fully disqualified. + // We won't need to use it again. + delete(t.requiring, m) + return + } + + // Either m is not a root, or it is a pruned root but only being disqualified + // when reached from the unpruned parts of the module graph. + // Either way, the reason for this disqualification is only visible to the + // unpruned parts of the module graph. + for _, p := range t.requiring[m] { + t.disqualify(p, unpruned, dqState{dep: m}) + } + if !isRoot { + // Since m is not a root, its dependencies can't be included in the pruned + // part of the module graph, and will never be disqualified from a pruned + // reason. We've already disqualified everything that matters. + delete(t.requiring, m) + } +} + +// check reports whether m is disqualified in the given pruning context. +func (t *dqTracker) check(m module.Version, pruning modPruning) dqState { + return t.dqReason[m].from(pruning) +} + +// path returns the path from m to the reason it is disqualified, which may be +// either a module that violates constraints or an error in loading +// requirements. +// +// If m is not disqualified, path returns (nil, nil). +func (t *dqTracker) path(m module.Version, pruning modPruning) (path []module.Version, err error) { + for { + if rootPruning, isRoot := t.extendedRootPruning[m]; isRoot && rootPruning == unpruned { + // Since m is a root, any other module that requires it would cause + // its full unpruned dependencies to be included in the module graph. + // Those dependencies must also be considered as part of the path to the conflict. + pruning = unpruned + } + dq := t.dqReason[m].from(pruning) + if !dq.isDisqualified() { + return path, nil + } + path = append(path, m) + if dq.err != nil || dq.dep == m { + return path, dq.err // m itself is the conflict. + } + m = dq.dep + } +} diff --git a/go/src/cmd/go/internal/modload/help.go b/go/src/cmd/go/internal/modload/help.go new file mode 100644 index 0000000000000000000000000000000000000000..886ad62bd90cb6a64113732336d9affe117a98ef --- /dev/null +++ b/go/src/cmd/go/internal/modload/help.go @@ -0,0 +1,64 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import "cmd/go/internal/base" + +var HelpModules = &base.Command{ + UsageLine: "modules", + Short: "modules, module versions, and more", + Long: ` +Modules are how Go manages dependencies. + +A module is a collection of packages that are released, versioned, and +distributed together. Modules may be downloaded directly from version control +repositories or from module proxy servers. + +For a series of tutorials on modules, see +https://golang.org/doc/tutorial/create-module. + +For a detailed reference on modules, see https://golang.org/ref/mod. + +By default, the go command may download modules from https://proxy.golang.org. +It may authenticate modules using the checksum database at +https://sum.golang.org. Both services are operated by the Go team at Google. +The privacy policies for these services are available at +https://proxy.golang.org/privacy and https://sum.golang.org/privacy, +respectively. + +The go command's download behavior may be configured using GOPROXY, GOSUMDB, +GOPRIVATE, and other environment variables. See 'go help environment' +and https://golang.org/ref/mod#private-module-privacy for more information. + `, +} + +var HelpGoMod = &base.Command{ + UsageLine: "go.mod", + Short: "the go.mod file", + Long: ` +A module version is defined by a tree of source files, with a go.mod +file in its root. When the go command is run, it looks in the current +directory and then successive parent directories to find the go.mod +marking the root of the main (current) module. + +The go.mod file format is described in detail at +https://golang.org/ref/mod#go-mod-file. + +To create a new go.mod file, use 'go mod init'. For details see +'go help mod init' or https://golang.org/ref/mod#go-mod-init. + +To add missing module requirements or remove unneeded requirements, +use 'go mod tidy'. For details, see 'go help mod tidy' or +https://golang.org/ref/mod#go-mod-tidy. + +To add, upgrade, downgrade, or remove a specific module requirement, use +'go get'. For details, see 'go help module-get' or +https://golang.org/ref/mod#go-get. + +To make other changes or to parse go.mod as JSON for use by other tools, +use 'go mod edit'. See 'go help mod edit' or +https://golang.org/ref/mod#go-mod-edit. + `, +} diff --git a/go/src/cmd/go/internal/modload/import.go b/go/src/cmd/go/internal/modload/import.go new file mode 100644 index 0000000000000000000000000000000000000000..04e95b7a8d928380ff4730bb0c0dabe7a8acd0c6 --- /dev/null +++ b/go/src/cmd/go/internal/modload/import.go @@ -0,0 +1,840 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "context" + "errors" + "fmt" + "go/build" + "io/fs" + "os" + pathpkg "path" + "path/filepath" + "sort" + "strings" + + "cmd/go/internal/cfg" + "cmd/go/internal/fsys" + "cmd/go/internal/gover" + "cmd/go/internal/modfetch" + "cmd/go/internal/modindex" + "cmd/go/internal/search" + "cmd/go/internal/str" + "cmd/internal/par" + + "golang.org/x/mod/module" +) + +type ImportMissingError struct { + Path string + Module module.Version + QueryErr error + modContainingCWD module.Version + allowMissingModuleImports bool + + // modRoot is dependent on the value of ImportingMainModule and should be + // kept in sync. + modRoot string + ImportingMainModule module.Version + + // isStd indicates whether we would expect to find the package in the standard + // library. This is normally true for all dotless import paths, but replace + // directives can cause us to treat the replaced paths as also being in + // modules. + isStd bool + + // importerGoVersion is the version the module containing the import error + // specified. It is only set when isStd is true. + importerGoVersion string + + // replaced the highest replaced version of the module where the replacement + // contains the package. replaced is only set if the replacement is unused. + replaced module.Version + + // newMissingVersion is set to a newer version of Module if one is present + // in the build list. When set, we can't automatically upgrade. + newMissingVersion string +} + +func (e *ImportMissingError) Error() string { + if e.Module.Path == "" { + if e.isStd { + msg := fmt.Sprintf("package %s is not in std (%s)", e.Path, filepath.Join(cfg.GOROOT, "src", e.Path)) + if e.importerGoVersion != "" { + msg += fmt.Sprintf("\nnote: imported by a module that requires go %s", e.importerGoVersion) + } + return msg + } + if e.QueryErr != nil && !errors.Is(e.QueryErr, ErrNoModRoot) { + return fmt.Sprintf("cannot find module providing package %s: %v", e.Path, e.QueryErr) + } + if cfg.BuildMod == "mod" || (cfg.BuildMod == "readonly" && e.allowMissingModuleImports) { + return "cannot find module providing package " + e.Path + } + + if e.replaced.Path != "" { + suggestArg := e.replaced.Path + if !module.IsZeroPseudoVersion(e.replaced.Version) { + suggestArg = e.replaced.String() + } + return fmt.Sprintf("module %s provides package %s and is replaced but not required; to add it:\n\tgo get %s", e.replaced.Path, e.Path, suggestArg) + } + + message := fmt.Sprintf("no required module provides package %s", e.Path) + if e.QueryErr != nil { + return fmt.Sprintf("%s: %v", message, e.QueryErr) + } + if e.ImportingMainModule.Path != "" && e.ImportingMainModule != e.modContainingCWD { + return fmt.Sprintf("%s; to add it:\n\tcd %s\n\tgo get %s", message, e.modRoot, e.Path) + } + return fmt.Sprintf("%s; to add it:\n\tgo get %s", message, e.Path) + } + + if e.newMissingVersion != "" { + return fmt.Sprintf("package %s provided by %s at latest version %s but not at required version %s", e.Path, e.Module.Path, e.Module.Version, e.newMissingVersion) + } + + return fmt.Sprintf("missing module for import: %s@%s provides %s", e.Module.Path, e.Module.Version, e.Path) +} + +func (e *ImportMissingError) Unwrap() error { + return e.QueryErr +} + +func (e *ImportMissingError) ImportPath() string { + return e.Path +} + +// An AmbiguousImportError indicates an import of a package found in multiple +// modules in the build list, or found in both the main module and its vendor +// directory. +type AmbiguousImportError struct { + importPath string + Dirs []string + Modules []module.Version // Either empty or 1:1 with Dirs. +} + +func (e *AmbiguousImportError) ImportPath() string { + return e.importPath +} + +func (e *AmbiguousImportError) Error() string { + locType := "modules" + if len(e.Modules) == 0 { + locType = "directories" + } + + var buf strings.Builder + fmt.Fprintf(&buf, "ambiguous import: found package %s in multiple %s:", e.importPath, locType) + + for i, dir := range e.Dirs { + buf.WriteString("\n\t") + if i < len(e.Modules) { + m := e.Modules[i] + buf.WriteString(m.Path) + if m.Version != "" { + fmt.Fprintf(&buf, " %s", m.Version) + } + fmt.Fprintf(&buf, " (%s)", dir) + } else { + buf.WriteString(dir) + } + } + + return buf.String() +} + +// A DirectImportFromImplicitDependencyError indicates a package directly +// imported by a package or test in the main module that is satisfied by a +// dependency that is not explicit in the main module's go.mod file. +type DirectImportFromImplicitDependencyError struct { + ImporterPath string + ImportedPath string + Module module.Version +} + +func (e *DirectImportFromImplicitDependencyError) Error() string { + return fmt.Sprintf("package %s imports %s from implicitly required module; to add missing requirements, run:\n\tgo get %s@%s", e.ImporterPath, e.ImportedPath, e.Module.Path, e.Module.Version) +} + +func (e *DirectImportFromImplicitDependencyError) ImportPath() string { + return e.ImporterPath +} + +// ImportMissingSumError is reported in readonly mode when we need to check +// if a module contains a package, but we don't have a sum for its .zip file. +// We might need sums for multiple modules to verify the package is unique. +// +// TODO(#43653): consolidate multiple errors of this type into a single error +// that suggests a 'go get' command for root packages that transitively import +// packages from modules with missing sums. load.CheckPackageErrors would be +// a good place to consolidate errors, but we'll need to attach the import +// stack here. +type ImportMissingSumError struct { + importPath string + found bool + mods []module.Version + importer, importerVersion string // optional, but used for additional context + importerIsTest bool +} + +func (e *ImportMissingSumError) Error() string { + var importParen string + if e.importer != "" { + importParen = fmt.Sprintf(" (imported by %s)", e.importer) + } + var message string + if e.found { + message = fmt.Sprintf("missing go.sum entry needed to verify package %s%s is provided by exactly one module", e.importPath, importParen) + } else { + message = fmt.Sprintf("missing go.sum entry for module providing package %s%s", e.importPath, importParen) + } + var hint string + if e.importer == "" { + // Importing package is unknown, or the missing package was named on the + // command line. Recommend 'go mod download' for the modules that could + // provide the package, since that shouldn't change go.mod. + if len(e.mods) > 0 { + args := make([]string, len(e.mods)) + for i, mod := range e.mods { + args[i] = mod.Path + } + hint = fmt.Sprintf("; to add:\n\tgo mod download %s", strings.Join(args, " ")) + } + } else { + // Importing package is known (common case). Recommend 'go get' on the + // current version of the importing package. + tFlag := "" + if e.importerIsTest { + tFlag = " -t" + } + version := "" + if e.importerVersion != "" { + version = "@" + e.importerVersion + } + hint = fmt.Sprintf("; to add:\n\tgo get%s %s%s", tFlag, e.importer, version) + } + return message + hint +} + +func (e *ImportMissingSumError) ImportPath() string { + return e.importPath +} + +type invalidImportError struct { + importPath string + err error +} + +func (e *invalidImportError) ImportPath() string { + return e.importPath +} + +func (e *invalidImportError) Error() string { + return e.err.Error() +} + +func (e *invalidImportError) Unwrap() error { + return e.err +} + +// importFromModules finds the module and directory in the dependency graph of +// rs containing the package with the given import path. If mg is nil, +// importFromModules attempts to locate the module using only the main module +// and the roots of rs before it loads the full graph. +// +// The answer must be unique: importFromModules returns an error if multiple +// modules are observed to provide the same package. +// +// importFromModules can return a module with an empty m.Path, for packages in +// the standard library. +// +// importFromModules can return an empty directory string, for fake packages +// like "C" and "unsafe". +// +// If the package is not present in any module selected from the requirement +// graph, importFromModules returns an *ImportMissingError. +// +// If the package is present in exactly one module, importFromModules will +// return the module, its root directory, and a list of other modules that +// lexically could have provided the package but did not. +// +// If skipModFile is true, the go.mod file for the package is not loaded. This +// allows 'go mod tidy' to preserve a minor checksum-preservation bug +// (https://go.dev/issue/56222) for modules with 'go' versions between 1.17 and +// 1.20, preventing unnecessary go.sum churn and network access in those +// modules. +func importFromModules(loaderstate *State, ctx context.Context, path string, rs *Requirements, mg *ModuleGraph, skipModFile bool) (m module.Version, modroot, dir string, altMods []module.Version, err error) { + invalidf := func(format string, args ...any) (module.Version, string, string, []module.Version, error) { + return module.Version{}, "", "", nil, &invalidImportError{ + importPath: path, + err: fmt.Errorf(format, args...), + } + } + + if strings.Contains(path, "@") { + return invalidf("import path %q should not have @version", path) + } + if build.IsLocalImport(path) { + return invalidf("%q is relative, but relative import paths are not supported in module mode", path) + } + if filepath.IsAbs(path) { + return invalidf("%q is not a package path; see 'go help packages'", path) + } + if search.IsMetaPackage(path) { + return invalidf("%q is not an importable package; see 'go help packages'", path) + } + + if path == "C" { + // There's no directory for import "C". + return module.Version{}, "", "", nil, nil + } + // Before any further lookup, check that the path is valid. + if err := module.CheckImportPath(path); err != nil { + return module.Version{}, "", "", nil, &invalidImportError{importPath: path, err: err} + } + + // Check each module on the build list. + var dirs, roots []string + var mods []module.Version + + // Is the package in the standard library? + pathIsStd := search.IsStandardImportPath(path) + if pathIsStd && modindex.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, path) { + for _, mainModule := range loaderstate.MainModules.Versions() { + if loaderstate.MainModules.InGorootSrc(mainModule) { + if dir, ok, err := dirInModule(path, loaderstate.MainModules.PathPrefix(mainModule), loaderstate.MainModules.ModRoot(mainModule), true); err != nil { + return module.Version{}, loaderstate.MainModules.ModRoot(mainModule), dir, nil, err + } else if ok { + return mainModule, loaderstate.MainModules.ModRoot(mainModule), dir, nil, nil + } + } + } + dir := filepath.Join(cfg.GOROOTsrc, path) + modroot = cfg.GOROOTsrc + if str.HasPathPrefix(path, "cmd") { + modroot = filepath.Join(cfg.GOROOTsrc, "cmd") + } + dirs = append(dirs, dir) + roots = append(roots, modroot) + mods = append(mods, module.Version{}) + } + // -mod=vendor is special. + // Everything must be in the main modules or the main module's or workspace's vendor directory. + if cfg.BuildMod == "vendor" { + var mainErr error + for _, mainModule := range loaderstate.MainModules.Versions() { + modRoot := loaderstate.MainModules.ModRoot(mainModule) + if modRoot != "" { + dir, mainOK, err := dirInModule(path, loaderstate.MainModules.PathPrefix(mainModule), modRoot, true) + if mainErr == nil { + mainErr = err + } + if mainOK { + mods = append(mods, mainModule) + dirs = append(dirs, dir) + roots = append(roots, modRoot) + } + } + } + + if loaderstate.HasModRoot() { + vendorDir := VendorDir(loaderstate) + dir, inVendorDir, _ := dirInModule(path, "", vendorDir, false) + if inVendorDir { + readVendorList(vendorDir) + // If vendorPkgModule does not contain an entry for path then it's probably either because + // vendor/modules.txt does not exist or the user manually added directories to the vendor directory. + // Go 1.23 and later require vendored packages to be present in modules.txt to be imported. + _, ok := vendorPkgModule[path] + if ok || (gover.Compare(loaderstate.MainModules.GoVersion(loaderstate), gover.ExplicitModulesTxtImportVersion) < 0) { + mods = append(mods, vendorPkgModule[path]) + dirs = append(dirs, dir) + roots = append(roots, vendorDir) + } else { + subCommand := "mod" + if loaderstate.inWorkspaceMode() { + subCommand = "work" + } + fmt.Fprintf(os.Stderr, "go: ignoring package %s which exists in the vendor directory but is missing from vendor/modules.txt. To sync the vendor directory run go %s vendor.\n", path, subCommand) + } + } + } + + if len(dirs) > 1 { + return module.Version{}, "", "", nil, &AmbiguousImportError{importPath: path, Dirs: dirs} + } + + if mainErr != nil { + return module.Version{}, "", "", nil, mainErr + } + + if len(mods) == 0 { + return module.Version{}, "", "", nil, &ImportMissingError{ + Path: path, + modContainingCWD: loaderstate.MainModules.ModContainingCWD(), + allowMissingModuleImports: loaderstate.allowMissingModuleImports, + } + } + + return mods[0], roots[0], dirs[0], nil, nil + } + + // Iterate over possible modules for the path, not all selected modules. + // Iterating over selected modules would make the overall loading time + // O(M × P) for M modules providing P imported packages, whereas iterating + // over path prefixes is only O(P × k) with maximum path depth k. For + // large projects both M and P may be very large (note that M ≤ P), but k + // will tend to remain smallish (if for no other reason than filesystem + // path limitations). + // + // We perform this iteration either one or two times. If mg is initially nil, + // then we first attempt to load the package using only the main module and + // its root requirements. If that does not identify the package, or if mg is + // already non-nil, then we attempt to load the package using the full + // requirements in mg. + for { + var sumErrMods, altMods []module.Version + for prefix := path; prefix != "."; prefix = pathpkg.Dir(prefix) { + if gover.IsToolchain(prefix) { + // Do not use the synthetic "go" module for "go/ast". + continue + } + var ( + v string + ok bool + ) + if mg == nil { + v, ok = rs.rootSelected(loaderstate, prefix) + } else { + v, ok = mg.Selected(prefix), true + } + if !ok || v == "none" { + continue + } + m := module.Version{Path: prefix, Version: v} + + root, isLocal, err := fetch(loaderstate, ctx, m) + if err != nil { + if _, ok := errors.AsType[*sumMissingError](err); ok { + // We are missing a sum needed to fetch a module in the build list. + // We can't verify that the package is unique, and we may not find + // the package at all. Keep checking other modules to decide which + // error to report. Multiple sums may be missing if we need to look in + // multiple nested modules to resolve the import; we'll report them all. + sumErrMods = append(sumErrMods, m) + continue + } + // Report fetch error. + // Note that we don't know for sure this module is necessary, + // but it certainly _could_ provide the package, and even if we + // continue the loop and find the package in some other module, + // we need to look at this module to make sure the import is + // not ambiguous. + return module.Version{}, "", "", nil, err + } + if dir, ok, err := dirInModule(path, m.Path, root, isLocal); err != nil { + return module.Version{}, "", "", nil, err + } else if ok { + mods = append(mods, m) + roots = append(roots, root) + dirs = append(dirs, dir) + } else { + altMods = append(altMods, m) + } + } + + if len(mods) > 1 { + // We produce the list of directories from longest to shortest candidate + // module path, but the AmbiguousImportError should report them from + // shortest to longest. Reverse them now. + for i := 0; i < len(mods)/2; i++ { + j := len(mods) - 1 - i + mods[i], mods[j] = mods[j], mods[i] + roots[i], roots[j] = roots[j], roots[i] + dirs[i], dirs[j] = dirs[j], dirs[i] + } + return module.Version{}, "", "", nil, &AmbiguousImportError{importPath: path, Dirs: dirs, Modules: mods} + } + + if len(sumErrMods) > 0 { + for i := 0; i < len(sumErrMods)/2; i++ { + j := len(sumErrMods) - 1 - i + sumErrMods[i], sumErrMods[j] = sumErrMods[j], sumErrMods[i] + } + return module.Version{}, "", "", nil, &ImportMissingSumError{ + importPath: path, + mods: sumErrMods, + found: len(mods) > 0, + } + } + + if len(mods) == 1 { + // We've found the unique module containing the package. + // However, in order to actually compile it we need to know what + // Go language version to use, which requires its go.mod file. + // + // If the module graph is pruned and this is a test-only dependency + // of a package in "all", we didn't necessarily load that file + // when we read the module graph, so do it now to be sure. + if !skipModFile && cfg.BuildMod != "vendor" && mods[0].Path != "" && !loaderstate.MainModules.Contains(mods[0].Path) { + if _, err := goModSummary(loaderstate, mods[0]); err != nil { + return module.Version{}, "", "", nil, err + } + } + return mods[0], roots[0], dirs[0], altMods, nil + } + + if mg != nil { + // We checked the full module graph and still didn't find the + // requested package. + var queryErr error + if !loaderstate.HasModRoot() { + queryErr = NewNoMainModulesError(loaderstate) + } + return module.Version{}, "", "", nil, &ImportMissingError{ + Path: path, + QueryErr: queryErr, + isStd: pathIsStd, + modContainingCWD: loaderstate.MainModules.ModContainingCWD(), + allowMissingModuleImports: loaderstate.allowMissingModuleImports, + } + } + + // So far we've checked the root dependencies. + // Load the full module graph and try again. + mg, err = rs.Graph(loaderstate, ctx) + if err != nil { + // We might be missing one or more transitive (implicit) dependencies from + // the module graph, so we can't return an ImportMissingError here — one + // of the missing modules might actually contain the package in question, + // in which case we shouldn't go looking for it in some new dependency. + return module.Version{}, "", "", nil, err + } + } +} + +// queryImport attempts to locate a module that can be added to the current +// build list to provide the package with the given import path. +// +// Unlike QueryPattern, queryImport prefers to add a replaced version of a +// module *before* checking the proxies for a version to add. +func queryImport(loaderstate *State, ctx context.Context, path string, rs *Requirements) (module.Version, error) { + // To avoid spurious remote fetches, try the latest replacement for each + // module (golang.org/issue/26241). + var mods []module.Version + if loaderstate.MainModules != nil { // TODO(#48912): Ensure MainModules exists at this point, and remove the check. + for mp, mv := range loaderstate.MainModules.HighestReplaced() { + if !maybeInModule(path, mp) { + continue + } + if mv == "" { + // The only replacement is a wildcard that doesn't specify a version, so + // synthesize a pseudo-version with an appropriate major version and a + // timestamp below any real timestamp. That way, if the main module is + // used from within some other module, the user will be able to upgrade + // the requirement to any real version they choose. + if _, pathMajor, ok := module.SplitPathVersion(mp); ok && len(pathMajor) > 0 { + mv = module.ZeroPseudoVersion(pathMajor[1:]) + } else { + mv = module.ZeroPseudoVersion("v0") + } + } + mg, err := rs.Graph(loaderstate, ctx) + if err != nil { + return module.Version{}, err + } + if gover.ModCompare(mp, mg.Selected(mp), mv) >= 0 { + // We can't resolve the import by adding mp@mv to the module graph, + // because the selected version of mp is already at least mv. + continue + } + mods = append(mods, module.Version{Path: mp, Version: mv}) + } + } + + // Every module path in mods is a prefix of the import path. + // As in QueryPattern, prefer the longest prefix that satisfies the import. + sort.Slice(mods, func(i, j int) bool { + return len(mods[i].Path) > len(mods[j].Path) + }) + for _, m := range mods { + root, isLocal, err := fetch(loaderstate, ctx, m) + if err != nil { + if _, ok := errors.AsType[*sumMissingError](err); ok { + return module.Version{}, &ImportMissingSumError{importPath: path} + } + return module.Version{}, err + } + if _, ok, err := dirInModule(path, m.Path, root, isLocal); err != nil { + return m, err + } else if ok { + if cfg.BuildMod == "readonly" { + return module.Version{}, &ImportMissingError{ + Path: path, + replaced: m, + modContainingCWD: loaderstate.MainModules.ModContainingCWD(), + allowMissingModuleImports: loaderstate.allowMissingModuleImports, + } + } + return m, nil + } + } + if len(mods) > 0 && module.CheckPath(path) != nil { + // The package path is not valid to fetch remotely, + // so it can only exist in a replaced module, + // and we know from the above loop that it is not. + replacement := Replacement(loaderstate, mods[0]) + return module.Version{}, &PackageNotInModuleError{ + Mod: mods[0], + Query: "latest", + Pattern: path, + Replacement: replacement, + } + } + + if search.IsStandardImportPath(path) { + // This package isn't in the standard library, isn't in any module already + // in the build list, and isn't in any other module that the user has + // shimmed in via a "replace" directive. + // Moreover, the import path is reserved for the standard library, so + // QueryPattern cannot possibly find a module containing this package. + // + // Instead of trying QueryPattern, report an ImportMissingError immediately. + return module.Version{}, &ImportMissingError{ + Path: path, + isStd: true, + modContainingCWD: loaderstate.MainModules.ModContainingCWD(), + allowMissingModuleImports: loaderstate.allowMissingModuleImports, + } + } + + if (cfg.BuildMod == "readonly" || cfg.BuildMod == "vendor") && !loaderstate.allowMissingModuleImports { + // In readonly mode, we can't write go.mod, so we shouldn't try to look up + // the module. If readonly mode was enabled explicitly, include that in + // the error message. + // In vendor mode, we cannot use the network or module cache, so we + // shouldn't try to look up the module + var queryErr error + if cfg.BuildModExplicit { + queryErr = fmt.Errorf("import lookup disabled by -mod=%s", cfg.BuildMod) + } else if cfg.BuildModReason != "" { + queryErr = fmt.Errorf("import lookup disabled by -mod=%s\n\t(%s)", cfg.BuildMod, cfg.BuildModReason) + } + return module.Version{}, &ImportMissingError{ + Path: path, + QueryErr: queryErr, + modContainingCWD: loaderstate.MainModules.ModContainingCWD(), + allowMissingModuleImports: loaderstate.allowMissingModuleImports, + } + } + + // Look up module containing the package, for addition to the build list. + // Goal is to determine the module, download it to dir, + // and return m, dir, ImportMissingError. + fmt.Fprintf(os.Stderr, "go: finding module for package %s\n", path) + + mg, err := rs.Graph(loaderstate, ctx) + if err != nil { + return module.Version{}, err + } + + candidates, err := QueryPackages(loaderstate, ctx, path, "latest", mg.Selected, loaderstate.CheckAllowed) + if err != nil { + if errors.Is(err, fs.ErrNotExist) { + // Return "cannot find module providing package […]" instead of whatever + // low-level error QueryPattern produced. + return module.Version{}, &ImportMissingError{ + Path: path, + QueryErr: err, + modContainingCWD: loaderstate.MainModules.ModContainingCWD(), + allowMissingModuleImports: loaderstate.allowMissingModuleImports, + } + } else { + return module.Version{}, err + } + } + + candidate0MissingVersion := "" + for i, c := range candidates { + if v := mg.Selected(c.Mod.Path); gover.ModCompare(c.Mod.Path, v, c.Mod.Version) > 0 { + // QueryPattern proposed that we add module c.Mod to provide the package, + // but we already depend on a newer version of that module (and that + // version doesn't have the package). + // + // This typically happens when a package is present at the "@latest" + // version (e.g., v1.0.0) of a module, but we have a newer version + // of the same module in the build list (e.g., v1.0.1-beta), and + // the package is not present there. + if i == 0 { + candidate0MissingVersion = v + } + continue + } + return c.Mod, nil + } + return module.Version{}, &ImportMissingError{ + Path: path, + Module: candidates[0].Mod, + newMissingVersion: candidate0MissingVersion, + modContainingCWD: loaderstate.MainModules.ModContainingCWD(), + allowMissingModuleImports: loaderstate.allowMissingModuleImports, + } +} + +// maybeInModule reports whether, syntactically, +// a package with the given import path could be supplied +// by a module with the given module path (mpath). +func maybeInModule(path, mpath string) bool { + return mpath == path || + len(path) > len(mpath) && path[len(mpath)] == '/' && path[:len(mpath)] == mpath +} + +var ( + haveGoModCache par.Cache[string, bool] // dir → bool + haveGoFilesCache par.ErrCache[string, bool] // dir → haveGoFiles +) + +// PkgIsInLocalModule reports whether the directory of the package with +// the given pkgpath, exists in the module with the given modpath +// at the given modroot, and contains go source files. +func PkgIsInLocalModule(pkgpath, modpath, modroot string) bool { + const isLocal = true + _, haveGoFiles, err := dirInModule(pkgpath, modpath, modroot, isLocal) + return err == nil && haveGoFiles +} + +// dirInModule locates the directory that would hold the package named by the given path, +// if it were in the module with module path mpath and root mdir. +// If path is syntactically not within mpath, +// or if mdir is a local file tree (isLocal == true) and the directory +// that would hold path is in a sub-module (covered by a go.mod below mdir), +// dirInModule returns "", false, nil. +// +// Otherwise, dirInModule returns the name of the directory where +// Go source files would be expected, along with a boolean indicating +// whether there are in fact Go source files in that directory. +// A non-nil error indicates that the existence of the directory and/or +// source files could not be determined, for example due to a permission error. +// +// TODO(matloob): Could we use the modindex to check packages in indexed modules? +func dirInModule(path, mpath, mdir string, isLocal bool) (dir string, haveGoFiles bool, err error) { + // Determine where to expect the package. + if path == mpath { + dir = mdir + } else if mpath == "" { // vendor directory + dir = filepath.Join(mdir, path) + } else if len(path) > len(mpath) && path[len(mpath)] == '/' && path[:len(mpath)] == mpath { + dir = filepath.Join(mdir, path[len(mpath)+1:]) + } else { + return "", false, nil + } + + // Check that there aren't other modules in the way. + // This check is unnecessary inside the module cache + // and important to skip in the vendor directory, + // where all the module trees have been overlaid. + // So we only check local module trees + // (the main module, and any directory trees pointed at by replace directives). + if isLocal { + for d := dir; d != mdir && len(d) > len(mdir); { + haveGoMod := haveGoModCache.Do(d, func() bool { + fi, err := fsys.Stat(filepath.Join(d, "go.mod")) + return err == nil && !fi.IsDir() + }) + + if haveGoMod { + return "", false, nil + } + parent := filepath.Dir(d) + if parent == d { + // Break the loop, as otherwise we'd loop + // forever if d=="." and mdir=="". + break + } + d = parent + } + } + + // Now committed to returning dir (not ""). + + // Are there Go source files in the directory? + // We don't care about build tags, not even "go:build ignore". + // We're just looking for a plausible directory. + haveGoFiles, err = haveGoFilesCache.Do(dir, func() (bool, error) { + // modindex.GetPackage will return ErrNotIndexed for any directories which + // are reached through a symlink, so that they will be handled by + // fsys.IsGoDir below. + if ip, err := modindex.GetPackage(mdir, dir); err == nil { + return ip.IsGoDir() + } else if !errors.Is(err, modindex.ErrNotIndexed) { + return false, err + } + return fsys.IsGoDir(dir) + }) + + return dir, haveGoFiles, err +} + +// fetch downloads the given module (or its replacement) +// and returns its location. +// +// The isLocal return value reports whether the replacement, +// if any, is local to the filesystem. +func fetch(loaderstate *State, ctx context.Context, mod module.Version) (dir string, isLocal bool, err error) { + if modRoot := loaderstate.MainModules.ModRoot(mod); modRoot != "" { + return modRoot, true, nil + } + if r := Replacement(loaderstate, mod); r.Path != "" { + if r.Version == "" { + dir = r.Path + if !filepath.IsAbs(dir) { + dir = filepath.Join(replaceRelativeTo(loaderstate), dir) + } + // Ensure that the replacement directory actually exists: + // dirInModule does not report errors for missing modules, + // so if we don't report the error now, later failures will be + // very mysterious. + if _, err := fsys.Stat(dir); err != nil { + // TODO(bcmills): We should also read dir/go.mod here and check its Go version, + // and return a gover.TooNewError if appropriate. + + if os.IsNotExist(err) { + // Semantically the module version itself “exists” — we just don't + // have its source code. Remove the equivalence to os.ErrNotExist, + // and make the message more concise while we're at it. + err = fmt.Errorf("replacement directory %s does not exist", r.Path) + } else { + err = fmt.Errorf("replacement directory %s: %w", r.Path, err) + } + return dir, true, module.VersionError(mod, err) + } + return dir, true, nil + } + mod = r + } + + if mustHaveSums(loaderstate) && !modfetch.HaveSum(loaderstate.Fetcher(), mod) { + return "", false, module.VersionError(mod, &sumMissingError{}) + } + + dir, err = loaderstate.Fetcher().Download(ctx, mod) + return dir, false, err +} + +// mustHaveSums reports whether we require that all checksums +// needed to load or build packages are already present in the go.sum file. +func mustHaveSums(loaderstate *State) bool { + return loaderstate.HasModRoot() && cfg.BuildMod == "readonly" && !loaderstate.inWorkspaceMode() +} + +type sumMissingError struct { + suggestion string +} + +func (e *sumMissingError) Error() string { + return "missing go.sum entry" + e.suggestion +} diff --git a/go/src/cmd/go/internal/modload/import_test.go b/go/src/cmd/go/internal/modload/import_test.go new file mode 100644 index 0000000000000000000000000000000000000000..820fb87b5928f2992e5c603bc7a27428caf73927 --- /dev/null +++ b/go/src/cmd/go/internal/modload/import_test.go @@ -0,0 +1,92 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "context" + "internal/testenv" + "regexp" + "strings" + "testing" + + "golang.org/x/mod/module" +) + +var importTests = []struct { + path string + m module.Version + err string +}{ + { + path: "golang.org/x/net/context", + m: module.Version{ + Path: "golang.org/x/net", + }, + }, + { + path: "golang.org/x/net", + err: `module golang.org/x/net@.* found \(v[01]\.\d+\.\d+\), but does not contain package golang.org/x/net`, + }, + { + path: "golang.org/x/text", + m: module.Version{ + Path: "golang.org/x/text", + }, + }, + { + path: "github.com/rsc/quote/buggy", + m: module.Version{ + Path: "github.com/rsc/quote", + Version: "v1.5.2", + }, + }, + { + path: "github.com/rsc/quote", + m: module.Version{ + Path: "github.com/rsc/quote", + Version: "v1.5.2", + }, + }, + { + path: "golang.org/x/foo/bar", + err: "cannot find module providing package golang.org/x/foo/bar", + }, +} + +func TestQueryImport(t *testing.T) { + loaderstate := NewState() + loaderstate.RootMode = NoRoot + loaderstate.AllowMissingModuleImports() + + testenv.MustHaveExternalNetwork(t) + testenv.MustHaveExecPath(t, "git") + + ctx := context.Background() + rs := LoadModFile(loaderstate, ctx) + + for _, tt := range importTests { + t.Run(strings.ReplaceAll(tt.path, "/", "_"), func(t *testing.T) { + // Note that there is no build list, so Import should always fail. + m, err := queryImport(loaderstate, ctx, tt.path, rs) + + if tt.err == "" { + if err != nil { + t.Fatalf("queryImport(_, %q): %v", tt.path, err) + } + } else { + if err == nil { + t.Fatalf("queryImport(_, %q) = %v, nil; expected error", tt.path, m) + } + if !regexp.MustCompile(tt.err).MatchString(err.Error()) { + t.Fatalf("queryImport(_, %q): error %q, want error matching %#q", tt.path, err, tt.err) + } + } + + if m.Path != tt.m.Path || (tt.m.Version != "" && m.Version != tt.m.Version) { + t.Errorf("queryImport(_, %q) = %v, _; want %v", tt.path, m, tt.m) + } + }) + } +} diff --git a/go/src/cmd/go/internal/modload/init.go b/go/src/cmd/go/internal/modload/init.go new file mode 100644 index 0000000000000000000000000000000000000000..e3babc29c6a01ffc7a82addf8d09ba9a2dd5c243 --- /dev/null +++ b/go/src/cmd/go/internal/modload/init.go @@ -0,0 +1,2265 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "bytes" + "context" + "errors" + "fmt" + "internal/godebugs" + "internal/lazyregexp" + "io" + "maps" + "os" + "path" + "path/filepath" + "slices" + "strconv" + "strings" + "sync" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/fips140" + "cmd/go/internal/fsys" + "cmd/go/internal/gover" + "cmd/go/internal/lockedfile" + "cmd/go/internal/modfetch" + "cmd/go/internal/search" + + "golang.org/x/mod/modfile" + "golang.org/x/mod/module" +) + +// Variables set by other packages. +// +// TODO(#40775): See if these can be plumbed as explicit parameters. +var ( + // ExplicitWriteGoMod prevents LoadPackages, ListModules, and other functions + // from updating go.mod and go.sum or reporting errors when updates are + // needed. A package should set this if it would cause go.mod to be written + // multiple times (for example, 'go get' calls LoadPackages multiple times) or + // if it needs some other operation to be successful before go.mod and go.sum + // can be written (for example, 'go mod download' must download modules before + // adding sums to go.sum). Packages that set this are responsible for calling + // WriteGoMod explicitly. + ExplicitWriteGoMod bool +) + +// Variables set in Init. +var ( + gopath string +) + +// EnterModule resets MainModules and requirements to refer to just this one module. +func EnterModule(loaderstate *State, ctx context.Context, enterModroot string) { + loaderstate.MainModules = nil // reset MainModules + loaderstate.requirements = nil + loaderstate.workFilePath = "" // Force module mode + loaderstate.Fetcher().Reset() + + loaderstate.modRoots = []string{enterModroot} + LoadModFile(loaderstate, ctx) +} + +// EnterWorkspace enters workspace mode from module mode, applying the updated requirements to the main +// module to that module in the workspace. There should be no calls to any of the exported +// functions of the modload package running concurrently with a call to EnterWorkspace as +// EnterWorkspace will modify the global state they depend on in a non-thread-safe way. +func EnterWorkspace(loaderstate *State, ctx context.Context) (exit func(), err error) { + // Find the identity of the main module that will be updated before we reset modload state. + mm := loaderstate.MainModules.mustGetSingleMainModule(loaderstate) + // Get the updated modfile we will use for that module. + _, _, updatedmodfile, err := UpdateGoModFromReqs(loaderstate, ctx, WriteOpts{}) + if err != nil { + return nil, err + } + + // Reset the state to a clean state. + oldstate := loaderstate.setState(NewState()) + loaderstate.ForceUseModules = true + + // Load in workspace mode. + loaderstate.InitWorkfile() + LoadModFile(loaderstate, ctx) + + // Update the content of the previous main module, and recompute the requirements. + *loaderstate.MainModules.ModFile(mm) = *updatedmodfile + loaderstate.requirements = requirementsFromModFiles(loaderstate, ctx, loaderstate.MainModules.workFile, slices.Collect(maps.Values(loaderstate.MainModules.modFiles)), nil) + + return func() { + loaderstate.setState(oldstate) + }, nil +} + +type MainModuleSet struct { + // versions are the module.Version values of each of the main modules. + // For each of them, the Path fields are ordinary module paths and the Version + // fields are empty strings. + // versions is clipped (len=cap). + versions []module.Version + + // modRoot maps each module in versions to its absolute filesystem path. + modRoot map[module.Version]string + + // pathPrefix is the path prefix for packages in the module, without a trailing + // slash. For most modules, pathPrefix is just version.Path, but the + // standard-library module "std" has an empty prefix. + pathPrefix map[module.Version]string + + // inGorootSrc caches whether modRoot is within GOROOT/src. + // The "std" module is special within GOROOT/src, but not otherwise. + inGorootSrc map[module.Version]bool + + modFiles map[module.Version]*modfile.File + + tools map[string]bool + + modContainingCWD module.Version + + workFile *modfile.WorkFile + + workFileReplaceMap map[module.Version]module.Version + // highest replaced version of each module path; empty string for wildcard-only replacements + highestReplaced map[string]string + + indexMu sync.RWMutex + indices map[module.Version]*modFileIndex +} + +func (mms *MainModuleSet) PathPrefix(m module.Version) string { + return mms.pathPrefix[m] +} + +// Versions returns the module.Version values of each of the main modules. +// For each of them, the Path fields are ordinary module paths and the Version +// fields are empty strings. +// Callers should not modify the returned slice. +func (mms *MainModuleSet) Versions() []module.Version { + if mms == nil { + return nil + } + return mms.versions +} + +// Tools returns the tools defined by all the main modules. +// The key is the absolute package path of the tool. +func (mms *MainModuleSet) Tools() map[string]bool { + if mms == nil { + return nil + } + return mms.tools +} + +func (mms *MainModuleSet) Contains(path string) bool { + if mms == nil { + return false + } + for _, v := range mms.versions { + if v.Path == path { + return true + } + } + return false +} + +func (mms *MainModuleSet) ModRoot(m module.Version) string { + if mms == nil { + return "" + } + return mms.modRoot[m] +} + +func (mms *MainModuleSet) InGorootSrc(m module.Version) bool { + if mms == nil { + return false + } + return mms.inGorootSrc[m] +} + +func (mms *MainModuleSet) mustGetSingleMainModule(loaderstate *State) module.Version { + mm, err := mms.getSingleMainModule(loaderstate) + if err != nil { + panic(err) + } + return mm +} + +func (mms *MainModuleSet) getSingleMainModule(loaderstate *State) (module.Version, error) { + if mms == nil || len(mms.versions) == 0 { + return module.Version{}, errors.New("internal error: mustGetSingleMainModule called in context with no main modules") + } + if len(mms.versions) != 1 { + if loaderstate.inWorkspaceMode() { + return module.Version{}, errors.New("internal error: mustGetSingleMainModule called in workspace mode") + } else { + return module.Version{}, errors.New("internal error: multiple main modules present outside of workspace mode") + } + } + return mms.versions[0], nil +} + +func (mms *MainModuleSet) GetSingleIndexOrNil(loaderstate *State) *modFileIndex { + if mms == nil { + return nil + } + if len(mms.versions) == 0 { + return nil + } + return mms.indices[mms.mustGetSingleMainModule(loaderstate)] +} + +func (mms *MainModuleSet) Index(m module.Version) *modFileIndex { + mms.indexMu.RLock() + defer mms.indexMu.RUnlock() + return mms.indices[m] +} + +func (mms *MainModuleSet) SetIndex(m module.Version, index *modFileIndex) { + mms.indexMu.Lock() + defer mms.indexMu.Unlock() + mms.indices[m] = index +} + +func (mms *MainModuleSet) ModFile(m module.Version) *modfile.File { + return mms.modFiles[m] +} + +func (mms *MainModuleSet) WorkFile() *modfile.WorkFile { + return mms.workFile +} + +func (mms *MainModuleSet) Len() int { + if mms == nil { + return 0 + } + return len(mms.versions) +} + +// ModContainingCWD returns the main module containing the working directory, +// or module.Version{} if none of the main modules contain the working +// directory. +func (mms *MainModuleSet) ModContainingCWD() module.Version { + return mms.modContainingCWD +} + +func (mms *MainModuleSet) HighestReplaced() map[string]string { + return mms.highestReplaced +} + +// GoVersion returns the go version set on the single module, in module mode, +// or the go.work file in workspace mode. +func (mms *MainModuleSet) GoVersion(loaderstate *State) string { + if loaderstate.inWorkspaceMode() { + return gover.FromGoWork(mms.workFile) + } + if mms != nil && len(mms.versions) == 1 { + f := mms.ModFile(mms.mustGetSingleMainModule(loaderstate)) + if f == nil { + // Special case: we are outside a module, like 'go run x.go'. + // Assume the local Go version. + // TODO(#49228): Clean this up; see loadModFile. + return gover.Local() + } + return gover.FromGoMod(f) + } + return gover.DefaultGoModVersion +} + +// Godebugs returns the godebug lines set on the single module, in module mode, +// or on the go.work file in workspace mode. +// The caller must not modify the result. +func (mms *MainModuleSet) Godebugs(loaderstate *State) []*modfile.Godebug { + if loaderstate.inWorkspaceMode() { + if mms.workFile != nil { + return mms.workFile.Godebug + } + return nil + } + if mms != nil && len(mms.versions) == 1 { + f := mms.ModFile(mms.mustGetSingleMainModule(loaderstate)) + if f == nil { + // Special case: we are outside a module, like 'go run x.go'. + return nil + } + return f.Godebug + } + return nil +} + +func (mms *MainModuleSet) WorkFileReplaceMap() map[module.Version]module.Version { + return mms.workFileReplaceMap +} + +type Root int + +const ( + // AutoRoot is the default for most commands. modload.Init will look for + // a go.mod file in the current directory or any parent. If none is found, + // modules may be disabled (GO111MODULE=auto) or commands may run in a + // limited module mode. + AutoRoot Root = iota + + // NoRoot is used for commands that run in module mode and ignore any go.mod + // file the current directory or in parent directories. + NoRoot + + // NeedRoot is used for commands that must run in module mode and don't + // make sense without a main module. + NeedRoot +) + +// ModFile returns the parsed go.mod file. +// +// Note that after calling LoadPackages or LoadModGraph, +// the require statements in the modfile.File are no longer +// the source of truth and will be ignored: edits made directly +// will be lost at the next call to WriteGoMod. +// To make permanent changes to the require statements +// in go.mod, edit it before loading. +func ModFile(loaderstate *State) *modfile.File { + Init(loaderstate) + modFile := loaderstate.MainModules.ModFile(loaderstate.MainModules.mustGetSingleMainModule(loaderstate)) + if modFile == nil { + die(loaderstate) + } + return modFile +} + +func BinDir(loaderstate *State) string { + Init(loaderstate) + if cfg.GOBIN != "" { + return cfg.GOBIN + } + if gopath == "" { + return "" + } + return filepath.Join(gopath, "bin") +} + +// InitWorkfile initializes the workFilePath variable for commands that +// operate in workspace mode. It should not be called by other commands, +// for example 'go mod tidy', that don't operate in workspace mode. +func (loaderstate *State) InitWorkfile() { + // Initialize fsys early because we need overlay to read go.work file. + fips140.Init() + if err := fsys.Init(); err != nil { + base.Fatal(err) + } + loaderstate.workFilePath = loaderstate.FindGoWork(base.Cwd()) +} + +// FindGoWork returns the name of the go.work file for this command, +// or the empty string if there isn't one. +// Most code should use Init and Enabled rather than use this directly. +// It is exported mainly for Go toolchain switching, which must process +// the go.work very early at startup. +func (loaderstate *State) FindGoWork(wd string) string { + if loaderstate.RootMode == NoRoot { + return "" + } + + switch gowork := cfg.Getenv("GOWORK"); gowork { + case "off": + return "" + case "", "auto": + return findWorkspaceFile(wd) + default: + if !filepath.IsAbs(gowork) { + base.Fatalf("go: invalid GOWORK: not an absolute path") + } + return gowork + } +} + +// WorkFilePath returns the absolute path of the go.work file, or "" if not in +// workspace mode. WorkFilePath must be called after InitWorkfile. +func WorkFilePath(loaderstate *State) string { + return loaderstate.workFilePath +} + +// Reset clears all the initialized, cached state about the use of modules, +// so that we can start over. +func (s *State) Reset() { + s.setState(NewState()) +} + +func (s *State) setState(new *State) (old *State) { + old = &State{ + initialized: s.initialized, + ForceUseModules: s.ForceUseModules, + RootMode: s.RootMode, + modRoots: s.modRoots, + modulesEnabled: cfg.ModulesEnabled, + MainModules: s.MainModules, + requirements: s.requirements, + workFilePath: s.workFilePath, + fetcher: s.fetcher, + } + s.initialized = new.initialized + s.ForceUseModules = new.ForceUseModules + s.RootMode = new.RootMode + s.modRoots = new.modRoots + cfg.ModulesEnabled = new.modulesEnabled + s.MainModules = new.MainModules + s.requirements = new.requirements + s.workFilePath = new.workFilePath + // The modfetch package's global state is used to compute + // the go.sum file, so save and restore it along with the + // modload state. + old.fetcher = s.fetcher.SetState(new.fetcher) + + return old +} + +type State struct { + initialized bool + allowMissingModuleImports bool + + // ForceUseModules may be set to force modules to be enabled when + // GO111MODULE=auto or to report an error when GO111MODULE=off. + ForceUseModules bool + + // RootMode determines whether a module root is needed. + RootMode Root + + // These are primarily used to initialize the MainModules, and should + // be eventually superseded by them but are still used in cases where + // the module roots are required but MainModules has not been + // initialized yet. Set to the modRoots of the main modules. + // modRoots != nil implies len(modRoots) > 0 + modRoots []string + modulesEnabled bool + MainModules *MainModuleSet + + // requirements is the requirement graph for the main module. + // + // It is always non-nil if the main module's go.mod file has been + // loaded. + // + // This variable should only be read from the loadModFile + // function, and should only be written in the loadModFile and + // commitRequirements functions. All other functions that need or + // produce a *Requirements should accept and/or return an explicit + // parameter. + requirements *Requirements + + // Set to the path to the go.work file, or "" if workspace mode is + // disabled + workFilePath string + fetcher *modfetch.Fetcher +} + +func NewState() *State { + s := new(State) + s.fetcher = modfetch.NewFetcher() + return s +} + +func (s *State) Fetcher() *modfetch.Fetcher { + return s.fetcher +} + +// Init determines whether module mode is enabled, locates the root of the +// current module (if any), sets environment variables for Git subprocesses, and +// configures the cfg, codehost, load, modfetch, and search packages for use +// with modules. +func Init(loaderstate *State) { + if loaderstate.initialized { + return + } + loaderstate.initialized = true + + fips140.Init() + + // Keep in sync with WillBeEnabled. We perform extra validation here, and + // there are lots of diagnostics and side effects, so we can't use + // WillBeEnabled directly. + var mustUseModules bool + env := cfg.Getenv("GO111MODULE") + switch env { + default: + base.Fatalf("go: unknown environment setting GO111MODULE=%s", env) + case "auto": + mustUseModules = loaderstate.ForceUseModules + case "on", "": + mustUseModules = true + case "off": + if loaderstate.ForceUseModules { + base.Fatalf("go: modules disabled by GO111MODULE=off; see 'go help modules'") + } + mustUseModules = false + return + } + + if err := fsys.Init(); err != nil { + base.Fatal(err) + } + + // Disable any prompting for passwords by Git. + // Only has an effect for 2.3.0 or later, but avoiding + // the prompt in earlier versions is just too hard. + // If user has explicitly set GIT_TERMINAL_PROMPT=1, keep + // prompting. + // See golang.org/issue/9341 and golang.org/issue/12706. + if os.Getenv("GIT_TERMINAL_PROMPT") == "" { + os.Setenv("GIT_TERMINAL_PROMPT", "0") + } + + if os.Getenv("GCM_INTERACTIVE") == "" { + os.Setenv("GCM_INTERACTIVE", "never") + } + if loaderstate.modRoots != nil { + // modRoot set before Init was called ("go mod init" does this). + // No need to search for go.mod. + } else if loaderstate.RootMode == NoRoot { + if cfg.ModFile != "" && !base.InGOFLAGS("-modfile") { + base.Fatalf("go: -modfile cannot be used with commands that ignore the current module") + } + loaderstate.modRoots = nil + } else if loaderstate.workFilePath != "" { + // We're in workspace mode, which implies module mode. + if cfg.ModFile != "" { + base.Fatalf("go: -modfile cannot be used in workspace mode") + } + } else { + if modRoot := findModuleRoot(base.Cwd()); modRoot == "" { + if cfg.ModFile != "" { + base.Fatalf("go: cannot find main module, but -modfile was set.\n\t-modfile cannot be used to set the module root directory.") + } + if loaderstate.RootMode == NeedRoot { + base.Fatal(NewNoMainModulesError(loaderstate)) + } + if !mustUseModules { + // GO111MODULE is 'auto', and we can't find a module root. + // Stay in GOPATH mode. + return + } + } else if search.InDir(modRoot, os.TempDir()) == "." { + // If you create /tmp/go.mod for experimenting, + // then any tests that create work directories under /tmp + // will find it and get modules when they're not expecting them. + // It's a bit of a peculiar thing to disallow but quite mysterious + // when it happens. See golang.org/issue/26708. + fmt.Fprintf(os.Stderr, "go: warning: ignoring go.mod in system temp root %v\n", os.TempDir()) + if loaderstate.RootMode == NeedRoot { + base.Fatal(NewNoMainModulesError(loaderstate)) + } + if !mustUseModules { + return + } + } else { + loaderstate.modRoots = []string{modRoot} + } + } + if cfg.ModFile != "" && !strings.HasSuffix(cfg.ModFile, ".mod") { + base.Fatalf("go: -modfile=%s: file does not have .mod extension", cfg.ModFile) + } + + // We're in module mode. Set any global variables that need to be set. + cfg.ModulesEnabled = true + setDefaultBuildMod(loaderstate) + list := filepath.SplitList(cfg.BuildContext.GOPATH) + if len(list) > 0 && list[0] != "" { + gopath = list[0] + if _, err := fsys.Stat(filepath.Join(gopath, "go.mod")); err == nil { + fmt.Fprintf(os.Stderr, "go: warning: ignoring go.mod in $GOPATH %v\n", gopath) + if loaderstate.RootMode == NeedRoot { + base.Fatal(NewNoMainModulesError(loaderstate)) + } + if !mustUseModules { + return + } + } + } +} + +// WillBeEnabled checks whether modules should be enabled but does not +// initialize modules by installing hooks. If Init has already been called, +// WillBeEnabled returns the same result as Enabled. +// +// This function is needed to break a cycle. The main package needs to know +// whether modules are enabled in order to install the module or GOPATH version +// of 'go get', but Init reads the -modfile flag in 'go get', so it shouldn't +// be called until the command is installed and flags are parsed. Instead of +// calling Init and Enabled, the main package can call this function. +func (loaderstate *State) WillBeEnabled() bool { + if loaderstate.modRoots != nil || cfg.ModulesEnabled { + // Already enabled. + return true + } + if loaderstate.initialized { + // Initialized, not enabled. + return false + } + + // Keep in sync with Init. Init does extra validation and prints warnings or + // exits, so it can't call this function directly. + env := cfg.Getenv("GO111MODULE") + switch env { + case "on", "": + return true + case "auto": + break + default: + return false + } + + return FindGoMod(base.Cwd()) != "" +} + +// FindGoMod returns the name of the go.mod file for this command, +// or the empty string if there isn't one. +// Most code should use Init and Enabled rather than use this directly. +// It is exported mainly for Go toolchain switching, which must process +// the go.mod very early at startup. +func FindGoMod(wd string) string { + modRoot := findModuleRoot(wd) + if modRoot == "" { + // GO111MODULE is 'auto', and we can't find a module root. + // Stay in GOPATH mode. + return "" + } + if search.InDir(modRoot, os.TempDir()) == "." { + // If you create /tmp/go.mod for experimenting, + // then any tests that create work directories under /tmp + // will find it and get modules when they're not expecting them. + // It's a bit of a peculiar thing to disallow but quite mysterious + // when it happens. See golang.org/issue/26708. + return "" + } + return filepath.Join(modRoot, "go.mod") +} + +// Enabled reports whether modules are (or must be) enabled. +// If modules are enabled but there is no main module, Enabled returns true +// and then the first use of module information will call die +// (usually through MustModRoot). +func (loaderstate *State) Enabled() bool { + Init(loaderstate) + return loaderstate.modRoots != nil || cfg.ModulesEnabled +} + +func (s *State) vendorDir() (string, error) { + if s.inWorkspaceMode() { + return filepath.Join(filepath.Dir(WorkFilePath(s)), "vendor"), nil + } + mainModule, err := s.MainModules.getSingleMainModule(s) + if err != nil { + return "", err + } + // Even if -mod=vendor, we could be operating with no mod root (and thus no + // vendor directory). As long as there are no dependencies that is expected + // to work. See script/vendor_outside_module.txt. + modRoot := s.MainModules.ModRoot(mainModule) + if modRoot == "" { + return "", errors.New("vendor directory does not exist when in single module mode outside of a module") + } + return filepath.Join(modRoot, "vendor"), nil +} + +func (s *State) VendorDirOrEmpty() string { + dir, err := s.vendorDir() + if err != nil { + return "" + } + return dir +} + +func VendorDir(loaderstate *State) string { + dir, err := loaderstate.vendorDir() + if err != nil { + panic(err) + } + return dir +} + +func (loaderstate *State) inWorkspaceMode() bool { + if !loaderstate.initialized { + panic("inWorkspaceMode called before modload.Init called") + } + if !loaderstate.Enabled() { + return false + } + return loaderstate.workFilePath != "" +} + +// HasModRoot reports whether a main module or main modules are present. +// HasModRoot may return false even if Enabled returns true: for example, 'get' +// does not require a main module. +func (loaderstate *State) HasModRoot() bool { + Init(loaderstate) + return loaderstate.modRoots != nil +} + +// MustHaveModRoot checks that a main module or main modules are present, +// and calls base.Fatalf if there are no main modules. +func (loaderstate *State) MustHaveModRoot() { + Init(loaderstate) + if !loaderstate.HasModRoot() { + die(loaderstate) + } +} + +// ModFilePath returns the path that would be used for the go.mod +// file, if in module mode. ModFilePath calls base.Fatalf if there is no main +// module, even if -modfile is set. +func (loaderstate *State) ModFilePath() string { + loaderstate.MustHaveModRoot() + return modFilePath(findModuleRoot(base.Cwd())) +} + +func modFilePath(modRoot string) string { + // TODO(matloob): This seems incompatible with workspaces + // (unless the user's intention is to replace all workspace modules' modfiles?). + // Should we produce an error in workspace mode if cfg.ModFile is set? + if cfg.ModFile != "" { + return cfg.ModFile + } + return filepath.Join(modRoot, "go.mod") +} + +func die(loaderstate *State) { + if cfg.Getenv("GO111MODULE") == "off" { + base.Fatalf("go: modules disabled by GO111MODULE=off; see 'go help modules'") + } + if !loaderstate.inWorkspaceMode() { + if dir, name := findAltConfig(base.Cwd()); dir != "" { + rel, err := filepath.Rel(base.Cwd(), dir) + if err != nil { + rel = dir + } + cdCmd := "" + if rel != "." { + cdCmd = fmt.Sprintf("cd %s && ", rel) + } + base.Fatalf("go: cannot find main module, but found %s in %s\n\tto create a module there, run:\n\t%sgo mod init", name, dir, cdCmd) + } + } + base.Fatal(NewNoMainModulesError(loaderstate)) +} + +var ErrNoModRoot = errors.New("no module root") + +// noMainModulesError returns the appropriate error if there is no main module or +// main modules depending on whether the go command is in workspace mode. +type noMainModulesError struct { + inWorkspaceMode bool +} + +func (e noMainModulesError) Error() string { + if e.inWorkspaceMode { + return "no modules were found in the current workspace; see 'go help work'" + } + return "go.mod file not found in current directory or any parent directory; see 'go help modules'" +} + +func (e noMainModulesError) Unwrap() error { + return ErrNoModRoot +} + +func NewNoMainModulesError(s *State) noMainModulesError { + return noMainModulesError{ + inWorkspaceMode: s.inWorkspaceMode(), + } +} + +type goModDirtyError struct{} + +func (goModDirtyError) Error() string { + if cfg.BuildModExplicit { + return fmt.Sprintf("updates to go.mod needed, disabled by -mod=%v; to update it:\n\tgo mod tidy", cfg.BuildMod) + } + if cfg.BuildModReason != "" { + return fmt.Sprintf("updates to go.mod needed, disabled by -mod=%s\n\t(%s)\n\tto update it:\n\tgo mod tidy", cfg.BuildMod, cfg.BuildModReason) + } + return "updates to go.mod needed; to update it:\n\tgo mod tidy" +} + +var errGoModDirty error = goModDirtyError{} + +// LoadWorkFile parses and checks the go.work file at the given path, +// and returns the absolute paths of the workspace modules' modroots. +// It does not modify the global state of the modload package. +func LoadWorkFile(path string) (workFile *modfile.WorkFile, modRoots []string, err error) { + workDir := filepath.Dir(path) + wf, err := ReadWorkFile(path) + if err != nil { + return nil, nil, err + } + seen := map[string]bool{} + for _, d := range wf.Use { + modRoot := d.Path + if !filepath.IsAbs(modRoot) { + modRoot = filepath.Join(workDir, modRoot) + } + + if seen[modRoot] { + return nil, nil, fmt.Errorf("error loading go.work:\n%s:%d: path %s appears multiple times in workspace", base.ShortPath(path), d.Syntax.Start.Line, modRoot) + } + seen[modRoot] = true + modRoots = append(modRoots, modRoot) + } + + for _, g := range wf.Godebug { + if err := CheckGodebug("godebug", g.Key, g.Value); err != nil { + return nil, nil, fmt.Errorf("error loading go.work:\n%s:%d: %w", base.ShortPath(path), g.Syntax.Start.Line, err) + } + } + + return wf, modRoots, nil +} + +// ReadWorkFile reads and parses the go.work file at the given path. +func ReadWorkFile(path string) (*modfile.WorkFile, error) { + path = base.ShortPath(path) // use short path in any errors + workData, err := fsys.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("reading go.work: %w", err) + } + + f, err := modfile.ParseWork(path, workData, nil) + if err != nil { + return nil, fmt.Errorf("errors parsing go.work:\n%w", err) + } + if f.Go != nil && gover.Compare(f.Go.Version, gover.Local()) > 0 && cfg.CmdName != "work edit" { + base.Fatal(&gover.TooNewError{What: base.ShortPath(path), GoVersion: f.Go.Version}) + } + return f, nil +} + +// WriteWorkFile cleans and writes out the go.work file to the given path. +func WriteWorkFile(path string, wf *modfile.WorkFile) error { + wf.SortBlocks() + wf.Cleanup() + out := modfile.Format(wf.Syntax) + + return os.WriteFile(path, out, 0666) +} + +// UpdateWorkGoVersion updates the go line in wf to be at least goVers, +// reporting whether it changed the file. +func UpdateWorkGoVersion(wf *modfile.WorkFile, goVers string) (changed bool) { + old := gover.FromGoWork(wf) + if gover.Compare(old, goVers) >= 0 { + return false + } + + wf.AddGoStmt(goVers) + + if wf.Toolchain == nil { + return true + } + + // Drop the toolchain line if it is implied by the go line, + // if its version is older than the version in the go line, + // or if it is asking for a toolchain older than Go 1.21, + // which will not understand the toolchain line. + // Previously, a toolchain line set to the local toolchain + // version was added so that future operations on the go file + // would use the same toolchain logic for reproducibility. + // This behavior seemed to cause user confusion without much + // benefit so it was removed. See #65847. + toolchain := wf.Toolchain.Name + toolVers := gover.FromToolchain(toolchain) + if toolchain == "go"+goVers || gover.Compare(toolVers, goVers) < 0 || gover.Compare(toolVers, gover.GoStrictVersion) < 0 { + wf.DropToolchainStmt() + } + + return true +} + +// UpdateWorkFile updates comments on directory directives in the go.work +// file to include the associated module path. +func UpdateWorkFile(wf *modfile.WorkFile) { + missingModulePaths := map[string]string{} // module directory listed in file -> abspath modroot + + for _, d := range wf.Use { + if d.Path == "" { + continue // d is marked for deletion. + } + modRoot := d.Path + if d.ModulePath == "" { + missingModulePaths[d.Path] = modRoot + } + } + + // Clean up and annotate directories. + // TODO(matloob): update x/mod to actually add module paths. + for moddir, absmodroot := range missingModulePaths { + _, f, err := ReadModFile(filepath.Join(absmodroot, "go.mod"), nil) + if err != nil { + continue // Error will be reported if modules are loaded. + } + wf.AddUse(moddir, f.Module.Mod.Path) + } +} + +// LoadModFile sets Target and, if there is a main module, parses the initial +// build list from its go.mod file. +// +// LoadModFile may make changes in memory, like adding a go directive and +// ensuring requirements are consistent. The caller is responsible for ensuring +// those changes are written to disk by calling LoadPackages or ListModules +// (unless ExplicitWriteGoMod is set) or by calling WriteGoMod directly. +// +// As a side-effect, LoadModFile may change cfg.BuildMod to "vendor" if +// -mod wasn't set explicitly and automatic vendoring should be enabled. +// +// If LoadModFile or CreateModFile has already been called, LoadModFile returns +// the existing in-memory requirements (rather than re-reading them from disk). +// +// LoadModFile checks the roots of the module graph for consistency with each +// other, but unlike LoadModGraph does not load the full module graph or check +// it for global consistency. Most callers outside of the modload package should +// use LoadModGraph instead. +func LoadModFile(loaderstate *State, ctx context.Context) *Requirements { + rs, err := loadModFile(loaderstate, ctx, nil) + if err != nil { + base.Fatal(err) + } + return rs +} + +func loadModFile(loaderstate *State, ctx context.Context, opts *PackageOpts) (*Requirements, error) { + if loaderstate.requirements != nil { + return loaderstate.requirements, nil + } + + Init(loaderstate) + var workFile *modfile.WorkFile + if loaderstate.inWorkspaceMode() { + var err error + workFile, loaderstate.modRoots, err = LoadWorkFile(loaderstate.workFilePath) + if err != nil { + return nil, err + } + for _, modRoot := range loaderstate.modRoots { + sumFile := strings.TrimSuffix(modFilePath(modRoot), ".mod") + ".sum" + loaderstate.Fetcher().AddWorkspaceGoSumFile(sumFile) + } + loaderstate.Fetcher().SetGoSumFile(loaderstate.workFilePath + ".sum") + } else if len(loaderstate.modRoots) == 0 { + // We're in module mode, but not inside a module. + // + // Commands like 'go build', 'go run', 'go list' have no go.mod file to + // read or write. They would need to find and download the latest versions + // of a potentially large number of modules with no way to save version + // information. We can succeed slowly (but not reproducibly), but that's + // not usually a good experience. + // + // Instead, we forbid resolving import paths to modules other than std and + // cmd. Users may still build packages specified with .go files on the + // command line, but they'll see an error if those files import anything + // outside std. + // + // This can be overridden by calling AllowMissingModuleImports. + // For example, 'go get' does this, since it is expected to resolve paths. + // + // See golang.org/issue/32027. + } else { + loaderstate.Fetcher().SetGoSumFile(strings.TrimSuffix(modFilePath(loaderstate.modRoots[0]), ".mod") + ".sum") + } + if len(loaderstate.modRoots) == 0 { + // TODO(#49228): Instead of creating a fake module with an empty modroot, + // make MainModules.Len() == 0 mean that we're in module mode but not inside + // any module. + mainModule := module.Version{Path: "command-line-arguments"} + loaderstate.MainModules = makeMainModules(loaderstate, []module.Version{mainModule}, []string{""}, []*modfile.File{nil}, []*modFileIndex{nil}, nil) + var ( + goVersion string + pruning modPruning + roots []module.Version + direct = map[string]bool{"go": true} + ) + if loaderstate.inWorkspaceMode() { + // Since we are in a workspace, the Go version for the synthetic + // "command-line-arguments" module must not exceed the Go version + // for the workspace. + goVersion = loaderstate.MainModules.GoVersion(loaderstate) + pruning = workspace + roots = []module.Version{ + mainModule, + {Path: "go", Version: goVersion}, + {Path: "toolchain", Version: gover.LocalToolchain()}, + } + } else { + goVersion = gover.Local() + pruning = pruningForGoVersion(goVersion) + roots = []module.Version{ + {Path: "go", Version: goVersion}, + {Path: "toolchain", Version: gover.LocalToolchain()}, + } + } + rawGoVersion.Store(mainModule, goVersion) + loaderstate.requirements = newRequirements(loaderstate, pruning, roots, direct) + if cfg.BuildMod == "vendor" { + // For issue 56536: Some users may have GOFLAGS=-mod=vendor set. + // Make sure it behaves as though the fake module is vendored + // with no dependencies. + loaderstate.requirements.initVendor(loaderstate, nil) + } + return loaderstate.requirements, nil + } + + var modFiles []*modfile.File + var mainModules []module.Version + var indices []*modFileIndex + var errs []error + for _, modroot := range loaderstate.modRoots { + gomod := modFilePath(modroot) + var fixed bool + data, f, err := ReadModFile(gomod, fixVersion(loaderstate, ctx, &fixed)) + if err != nil { + if loaderstate.inWorkspaceMode() { + if tooNew, ok := err.(*gover.TooNewError); ok && !strings.HasPrefix(cfg.CmdName, "work ") { + // Switching to a newer toolchain won't help - the go.work has the wrong version. + // Report this more specific error, unless we are a command like 'go work use' + // or 'go work sync', which will fix the problem after the caller sees the TooNewError + // and switches to a newer toolchain. + err = errWorkTooOld(gomod, workFile, tooNew.GoVersion) + } else { + err = fmt.Errorf("cannot load module %s listed in go.work file: %w", + base.ShortPath(filepath.Dir(gomod)), base.ShortPathError(err)) + } + } + errs = append(errs, err) + continue + } + if loaderstate.inWorkspaceMode() && !strings.HasPrefix(cfg.CmdName, "work ") { + // Refuse to use workspace if its go version is too old. + // Disable this check if we are a workspace command like work use or work sync, + // which will fix the problem. + mv := gover.FromGoMod(f) + wv := gover.FromGoWork(workFile) + if gover.Compare(mv, wv) > 0 && gover.Compare(mv, gover.GoStrictVersion) >= 0 { + errs = append(errs, errWorkTooOld(gomod, workFile, mv)) + continue + } + } + + if !loaderstate.inWorkspaceMode() { + ok := true + for _, g := range f.Godebug { + if err := CheckGodebug("godebug", g.Key, g.Value); err != nil { + errs = append(errs, fmt.Errorf("error loading go.mod:\n%s:%d: %v", base.ShortPath(gomod), g.Syntax.Start.Line, err)) + ok = false + } + } + if !ok { + continue + } + } + + modFiles = append(modFiles, f) + mainModule := f.Module.Mod + mainModules = append(mainModules, mainModule) + indices = append(indices, indexModFile(data, f, mainModule, fixed)) + + if err := module.CheckImportPath(f.Module.Mod.Path); err != nil { + if pathErr, ok := err.(*module.InvalidPathError); ok { + pathErr.Kind = "module" + } + errs = append(errs, err) + } + } + if len(errs) > 0 { + return nil, errors.Join(errs...) + } + + loaderstate.MainModules = makeMainModules(loaderstate, mainModules, loaderstate.modRoots, modFiles, indices, workFile) + setDefaultBuildMod(loaderstate) // possibly enable automatic vendoring + rs := requirementsFromModFiles(loaderstate, ctx, workFile, modFiles, opts) + + if cfg.BuildMod == "vendor" { + readVendorList(VendorDir(loaderstate)) + versions := loaderstate.MainModules.Versions() + indexes := make([]*modFileIndex, 0, len(versions)) + modFiles := make([]*modfile.File, 0, len(versions)) + modRoots := make([]string, 0, len(versions)) + for _, m := range versions { + indexes = append(indexes, loaderstate.MainModules.Index(m)) + modFiles = append(modFiles, loaderstate.MainModules.ModFile(m)) + modRoots = append(modRoots, loaderstate.MainModules.ModRoot(m)) + } + checkVendorConsistency(loaderstate, indexes, modFiles, modRoots) + rs.initVendor(loaderstate, vendorList) + } + + if loaderstate.inWorkspaceMode() { + // We don't need to update the mod file so return early. + loaderstate.requirements = rs + return rs, nil + } + + mainModule := loaderstate.MainModules.mustGetSingleMainModule(loaderstate) + + if rs.hasRedundantRoot(loaderstate) { + // If any module path appears more than once in the roots, we know that the + // go.mod file needs to be updated even though we have not yet loaded any + // transitive dependencies. + var err error + rs, err = updateRoots(loaderstate, ctx, rs.direct, rs, nil, nil, false) + if err != nil { + return nil, err + } + } + + if loaderstate.MainModules.Index(mainModule).goVersion == "" && rs.pruning != workspace { + // TODO(#45551): Do something more principled instead of checking + // cfg.CmdName directly here. + if cfg.BuildMod == "mod" && cfg.CmdName != "mod graph" && cfg.CmdName != "mod why" { + // go line is missing from go.mod; add one there and add to derived requirements. + v := gover.Local() + if opts != nil && opts.TidyGoVersion != "" { + v = opts.TidyGoVersion + } + addGoStmt(loaderstate.MainModules.ModFile(mainModule), mainModule, v) + rs = overrideRoots(loaderstate, ctx, rs, []module.Version{{Path: "go", Version: v}}) + + // We need to add a 'go' version to the go.mod file, but we must assume + // that its existing contents match something between Go 1.11 and 1.16. + // Go 1.11 through 1.16 do not support graph pruning, but the latest Go + // version uses a pruned module graph — so we need to convert the + // requirements to support pruning. + if gover.Compare(v, gover.ExplicitIndirectVersion) >= 0 { + var err error + rs, err = convertPruning(loaderstate, ctx, rs, pruned) + if err != nil { + return nil, err + } + } + } else { + rawGoVersion.Store(mainModule, gover.DefaultGoModVersion) + } + } + + loaderstate.requirements = rs + return loaderstate.requirements, nil +} + +func errWorkTooOld(gomod string, wf *modfile.WorkFile, goVers string) error { + verb := "lists" + if wf == nil || wf.Go == nil { + // A go.work file implicitly requires go1.18 + // even when it doesn't list any version. + verb = "implicitly requires" + } + return fmt.Errorf("module %s listed in go.work file requires go >= %s, but go.work %s go %s; to update it:\n\tgo work use", + base.ShortPath(filepath.Dir(gomod)), goVers, verb, gover.FromGoWork(wf)) +} + +// CheckReservedModulePath checks whether the module path is a reserved module path +// that can't be used for a user's module. +func CheckReservedModulePath(path string) error { + if gover.IsToolchain(path) { + return errors.New("module path is reserved") + } + + return nil +} + +// CreateModFile initializes a new module by creating a go.mod file. +// +// If modPath is empty, CreateModFile will attempt to infer the path from the +// directory location within GOPATH. +// +// If a vendoring configuration file is present, CreateModFile will attempt to +// translate it to go.mod directives. The resulting build list may not be +// exactly the same as in the legacy configuration (for example, we can't get +// packages at multiple versions from the same module). +func CreateModFile(loaderstate *State, ctx context.Context, modPath string) { + modRoot := base.Cwd() + loaderstate.modRoots = []string{modRoot} + Init(loaderstate) + modFilePath := modFilePath(modRoot) + if _, err := fsys.Stat(modFilePath); err == nil { + base.Fatalf("go: %s already exists", modFilePath) + } + + if modPath == "" { + var err error + modPath, err = findModulePath(modRoot) + if err != nil { + base.Fatal(err) + } + } else if err := module.CheckImportPath(modPath); err != nil { + if pathErr, ok := err.(*module.InvalidPathError); ok { + pathErr.Kind = "module" + // Same as build.IsLocalPath() + if pathErr.Path == "." || pathErr.Path == ".." || + strings.HasPrefix(pathErr.Path, "./") || strings.HasPrefix(pathErr.Path, "../") { + pathErr.Err = errors.New("is a local import path") + } + } + base.Fatal(err) + } else if err := CheckReservedModulePath(modPath); err != nil { + base.Fatalf(`go: invalid module path %q: `, modPath) + } else if _, _, ok := module.SplitPathVersion(modPath); !ok { + if strings.HasPrefix(modPath, "gopkg.in/") { + invalidMajorVersionMsg := fmt.Errorf("module paths beginning with gopkg.in/ must always have a major version suffix in the form of .vN:\n\tgo mod init %s", suggestGopkgIn(modPath)) + base.Fatalf(`go: invalid module path "%v": %v`, modPath, invalidMajorVersionMsg) + } + invalidMajorVersionMsg := fmt.Errorf("major version suffixes must be in the form of /vN and are only allowed for v2 or later:\n\tgo mod init %s", suggestModulePath(modPath)) + base.Fatalf(`go: invalid module path "%v": %v`, modPath, invalidMajorVersionMsg) + } + + fmt.Fprintf(os.Stderr, "go: creating new go.mod: module %s\n", modPath) + modFile := new(modfile.File) + modFile.AddModuleStmt(modPath) + loaderstate.MainModules = makeMainModules(loaderstate, []module.Version{modFile.Module.Mod}, []string{modRoot}, []*modfile.File{modFile}, []*modFileIndex{nil}, nil) + addGoStmt(modFile, modFile.Module.Mod, gover.Local()) // Add the go directive before converted module requirements. + + rs := requirementsFromModFiles(loaderstate, ctx, nil, []*modfile.File{modFile}, nil) + rs, err := updateRoots(loaderstate, ctx, rs.direct, rs, nil, nil, false) + if err != nil { + base.Fatal(err) + } + loaderstate.requirements = rs + if err := commitRequirements(loaderstate, ctx, WriteOpts{}); err != nil { + base.Fatal(err) + } + + // Suggest running 'go mod tidy' unless the project is empty. Even if we + // imported all the correct requirements above, we're probably missing + // some sums, so the next build command in -mod=readonly will likely fail. + // + // We look for non-hidden .go files or subdirectories to determine whether + // this is an existing project. Walking the tree for packages would be more + // accurate, but could take much longer. + empty := true + files, _ := os.ReadDir(modRoot) + for _, f := range files { + name := f.Name() + if strings.HasPrefix(name, ".") || strings.HasPrefix(name, "_") { + continue + } + if strings.HasSuffix(name, ".go") || f.IsDir() { + empty = false + break + } + } + if !empty { + fmt.Fprintf(os.Stderr, "go: to add module requirements and sums:\n\tgo mod tidy\n") + } +} + +// fixVersion returns a modfile.VersionFixer implemented using the Query function. +// +// It resolves commit hashes and branch names to versions, +// canonicalizes versions that appeared in early vgo drafts, +// and does nothing for versions that already appear to be canonical. +// +// The VersionFixer sets 'fixed' if it ever returns a non-canonical version. +func fixVersion(loaderstate *State, ctx context.Context, fixed *bool) modfile.VersionFixer { + return func(path, vers string) (resolved string, err error) { + defer func() { + if err == nil && resolved != vers { + *fixed = true + } + }() + + // Special case: remove the old -gopkgin- hack. + if strings.HasPrefix(path, "gopkg.in/") && strings.Contains(vers, "-gopkgin-") { + vers = vers[strings.Index(vers, "-gopkgin-")+len("-gopkgin-"):] + } + + // fixVersion is called speculatively on every + // module, version pair from every go.mod file. + // Avoid the query if it looks OK. + _, pathMajor, ok := module.SplitPathVersion(path) + if !ok { + return "", &module.ModuleError{ + Path: path, + Err: &module.InvalidVersionError{ + Version: vers, + Err: fmt.Errorf("malformed module path %q", path), + }, + } + } + if vers != "" && module.CanonicalVersion(vers) == vers { + if err := module.CheckPathMajor(vers, pathMajor); err != nil { + return "", module.VersionError(module.Version{Path: path, Version: vers}, err) + } + return vers, nil + } + + info, err := Query(loaderstate, ctx, path, vers, "", nil) + if err != nil { + return "", err + } + return info.Version, nil + } +} + +// AllowMissingModuleImports allows import paths to be resolved to modules +// when there is no module root. Normally, this is forbidden because it's slow +// and there's no way to make the result reproducible, but some commands +// like 'go get' are expected to do this. +// +// This function affects the default cfg.BuildMod when outside of a module, +// so it can only be called prior to Init. +func (s *State) AllowMissingModuleImports() { + if s.initialized { + panic("AllowMissingModuleImports after Init") + } + s.allowMissingModuleImports = true +} + +// makeMainModules creates a MainModuleSet and associated variables according to +// the given main modules. +func makeMainModules(loaderstate *State, ms []module.Version, rootDirs []string, modFiles []*modfile.File, indices []*modFileIndex, workFile *modfile.WorkFile) *MainModuleSet { + for _, m := range ms { + if m.Version != "" { + panic("mainModulesCalled with module.Version with non empty Version field: " + fmt.Sprintf("%#v", m)) + } + } + modRootContainingCWD := findModuleRoot(base.Cwd()) + mainModules := &MainModuleSet{ + versions: slices.Clip(ms), + inGorootSrc: map[module.Version]bool{}, + pathPrefix: map[module.Version]string{}, + modRoot: map[module.Version]string{}, + modFiles: map[module.Version]*modfile.File{}, + indices: map[module.Version]*modFileIndex{}, + highestReplaced: map[string]string{}, + tools: map[string]bool{}, + workFile: workFile, + } + var workFileReplaces []*modfile.Replace + if workFile != nil { + workFileReplaces = workFile.Replace + mainModules.workFileReplaceMap = toReplaceMap(workFile.Replace) + } + mainModulePaths := make(map[string]bool) + for _, m := range ms { + if mainModulePaths[m.Path] { + base.Errorf("go: module %s appears multiple times in workspace", m.Path) + } + mainModulePaths[m.Path] = true + } + replacedByWorkFile := make(map[string]bool) + replacements := make(map[module.Version]module.Version) + for _, r := range workFileReplaces { + if mainModulePaths[r.Old.Path] && r.Old.Version == "" { + base.Errorf("go: workspace module %v is replaced at all versions in the go.work file. To fix, remove the replacement from the go.work file or specify the version at which to replace the module.", r.Old.Path) + } + replacedByWorkFile[r.Old.Path] = true + v, ok := mainModules.highestReplaced[r.Old.Path] + if !ok || gover.ModCompare(r.Old.Path, r.Old.Version, v) > 0 { + mainModules.highestReplaced[r.Old.Path] = r.Old.Version + } + replacements[r.Old] = r.New + } + for i, m := range ms { + mainModules.pathPrefix[m] = m.Path + mainModules.modRoot[m] = rootDirs[i] + mainModules.modFiles[m] = modFiles[i] + mainModules.indices[m] = indices[i] + + if mainModules.modRoot[m] == modRootContainingCWD { + mainModules.modContainingCWD = m + } + + if rel := search.InDir(rootDirs[i], cfg.GOROOTsrc); rel != "" { + mainModules.inGorootSrc[m] = true + if m.Path == "std" { + // The "std" module in GOROOT/src is the Go standard library. Unlike other + // modules, the packages in the "std" module have no import-path prefix. + // + // Modules named "std" outside of GOROOT/src do not receive this special + // treatment, so it is possible to run 'go test .' in other GOROOTs to + // test individual packages using a combination of the modified package + // and the ordinary standard library. + // (See https://golang.org/issue/30756.) + mainModules.pathPrefix[m] = "" + } + } + + if modFiles[i] != nil { + curModuleReplaces := make(map[module.Version]bool) + for _, r := range modFiles[i].Replace { + if replacedByWorkFile[r.Old.Path] { + continue + } + var newV module.Version = r.New + if WorkFilePath(loaderstate) != "" && newV.Version == "" && !filepath.IsAbs(newV.Path) { + // Since we are in a workspace, we may be loading replacements from + // multiple go.mod files. Relative paths in those replacement are + // relative to the go.mod file, not the workspace, so the same string + // may refer to two different paths and different strings may refer to + // the same path. Convert them all to be absolute instead. + // + // (We could do this outside of a workspace too, but it would mean that + // replacement paths in error strings needlessly differ from what's in + // the go.mod file.) + newV.Path = filepath.Join(rootDirs[i], newV.Path) + } + if prev, ok := replacements[r.Old]; ok && !curModuleReplaces[r.Old] && prev != newV { + base.Fatalf("go: conflicting replacements for %v:\n\t%v\n\t%v\nuse \"go work edit -replace %v=[override]\" to resolve", r.Old, prev, newV, r.Old) + } + curModuleReplaces[r.Old] = true + replacements[r.Old] = newV + + v, ok := mainModules.highestReplaced[r.Old.Path] + if !ok || gover.ModCompare(r.Old.Path, r.Old.Version, v) > 0 { + mainModules.highestReplaced[r.Old.Path] = r.Old.Version + } + } + + for _, t := range modFiles[i].Tool { + if err := module.CheckImportPath(t.Path); err != nil { + if e, ok := err.(*module.InvalidPathError); ok { + e.Kind = "tool" + } + base.Fatal(err) + } + + mainModules.tools[t.Path] = true + } + } + } + + return mainModules +} + +// requirementsFromModFiles returns the set of non-excluded requirements from +// the global modFile. +func requirementsFromModFiles(loaderstate *State, ctx context.Context, workFile *modfile.WorkFile, modFiles []*modfile.File, opts *PackageOpts) *Requirements { + var roots []module.Version + direct := map[string]bool{} + var pruning modPruning + if loaderstate.inWorkspaceMode() { + pruning = workspace + roots = make([]module.Version, len(loaderstate.MainModules.Versions()), 2+len(loaderstate.MainModules.Versions())) + copy(roots, loaderstate.MainModules.Versions()) + goVersion := gover.FromGoWork(workFile) + var toolchain string + if workFile.Toolchain != nil { + toolchain = workFile.Toolchain.Name + } + roots = appendGoAndToolchainRoots(roots, goVersion, toolchain, direct) + direct = directRequirements(modFiles) + } else { + pruning = pruningForGoVersion(loaderstate.MainModules.GoVersion(loaderstate)) + if len(modFiles) != 1 { + panic(fmt.Errorf("requirementsFromModFiles called with %v modfiles outside workspace mode", len(modFiles))) + } + modFile := modFiles[0] + roots, direct = rootsFromModFile(loaderstate, loaderstate.MainModules.mustGetSingleMainModule(loaderstate), modFile, withToolchainRoot) + } + + gover.ModSort(roots) + rs := newRequirements(loaderstate, pruning, roots, direct) + return rs +} + +type addToolchainRoot bool + +const ( + omitToolchainRoot addToolchainRoot = false + withToolchainRoot = true +) + +func directRequirements(modFiles []*modfile.File) map[string]bool { + direct := make(map[string]bool) + for _, modFile := range modFiles { + for _, r := range modFile.Require { + if !r.Indirect { + direct[r.Mod.Path] = true + } + } + } + return direct +} + +func rootsFromModFile(loaderstate *State, m module.Version, modFile *modfile.File, addToolchainRoot addToolchainRoot) (roots []module.Version, direct map[string]bool) { + direct = make(map[string]bool) + padding := 2 // Add padding for the toolchain and go version, added upon return. + if !addToolchainRoot { + padding = 1 + } + roots = make([]module.Version, 0, padding+len(modFile.Require)) + for _, r := range modFile.Require { + if index := loaderstate.MainModules.Index(m); index != nil && index.exclude[r.Mod] { + if cfg.BuildMod == "mod" { + fmt.Fprintf(os.Stderr, "go: dropping requirement on excluded version %s %s\n", r.Mod.Path, r.Mod.Version) + } else { + fmt.Fprintf(os.Stderr, "go: ignoring requirement on excluded version %s %s\n", r.Mod.Path, r.Mod.Version) + } + continue + } + + roots = append(roots, r.Mod) + if !r.Indirect { + direct[r.Mod.Path] = true + } + } + goVersion := gover.FromGoMod(modFile) + var toolchain string + if addToolchainRoot && modFile.Toolchain != nil { + toolchain = modFile.Toolchain.Name + } + roots = appendGoAndToolchainRoots(roots, goVersion, toolchain, direct) + return roots, direct +} + +func appendGoAndToolchainRoots(roots []module.Version, goVersion, toolchain string, direct map[string]bool) []module.Version { + // Add explicit go and toolchain versions, inferring as needed. + roots = append(roots, module.Version{Path: "go", Version: goVersion}) + direct["go"] = true // Every module directly uses the language and runtime. + + if toolchain != "" { + roots = append(roots, module.Version{Path: "toolchain", Version: toolchain}) + // Leave the toolchain as indirect: nothing in the user's module directly + // imports a package from the toolchain, and (like an indirect dependency in + // a module without graph pruning) we may remove the toolchain line + // automatically if the 'go' version is changed so that it implies the exact + // same toolchain. + } + return roots +} + +// setDefaultBuildMod sets a default value for cfg.BuildMod if the -mod flag +// wasn't provided. setDefaultBuildMod may be called multiple times. +func setDefaultBuildMod(loaderstate *State) { + if cfg.BuildModExplicit { + if loaderstate.inWorkspaceMode() && cfg.BuildMod != "readonly" && cfg.BuildMod != "vendor" { + switch cfg.CmdName { + case "work sync", "mod graph", "mod verify", "mod why": + // These commands run with BuildMod set to mod, but they don't take the + // -mod flag, so we should never get here. + panic("in workspace mode and -mod was set explicitly, but command doesn't support setting -mod") + default: + base.Fatalf("go: -mod may only be set to readonly or vendor when in workspace mode, but it is set to %q"+ + "\n\tRemove the -mod flag to use the default readonly value, "+ + "\n\tor set GOWORK=off to disable workspace mode.", cfg.BuildMod) + } + } + // Don't override an explicit '-mod=' argument. + return + } + + // TODO(#40775): commands should pass in the module mode as an option + // to modload functions instead of relying on an implicit setting + // based on command name. + switch cfg.CmdName { + case "get", "mod download", "mod init", "mod tidy", "work sync": + // These commands are intended to update go.mod and go.sum. + cfg.BuildMod = "mod" + return + case "mod graph", "mod verify", "mod why": + // These commands should not update go.mod or go.sum, but they should be + // able to fetch modules not in go.sum and should not report errors if + // go.mod is inconsistent. They're useful for debugging, and they need + // to work in buggy situations. + cfg.BuildMod = "mod" + return + case "mod vendor", "work vendor": + cfg.BuildMod = "readonly" + return + } + if loaderstate.modRoots == nil { + if loaderstate.allowMissingModuleImports { + cfg.BuildMod = "mod" + } else { + cfg.BuildMod = "readonly" + } + return + } + + if len(loaderstate.modRoots) >= 1 { + var goVersion string + var versionSource string + if loaderstate.inWorkspaceMode() { + versionSource = "go.work" + if wfg := loaderstate.MainModules.WorkFile().Go; wfg != nil { + goVersion = wfg.Version + } + } else { + versionSource = "go.mod" + index := loaderstate.MainModules.GetSingleIndexOrNil(loaderstate) + if index != nil { + goVersion = index.goVersion + } + } + vendorDir := "" + if loaderstate.workFilePath != "" { + vendorDir = filepath.Join(filepath.Dir(loaderstate.workFilePath), "vendor") + } else { + if len(loaderstate.modRoots) != 1 { + panic(fmt.Errorf("outside workspace mode, but have %v modRoots", loaderstate.modRoots)) + } + vendorDir = filepath.Join(loaderstate.modRoots[0], "vendor") + } + if fi, err := fsys.Stat(vendorDir); err == nil && fi.IsDir() { + if goVersion != "" { + if gover.Compare(goVersion, "1.14") < 0 { + // The go version is less than 1.14. Don't set -mod=vendor by default. + // Since a vendor directory exists, we should record why we didn't use it. + // This message won't normally be shown, but it may appear with import errors. + cfg.BuildModReason = fmt.Sprintf("Go version in "+versionSource+" is %s, so vendor directory was not used.", goVersion) + } else { + vendoredWorkspace, err := modulesTextIsForWorkspace(vendorDir) + if err != nil { + base.Fatalf("go: reading modules.txt for vendor directory: %v", err) + } + if vendoredWorkspace != (versionSource == "go.work") { + if vendoredWorkspace { + cfg.BuildModReason = "Outside workspace mode, but vendor directory is for a workspace." + } else { + cfg.BuildModReason = "In workspace mode, but vendor directory is not for a workspace" + } + } else { + // The Go version is at least 1.14, a vendor directory exists, and + // the modules.txt was generated in the same mode the command is running in. + // Set -mod=vendor by default. + cfg.BuildMod = "vendor" + cfg.BuildModReason = "Go version in " + versionSource + " is at least 1.14 and vendor directory exists." + return + } + } + } else { + cfg.BuildModReason = fmt.Sprintf("Go version in %s is unspecified, so vendor directory was not used.", versionSource) + } + } + } + + cfg.BuildMod = "readonly" +} + +func modulesTextIsForWorkspace(vendorDir string) (bool, error) { + f, err := fsys.Open(filepath.Join(vendorDir, "modules.txt")) + if errors.Is(err, os.ErrNotExist) { + // Some vendor directories exist that don't contain modules.txt. + // This mostly happens when converting to modules. + // We want to preserve the behavior that mod=vendor is set (even though + // readVendorList does nothing in that case). + return false, nil + } + if err != nil { + return false, err + } + defer f.Close() + var buf [512]byte + n, err := f.Read(buf[:]) + if err != nil && err != io.EOF { + return false, err + } + line, _, _ := strings.Cut(string(buf[:n]), "\n") + if annotations, ok := strings.CutPrefix(line, "## "); ok { + for entry := range strings.SplitSeq(annotations, ";") { + entry = strings.TrimSpace(entry) + if entry == "workspace" { + return true, nil + } + } + } + return false, nil +} + +func mustHaveCompleteRequirements(loaderstate *State) bool { + return cfg.BuildMod != "mod" && !loaderstate.inWorkspaceMode() +} + +// addGoStmt adds a go directive to the go.mod file if it does not already +// include one. The 'go' version added, if any, is the latest version supported +// by this toolchain. +func addGoStmt(modFile *modfile.File, mod module.Version, v string) { + if modFile.Go != nil && modFile.Go.Version != "" { + return + } + forceGoStmt(modFile, mod, v) +} + +func forceGoStmt(modFile *modfile.File, mod module.Version, v string) { + if err := modFile.AddGoStmt(v); err != nil { + base.Fatalf("go: internal error: %v", err) + } + rawGoVersion.Store(mod, v) +} + +var altConfigs = []string{ + ".git/config", +} + +func findModuleRoot(dir string) (roots string) { + if dir == "" { + panic("dir not set") + } + dir = filepath.Clean(dir) + + // Look for enclosing go.mod. + for { + if fi, err := fsys.Stat(filepath.Join(dir, "go.mod")); err == nil && !fi.IsDir() { + return dir + } + d := filepath.Dir(dir) + if d == dir { + break + } + dir = d + } + return "" +} + +func findWorkspaceFile(dir string) (root string) { + if dir == "" { + panic("dir not set") + } + dir = filepath.Clean(dir) + + // Look for enclosing go.mod. + for { + f := filepath.Join(dir, "go.work") + if fi, err := fsys.Stat(f); err == nil && !fi.IsDir() { + return f + } + d := filepath.Dir(dir) + if d == dir { + break + } + if d == cfg.GOROOT { + // As a special case, don't cross GOROOT to find a go.work file. + // The standard library and commands built in go always use the vendored + // dependencies, so avoid using a most likely irrelevant go.work file. + return "" + } + dir = d + } + return "" +} + +func findAltConfig(dir string) (root, name string) { + if dir == "" { + panic("dir not set") + } + dir = filepath.Clean(dir) + if rel := search.InDir(dir, cfg.BuildContext.GOROOT); rel != "" { + // Don't suggest creating a module from $GOROOT/.git/config + // or a config file found in any parent of $GOROOT (see #34191). + return "", "" + } + for { + for _, name := range altConfigs { + if fi, err := fsys.Stat(filepath.Join(dir, name)); err == nil && !fi.IsDir() { + return dir, name + } + } + d := filepath.Dir(dir) + if d == dir { + break + } + dir = d + } + return "", "" +} + +func findModulePath(dir string) (string, error) { + // TODO(bcmills): once we have located a plausible module path, we should + // query version control (if available) to verify that it matches the major + // version of the most recent tag. + // See https://golang.org/issue/29433, https://golang.org/issue/27009, and + // https://golang.org/issue/31549. + + // Cast about for import comments, + // first in top-level directory, then in subdirectories. + list, _ := os.ReadDir(dir) + for _, info := range list { + if info.Type().IsRegular() && strings.HasSuffix(info.Name(), ".go") { + if com := findImportComment(filepath.Join(dir, info.Name())); com != "" { + return com, nil + } + } + } + for _, info1 := range list { + if info1.IsDir() { + files, _ := os.ReadDir(filepath.Join(dir, info1.Name())) + for _, info2 := range files { + if info2.Type().IsRegular() && strings.HasSuffix(info2.Name(), ".go") { + if com := findImportComment(filepath.Join(dir, info1.Name(), info2.Name())); com != "" { + return path.Dir(com), nil + } + } + } + } + } + + // Look for path in GOPATH. + var badPathErr error + for _, gpdir := range filepath.SplitList(cfg.BuildContext.GOPATH) { + if gpdir == "" { + continue + } + if rel := search.InDir(dir, filepath.Join(gpdir, "src")); rel != "" && rel != "." { + path := filepath.ToSlash(rel) + // gorelease will alert users publishing their modules to fix their paths. + if err := module.CheckImportPath(path); err != nil { + badPathErr = err + break + } + return path, nil + } + } + + reason := "outside GOPATH, module path must be specified" + if badPathErr != nil { + // return a different error message if the module was in GOPATH, but + // the module path determined above would be an invalid path. + reason = fmt.Sprintf("bad module path inferred from directory in GOPATH: %v", badPathErr) + } + msg := `cannot determine module path for source directory %s (%s) + +Example usage: + 'go mod init example.com/m' to initialize a v0 or v1 module + 'go mod init example.com/m/v2' to initialize a v2 module + +Run 'go help mod init' for more information. +` + return "", fmt.Errorf(msg, dir, reason) +} + +var ( + importCommentRE = lazyregexp.New(`(?m)^package[ \t]+[^ \t\r\n/]+[ \t]+//[ \t]+import[ \t]+(\"[^"]+\")[ \t]*\r?\n`) +) + +func findImportComment(file string) string { + data, err := os.ReadFile(file) + if err != nil { + return "" + } + m := importCommentRE.FindSubmatch(data) + if m == nil { + return "" + } + path, err := strconv.Unquote(string(m[1])) + if err != nil { + return "" + } + return path +} + +// WriteOpts control the behavior of WriteGoMod. +type WriteOpts struct { + DropToolchain bool // go get toolchain@none + ExplicitToolchain bool // go get has set explicit toolchain version + + AddTools []string // go get -tool example.com/m1 + DropTools []string // go get -tool example.com/m1@none + + // TODO(bcmills): Make 'go mod tidy' update the go version in the Requirements + // instead of writing directly to the modfile.File + TidyWroteGo bool // Go.Version field already updated by 'go mod tidy' +} + +// WriteGoMod writes the current build list back to go.mod. +func WriteGoMod(loaderstate *State, ctx context.Context, opts WriteOpts) error { + loaderstate.requirements = LoadModFile(loaderstate, ctx) + return commitRequirements(loaderstate, ctx, opts) +} + +var errNoChange = errors.New("no update needed") + +// UpdateGoModFromReqs returns a modified go.mod file using the current +// requirements. It does not commit these changes to disk. +func UpdateGoModFromReqs(loaderstate *State, ctx context.Context, opts WriteOpts) (before, after []byte, modFile *modfile.File, err error) { + if loaderstate.MainModules.Len() != 1 || loaderstate.MainModules.ModRoot(loaderstate.MainModules.Versions()[0]) == "" { + // We aren't in a module, so we don't have anywhere to write a go.mod file. + return nil, nil, nil, errNoChange + } + mainModule := loaderstate.MainModules.mustGetSingleMainModule(loaderstate) + modFile = loaderstate.MainModules.ModFile(mainModule) + if modFile == nil { + // command-line-arguments has no .mod file to write. + return nil, nil, nil, errNoChange + } + before, err = modFile.Format() + if err != nil { + return nil, nil, nil, err + } + + var list []*modfile.Require + toolchain := "" + goVersion := "" + for _, m := range loaderstate.requirements.rootModules { + if m.Path == "go" { + goVersion = m.Version + continue + } + if m.Path == "toolchain" { + toolchain = m.Version + continue + } + list = append(list, &modfile.Require{ + Mod: m, + Indirect: !loaderstate.requirements.direct[m.Path], + }) + } + + // Update go line. + // Every MVS graph we consider should have go as a root, + // and toolchain is either implied by the go line or explicitly a root. + if goVersion == "" { + base.Fatalf("go: internal error: missing go root module in WriteGoMod") + } + if gover.Compare(goVersion, gover.Local()) > 0 { + // We cannot assume that we know how to update a go.mod to a newer version. + return nil, nil, nil, &gover.TooNewError{What: "updating go.mod", GoVersion: goVersion} + } + wroteGo := opts.TidyWroteGo + if !wroteGo && modFile.Go == nil || modFile.Go.Version != goVersion { + alwaysUpdate := cfg.BuildMod == "mod" || cfg.CmdName == "mod tidy" || cfg.CmdName == "get" + if modFile.Go == nil && goVersion == gover.DefaultGoModVersion && !alwaysUpdate { + // The go.mod has no go line, the implied default Go version matches + // what we've computed for the graph, and we're not in one of the + // traditional go.mod-updating programs, so leave it alone. + } else { + wroteGo = true + forceGoStmt(modFile, mainModule, goVersion) + } + } + if toolchain == "" { + toolchain = "go" + goVersion + } + + toolVers := gover.FromToolchain(toolchain) + if opts.DropToolchain || toolchain == "go"+goVersion || (gover.Compare(toolVers, gover.GoStrictVersion) < 0 && !opts.ExplicitToolchain) { + // go get toolchain@none or toolchain matches go line or isn't valid; drop it. + // TODO(#57001): 'go get' should reject explicit toolchains below GoStrictVersion. + modFile.DropToolchainStmt() + } else { + modFile.AddToolchainStmt(toolchain) + } + + for _, path := range opts.AddTools { + modFile.AddTool(path) + } + + for _, path := range opts.DropTools { + modFile.DropTool(path) + } + + // Update require blocks. + if gover.Compare(goVersion, gover.SeparateIndirectVersion) < 0 { + modFile.SetRequire(list) + } else { + modFile.SetRequireSeparateIndirect(list) + } + modFile.Cleanup() + after, err = modFile.Format() + if err != nil { + return nil, nil, nil, err + } + return before, after, modFile, nil +} + +// commitRequirements ensures go.mod and go.sum are up to date with the current +// requirements. +// +// In "mod" mode, commitRequirements writes changes to go.mod and go.sum. +// +// In "readonly" and "vendor" modes, commitRequirements returns an error if +// go.mod or go.sum are out of date in a semantically significant way. +// +// In workspace mode, commitRequirements only writes changes to go.work.sum. +func commitRequirements(loaderstate *State, ctx context.Context, opts WriteOpts) (err error) { + if loaderstate.inWorkspaceMode() { + // go.mod files aren't updated in workspace mode, but we still want to + // update the go.work.sum file. + return loaderstate.Fetcher().WriteGoSum(ctx, keepSums(loaderstate, ctx, loaded, loaderstate.requirements, addBuildListZipSums), mustHaveCompleteRequirements(loaderstate)) + } + _, updatedGoMod, modFile, err := UpdateGoModFromReqs(loaderstate, ctx, opts) + if err != nil { + if errors.Is(err, errNoChange) { + return nil + } + return err + } + + index := loaderstate.MainModules.GetSingleIndexOrNil(loaderstate) + dirty := index.modFileIsDirty(modFile) || len(opts.DropTools) > 0 || len(opts.AddTools) > 0 + if dirty && cfg.BuildMod != "mod" { + // If we're about to fail due to -mod=readonly, + // prefer to report a dirty go.mod over a dirty go.sum + return errGoModDirty + } + + if !dirty && cfg.CmdName != "mod tidy" { + // The go.mod file has the same semantic content that it had before + // (but not necessarily the same exact bytes). + // Don't write go.mod, but write go.sum in case we added or trimmed sums. + // 'go mod init' shouldn't write go.sum, since it will be incomplete. + if cfg.CmdName != "mod init" { + if err := loaderstate.Fetcher().WriteGoSum(ctx, keepSums(loaderstate, ctx, loaded, loaderstate.requirements, addBuildListZipSums), mustHaveCompleteRequirements(loaderstate)); err != nil { + return err + } + } + return nil + } + + mainModule := loaderstate.MainModules.mustGetSingleMainModule(loaderstate) + modFilePath := modFilePath(loaderstate.MainModules.ModRoot(mainModule)) + if fsys.Replaced(modFilePath) { + if dirty { + return errors.New("updates to go.mod needed, but go.mod is part of the overlay specified with -overlay") + } + return nil + } + defer func() { + // At this point we have determined to make the go.mod file on disk equal to new. + loaderstate.MainModules.SetIndex(mainModule, indexModFile(updatedGoMod, modFile, mainModule, false)) + + // Update go.sum after releasing the side lock and refreshing the index. + // 'go mod init' shouldn't write go.sum, since it will be incomplete. + if cfg.CmdName != "mod init" { + if err == nil { + err = loaderstate.Fetcher().WriteGoSum(ctx, keepSums(loaderstate, ctx, loaded, loaderstate.requirements, addBuildListZipSums), mustHaveCompleteRequirements(loaderstate)) + } + } + }() + + // Make a best-effort attempt to acquire the side lock, only to exclude + // previous versions of the 'go' command from making simultaneous edits. + if unlock, err := modfetch.SideLock(ctx); err == nil { + defer unlock() + } + + err = lockedfile.Transform(modFilePath, func(old []byte) ([]byte, error) { + if bytes.Equal(old, updatedGoMod) { + // The go.mod file is already equal to new, possibly as the result of some + // other process. + return nil, errNoChange + } + + if index != nil && !bytes.Equal(old, index.data) { + // The contents of the go.mod file have changed. In theory we could add all + // of the new modules to the build list, recompute, and check whether any + // module in *our* build list got bumped to a different version, but that's + // a lot of work for marginal benefit. Instead, fail the command: if users + // want to run concurrent commands, they need to start with a complete, + // consistent module definition. + return nil, fmt.Errorf("existing contents have changed since last read") + } + + return updatedGoMod, nil + }) + + if err != nil && err != errNoChange { + return fmt.Errorf("updating go.mod: %w", err) + } + return nil +} + +// keepSums returns the set of modules (and go.mod file entries) for which +// checksums would be needed in order to reload the same set of packages +// loaded by the most recent call to LoadPackages or ImportFromFiles, +// including any go.mod files needed to reconstruct the MVS result +// or identify go versions, +// in addition to the checksums for every module in keepMods. +func keepSums(loaderstate *State, ctx context.Context, ld *loader, rs *Requirements, which whichSums) map[module.Version]bool { + // Every module in the full module graph contributes its requirements, + // so in order to ensure that the build list itself is reproducible, + // we need sums for every go.mod in the graph (regardless of whether + // that version is selected). + keep := make(map[module.Version]bool) + + // Add entries for modules in the build list with paths that are prefixes of + // paths of loaded packages. We need to retain sums for all of these modules — + // not just the modules containing the actual packages — in order to rule out + // ambiguous import errors the next time we load the package. + keepModSumsForZipSums := true + if ld == nil { + if gover.Compare(loaderstate.MainModules.GoVersion(loaderstate), gover.TidyGoModSumVersion) < 0 && cfg.BuildMod != "mod" { + keepModSumsForZipSums = false + } + } else { + keepPkgGoModSums := true + if gover.Compare(ld.requirements.GoVersion(loaderstate), gover.TidyGoModSumVersion) < 0 && (ld.Tidy || cfg.BuildMod != "mod") { + keepPkgGoModSums = false + keepModSumsForZipSums = false + } + for _, pkg := range ld.pkgs { + // We check pkg.mod.Path here instead of pkg.inStd because the + // pseudo-package "C" is not in std, but not provided by any module (and + // shouldn't force loading the whole module graph). + if pkg.testOf != nil || (pkg.mod.Path == "" && pkg.err == nil) || module.CheckImportPath(pkg.path) != nil { + continue + } + + // We need the checksum for the go.mod file for pkg.mod + // so that we know what Go version to use to compile pkg. + // However, we didn't do so before Go 1.21, and the bug is relatively + // minor, so we maintain the previous (buggy) behavior in 'go mod tidy' to + // avoid introducing unnecessary churn. + if keepPkgGoModSums { + r := resolveReplacement(loaderstate, pkg.mod) + keep[modkey(r)] = true + } + + if rs.pruning == pruned && pkg.mod.Path != "" { + if v, ok := rs.rootSelected(loaderstate, pkg.mod.Path); ok && v == pkg.mod.Version { + // pkg was loaded from a root module, and because the main module has + // a pruned module graph we do not check non-root modules for + // conflicts for packages that can be found in roots. So we only need + // the checksums for the root modules that may contain pkg, not all + // possible modules. + for prefix := pkg.path; prefix != "."; prefix = path.Dir(prefix) { + if v, ok := rs.rootSelected(loaderstate, prefix); ok && v != "none" { + m := module.Version{Path: prefix, Version: v} + r := resolveReplacement(loaderstate, m) + keep[r] = true + } + } + continue + } + } + + mg, _ := rs.Graph(loaderstate, ctx) + for prefix := pkg.path; prefix != "."; prefix = path.Dir(prefix) { + if v := mg.Selected(prefix); v != "none" { + m := module.Version{Path: prefix, Version: v} + r := resolveReplacement(loaderstate, m) + keep[r] = true + } + } + } + } + + if rs.graph.Load() == nil { + // We haven't needed to load the module graph so far. + // Save sums for the root modules (or their replacements), but don't + // incur the cost of loading the graph just to find and retain the sums. + for _, m := range rs.rootModules { + r := resolveReplacement(loaderstate, m) + keep[modkey(r)] = true + if which == addBuildListZipSums { + keep[r] = true + } + } + } else { + mg, _ := rs.Graph(loaderstate, ctx) + mg.WalkBreadthFirst(func(m module.Version) { + if _, ok := mg.RequiredBy(m); ok { + // The requirements from m's go.mod file are present in the module graph, + // so they are relevant to the MVS result regardless of whether m was + // actually selected. + r := resolveReplacement(loaderstate, m) + keep[modkey(r)] = true + } + }) + + if which == addBuildListZipSums { + for _, m := range mg.BuildList() { + r := resolveReplacement(loaderstate, m) + if keepModSumsForZipSums { + keep[modkey(r)] = true // we need the go version from the go.mod file to do anything useful with the zipfile + } + keep[r] = true + } + } + } + + return keep +} + +type whichSums int8 + +const ( + loadedZipSumsOnly = whichSums(iota) + addBuildListZipSums +) + +// modkey returns the module.Version under which the checksum for m's go.mod +// file is stored in the go.sum file. +func modkey(m module.Version) module.Version { + return module.Version{Path: m.Path, Version: m.Version + "/go.mod"} +} + +func suggestModulePath(path string) string { + var m string + + i := len(path) + for i > 0 && ('0' <= path[i-1] && path[i-1] <= '9' || path[i-1] == '.') { + i-- + } + url := path[:i] + url = strings.TrimSuffix(url, "/v") + url = strings.TrimSuffix(url, "/") + + f := func(c rune) bool { + return c > '9' || c < '0' + } + s := strings.FieldsFunc(path[i:], f) + if len(s) > 0 { + m = s[0] + } + m = strings.TrimLeft(m, "0") + if m == "" || m == "1" { + return url + "/v2" + } + + return url + "/v" + m +} + +func suggestGopkgIn(path string) string { + var m string + i := len(path) + for i > 0 && (('0' <= path[i-1] && path[i-1] <= '9') || (path[i-1] == '.')) { + i-- + } + url := path[:i] + url = strings.TrimSuffix(url, ".v") + url = strings.TrimSuffix(url, "/v") + url = strings.TrimSuffix(url, "/") + + f := func(c rune) bool { + return c > '9' || c < '0' + } + s := strings.FieldsFunc(path, f) + if len(s) > 0 { + m = s[0] + } + + m = strings.TrimLeft(m, "0") + + if m == "" { + return url + ".v1" + } + return url + ".v" + m +} + +func CheckGodebug(verb, k, v string) error { + if strings.ContainsAny(k, " \t") { + return fmt.Errorf("key contains space") + } + if strings.ContainsAny(v, " \t") { + return fmt.Errorf("value contains space") + } + if strings.ContainsAny(k, ",") { + return fmt.Errorf("key contains comma") + } + if strings.ContainsAny(v, ",") { + return fmt.Errorf("value contains comma") + } + if k == "default" { + if !strings.HasPrefix(v, "go") || !gover.IsValid(v[len("go"):]) { + return fmt.Errorf("value for default= must be goVERSION") + } + if gover.Compare(v[len("go"):], gover.Local()) > 0 { + return fmt.Errorf("default=%s too new (toolchain is go%s)", v, gover.Local()) + } + return nil + } + if godebugs.Lookup(k) != nil { + return nil + } + for _, info := range godebugs.Removed { + if info.Name == k { + return fmt.Errorf("use of removed %s %q, see https://go.dev/doc/godebug#go-1%v", verb, k, info.Removed) + } + } + return fmt.Errorf("unknown %s %q", verb, k) +} diff --git a/go/src/cmd/go/internal/modload/list.go b/go/src/cmd/go/internal/modload/list.go new file mode 100644 index 0000000000000000000000000000000000000000..32f8c5fe3d6e537300fe269a41176b4dd8b3caec --- /dev/null +++ b/go/src/cmd/go/internal/modload/list.go @@ -0,0 +1,345 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "os" + "runtime" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/modfetch/codehost" + "cmd/go/internal/modinfo" + "cmd/go/internal/search" + "cmd/internal/par" + "cmd/internal/pkgpattern" + + "golang.org/x/mod/module" +) + +type ListMode int + +const ( + ListU ListMode = 1 << iota + ListRetracted + ListDeprecated + ListVersions + ListRetractedVersions +) + +// ListModules returns a description of the modules matching args, if known, +// along with any error preventing additional matches from being identified. +// +// The returned slice can be nonempty even if the error is non-nil. +func ListModules(loaderstate *State, ctx context.Context, args []string, mode ListMode, reuseFile string) ([]*modinfo.ModulePublic, error) { + var reuse map[module.Version]*modinfo.ModulePublic + if reuseFile != "" { + data, err := os.ReadFile(reuseFile) + if err != nil { + return nil, err + } + dec := json.NewDecoder(bytes.NewReader(data)) + reuse = make(map[module.Version]*modinfo.ModulePublic) + for { + var m modinfo.ModulePublic + if err := dec.Decode(&m); err != nil { + if err == io.EOF { + break + } + return nil, fmt.Errorf("parsing %s: %v", reuseFile, err) + } + if m.Origin == nil { + continue + } + m.Reuse = true + reuse[module.Version{Path: m.Path, Version: m.Version}] = &m + if m.Query != "" { + reuse[module.Version{Path: m.Path, Version: m.Query}] = &m + } + } + } + + rs, mods, err := listModules(loaderstate, ctx, LoadModFile(loaderstate, ctx), args, mode, reuse) + + type token struct{} + sem := make(chan token, runtime.GOMAXPROCS(0)) + if mode != 0 { + for _, m := range mods { + if m.Reuse { + continue + } + add := func(m *modinfo.ModulePublic) { + sem <- token{} + go func() { + if mode&ListU != 0 { + addUpdate(loaderstate, ctx, m) + } + if mode&ListVersions != 0 { + addVersions(loaderstate, ctx, m, mode&ListRetractedVersions != 0) + } + if mode&ListRetracted != 0 { + addRetraction(loaderstate, ctx, m) + } + if mode&ListDeprecated != 0 { + addDeprecation(loaderstate, ctx, m) + } + <-sem + }() + } + + add(m) + if m.Replace != nil { + add(m.Replace) + } + } + } + // Fill semaphore channel to wait for all tasks to finish. + for n := cap(sem); n > 0; n-- { + sem <- token{} + } + + if err == nil { + loaderstate.requirements = rs + // TODO(#61605): The extra ListU clause fixes a problem with Go 1.21rc3 + // where "go mod tidy" and "go list -m -u all" fight over whether the go.sum + // should be considered up-to-date. The fix for now is to always treat the + // go.sum as up-to-date during list -m -u. Probably the right fix is more targeted, + // but in general list -u is looking up other checksums in the checksum database + // that won't be necessary later, so it makes sense not to write the go.sum back out. + if !ExplicitWriteGoMod && mode&ListU == 0 { + err = commitRequirements(loaderstate, ctx, WriteOpts{}) + } + } + return mods, err +} + +func listModules(loaderstate *State, ctx context.Context, rs *Requirements, args []string, mode ListMode, reuse map[module.Version]*modinfo.ModulePublic) (_ *Requirements, mods []*modinfo.ModulePublic, mgErr error) { + if len(args) == 0 { + var ms []*modinfo.ModulePublic + for _, m := range loaderstate.MainModules.Versions() { + if gover.IsToolchain(m.Path) { + continue + } + ms = append(ms, moduleInfo(loaderstate, ctx, rs, m, mode, reuse)) + } + return rs, ms, nil + } + + needFullGraph := false + for _, arg := range args { + if strings.Contains(arg, `\`) { + base.Fatalf("go: module paths never use backslash") + } + if search.IsRelativePath(arg) { + base.Fatalf("go: cannot use relative path %s to specify module", arg) + } + if arg == "all" || strings.Contains(arg, "...") { + needFullGraph = true + if !loaderstate.HasModRoot() { + base.Fatalf("go: cannot match %q: %v", arg, NewNoMainModulesError(loaderstate)) + } + continue + } + path, vers, found, err := ParsePathVersion(arg) + if err != nil { + base.Fatalf("go: %v", err) + } + if found { + if vers == "upgrade" || vers == "patch" { + if _, ok := rs.rootSelected(loaderstate, path); !ok || rs.pruning == unpruned { + needFullGraph = true + if !loaderstate.HasModRoot() { + base.Fatalf("go: cannot match %q: %v", arg, NewNoMainModulesError(loaderstate)) + } + } + } + continue + } + if _, ok := rs.rootSelected(loaderstate, arg); !ok || rs.pruning == unpruned { + needFullGraph = true + if mode&ListVersions == 0 && !loaderstate.HasModRoot() { + base.Fatalf("go: cannot match %q without -versions or an explicit version: %v", arg, NewNoMainModulesError(loaderstate)) + } + } + } + + var mg *ModuleGraph + if needFullGraph { + rs, mg, mgErr = expandGraph(loaderstate, ctx, rs) + } + + matchedModule := map[module.Version]bool{} + for _, arg := range args { + path, vers, found, err := ParsePathVersion(arg) + if err != nil { + base.Fatalf("go: %v", err) + } + if found { + var current string + if mg == nil { + current, _ = rs.rootSelected(loaderstate, path) + } else { + current = mg.Selected(path) + } + if current == "none" && mgErr != nil { + if vers == "upgrade" || vers == "patch" { + // The module graph is incomplete, so we don't know what version we're + // actually upgrading from. + // mgErr is already set, so just skip this module. + continue + } + } + + allowed := loaderstate.CheckAllowed + if IsRevisionQuery(path, vers) || mode&ListRetracted != 0 { + // Allow excluded and retracted versions if the user asked for a + // specific revision or used 'go list -retracted'. + allowed = nil + } + info, err := queryReuse(loaderstate, ctx, path, vers, current, allowed, reuse) + if err != nil { + var origin *codehost.Origin + if info != nil { + origin = info.Origin + } + mods = append(mods, &modinfo.ModulePublic{ + Path: path, + Version: vers, + Error: modinfoError(path, vers, err), + Origin: origin, + }) + continue + } + + // Indicate that m was resolved from outside of rs by passing a nil + // *Requirements instead. + var noRS *Requirements + + mod := moduleInfo(loaderstate, ctx, noRS, module.Version{Path: path, Version: info.Version}, mode, reuse) + if vers != mod.Version { + mod.Query = vers + } + mod.Origin = info.Origin + mods = append(mods, mod) + continue + } + + // Module path or pattern. + var match func(string) bool + if arg == "all" { + match = func(p string) bool { return !gover.IsToolchain(p) } + } else if strings.Contains(arg, "...") { + mp := pkgpattern.MatchPattern(arg) + match = func(p string) bool { return mp(p) && !gover.IsToolchain(p) } + } else { + var v string + if mg == nil { + var ok bool + v, ok = rs.rootSelected(loaderstate, arg) + if !ok { + // We checked rootSelected(arg) in the earlier args loop, so if there + // is no such root we should have loaded a non-nil mg. + panic(fmt.Sprintf("internal error: root requirement expected but not found for %v", arg)) + } + } else { + v = mg.Selected(arg) + } + if v == "none" && mgErr != nil { + // mgErr is already set, so just skip this module. + continue + } + if v != "none" { + mods = append(mods, moduleInfo(loaderstate, ctx, rs, module.Version{Path: arg, Version: v}, mode, reuse)) + } else if cfg.BuildMod == "vendor" { + // In vendor mode, we can't determine whether a missing module is “a + // known dependency” because the module graph is incomplete. + // Give a more explicit error message. + mods = append(mods, &modinfo.ModulePublic{ + Path: arg, + Error: modinfoError(arg, "", errors.New("can't resolve module using the vendor directory\n\t(Use -mod=mod or -mod=readonly to bypass.)")), + }) + } else if mode&ListVersions != 0 { + // Don't make the user provide an explicit '@latest' when they're + // explicitly asking what the available versions are. Instead, return a + // module with version "none", to which we can add the requested list. + mods = append(mods, &modinfo.ModulePublic{Path: arg}) + } else { + mods = append(mods, &modinfo.ModulePublic{ + Path: arg, + Error: modinfoError(arg, "", errors.New("not a known dependency")), + }) + } + continue + } + + var matches []module.Version + for _, m := range mg.BuildList() { + if match(m.Path) { + if !matchedModule[m] { + matchedModule[m] = true + matches = append(matches, m) + } + } + } + + if len(matches) == 0 { + fmt.Fprintf(os.Stderr, "warning: pattern %q matched no module dependencies\n", arg) + } + + q := par.NewQueue(runtime.GOMAXPROCS(0)) + fetchedMods := make([]*modinfo.ModulePublic, len(matches)) + for i, m := range matches { + q.Add(func() { + fetchedMods[i] = moduleInfo(loaderstate, ctx, rs, m, mode, reuse) + }) + } + <-q.Idle() + mods = append(mods, fetchedMods...) + } + + return rs, mods, mgErr +} + +// modinfoError wraps an error to create an error message in +// modinfo.ModuleError with minimal redundancy. +func modinfoError(path, vers string, err error) *modinfo.ModuleError { + if _, ok := errors.AsType[*NoMatchingVersionError](err); ok { + // NoMatchingVersionError contains the query, so we don't mention the + // query again in ModuleError. + err = &module.ModuleError{Path: path, Err: err} + } else if _, ok := errors.AsType[*module.ModuleError](err); !ok { + // If the error does not contain path and version, wrap it in a + // module.ModuleError. + err = &module.ModuleError{Path: path, Version: vers, Err: err} + } + + return &modinfo.ModuleError{Err: err.Error()} +} + +// ParsePathVersion parses arg expecting arg to be path@version. If there is no +// '@' in arg, found is false, vers is "", and path is arg. This mirrors the +// typical usage of strings.Cut. ParsePathVersion is meant to be a general +// replacement for strings.Cut in module version parsing. If the version is +// invalid, an error is returned. The version is considered invalid if it is +// prefixed with '-' or '/', which can cause security problems when constructing +// commands to execute that use the version. +func ParsePathVersion(arg string) (path, vers string, found bool, err error) { + path, vers, found = strings.Cut(arg, "@") + if !found { + return arg, "", false, nil + } + if len(vers) > 0 && (vers[0] == '-' || vers[0] == '/') { + return "", "", false, fmt.Errorf("invalid module version %q", vers) + } + return path, vers, true, nil +} diff --git a/go/src/cmd/go/internal/modload/load.go b/go/src/cmd/go/internal/modload/load.go new file mode 100644 index 0000000000000000000000000000000000000000..a432862429b11c077bb5e1eb5f4cdae0e0b57e7b --- /dev/null +++ b/go/src/cmd/go/internal/modload/load.go @@ -0,0 +1,2412 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +// This file contains the module-mode package loader, as well as some accessory +// functions pertaining to the package import graph. +// +// There are two exported entry points into package loading — LoadPackages and +// ImportFromFiles — both implemented in terms of loadFromRoots, which itself +// manipulates an instance of the loader struct. +// +// Although most of the loading state is maintained in the loader struct, +// one key piece - the build list - is a global, so that it can be modified +// separate from the loading operation, such as during "go get" +// upgrades/downgrades or in "go mod" operations. +// TODO(#40775): It might be nice to make the loader take and return +// a buildList rather than hard-coding use of the global. +// +// Loading is an iterative process. On each iteration, we try to load the +// requested packages and their transitive imports, then try to resolve modules +// for any imported packages that are still missing. +// +// The first step of each iteration identifies a set of “root” packages. +// Normally the root packages are exactly those matching the named pattern +// arguments. However, for the "all" meta-pattern, the final set of packages is +// computed from the package import graph, and therefore cannot be an initial +// input to loading that graph. Instead, the root packages for the "all" pattern +// are those contained in the main module, and allPatternIsRoot parameter to the +// loader instructs it to dynamically expand those roots to the full "all" +// pattern as loading progresses. +// +// The pkgInAll flag on each loadPkg instance tracks whether that +// package is known to match the "all" meta-pattern. +// A package matches the "all" pattern if: +// - it is in the main module, or +// - it is imported by any test in the main module, or +// - it is imported by a tool of the main module, or +// - it is imported by another package in "all", or +// - the main module specifies a go version ≤ 1.15, and the package is imported +// by a *test of* another package in "all". +// +// When graph pruning is in effect, we want to spot-check the graph-pruning +// invariants — which depend on which packages are known to be in "all" — even +// when we are only loading individual packages, so we set the pkgInAll flag +// regardless of the whether the "all" pattern is a root. +// (This is necessary to maintain the “import invariant” described in +// https://golang.org/design/36460-lazy-module-loading.) +// +// Because "go mod vendor" prunes out the tests of vendored packages, the +// behavior of the "all" pattern with -mod=vendor in Go 1.11–1.15 is the same +// as the "all" pattern (regardless of the -mod flag) in 1.16+. +// The loader uses the GoVersion parameter to determine whether the "all" +// pattern should close over tests (as in Go 1.11–1.15) or stop at only those +// packages transitively imported by the packages and tests in the main module +// ("all" in Go 1.16+ and "go mod vendor" in Go 1.11+). +// +// Note that it is possible for a loaded package NOT to be in "all" even when we +// are loading the "all" pattern. For example, packages that are transitive +// dependencies of other roots named on the command line must be loaded, but are +// not in "all". (The mod_notall test illustrates this behavior.) +// Similarly, if the LoadTests flag is set but the "all" pattern does not close +// over test dependencies, then when we load the test of a package that is in +// "all" but outside the main module, the dependencies of that test will not +// necessarily themselves be in "all". (That configuration does not arise in Go +// 1.11–1.15, but it will be possible in Go 1.16+.) +// +// Loading proceeds from the roots, using a parallel work-queue with a limit on +// the amount of active work (to avoid saturating disks, CPU cores, and/or +// network connections). Each package is added to the queue the first time it is +// imported by another package. When we have finished identifying the imports of +// a package, we add the test for that package if it is needed. A test may be +// needed if: +// - the package matches a root pattern and tests of the roots were requested, or +// - the package is in the main module and the "all" pattern is requested +// (because the "all" pattern includes the dependencies of tests in the main +// module), or +// - the package is in "all" and the definition of "all" we are using includes +// dependencies of tests (as is the case in Go ≤1.15). +// +// After all available packages have been loaded, we examine the results to +// identify any requested or imported packages that are still missing, and if +// so, which modules we could add to the module graph in order to make the +// missing packages available. We add those to the module graph and iterate, +// until either all packages resolve successfully or we cannot identify any +// module that would resolve any remaining missing package. +// +// If the main module is “tidy” (that is, if "go mod tidy" is a no-op for it) +// and all requested packages are in "all", then loading completes in a single +// iteration. +// TODO(bcmills): We should also be able to load in a single iteration if the +// requested packages all come from modules that are themselves tidy, regardless +// of whether those packages are in "all". Today, that requires two iterations +// if those packages are not found in existing dependencies of the main module. + +import ( + "context" + "errors" + "fmt" + "go/build" + "internal/diff" + "io/fs" + "maps" + "os" + pathpkg "path" + "path/filepath" + "runtime" + "slices" + "sort" + "strings" + "sync" + "sync/atomic" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/fips140" + "cmd/go/internal/fsys" + "cmd/go/internal/gover" + "cmd/go/internal/imports" + "cmd/go/internal/modfetch" + "cmd/go/internal/modindex" + "cmd/go/internal/mvs" + "cmd/go/internal/search" + "cmd/go/internal/str" + "cmd/internal/par" + + "golang.org/x/mod/module" +) + +// loaded is the most recently-used package loader. +// It holds details about individual packages. +// +// This variable should only be accessed directly in top-level exported +// functions. All other functions that require or produce a *loader should pass +// or return it as an explicit parameter. +var loaded *loader + +// PackageOpts control the behavior of the LoadPackages function. +type PackageOpts struct { + // TidyGoVersion is the Go version to which the go.mod file should be updated + // after packages have been loaded. + // + // An empty TidyGoVersion means to use the Go version already specified in the + // main module's go.mod file, or the latest Go version if there is no main + // module. + TidyGoVersion string + + // Tags are the build tags in effect (as interpreted by the + // cmd/go/internal/imports package). + // If nil, treated as equivalent to imports.Tags(). + Tags map[string]bool + + // Tidy, if true, requests that the build list and go.sum file be reduced to + // the minimal dependencies needed to reproducibly reload the requested + // packages. + Tidy bool + + // TidyDiff, if true, causes tidy not to modify go.mod or go.sum but + // instead print the necessary changes as a unified diff. It exits + // with a non-zero code if the diff is not empty. + TidyDiff bool + + // TidyCompatibleVersion is the oldest Go version that must be able to + // reproducibly reload the requested packages. + // + // If empty, the compatible version is the Go version immediately prior to the + // 'go' version listed in the go.mod file. + TidyCompatibleVersion string + + // VendorModulesInGOROOTSrc indicates that if we are within a module in + // GOROOT/src, packages in the module's vendor directory should be resolved as + // actual module dependencies (instead of standard-library packages). + VendorModulesInGOROOTSrc bool + + // ResolveMissingImports indicates that we should attempt to add module + // dependencies as needed to resolve imports of packages that are not found. + // + // For commands that support the -mod flag, resolving imports may still fail + // if the flag is set to "readonly" (the default) or "vendor". + ResolveMissingImports bool + + // AssumeRootsImported indicates that the transitive dependencies of the root + // packages should be treated as if those roots will be imported by the main + // module. + AssumeRootsImported bool + + // AllowPackage, if non-nil, is called after identifying the module providing + // each package. If AllowPackage returns a non-nil error, that error is set + // for the package, and the imports and test of that package will not be + // loaded. + // + // AllowPackage may be invoked concurrently by multiple goroutines, + // and may be invoked multiple times for a given package path. + AllowPackage func(ctx context.Context, path string, mod module.Version) error + + // LoadTests loads the test dependencies of each package matching a requested + // pattern. If ResolveMissingImports is also true, test dependencies will be + // resolved if missing. + LoadTests bool + + // UseVendorAll causes the "all" package pattern to be interpreted as if + // running "go mod vendor" (or building with "-mod=vendor"). + // + // This is a no-op for modules that declare 'go 1.16' or higher, for which this + // is the default (and only) interpretation of the "all" pattern in module mode. + UseVendorAll bool + + // AllowErrors indicates that LoadPackages should not terminate the process if + // an error occurs. + AllowErrors bool + + // SilencePackageErrors indicates that LoadPackages should not print errors + // that occur while matching or loading packages, and should not terminate the + // process if such an error occurs. + // + // Errors encountered in the module graph will still be reported. + // + // The caller may retrieve the silenced package errors using the Lookup + // function, and matching errors are still populated in the Errs field of the + // associated search.Match.) + SilencePackageErrors bool + + // SilenceMissingStdImports indicates that LoadPackages should not print + // errors or terminate the process if an imported package is missing, and the + // import path looks like it might be in the standard library (perhaps in a + // future version). + SilenceMissingStdImports bool + + // SilenceNoGoErrors indicates that LoadPackages should not print + // imports.ErrNoGo errors. + // This allows the caller to invoke LoadPackages (and report other errors) + // without knowing whether the requested packages exist for the given tags. + // + // Note that if a requested package does not exist *at all*, it will fail + // during module resolution and the error will not be suppressed. + SilenceNoGoErrors bool + + // SilenceUnmatchedWarnings suppresses the warnings normally emitted for + // patterns that did not match any packages. + SilenceUnmatchedWarnings bool + + // Resolve the query against this module. + MainModule module.Version + + // If Switcher is non-nil, then LoadPackages passes all encountered errors + // to Switcher.Error and tries Switcher.Switch before base.ExitIfErrors. + Switcher gover.Switcher +} + +// LoadPackages identifies the set of packages matching the given patterns and +// loads the packages in the import graph rooted at that set. +func LoadPackages(loaderstate *State, ctx context.Context, opts PackageOpts, patterns ...string) (matches []*search.Match, loadedPackages []string) { + if opts.Tags == nil { + opts.Tags = imports.Tags() + } + + patterns = search.CleanPatterns(patterns) + matches = make([]*search.Match, 0, len(patterns)) + allPatternIsRoot := false + for _, pattern := range patterns { + matches = append(matches, search.NewMatch(pattern)) + if pattern == "all" { + allPatternIsRoot = true + } + } + + updateMatches := func(rs *Requirements, ld *loader) { + for _, m := range matches { + switch { + case m.IsLocal(): + // Evaluate list of file system directories on first iteration. + if m.Dirs == nil { + matchModRoots := loaderstate.modRoots + if opts.MainModule != (module.Version{}) { + matchModRoots = []string{loaderstate.MainModules.ModRoot(opts.MainModule)} + } + matchLocalDirs(loaderstate, ctx, matchModRoots, m, rs) + } + + // Make a copy of the directory list and translate to import paths. + // Note that whether a directory corresponds to an import path + // changes as the build list is updated, and a directory can change + // from not being in the build list to being in it and back as + // the exact version of a particular module increases during + // the loader iterations. + m.Pkgs = m.Pkgs[:0] + for _, dir := range m.Dirs { + pkg, err := resolveLocalPackage(loaderstate, ctx, dir, rs) + if err != nil { + if !m.IsLiteral() && (err == errPkgIsBuiltin || err == errPkgIsGorootSrc) { + continue // Don't include "builtin" or GOROOT/src in wildcard patterns. + } + + // If we're outside of a module, ensure that the failure mode + // indicates that. + if !loaderstate.HasModRoot() { + die(loaderstate) + } + + if ld != nil { + m.AddError(err) + } + continue + } + m.Pkgs = append(m.Pkgs, pkg) + } + + case m.IsLiteral(): + m.Pkgs = []string{m.Pattern()} + + case strings.Contains(m.Pattern(), "..."): + m.Errs = m.Errs[:0] + mg, err := rs.Graph(loaderstate, ctx) + if err != nil { + // The module graph is (or may be) incomplete — perhaps we failed to + // load the requirements of some module. This is an error in matching + // the patterns to packages, because we may be missing some packages + // or we may erroneously match packages in the wrong versions of + // modules. However, for cases like 'go list -e', the error should not + // necessarily prevent us from loading the packages we could find. + m.Errs = append(m.Errs, err) + } + matchPackages(loaderstate, ctx, m, opts.Tags, includeStd, mg.BuildList()) + + case m.Pattern() == "work": + matchModules := loaderstate.MainModules.Versions() + if opts.MainModule != (module.Version{}) { + matchModules = []module.Version{opts.MainModule} + } + matchPackages(loaderstate, ctx, m, opts.Tags, omitStd, matchModules) + + case m.Pattern() == "all": + if ld == nil { + // The initial roots are the packages and tools in the main module. + // loadFromRoots will expand that to "all". + m.Errs = m.Errs[:0] + matchModules := loaderstate.MainModules.Versions() + if opts.MainModule != (module.Version{}) { + matchModules = []module.Version{opts.MainModule} + } + matchPackages(loaderstate, ctx, m, opts.Tags, omitStd, matchModules) + for tool := range loaderstate.MainModules.Tools() { + m.Pkgs = append(m.Pkgs, tool) + } + } else { + // Starting with the packages in the main module, + // enumerate the full list of "all". + m.Pkgs = ld.computePatternAll() + } + + case m.Pattern() == "std" || m.Pattern() == "cmd": + if m.Pkgs == nil { + m.MatchPackages() // Locate the packages within GOROOT/src. + } + + case m.Pattern() == "tool": + for tool := range loaderstate.MainModules.Tools() { + m.Pkgs = append(m.Pkgs, tool) + } + default: + panic(fmt.Sprintf("internal error: modload missing case for pattern %s", m.Pattern())) + } + } + } + + initialRS, err := loadModFile(loaderstate, ctx, &opts) + if err != nil { + base.Fatal(err) + } + + ld := loadFromRoots(loaderstate, ctx, loaderParams{ + PackageOpts: opts, + requirements: initialRS, + + allPatternIsRoot: allPatternIsRoot, + + listRoots: func(rs *Requirements) (roots []string) { + updateMatches(rs, nil) + for _, m := range matches { + roots = append(roots, m.Pkgs...) + } + return roots + }, + }) + + // One last pass to finalize wildcards. + updateMatches(ld.requirements, ld) + + // List errors in matching patterns (such as directory permission + // errors for wildcard patterns). + if !ld.SilencePackageErrors { + for _, match := range matches { + for _, err := range match.Errs { + ld.error(err) + } + } + } + ld.exitIfErrors(ctx) + + if !opts.SilenceUnmatchedWarnings { + search.WarnUnmatched(matches) + } + + if opts.Tidy { + if cfg.BuildV { + mg, _ := ld.requirements.Graph(loaderstate, ctx) + for _, m := range initialRS.rootModules { + var unused bool + if ld.requirements.pruning == unpruned { + // m is unused if it was dropped from the module graph entirely. If it + // was only demoted from direct to indirect, it may still be in use via + // a transitive import. + unused = mg.Selected(m.Path) == "none" + } else { + // m is unused if it was dropped from the roots. If it is still present + // as a transitive dependency, that transitive dependency is not needed + // by any package or test in the main module. + _, ok := ld.requirements.rootSelected(loaderstate, m.Path) + unused = !ok + } + if unused { + fmt.Fprintf(os.Stderr, "unused %s\n", m.Path) + } + } + } + + keep := keepSums(loaderstate, ctx, ld, ld.requirements, loadedZipSumsOnly) + compatVersion := ld.TidyCompatibleVersion + goVersion := ld.requirements.GoVersion(loaderstate) + if compatVersion == "" { + if gover.Compare(goVersion, gover.GoStrictVersion) < 0 { + compatVersion = gover.Prev(goVersion) + } else { + // Starting at GoStrictVersion, we no longer maintain compatibility with + // versions older than what is listed in the go.mod file. + compatVersion = goVersion + } + } + if gover.Compare(compatVersion, goVersion) > 0 { + // Each version of the Go toolchain knows how to interpret go.mod and + // go.sum files produced by all previous versions, so a compatibility + // version higher than the go.mod version adds nothing. + compatVersion = goVersion + } + if compatPruning := pruningForGoVersion(compatVersion); compatPruning != ld.requirements.pruning { + compatRS := newRequirements(loaderstate, compatPruning, ld.requirements.rootModules, ld.requirements.direct) + ld.checkTidyCompatibility(loaderstate, ctx, compatRS, compatVersion) + + for m := range keepSums(loaderstate, ctx, ld, compatRS, loadedZipSumsOnly) { + keep[m] = true + } + } + + if opts.TidyDiff { + cfg.BuildMod = "readonly" + loaded = ld + loaderstate.requirements = loaded.requirements + currentGoMod, updatedGoMod, _, err := UpdateGoModFromReqs(loaderstate, ctx, WriteOpts{}) + if err != nil { + base.Fatal(err) + } + goModDiff := diff.Diff("current/go.mod", currentGoMod, "tidy/go.mod", updatedGoMod) + + loaderstate.Fetcher().TrimGoSum(keep) + // Dropping compatibility for 1.16 may result in a strictly smaller go.sum. + // Update the keep map with only the loaded.requirements. + if gover.Compare(compatVersion, "1.16") > 0 { + keep = keepSums(loaderstate, ctx, loaded, loaderstate.requirements, addBuildListZipSums) + } + currentGoSum, tidyGoSum := loaderstate.fetcher.TidyGoSum(keep) + goSumDiff := diff.Diff("current/go.sum", currentGoSum, "tidy/go.sum", tidyGoSum) + + if len(goModDiff) > 0 { + fmt.Println(string(goModDiff)) + base.SetExitStatus(1) + } + if len(goSumDiff) > 0 { + fmt.Println(string(goSumDiff)) + base.SetExitStatus(1) + } + base.Exit() + } + + if !ExplicitWriteGoMod { + loaderstate.Fetcher().TrimGoSum(keep) + + // commitRequirements below will also call WriteGoSum, but the "keep" map + // we have here could be strictly larger: commitRequirements only commits + // loaded.requirements, but here we may have also loaded (and want to + // preserve checksums for) additional entities from compatRS, which are + // only needed for compatibility with ld.TidyCompatibleVersion. + if err := loaderstate.Fetcher().WriteGoSum(ctx, keep, mustHaveCompleteRequirements(loaderstate)); err != nil { + base.Fatal(err) + } + } + } + + if opts.TidyDiff && !opts.Tidy { + panic("TidyDiff is set but Tidy is not.") + } + + // Success! Update go.mod and go.sum (if needed) and return the results. + // We'll skip updating if ExplicitWriteGoMod is true (the caller has opted + // to call WriteGoMod itself) or if ResolveMissingImports is false (the + // command wants to examine the package graph as-is). + loaded = ld + loaderstate.requirements = loaded.requirements + + for _, pkg := range ld.pkgs { + if !pkg.isTest() { + loadedPackages = append(loadedPackages, pkg.path) + } + } + sort.Strings(loadedPackages) + + if !ExplicitWriteGoMod && opts.ResolveMissingImports { + if err := commitRequirements(loaderstate, ctx, WriteOpts{}); err != nil { + base.Fatal(err) + } + } + + return matches, loadedPackages +} + +// matchLocalDirs is like m.MatchDirs, but tries to avoid scanning directories +// outside of the standard library and active modules. +func matchLocalDirs(loaderstate *State, ctx context.Context, modRoots []string, m *search.Match, rs *Requirements) { + if !m.IsLocal() { + panic(fmt.Sprintf("internal error: resolveLocalDirs on non-local pattern %s", m.Pattern())) + } + + if i := strings.Index(m.Pattern(), "..."); i >= 0 { + // The pattern is local, but it is a wildcard. Its packages will + // only resolve to paths if they are inside of the standard + // library, the main module, or some dependency of the main + // module. Verify that before we walk the filesystem: a filesystem + // walk in a directory like /var or /etc can be very expensive! + dir := filepath.Dir(filepath.Clean(m.Pattern()[:i+3])) + absDir := dir + if !filepath.IsAbs(dir) { + absDir = filepath.Join(base.Cwd(), dir) + } + + modRoot := findModuleRoot(absDir) + if !slices.Contains(modRoots, modRoot) && search.InDir(absDir, cfg.GOROOTsrc) == "" && pathInModuleCache(loaderstate, ctx, absDir, rs) == "" { + m.Dirs = []string{} + scope := "main module or its selected dependencies" + if loaderstate.inWorkspaceMode() { + scope = "modules listed in go.work or their selected dependencies" + } + m.AddError(fmt.Errorf("directory prefix %s does not contain %s", base.ShortPath(absDir), scope)) + return + } + } + + m.MatchDirs(modRoots) +} + +// resolveLocalPackage resolves a filesystem path to a package path. +func resolveLocalPackage(loaderstate *State, ctx context.Context, dir string, rs *Requirements) (string, error) { + var absDir string + if filepath.IsAbs(dir) { + absDir = filepath.Clean(dir) + } else { + absDir = filepath.Join(base.Cwd(), dir) + } + + bp, err := cfg.BuildContext.ImportDir(absDir, 0) + if err != nil && (bp == nil || len(bp.IgnoredGoFiles) == 0) { + // golang.org/issue/32917: We should resolve a relative path to a + // package path only if the relative path actually contains the code + // for that package. + // + // If the named directory does not exist or contains no Go files, + // the package does not exist. + // Other errors may affect package loading, but not resolution. + if _, err := fsys.Stat(absDir); err != nil { + if os.IsNotExist(err) { + // Canonicalize OS-specific errors to errDirectoryNotFound so that error + // messages will be easier for users to search for. + return "", &fs.PathError{Op: "stat", Path: absDir, Err: errDirectoryNotFound} + } + return "", err + } + if _, noGo := err.(*build.NoGoError); noGo { + // A directory that does not contain any Go source files — even ignored + // ones! — is not a Go package, and we can't resolve it to a package + // path because that path could plausibly be provided by some other + // module. + // + // Any other error indicates that the package “exists” (at least in the + // sense that it cannot exist in any other module), but has some other + // problem (such as a syntax error). + return "", err + } + } + + for _, mod := range loaderstate.MainModules.Versions() { + modRoot := loaderstate.MainModules.ModRoot(mod) + if modRoot != "" && absDir == modRoot { + if absDir == cfg.GOROOTsrc { + return "", errPkgIsGorootSrc + } + return loaderstate.MainModules.PathPrefix(mod), nil + } + } + + // Note: The checks for @ here are just to avoid misinterpreting + // the module cache directories (formerly GOPATH/src/mod/foo@v1.5.2/bar). + // It's not strictly necessary but helpful to keep the checks. + var pkgNotFoundErr error + pkgNotFoundLongestPrefix := "" + for _, mainModule := range loaderstate.MainModules.Versions() { + modRoot := loaderstate.MainModules.ModRoot(mainModule) + if modRoot != "" && str.HasFilePathPrefix(absDir, modRoot) && !strings.Contains(absDir[len(modRoot):], "@") { + suffix := filepath.ToSlash(str.TrimFilePathPrefix(absDir, modRoot)) + if pkg, found := strings.CutPrefix(suffix, "vendor/"); found { + if cfg.BuildMod != "vendor" { + return "", fmt.Errorf("without -mod=vendor, directory %s has no package path", absDir) + } + + readVendorList(VendorDir(loaderstate)) + if _, ok := vendorPkgModule[pkg]; !ok { + return "", fmt.Errorf("directory %s is not a package listed in vendor/modules.txt", absDir) + } + return pkg, nil + } + + mainModulePrefix := loaderstate.MainModules.PathPrefix(mainModule) + if mainModulePrefix == "" { + pkg := suffix + if pkg == "builtin" { + // "builtin" is a pseudo-package with a real source file. + // It's not included in "std", so it shouldn't resolve from "." + // within module "std" either. + return "", errPkgIsBuiltin + } + return pkg, nil + } + + pkg := pathpkg.Join(mainModulePrefix, suffix) + if _, ok, err := dirInModule(pkg, mainModulePrefix, modRoot, true); err != nil { + return "", err + } else if !ok { + // This main module could contain the directory but doesn't. Other main + // modules might contain the directory, so wait till we finish the loop + // to see if another main module contains directory. But if not, + // return an error. + if len(mainModulePrefix) > len(pkgNotFoundLongestPrefix) { + pkgNotFoundLongestPrefix = mainModulePrefix + pkgNotFoundErr = &PackageNotInModuleError{MainModules: []module.Version{mainModule}, Pattern: pkg} + } + continue + } + return pkg, nil + } + } + if pkgNotFoundErr != nil { + return "", pkgNotFoundErr + } + + if sub := search.InDir(absDir, cfg.GOROOTsrc); sub != "" && sub != "." && !strings.Contains(sub, "@") { + pkg := filepath.ToSlash(sub) + if pkg == "builtin" { + return "", errPkgIsBuiltin + } + return pkg, nil + } + + pkg := pathInModuleCache(loaderstate, ctx, absDir, rs) + if pkg == "" { + dirstr := fmt.Sprintf("directory %s", base.ShortPath(absDir)) + if dirstr == "directory ." { + dirstr = "current directory" + } + if loaderstate.inWorkspaceMode() { + if mr := findModuleRoot(absDir); mr != "" { + return "", fmt.Errorf("%s is contained in a module that is not one of the workspace modules listed in go.work. You can add the module to the workspace using:\n\tgo work use %s", dirstr, base.ShortPath(mr)) + } + return "", fmt.Errorf("%s outside modules listed in go.work or their selected dependencies", dirstr) + } + return "", fmt.Errorf("%s outside main module or its selected dependencies", dirstr) + } + return pkg, nil +} + +var ( + errDirectoryNotFound = errors.New("directory not found") + errPkgIsGorootSrc = errors.New("GOROOT/src is not an importable package") + errPkgIsBuiltin = errors.New(`"builtin" is a pseudo-package, not an importable package`) +) + +// pathInModuleCache returns the import path of the directory dir, +// if dir is in the module cache copy of a module in our build list. +func pathInModuleCache(loaderstate *State, ctx context.Context, dir string, rs *Requirements) string { + tryMod := func(m module.Version) (string, bool) { + if gover.IsToolchain(m.Path) { + return "", false + } + var root string + var err error + if repl := Replacement(loaderstate, m); repl.Path != "" && repl.Version == "" { + root = repl.Path + if !filepath.IsAbs(root) { + root = filepath.Join(replaceRelativeTo(loaderstate), root) + } + } else if repl.Path != "" { + root, err = modfetch.DownloadDir(ctx, repl) + } else { + root, err = modfetch.DownloadDir(ctx, m) + } + if err != nil { + return "", false + } + + sub := search.InDir(dir, root) + if sub == "" { + return "", false + } + sub = filepath.ToSlash(sub) + if strings.Contains(sub, "/vendor/") || strings.HasPrefix(sub, "vendor/") || strings.Contains(sub, "@") { + return "", false + } + + return pathpkg.Join(m.Path, filepath.ToSlash(sub)), true + } + + if rs.pruning == pruned { + for _, m := range rs.rootModules { + if v, _ := rs.rootSelected(loaderstate, m.Path); v != m.Version { + continue // m is a root, but we have a higher root for the same path. + } + if importPath, ok := tryMod(m); ok { + // checkMultiplePaths ensures that a module can be used for at most one + // requirement, so this must be it. + return importPath + } + } + } + + // None of the roots contained dir, or the graph is unpruned (so we don't want + // to distinguish between roots and transitive dependencies). Either way, + // check the full graph to see if the directory is a non-root dependency. + // + // If the roots are not consistent with the full module graph, the selected + // versions of root modules may differ from what we already checked above. + // Re-check those paths too. + + mg, _ := rs.Graph(loaderstate, ctx) + var importPath string + for _, m := range mg.BuildList() { + var found bool + importPath, found = tryMod(m) + if found { + break + } + } + return importPath +} + +// ImportFromFiles adds modules to the build list as needed +// to satisfy the imports in the named Go source files. +// +// Errors in missing dependencies are silenced. +// +// TODO(bcmills): Silencing errors seems off. Take a closer look at this and +// figure out what the error-reporting actually ought to be. +func ImportFromFiles(loaderstate *State, ctx context.Context, gofiles []string) { + rs := LoadModFile(loaderstate, ctx) + + tags := imports.Tags() + imports, testImports, err := imports.ScanFiles(gofiles, tags) + if err != nil { + base.Fatal(err) + } + + loaded = loadFromRoots(loaderstate, ctx, loaderParams{ + PackageOpts: PackageOpts{ + Tags: tags, + ResolveMissingImports: true, + SilencePackageErrors: true, + }, + requirements: rs, + listRoots: func(*Requirements) (roots []string) { + roots = append(roots, imports...) + roots = append(roots, testImports...) + return roots + }, + }) + loaderstate.requirements = loaded.requirements + + if !ExplicitWriteGoMod { + if err := commitRequirements(loaderstate, ctx, WriteOpts{}); err != nil { + base.Fatal(err) + } + } +} + +// DirImportPath returns the effective import path for dir, +// provided it is within a main module, or else returns ".". +func (mms *MainModuleSet) DirImportPath(loaderstate *State, ctx context.Context, dir string) (path string, m module.Version) { + if !loaderstate.HasModRoot() { + return ".", module.Version{} + } + LoadModFile(loaderstate, ctx) // Sets targetPrefix. + + if !filepath.IsAbs(dir) { + dir = filepath.Join(base.Cwd(), dir) + } else { + dir = filepath.Clean(dir) + } + + var longestPrefix string + var longestPrefixPath string + var longestPrefixVersion module.Version + for _, v := range mms.Versions() { + modRoot := mms.ModRoot(v) + if dir == modRoot { + return mms.PathPrefix(v), v + } + if str.HasFilePathPrefix(dir, modRoot) { + pathPrefix := loaderstate.MainModules.PathPrefix(v) + if pathPrefix > longestPrefix { + longestPrefix = pathPrefix + longestPrefixVersion = v + suffix := filepath.ToSlash(str.TrimFilePathPrefix(dir, modRoot)) + if strings.HasPrefix(suffix, "vendor/") { + longestPrefixPath = suffix[len("vendor/"):] + continue + } + longestPrefixPath = pathpkg.Join(mms.PathPrefix(v), suffix) + } + } + } + if len(longestPrefix) > 0 { + return longestPrefixPath, longestPrefixVersion + } + + return ".", module.Version{} +} + +// PackageModule returns the module providing the package named by the import path. +func PackageModule(path string) module.Version { + pkg, ok := loaded.pkgCache.Get(path) + if !ok { + return module.Version{} + } + return pkg.mod +} + +// Lookup returns the source directory, import path, and any loading error for +// the package at path as imported from the package in parentDir. +// Lookup requires that one of the Load functions in this package has already +// been called. +func Lookup(loaderstate *State, parentPath string, parentIsStd bool, path string) (dir, realPath string, err error) { + if path == "" { + panic("Lookup called with empty package path") + } + + if parentIsStd { + path = loaded.stdVendor(loaderstate, parentPath, path) + } + pkg, ok := loaded.pkgCache.Get(path) + if !ok { + // The loader should have found all the relevant paths. + // There are a few exceptions, though: + // - during go list without -test, the p.Resolve calls to process p.TestImports and p.XTestImports + // end up here to canonicalize the import paths. + // - during any load, non-loaded packages like "unsafe" end up here. + // - during any load, build-injected dependencies like "runtime/cgo" end up here. + // - because we ignore appengine/* in the module loader, + // the dependencies of any actual appengine/* library end up here. + dir := findStandardImportPath(path) + if dir != "" { + return dir, path, nil + } + return "", "", errMissing + } + return pkg.dir, pkg.path, pkg.err +} + +// A loader manages the process of loading information about +// the required packages for a particular build, +// checking that the packages are available in the module set, +// and updating the module set if needed. +type loader struct { + loaderParams + + // allClosesOverTests indicates whether the "all" pattern includes + // dependencies of tests outside the main module (as in Go 1.11–1.15). + // (Otherwise — as in Go 1.16+ — the "all" pattern includes only the packages + // transitively *imported by* the packages and tests in the main module.) + allClosesOverTests bool + + // skipImportModFiles indicates whether we may skip loading go.mod files + // for imported packages (as in 'go mod tidy' in Go 1.17–1.20). + skipImportModFiles bool + + work *par.Queue + + // reset on each iteration + roots []*loadPkg + pkgCache *par.Cache[string, *loadPkg] + pkgs []*loadPkg // transitive closure of loaded packages and tests; populated in buildStacks +} + +// loaderParams configure the packages loaded by, and the properties reported +// by, a loader instance. +type loaderParams struct { + PackageOpts + requirements *Requirements + + allPatternIsRoot bool // Is the "all" pattern an additional root? + + listRoots func(rs *Requirements) []string +} + +func (ld *loader) reset() { + select { + case <-ld.work.Idle(): + default: + panic("loader.reset when not idle") + } + + ld.roots = nil + ld.pkgCache = new(par.Cache[string, *loadPkg]) + ld.pkgs = nil +} + +// error reports an error via either os.Stderr or base.Error, +// according to whether ld.AllowErrors is set. +func (ld *loader) error(err error) { + if ld.AllowErrors { + fmt.Fprintf(os.Stderr, "go: %v\n", err) + } else if ld.Switcher != nil { + ld.Switcher.Error(err) + } else { + base.Error(err) + } +} + +// switchIfErrors switches toolchains if a switch is needed. +func (ld *loader) switchIfErrors(ctx context.Context) { + if ld.Switcher != nil { + ld.Switcher.Switch(ctx) + } +} + +// exitIfErrors switches toolchains if a switch is needed +// or else exits if any errors have been reported. +func (ld *loader) exitIfErrors(ctx context.Context) { + ld.switchIfErrors(ctx) + base.ExitIfErrors() +} + +// goVersion reports the Go version that should be used for the loader's +// requirements: ld.TidyGoVersion if set, or ld.requirements.GoVersion() +// otherwise. +func (ld *loader) goVersion(loaderstate *State) string { + if ld.TidyGoVersion != "" { + return ld.TidyGoVersion + } + return ld.requirements.GoVersion(loaderstate) +} + +// A loadPkg records information about a single loaded package. +type loadPkg struct { + // Populated at construction time: + path string // import path + testOf *loadPkg + + // Populated at construction time and updated by (*loader).applyPkgFlags: + flags atomicLoadPkgFlags + + // Populated by (*loader).load: + mod module.Version // module providing package + dir string // directory containing source code + err error // error loading package + imports []*loadPkg // packages imported by this one + testImports []string // test-only imports, saved for use by pkg.test. + inStd bool + altMods []module.Version // modules that could have contained the package but did not + + // Populated by (*loader).pkgTest: + testOnce sync.Once + test *loadPkg + + // Populated by postprocessing in (*loader).buildStacks: + stack *loadPkg // package importing this one in minimal import stack for this pkg +} + +// loadPkgFlags is a set of flags tracking metadata about a package. +type loadPkgFlags int8 + +const ( + // pkgInAll indicates that the package is in the "all" package pattern, + // regardless of whether we are loading the "all" package pattern. + // + // When the pkgInAll flag and pkgImportsLoaded flags are both set, the caller + // who set the last of those flags must propagate the pkgInAll marking to all + // of the imports of the marked package. + // + // A test is marked with pkgInAll if that test would promote the packages it + // imports to be in "all" (such as when the test is itself within the main + // module, or when ld.allClosesOverTests is true). + pkgInAll loadPkgFlags = 1 << iota + + // pkgIsRoot indicates that the package matches one of the root package + // patterns requested by the caller. + // + // If LoadTests is set, then when pkgIsRoot and pkgImportsLoaded are both set, + // the caller who set the last of those flags must populate a test for the + // package (in the pkg.test field). + // + // If the "all" pattern is included as a root, then non-test packages in "all" + // are also roots (and must be marked pkgIsRoot). + pkgIsRoot + + // pkgFromRoot indicates that the package is in the transitive closure of + // imports starting at the roots. (Note that every package marked as pkgIsRoot + // is also trivially marked pkgFromRoot.) + pkgFromRoot + + // pkgImportsLoaded indicates that the imports and testImports fields of a + // loadPkg have been populated. + pkgImportsLoaded +) + +// has reports whether all of the flags in cond are set in f. +func (f loadPkgFlags) has(cond loadPkgFlags) bool { + return f&cond == cond +} + +// An atomicLoadPkgFlags stores a loadPkgFlags for which individual flags can be +// added atomically. +type atomicLoadPkgFlags struct { + bits atomic.Int32 +} + +// update sets the given flags in af (in addition to any flags already set). +// +// update returns the previous flag state so that the caller may determine which +// flags were newly-set. +func (af *atomicLoadPkgFlags) update(flags loadPkgFlags) (old loadPkgFlags) { + for { + old := af.bits.Load() + new := old | int32(flags) + if new == old || af.bits.CompareAndSwap(old, new) { + return loadPkgFlags(old) + } + } +} + +// has reports whether all of the flags in cond are set in af. +func (af *atomicLoadPkgFlags) has(cond loadPkgFlags) bool { + return loadPkgFlags(af.bits.Load())&cond == cond +} + +// isTest reports whether pkg is a test of another package. +func (pkg *loadPkg) isTest() bool { + return pkg.testOf != nil +} + +// fromExternalModule reports whether pkg was loaded from a module other than +// the main module. +func (pkg *loadPkg) fromExternalModule(loaderstate *State) bool { + if pkg.mod.Path == "" { + return false // loaded from the standard library, not a module + } + return !loaderstate.MainModules.Contains(pkg.mod.Path) +} + +var errMissing = errors.New("cannot find package") + +// loadFromRoots attempts to load the build graph needed to process a set of +// root packages and their dependencies. +// +// The set of root packages is returned by the params.listRoots function, and +// expanded to the full set of packages by tracing imports (and possibly tests) +// as needed. +func loadFromRoots(loaderstate *State, ctx context.Context, params loaderParams) *loader { + ld := &loader{ + loaderParams: params, + work: par.NewQueue(runtime.GOMAXPROCS(0)), + } + + if ld.requirements.pruning == unpruned { + // If the module graph does not support pruning, we assume that we will need + // the full module graph in order to load package dependencies. + // + // This might not be strictly necessary, but it matches the historical + // behavior of the 'go' command and keeps the go.mod file more consistent in + // case of erroneous hand-edits — which are less likely to be detected by + // spot-checks in modules that do not maintain the expanded go.mod + // requirements needed for graph pruning. + var err error + ld.requirements, _, err = expandGraph(loaderstate, ctx, ld.requirements) + if err != nil { + ld.error(err) + } + } + ld.exitIfErrors(ctx) + + updateGoVersion := func() { + goVersion := ld.goVersion(loaderstate) + + if ld.requirements.pruning != workspace { + var err error + ld.requirements, err = convertPruning(loaderstate, ctx, ld.requirements, pruningForGoVersion(goVersion)) + if err != nil { + ld.error(err) + ld.exitIfErrors(ctx) + } + } + + // If the module's Go version omits go.sum entries for go.mod files for test + // dependencies of external packages, avoid loading those files in the first + // place. + ld.skipImportModFiles = ld.Tidy && gover.Compare(goVersion, gover.TidyGoModSumVersion) < 0 + + // If the module's go version explicitly predates the change in "all" for + // graph pruning, continue to use the older interpretation. + ld.allClosesOverTests = gover.Compare(goVersion, gover.NarrowAllVersion) < 0 && !ld.UseVendorAll + } + + for { + ld.reset() + updateGoVersion() + + // Load the root packages and their imports. + // Note: the returned roots can change on each iteration, + // since the expansion of package patterns depends on the + // build list we're using. + rootPkgs := ld.listRoots(ld.requirements) + + if ld.requirements.pruning == pruned && cfg.BuildMod == "mod" { + // Before we start loading transitive imports of packages, locate all of + // the root packages and promote their containing modules to root modules + // dependencies. If their go.mod files are tidy (the common case) and the + // set of root packages does not change then we can select the correct + // versions of all transitive imports on the first try and complete + // loading in a single iteration. + changedBuildList := ld.preloadRootModules(loaderstate, ctx, rootPkgs) + if changedBuildList { + // The build list has changed, so the set of root packages may have also + // changed. Start over to pick up the changes. (Preloading roots is much + // cheaper than loading the full import graph, so we would rather pay + // for an extra iteration of preloading than potentially end up + // discarding the result of a full iteration of loading.) + continue + } + } + + inRoots := map[*loadPkg]bool{} + for _, path := range rootPkgs { + root := ld.pkg(loaderstate, ctx, path, pkgIsRoot) + if !inRoots[root] { + ld.roots = append(ld.roots, root) + inRoots[root] = true + } + } + + // ld.pkg adds imported packages to the work queue and calls applyPkgFlags, + // which adds tests (and test dependencies) as needed. + // + // When all of the work in the queue has completed, we'll know that the + // transitive closure of dependencies has been loaded. + <-ld.work.Idle() + + ld.buildStacks() + + changed, err := ld.updateRequirements(loaderstate, ctx) + if err != nil { + ld.error(err) + break + } + if changed { + // Don't resolve missing imports until the module graph has stabilized. + // If the roots are still changing, they may turn out to specify a + // requirement on the missing package(s), and we would rather use a + // version specified by a new root than add a new dependency on an + // unrelated version. + continue + } + + if !ld.ResolveMissingImports || (!loaderstate.HasModRoot() && !loaderstate.allowMissingModuleImports) { + // We've loaded as much as we can without resolving missing imports. + break + } + + modAddedBy, err := ld.resolveMissingImports(loaderstate, ctx) + if err != nil { + ld.error(err) + break + } + if len(modAddedBy) == 0 { + // The roots are stable, and we've resolved all of the missing packages + // that we can. + break + } + + toAdd := make([]module.Version, 0, len(modAddedBy)) + for m := range modAddedBy { + toAdd = append(toAdd, m) + } + gover.ModSort(toAdd) // to make errors deterministic + + // We ran updateRequirements before resolving missing imports and it didn't + // make any changes, so we know that the requirement graph is already + // consistent with ld.pkgs: we don't need to pass ld.pkgs to updateRoots + // again. (That would waste time looking for changes that we have already + // applied.) + var noPkgs []*loadPkg + // We also know that we're going to call updateRequirements again next + // iteration so we don't need to also update it here. (That would waste time + // computing a "direct" map that we'll have to recompute later anyway.) + direct := ld.requirements.direct + rs, err := updateRoots(loaderstate, ctx, direct, ld.requirements, noPkgs, toAdd, ld.AssumeRootsImported) + if err != nil { + // If an error was found in a newly added module, report the package + // import stack instead of the module requirement stack. Packages + // are more descriptive. + if err, ok := err.(*mvs.BuildListError); ok { + if pkg := modAddedBy[err.Module()]; pkg != nil { + ld.error(fmt.Errorf("%s: %w", pkg.stackText(), err.Err)) + break + } + } + ld.error(err) + break + } + if slices.Equal(rs.rootModules, ld.requirements.rootModules) { + // Something is deeply wrong. resolveMissingImports gave us a non-empty + // set of modules to add to the graph, but adding those modules had no + // effect — either they were already in the graph, or updateRoots did not + // add them as requested. + panic(fmt.Sprintf("internal error: adding %v to module graph had no effect on root requirements (%v)", toAdd, rs.rootModules)) + } + ld.requirements = rs + } + ld.exitIfErrors(ctx) + + // Tidy the build list, if applicable, before we report errors. + // (The process of tidying may remove errors from irrelevant dependencies.) + if ld.Tidy { + rs, err := tidyRoots(loaderstate, ctx, ld.requirements, ld.pkgs) + if err != nil { + ld.error(err) + } else { + if ld.TidyGoVersion != "" { + // Attempt to switch to the requested Go version. We have been using its + // pruning and semantics all along, but there may have been — and may + // still be — requirements on higher versions in the graph. + tidy := overrideRoots(loaderstate, ctx, rs, []module.Version{{Path: "go", Version: ld.TidyGoVersion}}) + mg, err := tidy.Graph(loaderstate, ctx) + if err != nil { + ld.error(err) + } + if v := mg.Selected("go"); v == ld.TidyGoVersion { + rs = tidy + } else { + conflict := Conflict{ + Path: mg.g.FindPath(func(m module.Version) bool { + return m.Path == "go" && m.Version == v + })[1:], + Constraint: module.Version{Path: "go", Version: ld.TidyGoVersion}, + } + msg := conflict.Summary() + if cfg.BuildV { + msg = conflict.String() + } + ld.error(errors.New(msg)) + } + } + + if ld.requirements.pruning == pruned { + // We continuously add tidy roots to ld.requirements during loading, so + // at this point the tidy roots (other than possibly the "go" version + // edited above) should be a subset of the roots of ld.requirements, + // ensuring that no new dependencies are brought inside the + // graph-pruning horizon. + // If that is not the case, there is a bug in the loading loop above. + for _, m := range rs.rootModules { + if m.Path == "go" && ld.TidyGoVersion != "" { + continue + } + if v, ok := ld.requirements.rootSelected(loaderstate, m.Path); !ok || v != m.Version { + ld.error(fmt.Errorf("internal error: a requirement on %v is needed but was not added during package loading (selected %s)", m, v)) + } + } + } + + ld.requirements = rs + } + + ld.exitIfErrors(ctx) + } + + // Report errors, if any. + for _, pkg := range ld.pkgs { + if pkg.err == nil { + continue + } + + // Add importer information to checksum errors. + if sumErr, ok := errors.AsType[*ImportMissingSumError](pkg.err); ok { + if importer := pkg.stack; importer != nil { + sumErr.importer = importer.path + sumErr.importerVersion = importer.mod.Version + sumErr.importerIsTest = importer.testOf != nil + } + } + + if stdErr, ok := errors.AsType[*ImportMissingError](pkg.err); ok && stdErr.isStd { + // Add importer go version information to import errors of standard + // library packages arising from newer releases. + if importer := pkg.stack; importer != nil { + if v, ok := rawGoVersion.Load(importer.mod); ok && gover.Compare(gover.Local(), v.(string)) < 0 { + stdErr.importerGoVersion = v.(string) + } + } + if ld.SilenceMissingStdImports { + continue + } + } + if ld.SilencePackageErrors { + continue + } + if ld.SilenceNoGoErrors && errors.Is(pkg.err, imports.ErrNoGo) { + continue + } + + ld.error(fmt.Errorf("%s: %w", pkg.stackText(), pkg.err)) + } + + ld.checkMultiplePaths(loaderstate) + return ld +} + +// updateRequirements ensures that ld.requirements is consistent with the +// information gained from ld.pkgs. +// +// In particular: +// +// - Modules that provide packages directly imported from the main module are +// marked as direct, and are promoted to explicit roots. If a needed root +// cannot be promoted due to -mod=readonly or -mod=vendor, the importing +// package is marked with an error. +// +// - If ld scanned the "all" pattern independent of build constraints, it is +// guaranteed to have seen every direct import. Module dependencies that did +// not provide any directly-imported package are then marked as indirect. +// +// - Root dependencies are updated to their selected versions. +// +// The "changed" return value reports whether the update changed the selected +// version of any module that either provided a loaded package or may now +// provide a package that was previously unresolved. +func (ld *loader) updateRequirements(loaderstate *State, ctx context.Context) (changed bool, err error) { + rs := ld.requirements + + // direct contains the set of modules believed to provide packages directly + // imported by the main module. + var direct map[string]bool + + // If we didn't scan all of the imports from the main module, or didn't use + // imports.AnyTags, then we didn't necessarily load every package that + // contributes “direct” imports — so we can't safely mark existing direct + // dependencies in ld.requirements as indirect-only. Propagate them as direct. + loadedDirect := ld.allPatternIsRoot && maps.Equal(ld.Tags, imports.AnyTags()) + if loadedDirect { + direct = make(map[string]bool) + } else { + // TODO(bcmills): It seems like a shame to allocate and copy a map here when + // it will only rarely actually vary from rs.direct. Measure this cost and + // maybe avoid the copy. + direct = make(map[string]bool, len(rs.direct)) + for mPath := range rs.direct { + direct[mPath] = true + } + } + + var maxTooNew *gover.TooNewError + for _, pkg := range ld.pkgs { + if pkg.err != nil { + if tooNew, ok := errors.AsType[*gover.TooNewError](pkg.err); ok { + if maxTooNew == nil || gover.Compare(tooNew.GoVersion, maxTooNew.GoVersion) > 0 { + maxTooNew = tooNew + } + } + } + if pkg.mod.Version != "" || !loaderstate.MainModules.Contains(pkg.mod.Path) { + continue + } + + for _, dep := range pkg.imports { + if !dep.fromExternalModule(loaderstate) { + continue + } + + if loaderstate.inWorkspaceMode() { + // In workspace mode / workspace pruning mode, the roots are the main modules + // rather than the main module's direct dependencies. The check below on the selected + // roots does not apply. + if cfg.BuildMod == "vendor" { + // In workspace vendor mode, we don't need to load the requirements of the workspace + // modules' dependencies so the check below doesn't work. But that's okay, because + // checking whether modules are required directly for the purposes of pruning is + // less important in vendor mode: if we were able to load the package, we have + // everything we need to build the package, and dependencies' tests are pruned out + // of the vendor directory anyway. + continue + } + if mg, err := rs.Graph(loaderstate, ctx); err != nil { + return false, err + } else if _, ok := mg.RequiredBy(dep.mod); !ok { + // dep.mod is not an explicit dependency, but needs to be. + // See comment on error returned below. + pkg.err = &DirectImportFromImplicitDependencyError{ + ImporterPath: pkg.path, + ImportedPath: dep.path, + Module: dep.mod, + } + } + } else if pkg.err == nil && cfg.BuildMod != "mod" { + if v, ok := rs.rootSelected(loaderstate, dep.mod.Path); !ok || v != dep.mod.Version { + // dep.mod is not an explicit dependency, but needs to be. + // Because we are not in "mod" mode, we will not be able to update it. + // Instead, mark the importing package with an error. + // + // TODO(#41688): The resulting error message fails to include the file + // position of the import statement (because that information is not + // tracked by the module loader). Figure out how to plumb the import + // position through. + pkg.err = &DirectImportFromImplicitDependencyError{ + ImporterPath: pkg.path, + ImportedPath: dep.path, + Module: dep.mod, + } + // cfg.BuildMod does not allow us to change dep.mod to be a direct + // dependency, so don't mark it as such. + continue + } + } + + // dep is a package directly imported by a package or test in the main + // module and loaded from some other module (not the standard library). + // Mark its module as a direct dependency. + direct[dep.mod.Path] = true + } + } + if maxTooNew != nil { + return false, maxTooNew + } + + var addRoots []module.Version + if ld.Tidy { + // When we are tidying a module with a pruned dependency graph, we may need + // to add roots to preserve the versions of indirect, test-only dependencies + // that are upgraded above or otherwise missing from the go.mod files of + // direct dependencies. (For example, the direct dependency might be a very + // stable codebase that predates modules and thus lacks a go.mod file, or + // the author of the direct dependency may have forgotten to commit a change + // to the go.mod file, or may have made an erroneous hand-edit that causes + // it to be untidy.) + // + // Promoting an indirect dependency to a root adds the next layer of its + // dependencies to the module graph, which may increase the selected + // versions of other modules from which we have already loaded packages. + // So after we promote an indirect dependency to a root, we need to reload + // packages, which means another iteration of loading. + // + // As an extra wrinkle, the upgrades due to promoting a root can cause + // previously-resolved packages to become unresolved. For example, the + // module providing an unstable package might be upgraded to a version + // that no longer contains that package. If we then resolve the missing + // package, we might add yet another root that upgrades away some other + // dependency. (The tests in mod_tidy_convergence*.txt illustrate some + // particularly worrisome cases.) + // + // To ensure that this process of promoting, adding, and upgrading roots + // eventually terminates, during iteration we only ever add modules to the + // root set — we only remove irrelevant roots at the very end of + // iteration, after we have already added every root that we plan to need + // in the (eventual) tidy root set. + // + // Since we do not remove any roots during iteration, even if they no + // longer provide any imported packages, the selected versions of the + // roots can only increase and the set of roots can only expand. The set + // of extant root paths is finite and the set of versions of each path is + // finite, so the iteration *must* reach a stable fixed-point. + tidy, err := tidyRoots(loaderstate, ctx, rs, ld.pkgs) + if err != nil { + return false, err + } + addRoots = tidy.rootModules + } + + rs, err = updateRoots(loaderstate, ctx, direct, rs, ld.pkgs, addRoots, ld.AssumeRootsImported) + if err != nil { + // We don't actually know what even the root requirements are supposed to be, + // so we can't proceed with loading. Return the error to the caller + return false, err + } + + if rs.GoVersion(loaderstate) != ld.requirements.GoVersion(loaderstate) { + // A change in the selected Go version may or may not affect the set of + // loaded packages, but in some cases it can change the meaning of the "all" + // pattern, the level of pruning in the module graph, and even the set of + // packages present in the standard library. If it has changed, it's best to + // reload packages once more to be sure everything is stable. + changed = true + } else if rs != ld.requirements && !slices.Equal(rs.rootModules, ld.requirements.rootModules) { + // The roots of the module graph have changed in some way (not just the + // "direct" markings). Check whether the changes affected any of the loaded + // packages. + mg, err := rs.Graph(loaderstate, ctx) + if err != nil { + return false, err + } + for _, pkg := range ld.pkgs { + if pkg.fromExternalModule(loaderstate) && mg.Selected(pkg.mod.Path) != pkg.mod.Version { + changed = true + break + } + if pkg.err != nil { + // Promoting a module to a root may resolve an import that was + // previously missing (by pulling in a previously-prune dependency that + // provides it) or ambiguous (by promoting exactly one of the + // alternatives to a root and ignoring the second-level alternatives) or + // otherwise errored out (by upgrading from a version that cannot be + // fetched to one that can be). + // + // Instead of enumerating all of the possible errors, we'll just check + // whether importFromModules returns nil for the package. + // False-positives are ok: if we have a false-positive here, we'll do an + // extra iteration of package loading this time, but we'll still + // converge when the root set stops changing. + // + // In some sense, we can think of this as ‘upgraded the module providing + // pkg.path from "none" to a version higher than "none"’. + if _, _, _, _, err = importFromModules(loaderstate, ctx, pkg.path, rs, nil, ld.skipImportModFiles); err == nil { + changed = true + break + } + } + } + } + + ld.requirements = rs + return changed, nil +} + +// resolveMissingImports returns a set of modules that could be added as +// dependencies in order to resolve missing packages from pkgs. +// +// The newly-resolved packages are added to the addedModuleFor map, and +// resolveMissingImports returns a map from each new module version to +// the first missing package that module would resolve. +func (ld *loader) resolveMissingImports(loaderstate *State, ctx context.Context) (modAddedBy map[module.Version]*loadPkg, err error) { + type pkgMod struct { + pkg *loadPkg + mod *module.Version + } + var pkgMods []pkgMod + for _, pkg := range ld.pkgs { + if pkg.err == nil { + continue + } + if pkg.isTest() { + // If we are missing a test, we are also missing its non-test version, and + // we should only add the missing import once. + continue + } + if _, ok := errors.AsType[*ImportMissingError](pkg.err); !ok { + // Leave other errors for Import or load.Packages to report. + continue + } + + pkg := pkg + var mod module.Version + ld.work.Add(func() { + var err error + mod, err = queryImport(loaderstate, ctx, pkg.path, ld.requirements) + if err != nil { + if ime, ok := errors.AsType[*ImportMissingError](err); ok { + for curstack := pkg.stack; curstack != nil; curstack = curstack.stack { + if loaderstate.MainModules.Contains(curstack.mod.Path) { + ime.ImportingMainModule = curstack.mod + ime.modRoot = loaderstate.MainModules.ModRoot(ime.ImportingMainModule) + break + } + } + } + // pkg.err was already non-nil, so we can reasonably attribute the error + // for pkg to either the original error or the one returned by + // queryImport. The existing error indicates only that we couldn't find + // the package, whereas the query error also explains why we didn't fix + // the problem — so we prefer the latter. + pkg.err = err + } + + // err is nil, but we intentionally leave pkg.err non-nil and pkg.mod + // unset: we still haven't satisfied other invariants of a + // successfully-loaded package, such as scanning and loading the imports + // of that package. If we succeed in resolving the new dependency graph, + // the caller can reload pkg and update the error at that point. + // + // Even then, the package might not be loaded from the version we've + // identified here. The module may be upgraded by some other dependency, + // or by a transitive dependency of mod itself, or — less likely — the + // package may be rejected by an AllowPackage hook or rendered ambiguous + // by some other newly-added or newly-upgraded dependency. + }) + + pkgMods = append(pkgMods, pkgMod{pkg: pkg, mod: &mod}) + } + <-ld.work.Idle() + + modAddedBy = map[module.Version]*loadPkg{} + + var ( + maxTooNew *gover.TooNewError + maxTooNewPkg *loadPkg + ) + for _, pm := range pkgMods { + if tooNew, ok := errors.AsType[*gover.TooNewError](pm.pkg.err); ok { + if maxTooNew == nil || gover.Compare(tooNew.GoVersion, maxTooNew.GoVersion) > 0 { + maxTooNew = tooNew + maxTooNewPkg = pm.pkg + } + } + } + if maxTooNew != nil { + fmt.Fprintf(os.Stderr, "go: toolchain upgrade needed to resolve %s\n", maxTooNewPkg.path) + return nil, maxTooNew + } + + for _, pm := range pkgMods { + pkg, mod := pm.pkg, *pm.mod + if mod.Path == "" { + continue + } + + fmt.Fprintf(os.Stderr, "go: found %s in %s %s\n", pkg.path, mod.Path, mod.Version) + if modAddedBy[mod] == nil { + modAddedBy[mod] = pkg + } + } + + return modAddedBy, nil +} + +// pkg locates the *loadPkg for path, creating and queuing it for loading if +// needed, and updates its state to reflect the given flags. +// +// The imports of the returned *loadPkg will be loaded asynchronously in the +// ld.work queue, and its test (if requested) will also be populated once +// imports have been resolved. When ld.work goes idle, all transitive imports of +// the requested package (and its test, if requested) will have been loaded. +func (ld *loader) pkg(loaderstate *State, ctx context.Context, path string, flags loadPkgFlags) *loadPkg { + if flags.has(pkgImportsLoaded) { + panic("internal error: (*loader).pkg called with pkgImportsLoaded flag set") + } + + pkg := ld.pkgCache.Do(path, func() *loadPkg { + pkg := &loadPkg{ + path: path, + } + ld.applyPkgFlags(loaderstate, ctx, pkg, flags) + + ld.work.Add(func() { ld.load(loaderstate, ctx, pkg) }) + return pkg + }) + + ld.applyPkgFlags(loaderstate, ctx, pkg, flags) + return pkg +} + +// applyPkgFlags updates pkg.flags to set the given flags and propagate the +// (transitive) effects of those flags, possibly loading or enqueueing further +// packages as a result. +func (ld *loader) applyPkgFlags(loaderstate *State, ctx context.Context, pkg *loadPkg, flags loadPkgFlags) { + if flags == 0 { + return + } + + if flags.has(pkgInAll) && ld.allPatternIsRoot && !pkg.isTest() { + // This package matches a root pattern by virtue of being in "all". + flags |= pkgIsRoot + } + if flags.has(pkgIsRoot) { + flags |= pkgFromRoot + } + + old := pkg.flags.update(flags) + new := old | flags + if new == old || !new.has(pkgImportsLoaded) { + // We either didn't change the state of pkg, or we don't know anything about + // its dependencies yet. Either way, we can't usefully load its test or + // update its dependencies. + return + } + + if !pkg.isTest() { + // Check whether we should add (or update the flags for) a test for pkg. + // ld.pkgTest is idempotent and extra invocations are inexpensive, + // so it's ok if we call it more than is strictly necessary. + wantTest := false + switch { + case ld.allPatternIsRoot && loaderstate.MainModules.Contains(pkg.mod.Path): + // We are loading the "all" pattern, which includes packages imported by + // tests in the main module. This package is in the main module, so we + // need to identify the imports of its test even if LoadTests is not set. + // + // (We will filter out the extra tests explicitly in computePatternAll.) + wantTest = true + + case ld.allPatternIsRoot && ld.allClosesOverTests && new.has(pkgInAll): + // This variant of the "all" pattern includes imports of tests of every + // package that is itself in "all", and pkg is in "all", so its test is + // also in "all" (as above). + wantTest = true + + case ld.LoadTests && new.has(pkgIsRoot): + // LoadTest explicitly requests tests of “the root packages”. + wantTest = true + } + + if wantTest { + var testFlags loadPkgFlags + if loaderstate.MainModules.Contains(pkg.mod.Path) || (ld.allClosesOverTests && new.has(pkgInAll)) { + // Tests of packages in the main module are in "all", in the sense that + // they cause the packages they import to also be in "all". So are tests + // of packages in "all" if "all" closes over test dependencies. + testFlags |= pkgInAll + } + ld.pkgTest(loaderstate, ctx, pkg, testFlags) + } + } + + if new.has(pkgInAll) && !old.has(pkgInAll|pkgImportsLoaded) { + // We have just marked pkg with pkgInAll, or we have just loaded its + // imports, or both. Now is the time to propagate pkgInAll to the imports. + for _, dep := range pkg.imports { + ld.applyPkgFlags(loaderstate, ctx, dep, pkgInAll) + } + } + + if new.has(pkgFromRoot) && !old.has(pkgFromRoot|pkgImportsLoaded) { + for _, dep := range pkg.imports { + ld.applyPkgFlags(loaderstate, ctx, dep, pkgFromRoot) + } + } +} + +// preloadRootModules loads the module requirements needed to identify the +// selected version of each module providing a package in rootPkgs, +// adding new root modules to the module graph if needed. +func (ld *loader) preloadRootModules(loaderstate *State, ctx context.Context, rootPkgs []string) (changedBuildList bool) { + needc := make(chan map[module.Version]bool, 1) + needc <- map[module.Version]bool{} + for _, path := range rootPkgs { + path := path + ld.work.Add(func() { + // First, try to identify the module containing the package using only roots. + // + // If the main module is tidy and the package is in "all" — or if we're + // lucky — we can identify all of its imports without actually loading the + // full module graph. + m, _, _, _, err := importFromModules(loaderstate, ctx, path, ld.requirements, nil, ld.skipImportModFiles) + if err != nil { + if _, ok := errors.AsType[*ImportMissingError](err); ok && ld.ResolveMissingImports { + // This package isn't provided by any selected module. + // If we can find it, it will be a new root dependency. + m, err = queryImport(loaderstate, ctx, path, ld.requirements) + } + if err != nil { + // We couldn't identify the root module containing this package. + // Leave it unresolved; we will report it during loading. + return + } + } + if m.Path == "" { + // The package is in std or cmd. We don't need to change the root set. + return + } + + v, ok := ld.requirements.rootSelected(loaderstate, m.Path) + if !ok || v != m.Version { + // We found the requested package in m, but m is not a root, so + // loadModGraph will not load its requirements. We need to promote the + // module to a root to ensure that any other packages this package + // imports are resolved from correct dependency versions. + // + // (This is the “argument invariant” from + // https://golang.org/design/36460-lazy-module-loading.) + need := <-needc + need[m] = true + needc <- need + } + }) + } + <-ld.work.Idle() + + need := <-needc + if len(need) == 0 { + return false // No roots to add. + } + + toAdd := make([]module.Version, 0, len(need)) + for m := range need { + toAdd = append(toAdd, m) + } + gover.ModSort(toAdd) + + rs, err := updateRoots(loaderstate, ctx, ld.requirements.direct, ld.requirements, nil, toAdd, ld.AssumeRootsImported) + if err != nil { + // We are missing some root dependency, and for some reason we can't load + // enough of the module dependency graph to add the missing root. Package + // loading is doomed to fail, so fail quickly. + ld.error(err) + ld.exitIfErrors(ctx) + return false + } + if slices.Equal(rs.rootModules, ld.requirements.rootModules) { + // Something is deeply wrong. resolveMissingImports gave us a non-empty + // set of modules to add to the graph, but adding those modules had no + // effect — either they were already in the graph, or updateRoots did not + // add them as requested. + panic(fmt.Sprintf("internal error: adding %v to module graph had no effect on root requirements (%v)", toAdd, rs.rootModules)) + } + + ld.requirements = rs + return true +} + +// load loads an individual package. +func (ld *loader) load(loaderstate *State, ctx context.Context, pkg *loadPkg) { + var mg *ModuleGraph + if ld.requirements.pruning == unpruned { + var err error + mg, err = ld.requirements.Graph(loaderstate, ctx) + if err != nil { + // We already checked the error from Graph in loadFromRoots and/or + // updateRequirements, so we ignored the error on purpose and we should + // keep trying to push past it. + // + // However, because mg may be incomplete (and thus may select inaccurate + // versions), we shouldn't use it to load packages. Instead, we pass a nil + // *ModuleGraph, which will cause mg to first try loading from only the + // main module and root dependencies. + mg = nil + } + } + + var modroot string + pkg.mod, modroot, pkg.dir, pkg.altMods, pkg.err = importFromModules(loaderstate, ctx, pkg.path, ld.requirements, mg, ld.skipImportModFiles) + if loaderstate.MainModules.Tools()[pkg.path] { + // Tools declared by main modules are always in "all". + // We apply the package flags before returning so that missing + // tool dependencies report an error https://go.dev/issue/70582 + ld.applyPkgFlags(loaderstate, ctx, pkg, pkgInAll) + } + if pkg.dir == "" { + return + } + if loaderstate.MainModules.Contains(pkg.mod.Path) { + // Go ahead and mark pkg as in "all". This provides the invariant that a + // package that is *only* imported by other packages in "all" is always + // marked as such before loading its imports. + // + // We don't actually rely on that invariant at the moment, but it may + // improve efficiency somewhat and makes the behavior a bit easier to reason + // about (by reducing churn on the flag bits of dependencies), and costs + // essentially nothing (these atomic flag ops are essentially free compared + // to scanning source code for imports). + ld.applyPkgFlags(loaderstate, ctx, pkg, pkgInAll) + } + if ld.AllowPackage != nil { + if err := ld.AllowPackage(ctx, pkg.path, pkg.mod); err != nil { + pkg.err = err + } + } + + pkg.inStd = (search.IsStandardImportPath(pkg.path) && search.InDir(pkg.dir, cfg.GOROOTsrc) != "") + + var imports, testImports []string + + if cfg.BuildContext.Compiler == "gccgo" && pkg.inStd { + // We can't scan standard packages for gccgo. + } else { + var err error + imports, testImports, err = scanDir(modroot, pkg.dir, ld.Tags) + if err != nil { + pkg.err = err + return + } + } + + pkg.imports = make([]*loadPkg, 0, len(imports)) + var importFlags loadPkgFlags + if pkg.flags.has(pkgInAll) { + importFlags = pkgInAll + } + for _, path := range imports { + if pkg.inStd { + // Imports from packages in "std" and "cmd" should resolve using + // GOROOT/src/vendor even when "std" is not the main module. + path = ld.stdVendor(loaderstate, pkg.path, path) + } + pkg.imports = append(pkg.imports, ld.pkg(loaderstate, ctx, path, importFlags)) + } + pkg.testImports = testImports + + ld.applyPkgFlags(loaderstate, ctx, pkg, pkgImportsLoaded) +} + +// pkgTest locates the test of pkg, creating it if needed, and updates its state +// to reflect the given flags. +// +// pkgTest requires that the imports of pkg have already been loaded (flagged +// with pkgImportsLoaded). +func (ld *loader) pkgTest(loaderstate *State, ctx context.Context, pkg *loadPkg, testFlags loadPkgFlags) *loadPkg { + if pkg.isTest() { + panic("pkgTest called on a test package") + } + + createdTest := false + pkg.testOnce.Do(func() { + pkg.test = &loadPkg{ + path: pkg.path, + testOf: pkg, + mod: pkg.mod, + dir: pkg.dir, + err: pkg.err, + inStd: pkg.inStd, + } + ld.applyPkgFlags(loaderstate, ctx, pkg.test, testFlags) + createdTest = true + }) + + test := pkg.test + if createdTest { + test.imports = make([]*loadPkg, 0, len(pkg.testImports)) + var importFlags loadPkgFlags + if test.flags.has(pkgInAll) { + importFlags = pkgInAll + } + for _, path := range pkg.testImports { + if pkg.inStd { + path = ld.stdVendor(loaderstate, test.path, path) + } + test.imports = append(test.imports, ld.pkg(loaderstate, ctx, path, importFlags)) + } + pkg.testImports = nil + ld.applyPkgFlags(loaderstate, ctx, test, pkgImportsLoaded) + } else { + ld.applyPkgFlags(loaderstate, ctx, test, testFlags) + } + + return test +} + +// stdVendor returns the canonical import path for the package with the given +// path when imported from the standard-library package at parentPath. +func (ld *loader) stdVendor(loaderstate *State, parentPath, path string) string { + if p, _, ok := fips140.ResolveImport(path); ok { + return p + } + if search.IsStandardImportPath(path) { + return path + } + + if str.HasPathPrefix(parentPath, "cmd") { + if !ld.VendorModulesInGOROOTSrc || !loaderstate.MainModules.Contains("cmd") { + vendorPath := pathpkg.Join("cmd", "vendor", path) + + if _, err := os.Stat(filepath.Join(cfg.GOROOTsrc, filepath.FromSlash(vendorPath))); err == nil { + return vendorPath + } + } + } else if !ld.VendorModulesInGOROOTSrc || !loaderstate.MainModules.Contains("std") || str.HasPathPrefix(parentPath, "vendor") { + // If we are outside of the 'std' module, resolve imports from within 'std' + // to the vendor directory. + // + // Do the same for importers beginning with the prefix 'vendor/' even if we + // are *inside* of the 'std' module: the 'vendor/' packages that resolve + // globally from GOROOT/src/vendor (and are listed as part of 'go list std') + // are distinct from the real module dependencies, and cannot import + // internal packages from the real module. + // + // (Note that although the 'vendor/' packages match the 'std' *package* + // pattern, they are not part of the std *module*, and do not affect + // 'go mod tidy' and similar module commands when working within std.) + vendorPath := pathpkg.Join("vendor", path) + if _, err := os.Stat(filepath.Join(cfg.GOROOTsrc, filepath.FromSlash(vendorPath))); err == nil { + return vendorPath + } + } + + // Not vendored: resolve from modules. + return path +} + +// computePatternAll returns the list of packages matching pattern "all", +// starting with a list of the import paths for the packages in the main module. +func (ld *loader) computePatternAll() (all []string) { + for _, pkg := range ld.pkgs { + if module.CheckImportPath(pkg.path) != nil { + // Don't add packages with invalid paths. This means that + // we don't try to load invalid imports of the main modules' + // packages. We will still report an errors invalid imports + // when we load the importing package. + continue + } + if pkg.flags.has(pkgInAll) && !pkg.isTest() { + all = append(all, pkg.path) + } + } + sort.Strings(all) + return all +} + +// checkMultiplePaths verifies that a given module path is used as itself +// or as a replacement for another module, but not both at the same time. +// +// (See https://golang.org/issue/26607 and https://golang.org/issue/34650.) +func (ld *loader) checkMultiplePaths(loaderstate *State) { + mods := ld.requirements.rootModules + if cached := ld.requirements.graph.Load(); cached != nil { + if mg := cached.mg; mg != nil { + mods = mg.BuildList() + } + } + + firstPath := map[module.Version]string{} + for _, mod := range mods { + src := resolveReplacement(loaderstate, mod) + if prev, ok := firstPath[src]; !ok { + firstPath[src] = mod.Path + } else if prev != mod.Path { + ld.error(fmt.Errorf("%s@%s used for two different module paths (%s and %s)", src.Path, src.Version, prev, mod.Path)) + } + } +} + +// checkTidyCompatibility emits an error if any package would be loaded from a +// different module under rs than under ld.requirements. +func (ld *loader) checkTidyCompatibility(loaderstate *State, ctx context.Context, rs *Requirements, compatVersion string) { + goVersion := rs.GoVersion(loaderstate) + suggestUpgrade := false + suggestEFlag := false + suggestFixes := func() { + if ld.AllowErrors { + // The user is explicitly ignoring these errors, so don't bother them with + // other options. + return + } + + // We print directly to os.Stderr because this information is advice about + // how to fix errors, not actually an error itself. + // (The actual errors should have been logged already.) + + fmt.Fprintln(os.Stderr) + + goFlag := "" + if goVersion != loaderstate.MainModules.GoVersion(loaderstate) { + goFlag = " -go=" + goVersion + } + + compatFlag := "" + if compatVersion != gover.Prev(goVersion) { + compatFlag = " -compat=" + compatVersion + } + if suggestUpgrade { + eDesc := "" + eFlag := "" + if suggestEFlag { + eDesc = ", leaving some packages unresolved" + eFlag = " -e" + } + fmt.Fprintf(os.Stderr, "To upgrade to the versions selected by go %s%s:\n\tgo mod tidy%s -go=%s && go mod tidy%s -go=%s%s\n", compatVersion, eDesc, eFlag, compatVersion, eFlag, goVersion, compatFlag) + } else if suggestEFlag { + // If some packages are missing but no package is upgraded, then we + // shouldn't suggest upgrading to the Go 1.16 versions explicitly — that + // wouldn't actually fix anything for Go 1.16 users, and *would* break + // something for Go 1.17 users. + fmt.Fprintf(os.Stderr, "To proceed despite packages unresolved in go %s:\n\tgo mod tidy -e%s%s\n", compatVersion, goFlag, compatFlag) + } + + fmt.Fprintf(os.Stderr, "If reproducibility with go %s is not needed:\n\tgo mod tidy%s -compat=%s\n", compatVersion, goFlag, goVersion) + + fmt.Fprintf(os.Stderr, "For information about 'go mod tidy' compatibility, see:\n\thttps://go.dev/ref/mod#graph-pruning\n") + } + + mg, err := rs.Graph(loaderstate, ctx) + if err != nil { + ld.error(fmt.Errorf("error loading go %s module graph: %w", compatVersion, err)) + ld.switchIfErrors(ctx) + suggestFixes() + ld.exitIfErrors(ctx) + return + } + + // Re-resolve packages in parallel. + // + // We re-resolve each package — rather than just checking versions — to ensure + // that we have fetched module source code (and, importantly, checksums for + // that source code) for all modules that are necessary to ensure that imports + // are unambiguous. That also produces clearer diagnostics, since we can say + // exactly what happened to the package if it became ambiguous or disappeared + // entirely. + // + // We re-resolve the packages in parallel because this process involves disk + // I/O to check for package sources, and because the process of checking for + // ambiguous imports may require us to download additional modules that are + // otherwise pruned out in Go 1.17 — we don't want to block progress on other + // packages while we wait for a single new download. + type mismatch struct { + mod module.Version + err error + } + mismatchMu := make(chan map[*loadPkg]mismatch, 1) + mismatchMu <- map[*loadPkg]mismatch{} + for _, pkg := range ld.pkgs { + if pkg.mod.Path == "" && pkg.err == nil { + // This package is from the standard library (which does not vary based on + // the module graph). + continue + } + + pkg := pkg + ld.work.Add(func() { + mod, _, _, _, err := importFromModules(loaderstate, ctx, pkg.path, rs, mg, ld.skipImportModFiles) + if mod != pkg.mod { + mismatches := <-mismatchMu + mismatches[pkg] = mismatch{mod: mod, err: err} + mismatchMu <- mismatches + } + }) + } + <-ld.work.Idle() + + mismatches := <-mismatchMu + if len(mismatches) == 0 { + // Since we're running as part of 'go mod tidy', the roots of the module + // graph should contain only modules that are relevant to some package in + // the package graph. We checked every package in the package graph and + // didn't find any mismatches, so that must mean that all of the roots of + // the module graph are also consistent. + // + // If we're wrong, Go 1.16 in -mod=readonly mode will error out with + // "updates to go.mod needed", which would be very confusing. So instead, + // we'll double-check that our reasoning above actually holds — if it + // doesn't, we'll emit an internal error and hopefully the user will report + // it as a bug. + for _, m := range ld.requirements.rootModules { + if v := mg.Selected(m.Path); v != m.Version { + fmt.Fprintln(os.Stderr) + base.Fatalf("go: internal error: failed to diagnose selected-version mismatch for module %s: go %s selects %s, but go %s selects %s\n\tPlease report this at https://golang.org/issue.", m.Path, goVersion, m.Version, compatVersion, v) + } + } + return + } + + // Iterate over the packages (instead of the mismatches map) to emit errors in + // deterministic order. + for _, pkg := range ld.pkgs { + mismatch, ok := mismatches[pkg] + if !ok { + continue + } + + if pkg.isTest() { + // We already did (or will) report an error for the package itself, + // so don't report a duplicate (and more verbose) error for its test. + if _, ok := mismatches[pkg.testOf]; !ok { + base.Fatalf("go: internal error: mismatch recorded for test %s, but not its non-test package", pkg.path) + } + continue + } + + switch { + case mismatch.err != nil: + // pkg resolved successfully, but errors out using the requirements in rs. + // + // This could occur because the import is provided by a single root (and + // is thus unambiguous in a main module with a pruned module graph) and + // also one or more transitive dependencies (and is ambiguous with an + // unpruned graph). + // + // It could also occur because some transitive dependency upgrades the + // module that previously provided the package to a version that no + // longer does, or to a version for which the module source code (but + // not the go.mod file in isolation) has a checksum error. + if _, ok := errors.AsType[*ImportMissingError](mismatch.err); ok { + selected := module.Version{ + Path: pkg.mod.Path, + Version: mg.Selected(pkg.mod.Path), + } + ld.error(fmt.Errorf("%s loaded from %v,\n\tbut go %s would fail to locate it in %s", pkg.stackText(), pkg.mod, compatVersion, selected)) + } else { + if _, ok := errors.AsType[*AmbiguousImportError](mismatch.err); ok { + // TODO: Is this check needed? + } + ld.error(fmt.Errorf("%s loaded from %v,\n\tbut go %s would fail to locate it:\n\t%v", pkg.stackText(), pkg.mod, compatVersion, mismatch.err)) + } + + suggestEFlag = true + + // Even if we press ahead with the '-e' flag, the older version will + // error out in readonly mode if it thinks the go.mod file contains + // any *explicit* dependency that is not at its selected version, + // even if that dependency is not relevant to any package being loaded. + // + // We check for that condition here. If all of the roots are consistent + // the '-e' flag suffices, but otherwise we need to suggest an upgrade. + if !suggestUpgrade { + for _, m := range ld.requirements.rootModules { + if v := mg.Selected(m.Path); v != m.Version { + suggestUpgrade = true + break + } + } + } + + case pkg.err != nil: + // pkg had an error in with a pruned module graph (presumably suppressed + // with the -e flag), but the error went away using an unpruned graph. + // + // This is possible, if, say, the import is unresolved in the pruned graph + // (because the "latest" version of each candidate module either is + // unavailable or does not contain the package), but is resolved in the + // unpruned graph due to a newer-than-latest dependency that is normally + // pruned out. + // + // This could also occur if the source code for the module providing the + // package in the pruned graph has a checksum error, but the unpruned + // graph upgrades that module to a version with a correct checksum. + // + // pkg.err should have already been logged elsewhere — along with a + // stack trace — so log only the import path and non-error info here. + suggestUpgrade = true + ld.error(fmt.Errorf("%s failed to load from any module,\n\tbut go %s would load it from %v", pkg.path, compatVersion, mismatch.mod)) + + case pkg.mod != mismatch.mod: + // The package is loaded successfully by both Go versions, but from a + // different module in each. This could lead to subtle (and perhaps even + // unnoticed!) variations in behavior between builds with different + // toolchains. + suggestUpgrade = true + ld.error(fmt.Errorf("%s loaded from %v,\n\tbut go %s would select %v\n", pkg.stackText(), pkg.mod, compatVersion, mismatch.mod.Version)) + + default: + base.Fatalf("go: internal error: mismatch recorded for package %s, but no differences found", pkg.path) + } + } + + ld.switchIfErrors(ctx) + suggestFixes() + ld.exitIfErrors(ctx) +} + +// scanDir is like imports.ScanDir but elides known magic imports from the list, +// so that we do not go looking for packages that don't really exist. +// +// The standard magic import is "C", for cgo. +// +// The only other known magic imports are appengine and appengine/*. +// These are so old that they predate "go get" and did not use URL-like paths. +// Most code today now uses google.golang.org/appengine instead, +// but not all code has been so updated. When we mostly ignore build tags +// during "go vendor", we look into "// +build appengine" files and +// may see these legacy imports. We drop them so that the module +// search does not look for modules to try to satisfy them. +func scanDir(modroot string, dir string, tags map[string]bool) (imports_, testImports []string, err error) { + if ip, mierr := modindex.GetPackage(modroot, dir); mierr == nil { + imports_, testImports, err = ip.ScanDir(tags) + goto Happy + } else if !errors.Is(mierr, modindex.ErrNotIndexed) { + return nil, nil, mierr + } + + imports_, testImports, err = imports.ScanDir(dir, tags) +Happy: + + filter := func(x []string) []string { + w := 0 + for _, pkg := range x { + if pkg != "C" && pkg != "appengine" && !strings.HasPrefix(pkg, "appengine/") && + pkg != "appengine_internal" && !strings.HasPrefix(pkg, "appengine_internal/") { + x[w] = pkg + w++ + } + } + return x[:w] + } + + return filter(imports_), filter(testImports), err +} + +// buildStacks computes minimal import stacks for each package, +// for use in error messages. When it completes, packages that +// are part of the original root set have pkg.stack == nil, +// and other packages have pkg.stack pointing at the next +// package up the import stack in their minimal chain. +// As a side effect, buildStacks also constructs ld.pkgs, +// the list of all packages loaded. +func (ld *loader) buildStacks() { + if len(ld.pkgs) > 0 { + panic("buildStacks") + } + for _, pkg := range ld.roots { + pkg.stack = pkg // sentinel to avoid processing in next loop + ld.pkgs = append(ld.pkgs, pkg) + } + for i := 0; i < len(ld.pkgs); i++ { // not range: appending to ld.pkgs in loop + pkg := ld.pkgs[i] + for _, next := range pkg.imports { + if next.stack == nil { + next.stack = pkg + ld.pkgs = append(ld.pkgs, next) + } + } + if next := pkg.test; next != nil && next.stack == nil { + next.stack = pkg + ld.pkgs = append(ld.pkgs, next) + } + } + for _, pkg := range ld.roots { + pkg.stack = nil + } +} + +// stackText builds the import stack text to use when +// reporting an error in pkg. It has the general form +// +// root imports +// other imports +// other2 tested by +// other2.test imports +// pkg +func (pkg *loadPkg) stackText() string { + var stack []*loadPkg + for p := pkg; p != nil; p = p.stack { + stack = append(stack, p) + } + + var buf strings.Builder + for i := len(stack) - 1; i >= 0; i-- { + p := stack[i] + fmt.Fprint(&buf, p.path) + if p.testOf != nil { + fmt.Fprint(&buf, ".test") + } + if i > 0 { + if stack[i-1].testOf == p { + fmt.Fprint(&buf, " tested by\n\t") + } else { + fmt.Fprint(&buf, " imports\n\t") + } + } + } + return buf.String() +} + +// why returns the text to use in "go mod why" output about the given package. +// It is less ornate than the stackText but contains the same information. +func (pkg *loadPkg) why() string { + var buf strings.Builder + var stack []*loadPkg + for p := pkg; p != nil; p = p.stack { + stack = append(stack, p) + } + + for i := len(stack) - 1; i >= 0; i-- { + p := stack[i] + if p.testOf != nil { + fmt.Fprintf(&buf, "%s.test\n", p.testOf.path) + } else { + fmt.Fprintf(&buf, "%s\n", p.path) + } + } + return buf.String() +} + +// Why returns the "go mod why" output stanza for the given package, +// without the leading # comment. +// The package graph must have been loaded already, usually by LoadPackages. +// If there is no reason for the package to be in the current build, +// Why returns an empty string. +func Why(path string) string { + pkg, ok := loaded.pkgCache.Get(path) + if !ok { + return "" + } + return pkg.why() +} + +// WhyDepth returns the number of steps in the Why listing. +// If there is no reason for the package to be in the current build, +// WhyDepth returns 0. +func WhyDepth(path string) int { + n := 0 + pkg, _ := loaded.pkgCache.Get(path) + for p := pkg; p != nil; p = p.stack { + n++ + } + return n +} diff --git a/go/src/cmd/go/internal/modload/modfile.go b/go/src/cmd/go/internal/modload/modfile.go new file mode 100644 index 0000000000000000000000000000000000000000..1e54a580345466bd1364dd6ae848331f44a9c57a --- /dev/null +++ b/go/src/cmd/go/internal/modload/modfile.go @@ -0,0 +1,867 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "context" + "errors" + "fmt" + "os" + "path/filepath" + "strings" + "sync" + "unicode" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/fsys" + "cmd/go/internal/gover" + "cmd/go/internal/lockedfile" + "cmd/go/internal/modfetch" + "cmd/go/internal/trace" + "cmd/internal/par" + + "golang.org/x/mod/modfile" + "golang.org/x/mod/module" +) + +// ReadModFile reads and parses the mod file at gomod. ReadModFile properly applies the +// overlay, locks the file while reading, and applies fix, if applicable. +func ReadModFile(gomod string, fix modfile.VersionFixer) (data []byte, f *modfile.File, err error) { + if fsys.Replaced(gomod) { + // Don't lock go.mod if it's part of the overlay. + // On Plan 9, locking requires chmod, and we don't want to modify any file + // in the overlay. See #44700. + data, err = os.ReadFile(fsys.Actual(gomod)) + } else { + data, err = lockedfile.Read(gomod) + } + if err != nil { + return nil, nil, err + } + + f, err = modfile.Parse(gomod, data, fix) + if err != nil { + f, laxErr := modfile.ParseLax(gomod, data, fix) + if laxErr == nil { + if f.Go != nil && gover.Compare(f.Go.Version, gover.Local()) > 0 { + toolchain := "" + if f.Toolchain != nil { + toolchain = f.Toolchain.Name + } + return nil, nil, &gover.TooNewError{What: base.ShortPath(gomod), GoVersion: f.Go.Version, Toolchain: toolchain} + } + } + + // Errors returned by modfile.Parse begin with file:line. + return nil, nil, fmt.Errorf("errors parsing %s:\n%w", base.ShortPath(gomod), shortPathErrorList(err)) + } + if f.Go != nil && gover.Compare(f.Go.Version, gover.Local()) > 0 { + toolchain := "" + if f.Toolchain != nil { + toolchain = f.Toolchain.Name + } + return nil, nil, &gover.TooNewError{What: base.ShortPath(gomod), GoVersion: f.Go.Version, Toolchain: toolchain} + } + if f.Module == nil { + // No module declaration. Must add module path. + return nil, nil, fmt.Errorf("error reading %s: missing module declaration. To specify the module path:\n\tgo mod edit -module=example.com/mod", base.ShortPath(gomod)) + } else if err := CheckReservedModulePath(f.Module.Mod.Path); err != nil { + return nil, nil, fmt.Errorf("error reading %s: invalid module path: %q", base.ShortPath(gomod), f.Module.Mod.Path) + } + + return data, f, err +} + +func shortPathErrorList(err error) error { + if el, ok := errors.AsType[modfile.ErrorList](err); ok { + for i := range el { + el[i].Filename = base.ShortPath(el[i].Filename) + } + } + return err +} + +// A modFileIndex is an index of data corresponding to a modFile +// at a specific point in time. +type modFileIndex struct { + data []byte + dataNeedsFix bool // true if fixVersion applied a change while parsing data + module module.Version + goVersion string // Go version (no "v" or "go" prefix) + toolchain string + require map[module.Version]requireMeta + replace map[module.Version]module.Version + exclude map[module.Version]bool + ignore []string +} + +type requireMeta struct { + indirect bool +} + +// A modPruning indicates whether transitive dependencies of Go 1.17 dependencies +// are pruned out of the module subgraph rooted at a given module. +// (See https://golang.org/ref/mod#graph-pruning.) +type modPruning uint8 + +const ( + pruned modPruning = iota // transitive dependencies of modules at go 1.17 and higher are pruned out + unpruned // no transitive dependencies are pruned out + workspace // pruned to the union of modules in the workspace +) + +func (p modPruning) String() string { + switch p { + case pruned: + return "pruned" + case unpruned: + return "unpruned" + case workspace: + return "workspace" + default: + return fmt.Sprintf("%T(%d)", p, p) + } +} + +func pruningForGoVersion(goVersion string) modPruning { + if gover.Compare(goVersion, gover.ExplicitIndirectVersion) < 0 { + // The go.mod file does not duplicate relevant information about transitive + // dependencies, so they cannot be pruned out. + return unpruned + } + return pruned +} + +// CheckAllowed returns an error equivalent to ErrDisallowed if m is excluded by +// the main module's go.mod or retracted by its author. Most version queries use +// this to filter out versions that should not be used. +func (s *State) CheckAllowed(ctx context.Context, m module.Version) error { + if err := s.CheckExclusions(ctx, m); err != nil { + return err + } + if err := s.CheckRetractions(ctx, m); err != nil { + return err + } + return nil +} + +// ErrDisallowed is returned by version predicates passed to Query and similar +// functions to indicate that a version should not be considered. +var ErrDisallowed = errors.New("disallowed module version") + +// CheckExclusions returns an error equivalent to ErrDisallowed if module m is +// excluded by the main module's go.mod file. +func (s *State) CheckExclusions(ctx context.Context, m module.Version) error { + for _, mainModule := range s.MainModules.Versions() { + if index := s.MainModules.Index(mainModule); index != nil && index.exclude[m] { + return module.VersionError(m, errExcluded) + } + } + return nil +} + +var errExcluded = &excludedError{} + +type excludedError struct{} + +func (e *excludedError) Error() string { return "excluded by go.mod" } +func (e *excludedError) Is(err error) bool { return err == ErrDisallowed } + +// CheckRetractions returns an error if module m has been retracted by +// its author. +func (s *State) CheckRetractions(ctx context.Context, m module.Version) (err error) { + defer func() { + if err == nil { + return + } + if _, ok := errors.AsType[*ModuleRetractedError](err); ok { + return + } + // Attribute the error to the version being checked, not the version from + // which the retractions were to be loaded. + if mErr, ok := errors.AsType[*module.ModuleError](err); ok { + err = mErr.Err + } + err = &retractionLoadingError{m: m, err: err} + }() + + if m.Version == "" { + // Main module, standard library, or file replacement module. + // Cannot be retracted. + return nil + } + if repl := Replacement(s, module.Version{Path: m.Path}); repl.Path != "" { + // All versions of the module were replaced. + // Don't load retractions, since we'd just load the replacement. + return nil + } + + // Find the latest available version of the module, and load its go.mod. If + // the latest version is replaced, we'll load the replacement. + // + // If there's an error loading the go.mod, we'll return it here. These errors + // should generally be ignored by callers since they happen frequently when + // we're offline. These errors are not equivalent to ErrDisallowed, so they + // may be distinguished from retraction errors. + // + // We load the raw file here: the go.mod file may have a different module + // path that we expect if the module or its repository was renamed. + // We still want to apply retractions to other aliases of the module. + rm, err := queryLatestVersionIgnoringRetractions(s, ctx, m.Path) + if err != nil { + return err + } + summary, err := rawGoModSummary(s, rm) + if err != nil && !errors.Is(err, gover.ErrTooNew) { + return err + } + + var rationale []string + isRetracted := false + for _, r := range summary.retract { + if gover.ModCompare(m.Path, r.Low, m.Version) <= 0 && gover.ModCompare(m.Path, m.Version, r.High) <= 0 { + isRetracted = true + if r.Rationale != "" { + rationale = append(rationale, r.Rationale) + } + } + } + if isRetracted { + return module.VersionError(m, &ModuleRetractedError{Rationale: rationale}) + } + return nil +} + +type ModuleRetractedError struct { + Rationale []string +} + +func (e *ModuleRetractedError) Error() string { + msg := "retracted by module author" + if len(e.Rationale) > 0 { + // This is meant to be a short error printed on a terminal, so just + // print the first rationale. + msg += ": " + ShortMessage(e.Rationale[0], "retracted by module author") + } + return msg +} + +func (e *ModuleRetractedError) Is(err error) bool { + return err == ErrDisallowed +} + +type retractionLoadingError struct { + m module.Version + err error +} + +func (e *retractionLoadingError) Error() string { + return fmt.Sprintf("loading module retractions for %v: %v", e.m, e.err) +} + +func (e *retractionLoadingError) Unwrap() error { + return e.err +} + +// ShortMessage returns a string from go.mod (for example, a retraction +// rationale or deprecation message) that is safe to print in a terminal. +// +// If the given string is empty, ShortMessage returns the given default. If the +// given string is too long or contains non-printable characters, ShortMessage +// returns a hard-coded string. +func ShortMessage(message, emptyDefault string) string { + const maxLen = 500 + if i := strings.Index(message, "\n"); i >= 0 { + message = message[:i] + } + message = strings.TrimSpace(message) + if message == "" { + return emptyDefault + } + if len(message) > maxLen { + return "(message omitted: too long)" + } + for _, r := range message { + if !unicode.IsGraphic(r) && !unicode.IsSpace(r) { + return "(message omitted: contains non-printable characters)" + } + } + // NOTE: the go.mod parser rejects invalid UTF-8, so we don't check that here. + return message +} + +// CheckDeprecation returns a deprecation message from the go.mod file of the +// latest version of the given module. Deprecation messages are comments +// before or on the same line as the module directives that start with +// "Deprecated:" and run until the end of the paragraph. +// +// CheckDeprecation returns an error if the message can't be loaded. +// CheckDeprecation returns "", nil if there is no deprecation message. +func CheckDeprecation(loaderstate *State, ctx context.Context, m module.Version) (deprecation string, err error) { + defer func() { + if err != nil { + err = fmt.Errorf("loading deprecation for %s: %w", m.Path, err) + } + }() + + if m.Version == "" { + // Main module, standard library, or file replacement module. + // Don't look up deprecation. + return "", nil + } + if repl := Replacement(loaderstate, module.Version{Path: m.Path}); repl.Path != "" { + // All versions of the module were replaced. + // We'll look up deprecation separately for the replacement. + return "", nil + } + + latest, err := queryLatestVersionIgnoringRetractions(loaderstate, ctx, m.Path) + if err != nil { + return "", err + } + summary, err := rawGoModSummary(loaderstate, latest) + if err != nil && !errors.Is(err, gover.ErrTooNew) { + return "", err + } + return summary.deprecated, nil +} + +func replacement(mod module.Version, replace map[module.Version]module.Version) (fromVersion string, to module.Version, ok bool) { + if r, ok := replace[mod]; ok { + return mod.Version, r, true + } + if r, ok := replace[module.Version{Path: mod.Path}]; ok { + return "", r, true + } + return "", module.Version{}, false +} + +// Replacement returns the replacement for mod, if any. If the path in the +// module.Version is relative it's relative to the single main module outside +// workspace mode, or the workspace's directory in workspace mode. +func Replacement(loaderstate *State, mod module.Version) module.Version { + r, foundModRoot, _ := replacementFrom(loaderstate, mod) + return canonicalizeReplacePath(loaderstate, r, foundModRoot) +} + +// replacementFrom returns the replacement for mod, if any, the modroot of the replacement if it appeared in a go.mod, +// and the source of the replacement. The replacement is relative to the go.work or go.mod file it appears in. +func replacementFrom(loaderstate *State, mod module.Version) (r module.Version, modroot string, fromFile string) { + foundFrom, found, foundModRoot := "", module.Version{}, "" + if loaderstate.MainModules == nil { + return module.Version{}, "", "" + } else if loaderstate.MainModules.Contains(mod.Path) && mod.Version == "" { + // Don't replace the workspace version of the main module. + return module.Version{}, "", "" + } + if _, r, ok := replacement(mod, loaderstate.MainModules.WorkFileReplaceMap()); ok { + return r, "", loaderstate.workFilePath + } + for _, v := range loaderstate.MainModules.Versions() { + if index := loaderstate.MainModules.Index(v); index != nil { + if from, r, ok := replacement(mod, index.replace); ok { + modRoot := loaderstate.MainModules.ModRoot(v) + if foundModRoot != "" && foundFrom != from && found != r { + base.Errorf("conflicting replacements found for %v in workspace modules defined by %v and %v", + mod, modFilePath(foundModRoot), modFilePath(modRoot)) + return found, foundModRoot, modFilePath(foundModRoot) + } + found, foundModRoot = r, modRoot + } + } + } + return found, foundModRoot, modFilePath(foundModRoot) +} + +func replaceRelativeTo(loaderstate *State) string { + if workFilePath := WorkFilePath(loaderstate); workFilePath != "" { + return filepath.Dir(workFilePath) + } + return loaderstate.MainModules.ModRoot(loaderstate.MainModules.mustGetSingleMainModule(loaderstate)) +} + +// canonicalizeReplacePath ensures that relative, on-disk, replaced module paths +// are relative to the workspace directory (in workspace mode) or to the module's +// directory (in module mode, as they already are). +func canonicalizeReplacePath(loaderstate *State, r module.Version, modRoot string) module.Version { + if filepath.IsAbs(r.Path) || r.Version != "" || modRoot == "" { + return r + } + workFilePath := WorkFilePath(loaderstate) + if workFilePath == "" { + return r + } + abs := filepath.Join(modRoot, r.Path) + if rel, err := filepath.Rel(filepath.Dir(workFilePath), abs); err == nil { + return module.Version{Path: ToDirectoryPath(rel), Version: r.Version} + } + // We couldn't make the version's path relative to the workspace's path, + // so just return the absolute path. It's the best we can do. + return module.Version{Path: ToDirectoryPath(abs), Version: r.Version} +} + +// resolveReplacement returns the module actually used to load the source code +// for m: either m itself, or the replacement for m (iff m is replaced). +// It also returns the modroot of the module providing the replacement if +// one was found. +func resolveReplacement(loaderstate *State, m module.Version) module.Version { + if r := Replacement(loaderstate, m); r.Path != "" { + return r + } + return m +} + +func toReplaceMap(replacements []*modfile.Replace) map[module.Version]module.Version { + replaceMap := make(map[module.Version]module.Version, len(replacements)) + for _, r := range replacements { + if prev, dup := replaceMap[r.Old]; dup && prev != r.New { + base.Fatalf("go: conflicting replacements for %v:\n\t%v\n\t%v", r.Old, prev, r.New) + } + replaceMap[r.Old] = r.New + } + return replaceMap +} + +// indexModFile rebuilds the index of modFile. +// If modFile has been changed since it was first read, +// modFile.Cleanup must be called before indexModFile. +func indexModFile(data []byte, modFile *modfile.File, mod module.Version, needsFix bool) *modFileIndex { + i := new(modFileIndex) + i.data = data + i.dataNeedsFix = needsFix + + i.module = module.Version{} + if modFile.Module != nil { + i.module = modFile.Module.Mod + } + + i.goVersion = "" + if modFile.Go == nil { + rawGoVersion.Store(mod, "") + } else { + i.goVersion = modFile.Go.Version + rawGoVersion.Store(mod, modFile.Go.Version) + } + if modFile.Toolchain != nil { + i.toolchain = modFile.Toolchain.Name + } + + i.require = make(map[module.Version]requireMeta, len(modFile.Require)) + for _, r := range modFile.Require { + i.require[r.Mod] = requireMeta{indirect: r.Indirect} + } + + i.replace = toReplaceMap(modFile.Replace) + + i.exclude = make(map[module.Version]bool, len(modFile.Exclude)) + for _, x := range modFile.Exclude { + i.exclude[x.Mod] = true + } + if modFile.Ignore != nil { + for _, x := range modFile.Ignore { + i.ignore = append(i.ignore, x.Path) + } + } + return i +} + +// modFileIsDirty reports whether the go.mod file differs meaningfully +// from what was indexed. +// If modFile has been changed (even cosmetically) since it was first read, +// modFile.Cleanup must be called before modFileIsDirty. +func (i *modFileIndex) modFileIsDirty(modFile *modfile.File) bool { + if i == nil { + return modFile != nil + } + + if i.dataNeedsFix { + return true + } + + if modFile.Module == nil { + if i.module != (module.Version{}) { + return true + } + } else if modFile.Module.Mod != i.module { + return true + } + + var goV, toolchain string + if modFile.Go != nil { + goV = modFile.Go.Version + } + if modFile.Toolchain != nil { + toolchain = modFile.Toolchain.Name + } + + if goV != i.goVersion || + toolchain != i.toolchain || + len(modFile.Require) != len(i.require) || + len(modFile.Replace) != len(i.replace) || + len(modFile.Exclude) != len(i.exclude) { + return true + } + + for _, r := range modFile.Require { + if meta, ok := i.require[r.Mod]; !ok { + return true + } else if r.Indirect != meta.indirect { + if cfg.BuildMod == "readonly" { + // The module's requirements are consistent; only the "// indirect" + // comments that are wrong. But those are only guaranteed to be accurate + // after a "go mod tidy" — it's a good idea to run those before + // committing a change, but it's certainly not mandatory. + } else { + return true + } + } + } + + for _, r := range modFile.Replace { + if r.New != i.replace[r.Old] { + return true + } + } + + for _, x := range modFile.Exclude { + if !i.exclude[x.Mod] { + return true + } + } + + return false +} + +// rawGoVersion records the Go version parsed from each module's go.mod file. +// +// If a module is replaced, the version of the replacement is keyed by the +// replacement module.Version, not the version being replaced. +var rawGoVersion sync.Map // map[module.Version]string + +// A modFileSummary is a summary of a go.mod file for which we do not need to +// retain complete information — for example, the go.mod file of a dependency +// module. +type modFileSummary struct { + module module.Version + goVersion string + toolchain string + ignore []string + pruning modPruning + require []module.Version + retract []retraction + deprecated string +} + +// A retraction consists of a retracted version interval and rationale. +// retraction is like modfile.Retract, but it doesn't point to the syntax tree. +type retraction struct { + modfile.VersionInterval + Rationale string +} + +// goModSummary returns a summary of the go.mod file for module m, +// taking into account any replacements for m, exclusions of its dependencies, +// and/or vendoring. +// +// m must be a version in the module graph, reachable from the Target module. +// In readonly mode, the go.sum file must contain an entry for m's go.mod file +// (or its replacement). goModSummary must not be called for the Target module +// itself, as its requirements may change. Use rawGoModSummary for other +// module versions. +// +// The caller must not modify the returned summary. +func goModSummary(loaderstate *State, m module.Version) (*modFileSummary, error) { + if m.Version == "" && !loaderstate.inWorkspaceMode() && loaderstate.MainModules.Contains(m.Path) { + panic("internal error: goModSummary called on a main module") + } + if gover.IsToolchain(m.Path) { + return rawGoModSummary(loaderstate, m) + } + + if cfg.BuildMod == "vendor" { + summary := &modFileSummary{ + module: module.Version{Path: m.Path}, + } + + readVendorList(VendorDir(loaderstate)) + if vendorVersion[m.Path] != m.Version { + // This module is not vendored, so packages cannot be loaded from it and + // it cannot be relevant to the build. + return summary, nil + } + + // For every module other than the target, + // return the full list of modules from modules.txt. + // We don't know what versions the vendored module actually relies on, + // so assume that it requires everything. + summary.require = vendorList + return summary, nil + } + + actual := resolveReplacement(loaderstate, m) + if mustHaveSums(loaderstate) && actual.Version != "" { + key := module.Version{Path: actual.Path, Version: actual.Version + "/go.mod"} + if !modfetch.HaveSum(loaderstate.Fetcher(), key) { + suggestion := fmt.Sprintf(" for go.mod file; to add it:\n\tgo mod download %s", m.Path) + return nil, module.VersionError(actual, &sumMissingError{suggestion: suggestion}) + } + } + summary, err := rawGoModSummary(loaderstate, actual) + if err != nil { + return nil, err + } + + if actual.Version == "" { + // The actual module is a filesystem-local replacement, for which we have + // unfortunately not enforced any sort of invariants about module lines or + // matching module paths. Anything goes. + // + // TODO(bcmills): Remove this special-case, update tests, and add a + // release note. + } else { + if summary.module.Path == "" { + return nil, module.VersionError(actual, errors.New("parsing go.mod: missing module line")) + } + + // In theory we should only allow mpath to be unequal to m.Path here if the + // version that we fetched lacks an explicit go.mod file: if the go.mod file + // is explicit, then it should match exactly (to ensure that imports of other + // packages within the module are interpreted correctly). Unfortunately, we + // can't determine that information from the module proxy protocol: we'll have + // to leave that validation for when we load actual packages from within the + // module. + if mpath := summary.module.Path; mpath != m.Path && mpath != actual.Path { + return nil, module.VersionError(actual, + fmt.Errorf("parsing go.mod:\n"+ + "\tmodule declares its path as: %s\n"+ + "\t but was required as: %s", mpath, m.Path)) + } + } + + for _, mainModule := range loaderstate.MainModules.Versions() { + if index := loaderstate.MainModules.Index(mainModule); index != nil && len(index.exclude) > 0 { + // Drop any requirements on excluded versions. + // Don't modify the cached summary though, since we might need the raw + // summary separately. + haveExcludedReqs := false + for _, r := range summary.require { + if index.exclude[r] { + haveExcludedReqs = true + break + } + } + if haveExcludedReqs { + s := new(modFileSummary) + *s = *summary + s.require = make([]module.Version, 0, len(summary.require)) + for _, r := range summary.require { + if !index.exclude[r] { + s.require = append(s.require, r) + } + } + summary = s + } + } + } + return summary, nil +} + +// rawGoModSummary returns a new summary of the go.mod file for module m, +// ignoring all replacements that may apply to m and excludes that may apply to +// its dependencies. +// +// rawGoModSummary cannot be used on the main module outside of workspace mode. +// The modFileSummary can still be used for retractions and deprecations +// even if a TooNewError is returned. +func rawGoModSummary(loaderstate *State, m module.Version) (*modFileSummary, error) { + if gover.IsToolchain(m.Path) { + if m.Path == "go" && gover.Compare(m.Version, gover.GoStrictVersion) >= 0 { + // Declare that go 1.21.3 requires toolchain 1.21.3, + // so that go get knows that downgrading toolchain implies downgrading go + // and similarly upgrading go requires upgrading the toolchain. + return &modFileSummary{module: m, require: []module.Version{{Path: "toolchain", Version: "go" + m.Version}}}, nil + } + return &modFileSummary{module: m}, nil + } + if m.Version == "" && !loaderstate.inWorkspaceMode() && loaderstate.MainModules.Contains(m.Path) { + // Calling rawGoModSummary implies that we are treating m as a module whose + // requirements aren't the roots of the module graph and can't be modified. + // + // If we are not in workspace mode, then the requirements of the main module + // are the roots of the module graph and we expect them to be kept consistent. + panic("internal error: rawGoModSummary called on a main module") + } + if m.Version == "" && loaderstate.inWorkspaceMode() && m.Path == "command-line-arguments" { + // "go work sync" calls LoadModGraph to make sure the module graph is valid. + // If there are no modules in the workspace, we synthesize an empty + // command-line-arguments module, which rawGoModData cannot read a go.mod for. + return &modFileSummary{module: m}, nil + } else if m.Version == "" && loaderstate.inWorkspaceMode() && loaderstate.MainModules.Contains(m.Path) { + // When go get uses EnterWorkspace to check that the workspace loads properly, + // it will update the contents of the workspace module's modfile in memory. To use the updated + // contents of the modfile when doing the load, don't read from disk and instead + // recompute a summary using the updated contents of the modfile. + if mf := loaderstate.MainModules.ModFile(m); mf != nil { + return summaryFromModFile(m, loaderstate.MainModules.modFiles[m]) + } + } + return rawGoModSummaryCache.Do(m, func() (*modFileSummary, error) { + name, data, err := rawGoModData(loaderstate, m) + if err != nil { + return nil, err + } + f, err := modfile.ParseLax(name, data, nil) + if err != nil { + return nil, module.VersionError(m, fmt.Errorf("parsing %s: %v", base.ShortPath(name), err)) + } + return summaryFromModFile(m, f) + }) +} + +func summaryFromModFile(m module.Version, f *modfile.File) (*modFileSummary, error) { + summary := new(modFileSummary) + if f.Module != nil { + summary.module = f.Module.Mod + summary.deprecated = f.Module.Deprecated + } + if f.Go != nil { + rawGoVersion.LoadOrStore(m, f.Go.Version) + summary.goVersion = f.Go.Version + summary.pruning = pruningForGoVersion(f.Go.Version) + } else { + summary.pruning = unpruned + } + if f.Toolchain != nil { + summary.toolchain = f.Toolchain.Name + } + if f.Ignore != nil { + for _, i := range f.Ignore { + summary.ignore = append(summary.ignore, i.Path) + } + } + if len(f.Require) > 0 { + summary.require = make([]module.Version, 0, len(f.Require)+1) + for _, req := range f.Require { + summary.require = append(summary.require, req.Mod) + } + } + + if len(f.Retract) > 0 { + summary.retract = make([]retraction, 0, len(f.Retract)) + for _, ret := range f.Retract { + summary.retract = append(summary.retract, retraction{ + VersionInterval: ret.VersionInterval, + Rationale: ret.Rationale, + }) + } + } + + // This block must be kept at the end of the function because the summary may + // be used for reading retractions or deprecations even if a TooNewError is + // returned. + if summary.goVersion != "" && gover.Compare(summary.goVersion, gover.GoStrictVersion) >= 0 { + summary.require = append(summary.require, module.Version{Path: "go", Version: summary.goVersion}) + if gover.Compare(summary.goVersion, gover.Local()) > 0 { + return summary, &gover.TooNewError{What: "module " + m.String(), GoVersion: summary.goVersion} + } + } + + return summary, nil +} + +var rawGoModSummaryCache par.ErrCache[module.Version, *modFileSummary] + +// rawGoModData returns the content of the go.mod file for module m, ignoring +// all replacements that may apply to m. +// +// rawGoModData cannot be used on the main module outside of workspace mode. +// +// Unlike rawGoModSummary, rawGoModData does not cache its results in memory. +// Use rawGoModSummary instead unless you specifically need these bytes. +func rawGoModData(loaderstate *State, m module.Version) (name string, data []byte, err error) { + if m.Version == "" { + dir := m.Path + if !filepath.IsAbs(dir) { + if loaderstate.inWorkspaceMode() && loaderstate.MainModules.Contains(m.Path) { + dir = loaderstate.MainModules.ModRoot(m) + } else { + // m is a replacement module with only a file path. + dir = filepath.Join(replaceRelativeTo(loaderstate), dir) + } + } + name = filepath.Join(dir, "go.mod") + if fsys.Replaced(name) { + // Don't lock go.mod if it's part of the overlay. + // On Plan 9, locking requires chmod, and we don't want to modify any file + // in the overlay. See #44700. + data, err = os.ReadFile(fsys.Actual(name)) + } else { + data, err = lockedfile.Read(name) + } + if err != nil { + return "", nil, module.VersionError(m, fmt.Errorf("reading %s: %v", base.ShortPath(name), err)) + } + } else { + if !gover.ModIsValid(m.Path, m.Version) { + // Disallow the broader queries supported by fetch.Lookup. + base.Fatalf("go: internal error: %s@%s: unexpected invalid semantic version", m.Path, m.Version) + } + name = "go.mod" + data, err = loaderstate.Fetcher().GoMod(context.TODO(), m.Path, m.Version) + } + return name, data, err +} + +// queryLatestVersionIgnoringRetractions looks up the latest version of the +// module with the given path without considering retracted or excluded +// versions. +// +// If all versions of the module are replaced, +// queryLatestVersionIgnoringRetractions returns the replacement without making +// a query. +// +// If the queried latest version is replaced, +// queryLatestVersionIgnoringRetractions returns the replacement. +func queryLatestVersionIgnoringRetractions(loaderstate *State, ctx context.Context, path string) (latest module.Version, err error) { + return latestVersionIgnoringRetractionsCache.Do(path, func() (module.Version, error) { + ctx, span := trace.StartSpan(ctx, "queryLatestVersionIgnoringRetractions "+path) + defer span.Done() + + if repl := Replacement(loaderstate, module.Version{Path: path}); repl.Path != "" { + // All versions of the module were replaced. + // No need to query. + return repl, nil + } + + // Find the latest version of the module. + // Ignore exclusions from the main module's go.mod. + const ignoreSelected = "" + var allowAll AllowedFunc + rev, err := Query(loaderstate, ctx, path, "latest", ignoreSelected, allowAll) + if err != nil { + return module.Version{}, err + } + latest := module.Version{Path: path, Version: rev.Version} + if repl := resolveReplacement(loaderstate, latest); repl.Path != "" { + latest = repl + } + return latest, nil + }) +} + +var latestVersionIgnoringRetractionsCache par.ErrCache[string, module.Version] // path → queryLatestVersionIgnoringRetractions result + +// ToDirectoryPath adds a prefix if necessary so that path in unambiguously +// an absolute path or a relative path starting with a '.' or '..' +// path component. +func ToDirectoryPath(path string) string { + if modfile.IsDirectoryPath(path) { + return path + } + // The path is not a relative path or an absolute path, so make it relative + // to the current directory. + return "./" + filepath.ToSlash(filepath.Clean(path)) +} diff --git a/go/src/cmd/go/internal/modload/mvs.go b/go/src/cmd/go/internal/modload/mvs.go new file mode 100644 index 0000000000000000000000000000000000000000..63fedae0f162124a16c0509561a3ceea8ebc342c --- /dev/null +++ b/go/src/cmd/go/internal/modload/mvs.go @@ -0,0 +1,137 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "context" + "errors" + "os" + "sort" + + "cmd/go/internal/gover" + "cmd/go/internal/modfetch" + "cmd/go/internal/modfetch/codehost" + + "golang.org/x/mod/module" +) + +// cmpVersion implements the comparison for versions in the module loader. +// +// It is consistent with gover.ModCompare except that as a special case, +// the version "" is considered higher than all other versions. +// The main module (also known as the target) has no version and must be chosen +// over other versions of the same module in the module dependency graph. +func cmpVersion(p string, v1, v2 string) int { + if v2 == "" { + if v1 == "" { + return 0 + } + return -1 + } + if v1 == "" { + return 1 + } + return gover.ModCompare(p, v1, v2) +} + +// mvsReqs implements mvs.Reqs for module semantic versions, +// with any exclusions or replacements applied internally. +type mvsReqs struct { + loaderstate *State // TODO(jitsu): Is there a way we can not depend on the entire loader state? + roots []module.Version +} + +func (r *mvsReqs) Required(mod module.Version) ([]module.Version, error) { + if mod.Version == "" && r.loaderstate.MainModules.Contains(mod.Path) { + // Use the build list as it existed when r was constructed, not the current + // global build list. + return r.roots, nil + } + + if mod.Version == "none" { + return nil, nil + } + + summary, err := goModSummary(r.loaderstate, mod) + if err != nil { + return nil, err + } + return summary.require, nil +} + +// Max returns the maximum of v1 and v2 according to gover.ModCompare. +// +// As a special case, the version "" is considered higher than all other +// versions. The main module (also known as the target) has no version and must +// be chosen over other versions of the same module in the module dependency +// graph. +func (*mvsReqs) Max(p, v1, v2 string) string { + if cmpVersion(p, v1, v2) < 0 { + return v2 + } + return v1 +} + +// Upgrade is a no-op, here to implement mvs.Reqs. +// The upgrade logic for go get -u is in ../modget/get.go. +func (*mvsReqs) Upgrade(m module.Version) (module.Version, error) { + return m, nil +} + +func versions(loaderstate *State, ctx context.Context, path string, allowed AllowedFunc) (versions []string, origin *codehost.Origin, err error) { + // Note: modfetch.Lookup and repo.Versions are cached, + // so there's no need for us to add extra caching here. + err = modfetch.TryProxies(func(proxy string) error { + repo, err := lookupRepo(loaderstate, ctx, proxy, path) + if err != nil { + return err + } + allVersions, err := repo.Versions(ctx, "") + if err != nil { + return err + } + allowedVersions := make([]string, 0, len(allVersions.List)) + for _, v := range allVersions.List { + if err := allowed(ctx, module.Version{Path: path, Version: v}); err == nil { + allowedVersions = append(allowedVersions, v) + } else if !errors.Is(err, ErrDisallowed) { + return err + } + } + versions = allowedVersions + origin = allVersions.Origin + return nil + }) + return versions, origin, err +} + +// previousVersion returns the tagged version of m.Path immediately prior to +// m.Version, or version "none" if no prior version is tagged. +// +// Since the version of a main module is not found in the version list, +// it has no previous version. +func previousVersion(loaderstate *State, ctx context.Context, m module.Version) (module.Version, error) { + if m.Version == "" && loaderstate.MainModules.Contains(m.Path) { + return module.Version{Path: m.Path, Version: "none"}, nil + } + + list, _, err := versions(loaderstate, ctx, m.Path, loaderstate.CheckAllowed) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + return module.Version{Path: m.Path, Version: "none"}, nil + } + return module.Version{}, err + } + i := sort.Search(len(list), func(i int) bool { return gover.ModCompare(m.Path, list[i], m.Version) >= 0 }) + if i > 0 { + return module.Version{Path: m.Path, Version: list[i-1]}, nil + } + return module.Version{Path: m.Path, Version: "none"}, nil +} + +func (r *mvsReqs) Previous(m module.Version) (module.Version, error) { + // TODO(golang.org/issue/38714): thread tracing context through MVS. + return previousVersion(r.loaderstate, context.TODO(), m) +} diff --git a/go/src/cmd/go/internal/modload/mvs_test.go b/go/src/cmd/go/internal/modload/mvs_test.go new file mode 100644 index 0000000000000000000000000000000000000000..e0a38b98d1e1b2ca7965135a70351758d3e25b2f --- /dev/null +++ b/go/src/cmd/go/internal/modload/mvs_test.go @@ -0,0 +1,31 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "testing" +) + +func TestReqsMax(t *testing.T) { + type testCase struct { + a, b, want string + } + reqs := new(mvsReqs) + for _, tc := range []testCase{ + {a: "v0.1.0", b: "v0.2.0", want: "v0.2.0"}, + {a: "v0.2.0", b: "v0.1.0", want: "v0.2.0"}, + {a: "", b: "v0.1.0", want: ""}, // "" is Target.Version + {a: "v0.1.0", b: "", want: ""}, + {a: "none", b: "v0.1.0", want: "v0.1.0"}, + {a: "v0.1.0", b: "none", want: "v0.1.0"}, + {a: "none", b: "", want: ""}, + {a: "", b: "none", want: ""}, + } { + max := reqs.Max("", tc.a, tc.b) + if max != tc.want { + t.Errorf("(%T).Max(%q, %q) = %q; want %q", reqs, tc.a, tc.b, max, tc.want) + } + } +} diff --git a/go/src/cmd/go/internal/modload/query.go b/go/src/cmd/go/internal/modload/query.go new file mode 100644 index 0000000000000000000000000000000000000000..b6bf0803c1055e2f7bff10894aa634bf427fff89 --- /dev/null +++ b/go/src/cmd/go/internal/modload/query.go @@ -0,0 +1,1349 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "bytes" + "context" + "errors" + "fmt" + "io/fs" + "os" + pathpkg "path" + "slices" + "sort" + "strings" + "sync" + "time" + + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/imports" + "cmd/go/internal/modfetch" + "cmd/go/internal/modfetch/codehost" + "cmd/go/internal/modinfo" + "cmd/go/internal/search" + "cmd/go/internal/str" + "cmd/go/internal/trace" + "cmd/internal/pkgpattern" + + "golang.org/x/mod/module" + "golang.org/x/mod/semver" +) + +// Query looks up a revision of a given module given a version query string. +// The module must be a complete module path. +// The version must take one of the following forms: +// +// - the literal string "latest", denoting the latest available, allowed +// tagged version, with non-prereleases preferred over prereleases. +// If there are no tagged versions in the repo, latest returns the most +// recent commit. +// +// - the literal string "upgrade", equivalent to "latest" except that if +// current is a newer version, current will be returned (see below). +// +// - the literal string "patch", denoting the latest available tagged version +// with the same major and minor number as current (see below). +// +// - v1, denoting the latest available tagged version v1.x.x. +// +// - v1.2, denoting the latest available tagged version v1.2.x. +// +// - v1.2.3, a semantic version string denoting that tagged version. +// +// - v1.2.3, >=v1.2.3, +// denoting the version closest to the target and satisfying the given operator, +// with non-prereleases preferred over prereleases. +// +// - a repository commit identifier or tag, denoting that commit. +// +// current denotes the currently-selected version of the module; it may be +// "none" if no version is currently selected, or "" if the currently-selected +// version is unknown or should not be considered. If query is +// "upgrade" or "patch", current will be returned if it is a newer +// semantic version or a chronologically later pseudo-version than the +// version that would otherwise be chosen. This prevents accidental downgrades +// from newer pre-release or development versions. +// +// The allowed function (which may be nil) is used to filter out unsuitable +// versions (see AllowedFunc documentation for details). If the query refers to +// a specific revision (for example, "master"; see IsRevisionQuery), and the +// revision is disallowed by allowed, Query returns the error. If the query +// does not refer to a specific revision (for example, "latest"), Query +// acts as if versions disallowed by allowed do not exist. +// +// If path is the path of the main module and the query is "latest", +// Query returns Target.Version as the version. +// +// Query often returns a non-nil *RevInfo with a non-nil error, +// to provide an info.Origin that can allow the error to be cached. +func Query(loaderstate *State, ctx context.Context, path, query, current string, allowed AllowedFunc) (*modfetch.RevInfo, error) { + ctx, span := trace.StartSpan(ctx, "modload.Query "+path) + defer span.Done() + + return queryReuse(loaderstate, ctx, path, query, current, allowed, nil) +} + +// queryReuse is like Query but also takes a map of module info that can be reused +// if the validation criteria in Origin are met. +func queryReuse(loaderstate *State, ctx context.Context, path, query, current string, allowed AllowedFunc, reuse map[module.Version]*modinfo.ModulePublic) (*modfetch.RevInfo, error) { + var info *modfetch.RevInfo + err := modfetch.TryProxies(func(proxy string) (err error) { + info, err = queryProxy(loaderstate, ctx, proxy, path, query, current, allowed, reuse) + return err + }) + return info, err +} + +// checkReuse checks whether a revision of a given module +// for a given module may be reused, according to the information in origin. +func checkReuse(loaderstate *State, ctx context.Context, m module.Version, old *codehost.Origin) error { + return modfetch.TryProxies(func(proxy string) error { + repo, err := lookupRepo(loaderstate, ctx, proxy, m.Path) + if err != nil { + return err + } + return checkReuseRepo(ctx, repo, m.Path, m.Version, old) + }) +} + +func checkReuseRepo(ctx context.Context, repo versionRepo, path, query string, origin *codehost.Origin) error { + if origin == nil { + return errors.New("nil Origin") + } + + // Ensure that the Origin actually includes enough fields to resolve the query. + // If we got the previous Origin data from a proxy, it may be missing something + // that we would have needed to resolve the query directly from the repo. + switch { + case origin.RepoSum != "": + // A RepoSum is always acceptable, since it incorporates everything + // (and is often associated with an error result). + + case query == module.CanonicalVersion(query): + // This query refers to a specific version, and Go module versions + // are supposed to be cacheable and immutable (confirmed with checksums). + // If the version exists at all, we shouldn't need any extra information + // to identify which commit it resolves to. + // + // It may be associated with a Ref for a semantic-version tag, but if so + // we don't expect that tag to change in the future. We also don't need a + // TagSum: if a tag is removed from some ancestor commit, the version may + // change from valid to invalid, but we're ok with keeping stale versions + // as long as they were valid at some point in the past. + // + // If the version did not successfully resolve, the origin may indicate + // a TagSum and/or RepoSum instead of a Hash, in which case we still need + // to check those to ensure that the error is still applicable. + if origin.Hash == "" && origin.Ref == "" && origin.TagSum == "" { + return errors.New("no Origin information to check") + } + + case IsRevisionQuery(path, query): + // This query may refer to a branch, non-version tag, or commit ID. + // + // If it is a commit ID, we expect to see a Hash in the Origin data. On + // the other hand, if it is not a commit ID, we expect to see either a Ref + // (for a positive result) or a RepoSum (for a negative result), since + // we don't expect refs in general to remain stable over time. + if origin.Hash == "" && origin.Ref == "" { + return fmt.Errorf("query %q requires a Hash or Ref", query) + } + // Once we resolve the query to a particular commit, we will need to + // also identify the most appropriate version to assign to that commit. + // (It may correspond to more than one valid version.) + // + // The most appropriate version depends on the tags associated with + // both the commit itself (if the commit is a tagged version) + // and its ancestors (if we need to produce a pseudo-version for it). + if origin.TagSum == "" { + return fmt.Errorf("query %q requires a TagSum", query) + } + + default: + // The query may be "latest" or a version inequality or prefix. + // Its result depends on the absence of higher tags matching the query, + // not just the state of an individual ref or tag. + if origin.TagSum == "" { + return fmt.Errorf("query %q requires a TagSum", query) + } + } + + return repo.CheckReuse(ctx, origin) +} + +// AllowedFunc is used by Query and other functions to filter out unsuitable +// versions, for example, those listed in exclude directives in the main +// module's go.mod file. +// +// An AllowedFunc returns an error equivalent to ErrDisallowed for an unsuitable +// version. Any other error indicates the function was unable to determine +// whether the version should be allowed, for example, the function was unable +// to fetch or parse a go.mod file containing retractions. Typically, errors +// other than ErrDisallowed may be ignored. +type AllowedFunc func(context.Context, module.Version) error + +var errQueryDisabled error = queryDisabledError{} + +type queryDisabledError struct{} + +func (queryDisabledError) Error() string { + if cfg.BuildModReason == "" { + return fmt.Sprintf("cannot query module due to -mod=%s", cfg.BuildMod) + } + return fmt.Sprintf("cannot query module due to -mod=%s\n\t(%s)", cfg.BuildMod, cfg.BuildModReason) +} + +func queryProxy(loaderstate *State, ctx context.Context, proxy, path, query, current string, allowed AllowedFunc, reuse map[module.Version]*modinfo.ModulePublic) (*modfetch.RevInfo, error) { + ctx, span := trace.StartSpan(ctx, "modload.queryProxy "+path+" "+query) + defer span.Done() + + if current != "" && current != "none" && !gover.ModIsValid(path, current) { + return nil, fmt.Errorf("invalid previous version %v@%v", path, current) + } + if cfg.BuildMod == "vendor" { + return nil, errQueryDisabled + } + if allowed == nil { + allowed = func(context.Context, module.Version) error { return nil } + } + + if loaderstate.MainModules.Contains(path) && (query == "upgrade" || query == "patch") { + m := module.Version{Path: path} + if err := allowed(ctx, m); err != nil { + return nil, fmt.Errorf("internal error: main module version is not allowed: %w", err) + } + return &modfetch.RevInfo{Version: m.Version}, nil + } + + if path == "std" || path == "cmd" { + return nil, fmt.Errorf("can't query specific version (%q) of standard-library module %q", query, path) + } + + repo, err := lookupRepo(loaderstate, ctx, proxy, path) + if err != nil { + return nil, err + } + + if old := reuse[module.Version{Path: path, Version: query}]; old != nil { + if err := checkReuseRepo(ctx, repo, path, query, old.Origin); err == nil { + info := &modfetch.RevInfo{ + Version: old.Version, + Origin: old.Origin, + } + if old.Time != nil { + info.Time = *old.Time + } + return info, nil + } + } + + // Parse query to detect parse errors (and possibly handle query) + // before any network I/O. + qm, err := newQueryMatcher(path, query, current, allowed) + if (err == nil && qm.canStat) || err == errRevQuery { + // Direct lookup of a commit identifier or complete (non-prefix) semantic + // version. + + // If the identifier is not a canonical semver tag — including if it's a + // semver tag with a +metadata suffix — then modfetch.Stat will populate + // info.Version with a suitable pseudo-version. + info, err := repo.Stat(ctx, query) + if err != nil { + queryErr := err + // The full query doesn't correspond to a tag. If it is a semantic version + // with a +metadata suffix, see if there is a tag without that suffix: + // semantic versioning defines them to be equivalent. + canonicalQuery := module.CanonicalVersion(query) + if canonicalQuery != "" && query != canonicalQuery { + info, err = repo.Stat(ctx, canonicalQuery) + if err != nil && !errors.Is(err, fs.ErrNotExist) { + return info, err + } + } + if err != nil { + return info, queryErr + } + } + if err := allowed(ctx, module.Version{Path: path, Version: info.Version}); errors.Is(err, ErrDisallowed) { + return nil, err + } + return info, nil + } else if err != nil { + return nil, err + } + + // Load versions and execute query. + versions, err := repo.Versions(ctx, qm.prefix) + if err != nil { + return nil, err + } + origin := versions.Origin + + revWithOrigin := func(rev *modfetch.RevInfo) *modfetch.RevInfo { + if rev == nil { + if origin == nil { + return nil + } + return &modfetch.RevInfo{Origin: origin} + } + + clone := *rev + clone.Origin = origin + return &clone + } + + releases, prereleases, err := qm.filterVersions(loaderstate, ctx, versions.List) + if err != nil { + return revWithOrigin(nil), err + } + + lookup := func(v string) (*modfetch.RevInfo, error) { + rev, err := repo.Stat(ctx, v) + if rev != nil { + // Note that Stat can return a non-nil rev and a non-nil err, + // in order to provide origin information to make the error cacheable. + origin = mergeOrigin(origin, rev.Origin) + } + if err != nil { + return revWithOrigin(nil), err + } + + if (query == "upgrade" || query == "patch") && module.IsPseudoVersion(current) && !rev.Time.IsZero() { + // Don't allow "upgrade" or "patch" to move from a pseudo-version + // to a chronologically older version or pseudo-version. + // + // If the current version is a pseudo-version from an untagged branch, it + // may be semantically lower than the "latest" release or the latest + // pseudo-version on the main branch. A user on such a version is unlikely + // to intend to “upgrade” to a version that already existed at that point + // in time. + // + // We do this only if the current version is a pseudo-version: if the + // version is tagged, the author of the dependency module has given us + // explicit information about their intended precedence of this version + // relative to other versions, and we shouldn't contradict that + // information. (For example, v1.0.1 might be a backport of a fix already + // incorporated into v1.1.0, in which case v1.0.1 would be chronologically + // newer but v1.1.0 is still an “upgrade”; or v1.0.2 might be a revert of + // an unsuccessful fix in v1.0.1, in which case the v1.0.2 commit may be + // older than the v1.0.1 commit despite the tag itself being newer.) + currentTime, err := module.PseudoVersionTime(current) + if err == nil && rev.Time.Before(currentTime) { + if err := allowed(ctx, module.Version{Path: path, Version: current}); errors.Is(err, ErrDisallowed) { + return revWithOrigin(nil), err + } + rev, err = repo.Stat(ctx, current) + if rev != nil { + origin = mergeOrigin(origin, rev.Origin) + } + if err != nil { + return revWithOrigin(nil), err + } + return revWithOrigin(rev), nil + } + } + + return revWithOrigin(rev), nil + } + + if qm.preferLower { + if len(releases) > 0 { + return lookup(releases[0]) + } + if len(prereleases) > 0 { + return lookup(prereleases[0]) + } + } else { + if len(releases) > 0 { + return lookup(releases[len(releases)-1]) + } + if len(prereleases) > 0 { + return lookup(prereleases[len(prereleases)-1]) + } + } + + if qm.mayUseLatest { + latest, err := repo.Latest(ctx) + if latest != nil { + origin = mergeOrigin(origin, latest.Origin) + } + if err == nil { + if qm.allowsVersion(ctx, latest.Version) { + return lookup(latest.Version) + } + } else if !errors.Is(err, fs.ErrNotExist) { + return revWithOrigin(nil), err + } + } + + if (query == "upgrade" || query == "patch") && current != "" && current != "none" { + // "upgrade" and "patch" may stay on the current version if allowed. + if err := allowed(ctx, module.Version{Path: path, Version: current}); errors.Is(err, ErrDisallowed) { + return revWithOrigin(nil), err + } + return lookup(current) + } + + return revWithOrigin(nil), &NoMatchingVersionError{query: query, current: current} +} + +// IsRevisionQuery returns true if vers is a version query that may refer to +// a particular version or revision in a repository like "v1.0.0", "master", +// or "0123abcd". IsRevisionQuery returns false if vers is a query that +// chooses from among available versions like "latest" or ">v1.0.0". +func IsRevisionQuery(path, vers string) bool { + if vers == "latest" || + vers == "upgrade" || + vers == "patch" || + strings.HasPrefix(vers, "<") || + strings.HasPrefix(vers, ">") || + (gover.ModIsValid(path, vers) && gover.ModIsPrefix(path, vers)) { + return false + } + return true +} + +type queryMatcher struct { + path string + prefix string + filter func(version string) bool + allowed AllowedFunc + canStat bool // if true, the query can be resolved by repo.Stat + preferLower bool // if true, choose the lowest matching version + mayUseLatest bool + preferIncompatible bool +} + +var errRevQuery = errors.New("query refers to a non-semver revision") + +// newQueryMatcher returns a new queryMatcher that matches the versions +// specified by the given query on the module with the given path. +// +// If the query can only be resolved by statting a non-SemVer revision, +// newQueryMatcher returns errRevQuery. +func newQueryMatcher(path string, query, current string, allowed AllowedFunc) (*queryMatcher, error) { + badVersion := func(v string) (*queryMatcher, error) { + return nil, fmt.Errorf("invalid semantic version %q in range %q", v, query) + } + + matchesMajor := func(v string) bool { + _, pathMajor, ok := module.SplitPathVersion(path) + if !ok { + return false + } + return module.CheckPathMajor(v, pathMajor) == nil + } + + qm := &queryMatcher{ + path: path, + allowed: allowed, + preferIncompatible: strings.HasSuffix(current, "+incompatible"), + } + + switch { + case query == "latest": + qm.mayUseLatest = true + + case query == "upgrade": + if current == "" || current == "none" { + qm.mayUseLatest = true + } else { + qm.mayUseLatest = module.IsPseudoVersion(current) + qm.filter = func(mv string) bool { return gover.ModCompare(qm.path, mv, current) >= 0 } + } + + case query == "patch": + if current == "" || current == "none" { + return nil, &NoPatchBaseError{path} + } + if current == "" { + qm.mayUseLatest = true + } else { + qm.mayUseLatest = module.IsPseudoVersion(current) + qm.prefix = gover.ModMajorMinor(qm.path, current) + "." + qm.filter = func(mv string) bool { return gover.ModCompare(qm.path, mv, current) >= 0 } + } + + case strings.HasPrefix(query, "<="): + v := query[len("<="):] + if !gover.ModIsValid(path, v) { + return badVersion(v) + } + if gover.ModIsPrefix(path, v) { + // Refuse to say whether <=v1.2 allows v1.2.3 (remember, @v1.2 might mean v1.2.3). + return nil, fmt.Errorf("ambiguous semantic version %q in range %q", v, query) + } + qm.filter = func(mv string) bool { return gover.ModCompare(qm.path, mv, v) <= 0 } + if !matchesMajor(v) { + qm.preferIncompatible = true + } + + case strings.HasPrefix(query, "<"): + v := query[len("<"):] + if !gover.ModIsValid(path, v) { + return badVersion(v) + } + qm.filter = func(mv string) bool { return gover.ModCompare(qm.path, mv, v) < 0 } + if !matchesMajor(v) { + qm.preferIncompatible = true + } + + case strings.HasPrefix(query, ">="): + v := query[len(">="):] + if !gover.ModIsValid(path, v) { + return badVersion(v) + } + qm.filter = func(mv string) bool { return gover.ModCompare(qm.path, mv, v) >= 0 } + qm.preferLower = true + if !matchesMajor(v) { + qm.preferIncompatible = true + } + + case strings.HasPrefix(query, ">"): + v := query[len(">"):] + if !gover.ModIsValid(path, v) { + return badVersion(v) + } + if gover.ModIsPrefix(path, v) { + // Refuse to say whether >v1.2 allows v1.2.3 (remember, @v1.2 might mean v1.2.3). + return nil, fmt.Errorf("ambiguous semantic version %q in range %q", v, query) + } + qm.filter = func(mv string) bool { return gover.ModCompare(qm.path, mv, v) > 0 } + qm.preferLower = true + if !matchesMajor(v) { + qm.preferIncompatible = true + } + + case gover.ModIsValid(path, query): + if gover.ModIsPrefix(path, query) { + qm.prefix = query + "." + // Do not allow the query "v1.2" to match versions lower than "v1.2.0", + // such as prereleases for that version. (https://golang.org/issue/31972) + qm.filter = func(mv string) bool { return gover.ModCompare(qm.path, mv, query) >= 0 } + } else { + qm.canStat = true + qm.filter = func(mv string) bool { return gover.ModCompare(qm.path, mv, query) == 0 } + qm.prefix = semver.Canonical(query) + } + if !matchesMajor(query) { + qm.preferIncompatible = true + } + + default: + return nil, errRevQuery + } + + return qm, nil +} + +// allowsVersion reports whether version v is allowed by the prefix, filter, and +// AllowedFunc of qm. +func (qm *queryMatcher) allowsVersion(ctx context.Context, v string) bool { + if qm.prefix != "" && !strings.HasPrefix(v, qm.prefix) { + if gover.IsToolchain(qm.path) && strings.TrimSuffix(qm.prefix, ".") == v { + // Allow 1.21 to match "1.21." prefix. + } else { + return false + } + } + if qm.filter != nil && !qm.filter(v) { + return false + } + if qm.allowed != nil { + if err := qm.allowed(ctx, module.Version{Path: qm.path, Version: v}); errors.Is(err, ErrDisallowed) { + return false + } + } + return true +} + +// filterVersions classifies versions into releases and pre-releases, filtering +// out: +// 1. versions that do not satisfy the 'allowed' predicate, and +// 2. "+incompatible" versions, if a compatible one satisfies the predicate +// and the incompatible version is not preferred. +// +// If the allowed predicate returns an error not equivalent to ErrDisallowed, +// filterVersions returns that error. +func (qm *queryMatcher) filterVersions(loaderstate *State, ctx context.Context, versions []string) (releases, prereleases []string, err error) { + needIncompatible := qm.preferIncompatible + + var lastCompatible string + for _, v := range versions { + if !qm.allowsVersion(ctx, v) { + continue + } + + if !needIncompatible { + // We're not yet sure whether we need to include +incompatible versions. + // Keep track of the last compatible version we've seen, and use the + // presence (or absence) of a go.mod file in that version to decide: a + // go.mod file implies that the module author is supporting modules at a + // compatible version (and we should ignore +incompatible versions unless + // requested explicitly), while a lack of go.mod file implies the + // potential for legacy (pre-modules) versioning without semantic import + // paths (and thus *with* +incompatible versions). + // + // This isn't strictly accurate if the latest compatible version has been + // replaced by a local file path, because we do not allow file-path + // replacements without a go.mod file: the user would have needed to add + // one. However, replacing the last compatible version while + // simultaneously expecting to upgrade implicitly to a +incompatible + // version seems like an extreme enough corner case to ignore for now. + + if !strings.HasSuffix(v, "+incompatible") { + lastCompatible = v + } else if lastCompatible != "" { + // If the latest compatible version is allowed and has a go.mod file, + // ignore any version with a higher (+incompatible) major version. (See + // https://golang.org/issue/34165.) Note that we even prefer a + // compatible pre-release over an incompatible release. + ok, err := versionHasGoMod(loaderstate, ctx, module.Version{Path: qm.path, Version: lastCompatible}) + if err != nil { + return nil, nil, err + } + if ok { + // The last compatible version has a go.mod file, so that's the + // highest version we're willing to consider. Don't bother even + // looking at higher versions, because they're all +incompatible from + // here onward. + break + } + + // No acceptable compatible release has a go.mod file, so the versioning + // for the module might not be module-aware, and we should respect + // legacy major-version tags. + needIncompatible = true + } + } + + if gover.ModIsPrerelease(qm.path, v) { + prereleases = append(prereleases, v) + } else { + releases = append(releases, v) + } + } + + return releases, prereleases, nil +} + +type QueryResult struct { + Mod module.Version + Rev *modfetch.RevInfo + Packages []string +} + +// QueryPackages is like QueryPattern, but requires that the pattern match at +// least one package and omits the non-package result (if any). +func QueryPackages(loaderstate *State, ctx context.Context, pattern, query string, current func(string) string, allowed AllowedFunc) ([]QueryResult, error) { + pkgMods, modOnly, err := QueryPattern(loaderstate, ctx, pattern, query, current, allowed) + + if len(pkgMods) == 0 && err == nil { + replacement := Replacement(loaderstate, modOnly.Mod) + return nil, &PackageNotInModuleError{ + Mod: modOnly.Mod, + Replacement: replacement, + Query: query, + Pattern: pattern, + } + } + + return pkgMods, err +} + +// QueryPattern looks up the module(s) containing at least one package matching +// the given pattern at the given version. The results are sorted by module path +// length in descending order. If any proxy provides a non-empty set of candidate +// modules, no further proxies are tried. +// +// For wildcard patterns, QueryPattern looks in modules with package paths up to +// the first "..." in the pattern. For the pattern "example.com/a/b.../c", +// QueryPattern would consider prefixes of "example.com/a". +// +// If any matching package is in the main module, QueryPattern considers only +// the main module and only the version "latest", without checking for other +// possible modules. +// +// QueryPattern always returns at least one QueryResult (which may be only +// modOnly) or a non-nil error. +func QueryPattern(loaderstate *State, ctx context.Context, pattern, query string, current func(string) string, allowed AllowedFunc) (pkgMods []QueryResult, modOnly *QueryResult, err error) { + ctx, span := trace.StartSpan(ctx, "modload.QueryPattern "+pattern+" "+query) + defer span.Done() + + base := pattern + + firstError := func(m *search.Match) error { + if len(m.Errs) == 0 { + return nil + } + return m.Errs[0] + } + + var match func(mod module.Version, roots []string, isLocal bool) *search.Match + matchPattern := pkgpattern.MatchPattern(pattern) + + if i := strings.Index(pattern, "..."); i >= 0 { + base = pathpkg.Dir(pattern[:i+3]) + if base == "." { + return nil, nil, &WildcardInFirstElementError{Pattern: pattern, Query: query} + } + match = func(mod module.Version, roots []string, isLocal bool) *search.Match { + m := search.NewMatch(pattern) + matchPackages(loaderstate, ctx, m, imports.AnyTags(), omitStd, []module.Version{mod}) + return m + } + } else { + match = func(mod module.Version, roots []string, isLocal bool) *search.Match { + m := search.NewMatch(pattern) + prefix := mod.Path + if loaderstate.MainModules.Contains(mod.Path) { + prefix = loaderstate.MainModules.PathPrefix(module.Version{Path: mod.Path}) + } + for _, root := range roots { + if _, ok, err := dirInModule(pattern, prefix, root, isLocal); err != nil { + m.AddError(err) + } else if ok { + m.Pkgs = []string{pattern} + } + } + return m + } + } + + var mainModuleMatches []module.Version + for _, mainModule := range loaderstate.MainModules.Versions() { + m := match(mainModule, loaderstate.modRoots, true) + if len(m.Pkgs) > 0 { + if query != "upgrade" && query != "patch" { + return nil, nil, &QueryMatchesPackagesInMainModuleError{ + Pattern: pattern, + Query: query, + Packages: m.Pkgs, + } + } + if err := allowed(ctx, mainModule); err != nil { + return nil, nil, fmt.Errorf("internal error: package %s is in the main module (%s), but version is not allowed: %w", pattern, mainModule.Path, err) + } + return []QueryResult{{ + Mod: mainModule, + Rev: &modfetch.RevInfo{Version: mainModule.Version}, + Packages: m.Pkgs, + }}, nil, nil + } + if err := firstError(m); err != nil { + return nil, nil, err + } + + var matchesMainModule bool + if matchPattern(mainModule.Path) { + mainModuleMatches = append(mainModuleMatches, mainModule) + matchesMainModule = true + } + + if (query == "upgrade" || query == "patch") && matchesMainModule { + if err := allowed(ctx, mainModule); err == nil { + modOnly = &QueryResult{ + Mod: mainModule, + Rev: &modfetch.RevInfo{Version: mainModule.Version}, + } + } + } + } + + var ( + results []QueryResult + candidateModules = modulePrefixesExcludingTarget(loaderstate, base) + ) + if len(candidateModules) == 0 { + if modOnly != nil { + return nil, modOnly, nil + } else if len(mainModuleMatches) != 0 { + return nil, nil, &QueryMatchesMainModulesError{ + MainModules: mainModuleMatches, + Pattern: pattern, + Query: query, + PatternIsModule: loaderstate.MainModules.Contains(pattern), + } + } else { + return nil, nil, &PackageNotInModuleError{ + MainModules: mainModuleMatches, + Query: query, + Pattern: pattern, + } + } + } + + err = modfetch.TryProxies(func(proxy string) error { + queryModule := func(ctx context.Context, path string) (r QueryResult, err error) { + ctx, span := trace.StartSpan(ctx, "modload.QueryPattern.queryModule ["+proxy+"] "+path) + defer span.Done() + + pathCurrent := current(path) + r.Mod.Path = path + r.Rev, err = queryProxy(loaderstate, ctx, proxy, path, query, pathCurrent, allowed, nil) + if err != nil { + return r, err + } + r.Mod.Version = r.Rev.Version + if gover.IsToolchain(r.Mod.Path) { + return r, nil + } + root, isLocal, err := fetch(loaderstate, ctx, r.Mod) + if err != nil { + return r, err + } + m := match(r.Mod, []string{root}, isLocal) + r.Packages = m.Pkgs + if len(r.Packages) == 0 && !matchPattern(path) { + if err := firstError(m); err != nil { + return r, err + } + replacement := Replacement(loaderstate, r.Mod) + return r, &PackageNotInModuleError{ + Mod: r.Mod, + Replacement: replacement, + Query: query, + Pattern: pattern, + } + } + return r, nil + } + + allResults, err := queryPrefixModules(loaderstate, ctx, candidateModules, queryModule) + results = allResults[:0] + for _, r := range allResults { + if len(r.Packages) == 0 { + modOnly = &r + } else { + results = append(results, r) + } + } + return err + }) + + if len(mainModuleMatches) > 0 && len(results) == 0 && modOnly == nil && errors.Is(err, fs.ErrNotExist) { + return nil, nil, &QueryMatchesMainModulesError{ + Pattern: pattern, + Query: query, + PatternIsModule: loaderstate.MainModules.Contains(pattern), + } + } + return slices.Clip(results), modOnly, err +} + +// modulePrefixesExcludingTarget returns all prefixes of path that may plausibly +// exist as a module, excluding targetPrefix but otherwise including path +// itself, sorted by descending length. Prefixes that are not valid module paths +// but are valid package paths (like "m" or "example.com/.gen") are included, +// since they might be replaced. +func modulePrefixesExcludingTarget(loaderstate *State, path string) []string { + prefixes := make([]string, 0, strings.Count(path, "/")+1) + + mainModulePrefixes := make(map[string]bool) + for _, m := range loaderstate.MainModules.Versions() { + mainModulePrefixes[m.Path] = true + } + + for { + if !mainModulePrefixes[path] { + if _, _, ok := module.SplitPathVersion(path); ok { + prefixes = append(prefixes, path) + } + } + + j := strings.LastIndexByte(path, '/') + if j < 0 { + break + } + path = path[:j] + } + + return prefixes +} + +func queryPrefixModules(loaderstate *State, ctx context.Context, candidateModules []string, queryModule func(ctx context.Context, path string) (QueryResult, error)) (found []QueryResult, err error) { + ctx, span := trace.StartSpan(ctx, "modload.queryPrefixModules") + defer span.Done() + + // If the path we're attempting is not in the module cache and we don't have a + // fetch result cached either, we'll end up making a (potentially slow) + // request to the proxy or (often even slower) the origin server. + // To minimize latency, execute all of those requests in parallel. + type result struct { + QueryResult + err error + } + results := make([]result, len(candidateModules)) + var wg sync.WaitGroup + wg.Add(len(candidateModules)) + for i, p := range candidateModules { + ctx := trace.StartGoroutine(ctx) + go func(p string, r *result) { + r.QueryResult, r.err = queryModule(ctx, p) + wg.Done() + }(p, &results[i]) + } + wg.Wait() + + // Classify the results. In case of failure, identify the error that the user + // is most likely to find helpful: the most useful class of error at the + // longest matching path. + var ( + noPackage *PackageNotInModuleError + noVersion *NoMatchingVersionError + noPatchBase *NoPatchBaseError + invalidPath *module.InvalidPathError // see comment in case below + invalidVersion error + notExistErr error + ) + for _, r := range results { + switch rErr := r.err.(type) { + case nil: + found = append(found, r.QueryResult) + case *PackageNotInModuleError: + // Given the option, prefer to attribute “package not in module” + // to modules other than the main one. + if noPackage == nil || loaderstate.MainModules.Contains(noPackage.Mod.Path) { + noPackage = rErr + } + case *NoMatchingVersionError: + if noVersion == nil { + noVersion = rErr + } + case *NoPatchBaseError: + if noPatchBase == nil { + noPatchBase = rErr + } + case *module.InvalidPathError: + // The prefix was not a valid module path, and there was no replacement. + // Prefixes like this may appear in candidateModules, since we handle + // replaced modules that weren't required in the repo lookup process + // (see lookupRepo). + // + // A shorter prefix may be a valid module path and may contain a valid + // import path, so this is a low-priority error. + if invalidPath == nil { + invalidPath = rErr + } + default: + if errors.Is(rErr, fs.ErrNotExist) { + if notExistErr == nil { + notExistErr = rErr + } + } else if _, ok := errors.AsType[*module.InvalidVersionError](rErr); ok { + if invalidVersion == nil { + invalidVersion = rErr + } + } else if err == nil { + if len(found) > 0 || noPackage != nil { + // golang.org/issue/34094: If we have already found a module that + // could potentially contain the target package, ignore unclassified + // errors for modules with shorter paths. + + // golang.org/issue/34383 is a special case of this: if we have + // already found example.com/foo/v2@v2.0.0 with a matching go.mod + // file, ignore the error from example.com/foo@v2.0.0. + } else { + err = r.err + } + } + } + } + + // TODO(#26232): If len(found) == 0 and some of the errors are 4xx HTTP + // codes, have the auth package recheck the failed paths. + // If we obtain new credentials for any of them, re-run the above loop. + + if len(found) == 0 && err == nil { + switch { + case noPackage != nil: + err = noPackage + case noVersion != nil: + err = noVersion + case noPatchBase != nil: + err = noPatchBase + case invalidPath != nil: + err = invalidPath + case invalidVersion != nil: + err = invalidVersion + case notExistErr != nil: + err = notExistErr + default: + panic("queryPrefixModules: no modules found, but no error detected") + } + } + + return found, err +} + +// A NoMatchingVersionError indicates that Query found a module at the requested +// path, but not at any versions satisfying the query string and allow-function. +// +// NOTE: NoMatchingVersionError MUST NOT implement Is(fs.ErrNotExist). +// +// If the module came from a proxy, that proxy had to return a successful status +// code for the versions it knows about, and thus did not have the opportunity +// to return a non-400 status code to suppress fallback. +type NoMatchingVersionError struct { + query, current string +} + +func (e *NoMatchingVersionError) Error() string { + currentSuffix := "" + if (e.query == "upgrade" || e.query == "patch") && e.current != "" && e.current != "none" { + currentSuffix = fmt.Sprintf(" (current version is %s)", e.current) + } + return fmt.Sprintf("no matching versions for query %q", e.query) + currentSuffix +} + +// A NoPatchBaseError indicates that Query was called with the query "patch" +// but with a current version of "" or "none". +type NoPatchBaseError struct { + path string +} + +func (e *NoPatchBaseError) Error() string { + return fmt.Sprintf(`can't query version "patch" of module %s: no existing version is required`, e.path) +} + +// A WildcardInFirstElementError indicates that a pattern passed to QueryPattern +// had a wildcard in its first path element, and therefore had no pattern-prefix +// modules to search in. +type WildcardInFirstElementError struct { + Pattern string + Query string +} + +func (e *WildcardInFirstElementError) Error() string { + return fmt.Sprintf("no modules to query for %s@%s because first path element contains a wildcard", e.Pattern, e.Query) +} + +// A PackageNotInModuleError indicates that QueryPattern found a candidate +// module at the requested version, but that module did not contain any packages +// matching the requested pattern. +// +// NOTE: PackageNotInModuleError MUST NOT implement Is(fs.ErrNotExist). +// +// If the module came from a proxy, that proxy had to return a successful status +// code for the versions it knows about, and thus did not have the opportunity +// to return a non-400 status code to suppress fallback. +type PackageNotInModuleError struct { + MainModules []module.Version + Mod module.Version + Replacement module.Version + Query string + Pattern string +} + +func (e *PackageNotInModuleError) Error() string { + if len(e.MainModules) > 0 { + prefix := "workspace modules do" + if len(e.MainModules) == 1 { + prefix = fmt.Sprintf("main module (%s) does", e.MainModules[0]) + } + if strings.Contains(e.Pattern, "...") { + return fmt.Sprintf("%s not contain packages matching %s", prefix, e.Pattern) + } + return fmt.Sprintf("%s not contain package %s", prefix, e.Pattern) + } + + found := "" + if r := e.Replacement; r.Path != "" { + replacement := r.Path + if r.Version != "" { + replacement = fmt.Sprintf("%s@%s", r.Path, r.Version) + } + if e.Query == e.Mod.Version { + found = fmt.Sprintf(" (replaced by %s)", replacement) + } else { + found = fmt.Sprintf(" (%s, replaced by %s)", e.Mod.Version, replacement) + } + } else if e.Query != e.Mod.Version { + found = fmt.Sprintf(" (%s)", e.Mod.Version) + } + + if strings.Contains(e.Pattern, "...") { + return fmt.Sprintf("module %s@%s found%s, but does not contain packages matching %s", e.Mod.Path, e.Query, found, e.Pattern) + } + return fmt.Sprintf("module %s@%s found%s, but does not contain package %s", e.Mod.Path, e.Query, found, e.Pattern) +} + +func (e *PackageNotInModuleError) ImportPath() string { + if !strings.Contains(e.Pattern, "...") { + return e.Pattern + } + return "" +} + +// versionHasGoMod returns whether a version has a go.mod file. +// +// versionHasGoMod fetches the go.mod file (possibly a fake) and true if it +// contains anything other than a module directive with the same path. When a +// module does not have a real go.mod file, the go command acts as if it had one +// that only contained a module directive. Normal go.mod files created after +// 1.12 at least have a go directive. +// +// This function is a heuristic, since it's possible to commit a file that would +// pass this test. However, we only need a heuristic for determining whether +// +incompatible versions may be "latest", which is what this function is used +// for. +// +// This heuristic is useful for two reasons: first, when using a proxy, +// this lets us fetch from the .mod endpoint which is much faster than the .zip +// endpoint. The .mod file is used anyway, even if the .zip file contains a +// go.mod with different content. Second, if we don't fetch the .zip, then +// we don't need to verify it in go.sum. This makes 'go list -m -u' faster +// and simpler. +func versionHasGoMod(loaderstate *State, _ context.Context, m module.Version) (bool, error) { + _, data, err := rawGoModData(loaderstate, m) + if err != nil { + return false, err + } + isFake := bytes.Equal(data, modfetch.LegacyGoMod(m.Path)) + return !isFake, nil +} + +// A versionRepo is a subset of modfetch.Repo that can report information about +// available versions, but cannot fetch specific source files. +type versionRepo interface { + ModulePath() string + CheckReuse(context.Context, *codehost.Origin) error + Versions(ctx context.Context, prefix string) (*modfetch.Versions, error) + Stat(ctx context.Context, rev string) (*modfetch.RevInfo, error) + Latest(ctx context.Context) (*modfetch.RevInfo, error) +} + +var _ versionRepo = modfetch.Repo(nil) + +func lookupRepo(loaderstate *State, ctx context.Context, proxy, path string) (repo versionRepo, err error) { + if path != "go" && path != "toolchain" { + err = module.CheckPath(path) + } + if err == nil { + repo = loaderstate.Fetcher().Lookup(ctx, proxy, path) + } else { + repo = emptyRepo{path: path, err: err} + } + + if loaderstate.MainModules == nil { + return repo, err + } else if _, ok := loaderstate.MainModules.HighestReplaced()[path]; ok { + return &replacementRepo{repo: repo, loaderstate: loaderstate}, nil + } + + return repo, err +} + +// An emptyRepo is a versionRepo that contains no versions. +type emptyRepo struct { + path string + err error +} + +var _ versionRepo = emptyRepo{} + +func (er emptyRepo) ModulePath() string { return er.path } +func (er emptyRepo) CheckReuse(ctx context.Context, old *codehost.Origin) error { + return fmt.Errorf("empty repo") +} + +func (er emptyRepo) Versions(ctx context.Context, prefix string) (*modfetch.Versions, error) { + return &modfetch.Versions{}, nil +} + +func (er emptyRepo) Stat(ctx context.Context, rev string) (*modfetch.RevInfo, error) { + return nil, er.err +} +func (er emptyRepo) Latest(ctx context.Context) (*modfetch.RevInfo, error) { return nil, er.err } + +// A replacementRepo augments a versionRepo to include the replacement versions +// (if any) found in the main module's go.mod file. +// +// A replacementRepo suppresses "not found" errors for otherwise-nonexistent +// modules, so a replacementRepo should only be constructed for a module that +// actually has one or more valid replacements. +type replacementRepo struct { + repo versionRepo + loaderstate *State +} + +var _ versionRepo = (*replacementRepo)(nil) + +func (rr *replacementRepo) ModulePath() string { return rr.repo.ModulePath() } + +func (rr *replacementRepo) CheckReuse(ctx context.Context, old *codehost.Origin) error { + return fmt.Errorf("replacement repo") +} + +// Versions returns the versions from rr.repo augmented with any matching +// replacement versions. +func (rr *replacementRepo) Versions(ctx context.Context, prefix string) (*modfetch.Versions, error) { + repoVersions, err := rr.repo.Versions(ctx, prefix) + if err != nil { + if !errors.Is(err, os.ErrNotExist) { + return nil, err + } + repoVersions = new(modfetch.Versions) + } + + versions := repoVersions.List + for _, mm := range rr.loaderstate.MainModules.Versions() { + if index := rr.loaderstate.MainModules.Index(mm); index != nil && len(index.replace) > 0 { + path := rr.ModulePath() + for m := range index.replace { + if m.Path == path && strings.HasPrefix(m.Version, prefix) && m.Version != "" && !module.IsPseudoVersion(m.Version) { + versions = append(versions, m.Version) + } + } + } + } + + if len(versions) == len(repoVersions.List) { // replacement versions added + return repoVersions, nil + } + + path := rr.ModulePath() + sort.Slice(versions, func(i, j int) bool { + return gover.ModCompare(path, versions[i], versions[j]) < 0 + }) + str.Uniq(&versions) + return &modfetch.Versions{List: versions}, nil +} + +func (rr *replacementRepo) Stat(ctx context.Context, rev string) (*modfetch.RevInfo, error) { + info, err := rr.repo.Stat(ctx, rev) + if err == nil { + return info, err + } + var hasReplacements bool + for _, v := range rr.loaderstate.MainModules.Versions() { + if index := rr.loaderstate.MainModules.Index(v); index != nil && len(index.replace) > 0 { + hasReplacements = true + } + } + if !hasReplacements { + return info, err + } + + v := module.CanonicalVersion(rev) + if v != rev { + // The replacements in the go.mod file list only canonical semantic versions, + // so a non-canonical version can't possibly have a replacement. + return info, err + } + + path := rr.ModulePath() + _, pathMajor, ok := module.SplitPathVersion(path) + if ok && pathMajor == "" { + if err := module.CheckPathMajor(v, pathMajor); err != nil && semver.Build(v) == "" { + v += "+incompatible" + } + } + + if r := Replacement(rr.loaderstate, module.Version{Path: path, Version: v}); r.Path == "" { + return info, err + } + return rr.replacementStat(v) +} + +func (rr *replacementRepo) Latest(ctx context.Context) (*modfetch.RevInfo, error) { + info, err := rr.repo.Latest(ctx) + path := rr.ModulePath() + + if v, ok := rr.loaderstate.MainModules.HighestReplaced()[path]; ok { + if v == "" { + // The only replacement is a wildcard that doesn't specify a version, so + // synthesize a pseudo-version with an appropriate major version and a + // timestamp below any real timestamp. That way, if the main module is + // used from within some other module, the user will be able to upgrade + // the requirement to any real version they choose. + if _, pathMajor, ok := module.SplitPathVersion(path); ok && len(pathMajor) > 0 { + v = module.PseudoVersion(pathMajor[1:], "", time.Time{}, "000000000000") + } else { + v = module.PseudoVersion("v0", "", time.Time{}, "000000000000") + } + } + + if err != nil || gover.ModCompare(path, v, info.Version) > 0 { + return rr.replacementStat(v) + } + } + + return info, err +} + +func (rr *replacementRepo) replacementStat(v string) (*modfetch.RevInfo, error) { + rev := &modfetch.RevInfo{Version: v} + if module.IsPseudoVersion(v) { + rev.Time, _ = module.PseudoVersionTime(v) + rev.Short, _ = module.PseudoVersionRev(v) + } + return rev, nil +} + +// A QueryMatchesMainModulesError indicates that a query requests +// a version of the main module that cannot be satisfied. +// (The main module's version cannot be changed.) +type QueryMatchesMainModulesError struct { + MainModules []module.Version + Pattern string + Query string + PatternIsModule bool // true if pattern is one of the main modules +} + +func (e *QueryMatchesMainModulesError) Error() string { + if e.PatternIsModule { + return fmt.Sprintf("can't request version %q of the main module (%s)", e.Query, e.Pattern) + } + + plural := "" + mainModulePaths := make([]string, len(e.MainModules)) + for i := range e.MainModules { + mainModulePaths[i] = e.MainModules[i].Path + } + if len(e.MainModules) > 1 { + plural = "s" + } + return fmt.Sprintf("can't request version %q of pattern %q that includes the main module%s (%s)", e.Query, e.Pattern, plural, strings.Join(mainModulePaths, ", ")) +} + +// A QueryUpgradesAllError indicates that a query requests +// an upgrade on the all pattern. +// (The main module's version cannot be changed.) +type QueryUpgradesAllError struct { + MainModules []module.Version + Query string +} + +func (e *QueryUpgradesAllError) Error() string { + var plural string = "" + if len(e.MainModules) != 1 { + plural = "s" + } + + return fmt.Sprintf("can't request version %q of pattern \"all\" that includes the main module%s", e.Query, plural) +} + +// A QueryMatchesPackagesInMainModuleError indicates that a query cannot be +// satisfied because it matches one or more packages found in the main module. +type QueryMatchesPackagesInMainModuleError struct { + Pattern string + Query string + Packages []string +} + +func (e *QueryMatchesPackagesInMainModuleError) Error() string { + if len(e.Packages) > 1 { + return fmt.Sprintf("pattern %s matches %d packages in the main module, so can't request version %s", e.Pattern, len(e.Packages), e.Query) + } + + if search.IsMetaPackage(e.Pattern) || strings.Contains(e.Pattern, "...") { + return fmt.Sprintf("pattern %s matches package %s in the main module, so can't request version %s", e.Pattern, e.Packages[0], e.Query) + } + + return fmt.Sprintf("package %s is in the main module, so can't request version %s", e.Packages[0], e.Query) +} diff --git a/go/src/cmd/go/internal/modload/query_test.go b/go/src/cmd/go/internal/modload/query_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a465fab5db39338520bd3e33a8226e25a796838b --- /dev/null +++ b/go/src/cmd/go/internal/modload/query_test.go @@ -0,0 +1,203 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "context" + "flag" + "internal/testenv" + "log" + "os" + "path" + "path/filepath" + "strings" + "testing" + + "cmd/go/internal/cfg" + "cmd/go/internal/vcweb/vcstest" + + "golang.org/x/mod/module" +) + +func TestMain(m *testing.M) { + flag.Parse() + if err := testMain(m); err != nil { + log.Fatal(err) + } +} + +func testMain(m *testing.M) (err error) { + cfg.GOPROXY = "direct" + cfg.ModCacheRW = true + + srv, err := vcstest.NewServer() + if err != nil { + return err + } + defer func() { + if closeErr := srv.Close(); err == nil { + err = closeErr + } + }() + + dir, err := os.MkdirTemp("", "modload-test-") + if err != nil { + return err + } + defer func() { + if rmErr := os.RemoveAll(dir); err == nil { + err = rmErr + } + }() + + os.Setenv("GOPATH", dir) + cfg.BuildContext.GOPATH = dir + cfg.GOMODCACHE = filepath.Join(dir, "pkg/mod") + cfg.SumdbDir = filepath.Join(dir, "pkg/sumdb") + m.Run() + return nil +} + +var ( + queryRepo = "vcs-test.golang.org/git/querytest.git" + queryRepoV2 = queryRepo + "/v2" + queryRepoV3 = queryRepo + "/v3" + + // Empty version list (no semver tags), not actually empty. + emptyRepoPath = "vcs-test.golang.org/git/emptytest.git" +) + +var queryTests = []struct { + path string + query string + current string + allow string + vers string + err string +}{ + {path: queryRepo, query: "v0.0.0", vers: "v0.0.1"}, + {path: queryRepo, query: ">=v0.0.0", vers: "v0.0.0"}, + {path: queryRepo, query: "v0.0.1", vers: "v0.0.1"}, + {path: queryRepo, query: "v0.0.1+foo", vers: "v0.0.1"}, + {path: queryRepo, query: "v0.0.99", err: `vcs-test.golang.org/git/querytest.git@v0.0.99: invalid version: unknown revision v0.0.99`}, + {path: queryRepo, query: "v0", vers: "v0.3.0"}, + {path: queryRepo, query: "v0.1", vers: "v0.1.2"}, + {path: queryRepo, query: "v0.2", err: `no matching versions for query "v0.2"`}, + {path: queryRepo, query: "v0.0", vers: "v0.0.3"}, + {path: queryRepo, query: "v1.9.10-pre2+metadata", vers: "v1.9.10-pre2.0.20190513201126-42abcb6df8ee"}, + {path: queryRepo, query: "ed5ffdaa", vers: "v1.9.10-pre2.0.20191220134614-ed5ffdaa1f5e"}, + + // golang.org/issue/29262: The major version for a module without a suffix + // should be based on the most recent tag (v1 as appropriate, not v0 + // unconditionally). + {path: queryRepo, query: "42abcb6df8ee", vers: "v1.9.10-pre2.0.20190513201126-42abcb6df8ee"}, + + {path: queryRepo, query: "v1.9.10-pre2+wrongmetadata", err: `vcs-test.golang.org/git/querytest.git@v1.9.10-pre2+wrongmetadata: invalid version: unknown revision v1.9.10-pre2+wrongmetadata`}, + {path: queryRepo, query: "v1.9.10-pre2", err: `vcs-test.golang.org/git/querytest.git@v1.9.10-pre2: invalid version: unknown revision v1.9.10-pre2`}, + {path: queryRepo, query: "latest", vers: "v1.9.9"}, + {path: queryRepo, query: "latest", current: "v1.9.10-pre1", vers: "v1.9.9"}, + {path: queryRepo, query: "upgrade", vers: "v1.9.9"}, + {path: queryRepo, query: "upgrade", current: "v1.9.10-pre1", vers: "v1.9.10-pre1"}, + {path: queryRepo, query: "upgrade", current: "v1.9.10-pre2+metadata", vers: "v1.9.10-pre2.0.20190513201126-42abcb6df8ee"}, + {path: queryRepo, query: "upgrade", current: "v0.0.0-20190513201126-42abcb6df8ee", vers: "v0.0.0-20190513201126-42abcb6df8ee"}, + {path: queryRepo, query: "upgrade", allow: "NOMATCH", err: `no matching versions for query "upgrade"`}, + {path: queryRepo, query: "upgrade", current: "v1.9.9", allow: "NOMATCH", err: `vcs-test.golang.org/git/querytest.git@v1.9.9: disallowed module version`}, + {path: queryRepo, query: "upgrade", current: "v1.99.99", err: `vcs-test.golang.org/git/querytest.git@v1.99.99: invalid version: unknown revision v1.99.99`}, + {path: queryRepo, query: "patch", current: "", err: `can't query version "patch" of module vcs-test.golang.org/git/querytest.git: no existing version is required`}, + {path: queryRepo, query: "patch", current: "v0.1.0", vers: "v0.1.2"}, + {path: queryRepo, query: "patch", current: "v1.9.0", vers: "v1.9.9"}, + {path: queryRepo, query: "patch", current: "v1.9.10-pre1", vers: "v1.9.10-pre1"}, + {path: queryRepo, query: "patch", current: "v1.9.10-pre2+metadata", vers: "v1.9.10-pre2.0.20190513201126-42abcb6df8ee"}, + {path: queryRepo, query: "patch", current: "v1.99.99", err: `vcs-test.golang.org/git/querytest.git@v1.99.99: invalid version: unknown revision v1.99.99`}, + {path: queryRepo, query: ">v1.9.9", vers: "v1.9.10-pre1"}, + {path: queryRepo, query: ">v1.10.0", err: `no matching versions for query ">v1.10.0"`}, + {path: queryRepo, query: ">=v1.10.0", err: `no matching versions for query ">=v1.10.0"`}, + {path: queryRepo, query: "6cf84eb", vers: "v0.0.2-0.20180704023347-6cf84ebaea54"}, + + // golang.org/issue/27173: A pseudo-version may be based on the highest tag on + // any parent commit, or any existing semantically-lower tag: a given commit + // could have been a pre-release for a backport tag at any point. + {path: queryRepo, query: "3ef0cec634e0", vers: "v0.1.2-0.20180704023347-3ef0cec634e0"}, + {path: queryRepo, query: "v0.1.2-0.20180704023347-3ef0cec634e0", vers: "v0.1.2-0.20180704023347-3ef0cec634e0"}, + {path: queryRepo, query: "v0.1.1-0.20180704023347-3ef0cec634e0", vers: "v0.1.1-0.20180704023347-3ef0cec634e0"}, + {path: queryRepo, query: "v0.0.4-0.20180704023347-3ef0cec634e0", vers: "v0.0.4-0.20180704023347-3ef0cec634e0"}, + + // Invalid tags are tested in cmd/go/testdata/script/mod_pseudo_invalid.txt. + + {path: queryRepo, query: "start", vers: "v0.0.0-20180704023101-5e9e31667ddf"}, + {path: queryRepo, query: "5e9e31667ddf", vers: "v0.0.0-20180704023101-5e9e31667ddf"}, + {path: queryRepo, query: "v0.0.0-20180704023101-5e9e31667ddf", vers: "v0.0.0-20180704023101-5e9e31667ddf"}, + + {path: queryRepo, query: "7a1b6bf", vers: "v0.1.0"}, + + {path: queryRepoV2, query: "v0.0.0", vers: "v2.0.0"}, + {path: queryRepoV2, query: ">=v0.0.0", vers: "v2.0.0"}, + + {path: queryRepoV2, query: "v2", vers: "v2.5.5"}, + {path: queryRepoV2, query: "v2.5", vers: "v2.5.5"}, + {path: queryRepoV2, query: "v2.6", err: `no matching versions for query "v2.6"`}, + {path: queryRepoV2, query: "v2.6.0-pre1", vers: "v2.6.0-pre1"}, + {path: queryRepoV2, query: "latest", vers: "v2.5.5"}, + + // Commit e0cf3de987e6 is actually v1.19.10-pre1, not anything resembling v3, + // and it has a go.mod file with a non-v3 module path. Attempting to query it + // as the v3 module should fail. + {path: queryRepoV3, query: "e0cf3de987e6", err: `vcs-test.golang.org/git/querytest.git/v3@v3.0.0-20180704024501-e0cf3de987e6: invalid version: go.mod has non-.../v3 module path "vcs-test.golang.org/git/querytest.git" (and .../v3/go.mod does not exist) at revision e0cf3de987e6`}, + + // The querytest repo does not have any commits tagged with major version 3, + // and the latest commit in the repo has a go.mod file specifying a non-v3 path. + // That should prevent us from resolving any version for the /v3 path. + {path: queryRepoV3, query: "latest", err: `no matching versions for query "latest"`}, + + {path: emptyRepoPath, query: "latest", vers: "v0.0.0-20180704023549-7bb914627242"}, + {path: emptyRepoPath, query: ">v0.0.0", err: `no matching versions for query ">v0.0.0"`}, + {path: emptyRepoPath, query: " *search.IgnorePatterns. +func parseIgnorePatterns(loaderstate *State, ctx context.Context, treeCanMatch func(string) bool, modules []module.Version) map[string]*search.IgnorePatterns { + ignorePatternsMap := make(map[string]*search.IgnorePatterns) + for _, mod := range modules { + if gover.IsToolchain(mod.Path) || !treeCanMatch(mod.Path) { + continue + } + var modRoot string + var ignorePatterns []string + if loaderstate.MainModules.Contains(mod.Path) { + modRoot = loaderstate.MainModules.ModRoot(mod) + if modRoot == "" { + continue + } + modIndex := loaderstate.MainModules.Index(mod) + if modIndex == nil { + continue + } + ignorePatterns = modIndex.ignore + } else if cfg.BuildMod != "vendor" { + // Skip getting ignore patterns for vendored modules because they + // do not have go.mod files. + var err error + modRoot, _, err = fetch(loaderstate, ctx, mod) + if err != nil { + continue + } + summary, err := goModSummary(loaderstate, mod) + if err != nil { + continue + } + ignorePatterns = summary.ignore + } + ignorePatternsMap[modRoot] = search.NewIgnorePatterns(ignorePatterns) + } + return ignorePatternsMap +} diff --git a/go/src/cmd/go/internal/modload/stat_openfile.go b/go/src/cmd/go/internal/modload/stat_openfile.go new file mode 100644 index 0000000000000000000000000000000000000000..5773073d903554c063545c55c9e94be9c05f8e28 --- /dev/null +++ b/go/src/cmd/go/internal/modload/stat_openfile.go @@ -0,0 +1,28 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build (js && wasm) || plan9 + +// On plan9, per http://9p.io/magic/man2html/2/access: “Since file permissions +// are checked by the server and group information is not known to the client, +// access must open the file to check permissions.” +// +// js,wasm is similar, in that it does not define syscall.Access. + +package modload + +import ( + "io/fs" + "os" +) + +// hasWritePerm reports whether the current user has permission to write to the +// file with the given info. +func hasWritePerm(path string, _ fs.FileInfo) bool { + if f, err := os.OpenFile(path, os.O_WRONLY, 0); err == nil { + f.Close() + return true + } + return false +} diff --git a/go/src/cmd/go/internal/modload/stat_unix.go b/go/src/cmd/go/internal/modload/stat_unix.go new file mode 100644 index 0000000000000000000000000000000000000000..a0d5f4d2476ed122615e3a15e8610b1ed92232e6 --- /dev/null +++ b/go/src/cmd/go/internal/modload/stat_unix.go @@ -0,0 +1,32 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix + +package modload + +import ( + "io/fs" + "os" + "syscall" +) + +// hasWritePerm reports whether the current user has permission to write to the +// file with the given info. +// +// Although the root user on most Unix systems can write to files even without +// permission, hasWritePerm reports false if no appropriate permission bit is +// set even if the current user is root. +func hasWritePerm(path string, fi fs.FileInfo) bool { + if os.Getuid() == 0 { + // The root user can access any file, but we still want to default to + // read-only mode if the go.mod file is marked as globally non-writable. + // (If the user really intends not to be in readonly mode, they can + // pass -mod=mod explicitly.) + return fi.Mode()&0222 != 0 + } + + const W_OK = 0x2 + return syscall.Access(path, W_OK) == nil +} diff --git a/go/src/cmd/go/internal/modload/stat_windows.go b/go/src/cmd/go/internal/modload/stat_windows.go new file mode 100644 index 0000000000000000000000000000000000000000..f29a99165e53001faec5e8553e670a82803522dc --- /dev/null +++ b/go/src/cmd/go/internal/modload/stat_windows.go @@ -0,0 +1,21 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build windows + +package modload + +import "io/fs" + +// hasWritePerm reports whether the current user has permission to write to the +// file with the given info. +func hasWritePerm(_ string, fi fs.FileInfo) bool { + // Windows has a read-only attribute independent of ACLs, so use that to + // determine whether the file is intended to be overwritten. + // + // Per https://golang.org/pkg/os/#Chmod: + // “On Windows, only the 0200 bit (owner writable) of mode is used; it + // controls whether the file's read-only attribute is set or cleared.” + return fi.Mode()&0200 != 0 +} diff --git a/go/src/cmd/go/internal/modload/vendor.go b/go/src/cmd/go/internal/modload/vendor.go new file mode 100644 index 0000000000000000000000000000000000000000..9956bcdb1272906e8d04946c272db53f3dd323be --- /dev/null +++ b/go/src/cmd/go/internal/modload/vendor.go @@ -0,0 +1,284 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "errors" + "fmt" + "io/fs" + "os" + "path/filepath" + "strings" + "sync" + + "cmd/go/internal/base" + "cmd/go/internal/gover" + + "golang.org/x/mod/modfile" + "golang.org/x/mod/module" + "golang.org/x/mod/semver" +) + +var ( + vendorOnce sync.Once + vendorList []module.Version // modules that contribute packages to the build, in order of appearance + vendorReplaced []module.Version // all replaced modules; may or may not also contribute packages + vendorVersion map[string]string // module path → selected version (if known) + vendorPkgModule map[string]module.Version // package → containing module + vendorMeta map[module.Version]vendorMetadata +) + +type vendorMetadata struct { + Explicit bool + Replacement module.Version + GoVersion string +} + +// readVendorList reads the list of vendored modules from vendor/modules.txt. +func readVendorList(vendorDir string) { + vendorOnce.Do(func() { + vendorList = nil + vendorPkgModule = make(map[string]module.Version) + vendorVersion = make(map[string]string) + vendorMeta = make(map[module.Version]vendorMetadata) + vendorFile := filepath.Join(vendorDir, "modules.txt") + data, err := os.ReadFile(vendorFile) + if err != nil { + if !errors.Is(err, fs.ErrNotExist) { + base.Fatalf("go: %s", err) + } + return + } + + var mod module.Version + for line := range strings.SplitSeq(string(data), "\n") { + if strings.HasPrefix(line, "# ") { + f := strings.Fields(line) + + if len(f) < 3 { + continue + } + if semver.IsValid(f[2]) { + // A module, but we don't yet know whether it is in the build list or + // only included to indicate a replacement. + mod = module.Version{Path: f[1], Version: f[2]} + f = f[3:] + } else if f[2] == "=>" { + // A wildcard replacement found in the main module's go.mod file. + mod = module.Version{Path: f[1]} + f = f[2:] + } else { + // Not a version or a wildcard replacement. + // We don't know how to interpret this module line, so ignore it. + mod = module.Version{} + continue + } + + if len(f) >= 2 && f[0] == "=>" { + meta := vendorMeta[mod] + if len(f) == 2 { + // File replacement. + meta.Replacement = module.Version{Path: f[1]} + vendorReplaced = append(vendorReplaced, mod) + } else if len(f) == 3 && semver.IsValid(f[2]) { + // Path and version replacement. + meta.Replacement = module.Version{Path: f[1], Version: f[2]} + vendorReplaced = append(vendorReplaced, mod) + } else { + // We don't understand this replacement. Ignore it. + } + vendorMeta[mod] = meta + } + continue + } + + // Not a module line. Must be a package within a module or a metadata + // directive, either of which requires a preceding module line. + if mod.Path == "" { + continue + } + + if annotations, ok := strings.CutPrefix(line, "## "); ok { + // Metadata. Take the union of annotations across multiple lines, if present. + meta := vendorMeta[mod] + for entry := range strings.SplitSeq(annotations, ";") { + entry = strings.TrimSpace(entry) + if entry == "explicit" { + meta.Explicit = true + } + if goVersion, ok := strings.CutPrefix(entry, "go "); ok { + meta.GoVersion = goVersion + rawGoVersion.Store(mod, meta.GoVersion) + if gover.Compare(goVersion, gover.Local()) > 0 { + base.Fatal(&gover.TooNewError{What: mod.Path + " in " + base.ShortPath(vendorFile), GoVersion: goVersion}) + } + } + // All other tokens are reserved for future use. + } + vendorMeta[mod] = meta + continue + } + + if f := strings.Fields(line); len(f) == 1 && module.CheckImportPath(f[0]) == nil { + // A package within the current module. + vendorPkgModule[f[0]] = mod + + // Since this module provides a package for the build, we know that it + // is in the build list and is the selected version of its path. + // If this information is new, record it. + if v, ok := vendorVersion[mod.Path]; !ok || gover.ModCompare(mod.Path, v, mod.Version) < 0 { + vendorList = append(vendorList, mod) + vendorVersion[mod.Path] = mod.Version + } + } + } + }) +} + +// checkVendorConsistency verifies that the vendor/modules.txt file matches (if +// go 1.14) or at least does not contradict (go 1.13 or earlier) the +// requirements and replacements listed in the main module's go.mod file. +func checkVendorConsistency(loaderstate *State, indexes []*modFileIndex, modFiles []*modfile.File, modRoots []string) { + // readVendorList only needs the main module to get the directory + // the vendor directory is in. + readVendorList(VendorDir(loaderstate)) + + if len(modFiles) < 1 { + // We should never get here if there are zero modfiles. Either + // we're in single module mode and there's a single module, or + // we're in workspace mode, and we fail earlier reporting that + // "no modules were found in the current workspace". + panic("checkVendorConsistency called with zero modfiles") + } + + pre114 := false + if !loaderstate.inWorkspaceMode() { // workspace mode was added after Go 1.14 + if len(indexes) != 1 { + panic(fmt.Errorf("not in workspace mode but number of indexes is %v, not 1", len(indexes))) + } + index := indexes[0] + if gover.Compare(index.goVersion, "1.14") < 0 { + // Go versions before 1.14 did not include enough information in + // vendor/modules.txt to check for consistency. + // If we know that we're on an earlier version, relax the consistency check. + pre114 = true + } + } + + vendErrors := new(strings.Builder) + vendErrorf := func(mod module.Version, format string, args ...any) { + detail := fmt.Sprintf(format, args...) + if mod.Version == "" { + fmt.Fprintf(vendErrors, "\n\t%s: %s", mod.Path, detail) + } else { + fmt.Fprintf(vendErrors, "\n\t%s@%s: %s", mod.Path, mod.Version, detail) + } + } + + // Iterate over the Require directives in their original (not indexed) order + // so that the errors match the original file. + for _, modFile := range modFiles { + for _, r := range modFile.Require { + if !vendorMeta[r.Mod].Explicit { + if pre114 { + // Before 1.14, modules.txt did not indicate whether modules were listed + // explicitly in the main module's go.mod file. + // However, we can at least detect a version mismatch if packages were + // vendored from a non-matching version. + if vv, ok := vendorVersion[r.Mod.Path]; ok && vv != r.Mod.Version { + vendErrorf(r.Mod, "is explicitly required in go.mod, but vendor/modules.txt indicates %s@%s", r.Mod.Path, vv) + } + } else { + vendErrorf(r.Mod, "is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt") + } + } + } + } + + describe := func(m module.Version) string { + if m.Version == "" { + return m.Path + } + return m.Path + "@" + m.Version + } + + // We need to verify *all* replacements that occur in modfile: even if they + // don't directly apply to any module in the vendor list, the replacement + // go.mod file can affect the selected versions of other (transitive) + // dependencies + seenrep := make(map[module.Version]bool) + checkReplace := func(replaces []*modfile.Replace) { + for _, r := range replaces { + if seenrep[r.Old] { + continue // Don't print the same error more than once + } + seenrep[r.Old] = true + rNew, modRoot, replacementSource := replacementFrom(loaderstate, r.Old) + rNewCanonical := canonicalizeReplacePath(loaderstate, rNew, modRoot) + vr := vendorMeta[r.Old].Replacement + if vr == (module.Version{}) { + if rNewCanonical == (module.Version{}) { + // r.Old is not actually replaced. It might be a main module. + // Don't return an error. + } else if pre114 && (r.Old.Version == "" || vendorVersion[r.Old.Path] != r.Old.Version) { + // Before 1.14, modules.txt omitted wildcard replacements and + // replacements for modules that did not have any packages to vendor. + } else { + vendErrorf(r.Old, "is replaced in %s, but not marked as replaced in vendor/modules.txt", base.ShortPath(replacementSource)) + } + } else if vr != rNewCanonical { + vendErrorf(r.Old, "is replaced by %s in %s, but marked as replaced by %s in vendor/modules.txt", describe(rNew), base.ShortPath(replacementSource), describe(vr)) + } + } + } + for _, modFile := range modFiles { + checkReplace(modFile.Replace) + } + if loaderstate.MainModules.workFile != nil { + checkReplace(loaderstate.MainModules.workFile.Replace) + } + + for _, mod := range vendorList { + meta := vendorMeta[mod] + if meta.Explicit { + // in workspace mode, check that it's required by at least one of the main modules + var foundRequire bool + for _, index := range indexes { + if _, inGoMod := index.require[mod]; inGoMod { + foundRequire = true + } + } + if !foundRequire { + article := "" + if loaderstate.inWorkspaceMode() { + article = "a " + } + vendErrorf(mod, "is marked as explicit in vendor/modules.txt, but not explicitly required in %vgo.mod", article) + } + + } + } + + for _, mod := range vendorReplaced { + r := Replacement(loaderstate, mod) + replacementSource := "go.mod" + if loaderstate.inWorkspaceMode() { + replacementSource = "the workspace" + } + if r == (module.Version{}) { + vendErrorf(mod, "is marked as replaced in vendor/modules.txt, but not replaced in %s", replacementSource) + continue + } + // If both replacements exist, we've already reported that they're different above. + } + + if vendErrors.Len() > 0 { + subcmd := "mod" + if loaderstate.inWorkspaceMode() { + subcmd = "work" + } + base.Fatalf("go: inconsistent vendoring in %s:%s\n\n\tTo ignore the vendor directory, use -mod=readonly or -mod=mod.\n\tTo sync the vendor directory, run:\n\t\tgo %s vendor", filepath.Dir(VendorDir(loaderstate)), vendErrors, subcmd) + } +} diff --git a/go/src/cmd/go/internal/mvs/errors.go b/go/src/cmd/go/internal/mvs/errors.go new file mode 100644 index 0000000000000000000000000000000000000000..8db65d656f027691220dcc2842e115e794f508ca --- /dev/null +++ b/go/src/cmd/go/internal/mvs/errors.go @@ -0,0 +1,105 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mvs + +import ( + "fmt" + "strings" + + "golang.org/x/mod/module" +) + +// BuildListError decorates an error that occurred gathering requirements +// while constructing a build list. BuildListError prints the chain +// of requirements to the module where the error occurred. +type BuildListError struct { + Err error + stack []buildListErrorElem +} + +type buildListErrorElem struct { + m module.Version + + // nextReason is the reason this module depends on the next module in the + // stack. Typically either "requires", or "updating to". + nextReason string +} + +// NewBuildListError returns a new BuildListError wrapping an error that +// occurred at a module found along the given path of requirements and/or +// upgrades, which must be non-empty. +// +// The isVersionChange function reports whether a path step is due to an +// explicit upgrade or downgrade (as opposed to an existing requirement in a +// go.mod file). A nil isVersionChange function indicates that none of the path +// steps are due to explicit version changes. +func NewBuildListError(err error, path []module.Version, isVersionChange func(from, to module.Version) bool) *BuildListError { + stack := make([]buildListErrorElem, 0, len(path)) + for len(path) > 1 { + reason := "requires" + if isVersionChange != nil && isVersionChange(path[0], path[1]) { + reason = "updating to" + } + stack = append(stack, buildListErrorElem{ + m: path[0], + nextReason: reason, + }) + path = path[1:] + } + stack = append(stack, buildListErrorElem{m: path[0]}) + + return &BuildListError{ + Err: err, + stack: stack, + } +} + +// Module returns the module where the error occurred. If the module stack +// is empty, this returns a zero value. +func (e *BuildListError) Module() module.Version { + if len(e.stack) == 0 { + return module.Version{} + } + return e.stack[len(e.stack)-1].m +} + +func (e *BuildListError) Error() string { + b := &strings.Builder{} + stack := e.stack + + // Don't print modules at the beginning of the chain without a + // version. These always seem to be the main module or a + // synthetic module ("target@"). + for len(stack) > 0 && stack[0].m.Version == "" { + stack = stack[1:] + } + + if len(stack) == 0 { + b.WriteString(e.Err.Error()) + } else { + for _, elem := range stack[:len(stack)-1] { + fmt.Fprintf(b, "%s %s\n\t", elem.m, elem.nextReason) + } + // Ensure that the final module path and version are included as part of the + // error message. + m := stack[len(stack)-1].m + if mErr, ok := e.Err.(*module.ModuleError); ok { + actual := module.Version{Path: mErr.Path, Version: mErr.Version} + if v, ok := mErr.Err.(*module.InvalidVersionError); ok { + actual.Version = v.Version + } + if actual == m { + fmt.Fprintf(b, "%v", e.Err) + } else { + fmt.Fprintf(b, "%s (replaced by %s): %v", m, actual, mErr.Err) + } + } else { + fmt.Fprintf(b, "%v", module.VersionError(m, e.Err)) + } + } + return b.String() +} + +func (e *BuildListError) Unwrap() error { return e.Err } diff --git a/go/src/cmd/go/internal/mvs/graph.go b/go/src/cmd/go/internal/mvs/graph.go new file mode 100644 index 0000000000000000000000000000000000000000..56b3c604eb1b9b5a5ecfb842003ab48d8581fd47 --- /dev/null +++ b/go/src/cmd/go/internal/mvs/graph.go @@ -0,0 +1,226 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mvs + +import ( + "fmt" + "slices" + + "cmd/go/internal/gover" + + "golang.org/x/mod/module" +) + +// Graph implements an incremental version of the MVS algorithm, with the +// requirements pushed by the caller instead of pulled by the MVS traversal. +type Graph struct { + cmp func(p, v1, v2 string) int + roots []module.Version + + required map[module.Version][]module.Version + + isRoot map[module.Version]bool // contains true for roots and false for reachable non-roots + selected map[string]string // path → version +} + +// NewGraph returns an incremental MVS graph containing only a set of root +// dependencies and using the given max function for version strings. +// +// The caller must ensure that the root slice is not modified while the Graph +// may be in use. +func NewGraph(cmp func(p, v1, v2 string) int, roots []module.Version) *Graph { + g := &Graph{ + cmp: cmp, + roots: slices.Clip(roots), + required: make(map[module.Version][]module.Version), + isRoot: make(map[module.Version]bool), + selected: make(map[string]string), + } + + for _, m := range roots { + g.isRoot[m] = true + if g.cmp(m.Path, g.Selected(m.Path), m.Version) < 0 { + g.selected[m.Path] = m.Version + } + } + + return g +} + +// Require adds the information that module m requires all modules in reqs. +// The reqs slice must not be modified after it is passed to Require. +// +// m must be reachable by some existing chain of requirements from g's target, +// and Require must not have been called for it already. +// +// If any of the modules in reqs has the same path as g's target, +// the target must have higher precedence than the version in req. +func (g *Graph) Require(m module.Version, reqs []module.Version) { + // To help catch disconnected-graph bugs, enforce that all required versions + // are actually reachable from the roots (and therefore should affect the + // selected versions of the modules they name). + if _, reachable := g.isRoot[m]; !reachable { + panic(fmt.Sprintf("%v is not reachable from any root", m)) + } + + // Truncate reqs to its capacity to avoid aliasing bugs if it is later + // returned from RequiredBy and appended to. + reqs = slices.Clip(reqs) + + if _, dup := g.required[m]; dup { + panic(fmt.Sprintf("requirements of %v have already been set", m)) + } + g.required[m] = reqs + + for _, dep := range reqs { + // Mark dep reachable, regardless of whether it is selected. + if _, ok := g.isRoot[dep]; !ok { + g.isRoot[dep] = false + } + + if g.cmp(dep.Path, g.Selected(dep.Path), dep.Version) < 0 { + g.selected[dep.Path] = dep.Version + } + } +} + +// RequiredBy returns the slice of requirements passed to Require for m, if any, +// with its capacity reduced to its length. +// If Require has not been called for m, RequiredBy(m) returns ok=false. +// +// The caller must not modify the returned slice, but may safely append to it +// and may rely on it not to be modified. +func (g *Graph) RequiredBy(m module.Version) (reqs []module.Version, ok bool) { + reqs, ok = g.required[m] + return reqs, ok +} + +// Selected returns the selected version of the given module path. +// +// If no version is selected, Selected returns version "none". +func (g *Graph) Selected(path string) (version string) { + v, ok := g.selected[path] + if !ok { + return "none" + } + return v +} + +// BuildList returns the selected versions of all modules present in the Graph, +// beginning with the selected versions of each module path in the roots of g. +// +// The order of the remaining elements in the list is deterministic +// but arbitrary. +func (g *Graph) BuildList() []module.Version { + seenRoot := make(map[string]bool, len(g.roots)) + + var list []module.Version + for _, r := range g.roots { + if seenRoot[r.Path] { + // Multiple copies of the same root, with the same or different versions, + // are a bit of a degenerate case: we will take the transitive + // requirements of both roots into account, but only the higher one can + // possibly be selected. However — especially given that we need the + // seenRoot map for later anyway — it is simpler to support this + // degenerate case than to forbid it. + continue + } + + if v := g.Selected(r.Path); v != "none" { + list = append(list, module.Version{Path: r.Path, Version: v}) + } + seenRoot[r.Path] = true + } + uniqueRoots := list + + for path, version := range g.selected { + if !seenRoot[path] { + list = append(list, module.Version{Path: path, Version: version}) + } + } + gover.ModSort(list[len(uniqueRoots):]) + + return list +} + +// WalkBreadthFirst invokes f once, in breadth-first order, for each module +// version other than "none" that appears in the graph, regardless of whether +// that version is selected. +func (g *Graph) WalkBreadthFirst(f func(m module.Version)) { + var queue []module.Version + enqueued := make(map[module.Version]bool) + for _, m := range g.roots { + if m.Version != "none" { + queue = append(queue, m) + enqueued[m] = true + } + } + + for len(queue) > 0 { + m := queue[0] + queue = queue[1:] + + f(m) + + reqs, _ := g.RequiredBy(m) + for _, r := range reqs { + if !enqueued[r] && r.Version != "none" { + queue = append(queue, r) + enqueued[r] = true + } + } + } +} + +// FindPath reports a shortest requirement path starting at one of the roots of +// the graph and ending at a module version m for which f(m) returns true, or +// nil if no such path exists. +func (g *Graph) FindPath(f func(module.Version) bool) []module.Version { + // firstRequires[a] = b means that in a breadth-first traversal of the + // requirement graph, the module version a was first required by b. + firstRequires := make(map[module.Version]module.Version) + + queue := g.roots + for _, m := range g.roots { + firstRequires[m] = module.Version{} + } + + for len(queue) > 0 { + m := queue[0] + queue = queue[1:] + + if f(m) { + // Construct the path reversed (because we're starting from the far + // endpoint), then reverse it. + path := []module.Version{m} + for { + m = firstRequires[m] + if m.Path == "" { + break + } + path = append(path, m) + } + + i, j := 0, len(path)-1 + for i < j { + path[i], path[j] = path[j], path[i] + i++ + j-- + } + + return path + } + + reqs, _ := g.RequiredBy(m) + for _, r := range reqs { + if _, seen := firstRequires[r]; !seen { + queue = append(queue, r) + firstRequires[r] = m + } + } + } + + return nil +} diff --git a/go/src/cmd/go/internal/mvs/mvs.go b/go/src/cmd/go/internal/mvs/mvs.go new file mode 100644 index 0000000000000000000000000000000000000000..50f8cb61ccdcfeba0951953184a3db6004a2c58c --- /dev/null +++ b/go/src/cmd/go/internal/mvs/mvs.go @@ -0,0 +1,488 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package mvs implements Minimal Version Selection. +// See https://research.swtch.com/vgo-mvs. +package mvs + +import ( + "fmt" + "slices" + "sort" + "sync" + + "cmd/internal/par" + + "golang.org/x/mod/module" +) + +// A Reqs is the requirement graph on which Minimal Version Selection (MVS) operates. +// +// The version strings are opaque except for the special version "none" +// (see the documentation for module.Version). In particular, MVS does not +// assume that the version strings are semantic versions; instead, the Max method +// gives access to the comparison operation. +// +// It must be safe to call methods on a Reqs from multiple goroutines simultaneously. +// Because a Reqs may read the underlying graph from the network on demand, +// the MVS algorithms parallelize the traversal to overlap network delays. +type Reqs interface { + // Required returns the module versions explicitly required by m itself. + // The caller must not modify the returned list. + Required(m module.Version) ([]module.Version, error) + + // Max returns the maximum of v1 and v2 (it returns either v1 or v2) + // in the module with path p. + // + // For all versions v, Max(v, "none") must be v, + // and for the target passed as the first argument to MVS functions, + // Max(target, v) must be target. + // + // Note that v1 < v2 can be written Max(v1, v2) != v1 + // and similarly v1 <= v2 can be written Max(v1, v2) == v2. + Max(p, v1, v2 string) string +} + +// An UpgradeReqs is a Reqs that can also identify available upgrades. +type UpgradeReqs interface { + Reqs + + // Upgrade returns the upgraded version of m, + // for use during an UpgradeAll operation. + // If m should be kept as is, Upgrade returns m. + // If m is not yet used in the build, then m.Version will be "none". + // More typically, m.Version will be the version required + // by some other module in the build. + // + // If no module version is available for the given path, + // Upgrade returns a non-nil error. + // TODO(rsc): Upgrade must be able to return errors, + // but should "no latest version" just return m instead? + Upgrade(m module.Version) (module.Version, error) +} + +// A DowngradeReqs is a Reqs that can also identify available downgrades. +type DowngradeReqs interface { + Reqs + + // Previous returns the version of m.Path immediately prior to m.Version, + // or "none" if no such version is known. + Previous(m module.Version) (module.Version, error) +} + +// BuildList returns the build list for the target module. +// +// target is the root vertex of a module requirement graph. For cmd/go, this is +// typically the main module, but note that this algorithm is not intended to +// be Go-specific: module paths and versions are treated as opaque values. +// +// reqs describes the module requirement graph and provides an opaque method +// for comparing versions. +// +// BuildList traverses the graph and returns a list containing the highest +// version for each visited module. The first element of the returned list is +// target itself; reqs.Max requires target.Version to compare higher than all +// other versions, so no other version can be selected. The remaining elements +// of the list are sorted by path. +// +// See https://research.swtch.com/vgo-mvs for details. +func BuildList(targets []module.Version, reqs Reqs) ([]module.Version, error) { + return buildList(targets, reqs, nil) +} + +func buildList(targets []module.Version, reqs Reqs, upgrade func(module.Version) (module.Version, error)) ([]module.Version, error) { + cmp := func(p, v1, v2 string) int { + if reqs.Max(p, v1, v2) != v1 { + return -1 + } + if reqs.Max(p, v2, v1) != v2 { + return 1 + } + return 0 + } + + var ( + mu sync.Mutex + g = NewGraph(cmp, targets) + upgrades = map[module.Version]module.Version{} + errs = map[module.Version]error{} // (non-nil errors only) + ) + + // Explore work graph in parallel in case reqs.Required + // does high-latency network operations. + var work par.Work[module.Version] + for _, target := range targets { + work.Add(target) + } + work.Do(10, func(m module.Version) { + + var required []module.Version + var err error + if m.Version != "none" { + required, err = reqs.Required(m) + } + + u := m + if upgrade != nil { + upgradeTo, upErr := upgrade(m) + if upErr == nil { + u = upgradeTo + } else if err == nil { + err = upErr + } + } + + mu.Lock() + if err != nil { + errs[m] = err + } + if u != m { + upgrades[m] = u + required = append([]module.Version{u}, required...) + } + g.Require(m, required) + mu.Unlock() + + for _, r := range required { + work.Add(r) + } + }) + + // If there was an error, find the shortest path from the target to the + // node where the error occurred so we can report a useful error message. + if len(errs) > 0 { + errPath := g.FindPath(func(m module.Version) bool { + return errs[m] != nil + }) + if len(errPath) == 0 { + panic("internal error: could not reconstruct path to module with error") + } + + err := errs[errPath[len(errPath)-1]] + isUpgrade := func(from, to module.Version) bool { + if u, ok := upgrades[from]; ok { + return u == to + } + return false + } + return nil, NewBuildListError(err, errPath, isUpgrade) + } + + // The final list is the minimum version of each module found in the graph. + list := g.BuildList() + if vs := list[:len(targets)]; !slices.Equal(vs, targets) { + // target.Version will be "" for modload, the main client of MVS. + // "" denotes the main module, which has no version. However, MVS treats + // version strings as opaque, so "" is not a special value here. + // See golang.org/issue/31491, golang.org/issue/29773. + panic(fmt.Sprintf("mistake: chose versions %+v instead of targets %+v", vs, targets)) + } + return list, nil +} + +// Req returns the minimal requirement list for the target module, +// with the constraint that all module paths listed in base must +// appear in the returned list. +func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version, error) { + list, err := BuildList([]module.Version{mainModule}, reqs) + if err != nil { + return nil, err + } + + // Note: Not running in parallel because we assume + // that list came from a previous operation that paged + // in all the requirements, so there's no I/O to overlap now. + + max := map[string]string{} + for _, m := range list { + max[m.Path] = m.Version + } + + // Compute postorder, cache requirements. + var postorder []module.Version + reqCache := map[module.Version][]module.Version{} + reqCache[mainModule] = nil + + var walk func(module.Version) error + walk = func(m module.Version) error { + _, ok := reqCache[m] + if ok { + return nil + } + required, err := reqs.Required(m) + if err != nil { + return err + } + reqCache[m] = required + for _, m1 := range required { + if err := walk(m1); err != nil { + return err + } + } + postorder = append(postorder, m) + return nil + } + for _, m := range list { + if err := walk(m); err != nil { + return nil, err + } + } + + // Walk modules in reverse post-order, only adding those not implied already. + have := map[module.Version]bool{} + walk = func(m module.Version) error { + if have[m] { + return nil + } + have[m] = true + for _, m1 := range reqCache[m] { + walk(m1) + } + return nil + } + // First walk the base modules that must be listed. + var min []module.Version + haveBase := map[string]bool{} + for _, path := range base { + if haveBase[path] { + continue + } + m := module.Version{Path: path, Version: max[path]} + min = append(min, m) + walk(m) + haveBase[path] = true + } + // Now the reverse postorder to bring in anything else. + for i := len(postorder) - 1; i >= 0; i-- { + m := postorder[i] + if max[m.Path] != m.Version { + // Older version. + continue + } + if !have[m] { + min = append(min, m) + walk(m) + } + } + sort.Slice(min, func(i, j int) bool { + return min[i].Path < min[j].Path + }) + return min, nil +} + +// UpgradeAll returns a build list for the target module +// in which every module is upgraded to its latest version. +func UpgradeAll(target module.Version, reqs UpgradeReqs) ([]module.Version, error) { + return buildList([]module.Version{target}, reqs, func(m module.Version) (module.Version, error) { + if m.Path == target.Path { + return target, nil + } + + return reqs.Upgrade(m) + }) +} + +// Upgrade returns a build list for the target module +// in which the given additional modules are upgraded. +func Upgrade(target module.Version, reqs UpgradeReqs, upgrade ...module.Version) ([]module.Version, error) { + list, err := reqs.Required(target) + if err != nil { + return nil, err + } + + pathInList := make(map[string]bool, len(list)) + for _, m := range list { + pathInList[m.Path] = true + } + list = append([]module.Version(nil), list...) + + upgradeTo := make(map[string]string, len(upgrade)) + for _, u := range upgrade { + if !pathInList[u.Path] { + list = append(list, module.Version{Path: u.Path, Version: "none"}) + } + if prev, dup := upgradeTo[u.Path]; dup { + upgradeTo[u.Path] = reqs.Max(u.Path, prev, u.Version) + } else { + upgradeTo[u.Path] = u.Version + } + } + + return buildList([]module.Version{target}, &override{target, list, reqs}, func(m module.Version) (module.Version, error) { + if v, ok := upgradeTo[m.Path]; ok { + return module.Version{Path: m.Path, Version: v}, nil + } + return m, nil + }) +} + +// Downgrade returns a build list for the target module +// in which the given additional modules are downgraded, +// potentially overriding the requirements of the target. +// +// The versions to be downgraded may be unreachable from reqs.Latest and +// reqs.Previous, but the methods of reqs must otherwise handle such versions +// correctly. +func Downgrade(target module.Version, reqs DowngradeReqs, downgrade ...module.Version) ([]module.Version, error) { + // Per https://research.swtch.com/vgo-mvs#algorithm_4: + // “To avoid an unnecessary downgrade to E 1.1, we must also add a new + // requirement on E 1.2. We can apply Algorithm R to find the minimal set of + // new requirements to write to go.mod.” + // + // In order to generate those new requirements, we need to identify versions + // for every module in the build list — not just reqs.Required(target). + list, err := BuildList([]module.Version{target}, reqs) + if err != nil { + return nil, err + } + list = list[1:] // remove target + + max := make(map[string]string) + for _, r := range list { + max[r.Path] = r.Version + } + for _, d := range downgrade { + if v, ok := max[d.Path]; !ok || reqs.Max(d.Path, v, d.Version) != d.Version { + max[d.Path] = d.Version + } + } + + var ( + added = make(map[module.Version]bool) + rdeps = make(map[module.Version][]module.Version) + excluded = make(map[module.Version]bool) + ) + var exclude func(module.Version) + exclude = func(m module.Version) { + if excluded[m] { + return + } + excluded[m] = true + for _, p := range rdeps[m] { + exclude(p) + } + } + var add func(module.Version) + add = func(m module.Version) { + if added[m] { + return + } + added[m] = true + if v, ok := max[m.Path]; ok && reqs.Max(m.Path, m.Version, v) != v { + // m would upgrade an existing dependency — it is not a strict downgrade, + // and because it was already present as a dependency, it could affect the + // behavior of other relevant packages. + exclude(m) + return + } + list, err := reqs.Required(m) + if err != nil { + // If we can't load the requirements, we couldn't load the go.mod file. + // There are a number of reasons this can happen, but this usually + // means an older version of the module had a missing or invalid + // go.mod file. For example, if example.com/mod released v2.0.0 before + // migrating to modules (v2.0.0+incompatible), then added a valid go.mod + // in v2.0.1, downgrading from v2.0.1 would cause this error. + // + // TODO(golang.org/issue/31730, golang.org/issue/30134): if the error + // is transient (we couldn't download go.mod), return the error from + // Downgrade. Currently, we can't tell what kind of error it is. + exclude(m) + return + } + for _, r := range list { + add(r) + if excluded[r] { + exclude(m) + return + } + rdeps[r] = append(rdeps[r], m) + } + } + + downgraded := make([]module.Version, 0, len(list)+1) + downgraded = append(downgraded, target) +List: + for _, r := range list { + add(r) + for excluded[r] { + p, err := reqs.Previous(r) + if err != nil { + // This is likely a transient error reaching the repository, + // rather than a permanent error with the retrieved version. + // + // TODO(golang.org/issue/31730, golang.org/issue/30134): + // decode what to do based on the actual error. + return nil, err + } + // If the target version is a pseudo-version, it may not be + // included when iterating over prior versions using reqs.Previous. + // Insert it into the right place in the iteration. + // If v is excluded, p should be returned again by reqs.Previous on the next iteration. + if v := max[r.Path]; reqs.Max(r.Path, v, r.Version) != v && reqs.Max(r.Path, p.Version, v) != p.Version { + p.Version = v + } + if p.Version == "none" { + continue List + } + add(p) + r = p + } + downgraded = append(downgraded, r) + } + + // The downgrades we computed above only downgrade to versions enumerated by + // reqs.Previous. However, reqs.Previous omits some versions — such as + // pseudo-versions and retracted versions — that may be selected as transitive + // requirements of other modules. + // + // If one of those requirements pulls the version back up above the version + // identified by reqs.Previous, then the transitive dependencies of that + // initially-downgraded version should no longer matter — in particular, we + // should not add new dependencies on module paths that nothing else in the + // updated module graph even requires. + // + // In order to eliminate those spurious dependencies, we recompute the build + // list with the actual versions of the downgraded modules as selected by MVS, + // instead of our initial downgrades. + // (See the downhiddenartifact and downhiddencross test cases). + actual, err := BuildList([]module.Version{target}, &override{ + target: target, + list: downgraded, + Reqs: reqs, + }) + if err != nil { + return nil, err + } + actualVersion := make(map[string]string, len(actual)) + for _, m := range actual { + actualVersion[m.Path] = m.Version + } + + downgraded = downgraded[:0] + for _, m := range list { + if v, ok := actualVersion[m.Path]; ok { + downgraded = append(downgraded, module.Version{Path: m.Path, Version: v}) + } + } + + return BuildList([]module.Version{target}, &override{ + target: target, + list: downgraded, + Reqs: reqs, + }) +} + +type override struct { + target module.Version + list []module.Version + Reqs +} + +func (r *override) Required(m module.Version) ([]module.Version, error) { + if m == r.target { + return r.list, nil + } + return r.Reqs.Required(m) +} diff --git a/go/src/cmd/go/internal/mvs/mvs_test.go b/go/src/cmd/go/internal/mvs/mvs_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6e1e71cd5c1e510d1f97c4159fbde194a1538be8 --- /dev/null +++ b/go/src/cmd/go/internal/mvs/mvs_test.go @@ -0,0 +1,635 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mvs + +import ( + "fmt" + "reflect" + "strings" + "testing" + + "golang.org/x/mod/module" +) + +var tests = ` +# Scenario from blog. +name: blog +A: B1 C2 +B1: D3 +C1: D2 +C2: D4 +C3: D5 +C4: G1 +D2: E1 +D3: E2 +D4: E2 F1 +D5: E2 +G1: C4 +A2: B1 C4 D4 +build A: A B1 C2 D4 E2 F1 +upgrade* A: A B1 C4 D5 E2 F1 G1 +upgrade A C4: A B1 C4 D4 E2 F1 G1 +build A2: A2 B1 C4 D4 E2 F1 G1 +downgrade A2 D2: A2 C4 D2 E2 F1 G1 + +name: trim +A: B1 C2 +B1: D3 +C2: B2 +B2: +build A: A B2 C2 D3 + +# Cross-dependency between D and E. +# No matter how it arises, should get result of merging all build lists via max, +# which leads to including both D2 and E2. + +name: cross1 +A: B C +B: D1 +C: D2 +D1: E2 +D2: E1 +build A: A B C D2 E2 + +name: cross1V +A: B2 C D2 E1 +B1: +B2: D1 +C: D2 +D1: E2 +D2: E1 +build A: A B2 C D2 E2 + +name: cross1U +A: B1 C +B1: +B2: D1 +C: D2 +D1: E2 +D2: E1 +build A: A B1 C D2 E1 +upgrade A B2: A B2 C D2 E2 + +name: cross1R +A: B C +B: D2 +C: D1 +D1: E2 +D2: E1 +build A: A B C D2 E2 + +name: cross1X +A: B C +B: D1 E2 +C: D2 +D1: E2 +D2: E1 +build A: A B C D2 E2 + +name: cross2 +A: B D2 +B: D1 +D1: E2 +D2: E1 +build A: A B D2 E2 + +name: cross2X +A: B D2 +B: D1 E2 +C: D2 +D1: E2 +D2: E1 +build A: A B D2 E2 + +name: cross3 +A: B D2 E1 +B: D1 +D1: E2 +D2: E1 +build A: A B D2 E2 + +name: cross3X +A: B D2 E1 +B: D1 E2 +D1: E2 +D2: E1 +build A: A B D2 E2 + +# Should not get E2 here, because B has been updated +# not to depend on D1 anymore. +name: cross4 +A1: B1 D2 +A2: B2 D2 +B1: D1 +B2: D2 +D1: E2 +D2: E1 +build A1: A1 B1 D2 E2 +build A2: A2 B2 D2 E1 + +# But the upgrade from A1 preserves the E2 dep explicitly. +upgrade A1 B2: A1 B2 D2 E2 +upgradereq A1 B2: B2 E2 + +name: cross5 +A: D1 +D1: E2 +D2: E1 +build A: A D1 E2 +upgrade* A: A D2 E2 +upgrade A D2: A D2 E2 +upgradereq A D2: D2 E2 + +name: cross6 +A: D2 +D1: E2 +D2: E1 +build A: A D2 E1 +upgrade* A: A D2 E2 +upgrade A E2: A D2 E2 + +name: cross7 +A: B C +B: D1 +C: E1 +D1: E2 +E1: D2 +build A: A B C D2 E2 + +# golang.org/issue/31248: +# Even though we select X2, the requirement on I1 +# via X1 should be preserved. +name: cross8 +M: A1 B1 +A1: X1 +B1: X2 +X1: I1 +X2: +build M: M A1 B1 I1 X2 + +# Upgrade from B1 to B2 should not drop the transitive dep on D. +name: drop +A: B1 C1 +B1: D1 +B2: +C2: +D2: +build A: A B1 C1 D1 +upgrade* A: A B2 C2 D2 + +name: simplify +A: B1 C1 +B1: C2 +C1: D1 +C2: +build A: A B1 C2 D1 + +name: up1 +A: B1 C1 +B1: +B2: +B3: +B4: +B5.hidden: +C2: +C3: +build A: A B1 C1 +upgrade* A: A B4 C3 + +name: up2 +A: B5.hidden C1 +B1: +B2: +B3: +B4: +B5.hidden: +C2: +C3: +build A: A B5.hidden C1 +upgrade* A: A B5.hidden C3 + +name: down1 +A: B2 +B1: C1 +B2: C2 +build A: A B2 C2 +downgrade A C1: A B1 C1 + +name: down2 +A: B2 E2 +B1: +B2: C2 F2 +C1: +D1: +C2: D2 E2 +D2: B2 +E2: D2 +E1: +F1: +build A: A B2 C2 D2 E2 F2 +downgrade A F1: A B1 C1 D1 E1 F1 + +# https://research.swtch.com/vgo-mvs#algorithm_4: +# “[D]owngrades are constrained to only downgrade packages, not also upgrade +# them; if an upgrade before downgrade is needed, the user must ask for it +# explicitly.” +# +# Here, downgrading B2 to B1 upgrades C1 to C2, and C2 does not depend on D2. +# However, C2 would be an upgrade — not a downgrade — so B1 must also be +# rejected. +name: downcross1 +A: B2 C1 +B1: C2 +B2: C1 +C1: D2 +C2: +D1: +D2: +build A: A B2 C1 D2 +downgrade A D1: A D1 + +# https://research.swtch.com/vgo-mvs#algorithm_4: +# “Unlike upgrades, downgrades must work by removing requirements, not adding +# them.” +# +# However, downgrading a requirement may introduce a new requirement on a +# previously-unrequired module. If each dependency's requirements are complete +# (“tidy”), that can't change the behavior of any other package whose version is +# not also being downgraded, so we should allow it. +name: downcross2 +A: B2 +B1: C1 +B2: D2 +C1: +D1: +D2: +build A: A B2 D2 +downgrade A D1: A B1 C1 D1 + +name: downcycle +A: A B2 +B2: A +B1: +build A: A B2 +downgrade A B1: A B1 + +# Both B3 and C2 require D2. +# If we downgrade D to D1, then in isolation B3 would downgrade to B1, +# because B2 is hidden — B1 is the next-highest version that is not hidden. +# However, if we downgrade D, we will also downgrade C to C1. +# And C1 requires B2.hidden, and B2.hidden also meets our requirements: +# it is compatible with D1 and a strict downgrade from B3. +# +# Since neither the initial nor the final build list includes B1, +# and the nothing in the final downgraded build list requires E at all, +# no dependency on E1 (required by only B1) should be introduced. +# +name: downhiddenartifact +A: B3 C2 +A1: B3 +B1: E1 +B2.hidden: +B3: D2 +C1: B2.hidden +C2: D2 +D1: +D2: +build A1: A1 B3 D2 +downgrade A1 D1: A1 B1 D1 E1 +build A: A B3 C2 D2 +downgrade A D1: A B2.hidden C1 D1 + +# Both B3 and C3 require D2. +# If we downgrade D to D1, then in isolation B3 would downgrade to B1, +# and C3 would downgrade to C1. +# But C1 requires B2.hidden, and B1 requires C2.hidden, so we can't +# downgrade to either of those without pulling the other back up a little. +# +# B2.hidden and C2.hidden are both compatible with D1, so that still +# meets our requirements — but then we're in an odd state in which +# B and C have both been downgraded to hidden versions, without any +# remaining requirements to explain how those hidden versions got there. +# +# TODO(bcmills): Would it be better to force downgrades to land on non-hidden +# versions? +# In this case, that would remove the dependencies on B and C entirely. +# +name: downhiddencross +A: B3 C3 +B1: C2.hidden +B2.hidden: +B3: D2 +C1: B2.hidden +C2.hidden: +C3: D2 +D1: +D2: +build A: A B3 C3 D2 +downgrade A D1: A B2.hidden C2.hidden D1 + +# golang.org/issue/25542. +name: noprev1 +A: B4 C2 +B2.hidden: +C2: +build A: A B4 C2 +downgrade A B2.hidden: A B2.hidden C2 + +name: noprev2 +A: B4 C2 +B2.hidden: +B1: +C2: +build A: A B4 C2 +downgrade A B2.hidden: A B2.hidden C2 + +name: noprev3 +A: B4 C2 +B3: +B2.hidden: +C2: +build A: A B4 C2 +downgrade A B2.hidden: A B2.hidden C2 + +# Cycles involving the target. + +# The target must be the newest version of itself. +name: cycle1 +A: B1 +B1: A1 +B2: A2 +B3: A3 +build A: A B1 +upgrade A B2: A B2 +upgrade* A: A B3 + +# golang.org/issue/29773: +# Requirements of older versions of the target +# must be carried over. +name: cycle2 +A: B1 +A1: C1 +A2: D1 +B1: A1 +B2: A2 +C1: A2 +C2: +D2: +build A: A B1 C1 D1 +upgrade* A: A B2 C2 D2 + +# Cycles with multiple possible solutions. +# (golang.org/issue/34086) +name: cycle3 +M: A1 C2 +A1: B1 +B1: C1 +B2: C2 +C1: +C2: B2 +build M: M A1 B2 C2 +req M: A1 B2 +req M A: A1 B2 +req M C: A1 C2 + +# Requirement minimization. + +name: req1 +A: B1 C1 D1 E1 F1 +B1: C1 E1 F1 +req A: B1 D1 +req A C: B1 C1 D1 + +name: req2 +A: G1 H1 +G1: H1 +H1: G1 +req A: G1 +req A G: G1 +req A H: H1 + +name: req3 +M: A1 B1 +A1: X1 +B1: X2 +X1: I1 +X2: +req M: A1 B1 + +name: reqnone +M: Anone B1 D1 E1 +B1: Cnone D1 +E1: Fnone +build M: M B1 D1 E1 +req M: B1 E1 + +name: reqdup +M: A1 B1 +A1: B1 +B1: +req M A A: A1 + +name: reqcross +M: A1 B1 C1 +A1: B1 C1 +B1: C1 +C1: +req M A B: A1 B1 +` + +func Test(t *testing.T) { + var ( + name string + reqs reqsMap + fns []func(*testing.T) + ) + flush := func() { + if name != "" { + t.Run(name, func(t *testing.T) { + for _, fn := range fns { + fn(t) + } + if len(fns) == 0 { + t.Errorf("no functions tested") + } + }) + } + } + m := func(s string) module.Version { + return module.Version{Path: s[:1], Version: s[1:]} + } + ms := func(list []string) []module.Version { + var mlist []module.Version + for _, s := range list { + mlist = append(mlist, m(s)) + } + return mlist + } + checkList := func(t *testing.T, desc string, list []module.Version, err error, val string) { + if err != nil { + t.Fatalf("%s: %v", desc, err) + } + vs := ms(strings.Fields(val)) + if !reflect.DeepEqual(list, vs) { + t.Errorf("%s = %v, want %v", desc, list, vs) + } + } + + for _, line := range strings.Split(tests, "\n") { + line = strings.TrimSpace(line) + if strings.HasPrefix(line, "#") || line == "" { + continue + } + i := strings.Index(line, ":") + if i < 0 { + t.Fatalf("missing colon: %q", line) + } + key := strings.TrimSpace(line[:i]) + val := strings.TrimSpace(line[i+1:]) + if key == "" { + t.Fatalf("missing key: %q", line) + } + kf := strings.Fields(key) + switch kf[0] { + case "name": + if len(kf) != 1 { + t.Fatalf("name takes no arguments: %q", line) + } + flush() + reqs = make(reqsMap) + fns = nil + name = val + continue + case "build": + if len(kf) != 2 { + t.Fatalf("build takes one argument: %q", line) + } + fns = append(fns, func(t *testing.T) { + list, err := BuildList([]module.Version{m(kf[1])}, reqs) + checkList(t, key, list, err, val) + }) + continue + case "upgrade*": + if len(kf) != 2 { + t.Fatalf("upgrade* takes one argument: %q", line) + } + fns = append(fns, func(t *testing.T) { + list, err := UpgradeAll(m(kf[1]), reqs) + checkList(t, key, list, err, val) + }) + continue + case "upgradereq": + if len(kf) < 2 { + t.Fatalf("upgrade takes at least one argument: %q", line) + } + fns = append(fns, func(t *testing.T) { + list, err := Upgrade(m(kf[1]), reqs, ms(kf[2:])...) + if err == nil { + // Copy the reqs map, but substitute the upgraded requirements in + // place of the target's original requirements. + upReqs := make(reqsMap, len(reqs)) + for m, r := range reqs { + upReqs[m] = r + } + upReqs[m(kf[1])] = list + + list, err = Req(m(kf[1]), nil, upReqs) + } + checkList(t, key, list, err, val) + }) + continue + case "upgrade": + if len(kf) < 2 { + t.Fatalf("upgrade takes at least one argument: %q", line) + } + fns = append(fns, func(t *testing.T) { + list, err := Upgrade(m(kf[1]), reqs, ms(kf[2:])...) + checkList(t, key, list, err, val) + }) + continue + case "downgrade": + if len(kf) < 2 { + t.Fatalf("downgrade takes at least one argument: %q", line) + } + fns = append(fns, func(t *testing.T) { + list, err := Downgrade(m(kf[1]), reqs, ms(kf[1:])...) + checkList(t, key, list, err, val) + }) + continue + case "req": + if len(kf) < 2 { + t.Fatalf("req takes at least one argument: %q", line) + } + fns = append(fns, func(t *testing.T) { + list, err := Req(m(kf[1]), kf[2:], reqs) + checkList(t, key, list, err, val) + }) + continue + } + if len(kf) == 1 && 'A' <= key[0] && key[0] <= 'Z' { + var rs []module.Version + for _, f := range strings.Fields(val) { + r := m(f) + if reqs[r] == nil { + reqs[r] = []module.Version{} + } + rs = append(rs, r) + } + reqs[m(key)] = rs + continue + } + t.Fatalf("bad line: %q", line) + } + flush() +} + +type reqsMap map[module.Version][]module.Version + +func (r reqsMap) Max(_, v1, v2 string) string { + if v1 == "none" || v2 == "" { + return v2 + } + if v2 == "none" || v1 == "" { + return v1 + } + if v1 < v2 { + return v2 + } + return v1 +} + +func (r reqsMap) Upgrade(m module.Version) (module.Version, error) { + u := module.Version{Version: "none"} + for k := range r { + if k.Path == m.Path && r.Max(k.Path, u.Version, k.Version) == k.Version && !strings.HasSuffix(k.Version, ".hidden") { + u = k + } + } + if u.Path == "" { + return module.Version{}, fmt.Errorf("missing module: %v", module.Version{Path: m.Path}) + } + return u, nil +} + +func (r reqsMap) Previous(m module.Version) (module.Version, error) { + var p module.Version + for k := range r { + if k.Path == m.Path && p.Version < k.Version && k.Version < m.Version && !strings.HasSuffix(k.Version, ".hidden") { + p = k + } + } + if p.Path == "" { + return module.Version{Path: m.Path, Version: "none"}, nil + } + return p, nil +} + +func (r reqsMap) Required(m module.Version) ([]module.Version, error) { + rr, ok := r[m] + if !ok { + return nil, fmt.Errorf("missing module: %v", m) + } + return rr, nil +} diff --git a/go/src/cmd/go/internal/run/run.go b/go/src/cmd/go/internal/run/run.go new file mode 100644 index 0000000000000000000000000000000000000000..ebd99ccfb21f19d6d258de26f8f65207c8ecc3b1 --- /dev/null +++ b/go/src/cmd/go/internal/run/run.go @@ -0,0 +1,211 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package run implements the “go run” command. +package run + +import ( + "context" + "go/build" + "path/filepath" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/load" + "cmd/go/internal/modload" + "cmd/go/internal/str" + "cmd/go/internal/work" +) + +var CmdRun = &base.Command{ + UsageLine: "go run [build flags] [-exec xprog] package [arguments...]", + Short: "compile and run Go program", + Long: ` +Run compiles and runs the named main Go package. +Typically the package is specified as a list of .go source files from a single +directory, but it may also be an import path, file system path, or pattern +matching a single known package, as in 'go run .' or 'go run my/cmd'. + +If the package argument has a version suffix (like @latest or @v1.0.0), +"go run" builds the program in module-aware mode, ignoring the go.mod file in +the current directory or any parent directory, if there is one. This is useful +for running programs without affecting the dependencies of the main module. + +If the package argument doesn't have a version suffix, "go run" may run in +module-aware mode or GOPATH mode, depending on the GO111MODULE environment +variable and the presence of a go.mod file. See 'go help modules' for details. +If module-aware mode is enabled, "go run" runs in the context of the main +module. + +By default, 'go run' runs the compiled binary directly: 'a.out arguments...'. +If the -exec flag is given, 'go run' invokes the binary using xprog: + 'xprog a.out arguments...'. +If the -exec flag is not given, GOOS or GOARCH is different from the system +default, and a program named go_$GOOS_$GOARCH_exec can be found +on the current search path, 'go run' invokes the binary using that program, +for example 'go_js_wasm_exec a.out arguments...'. This allows execution of +cross-compiled programs when a simulator or other execution method is +available. + +By default, 'go run' compiles the binary without generating the information +used by debuggers, to reduce build time. To include debugger information in +the binary, use 'go build'. + +The exit status of Run is not the exit status of the compiled binary. + +For more about build flags, see 'go help build'. +For more about specifying packages, see 'go help packages'. + +See also: go build. + `, +} + +func init() { + CmdRun.Run = runRun // break init loop + + work.AddBuildFlags(CmdRun, work.DefaultBuildFlags) + work.AddCoverFlags(CmdRun, nil) + CmdRun.Flag.Var((*base.StringsFlag)(&work.ExecCmd), "exec", "") +} + +func runRun(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + if shouldUseOutsideModuleMode(args) { + // Set global module flags for 'go run cmd@version'. + // This must be done before modload.Init, but we need to call work.BuildInit + // before loading packages, since it affects package locations, e.g., + // for -race and -msan. + moduleLoaderState.ForceUseModules = true + moduleLoaderState.RootMode = modload.NoRoot + moduleLoaderState.AllowMissingModuleImports() + modload.Init(moduleLoaderState) + } else { + moduleLoaderState.InitWorkfile() + } + + work.BuildInit(moduleLoaderState) + b := work.NewBuilder("", moduleLoaderState.VendorDirOrEmpty) + defer func() { + if err := b.Close(); err != nil { + base.Fatal(err) + } + }() + + i := 0 + for i < len(args) && strings.HasSuffix(args[i], ".go") { + i++ + } + pkgOpts := load.PackageOpts{MainOnly: true} + var p *load.Package + if i > 0 { + files := args[:i] + for _, file := range files { + if strings.HasSuffix(file, "_test.go") { + // GoFilesPackage is going to assign this to TestGoFiles. + // Reject since it won't be part of the build. + base.Fatalf("go: cannot run *_test.go files (%s)", file) + } + } + p = load.GoFilesPackage(moduleLoaderState, ctx, pkgOpts, files) + } else if len(args) > 0 && !strings.HasPrefix(args[0], "-") { + arg := args[0] + var pkgs []*load.Package + if strings.Contains(arg, "@") && !build.IsLocalImport(arg) && !filepath.IsAbs(arg) { + var err error + pkgs, err = load.PackagesAndErrorsOutsideModule(moduleLoaderState, ctx, pkgOpts, args[:1]) + if err != nil { + base.Fatal(err) + } + } else { + pkgs = load.PackagesAndErrors(moduleLoaderState, ctx, pkgOpts, args[:1]) + } + + if len(pkgs) == 0 { + base.Fatalf("go: no packages loaded from %s", arg) + } + if len(pkgs) > 1 { + names := make([]string, 0, len(pkgs)) + for _, p := range pkgs { + names = append(names, p.ImportPath) + } + base.Fatalf("go: pattern %s matches multiple packages:\n\t%s", arg, strings.Join(names, "\n\t")) + } + p = pkgs[0] + i++ + } else { + base.Fatalf("go: no go files listed") + } + cmdArgs := args[i:] + load.CheckPackageErrors([]*load.Package{p}) + + if cfg.BuildCover { + load.PrepareForCoverageBuild(moduleLoaderState, []*load.Package{p}) + } + + p.Internal.OmitDebug = true + p.Target = "" // must build - not up to date + if p.Internal.CmdlineFiles { + //set executable name if go file is given as cmd-argument + var src string + if len(p.GoFiles) > 0 { + src = p.GoFiles[0] + } else if len(p.CgoFiles) > 0 { + src = p.CgoFiles[0] + } else { + // this case could only happen if the provided source uses cgo + // while cgo is disabled. + hint := "" + if !cfg.BuildContext.CgoEnabled { + hint = " (cgo is disabled)" + } + base.Fatalf("go: no suitable source files%s", hint) + } + p.Internal.ExeName = src[:len(src)-len(".go")] + } else { + p.Internal.ExeName = p.DefaultExecName() + } + + a1 := b.LinkAction(moduleLoaderState, work.ModeBuild, work.ModeBuild, p) + a1.CacheExecutable = true + a := &work.Action{Mode: "go run", Actor: work.ActorFunc(buildRunProgram), Args: cmdArgs, Deps: []*work.Action{a1}} + b.Do(ctx, a) +} + +// shouldUseOutsideModuleMode returns whether 'go run' will load packages in +// module-aware mode, ignoring the go.mod file in the current directory. It +// returns true if the first argument contains "@", does not begin with "-" +// (resembling a flag) or end with ".go" (a file). The argument must not be a +// local or absolute file path. +// +// These rules are slightly different than other commands. Whether or not +// 'go run' uses this mode, it interprets arguments ending with ".go" as files +// and uses arguments up to the last ".go" argument to comprise the package. +// If there are no ".go" arguments, only the first argument is interpreted +// as a package path, since there can be only one package. +func shouldUseOutsideModuleMode(args []string) bool { + // NOTE: "@" not allowed in import paths, but it is allowed in non-canonical + // versions. + return len(args) > 0 && + !strings.HasSuffix(args[0], ".go") && + !strings.HasPrefix(args[0], "-") && + strings.Contains(args[0], "@") && + !build.IsLocalImport(args[0]) && + !filepath.IsAbs(args[0]) +} + +// buildRunProgram is the action for running a binary that has already +// been compiled. We ignore exit status. +func buildRunProgram(b *work.Builder, ctx context.Context, a *work.Action) error { + cmdline := str.StringList(work.FindExecCmd(), a.Deps[0].BuiltTarget(), a.Args) + if cfg.BuildN || cfg.BuildX { + b.Shell(a).ShowCmd("", "%s", strings.Join(cmdline, " ")) + if cfg.BuildN { + return nil + } + } + + base.RunStdin(cmdline) + return nil +} diff --git a/go/src/cmd/go/internal/search/search.go b/go/src/cmd/go/internal/search/search.go new file mode 100644 index 0000000000000000000000000000000000000000..a54486e540ca16f7f97040e21974197163ac66ec --- /dev/null +++ b/go/src/cmd/go/internal/search/search.go @@ -0,0 +1,612 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package search + +import ( + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/fsys" + "cmd/go/internal/str" + "cmd/internal/pkgpattern" + "fmt" + "go/build" + "io/fs" + "os" + "path" + "path/filepath" + "strings" + + "golang.org/x/mod/modfile" +) + +// A Match represents the result of matching a single package pattern. +type Match struct { + pattern string // the pattern itself + Dirs []string // if the pattern is local, directories that potentially contain matching packages + Pkgs []string // matching packages (import paths) + Errs []error // errors matching the patterns to packages, NOT errors loading those packages + + // Errs may be non-empty even if len(Pkgs) > 0, indicating that some matching + // packages could be located but results may be incomplete. + // If len(Pkgs) == 0 && len(Errs) == 0, the pattern is well-formed but did not + // match any packages. +} + +// NewMatch returns a Match describing the given pattern, +// without resolving its packages or errors. +func NewMatch(pattern string) *Match { + return &Match{pattern: pattern} +} + +// Pattern returns the pattern to be matched. +func (m *Match) Pattern() string { return m.pattern } + +// AddError appends a MatchError wrapping err to m.Errs. +func (m *Match) AddError(err error) { + m.Errs = append(m.Errs, &MatchError{Match: m, Err: err}) +} + +// IsLiteral reports whether the pattern is free of wildcards and meta-patterns. +// +// A literal pattern must match at most one package. +func (m *Match) IsLiteral() bool { + return !strings.Contains(m.pattern, "...") && !m.IsMeta() +} + +// IsLocal reports whether the pattern must be resolved from a specific root or +// directory, such as a filesystem path or a single module. +func (m *Match) IsLocal() bool { + return build.IsLocalImport(m.pattern) || filepath.IsAbs(m.pattern) +} + +// IsMeta reports whether the pattern is a “meta-package” keyword that represents +// multiple packages, such as "std", "cmd", "tool", "work", or "all". +func (m *Match) IsMeta() bool { + return IsMetaPackage(m.pattern) +} + +// IsMetaPackage checks if name is a reserved package name that expands to multiple packages. +func IsMetaPackage(name string) bool { + return name == "std" || name == "cmd" || name == "tool" || name == "work" || name == "all" +} + +// A MatchError indicates an error that occurred while attempting to match a +// pattern. +type MatchError struct { + Match *Match + Err error +} + +func (e *MatchError) Error() string { + if e.Match.IsLiteral() { + return fmt.Sprintf("%s: %v", e.Match.Pattern(), e.Err) + } + return fmt.Sprintf("pattern %s: %v", e.Match.Pattern(), e.Err) +} + +func (e *MatchError) Unwrap() error { + return e.Err +} + +// MatchPackages sets m.Pkgs to a non-nil slice containing all the packages that +// can be found under the $GOPATH directories and $GOROOT that match the +// pattern. The pattern must be either "all" (all packages), "std" (standard +// packages), "cmd" (standard commands), or a path including "...". +// +// If any errors may have caused the set of packages to be incomplete, +// MatchPackages appends those errors to m.Errs. +func (m *Match) MatchPackages() { + m.Pkgs = []string{} + if m.IsLocal() { + m.AddError(fmt.Errorf("internal error: MatchPackages: %s is not a valid package pattern", m.pattern)) + return + } + + if m.IsLiteral() { + m.Pkgs = []string{m.pattern} + return + } + + match := func(string) bool { return true } + treeCanMatch := func(string) bool { return true } + if !m.IsMeta() { + match = pkgpattern.MatchPattern(m.pattern) + treeCanMatch = pkgpattern.TreeCanMatchPattern(m.pattern) + } + + have := map[string]bool{ + "builtin": true, // ignore pseudo-package that exists only for documentation + } + if !cfg.BuildContext.CgoEnabled { + have["runtime/cgo"] = true // ignore during walk + } + + for _, src := range cfg.BuildContext.SrcDirs() { + if (m.pattern == "std" || m.pattern == "cmd") && src != cfg.GOROOTsrc { + continue + } + + // If the root itself is a symlink to a directory, + // we want to follow it (see https://go.dev/issue/50807). + // Add a trailing separator to force that to happen. + src = str.WithFilePathSeparator(filepath.Clean(src)) + root := src + if m.pattern == "cmd" { + root += "cmd" + string(filepath.Separator) + } + + err := fsys.WalkDir(root, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err // Likely a permission error, which could interfere with matching. + } + if path == src { + return nil // GOROOT/src and GOPATH/src cannot contain packages. + } + + want := true + // Avoid .foo, _foo, and testdata directory trees. + _, elem := filepath.Split(path) + if strings.HasPrefix(elem, ".") || strings.HasPrefix(elem, "_") || elem == "testdata" { + want = false + } + + name := filepath.ToSlash(path[len(src):]) + if m.pattern == "std" && (!IsStandardImportPath(name) || name == "cmd") { + // The name "std" is only the standard library. + // If the name is cmd, it's the root of the command tree. + want = false + } + if !treeCanMatch(name) { + want = false + } + + if !d.IsDir() { + if d.Type()&fs.ModeSymlink != 0 && want && strings.Contains(m.pattern, "...") { + if target, err := fsys.Stat(path); err == nil && target.IsDir() { + fmt.Fprintf(os.Stderr, "warning: ignoring symlink %s\n", path) + } + } + return nil + } + if !want { + return filepath.SkipDir + } + + if have[name] { + return nil + } + have[name] = true + if !match(name) { + return nil + } + pkg, err := cfg.BuildContext.ImportDir(path, 0) + if err != nil { + if _, noGo := err.(*build.NoGoError); noGo { + // The package does not actually exist, so record neither the package + // nor the error. + return nil + } + // There was an error importing path, but not matching it, + // which is all that Match promises to do. + // Ignore the import error. + } + + // If we are expanding "cmd", skip main + // packages under cmd/vendor. At least as of + // March, 2017, there is one there for the + // vendored pprof tool. + if m.pattern == "cmd" && pkg != nil && strings.HasPrefix(pkg.ImportPath, "cmd/vendor") && pkg.Name == "main" { + return nil + } + + m.Pkgs = append(m.Pkgs, name) + return nil + }) + if err != nil { + m.AddError(err) + } + } +} + +// IgnorePatterns is normalized with normalizePath. +type IgnorePatterns struct { + relativePatterns []string + anyPatterns []string +} + +// ShouldIgnore returns true if the given directory should be ignored +// based on the ignore patterns. +// +// An ignore pattern "x" will cause any file or directory named "x" +// (and its entire subtree) to be ignored, regardless of its location +// within the module. +// +// An ignore pattern "./x" will only cause the specific file or directory +// named "x" at the root of the module to be ignored. +// Wildcards in ignore patterns are not supported. +func (ignorePatterns *IgnorePatterns) ShouldIgnore(dir string) bool { + if dir == "" { + return false + } + dir = normalizePath(dir) + for _, pattern := range ignorePatterns.relativePatterns { + if strings.HasPrefix(dir, pattern) { + return true + } + } + for _, pattern := range ignorePatterns.anyPatterns { + if strings.Contains(dir, pattern) { + return true + } + } + return false +} + +func NewIgnorePatterns(patterns []string) *IgnorePatterns { + var relativePatterns, anyPatterns []string + for _, pattern := range patterns { + ignorePatternPath, isRelative := strings.CutPrefix(pattern, "./") + ignorePatternPath = normalizePath(ignorePatternPath) + if isRelative { + relativePatterns = append(relativePatterns, ignorePatternPath) + } else { + anyPatterns = append(anyPatterns, ignorePatternPath) + } + } + return &IgnorePatterns{ + relativePatterns: relativePatterns, + anyPatterns: anyPatterns, + } +} + +// normalizePath adds slashes to the front and end of the given path. +func normalizePath(path string) string { + path = filepath.ToSlash(path) + if !strings.HasPrefix(path, "/") { + path = "/" + path + } + if !strings.HasSuffix(path, "/") { + path += "/" + } + return path +} + +// MatchDirs sets m.Dirs to a non-nil slice containing all directories that +// potentially match a local pattern. The pattern must begin with an absolute +// path, or "./", or "../". On Windows, the pattern may use slash or backslash +// separators or a mix of both. +// +// If any errors may have caused the set of directories to be incomplete, +// MatchDirs appends those errors to m.Errs. +func (m *Match) MatchDirs(modRoots []string) { + m.Dirs = []string{} + if !m.IsLocal() { + m.AddError(fmt.Errorf("internal error: MatchDirs: %s is not a valid filesystem pattern", m.pattern)) + return + } + + if m.IsLiteral() { + m.Dirs = []string{m.pattern} + return + } + + // Clean the path and create a matching predicate. + // filepath.Clean removes "./" prefixes (and ".\" on Windows). We need to + // preserve these, since they are meaningful in MatchPattern and in + // returned import paths. + cleanPattern := filepath.Clean(m.pattern) + isLocal := strings.HasPrefix(m.pattern, "./") || (os.PathSeparator == '\\' && strings.HasPrefix(m.pattern, `.\`)) + prefix := "" + if cleanPattern != "." && isLocal { + prefix = "./" + cleanPattern = "." + string(os.PathSeparator) + cleanPattern + } + slashPattern := filepath.ToSlash(cleanPattern) + match := pkgpattern.MatchPattern(slashPattern) + + // Find directory to begin the scan. + // Could be smarter but this one optimization + // is enough for now, since ... is usually at the + // end of a path. + i := strings.Index(cleanPattern, "...") + dir, _ := filepath.Split(cleanPattern[:i]) + + // pattern begins with ./ or ../. + // path.Clean will discard the ./ but not the ../. + // We need to preserve the ./ for pattern matching + // and in the returned import paths. + + var modRoot string + if len(modRoots) > 0 { + abs, err := filepath.Abs(dir) + if err != nil { + m.AddError(err) + return + } + var found bool + for _, mr := range modRoots { + if mr != "" && str.HasFilePathPrefix(abs, mr) { + found = true + modRoot = mr + } + } + if !found { + plural := "" + if len(modRoots) > 1 { + plural = "s" + } + m.AddError(fmt.Errorf("directory %s is outside module root%s (%s)", abs, plural, strings.Join(modRoots, ", "))) + } + } + + ignorePatterns := parseIgnorePatterns(modRoot) + // If dir is actually a symlink to a directory, + // we want to follow it (see https://go.dev/issue/50807). + // Add a trailing separator to force that to happen. + dir = str.WithFilePathSeparator(dir) + err := fsys.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err // Likely a permission error, which could interfere with matching. + } + if !d.IsDir() { + return nil + } + top := false + if path == dir { + // Walk starts at dir and recurses. For the recursive case, + // the path is the result of filepath.Join, which calls filepath.Clean. + // The initial case is not Cleaned, though, so we do this explicitly. + // + // This converts a path like "./io/" to "io". Without this step, running + // "cd $GOROOT/src; go list ./io/..." would incorrectly skip the io + // package, because prepending the prefix "./" to the unclean path would + // result in "././io", and match("././io") returns false. + top = true + path = filepath.Clean(path) + } + + // Avoid .foo, _foo, and testdata directory trees, but do not avoid "." or "..". + _, elem := filepath.Split(path) + dot := strings.HasPrefix(elem, ".") && elem != "." && elem != ".." + if dot || strings.HasPrefix(elem, "_") || elem == "testdata" { + return filepath.SkipDir + } + absPath, err := filepath.Abs(path) + if err != nil { + return err + } + + if ignorePatterns != nil && ignorePatterns.ShouldIgnore(InDir(absPath, modRoot)) { + if cfg.BuildX { + fmt.Fprintf(os.Stderr, "# ignoring directory %s\n", absPath) + } + return filepath.SkipDir + } + + if !top && cfg.ModulesEnabled { + // Ignore other modules found in subdirectories. + if info, err := fsys.Stat(filepath.Join(path, "go.mod")); err == nil && !info.IsDir() { + return filepath.SkipDir + } + } + + name := prefix + filepath.ToSlash(path) + if !match(name) { + return nil + } + + // We keep the directory if we can import it, or if we can't import it + // due to invalid Go source files. This means that directories containing + // parse errors will be built (and fail) instead of being silently skipped + // as not matching the pattern. Go 1.5 and earlier skipped, but that + // behavior means people miss serious mistakes. + // See golang.org/issue/11407. + if p, err := cfg.BuildContext.ImportDir(path, 0); err != nil && (p == nil || len(p.InvalidGoFiles) == 0) { + if _, noGo := err.(*build.NoGoError); noGo { + // The package does not actually exist, so record neither the package + // nor the error. + return nil + } + // There was an error importing path, but not matching it, + // which is all that Match promises to do. + // Ignore the import error. + } + m.Dirs = append(m.Dirs, name) + return nil + }) + if err != nil { + m.AddError(err) + } +} + +// WarnUnmatched warns about patterns that didn't match any packages. +func WarnUnmatched(matches []*Match) { + for _, m := range matches { + if len(m.Pkgs) == 0 && len(m.Errs) == 0 { + fmt.Fprintf(os.Stderr, "go: warning: %q matched no packages\n", m.pattern) + } + } +} + +// ImportPaths returns the matching paths to use for the given command line. +// It calls ImportPathsQuiet and then WarnUnmatched. +func ImportPaths(patterns []string) []*Match { + matches := ImportPathsQuiet(patterns) + WarnUnmatched(matches) + return matches +} + +// ImportPathsQuiet is like ImportPaths but does not warn about patterns with no matches. +func ImportPathsQuiet(patterns []string) []*Match { + patterns = CleanPatterns(patterns) + out := make([]*Match, 0, len(patterns)) + for _, a := range patterns { + m := NewMatch(a) + if m.IsLocal() { + m.MatchDirs(nil) + + // Change the file import path to a regular import path if the package + // is in GOPATH or GOROOT. We don't report errors here; LoadImport + // (or something similar) will report them later. + m.Pkgs = make([]string, len(m.Dirs)) + for i, dir := range m.Dirs { + absDir := dir + if !filepath.IsAbs(dir) { + absDir = filepath.Join(base.Cwd(), dir) + } + if bp, _ := cfg.BuildContext.ImportDir(absDir, build.FindOnly); bp.ImportPath != "" && bp.ImportPath != "." { + m.Pkgs[i] = bp.ImportPath + } else { + m.Pkgs[i] = dir + } + } + } else { + m.MatchPackages() + } + + out = append(out, m) + } + return out +} + +// CleanPatterns returns the patterns to use for the given command line. It +// canonicalizes the patterns but does not evaluate any matches. For patterns +// that are not local or absolute paths, it preserves text after '@' to avoid +// modifying version queries. +func CleanPatterns(patterns []string) []string { + if len(patterns) == 0 { + return []string{"."} + } + out := make([]string, 0, len(patterns)) + for _, a := range patterns { + var p, v string + if build.IsLocalImport(a) || filepath.IsAbs(a) { + p = a + } else if i := strings.IndexByte(a, '@'); i < 0 { + p = a + } else { + p = a[:i] + v = a[i:] + } + + // Arguments may be either file paths or import paths. + // As a courtesy to Windows developers, rewrite \ to / + // in arguments that look like import paths. + // Don't replace slashes in absolute paths. + if filepath.IsAbs(p) { + p = filepath.Clean(p) + } else { + p = strings.ReplaceAll(p, `\`, `/`) + + // Put argument in canonical form, but preserve leading ./. + if strings.HasPrefix(p, "./") { + p = "./" + path.Clean(p) + if p == "./." { + p = "." + } + } else { + p = path.Clean(p) + } + } + + out = append(out, p+v) + } + return out +} + +// IsStandardImportPath reports whether $GOROOT/src/path should be considered +// part of the standard distribution. For historical reasons we allow people to add +// their own code to $GOROOT instead of using $GOPATH, but we assume that +// code will start with a domain name (dot in the first element). +// +// Note that this function is meant to evaluate whether a directory found in GOROOT +// should be treated as part of the standard library. It should not be used to decide +// that a directory found in GOPATH should be rejected: directories in GOPATH +// need not have dots in the first element, and they just take their chances +// with future collisions in the standard library. +func IsStandardImportPath(path string) bool { + i := strings.Index(path, "/") + if i < 0 { + i = len(path) + } + elem := path[:i] + return !strings.Contains(elem, ".") +} + +// IsRelativePath reports whether pattern should be interpreted as a directory +// path relative to the current directory, as opposed to a pattern matching +// import paths. +func IsRelativePath(pattern string) bool { + return strings.HasPrefix(pattern, "./") || strings.HasPrefix(pattern, "../") || pattern == "." || pattern == ".." +} + +// InDir checks whether path is in the file tree rooted at dir. +// If so, InDir returns an equivalent path relative to dir. +// If not, InDir returns an empty string. +// InDir makes some effort to succeed even in the presence of symbolic links. +func InDir(path, dir string) string { + // inDirLex reports whether path is lexically in dir, + // without considering symbolic or hard links. + inDirLex := func(path, dir string) (string, bool) { + if dir == "" { + return path, true + } + rel := str.TrimFilePathPrefix(path, dir) + if rel == path { + return "", false + } + if rel == "" { + return ".", true + } + return rel, true + } + + if rel, ok := inDirLex(path, dir); ok { + return rel + } + xpath, err := filepath.EvalSymlinks(path) + if err != nil || xpath == path { + xpath = "" + } else { + if rel, ok := inDirLex(xpath, dir); ok { + return rel + } + } + + xdir, err := filepath.EvalSymlinks(dir) + if err == nil && xdir != dir { + if rel, ok := inDirLex(path, xdir); ok { + return rel + } + if xpath != "" { + if rel, ok := inDirLex(xpath, xdir); ok { + return rel + } + } + } + return "" +} + +// parseIgnorePatterns reads the go.mod file at the given module root +// and extracts the ignore patterns defined within it. +// If modRoot is empty, it returns nil. +func parseIgnorePatterns(modRoot string) *IgnorePatterns { + if modRoot == "" { + return nil + } + data, err := os.ReadFile(filepath.Join(modRoot, "go.mod")) + if err != nil { + return nil + } + modFile, err := modfile.Parse("go.mod", data, nil) + if err != nil { + return nil + } + var patterns []string + for _, i := range modFile.Ignore { + patterns = append(patterns, i.Path) + } + return NewIgnorePatterns(patterns) +} diff --git a/go/src/cmd/go/internal/str/path.go b/go/src/cmd/go/internal/str/path.go new file mode 100644 index 0000000000000000000000000000000000000000..83a3d0eb75388f57b5bfbdac17b64e0bcdb5747a --- /dev/null +++ b/go/src/cmd/go/internal/str/path.go @@ -0,0 +1,133 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package str + +import ( + "os" + "path/filepath" + "runtime" + "strings" +) + +// HasPathPrefix reports whether the slash-separated path s +// begins with the elements in prefix. +func HasPathPrefix(s, prefix string) bool { + if len(s) == len(prefix) { + return s == prefix + } + if prefix == "" { + return true + } + if len(s) > len(prefix) { + if prefix[len(prefix)-1] == '/' || s[len(prefix)] == '/' { + return s[:len(prefix)] == prefix + } + } + return false +} + +// HasFilePathPrefix reports whether the filesystem path s +// begins with the elements in prefix. +// +// HasFilePathPrefix is case-sensitive (except for volume names) even if the +// filesystem is not, does not apply Unicode normalization even if the +// filesystem does, and assumes that all path separators are canonicalized to +// filepath.Separator (as returned by filepath.Clean). +func HasFilePathPrefix(s, prefix string) bool { + sv := filepath.VolumeName(s) + pv := filepath.VolumeName(prefix) + + // Strip the volume from both paths before canonicalizing sv and pv: + // it's unlikely that strings.ToUpper will change the length of the string, + // but doesn't seem impossible. + s = s[len(sv):] + prefix = prefix[len(pv):] + + // Always treat Windows volume names as case-insensitive, even though + // we don't treat the rest of the path as such. + // + // TODO(bcmills): Why do we care about case only for the volume name? It's + // been this way since https://go.dev/cl/11316, but I don't understand why + // that problem doesn't apply to case differences in the entire path. + if sv != pv { + sv = strings.ToUpper(sv) + pv = strings.ToUpper(pv) + } + + switch { + default: + return false + case sv != pv: + return false + case len(s) == len(prefix): + return s == prefix + case prefix == "": + return true + case len(s) > len(prefix): + if prefix[len(prefix)-1] == filepath.Separator { + return strings.HasPrefix(s, prefix) + } + return s[len(prefix)] == filepath.Separator && s[:len(prefix)] == prefix + } +} + +// TrimFilePathPrefix returns s without the leading path elements in prefix, +// such that joining the string to prefix produces s. +// +// If s does not start with prefix (HasFilePathPrefix with the same arguments +// returns false), TrimFilePathPrefix returns s. If s equals prefix, +// TrimFilePathPrefix returns "". +func TrimFilePathPrefix(s, prefix string) string { + if prefix == "" { + // Trimming the empty string from a path should join to produce that path. + // (Trim("/tmp/foo", "") should give "/tmp/foo", not "tmp/foo".) + return s + } + if !HasFilePathPrefix(s, prefix) { + return s + } + + trimmed := s[len(prefix):] + if len(trimmed) > 0 && os.IsPathSeparator(trimmed[0]) { + if runtime.GOOS == "windows" && prefix == filepath.VolumeName(prefix) && len(prefix) == 2 && prefix[1] == ':' { + // Joining a relative path to a bare Windows drive letter produces a path + // relative to the working directory on that drive, but the original path + // was absolute, not relative. Keep the leading path separator so that it + // remains absolute when joined to prefix. + } else { + // Prefix ends in a regular path element, so strip the path separator that + // follows it. + trimmed = trimmed[1:] + } + } + return trimmed +} + +// WithFilePathSeparator returns s with a trailing path separator, or the empty +// string if s is empty. +func WithFilePathSeparator(s string) string { + if s == "" || os.IsPathSeparator(s[len(s)-1]) { + return s + } + return s + string(filepath.Separator) +} + +// QuoteGlob returns s with all Glob metacharacters quoted. +// We don't try to handle backslash here, as that can appear in a +// file path on Windows. +func QuoteGlob(s string) string { + if !strings.ContainsAny(s, `*?[]`) { + return s + } + var sb strings.Builder + for _, c := range s { + switch c { + case '*', '?', '[', ']': + sb.WriteByte('\\') + } + sb.WriteRune(c) + } + return sb.String() +} diff --git a/go/src/cmd/go/internal/str/str.go b/go/src/cmd/go/internal/str/str.go new file mode 100644 index 0000000000000000000000000000000000000000..94be202ba2e61177c07e9a0e9848fffa40f5e2ce --- /dev/null +++ b/go/src/cmd/go/internal/str/str.go @@ -0,0 +1,103 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package str provides string manipulation utilities. +package str + +import ( + "fmt" + "strings" + "unicode" + "unicode/utf8" +) + +// StringList flattens its arguments into a single []string. +// Each argument in args must have type string or []string. +func StringList(args ...any) []string { + var x []string + for _, arg := range args { + switch arg := arg.(type) { + case []string: + x = append(x, arg...) + case string: + x = append(x, arg) + default: + panic("stringList: invalid argument of type " + fmt.Sprintf("%T", arg)) + } + } + return x +} + +// ToFold returns a string with the property that +// +// strings.EqualFold(s, t) iff ToFold(s) == ToFold(t) +// +// This lets us test a large set of strings for fold-equivalent +// duplicates without making a quadratic number of calls +// to EqualFold. Note that strings.ToUpper and strings.ToLower +// do not have the desired property in some corner cases. +func ToFold(s string) string { + // Fast path: all ASCII, no upper case. + // Most paths look like this already. + for i := 0; i < len(s); i++ { + c := s[i] + if c >= utf8.RuneSelf || 'A' <= c && c <= 'Z' { + goto Slow + } + } + return s + +Slow: + var b strings.Builder + for _, r := range s { + // SimpleFold(x) cycles to the next equivalent rune > x + // or wraps around to smaller values. Iterate until it wraps, + // and we've found the minimum value. + for { + r0 := r + r = unicode.SimpleFold(r0) + if r <= r0 { + break + } + } + // Exception to allow fast path above: A-Z => a-z + if 'A' <= r && r <= 'Z' { + r += 'a' - 'A' + } + b.WriteRune(r) + } + return b.String() +} + +// FoldDup reports a pair of strings from the list that are +// equal according to strings.EqualFold. +// It returns "", "" if there are no such strings. +func FoldDup(list []string) (string, string) { + clash := map[string]string{} + for _, s := range list { + fold := ToFold(s) + if t := clash[fold]; t != "" { + if s > t { + s, t = t, s + } + return s, t + } + clash[fold] = s + } + return "", "" +} + +// Uniq removes consecutive duplicate strings from ss. +func Uniq(ss *[]string) { + if len(*ss) <= 1 { + return + } + uniq := (*ss)[:1] + for _, s := range *ss { + if s != uniq[len(uniq)-1] { + uniq = append(uniq, s) + } + } + *ss = uniq +} diff --git a/go/src/cmd/go/internal/str/str_test.go b/go/src/cmd/go/internal/str/str_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7c1987766635c8b291eda6c3344ff1eecb000156 --- /dev/null +++ b/go/src/cmd/go/internal/str/str_test.go @@ -0,0 +1,185 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package str + +import ( + "os" + "path/filepath" + "runtime" + "strings" + "testing" +) + +var foldDupTests = []struct { + list []string + f1, f2 string +}{ + {StringList("math/rand", "math/big"), "", ""}, + {StringList("math", "strings"), "", ""}, + {StringList("strings"), "", ""}, + {StringList("strings", "strings"), "strings", "strings"}, + {StringList("Rand", "rand", "math", "math/rand", "math/Rand"), "Rand", "rand"}, +} + +func TestFoldDup(t *testing.T) { + for _, tt := range foldDupTests { + f1, f2 := FoldDup(tt.list) + if f1 != tt.f1 || f2 != tt.f2 { + t.Errorf("foldDup(%q) = %q, %q, want %q, %q", tt.list, f1, f2, tt.f1, tt.f2) + } + } +} + +func TestHasPathPrefix(t *testing.T) { + type testCase struct { + s, prefix string + want bool + } + for _, tt := range []testCase{ + {"", "", true}, + {"", "/", false}, + {"foo", "", true}, + {"foo", "/", false}, + {"foo", "foo", true}, + {"foo", "foo/", false}, + {"foo", "/foo", false}, + {"foo/bar", "", true}, + {"foo/bar", "foo", true}, + {"foo/bar", "foo/", true}, + {"foo/bar", "/foo", false}, + {"foo/bar", "foo/bar", true}, + {"foo/bar", "foo/bar/", false}, + {"foo/bar", "/foo/bar", false}, + } { + got := HasPathPrefix(tt.s, tt.prefix) + if got != tt.want { + t.Errorf("HasPathPrefix(%q, %q) = %v; want %v", tt.s, tt.prefix, got, tt.want) + } + } +} + +func TestTrimFilePathPrefixSlash(t *testing.T) { + if os.PathSeparator != '/' { + t.Skipf("test requires slash-separated file paths") + } + + type testCase struct { + s, prefix, want string + } + for _, tt := range []testCase{ + {"/", "", "/"}, + {"/", "/", ""}, + {"/foo", "", "/foo"}, + {"/foo", "/", "foo"}, + {"/foo", "/foo", ""}, + {"/foo/bar", "/foo", "bar"}, + {"/foo/bar", "/foo/", "bar"}, + {"/foo/", "/", "foo/"}, + {"/foo/", "/foo", ""}, + {"/foo/", "/foo/", ""}, + + // if prefix is not s's prefix, return s + {"", "/", ""}, + {"/foo", "/bar", "/foo"}, + {"/foo", "/foo/bar", "/foo"}, + {"foo", "/foo", "foo"}, + {"/foo", "foo", "/foo"}, + {"/foo", "/foo/", "/foo"}, + } { + got := TrimFilePathPrefix(tt.s, tt.prefix) + if got == tt.want { + t.Logf("TrimFilePathPrefix(%q, %q) = %q", tt.s, tt.prefix, got) + } else { + t.Errorf("TrimFilePathPrefix(%q, %q) = %q, want %q", tt.s, tt.prefix, got, tt.want) + } + + if HasFilePathPrefix(tt.s, tt.prefix) { + joined := filepath.Join(tt.prefix, got) + if clean := filepath.Clean(tt.s); joined != clean { + t.Errorf("filepath.Join(%q, %q) = %q, want %q", tt.prefix, got, joined, clean) + } + } + } +} + +func TestTrimFilePathPrefixWindows(t *testing.T) { + if runtime.GOOS != "windows" { + t.Skipf("test requires Windows file paths") + } + type testCase struct { + s, prefix, want string + } + for _, tt := range []testCase{ + {`\`, ``, `\`}, + {`\`, `\`, ``}, + {`C:`, `C:`, ``}, + {`C:\`, `C:`, `\`}, + {`C:\`, `C:\`, ``}, + {`C:\foo`, ``, `C:\foo`}, + {`C:\foo`, `C:`, `\foo`}, + {`C:\foo`, `C:\`, `foo`}, + {`C:\foo`, `C:\foo`, ``}, + {`C:\foo\`, `C:\foo`, ``}, + {`C:\foo\bar`, `C:\foo`, `bar`}, + {`C:\foo\bar`, `C:\foo\`, `bar`}, + // if prefix is not s's prefix, return s + {`C:\foo`, `C:\bar`, `C:\foo`}, + {`C:\foo`, `C:\foo\bar`, `C:\foo`}, + {`C:`, `C:\`, `C:`}, + // if volumes are different, return s + {`C:`, ``, `C:`}, + {`C:\`, ``, `C:\`}, + {`C:\foo`, ``, `C:\foo`}, + {`C:\foo`, `\foo`, `C:\foo`}, + {`C:\foo`, `D:\foo`, `C:\foo`}, + + //UNC path + {`\\host\share\foo`, `\\host\share`, `foo`}, + {`\\host\share\foo`, `\\host\share\`, `foo`}, + {`\\host\share\foo`, `\\host\share\foo`, ``}, + {`\\host\share\foo\bar`, `\\host\share\foo`, `bar`}, + {`\\host\share\foo\bar`, `\\host\share\foo\`, `bar`}, + // if prefix is not s's prefix, return s + {`\\host\share\foo`, `\\host\share\bar`, `\\host\share\foo`}, + {`\\host\share\foo`, `\\host\share\foo\bar`, `\\host\share\foo`}, + // if either host or share name is different, return s + {`\\host\share\foo`, ``, `\\host\share\foo`}, + {`\\host\share\foo`, `\foo`, `\\host\share\foo`}, + {`\\host\share\foo`, `\\host\other\`, `\\host\share\foo`}, + {`\\host\share\foo`, `\\other\share\`, `\\host\share\foo`}, + {`\\host\share\foo`, `\\host\`, `\\host\share\foo`}, + {`\\host\share\foo`, `\share\`, `\\host\share\foo`}, + + // only volume names are case-insensitive + {`C:\foo`, `c:`, `\foo`}, + {`C:\foo`, `c:\foo`, ``}, + {`c:\foo`, `C:`, `\foo`}, + {`c:\foo`, `C:\foo`, ``}, + {`C:\foo`, `C:\Foo`, `C:\foo`}, + {`\\Host\Share\foo`, `\\host\share`, `foo`}, + {`\\Host\Share\foo`, `\\host\share\foo`, ``}, + {`\\host\share\foo`, `\\Host\Share`, `foo`}, + {`\\host\share\foo`, `\\Host\Share\foo`, ``}, + {`\\Host\Share\foo`, `\\Host\Share\Foo`, `\\Host\Share\foo`}, + } { + got := TrimFilePathPrefix(tt.s, tt.prefix) + if got == tt.want { + t.Logf("TrimFilePathPrefix(%#q, %#q) = %#q", tt.s, tt.prefix, got) + } else { + t.Errorf("TrimFilePathPrefix(%#q, %#q) = %#q, want %#q", tt.s, tt.prefix, got, tt.want) + } + + if HasFilePathPrefix(tt.s, tt.prefix) { + // Although TrimFilePathPrefix is only case-insensitive in the volume name, + // what we care about in testing Join is that absolute paths remain + // absolute and relative paths remaining relative — there is no harm in + // over-normalizing letters in the comparison, so we use EqualFold. + joined := filepath.Join(tt.prefix, got) + if clean := filepath.Clean(tt.s); !strings.EqualFold(joined, clean) { + t.Errorf("filepath.Join(%#q, %#q) = %#q, want %#q", tt.prefix, got, joined, clean) + } + } + } +} diff --git a/go/src/cmd/go/internal/telemetrycmd/telemetry.go b/go/src/cmd/go/internal/telemetrycmd/telemetry.go new file mode 100644 index 0000000000000000000000000000000000000000..404ef638b10efce5fbc82abf4a3c265d2f6a3dee --- /dev/null +++ b/go/src/cmd/go/internal/telemetrycmd/telemetry.go @@ -0,0 +1,97 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package telemetrycmd implements the "go telemetry" command. +package telemetrycmd + +import ( + "context" + "fmt" + "os" + + "cmd/go/internal/base" + "cmd/internal/telemetry" +) + +var CmdTelemetry = &base.Command{ + UsageLine: "go telemetry [off|local|on]", + Short: "manage telemetry data and settings", + Long: `Telemetry is used to manage Go telemetry data and settings. + +Telemetry can be in one of three modes: off, local, or on. + +When telemetry is in local mode, counter data is written to the local file +system, but will not be uploaded to remote servers. + +When telemetry is off, local counter data is neither collected nor uploaded. + +When telemetry is on, telemetry data is written to the local file system +and periodically sent to https://telemetry.go.dev/. Uploaded data is used to +help improve the Go toolchain and related tools, and it will be published as +part of a public dataset. + +For more details, see https://telemetry.go.dev/privacy. +This data is collected in accordance with the Google Privacy Policy +(https://policies.google.com/privacy). + +To view the current telemetry mode, run "go telemetry". +To disable telemetry uploading, but keep local data collection, run +"go telemetry local". +To enable both collection and uploading, run “go telemetry on”. +To disable both collection and uploading, run "go telemetry off". + +The current telemetry mode is also available as the value of the +non-settable "GOTELEMETRY" go env variable. The directory in the +local file system that telemetry data is written to is available +as the value of the non-settable "GOTELEMETRYDIR" go env variable. + +See https://go.dev/doc/telemetry for more information on telemetry. +`, + Run: runTelemetry, +} + +func init() { + base.AddChdirFlag(&CmdTelemetry.Flag) +} + +func runTelemetry(ctx context.Context, cmd *base.Command, args []string) { + if len(args) == 0 { + fmt.Println(telemetry.Mode()) + return + } + + if len(args) != 1 { + cmd.Usage() + } + + mode := args[0] + if mode != "local" && mode != "off" && mode != "on" { + cmd.Usage() + } + if old := telemetry.Mode(); old == mode { + return + } + + if err := telemetry.SetMode(mode); err != nil { + base.Fatalf("go: failed to set the telemetry mode to %s: %v", mode, err) + } + if mode == "on" { + fmt.Fprintln(os.Stderr, telemetryOnMessage()) + } +} + +func telemetryOnMessage() string { + return `Telemetry uploading is now enabled and data will be periodically sent to +https://telemetry.go.dev/. Uploaded data is used to help improve the Go +toolchain and related tools, and it will be published as part of a public +dataset. + +For more details, see https://telemetry.go.dev/privacy. +This data is collected in accordance with the Google Privacy Policy +(https://policies.google.com/privacy). + +To disable telemetry uploading, but keep local data collection, run +“go telemetry local”. +To disable both collection and uploading, run “go telemetry off“.` +} diff --git a/go/src/cmd/go/internal/telemetrystats/telemetrystats.go b/go/src/cmd/go/internal/telemetrystats/telemetrystats.go new file mode 100644 index 0000000000000000000000000000000000000000..81a6e1e175846124f447bd85624aad94fdb98b7d --- /dev/null +++ b/go/src/cmd/go/internal/telemetrystats/telemetrystats.go @@ -0,0 +1,74 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cmd_go_bootstrap + +package telemetrystats + +import ( + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/modload" + "cmd/internal/telemetry/counter" + "strings" +) + +func Increment() { + incrementConfig() + incrementVersionCounters() +} + +// incrementConfig increments counters for the configuration +// the command is running in. +func incrementConfig() { + // TODO(jitsu): Telemetry for the go/mode counters should eventually be + // moved to modload.Init() + s := modload.NewState() + if !s.WillBeEnabled() { + counter.Inc("go/mode:gopath") + } else if workfile := s.FindGoWork(base.Cwd()); workfile != "" { + counter.Inc("go/mode:workspace") + } else { + counter.Inc("go/mode:module") + } + + if cfg.BuildContext.CgoEnabled { + counter.Inc("go/cgo:enabled") + } else { + counter.Inc("go/cgo:disabled") + } + + counter.Inc("go/platform/target/goos:" + cfg.Goos) + counter.Inc("go/platform/target/goarch:" + cfg.Goarch) + switch cfg.Goarch { + case "386": + counter.Inc("go/platform/target/go386:" + cfg.GO386) + case "amd64": + counter.Inc("go/platform/target/goamd64:" + cfg.GOAMD64) + case "arm": + counter.Inc("go/platform/target/goarm:" + cfg.GOARM) + case "arm64": + counter.Inc("go/platform/target/goarm64:" + cfg.GOARM64) + case "mips": + counter.Inc("go/platform/target/gomips:" + cfg.GOMIPS) + case "ppc64": + counter.Inc("go/platform/target/goppc64:" + cfg.GOPPC64) + case "riscv64": + counter.Inc("go/platform/target/goriscv64:" + cfg.GORISCV64) + case "wasm": + counter.Inc("go/platform/target/gowasm:" + cfg.GOWASM) + } + + // Use cfg.Experiment.String instead of cfg.Experiment.Enabled + // because we only want to count the experiments that differ + // from the baseline. + if cfg.Experiment != nil { + for exp := range strings.SplitSeq(cfg.Experiment.String(), ",") { + if exp == "" { + continue + } + counter.Inc("go/goexperiment:" + exp) + } + } +} diff --git a/go/src/cmd/go/internal/telemetrystats/telemetrystats_bootstrap.go b/go/src/cmd/go/internal/telemetrystats/telemetrystats_bootstrap.go new file mode 100644 index 0000000000000000000000000000000000000000..104676382ed05fc3bd9a820616a09d542afebd96 --- /dev/null +++ b/go/src/cmd/go/internal/telemetrystats/telemetrystats_bootstrap.go @@ -0,0 +1,9 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build cmd_go_bootstrap + +package telemetrystats + +func Increment() {} diff --git a/go/src/cmd/go/internal/telemetrystats/version_other.go b/go/src/cmd/go/internal/telemetrystats/version_other.go new file mode 100644 index 0000000000000000000000000000000000000000..efce5fcf362985b2cd1863f53e6d497a882d5628 --- /dev/null +++ b/go/src/cmd/go/internal/telemetrystats/version_other.go @@ -0,0 +1,13 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cmd_go_bootstrap && !unix && !windows + +package telemetrystats + +import "cmd/internal/telemetry/counter" + +func incrementVersionCounters() { + counter.Inc("go/platform:version-not-supported") +} diff --git a/go/src/cmd/go/internal/telemetrystats/version_unix.go b/go/src/cmd/go/internal/telemetrystats/version_unix.go new file mode 100644 index 0000000000000000000000000000000000000000..517e7829b68ef4768d2dfaaafb4322cf36478437 --- /dev/null +++ b/go/src/cmd/go/internal/telemetrystats/version_unix.go @@ -0,0 +1,60 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cmd_go_bootstrap && unix + +package telemetrystats + +import ( + "bytes" + "fmt" + "runtime" + "strings" + + "cmd/internal/telemetry/counter" + + "golang.org/x/sys/unix" +) + +func incrementVersionCounters() { + convert := func(nullterm []byte) string { + end := bytes.IndexByte(nullterm, 0) + if end < 0 { + end = len(nullterm) + } + return string(nullterm[:end]) + } + + var v unix.Utsname + err := unix.Uname(&v) + if err != nil { + counter.Inc(fmt.Sprintf("go/platform/host/%s/version:unknown-uname-error", runtime.GOOS)) + return + } + major, minor, ok := majorMinor(convert(v.Release[:])) + if runtime.GOOS == "aix" { + major, minor, ok = convert(v.Version[:]), convert(v.Release[:]), true + } + if !ok { + counter.Inc(fmt.Sprintf("go/platform/host/%s/version:unknown-bad-format", runtime.GOOS)) + return + } + counter.Inc(fmt.Sprintf("go/platform/host/%s/major-version:%s", runtime.GOOS, major)) + counter.Inc(fmt.Sprintf("go/platform/host/%s/version:%s-%s", runtime.GOOS, major, minor)) +} + +func majorMinor(v string) (string, string, bool) { + firstDot := strings.Index(v, ".") + if firstDot < 0 { + return "", "", false + } + major := v[:firstDot] + v = v[firstDot+len("."):] + endMinor := strings.IndexAny(v, ".-_") + if endMinor < 0 { + endMinor = len(v) + } + minor := v[:endMinor] + return major, minor, true +} diff --git a/go/src/cmd/go/internal/telemetrystats/version_windows.go b/go/src/cmd/go/internal/telemetrystats/version_windows.go new file mode 100644 index 0000000000000000000000000000000000000000..c5b1db7228507a5273653b91b4ab0e0c0680d28b --- /dev/null +++ b/go/src/cmd/go/internal/telemetrystats/version_windows.go @@ -0,0 +1,21 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !cmd_go_bootstrap && windows + +package telemetrystats + +import ( + "fmt" + "internal/syscall/windows" + + "cmd/internal/telemetry/counter" +) + +func incrementVersionCounters() { + major, minor, build := windows.Version() + counter.Inc(fmt.Sprintf("go/platform/host/windows/major-version:%d", major)) + counter.Inc(fmt.Sprintf("go/platform/host/windows/version:%d-%d", major, minor)) + counter.Inc(fmt.Sprintf("go/platform/host/windows/build:%d", build)) +} diff --git a/go/src/cmd/go/internal/test/cover.go b/go/src/cmd/go/internal/test/cover.go new file mode 100644 index 0000000000000000000000000000000000000000..e295c2d90fe40e315e116526a0118b85a915bc66 --- /dev/null +++ b/go/src/cmd/go/internal/test/cover.go @@ -0,0 +1,86 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "fmt" + "io" + "os" + "path/filepath" + "sync" +) + +var coverMerge struct { + f *os.File + sync.Mutex // for f.Write +} + +// initCoverProfile initializes the test coverage profile. +// It must be run before any calls to mergeCoverProfile or closeCoverProfile. +// Using this function clears the profile in case it existed from a previous run, +// or in case it doesn't exist and the test is going to fail to create it (or not run). +func initCoverProfile() { + if testCoverProfile == "" || testC { + return + } + if !filepath.IsAbs(testCoverProfile) { + testCoverProfile = filepath.Join(testOutputDir.getAbs(), testCoverProfile) + } + + // No mutex - caller's responsibility to call with no racing goroutines. + f, err := os.Create(testCoverProfile) + if err != nil { + base.Fatalf("%v", err) + } + _, err = fmt.Fprintf(f, "mode: %s\n", cfg.BuildCoverMode) + if err != nil { + base.Fatalf("%v", err) + } + coverMerge.f = f +} + +// mergeCoverProfile merges file into the profile stored in testCoverProfile. +// Errors encountered are logged and cause a non-zero exit status. +func mergeCoverProfile(file string) { + if coverMerge.f == nil { + return + } + coverMerge.Lock() + defer coverMerge.Unlock() + + expect := fmt.Sprintf("mode: %s\n", cfg.BuildCoverMode) + buf := make([]byte, len(expect)) + r, err := os.Open(file) + if err != nil { + // Test did not create profile, which is OK. + return + } + defer r.Close() + + n, err := io.ReadFull(r, buf) + if n == 0 { + return + } + if err != nil || string(buf) != expect { + base.Errorf("test wrote malformed coverage profile %s: header %q, expected %q: %v", file, string(buf), expect, err) + return + } + _, err = io.Copy(coverMerge.f, r) + if err != nil { + base.Errorf("saving coverage profile: %v", err) + return + } +} + +func closeCoverProfile() { + if coverMerge.f == nil { + return + } + if err := coverMerge.f.Close(); err != nil { + base.Errorf("closing coverage profile: %v", err) + } +} diff --git a/go/src/cmd/go/internal/test/flagdefs.go b/go/src/cmd/go/internal/test/flagdefs.go new file mode 100644 index 0000000000000000000000000000000000000000..b8b4bf649e42e7bd7f7a61448a21ac46249c8bbd --- /dev/null +++ b/go/src/cmd/go/internal/test/flagdefs.go @@ -0,0 +1,83 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by genflags.go — DO NOT EDIT. + +package test + +// passFlagToTest contains the flags that should be forwarded to +// the test binary with the prefix "test.". +var passFlagToTest = map[string]bool{ + "artifacts": true, + "bench": true, + "benchmem": true, + "benchtime": true, + "blockprofile": true, + "blockprofilerate": true, + "count": true, + "coverprofile": true, + "cpu": true, + "cpuprofile": true, + "failfast": true, + "fullpath": true, + "fuzz": true, + "fuzzminimizetime": true, + "fuzztime": true, + "list": true, + "memprofile": true, + "memprofilerate": true, + "mutexprofile": true, + "mutexprofilefraction": true, + "outputdir": true, + "parallel": true, + "run": true, + "short": true, + "shuffle": true, + "skip": true, + "timeout": true, + "trace": true, + "v": true, +} + +var passAnalyzersToVet = map[string]bool{ + "appends": true, + "asmdecl": true, + "assign": true, + "atomic": true, + "bool": true, + "bools": true, + "buildtag": true, + "buildtags": true, + "cgocall": true, + "composites": true, + "copylocks": true, + "defers": true, + "directive": true, + "errorsas": true, + "framepointer": true, + "hostport": true, + "httpresponse": true, + "ifaceassert": true, + "loopclosure": true, + "lostcancel": true, + "methods": true, + "nilfunc": true, + "printf": true, + "rangeloops": true, + "shift": true, + "sigchanyzer": true, + "slog": true, + "stdmethods": true, + "stdversion": true, + "stringintconv": true, + "structtag": true, + "testinggoroutine": true, + "tests": true, + "timeformat": true, + "unmarshal": true, + "unreachable": true, + "unsafeptr": true, + "unusedresult": true, + "waitgroup": true, +} diff --git a/go/src/cmd/go/internal/test/flagdefs_test.go b/go/src/cmd/go/internal/test/flagdefs_test.go new file mode 100644 index 0000000000000000000000000000000000000000..8a7ce1d7d6b85fa0df27b8af248bb96018692c0c --- /dev/null +++ b/go/src/cmd/go/internal/test/flagdefs_test.go @@ -0,0 +1,79 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "cmd/go/internal/cfg" + "cmd/go/internal/test/internal/genflags" + "internal/testenv" + "maps" + "os" + "testing" +) + +func TestMain(m *testing.M) { + cfg.SetGOROOT(testenv.GOROOT(nil), false) + os.Exit(m.Run()) +} + +// TestPassFlagToTest ensures that the generated table of flags is +// consistent with output of "go tool vet -flags", using the installed +// go command---so if it fails, you may need to re-run make.bash. +func TestPassFlagToTest(t *testing.T) { + wantNames := genflags.ShortTestFlags() + + missing := map[string]bool{} + for _, name := range wantNames { + if !passFlagToTest[name] { + missing[name] = true + } + } + if len(missing) > 0 { + t.Errorf("passFlagToTest is missing entries: %v", missing) + } + + extra := maps.Clone(passFlagToTest) + for _, name := range wantNames { + delete(extra, name) + } + if len(extra) > 0 { + t.Errorf("passFlagToTest contains extra entries: %v", extra) + } + + if t.Failed() { + t.Logf("To regenerate:\n\tgo generate cmd/go/internal/test") + } +} + +func TestPassAnalyzersToVet(t *testing.T) { + testenv.MustHaveGoBuild(t) // runs 'go tool vet -flags' + + wantNames, err := genflags.VetAnalyzers() + if err != nil { + t.Fatal(err) + } + + missing := map[string]bool{} + for _, name := range wantNames { + if !passAnalyzersToVet[name] { + missing[name] = true + } + } + if len(missing) > 0 { + t.Errorf("passAnalyzersToVet is missing entries: %v", missing) + } + + extra := maps.Clone(passAnalyzersToVet) + for _, name := range wantNames { + delete(extra, name) + } + if len(extra) > 0 { + t.Errorf("passFlagToTest contains extra entries: %v", extra) + } + + if t.Failed() { + t.Logf("To regenerate:\n\tgo generate cmd/go/internal/test") + } +} diff --git a/go/src/cmd/go/internal/test/genflags.go b/go/src/cmd/go/internal/test/genflags.go new file mode 100644 index 0000000000000000000000000000000000000000..bb5ceb647baf4ce508865f313255ff2d12aba71b --- /dev/null +++ b/go/src/cmd/go/internal/test/genflags.go @@ -0,0 +1,84 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +package main + +import ( + "bytes" + "log" + "os" + "os/exec" + "text/template" + + "cmd/go/internal/test/internal/genflags" +) + +func main() { + if err := regenerate(); err != nil { + log.Fatal(err) + } +} + +func regenerate() error { + vetAnalyzers, err := genflags.VetAnalyzers() + if err != nil { + return err + } + + t := template.Must(template.New("fileTemplate").Parse(fileTemplate)) + tData := map[string][]string{ + "testFlags": genflags.ShortTestFlags(), + "vetAnalyzers": vetAnalyzers, + } + buf := bytes.NewBuffer(nil) + if err := t.Execute(buf, tData); err != nil { + return err + } + + f, err := os.Create("flagdefs.go") + if err != nil { + return err + } + + cmd := exec.Command("gofmt") + cmd.Stdin = buf + cmd.Stdout = f + cmd.Stderr = os.Stderr + cmdErr := cmd.Run() + + if err := f.Close(); err != nil { + return err + } + if cmdErr != nil { + os.Remove(f.Name()) + return cmdErr + } + + return nil +} + +const fileTemplate = `// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by genflags.go — DO NOT EDIT. + +package test + +// passFlagToTest contains the flags that should be forwarded to +// the test binary with the prefix "test.". +var passFlagToTest = map[string]bool { +{{- range .testFlags}} + "{{.}}": true, +{{- end }} +} + +var passAnalyzersToVet = map[string]bool { +{{- range .vetAnalyzers}} + "{{.}}": true, +{{- end }} +} +` diff --git a/go/src/cmd/go/internal/test/internal/genflags/testflag.go b/go/src/cmd/go/internal/test/internal/genflags/testflag.go new file mode 100644 index 0000000000000000000000000000000000000000..712428d86adc1607f417a4c047be006231cfd4af --- /dev/null +++ b/go/src/cmd/go/internal/test/internal/genflags/testflag.go @@ -0,0 +1,35 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package genflags + +import ( + "flag" + "strings" + "testing" +) + +// ShortTestFlags returns the set of "-test." flag shorthand names that end +// users may pass to 'go test'. +func ShortTestFlags() []string { + testing.Init() + + var names []string + flag.VisitAll(func(f *flag.Flag) { + var name string + var found bool + if name, found = strings.CutPrefix(f.Name, "test."); !found { + return + } + + switch name { + case "testlogfile", "paniconexit0", "fuzzcachedir", "fuzzworker", "gocoverdir": + // These flags are only for use by cmd/go. + default: + names = append(names, name) + } + }) + + return names +} diff --git a/go/src/cmd/go/internal/test/internal/genflags/vetflag.go b/go/src/cmd/go/internal/test/internal/genflags/vetflag.go new file mode 100644 index 0000000000000000000000000000000000000000..1448811af053e4ab7f2270c6d3e9ee13f9bb2f0f --- /dev/null +++ b/go/src/cmd/go/internal/test/internal/genflags/vetflag.go @@ -0,0 +1,68 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package genflags + +import ( + "bytes" + "cmd/go/internal/base" + "encoding/json" + "fmt" + "os/exec" + "regexp" + "sort" +) + +// VetAnalyzers computes analyzers and their aliases supported by vet. +func VetAnalyzers() ([]string, error) { + // get supported vet flag information + tool := base.Tool("vet") + vetcmd := exec.Command(tool, "-flags") + out := new(bytes.Buffer) + vetcmd.Stdout = out + if err := vetcmd.Run(); err != nil { + return nil, fmt.Errorf("go vet: can't execute %s -flags: %v\n", tool, err) + } + var analysisFlags []struct { + Name string + Bool bool + Usage string + } + if err := json.Unmarshal(out.Bytes(), &analysisFlags); err != nil { + return nil, fmt.Errorf("go vet: can't unmarshal JSON from %s -flags: %v", tool, err) + } + + // parse the flags to figure out which ones stand for analyses + analyzerSet := make(map[string]bool) + rEnable := regexp.MustCompile("^enable .+ analysis$") + for _, flag := range analysisFlags { + if rEnable.MatchString(flag.Usage) { + analyzerSet[flag.Name] = true + } + } + + rDeprecated := regexp.MustCompile("^deprecated alias for -(?P(.+))$") + // Returns the original value matched by rDeprecated on input value. + // If there is no match, "" is returned. + originalValue := func(value string) string { + match := rDeprecated.FindStringSubmatch(value) + if len(match) < 2 { + return "" + } + return match[1] + } + // extract deprecated aliases for existing analyses + for _, flag := range analysisFlags { + if o := originalValue(flag.Usage); analyzerSet[o] { + analyzerSet[flag.Name] = true + } + } + + var analyzers []string + for a := range analyzerSet { + analyzers = append(analyzers, a) + } + sort.Strings(analyzers) + return analyzers, nil +} diff --git a/go/src/cmd/go/internal/test/test.go b/go/src/cmd/go/internal/test/test.go new file mode 100644 index 0000000000000000000000000000000000000000..1eb7905413a0d04337d574ce65591af0c14fb81e --- /dev/null +++ b/go/src/cmd/go/internal/test/test.go @@ -0,0 +1,2301 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "bytes" + "context" + "errors" + "fmt" + "internal/coverage" + "internal/platform" + "io" + "io/fs" + "os" + "os/exec" + "path/filepath" + "regexp" + "slices" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + + "cmd/go/internal/base" + "cmd/go/internal/cache" + "cmd/go/internal/cfg" + "cmd/go/internal/load" + "cmd/go/internal/lockedfile" + "cmd/go/internal/modload" + "cmd/go/internal/search" + "cmd/go/internal/str" + "cmd/go/internal/trace" + "cmd/go/internal/work" + "cmd/internal/test2json" + + "golang.org/x/mod/module" +) + +// Break init loop. +func init() { + CmdTest.Run = runTest +} + +const testUsage = "go test [build/test flags] [packages] [build/test flags & test binary flags]" + +var CmdTest = &base.Command{ + CustomFlags: true, + UsageLine: testUsage, + Short: "test packages", + Long: ` +'Go test' automates testing the packages named by the import paths. +It prints a summary of the test results in the format: + + ok archive/tar 0.011s + FAIL archive/zip 0.022s + ok compress/gzip 0.033s + ... + +followed by detailed output for each failed package. + +'Go test' recompiles each package along with any files with names matching +the file pattern "*_test.go". +These additional files can contain test functions, benchmark functions, fuzz +tests and example functions. See 'go help testfunc' for more. +Each listed package causes the execution of a separate test binary. +Files whose names begin with "_" (including "_test.go") or "." are ignored. + +Test files that declare a package with the suffix "_test" will be compiled as a +separate package, and then linked and run with the main test binary. + +The go tool will ignore a directory named "testdata", making it available +to hold ancillary data needed by the tests. + +As part of building a test binary, go test runs go vet on the package +and its test source files to identify significant problems. If go vet +finds any problems, go test reports those and does not run the test +binary. Only a high-confidence subset of the default go vet checks are +used. That subset is: atomic, bool, buildtags, directive, errorsas, +ifaceassert, nilfunc, printf, stringintconv, and tests. You can see +the documentation for these and other vet tests via "go doc cmd/vet". +To disable the running of go vet, use the -vet=off flag. To run all +checks, use the -vet=all flag. + +All test output and summary lines are printed to the go command's +standard output, even if the test printed them to its own standard +error. (The go command's standard error is reserved for printing +errors building the tests.) + +The go command places $GOROOT/bin at the beginning of $PATH +in the test's environment, so that tests that execute +'go' commands use the same 'go' as the parent 'go test' command. + +Go test runs in two different modes: + +The first, called local directory mode, occurs when go test is +invoked with no package arguments (for example, 'go test' or 'go +test -v'). In this mode, go test compiles the package sources and +tests found in the current directory and then runs the resulting +test binary. In this mode, caching (discussed below) is disabled. +After the package test finishes, go test prints a summary line +showing the test status ('ok' or 'FAIL'), package name, and elapsed +time. + +The second, called package list mode, occurs when go test is invoked +with explicit package arguments (for example 'go test math', 'go +test ./...', and even 'go test .'). In this mode, go test compiles +and tests each of the packages listed on the command line. If a +package test passes, go test prints only the final 'ok' summary +line. If a package test fails, go test prints the full test output. +If invoked with the -bench or -v flag, go test prints the full +output even for passing package tests, in order to display the +requested benchmark results or verbose logging. After the package +tests for all of the listed packages finish, and their output is +printed, go test prints a final 'FAIL' status if any package test +has failed. + +In package list mode only, go test caches successful package test +results to avoid unnecessary repeated running of tests. When the +result of a test can be recovered from the cache, go test will +redisplay the previous output instead of running the test binary +again. When this happens, go test prints '(cached)' in place of the +elapsed time in the summary line. + +The rule for a match in the cache is that the run involves the same +test binary and the flags on the command line come entirely from a +restricted set of 'cacheable' test flags, defined as -benchtime, +-coverprofile, -cpu, -failfast, -fullpath, -list, -outputdir, -parallel, +-run, -short, -skip, -timeout and -v. +If a run of go test has any test or non-test flags outside this set, +the result is not cached. To disable test caching, use any test flag +or argument other than the cacheable flags. The idiomatic way to disable +test caching explicitly is to use -count=1. Tests that open files within +the package's module or that consult environment variables only +match future runs in which the files and environment variables are +unchanged. A cached test result is treated as executing in no time +at all, so a successful package test result will be cached and +reused regardless of -timeout setting. + +In addition to the build flags, the flags handled by 'go test' itself are: + + -args + Pass the remainder of the command line (everything after -args) + to the test binary, uninterpreted and unchanged. + Because this flag consumes the remainder of the command line, + the package list (if present) must appear before this flag. + + -c + Compile the test binary to pkg.test in the current directory but do not run it + (where pkg is the last element of the package's import path). + The file name or target directory can be changed with the -o flag. + + -exec xprog + Run the test binary using xprog. The behavior is the same as + in 'go run'. See 'go help run' for details. + + -json + Convert test output to JSON suitable for automated processing. + See 'go doc test2json' for the encoding details. + Also emits build output in JSON. See 'go help buildjson'. + + -o file + Save a copy of the test binary to the named file. + The test still runs (unless -c is specified). + If file ends in a slash or names an existing directory, + the test is written to pkg.test in that directory. + +The test binary also accepts flags that control execution of the test; these +flags are also accessible by 'go test'. See 'go help testflag' for details. + +For more about build flags, see 'go help build'. +For more about specifying packages, see 'go help packages'. + +See also: go build, go vet. +`, +} + +var HelpTestflag = &base.Command{ + UsageLine: "testflag", + Short: "testing flags", + Long: ` +The 'go test' command takes both flags that apply to 'go test' itself +and flags that apply to the resulting test binary. + +Several of the flags control profiling and write an execution profile +suitable for "go tool pprof"; run "go tool pprof -h" for more +information. The -sample_index=alloc_space, -sample_index=alloc_objects, +and -show_bytes options of pprof control how the information is presented. + +The following flags are recognized by the 'go test' command and +control the execution of any test: + + -artifacts + Save test artifacts in the directory specified by -outputdir. + See 'go doc testing.T.ArtifactDir'. + + -bench regexp + Run only those benchmarks matching a regular expression. + By default, no benchmarks are run. + To run all benchmarks, use '-bench .' or '-bench=.'. + The regular expression is split by unbracketed slash (/) + characters into a sequence of regular expressions, and each + part of a benchmark's identifier must match the corresponding + element in the sequence, if any. Possible parents of matches + are run with b.N=1 to identify sub-benchmarks. For example, + given -bench=X/Y, top-level benchmarks matching X are run + with b.N=1 to find any sub-benchmarks matching Y, which are + then run in full. + + -benchtime t + Run enough iterations of each benchmark to take t, specified + as a time.Duration (for example, -benchtime 1h30s). + The default is 1 second (1s). + The special syntax Nx means to run the benchmark N times + (for example, -benchtime 100x). + + -count n + Run each test, benchmark, and fuzz seed n times (default 1). + If -cpu is set, run n times for each GOMAXPROCS value. + Examples are always run once. -count does not apply to + fuzz tests matched by -fuzz. + + -cover + Enable coverage analysis. + Note that because coverage works by annotating the source + code before compilation, compilation and test failures with + coverage enabled may report line numbers that don't correspond + to the original sources. + + -covermode set,count,atomic + Set the mode for coverage analysis for the package[s] + being tested. The default is "set" unless -race is enabled, + in which case it is "atomic". + The values: + set: bool: does this statement run? + count: int: how many times does this statement run? + atomic: int: count, but correct in multithreaded tests; + significantly more expensive. + Sets -cover. + + -coverpkg pattern1,pattern2,pattern3 + Apply coverage analysis in each test to packages whose import paths + match the patterns. The default is for each test to analyze only + the package being tested. See 'go help packages' for a description + of package patterns. Sets -cover. + + -cpu 1,2,4 + Specify a list of GOMAXPROCS values for which the tests, benchmarks or + fuzz tests should be executed. The default is the current value + of GOMAXPROCS. -cpu does not apply to fuzz tests matched by -fuzz. + + -failfast + Do not start new tests after the first test failure. + + -fullpath + Show full file names in the error messages. + + -fuzz regexp + Run the fuzz test matching the regular expression. When specified, + the command line argument must match exactly one package within the + main module, and regexp must match exactly one fuzz test within + that package. Fuzzing will occur after tests, benchmarks, seed corpora + of other fuzz tests, and examples have completed. See the Fuzzing + section of the testing package documentation for details. + + -fuzztime t + Run enough iterations of the fuzz target during fuzzing to take t, + specified as a time.Duration (for example, -fuzztime 1h30s). + The default is to run forever. + The special syntax Nx means to run the fuzz target N times + (for example, -fuzztime 1000x). + + -fuzzminimizetime t + Run enough iterations of the fuzz target during each minimization + attempt to take t, as specified as a time.Duration (for example, + -fuzzminimizetime 30s). + The default is 60s. + The special syntax Nx means to run the fuzz target N times + (for example, -fuzzminimizetime 100x). + + -json + Log verbose output and test results in JSON. This presents the + same information as the -v flag in a machine-readable format. + + -list regexp + List tests, benchmarks, fuzz tests, or examples matching the regular + expression. No tests, benchmarks, fuzz tests, or examples will be run. + This will only list top-level tests. No subtest or subbenchmarks will be + shown. + + -outputdir directory + Place output files from profiling and test artifacts in the + specified directory, by default the directory in which "go test" is running. + + -parallel n + Allow parallel execution of test functions that call t.Parallel, and + fuzz targets that call t.Parallel when running the seed corpus. + The value of this flag is the maximum number of tests to run + simultaneously. + While fuzzing, the value of this flag is the maximum number of + subprocesses that may call the fuzz function simultaneously, regardless of + whether T.Parallel is called. + By default, -parallel is set to the value of GOMAXPROCS. + Setting -parallel to values higher than GOMAXPROCS may cause degraded + performance due to CPU contention, especially when fuzzing. + Note that -parallel only applies within a single test binary. + The 'go test' command may run tests for different packages + in parallel as well, according to the setting of the -p flag + (see 'go help build'). + + -run regexp + Run only those tests, examples, and fuzz tests matching the regular + expression. For tests, the regular expression is split by unbracketed + slash (/) characters into a sequence of regular expressions, and each + part of a test's identifier must match the corresponding element in + the sequence, if any. Note that possible parents of matches are + run too, so that -run=X/Y matches and runs and reports the result + of all tests matching X, even those without sub-tests matching Y, + because it must run them to look for those sub-tests. + See also -skip. + + -short + Tell long-running tests to shorten their run time. + It is off by default but set during all.bash so that installing + the Go tree can run a sanity check but not spend time running + exhaustive tests. + + -shuffle off,on,N + Randomize the execution order of tests and benchmarks. + It is off by default. If -shuffle is set to on, then it will seed + the randomizer using the system clock. If -shuffle is set to an + integer N, then N will be used as the seed value. In both cases, + the seed will be reported for reproducibility. + + -skip regexp + Run only those tests, examples, fuzz tests, and benchmarks that + do not match the regular expression. Like for -run and -bench, + for tests and benchmarks, the regular expression is split by unbracketed + slash (/) characters into a sequence of regular expressions, and each + part of a test's identifier must match the corresponding element in + the sequence, if any. + + -timeout d + If a test binary runs longer than duration d, panic. + If d is 0, the timeout is disabled. + The default is 10 minutes (10m). + + -v + Verbose output: log all tests as they are run. Also print all + text from Log and Logf calls even if the test succeeds. + + -vet list + Configure the invocation of "go vet" during "go test" + to use the comma-separated list of vet checks. + If list is empty, "go test" runs "go vet" with a curated list of + checks believed to be always worth addressing. + If list is "off", "go test" does not run "go vet" at all. + +The following flags are also recognized by 'go test' and can be used to +profile the tests during execution: + + -benchmem + Print memory allocation statistics for benchmarks. + Allocations made in C or using C.malloc are not counted. + + -blockprofile block.out + Write a goroutine blocking profile to the specified file + when all tests are complete. + Writes test binary as -c would. + + -blockprofilerate n + Control the detail provided in goroutine blocking profiles by + calling runtime.SetBlockProfileRate with n. + See 'go doc runtime.SetBlockProfileRate'. + The profiler aims to sample, on average, one blocking event every + n nanoseconds the program spends blocked. By default, + if -test.blockprofile is set without this flag, all blocking events + are recorded, equivalent to -test.blockprofilerate=1. + + -coverprofile cover.out + Write a coverage profile to the file after all tests have passed. + Sets -cover. + + -cpuprofile cpu.out + Write a CPU profile to the specified file before exiting. + Writes test binary as -c would. + + -memprofile mem.out + Write an allocation profile to the file after all tests have passed. + Writes test binary as -c would. + + -memprofilerate n + Enable more precise (and expensive) memory allocation profiles by + setting runtime.MemProfileRate. See 'go doc runtime.MemProfileRate'. + To profile all memory allocations, use -test.memprofilerate=1. + + -mutexprofile mutex.out + Write a mutex contention profile to the specified file + when all tests are complete. + Writes test binary as -c would. + + -mutexprofilefraction n + Sample 1 in n stack traces of goroutines holding a + contended mutex. + + -trace trace.out + Write an execution trace to the specified file before exiting. + +Each of these flags is also recognized with an optional 'test.' prefix, +as in -test.v. When invoking the generated test binary (the result of +'go test -c') directly, however, the prefix is mandatory. + +The 'go test' command rewrites or removes recognized flags, +as appropriate, both before and after the optional package list, +before invoking the test binary. + +For instance, the command + + go test -v -myflag testdata -cpuprofile=prof.out -x + +will compile the test binary and then run it as + + pkg.test -test.v -myflag testdata -test.cpuprofile=prof.out + +(The -x flag is removed because it applies only to the go command's +execution, not to the test itself.) + +The test flags that generate profiles (other than for coverage) also +leave the test binary in pkg.test for use when analyzing the profiles. + +When 'go test' runs a test binary, it does so from within the +corresponding package's source code directory. Depending on the test, +it may be necessary to do the same when invoking a generated test +binary directly. Because that directory may be located within the +module cache, which may be read-only and is verified by checksums, the +test must not write to it or any other directory within the module +unless explicitly requested by the user (such as with the -fuzz flag, +which writes failures to testdata/fuzz). + +The command-line package list, if present, must appear before any +flag not known to the go test command. Continuing the example above, +the package list would have to appear before -myflag, but could appear +on either side of -v. + +When 'go test' runs in package list mode, 'go test' caches successful +package test results to avoid unnecessary repeated running of tests. To +disable test caching, use any test flag or argument other than the +cacheable flags. The idiomatic way to disable test caching explicitly +is to use -count=1. + +To keep an argument for a test binary from being interpreted as a +known flag or a package name, use -args (see 'go help test') which +passes the remainder of the command line through to the test binary +uninterpreted and unaltered. + +For instance, the command + + go test -v -args -x -v + +will compile the test binary and then run it as + + pkg.test -test.v -x -v + +Similarly, + + go test -args math + +will compile the test binary and then run it as + + pkg.test math + +In the first example, the -x and the second -v are passed through to the +test binary unchanged and with no effect on the go command itself. +In the second example, the argument math is passed through to the test +binary, instead of being interpreted as the package list. +`, +} + +var HelpTestfunc = &base.Command{ + UsageLine: "testfunc", + Short: "testing functions", + Long: ` +The 'go test' command expects to find test, benchmark, and example functions +in the "*_test.go" files corresponding to the package under test. + +A test function is one named TestXxx (where Xxx does not start with a +lower case letter) and should have the signature, + + func TestXxx(t *testing.T) { ... } + +A benchmark function is one named BenchmarkXxx and should have the signature, + + func BenchmarkXxx(b *testing.B) { ... } + +A fuzz test is one named FuzzXxx and should have the signature, + + func FuzzXxx(f *testing.F) { ... } + +An example function is similar to a test function but, instead of using +*testing.T to report success or failure, prints output to os.Stdout. +If the last comment in the function starts with "Output:" then the output +is compared exactly against the comment (see examples below). If the last +comment begins with "Unordered output:" then the output is compared to the +comment, however the order of the lines is ignored. An example with no such +comment is compiled but not executed. An example with no text after +"Output:" is compiled, executed, and expected to produce no output. + +Godoc displays the body of ExampleXxx to demonstrate the use +of the function, constant, or variable Xxx. An example of a method M with +receiver type T or *T is named ExampleT_M. There may be multiple examples +for a given function, constant, or variable, distinguished by a trailing _xxx, +where xxx is a suffix not beginning with an upper case letter. + +Here is an example of an example: + + func ExamplePrintln() { + Println("The output of\nthis example.") + // Output: The output of + // this example. + } + +Here is another example where the ordering of the output is ignored: + + func ExamplePerm() { + for _, value := range Perm(4) { + fmt.Println(value) + } + + // Unordered output: 4 + // 2 + // 1 + // 3 + // 0 + } + +The entire test file is presented as the example when it contains a single +example function, at least one other function, type, variable, or constant +declaration, and no tests, benchmarks, or fuzz tests. + +See the documentation of the testing package for more information. +`, +} + +var ( + testArtifacts bool // -artifacts flag + testBench string // -bench flag + testC bool // -c flag + testCoverPkgs []*load.Package // -coverpkg flag + testCoverProfile string // -coverprofile flag + testFailFast bool // -failfast flag + testFuzz string // -fuzz flag + testJSON bool // -json flag + testList string // -list flag + testO string // -o flag + testOutputDir outputdirFlag // -outputdir flag + testShuffle shuffleFlag // -shuffle flag + testTimeout time.Duration // -timeout flag + testV testVFlag // -v flag + testVet = vetFlag{flags: defaultVetFlags} // -vet flag +) + +type testVFlag struct { + on bool // -v is set in some form + json bool // -v=test2json is set, to make output better for test2json +} + +func (*testVFlag) IsBoolFlag() bool { return true } + +func (f *testVFlag) Set(arg string) error { + if v, err := strconv.ParseBool(arg); err == nil { + f.on = v + f.json = false + return nil + } + if arg == "test2json" { + f.on = true + f.json = true + return nil + } + return fmt.Errorf("invalid flag -test.v=%s", arg) +} + +func (f *testVFlag) String() string { + if f.json { + return "test2json" + } + if f.on { + return "true" + } + return "false" +} + +var ( + testArgs []string + pkgArgs []string + pkgs []*load.Package + + testHelp bool // -help option passed to test via -args + + testKillTimeout = 100 * 365 * 24 * time.Hour // backup alarm; defaults to about a century if no timeout is set + testWaitDelay time.Duration // how long to wait for output to close after a test binary exits; zero means unlimited + testCacheExpire time.Time // ignore cached test results before this time + testShouldFailFast atomic.Bool // signals pending tests to fail fast + + testBlockProfile, testCPUProfile, testMemProfile, testMutexProfile, testTrace string // profiling flag that limits test to one package + + testODir = false +) + +// testProfile returns the name of an arbitrary single-package profiling flag +// that is set, if any. +func testProfile() string { + switch { + case testBlockProfile != "": + return "-blockprofile" + case testCPUProfile != "": + return "-cpuprofile" + case testMemProfile != "": + return "-memprofile" + case testMutexProfile != "": + return "-mutexprofile" + case testTrace != "": + return "-trace" + default: + return "" + } +} + +// testNeedBinary reports whether the test needs to keep the binary around. +func testNeedBinary() bool { + switch { + case testBlockProfile != "": + return true + case testCPUProfile != "": + return true + case testMemProfile != "": + return true + case testMutexProfile != "": + return true + case testO != "": + return true + default: + return false + } +} + +// testShowPass reports whether the output for a passing test should be shown. +func testShowPass() bool { + return testV.on || testList != "" || testHelp +} + +var defaultVetFlags = []string{ + // TODO(rsc): Decide which tests are enabled by default. + // See golang.org/issue/18085. + // "-asmdecl", + // "-assign", + "-atomic", + "-bool", + "-buildtags", + // "-cgocall", + // "-composites", + // "-copylocks", + "-directive", + "-errorsas", + // "-httpresponse", + "-ifaceassert", + // "-lostcancel", + // "-methods", + "-nilfunc", + "-printf", + // "-rangeloops", + // "-shift", + "-slog", + "-stringintconv", + // "-structtags", + "-tests", + // "-unreachable", + // "-unsafeptr", + // "-unusedresult", +} + +func runTest(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + pkgArgs, testArgs = testFlags(args) + moduleLoaderState.InitWorkfile() // The test command does custom flag processing; initialize workspaces after that. + + if cfg.DebugTrace != "" { + var close func() error + var err error + ctx, close, err = trace.Start(ctx, cfg.DebugTrace) + if err != nil { + base.Fatalf("failed to start trace: %v", err) + } + defer func() { + if err := close(); err != nil { + base.Fatalf("failed to stop trace: %v", err) + } + }() + } + + ctx, span := trace.StartSpan(ctx, fmt.Sprint("Running ", cmd.Name(), " command")) + defer span.Done() + + work.FindExecCmd() // initialize cached result + + work.BuildInit(moduleLoaderState) + work.VetFlags = testVet.flags + work.VetExplicit = testVet.explicit + work.VetTool = base.Tool("vet") + + pkgOpts := load.PackageOpts{ModResolveTests: true} + pkgs = load.PackagesAndErrors(moduleLoaderState, ctx, pkgOpts, pkgArgs) + // We *don't* call load.CheckPackageErrors here because we want to report + // loading errors as per-package test setup errors later. + if len(pkgs) == 0 { + base.Fatalf("no packages to test") + } + + if testFuzz != "" { + if !platform.FuzzSupported(cfg.Goos, cfg.Goarch) { + base.Fatalf("-fuzz flag is not supported on %s/%s", cfg.Goos, cfg.Goarch) + } + if len(pkgs) != 1 { + base.Fatalf("cannot use -fuzz flag with multiple packages") + } + if testCoverProfile != "" { + base.Fatalf("cannot use -coverprofile flag with -fuzz flag") + } + if profileFlag := testProfile(); profileFlag != "" { + base.Fatalf("cannot use %s flag with -fuzz flag", profileFlag) + } + + // Reject the '-fuzz' flag if the package is outside the main module. + // Otherwise, if fuzzing identifies a failure it could corrupt checksums in + // the module cache (or permanently alter the behavior of std tests for all + // users) by writing the failing input to the package's testdata directory. + // (See https://golang.org/issue/48495 and cmd/internal/fuzztest/test_fuzz_modcache.txt.) + mainMods := moduleLoaderState.MainModules + if m := pkgs[0].Module; m != nil && m.Path != "" { + if !mainMods.Contains(m.Path) { + base.Fatalf("cannot use -fuzz flag on package outside the main module") + } + } else if pkgs[0].Standard && moduleLoaderState.Enabled() { + // Because packages in 'std' and 'cmd' are part of the standard library, + // they are only treated as part of a module in 'go mod' subcommands and + // 'go get'. However, we still don't want to accidentally corrupt their + // testdata during fuzzing, nor do we want to fail with surprising errors + // if GOROOT isn't writable (as is often the case for Go toolchains + // installed through package managers). + // + // If the user is requesting to fuzz a standard-library package, ensure + // that they are in the same module as that package (just like when + // fuzzing any other package). + if strings.HasPrefix(pkgs[0].ImportPath, "cmd/") { + if !mainMods.Contains("cmd") || !mainMods.InGorootSrc(module.Version{Path: "cmd"}) { + base.Fatalf("cannot use -fuzz flag on package outside the main module") + } + } else { + if !mainMods.Contains("std") || !mainMods.InGorootSrc(module.Version{Path: "std"}) { + base.Fatalf("cannot use -fuzz flag on package outside the main module") + } + } + } + } + if testProfile() != "" && len(pkgs) != 1 { + base.Fatalf("cannot use %s flag with multiple packages", testProfile()) + } + + if testO != "" { + if strings.HasSuffix(testO, "/") || strings.HasSuffix(testO, string(os.PathSeparator)) { + testODir = true + } else if fi, err := os.Stat(testO); err == nil && fi.IsDir() { + testODir = true + } + } + + if len(pkgs) > 1 && (testC || testO != "") && !base.IsNull(testO) { + if testO != "" && !testODir { + base.Fatalf("with multiple packages, -o must refer to a directory or %s", os.DevNull) + } + + pkgsForBinary := map[string][]*load.Package{} + + for _, p := range pkgs { + testBinary := testBinaryName(p) + pkgsForBinary[testBinary] = append(pkgsForBinary[testBinary], p) + } + + for testBinary, pkgs := range pkgsForBinary { + if len(pkgs) > 1 { + var buf strings.Builder + for _, pkg := range pkgs { + buf.WriteString(pkg.ImportPath) + buf.WriteString("\n") + } + + base.Errorf("cannot write test binary %s for multiple packages:\n%s", testBinary, buf.String()) + } + } + + base.ExitIfErrors() + } + + initCoverProfile() + defer closeCoverProfile() + + // If a test timeout is finite, set our kill timeout + // to that timeout plus one minute. This is a backup alarm in case + // the test wedges with a goroutine spinning and its background + // timer does not get a chance to fire. + // Don't set this if fuzzing or benchmarking, since it should be able to run + // indefinitely. + if testTimeout > 0 && testFuzz == "" && testBench == "" { + // The WaitDelay for the test process depends on both the OS I/O and + // scheduling overhead and the amount of I/O generated by the test just + // before it exits. We set the minimum at 5 seconds to account for the OS + // overhead, and scale it up from there proportional to the overall test + // timeout on the assumption that the time to write and read a goroutine + // dump from a timed-out test process scales roughly with the overall + // running time of the test. + // + // This is probably too generous when the timeout is very long, but it seems + // better to hard-code a scale factor than to hard-code a constant delay. + if wd := testTimeout / 10; wd < 5*time.Second { + testWaitDelay = 5 * time.Second + } else { + testWaitDelay = wd + } + + // We expect the test binary to terminate itself (and dump stacks) after + // exactly testTimeout. We give it up to one WaitDelay or one minute, + // whichever is longer, to finish dumping stacks before we send it an + // external signal: if the process has a lot of goroutines, dumping stacks + // after the timeout can take a while. + // + // After the signal is delivered, the test process may have up to one + // additional WaitDelay to finish writing its output streams. + if testWaitDelay < 1*time.Minute { + testKillTimeout = testTimeout + 1*time.Minute + } else { + testKillTimeout = testTimeout + testWaitDelay + } + } + + // Read testcache expiration time, if present. + // (We implement go clean -testcache by writing an expiration date + // instead of searching out and deleting test result cache entries.) + if dir, _, _ := cache.DefaultDir(); dir != "off" { + if data, _ := lockedfile.Read(filepath.Join(dir, "testexpire.txt")); len(data) > 0 && data[len(data)-1] == '\n' { + if t, err := strconv.ParseInt(string(data[:len(data)-1]), 10, 64); err == nil { + testCacheExpire = time.Unix(0, t) + } + } + } + + b := work.NewBuilder("", moduleLoaderState.VendorDirOrEmpty) + defer func() { + if err := b.Close(); err != nil { + base.Fatal(err) + } + }() + + var builds, runs, prints []*work.Action + var writeCoverMetaAct *work.Action + + if cfg.BuildCoverPkg != nil { + match := make([]func(*modload.State, *load.Package) bool, len(cfg.BuildCoverPkg)) + for i := range cfg.BuildCoverPkg { + match[i] = load.MatchPackage(cfg.BuildCoverPkg[i], base.Cwd()) + } + + // Select for coverage all dependencies matching the -coverpkg + // patterns. + plist := load.TestPackageList(moduleLoaderState, ctx, pkgOpts, pkgs) + testCoverPkgs = load.SelectCoverPackages(moduleLoaderState, plist, match, "test") + if len(testCoverPkgs) > 0 { + // create a new singleton action that will collect up the + // meta-data files from all of the packages mentioned in + // "-coverpkg" and write them to a summary file. This new + // action will depend on all the build actions for the + // test packages, and all the run actions for these + // packages will depend on it. Motivating example: + // supposed we have a top level directory with three + // package subdirs, "a", "b", and "c", and + // from the top level, a user runs "go test -coverpkg=./... ./...". + // This will result in (roughly) the following action graph: + // + // build("a") build("b") build("c") + // | | | + // link("a.test") link("b.test") link("c.test") + // | | | + // run("a.test") run("b.test") run("c.test") + // | | | + // print print print + // + // When -coverpkg= is in effect, we want to + // express the coverage percentage for each package as a + // fraction of *all* the statements that match the + // pattern, hence if "c" doesn't import "a", we need to + // pass as meta-data file for "a" (emitted during the + // package "a" build) to the package "c" run action, so + // that it can be incorporated with "c"'s regular + // metadata. To do this, we add edges from each compile + // action to a "writeCoverMeta" action, then from the + // writeCoverMeta action to each run action. Updated + // graph: + // + // build("a") build("b") build("c") + // | \ / | / | + // | v v | / | + // | writemeta <-|-------------+ | + // | ||| | | + // | ||\ | | + // link("a.test")/\ \ link("b.test") link("c.test") + // | / \ +-|--------------+ | + // | / \ | \ | + // | v v | v | + // run("a.test") run("b.test") run("c.test") + // | | | + // print print print + // + writeCoverMetaAct = &work.Action{ + Mode: "write coverage meta-data file", + Actor: work.ActorFunc(work.WriteCoverMetaFilesFile), + Objdir: b.NewObjdir(), + } + for _, p := range testCoverPkgs { + p.Internal.Cover.GenMeta = true + } + } + } + + // Inform the compiler that it should instrument the binary at + // build-time when fuzzing is enabled. + if testFuzz != "" { + // Don't instrument packages which may affect coverage guidance but are + // unlikely to be useful. Most of these are used by the testing or + // internal/fuzz packages concurrently with fuzzing. + var skipInstrumentation = map[string]bool{ + "context": true, + "internal/fuzz": true, + "internal/godebug": true, + "internal/runtime/maps": true, + "internal/sync": true, + "reflect": true, + "runtime": true, + "sync": true, + "sync/atomic": true, + "syscall": true, + "testing": true, + "time": true, + } + for _, p := range load.TestPackageList(moduleLoaderState, ctx, pkgOpts, pkgs) { + if !skipInstrumentation[p.ImportPath] { + p.Internal.FuzzInstrument = true + } + } + } + + // Collect all the packages imported by the packages being tested. + allImports := make(map[*load.Package]bool) + for _, p := range pkgs { + if p.Error != nil && p.Error.IsImportCycle { + continue + } + for _, p1 := range p.Internal.Imports { + allImports[p1] = true + } + } + + if cfg.BuildCover { + for _, p := range pkgs { + // sync/atomic import is inserted by the cover tool if + // we're using atomic mode (and not compiling + // sync/atomic package itself). See #18486 and #57445. + // Note that this needs to be done prior to any of the + // builderTest invocations below, due to the fact that + // a given package in the 'pkgs' list may import + // package Q which appears later in the list (if this + // happens we'll wind up building the Q compile action + // before updating its deps to include sync/atomic). + if cfg.BuildCoverMode == "atomic" && p.ImportPath != "sync/atomic" { + load.EnsureImport(moduleLoaderState, p, "sync/atomic") + } + // Tag the package for static meta-data generation if no + // test files (this works only with the new coverage + // design). Do this here (as opposed to in builderTest) so + // as to handle the case where we're testing multiple + // packages and one of the earlier packages imports a + // later package. Note that if -coverpkg is in effect + // p.Internal.Cover.GenMeta will wind up being set for + // all matching packages. + if len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 && cfg.BuildCoverPkg == nil { + p.Internal.Cover.GenMeta = true + } + + // Set coverage mode before building actions because it needs to be set + // before the first package build action for the package under test is + // created and cached, so that we can create the coverage action for it. + if cfg.BuildCover { + if p.Internal.Cover.GenMeta { + p.Internal.Cover.Mode = cfg.BuildCoverMode + } + } + } + } + + // Prepare build + run + print actions for all packages being tested. + for _, p := range pkgs { + reportErr := func(perr *load.Package, err error) { + str := err.Error() + if p.ImportPath != "" { + load.DefaultPrinter().Errorf(perr, "# %s\n%s", p.ImportPath, str) + } else { + load.DefaultPrinter().Errorf(perr, "%s", str) + } + } + reportSetupFailed := func(perr *load.Package, err error) { + var stdout io.Writer = os.Stdout + if testJSON { + json := test2json.NewConverter(stdout, p.ImportPath, test2json.Timestamp) + defer func() { + json.Exited(err) + json.Close() + }() + if gotestjsonbuildtext.Value() == "1" { + // While this flag is about go build -json, the other effect + // of that change was to include "FailedBuild" in the test JSON. + gotestjsonbuildtext.IncNonDefault() + } else { + json.SetFailedBuild(perr.Desc()) + } + stdout = json + } + fmt.Fprintf(stdout, "FAIL\t%s [setup failed]\n", p.ImportPath) + base.SetExitStatus(1) + } + + var firstErrPkg *load.Package // arbitrarily report setup failed error for first error pkg reached in DFS + load.PackageErrors([]*load.Package{p}, func(p *load.Package) { + reportErr(p, p.Error) + if firstErrPkg == nil { + firstErrPkg = p + } + }) + if firstErrPkg != nil { + reportSetupFailed(firstErrPkg, firstErrPkg.Error) + continue + } + buildTest, runTest, printTest, perr, err := builderTest(moduleLoaderState, b, ctx, pkgOpts, p, allImports[p], writeCoverMetaAct) + if err != nil { + reportErr(perr, err) + reportSetupFailed(perr, err) + continue + } + builds = append(builds, buildTest) + runs = append(runs, runTest) + prints = append(prints, printTest) + } + + // Order runs for coordinating start JSON prints via two mechanisms: + // 1. Channel locking forces runTest actions to start in-order. + // 2. Barrier tasks force runTest actions to be scheduled in-order. + // We need both for performant behavior, as channel locking without the barrier tasks starves the worker pool, + // and barrier tasks without channel locking doesn't guarantee start in-order behavior alone. + var prevBarrier *work.Action + ch := make(chan struct{}) + close(ch) + for _, a := range runs { + if r, ok := a.Actor.(*runTestActor); ok { + // Inject a barrier task between the run action and its dependencies. + // This barrier task wil also depend on the previous barrier task. + // This prevents the run task from being scheduled until all previous run dependencies have finished. + // The build graph will be augmented to look roughly like this: + // build("a") build("b") build("c") + // | | | + // barrier("a.test") -> barrier("b.test") -> barrier("c.test") + // | | | + // run("a.test") run("b.test") run("c.test") + + barrier := &work.Action{ + Mode: "test barrier", + Deps: slices.Clip(a.Deps), + } + if prevBarrier != nil { + barrier.Deps = append(barrier.Deps, prevBarrier) + } + a.Deps = []*work.Action{barrier} + prevBarrier = barrier + + r.prev = ch + ch = make(chan struct{}) + r.next = ch + } + } + + // Ultimately the goal is to print the output. + root := &work.Action{Mode: "go test", Actor: work.ActorFunc(printExitStatus), Deps: prints} + + // Force the printing of results to happen in order, + // one at a time. + for i, a := range prints { + if i > 0 { + a.Deps = append(a.Deps, prints[i-1]) + } + } + + // Force benchmarks to run in serial. + if !testC && (testBench != "") { + // The first run must wait for all builds. + // Later runs must wait for the previous run's print. + for i, run := range runs { + if i == 0 { + run.Deps = append(run.Deps, builds...) + } else { + run.Deps = append(run.Deps, prints[i-1]) + } + } + } + + b.Do(ctx, root) +} + +var windowsBadWords = []string{ + "install", + "patch", + "setup", + "update", +} + +func builderTest(loaderstate *modload.State, b *work.Builder, ctx context.Context, pkgOpts load.PackageOpts, p *load.Package, imported bool, writeCoverMetaAct *work.Action) (buildAction, runAction, printAction *work.Action, perr *load.Package, err error) { + if len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 { + build := b.CompileAction(work.ModeBuild, work.ModeBuild, p) + run := &work.Action{ + Mode: "test run", + Actor: new(runTestActor), + Deps: []*work.Action{build}, + Objdir: b.NewObjdir(), + Package: p, + IgnoreFail: true, // run (prepare output) even if build failed + } + if writeCoverMetaAct != nil && build.Actor != nil { + // There is no real "run" for this package (since there + // are no tests), but if coverage is turned on, we can + // collect coverage data for the code in the package by + // asking cmd/cover for a static meta-data file as part of + // the package build. This static meta-data file is then + // consumed by a pseudo-action (writeCoverMetaAct) that + // adds it to a summary file, then this summary file is + // consumed by the various "run test" actions. Below we + // add a dependence edge between the build action and the + // "write meta files" pseudo-action, and then another dep + // from writeCoverMetaAct to the run action. See the + // comment in runTest() at the definition of + // writeCoverMetaAct for more details. + run.Deps = append(run.Deps, writeCoverMetaAct) + writeCoverMetaAct.Deps = append(writeCoverMetaAct.Deps, build) + } + addTestVet(loaderstate, b, p, run, nil) + print := &work.Action{ + Mode: "test print", + Actor: work.ActorFunc(builderPrintTest), + Deps: []*work.Action{run}, + Package: p, + IgnoreFail: true, // print even if test failed + } + return build, run, print, nil, nil + } + + // Build Package structs describing: + // pmain - pkg.test binary + // ptest - package + test files + // pxtest - package of external test files + var cover *load.TestCover + if cfg.BuildCover { + cover = &load.TestCover{ + Mode: cfg.BuildCoverMode, + Local: cfg.BuildCoverPkg == nil, + Pkgs: testCoverPkgs, + Paths: cfg.BuildCoverPkg, + } + } + pmain, ptest, pxtest, perr := load.TestPackagesFor(loaderstate, ctx, pkgOpts, p, cover) + if perr != nil { + return nil, nil, nil, perr, perr.Error + } + + // If imported is true then this package is imported by some + // package being tested. Make building the test version of the + // package depend on building the non-test version, so that we + // only report build errors once. Issue #44624. + if imported && ptest != p { + buildTest := b.CompileAction(work.ModeBuild, work.ModeBuild, ptest) + buildP := b.CompileAction(work.ModeBuild, work.ModeBuild, p) + buildTest.Deps = append(buildTest.Deps, buildP) + } + + testBinary := testBinaryName(p) + + // Set testdir to compile action's objdir. + // so that the default file path stripping applies to _testmain.go. + testDir := b.CompileAction(work.ModeBuild, work.ModeBuild, pmain).Objdir + if err := b.BackgroundShell().Mkdir(testDir); err != nil { + return nil, nil, nil, nil, err + } + + pmain.Dir = testDir + pmain.Internal.OmitDebug = !testC && !testNeedBinary() + if pmain.ImportPath == "runtime.test" { + // The runtime package needs a symbolized binary for its tests. + // See runtime/unsafepoint_test.go. + pmain.Internal.OmitDebug = false + } + + if !cfg.BuildN { + // writeTestmain writes _testmain.go, + // using the test description gathered in t. + if err := os.WriteFile(testDir+"_testmain.go", *pmain.Internal.TestmainGo, 0666); err != nil { + return nil, nil, nil, nil, err + } + } + + a := b.LinkAction(loaderstate, work.ModeBuild, work.ModeBuild, pmain) + a.Target = testDir + testBinary + cfg.ExeSuffix + if cfg.Goos == "windows" { + // There are many reserved words on Windows that, + // if used in the name of an executable, cause Windows + // to try to ask for extra permissions. + // The word list includes setup, install, update, and patch, + // but it does not appear to be defined anywhere. + // We have run into this trying to run the + // go.codereview/patch tests. + // For package names containing those words, use test.test.exe + // instead of pkgname.test.exe. + // Note that this file name is only used in the Go command's + // temporary directory. If the -c or other flags are + // given, the code below will still use pkgname.test.exe. + // There are two user-visible effects of this change. + // First, you can actually run 'go test' in directories that + // have names that Windows thinks are installer-like, + // without getting a dialog box asking for more permissions. + // Second, in the Windows process listing during go test, + // the test shows up as test.test.exe, not pkgname.test.exe. + // That second one is a drawback, but it seems a small + // price to pay for the test running at all. + // If maintaining the list of bad words is too onerous, + // we could just do this always on Windows. + for _, bad := range windowsBadWords { + if strings.Contains(testBinary, bad) { + a.Target = testDir + "test.test" + cfg.ExeSuffix + break + } + } + } + buildAction = a + var installAction, cleanAction *work.Action + if testC || testNeedBinary() { + // -c or profiling flag: create action to copy binary to ./test.out. + target := filepath.Join(base.Cwd(), testBinary+cfg.ExeSuffix) + isNull := false + + if testO != "" { + target = testO + + if testODir { + if filepath.IsAbs(target) { + target = filepath.Join(target, testBinary+cfg.ExeSuffix) + } else { + target = filepath.Join(base.Cwd(), target, testBinary+cfg.ExeSuffix) + } + } else { + if base.IsNull(target) { + isNull = true + } else if !filepath.IsAbs(target) { + target = filepath.Join(base.Cwd(), target) + } + } + } + + if isNull { + runAction = buildAction + } else { + pmain.Target = target + installAction = &work.Action{ + Mode: "test build", + Actor: work.ActorFunc(work.BuildInstallFunc), + Deps: []*work.Action{buildAction}, + Package: pmain, + Target: target, + } + runAction = installAction // make sure runAction != nil even if not running test + } + } + + var vetRunAction *work.Action + if testC { + printAction = &work.Action{Mode: "test print (nop)", Package: p, Deps: []*work.Action{runAction}} // nop + vetRunAction = printAction + } else { + // run test + rta := &runTestActor{ + writeCoverMetaAct: writeCoverMetaAct, + } + runAction = &work.Action{ + Mode: "test run", + Actor: rta, + Deps: []*work.Action{buildAction}, + Package: p, + IgnoreFail: true, // run (prepare output) even if build failed + TryCache: rta.c.tryCache, + } + if writeCoverMetaAct != nil { + // If writeCoverMetaAct != nil, this indicates that our + // "go test -coverpkg" run actions will need to read the + // meta-files summary file written by writeCoverMetaAct, + // so add a dependence edge from writeCoverMetaAct to the + // run action. + runAction.Deps = append(runAction.Deps, writeCoverMetaAct) + if !p.IsTestOnly() { + // Package p is not test only, meaning that the build + // action for p may generate a static meta-data file. + // Add a dependence edge from p to writeCoverMetaAct, + // which needs to know the name of that meta-data + // file. + compileAction := b.CompileAction(work.ModeBuild, work.ModeBuild, p) + writeCoverMetaAct.Deps = append(writeCoverMetaAct.Deps, compileAction) + } + } + runAction.Objdir = testDir + vetRunAction = runAction + cleanAction = &work.Action{ + Mode: "test clean", + Actor: work.ActorFunc(builderCleanTest), + Deps: []*work.Action{runAction}, + Package: p, + IgnoreFail: true, // clean even if test failed + Objdir: testDir, + } + printAction = &work.Action{ + Mode: "test print", + Actor: work.ActorFunc(builderPrintTest), + Deps: []*work.Action{cleanAction}, + Package: p, + IgnoreFail: true, // print even if test failed + } + } + + if len(ptest.GoFiles)+len(ptest.CgoFiles) > 0 { + addTestVet(loaderstate, b, ptest, vetRunAction, installAction) + } + if pxtest != nil { + addTestVet(loaderstate, b, pxtest, vetRunAction, installAction) + } + + if installAction != nil { + if runAction != installAction { + installAction.Deps = append(installAction.Deps, runAction) + } + if cleanAction != nil { + cleanAction.Deps = append(cleanAction.Deps, installAction) + } + } + + return buildAction, runAction, printAction, nil, nil +} + +func addTestVet(loaderstate *modload.State, b *work.Builder, p *load.Package, runAction, installAction *work.Action) { + if testVet.off { + return + } + + vet := b.VetAction(loaderstate, work.ModeBuild, work.ModeBuild, false, p) + runAction.Deps = append(runAction.Deps, vet) + // Install will clean the build directory. + // Make sure vet runs first. + // The install ordering in b.VetAction does not apply here + // because we are using a custom installAction (created above). + if installAction != nil { + installAction.Deps = append(installAction.Deps, vet) + } +} + +var noTestsToRun = []byte("\ntesting: warning: no tests to run\n") +var noFuzzTestsToFuzz = []byte("\ntesting: warning: no fuzz tests to fuzz\n") +var tooManyFuzzTestsToFuzz = []byte("\ntesting: warning: -fuzz matches more than one fuzz test, won't fuzz\n") + +// runTestActor is the actor for running a test. +type runTestActor struct { + c runCache + + // writeCoverMetaAct points to the pseudo-action for collecting + // coverage meta-data files for selected -cover test runs. See the + // comment in runTest at the definition of writeCoverMetaAct for + // more details. + writeCoverMetaAct *work.Action + + // sequencing of json start messages, to preserve test order + prev <-chan struct{} // wait to start until prev is closed + next chan<- struct{} // close next once the next test can start. +} + +// runCache is the cache for running a single test. +type runCache struct { + disableCache bool // cache should be disabled for this run + + buf *bytes.Buffer + id1 cache.ActionID + id2 cache.ActionID + covMeta cache.ActionID // Hash of writeCoverMetaAct dependencies, for invalidating coverage profiles +} + +func coverProfTempFile(a *work.Action) string { + if a.Objdir == "" { + panic("internal error: objdir not set in coverProfTempFile") + } + return a.Objdir + "_cover_.out" +} + +// stdoutMu and lockedStdout provide a locked standard output +// that guarantees never to interlace writes from multiple +// goroutines, so that we can have multiple JSON streams writing +// to a lockedStdout simultaneously and know that events will +// still be intelligible. +var stdoutMu sync.Mutex + +type lockedStdout struct{} + +func (lockedStdout) Write(b []byte) (int, error) { + stdoutMu.Lock() + defer stdoutMu.Unlock() + return os.Stdout.Write(b) +} + +func (r *runTestActor) Act(b *work.Builder, ctx context.Context, a *work.Action) error { + sh := b.Shell(a) + barrierAction := a.Deps[0] + buildAction := barrierAction.Deps[0] + + // Wait for previous test to get started and print its first json line. + select { + case <-r.prev: + // If should fail fast then release next test and exit. + if testShouldFailFast.Load() { + close(r.next) + return nil + } + case <-base.Interrupted: + // We can't wait for the previous test action to complete: we don't start + // new actions after an interrupt, so if that action wasn't already running + // it might never happen. Instead, just don't log anything for this action. + base.SetExitStatus(1) + return nil + } + + // Stream test output (no buffering) when no package has + // been given on the command line (implicit current directory) + // or when benchmarking or fuzzing. + streamOutput := len(pkgArgs) == 0 || testBench != "" || testFuzz != "" + + // If we're only running a single package under test or if parallelism is + // set to 1, and if we're displaying all output (testShowPass), we can + // hurry the output along, echoing it as soon as it comes in. + // We still have to copy to &buf for caching the result. This special + // case was introduced in Go 1.5 and is intentionally undocumented: + // the exact details of output buffering are up to the go command and + // subject to change. It would be nice to remove this special case + // entirely, but it is surely very helpful to see progress being made + // when tests are run on slow single-CPU ARM systems. + // + // If we're showing JSON output, then display output as soon as + // possible even when multiple tests are being run: the JSON output + // events are attributed to specific package tests, so interlacing them + // is OK. + streamAndCacheOutput := testShowPass() && (len(pkgs) == 1 || cfg.BuildP == 1) || testJSON + + var stdout io.Writer = os.Stdout + var err error + var json *test2json.Converter + if testJSON { + json = test2json.NewConverter(lockedStdout{}, a.Package.ImportPath, test2json.Timestamp) + defer func() { + json.Exited(err) + json.Close() + }() + stdout = json + } + + var buf bytes.Buffer + if streamOutput { + // No change to stdout. + } else if streamAndCacheOutput { + // Write both to stdout and buf, for possible saving + // to cache, and for looking for the "no tests to run" message. + stdout = io.MultiWriter(stdout, &buf) + } else { + stdout = &buf + } + + // Release next test to start (test2json.NewConverter writes the start event). + close(r.next) + + if a.Failed != nil { + // We were unable to build the binary. + if json != nil && a.Failed.Package != nil { + if gotestjsonbuildtext.Value() == "1" { + gotestjsonbuildtext.IncNonDefault() + } else { + json.SetFailedBuild(a.Failed.Package.Desc()) + } + } + a.Failed = nil + fmt.Fprintf(stdout, "FAIL\t%s [build failed]\n", a.Package.ImportPath) + // Tell the JSON converter that this was a failure, not a passing run. + err = errors.New("build failed") + base.SetExitStatus(1) + if stdout == &buf { + a.TestOutput = &buf + } + return nil + } + + if p := a.Package; len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 { + reportNoTestFiles := true + if cfg.BuildCover && p.Internal.Cover.GenMeta { + if err := sh.Mkdir(a.Objdir); err != nil { + return err + } + mf, err := work.BuildActionCoverMetaFile(a) + if err != nil { + return err + } else if mf != "" { + reportNoTestFiles = false + // Write out "percent statements covered". + if err := work.WriteCoveragePercent(b, a, mf, stdout); err != nil { + return err + } + // If -coverprofile is in effect, then generate a + // coverage profile fragment for this package and + // merge it with the final -coverprofile output file. + if coverMerge.f != nil { + cp := coverProfTempFile(a) + if err := work.WriteCoverageProfile(b, a, mf, cp, stdout); err != nil { + return err + } + mergeCoverProfile(cp) + } + } + } + if reportNoTestFiles { + fmt.Fprintf(stdout, "? \t%s\t[no test files]\n", p.ImportPath) + } + if stdout == &buf { + a.TestOutput = &buf + } + return nil + } + + if r.c.buf == nil { + // We did not find a cached result using the link step action ID, + // so we ran the link step. Try again now with the link output + // content ID. The attempt using the action ID makes sure that + // if the link inputs don't change, we reuse the cached test + // result without even rerunning the linker. The attempt using + // the link output (test binary) content ID makes sure that if + // we have different link inputs but the same final binary, + // we still reuse the cached test result. + // c.saveOutput will store the result under both IDs. + r.c.tryCacheWithID(b, a, buildAction.BuildContentID()) + } + if r.c.buf != nil { + if stdout != &buf { + stdout.Write(r.c.buf.Bytes()) + r.c.buf.Reset() + } + a.TestOutput = r.c.buf + return nil + } + + execCmd := work.FindExecCmd() + testlogArg := []string{} + if !r.c.disableCache && len(execCmd) == 0 { + testlogArg = []string{"-test.testlogfile=" + a.Objdir + "testlog.txt"} + } + panicArg := "-test.paniconexit0" + fuzzArg := []string{} + if testFuzz != "" { + fuzzCacheDir := filepath.Join(cache.Default().FuzzDir(), a.Package.ImportPath) + fuzzArg = []string{"-test.fuzzcachedir=" + fuzzCacheDir} + } + coverdirArg := []string{} + addToEnv := "" + if cfg.BuildCover { + gcd := filepath.Join(a.Objdir, "gocoverdir") + if err := sh.Mkdir(gcd); err != nil { + // If we can't create a temp dir, terminate immediately + // with an error as opposed to returning an error to the + // caller; failed MkDir most likely indicates that we're + // out of disk space or there is some other systemic error + // that will make forward progress unlikely. + base.Fatalf("failed to create temporary dir: %v", err) + } + coverdirArg = append(coverdirArg, "-test.gocoverdir="+gcd) + if r.writeCoverMetaAct != nil { + // Copy the meta-files file over into the test's coverdir + // directory so that the coverage runtime support will be + // able to find it. + src := r.writeCoverMetaAct.Objdir + coverage.MetaFilesFileName + dst := filepath.Join(gcd, coverage.MetaFilesFileName) + if err := sh.CopyFile(dst, src, 0666, false); err != nil { + return err + } + } + // Even though we are passing the -test.gocoverdir option to + // the test binary, also set GOCOVERDIR as well. This is + // intended to help with tests that run "go build" to build + // fresh copies of tools to test as part of the testing. + addToEnv = "GOCOVERDIR=" + gcd + } + args := str.StringList(execCmd, buildAction.BuiltTarget(), testlogArg, panicArg, fuzzArg, coverdirArg, testArgs) + + if testCoverProfile != "" { + // Write coverage to temporary profile, for merging later. + for i, arg := range args { + if strings.HasPrefix(arg, "-test.coverprofile=") { + args[i] = "-test.coverprofile=" + coverProfTempFile(a) + } + } + } + + if cfg.BuildN || cfg.BuildX { + sh.ShowCmd("", "%s", strings.Join(args, " ")) + if cfg.BuildN { + return nil + } + } + + // Normally, the test will terminate itself when the timeout expires, + // but add a last-ditch deadline to detect and stop wedged binaries. + ctx, cancel := context.WithTimeout(ctx, testKillTimeout) + defer cancel() + + // Now we're ready to actually run the command. + // + // If the -o flag is set, or if at some point we change cmd/go to start + // copying test executables into the build cache, we may run into spurious + // ETXTBSY errors on Unix platforms (see https://go.dev/issue/22315). + // + // Since we know what causes those, and we know that they should resolve + // quickly (the ETXTBSY error will resolve as soon as the subprocess + // holding the descriptor open reaches its 'exec' call), we retry them + // in a loop. + + var ( + cmd *exec.Cmd + t0 time.Time + cancelKilled = false + cancelSignaled = false + ) + for { + cmd = exec.CommandContext(ctx, args[0], args[1:]...) + cmd.Dir = a.Package.Dir + + env := slices.Clip(cfg.OrigEnv) + env = base.AppendPATH(env) + env = base.AppendPWD(env, cmd.Dir) + cmd.Env = env + if addToEnv != "" { + cmd.Env = append(cmd.Env, addToEnv) + } + + cmd.Stdout = stdout + cmd.Stderr = stdout + + cmd.Cancel = func() error { + if base.SignalTrace == nil { + err := cmd.Process.Kill() + if err == nil { + cancelKilled = true + } + return err + } + + // Send a quit signal in the hope that the program will print + // a stack trace and exit. + err := cmd.Process.Signal(base.SignalTrace) + if err == nil { + cancelSignaled = true + } + return err + } + cmd.WaitDelay = testWaitDelay + + base.StartSigHandlers() + t0 = time.Now() + err = cmd.Run() + + if !base.IsETXTBSY(err) { + // We didn't hit the race in #22315, so there is no reason to retry the + // command. + break + } + } + + out := buf.Bytes() + a.TestOutput = &buf + t := fmt.Sprintf("%.3fs", time.Since(t0).Seconds()) + + mergeCoverProfile(coverProfTempFile(a)) + + if err == nil { + norun := "" + if !testShowPass() && !testJSON { + buf.Reset() + } + if bytes.HasPrefix(out, noTestsToRun[1:]) || bytes.Contains(out, noTestsToRun) { + norun = " [no tests to run]" + } + if bytes.HasPrefix(out, noFuzzTestsToFuzz[1:]) || bytes.Contains(out, noFuzzTestsToFuzz) { + norun = " [no fuzz tests to fuzz]" + } + if bytes.HasPrefix(out, tooManyFuzzTestsToFuzz[1:]) || bytes.Contains(out, tooManyFuzzTestsToFuzz) { + norun = "[-fuzz matches more than one fuzz test, won't fuzz]" + } + if len(out) > 0 && !bytes.HasSuffix(out, []byte("\n")) { + // Ensure that the output ends with a newline before the "ok" + // line we're about to print (https://golang.org/issue/49317). + cmd.Stdout.Write([]byte("\n")) + } + fmt.Fprintf(cmd.Stdout, "ok \t%s\t%s%s%s\n", a.Package.ImportPath, t, coveragePercentage(out), norun) + r.c.saveOutput(a) + } else { + if testFailFast { + testShouldFailFast.Store(true) + } + + base.SetExitStatus(1) + if cancelSignaled { + fmt.Fprintf(cmd.Stdout, "*** Test killed with %v: ran too long (%v).\n", base.SignalTrace, testKillTimeout) + } else if cancelKilled { + fmt.Fprintf(cmd.Stdout, "*** Test killed: ran too long (%v).\n", testKillTimeout) + } else if errors.Is(err, exec.ErrWaitDelay) { + fmt.Fprintf(cmd.Stdout, "*** Test I/O incomplete %v after exiting.\n", cmd.WaitDelay) + } + if ee, ok := errors.AsType[*exec.ExitError](err); !ok || !ee.Exited() || len(out) == 0 { + // If there was no test output, print the exit status so that the reason + // for failure is clear. + fmt.Fprintf(cmd.Stdout, "%s\n", err) + } else if !bytes.HasSuffix(out, []byte("\n")) { + // Otherwise, ensure that the output ends with a newline before the FAIL + // line we're about to print (https://golang.org/issue/49317). + cmd.Stdout.Write([]byte("\n")) + } + + // NOTE(golang.org/issue/37555): test2json reports that a test passes + // unless "FAIL" is printed at the beginning of a line. The test may not + // actually print that if it panics, exits, or terminates abnormally, + // so we print it here. We can't always check whether it was printed + // because some tests need stdout to be a terminal (golang.org/issue/34791), + // not a pipe. + // TODO(golang.org/issue/29062): tests that exit with status 0 without + // printing a final result should fail. + prefix := "" + if testJSON || testV.json { + prefix = "\x16" + } + fmt.Fprintf(cmd.Stdout, "%sFAIL\t%s\t%s\n", prefix, a.Package.ImportPath, t) + } + + if cmd.Stdout != &buf { + buf.Reset() // cmd.Stdout was going to os.Stdout already + } + return nil +} + +// tryCache is called just before the link attempt, +// to see if the test result is cached and therefore the link is unneeded. +// It reports whether the result can be satisfied from cache. +func (c *runCache) tryCache(b *work.Builder, a *work.Action, linkAction *work.Action) bool { + return c.tryCacheWithID(b, a, linkAction.BuildActionID()) +} + +func (c *runCache) tryCacheWithID(b *work.Builder, a *work.Action, id string) bool { + if len(pkgArgs) == 0 { + // Caching does not apply to "go test", + // only to "go test foo" (including "go test ."). + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: caching disabled in local directory mode\n") + } + c.disableCache = true + return false + } + + if a.Package.Root == "" { + // Caching does not apply to tests outside of any module, GOPATH, or GOROOT. + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: caching disabled for package outside of module root, GOPATH, or GOROOT: %s\n", a.Package.ImportPath) + } + c.disableCache = true + return false + } + + // If we are collecting coverage for out-of-band packages (-coverpkg), + // find the writeCoverMetaAct among the run action's dependencies and hash + // its deps to ensure the cache invalidates when covered packages change. + // Note: the run action's original deps may be wrapped inside a "test barrier" + // action, so we search both a.Deps and any barrier's deps. + if len(testCoverPkgs) != 0 { + searchDeps := a.Deps + for _, dep := range a.Deps { + if dep.Mode == "test barrier" { + searchDeps = dep.Deps + break + } + } + for _, dep := range searchDeps { + if dep.Mode == "write coverage meta-data file" { + h := cache.NewHash("covermeta") + for _, metaDep := range dep.Deps { + if aid := metaDep.BuildActionID(); aid != "" { + fmt.Fprintf(h, "dep %s\n", aid) + } + } + c.covMeta = h.Sum() + break + } + } + } + + var cacheArgs []string + for _, arg := range testArgs { + i := strings.Index(arg, "=") + if i < 0 || !strings.HasPrefix(arg, "-test.") { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: caching disabled for test argument: %s\n", arg) + } + c.disableCache = true + return false + } + switch arg[:i] { + case "-test.benchtime", + "-test.cpu", + "-test.list", + "-test.parallel", + "-test.run", + "-test.short", + "-test.skip", + "-test.timeout", + "-test.failfast", + "-test.v", + "-test.fullpath": + // These are cacheable. + // Note that this list is documented above, + // so if you add to this list, update the docs too. + cacheArgs = append(cacheArgs, arg) + case "-test.coverprofile", + "-test.outputdir": + // These are cacheable and do not invalidate the cache when they change. + // Note that this list is documented above, + // so if you add to this list, update the docs too. + default: + // nothing else is cacheable + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: caching disabled for test argument: %s\n", arg) + } + c.disableCache = true + return false + } + } + + // The test cache result fetch is a two-level lookup. + // + // First, we use the content hash of the test binary + // and its command-line arguments to find the + // list of environment variables and files consulted + // the last time the test was run with those arguments. + // (To avoid unnecessary links, we store this entry + // under two hashes: id1 uses the linker inputs as a + // proxy for the test binary, and id2 uses the actual + // test binary. If the linker inputs are unchanged, + // this way we avoid the link step, even though we + // do not cache link outputs.) + // + // Second, we compute a hash of the values of the + // environment variables and the content of the files + // listed in the log from the previous run. + // Then we look up test output using a combination of + // the hash from the first part (testID) and the hash of the + // test inputs (testInputsID). + // + // In order to store a new test result, we must redo the + // testInputsID computation using the log from the run + // we want to cache, and then we store that new log and + // the new outputs. + + h := cache.NewHash("testResult") + fmt.Fprintf(h, "test binary %s args %q execcmd %q", id, cacheArgs, work.ExecCmd) + testID := h.Sum() + if c.id1 == (cache.ActionID{}) { + c.id1 = testID + } else { + c.id2 = testID + } + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: test ID %x => %x\n", a.Package.ImportPath, id, testID) + } + + // Load list of referenced environment variables and files + // from last run of testID, and compute hash of that content. + data, entry, err := cache.GetBytes(cache.Default(), testID) + if !bytes.HasPrefix(data, testlogMagic) || data[len(data)-1] != '\n' { + if cache.DebugTest { + if err != nil { + fmt.Fprintf(os.Stderr, "testcache: %s: input list not found: %v\n", a.Package.ImportPath, err) + } else { + fmt.Fprintf(os.Stderr, "testcache: %s: input list malformed\n", a.Package.ImportPath) + } + } + return false + } + testInputsID, err := computeTestInputsID(a, data) + if err != nil { + return false + } + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: test ID %x => input ID %x => %x\n", a.Package.ImportPath, testID, testInputsID, testAndInputKey(testID, testInputsID)) + } + + // Parse cached result in preparation for changing run time to "(cached)". + // If we can't parse the cached result, don't use it. + data, entry, err = cache.GetBytes(cache.Default(), testAndInputKey(testID, testInputsID)) + + // Merge cached cover profile data to cover profile. + if testCoverProfile != "" { + // Specifically ignore entry as it will be the same as above. + cpData, _, err := cache.GetFile(cache.Default(), coverProfileAndInputKey(testID, testInputsID, c.covMeta)) + if err != nil { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: cached cover profile missing: %v\n", a.Package.ImportPath, err) + } + return false + } + mergeCoverProfile(cpData) + } else if c.covMeta != (cache.ActionID{}) { + // If we have a coverage metadata hash but no testCoverProfile, we're collecting + // coverage for out-of-band packages. Check if the coverage profile cache is still + // valid. If c.covMeta changed (meaning a covered package changed), the coverage + // profile cache will miss and we need to re-run the test. + _, _, err := cache.GetFile(cache.Default(), coverProfileAndInputKey(testID, testInputsID, c.covMeta)) + if err != nil { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: coverage metadata changed, re-running test: %v\n", a.Package.ImportPath, err) + } + return false + } + } + + if len(data) == 0 || data[len(data)-1] != '\n' { + if cache.DebugTest { + if err != nil { + fmt.Fprintf(os.Stderr, "testcache: %s: test output not found: %v\n", a.Package.ImportPath, err) + } else { + fmt.Fprintf(os.Stderr, "testcache: %s: test output malformed\n", a.Package.ImportPath) + } + } + return false + } + if entry.Time.Before(testCacheExpire) { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: test output expired due to go clean -testcache\n", a.Package.ImportPath) + } + return false + } + i := bytes.LastIndexByte(data[:len(data)-1], '\n') + 1 + if !bytes.HasPrefix(data[i:], []byte("ok \t")) { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: test output malformed\n", a.Package.ImportPath) + } + return false + } + j := bytes.IndexByte(data[i+len("ok \t"):], '\t') + if j < 0 { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: test output malformed\n", a.Package.ImportPath) + } + return false + } + j += i + len("ok \t") + 1 + + // Committed to printing. + c.buf = new(bytes.Buffer) + c.buf.Write(data[:j]) + c.buf.WriteString("(cached)") + for j < len(data) && ('0' <= data[j] && data[j] <= '9' || data[j] == '.' || data[j] == 's') { + j++ + } + c.buf.Write(data[j:]) + return true +} + +var errBadTestInputs = errors.New("error parsing test inputs") +var testlogMagic = []byte("# test log\n") // known to testing/internal/testdeps/deps.go + +// computeTestInputsID computes the "test inputs ID" +// (see comment in tryCacheWithID above) for the +// test log. +func computeTestInputsID(a *work.Action, testlog []byte) (cache.ActionID, error) { + testlog = bytes.TrimPrefix(testlog, testlogMagic) + h := cache.NewHash("testInputs") + // The runtime always looks at GODEBUG, without telling us in the testlog. + fmt.Fprintf(h, "env GODEBUG %x\n", hashGetenv("GODEBUG")) + pwd := a.Package.Dir + for _, line := range bytes.Split(testlog, []byte("\n")) { + if len(line) == 0 { + continue + } + s := string(line) + op, name, found := strings.Cut(s, " ") + if !found { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: input list malformed (%q)\n", a.Package.ImportPath, line) + } + return cache.ActionID{}, errBadTestInputs + } + switch op { + default: + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: input list malformed (%q)\n", a.Package.ImportPath, line) + } + return cache.ActionID{}, errBadTestInputs + case "getenv": + fmt.Fprintf(h, "env %s %x\n", name, hashGetenv(name)) + case "chdir": + pwd = name // always absolute + fmt.Fprintf(h, "chdir %s %x\n", name, hashStat(name)) + case "stat": + if !filepath.IsAbs(name) { + name = filepath.Join(pwd, name) + } + if a.Package.Root == "" || search.InDir(name, a.Package.Root) == "" { + // Do not recheck files outside the module, GOPATH, or GOROOT root. + break + } + fmt.Fprintf(h, "stat %s %x\n", name, hashStat(name)) + case "open": + if !filepath.IsAbs(name) { + name = filepath.Join(pwd, name) + } + if a.Package.Root == "" || search.InDir(name, a.Package.Root) == "" { + // Do not recheck files outside the module, GOPATH, or GOROOT root. + break + } + fh, err := hashOpen(name) + if err != nil { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: input file %s: %s\n", a.Package.ImportPath, name, err) + } + return cache.ActionID{}, err + } + fmt.Fprintf(h, "open %s %x\n", name, fh) + } + } + sum := h.Sum() + return sum, nil +} + +func hashGetenv(name string) cache.ActionID { + h := cache.NewHash("getenv") + v, ok := os.LookupEnv(name) + if !ok { + h.Write([]byte{0}) + } else { + h.Write([]byte{1}) + h.Write([]byte(v)) + } + return h.Sum() +} + +const modTimeCutoff = 2 * time.Second + +var errFileTooNew = errors.New("file used as input is too new") + +func hashOpen(name string) (cache.ActionID, error) { + h := cache.NewHash("open") + info, err := os.Stat(name) + if err != nil { + fmt.Fprintf(h, "err %v\n", err) + return h.Sum(), nil + } + hashWriteStat(h, info) + if info.IsDir() { + files, err := os.ReadDir(name) + if err != nil { + fmt.Fprintf(h, "err %v\n", err) + } + for _, f := range files { + fmt.Fprintf(h, "file %s ", f.Name()) + finfo, err := f.Info() + if err != nil { + fmt.Fprintf(h, "err %v\n", err) + } else { + hashWriteStat(h, finfo) + } + } + } else if info.Mode().IsRegular() { + // Because files might be very large, do not attempt + // to hash the entirety of their content. Instead assume + // the mtime and size recorded in hashWriteStat above + // are good enough. + // + // To avoid problems for very recent files where a new + // write might not change the mtime due to file system + // mtime precision, reject caching if a file was read that + // is less than modTimeCutoff old. + if time.Since(info.ModTime()) < modTimeCutoff { + return cache.ActionID{}, errFileTooNew + } + } + return h.Sum(), nil +} + +func hashStat(name string) cache.ActionID { + h := cache.NewHash("stat") + if info, err := os.Stat(name); err != nil { + fmt.Fprintf(h, "err %v\n", err) + } else { + hashWriteStat(h, info) + } + if info, err := os.Lstat(name); err != nil { + fmt.Fprintf(h, "err %v\n", err) + } else { + hashWriteStat(h, info) + } + return h.Sum() +} + +func hashWriteStat(h io.Writer, info fs.FileInfo) { + fmt.Fprintf(h, "stat %d %x %v %v\n", info.Size(), uint64(info.Mode()), info.ModTime(), info.IsDir()) +} + +// testAndInputKey returns the actual cache key for the pair (testID, testInputsID). +func testAndInputKey(testID, testInputsID cache.ActionID) cache.ActionID { + return cache.Subkey(testID, fmt.Sprintf("inputs:%x", testInputsID)) +} + +// coverProfileAndInputKey returns the "coverprofile" cache key. +// If covMetaID is non-zero, it is included in the hash to ensure coverage profiles are invalidated +// when the coverage metadata changes (e.g., when source files in covered packages are modified). +func coverProfileAndInputKey(testID, testInputsID, covMetaID cache.ActionID) cache.ActionID { + key := testAndInputKey(testID, testInputsID) + if covMetaID != (cache.ActionID{}) { + key = cache.Subkey(key, fmt.Sprintf("coverdeps:%x", covMetaID)) + } + return cache.Subkey(key, "coverprofile") +} + +func (c *runCache) saveOutput(a *work.Action) { + if c.id1 == (cache.ActionID{}) && c.id2 == (cache.ActionID{}) { + return + } + + // See comment about two-level lookup in tryCacheWithID above. + testlog, err := os.ReadFile(a.Objdir + "testlog.txt") + if err != nil || !bytes.HasPrefix(testlog, testlogMagic) || testlog[len(testlog)-1] != '\n' { + if cache.DebugTest { + if err != nil { + fmt.Fprintf(os.Stderr, "testcache: %s: reading testlog: %v\n", a.Package.ImportPath, err) + } else { + fmt.Fprintf(os.Stderr, "testcache: %s: reading testlog: malformed\n", a.Package.ImportPath) + } + } + return + } + testInputsID, err := computeTestInputsID(a, testlog) + if err != nil { + return + } + var coverProfile []byte + if testCoverProfile != "" { + coverProfile, err = os.ReadFile(coverProfTempFile(a)) + if err != nil { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: reading cover profile: %v\n", a.Package.ImportPath, err) + } + return + } + } + if c.id1 != (cache.ActionID{}) { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: save test ID %x => input ID %x => %x\n", a.Package.ImportPath, c.id1, testInputsID, testAndInputKey(c.id1, testInputsID)) + } + cache.PutNoVerify(cache.Default(), c.id1, bytes.NewReader(testlog)) + cache.PutNoVerify(cache.Default(), testAndInputKey(c.id1, testInputsID), bytes.NewReader(a.TestOutput.Bytes())) + if coverProfile != nil { + cache.PutNoVerify(cache.Default(), coverProfileAndInputKey(c.id1, testInputsID, c.covMeta), bytes.NewReader(coverProfile)) + } else if c.covMeta != (cache.ActionID{}) { + // Write a sentinel so the else-if branch in tryCacheWithID can verify + // that the covMeta hash has not changed since the last run. + cache.PutNoVerify(cache.Default(), coverProfileAndInputKey(c.id1, testInputsID, c.covMeta), bytes.NewReader(nil)) + } + } + if c.id2 != (cache.ActionID{}) { + if cache.DebugTest { + fmt.Fprintf(os.Stderr, "testcache: %s: save test ID %x => input ID %x => %x\n", a.Package.ImportPath, c.id2, testInputsID, testAndInputKey(c.id2, testInputsID)) + } + cache.PutNoVerify(cache.Default(), c.id2, bytes.NewReader(testlog)) + cache.PutNoVerify(cache.Default(), testAndInputKey(c.id2, testInputsID), bytes.NewReader(a.TestOutput.Bytes())) + if coverProfile != nil { + cache.PutNoVerify(cache.Default(), coverProfileAndInputKey(c.id2, testInputsID, c.covMeta), bytes.NewReader(coverProfile)) + } else if c.covMeta != (cache.ActionID{}) { + // Sentinel for covMeta validity; see comment in id1 block above. + cache.PutNoVerify(cache.Default(), coverProfileAndInputKey(c.id2, testInputsID, c.covMeta), bytes.NewReader(nil)) + } + } +} + +// coveragePercentage returns the coverage results (if enabled) for the +// test. It uncovers the data by scanning the output from the test run. +func coveragePercentage(out []byte) string { + if !cfg.BuildCover { + return "" + } + // The string looks like + // test coverage for encoding/binary: 79.9% of statements + // Extract the piece from the percentage to the end of the line. + re := regexp.MustCompile(`coverage: (.*)\n`) + matches := re.FindSubmatch(out) + if matches == nil { + // Probably running "go test -cover" not "go test -cover fmt". + // The coverage output will appear in the output directly. + return "" + } + return fmt.Sprintf("\tcoverage: %s", matches[1]) +} + +// builderCleanTest is the action for cleaning up after a test. +func builderCleanTest(b *work.Builder, ctx context.Context, a *work.Action) error { + if cfg.BuildWork { + return nil + } + b.Shell(a).RemoveAll(a.Objdir) + return nil +} + +// builderPrintTest is the action for printing a test result. +func builderPrintTest(b *work.Builder, ctx context.Context, a *work.Action) error { + run := a.Deps[0] + if run.Mode == "test clean" { + run = run.Deps[0] + } + if run.Mode != "test run" { + base.Fatalf("internal error: cannot find test run to print") + } + if run.TestOutput != nil { + os.Stdout.Write(run.TestOutput.Bytes()) + run.TestOutput = nil + } + return nil +} + +// printExitStatus is the action for printing the final exit status. +// If we are running multiple test targets, print a final "FAIL" +// in case a failure in an early package has already scrolled +// off of the user's terminal. +// (See https://golang.org/issue/30507#issuecomment-470593235.) +// +// In JSON mode, we need to maintain valid JSON output and +// we assume that the test output is being parsed by a tool +// anyway, so the failure will not be missed and would be +// awkward to try to wedge into the JSON stream. +// +// In fuzz mode, we only allow a single package for now +// (see CL 350156 and https://golang.org/issue/46312), +// so there is no possibility of scrolling off and no need +// to print the final status. +func printExitStatus(b *work.Builder, ctx context.Context, a *work.Action) error { + if !testJSON && testFuzz == "" && len(pkgArgs) != 0 { + if base.GetExitStatus() != 0 { + fmt.Println("FAIL") + return nil + } + } + return nil +} + +// testBinaryName can be used to create name for test binary executable. +// Use last element of import path, not package name. +// They differ when package name is "main". +// But if the import path is "command-line-arguments", +// like it is during 'go run', use the package name. +func testBinaryName(p *load.Package) string { + var elem string + if p.ImportPath == "command-line-arguments" { + elem = p.Name + } else { + elem = p.DefaultExecName() + } + + return elem + ".test" +} diff --git a/go/src/cmd/go/internal/test/testflag.go b/go/src/cmd/go/internal/test/testflag.go new file mode 100644 index 0000000000000000000000000000000000000000..d6891a1d0b955b8827f3aed5169112dcf7363740 --- /dev/null +++ b/go/src/cmd/go/internal/test/testflag.go @@ -0,0 +1,428 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package test + +import ( + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/cmdflag" + "cmd/go/internal/work" + "errors" + "flag" + "fmt" + "internal/godebug" + "os" + "path/filepath" + "strconv" + "strings" + "time" +) + +//go:generate go run ./genflags.go + +// The flag handling part of go test is large and distracting. +// We can't use (*flag.FlagSet).Parse because some of the flags from +// our command line are for us, and some are for the test binary, and +// some are for both. + +var gotestjsonbuildtext = godebug.New("gotestjsonbuildtext") + +func init() { + work.AddBuildFlags(CmdTest, work.OmitVFlag|work.OmitJSONFlag) + + cf := CmdTest.Flag + cf.BoolVar(&testC, "c", false, "") + cf.StringVar(&testO, "o", "", "") + work.AddCoverFlags(CmdTest, &testCoverProfile) + cf.Var((*base.StringsFlag)(&work.ExecCmd), "exec", "") + cf.BoolVar(&testJSON, "json", false, "") + cf.Var(&testVet, "vet", "") + + // Register flags to be forwarded to the test binary. We retain variables for + // some of them so that cmd/go knows what to do with the test output, or knows + // to build the test in a way that supports the use of the flag. + + cf.BoolVar(&testArtifacts, "artifacts", false, "") + cf.StringVar(&testBench, "bench", "", "") + cf.Bool("benchmem", false, "") + cf.String("benchtime", "", "") + cf.StringVar(&testBlockProfile, "blockprofile", "", "") + cf.String("blockprofilerate", "", "") + cf.Int("count", 0, "") + cf.String("cpu", "", "") + cf.StringVar(&testCPUProfile, "cpuprofile", "", "") + cf.BoolVar(&testFailFast, "failfast", false, "") + cf.StringVar(&testFuzz, "fuzz", "", "") + cf.Bool("fullpath", false, "") + cf.StringVar(&testList, "list", "", "") + cf.StringVar(&testMemProfile, "memprofile", "", "") + cf.String("memprofilerate", "", "") + cf.StringVar(&testMutexProfile, "mutexprofile", "", "") + cf.String("mutexprofilefraction", "", "") + cf.Var(&testOutputDir, "outputdir", "") + cf.Int("parallel", 0, "") + cf.String("run", "", "") + cf.Bool("short", false, "") + cf.String("skip", "", "") + cf.DurationVar(&testTimeout, "timeout", 10*time.Minute, "") // known to cmd/dist + cf.String("fuzztime", "", "") + cf.String("fuzzminimizetime", "", "") + cf.StringVar(&testTrace, "trace", "", "") + cf.Var(&testV, "v", "") + cf.Var(&testShuffle, "shuffle", "") + + for name, ok := range passFlagToTest { + if ok { + cf.Var(cf.Lookup(name).Value, "test."+name, "") + } + } +} + +// outputdirFlag implements the -outputdir flag. +// It interprets an empty value as the working directory of the 'go' command. +type outputdirFlag struct { + abs string +} + +func (f *outputdirFlag) String() string { + return f.abs +} + +func (f *outputdirFlag) Set(value string) (err error) { + if value == "" { + f.abs = "" + } else { + f.abs, err = filepath.Abs(value) + } + return err +} + +func (f *outputdirFlag) getAbs() string { + if f.abs == "" { + return base.Cwd() + } + return f.abs +} + +// vetFlag implements the special parsing logic for the -vet flag: +// a comma-separated list, with distinguished values "all" and +// "off", plus a boolean tracking whether it was set explicitly. +// +// "all" is encoded as vetFlag{true, false, nil}, since it will +// pass no flags to the vet binary, and by default, it runs all +// analyzers. +type vetFlag struct { + explicit bool + off bool + flags []string // passed to vet when invoked automatically during 'go test' +} + +func (f *vetFlag) String() string { + switch { + case !f.off && !f.explicit && len(f.flags) == 0: + return "all" + case f.off: + return "off" + } + + var buf strings.Builder + for i, f := range f.flags { + if i > 0 { + buf.WriteByte(',') + } + buf.WriteString(f) + } + return buf.String() +} + +func (f *vetFlag) Set(value string) error { + switch { + case value == "": + *f = vetFlag{flags: defaultVetFlags} + return nil + case strings.Contains(value, "="): + return fmt.Errorf("-vet argument cannot contain equal signs") + case strings.Contains(value, " "): + return fmt.Errorf("-vet argument is comma-separated list, cannot contain spaces") + } + + *f = vetFlag{explicit: true} + var single string + for arg := range strings.SplitSeq(value, ",") { + switch arg { + case "": + return fmt.Errorf("-vet argument contains empty list element") + case "all": + single = arg + *f = vetFlag{explicit: true} + continue + case "off": + single = arg + *f = vetFlag{ + explicit: true, + off: true, + } + continue + default: + if _, ok := passAnalyzersToVet[arg]; !ok { + return fmt.Errorf("-vet argument must be a supported analyzer or a distinguished value; found %s", arg) + } + f.flags = append(f.flags, "-"+arg) + } + } + if len(f.flags) > 1 && single != "" { + return fmt.Errorf("-vet does not accept %q in a list with other analyzers", single) + } + if len(f.flags) > 1 && single != "" { + return fmt.Errorf("-vet does not accept %q in a list with other analyzers", single) + } + return nil +} + +type shuffleFlag struct { + on bool + seed *int64 +} + +func (f *shuffleFlag) String() string { + if !f.on { + return "off" + } + if f.seed == nil { + return "on" + } + return fmt.Sprintf("%d", *f.seed) +} + +func (f *shuffleFlag) Set(value string) error { + if value == "off" { + *f = shuffleFlag{on: false} + return nil + } + + if value == "on" { + *f = shuffleFlag{on: true} + return nil + } + + seed, err := strconv.ParseInt(value, 10, 64) + if err != nil { + return fmt.Errorf(`-shuffle argument must be "on", "off", or an int64: %v`, err) + } + + *f = shuffleFlag{on: true, seed: &seed} + return nil +} + +// testFlags processes the command line, grabbing -x and -c, rewriting known flags +// to have "test" before them, and reading the command line for the test binary. +// Unfortunately for us, we need to do our own flag processing because go test +// grabs some flags but otherwise its command line is just a holding place for +// pkg.test's arguments. +// We allow known flags both before and after the package name list, +// to allow both +// +// go test fmt -custom-flag-for-fmt-test +// go test -x math +func testFlags(args []string) (packageNames, passToTest []string) { + base.SetFromGOFLAGS(&CmdTest.Flag) + addFromGOFLAGS := map[string]bool{} + CmdTest.Flag.Visit(func(f *flag.Flag) { + if short := strings.TrimPrefix(f.Name, "test."); passFlagToTest[short] { + addFromGOFLAGS[f.Name] = true + } + }) + + // firstUnknownFlag helps us report an error when flags not known to 'go + // test' are used along with -i or -c. + firstUnknownFlag := "" + + explicitArgs := make([]string, 0, len(args)) + inPkgList := false + afterFlagWithoutValue := false + for len(args) > 0 { + f, remainingArgs, err := cmdflag.ParseOne(&CmdTest.Flag, args) + + wasAfterFlagWithoutValue := afterFlagWithoutValue + afterFlagWithoutValue = false // provisionally + + if errors.Is(err, flag.ErrHelp) { + exitWithUsage() + } + + if errors.Is(err, cmdflag.ErrFlagTerminator) { + // 'go list' allows package arguments to be named either before or after + // the terminator, but 'go test' has historically allowed them only + // before. Preserve that behavior and treat all remaining arguments — + // including the terminator itself! — as arguments to the test. + explicitArgs = append(explicitArgs, args...) + break + } + + if nf, ok := errors.AsType[cmdflag.NonFlagError](err); ok { + if !inPkgList && packageNames != nil { + // We already saw the package list previously, and this argument is not + // a flag, so it — and everything after it — must be either a value for + // a preceding flag or a literal argument to the test binary. + if wasAfterFlagWithoutValue { + // This argument could syntactically be a flag value, so + // optimistically assume that it is and keep looking for go command + // flags after it. + // + // (If we're wrong, we'll at least be consistent with historical + // behavior; see https://golang.org/issue/40763.) + explicitArgs = append(explicitArgs, nf.RawArg) + args = remainingArgs + continue + } else { + // This argument syntactically cannot be a flag value, so it must be a + // positional argument, and so must everything after it. + explicitArgs = append(explicitArgs, args...) + break + } + } + + inPkgList = true + packageNames = append(packageNames, nf.RawArg) + args = remainingArgs // Consume the package name. + continue + } + + if inPkgList { + // This argument is syntactically a flag, so if we were in the package + // list we're not anymore. + inPkgList = false + } + + if nd, ok := errors.AsType[cmdflag.FlagNotDefinedError](err); ok { + // This is a flag we do not know. We must assume that any args we see + // after this might be flag arguments, not package names, so make + // packageNames non-nil to indicate that the package list is complete. + // + // (Actually, we only strictly need to assume that if the flag is not of + // the form -x=value, but making this more precise would be a breaking + // change in the command line API.) + if packageNames == nil { + packageNames = []string{} + } + + if nd.RawArg == "-args" || nd.RawArg == "--args" { + // -args or --args signals that everything that follows + // should be passed to the test. + explicitArgs = append(explicitArgs, remainingArgs...) + break + } + + if firstUnknownFlag == "" { + firstUnknownFlag = nd.RawArg + } + + explicitArgs = append(explicitArgs, nd.RawArg) + args = remainingArgs + if !nd.HasValue { + afterFlagWithoutValue = true + } + continue + } + + if err != nil { + fmt.Fprintln(os.Stderr, err) + exitWithUsage() + } + + if short := strings.TrimPrefix(f.Name, "test."); passFlagToTest[short] { + explicitArgs = append(explicitArgs, fmt.Sprintf("-test.%s=%v", short, f.Value)) + + // This flag has been overridden explicitly, so don't forward its implicit + // value from GOFLAGS. + delete(addFromGOFLAGS, short) + delete(addFromGOFLAGS, "test."+short) + } + + args = remainingArgs + } + if firstUnknownFlag != "" && testC { + fmt.Fprintf(os.Stderr, "go: unknown flag %s cannot be used with -c\n", firstUnknownFlag) + exitWithUsage() + } + + var injectedFlags []string + if testJSON { + // If converting to JSON, we need the full output in order to pipe it to test2json. + // The -test.v=test2json flag is like -test.v=true but causes the test to add + // extra ^V characters before testing output lines and other framing, + // which helps test2json do a better job creating the JSON events. + injectedFlags = append(injectedFlags, "-test.v=test2json") + delete(addFromGOFLAGS, "v") + delete(addFromGOFLAGS, "test.v") + + if gotestjsonbuildtext.Value() == "1" { + gotestjsonbuildtext.IncNonDefault() + } else { + cfg.BuildJSON = true + } + } + + // Inject flags from GOFLAGS before the explicit command-line arguments. + // (They must appear before the flag terminator or first non-flag argument.) + // Also determine whether flags with awkward defaults have already been set. + var timeoutSet, outputDirSet bool + CmdTest.Flag.Visit(func(f *flag.Flag) { + short := strings.TrimPrefix(f.Name, "test.") + if addFromGOFLAGS[f.Name] { + injectedFlags = append(injectedFlags, fmt.Sprintf("-test.%s=%v", short, f.Value)) + } + switch short { + case "timeout": + timeoutSet = true + case "outputdir": + outputDirSet = true + } + }) + + // 'go test' has a default timeout, but the test binary itself does not. + // If the timeout wasn't set (and forwarded) explicitly, add the default + // timeout to the command line. + if testTimeout > 0 && !timeoutSet { + injectedFlags = append(injectedFlags, fmt.Sprintf("-test.timeout=%v", testTimeout)) + } + + // Similarly, the test binary defaults -test.outputdir to its own working + // directory, but 'go test' defaults it to the working directory of the 'go' + // command. Set it explicitly if it is needed due to some other flag that + // requests output. + needOutputDir := testProfile() != "" || testArtifacts + if needOutputDir && !outputDirSet { + injectedFlags = append(injectedFlags, "-test.outputdir="+testOutputDir.getAbs()) + } + + // If the user is explicitly passing -help or -h, show output + // of the test binary so that the help output is displayed + // even though the test will exit with success. + // This loop is imperfect: it will do the wrong thing for a case + // like -args -test.outputdir -help. Such cases are probably rare, + // and getting this wrong doesn't do too much harm. +helpLoop: + for _, arg := range explicitArgs { + switch arg { + case "--": + break helpLoop + case "-h", "-help", "--help": + testHelp = true + break helpLoop + } + } + + // Forward any unparsed arguments (following --args) to the test binary. + return packageNames, append(injectedFlags, explicitArgs...) +} + +func exitWithUsage() { + fmt.Fprintf(os.Stderr, "usage: %s\n", CmdTest.UsageLine) + fmt.Fprintf(os.Stderr, "Run 'go help %s' and 'go help %s' for details.\n", CmdTest.LongName(), HelpTestflag.LongName()) + + base.SetExitStatus(2) + base.Exit() +} diff --git a/go/src/cmd/go/internal/tool/tool.go b/go/src/cmd/go/internal/tool/tool.go new file mode 100644 index 0000000000000000000000000000000000000000..92e8a803105f8d1b8f6c9f6fcc530f4f65475aef --- /dev/null +++ b/go/src/cmd/go/internal/tool/tool.go @@ -0,0 +1,404 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package tool implements the “go tool” command. +package tool + +import ( + "cmd/internal/telemetry/counter" + "context" + "encoding/json" + "errors" + "flag" + "fmt" + "go/build" + "internal/platform" + "maps" + "os" + "os/exec" + "os/signal" + "path" + "slices" + "sort" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/load" + "cmd/go/internal/modindex" + "cmd/go/internal/modload" + "cmd/go/internal/str" + "cmd/go/internal/work" +) + +var CmdTool = &base.Command{ + Run: runTool, + UsageLine: "go tool [-n] command [args...]", + Short: "run specified go tool", + Long: ` +Tool runs the go tool command identified by the arguments. + +Go ships with a number of builtin tools, and additional tools +may be defined in the go.mod of the current module. + +With no arguments it prints the list of known tools. + +The -n flag causes tool to print the command that would be +executed but not execute it. + +The -modfile=file.mod build flag causes tool to use an alternate file +instead of the go.mod in the module root directory. + +Tool also provides the -C, -overlay, and -modcacherw build flags. + +For more about build flags, see 'go help build'. + +For more about each builtin tool command, see 'go doc cmd/'. +`, +} + +var toolN bool + +// Return whether tool can be expected in the gccgo tool directory. +// Other binaries could be in the same directory so don't +// show those with the 'go tool' command. +func isGccgoTool(tool string) bool { + switch tool { + case "cgo", "fix", "cover", "godoc", "vet": + return true + } + return false +} + +func init() { + base.AddChdirFlag(&CmdTool.Flag) + base.AddModCommonFlags(&CmdTool.Flag) + CmdTool.Flag.BoolVar(&toolN, "n", false, "") +} + +func runTool(ctx context.Context, cmd *base.Command, args []string) { + moduleLoaderState := modload.NewState() + if len(args) == 0 { + counter.Inc("go/subcommand:tool") + listTools(moduleLoaderState, ctx) + return + } + toolName := args[0] + + toolPath, err := base.ToolPath(toolName) + if err != nil { + if toolName == "dist" && len(args) > 1 && args[1] == "list" { + // cmd/distpack removes the 'dist' tool from the toolchain to save space, + // since it is normally only used for building the toolchain in the first + // place. However, 'go tool dist list' is useful for listing all supported + // platforms. + // + // If the dist tool does not exist, impersonate this command. + if impersonateDistList(args[2:]) { + // If it becomes necessary, we could increment an additional counter to indicate + // that we're impersonating dist list if knowing that becomes important? + counter.Inc("go/subcommand:tool-dist") + return + } + } + + // See if tool can be a builtin tool. If so, try to build and run it. + // buildAndRunBuiltinTool will fail if the install target of the loaded package is not + // the tool directory. + if tool := loadBuiltinTool(toolName); tool != "" { + // Increment a counter for the tool subcommand with the tool name. + counter.Inc("go/subcommand:tool-" + toolName) + buildAndRunBuiltinTool(moduleLoaderState, ctx, toolName, tool, args[1:]) + return + } + + // Try to build and run mod tool. + tool := loadModTool(moduleLoaderState, ctx, toolName) + if tool != "" { + buildAndRunModtool(moduleLoaderState, ctx, toolName, tool, args[1:]) + return + } + + counter.Inc("go/subcommand:tool-unknown") + + // Emit the usual error for the missing tool. + _ = base.Tool(toolName) + } else { + // Increment a counter for the tool subcommand with the tool name. + counter.Inc("go/subcommand:tool-" + toolName) + } + + runBuiltTool(toolName, nil, append([]string{toolPath}, args[1:]...)) +} + +// listTools prints a list of the available tools in the tools directory. +func listTools(loaderstate *modload.State, ctx context.Context) { + f, err := os.Open(build.ToolDir) + if err != nil { + fmt.Fprintf(os.Stderr, "go: no tool directory: %s\n", err) + base.SetExitStatus(2) + return + } + defer f.Close() + names, err := f.Readdirnames(-1) + if err != nil { + fmt.Fprintf(os.Stderr, "go: can't read tool directory: %s\n", err) + base.SetExitStatus(2) + return + } + + sort.Strings(names) + for _, name := range names { + // Unify presentation by going to lower case. + // If it's windows, don't show the .exe suffix. + name = strings.TrimSuffix(strings.ToLower(name), cfg.ToolExeSuffix()) + + // The tool directory used by gccgo will have other binaries + // in addition to go tools. Only display go tools here. + if cfg.BuildToolchainName == "gccgo" && !isGccgoTool(name) { + continue + } + fmt.Println(name) + } + + loaderstate.InitWorkfile() + modload.LoadModFile(loaderstate, ctx) + modTools := slices.Sorted(maps.Keys(loaderstate.MainModules.Tools())) + for _, tool := range modTools { + fmt.Println(tool) + } +} + +func impersonateDistList(args []string) (handled bool) { + fs := flag.NewFlagSet("go tool dist list", flag.ContinueOnError) + jsonFlag := fs.Bool("json", false, "produce JSON output") + brokenFlag := fs.Bool("broken", false, "include broken ports") + + // The usage for 'go tool dist' claims that + // “All commands take -v flags to emit extra information”, + // but list -v appears not to have any effect. + _ = fs.Bool("v", false, "emit extra information") + + if err := fs.Parse(args); err != nil || len(fs.Args()) > 0 { + // Unrecognized flag or argument. + // Force fallback to the real 'go tool dist'. + return false + } + + if !*jsonFlag { + for _, p := range platform.List { + if !*brokenFlag && platform.Broken(p.GOOS, p.GOARCH) { + continue + } + fmt.Println(p) + } + return true + } + + type jsonResult struct { + GOOS string + GOARCH string + CgoSupported bool + FirstClass bool + Broken bool `json:",omitempty"` + } + + var results []jsonResult + for _, p := range platform.List { + broken := platform.Broken(p.GOOS, p.GOARCH) + if broken && !*brokenFlag { + continue + } + if *jsonFlag { + results = append(results, jsonResult{ + GOOS: p.GOOS, + GOARCH: p.GOARCH, + CgoSupported: platform.CgoSupported(p.GOOS, p.GOARCH), + FirstClass: platform.FirstClass(p.GOOS, p.GOARCH), + Broken: broken, + }) + } + } + out, err := json.MarshalIndent(results, "", "\t") + if err != nil { + return false + } + + os.Stdout.Write(out) + return true +} + +func defaultExecName(importPath string) string { + var p load.Package + p.ImportPath = importPath + return p.DefaultExecName() +} + +func loadBuiltinTool(toolName string) string { + if !base.ValidToolName(toolName) { + return "" + } + cmdTool := path.Join("cmd", toolName) + if !modindex.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, cmdTool) { + return "" + } + // Create a fake package and check to see if it would be installed to the tool directory. + // If not, it's not a builtin tool. + p := &load.Package{PackagePublic: load.PackagePublic{Name: "main", ImportPath: cmdTool, Goroot: true}} + if load.InstallTargetDir(p) != load.ToTool { + return "" + } + return cmdTool +} + +func loadModTool(loaderstate *modload.State, ctx context.Context, name string) string { + loaderstate.InitWorkfile() + modload.LoadModFile(loaderstate, ctx) + + matches := []string{} + for tool := range loaderstate.MainModules.Tools() { + if tool == name || defaultExecName(tool) == name { + matches = append(matches, tool) + } + } + + if len(matches) == 1 { + return matches[0] + } + + if len(matches) > 1 { + message := fmt.Sprintf("tool %q is ambiguous; choose one of:\n\t", name) + for _, tool := range matches { + message += tool + "\n\t" + } + base.Fatal(errors.New(message)) + } + + return "" +} + +func builtTool(runAction *work.Action) string { + linkAction := runAction.Deps[0] + if toolN { + // #72824: If -n is set, use the cached path if we can. + // This is only necessary if the binary wasn't cached + // before this invocation of the go command: if the binary + // was cached, BuiltTarget() will be the cached executable. + // It's only in the "first run", where we actually do the build + // and save the result to the cache that BuiltTarget is not + // the cached binary. Ideally, we would set BuiltTarget + // to the cached path even in the first run, but if we + // copy the binary to the cached path, and try to run it + // in the same process, we'll run into the dreaded #22315 + // resulting in occasional ETXTBSYs. Instead of getting the + // ETXTBSY and then retrying just don't use the cached path + // on the first run if we're going to actually run the binary. + if cached := linkAction.CachedExecutable(); cached != "" { + return cached + } + } + return linkAction.BuiltTarget() +} + +func buildAndRunBuiltinTool(loaderstate *modload.State, ctx context.Context, toolName, tool string, args []string) { + // Override GOOS and GOARCH for the build to build the tool using + // the same GOOS and GOARCH as this go command. + cfg.ForceHost() + + // Ignore go.mod and go.work: we don't need them, and we want to be able + // to run the tool even if there's an issue with the module or workspace the + // user happens to be in. + loaderstate.RootMode = modload.NoRoot + + runFunc := func(b *work.Builder, ctx context.Context, a *work.Action) error { + cmdline := str.StringList(builtTool(a), a.Args) + return runBuiltTool(toolName, nil, cmdline) + } + + buildAndRunTool(loaderstate, ctx, tool, args, runFunc) +} + +func buildAndRunModtool(loaderstate *modload.State, ctx context.Context, toolName, tool string, args []string) { + runFunc := func(b *work.Builder, ctx context.Context, a *work.Action) error { + // Use the ExecCmd to run the binary, as go run does. ExecCmd allows users + // to provide a runner to run the binary, for example a simulator for binaries + // that are cross-compiled to a different platform. + cmdline := str.StringList(work.FindExecCmd(), builtTool(a), a.Args) + // Use same environment go run uses to start the executable: + // the original environment with cfg.GOROOTbin added to the path. + env := slices.Clip(cfg.OrigEnv) + env = base.AppendPATH(env) + + return runBuiltTool(toolName, env, cmdline) + } + + buildAndRunTool(loaderstate, ctx, tool, args, runFunc) +} + +func buildAndRunTool(loaderstate *modload.State, ctx context.Context, tool string, args []string, runTool work.ActorFunc) { + work.BuildInit(loaderstate) + b := work.NewBuilder("", loaderstate.VendorDirOrEmpty) + defer func() { + if err := b.Close(); err != nil { + base.Fatal(err) + } + }() + + pkgOpts := load.PackageOpts{MainOnly: true} + p := load.PackagesAndErrors(loaderstate, ctx, pkgOpts, []string{tool})[0] + p.Internal.OmitDebug = true + p.Internal.ExeName = p.DefaultExecName() + + a1 := b.LinkAction(loaderstate, work.ModeBuild, work.ModeBuild, p) + a1.CacheExecutable = true + a := &work.Action{Mode: "go tool", Actor: runTool, Args: args, Deps: []*work.Action{a1}} + b.Do(ctx, a) +} + +func runBuiltTool(toolName string, env, cmdline []string) error { + if toolN { + fmt.Println(strings.Join(cmdline, " ")) + return nil + } + + toolCmd := &exec.Cmd{ + Path: cmdline[0], + Args: cmdline, + Stdin: os.Stdin, + Stdout: os.Stdout, + Stderr: os.Stderr, + Env: env, + } + err := toolCmd.Start() + if err == nil { + c := make(chan os.Signal, 100) + signal.Notify(c) + go func() { + for sig := range c { + toolCmd.Process.Signal(sig) + } + }() + err = toolCmd.Wait() + signal.Stop(c) + close(c) + } + if err != nil { + // Only print about the exit status if the command + // didn't even run (not an ExitError) or if it didn't exit cleanly + // or we're printing command lines too (-x mode). + // Assume if command exited cleanly (even with non-zero status) + // it printed any messages it wanted to print. + e, ok := err.(*exec.ExitError) + if !ok || !e.Exited() || cfg.BuildX { + fmt.Fprintf(os.Stderr, "go tool %s: %s\n", toolName, err) + } + if ok { + base.SetExitStatus(e.ExitCode()) + } else { + base.SetExitStatus(1) + } + } + + return nil +} diff --git a/go/src/cmd/go/internal/toolchain/exec.go b/go/src/cmd/go/internal/toolchain/exec.go new file mode 100644 index 0000000000000000000000000000000000000000..df385e7b4712e346063cb0bd7319af5a81e2191e --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/exec.go @@ -0,0 +1,63 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !js && !wasip1 + +package toolchain + +import ( + "cmd/go/internal/base" + "fmt" + "internal/godebug" + "os" + "os/exec" + "runtime" + "syscall" +) + +// execGoToolchain execs the Go toolchain with the given name (gotoolchain), +// GOROOT directory, and go command executable. +// The GOROOT directory is empty if we are invoking a command named +// gotoolchain found in $PATH. +func execGoToolchain(gotoolchain, dir, exe string) { + os.Setenv(targetEnv, gotoolchain) + if dir == "" { + os.Unsetenv("GOROOT") + } else { + os.Setenv("GOROOT", dir) + } + if toolchainTrace { + if dir == "" { + fmt.Fprintf(os.Stderr, "go: using %s toolchain located in system PATH (%s)\n", gotoolchain, exe) + } else { + fmt.Fprintf(os.Stderr, "go: using %s toolchain from cache located at %s\n", gotoolchain, exe) + } + } + + // On Windows, there is no syscall.Exec, so the best we can do + // is run a subprocess and exit with the same status. + // Doing the same on Unix would be a problem because it wouldn't + // propagate signals and such, but there are no signals on Windows. + // We also use the exec case when GODEBUG=gotoolchainexec=0, + // to allow testing this code even when not on Windows. + if godebug.New("#gotoolchainexec").Value() == "0" || runtime.GOOS == "windows" { + cmd := exec.Command(exe, os.Args[1:]...) + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil { + if e, ok := err.(*exec.ExitError); ok && e.ProcessState != nil { + if e.ProcessState.Exited() { + os.Exit(e.ProcessState.ExitCode()) + } + base.Fatalf("exec %s: %s", gotoolchain, e.ProcessState) + } + base.Fatalf("exec %s: %s", exe, err) + } + os.Exit(0) + } + err := syscall.Exec(exe, os.Args, os.Environ()) + base.Fatalf("exec %s: %v", gotoolchain, err) +} diff --git a/go/src/cmd/go/internal/toolchain/exec_stub.go b/go/src/cmd/go/internal/toolchain/exec_stub.go new file mode 100644 index 0000000000000000000000000000000000000000..e2123790a7e945923ad3db7cebdef5b6b2262277 --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/exec_stub.go @@ -0,0 +1,13 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build js || wasip1 + +package toolchain + +import "cmd/go/internal/base" + +func execGoToolchain(gotoolchain, dir, exe string) { + base.Fatalf("execGoToolchain unsupported") +} diff --git a/go/src/cmd/go/internal/toolchain/path_none.go b/go/src/cmd/go/internal/toolchain/path_none.go new file mode 100644 index 0000000000000000000000000000000000000000..8fdf71a6e6ad9b23303e2b2eaa80138324cc6876 --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/path_none.go @@ -0,0 +1,21 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !unix && !plan9 && !windows + +package toolchain + +import "io/fs" + +// pathDirs returns the directories in the system search path. +func pathDirs() []string { + return nil +} + +// pathVersion returns the Go version implemented by the file +// described by de and info in directory dir. +// The analysis only uses the name itself; it does not run the program. +func pathVersion(dir string, de fs.DirEntry, info fs.FileInfo) (string, bool) { + return "", false +} diff --git a/go/src/cmd/go/internal/toolchain/path_plan9.go b/go/src/cmd/go/internal/toolchain/path_plan9.go new file mode 100644 index 0000000000000000000000000000000000000000..3f836a07b1038364c6b9249963d7d4828e51cc19 --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/path_plan9.go @@ -0,0 +1,29 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package toolchain + +import ( + "io/fs" + "os" + "path/filepath" + + "cmd/go/internal/gover" +) + +// pathDirs returns the directories in the system search path. +func pathDirs() []string { + return filepath.SplitList(os.Getenv("path")) +} + +// pathVersion returns the Go version implemented by the file +// described by de and info in directory dir. +// The analysis only uses the name itself; it does not run the program. +func pathVersion(dir string, de fs.DirEntry, info fs.FileInfo) (string, bool) { + v := gover.FromToolchain(de.Name()) + if v == "" || info.Mode()&0111 == 0 { + return "", false + } + return v, true +} diff --git a/go/src/cmd/go/internal/toolchain/path_unix.go b/go/src/cmd/go/internal/toolchain/path_unix.go new file mode 100644 index 0000000000000000000000000000000000000000..519c53ec30b818b17252a607003d855957e82c0a --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/path_unix.go @@ -0,0 +1,46 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build unix + +package toolchain + +import ( + "internal/syscall/unix" + "io/fs" + "os" + "path/filepath" + "syscall" + + "cmd/go/internal/gover" +) + +// pathDirs returns the directories in the system search path. +func pathDirs() []string { + return filepath.SplitList(os.Getenv("PATH")) +} + +// pathVersion returns the Go version implemented by the file +// described by de and info in directory dir. +// The analysis only uses the name itself; it does not run the program. +func pathVersion(dir string, de fs.DirEntry, info fs.FileInfo) (string, bool) { + v := gover.FromToolchain(de.Name()) + if v == "" { + return "", false + } + + // Mimicking exec.findExecutable here. + // ENOSYS means Eaccess is not available or not implemented. + // EPERM can be returned by Linux containers employing seccomp. + // In both cases, fall back to checking the permission bits. + err := unix.Eaccess(filepath.Join(dir, de.Name()), unix.X_OK) + if (err == syscall.ENOSYS || err == syscall.EPERM) && info.Mode()&0111 != 0 { + err = nil + } + if err != nil { + return "", false + } + + return v, true +} diff --git a/go/src/cmd/go/internal/toolchain/path_windows.go b/go/src/cmd/go/internal/toolchain/path_windows.go new file mode 100644 index 0000000000000000000000000000000000000000..dfb2238a4dbb97333547e60c9142382a0fd5aa43 --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/path_windows.go @@ -0,0 +1,71 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package toolchain + +import ( + "io/fs" + "os" + "path/filepath" + "strings" + "sync" + + "cmd/go/internal/gover" +) + +var pathExts = sync.OnceValue(func() []string { + x := os.Getenv(`PATHEXT`) + if x == "" { + return []string{".com", ".exe", ".bat", ".cmd"} + } + + var exts []string + for e := range strings.SplitSeq(strings.ToLower(x), `;`) { + if e == "" { + continue + } + if e[0] != '.' { + e = "." + e + } + exts = append(exts, e) + } + return exts +}) + +// pathDirs returns the directories in the system search path. +func pathDirs() []string { + return filepath.SplitList(os.Getenv("PATH")) +} + +// pathVersion returns the Go version implemented by the file +// described by de and info in directory dir. +// The analysis only uses the name itself; it does not run the program. +func pathVersion(dir string, de fs.DirEntry, info fs.FileInfo) (string, bool) { + name, _, ok := cutExt(de.Name(), pathExts()) + if !ok { + return "", false + } + v := gover.FromToolchain(name) + if v == "" { + return "", false + } + return v, true +} + +// cutExt looks for any of the known extensions at the end of file. +// If one is found, cutExt returns the file name with the extension trimmed, +// the extension itself, and true to signal that an extension was found. +// Otherwise cutExt returns file, "", false. +func cutExt(file string, exts []string) (name, ext string, found bool) { + i := strings.LastIndex(file, ".") + if i < 0 { + return file, "", false + } + for _, x := range exts { + if strings.EqualFold(file[i:], x) { + return file[:i], file[i:], true + } + } + return file, "", false +} diff --git a/go/src/cmd/go/internal/toolchain/select.go b/go/src/cmd/go/internal/toolchain/select.go new file mode 100644 index 0000000000000000000000000000000000000000..0cb93f67e1321c804846566df93ca1a694c652e1 --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/select.go @@ -0,0 +1,718 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package toolchain implements dynamic switching of Go toolchains. +package toolchain + +import ( + "bytes" + "context" + "errors" + "flag" + "fmt" + "go/build" + "internal/godebug" + "io" + "io/fs" + "log" + "os" + "path/filepath" + "runtime" + "strconv" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/modload" + "cmd/go/internal/run" + "cmd/go/internal/work" + "cmd/internal/pathcache" + "cmd/internal/telemetry/counter" + + "golang.org/x/mod/module" +) + +const ( + // We download golang.org/toolchain version v0.0.1-.-. + // If the 0.0.1 indicates anything at all, its the version of the toolchain packaging: + // if for some reason we needed to change the way toolchains are packaged into + // module zip files in a future version of Go, we could switch to v0.0.2 and then + // older versions expecting the old format could use v0.0.1 and newer versions + // would use v0.0.2. Of course, then we'd also have to publish two of each + // module zip file. It's not likely we'll ever need to change this. + gotoolchainModule = "golang.org/toolchain" + gotoolchainVersion = "v0.0.1" + + // targetEnv is a special environment variable set to the expected + // toolchain version during the toolchain switch by the parent + // process and cleared in the child process. When set, that indicates + // to the child to confirm that it provides the expected toolchain version. + targetEnv = "GOTOOLCHAIN_INTERNAL_SWITCH_VERSION" + + // countEnv is a special environment variable + // that is incremented during each toolchain switch, to detect loops. + // It is cleared before invoking programs in 'go run', 'go test', 'go generate', and 'go tool' + // by invoking them in an environment filtered with FilterEnv, + // so user programs should not see this in their environment. + countEnv = "GOTOOLCHAIN_INTERNAL_SWITCH_COUNT" + + // maxSwitch is the maximum toolchain switching depth. + // Most uses should never see more than three. + // (Perhaps one for the initial GOTOOLCHAIN dispatch, + // a second for go get doing an upgrade, and a third if + // for some reason the chosen upgrade version is too small + // by a little.) + // When the count reaches maxSwitch - 10, we start logging + // the switched versions for debugging before crashing with + // a fatal error upon reaching maxSwitch. + // That should be enough to see the repetition. + maxSwitch = 100 +) + +// FilterEnv returns a copy of env with internal GOTOOLCHAIN environment +// variables filtered out. +func FilterEnv(env []string) []string { + // Note: Don't need to filter out targetEnv because Switch does that. + var out []string + for _, e := range env { + if strings.HasPrefix(e, countEnv+"=") { + continue + } + out = append(out, e) + } + return out +} + +var ( + counterErrorsInvalidToolchainInFile = counter.New("go/errors:invalid-toolchain-in-file") + toolchainTrace = godebug.New("#toolchaintrace").Value() == "1" +) + +// Select invokes a different Go toolchain if directed by +// the GOTOOLCHAIN environment variable or the user's configuration +// or go.mod file. +// It must be called early in startup. +// See https://go.dev/doc/toolchain#select. +func Select() { + moduleLoaderState := modload.NewState() + log.SetPrefix("go: ") + defer log.SetPrefix("") + + if !moduleLoaderState.WillBeEnabled() { + return + } + + // As a special case, let "go env GOTOOLCHAIN" and "go env -w GOTOOLCHAIN=..." + // be handled by the local toolchain, since an older toolchain may not understand it. + // This provides an easy way out of "go env -w GOTOOLCHAIN=go1.19" and makes + // sure that "go env GOTOOLCHAIN" always prints the local go command's interpretation of it. + // We look for these specific command lines in order to avoid mishandling + // + // GOTOOLCHAIN=go1.999 go env -newflag GOTOOLCHAIN + // + // where -newflag is a flag known to Go 1.999 but not known to us. + if (len(os.Args) == 3 && os.Args[1] == "env" && os.Args[2] == "GOTOOLCHAIN") || + (len(os.Args) == 4 && os.Args[1] == "env" && os.Args[2] == "-w" && strings.HasPrefix(os.Args[3], "GOTOOLCHAIN=")) { + return + } + + // As a special case, let "go env GOMOD" and "go env GOWORK" be handled by + // the local toolchain. Users expect to be able to look up GOMOD and GOWORK + // since the go.mod and go.work file need to be determined to determine + // the minimum toolchain. See issue #61455. + if len(os.Args) == 3 && os.Args[1] == "env" && (os.Args[2] == "GOMOD" || os.Args[2] == "GOWORK") { + return + } + + // Interpret GOTOOLCHAIN to select the Go toolchain to run. + gotoolchain := cfg.Getenv("GOTOOLCHAIN") + gover.Startup.GOTOOLCHAIN = gotoolchain + if gotoolchain == "" { + // cfg.Getenv should fall back to $GOROOT/go.env, + // so this should not happen, unless a packager + // has deleted the GOTOOLCHAIN line from go.env. + // It can also happen if GOROOT is missing or broken, + // in which case best to let the go command keep running + // and diagnose the problem. + return + } + + // Note: minToolchain is what https://go.dev/doc/toolchain#select calls the default toolchain. + minToolchain := gover.LocalToolchain() + minVers := gover.Local() + var mode string + var toolchainTraceBuffer bytes.Buffer + if gotoolchain == "auto" { + mode = "auto" + } else if gotoolchain == "path" { + mode = "path" + } else { + min, suffix, plus := strings.Cut(gotoolchain, "+") // go1.2.3+auto + if min != "local" { + v := gover.FromToolchain(min) + if v == "" { + if plus { + base.Fatalf("invalid GOTOOLCHAIN %q: invalid minimum toolchain %q", gotoolchain, min) + } + base.Fatalf("invalid GOTOOLCHAIN %q", gotoolchain) + } + minToolchain = min + minVers = v + } + if plus && suffix != "auto" && suffix != "path" { + base.Fatalf("invalid GOTOOLCHAIN %q: only version suffixes are +auto and +path", gotoolchain) + } + mode = suffix + if toolchainTrace { + fmt.Fprintf(&toolchainTraceBuffer, "go: default toolchain set to %s from GOTOOLCHAIN=%s\n", minToolchain, gotoolchain) + } + } + + gotoolchain = minToolchain + if mode == "auto" || mode == "path" { + // Read go.mod to find new minimum and suggested toolchain. + file, goVers, toolchain := modGoToolchain(moduleLoaderState) + gover.Startup.AutoFile = file + if toolchain == "default" { + // "default" means always use the default toolchain, + // which is already set, so nothing to do here. + // Note that if we have Go 1.21 installed originally, + // GOTOOLCHAIN=go1.30.0+auto or GOTOOLCHAIN=go1.30.0, + // and the go.mod says "toolchain default", we use Go 1.30, not Go 1.21. + // That is, default overrides the "auto" part of the calculation + // but not the minimum that the user has set. + // Of course, if the go.mod also says "go 1.35", using Go 1.30 + // will provoke an error about the toolchain being too old. + // That's what people who use toolchain default want: + // only ever use the toolchain configured by the user + // (including its environment and go env -w file). + gover.Startup.AutoToolchain = toolchain + } else { + if toolchain != "" { + // Accept toolchain only if it is > our min. + // (If it is equal, then min satisfies it anyway: that can matter if min + // has a suffix like "go1.21.1-foo" and toolchain is "go1.21.1".) + toolVers := gover.FromToolchain(toolchain) + if toolVers == "" || (!strings.HasPrefix(toolchain, "go") && !strings.Contains(toolchain, "-go")) { + counterErrorsInvalidToolchainInFile.Inc() + base.Fatalf("invalid toolchain %q in %s", toolchain, base.ShortPath(file)) + } + if gover.Compare(toolVers, minVers) > 0 { + if toolchainTrace { + modeFormat := mode + if strings.Contains(cfg.Getenv("GOTOOLCHAIN"), "+") { // go1.2.3+auto + modeFormat = fmt.Sprintf("+%s", mode) + } + fmt.Fprintf(&toolchainTraceBuffer, "go: upgrading toolchain to %s (required by toolchain line in %s; upgrade allowed by GOTOOLCHAIN=%s)\n", toolchain, base.ShortPath(file), modeFormat) + } + gotoolchain = toolchain + minVers = toolVers + gover.Startup.AutoToolchain = toolchain + } + } + if gover.Compare(goVers, minVers) > 0 { + gotoolchain = "go" + goVers + minVers = goVers + // Starting with Go 1.21, the first released version has a .0 patch version suffix. + // Don't try to download a language version (sans patch component), such as go1.22. + // Instead, use the first toolchain of that language version, such as 1.22.0. + // See golang.org/issue/62278. + if gover.IsLang(goVers) && gover.Compare(goVers, "1.21") >= 0 { + gotoolchain += ".0" + } + gover.Startup.AutoGoVersion = goVers + gover.Startup.AutoToolchain = "" // in case we are overriding it for being too old + if toolchainTrace { + modeFormat := mode + if strings.Contains(cfg.Getenv("GOTOOLCHAIN"), "+") { // go1.2.3+auto + modeFormat = fmt.Sprintf("+%s", mode) + } + fmt.Fprintf(&toolchainTraceBuffer, "go: upgrading toolchain to %s (required by go line in %s; upgrade allowed by GOTOOLCHAIN=%s)\n", gotoolchain, base.ShortPath(file), modeFormat) + } + } + } + maybeSwitchForGoInstallVersion(moduleLoaderState, minVers) + } + + // If we are invoked as a target toolchain, confirm that + // we provide the expected version and then run. + // This check is delayed until after the handling of auto and path + // so that we have initialized gover.Startup for use in error messages. + if target := os.Getenv(targetEnv); target != "" && TestVersionSwitch != "loop" { + if gover.LocalToolchain() != target { + base.Fatalf("toolchain %v invoked to provide %v", gover.LocalToolchain(), target) + } + os.Unsetenv(targetEnv) + + // Note: It is tempting to check that if gotoolchain != "local" + // then target == gotoolchain here, as a sanity check that + // the child has made the same version determination as the parent. + // This turns out not always to be the case. Specifically, if we are + // running Go 1.21 with GOTOOLCHAIN=go1.22+auto, which invokes + // Go 1.22, then 'go get go@1.23.0' or 'go get needs_go_1_23' + // will invoke Go 1.23, but as the Go 1.23 child the reason for that + // will not be apparent here: it will look like we should be using Go 1.22. + // We rely on the targetEnv being set to know not to downgrade. + // A longer term problem with the sanity check is that the exact details + // may change over time: there may be other reasons that a future Go + // version might invoke an older one, and the older one won't know why. + // Best to just accept that we were invoked to provide a specific toolchain + // (which we just checked) and leave it at that. + return + } + + if toolchainTrace { + // Flush toolchain tracing buffer only in the parent process (targetEnv is unset). + io.Copy(os.Stderr, &toolchainTraceBuffer) + } + + if gotoolchain == "local" || gotoolchain == gover.LocalToolchain() { + // Let the current binary handle the command. + if toolchainTrace { + fmt.Fprintf(os.Stderr, "go: using local toolchain %s\n", gover.LocalToolchain()) + } + return + } + + // Minimal sanity check of GOTOOLCHAIN setting before search. + // We want to allow things like go1.20.3 but also gccgo-go1.20.3. + // We want to disallow mistakes / bad ideas like GOTOOLCHAIN=bash, + // since we will find that in the path lookup. + if !strings.HasPrefix(gotoolchain, "go1") && !strings.Contains(gotoolchain, "-go1") { + base.Fatalf("invalid GOTOOLCHAIN %q", gotoolchain) + } + + counterSelectExec.Inc() + Exec(moduleLoaderState, gotoolchain) + panic("unreachable") +} + +var counterSelectExec = counter.New("go/toolchain/select-exec") + +// TestVersionSwitch is set in the test go binary to the value in $TESTGO_VERSION_SWITCH. +// Valid settings are: +// +// "switch" - simulate version switches by reinvoking the test go binary with a different TESTGO_VERSION. +// "mismatch" - like "switch" but forget to set TESTGO_VERSION, so it looks like we invoked a mismatched toolchain +// "loop" - like "mismatch" but forget the target check, causing a toolchain switching loop +var TestVersionSwitch string + +// Exec invokes the specified Go toolchain or else prints an error and exits the process. +// If $GOTOOLCHAIN is set to path or min+path, Exec only considers the PATH +// as a source of Go toolchains. Otherwise Exec tries the PATH but then downloads +// a toolchain if necessary. +func Exec(s *modload.State, gotoolchain string) { + log.SetPrefix("go: ") + + writeBits = sysWriteBits() + + count, _ := strconv.Atoi(os.Getenv(countEnv)) + if count >= maxSwitch-10 { + fmt.Fprintf(os.Stderr, "go: switching from go%v to %v [depth %d]\n", gover.Local(), gotoolchain, count) + } + if count >= maxSwitch { + base.Fatalf("too many toolchain switches") + } + os.Setenv(countEnv, fmt.Sprint(count+1)) + + env := cfg.Getenv("GOTOOLCHAIN") + pathOnly := env == "path" || strings.HasSuffix(env, "+path") + + // For testing, if TESTGO_VERSION is already in use + // (only happens in the cmd/go test binary) + // and TESTGO_VERSION_SWITCH=switch is set, + // "switch" toolchains by changing TESTGO_VERSION + // and reinvoking the current binary. + // The special cases =loop and =mismatch skip the + // setting of TESTGO_VERSION so that it looks like we + // accidentally invoked the wrong toolchain, + // to test detection of that failure mode. + switch TestVersionSwitch { + case "switch": + os.Setenv("TESTGO_VERSION", gotoolchain) + fallthrough + case "loop", "mismatch": + exe, err := os.Executable() + if err != nil { + base.Fatalf("%v", err) + } + execGoToolchain(gotoolchain, os.Getenv("GOROOT"), exe) + } + + // Look in PATH for the toolchain before we download one. + // This allows custom toolchains as well as reuse of toolchains + // already installed using go install golang.org/dl/go1.2.3@latest. + if exe, err := pathcache.LookPath(gotoolchain); err == nil { + execGoToolchain(gotoolchain, "", exe) + } + + // GOTOOLCHAIN=auto looks in PATH and then falls back to download. + // GOTOOLCHAIN=path only looks in PATH. + if pathOnly { + base.Fatalf("cannot find %q in PATH", gotoolchain) + } + + // Download and unpack toolchain module into module cache. + // Note that multiple go commands might be doing this at the same time, + // and that's OK: the module cache handles that case correctly. + m := module.Version{ + Path: gotoolchainModule, + Version: gotoolchainVersion + "-" + gotoolchain + "." + runtime.GOOS + "-" + runtime.GOARCH, + } + dir, err := s.Fetcher().Download(context.Background(), m) + if err != nil { + if errors.Is(err, fs.ErrNotExist) { + toolVers := gover.FromToolchain(gotoolchain) + if gover.IsLang(toolVers) && gover.Compare(toolVers, "1.21") >= 0 { + base.Fatalf("invalid toolchain: %s is a language version but not a toolchain version (%s.x)", gotoolchain, gotoolchain) + } + base.Fatalf("download %s for %s/%s: toolchain not available", gotoolchain, runtime.GOOS, runtime.GOARCH) + } + base.Fatalf("download %s: %v", gotoolchain, err) + } + + // On first use after download, set the execute bits on the commands + // so that we can run them. Note that multiple go commands might be + // doing this at the same time, but if so no harm done. + if runtime.GOOS != "windows" { + info, err := os.Stat(filepath.Join(dir, "bin/go")) + if err != nil { + base.Fatalf("download %s: %v", gotoolchain, err) + } + if info.Mode()&0o111 == 0 { + // allowExec sets the exec permission bits on all files found in dir if pattern is the empty string, + // or only those files that match the pattern if it's non-empty. + allowExec := func(dir, pattern string) { + err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if !d.IsDir() { + if pattern != "" { + if matched, _ := filepath.Match(pattern, d.Name()); !matched { + // Skip file. + return nil + } + } + info, err := os.Stat(path) + if err != nil { + return err + } + if err := os.Chmod(path, info.Mode()&0o777|0o111); err != nil { + return err + } + } + return nil + }) + if err != nil { + base.Fatalf("download %s: %v", gotoolchain, err) + } + } + + // Set the bits in pkg/tool before bin/go. + // If we are racing with another go command and do bin/go first, + // then the check of bin/go above might succeed, the other go command + // would skip its own mode-setting, and then the go command might + // try to run a tool before we get to setting the bits on pkg/tool. + // Setting pkg/tool and lib before bin/go avoids that ordering problem. + // The only other tool the go command invokes is gofmt, + // so we set that one explicitly before handling bin (which will include bin/go). + allowExec(filepath.Join(dir, "pkg/tool"), "") + allowExec(filepath.Join(dir, "lib"), "go_?*_?*_exec") + allowExec(filepath.Join(dir, "bin/gofmt"), "") + allowExec(filepath.Join(dir, "bin"), "") + } + } + + srcUGoMod := filepath.Join(dir, "src/_go.mod") + srcGoMod := filepath.Join(dir, "src/go.mod") + if size(srcGoMod) != size(srcUGoMod) { + err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if path == srcUGoMod { + // Leave for last, in case we are racing with another go command. + return nil + } + if pdir, name := filepath.Split(path); name == "_go.mod" { + if err := raceSafeCopy(path, pdir+"go.mod"); err != nil { + return err + } + } + return nil + }) + // Handle src/go.mod; this is the signal to other racing go commands + // that everything is okay and they can skip this step. + if err == nil { + err = raceSafeCopy(srcUGoMod, srcGoMod) + } + if err != nil { + base.Fatalf("download %s: %v", gotoolchain, err) + } + } + + // Reinvoke the go command. + execGoToolchain(gotoolchain, dir, filepath.Join(dir, "bin/go")) +} + +func size(path string) int64 { + info, err := os.Stat(path) + if err != nil { + return -1 + } + return info.Size() +} + +var writeBits fs.FileMode + +// raceSafeCopy copies the file old to the file new, being careful to ensure +// that if multiple go commands call raceSafeCopy(old, new) at the same time, +// they don't interfere with each other: both will succeed and return and +// later observe the correct content in new. Like in the build cache, we arrange +// this by opening new without truncation and then writing the content. +// Both go commands can do this simultaneously and will write the same thing +// (old never changes content). +func raceSafeCopy(old, new string) error { + oldInfo, err := os.Stat(old) + if err != nil { + return err + } + newInfo, err := os.Stat(new) + if err == nil && newInfo.Size() == oldInfo.Size() { + return nil + } + data, err := os.ReadFile(old) + if err != nil { + return err + } + // The module cache has unwritable directories by default. + // Restore the user write bit in the directory so we can create + // the new go.mod file. We clear it again at the end on a + // best-effort basis (ignoring failures). + dir := filepath.Dir(old) + info, err := os.Stat(dir) + if err != nil { + return err + } + if err := os.Chmod(dir, info.Mode()|writeBits); err != nil { + return err + } + defer os.Chmod(dir, info.Mode()) + // Note: create the file writable, so that a racing go command + // doesn't get an error before we store the actual data. + f, err := os.OpenFile(new, os.O_CREATE|os.O_WRONLY, writeBits&^0o111) + if err != nil { + // If OpenFile failed because a racing go command completed our work + // (and then OpenFile failed because the directory or file is now read-only), + // count that as a success. + if size(old) == size(new) { + return nil + } + return err + } + defer os.Chmod(new, oldInfo.Mode()) + if _, err := f.Write(data); err != nil { + f.Close() + return err + } + return f.Close() +} + +// modGoToolchain finds the enclosing go.work or go.mod file +// and returns the go version and toolchain lines from the file. +// The toolchain line overrides the version line +func modGoToolchain(loaderstate *modload.State) (file, goVers, toolchain string) { + wd := base.UncachedCwd() + file = loaderstate.FindGoWork(wd) + // $GOWORK can be set to a file that does not yet exist, if we are running 'go work init'. + // Do not try to load the file in that case + if _, err := os.Stat(file); err != nil { + file = "" + } + if file == "" { + file = modload.FindGoMod(wd) + } + if file == "" { + return "", "", "" + } + + data, err := os.ReadFile(file) + if err != nil { + base.Fatalf("%v", err) + } + return file, gover.GoModLookup(data, "go"), gover.GoModLookup(data, "toolchain") +} + +// maybeSwitchForGoInstallVersion reports whether the command line is go install m@v or go run m@v. +// If so, switch to the go version required to build m@v if it's higher than minVers. +func maybeSwitchForGoInstallVersion(loaderstate *modload.State, minVers string) { + // Note: We assume there are no flags between 'go' and 'install' or 'run'. + // During testing there are some debugging flags that are accepted + // in that position, but in production go binaries there are not. + if len(os.Args) < 3 { + return + } + + var cmdFlags *flag.FlagSet + switch os.Args[1] { + default: + // Command doesn't support a pkg@version as the main module. + return + case "install": + cmdFlags = &work.CmdInstall.Flag + case "run": + cmdFlags = &run.CmdRun.Flag + } + + // The modcachrw flag is unique, in that it affects how we fetch the + // requested module to even figure out what toolchain it needs. + // We need to actually set it before we check the toolchain version. + // (See https://go.dev/issue/64282.) + modcacherwFlag := cmdFlags.Lookup("modcacherw") + if modcacherwFlag == nil { + base.Fatalf("internal error: modcacherw flag not registered for command") + } + modcacherwVal, ok := modcacherwFlag.Value.(interface { + IsBoolFlag() bool + flag.Value + }) + if !ok || !modcacherwVal.IsBoolFlag() { + base.Fatalf("internal error: modcacherw is not a boolean flag") + } + + // Make a best effort to parse the command's args to find the pkg@version + // argument and the -modcacherw flag. + var ( + pkgArg string + modcacherwSeen bool + ) + for args := os.Args[2:]; len(args) > 0; { + a := args[0] + args = args[1:] + if a == "--" { + if len(args) == 0 { + return + } + pkgArg = args[0] + break + } + + a, ok := strings.CutPrefix(a, "-") + if !ok { + // Not a flag argument. Must be a package. + pkgArg = a + break + } + a = strings.TrimPrefix(a, "-") // Treat --flag as -flag. + + name, val, hasEq := strings.Cut(a, "=") + + if name == "modcacherw" { + if !hasEq { + val = "true" + } + if err := modcacherwVal.Set(val); err != nil { + return + } + modcacherwSeen = true + continue + } + + if hasEq { + // Already has a value; don't bother parsing it. + continue + } + + f := run.CmdRun.Flag.Lookup(a) + if f == nil { + // We don't know whether this flag is a boolean. + if os.Args[1] == "run" { + // We don't know where to find the pkg@version argument. + // For run, the pkg@version can be anywhere on the command line, + // because it is preceded by run flags and followed by arguments to the + // program being run. Since we don't know whether this flag takes + // an argument, we can't reliably identify the end of the run flags. + // Just give up and let the user clarify using the "=" form. + return + } + + // We would like to let 'go install -newflag pkg@version' work even + // across a toolchain switch. To make that work, assume by default that + // the pkg@version is the last argument and skip the remaining args unless + // we spot a plausible "-modcacherw" flag. + for len(args) > 0 { + a := args[0] + name, _, _ := strings.Cut(a, "=") + if name == "-modcacherw" || name == "--modcacherw" { + break + } + if len(args) == 1 && !strings.HasPrefix(a, "-") { + pkgArg = a + } + args = args[1:] + } + continue + } + + if bf, ok := f.Value.(interface{ IsBoolFlag() bool }); !ok || !bf.IsBoolFlag() { + // The next arg is the value for this flag. Skip it. + args = args[1:] + continue + } + } + + if !strings.Contains(pkgArg, "@") || build.IsLocalImport(pkgArg) || filepath.IsAbs(pkgArg) { + return + } + path, version, _, err := modload.ParsePathVersion(pkgArg) + if err != nil { + base.Fatalf("go: %v", err) + } + if path == "" || version == "" || gover.IsToolchain(path) { + return + } + + if !modcacherwSeen && base.InGOFLAGS("-modcacherw") { + fs := flag.NewFlagSet("goInstallVersion", flag.ExitOnError) + fs.Var(modcacherwVal, "modcacherw", modcacherwFlag.Usage) + base.SetFromGOFLAGS(fs) + } + + // It would be correct to do nothing here, and let "go run" or "go install" + // do the toolchain switch. + // Our goal instead is, since we have gone to the trouble of handling + // unknown flags to some degree, to run the switch now, so that + // these commands can switch to a newer toolchain directed by the + // go.mod which may actually understand the flag. + // This was brought up during the go.dev/issue/57001 proposal discussion + // and may end up being common in self-contained "go install" or "go run" + // command lines if we add new flags in the future. + + // Set up modules without an explicit go.mod, to download go.mod. + loaderstate.ForceUseModules = true + loaderstate.RootMode = modload.NoRoot + modload.Init(loaderstate) + defer loaderstate.Reset() + + // See internal/load.PackagesAndErrorsOutsideModule + ctx := context.Background() + allowed := loaderstate.CheckAllowed + if modload.IsRevisionQuery(path, version) { + // Don't check for retractions if a specific revision is requested. + allowed = nil + } + noneSelected := func(path string) (version string) { return "none" } + _, err = modload.QueryPackages(loaderstate, ctx, path, version, noneSelected, allowed) + if errors.Is(err, gover.ErrTooNew) { + // Run early switch, same one go install or go run would eventually do, + // if it understood all the command-line flags. + s := NewSwitcher(loaderstate) + s.Error(err) + if s.TooNew != nil && gover.Compare(s.TooNew.GoVersion, minVers) > 0 { + SwitchOrFatal(loaderstate, ctx, err) + } + } +} diff --git a/go/src/cmd/go/internal/toolchain/switch.go b/go/src/cmd/go/internal/toolchain/switch.go new file mode 100644 index 0000000000000000000000000000000000000000..ff4fce03074832249f5d4b287b29fd989a2a1c6f --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/switch.go @@ -0,0 +1,246 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package toolchain + +import ( + "context" + "fmt" + "os" + "path/filepath" + "sort" + "strings" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/gover" + "cmd/go/internal/modfetch" + "cmd/go/internal/modload" + "cmd/internal/telemetry/counter" +) + +// A Switcher collects errors to be reported and then decides +// between reporting the errors or switching to a new toolchain +// to resolve them. +// +// The client calls [Switcher.Error] repeatedly with errors encountered +// and then calls [Switcher.Switch]. If the errors included any +// *gover.TooNewErrors (potentially wrapped) and switching is +// permitted by GOTOOLCHAIN, Switch switches to a new toolchain. +// Otherwise Switch prints all the errors using base.Error. +// +// See https://go.dev/doc/toolchain#switch. +type Switcher struct { + TooNew *gover.TooNewError // max go requirement observed + Errors []error // errors collected so far + loaderstate *modload.State // temporarily here while we eliminate global module loader state +} + +func NewSwitcher(s *modload.State) *Switcher { + sw := new(Switcher) + sw.loaderstate = s + return sw +} + +// Error reports the error to the Switcher, +// which saves it for processing during Switch. +func (s *Switcher) Error(err error) { + s.Errors = append(s.Errors, err) + s.addTooNew(err) +} + +// addTooNew adds any TooNew errors that can be found in err. +func (s *Switcher) addTooNew(err error) { + switch err := err.(type) { + case interface{ Unwrap() []error }: + for _, e := range err.Unwrap() { + s.addTooNew(e) + } + + case interface{ Unwrap() error }: + s.addTooNew(err.Unwrap()) + + case *gover.TooNewError: + if s.TooNew == nil || + gover.Compare(err.GoVersion, s.TooNew.GoVersion) > 0 || + gover.Compare(err.GoVersion, s.TooNew.GoVersion) == 0 && err.What < s.TooNew.What { + s.TooNew = err + } + } +} + +// NeedSwitch reports whether Switch would attempt to switch toolchains. +func (s *Switcher) NeedSwitch() bool { + return s.TooNew != nil && (HasAuto() || HasPath()) +} + +// Switch decides whether to switch to a newer toolchain +// to resolve any of the saved errors. +// It switches if toolchain switches are permitted and there is at least one TooNewError. +// +// If Switch decides not to switch toolchains, it prints the errors using base.Error and returns. +// +// If Switch decides to switch toolchains but cannot identify a toolchain to use. +// it prints the errors along with one more about not being able to find the toolchain +// and returns. +// +// Otherwise, Switch prints an informational message giving a reason for the +// switch and the toolchain being invoked and then switches toolchains. +// This operation never returns. +func (s *Switcher) Switch(ctx context.Context) { + if !s.NeedSwitch() { + for _, err := range s.Errors { + base.Error(err) + } + return + } + + // Switch to newer Go toolchain if necessary and possible. + tv, err := NewerToolchain(ctx, s.loaderstate.Fetcher(), s.TooNew.GoVersion) + if err != nil { + for _, err := range s.Errors { + base.Error(err) + } + base.Error(fmt.Errorf("switching to go >= %v: %w", s.TooNew.GoVersion, err)) + return + } + + fmt.Fprintf(os.Stderr, "go: %v requires go >= %v; switching to %v\n", s.TooNew.What, s.TooNew.GoVersion, tv) + counterSwitchExec.Inc() + Exec(s.loaderstate, tv) + panic("unreachable") +} + +var counterSwitchExec = counter.New("go/toolchain/switch-exec") + +// SwitchOrFatal attempts a toolchain switch based on the information in err +// and otherwise falls back to base.Fatal(err). +func SwitchOrFatal(loaderstate *modload.State, ctx context.Context, err error) { + s := NewSwitcher(loaderstate) + s.Error(err) + s.Switch(ctx) + base.Exit() +} + +// NewerToolchain returns the name of the toolchain to use when we need +// to switch to a newer toolchain that must support at least the given Go version. +// See https://go.dev/doc/toolchain#switch. +// +// If the latest major release is 1.N.0, we use the latest patch release of 1.(N-1) if that's >= version. +// Otherwise we use the latest 1.N if that's allowed. +// Otherwise we use the latest release. +func NewerToolchain(ctx context.Context, f *modfetch.Fetcher, version string) (string, error) { + fetch := func(ctx context.Context) ([]string, error) { + return autoToolchains(ctx, f) + } + + if !HasAuto() { + fetch = pathToolchains + } + list, err := fetch(ctx) + if err != nil { + return "", err + } + return newerToolchain(version, list) +} + +// autoToolchains returns the list of toolchain versions available to GOTOOLCHAIN=auto or =min+auto mode. +func autoToolchains(ctx context.Context, f *modfetch.Fetcher) ([]string, error) { + var versions *modfetch.Versions + err := modfetch.TryProxies(func(proxy string) error { + v, err := f.Lookup(ctx, proxy, "go").Versions(ctx, "") + if err != nil { + return err + } + versions = v + return nil + }) + if err != nil { + return nil, err + } + return versions.List, nil +} + +// pathToolchains returns the list of toolchain versions available to GOTOOLCHAIN=path or =min+path mode. +func pathToolchains(ctx context.Context) ([]string, error) { + have := make(map[string]bool) + var list []string + for _, dir := range pathDirs() { + if dir == "" || !filepath.IsAbs(dir) { + // Refuse to use local directories in $PATH (hard-coding exec.ErrDot). + continue + } + entries, err := os.ReadDir(dir) + if err != nil { + continue + } + for _, de := range entries { + if de.IsDir() || !strings.HasPrefix(de.Name(), "go1.") { + continue + } + info, err := de.Info() + if err != nil { + continue + } + v, ok := pathVersion(dir, de, info) + if !ok || !strings.HasPrefix(v, "1.") || have[v] { + continue + } + have[v] = true + list = append(list, v) + } + } + sort.Slice(list, func(i, j int) bool { + return gover.Compare(list[i], list[j]) < 0 + }) + return list, nil +} + +// newerToolchain implements NewerToolchain where the list of choices is known. +// It is separated out for easier testing of this logic. +func newerToolchain(need string, list []string) (string, error) { + // Consider each release in the list, from newest to oldest, + // considering only entries >= need and then only entries + // that are the latest in their language family + // (the latest 1.40, the latest 1.39, and so on). + // We prefer the latest patch release before the most recent release family, + // so if the latest release is 1.40.1 we'll take the latest 1.39.X. + // Failing that, we prefer the latest patch release before the most recent + // prerelease family, so if the latest release is 1.40rc1 is out but 1.39 is okay, + // we'll still take 1.39.X. + // Failing that we'll take the latest release. + latest := "" + for i := len(list) - 1; i >= 0; i-- { + v := list[i] + if gover.Compare(v, need) < 0 { + break + } + if gover.Lang(latest) == gover.Lang(v) { + continue + } + newer := latest + latest = v + if newer != "" && !gover.IsPrerelease(newer) { + // latest is the last patch release of Go 1.X, and we saw a non-prerelease of Go 1.(X+1), + // so latest is the one we want. + break + } + } + if latest == "" { + return "", fmt.Errorf("no releases found for go >= %v", need) + } + return "go" + latest, nil +} + +// HasAuto reports whether the GOTOOLCHAIN setting allows "auto" upgrades. +func HasAuto() bool { + env := cfg.Getenv("GOTOOLCHAIN") + return env == "auto" || strings.HasSuffix(env, "+auto") +} + +// HasPath reports whether the GOTOOLCHAIN setting allows "path" upgrades. +func HasPath() bool { + env := cfg.Getenv("GOTOOLCHAIN") + return env == "path" || strings.HasSuffix(env, "+path") +} diff --git a/go/src/cmd/go/internal/toolchain/toolchain_test.go b/go/src/cmd/go/internal/toolchain/toolchain_test.go new file mode 100644 index 0000000000000000000000000000000000000000..e8ed5664e11b9242c55ff3fe2d162d281522c9bd --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/toolchain_test.go @@ -0,0 +1,66 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package toolchain + +import ( + "strings" + "testing" +) + +func TestNewerToolchain(t *testing.T) { + for _, tt := range newerToolchainTests { + out, err := newerToolchain(tt.need, tt.list) + if (err != nil) != (out == "") { + t.Errorf("newerToolchain(%v, %v) = %v, %v, want error", tt.need, tt.list, out, err) + continue + } + if out != tt.out { + t.Errorf("newerToolchain(%v, %v) = %v, %v want %v, nil", tt.need, tt.list, out, err, tt.out) + } + } +} + +var f = strings.Fields + +var relRC = []string{"1.39.0", "1.39.1", "1.39.2", "1.40.0", "1.40.1", "1.40.2", "1.41rc1"} +var rel2 = []string{"1.39.0", "1.39.1", "1.39.2", "1.40.0", "1.40.1", "1.40.2"} +var rel0 = []string{"1.39.0", "1.39.1", "1.39.2", "1.40.0"} +var newerToolchainTests = []struct { + need string + list []string + out string +}{ + {"1.30", rel0, "go1.39.2"}, + {"1.30", rel2, "go1.39.2"}, + {"1.30", relRC, "go1.39.2"}, + {"1.38", rel0, "go1.39.2"}, + {"1.38", rel2, "go1.39.2"}, + {"1.38", relRC, "go1.39.2"}, + {"1.38.1", rel0, "go1.39.2"}, + {"1.38.1", rel2, "go1.39.2"}, + {"1.38.1", relRC, "go1.39.2"}, + {"1.39", rel0, "go1.39.2"}, + {"1.39", rel2, "go1.39.2"}, + {"1.39", relRC, "go1.39.2"}, + {"1.39.2", rel0, "go1.39.2"}, + {"1.39.2", rel2, "go1.39.2"}, + {"1.39.2", relRC, "go1.39.2"}, + {"1.39.3", rel0, "go1.40.0"}, + {"1.39.3", rel2, "go1.40.2"}, + {"1.39.3", relRC, "go1.40.2"}, + {"1.40", rel0, "go1.40.0"}, + {"1.40", rel2, "go1.40.2"}, + {"1.40", relRC, "go1.40.2"}, + {"1.40.1", rel0, ""}, + {"1.40.1", rel2, "go1.40.2"}, + {"1.40.1", relRC, "go1.40.2"}, + {"1.41", rel0, ""}, + {"1.41", rel2, ""}, + {"1.41", relRC, "go1.41rc1"}, + {"1.41.0", rel0, ""}, + {"1.41.0", rel2, ""}, + {"1.41.0", relRC, ""}, + {"1.40", nil, ""}, +} diff --git a/go/src/cmd/go/internal/toolchain/umask_none.go b/go/src/cmd/go/internal/toolchain/umask_none.go new file mode 100644 index 0000000000000000000000000000000000000000..b092fe8b7dd51bfd1f5d231f7bef90d94002ae13 --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/umask_none.go @@ -0,0 +1,13 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !(darwin || freebsd || linux || netbsd || openbsd) + +package toolchain + +import "io/fs" + +func sysWriteBits() fs.FileMode { + return 0700 +} diff --git a/go/src/cmd/go/internal/toolchain/umask_unix.go b/go/src/cmd/go/internal/toolchain/umask_unix.go new file mode 100644 index 0000000000000000000000000000000000000000..cbe4307311f806a64f5c02d8cd7c5ce5c69b986f --- /dev/null +++ b/go/src/cmd/go/internal/toolchain/umask_unix.go @@ -0,0 +1,28 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build darwin || freebsd || linux || netbsd || openbsd + +package toolchain + +import ( + "io/fs" + "syscall" +) + +// sysWriteBits determines which bits to OR into the mode to make a directory writable. +// It must be called when there are no other file system operations happening. +func sysWriteBits() fs.FileMode { + // Read current umask. There's no way to read it without also setting it, + // so set it conservatively and then restore the original one. + m := syscall.Umask(0o777) + syscall.Umask(m) // restore bits + if m&0o22 == 0o22 { // group and world are unwritable by default + return 0o700 + } + if m&0o2 == 0o2 { // group is writable by default, but not world + return 0o770 + } + return 0o777 // everything is writable by default +} diff --git a/go/src/cmd/go/internal/trace/trace.go b/go/src/cmd/go/internal/trace/trace.go new file mode 100644 index 0000000000000000000000000000000000000000..f96aa40002e76f0769e5d4869c72a0bc1d05346f --- /dev/null +++ b/go/src/cmd/go/internal/trace/trace.go @@ -0,0 +1,206 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package trace + +import ( + "context" + "encoding/json" + "errors" + "internal/trace/traceviewer/format" + "os" + "strings" + "sync/atomic" + "time" +) + +// Constants used in event fields. +// See https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU +// for more details. +const ( + phaseDurationBegin = "B" + phaseDurationEnd = "E" + phaseFlowStart = "s" + phaseFlowEnd = "f" + + bindEnclosingSlice = "e" +) + +var traceStarted atomic.Bool + +func getTraceContext(ctx context.Context) (traceContext, bool) { + if !traceStarted.Load() { + return traceContext{}, false + } + v := ctx.Value(traceKey{}) + if v == nil { + return traceContext{}, false + } + return v.(traceContext), true +} + +// StartSpan starts a trace event with the given name. The Span ends when its Done method is called. +func StartSpan(ctx context.Context, name string) (context.Context, *Span) { + tc, ok := getTraceContext(ctx) + if !ok { + return ctx, nil + } + childSpan := &Span{t: tc.t, name: name, tid: tc.tid, start: time.Now()} + tc.t.writeEvent(&format.Event{ + Name: childSpan.name, + Time: float64(childSpan.start.UnixNano()) / float64(time.Microsecond), + TID: childSpan.tid, + Phase: phaseDurationBegin, + }) + ctx = context.WithValue(ctx, traceKey{}, traceContext{tc.t, tc.tid}) + return ctx, childSpan +} + +// StartGoroutine associates the context with a new Thread ID. The Chrome trace viewer associates each +// trace event with a thread, and doesn't expect events with the same thread id to happen at the +// same time. +func StartGoroutine(ctx context.Context) context.Context { + tc, ok := getTraceContext(ctx) + if !ok { + return ctx + } + return context.WithValue(ctx, traceKey{}, traceContext{tc.t, tc.t.getNextTID()}) +} + +// Flow marks a flow indicating that the 'to' span depends on the 'from' span. +// Flow should be called while the 'to' span is in progress. +func Flow(ctx context.Context, from *Span, to *Span) { + tc, ok := getTraceContext(ctx) + if !ok || from == nil || to == nil { + return + } + + id := tc.t.getNextFlowID() + tc.t.writeEvent(&format.Event{ + Name: from.name + " -> " + to.name, + Category: "flow", + ID: id, + Time: float64(from.end.UnixNano()) / float64(time.Microsecond), + Phase: phaseFlowStart, + TID: from.tid, + }) + tc.t.writeEvent(&format.Event{ + Name: from.name + " -> " + to.name, + Category: "flow", // TODO(matloob): Add Category to Flow? + ID: id, + Time: float64(to.start.UnixNano()) / float64(time.Microsecond), + Phase: phaseFlowEnd, + TID: to.tid, + BindPoint: bindEnclosingSlice, + }) +} + +type Span struct { + t *tracer + + name string + tid uint64 + start time.Time + end time.Time +} + +func (s *Span) Done() { + if s == nil { + return + } + s.end = time.Now() + s.t.writeEvent(&format.Event{ + Name: s.name, + Time: float64(s.end.UnixNano()) / float64(time.Microsecond), + TID: s.tid, + Phase: phaseDurationEnd, + }) +} + +type tracer struct { + file chan traceFile // 1-buffered + + nextTID atomic.Uint64 + nextFlowID atomic.Uint64 +} + +func (t *tracer) writeEvent(ev *format.Event) error { + f := <-t.file + defer func() { t.file <- f }() + var err error + if f.entries == 0 { + _, err = f.sb.WriteString("[\n") + } else { + _, err = f.sb.WriteString(",") + } + f.entries++ + if err != nil { + return nil + } + + if err := f.enc.Encode(ev); err != nil { + return err + } + + // Write event string to output file. + _, err = f.f.WriteString(f.sb.String()) + f.sb.Reset() + return err +} + +func (t *tracer) Close() error { + f := <-t.file + defer func() { t.file <- f }() + + _, firstErr := f.f.WriteString("]") + if err := f.f.Close(); firstErr == nil { + firstErr = err + } + return firstErr +} + +func (t *tracer) getNextTID() uint64 { + return t.nextTID.Add(1) +} + +func (t *tracer) getNextFlowID() uint64 { + return t.nextFlowID.Add(1) +} + +// traceKey is the context key for tracing information. It is unexported to prevent collisions with context keys defined in +// other packages. +type traceKey struct{} + +type traceContext struct { + t *tracer + tid uint64 +} + +// Start starts a trace which writes to the given file. +func Start(ctx context.Context, file string) (context.Context, func() error, error) { + traceStarted.Store(true) + if file == "" { + return nil, nil, errors.New("no trace file supplied") + } + f, err := os.Create(file) + if err != nil { + return nil, nil, err + } + t := &tracer{file: make(chan traceFile, 1)} + sb := new(strings.Builder) + t.file <- traceFile{ + f: f, + sb: sb, + enc: json.NewEncoder(sb), + } + ctx = context.WithValue(ctx, traceKey{}, traceContext{t: t}) + return ctx, t.Close, nil +} + +type traceFile struct { + f *os.File + sb *strings.Builder + enc *json.Encoder + entries int64 +} diff --git a/go/src/cmd/go/internal/vcs/discovery.go b/go/src/cmd/go/internal/vcs/discovery.go new file mode 100644 index 0000000000000000000000000000000000000000..8129fd408203c4b9cf6436b7aba0c5d7ab741cc3 --- /dev/null +++ b/go/src/cmd/go/internal/vcs/discovery.go @@ -0,0 +1,102 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcs + +import ( + "encoding/xml" + "fmt" + "io" + "strings" +) + +// charsetReader returns a reader that converts from the given charset to UTF-8. +// Currently it only supports UTF-8 and ASCII. Otherwise, it returns a meaningful +// error which is printed by go get, so the user can find why the package +// wasn't downloaded if the encoding is not supported. Note that, in +// order to reduce potential errors, ASCII is treated as UTF-8 (i.e. characters +// greater than 0x7f are not rejected). +func charsetReader(charset string, input io.Reader) (io.Reader, error) { + switch strings.ToLower(charset) { + case "utf-8", "ascii": + return input, nil + default: + return nil, fmt.Errorf("can't decode XML document using charset %q", charset) + } +} + +// parseMetaGoImports returns meta imports from the HTML in r. +// Parsing ends at the end of the section or the beginning of the . +func parseMetaGoImports(r io.Reader, mod ModuleMode) ([]metaImport, error) { + d := xml.NewDecoder(r) + d.CharsetReader = charsetReader + d.Strict = false + var imports []metaImport + for { + t, err := d.RawToken() + if err != nil { + if err != io.EOF && len(imports) == 0 { + return nil, err + } + break + } + if e, ok := t.(xml.StartElement); ok && strings.EqualFold(e.Name.Local, "body") { + break + } + if e, ok := t.(xml.EndElement); ok && strings.EqualFold(e.Name.Local, "head") { + break + } + e, ok := t.(xml.StartElement) + if !ok || !strings.EqualFold(e.Name.Local, "meta") { + continue + } + if attrValue(e.Attr, "name") != "go-import" { + continue + } + if f := strings.Fields(attrValue(e.Attr, "content")); len(f) == 3 || len(f) == 4 { + mi := metaImport{ + Prefix: f[0], + VCS: f[1], + RepoRoot: f[2], + } + // An optional subdirectory may be provided. + if len(f) == 4 { + mi.SubDir = f[3] + } + imports = append(imports, mi) + } + } + + // Extract mod entries if we are paying attention to them. + var list []metaImport + var have map[string]bool + if mod == PreferMod { + have = make(map[string]bool) + for _, m := range imports { + if m.VCS == "mod" { + have[m.Prefix] = true + list = append(list, m) + } + } + } + + // Append non-mod entries, ignoring those superseded by a mod entry. + for _, m := range imports { + if m.VCS != "mod" && !have[m.Prefix] { + list = append(list, m) + } + } + return list, nil +} + +// attrValue returns the attribute value for the case-insensitive key +// `name`, or the empty string if nothing is found. +func attrValue(attrs []xml.Attr, name string) string { + for _, a := range attrs { + if strings.EqualFold(a.Name.Local, name) { + return a.Value + } + } + return "" +} diff --git a/go/src/cmd/go/internal/vcs/discovery_test.go b/go/src/cmd/go/internal/vcs/discovery_test.go new file mode 100644 index 0000000000000000000000000000000000000000..e03eeaaa4c182c0b55b9e62c6d18263907113894 --- /dev/null +++ b/go/src/cmd/go/internal/vcs/discovery_test.go @@ -0,0 +1,120 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcs + +import ( + "reflect" + "strings" + "testing" +) + +var parseMetaGoImportsTests = []struct { + in string + mod ModuleMode + out []metaImport +}{ + { + ``, + IgnoreMod, + []metaImport{{"foo/bar", "git", "https://github.com/rsc/foo/bar", ""}}, + }, + { + ` + `, + IgnoreMod, + []metaImport{ + {"foo/bar", "git", "https://github.com/rsc/foo/bar", ""}, + {"baz/quux", "git", "http://github.com/rsc/baz/quux", ""}, + }, + }, + { + ` + `, + IgnoreMod, + []metaImport{ + {"foo/bar", "git", "https://github.com/rsc/foo/bar", ""}, + }, + }, + { + ` + `, + IgnoreMod, + []metaImport{ + {"foo/bar", "git", "https://github.com/rsc/foo/bar", ""}, + }, + }, + { + ` + `, + PreferMod, + []metaImport{ + {"foo/bar", "mod", "http://github.com/rsc/baz/quux", ""}, + }, + }, + { + ` + + `, + IgnoreMod, + []metaImport{{"foo/bar", "git", "https://github.com/rsc/foo/bar", ""}}, + }, + { + ` + `, + IgnoreMod, + []metaImport{{"foo/bar", "git", "https://github.com/rsc/foo/bar", ""}}, + }, + { + ``, + IgnoreMod, + []metaImport{{"foo/bar", "git", "https://github.com/rsc/foo/bar", ""}}, + }, + { + // XML doesn't like
    . + `Page Not Found
    DRAFT
    `, + IgnoreMod, + []metaImport{{"chitin.io/chitin", "git", "https://github.com/chitin-io/chitin", ""}}, + }, + { + ` + + `, + IgnoreMod, + []metaImport{{"myitcv.io", "git", "https://github.com/myitcv/x", ""}}, + }, + { + ` + + `, + PreferMod, + []metaImport{ + {"myitcv.io/blah2", "mod", "https://raw.githubusercontent.com/myitcv/pubx/master", ""}, + {"myitcv.io", "git", "https://github.com/myitcv/x", ""}, + }, + }, + { + ``, + IgnoreMod, + []metaImport{{"foo/bar", "git", "https://github.com/rsc/foo/bar", "subdir"}}, + }, + { + ``, + IgnoreMod, + []metaImport{{"foo/bar", "git", "https://github.com/rsc/foo/bar", "subdir/path"}}, + }, +} + +func TestParseMetaGoImports(t *testing.T) { + for i, tt := range parseMetaGoImportsTests { + out, err := parseMetaGoImports(strings.NewReader(tt.in), tt.mod) + if err != nil { + t.Errorf("test#%d: %v", i, err) + continue + } + if !reflect.DeepEqual(out, tt.out) { + t.Errorf("test#%d:\n\thave %q\n\twant %q", i, out, tt.out) + } + } +} diff --git a/go/src/cmd/go/internal/vcs/vcs.go b/go/src/cmd/go/internal/vcs/vcs.go new file mode 100644 index 0000000000000000000000000000000000000000..9e8efaf20634cca7540350f4ce3830d6cc6879ac --- /dev/null +++ b/go/src/cmd/go/internal/vcs/vcs.go @@ -0,0 +1,1428 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcs + +import ( + "bytes" + "errors" + "fmt" + "internal/godebug" + "internal/lazyregexp" + "internal/singleflight" + "io/fs" + "log" + urlpkg "net/url" + "os" + "os/exec" + "path/filepath" + "strconv" + "strings" + "sync" + "time" + + "cmd/go/internal/base" + "cmd/go/internal/cfg" + "cmd/go/internal/search" + "cmd/go/internal/str" + "cmd/go/internal/web" + "cmd/internal/pathcache" + + "golang.org/x/mod/module" +) + +// A Cmd describes how to use a version control system +// like Mercurial, Git, or Subversion. +type Cmd struct { + Name string + Cmd string // name of binary to invoke command + Env []string // any environment values to set/override + RootNames []rootName // filename and mode indicating the root of a checkout directory + + Scheme []string + PingCmd string + + Status func(v *Cmd, rootDir string) (Status, error) +} + +// Status is the current state of a local repository. +type Status struct { + Revision string // Optional. + CommitTime time.Time // Optional. + Uncommitted bool // Required. +} + +var ( + // VCSTestRepoURL is the URL of the HTTP server that serves the repos for + // vcs-test.golang.org. + // + // In tests, this is set to the URL of an httptest.Server hosting a + // cmd/go/internal/vcweb.Server. + VCSTestRepoURL string + + // VCSTestHosts is the set of hosts supported by the vcs-test server. + VCSTestHosts []string + + // VCSTestIsLocalHost reports whether the given URL refers to a local + // (loopback) host, such as "localhost" or "127.0.0.1:8080". + VCSTestIsLocalHost func(*urlpkg.URL) bool +) + +var defaultSecureScheme = map[string]bool{ + "https": true, + "git+ssh": true, + "bzr+ssh": true, + "svn+ssh": true, + "ssh": true, +} + +func (v *Cmd) IsSecure(repo string) bool { + u, err := urlpkg.Parse(repo) + if err != nil { + // If repo is not a URL, it's not secure. + return false + } + if VCSTestRepoURL != "" && web.IsLocalHost(u) { + // If the vcstest server is in use, it may redirect to other local ports for + // other protocols (such as svn). Assume that all loopback addresses are + // secure during testing. + return true + } + return v.isSecureScheme(u.Scheme) +} + +func (v *Cmd) isSecureScheme(scheme string) bool { + switch v.Cmd { + case "git": + // GIT_ALLOW_PROTOCOL is an environment variable defined by Git. It is a + // colon-separated list of schemes that are allowed to be used with git + // fetch/clone. Any scheme not mentioned will be considered insecure. + if allow := os.Getenv("GIT_ALLOW_PROTOCOL"); allow != "" { + for s := range strings.SplitSeq(allow, ":") { + if s == scheme { + return true + } + } + return false + } + } + return defaultSecureScheme[scheme] +} + +// A tagCmd describes a command to list available tags +// that can be passed to tagSyncCmd. +type tagCmd struct { + cmd string // command to list tags + pattern string // regexp to extract tags from list +} + +// vcsList lists the known version control systems +var vcsList = []*Cmd{ + vcsHg, + vcsGit, + vcsSvn, + vcsBzr, + vcsFossil, +} + +// vcsMod is a stub for the "mod" scheme. It's returned by +// repoRootForImportPathDynamic, but is otherwise not treated as a VCS command. +var vcsMod = &Cmd{Name: "mod"} + +// vcsByCmd returns the version control system for the given +// command name (hg, git, svn, bzr). +func vcsByCmd(cmd string) *Cmd { + for _, vcs := range vcsList { + if vcs.Cmd == cmd { + return vcs + } + } + return nil +} + +// vcsHg describes how to use Mercurial. +var vcsHg = &Cmd{ + Name: "Mercurial", + Cmd: "hg", + + // HGPLAIN=+strictflags turns off additional output that a user may have + // enabled via config options or certain extensions. + Env: []string{"HGPLAIN=+strictflags"}, + RootNames: []rootName{ + {filename: ".hg", isDir: true}, + }, + + Scheme: []string{"https", "http", "ssh"}, + PingCmd: "identify -- {scheme}://{repo}", + Status: hgStatus, +} + +func hgStatus(vcsHg *Cmd, rootDir string) (Status, error) { + // Output changeset ID and seconds since epoch. + out, err := vcsHg.runOutputVerboseOnly(rootDir, `log -r. -T {node}:{date|hgdate}`) + if err != nil { + return Status{}, err + } + + var rev string + var commitTime time.Time + if len(out) > 0 { + // Strip trailing timezone offset. + if i := bytes.IndexByte(out, ' '); i > 0 { + out = out[:i] + } + rev, commitTime, err = parseRevTime(out) + if err != nil { + return Status{}, err + } + } + + // Also look for untracked files. + out, err = vcsHg.runOutputVerboseOnly(rootDir, "status -S") + if err != nil { + return Status{}, err + } + uncommitted := len(out) > 0 + + return Status{ + Revision: rev, + CommitTime: commitTime, + Uncommitted: uncommitted, + }, nil +} + +// parseRevTime parses commit details in "revision:seconds" format. +func parseRevTime(out []byte) (string, time.Time, error) { + buf := string(bytes.TrimSpace(out)) + + i := strings.IndexByte(buf, ':') + if i < 1 { + return "", time.Time{}, errors.New("unrecognized VCS tool output") + } + rev := buf[:i] + + secs, err := strconv.ParseInt(buf[i+1:], 10, 64) + if err != nil { + return "", time.Time{}, fmt.Errorf("unrecognized VCS tool output: %v", err) + } + + return rev, time.Unix(secs, 0), nil +} + +// vcsGit describes how to use Git. +var vcsGit = &Cmd{ + Name: "Git", + Cmd: "git", + RootNames: []rootName{ + {filename: ".git", isDir: true}, + }, + + Scheme: []string{"git", "https", "http", "git+ssh", "ssh"}, + + // Leave out the '--' separator in the ls-remote command: git 2.7.4 does not + // support such a separator for that command, and this use should be safe + // without it because the {scheme} value comes from the predefined list above. + // See golang.org/issue/33836. + PingCmd: "ls-remote {scheme}://{repo}", + + Status: gitStatus, +} + +func gitStatus(vcsGit *Cmd, rootDir string) (Status, error) { + out, err := vcsGit.runOutputVerboseOnly(rootDir, "status --porcelain") + if err != nil { + return Status{}, err + } + uncommitted := len(out) > 0 + + // "git status" works for empty repositories, but "git log" does not. + // Assume there are no commits in the repo when "git log" fails with + // uncommitted files and skip tagging revision / committime. + var rev string + var commitTime time.Time + out, err = vcsGit.runOutputVerboseOnly(rootDir, "-c log.showsignature=false log -1 --format=%H:%ct") + if err != nil && !uncommitted { + return Status{}, err + } else if err == nil { + rev, commitTime, err = parseRevTime(out) + if err != nil { + return Status{}, err + } + } + + return Status{ + Revision: rev, + CommitTime: commitTime, + Uncommitted: uncommitted, + }, nil +} + +// vcsBzr describes how to use Bazaar. +var vcsBzr = &Cmd{ + Name: "Bazaar", + Cmd: "bzr", + RootNames: []rootName{ + {filename: ".bzr", isDir: true}, + }, + + Scheme: []string{"https", "http", "bzr", "bzr+ssh"}, + PingCmd: "info -- {scheme}://{repo}", + Status: bzrStatus, +} + +func bzrStatus(vcsBzr *Cmd, rootDir string) (Status, error) { + outb, err := vcsBzr.runOutputVerboseOnly(rootDir, "version-info") + if err != nil { + return Status{}, err + } + out := string(outb) + + // Expect (non-empty repositories only): + // + // revision-id: gopher@gopher.net-20211021072330-qshok76wfypw9lpm + // date: 2021-09-21 12:00:00 +1000 + // ... + var rev string + var commitTime time.Time + + for line := range strings.SplitSeq(out, "\n") { + i := strings.IndexByte(line, ':') + if i < 0 { + continue + } + key := line[:i] + value := strings.TrimSpace(line[i+1:]) + + switch key { + case "revision-id": + rev = value + case "date": + var err error + commitTime, err = time.Parse("2006-01-02 15:04:05 -0700", value) + if err != nil { + return Status{}, errors.New("unable to parse output of bzr version-info") + } + } + } + + outb, err = vcsBzr.runOutputVerboseOnly(rootDir, "status") + if err != nil { + return Status{}, err + } + + // Skip warning when working directory is set to an older revision. + if bytes.HasPrefix(outb, []byte("working tree is out of date")) { + i := bytes.IndexByte(outb, '\n') + if i < 0 { + i = len(outb) + } + outb = outb[:i] + } + uncommitted := len(outb) > 0 + + return Status{ + Revision: rev, + CommitTime: commitTime, + Uncommitted: uncommitted, + }, nil +} + +// vcsSvn describes how to use Subversion. +var vcsSvn = &Cmd{ + Name: "Subversion", + Cmd: "svn", + RootNames: []rootName{ + {filename: ".svn", isDir: true}, + }, + + // There is no tag command in subversion. + // The branch information is all in the path names. + + Scheme: []string{"https", "http", "svn", "svn+ssh"}, + PingCmd: "info -- {scheme}://{repo}", + Status: svnStatus, +} + +func svnStatus(vcsSvn *Cmd, rootDir string) (Status, error) { + out, err := vcsSvn.runOutputVerboseOnly(rootDir, "info --show-item last-changed-revision") + if err != nil { + return Status{}, err + } + rev := strings.TrimSpace(string(out)) + + out, err = vcsSvn.runOutputVerboseOnly(rootDir, "info --show-item last-changed-date") + if err != nil { + return Status{}, err + } + commitTime, err := time.Parse(time.RFC3339, strings.TrimSpace(string(out))) + if err != nil { + return Status{}, fmt.Errorf("unable to parse output of svn info: %v", err) + } + + out, err = vcsSvn.runOutputVerboseOnly(rootDir, "status") + if err != nil { + return Status{}, err + } + uncommitted := len(out) > 0 + + return Status{ + Revision: rev, + CommitTime: commitTime, + Uncommitted: uncommitted, + }, nil +} + +// fossilRepoName is the name go get associates with a fossil repository. In the +// real world the file can be named anything. +const fossilRepoName = ".fossil" + +// vcsFossil describes how to use Fossil (fossil-scm.org) +var vcsFossil = &Cmd{ + Name: "Fossil", + Cmd: "fossil", + RootNames: []rootName{ + {filename: ".fslckout", isDir: false}, + {filename: "_FOSSIL_", isDir: false}, + }, + + Scheme: []string{"https", "http"}, + Status: fossilStatus, +} + +var errFossilInfo = errors.New("unable to parse output of fossil info") + +func fossilStatus(vcsFossil *Cmd, rootDir string) (Status, error) { + outb, err := vcsFossil.runOutputVerboseOnly(rootDir, "info") + if err != nil { + return Status{}, err + } + out := string(outb) + + // Expect: + // ... + // checkout: 91ed71f22c77be0c3e250920f47bfd4e1f9024d2 2021-09-21 12:00:00 UTC + // ... + + // Extract revision and commit time. + // Ensure line ends with UTC (known timezone offset). + const prefix = "\ncheckout:" + const suffix = " UTC" + i := strings.Index(out, prefix) + if i < 0 { + return Status{}, errFossilInfo + } + checkout := out[i+len(prefix):] + i = strings.Index(checkout, suffix) + if i < 0 { + return Status{}, errFossilInfo + } + checkout = strings.TrimSpace(checkout[:i]) + + i = strings.IndexByte(checkout, ' ') + if i < 0 { + return Status{}, errFossilInfo + } + rev := checkout[:i] + + commitTime, err := time.ParseInLocation(time.DateTime, checkout[i+1:], time.UTC) + if err != nil { + return Status{}, fmt.Errorf("%v: %v", errFossilInfo, err) + } + + // Also look for untracked changes. + outb, err = vcsFossil.runOutputVerboseOnly(rootDir, "changes --differ") + if err != nil { + return Status{}, err + } + uncommitted := len(outb) > 0 + + return Status{ + Revision: rev, + CommitTime: commitTime, + Uncommitted: uncommitted, + }, nil +} + +func (v *Cmd) String() string { + return v.Name +} + +// run runs the command line cmd in the given directory. +// keyval is a list of key, value pairs. run expands +// instances of {key} in cmd into value, but only after +// splitting cmd into individual arguments. +// If an error occurs, run prints the command line and the +// command's combined stdout+stderr to standard error. +// Otherwise run discards the command's output. +func (v *Cmd) run(dir string, cmd string, keyval ...string) error { + _, err := v.run1(dir, cmd, keyval, true) + return err +} + +// runVerboseOnly is like run but only generates error output to standard error in verbose mode. +func (v *Cmd) runVerboseOnly(dir string, cmd string, keyval ...string) error { + _, err := v.run1(dir, cmd, keyval, false) + return err +} + +// runOutput is like run but returns the output of the command. +func (v *Cmd) runOutput(dir string, cmd string, keyval ...string) ([]byte, error) { + return v.run1(dir, cmd, keyval, true) +} + +// runOutputVerboseOnly is like runOutput but only generates error output to +// standard error in verbose mode. +func (v *Cmd) runOutputVerboseOnly(dir string, cmd string, keyval ...string) ([]byte, error) { + return v.run1(dir, cmd, keyval, false) +} + +// run1 is the generalized implementation of run and runOutput. +func (v *Cmd) run1(dir string, cmdline string, keyval []string, verbose bool) ([]byte, error) { + m := make(map[string]string) + for i := 0; i < len(keyval); i += 2 { + m[keyval[i]] = keyval[i+1] + } + args := strings.Fields(cmdline) + for i, arg := range args { + args[i] = expand(m, arg) + } + + if len(args) >= 2 && args[0] == "--go-internal-mkdir" { + var err error + if filepath.IsAbs(args[1]) { + err = os.Mkdir(args[1], fs.ModePerm) + } else { + err = os.Mkdir(filepath.Join(dir, args[1]), fs.ModePerm) + } + if err != nil { + return nil, err + } + args = args[2:] + } + + if len(args) >= 2 && args[0] == "--go-internal-cd" { + if filepath.IsAbs(args[1]) { + dir = args[1] + } else { + dir = filepath.Join(dir, args[1]) + } + args = args[2:] + } + + _, err := pathcache.LookPath(v.Cmd) + if err != nil { + fmt.Fprintf(os.Stderr, + "go: missing %s command. See https://golang.org/s/gogetcmd\n", + v.Name) + return nil, err + } + + cmd := exec.Command(v.Cmd, args...) + cmd.Dir = dir + if v.Env != nil { + cmd.Env = append(cmd.Environ(), v.Env...) + } + if cfg.BuildX { + fmt.Fprintf(os.Stderr, "cd %s\n", dir) + fmt.Fprintf(os.Stderr, "%s %s\n", v.Cmd, strings.Join(args, " ")) + } + out, err := cmd.Output() + if err != nil { + if verbose || cfg.BuildV { + fmt.Fprintf(os.Stderr, "# cd %s; %s %s\n", dir, v.Cmd, strings.Join(args, " ")) + if ee, ok := err.(*exec.ExitError); ok && len(ee.Stderr) > 0 { + os.Stderr.Write(ee.Stderr) + } else { + fmt.Fprintln(os.Stderr, err.Error()) + } + } + } + return out, err +} + +// Ping pings to determine scheme to use. +func (v *Cmd) Ping(scheme, repo string) error { + // Run the ping command in an arbitrary working directory, + // but don't let the current working directory pollute the results. + // In module mode, we expect GOMODCACHE to exist and be a safe place for + // commands; in GOPATH mode, we expect that to be true of GOPATH/src. + dir := cfg.GOMODCACHE + if !cfg.ModulesEnabled { + dir = filepath.Join(cfg.BuildContext.GOPATH, "src") + } + os.MkdirAll(dir, 0777) // Ignore errors — if unsuccessful, the command will likely fail. + + release, err := base.AcquireNet() + if err != nil { + return err + } + defer release() + + return v.runVerboseOnly(dir, v.PingCmd, "scheme", scheme, "repo", repo) +} + +// A vcsPath describes how to convert an import path into a +// version control system and repository name. +type vcsPath struct { + pathPrefix string // prefix this description applies to + regexp *lazyregexp.Regexp // compiled pattern for import path + repo string // repository to use (expand with match of re) + vcs string // version control system to use (expand with match of re) + check func(match map[string]string) error // additional checks + schemelessRepo bool // if true, the repo pattern lacks a scheme +} + +var allowmultiplevcs = godebug.New("allowmultiplevcs") + +// FromDir inspects dir and its parents to determine the +// version control system and code repository to use. +// If no repository is found, FromDir returns an error +// equivalent to os.ErrNotExist. +func FromDir(dir, srcRoot string) (repoDir string, vcsCmd *Cmd, err error) { + // Clean and double-check that dir is in (a subdirectory of) srcRoot. + dir = filepath.Clean(dir) + if srcRoot != "" { + srcRoot = filepath.Clean(srcRoot) + if len(dir) <= len(srcRoot) || dir[len(srcRoot)] != filepath.Separator { + return "", nil, fmt.Errorf("directory %q is outside source root %q", dir, srcRoot) + } + } + + origDir := dir + for len(dir) > len(srcRoot) { + for _, vcs := range vcsList { + if isVCSRoot(dir, vcs.RootNames) { + if vcsCmd == nil { + // Record first VCS we find. + vcsCmd = vcs + repoDir = dir + if allowmultiplevcs.Value() == "1" { + allowmultiplevcs.IncNonDefault() + return repoDir, vcsCmd, nil + } + // If allowmultiplevcs is not set, keep looking for + // repositories in current and parent directories and report + // an error if one is found to mitigate VCS injection + // attacks. + continue + } + if vcsCmd == vcsGit && vcs == vcsGit { + // Nested Git is allowed, as this is how things like + // submodules work. Git explicitly protects against + // injection against itself. + continue + } + return "", nil, fmt.Errorf("multiple VCS detected: %s in %q, and %s in %q", + vcsCmd.Cmd, repoDir, vcs.Cmd, dir) + } + } + + // Move to parent. + ndir := filepath.Dir(dir) + if len(ndir) >= len(dir) { + break + } + dir = ndir + } + if vcsCmd == nil { + return "", nil, &vcsNotFoundError{dir: origDir} + } + return repoDir, vcsCmd, nil +} + +// isVCSRoot identifies a VCS root by checking whether the directory contains +// any of the listed root names. +func isVCSRoot(dir string, rootNames []rootName) bool { + for _, root := range rootNames { + fi, err := os.Stat(filepath.Join(dir, root.filename)) + if err == nil && fi.IsDir() == root.isDir { + return true + } + } + + return false +} + +type rootName struct { + filename string + isDir bool +} + +type vcsNotFoundError struct { + dir string +} + +func (e *vcsNotFoundError) Error() string { + return fmt.Sprintf("directory %q is not using a known version control system", e.dir) +} + +func (e *vcsNotFoundError) Is(err error) bool { + return err == os.ErrNotExist +} + +// A govcsRule is a single GOVCS rule like private:hg|svn. +type govcsRule struct { + pattern string + allowed []string +} + +// A govcsConfig is a full GOVCS configuration. +type govcsConfig []govcsRule + +func parseGOVCS(s string) (govcsConfig, error) { + s = strings.TrimSpace(s) + if s == "" { + return nil, nil + } + var cfg govcsConfig + have := make(map[string]string) + for item := range strings.SplitSeq(s, ",") { + item = strings.TrimSpace(item) + if item == "" { + return nil, fmt.Errorf("empty entry in GOVCS") + } + pattern, list, found := strings.Cut(item, ":") + if !found { + return nil, fmt.Errorf("malformed entry in GOVCS (missing colon): %q", item) + } + pattern, list = strings.TrimSpace(pattern), strings.TrimSpace(list) + if pattern == "" { + return nil, fmt.Errorf("empty pattern in GOVCS: %q", item) + } + if list == "" { + return nil, fmt.Errorf("empty VCS list in GOVCS: %q", item) + } + if search.IsRelativePath(pattern) { + return nil, fmt.Errorf("relative pattern not allowed in GOVCS: %q", pattern) + } + if old := have[pattern]; old != "" { + return nil, fmt.Errorf("unreachable pattern in GOVCS: %q after %q", item, old) + } + have[pattern] = item + allowed := strings.Split(list, "|") + for i, a := range allowed { + a = strings.TrimSpace(a) + if a == "" { + return nil, fmt.Errorf("empty VCS name in GOVCS: %q", item) + } + allowed[i] = a + } + cfg = append(cfg, govcsRule{pattern, allowed}) + } + return cfg, nil +} + +func (c *govcsConfig) allow(path string, private bool, vcs string) bool { + for _, rule := range *c { + match := false + switch rule.pattern { + case "private": + match = private + case "public": + match = !private + default: + // Note: rule.pattern is known to be comma-free, + // so MatchPrefixPatterns is only matching a single pattern for us. + match = module.MatchPrefixPatterns(rule.pattern, path) + } + if !match { + continue + } + for _, allow := range rule.allowed { + if allow == vcs || allow == "all" { + return true + } + } + return false + } + + // By default, nothing is allowed. + return false +} + +var ( + govcs govcsConfig + govcsErr error + govcsOnce sync.Once +) + +// defaultGOVCS is the default setting for GOVCS. +// Setting GOVCS adds entries ahead of these but does not remove them. +// (They are appended to the parsed GOVCS setting.) +// +// The rationale behind allowing only Git and Mercurial is that +// these two systems have had the most attention to issues +// of being run as clients of untrusted servers. In contrast, +// Bazaar, Fossil, and Subversion have primarily been used +// in trusted, authenticated environments and are not as well +// scrutinized as attack surfaces. +// +// See golang.org/issue/41730 for details. +var defaultGOVCS = govcsConfig{ + {"private", []string{"all"}}, + {"public", []string{"git", "hg"}}, +} + +// checkGOVCS checks whether the policy defined by the environment variable +// GOVCS allows the given vcs command to be used with the given repository +// root path. Note that root may not be a real package or module path; it's +// the same as the root path in the go-import meta tag. +func checkGOVCS(vcs *Cmd, root string) error { + if vcs == vcsMod { + // Direct module (proxy protocol) fetches don't + // involve an external version control system + // and are always allowed. + return nil + } + + govcsOnce.Do(func() { + govcs, govcsErr = parseGOVCS(os.Getenv("GOVCS")) + govcs = append(govcs, defaultGOVCS...) + }) + if govcsErr != nil { + return govcsErr + } + + private := module.MatchPrefixPatterns(cfg.GOPRIVATE, root) + if !govcs.allow(root, private, vcs.Cmd) { + what := "public" + if private { + what = "private" + } + return fmt.Errorf("GOVCS disallows using %s for %s %s; see 'go help vcs'", vcs.Cmd, what, root) + } + + return nil +} + +// RepoRoot describes the repository root for a tree of source code. +type RepoRoot struct { + Repo string // repository URL, including scheme + Root string // import path corresponding to the SubDir + SubDir string // subdirectory within the repo (empty for root) + IsCustom bool // defined by served tags (as opposed to hard-coded pattern) + VCS *Cmd +} + +func httpPrefix(s string) string { + for _, prefix := range [...]string{"http:", "https:"} { + if strings.HasPrefix(s, prefix) { + return prefix + } + } + return "" +} + +// ModuleMode specifies whether to prefer modules when looking up code sources. +type ModuleMode int + +const ( + IgnoreMod ModuleMode = iota + PreferMod +) + +// RepoRootForImportPath analyzes importPath to determine the +// version control system, and code repository to use. +func RepoRootForImportPath(importPath string, mod ModuleMode, security web.SecurityMode) (*RepoRoot, error) { + rr, err := repoRootFromVCSPaths(importPath, security, vcsPaths) + if err == errUnknownSite { + rr, err = repoRootForImportDynamic(importPath, mod, security) + if err != nil { + err = importErrorf(importPath, "unrecognized import path %q: %v", importPath, err) + } + } + if err != nil { + rr1, err1 := repoRootFromVCSPaths(importPath, security, vcsPathsAfterDynamic) + if err1 == nil { + rr = rr1 + err = nil + } + } + + // Should have been taken care of above, but make sure. + if err == nil && strings.Contains(importPath, "...") && strings.Contains(rr.Root, "...") { + // Do not allow wildcards in the repo root. + rr = nil + err = importErrorf(importPath, "cannot expand ... in %q", importPath) + } + return rr, err +} + +var errUnknownSite = errors.New("dynamic lookup required to find mapping") + +// repoRootFromVCSPaths attempts to map importPath to a repoRoot +// using the mappings defined in vcsPaths. +func repoRootFromVCSPaths(importPath string, security web.SecurityMode, vcsPaths []*vcsPath) (*RepoRoot, error) { + if str.HasPathPrefix(importPath, "example.net") { + // TODO(rsc): This should not be necessary, but it's required to keep + // tests like ../../testdata/script/mod_get_extra.txt from using the network. + // That script has everything it needs in the replacement set, but it is still + // doing network calls. + return nil, fmt.Errorf("no modules on example.net") + } + if importPath == "rsc.io" { + // This special case allows tests like ../../testdata/script/govcs.txt + // to avoid making any network calls. The module lookup for a path + // like rsc.io/nonexist.svn/foo needs to not make a network call for + // a lookup on rsc.io. + return nil, fmt.Errorf("rsc.io is not a module") + } + // A common error is to use https://packagepath because that's what + // hg and git require. Diagnose this helpfully. + if prefix := httpPrefix(importPath); prefix != "" { + // The importPath has been cleaned, so has only one slash. The pattern + // ignores the slashes; the error message puts them back on the RHS at least. + return nil, fmt.Errorf("%q not allowed in import path", prefix+"//") + } + for _, srv := range vcsPaths { + if !str.HasPathPrefix(importPath, srv.pathPrefix) { + continue + } + m := srv.regexp.FindStringSubmatch(importPath) + if m == nil { + if srv.pathPrefix != "" { + return nil, importErrorf(importPath, "invalid %s import path %q", srv.pathPrefix, importPath) + } + continue + } + + // Build map of named subexpression matches for expand. + match := map[string]string{ + "prefix": srv.pathPrefix + "/", + "import": importPath, + } + for i, name := range srv.regexp.SubexpNames() { + if name != "" && match[name] == "" { + match[name] = m[i] + } + } + if srv.vcs != "" { + match["vcs"] = expand(match, srv.vcs) + } + if srv.repo != "" { + match["repo"] = expand(match, srv.repo) + } + if srv.check != nil { + if err := srv.check(match); err != nil { + return nil, err + } + } + vcs := vcsByCmd(match["vcs"]) + if vcs == nil { + return nil, fmt.Errorf("unknown version control system %q", match["vcs"]) + } + if err := checkGOVCS(vcs, match["root"]); err != nil { + return nil, err + } + var repoURL string + if !srv.schemelessRepo { + repoURL = match["repo"] + } else { + repo := match["repo"] + var ok bool + repoURL, ok = interceptVCSTest(repo, vcs, security) + if !ok { + scheme, err := func() (string, error) { + for _, s := range vcs.Scheme { + if security == web.SecureOnly && !vcs.isSecureScheme(s) { + continue + } + + // If we know how to ping URL schemes for this VCS, + // check that this repo works. + // Otherwise, default to the first scheme + // that meets the requested security level. + if vcs.PingCmd == "" { + return s, nil + } + if err := vcs.Ping(s, repo); err == nil { + return s, nil + } + } + securityFrag := "" + if security == web.SecureOnly { + securityFrag = "secure " + } + return "", fmt.Errorf("no %sprotocol found for repository", securityFrag) + }() + if err != nil { + return nil, err + } + repoURL = scheme + "://" + repo + } + } + rr := &RepoRoot{ + Repo: repoURL, + Root: match["root"], + VCS: vcs, + } + return rr, nil + } + return nil, errUnknownSite +} + +func interceptVCSTest(repo string, vcs *Cmd, security web.SecurityMode) (repoURL string, ok bool) { + if VCSTestRepoURL == "" { + return "", false + } + if vcs == vcsMod { + // Since the "mod" protocol is implemented internally, + // requests will be intercepted at a lower level (in cmd/go/internal/web). + return "", false + } + + if scheme, path, ok := strings.Cut(repo, "://"); ok { + if security == web.SecureOnly && !vcs.isSecureScheme(scheme) { + return "", false // Let the caller reject the original URL. + } + repo = path // Remove leading URL scheme if present. + } + for _, host := range VCSTestHosts { + if !str.HasPathPrefix(repo, host) { + continue + } + + httpURL := VCSTestRepoURL + strings.TrimPrefix(repo, host) + + if vcs == vcsSvn { + // Ping the vcweb HTTP server to tell it to initialize the SVN repository + // and get the SVN server URL. + u, err := urlpkg.Parse(httpURL + "?vcwebsvn=1") + if err != nil { + panic(fmt.Sprintf("invalid vcs-test repo URL: %v", err)) + } + svnURL, err := web.GetBytes(u) + svnURL = bytes.TrimSpace(svnURL) + if err == nil && len(svnURL) > 0 { + return string(svnURL) + strings.TrimPrefix(repo, host), true + } + + // vcs-test doesn't have a svn handler for the given path, + // so resolve the repo to HTTPS instead. + } + + return httpURL, true + } + return "", false +} + +// urlForImportPath returns a partially-populated URL for the given Go import path. +// +// The URL leaves the Scheme field blank so that web.Get will try any scheme +// allowed by the selected security mode. +func urlForImportPath(importPath string) (*urlpkg.URL, error) { + slash := strings.Index(importPath, "/") + if slash < 0 { + slash = len(importPath) + } + host, path := importPath[:slash], importPath[slash:] + if !strings.Contains(host, ".") { + return nil, errors.New("import path does not begin with hostname") + } + if len(path) == 0 { + path = "/" + } + return &urlpkg.URL{Host: host, Path: path, RawQuery: "go-get=1"}, nil +} + +// repoRootForImportDynamic finds a *RepoRoot for a custom domain that's not +// statically known by repoRootFromVCSPaths. +// +// This handles custom import paths like "name.tld/pkg/foo" or just "name.tld". +func repoRootForImportDynamic(importPath string, mod ModuleMode, security web.SecurityMode) (*RepoRoot, error) { + url, err := urlForImportPath(importPath) + if err != nil { + return nil, err + } + resp, err := web.Get(security, url) + if err != nil { + msg := "https fetch: %v" + if security == web.Insecure { + msg = "http/" + msg + } + return nil, fmt.Errorf(msg, err) + } + body := resp.Body + defer body.Close() + imports, err := parseMetaGoImports(body, mod) + if len(imports) == 0 { + if respErr := resp.Err(); respErr != nil { + // If the server's status was not OK, prefer to report that instead of + // an XML parse error. + return nil, respErr + } + } + if err != nil { + return nil, fmt.Errorf("parsing %s: %v", importPath, err) + } + // Find the matched meta import. + mmi, err := matchGoImport(imports, importPath) + if err != nil { + if _, ok := err.(ImportMismatchError); !ok { + return nil, fmt.Errorf("parse %s: %v", url, err) + } + return nil, fmt.Errorf("parse %s: no go-import meta tags (%s)", resp.URL, err) + } + if cfg.BuildV { + log.Printf("get %q: found meta tag %#v at %s", importPath, mmi, url) + } + // If the import was "uni.edu/bob/project", which said the + // prefix was "uni.edu" and the RepoRoot was "evilroot.com", + // make sure we don't trust Bob and check out evilroot.com to + // "uni.edu" yet (possibly overwriting/preempting another + // non-evil student). Instead, first verify the root and see + // if it matches Bob's claim. + if mmi.Prefix != importPath { + if cfg.BuildV { + log.Printf("get %q: verifying non-authoritative meta tag", importPath) + } + var imports []metaImport + url, imports, err = metaImportsForPrefix(mmi.Prefix, mod, security) + if err != nil { + return nil, err + } + metaImport2, err := matchGoImport(imports, importPath) + if err != nil || mmi != metaImport2 { + return nil, fmt.Errorf("%s and %s disagree about go-import for %s", resp.URL, url, mmi.Prefix) + } + } + + if err := validateRepoSubDir(mmi.SubDir); err != nil { + return nil, fmt.Errorf("%s: invalid subdirectory %q: %v", resp.URL, mmi.SubDir, err) + } + + if err := validateRepoRoot(mmi.RepoRoot); err != nil { + return nil, fmt.Errorf("%s: invalid repo root %q: %v", resp.URL, mmi.RepoRoot, err) + } + var vcs *Cmd + if mmi.VCS == "mod" { + vcs = vcsMod + } else { + vcs = vcsByCmd(mmi.VCS) + if vcs == nil { + return nil, fmt.Errorf("%s: unknown vcs %q", resp.URL, mmi.VCS) + } + } + + if err := checkGOVCS(vcs, mmi.Prefix); err != nil { + return nil, err + } + + repoURL, ok := interceptVCSTest(mmi.RepoRoot, vcs, security) + if !ok { + repoURL = mmi.RepoRoot + } + rr := &RepoRoot{ + Repo: repoURL, + Root: mmi.Prefix, + SubDir: mmi.SubDir, + IsCustom: true, + VCS: vcs, + } + return rr, nil +} + +// validateRepoSubDir returns an error if subdir is not a valid subdirectory path. +// We consider a subdirectory path to be valid as long as it doesn't have a leading +// slash (/) or hyphen (-). +func validateRepoSubDir(subdir string) error { + if subdir == "" { + return nil + } + if subdir[0] == '/' { + return errors.New("leading slash") + } + if subdir[0] == '-' { + return errors.New("leading hyphen") + } + return nil +} + +// validateRepoRoot returns an error if repoRoot does not seem to be +// a valid URL with scheme. +func validateRepoRoot(repoRoot string) error { + url, err := urlpkg.Parse(repoRoot) + if err != nil { + return err + } + if url.Scheme == "" { + return errors.New("no scheme") + } + if url.Scheme == "file" { + return errors.New("file scheme disallowed") + } + return nil +} + +var fetchGroup singleflight.Group +var ( + fetchCacheMu sync.Mutex + fetchCache = map[string]fetchResult{} // key is metaImportsForPrefix's importPrefix +) + +// metaImportsForPrefix takes a package's root import path as declared in a tag +// and returns its HTML discovery URL and the parsed metaImport lines +// found on the page. +// +// The importPath is of the form "golang.org/x/tools". +// It is an error if no imports are found. +// url will still be valid if err != nil. +// The returned url will be of the form "https://golang.org/x/tools?go-get=1" +func metaImportsForPrefix(importPrefix string, mod ModuleMode, security web.SecurityMode) (*urlpkg.URL, []metaImport, error) { + setCache := func(res fetchResult) (fetchResult, error) { + fetchCacheMu.Lock() + defer fetchCacheMu.Unlock() + fetchCache[importPrefix] = res + return res, nil + } + + resi, _, _ := fetchGroup.Do(importPrefix, func() (resi any, err error) { + fetchCacheMu.Lock() + if res, ok := fetchCache[importPrefix]; ok { + fetchCacheMu.Unlock() + return res, nil + } + fetchCacheMu.Unlock() + + url, err := urlForImportPath(importPrefix) + if err != nil { + return setCache(fetchResult{err: err}) + } + resp, err := web.Get(security, url) + if err != nil { + return setCache(fetchResult{url: url, err: fmt.Errorf("fetching %s: %v", importPrefix, err)}) + } + body := resp.Body + defer body.Close() + imports, err := parseMetaGoImports(body, mod) + if len(imports) == 0 { + if respErr := resp.Err(); respErr != nil { + // If the server's status was not OK, prefer to report that instead of + // an XML parse error. + return setCache(fetchResult{url: url, err: respErr}) + } + } + if err != nil { + return setCache(fetchResult{url: url, err: fmt.Errorf("parsing %s: %v", resp.URL, err)}) + } + if len(imports) == 0 { + err = fmt.Errorf("fetching %s: no go-import meta tag found in %s", importPrefix, resp.URL) + } + return setCache(fetchResult{url: url, imports: imports, err: err}) + }) + res := resi.(fetchResult) + return res.url, res.imports, res.err +} + +type fetchResult struct { + url *urlpkg.URL + imports []metaImport + err error +} + +// metaImport represents the parsed tags from HTML files. +type metaImport struct { + Prefix, VCS, RepoRoot, SubDir string +} + +// An ImportMismatchError is returned where metaImport/s are present +// but none match our import path. +type ImportMismatchError struct { + importPath string + mismatches []string // the meta imports that were discarded for not matching our importPath +} + +func (m ImportMismatchError) Error() string { + formattedStrings := make([]string, len(m.mismatches)) + for i, pre := range m.mismatches { + formattedStrings[i] = fmt.Sprintf("meta tag %s did not match import path %s", pre, m.importPath) + } + return strings.Join(formattedStrings, ", ") +} + +// matchGoImport returns the metaImport from imports matching importPath. +// An error is returned if there are multiple matches. +// An ImportMismatchError is returned if none match. +func matchGoImport(imports []metaImport, importPath string) (metaImport, error) { + match := -1 + + errImportMismatch := ImportMismatchError{importPath: importPath} + for i, im := range imports { + if !str.HasPathPrefix(importPath, im.Prefix) { + errImportMismatch.mismatches = append(errImportMismatch.mismatches, im.Prefix) + continue + } + + if match >= 0 { + if imports[match].VCS == "mod" && im.VCS != "mod" { + // All the mod entries precede all the non-mod entries. + // We have a mod entry and don't care about the rest, + // matching or not. + break + } + return metaImport{}, fmt.Errorf("multiple meta tags match import path %q", importPath) + } + match = i + } + + if match == -1 { + return metaImport{}, errImportMismatch + } + return imports[match], nil +} + +// expand rewrites s to replace {k} with match[k] for each key k in match. +func expand(match map[string]string, s string) string { + // We want to replace each match exactly once, and the result of expansion + // must not depend on the iteration order through the map. + // A strings.Replacer has exactly the properties we're looking for. + oldNew := make([]string, 0, 2*len(match)) + for k, v := range match { + oldNew = append(oldNew, "{"+k+"}", v) + } + return strings.NewReplacer(oldNew...).Replace(s) +} + +// vcsPaths defines the meaning of import paths referring to +// commonly-used VCS hosting sites (github.com/user/dir) +// and import paths referring to a fully-qualified importPath +// containing a VCS type (foo.com/repo.git/dir) +var vcsPaths = []*vcsPath{ + // GitHub + { + pathPrefix: "github.com", + regexp: lazyregexp.New(`^(?Pgithub\.com/[\w.\-]+/[\w.\-]+)(/[\w.\-]+)*$`), + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // Bitbucket + { + pathPrefix: "bitbucket.org", + regexp: lazyregexp.New(`^(?Pbitbucket\.org/(?P[\w.\-]+/[\w.\-]+))(/[\w.\-]+)*$`), + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // IBM DevOps Services (JazzHub) + { + pathPrefix: "hub.jazz.net/git", + regexp: lazyregexp.New(`^(?Phub\.jazz\.net/git/[a-z0-9]+/[\w.\-]+)(/[\w.\-]+)*$`), + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // Git at Apache + { + pathPrefix: "git.apache.org", + regexp: lazyregexp.New(`^(?Pgit\.apache\.org/[a-z0-9_.\-]+\.git)(/[\w.\-]+)*$`), + vcs: "git", + repo: "https://{root}", + }, + + // Git at OpenStack + { + pathPrefix: "git.openstack.org", + regexp: lazyregexp.New(`^(?Pgit\.openstack\.org/[\w.\-]+/[\w.\-]+)(\.git)?(/[\w.\-]+)*$`), + vcs: "git", + repo: "https://{root}", + }, + + // chiselapp.com for fossil + { + pathPrefix: "chiselapp.com", + regexp: lazyregexp.New(`^(?Pchiselapp\.com/user/[A-Za-z0-9]+/repository/[\w.\-]+)$`), + vcs: "fossil", + repo: "https://{root}", + }, + + // General syntax for any server. + // Must be last. + { + regexp: lazyregexp.New(`(?P(?P([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?(/~?[\w.\-]+)+?)\.(?Pbzr|fossil|git|hg|svn))(/~?[\w.\-]+)*$`), + schemelessRepo: true, + }, +} + +// vcsPathsAfterDynamic gives additional vcsPaths entries +// to try after the dynamic HTML check. +// This gives those sites a chance to introduce tags +// as part of a graceful transition away from the hard-coded logic. +var vcsPathsAfterDynamic = []*vcsPath{ + // Launchpad. See golang.org/issue/11436. + { + pathPrefix: "launchpad.net", + regexp: lazyregexp.New(`^(?Plaunchpad\.net/((?P[\w.\-]+)(?P/[\w.\-]+)?|~[\w.\-]+/(\+junk|[\w.\-]+)/[\w.\-]+))(/[\w.\-]+)*$`), + vcs: "bzr", + repo: "https://{root}", + check: launchpadVCS, + }, +} + +// noVCSSuffix checks that the repository name does not +// end in .foo for any version control system foo. +// The usual culprit is ".git". +func noVCSSuffix(match map[string]string) error { + repo := match["repo"] + for _, vcs := range vcsList { + if strings.HasSuffix(repo, "."+vcs.Cmd) { + return fmt.Errorf("invalid version control suffix in %s path", match["prefix"]) + } + } + return nil +} + +// launchpadVCS solves the ambiguity for "lp.net/project/foo". In this case, +// "foo" could be a series name registered in Launchpad with its own branch, +// and it could also be the name of a directory within the main project +// branch one level up. +func launchpadVCS(match map[string]string) error { + if match["project"] == "" || match["series"] == "" { + return nil + } + url := &urlpkg.URL{ + Scheme: "https", + Host: "code.launchpad.net", + Path: expand(match, "/{project}{series}/.bzr/branch-format"), + } + _, err := web.GetBytes(url) + if err != nil { + match["root"] = expand(match, "launchpad.net/{project}") + match["repo"] = expand(match, "https://{root}") + } + return nil +} + +// importError is a copy of load.importError, made to avoid a dependency cycle +// on cmd/go/internal/load. It just needs to satisfy load.ImportPathError. +type importError struct { + importPath string + err error +} + +func importErrorf(path, format string, args ...any) error { + err := &importError{importPath: path, err: fmt.Errorf(format, args...)} + if errStr := err.Error(); !strings.Contains(errStr, path) { + panic(fmt.Sprintf("path %q not in error %q", path, errStr)) + } + return err +} + +func (e *importError) Error() string { + return e.err.Error() +} + +func (e *importError) Unwrap() error { + // Don't return e.err directly, since we're only wrapping an error if %w + // was passed to ImportErrorf. + return errors.Unwrap(e.err) +} + +func (e *importError) ImportPath() string { + return e.importPath +} diff --git a/go/src/cmd/go/internal/vcs/vcs_test.go b/go/src/cmd/go/internal/vcs/vcs_test.go new file mode 100644 index 0000000000000000000000000000000000000000..ab70e517e277f8d594258a7500c778676a48d232 --- /dev/null +++ b/go/src/cmd/go/internal/vcs/vcs_test.go @@ -0,0 +1,639 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcs + +import ( + "errors" + "fmt" + "internal/testenv" + "os" + "path/filepath" + "strings" + "testing" + + "cmd/go/internal/web" +) + +func init() { + // GOVCS defaults to public:git|hg,private:all, + // which breaks many tests here - they can't use non-git, non-hg VCS at all! + // Change to fully permissive. + // The tests of the GOVCS setting itself are in ../../testdata/script/govcs.txt. + os.Setenv("GOVCS", "*:all") +} + +// Test that RepoRootForImportPath determines the correct RepoRoot for a given importPath. +// TODO(cmang): Add tests for SVN and BZR. +func TestRepoRootForImportPath(t *testing.T) { + testenv.MustHaveExternalNetwork(t) + + tests := []struct { + path string + want *RepoRoot + }{ + { + "github.com/golang/groupcache", + &RepoRoot{ + VCS: vcsGit, + Repo: "https://github.com/golang/groupcache", + }, + }, + // Unicode letters in directories are not valid. + { + "github.com/user/unicode/испытание", + nil, + }, + // IBM DevOps Services tests + { + "hub.jazz.net/git/user1/pkgname", + &RepoRoot{ + VCS: vcsGit, + Repo: "https://hub.jazz.net/git/user1/pkgname", + }, + }, + { + "hub.jazz.net/git/user1/pkgname/submodule/submodule/submodule", + &RepoRoot{ + VCS: vcsGit, + Repo: "https://hub.jazz.net/git/user1/pkgname", + }, + }, + { + "hub.jazz.net", + nil, + }, + { + "hubajazz.net", + nil, + }, + { + "hub2.jazz.net", + nil, + }, + { + "hub.jazz.net/someotherprefix", + nil, + }, + { + "hub.jazz.net/someotherprefix/user1/pkgname", + nil, + }, + // Spaces are not valid in user names or package names + { + "hub.jazz.net/git/User 1/pkgname", + nil, + }, + { + "hub.jazz.net/git/user1/pkg name", + nil, + }, + // Dots are not valid in user names + { + "hub.jazz.net/git/user.1/pkgname", + nil, + }, + { + "hub.jazz.net/git/user/pkg.name", + &RepoRoot{ + VCS: vcsGit, + Repo: "https://hub.jazz.net/git/user/pkg.name", + }, + }, + // User names cannot have uppercase letters + { + "hub.jazz.net/git/USER/pkgname", + nil, + }, + // OpenStack tests + { + "git.openstack.org/openstack/swift", + &RepoRoot{ + VCS: vcsGit, + Repo: "https://git.openstack.org/openstack/swift", + }, + }, + // Trailing .git is less preferred but included for + // compatibility purposes while the same source needs to + // be compilable on both old and new go + { + "git.openstack.org/openstack/swift.git", + &RepoRoot{ + VCS: vcsGit, + Repo: "https://git.openstack.org/openstack/swift.git", + }, + }, + { + "git.openstack.org/openstack/swift/go/hummingbird", + &RepoRoot{ + VCS: vcsGit, + Repo: "https://git.openstack.org/openstack/swift", + }, + }, + { + "git.openstack.org", + nil, + }, + { + "git.openstack.org/openstack", + nil, + }, + // Spaces are not valid in package name + { + "git.apache.org/package name/path/to/lib", + nil, + }, + // Should have ".git" suffix + { + "git.apache.org/package-name/path/to/lib", + nil, + }, + { + "gitbapache.org", + nil, + }, + { + "git.apache.org/package-name.git", + &RepoRoot{ + VCS: vcsGit, + Repo: "https://git.apache.org/package-name.git", + }, + }, + { + "git.apache.org/package-name_2.x.git/path/to/lib", + &RepoRoot{ + VCS: vcsGit, + Repo: "https://git.apache.org/package-name_2.x.git", + }, + }, + { + "chiselapp.com/user/kyle/repository/fossilgg", + &RepoRoot{ + VCS: vcsFossil, + Repo: "https://chiselapp.com/user/kyle/repository/fossilgg", + }, + }, + { + // must have a user/$name/repository/$repo path + "chiselapp.com/kyle/repository/fossilgg", + nil, + }, + { + "chiselapp.com/user/kyle/fossilgg", + nil, + }, + { + "bitbucket.org/workspace/pkgname", + &RepoRoot{ + VCS: vcsGit, + Repo: "https://bitbucket.org/workspace/pkgname", + }, + }, + } + + for _, test := range tests { + got, err := RepoRootForImportPath(test.path, IgnoreMod, web.SecureOnly) + want := test.want + + if want == nil { + if err == nil { + t.Errorf("RepoRootForImportPath(%q): Error expected but not received", test.path) + } + continue + } + if err != nil { + t.Errorf("RepoRootForImportPath(%q): %v", test.path, err) + continue + } + if got.VCS.Name != want.VCS.Name || got.Repo != want.Repo { + t.Errorf("RepoRootForImportPath(%q) = VCS(%s) Repo(%s), want VCS(%s) Repo(%s)", test.path, got.VCS, got.Repo, want.VCS, want.Repo) + } + } +} + +// Test that vcs.FromDir correctly inspects a given directory and returns the +// right VCS and repo directory. +func TestFromDir(t *testing.T) { + tempDir := t.TempDir() + + for _, vcs := range vcsList { + for r, root := range vcs.RootNames { + vcsName := fmt.Sprint(vcs.Name, r) + dir := filepath.Join(tempDir, "example.com", vcsName, root.filename) + if root.isDir { + err := os.MkdirAll(dir, 0755) + if err != nil { + t.Fatal(err) + } + } else { + err := os.MkdirAll(filepath.Dir(dir), 0755) + if err != nil { + t.Fatal(err) + } + f, err := os.Create(dir) + if err != nil { + t.Fatal(err) + } + f.Close() + } + + wantRepoDir := filepath.Dir(dir) + gotRepoDir, gotVCS, err := FromDir(dir, tempDir) + if err != nil { + t.Errorf("FromDir(%q, %q): %v", dir, tempDir, err) + continue + } + if gotRepoDir != wantRepoDir || gotVCS.Name != vcs.Name { + t.Errorf("FromDir(%q, %q) = RepoDir(%s), VCS(%s); want RepoDir(%s), VCS(%s)", dir, tempDir, gotRepoDir, gotVCS.Name, wantRepoDir, vcs.Name) + } + } + } +} + +func TestIsSecure(t *testing.T) { + tests := []struct { + vcs *Cmd + url string + secure bool + }{ + {vcsGit, "http://example.com/foo.git", false}, + {vcsGit, "https://example.com/foo.git", true}, + {vcsBzr, "http://example.com/foo.bzr", false}, + {vcsBzr, "https://example.com/foo.bzr", true}, + {vcsSvn, "http://example.com/svn", false}, + {vcsSvn, "https://example.com/svn", true}, + {vcsHg, "http://example.com/foo.hg", false}, + {vcsHg, "https://example.com/foo.hg", true}, + {vcsGit, "ssh://user@example.com/foo.git", true}, + {vcsGit, "user@server:path/to/repo.git", false}, + {vcsGit, "user@server:", false}, + {vcsGit, "server:repo.git", false}, + {vcsGit, "server:path/to/repo.git", false}, + {vcsGit, "example.com:path/to/repo.git", false}, + {vcsGit, "path/that/contains/a:colon/repo.git", false}, + {vcsHg, "ssh://user@example.com/path/to/repo.hg", true}, + {vcsFossil, "http://example.com/foo", false}, + {vcsFossil, "https://example.com/foo", true}, + } + + for _, test := range tests { + secure := test.vcs.IsSecure(test.url) + if secure != test.secure { + t.Errorf("%s isSecure(%q) = %t; want %t", test.vcs, test.url, secure, test.secure) + } + } +} + +func TestIsSecureGitAllowProtocol(t *testing.T) { + tests := []struct { + vcs *Cmd + url string + secure bool + }{ + // Same as TestIsSecure to verify same behavior. + {vcsGit, "http://example.com/foo.git", false}, + {vcsGit, "https://example.com/foo.git", true}, + {vcsBzr, "http://example.com/foo.bzr", false}, + {vcsBzr, "https://example.com/foo.bzr", true}, + {vcsSvn, "http://example.com/svn", false}, + {vcsSvn, "https://example.com/svn", true}, + {vcsHg, "http://example.com/foo.hg", false}, + {vcsHg, "https://example.com/foo.hg", true}, + {vcsGit, "user@server:path/to/repo.git", false}, + {vcsGit, "user@server:", false}, + {vcsGit, "server:repo.git", false}, + {vcsGit, "server:path/to/repo.git", false}, + {vcsGit, "example.com:path/to/repo.git", false}, + {vcsGit, "path/that/contains/a:colon/repo.git", false}, + {vcsHg, "ssh://user@example.com/path/to/repo.hg", true}, + // New behavior. + {vcsGit, "ssh://user@example.com/foo.git", false}, + {vcsGit, "foo://example.com/bar.git", true}, + {vcsHg, "foo://example.com/bar.hg", false}, + {vcsSvn, "foo://example.com/svn", false}, + {vcsBzr, "foo://example.com/bar.bzr", false}, + } + + defer os.Unsetenv("GIT_ALLOW_PROTOCOL") + os.Setenv("GIT_ALLOW_PROTOCOL", "https:foo") + for _, test := range tests { + secure := test.vcs.IsSecure(test.url) + if secure != test.secure { + t.Errorf("%s isSecure(%q) = %t; want %t", test.vcs, test.url, secure, test.secure) + } + } +} + +func TestMatchGoImport(t *testing.T) { + tests := []struct { + imports []metaImport + path string + mi metaImport + err error + }{ + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + path: "example.com/user/foo", + mi: metaImport{Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + path: "example.com/user/foo/", + mi: metaImport{Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + {Prefix: "example.com/user/fooa", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + path: "example.com/user/foo", + mi: metaImport{Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + {Prefix: "example.com/user/fooa", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + path: "example.com/user/fooa", + mi: metaImport{Prefix: "example.com/user/fooa", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + {Prefix: "example.com/user/foo/bar", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + path: "example.com/user/foo/bar", + err: errors.New("should not be allowed to create nested repo"), + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + {Prefix: "example.com/user/foo/bar", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + path: "example.com/user/foo/bar/baz", + err: errors.New("should not be allowed to create nested repo"), + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + {Prefix: "example.com/user/foo/bar", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + path: "example.com/user/foo/bar/baz/qux", + err: errors.New("should not be allowed to create nested repo"), + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + {Prefix: "example.com/user/foo/bar", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + path: "example.com/user/foo/bar/baz/", + err: errors.New("should not be allowed to create nested repo"), + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + {Prefix: "example.com/user/foo/bar", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + path: "example.com", + err: errors.New("pathologically short path"), + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target"}, + }, + path: "different.example.com/user/foo", + err: errors.New("meta tags do not match import path"), + }, + { + imports: []metaImport{ + {Prefix: "myitcv.io/blah2", VCS: "mod", RepoRoot: "https://raw.githubusercontent.com/myitcv/pubx/master"}, + {Prefix: "myitcv.io", VCS: "git", RepoRoot: "https://github.com/myitcv/x"}, + }, + path: "myitcv.io/blah2/foo", + mi: metaImport{Prefix: "myitcv.io/blah2", VCS: "mod", RepoRoot: "https://raw.githubusercontent.com/myitcv/pubx/master"}, + }, + { + imports: []metaImport{ + {Prefix: "myitcv.io/blah2", VCS: "mod", RepoRoot: "https://raw.githubusercontent.com/myitcv/pubx/master"}, + {Prefix: "myitcv.io", VCS: "git", RepoRoot: "https://github.com/myitcv/x"}, + }, + path: "myitcv.io/other", + mi: metaImport{Prefix: "myitcv.io", VCS: "git", RepoRoot: "https://github.com/myitcv/x"}, + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target", SubDir: "subdir"}, + }, + path: "example.com/user/foo", + mi: metaImport{Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target", SubDir: "subdir"}, + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target", SubDir: "foo/subdir"}, + }, + path: "example.com/user/foo", + mi: metaImport{Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target", SubDir: "foo/subdir"}, + }, + { + imports: []metaImport{ + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target", SubDir: "subdir"}, + {Prefix: "example.com/user/foo", VCS: "git", RepoRoot: "https://example.com/repo/target", SubDir: ""}, + }, + path: "example.com/user/foo", + err: errors.New("multiple meta tags match import path"), + }, + } + + for _, test := range tests { + mi, err := matchGoImport(test.imports, test.path) + if mi != test.mi { + t.Errorf("unexpected metaImport; got %v, want %v", mi, test.mi) + } + + got := err + want := test.err + if (got == nil) != (want == nil) { + t.Errorf("unexpected error; got %v, want %v", got, want) + } + } +} + +func TestValidateRepoRoot(t *testing.T) { + tests := []struct { + root string + ok bool + }{ + { + root: "", + ok: false, + }, + { + root: "http://", + ok: true, + }, + { + root: "git+ssh://", + ok: true, + }, + { + root: "http#://", + ok: false, + }, + { + root: "-config", + ok: false, + }, + { + root: "-config://", + ok: false, + }, + } + + for _, test := range tests { + err := validateRepoRoot(test.root) + ok := err == nil + if ok != test.ok { + want := "error" + if test.ok { + want = "nil" + } + t.Errorf("validateRepoRoot(%q) = %q, want %s", test.root, err, want) + } + } +} + +func TestValidateRepoSubDir(t *testing.T) { + tests := []struct { + subdir string + ok bool + }{ + { + subdir: "", + ok: true, + }, + { + subdir: "sub/dir", + ok: true, + }, + { + subdir: "/leading/slash", + ok: false, + }, + { + subdir: "-leading/hyphen", + ok: false, + }, + } + + for _, test := range tests { + err := validateRepoSubDir(test.subdir) + ok := err == nil + if ok != test.ok { + want := "error" + if test.ok { + want = "nil" + } + t.Errorf("validateRepoSubDir(%q) = %q, want %s", test.subdir, err, want) + } + } +} + +var govcsTests = []struct { + govcs string + path string + vcs string + ok bool +}{ + {"private:all", "is-public.com/foo", "zzz", false}, + {"private:all", "is-private.com/foo", "zzz", true}, + {"public:all", "is-public.com/foo", "zzz", true}, + {"public:all", "is-private.com/foo", "zzz", false}, + {"public:all,private:none", "is-public.com/foo", "zzz", true}, + {"public:all,private:none", "is-private.com/foo", "zzz", false}, + {"*:all", "is-public.com/foo", "zzz", true}, + {"golang.org:git", "golang.org/x/text", "zzz", false}, + {"golang.org:git", "golang.org/x/text", "git", true}, + {"golang.org:zzz", "golang.org/x/text", "zzz", true}, + {"golang.org:zzz", "golang.org/x/text", "git", false}, + {"golang.org:zzz", "golang.org/x/text", "zzz", true}, + {"golang.org:zzz", "golang.org/x/text", "git", false}, + {"golang.org:git|hg", "golang.org/x/text", "hg", true}, + {"golang.org:git|hg", "golang.org/x/text", "git", true}, + {"golang.org:git|hg", "golang.org/x/text", "zzz", false}, + {"golang.org:all", "golang.org/x/text", "hg", true}, + {"golang.org:all", "golang.org/x/text", "git", true}, + {"golang.org:all", "golang.org/x/text", "zzz", true}, + {"other.xyz/p:none,golang.org/x:git", "other.xyz/p/x", "git", false}, + {"other.xyz/p:none,golang.org/x:git", "unexpected.com", "git", false}, + {"other.xyz/p:none,golang.org/x:git", "golang.org/x/text", "zzz", false}, + {"other.xyz/p:none,golang.org/x:git", "golang.org/x/text", "git", true}, + {"other.xyz/p:none,golang.org/x:zzz", "golang.org/x/text", "zzz", true}, + {"other.xyz/p:none,golang.org/x:zzz", "golang.org/x/text", "git", false}, + {"other.xyz/p:none,golang.org/x:git|hg", "golang.org/x/text", "hg", true}, + {"other.xyz/p:none,golang.org/x:git|hg", "golang.org/x/text", "git", true}, + {"other.xyz/p:none,golang.org/x:git|hg", "golang.org/x/text", "zzz", false}, + {"other.xyz/p:none,golang.org/x:all", "golang.org/x/text", "hg", true}, + {"other.xyz/p:none,golang.org/x:all", "golang.org/x/text", "git", true}, + {"other.xyz/p:none,golang.org/x:all", "golang.org/x/text", "zzz", true}, + {"other.xyz/p:none,golang.org/x:git", "golang.org/y/text", "zzz", false}, + {"other.xyz/p:none,golang.org/x:git", "golang.org/y/text", "git", false}, + {"other.xyz/p:none,golang.org/x:zzz", "golang.org/y/text", "zzz", false}, + {"other.xyz/p:none,golang.org/x:zzz", "golang.org/y/text", "git", false}, + {"other.xyz/p:none,golang.org/x:git|hg", "golang.org/y/text", "hg", false}, + {"other.xyz/p:none,golang.org/x:git|hg", "golang.org/y/text", "git", false}, + {"other.xyz/p:none,golang.org/x:git|hg", "golang.org/y/text", "zzz", false}, + {"other.xyz/p:none,golang.org/x:all", "golang.org/y/text", "hg", false}, + {"other.xyz/p:none,golang.org/x:all", "golang.org/y/text", "git", false}, + {"other.xyz/p:none,golang.org/x:all", "golang.org/y/text", "zzz", false}, +} + +func TestGOVCS(t *testing.T) { + for _, tt := range govcsTests { + cfg, err := parseGOVCS(tt.govcs) + if err != nil { + t.Errorf("parseGOVCS(%q): %v", tt.govcs, err) + continue + } + private := strings.HasPrefix(tt.path, "is-private") + ok := cfg.allow(tt.path, private, tt.vcs) + if ok != tt.ok { + t.Errorf("parseGOVCS(%q).allow(%q, %v, %q) = %v, want %v", + tt.govcs, tt.path, private, tt.vcs, ok, tt.ok) + } + } +} + +var govcsErrors = []struct { + s string + err string +}{ + {`,`, `empty entry in GOVCS`}, + {`,x`, `empty entry in GOVCS`}, + {`x,`, `malformed entry in GOVCS (missing colon): "x"`}, + {`x:y,`, `empty entry in GOVCS`}, + {`x`, `malformed entry in GOVCS (missing colon): "x"`}, + {`x:`, `empty VCS list in GOVCS: "x:"`}, + {`x:|`, `empty VCS name in GOVCS: "x:|"`}, + {`x:y|`, `empty VCS name in GOVCS: "x:y|"`}, + {`x:|y`, `empty VCS name in GOVCS: "x:|y"`}, + {`x:y,z:`, `empty VCS list in GOVCS: "z:"`}, + {`x:y,z:|`, `empty VCS name in GOVCS: "z:|"`}, + {`x:y,z:|w`, `empty VCS name in GOVCS: "z:|w"`}, + {`x:y,z:w|`, `empty VCS name in GOVCS: "z:w|"`}, + {`x:y,z:w||v`, `empty VCS name in GOVCS: "z:w||v"`}, + {`x:y,x:z`, `unreachable pattern in GOVCS: "x:z" after "x:y"`}, +} + +func TestGOVCSErrors(t *testing.T) { + for _, tt := range govcsErrors { + _, err := parseGOVCS(tt.s) + if err == nil || !strings.Contains(err.Error(), tt.err) { + t.Errorf("parseGOVCS(%s): err=%v, want %v", tt.s, err, tt.err) + } + } +} diff --git a/go/src/cmd/go/internal/vcweb/auth.go b/go/src/cmd/go/internal/vcweb/auth.go new file mode 100644 index 0000000000000000000000000000000000000000..e7c7c6ca265758294ab27731b6d44a6a6e5f40b9 --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/auth.go @@ -0,0 +1,109 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcweb + +import ( + "encoding/json" + "fmt" + "io" + "log" + "net/http" + "os" + "path" + "strings" +) + +// authHandler serves requests only if the Basic Auth data sent with the request +// matches the contents of a ".access" file in the requested directory. +// +// For each request, the handler looks for a file named ".access" and parses it +// as a JSON-serialized accessToken. If the credentials from the request match +// the accessToken, the file is served normally; otherwise, it is rejected with +// the StatusCode and Message provided by the token. +type authHandler struct{} + +type accessToken struct { + Username, Password string + StatusCode int // defaults to 401. + Message string +} + +func (h *authHandler) Available() bool { return true } + +func (h *authHandler) Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) { + fs := http.Dir(dir) + + handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + urlPath := req.URL.Path + if urlPath != "" && strings.HasPrefix(path.Base(urlPath), ".") { + http.Error(w, "filename contains leading dot", http.StatusBadRequest) + return + } + + f, err := fs.Open(urlPath) + if err != nil { + if os.IsNotExist(err) { + http.NotFound(w, req) + } else { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + return + } + + accessDir := urlPath + if fi, err := f.Stat(); err == nil && !fi.IsDir() { + accessDir = path.Dir(urlPath) + } + f.Close() + + var accessFile http.File + for { + var err error + accessFile, err = fs.Open(path.Join(accessDir, ".access")) + if err == nil { + defer accessFile.Close() + break + } + + if !os.IsNotExist(err) { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + if accessDir == "." { + http.Error(w, "failed to locate access file", http.StatusInternalServerError) + return + } + accessDir = path.Dir(accessDir) + } + + data, err := io.ReadAll(accessFile) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + var token accessToken + if err := json.Unmarshal(data, &token); err != nil { + logger.Print(err) + http.Error(w, "malformed access file", http.StatusInternalServerError) + return + } + if username, password, ok := req.BasicAuth(); !ok || username != token.Username || password != token.Password { + code := token.StatusCode + if code == 0 { + code = http.StatusUnauthorized + } + if code == http.StatusUnauthorized { + w.Header().Add("WWW-Authenticate", fmt.Sprintf("basic realm=%s", accessDir)) + } + http.Error(w, token.Message, code) + return + } + + http.FileServer(fs).ServeHTTP(w, req) + }) + + return handler, nil +} diff --git a/go/src/cmd/go/internal/vcweb/bzr.go b/go/src/cmd/go/internal/vcweb/bzr.go new file mode 100644 index 0000000000000000000000000000000000000000..a915fb2b93347c2bfb9fe4d73209bc59c0233d8c --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/bzr.go @@ -0,0 +1,18 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcweb + +import ( + "log" + "net/http" +) + +type bzrHandler struct{} + +func (*bzrHandler) Available() bool { return true } + +func (*bzrHandler) Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) { + return http.FileServer(http.Dir(dir)), nil +} diff --git a/go/src/cmd/go/internal/vcweb/dir.go b/go/src/cmd/go/internal/vcweb/dir.go new file mode 100644 index 0000000000000000000000000000000000000000..2f122f414bb12d04109fd2c400237e7a1a3aabc4 --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/dir.go @@ -0,0 +1,19 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcweb + +import ( + "log" + "net/http" +) + +// dirHandler is a vcsHandler that serves the raw contents of a directory. +type dirHandler struct{} + +func (*dirHandler) Available() bool { return true } + +func (*dirHandler) Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) { + return http.FileServer(http.Dir(dir)), nil +} diff --git a/go/src/cmd/go/internal/vcweb/fossil.go b/go/src/cmd/go/internal/vcweb/fossil.go new file mode 100644 index 0000000000000000000000000000000000000000..cc24f2f1b0dc2f54a72737f58eb2cc5e45cf31b2 --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/fossil.go @@ -0,0 +1,61 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcweb + +import ( + "fmt" + "log" + "net/http" + "net/http/cgi" + "os" + "os/exec" + "path/filepath" + "sync" +) + +type fossilHandler struct { + once sync.Once + fossilPath string + fossilPathErr error +} + +func (h *fossilHandler) Available() bool { + h.once.Do(func() { + h.fossilPath, h.fossilPathErr = exec.LookPath("fossil") + }) + return h.fossilPathErr == nil +} + +func (h *fossilHandler) Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) { + if !h.Available() { + return nil, ServerNotInstalledError{name: "fossil"} + } + + name := filepath.Base(dir) + db := filepath.Join(dir, name+".fossil") + + cgiPath := db + ".cgi" + cgiScript := fmt.Sprintf("#!%s\nrepository: %s\n", h.fossilPath, db) + if err := os.WriteFile(cgiPath, []byte(cgiScript), 0755); err != nil { + return nil, err + } + + handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + if _, err := os.Stat(db); err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + ch := &cgi.Handler{ + Env: env, + Logger: logger, + Path: h.fossilPath, + Args: []string{cgiPath}, + Dir: dir, + } + ch.ServeHTTP(w, req) + }) + + return handler, nil +} diff --git a/go/src/cmd/go/internal/vcweb/git.go b/go/src/cmd/go/internal/vcweb/git.go new file mode 100644 index 0000000000000000000000000000000000000000..d1e0563bede03378562ca3105c5472b97107ef2f --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/git.go @@ -0,0 +1,71 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcweb + +import ( + "log" + "net/http" + "net/http/cgi" + "os/exec" + "runtime" + "slices" + "sync" +) + +type gitHandler struct { + once sync.Once + gitPath string + gitPathErr error +} + +func (h *gitHandler) Available() bool { + if runtime.GOOS == "plan9" { + // The Git command is usually not the real Git on Plan 9. + // See https://golang.org/issues/29640. + return false + } + h.once.Do(func() { + h.gitPath, h.gitPathErr = exec.LookPath("git") + }) + return h.gitPathErr == nil +} + +func (h *gitHandler) Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) { + if !h.Available() { + return nil, ServerNotInstalledError{name: "git"} + } + + baseEnv := append(slices.Clip(env), + "GIT_PROJECT_ROOT="+dir, + "GIT_HTTP_EXPORT_ALL=1", + ) + + handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + // The Git client sends the requested Git protocol version as a + // "Git-Protocol" HTTP request header, which the CGI host then converts + // to an environment variable (HTTP_GIT_PROTOCOL). + // + // However, versions of Git older that 2.34.0 don't recognize the + // HTTP_GIT_PROTOCOL variable, and instead need that value to be set in the + // GIT_PROTOCOL variable. We do so here so that vcweb can work reliably + // with older Git releases. (As of the time of writing, the Go project's + // builders were on Git version 2.30.2.) + env := slices.Clip(baseEnv) + if p := req.Header.Get("Git-Protocol"); p != "" { + env = append(env, "GIT_PROTOCOL="+p) + } + + h := &cgi.Handler{ + Path: h.gitPath, + Logger: logger, + Args: []string{"http-backend"}, + Dir: dir, + Env: env, + } + h.ServeHTTP(w, req) + }) + + return handler, nil +} diff --git a/go/src/cmd/go/internal/vcweb/hg.go b/go/src/cmd/go/internal/vcweb/hg.go new file mode 100644 index 0000000000000000000000000000000000000000..fb77d1a2fccdac4430ecca63bfa42adafb3930de --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/hg.go @@ -0,0 +1,178 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcweb + +import ( + "bufio" + "context" + "errors" + "io" + "log" + "net/http" + "net/http/httputil" + "net/url" + "os" + "os/exec" + "slices" + "strings" + "sync" + "time" +) + +type hgHandler struct { + once sync.Once + hgPath string + hgPathErr error + + mu sync.Mutex + wg sync.WaitGroup + ctx context.Context + cancel func() + cmds []*exec.Cmd + url map[string]*url.URL +} + +func (h *hgHandler) Available() bool { + h.once.Do(func() { + h.hgPath, h.hgPathErr = exec.LookPath("hg") + }) + return h.hgPathErr == nil +} + +func (h *hgHandler) Close() error { + h.mu.Lock() + defer h.mu.Unlock() + + if h.cancel == nil { + return nil + } + + h.cancel() + for _, cmd := range h.cmds { + h.wg.Add(1) + go func() { + cmd.Wait() + h.wg.Done() + }() + } + h.wg.Wait() + h.url = nil + h.cmds = nil + h.ctx = nil + h.cancel = nil + return nil +} + +func (h *hgHandler) Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) { + if !h.Available() { + return nil, ServerNotInstalledError{name: "hg"} + } + + handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + // Mercurial has a CGI server implementation (called hgweb). In theory we + // could use that — however, assuming that hgweb is even installed, the + // configuration for hgweb varies by Python version (2 vs 3), and we would + // rather not go rooting around trying to find the right Python version to + // run. + // + // Instead, we'll take a somewhat more roundabout approach: we assume that + // if "hg" works at all then "hg serve" works too, and we'll execute that as + // a subprocess, using a reverse proxy to forward the request and response. + + h.mu.Lock() + + if h.ctx == nil { + h.ctx, h.cancel = context.WithCancel(context.Background()) + } + + // Cache the hg server subprocess globally, because hg is too slow + // to start a new one for each request. There are under a dozen different + // repos we serve, so leaving a dozen processes around is not a big deal. + u := h.url[dir] + if u != nil { + h.mu.Unlock() + logger.Printf("proxying hg request to %s", u) + httputil.NewSingleHostReverseProxy(u).ServeHTTP(w, req) + return + } + + logger.Printf("starting hg serve for %s", dir) + cmd := exec.CommandContext(h.ctx, h.hgPath, "serve", "--port", "0", "--address", "localhost", "--accesslog", os.DevNull, "--name", "vcweb", "--print-url") + cmd.Dir = dir + cmd.Env = append(slices.Clip(env), "PWD="+dir) + + cmd.Cancel = func() error { + err := cmd.Process.Signal(os.Interrupt) + if err != nil && !errors.Is(err, os.ErrProcessDone) { + err = cmd.Process.Kill() + } + return err + } + // This WaitDelay is arbitrary. After 'hg serve' prints its URL, any further + // I/O is only for debugging. (The actual output goes through the HTTP URL, + // not the standard I/O streams.) + cmd.WaitDelay = 10 * time.Second + + stderr := new(strings.Builder) + cmd.Stderr = stderr + + stdout, err := cmd.StdoutPipe() + if err != nil { + h.mu.Unlock() + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + if err := cmd.Start(); err != nil { + h.mu.Unlock() + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + r := bufio.NewReader(stdout) + line, err := r.ReadString('\n') + if err != nil { + h.mu.Unlock() + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + // We have read what should be the server URL. 'hg serve' shouldn't need to + // write anything else to stdout, but it's not a big deal if it does anyway. + // Keep the stdout pipe open so that 'hg serve' won't get a SIGPIPE, but + // actively discard its output so that it won't hang on a blocking write. + h.wg.Add(1) + go func() { + io.Copy(io.Discard, r) + h.wg.Done() + }() + + // On some systems, + // hg serve --address=localhost --print-url prints in-addr.arpa hostnames + // even though they cannot be looked up. + // Replace them with IP literals. + line = strings.ReplaceAll(line, "//1.0.0.127.in-addr.arpa", "//127.0.0.1") + line = strings.ReplaceAll(line, "//1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa", "//[::1]") + + u, err = url.Parse(strings.TrimSpace(line)) + if err != nil { + h.mu.Unlock() + logger.Printf("%v: %v", cmd, err) + http.Error(w, err.Error(), http.StatusBadGateway) + return + } + + if h.url == nil { + h.url = make(map[string]*url.URL) + } + h.url[dir] = u + h.cmds = append(h.cmds, cmd) + h.mu.Unlock() + + logger.Printf("proxying hg request to %s", u) + httputil.NewSingleHostReverseProxy(u).ServeHTTP(w, req) + }) + + return handler, nil +} diff --git a/go/src/cmd/go/internal/vcweb/insecure.go b/go/src/cmd/go/internal/vcweb/insecure.go new file mode 100644 index 0000000000000000000000000000000000000000..1d6af25e79aee3529c2a1afe8fc8861778afd469 --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/insecure.go @@ -0,0 +1,42 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcweb + +import ( + "log" + "net/http" +) + +// insecureHandler redirects requests to the same host and path but using the +// "http" scheme instead of "https". +type insecureHandler struct{} + +func (h *insecureHandler) Available() bool { return true } + +func (h *insecureHandler) Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) { + // The insecure-redirect handler implementation doesn't depend or dir or env. + // + // The only effect of the directory is to determine which prefix the caller + // will strip from the request before passing it on to this handler. + return h, nil +} + +func (h *insecureHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { + if req.Host == "" && req.URL.Host == "" { + http.Error(w, "no Host provided in request", http.StatusBadRequest) + return + } + + // Note that if the handler is wrapped with http.StripPrefix, the prefix + // will remain stripped in the redirected URL, preventing redirect loops + // if the scheme is already "http". + + u := *req.URL + u.Scheme = "http" + u.User = nil + u.Host = req.Host + + http.Redirect(w, req, u.String(), http.StatusFound) +} diff --git a/go/src/cmd/go/internal/vcweb/script.go b/go/src/cmd/go/internal/vcweb/script.go new file mode 100644 index 0000000000000000000000000000000000000000..99f001254b54c7a08e191a01ce86c0e8fbb26662 --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/script.go @@ -0,0 +1,426 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcweb + +import ( + "bufio" + "bytes" + "cmd/internal/script" + "context" + "errors" + "fmt" + "internal/txtar" + "io" + "log" + "net/http" + "os" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "strconv" + "strings" + "time" + + "golang.org/x/mod/module" + "golang.org/x/mod/semver" + "golang.org/x/mod/zip" +) + +// newScriptEngine returns a script engine augmented with commands for +// reproducing version-control repositories by replaying commits. +func newScriptEngine() *script.Engine { + conds := script.DefaultConds() + + add := func(name string, cond script.Cond) { + if _, ok := conds[name]; ok { + panic(fmt.Sprintf("condition %q is already registered", name)) + } + conds[name] = cond + } + lazyBool := func(summary string, f func() bool) script.Cond { + return script.OnceCondition(summary, func() (bool, error) { return f(), nil }) + } + add("bzr", lazyBool("the 'bzr' executable exists and provides the standard CLI", hasWorkingBzr)) + add("git-sha256", script.OnceCondition("the local 'git' version is recent enough to support sha256 object/commit hashes", gitSupportsSHA256)) + + interrupt := func(cmd *exec.Cmd) error { return cmd.Process.Signal(os.Interrupt) } + gracePeriod := 30 * time.Second // arbitrary + + cmds := script.DefaultCmds() + cmds["at"] = scriptAt() + cmds["bzr"] = script.Program("bzr", interrupt, gracePeriod) + cmds["fossil"] = script.Program("fossil", interrupt, gracePeriod) + cmds["git"] = script.Program("git", interrupt, gracePeriod) + cmds["hg"] = script.Program("hg", interrupt, gracePeriod) + cmds["handle"] = scriptHandle() + cmds["modzip"] = scriptModzip() + cmds["skip"] = scriptSkip() + cmds["svnadmin"] = script.Program("svnadmin", interrupt, gracePeriod) + cmds["svn"] = script.Program("svn", interrupt, gracePeriod) + cmds["unquote"] = scriptUnquote() + + return &script.Engine{ + Cmds: cmds, + Conds: conds, + } +} + +// loadScript interprets the given script content using the vcweb script engine. +// loadScript always returns either a non-nil handler or a non-nil error. +// +// The script content must be a txtar archive with a comment containing a script +// with exactly one "handle" command and zero or more VCS commands to prepare +// the repository to be served. +func (s *Server) loadScript(ctx context.Context, logger *log.Logger, scriptPath string, scriptContent []byte, workDir string) (http.Handler, error) { + ar := txtar.Parse(scriptContent) + + if err := os.MkdirAll(workDir, 0755); err != nil { + return nil, err + } + + st, err := s.newState(ctx, workDir) + if err != nil { + return nil, err + } + if err := st.ExtractFiles(ar); err != nil { + return nil, err + } + + scriptName := filepath.Base(scriptPath) + scriptLog := new(strings.Builder) + err = s.engine.Execute(st, scriptName, bufio.NewReader(bytes.NewReader(ar.Comment)), scriptLog) + closeErr := st.CloseAndWait(scriptLog) + logger.Printf("%s:", scriptName) + io.WriteString(logger.Writer(), scriptLog.String()) + io.WriteString(logger.Writer(), "\n") + if err != nil { + return nil, err + } + if closeErr != nil { + return nil, err + } + + sc, err := getScriptCtx(st) + if err != nil { + return nil, err + } + if sc.handler == nil { + return nil, errors.New("script completed without setting handler") + } + return sc.handler, nil +} + +// newState returns a new script.State for executing scripts in workDir. +func (s *Server) newState(ctx context.Context, workDir string) (*script.State, error) { + ctx = &scriptCtx{ + Context: ctx, + server: s, + } + + st, err := script.NewState(ctx, workDir, s.env) + if err != nil { + return nil, err + } + return st, nil +} + +// scriptEnviron returns a new environment that attempts to provide predictable +// behavior for the supported version-control tools. +func scriptEnviron(homeDir string) []string { + env := []string{ + "USER=gopher", + homeEnvName() + "=" + homeDir, + "GIT_CONFIG_NOSYSTEM=1", + "HGRCPATH=" + filepath.Join(homeDir, ".hgrc"), + "HGENCODING=utf-8", + } + // Preserve additional environment variables that may be needed by VCS tools. + for _, k := range []string{ + pathEnvName(), + tempEnvName(), + "SYSTEMROOT", // must be preserved on Windows to find DLLs; golang.org/issue/25210 + "WINDIR", // must be preserved on Windows to be able to run PowerShell command; golang.org/issue/30711 + "ComSpec", // must be preserved on Windows to be able to run Batch files; golang.org/issue/56555 + "DYLD_LIBRARY_PATH", // must be preserved on macOS systems to find shared libraries + "LD_LIBRARY_PATH", // must be preserved on Unix systems to find shared libraries + "LIBRARY_PATH", // allow override of non-standard static library paths + "PYTHONPATH", // may be needed by hg to find imported modules + } { + if v, ok := os.LookupEnv(k); ok { + env = append(env, k+"="+v) + } + } + + if os.Getenv("GO_BUILDER_NAME") != "" || os.Getenv("GIT_TRACE_CURL") == "1" { + // To help diagnose https://go.dev/issue/52545, + // enable tracing for Git HTTPS requests. + env = append(env, + "GIT_TRACE_CURL=1", + "GIT_TRACE_CURL_NO_DATA=1", + "GIT_REDACT_COOKIES=o,SSO,GSSO_Uberproxy") + } + + return env +} + +// homeEnvName returns the environment variable used by os.UserHomeDir +// to locate the user's home directory. +func homeEnvName() string { + switch runtime.GOOS { + case "windows": + return "USERPROFILE" + case "plan9": + return "home" + default: + return "HOME" + } +} + +// tempEnvName returns the environment variable used by os.TempDir +// to locate the default directory for temporary files. +func tempEnvName() string { + switch runtime.GOOS { + case "windows": + return "TMP" + case "plan9": + return "TMPDIR" // actually plan 9 doesn't have one at all but this is fine + default: + return "TMPDIR" + } +} + +// pathEnvName returns the environment variable used by exec.LookPath to +// identify directories to search for executables. +func pathEnvName() string { + switch runtime.GOOS { + case "plan9": + return "path" + default: + return "PATH" + } +} + +// A scriptCtx is a context.Context that stores additional state for script +// commands. +type scriptCtx struct { + context.Context + server *Server + commitTime time.Time + handlerName string + handler http.Handler +} + +// scriptCtxKey is the key associating the *scriptCtx in a script's Context.. +type scriptCtxKey struct{} + +func (sc *scriptCtx) Value(key any) any { + if key == (scriptCtxKey{}) { + return sc + } + return sc.Context.Value(key) +} + +func getScriptCtx(st *script.State) (*scriptCtx, error) { + sc, ok := st.Context().Value(scriptCtxKey{}).(*scriptCtx) + if !ok { + return nil, errors.New("scriptCtx not found in State.Context") + } + return sc, nil +} + +func scriptAt() script.Cmd { + return script.Command( + script.CmdUsage{ + Summary: "set the current commit time for all version control systems", + Args: "time", + Detail: []string{ + "The argument must be an absolute timestamp in RFC3339 format.", + }, + }, + func(st *script.State, args ...string) (script.WaitFunc, error) { + if len(args) != 1 { + return nil, script.ErrUsage + } + + sc, err := getScriptCtx(st) + if err != nil { + return nil, err + } + + sc.commitTime, err = time.ParseInLocation(time.RFC3339, args[0], time.UTC) + if err == nil { + st.Setenv("GIT_COMMITTER_DATE", args[0]) + st.Setenv("GIT_AUTHOR_DATE", args[0]) + } + return nil, err + }) +} + +func scriptHandle() script.Cmd { + return script.Command( + script.CmdUsage{ + Summary: "set the HTTP handler that will serve the script's output", + Args: "handler [dir]", + Detail: []string{ + "The handler will be passed the script's current working directory and environment as arguments.", + "Valid handlers include 'dir' (for general http.Dir serving), 'bzr', 'fossil', 'git', and 'hg'", + }, + }, + func(st *script.State, args ...string) (script.WaitFunc, error) { + if len(args) == 0 || len(args) > 2 { + return nil, script.ErrUsage + } + + sc, err := getScriptCtx(st) + if err != nil { + return nil, err + } + + if sc.handler != nil { + return nil, fmt.Errorf("server handler already set to %s", sc.handlerName) + } + + name := args[0] + h, ok := sc.server.vcsHandlers[name] + if !ok { + return nil, fmt.Errorf("unrecognized VCS %q", name) + } + sc.handlerName = name + if !h.Available() { + return nil, ServerNotInstalledError{name} + } + + dir := st.Getwd() + if len(args) >= 2 { + dir = st.Path(args[1]) + } + sc.handler, err = h.Handler(dir, st.Environ(), sc.server.logger) + return nil, err + }) +} + +func scriptModzip() script.Cmd { + return script.Command( + script.CmdUsage{ + Summary: "create a Go module zip file from a directory", + Args: "zipfile path@version dir", + }, + func(st *script.State, args ...string) (wait script.WaitFunc, err error) { + if len(args) != 3 { + return nil, script.ErrUsage + } + zipPath := st.Path(args[0]) + mPath, version, ok := strings.Cut(args[1], "@") + if !ok { + return nil, script.ErrUsage + } + dir := st.Path(args[2]) + + if err := os.MkdirAll(filepath.Dir(zipPath), 0755); err != nil { + return nil, err + } + f, err := os.Create(zipPath) + if err != nil { + return nil, err + } + defer func() { + if closeErr := f.Close(); err == nil { + err = closeErr + } + }() + + return nil, zip.CreateFromDir(f, module.Version{Path: mPath, Version: version}, dir) + }) +} + +func scriptSkip() script.Cmd { + return script.Command( + script.CmdUsage{ + Summary: "skip the current test", + Args: "[msg]", + }, + func(_ *script.State, args ...string) (script.WaitFunc, error) { + if len(args) > 1 { + return nil, script.ErrUsage + } + if len(args) == 0 { + return nil, SkipError{""} + } + return nil, SkipError{args[0]} + }) +} + +type SkipError struct { + Msg string +} + +func (s SkipError) Error() string { + if s.Msg == "" { + return "skip" + } + return s.Msg +} + +func scriptUnquote() script.Cmd { + return script.Command( + script.CmdUsage{ + Summary: "unquote the argument as a Go string", + Args: "string", + }, + func(st *script.State, args ...string) (script.WaitFunc, error) { + if len(args) != 1 { + return nil, script.ErrUsage + } + + s, err := strconv.Unquote(`"` + args[0] + `"`) + if err != nil { + return nil, err + } + + wait := func(*script.State) (stdout, stderr string, err error) { + return s, "", nil + } + return wait, nil + }) +} + +func hasWorkingBzr() bool { + bzr, err := exec.LookPath("bzr") + if err != nil { + return false + } + // Check that 'bzr help' exits with code 0. + // See go.dev/issue/71504 for an example where 'bzr' exists in PATH but doesn't work. + err = exec.Command(bzr, "help").Run() + return err == nil +} + +// Capture the major, minor and (optionally) patch version, but ignore anything later +var gitVersLineExtract = regexp.MustCompile(`git version\s+(\d+\.\d+(?:\.\d+)?)`) + +func gitVersion() (string, error) { + gitOut, runErr := exec.Command("git", "version").CombinedOutput() + if runErr != nil { + return "v0", fmt.Errorf("failed to execute git version: %w", runErr) + } + matches := gitVersLineExtract.FindSubmatch(gitOut) + if len(matches) < 2 { + return "v0", fmt.Errorf("git version extraction regexp did not match version line: %q", gitOut) + } + return "v" + string(matches[1]), nil +} + +func hasAtLeastGitVersion(minVers string) (bool, error) { + gitVers, gitVersErr := gitVersion() + if gitVersErr != nil { + return false, gitVersErr + } + return semver.Compare(minVers, gitVers) <= 0, nil +} + +func gitSupportsSHA256() (bool, error) { + return hasAtLeastGitVersion("v2.29") +} diff --git a/go/src/cmd/go/internal/vcweb/svn.go b/go/src/cmd/go/internal/vcweb/svn.go new file mode 100644 index 0000000000000000000000000000000000000000..60222f1d0acb21a46663dacae3057ab7fd7ba855 --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/svn.go @@ -0,0 +1,199 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcweb + +import ( + "io" + "log" + "net" + "net/http" + "os/exec" + "strings" + "sync" +) + +// An svnHandler serves requests for Subversion repos. +// +// Unlike the other vcweb handlers, svnHandler does not serve the Subversion +// protocol directly over the HTTP connection. Instead, it opens a separate port +// that serves the (non-HTTP) 'svn' protocol. The test binary can retrieve the +// URL for that port by sending an HTTP request with the query parameter +// "vcwebsvn=1". +// +// We take this approach because the 'svn' protocol is implemented by a +// lightweight 'svnserve' binary that is usually packaged along with the 'svn' +// client binary, whereas only known implementation of the Subversion HTTP +// protocol is the mod_dav_svn apache2 module. Apache2 has a lot of dependencies +// and also seems to rely on global configuration via well-known file paths, so +// implementing a hermetic test using apache2 would require the test to run in a +// complicated container environment, which wouldn't be nearly as +// straightforward for Go contributors to set up and test against on their local +// machine. +type svnHandler struct { + svnRoot string // a directory containing all svn repos to be served + logger *log.Logger + + pathOnce sync.Once + svnservePath string // the path to the 'svnserve' executable + svnserveErr error + + listenOnce sync.Once + s chan *svnState // 1-buffered +} + +// An svnState describes the state of a port serving the 'svn://' protocol. +type svnState struct { + listener net.Listener + listenErr error + conns map[net.Conn]struct{} + closing bool + done chan struct{} +} + +func (h *svnHandler) Available() bool { + h.pathOnce.Do(func() { + h.svnservePath, h.svnserveErr = exec.LookPath("svnserve") + }) + return h.svnserveErr == nil +} + +// Handler returns an http.Handler that checks for the "vcwebsvn" query +// parameter and then serves the 'svn://' URL for the repository at the +// requested path. +// The HTTP client is expected to read that URL and pass it to the 'svn' client. +func (h *svnHandler) Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) { + if !h.Available() { + return nil, ServerNotInstalledError{name: "svn"} + } + + // Go ahead and start the listener now, so that if it fails (for example, due + // to port exhaustion) we can return an error from the Handler method instead + // of serving an error for each individual HTTP request. + h.listenOnce.Do(func() { + h.s = make(chan *svnState, 1) + l, err := net.Listen("tcp", "localhost:0") + done := make(chan struct{}) + + h.s <- &svnState{ + listener: l, + listenErr: err, + conns: map[net.Conn]struct{}{}, + done: done, + } + if err != nil { + close(done) + return + } + + h.logger.Printf("serving svn on svn://%v", l.Addr()) + + go func() { + for { + c, err := l.Accept() + + s := <-h.s + if err != nil { + s.listenErr = err + if len(s.conns) == 0 { + close(s.done) + } + h.s <- s + return + } + if s.closing { + c.Close() + } else { + s.conns[c] = struct{}{} + go h.serve(c) + } + h.s <- s + } + }() + }) + + s := <-h.s + addr := "" + if s.listener != nil { + addr = s.listener.Addr().String() + } + err := s.listenErr + h.s <- s + if err != nil { + return nil, err + } + + handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + if req.FormValue("vcwebsvn") != "" { + w.Header().Add("Content-Type", "text/plain; charset=UTF-8") + io.WriteString(w, "svn://"+addr+"\n") + return + } + http.NotFound(w, req) + }) + + return handler, nil +} + +// serve serves a single 'svn://' connection on c. +func (h *svnHandler) serve(c net.Conn) { + defer func() { + c.Close() + + s := <-h.s + delete(s.conns, c) + if len(s.conns) == 0 && s.listenErr != nil { + close(s.done) + } + h.s <- s + }() + + // The "--inetd" flag causes svnserve to speak the 'svn' protocol over its + // stdin and stdout streams as if invoked by the Unix "inetd" service. + // We aren't using inetd, but we are implementing essentially the same + // approach: using a host process to listen for connections and spawn + // subprocesses to serve them. + cmd := exec.Command(h.svnservePath, "--read-only", "--root="+h.svnRoot, "--inetd") + cmd.Stdin = c + cmd.Stdout = c + stderr := new(strings.Builder) + cmd.Stderr = stderr + err := cmd.Run() + + var errFrag any = "ok" + if err != nil { + errFrag = err + } + stderrFrag := "" + if stderr.Len() > 0 { + stderrFrag = "\n" + stderr.String() + } + h.logger.Printf("%v: %s%s", cmd, errFrag, stderrFrag) +} + +// Close stops accepting new svn:// connections and terminates the existing +// ones, then waits for the 'svnserve' subprocesses to complete. +func (h *svnHandler) Close() error { + h.listenOnce.Do(func() {}) + if h.s == nil { + return nil + } + + var err error + s := <-h.s + s.closing = true + if s.listener == nil { + err = s.listenErr + } else { + err = s.listener.Close() + } + for c := range s.conns { + c.Close() + } + done := s.done + h.s <- s + + <-done + return err +} diff --git a/go/src/cmd/go/internal/vcweb/vcstest/vcstest.go b/go/src/cmd/go/internal/vcweb/vcstest/vcstest.go new file mode 100644 index 0000000000000000000000000000000000000000..224cfd791931caa69d1c3cd1e8fe4fc709ceab6c --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/vcstest/vcstest.go @@ -0,0 +1,187 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package vcstest serves the repository scripts in cmd/go/testdata/vcstest +// using the [vcweb] script engine. +package vcstest + +import ( + "bytes" + "cmd/go/internal/vcs" + "cmd/go/internal/vcweb" + "cmd/go/internal/web/intercept" + "crypto/tls" + "crypto/x509" + "encoding/pem" + "fmt" + "internal/testenv" + "io" + "log" + "net/http" + "net/http/httptest" + "net/url" + "os" + "path/filepath" + "testing" +) + +var Hosts = []string{ + "vcs-test.golang.org", +} + +type Server struct { + vcweb *vcweb.Server + workDir string + HTTP *httptest.Server + HTTPS *httptest.Server +} + +// NewServer returns a new test-local vcweb server that serves VCS requests +// for modules with paths that begin with "vcs-test.golang.org" using the +// scripts in cmd/go/testdata/vcstest. +func NewServer() (srv *Server, err error) { + if vcs.VCSTestRepoURL != "" { + panic("vcs URL hooks already set") + } + + scriptDir := filepath.Join(testenv.GOROOT(nil), "src/cmd/go/testdata/vcstest") + + workDir, err := os.MkdirTemp("", "vcstest") + if err != nil { + return nil, err + } + defer func() { + if err != nil { + os.RemoveAll(workDir) + } + }() + + logger := log.Default() + if !testing.Verbose() { + logger = log.New(io.Discard, "", log.LstdFlags) + } + handler, err := vcweb.NewServer(scriptDir, workDir, logger) + if err != nil { + return nil, err + } + defer func() { + if err != nil { + handler.Close() + } + }() + + srvHTTP := httptest.NewUnstartedServer(handler) + srvHTTP.Config.ErrorLog = testLogger() + srvHTTP.Start() + httpURL, err := url.Parse(srvHTTP.URL) + if err != nil { + return nil, err + } + defer func() { + if err != nil { + srvHTTP.Close() + } + }() + + srvHTTPS := httptest.NewUnstartedServer(handler) + srvHTTPS.Config.ErrorLog = testLogger() + srvHTTPS.StartTLS() + httpsURL, err := url.Parse(srvHTTPS.URL) + if err != nil { + return nil, err + } + defer func() { + if err != nil { + srvHTTPS.Close() + } + }() + + srv = &Server{ + vcweb: handler, + workDir: workDir, + HTTP: srvHTTP, + HTTPS: srvHTTPS, + } + vcs.VCSTestRepoURL = srv.HTTP.URL + vcs.VCSTestHosts = Hosts + + interceptors := make([]intercept.Interceptor, 0, 2*len(Hosts)) + for _, host := range Hosts { + interceptors = append(interceptors, + intercept.Interceptor{Scheme: "http", FromHost: host, ToHost: httpURL.Host, Client: srv.HTTP.Client()}, + intercept.Interceptor{Scheme: "https", FromHost: host, ToHost: httpsURL.Host, Client: srv.HTTPS.Client()}) + } + intercept.EnableTestHooks(interceptors) + + fmt.Fprintln(os.Stderr, "vcs-test.golang.org rerouted to "+srv.HTTP.URL) + fmt.Fprintln(os.Stderr, "https://vcs-test.golang.org rerouted to "+srv.HTTPS.URL) + + return srv, nil +} + +func testLogger() *log.Logger { + return log.New(httpLogger{}, "vcweb: ", 0) +} + +type httpLogger struct{} + +func (httpLogger) Write(b []byte) (int, error) { + if bytes.Contains(b, []byte("TLS handshake error")) { + return len(b), nil + } + return os.Stdout.Write(b) +} + +func (srv *Server) Close() error { + if vcs.VCSTestRepoURL != srv.HTTP.URL { + panic("vcs URL hooks modified before Close") + } + vcs.VCSTestRepoURL = "" + vcs.VCSTestHosts = nil + intercept.DisableTestHooks() + + srv.HTTP.Close() + srv.HTTPS.Close() + err := srv.vcweb.Close() + if rmErr := os.RemoveAll(srv.workDir); err == nil { + err = rmErr + } + return err +} + +func (srv *Server) WriteCertificateFile() (string, error) { + b := pem.EncodeToMemory(&pem.Block{ + Type: "CERTIFICATE", + Bytes: srv.HTTPS.Certificate().Raw, + }) + + filename := filepath.Join(srv.workDir, "cert.pem") + if err := os.WriteFile(filename, b, 0644); err != nil { + return "", err + } + return filename, nil +} + +// TLSClient returns an http.Client that can talk to the httptest.Server +// whose certificate is written to the given file path. +func TLSClient(certFile string) (*http.Client, error) { + client := &http.Client{ + Transport: http.DefaultTransport.(*http.Transport).Clone(), + } + + pemBytes, err := os.ReadFile(certFile) + if err != nil { + return nil, err + } + + certpool := x509.NewCertPool() + if !certpool.AppendCertsFromPEM(pemBytes) { + return nil, fmt.Errorf("no certificates found in %s", certFile) + } + client.Transport.(*http.Transport).TLSClientConfig = &tls.Config{ + RootCAs: certpool, + } + + return client, nil +} diff --git a/go/src/cmd/go/internal/vcweb/vcstest/vcstest_test.go b/go/src/cmd/go/internal/vcweb/vcstest/vcstest_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6a6a0eee57ce851b4ae17d00459e727f839fb0de --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/vcstest/vcstest_test.go @@ -0,0 +1,177 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package vcstest_test + +import ( + "cmd/go/internal/vcweb" + "errors" + "flag" + "fmt" + "io" + "io/fs" + "log" + "net" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "strings" + "testing" + "time" +) + +var ( + dir = flag.String("dir", "../../../testdata/vcstest", "directory containing scripts to serve") + host = flag.String("host", "localhost", "hostname on which to serve HTTP") + port = flag.Int("port", -1, "port on which to serve HTTP; if nonnegative, skips running tests") +) + +func TestMain(m *testing.M) { + flag.Parse() + + if *port >= 0 { + err := serveStandalone(*host, *port) + if err != nil { + log.Fatal(err) + } + os.Exit(0) + } + + m.Run() +} + +// serveStandalone serves the vcweb testdata in a standalone HTTP server. +func serveStandalone(host string, port int) (err error) { + scriptDir, err := filepath.Abs(*dir) + if err != nil { + return err + } + work, err := os.MkdirTemp("", "vcweb") + if err != nil { + return err + } + defer func() { + if rmErr := os.RemoveAll(work); err == nil { + err = rmErr + } + }() + + log.Printf("running scripts in %s", work) + + v, err := vcweb.NewServer(scriptDir, work, log.Default()) + if err != nil { + return err + } + + l, err := net.Listen("tcp", fmt.Sprintf("%s:%d", host, port)) + if err != nil { + return err + } + log.Printf("serving on http://%s:%d/", host, l.Addr().(*net.TCPAddr).Port) + + return http.Serve(l, v) +} + +// TestScripts verifies that the VCS setup scripts in cmd/go/testdata/vcstest +// run successfully. +func TestScripts(t *testing.T) { + scriptDir, err := filepath.Abs(*dir) + if err != nil { + t.Fatal(err) + } + s, err := vcweb.NewServer(scriptDir, t.TempDir(), log.Default()) + if err != nil { + t.Fatal(err) + } + srv := httptest.NewServer(s) + + // To check for data races in the handler, run the root handler to produce an + // overview of the script status at an arbitrary point during the test. + // (We ignore the output because the expected failure mode is a friendly stack + // dump from the race detector.) + t.Run("overview", func(t *testing.T) { + t.Parallel() + + time.Sleep(1 * time.Millisecond) // Give the other handlers time to race. + + resp, err := http.Get(srv.URL) + if err == nil { + io.Copy(io.Discard, resp.Body) + resp.Body.Close() + } else { + t.Error(err) + } + }) + + t.Cleanup(func() { + // The subtests spawned by WalkDir run in parallel. When they complete, this + // Cleanup callback will run. At that point we fetch the root URL (which + // contains a status page), both to test that the root handler runs without + // crashing and to display a nice summary of the server's view of the test + // coverage. + resp, err := http.Get(srv.URL) + if err == nil { + var body []byte + body, err = io.ReadAll(resp.Body) + if err == nil && testing.Verbose() { + t.Logf("GET %s:\n%s", srv.URL, body) + } + resp.Body.Close() + } + if err != nil { + t.Error(err) + } + + srv.Close() + }) + + err = filepath.WalkDir(scriptDir, func(path string, d fs.DirEntry, err error) error { + if err != nil || d.IsDir() { + return err + } + + rel, err := filepath.Rel(scriptDir, path) + if err != nil { + return err + } + if rel == "README" { + return nil + } + + t.Run(filepath.ToSlash(rel), func(t *testing.T) { + t.Parallel() + + buf := new(strings.Builder) + logger := log.New(buf, "", log.LstdFlags) + // Load the script but don't try to serve the results: + // different VCS tools have different handler protocols, + // and the tests that actually use these repos will ensure + // that they are served correctly as a side effect anyway. + err := s.HandleScript(rel, logger, func(http.Handler) {}) + if buf.Len() > 0 { + t.Log(buf) + } + if err != nil { + if _, ok := errors.AsType[vcweb.ServerNotInstalledError](err); ok || errors.Is(err, exec.ErrNotFound) { + t.Skip(err) + } + if skip, ok := errors.AsType[vcweb.SkipError](err); ok { + if skip.Msg == "" { + t.Skip("SKIP") + } else { + t.Skipf("SKIP: %v", skip.Msg) + } + } + t.Error(err) + } + }) + return nil + }) + + if err != nil { + t.Error(err) + } +} diff --git a/go/src/cmd/go/internal/vcweb/vcweb.go b/go/src/cmd/go/internal/vcweb/vcweb.go new file mode 100644 index 0000000000000000000000000000000000000000..98d39a3b1f28a66014037fd92aad13cdaf476bbc --- /dev/null +++ b/go/src/cmd/go/internal/vcweb/vcweb.go @@ -0,0 +1,427 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package vcweb serves version control repos for testing the go command. +// +// It is loosely derived from golang.org/x/build/vcs-test/vcweb, +// which ran as a service hosted at vcs-test.golang.org. +// +// When a repository URL is first requested, the vcweb [Server] dynamically +// regenerates the repository using a script interpreted by a [script.Engine]. +// The script produces the server's contents for a corresponding root URL and +// all subdirectories of that URL, which are then cached: subsequent requests +// for any URL generated by the script will serve the script's previous output +// until the script is modified. +// +// The script engine includes all of the engine's default commands and +// conditions, as well as commands for each supported VCS binary (bzr, fossil, +// git, hg, and svn), a "handle" command that informs the script which protocol +// or handler to use to serve the request, and utilities "at" (which sets +// environment variables for Git timestamps) and "unquote" (which unquotes its +// argument as if it were a Go string literal). +// +// The server's "/" endpoint provides a summary of the available scripts, +// and "/help" provides documentation for the script environment. +// +// To run a standalone server based on the vcweb engine, use: +// +// go test cmd/go/internal/vcweb/vcstest -v --port=0 +package vcweb + +import ( + "bufio" + "cmd/internal/script" + "context" + "crypto/sha256" + "errors" + "fmt" + "io" + "io/fs" + "log" + "net/http" + "os" + "os/exec" + "path" + "path/filepath" + "runtime/debug" + "strings" + "sync" + "text/tabwriter" + "time" +) + +// A Server serves cached, dynamically-generated version control repositories. +type Server struct { + env []string + logger *log.Logger + + scriptDir string + workDir string + homeDir string // $workdir/home + engine *script.Engine + + scriptCache sync.Map // script path → *scriptResult + + vcsHandlers map[string]vcsHandler +} + +// A vcsHandler serves repositories over HTTP for a known version-control tool. +type vcsHandler interface { + Available() bool + Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) +} + +// A scriptResult describes the cached result of executing a vcweb script. +type scriptResult struct { + mu sync.RWMutex + + hash [sha256.Size]byte // hash of the script file, for cache invalidation + hashTime time.Time // timestamp at which the script was run, for diagnostics + + handler http.Handler // HTTP handler configured by the script + err error // error from executing the script, if any +} + +// NewServer returns a Server that generates and serves repositories in workDir +// using the scripts found in scriptDir and its subdirectories. +// +// A request for the path /foo/bar/baz will be handled by the first script along +// that path that exists: $scriptDir/foo.txt, $scriptDir/foo/bar.txt, or +// $scriptDir/foo/bar/baz.txt. +func NewServer(scriptDir, workDir string, logger *log.Logger) (*Server, error) { + if scriptDir == "" { + panic("vcweb.NewServer: scriptDir is required") + } + var err error + scriptDir, err = filepath.Abs(scriptDir) + if err != nil { + return nil, err + } + + if workDir == "" { + workDir, err = os.MkdirTemp("", "vcweb-*") + if err != nil { + return nil, err + } + logger.Printf("vcweb work directory: %s", workDir) + } else { + workDir, err = filepath.Abs(workDir) + if err != nil { + return nil, err + } + } + + homeDir := filepath.Join(workDir, "home") + if err := os.MkdirAll(homeDir, 0755); err != nil { + return nil, err + } + + env := scriptEnviron(homeDir) + + s := &Server{ + env: env, + logger: logger, + scriptDir: scriptDir, + workDir: workDir, + homeDir: homeDir, + engine: newScriptEngine(), + vcsHandlers: map[string]vcsHandler{ + "auth": new(authHandler), + "dir": new(dirHandler), + "bzr": new(bzrHandler), + "fossil": new(fossilHandler), + "git": new(gitHandler), + "hg": new(hgHandler), + "insecure": new(insecureHandler), + "svn": &svnHandler{svnRoot: workDir, logger: logger}, + }, + } + + if err := os.WriteFile(filepath.Join(s.homeDir, ".gitconfig"), []byte(gitConfig), 0644); err != nil { + return nil, err + } + gitConfigDir := filepath.Join(s.homeDir, ".config", "git") + if err := os.MkdirAll(gitConfigDir, 0755); err != nil { + return nil, err + } + if err := os.WriteFile(filepath.Join(gitConfigDir, "ignore"), []byte(""), 0644); err != nil { + return nil, err + } + + if err := os.WriteFile(filepath.Join(s.homeDir, ".hgrc"), []byte(hgrc), 0644); err != nil { + return nil, err + } + + return s, nil +} + +func (s *Server) Close() error { + var firstErr error + for _, h := range s.vcsHandlers { + if c, ok := h.(io.Closer); ok { + if closeErr := c.Close(); firstErr == nil { + firstErr = closeErr + } + } + } + return firstErr +} + +// gitConfig contains a ~/.gitconfg file that attempts to provide +// deterministic, platform-agnostic behavior for the 'git' command. +var gitConfig = ` +[user] + name = Go Gopher + email = gopher@golang.org +[init] + defaultBranch = main +[core] + eol = lf +[gui] + encoding = utf-8 +`[1:] + +// hgrc contains a ~/.hgrc file that attempts to provide +// deterministic, platform-agnostic behavior for the 'hg' command. +var hgrc = ` +[ui] +username=Go Gopher +[phases] +new-commit=public +[extensions] +convert= +`[1:] + +// ServeHTTP implements [http.Handler] for version-control repositories. +func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) { + s.logger.Printf("serving %s", req.URL) + + defer func() { + if v := recover(); v != nil { + if v == http.ErrAbortHandler { + panic(v) + } + s.logger.Fatalf("panic serving %s: %v\n%s", req.URL, v, debug.Stack()) + } + }() + + urlPath := req.URL.Path + if !strings.HasPrefix(urlPath, "/") { + urlPath = "/" + urlPath + } + clean := path.Clean(urlPath)[1:] + if clean == "" { + s.overview(w, req) + return + } + if clean == "help" { + s.help(w, req) + return + } + + // Locate the script that generates the requested path. + // We follow directories all the way to the end, then look for a ".txt" file + // matching the first component that doesn't exist. That guarantees + // uniqueness: if a path exists as a directory, then it cannot exist as a + // ".txt" script (because the search would ignore that file). + scriptPath := "." + for part := range strings.SplitSeq(clean, "/") { + scriptPath = filepath.Join(scriptPath, part) + dir := filepath.Join(s.scriptDir, scriptPath) + if _, err := os.Stat(dir); err != nil { + if !os.IsNotExist(err) { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + // scriptPath does not exist as a directory, so it either is the script + // location or the script doesn't exist. + break + } + } + scriptPath += ".txt" + + err := s.HandleScript(scriptPath, s.logger, func(handler http.Handler) { + handler.ServeHTTP(w, req) + }) + if err != nil { + s.logger.Print(err) + if _, ok := errors.AsType[ScriptNotFoundError](err); ok { + http.NotFound(w, req) + } else if _, ok := errors.AsType[ServerNotInstalledError](err); ok || errors.Is(err, exec.ErrNotFound) { + http.Error(w, err.Error(), http.StatusNotImplemented) + } else { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + } +} + +// A ScriptNotFoundError indicates that the requested script file does not exist. +// (It typically wraps a "stat" error for the script file.) +type ScriptNotFoundError struct{ err error } + +func (e ScriptNotFoundError) Error() string { return e.err.Error() } +func (e ScriptNotFoundError) Unwrap() error { return e.err } + +// A ServerNotInstalledError indicates that the server binary required for the +// indicated VCS does not exist. +type ServerNotInstalledError struct{ name string } + +func (v ServerNotInstalledError) Error() string { + return fmt.Sprintf("server for %#q VCS is not installed", v.name) +} + +// HandleScript ensures that the script at scriptRelPath has been evaluated +// with its current contents. +// +// If the script completed successfully, HandleScript invokes f on the handler +// with the script's result still read-locked, and waits for it to return. (That +// ensures that cache invalidation does not race with an in-flight handler.) +// +// Otherwise, HandleScript returns the (cached) error from executing the script. +func (s *Server) HandleScript(scriptRelPath string, logger *log.Logger, f func(http.Handler)) error { + ri, ok := s.scriptCache.Load(scriptRelPath) + if !ok { + ri, _ = s.scriptCache.LoadOrStore(scriptRelPath, new(scriptResult)) + } + r := ri.(*scriptResult) + + relDir := strings.TrimSuffix(scriptRelPath, filepath.Ext(scriptRelPath)) + workDir := filepath.Join(s.workDir, relDir) + prefix := path.Join("/", filepath.ToSlash(relDir)) + + r.mu.RLock() + defer r.mu.RUnlock() + for { + // For efficiency, we cache the script's output (in the work directory) + // across invocations. However, to allow for rapid iteration, we hash the + // script's contents and regenerate its output if the contents change. + // + // That way, one can use 'go run main.go' in this directory to stand up a + // server and see the output of the test script in order to fine-tune it. + content, err := os.ReadFile(filepath.Join(s.scriptDir, scriptRelPath)) + if err != nil { + if !os.IsNotExist(err) { + return err + } + return ScriptNotFoundError{err} + } + + hash := sha256.Sum256(content) + if prevHash := r.hash; prevHash != hash { + // The script's hash has changed, so regenerate its output. + func() { + r.mu.RUnlock() + r.mu.Lock() + defer func() { + r.mu.Unlock() + r.mu.RLock() + }() + if r.hash != prevHash { + // The cached result changed while we were waiting on the lock. + // It may have been updated to our hash or something even newer, + // so don't overwrite it. + return + } + + r.hash = hash + r.hashTime = time.Now() + r.handler, r.err = nil, nil + + if err := os.RemoveAll(workDir); err != nil { + r.err = err + return + } + + // Note: we use context.Background here instead of req.Context() so that we + // don't cache a spurious error (and lose work) if the request is canceled + // while the script is still running. + scriptHandler, err := s.loadScript(context.Background(), logger, scriptRelPath, content, workDir) + if err != nil { + r.err = err + return + } + r.handler = http.StripPrefix(prefix, scriptHandler) + }() + } + + if r.hash != hash { + continue // Raced with an update from another handler; try again. + } + + if r.err != nil { + return r.err + } + f(r.handler) + return nil + } +} + +// overview serves an HTML summary of the status of the scripts in the server's +// script directory. +func (s *Server) overview(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "\n") + fmt.Fprintf(w, "vcweb\n
    \n")
    +	fmt.Fprintf(w, "vcweb\n\n")
    +	fmt.Fprintf(w, "This server serves various version control repos for testing the go command.\n\n")
    +	fmt.Fprintf(w, "For an overview of the script language, see /help.\n\n")
    +
    +	fmt.Fprintf(w, "cache\n")
    +
    +	tw := tabwriter.NewWriter(w, 1, 8, 1, '\t', 0)
    +	err := filepath.WalkDir(s.scriptDir, func(path string, d fs.DirEntry, err error) error {
    +		if err != nil {
    +			return err
    +		}
    +		if filepath.Ext(path) != ".txt" {
    +			return nil
    +		}
    +
    +		rel, err := filepath.Rel(s.scriptDir, path)
    +		if err != nil {
    +			return err
    +		}
    +		hashTime := "(not loaded)"
    +		status := ""
    +		if ri, ok := s.scriptCache.Load(rel); ok {
    +			r := ri.(*scriptResult)
    +			r.mu.RLock()
    +			defer r.mu.RUnlock()
    +
    +			if !r.hashTime.IsZero() {
    +				hashTime = r.hashTime.Format(time.RFC3339)
    +			}
    +			if r.err == nil {
    +				status = "ok"
    +			} else {
    +				status = r.err.Error()
    +			}
    +		}
    +		fmt.Fprintf(tw, "%s\t%s\t%s\n", rel, hashTime, status)
    +		return nil
    +	})
    +	tw.Flush()
    +
    +	if err != nil {
    +		fmt.Fprintln(w, err)
    +	}
    +}
    +
    +// help serves a plain-text summary of the server's supported script language.
    +func (s *Server) help(w http.ResponseWriter, req *http.Request) {
    +	st, err := s.newState(req.Context(), s.workDir)
    +	if err != nil {
    +		http.Error(w, err.Error(), http.StatusInternalServerError)
    +		return
    +	}
    +
    +	scriptLog := new(strings.Builder)
    +	err = s.engine.Execute(st, "help", bufio.NewReader(strings.NewReader("help")), scriptLog)
    +	if err != nil {
    +		http.Error(w, err.Error(), http.StatusInternalServerError)
    +		return
    +	}
    +
    +	w.Header().Set("Content-Type", "text/plain; charset=UTF-8")
    +	io.WriteString(w, scriptLog.String())
    +}
    diff --git a/go/src/cmd/go/internal/vcweb/vcweb_test.go b/go/src/cmd/go/internal/vcweb/vcweb_test.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..20b213786feefb065d2c3a6e8f6121c75a4056a1
    --- /dev/null
    +++ b/go/src/cmd/go/internal/vcweb/vcweb_test.go
    @@ -0,0 +1,63 @@
    +// Copyright 2022 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package vcweb_test
    +
    +import (
    +	"cmd/go/internal/vcweb"
    +	"io"
    +	"log"
    +	"net/http"
    +	"net/http/httptest"
    +	"os"
    +	"testing"
    +)
    +
    +func TestHelp(t *testing.T) {
    +	s, err := vcweb.NewServer(os.DevNull, t.TempDir(), log.Default())
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	srv := httptest.NewServer(s)
    +	defer srv.Close()
    +
    +	resp, err := http.Get(srv.URL + "/help")
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	defer resp.Body.Close()
    +
    +	if resp.StatusCode != 200 {
    +		t.Fatal(resp.Status)
    +	}
    +	body, err := io.ReadAll(resp.Body)
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	t.Logf("%s", body)
    +}
    +
    +func TestOverview(t *testing.T) {
    +	s, err := vcweb.NewServer(os.DevNull, t.TempDir(), log.Default())
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	srv := httptest.NewServer(s)
    +	defer srv.Close()
    +
    +	resp, err := http.Get(srv.URL)
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	defer resp.Body.Close()
    +
    +	if resp.StatusCode != 200 {
    +		t.Fatal(resp.Status)
    +	}
    +	body, err := io.ReadAll(resp.Body)
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	t.Logf("%s", body)
    +}
    diff --git a/go/src/cmd/go/internal/version/version.go b/go/src/cmd/go/internal/version/version.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..781bc080e89fe4f412d0baae8278d4d63d97bb7e
    --- /dev/null
    +++ b/go/src/cmd/go/internal/version/version.go
    @@ -0,0 +1,202 @@
    +// Copyright 2011 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Package version implements the “go version” command.
    +package version
    +
    +import (
    +	"context"
    +	"debug/buildinfo"
    +	"encoding/json"
    +	"errors"
    +	"fmt"
    +	"io/fs"
    +	"os"
    +	"path/filepath"
    +	"runtime"
    +	"strings"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/gover"
    +)
    +
    +var CmdVersion = &base.Command{
    +	UsageLine: "go version [-m] [-v] [-json] [file ...]",
    +	Short:     "print Go version",
    +	Long: `Version prints the build information for Go binary files.
    +
    +Go version reports the Go version used to build each of the named files.
    +
    +If no files are named on the command line, go version prints its own
    +version information.
    +
    +If a directory is named, go version walks that directory, recursively,
    +looking for recognized Go binaries and reporting their versions.
    +By default, go version does not report unrecognized files found
    +during a directory scan. The -v flag causes it to report unrecognized files.
    +
    +The -m flag causes go version to print each file's embedded
    +module version information, when available. In the output, the module
    +information consists of multiple lines following the version line, each
    +indented by a leading tab character.
    +
    +The -json flag is similar to -m but outputs the runtime/debug.BuildInfo in JSON format.
    +If flag -json is specified without -m, go version reports an error.
    +
    +See also: go doc runtime/debug.BuildInfo.
    +`,
    +}
    +
    +func init() {
    +	base.AddChdirFlag(&CmdVersion.Flag)
    +	CmdVersion.Run = runVersion // break init cycle
    +}
    +
    +var (
    +	versionM    = CmdVersion.Flag.Bool("m", false, "")
    +	versionV    = CmdVersion.Flag.Bool("v", false, "")
    +	versionJson = CmdVersion.Flag.Bool("json", false, "")
    +)
    +
    +func runVersion(ctx context.Context, cmd *base.Command, args []string) {
    +	if len(args) == 0 {
    +		// If any of this command's flags were passed explicitly, error
    +		// out, because they only make sense with arguments.
    +		//
    +		// Don't error if the flags came from GOFLAGS, since that can be
    +		// a reasonable use case. For example, imagine GOFLAGS=-v to
    +		// turn "verbose mode" on for all Go commands, which should not
    +		// break "go version".
    +		var argOnlyFlag string
    +		if !base.InGOFLAGS("-m") && *versionM {
    +			argOnlyFlag = "-m"
    +		} else if !base.InGOFLAGS("-v") && *versionV {
    +			argOnlyFlag = "-v"
    +		} else if !base.InGOFLAGS("-json") && *versionJson {
    +			// Even though '-json' without '-m' should report an error,
    +			// it reports 'no arguments' issue only because that error will be reported
    +			// once the 'no arguments' issue is fixed by users.
    +			argOnlyFlag = "-json"
    +		}
    +		if argOnlyFlag != "" {
    +			fmt.Fprintf(os.Stderr, "go: 'go version' only accepts %s flag with arguments\n", argOnlyFlag)
    +			base.SetExitStatus(2)
    +			return
    +		}
    +		v := runtime.Version()
    +		if gover.TestVersion != "" {
    +			v = gover.TestVersion + " (TESTGO_VERSION)"
    +		}
    +		fmt.Printf("go version %s %s/%s\n", v, runtime.GOOS, runtime.GOARCH)
    +		return
    +	}
    +
    +	if !*versionM && *versionJson {
    +		fmt.Fprintf(os.Stderr, "go: 'go version' with -json flag requires -m flag\n")
    +		base.SetExitStatus(2)
    +		return
    +	}
    +
    +	for _, arg := range args {
    +		info, err := os.Stat(arg)
    +		if err != nil {
    +			fmt.Fprintf(os.Stderr, "%v\n", err)
    +			base.SetExitStatus(1)
    +			continue
    +		}
    +		if info.IsDir() {
    +			scanDir(arg)
    +		} else {
    +			ok := scanFile(arg, info, true)
    +			if !ok && *versionM {
    +				base.SetExitStatus(1)
    +			}
    +		}
    +	}
    +}
    +
    +// scanDir scans a directory for binary to run scanFile on.
    +func scanDir(dir string) {
    +	filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
    +		if d.Type().IsRegular() || d.Type()&fs.ModeSymlink != 0 {
    +			info, err := d.Info()
    +			if err != nil {
    +				if *versionV {
    +					fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
    +				}
    +				return nil
    +			}
    +			scanFile(path, info, *versionV)
    +		}
    +		return nil
    +	})
    +}
    +
    +// isGoBinaryCandidate reports whether the file is a candidate to be a Go binary.
    +func isGoBinaryCandidate(file string, info fs.FileInfo) bool {
    +	if info.Mode().IsRegular() && info.Mode()&0111 != 0 {
    +		return true
    +	}
    +	name := strings.ToLower(file)
    +	switch filepath.Ext(name) {
    +	case ".so", ".exe", ".dll":
    +		return true
    +	default:
    +		return strings.Contains(name, ".so.")
    +	}
    +}
    +
    +// scanFile scans file to try to report the Go and module versions.
    +// If mustPrint is true, scanFile will report any error reading file.
    +// Otherwise (mustPrint is false, because scanFile is being called
    +// by scanDir) scanFile prints nothing for non-Go binaries.
    +// scanFile reports whether the file is a Go binary.
    +func scanFile(file string, info fs.FileInfo, mustPrint bool) bool {
    +	if info.Mode()&fs.ModeSymlink != 0 {
    +		// Accept file symlinks only.
    +		i, err := os.Stat(file)
    +		if err != nil || !i.Mode().IsRegular() {
    +			if mustPrint {
    +				fmt.Fprintf(os.Stderr, "%s: symlink\n", file)
    +			}
    +			return false
    +		}
    +		info = i
    +	}
    +
    +	bi, err := buildinfo.ReadFile(file)
    +	if err != nil {
    +		if mustPrint {
    +			if pathErr, ok := errors.AsType[*os.PathError](err); ok && filepath.Clean(pathErr.Path) == filepath.Clean(file) {
    +				fmt.Fprintf(os.Stderr, "%v\n", file)
    +			} else {
    +				// Skip errors for non-Go binaries.
    +				// buildinfo.ReadFile errors are not fine-grained enough
    +				// to know if the file is a Go binary or not,
    +				// so try to infer it from the file mode and extension.
    +				if isGoBinaryCandidate(file, info) {
    +					fmt.Fprintf(os.Stderr, "%s: %v\n", file, err)
    +				}
    +			}
    +		}
    +		return false
    +	}
    +
    +	if *versionM && *versionJson {
    +		bs, err := json.MarshalIndent(bi, "", "\t")
    +		if err != nil {
    +			base.Fatal(err)
    +		}
    +		fmt.Printf("%s\n", bs)
    +		return true
    +	}
    +
    +	fmt.Printf("%s: %s\n", file, bi.GoVersion)
    +	bi.GoVersion = "" // suppress printing go version again
    +	mod := bi.String()
    +	if *versionM && len(mod) > 0 {
    +		fmt.Printf("\t%s\n", strings.ReplaceAll(mod[:len(mod)-1], "\n", "\n\t"))
    +	}
    +	return true
    +}
    diff --git a/go/src/cmd/go/internal/vet/vet.go b/go/src/cmd/go/internal/vet/vet.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..68357f81b3c39a17a83d548749e6df402e710b33
    --- /dev/null
    +++ b/go/src/cmd/go/internal/vet/vet.go
    @@ -0,0 +1,532 @@
    +// Copyright 2011 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Package vet implements the “go vet” and “go fix” commands.
    +package vet
    +
    +import (
    +	"archive/zip"
    +	"bytes"
    +	"context"
    +	"encoding/json"
    +	"errors"
    +	"fmt"
    +	"io"
    +	"os"
    +	"slices"
    +	"strconv"
    +	"strings"
    +	"sync"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/load"
    +	"cmd/go/internal/modload"
    +	"cmd/go/internal/trace"
    +	"cmd/go/internal/work"
    +)
    +
    +var CmdVet = &base.Command{
    +	CustomFlags: true,
    +	UsageLine:   "go vet [build flags] [-vettool prog] [vet flags] [packages]",
    +	Short:       "report likely mistakes in packages",
    +	Long: `
    +Vet runs the Go vet tool (cmd/vet) on the named packages
    +and reports diagnostics.
    +
    +It supports these flags:
    +
    +  -c int
    +	display offending line with this many lines of context (default -1)
    +  -json
    +	emit JSON output
    +  -fix
    +	instead of printing each diagnostic, apply its first fix (if any)
    +  -diff
    +	instead of applying each fix, print the patch as a unified diff;
    +	exit with a non-zero status if the diff is not empty
    +
    +The -vettool=prog flag selects a different analysis tool with
    +alternative or additional checks. For example, the 'shadow' analyzer
    +can be built and run using these commands:
    +
    +  go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
    +  go vet -vettool=$(which shadow)
    +
    +Alternative vet tools should be built atop golang.org/x/tools/go/analysis/unitchecker,
    +which handles the interaction with go vet.
    +
    +The default vet tool is 'go tool vet' or cmd/vet.
    +For help on its checkers and their flags, run 'go tool vet help'.
    +For details of a specific checker such as 'printf', see 'go tool vet help printf'.
    +
    +For more about specifying packages, see 'go help packages'.
    +
    +The build flags supported by go vet are those that control package resolution
    +and execution, such as -C, -n, -x, -v, -tags, and -toolexec.
    +For more about these flags, see 'go help build'.
    +
    +See also: go fmt, go fix.
    +	`,
    +}
    +
    +var CmdFix = &base.Command{
    +	CustomFlags: true,
    +	UsageLine:   "go fix [build flags] [-fixtool prog] [fix flags] [packages]",
    +	Short:       "apply fixes suggested by static checkers",
    +	Long: `
    +Fix runs the Go fix tool (cmd/fix) on the named packages
    +and applies suggested fixes.
    +
    +It supports these flags:
    +
    +  -diff
    +	instead of applying each fix, print the patch as a unified diff;
    +	exit with a non-zero status if the diff is not empty
    +
    +The -fixtool=prog flag selects a different analysis tool with
    +alternative or additional fixers; see the documentation for go vet's
    +-vettool flag for details.
    +
    +The default fix tool is 'go tool fix' or cmd/fix.
    +For help on its fixers and their flags, run 'go tool fix help'.
    +For details of a specific fixer such as 'hostport', see 'go tool fix help hostport'.
    +
    +For more about specifying packages, see 'go help packages'.
    +
    +The build flags supported by go fix are those that control package resolution
    +and execution, such as -C, -n, -x, -v, -tags, and -toolexec.
    +For more about these flags, see 'go help build'.
    +
    +See also: go fmt, go vet.
    +	`,
    +}
    +
    +func init() {
    +	// avoid initialization cycle
    +	CmdVet.Run = run
    +	CmdFix.Run = run
    +
    +	addFlags(CmdVet)
    +	addFlags(CmdFix)
    +}
    +
    +var (
    +	// "go vet -fix" causes fixes to be applied.
    +	vetFixFlag = CmdVet.Flag.Bool("fix", false, "apply the first fix (if any) for each diagnostic")
    +
    +	// The "go fix -fix=name,..." flag is an obsolete flag formerly
    +	// used to pass a list of names to the old "cmd/fix -r".
    +	fixFixFlag = CmdFix.Flag.String("fix", "", "obsolete; no effect")
    +)
    +
    +// run implements both "go vet" and "go fix".
    +
    +func run(ctx context.Context, cmd *base.Command, args []string) {
    +	moduleLoaderState := modload.NewState()
    +	// Compute flags for the vet/fix tool (e.g. cmd/{vet,fix}).
    +	toolFlags, pkgArgs := toolFlags(cmd, args)
    +
    +	// The vet/fix commands do custom flag processing;
    +	// initialize workspaces after that.
    +	moduleLoaderState.InitWorkfile()
    +
    +	if cfg.DebugTrace != "" {
    +		var close func() error
    +		var err error
    +		ctx, close, err = trace.Start(ctx, cfg.DebugTrace)
    +		if err != nil {
    +			base.Fatalf("failed to start trace: %v", err)
    +		}
    +		defer func() {
    +			if err := close(); err != nil {
    +				base.Fatalf("failed to stop trace: %v", err)
    +			}
    +		}()
    +	}
    +
    +	ctx, span := trace.StartSpan(ctx, fmt.Sprint("Running ", cmd.Name(), " command"))
    +	defer span.Done()
    +
    +	work.BuildInit(moduleLoaderState)
    +
    +	// Flag theory:
    +	//
    +	// All flags supported by unitchecker are accepted by go {vet,fix}.
    +	// Some arise from each analyzer in the tool (both to enable it
    +	// and to configure it), whereas others [-V -c -diff -fix -flags -json]
    +	// are core to unitchecker itself.
    +	//
    +	// Most are passed through to toolFlags, but not all:
    +	// * -V and -flags are used by the handshake in the [toolFlags] function;
    +	// * these old flags have no effect: [-all -source -tags -v]; and
    +	// * the [-c -fix -diff -json] flags are handled specially
    +	//   as described below:
    +	//
    +	// command args                 tool args
    +	// go vet               =>      cmd/vet -json           Parse stdout, print diagnostics to stderr.
    +	// go vet -json         =>      cmd/vet -json           Pass stdout through.
    +	// go vet -fix [-diff]  =>      cmd/vet -fix [-diff]    Pass stdout through (and exit 1 if diffs).
    +	// go fix [-diff]       =>      cmd/fix -fix [-diff]    Pass stdout through (and exit 1 if diffs).
    +	// go fix -json         =>      cmd/fix -json           Pass stdout through.
    +	//
    +	// Notes:
    +	// * -diff requires "go vet -fix" or "go fix", and no -json.
    +	// * -json output is the same in "vet" and "fix" modes,
    +	//   and describes both diagnostics and fixes (but does not apply them).
    +	// * -c=n is supported by the unitchecker, but we reimplement it
    +	//   here (see printDiagnostics), and do not pass the flag through.
    +
    +	work.VetExplicit = len(toolFlags) > 0
    +
    +	applyFixes := false
    +	if cmd.Name() == "fix" || *vetFixFlag {
    +		// fix mode: 'go fix' or 'go vet -fix'
    +		if jsonFlag {
    +			if diffFlag {
    +				base.Fatalf("-json and -diff cannot be used together")
    +			}
    +		} else {
    +			toolFlags = append(toolFlags, "-fix")
    +			if diffFlag {
    +				toolFlags = append(toolFlags, "-diff")
    +				// In -diff mode, the tool prints unified diffs to stdout.
    +				// Copy stdout through and exit non-zero if diffs were printed,
    +				// consistent with gofmt -d and go mod tidy -diff.
    +				work.VetHandleStdout = copyAndDetectDiff
    +			} else {
    +				applyFixes = true
    +			}
    +		}
    +		if contextFlag != -1 {
    +			base.Fatalf("-c flag cannot be used when applying fixes")
    +		}
    +	} else {
    +		// vet mode: 'go vet' without -fix
    +		if !jsonFlag {
    +			// Post-process the JSON diagnostics on stdout and format
    +			// it as "file:line: message" diagnostics on stderr.
    +			// (JSON reliably frames diagnostics, fixes, and errors so
    +			// that we don't have to parse stderr or interpret non-zero
    +			// exit codes, and interacts better with the action cache.)
    +			toolFlags = append(toolFlags, "-json")
    +			work.VetHandleStdout = printJSONDiagnostics
    +		}
    +		if diffFlag {
    +			base.Fatalf("go vet -diff flag requires -fix")
    +		}
    +	}
    +
    +	// Implement legacy "go fix -fix=name,..." flag.
    +	if *fixFixFlag != "" {
    +		fmt.Fprintf(os.Stderr, "go %s: the -fix=%s flag is obsolete and has no effect", cmd.Name(), *fixFixFlag)
    +
    +		// The buildtag fixer is now implemented by cmd/fix.
    +		if slices.Contains(strings.Split(*fixFixFlag, ","), "buildtag") {
    +			fmt.Fprintf(os.Stderr, "go %s: to enable the buildtag check, use -buildtag", cmd.Name())
    +		}
    +	}
    +
    +	work.VetFlags = toolFlags
    +
    +	pkgOpts := load.PackageOpts{ModResolveTests: true}
    +	pkgs := load.PackagesAndErrors(moduleLoaderState, ctx, pkgOpts, pkgArgs)
    +	load.CheckPackageErrors(pkgs)
    +	if len(pkgs) == 0 {
    +		base.Fatalf("no packages to %s", cmd.Name())
    +	}
    +
    +	// Build action graph.
    +	b := work.NewBuilder("", moduleLoaderState.VendorDirOrEmpty)
    +	defer func() {
    +		if err := b.Close(); err != nil {
    +			base.Fatal(err)
    +		}
    +	}()
    +
    +	root := &work.Action{Mode: "go " + cmd.Name()}
    +
    +	addVetAction := func(p *load.Package) {
    +		act := b.VetAction(moduleLoaderState, work.ModeBuild, work.ModeBuild, applyFixes, p)
    +		root.Deps = append(root.Deps, act)
    +	}
    +
    +	// To avoid file corruption from duplicate application of
    +	// fixes (in fix mode), and duplicate reporting of diagnostics
    +	// (in vet mode), we must run the tool only once for each
    +	// source file. We achieve that by running on ptest (below)
    +	// instead of p.
    +	//
    +	// As a side benefit, this also allows analyzers to make
    +	// "closed world" assumptions and report diagnostics (such as
    +	// "this symbol is unused") that might be false if computed
    +	// from just the primary package p, falsified by the
    +	// additional declarations in test files.
    +	//
    +	// We needn't worry about intermediate test variants, as they
    +	// will only be executed in VetxOnly mode, for facts but not
    +	// diagnostics.
    +	for _, p := range pkgs {
    +		// Don't apply fixes to vendored packages, including
    +		// the GOROOT vendor packages that are part of std,
    +		// or to packages from non-main modules (#76479).
    +		if applyFixes {
    +			if p.Standard && strings.HasPrefix(p.ImportPath, "vendor/") ||
    +				p.Module != nil && !p.Module.Main {
    +				continue
    +			}
    +		}
    +		_, ptest, pxtest, perr := load.TestPackagesFor(moduleLoaderState, ctx, pkgOpts, p, nil)
    +		if perr != nil {
    +			base.Errorf("%v", perr.Error)
    +			continue
    +		}
    +		if len(ptest.GoFiles) == 0 && len(ptest.CgoFiles) == 0 && pxtest == nil {
    +			base.Errorf("go: can't %s %s: no Go files in %s", cmd.Name(), p.ImportPath, p.Dir)
    +			continue
    +		}
    +		if len(ptest.GoFiles) > 0 || len(ptest.CgoFiles) > 0 {
    +			// The test package includes all the files of primary package.
    +			addVetAction(ptest)
    +		}
    +		if pxtest != nil {
    +			addVetAction(pxtest)
    +		}
    +	}
    +	b.Do(ctx, root)
    +
    +	// Apply fixes.
    +	//
    +	// We do this as a separate phase after the build to avoid
    +	// races between source file updates and reads of those same
    +	// files by concurrent actions of the ongoing build.
    +	//
    +	// If a file is fixed by multiple actions, they must be consistent.
    +	if applyFixes {
    +		contents := make(map[string][]byte)
    +		// Gather the fixes.
    +		for _, act := range root.Deps {
    +			if act.FixArchive != "" {
    +				if err := readZip(act.FixArchive, contents); err != nil {
    +					base.Errorf("reading archive of fixes: %v", err)
    +					return
    +				}
    +			}
    +		}
    +		// Apply them.
    +		for filename, content := range contents {
    +			if err := os.WriteFile(filename, content, 0644); err != nil {
    +				base.Errorf("applying fix: %v", err)
    +			}
    +		}
    +	}
    +}
    +
    +// readZip reads the zipfile entries into the provided map.
    +// It reports an error if updating the map would change an existing entry.
    +func readZip(zipfile string, out map[string][]byte) error {
    +	r, err := zip.OpenReader(zipfile)
    +	if err != nil {
    +		return err
    +	}
    +	defer r.Close() // ignore error
    +	for _, f := range r.File {
    +		rc, err := f.Open()
    +		if err != nil {
    +			return err
    +		}
    +		content, err := io.ReadAll(rc)
    +		rc.Close() // ignore error
    +		if err != nil {
    +			return err
    +		}
    +		if prev, ok := out[f.Name]; ok && !bytes.Equal(prev, content) {
    +			return fmt.Errorf("inconsistent fixes to file %v", f.Name)
    +		}
    +		out[f.Name] = content
    +	}
    +	return nil
    +}
    +
    +// copyAndDetectDiff copies the tool's stdout to the go command's stdout
    +// and sets exit status 1 if any output was produced (meaning diffs exist).
    +// This is used in -diff mode to implement the convention that "go fix -diff"
    +// exits non-zero when the diff is not empty, consistent with gofmt -d
    +// and go mod tidy -diff.
    +func copyAndDetectDiff(r io.Reader) error {
    +	stdouterrMu.Lock()
    +	defer stdouterrMu.Unlock()
    +	n, err := io.Copy(os.Stdout, r)
    +	if err != nil {
    +		return fmt.Errorf("copying diff output: %w", err)
    +	}
    +	if n > 0 {
    +		base.SetExitStatus(1)
    +	}
    +	return nil
    +}
    +
    +// printJSONDiagnostics parses JSON (from the tool's stdout) and
    +// prints it (to stderr) in "file:line: message" form.
    +// It also ensures that we exit nonzero if there were diagnostics.
    +func printJSONDiagnostics(r io.Reader) error {
    +	stdout, err := io.ReadAll(r)
    +	if err != nil {
    +		return err
    +	}
    +	if len(stdout) > 0 {
    +		// unitchecker emits a JSON map of the form:
    +		// output maps Package ID -> Analyzer.Name -> (error | []Diagnostic);
    +		var tree jsonTree
    +		if err := json.Unmarshal(stdout, &tree); err != nil {
    +			return fmt.Errorf("parsing JSON: %v", err)
    +		}
    +		for _, units := range tree {
    +			for analyzer, msg := range units {
    +				if msg[0] == '[' {
    +					// []Diagnostic
    +					var diags []jsonDiagnostic
    +					if err := json.Unmarshal([]byte(msg), &diags); err != nil {
    +						return fmt.Errorf("parsing JSON diagnostics: %v", err)
    +					}
    +					for _, diag := range diags {
    +						base.SetExitStatus(1)
    +						printJSONDiagnostic(analyzer, diag)
    +					}
    +				} else {
    +					// error
    +					var e jsonError
    +					if err := json.Unmarshal([]byte(msg), &e); err != nil {
    +						return fmt.Errorf("parsing JSON error: %v", err)
    +					}
    +
    +					base.SetExitStatus(1)
    +					return errors.New(e.Err)
    +				}
    +			}
    +		}
    +	}
    +	return nil
    +}
    +
    +var stdouterrMu sync.Mutex // serializes concurrent writes to stdout and stderr
    +
    +func printJSONDiagnostic(analyzer string, diag jsonDiagnostic) {
    +	stdouterrMu.Lock()
    +	defer stdouterrMu.Unlock()
    +
    +	type posn struct {
    +		file      string
    +		line, col int
    +	}
    +	parsePosn := func(s string) (_ posn, _ bool) {
    +		colon2 := strings.LastIndexByte(s, ':')
    +		if colon2 < 0 {
    +			return
    +		}
    +		colon1 := strings.LastIndexByte(s[:colon2], ':')
    +		if colon1 < 0 {
    +			return
    +		}
    +		line, err := strconv.Atoi(s[colon1+len(":") : colon2])
    +		if err != nil {
    +			return
    +		}
    +		col, err := strconv.Atoi(s[colon2+len(":"):])
    +		if err != nil {
    +			return
    +		}
    +		return posn{s[:colon1], line, col}, true
    +	}
    +
    +	print := func(start, end, message string) {
    +		if posn, ok := parsePosn(start); ok {
    +			// The (*work.Shell).reportCmd method relativizes the
    +			// prefix of each line of the subprocess's stdout;
    +			// but filenames in JSON aren't at the start of the line,
    +			// so we need to apply ShortPath here too.
    +			fmt.Fprintf(os.Stderr, "%s:%d:%d: %v\n", base.ShortPath(posn.file), posn.line, posn.col, message)
    +		} else {
    +			fmt.Fprintf(os.Stderr, "%s: %v\n", start, message)
    +		}
    +
    +		// -c=n: show offending line plus N lines of context.
    +		// (Duplicates logic in unitchecker; see analysisflags.PrintPlain.)
    +		if contextFlag >= 0 {
    +			if end == "" {
    +				end = start
    +			}
    +			var (
    +				startPosn, ok1 = parsePosn(start)
    +				endPosn, ok2   = parsePosn(end)
    +			)
    +			if ok1 && ok2 {
    +				// TODO(adonovan): respect overlays (like unitchecker does).
    +				data, _ := os.ReadFile(startPosn.file)
    +				lines := strings.Split(string(data), "\n")
    +				for i := startPosn.line - contextFlag; i <= endPosn.line+contextFlag; i++ {
    +					if 1 <= i && i <= len(lines) {
    +						fmt.Fprintf(os.Stderr, "%d\t%s\n", i, lines[i-1])
    +					}
    +				}
    +			}
    +		}
    +	}
    +
    +	// TODO(adonovan): append  " [analyzer]" to message. But we must first relax
    +	// x/tools/go/analysis/internal/versiontest.TestVettool and revendor; sigh.
    +	_ = analyzer
    +	print(diag.Posn, diag.End, diag.Message)
    +	for _, rel := range diag.Related {
    +		print(rel.Posn, rel.End, "\t"+rel.Message)
    +	}
    +}
    +
    +// -- JSON schema --
    +
    +// (populated by golang.org/x/tools/go/analysis/internal/analysisflags/flags.go)
    +
    +// A jsonTree is a mapping from package ID to analysis name to result.
    +// Each result is either a jsonError or a list of jsonDiagnostic.
    +type jsonTree map[string]map[string]json.RawMessage
    +
    +type jsonError struct {
    +	Err string `json:"error"`
    +}
    +
    +// A jsonTextEdit describes the replacement of a portion of a file.
    +// Start and End are zero-based half-open indices into the original byte
    +// sequence of the file, and New is the new text.
    +type jsonTextEdit struct {
    +	Filename string `json:"filename"`
    +	Start    int    `json:"start"`
    +	End      int    `json:"end"`
    +	New      string `json:"new"`
    +}
    +
    +// A jsonSuggestedFix describes an edit that should be applied as a whole or not
    +// at all. It might contain multiple TextEdits/text_edits if the SuggestedFix
    +// consists of multiple non-contiguous edits.
    +type jsonSuggestedFix struct {
    +	Message string         `json:"message"`
    +	Edits   []jsonTextEdit `json:"edits"`
    +}
    +
    +// A jsonDiagnostic describes the json schema of an analysis.Diagnostic.
    +type jsonDiagnostic struct {
    +	Category       string                   `json:"category,omitempty"`
    +	Posn           string                   `json:"posn"` // e.g. "file.go:line:column"
    +	End            string                   `json:"end"`
    +	Message        string                   `json:"message"`
    +	SuggestedFixes []jsonSuggestedFix       `json:"suggested_fixes,omitempty"`
    +	Related        []jsonRelatedInformation `json:"related,omitempty"`
    +}
    +
    +// A jsonRelatedInformation describes a secondary position and message related to
    +// a primary diagnostic.
    +type jsonRelatedInformation struct {
    +	Posn    string `json:"posn"` // e.g. "file.go:line:column"
    +	End     string `json:"end"`
    +	Message string `json:"message"`
    +}
    diff --git a/go/src/cmd/go/internal/vet/vetflag.go b/go/src/cmd/go/internal/vet/vetflag.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..7342b99d6e36bb45341c4d955d3dc2219f9343e0
    --- /dev/null
    +++ b/go/src/cmd/go/internal/vet/vetflag.go
    @@ -0,0 +1,212 @@
    +// Copyright 2017 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package vet
    +
    +import (
    +	"bytes"
    +	"encoding/json"
    +	"errors"
    +	"flag"
    +	"fmt"
    +	"log"
    +	"os"
    +	"os/exec"
    +	"path/filepath"
    +	"strings"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cmdflag"
    +	"cmd/go/internal/work"
    +)
    +
    +// go vet/fix flag processing
    +var (
    +	// We query the flags of the tool specified by -{vet,fix}tool
    +	// and accept any of those flags plus any flag valid for 'go
    +	// build'. The tool must support -flags, which prints a
    +	// description of its flags in JSON to stdout.
    +
    +	// toolFlag specifies the vet/fix command to run.
    +	// Any toolFlag that supports the (unpublished) vet
    +	// command-line protocol may be supplied; see
    +	// golang.org/x/tools/go/analysis/unitchecker for the
    +	// sole implementation. It is also used by tests.
    +	//
    +	// The default behavior ("") runs 'go tool {vet,fix}'.
    +	//
    +	// Do not access this flag directly; use [parseToolFlag].
    +	toolFlag    string // -{vet,fix}tool
    +	diffFlag    bool   // -diff
    +	jsonFlag    bool   // -json
    +	contextFlag = -1   // -c=n
    +)
    +
    +func addFlags(cmd *base.Command) {
    +	// We run the compiler for export data.
    +	// Suppress the build -json flag; we define our own.
    +	work.AddBuildFlags(cmd, work.OmitJSONFlag)
    +
    +	cmd.Flag.StringVar(&toolFlag, cmd.Name()+"tool", "", "") // -vettool or -fixtool
    +	cmd.Flag.BoolVar(&diffFlag, "diff", false, "print diff instead of applying it")
    +	cmd.Flag.BoolVar(&jsonFlag, "json", false, "print diagnostics and fixes as JSON")
    +	cmd.Flag.IntVar(&contextFlag, "c", -1, "display offending line with this many lines of context")
    +}
    +
    +// parseToolFlag scans args for -{vet,fix}tool and returns the effective tool filename.
    +func parseToolFlag(cmd *base.Command, args []string) string {
    +	toolFlagName := cmd.Name() + "tool" // vettool or fixtool
    +
    +	// Extract -{vet,fix}tool by ad hoc flag processing:
    +	// its value is needed even before we can declare
    +	// the flags available during main flag processing.
    +	for i, arg := range args {
    +		if arg == "-"+toolFlagName || arg == "--"+toolFlagName {
    +			if i+1 >= len(args) {
    +				log.Fatalf("%s requires a filename", arg)
    +			}
    +			toolFlag = args[i+1]
    +			break
    +		} else if strings.HasPrefix(arg, "-"+toolFlagName+"=") ||
    +			strings.HasPrefix(arg, "--"+toolFlagName+"=") {
    +			toolFlag = arg[strings.IndexByte(arg, '=')+1:]
    +			break
    +		}
    +	}
    +
    +	if toolFlag != "" {
    +		tool, err := filepath.Abs(toolFlag)
    +		if err != nil {
    +			log.Fatal(err)
    +		}
    +		return tool
    +	}
    +
    +	return base.Tool(cmd.Name()) // default to 'go tool vet|fix'
    +}
    +
    +// toolFlags processes the command line, splitting it at the first non-flag
    +// into the list of flags and list of packages.
    +func toolFlags(cmd *base.Command, args []string) (passToTool, packageNames []string) {
    +	tool := parseToolFlag(cmd, args)
    +	work.VetTool = tool
    +
    +	// Query the tool for its flags.
    +	out := new(bytes.Buffer)
    +	toolcmd := exec.Command(tool, "-flags")
    +	toolcmd.Stdout = out
    +	if err := toolcmd.Run(); err != nil {
    +		fmt.Fprintf(os.Stderr, "go: %s -flags failed: %v\n", tool, err)
    +		base.SetExitStatus(2)
    +		base.Exit()
    +	}
    +	var analysisFlags []struct {
    +		Name  string
    +		Bool  bool
    +		Usage string
    +	}
    +	if err := json.Unmarshal(out.Bytes(), &analysisFlags); err != nil {
    +		fmt.Fprintf(os.Stderr, "go: can't unmarshal JSON from %s -flags: %v", tool, err)
    +		base.SetExitStatus(2)
    +		base.Exit()
    +	}
    +
    +	// Add tool's flags to cmd.Flag.
    +	//
    +	// Some flags, in particular -tags and -v, are known to the tool but
    +	// also defined as build flags. This works fine, so we omit duplicates here.
    +	// However some, like -x, are known to the build but not to the tool.
    +	isToolFlag := make(map[string]bool, len(analysisFlags))
    +	cf := cmd.Flag
    +	for _, f := range analysisFlags {
    +		// We reimplement the unitchecker's -c=n flag.
    +		// Don't allow it to be passed through.
    +		if f.Name == "c" {
    +			continue
    +		}
    +		isToolFlag[f.Name] = true
    +		if cf.Lookup(f.Name) == nil {
    +			if f.Bool {
    +				cf.Bool(f.Name, false, "")
    +			} else {
    +				cf.String(f.Name, "", "")
    +			}
    +		}
    +	}
    +
    +	// Record the set of tool flags set by GOFLAGS. We want to pass them to
    +	// the tool, but only if they aren't overridden by an explicit argument.
    +	base.SetFromGOFLAGS(&cmd.Flag)
    +	addFromGOFLAGS := map[string]bool{}
    +	cmd.Flag.Visit(func(f *flag.Flag) {
    +		if isToolFlag[f.Name] {
    +			addFromGOFLAGS[f.Name] = true
    +		}
    +	})
    +
    +	explicitFlags := make([]string, 0, len(args))
    +	for len(args) > 0 {
    +		f, remainingArgs, err := cmdflag.ParseOne(&cmd.Flag, args)
    +
    +		if errors.Is(err, flag.ErrHelp) {
    +			exitWithUsage(cmd)
    +		}
    +
    +		if errors.Is(err, cmdflag.ErrFlagTerminator) {
    +			// All remaining args must be package names, but the flag terminator is
    +			// not included.
    +			packageNames = remainingArgs
    +			break
    +		}
    +
    +		if _, ok := errors.AsType[cmdflag.NonFlagError](err); ok {
    +			// Everything from here on out — including the argument we just consumed —
    +			// must be a package name.
    +			packageNames = args
    +			break
    +		}
    +
    +		if err != nil {
    +			fmt.Fprintln(os.Stderr, err)
    +			exitWithUsage(cmd)
    +		}
    +
    +		if isToolFlag[f.Name] {
    +			// Forward the raw arguments rather than cleaned equivalents, just in
    +			// case the tool parses them idiosyncratically.
    +			explicitFlags = append(explicitFlags, args[:len(args)-len(remainingArgs)]...)
    +
    +			// This flag has been overridden explicitly, so don't forward its implicit
    +			// value from GOFLAGS.
    +			delete(addFromGOFLAGS, f.Name)
    +		}
    +
    +		args = remainingArgs
    +	}
    +
    +	// Prepend arguments from GOFLAGS before other arguments.
    +	cmd.Flag.Visit(func(f *flag.Flag) {
    +		if addFromGOFLAGS[f.Name] {
    +			passToTool = append(passToTool, fmt.Sprintf("-%s=%s", f.Name, f.Value))
    +		}
    +	})
    +	passToTool = append(passToTool, explicitFlags...)
    +	return passToTool, packageNames
    +}
    +
    +func exitWithUsage(cmd *base.Command) {
    +	fmt.Fprintf(os.Stderr, "usage: %s\n", cmd.UsageLine)
    +	fmt.Fprintf(os.Stderr, "Run 'go help %s' for details.\n", cmd.LongName())
    +
    +	// This part is additional to what (*Command).Usage does:
    +	tool := toolFlag
    +	if tool == "" {
    +		tool = "go tool " + cmd.Name()
    +	}
    +	fmt.Fprintf(os.Stderr, "Run '%s help' for a full list of flags and analyzers.\n", tool)
    +	fmt.Fprintf(os.Stderr, "Run '%s -help' for an overview.\n", tool)
    +
    +	base.SetExitStatus(2)
    +	base.Exit()
    +}
    diff --git a/go/src/cmd/go/internal/web/api.go b/go/src/cmd/go/internal/web/api.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..7a6e0c310c9a7286441bb8f863de5d907b442a42
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/api.go
    @@ -0,0 +1,246 @@
    +// Copyright 2017 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Package web defines minimal helper routines for accessing HTTP/HTTPS
    +// resources without requiring external dependencies on the net package.
    +//
    +// If the cmd_go_bootstrap build tag is present, web avoids the use of the net
    +// package and returns errors for all network operations.
    +package web
    +
    +import (
    +	"bytes"
    +	"fmt"
    +	"io"
    +	"io/fs"
    +	"net/url"
    +	"strings"
    +	"unicode"
    +	"unicode/utf8"
    +)
    +
    +// SecurityMode specifies whether a function should make network
    +// calls using insecure transports (eg, plain text HTTP).
    +// The zero value is "secure".
    +type SecurityMode int
    +
    +const (
    +	SecureOnly      SecurityMode = iota // Reject plain HTTP; validate HTTPS.
    +	DefaultSecurity                     // Allow plain HTTP if explicit; validate HTTPS.
    +	Insecure                            // Allow plain HTTP if not explicitly HTTPS; skip HTTPS validation.
    +)
    +
    +// An HTTPError describes an HTTP error response (non-200 result).
    +type HTTPError struct {
    +	URL        string // redacted
    +	Status     string
    +	StatusCode int
    +	Err        error  // underlying error, if known
    +	Detail     string // limited to maxErrorDetailLines and maxErrorDetailBytes
    +}
    +
    +const (
    +	maxErrorDetailLines = 8
    +	maxErrorDetailBytes = maxErrorDetailLines * 81
    +)
    +
    +func (e *HTTPError) Error() string {
    +	if e.Detail != "" {
    +		detailSep := " "
    +		if strings.ContainsRune(e.Detail, '\n') {
    +			detailSep = "\n\t"
    +		}
    +		return fmt.Sprintf("reading %s: %v\n\tserver response:%s%s", e.URL, e.Status, detailSep, e.Detail)
    +	}
    +
    +	if eErr := e.Err; eErr != nil {
    +		if pErr, ok := e.Err.(*fs.PathError); ok {
    +			if u, err := url.Parse(e.URL); err == nil {
    +				if fp, err := urlToFilePath(u); err == nil && pErr.Path == fp {
    +					// Remove the redundant copy of the path.
    +					eErr = pErr.Err
    +				}
    +			}
    +		}
    +		return fmt.Sprintf("reading %s: %v", e.URL, eErr)
    +	}
    +
    +	return fmt.Sprintf("reading %s: %v", e.URL, e.Status)
    +}
    +
    +func (e *HTTPError) Is(target error) bool {
    +	return target == fs.ErrNotExist && (e.StatusCode == 404 || e.StatusCode == 410)
    +}
    +
    +func (e *HTTPError) Unwrap() error {
    +	return e.Err
    +}
    +
    +// GetBytes returns the body of the requested resource, or an error if the
    +// response status was not http.StatusOK.
    +//
    +// GetBytes is a convenience wrapper around Get and Response.Err.
    +func GetBytes(u *url.URL) ([]byte, error) {
    +	resp, err := Get(DefaultSecurity, u)
    +	if err != nil {
    +		return nil, err
    +	}
    +	defer resp.Body.Close()
    +	if err := resp.Err(); err != nil {
    +		return nil, err
    +	}
    +	b, err := io.ReadAll(resp.Body)
    +	if err != nil {
    +		return nil, fmt.Errorf("reading %s: %v", u.Redacted(), err)
    +	}
    +	return b, nil
    +}
    +
    +type Response struct {
    +	URL        string // redacted
    +	Status     string
    +	StatusCode int
    +	Header     map[string][]string
    +	Body       io.ReadCloser // Either the original body or &errorDetail.
    +
    +	fileErr     error
    +	errorDetail errorDetailBuffer
    +}
    +
    +// Err returns an *HTTPError corresponding to the response r.
    +// If the response r has StatusCode 200 or 0 (unset), Err returns nil.
    +// Otherwise, Err may read from r.Body in order to extract relevant error detail.
    +func (r *Response) Err() error {
    +	if r.StatusCode == 200 || r.StatusCode == 0 {
    +		return nil
    +	}
    +
    +	return &HTTPError{
    +		URL:        r.URL,
    +		Status:     r.Status,
    +		StatusCode: r.StatusCode,
    +		Err:        r.fileErr,
    +		Detail:     r.formatErrorDetail(),
    +	}
    +}
    +
    +// formatErrorDetail converts r.errorDetail (a prefix of the output of r.Body)
    +// into a short, tab-indented summary.
    +func (r *Response) formatErrorDetail() string {
    +	if r.Body != &r.errorDetail {
    +		return "" // Error detail collection not enabled.
    +	}
    +
    +	// Ensure that r.errorDetail has been populated.
    +	_, _ = io.Copy(io.Discard, r.Body)
    +
    +	s := r.errorDetail.buf.String()
    +	if !utf8.ValidString(s) {
    +		return "" // Don't try to recover non-UTF-8 error messages.
    +	}
    +	for _, r := range s {
    +		if !unicode.IsGraphic(r) && !unicode.IsSpace(r) {
    +			return "" // Don't let the server do any funny business with the user's terminal.
    +		}
    +	}
    +
    +	var detail strings.Builder
    +	for i, line := range strings.Split(s, "\n") {
    +		if strings.TrimSpace(line) == "" {
    +			break // Stop at the first blank line.
    +		}
    +		if i > 0 {
    +			detail.WriteString("\n\t")
    +		}
    +		if i >= maxErrorDetailLines {
    +			detail.WriteString("[Truncated: too many lines.]")
    +			break
    +		}
    +		if detail.Len()+len(line) > maxErrorDetailBytes {
    +			detail.WriteString("[Truncated: too long.]")
    +			break
    +		}
    +		detail.WriteString(line)
    +	}
    +
    +	return detail.String()
    +}
    +
    +// Get returns the body of the HTTP or HTTPS resource specified at the given URL.
    +//
    +// If the URL does not include an explicit scheme, Get first tries "https".
    +// If the server does not respond under that scheme and the security mode is
    +// Insecure, Get then tries "http".
    +// The URL included in the response indicates which scheme was actually used,
    +// and it is a redacted URL suitable for use in error messages.
    +//
    +// For the "https" scheme only, credentials are attached using the
    +// cmd/go/internal/auth package. If the URL itself includes a username and
    +// password, it will not be attempted under the "http" scheme unless the
    +// security mode is Insecure.
    +//
    +// Get returns a non-nil error only if the request did not receive a response
    +// under any applicable scheme. (A non-2xx response does not cause an error.)
    +func Get(security SecurityMode, u *url.URL) (*Response, error) {
    +	return get(security, u)
    +}
    +
    +// OpenBrowser attempts to open the requested URL in a web browser.
    +func OpenBrowser(url string) (opened bool) {
    +	return openBrowser(url)
    +}
    +
    +// Join returns the result of adding the slash-separated
    +// path elements to the end of u's path.
    +func Join(u *url.URL, path string) *url.URL {
    +	j := *u
    +	if path == "" {
    +		return &j
    +	}
    +	j.Path = strings.TrimSuffix(u.Path, "/") + "/" + strings.TrimPrefix(path, "/")
    +	j.RawPath = strings.TrimSuffix(u.RawPath, "/") + "/" + strings.TrimPrefix(path, "/")
    +	return &j
    +}
    +
    +// An errorDetailBuffer is an io.ReadCloser that copies up to
    +// maxErrorDetailLines into a buffer for later inspection.
    +type errorDetailBuffer struct {
    +	r        io.ReadCloser
    +	buf      strings.Builder
    +	bufLines int
    +}
    +
    +func (b *errorDetailBuffer) Close() error {
    +	return b.r.Close()
    +}
    +
    +func (b *errorDetailBuffer) Read(p []byte) (n int, err error) {
    +	n, err = b.r.Read(p)
    +
    +	// Copy the first maxErrorDetailLines+1 lines into b.buf,
    +	// discarding any further lines.
    +	//
    +	// Note that the read may begin or end in the middle of a UTF-8 character,
    +	// so don't try to do anything fancy with characters that encode to larger
    +	// than one byte.
    +	if b.bufLines <= maxErrorDetailLines {
    +		for _, line := range bytes.SplitAfterN(p[:n], []byte("\n"), maxErrorDetailLines-b.bufLines) {
    +			b.buf.Write(line)
    +			if len(line) > 0 && line[len(line)-1] == '\n' {
    +				b.bufLines++
    +				if b.bufLines > maxErrorDetailLines {
    +					break
    +				}
    +			}
    +		}
    +	}
    +
    +	return n, err
    +}
    +
    +// IsLocalHost reports whether the given URL refers to a local
    +// (loopback) host, such as "localhost" or "127.0.0.1:8080".
    +func IsLocalHost(u *url.URL) bool {
    +	return isLocalHost(u)
    +}
    diff --git a/go/src/cmd/go/internal/web/bootstrap.go b/go/src/cmd/go/internal/web/bootstrap.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..6312169ef00534a0dfb6a6cb9a835dd08292e2fb
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/bootstrap.go
    @@ -0,0 +1,25 @@
    +// Copyright 2012 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +//go:build cmd_go_bootstrap
    +
    +// This code is compiled only into the bootstrap 'go' binary.
    +// These stubs avoid importing packages with large dependency
    +// trees that potentially require C linking,
    +// like the use of "net/http" in vcs.go.
    +
    +package web
    +
    +import (
    +	"errors"
    +	urlpkg "net/url"
    +)
    +
    +func get(security SecurityMode, url *urlpkg.URL) (*Response, error) {
    +	return nil, errors.New("no http in bootstrap go command")
    +}
    +
    +func openBrowser(url string) bool { return false }
    +
    +func isLocalHost(u *urlpkg.URL) bool { return false }
    diff --git a/go/src/cmd/go/internal/web/file_test.go b/go/src/cmd/go/internal/web/file_test.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..3734df5c4e9bc0382f28ed87e2257527e17fc64f
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/file_test.go
    @@ -0,0 +1,60 @@
    +// Copyright 2019 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package web
    +
    +import (
    +	"errors"
    +	"io/fs"
    +	"os"
    +	"path/filepath"
    +	"testing"
    +)
    +
    +func TestGetFileURL(t *testing.T) {
    +	const content = "Hello, file!\n"
    +
    +	f, err := os.CreateTemp("", "web-TestGetFileURL")
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	defer os.Remove(f.Name())
    +
    +	if _, err := f.WriteString(content); err != nil {
    +		t.Error(err)
    +	}
    +	if err := f.Close(); err != nil {
    +		t.Fatal(err)
    +	}
    +
    +	u, err := urlFromFilePath(f.Name())
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +
    +	b, err := GetBytes(u)
    +	if err != nil {
    +		t.Fatalf("GetBytes(%v) = _, %v", u, err)
    +	}
    +	if string(b) != content {
    +		t.Fatalf("after writing %q to %s, GetBytes(%v) read %q", content, f.Name(), u, b)
    +	}
    +}
    +
    +func TestGetNonexistentFile(t *testing.T) {
    +	path, err := filepath.Abs("nonexistent")
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +
    +	u, err := urlFromFilePath(path)
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +
    +	b, err := GetBytes(u)
    +	if !errors.Is(err, fs.ErrNotExist) {
    +		t.Fatalf("GetBytes(%v) = %q, %v; want _, fs.ErrNotExist", u, b, err)
    +	}
    +}
    diff --git a/go/src/cmd/go/internal/web/http.go b/go/src/cmd/go/internal/web/http.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..2ef8169db5c37ffcdcf345a740b5a595e9247f55
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/http.go
    @@ -0,0 +1,361 @@
    +// Copyright 2012 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +//go:build !cmd_go_bootstrap
    +
    +// This code is compiled into the real 'go' binary, but it is not
    +// compiled into the binary that is built during all.bash, so as
    +// to avoid needing to build net (and thus use cgo) during the
    +// bootstrap process.
    +
    +package web
    +
    +import (
    +	"crypto/tls"
    +	"errors"
    +	"fmt"
    +	"io"
    +	"mime"
    +	"net"
    +	"net/http"
    +	urlpkg "net/url"
    +	"os"
    +	"strings"
    +	"time"
    +
    +	"cmd/go/internal/auth"
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/web/intercept"
    +	"cmd/internal/browser"
    +)
    +
    +// impatientInsecureHTTPClient is used with GOINSECURE,
    +// when we're connecting to https servers that might not be there
    +// or might be using self-signed certificates.
    +var impatientInsecureHTTPClient = &http.Client{
    +	CheckRedirect: checkRedirect,
    +	Timeout:       5 * time.Second,
    +	Transport: &http.Transport{
    +		Proxy: http.ProxyFromEnvironment,
    +		TLSClientConfig: &tls.Config{
    +			InsecureSkipVerify: true,
    +		},
    +	},
    +}
    +
    +var securityPreservingDefaultClient = securityPreservingHTTPClient(http.DefaultClient)
    +
    +// securityPreservingHTTPClient returns a client that is like the original
    +// but rejects redirects to plain-HTTP URLs if the original URL was secure.
    +func securityPreservingHTTPClient(original *http.Client) *http.Client {
    +	c := new(http.Client)
    +	*c = *original
    +	c.CheckRedirect = func(req *http.Request, via []*http.Request) error {
    +		if len(via) > 0 && via[0].URL.Scheme == "https" && req.URL.Scheme != "https" {
    +			lastHop := via[len(via)-1].URL
    +			return fmt.Errorf("redirected from secure URL %s to insecure URL %s", lastHop, req.URL)
    +		}
    +		return checkRedirect(req, via)
    +	}
    +	return c
    +}
    +
    +func checkRedirect(req *http.Request, via []*http.Request) error {
    +	// Go's http.DefaultClient allows 10 redirects before returning an error.
    +	// Mimic that behavior here.
    +	if len(via) >= 10 {
    +		return errors.New("stopped after 10 redirects")
    +	}
    +
    +	intercept.Request(req)
    +	return nil
    +}
    +
    +func get(security SecurityMode, url *urlpkg.URL) (*Response, error) {
    +	start := time.Now()
    +
    +	if url.Scheme == "file" {
    +		return getFile(url)
    +	}
    +
    +	if intercept.TestHooksEnabled {
    +		switch url.Host {
    +		case "proxy.golang.org":
    +			if os.Getenv("TESTGOPROXY404") == "1" {
    +				res := &Response{
    +					URL:        url.Redacted(),
    +					Status:     "404 testing",
    +					StatusCode: 404,
    +					Header:     make(map[string][]string),
    +					Body:       http.NoBody,
    +				}
    +				if cfg.BuildX {
    +					fmt.Fprintf(os.Stderr, "# get %s: %v (%.3fs)\n", url.Redacted(), res.Status, time.Since(start).Seconds())
    +				}
    +				return res, nil
    +			}
    +
    +		case "localhost.localdev":
    +			return nil, fmt.Errorf("no such host localhost.localdev")
    +
    +		default:
    +			if os.Getenv("TESTGONETWORK") == "panic" {
    +				if _, ok := intercept.URL(url); !ok {
    +					host := url.Host
    +					if h, _, err := net.SplitHostPort(url.Host); err == nil && h != "" {
    +						host = h
    +					}
    +					addr := net.ParseIP(host)
    +					if addr == nil || (!addr.IsLoopback() && !addr.IsUnspecified()) {
    +						panic("use of network: " + url.String())
    +					}
    +				}
    +			}
    +		}
    +	}
    +
    +	fetch := func(url *urlpkg.URL) (*http.Response, error) {
    +		// Note: The -v build flag does not mean "print logging information",
    +		// despite its historical misuse for this in GOPATH-based go get.
    +		// We print extra logging in -x mode instead, which traces what
    +		// commands are executed.
    +		if cfg.BuildX {
    +			fmt.Fprintf(os.Stderr, "# get %s\n", url.Redacted())
    +		}
    +
    +		req, err := http.NewRequest("GET", url.String(), nil)
    +		if err != nil {
    +			return nil, err
    +		}
    +		t, intercepted := intercept.URL(req.URL)
    +		var client *http.Client
    +		if security == Insecure && url.Scheme == "https" {
    +			client = impatientInsecureHTTPClient
    +		} else if intercepted && t.Client != nil {
    +			client = securityPreservingHTTPClient(t.Client)
    +		} else {
    +			client = securityPreservingDefaultClient
    +		}
    +		if url.Scheme == "https" {
    +			// Use initial GOAUTH credentials.
    +			auth.AddCredentials(client, req, nil, "")
    +		}
    +		if intercepted {
    +			req.Host = req.URL.Host
    +			req.URL.Host = t.ToHost
    +		}
    +
    +		release, err := base.AcquireNet()
    +		if err != nil {
    +			return nil, err
    +		}
    +		defer func() {
    +			if err != nil && release != nil {
    +				release()
    +			}
    +		}()
    +		res, err := client.Do(req)
    +		// If the initial request fails with a 4xx client error and the
    +		// response body didn't satisfy the request
    +		// (e.g. a valid  tag),
    +		// retry the request with credentials obtained by invoking GOAUTH
    +		// with the request URL.
    +		if url.Scheme == "https" && err == nil && res.StatusCode >= 400 && res.StatusCode < 500 {
    +			// Close the body of the previous response since we
    +			// are discarding it and creating a new one.
    +			res.Body.Close()
    +			req, err = http.NewRequest("GET", url.String(), nil)
    +			if err != nil {
    +				return nil, err
    +			}
    +			auth.AddCredentials(client, req, res, url.String())
    +			intercept.Request(req)
    +			res, err = client.Do(req)
    +		}
    +
    +		if err != nil {
    +			// Per the docs for [net/http.Client.Do], “On error, any Response can be
    +			// ignored. A non-nil Response with a non-nil error only occurs when
    +			// CheckRedirect fails, and even then the returned Response.Body is
    +			// already closed.”
    +			return nil, err
    +		}
    +
    +		// “If the returned error is nil, the Response will contain a non-nil Body
    +		// which the user is expected to close.”
    +		body := res.Body
    +		res.Body = hookCloser{
    +			ReadCloser: body,
    +			afterClose: release,
    +		}
    +		return res, nil
    +	}
    +
    +	var (
    +		fetched *urlpkg.URL
    +		res     *http.Response
    +		err     error
    +	)
    +	if url.Scheme == "" || url.Scheme == "https" {
    +		secure := new(urlpkg.URL)
    +		*secure = *url
    +		secure.Scheme = "https"
    +
    +		res, err = fetch(secure)
    +		if err == nil {
    +			fetched = secure
    +		} else {
    +			if cfg.BuildX {
    +				fmt.Fprintf(os.Stderr, "# get %s: %v\n", secure.Redacted(), err)
    +			}
    +			if security != Insecure || url.Scheme == "https" {
    +				// HTTPS failed, and we can't fall back to plain HTTP.
    +				// Report the error from the HTTPS attempt.
    +				return nil, err
    +			}
    +		}
    +	}
    +
    +	if res == nil {
    +		switch url.Scheme {
    +		case "http":
    +			if security == SecureOnly {
    +				if cfg.BuildX {
    +					fmt.Fprintf(os.Stderr, "# get %s: insecure\n", url.Redacted())
    +				}
    +				return nil, fmt.Errorf("insecure URL: %s", url.Redacted())
    +			}
    +		case "":
    +			if security != Insecure {
    +				panic("should have returned after HTTPS failure")
    +			}
    +		default:
    +			if cfg.BuildX {
    +				fmt.Fprintf(os.Stderr, "# get %s: unsupported\n", url.Redacted())
    +			}
    +			return nil, fmt.Errorf("unsupported scheme: %s", url.Redacted())
    +		}
    +
    +		insecure := new(urlpkg.URL)
    +		*insecure = *url
    +		insecure.Scheme = "http"
    +		if insecure.User != nil && security != Insecure {
    +			if cfg.BuildX {
    +				fmt.Fprintf(os.Stderr, "# get %s: insecure credentials\n", insecure.Redacted())
    +			}
    +			return nil, fmt.Errorf("refusing to pass credentials to insecure URL: %s", insecure.Redacted())
    +		}
    +
    +		res, err = fetch(insecure)
    +		if err == nil {
    +			fetched = insecure
    +		} else {
    +			if cfg.BuildX {
    +				fmt.Fprintf(os.Stderr, "# get %s: %v\n", insecure.Redacted(), err)
    +			}
    +			// HTTP failed, and we already tried HTTPS if applicable.
    +			// Report the error from the HTTP attempt.
    +			return nil, err
    +		}
    +	}
    +
    +	// Note: accepting a non-200 OK here, so people can serve a
    +	// meta import in their http 404 page.
    +	if cfg.BuildX {
    +		fmt.Fprintf(os.Stderr, "# get %s: %v (%.3fs)\n", fetched.Redacted(), res.Status, time.Since(start).Seconds())
    +	}
    +
    +	r := &Response{
    +		URL:        fetched.Redacted(),
    +		Status:     res.Status,
    +		StatusCode: res.StatusCode,
    +		Header:     map[string][]string(res.Header),
    +		Body:       res.Body,
    +	}
    +
    +	if res.StatusCode != http.StatusOK {
    +		contentType := res.Header.Get("Content-Type")
    +		if mediaType, params, _ := mime.ParseMediaType(contentType); mediaType == "text/plain" {
    +			switch charset := strings.ToLower(params["charset"]); charset {
    +			case "us-ascii", "utf-8", "":
    +				// Body claims to be plain text in UTF-8 or a subset thereof.
    +				// Try to extract a useful error message from it.
    +				r.errorDetail.r = res.Body
    +				r.Body = &r.errorDetail
    +			}
    +		}
    +	}
    +
    +	return r, nil
    +}
    +
    +func getFile(u *urlpkg.URL) (*Response, error) {
    +	path, err := urlToFilePath(u)
    +	if err != nil {
    +		return nil, err
    +	}
    +	f, err := os.Open(path)
    +
    +	if os.IsNotExist(err) {
    +		return &Response{
    +			URL:        u.Redacted(),
    +			Status:     http.StatusText(http.StatusNotFound),
    +			StatusCode: http.StatusNotFound,
    +			Body:       http.NoBody,
    +			fileErr:    err,
    +		}, nil
    +	}
    +
    +	if os.IsPermission(err) {
    +		return &Response{
    +			URL:        u.Redacted(),
    +			Status:     http.StatusText(http.StatusForbidden),
    +			StatusCode: http.StatusForbidden,
    +			Body:       http.NoBody,
    +			fileErr:    err,
    +		}, nil
    +	}
    +
    +	if err != nil {
    +		return nil, err
    +	}
    +
    +	return &Response{
    +		URL:        u.Redacted(),
    +		Status:     http.StatusText(http.StatusOK),
    +		StatusCode: http.StatusOK,
    +		Body:       f,
    +	}, nil
    +}
    +
    +func openBrowser(url string) bool { return browser.Open(url) }
    +
    +func isLocalHost(u *urlpkg.URL) bool {
    +	// VCSTestRepoURL itself is secure, and it may redirect requests to other
    +	// ports (such as a port serving the "svn" protocol) which should also be
    +	// considered secure.
    +	host, _, err := net.SplitHostPort(u.Host)
    +	if err != nil {
    +		host = u.Host
    +	}
    +	if host == "localhost" {
    +		return true
    +	}
    +	if ip := net.ParseIP(host); ip != nil && ip.IsLoopback() {
    +		return true
    +	}
    +	return false
    +}
    +
    +type hookCloser struct {
    +	io.ReadCloser
    +	afterClose func()
    +}
    +
    +func (c hookCloser) Close() error {
    +	err := c.ReadCloser.Close()
    +	c.afterClose()
    +	return err
    +}
    diff --git a/go/src/cmd/go/internal/web/intercept/intercept.go b/go/src/cmd/go/internal/web/intercept/intercept.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..dfdf6818c866110c4d0f6eaa81a7af9856bc2555
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/intercept/intercept.go
    @@ -0,0 +1,76 @@
    +// Copyright 2024 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package intercept
    +
    +import (
    +	"errors"
    +	"net/http"
    +	"net/url"
    +)
    +
    +// Interceptor is used to change the host, and maybe the client,
    +// for a request to point to a test host.
    +type Interceptor struct {
    +	Scheme   string
    +	FromHost string
    +	ToHost   string
    +	Client   *http.Client
    +}
    +
    +// EnableTestHooks installs the given interceptors to be used by URL and Request.
    +func EnableTestHooks(interceptors []Interceptor) error {
    +	if TestHooksEnabled {
    +		return errors.New("web: test hooks already enabled")
    +	}
    +
    +	for _, t := range interceptors {
    +		if t.FromHost == "" {
    +			panic("EnableTestHooks: missing FromHost")
    +		}
    +		if t.ToHost == "" {
    +			panic("EnableTestHooks: missing ToHost")
    +		}
    +	}
    +
    +	testInterceptors = interceptors
    +	TestHooksEnabled = true
    +	return nil
    +}
    +
    +// DisableTestHooks disables the installed interceptors.
    +func DisableTestHooks() {
    +	if !TestHooksEnabled {
    +		panic("web: test hooks not enabled")
    +	}
    +	TestHooksEnabled = false
    +	testInterceptors = nil
    +}
    +
    +var (
    +	// TestHooksEnabled is true if interceptors are installed
    +	TestHooksEnabled = false
    +	testInterceptors []Interceptor
    +)
    +
    +// URL returns the Interceptor to be used for a given URL.
    +func URL(u *url.URL) (*Interceptor, bool) {
    +	if !TestHooksEnabled {
    +		return nil, false
    +	}
    +	for i, t := range testInterceptors {
    +		if u.Host == t.FromHost && (u.Scheme == "" || u.Scheme == t.Scheme) {
    +			return &testInterceptors[i], true
    +		}
    +	}
    +	return nil, false
    +}
    +
    +// Request updates the host to actually use for the request, if it is to be intercepted.
    +func Request(req *http.Request) {
    +	if t, ok := URL(req.URL); ok {
    +		req.Host = req.URL.Host
    +		req.URL.Host = t.ToHost
    +	}
    +}
    diff --git a/go/src/cmd/go/internal/web/url.go b/go/src/cmd/go/internal/web/url.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..146c51f0aecfca50ab5f2fdfd26087e27146864c
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/url.go
    @@ -0,0 +1,95 @@
    +// Copyright 2019 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package web
    +
    +import (
    +	"errors"
    +	"net/url"
    +	"path/filepath"
    +	"strings"
    +)
    +
    +// TODO(golang.org/issue/32456): If accepted, move these functions into the
    +// net/url package.
    +
    +var errNotAbsolute = errors.New("path is not absolute")
    +
    +func urlToFilePath(u *url.URL) (string, error) {
    +	if u.Scheme != "file" {
    +		return "", errors.New("non-file URL")
    +	}
    +
    +	checkAbs := func(path string) (string, error) {
    +		if !filepath.IsAbs(path) {
    +			return "", errNotAbsolute
    +		}
    +		return path, nil
    +	}
    +
    +	if u.Path == "" {
    +		if u.Host != "" || u.Opaque == "" {
    +			return "", errors.New("file URL missing path")
    +		}
    +		return checkAbs(filepath.FromSlash(u.Opaque))
    +	}
    +
    +	path, err := convertFileURLPath(u.Host, u.Path)
    +	if err != nil {
    +		return path, err
    +	}
    +	return checkAbs(path)
    +}
    +
    +func urlFromFilePath(path string) (*url.URL, error) {
    +	if !filepath.IsAbs(path) {
    +		return nil, errNotAbsolute
    +	}
    +
    +	// If path has a Windows volume name, convert the volume to a host and prefix
    +	// per https://blogs.msdn.microsoft.com/ie/2006/12/06/file-uris-in-windows/.
    +	if vol := filepath.VolumeName(path); vol != "" {
    +		if strings.HasPrefix(vol, `\\`) {
    +			path = filepath.ToSlash(path[2:])
    +			i := strings.IndexByte(path, '/')
    +
    +			if i < 0 {
    +				// A degenerate case.
    +				// \\host.example.com (without a share name)
    +				// becomes
    +				// file://host.example.com/
    +				return &url.URL{
    +					Scheme: "file",
    +					Host:   path,
    +					Path:   "/",
    +				}, nil
    +			}
    +
    +			// \\host.example.com\Share\path\to\file
    +			// becomes
    +			// file://host.example.com/Share/path/to/file
    +			return &url.URL{
    +				Scheme: "file",
    +				Host:   path[:i],
    +				Path:   filepath.ToSlash(path[i:]),
    +			}, nil
    +		}
    +
    +		// C:\path\to\file
    +		// becomes
    +		// file:///C:/path/to/file
    +		return &url.URL{
    +			Scheme: "file",
    +			Path:   "/" + filepath.ToSlash(path),
    +		}, nil
    +	}
    +
    +	// /path/to/file
    +	// becomes
    +	// file:///path/to/file
    +	return &url.URL{
    +		Scheme: "file",
    +		Path:   filepath.ToSlash(path),
    +	}, nil
    +}
    diff --git a/go/src/cmd/go/internal/web/url_other.go b/go/src/cmd/go/internal/web/url_other.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..84bbd72820fcab516624f09755265dcd97f0f81d
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/url_other.go
    @@ -0,0 +1,21 @@
    +// Copyright 2019 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +//go:build !windows
    +
    +package web
    +
    +import (
    +	"errors"
    +	"path/filepath"
    +)
    +
    +func convertFileURLPath(host, path string) (string, error) {
    +	switch host {
    +	case "", "localhost":
    +	default:
    +		return "", errors.New("file URL specifies non-local host")
    +	}
    +	return filepath.FromSlash(path), nil
    +}
    diff --git a/go/src/cmd/go/internal/web/url_other_test.go b/go/src/cmd/go/internal/web/url_other_test.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..5c197de800dc1f31e73ca132da21218f7c8df148
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/url_other_test.go
    @@ -0,0 +1,36 @@
    +// Copyright 2019 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +//go:build !windows
    +
    +package web
    +
    +var urlTests = []struct {
    +	url          string
    +	filePath     string
    +	canonicalURL string // If empty, assume equal to url.
    +	wantErr      string
    +}{
    +	// Examples from RFC 8089:
    +	{
    +		url:      `file:///path/to/file`,
    +		filePath: `/path/to/file`,
    +	},
    +	{
    +		url:          `file:/path/to/file`,
    +		filePath:     `/path/to/file`,
    +		canonicalURL: `file:///path/to/file`,
    +	},
    +	{
    +		url:          `file://localhost/path/to/file`,
    +		filePath:     `/path/to/file`,
    +		canonicalURL: `file:///path/to/file`,
    +	},
    +
    +	// We reject non-local files.
    +	{
    +		url:     `file://host.example.com/path/to/file`,
    +		wantErr: "file URL specifies non-local host",
    +	},
    +}
    diff --git a/go/src/cmd/go/internal/web/url_test.go b/go/src/cmd/go/internal/web/url_test.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..8f462f53259b5c50ce27e828312ee41dbe32d4b2
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/url_test.go
    @@ -0,0 +1,77 @@
    +// Copyright 2019 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package web
    +
    +import (
    +	"net/url"
    +	"testing"
    +)
    +
    +func TestURLToFilePath(t *testing.T) {
    +	for _, tc := range urlTests {
    +		if tc.url == "" {
    +			continue
    +		}
    +		tc := tc
    +
    +		t.Run(tc.url, func(t *testing.T) {
    +			u, err := url.Parse(tc.url)
    +			if err != nil {
    +				t.Fatalf("url.Parse(%q): %v", tc.url, err)
    +			}
    +
    +			path, err := urlToFilePath(u)
    +			if err != nil {
    +				if err.Error() == tc.wantErr {
    +					return
    +				}
    +				if tc.wantErr == "" {
    +					t.Fatalf("urlToFilePath(%v): %v; want ", u, err)
    +				} else {
    +					t.Fatalf("urlToFilePath(%v): %v; want %s", u, err, tc.wantErr)
    +				}
    +			}
    +
    +			if path != tc.filePath || tc.wantErr != "" {
    +				t.Fatalf("urlToFilePath(%v) = %q, ; want %q, %s", u, path, tc.filePath, tc.wantErr)
    +			}
    +		})
    +	}
    +}
    +
    +func TestURLFromFilePath(t *testing.T) {
    +	for _, tc := range urlTests {
    +		if tc.filePath == "" {
    +			continue
    +		}
    +		tc := tc
    +
    +		t.Run(tc.filePath, func(t *testing.T) {
    +			u, err := urlFromFilePath(tc.filePath)
    +			if err != nil {
    +				if err.Error() == tc.wantErr {
    +					return
    +				}
    +				if tc.wantErr == "" {
    +					t.Fatalf("urlFromFilePath(%v): %v; want ", tc.filePath, err)
    +				} else {
    +					t.Fatalf("urlFromFilePath(%v): %v; want %s", tc.filePath, err, tc.wantErr)
    +				}
    +			}
    +
    +			if tc.wantErr != "" {
    +				t.Fatalf("urlFromFilePath(%v) = ; want error: %s", tc.filePath, tc.wantErr)
    +			}
    +
    +			wantURL := tc.url
    +			if tc.canonicalURL != "" {
    +				wantURL = tc.canonicalURL
    +			}
    +			if u.String() != wantURL {
    +				t.Errorf("urlFromFilePath(%v) = %v; want %s", tc.filePath, u, wantURL)
    +			}
    +		})
    +	}
    +}
    diff --git a/go/src/cmd/go/internal/web/url_windows.go b/go/src/cmd/go/internal/web/url_windows.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..2a65ec83f60e8e40ef2a19d75ef871e7a6856b52
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/url_windows.go
    @@ -0,0 +1,43 @@
    +// Copyright 2019 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package web
    +
    +import (
    +	"errors"
    +	"path/filepath"
    +	"strings"
    +)
    +
    +func convertFileURLPath(host, path string) (string, error) {
    +	if len(path) == 0 || path[0] != '/' {
    +		return "", errNotAbsolute
    +	}
    +
    +	path = filepath.FromSlash(path)
    +
    +	// We interpret Windows file URLs per the description in
    +	// https://blogs.msdn.microsoft.com/ie/2006/12/06/file-uris-in-windows/.
    +
    +	// The host part of a file URL (if any) is the UNC volume name,
    +	// but RFC 8089 reserves the authority "localhost" for the local machine.
    +	if host != "" && host != "localhost" {
    +		// A common "legacy" format omits the leading slash before a drive letter,
    +		// encoding the drive letter as the host instead of part of the path.
    +		// (See https://blogs.msdn.microsoft.com/freeassociations/2005/05/19/the-bizarre-and-unhappy-story-of-file-urls/.)
    +		// We do not support that format, but we should at least emit a more
    +		// helpful error message for it.
    +		if filepath.VolumeName(host) != "" {
    +			return "", errors.New("file URL encodes volume in host field: too few slashes?")
    +		}
    +		return `\\` + host + path, nil
    +	}
    +
    +	// If host is empty, path must contain an initial slash followed by a
    +	// drive letter and path. Remove the slash and verify that the path is valid.
    +	if vol := filepath.VolumeName(path[1:]); vol == "" || strings.HasPrefix(vol, `\\`) {
    +		return "", errors.New("file URL missing drive letter")
    +	}
    +	return path[1:], nil
    +}
    diff --git a/go/src/cmd/go/internal/web/url_windows_test.go b/go/src/cmd/go/internal/web/url_windows_test.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..06386a038988ca9a3bc34dcf5b7b072e1bdaf9ca
    --- /dev/null
    +++ b/go/src/cmd/go/internal/web/url_windows_test.go
    @@ -0,0 +1,94 @@
    +// Copyright 2019 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package web
    +
    +var urlTests = []struct {
    +	url          string
    +	filePath     string
    +	canonicalURL string // If empty, assume equal to url.
    +	wantErr      string
    +}{
    +	// Examples from https://blogs.msdn.microsoft.com/ie/2006/12/06/file-uris-in-windows/:
    +
    +	{
    +		url:      `file://laptop/My%20Documents/FileSchemeURIs.doc`,
    +		filePath: `\\laptop\My Documents\FileSchemeURIs.doc`,
    +	},
    +	{
    +		url:      `file:///C:/Documents%20and%20Settings/davris/FileSchemeURIs.doc`,
    +		filePath: `C:\Documents and Settings\davris\FileSchemeURIs.doc`,
    +	},
    +	{
    +		url:      `file:///D:/Program%20Files/Viewer/startup.htm`,
    +		filePath: `D:\Program Files\Viewer\startup.htm`,
    +	},
    +	{
    +		url:          `file:///C:/Program%20Files/Music/Web%20Sys/main.html?REQUEST=RADIO`,
    +		filePath:     `C:\Program Files\Music\Web Sys\main.html`,
    +		canonicalURL: `file:///C:/Program%20Files/Music/Web%20Sys/main.html`,
    +	},
    +	{
    +		url:      `file://applib/products/a-b/abc_9/4148.920a/media/start.swf`,
    +		filePath: `\\applib\products\a-b\abc_9\4148.920a\media\start.swf`,
    +	},
    +	{
    +		url:     `file:////applib/products/a%2Db/abc%5F9/4148.920a/media/start.swf`,
    +		wantErr: "file URL missing drive letter",
    +	},
    +	{
    +		url:     `C:\Program Files\Music\Web Sys\main.html?REQUEST=RADIO`,
    +		wantErr: "non-file URL",
    +	},
    +
    +	// The example "file://D:\Program Files\Viewer\startup.htm" errors out in
    +	// url.Parse, so we substitute a slash-based path for testing instead.
    +	{
    +		url:     `file://D:/Program Files/Viewer/startup.htm`,
    +		wantErr: "file URL encodes volume in host field: too few slashes?",
    +	},
    +
    +	// The blog post discourages the use of non-ASCII characters because they
    +	// depend on the user's current codepage. However, when we are working with Go
    +	// strings we assume UTF-8 encoding, and our url package refuses to encode
    +	// URLs to non-ASCII strings.
    +	{
    +		url:          `file:///C:/exampleㄓ.txt`,
    +		filePath:     `C:\exampleㄓ.txt`,
    +		canonicalURL: `file:///C:/example%E3%84%93.txt`,
    +	},
    +	{
    +		url:      `file:///C:/example%E3%84%93.txt`,
    +		filePath: `C:\exampleㄓ.txt`,
    +	},
    +
    +	// Examples from RFC 8089:
    +
    +	// We allow the drive-letter variation from section E.2, because it is
    +	// simpler to support than not to. However, we do not generate the shorter
    +	// form in the reverse direction.
    +	{
    +		url:          `file:c:/path/to/file`,
    +		filePath:     `c:\path\to\file`,
    +		canonicalURL: `file:///c:/path/to/file`,
    +	},
    +
    +	// We encode the UNC share name as the authority following section E.3.1,
    +	// because that is what the Microsoft blog post explicitly recommends.
    +	{
    +		url:      `file://host.example.com/Share/path/to/file.txt`,
    +		filePath: `\\host.example.com\Share\path\to\file.txt`,
    +	},
    +
    +	// We decline the four- and five-slash variations from section E.3.2.
    +	// The paths in these URLs would change meaning under path.Clean.
    +	{
    +		url:     `file:////host.example.com/path/to/file`,
    +		wantErr: "file URL missing drive letter",
    +	},
    +	{
    +		url:     `file://///host.example.com/path/to/file`,
    +		wantErr: "file URL missing drive letter",
    +	},
    +}
    diff --git a/go/src/cmd/go/internal/work/action.go b/go/src/cmd/go/internal/work/action.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..f0e34c33689b6a16881fc2cdc623d3939fe6730e
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/action.go
    @@ -0,0 +1,1267 @@
    +// Copyright 2011 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Action graph creation (planning).
    +
    +package work
    +
    +import (
    +	"bufio"
    +	"bytes"
    +	"cmd/internal/cov/covcmd"
    +	"cmd/internal/par"
    +	"container/heap"
    +	"context"
    +	"debug/elf"
    +	"encoding/json"
    +	"fmt"
    +	"internal/platform"
    +	"os"
    +	"path/filepath"
    +	"slices"
    +	"strings"
    +	"sync"
    +	"time"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cache"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/load"
    +	"cmd/go/internal/modload"
    +	"cmd/go/internal/str"
    +	"cmd/go/internal/trace"
    +	"cmd/internal/buildid"
    +	"cmd/internal/robustio"
    +)
    +
    +// A Builder holds global state about a build.
    +// It does not hold per-package state, because we
    +// build packages in parallel, and the builder is shared.
    +type Builder struct {
    +	WorkDir            string                    // the temporary work directory (ends in filepath.Separator)
    +	getVendorDir       func() string             // TODO(jitsu): remove this after we eliminate global module state
    +	actionCache        map[cacheKey]*Action      // a cache of already-constructed actions
    +	flagCache          map[[2]string]bool        // a cache of supported compiler flags
    +	gccCompilerIDCache map[string]cache.ActionID // cache for gccCompilerID
    +
    +	IsCmdList           bool // running as part of go list; set p.Stale and additional fields below
    +	NeedError           bool // list needs p.Error
    +	NeedExport          bool // list needs p.Export
    +	NeedCompiledGoFiles bool // list needs p.CompiledGoFiles
    +	AllowErrors         bool // errors don't immediately exit the program
    +
    +	objdirSeq int // counter for NewObjdir
    +	pkgSeq    int
    +
    +	backgroundSh *Shell // Shell that per-Action Shells are derived from
    +
    +	exec      sync.Mutex
    +	readySema chan bool
    +	ready     actionQueue
    +
    +	id             sync.Mutex
    +	toolIDCache    par.Cache[string, string] // tool name -> tool ID
    +	gccToolIDCache map[string]string         // tool name -> tool ID
    +	buildIDCache   map[string]string         // file name -> build ID
    +}
    +
    +// NOTE: Much of Action would not need to be exported if not for test.
    +// Maybe test functionality should move into this package too?
    +
    +// An Actor runs an action.
    +type Actor interface {
    +	Act(*Builder, context.Context, *Action) error
    +}
    +
    +// An ActorFunc is an Actor that calls the function.
    +type ActorFunc func(*Builder, context.Context, *Action) error
    +
    +func (f ActorFunc) Act(b *Builder, ctx context.Context, a *Action) error {
    +	return f(b, ctx, a)
    +}
    +
    +// An Action represents a single action in the action graph.
    +type Action struct {
    +	Mode       string        // description of action operation
    +	Package    *load.Package // the package this action works on
    +	Deps       []*Action     // actions that must happen before this one
    +	Actor      Actor         // the action itself (nil = no-op)
    +	IgnoreFail bool          // whether to run f even if dependencies fail
    +	TestOutput *bytes.Buffer // test output buffer
    +	Args       []string      // additional args for runProgram
    +
    +	Provider any // Additional information to be passed to successive actions. Similar to a Bazel provider.
    +
    +	triggers []*Action // inverse of deps
    +
    +	buggyInstall bool // is this a buggy install (see -linkshared)?
    +
    +	TryCache func(*Builder, *Action, *Action) bool // callback for cache bypass
    +
    +	CacheExecutable bool // Whether to cache executables produced by link steps
    +
    +	// Generated files, directories.
    +	Objdir           string         // directory for intermediate objects
    +	Target           string         // goal of the action: the created package or executable
    +	built            string         // the actual created package or executable
    +	cachedExecutable string         // the cached executable, if CacheExecutable was set
    +	actionID         cache.ActionID // cache ID of action input
    +	buildID          string         // build ID of action output
    +
    +	VetxOnly   bool       // Mode=="vet": only being called to supply info about dependencies
    +	needVet    bool       // Mode=="build": need to fill in vet config
    +	needBuild  bool       // Mode=="build": need to do actual build (can be false if needVet is true)
    +	needFix    bool       // Mode=="vet": need secondary target, a .zip file containing fixes
    +	vetCfg     *vetConfig // vet config
    +	FixArchive string     // the created .zip file containing fixes (if needFix)
    +	output     []byte     // output redirect buffer (nil means use b.Print)
    +
    +	sh *Shell // lazily created per-Action shell; see Builder.Shell
    +
    +	// Execution state.
    +	pending      int               // number of deps yet to complete
    +	priority     int               // relative execution priority
    +	Failed       *Action           // set to root cause if the action failed
    +	json         *actionJSON       // action graph information
    +	nonGoOverlay map[string]string // map from non-.go source files to copied files in objdir. Nil if no overlay is used.
    +	traceSpan    *trace.Span
    +}
    +
    +// BuildActionID returns the action ID section of a's build ID.
    +func (a *Action) BuildActionID() string { return actionID(a.buildID) }
    +
    +// BuildContentID returns the content ID section of a's build ID.
    +func (a *Action) BuildContentID() string { return contentID(a.buildID) }
    +
    +// BuildID returns a's build ID.
    +func (a *Action) BuildID() string { return a.buildID }
    +
    +// BuiltTarget returns the actual file that was built. This differs
    +// from Target when the result was cached.
    +func (a *Action) BuiltTarget() string { return a.built }
    +
    +// CachedExecutable returns the cached executable, if CacheExecutable
    +// was set and the executable could be cached, and "" otherwise.
    +func (a *Action) CachedExecutable() string { return a.cachedExecutable }
    +
    +// An actionQueue is a priority queue of actions.
    +type actionQueue []*Action
    +
    +// Implement heap.Interface
    +func (q *actionQueue) Len() int           { return len(*q) }
    +func (q *actionQueue) Swap(i, j int)      { (*q)[i], (*q)[j] = (*q)[j], (*q)[i] }
    +func (q *actionQueue) Less(i, j int) bool { return (*q)[i].priority < (*q)[j].priority }
    +func (q *actionQueue) Push(x any)         { *q = append(*q, x.(*Action)) }
    +func (q *actionQueue) Pop() any {
    +	n := len(*q) - 1
    +	x := (*q)[n]
    +	*q = (*q)[:n]
    +	return x
    +}
    +
    +func (q *actionQueue) push(a *Action) {
    +	if a.json != nil {
    +		a.json.TimeReady = time.Now()
    +	}
    +	heap.Push(q, a)
    +}
    +
    +func (q *actionQueue) pop() *Action {
    +	return heap.Pop(q).(*Action)
    +}
    +
    +type actionJSON struct {
    +	ID         int
    +	Mode       string
    +	Package    string
    +	Deps       []int     `json:",omitempty"`
    +	IgnoreFail bool      `json:",omitempty"`
    +	Args       []string  `json:",omitempty"`
    +	Link       bool      `json:",omitempty"`
    +	Objdir     string    `json:",omitempty"`
    +	Target     string    `json:",omitempty"`
    +	Priority   int       `json:",omitempty"`
    +	Failed     bool      `json:",omitempty"`
    +	Built      string    `json:",omitempty"`
    +	VetxOnly   bool      `json:",omitempty"`
    +	NeedVet    bool      `json:",omitempty"`
    +	NeedBuild  bool      `json:",omitempty"`
    +	ActionID   string    `json:",omitempty"`
    +	BuildID    string    `json:",omitempty"`
    +	TimeReady  time.Time `json:",omitempty"`
    +	TimeStart  time.Time `json:",omitempty"`
    +	TimeDone   time.Time `json:",omitempty"`
    +
    +	Cmd     []string      // `json:",omitempty"`
    +	CmdReal time.Duration `json:",omitempty"`
    +	CmdUser time.Duration `json:",omitempty"`
    +	CmdSys  time.Duration `json:",omitempty"`
    +}
    +
    +// cacheKey is the key for the action cache.
    +type cacheKey struct {
    +	mode string
    +	p    *load.Package
    +}
    +
    +func actionGraphJSON(a *Action) string {
    +	var workq []*Action
    +	var inWorkq = make(map[*Action]int)
    +
    +	add := func(a *Action) {
    +		if _, ok := inWorkq[a]; ok {
    +			return
    +		}
    +		inWorkq[a] = len(workq)
    +		workq = append(workq, a)
    +	}
    +	add(a)
    +
    +	for i := 0; i < len(workq); i++ {
    +		for _, dep := range workq[i].Deps {
    +			add(dep)
    +		}
    +	}
    +
    +	list := make([]*actionJSON, 0, len(workq))
    +	for id, a := range workq {
    +		if a.json == nil {
    +			a.json = &actionJSON{
    +				Mode:       a.Mode,
    +				ID:         id,
    +				IgnoreFail: a.IgnoreFail,
    +				Args:       a.Args,
    +				Objdir:     a.Objdir,
    +				Target:     a.Target,
    +				Failed:     a.Failed != nil,
    +				Priority:   a.priority,
    +				Built:      a.built,
    +				VetxOnly:   a.VetxOnly,
    +				NeedBuild:  a.needBuild,
    +				NeedVet:    a.needVet,
    +			}
    +			if a.Package != nil {
    +				// TODO(rsc): Make this a unique key for a.Package somehow.
    +				a.json.Package = a.Package.ImportPath
    +			}
    +			for _, a1 := range a.Deps {
    +				a.json.Deps = append(a.json.Deps, inWorkq[a1])
    +			}
    +		}
    +		list = append(list, a.json)
    +	}
    +
    +	js, err := json.MarshalIndent(list, "", "\t")
    +	if err != nil {
    +		fmt.Fprintf(os.Stderr, "go: writing debug action graph: %v\n", err)
    +		return ""
    +	}
    +	return string(js)
    +}
    +
    +// BuildMode specifies the build mode:
    +// are we just building things or also installing the results?
    +type BuildMode int
    +
    +const (
    +	ModeBuild BuildMode = iota
    +	ModeInstall
    +	ModeBuggyInstall
    +
    +	ModeVetOnly = 1 << 8
    +)
    +
    +// NewBuilder returns a new Builder ready for use.
    +//
    +// If workDir is the empty string, NewBuilder creates a WorkDir if needed
    +// and arranges for it to be removed in case of an unclean exit.
    +// The caller must Close the builder explicitly to clean up the WorkDir
    +// before a clean exit.
    +func NewBuilder(workDir string, getVendorDir func() string) *Builder {
    +	b := new(Builder)
    +	b.getVendorDir = getVendorDir
    +
    +	b.actionCache = make(map[cacheKey]*Action)
    +	b.gccToolIDCache = make(map[string]string)
    +	b.buildIDCache = make(map[string]string)
    +
    +	printWorkDir := false
    +	if workDir != "" {
    +		b.WorkDir = workDir
    +	} else if cfg.BuildN {
    +		b.WorkDir = "$WORK"
    +	} else {
    +		if !buildInitStarted {
    +			panic("internal error: NewBuilder called before BuildInit")
    +		}
    +		tmp, err := os.MkdirTemp(cfg.Getenv("GOTMPDIR"), "go-build")
    +		if err != nil {
    +			base.Fatalf("go: creating work dir: %v", err)
    +		}
    +		if !filepath.IsAbs(tmp) {
    +			abs, err := filepath.Abs(tmp)
    +			if err != nil {
    +				os.RemoveAll(tmp)
    +				base.Fatalf("go: creating work dir: %v", err)
    +			}
    +			tmp = abs
    +		}
    +		b.WorkDir = tmp
    +		builderWorkDirs.Store(b, b.WorkDir)
    +		printWorkDir = cfg.BuildX || cfg.BuildWork
    +	}
    +
    +	b.backgroundSh = NewShell(b.WorkDir, nil)
    +
    +	if printWorkDir {
    +		b.BackgroundShell().Printf("WORK=%s\n", b.WorkDir)
    +	}
    +
    +	if err := CheckGOOSARCHPair(cfg.Goos, cfg.Goarch); err != nil {
    +		fmt.Fprintf(os.Stderr, "go: %v\n", err)
    +		base.SetExitStatus(2)
    +		base.Exit()
    +	}
    +
    +	for _, tag := range cfg.BuildContext.BuildTags {
    +		if strings.Contains(tag, ",") {
    +			fmt.Fprintf(os.Stderr, "go: -tags space-separated list contains comma\n")
    +			base.SetExitStatus(2)
    +			base.Exit()
    +		}
    +	}
    +
    +	return b
    +}
    +
    +var builderWorkDirs sync.Map // *Builder → WorkDir
    +
    +func (b *Builder) Close() error {
    +	wd, ok := builderWorkDirs.Load(b)
    +	if !ok {
    +		return nil
    +	}
    +	defer builderWorkDirs.Delete(b)
    +
    +	if b.WorkDir != wd.(string) {
    +		base.Errorf("go: internal error: Builder WorkDir unexpectedly changed from %s to %s", wd, b.WorkDir)
    +	}
    +
    +	if !cfg.BuildWork {
    +		if err := robustio.RemoveAll(b.WorkDir); err != nil {
    +			return err
    +		}
    +	}
    +	b.WorkDir = ""
    +	return nil
    +}
    +
    +func closeBuilders() {
    +	leakedBuilders := 0
    +	builderWorkDirs.Range(func(bi, _ any) bool {
    +		leakedBuilders++
    +		if err := bi.(*Builder).Close(); err != nil {
    +			base.Error(err)
    +		}
    +		return true
    +	})
    +
    +	if leakedBuilders > 0 && base.GetExitStatus() == 0 {
    +		fmt.Fprintf(os.Stderr, "go: internal error: Builder leaked on successful exit\n")
    +		base.SetExitStatus(1)
    +	}
    +}
    +
    +func CheckGOOSARCHPair(goos, goarch string) error {
    +	if !platform.BuildModeSupported(cfg.BuildContext.Compiler, "default", goos, goarch) {
    +		return fmt.Errorf("unsupported GOOS/GOARCH pair %s/%s", goos, goarch)
    +	}
    +	return nil
    +}
    +
    +// NewObjdir returns the name of a fresh object directory under b.WorkDir.
    +// It is up to the caller to call b.Mkdir on the result at an appropriate time.
    +// The result ends in a slash, so that file names in that directory
    +// can be constructed with direct string addition.
    +//
    +// NewObjdir must be called only from a single goroutine at a time,
    +// so it is safe to call during action graph construction, but it must not
    +// be called during action graph execution.
    +func (b *Builder) NewObjdir() string {
    +	b.objdirSeq++
    +	return str.WithFilePathSeparator(filepath.Join(b.WorkDir, fmt.Sprintf("b%03d", b.objdirSeq)))
    +}
    +
    +// readpkglist returns the list of packages that were built into the shared library
    +// at shlibpath. For the native toolchain this list is stored, newline separated, in
    +// an ELF note with name "Go\x00\x00" and type 1. For GCCGO it is extracted from the
    +// .go_export section.
    +func readpkglist(s *modload.State, shlibpath string) (pkgs []*load.Package) {
    +	var stk load.ImportStack
    +	if cfg.BuildToolchainName == "gccgo" {
    +		f, err := elf.Open(shlibpath)
    +		if err != nil {
    +			base.Fatal(fmt.Errorf("failed to open shared library: %v", err))
    +		}
    +		defer f.Close()
    +		sect := f.Section(".go_export")
    +		if sect == nil {
    +			base.Fatal(fmt.Errorf("%s: missing .go_export section", shlibpath))
    +		}
    +		data, err := sect.Data()
    +		if err != nil {
    +			base.Fatal(fmt.Errorf("%s: failed to read .go_export section: %v", shlibpath, err))
    +		}
    +		pkgpath := []byte("pkgpath ")
    +		for _, line := range bytes.Split(data, []byte{'\n'}) {
    +			if path, found := bytes.CutPrefix(line, pkgpath); found {
    +				path = bytes.TrimSuffix(path, []byte{';'})
    +				pkgs = append(pkgs, load.LoadPackageWithFlags(s, string(path), base.Cwd(), &stk, nil, 0))
    +			}
    +		}
    +	} else {
    +		pkglistbytes, err := buildid.ReadELFNote(shlibpath, "Go\x00\x00", 1)
    +		if err != nil {
    +			base.Fatalf("readELFNote failed: %v", err)
    +		}
    +		scanner := bufio.NewScanner(bytes.NewBuffer(pkglistbytes))
    +		for scanner.Scan() {
    +			t := scanner.Text()
    +			pkgs = append(pkgs, load.LoadPackageWithFlags(s, t, base.Cwd(), &stk, nil, 0))
    +		}
    +	}
    +	return
    +}
    +
    +// cacheAction looks up {mode, p} in the cache and returns the resulting action.
    +// If the cache has no such action, f() is recorded and returned.
    +// TODO(rsc): Change the second key from *load.Package to interface{},
    +// to make the caching in linkShared less awkward?
    +func (b *Builder) cacheAction(mode string, p *load.Package, f func() *Action) *Action {
    +	a := b.actionCache[cacheKey{mode, p}]
    +	if a == nil {
    +		a = f()
    +		b.actionCache[cacheKey{mode, p}] = a
    +	}
    +	return a
    +}
    +
    +// AutoAction returns the "right" action for go build or go install of p.
    +func (b *Builder) AutoAction(s *modload.State, mode, depMode BuildMode, p *load.Package) *Action {
    +	if p.Name == "main" {
    +		return b.LinkAction(s, mode, depMode, p)
    +	}
    +	return b.CompileAction(mode, depMode, p)
    +}
    +
    +// buildActor implements the Actor interface for package build
    +// actions. For most package builds this simply means invoking the
    +// *Builder.build method.
    +type buildActor struct{}
    +
    +func (ba *buildActor) Act(b *Builder, ctx context.Context, a *Action) error {
    +	return b.build(ctx, a)
    +}
    +
    +// pgoActionID computes the action ID for a preprocess PGO action.
    +func (b *Builder) pgoActionID(input string) cache.ActionID {
    +	h := cache.NewHash("preprocess PGO profile " + input)
    +
    +	fmt.Fprintf(h, "preprocess PGO profile\n")
    +	fmt.Fprintf(h, "preprofile %s\n", b.toolID("preprofile"))
    +	fmt.Fprintf(h, "input %q\n", b.fileHash(input))
    +
    +	return h.Sum()
    +}
    +
    +// pgoActor implements the Actor interface for preprocessing PGO profiles.
    +type pgoActor struct {
    +	// input is the path to the original pprof profile.
    +	input string
    +}
    +
    +func (p *pgoActor) Act(b *Builder, ctx context.Context, a *Action) error {
    +	if b.useCache(a, b.pgoActionID(p.input), a.Target, !b.IsCmdList) || b.IsCmdList {
    +		return nil
    +	}
    +	defer b.flushOutput(a)
    +
    +	sh := b.Shell(a)
    +
    +	if err := sh.Mkdir(a.Objdir); err != nil {
    +		return err
    +	}
    +
    +	if err := sh.run(".", p.input, nil, cfg.BuildToolexec, base.Tool("preprofile"), "-o", a.Target, "-i", p.input); err != nil {
    +		return err
    +	}
    +
    +	// N.B. Builder.build looks for the out in a.built, regardless of
    +	// whether this came from cache.
    +	a.built = a.Target
    +
    +	if !cfg.BuildN {
    +		// Cache the output.
    +		//
    +		// N.B. We don't use updateBuildID here, as preprocessed PGO profiles
    +		// do not contain a build ID. updateBuildID is typically responsible
    +		// for adding to the cache, thus we must do so ourselves instead.
    +
    +		r, err := os.Open(a.Target)
    +		if err != nil {
    +			return fmt.Errorf("error opening target for caching: %w", err)
    +		}
    +
    +		c := cache.Default()
    +		outputID, _, err := c.Put(a.actionID, r)
    +		r.Close()
    +		if err != nil {
    +			return fmt.Errorf("error adding target to cache: %w", err)
    +		}
    +		if cfg.BuildX {
    +			sh.ShowCmd("", "%s # internal", joinUnambiguously(str.StringList("cp", a.Target, c.OutputFile(outputID))))
    +		}
    +	}
    +
    +	return nil
    +}
    +
    +type checkCacheProvider struct {
    +	need uint32 // What work do successive actions within this package's build need to do? Combination of need bits used in build actions.
    +}
    +
    +// The actor to check the cache to determine what work needs to be done for the action.
    +// It checks the cache and sets the need bits depending on the build mode and what's available
    +// in the cache, so the cover and compile actions know what to do.
    +// Currently, we don't cache the outputs of the individual actions composing the build
    +// for a single package (such as the output of the cover actor) separately from the
    +// output of the final build, but if we start doing so, we could schedule the run cgo
    +// and cgo compile actions earlier because they wouldn't depend on the builds of the
    +// dependencies of the package they belong to.
    +type checkCacheActor struct {
    +	covMetaFileName string
    +	buildAction     *Action
    +}
    +
    +func (cca *checkCacheActor) Act(b *Builder, ctx context.Context, a *Action) error {
    +	buildAction := cca.buildAction
    +	if buildAction.Mode == "build-install" {
    +		// (*Builder).installAction can rewrite the build action with its install action,
    +		// making the true build action its dependency. Fetch the build action in that case.
    +		buildAction = buildAction.Deps[0]
    +	}
    +	pr, err := b.checkCacheForBuild(a, buildAction, cca.covMetaFileName)
    +	if err != nil {
    +		return err
    +	}
    +	a.Provider = pr
    +	return nil
    +}
    +
    +type coverProvider struct {
    +	goSources, cgoSources []string // The go and cgo sources generated by the cover tool, which should be used instead of the raw sources on the package.
    +}
    +
    +// The actor to run the cover tool to produce instrumented source files for cover
    +// builds. In the case of a package with no test files, we store some additional state
    +// information in the build actor to help with reporting.
    +type coverActor struct {
    +	// name of static meta-data file fragment emitted by the cover
    +	// tool as part of the package cover action, for selected
    +	// "go test -cover" runs.
    +	covMetaFileName string
    +
    +	buildAction *Action
    +}
    +
    +func (ca *coverActor) Act(b *Builder, ctx context.Context, a *Action) error {
    +	pr, err := b.runCover(a, ca.buildAction, a.Objdir, a.Package.GoFiles, a.Package.CgoFiles)
    +	if err != nil {
    +		return err
    +	}
    +	a.Provider = pr
    +	return nil
    +}
    +
    +// runCgoActor implements the Actor interface for running the cgo command for the package.
    +type runCgoActor struct {
    +}
    +
    +func (c runCgoActor) Act(b *Builder, ctx context.Context, a *Action) error {
    +	var cacheProvider *checkCacheProvider
    +	for _, a1 := range a.Deps {
    +		if pr, ok := a1.Provider.(*checkCacheProvider); ok {
    +			cacheProvider = pr
    +			break
    +		}
    +	}
    +	need := cacheProvider.need
    +	need &^= needCovMetaFile // handled by cover action
    +	if need == 0 {
    +		return nil
    +	}
    +	return b.runCgo(ctx, a)
    +}
    +
    +type cgoCompileActor struct {
    +	file string
    +
    +	compileFunc  func(*Action, string, string, []string, string) error
    +	getFlagsFunc func(*runCgoProvider) []string
    +
    +	flags *[]string
    +}
    +
    +func (c cgoCompileActor) Act(b *Builder, ctx context.Context, a *Action) error {
    +	pr, ok := a.Deps[0].Provider.(*runCgoProvider)
    +	if !ok {
    +		return nil // cgo was not needed. do nothing.
    +	}
    +	a.nonGoOverlay = pr.nonGoOverlay
    +	buildAction := a.triggers[0].triggers[0] // cgo compile -> cgo collect -> build
    +
    +	a.actionID = cache.Subkey(buildAction.actionID, "cgo compile "+c.file) // buildAction's action id was computed by the check cache action.
    +	return c.compileFunc(a, a.Objdir, a.Target, c.getFlagsFunc(pr), c.file)
    +}
    +
    +// CompileAction returns the action for compiling and possibly installing
    +// (according to mode) the given package. The resulting action is only
    +// for building packages (archives), never for linking executables.
    +// depMode is the action (build or install) to use when building dependencies.
    +// To turn package main into an executable, call b.Link instead.
    +func (b *Builder) CompileAction(mode, depMode BuildMode, p *load.Package) *Action {
    +	vetOnly := mode&ModeVetOnly != 0
    +	mode &^= ModeVetOnly
    +
    +	if mode != ModeBuild && p.Target == "" {
    +		// No permanent target.
    +		mode = ModeBuild
    +	}
    +	if mode != ModeBuild && p.Name == "main" {
    +		// We never install the .a file for a main package.
    +		mode = ModeBuild
    +	}
    +
    +	// Construct package build action.
    +	a := b.cacheAction("build", p, func() *Action {
    +		a := &Action{
    +			Mode:    "build",
    +			Package: p,
    +			Actor:   &buildActor{},
    +			Objdir:  b.NewObjdir(),
    +		}
    +
    +		if p.Error == nil || !p.Error.IsImportCycle {
    +			for _, p1 := range p.Internal.Imports {
    +				a.Deps = append(a.Deps, b.CompileAction(depMode, depMode, p1))
    +			}
    +		}
    +
    +		if p.Internal.PGOProfile != "" {
    +			pgoAction := b.cacheAction("preprocess PGO profile "+p.Internal.PGOProfile, nil, func() *Action {
    +				a := &Action{
    +					Mode:   "preprocess PGO profile",
    +					Actor:  &pgoActor{input: p.Internal.PGOProfile},
    +					Objdir: b.NewObjdir(),
    +				}
    +				a.Target = filepath.Join(a.Objdir, "pgo.preprofile")
    +
    +				return a
    +			})
    +			a.Deps = append(a.Deps, pgoAction)
    +		}
    +
    +		if p.Standard {
    +			switch p.ImportPath {
    +			case "builtin", "unsafe":
    +				// Fake packages - nothing to build.
    +				a.Mode = "built-in package"
    +				a.Actor = nil
    +				return a
    +			}
    +
    +			// gccgo standard library is "fake" too.
    +			if cfg.BuildToolchainName == "gccgo" {
    +				// the target name is needed for cgo.
    +				a.Mode = "gccgo stdlib"
    +				a.Target = p.Target
    +				a.Actor = nil
    +				return a
    +			}
    +		}
    +
    +		// Determine the covmeta file name.
    +		var covMetaFileName string
    +		if p.Internal.Cover.GenMeta {
    +			covMetaFileName = covcmd.MetaFileForPackage(p.ImportPath)
    +		}
    +
    +		// Create a cache action.
    +		cacheAction := &Action{
    +			Mode:    "build check cache",
    +			Package: p,
    +			Actor:   &checkCacheActor{buildAction: a, covMetaFileName: covMetaFileName},
    +			Objdir:  a.Objdir,
    +			Deps:    a.Deps, // Need outputs of dependency build actions to generate action id.
    +		}
    +		a.Deps = append(a.Deps, cacheAction)
    +
    +		// Create a cover action if we need to instrument the code for coverage.
    +		// The cover action always runs in the same go build invocation as the build,
    +		// and is not cached separately, so it can use the same objdir.
    +		var coverAction *Action
    +		if p.Internal.Cover.Mode != "" {
    +			coverAction = b.cacheAction("cover", p, func() *Action {
    +				return &Action{
    +					Mode:    "cover",
    +					Package: p,
    +					Actor:   &coverActor{buildAction: a, covMetaFileName: covMetaFileName},
    +					Objdir:  a.Objdir,
    +					Deps:    []*Action{cacheAction},
    +				}
    +			})
    +			a.Deps = append(a.Deps, coverAction)
    +		}
    +
    +		// Create actions to run swig and cgo if needed. These actions always run in the
    +		// same go build invocation as the build action and their actions are not cached
    +		// separately, so they can use the same objdir.
    +		if p.UsesCgo() || p.UsesSwig() {
    +			deps := []*Action{cacheAction}
    +			if coverAction != nil {
    +				deps = append(deps, coverAction)
    +			}
    +			a.Deps = append(a.Deps, b.cgoAction(p, a.Objdir, deps, coverAction != nil))
    +		}
    +
    +		return a
    +	})
    +
    +	// Find the build action; the cache entry may have been replaced
    +	// by the install action during (*Builder).installAction.
    +	buildAction := a
    +	switch buildAction.Mode {
    +	case "build", "built-in package", "gccgo stdlib":
    +		// ok
    +	case "build-install":
    +		buildAction = a.Deps[0]
    +	default:
    +		panic("lost build action: " + buildAction.Mode)
    +	}
    +	buildAction.needBuild = buildAction.needBuild || !vetOnly
    +
    +	// Construct install action.
    +	if mode == ModeInstall || mode == ModeBuggyInstall {
    +		a = b.installAction(a, mode)
    +	}
    +
    +	return a
    +}
    +
    +func (b *Builder) cgoAction(p *load.Package, objdir string, deps []*Action, hasCover bool) *Action {
    +	cgoCollectAction := b.cacheAction("cgo collect", p, func() *Action {
    +		// Run cgo
    +		runCgo := b.cacheAction("cgo run", p, func() *Action {
    +			return &Action{
    +				Package: p,
    +				Mode:    "cgo run",
    +				Actor:   &runCgoActor{},
    +				Objdir:  objdir,
    +				Deps:    deps,
    +			}
    +		})
    +
    +		// Determine which files swig will produce in the cgo run action. We'll need to create
    +		// actions to compile the C and C++ files produced by swig, as well as the C file
    +		// produced by cgo processing swig's Go file outputs.
    +		swigGo, swigC, swigCXX := b.swigOutputs(p, objdir)
    +
    +		oseq := 0
    +		nextOfile := func() string {
    +			oseq++
    +			return objdir + fmt.Sprintf("_x%03d.o", oseq)
    +		}
    +		compileAction := func(file string, getFlagsFunc func(*runCgoProvider) []string, compileFunc func(*Action, string, string, []string, string) error) *Action {
    +			mode := "cgo compile " + file
    +			return b.cacheAction(mode, p, func() *Action {
    +				return &Action{
    +					Package: p,
    +					Mode:    mode,
    +					Actor:   &cgoCompileActor{file: file, getFlagsFunc: getFlagsFunc, compileFunc: compileFunc},
    +					Deps:    []*Action{runCgo},
    +					Objdir:  objdir,
    +					Target:  nextOfile(),
    +				}
    +			})
    +		}
    +
    +		var collectDeps []*Action
    +
    +		// Add compile actions for C files generated by cgo.
    +		cgoFiles := p.CgoFiles
    +		if hasCover {
    +			cgoFiles = slices.Clone(cgoFiles)
    +			for i := range cgoFiles {
    +				cgoFiles[i] = strings.TrimSuffix(cgoFiles[i], ".go") + ".cover.go"
    +			}
    +		}
    +		cfiles := []string{"_cgo_export.c"}
    +		for _, fn := range slices.Concat(cgoFiles, swigGo) {
    +			cfiles = append(cfiles, strings.TrimSuffix(filepath.Base(fn), ".go")+".cgo2.c")
    +		}
    +		for _, f := range cfiles {
    +			collectDeps = append(collectDeps, compileAction(objdir+f, (*runCgoProvider).cflags, b.gcc))
    +		}
    +
    +		// Add compile actions for S files.
    +		var sfiles []string
    +		// In a package using cgo, cgo compiles the C, C++ and assembly files with gcc.
    +		// There is one exception: runtime/cgo's job is to bridge the
    +		// cgo and non-cgo worlds, so it necessarily has files in both.
    +		// In that case gcc only gets the gcc_* files.
    +		if p.Standard && p.ImportPath == "runtime/cgo" {
    +			for _, f := range p.SFiles {
    +				if strings.HasPrefix(f, "gcc_") {
    +					sfiles = append(sfiles, f)
    +				}
    +			}
    +		} else {
    +			sfiles = p.SFiles
    +		}
    +		for _, f := range sfiles {
    +			collectDeps = append(collectDeps, compileAction(f, (*runCgoProvider).cflags, b.gas))
    +		}
    +
    +		// Add compile actions for C files in the package, M files, and those generated by swig.
    +		for _, f := range slices.Concat(p.CFiles, p.MFiles, swigC) {
    +			collectDeps = append(collectDeps, compileAction(f, (*runCgoProvider).cflags, b.gcc))
    +		}
    +
    +		// Add compile actions for C++ files in the package, and those generated by swig.
    +		for _, f := range slices.Concat(p.CXXFiles, swigCXX) {
    +			collectDeps = append(collectDeps, compileAction(f, (*runCgoProvider).cxxflags, b.gxx))
    +		}
    +
    +		// Add compile actions for Fortran files in the package.
    +		for _, f := range p.FFiles {
    +			collectDeps = append(collectDeps, compileAction(f, (*runCgoProvider).fflags, b.gfortran))
    +		}
    +
    +		// Add a single convenience action that does nothing to join the previous action,
    +		// and better separate the cgo action dependencies of the build action from the
    +		// build actions for its package dependencies.
    +		return &Action{
    +			Mode: "collect cgo",
    +			Actor: ActorFunc(func(b *Builder, ctx context.Context, a *Action) error {
    +				// Use the cgo run action's provider as our provider output,
    +				// so it can be easily accessed by the build action.
    +				a.Provider = a.Deps[0].Deps[0].Provider
    +				return nil
    +			}),
    +			Deps:   collectDeps,
    +			Objdir: objdir,
    +		}
    +	})
    +
    +	return cgoCollectAction
    +}
    +
    +// VetAction returns the action for running go vet on package p.
    +// It depends on the action for compiling p.
    +// If the caller may be causing p to be installed, it is up to the caller
    +// to make sure that the install depends on (runs after) vet.
    +func (b *Builder) VetAction(s *modload.State, mode, depMode BuildMode, needFix bool, p *load.Package) *Action {
    +	a := b.vetAction(s, mode, depMode, p)
    +	a.VetxOnly = false
    +	a.needFix = needFix
    +	return a
    +}
    +
    +func (b *Builder) vetAction(s *modload.State, mode, depMode BuildMode, p *load.Package) *Action {
    +	// Construct vet action.
    +	a := b.cacheAction("vet", p, func() *Action {
    +		a1 := b.CompileAction(mode|ModeVetOnly, depMode, p)
    +
    +		var deps []*Action
    +		if a1.buggyInstall {
    +			// (*Builder).vet expects deps[0] to be the package.
    +			// If we see buggyInstall
    +			// here then a1 is an install of a shared library,
    +			// and the real package is a1.Deps[0].
    +			deps = []*Action{a1.Deps[0], a1}
    +		} else {
    +			deps = []*Action{a1}
    +		}
    +		for _, p1 := range p.Internal.Imports {
    +			deps = append(deps, b.vetAction(s, mode, depMode, p1))
    +		}
    +
    +		a := &Action{
    +			Mode:       "vet",
    +			Package:    p,
    +			Deps:       deps,
    +			Objdir:     a1.Objdir,
    +			VetxOnly:   true,
    +			IgnoreFail: true, // it's OK if vet of dependencies "fails" (reports problems)
    +		}
    +		if a1.Actor == nil {
    +			// Built-in packages like unsafe.
    +			return a
    +		}
    +		deps[0].needVet = true
    +		a.Actor = ActorFunc((*Builder).vet)
    +		return a
    +	})
    +	return a
    +}
    +
    +// LinkAction returns the action for linking p into an executable
    +// and possibly installing the result (according to mode).
    +// depMode is the action (build or install) to use when compiling dependencies.
    +func (b *Builder) LinkAction(s *modload.State, mode, depMode BuildMode, p *load.Package) *Action {
    +	// Construct link action.
    +	a := b.cacheAction("link", p, func() *Action {
    +		a := &Action{
    +			Mode:    "link",
    +			Package: p,
    +		}
    +
    +		a1 := b.CompileAction(ModeBuild, depMode, p)
    +		a.Actor = ActorFunc((*Builder).link)
    +		a.Deps = []*Action{a1}
    +		a.Objdir = a1.Objdir
    +
    +		// An executable file. (This is the name of a temporary file.)
    +		// Because we run the temporary file in 'go run' and 'go test',
    +		// the name will show up in ps listings. If the caller has specified
    +		// a name, use that instead of a.out. The binary is generated
    +		// in an otherwise empty subdirectory named exe to avoid
    +		// naming conflicts. The only possible conflict is if we were
    +		// to create a top-level package named exe.
    +		name := "a.out"
    +		if p.Internal.ExeName != "" {
    +			name = p.Internal.ExeName
    +		} else if (cfg.Goos == "darwin" || cfg.Goos == "windows") && cfg.BuildBuildmode == "c-shared" && p.Target != "" {
    +			// On OS X, the linker output name gets recorded in the
    +			// shared library's LC_ID_DYLIB load command.
    +			// The code invoking the linker knows to pass only the final
    +			// path element. Arrange that the path element matches what
    +			// we'll install it as; otherwise the library is only loadable as "a.out".
    +			// On Windows, DLL file name is recorded in PE file
    +			// export section, so do like on OS X.
    +			_, name = filepath.Split(p.Target)
    +		}
    +		a.Target = a.Objdir + filepath.Join("exe", name) + cfg.ExeSuffix
    +		a.built = a.Target
    +		b.addTransitiveLinkDeps(s, a, a1, "")
    +
    +		// Sequence the build of the main package (a1) strictly after the build
    +		// of all other dependencies that go into the link. It is likely to be after
    +		// them anyway, but just make sure. This is required by the build ID-based
    +		// shortcut in (*Builder).useCache(a1), which will call b.linkActionID(a).
    +		// In order for that linkActionID call to compute the right action ID, all the
    +		// dependencies of a (except a1) must have completed building and have
    +		// recorded their build IDs.
    +		a1.Deps = append(a1.Deps, &Action{Mode: "nop", Deps: a.Deps[1:]})
    +		return a
    +	})
    +
    +	if mode == ModeInstall || mode == ModeBuggyInstall {
    +		a = b.installAction(a, mode)
    +	}
    +
    +	return a
    +}
    +
    +// installAction returns the action for installing the result of a1.
    +func (b *Builder) installAction(a1 *Action, mode BuildMode) *Action {
    +	// Because we overwrite the build action with the install action below,
    +	// a1 may already be an install action fetched from the "build" cache key,
    +	// and the caller just doesn't realize.
    +	if strings.HasSuffix(a1.Mode, "-install") {
    +		if a1.buggyInstall && mode == ModeInstall {
    +			//  Congratulations! The buggy install is now a proper install.
    +			a1.buggyInstall = false
    +		}
    +		return a1
    +	}
    +
    +	// If there's no actual action to build a1,
    +	// there's nothing to install either.
    +	// This happens if a1 corresponds to reusing an already-built object.
    +	if a1.Actor == nil {
    +		return a1
    +	}
    +
    +	p := a1.Package
    +	return b.cacheAction(a1.Mode+"-install", p, func() *Action {
    +		// The install deletes the temporary build result,
    +		// so we need all other actions, both past and future,
    +		// that attempt to depend on the build to depend instead
    +		// on the install.
    +
    +		// Make a private copy of a1 (the build action),
    +		// no longer accessible to any other rules.
    +		buildAction := new(Action)
    +		*buildAction = *a1
    +
    +		// Overwrite a1 with the install action.
    +		// This takes care of updating past actions that
    +		// point at a1 for the build action; now they will
    +		// point at a1 and get the install action.
    +		// We also leave a1 in the action cache as the result
    +		// for "build", so that actions not yet created that
    +		// try to depend on the build will instead depend
    +		// on the install.
    +		*a1 = Action{
    +			Mode:    buildAction.Mode + "-install",
    +			Actor:   ActorFunc(BuildInstallFunc),
    +			Package: p,
    +			Objdir:  buildAction.Objdir,
    +			Deps:    []*Action{buildAction},
    +			Target:  p.Target,
    +			built:   p.Target,
    +
    +			buggyInstall: mode == ModeBuggyInstall,
    +		}
    +
    +		b.addInstallHeaderAction(a1)
    +		return a1
    +	})
    +}
    +
    +// addTransitiveLinkDeps adds to the link action a all packages
    +// that are transitive dependencies of a1.Deps.
    +// That is, if a is a link of package main, a1 is the compile of package main
    +// and a1.Deps is the actions for building packages directly imported by
    +// package main (what the compiler needs). The linker needs all packages
    +// transitively imported by the whole program; addTransitiveLinkDeps
    +// makes sure those are present in a.Deps.
    +// If shlib is non-empty, then a corresponds to the build and installation of shlib,
    +// so any rebuild of shlib should not be added as a dependency.
    +func (b *Builder) addTransitiveLinkDeps(s *modload.State, a, a1 *Action, shlib string) {
    +	// Expand Deps to include all built packages, for the linker.
    +	// Use breadth-first search to find rebuilt-for-test packages
    +	// before the standard ones.
    +	// TODO(rsc): Eliminate the standard ones from the action graph,
    +	// which will require doing a little bit more rebuilding.
    +	workq := []*Action{a1}
    +	haveDep := map[string]bool{}
    +	if a1.Package != nil {
    +		haveDep[a1.Package.ImportPath] = true
    +	}
    +	for i := 0; i < len(workq); i++ {
    +		a1 := workq[i]
    +		for _, a2 := range a1.Deps {
    +			// TODO(rsc): Find a better discriminator than the Mode strings, once the dust settles.
    +			if a2.Package == nil || (a2.Mode != "build-install" && a2.Mode != "build") || haveDep[a2.Package.ImportPath] {
    +				continue
    +			}
    +			haveDep[a2.Package.ImportPath] = true
    +			a.Deps = append(a.Deps, a2)
    +			if a2.Mode == "build-install" {
    +				a2 = a2.Deps[0] // walk children of "build" action
    +			}
    +			workq = append(workq, a2)
    +		}
    +	}
    +
    +	// If this is go build -linkshared, then the link depends on the shared libraries
    +	// in addition to the packages themselves. (The compile steps do not.)
    +	if cfg.BuildLinkshared {
    +		haveShlib := map[string]bool{shlib: true}
    +		for _, a1 := range a.Deps {
    +			p1 := a1.Package
    +			if p1 == nil || p1.Shlib == "" || haveShlib[filepath.Base(p1.Shlib)] {
    +				continue
    +			}
    +			haveShlib[filepath.Base(p1.Shlib)] = true
    +			// TODO(rsc): The use of ModeInstall here is suspect, but if we only do ModeBuild,
    +			// we'll end up building an overall library or executable that depends at runtime
    +			// on other libraries that are out-of-date, which is clearly not good either.
    +			// We call it ModeBuggyInstall to make clear that this is not right.
    +			a.Deps = append(a.Deps, b.linkSharedAction(s, ModeBuggyInstall, ModeBuggyInstall, p1.Shlib, nil))
    +		}
    +	}
    +}
    +
    +// addInstallHeaderAction adds an install header action to a, if needed.
    +// The action a should be an install action as generated by either
    +// b.CompileAction or b.LinkAction with mode=ModeInstall,
    +// and so a.Deps[0] is the corresponding build action.
    +func (b *Builder) addInstallHeaderAction(a *Action) {
    +	// Install header for cgo in c-archive and c-shared modes.
    +	p := a.Package
    +	if p.UsesCgo() && (cfg.BuildBuildmode == "c-archive" || cfg.BuildBuildmode == "c-shared") {
    +		hdrTarget := a.Target[:len(a.Target)-len(filepath.Ext(a.Target))] + ".h"
    +		if cfg.BuildContext.Compiler == "gccgo" && cfg.BuildO == "" {
    +			// For the header file, remove the "lib"
    +			// added by go/build, so we generate pkg.h
    +			// rather than libpkg.h.
    +			dir, file := filepath.Split(hdrTarget)
    +			file = strings.TrimPrefix(file, "lib")
    +			hdrTarget = filepath.Join(dir, file)
    +		}
    +		ah := &Action{
    +			Mode:    "install header",
    +			Package: a.Package,
    +			Deps:    []*Action{a.Deps[0]},
    +			Actor:   ActorFunc((*Builder).installHeader),
    +			Objdir:  a.Deps[0].Objdir,
    +			Target:  hdrTarget,
    +		}
    +		a.Deps = append(a.Deps, ah)
    +	}
    +}
    +
    +// buildmodeShared takes the "go build" action a1 into the building of a shared library of a1.Deps.
    +// That is, the input a1 represents "go build pkgs" and the result represents "go build -buildmode=shared pkgs".
    +func (b *Builder) buildmodeShared(s *modload.State, mode, depMode BuildMode, args []string, pkgs []*load.Package, a1 *Action) *Action {
    +	name, err := libname(args, pkgs)
    +	if err != nil {
    +		base.Fatalf("%v", err)
    +	}
    +	return b.linkSharedAction(s, mode, depMode, name, a1)
    +}
    +
    +// linkSharedAction takes a grouping action a1 corresponding to a list of built packages
    +// and returns an action that links them together into a shared library with the name shlib.
    +// If a1 is nil, shlib should be an absolute path to an existing shared library,
    +// and then linkSharedAction reads that library to find out the package list.
    +func (b *Builder) linkSharedAction(s *modload.State, mode, depMode BuildMode, shlib string, a1 *Action) *Action {
    +	fullShlib := shlib
    +	shlib = filepath.Base(shlib)
    +	a := b.cacheAction("build-shlib "+shlib, nil, func() *Action {
    +		if a1 == nil {
    +			// TODO(rsc): Need to find some other place to store config,
    +			// not in pkg directory. See golang.org/issue/22196.
    +			pkgs := readpkglist(s, fullShlib)
    +			a1 = &Action{
    +				Mode: "shlib packages",
    +			}
    +			for _, p := range pkgs {
    +				a1.Deps = append(a1.Deps, b.CompileAction(mode, depMode, p))
    +			}
    +		}
    +
    +		// Fake package to hold ldflags.
    +		// As usual shared libraries are a kludgy, abstraction-violating special case:
    +		// we let them use the flags specified for the command-line arguments.
    +		p := &load.Package{}
    +		p.Internal.CmdlinePkg = true
    +		p.Internal.Ldflags = load.BuildLdflags.For(s, p)
    +		p.Internal.Gccgoflags = load.BuildGccgoflags.For(s, p)
    +
    +		// Add implicit dependencies to pkgs list.
    +		// Currently buildmode=shared forces external linking mode, and
    +		// external linking mode forces an import of runtime/cgo (and
    +		// math on arm). So if it was not passed on the command line and
    +		// it is not present in another shared library, add it here.
    +		// TODO(rsc): Maybe this should only happen if "runtime" is in the original package set.
    +		// TODO(rsc): This should probably be changed to use load.LinkerDeps(p).
    +		// TODO(rsc): We don't add standard library imports for gccgo
    +		// because they are all always linked in anyhow.
    +		// Maybe load.LinkerDeps should be used and updated.
    +		a := &Action{
    +			Mode:    "go build -buildmode=shared",
    +			Package: p,
    +			Objdir:  b.NewObjdir(),
    +			Actor:   ActorFunc((*Builder).linkShared),
    +			Deps:    []*Action{a1},
    +		}
    +		a.Target = filepath.Join(a.Objdir, shlib)
    +		if cfg.BuildToolchainName != "gccgo" {
    +			add := func(a1 *Action, pkg string, force bool) {
    +				for _, a2 := range a1.Deps {
    +					if a2.Package != nil && a2.Package.ImportPath == pkg {
    +						return
    +					}
    +				}
    +				var stk load.ImportStack
    +				p := load.LoadPackageWithFlags(s, pkg, base.Cwd(), &stk, nil, 0)
    +				if p.Error != nil {
    +					base.Fatalf("load %s: %v", pkg, p.Error)
    +				}
    +				// Assume that if pkg (runtime/cgo or math)
    +				// is already accounted for in a different shared library,
    +				// then that shared library also contains runtime,
    +				// so that anything we do will depend on that library,
    +				// so we don't need to include pkg in our shared library.
    +				if force || p.Shlib == "" || filepath.Base(p.Shlib) == pkg {
    +					a1.Deps = append(a1.Deps, b.CompileAction(depMode, depMode, p))
    +				}
    +			}
    +			add(a1, "runtime/cgo", false)
    +			if cfg.Goarch == "arm" {
    +				add(a1, "math", false)
    +			}
    +
    +			// The linker step still needs all the usual linker deps.
    +			// (For example, the linker always opens runtime.a.)
    +			ldDeps, err := load.LinkerDeps(s, nil)
    +			if err != nil {
    +				base.Error(err)
    +			}
    +			for _, dep := range ldDeps {
    +				add(a, dep, true)
    +			}
    +		}
    +		b.addTransitiveLinkDeps(s, a, a1, shlib)
    +		return a
    +	})
    +
    +	// Install result.
    +	if (mode == ModeInstall || mode == ModeBuggyInstall) && a.Actor != nil {
    +		buildAction := a
    +
    +		a = b.cacheAction("install-shlib "+shlib, nil, func() *Action {
    +			// Determine the eventual install target.
    +			// The install target is root/pkg/shlib, where root is the source root
    +			// in which all the packages lie.
    +			// TODO(rsc): Perhaps this cross-root check should apply to the full
    +			// transitive package dependency list, not just the ones named
    +			// on the command line?
    +			pkgDir := a1.Deps[0].Package.Internal.Build.PkgTargetRoot
    +			for _, a2 := range a1.Deps {
    +				if dir := a2.Package.Internal.Build.PkgTargetRoot; dir != pkgDir {
    +					base.Fatalf("installing shared library: cannot use packages %s and %s from different roots %s and %s",
    +						a1.Deps[0].Package.ImportPath,
    +						a2.Package.ImportPath,
    +						pkgDir,
    +						dir)
    +				}
    +			}
    +			// TODO(rsc): Find out and explain here why gccgo is different.
    +			if cfg.BuildToolchainName == "gccgo" {
    +				pkgDir = filepath.Join(pkgDir, "shlibs")
    +			}
    +			target := filepath.Join(pkgDir, shlib)
    +
    +			a := &Action{
    +				Mode:   "go install -buildmode=shared",
    +				Objdir: buildAction.Objdir,
    +				Actor:  ActorFunc(BuildInstallFunc),
    +				Deps:   []*Action{buildAction},
    +				Target: target,
    +			}
    +			for _, a2 := range buildAction.Deps[0].Deps {
    +				p := a2.Package
    +				pkgTargetRoot := p.Internal.Build.PkgTargetRoot
    +				if pkgTargetRoot == "" {
    +					continue
    +				}
    +				a.Deps = append(a.Deps, &Action{
    +					Mode:    "shlibname",
    +					Package: p,
    +					Actor:   ActorFunc((*Builder).installShlibname),
    +					Target:  filepath.Join(pkgTargetRoot, p.ImportPath+".shlibname"),
    +					Deps:    []*Action{a.Deps[0]},
    +				})
    +			}
    +			return a
    +		})
    +	}
    +
    +	return a
    +}
    diff --git a/go/src/cmd/go/internal/work/build.go b/go/src/cmd/go/internal/work/build.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..75d05d65de24cf3c2ba1f571f98c4088265dfd86
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/build.go
    @@ -0,0 +1,962 @@
    +// Copyright 2011 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package work
    +
    +import (
    +	"context"
    +	"errors"
    +	"flag"
    +	"fmt"
    +	"go/build"
    +	"os"
    +	"path/filepath"
    +	"runtime"
    +	"strconv"
    +	"strings"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/fsys"
    +	"cmd/go/internal/load"
    +	"cmd/go/internal/modload"
    +	"cmd/go/internal/search"
    +	"cmd/go/internal/trace"
    +	"cmd/internal/pathcache"
    +)
    +
    +var CmdBuild = &base.Command{
    +	UsageLine: "go build [-o output] [build flags] [packages]",
    +	Short:     "compile packages and dependencies",
    +	Long: `
    +Build compiles the packages named by the import paths,
    +along with their dependencies, but it does not install the results.
    +
    +If the arguments to build are a list of .go files from a single directory,
    +build treats them as a list of source files specifying a single package.
    +
    +When compiling packages, build ignores files that end in '_test.go'.
    +
    +When compiling a single main package, build writes the resulting
    +executable to an output file named after the last non-major-version
    +component of the package import path. The '.exe' suffix is added
    +when writing a Windows executable.
    +So 'go build example/sam' writes 'sam' or 'sam.exe'.
    +'go build example.com/foo/v2' writes 'foo' or 'foo.exe', not 'v2.exe'.
    +
    +When compiling a package from a list of .go files, the executable
    +is named after the first source file.
    +'go build ed.go rx.go' writes 'ed' or 'ed.exe'.
    +
    +When compiling multiple packages or a single non-main package,
    +build compiles the packages but discards the resulting object,
    +serving only as a check that the packages can be built.
    +
    +The -o flag forces build to write the resulting executable or object
    +to the named output file or directory, instead of the default behavior described
    +in the last two paragraphs. If the named output is an existing directory or
    +ends with a slash or backslash, then any resulting executables
    +will be written to that directory.
    +
    +The build flags are shared by the build, clean, get, install, list, run,
    +and test commands:
    +
    +	-C dir
    +		Change to dir before running the command.
    +		Any files named on the command line are interpreted after
    +		changing directories.
    +		If used, this flag must be the first one in the command line.
    +	-a
    +		force rebuilding of packages that are already up-to-date.
    +	-n
    +		print the commands but do not run them.
    +	-p n
    +		the number of programs, such as build commands or
    +		test binaries, that can be run in parallel.
    +		The default is GOMAXPROCS, normally the number of CPUs available.
    +	-race
    +		enable data race detection.
    +		Supported only on darwin/amd64, darwin/arm64, freebsd/amd64, linux/amd64,
    +		linux/arm64 (only for 48-bit VMA), linux/ppc64le, linux/riscv64 and
    +		windows/amd64.
    +	-msan
    +		enable interoperation with memory sanitizer.
    +		Supported only on linux/amd64, linux/arm64, linux/loong64, freebsd/amd64
    +		and only with Clang/LLVM as the host C compiler.
    +		PIE build mode will be used on all platforms except linux/amd64.
    +	-asan
    +		enable interoperation with address sanitizer.
    +		Supported only on linux/arm64, linux/amd64, linux/loong64.
    +		Supported on linux/amd64 or linux/arm64 and only with GCC 7 and higher
    +		or Clang/LLVM 9 and higher.
    +		And supported on linux/loong64 only with Clang/LLVM 16 and higher.
    +	-cover
    +		enable code coverage instrumentation.
    +	-covermode set,count,atomic
    +		set the mode for coverage analysis.
    +		The default is "set" unless -race is enabled,
    +		in which case it is "atomic".
    +		The values:
    +		set: bool: does this statement run?
    +		count: int: how many times does this statement run?
    +		atomic: int: count, but correct in multithreaded tests;
    +			significantly more expensive.
    +		Sets -cover.
    +	-coverpkg pattern1,pattern2,pattern3
    +		For a build that targets package 'main' (e.g. building a Go
    +		executable), apply coverage analysis to each package whose
    +		import path matches the patterns. The default is to apply
    +		coverage analysis to packages in the main Go module. See
    +		'go help packages' for a description of package patterns.
    +		Sets -cover.
    +	-v
    +		print the names of packages as they are compiled.
    +	-work
    +		print the name of the temporary work directory and
    +		do not delete it when exiting.
    +	-x
    +		print the commands.
    +	-asmflags '[pattern=]arg list'
    +		arguments to pass on each go tool asm invocation.
    +	-buildmode mode
    +		build mode to use. See 'go help buildmode' for more.
    +	-buildvcs
    +		Whether to stamp binaries with version control information
    +		("true", "false", or "auto"). By default ("auto"), version control
    +		information is stamped into a binary if the main package, the main module
    +		containing it, and the current directory are all in the same repository.
    +		Use -buildvcs=false to always omit version control information, or
    +		-buildvcs=true to error out if version control information is available but
    +		cannot be included due to a missing tool or ambiguous directory structure.
    +	-compiler name
    +		name of compiler to use, as in runtime.Compiler (gccgo or gc).
    +	-gccgoflags '[pattern=]arg list'
    +		arguments to pass on each gccgo compiler/linker invocation.
    +	-gcflags '[pattern=]arg list'
    +		arguments to pass on each go tool compile invocation.
    +	-installsuffix suffix
    +		a suffix to use in the name of the package installation directory,
    +		in order to keep output separate from default builds.
    +		If using the -race flag, the install suffix is automatically set to race
    +		or, if set explicitly, has _race appended to it. Likewise for the -msan
    +		and -asan flags. Using a -buildmode option that requires non-default compile
    +		flags has a similar effect.
    +	-json
    +		Emit build output in JSON suitable for automated processing.
    +		See 'go help buildjson' for the encoding details.
    +	-ldflags '[pattern=]arg list'
    +		arguments to pass on each go tool link invocation.
    +	-linkshared
    +		build code that will be linked against shared libraries previously
    +		created with -buildmode=shared.
    +	-mod mode
    +		module download mode to use: readonly, vendor, or mod.
    +		By default, if a vendor directory is present and the go version in go.mod
    +		is 1.14 or higher, the go command acts as if -mod=vendor were set.
    +		Otherwise, the go command acts as if -mod=readonly were set.
    +		See https://golang.org/ref/mod#build-commands for details.
    +	-modcacherw
    +		leave newly-created directories in the module cache read-write
    +		instead of making them read-only.
    +	-modfile file
    +		in module aware mode, read (and possibly write) an alternate go.mod
    +		file instead of the one in the module root directory. A file named
    +		"go.mod" must still be present in order to determine the module root
    +		directory, but it is not accessed. When -modfile is specified, an
    +		alternate go.sum file is also used: its path is derived from the
    +		-modfile flag by trimming the ".mod" extension and appending ".sum".
    +	-overlay file
    +		read a JSON config file that provides an overlay for build operations.
    +		The file is a JSON object with a single field, named 'Replace', that
    +		maps each disk file path (a string) to its backing file path, so that
    +		a build will run as if the disk file path exists with the contents
    +		given by the backing file paths, or as if the disk file path does not
    +		exist if its backing file path is empty. Support for the -overlay flag
    +		has some limitations: importantly, cgo files included from outside the
    +		include path must be in the same directory as the Go package they are
    +		included from, overlays will not appear when binaries and tests are
    +		run through go run and go test respectively, and files beneath
    +		GOMODCACHE may not be replaced.
    +	-pgo file
    +		specify the file path of a profile for profile-guided optimization (PGO).
    +		When the special name "auto" is specified, for each main package in the
    +		build, the go command selects a file named "default.pgo" in the package's
    +		directory if that file exists, and applies it to the (transitive)
    +		dependencies of the main package (other packages are not affected).
    +		Special name "off" turns off PGO. The default is "auto".
    +	-pkgdir dir
    +		install and load all packages from dir instead of the usual locations.
    +		For example, when building with a non-standard configuration,
    +		use -pkgdir to keep generated packages in a separate location.
    +	-tags tag,list
    +		a comma-separated list of additional build tags to consider satisfied
    +		during the build. For more information about build tags, see
    +		'go help buildconstraint'. (Earlier versions of Go used a
    +		space-separated list, and that form is deprecated but still recognized.)
    +	-trimpath
    +		remove all file system paths from the resulting executable.
    +		Instead of absolute file system paths, the recorded file names
    +		will begin either a module path@version (when using modules),
    +		or a plain import path (when using the standard library, or GOPATH).
    +	-toolexec 'cmd args'
    +		a program to use to invoke toolchain programs like vet and asm.
    +		For example, instead of running asm, the go command will run
    +		'cmd args /path/to/asm '.
    +		The TOOLEXEC_IMPORTPATH environment variable will be set,
    +		matching 'go list -f {{.ImportPath}}' for the package being built.
    +
    +The -asmflags, -gccgoflags, -gcflags, and -ldflags flags accept a
    +space-separated list of arguments to pass to an underlying tool
    +during the build. To embed spaces in an element in the list, surround
    +it with either single or double quotes. The argument list may be
    +preceded by a package pattern and an equal sign, which restricts
    +the use of that argument list to the building of packages matching
    +that pattern (see 'go help packages' for a description of package
    +patterns). Without a pattern, the argument list applies only to the
    +packages named on the command line. The flags may be repeated
    +with different patterns in order to specify different arguments for
    +different sets of packages. If a package matches patterns given in
    +multiple flags, the latest match on the command line wins.
    +For example, 'go build -gcflags=-S fmt' prints the disassembly
    +only for package fmt, while 'go build -gcflags=all=-S fmt'
    +prints the disassembly for fmt and all its dependencies.
    +
    +For more about specifying packages, see 'go help packages'.
    +For more about where packages and binaries are installed,
    +run 'go help gopath'.
    +For more about calling between Go and C/C++, run 'go help c'.
    +
    +Note: Build adheres to certain conventions such as those described
    +by 'go help gopath'. Not all projects can follow these conventions,
    +however. Installations that have their own conventions or that use
    +a separate software build system may choose to use lower-level
    +invocations such as 'go tool compile' and 'go tool link' to avoid
    +some of the overheads and design decisions of the build tool.
    +
    +See also: go install, go get, go clean.
    +	`,
    +}
    +
    +func init() {
    +	// break init cycle
    +	CmdBuild.Run = runBuild
    +	CmdInstall.Run = runInstall
    +
    +	CmdBuild.Flag.StringVar(&cfg.BuildO, "o", "", "output file or directory")
    +
    +	AddBuildFlags(CmdBuild, DefaultBuildFlags)
    +	AddBuildFlags(CmdInstall, DefaultBuildFlags)
    +	AddCoverFlags(CmdBuild, nil)
    +	AddCoverFlags(CmdInstall, nil)
    +}
    +
    +// Note that flags consulted by other parts of the code
    +// (for example, buildV) are in cmd/go/internal/cfg.
    +
    +var (
    +	forcedAsmflags   []string // internally-forced flags for cmd/asm
    +	forcedGcflags    []string // internally-forced flags for cmd/compile
    +	forcedLdflags    []string // internally-forced flags for cmd/link
    +	forcedGccgoflags []string // internally-forced flags for gccgo
    +)
    +
    +var BuildToolchain toolchain = noToolchain{}
    +var ldBuildmode string
    +
    +// buildCompiler implements flag.Var.
    +// It implements Set by updating both
    +// BuildToolchain and buildContext.Compiler.
    +type buildCompiler struct{}
    +
    +func (c buildCompiler) Set(value string) error {
    +	switch value {
    +	case "gc":
    +		BuildToolchain = gcToolchain{}
    +	case "gccgo":
    +		BuildToolchain = gccgoToolchain{}
    +	default:
    +		return fmt.Errorf("unknown compiler %q", value)
    +	}
    +	cfg.BuildToolchainName = value
    +	cfg.BuildContext.Compiler = value
    +	return nil
    +}
    +
    +func (c buildCompiler) String() string {
    +	return cfg.BuildContext.Compiler
    +}
    +
    +func init() {
    +	switch build.Default.Compiler {
    +	case "gc", "gccgo":
    +		buildCompiler{}.Set(build.Default.Compiler)
    +	}
    +}
    +
    +type BuildFlagMask int
    +
    +const (
    +	DefaultBuildFlags BuildFlagMask = 0
    +	OmitModFlag       BuildFlagMask = 1 << iota
    +	OmitModCommonFlags
    +	OmitVFlag
    +	OmitBuildOnlyFlags // Omit flags that only affect building packages
    +	OmitJSONFlag
    +)
    +
    +// AddBuildFlags adds the flags common to the build, clean, get,
    +// install, list, run, and test commands.
    +func AddBuildFlags(cmd *base.Command, mask BuildFlagMask) {
    +	base.AddBuildFlagsNX(&cmd.Flag)
    +	base.AddChdirFlag(&cmd.Flag)
    +	cmd.Flag.BoolVar(&cfg.BuildA, "a", false, "")
    +	cmd.Flag.IntVar(&cfg.BuildP, "p", cfg.BuildP, "")
    +	if mask&OmitVFlag == 0 {
    +		cmd.Flag.BoolVar(&cfg.BuildV, "v", false, "")
    +	}
    +
    +	cmd.Flag.BoolVar(&cfg.BuildASan, "asan", false, "")
    +	cmd.Flag.Var(&load.BuildAsmflags, "asmflags", "")
    +	cmd.Flag.Var(buildCompiler{}, "compiler", "")
    +	cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", "default", "")
    +	cmd.Flag.Var((*buildvcsFlag)(&cfg.BuildBuildvcs), "buildvcs", "")
    +	cmd.Flag.Var(&load.BuildGcflags, "gcflags", "")
    +	cmd.Flag.Var(&load.BuildGccgoflags, "gccgoflags", "")
    +	if mask&OmitModFlag == 0 {
    +		base.AddModFlag(&cmd.Flag)
    +	}
    +	if mask&OmitModCommonFlags == 0 {
    +		base.AddModCommonFlags(&cmd.Flag)
    +	} else {
    +		// Add the overlay flag even when we don't add the rest of the mod common flags.
    +		// This only affects 'go get' in GOPATH mode, but add the flag anyway for
    +		// consistency.
    +		cmd.Flag.StringVar(&fsys.OverlayFile, "overlay", "", "")
    +	}
    +	cmd.Flag.StringVar(&cfg.BuildContext.InstallSuffix, "installsuffix", "", "")
    +	if mask&(OmitBuildOnlyFlags|OmitJSONFlag) == 0 {
    +		// TODO(#62250): OmitBuildOnlyFlags should apply to many more flags
    +		// here, but we let a bunch of flags slip in before we realized that
    +		// many of them don't make sense for most subcommands. We might even
    +		// want to separate "AddBuildFlags" and "AddSelectionFlags".
    +		cmd.Flag.BoolVar(&cfg.BuildJSON, "json", false, "")
    +	}
    +	cmd.Flag.Var(&load.BuildLdflags, "ldflags", "")
    +	cmd.Flag.BoolVar(&cfg.BuildLinkshared, "linkshared", false, "")
    +	cmd.Flag.BoolVar(&cfg.BuildMSan, "msan", false, "")
    +	cmd.Flag.StringVar(&cfg.BuildPGO, "pgo", "auto", "")
    +	cmd.Flag.StringVar(&cfg.BuildPkgdir, "pkgdir", "", "")
    +	cmd.Flag.BoolVar(&cfg.BuildRace, "race", false, "")
    +	cmd.Flag.Var((*tagsFlag)(&cfg.BuildContext.BuildTags), "tags", "")
    +	cmd.Flag.Var((*base.StringsFlag)(&cfg.BuildToolexec), "toolexec", "")
    +	cmd.Flag.BoolVar(&cfg.BuildTrimpath, "trimpath", false, "")
    +	cmd.Flag.BoolVar(&cfg.BuildWork, "work", false, "")
    +
    +	// Undocumented, unstable debugging flags.
    +	cmd.Flag.StringVar(&cfg.DebugActiongraph, "debug-actiongraph", "", "")
    +	cmd.Flag.StringVar(&cfg.DebugRuntimeTrace, "debug-runtime-trace", "", "")
    +	cmd.Flag.StringVar(&cfg.DebugTrace, "debug-trace", "", "")
    +}
    +
    +// AddCoverFlags adds coverage-related flags to "cmd".
    +// We add -cover{mode,pkg} to the build command and only
    +// -coverprofile to the test command.
    +func AddCoverFlags(cmd *base.Command, coverProfileFlag *string) {
    +	cmd.Flag.BoolVar(&cfg.BuildCover, "cover", false, "")
    +	cmd.Flag.Var(coverFlag{(*coverModeFlag)(&cfg.BuildCoverMode)}, "covermode", "")
    +	cmd.Flag.Var(coverFlag{commaListFlag{&cfg.BuildCoverPkg}}, "coverpkg", "")
    +	if coverProfileFlag != nil {
    +		cmd.Flag.Var(coverFlag{V: stringFlag{coverProfileFlag}}, "coverprofile", "")
    +	}
    +}
    +
    +// tagsFlag is the implementation of the -tags flag.
    +type tagsFlag []string
    +
    +func (v *tagsFlag) Set(s string) error {
    +	// For compatibility with Go 1.12 and earlier, allow "-tags='a b c'" or even just "-tags='a'".
    +	if strings.Contains(s, " ") || strings.Contains(s, "'") {
    +		return (*base.StringsFlag)(v).Set(s)
    +	}
    +
    +	// Split on commas, ignore empty strings.
    +	*v = []string{}
    +	for s := range strings.SplitSeq(s, ",") {
    +		if s != "" {
    +			*v = append(*v, s)
    +		}
    +	}
    +	return nil
    +}
    +
    +func (v *tagsFlag) String() string {
    +	return ""
    +}
    +
    +// buildvcsFlag is the implementation of the -buildvcs flag.
    +type buildvcsFlag string
    +
    +func (f *buildvcsFlag) IsBoolFlag() bool { return true } // allow -buildvcs (without arguments)
    +
    +func (f *buildvcsFlag) Set(s string) error {
    +	// https://go.dev/issue/51748: allow "-buildvcs=auto",
    +	// in addition to the usual "true" and "false".
    +	if s == "" || s == "auto" {
    +		*f = "auto"
    +		return nil
    +	}
    +
    +	b, err := strconv.ParseBool(s)
    +	if err != nil {
    +		return errors.New("value is neither 'auto' nor a valid bool")
    +	}
    +	*f = (buildvcsFlag)(strconv.FormatBool(b)) // convert to canonical "true" or "false"
    +	return nil
    +}
    +
    +func (f *buildvcsFlag) String() string { return string(*f) }
    +
    +// fileExtSplit expects a filename and returns the name
    +// and ext (without the dot). If the file has no
    +// extension, ext will be empty.
    +func fileExtSplit(file string) (name, ext string) {
    +	dotExt := filepath.Ext(file)
    +	name = file[:len(file)-len(dotExt)]
    +	if dotExt != "" {
    +		ext = dotExt[1:]
    +	}
    +	return
    +}
    +
    +func pkgsMain(pkgs []*load.Package) (res []*load.Package) {
    +	for _, p := range pkgs {
    +		if p.Name == "main" {
    +			res = append(res, p)
    +		}
    +	}
    +	return res
    +}
    +
    +func pkgsNotMain(pkgs []*load.Package) (res []*load.Package) {
    +	for _, p := range pkgs {
    +		if p.Name != "main" {
    +			res = append(res, p)
    +		}
    +	}
    +	return res
    +}
    +
    +func oneMainPkg(pkgs []*load.Package) []*load.Package {
    +	if len(pkgs) != 1 || pkgs[0].Name != "main" {
    +		base.Fatalf("-buildmode=%s requires exactly one main package", cfg.BuildBuildmode)
    +	}
    +	return pkgs
    +}
    +
    +var pkgsFilter = func(pkgs []*load.Package) []*load.Package { return pkgs }
    +
    +func runBuild(ctx context.Context, cmd *base.Command, args []string) {
    +	moduleLoaderState := modload.NewState()
    +	moduleLoaderState.InitWorkfile()
    +	BuildInit(moduleLoaderState)
    +	b := NewBuilder("", moduleLoaderState.VendorDirOrEmpty)
    +	defer func() {
    +		if err := b.Close(); err != nil {
    +			base.Fatal(err)
    +		}
    +	}()
    +
    +	pkgs := load.PackagesAndErrors(moduleLoaderState, ctx, load.PackageOpts{AutoVCS: true}, args)
    +	load.CheckPackageErrors(pkgs)
    +
    +	explicitO := len(cfg.BuildO) > 0
    +
    +	if len(pkgs) == 1 && pkgs[0].Name == "main" && cfg.BuildO == "" {
    +		cfg.BuildO = pkgs[0].DefaultExecName()
    +		cfg.BuildO += cfg.ExeSuffix
    +	}
    +
    +	// sanity check some often mis-used options
    +	switch cfg.BuildContext.Compiler {
    +	case "gccgo":
    +		if load.BuildGcflags.Present() {
    +			fmt.Println("go build: when using gccgo toolchain, please pass compiler flags using -gccgoflags, not -gcflags")
    +		}
    +		if load.BuildLdflags.Present() {
    +			fmt.Println("go build: when using gccgo toolchain, please pass linker flags using -gccgoflags, not -ldflags")
    +		}
    +	case "gc":
    +		if load.BuildGccgoflags.Present() {
    +			fmt.Println("go build: when using gc toolchain, please pass compile flags using -gcflags, and linker flags using -ldflags")
    +		}
    +	}
    +
    +	depMode := ModeBuild
    +
    +	pkgs = omitTestOnly(pkgsFilter(pkgs))
    +
    +	// Special case -o /dev/null by not writing at all.
    +	if base.IsNull(cfg.BuildO) {
    +		cfg.BuildO = ""
    +	}
    +
    +	if cfg.BuildCover {
    +		load.PrepareForCoverageBuild(moduleLoaderState, pkgs)
    +	}
    +
    +	if cfg.BuildO != "" {
    +		// If the -o name exists and is a directory or
    +		// ends with a slash or backslash, then
    +		// write all main packages to that directory.
    +		// Otherwise require only a single package be built.
    +		if fi, err := os.Stat(cfg.BuildO); (err == nil && fi.IsDir()) ||
    +			strings.HasSuffix(cfg.BuildO, "/") ||
    +			strings.HasSuffix(cfg.BuildO, string(os.PathSeparator)) {
    +			if !explicitO {
    +				base.Fatalf("go: build output %q already exists and is a directory", cfg.BuildO)
    +			}
    +			a := &Action{Mode: "go build"}
    +			for _, p := range pkgs {
    +				if p.Name != "main" {
    +					continue
    +				}
    +
    +				p.Target = filepath.Join(cfg.BuildO, p.DefaultExecName())
    +				p.Target += cfg.ExeSuffix
    +				p.Stale = true
    +				p.StaleReason = "build -o flag in use"
    +				a.Deps = append(a.Deps, b.AutoAction(moduleLoaderState, ModeInstall, depMode, p))
    +			}
    +			if len(a.Deps) == 0 {
    +				base.Fatalf("go: no main packages to build")
    +			}
    +			b.Do(ctx, a)
    +			return
    +		}
    +		if len(pkgs) > 1 {
    +			base.Fatalf("go: cannot write multiple packages to non-directory %s", cfg.BuildO)
    +		} else if len(pkgs) == 0 {
    +			base.Fatalf("no packages to build")
    +		}
    +		p := pkgs[0]
    +		p.Target = cfg.BuildO
    +		p.Stale = true // must build - not up to date
    +		p.StaleReason = "build -o flag in use"
    +		a := b.AutoAction(moduleLoaderState, ModeInstall, depMode, p)
    +		b.Do(ctx, a)
    +		return
    +	}
    +
    +	a := &Action{Mode: "go build"}
    +	for _, p := range pkgs {
    +		a.Deps = append(a.Deps, b.AutoAction(moduleLoaderState, ModeBuild, depMode, p))
    +	}
    +	if cfg.BuildBuildmode == "shared" {
    +		a = b.buildmodeShared(moduleLoaderState, ModeBuild, depMode, args, pkgs, a)
    +	}
    +	b.Do(ctx, a)
    +}
    +
    +var CmdInstall = &base.Command{
    +	UsageLine: "go install [build flags] [packages]",
    +	Short:     "compile and install packages and dependencies",
    +	Long: `
    +Install compiles and installs the packages named by the import paths.
    +
    +Executables are installed in the directory named by the GOBIN environment
    +variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH
    +environment variable is not set. Executables in $GOROOT
    +are installed in $GOROOT/bin or $GOTOOLDIR instead of $GOBIN.
    +Cross compiled binaries are installed in $GOOS_$GOARCH subdirectories
    +of the above.
    +
    +If the arguments have version suffixes (like @latest or @v1.0.0), "go install"
    +builds packages in module-aware mode, ignoring the go.mod file in the current
    +directory or any parent directory, if there is one. This is useful for
    +installing executables without affecting the dependencies of the main module.
    +To eliminate ambiguity about which module versions are used in the build, the
    +arguments must satisfy the following constraints:
    +
    +- Arguments must be package paths or package patterns (with "..." wildcards).
    +They must not be standard packages (like fmt), meta-patterns (std, cmd,
    +all), or relative or absolute file paths.
    +
    +- All arguments must have the same version suffix. Different queries are not
    +allowed, even if they refer to the same version.
    +
    +- All arguments must refer to packages in the same module at the same version.
    +
    +- Package path arguments must refer to main packages. Pattern arguments
    +will only match main packages.
    +
    +- No module is considered the "main" module. If the module containing
    +packages named on the command line has a go.mod file, it must not contain
    +directives (replace and exclude) that would cause it to be interpreted
    +differently than if it were the main module. The module must not require
    +a higher version of itself.
    +
    +- Vendor directories are not used in any module. (Vendor directories are not
    +included in the module zip files downloaded by 'go install'.)
    +
    +If the arguments don't have version suffixes, "go install" may run in
    +module-aware mode or GOPATH mode, depending on the GO111MODULE environment
    +variable and the presence of a go.mod file. See 'go help modules' for details.
    +If module-aware mode is enabled, "go install" runs in the context of the main
    +module.
    +
    +When module-aware mode is disabled, non-main packages are installed in the
    +directory $GOPATH/pkg/$GOOS_$GOARCH. When module-aware mode is enabled,
    +non-main packages are built and cached but not installed.
    +
    +Before Go 1.20, the standard library was installed to
    +$GOROOT/pkg/$GOOS_$GOARCH.
    +Starting in Go 1.20, the standard library is built and cached but not installed.
    +Setting GODEBUG=installgoroot=all restores the use of
    +$GOROOT/pkg/$GOOS_$GOARCH.
    +
    +For more about build flags, see 'go help build'.
    +
    +For more about specifying packages, see 'go help packages'.
    +
    +See also: go build, go get, go clean.
    +	`,
    +}
    +
    +// libname returns the filename to use for the shared library when using
    +// -buildmode=shared. The rules we use are:
    +// Use arguments for special 'meta' packages:
    +//
    +//	std --> libstd.so
    +//	std cmd --> libstd,cmd.so
    +//
    +// A single non-meta argument with trailing "/..." is special cased:
    +//
    +//	foo/... --> libfoo.so
    +//	(A relative path like "./..."  expands the "." first)
    +//
    +// Use import paths for other cases, changing '/' to '-':
    +//
    +//	somelib --> libsubdir-somelib.so
    +//	./ or ../ --> libsubdir-somelib.so
    +//	gopkg.in/tomb.v2 -> libgopkg.in-tomb.v2.so
    +//	a/... b/... ---> liba/c,b/d.so - all matching import paths
    +//
    +// Name parts are joined with ','.
    +func libname(args []string, pkgs []*load.Package) (string, error) {
    +	var libname string
    +	appendName := func(arg string) {
    +		if libname == "" {
    +			libname = arg
    +		} else {
    +			libname += "," + arg
    +		}
    +	}
    +	var haveNonMeta bool
    +	for _, arg := range args {
    +		if search.IsMetaPackage(arg) {
    +			appendName(arg)
    +		} else {
    +			haveNonMeta = true
    +		}
    +	}
    +	if len(libname) == 0 { // non-meta packages only. use import paths
    +		if len(args) == 1 && strings.HasSuffix(args[0], "/...") {
    +			// Special case of "foo/..." as mentioned above.
    +			arg := strings.TrimSuffix(args[0], "/...")
    +			if build.IsLocalImport(arg) {
    +				cwd, _ := os.Getwd()
    +				bp, _ := cfg.BuildContext.ImportDir(filepath.Join(cwd, arg), build.FindOnly)
    +				if bp.ImportPath != "" && bp.ImportPath != "." {
    +					arg = bp.ImportPath
    +				}
    +			}
    +			appendName(strings.ReplaceAll(arg, "/", "-"))
    +		} else {
    +			for _, pkg := range pkgs {
    +				appendName(strings.ReplaceAll(pkg.ImportPath, "/", "-"))
    +			}
    +		}
    +	} else if haveNonMeta { // have both meta package and a non-meta one
    +		return "", errors.New("mixing of meta and non-meta packages is not allowed")
    +	}
    +	// TODO(mwhudson): Needs to change for platforms that use different naming
    +	// conventions...
    +	return "lib" + libname + ".so", nil
    +}
    +
    +func runInstall(ctx context.Context, cmd *base.Command, args []string) {
    +	moduleLoaderState := modload.NewState()
    +	for _, arg := range args {
    +		if strings.Contains(arg, "@") && !build.IsLocalImport(arg) && !filepath.IsAbs(arg) {
    +			installOutsideModule(moduleLoaderState, ctx, args)
    +			return
    +		}
    +	}
    +
    +	moduleLoaderState.InitWorkfile()
    +	BuildInit(moduleLoaderState)
    +	pkgs := load.PackagesAndErrors(moduleLoaderState, ctx, load.PackageOpts{AutoVCS: true}, args)
    +	if cfg.ModulesEnabled && !moduleLoaderState.HasModRoot() {
    +		haveErrors := false
    +		allMissingErrors := true
    +		for _, pkg := range pkgs {
    +			if pkg.Error == nil {
    +				continue
    +			}
    +			haveErrors = true
    +			if _, ok := errors.AsType[*modload.ImportMissingError](pkg.Error); !ok {
    +				allMissingErrors = false
    +				break
    +			}
    +		}
    +		if haveErrors && allMissingErrors {
    +			latestArgs := make([]string, len(args))
    +			for i := range args {
    +				latestArgs[i] = args[i] + "@latest"
    +			}
    +			hint := strings.Join(latestArgs, " ")
    +			base.Fatalf("go: 'go install' requires a version when current directory is not in a module\n\tTry 'go install %s' to install the latest version", hint)
    +		}
    +	}
    +	load.CheckPackageErrors(pkgs)
    +
    +	if cfg.BuildCover {
    +		load.PrepareForCoverageBuild(moduleLoaderState, pkgs)
    +	}
    +
    +	InstallPackages(moduleLoaderState, ctx, args, pkgs)
    +}
    +
    +// omitTestOnly returns pkgs with test-only packages removed.
    +func omitTestOnly(pkgs []*load.Package) []*load.Package {
    +	var list []*load.Package
    +	for _, p := range pkgs {
    +		if len(p.GoFiles)+len(p.CgoFiles) == 0 && !p.Internal.CmdlinePkgLiteral {
    +			// Package has no source files,
    +			// perhaps due to build tags or perhaps due to only having *_test.go files.
    +			// Also, it is only being processed as the result of a wildcard match
    +			// like ./..., not because it was listed as a literal path on the command line.
    +			// Ignore it.
    +			continue
    +		}
    +		list = append(list, p)
    +	}
    +	return list
    +}
    +
    +func InstallPackages(loaderstate *modload.State, ctx context.Context, patterns []string, pkgs []*load.Package) {
    +	ctx, span := trace.StartSpan(ctx, "InstallPackages "+strings.Join(patterns, " "))
    +	defer span.Done()
    +
    +	if cfg.GOBIN != "" && !filepath.IsAbs(cfg.GOBIN) {
    +		base.Fatalf("cannot install, GOBIN must be an absolute path")
    +	}
    +
    +	pkgs = omitTestOnly(pkgsFilter(pkgs))
    +	for _, p := range pkgs {
    +		if p.Target == "" {
    +			switch {
    +			case p.Name != "main" && p.Internal.Local && p.ConflictDir == "":
    +				// Non-executables outside GOPATH need not have a target:
    +				// we can use the cache to hold the built package archive for use in future builds.
    +				// The ones inside GOPATH should have a target (in GOPATH/pkg)
    +				// or else something is wrong and worth reporting (like a ConflictDir).
    +			case p.Name != "main" && p.Module != nil:
    +				// Non-executables have no target (except the cache) when building with modules.
    +			case p.Name != "main" && p.Standard && p.Internal.Build.PkgObj == "":
    +				// Most packages in std do not need an installed .a, because they can be
    +				// rebuilt and used directly from the build cache.
    +				// A few targets (notably those using cgo) still do need to be installed
    +				// in case the user's environment lacks a C compiler.
    +			case p.Internal.GobinSubdir:
    +				base.Errorf("go: cannot install cross-compiled binaries when GOBIN is set")
    +			case p.Internal.CmdlineFiles:
    +				base.Errorf("go: no install location for .go files listed on command line (GOBIN not set)")
    +			case p.ConflictDir != "":
    +				base.Errorf("go: no install location for %s: hidden by %s", p.Dir, p.ConflictDir)
    +			default:
    +				base.Errorf("go: no install location for directory %s outside GOPATH\n"+
    +					"\tFor more details see: 'go help gopath'", p.Dir)
    +			}
    +		}
    +	}
    +	base.ExitIfErrors()
    +
    +	b := NewBuilder("", loaderstate.VendorDirOrEmpty)
    +	defer func() {
    +		if err := b.Close(); err != nil {
    +			base.Fatal(err)
    +		}
    +	}()
    +
    +	depMode := ModeBuild
    +	a := &Action{Mode: "go install"}
    +	var tools []*Action
    +	for _, p := range pkgs {
    +		// If p is a tool, delay the installation until the end of the build.
    +		// This avoids installing assemblers/compilers that are being executed
    +		// by other steps in the build.
    +		a1 := b.AutoAction(loaderstate, ModeInstall, depMode, p)
    +		if load.InstallTargetDir(p) == load.ToTool {
    +			a.Deps = append(a.Deps, a1.Deps...)
    +			a1.Deps = append(a1.Deps, a)
    +			tools = append(tools, a1)
    +			continue
    +		}
    +		a.Deps = append(a.Deps, a1)
    +	}
    +	if len(tools) > 0 {
    +		a = &Action{
    +			Mode: "go install (tools)",
    +			Deps: tools,
    +		}
    +	}
    +
    +	if cfg.BuildBuildmode == "shared" {
    +		// Note: If buildmode=shared then only non-main packages
    +		// are present in the pkgs list, so all the special case code about
    +		// tools above did not apply, and a is just a simple Action
    +		// with a list of Deps, one per package named in pkgs,
    +		// the same as in runBuild.
    +		a = b.buildmodeShared(loaderstate, ModeInstall, ModeInstall, patterns, pkgs, a)
    +	}
    +
    +	b.Do(ctx, a)
    +	base.ExitIfErrors()
    +
    +	// Success. If this command is 'go install' with no arguments
    +	// and the current directory (the implicit argument) is a command,
    +	// remove any leftover command binary from a previous 'go build'.
    +	// The binary is installed; it's not needed here anymore.
    +	// And worse it might be a stale copy, which you don't want to find
    +	// instead of the installed one if $PATH contains dot.
    +	// One way to view this behavior is that it is as if 'go install' first
    +	// runs 'go build' and the moves the generated file to the install dir.
    +	// See issue 9645.
    +	if len(patterns) == 0 && len(pkgs) == 1 && pkgs[0].Name == "main" {
    +		// Compute file 'go build' would have created.
    +		// If it exists and is an executable file, remove it.
    +		targ := pkgs[0].DefaultExecName()
    +		targ += cfg.ExeSuffix
    +		if filepath.Join(pkgs[0].Dir, targ) != pkgs[0].Target { // maybe $GOBIN is the current directory
    +			fi, err := os.Stat(targ)
    +			if err == nil {
    +				m := fi.Mode()
    +				if m.IsRegular() {
    +					if m&0111 != 0 || cfg.Goos == "windows" { // windows never sets executable bit
    +						os.Remove(targ)
    +					}
    +				}
    +			}
    +		}
    +	}
    +}
    +
    +// installOutsideModule implements 'go install pkg@version'. It builds and
    +// installs one or more main packages in module mode while ignoring any go.mod
    +// in the current directory or parent directories.
    +//
    +// See golang.org/issue/40276 for details and rationale.
    +func installOutsideModule(loaderstate *modload.State, ctx context.Context, args []string) {
    +	loaderstate.ForceUseModules = true
    +	loaderstate.RootMode = modload.NoRoot
    +	loaderstate.AllowMissingModuleImports()
    +	modload.Init(loaderstate)
    +	BuildInit(loaderstate)
    +
    +	// Load packages. Ignore non-main packages.
    +	// Print a warning if an argument contains "..." and matches no main packages.
    +	// PackagesAndErrors already prints warnings for patterns that don't match any
    +	// packages, so be careful not to double print.
    +	// TODO(golang.org/issue/40276): don't report errors loading non-main packages
    +	// matched by a pattern.
    +	pkgOpts := load.PackageOpts{MainOnly: true}
    +	pkgs, err := load.PackagesAndErrorsOutsideModule(loaderstate, ctx, pkgOpts, args)
    +	if err != nil {
    +		base.Fatal(err)
    +	}
    +	load.CheckPackageErrors(pkgs)
    +	patterns := make([]string, len(args))
    +	for i, arg := range args {
    +		patterns[i] = arg[:strings.Index(arg, "@")]
    +	}
    +
    +	// Build and install the packages.
    +	InstallPackages(loaderstate, ctx, patterns, pkgs)
    +}
    +
    +// ExecCmd is the command to use to run user binaries.
    +// Normally it is empty, meaning run the binaries directly.
    +// If cross-compiling and running on a remote system or
    +// simulator, it is typically go_GOOS_GOARCH_exec, with
    +// the target GOOS and GOARCH substituted.
    +// The -exec flag overrides these defaults.
    +var ExecCmd []string
    +
    +// FindExecCmd derives the value of ExecCmd to use.
    +// It returns that value and leaves ExecCmd set for direct use.
    +func FindExecCmd() []string {
    +	if ExecCmd != nil {
    +		return ExecCmd
    +	}
    +	ExecCmd = []string{} // avoid work the second time
    +	if cfg.Goos == runtime.GOOS && cfg.Goarch == runtime.GOARCH {
    +		return ExecCmd
    +	}
    +	path, err := pathcache.LookPath(fmt.Sprintf("go_%s_%s_exec", cfg.Goos, cfg.Goarch))
    +	if err == nil {
    +		ExecCmd = []string{path}
    +	}
    +	return ExecCmd
    +}
    +
    +// A coverFlag is a flag.Value that also implies -cover.
    +type coverFlag struct{ V flag.Value }
    +
    +func (f coverFlag) String() string { return f.V.String() }
    +
    +func (f coverFlag) Set(value string) error {
    +	if err := f.V.Set(value); err != nil {
    +		return err
    +	}
    +	cfg.BuildCover = true
    +	return nil
    +}
    +
    +type coverModeFlag string
    +
    +func (f *coverModeFlag) String() string { return string(*f) }
    +func (f *coverModeFlag) Set(value string) error {
    +	switch value {
    +	case "", "set", "count", "atomic":
    +		*f = coverModeFlag(value)
    +		cfg.BuildCoverMode = value
    +		return nil
    +	default:
    +		return errors.New(`valid modes are "set", "count", or "atomic"`)
    +	}
    +}
    +
    +// A commaListFlag is a flag.Value representing a comma-separated list.
    +type commaListFlag struct{ Vals *[]string }
    +
    +func (f commaListFlag) String() string { return strings.Join(*f.Vals, ",") }
    +
    +func (f commaListFlag) Set(value string) error {
    +	if value == "" {
    +		*f.Vals = nil
    +	} else {
    +		*f.Vals = strings.Split(value, ",")
    +	}
    +	return nil
    +}
    +
    +// A stringFlag is a flag.Value representing a single string.
    +type stringFlag struct{ val *string }
    +
    +func (f stringFlag) String() string { return *f.val }
    +func (f stringFlag) Set(value string) error {
    +	*f.val = value
    +	return nil
    +}
    diff --git a/go/src/cmd/go/internal/work/build_test.go b/go/src/cmd/go/internal/work/build_test.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..88221d66fbce629b655e1acbe9de08377cc8abb9
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/build_test.go
    @@ -0,0 +1,274 @@
    +// Copyright 2016 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package work
    +
    +import (
    +	"internal/testenv"
    +	"io/fs"
    +	"os"
    +	"path/filepath"
    +	"reflect"
    +	"runtime"
    +	"strings"
    +	"testing"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/load"
    +)
    +
    +func TestRemoveDevNull(t *testing.T) {
    +	fi, err := os.Lstat(os.DevNull)
    +	if err != nil {
    +		t.Skip(err)
    +	}
    +	if fi.Mode().IsRegular() {
    +		t.Errorf("Lstat(%s).Mode().IsRegular() = true; expected false", os.DevNull)
    +	}
    +	mayberemovefile(os.DevNull)
    +	_, err = os.Lstat(os.DevNull)
    +	if err != nil {
    +		t.Errorf("mayberemovefile(%s) did remove it; oops", os.DevNull)
    +	}
    +}
    +
    +func TestSplitPkgConfigOutput(t *testing.T) {
    +	for _, test := range []struct {
    +		in   []byte
    +		want []string
    +	}{
    +		{[]byte(`-r:foo -L/usr/white\ space/lib -lfoo\ bar -lbar\ baz`), []string{"-r:foo", "-L/usr/white space/lib", "-lfoo bar", "-lbar baz"}},
    +		{[]byte(`-lextra\ fun\ arg\\`), []string{`-lextra fun arg\`}},
    +		{[]byte("\textra     whitespace\r\n"), []string{"extra", "whitespace\r"}},
    +		{[]byte("     \r\n      "), []string{"\r"}},
    +		{[]byte(`"-r:foo" "-L/usr/white space/lib" "-lfoo bar" "-lbar baz"`), []string{"-r:foo", "-L/usr/white space/lib", "-lfoo bar", "-lbar baz"}},
    +		{[]byte(`"-lextra fun arg\\"`), []string{`-lextra fun arg\`}},
    +		{[]byte(`"     \r\n\      "`), []string{`     \r\n\      `}},
    +		{[]byte(`""`), []string{""}},
    +		{[]byte(``), nil},
    +		{[]byte(`"\\"`), []string{`\`}},
    +		{[]byte(`"\x"`), []string{`\x`}},
    +		{[]byte(`"\\x"`), []string{`\x`}},
    +		{[]byte(`'\\'`), []string{`\\`}},
    +		{[]byte(`'\x'`), []string{`\x`}},
    +		{[]byte(`"\\x"`), []string{`\x`}},
    +		{[]byte("\\\n"), nil},
    +		{[]byte(`-fPIC -I/test/include/foo -DQUOTED='"/test/share/doc"'`), []string{"-fPIC", "-I/test/include/foo", `-DQUOTED="/test/share/doc"`}},
    +		{[]byte(`-fPIC -I/test/include/foo -DQUOTED="/test/share/doc"`), []string{"-fPIC", "-I/test/include/foo", "-DQUOTED=/test/share/doc"}},
    +		{[]byte(`-fPIC -I/test/include/foo -DQUOTED=\"/test/share/doc\"`), []string{"-fPIC", "-I/test/include/foo", `-DQUOTED="/test/share/doc"`}},
    +		{[]byte(`-fPIC -I/test/include/foo -DQUOTED='/test/share/doc'`), []string{"-fPIC", "-I/test/include/foo", "-DQUOTED=/test/share/doc"}},
    +		{[]byte(`-DQUOTED='/te\st/share/d\oc'`), []string{`-DQUOTED=/te\st/share/d\oc`}},
    +		{[]byte(`-Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\ world`), []string{"-Dhello=10", "-Dworld=+32", "-DDEFINED_FROM_PKG_CONFIG=hello world"}},
    +		{[]byte(`"broken\"" \\\a "a"`), []string{"broken\"", "\\a", "a"}},
    +	} {
    +		got, err := splitPkgConfigOutput(test.in)
    +		if err != nil {
    +			t.Errorf("splitPkgConfigOutput on %#q failed with error %v", test.in, err)
    +			continue
    +		}
    +		if !reflect.DeepEqual(got, test.want) {
    +			t.Errorf("splitPkgConfigOutput(%#q) = %#q; want %#q", test.in, got, test.want)
    +		}
    +	}
    +
    +	for _, test := range []struct {
    +		in   []byte
    +		want []string
    +	}{
    +		// broken quotation
    +		{[]byte(`"     \r\n      `), nil},
    +		{[]byte(`"-r:foo" "-L/usr/white space/lib "-lfoo bar" "-lbar baz"`), nil},
    +		{[]byte(`"-lextra fun arg\\`), nil},
    +		// broken char escaping
    +		{[]byte(`broken flag\`), nil},
    +		{[]byte(`extra broken flag \`), nil},
    +		{[]byte(`\`), nil},
    +		{[]byte(`"broken\"" "extra" \`), nil},
    +	} {
    +		got, err := splitPkgConfigOutput(test.in)
    +		if err == nil {
    +			t.Errorf("splitPkgConfigOutput(%v) = %v; haven't failed with error as expected.", test.in, got)
    +		}
    +		if !reflect.DeepEqual(got, test.want) {
    +			t.Errorf("splitPkgConfigOutput(%v) = %v; want %v", test.in, got, test.want)
    +		}
    +	}
    +
    +}
    +
    +func TestSharedLibName(t *testing.T) {
    +	// TODO(avdva) - make these values platform-specific
    +	prefix := "lib"
    +	suffix := ".so"
    +	testData := []struct {
    +		args      []string
    +		pkgs      []*load.Package
    +		expected  string
    +		expectErr bool
    +		rootedAt  string
    +	}{
    +		{
    +			args:     []string{"std"},
    +			pkgs:     []*load.Package{},
    +			expected: "std",
    +		},
    +		{
    +			args:     []string{"std", "cmd"},
    +			pkgs:     []*load.Package{},
    +			expected: "std,cmd",
    +		},
    +		{
    +			args:     []string{},
    +			pkgs:     []*load.Package{pkgImportPath("gopkg.in/somelib")},
    +			expected: "gopkg.in-somelib",
    +		},
    +		{
    +			args:     []string{"./..."},
    +			pkgs:     []*load.Package{pkgImportPath("somelib")},
    +			expected: "somelib",
    +			rootedAt: "somelib",
    +		},
    +		{
    +			args:     []string{"../somelib", "../somelib"},
    +			pkgs:     []*load.Package{pkgImportPath("somelib")},
    +			expected: "somelib",
    +		},
    +		{
    +			args:     []string{"../lib1", "../lib2"},
    +			pkgs:     []*load.Package{pkgImportPath("gopkg.in/lib1"), pkgImportPath("gopkg.in/lib2")},
    +			expected: "gopkg.in-lib1,gopkg.in-lib2",
    +		},
    +		{
    +			args: []string{"./..."},
    +			pkgs: []*load.Package{
    +				pkgImportPath("gopkg.in/dir/lib1"),
    +				pkgImportPath("gopkg.in/lib2"),
    +				pkgImportPath("gopkg.in/lib3"),
    +			},
    +			expected: "gopkg.in",
    +			rootedAt: "gopkg.in",
    +		},
    +		{
    +			args:      []string{"std", "../lib2"},
    +			pkgs:      []*load.Package{},
    +			expectErr: true,
    +		},
    +		{
    +			args:      []string{"all", "./"},
    +			pkgs:      []*load.Package{},
    +			expectErr: true,
    +		},
    +		{
    +			args:      []string{"cmd", "fmt"},
    +			pkgs:      []*load.Package{},
    +			expectErr: true,
    +		},
    +	}
    +	for _, data := range testData {
    +		func() {
    +			if data.rootedAt != "" {
    +				tmpGopath, err := os.MkdirTemp("", "gopath")
    +				if err != nil {
    +					t.Fatal(err)
    +				}
    +				cwd := base.Cwd()
    +				oldGopath := cfg.BuildContext.GOPATH
    +				defer func() {
    +					cfg.BuildContext.GOPATH = oldGopath
    +					os.Chdir(cwd)
    +					err := os.RemoveAll(tmpGopath)
    +					if err != nil {
    +						t.Error(err)
    +					}
    +				}()
    +				root := filepath.Join(tmpGopath, "src", data.rootedAt)
    +				err = os.MkdirAll(root, 0755)
    +				if err != nil {
    +					t.Fatal(err)
    +				}
    +				cfg.BuildContext.GOPATH = tmpGopath
    +				os.Chdir(root)
    +			}
    +			computed, err := libname(data.args, data.pkgs)
    +			if err != nil {
    +				if !data.expectErr {
    +					t.Errorf("libname returned an error %q, expected a name", err.Error())
    +				}
    +			} else if data.expectErr {
    +				t.Errorf("libname returned %q, expected an error", computed)
    +			} else {
    +				expected := prefix + data.expected + suffix
    +				if expected != computed {
    +					t.Errorf("libname returned %q, expected %q", computed, expected)
    +				}
    +			}
    +		}()
    +	}
    +}
    +
    +func pkgImportPath(pkgpath string) *load.Package {
    +	return &load.Package{
    +		PackagePublic: load.PackagePublic{
    +			ImportPath: pkgpath,
    +		},
    +	}
    +}
    +
    +// When installing packages, the installed package directory should
    +// respect the SetGID bit and group name of the destination
    +// directory.
    +// See https://golang.org/issue/18878.
    +func TestRespectSetgidDir(t *testing.T) {
    +	// Check that `cp` is called instead of `mv` by looking at the output
    +	// of `(*Shell).ShowCmd` afterwards as a sanity check.
    +	cfg.BuildX = true
    +	var cmdBuf strings.Builder
    +	sh := NewShell("", &load.TextPrinter{Writer: &cmdBuf})
    +
    +	setgiddir := t.TempDir()
    +
    +	// BSD mkdir(2) inherits the parent directory group, and other platforms
    +	// can inherit the parent directory group via setgid. The test setup (chmod
    +	// setgid) will fail if the process does not have the group permission to
    +	// the new temporary directory.
    +	err := os.Chown(setgiddir, os.Getuid(), os.Getgid())
    +	if err != nil {
    +		if testenv.SyscallIsNotSupported(err) {
    +			t.Skip("skipping: chown is not supported on " + runtime.GOOS)
    +		}
    +		t.Fatal(err)
    +	}
    +
    +	// Change setgiddir's permissions to include the SetGID bit.
    +	if err := os.Chmod(setgiddir, 0755|fs.ModeSetgid); err != nil {
    +		if testenv.SyscallIsNotSupported(err) {
    +			t.Skip("skipping: chmod is not supported on " + runtime.GOOS)
    +		}
    +		t.Fatal(err)
    +	}
    +	if fi, err := os.Stat(setgiddir); err != nil {
    +		t.Fatal(err)
    +	} else if fi.Mode()&fs.ModeSetgid == 0 {
    +		t.Skip("skipping: Chmod ignored ModeSetgid on " + runtime.GOOS)
    +	}
    +
    +	pkgfile, err := os.CreateTemp("", "pkgfile")
    +	if err != nil {
    +		t.Fatalf("os.CreateTemp(\"\", \"pkgfile\"): %v", err)
    +	}
    +	defer os.Remove(pkgfile.Name())
    +	defer pkgfile.Close()
    +
    +	dirGIDFile := filepath.Join(setgiddir, "setgid")
    +	if err := sh.moveOrCopyFile(dirGIDFile, pkgfile.Name(), 0666, true); err != nil {
    +		t.Fatalf("moveOrCopyFile: %v", err)
    +	}
    +
    +	got := strings.TrimSpace(cmdBuf.String())
    +	want := sh.fmtCmd("", "cp %s %s", pkgfile.Name(), dirGIDFile)
    +	if got != want {
    +		t.Fatalf("moveOrCopyFile(%q, %q): want %q, got %q", dirGIDFile, pkgfile.Name(), want, got)
    +	}
    +}
    diff --git a/go/src/cmd/go/internal/work/buildid.go b/go/src/cmd/go/internal/work/buildid.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..584c1ac6f41d237d2191af5a66888970a80dd78b
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/buildid.go
    @@ -0,0 +1,776 @@
    +// Copyright 2017 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package work
    +
    +import (
    +	"bytes"
    +	"fmt"
    +	"os"
    +	"os/exec"
    +	"strings"
    +	"sync"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cache"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/fsys"
    +	"cmd/go/internal/str"
    +	"cmd/internal/buildid"
    +	"cmd/internal/pathcache"
    +	"cmd/internal/quoted"
    +	"cmd/internal/telemetry/counter"
    +)
    +
    +// Build IDs
    +//
    +// Go packages and binaries are stamped with build IDs that record both
    +// the action ID, which is a hash of the inputs to the action that produced
    +// the packages or binary, and the content ID, which is a hash of the action
    +// output, namely the archive or binary itself. The hash is the same one
    +// used by the build artifact cache (see cmd/go/internal/cache), but
    +// truncated when stored in packages and binaries, as the full length is not
    +// needed and is a bit unwieldy. The precise form is
    +//
    +//	actionID/[.../]contentID
    +//
    +// where the actionID and contentID are prepared by buildid.HashToString below.
    +// and are found by looking for the first or last slash.
    +// Usually the buildID is simply actionID/contentID, but see below for an
    +// exception.
    +//
    +// The build ID serves two primary purposes.
    +//
    +// 1. The action ID half allows installed packages and binaries to serve as
    +// one-element cache entries. If we intend to build math.a with a given
    +// set of inputs summarized in the action ID, and the installed math.a already
    +// has that action ID, we can reuse the installed math.a instead of rebuilding it.
    +//
    +// 2. The content ID half allows the easy preparation of action IDs for steps
    +// that consume a particular package or binary. The content hash of every
    +// input file for a given action must be included in the action ID hash.
    +// Storing the content ID in the build ID lets us read it from the file with
    +// minimal I/O, instead of reading and hashing the entire file.
    +// This is especially effective since packages and binaries are typically
    +// the largest inputs to an action.
    +//
    +// Separating action ID from content ID is important for reproducible builds.
    +// The compiler is compiled with itself. If an output were represented by its
    +// own action ID (instead of content ID) when computing the action ID of
    +// the next step in the build process, then the compiler could never have its
    +// own input action ID as its output action ID (short of a miraculous hash collision).
    +// Instead we use the content IDs to compute the next action ID, and because
    +// the content IDs converge, so too do the action IDs and therefore the
    +// build IDs and the overall compiler binary. See cmd/dist's cmdbootstrap
    +// for the actual convergence sequence.
    +//
    +// The “one-element cache” purpose is a bit more complex for installed
    +// binaries. For a binary, like cmd/gofmt, there are two steps: compile
    +// cmd/gofmt/*.go into main.a, and then link main.a into the gofmt binary.
    +// We do not install gofmt's main.a, only the gofmt binary. Being able to
    +// decide that the gofmt binary is up-to-date means computing the action ID
    +// for the final link of the gofmt binary and comparing it against the
    +// already-installed gofmt binary. But computing the action ID for the link
    +// means knowing the content ID of main.a, which we did not keep.
    +// To sidestep this problem, each binary actually stores an expanded build ID:
    +//
    +//	actionID(binary)/actionID(main.a)/contentID(main.a)/contentID(binary)
    +//
    +// (Note that this can be viewed equivalently as:
    +//
    +//	actionID(binary)/buildID(main.a)/contentID(binary)
    +//
    +// Storing the buildID(main.a) in the middle lets the computations that care
    +// about the prefix or suffix halves ignore the middle and preserves the
    +// original build ID as a contiguous string.)
    +//
    +// During the build, when it's time to build main.a, the gofmt binary has the
    +// information needed to decide whether the eventual link would produce
    +// the same binary: if the action ID for main.a's inputs matches and then
    +// the action ID for the link step matches when assuming the given main.a
    +// content ID, then the binary as a whole is up-to-date and need not be rebuilt.
    +//
    +// This is all a bit complex and may be simplified once we can rely on the
    +// main cache, but at least at the start we will be using the content-based
    +// staleness determination without a cache beyond the usual installed
    +// package and binary locations.
    +
    +const buildIDSeparator = "/"
    +
    +// actionID returns the action ID half of a build ID.
    +func actionID(buildID string) string {
    +	i := strings.Index(buildID, buildIDSeparator)
    +	if i < 0 {
    +		return buildID
    +	}
    +	return buildID[:i]
    +}
    +
    +// contentID returns the content ID half of a build ID.
    +func contentID(buildID string) string {
    +	return buildID[strings.LastIndex(buildID, buildIDSeparator)+1:]
    +}
    +
    +// toolID returns the unique ID to use for the current copy of the
    +// named tool (asm, compile, cover, link).
    +//
    +// It is important that if the tool changes (for example a compiler bug is fixed
    +// and the compiler reinstalled), toolID returns a different string, so that old
    +// package archives look stale and are rebuilt (with the fixed compiler).
    +// This suggests using a content hash of the tool binary, as stored in the build ID.
    +//
    +// Unfortunately, we can't just open the tool binary, because the tool might be
    +// invoked via a wrapper program specified by -toolexec and we don't know
    +// what the wrapper program does. In particular, we want "-toolexec toolstash"
    +// to continue working: it does no good if "-toolexec toolstash" is executing a
    +// stashed copy of the compiler but the go command is acting as if it will run
    +// the standard copy of the compiler. The solution is to ask the tool binary to tell
    +// us its own build ID using the "-V=full" flag now supported by all tools.
    +// Then we know we're getting the build ID of the compiler that will actually run
    +// during the build. (How does the compiler binary know its own content hash?
    +// We store it there using updateBuildID after the standard link step.)
    +//
    +// A final twist is that we'd prefer to have reproducible builds for release toolchains.
    +// It should be possible to cross-compile for Windows from either Linux or Mac
    +// or Windows itself and produce the same binaries, bit for bit. If the tool ID,
    +// which influences the action ID half of the build ID, is based on the content ID,
    +// then the Linux compiler binary and Mac compiler binary will have different tool IDs
    +// and therefore produce executables with different action IDs.
    +// To avoid this problem, for releases we use the release version string instead
    +// of the compiler binary's content hash. This assumes that all compilers built
    +// on all different systems are semantically equivalent, which is of course only true
    +// modulo bugs. (Producing the exact same executables also requires that the different
    +// build setups agree on details like $GOROOT and file name paths, but at least the
    +// tool IDs do not make it impossible.)
    +func (b *Builder) toolID(name string) string {
    +	return b.toolIDCache.Do(name, func() string {
    +		path := base.Tool(name)
    +		desc := "go tool " + name
    +
    +		// Special case: -{vet,fix}tool overrides usual cmd/{vet,fix}
    +		// for testing or supplying an alternative analysis tool.
    +		// (We use only "vet" terminology in the action graph.)
    +		if name == "vet" {
    +			path = VetTool
    +			desc = VetTool
    +		}
    +
    +		cmdline := str.StringList(cfg.BuildToolexec, path, "-V=full")
    +		cmd := exec.Command(cmdline[0], cmdline[1:]...)
    +		var stdout, stderr strings.Builder
    +		cmd.Stdout = &stdout
    +		cmd.Stderr = &stderr
    +		if err := cmd.Run(); err != nil {
    +			if stderr.Len() > 0 {
    +				os.Stderr.WriteString(stderr.String())
    +			}
    +			base.Fatalf("go: error obtaining buildID for %s: %v", desc, err)
    +		}
    +
    +		line := stdout.String()
    +		f := strings.Fields(line)
    +		if len(f) < 3 || f[0] != name && path != VetTool || f[1] != "version" || strings.Contains(f[2], "devel") && !strings.HasPrefix(f[len(f)-1], "buildID=") {
    +			base.Fatalf("go: parsing buildID from %s -V=full: unexpected output:\n\t%s", desc, line)
    +		}
    +		if strings.Contains(f[2], "devel") {
    +			// On the development branch, use the content ID part of the build ID.
    +			return contentID(f[len(f)-1])
    +		}
    +		// For a release, the output is like: "compile version go1.9.1 X:framepointer".
    +		// Use the whole line.
    +		return strings.TrimSpace(line)
    +	})
    +}
    +
    +// gccToolID returns the unique ID to use for a tool that is invoked
    +// by the GCC driver. This is used particularly for gccgo, but this can also
    +// be used for gcc, g++, gfortran, etc.; those tools all use the GCC
    +// driver under different names. The approach used here should also
    +// work for sufficiently new versions of clang. Unlike toolID, the
    +// name argument is the program to run. The language argument is the
    +// type of input file as passed to the GCC driver's -x option.
    +//
    +// For these tools we have no -V=full option to dump the build ID,
    +// but we can run the tool with -v -### to reliably get the compiler proper
    +// and hash that. That will work in the presence of -toolexec.
    +//
    +// In order to get reproducible builds for released compilers, we
    +// detect a released compiler by the absence of "experimental" in the
    +// --version output, and in that case we just use the version string.
    +//
    +// gccToolID also returns the underlying executable for the compiler.
    +// The caller assumes that stat of the exe can be used, combined with the id,
    +// to detect changes in the underlying compiler. The returned exe can be empty,
    +// which means to rely only on the id.
    +func (b *Builder) gccToolID(name, language string) (id, exe string, err error) {
    +	//TODO: Use par.Cache instead of a mutex and a map. See Builder.toolID.
    +	key := name + "." + language
    +	b.id.Lock()
    +	id = b.gccToolIDCache[key]
    +	exe = b.gccToolIDCache[key+".exe"]
    +	b.id.Unlock()
    +
    +	if id != "" {
    +		return id, exe, nil
    +	}
    +
    +	// Invoke the driver with -### to see the subcommands and the
    +	// version strings. Use -x to set the language. Pretend to
    +	// compile an empty file on standard input.
    +	cmdline := str.StringList(cfg.BuildToolexec, name, "-###", "-x", language, "-c", "-")
    +	cmd := exec.Command(cmdline[0], cmdline[1:]...)
    +	// Force untranslated output so that we see the string "version".
    +	cmd.Env = append(os.Environ(), "LC_ALL=C")
    +	out, err := cmd.CombinedOutput()
    +	if err != nil {
    +		return "", "", fmt.Errorf("%s: %v; output: %q", name, err, out)
    +	}
    +
    +	version := ""
    +	lines := strings.Split(string(out), "\n")
    +	for _, line := range lines {
    +		fields := strings.Fields(line)
    +		for i, field := range fields {
    +			if strings.HasSuffix(field, ":") {
    +				// Avoid parsing fields of lines like "Configured with: …", which may
    +				// contain arbitrary substrings.
    +				break
    +			}
    +			if field == "version" && i < len(fields)-1 {
    +				// Check that the next field is plausibly a version number.
    +				// We require only that it begins with an ASCII digit,
    +				// since we don't know what version numbering schemes a given
    +				// C compiler may use. (Clang and GCC mostly seem to follow the scheme X.Y.Z,
    +				// but in https://go.dev/issue/64619 we saw "8.3 [DragonFly]", and who knows
    +				// what other C compilers like "zig cc" might report?)
    +				next := fields[i+1]
    +				if len(next) > 0 && next[0] >= '0' && next[0] <= '9' {
    +					version = line
    +					break
    +				}
    +			}
    +		}
    +		if version != "" {
    +			break
    +		}
    +	}
    +	if version == "" {
    +		return "", "", fmt.Errorf("%s: can not find version number in %q", name, out)
    +	}
    +
    +	if !strings.Contains(version, "experimental") {
    +		// This is a release. Use this line as the tool ID.
    +		id = version
    +	} else {
    +		// This is a development version. The first line with
    +		// a leading space is the compiler proper.
    +		compiler := ""
    +		for _, line := range lines {
    +			if strings.HasPrefix(line, " ") && !strings.HasPrefix(line, " (in-process)") {
    +				compiler = line
    +				break
    +			}
    +		}
    +		if compiler == "" {
    +			return "", "", fmt.Errorf("%s: can not find compilation command in %q", name, out)
    +		}
    +
    +		fields, _ := quoted.Split(compiler)
    +		if len(fields) == 0 {
    +			return "", "", fmt.Errorf("%s: compilation command confusion %q", name, out)
    +		}
    +		exe = fields[0]
    +		if !strings.ContainsAny(exe, `/\`) {
    +			if lp, err := pathcache.LookPath(exe); err == nil {
    +				exe = lp
    +			}
    +		}
    +		id, err = buildid.ReadFile(exe)
    +		if err != nil {
    +			return "", "", err
    +		}
    +
    +		// If we can't find a build ID, use a hash.
    +		if id == "" {
    +			id = b.fileHash(exe)
    +		}
    +	}
    +
    +	b.id.Lock()
    +	b.gccToolIDCache[key] = id
    +	b.gccToolIDCache[key+".exe"] = exe
    +	b.id.Unlock()
    +
    +	return id, exe, nil
    +}
    +
    +// Check if assembler used by gccgo is GNU as.
    +func assemblerIsGas() bool {
    +	cmd := exec.Command(BuildToolchain.compiler(), "-print-prog-name=as")
    +	assembler, err := cmd.Output()
    +	if err == nil {
    +		cmd := exec.Command(strings.TrimSpace(string(assembler)), "--version")
    +		out, err := cmd.Output()
    +		return err == nil && strings.Contains(string(out), "GNU")
    +	} else {
    +		return false
    +	}
    +}
    +
    +// gccgoBuildIDFile creates an assembler file that records the
    +// action's build ID in an SHF_EXCLUDE section for ELF files or
    +// in a CSECT in XCOFF files.
    +func (b *Builder) gccgoBuildIDFile(a *Action) (string, error) {
    +	sfile := a.Objdir + "_buildid.s"
    +
    +	var buf bytes.Buffer
    +	if cfg.Goos == "aix" {
    +		fmt.Fprintf(&buf, "\t.csect .go.buildid[XO]\n")
    +	} else if (cfg.Goos != "solaris" && cfg.Goos != "illumos") || assemblerIsGas() {
    +		fmt.Fprintf(&buf, "\t"+`.section .go.buildid,"e"`+"\n")
    +	} else if cfg.Goarch == "sparc" || cfg.Goarch == "sparc64" {
    +		fmt.Fprintf(&buf, "\t"+`.section ".go.buildid",#exclude`+"\n")
    +	} else { // cfg.Goarch == "386" || cfg.Goarch == "amd64"
    +		fmt.Fprintf(&buf, "\t"+`.section .go.buildid,#exclude`+"\n")
    +	}
    +	fmt.Fprintf(&buf, "\t.byte ")
    +	for i := 0; i < len(a.buildID); i++ {
    +		if i > 0 {
    +			if i%8 == 0 {
    +				fmt.Fprintf(&buf, "\n\t.byte ")
    +			} else {
    +				fmt.Fprintf(&buf, ",")
    +			}
    +		}
    +		fmt.Fprintf(&buf, "%#02x", a.buildID[i])
    +	}
    +	fmt.Fprintf(&buf, "\n")
    +	if cfg.Goos != "solaris" && cfg.Goos != "illumos" && cfg.Goos != "aix" {
    +		secType := "@progbits"
    +		if cfg.Goarch == "arm" {
    +			secType = "%progbits"
    +		}
    +		fmt.Fprintf(&buf, "\t"+`.section .note.GNU-stack,"",%s`+"\n", secType)
    +		fmt.Fprintf(&buf, "\t"+`.section .note.GNU-split-stack,"",%s`+"\n", secType)
    +	}
    +
    +	if err := b.Shell(a).writeFile(sfile, buf.Bytes()); err != nil {
    +		return "", err
    +	}
    +
    +	return sfile, nil
    +}
    +
    +// buildID returns the build ID found in the given file.
    +// If no build ID is found, buildID returns the content hash of the file.
    +func (b *Builder) buildID(file string) string {
    +	b.id.Lock()
    +	id := b.buildIDCache[file]
    +	b.id.Unlock()
    +
    +	if id != "" {
    +		return id
    +	}
    +
    +	id, err := buildid.ReadFile(file)
    +	if err != nil {
    +		id = b.fileHash(file)
    +	}
    +
    +	b.id.Lock()
    +	b.buildIDCache[file] = id
    +	b.id.Unlock()
    +
    +	return id
    +}
    +
    +// fileHash returns the content hash of the named file.
    +func (b *Builder) fileHash(file string) string {
    +	sum, err := cache.FileHash(fsys.Actual(file))
    +	if err != nil {
    +		return ""
    +	}
    +	return buildid.HashToString(sum)
    +}
    +
    +var (
    +	counterCacheHit  = counter.New("go/buildcache/hit")
    +	counterCacheMiss = counter.New("go/buildcache/miss")
    +
    +	stdlibRecompiled        = counter.New("go/buildcache/stdlib-recompiled")
    +	stdlibRecompiledIncOnce = sync.OnceFunc(stdlibRecompiled.Inc)
    +)
    +
    +// testRunAction returns the run action for a test given the link action
    +// for the test binary, if the only (non-test-barrier) action that depend
    +// on the link action is the run action.
    +func testRunAction(a *Action) *Action {
    +	if len(a.triggers) != 1 || a.triggers[0].Mode != "test barrier" {
    +		return nil
    +	}
    +	var runAction *Action
    +	for _, t := range a.triggers[0].triggers {
    +		if t.Mode == "test run" {
    +			if runAction != nil {
    +				return nil
    +			}
    +			runAction = t
    +		}
    +	}
    +	return runAction
    +}
    +
    +// useCache tries to satisfy the action a, which has action ID actionHash,
    +// by using a cached result from an earlier build.
    +// If useCache decides that the cache can be used, it sets a.buildID
    +// and a.built for use by parent actions and then returns true.
    +// Otherwise it sets a.buildID to a temporary build ID for use in the build
    +// and returns false. When useCache returns false the expectation is that
    +// the caller will build the target and then call updateBuildID to finish the
    +// build ID computation.
    +// When useCache returns false, it may have initiated buffering of output
    +// during a's work. The caller should defer b.flushOutput(a), to make sure
    +// that flushOutput is eventually called regardless of whether the action
    +// succeeds. The flushOutput call must happen after updateBuildID.
    +func (b *Builder) useCache(a *Action, actionHash cache.ActionID, target string, printOutput bool) (ok bool) {
    +	// The second half of the build ID here is a placeholder for the content hash.
    +	// It's important that the overall buildID be unlikely verging on impossible
    +	// to appear in the output by chance, but that should be taken care of by
    +	// the actionID half; if it also appeared in the input that would be like an
    +	// engineered 120-bit partial SHA256 collision.
    +	a.actionID = actionHash
    +	actionID := buildid.HashToString(actionHash)
    +	if a.json != nil {
    +		a.json.ActionID = actionID
    +	}
    +	contentID := actionID // temporary placeholder, likely unique
    +	a.buildID = actionID + buildIDSeparator + contentID
    +
    +	// Executable binaries also record the main build ID in the middle.
    +	// See "Build IDs" comment above.
    +	if a.Mode == "link" {
    +		mainpkg := a.Deps[0]
    +		a.buildID = actionID + buildIDSeparator + mainpkg.buildID + buildIDSeparator + contentID
    +	}
    +
    +	// If user requested -a, we force a rebuild, so don't use the cache.
    +	if cfg.BuildA {
    +		if p := a.Package; p != nil && !p.Stale {
    +			p.Stale = true
    +			p.StaleReason = "build -a flag in use"
    +		}
    +		// Begin saving output for later writing to cache.
    +		a.output = []byte{}
    +		return false
    +	}
    +
    +	defer func() {
    +		// Increment counters for cache hits and misses based on the return value
    +		// of this function. Don't increment counters if we return early because of
    +		// cfg.BuildA above because we don't even look at the cache in that case.
    +		if ok {
    +			counterCacheHit.Inc()
    +		} else {
    +			if a.Package != nil && a.Package.Standard {
    +				stdlibRecompiledIncOnce()
    +			}
    +			counterCacheMiss.Inc()
    +		}
    +	}()
    +
    +	c := cache.Default()
    +
    +	if target != "" {
    +		buildID, _ := buildid.ReadFile(target)
    +		if strings.HasPrefix(buildID, actionID+buildIDSeparator) {
    +			a.buildID = buildID
    +			if a.json != nil {
    +				a.json.BuildID = a.buildID
    +			}
    +			a.built = target
    +			// Poison a.Target to catch uses later in the build.
    +			a.Target = "DO NOT USE - " + a.Mode
    +			return true
    +		}
    +		// Special case for building a main package: if the only thing we
    +		// want the package for is to link a binary, and the binary is
    +		// already up-to-date, then to avoid a rebuild, report the package
    +		// as up-to-date as well. See "Build IDs" comment above.
    +		// TODO(rsc): Rewrite this code to use a TryCache func on the link action.
    +		if !b.NeedExport && a.Mode == "build" && len(a.triggers) == 1 && a.triggers[0].Mode == "link" {
    +			if id := strings.Split(buildID, buildIDSeparator); len(id) == 4 && id[1] == actionID {
    +				// Temporarily assume a.buildID is the package build ID
    +				// stored in the installed binary, and see if that makes
    +				// the upcoming link action ID a match. If so, report that
    +				// we built the package, safe in the knowledge that the
    +				// link step will not ask us for the actual package file.
    +				// Note that (*Builder).LinkAction arranged that all of
    +				// a.triggers[0]'s dependencies other than a are also
    +				// dependencies of a, so that we can be sure that,
    +				// other than a.buildID, b.linkActionID is only accessing
    +				// build IDs of completed actions.
    +				oldBuildID := a.buildID
    +				a.buildID = id[1] + buildIDSeparator + id[2]
    +				linkID := buildid.HashToString(b.linkActionID(a.triggers[0]))
    +				if id[0] == linkID {
    +					// Best effort attempt to display output from the compile and link steps.
    +					// If it doesn't work, it doesn't work: reusing the cached binary is more
    +					// important than reprinting diagnostic information.
    +					if printOutput {
    +						showStdout(b, c, a, "stdout")      // compile output
    +						showStdout(b, c, a, "link-stdout") // link output
    +					}
    +
    +					// Poison a.Target to catch uses later in the build.
    +					a.Target = "DO NOT USE - main build pseudo-cache Target"
    +					a.built = "DO NOT USE - main build pseudo-cache built"
    +					if a.json != nil {
    +						a.json.BuildID = a.buildID
    +					}
    +					return true
    +				}
    +				// Otherwise restore old build ID for main build.
    +				a.buildID = oldBuildID
    +			}
    +		}
    +	}
    +
    +	// TODO(matloob): If we end up caching all executables, the test executable will
    +	// already be cached so building it won't do any work. But for now we won't
    +	// cache all executables and instead only want to cache some:
    +	// we only cache executables produced for 'go run' (and soon, for 'go tool').
    +	//
    +	// Special case for linking a test binary: if the only thing we
    +	// want the binary for is to run the test, and the test result is cached,
    +	// then to avoid the link step, report the link as up-to-date.
    +	// We avoid the nested build ID problem in the previous special case
    +	// by recording the test results in the cache under the action ID half.
    +	if ra := testRunAction(a); ra != nil && ra.TryCache != nil && ra.TryCache(b, ra, a) {
    +		// Best effort attempt to display output from the compile and link steps.
    +		// If it doesn't work, it doesn't work: reusing the test result is more
    +		// important than reprinting diagnostic information.
    +		if printOutput {
    +			showStdout(b, c, a.Deps[0], "stdout")      // compile output
    +			showStdout(b, c, a.Deps[0], "link-stdout") // link output
    +		}
    +
    +		// Poison a.Target to catch uses later in the build.
    +		a.Target = "DO NOT USE -  pseudo-cache Target"
    +		a.built = "DO NOT USE - pseudo-cache built"
    +		return true
    +	}
    +
    +	// Check to see if the action output is cached.
    +	if file, _, err := cache.GetFile(c, actionHash); err == nil {
    +		if a.Mode == "preprocess PGO profile" {
    +			// Preprocessed PGO profiles don't embed a build ID, so
    +			// skip the build ID lookup.
    +			// TODO(prattmic): better would be to add a build ID to the format.
    +			a.built = file
    +			a.Target = "DO NOT USE - using cache"
    +			return true
    +		}
    +		if buildID, err := buildid.ReadFile(file); err == nil {
    +			if printOutput {
    +				switch a.Mode {
    +				case "link":
    +					// The link output is stored using the build action's action ID.
    +					// See corresponding code storing the link output in updateBuildID.
    +					for _, a1 := range a.Deps {
    +						showStdout(b, c, a1, "link-stdout") // link output
    +					}
    +				default:
    +					showStdout(b, c, a, "stdout") // compile output
    +				}
    +			}
    +			a.built = file
    +			a.Target = "DO NOT USE - using cache"
    +			a.buildID = buildID
    +			if a.json != nil {
    +				a.json.BuildID = a.buildID
    +			}
    +			if p := a.Package; p != nil && target != "" {
    +				p.Stale = true
    +				// Clearer than explaining that something else is stale.
    +				p.StaleReason = "not installed but available in build cache"
    +			}
    +			return true
    +		}
    +	}
    +
    +	// If we've reached this point, we can't use the cache for the action.
    +	if p := a.Package; p != nil && !p.Stale {
    +		p.Stale = true
    +		p.StaleReason = "build ID mismatch"
    +		if b.IsCmdList {
    +			// Since we may end up printing StaleReason, include more detail.
    +			for _, p1 := range p.Internal.Imports {
    +				if p1.Stale && p1.StaleReason != "" {
    +					if strings.HasPrefix(p1.StaleReason, "stale dependency: ") {
    +						p.StaleReason = p1.StaleReason
    +						break
    +					}
    +					if strings.HasPrefix(p.StaleReason, "build ID mismatch") {
    +						p.StaleReason = "stale dependency: " + p1.ImportPath
    +					}
    +				}
    +			}
    +		}
    +	}
    +
    +	// Begin saving output for later writing to cache.
    +	a.output = []byte{}
    +	return false
    +}
    +
    +func showStdout(b *Builder, c cache.Cache, a *Action, key string) error {
    +	actionID := a.actionID
    +
    +	stdout, stdoutEntry, err := cache.GetBytes(c, cache.Subkey(actionID, key))
    +	if err != nil {
    +		return err
    +	}
    +
    +	if len(stdout) > 0 {
    +		sh := b.Shell(a)
    +		if cfg.BuildX || cfg.BuildN {
    +			sh.ShowCmd("", "%s  # internal", joinUnambiguously(str.StringList("cat", c.OutputFile(stdoutEntry.OutputID))))
    +		}
    +		if !cfg.BuildN {
    +			sh.Printf("%s", stdout)
    +		}
    +	}
    +	return nil
    +}
    +
    +// flushOutput flushes the output being queued in a.
    +func (b *Builder) flushOutput(a *Action) {
    +	b.Shell(a).Printf("%s", a.output)
    +	a.output = nil
    +}
    +
    +// updateBuildID updates the build ID in the target written by action a.
    +// It requires that useCache was called for action a and returned false,
    +// and that the build was then carried out and given the temporary
    +// a.buildID to record as the build ID in the resulting package or binary.
    +// updateBuildID computes the final content ID and updates the build IDs
    +// in the binary.
    +//
    +// Keep in sync with src/cmd/buildid/buildid.go
    +func (b *Builder) updateBuildID(a *Action, target string) error {
    +	sh := b.Shell(a)
    +
    +	if cfg.BuildX || cfg.BuildN {
    +		sh.ShowCmd("", "%s # internal", joinUnambiguously(str.StringList("go", "tool", "buildid", "-w", target)))
    +		if cfg.BuildN {
    +			return nil
    +		}
    +	}
    +
    +	c := cache.Default()
    +
    +	// Cache output from compile/link, even if we don't do the rest.
    +	switch a.Mode {
    +	case "build":
    +		cache.PutBytes(c, cache.Subkey(a.actionID, "stdout"), a.output)
    +	case "link":
    +		// Even though we don't cache the binary, cache the linker text output.
    +		// We might notice that an installed binary is up-to-date but still
    +		// want to pretend to have run the linker.
    +		// Store it under the main package's action ID
    +		// to make it easier to find when that's all we have.
    +		for _, a1 := range a.Deps {
    +			if p1 := a1.Package; p1 != nil && p1.Name == "main" {
    +				cache.PutBytes(c, cache.Subkey(a1.actionID, "link-stdout"), a.output)
    +				break
    +			}
    +		}
    +	}
    +
    +	// Find occurrences of old ID and compute new content-based ID.
    +	r, err := os.Open(target)
    +	if err != nil {
    +		return err
    +	}
    +	matches, hash, err := buildid.FindAndHash(r, a.buildID, 0)
    +	r.Close()
    +	if err != nil {
    +		return err
    +	}
    +	newID := a.buildID[:strings.LastIndex(a.buildID, buildIDSeparator)] + buildIDSeparator + buildid.HashToString(hash)
    +	if len(newID) != len(a.buildID) {
    +		return fmt.Errorf("internal error: build ID length mismatch %q vs %q", a.buildID, newID)
    +	}
    +
    +	// Replace with new content-based ID.
    +	a.buildID = newID
    +	if a.json != nil {
    +		a.json.BuildID = a.buildID
    +	}
    +	if len(matches) == 0 {
    +		// Assume the user specified -buildid= to override what we were going to choose.
    +		return nil
    +	}
    +
    +	// Replace the build id in the file with the content-based ID.
    +	w, err := os.OpenFile(target, os.O_RDWR, 0)
    +	if err != nil {
    +		return err
    +	}
    +	err = buildid.Rewrite(w, matches, newID)
    +	if err != nil {
    +		w.Close()
    +		return err
    +	}
    +	if err := w.Close(); err != nil {
    +		return err
    +	}
    +
    +	// Cache package builds, and cache executable builds if
    +	// executable caching was requested. Executables are not
    +	// cached by default because they are not reused
    +	// nearly as often as individual packages, and they're
    +	// much larger, so the cache-footprint-to-utility ratio
    +	// of executables is much lower for executables.
    +	if a.Mode == "build" {
    +		r, err := os.Open(target)
    +		if err == nil {
    +			if a.output == nil {
    +				panic("internal error: a.output not set")
    +			}
    +			outputID, _, err := c.Put(a.actionID, r)
    +			r.Close()
    +			if err == nil && cfg.BuildX {
    +				sh.ShowCmd("", "%s # internal", joinUnambiguously(str.StringList("cp", target, c.OutputFile(outputID))))
    +			}
    +			if b.NeedExport {
    +				if err != nil {
    +					return err
    +				}
    +				a.Package.Export = c.OutputFile(outputID)
    +				a.Package.BuildID = a.buildID
    +			}
    +		}
    +	}
    +	if c, ok := c.(*cache.DiskCache); a.Mode == "link" && a.CacheExecutable && ok {
    +		r, err := os.Open(target)
    +		if err == nil {
    +			if a.output == nil {
    +				panic("internal error: a.output not set")
    +			}
    +			name := a.Package.Internal.ExeName
    +			if name == "" {
    +				name = a.Package.DefaultExecName()
    +			}
    +			outputID, _, err := c.PutExecutable(a.actionID, name+cfg.ExeSuffix, r)
    +			r.Close()
    +			a.cachedExecutable = c.OutputFile(outputID)
    +			if err == nil && cfg.BuildX {
    +				sh.ShowCmd("", "%s # internal", joinUnambiguously(str.StringList("cp", target, a.cachedExecutable)))
    +			}
    +		}
    +	}
    +
    +	return nil
    +}
    diff --git a/go/src/cmd/go/internal/work/cover.go b/go/src/cmd/go/internal/work/cover.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..be090ce4c3b50b8f604b5fa194ba0b8cf1008593
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/cover.go
    @@ -0,0 +1,153 @@
    +// Copyright 2023 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Action graph execution methods related to coverage.
    +
    +package work
    +
    +import (
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/str"
    +	"cmd/internal/cov/covcmd"
    +	"context"
    +	"encoding/json"
    +	"fmt"
    +	"internal/coverage"
    +	"io"
    +	"os"
    +	"path/filepath"
    +)
    +
    +// CovData invokes "go tool covdata" with the specified arguments
    +// as part of the execution of action 'a'.
    +func (b *Builder) CovData(a *Action, cmdargs ...any) ([]byte, error) {
    +	cmdline := str.StringList(cmdargs...)
    +	args := append([]string{}, cfg.BuildToolexec...)
    +	args = append(args, filepath.Join(cfg.GOROOTbin, "go"), "tool", "covdata")
    +	args = append(args, cmdline...)
    +	return b.Shell(a).runOut(a.Objdir, nil, args)
    +}
    +
    +// BuildActionCoverMetaFile locates and returns the path of the
    +// meta-data file written by the "go tool cover" step as part of the
    +// build action for the "go test -cover" run action 'runAct'. Note
    +// that if the package has no functions the meta-data file will exist
    +// but will be empty; in this case the return is an empty string.
    +func BuildActionCoverMetaFile(runAct *Action) (string, error) {
    +	p := runAct.Package
    +	barrierAct := runAct.Deps[0]
    +	for i := range barrierAct.Deps {
    +		pred := barrierAct.Deps[i]
    +		if pred.Mode != "build" || pred.Package == nil {
    +			continue
    +		}
    +		if pred.Package.ImportPath == p.ImportPath {
    +			metaFile := pred.Objdir + covcmd.MetaFileForPackage(p.ImportPath)
    +			if cfg.BuildN {
    +				return metaFile, nil
    +			}
    +			f, err := os.Open(metaFile)
    +			if err != nil {
    +				return "", err
    +			}
    +			defer f.Close()
    +			fi, err2 := f.Stat()
    +			if err2 != nil {
    +				return "", err2
    +			}
    +			if fi.Size() == 0 {
    +				return "", nil
    +			}
    +			return metaFile, nil
    +		}
    +	}
    +	return "", fmt.Errorf("internal error: unable to locate build action for package %q run action", p.ImportPath)
    +}
    +
    +// WriteCoveragePercent writes out to the writer 'w' a "percent
    +// statements covered" for the package whose test-run action is
    +// 'runAct', based on the meta-data file 'mf'. This helper is used in
    +// cases where a user runs "go test -cover" on a package that has
    +// functions but no tests; in the normal case (package has tests)
    +// the percentage is written by the test binary when it runs.
    +func WriteCoveragePercent(b *Builder, runAct *Action, mf string, w io.Writer) error {
    +	dir := filepath.Dir(mf)
    +	output, cerr := b.CovData(runAct, "percent", "-i", dir)
    +	if cerr != nil {
    +		return b.Shell(runAct).reportCmd("", "", output, cerr)
    +	}
    +	_, werr := w.Write(output)
    +	return werr
    +}
    +
    +// WriteCoverageProfile writes out a coverage profile fragment for the
    +// package whose test-run action is 'runAct'; content is written to
    +// the file 'outf' based on the coverage meta-data info found in
    +// 'mf'. This helper is used in cases where a user runs "go test
    +// -cover" on a package that has functions but no tests.
    +func WriteCoverageProfile(b *Builder, runAct *Action, mf, outf string, w io.Writer) error {
    +	dir := filepath.Dir(mf)
    +	output, err := b.CovData(runAct, "textfmt", "-i", dir, "-o", outf)
    +	if err != nil {
    +		return b.Shell(runAct).reportCmd("", "", output, err)
    +	}
    +	_, werr := w.Write(output)
    +	return werr
    +}
    +
    +// WriteCoverMetaFilesFile writes out a summary file ("meta-files
    +// file") as part of the action function for the "writeCoverMeta"
    +// pseudo action employed during "go test -coverpkg" runs where there
    +// are multiple tests and multiple packages covered. It builds up a
    +// table mapping package import path to meta-data file fragment and
    +// writes it out to a file where it can be read by the various test
    +// run actions. Note that this function has to be called A) after the
    +// build actions are complete for all packages being tested, and B)
    +// before any of the "run test" actions for those packages happen.
    +// This requirement is enforced by adding making this action ("a")
    +// dependent on all test package build actions, and making all test
    +// run actions dependent on this action.
    +func WriteCoverMetaFilesFile(b *Builder, ctx context.Context, a *Action) error {
    +	sh := b.Shell(a)
    +
    +	// Build the metafilecollection object.
    +	var collection coverage.MetaFileCollection
    +	for i := range a.Deps {
    +		dep := a.Deps[i]
    +		if dep.Mode != "build" {
    +			panic("unexpected mode " + dep.Mode)
    +		}
    +		metaFilesFile := dep.Objdir + covcmd.MetaFileForPackage(dep.Package.ImportPath)
    +		// Check to make sure the meta-data file fragment exists
    +		//  and has content (may be empty if package has no functions).
    +		if fi, err := os.Stat(metaFilesFile); err != nil {
    +			continue
    +		} else if fi.Size() == 0 {
    +			continue
    +		}
    +		collection.ImportPaths = append(collection.ImportPaths, dep.Package.ImportPath)
    +		collection.MetaFileFragments = append(collection.MetaFileFragments, metaFilesFile)
    +	}
    +
    +	// Serialize it.
    +	data, err := json.Marshal(collection)
    +	if err != nil {
    +		return fmt.Errorf("marshal MetaFileCollection: %v", err)
    +	}
    +	data = append(data, '\n') // makes -x output more readable
    +
    +	// Create the directory for this action's objdir and
    +	// then write out the serialized collection
    +	// to a file in the directory.
    +	if err := sh.Mkdir(a.Objdir); err != nil {
    +		return err
    +	}
    +	mfpath := a.Objdir + coverage.MetaFilesFileName
    +	if err := sh.writeFile(mfpath, data); err != nil {
    +		return fmt.Errorf("writing metafiles file: %v", err)
    +	}
    +
    +	// We're done.
    +	return nil
    +}
    diff --git a/go/src/cmd/go/internal/work/exec.go b/go/src/cmd/go/internal/work/exec.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..01591c9c9bbceb78be6bf23b52483507682c89f0
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/exec.go
    @@ -0,0 +1,3687 @@
    +// Copyright 2011 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Action graph execution.
    +
    +package work
    +
    +import (
    +	"bytes"
    +	"cmd/internal/cov/covcmd"
    +	"cmd/internal/pathcache"
    +	"context"
    +	"crypto/sha256"
    +	"encoding/json"
    +	"errors"
    +	"fmt"
    +	"go/token"
    +	"internal/lazyregexp"
    +	"io"
    +	"io/fs"
    +	"log"
    +	"math/rand"
    +	"os"
    +	"os/exec"
    +	"path/filepath"
    +	"regexp"
    +	"runtime"
    +	"slices"
    +	"sort"
    +	"strconv"
    +	"strings"
    +	"sync"
    +	"time"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cache"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/fsys"
    +	"cmd/go/internal/gover"
    +	"cmd/go/internal/load"
    +	"cmd/go/internal/modload"
    +	"cmd/go/internal/str"
    +	"cmd/go/internal/trace"
    +	"cmd/internal/buildid"
    +	"cmd/internal/quoted"
    +	"cmd/internal/sys"
    +)
    +
    +const DefaultCFlags = "-O2 -g"
    +
    +// actionList returns the list of actions in the dag rooted at root
    +// as visited in a depth-first post-order traversal.
    +func actionList(root *Action) []*Action {
    +	seen := map[*Action]bool{}
    +	all := []*Action{}
    +	var walk func(*Action)
    +	walk = func(a *Action) {
    +		if seen[a] {
    +			return
    +		}
    +		seen[a] = true
    +		for _, a1 := range a.Deps {
    +			walk(a1)
    +		}
    +		all = append(all, a)
    +	}
    +	walk(root)
    +	return all
    +}
    +
    +// Do runs the action graph rooted at root.
    +func (b *Builder) Do(ctx context.Context, root *Action) {
    +	ctx, span := trace.StartSpan(ctx, "exec.Builder.Do ("+root.Mode+" "+root.Target+")")
    +	defer span.Done()
    +
    +	if !b.IsCmdList {
    +		// If we're doing real work, take time at the end to trim the cache.
    +		c := cache.Default()
    +		defer func() {
    +			if err := c.Close(); err != nil {
    +				base.Fatalf("go: failed to trim cache: %v", err)
    +			}
    +		}()
    +	}
    +
    +	// Build list of all actions, assigning depth-first post-order priority.
    +	// The original implementation here was a true queue
    +	// (using a channel) but it had the effect of getting
    +	// distracted by low-level leaf actions to the detriment
    +	// of completing higher-level actions. The order of
    +	// work does not matter much to overall execution time,
    +	// but when running "go test std" it is nice to see each test
    +	// results as soon as possible. The priorities assigned
    +	// ensure that, all else being equal, the execution prefers
    +	// to do what it would have done first in a simple depth-first
    +	// dependency order traversal.
    +	all := actionList(root)
    +	for i, a := range all {
    +		a.priority = i
    +	}
    +
    +	// Write action graph, without timing information, in case we fail and exit early.
    +	writeActionGraph := func() {
    +		if file := cfg.DebugActiongraph; file != "" {
    +			if strings.HasSuffix(file, ".go") {
    +				// Do not overwrite Go source code in:
    +				//	go build -debug-actiongraph x.go
    +				base.Fatalf("go: refusing to write action graph to %v\n", file)
    +			}
    +			js := actionGraphJSON(root)
    +			if err := os.WriteFile(file, []byte(js), 0666); err != nil {
    +				fmt.Fprintf(os.Stderr, "go: writing action graph: %v\n", err)
    +				base.SetExitStatus(1)
    +			}
    +		}
    +	}
    +	writeActionGraph()
    +
    +	b.readySema = make(chan bool, len(all))
    +
    +	// Initialize per-action execution state.
    +	for _, a := range all {
    +		for _, a1 := range a.Deps {
    +			a1.triggers = append(a1.triggers, a)
    +		}
    +		a.pending = len(a.Deps)
    +		if a.pending == 0 {
    +			b.ready.push(a)
    +			b.readySema <- true
    +		}
    +	}
    +
    +	// Handle runs a single action and takes care of triggering
    +	// any actions that are runnable as a result.
    +	handle := func(ctx context.Context, a *Action) {
    +		if a.json != nil {
    +			a.json.TimeStart = time.Now()
    +		}
    +		var err error
    +		if a.Actor != nil && (a.Failed == nil || a.IgnoreFail) {
    +			// TODO(matloob): Better action descriptions
    +			desc := "Executing action (" + a.Mode
    +			if a.Package != nil {
    +				desc += " " + a.Package.Desc()
    +			}
    +			desc += ")"
    +			ctx, span := trace.StartSpan(ctx, desc)
    +			a.traceSpan = span
    +			for _, d := range a.Deps {
    +				trace.Flow(ctx, d.traceSpan, a.traceSpan)
    +			}
    +			err = a.Actor.Act(b, ctx, a)
    +			span.Done()
    +		}
    +		if a.json != nil {
    +			a.json.TimeDone = time.Now()
    +		}
    +
    +		// The actions run in parallel but all the updates to the
    +		// shared work state are serialized through b.exec.
    +		b.exec.Lock()
    +		defer b.exec.Unlock()
    +
    +		if err != nil {
    +			if b.AllowErrors && a.Package != nil {
    +				if a.Package.Error == nil {
    +					a.Package.Error = &load.PackageError{Err: err}
    +					a.Package.Incomplete = true
    +				}
    +			} else {
    +				if a.Package != nil {
    +					if ipe, ok := errors.AsType[load.ImportPathError](err); !ok || ipe.ImportPath() != a.Package.ImportPath {
    +						err = fmt.Errorf("%s: %v", a.Package.ImportPath, err)
    +					}
    +				}
    +				sh := b.Shell(a)
    +				sh.Errorf("%s", err)
    +			}
    +			if a.Failed == nil {
    +				a.Failed = a
    +			}
    +		}
    +
    +		for _, a0 := range a.triggers {
    +			if a.Failed != nil {
    +				if a0.Mode == "test barrier" {
    +					// If this action was triggered by a test, there
    +					// will be a test barrier action in between the test
    +					// and the true trigger. But there will be other
    +					// triggers that are other barriers that are waiting
    +					// for this one. Propagate the failure to the true
    +					// trigger, but not to the other barriers.
    +					for _, bt := range a0.triggers {
    +						if bt.Mode != "test barrier" {
    +							bt.Failed = a.Failed
    +						}
    +					}
    +				} else {
    +					a0.Failed = a.Failed
    +				}
    +			}
    +			if a0.pending--; a0.pending == 0 {
    +				b.ready.push(a0)
    +				b.readySema <- true
    +			}
    +		}
    +
    +		if a == root {
    +			close(b.readySema)
    +		}
    +	}
    +
    +	var wg sync.WaitGroup
    +
    +	// Kick off goroutines according to parallelism.
    +	// If we are using the -n flag (just printing commands)
    +	// drop the parallelism to 1, both to make the output
    +	// deterministic and because there is no real work anyway.
    +	par := cfg.BuildP
    +	if cfg.BuildN {
    +		par = 1
    +	}
    +	for i := 0; i < par; i++ {
    +		wg.Add(1)
    +		go func() {
    +			ctx := trace.StartGoroutine(ctx)
    +			defer wg.Done()
    +			for {
    +				select {
    +				case _, ok := <-b.readySema:
    +					if !ok {
    +						return
    +					}
    +					// Receiving a value from b.readySema entitles
    +					// us to take from the ready queue.
    +					b.exec.Lock()
    +					a := b.ready.pop()
    +					b.exec.Unlock()
    +					handle(ctx, a)
    +				case <-base.Interrupted:
    +					base.SetExitStatus(1)
    +					return
    +				}
    +			}
    +		}()
    +	}
    +
    +	wg.Wait()
    +
    +	if tokens != totalTokens || concurrentProcesses != 0 {
    +		base.Fatalf("internal error: tokens not restored at end of build: tokens: %d, totalTokens: %d, concurrentProcesses: %d",
    +			tokens, totalTokens, concurrentProcesses)
    +	}
    +
    +	// Write action graph again, this time with timing information.
    +	writeActionGraph()
    +}
    +
    +// buildActionID computes the action ID for a build action.
    +func (b *Builder) buildActionID(a *Action) cache.ActionID {
    +	p := a.Package
    +	h := cache.NewHash("build " + p.ImportPath)
    +
    +	// Configuration independent of compiler toolchain.
    +	// Note: buildmode has already been accounted for in buildGcflags
    +	// and should not be inserted explicitly. Most buildmodes use the
    +	// same compiler settings and can reuse each other's results.
    +	// If not, the reason is already recorded in buildGcflags.
    +	fmt.Fprintf(h, "compile\n")
    +
    +	// Include information about the origin of the package that
    +	// may be embedded in the debug info for the object file.
    +	if cfg.BuildTrimpath {
    +		// When -trimpath is used with a package built from the module cache,
    +		// its debug information refers to the module path and version
    +		// instead of the directory.
    +		if p.Module != nil {
    +			fmt.Fprintf(h, "module %s@%s\n", p.Module.Path, p.Module.Version)
    +		}
    +	} else if p.Goroot {
    +		// The Go compiler always hides the exact value of $GOROOT
    +		// when building things in GOROOT.
    +		//
    +		// The C compiler does not, but for packages in GOROOT we rewrite the path
    +		// as though -trimpath were set. This used to be so that we did not invalidate
    +		// the build cache (and especially precompiled archive files) when changing
    +		// GOROOT_FINAL, but we no longer ship precompiled archive files as of Go 1.20
    +		// (https://go.dev/issue/47257) and no longer support GOROOT_FINAL
    +		// (https://go.dev/issue/62047).
    +		// TODO(bcmills): Figure out whether this behavior is still useful.
    +		//
    +		// b.WorkDir is always either trimmed or rewritten to
    +		// the literal string "/tmp/go-build".
    +	} else if !strings.HasPrefix(p.Dir, b.WorkDir) {
    +		// -trimpath is not set and no other rewrite rules apply,
    +		// so the object file may refer to the absolute directory
    +		// containing the package.
    +		fmt.Fprintf(h, "dir %s\n", p.Dir)
    +	}
    +
    +	if p.Module != nil {
    +		fmt.Fprintf(h, "go %s\n", p.Module.GoVersion)
    +	}
    +	fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch)
    +	fmt.Fprintf(h, "import %q\n", p.ImportPath)
    +	fmt.Fprintf(h, "omitdebug %v standard %v local %v prefix %q\n", p.Internal.OmitDebug, p.Standard, p.Internal.Local, p.Internal.LocalPrefix)
    +	if cfg.BuildTrimpath {
    +		fmt.Fprintln(h, "trimpath")
    +	}
    +	if p.Internal.ForceLibrary {
    +		fmt.Fprintf(h, "forcelibrary\n")
    +	}
    +	if len(p.CgoFiles)+len(p.SwigFiles)+len(p.SwigCXXFiles) > 0 {
    +		fmt.Fprintf(h, "cgo %q\n", b.toolID("cgo"))
    +		cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p)
    +
    +		ccExe := b.ccExe()
    +		fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
    +		// Include the C compiler tool ID so that if the C
    +		// compiler changes we rebuild the package.
    +		if ccID, _, err := b.gccToolID(ccExe[0], "c"); err == nil {
    +			fmt.Fprintf(h, "CC ID=%q\n", ccID)
    +		} else {
    +			fmt.Fprintf(h, "CC ID ERROR=%q\n", err)
    +		}
    +		if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
    +			cxxExe := b.cxxExe()
    +			fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags)
    +			if cxxID, _, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
    +				fmt.Fprintf(h, "CXX ID=%q\n", cxxID)
    +			} else {
    +				fmt.Fprintf(h, "CXX ID ERROR=%q\n", err)
    +			}
    +		}
    +		if len(p.FFiles) > 0 {
    +			fcExe := b.fcExe()
    +			fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags)
    +			if fcID, _, err := b.gccToolID(fcExe[0], "f95"); err == nil {
    +				fmt.Fprintf(h, "FC ID=%q\n", fcID)
    +			} else {
    +				fmt.Fprintf(h, "FC ID ERROR=%q\n", err)
    +			}
    +		}
    +		// TODO(rsc): Should we include the SWIG version?
    +	}
    +	if p.Internal.Cover.Mode != "" {
    +		fmt.Fprintf(h, "cover %q %q\n", p.Internal.Cover.Mode, b.toolID("cover"))
    +	}
    +	if p.Internal.FuzzInstrument {
    +		if fuzzFlags := fuzzInstrumentFlags(); fuzzFlags != nil {
    +			fmt.Fprintf(h, "fuzz %q\n", fuzzFlags)
    +		}
    +	}
    +	if p.Internal.BuildInfo != nil {
    +		fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo.String())
    +	}
    +
    +	// Configuration specific to compiler toolchain.
    +	switch cfg.BuildToolchainName {
    +	default:
    +		base.Fatalf("buildActionID: unknown build toolchain %q", cfg.BuildToolchainName)
    +	case "gc":
    +		fmt.Fprintf(h, "compile %s %q %q\n", b.toolID("compile"), forcedGcflags, p.Internal.Gcflags)
    +		if len(p.SFiles) > 0 {
    +			fmt.Fprintf(h, "asm %q %q %q\n", b.toolID("asm"), forcedAsmflags, p.Internal.Asmflags)
    +		}
    +
    +		// GOARM, GOMIPS, etc.
    +		key, val, _ := cfg.GetArchEnv()
    +		fmt.Fprintf(h, "%s=%s\n", key, val)
    +
    +		if cfg.CleanGOEXPERIMENT != "" {
    +			fmt.Fprintf(h, "GOEXPERIMENT=%q\n", cfg.CleanGOEXPERIMENT)
    +		}
    +
    +		// TODO(rsc): Convince compiler team not to add more magic environment variables,
    +		// or perhaps restrict the environment variables passed to subprocesses.
    +		// Because these are clumsy, undocumented special-case hacks
    +		// for debugging the compiler, they are not settable using 'go env -w',
    +		// and so here we use os.Getenv, not cfg.Getenv.
    +		magic := []string{
    +			"GOCLOBBERDEADHASH",
    +			"GOSSAFUNC",
    +			"GOSSADIR",
    +			"GOCOMPILEDEBUG",
    +		}
    +		for _, env := range magic {
    +			if x := os.Getenv(env); x != "" {
    +				fmt.Fprintf(h, "magic %s=%s\n", env, x)
    +			}
    +		}
    +
    +	case "gccgo":
    +		id, _, err := b.gccToolID(BuildToolchain.compiler(), "go")
    +		if err != nil {
    +			base.Fatalf("%v", err)
    +		}
    +		fmt.Fprintf(h, "compile %s %q %q\n", id, forcedGccgoflags, p.Internal.Gccgoflags)
    +		fmt.Fprintf(h, "pkgpath %s\n", gccgoPkgpath(p))
    +		fmt.Fprintf(h, "ar %q\n", BuildToolchain.(gccgoToolchain).ar())
    +		if len(p.SFiles) > 0 {
    +			id, _, _ = b.gccToolID(BuildToolchain.compiler(), "assembler-with-cpp")
    +			// Ignore error; different assembler versions
    +			// are unlikely to make any difference anyhow.
    +			fmt.Fprintf(h, "asm %q\n", id)
    +		}
    +	}
    +
    +	// Input files.
    +	inputFiles := str.StringList(
    +		p.GoFiles,
    +		p.CgoFiles,
    +		p.CFiles,
    +		p.CXXFiles,
    +		p.FFiles,
    +		p.MFiles,
    +		p.HFiles,
    +		p.SFiles,
    +		p.SysoFiles,
    +		p.SwigFiles,
    +		p.SwigCXXFiles,
    +		p.EmbedFiles,
    +	)
    +	for _, file := range inputFiles {
    +		fmt.Fprintf(h, "file %s %s\n", file, b.fileHash(filepath.Join(p.Dir, file)))
    +	}
    +	for _, a1 := range a.Deps {
    +		p1 := a1.Package
    +		if p1 != nil {
    +			fmt.Fprintf(h, "import %s %s\n", p1.ImportPath, contentID(a1.buildID))
    +		}
    +		if a1.Mode == "preprocess PGO profile" {
    +			fmt.Fprintf(h, "pgofile %s\n", b.fileHash(a1.built))
    +		}
    +	}
    +
    +	return h.Sum()
    +}
    +
    +// needCgoHdr reports whether the actions triggered by this one
    +// expect to be able to access the cgo-generated header file.
    +func (b *Builder) needCgoHdr(a *Action) bool {
    +	// If this build triggers a header install, run cgo to get the header.
    +	if !b.IsCmdList && (a.Package.UsesCgo() || a.Package.UsesSwig()) && (cfg.BuildBuildmode == "c-archive" || cfg.BuildBuildmode == "c-shared") {
    +		for _, t1 := range a.triggers {
    +			if t1.Mode == "install header" {
    +				return true
    +			}
    +		}
    +		for _, t1 := range a.triggers {
    +			for _, t2 := range t1.triggers {
    +				if t2.Mode == "install header" {
    +					return true
    +				}
    +			}
    +		}
    +	}
    +	return false
    +}
    +
    +// allowedVersion reports whether the version v is an allowed version of go
    +// (one that we can compile).
    +// v is known to be of the form "1.23".
    +func allowedVersion(v string) bool {
    +	// Special case: no requirement.
    +	if v == "" {
    +		return true
    +	}
    +	return gover.Compare(gover.Local(), v) >= 0
    +}
    +
    +func (b *Builder) computeNonGoOverlay(a *Action, p *load.Package, sh *Shell, objdir string, nonGoFileLists [][]string) error {
    +OverlayLoop:
    +	for _, fs := range nonGoFileLists {
    +		for _, f := range fs {
    +			if fsys.Replaced(mkAbs(p.Dir, f)) {
    +				a.nonGoOverlay = make(map[string]string)
    +				break OverlayLoop
    +			}
    +		}
    +	}
    +	if a.nonGoOverlay != nil {
    +		for _, fs := range nonGoFileLists {
    +			for i := range fs {
    +				from := mkAbs(p.Dir, fs[i])
    +				dst := objdir + filepath.Base(fs[i])
    +				if err := sh.CopyFile(dst, fsys.Actual(from), 0666, false); err != nil {
    +					return err
    +				}
    +				a.nonGoOverlay[from] = dst
    +			}
    +		}
    +	}
    +
    +	return nil
    +}
    +
    +// needsBuild reports whether the Action (which must be mode "build") needs
    +// to produce the built output.
    +func (b *Builder) needsBuild(a *Action) bool {
    +	return !b.IsCmdList && a.needBuild || b.NeedExport
    +}
    +
    +const (
    +	needBuild uint32 = 1 << iota
    +	needCgoHdr
    +	needVet
    +	needCompiledGoFiles
    +	needCovMetaFile
    +	needStale
    +)
    +
    +// checkCacheForBuild checks the cache for the outputs of the buildAction to determine
    +// what work needs to be done by it and the actions preceding it. a is the action
    +// currently being run, which has an actor of type *checkCacheActor and is a dependency
    +// of the buildAction.
    +func (b *Builder) checkCacheForBuild(a, buildAction *Action, covMetaFileName string) (_ *checkCacheProvider, err error) {
    +	p := buildAction.Package
    +	sh := b.Shell(a)
    +
    +	bit := func(x uint32, b bool) uint32 {
    +		if b {
    +			return x
    +		}
    +		return 0
    +	}
    +
    +	cachedBuild := false
    +	needCovMeta := p.Internal.Cover.GenMeta
    +	need := bit(needBuild, !b.IsCmdList && buildAction.needBuild || b.NeedExport) |
    +		bit(needCgoHdr, b.needCgoHdr(buildAction)) |
    +		bit(needVet, buildAction.needVet) |
    +		bit(needCovMetaFile, needCovMeta) |
    +		bit(needCompiledGoFiles, b.NeedCompiledGoFiles)
    +
    +	if !p.BinaryOnly {
    +		// We pass 'a' (this checkCacheAction) to buildActionID so that we use its dependencies,
    +		// which are the actual package dependencies, rather than the buildAction's dependencies
    +		// which also includes this action and the cover action.
    +		if b.useCache(buildAction, b.buildActionID(a), p.Target, need&needBuild != 0) {
    +			// We found the main output in the cache.
    +			// If we don't need any other outputs, we can stop.
    +			// Otherwise, we need to write files to a.Objdir (needVet, needCgoHdr).
    +			// Remember that we might have them in cache
    +			// and check again after we create a.Objdir.
    +			cachedBuild = true
    +			buildAction.output = []byte{} // start saving output in case we miss any cache results
    +			need &^= needBuild
    +			if b.NeedExport {
    +				p.Export = buildAction.built
    +				p.BuildID = buildAction.buildID
    +			}
    +			if need&needCompiledGoFiles != 0 {
    +				if err := b.loadCachedCompiledGoFiles(buildAction); err == nil {
    +					need &^= needCompiledGoFiles
    +				}
    +			}
    +		}
    +
    +		// Source files might be cached, even if the full action is not
    +		// (e.g., go list -compiled -find).
    +		if !cachedBuild && need&needCompiledGoFiles != 0 {
    +			if err := b.loadCachedCompiledGoFiles(buildAction); err == nil {
    +				need &^= needCompiledGoFiles
    +			}
    +		}
    +
    +		if need == 0 {
    +			return &checkCacheProvider{need: need}, nil
    +		}
    +		defer b.flushOutput(a)
    +	}
    +
    +	defer func() {
    +		if err != nil && b.IsCmdList && b.NeedError && p.Error == nil {
    +			p.Error = &load.PackageError{Err: err}
    +		}
    +	}()
    +
    +	if p.Error != nil {
    +		// Don't try to build anything for packages with errors. There may be a
    +		// problem with the inputs that makes the package unsafe to build.
    +		return nil, p.Error
    +	}
    +
    +	// TODO(matloob): return early for binary-only packages so that we don't need to indent
    +	// the core of this function in the if !p.BinaryOnly block above.
    +	if p.BinaryOnly {
    +		p.Stale = true
    +		p.StaleReason = "binary-only packages are no longer supported"
    +		if b.IsCmdList {
    +			return &checkCacheProvider{need: 0}, nil
    +		}
    +		return nil, errors.New("binary-only packages are no longer supported")
    +	}
    +
    +	if p.Module != nil && !allowedVersion(p.Module.GoVersion) {
    +		return nil, errors.New("module requires Go " + p.Module.GoVersion + " or later")
    +	}
    +
    +	if err := b.checkDirectives(buildAction); err != nil {
    +		return nil, err
    +	}
    +
    +	if err := sh.Mkdir(buildAction.Objdir); err != nil {
    +		return nil, err
    +	}
    +
    +	// Load cached cgo header, but only if we're skipping the main build (cachedBuild==true).
    +	if cachedBuild && need&needCgoHdr != 0 {
    +		if err := b.loadCachedCgoHdr(buildAction); err == nil {
    +			need &^= needCgoHdr
    +		}
    +	}
    +
    +	// Load cached coverage meta-data file fragment, but only if we're
    +	// skipping the main build (cachedBuild==true).
    +	if cachedBuild && need&needCovMetaFile != 0 {
    +		if err := b.loadCachedObjdirFile(buildAction, cache.Default(), covMetaFileName); err == nil {
    +			need &^= needCovMetaFile
    +		}
    +	}
    +
    +	// Load cached vet config, but only if that's all we have left
    +	// (need == needVet, not testing just the one bit).
    +	// If we are going to do a full build anyway,
    +	// we're going to regenerate the files in the build action anyway.
    +	if need == needVet {
    +		if err := b.loadCachedVet(buildAction, a.Deps); err == nil {
    +			need &^= needVet
    +		}
    +	}
    +
    +	return &checkCacheProvider{need: need}, nil
    +}
    +
    +func (b *Builder) runCover(a, buildAction *Action, objdir string, gofiles, cgofiles []string) (*coverProvider, error) {
    +	p := a.Package
    +	sh := b.Shell(a)
    +
    +	var cacheProvider *checkCacheProvider
    +	for _, dep := range a.Deps {
    +		if pr, ok := dep.Provider.(*checkCacheProvider); ok {
    +			cacheProvider = pr
    +		}
    +	}
    +	if cacheProvider == nil {
    +		base.Fatalf("internal error: could not find checkCacheProvider")
    +	}
    +	need := cacheProvider.need
    +
    +	if need == 0 {
    +		return nil, nil
    +	}
    +
    +	if err := sh.Mkdir(a.Objdir); err != nil {
    +		return nil, err
    +	}
    +
    +	gofiles = slices.Clone(gofiles)
    +	cgofiles = slices.Clone(cgofiles)
    +
    +	outfiles := []string{}
    +	infiles := []string{}
    +	for i, file := range str.StringList(gofiles, cgofiles) {
    +		if base.IsTestFile(file) {
    +			continue // Not covering this file.
    +		}
    +
    +		var sourceFile string
    +		var coverFile string
    +		if base, found := strings.CutSuffix(file, ".cgo1.go"); found {
    +			// cgo files have absolute paths
    +			base = filepath.Base(base)
    +			sourceFile = file
    +			coverFile = objdir + base + ".cgo1.go"
    +		} else {
    +			sourceFile = filepath.Join(p.Dir, file)
    +			coverFile = objdir + file
    +		}
    +		coverFile = strings.TrimSuffix(coverFile, ".go") + ".cover.go"
    +		infiles = append(infiles, sourceFile)
    +		outfiles = append(outfiles, coverFile)
    +		if i < len(gofiles) {
    +			gofiles[i] = coverFile
    +		} else {
    +			cgofiles[i-len(gofiles)] = coverFile
    +		}
    +	}
    +
    +	if len(infiles) != 0 {
    +		// Coverage instrumentation creates new top level
    +		// variables in the target package for things like
    +		// meta-data containers, counter vars, etc. To avoid
    +		// collisions with user variables, suffix the var name
    +		// with 12 hex digits from the SHA-256 hash of the
    +		// import path. Choice of 12 digits is historical/arbitrary,
    +		// we just need enough of the hash to avoid accidents,
    +		// as opposed to precluding determined attempts by
    +		// users to break things.
    +		sum := sha256.Sum256([]byte(a.Package.ImportPath))
    +		coverVar := fmt.Sprintf("goCover_%x_", sum[:6])
    +		mode := a.Package.Internal.Cover.Mode
    +		if mode == "" {
    +			panic("covermode should be set at this point")
    +		}
    +		if newoutfiles, err := b.cover(a, infiles, outfiles, coverVar, mode); err != nil {
    +			return nil, err
    +		} else {
    +			outfiles = newoutfiles
    +			gofiles = append([]string{newoutfiles[0]}, gofiles...)
    +		}
    +		if ca, ok := a.Actor.(*coverActor); ok && ca.covMetaFileName != "" {
    +			b.cacheObjdirFile(buildAction, cache.Default(), ca.covMetaFileName)
    +		}
    +	}
    +	return &coverProvider{gofiles, cgofiles}, nil
    +}
    +
    +// build is the action for building a single package.
    +// Note that any new influence on this logic must be reported in b.buildActionID above as well.
    +func (b *Builder) build(ctx context.Context, a *Action) (err error) {
    +	p := a.Package
    +	sh := b.Shell(a)
    +
    +	var cacheProvider *checkCacheProvider
    +	var coverPr *coverProvider
    +	var runCgoPr *runCgoProvider
    +	for _, dep := range a.Deps {
    +		switch pr := dep.Provider.(type) {
    +		case *coverProvider:
    +			coverPr = pr
    +		case *checkCacheProvider:
    +			cacheProvider = pr
    +		case *runCgoProvider:
    +			runCgoPr = pr
    +		}
    +	}
    +	if cacheProvider == nil {
    +		base.Fatalf("internal error: could not find checkCacheProvider")
    +	}
    +
    +	need := cacheProvider.need
    +	need &^= needCovMetaFile // handled by cover action
    +	need &^= needCgoHdr      // handled by run cgo action // TODO: accumulate "negative" need bits from actions
    +
    +	if need == 0 {
    +		return
    +	}
    +	defer b.flushOutput(a)
    +
    +	if cfg.BuildN {
    +		// In -n mode, print a banner between packages.
    +		// The banner is five lines so that when changes to
    +		// different sections of the bootstrap script have to
    +		// be merged, the banners give patch something
    +		// to use to find its context.
    +		sh.Printf("\n#\n# %s\n#\n\n", p.ImportPath)
    +	}
    +
    +	if cfg.BuildV {
    +		sh.Printf("%s\n", p.ImportPath)
    +	}
    +
    +	objdir := a.Objdir
    +
    +	if err := AllowInstall(a); err != nil {
    +		return err
    +	}
    +
    +	// make target directory
    +	dir, _ := filepath.Split(a.Target)
    +	if dir != "" {
    +		if err := sh.Mkdir(dir); err != nil {
    +			return err
    +		}
    +	}
    +
    +	gofiles := str.StringList(p.GoFiles)
    +	cfiles := str.StringList(p.CFiles)
    +	sfiles := str.StringList(p.SFiles)
    +	var objects, cgoObjects []string
    +
    +	// If we're doing coverage, preprocess the .go files and put them in the work directory
    +	if p.Internal.Cover.Mode != "" {
    +		gofiles = coverPr.goSources
    +	}
    +
    +	if p.UsesCgo() || p.UsesSwig() {
    +		if runCgoPr == nil {
    +			base.Fatalf("internal error: could not find runCgoProvider")
    +		}
    +
    +		// In a package using cgo, cgo compiles the C, C++ and assembly files with gcc.
    +		// There is one exception: runtime/cgo's job is to bridge the
    +		// cgo and non-cgo worlds, so it necessarily has files in both.
    +		// In that case gcc only gets the gcc_* files.
    +		cfiles = nil
    +		if p.Standard && p.ImportPath == "runtime/cgo" {
    +			// filter to the non-gcc files.
    +			i := 0
    +			for _, f := range sfiles {
    +				if !strings.HasPrefix(f, "gcc_") {
    +					sfiles[i] = f
    +					i++
    +				}
    +			}
    +			sfiles = sfiles[:i]
    +		} else {
    +			sfiles = nil
    +		}
    +
    +		outGo, outObj, err := b.processCgoOutputs(a, runCgoPr, base.Tool("cgo"), objdir)
    +
    +		if err != nil {
    +			return err
    +		}
    +		if cfg.BuildToolchainName == "gccgo" {
    +			cgoObjects = append(cgoObjects, a.Objdir+"_cgo_flags")
    +		}
    +		cgoObjects = append(cgoObjects, outObj...)
    +		gofiles = append(gofiles, outGo...)
    +
    +		switch cfg.BuildBuildmode {
    +		case "c-archive", "c-shared":
    +			b.cacheCgoHdr(a)
    +		}
    +	}
    +
    +	var srcfiles []string // .go and non-.go
    +	srcfiles = append(srcfiles, gofiles...)
    +	srcfiles = append(srcfiles, sfiles...)
    +	srcfiles = append(srcfiles, cfiles...)
    +	b.cacheSrcFiles(a, srcfiles)
    +
    +	// Sanity check only, since Package.load already checked as well.
    +	if len(gofiles) == 0 {
    +		return &load.NoGoError{Package: p}
    +	}
    +
    +	// Prepare Go vet config if needed.
    +	if need&needVet != 0 {
    +		buildVetConfig(a, srcfiles, a.Deps)
    +		need &^= needVet
    +	}
    +	if need&needCompiledGoFiles != 0 {
    +		if err := b.loadCachedCompiledGoFiles(a); err != nil {
    +			return fmt.Errorf("loading compiled Go files from cache: %w", err)
    +		}
    +		need &^= needCompiledGoFiles
    +	}
    +	if need == 0 {
    +		// Nothing left to do.
    +		return nil
    +	}
    +
    +	// Collect symbol ABI requirements from assembly.
    +	symabis, err := BuildToolchain.symabis(b, a, sfiles)
    +	if err != nil {
    +		return err
    +	}
    +
    +	// Prepare Go import config.
    +	// We start it off with a comment so it can't be empty, so icfg.Bytes() below is never nil.
    +	// It should never be empty anyway, but there have been bugs in the past that resulted
    +	// in empty configs, which then unfortunately turn into "no config passed to compiler",
    +	// and the compiler falls back to looking in pkg itself, which mostly works,
    +	// except when it doesn't.
    +	var icfg bytes.Buffer
    +	fmt.Fprintf(&icfg, "# import config\n")
    +	for i, raw := range p.Internal.RawImports {
    +		final := p.Imports[i]
    +		if final != raw {
    +			fmt.Fprintf(&icfg, "importmap %s=%s\n", raw, final)
    +		}
    +	}
    +	for _, a1 := range a.Deps {
    +		p1 := a1.Package
    +		if p1 == nil || p1.ImportPath == "" || a1.built == "" {
    +			continue
    +		}
    +		fmt.Fprintf(&icfg, "packagefile %s=%s\n", p1.ImportPath, a1.built)
    +	}
    +
    +	// Prepare Go embed config if needed.
    +	// Unlike the import config, it's okay for the embed config to be empty.
    +	var embedcfg []byte
    +	if len(p.Internal.Embed) > 0 {
    +		var embed struct {
    +			Patterns map[string][]string
    +			Files    map[string]string
    +		}
    +		embed.Patterns = p.Internal.Embed
    +		embed.Files = make(map[string]string)
    +		for _, file := range p.EmbedFiles {
    +			embed.Files[file] = fsys.Actual(filepath.Join(p.Dir, file))
    +		}
    +		js, err := json.MarshalIndent(&embed, "", "\t")
    +		if err != nil {
    +			return fmt.Errorf("marshal embedcfg: %v", err)
    +		}
    +		embedcfg = js
    +	}
    +
    +	// Find PGO profile if needed.
    +	var pgoProfile string
    +	for _, a1 := range a.Deps {
    +		if a1.Mode != "preprocess PGO profile" {
    +			continue
    +		}
    +		if pgoProfile != "" {
    +			return fmt.Errorf("action contains multiple PGO profile dependencies")
    +		}
    +		pgoProfile = a1.built
    +	}
    +
    +	if p.Internal.BuildInfo != nil && cfg.ModulesEnabled {
    +		prog := modload.ModInfoProg(p.Internal.BuildInfo.String(), cfg.BuildToolchainName == "gccgo")
    +		if len(prog) > 0 {
    +			if err := sh.writeFile(objdir+"_gomod_.go", prog); err != nil {
    +				return err
    +			}
    +			gofiles = append(gofiles, objdir+"_gomod_.go")
    +		}
    +	}
    +
    +	// Compile Go.
    +	objpkg := objdir + "_pkg_.a"
    +	ofile, out, err := BuildToolchain.gc(b, a, objpkg, icfg.Bytes(), embedcfg, symabis, len(sfiles) > 0, pgoProfile, gofiles)
    +	if err := sh.reportCmd("", "", out, err); err != nil {
    +		return err
    +	}
    +	if ofile != objpkg {
    +		objects = append(objects, ofile)
    +	}
    +
    +	// Copy .h files named for goos or goarch or goos_goarch
    +	// to names using GOOS and GOARCH.
    +	// For example, defs_linux_amd64.h becomes defs_GOOS_GOARCH.h.
    +	_goos_goarch := "_" + cfg.Goos + "_" + cfg.Goarch
    +	_goos := "_" + cfg.Goos
    +	_goarch := "_" + cfg.Goarch
    +	for _, file := range p.HFiles {
    +		name, ext := fileExtSplit(file)
    +		switch {
    +		case strings.HasSuffix(name, _goos_goarch):
    +			targ := file[:len(name)-len(_goos_goarch)] + "_GOOS_GOARCH." + ext
    +			if err := sh.CopyFile(objdir+targ, filepath.Join(p.Dir, file), 0666, true); err != nil {
    +				return err
    +			}
    +		case strings.HasSuffix(name, _goarch):
    +			targ := file[:len(name)-len(_goarch)] + "_GOARCH." + ext
    +			if err := sh.CopyFile(objdir+targ, filepath.Join(p.Dir, file), 0666, true); err != nil {
    +				return err
    +			}
    +		case strings.HasSuffix(name, _goos):
    +			targ := file[:len(name)-len(_goos)] + "_GOOS." + ext
    +			if err := sh.CopyFile(objdir+targ, filepath.Join(p.Dir, file), 0666, true); err != nil {
    +				return err
    +			}
    +		}
    +	}
    +
    +	if err := b.computeNonGoOverlay(a, p, sh, objdir, [][]string{cfiles}); err != nil {
    +		return err
    +	}
    +
    +	// Compile C files in a package being built with gccgo. We disallow
    +	// C files when compiling with gc unless swig or cgo is used.
    +	for _, file := range cfiles {
    +		out := file[:len(file)-len(".c")] + ".o"
    +		if err := BuildToolchain.cc(b, a, objdir+out, file); err != nil {
    +			return err
    +		}
    +		objects = append(objects, out)
    +	}
    +
    +	// Assemble .s files.
    +	if len(sfiles) > 0 {
    +		ofiles, err := BuildToolchain.asm(b, a, sfiles)
    +		if err != nil {
    +			return err
    +		}
    +		objects = append(objects, ofiles...)
    +	}
    +
    +	// For gccgo on ELF systems, we write the build ID as an assembler file.
    +	// This lets us set the SHF_EXCLUDE flag.
    +	// This is read by readGccgoArchive in cmd/internal/buildid/buildid.go.
    +	if a.buildID != "" && cfg.BuildToolchainName == "gccgo" {
    +		switch cfg.Goos {
    +		case "aix", "android", "dragonfly", "freebsd", "illumos", "linux", "netbsd", "openbsd", "solaris":
    +			asmfile, err := b.gccgoBuildIDFile(a)
    +			if err != nil {
    +				return err
    +			}
    +			ofiles, err := BuildToolchain.asm(b, a, []string{asmfile})
    +			if err != nil {
    +				return err
    +			}
    +			objects = append(objects, ofiles...)
    +		}
    +	}
    +
    +	// NOTE(rsc): On Windows, it is critically important that the
    +	// gcc-compiled objects (cgoObjects) be listed after the ordinary
    +	// objects in the archive. I do not know why this is.
    +	// https://golang.org/issue/2601
    +	objects = append(objects, cgoObjects...)
    +
    +	// Add system object files.
    +	for _, syso := range p.SysoFiles {
    +		objects = append(objects, filepath.Join(p.Dir, syso))
    +	}
    +
    +	// Pack into archive in objdir directory.
    +	// If the Go compiler wrote an archive, we only need to add the
    +	// object files for non-Go sources to the archive.
    +	// If the Go compiler wrote an archive and the package is entirely
    +	// Go sources, there is no pack to execute at all.
    +	if len(objects) > 0 {
    +		if err := BuildToolchain.pack(b, a, objpkg, objects); err != nil {
    +			return err
    +		}
    +	}
    +
    +	if err := b.updateBuildID(a, objpkg); err != nil {
    +		return err
    +	}
    +
    +	a.built = objpkg
    +	return nil
    +}
    +
    +func (b *Builder) checkDirectives(a *Action) error {
    +	var msg []byte
    +	p := a.Package
    +	var seen map[string]token.Position
    +	for _, d := range p.Internal.Build.Directives {
    +		if strings.HasPrefix(d.Text, "//go:debug") {
    +			key, _, err := load.ParseGoDebug(d.Text)
    +			if err != nil && err != load.ErrNotGoDebug {
    +				msg = fmt.Appendf(msg, "%s: invalid //go:debug: %v\n", d.Pos, err)
    +				continue
    +			}
    +			if pos, ok := seen[key]; ok {
    +				msg = fmt.Appendf(msg, "%s: repeated //go:debug for %v\n\t%s: previous //go:debug\n", d.Pos, key, pos)
    +				continue
    +			}
    +			if seen == nil {
    +				seen = make(map[string]token.Position)
    +			}
    +			seen[key] = d.Pos
    +		}
    +	}
    +	if len(msg) > 0 {
    +		// We pass a non-nil error to reportCmd to trigger the failure reporting
    +		// path, but the content of the error doesn't matter because msg is
    +		// non-empty.
    +		err := errors.New("invalid directive")
    +		return b.Shell(a).reportCmd("", "", msg, err)
    +	}
    +	return nil
    +}
    +
    +func (b *Builder) cacheObjdirFile(a *Action, c cache.Cache, name string) error {
    +	f, err := os.Open(a.Objdir + name)
    +	if err != nil {
    +		return err
    +	}
    +	defer f.Close()
    +	_, _, err = c.Put(cache.Subkey(a.actionID, name), f)
    +	return err
    +}
    +
    +func (b *Builder) findCachedObjdirFile(a *Action, c cache.Cache, name string) (string, error) {
    +	file, _, err := cache.GetFile(c, cache.Subkey(a.actionID, name))
    +	if err != nil {
    +		return "", fmt.Errorf("loading cached file %s: %w", name, err)
    +	}
    +	return file, nil
    +}
    +
    +func (b *Builder) loadCachedObjdirFile(a *Action, c cache.Cache, name string) error {
    +	cached, err := b.findCachedObjdirFile(a, c, name)
    +	if err != nil {
    +		return err
    +	}
    +	return b.Shell(a).CopyFile(a.Objdir+name, cached, 0666, true)
    +}
    +
    +func (b *Builder) cacheCgoHdr(a *Action) {
    +	c := cache.Default()
    +	b.cacheObjdirFile(a, c, "_cgo_install.h")
    +}
    +
    +func (b *Builder) loadCachedCgoHdr(a *Action) error {
    +	c := cache.Default()
    +	return b.loadCachedObjdirFile(a, c, "_cgo_install.h")
    +}
    +
    +func (b *Builder) cacheSrcFiles(a *Action, srcfiles []string) {
    +	c := cache.Default()
    +	var buf bytes.Buffer
    +	for _, file := range srcfiles {
    +		if !strings.HasPrefix(file, a.Objdir) {
    +			// not generated
    +			buf.WriteString("./")
    +			buf.WriteString(file)
    +			buf.WriteString("\n")
    +			continue
    +		}
    +		name := file[len(a.Objdir):]
    +		buf.WriteString(name)
    +		buf.WriteString("\n")
    +		if err := b.cacheObjdirFile(a, c, name); err != nil {
    +			return
    +		}
    +	}
    +	cache.PutBytes(c, cache.Subkey(a.actionID, "srcfiles"), buf.Bytes())
    +}
    +
    +func (b *Builder) loadCachedVet(a *Action, vetDeps []*Action) error {
    +	c := cache.Default()
    +	list, _, err := cache.GetBytes(c, cache.Subkey(a.actionID, "srcfiles"))
    +	if err != nil {
    +		return fmt.Errorf("reading srcfiles list: %w", err)
    +	}
    +	var srcfiles []string
    +	for name := range strings.SplitSeq(string(list), "\n") {
    +		if name == "" { // end of list
    +			continue
    +		}
    +		if strings.HasPrefix(name, "./") {
    +			srcfiles = append(srcfiles, name[2:])
    +			continue
    +		}
    +		if err := b.loadCachedObjdirFile(a, c, name); err != nil {
    +			return err
    +		}
    +		srcfiles = append(srcfiles, a.Objdir+name)
    +	}
    +	buildVetConfig(a, srcfiles, vetDeps)
    +	return nil
    +}
    +
    +func (b *Builder) loadCachedCompiledGoFiles(a *Action) error {
    +	c := cache.Default()
    +	list, _, err := cache.GetBytes(c, cache.Subkey(a.actionID, "srcfiles"))
    +	if err != nil {
    +		return fmt.Errorf("reading srcfiles list: %w", err)
    +	}
    +	var gofiles []string
    +	for name := range strings.SplitSeq(string(list), "\n") {
    +		if name == "" { // end of list
    +			continue
    +		} else if !strings.HasSuffix(name, ".go") {
    +			continue
    +		}
    +		if strings.HasPrefix(name, "./") {
    +			gofiles = append(gofiles, name[len("./"):])
    +			continue
    +		}
    +		file, err := b.findCachedObjdirFile(a, c, name)
    +		if err != nil {
    +			return fmt.Errorf("finding %s: %w", name, err)
    +		}
    +		gofiles = append(gofiles, file)
    +	}
    +	a.Package.CompiledGoFiles = gofiles
    +	return nil
    +}
    +
    +// vetConfig is the configuration passed to vet describing a single package.
    +type vetConfig struct {
    +	ID           string   // package ID (example: "fmt [fmt.test]")
    +	Compiler     string   // compiler name (gc, gccgo)
    +	Dir          string   // directory containing package
    +	ImportPath   string   // canonical import path ("package path")
    +	GoFiles      []string // absolute paths to package source files
    +	NonGoFiles   []string // absolute paths to package non-Go files
    +	IgnoredFiles []string // absolute paths to ignored source files
    +
    +	ModulePath    string            // module path (may be "" on module error)
    +	ModuleVersion string            // module version (may be "" on main module or module error)
    +	ImportMap     map[string]string // map import path in source code to package path
    +	PackageFile   map[string]string // map package path to .a file with export data
    +	Standard      map[string]bool   // map package path to whether it's in the standard library
    +	PackageVetx   map[string]string // map package path to vetx data from earlier vet run
    +	VetxOnly      bool              // only compute vetx data; don't report detected problems
    +	VetxOutput    string            // write vetx data to this output file
    +	Stdout        string            // write stdout (JSON, unified diff) to this output file
    +	GoVersion     string            // Go version for package
    +	FixArchive    string            // write fixed files to this zip archive, if non-empty
    +
    +	SucceedOnTypecheckFailure bool // awful hack; see #18395 and below
    +}
    +
    +func buildVetConfig(a *Action, srcfiles []string, vetDeps []*Action) {
    +	// Classify files based on .go extension.
    +	// srcfiles does not include raw cgo files.
    +	var gofiles, nongofiles []string
    +	for _, name := range srcfiles {
    +		if strings.HasSuffix(name, ".go") {
    +			gofiles = append(gofiles, name)
    +		} else {
    +			nongofiles = append(nongofiles, name)
    +		}
    +	}
    +
    +	ignored := str.StringList(a.Package.IgnoredGoFiles, a.Package.IgnoredOtherFiles)
    +
    +	// Pass list of absolute paths to vet,
    +	// so that vet's error messages will use absolute paths,
    +	// so that we can reformat them relative to the directory
    +	// in which the go command is invoked.
    +	vcfg := &vetConfig{
    +		ID:           a.Package.ImportPath,
    +		Compiler:     cfg.BuildToolchainName,
    +		Dir:          a.Package.Dir,
    +		GoFiles:      actualFiles(mkAbsFiles(a.Package.Dir, gofiles)),
    +		NonGoFiles:   actualFiles(mkAbsFiles(a.Package.Dir, nongofiles)),
    +		IgnoredFiles: actualFiles(mkAbsFiles(a.Package.Dir, ignored)),
    +		ImportPath:   a.Package.ImportPath,
    +		ImportMap:    make(map[string]string),
    +		PackageFile:  make(map[string]string),
    +		Standard:     make(map[string]bool),
    +	}
    +	vcfg.GoVersion = "go" + gover.Local()
    +	if a.Package.Module != nil {
    +		v := a.Package.Module.GoVersion
    +		if v == "" {
    +			v = gover.DefaultGoModVersion
    +		}
    +		vcfg.GoVersion = "go" + v
    +
    +		if a.Package.Module.Error == nil {
    +			vcfg.ModulePath = a.Package.Module.Path
    +			vcfg.ModuleVersion = a.Package.Module.Version
    +		}
    +	}
    +	a.vetCfg = vcfg
    +	for i, raw := range a.Package.Internal.RawImports {
    +		final := a.Package.Imports[i]
    +		vcfg.ImportMap[raw] = final
    +	}
    +
    +	// Compute the list of mapped imports in the vet config
    +	// so that we can add any missing mappings below.
    +	vcfgMapped := make(map[string]bool)
    +	for _, p := range vcfg.ImportMap {
    +		vcfgMapped[p] = true
    +	}
    +
    +	for _, a1 := range vetDeps {
    +		p1 := a1.Package
    +		if p1 == nil || p1.ImportPath == "" || p1 == a.Package {
    +			continue
    +		}
    +		// Add import mapping if needed
    +		// (for imports like "runtime/cgo" that appear only in generated code).
    +		if !vcfgMapped[p1.ImportPath] {
    +			vcfg.ImportMap[p1.ImportPath] = p1.ImportPath
    +		}
    +		if a1.built != "" {
    +			vcfg.PackageFile[p1.ImportPath] = a1.built
    +		}
    +		if p1.Standard {
    +			vcfg.Standard[p1.ImportPath] = true
    +		}
    +	}
    +}
    +
    +// VetTool is the path to the effective vet or fix tool binary.
    +// The user may specify a non-default value using -{vet,fix}tool.
    +// The caller is expected to set it (if needed) before executing any vet actions.
    +var VetTool string
    +
    +// VetFlags are the default flags to pass to vet.
    +// The caller is expected to set them before executing any vet actions.
    +var VetFlags []string
    +
    +// VetHandleStdout determines how the stdout output of each vet tool
    +// invocation should be handled. The default behavior is to copy it to
    +// the go command's stdout, atomically.
    +var VetHandleStdout = copyToStdout
    +
    +// VetExplicit records whether the vet flags (which may include
    +// -{vet,fix}tool) were set explicitly on the command line.
    +var VetExplicit bool
    +
    +func (b *Builder) vet(ctx context.Context, a *Action) error {
    +	// a.Deps[0] is the build of the package being vetted.
    +
    +	a.Failed = nil // vet of dependency may have failed but we can still succeed
    +
    +	if a.Deps[0].Failed != nil {
    +		// The build of the package has failed. Skip vet check.
    +		// Vet could return export data for non-typecheck errors,
    +		// but we ignore it because the package cannot be compiled.
    +		return nil
    +	}
    +
    +	vcfg := a.Deps[0].vetCfg
    +	if vcfg == nil {
    +		// Vet config should only be missing if the build failed.
    +		return fmt.Errorf("vet config not found")
    +	}
    +
    +	sh := b.Shell(a)
    +
    +	// We use "vet" terminology even when building action graphs for go fix.
    +	vcfg.VetxOnly = a.VetxOnly
    +	vcfg.VetxOutput = a.Objdir + "vet.out"
    +	vcfg.Stdout = a.Objdir + "vet.stdout"
    +	if a.needFix {
    +		vcfg.FixArchive = a.Objdir + "vet.fix.zip"
    +	}
    +	vcfg.PackageVetx = make(map[string]string)
    +
    +	h := cache.NewHash("vet " + a.Package.ImportPath)
    +	fmt.Fprintf(h, "vet %q\n", b.toolID("vet"))
    +
    +	vetFlags := VetFlags
    +
    +	// In GOROOT, we enable all the vet tests during 'go test',
    +	// not just the high-confidence subset. This gets us extra
    +	// checking for the standard library (at some compliance cost)
    +	// and helps us gain experience about how well the checks
    +	// work, to help decide which should be turned on by default.
    +	// The command-line still wins.
    +	//
    +	// Note that this flag change applies even when running vet as
    +	// a dependency of vetting a package outside std.
    +	// (Otherwise we'd have to introduce a whole separate
    +	// space of "vet fmt as a dependency of a std top-level vet"
    +	// versus "vet fmt as a dependency of a non-std top-level vet".)
    +	// This is OK as long as the packages that are farther down the
    +	// dependency tree turn on *more* analysis, as here.
    +	// (The unsafeptr check does not write any facts for use by
    +	// later vet runs, nor does unreachable.)
    +	if a.Package.Goroot && !VetExplicit && VetTool == base.Tool("vet") {
    +		// Turn off -unsafeptr checks.
    +		// There's too much unsafe.Pointer code
    +		// that vet doesn't like in low-level packages
    +		// like runtime, sync, and reflect.
    +		// Note that $GOROOT/src/buildall.bash
    +		// does the same
    +		// and should be updated if these flags are
    +		// changed here.
    +		vetFlags = []string{"-unsafeptr=false"}
    +
    +		// Also turn off -unreachable checks during go test.
    +		// During testing it is very common to make changes
    +		// like hard-coded forced returns or panics that make
    +		// code unreachable. It's unreasonable to insist on files
    +		// not having any unreachable code during "go test".
    +		// (buildall.bash still has -unreachable enabled
    +		// for the overall whole-tree scan.)
    +		if cfg.CmdName == "test" {
    +			vetFlags = append(vetFlags, "-unreachable=false")
    +		}
    +	}
    +
    +	// Note: We could decide that vet should compute export data for
    +	// all analyses, in which case we don't need to include the flags here.
    +	// But that would mean that if an analysis causes problems like
    +	// unexpected crashes there would be no way to turn it off.
    +	// It seems better to let the flags disable export analysis too.
    +	fmt.Fprintf(h, "vetflags %q\n", vetFlags)
    +
    +	fmt.Fprintf(h, "pkg %q\n", a.Deps[0].actionID)
    +	for _, a1 := range a.Deps {
    +		if a1.Mode == "vet" && a1.built != "" {
    +			fmt.Fprintf(h, "vetout %q %s\n", a1.Package.ImportPath, b.fileHash(a1.built))
    +			vcfg.PackageVetx[a1.Package.ImportPath] = a1.built
    +		}
    +	}
    +	var (
    +		id            = cache.ActionID(h.Sum())     // for .vetx file
    +		stdoutKey     = cache.Subkey(id, "stdout")  // for .stdout file
    +		fixArchiveKey = cache.Subkey(id, "fix.zip") // for .fix.zip file
    +	)
    +
    +	// Check the cache; -a forces a rebuild.
    +	if !cfg.BuildA {
    +		c := cache.Default()
    +
    +		// There may be multiple artifacts in the cache.
    +		// We need to retrieve them all, or none:
    +		// the effect must be transactional.
    +		var (
    +			vetxFile   string                           // name of cached .vetx file
    +			fixArchive string                           // name of cached .fix.zip file
    +			stdout     io.Reader = bytes.NewReader(nil) // cached stdout stream
    +		)
    +
    +		// Obtain location of cached .vetx file.
    +		vetxFile, _, err := cache.GetFile(c, id)
    +		if err != nil {
    +			goto cachemiss
    +		}
    +
    +		// Obtain location of cached .fix.zip file (if needed).
    +		if a.needFix {
    +			file, _, err := cache.GetFile(c, fixArchiveKey)
    +			if err != nil {
    +				goto cachemiss
    +			}
    +			fixArchive = file
    +		}
    +
    +		// Copy cached .stdout file to stdout.
    +		if file, _, err := cache.GetFile(c, stdoutKey); err == nil {
    +			f, err := os.Open(file)
    +			if err != nil {
    +				goto cachemiss
    +			}
    +			defer f.Close() // ignore error (can't fail)
    +			stdout = f
    +		}
    +
    +		// Cache hit: commit transaction.
    +		a.built = vetxFile
    +		a.FixArchive = fixArchive
    +		if err := VetHandleStdout(stdout); err != nil {
    +			return err // internal error (don't fall through to cachemiss)
    +		}
    +
    +		return nil
    +	}
    +cachemiss:
    +
    +	js, err := json.MarshalIndent(vcfg, "", "\t")
    +	if err != nil {
    +		return fmt.Errorf("internal error marshaling vet config: %v", err)
    +	}
    +	js = append(js, '\n')
    +	if err := sh.writeFile(a.Objdir+"vet.cfg", js); err != nil {
    +		return err
    +	}
    +
    +	// TODO(rsc): Why do we pass $GCCGO to go vet?
    +	env := b.cCompilerEnv()
    +	if cfg.BuildToolchainName == "gccgo" {
    +		env = append(env, "GCCGO="+BuildToolchain.compiler())
    +	}
    +
    +	p := a.Package
    +	tool := VetTool
    +	if tool == "" {
    +		panic("VetTool unset")
    +	}
    +
    +	if err := sh.run(p.Dir, p.ImportPath, env, cfg.BuildToolexec, tool, vetFlags, a.Objdir+"vet.cfg"); err != nil {
    +		return err
    +	}
    +
    +	// Vet tool succeeded, possibly with facts, fixes, or JSON stdout.
    +	// Save all in cache.
    +
    +	// Save facts.
    +	if f, err := os.Open(vcfg.VetxOutput); err == nil {
    +		defer f.Close() // ignore error
    +		a.built = vcfg.VetxOutput
    +		cache.Default().Put(id, f) // ignore error
    +	}
    +
    +	// Save fix archive (if any).
    +	if a.needFix {
    +		if f, err := os.Open(vcfg.FixArchive); err == nil {
    +			defer f.Close() // ignore error
    +			a.FixArchive = vcfg.FixArchive
    +			cache.Default().Put(fixArchiveKey, f) // ignore error
    +		}
    +	}
    +
    +	// Save stdout.
    +	if f, err := os.Open(vcfg.Stdout); err == nil {
    +		defer f.Close() // ignore error
    +		if err := VetHandleStdout(f); err != nil {
    +			return err
    +		}
    +		f.Seek(0, io.SeekStart)           // ignore error
    +		cache.Default().Put(stdoutKey, f) // ignore error
    +	}
    +
    +	return nil
    +}
    +
    +var stdoutMu sync.Mutex // serializes concurrent writes (of e.g. JSON values) to stdout
    +
    +// copyToStdout copies the stream to stdout while holding the lock.
    +func copyToStdout(r io.Reader) error {
    +	stdoutMu.Lock()
    +	defer stdoutMu.Unlock()
    +	if _, err := io.Copy(os.Stdout, r); err != nil {
    +		return fmt.Errorf("copying vet tool stdout: %w", err)
    +	}
    +	return nil
    +}
    +
    +// linkActionID computes the action ID for a link action.
    +func (b *Builder) linkActionID(a *Action) cache.ActionID {
    +	p := a.Package
    +	h := cache.NewHash("link " + p.ImportPath)
    +
    +	// Toolchain-independent configuration.
    +	fmt.Fprintf(h, "link\n")
    +	fmt.Fprintf(h, "buildmode %s goos %s goarch %s\n", cfg.BuildBuildmode, cfg.Goos, cfg.Goarch)
    +	fmt.Fprintf(h, "import %q\n", p.ImportPath)
    +	fmt.Fprintf(h, "omitdebug %v standard %v local %v prefix %q\n", p.Internal.OmitDebug, p.Standard, p.Internal.Local, p.Internal.LocalPrefix)
    +	fmt.Fprintf(h, "defaultgodebug %q\n", p.DefaultGODEBUG)
    +	if cfg.BuildTrimpath {
    +		fmt.Fprintln(h, "trimpath")
    +	}
    +
    +	// Toolchain-dependent configuration, shared with b.linkSharedActionID.
    +	b.printLinkerConfig(h, p)
    +
    +	// Input files.
    +	for _, a1 := range a.Deps {
    +		p1 := a1.Package
    +		if p1 != nil {
    +			if a1.built != "" || a1.buildID != "" {
    +				buildID := a1.buildID
    +				if buildID == "" {
    +					buildID = b.buildID(a1.built)
    +				}
    +				fmt.Fprintf(h, "packagefile %s=%s\n", p1.ImportPath, contentID(buildID))
    +			}
    +			// Because we put package main's full action ID into the binary's build ID,
    +			// we must also put the full action ID into the binary's action ID hash.
    +			if p1.Name == "main" {
    +				fmt.Fprintf(h, "packagemain %s\n", a1.buildID)
    +			}
    +			if p1.Shlib != "" {
    +				fmt.Fprintf(h, "packageshlib %s=%s\n", p1.ImportPath, contentID(b.buildID(p1.Shlib)))
    +			}
    +		}
    +	}
    +
    +	return h.Sum()
    +}
    +
    +// printLinkerConfig prints the linker config into the hash h,
    +// as part of the computation of a linker-related action ID.
    +func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) {
    +	switch cfg.BuildToolchainName {
    +	default:
    +		base.Fatalf("linkActionID: unknown toolchain %q", cfg.BuildToolchainName)
    +
    +	case "gc":
    +		fmt.Fprintf(h, "link %s %q %s\n", b.toolID("link"), forcedLdflags, ldBuildmode)
    +		if p != nil {
    +			fmt.Fprintf(h, "linkflags %q\n", p.Internal.Ldflags)
    +		}
    +
    +		// GOARM, GOMIPS, etc.
    +		key, val, _ := cfg.GetArchEnv()
    +		fmt.Fprintf(h, "%s=%s\n", key, val)
    +
    +		if cfg.CleanGOEXPERIMENT != "" {
    +			fmt.Fprintf(h, "GOEXPERIMENT=%q\n", cfg.CleanGOEXPERIMENT)
    +		}
    +
    +		// The linker writes source file paths that refer to GOROOT,
    +		// but only if -trimpath is not specified (see [gctoolchain.ld] in gc.go).
    +		gorootFinal := cfg.GOROOT
    +		if cfg.BuildTrimpath {
    +			gorootFinal = ""
    +		}
    +		fmt.Fprintf(h, "GOROOT=%s\n", gorootFinal)
    +
    +		// GO_EXTLINK_ENABLED controls whether the external linker is used.
    +		fmt.Fprintf(h, "GO_EXTLINK_ENABLED=%s\n", cfg.Getenv("GO_EXTLINK_ENABLED"))
    +
    +		// TODO(rsc): Do cgo settings and flags need to be included?
    +		// Or external linker settings and flags?
    +
    +	case "gccgo":
    +		id, _, err := b.gccToolID(BuildToolchain.linker(), "go")
    +		if err != nil {
    +			base.Fatalf("%v", err)
    +		}
    +		fmt.Fprintf(h, "link %s %s\n", id, ldBuildmode)
    +		// TODO(iant): Should probably include cgo flags here.
    +	}
    +}
    +
    +// link is the action for linking a single command.
    +// Note that any new influence on this logic must be reported in b.linkActionID above as well.
    +func (b *Builder) link(ctx context.Context, a *Action) (err error) {
    +	if b.useCache(a, b.linkActionID(a), a.Package.Target, !b.IsCmdList) || b.IsCmdList {
    +		return nil
    +	}
    +	defer b.flushOutput(a)
    +
    +	sh := b.Shell(a)
    +	if err := sh.Mkdir(a.Objdir); err != nil {
    +		return err
    +	}
    +
    +	importcfg := a.Objdir + "importcfg.link"
    +	if err := b.writeLinkImportcfg(a, importcfg); err != nil {
    +		return err
    +	}
    +
    +	if err := AllowInstall(a); err != nil {
    +		return err
    +	}
    +
    +	// make target directory
    +	dir, _ := filepath.Split(a.Target)
    +	if dir != "" {
    +		if err := sh.Mkdir(dir); err != nil {
    +			return err
    +		}
    +	}
    +
    +	if err := BuildToolchain.ld(b, a, a.Target, importcfg, a.Deps[0].built); err != nil {
    +		return err
    +	}
    +
    +	// Update the binary with the final build ID.
    +	if err := b.updateBuildID(a, a.Target); err != nil {
    +		return err
    +	}
    +
    +	a.built = a.Target
    +	return nil
    +}
    +
    +func (b *Builder) writeLinkImportcfg(a *Action, file string) error {
    +	// Prepare Go import cfg.
    +	var icfg bytes.Buffer
    +	for _, a1 := range a.Deps {
    +		p1 := a1.Package
    +		if p1 == nil {
    +			continue
    +		}
    +		fmt.Fprintf(&icfg, "packagefile %s=%s\n", p1.ImportPath, a1.built)
    +		if p1.Shlib != "" {
    +			fmt.Fprintf(&icfg, "packageshlib %s=%s\n", p1.ImportPath, p1.Shlib)
    +		}
    +	}
    +	info := ""
    +	if a.Package.Internal.BuildInfo != nil {
    +		info = a.Package.Internal.BuildInfo.String()
    +	}
    +	fmt.Fprintf(&icfg, "modinfo %q\n", modload.ModInfoData(info))
    +	return b.Shell(a).writeFile(file, icfg.Bytes())
    +}
    +
    +// PkgconfigCmd returns a pkg-config binary name
    +// defaultPkgConfig is defined in zdefaultcc.go, written by cmd/dist.
    +func (b *Builder) PkgconfigCmd() string {
    +	return envList("PKG_CONFIG", cfg.DefaultPkgConfig)[0]
    +}
    +
    +// splitPkgConfigOutput parses the pkg-config output into a slice of flags.
    +// This implements the shell quoting semantics described in
    +// https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02,
    +// except that it does not support parameter or arithmetic expansion or command
    +// substitution and hard-codes the  delimiters instead of reading them
    +// from LC_LOCALE.
    +func splitPkgConfigOutput(out []byte) ([]string, error) {
    +	if len(out) == 0 {
    +		return nil, nil
    +	}
    +	var flags []string
    +	flag := make([]byte, 0, len(out))
    +	didQuote := false // was the current flag parsed from a quoted string?
    +	escaped := false  // did we just read `\` in a non-single-quoted context?
    +	quote := byte(0)  // what is the quote character around the current string?
    +
    +	for _, c := range out {
    +		if escaped {
    +			if quote == '"' {
    +				// “The  shall retain its special meaning as an escape
    +				// character … only when followed by one of the following characters
    +				// when considered special:”
    +				switch c {
    +				case '$', '`', '"', '\\', '\n':
    +					// Handle the escaped character normally.
    +				default:
    +					// Not an escape character after all.
    +					flag = append(flag, '\\', c)
    +					escaped = false
    +					continue
    +				}
    +			}
    +
    +			if c == '\n' {
    +				// “If a  follows the , the shell shall interpret
    +				// this as line continuation.”
    +			} else {
    +				flag = append(flag, c)
    +			}
    +			escaped = false
    +			continue
    +		}
    +
    +		if quote != 0 && c == quote {
    +			quote = 0
    +			continue
    +		}
    +		switch quote {
    +		case '\'':
    +			// “preserve the literal value of each character”
    +			flag = append(flag, c)
    +			continue
    +		case '"':
    +			// “preserve the literal value of all characters within the double-quotes,
    +			// with the exception of …”
    +			switch c {
    +			case '`', '$', '\\':
    +			default:
    +				flag = append(flag, c)
    +				continue
    +			}
    +		}
    +
    +		// “The application shall quote the following characters if they are to
    +		// represent themselves:”
    +		switch c {
    +		case '|', '&', ';', '<', '>', '(', ')', '$', '`':
    +			return nil, fmt.Errorf("unexpected shell character %q in pkgconf output", c)
    +
    +		case '\\':
    +			// “A  that is not quoted shall preserve the literal value of
    +			// the following character, with the exception of a .”
    +			escaped = true
    +			continue
    +
    +		case '"', '\'':
    +			quote = c
    +			didQuote = true
    +			continue
    +
    +		case ' ', '\t', '\n':
    +			if len(flag) > 0 || didQuote {
    +				flags = append(flags, string(flag))
    +			}
    +			flag, didQuote = flag[:0], false
    +			continue
    +		}
    +
    +		flag = append(flag, c)
    +	}
    +
    +	// Prefer to report a missing quote instead of a missing escape. If the string
    +	// is something like `"foo\`, it's ambiguous as to whether the trailing
    +	// backslash is really an escape at all.
    +	if quote != 0 {
    +		return nil, errors.New("unterminated quoted string in pkgconf output")
    +	}
    +	if escaped {
    +		return nil, errors.New("broken character escaping in pkgconf output")
    +	}
    +
    +	if len(flag) > 0 || didQuote {
    +		flags = append(flags, string(flag))
    +	}
    +	return flags, nil
    +}
    +
    +// Calls pkg-config if needed and returns the cflags/ldflags needed to build a's package.
    +func (b *Builder) getPkgConfigFlags(a *Action, p *load.Package) (cflags, ldflags []string, err error) {
    +	sh := b.Shell(a)
    +	if pcargs := p.CgoPkgConfig; len(pcargs) > 0 {
    +		// pkg-config permits arguments to appear anywhere in
    +		// the command line. Move them all to the front, before --.
    +		var pcflags []string
    +		var pkgs []string
    +		for _, pcarg := range pcargs {
    +			if pcarg == "--" {
    +				// We're going to add our own "--" argument.
    +			} else if strings.HasPrefix(pcarg, "--") {
    +				pcflags = append(pcflags, pcarg)
    +			} else {
    +				pkgs = append(pkgs, pcarg)
    +			}
    +		}
    +		for _, pkg := range pkgs {
    +			if !load.SafeArg(pkg) {
    +				return nil, nil, fmt.Errorf("invalid pkg-config package name: %s", pkg)
    +			}
    +		}
    +
    +		if err := checkPkgConfigFlags("", "pkg-config", pcflags); err != nil {
    +			return nil, nil, err
    +		}
    +
    +		var out []byte
    +		out, err = sh.runOut(p.Dir, nil, b.PkgconfigCmd(), "--cflags", pcflags, "--", pkgs)
    +		if err != nil {
    +			desc := b.PkgconfigCmd() + " --cflags " + strings.Join(pcflags, " ") + " -- " + strings.Join(pkgs, " ")
    +			return nil, nil, sh.reportCmd(desc, "", out, err)
    +		}
    +		if len(out) > 0 {
    +			cflags, err = splitPkgConfigOutput(bytes.TrimSpace(out))
    +			if err != nil {
    +				return nil, nil, err
    +			}
    +			if err := checkCompilerFlags("CFLAGS", "pkg-config --cflags", cflags); err != nil {
    +				return nil, nil, err
    +			}
    +		}
    +		out, err = sh.runOut(p.Dir, nil, b.PkgconfigCmd(), "--libs", pcflags, "--", pkgs)
    +		if err != nil {
    +			desc := b.PkgconfigCmd() + " --libs " + strings.Join(pcflags, " ") + " -- " + strings.Join(pkgs, " ")
    +			return nil, nil, sh.reportCmd(desc, "", out, err)
    +		}
    +		if len(out) > 0 {
    +			// We need to handle path with spaces so that C:/Program\ Files can pass
    +			// checkLinkerFlags. Use splitPkgConfigOutput here just like we treat cflags.
    +			ldflags, err = splitPkgConfigOutput(bytes.TrimSpace(out))
    +			if err != nil {
    +				return nil, nil, err
    +			}
    +			if err := checkLinkerFlags("LDFLAGS", "pkg-config --libs", ldflags); err != nil {
    +				return nil, nil, err
    +			}
    +		}
    +	}
    +
    +	return
    +}
    +
    +func (b *Builder) installShlibname(ctx context.Context, a *Action) error {
    +	if err := AllowInstall(a); err != nil {
    +		return err
    +	}
    +
    +	sh := b.Shell(a)
    +	a1 := a.Deps[0]
    +	if !cfg.BuildN {
    +		if err := sh.Mkdir(filepath.Dir(a.Target)); err != nil {
    +			return err
    +		}
    +	}
    +	return sh.writeFile(a.Target, []byte(filepath.Base(a1.Target)+"\n"))
    +}
    +
    +func (b *Builder) linkSharedActionID(a *Action) cache.ActionID {
    +	h := cache.NewHash("linkShared")
    +
    +	// Toolchain-independent configuration.
    +	fmt.Fprintf(h, "linkShared\n")
    +	fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch)
    +
    +	// Toolchain-dependent configuration, shared with b.linkActionID.
    +	b.printLinkerConfig(h, nil)
    +
    +	// Input files.
    +	for _, a1 := range a.Deps {
    +		p1 := a1.Package
    +		if a1.built == "" {
    +			continue
    +		}
    +		if p1 != nil {
    +			fmt.Fprintf(h, "packagefile %s=%s\n", p1.ImportPath, contentID(b.buildID(a1.built)))
    +			if p1.Shlib != "" {
    +				fmt.Fprintf(h, "packageshlib %s=%s\n", p1.ImportPath, contentID(b.buildID(p1.Shlib)))
    +			}
    +		}
    +	}
    +	// Files named on command line are special.
    +	for _, a1 := range a.Deps[0].Deps {
    +		p1 := a1.Package
    +		fmt.Fprintf(h, "top %s=%s\n", p1.ImportPath, contentID(b.buildID(a1.built)))
    +	}
    +
    +	return h.Sum()
    +}
    +
    +func (b *Builder) linkShared(ctx context.Context, a *Action) (err error) {
    +	if b.useCache(a, b.linkSharedActionID(a), a.Target, !b.IsCmdList) || b.IsCmdList {
    +		return nil
    +	}
    +	defer b.flushOutput(a)
    +
    +	if err := AllowInstall(a); err != nil {
    +		return err
    +	}
    +
    +	if err := b.Shell(a).Mkdir(a.Objdir); err != nil {
    +		return err
    +	}
    +
    +	importcfg := a.Objdir + "importcfg.link"
    +	if err := b.writeLinkImportcfg(a, importcfg); err != nil {
    +		return err
    +	}
    +
    +	// TODO(rsc): There is a missing updateBuildID here,
    +	// but we have to decide where to store the build ID in these files.
    +	a.built = a.Target
    +	return BuildToolchain.ldShared(b, a, a.Deps[0].Deps, a.Target, importcfg, a.Deps)
    +}
    +
    +// BuildInstallFunc is the action for installing a single package or executable.
    +func BuildInstallFunc(b *Builder, ctx context.Context, a *Action) (err error) {
    +	defer func() {
    +		if err != nil {
    +			// a.Package == nil is possible for the go install -buildmode=shared
    +			// action that installs libmangledname.so, which corresponds to
    +			// a list of packages, not just one.
    +			sep, path := "", ""
    +			if a.Package != nil {
    +				sep, path = " ", a.Package.ImportPath
    +			}
    +			err = fmt.Errorf("go %s%s%s: %v", cfg.CmdName, sep, path, err)
    +		}
    +	}()
    +	sh := b.Shell(a)
    +
    +	a1 := a.Deps[0]
    +	a.buildID = a1.buildID
    +	if a.json != nil {
    +		a.json.BuildID = a.buildID
    +	}
    +
    +	// If we are using the eventual install target as an up-to-date
    +	// cached copy of the thing we built, then there's no need to
    +	// copy it into itself (and that would probably fail anyway).
    +	// In this case a1.built == a.Target because a1.built == p.Target,
    +	// so the built target is not in the a1.Objdir tree that b.cleanup(a1) removes.
    +	if a1.built == a.Target {
    +		a.built = a.Target
    +		if !a.buggyInstall {
    +			b.cleanup(a1)
    +		}
    +		// Whether we're smart enough to avoid a complete rebuild
    +		// depends on exactly what the staleness and rebuild algorithms
    +		// are, as well as potentially the state of the Go build cache.
    +		// We don't really want users to be able to infer (or worse start depending on)
    +		// those details from whether the modification time changes during
    +		// "go install", so do a best-effort update of the file times to make it
    +		// look like we rewrote a.Target even if we did not. Updating the mtime
    +		// may also help other mtime-based systems that depend on our
    +		// previous mtime updates that happened more often.
    +		// This is still not perfect - we ignore the error result, and if the file was
    +		// unwritable for some reason then pretending to have written it is also
    +		// confusing - but it's probably better than not doing the mtime update.
    +		//
    +		// But don't do that for the special case where building an executable
    +		// with -linkshared implicitly installs all its dependent libraries.
    +		// We want to hide that awful detail as much as possible, so don't
    +		// advertise it by touching the mtimes (usually the libraries are up
    +		// to date).
    +		if !a.buggyInstall && !b.IsCmdList {
    +			if cfg.BuildN {
    +				sh.ShowCmd("", "touch %s", a.Target)
    +			} else if err := AllowInstall(a); err == nil {
    +				now := time.Now()
    +				os.Chtimes(a.Target, now, now)
    +			}
    +		}
    +		return nil
    +	}
    +
    +	// If we're building for go list -export,
    +	// never install anything; just keep the cache reference.
    +	if b.IsCmdList {
    +		a.built = a1.built
    +		return nil
    +	}
    +	if err := AllowInstall(a); err != nil {
    +		return err
    +	}
    +
    +	if err := sh.Mkdir(a.Objdir); err != nil {
    +		return err
    +	}
    +
    +	perm := fs.FileMode(0666)
    +	if a1.Mode == "link" {
    +		switch cfg.BuildBuildmode {
    +		case "c-archive", "c-shared", "plugin":
    +		default:
    +			perm = 0777
    +		}
    +	}
    +
    +	// make target directory
    +	dir, _ := filepath.Split(a.Target)
    +	if dir != "" {
    +		if err := sh.Mkdir(dir); err != nil {
    +			return err
    +		}
    +	}
    +
    +	if !a.buggyInstall {
    +		defer b.cleanup(a1)
    +	}
    +
    +	return sh.moveOrCopyFile(a.Target, a1.built, perm, false)
    +}
    +
    +// AllowInstall returns a non-nil error if this invocation of the go command is
    +// allowed to install a.Target.
    +//
    +// The build of cmd/go running under its own test is forbidden from installing
    +// to its original GOROOT. The var is exported so it can be set by TestMain.
    +var AllowInstall = func(*Action) error { return nil }
    +
    +// cleanup removes a's object dir to keep the amount of
    +// on-disk garbage down in a large build. On an operating system
    +// with aggressive buffering, cleaning incrementally like
    +// this keeps the intermediate objects from hitting the disk.
    +func (b *Builder) cleanup(a *Action) {
    +	if !cfg.BuildWork {
    +		b.Shell(a).RemoveAll(a.Objdir)
    +	}
    +}
    +
    +// Install the cgo export header file, if there is one.
    +func (b *Builder) installHeader(ctx context.Context, a *Action) error {
    +	sh := b.Shell(a)
    +
    +	src := a.Objdir + "_cgo_install.h"
    +	if _, err := os.Stat(src); os.IsNotExist(err) {
    +		// If the file does not exist, there are no exported
    +		// functions, and we do not install anything.
    +		// TODO(rsc): Once we know that caching is rebuilding
    +		// at the right times (not missing rebuilds), here we should
    +		// probably delete the installed header, if any.
    +		if cfg.BuildX {
    +			sh.ShowCmd("", "# %s not created", src)
    +		}
    +		return nil
    +	}
    +
    +	if err := AllowInstall(a); err != nil {
    +		return err
    +	}
    +
    +	dir, _ := filepath.Split(a.Target)
    +	if dir != "" {
    +		if err := sh.Mkdir(dir); err != nil {
    +			return err
    +		}
    +	}
    +
    +	return sh.moveOrCopyFile(a.Target, src, 0666, true)
    +}
    +
    +// cover runs, in effect,
    +//
    +//	go tool cover -pkgcfg= -mode=b.coverMode -var="varName" -o  
    +//
    +// Return value is an updated output files list; in addition to the
    +// regular outputs (instrumented source files) the cover tool also
    +// writes a separate file (appearing first in the list of outputs)
    +// that will contain coverage counters and meta-data.
    +func (b *Builder) cover(a *Action, infiles, outfiles []string, varName string, mode string) ([]string, error) {
    +	pkgcfg := a.Objdir + "pkgcfg.txt"
    +	covoutputs := a.Objdir + "coveroutfiles.txt"
    +	odir := filepath.Dir(outfiles[0])
    +	cv := filepath.Join(odir, "covervars.go")
    +	outfiles = append([]string{cv}, outfiles...)
    +	if err := b.writeCoverPkgInputs(a, pkgcfg, covoutputs, outfiles); err != nil {
    +		return nil, err
    +	}
    +	args := []string{base.Tool("cover"),
    +		"-pkgcfg", pkgcfg,
    +		"-mode", mode,
    +		"-var", varName,
    +		"-outfilelist", covoutputs,
    +	}
    +	args = append(args, infiles...)
    +	if err := b.Shell(a).run(a.Objdir, "", nil,
    +		cfg.BuildToolexec, args); err != nil {
    +		return nil, err
    +	}
    +	return outfiles, nil
    +}
    +
    +func (b *Builder) writeCoverPkgInputs(a *Action, pconfigfile string, covoutputsfile string, outfiles []string) error {
    +	sh := b.Shell(a)
    +	p := a.Package
    +	p.Internal.Cover.Cfg = a.Objdir + "coveragecfg"
    +	pcfg := covcmd.CoverPkgConfig{
    +		PkgPath: p.ImportPath,
    +		PkgName: p.Name,
    +		// Note: coverage granularity is currently hard-wired to
    +		// 'perblock'; there isn't a way using "go build -cover" or "go
    +		// test -cover" to select it. This may change in the future
    +		// depending on user demand.
    +		Granularity: "perblock",
    +		OutConfig:   p.Internal.Cover.Cfg,
    +		Local:       p.Internal.Local,
    +	}
    +	if ca, ok := a.Actor.(*coverActor); ok && ca.covMetaFileName != "" {
    +		pcfg.EmitMetaFile = a.Objdir + ca.covMetaFileName
    +	}
    +	if a.Package.Module != nil {
    +		pcfg.ModulePath = a.Package.Module.Path
    +	}
    +	data, err := json.Marshal(pcfg)
    +	if err != nil {
    +		return err
    +	}
    +	data = append(data, '\n')
    +	if err := sh.writeFile(pconfigfile, data); err != nil {
    +		return err
    +	}
    +	var sb strings.Builder
    +	for i := range outfiles {
    +		fmt.Fprintf(&sb, "%s\n", outfiles[i])
    +	}
    +	return sh.writeFile(covoutputsfile, []byte(sb.String()))
    +}
    +
    +var objectMagic = [][]byte{
    +	{'!', '<', 'a', 'r', 'c', 'h', '>', '\n'}, // Package archive
    +	{'<', 'b', 'i', 'g', 'a', 'f', '>', '\n'}, // Package AIX big archive
    +	{'\x7F', 'E', 'L', 'F'},                   // ELF
    +	{0xFE, 0xED, 0xFA, 0xCE},                  // Mach-O big-endian 32-bit
    +	{0xFE, 0xED, 0xFA, 0xCF},                  // Mach-O big-endian 64-bit
    +	{0xCE, 0xFA, 0xED, 0xFE},                  // Mach-O little-endian 32-bit
    +	{0xCF, 0xFA, 0xED, 0xFE},                  // Mach-O little-endian 64-bit
    +	{0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00},      // PE (Windows) as generated by 6l/8l and gcc
    +	{0x4d, 0x5a, 0x78, 0x00, 0x01, 0x00},      // PE (Windows) as generated by llvm for dll
    +	{0x00, 0x00, 0x01, 0xEB},                  // Plan 9 i386
    +	{0x00, 0x00, 0x8a, 0x97},                  // Plan 9 amd64
    +	{0x00, 0x00, 0x06, 0x47},                  // Plan 9 arm
    +	{0x00, 0x61, 0x73, 0x6D},                  // WASM
    +	{0x01, 0xDF},                              // XCOFF 32bit
    +	{0x01, 0xF7},                              // XCOFF 64bit
    +}
    +
    +func isObject(s string) bool {
    +	f, err := os.Open(s)
    +	if err != nil {
    +		return false
    +	}
    +	defer f.Close()
    +	buf := make([]byte, 64)
    +	io.ReadFull(f, buf)
    +	for _, magic := range objectMagic {
    +		if bytes.HasPrefix(buf, magic) {
    +			return true
    +		}
    +	}
    +	return false
    +}
    +
    +// cCompilerEnv returns environment variables to set when running the
    +// C compiler. This is needed to disable escape codes in clang error
    +// messages that confuse tools like cgo.
    +func (b *Builder) cCompilerEnv() []string {
    +	return []string{"TERM=dumb"}
    +}
    +
    +// mkAbs returns an absolute path corresponding to
    +// evaluating f in the directory dir.
    +// We always pass absolute paths of source files so that
    +// the error messages will include the full path to a file
    +// in need of attention.
    +func mkAbs(dir, f string) string {
    +	// Leave absolute paths alone.
    +	// Also, during -n mode we use the pseudo-directory $WORK
    +	// instead of creating an actual work directory that won't be used.
    +	// Leave paths beginning with $WORK alone too.
    +	if filepath.IsAbs(f) || strings.HasPrefix(f, "$WORK") {
    +		return f
    +	}
    +	return filepath.Join(dir, f)
    +}
    +
    +type toolchain interface {
    +	// gc runs the compiler in a specific directory on a set of files
    +	// and returns the name of the generated output file.
    +	gc(b *Builder, a *Action, archive string, importcfg, embedcfg []byte, symabis string, asmhdr bool, pgoProfile string, gofiles []string) (ofile string, out []byte, err error)
    +	// cc runs the toolchain's C compiler in a directory on a C file
    +	// to produce an output file.
    +	cc(b *Builder, a *Action, ofile, cfile string) error
    +	// asm runs the assembler in a specific directory on specific files
    +	// and returns a list of named output files.
    +	asm(b *Builder, a *Action, sfiles []string) ([]string, error)
    +	// symabis scans the symbol ABIs from sfiles and returns the
    +	// path to the output symbol ABIs file, or "" if none.
    +	symabis(b *Builder, a *Action, sfiles []string) (string, error)
    +	// pack runs the archive packer in a specific directory to create
    +	// an archive from a set of object files.
    +	// typically it is run in the object directory.
    +	pack(b *Builder, a *Action, afile string, ofiles []string) error
    +	// ld runs the linker to create an executable starting at mainpkg.
    +	ld(b *Builder, root *Action, targetPath, importcfg, mainpkg string) error
    +	// ldShared runs the linker to create a shared library containing the pkgs built by toplevelactions
    +	ldShared(b *Builder, root *Action, toplevelactions []*Action, targetPath, importcfg string, allactions []*Action) error
    +
    +	compiler() string
    +	linker() string
    +}
    +
    +type noToolchain struct{}
    +
    +func noCompiler() error {
    +	log.Fatalf("unknown compiler %q", cfg.BuildContext.Compiler)
    +	return nil
    +}
    +
    +func (noToolchain) compiler() string {
    +	noCompiler()
    +	return ""
    +}
    +
    +func (noToolchain) linker() string {
    +	noCompiler()
    +	return ""
    +}
    +
    +func (noToolchain) gc(b *Builder, a *Action, archive string, importcfg, embedcfg []byte, symabis string, asmhdr bool, pgoProfile string, gofiles []string) (ofile string, out []byte, err error) {
    +	return "", nil, noCompiler()
    +}
    +
    +func (noToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error) {
    +	return nil, noCompiler()
    +}
    +
    +func (noToolchain) symabis(b *Builder, a *Action, sfiles []string) (string, error) {
    +	return "", noCompiler()
    +}
    +
    +func (noToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) error {
    +	return noCompiler()
    +}
    +
    +func (noToolchain) ld(b *Builder, root *Action, targetPath, importcfg, mainpkg string) error {
    +	return noCompiler()
    +}
    +
    +func (noToolchain) ldShared(b *Builder, root *Action, toplevelactions []*Action, targetPath, importcfg string, allactions []*Action) error {
    +	return noCompiler()
    +}
    +
    +func (noToolchain) cc(b *Builder, a *Action, ofile, cfile string) error {
    +	return noCompiler()
    +}
    +
    +// gcc runs the gcc C compiler to create an object from a single C file.
    +func (b *Builder) gcc(a *Action, workdir, out string, flags []string, cfile string) error {
    +	p := a.Package
    +	return b.ccompile(a, out, flags, cfile, b.GccCmd(p.Dir, workdir))
    +}
    +
    +// gas runs the gcc c compiler to create an object file from a single C assembly file.
    +func (b *Builder) gas(a *Action, workdir, out string, flags []string, sfile string) error {
    +	p := a.Package
    +	data, err := os.ReadFile(filepath.Join(p.Dir, sfile))
    +	if err == nil {
    +		if bytes.HasPrefix(data, []byte("TEXT")) || bytes.Contains(data, []byte("\nTEXT")) ||
    +			bytes.HasPrefix(data, []byte("DATA")) || bytes.Contains(data, []byte("\nDATA")) ||
    +			bytes.HasPrefix(data, []byte("GLOBL")) || bytes.Contains(data, []byte("\nGLOBL")) {
    +			return fmt.Errorf("package using cgo has Go assembly file %s", sfile)
    +		}
    +	}
    +	return b.ccompile(a, out, flags, sfile, b.GccCmd(p.Dir, workdir))
    +}
    +
    +// gxx runs the g++ C++ compiler to create an object from a single C++ file.
    +func (b *Builder) gxx(a *Action, workdir, out string, flags []string, cxxfile string) error {
    +	p := a.Package
    +	return b.ccompile(a, out, flags, cxxfile, b.GxxCmd(p.Dir, workdir))
    +}
    +
    +// gfortran runs the gfortran Fortran compiler to create an object from a single Fortran file.
    +func (b *Builder) gfortran(a *Action, workdir, out string, flags []string, ffile string) error {
    +	p := a.Package
    +	return b.ccompile(a, out, flags, ffile, b.gfortranCmd(p.Dir, workdir))
    +}
    +
    +// ccompile runs the given C or C++ compiler and creates an object from a single source file.
    +func (b *Builder) ccompile(a *Action, outfile string, flags []string, file string, compiler []string) error {
    +	p := a.Package
    +	sh := b.Shell(a)
    +	file = mkAbs(p.Dir, file)
    +	outfile = mkAbs(p.Dir, outfile)
    +
    +	flags = slices.Clip(flags) // If we append to flags, write to a new slice that we own.
    +
    +	// Elide source directory paths if -trimpath is set.
    +	// This is needed for source files (e.g., a .c file in a package directory).
    +	// TODO(golang.org/issue/36072): cgo also generates files with #line
    +	// directives pointing to the source directory. It should not generate those
    +	// when -trimpath is enabled.
    +	if b.gccSupportsFlag(compiler, "-fdebug-prefix-map=a=b") {
    +		if cfg.BuildTrimpath || p.Goroot {
    +			prefixMapFlag := "-fdebug-prefix-map"
    +			if b.gccSupportsFlag(compiler, "-ffile-prefix-map=a=b") {
    +				prefixMapFlag = "-ffile-prefix-map"
    +			}
    +			// Keep in sync with Action.trimpath.
    +			// The trimmed paths are a little different, but we need to trim in mostly the
    +			// same situations.
    +			var from, toPath string
    +			if m := p.Module; m == nil {
    +				if p.Root == "" { // command-line-arguments in GOPATH mode, maybe?
    +					from = p.Dir
    +					toPath = p.ImportPath
    +				} else if p.Goroot {
    +					from = p.Root
    +					toPath = "GOROOT"
    +				} else {
    +					from = p.Root
    +					toPath = "GOPATH"
    +				}
    +			} else if m.Dir == "" {
    +				// The module is in the vendor directory. Replace the entire vendor
    +				// directory path, because the module's Dir is not filled in.
    +				from = b.getVendorDir()
    +				toPath = "vendor"
    +			} else {
    +				from = m.Dir
    +				toPath = m.Path
    +				if m.Version != "" {
    +					toPath += "@" + m.Version
    +				}
    +			}
    +			// -fdebug-prefix-map (or -ffile-prefix-map) requires an absolute "to"
    +			// path (or it joins the path  with the working directory). Pick something
    +			// that makes sense for the target platform.
    +			var to string
    +			if cfg.BuildContext.GOOS == "windows" {
    +				to = filepath.Join(`\\_\_`, toPath)
    +			} else {
    +				to = filepath.Join("/_", toPath)
    +			}
    +			flags = append(slices.Clip(flags), prefixMapFlag+"="+from+"="+to)
    +		}
    +	}
    +
    +	// Tell gcc to not insert truly random numbers into the build process
    +	// this ensures LTO won't create random numbers for symbols.
    +	if b.gccSupportsFlag(compiler, "-frandom-seed=1") {
    +		flags = append(flags, "-frandom-seed="+buildid.HashToString(a.actionID))
    +	}
    +
    +	overlayPath := file
    +	if p, ok := a.nonGoOverlay[overlayPath]; ok {
    +		overlayPath = p
    +	}
    +	output, err := sh.runOut(filepath.Dir(overlayPath), b.cCompilerEnv(), compiler, flags, "-o", outfile, "-c", filepath.Base(overlayPath))
    +
    +	// On FreeBSD 11, when we pass -g to clang 3.8 it
    +	// invokes its internal assembler with -dwarf-version=2.
    +	// When it sees .section .note.GNU-stack, it warns
    +	// "DWARF2 only supports one section per compilation unit".
    +	// This warning makes no sense, since the section is empty,
    +	// but it confuses people.
    +	// We work around the problem by detecting the warning
    +	// and dropping -g and trying again.
    +	if bytes.Contains(output, []byte("DWARF2 only supports one section per compilation unit")) {
    +		newFlags := make([]string, 0, len(flags))
    +		for _, f := range flags {
    +			if !strings.HasPrefix(f, "-g") {
    +				newFlags = append(newFlags, f)
    +			}
    +		}
    +		if len(newFlags) < len(flags) {
    +			return b.ccompile(a, outfile, newFlags, file, compiler)
    +		}
    +	}
    +
    +	if len(output) > 0 && err == nil && os.Getenv("GO_BUILDER_NAME") != "" {
    +		output = append(output, "C compiler warning promoted to error on Go builders\n"...)
    +		err = errors.New("warning promoted to error")
    +	}
    +
    +	return sh.reportCmd("", "", output, err)
    +}
    +
    +// gccld runs the gcc linker to create an executable from a set of object files.
    +func (b *Builder) gccld(a *Action, objdir, outfile string, flags []string, objs []string) error {
    +	p := a.Package
    +	sh := b.Shell(a)
    +	var cmd []string
    +	if len(p.CXXFiles) > 0 || len(p.SwigCXXFiles) > 0 {
    +		cmd = b.GxxCmd(p.Dir, objdir)
    +	} else {
    +		cmd = b.GccCmd(p.Dir, objdir)
    +	}
    +
    +	cmdargs := []any{cmd, "-o", outfile, objs, flags}
    +	_, err := sh.runOut(base.Cwd(), b.cCompilerEnv(), cmdargs...)
    +
    +	// Note that failure is an expected outcome here, so we report output only
    +	// in debug mode and don't report the error.
    +	if cfg.BuildN || cfg.BuildX {
    +		saw := "succeeded"
    +		if err != nil {
    +			saw = "failed"
    +		}
    +		sh.ShowCmd("", "%s # test for internal linking errors (%s)", joinUnambiguously(str.StringList(cmdargs...)), saw)
    +	}
    +
    +	return err
    +}
    +
    +// GccCmd returns a gcc command line prefix
    +// defaultCC is defined in zdefaultcc.go, written by cmd/dist.
    +func (b *Builder) GccCmd(incdir, workdir string) []string {
    +	return b.compilerCmd(b.ccExe(), incdir, workdir)
    +}
    +
    +// GxxCmd returns a g++ command line prefix
    +// defaultCXX is defined in zdefaultcc.go, written by cmd/dist.
    +func (b *Builder) GxxCmd(incdir, workdir string) []string {
    +	return b.compilerCmd(b.cxxExe(), incdir, workdir)
    +}
    +
    +// gfortranCmd returns a gfortran command line prefix.
    +func (b *Builder) gfortranCmd(incdir, workdir string) []string {
    +	return b.compilerCmd(b.fcExe(), incdir, workdir)
    +}
    +
    +// ccExe returns the CC compiler setting without all the extra flags we add implicitly.
    +func (b *Builder) ccExe() []string {
    +	return envList("CC", cfg.DefaultCC(cfg.Goos, cfg.Goarch))
    +}
    +
    +// cxxExe returns the CXX compiler setting without all the extra flags we add implicitly.
    +func (b *Builder) cxxExe() []string {
    +	return envList("CXX", cfg.DefaultCXX(cfg.Goos, cfg.Goarch))
    +}
    +
    +// fcExe returns the FC compiler setting without all the extra flags we add implicitly.
    +func (b *Builder) fcExe() []string {
    +	return envList("FC", "gfortran")
    +}
    +
    +// compilerCmd returns a command line prefix for the given environment
    +// variable and using the default command when the variable is empty.
    +func (b *Builder) compilerCmd(compiler []string, incdir, workdir string) []string {
    +	a := append(compiler, "-I", incdir)
    +
    +	// Definitely want -fPIC but on Windows gcc complains
    +	// "-fPIC ignored for target (all code is position independent)"
    +	if cfg.Goos != "windows" {
    +		a = append(a, "-fPIC")
    +	}
    +	a = append(a, b.gccArchArgs()...)
    +	// gcc-4.5 and beyond require explicit "-pthread" flag
    +	// for multithreading with pthread library.
    +	if cfg.BuildContext.CgoEnabled {
    +		switch cfg.Goos {
    +		case "windows":
    +			a = append(a, "-mthreads")
    +		default:
    +			a = append(a, "-pthread")
    +		}
    +	}
    +
    +	if cfg.Goos == "aix" {
    +		// mcmodel=large must always be enabled to allow large TOC.
    +		a = append(a, "-mcmodel=large")
    +	}
    +
    +	// disable ASCII art in clang errors, if possible
    +	if b.gccSupportsFlag(compiler, "-fno-caret-diagnostics") {
    +		a = append(a, "-fno-caret-diagnostics")
    +	}
    +	// clang is too smart about command-line arguments
    +	if b.gccSupportsFlag(compiler, "-Qunused-arguments") {
    +		a = append(a, "-Qunused-arguments")
    +	}
    +
    +	// zig cc passes --gc-sections to the underlying linker, which then causes
    +	// undefined symbol errors when compiling with cgo but without C code.
    +	// https://github.com/golang/go/issues/52690
    +	if b.gccSupportsFlag(compiler, "-Wl,--no-gc-sections") {
    +		a = append(a, "-Wl,--no-gc-sections")
    +	}
    +
    +	// disable word wrapping in error messages
    +	a = append(a, "-fmessage-length=0")
    +
    +	// Tell gcc not to include the work directory in object files.
    +	if b.gccSupportsFlag(compiler, "-fdebug-prefix-map=a=b") {
    +		if workdir == "" {
    +			workdir = b.WorkDir
    +		}
    +		workdir = strings.TrimSuffix(workdir, string(filepath.Separator))
    +		if b.gccSupportsFlag(compiler, "-ffile-prefix-map=a=b") {
    +			a = append(a, "-ffile-prefix-map="+workdir+"=/tmp/go-build")
    +		} else {
    +			a = append(a, "-fdebug-prefix-map="+workdir+"=/tmp/go-build")
    +		}
    +	}
    +
    +	// Tell gcc not to include flags in object files, which defeats the
    +	// point of -fdebug-prefix-map above.
    +	if b.gccSupportsFlag(compiler, "-gno-record-gcc-switches") {
    +		a = append(a, "-gno-record-gcc-switches")
    +	}
    +
    +	// On OS X, some of the compilers behave as if -fno-common
    +	// is always set, and the Mach-O linker in 6l/8l assumes this.
    +	// See https://golang.org/issue/3253.
    +	if cfg.Goos == "darwin" || cfg.Goos == "ios" {
    +		a = append(a, "-fno-common")
    +	}
    +
    +	return a
    +}
    +
    +// gccNoPie returns the flag to use to request non-PIE. On systems
    +// with PIE (position independent executables) enabled by default,
    +// -no-pie must be passed when doing a partial link with -Wl,-r.
    +// But -no-pie is not supported by all compilers, and clang spells it -nopie.
    +func (b *Builder) gccNoPie(linker []string) string {
    +	if b.gccSupportsFlag(linker, "-no-pie") {
    +		return "-no-pie"
    +	}
    +	if b.gccSupportsFlag(linker, "-nopie") {
    +		return "-nopie"
    +	}
    +	return ""
    +}
    +
    +// gccSupportsFlag checks to see if the compiler supports a flag.
    +func (b *Builder) gccSupportsFlag(compiler []string, flag string) bool {
    +	// We use the background shell for operations here because, while this is
    +	// triggered by some Action, it's not really about that Action, and often we
    +	// just get the results from the global cache.
    +	sh := b.BackgroundShell()
    +
    +	key := [2]string{compiler[0], flag}
    +
    +	// We used to write an empty C file, but that gets complicated with go
    +	// build -n. We tried using a file that does not exist, but that fails on
    +	// systems with GCC version 4.2.1; that is the last GPLv2 version of GCC,
    +	// so some systems have frozen on it. Now we pass an empty file on stdin,
    +	// which should work at least for GCC and clang.
    +	//
    +	// If the argument is "-Wl,", then it is testing the linker. In that case,
    +	// skip "-c". If it's not "-Wl,", then we are testing the compiler and can
    +	// omit the linking step with "-c".
    +	//
    +	// Using the same CFLAGS/LDFLAGS here and for building the program.
    +
    +	// On the iOS builder the command
    +	//   $CC -Wl,--no-gc-sections -x c - -o /dev/null < /dev/null
    +	// is failing with:
    +	//   Unable to remove existing file: Invalid argument
    +	tmp := os.DevNull
    +	if runtime.GOOS == "windows" || runtime.GOOS == "ios" {
    +		f, err := os.CreateTemp(b.WorkDir, "")
    +		if err != nil {
    +			return false
    +		}
    +		f.Close()
    +		tmp = f.Name()
    +		defer os.Remove(tmp)
    +	}
    +
    +	cmdArgs := str.StringList(compiler, flag)
    +	if strings.HasPrefix(flag, "-Wl,") /* linker flag */ {
    +		ldflags, err := buildFlags("LDFLAGS", DefaultCFlags, nil, checkLinkerFlags)
    +		if err != nil {
    +			return false
    +		}
    +		cmdArgs = append(cmdArgs, ldflags...)
    +	} else { /* compiler flag, add "-c" */
    +		cflags, err := buildFlags("CFLAGS", DefaultCFlags, nil, checkCompilerFlags)
    +		if err != nil {
    +			return false
    +		}
    +		cmdArgs = append(cmdArgs, cflags...)
    +		cmdArgs = append(cmdArgs, "-c")
    +	}
    +
    +	cmdArgs = append(cmdArgs, "-x", "c", "-", "-o", tmp)
    +
    +	if cfg.BuildN {
    +		sh.ShowCmd(b.WorkDir, "%s || true", joinUnambiguously(cmdArgs))
    +		return false
    +	}
    +
    +	// gccCompilerID acquires b.exec, so do before acquiring lock.
    +	compilerID, cacheOK := b.gccCompilerID(compiler[0])
    +
    +	b.exec.Lock()
    +	defer b.exec.Unlock()
    +	if b, ok := b.flagCache[key]; ok {
    +		return b
    +	}
    +	if b.flagCache == nil {
    +		b.flagCache = make(map[[2]string]bool)
    +	}
    +
    +	// Look in build cache.
    +	var flagID cache.ActionID
    +	if cacheOK {
    +		flagID = cache.Subkey(compilerID, "gccSupportsFlag "+flag)
    +		if data, _, err := cache.GetBytes(cache.Default(), flagID); err == nil {
    +			supported := string(data) == "true"
    +			b.flagCache[key] = supported
    +			return supported
    +		}
    +	}
    +
    +	if cfg.BuildX {
    +		sh.ShowCmd(b.WorkDir, "%s || true", joinUnambiguously(cmdArgs))
    +	}
    +	cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
    +	cmd.Dir = b.WorkDir
    +	cmd.Env = append(cmd.Environ(), "LC_ALL=C")
    +	out, _ := cmd.CombinedOutput()
    +	// GCC says "unrecognized command line option".
    +	// clang says "unknown argument".
    +	// tcc says "unsupported"
    +	// AIX says "not recognized"
    +	// Older versions of GCC say "unrecognised debug output level".
    +	// For -fsplit-stack GCC says "'-fsplit-stack' is not supported".
    +	supported := !bytes.Contains(out, []byte("unrecognized")) &&
    +		!bytes.Contains(out, []byte("unknown")) &&
    +		!bytes.Contains(out, []byte("unrecognised")) &&
    +		!bytes.Contains(out, []byte("is not supported")) &&
    +		!bytes.Contains(out, []byte("not recognized")) &&
    +		!bytes.Contains(out, []byte("unsupported"))
    +
    +	if cacheOK {
    +		s := "false"
    +		if supported {
    +			s = "true"
    +		}
    +		cache.PutBytes(cache.Default(), flagID, []byte(s))
    +	}
    +
    +	b.flagCache[key] = supported
    +	return supported
    +}
    +
    +// statString returns a string form of an os.FileInfo, for serializing and comparison.
    +func statString(info os.FileInfo) string {
    +	return fmt.Sprintf("stat %d %x %v %v\n", info.Size(), uint64(info.Mode()), info.ModTime(), info.IsDir())
    +}
    +
    +// gccCompilerID returns a build cache key for the current gcc,
    +// as identified by running 'compiler'.
    +// The caller can use subkeys of the key.
    +// Other parts of cmd/go can use the id as a hash
    +// of the installed compiler version.
    +func (b *Builder) gccCompilerID(compiler string) (id cache.ActionID, ok bool) {
    +	// We use the background shell for operations here because, while this is
    +	// triggered by some Action, it's not really about that Action, and often we
    +	// just get the results from the global cache.
    +	sh := b.BackgroundShell()
    +
    +	if cfg.BuildN {
    +		sh.ShowCmd(b.WorkDir, "%s || true", joinUnambiguously([]string{compiler, "--version"}))
    +		return cache.ActionID{}, false
    +	}
    +
    +	b.exec.Lock()
    +	defer b.exec.Unlock()
    +
    +	if id, ok := b.gccCompilerIDCache[compiler]; ok {
    +		return id, ok
    +	}
    +
    +	// We hash the compiler's full path to get a cache entry key.
    +	// That cache entry holds a validation description,
    +	// which is of the form:
    +	//
    +	//	filename \x00 statinfo \x00
    +	//	...
    +	//	compiler id
    +	//
    +	// If os.Stat of each filename matches statinfo,
    +	// then the entry is still valid, and we can use the
    +	// compiler id without any further expense.
    +	//
    +	// Otherwise, we compute a new validation description
    +	// and compiler id (below).
    +	exe, err := pathcache.LookPath(compiler)
    +	if err != nil {
    +		return cache.ActionID{}, false
    +	}
    +
    +	h := cache.NewHash("gccCompilerID")
    +	fmt.Fprintf(h, "gccCompilerID %q", exe)
    +	key := h.Sum()
    +	data, _, err := cache.GetBytes(cache.Default(), key)
    +	if err == nil && len(data) > len(id) {
    +		stats := strings.Split(string(data[:len(data)-len(id)]), "\x00")
    +		if len(stats)%2 != 0 {
    +			goto Miss
    +		}
    +		for i := 0; i+2 <= len(stats); i++ {
    +			info, err := os.Stat(stats[i])
    +			if err != nil || statString(info) != stats[i+1] {
    +				goto Miss
    +			}
    +		}
    +		copy(id[:], data[len(data)-len(id):])
    +		return id, true
    +	Miss:
    +	}
    +
    +	// Validation failed. Compute a new description (in buf) and compiler ID (in h).
    +	// For now, there are only at most two filenames in the stat information.
    +	// The first one is the compiler executable we invoke.
    +	// The second is the underlying compiler as reported by -v -###
    +	// (see b.gccToolID implementation in buildid.go).
    +	toolID, exe2, err := b.gccToolID(compiler, "c")
    +	if err != nil {
    +		return cache.ActionID{}, false
    +	}
    +
    +	exes := []string{exe, exe2}
    +	str.Uniq(&exes)
    +	fmt.Fprintf(h, "gccCompilerID %q %q\n", exes, toolID)
    +	id = h.Sum()
    +
    +	var buf bytes.Buffer
    +	for _, exe := range exes {
    +		if exe == "" {
    +			continue
    +		}
    +		info, err := os.Stat(exe)
    +		if err != nil {
    +			return cache.ActionID{}, false
    +		}
    +		buf.WriteString(exe)
    +		buf.WriteString("\x00")
    +		buf.WriteString(statString(info))
    +		buf.WriteString("\x00")
    +	}
    +	buf.Write(id[:])
    +
    +	cache.PutBytes(cache.Default(), key, buf.Bytes())
    +	if b.gccCompilerIDCache == nil {
    +		b.gccCompilerIDCache = make(map[string]cache.ActionID)
    +	}
    +	b.gccCompilerIDCache[compiler] = id
    +	return id, true
    +}
    +
    +// gccArchArgs returns arguments to pass to gcc based on the architecture.
    +func (b *Builder) gccArchArgs() []string {
    +	switch cfg.Goarch {
    +	case "386":
    +		return []string{"-m32"}
    +	case "amd64":
    +		if cfg.Goos == "darwin" {
    +			return []string{"-arch", "x86_64", "-m64"}
    +		}
    +		return []string{"-m64"}
    +	case "arm64":
    +		if cfg.Goos == "darwin" {
    +			return []string{"-arch", "arm64"}
    +		}
    +	case "arm":
    +		return []string{"-marm"} // not thumb
    +	case "s390x":
    +		// minimum supported s390x version on Go is z13
    +		return []string{"-m64", "-march=z13"}
    +	case "mips64", "mips64le":
    +		args := []string{"-mabi=64"}
    +		if cfg.GOMIPS64 == "hardfloat" {
    +			return append(args, "-mhard-float")
    +		} else if cfg.GOMIPS64 == "softfloat" {
    +			return append(args, "-msoft-float")
    +		}
    +	case "mips", "mipsle":
    +		args := []string{"-mabi=32", "-march=mips32"}
    +		if cfg.GOMIPS == "hardfloat" {
    +			return append(args, "-mhard-float", "-mfp32", "-mno-odd-spreg")
    +		} else if cfg.GOMIPS == "softfloat" {
    +			return append(args, "-msoft-float")
    +		}
    +	case "loong64":
    +		return []string{"-mabi=lp64d"}
    +	case "ppc64":
    +		if cfg.Goos == "aix" {
    +			return []string{"-maix64"}
    +		}
    +	}
    +	return nil
    +}
    +
    +// envList returns the value of the given environment variable broken
    +// into fields, using the default value when the variable is empty.
    +//
    +// The environment variable must be quoted correctly for
    +// quoted.Split. This should be done before building
    +// anything, for example, in BuildInit.
    +func envList(key, def string) []string {
    +	v := cfg.Getenv(key)
    +	if v == "" {
    +		v = def
    +	}
    +	args, err := quoted.Split(v)
    +	if err != nil {
    +		panic(fmt.Sprintf("could not parse environment variable %s with value %q: %v", key, v, err))
    +	}
    +	return args
    +}
    +
    +// CFlags returns the flags to use when invoking the C, C++ or Fortran compilers, or cgo.
    +func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) {
    +	if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
    +		return
    +	}
    +	if cflags, err = buildFlags("CFLAGS", DefaultCFlags, p.CgoCFLAGS, checkCompilerFlags); err != nil {
    +		return
    +	}
    +	if cxxflags, err = buildFlags("CXXFLAGS", DefaultCFlags, p.CgoCXXFLAGS, checkCompilerFlags); err != nil {
    +		return
    +	}
    +	if fflags, err = buildFlags("FFLAGS", DefaultCFlags, p.CgoFFLAGS, checkCompilerFlags); err != nil {
    +		return
    +	}
    +	if ldflags, err = buildFlags("LDFLAGS", DefaultCFlags, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
    +		return
    +	}
    +
    +	return
    +}
    +
    +func buildFlags(name, defaults string, fromPackage []string, check func(string, string, []string) error) ([]string, error) {
    +	if err := check(name, "#cgo "+name, fromPackage); err != nil {
    +		return nil, err
    +	}
    +	return str.StringList(envList("CGO_"+name, defaults), fromPackage), nil
    +}
    +
    +var cgoRe = lazyregexp.New(`[/\\:]`)
    +
    +type runCgoProvider struct {
    +	CFLAGS, CXXFLAGS, FFLAGS, LDFLAGS []string
    +	notCompatibleForInternalLinking   bool
    +	nonGoOverlay                      map[string]string
    +	goFiles                           []string // processed cgo files for the compiler
    +}
    +
    +func (pr *runCgoProvider) cflags() []string {
    +	return pr.CFLAGS
    +}
    +
    +func (pr *runCgoProvider) cxxflags() []string {
    +	return pr.CXXFLAGS
    +}
    +
    +func (pr *runCgoProvider) fflags() []string {
    +	return pr.CXXFLAGS
    +}
    +
    +func (pr *runCgoProvider) ldflags() []string {
    +	return pr.LDFLAGS
    +}
    +
    +func mustGetCoverInfo(a *Action) *coverProvider {
    +	for _, dep := range a.Deps {
    +		if dep.Mode == "cover" {
    +			return dep.Provider.(*coverProvider)
    +		}
    +	}
    +	base.Fatalf("internal error: cover provider not found")
    +	panic("unreachable")
    +}
    +
    +func (b *Builder) runCgo(ctx context.Context, a *Action) error {
    +	p := a.Package
    +	sh := b.Shell(a)
    +	objdir := a.Objdir
    +
    +	if err := sh.Mkdir(objdir); err != nil {
    +		return err
    +	}
    +
    +	nonGoFileLists := [][]string{p.CFiles, p.SFiles, p.CXXFiles, p.HFiles, p.FFiles}
    +	if err := b.computeNonGoOverlay(a, p, sh, objdir, nonGoFileLists); err != nil {
    +		return err
    +	}
    +
    +	cgofiles := slices.Clip(p.CgoFiles)
    +	if a.Package.Internal.Cover.Mode != "" {
    +		cp := mustGetCoverInfo(a)
    +		cgofiles = cp.cgoSources
    +	}
    +
    +	pcCFLAGS, pcLDFLAGS, err := b.getPkgConfigFlags(a, p)
    +	if err != nil {
    +		return err
    +	}
    +
    +	// Run SWIG on each .swig and .swigcxx file.
    +	// Each run will generate two files, a .go file and a .c or .cxx file.
    +	// The .go file will use import "C" and is to be processed by cgo.
    +	// For -cover test or build runs, this needs to happen after the cover
    +	// tool is run; we don't want to instrument swig-generated Go files,
    +	// see issue #64661.
    +	if p.UsesSwig() {
    +		if err := b.swig(a, objdir, pcCFLAGS); err != nil {
    +			return err
    +		}
    +		outGo, _, _ := b.swigOutputs(p, objdir)
    +		cgofiles = append(cgofiles, outGo...)
    +	}
    +
    +	cgoExe := base.Tool("cgo")
    +	cgofiles = mkAbsFiles(p.Dir, cgofiles)
    +
    +	cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p)
    +	if err != nil {
    +		return err
    +	}
    +
    +	cgoCPPFLAGS = append(cgoCPPFLAGS, pcCFLAGS...)
    +	cgoLDFLAGS = append(cgoLDFLAGS, pcLDFLAGS...)
    +	// If we are compiling Objective-C code, then we need to link against libobjc
    +	if len(p.MFiles) > 0 {
    +		cgoLDFLAGS = append(cgoLDFLAGS, "-lobjc")
    +	}
    +
    +	// Likewise for Fortran, except there are many Fortran compilers.
    +	// Support gfortran out of the box and let others pass the correct link options
    +	// via CGO_LDFLAGS
    +	if len(p.FFiles) > 0 {
    +		fc := cfg.Getenv("FC")
    +		if fc == "" {
    +			fc = "gfortran"
    +		}
    +		if strings.Contains(fc, "gfortran") {
    +			cgoLDFLAGS = append(cgoLDFLAGS, "-lgfortran")
    +		}
    +	}
    +
    +	// Scrutinize CFLAGS and related for flags that might cause
    +	// problems if we are using internal linking (for example, use of
    +	// plugins, LTO, etc) by calling a helper routine that builds on
    +	// the existing CGO flags allow-lists. If we see anything
    +	// suspicious, emit a special token file "preferlinkext" (known to
    +	// the linker) in the object file to signal the that it should not
    +	// try to link internally and should revert to external linking.
    +	// The token we pass is a suggestion, not a mandate; if a user is
    +	// explicitly asking for a specific linkmode via the "-linkmode"
    +	// flag, the token will be ignored. NB: in theory we could ditch
    +	// the token approach and just pass a flag to the linker when we
    +	// eventually invoke it, and the linker flag could then be
    +	// documented (although coming up with a simple explanation of the
    +	// flag might be challenging). For more context see issues #58619,
    +	// #58620, and #58848.
    +	flagSources := []string{"CGO_CFLAGS", "CGO_CXXFLAGS", "CGO_FFLAGS"}
    +	flagLists := [][]string{cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS}
    +	notCompatibleWithInternalLinking := flagsNotCompatibleWithInternalLinking(flagSources, flagLists)
    +
    +	if cfg.BuildMSan {
    +		cgoCFLAGS = append([]string{"-fsanitize=memory"}, cgoCFLAGS...)
    +		cgoLDFLAGS = append([]string{"-fsanitize=memory"}, cgoLDFLAGS...)
    +	}
    +	if cfg.BuildASan {
    +		cgoCFLAGS = append([]string{"-fsanitize=address"}, cgoCFLAGS...)
    +		cgoLDFLAGS = append([]string{"-fsanitize=address"}, cgoLDFLAGS...)
    +	}
    +
    +	// Allows including _cgo_export.h, as well as the user's .h files,
    +	// from .[ch] files in the package.
    +	cgoCPPFLAGS = append(cgoCPPFLAGS, "-I", objdir)
    +
    +	// cgo
    +	// TODO: CGO_FLAGS?
    +	gofiles := []string{objdir + "_cgo_gotypes.go"}
    +	cfiles := []string{objdir + "_cgo_export.c"}
    +	for _, fn := range cgofiles {
    +		f := strings.TrimSuffix(filepath.Base(fn), ".go")
    +		gofiles = append(gofiles, objdir+f+".cgo1.go")
    +		cfiles = append(cfiles, objdir+f+".cgo2.c")
    +	}
    +
    +	// TODO: make cgo not depend on $GOARCH?
    +
    +	cgoflags := []string{}
    +	if p.Standard && p.ImportPath == "runtime/cgo" {
    +		cgoflags = append(cgoflags, "-import_runtime_cgo=false")
    +	}
    +	if p.Standard && (p.ImportPath == "runtime/race" || p.ImportPath == "runtime/msan" || p.ImportPath == "runtime/cgo" || p.ImportPath == "runtime/asan") {
    +		cgoflags = append(cgoflags, "-import_syscall=false")
    +	}
    +
    +	// cgoLDFLAGS, which includes p.CgoLDFLAGS, can be very long.
    +	// Pass it to cgo on the command line, so that we use a
    +	// response file if necessary.
    +	//
    +	// These flags are recorded in the generated _cgo_gotypes.go file
    +	// using //go:cgo_ldflag directives, the compiler records them in the
    +	// object file for the package, and then the Go linker passes them
    +	// along to the host linker. At this point in the code, cgoLDFLAGS
    +	// consists of the original $CGO_LDFLAGS (unchecked) and all the
    +	// flags put together from source code (checked).
    +	cgoenv := b.cCompilerEnv()
    +	cgoenv = append(cgoenv, cfgChangedEnv...)
    +	var ldflagsOption []string
    +	if len(cgoLDFLAGS) > 0 {
    +		flags := make([]string, len(cgoLDFLAGS))
    +		for i, f := range cgoLDFLAGS {
    +			flags[i] = strconv.Quote(f)
    +		}
    +		ldflagsOption = []string{"-ldflags=" + strings.Join(flags, " ")}
    +
    +		// Remove CGO_LDFLAGS from the environment.
    +		cgoenv = append(cgoenv, "CGO_LDFLAGS=")
    +	}
    +
    +	if cfg.BuildToolchainName == "gccgo" {
    +		if b.gccSupportsFlag([]string{BuildToolchain.compiler()}, "-fsplit-stack") {
    +			cgoCFLAGS = append(cgoCFLAGS, "-fsplit-stack")
    +		}
    +		cgoflags = append(cgoflags, "-gccgo")
    +		if pkgpath := gccgoPkgpath(p); pkgpath != "" {
    +			cgoflags = append(cgoflags, "-gccgopkgpath="+pkgpath)
    +		}
    +		if !BuildToolchain.(gccgoToolchain).supportsCgoIncomplete(b, a) {
    +			cgoflags = append(cgoflags, "-gccgo_define_cgoincomplete")
    +		}
    +	}
    +
    +	switch cfg.BuildBuildmode {
    +	case "c-archive", "c-shared":
    +		// Tell cgo that if there are any exported functions
    +		// it should generate a header file that C code can
    +		// #include.
    +		cgoflags = append(cgoflags, "-exportheader="+objdir+"_cgo_install.h")
    +	}
    +
    +	// Rewrite overlaid paths in cgo files.
    +	// cgo adds //line and #line pragmas in generated files with these paths.
    +	var trimpath []string
    +	for i := range cgofiles {
    +		path := mkAbs(p.Dir, cgofiles[i])
    +		if fsys.Replaced(path) {
    +			actual := fsys.Actual(path)
    +			cgofiles[i] = actual
    +			trimpath = append(trimpath, actual+"=>"+path)
    +		}
    +	}
    +	if len(trimpath) > 0 {
    +		cgoflags = append(cgoflags, "-trimpath", strings.Join(trimpath, ";"))
    +	}
    +
    +	if err := sh.run(p.Dir, p.ImportPath, cgoenv, cfg.BuildToolexec, cgoExe, "-objdir", objdir, "-importpath", p.ImportPath, cgoflags, ldflagsOption, "--", cgoCPPFLAGS, cgoCFLAGS, cgofiles); err != nil {
    +		return err
    +	}
    +
    +	a.Provider = &runCgoProvider{
    +		CFLAGS:                          str.StringList(cgoCPPFLAGS, cgoCFLAGS),
    +		CXXFLAGS:                        str.StringList(cgoCPPFLAGS, cgoCXXFLAGS),
    +		FFLAGS:                          str.StringList(cgoCPPFLAGS, cgoFFLAGS),
    +		LDFLAGS:                         cgoLDFLAGS,
    +		notCompatibleForInternalLinking: notCompatibleWithInternalLinking,
    +		nonGoOverlay:                    a.nonGoOverlay,
    +		goFiles:                         gofiles,
    +	}
    +
    +	return nil
    +}
    +
    +func (b *Builder) processCgoOutputs(a *Action, runCgoProvider *runCgoProvider, cgoExe, objdir string) (outGo, outObj []string, err error) {
    +	outGo = slices.Clip(runCgoProvider.goFiles)
    +
    +	// TODO(matloob): Pretty much the only thing this function is doing is
    +	// producing the dynimport go files. But we should be able to compile
    +	// those separately from the package itself: we just need to get the
    +	// compiled output to the linker. That means that we can remove the
    +	// dependency of this build action on the outputs of the cgo compile actions
    +	// (though we'd still need to depend on the runCgo action of course).
    +
    +	sh := b.Shell(a)
    +
    +	// Output the preferlinkext file if the run cgo action determined this package
    +	// was not compatible for internal linking based on CFLAGS, CXXFLAGS, or FFLAGS.
    +	if runCgoProvider.notCompatibleForInternalLinking {
    +		tokenFile := objdir + "preferlinkext"
    +		if err := sh.writeFile(tokenFile, nil); err != nil {
    +			return nil, nil, err
    +		}
    +		outObj = append(outObj, tokenFile)
    +	}
    +
    +	var collectAction *Action
    +	for _, dep := range a.Deps {
    +		if dep.Mode == "collect cgo" {
    +			collectAction = dep
    +		}
    +	}
    +	if collectAction == nil {
    +		base.Fatalf("internal error: no cgo collect action")
    +	}
    +	for _, dep := range collectAction.Deps {
    +		outObj = append(outObj, dep.Target)
    +	}
    +
    +	switch cfg.BuildToolchainName {
    +	case "gc":
    +		importGo := objdir + "_cgo_import.go"
    +		dynOutGo, dynOutObj, err := b.dynimport(a, objdir, importGo, cgoExe, runCgoProvider.CFLAGS, runCgoProvider.LDFLAGS, outObj)
    +		if err != nil {
    +			return nil, nil, err
    +		}
    +		if dynOutGo != "" {
    +			outGo = append(outGo, dynOutGo)
    +		}
    +		if dynOutObj != "" {
    +			outObj = append(outObj, dynOutObj)
    +		}
    +
    +	case "gccgo":
    +		defunC := objdir + "_cgo_defun.c"
    +		defunObj := objdir + "_cgo_defun.o"
    +		if err := BuildToolchain.cc(b, a, defunObj, defunC); err != nil {
    +			return nil, nil, err
    +		}
    +		outObj = append(outObj, defunObj)
    +
    +	default:
    +		noCompiler()
    +	}
    +
    +	// Double check the //go:cgo_ldflag comments in the generated files.
    +	// The compiler only permits such comments in files whose base name
    +	// starts with "_cgo_". Make sure that the comments in those files
    +	// are safe. This is a backstop against people somehow smuggling
    +	// such a comment into a file generated by cgo.
    +	if cfg.BuildToolchainName == "gc" && !cfg.BuildN {
    +		var flags []string
    +		for _, f := range outGo {
    +			if !strings.HasPrefix(filepath.Base(f), "_cgo_") {
    +				continue
    +			}
    +
    +			src, err := os.ReadFile(f)
    +			if err != nil {
    +				return nil, nil, err
    +			}
    +
    +			const cgoLdflag = "//go:cgo_ldflag"
    +			idx := bytes.Index(src, []byte(cgoLdflag))
    +			for idx >= 0 {
    +				// We are looking at //go:cgo_ldflag.
    +				// Find start of line.
    +				start := bytes.LastIndex(src[:idx], []byte("\n"))
    +				if start == -1 {
    +					start = 0
    +				}
    +
    +				// Find end of line.
    +				end := bytes.Index(src[idx:], []byte("\n"))
    +				if end == -1 {
    +					end = len(src)
    +				} else {
    +					end += idx
    +				}
    +
    +				// Check for first line comment in line.
    +				// We don't worry about /* */ comments,
    +				// which normally won't appear in files
    +				// generated by cgo.
    +				commentStart := bytes.Index(src[start:], []byte("//"))
    +				commentStart += start
    +				// If that line comment is //go:cgo_ldflag,
    +				// it's a match.
    +				if bytes.HasPrefix(src[commentStart:], []byte(cgoLdflag)) {
    +					// Pull out the flag, and unquote it.
    +					// This is what the compiler does.
    +					flag := string(src[idx+len(cgoLdflag) : end])
    +					flag = strings.TrimSpace(flag)
    +					flag = strings.Trim(flag, `"`)
    +					flags = append(flags, flag)
    +				}
    +				src = src[end:]
    +				idx = bytes.Index(src, []byte(cgoLdflag))
    +			}
    +		}
    +
    +		// We expect to find the contents of cgoLDFLAGS used when running the CGO action in flags.
    +		if len(runCgoProvider.LDFLAGS) > 0 {
    +		outer:
    +			for i := range flags {
    +				for j, f := range runCgoProvider.LDFLAGS {
    +					if f != flags[i+j] {
    +						continue outer
    +					}
    +				}
    +				flags = append(flags[:i], flags[i+len(runCgoProvider.LDFLAGS):]...)
    +				break
    +			}
    +		}
    +
    +		if err := checkLinkerFlags("LDFLAGS", "go:cgo_ldflag", flags); err != nil {
    +			return nil, nil, err
    +		}
    +	}
    +
    +	return outGo, outObj, nil
    +}
    +
    +// flagsNotCompatibleWithInternalLinking scans the list of cgo
    +// compiler flags (C/C++/Fortran) looking for flags that might cause
    +// problems if the build in question uses internal linking. The
    +// primary culprits are use of plugins or use of LTO, but we err on
    +// the side of caution, supporting only those flags that are on the
    +// allow-list for safe flags from security perspective. Return is TRUE
    +// if a sensitive flag is found, FALSE otherwise.
    +func flagsNotCompatibleWithInternalLinking(sourceList []string, flagListList [][]string) bool {
    +	for i := range sourceList {
    +		sn := sourceList[i]
    +		fll := flagListList[i]
    +		if err := checkCompilerFlagsForInternalLink(sn, sn, fll); err != nil {
    +			return true
    +		}
    +	}
    +	return false
    +}
    +
    +// dynimport creates a Go source file named importGo containing
    +// //go:cgo_import_dynamic directives for each symbol or library
    +// dynamically imported by the object files outObj.
    +// dynOutGo, if not empty, is a new Go file to build as part of the package.
    +// dynOutObj, if not empty, is a new file to add to the generated archive.
    +func (b *Builder) dynimport(a *Action, objdir, importGo, cgoExe string, cflags, cgoLDFLAGS, outObj []string) (dynOutGo, dynOutObj string, err error) {
    +	p := a.Package
    +	sh := b.Shell(a)
    +
    +	cfile := objdir + "_cgo_main.c"
    +	ofile := objdir + "_cgo_main.o"
    +	if err := b.gcc(a, objdir, ofile, cflags, cfile); err != nil {
    +		return "", "", err
    +	}
    +
    +	// Gather .syso files from this package and all (transitive) dependencies.
    +	var syso []string
    +	seen := make(map[*Action]bool)
    +	var gatherSyso func(*Action)
    +	gatherSyso = func(a1 *Action) {
    +		if seen[a1] {
    +			return
    +		}
    +		seen[a1] = true
    +		if p1 := a1.Package; p1 != nil {
    +			syso = append(syso, mkAbsFiles(p1.Dir, p1.SysoFiles)...)
    +		}
    +		for _, a2 := range a1.Deps {
    +			gatherSyso(a2)
    +		}
    +	}
    +	gatherSyso(a)
    +	sort.Strings(syso)
    +	str.Uniq(&syso)
    +	linkobj := str.StringList(ofile, outObj, syso)
    +	dynobj := objdir + "_cgo_.o"
    +
    +	ldflags := cgoLDFLAGS
    +	if (cfg.Goarch == "arm" && cfg.Goos == "linux") || cfg.Goos == "android" {
    +		if !slices.Contains(ldflags, "-no-pie") {
    +			// we need to use -pie for Linux/ARM to get accurate imported sym (added in https://golang.org/cl/5989058)
    +			// this seems to be outdated, but we don't want to break existing builds depending on this (Issue 45940)
    +			ldflags = append(ldflags, "-pie")
    +		}
    +		if slices.Contains(ldflags, "-pie") && slices.Contains(ldflags, "-static") {
    +			// -static -pie doesn't make sense, and causes link errors.
    +			// Issue 26197.
    +			n := make([]string, 0, len(ldflags)-1)
    +			for _, flag := range ldflags {
    +				if flag != "-static" {
    +					n = append(n, flag)
    +				}
    +			}
    +			ldflags = n
    +		}
    +	}
    +	if err := b.gccld(a, objdir, dynobj, ldflags, linkobj); err != nil {
    +		// We only need this information for internal linking.
    +		// If this link fails, mark the object as requiring
    +		// external linking. This link can fail for things like
    +		// syso files that have unexpected dependencies.
    +		// cmd/link explicitly looks for the name "dynimportfail".
    +		// See issue #52863.
    +		fail := objdir + "dynimportfail"
    +		if err := sh.writeFile(fail, nil); err != nil {
    +			return "", "", err
    +		}
    +		return "", fail, nil
    +	}
    +
    +	// cgo -dynimport
    +	var cgoflags []string
    +	if p.Standard && p.ImportPath == "runtime/cgo" {
    +		cgoflags = []string{"-dynlinker"} // record path to dynamic linker
    +	}
    +	err = sh.run(base.Cwd(), p.ImportPath, b.cCompilerEnv(), cfg.BuildToolexec, cgoExe, "-dynpackage", p.Name, "-dynimport", dynobj, "-dynout", importGo, cgoflags)
    +	if err != nil {
    +		return "", "", err
    +	}
    +	return importGo, "", nil
    +}
    +
    +// Run SWIG on all SWIG input files.
    +// TODO: Don't build a shared library, once SWIG emits the necessary
    +// pragmas for external linking.
    +func (b *Builder) swig(a *Action, objdir string, pcCFLAGS []string) error {
    +	p := a.Package
    +
    +	if err := b.swigVersionCheck(); err != nil {
    +		return err
    +	}
    +
    +	intgosize, err := b.swigIntSize(objdir)
    +	if err != nil {
    +		return err
    +	}
    +
    +	for _, f := range p.SwigFiles {
    +		if err := b.swigOne(a, f, objdir, pcCFLAGS, false, intgosize); err != nil {
    +			return err
    +		}
    +	}
    +	for _, f := range p.SwigCXXFiles {
    +		if b.swigOne(a, f, objdir, pcCFLAGS, true, intgosize); err != nil {
    +			return err
    +		}
    +	}
    +	return nil
    +}
    +
    +func (b *Builder) swigOutputs(p *load.Package, objdir string) (outGo, outC, outCXX []string) {
    +	for _, f := range p.SwigFiles {
    +		goFile, cFile := swigOneOutputs(f, objdir, false)
    +		outGo = append(outGo, goFile)
    +		outC = append(outC, cFile)
    +	}
    +	for _, f := range p.SwigCXXFiles {
    +		goFile, cxxFile := swigOneOutputs(f, objdir, true)
    +		outGo = append(outGo, goFile)
    +		outCXX = append(outCXX, cxxFile)
    +	}
    +	return outGo, outC, outCXX
    +}
    +
    +// Make sure SWIG is new enough.
    +var (
    +	swigCheckOnce sync.Once
    +	swigCheck     error
    +)
    +
    +func (b *Builder) swigDoVersionCheck() error {
    +	sh := b.BackgroundShell()
    +	out, err := sh.runOut(".", nil, "swig", "-version")
    +	if err != nil {
    +		return err
    +	}
    +	re := regexp.MustCompile(`[vV]ersion +(\d+)([.]\d+)?([.]\d+)?`)
    +	matches := re.FindSubmatch(out)
    +	if matches == nil {
    +		// Can't find version number; hope for the best.
    +		return nil
    +	}
    +
    +	major, err := strconv.Atoi(string(matches[1]))
    +	if err != nil {
    +		// Can't find version number; hope for the best.
    +		return nil
    +	}
    +	const errmsg = "must have SWIG version >= 3.0.6"
    +	if major < 3 {
    +		return errors.New(errmsg)
    +	}
    +	if major > 3 {
    +		// 4.0 or later
    +		return nil
    +	}
    +
    +	// We have SWIG version 3.x.
    +	if len(matches[2]) > 0 {
    +		minor, err := strconv.Atoi(string(matches[2][1:]))
    +		if err != nil {
    +			return nil
    +		}
    +		if minor > 0 {
    +			// 3.1 or later
    +			return nil
    +		}
    +	}
    +
    +	// We have SWIG version 3.0.x.
    +	if len(matches[3]) > 0 {
    +		patch, err := strconv.Atoi(string(matches[3][1:]))
    +		if err != nil {
    +			return nil
    +		}
    +		if patch < 6 {
    +			// Before 3.0.6.
    +			return errors.New(errmsg)
    +		}
    +	}
    +
    +	return nil
    +}
    +
    +func (b *Builder) swigVersionCheck() error {
    +	swigCheckOnce.Do(func() {
    +		swigCheck = b.swigDoVersionCheck()
    +	})
    +	return swigCheck
    +}
    +
    +// Find the value to pass for the -intgosize option to swig.
    +var (
    +	swigIntSizeOnce  sync.Once
    +	swigIntSize      string
    +	swigIntSizeError error
    +)
    +
    +// This code fails to build if sizeof(int) <= 32
    +const swigIntSizeCode = `
    +package main
    +const i int = 1 << 32
    +`
    +
    +// Determine the size of int on the target system for the -intgosize option
    +// of swig >= 2.0.9. Run only once.
    +func (b *Builder) swigDoIntSize(objdir string) (intsize string, err error) {
    +	if cfg.BuildN {
    +		return "$INTBITS", nil
    +	}
    +	src := filepath.Join(b.WorkDir, "swig_intsize.go")
    +	if err = os.WriteFile(src, []byte(swigIntSizeCode), 0666); err != nil {
    +		return
    +	}
    +	srcs := []string{src}
    +
    +	p := load.GoFilesPackage(modload.NewState(), context.TODO(), load.PackageOpts{}, srcs)
    +
    +	if _, _, e := BuildToolchain.gc(b, &Action{Mode: "swigDoIntSize", Package: p, Objdir: objdir}, "", nil, nil, "", false, "", srcs); e != nil {
    +		return "32", nil
    +	}
    +	return "64", nil
    +}
    +
    +// Determine the size of int on the target system for the -intgosize option
    +// of swig >= 2.0.9.
    +func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
    +	swigIntSizeOnce.Do(func() {
    +		swigIntSize, swigIntSizeError = b.swigDoIntSize(objdir)
    +	})
    +	return swigIntSize, swigIntSizeError
    +}
    +
    +// Run SWIG on one SWIG input file.
    +func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) error {
    +	if strings.HasPrefix(file, "cgo") {
    +		return errors.New("SWIG file must not use prefix 'cgo'")
    +	}
    +
    +	p := a.Package
    +	sh := b.Shell(a)
    +
    +	cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p)
    +	if err != nil {
    +		return err
    +	}
    +
    +	var cflags []string
    +	if cxx {
    +		cflags = str.StringList(cgoCPPFLAGS, pcCFLAGS, cgoCXXFLAGS)
    +	} else {
    +		cflags = str.StringList(cgoCPPFLAGS, pcCFLAGS, cgoCFLAGS)
    +	}
    +
    +	base := swigBase(file, cxx)
    +	newGoFile, outC := swigOneOutputs(file, objdir, cxx)
    +
    +	gccgo := cfg.BuildToolchainName == "gccgo"
    +
    +	// swig
    +	args := []string{
    +		"-go",
    +		"-cgo",
    +		"-intgosize", intgosize,
    +		"-module", base,
    +		"-o", outC,
    +		"-outdir", objdir,
    +	}
    +
    +	for _, f := range cflags {
    +		if len(f) > 3 && f[:2] == "-I" {
    +			args = append(args, f)
    +		}
    +	}
    +
    +	if gccgo {
    +		args = append(args, "-gccgo")
    +		if pkgpath := gccgoPkgpath(p); pkgpath != "" {
    +			args = append(args, "-go-pkgpath", pkgpath)
    +		}
    +	}
    +	if cxx {
    +		args = append(args, "-c++")
    +	}
    +
    +	out, err := sh.runOut(p.Dir, nil, "swig", args, file)
    +	if err != nil && (bytes.Contains(out, []byte("-intgosize")) || bytes.Contains(out, []byte("-cgo"))) {
    +		return errors.New("must have SWIG version >= 3.0.6")
    +	}
    +	if err := sh.reportCmd("", "", out, err); err != nil {
    +		return err
    +	}
    +
    +	// If the input was x.swig, the output is x.go in the objdir.
    +	// But there might be an x.go in the original dir too, and if it
    +	// uses cgo as well, cgo will be processing both and will
    +	// translate both into x.cgo1.go in the objdir, overwriting one.
    +	// Rename x.go to _x_swig.go (newGoFile) to avoid this problem.
    +	// We ignore files in the original dir that begin with underscore
    +	// so _x_swig.go cannot conflict with an original file we were
    +	// going to compile.
    +	goFile := objdir + base + ".go"
    +	if cfg.BuildX || cfg.BuildN {
    +		sh.ShowCmd("", "mv %s %s", goFile, newGoFile)
    +	}
    +	if !cfg.BuildN {
    +		if err := os.Rename(goFile, newGoFile); err != nil {
    +			return err
    +		}
    +	}
    +
    +	return nil
    +}
    +
    +func swigBase(file string, cxx bool) string {
    +	n := 5 // length of ".swig"
    +	if cxx {
    +		n = 8 // length of ".swigcxx"
    +	}
    +	return file[:len(file)-n]
    +}
    +
    +func swigOneOutputs(file, objdir string, cxx bool) (outGo, outC string) {
    +	base := swigBase(file, cxx)
    +	gccBase := base + "_wrap."
    +	gccExt := "c"
    +	if cxx {
    +		gccExt = "cxx"
    +	}
    +
    +	newGoFile := objdir + "_" + base + "_swig.go"
    +	cFile := objdir + gccBase + gccExt
    +	return newGoFile, cFile
    +}
    +
    +// disableBuildID adjusts a linker command line to avoid creating a
    +// build ID when creating an object file rather than an executable or
    +// shared library. Some systems, such as Ubuntu, always add
    +// --build-id to every link, but we don't want a build ID when we are
    +// producing an object file. On some of those system a plain -r (not
    +// -Wl,-r) will turn off --build-id, but clang 3.0 doesn't support a
    +// plain -r. I don't know how to turn off --build-id when using clang
    +// other than passing a trailing --build-id=none. So that is what we
    +// do, but only on systems likely to support it, which is to say,
    +// systems that normally use gold or the GNU linker.
    +func (b *Builder) disableBuildID(ldflags []string) []string {
    +	switch cfg.Goos {
    +	case "android", "dragonfly", "linux", "netbsd":
    +		ldflags = append(ldflags, "-Wl,--build-id=none")
    +	}
    +	return ldflags
    +}
    +
    +// mkAbsFiles converts files into a list of absolute files,
    +// assuming they were originally relative to dir,
    +// and returns that new list.
    +func mkAbsFiles(dir string, files []string) []string {
    +	abs := make([]string, len(files))
    +	for i, f := range files {
    +		if !filepath.IsAbs(f) {
    +			f = filepath.Join(dir, f)
    +		}
    +		abs[i] = f
    +	}
    +	return abs
    +}
    +
    +// actualFiles applies fsys.Actual to the list of files.
    +func actualFiles(files []string) []string {
    +	a := make([]string, len(files))
    +	for i, f := range files {
    +		a[i] = fsys.Actual(f)
    +	}
    +	return a
    +}
    +
    +// passLongArgsInResponseFiles modifies cmd such that, for
    +// certain programs, long arguments are passed in "response files", a
    +// file on disk with the arguments, with one arg per line. An actual
    +// argument starting with '@' means that the rest of the argument is
    +// a filename of arguments to expand.
    +//
    +// See issues 18468 (Windows) and 37768 (Darwin).
    +func passLongArgsInResponseFiles(cmd *exec.Cmd) (cleanup func()) {
    +	cleanup = func() {} // no cleanup by default
    +
    +	var argLen int
    +	for _, arg := range cmd.Args {
    +		argLen += len(arg)
    +	}
    +
    +	// If we're not approaching 32KB of args, just pass args normally.
    +	// (use 30KB instead to be conservative; not sure how accounting is done)
    +	if !useResponseFile(cmd.Path, argLen) {
    +		return
    +	}
    +
    +	tf, err := os.CreateTemp("", "args")
    +	if err != nil {
    +		log.Fatalf("error writing long arguments to response file: %v", err)
    +	}
    +	cleanup = func() { os.Remove(tf.Name()) }
    +	var buf bytes.Buffer
    +	for _, arg := range cmd.Args[1:] {
    +		fmt.Fprintf(&buf, "%s\n", encodeArg(arg))
    +	}
    +	if _, err := tf.Write(buf.Bytes()); err != nil {
    +		tf.Close()
    +		cleanup()
    +		log.Fatalf("error writing long arguments to response file: %v", err)
    +	}
    +	if err := tf.Close(); err != nil {
    +		cleanup()
    +		log.Fatalf("error writing long arguments to response file: %v", err)
    +	}
    +	cmd.Args = []string{cmd.Args[0], "@" + tf.Name()}
    +	return cleanup
    +}
    +
    +func useResponseFile(path string, argLen int) bool {
    +	// Unless the program uses objabi.Flagparse, which understands
    +	// response files, don't use response files.
    +	// TODO: Note that other toolchains like CC are missing here for now.
    +	prog := strings.TrimSuffix(filepath.Base(path), ".exe")
    +	switch prog {
    +	case "compile", "link", "cgo", "asm", "cover":
    +	default:
    +		return false
    +	}
    +
    +	if argLen > sys.ExecArgLengthLimit {
    +		return true
    +	}
    +
    +	// On the Go build system, use response files about 10% of the
    +	// time, just to exercise this codepath.
    +	isBuilder := os.Getenv("GO_BUILDER_NAME") != ""
    +	if isBuilder && rand.Intn(10) == 0 {
    +		return true
    +	}
    +
    +	return false
    +}
    +
    +// encodeArg encodes an argument for response file writing.
    +func encodeArg(arg string) string {
    +	// If there aren't any characters we need to reencode, fastpath out.
    +	if !strings.ContainsAny(arg, "\\\n") {
    +		return arg
    +	}
    +	var b strings.Builder
    +	for _, r := range arg {
    +		switch r {
    +		case '\\':
    +			b.WriteByte('\\')
    +			b.WriteByte('\\')
    +		case '\n':
    +			b.WriteByte('\\')
    +			b.WriteByte('n')
    +		default:
    +			b.WriteRune(r)
    +		}
    +	}
    +	return b.String()
    +}
    diff --git a/go/src/cmd/go/internal/work/exec_test.go b/go/src/cmd/go/internal/work/exec_test.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..8bbf25bb337e8b44e49cf56ae3dd8dfba4aafcf7
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/exec_test.go
    @@ -0,0 +1,87 @@
    +// Copyright 2011 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package work
    +
    +import (
    +	"bytes"
    +	"cmd/internal/objabi"
    +	"cmd/internal/sys"
    +	"fmt"
    +	"math/rand"
    +	"testing"
    +	"time"
    +	"unicode/utf8"
    +)
    +
    +func TestEncodeArgs(t *testing.T) {
    +	t.Parallel()
    +	tests := []struct {
    +		arg, want string
    +	}{
    +		{"", ""},
    +		{"hello", "hello"},
    +		{"hello\n", "hello\\n"},
    +		{"hello\\", "hello\\\\"},
    +		{"hello\nthere", "hello\\nthere"},
    +		{"\\\n", "\\\\\\n"},
    +	}
    +	for _, test := range tests {
    +		if got := encodeArg(test.arg); got != test.want {
    +			t.Errorf("encodeArg(%q) = %q, want %q", test.arg, got, test.want)
    +		}
    +	}
    +}
    +
    +func TestEncodeDecode(t *testing.T) {
    +	t.Parallel()
    +	tests := []string{
    +		"",
    +		"hello",
    +		"hello\\there",
    +		"hello\nthere",
    +		"hello 中国",
    +		"hello \n中\\国",
    +	}
    +	for _, arg := range tests {
    +		if got := objabi.DecodeArg(encodeArg(arg)); got != arg {
    +			t.Errorf("objabi.DecodeArg(encodeArg(%q)) = %q", arg, got)
    +		}
    +	}
    +}
    +
    +func TestEncodeDecodeFuzz(t *testing.T) {
    +	if testing.Short() {
    +		t.Skip("fuzz test is slow")
    +	}
    +	t.Parallel()
    +
    +	nRunes := sys.ExecArgLengthLimit + 100
    +	rBuffer := make([]rune, nRunes)
    +	buf := bytes.NewBuffer([]byte(string(rBuffer)))
    +
    +	seed := time.Now().UnixNano()
    +	t.Logf("rand seed: %v", seed)
    +	rng := rand.New(rand.NewSource(seed))
    +
    +	for i := 0; i < 50; i++ {
    +		// Generate a random string of runes.
    +		buf.Reset()
    +		for buf.Len() < sys.ExecArgLengthLimit+1 {
    +			var r rune
    +			for {
    +				r = rune(rng.Intn(utf8.MaxRune + 1))
    +				if utf8.ValidRune(r) {
    +					break
    +				}
    +			}
    +			fmt.Fprintf(buf, "%c", r)
    +		}
    +		arg := buf.String()
    +
    +		if got := objabi.DecodeArg(encodeArg(arg)); got != arg {
    +			t.Errorf("[%d] objabi.DecodeArg(encodeArg(%q)) = %q [seed: %v]", i, arg, got, seed)
    +		}
    +	}
    +}
    diff --git a/go/src/cmd/go/internal/work/gc.go b/go/src/cmd/go/internal/work/gc.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..6300a9135b8af6decaeeb061e8ee939f54871446
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/gc.go
    @@ -0,0 +1,725 @@
    +// Copyright 2011 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package work
    +
    +import (
    +	"bufio"
    +	"fmt"
    +	"internal/buildcfg"
    +	"internal/platform"
    +	"io"
    +	"os"
    +	"path/filepath"
    +	"runtime"
    +	"strings"
    +	"sync"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/fips140"
    +	"cmd/go/internal/fsys"
    +	"cmd/go/internal/gover"
    +	"cmd/go/internal/load"
    +	"cmd/go/internal/str"
    +	"cmd/internal/quoted"
    +	"crypto/sha1"
    +)
    +
    +// Tests can override this by setting $TESTGO_TOOLCHAIN_VERSION.
    +var ToolchainVersion = runtime.Version()
    +
    +// The Go toolchain.
    +
    +type gcToolchain struct{}
    +
    +func (gcToolchain) compiler() string {
    +	return base.Tool("compile")
    +}
    +
    +func (gcToolchain) linker() string {
    +	return base.Tool("link")
    +}
    +
    +func pkgPath(a *Action) string {
    +	p := a.Package
    +	ppath := p.ImportPath
    +	if cfg.BuildBuildmode == "plugin" {
    +		ppath = pluginPath(a)
    +	} else if p.Name == "main" && !p.Internal.ForceLibrary {
    +		ppath = "main"
    +	}
    +	return ppath
    +}
    +
    +func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg, embedcfg []byte, symabis string, asmhdr bool, pgoProfile string, gofiles []string) (ofile string, output []byte, err error) {
    +	p := a.Package
    +	sh := b.Shell(a)
    +	objdir := a.Objdir
    +	if archive != "" {
    +		ofile = archive
    +	} else {
    +		out := "_go_.o"
    +		ofile = objdir + out
    +	}
    +
    +	pkgpath := pkgPath(a)
    +	defaultGcFlags := []string{"-p", pkgpath}
    +	vers := gover.Local()
    +	if p.Module != nil {
    +		v := p.Module.GoVersion
    +		if v == "" {
    +			v = gover.DefaultGoModVersion
    +		}
    +		// TODO(samthanawalla): Investigate when allowedVersion is not true.
    +		if allowedVersion(v) {
    +			vers = v
    +		}
    +	}
    +	defaultGcFlags = append(defaultGcFlags, "-lang=go"+gover.Lang(vers))
    +	if p.Standard {
    +		defaultGcFlags = append(defaultGcFlags, "-std")
    +	}
    +
    +	// If we're giving the compiler the entire package (no C etc files), tell it that,
    +	// so that it can give good error messages about forward declarations.
    +	// Exceptions: a few standard packages have forward declarations for
    +	// pieces supplied behind-the-scenes by package runtime.
    +	extFiles := len(p.CgoFiles) + len(p.CFiles) + len(p.CXXFiles) + len(p.MFiles) + len(p.FFiles) + len(p.SFiles) + len(p.SysoFiles) + len(p.SwigFiles) + len(p.SwigCXXFiles)
    +	if p.Standard {
    +		switch p.ImportPath {
    +		case "bytes", "internal/poll", "net", "os":
    +			fallthrough
    +		case "runtime/metrics", "runtime/pprof", "runtime/trace":
    +			fallthrough
    +		case "sync", "syscall", "time":
    +			extFiles++
    +		}
    +	}
    +	if extFiles == 0 {
    +		defaultGcFlags = append(defaultGcFlags, "-complete")
    +	}
    +	if cfg.BuildContext.InstallSuffix != "" {
    +		defaultGcFlags = append(defaultGcFlags, "-installsuffix", cfg.BuildContext.InstallSuffix)
    +	}
    +	if a.buildID != "" {
    +		defaultGcFlags = append(defaultGcFlags, "-buildid", a.buildID)
    +	}
    +	if p.Internal.OmitDebug || cfg.Goos == "plan9" || cfg.Goarch == "wasm" {
    +		defaultGcFlags = append(defaultGcFlags, "-dwarf=false")
    +	}
    +	if strings.HasPrefix(ToolchainVersion, "go1") && !strings.Contains(os.Args[0], "go_bootstrap") {
    +		defaultGcFlags = append(defaultGcFlags, "-goversion", ToolchainVersion)
    +	}
    +	if p.Internal.Cover.Cfg != "" {
    +		defaultGcFlags = append(defaultGcFlags, "-coveragecfg="+p.Internal.Cover.Cfg)
    +	}
    +	if pgoProfile != "" {
    +		defaultGcFlags = append(defaultGcFlags, "-pgoprofile="+pgoProfile)
    +	}
    +	if symabis != "" {
    +		defaultGcFlags = append(defaultGcFlags, "-symabis", symabis)
    +	}
    +
    +	gcflags := str.StringList(forcedGcflags, p.Internal.Gcflags)
    +	if p.Internal.FuzzInstrument {
    +		gcflags = append(gcflags, fuzzInstrumentFlags()...)
    +	}
    +	// Add -c=N to use concurrent backend compilation, if possible.
    +	c, release := compilerConcurrency()
    +	defer release()
    +	if c > 1 {
    +		defaultGcFlags = append(defaultGcFlags, fmt.Sprintf("-c=%d", c))
    +	}
    +
    +	args := []any{cfg.BuildToolexec, base.Tool("compile"), "-o", ofile, "-trimpath", a.trimpath(), defaultGcFlags, gcflags}
    +	if p.Internal.LocalPrefix == "" {
    +		args = append(args, "-nolocalimports")
    +	} else {
    +		args = append(args, "-D", p.Internal.LocalPrefix)
    +	}
    +	if importcfg != nil {
    +		if err := sh.writeFile(objdir+"importcfg", importcfg); err != nil {
    +			return "", nil, err
    +		}
    +		args = append(args, "-importcfg", objdir+"importcfg")
    +	}
    +	if embedcfg != nil {
    +		if err := sh.writeFile(objdir+"embedcfg", embedcfg); err != nil {
    +			return "", nil, err
    +		}
    +		args = append(args, "-embedcfg", objdir+"embedcfg")
    +	}
    +	if ofile == archive {
    +		args = append(args, "-pack")
    +	}
    +	if asmhdr {
    +		args = append(args, "-asmhdr", objdir+"go_asm.h")
    +	}
    +
    +	for _, f := range gofiles {
    +		f := mkAbs(p.Dir, f)
    +
    +		// Handle overlays. Convert path names using fsys.Actual
    +		// so these paths can be handed directly to tools.
    +		// Deleted files won't show up in when scanning directories earlier,
    +		// so Actual will never return "" (meaning a deleted file) here.
    +		// TODO(#39958): Handle cases where the package directory
    +		// doesn't exist on disk (this can happen when all the package's
    +		// files are in an overlay): the code expects the package directory
    +		// to exist and runs some tools in that directory.
    +		// TODO(#39958): Process the overlays when the
    +		// gofiles, cgofiles, cfiles, sfiles, and cxxfiles variables are
    +		// created in (*Builder).build. Doing that requires rewriting the
    +		// code that uses those values to expect absolute paths.
    +		args = append(args, fsys.Actual(f))
    +	}
    +	output, err = sh.runOut(base.Cwd(), cfgChangedEnv, args...)
    +	return ofile, output, err
    +}
    +
    +// compilerConcurrency returns the compiler concurrency level for a package compilation.
    +// The returned function must be called after the compile finishes.
    +func compilerConcurrency() (int, func()) {
    +	// Decide how many concurrent backend compilations to allow.
    +	//
    +	// If we allow too many, in theory we might end up with p concurrent processes,
    +	// each with c concurrent backend compiles, all fighting over the same resources.
    +	// However, in practice, that seems not to happen too much.
    +	// Most build graphs are surprisingly serial, so p==1 for much of the build.
    +	// Furthermore, concurrent backend compilation is only enabled for a part
    +	// of the overall compiler execution, so c==1 for much of the build.
    +	// So don't worry too much about that interaction for now.
    +	//
    +	// But to keep things reasonable, we maintain a cap on the total number of
    +	// concurrent backend compiles. (If we gave each compile action the full GOMAXPROCS, we could
    +	// potentially have GOMAXPROCS^2 running compile goroutines) In the past, we'd limit
    +	// the number of concurrent backend compiles per process to 4, which would result in a worst-case number
    +	// of backend compiles of 4*cfg.BuildP. Because some compile processes benefit from having
    +	// a larger number of compiles, especially when the compile action is the only
    +	// action running, we'll allow the max value to be larger, but ensure that the
    +	// total number of backend compiles never exceeds that previous worst-case number.
    +	// This is implemented using a pool of tokens that are given out. We'll set aside enough
    +	// tokens to make sure we don't run out, and then give half of the remaining tokens (up to
    +	// GOMAXPROCS) to each compile action that requests it.
    +	//
    +	// As a user, to limit parallelism, set GOMAXPROCS below numCPU; this may be useful
    +	// on a low-memory builder, or if a deterministic build order is required.
    +	if cfg.BuildP == 1 {
    +		// No process parallelism, do not cap compiler parallelism.
    +		return maxCompilerConcurrency, func() {}
    +	}
    +
    +	// Cap compiler parallelism using the pool.
    +	tokensMu.Lock()
    +	defer tokensMu.Unlock()
    +	concurrentProcesses++
    +	// Set aside tokens so that we don't run out if we were running cfg.BuildP concurrent compiles.
    +	// We'll set aside one token for each of the action goroutines that aren't currently running a compile.
    +	setAside := (cfg.BuildP - concurrentProcesses) * minTokens
    +	availableTokens := tokens - setAside
    +	// Grab half the remaining tokens: but with a floor of at least minTokens token, and
    +	// a ceiling of the max backend concurrency.
    +	c := max(min(availableTokens/2, maxCompilerConcurrency), minTokens)
    +	tokens -= c
    +	// Successfully grabbed the tokens.
    +	return c, func() {
    +		tokensMu.Lock()
    +		defer tokensMu.Unlock()
    +		concurrentProcesses--
    +		tokens += c
    +	}
    +}
    +
    +var maxCompilerConcurrency = runtime.GOMAXPROCS(0) // max value we will use for -c
    +
    +var (
    +	tokensMu            sync.Mutex
    +	totalTokens         int // total number of tokens: this is used for checking that we get them all back in the end
    +	tokens              int // number of available tokens
    +	concurrentProcesses int // number of currently running compiles
    +	minTokens           int // minimum number of tokens to give out
    +)
    +
    +// initCompilerConcurrencyPool sets the number of tokens in the pool. It needs
    +// to be run after init, so that it can use the value of cfg.BuildP.
    +func initCompilerConcurrencyPool() {
    +	// Size the pool to allow 2*maxCompilerConcurrency extra tokens to
    +	// be distributed amongst the compile actions in addition to the minimum
    +	// of min(4,GOMAXPROCS) tokens for each of the potentially cfg.BuildP
    +	// concurrently running compile actions.
    +	minTokens = min(4, maxCompilerConcurrency)
    +	tokens = 2*maxCompilerConcurrency + minTokens*cfg.BuildP
    +	totalTokens = tokens
    +}
    +
    +// trimpath returns the -trimpath argument to use
    +// when compiling the action.
    +func (a *Action) trimpath() string {
    +	// Keep in sync with Builder.ccompile
    +	// The trimmed paths are a little different, but we need to trim in the
    +	// same situations.
    +
    +	// Strip the object directory entirely.
    +	objdir := strings.TrimSuffix(a.Objdir, string(filepath.Separator))
    +	rewrite := ""
    +
    +	rewriteDir := a.Package.Dir
    +	if cfg.BuildTrimpath {
    +		importPath := a.Package.Internal.OrigImportPath
    +		if m := a.Package.Module; m != nil && m.Version != "" {
    +			rewriteDir = m.Path + "@" + m.Version + strings.TrimPrefix(importPath, m.Path)
    +		} else {
    +			rewriteDir = importPath
    +		}
    +		rewrite += a.Package.Dir + "=>" + rewriteDir + ";"
    +	}
    +
    +	// Add rewrites for overlays. The 'from' and 'to' paths in overlays don't need to have
    +	// same basename, so go from the overlay contents file path (passed to the compiler)
    +	// to the path the disk path would be rewritten to.
    +
    +	cgoFiles := make(map[string]bool)
    +	for _, f := range a.Package.CgoFiles {
    +		cgoFiles[f] = true
    +	}
    +
    +	// TODO(matloob): Higher up in the stack, when the logic for deciding when to make copies
    +	// of c/c++/m/f/hfiles is consolidated, use the same logic that Build uses to determine
    +	// whether to create the copies in objdir to decide whether to rewrite objdir to the
    +	// package directory here.
    +	var overlayNonGoRewrites string // rewrites for non-go files
    +	hasCgoOverlay := false
    +	if fsys.OverlayFile != "" {
    +		for _, filename := range a.Package.AllFiles() {
    +			path := filename
    +			if !filepath.IsAbs(path) {
    +				path = filepath.Join(a.Package.Dir, path)
    +			}
    +			base := filepath.Base(path)
    +			isGo := strings.HasSuffix(filename, ".go") || strings.HasSuffix(filename, ".s")
    +			isCgo := cgoFiles[filename] || !isGo
    +			if fsys.Replaced(path) {
    +				if isCgo {
    +					hasCgoOverlay = true
    +				} else {
    +					rewrite += fsys.Actual(path) + "=>" + filepath.Join(rewriteDir, base) + ";"
    +				}
    +			} else if isCgo {
    +				// Generate rewrites for non-Go files copied to files in objdir.
    +				if filepath.Dir(path) == a.Package.Dir {
    +					// This is a file copied to objdir.
    +					overlayNonGoRewrites += filepath.Join(objdir, base) + "=>" + filepath.Join(rewriteDir, base) + ";"
    +				}
    +			} else {
    +				// Non-overlay Go files are covered by the a.Package.Dir rewrite rule above.
    +			}
    +		}
    +	}
    +	if hasCgoOverlay {
    +		rewrite += overlayNonGoRewrites
    +	}
    +	rewrite += objdir + "=>"
    +
    +	return rewrite
    +}
    +
    +func asmArgs(a *Action, p *load.Package) []any {
    +	// Add -I pkg/GOOS_GOARCH so #include "textflag.h" works in .s files.
    +	inc := filepath.Join(cfg.GOROOT, "pkg", "include")
    +	pkgpath := pkgPath(a)
    +	args := []any{cfg.BuildToolexec, base.Tool("asm"), "-p", pkgpath, "-trimpath", a.trimpath(), "-I", a.Objdir, "-I", inc, "-D", "GOOS_" + cfg.Goos, "-D", "GOARCH_" + cfg.Goarch, forcedAsmflags, p.Internal.Asmflags}
    +	if p.ImportPath == "runtime" && cfg.Goarch == "386" {
    +		for _, arg := range forcedAsmflags {
    +			if arg == "-dynlink" {
    +				args = append(args, "-D=GOBUILDMODE_shared=1")
    +			}
    +		}
    +	}
    +
    +	if cfg.Goarch == "386" {
    +		// Define GO386_value from cfg.GO386.
    +		args = append(args, "-D", "GO386_"+cfg.GO386)
    +	}
    +
    +	if cfg.Goarch == "amd64" {
    +		// Define GOAMD64_value from cfg.GOAMD64.
    +		args = append(args, "-D", "GOAMD64_"+cfg.GOAMD64)
    +	}
    +
    +	if cfg.Goarch == "mips" || cfg.Goarch == "mipsle" {
    +		// Define GOMIPS_value from cfg.GOMIPS.
    +		args = append(args, "-D", "GOMIPS_"+cfg.GOMIPS)
    +	}
    +
    +	if cfg.Goarch == "mips64" || cfg.Goarch == "mips64le" {
    +		// Define GOMIPS64_value from cfg.GOMIPS64.
    +		args = append(args, "-D", "GOMIPS64_"+cfg.GOMIPS64)
    +	}
    +
    +	if cfg.Goarch == "ppc64" || cfg.Goarch == "ppc64le" {
    +		// Define GOPPC64_power8..N from cfg.PPC64.
    +		// We treat each powerpc version as a superset of functionality.
    +		switch cfg.GOPPC64 {
    +		case "power10":
    +			args = append(args, "-D", "GOPPC64_power10")
    +			fallthrough
    +		case "power9":
    +			args = append(args, "-D", "GOPPC64_power9")
    +			fallthrough
    +		default: // This should always be power8.
    +			args = append(args, "-D", "GOPPC64_power8")
    +		}
    +	}
    +
    +	if cfg.Goarch == "riscv64" {
    +		// Define GORISCV64_value from cfg.GORISCV64.
    +		args = append(args, "-D", "GORISCV64_"+cfg.GORISCV64)
    +	}
    +
    +	if cfg.Goarch == "arm" {
    +		// Define GOARM_value from cfg.GOARM, which can be either a version
    +		// like "6", or a version and a FP mode, like "7,hardfloat".
    +		switch {
    +		case strings.Contains(cfg.GOARM, "7"):
    +			args = append(args, "-D", "GOARM_7")
    +			fallthrough
    +		case strings.Contains(cfg.GOARM, "6"):
    +			args = append(args, "-D", "GOARM_6")
    +			fallthrough
    +		default:
    +			args = append(args, "-D", "GOARM_5")
    +		}
    +	}
    +
    +	if cfg.Goarch == "arm64" {
    +		g, err := buildcfg.ParseGoarm64(cfg.GOARM64)
    +		if err == nil && g.LSE {
    +			args = append(args, "-D", "GOARM64_LSE")
    +		}
    +	}
    +
    +	return args
    +}
    +
    +func (gcToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error) {
    +	p := a.Package
    +	args := asmArgs(a, p)
    +
    +	var ofiles []string
    +	for _, sfile := range sfiles {
    +		ofile := a.Objdir + sfile[:len(sfile)-len(".s")] + ".o"
    +		ofiles = append(ofiles, ofile)
    +		args1 := append(args, "-o", ofile, fsys.Actual(mkAbs(p.Dir, sfile)))
    +		if err := b.Shell(a).run(p.Dir, p.ImportPath, cfgChangedEnv, args1...); err != nil {
    +			return nil, err
    +		}
    +	}
    +	return ofiles, nil
    +}
    +
    +func (gcToolchain) symabis(b *Builder, a *Action, sfiles []string) (string, error) {
    +	sh := b.Shell(a)
    +
    +	mkSymabis := func(p *load.Package, sfiles []string, path string) error {
    +		args := asmArgs(a, p)
    +		args = append(args, "-gensymabis", "-o", path)
    +		for _, sfile := range sfiles {
    +			if p.ImportPath == "runtime/cgo" && strings.HasPrefix(sfile, "gcc_") {
    +				continue
    +			}
    +			args = append(args, fsys.Actual(mkAbs(p.Dir, sfile)))
    +		}
    +
    +		// Supply an empty go_asm.h as if the compiler had been run.
    +		// -gensymabis parsing is lax enough that we don't need the
    +		// actual definitions that would appear in go_asm.h.
    +		if err := sh.writeFile(a.Objdir+"go_asm.h", nil); err != nil {
    +			return err
    +		}
    +
    +		return sh.run(p.Dir, p.ImportPath, cfgChangedEnv, args...)
    +	}
    +
    +	var symabis string // Only set if we actually create the file
    +	p := a.Package
    +	if len(sfiles) != 0 {
    +		symabis = a.Objdir + "symabis"
    +		if err := mkSymabis(p, sfiles, symabis); err != nil {
    +			return "", err
    +		}
    +	}
    +
    +	return symabis, nil
    +}
    +
    +func (gcToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) error {
    +	absOfiles := make([]string, 0, len(ofiles))
    +	for _, f := range ofiles {
    +		absOfiles = append(absOfiles, mkAbs(a.Objdir, f))
    +	}
    +	absAfile := mkAbs(a.Objdir, afile)
    +
    +	// The archive file should have been created by the compiler.
    +	// Since it used to not work that way, verify.
    +	if !cfg.BuildN {
    +		if _, err := os.Stat(absAfile); err != nil {
    +			base.Fatalf("os.Stat of archive file failed: %v", err)
    +		}
    +	}
    +
    +	p := a.Package
    +	sh := b.Shell(a)
    +	if cfg.BuildN || cfg.BuildX {
    +		cmdline := str.StringList("go", "tool", "pack", "r", absAfile, absOfiles)
    +		sh.ShowCmd(p.Dir, "%s # internal", joinUnambiguously(cmdline))
    +	}
    +	if cfg.BuildN {
    +		return nil
    +	}
    +	if err := packInternal(absAfile, absOfiles); err != nil {
    +		return sh.reportCmd("", "", nil, err)
    +	}
    +	return nil
    +}
    +
    +func packInternal(afile string, ofiles []string) error {
    +	dst, err := os.OpenFile(afile, os.O_WRONLY|os.O_APPEND, 0)
    +	if err != nil {
    +		return err
    +	}
    +	defer dst.Close() // only for error returns or panics
    +	w := bufio.NewWriter(dst)
    +
    +	for _, ofile := range ofiles {
    +		src, err := os.Open(ofile)
    +		if err != nil {
    +			return err
    +		}
    +		fi, err := src.Stat()
    +		if err != nil {
    +			src.Close()
    +			return err
    +		}
    +		// Note: Not using %-16.16s format because we care
    +		// about bytes, not runes.
    +		name := fi.Name()
    +		if len(name) > 16 {
    +			name = name[:16]
    +		} else {
    +			name += strings.Repeat(" ", 16-len(name))
    +		}
    +		size := fi.Size()
    +		fmt.Fprintf(w, "%s%-12d%-6d%-6d%-8o%-10d`\n",
    +			name, 0, 0, 0, 0644, size)
    +		n, err := io.Copy(w, src)
    +		src.Close()
    +		if err == nil && n < size {
    +			err = io.ErrUnexpectedEOF
    +		} else if err == nil && n > size {
    +			err = fmt.Errorf("file larger than size reported by stat")
    +		}
    +		if err != nil {
    +			return fmt.Errorf("copying %s to %s: %v", ofile, afile, err)
    +		}
    +		if size&1 != 0 {
    +			w.WriteByte(0)
    +		}
    +	}
    +
    +	if err := w.Flush(); err != nil {
    +		return err
    +	}
    +	return dst.Close()
    +}
    +
    +// setextld sets the appropriate linker flags for the specified compiler.
    +func setextld(ldflags []string, compiler []string) ([]string, error) {
    +	for _, f := range ldflags {
    +		if f == "-extld" || strings.HasPrefix(f, "-extld=") {
    +			// don't override -extld if supplied
    +			return ldflags, nil
    +		}
    +	}
    +	joined, err := quoted.Join(compiler)
    +	if err != nil {
    +		return nil, err
    +	}
    +	return append(ldflags, "-extld="+joined), nil
    +}
    +
    +// pluginPath computes the package path for a plugin main package.
    +//
    +// This is typically the import path of the main package p, unless the
    +// plugin is being built directly from source files. In that case we
    +// combine the package build ID with the contents of the main package
    +// source files. This allows us to identify two different plugins
    +// built from two source files with the same name.
    +func pluginPath(a *Action) string {
    +	p := a.Package
    +	if p.ImportPath != "command-line-arguments" {
    +		return p.ImportPath
    +	}
    +	h := sha1.New()
    +	buildID := a.buildID
    +	if a.Mode == "link" {
    +		// For linking, use the main package's build ID instead of
    +		// the binary's build ID, so it is the same hash used in
    +		// compiling and linking.
    +		// When compiling, we use actionID/actionID (instead of
    +		// actionID/contentID) as a temporary build ID to compute
    +		// the hash. Do the same here. (See buildid.go:useCache)
    +		// The build ID matters because it affects the overall hash
    +		// in the plugin's pseudo-import path returned below.
    +		// We need to use the same import path when compiling and linking.
    +		id := strings.Split(buildID, buildIDSeparator)
    +		buildID = id[1] + buildIDSeparator + id[1]
    +	}
    +	fmt.Fprintf(h, "build ID: %s\n", buildID)
    +	for _, file := range str.StringList(p.GoFiles, p.CgoFiles, p.SFiles) {
    +		data, err := os.ReadFile(filepath.Join(p.Dir, file))
    +		if err != nil {
    +			base.Fatalf("go: %s", err)
    +		}
    +		h.Write(data)
    +	}
    +	return fmt.Sprintf("plugin/unnamed-%x", h.Sum(nil))
    +}
    +
    +func (gcToolchain) ld(b *Builder, root *Action, targetPath, importcfg, mainpkg string) error {
    +	cxx := len(root.Package.CXXFiles) > 0 || len(root.Package.SwigCXXFiles) > 0
    +	for _, a := range root.Deps {
    +		if a.Package != nil && (len(a.Package.CXXFiles) > 0 || len(a.Package.SwigCXXFiles) > 0) {
    +			cxx = true
    +		}
    +	}
    +	var ldflags []string
    +	if cfg.BuildContext.InstallSuffix != "" {
    +		ldflags = append(ldflags, "-installsuffix", cfg.BuildContext.InstallSuffix)
    +	}
    +	if root.Package.Internal.OmitDebug {
    +		ldflags = append(ldflags, "-s", "-w")
    +	}
    +	if cfg.BuildBuildmode == "plugin" {
    +		ldflags = append(ldflags, "-pluginpath", pluginPath(root))
    +	}
    +	if fips140.Enabled() {
    +		ldflags = append(ldflags, "-fipso", filepath.Join(root.Objdir, "fips.o"))
    +	}
    +
    +	// Store BuildID inside toolchain binaries as a unique identifier of the
    +	// tool being run, for use by content-based staleness determination.
    +	if root.Package.Goroot && strings.HasPrefix(root.Package.ImportPath, "cmd/") {
    +		// External linking will include our build id in the external
    +		// linker's build id, which will cause our build id to not
    +		// match the next time the tool is built.
    +		// Rely on the external build id instead.
    +		if !platform.MustLinkExternal(cfg.Goos, cfg.Goarch, false) {
    +			ldflags = append(ldflags, "-X=cmd/internal/objabi.buildID="+root.buildID)
    +		}
    +	}
    +
    +	// Store default GODEBUG in binaries.
    +	if root.Package.DefaultGODEBUG != "" {
    +		ldflags = append(ldflags, "-X=runtime.godebugDefault="+root.Package.DefaultGODEBUG)
    +	}
    +
    +	// If the user has not specified the -extld option, then specify the
    +	// appropriate linker. In case of C++ code, use the compiler named
    +	// by the CXX environment variable or defaultCXX if CXX is not set.
    +	// Else, use the CC environment variable and defaultCC as fallback.
    +	var compiler []string
    +	if cxx {
    +		compiler = envList("CXX", cfg.DefaultCXX(cfg.Goos, cfg.Goarch))
    +	} else {
    +		compiler = envList("CC", cfg.DefaultCC(cfg.Goos, cfg.Goarch))
    +	}
    +	ldflags = append(ldflags, "-buildmode="+ldBuildmode)
    +	if root.buildID != "" {
    +		ldflags = append(ldflags, "-buildid="+root.buildID)
    +	}
    +	ldflags = append(ldflags, forcedLdflags...)
    +	ldflags = append(ldflags, root.Package.Internal.Ldflags...)
    +	ldflags, err := setextld(ldflags, compiler)
    +	if err != nil {
    +		return err
    +	}
    +
    +	// On OS X when using external linking to build a shared library,
    +	// the argument passed here to -o ends up recorded in the final
    +	// shared library in the LC_ID_DYLIB load command.
    +	// To avoid putting the temporary output directory name there
    +	// (and making the resulting shared library useless),
    +	// run the link in the output directory so that -o can name
    +	// just the final path element.
    +	// On Windows, DLL file name is recorded in PE file
    +	// export section, so do like on OS X.
    +	// On Linux, for a shared object, at least with the Gold linker,
    +	// the output file path is recorded in the .gnu.version_d section.
    +	dir := "."
    +	if cfg.BuildBuildmode == "c-shared" || cfg.BuildBuildmode == "plugin" {
    +		dir, targetPath = filepath.Split(targetPath)
    +	}
    +
    +	env := cfgChangedEnv
    +	// When -trimpath is used, GOROOT is cleared
    +	if cfg.BuildTrimpath {
    +		env = append(env, "GOROOT=")
    +	} else {
    +		env = append(env, "GOROOT="+cfg.GOROOT)
    +	}
    +	return b.Shell(root).run(dir, root.Package.ImportPath, env, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags, mainpkg)
    +}
    +
    +func (gcToolchain) ldShared(b *Builder, root *Action, toplevelactions []*Action, targetPath, importcfg string, allactions []*Action) error {
    +	ldflags := []string{"-installsuffix", cfg.BuildContext.InstallSuffix}
    +	ldflags = append(ldflags, "-buildmode=shared")
    +	ldflags = append(ldflags, forcedLdflags...)
    +	ldflags = append(ldflags, root.Package.Internal.Ldflags...)
    +	cxx := false
    +	for _, a := range allactions {
    +		if a.Package != nil && (len(a.Package.CXXFiles) > 0 || len(a.Package.SwigCXXFiles) > 0) {
    +			cxx = true
    +		}
    +	}
    +	// If the user has not specified the -extld option, then specify the
    +	// appropriate linker. In case of C++ code, use the compiler named
    +	// by the CXX environment variable or defaultCXX if CXX is not set.
    +	// Else, use the CC environment variable and defaultCC as fallback.
    +	var compiler []string
    +	if cxx {
    +		compiler = envList("CXX", cfg.DefaultCXX(cfg.Goos, cfg.Goarch))
    +	} else {
    +		compiler = envList("CC", cfg.DefaultCC(cfg.Goos, cfg.Goarch))
    +	}
    +	ldflags, err := setextld(ldflags, compiler)
    +	if err != nil {
    +		return err
    +	}
    +	for _, d := range toplevelactions {
    +		if !strings.HasSuffix(d.Target, ".a") { // omit unsafe etc and actions for other shared libraries
    +			continue
    +		}
    +		ldflags = append(ldflags, d.Package.ImportPath+"="+d.Target)
    +	}
    +
    +	// On OS X when using external linking to build a shared library,
    +	// the argument passed here to -o ends up recorded in the final
    +	// shared library in the LC_ID_DYLIB load command.
    +	// To avoid putting the temporary output directory name there
    +	// (and making the resulting shared library useless),
    +	// run the link in the output directory so that -o can name
    +	// just the final path element.
    +	// On Windows, DLL file name is recorded in PE file
    +	// export section, so do like on OS X.
    +	// On Linux, for a shared object, at least with the Gold linker,
    +	// the output file path is recorded in the .gnu.version_d section.
    +	dir, targetPath := filepath.Split(targetPath)
    +
    +	return b.Shell(root).run(dir, targetPath, cfgChangedEnv, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags)
    +}
    +
    +func (gcToolchain) cc(b *Builder, a *Action, ofile, cfile string) error {
    +	return fmt.Errorf("%s: C source files not supported without cgo", mkAbs(a.Package.Dir, cfile))
    +}
    diff --git a/go/src/cmd/go/internal/work/gccgo.go b/go/src/cmd/go/internal/work/gccgo.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..276e082b71ba55c209a386dfbe8a3704ab471452
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/gccgo.go
    @@ -0,0 +1,678 @@
    +// Copyright 2011 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package work
    +
    +import (
    +	"bytes"
    +	"fmt"
    +	"os"
    +	"os/exec"
    +	"path/filepath"
    +	"strings"
    +	"sync"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/fsys"
    +	"cmd/go/internal/load"
    +	"cmd/go/internal/str"
    +	"cmd/internal/pathcache"
    +	"cmd/internal/pkgpath"
    +)
    +
    +// The Gccgo toolchain.
    +
    +type gccgoToolchain struct{}
    +
    +var GccgoName, GccgoBin string
    +var GccgoChanged bool
    +var gccgoErr error
    +
    +func init() {
    +	GccgoName = cfg.Getenv("GCCGO")
    +	if GccgoName == "" {
    +		GccgoName = "gccgo"
    +	}
    +	if GccgoName != "gccgo" {
    +		GccgoChanged = true
    +	}
    +	GccgoBin, gccgoErr = pathcache.LookPath(GccgoName)
    +}
    +
    +func (gccgoToolchain) compiler() string {
    +	checkGccgoBin()
    +	return GccgoBin
    +}
    +
    +func (gccgoToolchain) linker() string {
    +	checkGccgoBin()
    +	return GccgoBin
    +}
    +
    +func (gccgoToolchain) ar() []string {
    +	return envList("AR", "ar")
    +}
    +
    +func checkGccgoBin() {
    +	if gccgoErr == nil {
    +		return
    +	}
    +	fmt.Fprintf(os.Stderr, "cmd/go: gccgo: %s\n", gccgoErr)
    +	base.SetExitStatus(2)
    +	base.Exit()
    +}
    +
    +func (tools gccgoToolchain) gc(b *Builder, a *Action, archive string, importcfg, embedcfg []byte, symabis string, asmhdr bool, pgoProfile string, gofiles []string) (ofile string, output []byte, err error) {
    +	p := a.Package
    +	sh := b.Shell(a)
    +	objdir := a.Objdir
    +	out := "_go_.o"
    +	ofile = objdir + out
    +	gcargs := []string{"-g"}
    +	gcargs = append(gcargs, b.gccArchArgs()...)
    +	gcargs = append(gcargs, "-fdebug-prefix-map="+b.WorkDir+"=/tmp/go-build")
    +	gcargs = append(gcargs, "-gno-record-gcc-switches")
    +	if pkgpath := gccgoPkgpath(p); pkgpath != "" {
    +		gcargs = append(gcargs, "-fgo-pkgpath="+pkgpath)
    +	}
    +	if p.Internal.LocalPrefix != "" {
    +		gcargs = append(gcargs, "-fgo-relative-import-path="+p.Internal.LocalPrefix)
    +	}
    +
    +	args := str.StringList(tools.compiler(), "-c", gcargs, "-o", ofile, forcedGccgoflags)
    +	if importcfg != nil {
    +		if b.gccSupportsFlag(args[:1], "-fgo-importcfg=/dev/null") {
    +			if err := sh.writeFile(objdir+"importcfg", importcfg); err != nil {
    +				return "", nil, err
    +			}
    +			args = append(args, "-fgo-importcfg="+objdir+"importcfg")
    +		} else {
    +			root := objdir + "_importcfgroot_"
    +			if err := buildImportcfgSymlinks(sh, root, importcfg); err != nil {
    +				return "", nil, err
    +			}
    +			args = append(args, "-I", root)
    +		}
    +	}
    +	if embedcfg != nil && b.gccSupportsFlag(args[:1], "-fgo-embedcfg=/dev/null") {
    +		if err := sh.writeFile(objdir+"embedcfg", embedcfg); err != nil {
    +			return "", nil, err
    +		}
    +		args = append(args, "-fgo-embedcfg="+objdir+"embedcfg")
    +	}
    +
    +	if b.gccSupportsFlag(args[:1], "-ffile-prefix-map=a=b") {
    +		if cfg.BuildTrimpath {
    +			args = append(args, "-ffile-prefix-map="+base.Cwd()+"=.")
    +			args = append(args, "-ffile-prefix-map="+b.WorkDir+"=/tmp/go-build")
    +		}
    +		if fsys.OverlayFile != "" {
    +			for _, name := range gofiles {
    +				absPath := mkAbs(p.Dir, name)
    +				if !fsys.Replaced(absPath) {
    +					continue
    +				}
    +				toPath := absPath
    +				// gccgo only applies the last matching rule, so also handle the case where
    +				// BuildTrimpath is true and the path is relative to base.Cwd().
    +				if cfg.BuildTrimpath && str.HasFilePathPrefix(toPath, base.Cwd()) {
    +					toPath = "." + toPath[len(base.Cwd()):]
    +				}
    +				args = append(args, "-ffile-prefix-map="+fsys.Actual(absPath)+"="+toPath)
    +			}
    +		}
    +	}
    +
    +	args = append(args, a.Package.Internal.Gccgoflags...)
    +	for _, f := range gofiles {
    +		f := mkAbs(p.Dir, f)
    +		// Overlay files if necessary.
    +		// See comment on gctoolchain.gc about overlay TODOs
    +		args = append(args, fsys.Actual(f))
    +	}
    +
    +	output, err = sh.runOut(p.Dir, nil, args)
    +	return ofile, output, err
    +}
    +
    +// buildImportcfgSymlinks builds in root a tree of symlinks
    +// implementing the directives from importcfg.
    +// This serves as a temporary transition mechanism until
    +// we can depend on gccgo reading an importcfg directly.
    +// (The Go 1.9 and later gc compilers already do.)
    +func buildImportcfgSymlinks(sh *Shell, root string, importcfg []byte) error {
    +	for lineNum, line := range strings.Split(string(importcfg), "\n") {
    +		lineNum++ // 1-based
    +		line = strings.TrimSpace(line)
    +		if line == "" {
    +			continue
    +		}
    +		if line == "" || strings.HasPrefix(line, "#") {
    +			continue
    +		}
    +		var verb, args string
    +		if i := strings.Index(line, " "); i < 0 {
    +			verb = line
    +		} else {
    +			verb, args = line[:i], strings.TrimSpace(line[i+1:])
    +		}
    +		before, after, _ := strings.Cut(args, "=")
    +		switch verb {
    +		default:
    +			base.Fatalf("importcfg:%d: unknown directive %q", lineNum, verb)
    +		case "packagefile":
    +			if before == "" || after == "" {
    +				return fmt.Errorf(`importcfg:%d: invalid packagefile: syntax is "packagefile path=filename": %s`, lineNum, line)
    +			}
    +			archive := gccgoArchive(root, before)
    +			if err := sh.Mkdir(filepath.Dir(archive)); err != nil {
    +				return err
    +			}
    +			if err := sh.Symlink(after, archive); err != nil {
    +				return err
    +			}
    +		case "importmap":
    +			if before == "" || after == "" {
    +				return fmt.Errorf(`importcfg:%d: invalid importmap: syntax is "importmap old=new": %s`, lineNum, line)
    +			}
    +			beforeA := gccgoArchive(root, before)
    +			afterA := gccgoArchive(root, after)
    +			if err := sh.Mkdir(filepath.Dir(beforeA)); err != nil {
    +				return err
    +			}
    +			if err := sh.Mkdir(filepath.Dir(afterA)); err != nil {
    +				return err
    +			}
    +			if err := sh.Symlink(afterA, beforeA); err != nil {
    +				return err
    +			}
    +		case "packageshlib":
    +			return fmt.Errorf("gccgo -importcfg does not support shared libraries")
    +		}
    +	}
    +	return nil
    +}
    +
    +func (tools gccgoToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error) {
    +	p := a.Package
    +	var ofiles []string
    +	for _, sfile := range sfiles {
    +		base := filepath.Base(sfile)
    +		ofile := a.Objdir + base[:len(base)-len(".s")] + ".o"
    +		ofiles = append(ofiles, ofile)
    +		sfile = fsys.Actual(mkAbs(p.Dir, sfile))
    +		defs := []string{"-D", "GOOS_" + cfg.Goos, "-D", "GOARCH_" + cfg.Goarch}
    +		if pkgpath := tools.gccgoCleanPkgpath(b, p); pkgpath != "" {
    +			defs = append(defs, `-D`, `GOPKGPATH=`+pkgpath)
    +		}
    +		defs = tools.maybePIC(defs)
    +		defs = append(defs, b.gccArchArgs()...)
    +		err := b.Shell(a).run(p.Dir, p.ImportPath, nil, tools.compiler(), "-xassembler-with-cpp", "-I", a.Objdir, "-c", "-o", ofile, defs, sfile)
    +		if err != nil {
    +			return nil, err
    +		}
    +	}
    +	return ofiles, nil
    +}
    +
    +func (gccgoToolchain) symabis(b *Builder, a *Action, sfiles []string) (string, error) {
    +	return "", nil
    +}
    +
    +func gccgoArchive(basedir, imp string) string {
    +	end := filepath.FromSlash(imp + ".a")
    +	afile := filepath.Join(basedir, end)
    +	// add "lib" to the final element
    +	return filepath.Join(filepath.Dir(afile), "lib"+filepath.Base(afile))
    +}
    +
    +func (tools gccgoToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) error {
    +	p := a.Package
    +	sh := b.Shell(a)
    +	objdir := a.Objdir
    +	absOfiles := make([]string, 0, len(ofiles))
    +	for _, f := range ofiles {
    +		absOfiles = append(absOfiles, mkAbs(objdir, f))
    +	}
    +	var arArgs []string
    +	if cfg.Goos == "aix" && cfg.Goarch == "ppc64" {
    +		// AIX puts both 32-bit and 64-bit objects in the same archive.
    +		// Tell the AIX "ar" command to only care about 64-bit objects.
    +		arArgs = []string{"-X64"}
    +	}
    +	absAfile := mkAbs(objdir, afile)
    +	// Try with D modifier first, then without if that fails.
    +	output, err := sh.runOut(p.Dir, nil, tools.ar(), arArgs, "rcD", absAfile, absOfiles)
    +	if err != nil {
    +		return sh.run(p.Dir, p.ImportPath, nil, tools.ar(), arArgs, "rc", absAfile, absOfiles)
    +	}
    +
    +	// Show the output if there is any even without errors.
    +	return sh.reportCmd("", "", output, nil)
    +}
    +
    +func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string, allactions []*Action, buildmode, desc string) error {
    +	sh := b.Shell(root)
    +
    +	// gccgo needs explicit linking with all package dependencies,
    +	// and all LDFLAGS from cgo dependencies.
    +	afiles := []string{}
    +	shlibs := []string{}
    +	ldflags := b.gccArchArgs()
    +	cgoldflags := []string{}
    +	usesCgo := false
    +	cxx := false
    +	objc := false
    +	fortran := false
    +	if root.Package != nil {
    +		cxx = len(root.Package.CXXFiles) > 0 || len(root.Package.SwigCXXFiles) > 0
    +		objc = len(root.Package.MFiles) > 0
    +		fortran = len(root.Package.FFiles) > 0
    +	}
    +
    +	readCgoFlags := func(flagsFile string) error {
    +		flags, err := os.ReadFile(flagsFile)
    +		if err != nil {
    +			return err
    +		}
    +		const ldflagsPrefix = "_CGO_LDFLAGS="
    +		for line := range strings.SplitSeq(string(flags), "\n") {
    +			if strings.HasPrefix(line, ldflagsPrefix) {
    +				flag := line[len(ldflagsPrefix):]
    +				// Every _cgo_flags file has -g and -O2 in _CGO_LDFLAGS
    +				// but they don't mean anything to the linker so filter
    +				// them out.
    +				if flag != "-g" && !strings.HasPrefix(flag, "-O") {
    +					cgoldflags = append(cgoldflags, flag)
    +				}
    +			}
    +		}
    +		return nil
    +	}
    +
    +	var arArgs []string
    +	if cfg.Goos == "aix" && cfg.Goarch == "ppc64" {
    +		// AIX puts both 32-bit and 64-bit objects in the same archive.
    +		// Tell the AIX "ar" command to only care about 64-bit objects.
    +		arArgs = []string{"-X64"}
    +	}
    +
    +	newID := 0
    +	readAndRemoveCgoFlags := func(archive string) (string, error) {
    +		newID++
    +		newArchive := root.Objdir + fmt.Sprintf("_pkg%d_.a", newID)
    +		if err := sh.CopyFile(newArchive, archive, 0666, false); err != nil {
    +			return "", err
    +		}
    +		if cfg.BuildN || cfg.BuildX {
    +			sh.ShowCmd("", "ar d %s _cgo_flags", newArchive)
    +			if cfg.BuildN {
    +				// TODO(rsc): We could do better about showing the right _cgo_flags even in -n mode.
    +				// Either the archive is already built and we can read them out,
    +				// or we're printing commands to build the archive and can
    +				// forward the _cgo_flags directly to this step.
    +				return "", nil
    +			}
    +		}
    +		err := sh.run(root.Objdir, desc, nil, tools.ar(), arArgs, "x", newArchive, "_cgo_flags")
    +		if err != nil {
    +			return "", err
    +		}
    +		err = sh.run(".", desc, nil, tools.ar(), arArgs, "d", newArchive, "_cgo_flags")
    +		if err != nil {
    +			return "", err
    +		}
    +		err = readCgoFlags(filepath.Join(root.Objdir, "_cgo_flags"))
    +		if err != nil {
    +			return "", err
    +		}
    +		return newArchive, nil
    +	}
    +
    +	// If using -linkshared, find the shared library deps.
    +	haveShlib := make(map[string]bool)
    +	targetBase := filepath.Base(root.Target)
    +	if cfg.BuildLinkshared {
    +		for _, a := range root.Deps {
    +			p := a.Package
    +			if p == nil || p.Shlib == "" {
    +				continue
    +			}
    +
    +			// The .a we are linking into this .so
    +			// will have its Shlib set to this .so.
    +			// Don't start thinking we want to link
    +			// this .so into itself.
    +			base := filepath.Base(p.Shlib)
    +			if base != targetBase {
    +				haveShlib[base] = true
    +			}
    +		}
    +	}
    +
    +	// Arrange the deps into afiles and shlibs.
    +	addedShlib := make(map[string]bool)
    +	for _, a := range root.Deps {
    +		p := a.Package
    +		if p != nil && p.Shlib != "" && haveShlib[filepath.Base(p.Shlib)] {
    +			// This is a package linked into a shared
    +			// library that we will put into shlibs.
    +			continue
    +		}
    +
    +		if haveShlib[filepath.Base(a.Target)] {
    +			// This is a shared library we want to link against.
    +			if !addedShlib[a.Target] {
    +				shlibs = append(shlibs, a.Target)
    +				addedShlib[a.Target] = true
    +			}
    +			continue
    +		}
    +
    +		if p != nil {
    +			target := a.built
    +			if p.UsesCgo() || p.UsesSwig() {
    +				var err error
    +				target, err = readAndRemoveCgoFlags(target)
    +				if err != nil {
    +					continue
    +				}
    +			}
    +
    +			afiles = append(afiles, target)
    +		}
    +	}
    +
    +	for _, a := range allactions {
    +		if a.Package == nil {
    +			continue
    +		}
    +		if len(a.Package.CgoFiles) > 0 {
    +			usesCgo = true
    +		}
    +		if a.Package.UsesSwig() {
    +			usesCgo = true
    +		}
    +		if len(a.Package.CXXFiles) > 0 || len(a.Package.SwigCXXFiles) > 0 {
    +			cxx = true
    +		}
    +		if len(a.Package.MFiles) > 0 {
    +			objc = true
    +		}
    +		if len(a.Package.FFiles) > 0 {
    +			fortran = true
    +		}
    +	}
    +
    +	wholeArchive := []string{"-Wl,--whole-archive"}
    +	noWholeArchive := []string{"-Wl,--no-whole-archive"}
    +	if cfg.Goos == "aix" {
    +		wholeArchive = nil
    +		noWholeArchive = nil
    +	}
    +	ldflags = append(ldflags, wholeArchive...)
    +	ldflags = append(ldflags, afiles...)
    +	ldflags = append(ldflags, noWholeArchive...)
    +
    +	ldflags = append(ldflags, cgoldflags...)
    +	ldflags = append(ldflags, envList("CGO_LDFLAGS", "")...)
    +	if cfg.Goos != "aix" {
    +		ldflags = str.StringList("-Wl,-(", ldflags, "-Wl,-)")
    +	}
    +
    +	if root.buildID != "" {
    +		// On systems that normally use gold or the GNU linker,
    +		// use the --build-id option to write a GNU build ID note.
    +		switch cfg.Goos {
    +		case "android", "dragonfly", "linux", "netbsd":
    +			ldflags = append(ldflags, fmt.Sprintf("-Wl,--build-id=0x%x", root.buildID))
    +		}
    +	}
    +
    +	var rLibPath string
    +	if cfg.Goos == "aix" {
    +		rLibPath = "-Wl,-blibpath="
    +	} else {
    +		rLibPath = "-Wl,-rpath="
    +	}
    +	for _, shlib := range shlibs {
    +		ldflags = append(
    +			ldflags,
    +			"-L"+filepath.Dir(shlib),
    +			rLibPath+filepath.Dir(shlib),
    +			"-l"+strings.TrimSuffix(
    +				strings.TrimPrefix(filepath.Base(shlib), "lib"),
    +				".so"))
    +	}
    +
    +	var realOut string
    +	goLibBegin := str.StringList(wholeArchive, "-lgolibbegin", noWholeArchive)
    +	switch buildmode {
    +	case "exe":
    +		if usesCgo && cfg.Goos == "linux" {
    +			ldflags = append(ldflags, "-Wl,-E")
    +		}
    +
    +	case "c-archive":
    +		// Link the Go files into a single .o, and also link
    +		// in -lgolibbegin.
    +		//
    +		// We need to use --whole-archive with -lgolibbegin
    +		// because it doesn't define any symbols that will
    +		// cause the contents to be pulled in; it's just
    +		// initialization code.
    +		//
    +		// The user remains responsible for linking against
    +		// -lgo -lpthread -lm in the final link. We can't use
    +		// -r to pick them up because we can't combine
    +		// split-stack and non-split-stack code in a single -r
    +		// link, and libgo picks up non-split-stack code from
    +		// libffi.
    +		ldflags = append(ldflags, "-Wl,-r", "-nostdlib")
    +		ldflags = append(ldflags, goLibBegin...)
    +
    +		if nopie := b.gccNoPie([]string{tools.linker()}); nopie != "" {
    +			ldflags = append(ldflags, nopie)
    +		}
    +
    +		// We are creating an object file, so we don't want a build ID.
    +		if root.buildID == "" {
    +			ldflags = b.disableBuildID(ldflags)
    +		}
    +
    +		realOut = out
    +		out = out + ".o"
    +
    +	case "c-shared":
    +		ldflags = append(ldflags, "-shared", "-nostdlib")
    +		if cfg.Goos != "windows" {
    +			ldflags = append(ldflags, "-Wl,-z,nodelete")
    +		}
    +		ldflags = append(ldflags, goLibBegin...)
    +		ldflags = append(ldflags, "-lgo", "-lgcc_s", "-lgcc", "-lc", "-lgcc")
    +
    +	case "shared":
    +		if cfg.Goos != "aix" {
    +			ldflags = append(ldflags, "-zdefs")
    +		}
    +		ldflags = append(ldflags, "-shared", "-nostdlib", "-lgo", "-lgcc_s", "-lgcc", "-lc")
    +
    +	default:
    +		base.Fatalf("-buildmode=%s not supported for gccgo", buildmode)
    +	}
    +
    +	switch buildmode {
    +	case "exe", "c-shared":
    +		if cxx {
    +			ldflags = append(ldflags, "-lstdc++")
    +		}
    +		if objc {
    +			ldflags = append(ldflags, "-lobjc")
    +		}
    +		if fortran {
    +			fc := cfg.Getenv("FC")
    +			if fc == "" {
    +				fc = "gfortran"
    +			}
    +			// support gfortran out of the box and let others pass the correct link options
    +			// via CGO_LDFLAGS
    +			if strings.Contains(fc, "gfortran") {
    +				ldflags = append(ldflags, "-lgfortran")
    +			}
    +		}
    +	}
    +
    +	if err := sh.run(".", desc, nil, tools.linker(), "-o", out, ldflags, forcedGccgoflags, root.Package.Internal.Gccgoflags); err != nil {
    +		return err
    +	}
    +
    +	switch buildmode {
    +	case "c-archive":
    +		if err := sh.run(".", desc, nil, tools.ar(), arArgs, "rc", realOut, out); err != nil {
    +			return err
    +		}
    +	}
    +	return nil
    +}
    +
    +func (tools gccgoToolchain) ld(b *Builder, root *Action, targetPath, importcfg, mainpkg string) error {
    +	return tools.link(b, root, targetPath, importcfg, root.Deps, ldBuildmode, root.Package.ImportPath)
    +}
    +
    +func (tools gccgoToolchain) ldShared(b *Builder, root *Action, toplevelactions []*Action, targetPath, importcfg string, allactions []*Action) error {
    +	return tools.link(b, root, targetPath, importcfg, allactions, "shared", targetPath)
    +}
    +
    +func (tools gccgoToolchain) cc(b *Builder, a *Action, ofile, cfile string) error {
    +	p := a.Package
    +	inc := filepath.Join(cfg.GOROOT, "pkg", "include")
    +	cfile = mkAbs(p.Dir, cfile)
    +	defs := []string{"-D", "GOOS_" + cfg.Goos, "-D", "GOARCH_" + cfg.Goarch}
    +	defs = append(defs, b.gccArchArgs()...)
    +	if pkgpath := tools.gccgoCleanPkgpath(b, p); pkgpath != "" {
    +		defs = append(defs, `-D`, `GOPKGPATH="`+pkgpath+`"`)
    +	}
    +	compiler := envList("CC", cfg.DefaultCC(cfg.Goos, cfg.Goarch))
    +	if b.gccSupportsFlag(compiler, "-fsplit-stack") {
    +		defs = append(defs, "-fsplit-stack")
    +	}
    +	defs = tools.maybePIC(defs)
    +	if b.gccSupportsFlag(compiler, "-ffile-prefix-map=a=b") {
    +		defs = append(defs, "-ffile-prefix-map="+base.Cwd()+"=.")
    +		defs = append(defs, "-ffile-prefix-map="+b.WorkDir+"=/tmp/go-build")
    +	} else if b.gccSupportsFlag(compiler, "-fdebug-prefix-map=a=b") {
    +		defs = append(defs, "-fdebug-prefix-map="+b.WorkDir+"=/tmp/go-build")
    +	}
    +	if b.gccSupportsFlag(compiler, "-gno-record-gcc-switches") {
    +		defs = append(defs, "-gno-record-gcc-switches")
    +	}
    +	return b.Shell(a).run(p.Dir, p.ImportPath, nil, compiler, "-Wall", "-g",
    +		"-I", a.Objdir, "-I", inc, "-o", ofile, defs, "-c", cfile)
    +}
    +
    +// maybePIC adds -fPIC to the list of arguments if needed.
    +func (tools gccgoToolchain) maybePIC(args []string) []string {
    +	switch cfg.BuildBuildmode {
    +	case "c-shared", "shared", "plugin":
    +		args = append(args, "-fPIC")
    +	}
    +	return args
    +}
    +
    +func gccgoPkgpath(p *load.Package) string {
    +	if p.Internal.Build.IsCommand() && !p.Internal.ForceLibrary {
    +		return ""
    +	}
    +	return p.ImportPath
    +}
    +
    +var gccgoToSymbolFuncOnce sync.Once
    +var gccgoToSymbolFunc func(string) string
    +
    +func (tools gccgoToolchain) gccgoCleanPkgpath(b *Builder, p *load.Package) string {
    +	gccgoToSymbolFuncOnce.Do(func() {
    +		tmpdir := b.WorkDir
    +		if cfg.BuildN {
    +			tmpdir = os.TempDir()
    +		}
    +		fn, err := pkgpath.ToSymbolFunc(tools.compiler(), tmpdir)
    +		if err != nil {
    +			fmt.Fprintf(os.Stderr, "cmd/go: %v\n", err)
    +			base.SetExitStatus(2)
    +			base.Exit()
    +		}
    +		gccgoToSymbolFunc = fn
    +	})
    +
    +	return gccgoToSymbolFunc(gccgoPkgpath(p))
    +}
    +
    +var (
    +	gccgoSupportsCgoIncompleteOnce sync.Once
    +	gccgoSupportsCgoIncomplete     bool
    +)
    +
    +const gccgoSupportsCgoIncompleteCode = `
    +package p
    +
    +import "runtime/cgo"
    +
    +type I cgo.Incomplete
    +`
    +
    +// supportsCgoIncomplete reports whether the gccgo/GoLLVM compiler
    +// being used supports cgo.Incomplete, which was added in GCC 13.
    +//
    +// This takes an Action only for output reporting purposes.
    +// The result value is unrelated to the Action.
    +func (tools gccgoToolchain) supportsCgoIncomplete(b *Builder, a *Action) bool {
    +	gccgoSupportsCgoIncompleteOnce.Do(func() {
    +		sh := b.Shell(a)
    +
    +		fail := func(err error) {
    +			fmt.Fprintf(os.Stderr, "cmd/go: %v\n", err)
    +			base.SetExitStatus(2)
    +			base.Exit()
    +		}
    +
    +		tmpdir := b.WorkDir
    +		if cfg.BuildN {
    +			tmpdir = os.TempDir()
    +		}
    +		f, err := os.CreateTemp(tmpdir, "*_gccgo_cgoincomplete.go")
    +		if err != nil {
    +			fail(err)
    +		}
    +		fn := f.Name()
    +		f.Close()
    +		defer os.Remove(fn)
    +
    +		if err := os.WriteFile(fn, []byte(gccgoSupportsCgoIncompleteCode), 0644); err != nil {
    +			fail(err)
    +		}
    +
    +		on := strings.TrimSuffix(fn, ".go") + ".o"
    +		if cfg.BuildN || cfg.BuildX {
    +			sh.ShowCmd(tmpdir, "%s -c -o %s %s || true", tools.compiler(), on, fn)
    +			// Since this function affects later builds,
    +			// and only generates temporary files,
    +			// we run the command even with -n.
    +		}
    +		cmd := exec.Command(tools.compiler(), "-c", "-o", on, fn)
    +		cmd.Dir = tmpdir
    +		var buf bytes.Buffer
    +		cmd.Stdout = &buf
    +		cmd.Stderr = &buf
    +		err = cmd.Run()
    +		gccgoSupportsCgoIncomplete = err == nil
    +		if cfg.BuildN || cfg.BuildX {
    +			// Show output. We always pass a nil err because errors are an
    +			// expected outcome in this case.
    +			desc := sh.fmtCmd(tmpdir, "%s -c -o %s %s", tools.compiler(), on, fn)
    +			sh.reportCmd(desc, tmpdir, buf.Bytes(), nil)
    +		}
    +	})
    +	return gccgoSupportsCgoIncomplete
    +}
    diff --git a/go/src/cmd/go/internal/work/init.go b/go/src/cmd/go/internal/work/init.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..964d6e8363a95152b59b0f6e02f87d4f0ea894dd
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/init.go
    @@ -0,0 +1,458 @@
    +// Copyright 2017 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Build initialization (after flag parsing).
    +
    +package work
    +
    +import (
    +	"bytes"
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/fsys"
    +	"cmd/go/internal/modload"
    +	"cmd/internal/quoted"
    +	"fmt"
    +	"internal/platform"
    +	"os"
    +	"os/exec"
    +	"path/filepath"
    +	"regexp"
    +	"runtime"
    +	"slices"
    +	"strconv"
    +	"sync"
    +)
    +
    +var buildInitStarted = false
    +
    +// makeCfgChangedEnv is the environment to set to
    +// override the current environment for GOOS, GOARCH, and the GOARCH-specific
    +// architecture environment variable to the configuration used by
    +// the go command. They may be different because go tool  for builtin
    +// tools need to be built using the host configuration, so the configuration
    +// used will be changed from that set in the environment. It is clipped
    +// so its can append to it without changing it.
    +var cfgChangedEnv []string
    +
    +func makeCfgChangedEnv() []string {
    +	var env []string
    +	if cfg.Getenv("GOOS") != cfg.Goos {
    +		env = append(env, "GOOS="+cfg.Goos)
    +	}
    +	if cfg.Getenv("GOARCH") != cfg.Goarch {
    +		env = append(env, "GOARCH="+cfg.Goarch)
    +	}
    +	if archenv, val, changed := cfg.GetArchEnv(); changed {
    +		env = append(env, archenv+"="+val)
    +	}
    +	return slices.Clip(env)
    +}
    +
    +func BuildInit(loaderstate *modload.State) {
    +	if buildInitStarted {
    +		base.Fatalf("go: internal error: work.BuildInit called more than once")
    +	}
    +	buildInitStarted = true
    +	base.AtExit(closeBuilders)
    +
    +	modload.Init(loaderstate)
    +	instrumentInit()
    +	buildModeInit()
    +	initCompilerConcurrencyPool()
    +	cfgChangedEnv = makeCfgChangedEnv()
    +
    +	if err := fsys.Init(); err != nil {
    +		base.Fatal(err)
    +	}
    +	if from, replaced := fsys.DirContainsReplacement(cfg.GOMODCACHE); replaced {
    +		base.Fatalf("go: overlay contains a replacement for %s. Files beneath GOMODCACHE (%s) must not be replaced.", from, cfg.GOMODCACHE)
    +	}
    +
    +	// Make sure -pkgdir is absolute, because we run commands
    +	// in different directories.
    +	if cfg.BuildPkgdir != "" && !filepath.IsAbs(cfg.BuildPkgdir) {
    +		p, err := filepath.Abs(cfg.BuildPkgdir)
    +		if err != nil {
    +			fmt.Fprintf(os.Stderr, "go: evaluating -pkgdir: %v\n", err)
    +			base.SetExitStatus(2)
    +			base.Exit()
    +		}
    +		cfg.BuildPkgdir = p
    +	}
    +
    +	if cfg.BuildP <= 0 {
    +		base.Fatalf("go: -p must be a positive integer: %v\n", cfg.BuildP)
    +	}
    +
    +	// Make sure CC, CXX, and FC are absolute paths.
    +	for _, key := range []string{"CC", "CXX", "FC"} {
    +		value := cfg.Getenv(key)
    +		args, err := quoted.Split(value)
    +		if err != nil {
    +			base.Fatalf("go: %s environment variable could not be parsed: %v", key, err)
    +		}
    +		if len(args) == 0 {
    +			continue
    +		}
    +		path := args[0]
    +		if !filepath.IsAbs(path) && path != filepath.Base(path) {
    +			base.Fatalf("go: %s environment variable is relative; must be absolute path: %s\n", key, path)
    +		}
    +	}
    +
    +	// Set covermode if not already set.
    +	// Ensure that -race and -covermode are compatible.
    +	if cfg.BuildCoverMode == "" {
    +		cfg.BuildCoverMode = "set"
    +		if cfg.BuildRace {
    +			// Default coverage mode is atomic when -race is set.
    +			cfg.BuildCoverMode = "atomic"
    +		}
    +	}
    +	if cfg.BuildRace && cfg.BuildCoverMode != "atomic" {
    +		base.Fatalf(`-covermode must be "atomic", not %q, when -race is enabled`, cfg.BuildCoverMode)
    +	}
    +}
    +
    +// fuzzInstrumentFlags returns compiler flags that enable fuzzing instrumentation
    +// on supported platforms.
    +//
    +// On unsupported platforms, fuzzInstrumentFlags returns nil, meaning no
    +// instrumentation is added. 'go test -fuzz' still works without coverage,
    +// but it generates random inputs without guidance, so it's much less effective.
    +func fuzzInstrumentFlags() []string {
    +	if !platform.FuzzInstrumented(cfg.Goos, cfg.Goarch) {
    +		return nil
    +	}
    +	return []string{"-d=libfuzzer"}
    +}
    +
    +func instrumentInit() {
    +	if !cfg.BuildRace && !cfg.BuildMSan && !cfg.BuildASan {
    +		return
    +	}
    +	if cfg.BuildRace && cfg.BuildMSan {
    +		fmt.Fprintf(os.Stderr, "go: may not use -race and -msan simultaneously\n")
    +		base.SetExitStatus(2)
    +		base.Exit()
    +	}
    +	if cfg.BuildRace && cfg.BuildASan {
    +		fmt.Fprintf(os.Stderr, "go: may not use -race and -asan simultaneously\n")
    +		base.SetExitStatus(2)
    +		base.Exit()
    +	}
    +	if cfg.BuildMSan && cfg.BuildASan {
    +		fmt.Fprintf(os.Stderr, "go: may not use -msan and -asan simultaneously\n")
    +		base.SetExitStatus(2)
    +		base.Exit()
    +	}
    +	if cfg.BuildMSan && !platform.MSanSupported(cfg.Goos, cfg.Goarch) {
    +		fmt.Fprintf(os.Stderr, "-msan is not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
    +		base.SetExitStatus(2)
    +		base.Exit()
    +	}
    +	if cfg.BuildRace && !platform.RaceDetectorSupported(cfg.Goos, cfg.Goarch) {
    +		fmt.Fprintf(os.Stderr, "-race is not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
    +		base.SetExitStatus(2)
    +		base.Exit()
    +	}
    +	if cfg.BuildASan && !platform.ASanSupported(cfg.Goos, cfg.Goarch) {
    +		fmt.Fprintf(os.Stderr, "-asan is not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
    +		base.SetExitStatus(2)
    +		base.Exit()
    +	}
    +	// The current implementation is only compatible with the ASan library from version
    +	// v7 to v9 (See the description in src/runtime/asan/asan.go). Therefore, using the
    +	// -asan option must use a compatible version of ASan library, which requires that
    +	// the gcc version is not less than 7 and the clang version is not less than 9,
    +	// otherwise a segmentation fault will occur.
    +	if cfg.BuildASan {
    +		if err := compilerRequiredAsanVersion(); err != nil {
    +			fmt.Fprintf(os.Stderr, "%v\n", err)
    +			base.SetExitStatus(2)
    +			base.Exit()
    +		}
    +	}
    +
    +	mode := "race"
    +	if cfg.BuildMSan {
    +		mode = "msan"
    +		// MSAN needs PIE on all platforms except linux/amd64.
    +		// https://github.com/llvm/llvm-project/blob/llvmorg-13.0.1/clang/lib/Driver/SanitizerArgs.cpp#L621
    +		if cfg.BuildBuildmode == "default" && (cfg.Goos != "linux" || cfg.Goarch != "amd64") {
    +			cfg.BuildBuildmode = "pie"
    +		}
    +	}
    +	if cfg.BuildASan {
    +		mode = "asan"
    +	}
    +	modeFlag := "-" + mode
    +
    +	// Check that cgo is enabled.
    +	// Note: On macOS, -race does not require cgo. -asan and -msan still do.
    +	if !cfg.BuildContext.CgoEnabled && (cfg.Goos != "darwin" || cfg.BuildASan || cfg.BuildMSan) {
    +		if runtime.GOOS != cfg.Goos || runtime.GOARCH != cfg.Goarch {
    +			fmt.Fprintf(os.Stderr, "go: %s requires cgo\n", modeFlag)
    +		} else {
    +			fmt.Fprintf(os.Stderr, "go: %s requires cgo; enable cgo by setting CGO_ENABLED=1\n", modeFlag)
    +		}
    +
    +		base.SetExitStatus(2)
    +		base.Exit()
    +	}
    +	forcedGcflags = append(forcedGcflags, modeFlag)
    +	forcedLdflags = append(forcedLdflags, modeFlag)
    +
    +	if cfg.BuildContext.InstallSuffix != "" {
    +		cfg.BuildContext.InstallSuffix += "_"
    +	}
    +	cfg.BuildContext.InstallSuffix += mode
    +	cfg.BuildContext.ToolTags = append(cfg.BuildContext.ToolTags, mode)
    +}
    +
    +func buildModeInit() {
    +	gccgo := cfg.BuildToolchainName == "gccgo"
    +	var codegenArg string
    +
    +	// Configure the build mode first, then verify that it is supported.
    +	// That way, if the flag is completely bogus we will prefer to error out with
    +	// "-buildmode=%s not supported" instead of naming the specific platform.
    +
    +	switch cfg.BuildBuildmode {
    +	case "archive":
    +		pkgsFilter = pkgsNotMain
    +	case "c-archive":
    +		pkgsFilter = oneMainPkg
    +		if gccgo {
    +			codegenArg = "-fPIC"
    +		} else {
    +			switch cfg.Goos {
    +			case "darwin", "ios":
    +				switch cfg.Goarch {
    +				case "arm64":
    +					codegenArg = "-shared"
    +				}
    +
    +			case "dragonfly", "freebsd", "illumos", "linux", "netbsd", "openbsd", "solaris":
    +				// Use -shared so that the result is
    +				// suitable for inclusion in a PIE or
    +				// shared library.
    +				codegenArg = "-shared"
    +			}
    +		}
    +		cfg.ExeSuffix = ".a"
    +		ldBuildmode = "c-archive"
    +	case "c-shared":
    +		pkgsFilter = oneMainPkg
    +		if gccgo {
    +			codegenArg = "-fPIC"
    +		} else {
    +			switch cfg.Goos {
    +			case "linux", "android", "freebsd":
    +				codegenArg = "-shared"
    +			case "windows":
    +				// Do not add usual .exe suffix to the .dll file.
    +				cfg.ExeSuffix = ""
    +			}
    +		}
    +		ldBuildmode = "c-shared"
    +	case "default":
    +		ldBuildmode = "exe"
    +		if platform.DefaultPIE(cfg.Goos, cfg.Goarch, cfg.BuildRace) {
    +			ldBuildmode = "pie"
    +			if cfg.Goos != "windows" && !gccgo {
    +				codegenArg = "-shared"
    +			}
    +		}
    +	case "exe":
    +		pkgsFilter = pkgsMain
    +		ldBuildmode = "exe"
    +		// Set the pkgsFilter to oneMainPkg if the user passed a specific binary output
    +		// and is using buildmode=exe for a better error message.
    +		// See issue #20017.
    +		if cfg.BuildO != "" {
    +			pkgsFilter = oneMainPkg
    +		}
    +	case "pie":
    +		if cfg.BuildRace && !platform.DefaultPIE(cfg.Goos, cfg.Goarch, cfg.BuildRace) {
    +			base.Fatalf("-buildmode=pie not supported when -race is enabled on %s/%s", cfg.Goos, cfg.Goarch)
    +		}
    +		if gccgo {
    +			codegenArg = "-fPIE"
    +		} else {
    +			switch cfg.Goos {
    +			case "aix", "windows":
    +			default:
    +				codegenArg = "-shared"
    +			}
    +		}
    +		ldBuildmode = "pie"
    +	case "shared":
    +		pkgsFilter = pkgsNotMain
    +		if gccgo {
    +			codegenArg = "-fPIC"
    +		} else {
    +			codegenArg = "-dynlink"
    +		}
    +		if cfg.BuildO != "" {
    +			base.Fatalf("-buildmode=shared and -o not supported together")
    +		}
    +		ldBuildmode = "shared"
    +	case "plugin":
    +		pkgsFilter = oneMainPkg
    +		if gccgo {
    +			codegenArg = "-fPIC"
    +		} else {
    +			codegenArg = "-dynlink"
    +		}
    +		cfg.ExeSuffix = ".so"
    +		ldBuildmode = "plugin"
    +	default:
    +		base.Fatalf("buildmode=%s not supported", cfg.BuildBuildmode)
    +	}
    +
    +	if cfg.BuildBuildmode != "default" && !platform.BuildModeSupported(cfg.BuildToolchainName, cfg.BuildBuildmode, cfg.Goos, cfg.Goarch) {
    +		base.Fatalf("-buildmode=%s not supported on %s/%s\n", cfg.BuildBuildmode, cfg.Goos, cfg.Goarch)
    +	}
    +
    +	if cfg.BuildLinkshared {
    +		if !platform.BuildModeSupported(cfg.BuildToolchainName, "shared", cfg.Goos, cfg.Goarch) {
    +			base.Fatalf("-linkshared not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
    +		}
    +		if gccgo {
    +			codegenArg = "-fPIC"
    +		} else {
    +			forcedAsmflags = append(forcedAsmflags, "-D=GOBUILDMODE_shared=1",
    +				"-linkshared")
    +			codegenArg = "-dynlink"
    +			forcedGcflags = append(forcedGcflags, "-linkshared")
    +			// TODO(mwhudson): remove -w when that gets fixed in linker.
    +			forcedLdflags = append(forcedLdflags, "-linkshared", "-w")
    +		}
    +	}
    +	if codegenArg != "" {
    +		if gccgo {
    +			forcedGccgoflags = append([]string{codegenArg}, forcedGccgoflags...)
    +		} else {
    +			forcedAsmflags = append([]string{codegenArg}, forcedAsmflags...)
    +			forcedGcflags = append([]string{codegenArg}, forcedGcflags...)
    +		}
    +		// Don't alter InstallSuffix when modifying default codegen args.
    +		if cfg.BuildBuildmode != "default" || cfg.BuildLinkshared {
    +			if cfg.BuildContext.InstallSuffix != "" {
    +				cfg.BuildContext.InstallSuffix += "_"
    +			}
    +			cfg.BuildContext.InstallSuffix += codegenArg[1:]
    +		}
    +	}
    +
    +	switch cfg.BuildMod {
    +	case "":
    +		// Behavior will be determined automatically, as if no flag were passed.
    +	case "readonly", "vendor", "mod":
    +		if !cfg.ModulesEnabled && !base.InGOFLAGS("-mod") {
    +			base.Fatalf("build flag -mod=%s only valid when using modules", cfg.BuildMod)
    +		}
    +	default:
    +		base.Fatalf("-mod=%s not supported (can be '', 'mod', 'readonly', or 'vendor')", cfg.BuildMod)
    +	}
    +	if !cfg.ModulesEnabled {
    +		if cfg.ModCacheRW && !base.InGOFLAGS("-modcacherw") {
    +			base.Fatalf("build flag -modcacherw only valid when using modules")
    +		}
    +		if cfg.ModFile != "" && !base.InGOFLAGS("-mod") {
    +			base.Fatalf("build flag -modfile only valid when using modules")
    +		}
    +	}
    +}
    +
    +type version struct {
    +	name         string
    +	major, minor int
    +}
    +
    +var compiler struct {
    +	sync.Once
    +	version
    +	err error
    +}
    +
    +// compilerVersion detects the version of $(go env CC).
    +// It returns a non-nil error if the compiler matches a known version schema but
    +// the version could not be parsed, or if $(go env CC) could not be determined.
    +func compilerVersion() (version, error) {
    +	compiler.Once.Do(func() {
    +		compiler.err = func() error {
    +			compiler.name = "unknown"
    +			cc := os.Getenv("CC")
    +			cmd := exec.Command(cc, "--version")
    +			cmd.Env = append(cmd.Environ(), "LANG=C")
    +			out, err := cmd.Output()
    +			if err != nil {
    +				// Compiler does not support "--version" flag: not Clang or GCC.
    +				return err
    +			}
    +
    +			var match [][]byte
    +			if bytes.HasPrefix(out, []byte("gcc")) {
    +				compiler.name = "gcc"
    +				cmd := exec.Command(cc, "-v")
    +				cmd.Env = append(cmd.Environ(), "LANG=C")
    +				out, err := cmd.CombinedOutput()
    +				if err != nil {
    +					// gcc, but does not support gcc's "-v" flag?!
    +					return err
    +				}
    +				gccRE := regexp.MustCompile(`gcc version (\d+)\.(\d+)`)
    +				match = gccRE.FindSubmatch(out)
    +			} else {
    +				clangRE := regexp.MustCompile(`clang version (\d+)\.(\d+)`)
    +				if match = clangRE.FindSubmatch(out); len(match) > 0 {
    +					compiler.name = "clang"
    +				}
    +			}
    +
    +			if len(match) < 3 {
    +				return nil // "unknown"
    +			}
    +			if compiler.major, err = strconv.Atoi(string(match[1])); err != nil {
    +				return err
    +			}
    +			if compiler.minor, err = strconv.Atoi(string(match[2])); err != nil {
    +				return err
    +			}
    +			return nil
    +		}()
    +	})
    +	return compiler.version, compiler.err
    +}
    +
    +// compilerRequiredAsanVersion is a copy of the function defined in
    +// cmd/cgo/internal/testsanitizers/cc_test.go
    +// compilerRequiredAsanVersion reports whether the compiler is the version
    +// required by Asan.
    +func compilerRequiredAsanVersion() error {
    +	compiler, err := compilerVersion()
    +	if err != nil {
    +		return fmt.Errorf("-asan: the version of $(go env CC) could not be parsed")
    +	}
    +
    +	switch compiler.name {
    +	case "gcc":
    +		if runtime.GOARCH == "ppc64le" && compiler.major < 9 {
    +			return fmt.Errorf("-asan is not supported with %s compiler %d.%d\n", compiler.name, compiler.major, compiler.minor)
    +		}
    +		if compiler.major < 7 {
    +			return fmt.Errorf("-asan is not supported with %s compiler %d.%d\n", compiler.name, compiler.major, compiler.minor)
    +		}
    +	case "clang":
    +		if compiler.major < 9 {
    +			return fmt.Errorf("-asan is not supported with %s compiler %d.%d\n", compiler.name, compiler.major, compiler.minor)
    +		}
    +	default:
    +		return fmt.Errorf("-asan: C compiler is not gcc or clang")
    +	}
    +	return nil
    +}
    diff --git a/go/src/cmd/go/internal/work/security.go b/go/src/cmd/go/internal/work/security.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..b5acb0a0ee09a6ed3de0086b8eff5c230c05105a
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/security.go
    @@ -0,0 +1,444 @@
    +// Copyright 2018 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Checking of compiler and linker flags.
    +// We must avoid flags like -fplugin=, which can allow
    +// arbitrary code execution during the build.
    +// Do not make changes here without carefully
    +// considering the implications.
    +// (That's why the code is isolated in a file named security.go.)
    +//
    +// Note that -Wl,foo means split foo on commas and pass to
    +// the linker, so that -Wl,-foo,bar means pass -foo bar to
    +// the linker. Similarly -Wa,foo for the assembler and so on.
    +// If any of these are permitted, the wildcard portion must
    +// disallow commas.
    +//
    +// Note also that GNU binutils accept any argument @foo
    +// as meaning "read more flags from the file foo", so we must
    +// guard against any command-line argument beginning with @,
    +// even things like "-I @foo".
    +// We use load.SafeArg (which is even more conservative)
    +// to reject these.
    +//
    +// Even worse, gcc -I@foo (one arg) turns into cc1 -I @foo (two args),
    +// so although gcc doesn't expand the @foo, cc1 will.
    +// So out of paranoia, we reject @ at the beginning of every
    +// flag argument that might be split into its own argument.
    +
    +package work
    +
    +import (
    +	"fmt"
    +	"internal/lazyregexp"
    +	"regexp"
    +	"strings"
    +
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/load"
    +)
    +
    +var re = lazyregexp.New
    +
    +var validCompilerFlags = []*lazyregexp.Regexp{
    +	re(`-D([A-Za-z_][A-Za-z0-9_]*)(=[^@\-]*)?`),
    +	re(`-U([A-Za-z_][A-Za-z0-9_]*)`),
    +	re(`-F([^@\-].*)`),
    +	re(`-I([^@\-].*)`),
    +	re(`-O`),
    +	re(`-O([^@\-].*)`),
    +	re(`-W`),
    +	re(`-W([^@,]+)`), // -Wall but not -Wa,-foo.
    +	re(`-Wa,-mbig-obj`),
    +	re(`-Wp,-D([A-Za-z_][A-Za-z0-9_]*)(=[^@,\-]*)?`),
    +	re(`-Wp,-U([A-Za-z_][A-Za-z0-9_]*)`),
    +	re(`-ansi`),
    +	re(`-f(no-)?asynchronous-unwind-tables`),
    +	re(`-f(no-)?blocks`),
    +	re(`-f(no-)builtin-[a-zA-Z0-9_]*`),
    +	re(`-f(no-)?common`),
    +	re(`-f(no-)?constant-cfstrings`),
    +	re(`-fdebug-prefix-map=([^@]+)=([^@]+)`),
    +	re(`-fdiagnostics-show-note-include-stack`),
    +	re(`-ffile-prefix-map=([^@]+)=([^@]+)`),
    +	re(`-fno-canonical-system-headers`),
    +	re(`-f(no-)?eliminate-unused-debug-types`),
    +	re(`-f(no-)?exceptions`),
    +	re(`-f(no-)?fast-math`),
    +	re(`-f(no-)?inline-functions`),
    +	re(`-finput-charset=([^@\-].*)`),
    +	re(`-f(no-)?fat-lto-objects`),
    +	re(`-f(no-)?keep-inline-dllexport`),
    +	re(`-f(no-)?lto`),
    +	re(`-fmacro-backtrace-limit=(.+)`),
    +	re(`-fmessage-length=(.+)`),
    +	re(`-f(no-)?modules`),
    +	re(`-f(no-)?objc-arc`),
    +	re(`-f(no-)?objc-nonfragile-abi`),
    +	re(`-f(no-)?objc-legacy-dispatch`),
    +	re(`-f(no-)?omit-frame-pointer`),
    +	re(`-f(no-)?openmp(-simd)?`),
    +	re(`-f(no-)?permissive`),
    +	re(`-f(no-)?(pic|PIC|pie|PIE)`),
    +	re(`-f(no-)?plt`),
    +	re(`-f(no-)?rtti`),
    +	re(`-f(no-)?split-stack`),
    +	re(`-f(no-)?stack-(.+)`),
    +	re(`-f(no-)?strict-aliasing`),
    +	re(`-f(un)signed-char`),
    +	re(`-f(no-)?use-linker-plugin`), // safe if -B is not used; we don't permit -B
    +	re(`-f(no-)?visibility-inlines-hidden`),
    +	re(`-fsanitize=(.+)`),
    +	re(`-fsanitize-undefined-strip-path-components=(-)?[0-9]+`),
    +	re(`-ftemplate-depth-(.+)`),
    +	re(`-ftls-model=(global-dynamic|local-dynamic|initial-exec|local-exec)`),
    +	re(`-fvisibility=(.+)`),
    +	re(`-g([^@\-].*)?`),
    +	re(`-m32`),
    +	re(`-m64`),
    +	re(`-m(abi|arch|cpu|fpu|simd|tls-dialect|tune)=([^@\-].*)`),
    +	re(`-m(no-)?v?aes`),
    +	re(`-marm`),
    +	re(`-mcmodel=[0-9a-z-]+`),
    +	re(`-mfloat-abi=([^@\-].*)`),
    +	re(`-m(soft|single|double)-float`),
    +	re(`-mfpmath=[0-9a-z,+]*`),
    +	re(`-m(no-)?avx[0-9a-z.]*`),
    +	re(`-m(no-)?ms-bitfields`),
    +	re(`-m(no-)?stack-(.+)`),
    +	re(`-mmacosx-(.+)`),
    +	re(`-m(no-)?relax`),
    +	re(`-m(no-)?strict-align`),
    +	re(`-m(no-)?(lsx|lasx|frecipe|div32|lam-bh|lamcas|ld-seq-sa)`),
    +	re(`-mios-simulator-version-min=(.+)`),
    +	re(`-miphoneos-version-min=(.+)`),
    +	re(`-mlarge-data-threshold=[0-9]+`),
    +	re(`-mtvos-simulator-version-min=(.+)`),
    +	re(`-mtvos-version-min=(.+)`),
    +	re(`-mwatchos-simulator-version-min=(.+)`),
    +	re(`-mwatchos-version-min=(.+)`),
    +	re(`-mnop-fun-dllimport`),
    +	re(`-m(no-)?sse[0-9.]*`),
    +	re(`-m(no-)?ssse3`),
    +	re(`-mthumb(-interwork)?`),
    +	re(`-mthreads`),
    +	re(`-mwindows`),
    +	re(`-no-canonical-prefixes`),
    +	re(`--param=ssp-buffer-size=[0-9]*`),
    +	re(`-pedantic(-errors)?`),
    +	re(`-pipe`),
    +	re(`-pthread`),
    +	re(`--static`),
    +	re(`-?-std=([^@\-].*)`),
    +	re(`-?-stdlib=([^@\-].*)`),
    +	re(`--sysroot=([^@\-].*)`),
    +	re(`-w`),
    +	re(`-x([^@\-].*)`),
    +	re(`-v`),
    +}
    +
    +var validCompilerFlagsWithNextArg = []string{
    +	"-arch",
    +	"-D",
    +	"-U",
    +	"-I",
    +	"-F",
    +	"-framework",
    +	"-include",
    +	"-isysroot",
    +	"-isystem",
    +	"--sysroot",
    +	"-target",
    +	"-x",
    +}
    +
    +var invalidLinkerFlags = []*lazyregexp.Regexp{
    +	// On macOS this means the linker loads and executes the next argument.
    +	// Have to exclude separately because -lfoo is allowed in general.
    +	re(`-lto_library`),
    +}
    +
    +var validLinkerFlags = []*lazyregexp.Regexp{
    +	re(`-F([^@\-].*)`),
    +	re(`-l([^@\-].*)`),
    +	re(`-L([^@\-].*)`),
    +	re(`-O`),
    +	re(`-O([^@\-].*)`),
    +	re(`-f(no-)?(pic|PIC|pie|PIE)`),
    +	re(`-f(no-)?openmp(-simd)?`),
    +	re(`-fsanitize=([^@\-].*)`),
    +	re(`-flat_namespace`),
    +	re(`-g([^@\-].*)?`),
    +	re(`-headerpad_max_install_names`),
    +	re(`-m(abi|arch|cpu|fpu|simd|tls-dialect|tune)=([^@\-].*)`),
    +	re(`-mcmodel=[0-9a-z-]+`),
    +	re(`-mfloat-abi=([^@\-].*)`),
    +	re(`-m(soft|single|double)-float`),
    +	re(`-m(no-)?relax`),
    +	re(`-m(no-)?strict-align`),
    +	re(`-m(no-)?(lsx|lasx|frecipe|div32|lam-bh|lamcas|ld-seq-sa)`),
    +	re(`-mmacosx-(.+)`),
    +	re(`-mios-simulator-version-min=(.+)`),
    +	re(`-miphoneos-version-min=(.+)`),
    +	re(`-mthreads`),
    +	re(`-mwindows`),
    +	re(`-(pic|PIC|pie|PIE)`),
    +	re(`-pthread`),
    +	re(`-rdynamic`),
    +	re(`-shared`),
    +	re(`-?-static([-a-z0-9+]*)`),
    +	re(`-?-stdlib=([^@\-].*)`),
    +	re(`-v`),
    +
    +	// Note that any wildcards in -Wl need to exclude comma,
    +	// since -Wl splits its argument at commas and passes
    +	// them all to the linker uninterpreted. Allowing comma
    +	// in a wildcard would allow tunneling arbitrary additional
    +	// linker arguments through one of these.
    +	re(`-Wl,--(no-)?allow-multiple-definition`),
    +	re(`-Wl,--(no-)?allow-shlib-undefined`),
    +	re(`-Wl,--(no-)?as-needed`),
    +	re(`-Wl,-Bdynamic`),
    +	re(`-Wl,-berok`),
    +	re(`-Wl,-Bstatic`),
    +	re(`-Wl,-Bsymbolic-functions`),
    +	re(`-Wl,-O[0-9]+`),
    +	re(`-Wl,-d[ny]`),
    +	re(`-Wl,--disable-new-dtags`),
    +	re(`-Wl,-e[=,][a-zA-Z0-9]+`),
    +	re(`-Wl,--enable-new-dtags`),
    +	re(`-Wl,--end-group`),
    +	re(`-Wl,--(no-)?export-dynamic`),
    +	re(`-Wl,-E`),
    +	re(`-Wl,-framework,[^,@\-][^,]*`),
    +	re(`-Wl,--hash-style=(sysv|gnu|both)`),
    +	re(`-Wl,-headerpad_max_install_names`),
    +	re(`-Wl,--no-undefined`),
    +	re(`-Wl,--pop-state`),
    +	re(`-Wl,--push-state`),
    +	re(`-Wl,-R,?([^@\-,][^,@]*$)`),
    +	re(`-Wl,--just-symbols[=,]([^,@\-][^,@]*)`),
    +	re(`-Wl,-rpath(-link)?[=,]([^,@\-][^,]*)`),
    +	re(`-Wl,-s`),
    +	re(`-Wl,-search_paths_first`),
    +	re(`-Wl,-sectcreate,([^,@\-][^,]*),([^,@\-][^,]*),([^,@\-][^,]*)`),
    +	re(`-Wl,--start-group`),
    +	re(`-Wl,-?-static`),
    +	re(`-Wl,-?-subsystem,(native|windows|console|posix|xbox)`),
    +	re(`-Wl,-syslibroot[=,]([^,@\-][^,]*)`),
    +	re(`-Wl,-undefined[=,]([^,@\-][^,]*)`),
    +	re(`-Wl,-?-unresolved-symbols=[^,]+`),
    +	re(`-Wl,--(no-)?warn-([^,]+)`),
    +	re(`-Wl,-?-wrap[=,][^,@\-][^,]*`),
    +	re(`-Wl(,-z,(relro|now|(no)?execstack))+`),
    +
    +	re(`[a-zA-Z0-9_/].*\.(a|o|obj|dll|dylib|so|tbd)`), // direct linker inputs: x.o or libfoo.so (but not -foo.o or @foo.o)
    +	re(`\./.*\.(a|o|obj|dll|dylib|so|tbd)`),
    +}
    +
    +var validLinkerFlagsWithNextArg = []string{
    +	"-arch",
    +	"-F",
    +	"-l",
    +	"-L",
    +	"-framework",
    +	"-isysroot",
    +	"--sysroot",
    +	"-target",
    +	"-Wl,-framework",
    +	"-Wl,-rpath",
    +	"-Wl,-R",
    +	"-Wl,--just-symbols",
    +	"-Wl,-undefined",
    +}
    +
    +var validPkgConfigFlags = []*lazyregexp.Regexp{
    +	re(`--atleast-pkgconfig-version=\d+\.\d+\.\d+`),
    +	re(`--atleast-version=\d+\.\d+\.\d+`),
    +	re(`--cflags-only-I`),
    +	re(`--cflags`),
    +	re(`--define-prefix`),
    +	re(`--define-variable=[A-Za-z_][A-Za-z0-9_]*=[^@\-]*`),
    +	re(`--digraph`),
    +	re(`--dont-define-prefix`),
    +	re(`--dont-relocate-paths`),
    +	re(`--dump-personality`),
    +	re(`--env-only`),
    +	re(`--errors-to-stdout`),
    +	re(`--exact-version=\d+\.\d+\.\d+`),
    +	re(`--exists`),
    +	re(`--fragment-filter=[A-Za-z_][a-zA-Z0-9_]*`),
    +	re(`--ignore-conflicts`),
    +	re(`--internal-cflags`),
    +	re(`--keep-system-cflags`),
    +	re(`--keep-system-libs`),
    +	re(`--libs-only-l`),
    +	re(`--libs-only-L`),
    +	re(`--libs`),
    +	re(`--list-all`),
    +	re(`--list-package-names`),
    +	re(`--max-version=\d+\.\d+\.\d+`),
    +	re(`--maximum-traverse-depth=[0-9]+`),
    +	re(`--modversion`),
    +	re(`--msvc-syntax`),
    +	re(`--no-cache`),
    +	re(`--no-provides`),
    +	re(`--no-uninstalled`),
    +	re(`--path`),
    +	re(`--personality=(triplet|filename)`),
    +	re(`--prefix-variable=[A-Za-z_][a-zA-Z0-9_]*`),
    +	re(`--print-errors`),
    +	re(`--print-provides`),
    +	re(`--print-requires-private`),
    +	re(`--print-requires`),
    +	re(`--print-variables`),
    +	re(`--pure`),
    +	re(`--shared`),
    +	re(`--short-errors`),
    +	re(`--silence-errors`),
    +	re(`--simulate`),
    +	re(`--static`),
    +	re(`--uninstalled`),
    +	re(`--validate`),
    +	re(`--variable=[A-Za-z_][a-zA-Z0-9_]*`),
    +	re(`--with-path=[^@\-].*`),
    +}
    +
    +func checkCompilerFlags(name, source string, list []string) error {
    +	checkOverrides := true
    +	return checkFlags(name, source, list, nil, validCompilerFlags, validCompilerFlagsWithNextArg, checkOverrides)
    +}
    +
    +func checkLinkerFlags(name, source string, list []string) error {
    +	checkOverrides := true
    +	return checkFlags(name, source, list, invalidLinkerFlags, validLinkerFlags, validLinkerFlagsWithNextArg, checkOverrides)
    +}
    +
    +func checkPkgConfigFlags(name, source string, list []string) error {
    +	checkOverrides := false
    +	return checkFlags(name, source, list, nil, validPkgConfigFlags, nil, checkOverrides)
    +}
    +
    +// checkCompilerFlagsForInternalLink returns an error if 'list'
    +// contains a flag or flags that may not be fully supported by
    +// internal linking (meaning that we should punt the link to the
    +// external linker).
    +func checkCompilerFlagsForInternalLink(name, source string, list []string) error {
    +	checkOverrides := false
    +	if err := checkFlags(name, source, list, nil, validCompilerFlags, validCompilerFlagsWithNextArg, checkOverrides); err != nil {
    +		return err
    +	}
    +	// Currently the only flag on the allow list that causes problems
    +	// for the linker is "-flto"; check for it manually here.
    +	for _, fl := range list {
    +		if strings.HasPrefix(fl, "-flto") {
    +			return fmt.Errorf("flag %q triggers external linking", fl)
    +		}
    +	}
    +	return nil
    +}
    +
    +func checkFlags(name, source string, list []string, invalid, valid []*lazyregexp.Regexp, validNext []string, checkOverrides bool) error {
    +	// Let users override rules with $CGO_CFLAGS_ALLOW, $CGO_CFLAGS_DISALLOW, etc.
    +	var (
    +		allow    *regexp.Regexp
    +		disallow *regexp.Regexp
    +	)
    +	if checkOverrides {
    +		if env := cfg.Getenv("CGO_" + name + "_ALLOW"); env != "" {
    +			r, err := regexp.Compile(env)
    +			if err != nil {
    +				return fmt.Errorf("parsing $CGO_%s_ALLOW: %v", name, err)
    +			}
    +			allow = r
    +		}
    +		if env := cfg.Getenv("CGO_" + name + "_DISALLOW"); env != "" {
    +			r, err := regexp.Compile(env)
    +			if err != nil {
    +				return fmt.Errorf("parsing $CGO_%s_DISALLOW: %v", name, err)
    +			}
    +			disallow = r
    +		}
    +	}
    +
    +Args:
    +	for i := 0; i < len(list); i++ {
    +		arg := list[i]
    +		if disallow != nil && disallow.FindString(arg) == arg {
    +			goto Bad
    +		}
    +		if allow != nil && allow.FindString(arg) == arg {
    +			continue Args
    +		}
    +		for _, re := range invalid {
    +			if re.FindString(arg) == arg { // must be complete match
    +				goto Bad
    +			}
    +		}
    +		for _, re := range valid {
    +			if match := re.FindString(arg); match == arg { // must be complete match
    +				continue Args
    +			} else if strings.HasPrefix(arg, "-Wl,--push-state,") {
    +				// Examples for --push-state are written
    +				//     -Wl,--push-state,--as-needed
    +				// Support other commands in the same -Wl arg.
    +				args := strings.Split(arg, ",")
    +				for _, a := range args[1:] {
    +					a = "-Wl," + a
    +					var found bool
    +					for _, re := range valid {
    +						if re.FindString(a) == a {
    +							found = true
    +							break
    +						}
    +					}
    +					if !found {
    +						goto Bad
    +					}
    +					for _, re := range invalid {
    +						if re.FindString(a) == a {
    +							goto Bad
    +						}
    +					}
    +				}
    +				continue Args
    +			}
    +		}
    +		for _, x := range validNext {
    +			if arg == x {
    +				if i+1 < len(list) && load.SafeArg(list[i+1]) {
    +					i++
    +					continue Args
    +				}
    +
    +				// Permit -Wl,-framework -Wl,name.
    +				if i+1 < len(list) &&
    +					strings.HasPrefix(arg, "-Wl,") &&
    +					strings.HasPrefix(list[i+1], "-Wl,") &&
    +					load.SafeArg(list[i+1][4:]) &&
    +					!strings.Contains(list[i+1][4:], ",") {
    +					i++
    +					continue Args
    +				}
    +
    +				// Permit -I= /path, -I $SYSROOT.
    +				if i+1 < len(list) && arg == "-I" {
    +					if (strings.HasPrefix(list[i+1], "=") || strings.HasPrefix(list[i+1], "$SYSROOT")) &&
    +						load.SafeArg(list[i+1][1:]) {
    +						i++
    +						continue Args
    +					}
    +				}
    +
    +				if i+1 < len(list) {
    +					return fmt.Errorf("invalid flag in %s: %s %s (see https://go.dev/s/invalidflag)", source, arg, list[i+1])
    +				}
    +				return fmt.Errorf("invalid flag in %s: %s without argument (see https://go.dev/s/invalidflag)", source, arg)
    +			}
    +		}
    +	Bad:
    +		return fmt.Errorf("invalid flag in %s: %s (see https://go.dev/s/invalidflag)", source, arg)
    +	}
    +	return nil
    +}
    diff --git a/go/src/cmd/go/internal/work/security_test.go b/go/src/cmd/go/internal/work/security_test.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..48f98100a51bd1d6d5b9a5de9d809a0d498dff9f
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/security_test.go
    @@ -0,0 +1,373 @@
    +// Copyright 2018 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package work
    +
    +import (
    +	"os"
    +	"strings"
    +	"testing"
    +)
    +
    +var goodCompilerFlags = [][]string{
    +	{"-DFOO"},
    +	{"-Dfoo=bar"},
    +	{"-Ufoo"},
    +	{"-Ufoo1"},
    +	{"-F/Qt"},
    +	{"-F", "/Qt"},
    +	{"-I/"},
    +	{"-I/etc/passwd"},
    +	{"-I."},
    +	{"-O"},
    +	{"-O2"},
    +	{"-Osmall"},
    +	{"-W"},
    +	{"-Wall"},
    +	{"-Wp,-Dfoo=bar"},
    +	{"-Wp,-Ufoo"},
    +	{"-Wp,-Dfoo1"},
    +	{"-Wp,-Ufoo1"},
    +	{"-flto"},
    +	{"-fobjc-arc"},
    +	{"-fno-objc-arc"},
    +	{"-fomit-frame-pointer"},
    +	{"-fno-omit-frame-pointer"},
    +	{"-fpic"},
    +	{"-fno-pic"},
    +	{"-fPIC"},
    +	{"-fno-PIC"},
    +	{"-fpie"},
    +	{"-fno-pie"},
    +	{"-fPIE"},
    +	{"-fno-PIE"},
    +	{"-fsplit-stack"},
    +	{"-fno-split-stack"},
    +	{"-fstack-xxx"},
    +	{"-fno-stack-xxx"},
    +	{"-fsanitize=hands"},
    +	{"-ftls-model=local-dynamic"},
    +	{"-g"},
    +	{"-ggdb"},
    +	{"-mabi=lp64d"},
    +	{"-march=souza"},
    +	{"-mcmodel=medium"},
    +	{"-mcpu=123"},
    +	{"-mfpu=123"},
    +	{"-mtls-dialect=gnu"},
    +	{"-mtls-dialect=gnu2"},
    +	{"-mtls-dialect=trad"},
    +	{"-mtls-dialect=desc"},
    +	{"-mtls-dialect=xyz"},
    +	{"-msimd=lasx"},
    +	{"-msimd=xyz"},
    +	{"-mdouble-float"},
    +	{"-mrelax"},
    +	{"-mstrict-align"},
    +	{"-mlsx"},
    +	{"-mlasx"},
    +	{"-mfrecipe"},
    +	{"-mlam-bh"},
    +	{"-mlamcas"},
    +	{"-mld-seq-sa"},
    +	{"-mno-relax"},
    +	{"-mno-strict-align"},
    +	{"-mno-lsx"},
    +	{"-mno-lasx"},
    +	{"-mno-frecipe"},
    +	{"-mno-lam-bh"},
    +	{"-mno-lamcas"},
    +	{"-mno-ld-seq-sa"},
    +	{"-mlarge-data-threshold=16"},
    +	{"-mtune=happybirthday"},
    +	{"-mstack-overflow"},
    +	{"-mno-stack-overflow"},
    +	{"-mmacosx-version"},
    +	{"-mnop-fun-dllimport"},
    +	{"-pthread"},
    +	{"-std=c99"},
    +	{"-xc"},
    +	{"-D", "FOO"},
    +	{"-D", "foo=bar"},
    +	{"-I", "."},
    +	{"-I", "/etc/passwd"},
    +	{"-I", "世界"},
    +	{"-I", "=/usr/include/libxml2"},
    +	{"-I", "dir"},
    +	{"-I", "$SYSROOT/dir"},
    +	{"-isystem", "/usr/include/mozjs-68"},
    +	{"-include", "/usr/include/mozjs-68/RequiredDefines.h"},
    +	{"-framework", "Chocolate"},
    +	{"-x", "c"},
    +	{"-v"},
    +}
    +
    +var badCompilerFlags = [][]string{
    +	{"-D@X"},
    +	{"-D-X"},
    +	{"-Ufoo=bar"},
    +	{"-F@dir"},
    +	{"-F-dir"},
    +	{"-I@dir"},
    +	{"-I-dir"},
    +	{"-O@1"},
    +	{"-Wa,-foo"},
    +	{"-W@foo"},
    +	{"-Wp,-DX,-D@X"},
    +	{"-Wp,-UX,-U@X"},
    +	{"-g@gdb"},
    +	{"-g-gdb"},
    +	{"-march=@dawn"},
    +	{"-march=-dawn"},
    +	{"-mcmodel=@model"},
    +	{"-mfpu=@0"},
    +	{"-mfpu=-0"},
    +	{"-mlarge-data-threshold=@12"},
    +	{"-mtls-dialect=@gnu"},
    +	{"-mtls-dialect=-gnu"},
    +	{"-msimd=@none"},
    +	{"-msimd=-none"},
    +	{"-std=@c99"},
    +	{"-std=-c99"},
    +	{"-x@c"},
    +	{"-x-c"},
    +	{"-D", "@foo"},
    +	{"-D", "-foo"},
    +	{"-I", "@foo"},
    +	{"-I", "-foo"},
    +	{"-I", "=@obj"},
    +	{"-include", "@foo"},
    +	{"-framework", "-Caffeine"},
    +	{"-framework", "@Home"},
    +	{"-x", "--c"},
    +	{"-x", "@obj"},
    +}
    +
    +func TestCheckCompilerFlags(t *testing.T) {
    +	for _, f := range goodCompilerFlags {
    +		if err := checkCompilerFlags("test", "test", f); err != nil {
    +			t.Errorf("unexpected error for %q: %v", f, err)
    +		}
    +	}
    +	for _, f := range badCompilerFlags {
    +		if err := checkCompilerFlags("test", "test", f); err == nil {
    +			t.Errorf("missing error for %q", f)
    +		}
    +	}
    +}
    +
    +var goodLinkerFlags = [][]string{
    +	{"-Fbar"},
    +	{"-lbar"},
    +	{"-Lbar"},
    +	{"-fpic"},
    +	{"-fno-pic"},
    +	{"-fPIC"},
    +	{"-fno-PIC"},
    +	{"-fpie"},
    +	{"-fno-pie"},
    +	{"-fPIE"},
    +	{"-fno-PIE"},
    +	{"-fsanitize=hands"},
    +	{"-g"},
    +	{"-ggdb"},
    +	{"-march=souza"},
    +	{"-mcpu=123"},
    +	{"-mfpu=123"},
    +	{"-mtune=happybirthday"},
    +	{"-pic"},
    +	{"-pthread"},
    +	{"-Wl,--hash-style=both"},
    +	{"-Wl,-rpath,foo"},
    +	{"-Wl,-rpath,$ORIGIN/foo"},
    +	{"-Wl,-R", "/foo"},
    +	{"-Wl,-R", "foo"},
    +	{"-Wl,-R,foo"},
    +	{"-Wl,--just-symbols=foo"},
    +	{"-Wl,--just-symbols,foo"},
    +	{"-Wl,--warn-error"},
    +	{"-Wl,--no-warn-error"},
    +	{"foo.so"},
    +	{"_世界.dll"},
    +	{"./x.o"},
    +	{"libcgosotest.dylib"},
    +	{"-F", "framework"},
    +	{"-l", "."},
    +	{"-l", "/etc/passwd"},
    +	{"-l", "世界"},
    +	{"-L", "framework"},
    +	{"-framework", "Chocolate"},
    +	{"-v"},
    +	{"-Wl,-sectcreate,__TEXT,__info_plist,${SRCDIR}/Info.plist"},
    +	{"-Wl,-framework", "-Wl,Chocolate"},
    +	{"-Wl,-framework,Chocolate"},
    +	{"-Wl,-unresolved-symbols=ignore-all"},
    +	{"-Wl,-z,relro"},
    +	{"-Wl,-z,relro,-z,now"},
    +	{"-Wl,-z,now"},
    +	{"-Wl,-z,noexecstack"},
    +	{"libcgotbdtest.tbd"},
    +	{"./libcgotbdtest.tbd"},
    +	{"-Wl,--push-state"},
    +	{"-Wl,--pop-state"},
    +	{"-Wl,--push-state,--as-needed"},
    +	{"-Wl,--push-state,--no-as-needed,-Bstatic"},
    +	{"-Wl,--just-symbols,."},
    +	{"-Wl,-framework,."},
    +	{"-Wl,-rpath,."},
    +	{"-Wl,-rpath-link,."},
    +	{"-Wl,-sectcreate,.,.,."},
    +	{"-Wl,-syslibroot,."},
    +	{"-Wl,-undefined,."},
    +}
    +
    +var badLinkerFlags = [][]string{
    +	{"-DFOO"},
    +	{"-Dfoo=bar"},
    +	{"-W"},
    +	{"-Wall"},
    +	{"-fobjc-arc"},
    +	{"-fno-objc-arc"},
    +	{"-fomit-frame-pointer"},
    +	{"-fno-omit-frame-pointer"},
    +	{"-fsplit-stack"},
    +	{"-fno-split-stack"},
    +	{"-fstack-xxx"},
    +	{"-fno-stack-xxx"},
    +	{"-mstack-overflow"},
    +	{"-mno-stack-overflow"},
    +	{"-mnop-fun-dllimport"},
    +	{"-std=c99"},
    +	{"-xc"},
    +	{"-D", "FOO"},
    +	{"-D", "foo=bar"},
    +	{"-I", "FOO"},
    +	{"-L", "@foo"},
    +	{"-L", "-foo"},
    +	{"-x", "c"},
    +	{"-D@X"},
    +	{"-D-X"},
    +	{"-I@dir"},
    +	{"-I-dir"},
    +	{"-O@1"},
    +	{"-Wa,-foo"},
    +	{"-W@foo"},
    +	{"-g@gdb"},
    +	{"-g-gdb"},
    +	{"-march=@dawn"},
    +	{"-march=-dawn"},
    +	{"-std=@c99"},
    +	{"-std=-c99"},
    +	{"-x@c"},
    +	{"-x-c"},
    +	{"-D", "@foo"},
    +	{"-D", "-foo"},
    +	{"-I", "@foo"},
    +	{"-I", "-foo"},
    +	{"-l", "@foo"},
    +	{"-l", "-foo"},
    +	{"-framework", "-Caffeine"},
    +	{"-framework", "@Home"},
    +	{"-Wl,-framework,-Caffeine"},
    +	{"-Wl,-framework", "-Wl,@Home"},
    +	{"-Wl,-framework", "@Home"},
    +	{"-Wl,-framework,Chocolate,@Home"},
    +	{"-Wl,--hash-style=foo"},
    +	{"-x", "--c"},
    +	{"-x", "@obj"},
    +	{"-Wl,-rpath,@foo"},
    +	{"-Wl,-R,foo,bar"},
    +	{"-Wl,-R,@foo"},
    +	{"-Wl,--just-symbols,@foo"},
    +	{"../x.o"},
    +	{"-Wl,-R,"},
    +	{"-Wl,-O"},
    +	{"-Wl,-e="},
    +	{"-Wl,-e,"},
    +	{"-Wl,-R,-flag"},
    +	{"-Wl,--push-state,"},
    +	{"-Wl,--push-state,@foo"},
    +	{"-fplugin=./-Wl,--push-state,-R.so"},
    +	{"./-Wl,--push-state,-R.c"},
    +}
    +
    +func TestCheckLinkerFlags(t *testing.T) {
    +	for _, f := range goodLinkerFlags {
    +		if err := checkLinkerFlags("test", "test", f); err != nil {
    +			t.Errorf("unexpected error for %q: %v", f, err)
    +		}
    +	}
    +	for _, f := range badLinkerFlags {
    +		if err := checkLinkerFlags("test", "test", f); err == nil {
    +			t.Errorf("missing error for %q", f)
    +		}
    +	}
    +}
    +
    +func TestCheckFlagAllowDisallow(t *testing.T) {
    +	if err := checkCompilerFlags("TEST", "test", []string{"-disallow"}); err == nil {
    +		t.Fatalf("missing error for -disallow")
    +	}
    +	os.Setenv("CGO_TEST_ALLOW", "-disallo")
    +	if err := checkCompilerFlags("TEST", "test", []string{"-disallow"}); err == nil {
    +		t.Fatalf("missing error for -disallow with CGO_TEST_ALLOW=-disallo")
    +	}
    +	os.Setenv("CGO_TEST_ALLOW", "-disallow")
    +	if err := checkCompilerFlags("TEST", "test", []string{"-disallow"}); err != nil {
    +		t.Fatalf("unexpected error for -disallow with CGO_TEST_ALLOW=-disallow: %v", err)
    +	}
    +	os.Unsetenv("CGO_TEST_ALLOW")
    +
    +	if err := checkCompilerFlags("TEST", "test", []string{"-Wall"}); err != nil {
    +		t.Fatalf("unexpected error for -Wall: %v", err)
    +	}
    +	os.Setenv("CGO_TEST_DISALLOW", "-Wall")
    +	if err := checkCompilerFlags("TEST", "test", []string{"-Wall"}); err == nil {
    +		t.Fatalf("missing error for -Wall with CGO_TEST_DISALLOW=-Wall")
    +	}
    +	os.Setenv("CGO_TEST_ALLOW", "-Wall") // disallow wins
    +	if err := checkCompilerFlags("TEST", "test", []string{"-Wall"}); err == nil {
    +		t.Fatalf("missing error for -Wall with CGO_TEST_DISALLOW=-Wall and CGO_TEST_ALLOW=-Wall")
    +	}
    +
    +	os.Setenv("CGO_TEST_ALLOW", "-fplugin.*")
    +	os.Setenv("CGO_TEST_DISALLOW", "-fplugin=lint.so")
    +	if err := checkCompilerFlags("TEST", "test", []string{"-fplugin=faster.so"}); err != nil {
    +		t.Fatalf("unexpected error for -fplugin=faster.so: %v", err)
    +	}
    +	if err := checkCompilerFlags("TEST", "test", []string{"-fplugin=lint.so"}); err == nil {
    +		t.Fatalf("missing error for -fplugin=lint.so: %v", err)
    +	}
    +}
    +
    +func TestCheckCompilerFlagsForInternalLink(t *testing.T) {
    +	// Any "bad" compiler flag should trigger external linking.
    +	for _, f := range badCompilerFlags {
    +		if err := checkCompilerFlagsForInternalLink("test", "test", f); err == nil {
    +			t.Errorf("missing error for %q", f)
    +		}
    +	}
    +
    +	// All "good" compiler flags should not trigger external linking,
    +	// except for anything that begins with "-flto".
    +	for _, f := range goodCompilerFlags {
    +		foundLTO := false
    +		for _, s := range f {
    +			if strings.Contains(s, "-flto") {
    +				foundLTO = true
    +			}
    +		}
    +		if err := checkCompilerFlagsForInternalLink("test", "test", f); err != nil {
    +			// expect error for -flto
    +			if !foundLTO {
    +				t.Errorf("unexpected error for %q: %v", f, err)
    +			}
    +		} else {
    +			// expect no error for everything else
    +			if foundLTO {
    +				t.Errorf("missing error for %q: %v", f, err)
    +			}
    +		}
    +	}
    +}
    diff --git a/go/src/cmd/go/internal/work/shell.go b/go/src/cmd/go/internal/work/shell.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..ceff84d81f831f6181da7eb00d63a34061f24fa8
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/shell.go
    @@ -0,0 +1,705 @@
    +// Copyright 2023 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package work
    +
    +import (
    +	"bytes"
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cache"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/load"
    +	"cmd/go/internal/str"
    +	"cmd/internal/par"
    +	"cmd/internal/pathcache"
    +	"errors"
    +	"fmt"
    +	"internal/lazyregexp"
    +	"io"
    +	"io/fs"
    +	"os"
    +	"os/exec"
    +	"path/filepath"
    +	"runtime"
    +	"strconv"
    +	"strings"
    +	"sync"
    +	"time"
    +)
    +
    +// A Shell runs shell commands and performs shell-like file system operations.
    +//
    +// Shell tracks context related to running commands, and form a tree much like
    +// context.Context.
    +type Shell struct {
    +	action       *Action // nil for the root shell
    +	*shellShared         // per-Builder state shared across Shells
    +}
    +
    +// shellShared is Shell state shared across all Shells derived from a single
    +// root shell (generally a single Builder).
    +type shellShared struct {
    +	workDir string // $WORK, immutable
    +
    +	printLock sync.Mutex
    +	printer   load.Printer
    +	scriptDir string // current directory in printed script
    +
    +	mkdirCache par.Cache[string, error] // a cache of created directories
    +}
    +
    +// NewShell returns a new Shell.
    +//
    +// Shell will internally serialize calls to the printer.
    +// If printer is nil, it uses load.DefaultPrinter.
    +func NewShell(workDir string, printer load.Printer) *Shell {
    +	if printer == nil {
    +		printer = load.DefaultPrinter()
    +	}
    +	shared := &shellShared{
    +		workDir: workDir,
    +		printer: printer,
    +	}
    +	return &Shell{shellShared: shared}
    +}
    +
    +func (sh *Shell) pkg() *load.Package {
    +	if sh.action == nil {
    +		return nil
    +	}
    +	return sh.action.Package
    +}
    +
    +// Printf emits a to this Shell's output stream, formatting it like fmt.Printf.
    +// It is safe to call concurrently.
    +func (sh *Shell) Printf(format string, a ...any) {
    +	sh.printLock.Lock()
    +	defer sh.printLock.Unlock()
    +	sh.printer.Printf(sh.pkg(), format, a...)
    +}
    +
    +func (sh *Shell) printfLocked(format string, a ...any) {
    +	sh.printer.Printf(sh.pkg(), format, a...)
    +}
    +
    +// Errorf reports an error on sh's package and sets the process exit status to 1.
    +func (sh *Shell) Errorf(format string, a ...any) {
    +	sh.printLock.Lock()
    +	defer sh.printLock.Unlock()
    +	sh.printer.Errorf(sh.pkg(), format, a...)
    +}
    +
    +// WithAction returns a Shell identical to sh, but bound to Action a.
    +func (sh *Shell) WithAction(a *Action) *Shell {
    +	sh2 := *sh
    +	sh2.action = a
    +	return &sh2
    +}
    +
    +// Shell returns a shell for running commands on behalf of Action a.
    +func (b *Builder) Shell(a *Action) *Shell {
    +	if a == nil {
    +		// The root shell has a nil Action. The point of this method is to
    +		// create a Shell bound to an Action, so disallow nil Actions here.
    +		panic("nil Action")
    +	}
    +	if a.sh == nil {
    +		a.sh = b.backgroundSh.WithAction(a)
    +	}
    +	return a.sh
    +}
    +
    +// BackgroundShell returns a Builder-wide Shell that's not bound to any Action.
    +// Try not to use this unless there's really no sensible Action available.
    +func (b *Builder) BackgroundShell() *Shell {
    +	return b.backgroundSh
    +}
    +
    +// moveOrCopyFile is like 'mv src dst' or 'cp src dst'.
    +func (sh *Shell) moveOrCopyFile(dst, src string, perm fs.FileMode, force bool) error {
    +	if cfg.BuildN {
    +		sh.ShowCmd("", "mv %s %s", src, dst)
    +		return nil
    +	}
    +
    +	err := checkDstOverwrite(dst, force)
    +	if err != nil {
    +		return err
    +	}
    +
    +	// If we can update the mode and rename to the dst, do it.
    +	// Otherwise fall back to standard copy.
    +
    +	// If the source is in the build cache, we need to copy it.
    +	dir, _, _ := cache.DefaultDir()
    +	if strings.HasPrefix(src, dir) {
    +		return sh.CopyFile(dst, src, perm, force)
    +	}
    +
    +	// On Windows, always copy the file, so that we respect the NTFS
    +	// permissions of the parent folder. https://golang.org/issue/22343.
    +	// What matters here is not cfg.Goos (the system we are building
    +	// for) but runtime.GOOS (the system we are building on).
    +	if runtime.GOOS == "windows" {
    +		return sh.CopyFile(dst, src, perm, force)
    +	}
    +
    +	// If the destination directory has the group sticky bit set,
    +	// we have to copy the file to retain the correct permissions.
    +	// https://golang.org/issue/18878
    +	if fi, err := os.Stat(filepath.Dir(dst)); err == nil {
    +		if fi.IsDir() && (fi.Mode()&fs.ModeSetgid) != 0 {
    +			return sh.CopyFile(dst, src, perm, force)
    +		}
    +	}
    +
    +	// The perm argument is meant to be adjusted according to umask,
    +	// but we don't know what the umask is.
    +	// Create a dummy file to find out.
    +	// This avoids build tags and works even on systems like Plan 9
    +	// where the file mask computation incorporates other information.
    +	mode := perm
    +	f, err := os.OpenFile(filepath.Clean(dst)+"-go-tmp-umask", os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm)
    +	if err == nil {
    +		fi, err := f.Stat()
    +		if err == nil {
    +			mode = fi.Mode() & 0777
    +		}
    +		name := f.Name()
    +		f.Close()
    +		os.Remove(name)
    +	}
    +
    +	if err := os.Chmod(src, mode); err == nil {
    +		if err := os.Rename(src, dst); err == nil {
    +			if cfg.BuildX {
    +				sh.ShowCmd("", "mv %s %s", src, dst)
    +			}
    +			return nil
    +		}
    +	}
    +
    +	return sh.CopyFile(dst, src, perm, force)
    +}
    +
    +// CopyFile is like 'cp src dst'.
    +func (sh *Shell) CopyFile(dst, src string, perm fs.FileMode, force bool) error {
    +	if cfg.BuildN || cfg.BuildX {
    +		sh.ShowCmd("", "cp %s %s", src, dst)
    +		if cfg.BuildN {
    +			return nil
    +		}
    +	}
    +
    +	sf, err := os.Open(src)
    +	if err != nil {
    +		return err
    +	}
    +	defer sf.Close()
    +
    +	err = checkDstOverwrite(dst, force)
    +	if err != nil {
    +		return err
    +	}
    +
    +	// On Windows, remove lingering ~ file from last attempt.
    +	if runtime.GOOS == "windows" {
    +		if _, err := os.Stat(dst + "~"); err == nil {
    +			os.Remove(dst + "~")
    +		}
    +	}
    +
    +	mayberemovefile(dst)
    +	df, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
    +	if err != nil && runtime.GOOS == "windows" {
    +		// Windows does not allow deletion of a binary file
    +		// while it is executing. Try to move it out of the way.
    +		// If the move fails, which is likely, we'll try again the
    +		// next time we do an install of this binary.
    +		if err := os.Rename(dst, dst+"~"); err == nil {
    +			os.Remove(dst + "~")
    +		}
    +		df, err = os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
    +	}
    +	if err != nil {
    +		return fmt.Errorf("copying %s: %w", src, err) // err should already refer to dst
    +	}
    +
    +	_, err = io.Copy(df, sf)
    +	df.Close()
    +	if err != nil {
    +		mayberemovefile(dst)
    +		return fmt.Errorf("copying %s to %s: %v", src, dst, err)
    +	}
    +	return nil
    +}
    +
    +// mayberemovefile removes a file only if it is a regular file
    +// When running as a user with sufficient privileges, we may delete
    +// even device files, for example, which is not intended.
    +func mayberemovefile(s string) {
    +	if fi, err := os.Lstat(s); err == nil && !fi.Mode().IsRegular() {
    +		return
    +	}
    +	os.Remove(s)
    +}
    +
    +// Be careful about removing/overwriting dst.
    +// Do not remove/overwrite if dst exists and is a directory
    +// or a non-empty non-object file.
    +func checkDstOverwrite(dst string, force bool) error {
    +	if fi, err := os.Stat(dst); err == nil {
    +		if fi.IsDir() {
    +			return fmt.Errorf("build output %q already exists and is a directory", dst)
    +		}
    +		if !force && fi.Mode().IsRegular() && fi.Size() != 0 && !isObject(dst) {
    +			return fmt.Errorf("build output %q already exists and is not an object file", dst)
    +		}
    +	}
    +	return nil
    +}
    +
    +// writeFile writes the text to file.
    +func (sh *Shell) writeFile(file string, text []byte) error {
    +	if cfg.BuildN || cfg.BuildX {
    +		switch {
    +		case len(text) == 0:
    +			sh.ShowCmd("", "echo -n > %s # internal", file)
    +		case bytes.IndexByte(text, '\n') == len(text)-1:
    +			// One line. Use a simpler "echo" command.
    +			sh.ShowCmd("", "echo '%s' > %s # internal", bytes.TrimSuffix(text, []byte("\n")), file)
    +		default:
    +			// Use the most general form.
    +			sh.ShowCmd("", "cat >%s << 'EOF' # internal\n%sEOF", file, text)
    +		}
    +	}
    +	if cfg.BuildN {
    +		return nil
    +	}
    +	return os.WriteFile(file, text, 0666)
    +}
    +
    +// Mkdir makes the named directory.
    +func (sh *Shell) Mkdir(dir string) error {
    +	// Make Mkdir(a.Objdir) a no-op instead of an error when a.Objdir == "".
    +	if dir == "" {
    +		return nil
    +	}
    +
    +	// We can be a little aggressive about being
    +	// sure directories exist. Skip repeated calls.
    +	return sh.mkdirCache.Do(dir, func() error {
    +		if cfg.BuildN || cfg.BuildX {
    +			sh.ShowCmd("", "mkdir -p %s", dir)
    +			if cfg.BuildN {
    +				return nil
    +			}
    +		}
    +
    +		return os.MkdirAll(dir, 0777)
    +	})
    +}
    +
    +// RemoveAll is like 'rm -rf'. It attempts to remove all paths even if there's
    +// an error, and returns the first error.
    +func (sh *Shell) RemoveAll(paths ...string) error {
    +	if cfg.BuildN || cfg.BuildX {
    +		// Don't say we are removing the directory if we never created it.
    +		show := func() bool {
    +			for _, path := range paths {
    +				if _, ok := sh.mkdirCache.Get(path); ok {
    +					return true
    +				}
    +				if _, err := os.Stat(path); !os.IsNotExist(err) {
    +					return true
    +				}
    +			}
    +			return false
    +		}
    +		if show() {
    +			sh.ShowCmd("", "rm -rf %s", strings.Join(paths, " "))
    +		}
    +	}
    +	if cfg.BuildN {
    +		return nil
    +	}
    +
    +	var err error
    +	for _, path := range paths {
    +		if err2 := os.RemoveAll(path); err2 != nil && err == nil {
    +			err = err2
    +		}
    +	}
    +	return err
    +}
    +
    +// Symlink creates a symlink newname -> oldname.
    +func (sh *Shell) Symlink(oldname, newname string) error {
    +	// It's not an error to try to recreate an existing symlink.
    +	if link, err := os.Readlink(newname); err == nil && link == oldname {
    +		return nil
    +	}
    +
    +	if cfg.BuildN || cfg.BuildX {
    +		sh.ShowCmd("", "ln -s %s %s", oldname, newname)
    +		if cfg.BuildN {
    +			return nil
    +		}
    +	}
    +	return os.Symlink(oldname, newname)
    +}
    +
    +// fmtCmd formats a command in the manner of fmt.Sprintf but also:
    +//
    +//	fmtCmd replaces the value of b.WorkDir with $WORK.
    +func (sh *Shell) fmtCmd(dir string, format string, args ...any) string {
    +	cmd := fmt.Sprintf(format, args...)
    +	if sh.workDir != "" && !strings.HasPrefix(cmd, "cat ") {
    +		cmd = strings.ReplaceAll(cmd, sh.workDir, "$WORK")
    +		escaped := strconv.Quote(sh.workDir)
    +		escaped = escaped[1 : len(escaped)-1] // strip quote characters
    +		if escaped != sh.workDir {
    +			cmd = strings.ReplaceAll(cmd, escaped, "$WORK")
    +		}
    +	}
    +	return cmd
    +}
    +
    +// ShowCmd prints the given command to standard output
    +// for the implementation of -n or -x.
    +//
    +// ShowCmd also replaces the name of the current script directory with dot (.)
    +// but only when it is at the beginning of a space-separated token.
    +//
    +// If dir is not "" or "/" and not the current script directory, ShowCmd first
    +// prints a "cd" command to switch to dir and updates the script directory.
    +func (sh *Shell) ShowCmd(dir string, format string, args ...any) {
    +	// Use the output lock directly so we can manage scriptDir.
    +	sh.printLock.Lock()
    +	defer sh.printLock.Unlock()
    +
    +	cmd := sh.fmtCmd(dir, format, args...)
    +
    +	if dir != "" && dir != "/" {
    +		if dir != sh.scriptDir {
    +			// Show changing to dir and update the current directory.
    +			sh.printfLocked("%s", sh.fmtCmd("", "cd %s\n", dir))
    +			sh.scriptDir = dir
    +		}
    +		// Replace scriptDir is our working directory. Replace it
    +		// with "." in the command.
    +		dot := " ."
    +		if dir[len(dir)-1] == filepath.Separator {
    +			dot += string(filepath.Separator)
    +		}
    +		cmd = strings.ReplaceAll(" "+cmd, " "+dir, dot)[1:]
    +	}
    +
    +	sh.printfLocked("%s\n", cmd)
    +}
    +
    +// reportCmd reports the output and exit status of a command. The cmdOut and
    +// cmdErr arguments are the output and exit error of the command, respectively.
    +//
    +// The exact reporting behavior is as follows:
    +//
    +//	cmdOut  cmdErr  Result
    +//	""      nil     print nothing, return nil
    +//	!=""    nil     print output, return nil
    +//	""      !=nil   print nothing, return cmdErr (later printed)
    +//	!=""    !=nil   print nothing, ignore err, return output as error (later printed)
    +//
    +// reportCmd returns a non-nil error if and only if cmdErr != nil. It assumes
    +// that the command output, if non-empty, is more detailed than the command
    +// error (which is usually just an exit status), so prefers using the output as
    +// the ultimate error. Typically, the caller should return this error from an
    +// Action, which it will be printed by the Builder.
    +//
    +// reportCmd formats the output as "# desc" followed by the given output. The
    +// output is expected to contain references to 'dir', usually the source
    +// directory for the package that has failed to build. reportCmd rewrites
    +// mentions of dir with a relative path to dir when the relative path is
    +// shorter. This is usually more pleasant. For example, if fmt doesn't compile
    +// and we are in src/html, the output is
    +//
    +//	$ go build
    +//	# fmt
    +//	../fmt/print.go:1090: undefined: asdf
    +//	$
    +//
    +// instead of
    +//
    +//	$ go build
    +//	# fmt
    +//	/usr/gopher/go/src/fmt/print.go:1090: undefined: asdf
    +//	$
    +//
    +// reportCmd also replaces references to the work directory with $WORK, replaces
    +// cgo file paths with the original file path, and replaces cgo-mangled names
    +// with "C.name".
    +//
    +// desc is optional. If "", a.Package.Desc() is used.
    +//
    +// dir is optional. If "", a.Package.Dir is used.
    +func (sh *Shell) reportCmd(desc, dir string, cmdOut []byte, cmdErr error) error {
    +	if len(cmdOut) == 0 && cmdErr == nil {
    +		// Common case
    +		return nil
    +	}
    +	if len(cmdOut) == 0 && cmdErr != nil {
    +		// Just return the error.
    +		//
    +		// TODO: This is what we've done for a long time, but it may be a
    +		// mistake because it loses all of the extra context and results in
    +		// ultimately less descriptive output. We should probably just take the
    +		// text of cmdErr as the output in this case and do everything we
    +		// otherwise would. We could chain the errors if we feel like it.
    +		return cmdErr
    +	}
    +
    +	// Fetch defaults from the package.
    +	var p *load.Package
    +	a := sh.action
    +	if a != nil {
    +		p = a.Package
    +	}
    +	var importPath string
    +	if p != nil {
    +		importPath = p.ImportPath
    +		if desc == "" {
    +			desc = p.Desc()
    +		}
    +		if dir == "" {
    +			dir = p.Dir
    +		}
    +	}
    +
    +	out := string(cmdOut)
    +
    +	if !strings.HasSuffix(out, "\n") {
    +		out = out + "\n"
    +	}
    +
    +	// Replace workDir with $WORK
    +	out = replacePrefix(out, sh.workDir, "$WORK")
    +
    +	// Rewrite mentions of dir with a relative path to dir
    +	// when the relative path is shorter.
    +	for {
    +		// Note that dir starts out long, something like
    +		// /foo/bar/baz/root/a
    +		// The target string to be reduced is something like
    +		// (blah-blah-blah) /foo/bar/baz/root/sibling/whatever.go:blah:blah
    +		// /foo/bar/baz/root/a doesn't match /foo/bar/baz/root/sibling, but the prefix
    +		// /foo/bar/baz/root does.  And there may be other niblings sharing shorter
    +		// prefixes, the only way to find them is to look.
    +		// This doesn't always produce a relative path --
    +		// /foo is shorter than ../../.., for example.
    +		if reldir := base.ShortPath(dir); reldir != dir {
    +			out = replacePrefix(out, dir, reldir)
    +			if filepath.Separator == '\\' {
    +				// Don't know why, sometimes this comes out with slashes, not backslashes.
    +				wdir := strings.ReplaceAll(dir, "\\", "/")
    +				out = replacePrefix(out, wdir, reldir)
    +			}
    +		}
    +		dirP := filepath.Dir(dir)
    +		if dir == dirP {
    +			break
    +		}
    +		dir = dirP
    +	}
    +
    +	// Fix up output referring to cgo-generated code to be more readable.
    +	// Replace x.go:19[/tmp/.../x.cgo1.go:18] with x.go:19.
    +	// Replace *[100]_Ctype_foo with *[100]C.foo.
    +	// If we're using -x, assume we're debugging and want the full dump, so disable the rewrite.
    +	if !cfg.BuildX && cgoLine.MatchString(out) {
    +		out = cgoLine.ReplaceAllString(out, "")
    +		out = cgoTypeSigRe.ReplaceAllString(out, "C.")
    +	}
    +
    +	// Usually desc is already p.Desc(), but if not, signal cmdError.Error to
    +	// add a line explicitly mentioning the import path.
    +	needsPath := importPath != "" && p != nil && desc != p.Desc()
    +
    +	err := &cmdError{desc, out, importPath, needsPath}
    +	if cmdErr != nil {
    +		// The command failed. Report the output up as an error.
    +		return err
    +	}
    +	// The command didn't fail, so just print the output as appropriate.
    +	if a != nil && a.output != nil {
    +		// The Action is capturing output.
    +		a.output = append(a.output, err.Error()...)
    +	} else {
    +		// Write directly to the Builder output.
    +		sh.Printf("%s", err)
    +	}
    +	return nil
    +}
    +
    +// replacePrefix is like strings.ReplaceAll, but only replaces instances of old
    +// that are preceded by ' ', '\t', or appear at the beginning of a line.
    +func replacePrefix(s, old, new string) string {
    +	n := strings.Count(s, old)
    +	if n == 0 {
    +		return s
    +	}
    +
    +	s = strings.ReplaceAll(s, " "+old, " "+new)
    +	s = strings.ReplaceAll(s, "\n"+old, "\n"+new)
    +	s = strings.ReplaceAll(s, "\n\t"+old, "\n\t"+new)
    +	if strings.HasPrefix(s, old) {
    +		s = new + s[len(old):]
    +	}
    +	return s
    +}
    +
    +type cmdError struct {
    +	desc       string
    +	text       string
    +	importPath string
    +	needsPath  bool // Set if desc does not already include the import path
    +}
    +
    +func (e *cmdError) Error() string {
    +	var msg string
    +	if e.needsPath {
    +		// Ensure the import path is part of the message.
    +		// Clearly distinguish the description from the import path.
    +		msg = fmt.Sprintf("# %s\n# [%s]\n", e.importPath, e.desc)
    +	} else {
    +		msg = "# " + e.desc + "\n"
    +	}
    +	return msg + e.text
    +}
    +
    +func (e *cmdError) ImportPath() string {
    +	return e.importPath
    +}
    +
    +var cgoLine = lazyregexp.New(`\[[^\[\]]+\.(cgo1|cover)\.go:[0-9]+(:[0-9]+)?\]`)
    +var cgoTypeSigRe = lazyregexp.New(`\b_C2?(type|func|var|macro)_\B`)
    +
    +// run runs the command given by cmdline in the directory dir.
    +// If the command fails, run prints information about the failure
    +// and returns a non-nil error.
    +func (sh *Shell) run(dir string, desc string, env []string, cmdargs ...any) error {
    +	out, err := sh.runOut(dir, env, cmdargs...)
    +	if desc == "" {
    +		desc = sh.fmtCmd(dir, "%s", strings.Join(str.StringList(cmdargs...), " "))
    +	}
    +	return sh.reportCmd(desc, dir, out, err)
    +}
    +
    +// runOut runs the command given by cmdline in the directory dir.
    +// It returns the command output and any errors that occurred.
    +// It accumulates execution time in a.
    +func (sh *Shell) runOut(dir string, env []string, cmdargs ...any) ([]byte, error) {
    +	a := sh.action
    +
    +	cmdline := str.StringList(cmdargs...)
    +
    +	for _, arg := range cmdline {
    +		// GNU binutils commands, including gcc and gccgo, interpret an argument
    +		// @foo anywhere in the command line (even following --) as meaning
    +		// "read and insert arguments from the file named foo."
    +		// Don't say anything that might be misinterpreted that way.
    +		if strings.HasPrefix(arg, "@") {
    +			return nil, fmt.Errorf("invalid command-line argument %s in command: %s", arg, joinUnambiguously(cmdline))
    +		}
    +	}
    +
    +	if cfg.BuildN || cfg.BuildX {
    +		var envcmdline string
    +		for _, e := range env {
    +			if j := strings.IndexByte(e, '='); j != -1 {
    +				if strings.ContainsRune(e[j+1:], '\'') {
    +					envcmdline += fmt.Sprintf("%s=%q", e[:j], e[j+1:])
    +				} else {
    +					envcmdline += fmt.Sprintf("%s='%s'", e[:j], e[j+1:])
    +				}
    +				envcmdline += " "
    +			}
    +		}
    +		envcmdline += joinUnambiguously(cmdline)
    +		sh.ShowCmd(dir, "%s", envcmdline)
    +		if cfg.BuildN {
    +			return nil, nil
    +		}
    +	}
    +
    +	var buf bytes.Buffer
    +	path, err := pathcache.LookPath(cmdline[0])
    +	if err != nil {
    +		return nil, err
    +	}
    +	cmd := exec.Command(path, cmdline[1:]...)
    +	if cmd.Path != "" {
    +		cmd.Args[0] = cmd.Path
    +	}
    +	cmd.Stdout = &buf
    +	cmd.Stderr = &buf
    +	cleanup := passLongArgsInResponseFiles(cmd)
    +	defer cleanup()
    +	if dir != "." {
    +		cmd.Dir = dir
    +	}
    +	cmd.Env = cmd.Environ() // Pre-allocate with correct PWD.
    +
    +	// Add the TOOLEXEC_IMPORTPATH environment variable for -toolexec tools.
    +	// It doesn't really matter if -toolexec isn't being used.
    +	// Note that a.Package.Desc is not really an import path,
    +	// but this is consistent with 'go list -f {{.ImportPath}}'.
    +	// Plus, it is useful to uniquely identify packages in 'go list -json'.
    +	if a != nil && a.Package != nil {
    +		cmd.Env = append(cmd.Env, "TOOLEXEC_IMPORTPATH="+a.Package.Desc())
    +	}
    +
    +	cmd.Env = append(cmd.Env, env...)
    +	start := time.Now()
    +	err = cmd.Run()
    +	if a != nil && a.json != nil {
    +		aj := a.json
    +		aj.Cmd = append(aj.Cmd, joinUnambiguously(cmdline))
    +		aj.CmdReal += time.Since(start)
    +		if ps := cmd.ProcessState; ps != nil {
    +			aj.CmdUser += ps.UserTime()
    +			aj.CmdSys += ps.SystemTime()
    +		}
    +	}
    +
    +	// err can be something like 'exit status 1'.
    +	// Add information about what program was running.
    +	// Note that if buf.Bytes() is non-empty, the caller usually
    +	// shows buf.Bytes() and does not print err at all, so the
    +	// prefix here does not make most output any more verbose.
    +	if err != nil {
    +		err = errors.New(cmdline[0] + ": " + err.Error())
    +	}
    +	return buf.Bytes(), err
    +}
    +
    +// joinUnambiguously prints the slice, quoting where necessary to make the
    +// output unambiguous.
    +// TODO: See issue 5279. The printing of commands needs a complete redo.
    +func joinUnambiguously(a []string) string {
    +	var buf strings.Builder
    +	for i, s := range a {
    +		if i > 0 {
    +			buf.WriteByte(' ')
    +		}
    +		q := strconv.Quote(s)
    +		// A gccgo command line can contain -( and -).
    +		// Make sure we quote them since they are special to the shell.
    +		// The trimpath argument can also contain > (part of =>) and ;. Quote those too.
    +		if s == "" || strings.ContainsAny(s, " ()>;") || len(q) > len(s)+2 {
    +			buf.WriteString(q)
    +		} else {
    +			buf.WriteString(s)
    +		}
    +	}
    +	return buf.String()
    +}
    diff --git a/go/src/cmd/go/internal/work/shell_test.go b/go/src/cmd/go/internal/work/shell_test.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..24bef4e684a48b42c5a863ab0cb29ac789e489d6
    --- /dev/null
    +++ b/go/src/cmd/go/internal/work/shell_test.go
    @@ -0,0 +1,139 @@
    +// Copyright 2023 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +//go:build unix
    +
    +package work
    +
    +import (
    +	"bytes"
    +	"internal/testenv"
    +	"strings"
    +	"testing"
    +	"unicode"
    +)
    +
    +func FuzzSplitPkgConfigOutput(f *testing.F) {
    +	testenv.MustHaveExecPath(f, "/bin/sh")
    +
    +	f.Add([]byte(`$FOO`))
    +	f.Add([]byte(`\$FOO`))
    +	f.Add([]byte(`${FOO}`))
    +	f.Add([]byte(`\${FOO}`))
    +	f.Add([]byte(`$(/bin/false)`))
    +	f.Add([]byte(`\$(/bin/false)`))
    +	f.Add([]byte(`$((0))`))
    +	f.Add([]byte(`\$((0))`))
    +	f.Add([]byte(`unescaped space`))
    +	f.Add([]byte(`escaped\ space`))
    +	f.Add([]byte(`"unterminated quote`))
    +	f.Add([]byte(`'unterminated quote`))
    +	f.Add([]byte(`unterminated escape\`))
    +	f.Add([]byte(`"quote with unterminated escape\`))
    +	f.Add([]byte(`'quoted "double quotes"'`))
    +	f.Add([]byte(`"quoted 'single quotes'"`))
    +	f.Add([]byte(`"\$0"`))
    +	f.Add([]byte(`"\$\0"`))
    +	f.Add([]byte(`"\$"`))
    +	f.Add([]byte(`"\$ "`))
    +
    +	// Example positive inputs from TestSplitPkgConfigOutput.
    +	// Some bare newlines have been removed so that the inputs
    +	// are valid in the shell script we use for comparison.
    +	f.Add([]byte(`-r:foo -L/usr/white\ space/lib -lfoo\ bar -lbar\ baz`))
    +	f.Add([]byte(`-lextra\ fun\ arg\\`))
    +	f.Add([]byte("\textra     whitespace\r"))
    +	f.Add([]byte("     \r      "))
    +	f.Add([]byte(`"-r:foo" "-L/usr/white space/lib" "-lfoo bar" "-lbar baz"`))
    +	f.Add([]byte(`"-lextra fun arg\\"`))
    +	f.Add([]byte(`"     \r\n\      "`))
    +	f.Add([]byte(`""`))
    +	f.Add([]byte(``))
    +	f.Add([]byte(`"\\"`))
    +	f.Add([]byte(`"\x"`))
    +	f.Add([]byte(`"\\x"`))
    +	f.Add([]byte(`'\\'`))
    +	f.Add([]byte(`'\x'`))
    +	f.Add([]byte(`"\\x"`))
    +	f.Add([]byte("\\\n"))
    +	f.Add([]byte(`-fPIC -I/test/include/foo -DQUOTED='"/test/share/doc"'`))
    +	f.Add([]byte(`-fPIC -I/test/include/foo -DQUOTED="/test/share/doc"`))
    +	f.Add([]byte(`-fPIC -I/test/include/foo -DQUOTED=\"/test/share/doc\"`))
    +	f.Add([]byte(`-fPIC -I/test/include/foo -DQUOTED='/test/share/doc'`))
    +	f.Add([]byte(`-DQUOTED='/te\st/share/d\oc'`))
    +	f.Add([]byte(`-Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\ world`))
    +	f.Add([]byte(`"broken\"" \\\a "a"`))
    +
    +	// Example negative inputs from TestSplitPkgConfigOutput.
    +	f.Add([]byte(`"     \r\n      `))
    +	f.Add([]byte(`"-r:foo" "-L/usr/white space/lib "-lfoo bar" "-lbar baz"`))
    +	f.Add([]byte(`"-lextra fun arg\\`))
    +	f.Add([]byte(`broken flag\`))
    +	f.Add([]byte(`extra broken flag \`))
    +	f.Add([]byte(`\`))
    +	f.Add([]byte(`"broken\"" "extra" \`))
    +
    +	f.Fuzz(func(t *testing.T, b []byte) {
    +		t.Parallel()
    +
    +		if bytes.ContainsAny(b, "*?[#~%\x00{}!") {
    +			t.Skipf("skipping %#q: contains a sometimes-quoted character", b)
    +		}
    +		// splitPkgConfigOutput itself rejects inputs that contain unquoted
    +		// shell operator characters. (Quoted shell characters are fine.)
    +
    +		for _, c := range b {
    +			if c > unicode.MaxASCII {
    +				t.Skipf("skipping %#q: contains a non-ASCII character %q", b, c)
    +			}
    +			if !unicode.IsGraphic(rune(c)) && !unicode.IsSpace(rune(c)) {
    +				t.Skipf("skipping %#q: contains non-graphic character %q", b, c)
    +			}
    +		}
    +
    +		args, err := splitPkgConfigOutput(b)
    +		if err != nil {
    +			// We haven't checked that the shell would actually reject this input too,
    +			// but if splitPkgConfigOutput rejected it it's probably too dangerous to
    +			// run in the script.
    +			t.Logf("%#q: %v", b, err)
    +			return
    +		}
    +		t.Logf("splitPkgConfigOutput(%#q) = %#q", b, args)
    +		if len(args) == 0 {
    +			t.Skipf("skipping %#q: contains no arguments", b)
    +		}
    +
    +		var buf strings.Builder
    +		for _, arg := range args {
    +			buf.WriteString(arg)
    +			buf.WriteString("\n")
    +		}
    +		wantOut := buf.String()
    +
    +		if strings.Count(wantOut, "\n") != len(args)+bytes.Count(b, []byte("\n")) {
    +			// One of the newlines in b was treated as a delimiter and not part of an
    +			// argument. Our bash test script would interpret that as a syntax error.
    +			t.Skipf("skipping %#q: contains a bare newline", b)
    +		}
    +
    +		// We use the printf shell command to echo the arguments because, per
    +		// https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html#tag_20_37_16:
    +		// “It is not possible to use echo portably across all POSIX systems unless
    +		// both -n (as the first argument) and escape sequences are omitted.”
    +		cmd := testenv.Command(t, "/bin/sh", "-c", "printf '%s\n' "+string(b))
    +		cmd.Env = append(cmd.Environ(), "LC_ALL=POSIX", "POSIXLY_CORRECT=1")
    +		cmd.Stderr = new(strings.Builder)
    +		out, err := cmd.Output()
    +		if err != nil {
    +			t.Fatalf("%#q: %v\n%s", cmd.Args, err, cmd.Stderr)
    +		}
    +
    +		if string(out) != wantOut {
    +			t.Logf("%#q:\n%#q", cmd.Args, out)
    +			t.Logf("want:\n%#q", wantOut)
    +			t.Errorf("parsed args do not match")
    +		}
    +	})
    +}
    diff --git a/go/src/cmd/go/internal/workcmd/edit.go b/go/src/cmd/go/internal/workcmd/edit.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..9b62dbb15f7c494d8966b7f521fe815d28bd14e8
    --- /dev/null
    +++ b/go/src/cmd/go/internal/workcmd/edit.go
    @@ -0,0 +1,380 @@
    +// Copyright 2021 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// go work edit
    +
    +package workcmd
    +
    +import (
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/gover"
    +	"cmd/go/internal/modload"
    +	"context"
    +	"encoding/json"
    +	"fmt"
    +	"os"
    +	"path/filepath"
    +	"strings"
    +
    +	"golang.org/x/mod/module"
    +
    +	"golang.org/x/mod/modfile"
    +)
    +
    +var cmdEdit = &base.Command{
    +	UsageLine: "go work edit [editing flags] [go.work]",
    +	Short:     "edit go.work from tools or scripts",
    +	Long: `Edit provides a command-line interface for editing go.work,
    +for use primarily by tools or scripts. It only reads go.work;
    +it does not look up information about the modules involved.
    +If no file is specified, Edit looks for a go.work file in the current
    +directory and its parent directories
    +
    +The editing flags specify a sequence of editing operations.
    +
    +The -fmt flag reformats the go.work file without making other changes.
    +This reformatting is also implied by any other modifications that use or
    +rewrite the go.mod file. The only time this flag is needed is if no other
    +flags are specified, as in 'go work edit -fmt'.
    +
    +The -godebug=key=value flag adds a godebug key=value line,
    +replacing any existing godebug lines with the given key.
    +
    +The -dropgodebug=key flag drops any existing godebug lines
    +with the given key.
    +
    +The -use=path and -dropuse=path flags
    +add and drop a use directive from the go.work file's set of module directories.
    +
    +The -replace=old[@v]=new[@v] flag adds a replacement of the given
    +module path and version pair. If the @v in old@v is omitted, a
    +replacement without a version on the left side is added, which applies
    +to all versions of the old module path. If the @v in new@v is omitted,
    +the new path should be a local module root directory, not a module
    +path. Note that -replace overrides any redundant replacements for old[@v],
    +so omitting @v will drop existing replacements for specific versions.
    +
    +The -dropreplace=old[@v] flag drops a replacement of the given
    +module path and version pair. If the @v is omitted, a replacement without
    +a version on the left side is dropped.
    +
    +The -use, -dropuse, -replace, and -dropreplace,
    +editing flags may be repeated, and the changes are applied in the order given.
    +
    +The -go=version flag sets the expected Go language version.
    +
    +The -toolchain=name flag sets the Go toolchain to use.
    +
    +The -print flag prints the final go.work in its text format instead of
    +writing it back to go.mod.
    +
    +The -json flag prints the final go.work file in JSON format instead of
    +writing it back to go.mod. The JSON output corresponds to these Go types:
    +
    +	type GoWork struct {
    +		Go        string
    +		Toolchain string
    +		Godebug   []Godebug
    +		Use       []Use
    +		Replace   []Replace
    +	}
    +
    +	type Godebug struct {
    +		Key   string
    +		Value string
    +	}
    +
    +	type Use struct {
    +		DiskPath   string
    +		ModulePath string
    +	}
    +
    +	type Replace struct {
    +		Old Module
    +		New Module
    +	}
    +
    +	type Module struct {
    +		Path    string
    +		Version string
    +	}
    +
    +See the workspaces reference at https://go.dev/ref/mod#workspaces
    +for more information.
    +`,
    +}
    +
    +var (
    +	editFmt       = cmdEdit.Flag.Bool("fmt", false, "")
    +	editGo        = cmdEdit.Flag.String("go", "", "")
    +	editToolchain = cmdEdit.Flag.String("toolchain", "", "")
    +	editJSON      = cmdEdit.Flag.Bool("json", false, "")
    +	editPrint     = cmdEdit.Flag.Bool("print", false, "")
    +	workedits     []func(file *modfile.WorkFile) // edits specified in flags
    +)
    +
    +type flagFunc func(string)
    +
    +func (f flagFunc) String() string     { return "" }
    +func (f flagFunc) Set(s string) error { f(s); return nil }
    +
    +func init() {
    +	cmdEdit.Run = runEditwork // break init cycle
    +
    +	cmdEdit.Flag.Var(flagFunc(flagEditworkGodebug), "godebug", "")
    +	cmdEdit.Flag.Var(flagFunc(flagEditworkDropGodebug), "dropgodebug", "")
    +	cmdEdit.Flag.Var(flagFunc(flagEditworkUse), "use", "")
    +	cmdEdit.Flag.Var(flagFunc(flagEditworkDropUse), "dropuse", "")
    +	cmdEdit.Flag.Var(flagFunc(flagEditworkReplace), "replace", "")
    +	cmdEdit.Flag.Var(flagFunc(flagEditworkDropReplace), "dropreplace", "")
    +	base.AddChdirFlag(&cmdEdit.Flag)
    +}
    +
    +func runEditwork(ctx context.Context, cmd *base.Command, args []string) {
    +	moduleLoaderState := modload.NewState()
    +	if *editJSON && *editPrint {
    +		base.Fatalf("go: cannot use both -json and -print")
    +	}
    +
    +	if len(args) > 1 {
    +		base.Fatalf("go: 'go help work edit' accepts at most one argument")
    +	}
    +	var gowork string
    +	if len(args) == 1 {
    +		gowork = args[0]
    +	} else {
    +		moduleLoaderState.InitWorkfile()
    +		gowork = modload.WorkFilePath(moduleLoaderState)
    +	}
    +	if gowork == "" {
    +		base.Fatalf("go: no go.work file found\n\t(run 'go work init' first or specify path using GOWORK environment variable)")
    +	}
    +
    +	if *editGo != "" && *editGo != "none" {
    +		if !modfile.GoVersionRE.MatchString(*editGo) {
    +			base.Fatalf(`go work: invalid -go option; expecting something like "-go %s"`, gover.Local())
    +		}
    +	}
    +	if *editToolchain != "" && *editToolchain != "none" {
    +		if !modfile.ToolchainRE.MatchString(*editToolchain) {
    +			base.Fatalf(`go work: invalid -toolchain option; expecting something like "-toolchain go%s"`, gover.Local())
    +		}
    +	}
    +
    +	anyFlags := *editGo != "" ||
    +		*editToolchain != "" ||
    +		*editJSON ||
    +		*editPrint ||
    +		*editFmt ||
    +		len(workedits) > 0
    +
    +	if !anyFlags {
    +		base.Fatalf("go: no flags specified (see 'go help work edit').")
    +	}
    +
    +	workFile, err := modload.ReadWorkFile(gowork)
    +	if err != nil {
    +		base.Fatalf("go: errors parsing %s:\n%s", base.ShortPath(gowork), err)
    +	}
    +
    +	if *editGo == "none" {
    +		workFile.DropGoStmt()
    +	} else if *editGo != "" {
    +		if err := workFile.AddGoStmt(*editGo); err != nil {
    +			base.Fatalf("go: internal error: %v", err)
    +		}
    +	}
    +	if *editToolchain == "none" {
    +		workFile.DropToolchainStmt()
    +	} else if *editToolchain != "" {
    +		if err := workFile.AddToolchainStmt(*editToolchain); err != nil {
    +			base.Fatalf("go: internal error: %v", err)
    +		}
    +	}
    +
    +	if len(workedits) > 0 {
    +		for _, edit := range workedits {
    +			edit(workFile)
    +		}
    +	}
    +
    +	workFile.SortBlocks()
    +	workFile.Cleanup() // clean file after edits
    +
    +	// Note: No call to modload.UpdateWorkFile here.
    +	// Edit's job is only to make the edits on the command line,
    +	// not to apply the kinds of semantic changes that
    +	// UpdateWorkFile does (or would eventually do, if we
    +	// decide to add the module comments in go.work).
    +
    +	if *editJSON {
    +		editPrintJSON(workFile)
    +		return
    +	}
    +
    +	if *editPrint {
    +		os.Stdout.Write(modfile.Format(workFile.Syntax))
    +		return
    +	}
    +
    +	modload.WriteWorkFile(gowork, workFile)
    +}
    +
    +// flagEditworkGodebug implements the -godebug flag.
    +func flagEditworkGodebug(arg string) {
    +	key, value, ok := strings.Cut(arg, "=")
    +	if !ok || strings.ContainsAny(arg, "\"`',") {
    +		base.Fatalf("go: -godebug=%s: need key=value", arg)
    +	}
    +	workedits = append(workedits, func(f *modfile.WorkFile) {
    +		if err := f.AddGodebug(key, value); err != nil {
    +			base.Fatalf("go: -godebug=%s: %v", arg, err)
    +		}
    +	})
    +}
    +
    +// flagEditworkDropGodebug implements the -dropgodebug flag.
    +func flagEditworkDropGodebug(arg string) {
    +	workedits = append(workedits, func(f *modfile.WorkFile) {
    +		if err := f.DropGodebug(arg); err != nil {
    +			base.Fatalf("go: -dropgodebug=%s: %v", arg, err)
    +		}
    +	})
    +}
    +
    +// flagEditworkUse implements the -use flag.
    +func flagEditworkUse(arg string) {
    +	workedits = append(workedits, func(f *modfile.WorkFile) {
    +		_, mf, err := modload.ReadModFile(filepath.Join(arg, "go.mod"), nil)
    +		modulePath := ""
    +		if err == nil {
    +			modulePath = mf.Module.Mod.Path
    +		}
    +		f.AddUse(modload.ToDirectoryPath(arg), modulePath)
    +		if err := f.AddUse(modload.ToDirectoryPath(arg), ""); err != nil {
    +			base.Fatalf("go: -use=%s: %v", arg, err)
    +		}
    +	})
    +}
    +
    +// flagEditworkDropUse implements the -dropuse flag.
    +func flagEditworkDropUse(arg string) {
    +	workedits = append(workedits, func(f *modfile.WorkFile) {
    +		if err := f.DropUse(modload.ToDirectoryPath(arg)); err != nil {
    +			base.Fatalf("go: -dropdirectory=%s: %v", arg, err)
    +		}
    +	})
    +}
    +
    +// allowedVersionArg returns whether a token may be used as a version in go.mod.
    +// We don't call modfile.CheckPathVersion, because that insists on versions
    +// being in semver form, but here we want to allow versions like "master" or
    +// "1234abcdef", which the go command will resolve the next time it runs (or
    +// during -fix).  Even so, we need to make sure the version is a valid token.
    +func allowedVersionArg(arg string) bool {
    +	return !modfile.MustQuote(arg)
    +}
    +
    +// parsePathVersionOptional parses path[@version], using adj to
    +// describe any errors.
    +func parsePathVersionOptional(adj, arg string, allowDirPath bool) (path, version string, err error) {
    +	before, after, found, err := modload.ParsePathVersion(arg)
    +	if err != nil {
    +		return "", "", err
    +	}
    +	if !found {
    +		path = arg
    +	} else {
    +		path, version = strings.TrimSpace(before), strings.TrimSpace(after)
    +	}
    +	if err := module.CheckImportPath(path); err != nil {
    +		if !allowDirPath || !modfile.IsDirectoryPath(path) {
    +			return path, version, fmt.Errorf("invalid %s path: %v", adj, err)
    +		}
    +	}
    +	if path != arg && !allowedVersionArg(version) {
    +		return path, version, fmt.Errorf("invalid %s version: %q", adj, version)
    +	}
    +	return path, version, nil
    +}
    +
    +// flagEditworkReplace implements the -replace flag.
    +func flagEditworkReplace(arg string) {
    +	before, after, found := strings.Cut(arg, "=")
    +	if !found {
    +		base.Fatalf("go: -replace=%s: need old[@v]=new[@w] (missing =)", arg)
    +	}
    +	old, new := strings.TrimSpace(before), strings.TrimSpace(after)
    +	if strings.HasPrefix(new, ">") {
    +		base.Fatalf("go: -replace=%s: separator between old and new is =, not =>", arg)
    +	}
    +	oldPath, oldVersion, err := parsePathVersionOptional("old", old, false)
    +	if err != nil {
    +		base.Fatalf("go: -replace=%s: %v", arg, err)
    +	}
    +	newPath, newVersion, err := parsePathVersionOptional("new", new, true)
    +	if err != nil {
    +		base.Fatalf("go: -replace=%s: %v", arg, err)
    +	}
    +	if newPath == new && !modfile.IsDirectoryPath(new) {
    +		base.Fatalf("go: -replace=%s: unversioned new path must be local directory", arg)
    +	}
    +
    +	workedits = append(workedits, func(f *modfile.WorkFile) {
    +		if err := f.AddReplace(oldPath, oldVersion, newPath, newVersion); err != nil {
    +			base.Fatalf("go: -replace=%s: %v", arg, err)
    +		}
    +	})
    +}
    +
    +// flagEditworkDropReplace implements the -dropreplace flag.
    +func flagEditworkDropReplace(arg string) {
    +	path, version, err := parsePathVersionOptional("old", arg, true)
    +	if err != nil {
    +		base.Fatalf("go: -dropreplace=%s: %v", arg, err)
    +	}
    +	workedits = append(workedits, func(f *modfile.WorkFile) {
    +		if err := f.DropReplace(path, version); err != nil {
    +			base.Fatalf("go: -dropreplace=%s: %v", arg, err)
    +		}
    +	})
    +}
    +
    +type replaceJSON struct {
    +	Old module.Version
    +	New module.Version
    +}
    +
    +// editPrintJSON prints the -json output.
    +func editPrintJSON(workFile *modfile.WorkFile) {
    +	var f workfileJSON
    +	if workFile.Go != nil {
    +		f.Go = workFile.Go.Version
    +	}
    +	for _, d := range workFile.Use {
    +		f.Use = append(f.Use, useJSON{DiskPath: d.Path, ModPath: d.ModulePath})
    +	}
    +
    +	for _, r := range workFile.Replace {
    +		f.Replace = append(f.Replace, replaceJSON{r.Old, r.New})
    +	}
    +	data, err := json.MarshalIndent(&f, "", "\t")
    +	if err != nil {
    +		base.Fatalf("go: internal error: %v", err)
    +	}
    +	data = append(data, '\n')
    +	os.Stdout.Write(data)
    +}
    +
    +// workfileJSON is the -json output data structure.
    +type workfileJSON struct {
    +	Go      string `json:",omitempty"`
    +	Use     []useJSON
    +	Replace []replaceJSON
    +}
    +
    +type useJSON struct {
    +	DiskPath string
    +	ModPath  string `json:",omitempty"`
    +}
    diff --git a/go/src/cmd/go/internal/workcmd/init.go b/go/src/cmd/go/internal/workcmd/init.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..896740f08035021fd9f5047f5714b86fffe00c19
    --- /dev/null
    +++ b/go/src/cmd/go/internal/workcmd/init.go
    @@ -0,0 +1,67 @@
    +// Copyright 2021 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// go work init
    +
    +package workcmd
    +
    +import (
    +	"context"
    +	"path/filepath"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/fsys"
    +	"cmd/go/internal/gover"
    +	"cmd/go/internal/modload"
    +
    +	"golang.org/x/mod/modfile"
    +)
    +
    +var cmdInit = &base.Command{
    +	UsageLine: "go work init [moddirs]",
    +	Short:     "initialize workspace file",
    +	Long: `Init initializes and writes a new go.work file in the
    +current directory, in effect creating a new workspace at the current
    +directory.
    +
    +go work init optionally accepts paths to the workspace modules as
    +arguments. If the argument is omitted, an empty workspace with no
    +modules will be created.
    +
    +Each argument path is added to a use directive in the go.work file. The
    +current go version will also be listed in the go.work file.
    +
    +See the workspaces reference at https://go.dev/ref/mod#workspaces
    +for more information.
    +`,
    +	Run: runInit,
    +}
    +
    +func init() {
    +	base.AddChdirFlag(&cmdInit.Flag)
    +	base.AddModCommonFlags(&cmdInit.Flag)
    +}
    +
    +func runInit(ctx context.Context, cmd *base.Command, args []string) {
    +	moduleLoaderState := modload.NewState()
    +	moduleLoaderState.InitWorkfile()
    +
    +	moduleLoaderState.ForceUseModules = true
    +
    +	gowork := modload.WorkFilePath(moduleLoaderState)
    +	if gowork == "" {
    +		gowork = filepath.Join(base.Cwd(), "go.work")
    +	}
    +
    +	if _, err := fsys.Stat(gowork); err == nil {
    +		base.Fatalf("go: %s already exists", gowork)
    +	}
    +
    +	goV := gover.Local() // Use current Go version by default
    +	wf := new(modfile.WorkFile)
    +	wf.Syntax = new(modfile.FileSyntax)
    +	wf.AddGoStmt(goV)
    +	workUse(ctx, moduleLoaderState, gowork, wf, args)
    +	modload.WriteWorkFile(gowork, wf)
    +}
    diff --git a/go/src/cmd/go/internal/workcmd/sync.go b/go/src/cmd/go/internal/workcmd/sync.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..13ce1e5f4249ee2d658d8fc6001487230431f4dc
    --- /dev/null
    +++ b/go/src/cmd/go/internal/workcmd/sync.go
    @@ -0,0 +1,147 @@
    +// Copyright 2021 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// go work sync
    +
    +package workcmd
    +
    +import (
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/gover"
    +	"cmd/go/internal/imports"
    +	"cmd/go/internal/modload"
    +	"cmd/go/internal/toolchain"
    +	"context"
    +
    +	"golang.org/x/mod/module"
    +)
    +
    +var cmdSync = &base.Command{
    +	UsageLine: "go work sync",
    +	Short:     "sync workspace build list to modules",
    +	Long: `Sync syncs the workspace's build list back to the
    +workspace's modules
    +
    +The workspace's build list is the set of versions of all the
    +(transitive) dependency modules used to do builds in the workspace. go
    +work sync generates that build list using the Minimal Version Selection
    +algorithm, and then syncs those versions back to each of modules
    +specified in the workspace (with use directives).
    +
    +The syncing is done by sequentially upgrading each of the dependency
    +modules specified in a workspace module to the version in the build list
    +if the dependency module's version is not already the same as the build
    +list's version. Note that Minimal Version Selection guarantees that the
    +build list's version of each module is always the same or higher than
    +that in each workspace module.
    +
    +See the workspaces reference at https://go.dev/ref/mod#workspaces
    +for more information.
    +`,
    +	Run: runSync,
    +}
    +
    +func init() {
    +	base.AddChdirFlag(&cmdSync.Flag)
    +	base.AddModCommonFlags(&cmdSync.Flag)
    +}
    +
    +func runSync(ctx context.Context, cmd *base.Command, args []string) {
    +	moduleLoaderState := modload.NewState()
    +	moduleLoaderState.ForceUseModules = true
    +	moduleLoaderState.InitWorkfile()
    +	if modload.WorkFilePath(moduleLoaderState) == "" {
    +		base.Fatalf("go: no go.work file found\n\t(run 'go work init' first or specify path using GOWORK environment variable)")
    +	}
    +
    +	_, err := modload.LoadModGraph(moduleLoaderState, ctx, "")
    +	if err != nil {
    +		toolchain.SwitchOrFatal(moduleLoaderState, ctx, err)
    +	}
    +	mustSelectFor := map[module.Version][]module.Version{}
    +
    +	mms := moduleLoaderState.MainModules
    +
    +	opts := modload.PackageOpts{
    +		Tags:                     imports.AnyTags(),
    +		VendorModulesInGOROOTSrc: true,
    +		ResolveMissingImports:    false,
    +		LoadTests:                true,
    +		AllowErrors:              true,
    +		SilencePackageErrors:     true,
    +		SilenceUnmatchedWarnings: true,
    +	}
    +	for _, m := range mms.Versions() {
    +		opts.MainModule = m
    +		_, pkgs := modload.LoadPackages(moduleLoaderState, ctx, opts, "all")
    +		opts.MainModule = module.Version{} // reset
    +
    +		var (
    +			mustSelect   []module.Version
    +			inMustSelect = map[module.Version]bool{}
    +		)
    +		for _, pkg := range pkgs {
    +			if r := modload.PackageModule(pkg); r.Version != "" && !inMustSelect[r] {
    +				// r has a known version, so force that version.
    +				mustSelect = append(mustSelect, r)
    +				inMustSelect[r] = true
    +			}
    +		}
    +		gover.ModSort(mustSelect) // ensure determinism
    +		mustSelectFor[m] = mustSelect
    +	}
    +
    +	workFilePath := modload.WorkFilePath(moduleLoaderState) // save go.work path because EnterModule clobbers it.
    +
    +	var goV string
    +	for _, m := range mms.Versions() {
    +		if mms.ModRoot(m) == "" && m.Path == "command-line-arguments" {
    +			// This is not a real module.
    +			// TODO(#49228): Remove this special case once the special
    +			// command-line-arguments module is gone.
    +			continue
    +		}
    +
    +		// Use EnterModule to reset the global state in modload to be in
    +		// single-module mode using the modroot of m.
    +		modload.EnterModule(moduleLoaderState, ctx, mms.ModRoot(m))
    +
    +		// Edit the build list in the same way that 'go get' would if we
    +		// requested the relevant module versions explicitly.
    +		// TODO(#57001): Do we need a toolchain.SwitchOrFatal here,
    +		// and do we need to pass a toolchain.Switcher in LoadPackages?
    +		// If so, think about saving the WriteGoMods for after the loop,
    +		// so we don't write some go.mods with the "before" toolchain
    +		// and others with the "after" toolchain. If nothing else, that
    +		// discrepancy could show up in auto-recorded toolchain lines.
    +		changed, err := modload.EditBuildList(moduleLoaderState, ctx, nil, mustSelectFor[m])
    +		if err != nil {
    +			continue
    +		}
    +		if changed {
    +			modload.LoadPackages(moduleLoaderState, ctx, modload.PackageOpts{
    +				Tags:                     imports.AnyTags(),
    +				Tidy:                     true,
    +				VendorModulesInGOROOTSrc: true,
    +				ResolveMissingImports:    false,
    +				LoadTests:                true,
    +				AllowErrors:              true,
    +				SilenceMissingStdImports: true,
    +				SilencePackageErrors:     true,
    +			}, "all")
    +			modload.WriteGoMod(moduleLoaderState, ctx, modload.WriteOpts{})
    +		}
    +		goV = gover.Max(goV, moduleLoaderState.MainModules.GoVersion(moduleLoaderState))
    +	}
    +
    +	wf, err := modload.ReadWorkFile(workFilePath)
    +	if err != nil {
    +		base.Fatal(err)
    +	}
    +	modload.UpdateWorkGoVersion(wf, goV)
    +	modload.UpdateWorkFile(wf)
    +	if err := modload.WriteWorkFile(workFilePath, wf); err != nil {
    +		base.Fatal(err)
    +	}
    +}
    diff --git a/go/src/cmd/go/internal/workcmd/use.go b/go/src/cmd/go/internal/workcmd/use.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..041aa069e2d6bdeb65241ecef09435abd03820ff
    --- /dev/null
    +++ b/go/src/cmd/go/internal/workcmd/use.go
    @@ -0,0 +1,254 @@
    +// Copyright 2021 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// go work use
    +
    +package workcmd
    +
    +import (
    +	"context"
    +	"fmt"
    +	"io/fs"
    +	"os"
    +	"path/filepath"
    +
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/fsys"
    +	"cmd/go/internal/gover"
    +	"cmd/go/internal/modload"
    +	"cmd/go/internal/str"
    +	"cmd/go/internal/toolchain"
    +
    +	"golang.org/x/mod/modfile"
    +)
    +
    +var cmdUse = &base.Command{
    +	UsageLine: "go work use [-r] [moddirs]",
    +	Short:     "add modules to workspace file",
    +	Long: `Use provides a command-line interface for adding
    +directories, optionally recursively, to a go.work file.
    +
    +A use directive will be added to the go.work file for each argument
    +directory listed on the command line go.work file, if it exists,
    +or removed from the go.work file if it does not exist.
    +Use fails if any remaining use directives refer to modules that
    +do not exist.
    +
    +Use updates the go line in go.work to specify a version at least as
    +new as all the go lines in the used modules, both preexisting ones
    +and newly added ones. With no arguments, this update is the only
    +thing that go work use does.
    +
    +The -r flag searches recursively for modules in the argument
    +directories, and the use command operates as if each of the directories
    +were specified as arguments.
    +
    +
    +
    +See the workspaces reference at https://go.dev/ref/mod#workspaces
    +for more information.
    +`,
    +}
    +
    +var useR = cmdUse.Flag.Bool("r", false, "")
    +
    +func init() {
    +	cmdUse.Run = runUse // break init cycle
    +
    +	base.AddChdirFlag(&cmdUse.Flag)
    +	base.AddModCommonFlags(&cmdUse.Flag)
    +}
    +
    +func runUse(ctx context.Context, cmd *base.Command, args []string) {
    +	moduleLoaderState := modload.NewState()
    +	moduleLoaderState.ForceUseModules = true
    +	moduleLoaderState.InitWorkfile()
    +	gowork := modload.WorkFilePath(moduleLoaderState)
    +	if gowork == "" {
    +		base.Fatalf("go: no go.work file found\n\t(run 'go work init' first or specify path using GOWORK environment variable)")
    +	}
    +	wf, err := modload.ReadWorkFile(gowork)
    +	if err != nil {
    +		base.Fatal(err)
    +	}
    +	workUse(ctx, moduleLoaderState, gowork, wf, args)
    +	modload.WriteWorkFile(gowork, wf)
    +}
    +
    +func workUse(ctx context.Context, s *modload.State, gowork string, wf *modfile.WorkFile, args []string) {
    +	workDir := filepath.Dir(gowork) // absolute, since gowork itself is absolute
    +
    +	haveDirs := make(map[string][]string) // absolute → original(s)
    +	for _, use := range wf.Use {
    +		var abs string
    +		if filepath.IsAbs(use.Path) {
    +			abs = filepath.Clean(use.Path)
    +		} else {
    +			abs = filepath.Join(workDir, use.Path)
    +		}
    +		haveDirs[abs] = append(haveDirs[abs], use.Path)
    +	}
    +
    +	// keepDirs maps each absolute path to keep to the literal string to use for
    +	// that path (either an absolute or a relative path), or the empty string if
    +	// all entries for the absolute path should be removed.
    +	keepDirs := make(map[string]string)
    +
    +	sw := toolchain.NewSwitcher(s)
    +
    +	// lookDir updates the entry in keepDirs for the directory dir,
    +	// which is either absolute or relative to the current working directory
    +	// (not necessarily the directory containing the workfile).
    +	lookDir := func(dir string) {
    +		absDir, dir := pathRel(workDir, dir)
    +
    +		file := filepath.Join(absDir, "go.mod")
    +		fi, err := fsys.Stat(file)
    +		if err != nil {
    +			if os.IsNotExist(err) {
    +				keepDirs[absDir] = ""
    +			} else {
    +				sw.Error(err)
    +			}
    +			return
    +		}
    +
    +		if !fi.Mode().IsRegular() {
    +			sw.Error(fmt.Errorf("%v is not a regular file", base.ShortPath(file)))
    +			return
    +		}
    +
    +		if dup := keepDirs[absDir]; dup != "" && dup != dir {
    +			base.Errorf(`go: already added "%s" as "%s"`, dir, dup)
    +		}
    +		keepDirs[absDir] = dir
    +	}
    +
    +	for _, useDir := range args {
    +		absArg, _ := pathRel(workDir, useDir)
    +
    +		info, err := fsys.Stat(absArg)
    +		if err != nil {
    +			// Errors raised from os.Stat are formatted to be more user-friendly.
    +			if os.IsNotExist(err) {
    +				err = fmt.Errorf("directory %v does not exist", base.ShortPath(absArg))
    +			}
    +			sw.Error(err)
    +			continue
    +		} else if !info.IsDir() {
    +			sw.Error(fmt.Errorf("%s is not a directory", base.ShortPath(absArg)))
    +			continue
    +		}
    +
    +		if !*useR {
    +			lookDir(useDir)
    +			continue
    +		}
    +
    +		// Add or remove entries for any subdirectories that still exist.
    +		// If the root itself is a symlink to a directory,
    +		// we want to follow it (see https://go.dev/issue/50807).
    +		// Add a trailing separator to force that to happen.
    +		fsys.WalkDir(str.WithFilePathSeparator(useDir), func(path string, d fs.DirEntry, err error) error {
    +			if err != nil {
    +				return err
    +			}
    +
    +			if !d.IsDir() {
    +				if d.Type()&fs.ModeSymlink != 0 {
    +					if target, err := fsys.Stat(path); err == nil && target.IsDir() {
    +						fmt.Fprintf(os.Stderr, "warning: ignoring symlink %s\n", base.ShortPath(path))
    +					}
    +				}
    +				return nil
    +			}
    +			lookDir(path)
    +			return nil
    +		})
    +
    +		// Remove entries for subdirectories that no longer exist.
    +		// Because they don't exist, they will be skipped by Walk.
    +		for absDir := range haveDirs {
    +			if str.HasFilePathPrefix(absDir, absArg) {
    +				if _, ok := keepDirs[absDir]; !ok {
    +					keepDirs[absDir] = "" // Mark for deletion.
    +				}
    +			}
    +		}
    +	}
    +
    +	// Update the work file.
    +	for absDir, keepDir := range keepDirs {
    +		nKept := 0
    +		for _, dir := range haveDirs[absDir] {
    +			if dir == keepDir { // (note that dir is always non-empty)
    +				nKept++
    +			} else {
    +				wf.DropUse(dir)
    +			}
    +		}
    +		if keepDir != "" && nKept != 1 {
    +			// If we kept more than one copy, delete them all.
    +			// We'll recreate a unique copy with AddUse.
    +			if nKept > 1 {
    +				wf.DropUse(keepDir)
    +			}
    +			wf.AddUse(keepDir, "")
    +		}
    +	}
    +
    +	// Read the Go versions from all the use entries, old and new (but not dropped).
    +	goV := gover.FromGoWork(wf)
    +	for _, use := range wf.Use {
    +		if use.Path == "" { // deleted
    +			continue
    +		}
    +		var abs string
    +		if filepath.IsAbs(use.Path) {
    +			abs = filepath.Clean(use.Path)
    +		} else {
    +			abs = filepath.Join(workDir, use.Path)
    +		}
    +		_, mf, err := modload.ReadModFile(filepath.Join(abs, "go.mod"), nil)
    +		if err != nil {
    +			sw.Error(err)
    +			continue
    +		}
    +		goV = gover.Max(goV, gover.FromGoMod(mf))
    +	}
    +	sw.Switch(ctx)
    +	base.ExitIfErrors()
    +
    +	modload.UpdateWorkGoVersion(wf, goV)
    +	modload.UpdateWorkFile(wf)
    +}
    +
    +// pathRel returns the absolute and canonical forms of dir for use in a
    +// go.work file located in directory workDir.
    +//
    +// If dir is relative, it is interpreted relative to base.Cwd()
    +// and its canonical form is relative to workDir if possible.
    +// If dir is absolute or cannot be made relative to workDir,
    +// its canonical form is absolute.
    +//
    +// Canonical absolute paths are clean.
    +// Canonical relative paths are clean and slash-separated.
    +func pathRel(workDir, dir string) (abs, canonical string) {
    +	if filepath.IsAbs(dir) {
    +		abs = filepath.Clean(dir)
    +		return abs, abs
    +	}
    +
    +	abs = filepath.Join(base.Cwd(), dir)
    +	rel, err := filepath.Rel(workDir, abs)
    +	if err != nil {
    +		// The path can't be made relative to the go.work file,
    +		// so it must be kept absolute instead.
    +		return abs, abs
    +	}
    +
    +	// Normalize relative paths to use slashes, so that checked-in go.work
    +	// files with relative paths within the repo are platform-independent.
    +	return abs, modload.ToDirectoryPath(rel)
    +}
    diff --git a/go/src/cmd/go/internal/workcmd/vendor.go b/go/src/cmd/go/internal/workcmd/vendor.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..26715c8d3be3c6a7bb23917546432aa101a027c6
    --- /dev/null
    +++ b/go/src/cmd/go/internal/workcmd/vendor.go
    @@ -0,0 +1,56 @@
    +// Copyright 2022 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package workcmd
    +
    +import (
    +	"cmd/go/internal/base"
    +	"cmd/go/internal/cfg"
    +	"cmd/go/internal/modcmd"
    +	"cmd/go/internal/modload"
    +	"context"
    +)
    +
    +var cmdVendor = &base.Command{
    +	UsageLine: "go work vendor [-e] [-v] [-o outdir]",
    +	Short:     "make vendored copy of dependencies",
    +	Long: `
    +Vendor resets the workspace's vendor directory to include all packages
    +needed to build and test all the workspace's packages.
    +It does not include test code for vendored packages.
    +
    +The -v flag causes vendor to print the names of vendored
    +modules and packages to standard error.
    +
    +The -e flag causes vendor to attempt to proceed despite errors
    +encountered while loading packages.
    +
    +The -o flag causes vendor to create the vendor directory at the given
    +path instead of "vendor". The go command can only use a vendor directory
    +named "vendor" within the module root directory, so this flag is
    +primarily useful for other tools.`,
    +
    +	Run: runVendor,
    +}
    +
    +var vendorE bool   // if true, report errors but proceed anyway
    +var vendorO string // if set, overrides the default output directory
    +
    +func init() {
    +	cmdVendor.Flag.BoolVar(&cfg.BuildV, "v", false, "")
    +	cmdVendor.Flag.BoolVar(&vendorE, "e", false, "")
    +	cmdVendor.Flag.StringVar(&vendorO, "o", "", "")
    +	base.AddChdirFlag(&cmdVendor.Flag)
    +	base.AddModCommonFlags(&cmdVendor.Flag)
    +}
    +
    +func runVendor(ctx context.Context, cmd *base.Command, args []string) {
    +	moduleLoaderState := modload.NewState()
    +	moduleLoaderState.InitWorkfile()
    +	if modload.WorkFilePath(moduleLoaderState) == "" {
    +		base.Fatalf("go: no go.work file found\n\t(run 'go work init' first or specify path using GOWORK environment variable)")
    +	}
    +
    +	modcmd.RunVendor(moduleLoaderState, ctx, vendorE, vendorO, args)
    +}
    diff --git a/go/src/cmd/go/internal/workcmd/work.go b/go/src/cmd/go/internal/workcmd/work.go
    new file mode 100644
    index 0000000000000000000000000000000000000000..bfbed83e889cb1ee0906a0b9de13756b145a035b
    --- /dev/null
    +++ b/go/src/cmd/go/internal/workcmd/work.go
    @@ -0,0 +1,79 @@
    +// Copyright 2021 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Package workcmd implements the “go work” command.
    +package workcmd
    +
    +import (
    +	"cmd/go/internal/base"
    +)
    +
    +var CmdWork = &base.Command{
    +	UsageLine: "go work",
    +	Short:     "workspace maintenance",
    +	Long: `Work provides access to operations on workspaces.
    +
    +Note that support for workspaces is built into many other commands, not
    +just 'go work'.
    +
    +See 'go help modules' for information about Go's module system of which
    +workspaces are a part.
    +
    +See https://go.dev/ref/mod#workspaces for an in-depth reference on
    +workspaces.
    +
    +See https://go.dev/doc/tutorial/workspaces for an introductory
    +tutorial on workspaces.
    +
    +A workspace is specified by a go.work file that specifies a set of
    +module directories with the "use" directive. These modules are used as
    +root modules by the go command for builds and related operations.  A
    +workspace that does not specify modules to be used cannot be used to do
    +builds from local modules.
    +
    +go.work files are line-oriented. Each line holds a single directive,
    +made up of a keyword followed by arguments. For example:
    +
    +	go 1.18
    +
    +	use ../foo/bar
    +	use ./baz
    +
    +	replace example.com/foo v1.2.3 => example.com/bar v1.4.5
    +
    +The leading keyword can be factored out of adjacent lines to create a block,
    +like in Go imports.
    +
    +	use (
    +	  ../foo/bar
    +	  ./baz
    +	)
    +
    +The use directive specifies a module to be included in the workspace's
    +set of main modules. The argument to the use directive is the directory
    +containing the module's go.mod file.
    +
    +The go directive specifies the version of Go the file was written at. It
    +is possible there may be future changes in the semantics of workspaces
    +that could be controlled by this version, but for now the version
    +specified has no effect.
    +
    +The replace directive has the same syntax as the replace directive in a
    +go.mod file and takes precedence over replaces in go.mod files.  It is
    +primarily intended to override conflicting replaces in different workspace
    +modules.
    +
    +To determine whether the go command is operating in workspace mode, use
    +the "go env GOWORK" command. This will specify the workspace file being
    +used.
    +`,
    +
    +	Commands: []*base.Command{
    +		cmdEdit,
    +		cmdInit,
    +		cmdSync,
    +		cmdUse,
    +		cmdVendor,
    +	},
    +}
    diff --git a/go/src/cmd/go/testdata/script/script_wait.txt b/go/src/cmd/go/testdata/script/script_wait.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f253060e6014a2380364466b43266ce107ff8f6a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/script_wait.txt
    @@ -0,0 +1,28 @@
    +env GO111MODULE=off
    +
    +[!exec:echo] skip
    +[!exec:false] skip
    +
    +exec echo foo
    +stdout foo
    +
    +exec echo foo &
    +exec echo bar &
    +! exec false &
    +
    +# Starting a background process should clear previous output.
    +! stdout foo
    +
    +# Wait should set the output to the concatenated outputs of the background
    +# programs, in the order in which they were started.
    +wait
    +stdout 'foo\nbar'
    +
    +# The end of the test should interrupt or kill any remaining background
    +# programs, but that should not cause the test to fail if it does not
    +# care about the exit status of those programs.
    +[exec:sleep] ? exec sleep 86400 &
    +
    +# It should also cancel any backgrounded builtins that respond to Context
    +# cancellation.
    +? sleep 86400s &
    diff --git a/go/src/cmd/go/testdata/script/slashpath.txt b/go/src/cmd/go/testdata/script/slashpath.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..22b3e9dc07c1d6c10635fe5a06f12765c30b209e
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/slashpath.txt
    @@ -0,0 +1,18 @@
    +# .a files should use slash-separated paths even on windows
    +# This is important for reproducing native builds with cross-compiled builds.
    +go build -o x.a text/template
    +! grep 'GOROOT\\' x.a
    +! grep 'text\\template' x.a
    +! grep 'c:\\' x.a
    +
    +# executables should use slash-separated paths even on windows
    +# This is important for reproducing native builds with cross-compiled builds.
    +go build -o hello.exe hello.go
    +! grep 'GOROOT\\' hello.exe
    +! grep '\\runtime' hello.exe
    +! grep 'runtime\\' hello.exe
    +! grep 'gofile..[A-Za-z]:\\' hello.exe
    +
    +-- hello.go --
    +package main
    +func main() { println("hello") }
    diff --git a/go/src/cmd/go/testdata/script/src_file.txt b/go/src/cmd/go/testdata/script/src_file.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8d5c20bc97cab6a59c04455d5b37a77b3505bae7
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/src_file.txt
    @@ -0,0 +1,9 @@
    +# Files in src should not be treated as packages
    +
    +exists $GOROOT/src/regexp/testdata/README
    +go list -f '{{.Dir}}' regexp/testdata/README
    +
    +-- go.mod --
    +module regexp/testdata/README
    +-- p.go --
    +package p
    diff --git a/go/src/cmd/go/testdata/script/std_vendor.txt b/go/src/cmd/go/testdata/script/std_vendor.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..731ee9e670de80007f9189f536808838a3ee01e9
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/std_vendor.txt
    @@ -0,0 +1,43 @@
    +env GO111MODULE=off
    +
    +[!compiler:gc] skip
    +
    +# 'go list' should report imports from _test.go in the TestImports field.
    +go list -f '{{.TestImports}}'
    +stdout net/http # from .TestImports
    +
    +# 'go list' should report standard-vendored packages by path.
    +go list -f '{{.Dir}}' vendor/golang.org/x/net/http2/hpack
    +stdout $GOROOT[/\\]src[/\\]vendor
    +
    +# 'go list -test' should report vendored transitive dependencies of _test.go
    +# imports in the Deps field, with a 'vendor' prefix on their import paths.
    +go list -test -f '{{.Deps}}'
    +stdout golang.org/x/crypto # dep of .TestImports
    +
    +# Packages outside the standard library should not use its copy of vendored packages.
    +cd broken
    +! go build
    +stderr 'cannot find package'
    +
    +-- go.mod --
    +module m
    +
    +-- x.go --
    +package x
    +
    +-- x_test.go --
    +package x
    +import "testing"
    +import _ "net/http"
    +func Test(t *testing.T) {}
    +
    +-- broken/go.mod --
    +module broken
    +-- broken/http.go --
    +package broken
    +
    +import (
    +	_ "net/http"
    +	_ "golang.org/x/net/http/httpproxy"
    +)
    diff --git a/go/src/cmd/go/testdata/script/telemetry.txt b/go/src/cmd/go/testdata/script/telemetry.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..52bf8dee64e565dd5172983ce4ca460fdd1b1275
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/telemetry.txt
    @@ -0,0 +1,70 @@
    +# Tests for the telemetry subcommand,
    +
    +# The script test framework sets TEST_TELEMETRY_DIR (overriding the
    +# default telemetry dir location) and then checks that at least one
    +# counter has been written per script tests.
    +# Run go before unsetting TEST_TELEMETRY_DIR to make the tests happy.
    +# We want to unset it so the environment we're testing is as close
    +# to a user's environment.
    +go help telemetry
    +env TEST_TELEMETRY_DIR=
    +
    +# Set userconfig dir, which is determined by os.UserConfigDir.
    +# The telemetry dir is determined using that.
    +mkdir $WORK/userconfig
    +env AppData=$WORK\userconfig # windows
    +[GOOS:windows] env userconfig=$AppData
    +env HOME=$WORK/userconfig # darwin,unix,ios
    +[GOOS:darwin] env userconfig=$HOME'/Library/Application Support'
    +[GOOS:ios] env userconfig=$HOME'/Library/Application Support'
    +[!GOOS:windows] [!GOOS:darwin] [!GOOS:ios] [!GOOS:plan9] env userconfig=$HOME/.config
    +env home=$WORK/userconfig # plan9
    +[GOOS:plan9] env userconfig=$home/lib
    +
    +go telemetry
    +stdout 'local'
    +
    +go telemetry off
    +go telemetry
    +stdout 'off'
    +go env GOTELEMETRY
    +stdout 'off'
    +
    +go telemetry local
    +go telemetry
    +stdout 'local'
    +go env GOTELEMETRY
    +stdout 'local'
    +
    +go telemetry on
    +go telemetry
    +stdout 'on'
    +go env GOTELEMETRY
    +stdout 'on'
    +
    +go env
    +stdout 'GOTELEMETRY=''?on''?'
    +stdout 'GOTELEMETRYDIR=''?'$userconfig'[\\/]go[\\/]telemetry''?'
    +! go env -w GOTELEMETRY=off
    +stderr '^go: GOTELEMETRY cannot be modified$'
    +! go env -w GOTELEMETRYDIR=foo
    +stderr '^go: GOTELEMETRYDIR cannot be modified$'
    +
    +# Test issue #69269: 'go telemetry off' should not increment counters.
    +# Establish that previous commands did write telemetry files.
    +# Only check for the existence of telemetry data on supported platforms.
    +[!GOOS:openbsd] [!GOOS:solaris] [!GOOS:android] [!GOOS:illumos] [!GOOS:js] [!GOOS:wasip1] [!GOOS:plan9] [!GOARCH:mips] [!GOARCH:mipsle] exists $userconfig/go/telemetry/local
    +# Now check for go telemetry off behavior.
    +rm $userconfig/go/telemetry/local
    +go telemetry off
    +! exists $userconfig/go/telemetry/local
    +# Check for the behavior with -C, the only flag 'go telemetry off' can take.
    +go telemetry local
    +go -C $WORK telemetry off
    +! exists $userconfig/go/telemetry/local
    +go telemetry local
    +go telemetry -C=$WORK off
    +! exists $userconfig/go/telemetry/local
    +go telemetry local
    +go help telemetry
    +[!GOOS:openbsd] [!GOOS:solaris] [!GOOS:android] [!GOOS:illumos] [!GOOS:js] [!GOOS:wasip1] [!GOOS:plan9] [!GOARCH:mips] [!GOARCH:mipsle] exists $userconfig/go/telemetry/local
    diff --git a/go/src/cmd/go/testdata/script/test2json_interrupt.txt b/go/src/cmd/go/testdata/script/test2json_interrupt.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..763c3369914226e32632c684eb8f229aa1f09892
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test2json_interrupt.txt
    @@ -0,0 +1,58 @@
    +[short] skip 'links and runs a test binary'
    +[!fuzz] skip 'tests SIGINT behavior for interrupting fuzz tests'
    +[GOOS:windows] skip 'windows does not support os.Interrupt'
    +
    +? go test -json -fuzz FuzzInterrupt -run '^$' -parallel 1
    +stdout -count=1 '"Action":"pass","Package":"example","Test":"FuzzInterrupt"'
    +stdout -count=1 '"Action":"pass","Package":"example","Elapsed":'
    +
    +mkdir $WORK/fuzzcache
    +go test -c . -fuzz=. -o example_test.exe
    +? go tool test2json -p example -t ./example_test.exe -test.v -test.paniconexit0 -test.fuzzcachedir $WORK/fuzzcache -test.fuzz FuzzInterrupt -test.run '^$' -test.parallel 1
    +stdout -count=1 '"Action":"pass","Package":"example","Test":"FuzzInterrupt"'
    +stdout -count=1 '"Action":"pass","Package":"example","Elapsed":'
    +
    +-- go.mod --
    +module example
    +go 1.20
    +-- example_test.go --
    +package example_test
    +
    +import (
    +	"fmt"
    +	"os"
    +	"strconv"
    +	"testing"
    +	"strings"
    +	"time"
    +)
    +
    +func FuzzInterrupt(f *testing.F) {
    +	pids := os.Getenv("GO_TEST_INTERRUPT_PIDS")
    +	if pids == "" {
    +		// This is the main test process.
    +		// Set the environment variable for fuzz workers.
    +		pid := os.Getpid()
    +		ppid := os.Getppid()
    +		os.Setenv("GO_TEST_INTERRUPT_PIDS", fmt.Sprintf("%d,%d", ppid, pid))
    +	}
    +
    +	sentInterrupt := false
    +	f.Fuzz(func(t *testing.T, orig string) {
    +		if !sentInterrupt {
    +			// Simulate a ctrl-C on the keyboard by sending SIGINT
    +			// to the main test process and its parent.
    +			for _, pid := range strings.Split(pids, ",") {
    +				i, err := strconv.Atoi(pid)
    +				if err != nil {
    +					t.Fatal(err)
    +				}
    +				if p, err := os.FindProcess(i); err == nil {
    +					p.Signal(os.Interrupt)
    +					sentInterrupt = true // Only send interrupts once.
    +				}
    +			}
    +		}
    +		time.Sleep(1 * time.Millisecond)  // Delay the fuzzer a bit to avoid wasting CPU.
    +	})
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_android_issue62123.txt b/go/src/cmd/go/testdata/script/test_android_issue62123.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..2f46a6b44bffe18097aee0a2e606eb274fa13048
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_android_issue62123.txt
    @@ -0,0 +1,19 @@
    +env GOOS=android GOARCH=amd64 CGO_ENABLED=0
    +
    +! go build -o $devnull cmd/buildid
    +stderr 'android/amd64 requires external \(cgo\) linking, but cgo is not enabled'
    +! stderr 'cannot find runtime/cgo'
    +
    +! go test -c -o $devnull os
    +stderr '# os\nandroid/amd64 requires external \(cgo\) linking, but cgo is not enabled'
    +! stderr 'cannot find runtime/cgo'
    +
    +env GOOS=ios GOARCH=arm64 CGO_ENABLED=0
    +
    +! go build -o $devnull cmd/buildid
    +stderr 'ios/arm64 requires external \(cgo\) linking, but cgo is not enabled'
    +! stderr 'cannot find runtime/cgo'
    +
    +! go test -c -o $devnull os
    +stderr '# os\nios/arm64 requires external \(cgo\) linking, but cgo is not enabled'
    +! stderr 'cannot find runtime/cgo'
    diff --git a/go/src/cmd/go/testdata/script/test_bad_example.txt b/go/src/cmd/go/testdata/script/test_bad_example.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..46bc264779e3f869684f84a187de651d39221716
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_bad_example.txt
    @@ -0,0 +1,14 @@
    +# Tests that invalid examples are ignored.
    +# Verifies golang.org/issue/35284
    +# Disable vet, as 'tests' analyzer objects to surplus parameter.
    +go test -vet=off x_test.go
    +
    +-- x_test.go --
    +package  x
    +
    +import "fmt"
    +
    +func ExampleThisShouldNotHaveAParameter(thisShouldntExist int) {
    +	fmt.Println("X")
    +	// Output:
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_badtest.txt b/go/src/cmd/go/testdata/script/test_badtest.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e79fc511b3975e9788b35e099372f26bfb1f57df
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_badtest.txt
    @@ -0,0 +1,49 @@
    +env GO111MODULE=off
    +
    +! go test badtest/badexec
    +! stdout ^ok
    +stdout ^FAIL\tbadtest/badexec
    +
    +! go test badtest/badsyntax
    +! stdout ^ok
    +stdout ^FAIL\tbadtest/badsyntax
    +
    +! go test badtest/badvar
    +! stdout ^ok
    +stdout ^FAIL\tbadtest/badvar
    +
    +! go test notest
    +! stdout ^ok
    +stderr '^notest.hello.go:6:1: syntax error: non-declaration statement outside function body' # Exercise issue #7108
    +
    +-- badtest/badexec/x_test.go --
    +package badexec
    +
    +func init() {
    +	panic("badexec")
    +}
    +
    +-- badtest/badsyntax/x.go --
    +package badsyntax
    +
    +-- badtest/badsyntax/x_test.go --
    +package badsyntax
    +
    +func func func func func!
    +
    +-- badtest/badvar/x.go --
    +package badvar
    +
    +-- badtest/badvar/x_test.go --
    +package badvar_test
    +
    +func f() {
    +	_ = notdefined
    +}
    +-- notest/hello.go --
    +package notest
    +
    +func hello() {
    +	println("hello world")
    +}
    +Hello world
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_benchmark_1x.txt b/go/src/cmd/go/testdata/script/test_benchmark_1x.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b1d4c39c16f0505c6b3e29d4236eb301bbe90e49
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_benchmark_1x.txt
    @@ -0,0 +1,37 @@
    +# Test that -benchtime 1x only runs a total of 1 loop iteration.
    +# See golang.org/issue/32051.
    +
    +go test -run ^$ -bench . -benchtime 1x
    +
    +-- go.mod --
    +module bench
    +
    +go 1.16
    +-- x_test.go --
    +package bench
    +
    +import (
    +	"fmt"
    +	"os"
    +	"testing"
    +)
    +
    +var called = false
    +
    +func TestMain(m *testing.M) {
    +	m.Run()
    +	if !called {
    +		fmt.Println("benchmark never called")
    +		os.Exit(1)
    +	}
    +}
    +
    +func Benchmark(b *testing.B) {
    +	if b.N > 1 {
    +		b.Fatalf("called with b.N=%d; want b.N=1 only", b.N)
    +	}
    +	if called {
    +		b.Fatal("called twice")
    +	}
    +	called = true
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_benchmark_chatty_fail.txt b/go/src/cmd/go/testdata/script/test_benchmark_chatty_fail.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6031eadd0af5bc9e103418df7c6bb303315056f0
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_benchmark_chatty_fail.txt
    @@ -0,0 +1,32 @@
    +# Run chatty tests. Assert on CONT lines.
    +! go test chatty_test.go -v -bench . chatty_bench
    +
    +# Sanity check that output occurs.
    +stdout -count=2 'this is sub-0'
    +stdout -count=2 'this is sub-1'
    +stdout -count=2 'this is sub-2'
    +stdout -count=1 'error from sub-0'
    +stdout -count=1 'error from sub-1'
    +stdout -count=1 'error from sub-2'
    +
    +# Benchmarks should not print CONT.
    +! stdout CONT
    +
    +-- chatty_test.go --
    +package chatty_bench
    +
    +import (
    +	"testing"
    +	"fmt"
    +)
    +
    +func BenchmarkChatty(b *testing.B) {
    +    for i := 0; i < 3; i++ {
    +        b.Run(fmt.Sprintf("sub-%d", i), func(b *testing.B) {
    +            for j := 0; j < 2; j++ {
    +                b.Logf("this is sub-%d", i)
    +            }
    +            b.Errorf("error from sub-%d", i)
    +        })
    +    }
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_benchmark_chatty_success.txt b/go/src/cmd/go/testdata/script/test_benchmark_chatty_success.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a1c0d6545a951c601ffe78935ea78f9769ab3452
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_benchmark_chatty_success.txt
    @@ -0,0 +1,29 @@
    +# Run chatty tests. Assert on CONT lines.
    +go test chatty_test.go -v -bench . chatty_bench
    +
    +# Sanity check that output happens. We don't provide -count because the amount
    +# of output is variable.
    +stdout 'this is sub-0'
    +stdout 'this is sub-1'
    +stdout 'this is sub-2'
    +
    +# Benchmarks should not print CONT.
    +! stdout CONT
    +
    +-- chatty_test.go --
    +package chatty_bench
    +
    +import (
    +	"testing"
    +	"fmt"
    +)
    +
    +func BenchmarkChatty(b *testing.B) {
    +    for i := 0; i < 3; i++ {
    +        b.Run(fmt.Sprintf("sub-%d", i), func(b *testing.B) {
    +            for j := 0; j < 2; j++ {
    +                b.Logf("this is sub-%d", i)
    +            }
    +        })
    +    }
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_benchmark_fatal.txt b/go/src/cmd/go/testdata/script/test_benchmark_fatal.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e281379ebd94cc86f34b5e0151cc4ef9b8156f7a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_benchmark_fatal.txt
    @@ -0,0 +1,19 @@
    +# Test that calling t.Fatal in a benchmark causes a non-zero exit status.
    +
    +! go test -run '^$' -bench . benchfatal
    +! stdout ^ok
    +! stderr ^ok
    +stdout FAIL.*benchfatal
    +
    +-- go.mod --
    +module benchfatal
    +
    +go 1.16
    +-- x_test.go --
    +package benchfatal
    +
    +import "testing"
    +
    +func BenchmarkThatCallsFatal(b *testing.B) {
    +	b.Fatal("called by benchmark")
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_benchmark_labels.txt b/go/src/cmd/go/testdata/script/test_benchmark_labels.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6b424c1bd89392c363d1468eda2aa0590baae79d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_benchmark_labels.txt
    @@ -0,0 +1,23 @@
    +# Tests that go test -bench prints out goos, goarch, and pkg.
    +
    +# Check for goos, goarch, and pkg.
    +go test -run ^$ -bench . bench
    +stdout '^goos: '$GOOS
    +stdout '^goarch: '$GOARCH
    +stdout '^pkg: bench'
    +
    +# Check go test does not print pkg multiple times
    +! stdout 'pkg:.*pkg: '
    +! stderr 'pkg:.*pkg:'
    +
    +-- go.mod --
    +module bench
    +
    +go 1.16
    +-- x_test.go --
    +package bench
    +
    +import "testing"
    +
    +func Benchmark(b *testing.B) {
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_benchmark_timeout.txt b/go/src/cmd/go/testdata/script/test_benchmark_timeout.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..4bae7e7e7d0153337e106c7cd7a38372550943d0
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_benchmark_timeout.txt
    @@ -0,0 +1,18 @@
    +# Tests issue #18845
    +[short] skip
    +
    +go test -bench . -timeout=750ms timeoutbench_test.go
    +stdout ok
    +stdout PASS
    +
    +-- timeoutbench_test.go --
    +package timeoutbench_test
    +
    +import (
    +	"testing"
    +	"time"
    +)
    +
    +func BenchmarkSleep1s(b *testing.B) {
    +	time.Sleep(1 * time.Second)
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_build_failure.txt b/go/src/cmd/go/testdata/script/test_build_failure.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e8c984f272c33bbf95b8c1c2eb1f8427a76a2d6c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_build_failure.txt
    @@ -0,0 +1,31 @@
    +[short] skip
    +
    +! go test -x coverbad
    +! stderr '[\\/]coverbad\.test( |$)' # 'go test' should not claim to have run the test.
    +stderr 'undefined: g'
    +[cgo] stderr 'undefined: j'
    +
    +-- go.mod --
    +module coverbad
    +
    +go 1.16
    +-- p.go --
    +package p
    +
    +func f() {
    +	g()
    +}
    +-- p1.go --
    +package p
    +
    +import "C"
    +
    +func h() {
    +	j()
    +}
    +-- p_test.go --
    +package p
    +
    +import "testing"
    +
    +func Test(t *testing.T) {}
    diff --git a/go/src/cmd/go/testdata/script/test_buildinfo.txt b/go/src/cmd/go/testdata/script/test_buildinfo.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..fbf097c0a6e6f91e9a94845d09b7df2bf8280d10
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_buildinfo.txt
    @@ -0,0 +1,24 @@
    +# Ensure buildinfo is populated on test binaries even if they
    +# are not tests for package main. See issue #33976.
    +
    +[short] skip 'invokes go test'
    +
    +go mod init foo
    +go test -v
    +stdout '(devel)'
    +
    +-- foo_test.go --
    +package foo_test
    +
    +import (
    +        "runtime/debug"
    +        "testing"
    +)
    +
    +func TestBuildInfo(t *testing.T) {
    +        info, ok := debug.ReadBuildInfo()
    +        if !ok {
    +                t.Fatal("no debug info")
    +        }
    +        t.Log(info.Main.Version)
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_buildinfo_godebug_issue68053.txt b/go/src/cmd/go/testdata/script/test_buildinfo_godebug_issue68053.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e8b8ca215839ea6a2cea0bcc9f266e1b96880ceb
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_buildinfo_godebug_issue68053.txt
    @@ -0,0 +1,30 @@
    +[short] skip 'builds test binary'
    +
    +go list -test -f '{{.ImportPath}} {{.DefaultGODEBUG}}'
    +stdout 'example.com/foo\.test.*panicnil=1.*'
    +
    +go test -c
    +go version -m ./foo.test$GOEXE
    +stdout 'build\tDefaultGODEBUG=.*panicnil=1.*'
    +
    +-- go.mod --
    +module example.com/foo
    +
    +go 1.23
    +-- main_test.go --
    +//go:debug panicnil=1
    +package main_test
    +
    +import (
    +	"runtime/debug"
    +	"testing"
    +)
    +
    +func TestFoo(t *testing.T) {
    +	defer func() {
    +		t.Fatal(recover())
    +	}()
    +
    +	t.Log(debug.ReadBuildInfo())
    +	panic(nil)
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_buildvcs.txt b/go/src/cmd/go/testdata/script/test_buildvcs.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..db844f88b35341114653a36032e2a2efe7efafd2
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_buildvcs.txt
    @@ -0,0 +1,104 @@
    +# https://go.dev/issue/51723: 'go test' should not stamp VCS metadata
    +# in the build settings. (It isn't worth the latency hit, given that
    +# test binaries are almost never distributed to users.)
    +
    +[short] skip
    +[!git] skip
    +
    +exec git init
    +
    +# The test binaries should not have VCS settings stamped by default.
    +# (The test itself verifies that.)
    +go test . ./testonly
    +
    +# However, setting -buildvcs explicitly should override that and
    +# stamp anyway (https://go.dev/issue/52648).
    +go test -buildvcs -c -o ./testonly.exe ./testonly
    +! exec ./testonly.exe
    +stdout 'unexpected VCS setting: vcs\.modified=true'
    +
    +
    +# Remove 'git' from $PATH. The test should still build.
    +# This ensures that we aren't loading VCS metadata that
    +# we subsequently throw away.
    +env PATH=''
    +env path=''
    +
    +# Compiling the test should not require the VCS tool.
    +go test -c -o $devnull .
    +
    +
    +# When listing a main package, in general we need its VCS metadata to determine
    +# the .Stale and .StaleReason fields.
    +! go list -buildvcs=true .
    +stderr '^go: missing Git command\. See https://golang\.org/s/gogetcmd\nerror obtaining VCS status: .*\n\tUse -buildvcs=false to disable VCS stamping.'
    +
    +# Adding the -test flag should be strictly additive — it should not suppress the error.
    +! go list -buildvcs=true -test .
    +stderr '^go: missing Git command\. See https://golang\.org/s/gogetcmd\nerror obtaining VCS status: .*\n\tUse -buildvcs=false to disable VCS stamping.'
    +
    +# Adding the suggested flag should suppress the error.
    +go list -test -buildvcs=false .
    +! stderr .
    +
    +
    +# Since the ./testonly package doesn't itself produce an actual binary, we shouldn't
    +# invoke a VCS tool to compute a build stamp by default when listing it.
    +go list ./testonly
    +! stderr .
    +go list -test ./testonly
    +! stderr .
    +
    +# Again, setting -buildvcs explicitly should force the use of the VCS tool.
    +! go list -buildvcs ./testonly
    +stderr '^go: missing Git command\. See https://golang\.org/s/gogetcmd\nerror obtaining VCS status: .*\n\tUse -buildvcs=false to disable VCS stamping.'
    +! go list -buildvcs -test ./testonly
    +stderr '^go: missing Git command\. See https://golang\.org/s/gogetcmd\nerror obtaining VCS status: .*\n\tUse -buildvcs=false to disable VCS stamping.'
    +
    +
    +-- go.mod --
    +module example
    +
    +go 1.18
    +-- example.go --
    +package main
    +-- example_test.go --
    +package main
    +
    +import (
    +	"runtime/debug"
    +	"strings"
    +	"testing"
    +)
    +
    +func TestDetail(t *testing.T) {
    +	bi, ok := debug.ReadBuildInfo()
    +	if !ok {
    +		t.Fatal("BuildInfo not present")
    +	}
    +	for _, s := range bi.Settings {
    +		if strings.HasPrefix(s.Key, "vcs.") {
    +			t.Fatalf("unexpected VCS setting: %s=%s", s.Key, s.Value)
    +		}
    +	}
    +}
    +-- testonly/main_test.go --
    +package main
    +
    +import (
    +	"runtime/debug"
    +	"strings"
    +	"testing"
    +)
    +
    +func TestDetail(t *testing.T) {
    +	bi, ok := debug.ReadBuildInfo()
    +	if !ok {
    +		t.Fatal("BuildInfo not present")
    +	}
    +	for _, s := range bi.Settings {
    +		if strings.HasPrefix(s.Key, "vcs.") {
    +			t.Fatalf("unexpected VCS setting: %s=%s", s.Key, s.Value)
    +		}
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_cache_coverpkg_bug.txt b/go/src/cmd/go/testdata/script/test_cache_coverpkg_bug.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..71cd3b392050f889da41603a37ae0f37654a09e9
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_cache_coverpkg_bug.txt
    @@ -0,0 +1,134 @@
    +# Test for bug where cached coverage profiles with -coverpkg can contain
    +# outdated line references when source files are modified.
    +# This reproduces the issue where coverage data from cache may reference
    +# lines that no longer exist in the updated source files.
    +
    +[short] skip
    +[GODEBUG:gocacheverify=1] skip
    +
    +# We're testing cache behavior, so start with a clean GOCACHE.
    +env GOCACHE=$WORK/cache
    +
    +# Create a project structure with multiple packages
    +# proj/
    +#   some_func.go
    +#   some_func_test.go
    +#   sub/
    +#     sub.go
    +#     sub_test.go
    +#   sum/
    +#     sum.go
    +
    +# Switch to the proj directory
    +cd proj
    +
    +# Run tests with -coverpkg to collect coverage for all packages
    +go test -coverpkg=proj/... -coverprofile=cover1.out ./...
    +stdout 'coverage:'
    +
    +# Verify the first coverage profile exists and has expected content
    +exists cover1.out
    +grep -q 'proj/sub/sub.go:' cover1.out
    +
    +# Run again to ensure caching works
    +go test -coverpkg=proj/... -coverprofile=cover1_cached.out ./...
    +stdout '\(cached\)'
    +stdout 'coverage:'
    +
    +# Note: Due to the bug, cached coverage profiles may have duplicate entries.
    +# The duplicate entries are the entries for the previous file structure and the new file structure.
    +
    +# Now modify sub.go to change line structure - this will invalidate
    +# the cache for the sub package but not for the proj package.
    +cp ../sub_modified.go sub/sub.go
    +
    +# After modifying sub.go, we should not have both old and new line references.
    +go test -coverpkg=proj/... -coverprofile=cover2.out ./...
    +stdout 'coverage:'
    +
    +# With the bug present, we would see duplicate entries for the same lines.
    +# With the bug fixed, there should be no duplicate or stale entries in the coverage profile.
    +grep 'proj/sub/sub.go:' cover2.out
    +# The fix should ensure that only the new line format exists, not the old one
    +grep 'proj/sub/sub.go:3.24,4.35' cover2.out
    +# This should fail if the stale coverage line exists (the bug is present)
    +! grep 'proj/sub/sub.go:3.24,4.22' cover2.out
    +
    +-- proj/go.mod --
    +module proj
    +
    +go 1.21
    +
    +-- proj/some_func.go --
    +package proj
    +
    +import "proj/sum"
    +
    +func SomeFunc(a, b int) int {
    +	if a == 0 && b == 0 {
    +		return 0
    +	}
    +	return sum.Sum(a, b)
    +}
    +
    +-- proj/some_func_test.go --
    +package proj
    +
    +import (
    +	"testing"
    +)
    +
    +func Test_SomeFunc(t *testing.T) {
    +	t.Run("test1", func(t *testing.T) {
    +		result := SomeFunc(1, 1)
    +		if result != 2 {
    +			t.Errorf("Expected 2, got %d", result)
    +		}
    +	})
    +}
    +
    +-- proj/sub/sub.go --
    +package sub
    +
    +func Sub(a, b int) int {
    +	if a == 0 && b == 0 {
    +		return 0
    +	}
    +	return a - b
    +}
    +
    +-- proj/sub/sub_test.go --
    +package sub
    +
    +import (
    +	"testing"
    +)
    +
    +func Test_Sub(t *testing.T) {
    +	t.Run("test_sub1", func(t *testing.T) {
    +		result := Sub(1, 1)
    +		if result != 0 {
    +			t.Errorf("Expected 0, got %d", result)
    +		}
    +	})
    +}
    +
    +-- proj/sum/sum.go --
    +package sum
    +
    +func Sum(a, b int) int {
    +	if a == 0 {
    +		return b
    +	}
    +	return a + b
    +}
    +
    +-- sub_modified.go --
    +package sub
    +
    +func Sub(a, b int) int {
    +	if a == 0 && b == 0 || a == -100 {
    +		return 0
    +	}
    +	return a - b
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_cache_coverpkg_no_profile.txt b/go/src/cmd/go/testdata/script/test_cache_coverpkg_no_profile.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..263400a9e675ff70d04f8bd0bfe6628488aa3440
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_cache_coverpkg_no_profile.txt
    @@ -0,0 +1,80 @@
    +# Test that the test cache is invalidated when -coverpkg dependencies change,
    +# even when -coverprofile is not specified. This exercises the else-if branch
    +# in tryCacheWithID that checks covMeta without a cover profile file.
    +
    +[short] skip
    +[GODEBUG:gocacheverify=1] skip
    +
    +# Start with a clean GOCACHE.
    +env GOCACHE=$WORK/cache
    +
    +cd proj
    +
    +# Run tests with -cover and -coverpkg but without -coverprofile.
    +go test -cover -coverpkg=proj/... ./...
    +stdout 'coverage:'
    +
    +# Run again — should be served from cache.
    +go test -cover -coverpkg=proj/... ./...
    +stdout '\(cached\)'
    +stdout 'coverage:'
    +
    +# Modify a covered package that is not directly under test.
    +cp ../sub_modified.go sub/sub.go
    +
    +# Run again — the cache must be invalidated because a covered package changed.
    +go test -cover -coverpkg=proj/... ./...
    +! stdout '\(cached\)'
    +stdout 'coverage:'
    +
    +-- proj/go.mod --
    +module proj
    +
    +go 1.21
    +
    +-- proj/main.go --
    +package proj
    +
    +import "proj/sub"
    +
    +func Add(a, b int) int {
    +	return sub.Sub(a, -b)
    +}
    +
    +-- proj/main_test.go --
    +package proj
    +
    +import "testing"
    +
    +func TestAdd(t *testing.T) {
    +	if Add(1, 2) != 3 {
    +		t.Fatal("expected 3")
    +	}
    +}
    +
    +-- proj/sub/sub.go --
    +package sub
    +
    +func Sub(a, b int) int {
    +	return a - b
    +}
    +
    +-- proj/sub/sub_test.go --
    +package sub
    +
    +import "testing"
    +
    +func TestSub(t *testing.T) {
    +	if Sub(3, 1) != 2 {
    +		t.Fatal("expected 2")
    +	}
    +}
    +
    +-- sub_modified.go --
    +package sub
    +
    +// Added a comment to change the source.
    +
    +func Sub(a, b int) int {
    +	return a - b
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_cache_inputs.txt b/go/src/cmd/go/testdata/script/test_cache_inputs.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..29e538c11ece709f7c86bd414b4f5c985eae46da
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_cache_inputs.txt
    @@ -0,0 +1,354 @@
    +env GO111MODULE=off
    +
    +# Test that cached test results are invalidated in response to
    +# changes to the external inputs to the test.
    +
    +[short] skip
    +[GODEBUG:gocacheverify=1] skip
    +
    +# We're testing cache behavior, so start with a clean GOCACHE.
    +env GOCACHE=$WORK/cache
    +
    +# Build a helper binary to invoke os.Chtimes.
    +go build -o mkold$GOEXE mkold.go
    +
    +# Make test input files appear to be a minute old.
    +exec ./mkold$GOEXE 1m testcache/file.txt
    +exec ./mkold$GOEXE 1m testcache/script.sh
    +
    +# If the test reads an environment variable, changes to that variable
    +# should invalidate cached test results.
    +env TESTKEY=x
    +go test testcache -run=TestLookupEnv
    +go test testcache -run=TestLookupEnv
    +stdout '\(cached\)'
    +
    +# GODEBUG is always read
    +env GODEBUG=asdf=1
    +go test testcache -run=TestLookupEnv
    +! stdout '\(cached\)'
    +go test testcache -run=TestLookupEnv
    +stdout '\(cached\)'
    +env GODEBUG=
    +
    +env TESTKEY=y
    +go test testcache -run=TestLookupEnv
    +! stdout '\(cached\)'
    +go test testcache -run=TestLookupEnv
    +stdout '\(cached\)'
    +
    +# Changes in arguments forwarded to the test should invalidate cached test
    +# results.
    +go test testcache -run=TestOSArgs -v hello
    +! stdout '\(cached\)'
    +stdout 'hello'
    +go test testcache -run=TestOSArgs -v goodbye
    +! stdout '\(cached\)'
    +stdout 'goodbye'
    +
    +# golang.org/issue/36134: that includes the `-timeout` argument.
    +go test testcache -run=TestOSArgs -timeout=20m -v
    +! stdout '\(cached\)'
    +stdout '-test\.timeout[= ]20m'
    +go test testcache -run=TestOSArgs -timeout=5s -v
    +! stdout '\(cached\)'
    +stdout '-test\.timeout[= ]5s'
    +
    +# If the test stats a file, changes to the file should invalidate the cache.
    +go test testcache -run=FileSize
    +go test testcache -run=FileSize
    +stdout '\(cached\)'
    +
    +cp 4x.txt testcache/file.txt
    +go test testcache -run=FileSize
    +! stdout '\(cached\)'
    +go test testcache -run=FileSize
    +stdout '\(cached\)'
    +
    +# Files should be tracked even if the test changes its working directory.
    +go test testcache -run=Chdir
    +go test testcache -run=Chdir
    +stdout '\(cached\)'
    +cp 6x.txt testcache/file.txt
    +go test testcache -run=Chdir
    +! stdout '\(cached\)'
    +go test testcache -run=Chdir
    +stdout '\(cached\)'
    +
    +# The content of files should affect caching, provided that the mtime also changes.
    +exec ./mkold$GOEXE 1m testcache/file.txt
    +go test testcache -run=FileContent
    +go test testcache -run=FileContent
    +stdout '\(cached\)'
    +cp 2y.txt testcache/file.txt
    +exec ./mkold$GOEXE 50s testcache/file.txt
    +go test testcache -run=FileContent
    +! stdout '\(cached\)'
    +go test testcache -run=FileContent
    +stdout '\(cached\)'
    +
    +# Directory contents read via os.ReadDirNames should affect caching.
    +go test testcache -run=DirList
    +go test testcache -run=DirList
    +stdout '\(cached\)'
    +rm testcache/file.txt
    +go test testcache -run=DirList
    +! stdout '\(cached\)'
    +go test testcache -run=DirList
    +stdout '\(cached\)'
    +
    +# Files outside GOROOT and GOPATH should not affect caching.
    +env TEST_EXTERNAL_FILE=$WORK/external.txt
    +go test testcache -run=ExternalFile
    +go test testcache -run=ExternalFile
    +stdout '\(cached\)'
    +
    +rm $WORK/external.txt
    +go test testcache -run=ExternalFile
    +stdout '\(cached\)'
    +
    +# The -benchtime flag without -bench should not affect caching.
    +go test testcache -run=Benchtime -benchtime=1x
    +go test testcache -run=Benchtime -benchtime=1x
    +stdout '\(cached\)'
    +
    +go test testcache -run=Benchtime -bench=Benchtime -benchtime=1x
    +go test testcache -run=Benchtime -bench=Benchtime -benchtime=1x
    +! stdout '\(cached\)'
    +
    +# golang.org/issue/47355: that includes the `-failfast` argument.
    +go test testcache -run=TestOSArgs -failfast
    +! stdout '\(cached\)'
    +go test testcache -run=TestOSArgs -failfast
    +stdout '\(cached\)'
    +
    +# golang.org/issue/64638: that includes the `-fullpath` argument.
    +go test testcache -run=TestOSArgs -fullpath
    +! stdout '\(cached\)'
    +go test testcache -run=TestOSArgs -fullpath
    +stdout '\(cached\)'
    +
    +# golang.org/issue/70692: that includes the `-skip` flag
    +go test testcache -run=TestOdd -skip=TestOddFile
    +! stdout '\(cached\)'
    +go test testcache -run=TestOdd -skip=TestOddFile
    +stdout '\(cached\)'
    +
    +# Ensure that coverage profiles are being cached.
    +go test testcache -run=TestCoverageCache -coverprofile=coverage.out
    +go test testcache -run=TestCoverageCache -coverprofile=coverage.out
    +stdout '\(cached\)'
    +exists coverage.out
    +grep -q 'mode: set' coverage.out
    +grep -q 'testcache/hello.go:' coverage.out
    +
    +# A new -coverprofile file should use the cached coverage profile contents.
    +go test testcache -run=TestCoverageCache -coverprofile=coverage2.out
    +stdout '\(cached\)'
    +cmp coverage.out coverage2.out
    +
    +# Explicitly setting the default covermode should still use cache.
    +go test testcache -run=TestCoverageCache -coverprofile=coverage_set.out -covermode=set
    +stdout '\(cached\)'
    +cmp coverage.out coverage_set.out
    +
    +# A new -covermode should not use the cached coverage profile.
    +go test testcache -run=TestCoverageCache -coverprofile=coverage_atomic.out -covermode=atomic
    +! stdout '\(cached\)'
    +! cmp coverage.out coverage_atomic.out
    +grep -q 'mode: atomic' coverage_atomic.out
    +grep -q 'testcache/hello.go:' coverage_atomic.out
    +
    +# A new -coverpkg should not use the cached coverage profile.
    +go test testcache -run=TestCoverageCache -coverprofile=coverage_pkg.out -coverpkg=all
    +! stdout '\(cached\)'
    +! cmp coverage.out coverage_pkg.out
    +
    +# Test that -v doesn't prevent caching.
    +go test testcache -v -run=TestCoverageCache -coverprofile=coverage_v.out
    +go test testcache -v -run=TestCoverageCache -coverprofile=coverage_v2.out
    +stdout '\(cached\)'
    +cmp coverage_v.out coverage_v2.out
    +
    +# Test that -count affects caching.
    +go test testcache -run=TestCoverageCache -coverprofile=coverage_count.out -count=2
    +! stdout '\(cached\)'
    +
    +# Executables within GOROOT and GOPATH should affect caching,
    +# even if the test does not stat them explicitly.
    +
    +[!exec:/bin/sh] skip
    +chmod 0755 ./testcache/script.sh
    +
    +exec ./mkold$GOEXEC 1m testcache/script.sh
    +go test testcache -run=Exec
    +go test testcache -run=Exec
    +stdout '\(cached\)'
    +
    +exec ./mkold$GOEXE 50s testcache/script.sh
    +go test testcache -run=Exec
    +! stdout '\(cached\)'
    +go test testcache -run=Exec
    +stdout '\(cached\)'
    +
    +-- testcache/file.txt --
    +xx
    +-- 4x.txt --
    +xxxx
    +-- 6x.txt --
    +xxxxxx
    +-- 2y.txt --
    +yy
    +-- $WORK/external.txt --
    +This file is outside of GOPATH.
    +-- testcache/script.sh --
    +#!/bin/sh
    +exit 0
    +-- testcache/hello.go --
    +package testcache
    +
    +import "fmt"
    +
    +func HelloWorld(name string) string {
    +    if name == "" {
    +        return "Hello, World!"
    +    }
    +    return fmt.Sprintf("Hello, %s!", name)
    +}
    +
    +-- testcache/testcache_test.go --
    +// Copyright 2017 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package testcache
    +
    +import (
    +	"io"
    +	"os"
    +	"testing"
    +)
    +
    +func TestChdir(t *testing.T) {
    +	os.Chdir("..")
    +	defer os.Chdir("testcache")
    +	info, err := os.Stat("testcache/file.txt")
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	if info.Size()%2 != 1 {
    +		t.Fatal("even file")
    +	}
    +}
    +
    +func TestOddFileContent(t *testing.T) {
    +	f, err := os.Open("file.txt")
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	data, err := io.ReadAll(f)
    +	f.Close()
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	if len(data)%2 != 1 {
    +		t.Fatal("even file")
    +	}
    +}
    +
    +func TestOddFileSize(t *testing.T) {
    +	info, err := os.Stat("file.txt")
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	if info.Size()%2 != 1 {
    +		t.Fatal("even file")
    +	}
    +}
    +
    +func TestOddGetenv(t *testing.T) {
    +	val := os.Getenv("TESTKEY")
    +	if len(val)%2 != 1 {
    +		t.Fatal("even env value")
    +	}
    +}
    +
    +func TestLookupEnv(t *testing.T) {
    +	_, ok := os.LookupEnv("TESTKEY")
    +	if !ok {
    +		t.Fatal("env missing")
    +	}
    +}
    +
    +func TestDirList(t *testing.T) {
    +	f, err := os.Open(".")
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	f.Readdirnames(-1)
    +	f.Close()
    +}
    +
    +func TestExec(t *testing.T) {
    +	// Note: not using os/exec to make sure there is no unexpected stat.
    +	p, err := os.StartProcess("./script.sh", []string{"script"}, new(os.ProcAttr))
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	ps, err := p.Wait()
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	if !ps.Success() {
    +		t.Fatalf("script failed: %v", err)
    +	}
    +}
    +
    +func TestExternalFile(t *testing.T) {
    +	os.Open(os.Getenv("TEST_EXTERNAL_FILE"))
    +	_, err := os.Stat(os.Getenv("TEST_EXTERNAL_FILE"))
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +}
    +
    +func TestOSArgs(t *testing.T) {
    +	t.Log(os.Args)
    +}
    +
    +func TestBenchtime(t *testing.T) {
    +}
    +
    +func TestCoverageCache(t *testing.T) {
    +    result := HelloWorld("")
    +    if result != "Hello, World!" {
    +        t.Errorf("Expected 'Hello, World!', got '%s'", result)
    +    }
    +
    +    result = HelloWorld("Go")
    +    if result != "Hello, Go!" {
    +        t.Errorf("Expected 'Hello, Go!', got '%s'", result)
    +    }
    +}
    +
    +-- mkold.go --
    +package main
    +
    +import (
    +	"log"
    +	"os"
    +	"time"
    +)
    +
    +func main() {
    +	d, err := time.ParseDuration(os.Args[1])
    +	if err != nil {
    +		log.Fatal(err)
    +	}
    +	path := os.Args[2]
    +	old := time.Now().Add(-d)
    +	err = os.Chtimes(path, old, old)
    +	if err != nil {
    +		log.Fatal(err)
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_chatty_fail.txt b/go/src/cmd/go/testdata/script/test_chatty_fail.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a5ef559c77443bc6af8d432e932dadafce76cb9e
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_chatty_fail.txt
    @@ -0,0 +1,32 @@
    +# Run chatty tests. Assert on CONT lines.
    +! go test chatty_test.go -v
    +
    +# Sanity check that output occurs.
    +stdout -count=2 'this is sub-0'
    +stdout -count=2 'this is sub-1'
    +stdout -count=2 'this is sub-2'
    +stdout -count=1 'error from sub-0'
    +stdout -count=1 'error from sub-1'
    +stdout -count=1 'error from sub-2'
    +
    +# Non-parallel tests should not print CONT.
    +! stdout CONT
    +
    +-- chatty_test.go --
    +package chatty_test
    +
    +import (
    +	"testing"
    +	"fmt"
    +)
    +
    +func TestChatty(t *testing.T) {
    +    for i := 0; i < 3; i++ {
    +        t.Run(fmt.Sprintf("sub-%d", i), func(t *testing.T) {
    +            for j := 0; j < 2; j++ {
    +                t.Logf("this is sub-%d", i)
    +            }
    +            t.Errorf("error from sub-%d", i)
    +        })
    +    }
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_chatty_parallel_fail.txt b/go/src/cmd/go/testdata/script/test_chatty_parallel_fail.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..62f97db474c6c8e2b51f93c033a004e1cffc0dc1
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_chatty_parallel_fail.txt
    @@ -0,0 +1,62 @@
    +# Run parallel chatty tests.
    +# Check that multiple parallel outputs continue running.
    +! go test -parallel 3 chatty_parallel_test.go -v
    +
    +stdout -count=1 '^=== CONT  TestChattyParallel/sub-0'
    +stdout -count=1 '^=== CONT  TestChattyParallel/sub-1'
    +stdout -count=1 '^=== CONT  TestChattyParallel/sub-2'
    +
    +stdout -count=1 '^=== (CONT|NAME)  TestChattyParallel/sub-0\n    chatty_parallel_test.go:38: error from sub-0$'
    +stdout -count=1 '^=== (CONT|NAME)  TestChattyParallel/sub-1\n    chatty_parallel_test.go:38: error from sub-1$'
    +stdout -count=1 '^=== (CONT|NAME)  TestChattyParallel/sub-2\n    chatty_parallel_test.go:38: error from sub-2$'
    +
    +# Run parallel chatty tests with -json.
    +# Check that each output is attributed to the right test.
    +! go test -json -parallel 3 chatty_parallel_test.go -v
    +stdout -count=1 '"Test":"TestChattyParallel/sub-0","Output":"    chatty_parallel_test.go:38: error from sub-0\\n"'
    +stdout -count=1 '"Test":"TestChattyParallel/sub-1","Output":"    chatty_parallel_test.go:38: error from sub-1\\n"'
    +stdout -count=1 '"Test":"TestChattyParallel/sub-2","Output":"    chatty_parallel_test.go:38: error from sub-2\\n"'
    +
    +-- chatty_parallel_test.go --
    +package chatty_parallel_test
    +
    +import (
    +	"testing"
    +	"fmt"
    +	"flag"
    +)
    +
    +// This test ensures the order of CONT lines in parallel chatty tests.
    +func TestChattyParallel(t *testing.T) {
    +	t.Parallel()
    +
    +	// The number of concurrent tests running. This is closely tied to the
    +	// -parallel test flag, so we grab it from the flag rather than setting it
    +	// to some constant.
    +	parallel := flag.Lookup("test.parallel").Value.(flag.Getter).Get().(int)
    +
    +	// ready is a synchronization mechanism that causes subtests to execute
    +	// round robin.
    +	ready := make([]chan bool, parallel)
    +	for i := range ready {
    +		ready[i] = make(chan bool, 1)
    +	}
    +	ready[0] <- true
    +
    +	for i := range ready {
    +		i := i
    +		t.Run(fmt.Sprintf("sub-%d", i), func(t *testing.T) {
    +			t.Parallel()
    +
    +			// Some basic log output to precede the failures.
    +			<-ready[i]
    +			t.Logf("this is sub-%d", i)
    +			ready[(i+1)%len(ready)] <- true
    +
    +			// The actual failure messages we care about.
    +			<-ready[i]
    +			t.Errorf("error from sub-%d", i)
    +			ready[(i+1)%len(ready)] <- true
    +		})
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_chatty_parallel_success.txt b/go/src/cmd/go/testdata/script/test_chatty_parallel_success.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..01653acd3655a8b9fa8b78283a9fd0879ce5e300
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_chatty_parallel_success.txt
    @@ -0,0 +1,52 @@
    +# Run parallel chatty tests. Assert on CONT or NAME lines. This test makes sure that
    +# multiple parallel outputs have the appropriate test name lines between them.
    +go test -parallel 3 chatty_parallel_test.go -v
    +stdout -count=2 '^=== (CONT|NAME)  TestChattyParallel/sub-0\n    chatty_parallel_test.go:32: this is sub-0$'
    +stdout -count=2 '^=== (CONT|NAME)  TestChattyParallel/sub-1\n    chatty_parallel_test.go:32: this is sub-1$'
    +stdout -count=2 '^=== (CONT|NAME)  TestChattyParallel/sub-2\n    chatty_parallel_test.go:32: this is sub-2$'
    +
    +# Run parallel chatty tests with -json.
    +# Assert test2json has properly attributed output.
    +go test -json -parallel 3 chatty_parallel_test.go -v
    +stdout -count=2 '"Test":"TestChattyParallel/sub-0","Output":"    chatty_parallel_test.go:32: this is sub-0\\n"'
    +stdout -count=2 '"Test":"TestChattyParallel/sub-1","Output":"    chatty_parallel_test.go:32: this is sub-1\\n"'
    +stdout -count=2 '"Test":"TestChattyParallel/sub-2","Output":"    chatty_parallel_test.go:32: this is sub-2\\n"'
    +
    +-- chatty_parallel_test.go --
    +package chatty_parallel_test
    +
    +import (
    +	"testing"
    +	"fmt"
    +	"flag"
    +)
    +
    +// This test ensures the order of CONT lines in parallel chatty tests.
    +func TestChattyParallel(t *testing.T) {
    +	t.Parallel()
    +
    +	// The number of concurrent tests running. This is closely tied to the
    +	// -parallel test flag, so we grab it from the flag rather than setting it
    +	// to some constant.
    +	parallel := flag.Lookup("test.parallel").Value.(flag.Getter).Get().(int)
    +
    +	// ready is a synchronization mechanism that causes subtests to execute
    +	// round robin.
    +	ready := make([]chan bool, parallel)
    +	for i := range ready {
    +		ready[i] = make(chan bool, 1)
    +	}
    +	ready[0] <- true
    +
    +	for i := range ready {
    +		i := i
    +		t.Run(fmt.Sprintf("sub-%d", i), func(t *testing.T) {
    +			t.Parallel()
    +			for j := 0; j < 2; j++ {
    +				<-ready[i]
    +				t.Logf("this is sub-%d", i)
    +				ready[(i+1)%len(ready)] <- true
    +			}
    +		})
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_chatty_parallel_success_run.txt b/go/src/cmd/go/testdata/script/test_chatty_parallel_success_run.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..1d4b6d631898e11f6ba48b59536d2462ddd92c41
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_chatty_parallel_success_run.txt
    @@ -0,0 +1,41 @@
    +# Run parallel chatty tests. Assert on CONT or NAME lines. This test makes sure that
    +# multiple parallel outputs have the appropriate CONT lines between them.
    +go test -parallel 3 chatty_parallel -v
    +
    +stdout '=== RUN   TestInterruptor/interruption\n=== (CONT|NAME)  TestLog\n    chatty_parallel_test.go:28: this is the second TestLog log\n--- PASS: Test(Log|Interruptor) \([0-9.]{4}s\)'
    +
    +-- go.mod --
    +module chatty_parallel
    +
    +go 1.18
    +-- chatty_parallel_test.go --
    +package chatty_parallel_test
    +
    +import (
    +	"testing"
    +)
    +
    +var (
    +	afterFirstLog = make(chan struct{})
    +	afterSubTest  = make(chan struct{})
    +	afterSecondLog = make(chan struct{})
    +)
    +
    +func TestInterruptor(t *testing.T) {
    +	t.Parallel()
    +
    +	<-afterFirstLog
    +	t.Run("interruption", func (t *testing.T) {})
    +	close(afterSubTest)
    +	<-afterSecondLog // Delay the "PASS: TestInterruptor" line until after "CONT  TestLog".
    +}
    +
    +func TestLog(t *testing.T) {
    +	t.Parallel()
    +
    +	t.Logf("this is the first TestLog log")
    +	close(afterFirstLog)
    +	<-afterSubTest
    +	t.Logf("this is the second TestLog log")
    +	close(afterSecondLog)
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_chatty_success.txt b/go/src/cmd/go/testdata/script/test_chatty_success.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8bfa569f807fd4a95ad35aaa9be0bff7be7f3651
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_chatty_success.txt
    @@ -0,0 +1,27 @@
    +# Run chatty tests. Assert on CONT lines.
    +go test chatty_test.go -v
    +
    +# Non-parallel tests should not print CONT.
    +! stdout CONT
    +
    +# The assertion is condensed into one line so that it precisely matches output,
    +# rather than skipping lines and allow rogue CONT lines.
    +stdout '=== RUN   TestChatty\n=== RUN   TestChatty/sub-0\n    chatty_test.go:12: this is sub-0\n    chatty_test.go:12: this is sub-0\n=== RUN   TestChatty/sub-1\n    chatty_test.go:12: this is sub-1\n    chatty_test.go:12: this is sub-1\n=== RUN   TestChatty/sub-2\n    chatty_test.go:12: this is sub-2\n    chatty_test.go:12: this is sub-2\n--- PASS: TestChatty'
    +
    +-- chatty_test.go --
    +package chatty_test
    +
    +import (
    +	"testing"
    +	"fmt"
    +)
    +
    +func TestChatty(t *testing.T) {
    +    for i := 0; i < 3; i++ {
    +        t.Run(fmt.Sprintf("sub-%d", i), func(t *testing.T) {
    +            for j := 0; j < 2; j++ {
    +                t.Logf("this is sub-%d", i)
    +            }
    +        })
    +    }
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_cleanup_failnow.txt b/go/src/cmd/go/testdata/script/test_cleanup_failnow.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8f39d98852ec201b3d8bd61549667098f1f0c85a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_cleanup_failnow.txt
    @@ -0,0 +1,46 @@
    +# For issue 41355
    +[short] skip
    +
    +# This test could fail if the testing package does not wait until
    +# a panicking test does the panic. Turn off multithreading and GC
    +# to increase the probability of such a failure.
    +env GOMAXPROCS=1
    +env GOGC=off
    +
    +# If the test exits with 'no tests to run', it means the testing package
    +# implementation is incorrect and does not wait until a test panic.
    +# If the test exits with '(?s)panic: die.*panic: die', it means
    +# the testing package did an extra panic for a panicking test.
    +
    +! go test -v cleanup_failnow/panic_nocleanup_test.go
    +! stdout 'no tests to run'
    +stdout '(?s)panic: die \[recovered, repanicked\]'
    +! stdout '(?s)panic: die \[recovered, repanicked\].*panic: die'
    +
    +! go test -v cleanup_failnow/panic_withcleanup_test.go
    +! stdout 'no tests to run'
    +stdout '(?s)panic: die \[recovered\].*panic: die'
    +! stdout '(?s)panic: die \[recovered\].*panic: die.*panic: die'
    +
    +-- cleanup_failnow/panic_nocleanup_test.go --
    +package panic_nocleanup_test
    +import "testing"
    +func TestX(t *testing.T) {
    +	t.Run("x", func(t *testing.T) {
    +		panic("die")
    +	})
    +}
    +
    +-- cleanup_failnow/panic_withcleanup_test.go --
    +package panic_withcleanup_test
    +import "testing"
    +func TestCleanupWithFailNow(t *testing.T) {
    +	t.Cleanup(func() {
    +		t.FailNow()
    +	})
    +	t.Run("x", func(t *testing.T) {
    +		t.Run("y", func(t *testing.T) {
    +			panic("die")
    +		})
    +	})
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_compile_binary.txt b/go/src/cmd/go/testdata/script/test_compile_binary.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..63bb8ec3e78149ea2d80589304deec75131b97ca
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_compile_binary.txt
    @@ -0,0 +1,8 @@
    +env GO111MODULE=off
    +
    +! go test -c compile_binary/...
    +stderr 'build comment'
    +
    +-- compile_binary/foo_test.go --
    +// +build foo
    +package foo
    diff --git a/go/src/cmd/go/testdata/script/test_compile_multi_pkg.txt b/go/src/cmd/go/testdata/script/test_compile_multi_pkg.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..921ef5c6c5718ccdc3eb66b55494a146bbc324a5
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_compile_multi_pkg.txt
    @@ -0,0 +1,50 @@
    +[short] skip 'links test binaries'
    +
    +# Verify test -c can output multiple executables to a directory.
    +
    +# This test also serves as a regression test for https://go.dev/issue/62221:
    +# prior to the fix for that issue, it occasionally failed with ETXTBSY when
    +# run on Unix platforms.
    +
    +go test -c -o $WORK/some/nonexisting/directory/ ./pkg/...
    +exists -exec $WORK/some/nonexisting/directory/pkg1.test$GOEXE
    +exists -exec $WORK/some/nonexisting/directory/pkg2.test$GOEXE
    +
    +go test -c ./pkg/...
    +exists -exec pkg1.test$GOEXE
    +exists -exec pkg2.test$GOEXE
    +
    +! go test -c -o $WORK/bin/test/bin.test.exe ./pkg/...
    +stderr '^with multiple packages, -o must refer to a directory or '$devnull
    +
    +! go test -c ./...
    +stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1'
    +
    +! go test -c -o $WORK/bin/test/ ./...
    +stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1'
    +
    +! go test -o $WORK/bin/filename.exe ./pkg/...
    +stderr '^with multiple packages, -o must refer to a directory or '$devnull
    +
    +! go test -o $WORK/bin/ ./...
    +stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1'
    +
    +go test -c -o $devnull ./...
    +
    +rm pkg1.test$GOEXE
    +rm pkg2.test$GOEXE
    +go test -o . ./pkg/...
    +exists -exec pkg1.test$GOEXE
    +exists -exec pkg2.test$GOEXE
    +
    +-- go.mod --
    +module example
    +
    +-- pkg/pkg1/pkg1_test.go --
    +package pkg1
    +
    +-- pkg/pkg2/pkg2_test.go --
    +package pkg2
    +
    +-- anotherpkg/pkg1/pkg1_test.go --
    +package pkg1
    diff --git a/go/src/cmd/go/testdata/script/test_compile_tempfile.txt b/go/src/cmd/go/testdata/script/test_compile_tempfile.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..05f721a80070ae0e2fecc54f09ae78593e84defe
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_compile_tempfile.txt
    @@ -0,0 +1,11 @@
    +[short] skip
    +
    +# Ensure that the target of 'go build -o' can be an existing, empty file so that
    +# its name can be reserved using os.CreateTemp or the 'mktemp` command.
    +
    +go build -o empty-file$GOEXE main.go
    +
    +-- main.go --
    +package main
    +func main() {}
    +-- empty-file$GOEXE --
    diff --git a/go/src/cmd/go/testdata/script/test_crlf_example.txt b/go/src/cmd/go/testdata/script/test_crlf_example.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..9c2a70aa39b13aead6fd4c1bb31a3db774f476d8
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_crlf_example.txt
    @@ -0,0 +1,39 @@
    +# Tests that crlf in the output of examples are handled.
    +# Verifies golang.org/issue/51269
    +go test x_test.go
    +
    +-- x_test.go --
    +package  x
    +
    +import (
    +    "io"
    +    "fmt"
    +    "os"
    +    "runtime"
    +)
    +
    +func Example_lf() {
    +	fmt.Print("foo", "\n", "bar")
    +	// Output:
    +	// foo
    +	// bar
    +}
    +
    +func Example_println() {
    +	fmt.Println("foo")
    +	fmt.Println("bar")
    +	// Output:
    +	// foo
    +	// bar
    +}
    +
    +func Example_crlf() {
    +	if runtime.GOOS == "windows" {
    +		io.WriteString(os.Stdout, "foo\r\nbar\r\n")
    +	} else {
    +		io.WriteString(os.Stdout, "foo\nbar\n")
    +	}
    +	// Output:
    +	// foo
    +	// bar
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_deadline.txt b/go/src/cmd/go/testdata/script/test_deadline.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..06ae16ffd2a9aa7ed216a17bbbe3893349b8e69a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_deadline.txt
    @@ -0,0 +1,54 @@
    +[short] skip
    +
    +go test -timeout=0 -run=TestNoDeadline
    +go test -timeout=1m -run=TestDeadlineWithinMinute
    +go test -timeout=1m -run=TestSubtestDeadlineWithinMinute
    +
    +-- go.mod --
    +module m
    +
    +go 1.16
    +-- deadline_test.go --
    +package testing_test
    +
    +import (
    +	"testing"
    +	"time"
    +)
    +
    +func TestNoDeadline(t *testing.T) {
    +	d, ok := t.Deadline()
    +	if ok || !d.IsZero() {
    +		t.Fatalf("t.Deadline() = %v, %v; want 0, false", d, ok)
    +	}
    +}
    +
    +func TestDeadlineWithinMinute(t *testing.T) {
    +	now := time.Now()
    +	d, ok := t.Deadline()
    +	if !ok || d.IsZero() {
    +		t.Fatalf("t.Deadline() = %v, %v; want nonzero deadline", d, ok)
    +	}
    +	if !d.After(now) {
    +		t.Fatalf("t.Deadline() = %v; want after start of test (%v)", d, now)
    +	}
    +	if d.Sub(now) > time.Minute {
    +		t.Fatalf("t.Deadline() = %v; want within one minute of start of test (%v)", d, now)
    +	}
    +}
    +
    +func TestSubtestDeadlineWithinMinute(t *testing.T) {
    +	t.Run("sub", func(t *testing.T) {
    +		now := time.Now()
    +		d, ok := t.Deadline()
    +		if !ok || d.IsZero() {
    +			t.Fatalf("t.Deadline() = %v, %v; want nonzero deadline", d, ok)
    +		}
    +		if !d.After(now) {
    +			t.Fatalf("t.Deadline() = %v; want after start of test (%v)", d, now)
    +		}
    +		if d.Sub(now) > time.Minute {
    +			t.Fatalf("t.Deadline() = %v; want within one minute of start of test (%v)", d, now)
    +		}
    +	})
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_default_godebug_issue69203.txt b/go/src/cmd/go/testdata/script/test_default_godebug_issue69203.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..2e8d32dfc4d9a82bbd7e636a8a093d38090cdbea
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_default_godebug_issue69203.txt
    @@ -0,0 +1,28 @@
    +# This is the case reported in issue #69203. Setting GO111MODULE
    +# off sets the Go version used to determine default GODEBUG settings
    +# to Go 1.20, flipping the httplaxcontentlength godebug's value to "1".
    +# Doing so causes net/http.TestReadResponseErrors to fail.
    +# Before CL 610875, the default GODEBUG was only sometimes used to generate the actionID
    +# for a link: if the binary being linked was package main, the default GODEBUG would be
    +# embedded in the build info, which is in turn used for the action id. But for a test
    +# of a non-main package, there would be no build info set and the default godebug would not
    +# be taken into account in the action id. So if the only difference between a test run was the
    +# default GODEBUG setting, the cached test result would be used (even though the
    +# binaries were different because they contained different default GODEBUG values).
    +# Now we explicitly add the default GODEBUG to the action id, so the test binaries' link actions
    +# have different actionIDs. That means that the cached test results (whose action ids
    +# are based on the test binaries' action ids) should only be used when the default GODEBUG matches.
    +
    +[short] skip 'runs go test'
    +
    +# Baseline: ensure TestReadResponseErrors fails with GODEBUG httplaxcontentlength=1.
    +env GO111MODULE=off
    +! go test net/http -run=^TestReadResponseErrors$
    +
    +# Ensure that it passes without httplaxcontentlength=1.
    +env GO111MODULE=on
    +go test net/http -run=^TestReadResponseErrors$
    +
    +# Make sure that the previous cached pass isn't reused when setting httplaxcontentlength=1.
    +env GO111MODULE=off
    +! go test net/http -run=^TestReadResponseErrors$
    diff --git a/go/src/cmd/go/testdata/script/test_empty.txt b/go/src/cmd/go/testdata/script/test_empty.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..5ebbecd53def0ccd584cafc01055da59b5d75509
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_empty.txt
    @@ -0,0 +1,53 @@
    +[!race] skip
    +
    +cd $GOPATH/src/empty/pkg
    +go test -cover -coverpkg=. -race
    +
    +[short] stop # Only run first case in short mode
    +
    +cd $GOPATH/src/empty/test
    +go test -cover -coverpkg=. -race
    +
    +cd $GOPATH/src/empty/xtest
    +go test -cover -coverpkg=. -race
    +
    +cd $GOPATH/src/empty/pkgtest
    +go test -cover -coverpkg=. -race
    +
    +cd $GOPATH/src/empty/pkgxtest
    +go test -cover -coverpkg=. -race
    +
    +cd $GOPATH/src/empty/pkgtestxtest
    +go test -cover -coverpkg=. -race
    +
    +cd $GOPATH/src/empty/testxtest
    +go test -cover -coverpkg=. -race
    +
    +-- empty/go.mod --
    +module empty
    +
    +go 1.16
    +-- empty/pkg/pkg.go --
    +package p
    +-- empty/pkgtest/pkg.go --
    +package p
    +-- empty/pkgtest/test_test.go --
    +package p
    +-- empty/pkgtestxtest/pkg.go --
    +package p
    +-- empty/pkgtestxtest/test_test.go --
    +package p
    +-- empty/pkgtestxtest/xtest_test.go --
    +package p_test
    +-- empty/pkgxtest/pkg.go --
    +package p
    +-- empty/pkgxtest/xtest_test.go --
    +package p_test
    +-- empty/test/test_test.go --
    +package p
    +-- empty/testxtest/test_test.go --
    +package p
    +-- empty/testxtest/xtest_test.go --
    +package p_test
    +-- empty/xtest/xtest_test.go --
    +package p_test
    diff --git a/go/src/cmd/go/testdata/script/test_env_term.txt b/go/src/cmd/go/testdata/script/test_env_term.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8a5f79ab22013f76a6368c0515d5a8a173396af5
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_env_term.txt
    @@ -0,0 +1,15 @@
    +# Tests golang.org/issue/12096
    +
    +env TERM=''
    +go test test_test.go
    +! stdout '^ok.*\[no tests to run\]'
    +stdout '^ok'
    +
    +-- test_test.go --
    +package main
    +import ("os"; "testing")
    +func TestEnv(t *testing.T) {
    +	if os.Getenv("TERM") != "" {
    +		t.Fatal("TERM is set")
    +	}
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_example_goexit.txt b/go/src/cmd/go/testdata/script/test_example_goexit.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c924534f5a1da5598b6fea58b3890e9c1a5ae7b3
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_example_goexit.txt
    @@ -0,0 +1,29 @@
    +# For issue golang.org/issue/41084
    +[short] skip
    +
    +! go test -v examplegoexit
    +stdout '(?s)--- PASS.*--- FAIL.*'
    +stdout 'panic: test executed panic\(nil\) or runtime\.Goexit'
    +
    +-- go.mod --
    +module examplegoexit
    +
    +go 1.16
    +-- example_test.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"runtime"
    +)
    +
    +func Example_pass() {
    +	fmt.Println("pass")
    +	// Output:
    +	// pass
    +}
    +
    +func Example_goexit() {
    +	runtime.Goexit()
    +	// Output:
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_exit.txt b/go/src/cmd/go/testdata/script/test_exit.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..3703ba53d362b0b0930cde8aa2ff233c5eee9934
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_exit.txt
    @@ -0,0 +1,131 @@
    +# Builds and runs test binaries, so skip in short mode.
    +[short] skip
    +
    +env GO111MODULE=on
    +
    +# If a test invoked by 'go test' exits with a zero status code,
    +# it will panic.
    +! go test ./zero
    +! stdout ^ok
    +! stdout 'exit status'
    +stdout 'panic'
    +stdout ^FAIL
    +
    +# If a test exits with a non-zero status code, 'go test' fails normally.
    +! go test ./one
    +! stdout ^ok
    +stdout 'exit status'
    +! stdout 'panic'
    +stdout ^FAIL
    +
    +# Ensure that other flags still do the right thing.
    +go test -list=. ./zero
    +stdout ExitZero
    +
    +! go test -bench=. ./zero
    +stdout 'panic'
    +
    +# 'go test' with no args streams output without buffering. Ensure that it still
    +# catches a zero exit with missing output.
    +cd zero
    +! go test
    +stdout 'panic'
    +cd ../normal
    +go test
    +stdout ^ok
    +cd ..
    +
    +# If a TestMain exits with a zero status code, 'go test' shouldn't
    +# complain about that. It's a common way to skip testing a package
    +# entirely.
    +go test ./main_zero
    +! stdout 'skipping all tests'
    +stdout ^ok
    +
    +# With -v, we'll see the warning from TestMain.
    +go test -v ./main_zero
    +stdout 'skipping all tests'
    +stdout ^ok
    +
    +# Listing all tests won't actually give a result if TestMain exits. That's okay,
    +# because this is how TestMain works. If we decide to support -list even when
    +# TestMain is used to skip entire packages, we can change this test case.
    +go test -list=. ./main_zero
    +stdout 'skipping all tests'
    +! stdout TestNotListed
    +
    +# Running the test directly still fails, if we pass the flag.
    +go test -c -o ./zero.exe ./zero
    +! exec ./zero.exe -test.paniconexit0
    +
    +# Using -json doesn't affect the exit status.
    +! go test -json ./zero
    +! stdout '"Output":"ok'
    +! stdout 'exit status'
    +stdout 'panic'
    +stdout '"Output":"FAIL'
    +
    +# Running the test via test2json also fails.
    +! go tool test2json ./zero.exe -test.v -test.paniconexit0
    +! stdout '"Output":"ok'
    +! stdout 'exit status'
    +stdout 'panic'
    +
    +-- go.mod --
    +module m
    +
    +-- ./normal/normal.go --
    +package normal
    +-- ./normal/normal_test.go --
    +package normal
    +
    +import "testing"
    +
    +func TestExitZero(t *testing.T) {
    +}
    +
    +-- ./zero/zero.go --
    +package zero
    +-- ./zero/zero_test.go --
    +package zero
    +
    +import (
    +	"os"
    +	"testing"
    +)
    +
    +func TestExitZero(t *testing.T) {
    +	os.Exit(0)
    +}
    +
    +-- ./one/one.go --
    +package one
    +-- ./one/one_test.go --
    +package one
    +
    +import (
    +	"os"
    +	"testing"
    +)
    +
    +func TestExitOne(t *testing.T) {
    +	os.Exit(1)
    +}
    +
    +-- ./main_zero/zero.go --
    +package zero
    +-- ./main_zero/zero_test.go --
    +package zero
    +
    +import (
    +	"fmt"
    +	"os"
    +	"testing"
    +)
    +
    +func TestMain(m *testing.M) {
    +	fmt.Println("skipping all tests")
    +	os.Exit(0)
    +}
    +
    +func TestNotListed(t *testing.T) {}
    diff --git a/go/src/cmd/go/testdata/script/test_fail_fast.txt b/go/src/cmd/go/testdata/script/test_fail_fast.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..1f169d6da8717ba39242edc6f13c3dd2433e7be1
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_fail_fast.txt
    @@ -0,0 +1,146 @@
    +[short] skip
    +
    +# test fail fast
    +! go test ./failfast_test.go -run='TestFailingA' -failfast=true
    +stdout -count=1 'FAIL - '
    +! go test ./failfast_test.go -run='TestFailing[AB]' -failfast=true
    +stdout -count=1 'FAIL - '
    +! go test ./failfast_test.go -run='TestFailing[AB]' -failfast=false
    +stdout -count=2 'FAIL - '
    +
    +# mix with non-failing tests
    +! go test ./failfast_test.go -run='TestA|TestFailing[AB]' -failfast=true
    +stdout -count=1 'FAIL - '
    +! go test ./failfast_test.go -run='TestA|TestFailing[AB]' -failfast=false
    +stdout -count=2 'FAIL - '
    +
    +# mix with parallel tests
    +! go test ./failfast_test.go -run='TestFailingB|TestParallelFailingA' -failfast=true
    +stdout -count=2 'FAIL - '
    +! go test ./failfast_test.go -run='TestFailingB|TestParallelFailingA' -failfast=false
    +stdout -count=2 'FAIL - '
    +! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]' -failfast=true
    +stdout -count=3 'FAIL - '
    +! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]' -failfast=false
    +stdout -count=3 'FAIL - '
    +
    +# mix with parallel sub-tests
    +! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]|TestParallelFailingSubtestsA' -failfast=true
    +stdout -count=3 'FAIL - '
    +! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]|TestParallelFailingSubtestsA' -failfast=false
    +stdout -count=5 'FAIL - '
    +! go test ./failfast_test.go -run='TestParallelFailingSubtestsA' -failfast=true
    +stdout -count=1 'FAIL - '
    +
    +# only parallels
    +! go test ./failfast_test.go -run='TestParallelFailing[AB]' -failfast=false
    +stdout -count=2 'FAIL - '
    +
    +# non-parallel subtests
    +! go test ./failfast_test.go -run='TestFailingSubtestsA' -failfast=true
    +stdout -count=1 'FAIL - '
    +! go test ./failfast_test.go -run='TestFailingSubtestsA' -failfast=false
    +stdout -count=2 'FAIL - '
    +
    +# fatal test
    +! go test ./failfast_test.go -run='TestFatal[CD]' -failfast=true
    +stdout -count=1 'FAIL - '
    +! go test ./failfast_test.go -run='TestFatal[CD]' -failfast=false
    +stdout -count=2 'FAIL - '
    +
    +# cross package failfast
    +! go test -p 1 -failfast ./a ./b ./c
    +stdout -count=1 'FAIL - '
    +stdout -count=1 'FAIL - TestFailingPkgA'
    +
    +-- go.mod --
    +module m
    +
    +go 1.21.0
    +-- failfast_test.go --
    +// Copyright 2017 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package failfast
    +
    +import "testing"
    +
    +func TestA(t *testing.T) {
    +	// Edge-case testing, mixing unparallel tests too
    +	t.Logf("LOG: %s", t.Name())
    +}
    +
    +func TestFailingA(t *testing.T) {
    +	t.Errorf("FAIL - %s", t.Name())
    +}
    +
    +func TestB(t *testing.T) {
    +	// Edge-case testing, mixing unparallel tests too
    +	t.Logf("LOG: %s", t.Name())
    +}
    +
    +func TestParallelFailingA(t *testing.T) {
    +	t.Parallel()
    +	t.Errorf("FAIL - %s", t.Name())
    +}
    +
    +func TestParallelFailingB(t *testing.T) {
    +	t.Parallel()
    +	t.Errorf("FAIL - %s", t.Name())
    +}
    +
    +func TestParallelFailingSubtestsA(t *testing.T) {
    +	t.Parallel()
    +	t.Run("TestFailingSubtestsA1", func(t *testing.T) {
    +		t.Errorf("FAIL - %s", t.Name())
    +	})
    +	t.Run("TestFailingSubtestsA2", func(t *testing.T) {
    +		t.Errorf("FAIL - %s", t.Name())
    +	})
    +}
    +
    +func TestFailingSubtestsA(t *testing.T) {
    +	t.Run("TestFailingSubtestsA1", func(t *testing.T) {
    +		t.Errorf("FAIL - %s", t.Name())
    +	})
    +	t.Run("TestFailingSubtestsA2", func(t *testing.T) {
    +		t.Errorf("FAIL - %s", t.Name())
    +	})
    +}
    +
    +func TestFailingB(t *testing.T) {
    +	t.Errorf("FAIL - %s", t.Name())
    +}
    +
    +func TestFatalC(t *testing.T) {
    +	t.Fatalf("FAIL - %s", t.Name())
    +}
    +
    +func TestFatalD(t *testing.T) {
    +	t.Fatalf("FAIL - %s", t.Name())
    +}
    +-- a/a_test.go --
    +package a
    +
    +import "testing"
    +
    +func TestFailingPkgA(t *testing.T) {
    +	t.Errorf("FAIL - %s", t.Name())
    +}
    +-- b/b_test.go --
    +package b
    +
    +import "testing"
    +
    +func TestFailingPkgB(t *testing.T) {
    +	t.Errorf("FAIL - %s", t.Name())
    +}
    +-- c/c_test.go --
    +package c
    +
    +import "testing"
    +
    +func TestFailingPkgC(t *testing.T) {
    +	t.Errorf("FAIL - %s", t.Name())
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_fail_newline.txt b/go/src/cmd/go/testdata/script/test_fail_newline.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..43cee565a19c1e5a5819826ef34becd3de8c7564
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_fail_newline.txt
    @@ -0,0 +1,65 @@
    +[short] skip
    +
    +# In package list mode, output is buffered.
    +# Check that a newline is printed after the buffer's contents.
    +cd fail
    +! go test .
    +! stderr .
    +stdout '^exitcode=1\n'
    +stdout '^FAIL\s+example/fail'
    +
    +# In local directory mode output is streamed, so we don't know
    +# whether the test printed anything at all, so we print the exit code
    +# (just in case it failed without emitting any output at all),
    +# and that happens to add the needed newline as well.
    +! go test
    +! stderr .
    +stdout '^exitcode=1exit status 1\n'
    +stdout '^FAIL\s+example/fail'
    +
    +# In package list mode, if the test passes the 'ok' message appears
    +# on its own line.
    +cd ../skip
    +go test -v .
    +! stderr .
    +stdout '^skipping\n'
    +stdout '^ok\s+example/skip'
    +
    +# If the output is streamed and the test passes, we can't tell whether it ended
    +# in a partial line, and don't want to emit any extra output in the
    +# overwhelmingly common case that it did not.
    +# (In theory we could hook the 'os' package to report whether output
    +# was emitted and whether it ended in a newline, but that seems too invasive.)
    +go test
    +! stderr .
    +stdout '^skippingok\s+example/skip'
    +
    +
    +-- go.mod --
    +module example
    +
    +go 1.18
    +-- fail/fail_test.go --
    +package fail
    +
    +import (
    +	"os"
    +	"testing"
    +)
    +
    +func TestMain(m *testing.M) {
    +	os.Stderr.WriteString("exitcode=1")
    +	os.Exit(1)
    +}
    +-- skip/skip_test.go --
    +package skip
    +
    +import (
    +	"os"
    +	"testing"
    +)
    +
    +func TestMain(m *testing.M) {
    +	os.Stderr.WriteString("skipping")
    +	os.Exit(0)
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_finished_subtest_goroutines.txt b/go/src/cmd/go/testdata/script/test_finished_subtest_goroutines.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8db821eb77f2ecee3f1daad4144570f2c50f68f7
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_finished_subtest_goroutines.txt
    @@ -0,0 +1,52 @@
    +# Regression test for https://golang.org/issue/45127:
    +# Goroutines for completed parallel subtests should exit immediately,
    +# not block until earlier subtests have finished.
    +
    +[short] skip
    +
    +! go test .
    +stdout 'panic: slow failure'
    +! stdout '\[chan send'
    +
    +-- go.mod --
    +module golang.org/issue45127
    +
    +go 1.16
    +-- issue45127_test.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"runtime"
    +	"runtime/debug"
    +	"sync"
    +	"testing"
    +)
    +
    +func TestTestingGoroutineLeak(t *testing.T) {
    +	debug.SetTraceback("all")
    +
    +	var wg sync.WaitGroup
    +	const nFast = 10
    +
    +	t.Run("slow", func(t *testing.T) {
    +		t.Parallel()
    +		wg.Wait()
    +		for i := 0; i < nFast; i++ {
    +			// If the subtest goroutines are going to park on the channel
    +			// send, allow them to park now. If they're not going to park,
    +			// make sure they have had a chance to run to completion so
    +			// that they aren't spuriously parked when we panic.
    +			runtime.Gosched()
    +		}
    +		panic("slow failure")
    +	})
    +
    +	wg.Add(nFast)
    +	for i := 0; i < nFast; i++ {
    +		t.Run(fmt.Sprintf("leaky%d", i), func(t *testing.T) {
    +			t.Parallel()
    +			wg.Done()
    +		})
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_flag.txt b/go/src/cmd/go/testdata/script/test_flag.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6ef4529659b8002c522b35e6b425f6cc8674c657
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_flag.txt
    @@ -0,0 +1,38 @@
    +[short] skip
    +
    +go test flag_test.go -v -args -v=7 # Two distinct -v flags
    +go test -v flag_test.go -args -v=7 # Two distinct -v flags
    +
    +# Using a custom flag mixed with regular 'go test' flags should be OK.
    +go test -count=1 -custom -args -v=7
    +
    +# However, it should be an error to use custom flags when -c is used,
    +# since we know for sure that no test binary will run at all.
    +! go test -c -custom
    +stderr '^go: unknown flag -custom cannot be used with -c$'
    +
    +# The same should apply even if -c comes after a custom flag.
    +! go test -custom -c
    +stderr '^go: unknown flag -custom cannot be used with -c$'
    +
    +-- go.mod --
    +module m
    +-- flag_test.go --
    +package flag_test
    +
    +import (
    +	"flag"
    +	"log"
    +	"testing"
    +)
    +
    +var v = flag.Int("v", 0, "v flag")
    +
    +var custom = flag.Bool("custom", false, "")
    +
    +// Run this as go test pkg -v=7
    +func TestVFlagIsSet(t *testing.T) {
    +	if *v != 7 {
    +		log.Fatal("v flag not set")
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_flags.txt b/go/src/cmd/go/testdata/script/test_flags.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..afef08840df87a536450c6e5c5f8cfdba2238aae
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_flags.txt
    @@ -0,0 +1,132 @@
    +env GO111MODULE=on
    +
    +[short] skip
    +
    +# Arguments after the flag terminator should be ignored.
    +# If we pass '-- -test.v', we should not get verbose output
    +# *and* output from the test should not be echoed.
    +go test ./x -- -test.v
    +stdout '\Aok\s+example.com/x\s+[0-9.s]+\n\z'
    +! stderr .
    +
    +# For backward-compatibility with previous releases of the 'go' command,
    +# arguments that appear after unrecognized flags should not be treated
    +# as packages, even if they are unambiguously not arguments to flags.
    +# Even though ./x looks like a package path, the real package should be
    +# the implicit '.'.
    +! go test --answer=42 ./x
    +stdout '^FAIL\t. \[setup failed\]'
    +stderr '^# \.\nno Go files in '$PWD'$'
    +
    +# However, *flags* that appear after unrecognized flags should still be
    +# interpreted as flags, under the (possibly-erroneous) assumption that
    +# unrecognized flags are non-boolean.
    +
    +go test -v -x ./x -timeout 24h -boolflag=true foo -timeout 25h
    +stdout 'args: foo -timeout 25h'
    +stdout 'timeout: 24h0m0s$'  # -timeout is unambiguously not a flag, so the real flag wins.
    +
    +go test -v -x ./x -timeout 24h -boolflag foo -timeout 25h
    +stdout 'args: foo -test\.timeout=25h0m0s'  # For legacy reasons, '-timeout ' is erroneously rewritten to -test.timeout; see https://golang.org/issue/40763.
    +stdout 'timeout: 24h0m0s$'  # Actual flag wins.
    +
    +go test -v -x ./x -timeout 24h -stringflag foo -timeout 25h
    +stdout 'args: $'
    +stdout 'timeout: 25h0m0s$'  # Later flag wins.
    +
    +# An explicit '-outputdir=' argument should set test.outputdir
    +# to the 'go' command's working directory, not zero it out
    +# for the test binary.
    +go test -x -coverprofile=cover.out '-outputdir=' ./x
    +stderr '-test.outputdir=[^ ]'
    +exists ./cover.out
    +! exists ./x/cover.out
    +
    +# Test flags from GOFLAGS should be forwarded to the test binary,
    +# with the 'test.' prefix in the GOFLAGS entry...
    +env GOFLAGS='-test.timeout=24h0m0s -count=1'
    +go test -v -x ./x
    +stdout 'timeout: 24h0m0s$'
    +stderr '-test.count=1'
    +
    +# ...or without.
    +env GOFLAGS='-timeout=24h0m0s -count=1'
    +go test -v -x ./x
    +stdout 'timeout: 24h0m0s$'
    +stderr '-test.count=1'
    +
    +# Arguments from the command line should override GOFLAGS...
    +go test -v -x -timeout=25h0m0s ./x
    +stdout 'timeout: 25h0m0s$'
    +stderr '-test.count=1'
    +
    +# ...even if they use a different flag name.
    +go test -v -x -test.timeout=26h0m0s ./x
    +stdout 'timeout: 26h0m0s$'
    +stderr '-test\.timeout=26h0m0s'
    +! stderr 'timeout=24h0m0s'
    +stderr '-test.count=1'
    +
    +# Invalid flags should be reported exactly once.
    +! go test -covermode=walrus ./x
    +stderr -count=1 'invalid value "walrus" for flag -covermode: valid modes are .*$'
    +stderr '^usage: go test .*$'
    +stderr '^Run ''go help test'' and ''go help testflag'' for details.$'
    +
    +# Passing -help to the test binary should show flag help.
    +go test ./x -args -help
    +stdout 'usage_message'
    +
    +# -covermode, -coverpkg, and -coverprofile should imply -cover
    +go test -covermode=set ./x
    +stdout '\s+coverage:\s+'
    +
    +go test -coverpkg=encoding/binary ./x
    +stdout '\s+coverage:\s+'
    +
    +go test -coverprofile=cover.out ./x
    +stdout '\s+coverage:\s+'
    +exists ./cover.out
    +rm ./cover.out
    +
    +# -*profile and -trace flags should force output to the current working directory
    +# or -outputdir, not the directory containing the test.
    +
    +go test -memprofile=mem.out ./x
    +exists ./mem.out
    +rm ./mem.out
    +
    +go test -trace=trace.out ./x
    +exists ./trace.out
    +rm ./trace.out
    +
    +# Relative paths with -outputdir should be relative to the go command's working
    +# directory, not the directory containing the test.
    +mkdir profiles
    +go test -memprofile=mem.out -outputdir=./profiles ./x
    +exists ./profiles/mem.out
    +rm profiles
    +
    +-- go.mod --
    +module example.com
    +go 1.14
    +-- x/x_test.go --
    +package x
    +
    +import (
    +	"flag"
    +	"strings"
    +	"testing"
    +)
    +
    +var _ = flag.String("usage_message", "", "dummy flag to check usage message")
    +var boolflag = flag.Bool("boolflag", false, "ignored boolean flag")
    +var stringflag = flag.String("stringflag", "", "ignored string flag")
    +
    +func TestLogTimeout(t *testing.T) {
    +	t.Logf("timeout: %v", flag.Lookup("test.timeout").Value)
    +}
    +
    +func TestLogArgs(t *testing.T) {
    +	t.Logf("args: %s", strings.Join(flag.Args(), " "))
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_fullpath.txt b/go/src/cmd/go/testdata/script/test_fullpath.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8e015522381afb2c474f2143293a9248e1992378
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_fullpath.txt
    @@ -0,0 +1,21 @@
    +[short] skip
    +
    +# test with -fullpath
    +! go test ./x/... -fullpath
    +stdout '^ +.+/gopath/src/x/fullpath/fullpath_test.go:8: test failed'
    +# test without -fullpath
    +! go test ./x/...
    +stdout '^ +fullpath_test.go:8: test failed'
    +
    +-- go.mod --
    +module example
    +-- x/fullpath/fullpath_test.go --
    +package fullpath_test
    +
    +import (
    +	"testing"
    +)
    +
    +func TestFullPath(t *testing.T) {
    +	t.Error("test failed")
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_fuzz_modcache.txt b/go/src/cmd/go/testdata/script/test_fuzz_modcache.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c0f18ea3c073196dbc0cbae76597d7fff9d3966c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_fuzz_modcache.txt
    @@ -0,0 +1,58 @@
    +# This test demonstrates the fuzz corpus behavior for packages outside of the main module.
    +# (See https://golang.org/issue/48495.)
    +
    +[short] skip
    +
    +# Set -modcacherw so that the test behaves the same regardless of whether the
    +# module cache is writable. (For example, on some platforms it can always be
    +# written if the user is running as root.) At one point, a failing fuzz test
    +# in a writable module cache would corrupt module checksums in the cache.
    +env GOFLAGS=-modcacherw
    +
    +
    +# When the upstream module has no test corpus, running 'go test' should succeed,
    +# but 'go test -fuzz=.' should error out before running the test.
    +# (It should NOT corrupt the module cache by writing out new fuzz inputs,
    +# even if the cache is writable.)
    +
    +go get -t example.com/fuzzfail@v0.1.0
    +go test example.com/fuzzfail
    +
    +! go test -fuzz=. example.com/fuzzfail
    +! stdout .
    +stderr '^cannot use -fuzz flag on package outside the main module$'
    +
    +go mod verify
    +
    +
    +# If the module does include a test corpus, 'go test' (without '-fuzz') should
    +# load that corpus and run the fuzz tests against it, but 'go test -fuzz=.'
    +# should continue to be rejected.
    +
    +go get -t example.com/fuzzfail@v0.2.0
    +
    +! go test example.com/fuzzfail
    +stdout '^\s*fuzzfail_test\.go:7: oops:'
    +
    +! go test -fuzz=. example.com/fuzzfail
    +! stdout .
    +stderr '^cannot use -fuzz flag on package outside the main module$'
    +
    +go mod verify
    +
    +
    +# Packages in 'std' cannot be fuzzed when the corresponding GOROOT module is not
    +# the main module — either the failures would not be recorded or the behavior of
    +# the 'std' tests would change globally.
    +
    +! go test -fuzz . encoding/json
    +stderr '^cannot use -fuzz flag on package outside the main module$'
    +
    +! go test -fuzz . cmd/buildid
    +stderr '^cannot use -fuzz flag on package outside the main module$'
    +
    +
    +-- go.mod --
    +module example.com/m
    +
    +go 1.18
    diff --git a/go/src/cmd/go/testdata/script/test_generated_main.txt b/go/src/cmd/go/testdata/script/test_generated_main.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..2e991a5797f83c05550815f29c88519be3bb0366
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_generated_main.txt
    @@ -0,0 +1,34 @@
    +# Tests that the generated test main file has a generated code comment.
    +# This is needed by analyzers that access source files through 'go list'.
    +# Verifies golang.org/issue/31971.
    +# TODO(jayconrod): This test is brittle. We should write _testmain.go as
    +# a build action instead of with an ad-hoc WriteFile call
    +# in internal/test/test.go. Then we could just grep 'go get -n'.
    +go test x_test.go
    +
    +-- x_test.go --
    +package x
    +
    +import (
    +	"os"
    +	"path/filepath"
    +	"regexp"
    +	"testing"
    +)
    +
    +func Test(t *testing.T) {
    +	exePath, err := os.Executable()
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	testmainPath := filepath.Join(filepath.Dir(exePath), "_testmain.go")
    +	source, err := os.ReadFile(testmainPath)
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +	if matched, err := regexp.Match(`(?m)^// Code generated .* DO NOT EDIT\.$`, source); err != nil {
    +		t.Fatal(err)
    +	} else if !matched {
    +		t.Error("_testmain.go does not have generated code comment")
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_go111module_cache.txt b/go/src/cmd/go/testdata/script/test_go111module_cache.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..ca1de43a2b5dddbcb6d8fb3cf5cc0e95e6e358f8
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_go111module_cache.txt
    @@ -0,0 +1,15 @@
    +env GO111MODULE=on
    +go mod init foo
    +go test
    +stdout ^ok\s+foo
    +env GO111MODULE=off
    +go test
    +stdout ^ok\s+
    +! stdout ^ok\s+(cache)$
    +
    +-- main_test.go --
    +package main
    +
    +import "testing"
    +
    +func TestF(t *testing.T) {}
    diff --git a/go/src/cmd/go/testdata/script/test_goroot_PATH.txt b/go/src/cmd/go/testdata/script/test_goroot_PATH.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a6278ca749e6020aef49cc4db6b4dd2a9fc72406
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_goroot_PATH.txt
    @@ -0,0 +1,41 @@
    +# https://go.dev/issue/51473: to avoid the need for tests to rely on
    +# runtime.GOROOT, 'go test' should run the test with its own GOROOT/bin
    +# at the beginning of $PATH.
    +
    +[short] skip
    +
    +[!GOOS:plan9] env PATH=
    +[GOOS:plan9] env path=
    +go test .
    +
    +[!GOOS:plan9] env PATH=$WORK${/}bin
    +[GOOS:plan9] env path=$WORK${/}bin
    +go test .
    +
    +-- go.mod --
    +module example
    +
    +go 1.19
    +-- example_test.go --
    +package example
    +
    +import (
    +	"os"
    +	"os/exec"
    +	"path/filepath"
    +	"testing"
    +)
    +
    +func TestGoCommandExists(t *testing.T) {
    +	got, err := exec.LookPath("go")
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +
    +	want := filepath.Join(os.Getenv("GOROOT"), "bin", "go" + os.Getenv("GOEXE"))
    +	if got != want {
    +		t.Fatalf(`exec.LookPath("go") = %q; want %q`, got, want)
    +	}
    +}
    +-- $WORK/bin/README.txt --
    +This directory contains no executables.
    diff --git a/go/src/cmd/go/testdata/script/test_import_error_stack.txt b/go/src/cmd/go/testdata/script/test_import_error_stack.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6c60f3d2abe57564a9699e48a6afe42c4a611b10
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_import_error_stack.txt
    @@ -0,0 +1,31 @@
    +env GO111MODULE=off
    +! go test testdep/p1
    +stderr 'package testdep/p1 \(test\)\n\timports testdep/p2\n\timports testdep/p3: build constraints exclude all Go files ' # check for full import stack
    +! go vet testdep/p1
    +stderr 'package testdep/p1 \(test\)\n\timports testdep/p2\n\timports testdep/p3: build constraints exclude all Go files ' # check for full import stack
    +
    +env GO111MODULE=on
    +cd testdep
    +! go test testdep/p1
    +stderr 'package testdep/p1 \(test\)\n\timports testdep/p2\n\timports testdep/p3: build constraints exclude all Go files ' # check for full import stack
    +! go vet testdep/p1
    +stderr 'package testdep/p1 \(test\)\n\timports testdep/p2\n\timports testdep/p3: build constraints exclude all Go files ' # check for full import stack
    +
    +-- testdep/go.mod --
    +module testdep
    +
    +go 1.16
    +-- testdep/p1/p1.go --
    +package p1
    +-- testdep/p1/p1_test.go --
    +package p1
    +
    +import _ "testdep/p2"
    +-- testdep/p2/p2.go --
    +package p2
    +
    +import _ "testdep/p3"
    +-- testdep/p3/p3.go --
    +// +build ignore
    +
    +package ignored
    diff --git a/go/src/cmd/go/testdata/script/test_issue45477.txt b/go/src/cmd/go/testdata/script/test_issue45477.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f435b6a6f435d14eb5b646b6e02d6aecdcaf0517
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_issue45477.txt
    @@ -0,0 +1,12 @@
    +[short] skip  # links and runs a test binary
    +
    +go test -v .
    +
    +-- go.mod --
    +module example.com/pkg_test
    +
    +-- pkg.go --
    +package pkg_test
    +
    +-- pkg_test.go --
    +package pkg_test
    diff --git a/go/src/cmd/go/testdata/script/test_json.txt b/go/src/cmd/go/testdata/script/test_json.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6207c2efd43d711f87296211fe05503600d2b326
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_json.txt
    @@ -0,0 +1,80 @@
    +[compiler:gccgo] skip # gccgo does not have standard packages
    +[short] skip
    +
    +env GOCACHE=$WORK/tmp
    +
    +# Run go test -json on errors m/empty/pkg and m/skipper
    +# It would be nice to test that the output is interlaced
    +# but it seems to be impossible to do that in a short test
    +# that isn't also flaky. Just check that we get JSON output.
    +go test -json -short -v errors m/empty/pkg m/skipper
    +
    +# Check errors for run action
    +stdout '"Package":"errors"'
    +stdout '"Action":"start","Package":"errors"'
    +stdout '"Action":"run","Package":"errors"'
    +
    +# Check m/empty/pkg for output and skip actions
    +stdout '"Action":"start","Package":"m/empty/pkg"'
    +stdout '"Action":"output","Package":"m/empty/pkg","Output":".*no test files'
    +stdout '"Action":"skip","Package":"m/empty/pkg"'
    +
    +# Check skipper for output and skip actions
    +stdout '"Action":"start","Package":"m/skipper"'
    +stdout '"Action":"output","Package":"m/skipper","Test":"Test","Output":"--- SKIP:'
    +stdout '"Action":"skip","Package":"m/skipper","Test":"Test"'
    +
    +# Check that starts were ordered properly.
    +stdout '(?s)"Action":"start","Package":"errors".*"Action":"start","Package":"m/empty/pkg".*"Action":"start","Package":"m/skipper"'
    +
    +# Run go test -json on errors and check it's cached
    +go test -json -short -v errors
    +stdout '"Action":"output","Package":"errors","Output":".*\(cached\)'
    +
    +go test -json -bench=NONE -short -v errors
    +stdout '"Package":"errors"'
    +stdout '"Action":"run"'
    +
    +# Test running test2json
    +go test -o $WORK/tmp/errors.test$GOEXE -c errors
    +go tool test2json -p errors $WORK/tmp/errors.test$GOEXE -test.v -test.short
    +stdout '"Package":"errors"'
    +stdout '"Action":"run"'
    +stdout '\{"Action":"pass","Package":"errors"\}'
    +
    +-- go.mod --
    +module m
    +
    +go 1.16
    +-- skipper/skip_test.go --
    +package skipper
    +
    +import "testing"
    +
    +func Test(t *testing.T) {
    +	t.Skip("skipping")
    +}
    +-- empty/pkg/pkg.go --
    +package p
    +-- empty/pkgtest/pkg.go --
    +package p
    +-- empty/pkgtest/test_test.go --
    +package p
    +-- empty/pkgtestxtest/pkg.go --
    +package p
    +-- empty/pkgtestxtest/test_test.go --
    +package p
    +-- empty/pkgtestxtest/xtest_test.go --
    +package p_test
    +-- empty/pkgxtest/pkg.go --
    +package p
    +-- empty/pkgxtest/xtest_test.go --
    +package p_test
    +-- empty/test/test_test.go --
    +package p
    +-- empty/testxtest/test_test.go --
    +package p
    +-- empty/testxtest/xtest_test.go --
    +package p_test
    +-- empty/xtest/xtest_test.go --
    +package p_test
    diff --git a/go/src/cmd/go/testdata/script/test_json_build.txt b/go/src/cmd/go/testdata/script/test_json_build.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..2a572ace72336182914331834aaab7fbe41d3017
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_json_build.txt
    @@ -0,0 +1,123 @@
    +[short] skip
    +
    +env GODEBUG=gotestjsonbuildtext=0
    +
    +# There are several places where paths appear in JSON in regexps here.
    +# For the path separator we use (/|\\\\).
    +# Unfortunately, we can't just use ${/} because, while script test automatically
    +# escapes Windows-style \ in regexps, it doesn't know that it needs to escape
    +# them *again* for JSON. If we ever teach script test about matching JSON,
    +# we can probably fix this.
    +
    +# Test a build error directly in a test file.
    +! go test -json -o=$devnull ./builderror
    +stdout '"ImportPath":"m/builderror \[m/builderror\.test\]","Action":"build-output","Output":"# m/builderror \[m/builderror.test\]\\n"'
    +stdout '"ImportPath":"m/builderror \[m/builderror\.test\]","Action":"build-output","Output":"builderror(/|\\\\)main_test.go:3:11: undefined: y\\n"'
    +stdout '"ImportPath":"m/builderror \[m/builderror\.test\]","Action":"build-fail"'
    +stdout '"Action":"start","Package":"m/builderror"'
    +stdout '"Action":"output","Package":"m/builderror","Output":"FAIL\\tm/builderror \[build failed\]\\n"'
    +stdout '"Action":"fail","Package":"m/builderror","Elapsed":.*,"FailedBuild":"m/builderror \[m/builderror\.test\]"'
    +! stderr '.'
    +
    +# Test a build error in an imported package. Make sure it's attributed to the right package.
    +! go test -json -o=$devnull ./builderror2
    +stdout '"ImportPath":"m/builderror2/x","Action":"build-output","Output":"# m/builderror2/x\\n"'
    +stdout '"ImportPath":"m/builderror2/x","Action":"build-output","Output":"builderror2(/|\\\\)x(/|\\\\)main.go:3:11: undefined: y\\n"'
    +stdout '"ImportPath":"m/builderror2/x","Action":"build-fail"'
    +stdout '"Action":"start","Package":"m/builderror2"'
    +stdout '"Action":"output","Package":"m/builderror2","Output":"FAIL\\tm/builderror2 \[build failed\]\\n"'
    +stdout '"Action":"fail","Package":"m/builderror2","Elapsed":.*,"FailedBuild":"m/builderror2/x"'
    +! stderr '.'
    +
    +# Test a loading error in a test file
    +# TODO(#65335): ImportPath attribution is weird
    +! go test -json -o=$devnull ./loaderror
    +stdout '"ImportPath":"x","Action":"build-output","Output":"# m/loaderror\\n"'
    +stdout '"ImportPath":"x","Action":"build-output","Output":".*package x is not in std.*"'
    +stdout '"ImportPath":"x","Action":"build-fail"'
    +stdout '"Action":"start","Package":"m/loaderror"'
    +stdout '"Action":"output","Package":"m/loaderror","Output":"FAIL\\tm/loaderror \[setup failed\]\\n"'
    +stdout '"Action":"fail","Package":"m/loaderror","Elapsed":.*,"FailedBuild":"x"'
    +! stderr '.'
    +
    +# Test an import cycle loading error in a non test file. (#70820)
    +! go test -json -o=$devnull ./cycle/p
    +stdout '"ImportPath":"m/cycle/q","Action":"build-output","Output":"# m/cycle/p\\n"'
    +stdout '"ImportPath":"m/cycle/q","Action":"build-output","Output":"package m/cycle/p\\n"'
    +stdout '"ImportPath":"m/cycle/q","Action":"build-output","Output":"\\timports m/cycle/q from p.go\\n"'
    +stdout '"ImportPath":"m/cycle/q","Action":"build-output","Output":"\\timports m/cycle/q from q.go: import cycle not allowed\\n"'
    +stdout '"ImportPath":"m/cycle/q","Action":"build-fail"'
    +stdout '"Action":"start","Package":"m/cycle/p"'
    +stdout '"Action":"output","Package":"m/cycle/p","Output":"FAIL\\tm/cycle/p \[setup failed\]\\n"'
    +stdout '"Action":"fail","Package":"m/cycle/p","Elapsed":.*,"FailedBuild":"m/cycle/q"'
    +! stderr '.'
    +
    +# Test a vet error
    +! go test -json -o=$devnull ./veterror
    +stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"# m/veterror\\n"'
    +stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"# \[m/veterror\]\\n"'
    +stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"veterror(/|\\\\)main_test.go:9:21: fmt.Printf format %s reads arg #1, but call has 0 args\\n"'
    +stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-fail"'
    +stdout '"Action":"start","Package":"m/veterror"'
    +stdout '"Action":"output","Package":"m/veterror","Output":"FAIL\\tm/veterror \[build failed\]\\n"'
    +stdout '"Action":"fail","Package":"m/veterror","Elapsed":.*,"FailedBuild":"m/veterror \[m/veterror.test\]"'
    +! stderr '.'
    +
    +# Test that the GODEBUG fallback works.
    +env GODEBUG=gotestjsonbuildtext=1
    +! go test -json -o=$devnull ./builderror
    +stderr '# m/builderror \[m/builderror.test\]\n'
    +stderr 'builderror'${/}'main_test.go:3:11: undefined: y\n'
    +stdout '"Action":"start","Package":"m/builderror"'
    +stdout '"Action":"output","Package":"m/builderror","Output":"FAIL\\tm/builderror \[build failed\]\\n"'
    +stdout '"Action":"fail","Package":"m/builderror","Elapsed":[0-9.]+\}'
    +# FailedBuild should NOT appear in the output in this mode.
    +! stdout '"FailedBuild"'
    +
    +-- go.mod --
    +module m
    +go 1.21
    +-- builderror/main_test.go --
    +package builderror
    +
    +const x = y
    +-- builderror2/x/main.go --
    +package x
    +
    +const x = y
    +-- builderror2/main_test.go --
    +package builderror2
    +
    +import _ "m/builderror2/x"
    +-- loaderror/main_test.go --
    +// A bad import causes a "[setup failed]" message from cmd/go because
    +// it fails in package graph setup, before it can even get to the
    +// build.
    +//
    +// "[setup failed]" can also occur with various low-level failures in
    +// cmd/go, like failing to create a temporary directory.
    +
    +package loaderror
    +
    +import _ "x"
    +-- veterror/main_test.go --
    +package veterror
    +
    +import (
    +        "fmt"
    +        "testing"
    +)
    +
    +func TestVetError(t *testing.T) {
    +        fmt.Printf("%s")
    +}
    +-- cycle/p/p.go --
    +package p
    +
    +import "m/cycle/q"
    +-- cycle/q/q.go --
    +package q
    +
    +import (
    +	"m/cycle/q"
    +)
    diff --git a/go/src/cmd/go/testdata/script/test_json_exit.txt b/go/src/cmd/go/testdata/script/test_json_exit.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..dc7ffb06cfc83b7d7742a5b48d0774e753893fee
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_json_exit.txt
    @@ -0,0 +1,102 @@
    +[short] skip
    +
    +go test -c -o mainpanic.exe ./mainpanic &
    +go test -c -o mainexit0.exe ./mainexit0 &
    +go test -c -o testpanic.exe ./testpanic &
    +go test -c -o testbgpanic.exe ./testbgpanic &
    +wait
    +
    +# Test binaries that panic in TestMain should be marked as failing.
    +
    +! go test -json ./mainpanic
    +stdout '"Action":"fail"'
    +! stdout '"Action":"pass"'
    +
    +! go tool test2json ./mainpanic.exe
    +stdout '"Action":"fail"'
    +! stdout '"Action":"pass"'
    +
    +# Test binaries that exit with status 0 should be marked as passing.
    +
    +go test -json ./mainexit0
    +stdout '"Action":"pass"'
    +! stdout '"Action":"fail"'
    +
    +go tool test2json ./mainexit0.exe
    +stdout '"Action":"pass"'
    +! stdout '"Action":"fail"'
    +
    +# Test functions that panic should never be marked as passing
    +# (https://golang.org/issue/40132).
    +
    +! go test -json ./testpanic
    +stdout '"Action":"fail"'
    +! stdout '"Action":"pass"'
    +
    +! go tool test2json ./testpanic.exe -test.v
    +stdout '"Action":"fail"'
    +! stdout '"Action":"pass"'
    +
    +! go tool test2json ./testpanic.exe
    +stdout '"Action":"fail"'
    +! stdout '"Action":"pass"'
    +
    +# Tests that panic in a background goroutine should be marked as failing.
    +
    +! go test -json ./testbgpanic
    +stdout '"Action":"fail"'
    +! stdout '"Action":"pass"'
    +
    +! go tool test2json ./testbgpanic.exe -test.v
    +stdout '"Action":"fail"'
    +! stdout '"Action":"pass"'
    +
    +! go tool test2json ./testbgpanic.exe
    +stdout '"Action":"fail"'
    +! stdout '"Action":"pass"'
    +
    +-- go.mod --
    +module m
    +go 1.14
    +-- mainpanic/mainpanic_test.go --
    +package mainpanic_test
    +
    +import "testing"
    +
    +func TestMain(m *testing.M) {
    +	panic("haha no")
    +}
    +-- mainexit0/mainexit0_test.go --
    +package mainexit0_test
    +
    +import (
    +	"fmt"
    +	"os"
    +	"testing"
    +)
    +
    +func TestMain(m *testing.M) {
    +	fmt.Println("nothing to do")
    +	os.Exit(0)
    +}
    +-- testpanic/testpanic_test.go --
    +package testpanic_test
    +
    +import "testing"
    +
    +func TestPanic(*testing.T) {
    +	panic("haha no")
    +}
    +-- testbgpanic/testbgpanic_test.go --
    +package testbgpanic_test
    +
    +import "testing"
    +
    +func TestPanicInBackground(*testing.T) {
    +	c := make(chan struct{})
    +	go func() {
    +		panic("haha no")
    +		close(c)
    +	}()
    +	<-c
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_json_interleaved.txt b/go/src/cmd/go/testdata/script/test_json_interleaved.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e2d349e3fbca3fa9d9668f6f2e3f9e49a5f473dd
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_json_interleaved.txt
    @@ -0,0 +1,27 @@
    +# Regression test for https://golang.org/issue/40657: output from the main test
    +# function should be attributed correctly even if interleaved with the PAUSE
    +# line for a new parallel subtest.
    +
    +[short] skip
    +
    +go test -json
    +stdout '"Test":"TestWeirdTiming","Output":"[^"]* logging to outer again\\n"'
    +
    +-- go.mod --
    +module example.com
    +go 1.15
    +-- main_test.go --
    +package main
    +
    +import (
    +	"testing"
    +)
    +
    +func TestWeirdTiming(outer *testing.T) {
    +	outer.Run("pauser", func(pauser *testing.T) {
    +		outer.Logf("logging to outer")
    +		pauser.Parallel()
    +	})
    +
    +	outer.Logf("logging to outer again")
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_json_issue35169.txt b/go/src/cmd/go/testdata/script/test_json_issue35169.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..fdb57556bdb8fa89be636f3747893e0f4ca665a9
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_json_issue35169.txt
    @@ -0,0 +1,28 @@
    +! go test -json .
    +
    +	# We should see only JSON output on stdout, no non-JSON.
    +	# To simplify the check, we just look for non-curly-braces, since
    +	# every JSON entry has them and they're unlikely to occur
    +	# in other error messages.
    +! stdout '^[^{]'
    +! stdout '[^}]\n$'
    +
    +	# Since the only test we requested failed to build, we should
    +	# not see any "pass" actions in the JSON stream.
    +! stdout '\{.*"Action":"pass".*\}'
    +
    +	# TODO(#62067): emit this as a build event instead of a test event.
    +stdout '\{.*"Action":"output","Package":"example","Output":"FAIL\\texample \[build failed\]\\n"\}'
    +stdout '\{.*"Action":"fail","Package":"example",.*\}'
    +
    +-- go.mod --
    +module example
    +go 1.19
    +-- example.go --
    +package example
    +
    +This is not valid Go source.
    +-- example_test.go --
    +package  example
    +
    +func Test(*testing.T) {}
    diff --git a/go/src/cmd/go/testdata/script/test_json_panic_exit.txt b/go/src/cmd/go/testdata/script/test_json_panic_exit.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..5f1d03329f67d06ce63bc4d6982d39a5aa98cc99
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_json_panic_exit.txt
    @@ -0,0 +1,69 @@
    +# Verifies golang.org/issue/37555.
    +
    +[short] skip
    +
    +# 'go test -json' should say a test passes if it says it passes.
    +go test -json ./pass
    +stdout '"Action":"pass","Package":"[^"]*","Elapsed":[^"]*}\n\z'
    +! stdout '"Test":.*\n\z'
    +
    +# 'go test -json' should say a test passes if it exits 0 and prints nothing.
    +# TODO(golang.org/issue/29062): this should fail in the future.
    +go test -json ./exit0main
    +stdout '"Action":"pass".*\n\z'
    +! stdout '"Test":.*\n\z'
    +
    +# 'go test -json' should say a test fails if it exits 1 and prints nothing.
    +! go test -json ./exit1main
    +stdout '"Action":"fail".*\n\z'
    +! stdout '"Test":.*\n\z'
    +
    +# 'go test -json' should say a test fails if it panics.
    +! go test -json ./panic
    +stdout '"Action":"fail".*\n\z'
    +! stdout '"Test":.*\n\z'
    +
    +-- go.mod --
    +module example.com/test
    +
    +go 1.14
    +
    +-- pass/pass_test.go --
    +package pass_test
    +
    +import "testing"
    +
    +func TestPass(t *testing.T) {}
    +
    +-- exit0main/exit0main_test.go --
    +package exit0_test
    +
    +import (
    +	"os"
    +	"testing"
    +)
    +
    +func TestMain(m *testing.M) {
    +	os.Exit(0)
    +}
    +
    +-- exit1main/exit1main_test.go --
    +package exit1_test
    +
    +import (
    +	"os"
    +	"testing"
    +)
    +
    +func TestMain(m *testing.M) {
    +	os.Exit(1)
    +}
    +
    +-- panic/panic_test.go --
    +package panic_test
    +
    +import "testing"
    +
    +func TestPanic(t *testing.T) {
    +	panic("oh no")
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_json_prints.txt b/go/src/cmd/go/testdata/script/test_json_prints.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f979998068bcd125993ebd23639bd2db5f4a3f52
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_json_prints.txt
    @@ -0,0 +1,48 @@
    +go test -json
    +
    +stdout '"Action":"output","Package":"p","Output":"M1"}'
    +stdout '"Action":"output","Package":"p","Test":"Test","Output":"=== RUN   Test\\n"}'
    +stdout '"Action":"output","Package":"p","Test":"Test","Output":"T1"}'
    +stdout '"Action":"output","Package":"p","Test":"Test/Sub1","Output":"=== RUN   Test/Sub1\\n"}'
    +stdout '"Action":"output","Package":"p","Test":"Test/Sub1","Output":"Sub1    x_test.go:19: SubLog1\\n"}'
    +stdout '"Action":"output","Package":"p","Test":"Test/Sub1","Output":"Sub2"}'
    +stdout '"Action":"output","Package":"p","Test":"Test/Sub1","Output":"--- PASS: Test/Sub1 \([\d.]+s\)\\n"}'
    +stdout '"Action":"pass","Package":"p","Test":"Test/Sub1","Elapsed"'
    +stdout '"Action":"output","Package":"p","Test":"Test/Sub3","Output":"foo bar"}'
    +stdout '"Action":"output","Package":"p","Test":"Test/Sub3","Output":"baz\\n"}'
    +stdout '"Action":"output","Package":"p","Test":"Test","Output":"T2"}'
    +stdout '"Action":"output","Package":"p","Test":"Test","Output":"--- PASS: Test \([\d.]+s\)\\n"}'
    +stdout '"Action":"pass","Package":"p","Test":"Test","Elapsed"'
    +stdout '"Action":"output","Package":"p","Output":"M2ok  \\tp\\t[\d.]+s\\n"}'
    +stdout '"Action":"pass","Package":"p","Elapsed"'
    +
    +-- go.mod --
    +module p
    +
    +-- x_test.go --
    +package p
    +
    +import (
    +	"os"
    +	"testing"
    +)
    +
    +func TestMain(m *testing.M) {
    +	print("M1")
    +	code := m.Run()
    +	print("M2")
    +	os.Exit(code)
    +}
    +
    +func Test(t *testing.T) {
    +	print("T1")
    +	t.Run("Sub1", func(t *testing.T) {
    +		print("Sub1")
    +		t.Log("SubLog1")
    +		print("Sub2")
    +	})
    +	t.Run("Sub3", func(t *testing.T) {
    +		print("\x16foo bar\x16baz\n")
    +	})
    +	print("T2")
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_json_timeout.txt b/go/src/cmd/go/testdata/script/test_json_timeout.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..0a2329b9f3528bb3c152fb3bf2120a557bb594fb
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_json_timeout.txt
    @@ -0,0 +1,19 @@
    +! go test -json -timeout=1ms
    +
    +stdout '"Action":"output","Package":"p","Output":"FAIL\\tp\\t'
    +stdout '"Action":"fail","Package":"p","Elapsed":'
    +
    +-- go.mod --
    +module p
    +
    +-- x_test.go --
    +package p
    +
    +import (
    +	"testing"
    +	"time"
    +)
    +
    +func Test(t *testing.T) {
    +	time.Sleep(1*time.Hour)
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_main.txt b/go/src/cmd/go/testdata/script/test_main.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..25d02e4465cb4c72d5028927dc74af574f09da54
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_main.txt
    @@ -0,0 +1,92 @@
    +# Test TestMain
    +go test standalone_main_normal_test.go
    +! stdout '^ok.*\[no tests to run\]'
    +! stderr '^ok.*\[no tests to run\]'
    +stdout '^ok'
    +
    +# Test TestMain sees testing flags
    +go test standalone_testmain_flag_test.go
    +stdout '^ok.*\[no tests to run\]'
    +
    +# Test TestMain with wrong signature (Issue #22388)
    +! go test standalone_main_wrong_test.go
    +stderr 'wrong signature for TestMain, must be: func TestMain\(m \*testing.M\)'
    +
    +# Test TestMain does not call os.Exit (Issue #34129)
    +! go test standalone_testmain_not_call_os_exit_test.go
    +! stdout '^ok'
    +
    +-- standalone_main_normal_test.go --
    +// Copyright 2017 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package standalone_main_normal_test
    +
    +import "testing"
    +
    +func TestMain(t *testing.T) {
    +}
    +-- standalone_main_wrong_test.go --
    +// Copyright 2017 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package standalone_main_wrong_test
    +
    +import "testing"
    +
    +func TestMain(m *testing.Main) {
    +}
    +-- standalone_testmain_flag_test.go --
    +// Copyright 2019 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package standalone_testmain_flag_test
    +
    +import (
    +	"flag"
    +	"fmt"
    +	"os"
    +	"testing"
    +)
    +
    +func TestMain(m *testing.M) {
    +	// A TestMain should be able to access testing flags if it calls
    +	// flag.Parse without needing to use testing.Init.
    +	flag.Parse()
    +	found := false
    +	flag.VisitAll(func(f *flag.Flag) {
    +		if f.Name == "test.count" {
    +			found = true
    +		}
    +	})
    +	if !found {
    +		fmt.Println("testing flags not registered")
    +		os.Exit(1)
    +	}
    +	os.Exit(m.Run())
    +}
    +-- standalone_testmain_not_call_os_exit_test.go --
    +// Copyright 2020 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +package standalone_testmain_not_call_os_exit_test
    +
    +import (
    +	"testing"
    +)
    +
    +func TestWillFail(t *testing.T) {
    +	t.Error("this test will fail.")
    +}
    +
    +func TestMain(m *testing.M) {
    +	defer func() {
    +		recover()
    +	}()
    +	exit := m.Run()
    +	panic(exit)
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_main_archive.txt b/go/src/cmd/go/testdata/script/test_main_archive.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..410d923d2378d5fff899a65cff48bb13f00f066c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_main_archive.txt
    @@ -0,0 +1,32 @@
    +env GO111MODULE=off
    +
    +# Test that a main_test of 'package main' imports the package,
    +# not the installed binary.
    +
    +[short] skip
    +
    +env GOBIN=$WORK/bin
    +go test main_test
    +go install main_test
    +
    +go list -f '{{.Stale}}' main_test
    +stdout false
    +
    +go test main_test
    +
    +-- main_test/m.go --
    +package main
    +
    +func F()    {}
    +func main() {}
    +-- main_test/m_test.go --
    +package main_test
    +
    +import (
    +	. "main_test"
    +	"testing"
    +)
    +
    +func Test1(t *testing.T) {
    +	F()
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_main_compiler_flags.txt b/go/src/cmd/go/testdata/script/test_main_compiler_flags.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e207ecae16ac92905ac977cea8df94e1db0385e8
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_main_compiler_flags.txt
    @@ -0,0 +1,22 @@
    +# This is a script test conversion of TestPackageMainTestCompilerFlags
    +# originally added in CL 86265, which fixed #23180.
    +# Test that we don't pass the package name 'main' to -p when building the
    +# test package for a main package.
    +
    +go test -c -n p1
    +# should not have run compile -p main p1.go
    +! stdout '([\\/]compile|gccgo).* (-p main|-fgo-pkgpath=main).*p1\.go'
    +! stderr '([\\/]compile|gccgo).* (-p main|-fgo-pkgpath=main).*p1\.go'
    +# should have run compile -p p1 p1.go
    +stderr '([\\/]compile|gccgo).* (-p p1|-fgo-pkgpath=p1).*p1\.go'
    +
    +-- go.mod --
    +module p1
    +-- p1.go --
    +package main
    +-- p1_test.go --
    +package main
    +
    +import "testing"
    +
    +func Test(t *testing.T){}
    diff --git a/go/src/cmd/go/testdata/script/test_main_panic.txt b/go/src/cmd/go/testdata/script/test_main_panic.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..45887c5c733a18886598f76f0c070025e221d7a6
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_main_panic.txt
    @@ -0,0 +1,30 @@
    +[short] skip
    +[!race] skip
    +
    +! go test -v -race main_panic/testmain_parallel_sub_panic_test.go
    +! stdout 'DATA RACE'
    +-- main_panic/testmain_parallel_sub_panic_test.go --
    +package testmain_parallel_sub_panic_test
    +
    +import "testing"
    +
    +func setup()    { println("setup()") }
    +func teardown() { println("teardown()") }
    +func TestA(t *testing.T) {
    +	t.Run("1", func(t *testing.T) {
    +		t.Run("1", func(t *testing.T) {
    +			t.Parallel()
    +			panic("A/1/1 panics")
    +		})
    +		t.Run("2", func(t *testing.T) {
    +			t.Parallel()
    +			println("A/1/2 is ok")
    +		})
    +	})
    +}
    +
    +func TestMain(m *testing.M) {
    +	setup()
    +	defer teardown()
    +	m.Run()
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_main_twice.txt b/go/src/cmd/go/testdata/script/test_main_twice.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f32d4fc3b528c8a8a8f3ac1bf2ca1ab849898c52
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_main_twice.txt
    @@ -0,0 +1,27 @@
    +[short] skip
    +
    +env GOCACHE=$WORK/tmp
    +go test -v multimain
    +stdout -count=2 notwithstanding # check tests ran twice
    +
    +-- go.mod --
    +module multimain
    +
    +go 1.16
    +-- multimain_test.go --
    +package multimain_test
    +
    +import "testing"
    +
    +func TestMain(m *testing.M) {
    +	// Some users run m.Run multiple times, changing
    +	// some kind of global state between runs.
    +	// This used to work so I guess now it has to keep working.
    +	// See golang.org/issue/23129.
    +	m.Run()
    +	m.Run()
    +}
    +
    +func Test(t *testing.T) {
    +	t.Log("notwithstanding")
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_match_benchmark_labels.txt b/go/src/cmd/go/testdata/script/test_match_benchmark_labels.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..13c4007d7f4b02bd30f4d71b7a9d4802f15c1a6c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_benchmark_labels.txt
    @@ -0,0 +1,18 @@
    +# Benchmark labels, file outside gopath
    +# TODO(matloob): This test was called TestBenchmarkLabelsOutsideGOPATH
    +# why "OutsideGOPATH"? Does the go command need to be run outside GOPATH?
    +# Do the files need to exist outside GOPATH?
    +cp $GOPATH/src/standalone_benchmark_test.go $WORK/tmp/standalone_benchmark_test.go
    +go test -run '^$' -bench . $WORK/tmp/standalone_benchmark_test.go
    +stdout '^goos: '$GOOS
    +stdout '^goarch: '$GOARCH
    +! stdout '^pkg:'
    +! stderr '^pkg:'
    +
    +-- standalone_benchmark_test.go --
    +package standalone_benchmark
    +
    +import "testing"
    +
    +func Benchmark(b *testing.B) {
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_match_no_benchmarks.txt b/go/src/cmd/go/testdata/script/test_match_no_benchmarks.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..30f4be8a84b1ede46e274fc277287fd70876156f
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_no_benchmarks.txt
    @@ -0,0 +1,13 @@
    +# Matches no benchmarks
    +go test -run '^$' -bench ThisWillNotMatch standalone_benchmark_test.go
    +! stdout '^ok.*\[no tests to run\]'
    +! stderr '^ok.*\[no tests to run\]'
    +stdout '^ok'
    +
    +-- standalone_benchmark_test.go --
    +package standalone_benchmark
    +
    +import "testing"
    +
    +func Benchmark(b *testing.B) {
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_match_no_subtests.txt b/go/src/cmd/go/testdata/script/test_match_no_subtests.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..7abb1eb9b66789a7fc009a43ea32df01a3e1ae3f
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_no_subtests.txt
    @@ -0,0 +1,12 @@
    +# The subtests don't match
    +go test -run Test/ThisWillNotMatch standalone_sub_test.go
    +stdout '^ok.*\[no tests to run\]'
    +
    +-- standalone_sub_test.go --
    +package standalone_sub_test
    +
    +import "testing"
    +
    +func Test(t *testing.T) {
    +	t.Run("Sub", func(t *testing.T) {})
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_match_no_subtests_failure.txt b/go/src/cmd/go/testdata/script/test_match_no_subtests_failure.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b3c5b92f5eadd50c83295a20d0642cab6b4a5cab
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_no_subtests_failure.txt
    @@ -0,0 +1,15 @@
    +# Matches no subtests, but parent test still fails
    +! go test -run TestThatFails/ThisWillNotMatch standalone_fail_sub_test.go
    +! stdout '^ok.*\[no tests to run\]'
    +! stderr '^ok.*\[no tests to run\]'
    +stdout 'FAIL'
    +
    +-- standalone_fail_sub_test.go --
    +package standalone_fail_sub_test
    +
    +import "testing"
    +
    +func TestThatFails(t *testing.T) {
    +	t.Run("Sub", func(t *testing.T) {})
    +	t.Fail()
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_match_no_subtests_parallel.txt b/go/src/cmd/go/testdata/script/test_match_no_subtests_parallel.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..11c734c4c3fe71cab0655fbf3140a18d6da6f1ec
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_no_subtests_parallel.txt
    @@ -0,0 +1,19 @@
    +# Matches no subtests, parallel
    +go test -run Test/Sub/ThisWillNotMatch standalone_parallel_sub_test.go
    +stdout '^ok.*\[no tests to run\]'
    +
    +-- standalone_parallel_sub_test.go --
    +package standalone_parallel_sub_test
    +
    +import "testing"
    +
    +func Test(t *testing.T) {
    +	ch := make(chan bool, 1)
    +	t.Run("Sub", func(t *testing.T) {
    +		t.Parallel()
    +		<-ch
    +		t.Run("Nested", func(t *testing.T) {})
    +	})
    +	// Ensures that Sub will finish after its t.Run call already returned.
    +	ch <- true
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_match_no_tests.txt b/go/src/cmd/go/testdata/script/test_match_no_tests.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..1ad2097848faecf85fe9ee4b9771c0722909311f
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_no_tests.txt
    @@ -0,0 +1,11 @@
    +# Matches no tests
    +go test -run ThisWillNotMatch standalone_test.go
    +stdout '^ok.*\[no tests to run\]'
    +
    +-- standalone_test.go --
    +package standalone_test
    +
    +import "testing"
    +
    +func Test(t *testing.T) {
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_match_no_tests_build_failure.txt b/go/src/cmd/go/testdata/script/test_match_no_tests_build_failure.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e1c96438c85793ab9527d0c2e00f2f1ba8c1f705
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_no_tests_build_failure.txt
    @@ -0,0 +1,19 @@
    +# Test that when there's a build failure and a -run flag that doesn't match,
    +# that the error for not matching tests does not override the error for
    +# the build failure.
    +
    +! go test -run ThisWillNotMatch syntaxerror
    +! stderr '(?m)^ok.*\[no tests to run\]'
    +stdout 'FAIL'
    +
    +-- go.mod --
    +module syntaxerror
    +
    +go 1.16
    +-- x.go --
    +package p
    +-- x_test.go --
    +package p
    +
    +func f() (x.y, z int) {
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_match_no_tests_with_subtests.txt b/go/src/cmd/go/testdata/script/test_match_no_tests_with_subtests.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..0d9491861e1b976ed5090b553f2dccf59f44468f
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_no_tests_with_subtests.txt
    @@ -0,0 +1,12 @@
    +# Matches no tests with subtests
    +go test -run ThisWillNotMatch standalone_sub_test.go
    +stdout '^ok.*\[no tests to run\]'
    +
    +-- standalone_sub_test.go --
    +package standalone_sub_test
    +
    +import "testing"
    +
    +func Test(t *testing.T) {
    +	t.Run("Sub", func(t *testing.T) {})
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_match_only_benchmarks.txt b/go/src/cmd/go/testdata/script/test_match_only_benchmarks.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..5dfb96eae234bfdcf9707d538b1a9821de9bb973
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_only_benchmarks.txt
    @@ -0,0 +1,13 @@
    +# Matches only benchmarks
    +go test -run '^$' -bench . standalone_benchmark_test.go
    +! stdout '^ok.*\[no tests to run\]'
    +! stderr '^ok.*\[no tests to run\]'
    +stdout '^ok'
    +
    +-- standalone_benchmark_test.go --
    +package standalone_benchmark
    +
    +import "testing"
    +
    +func Benchmark(b *testing.B) {
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_match_only_example.txt b/go/src/cmd/go/testdata/script/test_match_only_example.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e35e69c42b43d19e05ba689d35c1066beffe1fc6
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_only_example.txt
    @@ -0,0 +1,31 @@
    +[short] skip
    +
    +# Check that it's okay for test pattern to match only examples.
    +go test -run Example example1_test.go
    +! stderr '^ok.*\[no tests to run\]'
    +stdout '^ok'
    +
    +-- example1_test.go --
    +// Copyright 2013 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Make sure that go test runs Example_z before Example_a, preserving source order.
    +
    +package p
    +
    +import "fmt"
    +
    +var n int
    +
    +func Example_z() {
    +	n++
    +	fmt.Println(n)
    +	// Output: 1
    +}
    +
    +func Example_a() {
    +	n++
    +	fmt.Println(n)
    +	// Output: 2
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_match_only_subtests.txt b/go/src/cmd/go/testdata/script/test_match_only_subtests.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..beea8953ca4d05a7f26922d79bd66b87a48406f1
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_only_subtests.txt
    @@ -0,0 +1,14 @@
    +# Matches only subtests
    +go test -run Test/Sub standalone_sub_test.go
    +! stdout '^ok.*\[no tests to run\]'
    +! stderr '^ok.*\[no tests to run\]'
    +stdout '^ok'
    +
    +-- standalone_sub_test.go --
    +package standalone_sub_test
    +
    +import "testing"
    +
    +func Test(t *testing.T) {
    +	t.Run("Sub", func(t *testing.T) {})
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_match_only_subtests_parallel.txt b/go/src/cmd/go/testdata/script/test_match_only_subtests_parallel.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..11872c28fd0541697f5c9460dc167102a976e12e
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_only_subtests_parallel.txt
    @@ -0,0 +1,21 @@
    +# Matches only subtests, parallel
    +go test -run Test/Sub/Nested standalone_parallel_sub_test.go
    +! stdout '^ok.*\[no tests to run\]'
    +! stderr '^ok.*\[no tests to run\]'
    +stdout '^ok'
    +
    +-- standalone_parallel_sub_test.go --
    +package standalone_parallel_sub_test
    +
    +import "testing"
    +
    +func Test(t *testing.T) {
    +	ch := make(chan bool, 1)
    +	t.Run("Sub", func(t *testing.T) {
    +		t.Parallel()
    +		<-ch
    +		t.Run("Nested", func(t *testing.T) {})
    +	})
    +	// Ensures that Sub will finish after its t.Run call already returned.
    +	ch <- true
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_match_only_tests.txt b/go/src/cmd/go/testdata/script/test_match_only_tests.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..9185793201fa491c205a5582d485b4217678f98c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_match_only_tests.txt
    @@ -0,0 +1,13 @@
    +# Matches only tests
    +go test -run Test standalone_test.go
    +! stdout '^ok.*\[no tests to run\]'
    +! stderr '^ok.*\[no tests to run\]'
    +stdout '^ok'
    +
    +-- standalone_test.go --
    +package standalone_test
    +
    +import "testing"
    +
    +func Test(t *testing.T) {
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/test_minus_n.txt b/go/src/cmd/go/testdata/script/test_minus_n.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..9900dbca0b88f4c66fa6ca21f86a1668e60643a4
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_minus_n.txt
    @@ -0,0 +1,14 @@
    +# The intent here is to verify that 'go test -n' works without crashing.
    +# Any test will do.
    +
    +go test -n x_test.go
    +
    +-- x_test.go --
    +package x_test
    +
    +import (
    +	"testing"
    +)
    +
    +func TestEmpty(t *testing.T) {
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_multivcs.txt b/go/src/cmd/go/testdata/script/test_multivcs.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..538cbf700b458531239dd3658ce48326b08bd885
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_multivcs.txt
    @@ -0,0 +1,54 @@
    +# To avoid VCS injection attacks, we should not accept multiple different VCS metadata
    +# folders within a single module (either in the same directory, or nested in different
    +# directories.)
    +#
    +# This behavior should be disabled by setting the allowmultiplevcs GODEBUG.
    +
    +[short] skip
    +[!git] skip
    +
    +cd samedir
    +
    +exec git init .
    +
    +# Without explicitly requesting buildvcs, the go command should silently continue
    +# without determining the correct VCS.
    +go test -c -o $devnull .
    +
    +# If buildvcs is explicitly requested, we expect the go command to fail
    +! go test -buildvcs -c -o $devnull .
    +stderr '^error obtaining VCS status: multiple VCS detected:'
    +
    +env GODEBUG=allowmultiplevcs=1
    +go test -buildvcs -c -o $devnull .
    +
    +env GODEBUG=
    +cd ../nested
    +exec git init .
    +# cd a
    +go test -c -o $devnull ./a
    +! go test -buildvcs -c -o $devnull ./a
    +stderr '^error obtaining VCS status: multiple VCS detected:'
    +# allowmultiplevcs doesn't disable the check that the current directory, package, and
    +# module are in the same repository.
    +env GODEBUG=allowmultiplevcs=1
    +! go test -buildvcs -c -o $devnull ./a
    +stderr '^error obtaining VCS status: main package is in repository'
    +
    +-- samedir/go.mod --
    +module example
    +
    +go 1.18
    +-- samedir/example.go --
    +package main
    +-- samedir/.bzr/test --
    +hello
    +
    +-- nested/go.mod --
    +module example
    +
    +go 1.18
    +-- nested/a/example.go --
    +package main
    +-- nested/a/.bzr/test --
    +hello
    diff --git a/go/src/cmd/go/testdata/script/test_n_cover_std.txt b/go/src/cmd/go/testdata/script/test_n_cover_std.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..77b92df37fd1b59edd534b8781346e9230c20619
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_n_cover_std.txt
    @@ -0,0 +1,7 @@
    +# Issue 67953: test to make sure that the go commands static coverage
    +# meta-data handling code handles pseudo-packages (ex: "unsafe") properly.
    +
    +[short] skip
    +
    +cd $GOROOT/src
    +go test -vet=off -p=1 -n -coverpkg=internal/coverage/decodecounter internal/coverage/decodecounter sync unsafe
    diff --git a/go/src/cmd/go/testdata/script/test_no_run_example.txt b/go/src/cmd/go/testdata/script/test_no_run_example.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..53ac755902fb471035f480d9b478d011d7b1909c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_no_run_example.txt
    @@ -0,0 +1,30 @@
    +go test -v norunexample
    +stdout 'File with non-runnable example was built.'
    +
    +-- go.mod --
    +module norunexample
    +
    +go 1.16
    +-- example_test.go --
    +package pkg_test
    +
    +import "os"
    +
    +func init() {
    +	os.Stdout.Write([]byte("File with non-runnable example was built.\n"))
    +}
    +
    +func Example_test() {
    +	// This test will not be run, it has no "Output:" comment.
    +}
    +-- test_test.go --
    +package pkg
    +
    +import (
    +	"os"
    +	"testing"
    +)
    +
    +func TestBuilt(t *testing.T) {
    +	os.Stdout.Write([]byte("A normal test was executed.\n"))
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_no_tests.txt b/go/src/cmd/go/testdata/script/test_no_tests.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..2d624d1da6bb61db145abf9e05567d676606f22d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_no_tests.txt
    @@ -0,0 +1,15 @@
    +# Tests issue #26242
    +
    +go test testnorun
    +stdout 'testnorun\t\[no test files\]'
    +
    +-- go.mod --
    +module testnorun
    +
    +go 1.16
    +-- p.go --
    +package p
    +
    +func init() {
    +	panic("go test must not link and run test binaries without tests")
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_overlay.txt b/go/src/cmd/go/testdata/script/test_overlay.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b6bdc116e62315b09e0640bf45d6621b14d5da97
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_overlay.txt
    @@ -0,0 +1,24 @@
    +[short] skip
    +
    +cd $WORK/gopath/src/foo
    +go test -list=. -overlay=overlay.json .
    +stdout 'TestBar'
    +
    +-- go.mod --
    +module test.pkg
    +-- foo/foo_test.go --
    +package foo
    +
    +import "testing"
    +
    +func TestFoo(t *testing.T) { }
    +-- tmp/bar_test.go --
    +package foo
    +
    +import "testing"
    +
    +func TestBar(t *testing.T) {
    +	t.Fatal("dummy failure")
    +}
    +-- foo/overlay.json --
    +{"Replace": {"foo_test.go": "../tmp/bar_test.go"}}
    diff --git a/go/src/cmd/go/testdata/script/test_parallel_number.txt b/go/src/cmd/go/testdata/script/test_parallel_number.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..4eb97945ef68f0dc671e7119d247806f6fbab41c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_parallel_number.txt
    @@ -0,0 +1,25 @@
    +[short] skip
    +
    +# go test -parallel -1 shouldn't work
    +! go test -parallel -1 standalone_parallel_sub_test.go
    +stdout '-parallel can only be given'
    +
    +# go test -parallel 0 shouldn't work
    +! go test -parallel 0 standalone_parallel_sub_test.go
    +stdout '-parallel can only be given'
    +
    +-- standalone_parallel_sub_test.go --
    +package standalone_parallel_sub_test
    +
    +import "testing"
    +
    +func Test(t *testing.T) {
    +	ch := make(chan bool, 1)
    +	t.Run("Sub", func(t *testing.T) {
    +		t.Parallel()
    +		<-ch
    +		t.Run("Nested", func(t *testing.T) {})
    +	})
    +	// Ensures that Sub will finish after its t.Run call already returned.
    +	ch <- true
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_ppc64_linker_funcs.txt b/go/src/cmd/go/testdata/script/test_ppc64_linker_funcs.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..d789f89f4e68cdf5114e6733858a9834a1408f2c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_ppc64_linker_funcs.txt
    @@ -0,0 +1,53 @@
    +# Tests that the linker implements the PPC64 ELFv2 ABI
    +# register save and restore functions as defined in
    +# section 2.3.3.1 of the PPC64 ELFv2 ABI when linking
    +# external objects most likely compiled with gcc's
    +# -Os option.
    +#
    +# Verifies golang.org/issue/52366 for linux/ppc64le
    +[!GOOS:linux] skip
    +[!compiler:gc] skip
    +[!cgo] skip
    +[!GOARCH:ppc64le] skip
    +
    +go build -ldflags='-linkmode=internal'
    +exec ./abitest
    +stdout success
    +
    +go build -buildmode=pie -o abitest.pie -ldflags='-linkmode=internal'
    +exec ./abitest.pie
    +stdout success
    +
    +-- go.mod --
    +module abitest
    +
    +-- abitest.go --
    +package main
    +
    +/*
    +#cgo CFLAGS: -Os
    +
    +int foo_fpr() {
    +        asm volatile("":::"fr31","fr30","fr29","fr28");
    +}
    +int foo_gpr0() {
    +        asm volatile("":::"r30","r29","r28");
    +}
    +int foo_gpr1() {
    +        asm volatile("":::"fr31", "fr30","fr29","fr28","r30","r29","r28");
    +}
    +int foo_vr() {
    +        asm volatile("":::"v31","v30","v29","v28");
    +}
    +*/
    +import "C"
    +
    +import "fmt"
    +
    +func main() {
    +	C.foo_fpr()
    +	C.foo_gpr0()
    +	C.foo_gpr1()
    +	C.foo_vr()
    +	fmt.Println("success")
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_ppc64le_cgo_inline_plt.txt b/go/src/cmd/go/testdata/script/test_ppc64le_cgo_inline_plt.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..ef9ff03592c3d34720142baa40191fd8e339a255
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_ppc64le_cgo_inline_plt.txt
    @@ -0,0 +1,38 @@
    +# Verify the linker will correctly resolve
    +# ppc64le objects compiled with gcc's -fno-plt
    +# option. This inlines PLT calls, and generates
    +# additional reloc types which the internal linker
    +# should handle.
    +#
    +# Verifies golang.org/issue/53345
    +#
    +# Note, older gcc/clang may accept this option, but
    +# ignore it if binutils does not support the relocs.
    +[!compiler:gc] skip
    +[!cgo] skip
    +[!GOARCH:ppc64le] skip
    +
    +env CGO_CFLAGS='-fno-plt -O2 -g'
    +
    +go build -ldflags='-linkmode=internal'
    +exec ./noplttest
    +stdout helloworld
    +
    +-- go.mod --
    +module noplttest
    +
    +-- noplttest.go --
    +package main
    +
    +/*
    +#include 
    +void helloworld(void) {
    +   printf("helloworld\n");
    +   fflush(stdout);
    +}
    +*/
    +import "C"
    +
    +func main() {
    +	C.helloworld()
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_print.txt b/go/src/cmd/go/testdata/script/test_print.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..32a487678c7df38e9572cf09741ba661b0999c7c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_print.txt
    @@ -0,0 +1,27 @@
    +[short] skip
    +
    +go test ./...
    +stdout 'pkg1(.|\n)*pkg2'
    +
    +-- go.mod --
    +module m
    +
    +-- pkg1/x_test.go --
    +package pkg1
    +
    +import (
    +	"testing"
    +	"time"
    +)
    +
    +func Test(t *testing.T) {
    +	// This sleep makes it more likely that pkg2 will be ready before pkg1,
    +	// which previously would have made this test fail, because pkg2 would
    +	// be printed before pkg1.
    +	// Now that there is proper ordering, the Sleep should not matter.
    +	// In particular, the Sleep does not make the test pass and won't
    +	// be a problem on slow builders.
    +	time.Sleep(1*time.Second)
    +}
    +-- pkg2/x.go --
    +package pkg2
    diff --git a/go/src/cmd/go/testdata/script/test_profile.txt b/go/src/cmd/go/testdata/script/test_profile.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..9110706f083d29cf365407defa265e6140e30b99
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_profile.txt
    @@ -0,0 +1,19 @@
    +[compiler:gccgo] skip 'gccgo has no standard packages'
    +[short] skip
    +
    +# Check go test -cpuprofile creates errors.test
    +go test -cpuprofile errors.prof errors
    +exists -exec errors.test$GOEXE
    +
    +# Check go test -cpuprofile -o myerrors.test creates errors.test
    +go test -cpuprofile errors.prof -o myerrors.test$GOEXE errors
    +exists -exec myerrors.test$GOEXE
    +
    +# Check go test -mutexprofile creates errors.test
    +go test -mutexprofile errors.prof errors
    +exists -exec errors.test$GOEXE
    +
    +# Check go test -mutexprofile -o myerrors.test creates errors.test
    +go test -mutexprofile errors.prof -o myerrors.test$GOEXE errors
    +exists -exec myerrors.test$GOEXE
    +
    diff --git a/go/src/cmd/go/testdata/script/test_race.txt b/go/src/cmd/go/testdata/script/test_race.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..2ffea4609256861b9a786e0dd7746707649d84e9
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_race.txt
    @@ -0,0 +1,51 @@
    +[short] skip
    +[!race] skip
    +
    +go test testrace
    +
    +! go test -race testrace
    +stdout 'FAIL: TestRace'
    +! stdout 'PASS'
    +! stderr 'PASS'
    +
    +! go test -race testrace -run XXX -bench .
    +stdout 'FAIL: BenchmarkRace'
    +! stdout 'PASS'
    +! stderr 'PASS'
    +
    +-- go.mod --
    +module testrace
    +
    +go 1.16
    +-- race_test.go --
    +package testrace
    +
    +import "testing"
    +
    +func TestRace(t *testing.T) {
    +	for i := 0; i < 10; i++ {
    +		c := make(chan int)
    +		x := 1
    +		go func() {
    +			x = 2
    +			c <- 1
    +		}()
    +		x = 3
    +		<-c
    +		_ = x
    +	}
    +}
    +
    +func BenchmarkRace(b *testing.B) {
    +	for i := 0; i < b.N; i++ {
    +		c := make(chan int)
    +		x := 1
    +		go func() {
    +			x = 2
    +			c <- 1
    +		}()
    +		x = 3
    +		<-c
    +		_ = x
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_race_cover_mode_issue20435.txt b/go/src/cmd/go/testdata/script/test_race_cover_mode_issue20435.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..eacc882091a7c2acc35e747652e69caaa3380b28
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_race_cover_mode_issue20435.txt
    @@ -0,0 +1,48 @@
    +[short] skip
    +[!race] skip
    +
    +# Make sure test is functional.
    +go test testrace
    +
    +# Now, check that -race -covermode=set is not allowed.
    +! go test -race -covermode=set testrace
    +stderr '-covermode must be "atomic", not "set", when -race is enabled'
    +! stdout PASS
    +! stderr PASS
    +
    +-- go.mod --
    +module testrace
    +
    +go 1.16
    +-- race_test.go --
    +package testrace
    +
    +import "testing"
    +
    +func TestRace(t *testing.T) {
    +	for i := 0; i < 10; i++ {
    +		c := make(chan int)
    +		x := 1
    +		go func() {
    +			x = 2
    +			c <- 1
    +		}()
    +		x = 3
    +		<-c
    +		_ = x
    +	}
    +}
    +
    +func BenchmarkRace(b *testing.B) {
    +	for i := 0; i < b.N; i++ {
    +		c := make(chan int)
    +		x := 1
    +		go func() {
    +			x = 2
    +			c <- 1
    +		}()
    +		x = 3
    +		<-c
    +		_ = x
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_race_install.txt b/go/src/cmd/go/testdata/script/test_race_install.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..918d7e925b97d401f83029e7f8425748d4f5bb28
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_race_install.txt
    @@ -0,0 +1,12 @@
    +[!race] skip
    +[short] skip
    +
    +mkdir $WORKDIR/tmp/pkg
    +go install -race -pkgdir=$WORKDIR/tmp/pkg std
    +
    +-- go.mod --
    +module empty
    +
    +go 1.16
    +-- pkg/pkg.go --
    +package p
    diff --git a/go/src/cmd/go/testdata/script/test_race_install_cgo.txt b/go/src/cmd/go/testdata/script/test_race_install_cgo.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e1fe4f2acea96f161198dec4f45558d341749f6f
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_race_install_cgo.txt
    @@ -0,0 +1,91 @@
    +# Tests Issue #10500
    +
    +[!race] skip
    +
    +env GOBIN=$WORK/bin
    +go install m/mtime m/sametime
    +
    +go tool -n cgo
    +cp stdout cgopath.txt
    +exec $GOBIN/mtime cgopath.txt # get the mtime of the file whose name is in cgopath.txt
    +cp stdout cgotime_before.txt
    +
    + # For this test, we don't actually care whether 'go test -race -i' succeeds.
    + # It may fail if GOROOT is read-only (perhaps it was installed as root).
    + # We only care that it does not overwrite cmd/cgo regardless.
    +? go test -race -i runtime/race
    +
    +exec $GOBIN/mtime cgopath.txt # get the mtime of the file whose name is in cgopath.txt
    +cp stdout cgotime_after.txt
    +exec $GOBIN/sametime cgotime_before.txt cgotime_after.txt
    +
    +-- go.mod --
    +module m
    +
    +go 1.16
    +-- mtime/mtime.go --
    +package main
    +
    +import (
    +	"encoding/json"
    +	"fmt"
    +	"os"
    +	"strings"
    +)
    +
    +func main() {
    +	b, err := os.ReadFile(os.Args[1])
    +	if err != nil {
    +		fmt.Fprintln(os.Stderr, err)
    +		os.Exit(1)
    +	}
    +	filename := strings.TrimSpace(string(b))
    +	info, err := os.Stat(filename)
    +	if err != nil {
    +		fmt.Fprintln(os.Stderr, err)
    +		os.Exit(1)
    +	}
    +	if err := json.NewEncoder(os.Stdout).Encode(info.ModTime()); err != nil {
    +		fmt.Fprintln(os.Stderr, err)
    +		os.Exit(1)
    +	}
    +}
    +-- sametime/sametime.go --
    +package main
    +
    +import (
    +	"encoding/json"
    +	"fmt"
    +	"os"
    +	"time"
    +)
    +
    +
    +func main() {
    +	var t1 time.Time
    +	b1, err := os.ReadFile(os.Args[1])
    +	if err != nil {
    +		fmt.Fprintln(os.Stderr, err)
    +		os.Exit(1)
    +	}
    +	if err := json.Unmarshal(b1, &t1); err != nil  {
    +		fmt.Fprintln(os.Stderr, err)
    +		os.Exit(1)
    +	}
    +
    +	var t2 time.Time
    +	b2, err := os.ReadFile(os.Args[2])
    +	if err != nil {
    +		fmt.Fprintln(os.Stderr, err)
    +		os.Exit(1)
    +	}
    +	if err := json.Unmarshal(b2, &t2); err != nil  {
    +		fmt.Fprintln(os.Stderr, err)
    +		os.Exit(1)
    +	}
    +
    +	if !t1.Equal(t2) {
    +		fmt.Fprintf(os.Stderr, "time in %v (%v) is not the same as time in %v (%v)", os.Args[1], t1, os.Args[2], t2)
    +		os.Exit(1)
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_race_issue26995.txt b/go/src/cmd/go/testdata/script/test_race_issue26995.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f40fb46f321ea87e01169263d99810cbb2b07a61
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_race_issue26995.txt
    @@ -0,0 +1,42 @@
    +[short] skip
    +[!race] skip
    +
    +go test -v -race
    +stdout 'testing_test.go:26: directCall'
    +stdout 'testing_test.go:27: interfaceTBCall'
    +stdout 'testing_test.go:28: interfaceCall'
    +
    +-- go.mod --
    +module 26995-TBHelper-line-number
    +
    +go 1.21
    +-- testing_test.go --
    +package testing_test
    +
    +import "testing"
    +
    +type TestingT interface {
    +	Helper()
    +	Log(args ...interface{})
    +}
    +
    +func directCall(t *testing.T) {
    +	t.Helper()
    +	t.Log("directCall")
    +}
    +
    +func interfaceTBCall(t testing.TB) {
    +	t.Helper()
    +	t.Log("interfaceTBCall")
    +}
    +
    +func interfaceCall(t TestingT) {
    +	t.Helper()
    +	t.Log("interfaceCall")
    +}
    +
    +func TestTesting(t *testing.T) {
    +	directCall(t)
    +	interfaceTBCall(t)
    +	interfaceCall(t)
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_race_tag.txt b/go/src/cmd/go/testdata/script/test_race_tag.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..4b18ebc45496f89add3ccc2e25aaf8690f2e5b64
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_race_tag.txt
    @@ -0,0 +1,29 @@
    +# Tests Issue #54468
    +
    +[short] skip 'links a test binary'
    +[!race] skip
    +
    +go mod tidy
    +go test -c -o=$devnull -race .
    +
    +! stderr 'cannot find package'
    +
    +-- go.mod --
    +module testrace
    +
    +go 1.18
    +
    +require rsc.io/sampler v1.0.0
    +-- race_test.go --
    +//go:build race
    +
    +package testrace
    +
    +import (
    +        "testing"
    +
    +        _ "rsc.io/sampler"
    +)
    +
    +func TestRaceTag(t *testing.T) {
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_rebuildall.txt b/go/src/cmd/go/testdata/script/test_rebuildall.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..38233c18922a1e9499397307c8f152b49ff725c5
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_rebuildall.txt
    @@ -0,0 +1,14 @@
    +env GO111MODULE=off
    +
    +# Regression test for golang.org/issue/6844:
    +# 'go test -a' should force dependencies in the standard library to be rebuilt.
    +
    +[short] skip
    +
    +go test -x -a -c testdata/dep_test.go
    +stderr '^.*[/\\]compile'$GOEXE'["]? (.* )?regexp .*[/\\]regexp\.go'
    +
    +-- testdata/dep_test.go --
    +package deps
    +
    +import _ "testing"
    diff --git a/go/src/cmd/go/testdata/script/test_regexps.txt b/go/src/cmd/go/testdata/script/test_regexps.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..2f33080a00474e3cd7c3c0b656de7a76b775b07c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_regexps.txt
    @@ -0,0 +1,79 @@
    +go test -cpu=1 -run=X/Y -bench=X/Y -count=2 -v testregexp
    +
    +# Test the following:
    +
    +# TestX is run, twice
    +stdout -count=2 '^=== RUN   TestX$'
    +stdout -count=2 '^    x_test.go:6: LOG: X running$'
    +
    +# TestX/Y is run, twice
    +stdout -count=2 '^=== RUN   TestX/Y$'
    +stdout -count=2 '^    x_test.go:8: LOG: Y running$'
    +
    +# TestXX is run, twice
    +stdout -count=2 '^=== RUN   TestXX$'
    +stdout -count=2 '^    z_test.go:10: LOG: XX running'
    +
    +# TestZ is not run
    +! stdout '^=== RUN   TestZ$'
    +
    +# BenchmarkX is run with N=1 once, only to discover what sub-benchmarks it has,
    +# and should not print a final summary line.
    +stdout -count=1 '^    x_test.go:13: LOG: X running N=1$'
    +! stdout '^\s+BenchmarkX: x_test.go:13: LOG: X running N=\d\d+'
    +! stdout 'BenchmarkX\s+\d+'
    +
    +# Same for BenchmarkXX.
    +stdout -count=1 '^    z_test.go:18: LOG: XX running N=1$'
    +! stdout  '^    z_test.go:18: LOG: XX running N=\d\d+'
    +! stdout 'BenchmarkXX\s+\d+'
    +
    +# BenchmarkX/Y is run in full twice due to -count=2.
    +# "Run in full" means that it runs for approximately the default benchtime,
    +# but may cap out at N=1e9.
    +# We don't actually care what the final iteration count is, but it should be
    +# a large number, and the last iteration count prints right before the results.
    +stdout -count=2 '^    x_test.go:15: LOG: Y running N=[1-9]\d{4,}\nBenchmarkX/Y\s+\d+'
    +
    +-- go.mod --
    +module testregexp
    +
    +go 1.16
    +-- x_test.go --
    +package x
    +
    +import "testing"
    +
    +func TestX(t *testing.T) {
    +	t.Logf("LOG: X running")
    +	t.Run("Y", func(t *testing.T) {
    +		t.Logf("LOG: Y running")
    +	})
    +}
    +
    +func BenchmarkX(b *testing.B) {
    +	b.Logf("LOG: X running N=%d", b.N)
    +	b.Run("Y", func(b *testing.B) {
    +		b.Logf("LOG: Y running N=%d", b.N)
    +	})
    +}
    +-- z_test.go --
    +package x
    +
    +import "testing"
    +
    +func TestZ(t *testing.T) {
    +	t.Logf("LOG: Z running")
    +}
    +
    +func TestXX(t *testing.T) {
    +	t.Logf("LOG: XX running")
    +}
    +
    +func BenchmarkZ(b *testing.B) {
    +	b.Logf("LOG: Z running N=%d", b.N)
    +}
    +
    +func BenchmarkXX(b *testing.B) {
    +	b.Logf("LOG: XX running N=%d", b.N)
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_relative_cmdline.txt b/go/src/cmd/go/testdata/script/test_relative_cmdline.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..96f7b872652b236379de4ca7ecf920b12d4a66eb
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_relative_cmdline.txt
    @@ -0,0 +1,52 @@
    +# Relative imports in command line package
    +
    +env GO111MODULE=off
    +
    +# Run tests outside GOPATH.
    +env GOPATH=$WORK/tmp
    +
    +go test ./testimport/p.go ./testimport/p_test.go ./testimport/x_test.go
    +stdout '^ok'
    +
    +-- testimport/p.go --
    +package p
    +
    +func F() int { return 1 }
    +-- testimport/p1/p1.go --
    +package p1
    +
    +func F() int { return 1 }
    +-- testimport/p2/p2.go --
    +package p2
    +
    +func F() int { return 1 }
    +-- testimport/p_test.go --
    +package p
    +
    +import (
    +	"./p1"
    +
    +	"testing"
    +)
    +
    +func TestF(t *testing.T) {
    +	if F() != p1.F() {
    +		t.Fatal(F())
    +	}
    +}
    +-- testimport/x_test.go --
    +package p_test
    +
    +import (
    +	. "../testimport"
    +
    +	"./p2"
    +
    +	"testing"
    +)
    +
    +func TestF1(t *testing.T) {
    +	if F() != p2.F() {
    +		t.Fatal(F())
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_relative_import.txt b/go/src/cmd/go/testdata/script/test_relative_import.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..938a875b55555e01954454931f067fdebdb56188
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_relative_import.txt
    @@ -0,0 +1,31 @@
    +# Relative imports in go test
    +env GO111MODULE=off # relative import not supported in module mode
    +
    +# Run tests outside GOPATH.
    +env GOPATH=$WORK/tmp
    +
    +go test ./testimport
    +stdout '^ok'
    +
    +-- testimport/p.go --
    +package p
    +
    +func F() int { return 1 }
    +-- testimport/p1/p1.go --
    +package p1
    +
    +func F() int { return 1 }
    +-- testimport/p_test.go --
    +package p
    +
    +import (
    +	"./p1"
    +
    +	"testing"
    +)
    +
    +func TestF(t *testing.T) {
    +	if F() != p1.F() {
    +		t.Fatal(F())
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_script_cmdcd.txt b/go/src/cmd/go/testdata/script/test_script_cmdcd.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6e6f67e13d089326dea85f0f9080bb1ead6cfd82
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_script_cmdcd.txt
    @@ -0,0 +1,13 @@
    +# Tests that after a cd command, where usually the UNIX path separator is used,
    +# a match against $PWD does not fail on Windows.
    +
    +cd $WORK/a/b/c/pkg
    +
    +go list -find -f {{.Root}}
    +stdout $PWD
    +
    +-- $WORK/a/b/c/pkg/go.mod --
    +module pkg
    +
    +-- $WORK/a/b/c/pkg/pkg.go --
    +package pkg
    diff --git a/go/src/cmd/go/testdata/script/test_setup_error.txt b/go/src/cmd/go/testdata/script/test_setup_error.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..bf566d4621f1a5d0ff05435725b84776102b980e
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_setup_error.txt
    @@ -0,0 +1,98 @@
    +[short] skip
    +
    +# Test that a loading error in a test file is reported as a "setup failed" error
    +# and doesn't prevent running other tests.
    +! go test -o=$devnull ./t1/p ./t
    +stderr '# m/t1/p\n.*package x is not in std'
    +stdout 'FAIL	m/t1/p \[setup failed\]'
    +stdout 'ok  	m/t'
    +
    +# Test a loading error in a test package, but not in the test file
    +! go test -o=$devnull ./t2/p ./t
    +stderr '# m/t2/p\n.*package x is not in std'
    +stdout 'FAIL	m/t2/p \[setup failed\]'
    +stdout 'ok  	m/t'
    +
    +# Test a loading error in a package imported by a test file
    +! go test -o=$devnull ./t3/p ./t
    +stderr '# m/t3/p\n.*package x is not in std'
    +stdout 'FAIL	m/t3/p \[setup failed\]'
    +stdout 'ok  	m/t'
    +
    +# Test a loading error in a package imported by a test package
    +! go test -o=$devnull ./t4/p ./t
    +stderr '# m/t4/p\n.*package x is not in std'
    +stdout 'FAIL	m/t4/p \[setup failed\]'
    +stdout 'ok  	m/t'
    +
    +# Test that two loading errors are both reported.
    +! go test -o=$devnull ./t1/p ./t2/p ./t
    +stderr '# m/t1/p\n.*package x is not in std'
    +stdout 'FAIL	m/t1/p \[setup failed\]'
    +stderr '# m/t2/p\n.*package x is not in std'
    +stdout 'FAIL	m/t2/p \[setup failed\]'
    +stdout 'ok  	m/t'
    +
    +# Test that an import cycle error is reported. Test for #70820
    +! go test -o=$devnull ./cycle/p ./t
    +stderr '# m/cycle/p\n.*package m/cycle/p\n\timports m/cycle/p from p\.go: import cycle not allowed'
    +stdout 'FAIL	m/cycle/p \[setup failed\]'
    +stdout 'ok  	m/t'
    +
    +# Test that multiple errors for the same package under test are reported.
    +! go test -o=$devnull ./cycle/q ./t
    +stderr '# m/cycle/q\n.*package m/cycle/q\n\timports m/cycle/p from q\.go\n\timports m/cycle/p from p\.go: import cycle not allowed'
    +stdout 'FAIL	m/cycle/q \[setup failed\]'
    +stdout 'ok  	m/t'
    +
    +# Finally, this one is a non-import-cycle load error that
    +# is produced for the package under test.
    +! go test -o=$devnull . ./t
    +stderr '# \.\n.*no Go files in '$PWD'$'
    +stdout 'FAIL	. \[setup failed\]'
    +stdout 'ok  	m/t'
    +
    +-- go.mod --
    +module m
    +go 1.21
    +-- t/t_test.go --
    +package t
    +
    +import "testing"
    +
    +func TestGood(t *testing.T) {}
    +-- t1/p/p_test.go --
    +package p
    +
    +import "x"
    +-- t2/p/p_test.go --
    +package p
    +-- t2/p/p.go --
    +package p
    +
    +import "x"
    +-- t3/p/p_test.go --
    +package p
    +
    +import "m/bad"
    +-- t4/p/p_test.go --
    +package p
    +-- t4/p/p.go --
    +package p
    +
    +import "m/bad"
    +-- cycle/p/p.go --
    +package p
    +
    +import "m/cycle/p"
    +-- cycle/q/q.go --
    +package q
    +
    +import (
    +	"m/bad"
    +	"m/cycle/p"
    +)
    +-- bad/bad.go --
    +package bad
    +
    +import "x"
    diff --git a/go/src/cmd/go/testdata/script/test_shuffle.txt b/go/src/cmd/go/testdata/script/test_shuffle.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..98029f552d4c888e1b330130bf60e4c27143a697
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_shuffle.txt
    @@ -0,0 +1,134 @@
    +# Shuffle order of tests and benchmarks
    +
    +[short] skip 'builds and repeatedly runs a test binary'
    +
    +# Run tests
    +go test -v foo_test.go
    +! stdout '-test.shuffle '
    +stdout '(?s)TestOne(.*)TestTwo(.*)TestThree'
    +
    +go test -v -shuffle=off foo_test.go
    +! stdout '-test.shuffle '
    +stdout '(?s)TestOne(.*)TestTwo(.*)TestThree'
    +
    +go test -v -shuffle=42 foo_test.go
    +stdout '^-test.shuffle 42'
    +stdout '(?s)TestThree(.*)TestOne(.*)TestTwo'
    +
    +go test -v -shuffle=0 foo_test.go
    +stdout '^-test.shuffle 0'
    +stdout '(?s)TestTwo(.*)TestOne(.*)TestThree'
    +
    +go test -v -shuffle -1 foo_test.go
    +stdout '^-test.shuffle -1'
    +stdout '(?s)TestThree(.*)TestOne(.*)TestTwo'
    +
    +go test -v -shuffle=on foo_test.go
    +stdout '^-test.shuffle '
    +stdout '(?s)=== RUN   TestOne(.*)--- PASS: TestOne'
    +stdout '(?s)=== RUN   TestTwo(.*)--- PASS: TestTwo'
    +stdout '(?s)=== RUN   TestThree(.*)--- PASS: TestThree'
    +
    +
    +# Run tests and benchmarks
    +go test -v -bench=. foo_test.go
    +! stdout '-test.shuffle '
    +stdout '(?s)TestOne(.*)TestTwo(.*)TestThree(.*)BenchmarkOne(.*)BenchmarkTwo(.*)BenchmarkThree'
    +
    +go test -v -bench=. -shuffle=off foo_test.go
    +! stdout '-test.shuffle '
    +stdout '(?s)TestOne(.*)TestTwo(.*)TestThree(.*)BenchmarkOne(.*)BenchmarkTwo(.*)BenchmarkThree'
    +
    +go test -v -bench=. -shuffle=42 foo_test.go
    +stdout '^-test.shuffle 42'
    +stdout '(?s)TestThree(.*)TestOne(.*)TestTwo(.*)BenchmarkThree(.*)BenchmarkOne(.*)BenchmarkTwo'
    +
    +go test -v -bench=. -shuffle=0 foo_test.go
    +stdout '^-test.shuffle 0'
    +stdout '(?s)TestTwo(.*)TestOne(.*)TestThree(.*)BenchmarkThree(.*)BenchmarkOne(.*)BenchmarkTwo'
    +
    +go test -v -bench=. -shuffle -1 foo_test.go
    +stdout '^-test.shuffle -1'
    +stdout '(?s)TestThree(.*)TestOne(.*)TestTwo(.*)BenchmarkOne(.*)BenchmarkThree(.*)BenchmarkTwo'
    +
    +go test -v -bench=. -shuffle=on foo_test.go
    +stdout '^-test.shuffle '
    +stdout '(?s)=== RUN   TestOne(.*)--- PASS: TestOne'
    +stdout '(?s)=== RUN   TestTwo(.*)--- PASS: TestTwo'
    +stdout '(?s)=== RUN   TestThree(.*)--- PASS: TestThree'
    +stdout -count=2 'BenchmarkOne'
    +stdout -count=2 'BenchmarkTwo'
    +stdout -count=2 'BenchmarkThree'
    +
    +
    +# When running go test -count=N, each of the N runs distinct runs should maintain the same
    +# shuffled order of these tests.
    +go test -v -shuffle=43 -count=4 foo_test.go
    +stdout '^-test.shuffle 43'
    +stdout '(?s)TestThree(.*)TestTwo(.*)TestOne(.*)TestThree(.*)TestTwo(.*)TestOne(.*)TestThree(.*)TestTwo(.*)TestOne(.*)TestThree(.*)TestTwo(.*)TestOne'
    +
    +go test -v -bench=. -shuffle=44 -count=2 foo_test.go
    +stdout '^-test.shuffle 44'
    +stdout '(?s)TestOne(.*)TestThree(.*)TestTwo(.*)TestOne(.*)TestThree(.*)TestTwo(.*)BenchmarkTwo(.*)BenchmarkOne(.*)BenchmarkThree(.*)'
    +
    +
    +# The feature should work with test binaries as well
    +go test -c
    +exec ./m.test -test.shuffle=off
    +! stdout '^-test.shuffle '
    +
    +exec ./m.test -test.shuffle=on
    +stdout '^-test.shuffle '
    +
    +exec ./m.test -test.v -test.bench=. -test.shuffle=0 foo_test.go
    +stdout '^-test.shuffle 0'
    +stdout '(?s)TestTwo(.*)TestOne(.*)TestThree(.*)BenchmarkThree(.*)BenchmarkOne(.*)BenchmarkTwo'
    +
    +exec ./m.test -test.v -test.bench=. -test.shuffle=123 foo_test.go
    +stdout '^-test.shuffle 123'
    +stdout '(?s)TestThree(.*)TestOne(.*)TestTwo(.*)BenchmarkThree(.*)BenchmarkTwo(.*)BenchmarkOne'
    +
    +exec ./m.test -test.v -test.bench=. -test.shuffle=-1 foo_test.go
    +stdout '^-test.shuffle -1'
    +stdout '(?s)TestThree(.*)TestOne(.*)TestTwo(.*)BenchmarkOne(.*)BenchmarkThree(.*)BenchmarkTwo'
    +
    +exec ./m.test -test.v -test.bench=. -test.shuffle=44 -test.count=2 foo_test.go
    +stdout '^-test.shuffle 44'
    +stdout '(?s)TestOne(.*)TestThree(.*)TestTwo(.*)TestOne(.*)TestThree(.*)TestTwo(.*)BenchmarkTwo(.*)BenchmarkOne(.*)BenchmarkThree(.*)'
    +
    +
    +# Negative testcases for invalid input
    +! go test -shuffle -count=2
    +stderr 'invalid value "-count=2" for flag -shuffle: -shuffle argument must be "on", "off", or an int64: strconv.ParseInt: parsing "-count=2": invalid syntax'
    +
    +! go test -shuffle=
    +stderr '(?s)invalid value "" for flag -shuffle: -shuffle argument must be "on", "off", or an int64: strconv.ParseInt: parsing "": invalid syntax'
    +
    +! go test -shuffle=' '
    +stderr '(?s)invalid value " " for flag -shuffle: -shuffle argument must be "on", "off", or an int64: strconv.ParseInt: parsing " ": invalid syntax'
    +
    +! go test -shuffle=true
    +stderr 'invalid value "true" for flag -shuffle: -shuffle argument must be "on", "off", or an int64: strconv.ParseInt: parsing "true": invalid syntax'
    +
    +! go test -shuffle='abc'
    +stderr 'invalid value "abc" for flag -shuffle: -shuffle argument must be "on", "off", or an int64: strconv.ParseInt: parsing "abc": invalid syntax'
    +
    +-- go.mod --
    +module m
    +
    +go 1.16
    +-- foo_test.go --
    +package foo
    +
    +import "testing"
    +
    +func TestOne(t *testing.T)   {}
    +func TestTwo(t *testing.T)   {}
    +func TestThree(t *testing.T) {}
    +
    +func BenchmarkOne(b *testing.B)   {}
    +func BenchmarkTwo(b *testing.B)   {}
    +func BenchmarkThree(b *testing.B) {}
    +
    +-- foo.go --
    +package foo
    diff --git a/go/src/cmd/go/testdata/script/test_skip.txt b/go/src/cmd/go/testdata/script/test_skip.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..350becbb20cc9f6c61bd5f56ef6e6e384af66207
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_skip.txt
    @@ -0,0 +1,47 @@
    +[short] skip 'runs test'
    +
    +go test -v -run Test -skip T skip_test.go
    +! stdout RUN
    +stdout '^ok.*\[no tests to run\]'
    +
    +go test -v -skip T skip_test.go
    +! stdout RUN
    +
    +go test -v -skip 1 skip_test.go
    +! stdout Test1
    +stdout RUN.*Test2
    +stdout RUN.*Test2/3
    +
    +go test -v -skip 2/3 skip_test.go
    +stdout RUN.*Test1
    +stdout RUN.*Test2
    +stdout RUN.*ExampleTest1
    +! stdout Test2/3
    +
    +go test -v -skip 2/4 skip_test.go
    +stdout RUN.*Test1
    +stdout RUN.*Test2
    +stdout RUN.*Test2/3
    +stdout RUN.*ExampleTest1
    +
    +go test -v -skip Example skip_test.go
    +stdout RUN.*Test1
    +stdout RUN.*Test2
    +stdout RUN.*Test2/3
    +! stdout ExampleTest1
    +
    +-- skip_test.go --
    +package skip_test
    +
    +import "testing"
    +
    +func Test1(t *testing.T) {
    +}
    +
    +func Test2(t *testing.T) {
    +	t.Run("3", func(t *testing.T) {})
    +}
    +
    +func ExampleTest1() {
    +	// Output:
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_source_order.txt b/go/src/cmd/go/testdata/script/test_source_order.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b636001b804ef9e53fe41d2f9125365036aa957a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_source_order.txt
    @@ -0,0 +1,54 @@
    +[short] skip
    +
    +# Control
    +! go test example2_test.go example1_test.go
    +
    +# This test only passes if the source order is preserved
    +go test example1_test.go example2_test.go
    +
    +-- example1_test.go --
    +// Copyright 2013 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Make sure that go test runs Example_z before Example_a, preserving source order.
    +
    +package p
    +
    +import "fmt"
    +
    +var n int
    +
    +func Example_z() {
    +	n++
    +	fmt.Println(n)
    +	// Output: 1
    +}
    +
    +func Example_a() {
    +	n++
    +	fmt.Println(n)
    +	// Output: 2
    +}
    +-- example2_test.go --
    +// Copyright 2013 The Go Authors. All rights reserved.
    +// Use of this source code is governed by a BSD-style
    +// license that can be found in the LICENSE file.
    +
    +// Make sure that go test runs Example_y before Example_b, preserving source order.
    +
    +package p
    +
    +import "fmt"
    +
    +func Example_y() {
    +	n++
    +	fmt.Println(n)
    +	// Output: 3
    +}
    +
    +func Example_b() {
    +	n++
    +	fmt.Println(n)
    +	// Output: 4
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_status.txt b/go/src/cmd/go/testdata/script/test_status.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..aa6ad3c50da94927fbf8e952f70f951515438eef
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_status.txt
    @@ -0,0 +1,18 @@
    +env GO111MODULE=off
    +
    +! go test x y
    +stdout ^FAIL\s+x
    +stdout ^ok\s+y
    +stdout (?-m)FAIL\n$
    +
    +-- x/x_test.go --
    +package x
    +
    +import "testing"
    +
    +func TestNothingJustFail(t *testing.T) {
    +    t.Fail()
    +}
    +
    +-- y/y_test.go --
    +package y
    diff --git a/go/src/cmd/go/testdata/script/test_syntax_error_says_fail.txt b/go/src/cmd/go/testdata/script/test_syntax_error_says_fail.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..44ff6e2b39533acb14204d2bf8a4e60964283bee
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_syntax_error_says_fail.txt
    @@ -0,0 +1,25 @@
    +# Test that the error message for a syntax error in a test go file
    +# says FAIL.
    +
    +env GO111MODULE=off
    +! go test syntaxerror
    +stderr 'x_test.go:' # check that the error is diagnosed
    +stdout 'FAIL' # check that go test says FAIL
    +
    +env GO111MODULE=on
    +cd syntaxerror
    +! go test syntaxerror
    +stderr 'x_test.go:' # check that the error is diagnosed
    +stdout 'FAIL' # check that go test says FAIL
    +
    +-- syntaxerror/go.mod --
    +module syntaxerror
    +
    +go 1.16
    +-- syntaxerror/x.go --
    +package p
    +-- syntaxerror/x_test.go --
    +package p
    +
    +func f() (x.y, z int) {
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_timeout.txt b/go/src/cmd/go/testdata/script/test_timeout.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..4de4df450821d4ebf9ff9b61b2c4874061118797
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_timeout.txt
    @@ -0,0 +1,23 @@
    +[short] skip
    +env GO111MODULE=off
    +cd a
    +
    +# If no timeout is set explicitly, 'go test' should set
    +# -test.timeout to its internal deadline.
    +go test -v . --
    +stdout '10m0s'
    +
    +# An explicit -timeout argument should be propagated to -test.timeout.
    +go test -v -timeout 30m . --
    +stdout '30m0s'
    +
    +-- a/timeout_test.go --
    +package t
    +import (
    +	"flag"
    +	"fmt"
    +	"testing"
    +)
    +func TestTimeout(t *testing.T) {
    +	fmt.Println(flag.Lookup("test.timeout").Value.String())
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_timeout_stdin.txt b/go/src/cmd/go/testdata/script/test_timeout_stdin.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f2de0a67ef793eec3a0de8852f75c4d9e5a42016
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_timeout_stdin.txt
    @@ -0,0 +1,88 @@
    +# Regression test for https://go.dev/issue/24050:
    +# a test that exits with an I/O stream held open
    +# should fail after a reasonable delay, not wait forever.
    +# (As of the time of writing, that delay is 10% of the timeout,
    +# but this test does not depend on its specific value.)
    +
    +[short] skip 'runs a test that hangs until its WaitDelay expires'
    +
    +! go test -v -timeout=1m .
    +
    +	# After the test process itself prints PASS and exits,
    +	# the kernel closes its stdin pipe to to the orphaned subprocess.
    +	# At that point, we expect the subprocess to print 'stdin closed'
    +	# and periodically log to stderr until the WaitDelay expires.
    +	#
    +	# Once the WaitDelay expires, the copying goroutine for 'go test' stops and
    +	# closes the read side of the stderr pipe, and the subprocess will eventually
    +	# exit due to a failed write to that pipe.
    +
    +stdout '^--- PASS: TestOrphanCmd .*\nPASS\nstdin closed'
    +stdout '^\*\*\* Test I/O incomplete \d+.* after exiting\.\nexec: WaitDelay expired before I/O complete\nFAIL\s+example\s+\d+(\.\d+)?s'
    +
    +-- go.mod --
    +module example
    +
    +go 1.20
    +-- main_test.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"io"
    +	"os"
    +	"os/exec"
    +	"testing"
    +	"time"
    +)
    +
    +func TestMain(m *testing.M) {
    +	if os.Getenv("TEST_TIMEOUT_HANG") == "1" {
    +		io.Copy(io.Discard, os.Stdin)
    +		if _, err := os.Stderr.WriteString("stdin closed\n"); err != nil {
    +			os.Exit(1)
    +		}
    +
    +		ticker := time.NewTicker(100 * time.Millisecond)
    +		for t := range ticker.C {
    +			_, err := fmt.Fprintf(os.Stderr, "still alive at %v\n", t)
    +			if err != nil {
    +				os.Exit(1)
    +			}
    +		}
    +	}
    +
    +	m.Run()
    +}
    +
    +func TestOrphanCmd(t *testing.T) {
    +	exe, err := os.Executable()
    +	if err != nil {
    +		t.Fatal(err)
    +	}
    +
    +	cmd := exec.Command(exe)
    +	cmd.Env = append(cmd.Environ(), "TEST_TIMEOUT_HANG=1")
    +
    +	// Hold stdin open until this (parent) process exits.
    +	if _, err := cmd.StdinPipe(); err != nil {
    +		t.Fatal(err)
    +	}
    +
    +	// Forward stderr to the subprocess so that it can hold the stream open.
    +	cmd.Stderr = os.Stderr
    +
    +	if err := cmd.Start(); err != nil {
    +		t.Fatal(err)
    +	}
    +	t.Logf("started %v", cmd)
    +
    +	// Intentionally leak cmd when the test completes.
    +	// This will allow the test process itself to exit, but (at least on Unix
    +	// platforms) will keep the parent process's stderr stream open.
    +	go func() {
    +		if err := cmd.Wait(); err != nil {
    +			os.Exit(3)
    +		}
    +	}()
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_trimpath.txt b/go/src/cmd/go/testdata/script/test_trimpath.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..065f9ce4d17852c87a360bba019132ad8df27bf8
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_trimpath.txt
    @@ -0,0 +1,51 @@
    +[short] skip
    +
    +go test -trimpath -v .
    +! stdout '[/\\]pkg_test[/\\]'
    +stdout -count=3 '[/\\]pkg[/\\]'
    +
    +-- go.mod --
    +module example.com/pkg
    +
    +go 1.17
    +
    +-- pkg.go --
    +package pkg
    +
    +import "runtime"
    +
    +func PrintFile() {
    +	_, file, _, _ := runtime.Caller(0)
    +	println(file)
    +}
    +
    +-- pkg_test.go --
    +package pkg
    +
    +import "runtime"
    +
    +func PrintFileForTest() {
    +	_, file, _, _ := runtime.Caller(0)
    +	println(file)
    +}
    +
    +-- pkg_x_test.go --
    +package pkg_test
    +
    +import (
    +	"runtime"
    +	"testing"
    +
    +	"example.com/pkg"
    +)
    +
    +func TestMain(m *testing.M) {
    +	pkg.PrintFile()
    +	pkg.PrintFileForTest()
    +	PrintFileInXTest()
    +}
    +
    +func PrintFileInXTest() {
    +	_, file, _, _ := runtime.Caller(0)
    +	println(file)
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_trimpath_main.txt b/go/src/cmd/go/testdata/script/test_trimpath_main.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c07621245fbdfcdda6057277ec43ef27cb48730e
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_trimpath_main.txt
    @@ -0,0 +1,38 @@
    +[short] skip
    +
    +go test -trimpath -v .
    +! stdout '[/\\]pkg_test[/\\]'
    +stdout -count=2 '[/\\]pkg[/\\]'
    +
    +-- go.mod --
    +module example.com/pkg
    +
    +go 1.17
    +
    +-- main.go --
    +package main
    +
    +import "runtime"
    +
    +func PrintFile() {
    +	_, file, _, _ := runtime.Caller(0)
    +	println(file)
    +}
    +
    +-- main_test.go --
    +package main
    +
    +import (
    +	"runtime"
    +	"testing"
    +)
    +
    +func PrintFileForTest() {
    +	_, file, _, _ := runtime.Caller(0)
    +	println(file)
    +}
    +
    +func TestMain(m *testing.M) {
    +	PrintFile()
    +	PrintFileForTest()
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_trimpath_test_suffix.txt b/go/src/cmd/go/testdata/script/test_trimpath_test_suffix.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6cbad83bc78051199936e32cc4aec35a80e2a50f
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_trimpath_test_suffix.txt
    @@ -0,0 +1,40 @@
    +[short] skip
    +
    +go test -trimpath -v .
    +! stdout '[/\\]pkg_test_test[/\\]'
    +stdout -count=2 '[/\\]pkg_test[/\\]'
    +
    +-- go.mod --
    +module example.com/pkg_test
    +
    +go 1.17
    +
    +-- pkg.go --
    +package pkg_test
    +
    +import "runtime"
    +
    +func PrintFile() {
    +	_, file, _, _ := runtime.Caller(0)
    +	println(file)
    +}
    +
    +-- pkg_x_test.go --
    +package pkg_test_test
    +
    +import (
    +	"runtime"
    +	"testing"
    +
    +	"example.com/pkg_test"
    +)
    +
    +func PrintFileForTest() {
    +	_, file, _, _ := runtime.Caller(0)
    +	println(file)
    +}
    +
    +func TestMain(m *testing.M) {
    +	pkg_test.PrintFile()
    +	PrintFileForTest()
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_vendor.txt b/go/src/cmd/go/testdata/script/test_vendor.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c6a88b6fedee2b74ca87ed3f59ad88aa7c828dde
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_vendor.txt
    @@ -0,0 +1,57 @@
    +# In GOPATH mode, vendored packages can replace std packages.
    +env GO111MODULE=off
    +cd vend/hello
    +go test -v
    +stdout TestMsgInternal
    +stdout TestMsgExternal
    +
    +# In module mode, they cannot.
    +env GO111MODULE=on
    +! go test -mod=vendor
    +stderr 'undefined: strings.Msg'
    +
    +-- vend/hello/go.mod --
    +module vend/hello
    +
    +go 1.16
    +-- vend/hello/hello.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"strings" // really ../vendor/strings
    +)
    +
    +func main() {
    +	fmt.Printf("%s\n", strings.Msg)
    +}
    +-- vend/hello/hello_test.go --
    +package main
    +
    +import (
    +	"strings" // really ../vendor/strings
    +	"testing"
    +)
    +
    +func TestMsgInternal(t *testing.T) {
    +	if strings.Msg != "hello, world" {
    +		t.Fatalf("unexpected msg: %v", strings.Msg)
    +	}
    +}
    +-- vend/hello/hellox_test.go --
    +package main_test
    +
    +import (
    +	"strings" // really ../vendor/strings
    +	"testing"
    +)
    +
    +func TestMsgExternal(t *testing.T) {
    +	if strings.Msg != "hello, world" {
    +		t.Fatalf("unexpected msg: %v", strings.Msg)
    +	}
    +}
    +-- vend/vendor/strings/msg.go --
    +package strings
    +
    +var Msg = "hello, world"
    diff --git a/go/src/cmd/go/testdata/script/test_vet.txt b/go/src/cmd/go/testdata/script/test_vet.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6151f912ae0db150eb1ede771f4628743d12e87a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_vet.txt
    @@ -0,0 +1,123 @@
    +[short] skip
    +
    +# Test file
    +! go test p1_test.go
    +stderr 'Logf format %d'
    +go test -vet=off
    +stdout '^ok'
    +
    +# Non-test file
    +! go test p1.go
    +stderr 'Printf format %d'
    +go test -x -vet=shift p1.go
    +stderr '[\\/]vet.*-shift'
    +stdout '\[no test files\]'
    +go test -vet=off p1.go
    +! stderr '[\\/]vet.*-shift'
    +stdout '\[no test files\]'
    +
    +# ensure all runs non-default vet
    +! go test -vet=all ./vetall/...
    +stderr 'using resp before checking for errors'
    +
    +# Test issue #47309
    +! go test -vet=bools,xyz ./vetall/...
    +stderr '-vet argument must be a supported analyzer'
    +
    +# Test with a single analyzer
    +! go test -vet=httpresponse ./vetall/...
    +stderr 'using resp before checking for errors'
    +
    +# Test with a list of analyzers
    +go test -vet=atomic,bools,nilfunc ./vetall/...
    +stdout 'm/vetall.*\[no tests to run\]'
    +
    +# Test issue #22890
    +go test m/vetcycle
    +stdout 'm/vetcycle.*\[no test files\]'
    +
    +# Test with ...
    +! go test ./vetfail/...
    +stderr 'Printf format %d'
    +stdout 'ok\s+m/vetfail/p2'
    +
    +# Check there's no diagnosis of a bad build constraint in vetxonly mode.
    +# Use -a so that we need to recompute the vet-specific export data for
    +# vetfail/p1.
    +go test -a m/vetfail/p2
    +! stderr 'invalid.*constraint'
    +
    +-- go.mod --
    +module m
    +
    +go 1.16
    +-- p1_test.go --
    +package p
    +
    +import "testing"
    +
    +func Test(t *testing.T) {
    +	t.Logf("%d") // oops
    +}
    +-- p1.go --
    +package p
    +
    +import "fmt"
    +
    +func F() {
    +	fmt.Printf("%d") // oops
    +}
    +-- vetall/p.go --
    +package p
    +
    +import "net/http"
    +
    +func F() {
    +	resp, err := http.Head("example.com")
    +	defer resp.Body.Close()
    +	if err != nil {
    +		panic(err)
    +	}
    +	// (defer statement belongs here)
    +}
    +-- vetall/p_test.go --
    +package p
    +-- vetcycle/p.go --
    +package p
    +
    +type (
    +	_  interface{ m(B1) }
    +	A1 interface{ a(D1) }
    +	B1 interface{ A1 }
    +	C1 interface {
    +		B1 /* ERROR issue #18395 */
    +	}
    +	D1 interface{ C1 }
    +)
    +
    +var _ A1 = C1 /* ERROR cannot use C1 */ (nil)
    +-- vetfail/p1/p1.go --
    +// +build !foo-bar
    +
    +package p1
    +
    +import "fmt"
    +
    +func F() {
    +	fmt.Printf("%d", "hello") // causes vet error
    +}
    +-- vetfail/p2/p2.go --
    +package p2
    +
    +import _ "m/vetfail/p1"
    +
    +func F() {
    +}
    +-- vetfail/p2/p2_test.go --
    +package p2
    +
    +import "testing"
    +
    +func TestF(t *testing.T) {
    +	F()
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_write_profiles_on_timeout.txt b/go/src/cmd/go/testdata/script/test_write_profiles_on_timeout.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..0db183f8f04f33aae08a9c4573f5472e099adef7
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_write_profiles_on_timeout.txt
    @@ -0,0 +1,26 @@
    +# Tests issue 19394
    +
    +[short] skip
    +
    +! go test -cpuprofile cpu.pprof -memprofile mem.pprof -timeout 1ms
    +stdout '^panic: test timed out'
    +grep . cpu.pprof
    +grep . mem.pprof
    +
    +-- go.mod --
    +module profiling
    +
    +go 1.16
    +-- timeout_test.go --
    +package timeouttest_test
    +
    +import (
    +	"testing"
    +	"time"
    +)
    +
    +func TestSleep(t *testing.T) {
    +	for {
    +		time.Sleep(1 * time.Second)
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/test_xtestonly_works.txt b/go/src/cmd/go/testdata/script/test_xtestonly_works.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8e150dbfc2571d685c3e9f5cee93dd8c190e710a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/test_xtestonly_works.txt
    @@ -0,0 +1,27 @@
    +[short] skip
    +
    +go test xtestonly
    +! stdout '^ok.*\[no tests to run\]'
    +stdout '^ok'
    +
    +-- go.mod --
    +module xtestonly
    +
    +go 1.16
    +-- f.go --
    +package xtestonly
    +
    +func F() int { return 42 }
    +-- f_test.go --
    +package xtestonly_test
    +
    +import (
    +	"testing"
    +	"xtestonly"
    +)
    +
    +func TestF(t *testing.T) {
    +	if x := xtestonly.F(); x != 42 {
    +		t.Errorf("f.F() = %d, want 42", x)
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/testing_coverage.txt b/go/src/cmd/go/testdata/script/testing_coverage.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..bf4dc83107b3b9f002187a38e6a10863b21507bb
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/testing_coverage.txt
    @@ -0,0 +1,56 @@
    +
    +# Rudimentary test of testing.Coverage().
    +
    +[short] skip
    +
    +# Simple test.
    +go test -v -cover -count=1
    +
    +# Make sure test still passes when test executable is built and
    +# run outside the go command.
    +go test -c -o t.exe -cover
    +exec ./t.exe
    +
    +-- go.mod --
    +module hello
    +
    +go 1.20
    +-- hello.go --
    +package hello
    +
    +func Hello() {
    +	println("hello")
    +}
    +
    +// contents not especially interesting, just need some code
    +func foo(n int) int {
    +	t := 0
    +	for i := 0; i < n; i++ {
    +		for j := 0; j < i; j++ {
    +			t += i ^ j
    +			if t == 1010101 {
    +				break
    +			}
    +		}
    +	}
    +	return t
    +}
    +
    +-- hello_test.go --
    +package hello
    +
    +import "testing"
    +
    +func TestTestCoverage(t *testing.T) {
    +	Hello()
    +	C1 := testing.Coverage()
    +	foo(29)
    +	C2 := testing.Coverage()
    +	if C1 == 0.0 || C2 == 0.0 {
    +		t.Errorf("unexpected zero values C1=%f C2=%f", C1, C2)
    +	}
    +	if C1 >= C2 {
    +		t.Errorf("testing.Coverage() not monotonically increasing C1=%f C2=%f", C1, C2)
    +	}
    +}
    +
    diff --git a/go/src/cmd/go/testdata/script/testing_issue40908.txt b/go/src/cmd/go/testdata/script/testing_issue40908.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..839320e4e8a105916acff09f94e12a0a5c23b349
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/testing_issue40908.txt
    @@ -0,0 +1,25 @@
    +[short] skip
    +[!race] skip
    +
    +go test -race testrace
    +
    +-- go.mod --
    +module testrace
    +
    +go 1.16
    +-- race_test.go --
    +package testrace
    +
    +import "testing"
    +
    +func TestRace(t *testing.T) {
    +	helperDone := make(chan struct{})
    +	go func() {
    +		t.Logf("Something happened before cleanup.")
    +		close(helperDone)
    +	}()
    +
    +	t.Cleanup(func() {
    +		<-helperDone
    +	})
    +}
    diff --git a/go/src/cmd/go/testdata/script/tool_build_as_needed.txt b/go/src/cmd/go/testdata/script/tool_build_as_needed.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e9bb8d34f356b3b575d455cdd2ca1e5e65888756
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/tool_build_as_needed.txt
    @@ -0,0 +1,54 @@
    +[short] skip 'builds and runs go programs'
    +[!symlink] skip 'uses symlinks to construct a GOROOT'
    +
    +env NEWGOROOT=$WORK${/}goroot
    +env TOOLDIR=$GOROOT/pkg/tool/${GOOS}_${GOARCH}
    +# Use ${/} in paths we'll check for in stdout below, so they contain '\' on Windows
    +env NEWTOOLDIR=$NEWGOROOT${/}pkg${/}tool${/}${GOOS}_${GOARCH}
    +mkdir $NEWGOROOT $NEWGOROOT/bin $NEWTOOLDIR
    +[symlink] symlink $NEWGOROOT/src -> $GOROOT/src
    +[symlink] symlink $NEWGOROOT/pkg/include -> $GOROOT/pkg/include
    +[symlink] symlink $NEWGOROOT/bin/go -> $GOROOT/bin/go
    +[symlink] symlink $NEWTOOLDIR/compile$GOEXE -> $TOOLDIR/compile$GOEXE
    +[symlink] symlink $NEWTOOLDIR/cgo$GOEXE -> $TOOLDIR/cgo$GOEXE
    +[symlink] symlink $NEWTOOLDIR/link$GOEXE -> $TOOLDIR/link$GOEXE
    +[symlink] symlink $NEWTOOLDIR/asm$GOEXE -> $TOOLDIR/asm$GOEXE
    +[symlink] symlink $NEWTOOLDIR/pack$GOEXE -> $TOOLDIR/pack$GOEXE
    +env GOROOT=$NEWGOROOT
    +env TOOLDIR=$NEWTOOLDIR
    +
    +# GOROOT without test2json tool builds and runs it as needed
    +go env GOROOT
    +! exists $TOOLDIR/test2json
    +go tool test2json
    +stdout '{"Action":"start"}'
    +! exists $TOOLDIR/test2json$GOEXE
    +go tool -n test2json
    +! stdout $NEWTOOLDIR${/}test2json$GOEXE
    +
    +# GOROOT with test2json uses the test2json in the GOROOT
    +go install cmd/test2json
    +exists $TOOLDIR/test2json$GOEXE
    +go tool test2json
    +stdout '{"Action":"start"}'
    +go tool -n test2json
    +stdout $NEWTOOLDIR${/}test2json$GOEXE
    +
    +# Tool still runs properly even with wrong GOOS/GOARCH
    +# Remove test2json from tooldir
    +rm $TOOLDIR/test2json$GOEXE
    +go tool -n test2json
    +! stdout $NEWTOOLDIR${/}test2json$GOEXE
    +# Set GOOS/GOARCH to different values than host GOOS/GOARCH.
    +env GOOS=js
    +env GOARCH=wasm
    +# Control case: go run shouldn't work because it respects
    +# GOOS/GOARCH, and we can't execute non-native binary.
    +# Don't actually run the binary because maybe we can.
    +# (Maybe the user has a go_js_wasm_exec installed.)
    +# Instead just look to see that the right binary got linked.
    +go run -n cmd/test2json
    +stderr modinfo.*GOARCH=wasm.*GOOS=js
    +# go tool should succeed because it doesn't respect GOOS/GOARCH.
    +go tool test2json
    +stdout '{"Action":"start"}'
    diff --git a/go/src/cmd/go/testdata/script/tool_exename.txt b/go/src/cmd/go/testdata/script/tool_exename.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a8dba8409f705747552f2aec975e0f7c13c7417a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/tool_exename.txt
    @@ -0,0 +1,79 @@
    +[short] skip 'runs go build'
    +
    +# First run: executable for bar is not cached.
    +# Make sure it's not called a.out
    +go tool bar
    +stdout 'my name is: bar'$GOEXE
    +! stdout 'a.out'
    +
    +# Second run: executable is cached. Make sure it
    +# has the right name.
    +go tool bar
    +stdout 'my name is: bar'$GOEXE
    +! stdout 'a.out'
    +
    +# Third run: with arguments
    +# https://go.dev/issue/70509
    +go tool bar --baz
    +stdout 'my name is: bar'$GOEXE
    +! stdout 'a.out'
    +
    +# Test tool package paths that end in v2
    +# to ensure we use the second to last component.
    +
    +# Don't use v2 as the short name of the tool.
    +! go tool v2
    +stderr 'go: no such tool "v2"'
    +
    +# Use the second to last component as the short
    +# name of the tool.
    +go tool foo
    +stdout 'my name is: foo'$GOEXE
    +
    +# go run should use the same name for the tool
    +# We need to use a fresh cache, or we'd end up with an executable cache hit
    +# from when we ran built the tool to run go tool above, and we'd just
    +# reuse the name from the test case above.
    +env GOCACHE=$WORK/cache2
    +go run example.com/foo/v2
    +stdout 'my name is: foo'$GOEXE
    +
    +-- go.mod --
    +module example.com/foo
    +
    +go 1.24
    +
    +tool example.com/foo/bar
    +tool example.com/foo/v2
    +
    +require example.com/foo/v2 v2.0.0
    +
    +replace example.com/foo/v2 => ./v2
    +-- bar/bar.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"os"
    +	"path/filepath"
    +)
    +
    +func main() {
    +	fmt.Println("my name is:", filepath.Base(os.Args[0]))
    +}
    +-- v2/go.mod --
    +module example.com/foo/v2
    +
    +go 1.24
    +-- v2/main.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"os"
    +	"path/filepath"
    +)
    +
    +func main() {
    +	fmt.Println("my name is:", filepath.Base(os.Args[0]))
    +}
    diff --git a/go/src/cmd/go/testdata/script/tool_n_issue72824.txt b/go/src/cmd/go/testdata/script/tool_n_issue72824.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..0c90fce290d286cb782fcf1ac3e0b7385eb9a5dc
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/tool_n_issue72824.txt
    @@ -0,0 +1,27 @@
    +[short] skip 'does a build in using an empty cache'
    +
    +# Start with a fresh cache because we want to verify the behavior
    +# when the tool hasn't been cached previously.
    +env GOCACHE=$WORK${/}cache
    +
    +# Even when the tool hasn't been previously cached but was built and
    +# saved to the cache in the invocation of 'go tool -n' we should return
    +# its cached location.
    +go tool -n foo
    +stdout $GOCACHE
    +
    +# And of course we should also return the cached location on subsequent
    +# runs.
    +go tool -n foo
    +stdout $GOCACHE
    +
    +-- go.mod --
    +module example.com/foo
    +
    +go 1.25
    +
    +tool example.com/foo
    +-- main.go --
    +package main
    +
    +func main() {}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/toolexec.txt b/go/src/cmd/go/testdata/script/toolexec.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..20a596805206c77191be491c7f1a81458e2c0bee
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/toolexec.txt
    @@ -0,0 +1,128 @@
    +[short] skip
    +
    +# Build our simple toolexec program.
    +go build ./cmd/mytool
    +
    +# Use an ephemeral build cache so that our toolexec output is not cached
    +# for any stale standard-library dependencies.
    +#
    +# TODO(#27628): This should not be necessary.
    +env GOCACHE=$WORK/gocache
    +
    +# Build the main package with our toolexec program. For each action, it will
    +# print the tool's name and the TOOLEXEC_IMPORTPATH value. We expect to compile
    +# each package once, and link the main package once.
    +# Don't check the entire output at once, because the order in which the tools
    +# are run is irrelevant here.
    +# Finally, note that asm and cgo are run twice.
    +
    +go build -toolexec=$PWD/mytool
    +[GOARCH:amd64] stderr -count=2 '^asm'${GOEXE}' TOOLEXEC_IMPORTPATH="test/main/withasm"$'
    +stderr -count=1 '^compile'${GOEXE}' TOOLEXEC_IMPORTPATH="test/main/withasm"$'
    +[cgo] stderr -count=2 '^cgo'${GOEXE}' TOOLEXEC_IMPORTPATH="test/main/withcgo"$'
    +[cgo] stderr -count=1 '^compile'${GOEXE}' TOOLEXEC_IMPORTPATH="test/main/withcgo"$'
    +stderr -count=1 '^compile'${GOEXE}' TOOLEXEC_IMPORTPATH="test/main"$'
    +stderr -count=1 '^link'${GOEXE}' TOOLEXEC_IMPORTPATH="test/main"$'
    +
    +# Test packages are a little bit trickier.
    +# We have four variants of test/main, as reported by 'go list -test':
    +#
    +#    test/main                        - the regular non-test package
    +#    test/main.test                   - the generated test program
    +#    test/main [test/main.test]       - the test package for foo_test.go
    +#    test/main_test [test/main.test]  - the test package for foo_separate_test.go
    +#
    +# As such, TOOLEXEC_IMPORTPATH must see the same strings, to be able to uniquely
    +# identify each package being built as reported by 'go list -f {{.ImportPath}}'.
    +# Note that these are not really "import paths" anymore, but that naming is
    +# consistent with 'go list -json' at least.
    +
    +go test -toolexec=$PWD/mytool
    +
    +stderr -count=2 '^# test/main\.test$'
    +stderr -count=1 '^compile'${GOEXE}' TOOLEXEC_IMPORTPATH="test/main\.test"$'
    +stderr -count=1 '^link'${GOEXE}' TOOLEXEC_IMPORTPATH="test/main\.test"$'
    +
    +stderr -count=1 '^# test/main \[test/main\.test\]$'
    +stderr -count=1 '^compile'${GOEXE}' TOOLEXEC_IMPORTPATH="test/main \[test/main\.test\]"$'
    +
    +stderr -count=1 '^# test/main_test \[test/main\.test\]$'
    +stderr -count=1 '^compile'${GOEXE}' TOOLEXEC_IMPORTPATH="test/main_test \[test/main\.test\]"$'
    +
    +-- go.mod --
    +module test/main
    +-- foo.go --
    +// Simple package so we can test a program build with -toolexec.
    +// With a dummy import, to test different TOOLEXEC_IMPORTPATH values.
    +// Includes dummy uses of cgo and asm, to cover those tools as well.
    +package main
    +
    +import (
    +	_ "test/main/withasm"
    +	_ "test/main/withcgo"
    +)
    +
    +func main() {}
    +-- foo_test.go --
    +package main
    +
    +import "testing"
    +
    +func TestFoo(t *testing.T) {}
    +-- foo_separate_test.go --
    +package main_test
    +
    +import "testing"
    +
    +func TestSeparateFoo(t *testing.T) {}
    +-- withcgo/withcgo.go --
    +package withcgo
    +
    +// int fortytwo()
    +// {
    +//     return 42;
    +// }
    +import "C"
    +-- withcgo/stub.go --
    +package withcgo
    +
    +// Stub file to ensure we build without cgo too.
    +-- withasm/withasm.go --
    +package withasm
    +
    +// Note that we don't need to declare the Add func at all.
    +-- withasm/withasm_amd64.s --
    +TEXT ·Add(SB),$0-24
    +	MOVQ a+0(FP), AX
    +	ADDQ b+8(FP), AX
    +	MOVQ AX, ret+16(FP)
    +	RET
    +-- cmd/mytool/main.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"os"
    +	"os/exec"
    +	"path/filepath"
    +)
    +
    +func main() {
    +	tool, args := os.Args[1], os.Args[2:]
    +	toolName := filepath.Base(tool)
    +	if len(args) > 0 && args[0] == "-V=full" {
    +		// We can't alter the version output.
    +	} else {
    +		// Print which tool we're running, and on what package.
    +		fmt.Fprintf(os.Stdout, "%s TOOLEXEC_IMPORTPATH=%q\n", toolName, os.Getenv("TOOLEXEC_IMPORTPATH"))
    +	}
    +
    +	// Simply run the tool.
    +	cmd := exec.Command(tool, args...)
    +	cmd.Stdout = os.Stdout
    +	cmd.Stderr = os.Stderr
    +	if err := cmd.Run(); err != nil {
    +		fmt.Fprintln(os.Stderr, err)
    +		os.Exit(1)
    +	}
    +}
    diff --git a/go/src/cmd/go/testdata/script/tooltags.txt b/go/src/cmd/go/testdata/script/tooltags.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a69b7a5c37b7463cb5d8d04a507296fe8116f078
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/tooltags.txt
    @@ -0,0 +1,82 @@
    +env GOOS=linux
    +
    +env GOARCH=amd64
    +env GOAMD64=v3
    +go list -f '{{context.ToolTags}}'
    +stdout 'amd64.v1 amd64.v2 amd64.v3'
    +
    +env GOARCH=arm
    +env GOARM=6
    +go list -f '{{context.ToolTags}}'
    +stdout 'arm.5 arm.6'
    +
    +env GOARCH=mips
    +env GOMIPS=hardfloat
    +go list -f '{{context.ToolTags}}'
    +stdout 'mips.hardfloat'
    +
    +env GOARCH=mips64
    +env GOMIPS=hardfloat
    +go list -f '{{context.ToolTags}}'
    +stdout 'mips64.hardfloat'
    +
    +env GOARCH=ppc64
    +env GOPPC64=power9
    +go list -f '{{context.ToolTags}}'
    +stdout 'ppc64.power8 ppc64.power9'
    +
    +env GOARCH=ppc64
    +env GOPPC64=power10
    +go list -f '{{context.ToolTags}}'
    +stdout 'ppc64.power8 ppc64.power9 ppc64.power10'
    +
    +env GOARCH=ppc64le
    +env GOPPC64=power9
    +go list -f '{{context.ToolTags}}'
    +stdout 'ppc64le.power8 ppc64le.power9'
    +
    +env GOARCH=ppc64le
    +env GOPPC64=power10
    +go list -f '{{context.ToolTags}}'
    +stdout 'ppc64le.power8 ppc64le.power9 ppc64le.power10'
    +
    +env GOARCH=riscv64
    +env GORISCV64=rva20u64
    +go list -f '{{context.ToolTags}}'
    +stdout 'riscv64.rva20u64'
    +
    +env GOARCH=riscv64
    +env GORISCV64=rva22u64
    +go list -f '{{context.ToolTags}}'
    +stdout 'riscv64.rva20u64 riscv64.rva22u64'
    +
    +env GOARCH=riscv64
    +env GORISCV64=rva23u64
    +go list -f '{{context.ToolTags}}'
    +stdout 'riscv64.rva20u64 riscv64.rva22u64 riscv64.rva23u64'
    +
    +env GOARCH=riscv64
    +env GORISCV64=rva22
    +! go list -f '{{context.ToolTags}}'
    +stderr 'go: invalid GORISCV64: must be rva20u64, rva22u64, rva23u64'
    +
    +env GOARCH=riscv64
    +env GORISCV64=
    +go list -f '{{context.ToolTags}}'
    +stdout 'riscv64.rva20u64'
    +
    +env GOARCH=386
    +env GO386=sse2
    +go list -f '{{context.ToolTags}}'
    +stdout '386.sse2'
    +
    +env GOARCH=wasm
    +env GOWASM=satconv
    +go list -f '{{context.ToolTags}}'
    +stdout 'wasm.satconv'
    +
    +-- go.mod --
    +module m
    +
    +-- p.go --
    +package p
    diff --git a/go/src/cmd/go/testdata/script/trampoline_reuse_test.txt b/go/src/cmd/go/testdata/script/trampoline_reuse_test.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..41e86e4d07ef9fd89ae4b8ad236174d7aad687e8
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/trampoline_reuse_test.txt
    @@ -0,0 +1,100 @@
    +# Verify PPC64 does not reuse a trampoline which is too far away.
    +# This tests an edge case where the direct call relocation addend should
    +# be ignored when computing the distance from the direct call to the
    +# already placed trampoline
    +[short] skip
    +[!GOARCH:ppc64] [!GOARCH:ppc64le] skip
    +[GOOS:aix] skip
    +
    +# Note, this program does not run. Presumably, 'DWORD $0' is simpler to
    +# assembly 2^26 or so times.
    +#
    +# We build something which should be laid out as such:
    +#
    +# bar.Bar
    +# main.Func1
    +# bar.Bar+400-tramp0
    +# main.BigAsm
    +# main.Func2
    +# bar.Bar+400-tramp1
    +#
    +# bar.Bar needs to be placed far enough away to generate relocations
    +# from main package calls. and main.Func1 and main.Func2 are placed
    +# a bit more than the direct call limit apart, but not more than 0x400
    +# bytes beyond it (to verify the reloc calc).
    +
    +go build
    +
    +-- go.mod --
    +
    +module foo
    +
    +go 1.19
    +
    +-- main.go --
    +
    +package main
    +
    +import "foo/bar"
    +
    +func Func1()
    +
    +func main() {
    +        Func1()
    +        bar.Bar2()
    +}
    +
    +-- foo.s --
    +
    +TEXT main·Func1(SB),0,$0-0
    +        CALL bar·Bar+0x400(SB)
    +        CALL main·BigAsm(SB)
    +// A trampoline will be placed here to bar.Bar
    +
    +// This creates a gap sufficiently large to prevent trampoline reuse
    +#define NOP64 DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0;
    +#define NOP256 NOP64 NOP64 NOP64 NOP64
    +#define NOP2S10 NOP256 NOP256 NOP256 NOP256
    +#define NOP2S12 NOP2S10 NOP2S10 NOP2S10 NOP2S10
    +#define NOP2S14 NOP2S12 NOP2S12 NOP2S12 NOP2S12
    +#define NOP2S16 NOP2S14 NOP2S14 NOP2S14 NOP2S14
    +#define NOP2S18 NOP2S16 NOP2S16 NOP2S16 NOP2S16
    +#define NOP2S20 NOP2S18 NOP2S18 NOP2S18 NOP2S18
    +#define NOP2S22 NOP2S20 NOP2S20 NOP2S20 NOP2S20
    +#define NOP2S24 NOP2S22 NOP2S22 NOP2S22 NOP2S22
    +#define BIGNOP NOP2S24 NOP2S24
    +TEXT main·BigAsm(SB),0,$0-0
    +        // Fill to the direct call limit so Func2 must generate a new trampoline.
    +        // As the implicit trampoline above is just barely unreachable.
    +        BIGNOP
    +        MOVD $main·Func2(SB), R3
    +
    +TEXT main·Func2(SB),0,$0-0
    +        CALL bar·Bar+0x400(SB)
    +// Another trampoline should be placed here.
    +
    +-- bar/bar.s --
    +
    +#define NOP64 DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0;
    +#define NOP256 NOP64 NOP64 NOP64 NOP64
    +#define NOP2S10 NOP256 NOP256 NOP256 NOP256
    +#define NOP2S12 NOP2S10 NOP2S10 NOP2S10 NOP2S10
    +#define NOP2S14 NOP2S12 NOP2S12 NOP2S12 NOP2S12
    +#define NOP2S16 NOP2S14 NOP2S14 NOP2S14 NOP2S14
    +#define NOP2S18 NOP2S16 NOP2S16 NOP2S16 NOP2S16
    +#define NOP2S20 NOP2S18 NOP2S18 NOP2S18 NOP2S18
    +#define NOP2S22 NOP2S20 NOP2S20 NOP2S20 NOP2S20
    +#define NOP2S24 NOP2S22 NOP2S22 NOP2S22 NOP2S22
    +#define BIGNOP NOP2S24 NOP2S24 NOP2S10
    +// A very big not very interesting function.
    +TEXT bar·Bar(SB),0,$0-0
    +        BIGNOP
    +
    +-- bar/bar.go --
    +
    +package bar
    +
    +func Bar()
    +
    +func Bar2() {
    +}
    diff --git a/go/src/cmd/go/testdata/script/vendor_complex.txt b/go/src/cmd/go/testdata/script/vendor_complex.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..290efdbd335590f3b64c0bd565df38514f08a317
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_complex.txt
    @@ -0,0 +1,75 @@
    +env GO111MODULE=off
    +
    +# smoke test for complex build configuration
    +go build -o complex.exe complex
    +[!cross] [exec:gccgo] go build -compiler=gccgo -o complex.exe complex
    +
    +-- complex/main.go --
    +package main
    +
    +import (
    +	_ "complex/nest/sub/test12"
    +	_ "complex/nest/sub/test23"
    +	"complex/w"
    +	"v"
    +)
    +
    +func main() {
    +	println(v.Hello + " " + w.World)
    +}
    +
    +-- complex/nest/sub/test12/p.go --
    +package test12
    +
    +// Check that vendor/v1 is used but vendor/v2 is NOT used (sub/vendor/v2 wins).
    +
    +import (
    +	"v1"
    +	"v2"
    +)
    +
    +const x = v1.ComplexNestVendorV1
    +const y = v2.ComplexNestSubVendorV2
    +
    +-- complex/nest/sub/test23/p.go --
    +package test23
    +
    +// Check that vendor/v3 is used but vendor/v2 is NOT used (sub/vendor/v2 wins).
    +
    +import (
    +	"v2"
    +	"v3"
    +)
    +
    +const x = v3.ComplexNestVendorV3
    +const y = v2.ComplexNestSubVendorV2
    +
    +-- complex/nest/sub/vendor/v2/v2.go --
    +package v2
    +
    +const ComplexNestSubVendorV2 = true
    +
    +-- complex/nest/vendor/v1/v1.go --
    +package v1
    +
    +const ComplexNestVendorV1 = true
    +
    +-- complex/nest/vendor/v2/v2.go --
    +package v2
    +
    +const ComplexNestVendorV2 = true
    +
    +-- complex/nest/vendor/v3/v3.go --
    +package v3
    +
    +const ComplexNestVendorV3 = true
    +
    +-- complex/vendor/v/v.go --
    +package v
    +
    +const Hello = "hello"
    +
    +-- complex/w/w.go --
    +package w
    +
    +const World = "world"
    diff --git a/go/src/cmd/go/testdata/script/vendor_gopath_issue11409.txt b/go/src/cmd/go/testdata/script/vendor_gopath_issue11409.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c85f67421a9d67de35d142ca2946840ff59bfd37
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_gopath_issue11409.txt
    @@ -0,0 +1,52 @@
    +[!GOOS:windows] [short] stop 'this test only applies to Windows'
    +env GO111MODULE=off
    +
    +go build run_go.go
    +exec ./run_go$GOEXE $GOPATH $GOPATH/src/vend/hello
    +stdout 'hello, world'
    +
    +-- run_go.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"os"
    +	"os/exec"
    +	"path/filepath"
    +	"strings"
    +)
    +
    +func changeVolume(s string, f func(s string) string) string {
    +	vol := filepath.VolumeName(s)
    +	return f(vol) + s[len(vol):]
    +}
    +
    +func main() {
    +	gopath := changeVolume(os.Args[1], strings.ToLower)
    +	dir := changeVolume(os.Args[2], strings.ToUpper)
    +	cmd := exec.Command("go", "run", "hello.go")
    +	cmd.Dir = dir
    +	cmd.Env = append(os.Environ(), "GOPATH="+gopath)
    +	cmd.Stdout = os.Stdout
    +	cmd.Stderr = os.Stderr
    +	if err := cmd.Run(); err != nil {
    +		fmt.Fprintln(os.Stderr, err)
    +		os.Exit(1)
    +	}
    +}
    +
    +-- vend/hello/hello.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"strings" // really ../vendor/strings
    +)
    +
    +func main() {
    +	fmt.Printf("%s\n", strings.Msg)
    +}
    +-- vend/vendor/strings/msg.go --
    +package strings
    +
    +var Msg = "hello, world"
    diff --git a/go/src/cmd/go/testdata/script/vendor_import.txt b/go/src/cmd/go/testdata/script/vendor_import.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c64af2c543f18c27e066c702ecb7e69f343d8a43
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_import.txt
    @@ -0,0 +1,106 @@
    +# Imports
    +env GO111MODULE=off
    +
    +# Pass -e to permit errors (e.g. bad.go, invalid.go)
    +go list -f  '{{.ImportPath}} {{.Imports}}' -e 'vend/...' 'vend/vendor/...' 'vend/x/vendor/...'
    +cmp stdout want_vendor_imports.txt
    +
    +-- want_vendor_imports.txt --
    +vend [vend/vendor/p r]
    +vend/dir1 []
    +vend/hello [fmt vend/vendor/strings]
    +vend/subdir [vend/vendor/p r]
    +vend/x [vend/x/vendor/p vend/vendor/q vend/x/vendor/r vend/dir1 vend/vendor/vend/dir1/dir2]
    +vend/x/invalid [vend/x/invalid/vendor/foo]
    +vend/vendor/p []
    +vend/vendor/q []
    +vend/vendor/strings []
    +vend/vendor/vend/dir1/dir2 []
    +vend/x/vendor/p []
    +vend/x/vendor/p/p [notfound]
    +vend/x/vendor/r []
    +-- vend/bad.go --
    +package vend
    +
    +import _ "r"
    +-- vend/dir1/dir1.go --
    +package dir1
    +-- vend/good.go --
    +package vend
    +
    +import _ "p"
    +-- vend/hello/hello.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"strings" // really ../vendor/strings
    +)
    +
    +func main() {
    +	fmt.Printf("%s\n", strings.Msg)
    +}
    +-- vend/hello/hello_test.go --
    +package main
    +
    +import (
    +	"strings" // really ../vendor/strings
    +	"testing"
    +)
    +
    +func TestMsgInternal(t *testing.T) {
    +	if strings.Msg != "hello, world" {
    +		t.Fatalf("unexpected msg: %v", strings.Msg)
    +	}
    +}
    +-- vend/hello/hellox_test.go --
    +package main_test
    +
    +import (
    +	"strings" // really ../vendor/strings
    +	"testing"
    +)
    +
    +func TestMsgExternal(t *testing.T) {
    +	if strings.Msg != "hello, world" {
    +		t.Fatalf("unexpected msg: %v", strings.Msg)
    +	}
    +}
    +-- vend/subdir/bad.go --
    +package subdir
    +
    +import _ "r"
    +-- vend/subdir/good.go --
    +package subdir
    +
    +import _ "p"
    +-- vend/vendor/p/p.go --
    +package p
    +-- vend/vendor/q/q.go --
    +package q
    +-- vend/vendor/strings/msg.go --
    +package strings
    +
    +var Msg = "hello, world"
    +-- vend/vendor/vend/dir1/dir2/dir2.go --
    +package dir2
    +-- vend/x/invalid/invalid.go --
    +package invalid
    +
    +import "vend/x/invalid/vendor/foo"
    +-- vend/x/vendor/p/p/p.go --
    +package p
    +
    +import _ "notfound"
    +-- vend/x/vendor/p/p.go --
    +package p
    +-- vend/x/vendor/r/r.go --
    +package r
    +-- vend/x/x.go --
    +package x
    +
    +import _ "p"
    +import _ "q"
    +import _ "r"
    +import _ "vend/dir1"      // not vendored
    +import _ "vend/dir1/dir2" // vendored
    diff --git a/go/src/cmd/go/testdata/script/vendor_import_missing.txt b/go/src/cmd/go/testdata/script/vendor_import_missing.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8e50dfe9d715170b586603dc165be46b608059a1
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_import_missing.txt
    @@ -0,0 +1,7 @@
    +# Missing package error message
    +! go build vend/x/vendor/p/p
    +
    +-- vend/x/vendor/p/p/p.go --
    +package p
    +
    +import _ "notfound"
    diff --git a/go/src/cmd/go/testdata/script/vendor_import_wrong.txt b/go/src/cmd/go/testdata/script/vendor_import_wrong.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..73bf5956400ce8b28dd115cfeb02d5c65121d335
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_import_wrong.txt
    @@ -0,0 +1,20 @@
    +# Wrong import path
    +env GO111MODULE=off
    +! go build vend/x/invalid
    +stderr 'must be imported as foo'
    +
    +env GO111MODULE=
    +cd vend/x/invalid
    +! go build vend/x/invalid
    +stderr 'must be imported as foo'
    +
    +-- vend/x/invalid/go.mod --
    +module vend/x/invalid
    +
    +go 1.16
    +
    +-- vend/x/invalid/invalid.go --
    +package invalid
    +
    +import "vend/x/invalid/vendor/foo"
    +
    diff --git a/go/src/cmd/go/testdata/script/vendor_internal.txt b/go/src/cmd/go/testdata/script/vendor_internal.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..4c0f1facee9877855f23d419a693cbd28fc459aa
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_internal.txt
    @@ -0,0 +1,16 @@
    +go build ./vendor/foo.com/internal/bar/a
    +
    +-- go.mod --
    +module example.com/x
    +go 1.19
    +
    +require "foo.com/internal/bar" v1.0.0
    +-- vendor/modules.txt --
    +# foo.com/internal/bar v1.0.0
    +## explicit
    +foo.com/internal/bar/a
    +-- vendor/foo.com/internal/bar/a/a.go --
    +package a
    +import _ "foo.com/internal/bar/b"
    +-- vendor/foo.com/internal/bar/b/b.go --
    +package b
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/vendor_issue12156.txt b/go/src/cmd/go/testdata/script/vendor_issue12156.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..ac95c6d3dae1181993f8dbdbe8c2aee1ee91a2f8
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_issue12156.txt
    @@ -0,0 +1,16 @@
    +# Tests issue #12156, a former index out of range panic.
    +
    +env GO111MODULE=off
    +env GOPATH=$WORK/gopath/src/testvendor2 # vendor/x is directly in $GOPATH, not in $GOPATH/src
    +cd $WORK/gopath/src/testvendor2/src/p
    +
    +! go build p.go
    +! stderr panic # Make sure it doesn't panic
    +stderr 'cannot find package "x"'
    +
    +-- testvendor2/src/p/p.go --
    +package p
    +
    +import "x"
    +-- testvendor2/vendor/x/x.go --
    +package x
    diff --git a/go/src/cmd/go/testdata/script/vendor_list_issue11977.txt b/go/src/cmd/go/testdata/script/vendor_list_issue11977.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f1ed6130632ca4a487c2f9624e13a4566c850dd3
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_list_issue11977.txt
    @@ -0,0 +1,87 @@
    +env GO111MODULE=off
    +
    +go list -f '{{join .TestImports "\n"}}' github.com/rsc/go-get-issue-11864/t
    +stdout 'go-get-issue-11864/vendor/vendor.org/p'
    +
    +go list -f '{{join .XTestImports "\n"}}' github.com/rsc/go-get-issue-11864/tx
    +stdout 'go-get-issue-11864/vendor/vendor.org/p'
    +
    +go list -f '{{join .XTestImports "\n"}}' github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2
    +stdout 'go-get-issue-11864/vendor/vendor.org/tx2'
    +
    +go list -f '{{join .XTestImports "\n"}}' github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx3
    +stdout 'go-get-issue-11864/vendor/vendor.org/tx3'
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/m.go --
    +package g
    +
    +import _ "vendor.org/p"
    +import _ "vendor.org/p1"
    +
    +func main() {}
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/t/t_test.go --
    +package t
    +
    +import _ "vendor.org/p"
    +import _ "vendor.org/p1"
    +import "testing"
    +
    +func TestNop(t *testing.T) {}
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/t/t.go --
    +package t
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/tx/tx_test.go --
    +package tx_test
    +
    +import _ "vendor.org/p"
    +import _ "vendor.org/p1"
    +import "testing"
    +
    +func TestNop(t *testing.T) {}
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/tx/tx.go --
    +package tx
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/p1/p1.go --
    +package p1 // import "vendor.org/p1"
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx3/tx3_test.go --
    +package tx3_test
    +
    +import "vendor.org/tx3"
    +import "testing"
    +
    +var Found = tx3.Exported
    +
    +func TestNop(t *testing.T) {}
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx3/export_test.go --
    +package tx3
    +
    +var Exported = true
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx3/tx3.go --
    +package tx3
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2/tx2_test.go --
    +package tx2_test
    +
    +import . "vendor.org/tx2"
    +import "testing"
    +
    +var Found = Exported
    +
    +func TestNop(t *testing.T) {}
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2/export_test.go --
    +package tx2
    +
    +var Exported = true
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2/tx2.go --
    +package tx2
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/p/p.go --
    +package p
    diff --git a/go/src/cmd/go/testdata/script/vendor_outside_module.txt b/go/src/cmd/go/testdata/script/vendor_outside_module.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..3ad45790e69fea4e788113b2f56e9626e5b9c907
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_outside_module.txt
    @@ -0,0 +1,36 @@
    +# baz.go (importing just fmt) works with -mod=mod,  -mod=vendor.
    +go build -x -mod=mod my-module/vendor/example.com/another-module/foo/bar/baz.go
    +go build -x -mod=readonly my-module/vendor/example.com/another-module/foo/bar/baz.go
    +go build -x -mod=vendor my-module/vendor/example.com/another-module/foo/bar/baz.go
    +
    +# baz_with_outside_dep.go (with a non-std dependency) works with -mod=mod
    +# but not with -mod=readonly and -mod=vendor.
    +go build -x -mod=mod my-module/vendor/example.com/another-module/foo/bar/baz_with_outside_dep.go
    +! go build -x -mod=readonly my-module/vendor/example.com/another-module/foo/bar/baz_with_outside_dep.go
    +stderr 'no required module provides package rsc.io/quote'
    +! go build -x -mod=vendor my-module/vendor/example.com/another-module/foo/bar/baz_with_outside_dep.go
    +stderr 'no required module provides package rsc.io/quote'
    +
    +-- my-module/go.mod --
    +module example.com/my-module
    +
    +go 1.20
    +-- my-module/vendor/example.com/another-module/foo/bar/baz.go --
    +package main
    +
    +import "fmt"
    +
    +func main() {
    +	fmt.Println("hello, world.")
    +}
    +-- my-module/vendor/example.com/another-module/foo/bar/baz_with_outside_dep.go --
    +package main
    +
    +import (
    +    "fmt"
    +    "rsc.io/quote"
    +)
    +
    +func main() {
    +	fmt.Println(quote.Hello())
    +}
    diff --git a/go/src/cmd/go/testdata/script/vendor_resolve.txt b/go/src/cmd/go/testdata/script/vendor_resolve.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..bc8cf0ab3826c4ac7c03d046be810c30a298a9b6
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_resolve.txt
    @@ -0,0 +1,21 @@
    +env GO111MODULE=off
    +! go build p
    +stderr 'must be imported as x'
    +
    +-- p/p.go --
    +package p
    +
    +import (
    +	_ "q/y"
    +	_ "q/z"
    +)
    +-- q/vendor/x/x.go --
    +package x
    +-- q/y/y.go --
    +package y
    +
    +import _ "x"
    +-- q/z/z.go --
    +package z
    +
    +import _ "q/vendor/x"
    diff --git a/go/src/cmd/go/testdata/script/vendor_test_issue11864.txt b/go/src/cmd/go/testdata/script/vendor_test_issue11864.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..90c9c59d793f929df240edfa03f1657c967bbe53
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_test_issue11864.txt
    @@ -0,0 +1,83 @@
    +[short] skip
    +env GO111MODULE=off
    +
    +# test should work too
    +go test github.com/rsc/go-get-issue-11864
    +go test github.com/rsc/go-get-issue-11864/t
    +
    +# external tests should observe internal test exports (golang.org/issue/11977)
    +go test github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/m.go --
    +package g
    +
    +import _ "vendor.org/p"
    +import _ "vendor.org/p1"
    +
    +func main() {}
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/t/t_test.go --
    +package t
    +
    +import _ "vendor.org/p"
    +import _ "vendor.org/p1"
    +import "testing"
    +
    +func TestNop(t *testing.T) {}
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/t/t.go --
    +package t
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/tx/tx_test.go --
    +package tx_test
    +
    +import _ "vendor.org/p"
    +import _ "vendor.org/p1"
    +import "testing"
    +
    +func TestNop(t *testing.T) {}
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/tx/tx.go --
    +package tx
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/p1/p1.go --
    +package p1 // import "vendor.org/p1"
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx3/tx3_test.go --
    +package tx3_test
    +
    +import "vendor.org/tx3"
    +import "testing"
    +
    +var Found = tx3.Exported
    +
    +func TestNop(t *testing.T) {}
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx3/export_test.go --
    +package tx3
    +
    +var Exported = true
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx3/tx3.go --
    +package tx3
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2/tx2_test.go --
    +package tx2_test
    +
    +import . "vendor.org/tx2"
    +import "testing"
    +
    +var Found = Exported
    +
    +func TestNop(t *testing.T) {}
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2/export_test.go --
    +package tx2
    +
    +var Exported = true
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/tx2/tx2.go --
    +package tx2
    +
    +-- $GOPATH/src/github.com/rsc/go-get-issue-11864/vendor/vendor.org/p/p.go --
    +package p
    diff --git a/go/src/cmd/go/testdata/script/vendor_test_issue14613.txt b/go/src/cmd/go/testdata/script/vendor_test_issue14613.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..d2f05c95aa17103ad5582d0dc26ebad1f2ab8e52
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vendor_test_issue14613.txt
    @@ -0,0 +1,52 @@
    +[short] skip
    +env GO111MODULE=off
    +
    +# test folder should work
    +go test github.com/clsung/go-vendor-issue-14613
    +
    +# test with specified _test.go should work too
    +cd $GOPATH/src
    +go test github.com/clsung/go-vendor-issue-14613/vendor_test.go
    +
    +# test with imported and not used
    +! go test github.com/clsung/go-vendor-issue-14613/vendor/mylibtesttest/myapp/myapp_test.go
    +stderr 'imported and not used'
    +
    +-- $GOPATH/src/github.com/clsung/go-vendor-issue-14613/./vendor_test.go --
    +package main
    +
    +import (
    +	"testing"
    +
    +	"github.com/clsung/fake"
    +)
    +
    +func TestVendor(t *testing.T) {
    +	ret := fake.DoNothing()
    +	expected := "Ok"
    +	if expected != ret {
    +		t.Errorf("fake returned %q, expected %q", ret, expected)
    +	}
    +}
    +
    +-- $GOPATH/src/github.com/clsung/go-vendor-issue-14613/./vendor/mylibtesttest/myapp/myapp_test.go --
    +package myapp
    +import (
    +   "mylibtesttest/rds"
    +)
    +
    +-- $GOPATH/src/github.com/clsung/go-vendor-issue-14613/./vendor/mylibtesttest/rds/rds.go --
    +package rds
    +
    +-- $GOPATH/src/github.com/clsung/go-vendor-issue-14613/./vendor/github.com/clsung/fake/fake.go --
    +package fake
    +
    +func DoNothing() string {
    +	return "Ok"
    +}
    +
    +-- $GOPATH/src/github.com/clsung/go-vendor-issue-14613/./m.go --
    +package main
    +
    +func main() {}
    +
    diff --git a/go/src/cmd/go/testdata/script/version.txt b/go/src/cmd/go/testdata/script/version.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..722859f25867e7b98e5d3e56c75fe32d7c00f307
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version.txt
    @@ -0,0 +1,110 @@
    +# Without arguments, we just print Go's own version.
    +go version
    +stdout '^go version'
    +
    +# Flags without files, or paths to missing files, should error.
    +! go version missing.exe
    +! go version -m
    +stderr 'with arguments'
    +! go version -v
    +stderr 'with arguments'
    +! go version -json
    +stderr 'with arguments'
    +
    +# Check that 'go version' succeed even when it does not contain Go build info.
    +# It should print an error if the file has a known Go binary extension.
    +#
    +go version empty.txt
    +! stdout .
    +! stderr .
    +go version empty.exe
    +stderr 'could not read Go build info'
    +go version empty.so
    +stderr 'could not read Go build info'
    +go version empty.dll
    +stderr 'could not read Go build info'
    +
    +# Neither of the three flags above should be an issue via GOFLAGS.
    +env GOFLAGS='-m -v -json'
    +go version
    +stdout '^go version'
    +env GOFLAGS=
    +
    +env GO111MODULE=on
    +
    +# Check that very basic version lookup succeeds.
    +go build empty.go
    +go version empty$GOEXE
    +[cgo] go build -ldflags=-linkmode=external empty.go
    +[cgo] go version empty$GOEXE
    +
    +# Skip the remaining builds if we are running in short mode.
    +[short] skip
    +
    +# Check that 'go version' and 'go version -m' work on a binary built in module mode.
    +go get rsc.io/fortune
    +go build -o fortune.exe rsc.io/fortune
    +go version fortune.exe
    +stdout '^fortune.exe: .+'
    +go version -m fortune.exe
    +stdout -buildmode=exe
    +stdout '^\tpath\trsc.io/fortune'
    +stdout '^\tmod\trsc.io/fortune\tv1.0.0'
    +
    +# Check the build info of a binary built from $GOROOT/src/cmd
    +go build -o test2json.exe cmd/test2json
    +go version -m test2json.exe
    +stdout -buildmode=exe
    +stdout '^test2json.exe: .+'
    +stdout '^\tpath\tcmd/test2json$'
    +! stdout 'mod[^e]'
    +
    +# Check -json flag
    +go build -o test2json.exe cmd/test2json
    +go version -m -json test2json.exe
    +stdout '"Path": "cmd/test2json"'
    +! stdout 'null'
    +
    +# Check -json flag output with multiple binaries
    +go build -o test2json.exe cmd/test2json
    +go version -m -json test2json.exe test2json.exe
    +stdout -count=2 '"Path": "cmd/test2json"'
    +
    +# Check -json flag without -m
    +go build -o test2json.exe cmd/test2json
    +! go version -json test2json.exe
    +! stdout '"Path": "cmd/test2json"'
    +stderr 'with -json flag requires -m flag'
    +
    +# Repeat the test with -buildmode=pie and default linking.
    +[!buildmode:pie] stop
    +[pielinkext] [!cgo] stop
    +go build -buildmode=pie -o external.exe rsc.io/fortune
    +go version external.exe
    +stdout '^external.exe: .+'
    +go version -m external.exe
    +stdout -buildmode=pie
    +stdout '^\tpath\trsc.io/fortune'
    +stdout '^\tmod\trsc.io/fortune\tv1.0.0'
    +
    +# Also test PIE with internal linking.
    +[pielinkext] stop
    +go build -buildmode=pie -ldflags=-linkmode=internal -o internal.exe rsc.io/fortune
    +go version internal.exe
    +stdout '^internal.exe: .+'
    +go version -m internal.exe
    +stdout -buildmode=pie
    +stdout '^\tpath\trsc.io/fortune'
    +stdout '^\tmod\trsc.io/fortune\tv1.0.0'
    +
    +-- go.mod --
    +module m
    +
    +-- empty.go --
    +package main
    +func main(){}
    +
    +-- empty.txt --
    +-- empty.exe --
    +-- empty.so --
    +-- empty.dll --
    diff --git a/go/src/cmd/go/testdata/script/version_build_settings.txt b/go/src/cmd/go/testdata/script/version_build_settings.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..cd3f5cfed2c7c960061a45520bd24e6356c2fa6b
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_build_settings.txt
    @@ -0,0 +1,89 @@
    +[short] skip
    +
    +# Compiler name is always added.
    +go build
    +go version -m m$GOEXE
    +stdout '^\tbuild\t-compiler=gc$'
    +stdout '^\tbuild\tGOOS='
    +stdout '^\tbuild\tGOARCH='
    +[GOARCH:amd64] stdout '^\tbuild\tGOAMD64='
    +! stdout asmflags|gcflags|ldflags|gccgoflags
    +
    +# Toolchain flags are added if present.
    +# The raw flags are included, with package patterns if specified.
    +go build -asmflags=example.com/m=-D=FOO=bar
    +go version -m m$GOEXE
    +stdout '^\tbuild\t-asmflags=example\.com/m=-D=FOO=bar$'
    +
    +go build -gcflags=example.com/m=-N
    +go version -m m$GOEXE
    +stdout '^\tbuild\t-gcflags=example\.com/m=-N$'
    +
    +go build -ldflags=example.com/m=-w
    +go version -m m$GOEXE
    +stdout '^\tbuild\t-ldflags=example\.com/m=-w$'
    +
    +go build -trimpath
    +go version -m m$GOEXE
    +stdout '\tbuild\t-trimpath=true$'
    +
    +# gccgoflags are not added when gc is used, and vice versa.
    +# TODO: test gccgo.
    +go build -gccgoflags=all=UNUSED
    +go version -m m$GOEXE
    +! stdout gccgoflags
    +
    +# Build and tool tags are added but not release tags.
    +# "race" is included with build tags but not "cgo".
    +go build -tags=a,b
    +go version -m m$GOEXE
    +stdout '^\tbuild\t-tags=a,b$'
    +[race] go build -race
    +[race] go version -m m$GOEXE
    +[race] ! stdout '^\tbuild\t-tags='
    +[race] stdout '^\tbuild\t-race=true$'
    +
    +# CGO flags are separate settings.
    +# CGO_ENABLED is always present.
    +# Other flags are added if CGO_ENABLED is true.
    +env CGO_ENABLED=0
    +go build
    +go version -m m$GOEXE
    +stdout '^\tbuild\tCGO_ENABLED=0$'
    +! stdout CGO_CPPFLAGS|CGO_CFLAGS|CGO_CXXFLAGS|CGO_LDFLAGS
    +
    +[cgo] env CGO_ENABLED=1
    +[cgo] env CGO_CPPFLAGS=-DFROM_CPPFLAGS=1
    +[cgo] env CGO_CFLAGS=-DFROM_CFLAGS=1
    +[cgo] env CGO_CXXFLAGS=-DFROM_CXXFLAGS=1
    +[cgo] env CGO_LDFLAGS=-L/extra/dir/does/not/exist
    +[cgo] go build '-ldflags=all=-linkmode=external -extldflags=-L/bonus/dir/does/not/exist'
    +[cgo] go version -m m$GOEXE
    +[cgo] stdout '^\tbuild\t-ldflags="all=-linkmode=external -extldflags=-L/bonus/dir/does/not/exist"$'
    +[cgo] stdout '^\tbuild\tCGO_ENABLED=1$'
    +[cgo] stdout '^\tbuild\tCGO_CPPFLAGS=-DFROM_CPPFLAGS=1$'
    +[cgo] stdout '^\tbuild\tCGO_CFLAGS=-DFROM_CFLAGS=1$'
    +[cgo] stdout '^\tbuild\tCGO_CXXFLAGS=-DFROM_CXXFLAGS=1$'
    +[cgo] stdout '^\tbuild\tCGO_LDFLAGS=-L/extra/dir/does/not/exist$'
    +
    +# https://go.dev/issue/52372: a cgo-enabled binary should not be stamped with
    +# CGO_ flags that contain paths.
    +[cgo] env CGO_ENABLED=1
    +[cgo] env CGO_CPPFLAGS=-DFROM_CPPFLAGS=1
    +[cgo] env CGO_CFLAGS=-DFROM_CFLAGS=1
    +[cgo] env CGO_CXXFLAGS=-DFROM_CXXFLAGS=1
    +[cgo] env CGO_LDFLAGS=-L/extra/dir/does/not/exist
    +[cgo] go build -trimpath '-ldflags=all=-linkmode=external -extldflags=-L/bonus/dir/does/not/exist'
    +[cgo] go version -m m$GOEXE
    +[cgo] ! stdout '/extra/dir/does/not/exist'
    +[cgo] ! stdout '/bonus/dir/does/not/exist'
    +[cgo] stdout '^\tbuild\tCGO_ENABLED=1$'
    +
    +-- go.mod --
    +module example.com/m
    +
    +go 1.18
    +-- m.go --
    +package main
    +
    +func main() {}
    diff --git a/go/src/cmd/go/testdata/script/version_buildvcs_bzr.txt b/go/src/cmd/go/testdata/script/version_buildvcs_bzr.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..fd0b80c40a9eaf0ea17b5ec22bb724fe6378383f
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_buildvcs_bzr.txt
    @@ -0,0 +1,129 @@
    +# This test checks that VCS information is stamped into Go binaries by default,
    +# controlled with -buildvcs. This test focuses on Bazaar specifics.
    +# The Git test covers common functionality.
    +
    +[short] skip
    +[!bzr] skip 'requires a working bzr client'
    +env GOBIN=$WORK/gopath/bin
    +env oldpath=$PATH
    +env HOME=$WORK
    +cd repo/a
    +exec bzr whoami 'J.R. Gopher '
    +
    +# If there's no local repository, there's no VCS info.
    +go install
    +go version -m $GOBIN/a$GOEXE
    +! stdout bzrrevision
    +stdout '^\tmod\texample.com/a\t\(devel\)'
    +rm $GOBIN/a$GOEXE
    +
    +# If there is a repository, but it can't be used for some reason,
    +# there should be an error. It should hint about -buildvcs=false.
    +cd ..
    +mkdir .bzr
    +env PATH=$WORK${/}fakebin${:}$oldpath
    +chmod 0755 $WORK/fakebin/bzr
    +! exec bzr help
    +cd a
    +! go install
    +stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$'
    +rm $GOBIN/a$GOEXE
    +cd ..
    +env PATH=$oldpath
    +rm .bzr
    +
    +# If there is an empty repository in a parent directory, only "modified" is tagged.
    +exec bzr init
    +cd a
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs=bzr$'
    +! stdout vcs.revision
    +! stdout vcs.time
    +stdout '^\tbuild\tvcs.modified=true$'
    +cd ..
    +
    +# Revision and commit time are tagged for repositories with commits.
    +exec bzr add a README go.mod
    +exec bzr commit -m 'initial commit'
    +cd a
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs=bzr$'
    +stdout '^\tbuild\tvcs.revision='
    +stdout '^\tbuild\tvcs.time='
    +stdout '^\tbuild\tvcs.modified=false$'
    +stdout '^\tmod\texample.com/a\tv0.0.0-\d+-\d+\t+'
    +rm $GOBIN/a$GOEXE
    +
    +# Tag is reflected in the version.
    +cd ..
    +cp README README2
    +exec bzr add a README2
    +exec bzr commit -m 'second commit'
    +exec bzr tag a/v1.2.3
    +cd a
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs=bzr$'
    +stdout '^\tbuild\tvcs.revision='
    +stdout '^\tbuild\tvcs.time='
    +stdout '^\tbuild\tvcs.modified=false$'
    +stdout '^\tmod\texample.com/a\tv1.2.3\t+'
    +rm $GOBIN/a$GOEXE
    +
    +# Building an earlier commit should still build clean.
    +cp ../../outside/empty.txt ../NEWS
    +exec bzr add ../NEWS
    +exec bzr commit -m 'add NEWS'
    +exec bzr update -r1
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs=bzr$'
    +stdout '^\tbuild\tvcs.revision='
    +stdout '^\tbuild\tvcs.time='
    +stdout '^\tbuild\tvcs.modified=false$'
    +
    +# Building with -buildvcs=false suppresses the info.
    +go install -buildvcs=false
    +go version -m $GOBIN/a$GOEXE
    +! stdout vcs.revision
    +rm $GOBIN/a$GOEXE
    +
    +# An untracked file is shown as modified, even if it isn't part of the build.
    +cp ../../outside/empty.txt .
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.modified=true$'
    +rm empty.txt
    +rm $GOBIN/a$GOEXE
    +
    +# An edited file is shown as modified, even if it isn't part of the build.
    +cp ../../outside/empty.txt ../README
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.modified=true$'
    +exec bzr revert ../README
    +rm $GOBIN/a$GOEXE
    +
    +-- $WORK/fakebin/bzr --
    +#!/bin/sh
    +exit 1
    +-- $WORK/fakebin/bzr.bat --
    +exit 1
    +-- repo/README --
    +Far out in the uncharted backwaters of the unfashionable end of the western
    +spiral arm of the Galaxy lies a small, unregarded yellow sun.
    +-- repo/go.mod --
    +module example.com
    +
    +go 1.18
    +-- repo/a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +-- repo/a/a.go --
    +package main
    +
    +func main() {}
    +-- outside/empty.txt --
    diff --git a/go/src/cmd/go/testdata/script/version_buildvcs_fossil.txt b/go/src/cmd/go/testdata/script/version_buildvcs_fossil.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..bd6b89d97aa5fe3569893c7d4c8d27d12151389e
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_buildvcs_fossil.txt
    @@ -0,0 +1,94 @@
    +# This test checks that VCS information is stamped into Go binaries by default,
    +# controlled with -buildvcs. This test focuses on Fossil specifics.
    +# The Git test covers common functionality.
    +
    +# "fossil" is the Fossil file server on Plan 9.
    +[GOOS:plan9] skip
    +[!exec:fossil] skip
    +[short] skip
    +env GOBIN=$WORK/gopath/bin
    +env oldpath=$PATH
    +env HOME=$WORK
    +env USER=gopher
    +[!GOOS:windows] env fslckout=.fslckout
    +[GOOS:windows] env fslckout=_FOSSIL_
    +exec pwd
    +exec fossil init repo.fossil
    +cd repo/a
    +
    +# If there's no local repository, there's no VCS info.
    +go install
    +go version -m $GOBIN/a$GOEXE
    +! stdout vcs.revision
    +rm $GOBIN/a$GOEXE
    +
    +# If there is a repository, but it can't be used for some reason,
    +# there should be an error. It should hint about -buildvcs=false.
    +cd ..
    +mv fslckout $fslckout
    +env PATH=$WORK${/}fakebin${:}$oldpath
    +chmod 0755 $WORK/fakebin/fossil
    +! exec fossil help
    +cd a
    +! go install
    +stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$'
    +rm $GOBIN/a$GOEXE
    +cd ..
    +env PATH=$oldpath
    +rm $fslckout
    +
    +# Revision and commit time are tagged for repositories with commits.
    +exec fossil open ../repo.fossil -f
    +exec fossil add a README
    +exec fossil commit -m 'initial commit'
    +cd a
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs=fossil\n'
    +stdout '^\tbuild\tvcs.revision='
    +stdout '^\tbuild\tvcs.time='
    +stdout '^\tbuild\tvcs.modified=false$'
    +rm $GOBIN/a$GOEXE
    +
    +# Building with -buildvcs=false suppresses the info.
    +go install -buildvcs=false
    +go version -m $GOBIN/a$GOEXE
    +! stdout vcs.revision
    +rm $GOBIN/a$GOEXE
    +
    +# An untracked file is shown as modified, even if it isn't part of the build.
    +cp ../../outside/empty.txt .
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs=fossil\n'
    +stdout '^\tbuild\tvcs.modified=true$'
    +rm empty.txt
    +rm $GOBIN/a$GOEXE
    +
    +# An edited file is shown as modified, even if it isn't part of the build.
    +cp ../../outside/empty.txt ../README
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs=fossil\n'
    +stdout '^\tbuild\tvcs.modified=true$'
    +exec fossil revert ../README
    +rm $GOBIN/a$GOEXE
    +
    +-- $WORK/fakebin/fossil --
    +#!/bin/sh
    +exit 1
    +-- $WORK/fakebin/fossil.bat --
    +exit 1
    +-- repo/README --
    +Far out in the uncharted backwaters of the unfashionable end of the western
    +spiral arm of the Galaxy lies a small, unregarded yellow sun.
    +-- repo/fslckout --
    +-- repo/a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +-- repo/a/a.go --
    +package main
    +
    +func main() {}
    +-- outside/empty.txt --
    diff --git a/go/src/cmd/go/testdata/script/version_buildvcs_git.txt b/go/src/cmd/go/testdata/script/version_buildvcs_git.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a360b9d9b7aee6906f04e9db3bf57cbbb30fb579
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_buildvcs_git.txt
    @@ -0,0 +1,182 @@
    +# This test checks that VCS information is stamped into Go binaries by default,
    +# controlled with -buildvcs. This test focuses on Git. Other tests focus on
    +# other VCS tools but may not cover common functionality.
    +
    +[!git] skip
    +[short] skip
    +env GOBIN=$WORK/gopath/bin
    +env oldpath=$PATH
    +cd repo/a
    +
    +# If there's no local repository, there's no VCS info.
    +go install
    +go version -m $GOBIN/a$GOEXE
    +! stdout vcs.revision
    +rm $GOBIN/a$GOEXE
    +
    +# If there's an orphan .git file left by a git submodule, it's not a git
    +# repository, and there's no VCS info.
    +cd ../gitsubmodule
    +go install
    +go version -m $GOBIN/gitsubmodule$GOEXE
    +! stdout vcs.revision
    +rm $GOBIN/gitsubmodule$GOEXE
    +
    +# If there is a repository, but it can't be used for some reason,
    +# there should be an error. It should hint about -buildvcs=false.
    +# Also ensure that multiple errors are collected by "go list -e".
    +cd ..
    +mkdir .git
    +env PATH=$WORK${/}fakebin${:}$oldpath
    +chmod 0755 $WORK/fakebin/git
    +! exec git help
    +cd a
    +! go install
    +stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$'
    +go list -e -f '{{.ImportPath}}: {{.Error}}' ./...
    +stdout -count=1 '^example\.com/a: error obtaining VCS status'
    +stdout -count=1 '^example\.com/a/library: '
    +stdout -count=1 '^example\.com/a/othermain: error obtaining VCS status'
    +cd ..
    +env PATH=$oldpath
    +rm .git
    +
    +# If there is an empty repository in a parent directory, only "uncommitted" is tagged.
    +exec git init
    +exec git config user.email gopher@golang.org
    +exec git config user.name 'J.R. Gopher'
    +cd a
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs=git$'
    +stdout '^\tbuild\tvcs.modified=true$'
    +! stdout vcs.revision
    +! stdout vcs.time
    +rm $GOBIN/a$GOEXE
    +
    +# Revision and commit time are tagged for repositories with commits.
    +exec git add -A
    +exec git commit -m 'initial commit'
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.revision='
    +stdout '^\tbuild\tvcs.time='
    +stdout '^\tbuild\tvcs.modified=false$'
    +rm $GOBIN/a$GOEXE
    +
    +# Building with -buildvcs=false suppresses the info.
    +go install -buildvcs=false
    +go version -m $GOBIN/a$GOEXE
    +! stdout vcs.revision
    +rm $GOBIN/a$GOEXE
    +
    +# An untracked file is shown as uncommitted, even if it isn't part of the build.
    +cp ../../outside/empty.txt .
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.modified=true$'
    +rm empty.txt
    +rm $GOBIN/a$GOEXE
    +
    +# An edited file is shown as uncommitted, even if it isn't part of the build.
    +cp ../../outside/empty.txt ../README
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.modified=true$'
    +exec git checkout ../README
    +rm $GOBIN/a$GOEXE
    +
    +# If the build doesn't include any packages from the repository,
    +# there should be no VCS info.
    +go install example.com/cmd/a@v1.0.0
    +go version -m $GOBIN/a$GOEXE
    +! stdout vcs.revision
    +rm $GOBIN/a$GOEXE
    +
    +go mod edit -require=example.com/c@v0.0.0
    +go mod edit -replace=example.com/c@v0.0.0=../../outside/c
    +go install example.com/c
    +go version -m $GOBIN/c$GOEXE
    +! stdout vcs.revision
    +rm $GOBIN/c$GOEXE
    +exec git checkout go.mod
    +
    +# If the build depends on a package in the repository, but it's not in the
    +# main module, there should be no VCS info.
    +go mod edit -require=example.com/b@v0.0.0
    +go mod edit -replace=example.com/b@v0.0.0=../b
    +go mod edit -require=example.com/d@v0.0.0
    +go mod edit -replace=example.com/d@v0.0.0=../../outside/d
    +go install example.com/d
    +go version -m $GOBIN/d$GOEXE
    +! stdout vcs.revision
    +exec git checkout go.mod
    +rm $GOBIN/d$GOEXE
    +
    +# If we're loading multiple main packages,
    +# but they share the same VCS repository,
    +# we only need to execute VCS status commands once.
    +go list -x ./...
    +stdout -count=3 '^example.com'
    +stderr -count=1 '^git status'
    +stderr -count=1 '^git -c log.showsignature=false log'
    +
    +-- $WORK/fakebin/git --
    +#!/bin/sh
    +exit 1
    +-- $WORK/fakebin/git.bat --
    +exit 1
    +-- repo/README --
    +Far out in the uncharted backwaters of the unfashionable end of the western
    +spiral arm of the Galaxy lies a small, unregarded yellow sun.
    +-- repo/a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +-- repo/a/a.go --
    +package main
    +
    +func main() {}
    +-- repo/a/library/f.go --
    +package library
    +-- repo/a/othermain/f.go --
    +package main
    +
    +func main() {}
    +-- repo/b/go.mod --
    +module example.com/b
    +
    +go 1.18
    +-- repo/b/b.go --
    +package b
    +-- repo/gitsubmodule/.git --
    +gitdir: ../.git/modules/gitsubmodule
    +-- repo/gitsubmodule/go.mod --
    +module example.com/gitsubmodule
    +
    +go 1.18
    +-- repo/gitsubmodule/main.go --
    +package main
    +
    +func main() {}
    +-- outside/empty.txt --
    +-- outside/c/go.mod --
    +module example.com/c
    +
    +go 1.18
    +-- outside/c/main.go --
    +package main
    +
    +func main() {}
    +-- outside/d/go.mod --
    +module example.com/d
    +
    +go 1.18
    +
    +require example.com/b v0.0.0
    +-- outside/d/main.go --
    +package main
    +
    +import _ "example.com/b"
    +
    +func main() {}
    diff --git a/go/src/cmd/go/testdata/script/version_buildvcs_hg.txt b/go/src/cmd/go/testdata/script/version_buildvcs_hg.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..81dee5a9df78f052d4d6abe4d839280e038e40b6
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_buildvcs_hg.txt
    @@ -0,0 +1,133 @@
    +# This test checks that VCS information is stamped into Go binaries by default,
    +# controlled with -buildvcs. This test focuses on Mercurial specifics.
    +# The Git test covers common functionality.
    +
    +[!exec:hg] skip
    +[short] skip
    +env GOBIN=$WORK/gopath/bin
    +env oldpath=$PATH
    +env TZ=GMT
    +env HGRCPATH=$WORK/hgrc
    +cd repo/a
    +
    +# If there's no local repository, there's no VCS info.
    +go install
    +go version -m $GOBIN/a$GOEXE
    +! stdout hgrevision
    +stdout '\s+mod\s+example.com/a\s+\(devel\)'
    +rm $GOBIN/a$GOEXE
    +
    +# If there is a repository, but it can't be used for some reason,
    +# there should be an error. It should hint about -buildvcs=false.
    +cd ..
    +mkdir .hg
    +env PATH=$WORK${/}fakebin${:}$oldpath
    +chmod 0755 $WORK/fakebin/hg
    +! exec hg help
    +cd a
    +! go install
    +stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$'
    +rm $GOBIN/a$GOEXE
    +cd ..
    +env PATH=$oldpath
    +rm .hg
    +
    +# An empty repository or one explicitly updated to null uses the null cset ID,
    +# and the time is hard set to 1/1/70, regardless of the current time.
    +exec hg init
    +cd a
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.revision=0000000000000000000000000000000000000000$'
    +stdout '^\tbuild\tvcs.time=1970-01-01T00:00:00Z$'
    +stdout '^\tbuild\tvcs.modified=true$'
    +stdout '\s+mod\s+example.com/a\s\(devel\)\s+'
    +cd ..
    +
    +# Revision and commit time are tagged for repositories with commits.
    +exec hg add a README go.mod
    +exec hg commit -m 'initial commit' --user test-user --date '2024-07-31T01:21:27+00:00'
    +exec hg tag a/v1.2.3
    +# Switch back to the tagged branch.
    +# Tagging a commit causes a new commit to be created. (See https://repo.mercurial-scm.org/hg/help/revsets)
    +exec hg update '.~1'
    +cd a
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.revision=eae91df98b5dd3c4451accf64c683ddc3edff6a9$'
    +stdout '^\tbuild\tvcs.time=2024-07-31T01:21:27Z$'
    +stdout '^\tbuild\tvcs.modified=false$'
    +stdout '\s+mod\s+example.com/a\s+v1.2.3\s+'
    +rm $GOBIN/a$GOEXE
    +
    +# Add an extra commit and then back off of it to show that the hash is
    +# from the checked out revision, not the tip revision.
    +cp ../../outside/empty.txt .
    +exec hg ci -Am 'another commit' --user test-user --date '2024-08-01T19:24:38+00:00'
    +exec hg update --clean -r '.^'
    +
    +# Modified state is not thrown off by extra status output
    +exec hg bisect -v -g .
    +exec hg bisect -v -b '.^^'
    +exec hg status
    +stdout '^.+'
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.revision=eae91df98b5dd3c4451accf64c683ddc3edff6a9$'
    +stdout '^\tbuild\tvcs.time=2024-07-31T01:21:27Z$'
    +stdout '^\tbuild\tvcs.modified=false$'
    +stdout '\s+mod\s+example.com/a\s+v1.2.3\s+'
    +rm $GOBIN/a$GOEXE
    +
    +# Building with -buildvcs=false suppresses the info.
    +go install -buildvcs=false
    +go version -m $GOBIN/a$GOEXE
    +! stdout hgrevision
    +stdout '\s+mod\s+example.com/a\s+\(devel\)'
    +rm $GOBIN/a$GOEXE
    +
    +# An untracked file is shown as uncommitted, even if it isn't part of the build.
    +cp ../../outside/empty.txt .
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.modified=true$'
    +stdout '\s+mod\s+example.com/a\s+v1.2.3\+dirty\s+'
    +rm empty.txt
    +rm $GOBIN/a$GOEXE
    +
    +# An edited file is shown as uncommitted, even if it isn't part of the build.
    +cp ../../outside/empty.txt ../README
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.modified=true$'
    +stdout '\s+mod\s+example.com/a\s+v1.2.3\+dirty\s+'
    +exec hg revert ../README
    +rm $GOBIN/a$GOEXE
    +
    +-- $WORK/fakebin/hg --
    +#!/bin/sh
    +exit 1
    +-- $WORK/fakebin/hg.bat --
    +exit 1
    +-- repo/README --
    +Far out in the uncharted backwaters of the unfashionable end of the western
    +spiral arm of the Galaxy lies a small, unregarded yellow sun.
    +-- repo/go.mod --
    +module example.com
    +
    +go 1.18
    +-- repo/a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +-- repo/a/a.go --
    +package main
    +
    +func main() {}
    +-- $WORK/hgrc --
    +[ui]
    +# tweakdefaults is an opt-in that may print extra output in commands like
    +# status.  That can be disabled by setting HGPLAIN=1.
    +tweakdefaults = 1
    +
    +-- outside/empty.txt --
    diff --git a/go/src/cmd/go/testdata/script/version_buildvcs_nested.txt b/go/src/cmd/go/testdata/script/version_buildvcs_nested.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..22cd71c454b712161c47e0f2b2d8a63f80a77014
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_buildvcs_nested.txt
    @@ -0,0 +1,61 @@
    +[!git] skip
    +[!exec:hg] skip
    +[short] skip
    +env GOFLAGS='-n -buildvcs'
    +
    +# Create a root module in a root Git repository.
    +mkdir root
    +cd root
    +go mod init example.com/root
    +exec git init
    +
    +
    +# Nesting repositories in parent directories are an error, to prevent VCS injection.
    +# This can be disabled with the allowmultiplevcs GODEBUG.
    +mkdir hgsub
    +cd hgsub
    +exec hg init
    +cp ../../main.go main.go
    +! go build
    +stderr '^error obtaining VCS status: multiple VCS detected: hg in ".*hgsub", and git in ".*root"$'
    +stderr '^\tUse -buildvcs=false to disable VCS stamping.$'
    +env GODEBUG=allowmultiplevcs=1
    +! go build
    +stderr '^error obtaining VCS status: main module is in repository ".*root" but current directory is in repository ".*hgsub"$'
    +stderr '^\tUse -buildvcs=false to disable VCS stamping.$'
    +go build -buildvcs=false
    +env GODEBUG=
    +go mod init example.com/root/hgsub
    +! go build
    +stderr '^error obtaining VCS status: multiple VCS detected: hg in ".*hgsub", and git in ".*root"$'
    +stderr '^\tUse -buildvcs=false to disable VCS stamping.$'
    +env GODEBUG=allowmultiplevcs=1
    +go build
    +env GODEBUG=
    +cd ..
    +
    +# It's an error to build a package from a nested Git repository if the package
    +# is in a separate repository from the current directory or from the module
    +# root directory. Otherwise nested Git repositories are allowed, as this is
    +# how Git implements submodules (and protects against Git based VCS injection.)
    +mkdir gitsub
    +cd gitsub
    +exec git init
    +exec git config user.name 'J.R.Gopher'
    +exec git config user.email 'gopher@golang.org'
    +cp ../../main.go main.go
    +! go build
    +stderr '^error obtaining VCS status: main module is in repository ".*root" but current directory is in repository ".*gitsub"$'
    +go build -buildvcs=false
    +go mod init example.com/root/gitsub
    +exec git commit --allow-empty -m empty # status commands fail without this
    +go build
    +rm go.mod
    +cd ..
    +! go build ./gitsub
    +stderr '^error obtaining VCS status: main package is in repository ".*gitsub" but current directory is in repository ".*root"$'
    +go build -buildvcs=false -o=gitsub${/} ./gitsub
    +
    +-- main.go --
    +package main
    +func main() {}
    diff --git a/go/src/cmd/go/testdata/script/version_buildvcs_svn.txt b/go/src/cmd/go/testdata/script/version_buildvcs_svn.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8fc5f023db7909fcfd74b65990cee019638c82c0
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_buildvcs_svn.txt
    @@ -0,0 +1,96 @@
    +# This test checks that VCS information is stamped into Go binaries by default,
    +# controlled with -buildvcs. This test focuses on Subversion specifics.
    +# The Git test covers common functionality.
    +
    +[!exec:svn] skip
    +[!exec:svnadmin] skip
    +[short] skip
    +env GOBIN=$WORK/gopath/bin
    +env oldpath=$PATH
    +cd repo/a
    +
    +# If there's no local repository, there's no VCS info.
    +go install
    +go version -m $GOBIN/a$GOEXE
    +! stdout vcs.revision
    +stdout '\s+mod\s+example.com/a\s+\(devel\)'
    +rm $GOBIN/a$GOEXE
    +
    +# If there is a repository, but it can't be used for some reason,
    +# there should be an error. It should hint about -buildvcs=false.
    +cd ..
    +mkdir .svn
    +env PATH=$WORK${/}fakebin${:}$oldpath
    +chmod 0755 $WORK/fakebin/svn
    +! exec svn help
    +cd a
    +! go install
    +stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$'
    +rm $GOBIN/a$GOEXE
    +cd ..
    +env PATH=$oldpath
    +rm .svn
    +
    +# Untagged repo.
    +exec svnadmin create repo
    +exec svn checkout file://$PWD/repo workingDir
    +cd workingDir
    +cp ../a/a.go .
    +cp ../a/go.mod .
    +cp ../README .
    +exec svn status
    +exec svn add a.go go.mod README
    +exec svn commit -m 'initial commit'
    +exec svn update
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs=svn$'
    +stdout '^\tbuild\tvcs.revision=1$'
    +stdout '^\tbuild\tvcs.time='
    +stdout '^\tbuild\tvcs.modified=false$'
    +stdout '^\tmod\texample.com/a\tv0.0.0-\d+-\d+\t+'
    +rm $GOBIN/a$GOEXE
    +
    +# Building with -buildvcs=false suppresses the info.
    +go install -buildvcs=false
    +go version -m $GOBIN/a$GOEXE
    +! stdout vcs.revision
    +stdout '\s+mod\s+example.com/a\s+\(devel\)'
    +rm $GOBIN/a$GOEXE
    +
    +# An untracked file is shown as uncommitted, even if it isn't part of the build.
    +cp ../../outside/empty.txt extra.txt
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.modified=true$'
    +stdout '\s+mod\s+example.com/a\s+v0.0.0-\d+-\d+\+dirty\s+'
    +rm extra.txt
    +rm $GOBIN/a$GOEXE
    +
    +# An edited file is shown as uncommitted, even if it isn't part of the build.
    +cp ../../outside/empty.txt README
    +go install
    +go version -m $GOBIN/a$GOEXE
    +stdout '^\tbuild\tvcs.modified=true$'
    +stdout '\s+mod\s+example.com/a\s+v0.0.0-\d+-\d+\+dirty\s+'
    +exec svn revert README
    +rm $GOBIN/a$GOEXE
    +
    +-- $WORK/fakebin/svn --
    +#!/bin/sh
    +exit 1
    +-- $WORK/fakebin/svn.bat --
    +exit 1
    +-- repo/README --
    +Far out in the uncharted backwaters of the unfashionable end of the western
    +spiral arm of the Galaxy lies a small, unregarded yellow sun.
    +-- repo/a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +-- repo/a/a.go --
    +package main
    +
    +func main() {}
    +
    +-- outside/empty.txt --
    diff --git a/go/src/cmd/go/testdata/script/version_cshared.txt b/go/src/cmd/go/testdata/script/version_cshared.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..18f257f64ab8c04c66febe402606edfc99b077fc
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_cshared.txt
    @@ -0,0 +1,20 @@
    +[short] skip
    +[!cgo] skip '-buildmode=c-shared requires external linking'
    +[!buildmode:c-shared] stop
    +
    +env GO111MODULE=on
    +
    +go get rsc.io/fortune
    +go build -buildmode=c-shared -o external.so rsc.io/fortune
    +go version external.so
    +stdout '^external.so: .+'
    +go version -m external.so
    +stdout '^\tpath\trsc.io/fortune'
    +stdout '^\tmod\trsc.io/fortune\tv1.0.0'
    +
    +-- go.mod --
    +module m
    +
    +-- empty.go --
    +package main
    +func main(){}
    diff --git a/go/src/cmd/go/testdata/script/version_gc_sections.txt b/go/src/cmd/go/testdata/script/version_gc_sections.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..4bda23ba953605f1683d919cccc8c909756a5353
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_gc_sections.txt
    @@ -0,0 +1,24 @@
    +# This test checks that external linking with --gc-sections does not strip version information.
    +
    +[short] skip
    +[!cgo] skip
    +[GOOS:aix] skip  # no --gc-sections
    +[GOOS:darwin] skip  # no --gc-sections
    +
    +go build -ldflags='-linkmode=external -extldflags=-Wl,--gc-sections'
    +go version hello$GOEXE
    +! stdout 'not a Go executable'
    +! stderr 'not a Go executable'
    +
    +-- go.mod --
    +module hello
    +-- hello.go --
    +package main
    +
    +/*
    +*/
    +import "C"
    +
    +func main() {
    +	println("hello")
    +}
    diff --git a/go/src/cmd/go/testdata/script/version_goexperiment.txt b/go/src/cmd/go/testdata/script/version_goexperiment.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..23fc57d456d52c9792758f018957e7421cf03937
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_goexperiment.txt
    @@ -0,0 +1,24 @@
    +# Test that experiments appear in "go version "
    +
    +# This test requires rebuilding the runtime, which takes a while.
    +[short] skip
    +
    +env GOEXPERIMENT=fieldtrack
    +go build -o main$GOEXE version.go
    +go version main$GOEXE
    +stdout 'X:fieldtrack$'
    +exec ./main$GOEXE
    +stderr 'X:fieldtrack$'
    +
    +-- version.go --
    +package main
    +import (
    +	"go/version"
    +	"runtime"
    +)
    +func main() {
    +	if !version.IsValid(runtime.Version()) {
    +		panic("version not valid: "+runtime.Version())
    +	}
    +	println(runtime.Version())
    +}
    diff --git a/go/src/cmd/go/testdata/script/version_replace.txt b/go/src/cmd/go/testdata/script/version_replace.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..82b8504458be9af7fd5da4322c2b5fa7307bd605
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/version_replace.txt
    @@ -0,0 +1,33 @@
    +[short] skip
    +
    +go mod download example.com/printversion@v0.1.0 example.com/printversion@v1.0.0
    +go get example.com/printversion@v0.1.0
    +go install example.com/printversion
    +
    +go run example.com/printversion
    +cmp stdout out.txt
    +
    +go version -m $GOPATH/bin/printversion$GOEXE
    +stdout '^.*[/\\]bin[/\\]printversion'$GOEXE': .*$'
    +stdout '^	path	example.com/printversion$'
    +stdout '^	mod	example.com/printversion	v0.1.0$'
    +stdout '^	=>	example.com/printversion	v1.0.0	h1:.*$'
    +stdout '^	dep	example.com/version	v1.0.0$'
    +stdout '^	=>	example.com/version	v1.0.1	h1:.*$'
    +
    +-- go.mod --
    +module golang.org/issue/37392
    +go 1.14
    +require (
    +	example.com/printversion v0.1.0
    +)
    +replace (
    +	example.com/printversion => example.com/printversion v1.0.0
    +	example.com/version v1.0.0 => example.com/version v1.0.1
    +)
    +-- out.txt --
    +path is example.com/printversion
    +main is example.com/printversion v0.1.0
    +	(replaced by example.com/printversion v1.0.0)
    +using example.com/version v1.0.0
    +	(replaced by example.com/version v1.0.1)
    diff --git a/go/src/cmd/go/testdata/script/vet.txt b/go/src/cmd/go/testdata/script/vet.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6573ae3ebdffeaef50e901dd7fe3a4393653ecbb
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vet.txt
    @@ -0,0 +1,62 @@
    +# Package with external tests
    +! go vet m/vetpkg
    +stderr 'Printf'
    +
    +# With tags
    +! go vet -tags tagtest m/vetpkg
    +stderr 'c\.go.*Printf'
    +
    +# With flags on
    +! go vet -printf m/vetpkg
    +stderr 'Printf'
    +
    +# With flags off
    +go vet -printf=false m/vetpkg
    +! stderr .
    +
    +# With only test files (tests issue #23395)
    +go vet m/onlytest
    +! stderr .
    +
    +# With only cgo files (tests issue #24193)
    +[!cgo] skip
    +[short] skip
    +go vet m/onlycgo
    +! stderr .
    +
    +-- go.mod --
    +module m
    +
    +go 1.16
    +-- vetpkg/a_test.go --
    +package p_test
    +-- vetpkg/b.go --
    +package p
    +
    +import "fmt"
    +
    +func f() {
    +	fmt.Printf("%d")
    +}
    +-- vetpkg/c.go --
    +// +build tagtest
    +
    +package p
    +
    +import "fmt"
    +
    +func g() {
    +	fmt.Printf("%d", 3, 4)
    +}
    +-- onlytest/p_test.go --
    +package p
    +
    +import "testing"
    +
    +func TestMe(*testing.T) {}
    +-- onlycgo/p.go --
    +package p
    +
    +import "C"
    +
    +func F() {}
    diff --git a/go/src/cmd/go/testdata/script/vet_asm.txt b/go/src/cmd/go/testdata/script/vet_asm.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f29e5b7067e1e386ffe4694ff3b5ac617190da37
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vet_asm.txt
    @@ -0,0 +1,34 @@
    +# Issue 27665. Verify that "go vet" analyzes non-Go files.
    +
    +env GO111MODULE=off
    +env GOARCH=amd64
    +env GOOS=linux
    +
    +! go vet -asmdecl a
    +stderr 'f: invalid MOVW of x'
    +
    +# -c=n flag shows n lines of context
    +! go vet -c=2 -asmdecl a
    +stderr '...invalid MOVW...'
    +stderr '1	.*TEXT'
    +stderr '2		MOVW'
    +stderr '3		RET'
    +stderr '4'
    +
    +# -json causes success, even with diagnostics and errors,
    +# and writes to stdout.
    +go vet -json -asmdecl a
    +stdout '"a": {'
    +stdout   '"asmdecl":'
    +stdout     '"posn": ".*asm.s:2:1",'
    +stdout     '"message": ".*invalid MOVW.*"'
    +
    +-- a/a.go --
    +package a
    +
    +func f(x int8)
    +
    +-- a/asm.s --
    +TEXT ·f(SB),0,$0-1
    +	MOVW	x+0(FP), AX
    +	RET
    diff --git a/go/src/cmd/go/testdata/script/vet_basic.txt b/go/src/cmd/go/testdata/script/vet_basic.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..faff586fcb07b2a98e0a777f7cac8366446962fb
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vet_basic.txt
    @@ -0,0 +1,126 @@
    +# Test basic features of "go vet"/"go fix" CLI.
    +#
    +# The example relies on two analyzers:
    +# - hostport (which is included in both the fix and vet suites), and
    +# - printf (which is only in the vet suite).
    +# Each reports one diagnostic with a fix.
    +
    +# vet default flags print diagnostics to stderr. Diagnostic => nonzero exit.
    +! go vet example.com/x
    +stderr 'does not work with IPv6'
    +stderr 'non-constant format string in call to fmt.Sprintf'
    +
    +# -hostport runs only one analyzer. Diagnostic => failure.
    +! go vet -hostport example.com/x
    +stderr 'does not work with IPv6'
    +! stderr 'non-constant format string'
    +
    +# -timeformat runs only one analyzer. No diagnostics => success.
    +go vet -timeformat example.com/x
    +! stderr .
    +
    +# JSON output includes diagnostics and fixes. Always success.
    +go vet -json example.com/x
    +! stderr .
    +stdout '"example.com/x": {'
    +stdout '"hostport":'
    +stdout '"message": "address format .* does not work with IPv6",'
    +stdout '"suggested_fixes":'
    +stdout '"message": "Replace fmt.Sprintf with net.JoinHostPort",'
    +
    +# vet -fix -diff displays a diff. Diff => nonzero exit.
    +! go vet -fix -diff example.com/x
    +stdout '\-var _ = fmt.Sprintf\(s\)'
    +stdout '\+var _ = fmt.Sprintf\("%s", s\)'
    +stdout '\-var _, _ = net.Dial\("tcp", fmt.Sprintf\("%s:%d", s, 80\)\)'
    +stdout '\+var _, _ = net.Dial\("tcp", net.JoinHostPort\(s, "80"\)\)'
    +
    +# vet -fix quietly applies the vet suite fixes.
    +cp x.go x.go.bak
    +go vet -fix example.com/x
    +grep 'fmt.Sprintf\("%s", s\)' x.go
    +grep 'net.JoinHostPort' x.go
    +! stderr .
    +cp x.go.bak x.go
    +
    +! go vet -diff example.com/x
    +stderr 'go vet -diff flag requires -fix'
    +
    +# go fix applies the fix suite fixes.
    +go fix example.com/x
    +grep 'net.JoinHostPort' x.go
    +! grep 'fmt.Sprintf\("%s", s\)' x.go
    +! stderr .
    +cp x.go.bak x.go
    +
    +# Show diff of fixes from the fix suite. Diff => nonzero exit.
    +! go fix -diff example.com/x
    +! stdout '\-var _ = fmt.Sprintf\(s\)'
    +stdout '\-var _, _ = net.Dial\("tcp", fmt.Sprintf\("%s:%d", s, 80\)\)'
    +stdout '\+var _, _ = net.Dial\("tcp", net.JoinHostPort\(s, "80"\)\)'
    +
    +# Show fix-suite fixes in JSON form.
    +go fix -json example.com/x
    +! stderr .
    +stdout '"example.com/x": {'
    +stdout '"hostport":'
    +stdout '"message": "address format .* does not work with IPv6",'
    +stdout '"suggested_fixes":'
    +stdout '"message": "Replace fmt.Sprintf with net.JoinHostPort",'
    +! stdout '"printf":'
    +! stdout '"message": "non-constant format string.*",'
    +! stdout '"message": "Insert.*%s.*format.string",'
    +
    +# Show vet-suite fixes in JSON form.
    +go vet -fix -json example.com/x
    +! stderr .
    +stdout '"example.com/x": {'
    +stdout '"hostport":'
    +stdout '"message": "address format .* does not work with IPv6",'
    +stdout '"suggested_fixes":'
    +stdout '"message": "Replace fmt.Sprintf with net.JoinHostPort",'
    +stdout '"printf":'
    +stdout '"message": "non-constant format string.*",'
    +stdout '"suggested_fixes":'
    +stdout '"message": "Insert.*%s.*format.string",'
    +
    +# Reject -diff + -json.
    +! go fix -diff -json example.com/x
    +stderr '-json and -diff cannot be used together'
    +
    +# Legacy way of selecting fixers is a no-op.
    +go fix -fix=old1,old2 example.com/x
    +stderr 'go fix: the -fix=old1,old2 flag is obsolete and has no effect'
    +cp x.go.bak x.go
    +
    +# -c=n flag shows n lines of context.
    +! go vet -c=2 -printf example.com/x
    +stderr 'x.go:12:21: non-constant format string in call to fmt.Sprintf'
    +! stderr '9	'
    +stderr '10	'
    +stderr '11	// This call...'
    +stderr '12	var _ = fmt.Sprintf\(s\)'
    +stderr '13	'
    +stderr '14	'
    +! stderr '15	'
    +
    +-- go.mod --
    +module example.com/x
    +go 1.25
    +
    +-- x.go --
    +package x
    +
    +
    +import (
    +	"fmt"
    +	"net"
    +)
    +
    +var s string
    +
    +// This call yields a "non-constant format string" diagnostic, with a fix (go vet only).
    +var _ = fmt.Sprintf(s)
    +
    +// This call yields a hostport diagnostic, with a fix (go vet and go fix).
    +var _, _ = net.Dial("tcp", fmt.Sprintf("%s:%d", s, 80))
    diff --git a/go/src/cmd/go/testdata/script/vet_cache.txt b/go/src/cmd/go/testdata/script/vet_cache.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..624df5573240c12556d7196d9721c17ffa9ea774
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vet_cache.txt
    @@ -0,0 +1,26 @@
    +# Test that go vet's caching of vet tool actions replays
    +# the recorded stderr output even after a cache hit.
    +
    +[short] skip 'uses a fresh build cache'
    +
    +# Set up fresh GOCACHE.
    +env GOCACHE=$WORK/gocache
    +
    +# First time is a cache miss.
    +! go vet example.com/a
    +stderr 'fmt.Sprint call has possible Printf formatting directive'
    +
    +# Second time is assumed to be a cache hit for the stdout JSON,
    +# but we don't bother to assert it. Same diagnostics again.
    +! go vet example.com/a
    +stderr 'fmt.Sprint call has possible Printf formatting directive'
    +
    +-- go.mod --
    +module example.com
    +
    +-- a/a.go --
    +package a
    +
    +import "fmt"
    +
    +var _ = fmt.Sprint("%s") // oops!
    diff --git a/go/src/cmd/go/testdata/script/vet_commandline.txt b/go/src/cmd/go/testdata/script/vet_commandline.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..51e65bbca4856f8d92cb56be3319f06d04b7b6f6
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vet_commandline.txt
    @@ -0,0 +1,43 @@
    +# go.dev/issue/65612
    +# go vet should set the GoVersion for command line files.
    +
    +env TESTGO_VERSION=go1.22.1
    +env TESTGO_VERSION_SWITCH=switch
    +
    +go vet -n -json example.com/m
    +stderr '"GoVersion": "go1.22.0"'
    +
    +# A command line file should use the local go version.
    +go vet -n -json main.go
    +stderr '"GoVersion": "go1.22.1"'
    +
    +# In workspace mode, the command line file version should use go.work version.
    +cp go.work.orig go.work
    +go vet -n -json example.com/m
    +stderr '"GoVersion": "go1.22.0'
    +
    +go vet -n -json main.go
    +stderr '"GoVersion": "go1.22.2'
    +
    +# Without go.mod or go.work, the command line file version should use local go version .
    +env TESTGO_VERSION=go1.22.3
    +rm go.mod
    +rm go.work
    +
    +! go vet -n -json example.com/m
    +
    +go vet -n -json main.go
    +stderr '"GoVersion": "go1.22.3"'
    +
    +-- go.mod --
    +module example.com/m
    +
    +go 1.22.0
    +
    +-- go.work.orig --
    +go 1.22.2
    +
    +use .
    +
    +-- main.go --
    +package main
    diff --git a/go/src/cmd/go/testdata/script/vet_deps.txt b/go/src/cmd/go/testdata/script/vet_deps.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b2a8f168b301eb5b055f66d65bb8318fd9ee5c75
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vet_deps.txt
    @@ -0,0 +1,34 @@
    +env GO111MODULE=off
    +
    +# Issue 30296. Verify that "go vet" uses only immediate dependencies.
    +
    +# First run fills the cache.
    +go vet a
    +
    +go vet -x a
    +! stderr 'transitive'
    +
    +-- a/a.go --
    +package a
    +
    +import "b"
    +
    +func F() {
    +	b.F()
    +}
    +
    +-- b/b.go --
    +package b
    +
    +import "transitive"
    +
    +func F() {
    +	transitive.F()
    +}
    +
    +-- transitive/c.go --
    +package transitive
    +
    +func F() {
    +}
    +
    diff --git a/go/src/cmd/go/testdata/script/vet_flags.txt b/go/src/cmd/go/testdata/script/vet_flags.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e274dbedb39bd87fb3286894a6e9143b1cb78ca3
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vet_flags.txt
    @@ -0,0 +1,94 @@
    +[short] skip 'runs test'
    +
    +env GO111MODULE=on
    +
    +# Issue 35837: "go vet - " should use the requested
    +# analyzers, not the default analyzers for 'go test'.
    +go vet -n -buildtags=false runtime
    +stderr '-buildtags=false'
    +! stderr '-unsafeptr=false'
    +
    +# Issue 37030: "go vet " without other flags should disable the
    +# unsafeptr check by default.
    +go vet -n runtime
    +stderr '-unsafeptr=false'
    +! stderr '-unreachable=false'
    +
    +# However, it should be enabled if requested explicitly.
    +go vet -n -unsafeptr runtime
    +stderr '-unsafeptr'
    +! stderr '-unsafeptr=false'
    +
    +# -unreachable is disabled during test but on during plain vet.
    +# The -a makes sure the vet result is not cached, or else we won't print the command line.
    +go test -a -n runtime
    +stderr '-unreachable=false'
    +
    +# A flag terminator should be allowed before the package list.
    +go vet -n -- .
    +
    +[short] stop
    +
    +# Analyzer flags should be included from GOFLAGS, and should override
    +# the defaults.
    +go vet .
    +env GOFLAGS='-tags=buggy'
    +! go vet .
    +stderr 'possible Printf formatting directive'
    +
    +# Enabling one analyzer in GOFLAGS should disable the rest implicitly...
    +env GOFLAGS='-tags=buggy -unsafeptr'
    +go vet .
    +
    +# ...but enabling one on the command line should not disable the analyzers
    +# enabled via GOFLAGS.
    +env GOFLAGS='-tags=buggy -printf'
    +! go vet -unsafeptr
    +stderr 'possible Printf formatting directive'
    +
    +# Analyzer flags don't exist unless we're running 'go vet',
    +# and we shouldn't run the vet tool to discover them otherwise.
    +# (Maybe someday we'll hard-code the analyzer flags for the default vet
    +# tool to make this work, but not right now.)
    +env GOFLAGS='-unsafeptr'
    +! go list .
    +stderr 'go: parsing \$GOFLAGS: unknown flag -unsafeptr'
    +env GOFLAGS=
    +
    +# "go test" on a user package should by default enable an explicit list of analyzers.
    +go test -n -run=none .
    +stderr '[/\\]vet'$GOEXE'["]? .* -errorsas .* ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
    +
    +# An explicitly-empty -vet argument should imply the default analyzers.
    +go test -n -vet= -run=none .
    +stderr '[/\\]vet'$GOEXE'["]? .* -errorsas .* ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
    +
    +# "go test" on a standard package should by default disable an explicit list.
    +go test -a -n -run=none encoding/binary
    +stderr '[/\\]vet'$GOEXE'["]? -unsafeptr=false -unreachable=false ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
    +
    +go test -a -n -vet= -run=none encoding/binary
    +stderr '[/\\]vet'$GOEXE'["]? -unsafeptr=false -unreachable=false ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
    +
    +# Both should allow users to override via the -vet flag.
    +go test -a -n -vet=unreachable -run=none .
    +stderr '[/\\]vet'$GOEXE'["]? -unreachable ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
    +go test -a -n -vet=unreachable -run=none encoding/binary
    +stderr '[/\\]vet'$GOEXE'["]? -unreachable ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
    +
    +-- go.mod --
    +module example.com/x
    +-- x.go --
    +package x
    +-- x_test.go --
    +package x
    +-- x_tagged.go --
    +// +build buggy
    +
    +package x
    +
    +import "fmt"
    +
    +func init() {
    +	fmt.Sprint("%s") // oops!
    +}
    diff --git a/go/src/cmd/go/testdata/script/vet_internal.txt b/go/src/cmd/go/testdata/script/vet_internal.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..85f709302c893588125eb31f232f039a0de675f5
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/vet_internal.txt
    @@ -0,0 +1,71 @@
    +env GO111MODULE=off
    +
    +# Issue 36173. Verify that "go vet" prints line numbers on load errors.
    +
    +! go vet a/a.go
    +stderr '^package command-line-arguments\n\ta[/\\]a.go:5:3: use of internal package'
    +
    +! go vet a/a_test.go
    +stderr '^package command-line-arguments \(test\)\n\ta[/\\]a_test.go:4:3: use of internal package'
    +
    +! go vet a
    +stderr '^package a\n\ta[/\\]a.go:5:3: use of internal package'
    +
    +go vet b/b.go
    +! stderr 'use of internal package'
    +
    +! go vet b/b_test.go
    +stderr '^package command-line-arguments \(test\)\n\tb[/\\]b_test.go:4:3: use of internal package'
    +
    +! go vet depends-on-a/depends-on-a.go
    +stderr '^package command-line-arguments\n\timports a\n\ta[/\\]a.go:5:3: use of internal package'
    +
    +! go vet depends-on-a/depends-on-a_test.go
    +stderr '^package command-line-arguments \(test\)\n\timports a\n\ta[/\\]a.go:5:3: use of internal package a/x/internal/y not allowed'
    +
    +! go vet depends-on-a
    +stderr '^package depends-on-a\n\timports a\n\ta[/\\]a.go:5:3: use of internal package'
    +
    +-- a/a.go --
    +// A package with bad imports in both src and test
    +package a
    +
    +import (
    +  _ "a/x/internal/y"
    +)
    +
    +-- a/a_test.go --
    +package a
    +
    +import (
    +  _ "a/x/internal/y"
    +)
    +
    +-- b/b.go --
    +// A package with a bad import in test only
    +package b
    +
    +-- b/b_test.go --
    +package b
    +
    +import (
    +  _ "a/x/internal/y"
    +)
    +
    +-- depends-on-a/depends-on-a.go --
    +// A package that depends on a package with a bad import
    +package depends
    +
    +import (
    +  _ "a"
    +)
    +
    +-- depends-on-a/depends-on-a_test.go --
    +package depends
    +
    +import (
    +  _ "a"
    +)
    +
    +-- a/x/internal/y/y.go --
    +package y
    diff --git a/go/src/cmd/go/testdata/script/work.txt b/go/src/cmd/go/testdata/script/work.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..31597928689552abaf79af4604caf4942c5f76cd
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work.txt
    @@ -0,0 +1,156 @@
    +[short] skip 'runs go run'
    +
    +! go work init doesnotexist
    +stderr 'go: directory doesnotexist does not exist'
    +go env GOWORK
    +! stdout .
    +
    +go work init ./a ./b
    +cmpenv go.work go.work.want
    +go env GOWORK
    +stdout '^'$WORK'(\\|/)gopath(\\|/)src(\\|/)go.work$'
    +
    +! go run  example.com/b
    +stderr 'a(\\|/)a.go:4:8: no required module provides package rsc.io/quote; to add it:\n\tcd '$WORK(\\|/)gopath(\\|/)src(\\|/)a'\n\tgo get rsc.io/quote'
    +cd a
    +go get rsc.io/quote
    +cat go.mod
    +go env GOMOD # go env GOMOD reports the module in a single module context
    +stdout $GOPATH(\\|/)src(\\|/)a(\\|/)go.mod
    +cd ..
    +go run example.com/b
    +stdout 'Hello, world.'
    +
    +# And try from a different directory
    +cd c
    +go run  example.com/b
    +stdout 'Hello, world.'
    +cd $GOPATH/src
    +
    +go list all # all includes both modules
    +stdout 'example.com/a'
    +stdout 'example.com/b'
    +
    +# -mod can only be set to readonly in workspace mode
    +go list -mod=readonly all
    +! go list -mod=mod all
    +stderr '^go: -mod may only be set to readonly or vendor when in workspace mode'
    +env GOWORK=off
    +go list -mod=mod all
    +env GOWORK=
    +
    +# Test that duplicates in the use list return an error
    +cp go.work go.work.backup
    +cp go.work.dup go.work
    +! go run example.com/b
    +stderr 'go.work:6: path .* appears multiple times in workspace'
    +cp go.work.backup go.work
    +
    +cp go.work.d go.work
    +go work use # update go version
    +go run example.com/d
    +
    +# Test that we don't run into "newRequirements called with unsorted roots"
    +# panic with unsorted main modules.
    +cp go.work.backwards go.work
    +go work use # update go version
    +go run example.com/d
    +
    +# Test that command-line-arguments work inside and outside modules.
    +# This exercises the code that determines which module command-line-arguments
    +# belongs to.
    +go list ./b/main.go
    +env GOWORK=off
    +go build -n -o foo foo.go
    +env GOWORK=
    +go build -n -o foo foo.go
    +
    +-- go.work.dup --
    +go 1.18
    +
    +use (
    +	a
    +	b
    +	../src/a
    +)
    +-- go.work.want --
    +go $goversion
    +
    +use (
    +	./a
    +	./b
    +)
    +-- go.work.d --
    +go 1.18
    +
    +use (
    +	a
    +	b
    +	d
    +)
    +-- a/go.mod --
    +
    +module example.com/a
    +
    +-- a/a.go --
    +package a
    +
    +import "fmt"
    +import "rsc.io/quote"
    +
    +func HelloFromA() {
    +	fmt.Println(quote.Hello())
    +}
    +
    +-- b/go.mod --
    +
    +module example.com/b
    +
    +-- b/main.go --
    +package main
    +
    +import "example.com/a"
    +
    +func main() {
    +	a.HelloFromA()
    +}
    +-- b/lib/hello.go --
    +package lib
    +
    +import "example.com/a"
    +
    +func Hello() {
    +	a.HelloFromA()
    +}
    +
    +-- c/README --
    +Create this directory so we can cd to
    +it and make sure paths are interpreted
    +relative to the go.work, not the cwd.
    +-- d/go.mod --
    +module example.com/d
    +
    +-- d/main.go --
    +package main
    +
    +import "example.com/b/lib"
    +
    +func main() {
    +	lib.Hello()
    +}
    +
    +-- go.work.backwards --
    +go 1.18
    +
    +use (
    +	d
    +	b
    +	a
    +)
    +
    +-- foo.go --
    +package main
    +import "fmt"
    +func main() {
    +	fmt.Println("Hello, World")
    +}
    diff --git a/go/src/cmd/go/testdata/script/work_build_no_modules.txt b/go/src/cmd/go/testdata/script/work_build_no_modules.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c9859b437e29cf521d2a301f35e26f8f1db9a6d2
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_build_no_modules.txt
    @@ -0,0 +1,13 @@
    +! go build .
    +stderr 'go: no modules were found in the current workspace; see ''go help work'''
    +
    +-- go.work --
    +go 1.18
    +-- go.mod --
    +go 1.18
    +
    +module foo
    +-- foo.go --
    +package main
    +
    +func main() {}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_disablevendor.txt b/go/src/cmd/go/testdata/script/work_disablevendor.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c4c580b2bb954c8be6f22093e90b710626728111
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_disablevendor.txt
    @@ -0,0 +1,56 @@
    +# Test that mod=vendor is disabled in workspace mode, even
    +# with a single workspace module.
    +
    +cd workspace
    +
    +# Base case: ensure the module would default to mod=vendor
    +# outside of workspace mode.
    +env GOWORK=off
    +go list -f '{{.Dir}}' example.com/dep
    +stdout $GOPATH[\\/]src[\\/]workspace[\\/]vendor[\\/]example.com[\\/]dep
    +
    +# Test case: endure the module does not enter mod=vendor outside
    +# worspace mode.
    +env GOWORK=''
    +go list -f '{{.Dir}}' example.com/dep
    +stdout $GOPATH[\\/]src[\\/]dep
    +
    +-- workspace/go.work --
    +use .
    +replace example.com/dep => ../dep
    +-- workspace/main.go --
    +package main
    +
    +import "example.com/dep"
    +
    +func main() {
    +	dep.Dep()
    +}
    +-- workspace/go.mod --
    +module example.com/mod
    +
    +go 1.20
    +
    +require example.com/dep v1.0.0
    +-- workspace/vendor/example.com/dep/dep.go --
    +package dep
    +
    +import "fmt"
    +
    +func Dep() {
    +	fmt.Println("the vendored dep")
    +}
    +-- workspace/vendor/modules.txt --
    +# example.com/dep v1.0.0
    +## explicit
    +example.com/dep
    +-- dep/go.mod --
    +module example.com/dep
    +-- dep/dep.go --
    +package dep
    +
    +import "fmt"
    +
    +func Dep () {
    +    fmt.Println("the real dep")
    +}
    diff --git a/go/src/cmd/go/testdata/script/work_edit.txt b/go/src/cmd/go/testdata/script/work_edit.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..021346653fb6e30cb286dd8c0dd2d78fb27d4c26
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_edit.txt
    @@ -0,0 +1,187 @@
    +# Test editing go.work files.
    +
    +go work init m
    +cmpenv go.work go.work.want_initial
    +
    +go work edit -use n
    +cmpenv go.work go.work.want_use_n
    +
    +grep go go.work
    +go work edit -go none
    +! grep go go.work
    +
    +go work edit -go 1.18
    +cmp go.work go.work.want_go_118
    +
    +go work edit -dropuse m
    +cmp go.work go.work.want_dropuse_m
    +
    +go work edit -replace=x.1@v1.3.0=y.1@v1.4.0 -replace='x.1@v1.4.0 = ../z'
    +cmp go.work go.work.want_add_replaces
    +
    +go work edit -use n -use ../a -use /b -use c -use c
    +cmp go.work go.work.want_multiuse
    +
    +go work edit -dropuse /b -dropuse n
    +cmp go.work go.work.want_multidropuse
    +
    +go work edit -dropreplace='x.1@v1.4.0'
    +cmp go.work go.work.want_dropreplace
    +
    +go work edit -print -go 1.19 -use b -dropuse c -replace 'x.1@v1.4.0 = ../z' -dropreplace x.1 -dropreplace x.1@v1.3.0
    +cmp stdout go.work.want_print
    +
    +go work edit -json -go 1.19 -use b -dropuse c -replace 'x.1@v1.4.0 = ../z' -dropreplace x.1 -dropreplace x.1@v1.3.0
    +cmp stdout go.work.want_json
    +
    +# go work edit -godebug
    +cd $WORK/g
    +cp go.work.start go.work
    +go work edit -godebug key=value
    +cmpenv go.work go.work.edit
    +go work edit -dropgodebug key2
    +cmpenv go.work go.work.edit
    +go work edit -dropgodebug key
    +cmpenv go.work go.work.start
    +
    +# go work edit -print -fmt
    +env GOWORK=$GOPATH/src/unformatted
    +go work edit -print -fmt
    +cmp stdout $GOPATH/src/formatted
    +
    +-- m/go.mod --
    +module m
    +
    +go 1.18
    +-- go.work.want_initial --
    +go $goversion
    +
    +use ./m
    +-- go.work.want_use_n --
    +go $goversion
    +
    +use (
    +	./m
    +	./n
    +)
    +-- go.work.want_go_118 --
    +go 1.18
    +
    +use (
    +	./m
    +	./n
    +)
    +-- go.work.want_dropuse_m --
    +go 1.18
    +
    +use ./n
    +-- go.work.want_add_replaces --
    +go 1.18
    +
    +use ./n
    +
    +replace (
    +	x.1 v1.3.0 => y.1 v1.4.0
    +	x.1 v1.4.0 => ../z
    +)
    +-- go.work.want_multiuse --
    +go 1.18
    +
    +use (
    +	../a
    +	./c
    +	./n
    +	/b
    +)
    +
    +replace (
    +	x.1 v1.3.0 => y.1 v1.4.0
    +	x.1 v1.4.0 => ../z
    +)
    +-- go.work.want_multidropuse --
    +go 1.18
    +
    +use (
    +	../a
    +	./c
    +)
    +
    +replace (
    +	x.1 v1.3.0 => y.1 v1.4.0
    +	x.1 v1.4.0 => ../z
    +)
    +-- go.work.want_dropreplace --
    +go 1.18
    +
    +use (
    +	../a
    +	./c
    +)
    +
    +replace x.1 v1.3.0 => y.1 v1.4.0
    +-- go.work.want_print --
    +go 1.19
    +
    +use (
    +	../a
    +	./b
    +)
    +
    +replace x.1 v1.4.0 => ../z
    +-- go.work.want_json --
    +{
    +	"Go": "1.19",
    +	"Use": [
    +		{
    +			"DiskPath": "../a"
    +		},
    +		{
    +			"DiskPath": "./b"
    +		}
    +	],
    +	"Replace": [
    +		{
    +			"Old": {
    +				"Path": "x.1",
    +				"Version": "v1.4.0"
    +			},
    +			"New": {
    +				"Path": "../z"
    +			}
    +		}
    +	]
    +}
    +-- unformatted --
    +go 1.18
    + use (
    + a
    +  b
    +  c
    +  )
    +  replace (
    +  x.1 v1.3.0 => y.1 v1.4.0
    +                            x.1 v1.4.0 => ../z
    +                            )
    +-- formatted --
    +go 1.18
    +
    +use (
    +	a
    +	b
    +	c
    +)
    +
    +replace (
    +	x.1 v1.3.0 => y.1 v1.4.0
    +	x.1 v1.4.0 => ../z
    +)
    +-- $WORK/g/go.work.start --
    +use g
    +
    +go 1.10
    +-- $WORK/g/go.work.edit --
    +use g
    +
    +go 1.10
    +
    +godebug key=value
    diff --git a/go/src/cmd/go/testdata/script/work_edit_toolchain.txt b/go/src/cmd/go/testdata/script/work_edit_toolchain.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b4e260d23876023391f67892ee9c1903ee6be170
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_edit_toolchain.txt
    @@ -0,0 +1,20 @@
    +# Test support for go work edit -toolchain to set toolchain to use
    +
    +env GOTOOLCHAIN=local
    +env GO111MODULE=on
    +
    +! grep toolchain go.work
    +go work edit -toolchain=go1.9
    +grep 'toolchain go1.9' go.work
    +
    +go work edit -toolchain=default
    +grep 'toolchain default' go.work
    +
    +go work edit -toolchain=none
    +! grep toolchain go.work
    +
    +-- go.work --
    +go 1.8
    +use .
    +-- go.mod --
    +module m
    diff --git a/go/src/cmd/go/testdata/script/work_empty_panic_GOPATH.txt b/go/src/cmd/go/testdata/script/work_empty_panic_GOPATH.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..43ebf113b50e6eec91d9c63da2c99b1cfe04168a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_empty_panic_GOPATH.txt
    @@ -0,0 +1,13 @@
    +# Regression test for https://go.dev/issue/58767:
    +# with an empty go.work file in GOPATH mode, calls to load.defaultGODEBUG for a
    +# package named "main" panicked in modload.MainModules.GoVersion.
    +
    +env GO111MODULE=off
    +cd example
    +go list example/m
    +
    +-- example/go.work --
    +go 1.21
    +-- example/m/main.go --
    +package main
    +func main() {}
    diff --git a/go/src/cmd/go/testdata/script/work_env.txt b/go/src/cmd/go/testdata/script/work_env.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8b1779ea703725e0b00196b708a68ce3b187049f
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_env.txt
    @@ -0,0 +1,28 @@
    +go env GOWORK
    +stdout '^'$GOPATH'[\\/]src[\\/]go.work$'
    +go env
    +stdout '^(set )?GOWORK=''?'$GOPATH'[\\/]src[\\/]go.work''?$'
    +
    +cd ..
    +go env GOWORK
    +! stdout .
    +go env
    +stdout 'GOWORK=("")?'
    +
    +cd src
    +go env GOWORK
    +stdout 'go.work'
    +
    +env GOWORK='off'
    +go env GOWORK
    +stdout 'off'
    +
    +! go env -w GOWORK=off
    +stderr '^go: GOWORK cannot be modified$'
    +
    +-- go.work --
    +go 1.18
    +
    +use a
    +-- a/go.mod --
    +module example.com/a
    diff --git a/go/src/cmd/go/testdata/script/work_errors_pos.txt b/go/src/cmd/go/testdata/script/work_errors_pos.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..2d05703a0599af040ecc01ad9fa96aa475db9d63
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_errors_pos.txt
    @@ -0,0 +1,46 @@
    +# Test case for #67623 in go.work files: make sure the errors are
    +# printed on lines starting with file and line number so they
    +# can be easily parsed by tools.
    +
    +cp go.work.repeated.txt go.work
    +! go list
    +stderr '^go.work:4: path .* appears multiple times in workspace$'
    +
    +cp go.work.badgodebug.txt go.work
    +! go list
    +stderr '^go.work:3: unknown godebug "foo"$'
    +
    +cp go.work.unparsable.txt go.work
    +! go list
    +stderr '^go.work:5: unknown directive: notadirective'
    +
    +cp go.work.firstlineerr.txt go.work
    +! go list
    +stderr '^go.work:1: unknown godebug "bar"$'
    +
    +cp go.work.firsterrlisted.txt go.work
    +! go list
    +stderr '^go.work:1: unknown godebug "baz"$'
    +
    +-- foo/go.mod --
    +module example.com/foo
    +-- go.work.repeated.txt --
    +
    +
    +use foo
    +use foo
    +-- go.work.badgodebug.txt --
    +
    +
    +godebug foo=1
    +-- go.work.unparsable.txt --
    +
    +
    +
    +
    +notadirective
    +-- go.work.firstlineerr.txt --
    +godebug bar=1
    +-- go.work.firsterrlisted.txt --
    +godebug baz=1
    +godebug baz=1
    diff --git a/go/src/cmd/go/testdata/script/work_get_toolchain.txt b/go/src/cmd/go/testdata/script/work_get_toolchain.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6548860ac9cc078f1464d858241e7fceac923711
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_get_toolchain.txt
    @@ -0,0 +1,24 @@
    +# go get should update the go line in go.work
    +env TESTGO_VERSION=go1.21
    +env TESTGO_VERSION_SWITCH=switch
    +env GOTOOLCHAIN=auto
    +cp go.mod.new go.mod
    +cp go.work.new go.work
    +go get rsc.io/needgo121 rsc.io/needgo122 rsc.io/needgo123 rsc.io/needall
    +stderr '^go: rsc.io/needall@v0.0.1 requires go >= 1.23; switching to go1.23.9$'
    +stderr '^go: added rsc.io/needall v0.0.1'
    +grep 'go 1.23$' go.mod
    +grep 'go 1.23$' go.work
    +! grep toolchain go.mod
    +! grep toolchain go.work
    +
    +-- go.mod.new --
    +module m
    +go 1.1
    +
    +-- p.go --
    +package p
    +
    +-- go.work.new --
    +go 1.18
    +use .
    diff --git a/go/src/cmd/go/testdata/script/work_goline_order.txt b/go/src/cmd/go/testdata/script/work_goline_order.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..fe1cddbcd4a59289cf279a9d1a241c0e8a06179b
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_goline_order.txt
    @@ -0,0 +1,34 @@
    +# Check that go line in go.work is always >= go line of used modules.
    +
    +# Using an old Go version, fails during module loading, but we rewrite the error to the
    +# same one a switching version would use, without the auto-switch.
    +# This is a misconfigured system that should not arise in practice.
    +env TESTGO_VERSION=go1.21.1
    +env TESTGO_VERSION_SWITCH=switch
    +cp go.work go.work.orig
    +! go list
    +stderr '^go: module . listed in go.work file requires go >= 1.21.2, but go.work lists go 1.21.1; to update it:\n\tgo work use$'
    +go work use
    +go list
    +
    +# Using a new enough Go version, fails later and can suggest 'go work use'.
    +env TESTGO_VERSION=go1.21.2
    +env TESTGO_VERSION_SWITCH=switch
    +cp go.work.orig go.work
    +! go list
    +stderr '^go: module . listed in go.work file requires go >= 1.21.2, but go.work lists go 1.21.1; to update it:\n\tgo work use$'
    +
    +# go work use fixes the problem.
    +go work use
    +go list
    +
    +-- go.work --
    +go 1.21.1
    +use .
    +
    +-- go.mod --
    +module m
    +go 1.21.2
    +
    +-- p.go --
    +package p
    diff --git a/go/src/cmd/go/testdata/script/work_goproxy_off.txt b/go/src/cmd/go/testdata/script/work_goproxy_off.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..0a602e3d7bd88c594cf013d5fb4035f1054ecaad
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_goproxy_off.txt
    @@ -0,0 +1,59 @@
    +go work init
    +go work use . ./sub
    +
    +# Verify that the go.mod files for both modules in the workspace are tidy,
    +# and add missing go.sum entries as needed.
    +
    +cp go.mod go.mod.orig
    +go mod tidy
    +cmp go.mod go.mod.orig
    +
    +cd sub
    +cp go.mod go.mod.orig
    +go mod tidy
    +cmp go.mod go.mod.orig
    +cd ..
    +
    +go list -m all
    +stdout '^rsc\.io/quote v1\.5\.1$'
    +stdout '^rsc\.io/sampler v1\.3\.1$'
    +
    +# Now remove the module dependencies from the module cache.
    +# Because one module upgrades a transitive dependency needed by another,
    +# listing the modules in the workspace should error out.
    +
    +go clean -modcache
    +env GOPROXY=off
    +! go list -m all
    +stderr '^go: rsc.io/sampler@v1.3.0: module lookup disabled by GOPROXY=off$'
    +
    +-- example.go --
    +package example
    +
    +import _ "rsc.io/sampler"
    +-- go.mod --
    +module example
    +
    +go 1.19
    +
    +require rsc.io/sampler v1.3.0
    +
    +require (
    +	golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
    +	rsc.io/testonly v1.0.0 // indirect
    +)
    +-- sub/go.mod --
    +module example/sub
    +
    +go 1.19
    +
    +require rsc.io/quote v1.5.1
    +
    +require (
    +	golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
    +	rsc.io/sampler v1.3.1 // indirect
    +)
    +-- sub/sub.go --
    +package example
    +
    +import _ "rsc.io/quote"
    diff --git a/go/src/cmd/go/testdata/script/work_gowork.txt b/go/src/cmd/go/testdata/script/work_gowork.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..1cfbf0ca18fac3a6086fa6382a81740c7e24fd46
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_gowork.txt
    @@ -0,0 +1,24 @@
    +env GOWORK=stop.work
    +! go list a # require absolute path
    +! stderr panic
    +env GOWORK=doesnotexist
    +! go list a
    +! stderr panic
    +
    +env GOWORK=$GOPATH/src/stop.work
    +go list -n a
    +go build -n a
    +go test -n a
    +
    +-- stop.work --
    +go 1.18
    +
    +use ./a
    +-- a/a.go --
    +package a
    +-- a/a_test.go --
    +package a
    +-- a/go.mod --
    +module a
    +
    +go 1.18
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_implicit_go_requirement.txt b/go/src/cmd/go/testdata/script/work_implicit_go_requirement.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e123a7b01a5c1b7bc428a8b386a83c8048604d7d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_implicit_go_requirement.txt
    @@ -0,0 +1,18 @@
    +# Issue 66207: provide a better error message when there's no
    +# go directive in a go.work file so 1.18 is implicitly required.
    +
    +! go list
    +stderr 'go: module . listed in go.work file requires go >= 1.21, but go.work implicitly requires go 1.18; to update it:\s+go work use'
    +
    +go work use
    +go list
    +stdout foo
    +
    +-- go.work --
    +use .
    +-- go.mod --
    +module foo
    +
    +go 1.21
    +-- foo.go --
    +package foo
    diff --git a/go/src/cmd/go/testdata/script/work_init_gowork.txt b/go/src/cmd/go/testdata/script/work_init_gowork.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..55ac99b8c009dc8479215c96447c190018d53a4d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_init_gowork.txt
    @@ -0,0 +1,19 @@
    +# Test that the GOWORK environment variable flag is used by go work init.
    +
    +! exists go.work
    +go work init
    +exists go.work
    +
    +env GOWORK=$GOPATH/src/foo/foo.work
    +! exists foo/foo.work
    +go work init
    +exists foo/foo.work
    +
    +env GOWORK=
    +cd foo/bar
    +! go work init
    +stderr 'already exists'
    +
    +# Create directories to make go.work files in.
    +-- foo/dummy.txt --
    +-- foo/bar/dummy.txt --
    diff --git a/go/src/cmd/go/testdata/script/work_init_path.txt b/go/src/cmd/go/testdata/script/work_init_path.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..0a2d3729fca4bf33e77a39ba86049c521970b563
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_init_path.txt
    @@ -0,0 +1,33 @@
    +# Regression test for https://go.dev/issue/51448.
    +# 'go work init . .. foo/bar' should produce a go.work file
    +# with the same paths as 'go work init; go work use -r ..',
    +# and it should have 'use .' rather than 'use ./.' inside.
    +
    +cd dir
    +
    +go work init . .. foo/bar
    +mv go.work go.work.init
    +
    +go work init
    +go work use -r ..
    +cmp go.work go.work.init
    +
    +cmpenv go.work $WORK/go.work.want
    +
    +-- go.mod --
    +module example
    +go 1.18
    +-- dir/go.mod --
    +module example
    +go 1.18
    +-- dir/foo/bar/go.mod --
    +module example
    +go 1.18
    +-- $WORK/go.work.want --
    +go $goversion
    +
    +use (
    +	.
    +	..
    +	./foo/bar
    +)
    diff --git a/go/src/cmd/go/testdata/script/work_init_toolchain.txt b/go/src/cmd/go/testdata/script/work_init_toolchain.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..900ea2cf2fc4317b92631f0c2947f03bd45b59e1
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_init_toolchain.txt
    @@ -0,0 +1,35 @@
    +
    +# Create basic modules and work space.
    +# Note that toolchain lines in modules should be completely ignored.
    +env TESTGO_VERSION=go1.50
    +mkdir m1_22_0
    +go mod init -C m1_22_0
    +go mod edit -C m1_22_0 -go=1.22.0 -toolchain=go1.99.0
    +
    +# work init writes the current Go version to the go line
    +go work init
    +grep '^go 1.50$' go.work
    +! grep toolchain go.work
    +
    +# work init with older modules should leave go 1.50 in the go.work.
    +rm go.work
    +go work init ./m1_22_0
    +grep '^go 1.50$' go.work
    +! grep toolchain go.work
    +
    +# work init with newer modules should bump go,
    +# including updating to a newer toolchain as needed.
    +# Because work init writes the current toolchain as the go version,
    +# it writes the bumped go version, not the max of the used modules.
    +env TESTGO_VERSION=go1.21
    +env TESTGO_VERSION_SWITCH=switch
    +rm go.work
    +env GOTOOLCHAIN=local
    +! go work init ./m1_22_0
    +stderr '^go: m1_22_0'${/}'go.mod requires go >= 1.22.0 \(running go 1.21; GOTOOLCHAIN=local\)$'
    +env GOTOOLCHAIN=auto
    +go work init ./m1_22_0
    +stderr '^go: m1_22_0'${/}'go.mod requires go >= 1.22.0; switching to go1.22.9$'
    +cat go.work
    +grep '^go 1.22.9$' go.work
    +! grep toolchain go.work
    diff --git a/go/src/cmd/go/testdata/script/work_install_submodule.txt b/go/src/cmd/go/testdata/script/work_install_submodule.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..3d1171736d9c7c7740b9384c330dc21b977d38c7
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_install_submodule.txt
    @@ -0,0 +1,36 @@
    +# This is a regression test for golang.org/issue/50036
    +# Don't check sums for other modules in the workspace.
    +
    +cd m/sub
    +go install -n
    +
    +-- go.work --
    +go 1.18
    +
    +use (
    +    ./m
    +    ./m/sub
    +)
    +-- m/go.mod --
    +module example.com/m
    +
    +go 1.18
    +
    +-- m/m.go --
    +package m
    +
    +func M() {}
    +-- m/sub/go.mod --
    +module example.com/m/sub
    +
    +go 1.18
    +
    +require example.com/m v1.0.0
    +-- m/sub/main.go --
    +package main
    +
    +import "example.com/m"
    +
    +func main() {
    +    m.M()
    +}
    diff --git a/go/src/cmd/go/testdata/script/work_issue51204.txt b/go/src/cmd/go/testdata/script/work_issue51204.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..d48300206074ebb48f6a06b3fa043fa846995748
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_issue51204.txt
    @@ -0,0 +1,57 @@
    +go work sync
    +
    +go list -f '{{.Dir}}' example.com/test
    +stdout '^'$PWD${/}test'$'
    +
    +-- go.work --
    +go 1.18
    +
    +use (
    +	./test2
    +	./test2/sub
    +)
    +-- test/go.mod --
    +module example.com/test
    +
    +go 1.18
    +-- test/file.go --
    +package test
    +
    +func DoSomething() {
    +}
    +-- test2/go.mod --
    +module example.com/test2
    +
    +go 1.18
    +
    +replace example.com/test => ../test
    +
    +require example.com/test v0.0.0-00010101000000-000000000000
    +-- test2/file.go --
    +package test2
    +
    +import (
    +	"example.com/test"
    +)
    +
    +func DoSomething() {
    +	test.DoSomething()
    +}
    +-- test2/sub/go.mod --
    +module example.com/test2/sub
    +
    +go 1.18
    +
    +replace example.com/test => ../../test
    +
    +require example.com/test v0.0.0
    +-- test2/sub/file.go --
    +package test2
    +
    +import (
    +	"example.com/test"
    +)
    +
    +func DoSomething() {
    +	test.DoSomething()
    +}
    diff --git a/go/src/cmd/go/testdata/script/work_issue54048.txt b/go/src/cmd/go/testdata/script/work_issue54048.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..ced3d9074a159215d7087e5c65e6a7d96035974c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_issue54048.txt
    @@ -0,0 +1,19 @@
    +! go list -m -json all
    +stderr 'go: module example.com/foo appears multiple times in workspace'
    +
    +-- go.work --
    +go 1.18
    +
    +use (
    +        ./a
    +        ./b
    +)
    +-- a/go.mod --
    +module example.com/foo
    +
    +go 1.18
    +
    +-- b/go.mod --
    +module example.com/foo
    +
    +go 1.18
    diff --git a/go/src/cmd/go/testdata/script/work_issue54372.txt b/go/src/cmd/go/testdata/script/work_issue54372.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..bd3108abab1947a73c69bd24c26b452a48b7553b
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_issue54372.txt
    @@ -0,0 +1,37 @@
    +# go mod verify should not try to verify the workspace modules.
    +# This is a test for #54372.
    +
    +go mod verify
    +stdout 'all modules verified'
    +! stderr .
    +
    +-- go.work --
    +go 1.21
    +
    +use (
    +    ./a
    +    ./b
    +    ./c
    +    ./d
    +)
    +-- a/go.mod --
    +module example.com/a
    +
    +go 1.21
    +
    +require rsc.io/quote v1.1.0
    +-- a/a.go --
    +package a
    +import _ "rsc.io/quote"
    +-- b/go.mod --
    +module example.com/b
    +
    +go 1.21
    +-- c/go.mod --
    +module example.com/c
    +
    +go 1.21
    +-- d/go.mod --
    +module example.com/d
    +
    +go 1.21
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_module_not_in_go_work.txt b/go/src/cmd/go/testdata/script/work_module_not_in_go_work.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..074bac5d6839c8aed93285c0a6041d96f10aa990
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_module_not_in_go_work.txt
    @@ -0,0 +1,40 @@
    +# This is a regression test for issue #49632.
    +# The Go command should mention go.work if the user
    +# tries to load a local package that's in a module
    +# that's not in go.work and can't be resolved.
    +
    +! go list ./...
    +stderr 'pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies'
    +
    +! go list ./a/c
    +stderr 'directory a[\\/]c is contained in a module that is not one of the workspace modules listed in go.work. You can add the module to the workspace using:\n\tgo work use a'
    +
    +! go install ./a/c
    +stderr 'directory a[\\/]c is contained in a module that is not one of the workspace modules listed in go.work. You can add the module to the workspace using:\n\tgo work use a'
    +
    +cd a/c
    +! go run .
    +stderr 'current directory is contained in a module that is not one of the workspace modules listed in go.work. You can add the module to the workspace using:\n\tgo work use \.\.'
    +
    +cd ../..
    +! go run .
    +stderr 'current directory outside modules listed in go.work or their selected dependencies'
    +
    +-- go.work --
    +go 1.18
    +
    +use ./b
    +-- a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +-- a/a.go --
    +package a
    +-- a/c/c.go --
    +package main
    +-- b/go.mod --
    +module example.com/b
    +
    +go 1.18
    +-- foo.go --
    +package foo
    diff --git a/go/src/cmd/go/testdata/script/work_no_mod_root_issue54419.txt b/go/src/cmd/go/testdata/script/work_no_mod_root_issue54419.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..385044d863d3d59de5e1505fc58145a54a52acf5
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_no_mod_root_issue54419.txt
    @@ -0,0 +1,13 @@
    +cd m
    +! go mod download
    +stderr 'no modules were found in the current workspace'
    +
    +! go list -m all
    +stderr 'no modules were found in the current workspace'
    +
    +-- go.work --
    +go 1.25
    +-- m/go.mod --
    +module example.com/m
    +
    +go 1.25
    diff --git a/go/src/cmd/go/testdata/script/work_nowork.txt b/go/src/cmd/go/testdata/script/work_nowork.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b4c9b1d9cf3dc927bd8bbfbf3d92a21353e103e2
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_nowork.txt
    @@ -0,0 +1,20 @@
    +! go work use
    +stderr '^go: no go\.work file found\n\t\(run ''go work init'' first or specify path using GOWORK environment variable\)$'
    +
    +! go work use .
    +stderr '^go: no go\.work file found\n\t\(run ''go work init'' first or specify path using GOWORK environment variable\)$'
    +
    +! go work edit
    +stderr '^go: no go\.work file found\n\t\(run ''go work init'' first or specify path using GOWORK environment variable\)$'
    +
    +! go work edit -go=1.18
    +stderr '^go: no go\.work file found\n\t\(run ''go work init'' first or specify path using GOWORK environment variable\)$'
    +
    +! go work sync
    +stderr '^go: no go\.work file found\n\t\(run ''go work init'' first or specify path using GOWORK environment variable\)$'
    +
    +-- go.mod --
    +module example
    +go 1.18
    +-- README.txt --
    +There is no go.work file here.
    diff --git a/go/src/cmd/go/testdata/script/work_overlay.txt b/go/src/cmd/go/testdata/script/work_overlay.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..161ad74c42ff0deb1e2351206ea2d3fa08bd214d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_overlay.txt
    @@ -0,0 +1,41 @@
    +# Test that overlays are respected when opening go.work files.
    +
    +# go.work in overlay, but not on disk.
    +go list -overlay=overlay.json -m
    +stdout example.com/a
    +stdout example.com/b
    +! stdout example.com/c
    +
    +# control case for go.work on disk and in overlay:
    +# go.work is on disk but not in overlay.
    +cp go.work.non-overlay go.work
    +go list -m
    +stdout example.com/a
    +stdout example.com/b
    +stdout example.com/c
    +
    +# go.work on disk and in overlay.
    +go list -overlay=overlay.json -m
    +stdout example.com/a
    +stdout example.com/b
    +! stdout example.com/c
    +
    +-- overlay.json --
    +{"Replace": {"go.work": "overlaywork"}}
    +-- overlaywork --
    +use (
    +    ./a
    +    ./b
    +)
    +-- go.work.non-overlay --
    +use (
    +    ./a
    +    ./b
    +    ./c
    +)
    +-- a/go.mod --
    +module example.com/a
    +-- b/go.mod --
    +module example.com/b
    +-- c/go.mod --
    +module example.com/c
    diff --git a/go/src/cmd/go/testdata/script/work_prune.txt b/go/src/cmd/go/testdata/script/work_prune.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b1f569e8ae426ae4171d7b2dcd861d56e92f7a4d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_prune.txt
    @@ -0,0 +1,103 @@
    +# This test makes sure workspace mode's handling of the module graph
    +# is compatible with module pruning. The graph we load from either of
    +# the workspace modules should be the same, even if their graphs
    +# don't overlap.
    +#
    +# This is the module graph in the test:
    +#
    +#  example.com/a -> example.com/b v1.0.0 -> example.com/q v1.1.0
    +#  example.com/p -> example.com/q v1.0.0
    +#
    +# If we didn't load the whole graph and didn't load the dependencies of b
    +# when loading p, we would end up loading q v1.0.0, rather than v1.1.0,
    +# which is selected by MVS.
    +
    +go list -m -f '{{.Version}}' example.com/q
    +stdout '^v1.1.0$'
    +
    +-- go.work --
    +go 1.18
    +
    +use (
    +	./a
    +	./p
    +)
    +-- a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +
    +require example.com/b v1.0.0
    +
    +replace example.com/b v1.0.0 => ../b
    +-- a/foo.go --
    +package main
    +
    +import "example.com/b"
    +
    +func main() {
    +	b.B()
    +}
    +-- b/go.mod --
    +module example.com/b
    +
    +go 1.18
    +
    +require example.com/q v1.1.0
    +
    +replace example.com/q v1.0.0 => ../q1_0_0
    +replace example.com/q v1.1.0 => ../q1_1_0
    +-- b/b.go --
    +package b
    +
    +func B() {
    +}
    +-- b/b_test.go --
    +package b
    +
    +import "example.com/q"
    +
    +func TestB() {
    +	q.PrintVersion()
    +}
    +-- p/go.mod --
    +module example.com/p
    +
    +go 1.18
    +
    +require example.com/q v1.0.0
    +
    +replace example.com/q v1.0.0 => ../q1_0_0
    +replace example.com/q v1.1.0 => ../q1_1_0
    +-- p/main.go --
    +package main
    +
    +import "example.com/q"
    +
    +func main() {
    +	q.PrintVersion()
    +}
    +-- q1_0_0/go.mod --
    +module example.com/q
    +
    +go 1.18
    +-- q1_0_0/q.go --
    +package q
    +
    +import "fmt"
    +
    +func PrintVersion() {
    +	fmt.Println("version 1.0.0")
    +}
    +-- q1_1_0/go.mod --
    +module example.com/q
    +
    +go 1.18
    +-- q1_1_0/q.go --
    +package q
    +
    +import "fmt"
    +
    +func PrintVersion() {
    +	fmt.Println("version 1.1.0")
    +}
    diff --git a/go/src/cmd/go/testdata/script/work_prune_all.txt b/go/src/cmd/go/testdata/script/work_prune_all.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a7ad9c04aff3d428304c1450f1e83d3462afbf38
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_prune_all.txt
    @@ -0,0 +1,176 @@
    +# This test makes sure workspace mode's handling of the module graph
    +# is compatible with module pruning. The graph we load from either of
    +# the workspace modules should be the same, even if their graphs
    +# don't overlap.
    +#
    +# This is the module graph in the test:
    +#
    +#  example.com/p -> example.com/q v1.0.0
    +#  example.com/a -> example.com/b v1.0.0 -> example.com/q v1.1.0 -> example.com/w v1.0.0 -> example.com/x v1.0.0 -> example.com/y v1.0.0
    +#                |-> example.com/z v1.0.0                        |-> example.com/z v1.1.0
    +#                            |-> example.com/q v1.0.5 -> example.com/r v1.0.0
    +# If we didn't load the whole graph and didn't load the dependencies of b
    +# when loading p, we would end up loading q v1.0.0, rather than v1.1.0,
    +# which is selected by MVS.
    +
    +go list -m all
    +stdout 'example.com/w v1.0.0'
    +stdout 'example.com/q v1.1.0'
    +stdout 'example.com/z v1.1.0'
    +stdout 'example.com/x v1.0.0'
    +! stdout 'example.com/r'
    +! stdout 'example.com/y'
    +
    +-- go.work --
    +go 1.18
    +
    +use (
    +	./a
    +	./p
    +)
    +
    +replace example.com/b v1.0.0 => ./b
    +replace example.com/q v1.0.0 => ./q1_0_0
    +replace example.com/q v1.0.5 => ./q1_0_5
    +replace example.com/q v1.1.0 => ./q1_1_0
    +replace example.com/r v1.0.0 => ./r
    +replace example.com/w v1.0.0 => ./w
    +replace example.com/x v1.0.0 => ./x
    +replace example.com/y v1.0.0 => ./y
    +replace example.com/z v1.0.0 => ./z1_0_0
    +replace example.com/z v1.1.0 => ./z1_1_0
    +
    +-- a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +
    +require example.com/b v1.0.0
    +require example.com/z v1.0.0
    +-- a/foo.go --
    +package main
    +
    +import "example.com/b"
    +
    +func main() {
    +	b.B()
    +}
    +-- b/go.mod --
    +module example.com/b
    +
    +go 1.18
    +
    +require example.com/q v1.1.0
    +-- b/b.go --
    +package b
    +
    +func B() {
    +}
    +-- p/go.mod --
    +module example.com/p
    +
    +go 1.18
    +
    +require example.com/q v1.0.0
    +
    +replace example.com/q v1.0.0 => ../q1_0_0
    +replace example.com/q v1.1.0 => ../q1_1_0
    +-- p/main.go --
    +package main
    +
    +import "example.com/q"
    +
    +func main() {
    +	q.PrintVersion()
    +}
    +-- q1_0_0/go.mod --
    +module example.com/q
    +
    +go 1.18
    +-- q1_0_0/q.go --
    +package q
    +
    +import "fmt"
    +
    +func PrintVersion() {
    +	fmt.Println("version 1.0.0")
    +}
    +-- q1_0_5/go.mod --
    +module example.com/q
    +
    +go 1.18
    +
    +require example.com/r v1.0.0
    +-- q1_0_5/q.go --
    +package q
    +
    +import _ "example.com/r"
    +-- q1_1_0/go.mod --
    +module example.com/q
    +
    +require example.com/w v1.0.0
    +require example.com/z v1.1.0
    +
    +go 1.18
    +-- q1_1_0/q.go --
    +package q
    +
    +import _ "example.com/w"
    +import _ "example.com/z"
    +
    +import "fmt"
    +
    +func PrintVersion() {
    +	fmt.Println("version 1.1.0")
    +}
    +-- r/go.mod --
    +module example.com/r
    +
    +go 1.18
    +
    +require example.com/r v1.0.0
    +-- r/r.go --
    +package r
    +-- w/go.mod --
    +module example.com/w
    +
    +go 1.18
    +
    +require example.com/x v1.0.0
    +-- w/w.go --
    +package w
    +-- w/w_test.go --
    +package w
    +
    +import _ "example.com/x"
    +-- x/go.mod --
    +module example.com/x
    +
    +go 1.18
    +-- x/x.go --
    +package x
    +-- x/x_test.go --
    +package x
    +import _ "example.com/y"
    +-- y/go.mod --
    +module example.com/y
    +
    +go 1.18
    +-- y/y.go --
    +package y
    +-- z1_0_0/go.mod --
    +module example.com/z
    +
    +go 1.18
    +
    +require example.com/q v1.0.5
    +-- z1_0_0/z.go --
    +package z
    +
    +import _ "example.com/q"
    +-- z1_1_0/go.mod --
    +module example.com/z
    +
    +go 1.18
    +-- z1_1_0/z.go --
    +package z
    diff --git a/go/src/cmd/go/testdata/script/work_regression_hang.txt b/go/src/cmd/go/testdata/script/work_regression_hang.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a7661b68ad400c025377ae80bfb28e17dda59097
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_regression_hang.txt
    @@ -0,0 +1,71 @@
    +# This test makes checks against a regression of a bug in the Go command
    +# where the module loader hung forever because all main module dependencies
    +# kept workspace pruning instead of adopting the pruning in their go.mod
    +# files, and the loader kept adding dependencies on the queue until they
    +# were either pruned or unpruned, never breaking a module dependency cycle.
    +#
    +# This is the module graph in the test:
    +#
    +#                               /-------------------------\
    +#                              |                          |
    +#                              V                          |
    +#  example.com/a -> example.com/b v1.0.0 -> example.com/c v1.1.0
    +
    +go list -m -f '{{.Version}}' example.com/c
    +
    +-- go.work --
    +go 1.16
    +
    +use (
    +	./a
    +)
    +-- a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +
    +require example.com/b v1.0.0
    +
    +replace example.com/b v1.0.0 => ../b
    +replace example.com/c v1.0.0 => ../c
    +-- a/foo.go --
    +package main
    +
    +import "example.com/b"
    +
    +func main() {
    +	b.B()
    +}
    +-- b/go.mod --
    +module example.com/b
    +
    +go 1.18
    +
    +require example.com/c v1.0.0
    +-- b/b.go --
    +package b
    +
    +func B() {
    +}
    +-- b/cmd/main.go --
    +package main
    +
    +import "example.com/c"
    +
    +func main() {
    +	c.C()
    +}
    +-- c/go.mod --
    +module example.com/c
    +
    +go 1.18
    +
    +require example.com/b v1.0.0
    +-- c/c.go --
    +package c
    +
    +import "example.com/b"
    +
    +func C() {
    +	b.B()
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_reject_modfile.txt b/go/src/cmd/go/testdata/script/work_reject_modfile.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f0cfa3bea01dd4c4099b73bd276b4ce51e56a677
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_reject_modfile.txt
    @@ -0,0 +1,34 @@
    +# Test that -modfile=path/to/go.mod is rejected in workspace mode.
    +
    +! go list -m -modfile=./a/go.alt.mod
    +stderr 'go: -modfile cannot be used in workspace mode'
    +
    +env GOFLAGS=-modfile=./a/go.alt.mod
    +! go list -m
    +stderr 'go: -modfile cannot be used in workspace mode'
    +
    +-- go.work --
    +go 1.20
    +
    +use (
    +    ./a
    +)
    +
    +-- a/go.mod --
    +module example.com/foo
    +
    +go 1.20
    +
    +-- a/go.alt.mod --
    +module example.com/foo
    +
    +go 1.20
    +
    +-- a/main.go --
    +package main
    +
    +import "fmt"
    +
    +func main() {
    +	fmt.Println("Hello world!")
    +}
    diff --git a/go/src/cmd/go/testdata/script/work_replace.txt b/go/src/cmd/go/testdata/script/work_replace.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..81268e50697eb74d7a44141b679c806e0790df65
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_replace.txt
    @@ -0,0 +1,55 @@
    +# Support replace statement in go.work file
    +
    +# Replacement in go.work file, and none in go.mod file.
    +go list -m example.com/dep
    +stdout 'example.com/dep v1.0.0 => ./dep'
    +
    +# Wildcard replacement in go.work file overrides version replacement in go.mod
    +# file.
    +go list -m example.com/other
    +stdout 'example.com/other v1.0.0 => ./other2'
    +
    +-- go.work --
    +use m
    +
    +replace example.com/dep => ./dep
    +replace example.com/other => ./other2
    +
    +-- m/go.mod --
    +module example.com/m
    +
    +require example.com/dep v1.0.0
    +require example.com/other v1.0.0
    +
    +replace example.com/other v1.0.0 => ./other
    +-- m/m.go --
    +package m
    +
    +import "example.com/dep"
    +import "example.com/other"
    +
    +func F() {
    +	dep.G()
    +	other.H()
    +}
    +-- dep/go.mod --
    +module example.com/dep
    +-- dep/dep.go --
    +package dep
    +
    +func G() {
    +}
    +-- other/go.mod --
    +module example.com/other
    +-- other/dep.go --
    +package other
    +
    +func G() {
    +}
    +-- other2/go.mod --
    +module example.com/other
    +-- other2/dep.go --
    +package other
    +
    +func G() {
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_replace_conflict.txt b/go/src/cmd/go/testdata/script/work_replace_conflict.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..7b71b0fbd78cfa8148bc64cebd145b8520e09900
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_replace_conflict.txt
    @@ -0,0 +1,53 @@
    +# Conflicting replaces in workspace modules returns error that suggests
    +# overriding it in the go.work file.
    +
    +! go list -m example.com/dep
    +stderr 'go: conflicting replacements for example.com/dep@v1.0.0:\n\t'$PWD${/}'dep1\n\t'$PWD${/}'dep2\nuse "go work edit -replace example.com/dep@v1.0.0=\[override\]" to resolve'
    +go work edit -replace example.com/dep@v1.0.0=./dep1
    +go list -m example.com/dep
    +stdout 'example.com/dep v1.0.0 => ./dep1'
    +
    +-- foo --
    +-- go.work --
    +use m
    +use n
    +-- m/go.mod --
    +module example.com/m
    +
    +require example.com/dep v1.0.0
    +replace example.com/dep v1.0.0 => ../dep1
    +-- m/m.go --
    +package m
    +
    +import "example.com/dep"
    +
    +func F() {
    +	dep.G()
    +}
    +-- n/go.mod --
    +module example.com/n
    +
    +require example.com/dep v1.0.0
    +replace example.com/dep v1.0.0 => ../dep2
    +-- n/n.go --
    +package n
    +
    +import "example.com/dep"
    +
    +func F() {
    +	dep.G()
    +}
    +-- dep1/go.mod --
    +module example.com/dep
    +-- dep1/dep.go --
    +package dep
    +
    +func G() {
    +}
    +-- dep2/go.mod --
    +module example.com/dep
    +-- dep2/dep.go --
    +package dep
    +
    +func G() {
    +}
    diff --git a/go/src/cmd/go/testdata/script/work_replace_conflict_override.txt b/go/src/cmd/go/testdata/script/work_replace_conflict_override.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c62084bee692cecef24ac245c332047854f2b724
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_replace_conflict_override.txt
    @@ -0,0 +1,57 @@
    +# Conflicting workspace module replaces can be overridden by a replace in the
    +# go.work file.
    +
    +go list -m example.com/dep
    +stdout 'example.com/dep v1.0.0 => ./dep3'
    +
    +-- go.work --
    +use m
    +use n
    +replace example.com/dep => ./dep3
    +-- m/go.mod --
    +module example.com/m
    +
    +require example.com/dep v1.0.0
    +replace example.com/dep => ./dep1
    +-- m/m.go --
    +package m
    +
    +import "example.com/dep"
    +
    +func F() {
    +	dep.G()
    +}
    +-- n/go.mod --
    +module example.com/n
    +
    +require example.com/dep v1.0.0
    +replace example.com/dep => ./dep2
    +-- n/n.go --
    +package n
    +
    +import "example.com/dep"
    +
    +func F() {
    +	dep.G()
    +}
    +-- dep1/go.mod --
    +module example.com/dep
    +-- dep1/dep.go --
    +package dep
    +
    +func G() {
    +}
    +-- dep2/go.mod --
    +module example.com/dep
    +-- dep2/dep.go --
    +package dep
    +
    +func G() {
    +}
    +-- dep3/go.mod --
    +module example.com/dep
    +-- dep3/dep.go --
    +package dep
    +
    +func G() {
    +}
    diff --git a/go/src/cmd/go/testdata/script/work_replace_main_module.txt b/go/src/cmd/go/testdata/script/work_replace_main_module.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b213764280ed21f1808438fbc6096b2c8621db30
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_replace_main_module.txt
    @@ -0,0 +1,45 @@
    +# Ensure that replaces of the main module in workspace modules
    +# are ignored, and replaces in the go.work file are disallowed.
    +# This tests against an issue where requirements of the
    +# main module were being ignored because the main module
    +# was replaced in a transitive dependency with another
    +# version.
    +
    +go list example.com/dep
    +
    +cp replace_main_module.go.work go.work
    +! go list example.com/dep
    +stderr 'go: workspace module example.com/mainmoda is replaced at all versions in the go.work file. To fix, remove the replacement from the go.work file or specify the version at which to replace the module.'
    +
    +-- replace_main_module.go.work --
    +go 1.18
    +use (
    +    ./mainmoda
    +    ./mainmodb
    +)
    +replace example.com/mainmoda => ../mainmodareplacement
    +-- go.work --
    +go 1.18
    +use (
    +    ./mainmoda
    +    ./mainmodb
    +)
    +-- mainmoda/go.mod --
    +module example.com/mainmoda
    +
    +go 1.18
    +
    +require example.com/dep v1.0.0
    +replace example.com/dep => ../dep
    +
    +-- dep/go.mod --
    +module example.com/dep
    +-- dep/dep.go --
    +package dep
    +-- mainmodb/go.mod --
    +module example.com/mainmodb
    +go 1.18
    +replace example.com/mainmoda => ../mainmodareplacement
    +-- mainmodareplacement/go.mod --
    +module example.com/mainmoda
    +go 1.18
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_sum.txt b/go/src/cmd/go/testdata/script/work_sum.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..19dbb90507a57fc26155fa10d153e2db1836293f
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_sum.txt
    @@ -0,0 +1,34 @@
    +# Test adding sums to go.work.sum when sum isn't in go.mod.
    +
    +go run .
    +cmp go.work.sum want.sum
    +
    +-- want.sum --
    +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
    +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
    +rsc.io/quote v1.5.2 h1:3fEykkD9k7lYzXqCYrwGAf7iNhbk4yCjHmKBN9td4L0=
    +rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
    +-- go.work --
    +go 1.18
    +
    +use .
    +-- go.mod --
    +go 1.18
    +
    +module example.com/hi
    +
    +require "rsc.io/quote" v1.5.2
    +-- go.sum --
    +rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
    +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
    +-- main.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"rsc.io/quote"
    +)
    +
    +func main() {
    +	fmt.Println(quote.Hello())
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_sum_mismatch.txt b/go/src/cmd/go/testdata/script/work_sum_mismatch.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..ca5d71dc5e73c73a213488ca6518ad3e000367c0
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_sum_mismatch.txt
    @@ -0,0 +1,61 @@
    +# Test mismatched sums in go.sum files
    +
    +! go run ./a
    +cmpenv stderr want-error
    +
    +-- want-error --
    +verifying rsc.io/sampler@v1.3.0/go.mod: checksum mismatch
    +	downloaded: h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
    +	$WORK${/}gopath${/}src${/}a${/}go.sum:     h1:U1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
    +
    +SECURITY ERROR
    +This download does NOT match an earlier download recorded in go.sum.
    +The bits may have been replaced on the origin server, or an attacker may
    +have intercepted the download attempt.
    +
    +For more information, see 'go help module-auth'.
    +-- go.work --
    +go 1.18
    +
    +use ./a
    +use ./b
    +-- a/go.mod --
    +go 1.18
    +
    +module example.com/hi
    +
    +require "rsc.io/quote" v1.5.2
    +-- a/go.sum --
    +rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
    +rsc.io/sampler v1.3.0/go.mod h1:U1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
    +-- a/main.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"rsc.io/quote"
    +)
    +
    +func main() {
    +	fmt.Println(quote.Hello())
    +}
    +-- b/go.mod --
    +go 1.18
    +
    +module example.com/hi2
    +
    +require "rsc.io/quote" v1.5.2
    +-- b/go.sum --
    +rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
    +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
    +-- b/main.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"rsc.io/quote"
    +)
    +
    +func main() {
    +	fmt.Println(quote.Hello())
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_sync.txt b/go/src/cmd/go/testdata/script/work_sync.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..69167d4cc14d047e3f704fba628f5a13f6b4aac4
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_sync.txt
    @@ -0,0 +1,119 @@
    +go work sync
    +cmp a/go.mod a/want_go.mod
    +cmp b/go.mod b/want_go.mod
    +
    +-- go.work --
    +go 1.18
    +
    +use (
    +	./a
    +	./b
    +)
    +
    +-- a/go.mod --
    +go 1.18
    +
    +module example.com/a
    +
    +require (
    +	example.com/p v1.0.0
    +	example.com/q v1.1.0
    +	example.com/r v1.0.0
    +)
    +
    +replace (
    +	example.com/p => ../p
    +	example.com/q => ../q
    +	example.com/r => ../r
    +)
    +-- a/want_go.mod --
    +go 1.18
    +
    +module example.com/a
    +
    +require (
    +	example.com/p v1.1.0
    +	example.com/q v1.1.0
    +)
    +
    +replace (
    +	example.com/p => ../p
    +	example.com/q => ../q
    +	example.com/r => ../r
    +)
    +-- a/a.go --
    +package a
    +
    +import (
    +	"example.com/p"
    +	"example.com/q"
    +)
    +
    +func Foo() {
    +	p.P()
    +	q.Q()
    +}
    +-- b/go.mod --
    +go 1.18
    +
    +module example.com/b
    +
    +require (
    +	example.com/p v1.1.0
    +	example.com/q v1.0.0
    +)
    +
    +replace (
    +	example.com/p => ../p
    +	example.com/q => ../q
    +)
    +-- b/want_go.mod --
    +go 1.18
    +
    +module example.com/b
    +
    +require (
    +	example.com/p v1.1.0
    +	example.com/q v1.1.0
    +)
    +
    +replace (
    +	example.com/p => ../p
    +	example.com/q => ../q
    +)
    +-- b/b.go --
    +package b
    +
    +import (
    +	"example.com/p"
    +	"example.com/q"
    +)
    +
    +func Foo() {
    +	p.P()
    +	q.Q()
    +}
    +-- p/go.mod --
    +go 1.18
    +
    +module example.com/p
    +-- p/p.go --
    +package p
    +
    +func P() {}
    +-- q/go.mod --
    +go 1.18
    +
    +module example.com/q
    +-- q/q.go --
    +package q
    +
    +func Q() {}
    +-- r/go.mod --
    +go 1.18
    +
    +module example.com/r
    +-- r/q.go --
    +package r
    +
    +func R() {}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_sync_irrelevant_dependency.txt b/go/src/cmd/go/testdata/script/work_sync_irrelevant_dependency.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..072323d15da8e57974c4b3b29f176ae9b360ff43
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_sync_irrelevant_dependency.txt
    @@ -0,0 +1,119 @@
    +# Test of go work sync in a workspace in which some dependency needed by `a`
    +# appears at a lower version in the build list of `b`, but is not needed at all
    +# by `b` (so it should not be upgraded within b).
    +#
    +# a -> p 1.1
    +# b -> q 1.0 -(through a test dependency)-> p 1.0
    +go work sync
    +cmp a/go.mod a/want_go.mod
    +cmp b/go.mod b/want_go.mod
    +
    +-- go.work --
    +go 1.18
    +
    +use (
    +	./a
    +	./b
    +)
    +
    +-- a/go.mod --
    +go 1.18
    +
    +module example.com/a
    +
    +require (
    +	example.com/p v1.1.0
    +)
    +
    +replace (
    +	example.com/p => ../p
    +)
    +-- a/want_go.mod --
    +go 1.18
    +
    +module example.com/a
    +
    +require (
    +	example.com/p v1.1.0
    +)
    +
    +replace (
    +	example.com/p => ../p
    +)
    +-- a/a.go --
    +package a
    +
    +import (
    +	"example.com/p"
    +)
    +
    +func Foo() {
    +	p.P()
    +}
    +-- b/go.mod --
    +go 1.18
    +
    +module example.com/b
    +
    +require (
    +	example.com/q v1.0.0
    +)
    +
    +replace (
    +	example.com/q => ../q
    +)
    +-- b/want_go.mod --
    +go 1.18
    +
    +module example.com/b
    +
    +require (
    +	example.com/q v1.0.0
    +)
    +
    +replace (
    +	example.com/q => ../q
    +)
    +-- b/b.go --
    +package b
    +
    +import (
    +	"example.com/q"
    +)
    +
    +func Foo() {
    +	q.Q()
    +}
    +-- p/go.mod --
    +go 1.18
    +
    +module example.com/p
    +-- p/p.go --
    +package p
    +
    +func P() {}
    +-- q/go.mod --
    +go 1.18
    +
    +module example.com/q
    +
    +require (
    +	example.com/p v1.0.0
    +)
    +
    +replace (
    +	example.com/p => ../p
    +)
    +-- q/q.go --
    +package q
    +
    +func Q() {
    +}
    +-- q/q_test.go --
    +package q
    +
    +import example.com/p
    +
    +func TestQ(t *testing.T) {
    +	p.P()
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_sync_missing_module.txt b/go/src/cmd/go/testdata/script/work_sync_missing_module.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..0018c733ee7e1df8da22f2111517bbbb24fdfcad
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_sync_missing_module.txt
    @@ -0,0 +1,12 @@
    +# Ensure go work sync works without any modules in go.work.
    +go work sync
    +
    +# Ensure go work sync works even without a go.mod file.
    +rm go.mod
    +go work sync
    +
    +-- go.work --
    +go 1.18
    +-- go.mod --
    +go 1.18
    +module foo
    diff --git a/go/src/cmd/go/testdata/script/work_sync_relevant_dependency.txt b/go/src/cmd/go/testdata/script/work_sync_relevant_dependency.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..d7997027d9d74f5ed6d01a8569bca903626e2dc7
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_sync_relevant_dependency.txt
    @@ -0,0 +1,106 @@
    +# Test of go work sync in a workspace in which some dependency in the build
    +# list of 'b' (but not otherwise needed by `b`, so not seen when lazy loading
    +# occurs) actually is relevant to `a`.
    +#
    +# a -> p 1.0
    +# b -> q 1.1 -> p 1.1
    +go work sync
    +cmp a/go.mod a/want_go.mod
    +cmp b/go.mod b/want_go.mod
    +
    +-- go.work --
    +go 1.18
    +
    +use (
    +	./a
    +	./b
    +)
    +
    +-- a/go.mod --
    +go 1.18
    +
    +module example.com/a
    +
    +require (
    +	example.com/p v1.0.0
    +)
    +
    +replace (
    +	example.com/p => ../p
    +)
    +-- a/want_go.mod --
    +go 1.18
    +
    +module example.com/a
    +
    +require example.com/p v1.1.0
    +
    +replace example.com/p => ../p
    +-- a/a.go --
    +package a
    +
    +import (
    +	"example.com/p"
    +)
    +
    +func Foo() {
    +	p.P()
    +}
    +-- b/go.mod --
    +go 1.18
    +
    +module example.com/b
    +
    +require (
    +	example.com/q v1.1.0
    +)
    +
    +replace (
    +	example.com/q => ../q
    +)
    +-- b/want_go.mod --
    +go 1.18
    +
    +module example.com/b
    +
    +require (
    +	example.com/q v1.1.0
    +)
    +
    +replace (
    +	example.com/q => ../q
    +)
    +-- b/b.go --
    +package b
    +
    +import (
    +	"example.com/q"
    +)
    +
    +func Foo() {
    +	q.Q()
    +}
    +-- p/go.mod --
    +go 1.18
    +
    +module example.com/p
    +-- p/p.go --
    +package p
    +
    +func P() {}
    +-- q/go.mod --
    +go 1.18
    +
    +module example.com/q
    +
    +require example.com/p v1.1.0
    +
    +replace example.com/p => ../p
    +-- q/q.go --
    +package q
    +
    +import example.com/p
    +
    +func Q() {
    +	p.P()
    +}
    diff --git a/go/src/cmd/go/testdata/script/work_sync_sum.txt b/go/src/cmd/go/testdata/script/work_sync_sum.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..656fd31379ea4834ac759e0c398346d726362a80
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_sync_sum.txt
    @@ -0,0 +1,40 @@
    +# Test that the sum file data state is properly reset between modules in
    +# go work sync so that the sum file that's written is correct.
    +# Exercises the fix to #50038.
    +
    +cp b/go.sum b/go.sum.want
    +
    +# As a sanity check, verify b/go.sum is tidy.
    +cd b
    +go mod tidy
    +cd ..
    +cmp b/go.sum b/go.sum.want
    +
    +# Run go work sync and verify it doesn't change b/go.sum.
    +go work sync
    +cmp b/go.sum b/go.sum.want
    +
    +-- b/go.sum --
    +rsc.io/quote v1.0.0 h1:kQ3IZQzPTiDJxSZI98YaWgxFEhlNdYASHvh+MplbViw=
    +rsc.io/quote v1.0.0/go.mod h1:v83Ri/njykPcgJltBc/gEkJTmjTsNgtO1Y7vyIK1CQA=
    +-- go.work --
    +go 1.18
    +use (
    +    ./a
    +    ./b
    +)
    +replace example.com/c => ./c
    +-- a/go.mod --
    +module example.com/a
    +go 1.18
    +require rsc.io/fortune v1.0.0
    +-- a/a.go --
    +package a
    +import "rsc.io/fortune"
    +-- b/go.mod --
    +module example.com/b
    +go 1.18
    +require rsc.io/quote v1.0.0
    +-- b/b.go --
    +package b
    +import _ "rsc.io/quote"
    diff --git a/go/src/cmd/go/testdata/script/work_sync_toolchain.txt b/go/src/cmd/go/testdata/script/work_sync_toolchain.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..989d6bb792148adac2172dc9307e652e8cd4b652
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_sync_toolchain.txt
    @@ -0,0 +1,45 @@
    +# Create basic modules and work space.
    +env TESTGO_VERSION=go1.50
    +mkdir m1_22_0
    +go mod init -C m1_22_0
    +go mod edit -C m1_22_0 -go=1.22.0 -toolchain=go1.99.0
    +mkdir m1_22_1
    +go mod init -C m1_22_1
    +go mod edit -C m1_22_1 -go=1.22.1 -toolchain=go1.99.1
    +mkdir m1_24_rc0
    +go mod init -C m1_24_rc0
    +go mod edit -C m1_24_rc0 -go=1.24rc0 -toolchain=go1.99.2
    +
    +go work init ./m1_22_0 ./m1_22_1
    +grep '^go 1.50$' go.work
    +! grep toolchain go.work
    +
    +# work sync with older modules should leave go 1.50 in the go.work.
    +go work sync
    +cat go.work
    +grep '^go 1.50$' go.work
    +! grep toolchain go.work
    +
    +# work sync with newer modules should update go 1.21 -> 1.22.1 and toolchain -> go1.22.9 in go.work
    +env TESTGO_VERSION=go1.21
    +env TESTGO_VERSION_SWITCH=switch
    +go work edit -go=1.21
    +grep '^go 1.21$' go.work
    +! grep toolchain go.work
    +env GOTOOLCHAIN=local
    +! go work sync
    +stderr '^go: cannot load module m1_22_0 listed in go.work file: m1_22_0'${/}'go.mod requires go >= 1.22.0 \(running go 1.21; GOTOOLCHAIN=local\)$'
    +stderr '^go: cannot load module m1_22_1 listed in go.work file: m1_22_1'${/}'go.mod requires go >= 1.22.1 \(running go 1.21; GOTOOLCHAIN=local\)$'
    +env GOTOOLCHAIN=auto
    +go work sync
    +stderr '^go: m1_22_1'${/}'go.mod requires go >= 1.22.1; switching to go1.22.9$'
    +grep '^go 1.22.1$' go.work
    +! grep toolchain go.work
    +
    +# work sync with newer modules should update go 1.22.1 -> 1.24rc1 and drop toolchain
    +go work edit -use=./m1_24_rc0
    +go work sync
    +stderr '^go: m1_24_rc0'${/}'go.mod requires go >= 1.24rc0; switching to go1.24rc1$'
    +cat go.work
    +grep '^go 1.24rc0$' go.work
    +! grep toolchain go.work
    diff --git a/go/src/cmd/go/testdata/script/work_use.txt b/go/src/cmd/go/testdata/script/work_use.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..747089918f69ccd8112d7180da898f7ca4d3a59c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_use.txt
    @@ -0,0 +1,36 @@
    +go work use -r foo
    +cmp go.work go.want_work_r
    +
    +! go work use other
    +stderr '^go: error reading other'${/}'go.mod: missing module declaration'
    +
    +go mod edit -C other -module=other
    +go work use other
    +cmp go.work go.want_work_other
    +-- go.work --
    +go 1.18
    +
    +use (
    +	foo
    +	foo/bar // doesn't exist
    +)
    +-- go.want_work_r --
    +go 1.18
    +
    +use (
    +	./foo
    +	./foo/bar/baz
    +)
    +-- go.want_work_other --
    +go 1.18
    +
    +use (
    +	./foo
    +	./foo/bar/baz
    +	./other
    +)
    +-- foo/go.mod --
    +module foo
    +-- foo/bar/baz/go.mod --
    +module baz
    +-- other/go.mod --
    diff --git a/go/src/cmd/go/testdata/script/work_use_deleted.txt b/go/src/cmd/go/testdata/script/work_use_deleted.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b379cbc09d982626cc70b0b1f48e02b60bc1c9d3
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_use_deleted.txt
    @@ -0,0 +1,22 @@
    +go work use -r .
    +cmp go.work go.work.want
    +
    +-- go.work --
    +go 1.18
    +
    +use (
    +	.
    +	./sub
    +	./sub/dir/deleted
    +)
    +-- go.work.want --
    +go 1.18
    +
    +use ./sub/dir
    +-- sub/README.txt --
    +A go.mod file has been deleted from this directory.
    +In addition, the entire subdirectory sub/dir/deleted
    +has been deleted, along with sub/dir/deleted/go.mod.
    +-- sub/dir/go.mod --
    +module example/sub/dir
    +go 1.18
    diff --git a/go/src/cmd/go/testdata/script/work_use_dot.txt b/go/src/cmd/go/testdata/script/work_use_dot.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8f210423ec2ad1f3fb579ccaaab23a90480a204a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_use_dot.txt
    @@ -0,0 +1,49 @@
    +cp go.work go.work.orig
    +
    +# If the current directory contains a go.mod file,
    +# 'go work use .' should add an entry for it.
    +cd bar/baz
    +go work use .
    +cmp ../../go.work ../../go.work.rel
    +
    +# If the current directory lacks a go.mod file, 'go work use .'
    +# should remove its entry.
    +mv go.mod go.mod.bak
    +go work use .
    +cmp ../../go.work ../../go.work.orig
    +
    +# If the path is absolute, it should remain absolute.
    +mv go.mod.bak go.mod
    +go work use $PWD
    +grep -count=1 '^use ' ../../go.work
    +grep '^use ["]?'$PWD'["]?$' ../../go.work
    +
    +# An absolute path should replace an entry for the corresponding relative path
    +# and vice-versa.
    +go work use .
    +cmp ../../go.work ../../go.work.rel
    +go work use $PWD
    +grep -count=1 '^use ' ../../go.work
    +grep '^use ["]?'$PWD'["]?$' ../../go.work
    +
    +# If both the absolute and relative paths are named, 'go work use' should error
    +# out: we don't know which one to use, and shouldn't add both because the
    +# resulting workspace would contain a duplicate module.
    +cp ../../go.work.orig ../../go.work
    +! go work use $PWD .
    +stderr '^go: already added "\./bar/baz" as "'$PWD'"$'
    +cmp ../../go.work ../../go.work.orig
    +
    +
    +-- go.mod --
    +module example
    +go 1.18
    +-- go.work --
    +go 1.18
    +-- go.work.rel --
    +go 1.18
    +
    +use ./bar/baz
    +-- bar/baz/go.mod --
    +module example/bar/baz
    +go 1.18
    diff --git a/go/src/cmd/go/testdata/script/work_use_issue50958.txt b/go/src/cmd/go/testdata/script/work_use_issue50958.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..7a25531f3d1cd20715d615aa9ab53a1ec51695b1
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_use_issue50958.txt
    @@ -0,0 +1,17 @@
    +go work use -r .
    +cmp go.work go.work.want
    +
    +-- go.mod --
    +module example
    +go 1.18
    +-- go.work --
    +go 1.18
    +
    +use sub
    +-- go.work.want --
    +go 1.18
    +
    +use .
    +-- sub/README.txt --
    +This directory no longer contains a go.mod file.
    +
    diff --git a/go/src/cmd/go/testdata/script/work_use_issue55952.txt b/go/src/cmd/go/testdata/script/work_use_issue55952.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..befec67227c621cbc78febda67ec86bd71b2bd0b
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_use_issue55952.txt
    @@ -0,0 +1,11 @@
    +! go list .
    +stderr '^go: cannot load module y listed in go\.work file: open y'${/}'go\.mod:'
    +
    +-- go.work --
    +use ./y
    +-- x/go.mod --
    +module x
    +
    +go 1.19
    +-- x/m.go --
    +package m
    diff --git a/go/src/cmd/go/testdata/script/work_use_only_dirs.txt b/go/src/cmd/go/testdata/script/work_use_only_dirs.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..5d0fcdd2a966bc2ec9ba0c4e7252b789b8479d92
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_use_only_dirs.txt
    @@ -0,0 +1,17 @@
    +! go work use foo bar baz
    +
    +stderr '^go: foo is not a directory'
    +stderr '^go: directory baz does not exist'
    +cmp go.work go.work_want
    +
    +! go work use -r qux
    +stderr '^go: qux is not a directory'
    +
    +-- go.work --
    +go 1.18
    +-- go.work_want --
    +go 1.18
    +-- foo --
    +-- qux --
    +-- bar/go.mod --
    +module bar
    diff --git a/go/src/cmd/go/testdata/script/work_use_symlink_issue68383.txt b/go/src/cmd/go/testdata/script/work_use_symlink_issue68383.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..7bcc96d39b0f21d33cf02c9b0cbfb547bcd146bf
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_use_symlink_issue68383.txt
    @@ -0,0 +1,23 @@
    +# This is a test for #68383, where go work use is used in a CWD
    +# one of whose parent directories is a symlink, trying to use
    +# a directory that exists in a subdirectory of a parent of that
    +# directory.
    +
    +[!symlink] skip 'tests an issue involving symlinks'
    +
    +symlink sym -> a/b
    +cd sym/c/d
    +
    +go work use $WORK/gopath/src/x/y    # "crosses" the symlink at $WORK/sym
    +cmpenv go.work go.work.want  # Check that the relative path is not used
    +
    +-- x/y/go.mod --
    +module example.com/y
    +
    +go 1.24
    +-- a/b/c/d/go.work --
    +go 1.24
    +-- a/b/c/d/go.work.want --
    +go 1.24
    +
    +use $WORK${/}gopath${/}src${/}x${/}y
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_use_toolchain.txt b/go/src/cmd/go/testdata/script/work_use_toolchain.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..d81e4a4c3ef13e8352abe347accfca44036e5576
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_use_toolchain.txt
    @@ -0,0 +1,51 @@
    +# Create basic modules and work space.
    +env TESTGO_VERSION=go1.50
    +mkdir m1_22_0
    +go mod init -C m1_22_0
    +go mod edit -C m1_22_0 -go=1.22.0 -toolchain=go1.99.0
    +mkdir m1_22_1
    +go mod init -C m1_22_1
    +go mod edit -C m1_22_1 -go=1.22.1 -toolchain=go1.99.1
    +mkdir m1_24_rc0
    +go mod init -C m1_24_rc0
    +go mod edit -C m1_24_rc0 -go=1.24rc0 -toolchain=go1.99.2
    +
    +go work init
    +grep '^go 1.50$' go.work
    +! grep toolchain go.work
    +
    +# work use with older modules should leave go 1.50 in the go.work.
    +go work use ./m1_22_0
    +grep '^go 1.50$' go.work
    +! grep toolchain go.work
    +
    +# work use with newer modules should bump go and toolchain,
    +# including updating to a newer toolchain as needed.
    +env TESTGO_VERSION=go1.21
    +env TESTGO_VERSION_SWITCH=switch
    +rm go.work
    +go work init
    +env GOTOOLCHAIN=local
    +! go work use ./m1_22_0
    +stderr '^go: m1_22_0'${/}'go.mod requires go >= 1.22.0 \(running go 1.21; GOTOOLCHAIN=local\)$'
    +env GOTOOLCHAIN=auto
    +go work use ./m1_22_0
    +stderr '^go: m1_22_0'${/}'go.mod requires go >= 1.22.0; switching to go1.22.9$'
    +grep '^go 1.22.0$' go.work
    +! grep toolchain go.work
    +
    +# work use with an even newer module should bump go again.
    +go work use ./m1_22_1
    +stderr '^go: m1_22_1'${/}'go.mod requires go >= 1.22.1; switching to go1.22.9$'
    +grep '^go 1.22.1$' go.work
    +! grep toolchain go.work
    +
    +# work use with an even newer module should bump go and toolchain again.
    +env GOTOOLCHAIN=go1.22.9
    +! go work use ./m1_24_rc0
    +stderr '^go: m1_24_rc0'${/}'go.mod requires go >= 1.24rc0 \(running go 1.22.9; GOTOOLCHAIN=go1.22.9\)$'
    +env GOTOOLCHAIN=auto
    +go work use ./m1_24_rc0
    +stderr '^go: m1_24_rc0'${/}'go.mod requires go >= 1.24rc0; switching to go1.24rc1$'
    +grep '^go 1.24rc0$' go.work
    +! grep 'toolchain' go.work
    diff --git a/go/src/cmd/go/testdata/script/work_vendor_empty.txt b/go/src/cmd/go/testdata/script/work_vendor_empty.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..3c0c7ed6a4fcdb86590eb7539f53d3227e13b7bb
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_vendor_empty.txt
    @@ -0,0 +1,16 @@
    +go work vendor
    +stderr 'go: no dependencies to vendor'
    +! exists vendor/modules.txt
    +! go list .
    +stderr 'go: no modules were found in the current workspace'
    +mkdir vendor
    +mv bad_modules.txt vendor/modules.txt
    +! go list .
    +stderr 'go: no modules were found in the current workspace'
    +
    +-- bad_modules.txt --
    +# a/module
    +a/package
    +-- go.work --
    +go 1.21
    +
    diff --git a/go/src/cmd/go/testdata/script/work_vendor_main_module_replaced.txt b/go/src/cmd/go/testdata/script/work_vendor_main_module_replaced.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..70446c7d419c824950fcb93f35a83807ab0f0c31
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_vendor_main_module_replaced.txt
    @@ -0,0 +1,46 @@
    +# This is a test that if one of the main modules replaces the other
    +# the vendor consistency checks still pass. The replacement is ignored
    +# because it is of a main module, but it is still recorded in
    +# vendor/modules.txt.
    +
    +go work vendor
    +go list all # make sure the consistency checks pass
    +! stderr .
    +
    +# Removing the replace causes consistency checks to fail
    +cp a_go_mod_no_replace a/go.mod
    +! go list all # consistency checks fail
    +stderr 'example.com/b@v0.0.0: is marked as replaced in vendor/modules.txt, but not replaced in the workspace'
    +
    +
    +-- a_go_mod_no_replace --
    +module example.com/a
    +
    +go 1.21
    +
    +require example.com/b v0.0.0
    +-- go.work --
    +go 1.21
    +
    +use (
    +    a
    +    b
    +)
    +-- a/go.mod --
    +module example.com/a
    +
    +go 1.21
    +
    +require example.com/b v0.0.0
    +
    +replace example.com/b => ../b
    +-- a/a.go --
    +package a
    +
    +import _ "example.com/b"
    +-- b/go.mod --
    +module example.com/b
    +
    +go 1.21
    +-- b/b.go --
    +package b
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_vendor_modules_txt_conditional.txt b/go/src/cmd/go/testdata/script/work_vendor_modules_txt_conditional.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..3d671ebaab121cb0c270ea443e9d0883bdcd4cc7
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_vendor_modules_txt_conditional.txt
    @@ -0,0 +1,62 @@
    +# This test checks to see if we only start in workspace vendor
    +# mode if the modules.txt specifies ## workspace (and only in
    +# standard vendor if it doesn't).
    +
    +# vendor directory produced for workspace, workspace mode
    +# runs in mod=vendor
    +go work vendor
    +cmp vendor/modules.txt want_workspace_modules_txt
    +go list -f {{.Dir}} example.com/b
    +stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]b
    +
    +# vendor directory produced for workspace, module mode
    +# runs in mod=readonly
    +env GOWORK=off
    +go list -f {{.Dir}} example.com/b
    +stdout $GOPATH[\\/]src[\\/]b
    +
    +# vendor directory produced for module, module mode
    +# runs in mod=vendor
    +go mod vendor
    +cmp vendor/modules.txt want_module_modules_txt
    +go list -f {{.Dir}} example.com/b
    +stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]b
    +
    +# vendor directory produced for module, workspace mode
    +# runs in mod=readonly
    +env GOWORK=
    +go list -f {{.Dir}} example.com/b
    +stdout $GOPATH[\\/]src[\\/]b
    +
    +-- want_workspace_modules_txt --
    +## workspace
    +# example.com/b v0.0.0 => ./b
    +## explicit; go 1.21
    +example.com/b
    +# example.com/b => ./b
    +-- want_module_modules_txt --
    +# example.com/b v0.0.0 => ./b
    +## explicit; go 1.21
    +example.com/b
    +# example.com/b => ./b
    +-- go.work --
    +go 1.21
    +
    +use .
    +-- go.mod --
    +module example.com/a
    +
    +go 1.21
    +
    +require example.com/b v0.0.0
    +replace example.com/b => ./b
    +-- a.go --
    +package a
    +
    +import _ "example.com/b"
    +-- b/go.mod --
    +module example.com/b
    +
    +go 1.21
    +-- b/b.go --
    +package b
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_vendor_modules_txt_consistent.txt b/go/src/cmd/go/testdata/script/work_vendor_modules_txt_consistent.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..bc0f068fd04bf48afc98804a90974e1d99d3c53d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_vendor_modules_txt_consistent.txt
    @@ -0,0 +1,141 @@
    +go work vendor
    +cmp modules.txt.want vendor/modules.txt
    +go list example.com/a example.com/b
    +
    +# Module required in go.mod but not marked explicit in modules.txt
    +cp modules.txt.required_but_not_explicit vendor/modules.txt
    +! go list example.com/a example.com/b
    +cmpenv stderr required_but_not_explicit_error.txt
    +
    +# Replacement in go.mod but no replacement in modules.txt
    +cp modules.txt.missing_replacement vendor/modules.txt
    +! go list example.com/a example.com/b
    +cmpenv stderr missing_replacement_error.txt
    +
    +# Replacement in go.mod but different replacement target in modules.txt
    +cp modules.txt.different_replacement vendor/modules.txt
    +! go list example.com/a example.com/b
    +cmpenv stderr different_replacement_error.txt
    +
    +# Module marked explicit in modules.txt but not required in go.mod
    +cp modules.txt.extra_explicit vendor/modules.txt
    +! go list example.com/a example.com/b
    +cmpenv stderr extra_explicit_error.txt
    +
    +# Replacement in modules.txt but not in go.mod
    +cp modules.txt.extra_replacement vendor/modules.txt
    +! go list example.com/a example.com/b
    +cmpenv stderr extra_replacement_error.txt
    +
    +-- modules.txt.want --
    +## workspace
    +# example.com/p v1.0.0 => ./p
    +## explicit; go 1.21
    +# example.com/q v1.0.0 => ./q
    +## explicit; go 1.21
    +-- modules.txt.required_but_not_explicit --
    +## workspace
    +# example.com/p v1.0.0 => ./p
    +## go 1.21
    +# example.com/q v1.0.0 => ./q
    +## explicit; go 1.21
    +-- required_but_not_explicit_error.txt --
    +go: inconsistent vendoring in $GOPATH${/}src:
    +	example.com/p@v1.0.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    +
    +	To ignore the vendor directory, use -mod=readonly or -mod=mod.
    +	To sync the vendor directory, run:
    +		go work vendor
    +-- modules.txt.missing_replacement --
    +## workspace
    +# example.com/p v1.0.0
    +## explicit; go 1.21
    +# example.com/q v1.0.0 => ./q
    +## explicit; go 1.21
    +-- missing_replacement_error.txt --
    +go: inconsistent vendoring in $GOPATH${/}src:
    +	example.com/p@v1.0.0: is replaced in a${/}go.mod, but not marked as replaced in vendor/modules.txt
    +
    +	To ignore the vendor directory, use -mod=readonly or -mod=mod.
    +	To sync the vendor directory, run:
    +		go work vendor
    +-- modules.txt.different_replacement --
    +## workspace
    +# example.com/p v1.0.0 => ./r
    +## explicit; go 1.21
    +# example.com/q v1.0.0 => ./q
    +## explicit; go 1.21
    +-- different_replacement_error.txt --
    +go: inconsistent vendoring in $GOPATH${/}src:
    +	example.com/p@v1.0.0: is replaced by ../p in a${/}go.mod, but marked as replaced by ./r in vendor/modules.txt
    +
    +	To ignore the vendor directory, use -mod=readonly or -mod=mod.
    +	To sync the vendor directory, run:
    +		go work vendor
    +-- modules.txt.extra_explicit --
    +## workspace
    +# example.com/p v1.0.0 => ./p
    +## explicit; go 1.21
    +# example.com/q v1.0.0 => ./q
    +## explicit; go 1.21
    +# example.com/r v1.0.0
    +example.com/r
    +## explicit; go 1.21
    +-- extra_explicit_error.txt --
    +go: inconsistent vendoring in $GOPATH${/}src:
    +	example.com/r@v1.0.0: is marked as explicit in vendor/modules.txt, but not explicitly required in a go.mod
    +
    +	To ignore the vendor directory, use -mod=readonly or -mod=mod.
    +	To sync the vendor directory, run:
    +		go work vendor
    +-- modules.txt.extra_replacement --
    +## workspace
    +# example.com/p v1.0.0 => ./p
    +## explicit; go 1.21
    +# example.com/q v1.0.0 => ./q
    +## explicit; go 1.21
    +# example.com/r v1.0.0 => ./r
    +example.com/r
    +## go 1.21
    +-- extra_replacement_error.txt --
    +go: inconsistent vendoring in $GOPATH${/}src:
    +	example.com/r@v1.0.0: is marked as replaced in vendor/modules.txt, but not replaced in the workspace
    +
    +	To ignore the vendor directory, use -mod=readonly or -mod=mod.
    +	To sync the vendor directory, run:
    +		go work vendor
    +-- go.work --
    +go 1.21
    +
    +use (
    +    ./a
    +    ./b
    +)
    +-- a/go.mod --
    +module example.com/a
    +
    +go 1.21
    +
    +require example.com/p v1.0.0
    +
    +replace example.com/p v1.0.0 => ../p
    +-- a/a.go --
    +package p
    +-- b/go.mod --
    +module example.com/b
    +
    +go 1.21
    +
    +require example.com/q v1.0.0
    +
    +replace example.com/q v1.0.0 => ../q
    +-- b/b.go --
    +package b
    +-- p/go.mod --
    +module example.com/p
    +
    +go 1.21
    +-- q/go.mod --
    +module example.com/q
    +
    +go 1.21
    diff --git a/go/src/cmd/go/testdata/script/work_vendor_prune.txt b/go/src/cmd/go/testdata/script/work_vendor_prune.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..424b4d59da0bb317bb3528e8d0f77b90b771f7ae
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_vendor_prune.txt
    @@ -0,0 +1,116 @@
    +# This test exercises that vendoring works properly using the workspace in the
    +# the work_prune test case.
    +
    +go work vendor
    +cmp vendor/modules.txt modules.txt.want
    +cmp vendor/example.com/b/b.go b/b.go
    +cmp vendor/example.com/q/q.go q1_1_0/q.go
    +go list -m -f '{{.Version}}' example.com/q
    +stdout '^v1.1.0$'
    +
    +go list -f '{{.Dir}}' example.com/q
    +stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]q
    +go list -f '{{.Dir}}' example.com/b
    +stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]b
    +
    +[short] skip
    +
    +rm b
    +rm q1_0_0
    +rm q1_1_0
    +go run example.com/p
    +stdout 'version 1.1.0'
    +
    +-- modules.txt.want --
    +## workspace
    +# example.com/b v1.0.0 => ./b
    +## explicit; go 1.18
    +example.com/b
    +# example.com/q v1.0.0 => ./q1_0_0
    +## explicit; go 1.18
    +# example.com/q v1.1.0 => ./q1_1_0
    +## go 1.18
    +example.com/q
    +-- go.work --
    +go 1.18
    +
    +use (
    +	./a
    +	./p
    +)
    +-- a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +
    +require example.com/b v1.0.0
    +
    +replace example.com/b v1.0.0 => ../b
    +-- a/foo.go --
    +package main
    +
    +import "example.com/b"
    +
    +func main() {
    +	b.B()
    +}
    +-- b/go.mod --
    +module example.com/b
    +
    +go 1.18
    +
    +require example.com/q v1.1.0
    +-- b/b.go --
    +package b
    +
    +func B() {
    +}
    +-- b/b_test.go --
    +package b
    +
    +import "example.com/q"
    +
    +func TestB() {
    +	q.PrintVersion()
    +}
    +-- p/go.mod --
    +module example.com/p
    +
    +go 1.18
    +
    +require example.com/q v1.0.0
    +
    +replace example.com/q v1.0.0 => ../q1_0_0
    +replace example.com/q v1.1.0 => ../q1_1_0
    +-- p/main.go --
    +package main
    +
    +import "example.com/q"
    +
    +func main() {
    +	q.PrintVersion()
    +}
    +-- q1_0_0/go.mod --
    +module example.com/q
    +
    +go 1.18
    +-- q1_0_0/q.go --
    +package q
    +
    +import "fmt"
    +
    +func PrintVersion() {
    +	fmt.Println("version 1.0.0")
    +}
    +-- q1_1_0/go.mod --
    +module example.com/q
    +
    +go 1.18
    +-- q1_1_0/q.go --
    +package q
    +
    +import "fmt"
    +
    +func PrintVersion() {
    +	fmt.Println("version 1.1.0")
    +}
    diff --git a/go/src/cmd/go/testdata/script/work_vendor_prune_all.txt b/go/src/cmd/go/testdata/script/work_vendor_prune_all.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a369d22bd808cb03158add21e8f4d938a5eddd78
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_vendor_prune_all.txt
    @@ -0,0 +1,201 @@
    +# This test exercises that vendoring works properly using the workspace in the
    +# the work_prune test case.
    +
    +go work vendor
    +cmp vendor/modules.txt modules.txt.want
    +go list -f '{{with .Module}}{{.Path}}@{{.Version}}{{end}}' all
    +cmp stdout want_versions
    +
    +go list -f '{{.Dir}}' example.com/q
    +stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]q
    +go list -f '{{.Dir}}' example.com/b
    +stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]b
    +go list -f '{{.Dir}}' example.com/w
    +stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]w
    +go list -f '{{.Dir}}' example.com/z
    +stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]z
    +
    +cmp $GOPATH/src/vendor/example.com/q/q.go q1_1_0/q.go
    +
    +-- modules.txt.want --
    +## workspace
    +# example.com/b v1.0.0 => ./b
    +## explicit; go 1.18
    +example.com/b
    +# example.com/q v1.0.0 => ./q1_0_0
    +## explicit; go 1.18
    +# example.com/q v1.1.0 => ./q1_1_0
    +## go 1.18
    +example.com/q
    +# example.com/w v1.0.0 => ./w
    +## go 1.18
    +example.com/w
    +# example.com/z v1.0.0 => ./z1_0_0
    +## explicit; go 1.18
    +# example.com/z v1.1.0 => ./z1_1_0
    +## go 1.18
    +example.com/z
    +# example.com/q v1.0.5 => ./q1_0_5
    +# example.com/r v1.0.0 => ./r
    +# example.com/x v1.0.0 => ./x
    +# example.com/y v1.0.0 => ./y
    +-- want_versions --
    +example.com/a@
    +example.com/b@v1.0.0
    +example.com/p@
    +example.com/q@v1.1.0
    +example.com/w@v1.0.0
    +example.com/z@v1.1.0
    +-- go.work --
    +go 1.18
    +
    +use (
    +	./a
    +	./p
    +)
    +
    +replace example.com/b v1.0.0 => ./b
    +replace example.com/q v1.0.0 => ./q1_0_0
    +replace example.com/q v1.0.5 => ./q1_0_5
    +replace example.com/q v1.1.0 => ./q1_1_0
    +replace example.com/r v1.0.0 => ./r
    +replace example.com/w v1.0.0 => ./w
    +replace example.com/x v1.0.0 => ./x
    +replace example.com/y v1.0.0 => ./y
    +replace example.com/z v1.0.0 => ./z1_0_0
    +replace example.com/z v1.1.0 => ./z1_1_0
    +
    +-- a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +
    +require example.com/b v1.0.0
    +require example.com/z v1.0.0
    +-- a/foo.go --
    +package main
    +
    +import "example.com/b"
    +
    +func main() {
    +	b.B()
    +}
    +-- b/go.mod --
    +module example.com/b
    +
    +go 1.18
    +
    +require example.com/q v1.1.0
    +-- b/b.go --
    +package b
    +
    +func B() {
    +}
    +-- p/go.mod --
    +module example.com/p
    +
    +go 1.18
    +
    +require example.com/q v1.0.0
    +
    +replace example.com/q v1.0.0 => ../q1_0_0
    +replace example.com/q v1.1.0 => ../q1_1_0
    +-- p/main.go --
    +package main
    +
    +import "example.com/q"
    +
    +func main() {
    +	q.PrintVersion()
    +}
    +-- q1_0_0/go.mod --
    +module example.com/q
    +
    +go 1.18
    +-- q1_0_0/q.go --
    +package q
    +
    +import "fmt"
    +
    +func PrintVersion() {
    +	fmt.Println("version 1.0.0")
    +}
    +-- q1_0_5/go.mod --
    +module example.com/q
    +
    +go 1.18
    +
    +require example.com/r v1.0.0
    +-- q1_0_5/q.go --
    +package q
    +
    +import _ "example.com/r"
    +-- q1_1_0/go.mod --
    +module example.com/q
    +
    +require example.com/w v1.0.0
    +require example.com/z v1.1.0
    +
    +go 1.18
    +-- q1_1_0/q.go --
    +package q
    +
    +import _ "example.com/w"
    +import _ "example.com/z"
    +
    +import "fmt"
    +
    +func PrintVersion() {
    +	fmt.Println("version 1.1.0")
    +}
    +-- r/go.mod --
    +module example.com/r
    +
    +go 1.18
    +
    +require example.com/r v1.0.0
    +-- r/r.go --
    +package r
    +-- w/go.mod --
    +module example.com/w
    +
    +go 1.18
    +
    +require example.com/x v1.0.0
    +-- w/w.go --
    +package w
    +-- w/w_test.go --
    +package w
    +
    +import _ "example.com/x"
    +-- x/go.mod --
    +module example.com/x
    +
    +go 1.18
    +-- x/x.go --
    +package x
    +-- x/x_test.go --
    +package x
    +import _ "example.com/y"
    +-- y/go.mod --
    +module example.com/y
    +
    +go 1.18
    +-- y/y.go --
    +package y
    +-- z1_0_0/go.mod --
    +module example.com/z
    +
    +go 1.18
    +
    +require example.com/q v1.0.5
    +-- z1_0_0/z.go --
    +package z
    +
    +import _ "example.com/q"
    +-- z1_1_0/go.mod --
    +module example.com/z
    +
    +go 1.18
    +-- z1_1_0/z.go --
    +package z
    diff --git a/go/src/cmd/go/testdata/script/work_vet.txt b/go/src/cmd/go/testdata/script/work_vet.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f95caddad675c495c5e2e8712fb9cbc9ed99869d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_vet.txt
    @@ -0,0 +1,19 @@
    +! go vet ./a
    +stderr 'fmt.Println call has possible Printf formatting directive'
    +
    +-- go.work --
    +go 1.18
    +
    +use ./a
    +-- a/go.mod --
    +module example.com/a
    +
    +go 1.18
    +-- a/a.go --
    +package a
    +
    +import "fmt"
    +
    +func A() {
    +    fmt.Println("%s")
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/script/work_why_download_graph.txt b/go/src/cmd/go/testdata/script/work_why_download_graph.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8f1aeddf47106d3abc51ba45610853ed0fab3164
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/work_why_download_graph.txt
    @@ -0,0 +1,65 @@
    +# Test go mod download, why, and graph work in workspace mode.
    +# TODO(bcmills): clarify the interaction with #44435
    +
    +go mod download rsc.io/quote
    +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info
    +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
    +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
    +! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
    +! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
    +grep '^rsc\.io/quote v1\.5\.2/go\.mod h1:' go.work.sum
    +grep '^rsc\.io/quote v1\.5\.2 h1:' go.work.sum
    +
    +go clean -modcache
    +rm go.work.sum
    +go mod download
    +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info
    +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
    +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
    +! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
    +! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
    +grep '^rsc\.io/quote v1\.5\.2/go\.mod h1:' go.work.sum
    +grep '^rsc\.io/quote v1\.5\.2 h1:' go.work.sum
    +
    +go mod why rsc.io/quote
    +stdout '# rsc.io/quote\nexample.com/a\nrsc.io/quote'
    +
    +go mod graph
    +stdout 'example.com/a rsc.io/quote@v1.5.2\nexample.com/b example.com/c@v1.0.0\nrsc.io/quote@v1.5.2 rsc.io/sampler@v1.3.0\nrsc.io/sampler@v1.3.0 golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c'
    +
    +-- go.work --
    +go 1.18
    +
    +use (
    +	./a
    +	./b
    +)
    +-- a/go.mod --
    +go 1.18
    +
    +module example.com/a
    +
    +require "rsc.io/quote" v1.5.2
    +-- a/main.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"rsc.io/quote"
    +)
    +
    +func main() {
    +	fmt.Println(quote.Hello())
    +}
    +-- b/go.mod --
    +go 1.18
    +
    +module example.com/b
    +
    +require example.com/c v1.0.0
    +replace example.com/c => ../c
    +-- c/go.mod --
    +go 1.18
    +
    +module example.com/c
    +
    diff --git a/go/src/cmd/go/testdata/script/ws2_32.txt b/go/src/cmd/go/testdata/script/ws2_32.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..54f6a94eaf84f3f20e7b854cc4338e68431527d8
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/script/ws2_32.txt
    @@ -0,0 +1,48 @@
    +[!GOOS:windows] skip
    +
    +go run .
    +stdout 'ws2_32.dll: not found'
    +
    +go run -tags net .
    +stdout 'ws2_32.dll: found'
    +
    +-- go.mod --
    +module m
    +
    +go 1.21
    +
    +-- utils.go --
    +package main
    +
    +import (
    +	"fmt"
    +	"syscall"
    +	"unsafe"
    +)
    +
    +func hasModuleHandle() {
    +	const ws2_32 = "ws2_32.dll"
    +	getModuleHandle := syscall.MustLoadDLL("kernel32.dll").MustFindProc("GetModuleHandleW")
    +	mod, _, _ := getModuleHandle.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(ws2_32))))
    +	if mod != 0 {
    +		fmt.Println(ws2_32+":", "found")
    +	} else {
    +		fmt.Println(ws2_32+":", "not found")
    +	}
    +}
    +-- net.go --
    +//go:build net
    +package main
    +
    +import _ "net"
    +
    +func main() {
    +    hasModuleHandle()
    +}
    +-- nonet.go --
    +//go:build !net
    +package main
    +
    +func main() {
    +    hasModuleHandle()
    +}
    \ No newline at end of file
    diff --git a/go/src/cmd/go/testdata/vcstest/README b/go/src/cmd/go/testdata/vcstest/README
    new file mode 100644
    index 0000000000000000000000000000000000000000..f3a0e1558972cf5b4a4855744ed30093745ebf92
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/README
    @@ -0,0 +1,14 @@
    +The scripts in this directory set up version-control repos for use in
    +tests of cmd/go and its subpackages.
    +
    +They are written in a dialect of the same script language as in
    +cmd/go/testdata/script, and the outputs are hosted by the server in
    +cmd/go/internal/vcweb.
    +
    +To see the conditions and commands available for these scripts, run:
    +
    +	go test cmd/go/internal/vcweb -v --run=TestHelp
    +
    +To host these scripts in a standalone server, run:
    +
    +	go test cmd/go/internal/vcweb/vcstest -v --port=0
    diff --git a/go/src/cmd/go/testdata/vcstest/auth/or401.txt b/go/src/cmd/go/testdata/vcstest/auth/or401.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..10da48d90c259e28576d3f2b2bb90ca9df09b2b2
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/auth/or401.txt
    @@ -0,0 +1,29 @@
    +handle auth
    +
    +modzip vcs-test.golang.org/auth/or401/@v/v0.0.0-20190405155051-52df474c8a8b.zip vcs-test.golang.org/auth/or401@v0.0.0-20190405155051-52df474c8a8b .moddir
    +
    +-- .access --
    +{
    +	"Username": "aladdin",
    +	"Password": "opensesame",
    +	"StatusCode": 401,
    +	"Message": "ACCESS DENIED, buddy"
    +}
    +-- index.html --
    +
    +
    +
    +-- vcs-test.golang.org/auth/or401/@v/list --
    +v0.0.0-20190405155051-52df474c8a8b
    +-- vcs-test.golang.org/auth/or401/@v/v0.0.0-20190405155051-52df474c8a8b.info --
    +{"Version":"v0.0.0-20190405155051-52df474c8a8b","Time":"2019-04-05T15:50:51Z"}
    +-- vcs-test.golang.org/auth/or401/@v/v0.0.0-20190405155051-52df474c8a8b.mod --
    +module vcs-test.golang.org/auth/or401
    +
    +go 1.13
    +-- .moddir/go.mod --
    +module vcs-test.golang.org/auth/or401
    +
    +go 1.13
    +-- .moddir/or401.go --
    +package or401
    diff --git a/go/src/cmd/go/testdata/vcstest/auth/or404.txt b/go/src/cmd/go/testdata/vcstest/auth/or404.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..9e393c70eadb69ca7259cd5814ab8b68fd926901
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/auth/or404.txt
    @@ -0,0 +1,30 @@
    +handle auth
    +
    +modzip vcs-test.golang.org/auth/or404/@v/v0.0.0-20190405155004-2234c475880e.zip vcs-test.golang.org/auth/or404@v0.0.0-20190405155004-2234c475880e .moddir
    +
    +-- .access --
    +{
    +	"Username": "aladdin",
    +	"Password": "opensesame",
    +	"StatusCode": 404,
    +	"Message": "File? What file?"
    +}
    +-- index.html --
    +
    +
    +
    +-- vcs-test.golang.org/auth/or404/@v/list --
    +v0.0.0-20190405155004-2234c475880e
    +-- vcs-test.golang.org/auth/or404/@v/v0.0.0-20190405155004-2234c475880e.info --
    +{"Version":"v0.0.0-20190405155004-2234c475880e","Time":"2019-04-05T15:50:04Z"}
    +-- vcs-test.golang.org/auth/or404/@v/v0.0.0-20190405155004-2234c475880e.mod --
    +module vcs-test.golang.org/auth/or404
    +
    +go 1.13
    +-- .moddir/go.mod --
    +module vcs-test.golang.org/auth/or404
    +
    +go 1.13
    +-- .moddir/or404.go --
    +package or404
    +-- vcs-test.golang.org/go/modauth404/@v/list --
    diff --git a/go/src/cmd/go/testdata/vcstest/auth/ormanylines.txt b/go/src/cmd/go/testdata/vcstest/auth/ormanylines.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..41cf5fe20d1df8ece25b5dbe21e1fb9567af9919
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/auth/ormanylines.txt
    @@ -0,0 +1,9 @@
    +handle auth
    +
    +-- .access --
    +{
    +	"Username": "aladdin",
    +	"Password": "opensesame",
    +	"StatusCode": 404,
    +	"Message": "line 1\nline 2\nline 3\nline 4\nline 5\nline 6\nline 7\nline 8\nline 9\nline 10\nline 11\nline 12\nline 13\nline 14\nline 15\nline 16"
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/auth/oronelongline.txt b/go/src/cmd/go/testdata/vcstest/auth/oronelongline.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..d27653aef0412a1d544be763e6577f9930ac29b0
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/auth/oronelongline.txt
    @@ -0,0 +1,9 @@
    +handle auth
    +
    +-- .access --
    +{
    +	"Username": "aladdin",
    +	"Password": "opensesame",
    +	"StatusCode": 404,
    +	"Message": "blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah"
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/bzr/hello.txt b/go/src/cmd/go/testdata/vcstest/bzr/hello.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..68465ec553bd556985f2fcbfdb1e6a598384e945
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/bzr/hello.txt
    @@ -0,0 +1,34 @@
    +[!bzr] skip 'requires a working bzr client'
    +handle bzr
    +
    +env BZR_EMAIL='Russ Cox '
    +env EMAIL='Russ Cox '
    +
    +bzr init-repo .
    +
    +bzr init b
    +cd b
    +cp ../hello.go .
    +bzr add hello.go
    +bzr commit --commit-time='2017-09-21 21:20:12 -0400' -m 'hello world'
    +bzr push ..
    +cd ..
    +rm b
    +
    +bzr log
    +cmp stdout .bzr-log
    +
    +-- .bzr-log --
    +------------------------------------------------------------
    +revno: 1
    +committer: Russ Cox 
    +branch nick: b
    +timestamp: Thu 2017-09-21 21:20:12 -0400
    +message:
    +  hello world
    +-- hello.go --
    +package main
    +
    +func main() {
    +	println("hello, world")
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/fossil/hello.txt b/go/src/cmd/go/testdata/vcstest/fossil/hello.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..48fb774bcf22e3ec7d7a1292a7680f7a38795a0d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/fossil/hello.txt
    @@ -0,0 +1,22 @@
    +handle fossil
    +
    +env USER=rsc
    +fossil init --date-override 2017-09-22T01:15:36Z hello.fossil
    +fossil open --keep hello.fossil
    +
    +fossil add hello.go
    +fossil commit --no-prompt --nosign --date-override 2017-09-22T01:19:07Z --comment 'hello world'
    +
    +fossil timeline --oneline
    +cmp stdout .fossil-timeline
    +
    +-- .fossil-timeline --
    +d4c7dcdc29 hello world
    +58da0d15e9 initial empty check-in
    ++++ no more data (2) +++
    +-- hello.go --
    +package main
    +
    +func main() {
    +	println("hello, world")
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/git/commit-after-tag.txt b/go/src/cmd/go/testdata/vcstest/git/commit-after-tag.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..eb13a6326efd751fede1a64341be5456cf56c700
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/commit-after-tag.txt
    @@ -0,0 +1,39 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2019-07-15T17:16:47-04:00
    +git add go.mod main.go
    +git commit -m 'all: add go.mod and main.go'
    +git branch -m master
    +git tag v1.0.0
    +
    +at 2019-07-15T17:17:27-04:00
    +cp _next/main.go main.go
    +git add main.go
    +git commit -m 'add init function'
    +
    +git log --oneline --decorate=short
    +cmp stdout .git-log
    +
    +-- .git-log --
    +b325d82 (HEAD -> master) add init function
    +8da67e0 (tag: v1.0.0) all: add go.mod and main.go
    +-- go.mod --
    +module vcs-test.golang.org/git/commit-after-tag.git
    +
    +go 1.13
    +-- main.go --
    +package main
    +
    +func main() {}
    +-- _next/main.go --
    +package main
    +
    +func main() {}
    +func init() {}
    diff --git a/go/src/cmd/go/testdata/vcstest/git/empty-v2-without-v1.txt b/go/src/cmd/go/testdata/vcstest/git/empty-v2-without-v1.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..afe407ee5535e6f1f9d364f1581146e805064998
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/empty-v2-without-v1.txt
    @@ -0,0 +1,24 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2019-10-07T14:15:32-04:00
    +git add go.mod
    +git commit -m 'add go.mod file without go source files'
    +git branch -m master
    +git tag v2.0.0
    +
    +git log --oneline --decorate=short
    +cmp stdout .git-log
    +
    +-- .git-log --
    +122733c (HEAD -> master, tag: v2.0.0) add go.mod file without go source files
    +-- go.mod --
    +module vcs-test.golang.org/git/empty-v2-without-v1.git/v2
    +
    +go 1.14
    diff --git a/go/src/cmd/go/testdata/vcstest/git/emptytest.txt b/go/src/cmd/go/testdata/vcstest/git/emptytest.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..4526202a7bd861936ce796a6d4c0bdebadcdae50
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/emptytest.txt
    @@ -0,0 +1,21 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Russ Cox'
    +env GIT_AUTHOR_EMAIL='rsc@golang.org'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2018-07-03T22:35:49-04:00
    +git add go.mod
    +git commit -m 'initial'
    +git branch -m master
    +
    +git log --oneline
    +cmp stdout .git-log
    +
    +-- .git-log --
    +7bb9146 initial
    +-- go.mod --
    +module vcs-test.golang.org/git/emptytest.git
    diff --git a/go/src/cmd/go/testdata/vcstest/git/gitrepo-sha256.txt b/go/src/cmd/go/testdata/vcstest/git/gitrepo-sha256.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a08e2949d3142a7e4ee93e512f1cebebcd796f6a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/gitrepo-sha256.txt
    @@ -0,0 +1,93 @@
    +[!git-sha256] skip
    +
    +handle git
    +
    +# This is a sha256 version of gitrepo1.txt (which uses sha1 hashes)
    +env GIT_AUTHOR_NAME='David Finkel'
    +env GIT_AUTHOR_EMAIL='david.finkel@gmail.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init --object-format=sha256
    +
    +at 2018-04-17T15:43:22-04:00
    +unquote ''
    +cp stdout README
    +git add README
    +git commit -m 'empty README'
    +git branch -m main
    +git tag v1.2.3
    +
    +at 2018-04-17T15:45:48-04:00
    +git branch v2
    +git checkout v2
    +echo 'v2'
    +cp stdout v2
    +git add v2
    +git commit -m 'v2'
    +git tag v2.3
    +git tag v2.0.1
    +git branch v2.3.4
    +
    +at 2018-04-17T16:00:19-04:00
    +echo 'intermediate'
    +cp stdout foo.txt
    +git add foo.txt
    +git commit -m 'intermediate'
    +
    +at 2018-04-17T16:00:32-04:00
    +echo 'another'
    +cp stdout another.txt
    +git add another.txt
    +git commit -m 'another'
    +git tag v2.0.2
    +
    +at 2018-04-17T16:16:52-04:00
    +git checkout main
    +git branch v3
    +git checkout v3
    +mkdir v3/sub/dir
    +echo 'v3/sub/dir/file'
    +cp stdout v3/sub/dir/file.txt
    +git add v3
    +git commit -m 'add v3/sub/dir/file.txt'
    +
    +at 2018-04-17T22:23:00-04:00
    +git checkout main
    +git tag -a v1.2.4-annotated -m 'v1.2.4-annotated'
    +
    +git switch -c basic_module
    +git add go.mod foobar.go
    +git commit -m 'add go.mod & Foobar function'
    +git tag v1.3.0
    +git switch main
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- go.mod --
    +module vcs-test.golang.org/go/mod/gitrepo-sha256
    +
    +go 1.24.3
    +
    +-- foobar.go --
    +
    +package sha256repo
    +
    +// Foobar is the identity function
    +func Foobar[T any](v T) T {
    +	return v
    +}
    +
    +-- .git-refs --
    +a9157cad2aa6dc2f78aa31fced5887f04e758afa8703f04d0178702ebf04ee17 refs/heads/basic_module
    +47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c refs/heads/main
    +1401e4e1fdb4169b51d44a1ff62af63ccc708bf5c12d15051268b51bbb6cbd82 refs/heads/v2
    +b7550fd9d2129c724c39ae0536e8b2fae4364d8c82bb8b0880c9b71f67295d09 refs/heads/v2.3.4
    +c2a5bbdbeb8b2c82e819a4af94ea59f7d67faeb6df7cb4907c3f0d70836a977b refs/heads/v3
    +47b8b51b2a2d9d5caa3d460096c4e01f05700ce3a9390deb54400bd508214c5c refs/tags/v1.2.3
    +f88263be2704531e0f664784b66c2f84dea6d0dc4231cf9c6be482af0400c607 refs/tags/v1.2.4-annotated
    +a9157cad2aa6dc2f78aa31fced5887f04e758afa8703f04d0178702ebf04ee17 refs/tags/v1.3.0
    +b7550fd9d2129c724c39ae0536e8b2fae4364d8c82bb8b0880c9b71f67295d09 refs/tags/v2.0.1
    +1401e4e1fdb4169b51d44a1ff62af63ccc708bf5c12d15051268b51bbb6cbd82 refs/tags/v2.0.2
    +b7550fd9d2129c724c39ae0536e8b2fae4364d8c82bb8b0880c9b71f67295d09 refs/tags/v2.3
    diff --git a/go/src/cmd/go/testdata/vcstest/git/gitrepo1.txt b/go/src/cmd/go/testdata/vcstest/git/gitrepo1.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..7919089792bb8cb4bc2692212074c87a8eb0a8ab
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/gitrepo1.txt
    @@ -0,0 +1,68 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Russ Cox'
    +env GIT_AUTHOR_EMAIL='rsc@golang.org'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2018-04-17T15:43:22-04:00
    +unquote ''
    +cp stdout README
    +git add README
    +git commit -a -m 'empty README'
    +git branch -m master
    +git tag v1.2.3
    +
    +at 2018-04-17T15:45:48-04:00
    +git branch v2
    +git checkout v2
    +echo 'v2'
    +cp stdout v2
    +git add v2
    +git commit -a -m 'v2'
    +git tag v2.3
    +git tag v2.0.1
    +git branch v2.3.4
    +
    +at 2018-04-17T16:00:19-04:00
    +echo 'intermediate'
    +cp stdout foo.txt
    +git add foo.txt
    +git commit -a -m 'intermediate'
    +
    +at 2018-04-17T16:00:32-04:00
    +echo 'another'
    +cp stdout another.txt
    +git add another.txt
    +git commit -a -m 'another'
    +git tag v2.0.2
    +
    +at 2018-04-17T16:16:52-04:00
    +git checkout master
    +git branch v3
    +git checkout v3
    +mkdir v3/sub/dir
    +echo 'v3/sub/dir/file'
    +cp stdout v3/sub/dir/file.txt
    +git add v3
    +git commit -a -m 'add v3/sub/dir/file.txt'
    +
    +at 2018-04-17T22:23:00-04:00
    +git checkout master
    +git tag -a v1.2.4-annotated -m 'v1.2.4-annotated'
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +ede458df7cd0fdca520df19a33158086a8a68e81 refs/heads/master
    +9d02800338b8a55be062c838d1f02e0c5780b9eb refs/heads/v2
    +76a00fb249b7f93091bc2c89a789dab1fc1bc26f refs/heads/v2.3.4
    +a8205f853c297ad2c3c502ba9a355b35b7dd3ca5 refs/heads/v3
    +ede458df7cd0fdca520df19a33158086a8a68e81 refs/tags/v1.2.3
    +b004e48a345a86ed7a2fb7debfa7e0b2f9b0dd91 refs/tags/v1.2.4-annotated
    +76a00fb249b7f93091bc2c89a789dab1fc1bc26f refs/tags/v2.0.1
    +9d02800338b8a55be062c838d1f02e0c5780b9eb refs/tags/v2.0.2
    +76a00fb249b7f93091bc2c89a789dab1fc1bc26f refs/tags/v2.3
    diff --git a/go/src/cmd/go/testdata/vcstest/git/gitreposubdir.txt b/go/src/cmd/go/testdata/vcstest/git/gitreposubdir.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..f9ba7629cc97ed821c708cbc0e44c0a00427b15b
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/gitreposubdir.txt
    @@ -0,0 +1,26 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Sam Thanawalla'
    +env GIT_AUTHOR_EMAIL='samthanawalla@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +at 2019-10-07T14:15:32-04:00
    +
    +git init
    +
    +git add foo/subdir
    +git commit -m 'initial commit'
    +git branch -m master
    +git tag foo/subdir/v1.2.3
    +
    +-- foo/subdir/go.mod --
    +module vcs-test.golang.org/go/gitreposubdir
    +
    +go 1.23
    +-- foo/subdir/hello.go --
    +package greeter
    +
    +func Hello() string {
    +	return "hello, world"
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/git/gitreposubdirv2.txt b/go/src/cmd/go/testdata/vcstest/git/gitreposubdirv2.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..35b2f9ed3a5fa70b2659644413e162f1aef2d33f
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/gitreposubdirv2.txt
    @@ -0,0 +1,31 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Sam Thanawalla'
    +env GIT_AUTHOR_EMAIL='samthanawalla@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +at 2019-10-07T14:15:32-04:00
    +
    +git init
    +
    +git add subdir
    +git commit -m 'initial commit'
    +git branch -m master
    +git tag subdir/v2.0.0
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +5212d800bfd1f6377da46aee6cbceca2f60d4ea6 refs/heads/master
    +5212d800bfd1f6377da46aee6cbceca2f60d4ea6 refs/tags/subdir/v2.0.0
    +-- subdir/go.mod --
    +module vcs-test.golang.org/go/gitreposubdirv2/v2
    +
    +go 1.23
    +-- subdir/hello.go --
    +package greeterv2
    +
    +func Hello() string {
    +	return "hello, world v2"
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/git/hello.txt b/go/src/cmd/go/testdata/vcstest/git/hello.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..17ba09cd9e9f4e64d6399f7949e74d3aae2fbc0c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/hello.txt
    @@ -0,0 +1,25 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME=bwk
    +env GIT_AUTHOR_EMAIL=bwk
    +env GIT_COMMITTER_NAME='Russ Cox'
    +env GIT_COMMITTER_EMAIL='rsc@golang.org'
    +
    +git init
    +
    +at 2017-09-21T21:05:58-04:00
    +git add hello.go
    +git commit -a -m 'hello'
    +git branch -m master
    +
    +git log --oneline --decorate=short
    +cmp stdout .git-log
    +
    +-- .git-log --
    +fc3a09f (HEAD -> master) hello
    +-- hello.go --
    +package main
    +
    +func main() {
    +	println("hello, world")
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/git/insecurerepo.txt b/go/src/cmd/go/testdata/vcstest/git/insecurerepo.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e0ea62c14d0ee6346a221b7ba4d81a1e1241bde6
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/insecurerepo.txt
    @@ -0,0 +1,32 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2019-04-03T13:30:35-04:00
    +git add go.mod
    +git commit -m 'all: initialize module'
    +git branch -m master
    +
    +at 2019-09-04T14:39:48-04:00
    +git add main.go
    +git commit -m 'main: add Go source file'
    +
    +git log --oneline --decorate=short
    +cmp stdout .git-log
    +
    +-- .git-log --
    +6fecd21 (HEAD -> master) main: add Go source file
    +d1a15cd all: initialize module
    +-- go.mod --
    +module vcs-test.golang.org/insecure/go/insecure
    +
    +go 1.13
    +-- main.go --
    +package main
    +
    +func main() {}
    diff --git a/go/src/cmd/go/testdata/vcstest/git/issue47650.txt b/go/src/cmd/go/testdata/vcstest/git/issue47650.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..52040787c817707a103e427ab907ab73949ee547
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/issue47650.txt
    @@ -0,0 +1,42 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2021-08-11T13:52:00-04:00
    +git add cmd
    +git commit -m 'add cmd/issue47650'
    +git branch -m main
    +git tag v0.1.0
    +
    +git add go.mod
    +git commit -m 'add go.mod'
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +git log --oneline --decorate=short
    +cmp stdout .git-log
    +
    +-- .git-refs --
    +21535ef346c3e79fd09edd75bd4725f06c828e43 refs/heads/main
    +4d237df2dbfc8a443af2f5e84be774f08a2aed0c refs/tags/v0.1.0
    +-- .git-log --
    +21535ef (HEAD -> main) add go.mod
    +4d237df (tag: v0.1.0) add cmd/issue47650
    +-- go.mod --
    +module vcs-test.golang.org/git/issue47650.git
    +
    +go 1.17
    +-- cmd/issue47650/main.go --
    +package main
    +
    +import "os"
    +
    +func main() {
    +	os.Stdout.WriteString("Hello, world!")
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/git/issue61415.txt b/go/src/cmd/go/testdata/vcstest/git/issue61415.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..5b8bca68fbb33d093605106f1427dc0dd65e0f9e
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/issue61415.txt
    @@ -0,0 +1,42 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +at 2023-11-14T13:00:00-05:00
    +
    +git init
    +
    +git add go.mod nested
    +git commit -m 'nested: add go.mod'
    +git branch -m main
    +
    +git tag has-nested
    +
    +at 2023-11-14T13:00:01-05:00
    +
    +git rm -r nested
    +git commit -m 'nested: delete subdirectory'
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +git log --pretty=oneline
    +cmp stdout .git-log
    +
    +-- .git-refs --
    +f213069baa68ec26412fb373c7cf6669db1f8e69 refs/heads/main
    +08a4fa6bb9c04ffba03b26ae427b0d6335d90a2a refs/tags/has-nested
    +-- .git-log --
    +f213069baa68ec26412fb373c7cf6669db1f8e69 nested: delete subdirectory
    +08a4fa6bb9c04ffba03b26ae427b0d6335d90a2a nested: add go.mod
    +-- go.mod --
    +module vcs-test.golang.org/git/issue61415.git
    +
    +go 1.20
    +-- nested/go.mod --
    +module vcs-test.golang.org/git/issue61415.git/nested
    +
    +go 1.20
    diff --git a/go/src/cmd/go/testdata/vcstest/git/legacytest.txt b/go/src/cmd/go/testdata/vcstest/git/legacytest.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6465242d6211f223663c15114c380b7752813f92
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/legacytest.txt
    @@ -0,0 +1,118 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Russ Cox'
    +env GIT_AUTHOR_EMAIL='rsc@golang.org'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +git checkout -b master
    +
    +at 2018-07-17T12:41:39-04:00
    +cp x_cf92c7b.go x.go
    +git add x.go
    +git commit -m 'initial commit'
    +
    +at 2018-07-17T12:41:57-04:00
    +cp x_52853eb.go x.go
    +git commit -m 'add X' x.go
    +
    +at 2018-07-17T12:42:07-04:00
    +cp x_7fff7f3.go x.go
    +git commit -m 'gofmt' x.go
    +git tag v1.0.0
    +
    +at 2018-07-17T12:42:28-04:00
    +cp x_fa4f5d6.go x.go
    +git commit -m 'X->XX' x.go
    +
    +at 2018-07-17T12:42:36-04:00
    +cp x_d7ae1e4.go x.go
    +git commit -m 'gofmt' x.go
    +git tag v2.0.0
    +
    +at 2018-07-17T12:42:53-04:00
    +cp x_7303f77.go x.go
    +git commit -m 'add XXX' x.go
    +
    +at 2018-07-17T12:47:59-04:00
    +git checkout v1.0.0
    +cp x_1abc5ff.go x.go
    +git commit -m 'comment' x.go
    +
    +at 2018-07-17T12:48:22-04:00
    +cp x_731e3b1.go x.go
    +git commit -m 'prerelease' x.go
    +git tag v1.1.0-pre
    +
    +at 2018-07-17T12:48:49-04:00
    +cp x_fb3c628.go x.go
    +git commit -m 'working' x.go
    +
    +at 2018-07-17T12:49:05-04:00
    +cp x_9f6f860.go x.go
    +git commit -m 'v1.2.0' x.go
    +git tag v1.2.0
    +
    +at 2018-07-17T12:49:42-04:00
    +cp x_d2d4c3e.go x.go
    +git commit -m 'more' x.go
    +git tag morework
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +7303f77963648d5f1ec5e55eccfad8e14035866c refs/heads/master
    +d2d4c3ea66230e7ad6fbd8f0ecd8c0f851392364 refs/tags/morework
    +7fff7f3417faa4a795f9518bc2bef05147a1d6c0 refs/tags/v1.0.0
    +731e3b12a0272dcafb560b8fa6a4e9ffb20ef5c9 refs/tags/v1.1.0-pre
    +9f6f860fe5c92cd835fdde2913aca8db9ce63373 refs/tags/v1.2.0
    +d7ae1e4b368320e7a577fc8a9efc1e78aacac52a refs/tags/v2.0.0
    +-- x_1abc5ff.go --
    +package legacytest
    +
    +// add comment
    +const X = 1
    +-- x_52853eb.go --
    +package legacytest
    +const X = 1
    +-- x_7303f77.go --
    +package legacytest
    +
    +const XX = 2
    +
    +const XXX = 3
    +-- x_731e3b1.go --
    +package legacytest
    +
    +// add comment again
    +const X = 1
    +-- x_7fff7f3.go --
    +package legacytest
    +
    +const X = 1
    +-- x_9f6f860.go --
    +package legacytest
    +
    +// add comment again!!!
    +const X = 1
    +-- x_cf92c7b.go --
    +package legacytest
    +-- x_d2d4c3e.go --
    +package legacytest
    +
    +// add comment hack hack hack
    +const X = 1
    +-- x_d7ae1e4.go --
    +package legacytest
    +
    +const XX = 2
    +-- x_fa4f5d6.go --
    +package legacytest
    +const XX = 2
    +-- x_fb3c628.go --
    +package legacytest
    +
    +// add comment fixed
    +const X = 1
    diff --git a/go/src/cmd/go/testdata/vcstest/git/mainonly.txt b/go/src/cmd/go/testdata/vcstest/git/mainonly.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..d294e34e132c1c07618534bf46d64d4200455abf
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/mainonly.txt
    @@ -0,0 +1,23 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2019-09-05T14:07:43-04:00
    +git add main.go
    +git commit -a -m 'add main.go'
    +git branch -m master
    +
    +git log --oneline --decorate=short
    +cmp stdout .git-log
    +
    +-- .git-log --
    +8a27e8b (HEAD -> master) add main.go
    +-- main.go --
    +package main
    +
    +func main() {}
    diff --git a/go/src/cmd/go/testdata/vcstest/git/missingrepo.txt b/go/src/cmd/go/testdata/vcstest/git/missingrepo.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b947d8cc9915b4777b001137f1cb6da2a4e4235d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/missingrepo.txt
    @@ -0,0 +1,10 @@
    +handle dir
    +
    +-- missingrepo-git/index.html --
    +
    +
    +
    +-- missingrepo-git/notmissing/index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/git/modlegacy1-new.txt b/go/src/cmd/go/testdata/vcstest/git/modlegacy1-new.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..ee14454b19f085247fe9b97764c9ad872b9e5f99
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/modlegacy1-new.txt
    @@ -0,0 +1,33 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Russ Cox'
    +env GIT_AUTHOR_EMAIL='rsc@golang.org'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2018-04-25T11:00:57-04:00
    +git add go.mod new.go p1 p2
    +git commit -m 'initial commit'
    +git branch -m master
    +
    +git log --oneline --decorate=short
    +cmp stdout .git-log
    +
    +-- .git-log --
    +36cc50a (HEAD -> master) initial commit
    +-- go.mod --
    +module "vcs-test.golang.org/git/modlegacy1-new.git/v2"
    +-- new.go --
    +package new
    +
    +import _ "vcs-test.golang.org/git/modlegacy1-new.git/v2/p2"
    +-- p1/p1.go --
    +package p1
    +
    +import _ "vcs-test.golang.org/git/modlegacy1-old.git/p2"
    +import _ "vcs-test.golang.org/git/modlegacy1-new.git"
    +import _ "vcs-test.golang.org/git/modlegacy1-new.git/p2"
    +-- p2/p2.go --
    +package p2
    diff --git a/go/src/cmd/go/testdata/vcstest/git/modlegacy1-old.txt b/go/src/cmd/go/testdata/vcstest/git/modlegacy1-old.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..bca8f061ef22f3b7fd759737c95a1907a8d3576b
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/modlegacy1-old.txt
    @@ -0,0 +1,27 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Russ Cox'
    +env GIT_AUTHOR_EMAIL='rsc@golang.org'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2018-04-25T10:59:24-04:00
    +git add p1 p2
    +git commit -m 'initial commit'
    +git branch -m master
    +
    +git log --oneline --decorate=short
    +cmp stdout .git-log
    +
    +-- .git-log --
    +6b4ba8b (HEAD -> master) initial commit
    +-- p1/p1.go --
    +package p1
    +
    +import _ "vcs-test.golang.org/git/modlegacy1-old.git/p2"
    +import _ "vcs-test.golang.org/git/modlegacy1-new.git/p1"
    +import _ "vcs-test.golang.org/git/modlegacy1-new.git"
    +-- p2/p2.go --
    +package p2
    diff --git a/go/src/cmd/go/testdata/vcstest/git/no-tags.txt b/go/src/cmd/go/testdata/vcstest/git/no-tags.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..5ff009161696d55d3d5b008a38817010384c3ddf
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/no-tags.txt
    @@ -0,0 +1,27 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2019-07-15T17:20:47-04:00
    +git add go.mod main.go
    +git commit -m 'all: add go.mod and main.go'
    +git branch -m master
    +
    +git log --oneline --decorate=short
    +cmp stdout .git-log
    +
    +-- .git-log --
    +e706ba1 (HEAD -> master) all: add go.mod and main.go
    +-- go.mod --
    +module vcs-test.golang.org/git/no-tags.git
    +
    +go 1.13
    +-- main.go --
    +package main
    +
    +func main() {}
    diff --git a/go/src/cmd/go/testdata/vcstest/git/odd-tags.txt b/go/src/cmd/go/testdata/vcstest/git/odd-tags.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8e2486741e55dc0741df007ee6edb2c75d8a03fc
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/odd-tags.txt
    @@ -0,0 +1,49 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2022-02-23T13:48:02-05:00
    +git add README.txt
    +git commit -m 'initial state'
    +git branch -m main
    +git tag 'v2.0.0+incompatible'
    +
    +at 2022-02-23T13:48:35-05:00
    +git rm -r README.txt
    +git add go.mod
    +git commit -m 'migrate to Go modules'
    +git tag 'v0.1.0+build-metadata'
    +
    +at 2022-02-23T14:41:55-05:00
    +git branch v3-dev
    +git checkout v3-dev
    +cp v3/go.mod go.mod
    +git commit go.mod -m 'update to /v3'
    +git tag 'v3.0.0-20220223184802-12d19af20458'
    +
    +git checkout main
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +9d863d525bbfcc8eda09364738c4032393711a56 refs/heads/main
    +cce3d0f5d2ec85678cca3c45ac4a87f3be5efaca refs/heads/v3-dev
    +9d863d525bbfcc8eda09364738c4032393711a56 refs/tags/v0.1.0+build-metadata
    +12d19af204585b0db3d2a876ceddf5b9323f5a4a refs/tags/v2.0.0+incompatible
    +cce3d0f5d2ec85678cca3c45ac4a87f3be5efaca refs/tags/v3.0.0-20220223184802-12d19af20458
    +-- README.txt --
    +This module lacks a go.mod file.
    +-- go.mod --
    +module vcs-test.golang.org/git/odd-tags.git
    +
    +go 1.18
    +-- v3/go.mod --
    +module vcs-test.golang.org/git/odd-tags.git/v3
    +
    +go 1.18
    diff --git a/go/src/cmd/go/testdata/vcstest/git/prefixtagtests.txt b/go/src/cmd/go/testdata/vcstest/git/prefixtagtests.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6c89c857f49ef86304f4ea4257feff92d799c589
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/prefixtagtests.txt
    @@ -0,0 +1,53 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Jay Conrod'
    +env GIT_AUTHOR_EMAIL='jayconrod@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +at 2019-05-09T18:35:00-04:00
    +
    +git init
    +
    +git add sub
    +git commit -m 'create module sub'
    +git branch -m master
    +
    +echo 'v0.1.0'
    +cp stdout status
    +git add status
    +git commit -a -m 'v0.1.0'
    +git tag 'v0.1.0'
    +
    +echo 'sub/v0.0.9'
    +cp stdout status
    +git commit -a -m 'sub/v0.0.9'
    +git tag 'sub/v0.0.9'
    +
    +echo 'sub/v0.0.10'
    +cp stdout status
    +git commit -a -m 'sub/v0.0.10'
    +git tag 'sub/v0.0.10'
    +
    +echo 'v0.2.0'
    +cp stdout status
    +git commit -a -m 'v0.2.0'
    +git tag 'v0.2.0'
    +
    +echo 'after last tag'
    +cp stdout status
    +git commit -a -m 'after last tag'
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +c3ee5d0dfbb9bf3c4d8bb2bce24cd8d14d2d4238 refs/heads/master
    +2b7c4692e12c109263cab51b416fcc835ddd7eae refs/tags/sub/v0.0.10
    +883885166298d79a0561d571a3044ec5db2e7c28 refs/tags/sub/v0.0.9
    +db89fc573cfb939faf0aa0660671eb4cf8b8b673 refs/tags/v0.1.0
    +1abe41965749e50828dd41de8d12c6ebc8e4e131 refs/tags/v0.2.0
    +-- sub/go.mod --
    +module vcs-test.golang.org/git/prefixtagtests.git/sub
    +-- sub/sub.go --
    +package sub
    diff --git a/go/src/cmd/go/testdata/vcstest/git/querytest.txt b/go/src/cmd/go/testdata/vcstest/git/querytest.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..b0f708a016be9fc21d8e0343dedb3025ca606345
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/querytest.txt
    @@ -0,0 +1,273 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Russ Cox'
    +env GIT_AUTHOR_EMAIL='rsc@golang.org'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2018-07-03T22:31:01-04:00
    +git add go.mod
    +git commit -a -m 'v1'
    +git branch -m master
    +git tag start
    +
    +git branch v2
    +
    +at 2018-07-03T22:33:47-04:00
    +echo 'before v0.0.0-pre1'
    +cp stdout status
    +git add status
    +git commit -a -m 'before v0.0.0-pre1'
    +
    +echo 'at v0.0.0-pre1'
    +cp stdout status
    +git commit -a -m 'at v0.0.0-pre1'
    +git tag 'v0.0.0-pre1'
    +
    +echo 'before v0.0.0'
    +cp stdout status
    +git commit -a -m 'before v0.0.0'
    +
    +echo 'at v0.0.0'
    +cp stdout status
    +git commit -a -m 'at v0.0.0'
    +git tag 'v0.0.0'
    +
    +echo 'before v0.0.1'
    +cp stdout status
    +git commit -a -m 'before v0.0.1'
    +
    +echo 'at v0.0.1'
    +cp stdout status
    +git commit -a -m 'at v0.0.1'
    +git tag 'v0.0.1'
    +
    +echo 'before v0.0.2'
    +cp stdout status
    +git commit -a -m 'before v0.0.2'
    +
    +echo 'at v0.0.2'
    +cp stdout status
    +git commit -a -m 'at v0.0.2'
    +git tag 'v0.0.2'
    +
    +echo 'before v0.0.3'
    +cp stdout status
    +git commit -a -m 'before v0.0.3'
    +
    +echo 'at v0.0.3'
    +cp stdout status
    +git commit -a -m 'at v0.0.3'
    +git tag 'v0.0.3'
    +git tag favorite
    +
    +echo 'before v0.1.0'
    +cp stdout status
    +git commit -a -m 'before v0.1.0'
    +
    +echo 'at v0.1.0'
    +cp stdout status
    +git commit -a -m 'at v0.1.0'
    +git tag v0.1.0
    +
    +echo 'before v0.1.1'
    +cp stdout status
    +git commit -a -m 'before v0.1.1'
    +
    +echo 'at v0.1.1'
    +cp stdout status
    +git commit -a -m 'at v0.1.1'
    +git tag 'v0.1.1'
    +
    +echo 'before v0.1.2'
    +cp stdout status
    +git commit -a -m 'before v0.1.2'
    +
    +echo 'at v0.1.2'
    +cp stdout status
    +git commit -a -m 'at v0.1.2'
    +git tag 'v0.1.2'
    +
    +echo 'before v0.3.0'
    +cp stdout status
    +git commit -a -m 'before v0.3.0'
    +
    +echo 'at v0.3.0'
    +cp stdout status
    +git commit -a -m 'at v0.3.0'
    +git tag 'v0.3.0'
    +
    +echo 'before v1.0.0'
    +cp stdout status
    +git commit -a -m 'before v1.0.0'
    +
    +echo 'at v1.0.0'
    +cp stdout status
    +git commit -a -m 'at v1.0.0'
    +git tag 'v1.0.0'
    +
    +echo 'before v1.1.0'
    +cp stdout status
    +git commit -a -m 'before v1.1.0'
    +
    +echo 'at v1.1.0'
    +cp stdout status
    +git commit -a -m 'at v1.1.0'
    +git tag 'v1.1.0'
    +
    +echo 'before v1.9.0'
    +cp stdout status
    +git commit -a -m 'before v1.9.0'
    +
    +echo 'at v1.9.0'
    +cp stdout status
    +git commit -a -m 'at v1.9.0'
    +git tag 'v1.9.0'
    +
    +echo 'before v1.9.9'
    +cp stdout status
    +git commit -a -m 'before v1.9.9'
    +
    +echo 'at v1.9.9'
    +cp stdout status
    +git commit -a -m 'at v1.9.9'
    +git tag 'v1.9.9'
    +
    +at 2018-07-03T22:45:01-04:00
    +echo 'before v1.9.10-pre1'
    +cp stdout status
    +git commit -a -m 'before v1.9.10-pre1'
    +
    +echo 'at v1.9.10-pre1'
    +cp stdout status
    +git commit -a -m 'at v1.9.10-pre1'
    +git tag 'v1.9.10-pre1'
    +
    +at 2018-07-03T22:50:24-04:00
    +git checkout v2
    +cp v2/go.mod go.mod
    +git add go.mod
    +git commit -a -m 'v2'
    +
    +at 2018-07-03T22:51:14-04:00
    +echo 'before v2.0.0'
    +cp stdout status
    +git add status
    +git commit -a -m 'before v2.0.0'
    +
    +at 2018-07-03T22:51:14-04:00
    +echo 'at v2.0.0'
    +cp stdout status
    +git commit -a -m 'at v2.0.0'
    +git tag 'v2.0.0'
    +
    +at 2018-07-03T22:51:14-04:00
    +echo 'before v2.1.0'
    +cp stdout status
    +git commit -a -m 'before v2.1.0'
    +
    +at 2018-07-03T22:51:14-04:00
    +echo 'at v2.1.0'
    +cp stdout status
    +git commit -a -m 'at v2.1.0'
    +git tag 'v2.1.0'
    +
    +at 2018-07-03T22:51:14-04:00
    +echo 'before v2.2.0'
    +cp stdout status
    +git commit -a -m 'before v2.2.0'
    +
    +at 2018-07-03T22:51:14-04:00
    +echo 'at v2.2.0'
    +cp stdout status
    +git commit -a -m 'at v2.2.0'
    +git tag 'v2.2.0'
    +
    +at 2018-07-03T22:51:14-04:00
    +echo 'before v2.5.5'
    +cp stdout status
    +git commit -a -m 'before v2.5.5'
    +
    +at 2018-07-03T22:51:14-04:00
    +echo 'at v2.5.5'
    +cp stdout status
    +git commit -a -m 'at v2.5.5'
    +git tag 'v2.5.5'
    +
    +at 2018-07-03T23:35:18-04:00
    +echo 'after v2.5.5'
    +cp stdout status
    +git commit -a -m 'after v2.5.5'
    +
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL=bcmills@google.com
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git checkout v2.5.5
    +
    +at 2019-05-13T17:13:56-04:00
    +echo 'before v2.6.0-pre1'
    +cp stdout status
    +git commit -a -m 'before v2.6.0-pre1'
    +
    +at 2019-05-13T17:13:56-04:00
    +echo 'at v2.6.0-pre1'
    +cp stdout status
    +git commit -a -m 'at v2.6.0-pre1'
    +git tag 'v2.6.0-pre1'
    +
    +git checkout master
    +
    +at 2019-05-13T16:11:25-04:00
    +echo 'before v1.9.10-pre2+metadata'
    +cp stdout status
    +git commit -a -m 'before v1.9.10-pre2+metadata'
    +
    +at 2019-05-13T16:11:26-04:00
    +echo 'at v1.9.10-pre2+metadata'
    +cp stdout status
    +git commit -a -m 'at v1.9.10-pre2+metadata'
    +git tag 'v1.9.10-pre2+metadata'
    +
    +at 2019-12-20T08:46:14-05:00
    +echo 'after v1.9.10-pre2+metadata'
    +cp stdout status
    +git commit -a -m 'after v1.9.10-pre2+metadata'
    +
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +ed5ffdaa1f5e7e0be6f5ba2d63097026506224f2 refs/heads/master
    +feed8f518cf4a7215a3b2a8268b8b0746dcbb12d refs/heads/v2
    +f6abd4e3ed7f2297bc8fd2888bd6d5412e255fcc refs/tags/favorite
    +5e9e31667ddfe16e9350f4bd00acc933c8cd5e56 refs/tags/start
    +0de900e0063bcc310ea0621bfbc227a9b4e3b020 refs/tags/v0.0.0
    +e5ec98b1c15df29e3bd346d538d73b6e8c3b500c refs/tags/v0.0.0-pre1
    +179bc86b1be3f6d4553f77ebe68a8b6d750ceff8 refs/tags/v0.0.1
    +81da2346e009fa1072fe4de3a9a223398ea8ec39 refs/tags/v0.0.2
    +f6abd4e3ed7f2297bc8fd2888bd6d5412e255fcc refs/tags/v0.0.3
    +7a1b6bf60ae5bb2b2bd49d152e0bbad806056122 refs/tags/v0.1.0
    +daedca9abee3171fe45e0344098a993675ac799e refs/tags/v0.1.1
    +ce829e0f1c45a2eca0f1ad16d7c1aca7cddb433b refs/tags/v0.1.2
    +44aadfee25d86acb32d6f352afd1d602b0e3a651 refs/tags/v0.3.0
    +20756d3a393908b2edb5db0f0bb954e962860168 refs/tags/v1.0.0
    +b0bf267f64b7d5b5cabe22fbcad22f3f1642b7e5 refs/tags/v1.1.0
    +609dca58c03f0ddf1d8ebe46c1f74fc6a99f3e73 refs/tags/v1.9.0
    +e0cf3de987e660c21b6950e85b317ce5f7fbb9d9 refs/tags/v1.9.10-pre1
    +42abcb6df8eee6983aeca9a307c28ea40530aceb refs/tags/v1.9.10-pre2+metadata
    +5ba9a4ea62136ae86213feba68bc73858f55b7e1 refs/tags/v1.9.9
    +9763aa065ae27c6cacec5ca8b6dfa43a1b31dea0 refs/tags/v2.0.0
    +23c28cb696ff40a2839ce406f2c173aa6c3cdda6 refs/tags/v2.1.0
    +1828ee9f8074075675013e4d488d5d49ddc1b502 refs/tags/v2.2.0
    +d7352560158175e3b6aa11e22efb06d9e87e6eea refs/tags/v2.5.5
    +fb9e35b393eb0cccc37e13e243ce60b4ff8c7eea refs/tags/v2.6.0-pre1
    +-- go.mod --
    +module vcs-test.golang.org/git/querytest.git
    +-- v2/go.mod --
    +module vcs-test.golang.org/git/querytest.git/v2
    diff --git a/go/src/cmd/go/testdata/vcstest/git/retract-pseudo.txt b/go/src/cmd/go/testdata/vcstest/git/retract-pseudo.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e189484869e531829dfb373bae48ea1126243208
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/retract-pseudo.txt
    @@ -0,0 +1,33 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Jay Conrod'
    +env GIT_AUTHOR_EMAIL='jayconrod@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +at 2020-10-09T13:37:47-04:00
    +
    +git init
    +
    +git add go.mod p.go
    +git commit -m 'create module retract-pseudo'
    +git branch -m main
    +git tag v1.0.0
    +
    +git mv p.go q.go
    +git commit -m 'trivial change'
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +713affd19d7b9b6dc876b603017f3dcaab8ba674 refs/heads/main
    +64c061ed4371ef372b6bbfd58ee32015d6bfc3e5 refs/tags/v1.0.0
    +-- go.mod --
    +module vcs-test.golang.org/git/retract-pseudo.git
    +
    +go 1.16
    +
    +retract v1.0.0
    +-- p.go --
    +package p
    diff --git a/go/src/cmd/go/testdata/vcstest/git/semver-branch.txt b/go/src/cmd/go/testdata/vcstest/git/semver-branch.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..69e1762a314647e7d82081ed888241da2b1b5d15
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/semver-branch.txt
    @@ -0,0 +1,53 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2022-02-02T14:15:21-05:00
    +git add pkg go.mod
    +git commit -a -m 'pkg: add empty package'
    +git branch -m main
    +git tag 'v0.1.0'
    +
    +at 2022-02-02T14:19:44-05:00
    +git branch 'v1.0.0'
    +git branch 'v2.0.0'
    +git checkout 'v1.0.0'
    +cp v1/pkg/pkg.go pkg/pkg.go
    +git commit -a -m 'pkg: start developing toward v1.0.0'
    +
    +at 2022-02-03T10:53:13-05:00
    +git branch 'v3.0.0-devel'
    +git checkout 'v3.0.0-devel'
    +git checkout v0.1.0 pkg/pkg.go
    +git commit -a -m 'pkg: remove panic'
    +git tag v4.0.0-beta.1
    +
    +git checkout main
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +33ea7ee36f3e3f44f528664b3712c9fa0cef7502 refs/heads/main
    +09c4d8f6938c7b5eeae46858a72712b8700fa46a refs/heads/v1.0.0
    +33ea7ee36f3e3f44f528664b3712c9fa0cef7502 refs/heads/v2.0.0
    +d59622f6e4d77f008819083582fde71ea1921b0c refs/heads/v3.0.0-devel
    +33ea7ee36f3e3f44f528664b3712c9fa0cef7502 refs/tags/v0.1.0
    +d59622f6e4d77f008819083582fde71ea1921b0c refs/tags/v4.0.0-beta.1
    +-- go.mod --
    +module vcs-test.golang.org/git/semver-branch.git
    +
    +go 1.16
    +-- pkg/pkg.go --
    +package pkg
    +-- v1/pkg/pkg.go --
    +package pkg
    +
    +func init() {
    +	panic("TODO")
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/git/tagtests.txt b/go/src/cmd/go/testdata/vcstest/git/tagtests.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..92e79cda877f87fb1d0b88d9fd989fa6b057ff6a
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/tagtests.txt
    @@ -0,0 +1,44 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Jay Conrod'
    +env GIT_AUTHOR_EMAIL='jayconrod@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +at 2019-05-09T18:56:25-04:00
    +
    +git init
    +
    +git add go.mod tagtests.go
    +git commit -m 'create module tagtests'
    +git branch -m master
    +git branch b
    +
    +git add v0.2.1
    +git commit -m 'v0.2.1'
    +git tag 'v0.2.1'
    +
    +git checkout b
    +git add 'v0.2.2'
    +git commit -m 'v0.2.2'
    +git tag 'v0.2.2'
    +
    +git checkout master
    +git merge b -m 'merge'
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +59356c8cd18c5fe9a598167d98a6843e52d57952 refs/heads/b
    +c7818c24fa2f3f714c67d0a6d3e411c85a518d1f refs/heads/master
    +101c49f5af1b2466332158058cf5f03c8cca6429 refs/tags/v0.2.1
    +59356c8cd18c5fe9a598167d98a6843e52d57952 refs/tags/v0.2.2
    +-- go.mod --
    +module vcs-test.golang.org/git/tagtests.git
    +-- tagtests.go --
    +package tagtests
    +-- v0.2.1 --
    +v0.2.1
    +-- v0.2.2 --
    +v0.2.2
    diff --git a/go/src/cmd/go/testdata/vcstest/git/v2repo.txt b/go/src/cmd/go/testdata/vcstest/git/v2repo.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6cbe9241484f6d8d6de18cf1a69f88d8e313f572
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/v2repo.txt
    @@ -0,0 +1,26 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2019-04-03T11:52:15-04:00
    +env GIT_AUTHOR_DATE=2019-04-03T11:44:11-04:00
    +git add go.mod
    +git commit -m 'all: add go.mod'
    +git branch -m master
    +git tag 'v2.0.0'
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +203b91c896acd173aa719e4cdcb7d463c4b090fa refs/heads/master
    +203b91c896acd173aa719e4cdcb7d463c4b090fa refs/tags/v2.0.0
    +-- go.mod --
    +module vcs-test.golang.org/go/v2module/v2
    +
    +go 1.12
    diff --git a/go/src/cmd/go/testdata/vcstest/git/v2sub.txt b/go/src/cmd/go/testdata/vcstest/git/v2sub.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..5d4ab5832fea88a69d0473a04e9909f6437998dd
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/v2sub.txt
    @@ -0,0 +1,35 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2022-02-22T15:53:33-05:00
    +git add v2sub.go v2
    +git commit -m 'all: add package v2sub and v2sub/v2'
    +git branch -m main
    +git tag v2.0.0
    +
    +at 2022-02-22T15:55:07-05:00
    +git add README.txt
    +git commit -m 'v2sub: add README.txt'
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +80beb17a16036f17a5aedd1bb5bd6d407b3c6dc5 refs/heads/main
    +5fcd3eaeeb391d399f562fd45a50dac9fc34ae8b refs/tags/v2.0.0
    +-- v2/go.mod --
    +module vcs-test.golang.org/git/v2sub.git/v2
    +
    +go 1.16
    +-- v2/v2sub.go --
    +package v2sub
    +-- v2sub.go --
    +package v2sub
    +-- README.txt --
    +This root module lacks a go.mod file.
    diff --git a/go/src/cmd/go/testdata/vcstest/git/v3pkg.txt b/go/src/cmd/go/testdata/vcstest/git/v3pkg.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..af18e01b9c1f7a8e3fb372d7fc5e9420f96fe5f2
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/v3pkg.txt
    @@ -0,0 +1,28 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Bryan C. Mills'
    +env GIT_AUTHOR_EMAIL='bcmills@google.com'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2019-07-15T14:01:24-04:00
    +env GIT_AUTHOR_DATE=2019-07-15T13:59:34-04:00
    +git add go.mod v3pkg.go
    +git commit -a -m 'all: add go.mod with v3 path'
    +git branch -m master
    +git tag 'v3.0.0'
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +a3eab1261b8e3164bcbde9171c23d5fd36e32a85 refs/heads/master
    +a3eab1261b8e3164bcbde9171c23d5fd36e32a85 refs/tags/v3.0.0
    +-- go.mod --
    +module vcs-test.golang.org/git/v3pkg.git/v3
    +
    +go 1.13
    +-- v3pkg.go --
    +package v3pkg
    diff --git a/go/src/cmd/go/testdata/vcstest/git/vgotest1.txt b/go/src/cmd/go/testdata/vcstest/git/vgotest1.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..d2fc741c3c2cac54677a559f13fa7a617033ba25
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/git/vgotest1.txt
    @@ -0,0 +1,257 @@
    +handle git
    +
    +env GIT_AUTHOR_NAME='Russ Cox'
    +env GIT_AUTHOR_EMAIL='rsc@golang.org'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +at 2018-02-19T17:21:09-05:00
    +git add LICENSE README.md
    +git commit -m 'initial commit'
    +git branch -m master
    +
    +git checkout --detach HEAD
    +
    +at 2018-02-19T18:10:06-05:00
    +mkdir pkg
    +echo 'package p // pkg/p.go'
    +cp stdout pkg/p.go
    +git add pkg/p.go
    +git commit -m 'add pkg/p.go'
    +git tag v0.0.0
    +git tag v1.0.0
    +git tag mytag
    +
    +git checkout --detach HEAD
    +
    +at 2018-02-19T18:14:23-05:00
    +mkdir v2
    +echo 'module "github.com/rsc/vgotest1/v2" // root go.mod'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'go.mod v2'
    +git tag v2.0.1
    +
    +at 2018-02-19T18:15:11-05:00
    +mkdir submod/pkg
    +echo 'package p // submod/pkg/p.go'
    +cp stdout submod/pkg/p.go
    +git add submod/pkg/p.go
    +git commit -m 'submod/pkg/p.go'
    +git tag v2.0.2
    +
    +at 2018-02-19T18:16:04-05:00
    +echo 'module "github.com/rsc/vgotest" // v2/go.mod'
    +cp stdout v2/go.mod
    +git add v2/go.mod
    +git commit -m 'v2/go.mod: bad go.mod (no version)'
    +git tag v2.0.3
    +
    +at 2018-02-19T19:03:38-05:00
    +env GIT_AUTHOR_DATE=2018-02-19T18:16:38-05:00
    +echo 'module "github.com/rsc/vgotest1/v2" // v2/go.mod'
    +cp stdout v2/go.mod
    +git add v2/go.mod
    +git commit -m 'v2/go.mod: fix'
    +git tag v2.0.4
    +
    +at 2018-02-19T19:03:59-05:00
    +env GIT_AUTHOR_DATE=2018-02-19T18:17:02-05:00
    +echo 'module "github.com/rsc/vgotest1" // root go.mod'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'go.mod: drop v2'
    +git tag v2.0.5
    +
    +git checkout --detach mytag
    +
    +at 2018-02-19T18:10:28-05:00
    +echo 'module "github.com/rsc/vgotest1" // root go.mod'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'go.mod'
    +git tag v0.0.1
    +git tag v1.0.1
    +
    +at 2018-02-19T18:11:28-05:00
    +mkdir submod/pkg
    +echo 'package pkg // submod/pkg/p.go'
    +cp stdout submod/pkg/p.go
    +git add submod
    +git commit -m 'submod/pkg/p.go'
    +git tag v1.0.2
    +
    +at 2018-02-19T18:12:07-05:00
    +echo 'module "github.com/vgotest1/submod" // submod/go.mod'
    +cp stdout submod/go.mod
    +git add submod/go.mod
    +git commit -m 'submod/go.mod'
    +git tag v1.0.3
    +git tag submod/v1.0.4
    +
    +at 2018-02-19T18:12:59-05:00
    +git apply 0001-submod-go.mod-add-require-vgotest1-v1.1.0.patch
    +git commit -a -m 'submod/go.mod: add require vgotest1 v1.1.0'
    +git tag submod/v1.0.5
    +
    +at 2018-02-19T18:13:36-05:00
    +git apply 0002-go.mod-add-require-submod-v1.0.5.patch
    +git commit -a -m 'go.mod: add require submod v1.0.5'
    +git tag v1.1.0
    +
    +git checkout master
    +
    +at 2018-02-19T17:23:01-05:00
    +mkdir pkg
    +echo 'package pkg'
    +cp stdout pkg/p.go
    +git add pkg/p.go
    +git commit -m 'pkg: add'
    +
    +at 2018-02-19T17:30:23-05:00
    +env GIT_AUTHOR_DATE=2018-02-19T17:24:48-05:00
    +echo 'module "github.com/vgotest1/v2"'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'add go.mod'
    +
    +at 2018-02-19T17:30:45-05:00
    +echo 'module "github.com/vgotest1"'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'bad mod path'
    +
    +at 2018-02-19T17:31:34-05:00
    +mkdir v2
    +echo 'module "github.com/vgotest1/v2"'
    +cp stdout v2/go.mod
    +git add v2/go.mod
    +git commit -m 'add v2/go.mod'
    +
    +at 2018-02-19T17:32:37-05:00
    +echo 'module "github.com/vgotest1/v2"'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'say v2 in root go.mod'
    +
    +git checkout --detach HEAD
    +at 2018-02-19T17:51:24-05:00
    +	# README.md at this commit lacked a trailing newline, so 'git apply' can't
    +	# seem to apply it correctly as a patch. Instead, we use 'echo -e' to write
    +	# the exact contents.
    +unquote 'This is a test repo for versioned go.\nThere''s nothing useful here.\n\n	v0.0.0 - has pkg/p.go\n	v0.0.1 - has go.mod\n	\n	v1.0.0 - has pkg/p.go\n	v1.0.1 - has go.mod\n	v1.0.2 - has submod/pkg/p.go\n	v1.0.3 - has submod/go.mod\n	submod/v1.0.4 - same\n	submod/v1.0.5 - add requirement on v1.1.0\n	v1.1.0 - add requirement on submod/v1.0.5\n	\n	v2.0.0 - has pkg/p.go\n	v2.0.1 - has go.mod with v2 module path\n	v2.0.2 - has go.mod with v1 (no version) module path\n	v2.0.3 - has v2/go.mod with v2 module path\n	v2.0.5 - has go.mod AND v2/go.mod with v2 module path\n	'
    +cp stdout README.md
    +mkdir v2/pkg
    +echo 'package q'
    +cp stdout v2/pkg/q.go
    +git add README.md v2/pkg/q.go
    +git commit -m 'add q'
    +git tag v2.0.6
    +
    +git checkout --detach mytag~1
    +at 2018-07-18T21:21:27-04:00
    +env GIT_AUTHOR_DATE=2018-02-19T18:10:06-05:00
    +mkdir pkg
    +echo 'package p // pkg/p.go'
    +cp stdout pkg/p.go
    +git add pkg/p.go
    +unquote 'add pkg/p.go\n\nv2\n'
    +cp stdout COMMIT_MSG
    +git commit -F COMMIT_MSG
    +git tag v2.0.0
    +
    +git checkout master
    +
    +git show-ref --tags --heads
    +cmp stdout .git-refs
    +
    +-- .git-refs --
    +a08abb797a6764035a9314ed5f1d757e0224f3bf refs/heads/master
    +80d85c5d4d17598a0e9055e7c175a32b415d6128 refs/tags/mytag
    +8afe2b2efed96e0880ecd2a69b98a53b8c2738b6 refs/tags/submod/v1.0.4
    +70fd92eaa4dacf82548d0c6099f5b853ae2c1fc8 refs/tags/submod/v1.0.5
    +80d85c5d4d17598a0e9055e7c175a32b415d6128 refs/tags/v0.0.0
    +5a115c66393dd8c4a5cc3215653850d7f5640d0e refs/tags/v0.0.1
    +80d85c5d4d17598a0e9055e7c175a32b415d6128 refs/tags/v1.0.0
    +5a115c66393dd8c4a5cc3215653850d7f5640d0e refs/tags/v1.0.1
    +2e38a1a347ba4d9e9946ec0ce480710ff445c919 refs/tags/v1.0.2
    +8afe2b2efed96e0880ecd2a69b98a53b8c2738b6 refs/tags/v1.0.3
    +b769f2de407a4db81af9c5de0a06016d60d2ea09 refs/tags/v1.1.0
    +45f53230a74ad275c7127e117ac46914c8126160 refs/tags/v2.0.0
    +ea65f87c8f52c15ea68f3bdd9925ef17e20d91e9 refs/tags/v2.0.1
    +f7b23352af1cd750b11e4673b20b24c2d239430a refs/tags/v2.0.2
    +f18795870fb14388a21ef3ebc1d75911c8694f31 refs/tags/v2.0.3
    +1f863feb76bc7029b78b21c5375644838962f88d refs/tags/v2.0.4
    +2f615117ce481c8efef46e0cc0b4b4dccfac8fea refs/tags/v2.0.5
    +a01a0aef06cbd571294fc5451788cd4eadbfd651 refs/tags/v2.0.6
    +-- LICENSE --
    +Copyright (c) 2009 The Go Authors. All rights reserved.
    +
    +Redistribution and use in source and binary forms, with or without
    +modification, are permitted provided that the following conditions are
    +met:
    +
    +   * Redistributions of source code must retain the above copyright
    +notice, this list of conditions and the following disclaimer.
    +   * Redistributions in binary form must reproduce the above
    +copyright notice, this list of conditions and the following disclaimer
    +in the documentation and/or other materials provided with the
    +distribution.
    +   * Neither the name of Google Inc. nor the names of its
    +contributors may be used to endorse or promote products derived from
    +this software without specific prior written permission.
    +
    +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    +-- README.md --
    +This is a test repo for versioned go.
    +There's nothing useful here.
    +-- 0001-submod-go.mod-add-require-vgotest1-v1.1.0.patch --
    +From 70fd92eaa4dacf82548d0c6099f5b853ae2c1fc8 Mon Sep 17 00:00:00 2001
    +From: Russ Cox 
    +Date: Mon, 19 Feb 2018 18:12:59 -0500
    +Subject: [PATCH] submod/go.mod: add require vgotest1 v1.1.0
    +
    +---
    + submod/go.mod | 1 +
    + 1 file changed, 1 insertion(+)
    +
    +diff --git a/submod/go.mod b/submod/go.mod
    +index 7b18d93..c88de0f 100644
    +--- a/submod/go.mod
    ++++ b/submod/go.mod
    +@@ -1 +1,2 @@
    + module "github.com/vgotest1/submod" // submod/go.mod
    ++require "github.com/vgotest1" v1.1.0
    +--
    +2.36.1.838.g23b219f8e3
    +-- 0002-go.mod-add-require-submod-v1.0.5.patch --
    +From b769f2de407a4db81af9c5de0a06016d60d2ea09 Mon Sep 17 00:00:00 2001
    +From: Russ Cox 
    +Date: Mon, 19 Feb 2018 18:13:36 -0500
    +Subject: [PATCH] go.mod: add require submod v1.0.5
    +
    +---
    + go.mod | 1 +
    + 1 file changed, 1 insertion(+)
    +
    +diff --git a/go.mod b/go.mod
    +index ac7a6d7..6118671 100644
    +--- a/go.mod
    ++++ b/go.mod
    +@@ -1 +1,2 @@
    + module "github.com/rsc/vgotest1" // root go.mod
    ++require "github.com/rsc/vgotest1/submod" v1.0.5
    +--
    +2.36.1.838.g23b219f8e3
    diff --git a/go/src/cmd/go/testdata/vcstest/go/custom-hg-hello.txt b/go/src/cmd/go/testdata/vcstest/go/custom-hg-hello.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..40b1ef6d4e01c606142947056c63609a8989762d
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/custom-hg-hello.txt
    @@ -0,0 +1,4 @@
    +handle dir
    +
    +-- index.html --
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/go/gitreposubdir.txt b/go/src/cmd/go/testdata/vcstest/go/gitreposubdir.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..53a16078d18cf30b40e5c4899a6f7ecad8254551
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/gitreposubdir.txt
    @@ -0,0 +1,6 @@
    +handle dir
    +
    +-- index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/go/gitreposubdirv2.txt b/go/src/cmd/go/testdata/vcstest/go/gitreposubdirv2.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..da77226c75ca6ebb0b96da7aef49044ff08910c9
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/gitreposubdirv2.txt
    @@ -0,0 +1,6 @@
    +handle dir
    +
    +-- v2/index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/go/insecure.txt b/go/src/cmd/go/testdata/vcstest/go/insecure.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..6eb83c31aa1fdc7db72c1136ecc7f1628cc0ad63
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/insecure.txt
    @@ -0,0 +1,6 @@
    +handle dir
    +
    +-- index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/go/missingrepo.txt b/go/src/cmd/go/testdata/vcstest/go/missingrepo.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..9db6c145d5a3305485f6e62ac442d884f80da049
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/missingrepo.txt
    @@ -0,0 +1,18 @@
    +handle dir
    +
    +-- missingrepo-git/index.html --
    +
    +
    +
    +-- missingrepo-git/notmissing/index.html --
    +
    +
    +
    +-- missingrepo-git-ssh/index.html --
    +
    +
    +
    +-- missingrepo-git-ssh/notmissing/index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/go/mod/gitrepo-sha256.txt b/go/src/cmd/go/testdata/vcstest/go/mod/gitrepo-sha256.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..5349b3a2ecfca5b3a6dba5c65d351f7cfeee46cd
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/mod/gitrepo-sha256.txt
    @@ -0,0 +1,6 @@
    +handle dir
    +
    +-- index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/go/mod/gitrepo1.txt b/go/src/cmd/go/testdata/vcstest/go/mod/gitrepo1.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..0e727d3ffd217dbefc30d8c6439d71748a25eefe
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/mod/gitrepo1.txt
    @@ -0,0 +1,6 @@
    +handle dir
    +
    +-- index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/go/modauth404.txt b/go/src/cmd/go/testdata/vcstest/go/modauth404.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..51f25a9deee028b39f6701d163852dd9138333c7
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/modauth404.txt
    @@ -0,0 +1,6 @@
    +handle dir
    +
    +-- index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/go/test1-svn-git.txt b/go/src/cmd/go/testdata/vcstest/go/test1-svn-git.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..42dc949dadfd1987bfc16292e15b23eb1514b249
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/test1-svn-git.txt
    @@ -0,0 +1,30 @@
    +handle dir
    +
    +-- aaa/index.html --
    +
    +
    +
    +-- git-README-only/index.html --
    +
    +
    +
    +-- git-README-only/other/index.html --
    +
    +
    +
    +-- git-README-only/pkg/index.html --
    +
    +
    +
    +-- index.html --
    +
    +
    +
    +-- other/index.html --
    +
    +
    +
    +-- tiny/index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/go/test2-svn-git.txt b/go/src/cmd/go/testdata/vcstest/go/test2-svn-git.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..8aae5c84d663d5330c9193f6089d4464fb8609b5
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/test2-svn-git.txt
    @@ -0,0 +1,26 @@
    +handle dir
    +
    +-- test2main/index.html --
    +
    +
    +
    +-- test2pkg/index.html --
    +
    +
    +
    +-- test2pkg/pkg/index.html --
    +
    +
    +
    +-- test2PKG/index.html --
    +
    +
    +
    +-- test2PKG/p1/index.html --
    +
    +
    +
    +-- test2PKG/pkg/index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/go/v2module.txt b/go/src/cmd/go/testdata/vcstest/go/v2module.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..abcf2fd950bbad481a9b176e0b095b2f4f405b48
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/go/v2module.txt
    @@ -0,0 +1,6 @@
    +handle dir
    +
    +-- v2/index.html --
    +
    +
    +
    diff --git a/go/src/cmd/go/testdata/vcstest/hg/custom-hg-hello.txt b/go/src/cmd/go/testdata/vcstest/hg/custom-hg-hello.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..572cbdfef06ffcbe0256515131a21ceab45176a4
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/hg/custom-hg-hello.txt
    @@ -0,0 +1,17 @@
    +handle hg
    +hg init
    +
    +hg add hello.go
    +hg commit --user 'Russ Cox ' --date '2017-10-10T19:39:36-04:00' --message 'hello'
    +
    +hg log -r ':' --template '{node|short} {desc|strip|firstline}\n'
    +cmp stdout .hg-log
    +
    +-- .hg-log --
    +a8c8e7a40da9 hello
    +-- hello.go --
    +package main // import "vcs-test.golang.org/go/custom-hg-hello"
    +
    +func main() {
    +	println("hello")
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/hg/hello.txt b/go/src/cmd/go/testdata/vcstest/hg/hello.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..10f114e572974626020185eb5b2c35b4da54071e
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/hg/hello.txt
    @@ -0,0 +1,17 @@
    +handle hg
    +hg init
    +
    +hg add hello.go
    +hg commit --user 'bwk' --date '2017-09-21T21:14:14-04:00' --message 'hello world'
    +
    +hg log -r ':' --template '{node|short} {desc|strip|firstline}\n'
    +cmp stdout .hg-log
    +
    +-- .hg-log --
    +e483a7d9f8c9 hello world
    +-- hello.go --
    +package main
    +
    +func main() {
    +	println("hello, world")
    +}
    diff --git a/go/src/cmd/go/testdata/vcstest/hg/hgrepo1.txt b/go/src/cmd/go/testdata/vcstest/hg/hgrepo1.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..42d81e9d39a3ee52b0364415ef6b13a39f1075ea
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/hg/hgrepo1.txt
    @@ -0,0 +1,97 @@
    +handle hg
    +
    +hg init
    +
    +env date=2018-04-17T15:43:22-04:00
    +unquote ''
    +cp stdout README
    +hg add README
    +hg commit --user=rsc --date=$date -m 'empty README'
    +hg branch tagbranch
    +hg tag --user=rsc --date=$date v1.2.3
    +hg update default
    +
    +env date=2018-04-17T15:45:48-04:00
    +hg branch v2
    +echo 'v2'
    +cp stdout v2
    +hg add v2
    +hg commit --user=rsc --date=$date -m 'v2'
    +hg update tagbranch
    +hg tag --user=rsc --date=$date -r v2 v2.3
    +hg tag --user=rsc --date=$date -r v2 v2.0.1
    +hg update v2
    +hg branch v2.3.4
    +
    +env date=2018-04-17T16:00:19-04:00
    +echo 'intermediate'
    +cp stdout foo.txt
    +hg add foo.txt
    +hg commit --user=rsc --date=$date -m 'intermediate'
    +
    +env date=2018-04-17T16:00:32-04:00
    +echo 'another'
    +cp stdout another.txt
    +hg add another.txt
    +hg commit --user=rsc --date=$date -m 'another'
    +hg update tagbranch
    +hg tag --user=rsc --date=$date -r v2.3.4 v2.0.2
    +
    +env date=2018-04-17T16:16:52-04:00
    +hg update default
    +hg branch v3
    +mkdir v3/sub/dir
    +echo 'v3/sub/dir/file'
    +cp stdout v3/sub/dir/file.txt
    +hg add v3
    +hg commit --user=rsc --date=$date -m 'add v3/sub/dir/file.txt'
    +
    +env date=2018-04-17T22:23:00-04:00
    +hg update default
    +hg tag --user=rsc --date=$date -r v1.2.3 v1.2.4-annotated
    +
    +env date=2018-06-27T12:15:24-04:00
    +hg update v2
    +unquote ''
    +cp stdout dummy
    +hg add dummy
    +hg commit --user=rsc --date=$date -m 'dummy'
    +
    +env date=2018-06-27T12:16:10-04:00
    +hg update v2.3.4
    +hg branch v2.3.4
    +unquote ''
    +cp stdout dummy
    +hg add dummy
    +hg commit --user=rsc --date=$date -m 'dummy'
    +
    +hg book v2 -r v2.0.2 --force
    +hg book v2.3.4 -r v2.0.1 --force
    +
    +hg log -G --debug
    +
    +hg tags
    +cmp stdout .hg-tags
    +
    +hg branches
    +cmp stdout .hg-branches
    +
    +hg bookmarks
    +cmp stdout .hg-bookmarks
    +
    +-- .hg-tags --
    +tip                               11:745aacc8b24d
    +v2.0.2                             6:b1ed98abc268
    +v2.3                               2:a546811101e1
    +v2.0.1                             2:a546811101e1
    +v1.2.4-annotated                   0:c0186fb00e50
    +v1.2.3                             0:c0186fb00e50
    +-- .hg-branches --
    +v2.3.4                        11:745aacc8b24d
    +v2                            10:2b5ca8689628
    +default                        9:a9a2a32d1392
    +v3                             8:442174d28f65
    +tagbranch                      7:1a3473c317b4
    +-- .hg-bookmarks --
    +   v2                        6:b1ed98abc268
    +   v2.3.4                    2:a546811101e1
    diff --git a/go/src/cmd/go/testdata/vcstest/hg/legacytest.txt b/go/src/cmd/go/testdata/vcstest/hg/legacytest.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c3f063e2fa2ccadf80a8bf52d298437bcb957ce1
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/hg/legacytest.txt
    @@ -0,0 +1,124 @@
    +handle hg
    +
    +env user='Russ Cox '
    +
    +hg init
    +
    +env date=2018-07-17T12:41:39-04:00
    +cp x_cf92c7b.go x.go
    +hg add x.go
    +hg commit --user=$user --date=$date -m 'initial commit'
    +
    +env date=2018-07-17T12:41:57-04:00
    +cp x_52853eb.go x.go
    +hg commit --user=$user --date=$date -m 'add X' x.go
    +
    +env date=2018-07-17T12:42:07-04:00
    +cp x_7fff7f3.go x.go
    +hg commit --user=$user --date=$date -m 'gofmt' x.go
    +hg tag --user=$user --date=$date v1.0.0
    +
    +env date=2018-07-17T12:42:28-04:00
    +cp x_fa4f5d6.go x.go
    +hg commit --user=$user --date=$date -m 'X->XX' x.go
    +
    +env date=2018-07-17T12:42:36-04:00
    +cp x_d7ae1e4.go x.go
    +hg commit --user=$user --date=$date -m 'gofmt' x.go
    +hg tag --user=$user --date=$date v2.0.0
    +
    +env date=2018-07-17T12:42:53-04:00
    +cp x_7303f77.go x.go
    +hg commit --user=$user --date=$date -m 'add XXX' x.go
    +
    +env date=2018-07-17T12:47:59-04:00
    +hg update v1.0.0
    +cp x_1abc5ff.go x.go
    +hg commit --user=$user --date=$date -m 'comment' x.go
    +
    +env date=2018-07-17T12:48:22-04:00
    +cp x_731e3b1.go x.go
    +hg commit --user=$user --date=$date -m 'prerelease' x.go
    +hg tag --user=$user --date=$date v1.1.0-pre
    +
    +env date=2018-07-17T12:48:49-04:00
    +cp x_fb3c628.go x.go
    +hg commit --user=$user --date=$date -m 'working' x.go
    +
    +env date=2018-07-17T12:49:05-04:00
    +cp x_9f6f860.go x.go
    +hg commit --user=$user --date=$date -m 'v1.2.0' x.go
    +hg tag --user=$user --date=$date v1.2.0
    +
    +env date=2018-07-17T12:49:42-04:00
    +cp x_d2d4c3e.go x.go
    +hg commit --user=$user --date=$date -m 'more' x.go
    +hg tag --user=$user --date=$date morework
    +
    +hg log -r ':' --template '{node|short} {desc|strip|firstline}\n'
    +cmp stdout .hg-log
    +
    +-- .hg-log --
    +9dc9138de2e5 initial commit
    +ee0106da3c7c add X
    +d6ad170f61d4 gofmt
    +90c54d4351ee Added tag v1.0.0 for changeset d6ad170f61d4
    +c6260ab8dc3e X->XX
    +e64782fcadfd gofmt
    +d6ad604046f6 Added tag v2.0.0 for changeset e64782fcadfd
    +663753d3ac63 add XXX
    +4555a6dd66c0 comment
    +90da67a9bf0c prerelease
    +d7c15fbd635d Added tag v1.1.0-pre for changeset 90da67a9bf0c
    +accb169a3696 working
    +07462d11385f v1.2.0
    +ed9a22ebb8a1 Added tag v1.2.0 for changeset 07462d11385f
    +498b291aa133 more
    +2840708d1294 Added tag morework for changeset 498b291aa133
    +-- x_1abc5ff.go --
    +package legacytest
    +
    +// add comment
    +const X = 1
    +-- x_52853eb.go --
    +package legacytest
    +const X = 1
    +-- x_7303f77.go --
    +package legacytest
    +
    +const XX = 2
    +
    +const XXX = 3
    +-- x_731e3b1.go --
    +package legacytest
    +
    +// add comment again
    +const X = 1
    +-- x_7fff7f3.go --
    +package legacytest
    +
    +const X = 1
    +-- x_9f6f860.go --
    +package legacytest
    +
    +// add comment again!!!
    +const X = 1
    +-- x_cf92c7b.go --
    +package legacytest
    +-- x_d2d4c3e.go --
    +package legacytest
    +
    +// add comment hack hack hack
    +const X = 1
    +-- x_d7ae1e4.go --
    +package legacytest
    +
    +const XX = 2
    +-- x_fa4f5d6.go --
    +package legacytest
    +const XX = 2
    +-- x_fb3c628.go --
    +package legacytest
    +
    +// add comment fixed
    +const X = 1
    diff --git a/go/src/cmd/go/testdata/vcstest/hg/prefixtagtests.txt b/go/src/cmd/go/testdata/vcstest/hg/prefixtagtests.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c61c9bacae93d071252d403abd376980ba188718
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/hg/prefixtagtests.txt
    @@ -0,0 +1,52 @@
    +env date=2019-05-09T18:35:00-04:00
    +
    +handle hg
    +
    +hg init
    +hg add sub
    +hg commit -u rsc -d $date -m 'create module sub'
    +
    +echo v0.1.0
    +cp stdout status
    +hg add status
    +hg commit -u rsc -d $date -m v0.1.0
    +hg tag -u rsc -d $date v0.1.0
    +
    +echo sub/v0.0.9
    +cp stdout status
    +hg add status
    +hg commit -u rsc -d $date -m sub/v0.0.9
    +hg tag -u rsc -d $date sub/v0.0.9
    +
    +echo sub/v0.0.10
    +cp stdout status
    +hg commit -u rsc -d $date -m sub/v0.0.10 status
    +hg tag -u rsc -d $date sub/v0.0.10
    +
    +echo v0.2.0
    +cp stdout status
    +hg commit -u rsc -d $date -m v0.2.0
    +hg tag -u rsc -d $date v0.2.0
    +
    +echo 'after last tag'
    +cp stdout status
    +hg commit -u rsc -d $date -m 'after last tag'
    +
    +hg tags
    +cmp stdout .hg-tags
    +
    +hg branches
    +cmp stdout .hg-branches
    +
    +-- .hg-tags --
    +tip                                9:840814f739c2
    +v0.2.0                             7:84e452ea2b0a
    +sub/v0.0.10                        5:1cc0dfcc254c
    +sub/v0.0.9                         3:c5f5e3168705
    +v0.1.0                             1:d6ba12969a9b
    +-- .hg-branches --
    +default                        9:840814f739c2
    +-- sub/go.mod --
    +module vcs-test.golang.org/git/prefixtagtests.git/sub
    +-- sub/sub.go --
    +package sub
    diff --git a/go/src/cmd/go/testdata/vcstest/hg/tagtests.txt b/go/src/cmd/go/testdata/vcstest/hg/tagtests.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..38b3e97ef9b3598dcc2b7eb4dd9e94dc0c133da8
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/hg/tagtests.txt
    @@ -0,0 +1,38 @@
    +env date=2019-05-09T18:56:25-04:00
    +
    +handle hg
    +
    +hg init
    +hg add go.mod tagtests.go
    +hg commit --user 'rsc' --date $date -m 'create module tagtests'
    +hg branch b
    +hg add v0.2.1
    +hg commit --user 'rsc' --date $date -m 'v0.2.1'
    +hg tag --user 'rsc' --date $date v0.2.1
    +
    +hg update default
    +hg add v0.2.2
    +hg commit --user 'rsc' --date $date -m 'v0.2.2'
    +hg tag --user 'rsc' --date $date v0.2.2
    +
    +hg tags
    +cmp stdout .hg-tags
    +
    +hg branches
    +cmp stdout .hg-branches
    +
    +-- go.mod --
    +module vcs-test.golang.org/git/tagtests.git
    +-- tagtests.go --
    +package tagtests
    +-- v0.2.1 --
    +v0.2.1
    +-- v0.2.2 --
    +v0.2.2
    +-- .hg-tags --
    +tip                                4:8d0b18b816df
    +v0.2.2                             3:1e531550e864
    +v0.2.1                             1:010a2d1a2ea7
    +-- .hg-branches --
    +default                        4:8d0b18b816df
    +b                              2:ceae444ffda5
    diff --git a/go/src/cmd/go/testdata/vcstest/hg/vgotest1.txt b/go/src/cmd/go/testdata/vcstest/hg/vgotest1.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..e53c5e04c90c62d93caff24dd5c3b45af435957c
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/hg/vgotest1.txt
    @@ -0,0 +1,322 @@
    +handle hg
    +
    +cd git
    +
    +env GIT_AUTHOR_NAME='Russ Cox'
    +env GIT_AUTHOR_EMAIL='rsc@golang.org'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +git init
    +
    +# 0
    +at 2018-02-19T17:21:09-05:00
    +git add LICENSE README.md
    +git commit -m 'initial commit'
    +git branch -m master
    +
    +# 1
    +git branch mybranch
    +git checkout mybranch
    +
    +at 2018-02-19T18:10:06-05:00
    +mkdir pkg
    +echo 'package p // pkg/p.go'
    +cp stdout pkg/p.go
    +git add pkg/p.go
    +git commit -m 'add pkg/p.go'
    +git tag v0.0.0
    +git tag v1.0.0
    +git tag v2.0.0
    +git tag mytag
    +
    +git branch v1
    +git branch v2
    +git checkout v2
    +
    +# 2
    +at 2018-02-19T18:14:23-05:00
    +mkdir v2
    +echo 'module "github.com/rsc/vgotest1/v2" // root go.mod'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'go.mod v2'
    +git tag v2.0.1
    +
    +# 3
    +at 2018-02-19T18:15:11-05:00
    +mkdir submod/pkg
    +echo 'package p // submod/pkg/p.go'
    +cp stdout submod/pkg/p.go
    +git add submod/pkg/p.go
    +git commit -m 'submod/pkg/p.go'
    +git tag v2.0.2
    +
    +# 4
    +at 2018-02-19T18:16:04-05:00
    +echo 'module "github.com/rsc/vgotest" // v2/go.mod'
    +cp stdout v2/go.mod
    +git add v2/go.mod
    +git commit -m 'v2/go.mod: bad go.mod (no version)'
    +git tag v2.0.3
    +
    +# 5
    +at 2018-02-19T19:03:38-05:00
    +env GIT_AUTHOR_DATE=2018-02-19T18:16:38-05:00
    +echo 'module "github.com/rsc/vgotest1/v2" // v2/go.mod'
    +cp stdout v2/go.mod
    +git add v2/go.mod
    +git commit -m 'v2/go.mod: fix'
    +git tag v2.0.4
    +
    +# 6
    +at 2018-02-19T19:03:59-05:00
    +env GIT_AUTHOR_DATE=2018-02-19T18:17:02-05:00
    +echo 'module "github.com/rsc/vgotest1" // root go.mod'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'go.mod: drop v2'
    +git tag v2.0.5
    +
    +git checkout v1
    +
    +# 7
    +at 2018-02-19T18:10:28-05:00
    +echo 'module "github.com/rsc/vgotest1" // root go.mod'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'go.mod'
    +git tag v0.0.1
    +git tag v1.0.1
    +
    +# 8
    +at 2018-02-19T18:11:28-05:00
    +mkdir submod/pkg
    +echo 'package pkg // submod/pkg/p.go'
    +cp stdout submod/pkg/p.go
    +git add submod
    +git commit -m 'submod/pkg/p.go'
    +git tag v1.0.2
    +
    +# 9
    +at 2018-02-19T18:12:07-05:00
    +echo 'module "github.com/vgotest1/submod" // submod/go.mod'
    +cp stdout submod/go.mod
    +git add submod/go.mod
    +git commit -m 'submod/go.mod'
    +git tag v1.0.3
    +git tag submod/v1.0.4
    +
    +# 10
    +at 2018-02-19T18:12:59-05:00
    +git apply ../0001-submod-go.mod-add-require-vgotest1-v1.1.0.patch
    +git commit -a -m 'submod/go.mod: add require vgotest1 v1.1.0'
    +git tag submod/v1.0.5
    +
    +# 11
    +at 2018-02-19T18:13:36-05:00
    +git apply ../0002-go.mod-add-require-submod-v1.0.5.patch
    +git commit -a -m 'go.mod: add require submod v1.0.5'
    +git tag v1.1.0
    +
    +git checkout master
    +
    +# 12
    +at 2018-02-19T17:23:01-05:00
    +mkdir pkg
    +echo 'package pkg'
    +cp stdout pkg/p.go
    +git add pkg/p.go
    +git commit -m 'pkg: add'
    +
    +# 13
    +at 2018-02-19T17:30:23-05:00
    +env GIT_AUTHOR_DATE=2018-02-19T17:24:48-05:00
    +echo 'module "github.com/vgotest1/v2"'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'add go.mod'
    +
    +# 14
    +at 2018-02-19T17:30:45-05:00
    +echo 'module "github.com/vgotest1"'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'bad mod path'
    +
    +# 15
    +at 2018-02-19T17:31:34-05:00
    +mkdir v2
    +echo 'module "github.com/vgotest1/v2"'
    +cp stdout v2/go.mod
    +git add v2/go.mod
    +git commit -m 'add v2/go.mod'
    +
    +# 16
    +at 2018-02-19T17:32:37-05:00
    +echo 'module "github.com/vgotest1/v2"'
    +cp stdout go.mod
    +git add go.mod
    +git commit -m 'say v2 in root go.mod'
    +
    +# 17
    +at 2018-02-19T17:51:24-05:00
    +	# README.md at this commit lacked a trailing newline, so 'git apply' can't
    +	# seem to apply it correctly as a patch. Instead, we use 'unquote' to write
    +	# the exact contents.
    +unquote 'This is a test repo for versioned go.\nThere''s nothing useful here.\n\n	v0.0.0 - has pkg/p.go\n	v0.0.1 - has go.mod\n	\n	v1.0.0 - has pkg/p.go\n	v1.0.1 - has go.mod\n	v1.0.2 - has submod/pkg/p.go\n	v1.0.3 - has submod/go.mod\n	submod/v1.0.4 - same\n	submod/v1.0.5 - add requirement on v1.1.0\n	v1.1.0 - add requirement on submod/v1.0.5\n	\n	v2.0.0 - has pkg/p.go\n	v2.0.1 - has go.mod with v2 module path\n	v2.0.2 - has go.mod with v1 (no version) module path\n	v2.0.3 - has v2/go.mod with v2 module path\n	v2.0.5 - has go.mod AND v2/go.mod with v2 module path\n	'
    +cp stdout README.md
    +mkdir v2/pkg
    +echo 'package q'
    +cp stdout v2/pkg/q.go
    +git add README.md v2/pkg/q.go
    +git commit -m 'add q'
    +git tag v2.0.6
    +
    +cd ..
    +
    +hg init
    +hg convert ./git .
    +rm ./git
    +
    +# Note: commit #18 is an 'update tags' commit automatically generated by 'hg
    +# convert'. We have no control over its timestamp, so it and its descendent
    +# commit #19 both end up with unpredictable commit hashes.
    +#
    +# Fortunately, these commits don't seem to matter for the purpose of reproducing
    +# the final branches and heads from the original copy of this repo.
    +
    +# 19
    +hg update -C -r 18
    +hg tag --user 'Russ Cox ' --date '2018-07-18T21:24:45-04:00' -m 'Removed tag v2.0.0' --remove v2.0.0
    +
    +# 20
    +hg branch default
    +hg update -C -r 1
    +echo 'v2'
    +cp stdout v2
    +hg add v2
    +hg commit --user 'Russ Cox ' --date '2018-07-18T21:25:08-04:00' -m 'v2.0.0'
    +
    +# 21
    +hg tag --user 'Russ Cox ' --date '2018-07-18T21:25:13-04:00' -r f0ababb31f75 -m 'Added tag v2.0.0 for changeset f0ababb31f75' v2.0.0
    +
    +# 22
    +hg tag --user 'Russ Cox ' --date '2018-07-18T21:26:02-04:00' -m 'Removed tag v2.0.0' --remove v2.0.0
    +
    +# 23
    +hg update -C -r 1
    +echo 'v2'
    +cp stdout v2
    +hg add v2
    +hg commit --user 'Russ Cox ' --date '2018-07-19T01:21:27+00:00' -m 'v2'
    +
    +# 24
    +hg tag --user 'Russ Cox ' --date '2018-07-18T21:26:33-04:00' -m 'Added tag v2.0.0 for changeset 814fce58e83a' -r 814fce58e83a v2.0.0
    +
    +hg book --delete v1
    +hg book --delete v2
    +hg book --force -r 16 master
    +
    +hg log -G --debug
    +
    +hg tags
    +cmp stdout .hg-tags
    +hg branches
    +cmp stdout .hg-branches
    +hg bookmarks
    +cmp stdout .hg-bookmarks
    +
    +-- .hg-tags --
    +tip                               24:645b06ca536d
    +v2.0.0                            23:814fce58e83a
    +v2.0.6                            17:3d4b89a2d059
    +v1.1.0                            11:92c7eb888b4f
    +submod/v1.0.5                     10:f3f560a6065c
    +v1.0.3                             9:4e58084d459a
    +submod/v1.0.4                      9:4e58084d459a
    +v1.0.2                             8:3ccdce3897f9
    +v1.0.1                             7:7890ea771ced
    +v0.0.1                             7:7890ea771ced
    +v2.0.5                             6:879ea98f7743
    +v2.0.4                             5:bf6388016230
    +v2.0.3                             4:a9ad6d1d14eb
    +v2.0.2                             3:de3663002f0f
    +v2.0.1                             2:f1fc0f22021b
    +v1.0.0                             1:e125018e286a
    +v0.0.0                             1:e125018e286a
    +mytag                              1:e125018e286a
    +-- .hg-branches --
    +default                       24:645b06ca536d
    +-- .hg-bookmarks --
    +   master                    16:577bde103b24
    +   mybranch                  1:e125018e286a
    +-- git/LICENSE --
    +Copyright (c) 2009 The Go Authors. All rights reserved.
    +
    +Redistribution and use in source and binary forms, with or without
    +modification, are permitted provided that the following conditions are
    +met:
    +
    +   * Redistributions of source code must retain the above copyright
    +notice, this list of conditions and the following disclaimer.
    +   * Redistributions in binary form must reproduce the above
    +copyright notice, this list of conditions and the following disclaimer
    +in the documentation and/or other materials provided with the
    +distribution.
    +   * Neither the name of Google Inc. nor the names of its
    +contributors may be used to endorse or promote products derived from
    +this software without specific prior written permission.
    +
    +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    +-- git/README.md --
    +This is a test repo for versioned go.
    +There's nothing useful here.
    +-- 0001-submod-go.mod-add-require-vgotest1-v1.1.0.patch --
    +From 70fd92eaa4dacf82548d0c6099f5b853ae2c1fc8 Mon Sep 17 00:00:00 2001
    +From: Russ Cox 
    +Date: Mon, 19 Feb 2018 18:12:59 -0500
    +Subject: [PATCH] submod/go.mod: add require vgotest1 v1.1.0
    +
    +---
    + submod/go.mod | 1 +
    + 1 file changed, 1 insertion(+)
    +
    +diff --git a/submod/go.mod b/submod/go.mod
    +index 7b18d93..c88de0f 100644
    +--- a/submod/go.mod
    ++++ b/submod/go.mod
    +@@ -1 +1,2 @@
    + module "github.com/vgotest1/submod" // submod/go.mod
    ++require "github.com/vgotest1" v1.1.0
    +-- 
    +2.36.1.838.g23b219f8e3
    +-- 0002-go.mod-add-require-submod-v1.0.5.patch --
    +From b769f2de407a4db81af9c5de0a06016d60d2ea09 Mon Sep 17 00:00:00 2001
    +From: Russ Cox 
    +Date: Mon, 19 Feb 2018 18:13:36 -0500
    +Subject: [PATCH] go.mod: add require submod v1.0.5
    +
    +---
    + go.mod | 1 +
    + 1 file changed, 1 insertion(+)
    +
    +diff --git a/go.mod b/go.mod
    +index ac7a6d7..6118671 100644
    +--- a/go.mod
    ++++ b/go.mod
    +@@ -1 +1,2 @@
    + module "github.com/rsc/vgotest1" // root go.mod
    ++require "github.com/rsc/vgotest1/submod" v1.0.5
    +-- 
    +2.36.1.838.g23b219f8e3
    diff --git a/go/src/cmd/go/testdata/vcstest/insecure.txt b/go/src/cmd/go/testdata/vcstest/insecure.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..cbfb1b93dfe9608739bdcef6acf4cc479dc77cf4
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/insecure.txt
    @@ -0,0 +1 @@
    +handle insecure
    diff --git a/go/src/cmd/go/testdata/vcstest/svn/hello.txt b/go/src/cmd/go/testdata/vcstest/svn/hello.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..c6ebd8d9670ef7c2832efee787b3709359a609e8
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/svn/hello.txt
    @@ -0,0 +1,87 @@
    +handle svn
    +
    +mkdir db/transactions
    +mkdir db/txn-protorevs
    +chmod 0755 hooks/pre-revprop-change
    +
    +env ROOT=$PWD
    +cd .checkout
    +[GOOS:windows] svn checkout file:///$ROOT .
    +[!GOOS:windows] svn checkout file://$ROOT .
    +
    +svn add hello.go
    +svn commit --file MSG
    +svn propset svn:author 'rsc' --revprop -r1
    +svn propset svn:date '2017-09-22T01:12:45.861368Z' --revprop -r1
    +
    +svn update
    +svn log --xml
    +
    +[GOOS:windows] replace '\n' '\r\n' .svn-log
    +cmp stdout .svn-log
    +
    +-- .checkout/MSG --
    +hello world
    +
    +-- .checkout/hello.go --
    +package main
    +
    +func main() {
    +	println("hello, world")
    +}
    +-- .checkout/.svn-log --
    +
    +
    +
    +rsc
    +2017-09-22T01:12:45.861368Z
    +hello world
    +
    +
    +
    +
    +-- conf/authz --
    +-- conf/passwd --
    +-- conf/svnserve.conf --
    +-- db/current --
    +0
    +-- db/format --
    +6
    +layout sharded 1000
    +-- db/fs-type --
    +fsfs
    +-- db/fsfs.conf --
    +-- db/min-unpacked-rev --
    +0
    +-- db/revprops/0/0 --
    +K 8
    +svn:date
    +V 27
    +2017-09-22T01:11:53.895835Z
    +END
    +-- db/revs/0/0 --
    +PLAIN
    +END
    +ENDREP
    +id: 0.0.r0/17
    +type: dir
    +count: 0
    +text: 0 0 4 4 2d2977d1c96f487abe4a1e202dd03b4e
    +cpath: /
    +
    +
    +17 107
    +-- db/txn-current --
    +0
    +-- db/txn-current-lock --
    +-- db/uuid --
    +53cccb44-0fca-40a2-b0c5-acaf9e75039a
    +-- db/write-lock --
    +-- format --
    +5
    +-- hooks/pre-revprop-change --
    +#!/bin/sh
    +
    +-- hooks/pre-revprop-change.bat --
    +@exit
    diff --git a/go/src/cmd/go/testdata/vcstest/svn/nonexistent.txt b/go/src/cmd/go/testdata/vcstest/svn/nonexistent.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..a71ecf1238df99488c4ee6b91abfde034fefde64
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/svn/nonexistent.txt
    @@ -0,0 +1,5 @@
    +handle svn
    +
    +# For this path, we turn on the svn handler but don't actually create the repo.
    +# svnserve should use the svn protocol to tell the client that the repo doesn't
    +# actually exist.
    diff --git a/go/src/cmd/go/testdata/vcstest/svn/test1-svn-git.txt b/go/src/cmd/go/testdata/vcstest/svn/test1-svn-git.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..2b942018900cff1122caa972ef306fbfc5a23303
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/svn/test1-svn-git.txt
    @@ -0,0 +1,188 @@
    +handle svn
    +
    +# Note: this repo script does not produce a byte-for-byte copy of the original.
    +#
    +# The 'git init' operation in the nested Git repo creates some sample files
    +# whose contents depend on the exact Git version in use, and the steps we take
    +# to construct a fake 'git clone' status don't produce some log files that
    +# a real 'git clone' leaves behind.
    +#
    +# However, the repo is probably accurate enough for the tests that need it.
    +
    +env GIT_AUTHOR_NAME='Russ Cox'
    +env GIT_AUTHOR_EMAIL='rsc@golang.org'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +mkdir db/transactions
    +mkdir db/txn-protorevs
    +chmod 0755 hooks/pre-revprop-change
    +
    +env ROOT=$PWD
    +cd .checkout
    +[GOOS:windows] svn checkout file:///$ROOT .
    +[!GOOS:windows] svn checkout file://$ROOT .
    +
    +cd git-README-only
    +git init
    +git config --add core.ignorecase true
    +git config --add core.precomposeunicode true
    +
    +git add README
    +at 2017-09-22T11:39:03-04:00
    +git commit -a -m 'README'
    +git branch -m master
    +
    +git rev-parse HEAD
    +stdout '^7f800d2ac276dd7042ea0e8d7438527d236fd098$'
    +
    +	# Fake a clone from an origin repo at this commit.
    +git remote add origin https://vcs-test.swtch.com/git/README-only
    +mkdir .git/refs/remotes/origin
    +echo 'ref: refs/remotes/origin/master'
    +cp stdout .git/refs/remotes/origin/HEAD
    +unquote '# pack-refs with: peeled fully-peeled \n7f800d2ac276dd7042ea0e8d7438527d236fd098 refs/remotes/origin/master\n'
    +cp stdout .git/packed-refs
    +git branch --set-upstream-to=origin/master
    +
    +git add pkg/pkg.go
    +at 2017-09-22T11:41:28-04:00
    +git commit -a -m 'add pkg'
    +
    +git log --oneline --decorate=short
    +cmp stdout ../.git-log
    +
    +cd ..
    +svn add git-README-only
    +svn commit -m 'add modified git-README-only'
    +svn propset svn:author rsc --revprop -r1
    +svn propset svn:date 2017-09-22T15:41:54.145716Z --revprop -r1
    +
    +svn add pkg.go
    +svn commit -m 'use git-README-only/pkg'
    +svn propset svn:author rsc --revprop -r2
    +svn propset svn:date 2017-09-22T15:49:11.130406Z --revprop -r2
    +
    +svn add other
    +svn commit -m 'add other'
    +svn propset svn:author rsc --revprop -r3
    +svn propset svn:date 2017-09-22T16:56:16.665173Z --revprop -r3
    +
    +svn add tiny
    +svn commit -m 'add tiny'
    +svn propset svn:author rsc --revprop -r4
    +svn propset svn:date 2017-09-27T17:48:18.350817Z --revprop -r4
    +
    +cd git-README-only
    +git remote set-url origin https://vcs-test.golang.org/git/README-only
    +cd ..
    +replace 'vcs-test.swtch.com' 'vcs-test.golang.org' other/pkg.go
    +replace 'vcs-test.swtch.com' 'vcs-test.golang.org' pkg.go
    +svn commit -m 'move from vcs-test.swtch.com to vcs-test.golang.org'
    +svn propset svn:author rsc --revprop -r5
    +svn propset svn:date 2017-10-04T15:08:26.291877Z --revprop -r5
    +
    +svn update
    +svn log --xml
    +
    +[GOOS:windows] replace '\n' '\r\n' .svn-log
    +cmp stdout .svn-log
    +
    +-- .checkout/git-README-only/pkg/pkg.go --
    +package pkg
    +const Message = "code not in git-README-only"
    +-- .checkout/git-README-only/README --
    +README
    +-- .checkout/.git-log --
    +ab9f66b (HEAD -> master) add pkg
    +7f800d2 (origin/master, origin/HEAD) README
    +-- .checkout/pkg.go --
    +package p
    +
    +import "vcs-test.swtch.com/go/test1-svn-git/git-README-only/pkg"
    +
    +const _ = pkg.Message
    +-- .checkout/other/pkg.go --
    +package other
    +
    +import _ "vcs-test.swtch.com/go/test1-svn-git/git-README-only/other"
    +-- .checkout/tiny/tiny.go --
    +package tiny
    +-- .checkout/.svn-log --
    +
    +
    +
    +rsc
    +2017-10-04T15:08:26.291877Z
    +move from vcs-test.swtch.com to vcs-test.golang.org
    +
    +
    +rsc
    +2017-09-27T17:48:18.350817Z
    +add tiny
    +
    +
    +rsc
    +2017-09-22T16:56:16.665173Z
    +add other
    +
    +
    +rsc
    +2017-09-22T15:49:11.130406Z
    +use git-README-only/pkg
    +
    +
    +rsc
    +2017-09-22T15:41:54.145716Z
    +add modified git-README-only
    +
    +
    +-- conf/authz --
    +-- conf/passwd --
    +-- conf/svnserve.conf --
    +-- db/current --
    +0
    +-- db/format --
    +6
    +layout sharded 1000
    +-- db/fs-type --
    +fsfs
    +-- db/fsfs.conf --
    +-- db/min-unpacked-rev --
    +0
    +-- db/revprops/0/0 --
    +K 8
    +svn:date
    +V 27
    +2017-09-22T01:11:53.895835Z
    +END
    +-- db/revs/0/0 --
    +PLAIN
    +END
    +ENDREP
    +id: 0.0.r0/17
    +type: dir
    +count: 0
    +text: 0 0 4 4 2d2977d1c96f487abe4a1e202dd03b4e
    +cpath: /
    +
    +
    +17 107
    +-- db/txn-current --
    +0
    +-- db/txn-current-lock --
    +-- db/uuid --
    +53cccb44-0fca-40a2-b0c5-acaf9e75039a
    +-- db/write-lock --
    +-- format --
    +5
    +-- hooks/pre-revprop-change --
    +#!/bin/sh
    +
    +-- hooks/pre-revprop-change.bat --
    +@exit
    diff --git a/go/src/cmd/go/testdata/vcstest/svn/test2-svn-git.txt b/go/src/cmd/go/testdata/vcstest/svn/test2-svn-git.txt
    new file mode 100644
    index 0000000000000000000000000000000000000000..bf827976c721dd0fb57c7d26cf2d8982b0fae642
    --- /dev/null
    +++ b/go/src/cmd/go/testdata/vcstest/svn/test2-svn-git.txt
    @@ -0,0 +1,154 @@
    +handle svn
    +
    +# Note: this repo script does not produce a byte-for-byte copy of the original.
    +#
    +# The 'git init' operation in the nested Git repo creates some sample files
    +# whose contents depend on the exact Git version in use, and the steps we take
    +# to construct a fake 'git clone' status don't produce some log files that
    +# a real 'git clone' leaves behind.
    +#
    +# However, the repo is probably accurate enough for the tests that need it.
    +
    +env GIT_AUTHOR_NAME='Russ Cox'
    +env GIT_AUTHOR_EMAIL='rsc@golang.org'
    +env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
    +env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
    +
    +mkdir db/transactions
    +mkdir db/txn-protorevs
    +chmod 0755 hooks/pre-revprop-change
    +
    +env ROOT=$PWD
    +cd .checkout
    +[GOOS:windows] svn checkout file:///$ROOT .
    +[!GOOS:windows] svn checkout file://$ROOT .
    +
    +git init
    +git config --add core.ignorecase true
    +git config --add core.precomposeunicode true
    +
    +git add README
    +at 2017-09-22T11:39:03-04:00
    +git commit -a -m 'README'
    +git branch -m master
    +
    +git rev-parse HEAD
    +stdout '^7f800d2ac276dd7042ea0e8d7438527d236fd098$'
    +
    +	# Fake a clone from an origin repo at this commit.
    +git remote add origin https://vcs-test.swtch.com/git/README-only
    +mkdir .git/refs/remotes/origin
    +echo 'ref: refs/remotes/origin/master'
    +cp stdout .git/refs/remotes/origin/HEAD
    +unquote '# pack-refs with: peeled fully-peeled \n7f800d2ac276dd7042ea0e8d7438527d236fd098 refs/remotes/origin/master\n'
    +cp stdout .git/packed-refs
    +git branch --set-upstream-to=origin/master
    +
    +git add pkg/pkg.go
    +at 2017-09-22T11:41:28-04:00
    +git commit -a -m 'add pkg'
    +
    +git log --oneline --decorate=short
    +cmp stdout .git-log
    +
    +rm README
    +
    +svn add .git pkg
    +svn commit -m 'git'
    +svn propset svn:author rsc --revprop -r1
    +svn propset svn:date 2017-09-27T18:00:52.201719Z --revprop -r1
    +
    +svn add p1
    +svn commit -m 'add p1'
    +svn propset svn:author rsc --revprop -r2
    +svn propset svn:date 2017-09-27T18:16:14.650893Z --revprop -r2
    +
    +git remote set-url origin https://vcs-test.golang.org/git/README-only
    +svn commit -m 'move from vcs-test.swtch.com to vcs-test.golang.org'
    +svn propset svn:author rsc --revprop -r3
    +svn propset svn:date 2017-10-04T15:09:35.963034Z --revprop -r3
    +
    +svn update
    +svn log --xml
    +
    +[GOOS:windows] replace '\n' '\r\n' .svn-log
    +cmp stdout .svn-log
    +
    +-- .checkout/.git-log --
    +ab9f66b (HEAD -> master) add pkg
    +7f800d2 (origin/master, origin/HEAD) README
    +-- .checkout/p1/p1.go --
    +package p1
    +-- .checkout/pkg/pkg.go --
    +package pkg
    +const Message = "code not in git-README-only"
    +-- .checkout/README --
    +README
    +-- .checkout/p1/p1.go --
    +package p1
    +-- .checkout/.svn-log --
    +
    +
    +
    +rsc
    +2017-10-04T15:09:35.963034Z
    +move from vcs-test.swtch.com to vcs-test.golang.org
    +
    +
    +rsc
    +2017-09-27T18:16:14.650893Z
    +add p1
    +
    +
    +rsc
    +2017-09-27T18:00:52.201719Z
    +git
    +
    +
    +-- conf/authz --
    +-- conf/passwd --
    +-- conf/svnserve.conf --
    +-- db/current --
    +0
    +-- db/format --
    +6
    +layout sharded 1000
    +-- db/fs-type --
    +fsfs
    +-- db/fsfs.conf --
    +-- db/min-unpacked-rev --
    +0
    +-- db/revprops/0/0 --
    +K 8
    +svn:date
    +V 27
    +2017-09-22T01:11:53.895835Z
    +END
    +-- db/revs/0/0 --
    +PLAIN
    +END
    +ENDREP
    +id: 0.0.r0/17
    +type: dir
    +count: 0
    +text: 0 0 4 4 2d2977d1c96f487abe4a1e202dd03b4e
    +cpath: /
    +
    +
    +17 107
    +-- db/txn-current --
    +0
    +-- db/txn-current-lock --
    +-- db/uuid --
    +53cccb44-0fca-40a2-b0c5-acaf9e75039a
    +-- db/write-lock --
    +-- format --
    +5
    +-- hooks/pre-revprop-change --
    +#!/bin/sh
    +
    +-- hooks/pre-revprop-change.bat --
    +@exit